diff --git a/.clang-format b/.clang-format index c5979d77ba1..33e5d4f9d0c 100644 --- a/.clang-format +++ b/.clang-format @@ -39,7 +39,60 @@ PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 200 -SortIncludes: false +SortIncludes: CaseSensitive +IncludeBlocks: Regroup +IncludeCategories: + # O2Physics, PWG + - Regex: ^(<|")PWG[A-Z]{2}/.*\.h + Priority: 2 + CaseSensitive: true + # O2Physics, non-PWG + - Regex: ^(<|")(Common|ALICE3|DPG|EventFiltering|Tools|Tutorials)/.*\.h + Priority: 3 + CaseSensitive: true + # O2 + - Regex: ^(<|")(Algorithm|CCDB|Common[A-Z]|DataFormats|DCAFitter|Detectors|EMCAL|Field|Framework|FT0|FV0|GlobalTracking|ITS|MathUtils|MFT|MCH|MID|PHOS|PID|ReconstructionDataFormats|SimulationDataFormat|TOF|TPC|ZDC).*/.*\.h + Priority: 4 + CaseSensitive: true + # ROOT + - Regex: ^(<|")(T[A-Z]|Math/|Roo[A-Z])[[:alnum:]/]+\.h + Priority: 5 + CaseSensitive: true + # known third-party: KFParticle + - Regex: ^(<|")KF[A-Z][[:alnum:]]+\.h + Priority: 6 + CaseSensitive: true + # known third-party: FastJet + - Regex: ^(<|")fastjet/ + Priority: 6 + CaseSensitive: true + # known third-party: ONNX runtime + - Regex: ^(<|")onnxruntime + Priority: 6 + CaseSensitive: true + # incomplete path to DataModel + - Regex: ^(<|").*DataModel/ + Priority: 1 + CaseSensitive: true + # other third-party + - Regex: ^(<|")([[:alnum:]_]+/)+[[:alnum:]_]+\.h + Priority: 6 + CaseSensitive: true + # other local-looking file + - Regex: ^".*\. + Priority: 1 + CaseSensitive: true + # C system + - Regex: ^(<|")[[:lower:]_]+\.h(>|") + Priority: 102 + CaseSensitive: true + # C++ system + - Regex: ^(<|")[[:lower:]_/]+(>|") + Priority: 101 + CaseSensitive: true + # rest + - Regex: .* + Priority: 100 SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false diff --git a/.clang-tidy b/.clang-tidy index da768906bcc..490b82a880b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,3 +1,23 @@ CheckOptions: - - key: CheckPathRegex - value: '.*/O2/.*' + - { key: CheckPathRegex, value: ".*/O2/.*" } + # Naming conventions + - { key: readability-identifier-naming.ClassCase, value: CamelCase } + - { key: readability-identifier-naming.ClassMemberPrefix, value: m } + - { key: readability-identifier-naming.ConceptCase, value: CamelCase } + - { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase } + - { key: readability-identifier-naming.ConstexprVariableIgnoredRegexp, value: "^k[A-Z].*$" } # Allow "k" prefix. + - { key: readability-identifier-naming.EnumCase, value: CamelCase } + - { key: readability-identifier-naming.EnumConstantCase, value: CamelCase } + - { key: readability-identifier-naming.EnumConstantIgnoredRegexp, value: "^k[A-Z].*$" } # Allow "k" prefix. + - { key: readability-identifier-naming.FunctionCase, value: camelBack } + - { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE } + - { key: readability-identifier-naming.MacroDefinitionIgnoredRegexp, value: "^[A-Z]+(_[A-Z]+)*_$" } # Allow the trailing underscore in header guards. + - { key: readability-identifier-naming.MemberCase, value: camelBack } + - { key: readability-identifier-naming.NamespaceCase, value: lower_case } + - { key: readability-identifier-naming.ParameterCase, value: camelBack } + - { key: readability-identifier-naming.StructCase, value: CamelCase } + - { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase } + - { key: readability-identifier-naming.TypeAliasCase, value: CamelCase } + - { key: readability-identifier-naming.TypedefCase, value: CamelCase } + - { key: readability-identifier-naming.TypeTemplateParameterCase, value: CamelCase } + - { key: readability-identifier-naming.VariableCase, value: camelBack } diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000000..e69de29bb2d diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..30ad6d8f005 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +--- +# Dependabot configuration +# Reference: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/labeler.yml b/.github/labeler.yml index b58bc4a81db..7d404c53f68 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -16,6 +16,7 @@ infrastructure: - '.github/**' - '.checkov.yml' - '.mega-linter.yml' + - '.pre-commit-config.yaml' - 'cmake/**' - 'CODEOWNERS' - 'CPPLINT.cfg' @@ -25,7 +26,7 @@ infrastructure: datamodel: - changed-files: - - any-glob-to-any-file: ['DataModel/**', '*/DataModel/**'] + - any-glob-to-any-file: ['DataModel/**', '**/DataModel/**'] dpg: - changed-files: diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index 90f11945ac0..b1bccfc61ca 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -38,7 +38,7 @@ jobs: id: ml # You can override MegaLinter flavor used to have faster performances # More info at https://megalinter.io/flavors/ - uses: oxsecurity/megalinter@v8.3.0 + uses: oxsecurity/megalinter@v8.7.0 env: # All available variables are described in documentation: # https://megalinter.io/configuration/ diff --git a/.github/workflows/o2-linter.yml b/.github/workflows/o2-linter.yml index 8e150e970fd..099209da6e6 100644 --- a/.github/workflows/o2-linter.yml +++ b/.github/workflows/o2-linter.yml @@ -2,10 +2,10 @@ # Find issues in O2 code name: O2 linter -'on': [pull_request, push] +"on": [pull_request_target, push] permissions: {} env: - MAIN_BRANCH: master + BRANCH_MAIN: master concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} @@ -15,20 +15,47 @@ jobs: o2-linter: name: O2 linter runs-on: ubuntu-24.04 + permissions: + pull-requests: write steps: + - name: Set branches + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + branch_head="${{ github.ref }}" + branch_base="${{ env.BRANCH_MAIN }}" + else + branch_head="refs/pull/${{ github.event.pull_request.number }}/merge" + branch_base="${{ github.event.pull_request.base.ref }}" + fi + echo BRANCH_HEAD="$branch_head" >> "$GITHUB_ENV" + echo BRANCH_BASE="$branch_base" >> "$GITHUB_ENV" - name: Checkout Code uses: actions/checkout@v4 with: + ref: ${{ env.BRANCH_HEAD }} fetch-depth: 0 # needed to get the full history - name: Run tests + id: linter run: | - # Diff against the common ancestor of the source branch and the main branch. - readarray -t files < <(git diff --diff-filter d --name-only origin/${{ env.MAIN_BRANCH }}...) + # Diff against the common ancestor of the source (head) branch and the target (base) branch. + echo "Diffing ${{ env.BRANCH_HEAD }} against ${{ env.BRANCH_BASE }}." + readarray -t files < <(git diff --diff-filter d --name-only origin/${{ env.BRANCH_BASE }}...) if [ ${#files[@]} -eq 0 ]; then echo "::notice::No files to lint." + echo "linter_ran=0" >> "$GITHUB_OUTPUT" exit 0 fi - [ ${{ github.event_name }} == 'pull_request' ] && options="-g" + echo "linter_ran=1" >> "$GITHUB_OUTPUT" + [[ "${{ github.event_name }}" == "pull_request_target" ]] && options="-g" # shellcheck disable=SC2086 # Ignore unquoted options. python3 Scripts/o2_linter.py $options "${files[@]}" echo "Tip: If you allow actions in your fork repository, O2 linter will run when you push commits." + - name: Comment PR + if: (success() || failure()) && (github.event_name == 'pull_request_target' && steps.linter.outputs.linter_ran == 1) + uses: thollander/actions-comment-pull-request@v3 + with: + comment-tag: o2-linter + message: "**O2 linter results:** + ❌ ${{ steps.linter.outputs.n_issues }} errors, + ⚠️ ${{ steps.linter.outputs.n_tolerated }} warnings, + 🔕 ${{ steps.linter.outputs.n_disabled }} disabled" diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 8056a231e90..24b650f65b5 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -12,7 +12,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v1 + - uses: actions/stale@v9 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: 'This PR has not been updated in the last 30 days. Is it still needed? Unless further action is taken, it will be closed in 5 days.' diff --git a/.mega-linter.yml b/.mega-linter.yml index 838c5454d14..f0e21bd5c23 100644 --- a/.mega-linter.yml +++ b/.mega-linter.yml @@ -15,7 +15,11 @@ DISABLE_LINTERS: - BASH_SHFMT - CPP_CLANG_FORMAT - JSON_PRETTIER + - PYTHON_BLACK + - PYTHON_FLAKE8 + - PYTHON_ISORT - REPOSITORY_DEVSKIM + - REPOSITORY_GITLEAKS - REPOSITORY_KICS - REPOSITORY_SECRETLINT - REPOSITORY_TRIVY @@ -35,3 +39,5 @@ PYTHON_PYRIGHT_CONFIG_FILE: pyproject.toml PYTHON_RUFF_CONFIG_FILE: pyproject.toml CPP_CPPLINT_FILE_EXTENSIONS: [".C", ".c", ".c++", ".cc", ".cl", ".cpp", ".cu", ".cuh", ".cxx", ".cxx.in", ".h", ".h++", ".hh", ".h.in", ".hpp", ".hxx", ".inc", ".inl", ".macro"] CPP_CLANG_FORMAT_FILE_EXTENSIONS: [".C", ".c", ".c++", ".cc", ".cl", ".cpp", ".cu", ".cuh", ".cxx", ".cxx.in", ".h", ".h++", ".hh", ".h.in", ".hpp", ".hxx", ".inc", ".inl", ".macro"] +CPP_CPPCHECK_ARGUMENTS: --language=c++ --std=c++20 --check-level=exhaustive --suppressions-list=cppcheck_config +REPOSITORY_GITLEAKS_PR_COMMITS_SCAN: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..ebff84266f2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v20.1.5 # clang-format version + hooks: + - id: clang-format + - repo: https://github.com/cpplint/cpplint + rev: 2.0.2 + hooks: + - id: cpplint diff --git a/ALICE3/CMakeLists.txt b/ALICE3/CMakeLists.txt index ab460641cad..10172ee7d01 100644 --- a/ALICE3/CMakeLists.txt +++ b/ALICE3/CMakeLists.txt @@ -14,4 +14,4 @@ add_subdirectory(Core) # add_subdirectory(DataModel) add_subdirectory(Tasks) add_subdirectory(TableProducer) -add_subdirectory(Tools) +# add_subdirectory(Tools) diff --git a/ALICE3/Core/CMakeLists.txt b/ALICE3/Core/CMakeLists.txt index 788711ac277..6d44d580c45 100644 --- a/ALICE3/Core/CMakeLists.txt +++ b/ALICE3/Core/CMakeLists.txt @@ -11,18 +11,27 @@ o2physics_add_library(ALICE3Core SOURCES TOFResoALICE3.cxx + TrackUtilities.cxx DelphesO2TrackSmearer.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore) + PUBLIC_LINK_LIBRARIES O2::Framework + O2Physics::AnalysisCore) o2physics_target_root_dictionary(ALICE3Core HEADERS TOFResoALICE3.h + TrackUtilities.h DelphesO2TrackSmearer.h LINKDEF ALICE3CoreLinkDef.h) o2physics_add_library(FastTracker SOURCES FastTracker.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore) + DetLayer.cxx + DelphesO2LutWriter.cxx + PUBLIC_LINK_LIBRARIES O2::Framework + O2Physics::AnalysisCore + O2Physics::ALICE3Core) o2physics_target_root_dictionary(FastTracker HEADERS FastTracker.h + DetLayer.h + DelphesO2LutWriter.h LINKDEF FastTrackerLinkDef.h) diff --git a/ALICE3/Core/DelphesO2LutWriter.cxx b/ALICE3/Core/DelphesO2LutWriter.cxx new file mode 100644 index 00000000000..987383092ec --- /dev/null +++ b/ALICE3/Core/DelphesO2LutWriter.cxx @@ -0,0 +1,538 @@ +// 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. + +/// +/// @file DelphesO2LutWriter.cxx +/// @brief Porting to O2Physics of DelphesO2 code. +/// Minimal changes have been made to the original code for adaptation purposes, formatting and commented parts have been considered. +/// Relevant sources: +/// DelphesO2/src/lutWrite.cc https://github.com/AliceO2Group/DelphesO2/blob/master/src/lutWrite.cc +/// @author: Roberto Preghenella +/// @email: preghenella@bo.infn.it +/// + +#include "ALICE3/Core/DelphesO2LutWriter.h" + +#include "ALICE3/Core/DelphesO2TrackSmearer.h" +#include "ALICE3/Core/FastTracker.h" +#include "ALICE3/Core/TrackUtilities.h" + +#include "TAxis.h" +#include "TDatabasePDG.h" +#include "TLorentzVector.h" +#include "TMatrixD.h" +#include "TMatrixDSymEigen.h" +#include "TVectorD.h" + +#include +#include + +// #define USE_FWD_PARAM +#ifdef USE_FWD_PARAM +#include "fwdRes.C" +#endif + +namespace o2::fastsim +{ + +void DelphesO2LutWriter::print() const +{ + LOG(info) << " --- Printing configuration of LUT writer --- "; + LOG(info) << " -> etaMaxBarrel = " << etaMaxBarrel; + LOG(info) << " -> usePara = " << usePara; + LOG(info) << " -> useDipole = " << useDipole; + LOG(info) << " -> useFlatDipole = " << useFlatDipole; + LOG(info) << " -> mAtLeastHits = " << mAtLeastHits; + LOG(info) << " -> mAtLeastCorr = " << mAtLeastCorr; + LOG(info) << " -> mAtLeastFake = " << mAtLeastFake; + LOG(info) << " -> Nch Binning: = " << mNchBinning.toString(); + LOG(info) << " -> Radius Binning: = " << mRadiusBinning.toString(); + LOG(info) << " -> Eta Binning: = " << mEtaBinning.toString(); + LOG(info) << " -> Pt Binning: = " << mPtBinning.toString(); + LOG(info) << " --- End of configuration --- "; +} + +std::string DelphesO2LutWriter::LutBinning::toString() const +{ + std::string str = ""; + str.append(log ? "log" : "lin"); + str.append(" nbins: "); + str.append(std::to_string(nbins)); + str.append(" min: "); + str.append(std::to_string(min)); + str.append(" max: "); + str.append(std::to_string(max)); + return str; +} + +bool DelphesO2LutWriter::fatSolve(lutEntry_t& lutEntry, + float pt, + float eta, + const float mass, + size_t itof, + size_t otof, + int q, + const float nch) +{ + lutEntry.valid = false; + + static TLorentzVector tlv; + tlv.SetPtEtaPhiM(pt, eta, 0., mass); + o2::track::TrackParCov trkIn; + o2::upgrade::convertTLorentzVectorToO2Track(q, tlv, {0., 0., 0.}, trkIn); + // tlv.Print(); + // return fmt::format("X:{:+.4e} Alp:{:+.3e} Par: {:+.4e} {:+.4e} {:+.4e} {:+.4e} {:+.4e} |Q|:{:d} {:s}\n", + // getX(), getAlpha(), getY(), getZ(), getSnp(), getTgl(), getQ2Pt(), getAbsCharge(), getPID().getName()); + // trkIn.print(); + o2::track::TrackParCov trkOut; + const int status = fat.FastTrack(trkIn, trkOut, nch); + if (status <= mAtLeastHits) { + LOGF(info, " --- fatSolve: FastTrack failed ---"); + // tlv.Print(); + return false; + } + LOGF(info, " --- fatSolve: FastTrack succeeded %d ---", status); + // trkOut.print(); + lutEntry.valid = true; + lutEntry.itof = fat.GetGoodHitProb(itof); + lutEntry.otof = fat.GetGoodHitProb(otof); + static constexpr int nCov = 15; + for (int i = 0; i < nCov; ++i) + lutEntry.covm[i] = trkOut.getCov()[i]; + + // define the efficiency + auto totfake = 0.; + lutEntry.eff = 1.; + for (size_t i = 1; i < fat.GetNLayers(); ++i) { + if (fat.IsLayerInert(i)) + continue; // skip inert layers + auto igoodhit = fat.GetGoodHitProb(i); + if (igoodhit <= 0. || i == itof || i == otof) + continue; + lutEntry.eff *= igoodhit; + auto pairfake = 0.; + for (size_t j = i + 1; j < fat.GetNLayers(); ++j) { + auto jgoodhit = fat.GetGoodHitProb(j); + if (jgoodhit <= 0. || j == itof || j == otof) + continue; + pairfake = (1. - igoodhit) * (1. - jgoodhit); + break; + } + totfake += pairfake; + } + lutEntry.eff2 = (1. - totfake); + + return true; +} + +#ifdef USE_FWD_PARAM +bool DelphesO2LutWriter::fwdSolve(float* covm, float pt, float eta, float mass) +{ + if (fwdRes(covm, pt, eta, mass) < 0) + return false; + return true; +} +#else +bool DelphesO2LutWriter::fwdSolve(float*, float, float, float) +{ + return false; +} +#endif + +bool DelphesO2LutWriter::fwdPara(lutEntry_t& lutEntry, float pt, float eta, float mass, float Bfield) +{ + lutEntry.valid = false; + + // parametrised forward response; interpolates between FAT at eta = 1.75 and a fixed parametrisation at eta = 4; only diagonal elements + static constexpr float etaLimit = 4.0f; + if (std::fabs(eta) < etaMaxBarrel || std::fabs(eta) > etaLimit) + return false; + + if (!fatSolve(lutEntry, pt, etaMaxBarrel, mass)) + return false; + static constexpr int nCov = 15; + float covmbarrel[nCov] = {0}; + for (int i = 0; i < nCov; ++i) { + covmbarrel[i] = lutEntry.covm[i]; + } + + // parametrisation at eta = 4 + const double beta = 1. / std::sqrt(1 + mass * mass / pt / pt / std::cosh(eta) / std::cosh(eta)); + const float dcaPos = 2.5e-4 / std::sqrt(3); // 2.5 micron/sqrt(3) + const float r0 = 0.5; // layer 0 radius [cm] + const float r1 = 1.3; + const float r2 = 2.5; + const float x0layer = 0.001; // material budget (rad length) per layer + const double sigmaAlpha = 0.0136 / beta / pt * std::sqrt(x0layer * std::cosh(eta)) * (1 + 0.038 * std::log(x0layer * std::cosh(eta))); + const double dcaxyMs = sigmaAlpha * r0 * std::sqrt(1 + r1 * r1 / (r2 - r0) / (r2 - r0)); + const double dcaxy2 = dcaPos * dcaPos + dcaxyMs * dcaxyMs; + + const double dcazMs = sigmaAlpha * r0 * std::cosh(eta); + const double dcaz2 = dcaPos * dcaPos + dcazMs * dcazMs; + + const float Leta = 2.8 / std::sinh(eta) - 0.01 * r0; // m + const double relmomresPos = 10e-6 * pt / 0.3 / Bfield / Leta / Leta * std::sqrt(720. / 15.); + + const float relmomresBarrel = std::sqrt(covmbarrel[14]) * pt; + const float rOuter = 1; // m + const float relmomresPosBarrel = 10e-6 * pt / 0.3 / Bfield / rOuter / rOuter / std::sqrt(720. / 15.); + const float relmomresMSBarrel = std::sqrt(relmomresBarrel * relmomresBarrel - relmomresPosBarrel * relmomresPosBarrel); + + // interpolate MS contrib (rel resolution 0.4 at eta = 4) + const float relmomresMSEta4 = 0.4 / beta * 0.5 / Bfield; + const float relmomresMS = relmomresMSEta4 * std::pow(relmomresMSEta4 / relmomresMSBarrel, (std::fabs(eta) - 4.) / (4. - etaMaxBarrel)); + const float momresTot = pt * std::sqrt(relmomresPos * relmomresPos + relmomresMS * relmomresMS); // total absolute mom reso + + // Fill cov matrix diag + for (int i = 0; i < 15; ++i) + lutEntry.covm[i] = 0; + + lutEntry.covm[0] = covmbarrel[0]; + if (dcaxy2 > lutEntry.covm[0]) + lutEntry.covm[0] = dcaxy2; + lutEntry.covm[2] = covmbarrel[2]; + if (dcaz2 > lutEntry.covm[2]) + lutEntry.covm[2] = dcaz2; + lutEntry.covm[5] = covmbarrel[5]; // sigma^2 sin(phi) + lutEntry.covm[9] = covmbarrel[9]; // sigma^2 tanl + lutEntry.covm[14] = momresTot * momresTot / pt / pt / pt / pt; // sigma^2 1/pt + // Check that all numbers are numbers + for (int i = 0; i < 15; ++i) { + if (std::isnan(lutEntry.covm[i])) { + LOGF(info, " --- lutEntry.covm[%d] is NaN", i); + return false; + } + } + return true; +} + +void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, size_t itof, size_t otof) +{ + + if (useFlatDipole && useDipole) { + LOGF(info, "Both dipole and dipole flat flags are on, please use only one of them"); + return; + } + + // output file + std::ofstream lutFile(filename, std::ofstream::binary); + if (!lutFile.is_open()) { + LOGF(info, "Did not manage to open output file!!"); + return; + } + + // write header + lutHeader_t lutHeader; + // pid + lutHeader.pdg = pdg; + const TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(pdg); + if (!particle) { + LOG(fatal) << "Cannot find particle with PDG code " << pdg; + return; + } + lutHeader.mass = particle->Mass(); + const int q = std::abs(particle->Charge()) / 3; + if (q <= 0) { + LOGF(info, "Negative or null charge (%f) for pdg code %i. Fix the charge!", particle->Charge(), pdg); + return; + } + lutHeader.field = field; + auto setMap = [](map_t& map, LutBinning b) { + map.log = b.log; + map.nbins = b.nbins; + map.min = b.min; + map.max = b.max; + }; + // nch + setMap(lutHeader.nchmap, mNchBinning); + // radius + setMap(lutHeader.radmap, mRadiusBinning); + // eta + setMap(lutHeader.etamap, mEtaBinning); + // pt + setMap(lutHeader.ptmap, mPtBinning); + + lutFile.write(reinterpret_cast(&lutHeader), sizeof(lutHeader)); + + // entries + const int nnch = lutHeader.nchmap.nbins; + const int nrad = lutHeader.radmap.nbins; + const int neta = lutHeader.etamap.nbins; + const int npt = lutHeader.ptmap.nbins; + lutEntry_t lutEntry; + + // write entries + int nCalls = 0; + int successfullCalls = 0; + int failedCalls = 0; + for (int inch = 0; inch < nnch; ++inch) { + LOGF(info, " --- writing nch = %d/%d", inch, nnch); + auto nch = lutHeader.nchmap.eval(inch); + lutEntry.nch = nch; + fat.SetdNdEtaCent(nch); + for (int irad = 0; irad < nrad; ++irad) { + LOGF(info, " --- writing irad = %d/%d", irad, nrad); + for (int ieta = 0; ieta < neta; ++ieta) { + LOGF(info, " --- writing ieta = %d/%d", ieta, neta); + auto eta = lutHeader.etamap.eval(ieta); + lutEntry.eta = lutHeader.etamap.eval(ieta); + for (int ipt = 0; ipt < npt; ++ipt) { + nCalls++; + LOGF(info, " --- writing ipt = %d/%d", ipt, npt); + lutEntry.pt = lutHeader.ptmap.eval(ipt); + lutEntry.valid = true; + if (std::fabs(eta) <= etaMaxBarrel) { // full lever arm ends at etaMaxBarrel + LOGF(info, "Solving in the barrel"); + // LOGF(info, " --- fatSolve: pt = %f, eta = %f, mass = %f, field=%f", lutEntry.pt, lutEntry.eta, lutHeader.mass, lutHeader.field); + successfullCalls++; + if (!fatSolve(lutEntry, lutEntry.pt, lutEntry.eta, lutHeader.mass, itof, otof, q)) { + // LOGF(info, " --- fatSolve: error"); + lutEntry.valid = false; + lutEntry.eff = 0.; + lutEntry.eff2 = 0.; + for (int i = 0; i < 15; ++i) { + lutEntry.covm[i] = 0.; + } + successfullCalls--; + failedCalls++; + } + } else { + LOGF(info, "Solving outside the barrel"); + // LOGF(info, " --- fwdSolve: pt = %f, eta = %f, mass = %f, field=%f", lutEntry.pt, lutEntry.eta, lutHeader.mass, lutHeader.field); + lutEntry.eff = 1.; + lutEntry.eff2 = 1.; + bool retval = true; + successfullCalls++; + if (useFlatDipole) { // Using the parametrization at the border of the barrel + retval = fatSolve(lutEntry, lutEntry.pt, etaMaxBarrel, lutHeader.mass, itof, otof, q); + } else if (usePara) { + retval = fwdPara(lutEntry, lutEntry.pt, lutEntry.eta, lutHeader.mass, field); + } else { + retval = fwdSolve(lutEntry.covm, lutEntry.pt, lutEntry.eta, lutHeader.mass); + } + if (useDipole) { // Using the parametrization at the border of the barrel only for efficiency and momentum resolution + lutEntry_t lutEntryBarrel; + retval = fatSolve(lutEntryBarrel, lutEntry.pt, etaMaxBarrel, lutHeader.mass, itof, otof, q); + lutEntry.valid = lutEntryBarrel.valid; + lutEntry.covm[14] = lutEntryBarrel.covm[14]; + lutEntry.eff = lutEntryBarrel.eff; + lutEntry.eff2 = lutEntryBarrel.eff2; + } + if (!retval) { + LOGF(info, " --- fwdSolve: error"); + lutEntry.valid = false; + for (int i = 0; i < 15; ++i) { + lutEntry.covm[i] = 0.; + } + successfullCalls--; + failedCalls++; + } + } + LOGF(info, "Diagonalizing"); + diagonalise(lutEntry); + LOGF(info, "Writing"); + lutFile.write(reinterpret_cast(&lutEntry), sizeof(lutEntry_t)); + } + } + } + } + LOGF(info, " --- finished writing LUT file %s", filename); + LOGF(info, " --- successfull calls: %d/%d, failed calls: %d/%d", successfullCalls, nCalls, failedCalls, nCalls); + lutFile.close(); +} + +void DelphesO2LutWriter::diagonalise(lutEntry_t& lutEntry) +{ + static constexpr int kEig = 5; + TMatrixDSym m(kEig); + for (int i = 0, k = 0; i < kEig; ++i) { + for (int j = 0; j < i + 1; ++j, ++k) { + m(i, j) = lutEntry.covm[k]; + m(j, i) = lutEntry.covm[k]; + } + } + + // m.Print(); + TMatrixDSymEigen eigen(m); + // eigenvalues vector + TVectorD eigenVal = eigen.GetEigenValues(); + for (int i = 0; i < kEig; ++i) + lutEntry.eigval[i] = eigenVal[i]; + // eigenvectors matrix + TMatrixD eigenVec = eigen.GetEigenVectors(); + for (int i = 0; i < kEig; ++i) + for (int j = 0; j < kEig; ++j) + lutEntry.eigvec[i][j] = eigenVec[i][j]; + // inverse eigenvectors matrix + eigenVec.Invert(); + for (int i = 0; i < kEig; ++i) + for (int j = 0; j < kEig; ++j) + lutEntry.eiginv[i][j] = eigenVec[i][j]; +} + +TGraph* DelphesO2LutWriter::lutRead(const char* filename, int pdg, int what, int vs, float nch, float radius, float eta, float pt) +{ + LOGF(info, " --- reading LUT file %s", filename); + // vs + static const int kNch = 0; + static const int kEta = 1; + static const int kPt = 2; + + // what + static const int kEfficiency = 0; + static const int kEfficiency2 = 1; + static const int kEfficiencyInnerTOF = 2; + static const int kEfficiencyOuterTOF = 3; + static const int kPtResolution = 4; + static const int kRPhiResolution = 5; + static const int kZResolution = 6; + + o2::delphes::DelphesO2TrackSmearer smearer; + smearer.loadTable(pdg, filename); + auto lutHeader = smearer.getLUTHeader(pdg); + lutHeader->print(); + map_t lutMap; + switch (vs) { + case kNch: + lutMap = lutHeader->nchmap; + break; + case kEta: + lutMap = lutHeader->etamap; + break; + case kPt: + lutMap = lutHeader->ptmap; + break; + } + auto nbins = lutMap.nbins; + auto g = new TGraph(); + g->SetName(Form("lut_%s_%d_vs_%d_what_%d", filename, pdg, vs, what)); + g->SetTitle(Form("LUT for %s, pdg %d, vs %d, what %d", filename, pdg, vs, what)); + switch (vs) { + case kNch: + LOGF(info, " --- vs = kNch"); + g->GetXaxis()->SetTitle("Nch"); + break; + case kEta: + LOGF(info, " --- vs = kEta"); + g->GetXaxis()->SetTitle("#eta"); + break; + case kPt: + LOGF(info, " --- vs = kPt"); + g->GetXaxis()->SetTitle("p_{T} (GeV/c)"); + break; + default: + LOGF(info, " --- error: unknown vs %d", vs); + return nullptr; + } + switch (what) { + case kEfficiency: + LOGF(info, " --- what = kEfficiency"); + g->GetYaxis()->SetTitle("Efficiency (%)"); + break; + case kEfficiency2: + LOGF(info, " --- what = kEfficiency2"); + g->GetYaxis()->SetTitle("Efficiency2 (%)"); + break; + case kEfficiencyInnerTOF: + LOGF(info, " --- what = kEfficiencyInnerTOF"); + g->GetYaxis()->SetTitle("Inner TOF Efficiency (%)"); + break; + case kEfficiencyOuterTOF: + LOGF(info, " --- what = kEfficiencyOuterTOF"); + g->GetYaxis()->SetTitle("Outer TOF Efficiency (%)"); + break; + case kPtResolution: + LOGF(info, " --- what = kPtResolution"); + g->GetYaxis()->SetTitle("p_{T} Resolution (%)"); + break; + case kRPhiResolution: + LOGF(info, " --- what = kRPhiResolution"); + g->GetYaxis()->SetTitle("R#phi Resolution (#mum)"); + break; + case kZResolution: + LOGF(info, " --- what = kZResolution"); + g->GetYaxis()->SetTitle("Z Resolution (#mum)"); + break; + default: + LOGF(info, " --- error: unknown what %d", what); + return nullptr; + } + + bool canBeInvalid = true; + for (int i = 0; i < nbins; ++i) { + switch (vs) { + case kNch: + nch = lutMap.eval(i); + break; + case kEta: + eta = lutMap.eval(i); + break; + case kPt: + pt = lutMap.eval(i); + break; + } + float eff = 0.; + auto lutEntry = smearer.getLUTEntry(pdg, nch, radius, eta, pt, eff); + if (!lutEntry->valid || lutEntry->eff == 0.) { + if (!canBeInvalid) { + LOGF(info, " --- warning: it cannot be invalid"); + } + continue; + } + canBeInvalid = false; + + double cen = 0.; + switch (vs) { + case kNch: + cen = lutEntry->nch; + break; + case kEta: + cen = lutEntry->eta; + break; + case kPt: + cen = lutEntry->pt; + break; + } + double val = 0.; + switch (what) { + case kEfficiency: + val = lutEntry->eff * 100.; // efficiency (%) + break; + case kEfficiency2: + val = lutEntry->eff2 * 100.; // efficiency (%) + break; + case kEfficiencyInnerTOF: + val = lutEntry->itof * 100.; // efficiency (%) + break; + case kEfficiencyOuterTOF: + val = lutEntry->otof * 100.; // efficiency (%) + break; + case kPtResolution: + val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt * 100.; // pt resolution (%) + break; + case kRPhiResolution: + val = std::sqrt(lutEntry->covm[0]) * 1.e4; // rphi resolution (um) + break; + case kZResolution: + val = std::sqrt(lutEntry->covm[1]) * 1.e4; // z resolution (um) + break; + default: + LOGF(info, " --- error: unknown what %d", what); + break; + } + g->AddPoint(cen, val); + } + + return g; +} +} // namespace o2::fastsim + +ClassImp(o2::fastsim::DelphesO2LutWriter); diff --git a/ALICE3/Core/DelphesO2LutWriter.h b/ALICE3/Core/DelphesO2LutWriter.h new file mode 100644 index 00000000000..1528ab80bac --- /dev/null +++ b/ALICE3/Core/DelphesO2LutWriter.h @@ -0,0 +1,94 @@ +// 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. +/// \file DelphesO2LutWriter.h +/// \brief Porting to O2Physics of DelphesO2 code. +/// Minimal changes have been made to the original code for adaptation purposes, formatting and commented parts have been considered. +/// Relevant sources: +/// DelphesO2/src/lutWrite.cc https://github.com/AliceO2Group/DelphesO2/blob/master/src/lutWrite.cc +/// \author: Roberto Preghenella +/// \email: preghenella@bo.infn.it +/// + +#ifndef ALICE3_CORE_DELPHESO2LUTWRITER_H_ +#define ALICE3_CORE_DELPHESO2LUTWRITER_H_ + +#include "ALICE3/Core/DelphesO2TrackSmearer.h" +#include "ALICE3/Core/FastTracker.h" + +#include "ReconstructionDataFormats/PID.h" + +#include "TGraph.h" + +#include + +namespace o2::fastsim +{ +class DelphesO2LutWriter +{ + public: + DelphesO2LutWriter() = default; + virtual ~DelphesO2LutWriter() = default; + + // Setters + void setBinningNch(bool log, int nbins, float min, float max) { mNchBinning = {log, nbins, min, max}; } + void setBinningRadius(bool log, int nbins, float min, float max) { mRadiusBinning = {log, nbins, min, max}; } + void setBinningEta(bool log, int nbins, float min, float max) { mEtaBinning = {log, nbins, min, max}; } + void setBinningPt(bool log, int nbins, float min, float max) { mPtBinning = {log, nbins, min, max}; } + void setEtaMaxBarrel(float eta) { etaMaxBarrel = eta; } + void setAtLeastHits(int n) { mAtLeastHits = n; } + void setAtLeastCorr(int n) { mAtLeastCorr = n; } + void setAtLeastFake(int n) { mAtLeastFake = n; } + bool fatSolve(lutEntry_t& lutEntry, + float pt = 0.1, + float eta = 0.0, + const float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion], + size_t itof = 0, + size_t otof = 0, + int q = 1, + const float nch = 1); + + void print() const; + bool fwdSolve(float* covm, float pt = 0.1, float eta = 0.0, float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion]); + bool fwdPara(lutEntry_t& lutEntry, float pt = 0.1, float eta = 0.0, float mass = o2::track::pid_constants::sMasses[o2::track::PID::Pion], float Bfield = 0.5); + void lutWrite(const char* filename = "lutCovm.dat", int pdg = 211, float field = 0.2, size_t itof = 0, size_t otof = 0); + TGraph* lutRead(const char* filename, int pdg, int what, int vs, float nch = 0., float radius = 0., float eta = 0., float pt = 0.); + + o2::fastsim::FastTracker fat; + + private: + void diagonalise(lutEntry_t& lutEntry); + float etaMaxBarrel = 1.75f; + bool usePara = true; // use fwd parameterisation + bool useDipole = false; // use dipole i.e. flat parametrization for efficiency and momentum resolution + bool useFlatDipole = false; // use dipole i.e. flat parametrization outside of the barrel + + int mAtLeastHits = 4; + int mAtLeastCorr = 4; + int mAtLeastFake = 0; + + // Binning of the LUT to make + struct LutBinning { + bool log; + int nbins; + float min; + float max; + std::string toString() const; + }; + LutBinning mNchBinning = {true, 20, 0.5f, 3.5f}; + LutBinning mRadiusBinning = {false, 1, 0.0f, 100.0f}; + LutBinning mEtaBinning = {false, 80, -4.0f, 4.0f}; + LutBinning mPtBinning = {true, 200, -2.0f, 2.0f}; + + ClassDef(DelphesO2LutWriter, 1); +}; +} // namespace o2::fastsim + +#endif // ALICE3_CORE_DELPHESO2LUTWRITER_H_ diff --git a/ALICE3/Core/DetLayer.cxx b/ALICE3/Core/DetLayer.cxx new file mode 100644 index 00000000000..25e61e6e6d5 --- /dev/null +++ b/ALICE3/Core/DetLayer.cxx @@ -0,0 +1,91 @@ +// 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. + +/// +/// \file DetLayer.cxx +/// \author David Dobrigkeit Chinellato +/// \since 11/03/2021 +/// \brief Basic struct to hold information regarding a detector layer to be used in fast simulation +/// + +#include +#include + +#include "DetLayer.h" + +namespace o2::fastsim +{ + +// Parametric constructor +DetLayer::DetLayer(const TString& name_, + float r_, + float z_, + float x0_, + float xrho_, + float resRPhi_, + float resZ_, + float eff_, + int type_) + : name(name_), + r(r_), + z(z_), + x0(x0_), + xrho(xrho_), + resRPhi(resRPhi_), + resZ(resZ_), + eff(eff_), + type(type_) +{ +} + +DetLayer::DetLayer(const DetLayer& other) + : name(other.name), r(other.r), z(other.z), x0(other.x0), xrho(other.xrho), resRPhi(other.resRPhi), resZ(other.resZ), eff(other.eff), type(other.type) +{ +} + +std::string DetLayer::toString() const +{ + std::string out = ""; + out.append("DetLayer: "); + out.append(name.Data()); + out.append(" | r: "); + out.append(std::to_string(r)); + out.append(" cm | z: "); + out.append(std::to_string(z)); + out.append(" cm | x0: "); + out.append(std::to_string(x0)); + out.append(" cm | xrho: "); + out.append(std::to_string(xrho)); + out.append(" g/cm^3 | resRPhi: "); + out.append(std::to_string(resRPhi)); + out.append(" cm | resZ: "); + out.append(std::to_string(resZ)); + out.append(" cm | eff: "); + out.append(std::to_string(eff)); + out.append(" | type: "); + switch (type) { + case layerInert: + out.append("Inert"); + break; + case layerSilicon: + out.append("Silicon"); + break; + case layerGas: + out.append("Gas/TPC"); + break; + default: + out.append("Unknown"); + break; + } + return out; +} + +} // namespace o2::fastsim diff --git a/ALICE3/Core/DetLayer.h b/ALICE3/Core/DetLayer.h index 6b9fea14c06..2577c73e42d 100644 --- a/ALICE3/Core/DetLayer.h +++ b/ALICE3/Core/DetLayer.h @@ -19,12 +19,59 @@ #ifndef ALICE3_CORE_DETLAYER_H_ #define ALICE3_CORE_DETLAYER_H_ +#include + #include "TString.h" namespace o2::fastsim { struct DetLayer { + public: + // Default constructor + DetLayer() = default; + // Parametric constructor + DetLayer(const TString& name_, float r_, float z_, float x0_, float xrho_, + float resRPhi_ = 0.0f, float resZ_ = 0.0f, float eff_ = 0.0f, int type_ = layerInert); + // Copy constructor + DetLayer(const DetLayer& other); + + // Setters + void setName(const TString& name_) { name = name_; } + void setRadius(float r_) { r = r_; } + void setZ(float z_) { z = z_; } + void setRadiationLength(float x0_) { x0 = x0_; } + void setDensity(float xrho_) { xrho = xrho_; } + void setResolutionRPhi(float resRPhi_) { resRPhi = resRPhi_; } + void setResolutionZ(float resZ_) { resZ = resZ_; } + void setEfficiency(float eff_) { eff = eff_; } + void setType(int type_) { type = type_; } + + // Getters + float getRadius() const { return r; } + float getZ() const { return z; } + float getRadiationLength() const { return x0; } + float getDensity() const { return xrho; } + float getResolutionRPhi() const { return resRPhi; } + float getResolutionZ() const { return resZ; } + float getEfficiency() const { return eff; } + int getType() const { return type; } + const TString& getName() const { return name; } + + // Check layer type + bool isInert() const { return type == layerInert; } + bool isSilicon() const { return type == layerSilicon; } + bool isGas() const { return type == layerGas; } + + // Utilities + std::string toString() const; + friend std::ostream& operator<<(std::ostream& os, const DetLayer& layer) + { + os << layer.toString(); + return os; + } + + private: // TString for holding name TString name; @@ -44,7 +91,10 @@ struct DetLayer { float eff; // detection efficiency // layer type - int type; // 0: undefined/inert, 1: silicon, 2: gas/tpc + int type; // 0: undefined/inert, 1: silicon, 2: gas/tpc + static constexpr int layerInert = 0; // inert/undefined layer + static constexpr int layerSilicon = 1; // silicon layer + static constexpr int layerGas = 2; // gas/tpc layer }; } // namespace o2::fastsim diff --git a/ALICE3/Core/FastTracker.cxx b/ALICE3/Core/FastTracker.cxx index 715ed9343e2..15ac7939af2 100644 --- a/ALICE3/Core/FastTracker.cxx +++ b/ALICE3/Core/FastTracker.cxx @@ -9,12 +9,17 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include +#include "FastTracker.h" + +#include "ReconstructionDataFormats/TrackParametrization.h" + #include "TMath.h" #include "TMatrixD.h" -#include "TRandom.h" #include "TMatrixDSymEigen.h" -#include "FastTracker.h" +#include "TRandom.h" + +#include +#include namespace o2 { @@ -23,26 +28,52 @@ namespace fastsim // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ -FastTracker::FastTracker() +void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type) { - // base constructor - magneticField = 5; // in kiloGauss - applyZacceptance = false; - covMatFactor = 0.99f; - verboseLevel = 0; - - // last fast-tracked track properties - covMatOK = 0; - covMatNotOK = 0; - nIntercepts = 0; - nSiliconPoints = 0; - nGasPoints = 0; + DetLayer newLayer(name, r, z, x0, xrho, resRPhi, resZ, eff, type); + // Check that efficient layers are not inert layers + if (newLayer.getEfficiency() > 0.0f && newLayer.isInert()) { + LOG(error) << "Layer " << name << " with efficiency > 0.0 should not be inert"; + } + // Layers should be ordered by increasing radius, check this + if (!layers.empty() && newLayer.getRadius() < layers.back().getRadius()) { + LOG(fatal) << "Layer " << newLayer << " is not ordered correctly, it should be after layer " << layers.back(); + } + // Layers should all have different names + for (const auto& layer : layers) { + if (layer.getName() == newLayer.getName()) { + LOG(fatal) << "Layer with name " << newLayer.getName() << " already exists in FastTracker layers"; + } + } + // Add the new layer to the layers vector + layers.push_back(newLayer); } -void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type) +DetLayer FastTracker::GetLayer(int layer, bool ignoreBarrelLayers) const { - DetLayer newLayer{name.Data(), r, z, x0, xrho, resRPhi, resZ, eff, type}; - layers.push_back(newLayer); + int layerIdx = layer; + if (ignoreBarrelLayers) { + for (int il = 0, trackingLayerIdx = 0; trackingLayerIdx <= layer; il++) { + if (layers[il].isInert()) + continue; + trackingLayerIdx++; + layerIdx = il; + } + } + return layers[layerIdx]; +} + +int FastTracker::GetLayerIndex(const std::string& name) const +{ + int i = 0; + for (const auto& layer : layers) { + if (layer.getName() == name) { + return i; + } + i++; + } + LOG(error) << "Layer with name " << name << " not found in FastTracker layers"; + return -1; } void FastTracker::Print() @@ -51,67 +82,66 @@ void FastTracker::Print() LOG(info) << "+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+"; LOG(info) << " Printing detector layout with " << layers.size() << " effective elements: "; for (uint32_t il = 0; il < layers.size(); il++) { - LOG(info) << " Layer #" << il << "\t" << layers[il].name.Data() << "\tr = " << Form("%.2f", layers[il].r) << "cm\tz = " << layers[il].z << "\t" - << "x0 = " << layers[il].x0 << "\txrho = " << layers[il].xrho << "\tresRPhi = " << layers[il].resRPhi << "\tresZ = " << layers[il].resZ << "\teff = " << layers[il].eff; + LOG(info) << " Layer #" << il << "\t" << layers[il]; } LOG(info) << "+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+"; } -void FastTracker::AddSiliconALICE3v4() +void FastTracker::AddSiliconALICE3v4(std::vector pixelResolution) { - LOG(info) << " Adding ALICE 3 v4 ITS layers"; + LOG(info) << " ALICE 3: Adding v4 tracking layers"; float x0IT = 0.001; // 0.1% float x0OT = 0.005; // 0.5% float xrhoIB = 1.1646e-02; // 50 mum Si - float xrhoOB = 1.1646e-01; // 500 mum Si - - float resRPhiIT = 0.00025; // 2.5 mum - float resZIT = 0.00025; // 2.5 mum - float resRPhiOT = 0.0005; // 5 mum - float resZOT = 0.0005; // 5 mum + float xrhoOT = 1.1646e-01; // 500 mum Si float eff = 1.00; - layers.push_back(DetLayer{"bpipe0", 0.48, 250, 0.00042, 2.772e-02, 0.0f, 0.0f, 0.0f, 0}); // 150 mum Be - layers.push_back(DetLayer{"ddd0", 0.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1}); - layers.push_back(DetLayer{"ddd1", 1.2, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1}); - layers.push_back(DetLayer{"ddd2", 2.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1}); - layers.push_back(DetLayer{"bpipe1", 5.7, 250, 0.0014, 9.24e-02, 0.0f, 0.0f, 0.0f, 0}); // 500 mum Be - layers.push_back(DetLayer{"ddd3", 7., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"ddd4", 10., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"ddd5", 13., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"ddd6", 16., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"ddd7", 25., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"ddd8", 40., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"ddd9", 45., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); + float resRPhiIT = pixelResolution[0]; + float resZIT = pixelResolution[1]; + float resRPhiOT = pixelResolution[2]; + float resZOT = pixelResolution[3]; + + AddLayer("bpipe0", 0.48, 250, 0.00042, 2.772e-02, 0.0f, 0.0f, 0.0f, 0); // 150 mum Be + AddLayer("ddd0", 0.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1); + AddLayer("ddd1", 1.2, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1); + AddLayer("ddd2", 2.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1); + AddLayer("bpipe1", 5.7, 250, 0.0014, 9.24e-02, 0.0f, 0.0f, 0.0f, 0); // 500 mum Be + AddLayer("ddd3", 7., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("ddd4", 10., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("ddd5", 13., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("ddd6", 16., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("ddd7", 25., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("ddd8", 40., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("ddd9", 45., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); } -void FastTracker::AddSiliconALICE3v1() +void FastTracker::AddSiliconALICE3v2(std::vector pixelResolution) { - LOG(info) << " Adding ALICE 3 v1 ITS layers"; + LOG(info) << "ALICE 3: Adding v2 tracking layers;"; float x0IT = 0.001; // 0.1% - float x0OT = 0.005; // 0.5% + float x0OT = 0.01; // 1.0% float xrhoIB = 2.3292e-02; // 100 mum Si - float xrhoOB = 2.3292e-01; // 1000 mum Si - - float resRPhiIT = 0.00025; // 2.5 mum - float resZIT = 0.00025; // 2.5 mum - float resRPhiOT = 0.00100; // 5 mum - float resZOT = 0.00100; // 5 mum + float xrhoOT = 2.3292e-01; // 1000 mum Si float eff = 1.00; - layers.push_back(DetLayer{"bpipe0", 0.48, 250, 0.00042, 2.772e-02, 0.0f, 0.0f, 0.0f, 1}); // 150 mum Be - layers.push_back(DetLayer{"B00", 0.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1}); - layers.push_back(DetLayer{"B01", 1.2, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1}); - layers.push_back(DetLayer{"B02", 2.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1}); - layers.push_back(DetLayer{"bpipe1", 3.7, 250, 0.0014, 9.24e-02, 0.0f, 0.0f, 0.0f, 1}); // 500 mum Be - layers.push_back(DetLayer{"B03", 3.75, 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"B04", 7., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"B05", 12., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"B06", 20., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"B07", 30., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"B08", 45., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"B09", 60., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); - layers.push_back(DetLayer{"B10", 80., 250, x0OT, xrhoOB, resRPhiOT, resZOT, eff, 1}); + float resRPhiIT = pixelResolution[0]; + float resZIT = pixelResolution[1]; + float resRPhiOT = pixelResolution[2]; + float resZOT = pixelResolution[3]; + + AddLayer("bpipe0", 0.48, 250, 0.00042, 2.772e-02, 0.0f, 0.0f, 0.0f, 0); // 150 mum Be + AddLayer("B00", 0.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1); + AddLayer("B01", 1.2, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1); + AddLayer("B02", 2.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1); + AddLayer("bpipe1", 3.7, 250, 0.0014, 9.24e-02, 0.0f, 0.0f, 0.0f, 0); // 500 mum Be + AddLayer("B03", 3.75, 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("B04", 7., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("B05", 12., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("B06", 20., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("B07", 30., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("B08", 45., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("B09", 60., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); + AddLayer("B10", 80., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1); } void FastTracker::AddTPC(float phiResMean, float zResMean) @@ -120,7 +150,7 @@ void FastTracker::AddTPC(float phiResMean, float zResMean) // porting of DetectorK::AddTPC // see here: - // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx + // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L522 // % Radiation Lengths ... Average per TPC row (i.e. total/159 ) const int kNPassiveBound = 2; const float radLBoundary[kNPassiveBound] = {1.692612e-01, 8.711904e-02}; @@ -159,106 +189,236 @@ void FastTracker::AddTPC(float phiResMean, float zResMean) } } +float FastTracker::Dist(float z, float r) +{ + // porting of DetektorK::Dist + // see here: + // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L743 + int index = 1; + int nSteps = 301; + float dist = 0.0; + float dz0 = (4 * sigmaD - (-4) * sigmaD / (nSteps = 1)); + float z0 = 0.0; + for (int i = 0; i < nSteps; i++) { + if (i == nSteps - 1) + index = 1; + z0 = -4 * sigmaD + i * dz0; + dist += index * (dz0 / 3.) * (1 / o2::math_utils::sqrt(o2::constants::math::TwoPI) / sigmaD) * std::exp(-z0 * z0 / 2. / sigmaD / sigmaD) * (1 / o2::math_utils::sqrt((z - z0) * (z - z0) + r * r)); + if (index != 4) + index = 4; + else + index = 2; + } + return dist; +} + +float FastTracker::OneEventHitDensity(float multiplicity, float radius) +{ + // porting of DetektorK::OneEventHitDensity + // see here: + // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L694 + float den = multiplicity / (o2::constants::math::TwoPI * radius * radius); + float tg = o2::math_utils::tan(2. * o2::math_utils::atan(-avgRapidity)); + den = den / o2::math_utils::sqrt(1 + 1 / (tg * tg)); + return den; +} + +float FastTracker::IntegratedHitDensity(float multiplicity, float radius) +{ + // porting of DetektorK::IntegratedHitDensity + // see here: + // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L712 + float zdcHz = luminosity * 1.e24 * mCrossSectionMinB; + float den = zdcHz * integrationTime / 1000. * multiplicity * Dist(0., radius) / (o2::constants::math::TwoPI * radius); + if (den < OneEventHitDensity(multiplicity, radius)) + den = OneEventHitDensity(multiplicity, radius); + return den; +} + +float FastTracker::UpcHitDensity(float radius) +{ + // porting of DetektorK::UpcHitDensity + // see here: + // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L727 + float mUPCelectrons = 0; + mUPCelectrons = lhcUPCScale * 5456 / (radius * radius) / dNdEtaMinB; + if (mUPCelectrons < 0) + mUPCelectrons = 0.0; + mUPCelectrons *= IntegratedHitDensity(dNdEtaMinB, radius); + mUPCelectrons *= upcBackgroundMultiplier; + return mUPCelectrons; +} + +float FastTracker::HitDensity(float radius) +{ + // porting of DetektorK::HitDensity + // see here: + // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L663 + float arealDensity = 0.; + if (radius > maxRadiusSlowDet) { + arealDensity = OneEventHitDensity(dNdEtaCent, radius); + arealDensity += otherBackground * OneEventHitDensity(dNdEtaMinB, radius); + } + + // In the version of Delphes used to produce + // Look-up tables, UpcHitDensity(radius) always returns 0, + // hence it is left commented out for now + if (radius < maxRadiusSlowDet) { + arealDensity = OneEventHitDensity(dNdEtaCent, radius); + arealDensity += otherBackground * OneEventHitDensity(dNdEtaMinB, radius) + IntegratedHitDensity(dNdEtaMinB, radius); + // +UpcHitDensity(radius); + } + return arealDensity; +} + +float FastTracker::ProbGoodChiSqHit(float radius, float searchRadiusRPhi, float searchRadiusZ) +{ + // porting of DetektorK::ProbGoodChiSqHit + // see here: + // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx#L629 + float sx, goodHit; + sx = o2::constants::math::TwoPI * searchRadiusRPhi * searchRadiusZ * HitDensity(radius); + goodHit = 1. / (1 + sx); + return goodHit; +} + // function to provide a reconstructed track from a perfect input track // returns number of intercepts (generic for now) -int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackParCov& outputTrack) +int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackParCov& outputTrack, const float nch) { + dNdEtaCent = nch; // set the number of charged particles per unit rapidity hits.clear(); nIntercepts = 0; nSiliconPoints = 0; nGasPoints = 0; std::array posIni; // provision for != PV inputTrack.getXYZGlo(posIni); - float initialRadius = std::hypot(posIni[0], posIni[1]); + const float initialRadius = std::hypot(posIni[0], posIni[1]); + const float kTrackingMargin = 0.1; + const int kMaxNumberOfDetectors = 20; + if (kMaxNumberOfDetectors < layers.size()) { + LOG(fatal) << "Too many layers in FastTracker, increase kMaxNumberOfDetectors"; + return -1; // too many layers + } + int firstActiveLayer = -1; // first layer that is not inert + for (size_t i = 0; i < layers.size(); ++i) { + if (!layers[i].isInert()) { + firstActiveLayer = i; + break; + } + } + if (firstActiveLayer <= 0) { + LOG(fatal) << "No active layers found in FastTracker, check layer setup"; + return -2; // no active layers + } + const int xrhosteps = 100; + const bool applyAngularCorrection = true; + + goodHitProbability.clear(); + for (int i = 0; i < kMaxNumberOfDetectors; ++i) { + goodHitProbability.push_back(-1.); + } + goodHitProbability[0] = 1.; // we use layer zero to accumulate // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ // Outward pass to find intercepts int firstLayerReached = -1; int lastLayerReached = -1; - for (uint32_t il = 0; il < layers.size(); il++) { + new (&outputTrack)(o2::track::TrackParCov)(inputTrack); + for (size_t il = 0; il < layers.size(); il++) { // check if layer is doable - if (layers[il].r < initialRadius) + if (layers[il].getRadius() < initialRadius) { continue; // this layer should not be attempted, but go ahead - if (layers[il].type == 0) - continue; // inert layer, skip + } // check if layer is reached float targetX = 1e+3; - inputTrack.getXatLabR(layers[il].r, targetX, magneticField); - if (targetX > 999) + inputTrack.getXatLabR(layers[il].getRadius(), targetX, magneticField); + if (targetX > 999.f) { + LOGF(debug, "Failed to find intercept for layer %d at radius %.2f cm", il, layers[il].getRadius()); break; // failed to find intercept + } - if (!inputTrack.propagateTo(targetX, magneticField)) { - break; // failed to propagate + bool ok = inputTrack.propagateTo(targetX, magneticField); + if (ok && mApplyMSCorrection && layers[il].getRadiationLength() > 0) { + ok = inputTrack.correctForMaterial(layers[il].getRadiationLength(), 0, applyAngularCorrection); } - if (std::abs(inputTrack.getZ()) > layers[il].z && applyZacceptance) { + if (ok && mApplyElossCorrection && layers[il].getDensity() > 0) { // correct in small steps + for (int ise = xrhosteps; ise--;) { + ok = inputTrack.correctForMaterial(0, -layers[il].getDensity() / xrhosteps, applyAngularCorrection); + if (!ok) + break; + } + } + LOGF(debug, "Propagation was %s up to layer %d", ok ? "successful" : "unsuccessful", il); + + // was there a problem on this layer? + if (!ok && il > 0) { // may fail to reach target layer due to the eloss + float rad2 = inputTrack.getX() * inputTrack.getX() + inputTrack.getY() * inputTrack.getY(); + float maxR = layers[il - 1].getRadius() + kTrackingMargin * 2; + float minRad = (fMinRadTrack > 0 && fMinRadTrack < maxR) ? fMinRadTrack : maxR; + if (rad2 - minRad * minRad < kTrackingMargin * kTrackingMargin) { // check previously reached layer + return -5; // did not reach min requested layer + } else { + break; + } + } + if (std::abs(inputTrack.getZ()) > layers[il].getZ() && mApplyZacceptance) { break; // out of acceptance bounds } + if (layers[il].isInert()) { + if (mVerboseLevel > 0) { + LOG(info) << "Skipping inert layer: " << layers[il].getName() << " at radius " << layers[il].getRadius() << " cm"; + } + continue; // inert layer, skip + } + // layer is reached - if (firstLayerReached < 0) + if (firstLayerReached < 0) { + LOGF(debug, "First layer reached: %d", il); firstLayerReached = il; + } lastLayerReached = il; nIntercepts++; } // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ // initialize track at outer point - new (&outputTrack)(o2::track::TrackParCov)(inputTrack); + o2::track::TrackParCov inwardTrack(inputTrack); // Enlarge covariance matrix - std::array trPars = {0.}; - for (int ip = 0; ip < 5; ip++) { + std::array trPars = {0.}; + for (int ip = 0; ip < o2::track::kNParams; ip++) { trPars[ip] = outputTrack.getParam(ip); } - std::array largeCov = {0.}; - enum { kY, - kZ, - kSnp, - kTgl, - kPtI }; // track parameter aliases - enum { kY2, - kYZ, - kZ2, - kYSnp, - kZSnp, - kSnp2, - kYTgl, - kZTgl, - kSnpTgl, - kTgl2, - kYPtI, - kZPtI, - kSnpPtI, - kTglPtI, - kPtI2 }; // cov.matrix aliases - const double kLargeErr2Coord = 5 * 5; - const double kLargeErr2Dir = 0.7 * 0.7; - const double kLargeErr2PtI = 30.5 * 30.5; - for (int ic = 15; ic--;) + static constexpr float kLargeErr2Coord = 5 * 5; + static constexpr float kLargeErr2Dir = 0.7 * 0.7; + static constexpr float kLargeErr2PtI = 30.5 * 30.5; + std::array largeCov = {0.}; + for (int ic = o2::track::kCovMatSize; ic--;) largeCov[ic] = 0.; - largeCov[kY2] = largeCov[kZ2] = kLargeErr2Coord; - largeCov[kSnp2] = largeCov[kTgl2] = kLargeErr2Dir; - largeCov[kPtI2] = kLargeErr2PtI * trPars[kPtI] * trPars[kPtI]; + largeCov[o2::track::CovLabels::kSigY2] = largeCov[o2::track::CovLabels::kSigZ2] = kLargeErr2Coord; + largeCov[o2::track::CovLabels::kSigSnp2] = largeCov[o2::track::CovLabels::kSigTgl2] = kLargeErr2Dir; + largeCov[o2::track::CovLabels::kSigQ2Pt2] = kLargeErr2PtI * trPars[o2::track::ParLabels::kQ2Pt] * trPars[o2::track::ParLabels::kQ2Pt]; - outputTrack.setCov(largeCov); - outputTrack.checkCovariance(); + inwardTrack.setCov(largeCov); + inwardTrack.checkCovariance(); // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ // Inward pass to calculate covariances for (int il = lastLayerReached; il >= firstLayerReached; il--) { - if (layers[il].type == 0) - continue; // inert layer, skip float targetX = 1e+3; - inputTrack.getXatLabR(layers[il].r, targetX, magneticField); + inputTrack.getXatLabR(layers[il].getRadius(), targetX, magneticField); if (targetX > 999) continue; // failed to find intercept if (!inputTrack.propagateTo(targetX, magneticField)) { continue; // failed to propagate } - if (std::abs(inputTrack.getZ()) > layers[il].z && applyZacceptance) { + + if (std::abs(inputTrack.getZ()) > layers[il].getZ() && mApplyZacceptance) { continue; // out of acceptance bounds but continue inwards } @@ -268,36 +428,67 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa std::vector thisHit = {spacePoint[0], spacePoint[1], spacePoint[2]}; // towards adding cluster: move to track alpha - double alpha = outputTrack.getAlpha(); - double xyz1[3]{ - TMath::Cos(alpha) * spacePoint[0] + TMath::Sin(alpha) * spacePoint[1], - -TMath::Sin(alpha) * spacePoint[0] + TMath::Cos(alpha) * spacePoint[1], + float alpha = inwardTrack.getAlpha(); + float xyz1[3]{ + std::cos(alpha) * spacePoint[0] + std::sin(alpha) * spacePoint[1], + -std::sin(alpha) * spacePoint[0] + std::cos(alpha) * spacePoint[1], spacePoint[2]}; - if (!(outputTrack.propagateTo(xyz1[0], magneticField))) + if (!inwardTrack.propagateTo(xyz1[0], magneticField)) continue; - const o2::track::TrackParametrization::dim2_t hitpoint = { - static_cast(xyz1[1]), - static_cast(xyz1[2])}; - const o2::track::TrackParametrization::dim3_t hitpointcov = {layers[il].resRPhi * layers[il].resRPhi, 0.f, layers[il].resZ * layers[il].resZ}; - outputTrack.update(hitpoint, hitpointcov); - outputTrack.checkCovariance(); + if (!layers[il].isInert()) { // only update covm for tracker hits + const o2::track::TrackParametrization::dim2_t hitpoint = { + static_cast(xyz1[1]), + static_cast(xyz1[2])}; + const o2::track::TrackParametrization::dim3_t hitpointcov = {layers[il].getResolutionRPhi() * layers[il].getResolutionRPhi(), 0.f, layers[il].getResolutionZ() * layers[il].getResolutionZ()}; + + inwardTrack.update(hitpoint, hitpointcov); + inwardTrack.checkCovariance(); + } + + if (mApplyMSCorrection && layers[il].getRadiationLength() > 0) { + if (!inputTrack.correctForMaterial(layers[il].getRadiationLength(), 0, applyAngularCorrection)) { + return -6; + } + if (!inwardTrack.correctForMaterial(layers[il].getRadiationLength(), 0, applyAngularCorrection)) { + return -6; + } + } + if (mApplyElossCorrection && layers[il].getDensity() > 0) { + for (int ise = xrhosteps; ise--;) { // correct in small steps + if (!inputTrack.correctForMaterial(0, layers[il].getDensity() / xrhosteps, applyAngularCorrection)) { + return -7; + } + if (!inwardTrack.correctForMaterial(0, layers[il].getDensity() / xrhosteps, applyAngularCorrection)) { + return -7; + } + } + } - if (layers[il].type == 1) + if (layers[il].isSilicon()) nSiliconPoints++; // count silicon hits - if (layers[il].type == 2) + if (layers[il].isGas()) nGasPoints++; // count TPC/gas hits hits.push_back(thisHit); + + if (!layers[il].isInert()) { // good hit probability calculation + float sigYCmb = o2::math_utils::sqrt(inwardTrack.getSigmaY2() + layers[il].getResolutionRPhi() * layers[il].getResolutionRPhi()); + float sigZCmb = o2::math_utils::sqrt(inwardTrack.getSigmaZ2() + layers[il].getResolutionZ() * layers[il].getResolutionZ()); + goodHitProbability[il] = ProbGoodChiSqHit(layers[il].getRadius() * 100, sigYCmb * 100, sigZCmb * 100); + goodHitProbability[0] *= goodHitProbability[il]; + } } // backpropagate to original radius float finalX = 1e+3; - outputTrack.getXatLabR(initialRadius, finalX, magneticField); - if (finalX > 999) + bool inPropStatus = inwardTrack.getXatLabR(initialRadius, finalX, magneticField); + if (finalX > 999) { + LOG(debug) << "Failed to find intercept for initial radius " << initialRadius << " cm, x = " << finalX << " and status " << inPropStatus << " and sn = " << inwardTrack.getSnp() << " r = " << inwardTrack.getY() * inwardTrack.getY(); return -3; // failed to find intercept + } - if (!outputTrack.propagateTo(finalX, magneticField)) { + if (!inwardTrack.propagateTo(finalX, magneticField)) { return -4; // failed to propagate } @@ -305,12 +496,29 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa if (nIntercepts < 4) return nIntercepts; + // generate efficiency + float eff = 1.; + for (int i = 0; i < kMaxNumberOfDetectors; i++) { + float iGoodHit = goodHitProbability[i]; + if (iGoodHit <= 0) + continue; + + eff *= iGoodHit; + } + if (mApplyEffCorrection) { + if (gRandom->Uniform() > eff) + return -8; + } + + outputTrack.setCov(inwardTrack.getCov()); + outputTrack.checkCovariance(); + // Use covariance matrix based smearing - std::array covMat = {0.}; - for (int ii = 0; ii < 15; ii++) + std::array covMat = {0.}; + for (int ii = 0; ii < o2::track::kCovMatSize; ii++) covMat[ii] = outputTrack.getCov()[ii]; TMatrixDSym m(5); - double fcovm[5][5]; + double fcovm[5][5]; // double precision is needed for regularisation for (int ii = 0, k = 0; ii < 5; ++ii) { for (int j = 0; j < ii + 1; ++j, ++k) { @@ -320,7 +528,7 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa } // evaluate ruben's conditional, regularise - bool makePositiveDefinite = (covMatFactor > -1e-5); // apply fix + const bool makePositiveDefinite = (covMatFactor > -1e-5); // apply fix bool rubenConditional = false; for (int ii = 0; ii < 5; ii++) { for (int jj = 0; jj < 5; jj++) { @@ -347,7 +555,7 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa } if (negEigVal && rubenConditional && makePositiveDefinite) { - if (verboseLevel > 0) { + if (mVerboseLevel > 0) { LOG(info) << "WARNING: this diagonalization (at pt = " << inputTrack.getPt() << ") has negative eigenvalues despite Ruben's fix! Please be careful!"; LOG(info) << "Printing info:"; LOG(info) << "Kalman updates: " << nIntercepts; @@ -361,9 +569,9 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa covMatOK++; // transform parameter vector and smear - double params_[5]; + float params_[5]; for (int ii = 0; ii < 5; ++ii) { - double val = 0.; + float val = 0.; for (int j = 0; j < 5; ++j) val += eigVec[j][ii] * outputTrack.getParam(j); // smear parameters according to eigenvalues @@ -374,7 +582,7 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa eigVec.Invert(); // transform back params vector for (int ii = 0; ii < 5; ++ii) { - double val = 0.; + float val = 0.; for (int j = 0; j < 5; ++j) val += eigVec[j][ii] * params_[j]; outputTrack.setParam(val, ii); diff --git a/ALICE3/Core/FastTracker.h b/ALICE3/Core/FastTracker.h index ecd7d19cb98..a0dba5d7ec5 100644 --- a/ALICE3/Core/FastTracker.h +++ b/ALICE3/Core/FastTracker.h @@ -12,11 +12,15 @@ #ifndef ALICE3_CORE_FASTTRACKER_H_ #define ALICE3_CORE_FASTTRACKER_H_ -#include // not a system header but megalinter thinks so -#include #include "DetLayer.h" + #include "ReconstructionDataFormats/Track.h" +#include // not a system header but megalinter thinks so + +#include +#include + namespace o2 { namespace fastsim @@ -31,35 +35,117 @@ class FastTracker { public: // Constructor/destructor - FastTracker(); + FastTracker() = default; + // Destructor virtual ~FastTracker() {} + // Layer and layer configuration void AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi = 0.0f, float resZ = 0.0f, float eff = 0.0f, int type = 0); - - void AddSiliconALICE3v4(); - void AddSiliconALICE3v1(); + DetLayer GetLayer(const int layer, bool ignoreBarrelLayers = true) const; + int GetLayerIndex(const std::string& name) const; + size_t GetNLayers() const { return layers.size(); } + bool IsLayerInert(const int layer) const { return layers[layer].isInert(); } + void SetRadiationLength(const std::string layerName, float x0) { layers[GetLayerIndex(layerName)].setRadiationLength(x0); } + void SetRadius(const std::string layerName, float r) { layers[GetLayerIndex(layerName)].setRadius(r); } + void SetResolutionRPhi(const std::string layerName, float resRPhi) { layers[GetLayerIndex(layerName)].setResolutionRPhi(resRPhi); } + void SetResolutionZ(const std::string layerName, float resZ) { layers[GetLayerIndex(layerName)].setResolutionZ(resZ); } + void SetResolution(const std::string layerName, float resRPhi, float resZ) + { + SetResolutionRPhi(layerName, resRPhi); + SetResolutionZ(layerName, resZ); + } + + void AddSiliconALICE3v4(std::vector pixelResolution); + void AddSiliconALICE3v2(std::vector pixelResolution); void AddTPC(float phiResMean, float zResMean); void Print(); - int FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackParCov& outputTrack); + /** + * @brief Performs fast tracking on the input track parameters. + * + * Propagates the given input track through the detector layers, applying + * relevant corrections and updates, and stores the result in outputTrack. + * + * @param inputTrack The input track parameters and covariance (const, by value). + * @param outputTrack Reference to the output track parameters and covariance, to be filled. + * @param nch Charged particle multiplicity (used for hit density calculations). + * @return int i.e. number of intercepts (implementation-defined). + */ + int FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackParCov& outputTrack, const float nch); + + // For efficiency calculation + float Dist(float z, float radius); + float OneEventHitDensity(float multiplicity, float radius); + float IntegratedHitDensity(float multiplicity, float radius); + float UpcHitDensity(float radius); + float HitDensity(float radius); + float ProbGoodChiSqHit(float radius, float searchRadiusRPhi, float searchRadiusZ); + + // Setters and getters for configuration + void SetIntegrationTime(float t) { integrationTime = t; } + void SetMaxRadiusOfSlowDetectors(float r) { maxRadiusSlowDet = r; } + void SetAvgRapidity(float y) { avgRapidity = y; } + void SetdNdEtaCent(int d) { dNdEtaCent = d; } + void SetLhcUPCscale(float s) { lhcUPCScale = s; } + void SetBField(float b) { magneticField = b; } + void SetMinRadTrack(float r) { fMinRadTrack = r; } + void SetMagneticField(float b) { magneticField = b; } + void SetApplyZacceptance(bool b) { mApplyZacceptance = b; } + void SetApplyMSCorrection(bool b) { mApplyMSCorrection = b; } + void SetApplyElossCorrection(bool b) { mApplyElossCorrection = b; } + void SetApplyEffCorrection(bool b) { mApplyEffCorrection = b; } + + // Getters for the last track + int GetNIntercepts() const { return nIntercepts; } + int GetNSiliconPoints() const { return nSiliconPoints; } + int GetNGasPoints() const { return nGasPoints; } + float GetGoodHitProb(int layer) const + { + return (layer >= 0 && static_cast(layer) < goodHitProbability.size()) ? goodHitProbability[layer] : 0.0f; + } + std::size_t GetNHits() const { return hits.size(); } + float GetHitX(const int i) const { return hits[i][0]; } + float GetHitY(const int i) const { return hits[i][1]; } + float GetHitZ(const int i) const { return hits[i][2]; } + uint64_t GetCovMatOK() const { return covMatOK; } + uint64_t GetCovMatNotOK() const { return covMatNotOK; } + + private: // Definition of detector layers std::vector layers; std::vector> hits; // bookkeep last added hits - // operational - float magneticField; // in kiloGauss (5 = 0.5T, etc) - bool applyZacceptance; // check z acceptance or not - float covMatFactor; // covmat off-diagonal factor to use for covmat fix (negative: no factor) - int verboseLevel; // 0: not verbose, >0 more verbose - - uint64_t covMatOK; // cov mat has negative eigenvals - uint64_t covMatNotOK; // cov mat has negative eigenvals - - // last track information - int nIntercepts; // found in first outward propagation - int nSiliconPoints; // silicon-based space points added to track - int nGasPoints; // tpc-based space points added to track + /// configuration parameters + bool mApplyZacceptance = false; /// check z acceptance or not + bool mApplyMSCorrection = true; /// Apply correction for multiple scattering + bool mApplyElossCorrection = true; /// Apply correction for eloss (requires MS correction) + bool mApplyEffCorrection = true; /// Apply correction for hit efficiency + int mVerboseLevel = 0; /// 0: not verbose, >0 more verbose + const float mCrossSectionMinB = 8; /// Minimum bias Cross section for event under study (PbPb MinBias ~ 8 Barns) + int dNdEtaCent = 2200; /// dN/deta e.g. at centrality 0-5% (for 5 TeV PbPb) + int dNdEtaMinB = 1; /// dN/deta for minimum bias events + float integrationTime = 0.02f; /// Integration time in ms + float magneticField = 20.f; /// Magnetic field in kiloGauss (5 = 0.5T, 20 = 2T, etc) + float covMatFactor = 0.99f; /// covmat off-diagonal factor to use for covmat fix (negative: no factor) + float sigmaD = 6.0f; /// sigma for the detector resolution in cm + float luminosity = 1.e27f; /// luminosity in cm^-2 s^-1 (e.g. 1.e27 for PbPb at 5 TeV) + float otherBackground = 0.0f; /// background from other sources, e.g. pileup, in [0, 1] + float maxRadiusSlowDet = 10.f; /// maximum radius of slow detectors in cm + float avgRapidity = 0.45f; /// average rapidity for hit density calculation + float lhcUPCScale = 1.0f; /// scale factor for LHC UPC events + float upcBackgroundMultiplier = 1.0f; /// multiplier for UPC background + float fMinRadTrack = 132.f; /// minimum radius for track propagation in cm + + /// counters for covariance matrix statuses + uint64_t covMatOK = 0; /// cov mat has positive eigenvals + uint64_t covMatNotOK = 0; /// cov mat has negative eigenvals + + /// last track information + int nIntercepts = 0; /// found in first outward propagation + int nSiliconPoints = 0; /// silicon-based space points added to track + int nGasPoints = 0; /// tpc-based space points added to track + std::vector goodHitProbability; ClassDef(FastTracker, 1); }; diff --git a/ALICE3/Core/FastTrackerLinkDef.h b/ALICE3/Core/FastTrackerLinkDef.h index a69755b7e92..a5441d81cde 100644 --- a/ALICE3/Core/FastTrackerLinkDef.h +++ b/ALICE3/Core/FastTrackerLinkDef.h @@ -17,5 +17,6 @@ #pragma link off all functions; #pragma link C++ class o2::fastsim::FastTracker + ; +#pragma link C++ class o2::fastsim::DelphesO2LutWriter + ; #endif // ALICE3_CORE_FASTTRACKERLINKDEF_H_ diff --git a/ALICE3/Core/TrackUtilities.cxx b/ALICE3/Core/TrackUtilities.cxx new file mode 100644 index 00000000000..c07fe145ccf --- /dev/null +++ b/ALICE3/Core/TrackUtilities.cxx @@ -0,0 +1,40 @@ +// 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. +/// +/// \file TrackUtilities.cxx +/// \author Nicolò Jacazio, Universita del Piemonte Orientale (IT) +/// \brief Set of utilities for the ALICE3 track handling +/// \since May 21, 2025 +/// + +#include "TrackUtilities.h" + +#include + +void o2::upgrade::convertTLorentzVectorToO2Track(const int charge, + const TLorentzVector particle, + const std::vector productionVertex, + o2::track::TrackParCov& o2track) +{ + std::array params; + std::array covm = {0.}; + float s, c, x; + o2::math_utils::sincos(static_cast(particle.Phi()), s, c); + o2::math_utils::rotateZInv(static_cast(productionVertex[0]), static_cast(productionVertex[1]), x, params[0], s, c); + params[1] = static_cast(productionVertex[2]); + params[2] = 0.; // since alpha = phi + const auto theta = 2. * std::atan(std::exp(-particle.PseudoRapidity())); + params[3] = 1. / std::tan(theta); + params[4] = charge / particle.Pt(); + + // Initialize TrackParCov in-place + new (&o2track)(o2::track::TrackParCov)(x, particle.Phi(), params, covm); +} diff --git a/ALICE3/Core/TrackUtilities.h b/ALICE3/Core/TrackUtilities.h new file mode 100644 index 00000000000..9bbc00c8f09 --- /dev/null +++ b/ALICE3/Core/TrackUtilities.h @@ -0,0 +1,90 @@ +// 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. +/// +/// \file TrackUtilities.h +/// \author Nicolò Jacazio, Universita del Piemonte Orientale (IT) +/// \brief Set of utilities for the ALICE3 track handling +/// \since May 21, 2025 +/// + +#ifndef ALICE3_CORE_TRACKUTILITIES_H_ +#define ALICE3_CORE_TRACKUTILITIES_H_ + +#include "ReconstructionDataFormats/Track.h" + +#include "TLorentzVector.h" + +#include + +namespace o2::upgrade +{ + +/// Function to convert a TLorentzVector into a perfect Track +/// \param charge particle charge (integer) +/// \param particle the particle to convert (TLorentzVector) +/// \param productionVertex where the particle was produced +/// \param o2track the address of the resulting TrackParCov +void convertTLorentzVectorToO2Track(const int charge, + const TLorentzVector particle, + const std::vector productionVertex, + o2::track::TrackParCov& o2track); + +/// Function to convert a TLorentzVector into a perfect Track +/// \param pdgCode particle pdg +/// \param particle the particle to convert (TLorentzVector) +/// \param productionVertex where the particle was produced +/// \param o2track the address of the resulting TrackParCov +/// \param pdg the pdg service +template +void convertTLorentzVectorToO2Track(int pdgCode, + TLorentzVector particle, + std::vector productionVertex, + o2::track::TrackParCov& o2track, + const PdgService& pdg) +{ + const auto pdgInfo = pdg->GetParticle(pdgCode); + int charge = 0; + if (pdgInfo != nullptr) { + charge = pdgInfo->Charge() / 3; + } + convertTLorentzVectorToO2Track(charge, particle, productionVertex, o2track); +} + +/// Function to convert a McParticle into a perfect Track +/// \param particle the particle to convert (mcParticle) +/// \param o2track the address of the resulting TrackParCov +/// \param pdg the pdg service +template +void convertMCParticleToO2Track(McParticleType& particle, + o2::track::TrackParCov& o2track, + const PdgService& pdg) +{ + static TLorentzVector tlv; + tlv.SetPxPyPzE(particle.px(), particle.py(), particle.pz(), particle.e()); + convertTLorentzVectorToO2Track(particle.pdgCode(), tlv, {particle.vx(), particle.vy(), particle.vz()}, o2track, pdg); +} + +/// Function to convert a McParticle into a perfect Track +/// \param particle the particle to convert (mcParticle) +/// \param o2track the address of the resulting TrackParCov +/// \param pdg the pdg service +template +o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle, + const PdgService& pdg) +{ + o2::track::TrackParCov o2track; + convertMCParticleToO2Track(particle, o2track, pdg); + return o2track; +} + +} // namespace o2::upgrade + +#endif // ALICE3_CORE_TRACKUTILITIES_H_ diff --git a/ALICE3/DataModel/A3DecayFinderTables.h b/ALICE3/DataModel/A3DecayFinderTables.h index 05eb5ad9307..55229bbb5d4 100644 --- a/ALICE3/DataModel/A3DecayFinderTables.h +++ b/ALICE3/DataModel/A3DecayFinderTables.h @@ -20,6 +20,7 @@ // O2 includes #include "Framework/AnalysisDataModel.h" +#include "Common/Core/RecoDecay.h" enum a3selectionBit : uint32_t { kDCAxy = 0, kInnerTOFPion, @@ -59,6 +60,64 @@ DECLARE_SOA_TABLE(Alice3DecayMaps, "AOD", "ALICE3DECAYMAPS", using Alice3DecayMap = Alice3DecayMaps::iterator; +namespace a3D0meson +{ +DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! +DECLARE_SOA_COLUMN(PxProng0, pxProng0, float); //! positive track +DECLARE_SOA_COLUMN(PyProng0, pyProng0, float); //! +DECLARE_SOA_COLUMN(PzProng0, pzProng0, float); //! +DECLARE_SOA_COLUMN(PxProng1, pxProng1, float); //! negative track +DECLARE_SOA_COLUMN(PyProng1, pyProng1, float); //! +DECLARE_SOA_COLUMN(PzProng1, pzProng1, float); //! +DECLARE_SOA_DYNAMIC_COLUMN(PtProng0, ptProng0, //! + [](float px, float py) -> float { return RecoDecay::pt(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(PtProng1, ptProng1, //! + [](float px, float py) -> float { return RecoDecay::pt(px, py); }); +DECLARE_SOA_EXPRESSION_COLUMN(Px, px, //! + float, 1.f * aod::a3D0meson::pxProng0 + 1.f * aod::a3D0meson::pxProng1); +DECLARE_SOA_EXPRESSION_COLUMN(Py, py, //! + float, 1.f * aod::a3D0meson::pyProng0 + 1.f * aod::a3D0meson::pyProng1); +DECLARE_SOA_EXPRESSION_COLUMN(Pz, pz, //! + float, 1.f * aod::a3D0meson::pzProng0 + 1.f * aod::a3D0meson::pzProng1); +DECLARE_SOA_COLUMN(Pt, pt, float); //! +DECLARE_SOA_COLUMN(M, m, float); //! +DECLARE_SOA_DYNAMIC_COLUMN(E, e, //! + [](float px, float py, float pz, double m) -> float { return RecoDecay::e(px, py, pz, m); }); +DECLARE_SOA_COLUMN(Eta, eta, float); //! +DECLARE_SOA_COLUMN(Phi, phi, float); //! +DECLARE_SOA_COLUMN(Y, y, float); +} // namespace a3D0meson +DECLARE_SOA_TABLE(Alice3D0Meson, "AOD", "ALICE3D0MESON", //! + o2::soa::Index<>, + a3D0meson::CollisionId, + a3D0meson::PxProng0, a3D0meson::PyProng0, a3D0meson::PzProng0, // positive track + a3D0meson::PxProng1, a3D0meson::PyProng1, a3D0meson::PzProng1, // negative track + a3D0meson::PtProng0, + a3D0meson::PtProng1, + a3D0meson::Px, a3D0meson::Py, a3D0meson::Pz, + a3D0meson::Pt, + a3D0meson::M, + a3D0meson::E, + a3D0meson::Eta, + a3D0meson::Phi, + a3D0meson::Y); + +namespace a3D0Selection +{ +DECLARE_SOA_COLUMN(IsSelD0, isSelD0, int); //! +DECLARE_SOA_COLUMN(IsSelD0bar, isSelD0bar, int); //! +} // namespace a3D0Selection +DECLARE_SOA_TABLE(Alice3D0Sel, "AOD", "ALICE3D0SEL", //! + a3D0Selection::IsSelD0, + a3D0Selection::IsSelD0bar); + +namespace a3D0MCTruth +{ +DECLARE_SOA_COLUMN(McTruthInfo, mcTruthInfo, int); //! 0 for bkg, 1 for true D0, 2 for true D0bar +} // namespace a3D0MCTruth +DECLARE_SOA_TABLE(Alice3D0MCTruth, "AOD", "ALICE3D0MCTRUTH", //! + a3D0MCTruth::McTruthInfo); //! + } // namespace o2::aod #endif // ALICE3_DATAMODEL_A3DECAYFINDERTABLES_H_ diff --git a/ALICE3/DataModel/OTFMcTrackExtra.h b/ALICE3/DataModel/OTFMcTrackExtra.h deleted file mode 100644 index bb75c86746c..00000000000 --- a/ALICE3/DataModel/OTFMcTrackExtra.h +++ /dev/null @@ -1,42 +0,0 @@ -// 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. - -/// -/// \file OTFMcTrackExtra.h -/// \author Jesper Karlsson Gumprecht -/// \since 05/08/2024 -/// \brief Table to to hold MC information specifically for xi daughters created in the otf-tracker -/// - -#ifndef ALICE3_DATAMODEL_OTFMCTRACKEXTRA_H_ -#define ALICE3_DATAMODEL_OTFMCTRACKEXTRA_H_ - -// O2 includes -#include "Framework/AnalysisDataModel.h" - -namespace o2::aod -{ -namespace otf_mctrack_extra -{ -DECLARE_SOA_COLUMN(NewPdgCode, newPdgCode, int); //! PDG code (duplicate column but needed for particles created in the otf-tracker) -DECLARE_SOA_COLUMN(IsFromXi, isFromXi, bool); //! From Xi decayed in otf-tracker -DECLARE_SOA_COLUMN(IsFromL0, isFromL0, bool); //! From L0 decayed in otf-tracker -} // namespace otf_mctrack_extra -DECLARE_SOA_TABLE(OTFMcExtra, "AOD", "OTFMcExtra", - otf_mctrack_extra::NewPdgCode, - otf_mctrack_extra::IsFromXi, - otf_mctrack_extra::IsFromL0); - -using OTFMcTrackExtra = OTFMcExtra::iterator; - -} // namespace o2::aod - -#endif // ALICE3_DATAMODEL_OTFMCTRACKEXTRA_H_ diff --git a/ALICE3/DataModel/OTFMulticharm.h b/ALICE3/DataModel/OTFMulticharm.h index 7dbde7bdc9a..2c3a715f16c 100644 --- a/ALICE3/DataModel/OTFMulticharm.h +++ b/ALICE3/DataModel/OTFMulticharm.h @@ -10,16 +10,19 @@ // or submit itself to any jurisdiction. /// -/// \file OTFStrangeness.h +/// \file OTFMulticharm.h /// \author David Dobrigkeit Chinellato +/// \author Jesper Karlsson Gumprecht /// \since 05/08/2024 -/// \brief Set of tables for the ALICE3 strangeness information +/// \brief Set of tables for the ALICE3 multi-charm information /// #ifndef ALICE3_DATAMODEL_OTFMULTICHARM_H_ #define ALICE3_DATAMODEL_OTFMULTICHARM_H_ // O2 includes +#include "ALICE3/DataModel/OTFStrangeness.h" + #include "Framework/AnalysisDataModel.h" namespace o2::aod @@ -31,47 +34,88 @@ DECLARE_SOA_INDEX_COLUMN_FULL(XiCPion1, xiCPion1, int, Tracks, "_Pi1XiC"); DECLARE_SOA_INDEX_COLUMN_FULL(XiCPion2, xiCPion2, int, Tracks, "_Pi2XiC"); DECLARE_SOA_INDEX_COLUMN_FULL(XiCCPion, xiCCPion, int, Tracks, "_PiXiCC"); -// topo vars -DECLARE_SOA_COLUMN(DCAXiCDaughters, dcaXiCDaughters, float); -DECLARE_SOA_COLUMN(DCAXiCCDaughters, dcaXiCCDaughters, float); - -DECLARE_SOA_COLUMN(MXiC, mXiC, float); -DECLARE_SOA_COLUMN(MXiCC, mXiCC, float); +DECLARE_SOA_COLUMN(XicMass, xicMass, float); +DECLARE_SOA_COLUMN(XiccMass, xiccMass, float); // kine vars -DECLARE_SOA_COLUMN(Pt, pt, float); -DECLARE_SOA_COLUMN(Eta, eta, float); - -// tracking counters -DECLARE_SOA_COLUMN(NSiliconHitsXi, nSiliconHitsXi, int); -DECLARE_SOA_COLUMN(NSiliconHitsPiFromXi, nSiliconHitsPiFromXi, int); -DECLARE_SOA_COLUMN(NSiliconHitsPiFromLa, nSiliconHitsPiFromLa, int); -DECLARE_SOA_COLUMN(NSiliconHitsPrFromLa, nSiliconHitsPrFromLa, int); -DECLARE_SOA_COLUMN(NSiliconHitsPiC1, nSiliconHitsPiC1, int); -DECLARE_SOA_COLUMN(NSiliconHitsPiC2, nSiliconHitsPiC2, int); -DECLARE_SOA_COLUMN(NSiliconHitsPiCC, nSiliconHitsPiCC, int); - -DECLARE_SOA_COLUMN(NTPCHitsPiFromXi, nTPCHitsPiFromXi, int); -DECLARE_SOA_COLUMN(NTPCHitsPiFromLa, nTPCHitsPiFromLa, int); -DECLARE_SOA_COLUMN(NTPCHitsPrFromLa, nTPCHitsPrFromLa, int); -DECLARE_SOA_COLUMN(NTPCHitsPiC1, nTPCHitsPiC1, int); -DECLARE_SOA_COLUMN(NTPCHitsPiC2, nTPCHitsPiC2, int); -DECLARE_SOA_COLUMN(NTPCHitsPiCC, nTPCHitsPiCC, int); - -// DCA to PV variables -DECLARE_SOA_COLUMN(DCAToPVXi, dcaToPVXi, float); -DECLARE_SOA_COLUMN(DCAToPVXiC, dcaToPVXiC, float); -DECLARE_SOA_COLUMN(DCAToPVXiCC, dcaToPVXiCC, float); - -DECLARE_SOA_COLUMN(DCAToPVPiFromXi, dcaToPVPiFromXi, float); -DECLARE_SOA_COLUMN(DCAToPVPiFromLa, dcaToPVPiFromLa, float); -DECLARE_SOA_COLUMN(DCAToPVPrFromLa, dcaToPVPrFromLa, float); - -DECLARE_SOA_COLUMN(DCAToPVPiC1, dcaToPVPiC1, float); -DECLARE_SOA_COLUMN(DCAToPVPiC2, dcaToPVPiC2, float); -DECLARE_SOA_COLUMN(DCAToPVPiCC, dcaToPVPiCC, float); +DECLARE_SOA_COLUMN(XiccPt, xiccPt, float); +DECLARE_SOA_COLUMN(XiccEta, xiccEta, float); +DECLARE_SOA_COLUMN(XicPt, xicPt, float); +DECLARE_SOA_COLUMN(XicEta, xicEta, float); + +// topo vars +DECLARE_SOA_COLUMN(XiDCAz, xiDCAz, float); +DECLARE_SOA_COLUMN(XiDCAxy, xiDCAxy, float); +DECLARE_SOA_COLUMN(XicDauDCA, xicDauDCA, float); +DECLARE_SOA_COLUMN(XicDCAxy, xicDCAxy, float); +DECLARE_SOA_COLUMN(XicDCAz, xicDCAz, float); +DECLARE_SOA_COLUMN(XiccDauDCA, xiccDauDCA, float); +DECLARE_SOA_COLUMN(XiccDCAxy, xiccDCAxy, float); +DECLARE_SOA_COLUMN(XiccDCAz, xiccDCAz, float); + +DECLARE_SOA_COLUMN(BachDCAxy, bachDCAxy, float); +DECLARE_SOA_COLUMN(BachDCAz, bachDCAz, float); +DECLARE_SOA_COLUMN(PosDCAxy, posDCAxy, float); +DECLARE_SOA_COLUMN(PosDCAz, posDCAz, float); +DECLARE_SOA_COLUMN(NegDCAxy, negDCAxy, float); +DECLARE_SOA_COLUMN(NegDCAz, negDCAz, float); + +DECLARE_SOA_COLUMN(Pi1cDCAxy, pi1cDCAxy, float); +DECLARE_SOA_COLUMN(Pi1cDCAz, pi1cDCAz, float); +DECLARE_SOA_COLUMN(Pi2cDCAxy, pi2cDCAxy, float); +DECLARE_SOA_COLUMN(Pi2cDCAz, pi2cDCAz, float); +DECLARE_SOA_COLUMN(PiccDCAxy, piccDCAxy, float); +DECLARE_SOA_COLUMN(PiccDCAz, piccDCAz, float); + +// Lengths +DECLARE_SOA_COLUMN(XicDecayRadius2D, xicDecayRadius2D, float); +DECLARE_SOA_COLUMN(XiccDecayRadius2D, xiccDecayRadius2D, float); +DECLARE_SOA_COLUMN(XicProperLength, xicProperLength, float); +DECLARE_SOA_COLUMN(XicDistanceFromPV, xicDistanceFromPV, float); +DECLARE_SOA_COLUMN(XiccProperLength, xiccProperLength, float); + +// PID +DECLARE_SOA_COLUMN(Pi1cTofDeltaInner, pi1cTofDeltaInner, float); +DECLARE_SOA_COLUMN(Pi1cTofNSigmaInner, pi1cTofNSigmaInner, float); +DECLARE_SOA_COLUMN(Pi1cTofDeltaOuter, pi1cTofDeltaOuter, float); +DECLARE_SOA_COLUMN(Pi1cTofNSigmaOuter, pi1cTofNSigmaOuter, float); +DECLARE_SOA_COLUMN(Pi1cHasRichSignal, pi1cHasRichSignal, bool); +DECLARE_SOA_COLUMN(Pi1cRichNSigma, pi1cRichNSigma, float); +DECLARE_SOA_COLUMN(Pi1cPdgCode, pi1cPdgCode, int); + +DECLARE_SOA_COLUMN(Pi2cTofDeltaInner, pi2cTofDeltaInner, float); +DECLARE_SOA_COLUMN(Pi2cTofNSigmaInner, pi2cTofNSigmaInner, float); +DECLARE_SOA_COLUMN(Pi2cTofDeltaOuter, pi2cTofDeltaOuter, float); +DECLARE_SOA_COLUMN(Pi2cTofNSigmaOuter, pi2cTofNSigmaOuter, float); +DECLARE_SOA_COLUMN(Pi2cHasRichSignal, pi2cHasRichSignal, bool); +DECLARE_SOA_COLUMN(Pi2cRichNSigma, pi2cRichNSigma, float); +DECLARE_SOA_COLUMN(Pi2cPdgCode, pi2cPdgCode, int); + +DECLARE_SOA_COLUMN(PiccTofDeltaInner, piccTofDeltaInner, float); +DECLARE_SOA_COLUMN(PiccTofNSigmaInner, piccTofNSigmaInner, float); +DECLARE_SOA_COLUMN(PiccTofDeltaOuter, piccTofDeltaOuter, float); +DECLARE_SOA_COLUMN(PiccTofNSigmaOuter, piccTofNSigmaOuter, float); +DECLARE_SOA_COLUMN(PiccHasRichSignal, piccHasRichSignal, bool); +DECLARE_SOA_COLUMN(PiccRichNSigma, piccRichNSigma, float); +DECLARE_SOA_COLUMN(PiccPdgCode, piccPdgCode, int); + +// Daughter info +DECLARE_SOA_COLUMN(PosPt, posPt, float); +DECLARE_SOA_COLUMN(PosEta, posEta, float); +DECLARE_SOA_COLUMN(NegPt, negPt, float); +DECLARE_SOA_COLUMN(NegEta, negEta, float); +DECLARE_SOA_COLUMN(BachPt, bachPt, float); +DECLARE_SOA_COLUMN(BachEta, bachEta, float); +DECLARE_SOA_COLUMN(BachPhi, bachPhi, float); +DECLARE_SOA_COLUMN(Pi1cPt, pi1cPt, float); +DECLARE_SOA_COLUMN(Pi1cEta, pi1cEta, float); +DECLARE_SOA_COLUMN(Pi2cPt, pi2cPt, float); +DECLARE_SOA_COLUMN(Pi2cEta, pi2cEta, float); +DECLARE_SOA_COLUMN(PiccPt, piccPt, float); +DECLARE_SOA_COLUMN(PiccEta, piccEta, float); } // namespace otfmulticharm + DECLARE_SOA_TABLE(MCharmIndices, "AOD", "MCharmIndices", o2::soa::Index<>, otfmulticharm::CascadeId, @@ -80,36 +124,83 @@ DECLARE_SOA_TABLE(MCharmIndices, "AOD", "MCharmIndices", otfmulticharm::XiCCPionId); DECLARE_SOA_TABLE(MCharmCores, "AOD", "MCharmCores", - otfmulticharm::DCAXiCDaughters, - otfmulticharm::DCAXiCCDaughters, - otfmulticharm::MXiC, - otfmulticharm::MXiCC, - otfmulticharm::Pt, - otfmulticharm::Eta, - - otfmulticharm::NSiliconHitsXi, - otfmulticharm::NSiliconHitsPiFromXi, - otfmulticharm::NSiliconHitsPiFromLa, - otfmulticharm::NSiliconHitsPrFromLa, - otfmulticharm::NSiliconHitsPiC1, - otfmulticharm::NSiliconHitsPiC2, - otfmulticharm::NSiliconHitsPiCC, - otfmulticharm::NTPCHitsPiFromXi, - otfmulticharm::NTPCHitsPiFromLa, - otfmulticharm::NTPCHitsPrFromLa, - otfmulticharm::NTPCHitsPiC1, - otfmulticharm::NTPCHitsPiC2, - otfmulticharm::NTPCHitsPiCC, - - otfmulticharm::DCAToPVXi, - otfmulticharm::DCAToPVXiC, - otfmulticharm::DCAToPVXiCC, - otfmulticharm::DCAToPVPiFromXi, - otfmulticharm::DCAToPVPiFromLa, - otfmulticharm::DCAToPVPrFromLa, - otfmulticharm::DCAToPVPiC1, - otfmulticharm::DCAToPVPiC2, - otfmulticharm::DCAToPVPiCC); + otfmulticharm::XiccMass, + otfmulticharm::XiccPt, + otfmulticharm::XiccEta, + otfmulticharm::XiccDauDCA, + + otfmulticharm::XicMass, + otfmulticharm::XicPt, + otfmulticharm::XicEta, + otfmulticharm::XicDauDCA, + + otfmulticharm::XiDCAxy, + otfmulticharm::XiDCAz, + otfmulticharm::XicDCAxy, + otfmulticharm::XicDCAz, + otfmulticharm::XiccDCAxy, + otfmulticharm::XiccDCAz, + + otfmulticharm::Pi1cDCAxy, + otfmulticharm::Pi1cDCAz, + otfmulticharm::Pi2cDCAxy, + otfmulticharm::Pi2cDCAz, + otfmulticharm::PiccDCAxy, + otfmulticharm::PiccDCAz, + + otfmulticharm::XicDecayRadius2D, + otfmulticharm::XiccDecayRadius2D, + otfmulticharm::XicProperLength, + otfmulticharm::XicDistanceFromPV, + otfmulticharm::XiccProperLength, + otfmulticharm::Pi1cPt, + otfmulticharm::Pi2cPt, + otfmulticharm::PiccPt); + +DECLARE_SOA_TABLE(MCharmPID, "AOD", "MCharmPID", + otfmulticharm::Pi1cTofDeltaInner, + otfmulticharm::Pi1cTofNSigmaInner, + otfmulticharm::Pi1cTofDeltaOuter, + otfmulticharm::Pi1cTofNSigmaOuter, + otfmulticharm::Pi1cHasRichSignal, + otfmulticharm::Pi1cRichNSigma, + otfmulticharm::Pi1cPdgCode, + + otfmulticharm::Pi2cTofDeltaInner, + otfmulticharm::Pi2cTofNSigmaInner, + otfmulticharm::Pi2cTofDeltaOuter, + otfmulticharm::Pi2cTofNSigmaOuter, + otfmulticharm::Pi2cHasRichSignal, + otfmulticharm::Pi2cRichNSigma, + otfmulticharm::Pi2cPdgCode, + + otfmulticharm::PiccTofDeltaInner, + otfmulticharm::PiccTofNSigmaInner, + otfmulticharm::PiccTofDeltaOuter, + otfmulticharm::PiccTofNSigmaOuter, + otfmulticharm::PiccHasRichSignal, + otfmulticharm::PiccRichNSigma, + otfmulticharm::PiccPdgCode); + +DECLARE_SOA_TABLE(MCharmExtra, "AOD", "MCharmExtra", + otfmulticharm::BachPt, + otfmulticharm::BachEta, + otfmulticharm::BachDCAxy, + otfmulticharm::BachDCAz, + + otfmulticharm::PosPt, + otfmulticharm::PosEta, + otfmulticharm::PosDCAxy, + otfmulticharm::PosDCAz, + + otfmulticharm::NegPt, + otfmulticharm::NegEta, + otfmulticharm::NegDCAxy, + otfmulticharm::NegDCAz, + + otfmulticharm::Pi1cEta, + otfmulticharm::Pi2cEta, + otfmulticharm::PiccEta); } // namespace o2::aod diff --git a/ALICE3/DataModel/OTFPIDTrk.h b/ALICE3/DataModel/OTFPIDTrk.h new file mode 100644 index 00000000000..b10923a892b --- /dev/null +++ b/ALICE3/DataModel/OTFPIDTrk.h @@ -0,0 +1,90 @@ +// 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. + +/// +/// \file OTFPIDTrk.h +/// \author Berkin Ulukutlu TUM +/// \author Henrik Fribert TUM +/// \author Nicolò Jacazio Università del Piemonte Orientale +/// \since May 22, 2025 +/// \brief Set of tables for the ALICE3 Trk PID information +/// + +#ifndef ALICE3_DATAMODEL_OTFPIDTRK_H_ +#define ALICE3_DATAMODEL_OTFPIDTRK_H_ + +// O2 includes +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace upgrade::trk +{ + +DECLARE_SOA_COLUMN(TimeOverThresholdBarrel, timeOverThresholdBarrel, float); //! Time over threshold for the barrel layers +DECLARE_SOA_COLUMN(ClusterSizeBarrel, clusterSizeBarrel, float); //! Cluster size for the barrel layers +DECLARE_SOA_COLUMN(TimeOverThresholdForward, timeOverThresholdForward, float); //! Time over threshold for the Forward layers +DECLARE_SOA_COLUMN(ClusterSizeForward, clusterSizeForward, float); //! Cluster size for the barrel layers + +DECLARE_SOA_COLUMN(NSigmaTrkEl, nSigmaEl, float); //! NSigma electron from the tracker layers +DECLARE_SOA_COLUMN(NSigmaTrkMu, nSigmaMu, float); //! NSigma muon from the tracker layers +DECLARE_SOA_COLUMN(NSigmaTrkPi, nSigmaPi, float); //! NSigma pion from the tracker layers +DECLARE_SOA_COLUMN(NSigmaTrkKa, nSigmaKa, float); //! NSigma kaon from the tracker layers +DECLARE_SOA_COLUMN(NSigmaTrkPr, nSigmaPr, float); //! NSigma proton from the tracker layers + +DECLARE_SOA_DYNAMIC_COLUMN(NSigmaTrk, nSigmaTrk, //! General function to get the nSigma for the tracker layers + [](const float el, + const float mu, + const float pi, + const float ka, + const float pr, + const int id) -> float { + switch (std::abs(id)) { + case 0: + return el; + case 1: + return mu; + case 2: + return pi; + case 3: + return ka; + case 4: + return pr; + default: + LOG(fatal) << "Unrecognized PDG code for InnerTOF"; + return 999.f; + } + }); + +} // namespace upgrade::trk + +DECLARE_SOA_TABLE(UpgradeTrkPidSignals, "AOD", "UPGRADETRKSIG", + upgrade::trk::TimeOverThresholdBarrel, + upgrade::trk::ClusterSizeBarrel); + +DECLARE_SOA_TABLE(UpgradeTrkPids, "AOD", "UPGRADETRKPID", + upgrade::trk::NSigmaTrkEl, + upgrade::trk::NSigmaTrkMu, + upgrade::trk::NSigmaTrkPi, + upgrade::trk::NSigmaTrkKa, + upgrade::trk::NSigmaTrkPr, + upgrade::trk::NSigmaTrk); + +using UpgradeTrkPidSignal = UpgradeTrkPidSignals::iterator; +using UpgradeTrkPid = UpgradeTrkPids::iterator; + +} // namespace o2::aod + +#endif // ALICE3_DATAMODEL_OTFPIDTRK_H_ diff --git a/ALICE3/DataModel/OTFRICH.h b/ALICE3/DataModel/OTFRICH.h index e853a2ff30f..d4d9c5257ce 100644 --- a/ALICE3/DataModel/OTFRICH.h +++ b/ALICE3/DataModel/OTFRICH.h @@ -31,16 +31,64 @@ DECLARE_SOA_COLUMN(NSigmaMuonRich, nSigmaMuonRich, float); //! NSigma mu DECLARE_SOA_COLUMN(NSigmaPionRich, nSigmaPionRich, float); //! NSigma pion BarrelRich DECLARE_SOA_COLUMN(NSigmaKaonRich, nSigmaKaonRich, float); //! NSigma kaon BarrelRich DECLARE_SOA_COLUMN(NSigmaProtonRich, nSigmaProtonRich, float); //! NSigma proton BarrelRich +DECLARE_SOA_DYNAMIC_COLUMN(NSigmaRich, nSigmaRich, //! General function to get the nSigma for the RICH + [](const float el, + const float mu, + const float pi, + const float ka, + const float pr, + const int id) -> float { + switch (std::abs(id)) { + case 0: + return el; + case 1: + return mu; + case 2: + return pi; + case 3: + return ka; + case 4: + return pr; + default: + LOG(fatal) << "Unrecognized PDG code for RICH"; + return 999.f; + } + }); + +DECLARE_SOA_COLUMN(HasSig, hasSig, bool); //! Has signal in the barrel rich (is particle over threshold) +DECLARE_SOA_COLUMN(HasSigInGas, hasSigInGas, bool); //! Has signal in the gas radiator in the barrel rich (is particle over threshold) +DECLARE_SOA_COLUMN(HasSigEl, hasSigEl, bool); //! Has nSigma electron BarrelRich (is electron over threshold) +DECLARE_SOA_COLUMN(HasSigMu, hasSigMu, bool); //! Has nSigma muon BarrelRich (is muon over threshold) +DECLARE_SOA_COLUMN(HasSigPi, hasSigPi, bool); //! Has nSigma pion BarrelRich (is pion over threshold) +DECLARE_SOA_COLUMN(HasSigKa, hasSigKa, bool); //! Has nSigma kaon BarrelRich (is kaon over threshold) +DECLARE_SOA_COLUMN(HasSigPr, hasSigPr, bool); //! Has nSigma proton BarrelRich (is proton over threshold) + } // namespace upgrade_rich DECLARE_SOA_TABLE(UpgradeRichs, "AOD", "UPGRADERICH", upgrade_rich::NSigmaElectronRich, upgrade_rich::NSigmaMuonRich, upgrade_rich::NSigmaPionRich, upgrade_rich::NSigmaKaonRich, - upgrade_rich::NSigmaProtonRich); + upgrade_rich::NSigmaProtonRich, + upgrade_rich::NSigmaRich); using UpgradeRich = UpgradeRichs::iterator; +DECLARE_SOA_TABLE(UpgradeRichSignals, "AOD", "UPGRADERICHSIG", + upgrade_rich::HasSig, + upgrade_rich::HasSigEl, + upgrade_rich::HasSigMu, + upgrade_rich::HasSigPi, + upgrade_rich::HasSigKa, + upgrade_rich::HasSigPr, + upgrade_rich::HasSigInGas); + +using UpgradeRichSignal = UpgradeRichSignals::iterator; + } // namespace o2::aod #endif // ALICE3_DATAMODEL_OTFRICH_H_ diff --git a/ALICE3/DataModel/OTFTOF.h b/ALICE3/DataModel/OTFTOF.h index 57fd5bb8e8c..f6f7c39234b 100644 --- a/ALICE3/DataModel/OTFTOF.h +++ b/ALICE3/DataModel/OTFTOF.h @@ -27,42 +27,138 @@ namespace o2::aod { namespace upgrade_tof { -DECLARE_SOA_COLUMN(NSigmaElectronInnerTOF, nSigmaElectronInnerTOF, float); //! NSigma electron InnerTOF -DECLARE_SOA_COLUMN(NSigmaMuonInnerTOF, nSigmaMuonInnerTOF, float); //! NSigma muon InnerTOF -DECLARE_SOA_COLUMN(NSigmaPionInnerTOF, nSigmaPionInnerTOF, float); //! NSigma pion InnerTOF -DECLARE_SOA_COLUMN(NSigmaKaonInnerTOF, nSigmaKaonInnerTOF, float); //! NSigma kaon InnerTOF -DECLARE_SOA_COLUMN(NSigmaProtonInnerTOF, nSigmaProtonInnerTOF, float); //! NSigma proton InnerTOF -DECLARE_SOA_COLUMN(InnerTOFTrackLength, innerTOFTrackLength, float); //! track length for calculation of InnerTOF -DECLARE_SOA_COLUMN(InnerTOFTrackLengthReco, innerTOFTrackLengthReco, float); //! track length for calculation of InnerTOF -DECLARE_SOA_COLUMN(DeltaTrackLengthInnerTOF, deltaTrackLengthInnerTOF, float); //! track length for calculation of InnerTOF -DECLARE_SOA_COLUMN(NSigmaElectronOuterTOF, nSigmaElectronOuterTOF, float); //! NSigma electron OuterTOF -DECLARE_SOA_COLUMN(NSigmaMuonOuterTOF, nSigmaMuonOuterTOF, float); //! NSigma muon OuterTOF -DECLARE_SOA_COLUMN(NSigmaPionOuterTOF, nSigmaPionOuterTOF, float); //! NSigma pion OuterTOF -DECLARE_SOA_COLUMN(NSigmaKaonOuterTOF, nSigmaKaonOuterTOF, float); //! NSigma kaon OuterTOF -DECLARE_SOA_COLUMN(NSigmaProtonOuterTOF, nSigmaProtonOuterTOF, float); //! NSigma proton OuterTOF -DECLARE_SOA_COLUMN(OuterTOFTrackLength, outerTOFTrackLength, float); //! track length for calculation of OuterTOF -DECLARE_SOA_COLUMN(OuterTOFTrackLengthReco, outerTOFTrackLengthReco, float); //! track length for calculation of OuterTOF -DECLARE_SOA_COLUMN(DeltaTrackLengthOuterTOF, deltaTrackLengthOuterTOF, float); //! track length for calculation of InnerTOF +DECLARE_SOA_COLUMN(InnerTOFTrackTime, innerTOFTrackTime, float); //! Track time generated at the InnerTOF +DECLARE_SOA_COLUMN(InnerTOFTrackLength, innerTOFTrackLength, float); //! track length for calculation of InnerTOF (generated) +DECLARE_SOA_COLUMN(OuterTOFTrackTime, outerTOFTrackTime, float); //! Track time generated at the OuterTOF +DECLARE_SOA_COLUMN(OuterTOFTrackLength, outerTOFTrackLength, float); //! track length for calculation of OuterTOF (generated) + +DECLARE_SOA_COLUMN(TOFEventTime, tofEventTime, float); //! Event time reconstructed with the TOF +DECLARE_SOA_COLUMN(TOFEventTimeErr, tofEventTimeErr, float); //! Uncertainty on the event time reconstructed with the TOF +DECLARE_SOA_COLUMN(NSigmaElectronInnerTOF, nSigmaElectronInnerTOF, float); //! NSigma electron InnerTOF +DECLARE_SOA_COLUMN(NSigmaMuonInnerTOF, nSigmaMuonInnerTOF, float); //! NSigma muon InnerTOF +DECLARE_SOA_COLUMN(NSigmaPionInnerTOF, nSigmaPionInnerTOF, float); //! NSigma pion InnerTOF +DECLARE_SOA_COLUMN(NSigmaKaonInnerTOF, nSigmaKaonInnerTOF, float); //! NSigma kaon InnerTOF +DECLARE_SOA_COLUMN(NSigmaProtonInnerTOF, nSigmaProtonInnerTOF, float); //! NSigma proton InnerTOF +DECLARE_SOA_COLUMN(InnerTOFTrackTimeReco, innerTOFTrackTimeReco, float); //! Track time measured at the InnerTOF +DECLARE_SOA_COLUMN(InnerTOFTrackLengthReco, innerTOFTrackLengthReco, float); //! track length for calculation of InnerTOF (reconstructed) + +DECLARE_SOA_COLUMN(InnerTOFExpectedTimeEl, innerTOFExpectedTimeEl, float); //! Reconstructed expected time at the InnerTOF for the Electron mass hypotheses +DECLARE_SOA_COLUMN(InnerTOFExpectedTimeMu, innerTOFExpectedTimeMu, float); //! Reconstructed expected time at the InnerTOF for the Muon mass hypotheses +DECLARE_SOA_COLUMN(InnerTOFExpectedTimePi, innerTOFExpectedTimePi, float); //! Reconstructed expected time at the InnerTOF for the Pion mass hypotheses +DECLARE_SOA_COLUMN(InnerTOFExpectedTimeKa, innerTOFExpectedTimeKa, float); //! Reconstructed expected time at the InnerTOF for the Kaon mass hypotheses +DECLARE_SOA_COLUMN(InnerTOFExpectedTimePr, innerTOFExpectedTimePr, float); //! Reconstructed expected time at the InnerTOF for the Proton mass hypotheses + +DECLARE_SOA_COLUMN(NSigmaElectronOuterTOF, nSigmaElectronOuterTOF, float); //! NSigma electron OuterTOF +DECLARE_SOA_COLUMN(NSigmaMuonOuterTOF, nSigmaMuonOuterTOF, float); //! NSigma muon OuterTOF +DECLARE_SOA_COLUMN(NSigmaPionOuterTOF, nSigmaPionOuterTOF, float); //! NSigma pion OuterTOF +DECLARE_SOA_COLUMN(NSigmaKaonOuterTOF, nSigmaKaonOuterTOF, float); //! NSigma kaon OuterTOF +DECLARE_SOA_COLUMN(NSigmaProtonOuterTOF, nSigmaProtonOuterTOF, float); //! NSigma proton OuterTOF +DECLARE_SOA_COLUMN(OuterTOFTrackTimeReco, outerTOFTrackTimeReco, float); //! Track time measured at the OuterTOF +DECLARE_SOA_COLUMN(OuterTOFTrackLengthReco, outerTOFTrackLengthReco, float); //! track length for calculation of OuterTOF (reconstructed) + +DECLARE_SOA_COLUMN(OuterTOFExpectedTimeEl, outerTOFExpectedTimeEl, float); //! Reconstructed expected time at the OuterTOF for the Electron mass hypotheses +DECLARE_SOA_COLUMN(OuterTOFExpectedTimeMu, outerTOFExpectedTimeMu, float); //! Reconstructed expected time at the OuterTOF for the Muon mass hypotheses +DECLARE_SOA_COLUMN(OuterTOFExpectedTimePi, outerTOFExpectedTimePi, float); //! Reconstructed expected time at the OuterTOF for the Pion mass hypotheses +DECLARE_SOA_COLUMN(OuterTOFExpectedTimeKa, outerTOFExpectedTimeKa, float); //! Reconstructed expected time at the OuterTOF for the Kaon mass hypotheses +DECLARE_SOA_COLUMN(OuterTOFExpectedTimePr, outerTOFExpectedTimePr, float); //! Reconstructed expected time at the OuterTOF for the Proton mass hypotheses +DECLARE_SOA_DYNAMIC_COLUMN(NSigmaInnerTOF, nSigmaInnerTOF, //! General function to get the nSigma for the InnerTOF + [](const float el, + const float mu, + const float pi, + const float ka, + const float pr, + const int id) -> float { + switch (std::abs(id)) { + case 0: + return el; + case 1: + return mu; + case 2: + return pi; + case 3: + return ka; + case 4: + return pr; + default: + LOG(fatal) << "Unrecognized PDG code for InnerTOF"; + return 999.f; + } + }); +DECLARE_SOA_DYNAMIC_COLUMN(NSigmaOuterTOF, nSigmaOuterTOF, //! General function to get the nSigma for the OuterTOF + [](const float el, + const float mu, + const float pi, + const float ka, + const float pr, + const int id) -> float { + switch (std::abs(id)) { + case 0: + return el; + case 1: + return mu; + case 2: + return pi; + case 3: + return ka; + case 4: + return pr; + default: + LOG(fatal) << "Unrecognized PDG code for InnerTOF"; + return 999.f; + } + }); + } // namespace upgrade_tof + +DECLARE_SOA_TABLE(UpgradeTofMCs, "AOD", "UPGRADETOFMC", + upgrade_tof::InnerTOFTrackTime, + upgrade_tof::InnerTOFTrackLength, + upgrade_tof::OuterTOFTrackTime, + upgrade_tof::OuterTOFTrackLength); + DECLARE_SOA_TABLE(UpgradeTofs, "AOD", "UPGRADETOF", + upgrade_tof::TOFEventTime, + upgrade_tof::TOFEventTimeErr, upgrade_tof::NSigmaElectronInnerTOF, upgrade_tof::NSigmaMuonInnerTOF, upgrade_tof::NSigmaPionInnerTOF, upgrade_tof::NSigmaKaonInnerTOF, upgrade_tof::NSigmaProtonInnerTOF, - upgrade_tof::InnerTOFTrackLength, + upgrade_tof::InnerTOFTrackTimeReco, upgrade_tof::InnerTOFTrackLengthReco, - upgrade_tof::DeltaTrackLengthInnerTOF, upgrade_tof::NSigmaElectronOuterTOF, upgrade_tof::NSigmaMuonOuterTOF, upgrade_tof::NSigmaPionOuterTOF, upgrade_tof::NSigmaKaonOuterTOF, upgrade_tof::NSigmaProtonOuterTOF, - upgrade_tof::OuterTOFTrackLength, + upgrade_tof::OuterTOFTrackTimeReco, upgrade_tof::OuterTOFTrackLengthReco, - upgrade_tof::DeltaTrackLengthOuterTOF); + upgrade_tof::NSigmaInnerTOF, + upgrade_tof::NSigmaOuterTOF); + +DECLARE_SOA_TABLE(UpgradeTofExpectedTimes, "AOD", "UPGRADETOFEXPT", + upgrade_tof::InnerTOFExpectedTimeEl, + upgrade_tof::InnerTOFExpectedTimeMu, + upgrade_tof::InnerTOFExpectedTimePi, + upgrade_tof::InnerTOFExpectedTimeKa, + upgrade_tof::InnerTOFExpectedTimePr, + upgrade_tof::OuterTOFExpectedTimeEl, + upgrade_tof::OuterTOFExpectedTimeMu, + upgrade_tof::OuterTOFExpectedTimePi, + upgrade_tof::OuterTOFExpectedTimeKa, + upgrade_tof::OuterTOFExpectedTimePr); +using UpgradeTofMC = UpgradeTofMCs::iterator; using UpgradeTof = UpgradeTofs::iterator; +using UpgradeTofExpectedTime = UpgradeTofExpectedTimes::iterator; } // namespace o2::aod diff --git a/ALICE3/TableProducer/CMakeLists.txt b/ALICE3/TableProducer/CMakeLists.txt index 9c3d710d358..d0b7afce076 100644 --- a/ALICE3/TableProducer/CMakeLists.txt +++ b/ALICE3/TableProducer/CMakeLists.txt @@ -41,7 +41,12 @@ o2physics_add_dpl_workflow(alice3-decayfinder PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(alice3-multicharm - SOURCES alice3-multicharm.cxx +o2physics_add_dpl_workflow(alice3-multicharm-table + SOURCES alice3-multicharmTable.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(alice3-correlatorddbar + SOURCES alice3-correlatorDDbar.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter COMPONENT_NAME Analysis) diff --git a/ALICE3/TableProducer/OTF/CMakeLists.txt b/ALICE3/TableProducer/OTF/CMakeLists.txt index d20b6c6ba5c..69a4d2ec722 100644 --- a/ALICE3/TableProducer/OTF/CMakeLists.txt +++ b/ALICE3/TableProducer/OTF/CMakeLists.txt @@ -15,11 +15,16 @@ o2physics_add_dpl_workflow(onthefly-tracker COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(onthefly-tofpid - SOURCES onTheFlyTOFPID.cxx + SOURCES onTheFlyTofPid.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2Physics::ALICE3Core COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(onthefly-richpid - SOURCES onTheFlyRICHPID.cxx + SOURCES onTheFlyRichPid.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2Physics::ALICE3Core + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(on-the-fly-tracker-pid + SOURCES onTheFlyTrackerPid.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2Physics::ALICE3Core COMPONENT_NAME Analysis) diff --git a/ALICE3/TableProducer/OTF/onTheFlyRICHPID.cxx b/ALICE3/TableProducer/OTF/onTheFlyRICHPID.cxx deleted file mode 100644 index af6024f3afd..00000000000 --- a/ALICE3/TableProducer/OTF/onTheFlyRICHPID.cxx +++ /dev/null @@ -1,627 +0,0 @@ -// 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. - -// -// Task to add a table of track parameters propagated to the primary vertex -// - -#include -#include - -#include - -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/ASoAHelpers.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/trackUtilities.h" -#include "ReconstructionDataFormats/DCA.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "CommonUtils/NameConf.h" -#include "CCDB/CcdbApi.h" -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsCalibration/MeanVertexObject.h" -#include "CommonConstants/GeomConstants.h" -#include "CommonConstants/PhysicsConstants.h" -#include "TRandom3.h" -#include "TVector3.h" -#include "TString.h" -#include "ALICE3/DataModel/OTFRICH.h" -#include "DetectorsVertexing/HelixHelper.h" - -#include "TableHelper.h" -#include "ALICE3/Core/DelphesO2TrackSmearer.h" - -/// \file onTheFlyRichPid.cxx -/// -/// \brief This task goes straight from a combination of track table and mcParticles -/// and a projective bRICH configuration to a table of TOF NSigmas for the particles -/// being analysed. It currently contemplates 5 particle types: -/// electrons, pions, kaons, protons and muons. -/// -/// More particles could be added but would have to be added to the LUT -/// being used in the onTheFly tracker task. -/// -/// \warning Geometry parameters are configurable, but resolution values should be adapted. -/// Since angular resolution depends on the specific geometric details, it is better to -/// calculate it from full simulation and add new input. Alternatively, an analytical -/// expression can be provided as a function of the main parameters. -/// -/// \author David Dobrigkeit Chinellato, UNICAMP, Nicola Nicassio, University and INFN Bari - -using namespace o2; -using namespace o2::framework; - -struct OnTheFlyRichPid { - Produces upgradeRich; - - // necessary for particle charges - Service pdg; - - // master setting: magnetic field - Configurable dBz{"dBz", 20, "magnetic field (kilogauss)"}; - - // add rich-specific configurables here - Configurable bRichNumberOfSectors{"bRichNumberOfSectors", 21, "barrel RICH number of sectors"}; - Configurable bRichPhotodetectorCentralModuleHalfLength{"bRichPhotodetectorCentralModuleHalfLength", 18.4 / 2.0, "barrel RICH photodetector central module half length (cm)"}; - Configurable bRichPhotodetectorOtherModuleLength{"bRichPhotodetectorOtherModuleLength", 18.4, "barrel RICH photodetector other module length (cm)"}; - Configurable bRichRadiatorInnerRadius{"bRichRadiatorInnerRadius", 85., "barrel RICH radiator inner radius (cm)"}; - Configurable bRichPhotodetectorOuterRadius{"bRichPhotodetectorOuterRadius", 112., "barrel RICH photodetector outer radius (cm)"}; - Configurable bRichRadiatorThickness{"bRichRadiatorThickness", 2., "barrel RICH radiator thickness (cm)"}; - Configurable bRichRefractiveIndex{"bRichRefractiveIndex", 1.03, "barrel RICH refractive index"}; - Configurable bRichFlagAbsorbingWalls{"bRichFlagAbsorbingWalls", false, "barrel RICH flag absorbing walls between sectors"}; - Configurable nStepsLIntegrator{"nStepsLIntegrator", 200, "number of steps in length integrator"}; - Configurable doQAplots{"doQAplots", true, "do basic velocity plot qa"}; - Configurable nBinsThetaRing{"nBinsThetaRing", 3000, "number of bins in theta ring"}; - Configurable nBinsP{"nBinsP", 400, "number of bins in momentum"}; - Configurable nBinsNsigmaCorrectSpecies{"nBinsNsigmaCorrectSpecies", 200, "number of bins in Nsigma plot (correct speies)"}; - Configurable nBinsNsigmaWrongSpecies{"nBinsNsigmaWrongSpecies", 200, "number of bins in Nsigma plot (wrong species)"}; - Configurable nBinsAngularRes{"nBinsAngularRes", 400, "number of bins plots angular resolution"}; - Configurable nBinsRelativeEtaPt{"nBinsRelativeEtaPt", 400, "number of bins plots pt and eta relative errors"}; - Configurable nBinsEta{"nBinsEta", 400, "number of bins plot relative eta error"}; - Configurable flagIncludeTrackAngularRes{"flagIncludeTrackAngularRes", true, "flag to include or exclude track time resolution"}; - Configurable multiplicityEtaRange{"multiplicityEtaRange", 0.800000012, "eta range to compute the multiplicity"}; - Configurable flagRICHLoadDelphesLUTs{"flagRICHLoadDelphesLUTs", false, "flag to load Delphes LUTs for tracking correction (use recoTrack parameters if false)"}; - - Configurable lutEl{"lutEl", "lutCovm.el.dat", "LUT for electrons"}; - Configurable lutMu{"lutMu", "lutCovm.mu.dat", "LUT for muons"}; - Configurable lutPi{"lutPi", "lutCovm.pi.dat", "LUT for pions"}; - Configurable lutKa{"lutKa", "lutCovm.ka.dat", "LUT for kaons"}; - Configurable lutPr{"lutPr", "lutCovm.pr.dat", "LUT for protons"}; - - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - - // Track smearer (here used to get relative pt and eta uncertainties) - o2::delphes::DelphesO2TrackSmearer mSmearer; - - // needed: random number generator for smearing - TRandom3 pRandomNumberGenerator; - - // for handling basic QA histograms if requested - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - /// Flag unphysical and unavailable values - float error_value = -1000; - - // Variables projective/hybrid layout - int mNumberSectors = bRichNumberOfSectors; // 21; - float mTileLength = bRichPhotodetectorOtherModuleLength; // 18.4; // [cm] - float mTileLengthCentral = bRichPhotodetectorCentralModuleHalfLength; // 18.4 / 2.0; // [cm] - float mProjectiveLengthInner = mTileLengthCentral; - float mRadiusProjIn = bRichRadiatorInnerRadius; // 85.; // [cm] - float mRadiusProjOut = bRichPhotodetectorOuterRadius; // 112.; // [cm] - std::vector det_centers; - std::vector rad_centers; - std::vector angle_centers; - std::vector theta_min; - std::vector theta_max; - - // Update projective geometry - void updateProjectiveParameters() - { - const int number_of_sectors_in_z = mNumberSectors; - det_centers.resize(number_of_sectors_in_z); - rad_centers.resize(number_of_sectors_in_z); - angle_centers.resize(number_of_sectors_in_z); - theta_min.resize(number_of_sectors_in_z); - theta_max.resize(number_of_sectors_in_z); - float square_size_barrel_cylinder = 2.0 * mTileLengthCentral; - float square_size_z = mTileLength; - float R_min = mRadiusProjIn; - float R_max = mRadiusProjOut; - std::vector theta_bi; - std::vector R0_tilt; - std::vector z0_tilt; - std::vector T_r_plus_g; - std::vector l_aerogel_z; - std::vector l_detector_z; - theta_bi.resize(number_of_sectors_in_z); - R0_tilt.resize(number_of_sectors_in_z); - z0_tilt.resize(number_of_sectors_in_z); - T_r_plus_g.resize(number_of_sectors_in_z); - l_aerogel_z.resize(number_of_sectors_in_z); - l_detector_z.resize(number_of_sectors_in_z); - - // Central sector - int i_central_mirror = static_cast((number_of_sectors_in_z) / 2.0); - float m_val = std::tan(0.0); - theta_bi[i_central_mirror] = std::atan(m_val); - R0_tilt[i_central_mirror] = R_max; - z0_tilt[i_central_mirror] = R0_tilt[i_central_mirror] * std::tan(theta_bi[i_central_mirror]); - l_detector_z[i_central_mirror] = square_size_barrel_cylinder; - l_aerogel_z[i_central_mirror] = std::sqrt(1.0 + m_val * m_val) * R_min * square_size_barrel_cylinder / (std::sqrt(1.0 + m_val * m_val) * R_max - m_val * square_size_barrel_cylinder); - T_r_plus_g[i_central_mirror] = R_max - R_min; - float t = std::tan(atan(m_val) + std::atan(square_size_barrel_cylinder / (2.0 * R_max * std::sqrt(1.0 + m_val * m_val) - square_size_barrel_cylinder * m_val))); - theta_max[i_central_mirror] = M_PI / 2.0 - std::atan(t); - theta_min[i_central_mirror] = M_PI / 2.0 + std::atan(t); - mProjectiveLengthInner = R_min * t; - for (int i = static_cast((number_of_sectors_in_z) / 2.0) + 1; i < number_of_sectors_in_z; i++) { - float par_a = t; - float par_b = 2.0 * R_max / square_size_z; - m_val = (std::sqrt(par_a * par_a * par_b * par_b + par_b * par_b - 1.0) + par_a * par_b * par_b) / (par_b * par_b - 1.0); - theta_min[i] = M_PI / 2.0 - std::atan(t); - theta_max[2 * i_central_mirror - i] = M_PI / 2.0 + std::atan(t); - t = std::tan(std::atan(m_val) + std::atan(square_size_z / (2.0 * R_max * std::sqrt(1.0 + m_val * m_val) - square_size_z * m_val))); - theta_max[i] = M_PI / 2.0 - std::atan(t); - theta_min[2 * i_central_mirror - i] = M_PI / 2.0 + std::atan(t); - // Forward sectors - theta_bi[i] = std::atan(m_val); - R0_tilt[i] = R_max - square_size_z / 2.0 * std::sin(std::atan(m_val)); - z0_tilt[i] = R0_tilt[i] * std::tan(theta_bi[i]); - l_detector_z[i] = square_size_z; - l_aerogel_z[i] = std::sqrt(1.0 + m_val * m_val) * R_min * square_size_z / (std::sqrt(1.0 + m_val * m_val) * R_max - m_val * square_size_z); - T_r_plus_g[i] = std::sqrt(1.0 + m_val * m_val) * (R_max - R_min) - m_val / 2.0 * (square_size_z + l_aerogel_z[i]); - // Backword sectors - theta_bi[2 * i_central_mirror - i] = -std::atan(m_val); - R0_tilt[2 * i_central_mirror - i] = R_max - square_size_z / 2.0 * std::sin(std::atan(m_val)); - z0_tilt[2 * i_central_mirror - i] = -R0_tilt[i] * std::tan(theta_bi[i]); - l_detector_z[2 * i_central_mirror - i] = square_size_z; - l_aerogel_z[2 * i_central_mirror - i] = std::sqrt(1.0 + m_val * m_val) * R_min * square_size_z / (std::sqrt(1.0 + m_val * m_val) * R_max - m_val * square_size_z); - T_r_plus_g[2 * i_central_mirror - i] = std::sqrt(1.0 + m_val * m_val) * (R_max - R_min) - m_val / 2.0 * (square_size_z + l_aerogel_z[i]); - mProjectiveLengthInner = R_min * t; // <-- At the end of the loop this will be the maximum Z - } - // Coordinate radiali layer considerati - std::vector R0_detector; - std::vector R0_aerogel; - R0_detector.resize(number_of_sectors_in_z); - R0_aerogel.resize(number_of_sectors_in_z); - for (int i = 0; i < number_of_sectors_in_z; i++) { - R0_detector[i] = R0_tilt[i]; - det_centers[i].SetXYZ(R0_detector[i], 0, R0_detector[i] * std::tan(theta_bi[i])); - R0_aerogel[i] = R0_tilt[i] - (T_r_plus_g[i]) * std::cos(theta_bi[i]); - rad_centers[i].SetXYZ(R0_aerogel[i], 0, R0_aerogel[i] * std::tan(theta_bi[i])); - angle_centers[i] = theta_bi[i]; - } - } - - void init(o2::framework::InitContext&) - { - pRandomNumberGenerator.SetSeed(0); // fully randomize - - // Load LUT for pt and eta smearing - if (flagIncludeTrackAngularRes && flagRICHLoadDelphesLUTs) { - std::map mapPdgLut; - const char* lutElChar = lutEl->c_str(); - const char* lutMuChar = lutMu->c_str(); - const char* lutPiChar = lutPi->c_str(); - const char* lutKaChar = lutKa->c_str(); - const char* lutPrChar = lutPr->c_str(); - - LOGF(info, "Will load electron lut file ..: %s for RICH PID", lutElChar); - LOGF(info, "Will load muon lut file ......: %s for RICH PID", lutMuChar); - LOGF(info, "Will load pion lut file ......: %s for RICH PID", lutPiChar); - LOGF(info, "Will load kaon lut file ......: %s for RICH PID", lutKaChar); - LOGF(info, "Will load proton lut file ....: %s for RICH PID", lutPrChar); - - mapPdgLut.insert(std::make_pair(11, lutElChar)); - mapPdgLut.insert(std::make_pair(13, lutMuChar)); - mapPdgLut.insert(std::make_pair(211, lutPiChar)); - mapPdgLut.insert(std::make_pair(321, lutKaChar)); - mapPdgLut.insert(std::make_pair(2212, lutPrChar)); - - for (auto e : mapPdgLut) { - if (!mSmearer.loadTable(e.first, e.second)) { - LOG(fatal) << "Having issue with loading the LUT " << e.first << " " << e.second; - } - } - } - - if (doQAplots) { - const AxisSpec axisMomentum{static_cast(nBinsP), 0.0f, +20.0f, "#it{p} (GeV/#it{c})"}; - const AxisSpec axisAngle{static_cast(nBinsThetaRing), 0.0f, +0.30f, "Measured Cherenkov angle (rad)"}; - histos.add("h2dAngleVsMomentumBarrelRICH", "h2dAngleVsMomentumBarrelRICH", kTH2F, {axisMomentum, axisAngle}); - - std::string particle_names1[5] = {"#it{e}", "#it{#mu}", "#it{#pi}", "#it{K}", "#it{p}"}; - std::string particle_names2[5] = {"Elec", "Muon", "Pion", "Kaon", "Prot"}; - for (int i_true = 0; i_true < 5; i_true++) { - std::string name_title_barrel_track_res = "h2dBarrelAngularResTrack" + particle_names2[i_true] + "VsP"; - std::string name_title_barrel_total_res = "h2dBarrelAngularResTotal" + particle_names2[i_true] + "VsP"; - const AxisSpec axisTrackAngularRes{static_cast(nBinsAngularRes), 0.0f, +5.0f, "Track angular resolution - " + particle_names1[i_true] + " (mrad)"}; - const AxisSpec axisTotalAngularRes{static_cast(nBinsAngularRes), 0.0f, +5.0f, "Total angular resolution - " + particle_names1[i_true] + " (mrad)"}; - histos.add(name_title_barrel_track_res.c_str(), name_title_barrel_track_res.c_str(), kTH2F, {axisMomentum, axisTrackAngularRes}); - histos.add(name_title_barrel_total_res.c_str(), name_title_barrel_total_res.c_str(), kTH2F, {axisMomentum, axisTotalAngularRes}); - } - for (int i_true = 0; i_true < 5; i_true++) { - for (int i_hyp = 0; i_hyp < 5; i_hyp++) { - std::string name_title = "h2dBarrelNsigmaTrue" + particle_names2[i_true] + "Vs" + particle_names2[i_hyp] + "Hypothesis"; - if (i_true == i_hyp) { - const AxisSpec axisNsigmaCorrect{static_cast(nBinsNsigmaCorrectSpecies), -10.0f, +10.0f, "N#sigma - True " + particle_names1[i_true] + " vs " + particle_names1[i_hyp] + " hypothesis"}; - histos.add(name_title.c_str(), name_title.c_str(), kTH2F, {axisMomentum, axisNsigmaCorrect}); - } else { - const AxisSpec axisNsigmaWrong{static_cast(nBinsNsigmaWrongSpecies), -10.0f, +10.0f, "N#sigma - True " + particle_names1[i_true] + " vs " + particle_names1[i_hyp] + " hypothesis"}; - histos.add(name_title.c_str(), name_title.c_str(), kTH2F, {axisMomentum, axisNsigmaWrong}); - } - } - } - } - - // Update projective parameters - updateProjectiveParameters(); - } - - /// Function to convert a McParticle into a perfect Track - /// \param particle the particle to convert (mcParticle) - /// \param o2track the address of the resulting TrackParCov - template - o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle) - { - // FIXME: this is a fundamentally important piece of code. - // It could be placed in a utility file instead of here. - auto pdgInfo = pdg->GetParticle(particle.pdgCode()); - int charge = 0; - if (pdgInfo != nullptr) { - charge = pdgInfo->Charge() / 3; - } - std::array params; - std::array covm = {0.}; - float s, c, x; - o2::math_utils::sincos(particle.phi(), s, c); - o2::math_utils::rotateZInv(particle.vx(), particle.vy(), x, params[0], s, c); - params[1] = particle.vz(); - params[2] = 0.; // since alpha = phi - auto theta = 2. * std::atan(std::exp(-particle.eta())); - params[3] = 1. / std::tan(theta); - params[4] = charge / particle.pt(); - - // Return TrackParCov - return o2::track::TrackParCov(x, particle.phi(), params, covm); - } - - /// check if particle reaches radiator - /// \param track the input track - /// \param radius the radius of the layer you're calculating the length to - /// \param magneticField the magnetic field to use when propagating - bool checkMagfieldLimit(o2::track::TrackParCov track, float radius, float magneticField) - { - o2::math_utils::CircleXYf_t trcCircle; - float sna, csa; - track.getCircleParams(magneticField, trcCircle, sna, csa); - - // distance between circle centers (one circle is at origin -> easy) - float centerDistance = std::hypot(trcCircle.xC, trcCircle.yC); - - // condition of circles touching - if not satisfied returned value if false - if (centerDistance < trcCircle.rC + radius && centerDistance > std::fabs(trcCircle.rC - radius)) { - return true; - } else { - return false; - } - } - - /// returns radiator radius in cm at considered eta (accounting for sector inclination) - /// \param eta the pseudorapidity of the tarck (assuming primary vertex at origin) - float radiusRipple(float eta) - { - float polar = 2.0 * std::atan(std::exp(-eta)); - float i_sector = 0; - bool flag_sector = false; - for (int j_sec = 0; j_sec < mNumberSectors; j_sec++) { - if (polar > theta_max[j_sec] && polar < theta_min[j_sec]) { - flag_sector = true; - i_sector = j_sec; - } - } - if (flag_sector) { - float R_sec_rich = rad_centers[i_sector].X(); - float z_sec_rich = rad_centers[i_sector].Z(); - return (std::pow(R_sec_rich, 2) + std::pow(z_sec_rich, 2)) / (R_sec_rich + z_sec_rich / std::tan(polar)); - } else { - return error_value; - } - } - - /// returns Cherenkov angle in rad (above threshold) or bad flag (below threshold) - /// \param momentum the momentum of the tarck - /// \param mass the mass of the particle - float CherenkovAngle(float momentum, float mass) - { - // Check if particle is above the threshold - if (momentum > mass / std::sqrt(bRichRefractiveIndex * bRichRefractiveIndex - 1.0)) { - // Calculate angle - float angle = std::acos(std::sqrt(momentum * momentum + mass * mass) / (momentum * bRichRefractiveIndex)); - - // Mean number of detected photons (SiPM PDE is accountd in multiplicative factor!!!) - float meanNumberofDetectedPhotons = 230. * std::sin(angle) * std::sin(angle) * bRichRadiatorThickness; - - // Require at least 3 photons on average for real angle reconstruction - if (meanNumberofDetectedPhotons > 3.) { - return angle; - } else { - return error_value; - } - } else { - return error_value; - } - } - - /// returns linear interpolation - /// \param x the eta we want the resolution for - /// \param x0 the closest smaller available eta - /// \param x1 the closest larger available eta - /// \param y0 the resolution corresponding to x0 - /// \param y1 the resolution corresponding to x1 - float interpolate(double x, double x0, double x1, double y0, double y1) - { - float y = y0 + ((y1 - y0) / (x1 - x0)) * (x - x0); - return y; - } - - /// returns angular resolution for considered track eta - /// \param eta the pseudorapidity of the tarck (assuming primary vertex at origin) - float AngularResolution(float eta) - { - // Vectors for sampling (USE ANALYTICAL EXTRAPOLATION FOR BETTER RESULTS) - float eta_sampling[] = {-2.000000, -1.909740, -1.731184, -1.552999, -1.375325, -1.198342, -1.022276, -0.847390, -0.673976, -0.502324, -0.332683, -0.165221, 0.000000, 0.165221, 0.332683, 0.502324, 0.673976, 0.847390, 1.022276, 1.198342, 1.375325, 1.552999, 1.731184, 1.909740, 2.000000}; - float res_ring_sampling_with_abs_walls[] = {0.0009165, 0.000977, 0.001098, 0.001198, 0.001301, 0.001370, 0.001465, 0.001492, 0.001498, 0.001480, 0.001406, 0.001315, 0.001241, 0.001325, 0.001424, 0.001474, 0.001480, 0.001487, 0.001484, 0.001404, 0.001273, 0.001197, 0.001062, 0.000965, 0.0009165}; - float res_ring_sampling_without_abs_walls[] = {0.0009165, 0.000977, 0.001095, 0.001198, 0.001300, 0.001369, 0.001468, 0.001523, 0.001501, 0.001426, 0.001299, 0.001167, 0.001092, 0.001179, 0.001308, 0.001407, 0.001491, 0.001508, 0.001488, 0.001404, 0.001273, 0.001196, 0.001061, 0.000965, 0.0009165}; - int size_res_vector = sizeof(eta_sampling) / sizeof(eta_sampling[0]); - // Use binary search to find the lower and upper indices - int lowerIndex = std::lower_bound(eta_sampling, eta_sampling + size_res_vector, eta) - eta_sampling - 1; - int upperIndex = lowerIndex + 1; - if (lowerIndex >= 0 && upperIndex < size_res_vector) { - // Resolution interpolation - if (bRichFlagAbsorbingWalls) { - float interpolatedResRing = interpolate(eta, eta_sampling[lowerIndex], eta_sampling[upperIndex], res_ring_sampling_with_abs_walls[lowerIndex], res_ring_sampling_with_abs_walls[upperIndex]); - // std::cout << "Interpolated y value: " << interpolatedY << std::endl; - return interpolatedResRing; - } else { - float interpolatedResRing = interpolate(eta, eta_sampling[lowerIndex], eta_sampling[upperIndex], res_ring_sampling_without_abs_walls[lowerIndex], res_ring_sampling_without_abs_walls[upperIndex]); - // std::cout << "Interpolated y value: " << interpolatedY << std::endl; - return interpolatedResRing; - } - } else { - // std::cout << "Unable to interpolate. Target x value is outside the range of available data." << std::endl; - return error_value; - } - } - - /// returns track angular resolution - /// \param pt the transverse momentum of the tarck - /// \param eta the pseudorapidity of the tarck - /// \param track_pt_resolution the absolute resolution on pt - /// \param track_pt_resolution the absolute resolution on eta - /// \param mass the mass of the particle - /// \param refractive_index the refractive index of the radiator - double calculate_track_time_resolution_advanced(float pt, float eta, float track_pt_resolution, float track_eta_resolution, float mass, float refractive_index) - { - // Compute tracking contribution to timing using the error propagation formula - // Uses light speed in m/ps, magnetic field in T (*0.1 for conversion kGauss -> T) - double a0 = mass * mass; - double a1 = refractive_index; - double dtheta_on_dpt = a0 / (pt * std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2)) * std::sqrt(std::pow(pt * std::cosh(eta), 2) * (std::pow(a1, 2) - 1.0) - a0)); - double dtheta_on_deta = (a0 * std::tanh(eta)) / (std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2)) * std::sqrt(std::pow(pt * std::cosh(eta), 2) * (std::pow(a1, 2) - 1.0) - a0)); - double track_angular_resolution = std::hypot(std::fabs(dtheta_on_dpt) * track_pt_resolution, std::fabs(dtheta_on_deta) * track_eta_resolution); - return track_angular_resolution; - } - - void process(soa::Join::iterator const& collision, soa::Join const& tracks, aod::McParticles const&, aod::McCollisions const&) - { - - o2::dataformats::VertexBase pvVtx({collision.posX(), collision.posY(), collision.posZ()}, - {collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}); - - std::array mcPvCov = {0.}; - o2::dataformats::VertexBase mcPvVtx({0.0f, 0.0f, 0.0f}, mcPvCov); - if (collision.has_mcCollision()) { - auto mcCollision = collision.mcCollision(); - mcPvVtx.setX(mcCollision.posX()); - mcPvVtx.setY(mcCollision.posY()); - mcPvVtx.setZ(mcCollision.posZ()); - } // else remains untreated for now - - // First we compute the number of charged particles in the event - float dNdEta = 0.f; - if (flagRICHLoadDelphesLUTs) { - for (const auto& track : tracks) { - if (!track.has_mcParticle()) - continue; - auto mcParticle = track.mcParticle(); - if (std::abs(mcParticle.eta()) > multiplicityEtaRange) { - continue; - } - if (mcParticle.has_daughters()) { - continue; - } - const auto& pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); - if (!pdgInfo) { - // LOG(warning) << "PDG code " << mcParticle.pdgCode() << " not found in the database"; - continue; - } - if (pdgInfo->Charge() == 0) { - continue; - } - dNdEta += 1.f; - } - } - - for (const auto& track : tracks) { - // first step: find precise arrival time (if any) - // --- convert track into perfect track - if (!track.has_mcParticle()) // should always be OK but check please - continue; - - auto mcParticle = track.mcParticle(); - o2::track::TrackParCov o2track = convertMCParticleToO2Track(mcParticle); - - // float xPv = error_value; - if (o2track.propagateToDCA(mcPvVtx, dBz)) { - // xPv = o2track.getX(); - } - - // get particle to calculate Cherenkov angle and resolution - auto pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); - if (pdgInfo == nullptr) { - continue; - } - float expectedAngleBarrelRich = CherenkovAngle(o2track.getP(), pdgInfo->Mass()); - float barrelRICHAngularResolution = AngularResolution(o2track.getEta()); - float projectiveRadiatorRadius = radiusRipple(o2track.getEta()); - bool flagReachesRadiator = false; - if (projectiveRadiatorRadius > error_value + 1.) { - flagReachesRadiator = checkMagfieldLimit(o2track, projectiveRadiatorRadius, dBz); - } - /// DISCLAIMER: Exact extrapolation of angular resolution would require track propagation - /// to the RICH radiator (accounting sector inclination) in terms of (R,z). - /// The extrapolation with Eta is correct only if the primary vertex is at origin. - /// Discrepancies may be negligible, but would be more rigorous if propagation tool is available - - // Smear with expected resolutions - float measuredAngleBarrelRich = pRandomNumberGenerator.Gaus(expectedAngleBarrelRich, barrelRICHAngularResolution); - - // Now we calculate the expected arrival time following certain mass hypotheses - // and the (imperfect!) reconstructed track parametrizations - auto recoTrack = getTrackParCov(track); - if (recoTrack.propagateToDCA(pvVtx, dBz)) { - // xPv = recoTrack.getX(); - } - - // Straight to Nsigma - float deltaThetaBarrelRich[5], nSigmaBarrelRich[5]; - int lpdg_array[5] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; - float masses[5]; - - for (int ii = 0; ii < 5; ii++) { - nSigmaBarrelRich[ii] = error_value; - - auto pdgInfoThis = pdg->GetParticle(lpdg_array[ii]); - masses[ii] = pdgInfoThis->Mass(); - float hypothesisAngleBarrelRich = CherenkovAngle(recoTrack.getP(), masses[ii]); - - // Evaluate total sigma (layer + tracking resolution) - float barrelTotalAngularReso = barrelRICHAngularResolution; - if (flagIncludeTrackAngularRes) { - double pt_resolution = std::pow(recoTrack.getP() / std::cosh(recoTrack.getEta()), 2) * std::sqrt(recoTrack.getSigma1Pt2()); - double eta_resolution = std::fabs(std::sin(2.0 * std::atan(std::exp(-recoTrack.getEta())))) * std::sqrt(recoTrack.getSigmaTgl2()); - if (flagRICHLoadDelphesLUTs) { - pt_resolution = mSmearer.getAbsPtRes(pdgInfoThis->PdgCode(), dNdEta, recoTrack.getEta(), recoTrack.getP() / std::cosh(recoTrack.getEta())); - eta_resolution = mSmearer.getAbsEtaRes(pdgInfoThis->PdgCode(), dNdEta, recoTrack.getEta(), recoTrack.getP() / std::cosh(recoTrack.getEta())); - } - // cout << endl << "Pt resolution: " << pt_resolution << ", Eta resolution: " << eta_resolution << endl << endl; - float barrelTrackAngularReso = calculate_track_time_resolution_advanced(recoTrack.getP() / std::cosh(recoTrack.getEta()), recoTrack.getEta(), pt_resolution, eta_resolution, masses[ii], bRichRefractiveIndex); - barrelTotalAngularReso = std::hypot(barrelRICHAngularResolution, barrelTrackAngularReso); - if (doQAplots && hypothesisAngleBarrelRich > error_value + 1. && measuredAngleBarrelRich > error_value + 1. && barrelRICHAngularResolution > error_value + 1. && flagReachesRadiator) { - float momentum = recoTrack.getP(); - // float pseudorapidity = recoTrack.getEta(); - // float transverse_momentum = momentum / std::cosh(pseudorapidity); - if (ii == 0 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[0])->PdgCode()) { - histos.fill(HIST("h2dBarrelAngularResTrackElecVsP"), momentum, 1000.0 * barrelTrackAngularReso); - histos.fill(HIST("h2dBarrelAngularResTotalElecVsP"), momentum, 1000.0 * barrelTotalAngularReso); - } - if (ii == 1 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[1])->PdgCode()) { - histos.fill(HIST("h2dBarrelAngularResTrackMuonVsP"), momentum, 1000.0 * barrelTrackAngularReso); - histos.fill(HIST("h2dBarrelAngularResTotalMuonVsP"), momentum, 1000.0 * barrelTotalAngularReso); - } - if (ii == 2 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[2])->PdgCode()) { - histos.fill(HIST("h2dBarrelAngularResTrackPionVsP"), momentum, 1000.0 * barrelTrackAngularReso); - histos.fill(HIST("h2dBarrelAngularResTotalPionVsP"), momentum, 1000.0 * barrelTotalAngularReso); - } - if (ii == 3 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[3])->PdgCode()) { - histos.fill(HIST("h2dBarrelAngularResTrackKaonVsP"), momentum, 1000.0 * barrelTrackAngularReso); - histos.fill(HIST("h2dBarrelAngularResTotalKaonVsP"), momentum, 1000.0 * barrelTotalAngularReso); - } - if (ii == 4 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[4])->PdgCode()) { - histos.fill(HIST("h2dBarrelAngularResTrackProtVsP"), momentum, 1000.0 * barrelTrackAngularReso); - histos.fill(HIST("h2dBarrelAngularResTotalProtVsP"), momentum, 1000.0 * barrelTotalAngularReso); - } - } - } - - /// DISCLAIMER: here tracking is accounted only for momentum value, but not for track parameters at impact point on the - /// RICH radiator, since exact resolution would require photon generation and transport to photodetector. - /// Effects are expected to be negligible (a few tenths of a milliradian) but further studies are required ! - if (hypothesisAngleBarrelRich > error_value + 1. && measuredAngleBarrelRich > error_value + 1. && barrelRICHAngularResolution > error_value + 1. && flagReachesRadiator) { - deltaThetaBarrelRich[ii] = hypothesisAngleBarrelRich - measuredAngleBarrelRich; - nSigmaBarrelRich[ii] = deltaThetaBarrelRich[ii] / barrelTotalAngularReso; - } - } - - // Fill histograms - if (doQAplots) { - float momentum = recoTrack.getP(); - float barrelRichTheta = measuredAngleBarrelRich; - - if (barrelRichTheta > error_value + 1. && barrelRICHAngularResolution > error_value + 1. && flagReachesRadiator) { - histos.fill(HIST("h2dAngleVsMomentumBarrelRICH"), momentum, barrelRichTheta); - - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[0])->PdgCode()) { - histos.fill(HIST("h2dBarrelNsigmaTrueElecVsElecHypothesis"), momentum, nSigmaBarrelRich[0]); - histos.fill(HIST("h2dBarrelNsigmaTrueElecVsMuonHypothesis"), momentum, nSigmaBarrelRich[1]); - histos.fill(HIST("h2dBarrelNsigmaTrueElecVsPionHypothesis"), momentum, nSigmaBarrelRich[2]); - histos.fill(HIST("h2dBarrelNsigmaTrueElecVsKaonHypothesis"), momentum, nSigmaBarrelRich[3]); - histos.fill(HIST("h2dBarrelNsigmaTrueElecVsProtHypothesis"), momentum, nSigmaBarrelRich[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[1])->PdgCode()) { - histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsElecHypothesis"), momentum, nSigmaBarrelRich[0]); - histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsMuonHypothesis"), momentum, nSigmaBarrelRich[1]); - histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsPionHypothesis"), momentum, nSigmaBarrelRich[2]); - histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsKaonHypothesis"), momentum, nSigmaBarrelRich[3]); - histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsProtHypothesis"), momentum, nSigmaBarrelRich[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[2])->PdgCode()) { - histos.fill(HIST("h2dBarrelNsigmaTruePionVsElecHypothesis"), momentum, nSigmaBarrelRich[0]); - histos.fill(HIST("h2dBarrelNsigmaTruePionVsMuonHypothesis"), momentum, nSigmaBarrelRich[1]); - histos.fill(HIST("h2dBarrelNsigmaTruePionVsPionHypothesis"), momentum, nSigmaBarrelRich[2]); - histos.fill(HIST("h2dBarrelNsigmaTruePionVsKaonHypothesis"), momentum, nSigmaBarrelRich[3]); - histos.fill(HIST("h2dBarrelNsigmaTruePionVsProtHypothesis"), momentum, nSigmaBarrelRich[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[3])->PdgCode()) { - histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsElecHypothesis"), momentum, nSigmaBarrelRich[0]); - histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsMuonHypothesis"), momentum, nSigmaBarrelRich[1]); - histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsPionHypothesis"), momentum, nSigmaBarrelRich[2]); - histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsKaonHypothesis"), momentum, nSigmaBarrelRich[3]); - histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsProtHypothesis"), momentum, nSigmaBarrelRich[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[4])->PdgCode()) { - histos.fill(HIST("h2dBarrelNsigmaTrueProtVsElecHypothesis"), momentum, nSigmaBarrelRich[0]); - histos.fill(HIST("h2dBarrelNsigmaTrueProtVsMuonHypothesis"), momentum, nSigmaBarrelRich[1]); - histos.fill(HIST("h2dBarrelNsigmaTrueProtVsPionHypothesis"), momentum, nSigmaBarrelRich[2]); - histos.fill(HIST("h2dBarrelNsigmaTrueProtVsKaonHypothesis"), momentum, nSigmaBarrelRich[3]); - histos.fill(HIST("h2dBarrelNsigmaTrueProtVsProtHypothesis"), momentum, nSigmaBarrelRich[4]); - } - } - } - - // Sigmas have been fully calculated. Please populate the NSigma helper table (once per track) - upgradeRich(nSigmaBarrelRich[0], nSigmaBarrelRich[1], nSigmaBarrelRich[2], nSigmaBarrelRich[3], nSigmaBarrelRich[4]); - } - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx new file mode 100644 index 00000000000..79279bbc70e --- /dev/null +++ b/ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx @@ -0,0 +1,989 @@ +// 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. +/// +/// \file onTheFlyRichPid.cxx +/// +/// \brief This task goes straight from a combination of track table and mcParticles +/// and a projective bRICH configuration to a table of TOF NSigmas for the particles +/// being analysed. It currently contemplates 5 particle types: +/// electrons, pions, kaons, protons and muons +/// +/// More particles could be added but would have to be added to the LUT +/// being used in the onTheFly tracker task. +/// +/// \warning Geometry parameters are configurable, but resolution values should be adapted. +/// Since angular resolution depends on the specific geometric details, it is better to +/// calculate it from full simulation and add new input. Alternatively, an analytical +/// expression can be provided as a function of the main parameters. +/// Latest version: analytical parametrization of angular resolution !!! +/// +/// \author David Dobrigkeit Chinellato, UNICAMP +/// \author Nicola Nicassio, University and INFN Bari +/// \since May 22, 2024 +/// + +#include "TableHelper.h" + +#include "ALICE3/Core/DelphesO2TrackSmearer.h" +#include "ALICE3/Core/TrackUtilities.h" +#include "ALICE3/DataModel/OTFRICH.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "CommonConstants/GeomConstants.h" +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "CommonUtils/NameConf.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsVertexing/HelixHelper.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/PID.h" + +#include "TRandom3.h" +#include "TString.h" +#include "TVector3.h" +#include + +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::constants::math; + +struct OnTheFlyRichPid { + Produces upgradeRich; + Produces upgradeRichSignal; + + // necessary for particle charges + Service pdg; + + // master setting: magnetic field + Configurable magneticField{"magneticField", 0, "magnetic field (kilogauss) if 0, taken from the tracker task"}; + + // add rich-specific configurables here + Configurable bRichNumberOfSectors{"bRichNumberOfSectors", 21, "barrel RICH number of sectors"}; + Configurable bRichPhotodetectorCentralModuleHalfLength{"bRichPhotodetectorCentralModuleHalfLength", 18.4 / 2.0, "barrel RICH photodetector central module half length (cm)"}; + Configurable bRichPhotodetectorOtherModuleLength{"bRichPhotodetectorOtherModuleLength", 18.4, "barrel RICH photodetector other module length (cm)"}; + Configurable bRichRadiatorInnerRadius{"bRichRadiatorInnerRadius", 85., "barrel RICH radiator inner radius (cm)"}; + Configurable bRichPhotodetectorOuterRadius{"bRichPhotodetectorOuterRadius", 112., "barrel RICH photodetector outer radius (cm)"}; + Configurable bRichRadiatorThickness{"bRichRadiatorThickness", 2., "barrel RICH radiator thickness (cm)"}; + Configurable bRichRefractiveIndex{"bRichRefractiveIndex", 1.03, "barrel RICH refractive index"}; + Configurable bRichFlagAbsorbingWalls{"bRichFlagAbsorbingWalls", false, "barrel RICH flag absorbing walls between sectors"}; + Configurable nStepsLIntegrator{"nStepsLIntegrator", 200, "number of steps in length integrator"}; + Configurable doQAplots{"doQAplots", true, "do basic velocity plot qa"}; + Configurable nBinsThetaRing{"nBinsThetaRing", 3000, "number of bins in theta ring"}; + Configurable nBinsP{"nBinsP", 400, "number of bins in momentum"}; + Configurable nBinsNsigmaCorrectSpecies{"nBinsNsigmaCorrectSpecies", 200, "number of bins in Nsigma plot (correct speies)"}; + Configurable nBinsNsigmaWrongSpecies{"nBinsNsigmaWrongSpecies", 200, "number of bins in Nsigma plot (wrong species)"}; + Configurable nBinsAngularRes{"nBinsAngularRes", 400, "number of bins plots angular resolution"}; + Configurable nBinsRelativeEtaPt{"nBinsRelativeEtaPt", 400, "number of bins plots pt and eta relative errors"}; + Configurable nBinsEta{"nBinsEta", 400, "number of bins plot relative eta error"}; + Configurable flagIncludeTrackAngularRes{"flagIncludeTrackAngularRes", true, "flag to include or exclude track time resolution"}; + Configurable multiplicityEtaRange{"multiplicityEtaRange", 0.800000012, "eta range to compute the multiplicity"}; + Configurable flagRICHLoadDelphesLUTs{"flagRICHLoadDelphesLUTs", false, "flag to load Delphes LUTs for tracking correction (use recoTrack parameters if false)"}; + Configurable gasRadiatorRindex{"gasRadiatorRindex", 1.0006f, "gas radiator refractive index"}; + Configurable gasRichRadiatorThickness{"gasRichRadiatorThickness", 25.f, "gas radiator thickness (cm)"}; + Configurable bRichRefractiveIndexSector0{"bRichRefractiveIndexSector0", 1.03, "barrel RICH refractive index central(s)"}; // central(s) + Configurable bRichRefractiveIndexSector1{"bRichRefractiveIndexSector1", 1.03, "barrel RICH refractive index central(s)-1 and central(s)+1"}; // central(s)-1 and central(s)+1 + Configurable bRichRefractiveIndexSector2{"bRichRefractiveIndexSector2", 1.03, "barrel RICH refractive index central(s)-2 and central(s)+2"}; // central(s)-2 and central(s)+2 + Configurable bRichRefractiveIndexSector3{"bRichRefractiveIndexSector3", 1.03, "barrel RICH refractive index central(s)-3 and central(s)+3"}; // central(s)-3 and central(s)+3 + Configurable bRichRefractiveIndexSector4{"bRichRefractiveIndexSector4", 1.03, "barrel RICH refractive index central(s)-4 and central(s)+4"}; // central(s)-4 and central(s)+4 + Configurable bRichRefractiveIndexSector5{"bRichRefractiveIndexSector5", 1.03, "barrel RICH refractive index central(s)-5 and central(s)+5"}; // central(s)-5 and central(s)+5 + Configurable bRichRefractiveIndexSector6{"bRichRefractiveIndexSector6", 1.03, "barrel RICH refractive index central(s)-6 and central(s)+6"}; // central(s)-6 and central(s)+6 + Configurable bRichRefractiveIndexSector7{"bRichRefractiveIndexSector7", 1.03, "barrel RICH refractive index central(s)-7 and central(s)+7"}; // central(s)-7 and central(s)+7 + Configurable bRichRefractiveIndexSector8{"bRichRefractiveIndexSector8", 1.03, "barrel RICH refractive index central(s)-8 and central(s)+8"}; // central(s)-8 and central(s)+8 + Configurable bRichRefractiveIndexSector9{"bRichRefractiveIndexSector9", 1.03, "barrel RICH refractive index central(s)-9 and central(s)+9"}; // central(s)-9 and central(s)+9 + Configurable bRichRefractiveIndexSector10{"bRichRefractiveIndexSector10", 1.03, "barrel RICH refractive index central(s)-10 and central(s)+10"}; // central(s)-10 and central(s)+10 + Configurable bRichRefractiveIndexSector11{"bRichRefractiveIndexSector11", 1.03, "barrel RICH refractive index central(s)-11 and central(s)+11"}; // central(s)-11 and central(s)+11 + Configurable bRichRefractiveIndexSector12{"bRichRefractiveIndexSector12", 1.03, "barrel RICH refractive index central(s)-12 and central(s)+12"}; // central(s)-12 and central(s)+12 + Configurable bRichRefractiveIndexSector13{"bRichRefractiveIndexSector13", 1.03, "barrel RICH refractive index central(s)-13 and central(s)+13"}; // central(s)-13 and central(s)+13 + Configurable bRichRefractiveIndexSector14{"bRichRefractiveIndexSector14", 1.03, "barrel RICH refractive index central(s)-14 and central(s)+14"}; // central(s)-14 and central(s)+14 + Configurable bRichRefractiveIndexSector15{"bRichRefractiveIndexSector15", 1.03, "barrel RICH refractive index central(s)-15 and central(s)+15"}; // central(s)-15 and central(s)+15 + Configurable bRichRefractiveIndexSector16{"bRichRefractiveIndexSector16", 1.03, "barrel RICH refractive index central(s)-16 and central(s)+16"}; // central(s)-16 and central(s)+16 + Configurable bRichRefractiveIndexSector17{"bRichRefractiveIndexSector17", 1.03, "barrel RICH refractive index central(s)-17 and central(s)+17"}; // central(s)-17 and central(s)+17 + Configurable bRichRefractiveIndexSector18{"bRichRefractiveIndexSector18", 1.03, "barrel RICH refractive index central(s)-18 and central(s)+18"}; // central(s)-18 and central(s)+18 + Configurable bRichRefractiveIndexSector19{"bRichRefractiveIndexSector19", 1.03, "barrel RICH refractive index central(s)-19 and central(s)+19"}; // central(s)-19 and central(s)+19 + Configurable bRichRefractiveIndexSector20{"bRichRefractiveIndexSector20", 1.03, "barrel RICH refractive index central(s)-20 and central(s)+20"}; // central(s)-20 and central(s)+20 + Configurable bRICHPixelSize{"bRICHPixelSize", 0.1, "barrel RICH pixel size (cm)"}; + Configurable bRichGapRefractiveIndex{"bRichGapRefractiveIndex", 1.000283, "barrel RICH gap refractive index"}; + + struct : ConfigurableGroup { + Configurable lutEl{"lutEl", "inherit", "LUT for electrons (if inherit, inherits from otf tracker task)"}; + Configurable lutMu{"lutMu", "inherit", "LUT for muons (if inherit, inherits from otf tracker task)"}; + Configurable lutPi{"lutPi", "inherit", "LUT for pions (if inherit, inherits from otf tracker task)"}; + Configurable lutKa{"lutKa", "inherit", "LUT for kaons (if inherit, inherits from otf tracker task)"}; + Configurable lutPr{"lutPr", "inherit", "LUT for protons (if inherit, inherits from otf tracker task)"}; + } simConfig; + + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + + // Track smearer (here used to get relative pt and eta uncertainties) + o2::delphes::DelphesO2TrackSmearer mSmearer; + + // needed: random number generator for smearing + TRandom3 pRandomNumberGenerator; + + // for handling basic QA histograms if requested + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + /// Flag unphysical and unavailable values (must be negative) + static constexpr float kErrorValue = -1000; + + // Variables projective/hybrid layout + std::vector detCenters; + std::vector radCenters; + std::vector angleCenters; + std::vector thetaMin; + std::vector thetaMax; + std::vector bRichRefractiveIndexSector; + std::vector aerogelRindex; + std::vector photodetrctorLength; + std::vector gapThickness; + + // Update projective geometry + void updateProjectiveParameters() + { + const int numberOfSectorsInZ = bRichNumberOfSectors; + detCenters.resize(numberOfSectorsInZ); + radCenters.resize(numberOfSectorsInZ); + angleCenters.resize(numberOfSectorsInZ); + thetaMin.resize(numberOfSectorsInZ); + thetaMax.resize(numberOfSectorsInZ); + aerogelRindex.resize(numberOfSectorsInZ); + photodetrctorLength.resize(numberOfSectorsInZ); + gapThickness.resize(numberOfSectorsInZ); + float squareSizeBarrelCylinder = 2.0 * bRichPhotodetectorCentralModuleHalfLength; + float squareSizeZ = bRichPhotodetectorOtherModuleLength; + float rMin = bRichRadiatorInnerRadius; + float rMax = bRichPhotodetectorOuterRadius; + std::vector thetaBi; + std::vector r0Tilt; + std::vector z0Tilt; + std::vector tRPlusG; + std::vector lAerogelZ; + std::vector lDetectorZ; + thetaBi.resize(numberOfSectorsInZ); + r0Tilt.resize(numberOfSectorsInZ); + z0Tilt.resize(numberOfSectorsInZ); + tRPlusG.resize(numberOfSectorsInZ); + lAerogelZ.resize(numberOfSectorsInZ); + lDetectorZ.resize(numberOfSectorsInZ); + + // Odd number of sectors + static constexpr int kTwo = 2; + if (numberOfSectorsInZ % kTwo != 0) { + int iCentralMirror = static_cast((numberOfSectorsInZ) / 2.0); + float mVal = std::tan(0.0); + thetaBi[iCentralMirror] = std::atan(mVal); + r0Tilt[iCentralMirror] = rMax; + z0Tilt[iCentralMirror] = r0Tilt[iCentralMirror] * std::tan(thetaBi[iCentralMirror]); + lDetectorZ[iCentralMirror] = squareSizeBarrelCylinder; + lAerogelZ[iCentralMirror] = std::sqrt(1.0 + mVal * mVal) * rMin * squareSizeBarrelCylinder / (std::sqrt(1.0 + mVal * mVal) * rMax - mVal * squareSizeBarrelCylinder); + tRPlusG[iCentralMirror] = rMax - rMin; + float t = std::tan(std::atan(mVal) + std::atan(squareSizeBarrelCylinder / (2.0 * rMax * std::sqrt(1.0 + mVal * mVal) - squareSizeBarrelCylinder * mVal))); + thetaMax[iCentralMirror] = o2::constants::math::PIHalf - std::atan(t); + thetaMin[iCentralMirror] = o2::constants::math::PIHalf + std::atan(t); + bRichPhotodetectorCentralModuleHalfLength.value = rMin * t; + aerogelRindex[iCentralMirror] = bRichRefractiveIndexSector[0]; + for (int i = iCentralMirror + 1; i < numberOfSectorsInZ; i++) { + float parA = t; + float parB = 2.0 * rMax / squareSizeZ; + mVal = (std::sqrt(parA * parA * parB * parB + parB * parB - 1.0) + parA * parB * parB) / (parB * parB - 1.0); + thetaMin[i] = o2::constants::math::PIHalf - std::atan(t); + thetaMax[2 * iCentralMirror - i] = o2::constants::math::PIHalf + std::atan(t); + t = std::tan(std::atan(mVal) + std::atan(squareSizeZ / (2.0 * rMax * std::sqrt(1.0 + mVal * mVal) - squareSizeZ * mVal))); + thetaMax[i] = o2::constants::math::PIHalf - std::atan(t); + thetaMin[2 * iCentralMirror - i] = o2::constants::math::PIHalf + std::atan(t); + // Forward sectors + thetaBi[i] = std::atan(mVal); + r0Tilt[i] = rMax - squareSizeZ / 2.0 * std::sin(std::atan(mVal)); + z0Tilt[i] = r0Tilt[i] * std::tan(thetaBi[i]); + lDetectorZ[i] = squareSizeZ; + lAerogelZ[i] = std::sqrt(1.0 + mVal * mVal) * rMin * squareSizeZ / (std::sqrt(1.0 + mVal * mVal) * rMax - mVal * squareSizeZ); + tRPlusG[i] = std::sqrt(1.0 + mVal * mVal) * (rMax - rMin) - mVal / 2.0 * (squareSizeZ + lAerogelZ[i]); + aerogelRindex[i] = bRichRefractiveIndexSector[i - iCentralMirror]; + // Backword sectors + thetaBi[2 * iCentralMirror - i] = -std::atan(mVal); + r0Tilt[2 * iCentralMirror - i] = rMax - squareSizeZ / 2.0 * std::sin(std::atan(mVal)); + z0Tilt[2 * iCentralMirror - i] = -r0Tilt[i] * std::tan(thetaBi[i]); + lDetectorZ[2 * iCentralMirror - i] = squareSizeZ; + lAerogelZ[2 * iCentralMirror - i] = std::sqrt(1.0 + mVal * mVal) * rMin * squareSizeZ / (std::sqrt(1.0 + mVal * mVal) * rMax - mVal * squareSizeZ); + tRPlusG[2 * iCentralMirror - i] = std::sqrt(1.0 + mVal * mVal) * (rMax - rMin) - mVal / 2.0 * (squareSizeZ + lAerogelZ[i]); + aerogelRindex[2 * iCentralMirror - i] = bRichRefractiveIndexSector[i - iCentralMirror]; + bRichPhotodetectorCentralModuleHalfLength.value = rMin * t; // <-- At the end of the loop this will be the maximum z + } + } else { // Even number of sectors + float twoHalfGap = 1.0; + int iCentralMirror = static_cast((numberOfSectorsInZ) / 2.0); + float mVal = std::tan(0.0); + float t = std::tan(std::atan(mVal) + std::atan(twoHalfGap / (2.0 * rMax * std::sqrt(1.0 + mVal * mVal) - twoHalfGap * mVal))); + bRichPhotodetectorCentralModuleHalfLength.value = rMin * t; + for (int i = iCentralMirror; i < numberOfSectorsInZ; i++) { + float parA = t; + float parB = 2.0 * rMax / squareSizeZ; + mVal = (std::sqrt(parA * parA * parB * parB + parB * parB - 1.0) + parA * parB * parB) / (parB * parB - 1.0); + thetaMin[i] = o2::constants::math::PIHalf - std::atan(t); + thetaMax[2 * iCentralMirror - i - 1] = o2::constants::math::PIHalf + std::atan(t); + t = std::tan(std::atan(mVal) + std::atan(squareSizeZ / (2.0 * rMax * std::sqrt(1.0 + mVal * mVal) - squareSizeZ * mVal))); + thetaMax[i] = o2::constants::math::PIHalf - std::atan(t); + thetaMin[2 * iCentralMirror - i - 1] = o2::constants::math::PIHalf + std::atan(t); + // Forward sectors + thetaBi[i] = std::atan(mVal); + r0Tilt[i] = rMax - squareSizeZ / 2.0 * std::sin(std::atan(mVal)); + z0Tilt[i] = r0Tilt[i] * std::tan(thetaBi[i]); + lDetectorZ[i] = squareSizeZ; + lAerogelZ[i] = std::sqrt(1.0 + mVal * mVal) * rMin * squareSizeZ / (std::sqrt(1.0 + mVal * mVal) * rMax - mVal * squareSizeZ); + tRPlusG[i] = std::sqrt(1.0 + mVal * mVal) * (rMax - rMin) - mVal / 2.0 * (squareSizeZ + lAerogelZ[i]); + aerogelRindex[i] = bRichRefractiveIndexSector[i - iCentralMirror]; + // Backword sectors + thetaBi[2 * iCentralMirror - i - 1] = -std::atan(mVal); + r0Tilt[2 * iCentralMirror - i - 1] = rMax - squareSizeZ / 2.0 * std::sin(std::atan(mVal)); + z0Tilt[2 * iCentralMirror - i - 1] = -r0Tilt[i] * std::tan(thetaBi[i]); + lDetectorZ[2 * iCentralMirror - i - 1] = squareSizeZ; + lAerogelZ[2 * iCentralMirror - i - 1] = std::sqrt(1.0 + mVal * mVal) * rMin * squareSizeZ / (std::sqrt(1.0 + mVal * mVal) * rMax - mVal * squareSizeZ); + tRPlusG[2 * iCentralMirror - i - 1] = std::sqrt(1.0 + mVal * mVal) * (rMax - rMin) - mVal / 2.0 * (squareSizeZ + lAerogelZ[i]); + aerogelRindex[2 * iCentralMirror - i - 1] = bRichRefractiveIndexSector[i - iCentralMirror]; + bRichPhotodetectorCentralModuleHalfLength.value = rMin * t; // <-- At the end of the loop this will be the maximum z + } + } + // Coordinate radiali layer considerati + std::vector r0Detector; + std::vector r0Aerogel; + r0Detector.resize(numberOfSectorsInZ); + r0Aerogel.resize(numberOfSectorsInZ); + for (int i = 0; i < numberOfSectorsInZ; i++) { + r0Detector[i] = r0Tilt[i]; // + (detector_thickness / 2.0) * std::cos(thetaBi[i]) NEGLIGIBLE + detCenters[i].SetXYZ(r0Detector[i], 0, r0Detector[i] * std::tan(thetaBi[i])); + r0Aerogel[i] = r0Tilt[i] - (tRPlusG[i] - bRichRadiatorThickness / 2.0) * std::cos(thetaBi[i]); + radCenters[i].SetXYZ(r0Aerogel[i], 0, r0Aerogel[i] * std::tan(thetaBi[i])); + angleCenters[i] = thetaBi[i]; + photodetrctorLength[i] = lDetectorZ[i]; + gapThickness[i] = (detCenters[i] - radCenters[i]).Mag() - bRichRadiatorThickness / 2.0; + } + // DEBUG + // std::cout << std::endl << std::endl; + // for (int i = 0; i < numberOfSectorsInZ; i++) { + // std::cout << "Sector " << i << ": Gap = " << gapThickness[i] << " cm, Index aerogel = " << aerogelRindex[i] << ", Gap thickness = " << gapThickness[i] << " cm" << std::endl; + // } + // std::cout << std::endl << std::endl; + } + + void init(o2::framework::InitContext& initContext) + { + pRandomNumberGenerator.SetSeed(0); // fully randomize + + if (magneticField.value < o2::constants::math::Epsilon) { + LOG(info) << "Getting the magnetic field from the on-the-fly tracker task"; + if (!getTaskOptionValue(initContext, "on-the-fly-tracker", magneticField, false)) { + LOG(fatal) << "Could not get Bz from on-the-fly-tracker task"; + } + LOG(info) << "Bz = " << magneticField.value << " T"; + } + + // Check if inheriting the LUT configuration + auto configLutPath = [&](Configurable& lut) { + if (lut.value != "inherit") { + return; + } + if (!getTaskOptionValue(initContext, "on-the-fly-tracker", lut, false)) { + LOG(fatal) << "Could not get " << lut.name << " from on-the-fly-tracker task"; + } + }; + configLutPath(simConfig.lutEl); + configLutPath(simConfig.lutMu); + configLutPath(simConfig.lutPi); + configLutPath(simConfig.lutKa); + configLutPath(simConfig.lutPr); + + // Load LUT for pt and eta smearing + if (flagIncludeTrackAngularRes && flagRICHLoadDelphesLUTs) { + std::map mapPdgLut; + const char* lutElChar = simConfig.lutEl->c_str(); + const char* lutMuChar = simConfig.lutMu->c_str(); + const char* lutPiChar = simConfig.lutPi->c_str(); + const char* lutKaChar = simConfig.lutKa->c_str(); + const char* lutPrChar = simConfig.lutPr->c_str(); + + LOGF(info, "Will load electron lut file ..: %s for RICH PID", lutElChar); + LOGF(info, "Will load muon lut file ......: %s for RICH PID", lutMuChar); + LOGF(info, "Will load pion lut file ......: %s for RICH PID", lutPiChar); + LOGF(info, "Will load kaon lut file ......: %s for RICH PID", lutKaChar); + LOGF(info, "Will load proton lut file ....: %s for RICH PID", lutPrChar); + + mapPdgLut.insert(std::make_pair(11, lutElChar)); + mapPdgLut.insert(std::make_pair(13, lutMuChar)); + mapPdgLut.insert(std::make_pair(211, lutPiChar)); + mapPdgLut.insert(std::make_pair(321, lutKaChar)); + mapPdgLut.insert(std::make_pair(2212, lutPrChar)); + + for (const auto& e : mapPdgLut) { + if (!mSmearer.loadTable(e.first, e.second)) { + LOG(fatal) << "Having issue with loading the LUT " << e.first << " " << e.second; + } + } + } + + if (doQAplots) { + const AxisSpec axisMomentum{static_cast(nBinsP), 0.0f, +20.0f, "#it{p} (GeV/#it{c})"}; + const AxisSpec axisAngle{static_cast(nBinsThetaRing), 0.0f, +0.30f, "Measured Cherenkov angle (rad)"}; + const AxisSpec axisEta{static_cast(nBinsEta), -2.0f, +2.0f, "#eta"}; + const AxisSpec axisSector{static_cast(bRichNumberOfSectors), -0.5f, static_cast(bRichNumberOfSectors) - 0.5f, "Sector ID number"}; + const AxisSpec axisRingAngularResolution{static_cast(nBinsAngularRes), 0.0f, +5.0f, "Ring angular resolution - rec. only (mrad)"}; + histos.add("h2dAngleVsMomentumBarrelRICH", "h2dAngleVsMomentumBarrelRICH", kTH2F, {axisMomentum, axisAngle}); + histos.add("h2dAngleVsEtaBarrelRICH", "h2dAngleVsEtaBarrelRICH", kTH2F, {axisEta, axisAngle}); + histos.add("h2dAngularResolutionVsMomentumBarrelRICH", "h2dAngularResolutionVsMomentumBarrelRICH", kTH2F, {axisMomentum, axisRingAngularResolution}); + histos.add("h2dAngularResolutionVsEtaBarrelRICH", "h2dAngularResolutionVsEtaBarrelRICH", kTH2F, {axisEta, axisRingAngularResolution}); + histos.add("hSectorID", "hSectorID", kTH1F, {axisSector}); + + const int kNspec = 5; // electron, muon, pion, kaon, proton + std::string particleNames1[kNspec] = {"#it{e}", "#it{#mu}", "#it{#pi}", "#it{K}", "#it{p}"}; + std::string particleNames2[kNspec] = {"Elec", "Muon", "Pion", "Kaon", "Prot"}; + for (int iTrue = 0; iTrue < kNspec; iTrue++) { + std::string nameTitleBarrelTrackRes = "h2dBarrelAngularResTrack" + particleNames2[iTrue] + "VsP"; + std::string nameTitleBarrelTotalRes = "h2dBarrelAngularResTotal" + particleNames2[iTrue] + "VsP"; + const AxisSpec axisTrackAngularRes{static_cast(nBinsAngularRes), 0.0f, +5.0f, "Track angular resolution - " + particleNames1[iTrue] + " (mrad)"}; + const AxisSpec axisTotalAngularRes{static_cast(nBinsAngularRes), 0.0f, +5.0f, "Total angular resolution - " + particleNames1[iTrue] + " (mrad)"}; + histos.add(nameTitleBarrelTrackRes.c_str(), nameTitleBarrelTrackRes.c_str(), kTH2F, {axisMomentum, axisTrackAngularRes}); + histos.add(nameTitleBarrelTotalRes.c_str(), nameTitleBarrelTotalRes.c_str(), kTH2F, {axisMomentum, axisTotalAngularRes}); + } + for (int iTrue = 0; iTrue < kNspec; iTrue++) { + for (int iHyp = 0; iHyp < kNspec; iHyp++) { + std::string nameTitle = "h2dBarrelNsigmaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis"; + if (iTrue == iHyp) { + const AxisSpec axisNsigmaCorrect{static_cast(nBinsNsigmaCorrectSpecies), -10.0f, +10.0f, "N#sigma - True " + particleNames1[iTrue] + " vs " + particleNames1[iHyp] + " hypothesis"}; + histos.add(nameTitle.c_str(), nameTitle.c_str(), kTH2F, {axisMomentum, axisNsigmaCorrect}); + } else { + const AxisSpec axisNsigmaWrong{static_cast(nBinsNsigmaWrongSpecies), -10.0f, +10.0f, "N#sigma - True " + particleNames1[iTrue] + " vs " + particleNames1[iHyp] + " hypothesis"}; + histos.add(nameTitle.c_str(), nameTitle.c_str(), kTH2F, {axisMomentum, axisNsigmaWrong}); + } + } + } + } + // Load all sector refractive indices + /*bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector0AndNMinus1); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector1AndNMinus2); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector2AndNMinus3); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector3AndNMinus4); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector4AndNMinus5); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector5AndNMinus6); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector6AndNMinus7); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector7AndNMinus8); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector8AndNMinus9); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector9AndNMinus10); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector10AndNMinus11); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector11AndNMinus12); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector12AndNMinus13); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector13AndNMinus14); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector14AndNMinus15); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector15AndNMinus16); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector16AndNMinus17); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector17AndNMinus18); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector18AndNMinus19); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector19AndNMinus20); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector20AndNMinus21);*/ + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector0); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector1); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector2); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector3); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector4); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector5); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector6); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector7); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector8); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector9); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector10); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector11); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector12); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector13); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector14); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector15); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector16); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector17); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector18); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector19); + bRichRefractiveIndexSector.push_back(bRichRefractiveIndexSector20); + + // Update projective parameters + updateProjectiveParameters(); + } + + /// check if particle reaches radiator + /// \param track the input track + /// \param radius the radius of the layer you're calculating the length to + /// \param magneticField the magnetic field to use when propagating + bool checkMagfieldLimit(o2::track::TrackParCov track, const float radius, const float magneticField) + { + o2::math_utils::CircleXYf_t trcCircle; + float sna, csa; + track.getCircleParams(magneticField, trcCircle, sna, csa); + + // distance between circle centers (one circle is at origin -> easy) + float centerDistance = std::hypot(trcCircle.xC, trcCircle.yC); + + // condition of circles touching - if not satisfied returned value if false + if (centerDistance < trcCircle.rC + radius && centerDistance > std::fabs(trcCircle.rC - radius)) { + return true; + } else { + return false; + } + } + + /// returns sector hit by the track (if any), -1 otherwise + /// \param eta the pseudorapidity of the tarck (assuming primary vertex at origin) + int findSector(const float eta) + { + float polar = 2.0 * std::atan(std::exp(-eta)); + for (int jSector = 0; jSector < bRichNumberOfSectors; jSector++) { + if (polar > thetaMax[jSector] && polar < thetaMin[jSector]) { + return jSector; + } + } + return -1; + } + + /// returns radiator radius in cm at considered eta (accounting for sector inclination) + /// \param eta the pseudorapidity of the tarck (assuming primary vertex at origin) + /// \param iSecor the index of the track RICH sector + float radiusRipple(const float eta, const int iSecor) + { + if (iSecor > 0) { + const float polar = 2.0 * std::atan(std::exp(-eta)); + const float rSecRich = radCenters[iSecor].X(); + const float zSecRich = radCenters[iSecor].Z(); + const float rSecRichSquared = rSecRich * rSecRich; + const float zSecRichSquared = zSecRich * zSecRich; + return (rSecRichSquared + zSecRichSquared) / (rSecRich + zSecRich / std::tan(polar)); + } else { + return kErrorValue; + } + } + + /// returns Cherenkov angle in rad (above threshold) or bad flag (below threshold) + /// \param momentum the momentum of the tarck + /// \param mass the mass of the particle + /// \param n the refractive index of the considered sector + /// \param angle the output angle (passed by reference) + /// \return true if particle is above the threshold and enough photons, false otherwise + bool cherenkovAngle(const float momentum, const float mass, const float n, float& angle) + { + if (momentum > mass / std::sqrt(n * n - 1.0)) { // Check if particle is above the threshold + // Calculate angle + angle = std::acos(std::sqrt(momentum * momentum + mass * mass) / (momentum * n)); + + // Mean number of detected photons (SiPM PDE is accountd in multiplicative factor!!!) + const float meanNumberofDetectedPhotons = 230. * std::sin(angle) * std::sin(angle) * bRichRadiatorThickness; + + // Require at least 3 photons on average for real angle reconstruction + static constexpr float kMinPhotons = 3.f; + if (meanNumberofDetectedPhotons > kMinPhotons) { + return true; // Particle is above the threshold and enough photons + } + return false; // Particle is above the threshold, but not enough photons + } + return false; // Particle is below the threshold + } + + bool isOverTrhesholdInGasRadiator(const float momentum, const float mass) + { + if (momentum < mass / std::sqrt(gasRadiatorRindex * gasRadiatorRindex - 1.0)) { // Check if particle is above the threshold + return false; + } + const float angle = std::acos(std::sqrt(momentum * momentum + mass * mass) / (momentum * gasRadiatorRindex)); + const float meanNumberofDetectedPhotons = 230. * std::sin(angle) * std::sin(angle) * gasRichRadiatorThickness; + + // Require at least 3 photons on average for real angle reconstruction + static constexpr float kMinPhotons = 3.f; + if (meanNumberofDetectedPhotons <= kMinPhotons) { + return false; + } + return true; + } + + /// returns linear interpolation + /// \param x the eta we want the resolution for + /// \param x0 the closest smaller available eta + /// \param x1 the closest larger available eta + /// \param y0 the resolution corresponding to x0 + /// \param y1 the resolution corresponding to x1 + float interpolate(double x, double x0, double x1, double y0, double y1) + { + float y = y0 + ((y1 - y0) / (x1 - x0)) * (x - x0); + return y; + } + + /// returns angular resolution for considered track eta + /// \param eta the pseudorapidity of the tarck (assuming primary vertex at origin) + float angularResolution(float eta) + { + // Vectors for sampling (USE ANALYTICAL EXTRAPOLATION FOR BETTER RESULTS) + static constexpr float kEtaSampling[] = {-2.000000, -1.909740, -1.731184, -1.552999, -1.375325, -1.198342, -1.022276, -0.847390, -0.673976, -0.502324, -0.332683, -0.165221, 0.000000, 0.165221, 0.332683, 0.502324, 0.673976, 0.847390, 1.022276, 1.198342, 1.375325, 1.552999, 1.731184, 1.909740, 2.000000}; + static constexpr float kResRingSamplingWithAbsWalls[] = {0.0009165, 0.000977, 0.001098, 0.001198, 0.001301, 0.001370, 0.001465, 0.001492, 0.001498, 0.001480, 0.001406, 0.001315, 0.001241, 0.001325, 0.001424, 0.001474, 0.001480, 0.001487, 0.001484, 0.001404, 0.001273, 0.001197, 0.001062, 0.000965, 0.0009165}; + static constexpr float kResRingSamplingWithoutAbsWalls[] = {0.0009165, 0.000977, 0.001095, 0.001198, 0.001300, 0.001369, 0.001468, 0.001523, 0.001501, 0.001426, 0.001299, 0.001167, 0.001092, 0.001179, 0.001308, 0.001407, 0.001491, 0.001508, 0.001488, 0.001404, 0.001273, 0.001196, 0.001061, 0.000965, 0.0009165}; + static constexpr int kSizeResVector = sizeof(kEtaSampling) / sizeof(kEtaSampling[0]); + // Use binary search to find the lower and upper indices + const int lowerIndex = std::lower_bound(kEtaSampling, kEtaSampling + kSizeResVector, eta) - kEtaSampling - 1; + const int upperIndex = lowerIndex + 1; + if (lowerIndex >= 0 && upperIndex < kSizeResVector) { + // Resolution interpolation + if (bRichFlagAbsorbingWalls) { + float interpolatedResRing = interpolate(eta, kEtaSampling[lowerIndex], kEtaSampling[upperIndex], kResRingSamplingWithAbsWalls[lowerIndex], kResRingSamplingWithAbsWalls[upperIndex]); + // std::cout << "Interpolated y value: " << interpolatedY << std::endl; + return interpolatedResRing; + } else { + float interpolatedResRing = interpolate(eta, kEtaSampling[lowerIndex], kEtaSampling[upperIndex], kResRingSamplingWithoutAbsWalls[lowerIndex], kResRingSamplingWithoutAbsWalls[upperIndex]); + // std::cout << "Interpolated y value: " << interpolatedY << std::endl; + return interpolatedResRing; + } + } else { + // std::cout << "Unable to interpolate. Target x value is outside the range of available data." << std::endl; + return kErrorValue; + } + } + + /// To account border effects in bRICH + /// Approximation for analytic calculation: track along projective sector normal (reasonable) + /// \param eta the pseudorapidity of the tarck (assuming primary vertex at origin) + /// \param tileZlength the Z-length of the photodetector plane of the considered sector + /// \param radius the nominal radius of the Cherenkov ring + float fractionPhotonsProjectiveRICH(float eta, float tileZlength, float radius) + { + const float polar = 2.0 * std::atan(std::exp(-eta)); + int iSecor = 0; + bool flagSector = false; + for (int jSector = 0; jSector < bRichNumberOfSectors; jSector++) { + if (polar > thetaMax[jSector] && polar < thetaMin[jSector]) { + flagSector = true; + iSecor = jSector; + } + } + if (flagSector == false) { + return kErrorValue; // <-- Returning negative value + } + float rSecRich = radCenters[iSecor].X(); + float zSecRich = radCenters[iSecor].Z(); + // float rSecTof = detCenters[iSecor].X(); + // float zSecTof = detCenters[iSecor].Z(); + const float rSecRichSquared = rSecRich * rSecRich; + const float zSecRichSquared = zSecRich * zSecRich; + const float radiusRipple = (rSecRichSquared + zSecRichSquared) / (rSecRich + zSecRich / std::tan(polar)); + const float zRipple = radiusRipple / std::tan(polar); + const float absZ = std::hypot(radiusRipple - rSecRich, zRipple - zSecRich); + float fraction = 1.; + if (tileZlength / 2. - absZ < radius) { + fraction = fraction - (1. / o2::constants::math::PI) * std::acos((tileZlength / 2. - absZ) / radius); + if (tileZlength / 2. + absZ < radius) { + fraction = fraction - (1. / o2::constants::math::PI) * std::acos((tileZlength / 2. + absZ) / radius); + } + } + return fraction; + } + + /// returns refined ring angular resolution + /// \param eta the pseudorapidity of the tarck (assuming primary vertex at origin) + /// \param n the refractive index of the considered sector + /// \param nGas the refractive index of the gas filling the RICH proximity gap + /// \param thicknessRad the radiator thickness in cm + /// \param thicknessGas the proximity gap thickness of the considered sector in cm + /// \param pixelSize the SiPM pixel size in cm + /// \param thetaCherenkov the Cherenkov angle for the considered track + /// \param tileZlength the Z-length of the photodetector plane of the considered sector + float extractRingAngularResolution(const float eta, const float n, const float nGas, const float thicknessRad, const float thicknessGas, const float pixelSize, const float thetaCherenkov, const float tileZlength) + { + // Check if input angle is error value + if (thetaCherenkov <= kErrorValue + 1) + return kErrorValue; + // Parametrization variables (notation from https://doi.org/10.1016/0168-9002(94)90532-0) + const float phiC = 0.; + const float thetaP = 0.; + const float sinThetaCherenkov = std::sin(thetaCherenkov); + const float cosThetaCherenkov = std::cos(thetaCherenkov); + const float xP = std::sin(thetaP); + const float zP = std::cos(thetaP); + const float sinPhi = std::sin(phiC); + const float cosPhi = std::cos(phiC); + // const float ze = thicknessRad / (2. * zP); + const float aZ = zP * cosThetaCherenkov - xP * sinThetaCherenkov * cosPhi; + const float e3z = std::sqrt(aZ * aZ + (nGas / n) * (nGas / n) - 1.); + const float z = thicknessGas; + const float alpha = e3z / aZ; + const float etac = e3z * n * n; + const float k = thicknessRad / (2. * z); + const float m = 1. / (n * n); + const float lambda = (1. + k * alpha * alpha * alpha) / (1. + k * alpha); + // Derivative d(thetaCherenkov)/dx + const float temp1 = etac / z; + const float temp2 = alpha * e3z * cosPhi; + const float temp3 = xP * sinThetaCherenkov * sinPhi * sinPhi; + const float dThetaX = temp1 * (temp2 - temp3); + // Derivative d(thetaCherenkov)/dy + const float temp4 = etac * sinPhi / z; + const float temp5 = cosThetaCherenkov - zP * (1 - m) / aZ; + const float dThetaY = temp4 * temp5; + // Derivative d(thetaCherenkov)/dze + const float temp8 = etac * sinThetaCherenkov; + const float temp9 = z * (1.0 + k * alpha * alpha * alpha * n * n); + const float temp10 = alpha * alpha * (1.0 - xP * xP * sinPhi * sinPhi) + lambda * xP * xP * sinPhi * sinPhi; + const float dThetaZe = temp8 * temp10 / temp9; + // Derivative d(thetaCherenkov)/dn + const float dThetaN = zP / (n * aZ * sinThetaCherenkov); + // RMS wavelength (using Sellmeier formula with measured aerogel parameters) + const float a0 = 0.0616; + const float w0 = 56.5; + const float n0 = 1.0307; + const float wMean = 436.0; // 450.0;//484.9;//426.0; //450;//485;//450; // nm //450 426 493.5 // 426.0 + const float scaling = n / n0; + const float temp11 = a0 * w0 * w0 * wMean; + const float temp12 = std::pow(wMean * wMean - w0 * w0, 1.5); + const float temp13 = std::sqrt(wMean * wMean * (1.0 + a0) - w0 * w0); + const float dNw = temp11 / (temp12 * temp13) * scaling; + const float sigmaW = 115.0; + // RMS x y + const float sigmaThetaX = pixelSize / std::sqrt(12.0); + const float sigmaThetaY = pixelSize / std::sqrt(12.0); + // RMS emission point + const float sigmaThetaZe = thicknessRad / (zP * std::sqrt(12.0)); + // Single photon angular resolution + const float resX = dThetaX * sigmaThetaX; + const float resY = dThetaY * sigmaThetaY; + const float resZe = dThetaZe * sigmaThetaZe; + const float resN = dThetaN * dNw * sigmaW; + const float resXsquared = resX * resX; + const float resYsquared = resY * resY; + const float resZesquared = resZe * resZe; + const float resNsquared = resN * resN; + const float singlePhotonAngularResolution = std::sqrt(resXsquared + resYsquared + resZesquared + resNsquared); + // Fraction of photons in rings (to account loss close to sector boundary in projective geometry) + const float sinThetaCherenkovSquared = sinThetaCherenkov * sinThetaCherenkov; + const float radius = (thicknessRad / 2.0) * std::tan(thetaCherenkov) + thicknessGas * std::tan(std::asin((n / nGas) * sinThetaCherenkov)); + const float n0Photons = 24. * thicknessRad / 2.; // photons for N = 1.03 at saturation ( 24/2 factor per radiator cm ) + const float sinAngle = std::sin(std::acos(1. / 1.03)); + const float sinAngleSquared = sinAngle * sinAngle; + const float multiplicitySpectrumFactor = sinThetaCherenkovSquared / sinAngleSquared; // scale multiplicity w.r.t. N = 1.03 at saturation + // Considering average resolution (integrated over the sector) + // float nPhotons = (tileZlength / 2.0 > radius) ? n0Photons * multiplicitySpectrumFactor * (1.-(2.0*radius)/(o2::constants::math::PI*tileZlength)) : n0Photons * multiplicitySpectrumFactor * (1.-(2.0*radius)/(o2::constants::math::PI*tileZlength) - (2.0/(tileZlength*o2::constants::math::PI))*(-(tileZlength/(2.0))*std::acos(tileZlength/(2.0*radius)) + radius*std::sqrt(1.-std::pow(tileZlength/(2.0*radius),2.0)))); + // Considering "exact" resolution (eta by eta) + const float nPhotons = n0Photons * multiplicitySpectrumFactor * fractionPhotonsProjectiveRICH(eta, tileZlength, radius); + if (nPhotons <= kErrorValue + 1) + return kErrorValue; + // Ring angular resolution + const float ringAngularResolution = singlePhotonAngularResolution / std::sqrt(nPhotons); + return ringAngularResolution; + } + + /// returns track angular resolution + /// \param pt the transverse momentum of the tarck + /// \param eta the pseudorapidity of the tarck + /// \param trackPtResolution the absolute resolution on pt + /// \param trackPtResolution the absolute resolution on eta + /// \param mass the mass of the particle + /// \param refractiveIndex the refractive index of the radiator + double calculateTrackAngularResolutionAdvanced(const float pt, const float eta, const float trackPtResolution, const float trackEtaResolution, const float mass, const float refractiveIndex) + { + // Compute tracking contribution to timing using the error propagation formula + // Uses light speed in m/ps, magnetic field in T (*0.1 for conversion kGauss -> T) + const double a0 = mass * mass; + const double a1 = refractiveIndex; + const double a1Squared = a1 * a1; + const float ptCoshEta = pt * std::cosh(eta); + const float ptCoshEtaSquared = ptCoshEta * ptCoshEta; + const double dThetaOndPt = a0 / (pt * std::sqrt(a0 + ptCoshEtaSquared) * std::sqrt(ptCoshEtaSquared * (a1Squared - 1.0) - a0)); + const double dThetaOndEta = (a0 * std::tanh(eta)) / (std::sqrt(a0 + ptCoshEtaSquared) * std::sqrt(ptCoshEtaSquared * (a1Squared - 1.0) - a0)); + const double trackAngularResolution = std::hypot(std::fabs(dThetaOndPt) * trackPtResolution, std::fabs(dThetaOndEta) * trackEtaResolution); + return trackAngularResolution; + } + + void process(soa::Join::iterator const& collision, + soa::Join const& tracks, + aod::McParticles const&, + aod::McCollisions const&) + { + const o2::dataformats::VertexBase pvVtx({collision.posX(), collision.posY(), collision.posZ()}, + {collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}); + + std::array mcPvCov = {0.}; + o2::dataformats::VertexBase mcPvVtx({0.0f, 0.0f, 0.0f}, mcPvCov); + if (collision.has_mcCollision()) { + auto mcCollision = collision.mcCollision(); + mcPvVtx.setX(mcCollision.posX()); + mcPvVtx.setY(mcCollision.posY()); + mcPvVtx.setZ(mcCollision.posZ()); + } // else remains untreated for now + + // First we compute the number of charged particles in the event + float dNdEta = 0.f; + if (flagRICHLoadDelphesLUTs) { + for (const auto& track : tracks) { + if (!track.has_mcParticle()) + continue; + auto mcParticle = track.mcParticle(); + if (std::abs(mcParticle.eta()) > multiplicityEtaRange) { + continue; + } + if (mcParticle.has_daughters()) { + continue; + } + const auto& pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + if (!pdgInfo) { + // LOG(warning) << "PDG code " << mcParticle.pdgCode() << " not found in the database"; + continue; + } + if (pdgInfo->Charge() == 0) { + continue; + } + dNdEta += 1.f; + } + } + + for (const auto& track : tracks) { + + auto fillDummyValues = [&](bool gasRich = false) { + upgradeRich(kErrorValue, kErrorValue, kErrorValue, kErrorValue, kErrorValue); + upgradeRichSignal(false, false, false, false, false, false, gasRich); + }; + + // first step: find precise arrival time (if any) + // --- convert track into perfect track + if (!track.has_mcParticle()) { // should always be OK but check please + fillDummyValues(); + continue; + } + + const auto& mcParticle = track.mcParticle(); + o2::track::TrackParCov o2track = o2::upgrade::convertMCParticleToO2Track(mcParticle, pdg); + + // float xPv = kErrorValue; + if (o2track.propagateToDCA(mcPvVtx, magneticField)) { + // xPv = o2track.getX(); + } + + // get particle to calculate Cherenkov angle and resolution + auto pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + if (pdgInfo == nullptr) { + fillDummyValues(); + continue; + } + + // find track bRICH sector + const int iSecor = findSector(o2track.getEta()); + if (iSecor < 0) { + fillDummyValues(); + continue; + } + + const bool expectedAngleBarrelGasRichOk = isOverTrhesholdInGasRadiator(o2track.getP(), pdgInfo->Mass()); + float expectedAngleBarrelRich = kErrorValue; + const bool expectedAngleBarrelRichOk = cherenkovAngle(o2track.getP(), pdgInfo->Mass(), aerogelRindex[iSecor], expectedAngleBarrelRich); + if (!expectedAngleBarrelRichOk) { + fillDummyValues(expectedAngleBarrelGasRichOk); + continue; // Particle is below the threshold or not enough photons + } + // float barrelRICHAngularResolution = angularResolution(o2track.getEta()); + const float barrelRICHAngularResolution = extractRingAngularResolution(o2track.getEta(), aerogelRindex[iSecor], bRichGapRefractiveIndex, bRichRadiatorThickness, gapThickness[iSecor], bRICHPixelSize, expectedAngleBarrelRich, photodetrctorLength[iSecor]); + const float projectiveRadiatorRadius = radiusRipple(o2track.getEta(), iSecor); + bool flagReachesRadiator = false; + if (projectiveRadiatorRadius > kErrorValue + 1.) { + flagReachesRadiator = checkMagfieldLimit(o2track, projectiveRadiatorRadius, magneticField); + } + /// DISCLAIMER: Exact extrapolation of angular resolution would require track propagation + /// to the RICH radiator (accounting sector inclination) in terms of (R,z). + /// The extrapolation with Eta is correct only if the primary vertex is at origin. + /// Discrepancies may be negligible, but would be more rigorous if propagation tool is available + + // Smear with expected resolutions + const float measuredAngleBarrelRich = pRandomNumberGenerator.Gaus(expectedAngleBarrelRich, barrelRICHAngularResolution); + + // Now we calculate the expected Cherenkov angle following certain mass hypotheses + // and the (imperfect!) reconstructed track parametrizations + auto recoTrack = getTrackParCov(track); + if (recoTrack.propagateToDCA(pvVtx, magneticField)) { + // xPv = recoTrack.getX(); + } + + // Straight to Nsigma + static constexpr int kNspecies = 5; + static constexpr int kEl = 0; + static constexpr int kMu = 1; + static constexpr int kPi = 2; + static constexpr int kKa = 3; + static constexpr int kPr = 4; + float nSigmaBarrelRich[kNspecies] = {kErrorValue, kErrorValue, kErrorValue, kErrorValue, kErrorValue}; + bool signalBarrelRich[kNspecies] = {false, false, false, false, false}; + float deltaThetaBarrelRich[kNspecies]; //, nSigmaBarrelRich[kNspecies]; + static constexpr int kPdgArray[kNspecies] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; + static constexpr float kMasses[kNspecies] = {o2::track::pid_constants::sMasses[o2::track::PID::Electron], + o2::track::pid_constants::sMasses[o2::track::PID::Muon], + o2::track::pid_constants::sMasses[o2::track::PID::Pion], + o2::track::pid_constants::sMasses[o2::track::PID::Kaon], + o2::track::pid_constants::sMasses[o2::track::PID::Proton]}; + + for (int ii = 0; ii < kNspecies; ii++) { // Loop on the particle hypotheses + + float hypothesisAngleBarrelRich = kErrorValue; + const bool hypothesisAngleBarrelRichOk = cherenkovAngle(recoTrack.getP(), kMasses[ii], aerogelRindex[iSecor], hypothesisAngleBarrelRich); + signalBarrelRich[ii] = hypothesisAngleBarrelRichOk; // Particle is above the threshold and enough photons + + // Evaluate total sigma (layer + tracking resolution) + float barrelTotalAngularReso = barrelRICHAngularResolution; + if (flagIncludeTrackAngularRes) { + const float transverseMomentum = recoTrack.getP() / std::cosh(recoTrack.getEta()); + double ptResolution = transverseMomentum * transverseMomentum * std::sqrt(recoTrack.getSigma1Pt2()); + double etaResolution = std::fabs(std::sin(2.0 * std::atan(std::exp(-recoTrack.getEta())))) * std::sqrt(recoTrack.getSigmaTgl2()); + if (flagRICHLoadDelphesLUTs) { + ptResolution = mSmearer.getAbsPtRes(kPdgArray[ii], dNdEta, recoTrack.getEta(), transverseMomentum); + etaResolution = mSmearer.getAbsEtaRes(kPdgArray[ii], dNdEta, recoTrack.getEta(), transverseMomentum); + } + // cout << endl << "Pt resolution: " << ptResolution << ", Eta resolution: " << etaResolution << endl << endl; + const float barrelTrackAngularReso = calculateTrackAngularResolutionAdvanced(recoTrack.getP() / std::cosh(recoTrack.getEta()), recoTrack.getEta(), ptResolution, etaResolution, kMasses[ii], aerogelRindex[iSecor]); + barrelTotalAngularReso = std::hypot(barrelRICHAngularResolution, barrelTrackAngularReso); + if (doQAplots && + hypothesisAngleBarrelRich > kErrorValue + 1. && + measuredAngleBarrelRich > kErrorValue + 1. && + barrelRICHAngularResolution > kErrorValue + 1. && + flagReachesRadiator) { + switch (mcParticle.pdgCode()) { + case kPdgArray[kEl]: // Electron + case -kPdgArray[kEl]: // Positron + if (ii == kEl) { + histos.fill(HIST("h2dBarrelAngularResTrackElecVsP"), recoTrack.getP(), 1000.0 * barrelTrackAngularReso); + histos.fill(HIST("h2dBarrelAngularResTotalElecVsP"), recoTrack.getP(), 1000.0 * barrelTotalAngularReso); + } + break; + case kPdgArray[kMu]: // Muon + case -kPdgArray[kMu]: // AntiMuon + if (ii == kMu) { + histos.fill(HIST("h2dBarrelAngularResTrackMuonVsP"), recoTrack.getP(), 1000.0 * barrelTrackAngularReso); + histos.fill(HIST("h2dBarrelAngularResTotalMuonVsP"), recoTrack.getP(), 1000.0 * barrelTotalAngularReso); + } + break; + case kPdgArray[kPi]: // Pion + case -kPdgArray[kPi]: // AntiPion + if (ii == kPi) { + histos.fill(HIST("h2dBarrelAngularResTrackPionVsP"), recoTrack.getP(), 1000.0 * barrelTrackAngularReso); + histos.fill(HIST("h2dBarrelAngularResTotalPionVsP"), recoTrack.getP(), 1000.0 * barrelTotalAngularReso); + } + break; + case kPdgArray[kKa]: // Kaon + case -kPdgArray[kKa]: // AntiKaon + if (ii == kKa) { + histos.fill(HIST("h2dBarrelAngularResTrackKaonVsP"), recoTrack.getP(), 1000.0 * barrelTrackAngularReso); + histos.fill(HIST("h2dBarrelAngularResTotalKaonVsP"), recoTrack.getP(), 1000.0 * barrelTotalAngularReso); + } + break; + case kPdgArray[kPr]: // Proton + case -kPdgArray[kPr]: // AntiProton + if (ii == kPr) { + histos.fill(HIST("h2dBarrelAngularResTrackProtVsP"), recoTrack.getP(), 1000.0 * barrelTrackAngularReso); + histos.fill(HIST("h2dBarrelAngularResTotalProtVsP"), recoTrack.getP(), 1000.0 * barrelTotalAngularReso); + } + break; + default: + break; + } + } + } + + /// DISCLAIMER: here tracking is accounted only for momentum value, but not for track parameters at impact point on the + /// RICH radiator, since exact resolution would require photon generation and transport to photodetector. + /// Effects are expected to be negligible (a few tenths of a milliradian) but further studies are required ! + if (hypothesisAngleBarrelRich > kErrorValue + 1. && + measuredAngleBarrelRich > kErrorValue + 1. && + barrelRICHAngularResolution > kErrorValue + 1. && + flagReachesRadiator) { + deltaThetaBarrelRich[ii] = hypothesisAngleBarrelRich - measuredAngleBarrelRich; + nSigmaBarrelRich[ii] = deltaThetaBarrelRich[ii] / barrelTotalAngularReso; + } + } + + // Fill histograms + if (doQAplots) { + if (measuredAngleBarrelRich > kErrorValue + 1. && + barrelRICHAngularResolution > kErrorValue + 1. && + flagReachesRadiator) { + histos.fill(HIST("h2dAngleVsMomentumBarrelRICH"), recoTrack.getP(), measuredAngleBarrelRich); + histos.fill(HIST("h2dAngleVsEtaBarrelRICH"), recoTrack.getEta(), measuredAngleBarrelRich); + histos.fill(HIST("h2dAngularResolutionVsMomentumBarrelRICH"), recoTrack.getP(), 1000 * barrelRICHAngularResolution); + histos.fill(HIST("h2dAngularResolutionVsEtaBarrelRICH"), recoTrack.getEta(), 1000 * barrelRICHAngularResolution); + histos.fill(HIST("hSectorID"), iSecor); + + switch (mcParticle.pdgCode()) { + case kPdgArray[kEl]: // Electron + case -kPdgArray[kEl]: // Positron + histos.fill(HIST("h2dBarrelNsigmaTrueElecVsElecHypothesis"), recoTrack.getP(), nSigmaBarrelRich[0]); + histos.fill(HIST("h2dBarrelNsigmaTrueElecVsMuonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[1]); + histos.fill(HIST("h2dBarrelNsigmaTrueElecVsPionHypothesis"), recoTrack.getP(), nSigmaBarrelRich[2]); + histos.fill(HIST("h2dBarrelNsigmaTrueElecVsKaonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[3]); + histos.fill(HIST("h2dBarrelNsigmaTrueElecVsProtHypothesis"), recoTrack.getP(), nSigmaBarrelRich[4]); + break; + case kPdgArray[kMu]: // Muon + case -kPdgArray[kMu]: // AntiMuon + histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsElecHypothesis"), recoTrack.getP(), nSigmaBarrelRich[0]); + histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsMuonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[1]); + histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsPionHypothesis"), recoTrack.getP(), nSigmaBarrelRich[2]); + histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsKaonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[3]); + histos.fill(HIST("h2dBarrelNsigmaTrueMuonVsProtHypothesis"), recoTrack.getP(), nSigmaBarrelRich[4]); + break; + case kPdgArray[kPi]: // Pion + case -kPdgArray[kPi]: // AntiPion + histos.fill(HIST("h2dBarrelNsigmaTruePionVsElecHypothesis"), recoTrack.getP(), nSigmaBarrelRich[0]); + histos.fill(HIST("h2dBarrelNsigmaTruePionVsMuonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[1]); + histos.fill(HIST("h2dBarrelNsigmaTruePionVsPionHypothesis"), recoTrack.getP(), nSigmaBarrelRich[2]); + histos.fill(HIST("h2dBarrelNsigmaTruePionVsKaonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[3]); + histos.fill(HIST("h2dBarrelNsigmaTruePionVsProtHypothesis"), recoTrack.getP(), nSigmaBarrelRich[4]); + break; + case kPdgArray[kKa]: // Kaon + case -kPdgArray[kKa]: // AntiKaon + histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsElecHypothesis"), recoTrack.getP(), nSigmaBarrelRich[0]); + histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsMuonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[1]); + histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsPionHypothesis"), recoTrack.getP(), nSigmaBarrelRich[2]); + histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsKaonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[3]); + histos.fill(HIST("h2dBarrelNsigmaTrueKaonVsProtHypothesis"), recoTrack.getP(), nSigmaBarrelRich[4]); + break; + case kPdgArray[kPr]: // Proton + case -kPdgArray[kPr]: // AntiProton + histos.fill(HIST("h2dBarrelNsigmaTrueProtVsElecHypothesis"), recoTrack.getP(), nSigmaBarrelRich[0]); + histos.fill(HIST("h2dBarrelNsigmaTrueProtVsMuonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[1]); + histos.fill(HIST("h2dBarrelNsigmaTrueProtVsPionHypothesis"), recoTrack.getP(), nSigmaBarrelRich[2]); + histos.fill(HIST("h2dBarrelNsigmaTrueProtVsKaonHypothesis"), recoTrack.getP(), nSigmaBarrelRich[3]); + histos.fill(HIST("h2dBarrelNsigmaTrueProtVsProtHypothesis"), recoTrack.getP(), nSigmaBarrelRich[4]); + break; + default: + break; + } + } + } + + // Sigmas have been fully calculated. Please populate the NSigma helper table (once per track) + upgradeRich(nSigmaBarrelRich[0], nSigmaBarrelRich[1], nSigmaBarrelRich[2], nSigmaBarrelRich[3], nSigmaBarrelRich[4]); + upgradeRichSignal(expectedAngleBarrelRichOk, signalBarrelRich[0], signalBarrelRich[1], signalBarrelRich[2], signalBarrelRich[3], signalBarrelRich[4], expectedAngleBarrelGasRichOk); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/ALICE3/TableProducer/OTF/onTheFlyTOFPID.cxx b/ALICE3/TableProducer/OTF/onTheFlyTOFPID.cxx deleted file mode 100644 index 3a907d47342..00000000000 --- a/ALICE3/TableProducer/OTF/onTheFlyTOFPID.cxx +++ /dev/null @@ -1,609 +0,0 @@ -// 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. - -// -// Task to add a table of track parameters propagated to the primary vertex -// - -#include - -#include - -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/ASoAHelpers.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/trackUtilities.h" -#include "ReconstructionDataFormats/DCA.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "CommonUtils/NameConf.h" -#include "CCDB/CcdbApi.h" -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsCalibration/MeanVertexObject.h" -#include "CommonConstants/GeomConstants.h" -#include "CommonConstants/PhysicsConstants.h" -#include "TRandom3.h" -#include "ALICE3/DataModel/OTFTOF.h" -#include "DetectorsVertexing/HelixHelper.h" -#include "TableHelper.h" -#include "ALICE3/Core/DelphesO2TrackSmearer.h" - -/// \file onTheFlyTOFPID.cxx -/// -/// \brief This task goes straight from a combination of track table and mcParticles -/// and a custom TOF configuration to a table of TOF NSigmas for the particles -/// being analysed. It currently contemplates 5 particle types: -/// electrons, pions, kaons, protons and muons -/// -/// More particles could be added but would have to be added to the LUT -/// being used in the onTheFly tracker task. -/// -/// \author David Dobrigkeit Chinellato, UNICAMP, Nicola Nicassio, University and INFN Bari - -using namespace o2; -using namespace o2::framework; - -struct OnTheFlyTOFPID { - Produces upgradeTof; - - // necessary for particle charges - Service pdg; - - // these are the settings governing the TOF layers to be used - // note that there are two layers foreseen for now: inner and outer TOF - // more could be added (especially a disk TOF at a certain z?) - // in the evolution of this effort - Configurable dBz{"dBz", 20, "magnetic field (kilogauss)"}; - Configurable innerTOFRadius{"innerTOFRadius", 20, "barrel inner TOF radius (cm)"}; - Configurable outerTOFRadius{"outerTOFRadius", 80, "barrel outer TOF radius (cm)"}; - Configurable innerTOFTimeReso{"innerTOFTimeReso", 20, "barrel inner TOF time error (ps)"}; - Configurable outerTOFTimeReso{"outerTOFTimeReso", 20, "barrel outer TOF time error (ps)"}; - Configurable nStepsLIntegrator{"nStepsLIntegrator", 200, "number of steps in length integrator"}; - Configurable doQAplots{"doQAplots", true, "do basic velocity plot qa"}; - Configurable nBinsBeta{"nBinsBeta", 2200, "number of bins in beta"}; - Configurable nBinsP{"nBinsP", 80, "number of bins in momentum"}; - Configurable nBinsTrackLengthInner{"nBinsTrackLengthInner", 300, "number of bins in track length"}; - Configurable nBinsTrackLengthOuter{"nBinsTrackLengthOuter", 300, "number of bins in track length"}; - Configurable nBinsTrackDeltaLength{"nBinsTrackDeltaLength", 100, "number of bins in delta track length"}; - Configurable nBinsNsigmaCorrectSpecies{"nBinsNsigmaCorrectSpecies", 200, "number of bins in Nsigma plot (correct speies)"}; - Configurable nBinsNsigmaWrongSpecies{"nBinsNsigmaWrongSpecies", 200, "number of bins in Nsigma plot (wrong species)"}; - Configurable minNsigmaRange{"minNsigmaRange", -10, "lower limit for the nsigma axis"}; - Configurable maxNsigmaRange{"maxNsigmaRange", +10, "upper limit for the nsigma axis"}; - Configurable nBinsTimeRes{"nBinsTimeRes", 400, "number of bins plots time resolution"}; - Configurable nBinsRelativeEtaPt{"nBinsRelativeEtaPt", 400, "number of bins plots pt and eta relative errors"}; - Configurable nBinsEta{"nBinsEta", 400, "number of bins plot relative eta error"}; - Configurable flagIncludeTrackTimeRes{"flagIncludeTrackTimeRes", true, "flag to include or exclude track time resolution"}; - Configurable multiplicityEtaRange{"multiplicityEtaRange", 0.800000012, "eta range to compute the multiplicity"}; - Configurable flagTOFLoadDelphesLUTs{"flagTOFLoadDelphesLUTs", false, "flag to load Delphes LUTs for tracking correction (use recoTrack parameters if false)"}; - - Configurable lutEl{"lutEl", "lutCovm.el.dat", "LUT for electrons"}; - Configurable lutMu{"lutMu", "lutCovm.mu.dat", "LUT for muons"}; - Configurable lutPi{"lutPi", "lutCovm.pi.dat", "LUT for pions"}; - Configurable lutKa{"lutKa", "lutCovm.ka.dat", "LUT for kaons"}; - Configurable lutPr{"lutPr", "lutCovm.pr.dat", "LUT for protons"}; - - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - - // Track smearer (here used to get absolute pt and eta uncertainties if flagTOFLoadDelphesLUTs is true) - o2::delphes::DelphesO2TrackSmearer mSmearer; - - // needed: random number generator for smearing - TRandom3 pRandomNumberGenerator; - - // for handling basic QA histograms if requested - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - void init(o2::framework::InitContext&) - { - pRandomNumberGenerator.SetSeed(0); // fully randomize - - // Load LUT for pt and eta smearing - if (flagIncludeTrackTimeRes && flagTOFLoadDelphesLUTs) { - std::map mapPdgLut; - const char* lutElChar = lutEl->c_str(); - const char* lutMuChar = lutMu->c_str(); - const char* lutPiChar = lutPi->c_str(); - const char* lutKaChar = lutKa->c_str(); - const char* lutPrChar = lutPr->c_str(); - - LOGF(info, "Will load electron lut file ..: %s for TOF PID", lutElChar); - LOGF(info, "Will load muon lut file ......: %s for TOF PID", lutMuChar); - LOGF(info, "Will load pion lut file ......: %s for TOF PID", lutPiChar); - LOGF(info, "Will load kaon lut file ......: %s for TOF PID", lutKaChar); - LOGF(info, "Will load proton lut file ....: %s for TOF PID", lutPrChar); - - mapPdgLut.insert(std::make_pair(11, lutElChar)); - mapPdgLut.insert(std::make_pair(13, lutMuChar)); - mapPdgLut.insert(std::make_pair(211, lutPiChar)); - mapPdgLut.insert(std::make_pair(321, lutKaChar)); - mapPdgLut.insert(std::make_pair(2212, lutPrChar)); - - for (auto e : mapPdgLut) { - if (!mSmearer.loadTable(e.first, e.second)) { - LOG(fatal) << "Having issue with loading the LUT " << e.first << " " << e.second; - } - } - } - - if (doQAplots) { - const AxisSpec axisMomentum{static_cast(nBinsP), 0.0f, +10.0f, "#it{p} (GeV/#it{c})"}; - const AxisSpec axisMomentumSmall{static_cast(nBinsP), 0.0f, +1.0f, "#it{p} (GeV/#it{c})"}; - const AxisSpec axisVelocity{static_cast(nBinsBeta), 0.0f, +1.1f, "Measured #beta"}; - const AxisSpec axisTrackLengthInner{static_cast(nBinsTrackLengthInner), 0.0f, 60.0f, "Track length (cm)"}; - const AxisSpec axisTrackLengthOuter{static_cast(nBinsTrackLengthOuter), 0.0f, 300.0f, "Track length (cm)"}; - const AxisSpec axisTrackDeltaLength{static_cast(nBinsTrackDeltaLength), 0.0f, 30.0f, "Delta Track length (cm)"}; - histos.add("h2dVelocityVsMomentumInner", "h2dVelocityVsMomentumInner", kTH2F, {axisMomentum, axisVelocity}); - histos.add("h2dVelocityVsMomentumOuter", "h2dVelocityVsMomentumOuter", kTH2F, {axisMomentum, axisVelocity}); - histos.add("h2dTrackLengthInnerVsPt", "h2dTrackLengthInnerVsPt", kTH2F, {axisMomentumSmall, axisTrackLengthInner}); - histos.add("h2dTrackLengthOuterVsPt", "h2dTrackLengthOuterVsPt", kTH2F, {axisMomentumSmall, axisTrackLengthOuter}); - - histos.add("h2dTrackLengthInnerRecoVsPt", "h2dTrackLengthInnerRecoVsPt", kTH2F, {axisMomentumSmall, axisTrackLengthInner}); - histos.add("h2dTrackLengthOuterRecoVsPt", "h2dTrackLengthOuterRecoVsPt", kTH2F, {axisMomentumSmall, axisTrackLengthOuter}); - - histos.add("h2dDeltaTrackLengthInnerVsPt", "h2dDeltaTrackLengthInnerVsPt", kTH2F, {axisMomentumSmall, axisTrackDeltaLength}); - histos.add("h2dDeltaTrackLengthOuterVsPt", "h2dDeltaTrackLengthOuterVsPt", kTH2F, {axisMomentumSmall, axisTrackDeltaLength}); - - const AxisSpec axisPt{static_cast(nBinsP), 0.0f, +4.0f, "#it{p_{T}} (GeV/#it{c})"}; - const AxisSpec axisEta{static_cast(nBinsEta), -2.0f, +2.0f, "#eta"}; - const AxisSpec axisRelativePt{static_cast(nBinsRelativeEtaPt), 0.0f, +10.0f, "#it{#sigma_{p_{T}}} / #it{p_{T}} (%)"}; - const AxisSpec axisRelativeEta{static_cast(nBinsRelativeEtaPt), 0.0f, +10.0f, "#it{#sigma_{#eta}} / #it{#eta} (%)"}; - histos.add("h2dRelativePtResolution", "h2dRelativePtResolution", kTH2F, {axisPt, axisRelativePt}); - histos.add("h2dRelativeEtaResolution", "h2dRelativeEtaResolution", kTH2F, {axisEta, axisRelativeEta}); - - std::string particle_names1[5] = {"#it{e}", "#it{#mu}", "#it{#pi}", "#it{K}", "#it{p}"}; - std::string particle_names2[5] = {"Elec", "Muon", "Pion", "Kaon", "Prot"}; - for (int i_true = 0; i_true < 5; i_true++) { - std::string name_title_inner_track_res = "h2dInnerTimeResTrack" + particle_names2[i_true] + "VsP"; - std::string name_title_inner_total_res = "h2dInnerTimeResTotal" + particle_names2[i_true] + "VsP"; - std::string name_title_outer_track_res = "h2dOuterTimeResTrack" + particle_names2[i_true] + "VsP"; - std::string name_title_outer_total_res = "h2dOuterTimeResTotal" + particle_names2[i_true] + "VsP"; - const AxisSpec axisTrackTimeRes{static_cast(nBinsTimeRes), 0.0f, +200.0f, "Track time resolution - " + particle_names1[i_true] + " (ps)"}; - const AxisSpec axisTotalTimeRes{static_cast(nBinsTimeRes), 0.0f, +200.0f, "Total time resolution - " + particle_names1[i_true] + " (ps)"}; - histos.add(name_title_inner_track_res.c_str(), name_title_inner_track_res.c_str(), kTH2F, {axisMomentum, axisTrackTimeRes}); - histos.add(name_title_inner_total_res.c_str(), name_title_inner_total_res.c_str(), kTH2F, {axisMomentum, axisTotalTimeRes}); - histos.add(name_title_outer_track_res.c_str(), name_title_outer_track_res.c_str(), kTH2F, {axisMomentum, axisTrackTimeRes}); - histos.add(name_title_outer_total_res.c_str(), name_title_outer_total_res.c_str(), kTH2F, {axisMomentum, axisTotalTimeRes}); - } - - for (int i_true = 0; i_true < 5; i_true++) { - for (int i_hyp = 0; i_hyp < 5; i_hyp++) { - std::string name_title_inner = "h2dInnerNsigmaTrue" + particle_names2[i_true] + "Vs" + particle_names2[i_hyp] + "Hypothesis"; - std::string name_title_outer = "h2dOuterNsigmaTrue" + particle_names2[i_true] + "Vs" + particle_names2[i_hyp] + "Hypothesis"; - if (i_true == i_hyp) { - const AxisSpec axisNsigmaCorrect{static_cast(nBinsNsigmaCorrectSpecies), minNsigmaRange, maxNsigmaRange, "N#sigma - True " + particle_names1[i_true] + " vs " + particle_names1[i_hyp] + " hypothesis"}; - histos.add(name_title_inner.c_str(), name_title_inner.c_str(), kTH2F, {axisMomentum, axisNsigmaCorrect}); - histos.add(name_title_outer.c_str(), name_title_outer.c_str(), kTH2F, {axisMomentum, axisNsigmaCorrect}); - } else { - const AxisSpec axisNsigmaWrong{static_cast(nBinsNsigmaWrongSpecies), minNsigmaRange, maxNsigmaRange, "N#sigma - True " + particle_names1[i_true] + " vs " + particle_names1[i_hyp] + " hypothesis"}; - histos.add(name_title_inner.c_str(), name_title_inner.c_str(), kTH2F, {axisMomentum, axisNsigmaWrong}); - histos.add(name_title_outer.c_str(), name_title_outer.c_str(), kTH2F, {axisMomentum, axisNsigmaWrong}); - } - } - } - } - } - - /// Function to convert a McParticle into a perfect Track - /// \param particle the particle to convert (mcParticle) - /// \param o2track the address of the resulting TrackParCov - template - o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle) - { - // FIXME: this is a fundamentally important piece of code. - // It could be placed in a utility file instead of here. - auto pdgInfo = pdg->GetParticle(particle.pdgCode()); - int charge = 0; - if (pdgInfo != nullptr) { - charge = pdgInfo->Charge() / 3; - } - std::array params; - std::array covm = {0.}; - float s, c, x; - o2::math_utils::sincos(particle.phi(), s, c); - o2::math_utils::rotateZInv(particle.vx(), particle.vy(), x, params[0], s, c); - params[1] = particle.vz(); - params[2] = 0.; // since alpha = phi - auto theta = 2. * std::atan(std::exp(-particle.eta())); - params[3] = 1. / std::tan(theta); - params[4] = charge / particle.pt(); - - // Return TrackParCov - return o2::track::TrackParCov(x, particle.phi(), params, covm); - } - - /// function to calculate track length of this track up to a certain radius - /// \param track the input track - /// \param radius the radius of the layer you're calculating the length to - /// \param magneticField the magnetic field to use when propagating - float trackLength(o2::track::TrackParCov track, float radius, float magneticField) - { - // don't make use of the track parametrization - float length = -100; - - o2::math_utils::CircleXYf_t trcCircle; - float sna, csa; - track.getCircleParams(magneticField, trcCircle, sna, csa); - - // distance between circle centers (one circle is at origin -> easy) - float centerDistance = std::hypot(trcCircle.xC, trcCircle.yC); - - // condition of circles touching - if not satisfied returned length will be -100 - if (centerDistance < trcCircle.rC + radius && centerDistance > fabs(trcCircle.rC - radius)) { - length = 0.0f; - - // base radical direction - float ux = trcCircle.xC / centerDistance; - float uy = trcCircle.yC / centerDistance; - // calculate perpendicular vector (normalized) for +/- displacement - float vx = -uy; - float vy = +ux; - // calculate coordinate for radical line - float radical = (centerDistance * centerDistance - trcCircle.rC * trcCircle.rC + radius * radius) / (2.0f * centerDistance); - // calculate absolute displacement from center-to-center axis - float displace = (0.5f / centerDistance) * TMath::Sqrt( - (-centerDistance + trcCircle.rC - radius) * - (-centerDistance - trcCircle.rC + radius) * - (-centerDistance + trcCircle.rC + radius) * - (centerDistance + trcCircle.rC + radius)); - - // possible intercept points of track and TOF layer in 2D plane - float point1[2] = {radical * ux + displace * vx, radical * uy + displace * vy}; - float point2[2] = {radical * ux - displace * vx, radical * uy - displace * vy}; - - // decide on correct intercept point - std::array mom; - track.getPxPyPzGlo(mom); - float scalarProduct1 = point1[0] * mom[0] + point1[1] * mom[1]; - float scalarProduct2 = point2[0] * mom[0] + point2[1] * mom[1]; - - // get start point - std::array startPoint; - track.getXYZGlo(startPoint); - - float cosAngle = -1000, modulus = -1000; - - if (scalarProduct1 > scalarProduct2) { - modulus = std::hypot(point1[0] - trcCircle.xC, point1[1] - trcCircle.yC) * std::hypot(startPoint[0] - trcCircle.xC, startPoint[1] - trcCircle.yC); - cosAngle = (point1[0] - trcCircle.xC) * (startPoint[0] - trcCircle.xC) + (point1[1] - trcCircle.yC) * (startPoint[1] - trcCircle.yC); - } else { - modulus = std::hypot(point2[0] - trcCircle.xC, point2[1] - trcCircle.yC) * std::hypot(startPoint[0] - trcCircle.xC, startPoint[1] - trcCircle.yC); - cosAngle = (point2[0] - trcCircle.xC) * (startPoint[0] - trcCircle.xC) + (point2[1] - trcCircle.yC) * (startPoint[1] - trcCircle.yC); - } - cosAngle /= modulus; - length = trcCircle.rC * TMath::ACos(cosAngle); - length *= sqrt(1.0f + track.getTgl() * track.getTgl()); - } - return length; - } - - /// returns velocity in centimeters per picoseconds - /// \param momentum the momentum of the tarck - /// \param mass the mass of the particle - float velocity(float momentum, float mass) - { - float a = std::pow(momentum / mass, 2); - // uses light speed in cm/ps so output is in those units - return (o2::constants::physics::LightSpeedCm2NS / 1e+3) * std::sqrt(a / (1 + a)); - } - - /// returns track time resolution - /// \param pt the transverse momentum of the tarck - /// \param eta the pseudorapidity of the tarck - /// \param track_pt_resolution the absolute resolution on pt - /// \param track_pt_resolution the absolute resolution on eta - /// \param mass the mass of the particle - /// \param det_radius the radius of the cylindrical layer - /// \param magneticField the magnetic field (along Z) - double calculate_track_time_resolution_advanced(float pt, float eta, float track_pt_resolution, float track_eta_resolution, float mass, float det_radius, float magneticField) - { - // Compute tracking contribution to timing using the error propagation formula - // Uses light speed in m/ps, magnetic field in T (*0.1 for conversion kGauss -> T) - double a0 = mass * mass; - double a1 = 0.299792458 * (0.1 * magneticField) * (0.01 * o2::constants::physics::LightSpeedCm2NS / 1e+3); - double a2 = (det_radius * 0.01) * (det_radius * 0.01) * (0.299792458) * (0.299792458) * (0.1 * magneticField) * (0.1 * magneticField) / 2.0; - double dtof_on_dpt = (std::pow(pt, 4) * std::pow(std::cosh(eta), 2) * std::acos(1.0 - a2 / std::pow(pt, 2)) - 2.0 * a2 * std::pow(pt, 2) * (a0 + std::pow(pt * std::cosh(eta), 2)) / std::sqrt(a2 * (2.0 * std::pow(pt, 2) - a2))) / (a1 * std::pow(pt, 3) * std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2))); - double dtof_on_deta = std::pow(pt, 2) * std::sinh(eta) * std::cosh(eta) * std::acos(1.0 - a2 / std::pow(pt, 2)) / (a1 * std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2))); - double track_time_resolution = std::hypot(std::fabs(dtof_on_dpt) * track_pt_resolution, std::fabs(dtof_on_deta) * track_eta_resolution); - return track_time_resolution; - } - - void process(soa::Join::iterator const& collision, soa::Join const& tracks, aod::McParticles const&, aod::McCollisions const&) - { - o2::dataformats::VertexBase pvVtx({collision.posX(), collision.posY(), collision.posZ()}, - {collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}); - - std::array mcPvCov = {0.}; - o2::dataformats::VertexBase mcPvVtx({0.0f, 0.0f, 0.0f}, mcPvCov); - if (collision.has_mcCollision()) { - auto mcCollision = collision.mcCollision(); - mcPvVtx.setX(mcCollision.posX()); - mcPvVtx.setY(mcCollision.posY()); - mcPvVtx.setZ(mcCollision.posZ()); - } // else remains untreated for now - - // First we compute the number of charged particles in the event if LUTs are loaded - float dNdEta = 0.f; - if (flagTOFLoadDelphesLUTs) { - for (const auto& track : tracks) { - if (!track.has_mcParticle()) - continue; - auto mcParticle = track.mcParticle(); - if (std::abs(mcParticle.eta()) > multiplicityEtaRange) { - continue; - } - if (mcParticle.has_daughters()) { - continue; - } - const auto& pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); - if (!pdgInfo) { - // LOG(warning) << "PDG code " << mcParticle.pdgCode() << " not found in the database"; - continue; - } - if (pdgInfo->Charge() == 0) { - continue; - } - dNdEta += 1.f; - } - } - - for (const auto& track : tracks) { - // first step: find precise arrival time (if any) - // --- convert track into perfect track - if (!track.has_mcParticle()) // should always be OK but check please - continue; - - auto mcParticle = track.mcParticle(); - o2::track::TrackParCov o2track = convertMCParticleToO2Track(mcParticle); - - float xPv = -100, trackLengthInnerTOF = -1, trackLengthOuterTOF = -1; - if (o2track.propagateToDCA(mcPvVtx, dBz)) - xPv = o2track.getX(); - if (xPv > -99.) { - trackLengthInnerTOF = trackLength(o2track, innerTOFRadius, dBz); - trackLengthOuterTOF = trackLength(o2track, outerTOFRadius, dBz); - } - - // get mass to calculate velocity - auto pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); - if (pdgInfo == nullptr) { - continue; - } - float expectedTimeInnerTOF = trackLengthInnerTOF / velocity(o2track.getP(), pdgInfo->Mass()); - float expectedTimeOuterTOF = trackLengthOuterTOF / velocity(o2track.getP(), pdgInfo->Mass()); - - // Smear with expected resolutions - float measuredTimeInnerTOF = pRandomNumberGenerator.Gaus(expectedTimeInnerTOF, innerTOFTimeReso); - float measuredTimeOuterTOF = pRandomNumberGenerator.Gaus(expectedTimeOuterTOF, outerTOFTimeReso); - - // Now we calculate the expected arrival time following certain mass hypotheses - // and the (imperfect!) reconstructed track parametrizations - float trackLengthRecoInnerTOF = -1, trackLengthRecoOuterTOF = -1; - auto recoTrack = getTrackParCov(track); - if (recoTrack.propagateToDCA(pvVtx, dBz)) - xPv = recoTrack.getX(); - if (xPv > -99.) { - trackLengthRecoInnerTOF = trackLength(recoTrack, innerTOFRadius, dBz); - trackLengthRecoOuterTOF = trackLength(recoTrack, outerTOFRadius, dBz); - } - - // Straight to Nsigma - float deltaTimeInnerTOF[5], nSigmaInnerTOF[5]; - float deltaTimeOuterTOF[5], nSigmaOuterTOF[5]; - int lpdg_array[5] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; - float masses[5]; - - if (doQAplots) { - float momentum = recoTrack.getP(); - // unit conversion: length in cm, time in ps - float innerBeta = 1e+3 * (trackLengthInnerTOF / measuredTimeInnerTOF) / o2::constants::physics::LightSpeedCm2NS; - float outerBeta = 1e+3 * (trackLengthOuterTOF / measuredTimeOuterTOF) / o2::constants::physics::LightSpeedCm2NS; - if (trackLengthRecoInnerTOF > 0) { - histos.fill(HIST("h2dVelocityVsMomentumInner"), momentum, innerBeta); - histos.fill(HIST("h2dTrackLengthInnerVsPt"), o2track.getPt(), trackLengthInnerTOF); - histos.fill(HIST("h2dTrackLengthInnerRecoVsPt"), o2track.getPt(), trackLengthRecoInnerTOF); - } - if (trackLengthRecoOuterTOF > 0) { - histos.fill(HIST("h2dVelocityVsMomentumOuter"), momentum, outerBeta); - histos.fill(HIST("h2dTrackLengthOuterVsPt"), o2track.getPt(), trackLengthOuterTOF); - histos.fill(HIST("h2dTrackLengthOuterRecoVsPt"), o2track.getPt(), trackLengthRecoOuterTOF); - } - } - - for (int ii = 0; ii < 5; ii++) { - nSigmaInnerTOF[ii] = -100; - nSigmaOuterTOF[ii] = -100; - - auto pdgInfoThis = pdg->GetParticle(lpdg_array[ii]); - masses[ii] = pdgInfoThis->Mass(); - deltaTimeInnerTOF[ii] = trackLengthRecoInnerTOF / velocity(recoTrack.getP(), masses[ii]) - measuredTimeInnerTOF; - deltaTimeOuterTOF[ii] = trackLengthRecoOuterTOF / velocity(recoTrack.getP(), masses[ii]) - measuredTimeOuterTOF; - - // Evaluate total sigma (layer + tracking resolution) - float innerTotalTimeReso = innerTOFTimeReso; - float outerTotalTimeReso = outerTOFTimeReso; - if (flagIncludeTrackTimeRes) { - double pt_resolution = std::pow(recoTrack.getP() / std::cosh(recoTrack.getEta()), 2) * std::sqrt(recoTrack.getSigma1Pt2()); - double eta_resolution = std::fabs(std::sin(2.0 * std::atan(std::exp(-recoTrack.getEta())))) * std::sqrt(recoTrack.getSigmaTgl2()); - if (flagTOFLoadDelphesLUTs) { - pt_resolution = mSmearer.getAbsPtRes(pdgInfoThis->PdgCode(), dNdEta, recoTrack.getEta(), recoTrack.getP() / std::cosh(recoTrack.getEta())); - eta_resolution = mSmearer.getAbsEtaRes(pdgInfoThis->PdgCode(), dNdEta, recoTrack.getEta(), recoTrack.getP() / std::cosh(recoTrack.getEta())); - } - float innerTrackTimeReso = calculate_track_time_resolution_advanced(recoTrack.getP() / std::cosh(recoTrack.getEta()), recoTrack.getEta(), pt_resolution, eta_resolution, masses[ii], innerTOFRadius, dBz); - float outerTrackTimeReso = calculate_track_time_resolution_advanced(recoTrack.getP() / std::cosh(recoTrack.getEta()), recoTrack.getEta(), pt_resolution, eta_resolution, masses[ii], outerTOFRadius, dBz); - innerTotalTimeReso = std::hypot(innerTOFTimeReso, innerTrackTimeReso); - outerTotalTimeReso = std::hypot(outerTOFTimeReso, outerTrackTimeReso); - - if (doQAplots && trackLengthRecoInnerTOF > 0) { - float momentum = recoTrack.getP(); - if (ii == 0 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[0])->PdgCode()) { - histos.fill(HIST("h2dInnerTimeResTrackElecVsP"), momentum, innerTrackTimeReso); - histos.fill(HIST("h2dInnerTimeResTotalElecVsP"), momentum, innerTotalTimeReso); - } - if (ii == 1 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[1])->PdgCode()) { - histos.fill(HIST("h2dInnerTimeResTrackMuonVsP"), momentum, innerTrackTimeReso); - histos.fill(HIST("h2dInnerTimeResTotalMuonVsP"), momentum, innerTotalTimeReso); - } - if (ii == 2 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[2])->PdgCode()) { - histos.fill(HIST("h2dInnerTimeResTrackPionVsP"), momentum, innerTrackTimeReso); - histos.fill(HIST("h2dInnerTimeResTotalPionVsP"), momentum, innerTotalTimeReso); - } - if (ii == 3 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[3])->PdgCode()) { - histos.fill(HIST("h2dInnerTimeResTrackKaonVsP"), momentum, innerTrackTimeReso); - histos.fill(HIST("h2dInnerTimeResTotalKaonVsP"), momentum, innerTotalTimeReso); - } - if (ii == 4 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[4])->PdgCode()) { - histos.fill(HIST("h2dInnerTimeResTrackProtVsP"), momentum, innerTrackTimeReso); - histos.fill(HIST("h2dInnerTimeResTotalProtVsP"), momentum, innerTotalTimeReso); - } - } - if (doQAplots && trackLengthRecoOuterTOF > 0) { - float momentum = recoTrack.getP(); - float pseudorapidity = recoTrack.getEta(); - float transverse_momentum = momentum / std::cosh(pseudorapidity); - if (ii == 0 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[0])->PdgCode()) { - histos.fill(HIST("h2dOuterTimeResTrackElecVsP"), momentum, outerTrackTimeReso); - histos.fill(HIST("h2dOuterTimeResTotalElecVsP"), momentum, outerTotalTimeReso); - } - if (ii == 1 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[1])->PdgCode()) { - histos.fill(HIST("h2dOuterTimeResTrackMuonVsP"), momentum, outerTrackTimeReso); - histos.fill(HIST("h2dOuterTimeResTotalMuonVsP"), momentum, outerTotalTimeReso); - } - if (ii == 2 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[2])->PdgCode()) { - histos.fill(HIST("h2dOuterTimeResTrackPionVsP"), momentum, outerTrackTimeReso); - histos.fill(HIST("h2dOuterTimeResTotalPionVsP"), momentum, outerTotalTimeReso); - - histos.fill(HIST("h2dRelativePtResolution"), transverse_momentum, 100.0 * pt_resolution / transverse_momentum); - histos.fill(HIST("h2dRelativeEtaResolution"), pseudorapidity, 100.0 * eta_resolution / (std::fabs(pseudorapidity) + 1e-6)); - } - if (ii == 3 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[3])->PdgCode()) { - histos.fill(HIST("h2dOuterTimeResTrackKaonVsP"), momentum, outerTrackTimeReso); - histos.fill(HIST("h2dOuterTimeResTotalKaonVsP"), momentum, outerTotalTimeReso); - } - if (ii == 4 && std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[4])->PdgCode()) { - histos.fill(HIST("h2dOuterTimeResTrackProtVsP"), momentum, outerTrackTimeReso); - histos.fill(HIST("h2dOuterTimeResTotalProtVsP"), momentum, outerTotalTimeReso); - } - } - } - - // Fixme: assumes dominant resolution effect is the TOF resolution - // and not the tracking itself. It's *probably* a fair assumption - // but it should be tested further! --> FIXED IN THIS VERSION - if (trackLengthInnerTOF > 0 && trackLengthRecoInnerTOF > 0) - nSigmaInnerTOF[ii] = deltaTimeInnerTOF[ii] / innerTotalTimeReso; - if (trackLengthOuterTOF > 0 && trackLengthRecoOuterTOF > 0) - nSigmaOuterTOF[ii] = deltaTimeOuterTOF[ii] / outerTotalTimeReso; - } - - if (doQAplots) { - float momentum = recoTrack.getP(); - if (trackLengthRecoInnerTOF > 0) { - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[0])->PdgCode()) { - histos.fill(HIST("h2dInnerNsigmaTrueElecVsElecHypothesis"), momentum, nSigmaInnerTOF[0]); - histos.fill(HIST("h2dInnerNsigmaTrueElecVsMuonHypothesis"), momentum, nSigmaInnerTOF[1]); - histos.fill(HIST("h2dInnerNsigmaTrueElecVsPionHypothesis"), momentum, nSigmaInnerTOF[2]); - histos.fill(HIST("h2dInnerNsigmaTrueElecVsKaonHypothesis"), momentum, nSigmaInnerTOF[3]); - histos.fill(HIST("h2dInnerNsigmaTrueElecVsProtHypothesis"), momentum, nSigmaInnerTOF[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[1])->PdgCode()) { - histos.fill(HIST("h2dInnerNsigmaTrueMuonVsElecHypothesis"), momentum, nSigmaInnerTOF[0]); - histos.fill(HIST("h2dInnerNsigmaTrueMuonVsMuonHypothesis"), momentum, nSigmaInnerTOF[1]); - histos.fill(HIST("h2dInnerNsigmaTrueMuonVsPionHypothesis"), momentum, nSigmaInnerTOF[2]); - histos.fill(HIST("h2dInnerNsigmaTrueMuonVsKaonHypothesis"), momentum, nSigmaInnerTOF[3]); - histos.fill(HIST("h2dInnerNsigmaTrueMuonVsProtHypothesis"), momentum, nSigmaInnerTOF[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[2])->PdgCode()) { - histos.fill(HIST("h2dInnerNsigmaTruePionVsElecHypothesis"), momentum, nSigmaInnerTOF[0]); - histos.fill(HIST("h2dInnerNsigmaTruePionVsMuonHypothesis"), momentum, nSigmaInnerTOF[1]); - histos.fill(HIST("h2dInnerNsigmaTruePionVsPionHypothesis"), momentum, nSigmaInnerTOF[2]); - histos.fill(HIST("h2dInnerNsigmaTruePionVsKaonHypothesis"), momentum, nSigmaInnerTOF[3]); - histos.fill(HIST("h2dInnerNsigmaTruePionVsProtHypothesis"), momentum, nSigmaInnerTOF[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[3])->PdgCode()) { - histos.fill(HIST("h2dInnerNsigmaTrueKaonVsElecHypothesis"), momentum, nSigmaInnerTOF[0]); - histos.fill(HIST("h2dInnerNsigmaTrueKaonVsMuonHypothesis"), momentum, nSigmaInnerTOF[1]); - histos.fill(HIST("h2dInnerNsigmaTrueKaonVsPionHypothesis"), momentum, nSigmaInnerTOF[2]); - histos.fill(HIST("h2dInnerNsigmaTrueKaonVsKaonHypothesis"), momentum, nSigmaInnerTOF[3]); - histos.fill(HIST("h2dInnerNsigmaTrueKaonVsProtHypothesis"), momentum, nSigmaInnerTOF[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[4])->PdgCode()) { - histos.fill(HIST("h2dInnerNsigmaTrueProtVsElecHypothesis"), momentum, nSigmaInnerTOF[0]); - histos.fill(HIST("h2dInnerNsigmaTrueProtVsMuonHypothesis"), momentum, nSigmaInnerTOF[1]); - histos.fill(HIST("h2dInnerNsigmaTrueProtVsPionHypothesis"), momentum, nSigmaInnerTOF[2]); - histos.fill(HIST("h2dInnerNsigmaTrueProtVsKaonHypothesis"), momentum, nSigmaInnerTOF[3]); - histos.fill(HIST("h2dInnerNsigmaTrueProtVsProtHypothesis"), momentum, nSigmaInnerTOF[4]); - } - } - if (trackLengthRecoOuterTOF > 0) { - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[0])->PdgCode()) { - histos.fill(HIST("h2dOuterNsigmaTrueElecVsElecHypothesis"), momentum, nSigmaOuterTOF[0]); - histos.fill(HIST("h2dOuterNsigmaTrueElecVsMuonHypothesis"), momentum, nSigmaOuterTOF[1]); - histos.fill(HIST("h2dOuterNsigmaTrueElecVsPionHypothesis"), momentum, nSigmaOuterTOF[2]); - histos.fill(HIST("h2dOuterNsigmaTrueElecVsKaonHypothesis"), momentum, nSigmaOuterTOF[3]); - histos.fill(HIST("h2dOuterNsigmaTrueElecVsProtHypothesis"), momentum, nSigmaOuterTOF[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[1])->PdgCode()) { - histos.fill(HIST("h2dOuterNsigmaTrueMuonVsElecHypothesis"), momentum, nSigmaOuterTOF[0]); - histos.fill(HIST("h2dOuterNsigmaTrueMuonVsMuonHypothesis"), momentum, nSigmaOuterTOF[1]); - histos.fill(HIST("h2dOuterNsigmaTrueMuonVsPionHypothesis"), momentum, nSigmaOuterTOF[2]); - histos.fill(HIST("h2dOuterNsigmaTrueMuonVsKaonHypothesis"), momentum, nSigmaOuterTOF[3]); - histos.fill(HIST("h2dOuterNsigmaTrueMuonVsProtHypothesis"), momentum, nSigmaOuterTOF[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[2])->PdgCode()) { - histos.fill(HIST("h2dOuterNsigmaTruePionVsElecHypothesis"), momentum, nSigmaOuterTOF[0]); - histos.fill(HIST("h2dOuterNsigmaTruePionVsMuonHypothesis"), momentum, nSigmaOuterTOF[1]); - histos.fill(HIST("h2dOuterNsigmaTruePionVsPionHypothesis"), momentum, nSigmaOuterTOF[2]); - histos.fill(HIST("h2dOuterNsigmaTruePionVsKaonHypothesis"), momentum, nSigmaOuterTOF[3]); - histos.fill(HIST("h2dOuterNsigmaTruePionVsProtHypothesis"), momentum, nSigmaOuterTOF[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[3])->PdgCode()) { - histos.fill(HIST("h2dOuterNsigmaTrueKaonVsElecHypothesis"), momentum, nSigmaOuterTOF[0]); - histos.fill(HIST("h2dOuterNsigmaTrueKaonVsMuonHypothesis"), momentum, nSigmaOuterTOF[1]); - histos.fill(HIST("h2dOuterNsigmaTrueKaonVsPionHypothesis"), momentum, nSigmaOuterTOF[2]); - histos.fill(HIST("h2dOuterNsigmaTrueKaonVsKaonHypothesis"), momentum, nSigmaOuterTOF[3]); - histos.fill(HIST("h2dOuterNsigmaTrueKaonVsProtHypothesis"), momentum, nSigmaOuterTOF[4]); - } - if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(lpdg_array[4])->PdgCode()) { - histos.fill(HIST("h2dOuterNsigmaTrueProtVsElecHypothesis"), momentum, nSigmaOuterTOF[0]); - histos.fill(HIST("h2dOuterNsigmaTrueProtVsMuonHypothesis"), momentum, nSigmaOuterTOF[1]); - histos.fill(HIST("h2dOuterNsigmaTrueProtVsPionHypothesis"), momentum, nSigmaOuterTOF[2]); - histos.fill(HIST("h2dOuterNsigmaTrueProtVsKaonHypothesis"), momentum, nSigmaOuterTOF[3]); - histos.fill(HIST("h2dOuterNsigmaTrueProtVsProtHypothesis"), momentum, nSigmaOuterTOF[4]); - } - } - } - - float deltaTrackLengthInnerTOF = abs(trackLengthInnerTOF - trackLengthRecoInnerTOF); - if (trackLengthInnerTOF > 0 && trackLengthRecoInnerTOF > 0) { - histos.fill(HIST("h2dDeltaTrackLengthInnerVsPt"), o2track.getPt(), deltaTrackLengthInnerTOF); - } - float deltaTrackLengthOuterTOF = abs(trackLengthOuterTOF - trackLengthRecoOuterTOF); - if (trackLengthOuterTOF > 0 && trackLengthRecoOuterTOF > 0) { - histos.fill(HIST("h2dDeltaTrackLengthOuterVsPt"), o2track.getPt(), deltaTrackLengthInnerTOF); - } - - // Sigmas have been fully calculated. Please populate the NSigma helper table (once per track) - upgradeTof(nSigmaInnerTOF[0], nSigmaInnerTOF[1], nSigmaInnerTOF[2], nSigmaInnerTOF[3], nSigmaInnerTOF[4], trackLengthInnerTOF, trackLengthRecoInnerTOF, deltaTrackLengthInnerTOF, - nSigmaOuterTOF[0], nSigmaOuterTOF[1], nSigmaOuterTOF[2], nSigmaOuterTOF[3], nSigmaOuterTOF[4], trackLengthOuterTOF, trackLengthRecoOuterTOF, deltaTrackLengthOuterTOF); - } - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx new file mode 100644 index 00000000000..4c062fd0e7a --- /dev/null +++ b/ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx @@ -0,0 +1,731 @@ +// 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. +/// +/// \file onTheFlyTofPid.cxx +/// +/// \brief This task goes straight from a combination of track table and mcParticles +/// and a custom TOF configuration to a table of TOF NSigmas for the particles +/// being analysed. It currently contemplates 5 particle types: +/// electrons, pions, kaons, protons and muons +/// +/// More particles could be added but would have to be added to the LUT +/// being used in the onTheFly tracker task. +/// +/// \author David Dobrigkeit Chinellato, UNICAMP +/// \author Nicola Nicassio, University and INFN Bari +/// \since May 22, 2024 +/// + +#include "TableHelper.h" + +#include "ALICE3/Core/DelphesO2TrackSmearer.h" +#include "ALICE3/Core/TrackUtilities.h" +#include "ALICE3/DataModel/OTFTOF.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "CommonConstants/GeomConstants.h" +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "CommonUtils/NameConf.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsVertexing/HelixHelper.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/DCA.h" + +#include "TEfficiency.h" +#include "THashList.h" +#include "TRandom3.h" +#include + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; + +std::array, 5> h2dInnerTimeResTrack; +std::array, 5> h2dInnerTimeResTotal; +std::array, 5> h2dOuterTimeResTrack; +std::array, 5> h2dOuterTimeResTotal; +std::array, 5>, 5> h2dInnerNsigmaTrue; +std::array, 5>, 5> h2dOuterNsigmaTrue; +std::array, 5>, 5> h2dInnerDeltaTrue; +std::array, 5>, 5> h2dOuterDeltaTrue; + +struct OnTheFlyTofPid { + Produces upgradeTofMC; + Produces upgradeTof; + Produces upgradeTofExpectedTime; + + // necessary for particle charges + Service pdg; + + // these are the settings governing the TOF layers to be used + // note that there are two layers foreseen for now: inner and outer TOF + // more could be added (especially a disk TOF at a certain z?) + // in the evolution of this effort + struct : ConfigurableGroup { + Configurable magneticField{"magneticField", 0, "magnetic field (kilogauss) if 0, taken from the tracker task"}; + Configurable considerEventTime{"considerEventTime", true, "flag to consider event time"}; + Configurable innerTOFRadius{"innerTOFRadius", 20, "barrel inner TOF radius (cm)"}; + Configurable outerTOFRadius{"outerTOFRadius", 80, "barrel outer TOF radius (cm)"}; + Configurable innerTOFTimeReso{"innerTOFTimeReso", 20, "barrel inner TOF time error (ps)"}; + Configurable outerTOFTimeReso{"outerTOFTimeReso", 20, "barrel outer TOF time error (ps)"}; + Configurable nStepsLIntegrator{"nStepsLIntegrator", 200, "number of steps in length integrator"}; + Configurable multiplicityEtaRange{"multiplicityEtaRange", 0.800000012, "eta range to compute the multiplicity"}; + Configurable flagIncludeTrackTimeRes{"flagIncludeTrackTimeRes", true, "flag to include or exclude track time resolution"}; + Configurable flagTOFLoadDelphesLUTs{"flagTOFLoadDelphesLUTs", false, "flag to load Delphes LUTs for tracking correction (use recoTrack parameters if false)"}; + Configurable lutEl{"lutEl", "inherit", "LUT for electrons (if inherit, inherits from otf tracker task)"}; + Configurable lutMu{"lutMu", "inherit", "LUT for muons (if inherit, inherits from otf tracker task)"}; + Configurable lutPi{"lutPi", "inherit", "LUT for pions (if inherit, inherits from otf tracker task)"}; + Configurable lutKa{"lutKa", "inherit", "LUT for kaons (if inherit, inherits from otf tracker task)"}; + Configurable lutPr{"lutPr", "inherit", "LUT for protons (if inherit, inherits from otf tracker task)"}; + } simConfig; + + struct : ConfigurableGroup { + Configurable doQAplots{"doQAplots", true, "do basic velocity plot qa"}; + Configurable doSeparationVsPt{"doSeparationVsPt", true, "Produce plots vs pt or p"}; + Configurable nBinsBeta{"nBinsBeta", 2200, "number of bins in beta"}; + Configurable nBinsP{"nBinsP", 80, "number of bins in momentum/pT depending on doSeparationVsPt"}; + Configurable nBinsTrackLengthInner{"nBinsTrackLengthInner", 300, "number of bins in track length"}; + Configurable nBinsTrackLengthOuter{"nBinsTrackLengthOuter", 300, "number of bins in track length"}; + Configurable nBinsTrackDeltaLength{"nBinsTrackDeltaLength", 100, "number of bins in delta track length"}; + Configurable nBinsNsigmaCorrectSpecies{"nBinsNsigmaCorrectSpecies", 200, "number of bins in Nsigma plot (correct speies)"}; + Configurable nBinsNsigmaWrongSpecies{"nBinsNsigmaWrongSpecies", 200, "number of bins in Nsigma plot (wrong species)"}; + Configurable minNsigmaRange{"minNsigmaRange", -10, "lower limit for the nsigma axis"}; + Configurable maxNsigmaRange{"maxNsigmaRange", +10, "upper limit for the nsigma axis"}; + Configurable nBinsDeltaCorrectSpecies{"nBinsDeltaCorrectSpecies", 200, "number of bins in Delta plot (correct speies)"}; + Configurable nBinsDeltaWrongSpecies{"nBinsDeltaWrongSpecies", 200, "number of bins in Delta plot (wrong species)"}; + Configurable minDeltaRange{"minDeltaRange", -100, "lower limit for the nsigma axis"}; + Configurable maxDeltaRange{"maxDeltaRange", +100, "upper limit for the nsigma axis"}; + Configurable nBinsTimeRes{"nBinsTimeRes", 400, "number of bins plots time resolution"}; + Configurable nBinsRelativeEtaPt{"nBinsRelativeEtaPt", 400, "number of bins plots pt and eta relative errors"}; + Configurable nBinsEta{"nBinsEta", 400, "number of bins plot relative eta error"}; + Configurable nBinsMult{"nBinsMult", 200, "number of bins in multiplicity"}; + Configurable maxMultRange{"maxMultRange", 1000.f, "upper limit in multiplicity plots"}; + } plotsConfig; + + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + + // Track smearer (here used to get absolute pt and eta uncertainties if simConfig.flagTOFLoadDelphesLUTs is true) + o2::delphes::DelphesO2TrackSmearer mSmearer; + + // needed: random number generator for smearing + TRandom3 pRandomNumberGenerator; + + // for handling basic QA histograms if requested + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + OutputObj listEfficiency{"efficiency"}; + static constexpr int kParticles = 5; + + void init(o2::framework::InitContext& initContext) + { + pRandomNumberGenerator.SetSeed(0); // fully randomize + if (simConfig.magneticField.value < o2::constants::math::Epsilon) { + LOG(info) << "Getting the magnetic field from the on-the-fly tracker task"; + if (!getTaskOptionValue(initContext, "on-the-fly-tracker", simConfig.magneticField, false)) { + LOG(fatal) << "Could not get Bz from on-the-fly-tracker task"; + } + LOG(info) << "Bz = " << simConfig.magneticField.value << " T"; + } + + // Check if inheriting the LUT configuration + auto configLutPath = [&](Configurable& lut) { + if (lut.value != "inherit") { + return; + } + if (!getTaskOptionValue(initContext, "on-the-fly-tracker", lut, false)) { + LOG(fatal) << "Could not get " << lut.name << " from on-the-fly-tracker task"; + } + }; + configLutPath(simConfig.lutEl); + configLutPath(simConfig.lutMu); + configLutPath(simConfig.lutPi); + configLutPath(simConfig.lutKa); + configLutPath(simConfig.lutPr); + + // Load LUT for pt and eta smearing + if (simConfig.flagIncludeTrackTimeRes && simConfig.flagTOFLoadDelphesLUTs) { + std::map mapPdgLut; + const char* lutElChar = simConfig.lutEl->c_str(); + const char* lutMuChar = simConfig.lutMu->c_str(); + const char* lutPiChar = simConfig.lutPi->c_str(); + const char* lutKaChar = simConfig.lutKa->c_str(); + const char* lutPrChar = simConfig.lutPr->c_str(); + + LOGF(info, "Will load electron lut file ..: %s for TOF PID", lutElChar); + LOGF(info, "Will load muon lut file ......: %s for TOF PID", lutMuChar); + LOGF(info, "Will load pion lut file ......: %s for TOF PID", lutPiChar); + LOGF(info, "Will load kaon lut file ......: %s for TOF PID", lutKaChar); + LOGF(info, "Will load proton lut file ....: %s for TOF PID", lutPrChar); + + mapPdgLut.insert(std::make_pair(11, lutElChar)); + mapPdgLut.insert(std::make_pair(13, lutMuChar)); + mapPdgLut.insert(std::make_pair(211, lutPiChar)); + mapPdgLut.insert(std::make_pair(321, lutKaChar)); + mapPdgLut.insert(std::make_pair(2212, lutPrChar)); + + for (const auto& e : mapPdgLut) { + if (!mSmearer.loadTable(e.first, e.second)) { + LOG(fatal) << "Having issue with loading the LUT " << e.first << " " << e.second; + } + } + } + + if (plotsConfig.doQAplots) { + const AxisSpec axisdNdeta{plotsConfig.nBinsMult, 0.0f, plotsConfig.maxMultRange, Form("dN/d#eta in |#eta| < %f", simConfig.multiplicityEtaRange.value)}; + + histos.add("h1dNdeta", "h2dNdeta", kTH1F, {axisdNdeta}); + histos.add("h2dEventTime", "h2dEventTime", kTH2F, {{200, -1000, 1000, "computed"}, {200, -1000, 1000, "generated"}}); + histos.add("h1dEventTimegen", "h1dEventTimegen", kTH1F, {{200, -1000, 1000, "generated"}}); + histos.add("h1dEventTimerec", "h1dEventTimerec", kTH1F, {{200, -1000, 1000, "computed"}}); + histos.add("h1dEventTimedelta", "h1dEventTimedelta", kTH1F, {{200, -1000, 1000, "generated - computed"}}); + histos.add("h2dEventTimeres", "h2dEventTimeres", kTH2F, {axisdNdeta, {300, 0, 300, "resolution"}}); + listEfficiency.setObject(new THashList); + listEfficiency->Add(new TEfficiency("effEventTime", "effEventTime", plotsConfig.nBinsMult, 0.0f, plotsConfig.maxMultRange)); + + const AxisSpec axisMomentum{static_cast(plotsConfig.nBinsP), 0.0f, +10.0f, "#it{p} (GeV/#it{c})"}; + const AxisSpec axisMomentumSmall{static_cast(plotsConfig.nBinsP), 0.0f, +1.0f, "#it{p} (GeV/#it{c})"}; + const AxisSpec axisVelocity{static_cast(plotsConfig.nBinsBeta), 0.0f, +1.1f, "Measured #beta"}; + const AxisSpec axisTrackLengthInner{static_cast(plotsConfig.nBinsTrackLengthInner), 0.0f, 60.0f, "Track length (cm)"}; + const AxisSpec axisTrackLengthOuter{static_cast(plotsConfig.nBinsTrackLengthOuter), 0.0f, 300.0f, "Track length (cm)"}; + const AxisSpec axisTrackDeltaLength{static_cast(plotsConfig.nBinsTrackDeltaLength), 0.0f, 30.0f, "Delta Track length (cm)"}; + histos.add("iTOF/h2dVelocityVsMomentumInner", "h2dVelocityVsMomentumInner", kTH2F, {axisMomentum, axisVelocity}); + histos.add("iTOF/h2dTrackLengthInnerVsPt", "h2dTrackLengthInnerVsPt", kTH2F, {axisMomentumSmall, axisTrackLengthInner}); + histos.add("iTOF/h2dTrackLengthInnerRecoVsPt", "h2dTrackLengthInnerRecoVsPt", kTH2F, {axisMomentumSmall, axisTrackLengthInner}); + histos.add("iTOF/h2dDeltaTrackLengthInnerVsPt", "h2dDeltaTrackLengthInnerVsPt", kTH2F, {axisMomentumSmall, axisTrackDeltaLength}); + + histos.add("oTOF/h2dVelocityVsMomentumOuter", "h2dVelocityVsMomentumOuter", kTH2F, {axisMomentum, axisVelocity}); + histos.add("oTOF/h2dTrackLengthOuterVsPt", "h2dTrackLengthOuterVsPt", kTH2F, {axisMomentumSmall, axisTrackLengthOuter}); + histos.add("oTOF/h2dTrackLengthOuterRecoVsPt", "h2dTrackLengthOuterRecoVsPt", kTH2F, {axisMomentumSmall, axisTrackLengthOuter}); + histos.add("oTOF/h2dDeltaTrackLengthOuterVsPt", "h2dDeltaTrackLengthOuterVsPt", kTH2F, {axisMomentumSmall, axisTrackDeltaLength}); + + const AxisSpec axisPt{static_cast(plotsConfig.nBinsP), 0.0f, +4.0f, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisEta{static_cast(plotsConfig.nBinsEta), -2.0f, +2.0f, "#eta"}; + const AxisSpec axisRelativePt{static_cast(plotsConfig.nBinsRelativeEtaPt), 0.0f, +10.0f, "#it{#sigma_{p_{T}}} / #it{p_{T}} (%)"}; + const AxisSpec axisRelativeEta{static_cast(plotsConfig.nBinsRelativeEtaPt), 0.0f, +10.0f, "#it{#sigma_{#eta}} / #it{#eta} (%)"}; + histos.add("h2dRelativePtResolution", "h2dRelativePtResolution", kTH2F, {axisPt, axisRelativePt}); + histos.add("h2dRelativeEtaResolution", "h2dRelativeEtaResolution", kTH2F, {axisEta, axisRelativeEta}); + + std::string particleNames[kParticles] = {"#it{e}", "#it{#mu}", "#it{#pi}", "#it{K}", "#it{p}"}; + std::string particleNames2[kParticles] = {"Elec", "Muon", "Pion", "Kaon", "Prot"}; + for (int iTrue = 0; iTrue < kParticles; iTrue++) { + auto addHistogram = [&](const std::string& name, const AxisSpec& axis) { + return histos.add(name, "", kTH2F, {axisMomentum, axis}); + }; + + const AxisSpec axisTrackTimeRes{plotsConfig.nBinsTimeRes, 0.0f, +200.0f, "Track time resolution - " + particleNames[iTrue] + " (ps)"}; + h2dInnerTimeResTrack[iTrue] = addHistogram("iTOF/res/h2dInnerTimeResTrack" + particleNames2[iTrue] + "VsP", axisTrackTimeRes); + h2dOuterTimeResTrack[iTrue] = addHistogram("oTOF/res/h2dOuterTimeResTrack" + particleNames2[iTrue] + "VsP", axisTrackTimeRes); + const AxisSpec axisTotalTimeRes{plotsConfig.nBinsTimeRes, 0.0f, +200.0f, "Total time resolution - " + particleNames[iTrue] + " (ps)"}; + h2dInnerTimeResTotal[iTrue] = addHistogram("iTOF/res/h2dInnerTimeResTotal" + particleNames2[iTrue] + "VsP", axisTotalTimeRes); + h2dOuterTimeResTotal[iTrue] = addHistogram("oTOF/res/h2dOuterTimeResTotal" + particleNames2[iTrue] + "VsP", axisTotalTimeRes); + for (int iHyp = 0; iHyp < kParticles; iHyp++) { + std::string nameTitleInner = "h2dInnerNsigmaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis"; + std::string nameTitleOuter = "h2dOuterNsigmaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis"; + std::string nameTitleInnerDelta = "h2dInnerDeltaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis"; + std::string nameTitleOuterDelta = "h2dOuterDeltaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis"; + const AxisSpec axisX{plotsConfig.doSeparationVsPt.value ? axisPt : axisMomentum}; + const AxisSpec axisNsigmaCorrect{plotsConfig.nBinsNsigmaCorrectSpecies, plotsConfig.minNsigmaRange, plotsConfig.maxNsigmaRange, "N#sigma - True " + particleNames[iTrue] + " vs " + particleNames[iHyp] + " hypothesis"}; + const AxisSpec axisDeltaCorrect{plotsConfig.nBinsDeltaCorrectSpecies, plotsConfig.minDeltaRange, plotsConfig.maxDeltaRange, "#Delta - True " + particleNames[iTrue] + " vs " + particleNames[iHyp] + " hypothesis"}; + const AxisSpec axisNsigmaWrong{plotsConfig.nBinsNsigmaWrongSpecies, plotsConfig.minNsigmaRange, plotsConfig.maxNsigmaRange, "N#sigma - True " + particleNames[iTrue] + " vs " + particleNames[iHyp] + " hypothesis"}; + const AxisSpec axisDeltaWrong{plotsConfig.nBinsDeltaWrongSpecies, plotsConfig.minDeltaRange, plotsConfig.maxDeltaRange, "#Delta - True " + particleNames[iTrue] + " vs " + particleNames[iHyp] + " hypothesis"}; + const AxisSpec axisNSigma{iTrue == iHyp ? axisNsigmaCorrect : axisNsigmaWrong}; + const AxisSpec axisDelta{iTrue == iHyp ? axisDeltaCorrect : axisDeltaWrong}; + h2dInnerNsigmaTrue[iTrue][iHyp] = histos.add("iTOF/nsigma/h2dInnerNsigmaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis", "", kTH2F, {axisX, axisNSigma}); + h2dOuterNsigmaTrue[iTrue][iHyp] = histos.add("oTOF/nsigma/h2dOuterNsigmaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis", "", kTH2F, {axisX, axisNSigma}); + h2dInnerDeltaTrue[iTrue][iHyp] = histos.add("iTOF/delta/h2dInnerDeltaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis", "", kTH2F, {axisX, axisDelta}); + h2dOuterDeltaTrue[iTrue][iHyp] = histos.add("oTOF/delta/h2dOuterDeltaTrue" + particleNames2[iTrue] + "Vs" + particleNames2[iHyp] + "Hypothesis", "", kTH2F, {axisX, axisDelta}); + } + } + } + } + + /// function to calculate track length of this track up to a certain radius + /// \param track the input track + /// \param radius the radius of the layer you're calculating the length to + /// \param magneticField the magnetic field to use when propagating + float computeTrackLength(o2::track::TrackParCov track, float radius, float magneticField) + { + // don't make use of the track parametrization + float length = -100; + + o2::math_utils::CircleXYf_t trcCircle; + float sna, csa; + track.getCircleParams(magneticField, trcCircle, sna, csa); + + // distance between circle centers (one circle is at origin -> easy) + const float centerDistance = std::hypot(trcCircle.xC, trcCircle.yC); + + // condition of circles touching - if not satisfied returned length will be -100 + if (centerDistance < trcCircle.rC + radius && centerDistance > std::fabs(trcCircle.rC - radius)) { + length = 0.0f; + + // base radical direction + const float ux = trcCircle.xC / centerDistance; + const float uy = trcCircle.yC / centerDistance; + // calculate perpendicular vector (normalized) for +/- displacement + const float vx = -uy; + const float vy = +ux; + // calculate coordinate for radical line + const float radical = (centerDistance * centerDistance - trcCircle.rC * trcCircle.rC + radius * radius) / (2.0f * centerDistance); + // calculate absolute displacement from center-to-center axis + const float displace = (0.5f / centerDistance) * std::sqrt( + (-centerDistance + trcCircle.rC - radius) * + (-centerDistance - trcCircle.rC + radius) * + (-centerDistance + trcCircle.rC + radius) * + (centerDistance + trcCircle.rC + radius)); + + // possible intercept points of track and TOF layer in 2D plane + const float point1[2] = {radical * ux + displace * vx, radical * uy + displace * vy}; + const float point2[2] = {radical * ux - displace * vx, radical * uy - displace * vy}; + + // decide on correct intercept point + std::array mom; + track.getPxPyPzGlo(mom); + const float scalarProduct1 = point1[0] * mom[0] + point1[1] * mom[1]; + const float scalarProduct2 = point2[0] * mom[0] + point2[1] * mom[1]; + + // get start point + std::array startPoint; + track.getXYZGlo(startPoint); + + float cosAngle = -1000, modulus = -1000; + + if (scalarProduct1 > scalarProduct2) { + modulus = std::hypot(point1[0] - trcCircle.xC, point1[1] - trcCircle.yC) * std::hypot(startPoint[0] - trcCircle.xC, startPoint[1] - trcCircle.yC); + cosAngle = (point1[0] - trcCircle.xC) * (startPoint[0] - trcCircle.xC) + (point1[1] - trcCircle.yC) * (startPoint[1] - trcCircle.yC); + } else { + modulus = std::hypot(point2[0] - trcCircle.xC, point2[1] - trcCircle.yC) * std::hypot(startPoint[0] - trcCircle.xC, startPoint[1] - trcCircle.yC); + cosAngle = (point2[0] - trcCircle.xC) * (startPoint[0] - trcCircle.xC) + (point2[1] - trcCircle.yC) * (startPoint[1] - trcCircle.yC); + } + cosAngle /= modulus; + length = trcCircle.rC * std::acos(cosAngle); + length *= std::sqrt(1.0f + track.getTgl() * track.getTgl()); + } + return length; + } + + /// returns velocity in centimeters per picoseconds + /// \param momentum the momentum of the tarck + /// \param mass the mass of the particle + float computeParticleVelocity(float momentum, float mass) + { + const float a = momentum / mass; + // uses light speed in cm/ps so output is in those units + return o2::constants::physics::LightSpeedCm2PS * a / std::sqrt((1.f + a * a)); + } + + struct TracksWithTime { + TracksWithTime(int pdgCode, + std::pair innerTOFTime, + std::pair outerTOFTime, + std::pair trackLengthInnerTOF, + std::pair trackLengthOuterTOF, + std::pair momentum, + std::pair pseudorapidity, + float noSmearingPt) + : mPdgCode(pdgCode), + mInnerTOFTime(innerTOFTime), + mOuterTOFTime(outerTOFTime), + mTrackLengthInnerTOF(trackLengthInnerTOF), + mTrackLengthOuterTOF(trackLengthOuterTOF), + mMomentum(momentum), + mPseudorapidity{pseudorapidity}, + mNoSmearingPt{noSmearingPt} {} + + int mPdgCode; + std::pair mInnerTOFTime; // Measured time and expected resolution at the inner TOF [ps] + std::pair mOuterTOFTime; // Measured time and expected resolution at the outer TOF [ps] + std::pair mTrackLengthInnerTOF; // Measured and generated length at the innerTOF [cm] + std::pair mTrackLengthOuterTOF; // Measured and generated length at the outerTOF [cm] + std::pair mMomentum; // Measured momentum and uncertainty on the momentum [GeV/c] + std::pair mPseudorapidity; // Measured pseudorapidity and uncertainty on the pseudorapidity + float mNoSmearingPt; // No smearing pt + }; + + std::vector tracksWithTime; + bool eventTime(std::vector& tracks, + std::array& tzero) + { + + float sum = 0.; + float sumw = 0.; + + // Todo: check the different mass hypothesis iteratively + for (const auto& track : tracks) { + auto pdgInfo = pdg->GetParticle(track.mPdgCode); + if (pdgInfo == nullptr) { + continue; + } + const float mass = pdgInfo->Mass(); + const float mass2 = mass * mass; + const float tof = track.mInnerTOFTime.first; // [ps] + if (tof <= 0) { + continue; + } + const float etof = track.mInnerTOFTime.second; // [ps] + const float length = track.mTrackLengthInnerTOF.first; // [cm] + float p = track.mMomentum.first; // [GeV/c] + p *= std::abs(pdgInfo->Charge()) / 3.; // Total momentum + const float ep = track.mMomentum.second; // [GeV/c] + const float p2 = p * p; + const float lengthOverC = length * o2::constants::physics::invLightSpeedCm2PS; + const float texp = lengthOverC / p * std::sqrt(mass2 + p2); + // LOG(info) << "TOF: " << tof << " " << etof << " vs " << texp; + const float etexp = lengthOverC * mass2 / p2 / std::sqrt(mass2 + p2) * ep; + const float sigma = std::sqrt(etexp * etexp + etof * etof); + const float deltat = tof - texp; + + const float w = 1. / (sigma * sigma); + + sum += w * deltat; + sumw += w; + } + + static constexpr float kMaxEventTimeResolution = 200.f; + if (sumw <= 0. || tracks.size() <= 1 || std::sqrt(1. / sumw) > kMaxEventTimeResolution) { + tzero[0] = 0.; // [ps] + tzero[1] = kMaxEventTimeResolution; // [ps] + return false; + } + + tzero[0] = sum / sumw; + tzero[1] = std::sqrt(1. / sumw); + return true; + } + + /// returns track time resolution + /// \param pt the transverse momentum of the tarck + /// \param eta the pseudorapidity of the tarck + /// \param trackPtResolution the absolute resolution on pt + /// \param trackEtaResolution the absolute resolution on eta + /// \param mass the mass of the particle + /// \param detRadius the radius of the cylindrical layer + /// \param magneticField the magnetic field (along Z) + double calculateTrackTimeResolutionAdvanced(const float pt, + const float eta, + const float trackPtResolution, + const float trackEtaResolution, + const float mass, + const float detRadius, + const float magneticField) + { + // Compute tracking contribution to timing using the error propagation formula + // Uses light speed in m/ps, magnetic field in T (*0.1 for conversion kGauss -> T) + double a0 = mass * mass; + double a1 = 0.299792458 * (0.1 * magneticField) * (0.01 * o2::constants::physics::LightSpeedCm2NS / 1e+3); + double a2 = (detRadius * 0.01) * (detRadius * 0.01) * (0.299792458) * (0.299792458) * (0.1 * magneticField) * (0.1 * magneticField) / 2.0; + double dtofOndPt = (std::pow(pt, 4) * std::pow(std::cosh(eta), 2) * std::acos(1.0 - a2 / std::pow(pt, 2)) - 2.0 * a2 * std::pow(pt, 2) * (a0 + std::pow(pt * std::cosh(eta), 2)) / std::sqrt(a2 * (2.0 * std::pow(pt, 2) - a2))) / (a1 * std::pow(pt, 3) * std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2))); + double dtofOndEta = std::pow(pt, 2) * std::sinh(eta) * std::cosh(eta) * std::acos(1.0 - a2 / std::pow(pt, 2)) / (a1 * std::sqrt(a0 + std::pow(pt * std::cosh(eta), 2))); + double trackTimeResolution = std::hypot(std::fabs(dtofOndPt) * trackPtResolution, std::fabs(dtofOndEta) * trackEtaResolution); + return trackTimeResolution; + } + + void process(soa::Join::iterator const& collision, + soa::Join const& tracks, + aod::McParticles const&, + aod::McCollisions const&) + { + o2::dataformats::VertexBase pvVtx({collision.posX(), collision.posY(), collision.posZ()}, + {collision.covXX(), collision.covXY(), collision.covYY(), + collision.covXZ(), collision.covYZ(), collision.covZZ()}); + + std::array mcPvCov = {0.}; + o2::dataformats::VertexBase mcPvVtx({0.0f, 0.0f, 0.0f}, mcPvCov); + const float eventCollisionTimePS = (simConfig.considerEventTime.value ? collision.collisionTime() * 1e3 : 0.f); // convert ns to ps + if (collision.has_mcCollision()) { + auto mcCollision = collision.mcCollision(); + mcPvVtx.setX(mcCollision.posX()); + mcPvVtx.setY(mcCollision.posY()); + mcPvVtx.setZ(mcCollision.posZ()); + } // else remains untreated for now + + // First we compute the number of charged particles in the event if LUTs are loaded + float dNdEta = 0.f; + for (const auto& track : tracks) { + if (!track.has_mcParticle()) + continue; + auto mcParticle = track.mcParticle(); + if (std::abs(mcParticle.eta()) > simConfig.multiplicityEtaRange) { + continue; + } + if (mcParticle.has_daughters()) { + continue; + } + const auto& pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + if (!pdgInfo) { + // LOG(warning) << "PDG code " << mcParticle.pdgCode() << " not found in the database"; + continue; + } + if (pdgInfo->Charge() == 0) { + continue; + } + dNdEta += 1.f; + } + if (plotsConfig.doQAplots) { + histos.fill(HIST("h1dNdeta"), dNdEta); + } + + tracksWithTime.clear(); // clear the vector of tracks with time to prepare the cache for the next event + tracksWithTime.reserve(tracks.size()); + // First loop to generate the arrival time of the particles to the TOF layers + for (const auto& track : tracks) { + // first step: find precise arrival time (if any) + // --- convert track into perfect track + if (!track.has_mcParticle()) { // should always be OK but check please + upgradeTofMC(-999.f, -999.f, -999.f, -999.f); + continue; + } else { + LOG(debug) << "Track without mcParticle found!"; + } + const auto& mcParticle = track.mcParticle(); + o2::track::TrackParCov o2track = o2::upgrade::convertMCParticleToO2Track(mcParticle, pdg); + + float xPv = -100.f; + static constexpr float kTrkXThreshold = -99.f; // Threshold to consider a good propagation of the track + if (o2track.propagateToDCA(mcPvVtx, simConfig.magneticField)) { + xPv = o2track.getX(); + } + float trackLengthInnerTOF = -1, trackLengthOuterTOF = -1; + if (xPv > kTrkXThreshold) { + trackLengthInnerTOF = computeTrackLength(o2track, simConfig.innerTOFRadius, simConfig.magneticField); + trackLengthOuterTOF = computeTrackLength(o2track, simConfig.outerTOFRadius, simConfig.magneticField); + } + + // get mass to calculate velocity + auto pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + if (pdgInfo == nullptr) { + LOG(error) << "PDG code " << mcParticle.pdgCode() << " not found in the database"; + upgradeTofMC(-999.f, -999.f, -999.f, -999.f); + continue; + } + const float v = computeParticleVelocity(o2track.getP(), pdgInfo->Mass()); + const float expectedTimeInnerTOF = trackLengthInnerTOF / v + eventCollisionTimePS; // arrival time to the Inner TOF in ps + const float expectedTimeOuterTOF = trackLengthOuterTOF / v + eventCollisionTimePS; // arrival time to the Outer TOF in ps + upgradeTofMC(expectedTimeInnerTOF, trackLengthInnerTOF, expectedTimeOuterTOF, trackLengthOuterTOF); + + // Smear with expected resolutions + const float measuredTimeInnerTOF = pRandomNumberGenerator.Gaus(expectedTimeInnerTOF, simConfig.innerTOFTimeReso); + const float measuredTimeOuterTOF = pRandomNumberGenerator.Gaus(expectedTimeOuterTOF, simConfig.outerTOFTimeReso); + + // Now we calculate the expected arrival time following certain mass hypotheses + // and the (imperfect!) reconstructed track parametrizations + float trackLengthRecoInnerTOF = -1, trackLengthRecoOuterTOF = -1; + auto recoTrack = getTrackParCov(track); + xPv = -100.f; + if (recoTrack.propagateToDCA(pvVtx, simConfig.magneticField)) { + xPv = recoTrack.getX(); + } + if (xPv > kTrkXThreshold) { + trackLengthRecoInnerTOF = computeTrackLength(recoTrack, simConfig.innerTOFRadius, simConfig.magneticField); + trackLengthRecoOuterTOF = computeTrackLength(recoTrack, simConfig.outerTOFRadius, simConfig.magneticField); + } + + // cache the track info needed for the event time calculation + // Reuse or emplace a new object in the vector + tracksWithTime.emplace_back(TracksWithTime{mcParticle.pdgCode(), + {measuredTimeInnerTOF, simConfig.innerTOFTimeReso}, + {measuredTimeOuterTOF, simConfig.outerTOFTimeReso}, + {trackLengthRecoInnerTOF, trackLengthInnerTOF}, + {trackLengthRecoOuterTOF, trackLengthOuterTOF}, + {recoTrack.getP(), recoTrack.getSigma1Pt2()}, + {recoTrack.getEta(), recoTrack.getSigmaTgl2()}, + o2track.getPt()}); + } + + // Now we compute the event time for the tracks + + std::array tzero = {0.f, 0.f}; + bool etStatus = false; + if (simConfig.considerEventTime.value) { + etStatus = eventTime(tracksWithTime, tzero); + if (!etStatus) { + LOG(debug) << "Event time calculation failed with " << tracksWithTime.size() << " tracks with time and " << dNdEta << " charged particles"; + } + } + + if (plotsConfig.doQAplots) { + histos.fill(HIST("h2dEventTime"), tzero[0], eventCollisionTimePS); + histos.fill(HIST("h1dEventTimegen"), eventCollisionTimePS); + histos.fill(HIST("h1dEventTimerec"), tzero[0]); + histos.fill(HIST("h2dEventTimeres"), dNdEta, tzero[1]); + if (etStatus) { + histos.fill(HIST("h1dEventTimedelta"), eventCollisionTimePS - tzero[0]); + } + static_cast(listEfficiency->At(0))->Fill(etStatus, dNdEta); + } + + // Then we do a second loop to compute the measured quantities with the measured event time + int trackWithTimeIndex = 0; + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { // should always be OK but check please + continue; + } + const auto& mcParticle = track.mcParticle(); + + const auto& trkWithTime = tracksWithTime[trackWithTimeIndex++]; + const float trackLengthRecoInnerTOF = trkWithTime.mTrackLengthInnerTOF.first; + const float trackLengthRecoOuterTOF = trkWithTime.mTrackLengthOuterTOF.first; + const float trackLengthInnerTOF = trkWithTime.mTrackLengthInnerTOF.second; + const float trackLengthOuterTOF = trkWithTime.mTrackLengthOuterTOF.second; + // Todo: remove the bias of the track used in the event time calculation for low multiplicity events + const float measuredTimeInnerTOF = trkWithTime.mInnerTOFTime.first - tzero[0]; + const float measuredTimeOuterTOF = trkWithTime.mOuterTOFTime.first - tzero[0]; + const float momentum = trkWithTime.mMomentum.first; + const float pseudorapidity = trkWithTime.mPseudorapidity.first; + const float noSmearingPt = trkWithTime.mNoSmearingPt; + + // Straight to Nsigma + static std::array expectedTimeInnerTOF, expectedTimeOuterTOF; + static std::array deltaTimeInnerTOF, deltaTimeOuterTOF; + static std::array nSigmaInnerTOF, nSigmaOuterTOF; + static constexpr int kParticlePdgs[kParticles] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; + float masses[kParticles]; + + if (plotsConfig.doQAplots) { + // unit conversion: length in cm, time in ps + const float innerBeta = (trackLengthInnerTOF / measuredTimeInnerTOF) / o2::constants::physics::LightSpeedCm2PS; + const float outerBeta = (trackLengthOuterTOF / measuredTimeOuterTOF) / o2::constants::physics::LightSpeedCm2PS; + if (trackLengthRecoInnerTOF > 0) { + histos.fill(HIST("iTOF/h2dVelocityVsMomentumInner"), momentum, innerBeta); + histos.fill(HIST("iTOF/h2dTrackLengthInnerVsPt"), noSmearingPt, trackLengthInnerTOF); + histos.fill(HIST("iTOF/h2dTrackLengthInnerRecoVsPt"), noSmearingPt, trackLengthRecoInnerTOF); + } + if (trackLengthRecoOuterTOF > 0) { + histos.fill(HIST("oTOF/h2dVelocityVsMomentumOuter"), momentum, outerBeta); + histos.fill(HIST("oTOF/h2dTrackLengthOuterVsPt"), noSmearingPt, trackLengthOuterTOF); + histos.fill(HIST("oTOF/h2dTrackLengthOuterRecoVsPt"), noSmearingPt, trackLengthRecoOuterTOF); + } + } + + for (int ii = 0; ii < kParticles; ii++) { + expectedTimeInnerTOF[ii] = -100; + expectedTimeOuterTOF[ii] = -100; + deltaTimeInnerTOF[ii] = -100; + deltaTimeOuterTOF[ii] = -100; + nSigmaInnerTOF[ii] = -100; + nSigmaOuterTOF[ii] = -100; + + auto pdgInfoThis = pdg->GetParticle(kParticlePdgs[ii]); + masses[ii] = pdgInfoThis->Mass(); + const float v = computeParticleVelocity(momentum, masses[ii]); + + expectedTimeInnerTOF[ii] = trackLengthInnerTOF / v; + expectedTimeOuterTOF[ii] = trackLengthOuterTOF / v; + + deltaTimeInnerTOF[ii] = measuredTimeInnerTOF - expectedTimeInnerTOF[ii]; + deltaTimeOuterTOF[ii] = measuredTimeOuterTOF - expectedTimeOuterTOF[ii]; + + // Evaluate total sigma (layer + tracking resolution) + float innerTotalTimeReso = simConfig.innerTOFTimeReso; + float outerTotalTimeReso = simConfig.outerTOFTimeReso; + if (simConfig.flagIncludeTrackTimeRes) { + double ptResolution = std::pow(momentum / std::cosh(pseudorapidity), 2) * std::sqrt(trkWithTime.mMomentum.second); + double etaResolution = std::fabs(std::sin(2.0 * std::atan(std::exp(-pseudorapidity)))) * std::sqrt(trkWithTime.mPseudorapidity.second); + if (simConfig.flagTOFLoadDelphesLUTs) { + ptResolution = mSmearer.getAbsPtRes(pdgInfoThis->PdgCode(), dNdEta, pseudorapidity, momentum / std::cosh(pseudorapidity)); + etaResolution = mSmearer.getAbsEtaRes(pdgInfoThis->PdgCode(), dNdEta, pseudorapidity, momentum / std::cosh(pseudorapidity)); + } + float innerTrackTimeReso = calculateTrackTimeResolutionAdvanced(momentum / std::cosh(pseudorapidity), pseudorapidity, ptResolution, etaResolution, masses[ii], simConfig.innerTOFRadius, simConfig.magneticField); + float outerTrackTimeReso = calculateTrackTimeResolutionAdvanced(momentum / std::cosh(pseudorapidity), pseudorapidity, ptResolution, etaResolution, masses[ii], simConfig.outerTOFRadius, simConfig.magneticField); + innerTotalTimeReso = std::hypot(simConfig.innerTOFTimeReso, innerTrackTimeReso); + outerTotalTimeReso = std::hypot(simConfig.outerTOFTimeReso, outerTrackTimeReso); + + if (plotsConfig.doQAplots) { + if (std::fabs(mcParticle.pdgCode()) == pdg->GetParticle(kParticlePdgs[ii])->PdgCode()) { + if (trackLengthRecoInnerTOF > 0) { + h2dInnerTimeResTrack[ii]->Fill(momentum, innerTrackTimeReso); + h2dInnerTimeResTotal[ii]->Fill(momentum, innerTotalTimeReso); + } + if (trackLengthRecoOuterTOF > 0) { + const float transverseMomentum = momentum / std::cosh(pseudorapidity); + h2dOuterTimeResTrack[ii]->Fill(momentum, outerTrackTimeReso); + h2dOuterTimeResTotal[ii]->Fill(momentum, outerTotalTimeReso); + static constexpr int kIdPion = 2; + if (ii == kIdPion) { + histos.fill(HIST("h2dRelativePtResolution"), transverseMomentum, 100.0 * ptResolution / transverseMomentum); + histos.fill(HIST("h2dRelativeEtaResolution"), pseudorapidity, 100.0 * etaResolution / (std::fabs(pseudorapidity) + 1e-6)); + } + } + } + } + } + + // Fixme: assumes dominant resolution effect is the TOF resolution + // and not the tracking itself. It's *probably* a fair assumption + // but it should be tested further! --> FIXED IN THIS VERSION + if (trackLengthInnerTOF > 0 && trackLengthRecoInnerTOF > 0) + nSigmaInnerTOF[ii] = deltaTimeInnerTOF[ii] / std::sqrt(innerTotalTimeReso * innerTotalTimeReso + tzero[1] * tzero[1]); + if (trackLengthOuterTOF > 0 && trackLengthRecoOuterTOF > 0) + nSigmaOuterTOF[ii] = deltaTimeOuterTOF[ii] / std::sqrt(outerTotalTimeReso * outerTotalTimeReso + tzero[1] * tzero[1]); + } + + if (plotsConfig.doQAplots) { + for (int ii = 0; ii < kParticles; ii++) { + if (std::fabs(mcParticle.pdgCode()) != pdg->GetParticle(kParticlePdgs[ii])->PdgCode()) { + continue; + } + if (trackLengthRecoInnerTOF > 0) { + for (int iii = 0; iii < kParticles; iii++) { + h2dInnerNsigmaTrue[ii][iii]->Fill(momentum, nSigmaInnerTOF[iii]); + h2dInnerDeltaTrue[ii][iii]->Fill(momentum, deltaTimeInnerTOF[iii]); + } + } + if (trackLengthRecoOuterTOF > 0) { + for (int iii = 0; iii < kParticles; iii++) { + h2dOuterNsigmaTrue[ii][iii]->Fill(momentum, nSigmaOuterTOF[iii]); + h2dOuterDeltaTrue[ii][iii]->Fill(momentum, deltaTimeOuterTOF[iii]); + } + } + } + } + + const float deltaTrackLengthInnerTOF = std::abs(trackLengthInnerTOF - trackLengthRecoInnerTOF); + if (trackLengthInnerTOF > 0 && trackLengthRecoInnerTOF > 0) { + histos.fill(HIST("iTOF/h2dDeltaTrackLengthInnerVsPt"), noSmearingPt, deltaTrackLengthInnerTOF); + } + const float deltaTrackLengthOuterTOF = std::abs(trackLengthOuterTOF - trackLengthRecoOuterTOF); + if (trackLengthOuterTOF > 0 && trackLengthRecoOuterTOF > 0) { + histos.fill(HIST("oTOF/h2dDeltaTrackLengthOuterVsPt"), noSmearingPt, deltaTrackLengthOuterTOF); + } + + // Sigmas have been fully calculated. Please populate the NSigma helper table (once per track) + upgradeTof(tzero[0], tzero[1], + nSigmaInnerTOF[0], nSigmaInnerTOF[1], nSigmaInnerTOF[2], nSigmaInnerTOF[3], nSigmaInnerTOF[4], + measuredTimeInnerTOF, trackLengthRecoInnerTOF, + nSigmaOuterTOF[0], nSigmaOuterTOF[1], nSigmaOuterTOF[2], nSigmaOuterTOF[3], nSigmaOuterTOF[4], + measuredTimeOuterTOF, trackLengthRecoOuterTOF); + upgradeTofExpectedTime(expectedTimeInnerTOF[0], expectedTimeInnerTOF[1], expectedTimeInnerTOF[2], expectedTimeInnerTOF[3], expectedTimeInnerTOF[4], + expectedTimeOuterTOF[0], expectedTimeOuterTOF[1], expectedTimeOuterTOF[2], expectedTimeOuterTOF[3], expectedTimeOuterTOF[4]); + } + + if (trackWithTimeIndex != tracks.size()) { + LOG(fatal) << "Track with time index " << trackWithTimeIndex << " does not match the number of tracks " << tracks.size(); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx index 1bff52b73da..c858f5a753e 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx @@ -23,43 +23,42 @@ /// \author Roberto Preghenella preghenella@bo.infn.it /// -#include -#include - -#include -#include -#include -#include +#include "ALICE3/Core/DelphesO2TrackSmearer.h" +#include "ALICE3/Core/DetLayer.h" +#include "ALICE3/Core/FastTracker.h" +#include "ALICE3/Core/TrackUtilities.h" +#include "ALICE3/DataModel/OTFStrangeness.h" +#include "ALICE3/DataModel/collisionAlice3.h" +#include "ALICE3/DataModel/tracksAlice3.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "CommonConstants/MathConstants.h" +#include "DCAFitter/DCAFitterN.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsVertexing/PVertexer.h" +#include "DetectorsVertexing/PVertexerHelpers.h" +#include "Field/MagneticField.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" -#include -#include "DCAFitter/DCAFitterN.h" -#include "Common/Core/RecoDecay.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/DCA.h" -#include "DetectorsBase/Propagator.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DetectorsVertexing/PVertexer.h" -#include "DetectorsVertexing/PVertexerHelpers.h" #include "SimulationDataFormat/InteractionSampler.h" -#include "Field/MagneticField.h" -#include "ITSMFTSimulation/Hit.h" -#include "ITStracking/Configuration.h" -#include "ITStracking/IOUtils.h" -#include "ITStracking/Tracker.h" -#include "ITStracking/Vertexer.h" -#include "ITStracking/VertexerTraits.h" +#include +#include +#include +#include +#include -#include "ALICE3/Core/DelphesO2TrackSmearer.h" -#include "ALICE3/Core/FastTracker.h" -#include "ALICE3/DataModel/collisionAlice3.h" -#include "ALICE3/DataModel/tracksAlice3.h" -#include "ALICE3/DataModel/OTFStrangeness.h" +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -96,20 +95,15 @@ struct OnTheFlyTracker { Configurable enableNucleiSmearing{"enableNucleiSmearing", false, "Enable smearing of nuclei"}; Configurable enablePrimaryVertexing{"enablePrimaryVertexing", true, "Enable primary vertexing"}; Configurable interpolateLutEfficiencyVsNch{"interpolateLutEfficiencyVsNch", true, "interpolate LUT efficiency as f(Nch)"}; - Configurable treatXi{"treatXi", false, "Manually decay Xi and fill tables with daughters"}; - Configurable findXi{"findXi", false, "if treatXi on, find Xi and fill Tracks table also with Xi"}; - Configurable trackXi{"trackXi", false, "if findXi on, attempt to track Xi"}; - Configurable pixelResolution{"pixelResolution", 2.5e-4, "pixel resolution in centimeters (for OTF strangeness tracking)"}; Configurable populateTracksDCA{"populateTracksDCA", true, "populate TracksDCA table"}; Configurable populateTracksDCACov{"populateTracksDCACov", false, "populate TracksDCACov table"}; - Configurable populateTracksExtra{"populateTracksExtra", false, "populate TracksExtra table (legacy)"}; + Configurable populateTracksExtra{"populateTracksExtra", false, "populate TrackExtra table (legacy)"}; Configurable populateTrackSelection{"populateTrackSelection", false, "populate TrackSelection table (legacy)"}; Configurable processUnreconstructedTracks{"processUnreconstructedTracks", false, "process (smear) unreco-ed tracks"}; Configurable doExtraQA{"doExtraQA", false, "do extra 2D QA plots"}; Configurable extraQAwithoutDecayDaughters{"extraQAwithoutDecayDaughters", false, "remove decay daughters from qa plots (yes/no)"}; - Configurable doXiQA{"doXiQA", false, "QA plots for when treating Xi"}; Configurable lutEl{"lutEl", "lutCovm.el.dat", "LUT for electrons"}; Configurable lutMu{"lutMu", "lutCovm.mu.dat", "LUT for muons"}; @@ -141,13 +135,25 @@ struct OnTheFlyTracker { // for topo var QA struct : ConfigurableGroup { std::string prefix = "fastTrackerSettings"; // JSON group name - Configurable minSiliconHits{"minSiliconHits", 4, "minimum number of silicon hits to accept track"}; + Configurable minSiliconHits{"minSiliconHits", 6, "minimum number of silicon hits to accept track"}; Configurable minSiliconHitsIfTPCUsed{"minSiliconHitsIfTPCUsed", 2, "minimum number of silicon hits to accept track in case TPC info is present"}; Configurable minTPCClusters{"minTPCClusters", 70, "minimum number of TPC hits necessary to consider minSiliconHitsIfTPCUsed"}; Configurable alice3detector{"alice3detector", 0, "0: ALICE 3 v1, 1: ALICE 3 v4"}; Configurable applyZacceptance{"applyZacceptance", false, "apply z limits to detector layers or not"}; + Configurable applyMSCorrection{"applyMSCorrection", true, "apply ms corrections for secondaries or not"}; + Configurable applyElossCorrection{"applyElossCorrection", true, "apply eloss corrections for secondaries or not"}; + Configurable applyEffCorrection{"applyEffCorrection", true, "apply efficiency correction or not"}; + Configurable> pixelRes{"pixelRes", {0.00025, 0.00025, 0.001, 0.001}, "RPhiIT, ZIT, RPhiOT, ZOT"}; } fastTrackerSettings; // allows for gap between peak and bg in case someone wants to + struct : ConfigurableGroup { + std::string prefix = "cascadeDecaySettings"; // Cascade decay settings + Configurable decayXi{"decayXi", false, "Manually decay Xi and fill tables with daughters"}; + Configurable findXi{"findXi", false, "if decayXi on, find Xi and fill Tracks table also with Xi"}; + Configurable trackXi{"trackXi", false, "if findXi on, attempt to track Xi"}; + Configurable doXiQA{"doXiQA", false, "QA plots for when treating Xi"}; + } cascadeDecaySettings; + using PVertex = o2::dataformats::PrimaryVertex; // for secondary vertex finding @@ -223,14 +229,6 @@ struct OnTheFlyTracker { // Track smearer o2::delphes::DelphesO2TrackSmearer mSmearer; - // Xi daughters uses different smearers - o2::delphes::DelphesO2TrackSmearer mSmearer0; - o2::delphes::DelphesO2TrackSmearer mSmearer1; - o2::delphes::DelphesO2TrackSmearer mSmearer2; - o2::delphes::DelphesO2TrackSmearer mSmearer3; - o2::delphes::DelphesO2TrackSmearer mSmearer4; - o2::delphes::DelphesO2TrackSmearer mSmearer5; - // For processing and vertexing std::vector tracksAlice3; std::vector ghostTracksAlice3; @@ -272,7 +270,7 @@ struct OnTheFlyTracker { mapPdgLut.insert(std::make_pair(1000010030, lutTrChar)); mapPdgLut.insert(std::make_pair(1000020030, lutHe3Char)); } - for (auto e : mapPdgLut) { + for (const auto& e : mapPdgLut) { if (!mSmearer.loadTable(e.first, e.second)) { LOG(fatal) << "Having issue with loading the LUT " << e.first << " " << e.second; } @@ -320,24 +318,25 @@ struct OnTheFlyTracker { histos.add("h2dVerticesVsContributors", "h2dVerticesVsContributors", kTH2F, {axes.axisMultiplicity, axes.axisNVertices}); histos.add("hRecoVsSimMultiplicity", "hRecoVsSimMultiplicity", kTH2F, {axes.axisMultiplicity, axes.axisMultiplicity}); histos.add("h2dDCAxy", "h2dDCAxy", kTH2F, {axes.axisMomentum, axes.axisDCA}); + histos.add("h2dDCAz", "h2dDCAz", kTH2F, {axes.axisMomentum, axes.axisDCA}); histos.add("hSimTrackX", "hSimTrackX", kTH1F, {axes.axisX}); histos.add("hRecoTrackX", "hRecoTrackX", kTH1F, {axes.axisX}); histos.add("hTrackXatDCA", "hTrackXatDCA", kTH1F, {axes.axisX}); } - if (doXiQA) { + if (cascadeDecaySettings.doXiQA) { histos.add("hXiBuilding", "hXiBuilding", kTH1F, {{10, -0.5f, 9.5f}}); histos.add("hGenXi", "hGenXi", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); histos.add("hRecoXi", "hRecoXi", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); histos.add("hGenPiFromXi", "hGenPiFromXi", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); - histos.add("hGenPiFromL0", "hGenPiFromL0", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); - histos.add("hGenPrFromL0", "hGenPrFromL0", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); + histos.add("hGenPiFromLa", "hGenPiFromLa", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); + histos.add("hGenPrFromLa", "hGenPrFromLa", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); histos.add("hRecoPiFromXi", "hRecoPiFromXi", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); - histos.add("hRecoPiFromL0", "hRecoPiFromL0", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); - histos.add("hRecoPrFromL0", "hRecoPrFromL0", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); + histos.add("hRecoPiFromLa", "hRecoPiFromLa", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); + histos.add("hRecoPrFromLa", "hRecoPrFromLa", kTH2F, {axes.axisDecayRadius, axes.axisMomentum}); // basic mass histograms to see if we're in business histos.add("hMassLambda", "hMassLambda", kTH1F, {axes.axisLambdaMass}); @@ -351,10 +350,24 @@ struct OnTheFlyTracker { histos.add("h2dDCAxyCascadeNegative", "h2dDCAxyCascadeNegative", kTH2F, {axes.axisMomentum, axes.axisDCA}); histos.add("h2dDCAxyCascadePositive", "h2dDCAxyCascadePositive", kTH2F, {axes.axisMomentum, axes.axisDCA}); + histos.add("h2dDCAzCascade", "h2dDCAzCascade", kTH2F, {axes.axisMomentum, axes.axisDCA}); + histos.add("h2dDCAzCascadeBachelor", "h2dDCAzCascadeBachelor", kTH2F, {axes.axisMomentum, axes.axisDCA}); + histos.add("h2dDCAzCascadeNegative", "h2dDCAzCascadeNegative", kTH2F, {axes.axisMomentum, axes.axisDCA}); + histos.add("h2dDCAzCascadePositive", "h2dDCAzCascadePositive", kTH2F, {axes.axisMomentum, axes.axisDCA}); + histos.add("h2dDeltaPtVsPt", "h2dDeltaPtVsPt", kTH2F, {axes.axisMomentum, axes.axisDeltaPt}); histos.add("h2dDeltaEtaVsPt", "h2dDeltaEtaVsPt", kTH2F, {axes.axisMomentum, axes.axisDeltaEta}); histos.add("hFastTrackerHits", "hFastTrackerHits", kTH2F, {axes.axisZ, axes.axisRadius}); + auto hFastTrackerQA = histos.add("hFastTrackerQA", "hFastTrackerQA", kTH1D, {{8, -0.5f, 7.5f}}); + hFastTrackerQA->GetXaxis()->SetBinLabel(1, "Negative eigenvalue"); + hFastTrackerQA->GetXaxis()->SetBinLabel(2, "Failed sanity check"); + hFastTrackerQA->GetXaxis()->SetBinLabel(3, "intercept original radius"); + hFastTrackerQA->GetXaxis()->SetBinLabel(4, "propagate to original radius"); + hFastTrackerQA->GetXaxis()->SetBinLabel(5, "problematic layer"); + hFastTrackerQA->GetXaxis()->SetBinLabel(6, "multiple scattering"); + hFastTrackerQA->GetXaxis()->SetBinLabel(7, "energy loss"); + hFastTrackerQA->GetXaxis()->SetBinLabel(8, "efficiency"); } LOGF(info, "Initializing magnetic field to value: %.3f kG", static_cast(magneticField)); @@ -404,14 +417,16 @@ struct OnTheFlyTracker { rand.SetSeed(seed); // configure FastTracker - fastTracker.magneticField = magneticField; - fastTracker.applyZacceptance = fastTrackerSettings.applyZacceptance; + fastTracker.SetMagneticField(magneticField); + fastTracker.SetApplyZacceptance(fastTrackerSettings.applyZacceptance); + fastTracker.SetApplyMSCorrection(fastTrackerSettings.applyMSCorrection); + fastTracker.SetApplyElossCorrection(fastTrackerSettings.applyElossCorrection); if (fastTrackerSettings.alice3detector == 0) { - fastTracker.AddSiliconALICE3v1(); + fastTracker.AddSiliconALICE3v2(fastTrackerSettings.pixelRes); } if (fastTrackerSettings.alice3detector == 1) { - fastTracker.AddSiliconALICE3v4(); + fastTracker.AddSiliconALICE3v4(fastTrackerSettings.pixelRes); fastTracker.AddTPC(0.1, 0.1); } @@ -424,12 +439,18 @@ struct OnTheFlyTracker { /// \param track track of particle to decay /// \param decayDaughters the address of resulting daughters /// \param xiDecayVertex the address of the xi decay vertex - /// \param l0DecayVertex the address of the l0 decay vertex + /// \param laDecayVertex the address of the la decay vertex template - void decayParticle(McParticleType particle, o2::track::TrackParCov track, std::vector& decayDaughters, std::vector& xiDecayVertex, std::vector& l0DecayVertex) + void decayParticle(McParticleType particle, o2::track::TrackParCov track, std::vector& decayDaughters, std::vector& xiDecayVertex, std::vector& laDecayVertex) { double u = rand.Uniform(0, 1); - double xi_ctau = 4.91; // xi + double xi_mass = o2::constants::physics::MassXiMinus; + double la_mass = o2::constants::physics::MassLambda; + double pi_mass = o2::constants::physics::MassPionCharged; + double pr_mass = o2::constants::physics::MassProton; + + double xi_gamma = 1 / sqrt(1 + (particle.p() * particle.p()) / (xi_mass * xi_mass)); + double xi_ctau = 4.91 * xi_gamma; double xi_rxyz = (-xi_ctau * log(1 - u)); float sna, csa; o2::math_utils::CircleXYf_t xi_circle; @@ -444,79 +465,27 @@ struct OnTheFlyTracker { xiDecayVertex.push_back(newY); xiDecayVertex.push_back(particle.vz() + xi_rxyz * (particle.pz() / particle.p())); - std::vector xiDaughters = {1.115, 0.139570}; + std::vector xiDaughters = {la_mass, pi_mass}; TLorentzVector xi(newPx, newPy, particle.pz(), particle.e()); TGenPhaseSpace xiDecay; xiDecay.SetDecay(xi, 2, xiDaughters.data()); xiDecay.Generate(); decayDaughters.push_back(*xiDecay.GetDecay(1)); - - double l0_ctau = 7.89; // lambda - std::vector l0Daughters = {0.139570, 0.938272}; - double l0_rxyz = (-l0_ctau * log(1 - u)); - l0DecayVertex.push_back(xiDecayVertex[0] + l0_rxyz * (xiDecay.GetDecay(0)->Px() / xiDecay.GetDecay(0)->P())); - l0DecayVertex.push_back(xiDecayVertex[1] + l0_rxyz * (xiDecay.GetDecay(0)->Py() / xiDecay.GetDecay(0)->P())); - l0DecayVertex.push_back(xiDecayVertex[2] + l0_rxyz * (xiDecay.GetDecay(0)->Pz() / xiDecay.GetDecay(0)->P())); - - TLorentzVector l0 = *xiDecay.GetDecay(0); - TGenPhaseSpace l0Decay; - l0Decay.SetDecay(l0, 2, l0Daughters.data()); - l0Decay.Generate(); - decayDaughters.push_back(*l0Decay.GetDecay(0)); - decayDaughters.push_back(*l0Decay.GetDecay(1)); - } - - /// Function to convert a TLorentzVector into a perfect Track - /// \param pdgCode particle pdg - /// \param particle the particle to convert (TLorentzVector) - /// \param productionVertex where the particle was produced - /// \param o2track the address of the resulting TrackParCov - void convertTLorentzVectorToO2Track(int pdgCode, TLorentzVector particle, std::vector productionVertex, o2::track::TrackParCov& o2track) - { - auto pdgInfo = pdgDB->GetParticle(pdgCode); - int charge = 0; - if (pdgInfo != nullptr) { - charge = pdgInfo->Charge() / 3; - } - std::array params; - std::array covm = {0.}; - float s, c, x; - o2::math_utils::sincos(static_cast(particle.Phi()), s, c); - o2::math_utils::rotateZInv(static_cast(productionVertex[0]), static_cast(productionVertex[1]), x, params[0], s, c); - params[1] = static_cast(productionVertex[2]); - params[2] = 0; - auto theta = 2. * std::atan(std::exp(-particle.PseudoRapidity())); - params[3] = 1. / std::tan(theta); - params[4] = charge / particle.Pt(); - - // Initialize TrackParCov in-place - new (&o2track)(o2::track::TrackParCov)(x, particle.Phi(), params, covm); - } - - /// Function to convert a McParticle into a perfect Track - /// \param particle the particle to convert (mcParticle) - /// \param o2track the address of the resulting TrackParCov - template - void convertMCParticleToO2Track(McParticleType& particle, o2::track::TrackParCov& o2track) - { - auto pdgInfo = pdgDB->GetParticle(particle.pdgCode()); - int charge = 0; - if (pdgInfo != nullptr) { - charge = pdgInfo->Charge() / 3; - } - std::array params; - std::array covm = {0.}; - float s, c, x; - o2::math_utils::sincos(particle.phi(), s, c); - o2::math_utils::rotateZInv(particle.vx(), particle.vy(), x, params[0], s, c); - params[1] = particle.vz(); - params[2] = 0.; // since alpha = phi - auto theta = 2. * std::atan(std::exp(-particle.eta())); - params[3] = 1. / std::tan(theta); - params[4] = charge / particle.pt(); - - // Initialize TrackParCov in-place - new (&o2track)(o2::track::TrackParCov)(x, particle.phi(), params, covm); + TLorentzVector la = *xiDecay.GetDecay(0); + + double la_gamma = 1 / sqrt(1 + (la.P() * la.P()) / (la_mass * la_mass)); + double la_ctau = 7.89 * la_gamma; + std::vector laDaughters = {pi_mass, pr_mass}; + double la_rxyz = (-la_ctau * log(1 - u)); + laDecayVertex.push_back(xiDecayVertex[0] + la_rxyz * (xiDecay.GetDecay(0)->Px() / xiDecay.GetDecay(0)->P())); + laDecayVertex.push_back(xiDecayVertex[1] + la_rxyz * (xiDecay.GetDecay(0)->Py() / xiDecay.GetDecay(0)->P())); + laDecayVertex.push_back(xiDecayVertex[2] + la_rxyz * (xiDecay.GetDecay(0)->Pz() / xiDecay.GetDecay(0)->P())); + + TGenPhaseSpace laDecay; + laDecay.SetDecay(la, 2, laDaughters.data()); + laDecay.Generate(); + decayDaughters.push_back(*laDecay.GetDecay(0)); + decayDaughters.push_back(*laDecay.GetDecay(1)); } float dNdEta = 0.f; // Charged particle multiplicity to use in the efficiency evaluation @@ -534,6 +503,7 @@ struct OnTheFlyTracker { // generate collision time auto ir = irSampler.generateCollisionTime(); + const float eventCollisionTime = ir.timeInBCNS; // First we compute the number of charged particles in the event dNdEta = 0.f; @@ -546,7 +516,7 @@ struct OnTheFlyTracker { } const auto pdg = std::abs(mcParticle.pdgCode()); if (pdg != kElectron && pdg != kMuonMinus && pdg != kPiPlus && pdg != kKPlus && pdg != kProton) { - if (!treatXi) { + if (!cascadeDecaySettings.decayXi) { continue; } else if (pdg != 3312) { continue; @@ -570,30 +540,30 @@ struct OnTheFlyTracker { for (const auto& mcParticle : mcParticles) { double xiDecayRadius2D = 0; - double l0DecayRadius2D = 0; + double laDecayRadius2D = 0; std::vector decayProducts; - std::vector xiDecayVertex, l0DecayVertex; + std::vector xiDecayVertex, laDecayVertex; std::vector layers = {0.50, 1.20, 2.50, 3.75, 7.00, 12.0, 20.0}; - if (treatXi) { + if (cascadeDecaySettings.decayXi) { if (mcParticle.pdgCode() == 3312) { o2::track::TrackParCov xiTrackParCov; - convertMCParticleToO2Track(mcParticle, xiTrackParCov); - decayParticle(mcParticle, xiTrackParCov, decayProducts, xiDecayVertex, l0DecayVertex); + o2::upgrade::convertMCParticleToO2Track(mcParticle, xiTrackParCov, pdgDB); + decayParticle(mcParticle, xiTrackParCov, decayProducts, xiDecayVertex, laDecayVertex); xiDecayRadius2D = sqrt(xiDecayVertex[0] * xiDecayVertex[0] + xiDecayVertex[1] * xiDecayVertex[1]); - l0DecayRadius2D = sqrt(l0DecayVertex[0] * l0DecayVertex[0] + l0DecayVertex[1] * l0DecayVertex[1]); + laDecayRadius2D = sqrt(laDecayVertex[0] * laDecayVertex[0] + laDecayVertex[1] * laDecayVertex[1]); } } const auto pdg = std::abs(mcParticle.pdgCode()); if (!mcParticle.isPhysicalPrimary()) { - if (!treatXi) { + if (!cascadeDecaySettings.decayXi) { continue; } else if (pdg != 3312) { continue; } } if (pdg != kElectron && pdg != kMuonMinus && pdg != kPiPlus && pdg != kKPlus && pdg != kProton) { - if (!treatXi) { + if (!cascadeDecaySettings.decayXi) { continue; } else if (pdg != 3312) { continue; @@ -613,11 +583,11 @@ struct OnTheFlyTracker { if (TMath::Abs(mcParticle.pdgCode()) == 2212) histos.fill(HIST("hPtGeneratedPr"), mcParticle.pt()); - if (doXiQA && mcParticle.pdgCode() == 3312) { + if (cascadeDecaySettings.doXiQA && mcParticle.pdgCode() == 3312) { histos.fill(HIST("hGenXi"), xiDecayRadius2D, mcParticle.pt()); histos.fill(HIST("hGenPiFromXi"), xiDecayRadius2D, decayProducts[0].Pt()); - histos.fill(HIST("hGenPiFromL0"), l0DecayRadius2D, decayProducts[1].Pt()); - histos.fill(HIST("hGenPrFromL0"), l0DecayRadius2D, decayProducts[2].Pt()); + histos.fill(HIST("hGenPiFromLa"), laDecayRadius2D, decayProducts[1].Pt()); + histos.fill(HIST("hGenPrFromLa"), laDecayRadius2D, decayProducts[2].Pt()); } if (mcParticle.pt() < minPt) { @@ -625,30 +595,30 @@ struct OnTheFlyTracker { } o2::track::TrackParCov trackParCov; - convertMCParticleToO2Track(mcParticle, trackParCov); + o2::upgrade::convertMCParticleToO2Track(mcParticle, trackParCov, pdgDB); bool isDecayDaughter = false; if (mcParticle.getProcess() == 4) isDecayDaughter = true; multiplicityCounter++; - const float t = (ir.timeInBCNS + gRandom->Gaus(0., 100.)) * 1e-3; + const float t = (eventCollisionTime + gRandom->Gaus(0., 100.)) * 1e-3; std::vector xiDaughterTrackParCovsPerfect(3); std::vector xiDaughterTrackParCovsTracked(3); std::vector isReco(3); std::vector nHits(3); // total std::vector nSiliconHits(3); // silicon type std::vector nTPCHits(3); // TPC type - std::vector smearer = {mSmearer0, mSmearer1, mSmearer2, mSmearer3, mSmearer4, mSmearer5}; - if (treatXi && mcParticle.pdgCode() == 3312) { - histos.fill(HIST("hXiBuilding"), 0.0f); + if (cascadeDecaySettings.decayXi && mcParticle.pdgCode() == 3312) { + if (cascadeDecaySettings.doXiQA) + histos.fill(HIST("hXiBuilding"), 0.0f); if (xiDecayRadius2D > 20) { continue; } - convertTLorentzVectorToO2Track(-211, decayProducts[0], xiDecayVertex, xiDaughterTrackParCovsPerfect[0]); - convertTLorentzVectorToO2Track(-211, decayProducts[1], l0DecayVertex, xiDaughterTrackParCovsPerfect[1]); - convertTLorentzVectorToO2Track(2212, decayProducts[2], l0DecayVertex, xiDaughterTrackParCovsPerfect[2]); + o2::upgrade::convertTLorentzVectorToO2Track(-211, decayProducts[0], xiDecayVertex, xiDaughterTrackParCovsPerfect[0], pdgDB); + o2::upgrade::convertTLorentzVectorToO2Track(-211, decayProducts[1], laDecayVertex, xiDaughterTrackParCovsPerfect[1], pdgDB); + o2::upgrade::convertTLorentzVectorToO2Track(2212, decayProducts[2], laDecayVertex, xiDaughterTrackParCovsPerfect[2], pdgDB); for (int i = 0; i < 3; i++) { isReco[i] = false; @@ -656,18 +626,21 @@ struct OnTheFlyTracker { nSiliconHits[i] = 0; nTPCHits[i] = 0; if (enableSecondarySmearing) { + nHits[i] = fastTracker.FastTrack(xiDaughterTrackParCovsPerfect[i], xiDaughterTrackParCovsTracked[i], dNdEta); + nSiliconHits[i] = fastTracker.GetNSiliconPoints(); + nTPCHits[i] = fastTracker.GetNGasPoints(); - nHits[i] = fastTracker.FastTrack(xiDaughterTrackParCovsPerfect[i], xiDaughterTrackParCovsTracked[i]); - nSiliconHits[i] = fastTracker.nSiliconPoints; - nTPCHits[i] = fastTracker.nGasPoints; + if (nHits[i] < 0) { // QA + histos.fill(HIST("hFastTrackerQA"), o2::math_utils::abs(nHits[i])); + } if (nSiliconHits[i] >= fastTrackerSettings.minSiliconHits || (nSiliconHits[i] >= fastTrackerSettings.minSiliconHitsIfTPCUsed && nTPCHits[i] >= fastTrackerSettings.minTPCClusters)) { isReco[i] = true; } else { continue; // extra sure } - for (uint32_t ih = 0; ih < fastTracker.hits.size(); ih++) { - histos.fill(HIST("hFastTrackerHits"), fastTracker.hits[ih][2], std::hypot(fastTracker.hits[ih][0], fastTracker.hits[ih][1])); + for (uint32_t ih = 0; ih < fastTracker.GetNHits(); ih++) { + histos.fill(HIST("hFastTrackerHits"), fastTracker.GetHitZ(ih), std::hypot(fastTracker.GetHitX(ih), fastTracker.GetHitY(ih))); } } else { isReco[i] = true; @@ -686,7 +659,7 @@ struct OnTheFlyTracker { } } - if (doXiQA && mcParticle.pdgCode() == 3312) { + if (cascadeDecaySettings.doXiQA && mcParticle.pdgCode() == 3312) { if (isReco[0] && isReco[1] && isReco[2]) { histos.fill(HIST("hXiBuilding"), 2.0f); histos.fill(HIST("hRecoXi"), xiDecayRadius2D, mcParticle.pt()); @@ -694,16 +667,17 @@ struct OnTheFlyTracker { if (isReco[0]) histos.fill(HIST("hRecoPiFromXi"), xiDecayRadius2D, decayProducts[0].Pt()); if (isReco[1]) - histos.fill(HIST("hRecoPiFromL0"), l0DecayRadius2D, decayProducts[1].Pt()); + histos.fill(HIST("hRecoPiFromLa"), laDecayRadius2D, decayProducts[1].Pt()); if (isReco[2]) - histos.fill(HIST("hRecoPrFromL0"), l0DecayRadius2D, decayProducts[2].Pt()); + histos.fill(HIST("hRecoPrFromLa"), laDecayRadius2D, decayProducts[2].Pt()); } // +-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+ // combine particles into actual Xi candidate // cascade building starts here - if (findXi && mcParticle.pdgCode() == 3312 && isReco[0] && isReco[1] && isReco[2]) { - histos.fill(HIST("hXiBuilding"), 3.0f); + if (cascadeDecaySettings.findXi && mcParticle.pdgCode() == 3312 && isReco[0] && isReco[1] && isReco[2]) { + if (cascadeDecaySettings.doXiQA) + histos.fill(HIST("hXiBuilding"), 3.0f); // assign indices of the particles we've used // they should be the last ones to be filled, in order: // n-1: proton from lambda @@ -727,7 +701,8 @@ struct OnTheFlyTracker { } // V0 found successfully if (dcaFitterOK_V0) { - histos.fill(HIST("hXiBuilding"), 4.0f); + if (cascadeDecaySettings.doXiQA) + histos.fill(HIST("hXiBuilding"), 4.0f); std::array pos; std::array posCascade; std::array posP; @@ -780,7 +755,8 @@ struct OnTheFlyTracker { // Cascade found successfully if (dcaFitterOK_Cascade) { - histos.fill(HIST("hXiBuilding"), 5.0f); + if (cascadeDecaySettings.doXiQA) + histos.fill(HIST("hXiBuilding"), 5.0f); o2::track::TrackParCov bachelorTrackAtPCA = fitter.getTrack(1); const auto& vtxCascade = fitter.getPCACandidate(); @@ -804,7 +780,7 @@ struct OnTheFlyTracker { thisCascade.findableClusters = 0; thisCascade.foundClusters = 0; - if (trackXi) { + if (cascadeDecaySettings.trackXi) { // optionally, add the points in the layers before the decay of the Xi // will back-track the perfect MC cascade to relevant layers, find hit, smear and add to smeared cascade for (int i = layers.size() - 1; i >= 0; i--) { @@ -826,15 +802,19 @@ struct OnTheFlyTracker { std::array posClusterCandidate; trackParCov.getXYZGlo(posClusterCandidate); float r{std::hypot(posClusterCandidate[0], posClusterCandidate[1])}; - float phi{std::atan2(-posClusterCandidate[1], -posClusterCandidate[0]) + o2::its::constants::math::Pi}; + float phi{std::atan2(-posClusterCandidate[1], -posClusterCandidate[0]) + o2::constants::math::PI}; + o2::fastsim::DetLayer currentTrackingLayer = fastTracker.GetLayer(i); - if (pixelResolution > 1e-8) { // catch zero (though should not really happen...) - phi = gRandom->Gaus(phi, std::asin(pixelResolution / r)); + if (currentTrackingLayer.getResolutionRPhi() > 1e-8 && currentTrackingLayer.getResolutionZ() > 1e-8) { // catch zero (though should not really happen...) + phi = gRandom->Gaus(phi, std::asin(currentTrackingLayer.getResolutionRPhi() / r)); posClusterCandidate[0] = r * std::cos(phi); posClusterCandidate[1] = r * std::sin(phi); - posClusterCandidate[2] = gRandom->Gaus(posClusterCandidate[2], pixelResolution); + posClusterCandidate[2] = gRandom->Gaus(posClusterCandidate[2], currentTrackingLayer.getResolutionZ()); } + if (std::isnan(phi)) + continue; // Catch when getXatLabR misses layer[i] + // towards adding cluster: move to track alpha double alpha = cascadeTrack.getAlpha(); double xyz1[3]{ @@ -847,7 +827,7 @@ struct OnTheFlyTracker { const o2::track::TrackParametrization::dim2_t hitpoint = { static_cast(xyz1[1]), static_cast(xyz1[2])}; - const o2::track::TrackParametrization::dim3_t hitpointcov = {pixelResolution * pixelResolution, 0.f, pixelResolution * pixelResolution}; + const o2::track::TrackParametrization::dim3_t hitpointcov = {currentTrackingLayer.getResolutionRPhi() * currentTrackingLayer.getResolutionRPhi(), 0.f, currentTrackingLayer.getResolutionZ() * currentTrackingLayer.getResolutionZ()}; cascadeTrack.update(hitpoint, hitpointcov); thisCascade.foundClusters++; // add to findable } @@ -856,12 +836,12 @@ struct OnTheFlyTracker { // add cascade track - histos.fill(HIST("hXiBuilding"), 6.0f); thisCascade.cascadeTrackId = lastTrackIndex + tracksAlice3.size(); // this is the next index to be filled -> should be it tracksAlice3.push_back(TrackAlice3{cascadeTrack, mcParticle.globalIndex(), t, 100.f * 1e-3, false, false, 1, thisCascade.foundClusters}); - if (doXiQA) { + if (cascadeDecaySettings.doXiQA) { + histos.fill(HIST("hXiBuilding"), 6.0f); histos.fill(HIST("h2dDeltaPtVsPt"), trackParCov.getPt(), cascadeTrack.getPt() - trackParCov.getPt()); histos.fill(HIST("h2dDeltaEtaVsPt"), trackParCov.getPt(), cascadeTrack.getEta() - trackParCov.getEta()); @@ -989,7 +969,7 @@ struct OnTheFlyTracker { primaryVertex.getSigmaX2(), primaryVertex.getSigmaXY(), primaryVertex.getSigmaY2(), primaryVertex.getSigmaXZ(), primaryVertex.getSigmaYZ(), primaryVertex.getSigmaZ2(), 0, primaryVertex.getChi2(), primaryVertex.getNContributors(), - 0, 0); + eventCollisionTime, 0.f); // For the moment the event collision time is taken as the "GEANT" time, the computation of the event time is done a posteriori from the tracks in the OTF TOF PID task collLabels(mcCollision.globalIndex(), 0); collisionsAlice3(dNdEta); // *+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+* @@ -1009,17 +989,26 @@ struct OnTheFlyTracker { } if (doExtraQA && (!extraQAwithoutDecayDaughters || (extraQAwithoutDecayDaughters && !trackParCov.isDecayDau))) { histos.fill(HIST("h2dDCAxy"), trackParametrization.getPt(), dcaXY * 1e+4); // in microns, please + histos.fill(HIST("h2dDCAz"), trackParametrization.getPt(), dcaZ * 1e+4); // in microns, please histos.fill(HIST("hTrackXatDCA"), trackParametrization.getX()); } - if (doXiQA) { - if (trackParCov.isUsedInCascading == 1) + if (cascadeDecaySettings.doXiQA) { + if (trackParCov.isUsedInCascading == 1) { histos.fill(HIST("h2dDCAxyCascade"), trackParametrization.getPt(), dcaXY * 1e+4); // in microns, please - if (trackParCov.isUsedInCascading == 2) + histos.fill(HIST("h2dDCAzCascade"), trackParametrization.getPt(), dcaZ * 1e+4); // in microns, please + } + if (trackParCov.isUsedInCascading == 2) { histos.fill(HIST("h2dDCAxyCascadeBachelor"), trackParametrization.getPt(), dcaXY * 1e+4); // in microns, please - if (trackParCov.isUsedInCascading == 3) + histos.fill(HIST("h2dDCAzCascadeBachelor"), trackParametrization.getPt(), dcaZ * 1e+4); // in microns, please + } + if (trackParCov.isUsedInCascading == 3) { histos.fill(HIST("h2dDCAxyCascadeNegative"), trackParametrization.getPt(), dcaXY * 1e+4); // in microns, please - if (trackParCov.isUsedInCascading == 4) + histos.fill(HIST("h2dDCAzCascadeNegative"), trackParametrization.getPt(), dcaZ * 1e+4); // in microns, please + } + if (trackParCov.isUsedInCascading == 4) { histos.fill(HIST("h2dDCAxyCascadePositive"), trackParametrization.getPt(), dcaXY * 1e+4); // in microns, please + histos.fill(HIST("h2dDCAzCascadePositive"), trackParametrization.getPt(), dcaZ * 1e+4); // in microns, please + } } tracksDCA(dcaXY, dcaZ); if (populateTracksDCACov) { @@ -1041,13 +1030,13 @@ struct OnTheFlyTracker { // populate extra tables if required to do so if (populateTracksExtra) { - tracksExtra(0.0f, (uint32_t)0, (uint8_t)0, (uint8_t)0, (uint8_t)0, - (int8_t)0, (int8_t)0, (uint8_t)0, (uint8_t)0, + tracksExtra(0.0f, static_cast(0), static_cast(0), static_cast(0), static_cast(0), + static_cast(0), static_cast(0), static_cast(0), static_cast(0), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); } if (populateTrackSelection) { - trackSelection((uint8_t)0, false, false, false, false, false, false); + trackSelection(static_cast(0), false, false, false, false, false, false); trackSelectionExtension(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false); } TracksAlice3(true); @@ -1066,6 +1055,7 @@ struct OnTheFlyTracker { } if (doExtraQA && (!extraQAwithoutDecayDaughters || (extraQAwithoutDecayDaughters && !trackParCov.isDecayDau))) { histos.fill(HIST("h2dDCAxy"), trackParametrization.getPt(), dcaXY * 1e+4); // in microns, please + histos.fill(HIST("h2dDCAz"), trackParametrization.getPt(), dcaZ * 1e+4); // in microns, please histos.fill(HIST("hTrackXatDCA"), trackParametrization.getX()); } tracksDCA(dcaXY, dcaZ); @@ -1089,13 +1079,13 @@ struct OnTheFlyTracker { // populate extra tables if required to do so if (populateTracksExtra) { - tracksExtra(0.0f, (uint32_t)0, (uint8_t)0, (uint8_t)0, (uint8_t)0, - (int8_t)0, (int8_t)0, (uint8_t)0, (uint8_t)0, + tracksExtra(0.0f, static_cast(0), static_cast(0), static_cast(0), static_cast(0), + static_cast(0), static_cast(0), static_cast(0), static_cast(0), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); } if (populateTrackSelection) { - trackSelection((uint8_t)0, false, false, false, false, false, false); + trackSelection(static_cast(0), false, false, false, false, false, false); trackSelectionExtension(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false); } TracksAlice3(false); @@ -1120,9 +1110,8 @@ struct OnTheFlyTracker { } // do bookkeeping of fastTracker tracking - histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker.covMatNotOK); - histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker.covMatOK); - + histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker.GetCovMatNotOK()); + histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker.GetCovMatOK()); } // end process }; diff --git a/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx new file mode 100644 index 00000000000..42d2bcc5252 --- /dev/null +++ b/ALICE3/TableProducer/OTF/onTheFlyTrackerPid.cxx @@ -0,0 +1,175 @@ +// 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. +/// +/// \file onTheFlyTrackerPid.cxx +/// +/// \brief This task produces the PID information that can be obtained from the tracker layers (i.e. cluster size and ToT). +/// It currently contemplates 5 particle types: electrons, muons, pions, kaons and protons. +/// +/// \author Berkin Ulukutlu TUM +/// \author Henrik Fribert TUM +/// \author Nicolò Jacazio Università del Piemonte Orientale +/// \since May 22, 2025 +/// + +#include +#include +#include +#include +#include + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/ASoAHelpers.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/trackUtilities.h" +#include "ALICE3/Core/TrackUtilities.h" +#include "ReconstructionDataFormats/DCA.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsBase/GeometryManager.h" +#include "CommonUtils/NameConf.h" +#include "CCDB/CcdbApi.h" +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "CommonConstants/GeomConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "TRandom3.h" +#include "TF1.h" +#include "TH2F.h" +#include "TVector3.h" +#include "TString.h" +#include "ALICE3/DataModel/OTFRICH.h" +#include "DetectorsVertexing/HelixHelper.h" +#include "TableHelper.h" +#include "ALICE3/Core/DelphesO2TrackSmearer.h" +#include "ALICE3/DataModel/OTFPIDTrk.h" + +using namespace o2; +using namespace o2::framework; + +struct OnTheFlyTrackerPid { + Produces tableUpgradeTrkPidSignals; + Produces tableUpgradeTrkPids; + + // necessary for particle charges + Service pdg; + + static constexpr int kMaxBarrelLayers = 8; + static constexpr int kMaxForwardLayers = 9; + + struct : ConfigurableGroup { + Configurable efficiencyFormula{"efficiencyFormula", "1.0/(1.0+exp(-(x-0.01)/0.2))", "ROOT TF1 formula for efficiency"}; + Configurable landauFormula{"landauFormula", "TMath::Landau(x, 1, 1, true)", "ROOT TF1 formula for Landau distribution (e.g. ToT response)"}; + Configurable averageMethod{"averageMethod", 0, "Method to average the ToT and cluster size. 0: truncated mean"}; + } simConfig; + + TF1* mEfficiency = nullptr; + static constexpr int kEtaBins = 50; + static constexpr float kEtaMin = -2.5; + static constexpr float kEtaMax = 2.5; + static constexpr int kPtBins = 200; + static constexpr float kPtMin = 0.0; + static constexpr float kPtMax = 20.0; + + std::array, kEtaBins> mElossPi; + + void init(o2::framework::InitContext&) + { + + for (int i = 0; i < kEtaBins; i++) { + for (int j = 0; j < kPtBins; j++) { + mElossPi[i][j] = new TF1(Form("mElossPi_%d_%d", i, j), simConfig.landauFormula.value.c_str(), 0, 20); + } + } + mEfficiency = new TF1("mEfficiency", simConfig.efficiencyFormula.value.c_str(), 0, 20); + } + + void process(soa::Join::iterator const&, + soa::Join const& tracks, + aod::McParticles const&, + aod::McCollisions const&) + { + std::array timeOverThresholdBarrel; + std::array clusterSizeBarrel; + // std::array timeOverThresholdForward; + // std::array clusterSizeForward; + + auto noSignalTrack = [&]() { + tableUpgradeTrkPidSignals(0.f, 0.f); // no PID information + tableUpgradeTrkPids(0.f, 0.f, 0.f, 0.f, 0.f); // no PID information + }; + + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + noSignalTrack(); + continue; + } + const auto& mcParticle = track.mcParticle(); + const auto& pdgInfo = pdg->GetParticle(mcParticle.pdgCode()); + if (!pdgInfo) { + LOG(warning) << "PDG code " << mcParticle.pdgCode() << " not found in the database"; + noSignalTrack(); + continue; + } + const float pt = mcParticle.pt(); + const float eta = mcParticle.eta(); + + const int binnedPt = static_cast((pt - kPtMin) / kPtBins); + const int binnedEta = static_cast((eta - kEtaMin) / kEtaBins); + if (binnedPt < 0 || binnedPt >= kPtBins || binnedEta < 0 || binnedEta >= kEtaBins) { + noSignalTrack(); + continue; + } + for (int i = 0; i < kMaxBarrelLayers; i++) { + timeOverThresholdBarrel[i] = -1; + clusterSizeBarrel[i] = -1; + + // Check if layer is efficient + if (mEfficiency->Eval(pt) > gRandom->Uniform(0, 1)) { + timeOverThresholdBarrel[i] = mElossPi[binnedEta][binnedPt]->GetRandom(); // Simulate ToT + clusterSizeBarrel[i] = mElossPi[binnedEta][binnedPt]->GetRandom(); // Simulate cluster size + } + } + + // Now we do the average + switch (simConfig.averageMethod) { + case 0: { // truncated mean + float meanToT = 0; + float meanClusterSize = 0; + // Order them by ToT + std::sort(timeOverThresholdBarrel.begin(), timeOverThresholdBarrel.end()); + std::sort(clusterSizeBarrel.begin(), clusterSizeBarrel.end()); + static constexpr int kTruncatedMean = 5; + // Take the mean of the first 5 values + for (int i = 0; i < kTruncatedMean; i++) { + meanToT += timeOverThresholdBarrel[i]; + meanClusterSize += clusterSizeBarrel[i]; + } + meanToT /= kTruncatedMean; + meanClusterSize /= kTruncatedMean; + // Fill the table + tableUpgradeTrkPidSignals(meanToT, meanClusterSize); + } break; + + default: + LOG(fatal) << "Unknown average method " << simConfig.averageMethod; + break; + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/ALICE3/TableProducer/alice3-correlatorDDbar.cxx b/ALICE3/TableProducer/alice3-correlatorDDbar.cxx new file mode 100644 index 00000000000..b17216e9b76 --- /dev/null +++ b/ALICE3/TableProducer/alice3-correlatorDDbar.cxx @@ -0,0 +1,332 @@ +// 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. + +/// \file alice3-correlatorDDbar.cxx +/// \brief D0-D0bar correlator task - data-like and MC-reco analysis performance on ALICE 3 detector. +/// +/// \author Fabio Colamaria , INFN Bari + +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/HFC/DataModel/CorrelationTables.h" + +#include "ALICE3/DataModel/A3DecayFinderTables.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include + +using namespace o2; +using namespace o2::analysis; +using namespace o2::constants::physics; +using namespace o2::framework; +using namespace o2::framework::expressions; + +/// +/// Returns deltaPhi value in range [-pi/2., 3.*pi/2], typically used for correlation studies +/// +double getDeltaPhi(double phiD, double phiDbar) +{ + return RecoDecay::constrainAngle(phiDbar - phiD, -o2::constants::math::PIHalf); +} + +/// definition of variables for D0D0bar pairs vs eta acceptance studies (hDDbarVsEtaCut, in data-like, MC-reco and MC-kine tasks) +const double maxEtaCut = 5.; +const double ptThresholdForMaxEtaCut = 10.; +const double incrementEtaCut = 0.1; +const double incrementPtThreshold = 0.5; +const double epsilon = 1E-5; + +const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::NBinsPt; +const double efficiencyDmesonDefault[npTBinsMassAndEfficiency] = {}; +auto efficiencyDmeson_v = std::vector{efficiencyDmesonDefault, efficiencyDmesonDefault + npTBinsMassAndEfficiency}; + +// histogram binning definition +const int massAxisBins = 120; +const double massAxisMin = 1.5848; +const double massAxisMax = 2.1848; +const int phiAxisBins = 32; +const double phiAxisMin = 0.; +const double phiAxisMax = o2::constants::math::TwoPI; +const int yAxisBins = 100; +const double yAxisMin = -5.; +const double yAxisMax = 5.; +const int ptDAxisBins = 180; +const double ptDAxisMin = 0.; +const double ptDAxisMax = 36.; + +struct alice3correlatorddbar { + SliceCache cache; + Preslice perCol = aod::a3D0meson::collisionId; + Produces entryD0D0barPair; + Produces entryD0D0barRecoInfo; + + Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; + Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection Flag for D0bar"}; + Configurable applyEfficiency{"applyEfficiency", 1, "Flag for applying D-meson efficiency weights"}; + Configurable yCandMax{"yCandMax", 999., "max. cand. rapidity"}; + Configurable ptCandMin{"ptCandMin", -1., "min. cand. pT"}; + Configurable> binsPt{"binsPt", std::vector{o2::analysis::hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for candidate mass plots and efficiency"}; + Configurable> efficiencyD{"efficiencyD", std::vector{efficiencyDmeson_v}, "Efficiency values for D0 meson"}; + + // HfHelper hfHelper; //not needed for now + + Partition> selectedCandidates = aod::a3D0meson::y > -yCandMax&& aod::a3D0meson::y ptCandMin && (aod::a3D0Selection::isSelD0 >= selectionFlagD0 || aod::a3D0Selection::isSelD0bar >= selectionFlagD0bar); + Partition> selectedCandidatesMC = aod::a3D0meson::y > -yCandMax&& aod::a3D0meson::y ptCandMin && (aod::a3D0Selection::isSelD0 >= selectionFlagD0 || aod::a3D0Selection::isSelD0bar >= selectionFlagD0bar); + + HistogramRegistry registry{ + "registry", + // NOTE: use hMassD0 for trigger normalisation (S*0.955), and hMass2DCorrelationPairs (in final task) for 2D-sideband-subtraction purposes + {{"hPtCand", "D0,D0bar candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, + {"hPtProng0", "D0,D0bar candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, + {"hPtProng1", "D0,D0bar candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, + {"hSelectionStatus", "D0,D0bar candidates;selection status;entries", {HistType::kTH1F, {{4, -0.5, 3.5}}}}, + {"hEta", "D0,D0bar candidates;candidate #it{#eta};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}, + {"hPhi", "D0,D0bar candidates;candidate #it{#varphi};entries", {HistType::kTH1F, {{phiAxisBins, phiAxisMin, phiAxisMax}}}}, + {"hY", "D0,D0bar candidates;candidate #it{y};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}, + {"hDDbarVsEtaCut", "D0,D0bar pairs vs #eta cut;#eta_{max};candidates #it{p}_{T} threshold (GeV/#it{c});entries", {HistType::kTH2F, {{static_cast(maxEtaCut / incrementEtaCut), 0., maxEtaCut}, {static_cast(ptThresholdForMaxEtaCut / incrementPtThreshold), 0., ptThresholdForMaxEtaCut}}}}, + {"hPtCandMCRec", "D0,D0bar candidates - MC reco;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, + {"hPtProng0MCRec", "D0,D0bar candidates - MC reco;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, + {"hPtProng1MCRec", "D0,D0bar candidates - MC reco;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, + {"hSelectionStatusMCRec", "D0,D0bar candidates - MC reco;selection status;entries", {HistType::kTH1F, {{4, -0.5, 3.5}}}}, + {"hEtaMCRec", "D0,D0bar candidates - MC reco;candidate #it{#eta};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}, + {"hPhiMCRec", "D0,D0bar candidates - MC reco;candidate #it{#varphi};entries", {HistType::kTH1F, {{phiAxisBins, phiAxisMin, phiAxisMax}}}}, + {"hYMCRec", "D0,D0bar candidates - MC reco;candidate #it{y};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}}}; + + void init(InitContext&) + { + auto vbins = (std::vector)binsPt; + registry.add("hMass", "D0,D0bar candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0", "D0,D0bar candidates;inv. mass D0 only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0bar", "D0,D0bar candidates;inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0MCRecSig", "D0 signal candidates - MC reco;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0MCRecRefl", "D0 reflection candidates - MC reco;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0MCRecBkg", "D0 background candidates - MC reco;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0barMCRecSig", "D0bar signal candidates - MC reco;inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0barMCRecRefl", "D0bar reflection candidates - MC reco;inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0barMCRecBkg", "D0bar background candidates - MC reco;inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMass_NoEff", "D0,D0bar candidates (wo efficiency);inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0_NoEff", "D0,D0bar candidates (wo efficiency);inv. mass D0 only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0bar_NoEff", "D0,D0bar candidates (wo efficiency);inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0MCRecSig_NoEff", "D0 signal candidates - MC reco (wo efficiency);inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0MCRecRefl_NoEff", "D0 reflection candidates - MC reco (wo efficiency);inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0MCRecBkg_NoEff", "D0 background candidates - MC reco (wo efficiency);inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0barMCRecSig_NoEff", "D0bar signal candidates - MC reco (wo efficiency);inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0barMCRecRefl_NoEff", "D0bar reflection candidates - MC reco (wo efficiency);inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassD0barMCRecBkg_NoEff", "D0bar background candidates - MC reco (wo efficiency);inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + } + + /// D0-D0bar correlation pair builder - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) + void processData(aod::Collision const& collision, + soa::Join const&) + { + auto selectedCandidatesGrouped = selectedCandidates->sliceByCached(aod::a3D0meson::collisionId, collision.globalIndex(), cache); + + for (const auto& candidate1 : selectedCandidatesGrouped) { // loop over reconstructed and selected D0 and D0bar (together, to fill mass plots first) + double efficiencyWeight = 1.; + if (applyEfficiency) { + efficiencyWeight = 1. / efficiencyD->at(o2::analysis::findBin(binsPt, candidate1.pt())); + } + + // fill invariant mass plots and generic info from all D0/D0bar candidates + if (candidate1.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hMass"), candidate1.m(), candidate1.pt(), efficiencyWeight); + registry.fill(HIST("hMassD0"), candidate1.m(), candidate1.pt(), efficiencyWeight); + registry.fill(HIST("hMass_NoEff"), candidate1.m(), candidate1.pt()); + registry.fill(HIST("hMassD0_NoEff"), candidate1.m(), candidate1.pt()); + } + if (candidate1.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hMass"), candidate1.m(), candidate1.pt(), efficiencyWeight); + registry.fill(HIST("hMassD0bar"), candidate1.m(), candidate1.pt(), efficiencyWeight); + registry.fill(HIST("hMass_NoEff"), candidate1.m(), candidate1.pt()); + registry.fill(HIST("hMassD0bar_NoEff"), candidate1.m(), candidate1.pt()); + } + registry.fill(HIST("hPtCand"), candidate1.pt()); + registry.fill(HIST("hPtProng0"), candidate1.ptProng0()); + registry.fill(HIST("hPtProng1"), candidate1.ptProng1()); + registry.fill(HIST("hEta"), candidate1.eta()); + registry.fill(HIST("hPhi"), candidate1.phi()); + registry.fill(HIST("hY"), candidate1.y()); + registry.fill(HIST("hSelectionStatus"), candidate1.isSelD0() + (candidate1.isSelD0bar() * 2)); + + // D-Dbar correlation dedicated section + + // if the candidate is a D0, search for D0bar and evaluate correlations + if (candidate1.isSelD0() < selectionFlagD0) { + continue; + } + for (const auto& candidate2 : selectedCandidatesGrouped) { + if (candidate2.isSelD0bar() < selectionFlagD0bar) { // keep only D0bar candidates passing the selection + continue; + } + // excluding trigger self-correlations (possible in case of both mass hypotheses accepted) + if (candidate1.mRowIndex == candidate2.mRowIndex) { // this by definition should never happen, since each candidate is either D0 or D0bar + continue; + } + if ((candidate1.pt() - candidate2.pt()) < 1e-5 && (candidate1.eta() - candidate2.eta()) < 1e-5 && (candidate1.phi() - candidate2.phi()) < 1e-5) { // revised, temporary condition to avoid self-correlations (the best would be check the daughterIDs, but we don't store them at the moment) + continue; + } + entryD0D0barPair(getDeltaPhi(candidate2.phi(), candidate1.phi()), + candidate2.eta() - candidate1.eta(), + candidate1.pt(), + candidate2.pt()); + entryD0D0barRecoInfo(candidate1.m(), // mD0 + candidate2.m(), // mD0bar + 0); + double etaCut = 0.; + double ptCut = 0.; + do { // fill pairs vs etaCut plot + ptCut = 0.; + etaCut += incrementEtaCut; + do { // fill pairs vs etaCut plot + if (std::abs(candidate1.eta()) < etaCut && std::abs(candidate2.eta()) < etaCut && candidate1.pt() > ptCut && candidate2.pt() > ptCut) { + registry.fill(HIST("hDDbarVsEtaCut"), etaCut - epsilon, ptCut + epsilon); + } + ptCut += incrementPtThreshold; + } while (ptCut < ptThresholdForMaxEtaCut - epsilon); + } while (etaCut < maxEtaCut - epsilon); + // note: candidates selected as both D0 and D0bar are used, and considered in both situation (but not auto-correlated): reflections could play a relevant role. + // another, more restrictive, option, could be to consider only candidates selected with a single option (D0 xor D0bar) + + } // end inner loop (Dbars) + + } // end outer loop + } + + PROCESS_SWITCH(alice3correlatorddbar, processData, "Process data", true); + + /// D0-D0bar correlation pair builder - for MC reco-level analysis (candidates matched to true signal only, but also the various bkg sources are studied) + void processMcRec(aod::Collision const& collision, + soa::Join const&) + { + auto selectedCandidatesGroupedMC = selectedCandidatesMC->sliceByCached(aod::a3D0meson::collisionId, collision.globalIndex(), cache); + + // MC reco level + bool flagD0Signal = false; + bool flagD0Reflection = false; + bool flagD0barSignal = false; + bool flagD0barReflection = false; + for (const auto& candidate1 : selectedCandidatesGroupedMC) { + double efficiencyWeight = 1.; + if (applyEfficiency) { + efficiencyWeight = 1. / efficiencyD->at(o2::analysis::findBin(binsPt, candidate1.pt())); + } + + if (candidate1.mcTruthInfo()) { // 1 or 2, i.e. true D0 or D0bar + // fill per-candidate distributions from D0/D0bar true candidates + registry.fill(HIST("hPtCandMCRec"), candidate1.pt()); + registry.fill(HIST("hPtProng0MCRec"), candidate1.ptProng0()); + registry.fill(HIST("hPtProng1MCRec"), candidate1.ptProng1()); + registry.fill(HIST("hEtaMCRec"), candidate1.eta()); + registry.fill(HIST("hPhiMCRec"), candidate1.phi()); + registry.fill(HIST("hYMCRec"), candidate1.y()); + registry.fill(HIST("hSelectionStatusMCRec"), candidate1.isSelD0() + (candidate1.isSelD0bar() * 2)); + } + // fill invariant mass plots from D0/D0bar signal and background candidates + if (candidate1.isSelD0() >= selectionFlagD0) { // only reco as D0 + if (candidate1.mcTruthInfo() == 1) { // also matched as D0 + registry.fill(HIST("hMassD0MCRecSig"), candidate1.m(), candidate1.pt(), efficiencyWeight); // here m is univoque, since a given candidate passes the selection with only a single mass option + registry.fill(HIST("hMassD0MCRecSig_NoEff"), candidate1.m(), candidate1.pt()); + } else if (candidate1.mcTruthInfo() == 2) { + registry.fill(HIST("hMassD0MCRecRefl"), candidate1.m(), candidate1.pt(), efficiencyWeight); + registry.fill(HIST("hMassD0MCRecRefl_NoEff"), candidate1.m(), candidate1.pt()); + } else { + registry.fill(HIST("hMassD0MCRecBkg"), candidate1.m(), candidate1.pt(), efficiencyWeight); + registry.fill(HIST("hMassD0MCRecBkg_NoEff"), candidate1.m(), candidate1.pt()); + } + } + if (candidate1.isSelD0bar() >= selectionFlagD0bar) { // only reco as D0bar + if (candidate1.mcTruthInfo() == 2) { // also matched as D0bar + registry.fill(HIST("hMassD0barMCRecSig"), candidate1.m(), candidate1.pt(), efficiencyWeight); // here m is univoque, since a given candidate passes the selection with only a single mass option + registry.fill(HIST("hMassD0barMCRecSig_NoEff"), candidate1.m(), candidate1.pt()); + } else if (candidate1.mcTruthInfo() == 1) { + registry.fill(HIST("hMassD0barMCRecRefl"), candidate1.m(), candidate1.pt(), efficiencyWeight); + registry.fill(HIST("hMassD0barMCRecRefl_NoEff"), candidate1.m(), candidate1.pt()); + } else { + registry.fill(HIST("hMassD0barMCRecBkg"), candidate1.m(), candidate1.pt(), efficiencyWeight); + registry.fill(HIST("hMassD0barMCRecBkg_NoEff"), candidate1.m(), candidate1.pt()); + } + } + + // D-Dbar correlation dedicated section + // if the candidate is selected ad D0, search for D0bar and evaluate correlations + if (candidate1.isSelD0() < selectionFlagD0) { // discard candidates not selected as D0 in outer loop + continue; + } + + flagD0Signal = candidate1.mcTruthInfo() == 1; // flagD0Signal 'true' if candidate1 matched to D0 (particle) + flagD0Reflection = candidate1.mcTruthInfo() == 2; // flagD0Reflection 'true' if candidate1, selected as D0 (particle), is matched to D0bar (antiparticle) + + for (const auto& candidate2 : selectedCandidatesGroupedMC) { + if (candidate2.isSelD0bar() < selectionFlagD0bar) { // discard candidates not selected as D0bar in inner loop + continue; + } + flagD0barSignal = candidate2.mcTruthInfo() == 2; // flagD0barSignal 'true' if candidate2 matched to D0bar (antiparticle) + flagD0barReflection = candidate2.mcTruthInfo() == 1; // flagD0barReflection 'true' if candidate2, selected as D0bar (antiparticle), is matched to D0 (particle) + + // Excluding trigger self-correlations (possible in case of both mass hypotheses of the same real particle, reconstructed as candidate1 for D0 and candidate2 for D0bar) + if (candidate1.mRowIndex == candidate2.mRowIndex) { // this by definition should never happen, since each candidate is either D0 or D0bar + continue; + } + if ((candidate1.pt() - candidate2.pt()) < 1e-5 && (candidate1.eta() - candidate2.eta()) < 1e-5 && (candidate1.phi() - candidate2.phi()) < 1e-5) { // revised, temporary condition to avoid self-correlations (the best would be check the daughterIDs, but we don't store them at the moment) + continue; + } + // choice of options (D0/D0bar signal/bkg) + int pairSignalStatus = 0; // 0 = bkg/bkg, 1 = bkg/ref, 2 = bkg/sig, 3 = ref/bkg, 4 = ref/ref, 5 = ref/sig, 6 = sig/bkg, 7 = sig/ref, 8 = sig/sig + if (flagD0Signal) { + pairSignalStatus += 6; + } + if (flagD0Reflection) { + pairSignalStatus += 3; + } + if (flagD0barSignal) { + pairSignalStatus += 2; + } + if (flagD0barReflection) { + pairSignalStatus += 1; + } + entryD0D0barPair(getDeltaPhi(candidate2.phi(), candidate1.phi()), + candidate2.eta() - candidate1.eta(), + candidate1.pt(), + candidate2.pt()); + entryD0D0barRecoInfo(candidate1.m(), // mD0 + candidate2.m(), // mD0bar + pairSignalStatus); + double etaCut = 0.; + double ptCut = 0.; + do { // fill pairs vs etaCut plot + ptCut = 0.; + etaCut += incrementEtaCut; + do { // fill pairs vs etaCut plot + if (std::abs(candidate1.eta()) < etaCut && std::abs(candidate2.eta()) < etaCut && candidate1.pt() > ptCut && candidate2.pt() > ptCut) { + registry.fill(HIST("hDDbarVsEtaCut"), etaCut - epsilon, ptCut + epsilon); + } + ptCut += incrementPtThreshold; + } while (ptCut < ptThresholdForMaxEtaCut - epsilon); + } while (etaCut < maxEtaCut - epsilon); + } // end inner loop (Dbars) + + } // end outer loop + } + + PROCESS_SWITCH(alice3correlatorddbar, processMcRec, "Process MC Reco mode", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/ALICE3/TableProducer/alice3-decayfinder.cxx b/ALICE3/TableProducer/alice3-decayfinder.cxx index 4b88305fb60..2d12ea9ed14 100644 --- a/ALICE3/TableProducer/alice3-decayfinder.cxx +++ b/ALICE3/TableProducer/alice3-decayfinder.cxx @@ -49,6 +49,7 @@ using namespace o2; using namespace o2::framework; +using namespace o2::constants::physics; using namespace o2::framework::expressions; using std::array; @@ -68,10 +69,15 @@ using alice3tracks = soa::Join candidateD0meson; // contains D0 and D0bar selected candidates (separated, i.e. each row with a single mass hypothesis) + Produces selectionOutcome; // flags for isSelD0 and isSelD0bar + Produces mcTruthOutcome; // contains MC truth info (is true D0, true D0bar, or bkg) + // Operation and minimisation criteria Configurable magneticField{"magneticField", 20.0f, "Magnetic field (in kilogauss)"}; Configurable doDCAplotsD{"doDCAplotsD", true, "do daughter prong DCA plots for D mesons"}; Configurable doDCAplotsLc{"doDCAplotsLc", true, "do daughter prong DCA plots for Lc baryons"}; + Configurable doTopoPlotsForSAndB{"doTopoPlotsForSAndB", true, "do topological variable distributions for S and B separately"}; Configurable mcSameMotherCheck{"mcSameMotherCheck", true, "check if tracks come from the same MC mother"}; Configurable dcaDaughtersSelection{"dcaDaughtersSelection", 1000.0f, "DCA between daughters (cm)"}; @@ -80,6 +86,26 @@ struct alice3decayFinder { Configurable kaFromD_dcaXYconstant{"kaFromD_dcaXYconstant", -1.0f, "[0] in |DCAxy| > [0]+[1]/pT"}; Configurable kaFromD_dcaXYpTdep{"kaFromD_dcaXYpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + Configurable DCosPA{"DCosPA", 0.99, " Cos of pointing angle: low pt"}; + Configurable DCosPAHighPt{"DCosPAHighPt", 0.995, " Cos of pointing angle: high pt"}; + Configurable DCosPAxy{"DCosPAxy", 0.99, " Cos of pointing angle xy: low pt"}; + Configurable DCosPAxyHighPt{"DCosPAxyHighPt", 0.995, " Cos of pointing angle xy: DCosPAxyHighPt pt"}; + Configurable DCosThetaStarLowPt{"DCosThetaStarLowPt", 0.8, "Cos theta; low pt"}; + Configurable DCosThetaStarHighPt{"DCosThetaStarHighPt", 0.9, "Cos theta; high pt"}; + Configurable DCosThetaStarVHighPt{"DCosThetaStarVHighPt", 1.0, "Cos theta; very high pt"}; + Configurable DDecayLengthSquaredCut{"DDecayLengthSquaredCut", 0., "Flat component of squared decay length cut (only for LoI legacy)"}; + Configurable DMinDecayLength{"DMinDecayLength", 0., "Minimum D decay length (3D)"}; + Configurable DMaxDecayLength{"DMaxDecayLength", 10., "Maximum D decay length (3D)"}; + Configurable DMinDecayLengthXY{"DMinDecayLengthXY", 0., "Minimum D decay length (xy)"}; + Configurable DMaxDecayLengthXY{"DMaxDecayLengthXY", 10., "Maximum D decay length (xy)"}; + Configurable DMinNormDecayLength{"DMinNormDecayLength", 3, "Minimum normalized decay length"}; + Configurable DMaxNormDecayLength{"DMaxNormDecayLength", 3, "Maximum normalized decay length"}; + Configurable minPtPi{"minPtPi", 0., "Minimum pT of daughter pion track"}; + Configurable minPtK{"minPtK", 0., "Minimum pT of daughter kaon track"}; + Configurable maxImpParPi{"maxImpParPi", 1., "Maximum impact paramter of daughter pion track"}; + Configurable maxImpParK{"maxImpParK", 1., "Maximum impact paramter of daughter kaon track"}; + Configurable maxImpParProduct{"maxImpParProduct", 0., "Maximum daughter impact paramter product"}; + Configurable piFromLc_dcaXYconstant{"piFromLc_dcaXYconstant", -1.0f, "[0] in |DCAxy| > [0]+[1]/pT"}; Configurable piFromLc_dcaXYpTdep{"piFromLc_dcaXYpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; Configurable kaFromLc_dcaXYconstant{"kaFromLc_dcaXYconstant", -1.0f, "[0] in |DCAxy| > [0]+[1]/pT"}; @@ -87,9 +113,14 @@ struct alice3decayFinder { Configurable prFromLc_dcaXYconstant{"prFromLc_dcaXYconstant", -1.0f, "[0] in |DCAxy| > [0]+[1]/pT"}; Configurable prFromLc_dcaXYpTdep{"prFromLc_dcaXYpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + Configurable lowPtDLimit{"lowPtDLimit", 3.5, "Upper boundary of low pT D range, for topological selection (GeV/c)"}; + Configurable highPtDLimit{"highPtDLimit", 16, "Upper boundary of high pT D range, for topological selection (GeV/c)"}; + ConfigurableAxis axisEta{"axisEta", {8, -4.0f, +4.0f}, "#eta"}; + ConfigurableAxis axisY{"axisY", {12, -6.0f, +6.0f}, "y"}; ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for QA histograms"}; ConfigurableAxis axisDCA{"axisDCA", {200, -100, 100}, "DCA (#mum)"}; + ConfigurableAxis axisDCADaughters{"axisDCADaughters", {200, 0, 100}, "DCA (#mum)"}; ConfigurableAxis axisDMass{"axisDMass", {200, 1.765f, 1.965f}, "D Inv Mass (GeV/c^{2})"}; ConfigurableAxis axisLcMass{"axisLcMass", {200, 2.186f, 2.386f}, "#Lambda_{c} Inv Mass (GeV/c^{2})"}; @@ -119,7 +150,9 @@ struct alice3decayFinder { // partitions for D mesons Partition tracksPiPlusFromD = - ((aod::a3DecayMap::decayMap & trackSelectionPiPlusFromD) == trackSelectionPiPlusFromD) && aod::track::signed1Pt > 0.0f && nabs(aod::track::dcaXY) > piFromD_dcaXYconstant + piFromD_dcaXYpTdep* nabs(aod::track::signed1Pt); + ((aod::a3DecayMap::decayMap & trackSelectionPiPlusFromD) == trackSelectionPiPlusFromD) && + aod::track::signed1Pt > 0.0f && + nabs(aod::track::dcaXY) > piFromD_dcaXYconstant + piFromD_dcaXYpTdep* nabs(aod::track::signed1Pt); Partition tracksPiMinusFromD = ((aod::a3DecayMap::decayMap & trackSelectionPiMinusFromD) == trackSelectionPiMinusFromD) && aod::track::signed1Pt < 0.0f && nabs(aod::track::dcaXY) > piFromD_dcaXYconstant + piFromD_dcaXYpTdep* nabs(aod::track::signed1Pt); Partition tracksKaPlusFromD = @@ -144,19 +177,35 @@ struct alice3decayFinder { // Helper struct to pass candidate information struct { + float dcaDau; float mass; + std::array posSV; + std::array P; + std::array Pdaug; // positive track + std::array Ndaug; // negative track float pt; + float ptdaugPos; + float ptdaugNeg; + float phi; float eta; + float y; + float cosPA; + float cosPAxy; + float cosThetaStar; + float normalizedDecayLength; + int mcTruth; // 0 = bkg, 1 = D0, 2 = D0bar } dmeson; struct { + float dcaDau; float mass; float pt; + float phi; float eta; } lcbaryon; template - bool buildDecayCandidateTwoBody(TTrackType const& posTrackRow, TTrackType const& negTrackRow, float posMass, float negMass) + bool buildDecayCandidateTwoBody(TTrackType const& posTrackRow, TTrackType const& negTrackRow, float posMass, float negMass, aod::McParticles const& mcParticles) { o2::track::TrackParCov posTrack = getTrackParCov(posTrackRow); o2::track::TrackParCov negTrack = getTrackParCov(negTrackRow); @@ -180,15 +229,45 @@ struct alice3decayFinder { std::array negP; posTrack.getPxPyPzGlo(posP); negTrack.getPxPyPzGlo(negP); - - float dcaDau = TMath::Sqrt(fitter.getChi2AtPCACandidate()); - if (dcaDau > dcaDaughtersSelection) - return false; - - // return mass + dmeson.dcaDau = TMath::Sqrt(fitter.getChi2AtPCACandidate()); + dmeson.Pdaug[0] = posP[0]; + dmeson.Pdaug[1] = posP[1]; + dmeson.Pdaug[2] = posP[2]; + dmeson.Ndaug[0] = negP[0]; + dmeson.Ndaug[1] = negP[1]; + dmeson.Ndaug[2] = negP[2]; + + // return mass and kinematic variables dmeson.mass = RecoDecay::m(array{array{posP[0], posP[1], posP[2]}, array{negP[0], negP[1], negP[2]}}, array{posMass, negMass}); dmeson.pt = std::hypot(posP[0] + negP[0], posP[1] + negP[1]); + dmeson.ptdaugPos = std::hypot(posP[0], posP[1]); + dmeson.ptdaugNeg = std::hypot(negP[0], negP[1]); + dmeson.phi = RecoDecay::phi(array{posP[0] + negP[0], posP[1] + negP[1]}); dmeson.eta = RecoDecay::eta(array{posP[0] + negP[0], posP[1] + negP[1], posP[2] + negP[2]}); + dmeson.y = RecoDecay::y(std::array{posP[0] + negP[0], posP[1] + negP[1], posP[2] + negP[2]}, dmeson.mass); + const auto posSV = fitter.getPCACandidate(); + dmeson.posSV[0] = posSV[0]; + dmeson.posSV[1] = posSV[1]; + dmeson.posSV[2] = posSV[2]; + o2::track::TrackParCov parentTrack = fitter.createParentTrackParCov(); + parentTrack.getPxPyPzGlo(dmeson.P); + dmeson.cosThetaStar = RecoDecay::cosThetaStar(std::array{std::array{posP[0], posP[1], posP[2]}, std::array{negP[0], negP[1], negP[2]}}, std::array{posMass, negMass}, dmeson.mass, 0); + + // MC truth check + int indexRec = -1; + int8_t sign = 0; + auto arrayDaughters = std::array{posTrackRow, negTrackRow}; + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign); + if (indexRec < 0) { + dmeson.mcTruth = 0; // bkg + } else { + if (sign > 0) { + dmeson.mcTruth = 1; // D0 + } else { + dmeson.mcTruth = 2; // D0bar + } + } + return true; } @@ -222,13 +301,14 @@ struct alice3decayFinder { t1.getPxPyPzGlo(P1); t2.getPxPyPzGlo(P2); - float dcaDau = TMath::Sqrt(fitter3.getChi2AtPCACandidate()); - if (dcaDau > dcaDaughtersSelection) + lcbaryon.dcaDau = TMath::Sqrt(fitter3.getChi2AtPCACandidate()); + if (lcbaryon.dcaDau > dcaDaughtersSelection) return false; // return mass lcbaryon.mass = RecoDecay::m(array{array{P0[0], P0[1], P0[2]}, array{P1[0], P1[1], P1[2]}, array{P2[0], P2[1], P2[2]}}, array{p0mass, p1mass, p2mass}); lcbaryon.pt = std::hypot(P0[0] + P1[0] + P2[0], P0[1] + P1[1] + P2[1]); + lcbaryon.phi = RecoDecay::phi(array{P0[0] + P1[0] + P2[0], P0[1] + P1[1] + P2[1]}); lcbaryon.eta = RecoDecay::eta(array{P0[0] + P1[0] + P2[0], P0[1] + P1[1] + P2[1], P0[2] + P1[2] + P2[2]}); return true; } @@ -283,18 +363,86 @@ struct alice3decayFinder { if (doprocessFindDmesons) { histos.add("h2dGenD", "h2dGenD", kTH2F, {axisPt, axisEta}); + histos.add("h2dGenD_KpiOnly", "h2dGenD_KpiOnly", kTH2F, {axisPt, axisEta}); histos.add("h2dGenDbar", "h2dGenDbar", kTH2F, {axisPt, axisEta}); - histos.add("h3dRecD", "h2dRecD", kTH3F, {axisPt, axisEta, axisDMass}); - histos.add("h3dRecDbar", "h2dRecDbar", kTH3F, {axisPt, axisEta, axisDMass}); + histos.add("h2dGenDbar_KpiOnly", "h2dGenDbar_KpiOnly", kTH2F, {axisPt, axisEta}); + histos.add("h3dRecD", "h3dRecD", kTH3F, {axisPt, axisEta, axisDMass}); + histos.add("h3dRecDSig", "h3dRecDSig", kTH3F, {axisPt, axisEta, axisDMass}); + histos.add("h3dRecDRefl", "h3dRecDRefl", kTH3F, {axisPt, axisEta, axisDMass}); + histos.add("h3dRecDBkg", "h3dRecDBkg", kTH3F, {axisPt, axisEta, axisDMass}); + histos.add("h3dRecDbar", "h3dRecDbar", kTH3F, {axisPt, axisEta, axisDMass}); + histos.add("h3dRecDbarSig", "h3dRecDbarSig", kTH3F, {axisPt, axisEta, axisDMass}); + histos.add("h3dRecDbarRefl", "h3dRecDbarRefl", kTH3F, {axisPt, axisEta, axisDMass}); + histos.add("h3dRecDbarBkg", "h3dRecDbarBkg", kTH3F, {axisPt, axisEta, axisDMass}); + + histos.add("hDGenForEfficiency", "hDGenForEfficiency", kTH2F, {axisPt, axisY}); // 2D vs pT, Y, filling generated D0 and D0bar + histos.add("hDRecForEfficiency", "hDRecForEfficiency", kTH2F, {axisPt, axisY}); // 2D vs pT, Y, filling reconstructed D0 and D0bar with correct MC matching histos.add("hMassD", "hMassD", kTH1F, {axisDMass}); + histos.add("hMassDSig", "hMassDSig", kTH1F, {axisDMass}); + histos.add("hMassDRefl", "hMassDRefl", kTH1F, {axisDMass}); + histos.add("hMassDBkg", "hMassDBkg", kTH1F, {axisDMass}); histos.add("hMassDbar", "hMassDbar", kTH1F, {axisDMass}); + histos.add("hMassDbarSig", "hMassDbarSig", kTH1F, {axisDMass}); + histos.add("hMassDbarRefl", "hMassDbarRefl", kTH1F, {axisDMass}); + histos.add("hMassDbarBkg", "hMassDbarBkg", kTH1F, {axisDMass}); + + histos.add("hDCosPA", "hDCosPA", kTH1F, {{800, -1, 1}}); + histos.add("hDCosPAxy", "hDCosPAxy", kTH1F, {{800, -1, 1}}); + histos.add("hDCosThetaStar", "hDCosThetaStar", kTH1F, {{200, -1, 1}}); + histos.add("hDDecayLength", "hDDecayLength", kTH1F, {{100, 0, 0.5}}); + histos.add("hDDecayLengthXY", "hDDecayLengthXY", kTH1F, {{100, 0, 0.5}}); + histos.add("hDNormDecayLength", "hDNormDecayLength", kTH1F, {{100, 0, 10}}); + histos.add("hImpParPi", "hImpParPi", kTH1F, {{200, -0.4, 0.4}}); + histos.add("hImpParK", "hImpParK", kTH1F, {{200, -0.4, 0.4}}); + histos.add("hImpParProduct", "hImpParProduct", kTH1F, {{400, -0.04, 0.04}}); + + histos.add("hDCosPA_Selected", "hDCosPA_Selected", kTH1F, {{800, -1, 1}}); + histos.add("hDCosPAxy_Selected", "hDCosPAxy_Selected", kTH1F, {{800, -1, 1}}); + histos.add("hDCosThetaStar_Selected", "hDCosThetaStar_Selected", kTH1F, {{200, -1, 1}}); + histos.add("hDDecayLength_Selected", "hDDecayLength_Selected", kTH1F, {{100, 0, 0.5}}); + histos.add("hDDecayLengthXY_Selected", "hDDecayLengthXY_Selected", kTH1F, {{100, 0, 0.5}}); + histos.add("hDNormDecayLength_Selected", "hDNormDecayLength_Selected", kTH1F, {{100, 0, 10}}); + histos.add("hImpParPi_Selected", "hImpParPi_Selected", kTH1F, {{200, -0.4, 0.4}}); + histos.add("hImpParK_Selected", "hImpParK_Selected", kTH1F, {{200, -0.4, 0.4}}); + histos.add("hImpParProduct_Selected", "hImpParProduct_Selected", kTH1F, {{400, -0.04, 0.04}}); + + if (doTopoPlotsForSAndB) { + histos.add("hDCosPA_Signal", "hDCosPA_Signal", kTH1F, {{800, -1, 1}}); + histos.add("hDCosPAxy_Signal", "hDCosPAxy_Signal", kTH1F, {{800, -1, 1}}); + histos.add("hDCosThetaStar_Signal", "hDCosThetaStar_Signal", kTH1F, {{200, -1, 1}}); + histos.add("hDDecayLength_Signal", "hDDecayLength_Signal", kTH1F, {{100, 0, 0.5}}); + histos.add("hDDecayLengthXY_Signal", "hDDecayLengthXY_Signal", kTH1F, {{100, 0, 0.5}}); + histos.add("hDNormDecayLength_Signal", "hDNormDecayLength_Signal", kTH1F, {{100, 0, 10}}); + histos.add("hImpParPi_Signal", "hImpParPi_Signal", kTH1F, {{200, -0.4, 0.4}}); + histos.add("hImpParK_Signal", "hImpParK_Signal", kTH1F, {{200, -0.4, 0.4}}); + histos.add("hImpParProduct_Signal", "hImpParProduct_Signal", kTH1F, {{400, -0.04, 0.04}}); + histos.add("hDCosPA_Bkg", "hDCosPA_Bkg", kTH1F, {{800, -1, 1}}); + histos.add("hDCosPAxy_Bkg", "hDCosPAxy_Bkg", kTH1F, {{800, -1, 1}}); + histos.add("hDCosThetaStar_Bkg", "hDCosThetaStar_Bkg", kTH1F, {{200, -1, 1}}); + histos.add("hDDecayLength_Bkg", "hDDecayLength_Bkg", kTH1F, {{100, 0, 0.5}}); + histos.add("hDDecayLengthXY_Bkg", "hDDecayLengthXY_Bkg", kTH1F, {{100, 0, 0.5}}); + histos.add("hDNormDecayLength_Bkg", "hDNormDecayLength_Bkg", kTH1F, {{100, 0, 10}}); + histos.add("hImpParPi_Bkg", "hImpParPi_Bkg", kTH1F, {{200, -0.4, 0.4}}); + histos.add("hImpParK_Bkg", "hImpParK_Bkg", kTH1F, {{200, -0.4, 0.4}}); + histos.add("hImpParProduct_Bkg", "hImpParProduct_Bkg", kTH1F, {{400, -0.04, 0.04}}); + } if (doDCAplotsD) { + histos.add("hDCADDaughters", "hDCADDaughters", kTH1D, {axisDCADaughters}); + histos.add("hDCADbarDaughters", "hDCADbarDaughters", kTH1D, {axisDCADaughters}); + histos.add("hDCADDaughters_Selected", "hDCADDaughters_Selected", kTH1D, {axisDCADaughters}); + histos.add("hDCADbarDaughters_Selected", "hDCADbarDaughters_Selected", kTH1D, {axisDCADaughters}); histos.add("h2dDCAxyVsPtPiPlusFromD", "h2dDCAxyVsPtPiPlusFromD", kTH2F, {axisPt, axisDCA}); histos.add("h2dDCAxyVsPtPiMinusFromD", "h2dDCAxyVsPtPiMinusFromD", kTH2F, {axisPt, axisDCA}); histos.add("h2dDCAxyVsPtKaPlusFromD", "h2dDCAxyVsPtKaPlusFromD", kTH2F, {axisPt, axisDCA}); histos.add("h2dDCAxyVsPtKaMinusFromD", "h2dDCAxyVsPtKaMinusFromD", kTH2F, {axisPt, axisDCA}); + if (doTopoPlotsForSAndB) { + histos.add("hDCADDaughters_Signal", "hDCADDaughters_Signal", kTH1D, {axisDCADaughters}); + histos.add("hDCADDaughters_Bkg", "hDCADDaughters_Bkg", kTH1D, {axisDCADaughters}); + histos.add("hDCADbarDaughters_Signal", "hDCADbarDaughters_Signal", kTH1D, {axisDCADaughters}); + histos.add("hDCADbarDaughters_Bkg", "hDCADbarDaughters_Bkg", kTH1D, {axisDCADaughters}); + } } } if (doprocessFindLcBaryons) { @@ -307,6 +455,8 @@ struct alice3decayFinder { histos.add("hMassLcbar", "hMassLcbar", kTH1F, {axisLcMass}); if (doDCAplotsD) { + histos.add("hDCALcDaughters", "hDCALcDaughters", kTH1D, {axisDCADaughters}); + histos.add("hDCALcbarDaughters", "hDCALcbarDaughters", kTH1D, {axisDCA}); histos.add("h2dDCAxyVsPtPiPlusFromLc", "h2dDCAxyVsPtPiPlusFromLc", kTH2F, {axisPt, axisDCA}); histos.add("h2dDCAxyVsPtPiMinusFromLc", "h2dDCAxyVsPtPiMinusFromLc", kTH2F, {axisPt, axisDCA}); histos.add("h2dDCAxyVsPtKaPlusFromLc", "h2dDCAxyVsPtKaPlusFromLc", kTH2F, {axisPt, axisDCA}); @@ -322,10 +472,40 @@ struct alice3decayFinder { { // no grouping for MC particles -> as intended if (doprocessFindDmesons) { - for (auto const& mcParticle : trueD) + for (auto const& mcParticle : trueD) { histos.fill(HIST("h2dGenD"), mcParticle.pt(), mcParticle.eta()); - for (auto const& mcParticle : trueDbar) + auto daughters = mcParticle.template daughters_as(); + if (daughters.size() != 2) + continue; + // int daugID[2]; + int daugPDG[2], i = 0; + for (const auto& dau : daughters) { + // daugID[i] = dau.globalIndex(); + daugPDG[i] = dau.pdgCode(); + i++; + } + if ((std::fabs(daugPDG[0]) == 321 && std::fabs(daugPDG[1]) == 211) || (std::fabs(daugPDG[0]) == 211 && std::fabs(daugPDG[1]) == 321)) { + histos.fill(HIST("h2dGenD_KpiOnly"), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hDGenForEfficiency"), mcParticle.pt(), mcParticle.y()); // in common for D and Dbar + } + } + for (auto const& mcParticle : trueDbar) { histos.fill(HIST("h2dGenDbar"), mcParticle.pt(), mcParticle.eta()); + auto daughters = mcParticle.template daughters_as(); + if (daughters.size() != 2) + continue; + // int daugID[2]; + int daugPDG[2], i = 0; + for (const auto& dau : daughters) { + // daugID[i] = dau.globalIndex(); + daugPDG[i] = dau.pdgCode(); + i++; + } + if ((std::fabs(daugPDG[0]) == 321 && std::fabs(daugPDG[1]) == 211) || (std::fabs(daugPDG[0]) == 211 && std::fabs(daugPDG[1]) == 321)) { + histos.fill(HIST("h2dGenDbar_KpiOnly"), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hDGenForEfficiency"), mcParticle.pt(), mcParticle.y()); // in common for D and Dbar + } + } } if (doprocessFindLcBaryons) { for (auto const& mcParticle : trueLc) @@ -336,7 +516,7 @@ struct alice3decayFinder { } //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - void processFindDmesons(aod::Collision const& collision, alice3tracks const&, aod::McParticles const&) + void processFindDmesons(aod::Collision const& collision, alice3tracks const&, aod::McParticles const& mcParticles) { // group with this collision auto tracksPiPlusFromDgrouped = tracksPiPlusFromD->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); @@ -355,26 +535,297 @@ struct alice3decayFinder { histos.fill(HIST("h2dDCAxyVsPtKaMinusFromD"), track.pt(), track.dcaXY() * 1e+4); } - // D mesons + // D0 mesons for (auto const& posTrackRow : tracksPiPlusFromDgrouped) { for (auto const& negTrackRow : tracksKaMinusFromDgrouped) { + if (mcSameMotherCheck && !checkSameMother(posTrackRow, negTrackRow)) continue; - if (!buildDecayCandidateTwoBody(posTrackRow, negTrackRow, o2::constants::physics::MassPionCharged, o2::constants::physics::MassKaonCharged)) + if (!buildDecayCandidateTwoBody(posTrackRow, negTrackRow, o2::constants::physics::MassPionCharged, o2::constants::physics::MassKaonCharged, mcParticles)) + continue; + + dmeson.cosPA = RecoDecay::cpa(std::array{collision.posX(), collision.posY(), collision.posZ()}, std::array{dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]}, std::array{dmeson.P[0], dmeson.P[1], dmeson.P[2]}); + dmeson.cosPAxy = RecoDecay::cpaXY(std::array{collision.posX(), collision.posY(), collision.posZ()}, std::array{dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]}, std::array{dmeson.P[0], dmeson.P[1], dmeson.P[2]}); + + const float dmesonCtau = 0.012301; + dmeson.normalizedDecayLength = ((dmeson.mass * std::fabs(std::hypot(collision.posX(), collision.posY(), collision.posZ()) - std::hypot(dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]))) / std::hypot(dmeson.P[0], dmeson.P[1], dmeson.P[2])) / dmesonCtau; + + auto impParXY_daugPos = RecoDecay::impParXY(std::array{collision.posX(), collision.posY(), collision.posZ()}, std::array{dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]}, std::array{dmeson.Pdaug[0], dmeson.Pdaug[1], dmeson.Pdaug[2]}); + auto impParXY_daugNeg = RecoDecay::impParXY(std::array{collision.posX(), collision.posY(), collision.posZ()}, std::array{dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]}, std::array{dmeson.Ndaug[0], dmeson.Ndaug[1], dmeson.Ndaug[2]}); + auto decayLength = std::hypot(collision.posX() - dmeson.posSV[0], collision.posY() - dmeson.posSV[1], collision.posZ() - dmeson.posSV[2]); + auto decayLengthXY = std::hypot(collision.posX() - dmeson.posSV[0], collision.posY() - dmeson.posSV[1]); + + // fill plots of topological variables before topological selection + histos.fill(HIST("hDCosPA"), dmeson.cosPA); + histos.fill(HIST("hDCosPAxy"), dmeson.cosPAxy); + histos.fill(HIST("hDCosThetaStar"), dmeson.cosThetaStar); + histos.fill(HIST("hDDecayLength"), decayLength); + histos.fill(HIST("hDDecayLengthXY"), decayLengthXY); + histos.fill(HIST("hDNormDecayLength"), dmeson.normalizedDecayLength); + histos.fill(HIST("hImpParPi"), impParXY_daugPos); + histos.fill(HIST("hImpParK"), impParXY_daugNeg); + histos.fill(HIST("hImpParProduct"), impParXY_daugPos * impParXY_daugNeg); + if (doDCAplotsD) + histos.fill(HIST("hDCADDaughters"), dmeson.dcaDau * 1e+4); + + if (doTopoPlotsForSAndB) { // fill plots of topological variables for S and B separately (reflections not considered here) + if (dmeson.mcTruth == 1) { // true D0 + histos.fill(HIST("hDCosPA_Signal"), dmeson.cosPA); + histos.fill(HIST("hDCosPAxy_Signal"), dmeson.cosPAxy); + histos.fill(HIST("hDCosThetaStar_Signal"), dmeson.cosThetaStar); + histos.fill(HIST("hDDecayLength_Signal"), decayLength); + histos.fill(HIST("hDDecayLengthXY_Signal"), decayLengthXY); + histos.fill(HIST("hDNormDecayLength_Signal"), dmeson.normalizedDecayLength); + histos.fill(HIST("hImpParPi_Signal"), impParXY_daugPos); + histos.fill(HIST("hImpParK_Signal"), impParXY_daugNeg); + histos.fill(HIST("hImpParProduct_Signal"), impParXY_daugPos * impParXY_daugNeg); + if (doDCAplotsD) + histos.fill(HIST("hDCADDaughters_Signal"), dmeson.dcaDau * 1e+4); + } else if (!dmeson.mcTruth) { // bkg D0 + histos.fill(HIST("hDCosPA_Bkg"), dmeson.cosPA); + histos.fill(HIST("hDCosPAxy_Bkg"), dmeson.cosPAxy); + histos.fill(HIST("hDCosThetaStar_Bkg"), dmeson.cosThetaStar); + histos.fill(HIST("hDDecayLength_Bkg"), decayLength); + histos.fill(HIST("hDDecayLengthXY_Bkg"), decayLengthXY); + histos.fill(HIST("hDNormDecayLength_Bkg"), dmeson.normalizedDecayLength); + histos.fill(HIST("hImpParPi_Bkg"), impParXY_daugPos); + histos.fill(HIST("hImpParK_Bkg"), impParXY_daugNeg); + histos.fill(HIST("hImpParProduct_Bkg"), impParXY_daugPos * impParXY_daugNeg); + if (doDCAplotsD) + histos.fill(HIST("hDCADDaughters_Bkg"), dmeson.dcaDau * 1e+4); + } + } + + if (dmeson.dcaDau > dcaDaughtersSelection) + continue; + + if (dmeson.pt <= lowPtDLimit && dmeson.cosPA < DCosPA) + continue; + else if (dmeson.pt > lowPtDLimit && dmeson.cosPA < DCosPAHighPt) + continue; + + if (dmeson.pt <= lowPtDLimit && dmeson.cosPAxy < DCosPAxy) + continue; + else if (dmeson.pt > lowPtDLimit && dmeson.cosPAxy < DCosPAxyHighPt) + continue; + + if (dmeson.pt <= lowPtDLimit && std::fabs(dmeson.cosThetaStar) > DCosThetaStarLowPt) + continue; + else if (dmeson.pt <= highPtDLimit && std::fabs(dmeson.cosThetaStar) > DCosThetaStarHighPt) + continue; + else if (dmeson.pt > highPtDLimit && std::fabs(dmeson.cosThetaStar) > DCosThetaStarVHighPt) + continue; + + if (dmeson.normalizedDecayLength < DMinNormDecayLength || dmeson.normalizedDecayLength > DMaxNormDecayLength) + continue; + + if (dmeson.ptdaugPos < minPtPi) // track1 (positive) is the pion + continue; + if (dmeson.ptdaugNeg < minPtK) // track2 (negative) is the kaon + continue; + + if (impParXY_daugPos > maxImpParPi) continue; + if (impParXY_daugNeg > maxImpParK) + continue; + if (impParXY_daugPos * impParXY_daugNeg > maxImpParProduct) + continue; + + if (decayLength < DMinDecayLength || decayLength > DMaxDecayLength) + continue; + if (decayLengthXY < DMinDecayLengthXY || decayLengthXY > DMaxDecayLengthXY) + continue; + auto decayLengthSquaredCut = std::min((std::hypot(dmeson.P[0], dmeson.P[1], dmeson.P[2]) * 0.0066) + 0.01, (double)DDecayLengthSquaredCut); + if (decayLength * decayLength < decayLengthSquaredCut * decayLengthSquaredCut) + continue; + + // fill plots of topological variables after topological selection + histos.fill(HIST("hDCosPA_Selected"), dmeson.cosPA); + histos.fill(HIST("hDCosPAxy_Selected"), dmeson.cosPAxy); + histos.fill(HIST("hDCosThetaStar_Selected"), dmeson.cosThetaStar); + histos.fill(HIST("hDDecayLength_Selected"), decayLength); + histos.fill(HIST("hDDecayLengthXY_Selected"), decayLengthXY); + histos.fill(HIST("hDNormDecayLength_Selected"), dmeson.normalizedDecayLength); + histos.fill(HIST("hImpParPi_Selected"), impParXY_daugPos); + histos.fill(HIST("hImpParK_Selected"), impParXY_daugNeg); + histos.fill(HIST("hImpParProduct_Selected"), impParXY_daugPos * impParXY_daugNeg); + if (doDCAplotsD) + histos.fill(HIST("hDCADDaughters_Selected"), dmeson.dcaDau * 1e+4); + + // filling of mass plots for selected candidates histos.fill(HIST("hMassD"), dmeson.mass); histos.fill(HIST("h3dRecD"), dmeson.pt, dmeson.eta, dmeson.mass); + if (dmeson.mcTruth == 1) { // true D0 meson, reco as D0 (= correct matching) + histos.fill(HIST("h3dRecDSig"), dmeson.pt, dmeson.eta, dmeson.mass); + histos.fill(HIST("hMassDSig"), dmeson.mass); + histos.fill(HIST("hDRecForEfficiency"), dmeson.pt, dmeson.y); // for efficiency + } else if (dmeson.mcTruth == 2) { // true D0bar meson, reco as D0 (= reflection) + histos.fill(HIST("hMassDRefl"), dmeson.mass); + histos.fill(HIST("h3dRecDRefl"), dmeson.pt, dmeson.eta, dmeson.mass); + } else { // background, reco as D0 + histos.fill(HIST("hMassDBkg"), dmeson.mass); + histos.fill(HIST("h3dRecDBkg"), dmeson.pt, dmeson.eta, dmeson.mass); + } + + // store D0 in output table + candidateD0meson(collision.globalIndex(), + dmeson.Pdaug[0], dmeson.Pdaug[1], dmeson.Pdaug[2], + dmeson.Ndaug[0], dmeson.Ndaug[1], dmeson.Ndaug[2], + dmeson.P[0], dmeson.P[1], dmeson.P[2], + dmeson.pt, + dmeson.mass, + dmeson.eta, + dmeson.phi, + dmeson.y); + selectionOutcome(1, 0); // isSelD0 true, isSelD0bar false + mcTruthOutcome(dmeson.mcTruth); } } - // D mesons + + // D0bar mesons for (auto const& posTrackRow : tracksKaPlusFromDgrouped) { for (auto const& negTrackRow : tracksPiMinusFromDgrouped) { + if (mcSameMotherCheck && !checkSameMother(posTrackRow, negTrackRow)) continue; - if (!buildDecayCandidateTwoBody(posTrackRow, negTrackRow, o2::constants::physics::MassKaonCharged, o2::constants::physics::MassPionCharged)) + if (!buildDecayCandidateTwoBody(posTrackRow, negTrackRow, o2::constants::physics::MassKaonCharged, o2::constants::physics::MassPionCharged, mcParticles)) + continue; + + dmeson.cosPA = RecoDecay::cpa(std::array{collision.posX(), collision.posY(), collision.posZ()}, std::array{dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]}, std::array{dmeson.P[0], dmeson.P[1], dmeson.P[2]}); + dmeson.cosPAxy = RecoDecay::cpaXY(std::array{collision.posX(), collision.posY(), collision.posZ()}, std::array{dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]}, std::array{dmeson.P[0], dmeson.P[1], dmeson.P[2]}); + + const float dmesonCtau = 0.012301; + dmeson.normalizedDecayLength = ((dmeson.mass * std::fabs(std::hypot(collision.posX(), collision.posY(), collision.posZ()) - std::hypot(dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]))) / std::hypot(dmeson.P[0], dmeson.P[1], dmeson.P[2])) / dmesonCtau; + + auto impParXY_daugPos = RecoDecay::impParXY(std::array{collision.posX(), collision.posY(), collision.posZ()}, std::array{dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]}, std::array{dmeson.Pdaug[0], dmeson.Pdaug[1], dmeson.Pdaug[2]}); + auto impParXY_daugNeg = RecoDecay::impParXY(std::array{collision.posX(), collision.posY(), collision.posZ()}, std::array{dmeson.posSV[0], dmeson.posSV[1], dmeson.posSV[2]}, std::array{dmeson.Ndaug[0], dmeson.Ndaug[1], dmeson.Ndaug[2]}); + auto decayLength = std::hypot(collision.posX() - dmeson.posSV[0], collision.posY() - dmeson.posSV[1], collision.posZ() - dmeson.posSV[2]); + auto decayLengthXY = std::hypot(collision.posX() - dmeson.posSV[0], collision.posY() - dmeson.posSV[1]); + + // fill plots of topological variables before topological selection + histos.fill(HIST("hDCosPA"), dmeson.cosPA); + histos.fill(HIST("hDCosPAxy"), dmeson.cosPAxy); + histos.fill(HIST("hDCosThetaStar"), dmeson.cosThetaStar); + histos.fill(HIST("hDDecayLength"), decayLength); + histos.fill(HIST("hDDecayLengthXY"), decayLengthXY); + histos.fill(HIST("hDNormDecayLength"), dmeson.normalizedDecayLength); + histos.fill(HIST("hImpParPi"), impParXY_daugNeg); + histos.fill(HIST("hImpParK"), impParXY_daugPos); + histos.fill(HIST("hImpParProduct"), impParXY_daugPos * impParXY_daugNeg); + if (doDCAplotsD) + histos.fill(HIST("hDCADbarDaughters"), dmeson.dcaDau * 1e+4); + + if (doTopoPlotsForSAndB) { // fill plots of topological variables for S and B separately (reflections not considered here) + if (dmeson.mcTruth == 2) { // true D0bar + histos.fill(HIST("hDCosPA_Signal"), dmeson.cosPA); + histos.fill(HIST("hDCosPAxy_Signal"), dmeson.cosPAxy); + histos.fill(HIST("hDCosThetaStar_Signal"), dmeson.cosThetaStar); + histos.fill(HIST("hDDecayLength_Signal"), decayLength); + histos.fill(HIST("hDDecayLengthXY_Signal"), decayLengthXY); + histos.fill(HIST("hDNormDecayLength_Signal"), dmeson.normalizedDecayLength); + histos.fill(HIST("hImpParPi_Signal"), impParXY_daugNeg); + histos.fill(HIST("hImpParK_Signal"), impParXY_daugPos); + histos.fill(HIST("hImpParProduct_Signal"), impParXY_daugPos * impParXY_daugNeg); + if (doDCAplotsD) + histos.fill(HIST("hDCADbarDaughters_Signal"), dmeson.dcaDau * 1e+4); + } else if (!dmeson.mcTruth) { // bkg D0bar + histos.fill(HIST("hDCosPA_Bkg"), dmeson.cosPA); + histos.fill(HIST("hDCosPAxy_Bkg"), dmeson.cosPAxy); + histos.fill(HIST("hDCosThetaStar_Bkg"), dmeson.cosThetaStar); + histos.fill(HIST("hDDecayLength_Bkg"), decayLength); + histos.fill(HIST("hDDecayLengthXY_Bkg"), decayLengthXY); + histos.fill(HIST("hDNormDecayLength_Bkg"), dmeson.normalizedDecayLength); + histos.fill(HIST("hImpParPi_Bkg"), impParXY_daugNeg); + histos.fill(HIST("hImpParK_Bkg"), impParXY_daugPos); + histos.fill(HIST("hImpParProduct_Bkg"), impParXY_daugPos * impParXY_daugNeg); + } + if (doDCAplotsD) + histos.fill(HIST("hDCADbarDaughters_Bkg"), dmeson.dcaDau * 1e+4); + } + + if (dmeson.dcaDau > dcaDaughtersSelection) + continue; + + if (dmeson.pt <= lowPtDLimit && dmeson.cosPA < DCosPA) + continue; + else if (dmeson.pt > lowPtDLimit && dmeson.cosPA < DCosPAHighPt) + continue; + + if (dmeson.pt <= lowPtDLimit && dmeson.cosPAxy < DCosPAxy) + continue; + else if (dmeson.pt > lowPtDLimit && dmeson.cosPAxy < DCosPAxyHighPt) + continue; + + if (dmeson.pt <= highPtDLimit && std::fabs(dmeson.cosThetaStar) > DCosThetaStarLowPt) + continue; + else if (dmeson.pt <= highPtDLimit && std::fabs(dmeson.cosThetaStar) > DCosThetaStarHighPt) + continue; + else if (dmeson.pt > highPtDLimit && std::fabs(dmeson.cosThetaStar) > DCosThetaStarVHighPt) continue; + + if (dmeson.normalizedDecayLength < DMinNormDecayLength || dmeson.normalizedDecayLength > DMaxNormDecayLength) + continue; + + if (dmeson.ptdaugPos < minPtK) // track1 is the kaon + continue; + if (dmeson.ptdaugNeg < minPtPi) // track2 is the pion + continue; + + if (impParXY_daugPos > maxImpParK) + continue; + if (impParXY_daugNeg > maxImpParPi) + continue; + if (impParXY_daugPos * impParXY_daugNeg > maxImpParProduct) + continue; + + if (decayLength < DMinDecayLength || decayLength > DMaxDecayLength) + continue; + if (decayLengthXY < DMinDecayLengthXY || decayLengthXY > DMaxDecayLengthXY) + continue; + auto decayLengthSquaredCut = std::min((std::hypot(dmeson.P[0], dmeson.P[1], dmeson.P[2]) * 0.0066) + 0.01, (double)DDecayLengthSquaredCut); + if (decayLength * decayLength < decayLengthSquaredCut * decayLengthSquaredCut) + continue; + + // fill plots of topological variables after topological selection + histos.fill(HIST("hDCosPA_Selected"), dmeson.cosPA); + histos.fill(HIST("hDCosPAxy_Selected"), dmeson.cosPAxy); + histos.fill(HIST("hDCosThetaStar_Selected"), dmeson.cosThetaStar); + histos.fill(HIST("hDDecayLength_Selected"), decayLength); + histos.fill(HIST("hDDecayLengthXY_Selected"), decayLengthXY); + histos.fill(HIST("hDNormDecayLength_Selected"), dmeson.normalizedDecayLength); + histos.fill(HIST("hImpParK_Selected"), impParXY_daugPos); + histos.fill(HIST("hImpParPi_Selected"), impParXY_daugNeg); + histos.fill(HIST("hImpParProduct_Selected"), impParXY_daugPos * impParXY_daugNeg); + if (doDCAplotsD) + histos.fill(HIST("hDCADbarDaughters_Selected"), dmeson.dcaDau * 1e+4); + + // filling of mass plots for selected candidates histos.fill(HIST("hMassDbar"), dmeson.mass); histos.fill(HIST("h3dRecDbar"), dmeson.pt, dmeson.eta, dmeson.mass); + if (dmeson.mcTruth == 2) { // true D0bar meson, reco as D0bar (= correct matching) + histos.fill(HIST("h3dRecDbarSig"), dmeson.pt, dmeson.eta, dmeson.mass); + histos.fill(HIST("hMassDbarSig"), dmeson.mass); + histos.fill(HIST("hDRecForEfficiency"), dmeson.pt, dmeson.y); // for efficiency + } else if (dmeson.mcTruth == 1) { // true D0 meson, reco as D0bar (= reflection) + histos.fill(HIST("hMassDbarRefl"), dmeson.mass); + histos.fill(HIST("h3dRecDbarRefl"), dmeson.pt, dmeson.eta, dmeson.mass); + } else { // background, reco as D0 + histos.fill(HIST("hMassDbarBkg"), dmeson.mass); + histos.fill(HIST("h3dRecDbarBkg"), dmeson.pt, dmeson.eta, dmeson.mass); + } + + // store D0bar in output table + candidateD0meson(collision.globalIndex(), + dmeson.Pdaug[0], dmeson.Pdaug[1], dmeson.Pdaug[2], + dmeson.Ndaug[0], dmeson.Ndaug[1], dmeson.Ndaug[2], + dmeson.P[0], dmeson.P[1], dmeson.P[2], + dmeson.pt, + dmeson.mass, + dmeson.eta, + dmeson.phi, + dmeson.y); + selectionOutcome(0, 1); // isSelD0 true, isSelD0bar false + mcTruthOutcome(dmeson.mcTruth); } } } @@ -417,6 +868,7 @@ struct alice3decayFinder { continue; if (!buildDecayCandidateThreeBody(proton, kaon, pion, o2::constants::physics::MassProton, o2::constants::physics::MassKaonCharged, o2::constants::physics::MassPionCharged)) continue; + histos.fill(HIST("hDCALcDaughters"), lcbaryon.dcaDau * 1e+4); histos.fill(HIST("hMassLc"), lcbaryon.mass); histos.fill(HIST("h3dRecLc"), lcbaryon.pt, lcbaryon.eta, lcbaryon.mass); } @@ -432,6 +884,7 @@ struct alice3decayFinder { continue; if (!buildDecayCandidateThreeBody(proton, kaon, pion, o2::constants::physics::MassProton, o2::constants::physics::MassKaonCharged, o2::constants::physics::MassPionCharged)) continue; + histos.fill(HIST("hDCALcbarDaughters"), lcbaryon.dcaDau * 1e+4); histos.fill(HIST("hMassLcbar"), lcbaryon.mass); histos.fill(HIST("h3dRecLcbar"), lcbaryon.pt, lcbaryon.eta, lcbaryon.mass); } diff --git a/ALICE3/TableProducer/alice3-decaypreselector.cxx b/ALICE3/TableProducer/alice3-decaypreselector.cxx index 66569360db9..527d1c1d197 100644 --- a/ALICE3/TableProducer/alice3-decaypreselector.cxx +++ b/ALICE3/TableProducer/alice3-decaypreselector.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "Framework/runDataProcessing.h" @@ -44,7 +45,7 @@ #include "CCDB/BasicCCDBManager.h" #include "DataFormatsCalibration/MeanVertexObject.h" #include "ALICE3/DataModel/OTFTOF.h" -#include "ALICE3/DataModel/RICH.h" +#include "ALICE3/DataModel/OTFRICH.h" #include "ALICE3/DataModel/A3DecayFinderTables.h" using namespace o2; @@ -62,7 +63,7 @@ using FullTracksExt = soa::Join; // For MC association in pre-selection using labeledTracks = soa::Join; using tofTracks = soa::Join; -using richTracks = soa::Join; +using richTracks = soa::Join; struct alice3decaypreselector { Produces a3decayMaps; @@ -111,9 +112,9 @@ struct alice3decaypreselector { Partition pOuterTOFPi = nabs(aod::upgrade_tof::nSigmaPionOuterTOF) > nSigmaTOF; Partition pOuterTOFKa = nabs(aod::upgrade_tof::nSigmaKaonOuterTOF) > nSigmaTOF; Partition pOuterTOFPr = nabs(aod::upgrade_tof::nSigmaProtonOuterTOF) > nSigmaTOF; - Partition pRICHPi = nabs(aod::alice3rich::richNsigmaPi) > nSigmaRICH; - Partition pRICHKa = nabs(aod::alice3rich::richNsigmaKa) > nSigmaRICH; - Partition pRICHPr = nabs(aod::alice3rich::richNsigmaPr) > nSigmaRICH; + Partition pRICHPi = aod::upgrade_rich::hasSig && aod::upgrade_rich::hasSigPi && nabs(aod::upgrade_rich::nSigmaPionRich) > nSigmaRICH; + Partition pRICHKa = aod::upgrade_rich::hasSig && aod::upgrade_rich::hasSigKa && nabs(aod::upgrade_rich::nSigmaKaonRich) > nSigmaRICH; + Partition pRICHPr = aod::upgrade_rich::hasSig && aod::upgrade_rich::hasSigPr && nabs(aod::upgrade_rich::nSigmaProtonRich) > nSigmaRICH; //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* /// Initialization of mask vectors if uninitialized diff --git a/ALICE3/TableProducer/alice3-multicharm.cxx b/ALICE3/TableProducer/alice3-multicharmTable.cxx similarity index 63% rename from ALICE3/TableProducer/alice3-multicharm.cxx rename to ALICE3/TableProducer/alice3-multicharmTable.cxx index 71be5256362..f667b5dcd0a 100644 --- a/ALICE3/TableProducer/alice3-multicharm.cxx +++ b/ALICE3/TableProducer/alice3-multicharmTable.cxx @@ -17,41 +17,43 @@ // HF decays. Work in progress: use at your own risk! // -#include -#include -#include -#include -#include -#include +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "DCAFitter/DCAFitterN.h" -#include "ReconstructionDataFormats/Track.h" +#include "ALICE3/DataModel/A3DecayFinderTables.h" +#include "ALICE3/DataModel/OTFMulticharm.h" +#include "ALICE3/DataModel/OTFRICH.h" +#include "ALICE3/DataModel/OTFStrangeness.h" +#include "ALICE3/DataModel/OTFTOF.h" +#include "ALICE3/DataModel/tracksAlice3.h" #include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/LFParticleIdentification.h" #include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" + #include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DCAFitter/DCAFitterN.h" #include "DataFormatsCalibration/MeanVertexObject.h" -#include "ALICE3/DataModel/OTFTOF.h" -#include "ALICE3/DataModel/RICH.h" -#include "ALICE3/DataModel/A3DecayFinderTables.h" -#include "ALICE3/DataModel/OTFStrangeness.h" -#include "ALICE3/DataModel/OTFMulticharm.h" -#include "ALICE3/DataModel/tracksAlice3.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" #include "DetectorsVertexing/PVertexer.h" #include "DetectorsVertexing/PVertexerHelpers.h" -#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -68,47 +70,77 @@ using FullTracksExt = soa::Join; // For MC association in pre-selection using labeledTracks = soa::Join; using tofTracks = soa::Join; -using richTracks = soa::Join; -using alice3tracks = soa::Join; +using richTracks = soa::Join; +using alice3tracks = soa::Join; -struct alice3multicharm { +struct alice3multicharmTable { SliceCache cache; Produces multiCharmIdx; Produces multiCharmCore; + Produces multiCharmPID; + Produces multiCharmExtra; // Operation and minimisation criteria Configurable fillDerivedTable{"fillDerivedTable", false, "fill MCharm[] tables (careful: memory)"}; Configurable magneticField{"magneticField", 20.0f, "Magnetic field (in kilogauss)"}; Configurable doDCAplots{"doDCAplots", true, "do daughter prong DCA plots for D mesons"}; Configurable mcSameMotherCheck{"mcSameMotherCheck", true, "check if tracks come from the same MC mother"}; - Configurable dcaXiCDaughtersSelection{"dcaXiCDaughtersSelection", 200.0f, "DCA between XiC daughters (cm)"}; - Configurable dcaXiCCDaughtersSelection{"dcaXiCCDaughtersSelection", 200.0f, "DCA between XiCC daughters (cm)"}; + Configurable dcaXiCDaughtersSelection{"dcaXiCDaughtersSelection", 0.002f, "DCA between XiC daughters (cm)"}; + Configurable dcaXiCCDaughtersSelection{"dcaXiCCDaughtersSelection", 0.002f, "DCA between XiCC daughters (cm)"}; Configurable piFromXiC_dcaXYconstant{"piFromXiC_dcaXYconstant", 0.001f, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable piFromXiC_dcaZconstant{"piFromXiC_dcaZconstant", 0.001f, "[0] in |DCAxy| > [0]+[1]/pT"}; Configurable piFromXiC_dcaXYpTdep{"piFromXiC_dcaXYpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + Configurable piFromXiC_dcaZpTdep{"piFromXiC_dcaZpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + Configurable piFromXiC_tofDiffInner{"piFromXiC_tofDiffInner", 50, "|signal - expected| (ps)"}; + Configurable piFromXiCC_tofDiffInner{"piFromXiCC_tofDiffInner", 50, "|signal - expected| (ps)"}; Configurable piFromXiCC_dcaXYconstant{"piFromXiCC_dcaXYconstant", 0.001f, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable piFromXiCC_dcaZconstant{"piFromXiCC_dcaZconstant", 0.001f, "[0] in |DCAxy| > [0]+[1]/pT"}; Configurable piFromXiCC_dcaXYpTdep{"piFromXiCC_dcaXYpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + Configurable piFromXiCC_dcaZpTdep{"piFromXiCC_dcaZpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; Configurable xiFromXiC_dcaXYconstant{"xiFromXiC_dcaXYconstant", 0.001f, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable xiFromXiC_dcaZconstant{"xiFromXiC_dcaZconstant", 0.001f, "[0] in |DCAxy| > [0]+[1]/pT"}; Configurable xiFromXiC_dcaXYpTdep{"xiFromXiC_dcaXYpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + Configurable xiFromXiC_dcaZpTdep{"xiFromXiC_dcaZpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + + Configurable xiCFromXiCC_dcaXY{"xiCFromXiCC_dcaXY", 0.0015f, "maxDCA"}; + Configurable xiCFromXiCC_dcaZ{"xiCFromXiCC_dcaZ", 0.0015f, "maxDCA"}; + Configurable xiCC_dcaXY{"xiCC_dcaXY", 0.002f, "maxDCA"}; + Configurable xiCC_dcaZ{"xiCC_dcaZ", 0.002f, "maxDCA"}; Configurable minPiCPt{"minPiCPt", 0.15, "Minimum pT for XiC pions"}; Configurable minPiCCPt{"minPiCCPt", 0.3, "Minimum pT for XiCC pions"}; + Configurable minNTracks{"minNTracks", -1, "Minimum number of tracks"}; + Configurable minXiRadius{"minXiRadius", 0.5, "Minimum R2D for XiC decay (cm)"}; Configurable minXiCRadius{"minXiCRadius", 0.001, "Minimum R2D for XiC decay (cm)"}; - Configurable massWindowXi{"massWindowXi", 0.015, "Mass window around Xi peak"}; - Configurable massWindowXiC{"massWindowXiC", 0.015, "Mass window around XiC peak"}; + Configurable minXiCCRadius{"minXiCCRadius", 0.005, "Minimum R2D for XiCC decay (cm)"}; + Configurable xicMinDecayDistanceFromPV{"xicMinDecayDistanceFromPV", 0.002, "Minimum distance for XiC decay from PV (cm)"}; + Configurable xicMinProperLength{"xicMinProperLength", 0.002, "Minimum proper length for XiC decay (cm)"}; + Configurable xicMaxProperLength{"xicMaxProperLength", 0.06, "Minimum proper length for XiC decay (cm)"}; + Configurable xiccMinProperLength{"xiccMinProperLength", 0.004, "Minimum proper length for XiCC decay (cm)"}; + Configurable xiccMaxProperLength{"xiccMaxProperLength", 999, "Minimum proper length for XiCC decay (cm)"}; + Configurable xiccMaxEta{"xiccMaxEta", 1.5, "Max eta"}; + Configurable massWindowXi{"massWindowXi", 0.015, "Mass window around Xi peak (GeV/c)"}; + Configurable massWindowXiC{"massWindowXiC", 0.015, "Mass window around XiC peak (GeV/c)"}; ConfigurableAxis axisEta{"axisEta", {80, -4.0f, +4.0f}, "#eta"}; ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for QA histograms"}; - ConfigurableAxis axisDCA{"axisDCA", {200, -100, 100}, "DCA (#mum)"}; + ConfigurableAxis axisDCA2D{"axisDCA2D", {400, -200, 200}, "DCA2d (#mum)"}; + ConfigurableAxis axisDCA{"axisDCA", {400, 0, 400}, "DCA (#mum)"}; + ConfigurableAxis axisRadius{"axisRadius", {10000, 0, 10000}, "Decay radius (#mum)"}; + ConfigurableAxis axisRadius2D{"axisRadius2D", {1000, 0, 100000}, "Decay radius (#mum)"}; + ConfigurableAxis axisRadius2DXi{"axisRadius2DXi", {1000, 0, 20}, "Decay radius (cm)"}; + ConfigurableAxis axisDecayLength{"axisDecayLength", {2000, 0, 2000}, "Decay lenght (#mum)"}; + ConfigurableAxis axisTOFTrack{"axisTOFTrack", {1000, 0, 5000}, "TOF track time"}; ConfigurableAxis axisXiMass{"axisXiMass", {200, 1.221f, 1.421f}, "Xi Inv Mass (GeV/c^{2})"}; ConfigurableAxis axisXiCMass{"axisXiCMass", {200, 2.368f, 2.568f}, "XiC Inv Mass (GeV/c^{2})"}; ConfigurableAxis axisXiCCMass{"axisXiCCMass", {200, 3.521f, 3.721f}, "XiCC Inv Mass (GeV/c^{2})"}; - ConfigurableAxis axisDCAXiCDaughters{"axisDCAXiCDaughters", {200, 0, 100}, "DCA (cm)"}; - ConfigurableAxis axisDCAXiCCDaughters{"axisDCAXiCCDaughters", {200, 0, 100}, "DCA (cm)"}; + ConfigurableAxis axisDCAXiCDaughters{"axisDCAXiCDaughters", {200, 0, 100}, "DCA (mum)"}; + ConfigurableAxis axisDCAXiCCDaughters{"axisDCAXiCCDaughters", {200, 0, 100}, "DCA (mum)"}; ConfigurableAxis axisNConsidered{"axisNConsidered", {200, -0.5f, 199.5f}, "Number of considered track combinations"}; @@ -127,9 +159,9 @@ struct alice3multicharm { // partitions for Xi daughters Partition tracksPiFromXiC = - ((aod::a3DecayMap::decayMap & trackSelectionPiFromXiC) == trackSelectionPiFromXiC) && aod::track::signed1Pt > 0.0f && 1.0f / nabs(aod::track::signed1Pt) > minPiCPt&& nabs(aod::track::dcaXY) > piFromXiC_dcaXYconstant + piFromXiC_dcaXYpTdep* nabs(aod::track::signed1Pt); - Partition tracksPiFromXiCC = - ((aod::a3DecayMap::decayMap & trackSelectionPiFromXiCC) == trackSelectionPiFromXiCC) && aod::track::signed1Pt > 0.0f && 1.0f / nabs(aod::track::signed1Pt) > minPiCCPt&& nabs(aod::track::dcaXY) > piFromXiCC_dcaXYconstant + piFromXiCC_dcaXYpTdep* nabs(aod::track::signed1Pt); + ((aod::a3DecayMap::decayMap & trackSelectionPiFromXiC) == trackSelectionPiFromXiC) && aod::track::signed1Pt > 0.0f && 1.0f / nabs(aod::track::signed1Pt) > minPiCPt&& nabs(aod::track::dcaXY) > piFromXiC_dcaXYconstant + piFromXiC_dcaXYpTdep* nabs(aod::track::signed1Pt) && nabs(aod::track::dcaZ) > piFromXiC_dcaZconstant + piFromXiC_dcaZpTdep* nabs(aod::track::signed1Pt); + + Partition tracksPiFromXiCC = ((aod::a3DecayMap::decayMap & trackSelectionPiFromXiCC) == trackSelectionPiFromXiCC) && aod::track::signed1Pt > 0.0f && 1.0f / nabs(aod::track::signed1Pt) > minPiCCPt&& nabs(aod::track::dcaXY) > piFromXiCC_dcaXYconstant + piFromXiCC_dcaXYpTdep* nabs(aod::track::signed1Pt); // Helper struct to pass candidate information struct { @@ -293,6 +325,13 @@ struct alice3multicharm { return true; } + template + int getPdgCodeForTrack(TTrackType track) + { + auto mcParticle = track.template mcParticle_as(); + return mcParticle.pdgCode(); + } + /// function to check if tracks have the same mother in MC template bool checkSameMother(TTrackType1 const& track1, TTrackType2 const& track2) @@ -384,22 +423,50 @@ struct alice3multicharm { histos.add("hEtaXiCC", "hEtaXiCC", kTH1D, {axisEta}); histos.add("hPtXiCC", "hPtXiCC", kTH1D, {axisPt}); - histos.add("hMcPtXiCC", "hMcPtXiCC", kTH1D, {axisPt}); histos.add("h3dMassXiCC", "h3dMassXiCC", kTH3D, {axisPt, axisEta, axisXiCCMass}); histos.add("hDCAXiCDaughters", "hDCAXiCDaughters", kTH1D, {axisDCAXiCDaughters}); histos.add("hDCAXiCCDaughters", "hDCAXiCCDaughters", kTH1D, {axisDCAXiCCDaughters}); + histos.add("hDCAxyXi", "hDCAxyXi", kTH1D, {axisDCA}); + histos.add("hDCAzXi", "hDCAzXi", kTH1D, {axisDCA}); + + histos.add("hDCAxyXiC", "hDCAxyXiC", kTH1D, {axisDCA}); + histos.add("hDCAzXiC", "hDCAzXiC", kTH1D, {axisDCA}); + + histos.add("hDCAxyXiCC", "hDCAxyXiCC", kTH1D, {axisDCA}); + histos.add("hDCAzXiCC", "hDCAzXiCC", kTH1D, {axisDCA}); + + histos.add("hPi1cPt", "hPi1cPt", kTH1D, {axisPt}); + histos.add("hPi2cPt", "hPi2cPt", kTH1D, {axisPt}); + histos.add("hPiccPt", "hPiccPt", kTH1D, {axisPt}); + + histos.add("hMinXiDecayRadius", "hMinXiDecayRadius", kTH1D, {axisRadius2DXi}); + histos.add("hMinXiCDecayRadius", "hMinXiCDecayRadius", kTH1D, {axisRadius}); + histos.add("hMinXiCCDecayRadius", "hMinXiCCDecayRadius", kTH1D, {axisRadius}); + + histos.add("hMinxicDecayDistanceFromPV", "hMinxicDecayDistanceFromPV", kTH1D, {axisDecayLength}); + histos.add("hProperLengthXiC", "hProperLengthXiC", kTH1D, {axisDecayLength}); + histos.add("hProperLengthXiCC", "hProperLengthXiCC", kTH1D, {axisDecayLength}); + + histos.add("hInnerTOFTrackTimeRecoPi1c", "hInnerTOFTrackTimeRecoPi1c", kTH1D, {axisTOFTrack}); + histos.add("hInnerTOFTrackTimeRecoPi2c", "hInnerTOFTrackTimeRecoPi2c", kTH1D, {axisTOFTrack}); + histos.add("hInnerTOFTrackTimeRecoPicc", "hInnerTOFTrackTimeRecoPicc", kTH1D, {axisTOFTrack}); + + histos.add("hXiRadiusVsXicRadius", "hXiRadiusVsXicRadius", kTH2D, {axisRadius2D, axisRadius2D}); + histos.add("hXicRadiusVsXiccRadius", "hXicRadiusVsXiccRadius", kTH2D, {axisRadius2D, axisRadius2D}); // These histograms bookkeep the exact number of combinations attempted // CombinationsXiC: triplets Xi-pi-pi considered per Xi // CombinationsXiCC: doublets XiC-pi considered per XiC histos.add("hCombinationsXiC", "hCombinationsXiC", kTH1D, {axisNConsidered}); histos.add("hCombinationsXiCC", "hCombinationsXiCC", kTH1D, {axisNConsidered}); + histos.add("hNCollisions", "hNCollisions", kTH1D, {{2, 0.5, 2.5}}); + histos.add("hNTracks", "hNTracks", kTH1D, {{20000, 0, 20000}}); if (doDCAplots) { - histos.add("h2dDCAxyVsPtXiFromXiC", "h2dDCAxyVsPtXiFromXiC", kTH2D, {axisPt, axisDCA}); - histos.add("h2dDCAxyVsPtPiFromXiC", "h2dDCAxyVsPtPiFromXiC", kTH2D, {axisPt, axisDCA}); - histos.add("h2dDCAxyVsPtPiFromXiCC", "h2dDCAxyVsPtPiFromXiCC", kTH2D, {axisPt, axisDCA}); + histos.add("h2dDCAxyVsPtXiFromXiC", "h2dDCAxyVsPtXiFromXiC", kTH2D, {axisPt, axisDCA2D}); + histos.add("h2dDCAxyVsPtPiFromXiC", "h2dDCAxyVsPtPiFromXiC", kTH2D, {axisPt, axisDCA2D}); + histos.add("h2dDCAxyVsPtPiFromXiCC", "h2dDCAxyVsPtPiFromXiCC", kTH2D, {axisPt, axisDCA2D}); } } @@ -412,13 +479,20 @@ struct alice3multicharm { histos.fill(HIST("h2dGenXiC"), mcParticle.pt(), mcParticle.eta()); for (auto const& mcParticle : trueXiCC) { histos.fill(HIST("h2dGenXiCC"), mcParticle.pt(), mcParticle.eta()); - histos.fill(HIST("hMcPtXiCC"), mcParticle.pt()); } } //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* void processFindXiCC(aod::Collision const& collision, alice3tracks const& tracks, aod::McParticles const&, aod::UpgradeCascades const& cascades) { + histos.fill(HIST("hNCollisions"), 1); + histos.fill(HIST("hNTracks"), tracks.size()); + + if (tracks.size() < minNTracks) + return; + + histos.fill(HIST("hNCollisions"), 2); + // group with this collision // n.b. cascades do not need to be grouped, being used directly in iterator-grouping auto tracksPiFromXiCgrouped = tracksPiFromXiC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); @@ -444,11 +518,11 @@ struct alice3multicharm { for (auto const& xiCand : cascades) { histos.fill(HIST("hMassXi"), xiCand.mXi()); - if (std::abs(xiCand.mXi() - o2::constants::physics::MassXiMinus) > massWindowXi) + if (std::fabs(xiCand.mXi() - o2::constants::physics::MassXiMinus) > massWindowXi) continue; // out of mass region uint32_t nCombinationsC = 0; - auto xi = xiCand.cascadeTrack_as(); // de-reference cascade track + auto xi = xiCand.cascadeTrack_as(); // de-reference cascade track auto piFromXi = xiCand.bachTrack_as(); // de-reference bach track auto piFromLa = xiCand.negTrack_as(); // de-reference neg track auto prFromLa = xiCand.posTrack_as(); // de-reference pos track @@ -456,36 +530,66 @@ struct alice3multicharm { if (!bitcheck(xi.decayMap(), kTrueXiFromXiC)) continue; + if (std::fabs(xi.dcaXY()) < xiFromXiC_dcaXYconstant || std::fabs(xi.dcaZ()) < xiFromXiC_dcaZconstant) + continue; // likely a primary xi + + histos.fill(HIST("hDCAxyXi"), std::fabs(xi.dcaXY() * 1e+4)); + histos.fill(HIST("hDCAzXi"), std::fabs(xi.dcaZ() * 1e+4)); + + if (xiCand.cascRadius() < minXiRadius) + continue; + + histos.fill(HIST("hMinXiDecayRadius"), xiCand.cascRadius()); for (auto const& pi1c : tracksPiFromXiCgrouped) { if (mcSameMotherCheck && !checkSameMother(xi, pi1c)) continue; if (xiCand.posTrackId() == pi1c.globalIndex() || xiCand.negTrackId() == pi1c.globalIndex() || xiCand.bachTrackId() == pi1c.globalIndex()) continue; // avoid using any track that was already used + if (pi1c.pt() < minPiCPt) - continue; + continue; // too low momentum + histos.fill(HIST("hPi1cPt"), pi1c.pt()); + float pi1cTOFDiffInner = std::fabs(pi1c.innerTOFTrackTimeReco() - pi1c.innerTOFExpectedTimePi()); + float pi1cTOFDiffOuter = std::fabs(pi1c.outerTOFTrackTimeReco() - pi1c.outerTOFExpectedTimePi()); + if (pi1cTOFDiffInner > piFromXiC_tofDiffInner) + continue; // did not arrive at expected time + + histos.fill(HIST("hInnerTOFTrackTimeRecoPi1c"), pi1cTOFDiffInner); // second pion from XiC decay for starts here for (auto const& pi2c : tracksPiFromXiCgrouped) { - if (mcSameMotherCheck && !checkSameMother(xi, pi2c)) continue; // keep only if same mother + if (pi1c.globalIndex() >= pi2c.globalIndex()) continue; // avoid same-mother, avoid double-counting + if (xiCand.posTrackId() == pi2c.globalIndex() || xiCand.negTrackId() == pi2c.globalIndex() || xiCand.bachTrackId() == pi2c.globalIndex()) continue; // avoid using any track that was already used + if (pi2c.pt() < minPiCPt) - continue; + continue; // too low momentum + histos.fill(HIST("hPi2cPt"), pi2c.pt()); + float pi2cTOFDiffInner = std::fabs(pi2c.innerTOFTrackTimeReco() - pi2c.innerTOFExpectedTimePi()); + float pi2cTOFDiffOuter = std::fabs(pi2c.outerTOFTrackTimeReco() - pi2c.outerTOFExpectedTimePi()); + if (pi2cTOFDiffInner > piFromXiC_tofDiffInner) + continue; // did not arrive at expected time + + histos.fill(HIST("hInnerTOFTrackTimeRecoPi2c"), pi2cTOFDiffInner); // if I am here, it means this is a triplet to be considered for XiC vertexing. // will now attempt to build a three-body decay candidate with these three track rows. nCombinationsC++; histos.fill(HIST("hCharmBuilding"), 0.0f); - if (!buildDecayCandidateThreeBody(xi, pi1c, pi2c, 1.32171, 0.139570, 0.139570)) + if (!buildDecayCandidateThreeBody(xi, pi1c, pi2c, o2::constants::physics::MassXiMinus, o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged)) continue; // failed at building candidate - if (std::abs(thisXiCcandidate.mass - o2::constants::physics::MassXiCPlus) > massWindowXiC) + histos.fill(HIST("hDCAXiCDaughters"), thisXiCcandidate.dca * 1e+4); + + if (std::fabs(thisXiCcandidate.mass - o2::constants::physics::MassXiCPlus) > massWindowXiC) continue; // out of mass region + histos.fill(HIST("hCharmBuilding"), 1.0f); const std::array momentumC = { @@ -494,46 +598,63 @@ struct alice3multicharm { thisXiCcandidate.prong0mom[2] + thisXiCcandidate.prong1mom[2] + thisXiCcandidate.prong2mom[2]}; o2::track::TrackParCov xicTrack(thisXiCcandidate.xyz, momentumC, thisXiCcandidate.parentTrackCovMatrix, +1); - - if (std::hypot(thisXiCcandidate.xyz[0], thisXiCcandidate.xyz[1]) < minXiCRadius) + float xicDecayRadius2D = std::hypot(thisXiCcandidate.xyz[0], thisXiCcandidate.xyz[1]); + if (xicDecayRadius2D < minXiCRadius) continue; // do not take if radius too small, likely a primary combination + histos.fill(HIST("hMinXiCDecayRadius"), xicDecayRadius2D * 1e+4); + + if (xicDecayRadius2D > xiCand.cascRadius()) + continue; + + histos.fill(HIST("hXiRadiusVsXicRadius"), xiCand.cascRadius() * 1e+4, xicDecayRadius2D * 1e+4); + o2::dataformats::DCA dcaInfo; - float xicdcaXY = 1e+10; + float xicdcaXY = 1e+10, xicdcaZ = 1e+10; o2::track::TrackParCov xicTrackCopy(xicTrack); // paranoia - o2::vertexing::PVertex primaryVertex; primaryVertex.setXYZ(collision.posX(), collision.posY(), collision.posZ()); if (xicTrackCopy.propagateToDCA(primaryVertex, magneticField, &dcaInfo)) { xicdcaXY = dcaInfo.getY(); + xicdcaZ = dcaInfo.getZ(); } + if (std::fabs(xicdcaXY) < xiCFromXiCC_dcaXY || std::fabs(xicdcaZ) < xiCFromXiCC_dcaZ) + continue; // likely a primary xic + + histos.fill(HIST("hDCAxyXiC"), std::fabs(xicdcaXY * 1e+4)); + histos.fill(HIST("hDCAzXiC"), std::fabs(xicdcaZ * 1e+4)); histos.fill(HIST("hMassXiC"), thisXiCcandidate.mass); - histos.fill(HIST("hDCAXiCDaughters"), thisXiCcandidate.dca); // attempt XiCC finding uint32_t nCombinationsCC = 0; for (auto const& picc : tracksPiFromXiCCgrouped) { + if (mcSameMotherCheck && !checkSameMotherExtra(xi, picc)) + continue; if (xiCand.posTrackId() == picc.globalIndex() || xiCand.negTrackId() == picc.globalIndex() || xiCand.bachTrackId() == picc.globalIndex()) continue; // avoid using any track that was already used + if (picc.pt() < minPiCCPt) - continue; - if (mcSameMotherCheck && !checkSameMotherExtra(xi, picc)) - continue; + continue; // too low momentum + + histos.fill(HIST("hPiccPt"), picc.pt()); + + float piccTOFDiffInner = std::fabs(picc.innerTOFTrackTimeReco() - picc.innerTOFExpectedTimePi()); + float piccTOFDiffOuter = std::fabs(picc.outerTOFTrackTimeReco() - picc.outerTOFExpectedTimePi()); + if (piccTOFDiffInner > piFromXiCC_tofDiffInner) + continue; // did not arrive at expected time + + histos.fill(HIST("hInnerTOFTrackTimeRecoPicc"), piccTOFDiffInner); + o2::track::TrackParCov piccTrack = getTrackParCov(picc); nCombinationsCC++; histos.fill(HIST("hCharmBuilding"), 2.0f); - if (!buildDecayCandidateTwoBody(xicTrack, piccTrack, 2.46793, 0.139570)) + if (!buildDecayCandidateTwoBody(xicTrack, piccTrack, o2::constants::physics::MassXiCPlus, o2::constants::physics::MassPionCharged)) continue; // failed at building candidate - histos.fill(HIST("hCharmBuilding"), 3.0f); - histos.fill(HIST("hMassXiCC"), thisXiCCcandidate.mass); - histos.fill(HIST("hPtXiCC"), thisXiCCcandidate.pt); - histos.fill(HIST("hEtaXiCC"), thisXiCCcandidate.eta); - histos.fill(HIST("h3dMassXiCC"), thisXiCCcandidate.pt, thisXiCCcandidate.eta, thisXiCCcandidate.mass); - histos.fill(HIST("hDCAXiCCDaughters"), thisXiCCcandidate.dca); + histos.fill(HIST("hDCAXiCCDaughters"), thisXiCCcandidate.dca * 1e+4); const std::array momentumCC = { thisXiCCcandidate.prong0mom[0] + thisXiCCcandidate.prong1mom[0], @@ -541,26 +662,118 @@ struct alice3multicharm { thisXiCCcandidate.prong0mom[2] + thisXiCCcandidate.prong1mom[2]}; o2::track::TrackParCov xiccTrack(thisXiCCcandidate.xyz, momentumCC, thisXiCCcandidate.parentTrackCovMatrix, +2); - - float xiccdcaXY = 1e+10; + float xiccDecayRadius2D = std::hypot(thisXiCCcandidate.xyz[0], thisXiCCcandidate.xyz[1]); + if (xiccDecayRadius2D < minXiCCRadius) + continue; // do not take if radius too small, likely a primary combination + + histos.fill(HIST("hMinXiCCDecayRadius"), xiccDecayRadius2D * 1e+4); + + float totalMomentumC = std::hypot(momentumC[0], momentumC[1], momentumC[2]); + float decayLengthXiC = std::hypot( + thisXiCcandidate.xyz[0] - thisXiCCcandidate.xyz[0], + thisXiCcandidate.xyz[1] - thisXiCCcandidate.xyz[1], + thisXiCcandidate.xyz[2] - thisXiCCcandidate.xyz[2]); + float xicProperLength = decayLengthXiC * thisXiCcandidate.mass / totalMomentumC; + + if (xicProperLength < xicMinProperLength || xicProperLength > xicMaxProperLength) + continue; // likely background + + histos.fill(HIST("hProperLengthXiC"), xicProperLength * 1e+4); + + float xicDistanceFromPV = std::hypot( + thisXiCcandidate.xyz[0] - collision.posX(), + thisXiCcandidate.xyz[1] - collision.posY(), + thisXiCcandidate.xyz[2] - collision.posZ()); + float xicDecayDistanceFromPV = xicDistanceFromPV * thisXiCcandidate.mass / totalMomentumC; + if (xicDecayDistanceFromPV < xicMinDecayDistanceFromPV) + continue; // too close to PV + + histos.fill(HIST("hMinxicDecayDistanceFromPV"), xicDecayDistanceFromPV * 1e+4); + + float totalMomentumCC = std::hypot(momentumCC[0], momentumCC[1], momentumCC[2]); + float decayLengthXiCC = std::hypot( + thisXiCCcandidate.xyz[0] - collision.posX(), + thisXiCCcandidate.xyz[1] - collision.posY(), + thisXiCCcandidate.xyz[2] - collision.posZ()); + float xiccProperLength = decayLengthXiCC * thisXiCCcandidate.mass / totalMomentumCC; + if (xiccProperLength < xiccMinProperLength || xiccProperLength > xicMaxProperLength) + continue; // likely background + + histos.fill(HIST("hProperLengthXiCC"), xiccProperLength * 1e+4); + if (xiccDecayRadius2D > xicDecayRadius2D) + continue; // XiCC should decay before XiC + + histos.fill(HIST("hXicRadiusVsXiccRadius"), xicDecayRadius2D * 1e+4, xiccDecayRadius2D * 1e+4); + + float xiccdcaXY = 1e+10, xiccdcaZ = 1e+10; if (xiccTrack.propagateToDCA(primaryVertex, magneticField, &dcaInfo)) { xiccdcaXY = dcaInfo.getY(); + xiccdcaZ = dcaInfo.getZ(); } + if (std::fabs(xiccdcaXY) > xiCC_dcaXY || std::fabs(xiccdcaZ) > xiCC_dcaZ) + continue; // not pointing to PV + + histos.fill(HIST("hDCAxyXiCC"), std::fabs(xiccdcaXY * 1e+4)); + histos.fill(HIST("hDCAzXiCC"), std::fabs(xiccdcaZ * 1e+4)); + + if (std::fabs(thisXiCcandidate.eta) > xiccMaxEta) + continue; // not in central barrel + + histos.fill(HIST("hCharmBuilding"), 3.0f); + histos.fill(HIST("hMassXiCC"), thisXiCCcandidate.mass); + histos.fill(HIST("hPtXiCC"), thisXiCCcandidate.pt); + histos.fill(HIST("hEtaXiCC"), thisXiCCcandidate.eta); + histos.fill(HIST("h3dMassXiCC"), thisXiCCcandidate.pt, thisXiCCcandidate.eta, thisXiCCcandidate.mass); + // produce multi-charm table for posterior analysis if (fillDerivedTable) { + multiCharmIdx( + xiCand.globalIndex(), + pi1c.globalIndex(), pi2c.globalIndex(), + picc.globalIndex()); + multiCharmCore( - thisXiCcandidate.dca, thisXiCCcandidate.dca, - thisXiCcandidate.mass, thisXiCCcandidate.mass, - thisXiCCcandidate.pt, thisXiCCcandidate.eta, - xi.nSiliconHits(), piFromXi.nSiliconHits(), - piFromLa.nSiliconHits(), prFromLa.nSiliconHits(), - pi1c.nSiliconHits(), pi2c.nSiliconHits(), picc.nSiliconHits(), - piFromXi.nTPCHits(), piFromLa.nTPCHits(), prFromLa.nTPCHits(), - pi1c.nTPCHits(), pi2c.nTPCHits(), picc.nTPCHits(), - xi.dcaXY(), xicdcaXY, xiccdcaXY, - piFromXi.dcaXY(), piFromLa.dcaXY(), prFromLa.dcaXY(), - pi1c.dcaXY(), pi2c.dcaXY(), picc.dcaXY()); + thisXiCCcandidate.mass, thisXiCCcandidate.pt, + thisXiCCcandidate.eta, thisXiCCcandidate.dca, + thisXiCcandidate.mass, thisXiCcandidate.pt, + thisXiCcandidate.eta, thisXiCcandidate.dca, + xi.dcaXY(), xi.dcaZ(), + xicdcaXY, xicdcaZ, + xiccdcaXY, xiccdcaZ, + pi1c.dcaXY(), pi1c.dcaZ(), + pi2c.dcaXY(), pi2c.dcaZ(), + picc.dcaXY(), picc.dcaZ(), + xicDecayRadius2D, xiccDecayRadius2D, + xicProperLength, + xicDecayDistanceFromPV, + xiccProperLength, + pi1c.pt(), + pi2c.pt(), + picc.pt()); + + multiCharmPID( + pi1cTOFDiffInner, pi1c.nSigmaPionInnerTOF(), + pi1cTOFDiffOuter, pi1c.nSigmaPionOuterTOF(), + pi1c.hasSigPi(), pi1c.nSigmaPionRich(), + getPdgCodeForTrack(pi1c), + pi2cTOFDiffInner, pi2c.nSigmaPionInnerTOF(), + pi2cTOFDiffOuter, pi2c.nSigmaPionOuterTOF(), + pi2c.hasSigPi(), pi2c.nSigmaPionRich(), + getPdgCodeForTrack(pi2c), + piccTOFDiffInner, picc.nSigmaPionInnerTOF(), + piccTOFDiffOuter, picc.nSigmaPionOuterTOF(), + picc.hasSigPi(), picc.nSigmaPionRich(), + getPdgCodeForTrack(picc)); + + multiCharmExtra( + piFromXi.pt(), piFromXi.eta(), + piFromXi.dcaXY(), piFromXi.dcaZ(), + prFromLa.pt(), prFromLa.eta(), + prFromLa.dcaXY(), prFromLa.dcaZ(), + piFromLa.pt(), piFromLa.eta(), + piFromLa.dcaXY(), piFromLa.dcaZ(), + pi1c.eta(), pi2c.eta(), picc.eta()); } } histos.fill(HIST("hCombinationsXiCC"), nCombinationsCC); @@ -572,13 +785,13 @@ struct alice3multicharm { //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* //*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<* - PROCESS_SWITCH(alice3multicharm, processGenerated, "fill MC-only histograms", true); - PROCESS_SWITCH(alice3multicharm, processFindXiCC, "find XiCC baryons", true); + PROCESS_SWITCH(alice3multicharmTable, processGenerated, "fill MC-only histograms", true); + PROCESS_SWITCH(alice3multicharmTable, processFindXiCC, "find XiCC baryons", true); //*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<* }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/ALICE3/TableProducer/alice3-pidTOF.cxx b/ALICE3/TableProducer/alice3-pidTOF.cxx index 4ced165e00a..3e54b1f46dc 100644 --- a/ALICE3/TableProducer/alice3-pidTOF.cxx +++ b/ALICE3/TableProducer/alice3-pidTOF.cxx @@ -123,7 +123,7 @@ struct ALICE3pidTOFTask { if (!track.hasTOF()) { return -999.f; } - return ((track.trackTime() - track.collision().collisionTime()) * 1000.f - o2::pid::tof::ExpTimes::ComputeExpectedTime(track.tofExpMom() / o2::pid::tof::kCSPEED, + return ((track.trackTime() - track.collision().collisionTime()) * 1000.f - o2::pid::tof::ExpTimes::ComputeExpectedTime(track.tofExpMom() * o2::constants::physics::invLightSpeedCm2PS, track.length())) / sigma(track); } @@ -294,7 +294,7 @@ struct ALICE3pidTOFTaskQA { // // histos.fill(HIST("event/tofsignal"), t.p(), t.tofSignal()); histos.fill(HIST("event/tofsignal"), t.p(), tofSignal); - histos.fill(HIST("event/pexp"), t.p(), t.tofExpMom() / o2::pid::tof::kCSPEED); + histos.fill(HIST("event/pexp"), t.p(), t.tofExpMom() * o2::constants::physics::invLightSpeedCm2PS); histos.fill(HIST("event/eta"), t.eta()); histos.fill(HIST("event/length"), t.length()); histos.fill(HIST("event/pt"), t.pt()); diff --git a/ALICE3/Tasks/CMakeLists.txt b/ALICE3/Tasks/CMakeLists.txt index 36a9d8d58e8..06864096cf5 100644 --- a/ALICE3/Tasks/CMakeLists.txt +++ b/ALICE3/Tasks/CMakeLists.txt @@ -39,6 +39,11 @@ o2physics_add_dpl_workflow(alice3-pid-ftof-qa PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(alice3-pid-separation-power + SOURCES alice3SeparationPower.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(alice3-cdeuteron SOURCES alice3-cdeuteron.cxx PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore @@ -48,3 +53,25 @@ o2physics_add_dpl_workflow(alice3-dilepton SOURCES alice3-dilepton.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(alice3-taskcorrelationddbar + SOURCES alice3-taskcorrelationDDbar.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(alice3-multicharm + SOURCES alice3-multicharm.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(alice3-efficiency + SOURCES alice3Efficiency.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(alice3-tracking-performance + SOURCES alice3TrackingPerformance.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + + diff --git a/ALICE3/Tasks/alice3-dilepton.cxx b/ALICE3/Tasks/alice3-dilepton.cxx index ef8d1ff4b53..e3632fc5a02 100644 --- a/ALICE3/Tasks/alice3-dilepton.cxx +++ b/ALICE3/Tasks/alice3-dilepton.cxx @@ -531,9 +531,9 @@ struct Alice3Dilepton { FillPairGen(neg_mcParticles_coll, neg_mcParticles_coll, mcParticles); } // end of mc collision loop - } // end of processGen + } // end of processGen - using MyTracksMC = soa::Join; + using MyTracksMC = soa::Join; // Filter trackFilter = etaMin < o2::aod::track::eta && // o2::aod::track::eta < etaMax && // ptMin < o2::aod::track::pt && @@ -616,7 +616,7 @@ struct Alice3Dilepton { FillPairRec(negTracks_coll, negTracks_coll, mcParticles); } // end of collision loop - } // end of processRec + } // end of processRec PROCESS_SWITCH(Alice3Dilepton, processGen, "Run for generated particle", true); PROCESS_SWITCH(Alice3Dilepton, processRec, "Run for reconstructed track", false); diff --git a/ALICE3/Tasks/alice3-multicharm.cxx b/ALICE3/Tasks/alice3-multicharm.cxx new file mode 100644 index 00000000000..088a3b5c1f6 --- /dev/null +++ b/ALICE3/Tasks/alice3-multicharm.cxx @@ -0,0 +1,581 @@ +// 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. +// +// *+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* +// Decay finder task for ALICE 3 +// *+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* +// +// Uses specific ALICE 3 PID and performance for studying +// HF decays. Work in progress: use at your own risk! +// + +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "ALICE3/DataModel/A3DecayFinderTables.h" +#include "ALICE3/DataModel/OTFMulticharm.h" +#include "ALICE3/DataModel/OTFRICH.h" +#include "ALICE3/DataModel/OTFStrangeness.h" +#include "ALICE3/DataModel/OTFTOF.h" +#include "ALICE3/DataModel/tracksAlice3.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Tools/ML/MlResponse.h" +#include "Tools/ML/model.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DCAFitter/DCAFitterN.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsVertexing/PVertexer.h" +#include "DetectorsVertexing/PVertexerHelpers.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::ml; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using multiCharmTracksPID = soa::Join; +using multiCharmTracksFull = soa::Join; +#define getHist(type, name) std::get>(histPointers[name]) + +struct alice3multicharm { + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + std::map histPointers; + std::string histPath; + + std::map pdgToBin; + o2::ml::OnnxModel bdtMCharm; + + std::map metadata; + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + + struct : ConfigurableGroup { + std::string prefix = "bdt"; // JSON group name + Configurable ccdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable localPath{"localPath", "MCharm_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; + Configurable pathCCDB{"btdPathCCDB", "Users/j/jekarlss/MLModels", "Path on CCDB"}; + Configurable timestampCCDB{"timestampCCDB", 1695750420200, "timestamp of the ONNX file for ML model used to query in CCDB. Please use 1695750420200"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + Configurable enableOptimizations{"enableOptimizations", false, "Enables the ONNX extended model-optimization: sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED)"}; + Configurable enableML{"enableML", false, "Enables bdt model"}; + Configurable> requiredScores{"requiredScores", {0.5, 0.75, 0.85, 0.9, 0.95, 0.99}, "Vector of different scores to try"}; + } bdt; + + ConfigurableAxis axisEta{"axisEta", {80, -4.0f, +4.0f}, "#eta"}; + ConfigurableAxis axisXicMass{"axisXicMass", {200, 2.368f, 2.568f}, "Xic Inv Mass (GeV/c^{2})"}; + ConfigurableAxis axisXiccMass{"axisXiccMass", {200, 3.521f, 3.721f}, "Xicc Inv Mass (GeV/c^{2})"}; + ConfigurableAxis axisDCA{"axisDCA", {400, 0, 400}, "DCA (#mum)"}; + ConfigurableAxis axisRadiusLarge{"axisRadiusLarge", {1000, 0, 20}, "Decay radius (cm)"}; + ConfigurableAxis axisRadius{"axisRadius", {10000, 0, 10000}, "Decay radius (#mum)"}; + ConfigurableAxis axisTofTrackDelta{"axisTofTrackDelta", {200, 0, 1000}, "TOF track time"}; + ConfigurableAxis axisNSigma{"axisNSigma", {21, -10, 10}, "nsigma"}; + ConfigurableAxis axisDecayLength{"axisDecayLength", {2000, 0, 2000}, "Decay lenght (#mum)"}; + ConfigurableAxis axisDcaDaughters{"axisDcaDaughters", {200, 0, 100}, "DCA (mum)"}; + ConfigurableAxis axisBDTScore{"axisBDTScore", {100, 0, 1}, "BDT Score"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for QA histograms"}; + + Configurable xiMinDCAxy{"xiMinDCAxy", -1, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable xiMinDCAz{"xiMinDCAz", -1, "[0] in |DCAz| > [0]+[1]/pT"}; + Configurable xiMinRadius{"xiMinRadius", -1, "Minimum R2D for Xic decay (cm)"}; + + Configurable picMinDCAxy{"picMinDCAxy", -1, "[0] in |DCAz| > [0]+[1]/pT"}; + Configurable picMinDCAz{"picMinDCAz", -1, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable picMinPt{"picMinPt", -1, "Minimum pT for Xic pions"}; + + Configurable piccMinDCAxy{"piccMinDCAxy", -1, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable piccMinDCAz{"piccMinDCAz", -1, "[0] in |DCAz| > [0]+[1]/pT"}; + Configurable piccMinPt{"piccMinPt", -1, "Minimum pT for Xicc pions"}; + + Configurable xicMaxDauDCA{"xicMaxDauDCA", 1e+4, "DCA between Xic daughters (cm)"}; + Configurable xicMinDCAxy{"xicMinDCAxy", -1, "[0] in |DCAz| > [0]+[1]/pT"}; + Configurable xicMinDCAz{"xicMinDCAz", -1, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable xiccMaxDCAxy{"xiccMaxDCAxy", 1e+4, "Maximum DCAxy"}; + Configurable xiccMaxDCAz{"xiccMaxDCAz", 1e+4, "Maximum DCAz"}; + Configurable xicMinRadius{"xicMinRadius", -1, "Minimum R2D for Xic decay (cm)"}; + Configurable xicMinDecayDistanceFromPV{"xicMinDecayDistanceFromPV", -1, "Minimum distance for Xic decay from PV (cm)"}; + Configurable xicMinProperLength{"xicMinProperLength", -1, "Minimum proper length for Xic decay (cm)"}; + Configurable xicMaxProperLength{"xicMaxProperLength", 1e+4, "Minimum proper length for Xic decay (cm)"}; + + Configurable xiccMaxDauDCA{"xiccMaxDauDCA", 1e+4, "DCA between Xicc daughters (cm)"}; + Configurable xiccMinRadius{"xiccMinRadius", -1, "Minimum R2D for Xicc decay (cm)"}; + Configurable xiccMinProperLength{"xiccMinProperLength", -1, "Minimum proper length for Xicc decay (cm)"}; + Configurable xiccMaxProperLength{"xiccMaxProperLength", 1e+4, "Minimum proper length for Xicc decay (cm)"}; + + void init(InitContext&) + { + histos.add("SelectionQA/hDCAXicDaughters", "hDCAXicDaughters; DCA between Xic daughters (#mum)", kTH1D, {axisDcaDaughters}); + histos.add("SelectionQA/hDCAXiccDaughters", "hDCAXiccDaughters; DCA between Xicc daughters (#mum)", kTH1D, {axisDcaDaughters}); + histos.add("SelectionQA/hDCAxyXi", "hDCAxyXi; Xi DCAxy to PV (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hDCAzXi", "hDCAzXi; Xi DCAz to PV (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hDCAxyXic", "hDCAxyXic; Xic DCAxy to PV (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hDCAzXic", "hDCAzXic; Xic DCAz to PV (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hDCAxyXicc", "hDCAxyXicc; Xicc DCAxy to PV (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hDCAzXicc", "hDCAzXicc; Xicc DCAz to PV (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hDecayRadiusXic", "hDecayRadiusXic; Distance (#mum)", kTH1D, {axisRadius}); + histos.add("SelectionQA/hDecayRadiusXicc", "hDecayRadiusXicc; Distance (#mum)", kTH1D, {axisRadius}); + histos.add("SelectionQA/hDecayDistanceFromPVXic", "hDecayDistanceFromPVXic; Distance (#mum)", kTH1D, {axisDecayLength}); + histos.add("SelectionQA/hProperLengthXic", "hProperLengthXic; Distance (#mum)", kTH1D, {axisDecayLength}); + histos.add("SelectionQA/hProperLengthXicc", "hProperLengthXicc; Distance (#mum)", kTH1D, {axisDecayLength}); + histos.add("SelectionQA/hPi1cDCAxy", "hPi1cDCAxy; Pi1c DCAxy (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hPi1cDCAz", "hPi1cDCAz; Pi1c DCAz (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hPi2cDCAxy", "hPi2cDCAxy; Pi2c DCAxy (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hPi2cDCAz", "hPi2cDCAz; Pi2c DCAz (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hPiccDCAxy", "hPiccDCAxy; Picc DCAxy (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hPiccDCAz", "hPiccDCAz; Picc DCAz (#mum)", kTH1D, {axisDCA}); + histos.add("SelectionQA/hPi1cPt", "hPi1cPt; Pi1c pT (Gev/#it(c))", kTH1D, {axisPt}); + histos.add("SelectionQA/hPi2cPt", "hPi2cPt; Pi2c pT (Gev/#it(c))", kTH1D, {axisPt}); + histos.add("SelectionQA/hPiccPt", "hPiccPt; Picc pT (Gev/#it(c))", kTH1D, {axisPt}); + + auto hMCharmBuilding = histos.add("hMCharmBuilding", "hMCharmBuilding", kTH1D, {{22, -0.5, 21.5}}); + hMCharmBuilding->GetXaxis()->SetBinLabel(1, "nTotalCandidates"); + hMCharmBuilding->GetXaxis()->SetBinLabel(2, "xicMaxDauDCA"); + hMCharmBuilding->GetXaxis()->SetBinLabel(3, "xiccMaxDauDCA"); + hMCharmBuilding->GetXaxis()->SetBinLabel(4, "xiMinDCAxy"); + hMCharmBuilding->GetXaxis()->SetBinLabel(5, "xiMinDCAz"); + hMCharmBuilding->GetXaxis()->SetBinLabel(6, "pi1cMinDCAxy"); + hMCharmBuilding->GetXaxis()->SetBinLabel(7, "pi1cMinDCAz"); + hMCharmBuilding->GetXaxis()->SetBinLabel(8, "pi2cMinDCAxy"); + hMCharmBuilding->GetXaxis()->SetBinLabel(9, "pi2cMinDCAz"); + hMCharmBuilding->GetXaxis()->SetBinLabel(10, "piccMinDCAxy"); + hMCharmBuilding->GetXaxis()->SetBinLabel(11, "piccMinDCAz"); + hMCharmBuilding->GetXaxis()->SetBinLabel(12, "xicMinDCAxy"); + hMCharmBuilding->GetXaxis()->SetBinLabel(13, "xicMinDCAz"); + hMCharmBuilding->GetXaxis()->SetBinLabel(14, "xiccMaxDCAxy"); + hMCharmBuilding->GetXaxis()->SetBinLabel(15, "xiccMaxDCAz"); + hMCharmBuilding->GetXaxis()->SetBinLabel(16, "xicMinRadius"); + hMCharmBuilding->GetXaxis()->SetBinLabel(17, "xiccMinRadius"); + hMCharmBuilding->GetXaxis()->SetBinLabel(18, "xicMinProperLength"); + hMCharmBuilding->GetXaxis()->SetBinLabel(19, "xicMaxProperLength"); + hMCharmBuilding->GetXaxis()->SetBinLabel(20, "xiccMinProperLength"); + hMCharmBuilding->GetXaxis()->SetBinLabel(21, "xiccMaxProperLength"); + hMCharmBuilding->GetXaxis()->SetBinLabel(22, "xicMinDecayDistanceFromPV"); + + if (doprocessXiccPID || doprocessXiccExtra) { + auto hPdgCodes = histos.add("PIDQA/hPdgCodes", "hPdgCodes", kTH2D, {{3, 0.5, 3.5}, {7, 0.5, 7.5}}); + hPdgCodes->GetXaxis()->SetBinLabel(1, "pi1c"); + hPdgCodes->GetXaxis()->SetBinLabel(2, "pi2c"); + hPdgCodes->GetXaxis()->SetBinLabel(3, "picc"); + hPdgCodes->GetYaxis()->SetBinLabel(1, "el"); + hPdgCodes->GetYaxis()->SetBinLabel(2, "mu"); + hPdgCodes->GetYaxis()->SetBinLabel(3, "pi"); + hPdgCodes->GetYaxis()->SetBinLabel(4, "ka"); + hPdgCodes->GetYaxis()->SetBinLabel(5, "pr"); + hPdgCodes->GetYaxis()->SetBinLabel(6, "xi"); + hPdgCodes->GetYaxis()->SetBinLabel(7, "other"); + pdgToBin.insert({kElectron, 1}); + pdgToBin.insert({kMuonMinus, 2}); + pdgToBin.insert({kPiPlus, 3}); + pdgToBin.insert({kKPlus, 4}); + pdgToBin.insert({kProton, 5}); + pdgToBin.insert({kXiMinus, 6}); + + histos.add("PIDQA/hInnerTofTimeDeltaPi1c", "hInnerTofTimeDeltaPi1c; Reco - expected pion (ps)", kTH1D, {axisTofTrackDelta}); + histos.add("PIDQA/hInnerTofTimeDeltaPi2c", "hInnerTofTimeDeltaPi2c; Reco - expected pion (ps)", kTH1D, {axisTofTrackDelta}); + histos.add("PIDQA/hInnerTofTimeDeltaPicc", "hInnerTofTimeDeltaPicc; Reco - expected pion (ps)", kTH1D, {axisTofTrackDelta}); + histos.add("PIDQA/hOuterTofTimeDeltaPi1c", "hOuterTofTimeDeltaPi1c; Reco - expected pion (ps)", kTH1D, {axisTofTrackDelta}); + histos.add("PIDQA/hOuterTofTimeDeltaPi2c", "hOuterTofTimeDeltaPi2c; Reco - expected pion (ps)", kTH1D, {axisTofTrackDelta}); + histos.add("PIDQA/hOuterTofTimeDeltaPicc", "hOuterTofTimeDeltaPicc; Reco - expected pion (ps)", kTH1D, {axisTofTrackDelta}); + + histos.add("PIDQA/hInnerTofNSigmaPi1c", "hInnerTofNSigmaPi1c; TOF NSigma pion", kTH2D, {axisPt, axisNSigma}); + histos.add("PIDQA/hOuterTofNSigmaPi1c", "hOuterTofNSigmaPi1c; TOF NSigma pion", kTH2D, {axisPt, axisNSigma}); + histos.add("PIDQA/hInnerTofNSigmaPi2c", "hInnerTofNSigmaPi2c; TOF NSigma pion", kTH2D, {axisPt, axisNSigma}); + histos.add("PIDQA/hOuterTofNSigmaPi2c", "hOuterTofNSigmaPi2c; TOF NSigma pion", kTH2D, {axisPt, axisNSigma}); + histos.add("PIDQA/hInnerTofNSigmaPicc", "hInnerTofNSigmaPicc; TOF NSigma pion", kTH2D, {axisPt, axisNSigma}); + histos.add("PIDQA/hOuterTofNSigmaPicc", "hOuterTofNSigmaPicc; TOF NSigma pion", kTH2D, {axisPt, axisNSigma}); + + histos.add("PIDQA/hRichNSigmaPi1c", "hRichNSigmaPi1c; RICH NSigma pion", kTH2D, {axisPt, axisNSigma}); + histos.add("PIDQA/hRichNSigmaPi2c", "hRichNSigmaPi2c; RICH NSigma pion", kTH2D, {axisPt, axisNSigma}); + histos.add("PIDQA/hRichNSigmaPicc", "hRichNSigmaPicc; RICH NSigma pion", kTH2D, {axisPt, axisNSigma}); + } + + if (doprocessXiccExtra) { + histos.add("XiccProngs/h3dPos", "h3dPos; Xicc pT (GeV/#it(c)); Pos pT (GeV/#it(c)); Pos #eta", kTH3D, {axisPt, axisPt, axisEta}); + histos.add("XiccProngs/h3dNeg", "h3dNeg; Xicc pT (GeV/#it(c)); Neg pT (GeV/#it(c)); Neg #eta", kTH3D, {axisPt, axisPt, axisEta}); + histos.add("XiccProngs/h3dBach", "h3dBach; Xicc pT (GeV/#it(c)); Bach pT (GeV/#it(c)); Bach #eta", kTH3D, {axisPt, axisPt, axisEta}); + histos.add("XiccProngs/h3dPi1c", "h3dPi1c; Xicc pT (GeV/#it(c)); Pi1c pT (GeV/#it(c)); Pi1c #eta", kTH3D, {axisPt, axisPt, axisEta}); + histos.add("XiccProngs/h3dPi2c", "h3dPi2c; Xicc pT (GeV/#it(c)); Pi2c pT (GeV/#it(c)); Pi2c #eta", kTH3D, {axisPt, axisPt, axisEta}); + histos.add("XiccProngs/h3dPicc", "h3dPicc; Xicc pT (GeV/#it(c)); Picc pT (GeV/#it(c)); Picc #eta", kTH3D, {axisPt, axisPt, axisEta}); + } + + histos.add("hXiccMass", "hXiccMass", kTH1D, {axisXiccMass}); + histos.add("hXicMass", "hXicMass", kTH1D, {axisXicMass}); + histos.add("hXiccPt", "hXiccPt", kTH1D, {axisPt}); + histos.add("hXicPt", "hXicPt", kTH1D, {axisPt}); + histos.add("h3dXicc", "h3dXicc; Xicc pT (GeV/#it(c)); Xicc #eta; Xicc mass (GeV/#it(c)^{2})", kTH3D, {axisPt, axisEta, axisXiccMass}); + + if (bdt.enableML) { + ccdb->setURL(bdt.ccdbUrl.value); + if (bdt.loadModelsFromCCDB) { + ccdbApi.init(bdt.ccdbUrl); + LOG(info) << "Fetching model for timestamp: " << bdt.timestampCCDB.value; + bool retrieveSuccessMCharm = ccdbApi.retrieveBlob(bdt.pathCCDB.value, ".", metadata, bdt.timestampCCDB.value, false, bdt.localPath.value); + + if (retrieveSuccessMCharm) { + bdtMCharm.initModel(bdt.localPath.value, bdt.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the MCharm model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } else { + bdtMCharm.initModel(bdt.localPath.value, bdt.enableOptimizations.value); + } + + histos.add("hBDTScore", "hBDTScore", kTH1D, {axisBDTScore}); + histos.add("hBDTScoreVsXiccMass", "hBDTScoreVsXiccMass", kTH2D, {axisXiccMass, axisBDTScore}); + histos.add("hBDTScoreVsXiccPt", "hBDTScoreVsXiccPt", kTH2D, {axisXiccMass, axisPt}); + for (const auto& score : bdt.requiredScores.value) { + histPath = std::format("MLQA/RequiredBDTScore_{}/", static_cast(score * 100)); + histPointers.insert({histPath + "hDCAXicDaughters", histos.add((histPath + "hDCAXicDaughters").c_str(), "hDCAXicDaughters", {kTH1D, {{axisDcaDaughters}}})}); + histPointers.insert({histPath + "hDCAXiccDaughters", histos.add((histPath + "hDCAXiccDaughters").c_str(), "hDCAXiccDaughters", {kTH1D, {{axisDcaDaughters}}})}); + histPointers.insert({histPath + "hDCAxyXi", histos.add((histPath + "hDCAxyXi").c_str(), "hDCAxyXi", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hDCAzXi", histos.add((histPath + "hDCAzXi").c_str(), "hDCAzXi", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hDCAxyXic", histos.add((histPath + "hDCAxyXic").c_str(), "hDCAxyXic", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hDCAzXic", histos.add((histPath + "hDCAzXic").c_str(), "hDCAzXic", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hDCAxyXicc", histos.add((histPath + "hDCAxyXicc").c_str(), "hDCAxyXicc", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hDCAzXicc", histos.add((histPath + "hDCAzXicc").c_str(), "hDCAzXicc", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hDecayRadiusXic", histos.add((histPath + "hDecayRadiusXic").c_str(), "hDecayRadiusXic", {kTH1D, {{axisRadius}}})}); + histPointers.insert({histPath + "hDecayRadiusXicc", histos.add((histPath + "hDecayRadiusXicc").c_str(), "hDecayRadiusXicc", {kTH1D, {{axisRadius}}})}); + histPointers.insert({histPath + "hDecayDistanceFromPVXic", histos.add((histPath + "hDecayDistanceFromPVXic").c_str(), "hDecayDistanceFromPVXic", {kTH1D, {{axisDecayLength}}})}); + histPointers.insert({histPath + "hProperLengthXic", histos.add((histPath + "hProperLengthXic").c_str(), "hProperLengthXic", {kTH1D, {{axisDecayLength}}})}); + histPointers.insert({histPath + "hProperLengthXicc", histos.add((histPath + "hProperLengthXicc").c_str(), "hProperLengthXicc", {kTH1D, {{axisDecayLength}}})}); + histPointers.insert({histPath + "hPi1cDCAxy", histos.add((histPath + "hPi1cDCAxy").c_str(), "hPi1cDCAxy", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hPi1cDCAz", histos.add((histPath + "hPi1cDCAz").c_str(), "hPi1cDCAxy", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hPi2cDCAxy", histos.add((histPath + "hPi2cDCAxy").c_str(), "hPi2cDCAxy", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hPi2cDCAz", histos.add((histPath + "hPi2cDCAz").c_str(), "hPi2cDCAz", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hPiccDCAxy", histos.add((histPath + "hPiccDCAxy").c_str(), "hPiccDCAxy", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hPiccDCAz", histos.add((histPath + "hPiccDCAz").c_str(), "hPiccDCAz", {kTH1D, {{axisDCA}}})}); + histPointers.insert({histPath + "hPi1cPt", histos.add((histPath + "hPi1cPt").c_str(), "hPi1cPt", {kTH1D, {{axisPt}}})}); + histPointers.insert({histPath + "hPi2cPt", histos.add((histPath + "hPi2cPt").c_str(), "hPi2cPt", {kTH1D, {{axisPt}}})}); + histPointers.insert({histPath + "hPiccPt", histos.add((histPath + "hPiccPt").c_str(), "hPiccPt", {kTH1D, {{axisPt}}})}); + histPointers.insert({histPath + "h3dXicc", histos.add((histPath + "h3dXicc").c_str(), "h3dXicc", {kTH3D, {{axisPt, axisEta, axisXiccMass}}})}); + histPointers.insert({histPath + "hXiccMass", histos.add((histPath + "hXiccMass").c_str(), "hXiccMass", {kTH1D, {{axisXiccMass}}})}); + histPointers.insert({histPath + "hXicMass", histos.add((histPath + "hXicMass").c_str(), "hXicMass", {kTH1D, {{axisXicMass}}})}); + histPointers.insert({histPath + "hXiccPt", histos.add((histPath + "hXiccPt").c_str(), "hXiccPt", {kTH1D, {{axisPt}}})}); + histPointers.insert({histPath + "hXicPt", histos.add((histPath + "hXicPt").c_str(), "hXicPt", {kTH1D, {{axisPt}}})}); + } + } + } + + int getBin(const std::map& pdgToBin, int pdg) + { + auto it = pdgToBin.find(pdg); + return (it != pdgToBin.end()) ? it->second : 7; + } + + template + void genericProcessXicc(TMCharmCands xiccCands) + { + for (const auto& xiccCand : xiccCands) { + if (bdt.enableML) { + std::vector inputFeatures{ + xiccCand.xicDauDCA(), + xiccCand.xiccDauDCA(), + xiccCand.xiDCAxy(), + xiccCand.xicDCAxy(), + xiccCand.xiccDCAxy(), + xiccCand.xiDCAz(), + xiccCand.xicDCAz(), + xiccCand.xiccDCAz(), + xiccCand.pi1cDCAxy(), + xiccCand.pi2cDCAxy(), + xiccCand.piccDCAxy(), + xiccCand.pi1cDCAz(), + xiccCand.pi2cDCAz(), + xiccCand.piccDCAz(), + xiccCand.xicDecayRadius2D(), + xiccCand.xiccDecayRadius2D(), + xiccCand.xicProperLength(), + xiccCand.xicDistanceFromPV(), + xiccCand.xiccProperLength()}; + + float* probabilityMCharm = bdtMCharm.evalModel(inputFeatures); + float bdtScore = probabilityMCharm[1]; + + histos.fill(HIST("hBDTScore"), bdtScore); + histos.fill(HIST("hBDTScoreVsXiccMass"), xiccCand.xiccMass(), bdtScore); + histos.fill(HIST("hBDTScoreVsXiccPt"), xiccCand.xiccPt(), bdtScore); + + for (const auto& requiredScore : bdt.requiredScores.value) { + if (bdtScore > requiredScore) { + histPath = std::format("MLQA/RequiredBDTScore_{}/", static_cast(requiredScore * 100)); + getHist(TH1, histPath + "hDCAXicDaughters")->Fill(xiccCand.xicDauDCA() * 1e+4); + getHist(TH1, histPath + "hDCAXiccDaughters")->Fill(xiccCand.xiccDauDCA() * 1e+4); + getHist(TH1, histPath + "hDCAxyXi")->Fill(std::fabs(xiccCand.xiDCAxy() * 1e+4)); + getHist(TH1, histPath + "hDCAzXi")->Fill(std::fabs(xiccCand.xiDCAz() * 1e+4)); + getHist(TH1, histPath + "hDCAxyXic")->Fill(std::fabs(xiccCand.xicDCAxy() * 1e+4)); + getHist(TH1, histPath + "hDCAzXic")->Fill(std::fabs(xiccCand.xicDCAz() * 1e+4)); + getHist(TH1, histPath + "hDCAxyXicc")->Fill(std::fabs(xiccCand.xiccDCAxy() * 1e+4)); + getHist(TH1, histPath + "hDCAzXicc")->Fill(std::fabs(xiccCand.xiccDCAz() * 1e+4)); + getHist(TH1, histPath + "hDecayRadiusXic")->Fill(xiccCand.xicDecayRadius2D() * 1e+4); + getHist(TH1, histPath + "hDecayRadiusXicc")->Fill(xiccCand.xiccDecayRadius2D() * 1e+4); + getHist(TH1, histPath + "hDecayDistanceFromPVXic")->Fill(xiccCand.xicDistanceFromPV() * 1e+4); + getHist(TH1, histPath + "hProperLengthXic")->Fill(xiccCand.xicProperLength() * 1e+4); + getHist(TH1, histPath + "hProperLengthXicc")->Fill(xiccCand.xiccProperLength() * 1e+4); + getHist(TH1, histPath + "hPi1cDCAxy")->Fill(xiccCand.pi1cDCAxy() * 1e+4); + getHist(TH1, histPath + "hPi1cDCAz")->Fill(xiccCand.pi1cDCAz() * 1e+4); + getHist(TH1, histPath + "hPi2cDCAxy")->Fill(xiccCand.pi2cDCAxy() * 1e+4); + getHist(TH1, histPath + "hPi2cDCAz")->Fill(xiccCand.pi2cDCAz() * 1e+4); + getHist(TH1, histPath + "hPiccDCAxy")->Fill(xiccCand.piccDCAxy() * 1e+4); + getHist(TH1, histPath + "hPiccDCAz")->Fill(xiccCand.piccDCAz() * 1e+4); + getHist(TH1, histPath + "hPi1cDCAz")->Fill(xiccCand.pi1cPt()); + getHist(TH1, histPath + "hPi2cDCAz")->Fill(xiccCand.pi2cPt()); + getHist(TH1, histPath + "hPiccDCAz")->Fill(xiccCand.piccPt()); + getHist(TH1, histPath + "hXiccMass")->Fill(xiccCand.xiccMass()); + getHist(TH1, histPath + "hXicMass")->Fill(xiccCand.xicMass()); + getHist(TH1, histPath + "hXiccPt")->Fill(xiccCand.xiccPt()); + getHist(TH1, histPath + "hXicPt")->Fill(xiccCand.xicPt()); + getHist(TH3, histPath + "h3dXicc")->Fill(xiccCand.xiccPt(), xiccCand.xiccEta(), xiccCand.xiccMass()); + } + } + } + + histos.fill(HIST("hMCharmBuilding"), 0); + if (xiccCand.xicDauDCA() > xicMaxDauDCA) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 1); + } + + if (xiccCand.xiccDauDCA() > xiccMaxDauDCA) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 2); + } + + if (std::fabs(xiccCand.xiDCAxy()) < xiMinDCAxy) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 3); + } + + if (std::fabs(xiccCand.xiDCAz()) < xiMinDCAz) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 4); + } + + if (std::fabs(xiccCand.pi1cDCAxy()) < picMinDCAxy) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 5); + } + + if (std::fabs(xiccCand.pi1cDCAz()) < picMinDCAz) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 6); + } + + if (std::fabs(xiccCand.pi2cDCAxy()) < picMinDCAxy) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 7); + } + + if (std::fabs(xiccCand.pi2cDCAz()) < picMinDCAz) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 8); + } + + if (std::fabs(xiccCand.piccDCAxy()) < piccMinDCAxy) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 9); + } + + if (std::fabs(xiccCand.piccDCAz()) < piccMinDCAz) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 10); + } + + if (std::fabs(xiccCand.xicDCAxy()) < xicMinDCAxy) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 11); + } + + if (std::fabs(xiccCand.xicDCAz()) < xicMinDCAz) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 12); + } + + if (std::fabs(xiccCand.xiccDCAxy()) > xiccMaxDCAxy) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 13); + } + + if (std::fabs(xiccCand.xiccDCAz()) > xiccMaxDCAz) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 14); + } + + if (xiccCand.xicDecayRadius2D() < xicMinRadius) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 15); + } + + if (xiccCand.xiccDecayRadius2D() < xiccMinRadius) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 16); + } + + if (xiccCand.xicProperLength() < xicMinProperLength) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 17); + } + + if (xiccCand.xicProperLength() > xicMaxProperLength) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 18); + } + + if (xiccCand.xiccProperLength() < xiccMinProperLength) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 19); + } + + if (xiccCand.xiccProperLength() > xiccMaxProperLength) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 20); + } + + if (xiccCand.xicDistanceFromPV() < xicMinDecayDistanceFromPV) { + continue; + } else { + histos.fill(HIST("hMCharmBuilding"), 21); + } + + histos.fill(HIST("SelectionQA/hDCAXicDaughters"), xiccCand.xicDauDCA() * 1e+4); + histos.fill(HIST("SelectionQA/hDCAXiccDaughters"), xiccCand.xiccDauDCA() * 1e+4); + histos.fill(HIST("SelectionQA/hDCAxyXi"), std::fabs(xiccCand.xiDCAxy() * 1e+4)); + histos.fill(HIST("SelectionQA/hDCAzXi"), std::fabs(xiccCand.xiDCAz() * 1e+4)); + histos.fill(HIST("SelectionQA/hDCAxyXic"), std::fabs(xiccCand.xicDCAxy() * 1e+4)); + histos.fill(HIST("SelectionQA/hDCAzXic"), std::fabs(xiccCand.xicDCAz() * 1e+4)); + histos.fill(HIST("SelectionQA/hDCAxyXicc"), std::fabs(xiccCand.xiccDCAxy() * 1e+4)); + histos.fill(HIST("SelectionQA/hDCAzXicc"), std::fabs(xiccCand.xiccDCAz() * 1e+4)); + histos.fill(HIST("SelectionQA/hDecayRadiusXic"), xiccCand.xicDecayRadius2D() * 1e+4); + histos.fill(HIST("SelectionQA/hDecayRadiusXicc"), xiccCand.xiccDecayRadius2D() * 1e+4); + histos.fill(HIST("SelectionQA/hDecayDistanceFromPVXic"), xiccCand.xicDistanceFromPV() * 1e+4); + histos.fill(HIST("SelectionQA/hProperLengthXic"), xiccCand.xicProperLength() * 1e+4); + histos.fill(HIST("SelectionQA/hProperLengthXicc"), xiccCand.xiccProperLength() * 1e+4); + histos.fill(HIST("SelectionQA/hPi1cDCAxy"), xiccCand.pi1cDCAxy() * 1e+4); + histos.fill(HIST("SelectionQA/hPi1cDCAz"), xiccCand.pi1cDCAz() * 1e+4); + histos.fill(HIST("SelectionQA/hPi2cDCAxy"), xiccCand.pi2cDCAxy() * 1e+4); + histos.fill(HIST("SelectionQA/hPi2cDCAz"), xiccCand.pi2cDCAz() * 1e+4); + histos.fill(HIST("SelectionQA/hPiccDCAxy"), xiccCand.piccDCAxy() * 1e+4); + histos.fill(HIST("SelectionQA/hPiccDCAz"), xiccCand.piccDCAz() * 1e+4); + histos.fill(HIST("SelectionQA/hPi1cPt"), xiccCand.pi1cPt()); + histos.fill(HIST("SelectionQA/hPi2cPt"), xiccCand.pi2cPt()); + histos.fill(HIST("SelectionQA/hPiccPt"), xiccCand.piccPt()); + + if constexpr (requires { xiccCand.pi1cTofDeltaInner(); }) { // if pid table + histos.fill(HIST("PIDQA/hInnerTofTimeDeltaPi1c"), xiccCand.pi1cTofDeltaInner()); + histos.fill(HIST("PIDQA/hInnerTofTimeDeltaPi2c"), xiccCand.pi2cTofDeltaInner()); + histos.fill(HIST("PIDQA/hInnerTofTimeDeltaPicc"), xiccCand.piccTofDeltaInner()); + histos.fill(HIST("PIDQA/hOuterTofTimeDeltaPi1c"), xiccCand.pi1cTofDeltaOuter()); + histos.fill(HIST("PIDQA/hOuterTofTimeDeltaPi2c"), xiccCand.pi2cTofDeltaOuter()); + histos.fill(HIST("PIDQA/hOuterTofTimeDeltaPicc"), xiccCand.piccTofDeltaOuter()); + histos.fill(HIST("PIDQA/hInnerTofNSigmaPi1c"), xiccCand.pi1cPt(), xiccCand.pi1cTofNSigmaInner()); + histos.fill(HIST("PIDQA/hOuterTofNSigmaPi1c"), xiccCand.pi1cPt(), xiccCand.pi1cTofNSigmaOuter()); + histos.fill(HIST("PIDQA/hInnerTofNSigmaPi2c"), xiccCand.pi2cPt(), xiccCand.pi2cTofNSigmaInner()); + histos.fill(HIST("PIDQA/hOuterTofNSigmaPi2c"), xiccCand.pi2cPt(), xiccCand.pi2cTofNSigmaOuter()); + histos.fill(HIST("PIDQA/hInnerTofNSigmaPicc"), xiccCand.piccPt(), xiccCand.piccTofNSigmaInner()); + histos.fill(HIST("PIDQA/hOuterTofNSigmaPicc"), xiccCand.piccPt(), xiccCand.piccTofNSigmaOuter()); + if (xiccCand.pi1cHasRichSignal()) { + histos.fill(HIST("PIDQA/hRichNSigmaPi1c"), xiccCand.pi1cPt(), xiccCand.pi1cRichNSigma()); + } + if (xiccCand.pi2cHasRichSignal()) { + histos.fill(HIST("PIDQA/hRichNSigmaPi2c"), xiccCand.pi2cPt(), xiccCand.pi2cRichNSigma()); + } + if (xiccCand.piccHasRichSignal()) { + histos.fill(HIST("PIDQA/hRichNSigmaPicc"), xiccCand.piccPt(), xiccCand.piccRichNSigma()); + } + + histos.fill(HIST("PIDQA/hPdgCodes"), 1, getBin(pdgToBin, std::abs(xiccCand.pi1cPdgCode()))); + histos.fill(HIST("PIDQA/hPdgCodes"), 2, getBin(pdgToBin, std::abs(xiccCand.pi2cPdgCode()))); + histos.fill(HIST("PIDQA/hPdgCodes"), 3, getBin(pdgToBin, std::abs(xiccCand.piccPdgCode()))); + } + + if constexpr (requires { xiccCand.negPt(); }) { // if extra table + histos.fill(HIST("XiccProngs/h3dNeg"), xiccCand.xiccPt(), xiccCand.negPt(), xiccCand.negEta()); + histos.fill(HIST("XiccProngs/h3dPos"), xiccCand.xiccPt(), xiccCand.posPt(), xiccCand.posEta()); + histos.fill(HIST("XiccProngs/h3dBach"), xiccCand.xiccPt(), xiccCand.bachPt(), xiccCand.bachEta()); + histos.fill(HIST("XiccProngs/h3dPi1c"), xiccCand.xiccPt(), xiccCand.pi1cPt(), xiccCand.pi1cEta()); + histos.fill(HIST("XiccProngs/h3dPi2c"), xiccCand.xiccPt(), xiccCand.pi2cPt(), xiccCand.pi2cEta()); + histos.fill(HIST("XiccProngs/h3dPicc"), xiccCand.xiccPt(), xiccCand.piccPt(), xiccCand.piccEta()); + } + + histos.fill(HIST("hXiccMass"), xiccCand.xiccMass()); + histos.fill(HIST("hXicMass"), xiccCand.xicMass()); + histos.fill(HIST("hXiccPt"), xiccCand.xiccPt()); + histos.fill(HIST("hXicPt"), xiccCand.xicPt()); + histos.fill(HIST("h3dXicc"), xiccCand.xiccPt(), xiccCand.xiccEta(), xiccCand.xiccMass()); + } + } + + void processXicc(aod::MCharmCores const& multiCharmTracks) + { + genericProcessXicc(multiCharmTracks); + } + + void processXiccPID(multiCharmTracksPID const& multiCharmTracks) + { + genericProcessXicc(multiCharmTracks); + } + + void processXiccExtra(multiCharmTracksFull const& multiCharmTracks) + { + genericProcessXicc(multiCharmTracks); + } + + PROCESS_SWITCH(alice3multicharm, processXicc, "find Xicc baryons", true); + PROCESS_SWITCH(alice3multicharm, processXiccPID, "find Xicc baryons with more QA from PID information", false); + PROCESS_SWITCH(alice3multicharm, processXiccExtra, "find Xicc baryons with all QA", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/ALICE3/Tasks/alice3-taskcorrelationDDbar.cxx b/ALICE3/Tasks/alice3-taskcorrelationDDbar.cxx new file mode 100644 index 00000000000..b6c8058f747 --- /dev/null +++ b/ALICE3/Tasks/alice3-taskcorrelationDDbar.cxx @@ -0,0 +1,434 @@ +// 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. + +/// \file taskCorrelationDDbar.cxx +/// \brief D0-D0bar correlation analysis task - data-like and MC-reco analysis performance on ALICE 3 detector. +/// +/// \author Fabio Colamaria , INFN Bari + +#include + +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/Utils/utilsAnalysis.h" +#include "PWGHF/HFC/DataModel/CorrelationTables.h" +// #include "PWGHF/DataModel/CandidateReconstructionTables.h" +// #include "PWGHF/DataModel/CandidateSelectionTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +using DDbarPairFull = soa::Join; +} // namespace o2::aod + +/// +/// Returns deltaPhi value in range [-pi/2., 3.*pi/2], typically used for correlation studies +/// +double getDeltaPhi(double phiD, double phiDbar) +{ + return RecoDecay::constrainAngle(phiDbar - phiD, -o2::constants::math::PIHalf); +} + +/// +/// Returns phi of candidate/particle evaluated from x and y components of segment connecting primary and secondary vertices +/// +double evaluatePhiByVertex(double xVertex1, double xVertex2, double yVertex1, double yVertex2) +{ + return RecoDecay::phi(xVertex2 - xVertex1, yVertex2 - yVertex1); +} + +// string definitions, used for histogram axis labels +const TString stringPtD = "#it{p}_{T}^{D} (GeV/#it{c});"; +const TString stringPtDbar = "#it{p}_{T}^{Dbar} (GeV/#it{c});"; +const TString stringDeltaPt = "#it{p}_{T}^{Dbar}-#it{p}_{T}^{D} (GeV/#it{c});"; +const TString stringDeltaPtMaxMin = "#it{p}_{T}^{max}-#it{p}_{T}^{min} (GeV/#it{c});"; +const TString stringDeltaEta = "#it{#eta}^{Dbar}-#it{#eta}^{D};"; +const TString stringDeltaPhi = "#it{#varphi}^{Dbar}-#it{#varphi}^{D} (rad);"; +const TString stringDDbar = "D,Dbar candidates "; +const TString stringSignal = "signal region;"; +const TString stringSideband = "sidebands;"; +const TString stringMCParticles = "MC gen - D,Dbar particles;"; +const TString stringMCReco = "MC reco - D,Dbar candidates "; + +// definition of vectors for standard ptbin and invariant mass configurables +const int npTBinsCorrelations = 8; +const double pTBinsCorrelations[npTBinsCorrelations + 1] = {0., 2., 4., 6., 8., 12., 16., 24., 99.}; +auto pTBinsCorrelations_v = std::vector{pTBinsCorrelations, pTBinsCorrelations + npTBinsCorrelations + 1}; +const double signalRegionInnerDefault[npTBinsCorrelations] = {1.810, 1.810, 1.810, 1.810, 1.810, 1.810, 1.810, 1.810}; +const double signalRegionOuterDefault[npTBinsCorrelations] = {1.922, 1.922, 1.922, 1.922, 1.922, 1.922, 1.922, 1.922}; +const double sidebandLeftInnerDefault[npTBinsCorrelations] = {1.642, 1.642, 1.642, 1.642, 1.642, 1.642, 1.642, 1.642}; +const double sidebandLeftOuterDefault[npTBinsCorrelations] = {1.754, 1.754, 1.754, 1.754, 1.754, 1.754, 1.754, 1.754}; +const double sidebandRightInnerDefault[npTBinsCorrelations] = {1.978, 1.978, 1.978, 1.978, 1.978, 1.978, 1.978, 1.978}; +const double sidebandRightOuterDefault[npTBinsCorrelations] = {2.090, 2.090, 2.090, 2.090, 2.090, 2.090, 2.090, 2.090}; +auto signalRegionInner_v = std::vector{signalRegionInnerDefault, signalRegionInnerDefault + npTBinsCorrelations}; +auto signalRegionOuter_v = std::vector{signalRegionOuterDefault, signalRegionOuterDefault + npTBinsCorrelations}; +auto sidebandLeftInner_v = std::vector{sidebandLeftInnerDefault, sidebandLeftInnerDefault + npTBinsCorrelations}; +auto sidebandLeftOuter_v = std::vector{sidebandLeftOuterDefault, sidebandLeftOuterDefault + npTBinsCorrelations}; +auto sidebandRightInner_v = std::vector{sidebandRightInnerDefault, sidebandRightInnerDefault + npTBinsCorrelations}; +auto sidebandRightOuter_v = std::vector{sidebandRightOuterDefault, sidebandRightOuterDefault + npTBinsCorrelations}; +const int npTBinsEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::NBinsPt; +const double efficiencyDmesonDefault[npTBinsEfficiency] = {}; +auto efficiencyDmeson_v = std::vector{efficiencyDmesonDefault, efficiencyDmesonDefault + npTBinsEfficiency}; + +struct alice3taskcorrelationddbar { + Configurable applyEfficiency{"applyEfficiency", 1, "Flag for applying efficiency weights"}; + // pT ranges for correlation plots: the default values are those embedded in hf_cuts_d0_to_pi_k (i.e. the mass pT bins), but can be redefined via json files + Configurable> binsPtCorrelations{"binsPtCorrelations", std::vector{pTBinsCorrelations_v}, "pT bin limits for correlation plots"}; + // pT bins for effiencies: same as above + Configurable> binsPtEfficiency{"binsPtEfficiency", std::vector{o2::analysis::hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for efficiency"}; + // signal and sideband region edges, to be defined via json file (initialised to empty) + Configurable> signalRegionInner{"signalRegionInner", std::vector{signalRegionInner_v}, "Inner values of signal region vs pT"}; + Configurable> signalRegionOuter{"signalRegionOuter", std::vector{signalRegionOuter_v}, "Outer values of signal region vs pT"}; + Configurable> sidebandLeftInner{"sidebandLeftInner", std::vector{sidebandLeftInner_v}, "Inner values of left sideband vs pT"}; + Configurable> sidebandLeftOuter{"sidebandLeftOuter", std::vector{sidebandLeftOuter_v}, "Outer values of left sideband vs pT"}; + Configurable> sidebandRightInner{"sidebandRightInner", std::vector{sidebandRightInner_v}, "Inner values of right sideband vs pT"}; + Configurable> sidebandRightOuter{"sidebandRightOuter", std::vector{sidebandRightOuter_v}, "Outer values of right sideband vs pT"}; + Configurable> efficiencyD{"efficiencyD", std::vector{efficiencyDmeson_v}, "Efficiency values for D meson specie under study"}; + + HistogramRegistry registry{ + "registry", + // NOTE: use hMassD0 (from correlator task) for normalisation, and hMass2DCorrelationPairs for 2D-sideband-subtraction purposes + {{"hMass2DCorrelationPairs", stringDDbar + "2D;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hDeltaEtaPtIntSignalRegion", stringDDbar + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {{200, -10., 10.}}}}, + {"hDeltaPhiPtIntSignalRegion", stringDDbar + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}}}}, + {"hCorrel2DPtIntSignalRegion", stringDDbar + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {200, -10., 10.}}}}, + {"hCorrel2DVsPtSignalRegion", stringDDbar + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hDeltaPtDDbarSignalRegion", stringDDbar + stringSignal + stringDeltaPt + "entries", {HistType::kTH1F, {{144, -36., 36.}}}}, + {"hDeltaPtMaxMinSignalRegion", stringDDbar + stringSignal + stringDeltaPtMaxMin + "entries", {HistType::kTH1F, {{72, 0., 36.}}}}, + {"hDeltaEtaPtIntSidebands", stringDDbar + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {{200, -10., 10.}}}}, + {"hDeltaPhiPtIntSidebands", stringDDbar + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}}}}, + {"hCorrel2DPtIntSidebands", stringDDbar + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {200, -10., 10.}}}}, + {"hCorrel2DVsPtSidebands", stringDDbar + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hDeltaPtDDbarSidebands", stringDDbar + stringSideband + stringDeltaPt + "entries", {HistType::kTH1F, {{144, -36., 36.}}}}, + {"hDeltaPtMaxMinSidebands", stringDDbar + stringSideband + stringDeltaPtMaxMin + "entries", {HistType::kTH1F, {{72, 0., 36.}}}}, + {"hMass2DCorrelationPairsMCRecBkgBkg", stringDDbar + "2D BkgBkg - MC reco;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hMass2DCorrelationPairsMCRecBkgRef", stringDDbar + "2D BkgRef - MC reco;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hMass2DCorrelationPairsMCRecBkgSig", stringDDbar + "2D BkgSig - MC reco;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hMass2DCorrelationPairsMCRecRefBkg", stringDDbar + "2D RefBkg - MC reco;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hMass2DCorrelationPairsMCRecRefRef", stringDDbar + "2D RefRef - MC reco;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hMass2DCorrelationPairsMCRecRefSig", stringDDbar + "2D RefSig - MC reco;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hMass2DCorrelationPairsMCRecSigBkg", stringDDbar + "2D SigBkg - MC reco;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hMass2DCorrelationPairsMCRecSigRef", stringDDbar + "2D SigRef - MC reco;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hMass2DCorrelationPairsMCRecSigSig", stringDDbar + "2D SigSig - MC reco;inv. mass D (GeV/#it{c}^{2});inv. mass Dbar (GeV/#it{c}^{2});" + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{200, 1.6, 2.1}, {200, 1.6, 2.1}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hDeltaEtaPtIntSignalRegionMCRec", stringMCReco + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {{200, -10., 10.}}}}, + {"hDeltaPhiPtIntSignalRegionMCRec", stringMCReco + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}}}}, + {"hCorrel2DPtIntSignalRegionMCRec", stringMCReco + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {200, -10., 10.}}}}, + {"hDeltaPtDDbarSignalRegionMCRec", stringMCReco + stringSignal + stringDeltaPt + "entries", {HistType::kTH1F, {{144, -36., 36.}}}}, + {"hDeltaPtMaxMinSignalRegionMCRec", stringMCReco + stringSignal + stringDeltaPtMaxMin + "entries", {HistType::kTH1F, {{72, 0., 36.}}}}, + {"hCorrel2DVsPtSignalRegionMCRecBkgBkg", stringMCReco + "BkgBkg" + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSignalRegionMCRecBkgRef", stringMCReco + "BkgRef" + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSignalRegionMCRecBkgSig", stringMCReco + "BkgSig" + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSignalRegionMCRecRefBkg", stringMCReco + "RefBkg" + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSignalRegionMCRecRefRef", stringMCReco + "RefRef" + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSignalRegionMCRecRefSig", stringMCReco + "RefSig" + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSignalRegionMCRecSigBkg", stringMCReco + "SigBkg" + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSignalRegionMCRecSigRef", stringMCReco + "SigRef" + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSignalRegionMCRecSigSig", stringMCReco + "SigSig" + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hDeltaEtaPtIntSidebandsMCRec", stringMCReco + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {{200, -10., 10.}}}}, + {"hDeltaPhiPtIntSidebandsMCRec", stringMCReco + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}}}}, + {"hCorrel2DPtIntSidebandsMCRec", stringMCReco + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {200, -10., 10.}}}}, + {"hDeltaPtDDbarSidebandsMCRec", stringMCReco + stringSideband + stringDeltaPt + "entries", {HistType::kTH1F, {{144, -36., 36.}}}}, + {"hDeltaPtMaxMinSidebandsMCRec", stringMCReco + stringSideband + stringDeltaPtMaxMin + "entries", {HistType::kTH1F, {{72, 0., 36.}}}}, + {"hCorrel2DVsPtSidebandsMCRecBkgBkg", stringMCReco + "BkgBkg" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSidebandsMCRecBkgRef", stringMCReco + "BkgRef" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSidebandsMCRecBkgSig", stringMCReco + "BkgSig" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSidebandsMCRecRefBkg", stringMCReco + "RefBkg" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSidebandsMCRecRefRef", stringMCReco + "RefRef" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSidebandsMCRecRefSig", stringMCReco + "RefSig" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSidebandsMCRecSigBkg", stringMCReco + "SigBkg" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSidebandsMCRecSigRef", stringMCReco + "SigRef" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}, // note: axes 3 and 4 (the pT) are updated in the init() + {"hCorrel2DVsPtSidebandsMCRecSigSig", stringMCReco + "SigSig" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtDbar + "entries", {HistType::kTHnSparseD, {{64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {120, -6., 6.}, {10, 0., 10.}, {10, 0., 10.}}}}}}; // note: axes 3 and 4 (the pT) are updated in the init() + + void init(InitContext&) + { + // redefinition of pT axes for THnSparse holding correlation entries + int nBinspTaxis = binsPtCorrelations->size() - 1; + const double* valuespTaxis = binsPtCorrelations->data(); + + for (int i = 2; i <= 3; i++) { + registry.get(HIST("hMass2DCorrelationPairs"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegion"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebands"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairs"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegion"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebands"))->Sumw2(); + registry.get(HIST("hMass2DCorrelationPairsMCRecBkgBkg"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairsMCRecBkgRef"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairsMCRecBkgSig"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairsMCRecRefBkg"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairsMCRecRefRef"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairsMCRecRefSig"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairsMCRecSigBkg"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairsMCRecSigRef"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairsMCRecSigSig"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecBkgBkg"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecBkgRef"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecBkgSig"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecRefBkg"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecRefRef"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecRefSig"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecSigBkg"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecSigRef"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecSigSig"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecBkgBkg"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecBkgRef"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecBkgSig"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecRefBkg"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecRefRef"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecRefSig"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecSigBkg"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecSigRef"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecSigSig"))->GetAxis(i)->Set(nBinspTaxis, valuespTaxis); + registry.get(HIST("hMass2DCorrelationPairsMCRecBkgBkg"))->Sumw2(); + registry.get(HIST("hMass2DCorrelationPairsMCRecBkgRef"))->Sumw2(); + registry.get(HIST("hMass2DCorrelationPairsMCRecBkgSig"))->Sumw2(); + registry.get(HIST("hMass2DCorrelationPairsMCRecRefBkg"))->Sumw2(); + registry.get(HIST("hMass2DCorrelationPairsMCRecRefRef"))->Sumw2(); + registry.get(HIST("hMass2DCorrelationPairsMCRecRefSig"))->Sumw2(); + registry.get(HIST("hMass2DCorrelationPairsMCRecSigBkg"))->Sumw2(); + registry.get(HIST("hMass2DCorrelationPairsMCRecSigRef"))->Sumw2(); + registry.get(HIST("hMass2DCorrelationPairsMCRecSigSig"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecBkgBkg"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecBkgRef"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecBkgSig"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecRefBkg"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecRefRef"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecRefSig"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecSigBkg"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecSigRef"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMCRecSigSig"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecBkgBkg"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecBkgRef"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecBkgSig"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecRefBkg"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecRefRef"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecRefSig"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecSigBkg"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecSigRef"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMCRecSigSig"))->Sumw2(); + } + } + + /// D-Dbar correlation pair filling task, from pair tables - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) + /// Works on both USL and LS analyses pair tables + void processData(aod::DDbarPairFull const& pairEntries) + { + for (const auto& pairEntry : pairEntries) { + // define variables for widely used quantities + double deltaPhi = pairEntry.deltaPhi(); + double deltaEta = pairEntry.deltaEta(); + double ptD = pairEntry.ptD(); + double ptDbar = pairEntry.ptDbar(); + double massD = pairEntry.mD(); + double massDbar = pairEntry.mDbar(); + + int pTBinD = o2::analysis::findBin(binsPtCorrelations, ptD); + int pTBinDbar = o2::analysis::findBin(binsPtCorrelations, ptDbar); + + double efficiencyWeight = 1.; + if (applyEfficiency) { + efficiencyWeight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiency, ptD)) * efficiencyD->at(o2::analysis::findBin(binsPtEfficiency, ptDbar))); + } + + // fill 2D invariant mass plots + registry.fill(HIST("hMass2DCorrelationPairs"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + + // reject entries outside pT ranges of interest + if (pTBinD == -1 || pTBinDbar == -1) { // at least one particle outside accepted pT range + continue; + } + + // check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots + if (massD > signalRegionInner->at(pTBinD) && massD < signalRegionOuter->at(pTBinD) && massDbar > signalRegionInner->at(pTBinDbar) && massDbar < signalRegionOuter->at(pTBinDbar)) { + // in signal region + registry.fill(HIST("hCorrel2DVsPtSignalRegion"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + registry.fill(HIST("hCorrel2DPtIntSignalRegion"), deltaPhi, deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSignalRegion"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSignalRegion"), deltaPhi, efficiencyWeight); + registry.fill(HIST("hDeltaPtDDbarSignalRegion"), ptDbar - ptD, efficiencyWeight); + registry.fill(HIST("hDeltaPtMaxMinSignalRegion"), std::abs(ptDbar - ptD), efficiencyWeight); + } + + if ((massD > sidebandLeftInner->at(pTBinD) && massD < sidebandLeftOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar)) || + (massD > sidebandRightInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar)) || + (massD > sidebandLeftInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandLeftOuter->at(pTBinDbar)) || + (massD > sidebandLeftInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandRightInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar))) { + // in sideband region + registry.fill(HIST("hCorrel2DVsPtSidebands"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + registry.fill(HIST("hCorrel2DPtIntSidebands"), deltaPhi, deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSidebands"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSidebands"), deltaPhi, efficiencyWeight); + registry.fill(HIST("hDeltaPtDDbarSidebands"), ptDbar - ptD, efficiencyWeight); + registry.fill(HIST("hDeltaPtMaxMinSidebands"), std::abs(ptDbar - ptD), efficiencyWeight); + } + } // end loop + } + + PROCESS_SWITCH(alice3taskcorrelationddbar, processData, "Process data", true); + + /// D-Dbar correlation pair filling task, from pair tables - for MC reco-level analysis (candidates matched to true signal only, but also bkg sources are studied) + /// Works on both USL and LS analyses pair tables + void processMcRec(aod::DDbarPairFull const& pairEntries) + { + for (const auto& pairEntry : pairEntries) { + // define variables for widely used quantities + double deltaPhi = pairEntry.deltaPhi(); + double deltaEta = pairEntry.deltaEta(); + double ptD = pairEntry.ptD(); + double ptDbar = pairEntry.ptDbar(); + double massD = pairEntry.mD(); + double massDbar = pairEntry.mDbar(); + + int pTBinD = o2::analysis::findBin(binsPtCorrelations, ptD); + int pTBinDbar = o2::analysis::findBin(binsPtCorrelations, ptDbar); + + double efficiencyWeight = 1.; + if (applyEfficiency) { + efficiencyWeight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiency, ptD)) * efficiencyD->at(o2::analysis::findBin(binsPtEfficiency, ptDbar))); + } + + // fill 2D invariant mass plots + switch (pairEntry.signalStatus()) { + case 0: // D Bkg, Dbar Bkg + registry.fill(HIST("hMass2DCorrelationPairsMCRecBkgBkg"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + break; + case 1: // D Bkg, Dbar Ref + registry.fill(HIST("hMass2DCorrelationPairsMCRecBkgRef"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + break; + case 2: // D Bkg, Dbar Sig + registry.fill(HIST("hMass2DCorrelationPairsMCRecBkgSig"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + break; + case 3: // D Ref, Dbar Bkg + registry.fill(HIST("hMass2DCorrelationPairsMCRecRefBkg"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + break; + case 4: // D Ref, Dbar Ref + registry.fill(HIST("hMass2DCorrelationPairsMCRecRefRef"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + break; + case 5: // D Ref, Dbar Sig + registry.fill(HIST("hMass2DCorrelationPairsMCRecRefSig"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + break; + case 6: // D Sig, Dbar Bkg + registry.fill(HIST("hMass2DCorrelationPairsMCRecSigBkg"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + break; + case 7: // D Sig, Dbar Ref + registry.fill(HIST("hMass2DCorrelationPairsMCRecSigRef"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + break; + case 8: // D Sig, Dbar Sig + registry.fill(HIST("hMass2DCorrelationPairsMCRecSigSig"), massD, massDbar, ptD, ptDbar, efficiencyWeight); + break; + default: // should not happen for MC reco + break; + } + + // reject entries outside pT ranges of interest + if (pTBinD == -1 || pTBinDbar == -1) { // at least one particle outside accepted pT range + continue; + } + + // check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots + if (massD > signalRegionInner->at(pTBinD) && massD < signalRegionOuter->at(pTBinD) && massDbar > signalRegionInner->at(pTBinDbar) && massDbar < signalRegionOuter->at(pTBinDbar)) { + // in signal region + registry.fill(HIST("hCorrel2DPtIntSignalRegionMCRec"), deltaPhi, deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSignalRegionMCRec"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSignalRegionMCRec"), deltaPhi, efficiencyWeight); + registry.fill(HIST("hDeltaPtDDbarSignalRegionMCRec"), ptDbar - ptD, efficiencyWeight); + registry.fill(HIST("hDeltaPtMaxMinSignalRegionMCRec"), std::abs(ptDbar - ptD), efficiencyWeight); + switch (pairEntry.signalStatus()) { + case 0: // D Bkg, Dbar Bkg + registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecBkgBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 1: // D Bkg, Dbar Ref + registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecBkgRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 2: // D Bkg, Dbar Sig + registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecBkgSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 3: // D Ref, Dbar Bkg + registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecRefBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 4: // D Ref, Dbar Ref + registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecRefRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 5: // D Ref, Dbar Sig + registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecRefSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 6: // D Sig, Dbar Bkg + registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecSigBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 7: // D Sig, Dbar Ref + registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecSigRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 8: // D Sig, Dbar Sig + registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecSigSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + default: // should not happen for MC reco + break; + } + } + + if ((massD > sidebandLeftInner->at(pTBinD) && massD < sidebandLeftOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar)) || + (massD > sidebandRightInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar)) || + (massD > sidebandLeftInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandLeftOuter->at(pTBinDbar)) || + (massD > sidebandLeftInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandRightInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar))) { + // in sideband region + registry.fill(HIST("hCorrel2DPtIntSidebandsMCRec"), deltaPhi, deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSidebandsMCRec"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSidebandsMCRec"), deltaPhi, efficiencyWeight); + registry.fill(HIST("hDeltaPtDDbarSidebandsMCRec"), ptDbar - ptD, efficiencyWeight); + registry.fill(HIST("hDeltaPtMaxMinSidebandsMCRec"), std::abs(ptDbar - ptD), efficiencyWeight); + switch (pairEntry.signalStatus()) { + case 0: // D Bkg, Dbar Bkg + registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecBkgBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 1: // D Bkg, Dbar Ref + registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecBkgRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 2: // D Bkg, Dbar Sig + registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecBkgSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 3: // D Ref, Dbar Bkg + registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecRefBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 4: // D Ref, Dbar Ref + registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecRefRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 5: // D Ref, Dbar Sig + registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecRefSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 6: // D Sig, Dbar Bkg + registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecSigBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 7: // D Sig, Dbar Ref + registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecSigRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + case 8: // D Sig, Dbar Sig + registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecSigSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); + break; + default: // should not happen for MC reco + break; + } + } + } // end loop + } + + PROCESS_SWITCH(alice3taskcorrelationddbar, processMcRec, "Process MC Reco mode", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/ALICE3/Tasks/alice3Efficiency.cxx b/ALICE3/Tasks/alice3Efficiency.cxx new file mode 100644 index 00000000000..7741ea24696 --- /dev/null +++ b/ALICE3/Tasks/alice3Efficiency.cxx @@ -0,0 +1,103 @@ +// 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. +/// +/// \file alice3Efficiency.cxx +/// +/// \brief This task produces the efficiency +/// +/// \author Nicolò Jacazio, Universita del Piemonte Orientale (IT) +/// \since May 27, 2025 +/// + +#include +#include + +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/ConfigParamRegistry.h" +#include "TEfficiency.h" +#include "THashList.h" + +using namespace o2; +using namespace o2::framework; +std::map effVsPt; +std::map effVsEta; + +struct alice3Efficiency { + Configurable> pdgCodes{"pdgCodes", {211}, "List of PDG codes to consider for efficiency calculation"}; + OutputObj outList{"output"}; + Configurable> etaRange{"etaRange", {-5.f, 5.f}, "Eta range for efficiency calculation"}; + void init(o2::framework::InitContext&) + { + outList.setObject(new THashList); + auto createEff = [&](const char* baseName, const char* axisTitle, int pdg, int nBins, double min, double max) { + auto eff = new TEfficiency(Form("%s_pdg%d", baseName, pdg), + Form("Efficiency for PDG %d; %s; Efficiency", pdg, axisTitle), + nBins, min, max); + outList->Add(eff); + return eff; + }; + for (auto pdg : pdgCodes.value) { + effVsPt[pdg] = createEff("efficiency", "p_{T} (GeV/c)", pdg, 100, 0, 10); + effVsEta[pdg] = createEff("efficiency_eta", "#eta", pdg, 100, -5, 5); + } + } + + void process(soa::Join const& tracks, + aod::McParticles const& mcParticles) + { + std::map> pdgIndices; + + // Lambda function to select particles after all cuts + auto isParticleSelected = [&](const o2::aod::McParticle& p) { + if (!p.isPhysicalPrimary()) { + return false; + } + if (p.eta() < etaRange.value.first) { + return false; + } + if (p.eta() > etaRange.value.second) { + return false; + } + return true; + }; + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + const auto& mcParticle = track.mcParticle(); + if (!isParticleSelected(mcParticle)) { + continue; + } + pdgIndices[mcParticle.pdgCode()].push_back(mcParticle.globalIndex()); + } + + for (auto& mc : mcParticles) { + if (effVsPt.find(mc.pdgCode()) == effVsPt.end()) { + continue; + } + if (!isParticleSelected(mc)) { + continue; + } + std::vector& indices = pdgIndices[mc.pdgCode()]; + // Fill efficiency histogram + const bool found = std::find(indices.begin(), indices.end(), mc.globalIndex()) != indices.end(); + effVsPt[mc.pdgCode()]->Fill(found, mc.pt()); + effVsEta[mc.pdgCode()]->Fill(found, mc.eta()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& ctx) +{ + return WorkflowSpec{adaptAnalysisTask(ctx)}; +} diff --git a/ALICE3/Tasks/alice3SeparationPower.cxx b/ALICE3/Tasks/alice3SeparationPower.cxx new file mode 100644 index 00000000000..ae5b52d0692 --- /dev/null +++ b/ALICE3/Tasks/alice3SeparationPower.cxx @@ -0,0 +1,106 @@ +// 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. +/// +/// \file alice3SeparationPower.cxx +/// +/// \brief This task produces the separation power of the ALICE3 detector +/// +/// \author Nicolò Jacazio, Universita del Piemonte Orientale (IT) +/// \since May 13, 2025 +/// + +#include +#include +#include +#include + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/HistogramRegistry.h" +#include "TProfile2D.h" +#include "THashList.h" +#include "ALICE3/DataModel/OTFTOF.h" +#include "ALICE3/DataModel/OTFRICH.h" + +using namespace o2; +using namespace o2::framework; + +std::array separationInnerTOF; +std::array separationOuterTOF; +std::array separationRICH; +struct alice3SeparationPower { + + ConfigurableAxis etaAxis{"etaAxis", {100, -1.f, 1.f}, "Binning in eta"}; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + OutputObj listSeparation{"separationPower"}; + void init(o2::framework::InitContext&) + { + listSeparation.setObject(new THashList); + for (int i = 0; i < 5; i++) { + auto createEfficiency = [&](const char* name, const char* title) { + TProfile2D* eff = new TProfile2D(Form("%s_%d", name, i), + Form("%s_%d;%s", title, i, "#it{p}_{T} (GeV/#it{c});#it{#eta}"), + 100, 0.f, 10.f, + 100, 0.f, 10.f); + listSeparation->Add(eff); + return eff; + }; + separationInnerTOF[i] = createEfficiency("separationInnerTOF", "separationInnerTOF"); + separationOuterTOF[i] = createEfficiency("separationOuterTOF", "separationOuterTOF"); + separationRICH[i] = createEfficiency("separationRICH", "separationRICH"); + } + } + + void process(soa::Join::iterator const& /*collision*/, + soa::Join const& tracks, + aod::McParticles const&, + aod::McCollisions const&) + { + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + // Check that all the nsigmas are numbers (sanity check) + for (int i = 0; i < 5; i++) { + if (std::isnan(track.nSigmaInnerTOF(i)) || std::isnan(track.nSigmaOuterTOF(i))) { + LOG(fatal) << "Unrecognized nsigma for " << i << " " << track.nSigmaInnerTOF(i) << " " << track.nSigmaOuterTOF(i); + } + } + + const auto& mcParticle = track.mcParticle(); + // Separation electron pion + switch (std::abs(mcParticle.pdgCode())) { + { + case 211: // electron-pion separation + separationInnerTOF[0]->Fill(track.pt(), track.eta(), track.nSigmaInnerTOF(0)); + separationOuterTOF[0]->Fill(track.pt(), track.eta(), track.nSigmaOuterTOF(0)); + // separationRICH[0]->Fill(track.pt(), track.eta(), track.nSigmaElectronRich() ); + break; + case 321: // pion-kaon separation + separationInnerTOF[1]->Fill(track.pt(), track.eta(), track.nSigmaInnerTOF(1)); + separationOuterTOF[1]->Fill(track.pt(), track.eta(), track.nSigmaInnerTOF(1)); + // separationRICH[1]->Fill(track.pt(), track.eta(), track.nSigmaPionRich() ); + break; + case 2212: // kaon-proton separation + separationInnerTOF[2]->Fill(track.pt(), track.eta(), track.nSigmaInnerTOF(2)); + separationOuterTOF[2]->Fill(track.pt(), track.eta(), track.nSigmaInnerTOF(2)); + // separationRICH[2]->Fill((track.nSigmaKaonRich() > 3.f), track.pt(), track.eta()); + default: + break; + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/ALICE3/Tasks/alice3TrackingPerformance.cxx b/ALICE3/Tasks/alice3TrackingPerformance.cxx new file mode 100644 index 00000000000..bfb9418bb2c --- /dev/null +++ b/ALICE3/Tasks/alice3TrackingPerformance.cxx @@ -0,0 +1,94 @@ +// 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. +/// +/// \file alice3TrackingPerformance.cxx +/// +/// \brief This task produces the tracking performance +/// +/// \author Nicolò Jacazio, Universita del Piemonte Orientale (IT) +/// \since May 27, 2025 +/// + +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/ConfigParamRegistry.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include +#include + +using namespace o2; +using namespace o2::framework; +std::map> ptResolutionVsPt; +std::map> invPtResolutionVsPt; +std::map> dcaXyResolutionVsPt; +std::map> dcaZResolutionVsPt; + +struct alice3TrackingPerformance { + Configurable> pdgCodes{"pdgCodes", {211}, "List of PDG codes to consider for efficiency calculation"}; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable> etaRange{"etaRange", {-5.f, 5.f}, "Eta range for efficiency calculation"}; + + void init(o2::framework::InitContext&) + { + const AxisSpec axisPt{100, 0, 10, "p_{T} (GeV/c)"}; + const AxisSpec axisPtDelta{100, -1, 1, "p_{T}^{gen} - p_{T}^{reco} (GeV/c)"}; + const AxisSpec axisInvPtDelta{100, -1, 1, "1./p_{T}^{gen} - 1./p_{T}^{reco} (GeV/c)^{-1}"}; + const AxisSpec axisDcaXy{100, -1, 1, "DCA_{xy} (cm)"}; + const AxisSpec axisDcaZ{100, -1, 1, "DCA_{z} (cm)"}; + for (auto pdg : pdgCodes.value) { + ptResolutionVsPt[pdg] = histos.add(Form("ptResolutionVsPt_%d", pdg), "", kTH2D, {axisPt, axisPtDelta}); + invPtResolutionVsPt[pdg] = histos.add(Form("invPtResolutionVsPt_%d", pdg), "", kTH2D, {axisPt, axisInvPtDelta}); + dcaXyResolutionVsPt[pdg] = histos.add(Form("dcaXyResolutionVsPt_%d", pdg), "", kTH2D, {axisPt, axisDcaXy}); + dcaZResolutionVsPt[pdg] = histos.add(Form("dcaZResolutionVsPt_%d", pdg), "", kTH2D, {axisPt, axisDcaZ}); + } + } + + void process(soa::Join const& tracks, + aod::McParticles const&) + { + auto isParticleSelected = [&](const o2::aod::McParticle& p) { + if (!p.isPhysicalPrimary()) { + return false; + } + if (p.eta() < etaRange.value.first) { + return false; + } + if (p.eta() > etaRange.value.second) { + return false; + } + return true; + }; + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + const auto& mcParticle = track.mcParticle(); + if (!isParticleSelected(mcParticle)) { + continue; + } + if (ptResolutionVsPt.find(mcParticle.pdgCode()) == ptResolutionVsPt.end()) { + continue; + } + ptResolutionVsPt[mcParticle.pdgCode()]->Fill(mcParticle.pt(), mcParticle.pt() - track.pt()); + invPtResolutionVsPt[mcParticle.pdgCode()]->Fill(mcParticle.pt(), 1.f / mcParticle.pt() - 1.f / track.pt()); + dcaXyResolutionVsPt[mcParticle.pdgCode()]->Fill(mcParticle.pt(), track.dcaXY()); + dcaZResolutionVsPt[mcParticle.pdgCode()]->Fill(mcParticle.pt(), track.dcaZ()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& ctx) +{ + return WorkflowSpec{adaptAnalysisTask(ctx)}; +} diff --git a/ALICE3/Tools/handleParamTOFResoALICE3.cxx b/ALICE3/Tools/handleParamTOFResoALICE3.cxx deleted file mode 100644 index 79184cfd8d2..00000000000 --- a/ALICE3/Tools/handleParamTOFResoALICE3.cxx +++ /dev/null @@ -1,132 +0,0 @@ -// 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. - -/// -/// \file handleParamTOFResoALICE3.cxx -/// \author Nicolo' Jacazio -/// \since 2020-06-22 -/// \brief A simple tool to produce Bethe Bloch parametrization objects for the TOF PID Response -/// - -#include "CCDB/CcdbApi.h" -#include -#include "Framework/Logger.h" -#include "TFile.h" -#include "ALICE3/Core/TOFResoALICE3.h" - -using namespace o2::pid::tof; -namespace bpo = boost::program_options; - -bool initOptionsAndParse(bpo::options_description& options, int argc, char* argv[], bpo::variables_map& vm) -{ - options.add_options()( - "url,u", bpo::value()->default_value("http://alice-ccdb.cern.ch"), "URL of the CCDB database")( - "ccdb-path,c", bpo::value()->default_value("Analysis/ALICE3/PID/TOF"), "CCDB path for storage/retrieval")( - "start,s", bpo::value()->default_value(0), "Start timestamp of object validity")( - "stop,S", bpo::value()->default_value(4108971600000), "Stop timestamp of object validity")( - "delete-previous,delete_previous,d", bpo::value()->default_value(0), "Flag to delete previous versions of converter objects in the CCDB before uploading the new one so as to avoid proliferation on CCDB")( - "save-to-file,file,f,o", bpo::value()->default_value(""), "Option to save parametrization to file instead of uploading to ccdb")( - "read-from-file,i", bpo::value()->default_value(""), "Option to get parametrization from a file")( - "reso-name,n", bpo::value()->default_value("TOFResoALICE3"), "Name of the parametrization object")( - "mode,m", bpo::value()->default_value(1), "Working mode: 0 push 1 pull and test")( - "p0", bpo::value()->default_value(20.0f), "Parameter 0 of the TOF resolution: average TOF resolution")( - "verbose,v", bpo::value()->default_value(0), "Verbose level 0, 1")( - "help,h", "Produce help message."); - try { - bpo::store(parse_command_line(argc, argv, options), vm); - - // help - if (vm.count("help")) { - LOG(info) << options; - return false; - } - - bpo::notify(vm); - } catch (const bpo::error& e) { - LOG(error) << e.what() << "\n"; - LOG(error) << "Error parsing command line arguments; Available options:"; - LOG(error) << options; - return false; - } - return true; -} - -int main(int argc, char* argv[]) -{ - bpo::options_description options("Allowed options"); - bpo::variables_map vm; - if (!initOptionsAndParse(options, argc, argv, vm)) { - return 1; - } - - const unsigned int mode = vm["mode"].as(); - const std::string path = vm["ccdb-path"].as(); - std::map metadata; - std::map* headers = nullptr; - o2::ccdb::CcdbApi api; - const std::string url = vm["url"].as(); - api.init(url); - if (!api.isHostReachable()) { - LOG(warning) << "CCDB host " << url << " is not reacheable, cannot go forward"; - return 1; - } - TOFResoALICE3* reso = nullptr; - const std::string reso_name = vm["reso-name"].as(); - if (mode == 0) { // Push mode - LOG(info) << "Handling TOF parametrization in create mode"; - const std::string input_file_name = vm["read-from-file"].as(); - if (!input_file_name.empty()) { - TFile f(input_file_name.data(), "READ"); - if (!f.IsOpen()) { - LOG(warning) << "Input file " << input_file_name << " is not reacheable, cannot get param from file"; - } - f.GetObject(reso_name.c_str(), reso); - f.Close(); - } - if (!reso) { - reso = new TOFResoALICE3(); - const std::vector resoparams = {vm["p0"].as()}; - reso->SetParameters(resoparams); - } - reso->Print(); - const std::string fname = vm["save-to-file"].as(); - if (!fname.empty()) { // Saving it to file - LOG(info) << "Saving parametrization to file " << fname; - TFile f(fname.data(), "RECREATE"); - reso->Write(); - reso->GetParameters().Write(); - f.ls(); - f.Close(); - } else { // Saving it to CCDB - LOG(info) << "Saving parametrization to CCDB " << path; - - long start = vm["start"].as(); - long stop = vm["stop"].as(); - - if (vm["delete-previous"].as()) { - api.truncate(path); - } - api.storeAsTFileAny(reso, path + "/" + reso_name, metadata, start, stop); - o2::pid::Parameters* params; - reso->GetParameters(params); - api.storeAsTFileAny(params, path + "/Parameters/" + reso_name, metadata, start, stop); - } - } else { // Pull and test mode - LOG(info) << "Handling TOF parametrization in test mode"; - const float x[7] = {1, 1, 1, 1, 1, 1, 1}; // mom, time, ev. reso, mass, length, sigma1pt, pt - reso = api.retrieveFromTFileAny(path + "/" + reso_name, metadata, -1, headers); - reso->Print(); - LOG(info) << "TOF expected resolution at p=" << x[0] << " GeV/c " - << " and mass " << x[3] << ":" << reso->operator()(x); - } - - return 0; -} diff --git a/CODEOWNERS b/CODEOWNERS index ea2fc514796..57766839579 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -19,7 +19,9 @@ /DPG/Tasks/AOTEvent @alibuild @ekryshen @strogolo @altsybee /DPG/Tasks/AOTTrack @alibuild @mfaggin @iouribelikov @njacazio @lbariogl @f3sch /DPG/Tasks/TOF @alibuild @noferini @njacazio -/DPG/Tasks/FT0 @alibuild @afurs +/DPG/Tasks/FT0 @alibuild @jotwinow @sahilupadhyaya92 @andreasmolander @afurs +/DPG/Tasks/FV0 @alibuild @jotwinow @sahilupadhyaya92 @andreasmolander @afurs +/DPG/Tasks/FDD @alibuild @jotwinow @sahilupadhyaya92 @andreasmolander @afurs /EventFiltering @alibuild @mpuccio @lietava /EventFiltering/PWGHF @alibuild @fgrosa @zhangbiao-phy @mpuccio @lietava /EventFiltering/PWGUD @alibuild @pbuehler @mpuccio @lietava @@ -27,42 +29,44 @@ /EventFiltering/PWGCF @alibuild @lauraser @mpuccio @lietava /EventFiltering/PWGMM @alibuild @aortizve @mpuccio @lietava /EventFiltering/PWGJE @alibuild @fkrizek @nzardosh @mpuccio @lietava -/PWGCF @alibuild @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye -/PWGCF/Core @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye -/PWGCF/DataModel @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye -/PWGCF/TableProducer @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye -/PWGCF/Tasks @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye -/PWGDQ @alibuild @iarsene @dsekihat @feisenhu @lucamicheletti93 +/PWGCF @alibuild @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye @glromane +/PWGCF/Core @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye @glromane +/PWGCF/DataModel @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye @glromane +/PWGCF/TableProducer @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye @glromane +/PWGCF/Tasks @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye @glromane +/PWGDQ @alibuild @iarsene @mcoquet642 @lucamicheletti93 /PWGEM @alibuild @feisenhu @dsekihat @ivorobye -/PWGEM/Dilepton @alibuild @mikesas @rbailhac @dsekihat @ivorobye @feisenhu +/PWGEM/Dilepton @alibuild @mikesas @rbailhac @dsekihat @ivorobye @feisenhu @hscheid /PWGEM/PhotonMeson @alibuild @mikesas @rbailhac @m-c-danisch @novitzky @mhemmer-cern @dsekihat -/PWGHF @alibuild @vkucera @fcolamar @fgrosa @fcatalan92 @mfaggin @mmazzilli @deepathoms @NicoleBastid @hahassan7 @jpxrk @apalasciano +/PWGHF @alibuild @vkucera @fcolamar @fgrosa @fcatalan92 @mfaggin @mmazzilli @deepathoms @NicoleBastid @hahassan7 @jpxrk @apalasciano @zhangbiao-phy @gluparel # PWG-LF -/PWGLF @alibuild @njacazio @skundu692 -/PWGLF/Tasks/GlobalEventProperties @alibuild @njacazio @skundu692 @gbencedi @omvazque -/PWGLF/TableProducer/GlobalEventProperties @alibuild @njacazio @skundu692 @gbencedi @omvazque -/PWGLF/Tasks/Nuspex @alibuild @njacazio @skundu692 @fmazzasc @chiarapinto @maciacco -/PWGLF/TableProducer/Nuspex @alibuild @njacazio @skundu692 @fmazzasc @chiarapinto @maciacco -/PWGLF/Tasks/Resonances @alibuild @njacazio @skundu692 @dmallick2 @smaff92 -/PWGLF/TableProducer/Resonances @alibuild @njacazio @skundu692 @dmallick2 @smaff92 -/PWGLF/Tasks/Strangeness @alibuild @njacazio @skundu692 @ercolessi @ChiaraDeMartin95 -/PWGLF/TableProducer/Strangeness @alibuild @njacazio @skundu692 @ercolessi @ChiaraDeMartin95 +/PWGLF @alibuild @sustripathy @skundu692 +/PWGLF/DataModel @alibuild @sustripathy @skundu692 @gbencedi @abmodak @fmazzasc @maciacco @dmallick2 @smaff92 @ercolessi @romainschotter +/PWGLF/Tasks/GlobalEventProperties @alibuild @sustripathy @skundu692 @gbencedi @abmodak @omvazque +/PWGLF/TableProducer/GlobalEventProperties @alibuild @sustripathy @skundu692 @gbencedi @abmodak @omvazque +/PWGLF/Tasks/Nuspex @alibuild @sustripathy @skundu692 @fmazzasc @maciacco +/PWGLF/TableProducer/Nuspex @alibuild @sustripathy @skundu692 @fmazzasc @maciacco +/PWGLF/Tasks/Resonances @alibuild @sustripathy @skundu692 @dmallick2 @smaff92 +/PWGLF/TableProducer/Resonances @alibuild @sustripathy @skundu692 @dmallick2 @smaff92 +/PWGLF/Tasks/Strangeness @alibuild @sustripathy @skundu692 @ercolessi @romainschotter +/PWGLF/TableProducer/Strangeness @alibuild @sustripathy @skundu692 @ercolessi @romainschotter +/PWGLF/Utils @alibuild @sustripathy @skundu692 @gbencedi @abmodak @fmazzasc @maciacco @dmallick2 @smaff92 @ercolessi @romainschotter # PWG-MM -/PWGMM @alibuild @njacazio @skundu692 @aalkin -/PWGMM/Mult @alibuild @njacazio @skundu692 @aalkin @aortizve @ddobrigk -/PWGMM/Lumi @alibuild @aalkin -/PWGMM/UE @alibuild @aalkin @aortizve +/PWGMM @alibuild @sustripathy @skundu692 @aalkin @jgcn +/PWGMM/Mult @alibuild @sustripathy @skundu692 @aalkin @aortizve @ddobrigk @gbencedi @jgcn +/PWGMM/Lumi @alibuild @aalkin @jgcn +/PWGMM/UE @alibuild @aalkin @aortizve @jgcn -/PWGUD @alibuild @pbuehler @abylinkin @rolavick +/PWGUD @alibuild @pbuehler @nystrand @rolavick /PWGJE @alibuild @lhavener @maoyx @nzardosh @fjonasALICE @mfasDa @mhemmer-cern /Tools/PIDML @alibuild @saganatt /Tools/ML @alibuild @fcatalan92 @fmazzasc /Tutorials/PWGCF @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul -/Tutorials/PWGDQ @alibuild @iarsene @dsekihat @feisenhu @lucamicheletti93 +/Tutorials/PWGDQ @alibuild @iarsene @mcoquet @lucamicheletti93 /Tutorials/PWGEM @alibuild @mikesas @rbailhac @dsekihat @ivorobye @feisenhu -/Tutorials/PWGHF @alibuild @vkucera @fcolamar @fgrosa +/Tutorials/PWGHF @alibuild @vkucera @fcolamar @fgrosa @gluparel /Tutorials/PWGJE @alibuild @lhavener @maoyx @nzardosh @mfasDa @fjonasALICE -/Tutorials/PWGLF @alibuild @alcaliva @lbariogl @chiarapinto @BongHwi @lbarnby @mbombara @iravasen @njacazio @ChiaraDeMartin95 @skundu692 +/Tutorials/PWGLF @alibuild @alcaliva @lbariogl @chiarapinto @BongHwi @lbarnby @ercolessi @iravasen @njacazio @romainschotter @skundu692 /Tutorials/PWGMM @alibuild @aalkin @ddobrigk /Tutorials/PWGUD @alibuild @pbuehler diff --git a/CPPLINT.cfg b/CPPLINT.cfg index 7f7d3c357c3..96a8077f685 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -1 +1 @@ -filter=-build/c++11,-build/namespaces,-readability/fn_size,-readability/todo,-runtime/references,-whitespace/blank_line,-whitespace/braces,-whitespace/comments,-whitespace/indent_namespace,-whitespace/line_length,-whitespace/semicolon,-whitespace/todo +filter=-build/c++11,-build/include_order,-build/namespaces,-readability/fn_size,-readability/todo,-runtime/references,-whitespace/blank_line,-whitespace/braces,-whitespace/comments,-whitespace/indent_namespace,-whitespace/line_length,-whitespace/semicolon,-whitespace/todo diff --git a/Common/CCDB/AnalysisCCDBLinkDef.h b/Common/CCDB/AnalysisCCDBLinkDef.h index e87efaadcbf..bb2da231284 100644 --- a/Common/CCDB/AnalysisCCDBLinkDef.h +++ b/Common/CCDB/AnalysisCCDBLinkDef.h @@ -9,9 +9,20 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file AnalysisCCDBLinkDef.h +/// \brief Dictionary definitions +/// +/// \author Evgeny Kryshen + +#ifndef COMMON_CCDB_ANALYSISCCDBLINKDEF_H_ +#define COMMON_CCDB_ANALYSISCCDBLINKDEF_H_ + #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class EventSelectionParams + ; #pragma link C++ class TriggerAliases + ; +#pragma link C++ class std::map < uint64_t, uint32_t> + ; + +#endif // COMMON_CCDB_ANALYSISCCDBLINKDEF_H_ diff --git a/Common/CCDB/CMakeLists.txt b/Common/CCDB/CMakeLists.txt index 63584528a38..21a2c31877e 100644 --- a/Common/CCDB/CMakeLists.txt +++ b/Common/CCDB/CMakeLists.txt @@ -19,4 +19,8 @@ o2physics_target_root_dictionary(AnalysisCCDB HEADERS EventSelectionParams.h HEADERS TriggerAliases.h HEADERS ctpRateFetcher.h + HEADERS RCTSelectionFlags.h LINKDEF AnalysisCCDBLinkDef.h) + +o2physics_add_header_only_library(RCTSelectionFlags + HEADERS RCTSelectionFlags.h) diff --git a/Common/CCDB/EventSelectionParams.cxx b/Common/CCDB/EventSelectionParams.cxx index 2259c916787..74587314240 100644 --- a/Common/CCDB/EventSelectionParams.cxx +++ b/Common/CCDB/EventSelectionParams.cxx @@ -65,7 +65,6 @@ const char* selectionLabels[kNsel] = { "kNoCollInTimeRangeNarrow", "kNoCollInTimeRangeStrict", "kNoCollInTimeRangeStandard", - "kNoCollInTimeRangeVzDependent", "kNoCollInRofStrict", "kNoCollInRofStandard", "kNoHighMultCollInPrevRof", diff --git a/Common/CCDB/EventSelectionParams.h b/Common/CCDB/EventSelectionParams.h index afd8dcbf081..4633ff7aa73 100644 --- a/Common/CCDB/EventSelectionParams.h +++ b/Common/CCDB/EventSelectionParams.h @@ -24,58 +24,57 @@ namespace o2::aod::evsel { // Event selection criteria enum EventSelectionFlags { - kIsBBV0A = 0, // cell-averaged time in V0A in beam-beam window - kIsBBV0C, // cell-averaged time in V0C in beam-beam window (for Run 2 only) - kIsBBFDA, // cell-averaged time in FDA (or AD in Run2) in beam-beam window - kIsBBFDC, // cell-averaged time in FDC (or AD in Run2) in beam-beam window - kIsBBT0A, // cell-averaged time in T0A in beam-beam window - kIsBBT0C, // cell-averaged time in T0C in beam-beam window - kNoBGV0A, // cell-averaged time in V0A in beam-gas window - kNoBGV0C, // cell-averaged time in V0C in beam-gas window (for Run 2 only) - kNoBGFDA, // cell-averaged time in FDA (AD in Run2) in beam-gas window - kNoBGFDC, // cell-averaged time in FDC (AD in Run2) in beam-gas window - kNoBGT0A, // cell-averaged time in T0A in beam-gas window - kNoBGT0C, // cell-averaged time in T0C in beam-gas window - kIsBBZNA, // time in common ZNA channel in beam-beam window - kIsBBZNC, // time in common ZNC channel in beam-beam window - kIsBBZAC, // time in ZNA and ZNC in beam-beam window - circular cut in ZNA-ZNC plane - kNoBGZNA, // time in common ZNA channel is outside of beam-gas window - kNoBGZNC, // time in common ZNC channel is outside of beam-gas window - kNoV0MOnVsOfPileup, // no out-of-bunch pileup according to online-vs-offline VOM correlation - kNoSPDOnVsOfPileup, // no out-of-bunch pileup according to online-vs-offline SPD correlation - kNoV0Casymmetry, // no beam-gas according to correlation of V0C multiplicities in V0C3 and V0C012 - kIsGoodTimeRange, // good time range - kNoIncompleteDAQ, // complete event according to DAQ flags - kNoTPCLaserWarmUp, // no TPC laser warm-up event (used in Run 1) - kNoTPCHVdip, // no TPC HV dip - kNoPileupFromSPD, // no pileup according to SPD vertexer - kNoV0PFPileup, // no out-of-bunch pileup according to V0 past-future info - kNoSPDClsVsTklBG, // no beam-gas according to cluster-vs-tracklet correlation - kNoV0C012vsTklBG, // no beam-gas according to V0C012-vs-tracklet correlation - kNoInconsistentVtx, // no inconsistency in SPD and Track vertices - kNoPileupInMultBins, // no pileup according to multiplicity-differential pileup checks - kNoPileupMV, // no pileup according to multi-vertexer - kNoPileupTPC, // no pileup in TPC - kIsTriggerTVX, // FT0 vertex (acceptable FT0C-FT0A time difference) at trigger level - kIsINT1, // SPDGFO >= 1 || V0A || V0C - kNoITSROFrameBorder, // bunch crossing is far from ITS RO Frame border - kNoTimeFrameBorder, // bunch crossing is far from Time Frame borders - kNoSameBunchPileup, // reject collisions in case of pileup with another collision in the same foundBC - kIsGoodZvtxFT0vsPV, // small difference between z-vertex from PV and from FT0 - kIsVertexITSTPC, // at least one ITS-TPC track (reject vertices built from ITS-only tracks) - kIsVertexTOFmatched, // at least one of vertex contributors is matched to TOF - kIsVertexTRDmatched, // at least one of vertex contributors is matched to TRD - kNoCollInTimeRangeNarrow, // no other collisions in specified time range (narrower than Strict) - kNoCollInTimeRangeStrict, // no other collisions in specified time range - kNoCollInTimeRangeStandard, // no other collisions in specified time range with per-collision multiplicity above threshold - kNoCollInTimeRangeVzDependent, // no other collisions in vZ-dependent time range near a given collision - kNoCollInRofStrict, // no other collisions in this Readout Frame - kNoCollInRofStandard, // no other collisions in this Readout Frame with per-collision multiplicity above threshold - kNoHighMultCollInPrevRof, // veto an event if FT0C amplitude in previous ITS ROF is above threshold - kIsGoodITSLayer3, // number of inactive chips on ITS layer 3 is below maximum allowed value - kIsGoodITSLayer0123, // numbers of inactive chips on ITS layers 0-3 are below maximum allowed values - kIsGoodITSLayersAll, // numbers of inactive chips on all ITS layers are below maximum allowed values - kNsel // counter + kIsBBV0A = 0, // cell-averaged time in V0A in beam-beam window + kIsBBV0C, // cell-averaged time in V0C in beam-beam window (for Run 2 only) + kIsBBFDA, // cell-averaged time in FDA (or AD in Run2) in beam-beam window + kIsBBFDC, // cell-averaged time in FDC (or AD in Run2) in beam-beam window + kIsBBT0A, // cell-averaged time in T0A in beam-beam window + kIsBBT0C, // cell-averaged time in T0C in beam-beam window + kNoBGV0A, // cell-averaged time in V0A in beam-gas window + kNoBGV0C, // cell-averaged time in V0C in beam-gas window (for Run 2 only) + kNoBGFDA, // cell-averaged time in FDA (AD in Run2) in beam-gas window + kNoBGFDC, // cell-averaged time in FDC (AD in Run2) in beam-gas window + kNoBGT0A, // cell-averaged time in T0A in beam-gas window + kNoBGT0C, // cell-averaged time in T0C in beam-gas window + kIsBBZNA, // time in common ZNA channel in beam-beam window + kIsBBZNC, // time in common ZNC channel in beam-beam window + kIsBBZAC, // time in ZNA and ZNC in beam-beam window - circular cut in ZNA-ZNC plane + kNoBGZNA, // time in common ZNA channel is outside of beam-gas window + kNoBGZNC, // time in common ZNC channel is outside of beam-gas window + kNoV0MOnVsOfPileup, // no out-of-bunch pileup according to online-vs-offline VOM correlation + kNoSPDOnVsOfPileup, // no out-of-bunch pileup according to online-vs-offline SPD correlation + kNoV0Casymmetry, // no beam-gas according to correlation of V0C multiplicities in V0C3 and V0C012 + kIsGoodTimeRange, // good time range + kNoIncompleteDAQ, // complete event according to DAQ flags + kNoTPCLaserWarmUp, // no TPC laser warm-up event (used in Run 1) + kNoTPCHVdip, // no TPC HV dip + kNoPileupFromSPD, // no pileup according to SPD vertexer + kNoV0PFPileup, // no out-of-bunch pileup according to V0 past-future info + kNoSPDClsVsTklBG, // no beam-gas according to cluster-vs-tracklet correlation + kNoV0C012vsTklBG, // no beam-gas according to V0C012-vs-tracklet correlation + kNoInconsistentVtx, // no inconsistency in SPD and Track vertices + kNoPileupInMultBins, // no pileup according to multiplicity-differential pileup checks + kNoPileupMV, // no pileup according to multi-vertexer + kNoPileupTPC, // no pileup in TPC + kIsTriggerTVX, // FT0 vertex (acceptable FT0C-FT0A time difference) at trigger level + kIsINT1, // SPDGFO >= 1 || V0A || V0C + kNoITSROFrameBorder, // bunch crossing is far from ITS RO Frame border + kNoTimeFrameBorder, // bunch crossing is far from Time Frame borders + kNoSameBunchPileup, // reject collisions in case of pileup with another collision in the same foundBC + kIsGoodZvtxFT0vsPV, // small difference between z-vertex from PV and from FT0 + kIsVertexITSTPC, // at least one ITS-TPC track (reject vertices built from ITS-only tracks) + kIsVertexTOFmatched, // at least one of vertex contributors is matched to TOF + kIsVertexTRDmatched, // at least one of vertex contributors is matched to TRD + kNoCollInTimeRangeNarrow, // no other collisions in specified time range (narrower than Strict) + kNoCollInTimeRangeStrict, // no other collisions in specified time range + kNoCollInTimeRangeStandard, // no other collisions in specified time range with per-collision multiplicity above threshold + kNoCollInRofStrict, // no other collisions in this Readout Frame + kNoCollInRofStandard, // no other collisions in this Readout Frame with per-collision multiplicity above threshold + kNoHighMultCollInPrevRof, // veto an event if FT0C amplitude in previous ITS ROF is above threshold + kIsGoodITSLayer3, // number of inactive chips on ITS layer 3 is below maximum allowed value + kIsGoodITSLayer0123, // numbers of inactive chips on ITS layers 0-3 are below maximum allowed values + kIsGoodITSLayersAll, // numbers of inactive chips on all ITS layers are below maximum allowed values + kNsel // counter }; extern const char* selectionLabels[kNsel]; diff --git a/Common/CCDB/RCTSelectionFlags.h b/Common/CCDB/RCTSelectionFlags.h new file mode 100644 index 00000000000..1f396751c25 --- /dev/null +++ b/Common/CCDB/RCTSelectionFlags.h @@ -0,0 +1,211 @@ +// 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. + +/// \file RCTSelectionFlags.h +/// \brief RCT selection flags +/// +/// \author Andrea Ferrero and Evgeny Kryshen + +#ifndef COMMON_CCDB_RCTSELECTIONFLAGS_H_ +#define COMMON_CCDB_RCTSELECTIONFLAGS_H_ + +#include +#include +#include + +#include +#include +#include +#include + +namespace o2::aod::rctsel +{ +/* + * Bit mapping used for populating the CCDB objects from the RCT flags + * From https://github.com/JianLIUhep/RCTutils/blob/main/CCDB/process_and_upload.C +std::map> detailedBitMapping = { + {"CPV", { {"Bad", 0}, {"Invalid", 0} }}, + {"EMC", { {"Bad", 1}, {"NoDetectorData", 1}, {"BadEMCalorimetry", 1}, {"LimitedAcceptanceMCReproducible", 2} }}, + {"FDD", { {"Bad", 3}, {"Invalid", 3}, {"NoDetectorData", 3} }}, + {"FT0", { {"Bad", 4}, {"UnknownQuality", 4}, {"Unknown", 4} }}, + {"FV0", { {"Bad", 5} }}, + {"HMP", { {"Bad", 6}, {"NoDetectorData", 6} }}, + {"ITS", { {"Bad", 7}, {"UnknownQuality", 7}, {"BadTracking", 7}, {"LimitedAcceptanceMCReproducible", 8} }}, + {"MCH", { {"Bad", 9}, {"NoDetectorData", 9}, {"Unknown", 9}, {"LimitedAcceptanceMCReproducible", 10} }}, + {"MFT", { {"Bad", 11}, {"BadTracking", 11}, {"LimitedAcceptanceMCReproducible", 12} }}, + {"MID", { {"Bad", 13}, {"BadTracking", 13}, {"LimitedAcceptanceMCReproducible", 14} }}, + {"PHS", { {"Bad", 15}, {"Invalid", 15} }}, + {"TOF", { {"Bad", 16}, {"NoDetectorData", 16}, {"BadPID", 16}, {"LimitedAcceptanceMCReproducible", 17} }}, + {"TPC", { {"Bad", 18}, {"BadTracking", 18}, {"BadPID", 19}, {"LimitedAcceptanceMCNotReproducible", 18}, {"LimitedAcceptanceMCReproducible", 20} }}, + {"TRD", { {"Bad", 21}, {"BadTracking", 21} }}, + {"ZDC", { {"Bad", 22}, {"UnknownQuality", 22}, {"Unknown", 22}, {"NoDetectorData", 22} }} +}; +*/ + +// RCT selection flags +enum RCTSelectionFlags { + kCPVBad = 0, + kEMCBad, + kEMCLimAccMCRepr, + kFDDBad, + kFT0Bad, + kFV0Bad, + kHMPBad, + kITSBad, + kITSLimAccMCRepr, + kMCHBad, + kMCHLimAccMCRepr, + kMFTBad, + kMFTLimAccMCRepr, + kMIDBad, + kMIDLimAccMCRepr, + kPHSBad, + kTOFBad, + kTOFLimAccMCRepr, + kTPCBadTracking, + kTPCBadPID, + kTPCLimAccMCRepr, + kTRDBad, + kZDCBad, + kNRCTSelectionFlags +}; + +template +concept HasRCTFlags = requires(T a, int bit) { + { a.rct_bit(bit) } -> std::convertible_to; + { a.rct_raw() } -> std::convertible_to; +}; + +class RCTFlagsChecker : public o2::utils::EnumFlags +{ + public: + RCTFlagsChecker() = default; + + // Construct the object from an initializer list, like this: + // RCTFlagsChecker qualityFlagsChecker{ kFT0Bad, kITSBad, kMFTBad, kMFTLimAccMCRepr }; + using o2::utils::EnumFlags::EnumFlags; + + // Construct the object from one of the pre-defined runlist selections. + // The label parameter can take the following values: + // - "CBT" + // - "CBT_hadronPID" + // - "CBT_electronPID" + // - "CCBT_calo" + // - "CBT_muon" + // - "CBT_muon_glo" + // The checkZDC boolean flag controls whether to iclude the ZDC quality in all the pre-defined selections (for Pb-Pb data) + // The treatLimitedAcceptanceAsBad boolean flag controls whether "LimitedAcceptanceMCReproducible" flags should be + // treated as Bad and the corresponding events excluded + explicit RCTFlagsChecker(const std::string& label, bool checkZDC = false, bool treatLimitedAcceptanceAsBad = false) + { + init(label, checkZDC, treatLimitedAcceptanceAsBad); + } + + // Initialize the object from an initializer list of RCTSelectionFlags values + void init(std::initializer_list flags) + { + reset(); + *this = RCTFlagsChecker(flags); + } + + // Initialize the object from one of the pre-defined runlist selections. + // The label parameter can take the following values: + // - "CBT" + // - "CBT_hadronPID" + // - "CBT_electronPID" + // - "CCBT_calo" + // - "CBT_muon" + // - "CBT_muon_glo" + // The checkZDC boolean flag controls whether to iclude the ZDC quality in all the pre-defined selections (for Pb-Pb data) + // The treatLimitedAcceptanceAsBad boolean flag controls whether "LimitedAcceptanceMCReproducible" flags should be + // treated as Bad and the corresponding events excluded + void init(const std::string& label, bool checkZDC = false, bool treatLimitedAcceptanceAsBad = false) + { + auto setFlags = [this](std::initializer_list flags) { + std::for_each(flags.begin(), + flags.end(), + [this](const RCTSelectionFlags f) noexcept { set(f); }); + }; + + reset(); + + if (label == "CBT") { + setFlags({kFT0Bad, kITSBad, kTPCBadTracking, kTPCBadPID}); + if (treatLimitedAcceptanceAsBad) { + setFlags({kITSLimAccMCRepr, kTPCLimAccMCRepr}); + } + } + + if (label == "CBT_hadronPID") { + setFlags({kFT0Bad, kITSBad, kTPCBadTracking, kTPCBadPID, kTOFBad}); + if (treatLimitedAcceptanceAsBad) { + setFlags({kITSLimAccMCRepr, kTPCLimAccMCRepr, kTOFLimAccMCRepr}); + } + } + + if (label == "CBT_electronPID") { + setFlags({kFT0Bad, kITSBad, kTPCBadTracking, kTPCBadPID, kTRDBad}); + if (treatLimitedAcceptanceAsBad) { + setFlags({kITSLimAccMCRepr, kTPCLimAccMCRepr}); + } + } + + if (label == "CBT_calo") { + setFlags({kFT0Bad, kITSBad, kTPCBadTracking, kTPCBadPID, kEMCBad}); + if (treatLimitedAcceptanceAsBad) { + setFlags({kITSLimAccMCRepr, kTPCLimAccMCRepr, kEMCLimAccMCRepr}); + } + } + + if (label == "CBT_muon") { + setFlags({kFT0Bad, kITSBad, kTPCBadTracking, kMCHBad, kMIDBad}); + if (treatLimitedAcceptanceAsBad) { + setFlags({kITSLimAccMCRepr, kTPCLimAccMCRepr, kMCHLimAccMCRepr, kMIDLimAccMCRepr}); + } + } + + if (label == "CBT_muon_glo") { + setFlags({kFT0Bad, kITSBad, kTPCBadTracking, kMCHBad, kMIDBad, kMFTBad}); + if (treatLimitedAcceptanceAsBad) { + setFlags({kITSLimAccMCRepr, kTPCLimAccMCRepr, kMCHLimAccMCRepr, kMIDLimAccMCRepr, kMFTLimAccMCRepr}); + } + } + + if (checkZDC) { + set(kZDCBad); + } + } + + // Check the RCT column of a given event selection table. + // The function returns true if none of the checked flags is set in the RCT column. + bool checkTable(const HasRCTFlags auto& table) + { + if (!any()) { + throw std::out_of_range("RCTFlagsCheckerAlt with empty RCTSelectionFlags bits mask"); + } + + // bitmask of the current table + uint64_t tableBits = table.rct_raw(); + // bitmask of flags to be checked + uint64_t flagsBits = value(); + + // return true if none of the checked bits is set in the table bitmask + return ((tableBits & flagsBits) == 0); + } + + bool operator()(const HasRCTFlags auto& table) + { + return checkTable(table); + } +}; + +} // namespace o2::aod::rctsel +#endif // COMMON_CCDB_RCTSELECTIONFLAGS_H_ diff --git a/Common/CCDB/ctpRateFetcher.cxx b/Common/CCDB/ctpRateFetcher.cxx index 49d3c7ecd97..09c50d854f5 100644 --- a/Common/CCDB/ctpRateFetcher.cxx +++ b/Common/CCDB/ctpRateFetcher.cxx @@ -22,7 +22,7 @@ namespace o2 { -double ctpRateFetcher::fetch(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, std::string sourceName) +double ctpRateFetcher::fetch(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, std::string sourceName, bool fCrashOnNull) { setupRun(runNumber, ccdb, timeStamp); if (sourceName.find("ZNC") != std::string::npos) { @@ -43,7 +43,7 @@ double ctpRateFetcher::fetch(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStam if (ret < 0.) { LOG(info) << "Trying different class"; ret = fetchCTPratesClasses(ccdb, timeStamp, runNumber, "CMTVX-NONE"); - if (ret < 0) { + if ((ret < 0) && fCrashOnNull) { LOG(fatal) << "None of the classes used for lumi found"; } } @@ -69,7 +69,7 @@ double ctpRateFetcher::fetchCTPratesClasses(o2::ccdb::BasicCCDBManager* /*ccdb*/ LOG(warn) << "Trigger class " << className << " not found in CTPConfiguration"; return -1.; } - auto rate{mScalers->getRateGivenT(timeStamp * 1.e-3, classIndex, inputType)}; + auto rate{mScalers->getRateGivenT(timeStamp * 1.e-3, classIndex, inputType, 1)}; return pileUpCorrection(rate.second); } @@ -77,7 +77,7 @@ double ctpRateFetcher::fetchCTPratesInputs(o2::ccdb::BasicCCDBManager* /*ccdb*/, { std::vector recs = mScalers->getScalerRecordO2(); if (recs[0].scalersInps.size() == 48) { - return pileUpCorrection(mScalers->getRateGivenT(timeStamp * 1.e-3, input, 7).second); + return pileUpCorrection(mScalers->getRateGivenT(timeStamp * 1.e-3, input, 7, 1).second); } else { LOG(error) << "Inputs not available"; return -1.; diff --git a/Common/CCDB/ctpRateFetcher.h b/Common/CCDB/ctpRateFetcher.h index 412c1e7a424..6aaf5e3ebaa 100644 --- a/Common/CCDB/ctpRateFetcher.h +++ b/Common/CCDB/ctpRateFetcher.h @@ -34,7 +34,7 @@ class ctpRateFetcher { public: ctpRateFetcher() = default; - double fetch(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, std::string sourceName); + double fetch(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, std::string sourceName, bool fCrashOnNull = true); void setManualCleanup(bool manualCleanup = true) { mManualCleanup = manualCleanup; } diff --git a/Common/CCDB/macros/upload_event_selection_params.C b/Common/CCDB/macros/upload_event_selection_params.C index 5d63cf49be8..cafc863ab03 100644 --- a/Common/CCDB/macros/upload_event_selection_params.C +++ b/Common/CCDB/macros/upload_event_selection_params.C @@ -12,8 +12,8 @@ #include "CCDB/CcdbApi.h" #include "CCDB/BasicCCDBManager.h" #include "TString.h" -#include "map" -#include "string" +#include +#include #include "EventSelectionParams.h" using std::map; using std::string; diff --git a/Common/CCDB/macros/upload_event_selection_params_run3.C b/Common/CCDB/macros/upload_event_selection_params_run3.C index b439959fe1c..f81491949c6 100644 --- a/Common/CCDB/macros/upload_event_selection_params_run3.C +++ b/Common/CCDB/macros/upload_event_selection_params_run3.C @@ -11,8 +11,8 @@ #include "CCDB/CcdbApi.h" #include "TString.h" -#include "map" -#include "string" +#include +#include #include "EventSelectionParams.h" using std::map; using std::string; diff --git a/Common/Core/CMakeLists.txt b/Common/Core/CMakeLists.txt index c51c9dbfa2a..a5a771a2ca3 100644 --- a/Common/Core/CMakeLists.txt +++ b/Common/Core/CMakeLists.txt @@ -13,6 +13,7 @@ o2physics_add_library(AnalysisCore SOURCES TrackSelection.cxx OrbitRange.cxx PID/ParamBase.cxx + PID/PIDTOF.cxx CollisionAssociation.cxx TrackSelectionDefaults.cxx EventPlaneHelper.cxx diff --git a/Common/Core/CollisionTypeHelper.cxx b/Common/Core/CollisionTypeHelper.cxx index c22510ec82e..4d7e1de3f87 100644 --- a/Common/Core/CollisionTypeHelper.cxx +++ b/Common/Core/CollisionTypeHelper.cxx @@ -10,17 +10,20 @@ // or submit itself to any jurisdiction. /// -/// \file CollisionTypeHelper.h +/// \file CollisionTypeHelper.cxx /// \author Nicolò Jacazio nicolo.jacazio@cern.ch /// \brief Utility to handle the collision type from the GRP information /// #include "Common/Core/CollisionTypeHelper.h" + +#include "DataFormatsParameters/GRPLHCIFData.h" + #include + #include -#include "DataFormatsParameters/GRPLHCIFData.h" -std::string CollisionSystemType::getCollisionSystemName(collType collSys) +std::string o2::common::core::CollisionSystemType::getCollisionSystemName(collType collSys) { switch (collSys) { case kCollSyspp: @@ -31,17 +34,26 @@ std::string CollisionSystemType::getCollisionSystemName(collType collSys) return "XeXe"; case kCollSyspPb: return "pPb"; + case kCollSysOO: + return "OO"; + case kCollSyspO: + return "pO"; + case kCollSysNeNe: + return "NeNe"; + case kCollSysUndef: + return "Undefined"; default: + LOG(warning) << "Undefined collision system type: " << collSys; return "Undefined"; } } -int CollisionSystemType::getCollisionTypeFromGrp(o2::parameters::GRPLHCIFData* grplhcif) +int o2::common::core::CollisionSystemType::getCollisionTypeFromGrp(o2::parameters::GRPLHCIFData* grplhcif) { - const int ZBeamA = grplhcif->getBeamZ(o2::constants::lhc::BeamDirection::BeamA); - const int ZBeamC = grplhcif->getBeamZ(o2::constants::lhc::BeamDirection::BeamC); - LOG(debug) << "Collision system: " << ZBeamA << " * " << ZBeamC << " detected"; - switch (ZBeamA * ZBeamC) { + const int zBeamA = grplhcif->getBeamZ(o2::constants::lhc::BeamDirection::BeamA); + const int zBeamC = grplhcif->getBeamZ(o2::constants::lhc::BeamDirection::BeamC); + LOG(debug) << "Collision system Z: " << zBeamA << " * " << zBeamC << " detected = " << zBeamA * zBeamC; + switch (zBeamA * zBeamC) { case 1: // pp 1*1 return kCollSyspp; case 6724: // Pb-Pb 82*82 @@ -50,8 +62,14 @@ int CollisionSystemType::getCollisionTypeFromGrp(o2::parameters::GRPLHCIFData* g return kCollSysXeXe; case 82: // p-Pb 82*1 return kCollSyspPb; + case 64: // O-O 8*8 + return kCollSysOO; + case 8: // p-O 8*1 + return kCollSyspO; + case 100: // Ne-Ne 10*10 + return kCollSysNeNe; default: - LOG(fatal) << "Undefined collision system in getCollisionTypeFromGrp with BeamA = " << ZBeamA << " and BeamC = " << ZBeamC; + LOG(fatal) << "Undefined collision system in getCollisionTypeFromGrp with Z of BeamA = " << zBeamA << " and Z of BeamC = " << zBeamC; return kCollSysUndef; } return kCollSysUndef; diff --git a/Common/Core/CollisionTypeHelper.h b/Common/Core/CollisionTypeHelper.h index 0196fdc03bb..c8dc7a21842 100644 --- a/Common/Core/CollisionTypeHelper.h +++ b/Common/Core/CollisionTypeHelper.h @@ -18,9 +18,12 @@ #ifndef COMMON_CORE_COLLISIONTYPEHELPER_H_ #define COMMON_CORE_COLLISIONTYPEHELPER_H_ -#include #include "DataFormatsParameters/GRPLHCIFData.h" +#include + +namespace o2::common::core +{ // Container for the collision system type struct CollisionSystemType { // Enum type for the collision system @@ -31,11 +34,18 @@ struct CollisionSystemType { static constexpr collType kCollSysPbPb = 1; // PbPb static constexpr collType kCollSysXeXe = 2; // XeXe static constexpr collType kCollSyspPb = 3; // pPb - static constexpr collType kNCollSys = 4; // Number of collision systems + static constexpr collType kCollSysOO = 4; // OO (Oxygen-Oxygen) + static constexpr collType kCollSyspO = 5; // pO (proton-Oxygen) + static constexpr collType kCollSysNeNe = 6; // NeNe (Neon-Neon) + static constexpr collType kNCollSys = 7; // Number of collision systems static std::string getCollisionSystemName(collType collSys); static int getCollisionTypeFromGrp(o2::parameters::GRPLHCIFData* grplhcif); }; +} // namespace o2::common::core + +using CollisionSystemType = o2::common::core::CollisionSystemType; + #endif // COMMON_CORE_COLLISIONTYPEHELPER_H_ diff --git a/Common/Core/FFitWeights.cxx b/Common/Core/FFitWeights.cxx index 9c98479627d..3a92114f48c 100644 --- a/Common/Core/FFitWeights.cxx +++ b/Common/Core/FFitWeights.cxx @@ -16,6 +16,10 @@ #include "FFitWeights.h" +#include +#include +#include + #include ClassImp(FFitWeights) @@ -43,20 +47,20 @@ FFitWeights::~FFitWeights() delete qAxis; }; -void FFitWeights::Init() +void FFitWeights::init() { fW_data = new TObjArray(); fW_data->SetName("FFitWeights_Data"); fW_data->SetOwner(kTRUE); if (!qAxis) - this->SetBinAxis(500, 0, 25); + this->setBinAxis(500, 0, 25); for (const auto& qn : qnTYPE) { - fW_data->Add(new TH2D(this->GetQName(qn.first, qn.second.c_str()), this->GetAxisName(qn.first, qn.second.c_str()), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax())); + fW_data->Add(new TH2D(this->getQName(qn.first, qn.second.c_str()), this->getAxisName(qn.first, qn.second.c_str()), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax())); } }; -void FFitWeights::Fill(float centrality, float qn, int nh, const char* pf) +void FFitWeights::fillWeights(float centrality, float qn, int nh, const char* pf) { TObjArray* tar{nullptr}; @@ -64,9 +68,9 @@ void FFitWeights::Fill(float centrality, float qn, int nh, const char* pf) if (!tar) return; - TH2D* th2 = reinterpret_cast(tar->FindObject(this->GetQName(nh, pf))); + TH2D* th2 = reinterpret_cast(tar->FindObject(this->getQName(nh, pf))); if (!th2) { - tar->Add(new TH2D(this->GetQName(nh, pf), this->GetAxisName(nh, pf), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax())); + tar->Add(new TH2D(this->getQName(nh, pf), this->getAxisName(nh, pf), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax())); th2 = reinterpret_cast(tar->At(tar->GetEntries() - 1)); } th2->Fill(centrality, qn); @@ -83,12 +87,12 @@ Long64_t FFitWeights::Merge(TCollection* collist) FFitWeights* l_w = 0; TIter all_w(collist); while ((l_w = (reinterpret_cast(all_w())))) { - AddArray(fW_data, l_w->GetDataArray()); + addArray(fW_data, l_w->getDataArray()); nmerged++; } return nmerged; }; -void FFitWeights::AddArray(TObjArray* targ, TObjArray* sour) +void FFitWeights::addArray(TObjArray* targ, TObjArray* sour) { if (!sour) { printf("Source array does not exist!\n"); @@ -107,7 +111,7 @@ void FFitWeights::AddArray(TObjArray* targ, TObjArray* sour) } }; -void FFitWeights::qSelectionSpline(std::vector nhv, std::vector stv) /* only execute OFFLINE */ +void FFitWeights::qSelection(std::vector nhv, std::vector stv) /* only execute OFFLINE */ { TObjArray* tar{nullptr}; @@ -117,15 +121,15 @@ void FFitWeights::qSelectionSpline(std::vector nhv, std::vector(tar->FindObject(this->GetQName(nh, pf.c_str()))); + TH2D* th2{reinterpret_cast(tar->FindObject(this->getQName(nh, pf.c_str())))}; if (!th2) { printf("qh not found!\n"); return; } - TH1D* tmp = nullptr; - TGraph* tmpgr = nullptr; - TSpline3* spline = nullptr; + TH1D* tmp{nullptr}; + TGraph* tmpgr{nullptr}; + // TSpline3* spline = nullptr; for (int iSP{0}; iSP < 90; iSP++) { tmp = th2->ProjectionY(Form("q%i_%i_%i", nh, iSP, iSP + 1), iSP + 1, iSP + 1); std::vector xq(nResolution); @@ -134,15 +138,16 @@ void FFitWeights::qSelectionSpline(std::vector nhv, std::vector(i + 1) / static_cast(nResolution); tmp->GetQuantiles(nResolution, yq.data(), xq.data()); tmpgr = new TGraph(nResolution, yq.data(), xq.data()); - spline = new TSpline3(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP), tmpgr); - spline->SetName(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP)); - fW_data->Add(spline); + tmpgr->SetName(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP)); + // spline = new TSpline3(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP), tmpgr); + // spline->SetName(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP)); + fW_data->Add(tmpgr); } } } }; -float FFitWeights::EvalSplines(float centr, const float& dqn, const int nh, const char* pf) +float FFitWeights::eval(float centr, const float& dqn, const int nh, const char* pf) { TObjArray* tar{nullptr}; @@ -150,19 +155,19 @@ float FFitWeights::EvalSplines(float centr, const float& dqn, const int nh, cons if (!tar) return -1; - int isp = static_cast(centr); + int isp{static_cast(centr)}; if (isp < 0 || isp > 90) { return -1; } - TSpline3* spline = nullptr; - spline = reinterpret_cast(tar->FindObject(Form("sp_q%i%s_%i", nh, pf, isp))); + TGraph* spline{nullptr}; + spline = reinterpret_cast(tar->FindObject(Form("sp_q%i%s_%i", nh, pf, isp))); if (!spline) { return -1; } - float qn_val = 100. * spline->Eval(dqn); - if (qn_val < 0) { + float qn_val{static_cast(100. * spline->Eval(dqn))}; + if (qn_val < 0 || qn_val > 100.05) { return -1; } diff --git a/Common/Core/FFitWeights.h b/Common/Core/FFitWeights.h index 0a3d285176e..c80165730f7 100644 --- a/Common/Core/FFitWeights.h +++ b/Common/Core/FFitWeights.h @@ -41,22 +41,23 @@ class FFitWeights : public TNamed explicit FFitWeights(const char* name); ~FFitWeights(); - void Init(); - void Fill(float centrality, float qn, int nh, const char* pf = ""); - TObjArray* GetDataArray() { return fW_data; } + void init(); + void fillWeights(float centrality, float qn, int nh, const char* pf = ""); + TObjArray* getDataArray() { return fW_data; } - void SetCentBin(int bin) { CentBin = bin; } - void SetBinAxis(int bin, float min, float max) + void setCentBin(int bin) { CentBin = bin; } + void setBinAxis(int bin, float min, float max) { qAxis = new TAxis(bin, min, max); } - TAxis* GetqVecAx() { return qAxis; } + TAxis* getqVecAx() { return qAxis; } Long64_t Merge(TCollection* collist); - void qSelectionSpline(std::vector nhv, std::vector stv); - float EvalSplines(float centr, const float& dqn, const int nh, const char* pf = ""); - void SetResolution(int res) { nResolution = res; } - void SetQnType(std::vector> qninp) { qnTYPE = qninp; } + void qSelection(std::vector nhv, std::vector stv); + float eval(float centr, const float& dqn, const int nh, const char* pf = ""); + void setResolution(int res) { nResolution = res; } + int getResolution() const { return nResolution; } + void setQnType(std::vector> qninp) { qnTYPE = qninp; } private: TObjArray* fW_data; @@ -67,15 +68,15 @@ class FFitWeights : public TNamed std::vector> qnTYPE; - const char* GetQName(const int nh, const char* pf = "") + const char* getQName(const int nh, const char* pf = "") { return Form("q%i%s", nh, pf); }; - const char* GetAxisName(const int nh, const char* pf = "") + const char* getAxisName(const int nh, const char* pf = "") { return Form(";Centrality;q_{%i}^{%s}", nh, pf); }; - void AddArray(TObjArray* targ, TObjArray* sour); + void addArray(TObjArray* targ, TObjArray* sour); ClassDef(FFitWeights, 1); // calibration class }; diff --git a/Common/Core/MetadataHelper.cxx b/Common/Core/MetadataHelper.cxx index bdcb7e2e8a4..b8c2fe6ad22 100644 --- a/Common/Core/MetadataHelper.cxx +++ b/Common/Core/MetadataHelper.cxx @@ -20,13 +20,18 @@ #include "Framework/InitContext.h" #include "Framework/RunningWorkflowInfo.h" +using namespace o2::common::core; + MetadataHelper::MetadataHelper() { - const std::array keyList = {"DataType", + const std::array keyList = {"DataType", "RecoPassName", "Run", "AnchorPassName", - "AnchorProduction"}; + "AnchorProduction", + "ROOTVersion", + "LPMProductionTag", + "O2Version"}; for (const auto& key : keyList) { mMetadata[key] = "undefined"; } diff --git a/Common/Core/MetadataHelper.h b/Common/Core/MetadataHelper.h index 8519c25bc88..f3522a5d190 100644 --- a/Common/Core/MetadataHelper.h +++ b/Common/Core/MetadataHelper.h @@ -8,8 +8,6 @@ // 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. - -/// /// \file TableHelper.h /// \author Nicolò Jacazio nicolo.jacazio@cern.ch /// \brief Utility to handle the metadata from the AOD @@ -18,10 +16,14 @@ #ifndef COMMON_CORE_METADATAHELPER_H_ #define COMMON_CORE_METADATAHELPER_H_ -#include -#include #include "Framework/ConfigContext.h" +#include +#include + +namespace o2::common::core +{ + struct MetadataHelper { /// @brief Constructor for the MetadataHelper. Defines the all the metadata keys that will be looked for and accessible MetadataHelper(); @@ -64,4 +66,6 @@ struct MetadataHelper { bool mIsInitialized = false; /// < Flag to check if the metadata has been initialized }; +} // namespace o2::common::core + #endif // COMMON_CORE_METADATAHELPER_H_ diff --git a/Common/Core/PID/PIDTOF.cxx b/Common/Core/PID/PIDTOF.cxx new file mode 100644 index 00000000000..bec41fafc43 --- /dev/null +++ b/Common/Core/PID/PIDTOF.cxx @@ -0,0 +1,104 @@ +// 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. + +/// +/// \file PIDTOF.cxx +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \since 02/07/2020 +/// \brief Implementation of the TOF detector response for PID +/// + +#include "PIDTOF.h" +#include + +namespace o2::pid::tof +{ + +void TOFResoParamsV3::setResolutionParametrizationRun2(std::unordered_map const& pars) +{ + std::array paramNames{"TrkRes.Pi.P0", "TrkRes.Pi.P1", "TrkRes.Pi.P2", "TrkRes.Pi.P3", "time_resolution", + "TrkRes.Ka.P0", "TrkRes.Ka.P1", "TrkRes.Ka.P2", "TrkRes.Ka.P3", + "TrkRes.Pr.P0", "TrkRes.Pr.P1", "TrkRes.Pr.P2", "TrkRes.Pr.P3"}; + // Now we override the parametrization to use the Run 2 one + for (int i = 0; i < 9; i++) { + if (mResolution[i]) { + delete mResolution[i]; + } + mResolution[i] = new TF2(Form("tofResTrack.%s_Run2", particleNames[i]), "-10", 0., 20, -1, 1.); // With negative values the old one is used + } + // Print the map + for (const auto& [key, value] : pars) { + LOG(info) << "Key: " << key << " Value: " << value; + } + for (int i = 0; i < 13; i++) { + setParameter(i, pars.at(paramNames[i])); + } +} + +// Time shift for post calibration to realign as a function of eta +void TOFResoParamsV3::setTimeShiftParameters(std::unordered_map const& pars, const bool positive) +{ + std::string baseOpt = positive ? "TimeShift.Pos." : "TimeShift.Neg."; + + if (pars.count(baseOpt + "GetN") == 0) { // If the map does not contain the number of eta bins, we assume that no correction has to be applied + return; + } + const int nPoints = static_cast(pars.at(baseOpt + "GetN")); + if (nPoints <= 0) { + LOG(fatal) << "TOFResoParamsV3 shift: time must be positive"; + } + TGraph graph; + for (int i = 0; i < nPoints; ++i) { + graph.AddPoint(pars.at(Form("TimeShift.eta%i", i)), pars.at(Form("TimeShift.cor%i", i))); + } + setTimeShiftParameters(&graph, positive); +} +void TOFResoParamsV3::setTimeShiftParameters(std::string const& filename, std::string const& objname, const bool positive) +{ + TFile f(filename.c_str(), "READ"); + if (f.IsOpen()) { + if (positive) { + f.GetObject(objname.c_str(), gPosEtaTimeCorr); + } else { + f.GetObject(objname.c_str(), gNegEtaTimeCorr); + } + f.Close(); + } + LOG(info) << "Set the Time Shift parameters from file " << filename << " and object " << objname << " for " << (positive ? "positive" : "negative"); +} +void TOFResoParamsV3::setTimeShiftParameters(TGraph* g, const bool positive) +{ + if (!g) { + LOG(info) << "No Time Shift parameter is passed for " << (positive ? "positive" : "negative"); + return; + } + if (positive) { + gPosEtaTimeCorr = g; + } else { + gNegEtaTimeCorr = g; + } + LOG(info) << "Set the Time Shift parameters from object " << g->GetName() << " " << g->GetTitle() << " for " << (positive ? "positive" : "negative"); +} +float TOFResoParamsV3::getTimeShift(float eta, int16_t sign) const +{ + if (sign > 0) { + if (!gPosEtaTimeCorr) { + return 0.f; + } + return gPosEtaTimeCorr->Eval(eta); + } + if (!gNegEtaTimeCorr) { + return 0.f; + } + return gNegEtaTimeCorr->Eval(eta); +} + +} // namespace o2::pid::tof diff --git a/Common/Core/PID/PIDTOF.h b/Common/Core/PID/PIDTOF.h index f0165c65400..ad16716916c 100644 --- a/Common/Core/PID/PIDTOF.h +++ b/Common/Core/PID/PIDTOF.h @@ -40,108 +40,8 @@ namespace o2::pid::tof { -// Utility values (to remove!) -static constexpr float kCSPEED = TMath::C() * 1.0e2f * 1.0e-12f; /// Speed of light in TOF units (cm/ps) -static constexpr float kCSPEDDInv = 1.f / kCSPEED; /// Inverse of the Speed of light in TOF units (ps/cm) -static constexpr float defaultReturnValue = -999.f; /// Default return value in case TOF measurement is not available - -/// \brief Class to handle the the TOF detector response for the TOF beta measurement -class Beta -{ - public: - Beta() = default; - ~Beta() = default; - - /// Computes the beta of a track given a length, a time measurement and an event time (in ps) - /// \param length Length in cm of the track - /// \param tofSignal TOF signal in ps for the track - /// \param collisionTime collision time in ps for the event of the track - static float GetBeta(const float length, const float tofSignal, const float collisionTime) { return length / (tofSignal - collisionTime) * o2::constants::physics::invLightSpeedCm2PS; } - - /// Gets the beta for the track of interest - /// \param track Track of interest - /// \param collisionTime Collision time - template - static float GetBeta(const TrackType& track, const float collisionTime) - { - return track.hasTOF() ? GetBeta(track.length(), track.tofSignal(), collisionTime) : defaultReturnValue; - } - - /// Gets the beta for the track of interest - /// \param track Track of interest - template - static float GetBeta(const TrackType& track) - { - return GetBeta(track, track.tofEvTime()); - } - - /// Computes the expected uncertainty on the beta measurement - /// \param length Length in cm of the track - /// \param tofSignal TOF signal in ps for the track - /// \param collisionTime collision time in ps for the event of the track - /// \param time_reso expected time resolution - static float GetExpectedSigma(const float length, const float tofSignal, const float collisionTime, const float expectedResolution) { return GetBeta(length, tofSignal, collisionTime) / (tofSignal - collisionTime) * expectedResolution; } - - /// Gets the expected uncertainty on the beta measurement of the track of interest - /// \param track Track of interest - template - float GetExpectedSigma(const TrackType& track) const - { - return GetExpectedSigma(track.length(), track.tofSignal(), track.tofEvTime(), mExpectedResolution); - } - - /// Gets the expected beta for a given mass hypothesis (no energy loss taken into account) - /// \param momentum momentum in GeV/c of the track - /// \param mass mass in GeV/c2 of the particle of interest - static float GetExpectedBeta(const float momentum, const float mass) { return momentum > 0 ? momentum / std::sqrt(momentum * momentum + mass * mass) : 0.f; } - - /// Gets the expected beta given the particle index (no energy loss taken into account) of the track of interest - /// \param track Track of interest - template - float GetExpectedBeta(const TrackType& track) const - { - return GetExpectedBeta(track.p(), o2::track::PID::getMass2Z(id)); - } - - /// Gets the number of sigmas with respect the approximate beta (no energy loss taken into account) of the track of interest - /// \param track Track of interest - template - float GetSeparation(const TrackType& track) const - { - return (GetBeta(track) - GetExpectedBeta(track)) / GetExpectedSigma(track); - } - - float mExpectedResolution = 80; /// Expected time resolution -}; - -/// \brief Class to handle the the TOF detector response for the TOF mass measurement -class TOFMass -{ - public: - TOFMass() = default; - ~TOFMass() = default; - - /// Computes the TOF mass of a track given a momentum, a beta measurement - /// \param momentum momentum of the track - /// \param beta TOF beta measurement - static float GetTOFMass(const float momentum, const float beta) { return (momentum / beta) * std::sqrt(std::abs(1.f - beta * beta)); } - - /// Gets the TOF mass for the track of interest - /// \param track Track of interest - template - static float GetTOFMass(const TrackType& track, const float beta) - { - return track.hasTOF() ? GetTOFMass(track.p(), beta) : defaultReturnValue; - } - - /// Gets the TOF mass for the track of interest - /// \param track Track of interest - template - static float GetTOFMass(const TrackType& track) - { - return track.hasTOF() ? GetTOFMass(track.p(), Beta::GetBeta(track)) : defaultReturnValue; - } -}; +// Utility values +static constexpr float defaultReturnValue = -999.f; /// Default return value in case TOF measurement is not available /// \brief Next implementation class to store TOF response parameters for exp. times class TOFResoParamsV2 : public o2::tof::Parameters<13> @@ -337,58 +237,10 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13> } // Time shift for post calibration to realign as a function of eta - void setTimeShiftParameters(std::unordered_map const& pars, bool positive) - { - std::string baseOpt = positive ? "TimeShift.Pos." : "TimeShift.Neg."; - - if (pars.count(baseOpt + "GetN") == 0) { // If the map does not contain the number of eta bins, we assume that no correction has to be applied - return; - } - const int nPoints = static_cast(pars.at(baseOpt + "GetN")); - if (nPoints <= 0) { - LOG(fatal) << "TOFResoParamsV3 shift: time must be positive"; - } - TGraph graph; - for (int i = 0; i < nPoints; ++i) { - graph.AddPoint(pars.at(Form("TimeShift.eta%i", i)), pars.at(Form("TimeShift.cor%i", i))); - } - setTimeShiftParameters(&graph, positive); - } - void setTimeShiftParameters(std::string const& filename, std::string const& objname, bool positive) - { - TFile f(filename.c_str(), "READ"); - if (f.IsOpen()) { - if (positive) { - f.GetObject(objname.c_str(), gPosEtaTimeCorr); - } else { - f.GetObject(objname.c_str(), gNegEtaTimeCorr); - } - f.Close(); - } - LOG(info) << "Set the Time Shift parameters from file " << filename << " and object " << objname << " for " << (positive ? "positive" : "negative"); - } - void setTimeShiftParameters(TGraph* g, bool positive) - { - if (positive) { - gPosEtaTimeCorr = g; - } else { - gNegEtaTimeCorr = g; - } - LOG(info) << "Set the Time Shift parameters from object " << g->GetName() << " " << g->GetTitle() << " for " << (positive ? "positive" : "negative"); - } - float getTimeShift(float eta, int16_t sign) const - { - if (sign > 0) { - if (!gPosEtaTimeCorr) { - return 0.f; - } - return gPosEtaTimeCorr->Eval(eta); - } - if (!gNegEtaTimeCorr) { - return 0.f; - } - return gNegEtaTimeCorr->Eval(eta); - } + void setTimeShiftParameters(std::unordered_map const& pars, const bool positive); + void setTimeShiftParameters(std::string const& filename, std::string const& objname, const bool positive); + void setTimeShiftParameters(TGraph* g, const bool positive); + float getTimeShift(float eta, int16_t sign) const; void printTimeShiftParameters() const { @@ -406,8 +258,7 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13> void setResolutionParametrization(std::unordered_map const& pars) { - static constexpr std::array particleNames = {"El", "Mu", "Pi", "Ka", "Pr", "De", "Tr", "He", "Al"}; - for (int i = 0; i < 9; ++i) { + for (int i = 0; i < 9; i++) { const std::string baseOpt = Form("tofResTrack.%s_", particleNames[i]); // Check if a key begins with a string for (const auto& [key, value] : pars) { @@ -424,7 +275,7 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13> } } // Print a summary - for (int i = 0; i < 9; ++i) { + for (int i = 0; i < 9; i++) { if (!mResolution[i]) { LOG(info) << "Resolution function for " << particleNames[i] << " not provided, using default " << mDefaultResoParams[i]; mResolution[i] = new TF2(Form("tofResTrack.%s_Default", particleNames[i]), mDefaultResoParams[i], 0., 20, -1, 1.); @@ -433,6 +284,8 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13> } } + void setResolutionParametrizationRun2(std::unordered_map const& pars); + template float getResolution(const float p, const float eta) const { @@ -441,9 +294,8 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13> void printResolution() const { - static constexpr std::array particleNames = {"El", "Mu", "Pi", "Ka", "Pr", "De", "Tr", "He", "Al"}; // Print a summary - for (int i = 0; i < 9; ++i) { + for (int i = 0; i < 9; i++) { if (!mResolution[i]) { LOG(info) << "Resolution function for " << particleNames[i] << " is not defined yet"; continue; @@ -476,12 +328,111 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13> "315*TMath::Power((TMath::Max(x-0.811,0.1))*(1-0.4235*y*y),-0.783)", "157*TMath::Power((TMath::Max(x-0.556,0.1))*(1-0.4235*y*y),-0.783)", "216*TMath::Power((TMath::Max(x-0.647,0.1))*(1-0.4235*y*y),-0.76)"}; + static constexpr std::array particleNames = {"El", "Mu", "Pi", "Ka", "Pr", "De", "Tr", "He", "Al"}; // Time shift for post calibration TGraph* gPosEtaTimeCorr = nullptr; /// Time shift correction for positive tracks TGraph* gNegEtaTimeCorr = nullptr; /// Time shift correction for negative tracks }; +/// \brief Class to handle the the TOF detector response for the TOF beta measurement +class Beta +{ + public: + Beta() = default; + ~Beta() = default; + + /// Computes the beta of a track given a length, a time measurement and an event time (in ps) + /// \param length Length in cm of the track + /// \param tofSignal TOF signal in ps for the track + /// \param collisionTime collision time in ps for the event of the track + static float GetBeta(const float length, const float tofSignal, const float collisionTime) { return length / (tofSignal - collisionTime) * o2::constants::physics::invLightSpeedCm2PS; } + + /// Gets the beta for the track of interest + /// \param track Track of interest + /// \param collisionTime Collision time + template + static float GetBeta(const TrackType& track, const float collisionTime) + { + return track.hasTOF() ? GetBeta(track.length(), track.tofSignal(), collisionTime) : defaultReturnValue; + } + + /// Gets the beta for the track of interest + /// \param track Track of interest + template + static float GetBeta(const TrackType& track) + { + return GetBeta(track, track.tofEvTime()); + } + + /// Computes the expected uncertainty on the beta measurement + /// \param length Length in cm of the track + /// \param tofSignal TOF signal in ps for the track + /// \param collisionTime collision time in ps for the event of the track + /// \param time_reso expected time resolution + static float GetExpectedSigma(const float length, const float tofSignal, const float collisionTime, const float expectedResolution) { return GetBeta(length, tofSignal, collisionTime) / (tofSignal - collisionTime) * expectedResolution; } + + /// Gets the expected uncertainty on the beta measurement of the track of interest + /// \param track Track of interest + template + float GetExpectedSigma(const TrackType& track) const + { + return GetExpectedSigma(track.length(), track.tofSignal(), track.tofEvTime(), mExpectedResolution); + } + + /// Gets the expected beta for a given mass hypothesis (no energy loss taken into account) + /// \param momentum momentum in GeV/c of the track + /// \param mass mass in GeV/c2 of the particle of interest + static float GetExpectedBeta(const float momentum, const float mass) { return momentum > 0 ? momentum / std::sqrt(momentum * momentum + mass * mass) : 0.f; } + + /// Gets the expected beta given the particle index (no energy loss taken into account) of the track of interest + /// \param track Track of interest + template + float GetExpectedBeta(const TrackType& track) const + { + return GetExpectedBeta(track.p(), o2::track::PID::getMass2Z(id)); + } + + /// Gets the number of sigmas with respect the approximate beta (no energy loss taken into account) of the track of interest + /// \param track Track of interest + template + float GetSeparation(const TrackType& track) const + { + return (GetBeta(track) - GetExpectedBeta(track)) / GetExpectedSigma(track); + } + + float mExpectedResolution = 80; /// Expected time resolution +}; + +/// \brief Class to handle the the TOF detector response for the TOF mass measurement +class TOFMass +{ + public: + TOFMass() = default; + ~TOFMass() = default; + + /// Computes the TOF mass of a track given a momentum, a beta measurement + /// \param momentum momentum of the track + /// \param beta TOF beta measurement + static float GetTOFMass(const float momentum, const float beta) { return (momentum / beta) * std::sqrt(std::abs(1.f - beta * beta)); } + + /// Gets the TOF mass for the track of interest + /// \param track Track of interest + template + static float GetTOFMass(const TrackType& track, const float beta) + { + return track.hasTOF() ? GetTOFMass(track.p(), beta) : defaultReturnValue; + } + + /// Gets the TOF mass for the track of interest + /// \param track Track of interest + template + static float GetTOFMass(const TrackType& track) + { + return track.hasTOF() ? GetTOFMass(track.p(), Beta::GetBeta(track)) : defaultReturnValue; + } +}; + /// \brief Class to handle the the TOF detector response for the expected time template class ExpTimes diff --git a/Common/Core/PID/TPCPIDResponse.h b/Common/Core/PID/TPCPIDResponse.h index f25e1acd69e..deafdf4fed2 100644 --- a/Common/Core/PID/TPCPIDResponse.h +++ b/Common/Core/PID/TPCPIDResponse.h @@ -74,12 +74,18 @@ class Response /// Gets the expected resolution of the track template float GetExpectedSigma(const CollisionType& collision, const TrackType& trk, const o2::track::PID::ID id) const; + /// Gets the expected resolution of the track with multTPC explicitly provided + template + float GetExpectedSigmaAtMultiplicity(const long multTPC, const TrackType& trk, const o2::track::PID::ID id) const; /// Gets the number of sigmas with respect the expected value template float GetNumberOfSigma(const CollisionType& collision, const TrackType& trk, const o2::track::PID::ID id) const; // Number of sigmas with respect to expected for MC, defining a tune-on-data signal value template float GetNumberOfSigmaMCTuned(const CollisionType& collision, const TrackType& trk, const o2::track::PID::ID id, float mcTunedTPCSignal) const; + // Number of sigmas with respect to expected for MC, defining a tune-on-data signal value, explicit multTPC + template + float GetNumberOfSigmaMCTunedAtMultiplicity(const long multTPC, const TrackType& trk, const o2::track::PID::ID id, float mcTunedTPCSignal) const; /// Gets the deviation to the expected signal template float GetSignalDelta(const TrackType& trk, const o2::track::PID::ID id) const; @@ -116,6 +122,14 @@ inline float Response::GetExpectedSignal(const TrackType& track, const o2::track /// Gets the expected resolution of the measurement template inline float Response::GetExpectedSigma(const CollisionType& collision, const TrackType& track, const o2::track::PID::ID id) const +{ + // use multTPC (legacy behaviour) if multTPC not provided + return Response::GetExpectedSigmaAtMultiplicity(collision.multTPC(), track, id); +} + +/// Gets the expected resolution of the measurement +template +inline float Response::GetExpectedSigmaAtMultiplicity(const long multTPC, const TrackType& track, const o2::track::PID::ID id) const { if (!track.hasTPC()) { return -999.f; @@ -133,7 +147,7 @@ inline float Response::GetExpectedSigma(const CollisionType& collision, const Tr const double dEdx = o2::tpc::BetheBlochAleph(static_cast(bg), mBetheBlochParams[0], mBetheBlochParams[1], mBetheBlochParams[2], mBetheBlochParams[3], mBetheBlochParams[4]) * std::pow(static_cast(o2::track::pid_constants::sCharges[id]), mChargeFactor); const double relReso = GetRelativeResolutiondEdx(p, mass, o2::track::pid_constants::sCharges[id], mResolutionParams[3]); - const std::vector values{1.f / dEdx, track.tgl(), std::sqrt(ncl), relReso, track.signed1Pt(), collision.multTPC() / mMultNormalization}; + const std::vector values{1.f / dEdx, track.tgl(), std::sqrt(ncl), relReso, track.signed1Pt(), multTPC / mMultNormalization}; const float reso = sqrt(pow(mResolutionParams[0], 2) * values[0] + pow(mResolutionParams[1], 2) * (values[2] * mResolutionParams[5]) * pow(values[0] / sqrt(1 + pow(values[1], 2)), mResolutionParams[2]) + values[2] * pow(values[3], 2) + pow(mResolutionParams[4] * values[4], 2) + pow(values[5] * mResolutionParams[6], 2) + pow(values[5] * (values[0] / sqrt(1 + pow(values[1], 2))) * mResolutionParams[7], 2)) * dEdx * mMIP; reso >= 0.f ? resolution = reso : resolution = -999.f; @@ -160,7 +174,13 @@ inline float Response::GetNumberOfSigma(const CollisionType& collision, const Tr template inline float Response::GetNumberOfSigmaMCTuned(const CollisionType& collision, const TrackType& trk, const o2::track::PID::ID id, float mcTunedTPCSignal) const { - if (GetExpectedSigma(collision, trk, id) < 0.) { + return Response::GetNumberOfSigmaMCTunedAtMultiplicity(collision.multTPC(), trk, id, mcTunedTPCSignal); +} + +template +inline float Response::GetNumberOfSigmaMCTunedAtMultiplicity(const long multTPC, const TrackType& trk, const o2::track::PID::ID id, float mcTunedTPCSignal) const +{ + if (GetExpectedSigmaAtMultiplicity(multTPC, trk, id) < 0.) { return -999.f; } if (GetExpectedSignal(trk, id) < 0.) { @@ -169,7 +189,7 @@ inline float Response::GetNumberOfSigmaMCTuned(const CollisionType& collision, c if (!trk.hasTPC()) { return -999.f; } - return ((mcTunedTPCSignal - GetExpectedSignal(trk, id)) / GetExpectedSigma(collision, trk, id)); + return ((mcTunedTPCSignal - GetExpectedSignal(trk, id)) / GetExpectedSigmaAtMultiplicity(multTPC, trk, id)); } /// Gets the deviation between the actual signal and the expected signal diff --git a/Common/Core/RecoDecay.h b/Common/Core/RecoDecay.h index 94ff6f12664..5b4464e112a 100644 --- a/Common/Core/RecoDecay.h +++ b/Common/Core/RecoDecay.h @@ -17,15 +17,20 @@ #ifndef COMMON_CORE_RECODECAY_H_ #define COMMON_CORE_RECODECAY_H_ +// C++ includes #include // std::find #include // std::array #include // std::abs, std::sqrt #include -#include // std::move -#include // std::vector +#include // std::apply +#include // std::move +#include // std::vector -#include "TMCProcess.h" // for VMC Particle Production Process -#include "TPDGCode.h" // for PDG codes +// ROOT includes +#include // for VMC Particle Production Process +#include // for PDG codes + +// O2 includes #include "CommonConstants/MathConstants.h" /// Base class for calculating properties of reconstructed decays @@ -42,7 +47,7 @@ struct RecoDecay { Prompt, NonPrompt }; - static constexpr int8_t PdgStatusCodeAfterFlavourOscillation = 92; // decay products after B0(s) flavour oscillation + static constexpr int8_t StatusCodeAfterFlavourOscillation = 92; // decay products after B0(s) flavour oscillation // Auxiliary functions @@ -281,6 +286,19 @@ struct RecoDecay { return static_cast(length) * static_cast(mass) / p(mom); } + /// Calculates proper lifetime times c (pseudoproper decay length) in XY from information on daughter tracks. + /// \param posPV {x, y, z} or {x, y} position of the primary vertex + /// \param posSV {x, y, z} or {x, y} position of the secondary vertex + /// \param mom array of {x, y, z} or {x, y} momentum arrays of the decay products + /// \param mass mass of the decay products + /// \return pseudoproper decay length + template + static double ctXY(const T& posPV, const U& posSV, const std::array, N>& mom, const std::array mass) + { + // c t_xy = l_xy * m c^2 / (pT c) + return distanceXY(posPV, posSV) * m(mom, mass) / std::apply([](const auto&... args) { return pt(args...); }, mom); + } + /// Calculates cosine of θ* (theta star). /// \note Implemented for 2 prongs only. /// \param arrMom array of two 3-momentum arrays @@ -425,7 +443,7 @@ struct RecoDecay { static double m2(const std::array, N>& arrMom, const std::array& arrMass) { std::array momTotal{0., 0., 0.}; // candidate momentum vector - double energyTot{0.}; // candidate energy + double energyTot{0.}; // candidate energy for (std::size_t iProng = 0; iProng < N; ++iProng) { for (std::size_t iMom = 0; iMom < 3; ++iMom) { momTotal[iMom] += arrMom[iProng][iMom]; @@ -519,20 +537,20 @@ struct RecoDecay { /// Finds the mother of an MC particle by looking for the expected PDG code in the mother chain. /// \param particlesMC table with MC particles /// \param particle MC particle - /// \param PDGMother expected mother PDG code + /// \param pdgMother expected mother PDG code /// \param acceptAntiParticles switch to accept the antiparticle of the expected mother - /// \param sign antiparticle indicator of the found mother w.r.t. PDGMother; 1 if particle, -1 if antiparticle, 0 if mother not found + /// \param sign antiparticle indicator of the found mother w.r.t. pdgMother; 1 if particle, -1 if antiparticle, 0 if mother not found /// \param depthMax maximum decay tree level to check; Mothers up to this level will be considered. If -1, all levels are considered. /// \return index of the mother particle if found, -1 otherwise template static int getMother(const T& particlesMC, const typename T::iterator& particle, - int PDGMother, + int pdgMother, bool acceptAntiParticles = false, int8_t* sign = nullptr, int8_t depthMax = -1) { - int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. PDGMother) + int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. pdgMother) int indexMother = -1; // index of the final matched mother, if found int stage = 0; // mother tree level (just for debugging) bool motherFound = false; // true when the desired mother particle is found in the kine tree @@ -548,7 +566,7 @@ struct RecoDecay { while (!motherFound && arrayIds[-stage].size() > 0 && (depthMax < 0 || -stage < depthMax)) { // vector of mother indices for the current stage std::vector arrayIdsStage{}; - for (auto& iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage + for (auto iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage, o2-linter: disable=const-ref-in-for-loop (int elements) auto particleMother = particlesMC.rawIteratorAt(iPart - particlesMC.offset()); if (particleMother.has_mothers()) { for (auto iMother = particleMother.mothersIds().front(); iMother <= particleMother.mothersIds().back(); ++iMother) { // loop over the mother particles of the analysed particle @@ -557,17 +575,17 @@ struct RecoDecay { } auto mother = particlesMC.rawIteratorAt(iMother - particlesMC.offset()); // Check mother's PDG code. - auto PDGParticleIMother = mother.pdgCode(); // PDG code of the mother + auto pdgParticleIMother = mother.pdgCode(); // PDG code of the mother // printf("getMother: "); // for (int i = stage; i < 0; i++) // Indent to make the tree look nice. // printf(" "); - // printf("Stage %d: Mother PDG: %d, Index: %d\n", stage, PDGParticleIMother, iMother); - if (PDGParticleIMother == PDGMother) { // exact PDG match + // printf("Stage %d: Mother PDG: %d, Index: %d\n", stage, pdgParticleIMother, iMother); + if (pdgParticleIMother == pdgMother) { // exact PDG match sgn = 1; indexMother = iMother; motherFound = true; break; - } else if (acceptAntiParticles && PDGParticleIMother == -PDGMother) { // antiparticle PDG match + } else if (acceptAntiParticles && pdgParticleIMother == -pdgMother) { // antiparticle PDG match sgn = -1; indexMother = iMother; motherFound = true; @@ -584,8 +602,8 @@ struct RecoDecay { } if (sign) { if constexpr (acceptFlavourOscillation) { - if (std::abs(particle.getGenStatusCode()) == PdgStatusCodeAfterFlavourOscillation) { // take possible flavour oscillation of B0(s) mother into account - sgn *= -1; // select the sign of the mother after oscillation (and not before) + if (std::abs(particle.getGenStatusCode()) == StatusCodeAfterFlavourOscillation) { // take possible flavour oscillation of B0(s) mother into account + sgn *= -1; // select the sign of the mother after oscillation (and not before) } } *sign = sgn; @@ -598,15 +616,15 @@ struct RecoDecay { /// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles /// \param particle MC particle /// \param list vector where the indices of final-state daughters will be added - /// \param arrPDGFinal array of PDG codes of particles to be considered final if found + /// \param arrPdgFinal array of PDG codes of particles to be considered final if found /// \param depthMax maximum decay tree level; Daughters at this level (or beyond) will be considered final. If -1, all levels are considered. /// \param stage decay tree level; If different from 0, the particle itself will be added in the list in case it has no daughters. - /// \note Final state is defined as particles from arrPDGFinal plus final daughters of any other decay branch. - /// \note Antiparticles of particles in arrPDGFinal are accepted as well. + /// \note Final state is defined as particles from arrPdgFinal plus final daughters of any other decay branch. + /// \note Antiparticles of particles in arrPdgFinal are accepted as well. template static void getDaughters(const T& particle, std::vector* list, - const std::array& arrPDGFinal, + const std::array& arrPdgFinal, int8_t depthMax = -1, int8_t stage = 0) { @@ -635,12 +653,12 @@ struct RecoDecay { // If this is not the original particle, we are at the end of this branch and this particle is final. isFinal = true; } - auto PDGParticle = std::abs(particle.pdgCode()); + auto pdgParticle = std::abs(particle.pdgCode()); // If this is not the original particle, check its PDG code. if (!isFinal && stage > 0) { // If the particle has daughters but is considered to be final, we label it as final. - for (auto PDGi : arrPDGFinal) { - if (PDGParticle == std::abs(PDGi)) { // Accept antiparticles. + for (auto pdgI : arrPdgFinal) { // o2-linter: disable=const-ref-in-for-loop (int elements) + if (pdgParticle == std::abs(pdgI)) { // Accept antiparticles. isFinal = true; break; } @@ -651,7 +669,7 @@ struct RecoDecay { // printf("getDaughters: "); // for (int i = 0; i < stage; i++) // Indent to make the tree look nice. // printf(" "); - // printf("Stage %d: Adding %d (PDG %d) as final daughter.\n", stage, index, PDGParticle); + // printf("Stage %d: Adding %d (PDG %d) as final daughter.\n", stage, index, pdgParticle); list->push_back(particle.globalIndex()); return; } @@ -659,47 +677,52 @@ struct RecoDecay { // printf("getDaughters: "); // for (int i = 0; i < stage; i++) // Indent to make the tree look nice. // printf(" "); - // printf("Stage %d: %d (PDG %d) -> %d-%d\n", stage, index, PDGParticle, indexDaughterFirst, indexDaughterLast); + // printf("Stage %d: %d (PDG %d) -> %d-%d\n", stage, index, pdgParticle, indexDaughterFirst, indexDaughterLast); // Call itself to get daughters of daughters recursively. stage++; - for (auto& dau : particle.template daughters_as::parent_t>()) { - getDaughters(dau, list, arrPDGFinal, depthMax, stage); + for (const auto& dau : particle.template daughters_as::parent_t>()) { + getDaughters(dau, list, arrPdgFinal, depthMax, stage); } } /// Checks whether the reconstructed decay candidate is the expected decay. - /// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles - /// \param acceptIncompleteReco switch to accept candidates with only part of the daughters reconstructed + /// \tparam acceptFlavourOscillation switch to accept flavour oscillastion (i.e. B0 -> B0bar -> D+pi-) + /// \tparam checkProcess switch to accept only decay daughters by checking the production process of MC particles + /// \tparam acceptIncompleteReco switch to accept candidates with only part of the daughters reconstructed /// \tparam acceptTrackDecay switch to accept candidates with daughter tracks of pions and kaons which decayed + /// \tparam acceptTrackIntWithMaterial switch to accept candidates with final (i.e. p, K, pi) daughter tracks interacting with material /// \param particlesMC table with MC particles /// \param arrDaughters array of candidate daughters - /// \param PDGMother expected mother PDG code - /// \param arrPDGDaughters array of expected daughter PDG codes + /// \param pdgMother expected mother PDG code + /// \param arrPdgDaughters array of expected daughter PDG codes /// \param acceptAntiParticles switch to accept the antiparticle version of the expected decay - /// \param sign antiparticle indicator of the found mother w.r.t. PDGMother; 1 if particle, -1 if antiparticle, 0 if mother not found + /// \param sign antiparticle indicator of the found mother w.r.t. pdgMother; 1 if particle, -1 if antiparticle, 0 if mother not found /// \param depthMax maximum decay tree level to check; Daughters up to this level will be considered. If -1, all levels are considered. /// \param nPiToMu number of pion prongs decayed to a muon /// \param nKaToPi number of kaon prongs decayed to a pion + /// \param nInteractionsWithMaterial number of daughter particles that interacted with material /// \return index of the mother particle if the mother and daughters are correct, -1 otherwise - template + template static int getMatchedMCRec(const T& particlesMC, const std::array& arrDaughters, - int PDGMother, - std::array arrPDGDaughters, + int pdgMother, + std::array arrPdgDaughters, bool acceptAntiParticles = false, int8_t* sign = nullptr, int depthMax = 1, int8_t* nPiToMu = nullptr, - int8_t* nKaToPi = nullptr) - { - // Printf("MC Rec: Expected mother PDG: %d", PDGMother); - int8_t coefFlavourOscillation = 1; // 1 if no B0(s) flavour oscillation occured, -1 else - int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. PDGMother) - int8_t nPiToMuLocal = 0; // number of pion prongs decayed to a muon - int8_t nKaToPiLocal = 0; // number of kaon prongs decayed to a pion - int indexMother = -1; // index of the mother particle - std::vector arrAllDaughtersIndex; // vector of indices of all daughters of the mother of the first provided daughter - std::array arrDaughtersIndex; // array of indices of provided daughters + int8_t* nKaToPi = nullptr, + int8_t* nInteractionsWithMaterial = nullptr) + { + // Printf("MC Rec: Expected mother PDG: %d", pdgMother); + int8_t coefFlavourOscillation = 1; // 1 if no B0(s) flavour oscillation occured, -1 else + int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. pdgMother) + int8_t nPiToMuLocal = 0; // number of pion prongs decayed to a muon + int8_t nKaToPiLocal = 0; // number of kaon prongs decayed to a pion + int8_t nInteractionsWithMaterialLocal = 0; // number of interactions with material + int indexMother = -1; // index of the mother particle + std::vector arrAllDaughtersIndex; // vector of indices of all daughters of the mother of the first provided daughter + std::array arrDaughtersIndex; // array of indices of provided daughters if (sign) { *sign = sgn; } @@ -709,9 +732,9 @@ struct RecoDecay { if (!arrDaughters[iProng].has_mcParticle()) { return -1; } - auto particleI = arrDaughters[iProng].mcParticle(); // ith daughter particle - if (std::abs(particleI.getGenStatusCode()) == PdgStatusCodeAfterFlavourOscillation) { // oscillation decay product spotted - coefFlavourOscillation = -1; // select the sign of the mother after oscillation (and not before) + auto particleI = arrDaughters[iProng].template mcParticle_as(); // ith daughter particle + if (std::abs(particleI.getGenStatusCode()) == StatusCodeAfterFlavourOscillation) { // oscillation decay product spotted + coefFlavourOscillation = -1; // select the sign of the mother after oscillation (and not before) break; } } @@ -721,7 +744,7 @@ struct RecoDecay { if (!arrDaughters[iProng].has_mcParticle()) { return -1; } - auto particleI = arrDaughters[iProng].mcParticle(); // ith daughter particle + auto particleI = arrDaughters[iProng].template mcParticle_as(); // ith daughter particle if constexpr (acceptTrackDecay) { // Replace the MC particle associated with the prong by its mother for π → μ and K → π. auto motherI = particleI.template mothers_first_as(); @@ -737,12 +760,34 @@ struct RecoDecay { particleI = motherI; } } + if constexpr (acceptTrackIntWithMaterial) { + // Replace the MC particle associated with the prong by its mother for part → part due to material interactions. + // It keeps looking at the mother iteratively, until it finds a particle from decay or primary + auto process = particleI.getProcess(); + auto pdgI = std::abs(particleI.pdgCode()); + auto pdgMotherI = std::abs(particleI.pdgCode()); + while (process != TMCProcess::kPDecay && process != TMCProcess::kPPrimary && pdgI == pdgMotherI) { + if (!particleI.has_mothers()) { + break; + } + auto motherI = particleI.template mothers_first_as(); + pdgI = std::abs(particleI.pdgCode()); + pdgMotherI = std::abs(motherI.pdgCode()); + if (pdgI == pdgMotherI) { + particleI = motherI; + process = particleI.getProcess(); + if (process == TMCProcess::kPDecay || process == TMCProcess::kPPrimary) { // we found the original daughter that interacted with material + nInteractionsWithMaterialLocal++; + } + } + } + } arrDaughtersIndex[iProng] = particleI.globalIndex(); // Get the list of daughter indices from the mother of the first prong. if (iProng == 0) { // Get the mother index and its sign. // PDG code of the first daughter's mother determines whether the expected mother is a particle or antiparticle. - indexMother = getMother(particlesMC, particleI, PDGMother, acceptAntiParticles, &sgn, depthMax); + indexMother = getMother(particlesMC, particleI, pdgMother, acceptAntiParticles, &sgn, depthMax); // Check whether mother was found. if (indexMother <= -1) { // Printf("MC Rec: Rejected: bad mother index or PDG"); @@ -763,7 +808,7 @@ struct RecoDecay { } } // Get the list of actual final daughters. - getDaughters(particleMother, &arrAllDaughtersIndex, arrPDGDaughters, depthMax); + getDaughters(particleMother, &arrAllDaughtersIndex, arrPdgDaughters, depthMax); // printf("MC Rec: Mother %d has %d final daughters:", indexMother, arrAllDaughtersIndex.size()); // for (auto i : arrAllDaughtersIndex) { // printf(" %d", i); @@ -790,18 +835,18 @@ struct RecoDecay { return -1; } // Check daughter's PDG code. - auto PDGParticleI = particleI.pdgCode(); // PDG code of the ith daughter - // Printf("MC Rec: Daughter %d PDG: %d", iProng, PDGParticleI); - bool isPDGFound = false; // Is the PDG code of this daughter among the remaining expected PDG codes? + auto pdgParticleI = particleI.pdgCode(); // PDG code of the ith daughter + // Printf("MC Rec: Daughter %d PDG: %d", iProng, pdgParticleI); + bool isPdgFound = false; // Is the PDG code of this daughter among the remaining expected PDG codes? for (std::size_t iProngCp = 0; iProngCp < N; ++iProngCp) { - if (PDGParticleI == coefFlavourOscillation * sgn * arrPDGDaughters[iProngCp]) { - arrPDGDaughters[iProngCp] = 0; // Remove this PDG code from the array of expected ones. - isPDGFound = true; + if (pdgParticleI == coefFlavourOscillation * sgn * arrPdgDaughters[iProngCp]) { + arrPdgDaughters[iProngCp] = 0; // Remove this PDG code from the array of expected ones. + isPdgFound = true; break; } } - if (!isPDGFound) { - // Printf("MC Rec: Rejected: bad daughter PDG: %d", PDGParticleI); + if (!isPdgFound) { + // Printf("MC Rec: Rejected: bad daughter PDG: %d", pdgParticleI); return -1; } } @@ -817,6 +862,11 @@ struct RecoDecay { *nKaToPi = nKaToPiLocal; } } + if constexpr (acceptTrackIntWithMaterial) { + if (nInteractionsWithMaterial) { + *nInteractionsWithMaterial = nInteractionsWithMaterialLocal; + } + } return indexMother; } @@ -824,57 +874,57 @@ struct RecoDecay { /// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles /// \param particlesMC table with MC particles /// \param candidate candidate MC particle - /// \param PDGParticle expected particle PDG code + /// \param pdgParticle expected particle PDG code /// \param acceptAntiParticles switch to accept the antiparticle - /// \param sign antiparticle indicator of the candidate w.r.t. PDGParticle; 1 if particle, -1 if antiparticle, 0 if not matched + /// \param sign antiparticle indicator of the candidate w.r.t. pdgParticle; 1 if particle, -1 if antiparticle, 0 if not matched /// \return true if PDG code of the particle is correct, false otherwise template static int isMatchedMCGen(const T& particlesMC, const U& candidate, - int PDGParticle, + int pdgParticle, bool acceptAntiParticles = false, int8_t* sign = nullptr) { - std::array arrPDGDaughters; - return isMatchedMCGen(particlesMC, candidate, PDGParticle, std::move(arrPDGDaughters), acceptAntiParticles, sign); + std::array arrPdgDaughters; + return isMatchedMCGen(particlesMC, candidate, pdgParticle, std::move(arrPdgDaughters), acceptAntiParticles, sign); } /// Check whether the MC particle is the expected one and whether it decayed via the expected decay channel. /// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles /// \param particlesMC table with MC particles /// \param candidate candidate MC particle - /// \param PDGParticle expected particle PDG code - /// \param arrPDGDaughters array of expected PDG codes of daughters + /// \param pdgParticle expected particle PDG code + /// \param arrPdgDaughters array of expected PDG codes of daughters /// \param acceptAntiParticles switch to accept the antiparticle - /// \param sign antiparticle indicator of the candidate w.r.t. PDGParticle; 1 if particle, -1 if antiparticle, 0 if not matched + /// \param sign antiparticle indicator of the candidate w.r.t. pdgParticle; 1 if particle, -1 if antiparticle, 0 if not matched /// \param depthMax maximum decay tree level to check; Daughters up to this level will be considered. If -1, all levels are considered. /// \param listIndexDaughters vector of indices of found daughter /// \return true if PDG codes of the particle and its daughters are correct, false otherwise template static bool isMatchedMCGen(const T& particlesMC, const U& candidate, - int PDGParticle, - std::array arrPDGDaughters, + int pdgParticle, + std::array arrPdgDaughters, bool acceptAntiParticles = false, int8_t* sign = nullptr, int depthMax = 1, std::vector* listIndexDaughters = nullptr) { - // Printf("MC Gen: Expected particle PDG: %d", PDGParticle); + // Printf("MC Gen: Expected particle PDG: %d", pdgParticle); int8_t coefFlavourOscillation = 1; // 1 if no B0(s) flavour oscillation occured, -1 else - int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. PDGParticle) + int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. pdgParticle) if (sign) { *sign = sgn; } // Check the PDG code of the particle. - auto PDGCandidate = candidate.pdgCode(); - // Printf("MC Gen: Candidate PDG: %d", PDGCandidate); - if (PDGCandidate == PDGParticle) { // exact PDG match + auto pdgCandidate = candidate.pdgCode(); + // Printf("MC Gen: Candidate PDG: %d", pdgCandidate); + if (pdgCandidate == pdgParticle) { // exact PDG match sgn = 1; - } else if (acceptAntiParticles && PDGCandidate == -PDGParticle) { // antiparticle PDG match + } else if (acceptAntiParticles && pdgCandidate == -pdgParticle) { // antiparticle PDG match sgn = -1; } else { - // Printf("MC Gen: Rejected: bad particle PDG: %s%d != %d", acceptAntiParticles ? "abs " : "", PDGCandidate, std::abs(PDGParticle)); + // Printf("MC Gen: Rejected: bad particle PDG: %s%d != %d", acceptAntiParticles ? "abs " : "", pdgCandidate, std::abs(pdgParticle)); return false; } // Check the PDG codes of the decay products. @@ -894,7 +944,7 @@ struct RecoDecay { } } // Get the list of actual final daughters. - getDaughters(candidate, &arrAllDaughtersIndex, arrPDGDaughters, depthMax); + getDaughters(candidate, &arrAllDaughtersIndex, arrPdgDaughters, depthMax); // printf("MC Gen: Mother %ld has %ld final daughters:", candidate.globalIndex(), arrAllDaughtersIndex.size()); // for (auto i : arrAllDaughtersIndex) { // printf(" %d", i); @@ -907,29 +957,29 @@ struct RecoDecay { } if constexpr (acceptFlavourOscillation) { // Loop over decay candidate prongs to spot possible oscillation decay product - for (auto indexDaughterI : arrAllDaughtersIndex) { - auto candidateDaughterI = particlesMC.rawIteratorAt(indexDaughterI - particlesMC.offset()); // ith daughter particle - if (std::abs(candidateDaughterI.getGenStatusCode()) == PdgStatusCodeAfterFlavourOscillation) { // oscillation decay product spotted - coefFlavourOscillation = -1; // select the sign of the mother after oscillation (and not before) + for (auto indexDaughterI : arrAllDaughtersIndex) { // o2-linter: disable=const-ref-in-for-loop (int elements) + auto candidateDaughterI = particlesMC.rawIteratorAt(indexDaughterI - particlesMC.offset()); // ith daughter particle + if (std::abs(candidateDaughterI.getGenStatusCode()) == StatusCodeAfterFlavourOscillation) { // oscillation decay product spotted + coefFlavourOscillation = -1; // select the sign of the mother after oscillation (and not before) break; } } } // Check daughters' PDG codes. - for (auto indexDaughterI : arrAllDaughtersIndex) { + for (auto indexDaughterI : arrAllDaughtersIndex) { // o2-linter: disable=const-ref-in-for-loop (int elements) auto candidateDaughterI = particlesMC.rawIteratorAt(indexDaughterI - particlesMC.offset()); // ith daughter particle - auto PDGCandidateDaughterI = candidateDaughterI.pdgCode(); // PDG code of the ith daughter - // Printf("MC Gen: Daughter %d PDG: %d", indexDaughterI, PDGCandidateDaughterI); - bool isPDGFound = false; // Is the PDG code of this daughter among the remaining expected PDG codes? + auto pdgCandidateDaughterI = candidateDaughterI.pdgCode(); // PDG code of the ith daughter + // Printf("MC Gen: Daughter %d PDG: %d", indexDaughterI, pdgCandidateDaughterI); + bool isPdgFound = false; // Is the PDG code of this daughter among the remaining expected PDG codes? for (std::size_t iProngCp = 0; iProngCp < N; ++iProngCp) { - if (PDGCandidateDaughterI == coefFlavourOscillation * sgn * arrPDGDaughters[iProngCp]) { - arrPDGDaughters[iProngCp] = 0; // Remove this PDG code from the array of expected ones. - isPDGFound = true; + if (pdgCandidateDaughterI == coefFlavourOscillation * sgn * arrPdgDaughters[iProngCp]) { + arrPdgDaughters[iProngCp] = 0; // Remove this PDG code from the array of expected ones. + isPdgFound = true; break; } } - if (!isPDGFound) { - // Printf("MC Gen: Rejected: bad daughter PDG: %d", PDGCandidateDaughterI); + if (!isPdgFound) { + // Printf("MC Gen: Rejected: bad daughter PDG: %d", pdgCandidateDaughterI); return false; } } @@ -962,23 +1012,23 @@ struct RecoDecay { std::vector> arrayIds{}; std::vector initVec{particle.globalIndex()}; arrayIds.push_back(initVec); // the first vector contains the index of the original particle - auto PDGParticle = std::abs(particle.pdgCode()); + auto pdgParticle = std::abs(particle.pdgCode()); bool couldBePrompt = false; - if (PDGParticle / 100 == 4 || PDGParticle / 1000 == 4) { + if (pdgParticle / 100 == kCharm || pdgParticle / 1000 == kCharm) { couldBePrompt = true; } while (arrayIds[-stage].size() > 0) { // vector of mother indices for the current stage std::vector arrayIdsStage{}; - for (auto& iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage + for (auto iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage, o2-linter: disable=const-ref-in-for-loop (int elements) auto particleMother = particlesMC.rawIteratorAt(iPart - particlesMC.offset()); if (particleMother.has_mothers()) { // we exit immediately if searchUpToQuark is false and the first mother is a parton (an hadron should never be the mother of a parton) if (!searchUpToQuark) { auto mother = particlesMC.rawIteratorAt(particleMother.mothersIds().front() - particlesMC.offset()); - auto PDGParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother - if (PDGParticleIMother < 9 || (PDGParticleIMother > 20 && PDGParticleIMother < 38)) { + auto pdgParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother + if (pdgParticleIMother < 9 || (pdgParticleIMother > 20 && pdgParticleIMother < 38)) { return OriginType::Prompt; } } @@ -989,30 +1039,30 @@ struct RecoDecay { } auto mother = particlesMC.rawIteratorAt(iMother - particlesMC.offset()); // Check mother's PDG code. - auto PDGParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother + auto pdgParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother // printf("getMother: "); // for (int i = stage; i < 0; i++) // Indent to make the tree look nice. // printf(" "); - // printf("Stage %d: Mother PDG: %d, Index: %d\n", stage, PDGParticleIMother, iMother); + // printf("Stage %d: Mother PDG: %d, Index: %d\n", stage, pdgParticleIMother, iMother); if (searchUpToQuark) { if (idxBhadMothers) { - if (PDGParticleIMother / 100 == 5 || // b mesons - PDGParticleIMother / 1000 == 5) // b baryons + if (pdgParticleIMother / 100 == kBottom || // b mesons + pdgParticleIMother / 1000 == kBottom) // b baryons { idxBhadMothers->push_back(iMother); } } - if (PDGParticleIMother == 5) { // b quark + if (pdgParticleIMother == kBottom) { // b quark return OriginType::NonPrompt; } - if (PDGParticleIMother == 4) { // c quark + if (pdgParticleIMother == kCharm) { // c quark return OriginType::Prompt; } } else { if ( - (PDGParticleIMother / 100 == 5 || // b mesons - PDGParticleIMother / 1000 == 5) // b baryons + (pdgParticleIMother / 100 == kBottom || // b mesons + pdgParticleIMother / 1000 == kBottom) // b baryons ) { if (idxBhadMothers) { idxBhadMothers->push_back(iMother); @@ -1020,8 +1070,8 @@ struct RecoDecay { return OriginType::NonPrompt; } if ( - (PDGParticleIMother / 100 == 4 || // c mesons - PDGParticleIMother / 1000 == 4) // c baryons + (pdgParticleIMother / 100 == kCharm || // c mesons + pdgParticleIMother / 1000 == kCharm) // c baryons ) { couldBePrompt = true; } @@ -1060,33 +1110,33 @@ struct RecoDecay { std::vector> arrayIds{}; std::vector initVec{particle.globalIndex()}; arrayIds.push_back(initVec); // the first vector contains the index of the original particle - auto PDGParticle = std::abs(particle.pdgCode()); + auto pdgParticle = std::abs(particle.pdgCode()); bool couldBeCharm = false; - if (PDGParticle / 100 == 4 || PDGParticle / 1000 == 4) { + if (pdgParticle / 100 == kCharm || pdgParticle / 1000 == kCharm) { couldBeCharm = true; } while (arrayIds[-stage].size() > 0) { // vector of mother indices for the current stage std::vector arrayIdsStage{}; - for (auto& iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage + for (auto iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage, o2-linter: disable=const-ref-in-for-loop (int elements) auto particleMother = particlesMC.rawIteratorAt(iPart - particlesMC.offset()); if (particleMother.has_mothers()) { // we break immediately if searchUpToQuark is false and the first mother is a parton (an hadron should never be the mother of a parton) if (!searchUpToQuark) { auto mother = particlesMC.rawIteratorAt(particleMother.mothersIds().front() - particlesMC.offset()); - auto PDGParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother - if (PDGParticleIMother < 9 || (PDGParticleIMother > 20 && PDGParticleIMother < 38)) { + auto pdgParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother + if (pdgParticleIMother < 9 || (pdgParticleIMother > 20 && pdgParticleIMother < 38)) { // auto PDGPaticle = std::abs(particleMother.pdgCode()); if ( - (PDGParticleIMother / 100 == 5 || // b mesons - PDGParticleIMother / 1000 == 5) // b baryons + (pdgParticle / 100 == kBottom || // b mesons + pdgParticle / 1000 == kBottom) // b baryons ) { return OriginType::NonPrompt; // beauty } if ( - (PDGParticleIMother / 100 == 4 || // c mesons - PDGParticleIMother / 1000 == 4) // c baryons + (pdgParticle / 100 == kCharm || // c mesons + pdgParticle / 1000 == kCharm) // c baryons ) { return OriginType::Prompt; // charm } @@ -1101,31 +1151,31 @@ struct RecoDecay { auto mother = particlesMC.rawIteratorAt(iMother - particlesMC.offset()); // Check status code // auto motherStatusCode = std::abs(mother.getGenStatusCode()); - auto PDGParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother + auto pdgParticleIMother = std::abs(mother.pdgCode()); // PDG code of the mother // Check mother's PDG code. // printf("getMother: "); // for (int i = stage; i < 0; i++) // Indent to make the tree look nice. // printf(" "); - // printf("Stage %d: Mother PDG: %d, status: %d, Index: %d\n", stage, PDGParticleIMother, motherStatusCode, iMother); + // printf("Stage %d: Mother PDG: %d, status: %d, Index: %d\n", stage, pdgParticleIMother, motherStatusCode, iMother); if (searchUpToQuark) { if (idxBhadMothers) { - if (PDGParticleIMother / 100 == 5 || // b mesons - PDGParticleIMother / 1000 == 5) // b baryons + if (pdgParticleIMother / 100 == kBottom || // b mesons + pdgParticleIMother / 1000 == kBottom) // b baryons { idxBhadMothers->push_back(iMother); } } - if (PDGParticleIMother == 5) { // b quark - return OriginType::NonPrompt; // beauty + if (pdgParticleIMother == kBottom) { // b quark + return OriginType::NonPrompt; // beauty } - if (PDGParticleIMother == 4) { // c quark - return OriginType::Prompt; // charm + if (pdgParticleIMother == kCharm) { // c quark + return OriginType::Prompt; // charm } } else { if ( - (PDGParticleIMother / 100 == 5 || // b mesons - PDGParticleIMother / 1000 == 5) // b baryons + (pdgParticleIMother / 100 == kBottom || // b mesons + pdgParticleIMother / 1000 == kBottom) // b baryons ) { if (idxBhadMothers) { idxBhadMothers->push_back(iMother); @@ -1133,8 +1183,8 @@ struct RecoDecay { return OriginType::NonPrompt; // beauty } if ( - (PDGParticleIMother / 100 == 4 || // c mesons - PDGParticleIMother / 1000 == 4) // c baryons + (pdgParticleIMother / 100 == kCharm || // c mesons + pdgParticleIMother / 1000 == kCharm) // c baryons ) { couldBeCharm = true; } @@ -1362,41 +1412,41 @@ struct RecoDecayPtEtaPhiBase { return y(vec, vec[indexM]); } - /// Test consistency of calculations of kinematic quantities - /// \param pxIn px - /// \param pyIn py - /// \param pzIn pz - /// \param mIn mass - template - static void test(T pxIn, T pyIn, T pzIn, TM mIn) - { - std::array vecXYZ{pxIn, pyIn, pzIn}; - std::array vecXYZ0{0, 0, 0}; - std::array vecPtEtaPhi; - std::array vecPtEtaPhiM; - setVectorFromVariables(vecPtEtaPhi, RecoDecay::pt(vecXYZ), RecoDecay::eta(vecXYZ), RecoDecay::phi(vecXYZ)); - setVectorFromVariables(vecPtEtaPhiM, RecoDecay::pt(vecXYZ), RecoDecay::eta(vecXYZ), RecoDecay::phi(vecXYZ)); - vecPtEtaPhiM[3] = mIn; - auto vecXYZFromVec = pVector(vecPtEtaPhi); - auto vecXYZFromVars = pVector(pt(vecPtEtaPhi), eta(vecPtEtaPhi), phi(vecPtEtaPhi)); - // Test px, py, pz, pt, p, eta, phi, e, y, m - printf("RecoDecay test\n"); - printf("px: In: %g, XYZ: %g, XYZ from vec: %g, XYZ from vars: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", pxIn, vecXYZ[0], vecXYZFromVec[0], vecXYZFromVars[0], px(vecPtEtaPhi), px(vecPtEtaPhiM)); - printf("py: In: %g, XYZ: %g, XYZ from vec: %g, XYZ from vars: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", pyIn, vecXYZ[1], vecXYZFromVec[1], vecXYZFromVars[1], py(vecPtEtaPhi), py(vecPtEtaPhiM)); - printf("pz: In: %g, XYZ: %g, XYZ from vec: %g, XYZ from vars: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", pzIn, vecXYZ[2], vecXYZFromVec[2], vecXYZFromVars[2], pz(vecPtEtaPhi), pz(vecPtEtaPhiM)); - printf("pt: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::pt(vecXYZ), pt(vecPtEtaPhi), pt(vecPtEtaPhiM)); - printf("p: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::p(vecXYZ), p(vecPtEtaPhi), p(vecPtEtaPhiM)); - printf("eta: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::eta(vecXYZ), eta(vecPtEtaPhi), eta(vecPtEtaPhiM)); - printf("phi: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::phi(vecXYZ), phi(vecPtEtaPhi), phi(vecPtEtaPhiM)); - printf("e: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::e(vecXYZ, mIn), e(vecPtEtaPhi, mIn), e(vecPtEtaPhiM)); - printf("y: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::y(vecXYZ, mIn), y(vecPtEtaPhi, mIn), y(vecPtEtaPhiM)); - printf("m: In: %g, XYZ(p, E): %g, XYZ(pVec, E): %g, XYZ(arr): %g, PtEtaPhiM: %g\n", - mIn, - RecoDecay::m(RecoDecay::p(vecXYZ), RecoDecay::e(vecXYZ, mIn)), - RecoDecay::m(vecXYZ, RecoDecay::e(vecXYZ, mIn)), - RecoDecay::m(std::array{vecXYZ, vecXYZ0}, std::array{mIn, 0.}), - vecPtEtaPhiM[indexM]); - } + // /// Test consistency of calculations of kinematic quantities + // /// \param pxIn px + // /// \param pyIn py + // /// \param pzIn pz + // /// \param mIn mass + // template + // static void test(T pxIn, T pyIn, T pzIn, TM mIn) + // { + // std::array vecXYZ{pxIn, pyIn, pzIn}; + // std::array vecXYZ0{0, 0, 0}; + // std::array vecPtEtaPhi; + // std::array vecPtEtaPhiM; + // setVectorFromVariables(vecPtEtaPhi, RecoDecay::pt(vecXYZ), RecoDecay::eta(vecXYZ), RecoDecay::phi(vecXYZ)); + // setVectorFromVariables(vecPtEtaPhiM, RecoDecay::pt(vecXYZ), RecoDecay::eta(vecXYZ), RecoDecay::phi(vecXYZ)); + // vecPtEtaPhiM[3] = mIn; + // auto vecXYZFromVec = pVector(vecPtEtaPhi); + // auto vecXYZFromVars = pVector(pt(vecPtEtaPhi), eta(vecPtEtaPhi), phi(vecPtEtaPhi)); + // // Test px, py, pz, pt, p, eta, phi, e, y, m + // printf("RecoDecay test\n"); + // printf("px: In: %g, XYZ: %g, XYZ from vec: %g, XYZ from vars: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", pxIn, vecXYZ[0], vecXYZFromVec[0], vecXYZFromVars[0], px(vecPtEtaPhi), px(vecPtEtaPhiM)); + // printf("py: In: %g, XYZ: %g, XYZ from vec: %g, XYZ from vars: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", pyIn, vecXYZ[1], vecXYZFromVec[1], vecXYZFromVars[1], py(vecPtEtaPhi), py(vecPtEtaPhiM)); + // printf("pz: In: %g, XYZ: %g, XYZ from vec: %g, XYZ from vars: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", pzIn, vecXYZ[2], vecXYZFromVec[2], vecXYZFromVars[2], pz(vecPtEtaPhi), pz(vecPtEtaPhiM)); + // printf("pt: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::pt(vecXYZ), pt(vecPtEtaPhi), pt(vecPtEtaPhiM)); + // printf("p: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::p(vecXYZ), p(vecPtEtaPhi), p(vecPtEtaPhiM)); + // printf("eta: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::eta(vecXYZ), eta(vecPtEtaPhi), eta(vecPtEtaPhiM)); + // printf("phi: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::phi(vecXYZ), phi(vecPtEtaPhi), phi(vecPtEtaPhiM)); + // printf("e: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::e(vecXYZ, mIn), e(vecPtEtaPhi, mIn), e(vecPtEtaPhiM)); + // printf("y: XYZ: %g, PtEtaPhi: %g, PtEtaPhiM: %g\n", RecoDecay::y(vecXYZ, mIn), y(vecPtEtaPhi, mIn), y(vecPtEtaPhiM)); + // printf("m: In: %g, XYZ(p, E): %g, XYZ(pVec, E): %g, XYZ(arr): %g, PtEtaPhiM: %g\n", + // mIn, + // RecoDecay::m(RecoDecay::p(vecXYZ), RecoDecay::e(vecXYZ, mIn)), + // RecoDecay::m(vecXYZ, RecoDecay::e(vecXYZ, mIn)), + // RecoDecay::m(std::array{vecXYZ, vecXYZ0}, std::array{mIn, 0.}), + // vecPtEtaPhiM[indexM]); + // } }; using RecoDecayPtEtaPhi = RecoDecayPtEtaPhiBase<>; // alias for instance with default parameters diff --git a/Common/Core/TableHelper.cxx b/Common/Core/TableHelper.cxx index 4af58f00428..04745ffe694 100644 --- a/Common/Core/TableHelper.cxx +++ b/Common/Core/TableHelper.cxx @@ -17,14 +17,14 @@ #include "Common/Core/TableHelper.h" -#include - #include "Framework/InitContext.h" #include "Framework/RunningWorkflowInfo.h" +#include + /// Function to print the table required in the full workflow /// @param initContext initContext of the init function -void printTablesInWorkflow(o2::framework::InitContext& initContext) +void o2::common::core::printTablesInWorkflow(o2::framework::InitContext& initContext) { auto& workflows = initContext.services().get(); for (auto const& device : workflows.devices) { @@ -37,7 +37,7 @@ void printTablesInWorkflow(o2::framework::InitContext& initContext) /// Function to check if a table is required in a workflow /// @param initContext initContext of the init function /// @param table name of the table to check for -bool isTableRequiredInWorkflow(o2::framework::InitContext& initContext, const std::string& table) +bool o2::common::core::isTableRequiredInWorkflow(o2::framework::InitContext& initContext, const std::string& table) { LOG(debug) << "Checking if table " << table << " is needed"; bool tableNeeded = false; @@ -57,7 +57,7 @@ bool isTableRequiredInWorkflow(o2::framework::InitContext& initContext, const st /// @param initContext initContext of the init function /// @param table name of the table to check for /// @param flag bool value of flag to set, if the given value is true it will be kept, disregarding the table usage in the workflow. -void enableFlagIfTableRequired(o2::framework::InitContext& initContext, const std::string& table, bool& flag) +void o2::common::core::enableFlagIfTableRequired(o2::framework::InitContext& initContext, const std::string& table, bool& flag) { if (flag) { LOG(info) << "Table enabled: " + table; @@ -75,7 +75,7 @@ void enableFlagIfTableRequired(o2::framework::InitContext& initContext, const st /// @param initContext initContext of the init function /// @param table name of the table to check for /// @param flag int value of flag to set, only if initially set to -1. Initial values of 0 or 1 will be kept disregarding the table usage in the workflow. -void enableFlagIfTableRequired(o2::framework::InitContext& initContext, const std::string& table, int& flag) +void o2::common::core::enableFlagIfTableRequired(o2::framework::InitContext& initContext, const std::string& table, int& flag) { if (flag > 0) { flag = 1; diff --git a/Common/Core/TableHelper.h b/Common/Core/TableHelper.h index a5935c558f3..56d2264ed6c 100644 --- a/Common/Core/TableHelper.h +++ b/Common/Core/TableHelper.h @@ -18,11 +18,15 @@ #ifndef COMMON_CORE_TABLEHELPER_H_ #define COMMON_CORE_TABLEHELPER_H_ -#include - +#include "Framework/Configurable.h" #include "Framework/InitContext.h" #include "Framework/RunningWorkflowInfo.h" +#include + +namespace o2::common::core +{ + /// Function to print the table required in the full workflow /// @param initContext initContext of the init function void printTablesInWorkflow(o2::framework::InitContext& initContext); @@ -75,14 +79,16 @@ bool getTaskOptionValue(o2::framework::InitContext& initContext, const std::stri } if (device.name == taskName) { // Found the mother task int optionCounter = 0; - for (auto const& option : device.options) { + for (const o2::framework::ConfigParamSpec& option : device.options) { if (verbose) { - LOG(info) << " Option " << optionCounter++ << " " << option.name << " = '" << option.defaultValue.asString() << "'"; + LOG(info) << " Option " << optionCounter++ << " " << option.name << " of type " << static_cast(option.type) << " = '" << option.defaultValue.asString() << "'"; } if (option.name == optName) { value = option.defaultValue.get(); if (verbose) { - LOG(info) << " Found option '" << optName << "' with value '" << value << "'"; + if constexpr (!std::is_same_v>) { + LOG(info) << " Found option '" << optName << "' with value '" << value << "'"; + } found = true; } else { return true; @@ -95,4 +101,22 @@ bool getTaskOptionValue(o2::framework::InitContext& initContext, const std::stri return false; } +/// Function to check for a specific configurable from another task in the current workflow and fetch its value. Useful for tasks that need to know the value of a configurable in another task. +/// @param initContext initContext of the init function +/// @param taskName name of the task to check for +/// @param value Task configurable to inherit from (name and values are used) +/// @param verbose if true, print debug messages +template +bool getTaskOptionValue(o2::framework::InitContext& initContext, const std::string& taskName, ValueType& configurable, const bool verbose = true) +{ + return getTaskOptionValue(initContext, taskName, configurable.name, configurable.value, verbose); +} + +} // namespace o2::common::core + +using o2::common::core::enableFlagIfTableRequired; +using o2::common::core::getTaskOptionValue; +using o2::common::core::isTableRequiredInWorkflow; +using o2::common::core::printTablesInWorkflow; + #endif // COMMON_CORE_TABLEHELPER_H_ diff --git a/Common/Core/TrackSelection.cxx b/Common/Core/TrackSelection.cxx index 4cc355b57ce..717d7db77f5 100644 --- a/Common/Core/TrackSelection.cxx +++ b/Common/Core/TrackSelection.cxx @@ -30,7 +30,7 @@ bool TrackSelection::FulfillsITSHitRequirements(uint8_t itsClusterMap) const return true; } -const std::string TrackSelection::mCutNames[static_cast(TrackSelection::TrackCuts::kNCuts)] = {"TrackType", "PtRange", "EtaRange", "TPCNCls", "TPCCrossedRows", "TPCCrossedRowsOverNCls", "TPCChi2NDF", "TPCRefit", "ITSNCls", "ITSChi2NDF", "ITSRefit", "ITSHits", "GoldenChi2", "DCAxy", "DCAz"}; +const std::string TrackSelection::mCutNames[static_cast(TrackSelection::TrackCuts::kNCuts)] = {"TrackType", "PtRange", "EtaRange", "TPCNCls", "TPCCrossedRows", "TPCCrossedRowsOverNCls", "TPCChi2NDF", "TPCRefit", "ITSNCls", "ITSChi2NDF", "ITSRefit", "ITSHits", "GoldenChi2", "DCAxy", "DCAz", "TPCFracSharedCls"}; void TrackSelection::SetTrackType(o2::aod::track::TrackTypeEnum trackType) { @@ -79,6 +79,11 @@ void TrackSelection::SetMinNCrossedRowsOverFindableClustersTPC(float minNCrossed mMinNCrossedRowsOverFindableClustersTPC = minNCrossedRowsOverFindableClustersTPC; LOG(info) << "Track selection, set min N crossed rows over findable clusters TPC: " << mMinNCrossedRowsOverFindableClustersTPC; } +void TrackSelection::SetMaxTPCFractionSharedCls(float maxTPCFractionSharedCls) +{ + mMaxTPCFractionSharedCls = maxTPCFractionSharedCls; + LOG(info) << "Track selection, set max fraction of shared clusters TPC: " << mMaxTPCFractionSharedCls; +} void TrackSelection::SetMinNClustersITS(int minNClustersITS) { mMinNClustersITS = minNClustersITS; @@ -175,6 +180,9 @@ void TrackSelection::print() const case TrackCuts::kDCAz: LOG(info) << mCutNames[i] << " < " << mMaxDcaZ; break; + case TrackCuts::kTPCFracSharedCls: + LOG(info) << mCutNames[i] << " < " << mMaxTPCFractionSharedCls; + break; default: LOG(fatal) << "Cut unknown!"; } diff --git a/Common/Core/TrackSelection.h b/Common/Core/TrackSelection.h index 351b662c48d..19d77a198e1 100644 --- a/Common/Core/TrackSelection.h +++ b/Common/Core/TrackSelection.h @@ -45,6 +45,7 @@ class TrackSelection kGoldenChi2, kDCAxy, kDCAz, + kTPCFracSharedCls, kNCuts }; @@ -114,6 +115,9 @@ class TrackSelection if (!IsSelected(track, TrackCuts::kDCAz)) { return false; } + if (!IsSelected(track, TrackCuts::kTPCFracSharedCls)) { + return false; + } return true; } @@ -144,6 +148,7 @@ class TrackSelection setFlag(TrackCuts::kGoldenChi2); setFlag(TrackCuts::kDCAxy); setFlag(TrackCuts::kDCAz); + setFlag(TrackCuts::kTPCFracSharedCls); return flag; } @@ -199,6 +204,8 @@ class TrackSelection case TrackCuts::kDCAz: return std::fabs(track.dcaZ()) <= mMaxDcaZ; + case TrackCuts::kTPCFracSharedCls: + return track.tpcFractionSharedCls() <= mMaxTPCFractionSharedCls; default: return false; @@ -225,6 +232,7 @@ class TrackSelection void SetRequireNoHitsInITSLayers(std::set excludedLayers); /// @brief Reset ITS requirements void ResetITSRequirements() { mRequiredITSHits.clear(); } + void SetMaxTPCFractionSharedCls(float maxTPCFractionSharedCls); /// @brief Print the track selection void print() const; @@ -250,6 +258,8 @@ class TrackSelection float mMaxDcaZ{1e10f}; // max dca in z direction std::function mMaxDcaXYPtDep{}; // max dca in xy plane as function of pT + float mMaxTPCFractionSharedCls{1e10f}; // max fraction of shared TPC clusters + bool mRequireITSRefit{false}; // require refit in ITS bool mRequireTPCRefit{false}; // require refit in TPC bool mRequireGoldenChi2{false}; // require golden chi2 cut (Run 2 only) diff --git a/Common/Core/TrackSelectionDefaults.cxx b/Common/Core/TrackSelectionDefaults.cxx index 1974b7df38f..2958718feba 100644 --- a/Common/Core/TrackSelectionDefaults.cxx +++ b/Common/Core/TrackSelectionDefaults.cxx @@ -120,12 +120,27 @@ TrackSelection getGlobalTrackSelectionRun3HF() // Reduced default track selection for jet validation based on hybrid cuts for converted (based on ESD's from run 2) A02D's TrackSelection getJEGlobalTrackSelectionRun2() { - TrackSelection selectedTracks = getGlobalTrackSelection(); - selectedTracks.SetPtRange(0.15f, 1e15f); - selectedTracks.SetRequireGoldenChi2(false); - selectedTracks.SetMaxDcaXYPtDep([](float /*pt*/) { return 1e+10; }); + TrackSelection selectedTracks; + + // These track selections are the same as the global track selections as of Jan 2025. Implemented seperately to prevent future + // global track selection changes from affecting the Run 2 hybrid track selections. + selectedTracks.SetTrackType(o2::aod::track::Run2Track); // Run 2 track asked by default + selectedTracks.SetRequireITSRefit(true); + selectedTracks.SetRequireTPCRefit(true); + selectedTracks.SetRequireGoldenChi2(true); + selectedTracks.SetMinNCrossedRowsTPC(70); + selectedTracks.SetMinNCrossedRowsOverFindableClustersTPC(0.8f); + selectedTracks.SetMaxChi2PerClusterTPC(4.f); + selectedTracks.SetMaxChi2PerClusterITS(36.f); + + // These track selections are different to the global track selections as of Jan 2025. + selectedTracks.SetPtRange(0.15f, 1000.f); selectedTracks.SetEtaRange(-0.9f, 0.9f); + selectedTracks.SetMaxDcaXYPtDep([](float /*pt*/) { return 1e+10; }); selectedTracks.SetMaxDcaXY(2.4f); selectedTracks.SetMaxDcaZ(3.2f); + selectedTracks.SetRequireHitsInITSLayers(0, {0, 1}); // no minimum required number of hits in any SPD layer + selectedTracks.SetMaxTPCFractionSharedCls(0.4f); // This cut machinery was added since it's used in hybrid tracks Run 2 + return selectedTracks; } diff --git a/Common/Core/fwdtrackUtilities.h b/Common/Core/fwdtrackUtilities.h new file mode 100644 index 00000000000..74fe125c2f0 --- /dev/null +++ b/Common/Core/fwdtrackUtilities.h @@ -0,0 +1,104 @@ +// 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. + +/// \file fwdtrackUtilities.h +/// \brief Utilities for manipulating parameters of fwdtracks +/// \author Maurice Coquet +/// \author Luca Micheletti +/// \author Daiki Sekihata + +#ifndef COMMON_CORE_FWDTRACKUTILITIES_H_ +#define COMMON_CORE_FWDTRACKUTILITIES_H_ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +namespace o2::aod +{ +namespace fwdtrackutils +{ +// Index used to set different options for muon propagation +enum class propagationPoint : int { + kToVertex = 0, + kToDCA = 1, + kToRabs = 2, +}; +using SMatrix55 = ROOT::Math::SMatrix>; +using SMatrix5 = ROOT::Math::SVector; + +/// propagate fwdtrack to a certain point. +template +o2::dataformats::GlobalFwdTrack propagateMuon(TFwdTrack const& muon, TCollision const& collision, const propagationPoint endPoint) +{ + double chi2 = muon.chi2(); + SMatrix5 tpars(muon.x(), muon.y(), muon.phi(), muon.tgl(), muon.signed1Pt()); + std::vector v1{muon.cXX(), muon.cXY(), muon.cYY(), muon.cPhiX(), muon.cPhiY(), + muon.cPhiPhi(), muon.cTglX(), muon.cTglY(), muon.cTglPhi(), muon.cTglTgl(), + muon.c1PtX(), muon.c1PtY(), muon.c1PtPhi(), muon.c1PtTgl(), muon.c1Pt21Pt2()}; + SMatrix55 tcovs(v1.begin(), v1.end()); + o2::track::TrackParCovFwd fwdtrack{muon.z(), tpars, tcovs, chi2}; + o2::dataformats::GlobalFwdTrack propmuon; + o2::globaltracking::MatchGlobalFwd mMatching; + + if (static_cast(muon.trackType()) > 2) { // MCH-MID or MCH standalone + o2::dataformats::GlobalFwdTrack track; + track.setParameters(tpars); + track.setZ(fwdtrack.getZ()); + track.setCovariances(tcovs); + auto mchTrack = mMatching.FwdtoMCH(track); + + if (endPoint == propagationPoint::kToVertex) { + o2::mch::TrackExtrap::extrapToVertex(mchTrack, collision.posX(), collision.posY(), collision.posZ(), collision.covXX(), collision.covYY()); + } else if (endPoint == propagationPoint::kToDCA) { + o2::mch::TrackExtrap::extrapToVertexWithoutBranson(mchTrack, collision.posZ()); + } else if (endPoint == propagationPoint::kToRabs) { + o2::mch::TrackExtrap::extrapToZ(mchTrack, -505.); + } + + auto proptrack = mMatching.MCHtoFwd(mchTrack); + propmuon.setParameters(proptrack.getParameters()); + propmuon.setZ(proptrack.getZ()); + propmuon.setCovariances(proptrack.getCovariances()); + } else if (static_cast(muon.trackType()) < 2) { // MFT-MCH-MID + const double centerMFT[3] = {0, 0, -61.4}; + o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); + auto Bz = field->getBz(centerMFT); // Get field at centre of MFT + auto geoMan = o2::base::GeometryManager::meanMaterialBudget(muon.x(), muon.y(), muon.z(), collision.posX(), collision.posY(), collision.posZ()); + auto x2x0 = static_cast(geoMan.meanX2X0); + if (endPoint == propagationPoint::kToVertex) { + fwdtrack.propagateToVtxhelixWithMCS(collision.posZ(), {collision.posX(), collision.posY()}, {collision.covXX(), collision.covYY()}, Bz, x2x0); + } else if (endPoint == propagationPoint::kToDCA) { + fwdtrack.propagateToZhelix(collision.posZ(), Bz); + } + propmuon.setParameters(fwdtrack.getParameters()); + propmuon.setZ(fwdtrack.getZ()); + propmuon.setCovariances(fwdtrack.getCovariances()); + } + + v1.clear(); + v1.shrink_to_fit(); + + return propmuon; +} +} // namespace fwdtrackutils +} // namespace o2::aod + +#endif // COMMON_CORE_FWDTRACKUTILITIES_H_ diff --git a/Common/Core/macros/testCollisionTypeHelper.C b/Common/Core/macros/testCollisionTypeHelper.C new file mode 100644 index 00000000000..43624ea697e --- /dev/null +++ b/Common/Core/macros/testCollisionTypeHelper.C @@ -0,0 +1,30 @@ +// 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. + +/// \file testCollisionTypeHelper.C +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \brief Test the CollisionTypeHelper functionality + +#include "Common/Core/CollisionTypeHelper.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPLHCIFData.h" + +void testCollisionTypeHelper(int runNumber = 544124) +{ + + auto& ccdb = o2::ccdb::BasicCCDBManager::instance(); + ccdb.setURL("http://alice-ccdb.cern.ch"); + o2::parameters::GRPLHCIFData* grpo = ccdb.getSpecificForRun("GLO/Config/GRPLHCIF", + runNumber); + grpo->print(); + int collsys = o2::common::core::CollisionSystemType::getCollisionTypeFromGrp(grpo); +} diff --git a/Common/DataModel/CMakeLists.txt b/Common/DataModel/CMakeLists.txt index 39e83d2a2dd..084222c9648 100644 --- a/Common/DataModel/CMakeLists.txt +++ b/Common/DataModel/CMakeLists.txt @@ -16,6 +16,9 @@ o2physics_add_header_only_library(DataModel FT0Corrected.h Multiplicity.h PIDResponse.h + PIDResponseITS.h + PIDResponseTOF.h + PIDResponseTPC.h CollisionAssociationTables.h TrackSelectionTables.h McCollisionExtra.h @@ -23,4 +26,5 @@ o2physics_add_header_only_library(DataModel MatchMFTFT0.h MftmchMatchingML.h ZDCInterCalib.h - EseTable.h) + EseTable.h + FwdTrackReAlignTables.h) diff --git a/Common/DataModel/Centrality.h b/Common/DataModel/Centrality.h index e2aa77d0238..fa7e2ec51bc 100644 --- a/Common/DataModel/Centrality.h +++ b/Common/DataModel/Centrality.h @@ -26,14 +26,15 @@ DECLARE_SOA_COLUMN(CentRun2CL1, centRun2CL1, float); //! Run 2 DECLARE_SOA_COLUMN(CentRun2RefMult5, centRun2RefMult5, float); //! Run 2 cent. from ref. mult. estimator, eta 0.5 DECLARE_SOA_COLUMN(CentRun2RefMult8, centRun2RefMult8, float); //! Run 2 cent. from ref. mult. estimator, eta 0.8 -DECLARE_SOA_COLUMN(CentFV0A, centFV0A, float); //! Run 3 cent. from FV0A multiplicities -DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); //! Run 3 cent. from FT0A+FT0C multiplicities -DECLARE_SOA_COLUMN(CentFT0A, centFT0A, float); //! Run 3 cent. from FT0A multiplicity -DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); //! Run 3 cent. from FT0C multiplicity -DECLARE_SOA_COLUMN(CentFDDM, centFDDM, float); //! Run 3 cent. from FDDA+FDDC multiplicity -DECLARE_SOA_COLUMN(CentNTPV, centNTPV, float); //! Run 3 cent. from the number of tracks contributing to the -DECLARE_SOA_COLUMN(CentNGlobal, centNGlobal, float); //! Run 3 cent. from the number of tracks contributing to the PV -DECLARE_SOA_COLUMN(CentMFT, centMFT, float); //! Run 3 cent. from the number of tracks in the MFT +DECLARE_SOA_COLUMN(CentFV0A, centFV0A, float); //! Run 3 cent. from FV0A multiplicities +DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); //! Run 3 cent. from FT0A+FT0C multiplicities +DECLARE_SOA_COLUMN(CentFT0A, centFT0A, float); //! Run 3 cent. from FT0A multiplicity +DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); //! Run 3 cent. from FT0C multiplicity +DECLARE_SOA_COLUMN(CentFT0CVariant1, centFT0CVariant1, float); //! Run 3 cent. from FT0C multiplicity +DECLARE_SOA_COLUMN(CentFDDM, centFDDM, float); //! Run 3 cent. from FDDA+FDDC multiplicity +DECLARE_SOA_COLUMN(CentNTPV, centNTPV, float); //! Run 3 cent. from the number of tracks contributing to the +DECLARE_SOA_COLUMN(CentNGlobal, centNGlobal, float); //! Run 3 cent. from the number of tracks contributing to the PV +DECLARE_SOA_COLUMN(CentMFT, centMFT, float); //! Run 3 cent. from the number of tracks in the MFT } // namespace cent // Run 2 tables @@ -56,6 +57,14 @@ DECLARE_SOA_TABLE(CentNTPVs, "AOD", "CENTNTPV", cent::CentNTPV); //! Ru DECLARE_SOA_TABLE(CentNGlobals, "AOD", "CENTNGLOBAL", cent::CentNGlobal); //! Run 3 NGlobal centrality table DECLARE_SOA_TABLE(CentMFTs, "AOD", "CENTMFT", cent::CentMFT); //! Run 3 MFT tracks centrality table +// Run 3 variant tables +DECLARE_SOA_TABLE(CentFT0CVariant1s, "AOD", "CENTFT0Cvar1", cent::CentFT0CVariant1); //! Run 3 FT0C variant 1 + +// Run 3 centrality per BC (joinable with BC) +DECLARE_SOA_TABLE(BCCentFT0Ms, "AOD", "BCCENTFT0M", cent::CentFT0M, o2::soa::Marker<1>); //! Run 3 FT0M BC centrality table +DECLARE_SOA_TABLE(BCCentFT0As, "AOD", "BCCENTFT0A", cent::CentFT0A, o2::soa::Marker<1>); //! Run 3 FT0A BC centrality table +DECLARE_SOA_TABLE(BCCentFT0Cs, "AOD", "BCCENTFT0C", cent::CentFT0C, o2::soa::Marker<1>); //! Run 3 FT0C BC centrality table + using CentRun2V0M = CentRun2V0Ms::iterator; using CentRun2V0A = CentRun2V0As::iterator; using CentRun2SPDTrk = CentRun2SPDTrks::iterator; @@ -73,6 +82,10 @@ using CentNTPV = CentNTPVs::iterator; using CentNGlobal = CentNGlobals::iterator; using CentMFT = CentMFTs::iterator; +using BCCentFT0M = BCCentFT0Ms::iterator; +using BCCentFT0A = BCCentFT0As::iterator; +using BCCentFT0C = BCCentFT0Cs::iterator; + template concept HasRun2Centrality = requires(T&& t) { { t.centRun2V0M() }; diff --git a/Common/DataModel/EseTable.h b/Common/DataModel/EseTable.h index ca9bd41357e..68ffdff450a 100644 --- a/Common/DataModel/EseTable.h +++ b/Common/DataModel/EseTable.h @@ -29,20 +29,23 @@ namespace q_vector DECLARE_SOA_COLUMN(QPERCFT0C, qPERCFT0C, std::vector); DECLARE_SOA_COLUMN(QPERCFT0A, qPERCFT0A, std::vector); DECLARE_SOA_COLUMN(QPERCFV0A, qPERCFV0A, std::vector); -DECLARE_SOA_COLUMN(QPERCTPC, qPERCTPC, std::vector); -DECLARE_SOA_COLUMN(FESECOL, fESECOL, std::vector); +DECLARE_SOA_COLUMN(QPERCTPCall, qPERCTPCall, std::vector); +DECLARE_SOA_COLUMN(QPERCTPCneg, qPERCTPCneg, std::vector); +DECLARE_SOA_COLUMN(QPERCTPCpos, qPERCTPCpos, std::vector); } // namespace q_vector DECLARE_SOA_TABLE(QPercentileFT0Cs, "AOD", "QPERCENTILEFT0C", q_vector::QPERCFT0C); DECLARE_SOA_TABLE(QPercentileFT0As, "AOD", "QPERCENTILEFT0A", q_vector::QPERCFT0A); DECLARE_SOA_TABLE(QPercentileFV0As, "AOD", "QPERCENTILEFV0A", q_vector::QPERCFV0A); -DECLARE_SOA_TABLE(QPercentileTPCs, "AOD", "QPERCENTILETPC", q_vector::QPERCTPC); -DECLARE_SOA_TABLE(FEseCols, "AOD", "FEVENTSHAPE", q_vector::FESECOL); +DECLARE_SOA_TABLE(QPercentileTPCalls, "AOD", "QPERCENTILETPCall", q_vector::QPERCTPCall); +DECLARE_SOA_TABLE(QPercentileTPCnegs, "AOD", "QPERCENTILETPCneg", q_vector::QPERCTPCneg); +DECLARE_SOA_TABLE(QPercentileTPCposs, "AOD", "QPERCENTILETPCpos", q_vector::QPERCTPCpos); using QPercentileFT0C = QPercentileFT0Cs::iterator; using QPercentileFT0A = QPercentileFT0As::iterator; using QPercentileFV0A = QPercentileFV0As::iterator; -using QPercentileTPC = QPercentileTPCs::iterator; -using FEseCol = FEseCols::iterator; +using QPercentileTPCall = QPercentileTPCalls::iterator; +using QPercentileTPCneg = QPercentileTPCnegs::iterator; +using QPercentileTPCpos = QPercentileTPCposs::iterator; } // namespace o2::aod diff --git a/Common/DataModel/EventSelection.h b/Common/DataModel/EventSelection.h index 7b7b4ac9ae0..77849d0d7cf 100644 --- a/Common/DataModel/EventSelection.h +++ b/Common/DataModel/EventSelection.h @@ -8,12 +8,19 @@ // 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. + +/// \file EventSelection.h +/// \brief Definitions of event selection tables +/// +/// \author Evgeny Kryshen and Igor Altsybeev + #ifndef COMMON_DATAMODEL_EVENTSELECTION_H_ #define COMMON_DATAMODEL_EVENTSELECTION_H_ #include "Framework/AnalysisDataModel.h" #include "Common/CCDB/TriggerAliases.h" #include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/RCTSelectionFlags.h" namespace o2::aod { @@ -47,6 +54,7 @@ namespace evsel { DECLARE_SOA_BITMAP_COLUMN(Alias, alias, 32); //! Bitmask of fired trigger aliases (see TriggerAliases.h for definitions) DECLARE_SOA_BITMAP_COLUMN(Selection, selection, 64); //! Bitmask of selection flags (see EventSelectionParams.h for definitions) +DECLARE_SOA_BITMAP_COLUMN(Rct, rct, 32); //! Bitmask of RCT flags DECLARE_SOA_COLUMN(Sel7, sel7, bool); //! Event selection decision based on V0A & V0C DECLARE_SOA_COLUMN(Sel8, sel8, bool); //! Event selection decision based on TVX DECLARE_SOA_INDEX_COLUMN_FULL(FoundBC, foundBC, int, BCs, "_foundBC"); //! BC entry index in BCs table (-1 if doesn't exist) @@ -54,20 +62,20 @@ DECLARE_SOA_INDEX_COLUMN_FULL(FoundFT0, foundFT0, int, FT0s, "_foundFT0"); //! DECLARE_SOA_INDEX_COLUMN_FULL(FoundFV0, foundFV0, int, FV0As, "_foundFV0"); //! FV0 entry index in FV0As table (-1 if doesn't exist) DECLARE_SOA_INDEX_COLUMN_FULL(FoundFDD, foundFDD, int, FDDs, "_foundFDD"); //! FDD entry index in FDDs table (-1 if doesn't exist) DECLARE_SOA_INDEX_COLUMN_FULL(FoundZDC, foundZDC, int, Zdcs, "_foundZDC"); //! ZDC entry index in ZDCs table (-1 if doesn't exist) -DECLARE_SOA_COLUMN(BcInTF, bcInTF, int); //! Position of a (found) bunch crossing inside a given timeframe -DECLARE_SOA_COLUMN(NumTracksInTimeRange, trackOccupancyInTimeRange, int); //! Occupancy in specified time interval by a number of tracks from nearby collisions -DECLARE_SOA_COLUMN(SumAmpFT0CInTimeRange, ft0cOccupancyInTimeRange, float); //! Occupancy in specified time interval by a sum of FT0C amplitudes from nearby collisions +DECLARE_SOA_COLUMN(NumTracksInTimeRange, trackOccupancyInTimeRange, int); //! Occupancy in specified time interval by a number of tracks from nearby collisions // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(SumAmpFT0CInTimeRange, ft0cOccupancyInTimeRange, float); //! Occupancy in specified time interval by a sum of FT0C amplitudes from nearby collisions // o2-linter: disable=name/o2-column } // namespace evsel // bc-joinable event selection decisions DECLARE_SOA_TABLE(BcSels, "AOD", "BCSEL", //! - evsel::Alias, evsel::Selection, evsel::FoundFT0Id, evsel::FoundFV0Id, evsel::FoundFDDId, evsel::FoundZDCId); + evsel::Alias, evsel::Selection, evsel::Rct, evsel::FoundFT0Id, evsel::FoundFV0Id, evsel::FoundFDDId, evsel::FoundZDCId); using BcSel = BcSels::iterator; // collision-joinable event selection decisions DECLARE_SOA_TABLE(EvSels, "AOD", "EVSEL", //! evsel::Alias, evsel::Selection, + evsel::Rct, evsel::Sel7, evsel::Sel8, evsel::FoundBCId, @@ -75,7 +83,6 @@ DECLARE_SOA_TABLE(EvSels, "AOD", "EVSEL", //! evsel::FoundFV0Id, evsel::FoundFDDId, evsel::FoundZDCId, - evsel::BcInTF, evsel::NumTracksInTimeRange, evsel::SumAmpFT0CInTimeRange); using EvSel = EvSels::iterator; diff --git a/Common/DataModel/FwdTrackReAlignTables.h b/Common/DataModel/FwdTrackReAlignTables.h new file mode 100644 index 00000000000..2dc9bf3dd6c --- /dev/null +++ b/Common/DataModel/FwdTrackReAlignTables.h @@ -0,0 +1,77 @@ +// 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. + +/// \file FwdTrackReAlignTables.h +/// \brief Table definitions for re-aligned forward tracks +/// \author Chi Zhang , CEA-Saclay + +#ifndef COMMON_DATAMODEL_FWDTRACKREALIGNTABLES_H_ +#define COMMON_DATAMODEL_FWDTRACKREALIGNTABLES_H_ + +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace fwdtrackrealign +{ +DECLARE_SOA_COLUMN(IsRemovable, isRemovable, int); //! flag to check the refit status +} + +DECLARE_SOA_TABLE_FULL(StoredFwdTracksReAlign, "FwdTracksReAlign", "AOD", "FWDTRACKREALIGN", + o2::soa::Index<>, fwdtrack::CollisionId, fwdtrack::TrackType, + fwdtrack::X, fwdtrack::Y, fwdtrack::Z, fwdtrack::Phi, fwdtrack::Tgl, + fwdtrack::Signed1Pt, fwdtrack::NClusters, fwdtrack::PDca, fwdtrack::RAtAbsorberEnd, + fwdtrackrealign::IsRemovable, + fwdtrack::Px, + fwdtrack::Py, + fwdtrack::Pz, + fwdtrack::Sign, + fwdtrack::Chi2, fwdtrack::Chi2MatchMCHMID, fwdtrack::Chi2MatchMCHMFT, + fwdtrack::MatchScoreMCHMFT, fwdtrack::MFTTrackId, fwdtrack::MCHTrackId, + fwdtrack::MCHBitMap, fwdtrack::MIDBitMap, fwdtrack::MIDBoards, + fwdtrack::TrackTime, fwdtrack::TrackTimeRes); + +// extended table with expression columns that can be used as arguments of dynamic columns +DECLARE_SOA_EXTENDED_TABLE_USER(FwdTracksReAlign, StoredFwdTracksReAlign, "FWDTRKREALIGNEXT", //! + fwdtrack::Pt, + fwdtrack::Eta, + fwdtrack::P); + +DECLARE_SOA_TABLE_FULL(StoredFwdTrksCovReAlign, "FwdCovsReAlign", "AOD", "FWDCOVREALIGN", + fwdtrack::SigmaX, fwdtrack::SigmaY, fwdtrack::SigmaPhi, fwdtrack::SigmaTgl, fwdtrack::Sigma1Pt, + fwdtrack::RhoXY, fwdtrack::RhoPhiY, fwdtrack::RhoPhiX, fwdtrack::RhoTglX, fwdtrack::RhoTglY, + fwdtrack::RhoTglPhi, fwdtrack::Rho1PtX, fwdtrack::Rho1PtY, fwdtrack::Rho1PtPhi, fwdtrack::Rho1PtTgl); + +// extended table with expression columns that can be used as arguments of dynamic columns +DECLARE_SOA_EXTENDED_TABLE_USER(FwdTrksCovReAlign, StoredFwdTrksCovReAlign, "FWDCOVREALIGNEXT", //! + fwdtrack::CXX, + fwdtrack::CXY, + fwdtrack::CYY, + fwdtrack::CPhiX, + fwdtrack::CPhiY, + fwdtrack::CPhiPhi, + fwdtrack::CTglX, + fwdtrack::CTglY, + fwdtrack::CTglPhi, + fwdtrack::CTglTgl, + fwdtrack::C1PtX, + fwdtrack::C1PtY, + fwdtrack::C1PtPhi, + fwdtrack::C1PtTgl, + fwdtrack::C1Pt21Pt2); + +using FwdTrackRealign = FwdTracksReAlign::iterator; +using FwdTrkCovRealign = FwdTrksCovReAlign::iterator; +using FullFwdTracksRealign = soa::Join; +using FullFwdTrackRealign = FullFwdTracksRealign::iterator; +} // namespace o2::aod + +#endif // COMMON_DATAMODEL_FWDTRACKREALIGNTABLES_H_ diff --git a/Common/DataModel/Multiplicity.h b/Common/DataModel/Multiplicity.h index ce6aa4ba046..d2db60732f2 100644 --- a/Common/DataModel/Multiplicity.h +++ b/Common/DataModel/Multiplicity.h @@ -8,6 +8,11 @@ // 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. + +/// \file Multiplicity.h +/// \brief multiplicity tables +/// \author ALICE + #ifndef COMMON_DATAMODEL_MULTIPLICITY_H_ #define COMMON_DATAMODEL_MULTIPLICITY_H_ @@ -120,6 +125,7 @@ DECLARE_SOA_TABLE(MFTMults, "AOD", "MFTMULT", //! Multiplicity with MFT mult::MFTNalltracks, mult::MFTNtracks); using BarrelMults = soa::Join; using Mults = soa::Join; +using MultsRun3 = soa::Join; using FT0Mult = FT0Mults::iterator; using MFTMult = MFTMults::iterator; using Mult = Mults::iterator; @@ -197,6 +203,12 @@ DECLARE_SOA_INDEX_COLUMN(MultMCExtra, multMCExtra); DECLARE_SOA_TABLE(Mult2MCExtras, "AOD", "Mult2MCEXTRA", //! Relate reco mult entry to MC extras entry o2::soa::Index<>, mult::MultMCExtraId); +DECLARE_SOA_TABLE(MultHepMCHIs, "AOD", "MULTHEPMCHI", //! complementary table for heavy-ion mc info (subset of HepMCHeavyIons) + o2::soa::Index<>, mult::MultMCExtraId, hepmcheavyion::NcollHard, hepmcheavyion::NpartProj, hepmcheavyion::NpartTarg, + hepmcheavyion::Ncoll, hepmcheavyion::ImpactParameter); + +using MultHepMCHI = MultHepMCHIs::iterator; + namespace multZeq { DECLARE_SOA_COLUMN(MultZeqFV0A, multZeqFV0A, float); //! Multiplicity equalized for the vertex position with the FV0A detector diff --git a/Common/DataModel/OccupancyTables.h b/Common/DataModel/OccupancyTables.h new file mode 100644 index 00000000000..9e14fd8f4f2 --- /dev/null +++ b/Common/DataModel/OccupancyTables.h @@ -0,0 +1,399 @@ +// 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. + +/// \file OccupancyTables.h +/// \brief Occupancy Table Header : TPC PID - Calibration +/// +/// \author Rahul Verma (rahul.verma@iitb.ac.in) :: Marian I Ivanov (marian.ivanov@cern.ch) + +#include + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" + +#ifndef COMMON_DATAMODEL_OCCUPANCYTABLES_H_ +#define COMMON_DATAMODEL_OCCUPANCYTABLES_H_ + +namespace o2::aod +{ +namespace occp +{ +DECLARE_SOA_COLUMN(TfId, tfId, int64_t); +DECLARE_SOA_COLUMN(BcsInTFList, bcsInTFList, std::vector); + +DECLARE_SOA_COLUMN(OccPrimUnfm80, occPrimUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccFV0AUnfm80, occFV0AUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccFV0CUnfm80, occFV0CUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccFT0AUnfm80, occFT0AUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccFT0CUnfm80, occFT0CUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccFDDAUnfm80, occFDDAUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccFDDCUnfm80, occFDDCUnfm80, std::vector); + +DECLARE_SOA_COLUMN(OccNTrackITSUnfm80, occNTrackITSUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccNTrackTPCUnfm80, occNTrackTPCUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccNTrackTRDUnfm80, occNTrackTRDUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccNTrackTOFUnfm80, occNTrackTOFUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccNTrackSizeUnfm80, occNTrackSizeUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccNTrackTPCAUnfm80, occNTrackTPCAUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccNTrackTPCCUnfm80, occNTrackTPCCUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccNTrackITSTPCUnfm80, occNTrackITSTPCUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccNTrackITSTPCAUnfm80, occNTrackITSTPCAUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccNTrackITSTPCCUnfm80, occNTrackITSTPCCUnfm80, std::vector); + +DECLARE_SOA_COLUMN(OccMultNTracksHasITSUnfm80, occMultNTracksHasITSUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccMultNTracksHasTPCUnfm80, occMultNTracksHasTPCUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccMultNTracksHasTOFUnfm80, occMultNTracksHasTOFUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccMultNTracksHasTRDUnfm80, occMultNTracksHasTRDUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccMultNTracksITSOnlyUnfm80, occMultNTracksITSOnlyUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccMultNTracksTPCOnlyUnfm80, occMultNTracksTPCOnlyUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccMultNTracksITSTPCUnfm80, occMultNTracksITSTPCUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccMultAllTracksTPCOnlyUnfm80, occMultAllTracksTPCOnlyUnfm80, std::vector); + +DECLARE_SOA_COLUMN(OccRobustT0V0PrimUnfm80, occRobustT0V0PrimUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccRobustFDDT0V0PrimUnfm80, occRobustFDDT0V0PrimUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccRobustNtrackDetUnfm80, occRobustNtrackDetUnfm80, std::vector); +DECLARE_SOA_COLUMN(OccRobustMultExtraTableUnfm80, occRobustMultExtraTableUnfm80, std::vector); + +DECLARE_SOA_COLUMN(MeanOccPrimUnfm80, meanOccPrimUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccFV0AUnfm80, meanOccFV0AUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccFV0CUnfm80, meanOccFV0CUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccFT0AUnfm80, meanOccFT0AUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccFT0CUnfm80, meanOccFT0CUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccFDDAUnfm80, meanOccFDDAUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccFDDCUnfm80, meanOccFDDCUnfm80, float); + +DECLARE_SOA_COLUMN(MeanOccNTrackITSUnfm80, meanOccNTrackITSUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccNTrackTPCUnfm80, meanOccNTrackTPCUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccNTrackTRDUnfm80, meanOccNTrackTRDUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccNTrackTOFUnfm80, meanOccNTrackTOFUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccNTrackSizeUnfm80, meanOccNTrackSizeUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccNTrackTPCAUnfm80, meanOccNTrackTPCAUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccNTrackTPCCUnfm80, meanOccNTrackTPCCUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccNTrackITSTPCUnfm80, meanOccNTrackITSTPCUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccNTrackITSTPCAUnfm80, meanOccNTrackITSTPCAUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccNTrackITSTPCCUnfm80, meanOccNTrackITSTPCCUnfm80, float); + +DECLARE_SOA_COLUMN(MeanOccMultNTracksHasITSUnfm80, meanOccMultNTracksHasITSUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccMultNTracksHasTPCUnfm80, meanOccMultNTracksHasTPCUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccMultNTracksHasTOFUnfm80, meanOccMultNTracksHasTOFUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccMultNTracksHasTRDUnfm80, meanOccMultNTracksHasTRDUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccMultNTracksITSOnlyUnfm80, meanOccMultNTracksITSOnlyUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccMultNTracksTPCOnlyUnfm80, meanOccMultNTracksTPCOnlyUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccMultNTracksITSTPCUnfm80, meanOccMultNTracksITSTPCUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccMultAllTracksTPCOnlyUnfm80, meanOccMultAllTracksTPCOnlyUnfm80, float); + +DECLARE_SOA_COLUMN(MeanOccRobustT0V0PrimUnfm80, meanOccRobustT0V0PrimUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccRobustFDDT0V0PrimUnfm80, meanOccRobustFDDT0V0PrimUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccRobustNtrackDetUnfm80, meanOccRobustNtrackDetUnfm80, float); +DECLARE_SOA_COLUMN(MeanOccRobustMultExtraTableUnfm80, meanOccRobustMultExtraTableUnfm80, float); +} // namespace occp + +DECLARE_SOA_TABLE(OccsBCsList, "AOD", "OCCSBCSLIST", o2::soa::Index<>, o2::aod::occp::TfId, o2::aod::occp::BcsInTFList); +// 1 +DECLARE_SOA_TABLE(OccsPrim, "AOD", "OCCSPRIM", o2::soa::Index<>, + o2::aod::occp::OccPrimUnfm80); +DECLARE_SOA_TABLE(OccsMeanPrim, "AOD", "OCCSMEANPRIM", o2::soa::Index<>, + o2::aod::occp::MeanOccPrimUnfm80); +// 2 +DECLARE_SOA_TABLE(OccsT0V0, "AOD", "OCCST0V0", o2::soa::Index<>, + o2::aod::occp::OccFV0AUnfm80, + o2::aod::occp::OccFV0CUnfm80, + o2::aod::occp::OccFT0AUnfm80, + o2::aod::occp::OccFT0CUnfm80); +DECLARE_SOA_TABLE(OccsMeanT0V0, "AOD", "OCCSMEANT0V0", o2::soa::Index<>, + o2::aod::occp::MeanOccFV0AUnfm80, + o2::aod::occp::MeanOccFV0CUnfm80, + o2::aod::occp::MeanOccFT0AUnfm80, + o2::aod::occp::MeanOccFT0CUnfm80); +// 3 +DECLARE_SOA_TABLE(OccsFDD, "AOD", "OCCSFDD", o2::soa::Index<>, + o2::aod::occp::OccFDDAUnfm80, + o2::aod::occp::OccFDDCUnfm80); +DECLARE_SOA_TABLE(OccsMeanFDD, "AOD", "OCCSMEANFDD", o2::soa::Index<>, + o2::aod::occp::MeanOccFDDAUnfm80, + o2::aod::occp::MeanOccFDDCUnfm80); +// 4 +DECLARE_SOA_TABLE(OccsNTrackDet, "AOD", "OCCSNTRACKDET", o2::soa::Index<>, + o2::aod::occp::OccNTrackITSUnfm80, + o2::aod::occp::OccNTrackTPCUnfm80, + o2::aod::occp::OccNTrackTRDUnfm80, + o2::aod::occp::OccNTrackTOFUnfm80, + o2::aod::occp::OccNTrackSizeUnfm80, + o2::aod::occp::OccNTrackTPCAUnfm80, + o2::aod::occp::OccNTrackTPCCUnfm80, + o2::aod::occp::OccNTrackITSTPCUnfm80, + o2::aod::occp::OccNTrackITSTPCAUnfm80, + o2::aod::occp::OccNTrackITSTPCCUnfm80); +DECLARE_SOA_TABLE(OccsMeanNTrkDet, "AOD", "OCCSMEANNTRKDET", o2::soa::Index<>, + o2::aod::occp::MeanOccNTrackITSUnfm80, + o2::aod::occp::MeanOccNTrackTPCUnfm80, + o2::aod::occp::MeanOccNTrackTRDUnfm80, + o2::aod::occp::MeanOccNTrackTOFUnfm80, + o2::aod::occp::MeanOccNTrackSizeUnfm80, + o2::aod::occp::MeanOccNTrackTPCAUnfm80, + o2::aod::occp::MeanOccNTrackTPCCUnfm80, + o2::aod::occp::MeanOccNTrackITSTPCUnfm80, + o2::aod::occp::MeanOccNTrackITSTPCAUnfm80, + o2::aod::occp::MeanOccNTrackITSTPCCUnfm80); +// 5 +DECLARE_SOA_TABLE(OccsMultExtra, "AOD", "OCCSMULTEXTRA", o2::soa::Index<>, + o2::aod::occp::OccMultNTracksHasITSUnfm80, + o2::aod::occp::OccMultNTracksHasTPCUnfm80, + o2::aod::occp::OccMultNTracksHasTOFUnfm80, + o2::aod::occp::OccMultNTracksHasTRDUnfm80, + o2::aod::occp::OccMultNTracksITSOnlyUnfm80, + o2::aod::occp::OccMultNTracksTPCOnlyUnfm80, + o2::aod::occp::OccMultNTracksITSTPCUnfm80, + o2::aod::occp::OccMultAllTracksTPCOnlyUnfm80); +DECLARE_SOA_TABLE(OccsMnMultExtra, "AOD", "OCCSMNMULTEXTRA", o2::soa::Index<>, + o2::aod::occp::MeanOccMultNTracksHasITSUnfm80, + o2::aod::occp::MeanOccMultNTracksHasTPCUnfm80, + o2::aod::occp::MeanOccMultNTracksHasTOFUnfm80, + o2::aod::occp::MeanOccMultNTracksHasTRDUnfm80, + o2::aod::occp::MeanOccMultNTracksITSOnlyUnfm80, + o2::aod::occp::MeanOccMultNTracksTPCOnlyUnfm80, + o2::aod::occp::MeanOccMultNTracksITSTPCUnfm80, + o2::aod::occp::MeanOccMultAllTracksTPCOnlyUnfm80); + +// Robust Occupancies +// 1 +DECLARE_SOA_TABLE(ORT0V0Prim, "AOD", "ORT0V0Prim", o2::soa::Index<>, + o2::aod::occp::OccRobustT0V0PrimUnfm80); +DECLARE_SOA_TABLE(OMRT0V0Prim, "AOD", "OMRT0V0PRIM", o2::soa::Index<>, + o2::aod::occp::MeanOccRobustT0V0PrimUnfm80); +// 2 +DECLARE_SOA_TABLE(ORFDDT0V0Prim, "AOD", "ORFDDT0V0PRIM", o2::soa::Index<>, + o2::aod::occp::OccRobustFDDT0V0PrimUnfm80); +DECLARE_SOA_TABLE(OMRFDDT0V0Prim, "AOD", "OMRFDDT0V0PRIM", o2::soa::Index<>, + o2::aod::occp::MeanOccRobustFDDT0V0PrimUnfm80); +// 3 +DECLARE_SOA_TABLE(ORNtrackDet, "AOD", "ORNTRACKDET", o2::soa::Index<>, + o2::aod::occp::OccRobustNtrackDetUnfm80); +DECLARE_SOA_TABLE(OMRNtrackDet, "AOD", "OMRNTRACKDET", o2::soa::Index<>, + o2::aod::occp::MeanOccRobustNtrackDetUnfm80); +// 4 +DECLARE_SOA_TABLE(ORMultExtra, "AOD", "ORMULTEXTRA", o2::soa::Index<>, + o2::aod::occp::OccRobustMultExtraTableUnfm80); +DECLARE_SOA_TABLE(OMRMultExtra, "AOD", "OMRMULTEXTRA", o2::soa::Index<>, + o2::aod::occp::MeanOccRobustMultExtraTableUnfm80); + +using Occs = aod::OccsBCsList; +using Occ = Occs::iterator; + +namespace occidx +{ +DECLARE_SOA_INDEX_COLUMN(BC, bc); // o2-linter: disable=name/o2-column (BC is an acronym already defined in data model) // Iterator is passed here in index column +DECLARE_SOA_INDEX_COLUMN(Occ, occ); +DECLARE_SOA_COLUMN(TfId, tfId, int); +DECLARE_SOA_COLUMN(BcInTF, bcInTF, int); +} // namespace occidx + +// DECLARE_SOA_TABLE(OccIndexTable, "AOD", "OCCINDEXTABLE", o2::soa::Index<>, +DECLARE_SOA_INDEX_TABLE_USER(OccIndexTable, Occs, "OCCINDEXTABLE", + o2::aod::occidx::BCId, + o2::aod::occidx::OccId); + +DECLARE_SOA_TABLE(BCTFinfoTable, "AOD", "BCTFINFOTABLE", o2::soa::Index<>, + o2::aod::occidx::TfId, + o2::aod::occidx::BcInTF); + +namespace trackmeanocc +{ +DECLARE_SOA_INDEX_COLUMN(Track, track); + +// DECLARE_SOA_INDEX_COLUMN(TracksQA, tracksQA);// this is not working + +DECLARE_SOA_COLUMN(TmoPrimUnfm80, tmoPrimUnfm80, float); +DECLARE_SOA_COLUMN(TmoFV0AUnfm80, tmoFV0AUnfm80, float); +DECLARE_SOA_COLUMN(TmoFV0CUnfm80, tmoFV0CUnfm80, float); +DECLARE_SOA_COLUMN(TmoFT0AUnfm80, tmoFT0AUnfm80, float); +DECLARE_SOA_COLUMN(TmoFT0CUnfm80, tmoFT0CUnfm80, float); +DECLARE_SOA_COLUMN(TmoFDDAUnfm80, tmoFDDAUnfm80, float); +DECLARE_SOA_COLUMN(TmoFDDCUnfm80, tmoFDDCUnfm80, float); + +DECLARE_SOA_COLUMN(TmoNTrackITSUnfm80, tmoNTrackITSUnfm80, float); +DECLARE_SOA_COLUMN(TmoNTrackTPCUnfm80, tmoNTrackTPCUnfm80, float); +DECLARE_SOA_COLUMN(TmoNTrackTRDUnfm80, tmoNTrackTRDUnfm80, float); +DECLARE_SOA_COLUMN(TmoNTrackTOFUnfm80, tmoNTrackTOFUnfm80, float); +DECLARE_SOA_COLUMN(TmoNTrackSizeUnfm80, tmoNTrackSizeUnfm80, float); +DECLARE_SOA_COLUMN(TmoNTrackTPCAUnfm80, tmoNTrackTPCAUnfm80, float); +DECLARE_SOA_COLUMN(TmoNTrackTPCCUnfm80, tmoNTrackTPCCUnfm80, float); +DECLARE_SOA_COLUMN(TmoNTrackITSTPCUnfm80, tmoNTrackITSTPCUnfm80, float); +DECLARE_SOA_COLUMN(TmoNTrackITSTPCAUnfm80, tmoNTrackITSTPCAUnfm80, float); +DECLARE_SOA_COLUMN(TmoNTrackITSTPCCUnfm80, tmoNTrackITSTPCCUnfm80, float); + +DECLARE_SOA_COLUMN(TmoMultNTracksHasITSUnfm80, tmoMultNTracksHasITSUnfm80, float); +DECLARE_SOA_COLUMN(TmoMultNTracksHasTPCUnfm80, tmoMultNTracksHasTPCUnfm80, float); +DECLARE_SOA_COLUMN(TmoMultNTracksHasTOFUnfm80, tmoMultNTracksHasTOFUnfm80, float); +DECLARE_SOA_COLUMN(TmoMultNTracksHasTRDUnfm80, tmoMultNTracksHasTRDUnfm80, float); +DECLARE_SOA_COLUMN(TmoMultNTracksITSOnlyUnfm80, tmoMultNTracksITSOnlyUnfm80, float); +DECLARE_SOA_COLUMN(TmoMultNTracksTPCOnlyUnfm80, tmoMultNTracksTPCOnlyUnfm80, float); +DECLARE_SOA_COLUMN(TmoMultNTracksITSTPCUnfm80, tmoMultNTracksITSTPCUnfm80, float); +DECLARE_SOA_COLUMN(TmoMultAllTracksTPCOnlyUnfm80, tmoMultAllTracksTPCOnlyUnfm80, float); + +DECLARE_SOA_COLUMN(TmoRobustT0V0PrimUnfm80, tmoRobustT0V0PrimUnfm80, float); +DECLARE_SOA_COLUMN(TmoRobustFDDT0V0PrimUnfm80, tmoRobustFDDT0V0PrimUnfm80, float); +DECLARE_SOA_COLUMN(TmoRobustNtrackDetUnfm80, tmoRobustNtrackDetUnfm80, float); +DECLARE_SOA_COLUMN(TmoRobustMultExtraTableUnfm80, tmoRobustMultExtraTableUnfm80, float); + +DECLARE_SOA_COLUMN(TwmoPrimUnfm80, twmoPrimUnfm80, float); +DECLARE_SOA_COLUMN(TwmoFV0AUnfm80, twmoFV0AUnfm80, float); +DECLARE_SOA_COLUMN(TwmoFV0CUnfm80, twmoFV0CUnfm80, float); +DECLARE_SOA_COLUMN(TwmoFT0AUnfm80, twmoFT0AUnfm80, float); +DECLARE_SOA_COLUMN(TwmoFT0CUnfm80, twmoFT0CUnfm80, float); +DECLARE_SOA_COLUMN(TwmoFDDAUnfm80, twmoFDDAUnfm80, float); +DECLARE_SOA_COLUMN(TwmoFDDCUnfm80, twmoFDDCUnfm80, float); + +DECLARE_SOA_COLUMN(TwmoNTrackITSUnfm80, twmoNTrackITSUnfm80, float); +DECLARE_SOA_COLUMN(TwmoNTrackTPCUnfm80, twmoNTrackTPCUnfm80, float); +DECLARE_SOA_COLUMN(TwmoNTrackTRDUnfm80, twmoNTrackTRDUnfm80, float); +DECLARE_SOA_COLUMN(TwmoNTrackTOFUnfm80, twmoNTrackTOFUnfm80, float); +DECLARE_SOA_COLUMN(TwmoNTrackSizeUnfm80, twmoNTrackSizeUnfm80, float); +DECLARE_SOA_COLUMN(TwmoNTrackTPCAUnfm80, twmoNTrackTPCAUnfm80, float); +DECLARE_SOA_COLUMN(TwmoNTrackTPCCUnfm80, twmoNTrackTPCCUnfm80, float); +DECLARE_SOA_COLUMN(TwmoNTrackITSTPCUnfm80, twmoNTrackITSTPCUnfm80, float); +DECLARE_SOA_COLUMN(TwmoNTrackITSTPCAUnfm80, twmoNTrackITSTPCAUnfm80, float); +DECLARE_SOA_COLUMN(TwmoNTrackITSTPCCUnfm80, twmoNTrackITSTPCCUnfm80, float); + +DECLARE_SOA_COLUMN(TwmoMultNTracksHasITSUnfm80, twmoMultNTracksHasITSUnfm80, float); +DECLARE_SOA_COLUMN(TwmoMultNTracksHasTPCUnfm80, twmoMultNTracksHasTPCUnfm80, float); +DECLARE_SOA_COLUMN(TwmoMultNTracksHasTOFUnfm80, twmoMultNTracksHasTOFUnfm80, float); +DECLARE_SOA_COLUMN(TwmoMultNTracksHasTRDUnfm80, twmoMultNTracksHasTRDUnfm80, float); +DECLARE_SOA_COLUMN(TwmoMultNTracksITSOnlyUnfm80, twmoMultNTracksITSOnlyUnfm80, float); +DECLARE_SOA_COLUMN(TwmoMultNTracksTPCOnlyUnfm80, twmoMultNTracksTPCOnlyUnfm80, float); +DECLARE_SOA_COLUMN(TwmoMultNTracksITSTPCUnfm80, twmoMultNTracksITSTPCUnfm80, float); +DECLARE_SOA_COLUMN(TwmoMultAllTracksTPCOnlyUnfm80, twmoMultAllTracksTPCOnlyUnfm80, float); + +DECLARE_SOA_COLUMN(TwmoRobustT0V0PrimUnfm80, twmoRobustT0V0PrimUnfm80, float); +DECLARE_SOA_COLUMN(TwmoRobustFDDT0V0PrimUnfm80, twmoRobustFDDT0V0PrimUnfm80, float); +DECLARE_SOA_COLUMN(TwmoRobustNtrackDetUnfm80, twmoRobustNtrackDetUnfm80, float); +DECLARE_SOA_COLUMN(TwmoRobustMultExtraTableUnfm80, twmoRobustMultExtraTableUnfm80, float); + +} // namespace trackmeanocc + +// Tracks +// using Tracks = aod::Tracks; +// DECLARE_SOA_INDEX_TABLE_USER(TrackMeanOccs0, Tracks, "TRACKMEANOCCS0", o2::aod::trackmeanocc::TrackId); + +DECLARE_SOA_TABLE(TmoTrackIds, "AOD", "TMOTRACKIDS", o2::aod::trackmeanocc::TrackId); + +DECLARE_SOA_TABLE(TmoPrim, "AOD", "TMOPRIM", o2::soa::Index<>, // TrackMeanOccDet + o2::aod::trackmeanocc::TmoPrimUnfm80); + +DECLARE_SOA_TABLE(TmoT0V0, "AOD", "TMOT0V0", o2::soa::Index<>, // TrackMeanOccDet + o2::aod::trackmeanocc::TmoFV0AUnfm80, + o2::aod::trackmeanocc::TmoFV0CUnfm80, + o2::aod::trackmeanocc::TmoFT0AUnfm80, + o2::aod::trackmeanocc::TmoFT0CUnfm80); + +DECLARE_SOA_TABLE(TmoFDD, "AOD", "TMOFDD", o2::soa::Index<>, // TrackMeanOccDet + o2::aod::trackmeanocc::TmoFDDAUnfm80, + o2::aod::trackmeanocc::TmoFDDCUnfm80); + +DECLARE_SOA_TABLE(TmoNTrackDet, "AOD", "TMONTRACKDET", o2::soa::Index<>, // TrackMeanOccNtrackDet + o2::aod::trackmeanocc::TmoNTrackITSUnfm80, + o2::aod::trackmeanocc::TmoNTrackTPCUnfm80, + o2::aod::trackmeanocc::TmoNTrackTRDUnfm80, + o2::aod::trackmeanocc::TmoNTrackTOFUnfm80, + o2::aod::trackmeanocc::TmoNTrackSizeUnfm80, + o2::aod::trackmeanocc::TmoNTrackTPCAUnfm80, + o2::aod::trackmeanocc::TmoNTrackTPCCUnfm80, + o2::aod::trackmeanocc::TmoNTrackITSTPCUnfm80, + o2::aod::trackmeanocc::TmoNTrackITSTPCAUnfm80, + o2::aod::trackmeanocc::TmoNTrackITSTPCCUnfm80); + +DECLARE_SOA_TABLE(TmoMultExtra, "AOD", "TMOMULTEXTRA", o2::soa::Index<>, // TrackMeanOccMultExtra + o2::aod::trackmeanocc::TmoMultNTracksHasITSUnfm80, + o2::aod::trackmeanocc::TmoMultNTracksHasTPCUnfm80, + o2::aod::trackmeanocc::TmoMultNTracksHasTOFUnfm80, + o2::aod::trackmeanocc::TmoMultNTracksHasTRDUnfm80, + o2::aod::trackmeanocc::TmoMultNTracksITSOnlyUnfm80, + o2::aod::trackmeanocc::TmoMultNTracksTPCOnlyUnfm80, + o2::aod::trackmeanocc::TmoMultNTracksITSTPCUnfm80, + o2::aod::trackmeanocc::TmoMultAllTracksTPCOnlyUnfm80); + +DECLARE_SOA_TABLE(TmoRT0V0Prim, "AOD", "TMORT0V0PRIM", o2::soa::Index<>, + o2::aod::trackmeanocc::TmoRobustT0V0PrimUnfm80); + +DECLARE_SOA_TABLE(TmoRFDDT0V0Prim, "AOD", "TMORFDDT0V0PRIM", o2::soa::Index<>, + o2::aod::trackmeanocc::TmoRobustFDDT0V0PrimUnfm80); + +DECLARE_SOA_TABLE(TmoRNtrackDet, "AOD", "TMORNTRACKDET", o2::soa::Index<>, + o2::aod::trackmeanocc::TmoRobustNtrackDetUnfm80); + +DECLARE_SOA_TABLE(TmoRMultExtra, "AOD", "TMORMULTEXTRA", o2::soa::Index<>, + o2::aod::trackmeanocc::TmoRobustMultExtraTableUnfm80); + +DECLARE_SOA_TABLE(TwmoPrim, "AOD", "TWMOPRIM", o2::soa::Index<>, // WeightTrackMeanOcc + o2::aod::trackmeanocc::TwmoPrimUnfm80); + +DECLARE_SOA_TABLE(TwmoT0V0, "AOD", "TWMOT0V0", o2::soa::Index<>, // WeightTrackMeanOccDet + o2::aod::trackmeanocc::TwmoFV0AUnfm80, + o2::aod::trackmeanocc::TwmoFV0CUnfm80, + o2::aod::trackmeanocc::TwmoFT0AUnfm80, + o2::aod::trackmeanocc::TwmoFT0CUnfm80); + +DECLARE_SOA_TABLE(TwmoFDD, "AOD", "TWMOFDD", o2::soa::Index<>, // WeightTrackMeanOccDet + o2::aod::trackmeanocc::TwmoFDDAUnfm80, + o2::aod::trackmeanocc::TwmoFDDCUnfm80); + +DECLARE_SOA_TABLE(TwmoNTrackDet, "AOD", "TWMONTRACKDET", o2::soa::Index<>, // WeightTrackMeanOccTrackMult + o2::aod::trackmeanocc::TwmoNTrackITSUnfm80, + o2::aod::trackmeanocc::TwmoNTrackTPCUnfm80, + o2::aod::trackmeanocc::TwmoNTrackTRDUnfm80, + o2::aod::trackmeanocc::TwmoNTrackTOFUnfm80, + o2::aod::trackmeanocc::TwmoNTrackSizeUnfm80, + o2::aod::trackmeanocc::TwmoNTrackTPCAUnfm80, + o2::aod::trackmeanocc::TwmoNTrackTPCCUnfm80, + o2::aod::trackmeanocc::TwmoNTrackITSTPCUnfm80, + o2::aod::trackmeanocc::TwmoNTrackITSTPCAUnfm80, + o2::aod::trackmeanocc::TwmoNTrackITSTPCCUnfm80); + +DECLARE_SOA_TABLE(TwmoMultExtra, "AOD", "TWMOMULTEXTRA", o2::soa::Index<>, // WeightTrackMeanOccMultExtra + o2::aod::trackmeanocc::TwmoMultNTracksHasITSUnfm80, + o2::aod::trackmeanocc::TwmoMultNTracksHasTPCUnfm80, + o2::aod::trackmeanocc::TwmoMultNTracksHasTOFUnfm80, + o2::aod::trackmeanocc::TwmoMultNTracksHasTRDUnfm80, + o2::aod::trackmeanocc::TwmoMultNTracksITSOnlyUnfm80, + o2::aod::trackmeanocc::TwmoMultNTracksTPCOnlyUnfm80, + o2::aod::trackmeanocc::TwmoMultNTracksITSTPCUnfm80, + o2::aod::trackmeanocc::TwmoMultAllTracksTPCOnlyUnfm80); + +DECLARE_SOA_TABLE(TwmoRT0V0Prim, "AOD", "TWMORT0V0PRIM", o2::soa::Index<>, + o2::aod::trackmeanocc::TwmoRobustT0V0PrimUnfm80); + +DECLARE_SOA_TABLE(TwmoRFDDT0V0Pri, "AOD", "TWMORFDDT0V0PRI", o2::soa::Index<>, + o2::aod::trackmeanocc::TwmoRobustFDDT0V0PrimUnfm80); + +DECLARE_SOA_TABLE(TwmoRNtrackDet, "AOD", "TWMORNTRACKDET", o2::soa::Index<>, + o2::aod::trackmeanocc::TwmoRobustNtrackDetUnfm80); + +DECLARE_SOA_TABLE(TwmoRMultExtra, "AOD", "TWMORMULTEXTRA", o2::soa::Index<>, + o2::aod::trackmeanocc::TwmoRobustMultExtraTableUnfm80); + +using Tmo = aod::TmoTrackIds::iterator; + +using TrackQA = TracksQAVersion::iterator; + +namespace trackmeanocc +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Tmo, tmo, int64_t, TmoTrackIds, ""); +DECLARE_SOA_INDEX_COLUMN_FULL(TrackQA, trackQA, int64_t, TracksQAVersion, ""); +} // namespace trackmeanocc + +DECLARE_SOA_TABLE(TrackToTracksQA, "AOD", "TRACKTOTRACKSQA", o2::aod::trackmeanocc::TrackQAId); +DECLARE_SOA_TABLE(TrackToTmo, "AOD", "TRACKTOTMO", o2::aod::trackmeanocc::TmoId); + +DECLARE_SOA_TABLE(TrackQAToTmo, "AOD", "TRACKQATOTMO", o2::aod::trackmeanocc::TmoId); +DECLARE_SOA_TABLE(TmoToTrackQA, "AOD", "TMOTOTRACKQA", o2::aod::trackmeanocc::TrackQAId); + +} // namespace o2::aod +#endif // COMMON_DATAMODEL_OCCUPANCYTABLES_H_ diff --git a/Common/DataModel/PIDResponse.h b/Common/DataModel/PIDResponse.h index 90eb0e55112..eee2e4df2e3 100644 --- a/Common/DataModel/PIDResponse.h +++ b/Common/DataModel/PIDResponse.h @@ -13,802 +13,34 @@ /// \file PIDResponse.h /// \author Nicolò Jacazio nicolo.jacazio@cern.ch /// \brief Set of tables, tasks and utilities to provide the interface between -/// the analysis data model and the PID response +/// the analysis data model and the PID response. This is interim. To be removed /// #ifndef COMMON_DATAMODEL_PIDRESPONSE_H_ #define COMMON_DATAMODEL_PIDRESPONSE_H_ -#include - -// O2 includes -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "ReconstructionDataFormats/PID.h" -#include "Framework/Logger.h" +#include "PIDResponseTOF.h" +#include "PIDResponseTPC.h" +#include "PIDResponseCombined.h" namespace o2::aod { namespace pidutils { -// Function to pack a float into a binned value in table +// Function to pack a float into a binned value in table (interim solution) template void packInTable(const float& valueToBin, T& table) { - if (valueToBin <= binningType::binned_min) { - table(binningType::underflowBin); - } else if (valueToBin >= binningType::binned_max) { - table(binningType::overflowBin); - } else if (valueToBin >= 0) { - table(static_cast((valueToBin / binningType::bin_width) + 0.5f)); - } else { - table(static_cast((valueToBin / binningType::bin_width) - 0.5f)); - } + binningType::packInTable(valueToBin, table); } // Function to unpack a binned value into a float template float unPackInTable(const typename binningType::binned_t& valueToUnpack) { - return binningType::bin_width * static_cast(valueToUnpack); -} - -// Checkers for TOF PID hypothesis availability (runtime) -template -using hasTOFEl = decltype(std::declval().tofNSigmaEl()); -template -using hasTOFMu = decltype(std::declval().tofNSigmaMu()); -template -using hasTOFPi = decltype(std::declval().tofNSigmaPi()); -template -using hasTOFKa = decltype(std::declval().tofNSigmaKa()); -template -using hasTOFPr = decltype(std::declval().tofNSigmaPr()); -template -using hasTOFDe = decltype(std::declval().tofNSigmaDe()); -template -using hasTOFTr = decltype(std::declval().tofNSigmaTr()); -template -using hasTOFHe = decltype(std::declval().tofNSigmaHe()); -template -using hasTOFAl = decltype(std::declval().tofNSigmaAl()); - -// Checkers for TPC PID hypothesis availability (runtime) -template -using hasTPCEl = decltype(std::declval().tpcNSigmaEl()); -template -using hasTPCMu = decltype(std::declval().tpcNSigmaMu()); -template -using hasTPCPi = decltype(std::declval().tpcNSigmaPi()); -template -using hasTPCKa = decltype(std::declval().tpcNSigmaKa()); -template -using hasTPCPr = decltype(std::declval().tpcNSigmaPr()); -template -using hasTPCDe = decltype(std::declval().tpcNSigmaDe()); -template -using hasTPCTr = decltype(std::declval().tpcNSigmaTr()); -template -using hasTPCHe = decltype(std::declval().tpcNSigmaHe()); -template -using hasTPCAl = decltype(std::declval().tpcNSigmaAl()); - -// PID index as template argument -#define PER_SPECIES_WRAPPER(functionName) \ - template \ - auto functionName(const TrackType& track) \ - { \ - if constexpr (index == o2::track::PID::Electron) { \ - return track.functionName##El(); \ - } else if constexpr (index == o2::track::PID::Muon) { \ - return track.functionName##Mu(); \ - } else if constexpr (index == o2::track::PID::Pion) { \ - return track.functionName##Pi(); \ - } else if constexpr (index == o2::track::PID::Kaon) { \ - return track.functionName##Ka(); \ - } else if constexpr (index == o2::track::PID::Proton) { \ - return track.functionName##Pr(); \ - } else if constexpr (index == o2::track::PID::Deuteron) { \ - return track.functionName##De(); \ - } else if constexpr (index == o2::track::PID::Triton) { \ - return track.functionName##Tr(); \ - } else if constexpr (index == o2::track::PID::Helium3) { \ - return track.functionName##He(); \ - } else if constexpr (index == o2::track::PID::Alpha) { \ - return track.functionName##Al(); \ - } \ - } - -PER_SPECIES_WRAPPER(tofNSigma); -PER_SPECIES_WRAPPER(tofExpSigma); -template -auto tofExpSignal(const TrackType& track) -{ - if constexpr (index == o2::track::PID::Electron) { - return track.tofExpSignalEl(track.tofSignal()); - } else if constexpr (index == o2::track::PID::Muon) { - return track.tofExpSignalMu(track.tofSignal()); - } else if constexpr (index == o2::track::PID::Pion) { - return track.tofExpSignalPi(track.tofSignal()); - } else if constexpr (index == o2::track::PID::Kaon) { - return track.tofExpSignalKa(track.tofSignal()); - } else if constexpr (index == o2::track::PID::Proton) { - return track.tofExpSignalPr(track.tofSignal()); - } else if constexpr (index == o2::track::PID::Deuteron) { - return track.tofExpSignalDe(track.tofSignal()); - } else if constexpr (index == o2::track::PID::Triton) { - return track.tofExpSignalTr(track.tofSignal()); - } else if constexpr (index == o2::track::PID::Helium3) { - return track.tofExpSignalHe(track.tofSignal()); - } else if constexpr (index == o2::track::PID::Alpha) { - return track.tofExpSignalAl(track.tofSignal()); - } -} -PER_SPECIES_WRAPPER(tofExpSignalDiff); - -PER_SPECIES_WRAPPER(tpcNSigma); -PER_SPECIES_WRAPPER(tpcExpSigma); -template -auto tpcExpSignal(const TrackType& track) -{ - if constexpr (index == o2::track::PID::Electron) { - return track.tpcExpSignalEl(track.tpcSignal()); - } else if constexpr (index == o2::track::PID::Muon) { - return track.tpcExpSignalMu(track.tpcSignal()); - } else if constexpr (index == o2::track::PID::Pion) { - return track.tpcExpSignalPi(track.tpcSignal()); - } else if constexpr (index == o2::track::PID::Kaon) { - return track.tpcExpSignalKa(track.tpcSignal()); - } else if constexpr (index == o2::track::PID::Proton) { - return track.tpcExpSignalPr(track.tpcSignal()); - } else if constexpr (index == o2::track::PID::Deuteron) { - return track.tpcExpSignalDe(track.tpcSignal()); - } else if constexpr (index == o2::track::PID::Triton) { - return track.tpcExpSignalTr(track.tpcSignal()); - } else if constexpr (index == o2::track::PID::Helium3) { - return track.tpcExpSignalHe(track.tpcSignal()); - } else if constexpr (index == o2::track::PID::Alpha) { - return track.tpcExpSignalAl(track.tpcSignal()); - } -} -PER_SPECIES_WRAPPER(tpcExpSignalDiff); - -#undef PER_SPECIES_WRAPPER - -// PID index as function argument for TOF -#define PER_SPECIES_WRAPPER(functionName) \ - template \ - auto functionName(const o2::track::PID::ID index, const TrackType& track) \ - { \ - switch (index) { \ - case o2::track::PID::Electron: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##El(); \ - } \ - case o2::track::PID::Muon: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Mu(); \ - } \ - case o2::track::PID::Pion: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Pi(); \ - } \ - case o2::track::PID::Kaon: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Ka(); \ - } \ - case o2::track::PID::Proton: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Pr(); \ - } \ - case o2::track::PID::Deuteron: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##De(); \ - } \ - case o2::track::PID::Triton: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Tr(); \ - } \ - case o2::track::PID::Helium3: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##He(); \ - } \ - case o2::track::PID::Alpha: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Al(); \ - } \ - default: \ - LOGF(fatal, "TOF PID table for PID index %i (%s) is not available", index, o2::track::PID::getName(index)); \ - return 0.f; \ - } \ - } - -PER_SPECIES_WRAPPER(tofNSigma); -PER_SPECIES_WRAPPER(tofExpSigma); -template -auto tofExpSignal(const o2::track::PID::ID index, const TrackType& track) -{ - switch (index) { - case o2::track::PID::Electron: - if constexpr (std::experimental::is_detected::value) { - return track.tofExpSignalEl(track.tofSignal()); - } - case o2::track::PID::Muon: - if constexpr (std::experimental::is_detected::value) { - return track.tofExpSignalMu(track.tofSignal()); - } - case o2::track::PID::Pion: - if constexpr (std::experimental::is_detected::value) { - return track.tofExpSignalPi(track.tofSignal()); - } - case o2::track::PID::Kaon: - if constexpr (std::experimental::is_detected::value) { - return track.tofExpSignalKa(track.tofSignal()); - } - case o2::track::PID::Proton: - if constexpr (std::experimental::is_detected::value) { - return track.tofExpSignalPr(track.tofSignal()); - } - case o2::track::PID::Deuteron: - if constexpr (std::experimental::is_detected::value) { - return track.tofExpSignalDe(track.tofSignal()); - } - case o2::track::PID::Triton: - if constexpr (std::experimental::is_detected::value) { - return track.tofExpSignalTr(track.tofSignal()); - } - case o2::track::PID::Helium3: - if constexpr (std::experimental::is_detected::value) { - return track.tofExpSignalHe(track.tofSignal()); - } - case o2::track::PID::Alpha: - if constexpr (std::experimental::is_detected::value) { - return track.tofExpSignalAl(track.tofSignal()); - } - default: - LOGF(fatal, "TOF PID table for PID index %i (%s) is not available", index, o2::track::PID::getName(index)); - return 0.f; - } -} -PER_SPECIES_WRAPPER(tofExpSignalDiff); - -#undef PER_SPECIES_WRAPPER - -// PID index as function argument for TPC -#define PER_SPECIES_WRAPPER(functionName) \ - template \ - auto functionName(const o2::track::PID::ID index, const TrackType& track) \ - { \ - switch (index) { \ - case o2::track::PID::Electron: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##El(); \ - } \ - case o2::track::PID::Muon: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Mu(); \ - } \ - case o2::track::PID::Pion: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Pi(); \ - } \ - case o2::track::PID::Kaon: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Ka(); \ - } \ - case o2::track::PID::Proton: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Pr(); \ - } \ - case o2::track::PID::Deuteron: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##De(); \ - } \ - case o2::track::PID::Triton: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Tr(); \ - } \ - case o2::track::PID::Helium3: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##He(); \ - } \ - case o2::track::PID::Alpha: \ - if constexpr (std::experimental::is_detected::value) { \ - return track.functionName##Al(); \ - } \ - default: \ - LOGF(fatal, "TPC PID table for PID index %i (%s) is not available", index, o2::track::PID::getName(index)); \ - return 0.f; \ - } \ - } - -PER_SPECIES_WRAPPER(tpcNSigma); -PER_SPECIES_WRAPPER(tpcExpSigma); -template -auto tpcExpSignal(const o2::track::PID::ID index, const TrackType& track) -{ - switch (index) { - case o2::track::PID::Electron: - if constexpr (std::experimental::is_detected::value) { - return track.tpcExpSignalEl(track.tpcSignal()); - } - case o2::track::PID::Muon: - if constexpr (std::experimental::is_detected::value) { - return track.tpcExpSignalMu(track.tpcSignal()); - } - case o2::track::PID::Pion: - if constexpr (std::experimental::is_detected::value) { - return track.tpcExpSignalPi(track.tpcSignal()); - } - case o2::track::PID::Kaon: - if constexpr (std::experimental::is_detected::value) { - return track.tpcExpSignalKa(track.tpcSignal()); - } - case o2::track::PID::Proton: - if constexpr (std::experimental::is_detected::value) { - return track.tpcExpSignalPr(track.tpcSignal()); - } - case o2::track::PID::Deuteron: - if constexpr (std::experimental::is_detected::value) { - return track.tpcExpSignalDe(track.tpcSignal()); - } - case o2::track::PID::Triton: - if constexpr (std::experimental::is_detected::value) { - return track.tpcExpSignalTr(track.tpcSignal()); - } - case o2::track::PID::Helium3: - if constexpr (std::experimental::is_detected::value) { - return track.tpcExpSignalHe(track.tpcSignal()); - } - case o2::track::PID::Alpha: - if constexpr (std::experimental::is_detected::value) { - return track.tpcExpSignalAl(track.tpcSignal()); - } - default: - LOGF(fatal, "TPC PID table for PID index %i (%s) is not available", index, o2::track::PID::getName(index)); - return 0.f; - } + return binningType::unPackInTable(valueToUnpack); } -PER_SPECIES_WRAPPER(tpcExpSignalDiff); - -#undef PER_SPECIES_WRAPPER - } // namespace pidutils - -namespace pidflags -{ - -namespace enums -{ -enum PIDFlags : uint8_t { - EvTimeUndef = 0x0, // Event collision not set, corresponding to the LHC Fill event time - EvTimeTOF = 0x1, // Event collision time from TOF - EvTimeT0AC = 0x2, // Event collision time from the FT0AC - EvTimeTOFT0AC = 0x4 // Event collision time from the TOF and FT0AC -}; -} - -DECLARE_SOA_COLUMN(GoodTOFMatch, goodTOFMatch, bool); //! Bool for the TOF PID information on the single track information -DECLARE_SOA_COLUMN(TOFFlags, tofFlags, uint8_t); //! Flag for the complementary TOF PID information for the event time -DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeDefined, isEvTimeDefined, //! True if the Event Time was computed with any method i.e. there is a usable event time - [](uint8_t flags) -> bool { return (flags > 0); }); -DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeTOF, isEvTimeTOF, //! True if the Event Time was computed with the TOF - [](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeTOF) == enums::PIDFlags::EvTimeTOF; }); -DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeT0AC, isEvTimeT0AC, //! True if the Event Time was computed with the T0AC - [](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeT0AC) == enums::PIDFlags::EvTimeT0AC; }); -DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeTOFT0AC, isEvTimeTOFT0AC, //! True if the Event Time was computed with the TOF and T0AC - [](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeTOFT0AC) == enums::PIDFlags::EvTimeTOFT0AC; }); - -} // namespace pidflags - -namespace pidtofsignal -{ -DECLARE_SOA_COLUMN(TOFSignal, tofSignal, float); //! TOF signal from track time -DECLARE_SOA_DYNAMIC_COLUMN(EventCollisionTime, eventCollisionTime, //! Event collision time used for the track. Needs the TOF - [](float signal, float tMinusTexp, float texp) -> float { return texp + tMinusTexp - signal; }); - -} // namespace pidtofsignal - -namespace pidtofevtime -{ -DECLARE_SOA_COLUMN(TOFEvTime, tofEvTime, float); //! event time for TOF signal. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C -DECLARE_SOA_COLUMN(TOFEvTimeErr, tofEvTimeErr, float); //! event time error for TOF. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C -} // namespace pidtofevtime - -namespace pidtofbeta -{ -DECLARE_SOA_COLUMN(Beta, beta, float); //! TOF beta -DECLARE_SOA_COLUMN(BetaError, betaerror, float); //! Uncertainty on the TOF beta -// -DECLARE_SOA_COLUMN(ExpBetaEl, expbetael, float); //! Expected beta of electron -DECLARE_SOA_COLUMN(ExpBetaElError, expbetaelerror, float); //! Expected uncertainty on the beta of electron -// -DECLARE_SOA_COLUMN(SeparationBetaEl, separationbetael, float); //! Separation computed with the expected beta for electrons -DECLARE_SOA_DYNAMIC_COLUMN(DiffBetaEl, diffbetael, //! Difference between the measured and the expected beta for electrons - [](float beta, float expbetael) -> float { return beta - expbetael; }); -} // namespace pidtofbeta - -namespace pidtofmass -{ -DECLARE_SOA_COLUMN(TOFMass, mass, float); //! TOF mass -} // namespace pidtofmass - -namespace pidtof -{ -// Expected times -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalEl, tofExpSignalEl, //! Expected time for electron - [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalMu, tofExpSignalMu, //! Expected time for muon - [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalPi, tofExpSignalPi, //! Expected time for pion - [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalKa, tofExpSignalKa, //! Expected time for kaon - [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalPr, tofExpSignalPr, //! Expected time for proton - [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDe, tofExpSignalDe, //! Expected time for deuteron - [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalTr, tofExpSignalTr, //! Expected time for triton - [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalHe, tofExpSignalHe, //! Expected time for helium3 - [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalAl, tofExpSignalAl, //! Expected time for alpha - [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); -// Delta with respect to signal -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffEl, tofExpSignalDiffEl, //! Difference between signal and expected for electron - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffMu, tofExpSignalDiffMu, //! Difference between signal and expected for muon - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffPi, tofExpSignalDiffPi, //! Difference between signal and expected for pion - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffKa, tofExpSignalDiffKa, //! Difference between signal and expected for kaon - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffPr, tofExpSignalDiffPr, //! Difference between signal and expected for proton - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffDe, tofExpSignalDiffDe, //! Difference between signal and expected for deuteron - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffTr, tofExpSignalDiffTr, //! Difference between signal and expected for triton - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffHe, tofExpSignalDiffHe, //! Difference between signal and expected for helium3 - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffAl, tofExpSignalDiffAl, //! Difference between signal and expected for alpha - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -// Expected sigma -DECLARE_SOA_COLUMN(TOFExpSigmaEl, tofExpSigmaEl, float); //! Expected resolution with the TOF detector for electron -DECLARE_SOA_COLUMN(TOFExpSigmaMu, tofExpSigmaMu, float); //! Expected resolution with the TOF detector for muon -DECLARE_SOA_COLUMN(TOFExpSigmaPi, tofExpSigmaPi, float); //! Expected resolution with the TOF detector for pion -DECLARE_SOA_COLUMN(TOFExpSigmaKa, tofExpSigmaKa, float); //! Expected resolution with the TOF detector for kaon -DECLARE_SOA_COLUMN(TOFExpSigmaPr, tofExpSigmaPr, float); //! Expected resolution with the TOF detector for proton -DECLARE_SOA_COLUMN(TOFExpSigmaDe, tofExpSigmaDe, float); //! Expected resolution with the TOF detector for deuteron -DECLARE_SOA_COLUMN(TOFExpSigmaTr, tofExpSigmaTr, float); //! Expected resolution with the TOF detector for triton -DECLARE_SOA_COLUMN(TOFExpSigmaHe, tofExpSigmaHe, float); //! Expected resolution with the TOF detector for helium3 -DECLARE_SOA_COLUMN(TOFExpSigmaAl, tofExpSigmaAl, float); //! Expected resolution with the TOF detector for alpha -// NSigma -DECLARE_SOA_COLUMN(TOFNSigmaEl, tofNSigmaEl, float); //! Nsigma separation with the TOF detector for electron -DECLARE_SOA_COLUMN(TOFNSigmaMu, tofNSigmaMu, float); //! Nsigma separation with the TOF detector for muon -DECLARE_SOA_COLUMN(TOFNSigmaPi, tofNSigmaPi, float); //! Nsigma separation with the TOF detector for pion -DECLARE_SOA_COLUMN(TOFNSigmaKa, tofNSigmaKa, float); //! Nsigma separation with the TOF detector for kaon -DECLARE_SOA_COLUMN(TOFNSigmaPr, tofNSigmaPr, float); //! Nsigma separation with the TOF detector for proton -DECLARE_SOA_COLUMN(TOFNSigmaDe, tofNSigmaDe, float); //! Nsigma separation with the TOF detector for deuteron -DECLARE_SOA_COLUMN(TOFNSigmaTr, tofNSigmaTr, float); //! Nsigma separation with the TOF detector for triton -DECLARE_SOA_COLUMN(TOFNSigmaHe, tofNSigmaHe, float); //! Nsigma separation with the TOF detector for helium3 -DECLARE_SOA_COLUMN(TOFNSigmaAl, tofNSigmaAl, float); //! Nsigma separation with the TOF detector for alpha -} // namespace pidtof - -// Macro to convert the stored Nsigmas to floats -#define DEFINE_UNWRAP_NSIGMA_COLUMN(COLUMN, COLUMN_NAME) \ - DECLARE_SOA_DYNAMIC_COLUMN(COLUMN, COLUMN_NAME, \ - [](binning::binned_t nsigma_binned) -> float { return o2::aod::pidutils::unPackInTable(nsigma_binned); }); - -namespace pidtof_tiny -{ -struct binning { - public: - typedef int8_t binned_t; - static constexpr int nbins = (1 << 8 * sizeof(binned_t)) - 2; - static constexpr binned_t overflowBin = nbins >> 1; - static constexpr binned_t underflowBin = -(nbins >> 1); - static constexpr float binned_max = 6.35; - static constexpr float binned_min = -6.35; - static constexpr float bin_width = (binned_max - binned_min) / nbins; -}; - -// NSigma with reduced size 8 bit -DECLARE_SOA_COLUMN(TOFNSigmaStoreEl, tofNSigmaStoreEl, binning::binned_t); //! Stored binned nsigma with the TOF detector for electron -DECLARE_SOA_COLUMN(TOFNSigmaStoreMu, tofNSigmaStoreMu, binning::binned_t); //! Stored binned nsigma with the TOF detector for muon -DECLARE_SOA_COLUMN(TOFNSigmaStorePi, tofNSigmaStorePi, binning::binned_t); //! Stored binned nsigma with the TOF detector for pion -DECLARE_SOA_COLUMN(TOFNSigmaStoreKa, tofNSigmaStoreKa, binning::binned_t); //! Stored binned nsigma with the TOF detector for kaon -DECLARE_SOA_COLUMN(TOFNSigmaStorePr, tofNSigmaStorePr, binning::binned_t); //! Stored binned nsigma with the TOF detector for proton -DECLARE_SOA_COLUMN(TOFNSigmaStoreDe, tofNSigmaStoreDe, binning::binned_t); //! Stored binned nsigma with the TOF detector for deuteron -DECLARE_SOA_COLUMN(TOFNSigmaStoreTr, tofNSigmaStoreTr, binning::binned_t); //! Stored binned nsigma with the TOF detector for triton -DECLARE_SOA_COLUMN(TOFNSigmaStoreHe, tofNSigmaStoreHe, binning::binned_t); //! Stored binned nsigma with the TOF detector for helium3 -DECLARE_SOA_COLUMN(TOFNSigmaStoreAl, tofNSigmaStoreAl, binning::binned_t); //! Stored binned nsigma with the TOF detector for alpha -// NSigma with reduced size in [binned_min, binned_max] bin size bin_width -DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaEl, tofNSigmaEl); //! Unwrapped (float) nsigma with the TOF detector for electron -DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaMu, tofNSigmaMu); //! Unwrapped (float) nsigma with the TOF detector for muon -DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaPi, tofNSigmaPi); //! Unwrapped (float) nsigma with the TOF detector for pion -DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaKa, tofNSigmaKa); //! Unwrapped (float) nsigma with the TOF detector for kaon -DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaPr, tofNSigmaPr); //! Unwrapped (float) nsigma with the TOF detector for proton -DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaDe, tofNSigmaDe); //! Unwrapped (float) nsigma with the TOF detector for deuteron -DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaTr, tofNSigmaTr); //! Unwrapped (float) nsigma with the TOF detector for triton -DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaHe, tofNSigmaHe); //! Unwrapped (float) nsigma with the TOF detector for helium3 -DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaAl, tofNSigmaAl); //! Unwrapped (float) nsigma with the TOF detector for alpha - -} // namespace pidtof_tiny - -DECLARE_SOA_TABLE(TOFSignal, "AOD", "TOFSignal", //! Table of the TOF signal - pidtofsignal::TOFSignal, - pidtofsignal::EventCollisionTime); - -DECLARE_SOA_TABLE(TOFEvTime, "AOD", "TOFEvTime", //! Table of the TOF event time. One entry per track. - pidtofevtime::TOFEvTime, - pidtofevtime::TOFEvTimeErr); - -DECLARE_SOA_TABLE(pidTOFFlags, "AOD", "pidTOFFlags", //! Table of the flags for TOF signal quality on the track level - pidflags::GoodTOFMatch); - -DECLARE_SOA_TABLE(pidTOFbeta, "AOD", "pidTOFbeta", //! Table of the TOF beta - pidtofbeta::Beta, pidtofbeta::BetaError); - -DECLARE_SOA_TABLE(pidTOFmass, "AOD", "pidTOFmass", //! Table of the TOF mass - pidtofmass::TOFMass); - -DECLARE_SOA_TABLE(pidEvTimeFlags, "AOD", "pidEvTimeFlags", //! Table of the PID flags for the event time tables - pidflags::TOFFlags, - pidflags::IsEvTimeDefined, - pidflags::IsEvTimeTOF, - pidflags::IsEvTimeT0AC, - pidflags::IsEvTimeTOFT0AC); - -// Per particle tables -DECLARE_SOA_TABLE(pidTOFFullEl, "AOD", "pidTOFFullEl", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for electron - pidtof::TOFExpSignalDiffEl, - pidtof::TOFExpSignalEl, - pidtof::TOFExpSigmaEl, pidtof::TOFNSigmaEl); -DECLARE_SOA_TABLE(pidTOFFullMu, "AOD", "pidTOFFullMu", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for muon - pidtof::TOFExpSignalDiffMu, - pidtof::TOFExpSignalMu, - pidtof::TOFExpSigmaMu, pidtof::TOFNSigmaMu); -DECLARE_SOA_TABLE(pidTOFFullPi, "AOD", "pidTOFFullPi", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for pion - pidtof::TOFExpSignalDiffPi, - pidtof::TOFExpSignalPi, - pidtof::TOFExpSigmaPi, pidtof::TOFNSigmaPi); -DECLARE_SOA_TABLE(pidTOFFullKa, "AOD", "pidTOFFullKa", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for kaon - pidtof::TOFExpSignalDiffKa, - pidtof::TOFExpSignalKa, - pidtof::TOFExpSigmaKa, pidtof::TOFNSigmaKa); -DECLARE_SOA_TABLE(pidTOFFullPr, "AOD", "pidTOFFullPr", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for proton - pidtof::TOFExpSignalDiffPr, - pidtof::TOFExpSignalPr, - pidtof::TOFExpSigmaPr, pidtof::TOFNSigmaPr); -DECLARE_SOA_TABLE(pidTOFFullDe, "AOD", "pidTOFFullDe", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for deuteron - pidtof::TOFExpSignalDiffDe, - pidtof::TOFExpSignalDe, - pidtof::TOFExpSigmaDe, pidtof::TOFNSigmaDe); -DECLARE_SOA_TABLE(pidTOFFullTr, "AOD", "pidTOFFullTr", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for triton - pidtof::TOFExpSignalDiffTr, - pidtof::TOFExpSignalTr, - pidtof::TOFExpSigmaTr, pidtof::TOFNSigmaTr); -DECLARE_SOA_TABLE(pidTOFFullHe, "AOD", "pidTOFFullHe", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for helium3 - pidtof::TOFExpSignalDiffHe, - pidtof::TOFExpSignalHe, - pidtof::TOFExpSigmaHe, pidtof::TOFNSigmaHe); -DECLARE_SOA_TABLE(pidTOFFullAl, "AOD", "pidTOFFullAl", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for alpha - pidtof::TOFExpSignalDiffAl, - pidtof::TOFExpSignalAl, - pidtof::TOFExpSigmaAl, pidtof::TOFNSigmaAl); - -// Tiny size tables -DECLARE_SOA_TABLE(pidTOFEl, "AOD", "pidTOFEl", //! Table of the TOF response with binned Nsigma for electron - pidtof_tiny::TOFNSigmaStoreEl, pidtof_tiny::TOFNSigmaEl); -DECLARE_SOA_TABLE(pidTOFMu, "AOD", "pidTOFMu", //! Table of the TOF response with binned Nsigma for muon - pidtof_tiny::TOFNSigmaStoreMu, pidtof_tiny::TOFNSigmaMu); -DECLARE_SOA_TABLE(pidTOFPi, "AOD", "pidTOFPi", //! Table of the TOF response with binned Nsigma for pion - pidtof_tiny::TOFNSigmaStorePi, pidtof_tiny::TOFNSigmaPi); -DECLARE_SOA_TABLE(pidTOFKa, "AOD", "pidTOFKa", //! Table of the TOF response with binned Nsigma for kaon - pidtof_tiny::TOFNSigmaStoreKa, pidtof_tiny::TOFNSigmaKa); -DECLARE_SOA_TABLE(pidTOFPr, "AOD", "pidTOFPr", //! Table of the TOF response with binned Nsigma for proton - pidtof_tiny::TOFNSigmaStorePr, pidtof_tiny::TOFNSigmaPr); -DECLARE_SOA_TABLE(pidTOFDe, "AOD", "pidTOFDe", //! Table of the TOF response with binned Nsigma for deuteron - pidtof_tiny::TOFNSigmaStoreDe, pidtof_tiny::TOFNSigmaDe); -DECLARE_SOA_TABLE(pidTOFTr, "AOD", "pidTOFTr", //! Table of the TOF response with binned Nsigma for triton - pidtof_tiny::TOFNSigmaStoreTr, pidtof_tiny::TOFNSigmaTr); -DECLARE_SOA_TABLE(pidTOFHe, "AOD", "pidTOFHe", //! Table of the TOF response with binned Nsigma for helium3 - pidtof_tiny::TOFNSigmaStoreHe, pidtof_tiny::TOFNSigmaHe); -DECLARE_SOA_TABLE(pidTOFAl, "AOD", "pidTOFAl", //! Table of the TOF response with binned Nsigma for alpha - pidtof_tiny::TOFNSigmaStoreAl, pidtof_tiny::TOFNSigmaAl); - -namespace mcpidtpc -{ -// Tuned MC on data -DECLARE_SOA_COLUMN(DeDxTunedMc, mcTunedTPCSignal, float); //! TPC signal after TuneOnData application for MC -} // namespace mcpidtpc - -DECLARE_SOA_TABLE(mcTPCTuneOnData, "AOD", "MCTPCTUNEONDATA", mcpidtpc::DeDxTunedMc); - -namespace pidtpc -{ -// Expected signals -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalEl, tpcExpSignalEl, //! Expected signal with the TPC detector for electron - [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalMu, tpcExpSignalMu, //! Expected signal with the TPC detector for muon - [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalPi, tpcExpSignalPi, //! Expected signal with the TPC detector for pion - [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalKa, tpcExpSignalKa, //! Expected signal with the TPC detector for kaon - [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalPr, tpcExpSignalPr, //! Expected signal with the TPC detector for proton - [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDe, tpcExpSignalDe, //! Expected signal with the TPC detector for deuteron - [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalTr, tpcExpSignalTr, //! Expected signal with the TPC detector for triton - [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalHe, tpcExpSignalHe, //! Expected signal with the TPC detector for helium3 - [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalAl, tpcExpSignalAl, //! Expected signal with the TPC detector for alpha - [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); -// Expected signals difference -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffEl, tpcExpSignalDiffEl, //! Difference between signal and expected for electron - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffMu, tpcExpSignalDiffMu, //! Difference between signal and expected for muon - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffPi, tpcExpSignalDiffPi, //! Difference between signal and expected for pion - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffKa, tpcExpSignalDiffKa, //! Difference between signal and expected for kaon - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffPr, tpcExpSignalDiffPr, //! Difference between signal and expected for proton - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffDe, tpcExpSignalDiffDe, //! Difference between signal and expected for deuteron - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffTr, tpcExpSignalDiffTr, //! Difference between signal and expected for triton - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffHe, tpcExpSignalDiffHe, //! Difference between signal and expected for helium3 - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffAl, tpcExpSignalDiffAl, //! Difference between signal and expected for alpha - [](float nsigma, float sigma) -> float { return nsigma * sigma; }); -// Expected sigma -DECLARE_SOA_COLUMN(TPCExpSigmaEl, tpcExpSigmaEl, float); //! Expected resolution with the TPC detector for electron -DECLARE_SOA_COLUMN(TPCExpSigmaMu, tpcExpSigmaMu, float); //! Expected resolution with the TPC detector for muon -DECLARE_SOA_COLUMN(TPCExpSigmaPi, tpcExpSigmaPi, float); //! Expected resolution with the TPC detector for pion -DECLARE_SOA_COLUMN(TPCExpSigmaKa, tpcExpSigmaKa, float); //! Expected resolution with the TPC detector for kaon -DECLARE_SOA_COLUMN(TPCExpSigmaPr, tpcExpSigmaPr, float); //! Expected resolution with the TPC detector for proton -DECLARE_SOA_COLUMN(TPCExpSigmaDe, tpcExpSigmaDe, float); //! Expected resolution with the TPC detector for deuteron -DECLARE_SOA_COLUMN(TPCExpSigmaTr, tpcExpSigmaTr, float); //! Expected resolution with the TPC detector for triton -DECLARE_SOA_COLUMN(TPCExpSigmaHe, tpcExpSigmaHe, float); //! Expected resolution with the TPC detector for helium3 -DECLARE_SOA_COLUMN(TPCExpSigmaAl, tpcExpSigmaAl, float); //! Expected resolution with the TPC detector for alpha -// NSigma -DECLARE_SOA_COLUMN(TPCNSigmaEl, tpcNSigmaEl, float); //! Nsigma separation with the TPC detector for electron -DECLARE_SOA_COLUMN(TPCNSigmaMu, tpcNSigmaMu, float); //! Nsigma separation with the TPC detector for muon -DECLARE_SOA_COLUMN(TPCNSigmaPi, tpcNSigmaPi, float); //! Nsigma separation with the TPC detector for pion -DECLARE_SOA_COLUMN(TPCNSigmaKa, tpcNSigmaKa, float); //! Nsigma separation with the TPC detector for kaon -DECLARE_SOA_COLUMN(TPCNSigmaPr, tpcNSigmaPr, float); //! Nsigma separation with the TPC detector for proton -DECLARE_SOA_COLUMN(TPCNSigmaDe, tpcNSigmaDe, float); //! Nsigma separation with the TPC detector for deuteron -DECLARE_SOA_COLUMN(TPCNSigmaTr, tpcNSigmaTr, float); //! Nsigma separation with the TPC detector for triton -DECLARE_SOA_COLUMN(TPCNSigmaHe, tpcNSigmaHe, float); //! Nsigma separation with the TPC detector for helium3 -DECLARE_SOA_COLUMN(TPCNSigmaAl, tpcNSigmaAl, float); //! Nsigma separation with the TPC detector for alpha - -} // namespace pidtpc - -namespace pidtpc_tiny -{ - -struct binning { - public: - typedef int8_t binned_t; - static constexpr int nbins = (1 << 8 * sizeof(binned_t)) - 2; - static constexpr binned_t overflowBin = nbins >> 1; - static constexpr binned_t underflowBin = -(nbins >> 1); - static constexpr float binned_max = 6.35; - static constexpr float binned_min = -6.35; - static constexpr float bin_width = (binned_max - binned_min) / nbins; -}; - -// NSigma with reduced size -DECLARE_SOA_COLUMN(TPCNSigmaStoreEl, tpcNSigmaStoreEl, binning::binned_t); //! Stored binned nsigma with the TPC detector for electron -DECLARE_SOA_COLUMN(TPCNSigmaStoreMu, tpcNSigmaStoreMu, binning::binned_t); //! Stored binned nsigma with the TPC detector for muon -DECLARE_SOA_COLUMN(TPCNSigmaStorePi, tpcNSigmaStorePi, binning::binned_t); //! Stored binned nsigma with the TPC detector for pion -DECLARE_SOA_COLUMN(TPCNSigmaStoreKa, tpcNSigmaStoreKa, binning::binned_t); //! Stored binned nsigma with the TPC detector for kaon -DECLARE_SOA_COLUMN(TPCNSigmaStorePr, tpcNSigmaStorePr, binning::binned_t); //! Stored binned nsigma with the TPC detector for proton -DECLARE_SOA_COLUMN(TPCNSigmaStoreDe, tpcNSigmaStoreDe, binning::binned_t); //! Stored binned nsigma with the TPC detector for deuteron -DECLARE_SOA_COLUMN(TPCNSigmaStoreTr, tpcNSigmaStoreTr, binning::binned_t); //! Stored binned nsigma with the TPC detector for triton -DECLARE_SOA_COLUMN(TPCNSigmaStoreHe, tpcNSigmaStoreHe, binning::binned_t); //! Stored binned nsigma with the TPC detector for helium3 -DECLARE_SOA_COLUMN(TPCNSigmaStoreAl, tpcNSigmaStoreAl, binning::binned_t); //! Stored binned nsigma with the TPC detector for alpha -// NSigma with reduced size in [binned_min, binned_max] bin size bin_width -DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaEl, tpcNSigmaEl); //! Unwrapped (float) nsigma with the TPC detector for electron -DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaMu, tpcNSigmaMu); //! Unwrapped (float) nsigma with the TPC detector for muon -DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaPi, tpcNSigmaPi); //! Unwrapped (float) nsigma with the TPC detector for pion -DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaKa, tpcNSigmaKa); //! Unwrapped (float) nsigma with the TPC detector for kaon -DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaPr, tpcNSigmaPr); //! Unwrapped (float) nsigma with the TPC detector for proton -DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaDe, tpcNSigmaDe); //! Unwrapped (float) nsigma with the TPC detector for deuteron -DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaTr, tpcNSigmaTr); //! Unwrapped (float) nsigma with the TPC detector for triton -DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaHe, tpcNSigmaHe); //! Unwrapped (float) nsigma with the TPC detector for helium3 -DEFINE_UNWRAP_NSIGMA_COLUMN(TPCNSigmaAl, tpcNSigmaAl); //! Unwrapped (float) nsigma with the TPC detector for alpha - -} // namespace pidtpc_tiny - -// Per particle tables -DECLARE_SOA_TABLE(pidTPCFullEl, "AOD", "pidTPCFullEl", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for electron - pidtpc::TPCExpSignalEl, pidtpc::TPCExpSignalDiffEl, pidtpc::TPCExpSigmaEl, pidtpc::TPCNSigmaEl); -DECLARE_SOA_TABLE(pidTPCFullMu, "AOD", "pidTPCFullMu", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for muon - pidtpc::TPCExpSignalMu, pidtpc::TPCExpSignalDiffMu, pidtpc::TPCExpSigmaMu, pidtpc::TPCNSigmaMu); -DECLARE_SOA_TABLE(pidTPCFullPi, "AOD", "pidTPCFullPi", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for pion - pidtpc::TPCExpSignalPi, pidtpc::TPCExpSignalDiffPi, pidtpc::TPCExpSigmaPi, pidtpc::TPCNSigmaPi); -DECLARE_SOA_TABLE(pidTPCFullKa, "AOD", "pidTPCFullKa", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for kaon - pidtpc::TPCExpSignalKa, pidtpc::TPCExpSignalDiffKa, pidtpc::TPCExpSigmaKa, pidtpc::TPCNSigmaKa); -DECLARE_SOA_TABLE(pidTPCFullPr, "AOD", "pidTPCFullPr", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for proton - pidtpc::TPCExpSignalPr, pidtpc::TPCExpSignalDiffPr, pidtpc::TPCExpSigmaPr, pidtpc::TPCNSigmaPr); -DECLARE_SOA_TABLE(pidTPCFullDe, "AOD", "pidTPCFullDe", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for deuteron - pidtpc::TPCExpSignalDe, pidtpc::TPCExpSignalDiffDe, pidtpc::TPCExpSigmaDe, pidtpc::TPCNSigmaDe); -DECLARE_SOA_TABLE(pidTPCFullTr, "AOD", "pidTPCFullTr", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for triton - pidtpc::TPCExpSignalTr, pidtpc::TPCExpSignalDiffTr, pidtpc::TPCExpSigmaTr, pidtpc::TPCNSigmaTr); -DECLARE_SOA_TABLE(pidTPCFullHe, "AOD", "pidTPCFullHe", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for helium3 - pidtpc::TPCExpSignalHe, pidtpc::TPCExpSignalDiffHe, pidtpc::TPCExpSigmaHe, pidtpc::TPCNSigmaHe); -DECLARE_SOA_TABLE(pidTPCFullAl, "AOD", "pidTPCFullAl", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for alpha - pidtpc::TPCExpSignalAl, pidtpc::TPCExpSignalDiffAl, pidtpc::TPCExpSigmaAl, pidtpc::TPCNSigmaAl); - -// Tiny size tables -DECLARE_SOA_TABLE(pidTPCEl, "AOD", "pidTPCEl", //! Table of the TPC response with binned Nsigma for electron - pidtpc_tiny::TPCNSigmaStoreEl, pidtpc_tiny::TPCNSigmaEl); -DECLARE_SOA_TABLE(pidTPCMu, "AOD", "pidTPCMu", //! Table of the TPC response with binned Nsigma for muon - pidtpc_tiny::TPCNSigmaStoreMu, pidtpc_tiny::TPCNSigmaMu); -DECLARE_SOA_TABLE(pidTPCPi, "AOD", "pidTPCPi", //! Table of the TPC response with binned Nsigma for pion - pidtpc_tiny::TPCNSigmaStorePi, pidtpc_tiny::TPCNSigmaPi); -DECLARE_SOA_TABLE(pidTPCKa, "AOD", "pidTPCKa", //! Table of the TPC response with binned Nsigma for kaon - pidtpc_tiny::TPCNSigmaStoreKa, pidtpc_tiny::TPCNSigmaKa); -DECLARE_SOA_TABLE(pidTPCPr, "AOD", "pidTPCPr", //! Table of the TPC response with binned Nsigma for proton - pidtpc_tiny::TPCNSigmaStorePr, pidtpc_tiny::TPCNSigmaPr); -DECLARE_SOA_TABLE(pidTPCDe, "AOD", "pidTPCDe", //! Table of the TPC response with binned Nsigma for deuteron - pidtpc_tiny::TPCNSigmaStoreDe, pidtpc_tiny::TPCNSigmaDe); -DECLARE_SOA_TABLE(pidTPCTr, "AOD", "pidTPCTr", //! Table of the TPC response with binned Nsigma for triton - pidtpc_tiny::TPCNSigmaStoreTr, pidtpc_tiny::TPCNSigmaTr); -DECLARE_SOA_TABLE(pidTPCHe, "AOD", "pidTPCHe", //! Table of the TPC response with binned Nsigma for helium3 - pidtpc_tiny::TPCNSigmaStoreHe, pidtpc_tiny::TPCNSigmaHe); -DECLARE_SOA_TABLE(pidTPCAl, "AOD", "pidTPCAl", //! Table of the TPC response with binned Nsigma for alpha - pidtpc_tiny::TPCNSigmaStoreAl, pidtpc_tiny::TPCNSigmaAl); - -#undef DEFINE_UNWRAP_NSIGMA_COLUMN - -namespace pidbayes -{ -typedef int8_t binned_prob_t; -// Bayesian probabilities with reduced size -DECLARE_SOA_COLUMN(BayesEl, bayesEl, binned_prob_t); //! Bayesian probability for electron expressed in % -DECLARE_SOA_COLUMN(BayesMu, bayesMu, binned_prob_t); //! Bayesian probability for muon expressed in % -DECLARE_SOA_COLUMN(BayesPi, bayesPi, binned_prob_t); //! Bayesian probability for pion expressed in % -DECLARE_SOA_COLUMN(BayesKa, bayesKa, binned_prob_t); //! Bayesian probability for kaon expressed in % -DECLARE_SOA_COLUMN(BayesPr, bayesPr, binned_prob_t); //! Bayesian probability for proton expressed in % -DECLARE_SOA_COLUMN(BayesDe, bayesDe, binned_prob_t); //! Bayesian probability for deuteron expressed in % -DECLARE_SOA_COLUMN(BayesTr, bayesTr, binned_prob_t); //! Bayesian probability for triton expressed in % -DECLARE_SOA_COLUMN(BayesHe, bayesHe, binned_prob_t); //! Bayesian probability for helium3 expressed in % -DECLARE_SOA_COLUMN(BayesAl, bayesAl, binned_prob_t); //! Bayesian probability for alpha expressed in % -DECLARE_SOA_COLUMN(BayesProb, bayesProb, binned_prob_t); //! Bayesian probability of the most probable ID -DECLARE_SOA_COLUMN(BayesID, bayesID, o2::track::pid_constants::ID); //! Most probable ID - -} // namespace pidbayes - -// Table for each particle hypothesis -DECLARE_SOA_TABLE(pidBayesEl, "AOD", "pidBayesEl", //! Binned (in percentage) Bayesian probability of having a Electron - pidbayes::BayesEl); -DECLARE_SOA_TABLE(pidBayesMu, "AOD", "pidBayesMu", //! Binned (in percentage) Bayesian probability of having a Muon - pidbayes::BayesMu); -DECLARE_SOA_TABLE(pidBayesPi, "AOD", "pidBayesPi", //! Binned (in percentage) Bayesian probability of having a Pion - pidbayes::BayesPi); -DECLARE_SOA_TABLE(pidBayesKa, "AOD", "pidBayesKa", //! Binned (in percentage) Bayesian probability of having a Kaon - pidbayes::BayesKa); -DECLARE_SOA_TABLE(pidBayesPr, "AOD", "pidBayesPr", //! Binned (in percentage) Bayesian probability of having a Proton - pidbayes::BayesPr); -DECLARE_SOA_TABLE(pidBayesDe, "AOD", "pidBayesDe", //! Binned (in percentage) Bayesian probability of having a Deuteron - pidbayes::BayesDe); -DECLARE_SOA_TABLE(pidBayesTr, "AOD", "pidBayesTr", //! Binned (in percentage) Bayesian probability of having a Triton - pidbayes::BayesTr); -DECLARE_SOA_TABLE(pidBayesHe, "AOD", "pidBayesHe", //! Binned (in percentage) Bayesian probability of having a Helium3 - pidbayes::BayesHe); -DECLARE_SOA_TABLE(pidBayesAl, "AOD", "pidBayesAl", //! Binned (in percentage) Bayesian probability of having a Alpha - pidbayes::BayesAl); - -// Table for the most probable particle -DECLARE_SOA_TABLE(pidBayes, "AOD", "pidBayes", pidbayes::BayesProb, pidbayes::BayesID); //! Index of the most probable ID and its bayesian probability - } // namespace o2::aod #endif // COMMON_DATAMODEL_PIDRESPONSE_H_ diff --git a/Common/DataModel/PIDResponseCombined.h b/Common/DataModel/PIDResponseCombined.h new file mode 100644 index 00000000000..4b54d214838 --- /dev/null +++ b/Common/DataModel/PIDResponseCombined.h @@ -0,0 +1,76 @@ +// 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. + +/// +/// \file PIDResponseCombined.h +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \brief Set of tables, tasks and utilities to provide the interface between +/// the analysis data model and the combined PID response +/// + +#ifndef COMMON_DATAMODEL_PIDRESPONSECOMBINED_H_ +#define COMMON_DATAMODEL_PIDRESPONSECOMBINED_H_ + +#include + +// O2 includes +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "ReconstructionDataFormats/PID.h" +#include "Framework/Logger.h" + +namespace o2::aod +{ + +namespace pidbayes +{ +typedef int8_t binned_prob_t; +// Bayesian probabilities with reduced size +DECLARE_SOA_COLUMN(BayesEl, bayesEl, binned_prob_t); //! Bayesian probability for electron expressed in % +DECLARE_SOA_COLUMN(BayesMu, bayesMu, binned_prob_t); //! Bayesian probability for muon expressed in % +DECLARE_SOA_COLUMN(BayesPi, bayesPi, binned_prob_t); //! Bayesian probability for pion expressed in % +DECLARE_SOA_COLUMN(BayesKa, bayesKa, binned_prob_t); //! Bayesian probability for kaon expressed in % +DECLARE_SOA_COLUMN(BayesPr, bayesPr, binned_prob_t); //! Bayesian probability for proton expressed in % +DECLARE_SOA_COLUMN(BayesDe, bayesDe, binned_prob_t); //! Bayesian probability for deuteron expressed in % +DECLARE_SOA_COLUMN(BayesTr, bayesTr, binned_prob_t); //! Bayesian probability for triton expressed in % +DECLARE_SOA_COLUMN(BayesHe, bayesHe, binned_prob_t); //! Bayesian probability for helium3 expressed in % +DECLARE_SOA_COLUMN(BayesAl, bayesAl, binned_prob_t); //! Bayesian probability for alpha expressed in % +DECLARE_SOA_COLUMN(BayesProb, bayesProb, binned_prob_t); //! Bayesian probability of the most probable ID +DECLARE_SOA_COLUMN(BayesID, bayesID, o2::track::pid_constants::ID); //! Most probable ID + +} // namespace pidbayes + +// Table for each particle hypothesis +DECLARE_SOA_TABLE(pidBayesEl, "AOD", "pidBayesEl", //! Binned (in percentage) Bayesian probability of having a Electron + pidbayes::BayesEl); +DECLARE_SOA_TABLE(pidBayesMu, "AOD", "pidBayesMu", //! Binned (in percentage) Bayesian probability of having a Muon + pidbayes::BayesMu); +DECLARE_SOA_TABLE(pidBayesPi, "AOD", "pidBayesPi", //! Binned (in percentage) Bayesian probability of having a Pion + pidbayes::BayesPi); +DECLARE_SOA_TABLE(pidBayesKa, "AOD", "pidBayesKa", //! Binned (in percentage) Bayesian probability of having a Kaon + pidbayes::BayesKa); +DECLARE_SOA_TABLE(pidBayesPr, "AOD", "pidBayesPr", //! Binned (in percentage) Bayesian probability of having a Proton + pidbayes::BayesPr); +DECLARE_SOA_TABLE(pidBayesDe, "AOD", "pidBayesDe", //! Binned (in percentage) Bayesian probability of having a Deuteron + pidbayes::BayesDe); +DECLARE_SOA_TABLE(pidBayesTr, "AOD", "pidBayesTr", //! Binned (in percentage) Bayesian probability of having a Triton + pidbayes::BayesTr); +DECLARE_SOA_TABLE(pidBayesHe, "AOD", "pidBayesHe", //! Binned (in percentage) Bayesian probability of having a Helium3 + pidbayes::BayesHe); +DECLARE_SOA_TABLE(pidBayesAl, "AOD", "pidBayesAl", //! Binned (in percentage) Bayesian probability of having a Alpha + pidbayes::BayesAl); + +// Table for the most probable particle +DECLARE_SOA_TABLE(pidBayes, "AOD", "pidBayes", pidbayes::BayesProb, pidbayes::BayesID); //! Index of the most probable ID and its bayesian probability + +} // namespace o2::aod + +#endif // COMMON_DATAMODEL_PIDRESPONSECOMBINED_H_ diff --git a/Common/DataModel/PIDResponseITS.h b/Common/DataModel/PIDResponseITS.h index 3b5e13d94fd..e1e2a586472 100644 --- a/Common/DataModel/PIDResponseITS.h +++ b/Common/DataModel/PIDResponseITS.h @@ -23,10 +23,12 @@ #define COMMON_DATAMODEL_PIDRESPONSEITS_H_ // O2 includes +#include "TableHelper.h" + #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" -#include "ReconstructionDataFormats/PID.h" #include "Framework/Logger.h" +#include "ReconstructionDataFormats/PID.h" namespace o2::aod { @@ -34,19 +36,24 @@ namespace o2::aod struct ITSResponse { static float averageClusterSize(uint32_t itsClusterSizes) { - float average = 0; + float sum = 0; int nclusters = 0; - + int max = 0; for (int layer = 0; layer < 7; layer++) { - if ((itsClusterSizes >> (layer * 4)) & 0xf) { + int clsize = (itsClusterSizes >> (layer * 4)) & 0xf; + if (clsize > 0) { nclusters++; - average += (itsClusterSizes >> (layer * 4)) & 0xf; + sum += clsize; + if (clsize > max) { + max = clsize; + } } } if (nclusters == 0) { return 0; } - return average / nclusters; + // truncated mean + return (sum - max) / (nclusters - 1); }; template @@ -67,13 +74,17 @@ struct ITSResponse { static constexpr float inverseMass = 1. / o2::track::pid_constants::sMasses[id]; // static constexpr float charge = static_cast(o2::track::pid_constants::sCharges[id]); const float bg = momentum * inverseMass; - float relRes = mResolutionParams[0] * std::erf((bg - mResolutionParams[1]) / mResolutionParams[2]); - return relRes; + if (id == o2::track::PID::Helium3 || id == o2::track::PID::Alpha) { + return mResolutionParamsZ2[1] > -999.0 ? mResolutionParamsZ2[0] * std::erf((bg - mResolutionParamsZ2[1]) / mResolutionParamsZ2[2]) : mResolutionParamsZ2[0]; + } + return mResolutionParams[1] > -999.0 ? mResolutionParams[0] * std::erf((bg - mResolutionParams[1]) / mResolutionParams[2]) : mResolutionParams[0]; } template static float nSigmaITS(uint32_t itsClusterSizes, float momentum, float eta) { + unsigned int charge = (id == o2::track::PID::Helium3 || id == o2::track::PID::Alpha) ? 2 : 1; + momentum *= charge; const float exp = expSignal(momentum); const float average = averageClusterSize(itsClusterSizes); const float coslInv = 1. / std::cosh(eta); @@ -87,7 +98,10 @@ struct ITSResponse { return nSigmaITS(track.itsClusterSizes(), track.p(), track.eta()); } - static void setParameters(float p0, float p1, float p2, float p0_Z2, float p1_Z2, float p2_Z2, float p0_res, float p1_res, float p2_res) + static void setParameters(float p0, float p1, float p2, + float p0_Z2, float p1_Z2, float p2_Z2, + float p0_res, float p1_res, float p2_res, + float p0_res_Z2, float p1_res_Z2, float p2_res_Z2) { if (mIsInitialized) { LOG(fatal) << "ITSResponse parameters already initialized"; @@ -102,19 +116,66 @@ struct ITSResponse { mResolutionParams[0] = p0_res; mResolutionParams[1] = p1_res; mResolutionParams[2] = p2_res; + mResolutionParamsZ2[0] = p0_res_Z2; + mResolutionParamsZ2[1] = p1_res_Z2; + mResolutionParamsZ2[2] = p2_res_Z2; + } + + static void setMCDefaultParameters() + { + setParameters(1.63806, 1.58847, 2.52275, + 2.66505, 1.48405, 6.90453, + 1.40487e-01, -4.31078e-01, 1.50052, + 0.09, -999., -999.); + } + + /// Initialize the TOF response parameters in the init function of each task + /// \param initContext Initialization context. Gets the configuration parameters from the pidITS task + static void setParameters(o2::framework::InitContext& initContext, bool isMC = false) + { + float p0 = 0, p1 = 0, p2 = 0; + float p0_Z2 = 0, p1_Z2 = 0, p2_Z2 = 0; + float p0_res = 0, p1_res = 0, p2_res = 0; + float p0_res_Z2 = 0, p1_res_Z2 = 0, p2_res_Z2 = 0; + o2::framework::LabeledArray itsParams; + getTaskOptionValue(initContext, "its-pid", "itsParams", itsParams, true); + auto data = itsParams.getData(); + const int col = isMC ? 1 : 0; // 0 for Data, 1 for MC + if (data.rows != 2 || data.cols != 12) { + LOG(fatal) << "ITSResponse parameters not initialized, check the itsParams configuration"; + } + p0 = data(col, 0); + p1 = data(col, 1); + p2 = data(col, 2); + p0_Z2 = data(col, 3); + p1_Z2 = data(col, 4); + p2_Z2 = data(col, 5); + p0_res = data(col, 6); + p1_res = data(col, 7); + p2_res = data(col, 8); + p0_res_Z2 = data(col, 9); + p1_res_Z2 = data(col, 10); + p2_res_Z2 = data(col, 11); + + setParameters(p0, p1, p2, + p0_Z2, p1_Z2, p2_Z2, + p0_res, p1_res, p2_res, + p0_res_Z2, p1_res_Z2, p2_res_Z2); } private: static std::array mITSRespParams; static std::array mITSRespParamsZ2; static std::array mResolutionParams; + static std::array mResolutionParamsZ2; static bool mIsInitialized; }; -std::array ITSResponse::mITSRespParams = {1.1576, 1.684, 1.9453}; -std::array ITSResponse::mITSRespParamsZ2 = {2.8752, 1.1246, 5.0259}; +std::array ITSResponse::mITSRespParams = {1.18941, 1.53792, 1.69961}; +std::array ITSResponse::mITSRespParamsZ2 = {2.35117, 1.80347, 5.14355}; // relative resolution is modelled with an erf function: [0]*TMath::Erf((x-[1])/[2]) -std::array ITSResponse::mResolutionParams = {0.2431, -0.3293, 1.533}; +std::array ITSResponse::mResolutionParams = {1.94669e-01, -2.08616e-01, 1.30753}; +std::array ITSResponse::mResolutionParamsZ2 = {0.09, -999., -999.}; bool ITSResponse::mIsInitialized = false; namespace pidits diff --git a/Common/DataModel/PIDResponseTOF.h b/Common/DataModel/PIDResponseTOF.h new file mode 100644 index 00000000000..5edfe931ad8 --- /dev/null +++ b/Common/DataModel/PIDResponseTOF.h @@ -0,0 +1,501 @@ +// 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. + +/// +/// \file PIDResponseTOF.h +/// \since 2024-11-15 +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \brief Set of tables, tasks and utilities to provide the interface between +/// the analysis data model and the PID response of the TOF +/// + +#ifndef COMMON_DATAMODEL_PIDRESPONSETOF_H_ +#define COMMON_DATAMODEL_PIDRESPONSETOF_H_ + +#include + +// O2 includes +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "ReconstructionDataFormats/PID.h" +#include "Framework/Logger.h" +#include "Common/Core/PID/PIDTOF.h" + +namespace o2::aod +{ +namespace pidutils +{ + +// Checkers for TOF PID hypothesis availability (runtime) +template +using hasTOFEl = decltype(std::declval().tofNSigmaEl()); +template +using hasTOFMu = decltype(std::declval().tofNSigmaMu()); +template +using hasTOFPi = decltype(std::declval().tofNSigmaPi()); +template +using hasTOFKa = decltype(std::declval().tofNSigmaKa()); +template +using hasTOFPr = decltype(std::declval().tofNSigmaPr()); +template +using hasTOFDe = decltype(std::declval().tofNSigmaDe()); +template +using hasTOFTr = decltype(std::declval().tofNSigmaTr()); +template +using hasTOFHe = decltype(std::declval().tofNSigmaHe()); +template +using hasTOFAl = decltype(std::declval().tofNSigmaAl()); + +// PID index as template argument +#define perSpeciesWrapper(functionName) \ + template \ + auto functionName(const TrackType& track) \ + { \ + if constexpr (index == o2::track::PID::Electron) { \ + return track.functionName##El(); \ + } else if constexpr (index == o2::track::PID::Muon) { \ + return track.functionName##Mu(); \ + } else if constexpr (index == o2::track::PID::Pion) { \ + return track.functionName##Pi(); \ + } else if constexpr (index == o2::track::PID::Kaon) { \ + return track.functionName##Ka(); \ + } else if constexpr (index == o2::track::PID::Proton) { \ + return track.functionName##Pr(); \ + } else if constexpr (index == o2::track::PID::Deuteron) { \ + return track.functionName##De(); \ + } else if constexpr (index == o2::track::PID::Triton) { \ + return track.functionName##Tr(); \ + } else if constexpr (index == o2::track::PID::Helium3) { \ + return track.functionName##He(); \ + } else if constexpr (index == o2::track::PID::Alpha) { \ + return track.functionName##Al(); \ + } \ + } + +perSpeciesWrapper(tofNSigma); +perSpeciesWrapper(tofExpSigma); +template +auto tofExpSignal(const TrackType& track) +{ + if constexpr (index == o2::track::PID::Electron) { + return track.tofExpSignalEl(track.tofSignal()); + } else if constexpr (index == o2::track::PID::Muon) { + return track.tofExpSignalMu(track.tofSignal()); + } else if constexpr (index == o2::track::PID::Pion) { + return track.tofExpSignalPi(track.tofSignal()); + } else if constexpr (index == o2::track::PID::Kaon) { + return track.tofExpSignalKa(track.tofSignal()); + } else if constexpr (index == o2::track::PID::Proton) { + return track.tofExpSignalPr(track.tofSignal()); + } else if constexpr (index == o2::track::PID::Deuteron) { + return track.tofExpSignalDe(track.tofSignal()); + } else if constexpr (index == o2::track::PID::Triton) { + return track.tofExpSignalTr(track.tofSignal()); + } else if constexpr (index == o2::track::PID::Helium3) { + return track.tofExpSignalHe(track.tofSignal()); + } else if constexpr (index == o2::track::PID::Alpha) { + return track.tofExpSignalAl(track.tofSignal()); + } +} +perSpeciesWrapper(tofExpSignalDiff); + +#undef perSpeciesWrapper + +// PID index as function argument for TOF +#define perSpeciesWrapper(functionName) \ + template \ + auto functionName(const o2::track::PID::ID index, const TrackType& track) \ + { \ + switch (index) { \ + case o2::track::PID::Electron: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##El(); \ + } \ + case o2::track::PID::Muon: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Mu(); \ + } \ + case o2::track::PID::Pion: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Pi(); \ + } \ + case o2::track::PID::Kaon: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Ka(); \ + } \ + case o2::track::PID::Proton: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Pr(); \ + } \ + case o2::track::PID::Deuteron: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##De(); \ + } \ + case o2::track::PID::Triton: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Tr(); \ + } \ + case o2::track::PID::Helium3: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##He(); \ + } \ + case o2::track::PID::Alpha: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Al(); \ + } \ + default: \ + LOGF(fatal, "TOF PID table for PID index %i (%s) is not available", index, o2::track::PID::getName(index)); \ + return 0.f; \ + } \ + } + +perSpeciesWrapper(tofNSigma); +perSpeciesWrapper(tofExpSigma); +template +auto tofExpSignal(const o2::track::PID::ID index, const TrackType& track) +{ + switch (index) { + case o2::track::PID::Electron: + if constexpr (std::experimental::is_detected::value) { + return track.tofExpSignalEl(track.tofSignal()); + } + case o2::track::PID::Muon: + if constexpr (std::experimental::is_detected::value) { + return track.tofExpSignalMu(track.tofSignal()); + } + case o2::track::PID::Pion: + if constexpr (std::experimental::is_detected::value) { + return track.tofExpSignalPi(track.tofSignal()); + } + case o2::track::PID::Kaon: + if constexpr (std::experimental::is_detected::value) { + return track.tofExpSignalKa(track.tofSignal()); + } + case o2::track::PID::Proton: + if constexpr (std::experimental::is_detected::value) { + return track.tofExpSignalPr(track.tofSignal()); + } + case o2::track::PID::Deuteron: + if constexpr (std::experimental::is_detected::value) { + return track.tofExpSignalDe(track.tofSignal()); + } + case o2::track::PID::Triton: + if constexpr (std::experimental::is_detected::value) { + return track.tofExpSignalTr(track.tofSignal()); + } + case o2::track::PID::Helium3: + if constexpr (std::experimental::is_detected::value) { + return track.tofExpSignalHe(track.tofSignal()); + } + case o2::track::PID::Alpha: + if constexpr (std::experimental::is_detected::value) { + return track.tofExpSignalAl(track.tofSignal()); + } + default: + LOGF(fatal, "TOF PID table for PID index %i (%s) is not available", index, o2::track::PID::getName(index)); + return 0.f; + } +} +perSpeciesWrapper(tofExpSignalDiff); + +#undef perSpeciesWrapper + +} // namespace pidutils + +// Extra tables +namespace pidflags +{ + +namespace enums +{ +enum PIDFlags : uint8_t { + EvTimeUndef = 0x0, // Event collision not set, corresponding to the LHC Fill event time + EvTimeTOF = 0x1, // Event collision time from TOF + EvTimeT0AC = 0x2, // Event collision time from the FT0AC + EvTimeTOFT0AC = 0x4 // Event collision time from the TOF and FT0AC +}; +} + +DECLARE_SOA_COLUMN(GoodTOFMatch, goodTOFMatch, bool); //! Bool for the TOF PID information on the single track information +DECLARE_SOA_COLUMN(TOFFlags, tofFlags, uint8_t); //! Flag for the complementary TOF PID information for the event time +DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeDefined, isEvTimeDefined, //! True if the Event Time was computed with any method i.e. there is a usable event time + [](uint8_t flags) -> bool { return (flags > 0); }); +DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeTOF, isEvTimeTOF, //! True if the Event Time was computed with the TOF + [](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeTOF) == enums::PIDFlags::EvTimeTOF; }); +DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeT0AC, isEvTimeT0AC, //! True if the Event Time was computed with the T0AC + [](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeT0AC) == enums::PIDFlags::EvTimeT0AC; }); +DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeTOFT0AC, isEvTimeTOFT0AC, //! True if the Event Time was computed with the TOF and T0AC + [](uint8_t flags) -> bool { return (flags & enums::PIDFlags::EvTimeTOFT0AC) == enums::PIDFlags::EvTimeTOFT0AC; }); + +} // namespace pidflags + +DECLARE_SOA_TABLE(pidTOFFlags, "AOD", "pidTOFFlags", //! Table of the flags for TOF signal quality on the track level + pidflags::GoodTOFMatch); + +DECLARE_SOA_TABLE(pidEvTimeFlags, "AOD", "pidEvTimeFlags", //! Table of the PID flags for the event time tables + pidflags::TOFFlags, + pidflags::IsEvTimeDefined, + pidflags::IsEvTimeTOF, + pidflags::IsEvTimeT0AC, + pidflags::IsEvTimeTOFT0AC); + +namespace pidtofsignal +{ +DECLARE_SOA_COLUMN(TOFSignal, tofSignal, float); //! TOF signal from track time +DECLARE_SOA_DYNAMIC_COLUMN(EventCollisionTime, eventCollisionTime, //! Event collision time used for the track. Needs the TOF + [](float signal, float tMinusTexp, float texp) -> float { return texp + tMinusTexp - signal; }); + +} // namespace pidtofsignal + +DECLARE_SOA_TABLE(TOFSignal, "AOD", "TOFSignal", //! Table of the TOF signal + pidtofsignal::TOFSignal, + pidtofsignal::EventCollisionTime); + +namespace pidtofevtime +{ +DECLARE_SOA_COLUMN(TOFEvTime, tofEvTime, float); //! event time for TOF signal. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C +DECLARE_SOA_COLUMN(TOFEvTimeErr, tofEvTimeErr, float); //! event time error for TOF. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C +} // namespace pidtofevtime + +DECLARE_SOA_TABLE(TOFEvTime, "AOD", "TOFEvTime", //! Table of the TOF event time. One entry per track. + pidtofevtime::TOFEvTime, + pidtofevtime::TOFEvTimeErr); + +namespace pidtof +{ +// Expected signals +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalEl, tofExpSignalEl, //! Expected time for electron + [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalMu, tofExpSignalMu, //! Expected time for muon + [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalPi, tofExpSignalPi, //! Expected time for pion + [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalKa, tofExpSignalKa, //! Expected time for kaon + [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalPr, tofExpSignalPr, //! Expected time for proton + [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDe, tofExpSignalDe, //! Expected time for deuteron + [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalTr, tofExpSignalTr, //! Expected time for triton + [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalHe, tofExpSignalHe, //! Expected time for helium3 + [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalAl, tofExpSignalAl, //! Expected time for alpha + [](float nsigma, float sigma, float tofsignal) -> float { return tofsignal - nsigma * sigma; }); +// Delta with respect to signal +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffEl, tofExpSignalDiffEl, //! Difference between signal and expected for electron + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffMu, tofExpSignalDiffMu, //! Difference between signal and expected for muon + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffPi, tofExpSignalDiffPi, //! Difference between signal and expected for pion + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffKa, tofExpSignalDiffKa, //! Difference between signal and expected for kaon + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffPr, tofExpSignalDiffPr, //! Difference between signal and expected for proton + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffDe, tofExpSignalDiffDe, //! Difference between signal and expected for deuteron + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffTr, tofExpSignalDiffTr, //! Difference between signal and expected for triton + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffHe, tofExpSignalDiffHe, //! Difference between signal and expected for helium3 + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFExpSignalDiffAl, tofExpSignalDiffAl, //! Difference between signal and expected for alpha + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +// Expected sigma +DECLARE_SOA_COLUMN(TOFExpSigmaEl, tofExpSigmaEl, float); //! Expected resolution with the TOF detector for electron +DECLARE_SOA_COLUMN(TOFExpSigmaMu, tofExpSigmaMu, float); //! Expected resolution with the TOF detector for muon +DECLARE_SOA_COLUMN(TOFExpSigmaPi, tofExpSigmaPi, float); //! Expected resolution with the TOF detector for pion +DECLARE_SOA_COLUMN(TOFExpSigmaKa, tofExpSigmaKa, float); //! Expected resolution with the TOF detector for kaon +DECLARE_SOA_COLUMN(TOFExpSigmaPr, tofExpSigmaPr, float); //! Expected resolution with the TOF detector for proton +DECLARE_SOA_COLUMN(TOFExpSigmaDe, tofExpSigmaDe, float); //! Expected resolution with the TOF detector for deuteron +DECLARE_SOA_COLUMN(TOFExpSigmaTr, tofExpSigmaTr, float); //! Expected resolution with the TOF detector for triton +DECLARE_SOA_COLUMN(TOFExpSigmaHe, tofExpSigmaHe, float); //! Expected resolution with the TOF detector for helium3 +DECLARE_SOA_COLUMN(TOFExpSigmaAl, tofExpSigmaAl, float); //! Expected resolution with the TOF detector for alpha +// NSigma +DECLARE_SOA_COLUMN(TOFNSigmaEl, tofNSigmaEl, float); //! Nsigma separation with the TOF detector for electron +DECLARE_SOA_COLUMN(TOFNSigmaMu, tofNSigmaMu, float); //! Nsigma separation with the TOF detector for muon +DECLARE_SOA_COLUMN(TOFNSigmaPi, tofNSigmaPi, float); //! Nsigma separation with the TOF detector for pion +DECLARE_SOA_COLUMN(TOFNSigmaKa, tofNSigmaKa, float); //! Nsigma separation with the TOF detector for kaon +DECLARE_SOA_COLUMN(TOFNSigmaPr, tofNSigmaPr, float); //! Nsigma separation with the TOF detector for proton +DECLARE_SOA_COLUMN(TOFNSigmaDe, tofNSigmaDe, float); //! Nsigma separation with the TOF detector for deuteron +DECLARE_SOA_COLUMN(TOFNSigmaTr, tofNSigmaTr, float); //! Nsigma separation with the TOF detector for triton +DECLARE_SOA_COLUMN(TOFNSigmaHe, tofNSigmaHe, float); //! Nsigma separation with the TOF detector for helium3 +DECLARE_SOA_COLUMN(TOFNSigmaAl, tofNSigmaAl, float); //! Nsigma separation with the TOF detector for alpha + +} // namespace pidtof + +namespace pidtof_tiny +{ +struct binning { + public: + typedef int8_t binned_t; + static constexpr int nbins = (1 << 8 * sizeof(binned_t)) - 2; + static constexpr binned_t overflowBin = nbins >> 1; + static constexpr binned_t underflowBin = -(nbins >> 1); + static constexpr float binned_max = 6.35; + static constexpr float binned_min = -6.35; + static constexpr float bin_width = (binned_max - binned_min) / nbins; + + // Function to pack a float into a binned value in table + template + static void packInTable(const float& valueToBin, T& table) + { + if (valueToBin <= binned_min) { + table(underflowBin); + } else if (valueToBin >= binned_max) { + table(overflowBin); + } else if (valueToBin >= 0) { + table(static_cast((valueToBin / bin_width) + 0.5f)); + } else { + table(static_cast((valueToBin / bin_width) - 0.5f)); + } + } + + // Function to unpack a binned value into a float + static float unPackInTable(const binned_t& valueToUnpack) + { + return bin_width * static_cast(valueToUnpack); + } +}; + +// NSigma with reduced size 8 bit +DECLARE_SOA_COLUMN(TOFNSigmaStoreEl, tofNSigmaStoreEl, binning::binned_t); //! Stored binned nsigma with the TOF detector for electron +DECLARE_SOA_COLUMN(TOFNSigmaStoreMu, tofNSigmaStoreMu, binning::binned_t); //! Stored binned nsigma with the TOF detector for muon +DECLARE_SOA_COLUMN(TOFNSigmaStorePi, tofNSigmaStorePi, binning::binned_t); //! Stored binned nsigma with the TOF detector for pion +DECLARE_SOA_COLUMN(TOFNSigmaStoreKa, tofNSigmaStoreKa, binning::binned_t); //! Stored binned nsigma with the TOF detector for kaon +DECLARE_SOA_COLUMN(TOFNSigmaStorePr, tofNSigmaStorePr, binning::binned_t); //! Stored binned nsigma with the TOF detector for proton +DECLARE_SOA_COLUMN(TOFNSigmaStoreDe, tofNSigmaStoreDe, binning::binned_t); //! Stored binned nsigma with the TOF detector for deuteron +DECLARE_SOA_COLUMN(TOFNSigmaStoreTr, tofNSigmaStoreTr, binning::binned_t); //! Stored binned nsigma with the TOF detector for triton +DECLARE_SOA_COLUMN(TOFNSigmaStoreHe, tofNSigmaStoreHe, binning::binned_t); //! Stored binned nsigma with the TOF detector for helium3 +DECLARE_SOA_COLUMN(TOFNSigmaStoreAl, tofNSigmaStoreAl, binning::binned_t); //! Stored binned nsigma with the TOF detector for alpha + +// NSigma with reduced size in [binned_min, binned_max] bin size bin_width +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaEl, tofNSigmaEl, //! Unwrapped (float) nsigma with the TOF detector for electron + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaMu, tofNSigmaMu, //! Unwrapped (float) nsigma with the TOF detector for muon + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPi, tofNSigmaPi, //! Unwrapped (float) nsigma with the TOF detector for pion + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaKa, tofNSigmaKa, //! Unwrapped (float) nsigma with the TOF detector for kaon + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPr, tofNSigmaPr, //! Unwrapped (float) nsigma with the TOF detector for proton + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaDe, tofNSigmaDe, //! Unwrapped (float) nsigma with the TOF detector for deuteron + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaTr, tofNSigmaTr, //! Unwrapped (float) nsigma with the TOF detector for triton + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaHe, tofNSigmaHe, //! Unwrapped (float) nsigma with the TOF detector for helium3 + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaAl, tofNSigmaAl, //! Unwrapped (float) nsigma with the TOF detector for alpha + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); + +} // namespace pidtof_tiny + +// Per particle tables +DECLARE_SOA_TABLE(pidTOFFullEl, "AOD", "pidTOFFullEl", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for electron + pidtof::TOFExpSignalDiffEl, + pidtof::TOFExpSignalEl, + pidtof::TOFExpSigmaEl, pidtof::TOFNSigmaEl); +DECLARE_SOA_TABLE(pidTOFFullMu, "AOD", "pidTOFFullMu", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for muon + pidtof::TOFExpSignalDiffMu, + pidtof::TOFExpSignalMu, + pidtof::TOFExpSigmaMu, pidtof::TOFNSigmaMu); +DECLARE_SOA_TABLE(pidTOFFullPi, "AOD", "pidTOFFullPi", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for pion + pidtof::TOFExpSignalDiffPi, + pidtof::TOFExpSignalPi, + pidtof::TOFExpSigmaPi, pidtof::TOFNSigmaPi); +DECLARE_SOA_TABLE(pidTOFFullKa, "AOD", "pidTOFFullKa", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for kaon + pidtof::TOFExpSignalDiffKa, + pidtof::TOFExpSignalKa, + pidtof::TOFExpSigmaKa, pidtof::TOFNSigmaKa); +DECLARE_SOA_TABLE(pidTOFFullPr, "AOD", "pidTOFFullPr", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for proton + pidtof::TOFExpSignalDiffPr, + pidtof::TOFExpSignalPr, + pidtof::TOFExpSigmaPr, pidtof::TOFNSigmaPr); +DECLARE_SOA_TABLE(pidTOFFullDe, "AOD", "pidTOFFullDe", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for deuteron + pidtof::TOFExpSignalDiffDe, + pidtof::TOFExpSignalDe, + pidtof::TOFExpSigmaDe, pidtof::TOFNSigmaDe); +DECLARE_SOA_TABLE(pidTOFFullTr, "AOD", "pidTOFFullTr", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for triton + pidtof::TOFExpSignalDiffTr, + pidtof::TOFExpSignalTr, + pidtof::TOFExpSigmaTr, pidtof::TOFNSigmaTr); +DECLARE_SOA_TABLE(pidTOFFullHe, "AOD", "pidTOFFullHe", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for helium3 + pidtof::TOFExpSignalDiffHe, + pidtof::TOFExpSignalHe, + pidtof::TOFExpSigmaHe, pidtof::TOFNSigmaHe); +DECLARE_SOA_TABLE(pidTOFFullAl, "AOD", "pidTOFFullAl", //! Table of the TOF (full) response with expected signal, expected resolution and Nsigma for alpha + pidtof::TOFExpSignalDiffAl, + pidtof::TOFExpSignalAl, + pidtof::TOFExpSigmaAl, pidtof::TOFNSigmaAl); + +// Tiny size tables +DECLARE_SOA_TABLE(pidTOFEl, "AOD", "pidTOFEl", //! Table of the TOF response with binned Nsigma for electron + pidtof_tiny::TOFNSigmaStoreEl, pidtof_tiny::TOFNSigmaEl); +DECLARE_SOA_TABLE(pidTOFMu, "AOD", "pidTOFMu", //! Table of the TOF response with binned Nsigma for muon + pidtof_tiny::TOFNSigmaStoreMu, pidtof_tiny::TOFNSigmaMu); +DECLARE_SOA_TABLE(pidTOFPi, "AOD", "pidTOFPi", //! Table of the TOF response with binned Nsigma for pion + pidtof_tiny::TOFNSigmaStorePi, pidtof_tiny::TOFNSigmaPi); +DECLARE_SOA_TABLE(pidTOFKa, "AOD", "pidTOFKa", //! Table of the TOF response with binned Nsigma for kaon + pidtof_tiny::TOFNSigmaStoreKa, pidtof_tiny::TOFNSigmaKa); +DECLARE_SOA_TABLE(pidTOFPr, "AOD", "pidTOFPr", //! Table of the TOF response with binned Nsigma for proton + pidtof_tiny::TOFNSigmaStorePr, pidtof_tiny::TOFNSigmaPr); +DECLARE_SOA_TABLE(pidTOFDe, "AOD", "pidTOFDe", //! Table of the TOF response with binned Nsigma for deuteron + pidtof_tiny::TOFNSigmaStoreDe, pidtof_tiny::TOFNSigmaDe); +DECLARE_SOA_TABLE(pidTOFTr, "AOD", "pidTOFTr", //! Table of the TOF response with binned Nsigma for triton + pidtof_tiny::TOFNSigmaStoreTr, pidtof_tiny::TOFNSigmaTr); +DECLARE_SOA_TABLE(pidTOFHe, "AOD", "pidTOFHe", //! Table of the TOF response with binned Nsigma for helium3 + pidtof_tiny::TOFNSigmaStoreHe, pidtof_tiny::TOFNSigmaHe); +DECLARE_SOA_TABLE(pidTOFAl, "AOD", "pidTOFAl", //! Table of the TOF response with binned Nsigma for alpha + pidtof_tiny::TOFNSigmaStoreAl, pidtof_tiny::TOFNSigmaAl); + +namespace pidtofbeta +{ +DECLARE_SOA_COLUMN(Beta, beta, float); //! TOF beta +DECLARE_SOA_COLUMN(BetaError, betaerror, float); //! Uncertainty on the TOF beta +// Dynamic column, i.e. the future +DECLARE_SOA_DYNAMIC_COLUMN(TOFBetaImp, tofBeta, //! TOF Beta value + [](const float length, const float tofSignal, const float collisionTime) -> float { + return o2::pid::tof::Beta::GetBeta(length, tofSignal, collisionTime); + }); +// +DECLARE_SOA_COLUMN(ExpBetaEl, expbetael, float); //! Expected beta of electron +DECLARE_SOA_COLUMN(ExpBetaElError, expbetaelerror, float); //! Expected uncertainty on the beta of electron +// +DECLARE_SOA_COLUMN(SeparationBetaEl, separationbetael, float); //! Separation computed with the expected beta for electrons +DECLARE_SOA_DYNAMIC_COLUMN(DiffBetaEl, diffbetael, //! Difference between the measured and the expected beta for electrons + [](float beta, float expbetael) -> float { return beta - expbetael; }); +} // namespace pidtofbeta + +using TOFBeta = pidtofbeta::TOFBetaImp; + +DECLARE_SOA_TABLE(pidTOFbeta, "AOD", "pidTOFbeta", //! Table of the TOF beta + pidtofbeta::Beta, pidtofbeta::BetaError); + +namespace pidtofmass +{ +DECLARE_SOA_COLUMN(TOFMass, mass, float); //! TOF mass +// Dynamic column, i.e. the future +DECLARE_SOA_DYNAMIC_COLUMN(TOFMassImp, tofMass, //! TOF Mass value + [](const float length, const float tofSignal, const float collisionTime, const float momentum) -> float { + const float beta = o2::pid::tof::Beta::GetBeta(length, tofSignal, collisionTime); + return o2::pid::tof::TOFMass::GetTOFMass(momentum, beta); + }); +} // namespace pidtofmass + +using TOFMass = pidtofmass::TOFMassImp; + +DECLARE_SOA_TABLE(pidTOFmass, "AOD", "pidTOFmass", //! Table of the TOF mass + pidtofmass::TOFMass); + +} // namespace o2::aod + +#endif // COMMON_DATAMODEL_PIDRESPONSETOF_H_ diff --git a/Common/DataModel/PIDResponseTPC.h b/Common/DataModel/PIDResponseTPC.h new file mode 100644 index 00000000000..a22d5c9c008 --- /dev/null +++ b/Common/DataModel/PIDResponseTPC.h @@ -0,0 +1,411 @@ +// 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. + +/// +/// \file PIDResponseTPC.h +/// \since 2024-11-15 +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \brief Set of tables, tasks and utilities to provide the interface between +/// the analysis data model and the PID response of the TPC +/// + +#ifndef COMMON_DATAMODEL_PIDRESPONSETPC_H_ +#define COMMON_DATAMODEL_PIDRESPONSETPC_H_ + +#include + +// O2 includes +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "ReconstructionDataFormats/PID.h" +#include "Framework/Logger.h" + +namespace o2::aod +{ +namespace pidutils +{ + +// Checkers for TPC PID hypothesis availability (runtime) +template +using hasTPCEl = decltype(std::declval().tpcNSigmaEl()); +template +using hasTPCMu = decltype(std::declval().tpcNSigmaMu()); +template +using hasTPCPi = decltype(std::declval().tpcNSigmaPi()); +template +using hasTPCKa = decltype(std::declval().tpcNSigmaKa()); +template +using hasTPCPr = decltype(std::declval().tpcNSigmaPr()); +template +using hasTPCDe = decltype(std::declval().tpcNSigmaDe()); +template +using hasTPCTr = decltype(std::declval().tpcNSigmaTr()); +template +using hasTPCHe = decltype(std::declval().tpcNSigmaHe()); +template +using hasTPCAl = decltype(std::declval().tpcNSigmaAl()); + +// PID index as template argument +#define perSpeciesWrapper(functionName) \ + template \ + auto functionName(const TrackType& track) \ + { \ + if constexpr (index == o2::track::PID::Electron) { \ + return track.functionName##El(); \ + } else if constexpr (index == o2::track::PID::Muon) { \ + return track.functionName##Mu(); \ + } else if constexpr (index == o2::track::PID::Pion) { \ + return track.functionName##Pi(); \ + } else if constexpr (index == o2::track::PID::Kaon) { \ + return track.functionName##Ka(); \ + } else if constexpr (index == o2::track::PID::Proton) { \ + return track.functionName##Pr(); \ + } else if constexpr (index == o2::track::PID::Deuteron) { \ + return track.functionName##De(); \ + } else if constexpr (index == o2::track::PID::Triton) { \ + return track.functionName##Tr(); \ + } else if constexpr (index == o2::track::PID::Helium3) { \ + return track.functionName##He(); \ + } else if constexpr (index == o2::track::PID::Alpha) { \ + return track.functionName##Al(); \ + } \ + } + +perSpeciesWrapper(tpcNSigma); +perSpeciesWrapper(tpcExpSigma); +template +auto tpcExpSignal(const TrackType& track) +{ + if constexpr (index == o2::track::PID::Electron) { + return track.tpcExpSignalEl(track.tpcSignal()); + } else if constexpr (index == o2::track::PID::Muon) { + return track.tpcExpSignalMu(track.tpcSignal()); + } else if constexpr (index == o2::track::PID::Pion) { + return track.tpcExpSignalPi(track.tpcSignal()); + } else if constexpr (index == o2::track::PID::Kaon) { + return track.tpcExpSignalKa(track.tpcSignal()); + } else if constexpr (index == o2::track::PID::Proton) { + return track.tpcExpSignalPr(track.tpcSignal()); + } else if constexpr (index == o2::track::PID::Deuteron) { + return track.tpcExpSignalDe(track.tpcSignal()); + } else if constexpr (index == o2::track::PID::Triton) { + return track.tpcExpSignalTr(track.tpcSignal()); + } else if constexpr (index == o2::track::PID::Helium3) { + return track.tpcExpSignalHe(track.tpcSignal()); + } else if constexpr (index == o2::track::PID::Alpha) { + return track.tpcExpSignalAl(track.tpcSignal()); + } +} +perSpeciesWrapper(tpcExpSignalDiff); + +#undef perSpeciesWrapper + +// PID index as function argument for TPC +#define perSpeciesWrapper(functionName) \ + template \ + auto functionName(const o2::track::PID::ID index, const TrackType& track) \ + { \ + switch (index) { \ + case o2::track::PID::Electron: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##El(); \ + } \ + case o2::track::PID::Muon: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Mu(); \ + } \ + case o2::track::PID::Pion: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Pi(); \ + } \ + case o2::track::PID::Kaon: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Ka(); \ + } \ + case o2::track::PID::Proton: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Pr(); \ + } \ + case o2::track::PID::Deuteron: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##De(); \ + } \ + case o2::track::PID::Triton: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Tr(); \ + } \ + case o2::track::PID::Helium3: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##He(); \ + } \ + case o2::track::PID::Alpha: \ + if constexpr (std::experimental::is_detected::value) { \ + return track.functionName##Al(); \ + } \ + default: \ + LOGF(fatal, "TPC PID table for PID index %i (%s) is not available", index, o2::track::PID::getName(index)); \ + return 0.f; \ + } \ + } + +perSpeciesWrapper(tpcNSigma); +perSpeciesWrapper(tpcExpSigma); +template +auto tpcExpSignal(const o2::track::PID::ID index, const TrackType& track) +{ + switch (index) { + case o2::track::PID::Electron: + if constexpr (std::experimental::is_detected::value) { + return track.tpcExpSignalEl(track.tpcSignal()); + } + case o2::track::PID::Muon: + if constexpr (std::experimental::is_detected::value) { + return track.tpcExpSignalMu(track.tpcSignal()); + } + case o2::track::PID::Pion: + if constexpr (std::experimental::is_detected::value) { + return track.tpcExpSignalPi(track.tpcSignal()); + } + case o2::track::PID::Kaon: + if constexpr (std::experimental::is_detected::value) { + return track.tpcExpSignalKa(track.tpcSignal()); + } + case o2::track::PID::Proton: + if constexpr (std::experimental::is_detected::value) { + return track.tpcExpSignalPr(track.tpcSignal()); + } + case o2::track::PID::Deuteron: + if constexpr (std::experimental::is_detected::value) { + return track.tpcExpSignalDe(track.tpcSignal()); + } + case o2::track::PID::Triton: + if constexpr (std::experimental::is_detected::value) { + return track.tpcExpSignalTr(track.tpcSignal()); + } + case o2::track::PID::Helium3: + if constexpr (std::experimental::is_detected::value) { + return track.tpcExpSignalHe(track.tpcSignal()); + } + case o2::track::PID::Alpha: + if constexpr (std::experimental::is_detected::value) { + return track.tpcExpSignalAl(track.tpcSignal()); + } + default: + LOGF(fatal, "TPC PID table for PID index %i (%s) is not available", index, o2::track::PID::getName(index)); + return 0.f; + } +} +perSpeciesWrapper(tpcExpSignalDiff); + +#undef perSpeciesWrapper + +} // namespace pidutils + +namespace pidtpc +{ +// Expected signals +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalEl, tpcExpSignalEl, //! Expected signal with the TPC detector for electron + [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalMu, tpcExpSignalMu, //! Expected signal with the TPC detector for muon + [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalPi, tpcExpSignalPi, //! Expected signal with the TPC detector for pion + [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalKa, tpcExpSignalKa, //! Expected signal with the TPC detector for kaon + [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalPr, tpcExpSignalPr, //! Expected signal with the TPC detector for proton + [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDe, tpcExpSignalDe, //! Expected signal with the TPC detector for deuteron + [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalTr, tpcExpSignalTr, //! Expected signal with the TPC detector for triton + [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalHe, tpcExpSignalHe, //! Expected signal with the TPC detector for helium3 + [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalAl, tpcExpSignalAl, //! Expected signal with the TPC detector for alpha + [](float nsigma, float sigma, float tpcsignal) -> float { return tpcsignal - nsigma * sigma; }); +// Delta with respect to signal +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffEl, tpcExpSignalDiffEl, //! Difference between signal and expected for electron + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffMu, tpcExpSignalDiffMu, //! Difference between signal and expected for muon + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffPi, tpcExpSignalDiffPi, //! Difference between signal and expected for pion + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffKa, tpcExpSignalDiffKa, //! Difference between signal and expected for kaon + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffPr, tpcExpSignalDiffPr, //! Difference between signal and expected for proton + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffDe, tpcExpSignalDiffDe, //! Difference between signal and expected for deuteron + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffTr, tpcExpSignalDiffTr, //! Difference between signal and expected for triton + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffHe, tpcExpSignalDiffHe, //! Difference between signal and expected for helium3 + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCExpSignalDiffAl, tpcExpSignalDiffAl, //! Difference between signal and expected for alpha + [](float nsigma, float sigma) -> float { return nsigma * sigma; }); +// Expected sigma +DECLARE_SOA_COLUMN(TPCExpSigmaEl, tpcExpSigmaEl, float); //! Expected resolution with the TPC detector for electron +DECLARE_SOA_COLUMN(TPCExpSigmaMu, tpcExpSigmaMu, float); //! Expected resolution with the TPC detector for muon +DECLARE_SOA_COLUMN(TPCExpSigmaPi, tpcExpSigmaPi, float); //! Expected resolution with the TPC detector for pion +DECLARE_SOA_COLUMN(TPCExpSigmaKa, tpcExpSigmaKa, float); //! Expected resolution with the TPC detector for kaon +DECLARE_SOA_COLUMN(TPCExpSigmaPr, tpcExpSigmaPr, float); //! Expected resolution with the TPC detector for proton +DECLARE_SOA_COLUMN(TPCExpSigmaDe, tpcExpSigmaDe, float); //! Expected resolution with the TPC detector for deuteron +DECLARE_SOA_COLUMN(TPCExpSigmaTr, tpcExpSigmaTr, float); //! Expected resolution with the TPC detector for triton +DECLARE_SOA_COLUMN(TPCExpSigmaHe, tpcExpSigmaHe, float); //! Expected resolution with the TPC detector for helium3 +DECLARE_SOA_COLUMN(TPCExpSigmaAl, tpcExpSigmaAl, float); //! Expected resolution with the TPC detector for alpha +// NSigma +DECLARE_SOA_COLUMN(TPCNSigmaEl, tpcNSigmaEl, float); //! Nsigma separation with the TPC detector for electron +DECLARE_SOA_COLUMN(TPCNSigmaMu, tpcNSigmaMu, float); //! Nsigma separation with the TPC detector for muon +DECLARE_SOA_COLUMN(TPCNSigmaPi, tpcNSigmaPi, float); //! Nsigma separation with the TPC detector for pion +DECLARE_SOA_COLUMN(TPCNSigmaKa, tpcNSigmaKa, float); //! Nsigma separation with the TPC detector for kaon +DECLARE_SOA_COLUMN(TPCNSigmaPr, tpcNSigmaPr, float); //! Nsigma separation with the TPC detector for proton +DECLARE_SOA_COLUMN(TPCNSigmaDe, tpcNSigmaDe, float); //! Nsigma separation with the TPC detector for deuteron +DECLARE_SOA_COLUMN(TPCNSigmaTr, tpcNSigmaTr, float); //! Nsigma separation with the TPC detector for triton +DECLARE_SOA_COLUMN(TPCNSigmaHe, tpcNSigmaHe, float); //! Nsigma separation with the TPC detector for helium3 +DECLARE_SOA_COLUMN(TPCNSigmaAl, tpcNSigmaAl, float); //! Nsigma separation with the TPC detector for alpha + +} // namespace pidtpc + +namespace pidtpc_tiny +{ +struct binning { + public: + typedef int8_t binned_t; + static constexpr int nbins = (1 << 8 * sizeof(binned_t)) - 2; + static constexpr binned_t overflowBin = nbins >> 1; + static constexpr binned_t underflowBin = -(nbins >> 1); + static constexpr float binned_max = 6.35; + static constexpr float binned_min = -6.35; + static constexpr float bin_width = (binned_max - binned_min) / nbins; + + // Function to pack a float into a binned value in table + template + static void packInTable(const float& valueToBin, T& table) + { + if (valueToBin <= binned_min) { + table(underflowBin); + } else if (valueToBin >= binned_max) { + table(overflowBin); + } else if (valueToBin >= 0) { + table(static_cast((valueToBin / bin_width) + 0.5f)); + } else { + table(static_cast((valueToBin / bin_width) - 0.5f)); + } + } + + // Function to unpack a binned value into a float + static float unPackInTable(const binned_t& valueToUnpack) + { + return bin_width * static_cast(valueToUnpack); + } +}; + +// NSigma with reduced size 8 bit +DECLARE_SOA_COLUMN(TPCNSigmaStoreEl, tpcNSigmaStoreEl, binning::binned_t); //! Stored binned nsigma with the TPC detector for electron +DECLARE_SOA_COLUMN(TPCNSigmaStoreMu, tpcNSigmaStoreMu, binning::binned_t); //! Stored binned nsigma with the TPC detector for muon +DECLARE_SOA_COLUMN(TPCNSigmaStorePi, tpcNSigmaStorePi, binning::binned_t); //! Stored binned nsigma with the TPC detector for pion +DECLARE_SOA_COLUMN(TPCNSigmaStoreKa, tpcNSigmaStoreKa, binning::binned_t); //! Stored binned nsigma with the TPC detector for kaon +DECLARE_SOA_COLUMN(TPCNSigmaStorePr, tpcNSigmaStorePr, binning::binned_t); //! Stored binned nsigma with the TPC detector for proton +DECLARE_SOA_COLUMN(TPCNSigmaStoreDe, tpcNSigmaStoreDe, binning::binned_t); //! Stored binned nsigma with the TPC detector for deuteron +DECLARE_SOA_COLUMN(TPCNSigmaStoreTr, tpcNSigmaStoreTr, binning::binned_t); //! Stored binned nsigma with the TPC detector for triton +DECLARE_SOA_COLUMN(TPCNSigmaStoreHe, tpcNSigmaStoreHe, binning::binned_t); //! Stored binned nsigma with the TPC detector for helium3 +DECLARE_SOA_COLUMN(TPCNSigmaStoreAl, tpcNSigmaStoreAl, binning::binned_t); //! Stored binned nsigma with the TPC detector for alpha + +// NSigma with reduced size in [binned_min, binned_max] bin size bin_width +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaEl, tpcNSigmaEl, //! Unwrapped (float) nsigma with the TPC detector for electron + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaMu, tpcNSigmaMu, //! Unwrapped (float) nsigma with the TPC detector for muon + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPi, tpcNSigmaPi, //! Unwrapped (float) nsigma with the TPC detector for pion + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaKa, tpcNSigmaKa, //! Unwrapped (float) nsigma with the TPC detector for kaon + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPr, tpcNSigmaPr, //! Unwrapped (float) nsigma with the TPC detector for proton + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaDe, tpcNSigmaDe, //! Unwrapped (float) nsigma with the TPC detector for deuteron + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaTr, tpcNSigmaTr, //! Unwrapped (float) nsigma with the TPC detector for triton + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaHe, tpcNSigmaHe, //! Unwrapped (float) nsigma with the TPC detector for helium3 + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaAl, tpcNSigmaAl, //! Unwrapped (float) nsigma with the TPC detector for alpha + [](binning::binned_t nsigma_binned) -> float { return binning::unPackInTable(nsigma_binned); }); + +} // namespace pidtpc_tiny + +// Per particle tables +DECLARE_SOA_TABLE(pidTPCFullEl, "AOD", "pidTPCFullEl", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for electron + pidtpc::TPCExpSignalEl, + pidtpc::TPCExpSignalDiffEl, + pidtpc::TPCExpSigmaEl, pidtpc::TPCNSigmaEl); +DECLARE_SOA_TABLE(pidTPCFullMu, "AOD", "pidTPCFullMu", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for muon + pidtpc::TPCExpSignalMu, + pidtpc::TPCExpSignalDiffMu, + pidtpc::TPCExpSigmaMu, pidtpc::TPCNSigmaMu); +DECLARE_SOA_TABLE(pidTPCFullPi, "AOD", "pidTPCFullPi", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for pion + pidtpc::TPCExpSignalPi, + pidtpc::TPCExpSignalDiffPi, + pidtpc::TPCExpSigmaPi, pidtpc::TPCNSigmaPi); +DECLARE_SOA_TABLE(pidTPCFullKa, "AOD", "pidTPCFullKa", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for kaon + pidtpc::TPCExpSignalKa, + pidtpc::TPCExpSignalDiffKa, + pidtpc::TPCExpSigmaKa, pidtpc::TPCNSigmaKa); +DECLARE_SOA_TABLE(pidTPCFullPr, "AOD", "pidTPCFullPr", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for proton + pidtpc::TPCExpSignalPr, + pidtpc::TPCExpSignalDiffPr, + pidtpc::TPCExpSigmaPr, pidtpc::TPCNSigmaPr); +DECLARE_SOA_TABLE(pidTPCFullDe, "AOD", "pidTPCFullDe", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for deuteron + pidtpc::TPCExpSignalDe, + pidtpc::TPCExpSignalDiffDe, + pidtpc::TPCExpSigmaDe, pidtpc::TPCNSigmaDe); +DECLARE_SOA_TABLE(pidTPCFullTr, "AOD", "pidTPCFullTr", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for triton + pidtpc::TPCExpSignalTr, + pidtpc::TPCExpSignalDiffTr, + pidtpc::TPCExpSigmaTr, pidtpc::TPCNSigmaTr); +DECLARE_SOA_TABLE(pidTPCFullHe, "AOD", "pidTPCFullHe", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for helium3 + pidtpc::TPCExpSignalHe, + pidtpc::TPCExpSignalDiffHe, + pidtpc::TPCExpSigmaHe, pidtpc::TPCNSigmaHe); +DECLARE_SOA_TABLE(pidTPCFullAl, "AOD", "pidTPCFullAl", //! Table of the TPC (full) response with expected signal, expected resolution and Nsigma for alpha + pidtpc::TPCExpSignalAl, + pidtpc::TPCExpSignalDiffAl, + pidtpc::TPCExpSigmaAl, pidtpc::TPCNSigmaAl); + +// Tiny size tables +DECLARE_SOA_TABLE(pidTPCEl, "AOD", "pidTPCEl", //! Table of the TPC response with binned Nsigma for electron + pidtpc_tiny::TPCNSigmaStoreEl, pidtpc_tiny::TPCNSigmaEl); +DECLARE_SOA_TABLE(pidTPCMu, "AOD", "pidTPCMu", //! Table of the TPC response with binned Nsigma for muon + pidtpc_tiny::TPCNSigmaStoreMu, pidtpc_tiny::TPCNSigmaMu); +DECLARE_SOA_TABLE(pidTPCPi, "AOD", "pidTPCPi", //! Table of the TPC response with binned Nsigma for pion + pidtpc_tiny::TPCNSigmaStorePi, pidtpc_tiny::TPCNSigmaPi); +DECLARE_SOA_TABLE(pidTPCKa, "AOD", "pidTPCKa", //! Table of the TPC response with binned Nsigma for kaon + pidtpc_tiny::TPCNSigmaStoreKa, pidtpc_tiny::TPCNSigmaKa); +DECLARE_SOA_TABLE(pidTPCPr, "AOD", "pidTPCPr", //! Table of the TPC response with binned Nsigma for proton + pidtpc_tiny::TPCNSigmaStorePr, pidtpc_tiny::TPCNSigmaPr); +DECLARE_SOA_TABLE(pidTPCDe, "AOD", "pidTPCDe", //! Table of the TPC response with binned Nsigma for deuteron + pidtpc_tiny::TPCNSigmaStoreDe, pidtpc_tiny::TPCNSigmaDe); +DECLARE_SOA_TABLE(pidTPCTr, "AOD", "pidTPCTr", //! Table of the TPC response with binned Nsigma for triton + pidtpc_tiny::TPCNSigmaStoreTr, pidtpc_tiny::TPCNSigmaTr); +DECLARE_SOA_TABLE(pidTPCHe, "AOD", "pidTPCHe", //! Table of the TPC response with binned Nsigma for helium3 + pidtpc_tiny::TPCNSigmaStoreHe, pidtpc_tiny::TPCNSigmaHe); +DECLARE_SOA_TABLE(pidTPCAl, "AOD", "pidTPCAl", //! Table of the TPC response with binned Nsigma for alpha + pidtpc_tiny::TPCNSigmaStoreAl, pidtpc_tiny::TPCNSigmaAl); + +// Extra tables +namespace mcpidtpc +{ +// Tuned MC on data +DECLARE_SOA_COLUMN(DeDxTunedMc, mcTunedTPCSignal, float); //! TPC signal after TuneOnData application for MC +} // namespace mcpidtpc + +DECLARE_SOA_TABLE(mcTPCTuneOnData, "AOD", "MCTPCTUNEONDATA", mcpidtpc::DeDxTunedMc); + +} // namespace o2::aod + +#endif // COMMON_DATAMODEL_PIDRESPONSETPC_H_ diff --git a/Common/DataModel/PmdTable.h b/Common/DataModel/PmdTable.h new file mode 100644 index 00000000000..fe1cb14018e --- /dev/null +++ b/Common/DataModel/PmdTable.h @@ -0,0 +1,36 @@ +// 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. +/// +/// \file PmdTable.h +/// +/// \brief pmd index table define +/// \author Abhi Modak (abhi.modak@cern.ch) +/// \since May 17, 2025 + +#ifndef COMMON_DATAMODEL_PMDTABLE_H_ +#define COMMON_DATAMODEL_PMDTABLE_H_ + +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace pmdtrack +{ +DECLARE_SOA_INDEX_COLUMN(Collision, collision); +DECLARE_SOA_ARRAY_INDEX_COLUMN(Collision, collisions); +DECLARE_SOA_INDEX_COLUMN(BC, bc); +DECLARE_SOA_SLICE_INDEX_COLUMN(Pmd, pmd); +} // namespace pmdtrack + +DECLARE_SOA_INDEX_TABLE_USER(PMDTracksIndex, BCs, "PMDTRKIDX", pmdtrack::CollisionId, pmdtrack::BCId, pmdtrack::PmdIdSlice); +} // namespace o2::aod + +#endif // COMMON_DATAMODEL_PMDTABLE_H_ diff --git a/Common/DataModel/SelectionStudyTables.h b/Common/DataModel/SelectionStudyTables.h new file mode 100644 index 00000000000..3a62c30b267 --- /dev/null +++ b/Common/DataModel/SelectionStudyTables.h @@ -0,0 +1,57 @@ +// 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. + +/// \file SelectionStudyTables +/// \brief tables meant to do event selection studies for O-O / light systems +/// +/// \author ALICE + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" + +#include + +#ifndef COMMON_DATAMODEL_SELECTIONSTUDYTABLES_H_ +#define COMMON_DATAMODEL_SELECTIONSTUDYTABLES_H_ + +namespace o2::aod +{ +namespace selectionstudy +{ +DECLARE_SOA_COLUMN(PtPions, ptPions, std::vector); +DECLARE_SOA_COLUMN(PtKaons, ptKaons, std::vector); +DECLARE_SOA_COLUMN(PtProtons, ptProtons, std::vector); +DECLARE_SOA_COLUMN(PtK0s, ptPK0s, std::vector); +DECLARE_SOA_COLUMN(PtLambdas, ptLambdas, std::vector); +DECLARE_SOA_COLUMN(PtXis, ptXis, std::vector); +DECLARE_SOA_COLUMN(PtOmegas, ptOmegas, std::vector); +DECLARE_SOA_COLUMN(PtPhis, ptPhis, std::vector); +DECLARE_SOA_COLUMN(PtKStars, ptKStars, std::vector); +DECLARE_SOA_COLUMN(PtDs, ptDs, std::vector); +DECLARE_SOA_COLUMN(PtLambdaCs, ptLambdaCs, std::vector); +DECLARE_SOA_COLUMN(PtJPsis, ptJPsis, std::vector); +} // namespace selectionstudy + +DECLARE_SOA_TABLE(PIDPts, "AOD", "PIDPTS", o2::soa::Index<>, + o2::aod::selectionstudy::PtPions, + o2::aod::selectionstudy::PtKaons, + o2::aod::selectionstudy::PtProtons, + o2::aod::selectionstudy::PtK0s, + o2::aod::selectionstudy::PtLambdas, + o2::aod::selectionstudy::PtXis, + o2::aod::selectionstudy::PtOmegas, + o2::aod::selectionstudy::PtPhis, + o2::aod::selectionstudy::PtKStars, + o2::aod::selectionstudy::PtDs, + o2::aod::selectionstudy::PtLambdaCs, + o2::aod::selectionstudy::PtJPsis); +} // namespace o2::aod +#endif // COMMON_DATAMODEL_SELECTIONSTUDYTABLES_H_ diff --git a/Common/DataModel/ZDCInterCalib.h b/Common/DataModel/ZDCInterCalib.h index 290a3ac61fe..d7b66575340 100644 --- a/Common/DataModel/ZDCInterCalib.h +++ b/Common/DataModel/ZDCInterCalib.h @@ -20,21 +20,23 @@ namespace o2::aod { -namespace znoutput +namespace znoutput // o2-linter: disable=name/workflow-file { -DECLARE_SOA_COLUMN(ZNApmc, commonPMZNA, float); //! PMC ZNA // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNApm1, ZNAPM1, float); //! PM1 ZNA // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNApm2, ZNAPM2, float); //! PM2 ZNA // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNApm3, ZNAPM3, float); //! PM3 ZNA // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNApm4, ZNAPM4, float); //! PM4 ZNA // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNAtdc, ZNATDC, float); //! TDC ZNA // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNCpmc, commonPMZNC, float); //! PMC ZNC // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNCpm1, ZNCPM1, float); //! PM1 ZNC // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNCpm2, ZNCPM2, float); //! PM2 ZNC // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNCpm3, ZNCPM3, float); //! PM3 ZNC // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNCpm4, ZNCPM4, float); //! PM4 ZNC // o2-linter: disable=name/o2-column -DECLARE_SOA_COLUMN(ZNCtdc, ZNCTDC, float); //! TDC ZNC // o2-linter: disable=name/o2-column - +DECLARE_SOA_COLUMN(ZNApmc, commonPMZNA, float); //! PMC ZNA // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNApm1, ZNAPM1, float); //! PM1 ZNA // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNApm2, ZNAPM2, float); //! PM2 ZNA // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNApm3, ZNAPM3, float); //! PM3 ZNA // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNApm4, ZNAPM4, float); //! PM4 ZNA // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNAtdc, ZNATDC, float); //! TDC ZNA // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNCpmc, commonPMZNC, float); //! PMC ZNC // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNCpm1, ZNCPM1, float); //! PM1 ZNC // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNCpm2, ZNCPM2, float); //! PM2 ZNC // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNCpm3, ZNCPM3, float); //! PM3 ZNC // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNCpm4, ZNCPM4, float); //! PM4 ZNC // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZNCtdc, ZNCTDC, float); //! TDC ZNC // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(Centrality, centrality, float); //! Centrality +DECLARE_SOA_COLUMN(Timestamp, timestamp, uint64_t); //! Timestamp +DECLARE_SOA_COLUMN(SelectionBits, selectionBits, uint8_t); //! Selection Flags } // namespace znoutput DECLARE_SOA_TABLE(ZDCInterCalib, "AOD", "ZDCIC", o2::soa::Index<>, @@ -49,7 +51,10 @@ DECLARE_SOA_TABLE(ZDCInterCalib, "AOD", "ZDCIC", o2::soa::Index<>, znoutput::ZNCpm2, znoutput::ZNCpm3, znoutput::ZNCpm4, - znoutput::ZNCtdc); + znoutput::ZNCtdc, + znoutput::Centrality, + znoutput::Timestamp, + znoutput::SelectionBits); } // namespace o2::aod #endif // COMMON_DATAMODEL_ZDCINTERCALIB_H_ diff --git a/Common/LegacyDataQA/CMakeLists.txt b/Common/LegacyDataQA/CMakeLists.txt index c40882e2376..e23c1f7c29c 100644 --- a/Common/LegacyDataQA/CMakeLists.txt +++ b/Common/LegacyDataQA/CMakeLists.txt @@ -22,4 +22,14 @@ o2physics_add_dpl_workflow(centqa o2physics_add_dpl_workflow(tpcpidqa SOURCES tpcpidqa.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore - COMPONENT_NAME Analysis) \ No newline at end of file + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(pmd-qa + SOURCES pmdQa.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(pcm-run2 + SOURCES pcmRun2.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/Common/LegacyDataQA/pcmRun2.cxx b/Common/LegacyDataQA/pcmRun2.cxx new file mode 100644 index 00000000000..87032dd96d3 --- /dev/null +++ b/Common/LegacyDataQA/pcmRun2.cxx @@ -0,0 +1,314 @@ +// 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. + +/// \file pcmRun2.cxx +/// \brief Analysis using PCM photons from Run2 +/// \author M. Hemmer, marvin.hemmer@cern.ch + +#include "Common/DataModel/PIDResponseTPC.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +struct PcmRun2 { + struct : ConfigurableGroup { + std::string prefix = "trackcuts"; + Configurable tpcFindOverFoundable{"tpcFindOverFoundable", 0.6, "Ratio of number of found TPC clusters to the number of foundable TPC clusters a track must have at least."}; + Configurable minPt{"minPt", 0.05, "Minimum pT cut for the tracks."}; + } trackcuts; + + struct : ConfigurableGroup { + std::string prefix = "pidcuts"; + Configurable minNSigmaEl{"minNSigmaEl", -3., "Minimum NSgimal electron allowed for V0 leg."}; + Configurable maxNSigmaEl{"maxNSigmaEl", +4., "Maximum NSgimal electron allowed for V0 leg."}; + Configurable doPionRejection{"doPionRejection", true, "Flag to enable pion rejection based on TPC PID for V0 legs."}; + Configurable minNSigmaPiLowP{"minNSigmaPiLowP", 1., "Minimum NSgimal pion to reject V0 legs for low 0.4 < pT/(GeV/c) < 3.5."}; + Configurable minNSigmaPiHighP{"minNSigmaPiHighP", +0.5, "Minimum NSgimal pion to reject V0 legs for pT > 3.5 GeV/c."}; + } pidcuts; + + struct : ConfigurableGroup { + std::string prefix = "v0cuts"; + Configurable minPt{"minPt", 0.02, "Minimum pT cut for the V0."}; + Configurable maxEta{"maxEta", 0.8, "Maximum absolut pseudorapidity cut for the V0."}; + Configurable maxZconv{"maxZconv", 0.8, "Maximum absolut z conversion position cut for the V0."}; + Configurable qTFactor{"qTFactor", 0.125, "qT < this * pT"}; + Configurable cosP{"cosP", 0.85, "cos of pointing angle > this value."}; + Configurable rejectTooCloseV0{"rejectTooCloseV0", true, "."}; + } v0cuts; + + using TracksWithPID = soa::Join; + + SliceCache cache; + Preslice perCollisionV0 = aod::run2::oftv0::collisionId; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + void init(InitContext&) + { + + const AxisSpec thnAxisInvMass{400, 0.0, 0.8, "#it{M}_{#gamma#gamma} (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisPt{100, 0., 20., "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisCent{20, 0., 100., "Centrality (%)"}; + const AxisSpec thnAxisCuts{5, -0.5, 4.5, "cuts"}; + const AxisSpec thnAxisNSgimaE{254, -6.35f, 6.35f, "n#sigma_{e}"}; + + registry.add("hSameEvent2D", "hSameEvent2D", HistType::kTH2D, {thnAxisInvMass, thnAxisPt}); + registry.add("hNSigmaEPt", "hNSigmaEPt", HistType::kTH2D, {thnAxisNSgimaE, thnAxisPt}); + + registry.add("hCuts", "hCuts", HistType::kTH1D, {thnAxisCuts}); + registry.add("hCutsPair", "hCutsPair", HistType::kTH1D, {thnAxisCuts}); + + }; // end init + + template + float getCosP(CollisionIter const& coll, V0Iter const& v0) + { + // V0 momentum + float px = v0.px(); + float py = v0.py(); + float pz = v0.pz(); + + // V0 decay position + float xV0 = v0.x(); + float yV0 = v0.y(); + float zV0 = v0.z(); + + // Primary vertex + float xPV = coll.posX(); + float yPV = coll.posY(); + float zPV = coll.posZ(); + + // Displacement vector r = V0 - PV + float rx = xV0 - xPV; + float ry = yV0 - yPV; + float rz = zV0 - zPV; + + // Dot product p·r + float dot = px * rx + py * ry + pz * rz; + + // Magnitudes |p| and |r| + float magP = std::sqrt(px * px + py * py + pz * pz); + float magR = std::sqrt(rx * rx + ry * ry + rz * rz); + + // Cosine of pointing angle + return dot / (magP * magR); + } + + template + bool checkLegs(V0Iter const& v0) + { + + auto posLeg = v0.template posTrack_as(); + auto negLeg = v0.template negTrack_as(); + + registry.fill(HIST("hNSigmaEPt"), posLeg.tpcNSigmaEl(), posLeg.pt()); + registry.fill(HIST("hNSigmaEPt"), negLeg.tpcNSigmaEl(), negLeg.pt()); + + // first let's check the positive leg + if (posLeg.pt() <= trackcuts.minPt.value) { + registry.fill(HIST("hCuts"), 1); + return false; + } + if (posLeg.tpcFoundOverFindableCls() <= trackcuts.tpcFindOverFoundable.value) { + registry.fill(HIST("hCuts"), 1); + return false; + } + if (posLeg.tpcNSigmaEl() <= pidcuts.minNSigmaEl.value || posLeg.tpcNSigmaEl() >= pidcuts.maxNSigmaEl.value) { + registry.fill(HIST("hCuts"), 2); + return false; + } + + float minP = 0.4f; // minimum momentum for legs + float midP = 3.5f; // momentum where we change NSigma window + if (pidcuts.doPionRejection.value && posLeg.p() > minP) { + if (posLeg.p() < midP && posLeg.tpcNSigmaPi() <= pidcuts.minNSigmaPiLowP.value) { + registry.fill(HIST("hCuts"), 2); + return false; + } else if (posLeg.p() >= midP && posLeg.tpcNSigmaPi() <= pidcuts.minNSigmaPiHighP.value) { + registry.fill(HIST("hCuts"), 2); + return false; + } + } + + // second let's check the negative leg + if (negLeg.pt() <= trackcuts.minPt.value) { + registry.fill(HIST("hCuts"), 1); + return false; + } + if (negLeg.tpcFoundOverFindableCls() <= trackcuts.tpcFindOverFoundable.value) { + registry.fill(HIST("hCuts"), 1); + return false; + } + if (negLeg.tpcNSigmaEl() <= pidcuts.minNSigmaEl.value || negLeg.tpcNSigmaEl() >= pidcuts.maxNSigmaEl.value) { + registry.fill(HIST("hCuts"), 2); + return false; + } + + if (pidcuts.doPionRejection.value && negLeg.p() > minP) { + if (negLeg.p() < midP && negLeg.tpcNSigmaPi() <= pidcuts.minNSigmaPiLowP.value) { + registry.fill(HIST("hCuts"), 2); + return false; + } else if (negLeg.p() >= midP && negLeg.tpcNSigmaPi() <= pidcuts.minNSigmaPiHighP.value) { + registry.fill(HIST("hCuts"), 2); + return false; + } + } + return true; + } + + // Pi0 from EMCal + void process(o2::aod::Collisions const& collisions, o2::aod::Run2OTFV0s const& v0s, TracksWithPID const& /*tracks*/) + { + // TODO: + // - Add TooCloseToV0 cut: if two V0s are within dAngle < 0.02 and dR < 6. then remove the V0 with higher Chi2 + // - Everything here! + // nothing yet + + const float zRslope = std::tan(2.f * std::atan(std::exp(-1.f * v0cuts.maxEta.value))); + const float z0 = 7.f; // 7 cm + const float maxZ = 10.f; + const float minR = 5.f; + const float maxR = 280.f; + const float minRExclude = 55.f; + const float maxRExclude = 72.f; + + for (const auto& collision : collisions) { + if (std::fabs(collision.posZ()) > maxZ) { + continue; + } + auto photonsPerCollision = v0s.sliceBy(perCollisionV0, collision.globalIndex()); + + for (const auto& [g1, g2] : combinations(CombinationsStrictlyUpperIndexPolicy(photonsPerCollision, photonsPerCollision))) { + registry.fill(HIST("hCutsPair"), 0); + // next V0 cuts + float cX1 = g1.x(); + float cY1 = g1.y(); + float cZ1 = g1.z(); + float cR1 = std::sqrt(std::pow(cX1, 2.) + std::pow(cY1, 2.)); + + float cX2 = g2.x(); + float cY2 = g2.y(); + float cZ2 = g2.z(); + float cR2 = std::sqrt(std::pow(cX2, 2.) + std::pow(cY2, 2.)); + + ROOT::Math::PxPyPzEVector v4Photon2(g2.px(), g2.py(), g2.pz(), g2.e()); + ROOT::Math::PxPyPzEVector v4Photon1(g1.px(), g1.py(), g1.pz(), g1.e()); + + if (!checkLegs(g1)) { + registry.fill(HIST("hCutsPair"), 1); + continue; + } + + if (!checkLegs(g2)) { + registry.fill(HIST("hCutsPair"), 1); + continue; + } + + if (cR1 < minR || (cR1 > minRExclude && cR1 < maxRExclude) || cR1 > maxR) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (v4Photon1.Pt() < v0cuts.minPt.value) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (std::fabs(v4Photon1.Eta()) >= v0cuts.maxEta.value) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (std::fabs(cZ1) > v0cuts.maxZconv.value) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (cR1 <= ((std::fabs(cZ1) * zRslope) - z0)) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (g1.psiPair() >= (0.18f * std::exp(-0.055f * g1.chi2NDF()))) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (g1.qt() >= (v0cuts.qTFactor.value * v4Photon1.Pt())) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (getCosP(collision, g1) <= v0cuts.cosP.value) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + + if (cR2 < minR || (cR2 > minRExclude && cR2 < maxRExclude) || cR2 > maxR) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (v4Photon2.Pt() < v0cuts.minPt.value) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (std::fabs(v4Photon2.Eta()) >= v0cuts.maxEta.value) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (std::fabs(cZ2) > v0cuts.maxZconv.value) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (cR2 <= ((std::fabs(cZ2) * zRslope) - z0)) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (g2.psiPair() >= (0.18f * std::exp(-0.055f * g2.chi2NDF()))) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (g2.qt() >= (v0cuts.qTFactor.value * v4Photon2.Pt())) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + if (getCosP(collision, g2) <= v0cuts.cosP.value) { + registry.fill(HIST("hCutsPair"), 2); + continue; + } + + ROOT::Math::PxPyPzEVector vMeson = v4Photon1 + v4Photon2; + registry.fill(HIST("hCutsPair"), 3); + registry.fill(HIST("hSameEvent2D"), vMeson.M(), vMeson.Pt()); + } // end of loop over photon pairs + } // end of loop over collision + } + PROCESS_SWITCH(PcmRun2, process, "Default process function", true); +}; // End struct PcmRun2 + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/Common/LegacyDataQA/pmdQa.cxx b/Common/LegacyDataQA/pmdQa.cxx new file mode 100644 index 00000000000..9958fd26761 --- /dev/null +++ b/Common/LegacyDataQA/pmdQa.cxx @@ -0,0 +1,133 @@ +// 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. +/// +/// \file pmdQa.cxx +/// +/// \brief QA task to check PMD info on Run 2 converted data +/// \author Abhi Modak (abhi.modak@cern.ch) +/// \since May 17, 2025 + +#include +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PmdTable.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "CCDB/BasicCCDBManager.h" +#include "TH1F.h" +#include "TH2F.h" + +using namespace o2; +using namespace o2::aod::run2; +using namespace o2::framework; +using namespace o2::aod::evsel; +using namespace o2::framework::expressions; + +struct BuiltPmdIndex { + // build the index table PMDTracksIndex + Builds idx; + void init(InitContext const&) {} +}; + +struct PmdQa { + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + ConfigurableAxis axisEventBin{"axisEventBin", {4, 0.5, 4.5}, ""}; + ConfigurableAxis axisVtxZBin{"axisVtxZBin", {40, -20, 20}, ""}; + ConfigurableAxis axisNPMDtracksBin{"axisNPMDtracksBin", {500, 0, 500}, "Number of pmdtracks"}; + ConfigurableAxis axisClsxyBin{"axisClsxyBin", {200, -100, 100}, ""}; + ConfigurableAxis axisAdcBin{"axisAdcBin", {200, 0, 2000}, ""}; + ConfigurableAxis axisEtaBin{"axisEtaBin", {10, 2.1, 4.1}, ""}; + ConfigurableAxis axisNcellBin{"axisNcellBin", {50, -0.5, 49.5}, ""}; + Configurable fMipCut{"fMipCut", 432, "fMipCut"}; + Configurable fNcellCut{"fNcellCut", 2, "fNcellCut"}; + Configurable fEtalow{"fEtalow", 2.3, "fEtalow"}; + Configurable fEtahigh{"fEtahigh", 3.9, "fEtahigh"}; + Configurable fVtxCut{"fVtxCut", 10.0, "fVtxCut"}; + + void init(InitContext&) + { + + AxisSpec axisEvent = {axisEventBin, "Event", "EventAxis"}; + AxisSpec axisVtxZ = {axisVtxZBin, "VtxZ", "VtxZAxis"}; + AxisSpec axisNPMDtracks = {axisNPMDtracksBin, "NPMDtracks", "NPMDtracksAxis"}; + AxisSpec axisClsxy = {axisClsxyBin, "Clsxy", "ClsxyAxis"}; + AxisSpec axisAdc = {axisAdcBin, "Adc", "AdcAxis"}; + AxisSpec axisEta = {axisEtaBin, "Eta", "EtaAxis"}; + AxisSpec axisNcell = {axisNcellBin, "Ncell", "NcellAxis"}; + + histos.add("hEventHist", "hEventHist", kTH1F, {axisEvent}); + histos.add("hVtxZHist", "hVtxZHist", kTH1F, {axisVtxZ}); + histos.add("hNPMDtracks", "Number of pmdtracks", kTH1F, {axisNPMDtracks}); + histos.add("hClusXY", "hClusXY", kTH2F, {axisClsxy, axisClsxy}); + histos.add("hClusAdc", "hClusAdc", kTH1F, {axisAdc}); + histos.add("hetacls", "hetacls", kTH1F, {axisEta}); + histos.add("hclsncell", "hclsncell", kTH1F, {axisNcell}); + } + + using ColTable = soa::Join; + using ColevSel = soa::Join; + + void process(ColevSel::iterator const& collision, aod::Pmds const&) + { + histos.fill(HIST("hEventHist"), 1); + if (collision.sel7()) { + return; + } + histos.fill(HIST("hEventHist"), 2); + if (std::abs(collision.posZ()) >= fVtxCut) { + return; + } + histos.fill(HIST("hEventHist"), 3); + histos.fill(HIST("hVtxZHist"), collision.posZ()); + + if (collision.has_pmd()) { + histos.fill(HIST("hEventHist"), 4); + auto tracks = collision.pmd(); + histos.fill(HIST("hNPMDtracks"), tracks.size()); + for (const auto& track : tracks) { + if (track.pmddet() == 1) { + return; + } + if (track.pmdclsz() == 0) { + return; + } + if (!track.pmdmodule()) { + return; + } + histos.fill(HIST("hClusXY"), track.pmdclsx(), track.pmdclsy()); + histos.fill(HIST("hClusAdc"), track.pmdclsadc()); + float rdist = std::sqrt(track.pmdclsx() * track.pmdclsx() + track.pmdclsy() * track.pmdclsy()); + float theta = std::atan2(rdist, track.pmdclsz()); + float etacls = -std::log(std::tan(0.5 * theta)); + if (track.pmdclsadc() > fMipCut && track.pmdncell() > fNcellCut) { + if (etacls > fEtalow && etacls < fEtahigh) { + histos.fill(HIST("hetacls"), etacls); + histos.fill(HIST("hclsncell"), track.pmdncell()); + } + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + }; +} diff --git a/Common/TableProducer/CMakeLists.txt b/Common/TableProducer/CMakeLists.txt index d0a9e6f5440..cdd408d4bff 100644 --- a/Common/TableProducer/CMakeLists.txt +++ b/Common/TableProducer/CMakeLists.txt @@ -14,7 +14,7 @@ add_subdirectory(PID) o2physics_add_dpl_workflow(trackextension SOURCES trackextension.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(trackselection @@ -25,6 +25,13 @@ o2physics_add_dpl_workflow(trackselection o2physics_add_dpl_workflow(event-selection SOURCES eventSelection.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCCDB + O2::DataFormatsITSMFT + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(event-selection-service + SOURCES eventSelectionService.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCCDB + O2::DataFormatsITSMFT COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(multiplicity-table @@ -32,6 +39,11 @@ o2physics_add_dpl_workflow(multiplicity-table PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(multcenttable + SOURCES multCentTable.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(multiplicity-extra-table SOURCES multiplicityExtraTable.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -47,6 +59,11 @@ o2physics_add_dpl_workflow(timestamp PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(timestamptester + SOURCES timestampTester.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(weak-decay-indices SOURCES weakDecayIndices.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -59,12 +76,17 @@ o2physics_add_dpl_workflow(ft0-corrected-table o2physics_add_dpl_workflow(track-propagation SOURCES trackPropagation.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(track-dca-cov-filler-run2 + SOURCES trackDcaCovFillerRun2.cxx PUBLIC_LINK_LIBRARIES O2::DetectorsBase O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(track-propagation-tester SOURCES trackPropagationTester.cxx - PUBLIC_LINK_LIBRARIES O2::DetectorsBase O2Physics::AnalysisCore O2Physics::trackSelectionRequest + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::trackSelectionRequest COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(calo-clusters @@ -92,7 +114,7 @@ o2physics_add_dpl_workflow(fwdtrack-to-collision-associator o2physics_add_dpl_workflow(mccollisionextra SOURCES mcCollsExtra.cxx - PUBLIC_LINK_LIBRARIES O2::DetectorsBase O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(qvector-table @@ -120,8 +142,8 @@ o2physics_add_dpl_workflow(match-mft-ft0 O2::DetectorsBase O2::DetectorsCommonDataFormats COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(zdc-task-intercalib - SOURCES zdc-task-intercalib.cxx +o2physics_add_dpl_workflow(zdc-task-inter-calib + SOURCES zdcTaskInterCalib.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -132,10 +154,25 @@ o2physics_add_dpl_workflow(ese-table-producer o2physics_add_dpl_workflow(mftmch-matching-data SOURCES match-mft-mch-data.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2Physics::AnalysisCCDB O2Physics::PWGDQCore O2Physics::EventFilteringUtils + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::GlobalTracking + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(occ-table-producer + SOURCES occupancyTableProducer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(mftmch-matching-data-mc SOURCES match-mft-mch-data-mc.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2Physics::AnalysisCCDB O2Physics::PWGDQCore O2Physics::EventFilteringUtils + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::GlobalTracking + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(muon-realignment + SOURCES muonRealignment.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::DetectorsCommonDataFormats O2::MathUtils O2::MCHTracking O2::DataFormatsMCH O2::GlobalTracking O2::MCHBase O2::MCHGeometryTransformer O2::CommonUtils + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(selectionstudytable + SOURCES selectionStudyTable.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) diff --git a/Common/TableProducer/Converters/CMakeLists.txt b/Common/TableProducer/Converters/CMakeLists.txt index 13b1fbb38be..34ddc8efb3e 100644 --- a/Common/TableProducer/Converters/CMakeLists.txt +++ b/Common/TableProducer/Converters/CMakeLists.txt @@ -94,6 +94,11 @@ o2physics_add_dpl_workflow(trackqa-converter-002 PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(trackqa-converter-003 + SOURCES trackQA003Converter.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(run2bcinfos-converter SOURCES run2bcinfosConverter.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore diff --git a/Common/TableProducer/Converters/trackQA003Converter.cxx b/Common/TableProducer/Converters/trackQA003Converter.cxx new file mode 100644 index 00000000000..56a6d3551e9 --- /dev/null +++ b/Common/TableProducer/Converters/trackQA003Converter.cxx @@ -0,0 +1,133 @@ +// 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. +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" + +using namespace o2; +using namespace o2::framework; + +struct TrackQAConverter003 { + Produces tracksQA_003; + + void process000(aod::TracksQA_000 const& tracksQA_000) + { + for (const auto& trackQA : tracksQA_000) { + tracksQA_003( + trackQA.trackId(), + trackQA.tpcTime0(), + 0.f, // dummy, not available in _000 + trackQA.tpcdcaR(), + trackQA.tpcdcaZ(), + trackQA.tpcClusterByteMask(), + trackQA.tpcdEdxMax0R(), + trackQA.tpcdEdxMax1R(), + trackQA.tpcdEdxMax2R(), + trackQA.tpcdEdxMax3R(), + trackQA.tpcdEdxTot0R(), + trackQA.tpcdEdxTot1R(), + trackQA.tpcdEdxTot2R(), + trackQA.tpcdEdxTot3R(), + // dummy values, not available in _000 + std::numeric_limits::min(), // deltaRefContParamY + std::numeric_limits::min(), // deltaRefContParamZ + std::numeric_limits::min(), // deltaRefContParamSnp + std::numeric_limits::min(), // deltaRefContParamTgl + std::numeric_limits::min(), // deltaRefContParamQ2Pt + std::numeric_limits::min(), // deltaRefGloParamY + std::numeric_limits::min(), // deltaRefGloParamZ + std::numeric_limits::min(), // deltaRefGloParamSnp + std::numeric_limits::min(), // deltaRefGloParamTgl + std::numeric_limits::min(), // deltaRefGloParamQ2Pt + std::numeric_limits::min(), // dTofdX + std::numeric_limits::min()); // dTofdY + } + } + PROCESS_SWITCH(TrackQAConverter003, process000, "process v000-to-v003 conversion", false); + + void process001(aod::TracksQA_001 const& tracksQA_001) + { + for (const auto& trackQA : tracksQA_001) { + tracksQA_003( + trackQA.trackId(), + trackQA.tpcTime0(), + 0.f, // dummy, not available in _001 + trackQA.tpcdcaR(), + trackQA.tpcdcaZ(), + trackQA.tpcClusterByteMask(), + trackQA.tpcdEdxMax0R(), + trackQA.tpcdEdxMax1R(), + trackQA.tpcdEdxMax2R(), + trackQA.tpcdEdxMax3R(), + trackQA.tpcdEdxTot0R(), + trackQA.tpcdEdxTot1R(), + trackQA.tpcdEdxTot2R(), + trackQA.tpcdEdxTot3R(), + trackQA.deltaRefContParamY(), + trackQA.deltaRefITSParamZ(), + trackQA.deltaRefContParamSnp(), + trackQA.deltaRefContParamTgl(), + trackQA.deltaRefContParamQ2Pt(), + trackQA.deltaRefGloParamY(), + trackQA.deltaRefGloParamZ(), + trackQA.deltaRefGloParamSnp(), + trackQA.deltaRefGloParamTgl(), + trackQA.deltaRefGloParamQ2Pt(), + // dummy values, not available in _001 + std::numeric_limits::min(), // dTofdX + std::numeric_limits::min()); // dTofdY + } + } + PROCESS_SWITCH(TrackQAConverter003, process001, "process v001-to-v003 conversion", false); + + void process002(aod::TracksQA_002 const& tracksQA_002) + { + for (const auto& trackQA : tracksQA_002) { + tracksQA_003( + trackQA.trackId(), + trackQA.tpcTime0(), + 0.f, // dummy, not available in _002 + trackQA.tpcdcaR(), + trackQA.tpcdcaZ(), + trackQA.tpcClusterByteMask(), + trackQA.tpcdEdxMax0R(), + trackQA.tpcdEdxMax1R(), + trackQA.tpcdEdxMax2R(), + trackQA.tpcdEdxMax3R(), + trackQA.tpcdEdxTot0R(), + trackQA.tpcdEdxTot1R(), + trackQA.tpcdEdxTot2R(), + trackQA.tpcdEdxTot3R(), + trackQA.deltaRefContParamY(), + trackQA.deltaRefITSParamZ(), + trackQA.deltaRefContParamSnp(), + trackQA.deltaRefContParamTgl(), + trackQA.deltaRefContParamQ2Pt(), + trackQA.deltaRefGloParamY(), + trackQA.deltaRefGloParamZ(), + trackQA.deltaRefGloParamSnp(), + trackQA.deltaRefGloParamTgl(), + trackQA.deltaRefGloParamQ2Pt(), + trackQA.deltaTOFdX(), + trackQA.deltaTOFdZ()); + } + } + PROCESS_SWITCH(TrackQAConverter003, process002, "process v002-to-v003 conversion", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/Common/TableProducer/PID/CMakeLists.txt b/Common/TableProducer/PID/CMakeLists.txt index d28a3268954..e0ea2d40ab3 100644 --- a/Common/TableProducer/PID/CMakeLists.txt +++ b/Common/TableProducer/PID/CMakeLists.txt @@ -43,9 +43,14 @@ o2physics_add_dpl_workflow(pid-tof-full # TPC +o2physics_add_dpl_workflow(pid-tpc-service + SOURCES pidTPCService.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::AnalysisCCDB + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(pid-tpc-base SOURCES pidTPCBase.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(pid-tpc diff --git a/Common/TableProducer/PID/pidBayes.cxx b/Common/TableProducer/PID/pidBayes.cxx index c990875e967..abedb281668 100644 --- a/Common/TableProducer/PID/pidBayes.cxx +++ b/Common/TableProducer/PID/pidBayes.cxx @@ -16,6 +16,12 @@ /// Only the tables for the mass hypotheses requested are filled, the others are sent empty. /// +#include +#include +#include +#include +#include + // O2 includes #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" @@ -28,7 +34,9 @@ #include "Common/Core/PID/PIDTOF.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseCombined.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/PIDResponseTOF.h" #include "pidTOFBase.h" diff --git a/Common/TableProducer/PID/pidITS.cxx b/Common/TableProducer/PID/pidITS.cxx index 58ac57984fe..1a6cdbc5491 100644 --- a/Common/TableProducer/PID/pidITS.cxx +++ b/Common/TableProducer/PID/pidITS.cxx @@ -40,24 +40,23 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::track; -MetadataHelper metadataInfo; +o2::common::core::MetadataHelper metadataInfo; static constexpr int nCases = 2; -static constexpr int nParameters = 9; +static constexpr int nParameters = 12; static const std::vector casesNames{"Data", "MC"}; static const std::vector parameterNames{"RespITSPar1", "RespITSPar2", "RespITSPar3", "RespITSPar1_Z2", "RespITSPar2_Z2", "RespITSPar3_Z2", - "ResolutionPar1", "ResolutionPar2", "ResolutionPar3"}; -static constexpr float defaultParameters[nCases][nParameters]{{0.903, 2.014, 2.440, - 2.8752, 1.1246, 5.0259, - 0.2431, -0.3293, 1.533}, - {0.903, 2.014, 2.440, - 2.8752, 1.1246, 5.0259, - 0.2431, -0.3293, 1.533}}; + "ResolutionPar1", "ResolutionPar2", "ResolutionPar3", + "ResolutionPar1_Z2", "ResolutionPar2_Z2", "ResolutionPar3_Z2"}; + +static constexpr float defaultParameters[nCases][nParameters] = { + {1.18941, 1.53792, 1.69961, 2.35117, 1.80347, 5.14355, 1.94669e-01, -2.08616e-01, 1.30753, 0.09, -999., -999.}, + {1.63806, 1.58847, 2.52275, 2.66505, 1.48405, 6.90453, 1.40487e-01, -4.31078e-01, 1.50052, 0.09, -999., -999.}}; /// Task to produce the ITS PID information for each particle species /// The parametrization is: [p0/(bg)**p1 + p2] being bg = p/m. Different parametrizations are used for He3 and Alpha particles. -/// The resolution depends on the bg and is modelled with an erf function: p0*TMath::Erf((bg-p1)/p2) +/// The resolution depends on the bg and is modelled with an erf function: p0*TMath::Erf((bg-p1)/p2). If p1/p2 is -999, the resolution is set to p0. struct itsPid { Configurable> itsParams{"itsParams", @@ -81,16 +80,19 @@ struct itsPid { ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); LOG(fatal) << "Not implemented yet"; } else { - const char* key = metadataInfo.isMC() ? "MC" : "Data"; - o2::aod::ITSResponse::setParameters(itsParams->get(key, "RespITSPar1"), - itsParams->get(key, "RespITSPar2"), - itsParams->get(key, "RespITSPar3"), - itsParams->get(key, "RespITSPar1_Z2"), - itsParams->get(key, "RespITSPar2_Z2"), - itsParams->get(key, "RespITSPar3_Z2"), - itsParams->get(key, "ResolutionPar1"), - itsParams->get(key, "ResolutionPar2"), - itsParams->get(key, "ResolutionPar3")); + const char* dataType = metadataInfo.isMC() ? "MC" : "Data"; + o2::aod::ITSResponse::setParameters(itsParams->get(dataType, "RespITSPar1"), + itsParams->get(dataType, "RespITSPar2"), + itsParams->get(dataType, "RespITSPar3"), + itsParams->get(dataType, "RespITSPar1_Z2"), + itsParams->get(dataType, "RespITSPar2_Z2"), + itsParams->get(dataType, "RespITSPar3_Z2"), + itsParams->get(dataType, "ResolutionPar1"), + itsParams->get(dataType, "ResolutionPar2"), + itsParams->get(dataType, "ResolutionPar3"), + itsParams->get(dataType, "ResolutionPar1_Z2"), + itsParams->get(dataType, "ResolutionPar2_Z2"), + itsParams->get(dataType, "ResolutionPar3_Z2")); } } diff --git a/Common/TableProducer/PID/pidTOF.cxx b/Common/TableProducer/PID/pidTOF.cxx index f26df966313..076cc0c26de 100644 --- a/Common/TableProducer/PID/pidTOF.cxx +++ b/Common/TableProducer/PID/pidTOF.cxx @@ -232,40 +232,31 @@ struct tofPid { { switch (id) { case 0: - aod::pidutils::packInTable(-999.f, - tablePIDEl); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDEl); break; case 1: - aod::pidutils::packInTable(-999.f, - tablePIDMu); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDMu); break; case 2: - aod::pidutils::packInTable(-999.f, - tablePIDPi); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDPi); break; case 3: - aod::pidutils::packInTable(-999.f, - tablePIDKa); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDKa); break; case 4: - aod::pidutils::packInTable(-999.f, - tablePIDPr); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDPr); break; case 5: - aod::pidutils::packInTable(-999.f, - tablePIDDe); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDDe); break; case 6: - aod::pidutils::packInTable(-999.f, - tablePIDTr); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDTr); break; case 7: - aod::pidutils::packInTable(-999.f, - tablePIDHe); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDHe); break; case 8: - aod::pidutils::packInTable(-999.f, - tablePIDAl); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDAl); break; default: LOG(fatal) << "Wrong particle ID in makeTableEmpty()"; @@ -326,40 +317,40 @@ struct tofPid { for (auto const& pidId : mEnabledParticles) { // Loop on enabled particle hypotheses switch (pidId) { case 0: - aod::pidutils::packInTable(responseEl.GetSeparation(mRespParamsV2, trkInColl), - tablePIDEl); + aod::pidtof_tiny::binning::packInTable(responseEl.GetSeparation(mRespParamsV2, trkInColl), + tablePIDEl); break; case 1: - aod::pidutils::packInTable(responseMu.GetSeparation(mRespParamsV2, trkInColl), - tablePIDMu); + aod::pidtof_tiny::binning::packInTable(responseMu.GetSeparation(mRespParamsV2, trkInColl), + tablePIDMu); break; case 2: - aod::pidutils::packInTable(responsePi.GetSeparation(mRespParamsV2, trkInColl), - tablePIDPi); + aod::pidtof_tiny::binning::packInTable(responsePi.GetSeparation(mRespParamsV2, trkInColl), + tablePIDPi); break; case 3: - aod::pidutils::packInTable(responseKa.GetSeparation(mRespParamsV2, trkInColl), - tablePIDKa); + aod::pidtof_tiny::binning::packInTable(responseKa.GetSeparation(mRespParamsV2, trkInColl), + tablePIDKa); break; case 4: - aod::pidutils::packInTable(responsePr.GetSeparation(mRespParamsV2, trkInColl), - tablePIDPr); + aod::pidtof_tiny::binning::packInTable(responsePr.GetSeparation(mRespParamsV2, trkInColl), + tablePIDPr); break; case 5: - aod::pidutils::packInTable(responseDe.GetSeparation(mRespParamsV2, trkInColl), - tablePIDDe); + aod::pidtof_tiny::binning::packInTable(responseDe.GetSeparation(mRespParamsV2, trkInColl), + tablePIDDe); break; case 6: - aod::pidutils::packInTable(responseTr.GetSeparation(mRespParamsV2, trkInColl), - tablePIDTr); + aod::pidtof_tiny::binning::packInTable(responseTr.GetSeparation(mRespParamsV2, trkInColl), + tablePIDTr); break; case 7: - aod::pidutils::packInTable(responseHe.GetSeparation(mRespParamsV2, trkInColl), - tablePIDHe); + aod::pidtof_tiny::binning::packInTable(responseHe.GetSeparation(mRespParamsV2, trkInColl), + tablePIDHe); break; case 8: - aod::pidutils::packInTable(responseAl.GetSeparation(mRespParamsV2, trkInColl), - tablePIDAl); + aod::pidtof_tiny::binning::packInTable(responseAl.GetSeparation(mRespParamsV2, trkInColl), + tablePIDAl); break; default: LOG(fatal) << "Wrong particle ID in processWSlice()"; @@ -414,40 +405,40 @@ struct tofPid { for (auto const& pidId : mEnabledParticles) { // Loop on enabled particle hypotheses switch (pidId) { case 0: - aod::pidutils::packInTable(responseEl.GetSeparation(mRespParamsV2, track), - tablePIDEl); + aod::pidtof_tiny::binning::packInTable(responseEl.GetSeparation(mRespParamsV2, track), + tablePIDEl); break; case 1: - aod::pidutils::packInTable(responseMu.GetSeparation(mRespParamsV2, track), - tablePIDMu); + aod::pidtof_tiny::binning::packInTable(responseMu.GetSeparation(mRespParamsV2, track), + tablePIDMu); break; case 2: - aod::pidutils::packInTable(responsePi.GetSeparation(mRespParamsV2, track), - tablePIDPi); + aod::pidtof_tiny::binning::packInTable(responsePi.GetSeparation(mRespParamsV2, track), + tablePIDPi); break; case 3: - aod::pidutils::packInTable(responseKa.GetSeparation(mRespParamsV2, track), - tablePIDKa); + aod::pidtof_tiny::binning::packInTable(responseKa.GetSeparation(mRespParamsV2, track), + tablePIDKa); break; case 4: - aod::pidutils::packInTable(responsePr.GetSeparation(mRespParamsV2, track), - tablePIDPr); + aod::pidtof_tiny::binning::packInTable(responsePr.GetSeparation(mRespParamsV2, track), + tablePIDPr); break; case 5: - aod::pidutils::packInTable(responseDe.GetSeparation(mRespParamsV2, track), - tablePIDDe); + aod::pidtof_tiny::binning::packInTable(responseDe.GetSeparation(mRespParamsV2, track), + tablePIDDe); break; case 6: - aod::pidutils::packInTable(responseTr.GetSeparation(mRespParamsV2, track), - tablePIDTr); + aod::pidtof_tiny::binning::packInTable(responseTr.GetSeparation(mRespParamsV2, track), + tablePIDTr); break; case 7: - aod::pidutils::packInTable(responseHe.GetSeparation(mRespParamsV2, track), - tablePIDHe); + aod::pidtof_tiny::binning::packInTable(responseHe.GetSeparation(mRespParamsV2, track), + tablePIDHe); break; case 8: - aod::pidutils::packInTable(responseAl.GetSeparation(mRespParamsV2, track), - tablePIDAl); + aod::pidtof_tiny::binning::packInTable(responseAl.GetSeparation(mRespParamsV2, track), + tablePIDAl); break; default: LOG(fatal) << "Wrong particle ID in processWoSlice()"; diff --git a/Common/TableProducer/PID/pidTOFBase.h b/Common/TableProducer/PID/pidTOFBase.h index 2861cf883ce..44367eacb75 100644 --- a/Common/TableProducer/PID/pidTOFBase.h +++ b/Common/TableProducer/PID/pidTOFBase.h @@ -24,6 +24,7 @@ // O2Physics #include "PID/ParamBase.h" #include "PID/PIDTOF.h" +#include "Common/DataModel/PIDResponseTOF.h" #include "Common/DataModel/PIDResponse.h" static constexpr int nSpecies = 9; diff --git a/Common/TableProducer/PID/pidTOFMerge.cxx b/Common/TableProducer/PID/pidTOFMerge.cxx index e2c5489ab65..7ea0ac3b3b1 100644 --- a/Common/TableProducer/PID/pidTOFMerge.cxx +++ b/Common/TableProducer/PID/pidTOFMerge.cxx @@ -8,37 +8,37 @@ // 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. - /// -/// \file tofPidMerge.cxx -/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \file pidTOFMerge.cxx /// \brief Task to produce PID tables for TOF split for each particle. /// Only the tables for the mass hypotheses requested are filled, the others are sent empty. +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch /// -#include -#include -#include #include +#include #include +#include +#include // O2 includes -#include "Framework/runDataProcessing.h" +#include "CCDB/BasicCCDBManager.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" -#include "CCDB/BasicCCDBManager.h" #include "TOFBase/EventTimeMaker.h" // O2Physics includes -#include "TableHelper.h" -#include "MetadataHelper.h" #include "CollisionTypeHelper.h" +#include "MetadataHelper.h" +#include "TableHelper.h" #include "pidTOFBase.h" -#include "Common/DataModel/TrackSelectionTables.h" + #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/FT0Corrected.h" #include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" using namespace o2; using namespace o2::framework; @@ -46,7 +46,7 @@ using namespace o2::pid; using namespace o2::framework::expressions; using namespace o2::track; -MetadataHelper metadataInfo; +o2::common::core::MetadataHelper metadataInfo; // Input data types using Run3Trks = o2::soa::Join; @@ -149,12 +149,20 @@ struct TOFCalibConfig { paramCollection.print(); LOG(fatal) << "Cannot get default pass for calibration " << mReconstructionPassDefault; } else { - mRespParamsV3.setResolutionParametrization(paramCollection.getPars(mReconstructionPassDefault)); + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection.getPars(mReconstructionPassDefault)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection.getPars(mReconstructionPassDefault)); + } mRespParamsV3.setMomentumChargeShiftParameters(paramCollection.getPars(mReconstructionPassDefault)); } } } else { // Pass is available, load non standard parameters - mRespParamsV3.setResolutionParametrization(paramCollection.getPars(mReconstructionPass)); + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection.getPars(mReconstructionPass)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection.getPars(mReconstructionPass)); + } mRespParamsV3.setMomentumChargeShiftParameters(paramCollection.getPars(mReconstructionPass)); } } else if (!mEnableTimeDependentResponse) { // Loading it from CCDB @@ -169,12 +177,20 @@ struct TOFCalibConfig { paramCollection->print(); LOG(fatal) << "Cannot get default pass for calibration " << mReconstructionPassDefault; } else { - mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPassDefault)); + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPassDefault)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection->getPars(mReconstructionPassDefault)); + } mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPassDefault)); } } } else { // Pass is available, load non standard parameters - mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPass)); + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPass)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection->getPars(mReconstructionPass)); + } mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPass)); } } @@ -197,7 +213,9 @@ struct TOFCalibConfig { LOG(info) << "Initializing the time shift for " << (isPositive ? "positive" : "negative") << " from ccdb '" << nameShift << "' and timestamp " << mTimestamp << " and pass '" << mReconstructionPass << "'"; + ccdb->setFatalWhenNull(false); mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(nameShift, mTimestamp, metadata), isPositive); + ccdb->setFatalWhenNull(true); } LOG(info) << " test getTimeShift at 0 " << (isPositive ? "pos" : "neg") << ": " << mRespParamsV3.getTimeShift(0, isPositive); @@ -252,12 +270,20 @@ struct TOFCalibConfig { paramCollection->print(); LOG(fatal) << "Cannot get default pass for calibration " << mReconstructionPassDefault; } else { // Found the default case - mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPassDefault)); + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPassDefault)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection->getPars(mReconstructionPassDefault)); + } mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPassDefault)); } } } else { // Found the non default case - mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPass)); + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPass)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection->getPars(mReconstructionPass)); + } mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPass)); } } @@ -279,7 +305,9 @@ struct TOFCalibConfig { LOG(info) << "Updating the time shift for " << (isPositive ? "positive" : "negative") << " from ccdb '" << nameShift << "' and timestamp " << mTimestamp << " and pass '" << mReconstructionPass << "'"; + ccdb->setFatalWhenNull(false); mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(nameShift, mTimestamp, metadata), isPositive); + ccdb->setFatalWhenNull(true); LOG(info) << " test getTimeShift at 0 " << (isPositive ? "pos" : "neg") << ": " << mRespParamsV3.getTimeShift(0, isPositive); }; @@ -419,7 +447,7 @@ struct tofSignal { if (enableTablepidTOFFlags) { tableFlags.reserve(tracks.size()); } - for (auto& trk : tracks) { + for (const auto& trk : tracks) { const float& sig = o2::pid::tof::TOFSignal::GetTOFSignal(trk); if (enableQaHistograms) { histos.fill(HIST("tofSignal"), sig); @@ -446,7 +474,7 @@ struct tofSignal { if (enableTablepidTOFFlags) { tableFlags.reserve(tracks.size()); } - for (auto& trk : tracks) { + for (const auto& trk : tracks) { table(o2::pid::tof::TOFSignal::GetTOFSignal(trk)); if (!enableTablepidTOFFlags) { continue; @@ -491,10 +519,10 @@ struct tofEventTime { Produces tableEvTime; Produces tableEvTimeTOFOnly; Produces tableFlags; - static constexpr bool removeTOFEvTimeBias = true; // Flag to subtract the Ev. Time bias for low multiplicity events with TOF - static constexpr float diamond = 6.0; // Collision diamond used in the estimation of the TOF event time - static constexpr float errDiamond = diamond * 33.356409f; - static constexpr float weightDiamond = 1.f / (errDiamond * errDiamond); + static constexpr bool kRemoveTOFEvTimeBias = true; // Flag to subtract the Ev. Time bias for low multiplicity events with TOF + static constexpr float kDiamond = 6.0; // Collision diamond used in the estimation of the TOF event time + static constexpr float kErrDiamond = kDiamond * 33.356409f; + static constexpr float kWeightDiamond = 1.f / (kErrDiamond * kErrDiamond); bool enableTableTOFEvTime = false; bool enableTableEvTimeTOFOnly = false; @@ -611,7 +639,7 @@ struct tofEventTime { Preslice perCollision = aod::track::collisionId; template using ResponseImplementationEvTime = o2::pid::tof::ExpTimes; - void processRun3(Run3TrksWtof& tracks, + void processRun3(Run3TrksWtof const& tracks, aod::FT0s const&, EvTimeCollisionsFT0 const&, aod::BCsWithTimestamps const& bcs) @@ -668,7 +696,7 @@ struct tofEventTime { const auto& collision = t.collision_as(); // Compute the TOF event time - const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, diamond); + const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, kDiamond); float t0AC[2] = {.0f, 999.f}; // Value and error of T0A or T0C or T0AC float t0TOF[2] = {static_cast(evTimeMakerTOF.mEventTime), static_cast(evTimeMakerTOF.mEventTimeError)}; // Value and error of TOF @@ -687,10 +715,10 @@ struct tofEventTime { sumOfWeights = 0.f; weight = 0.f; // Remove the bias on TOF ev. time - if constexpr (removeTOFEvTimeBias) { + if constexpr (kRemoveTOFEvTimeBias) { evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, t0TOF[0], t0TOF[1], 2); } - if (t0TOF[1] < errDiamond && (maxEvTimeTOF <= 0 || std::abs(t0TOF[0]) < maxEvTimeTOF)) { + if (t0TOF[1] < kErrDiamond && (maxEvTimeTOF <= 0 || std::abs(t0TOF[0]) < maxEvTimeTOF)) { flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; weight = 1.f / (t0TOF[1] * t0TOF[1]); @@ -711,14 +739,14 @@ struct tofEventTime { sumOfWeights += weight; } - if (sumOfWeights < weightDiamond) { // avoiding sumOfWeights = 0 or worse that diamond + if (sumOfWeights < kWeightDiamond) { // avoiding sumOfWeights = 0 or worse that kDiamond eventTime = 0; - sumOfWeights = weightDiamond; + sumOfWeights = kWeightDiamond; tableFlags(0); } else { tableFlags(flags); } - tableEvTime(eventTime / sumOfWeights, sqrt(1. / sumOfWeights)); + tableEvTime(eventTime / sumOfWeights, std::sqrt(1. / sumOfWeights)); if (enableTableEvTimeTOFOnly) { tableEvTimeTOFOnly((uint8_t)filterForTOFEventTime(trk), t0TOF[0], t0TOF[1], evTimeMakerTOF.mEventTimeMultiplicity); } @@ -744,21 +772,21 @@ struct tofEventTime { const auto& tracksInCollision = tracks.sliceBy(perCollision, lastCollisionId); // First make table for event time - const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, diamond); + const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, kDiamond); int nGoodTracksForTOF = 0; float et = evTimeMakerTOF.mEventTime; float erret = evTimeMakerTOF.mEventTimeError; for (auto const& trk : tracksInCollision) { // Loop on Tracks - if constexpr (removeTOFEvTimeBias) { + if constexpr (kRemoveTOFEvTimeBias) { evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, et, erret, 2); } uint8_t flags = 0; - if (erret < errDiamond && (maxEvTimeTOF <= 0.f || std::abs(et) < maxEvTimeTOF)) { + if (erret < kErrDiamond && (maxEvTimeTOF <= 0.f || std::abs(et) < maxEvTimeTOF)) { flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; } else { et = 0.f; - erret = errDiamond; + erret = kErrDiamond; } tableFlags(flags); tableEvTime(et, erret); @@ -799,19 +827,19 @@ struct tofEventTime { // Part 3 Nsigma computation -static constexpr int nParameters2 = 2; -static const std::vector parameterNames2{"Enable", "EnableFull"}; -static constexpr int idxEl = 0; -static constexpr int idxMu = 1; -static constexpr int idxPi = 2; -static constexpr int idxKa = 3; -static constexpr int idxPr = 4; -static constexpr int idxDe = 5; -static constexpr int idxTr = 6; -static constexpr int idxHe = 7; -static constexpr int idxAl = 8; - -static constexpr int defaultParameters2[nSpecies][nParameters2]{{-1, -1}, +static constexpr int kParEnabledN = 2; +static constexpr int kIdxEl = 0; +static constexpr int kIdxMu = 1; +static constexpr int kIdxPi = 2; +static constexpr int kIdxKa = 3; +static constexpr int kIdxPr = 4; +static constexpr int kIdxDe = 5; +static constexpr int kIdxTr = 6; +static constexpr int kIdxHe = 7; +static constexpr int kIdxAl = 8; + +static const std::vector kParEnabledNames{"Enable", "EnableFull"}; +static constexpr int kDefaultParEnabled[nSpecies][kParEnabledN]{{-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}, @@ -845,15 +873,22 @@ struct tofPidMerge { Produces tablePIDFullHe; Produces tablePIDFullAl; + // Beta tables + Produces tablePIDBeta; + Produces tablePIDTOFMass; + bool enableTableBeta = false; + bool enableTableMass = false; + // Detector response parameters o2::pid::tof::TOFResoParamsV3 mRespParamsV3; Service ccdb; TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration Configurable enableQaHistograms{"enableQaHistograms", false, "Flag to enable the QA histograms"}; + Configurable enableTOFParamsForBetaMass{"enableTOFParamsForBetaMass", false, "Flag to use TOF parameters for TOF Beta and Mass"}; // Configuration flags to include and exclude particle hypotheses Configurable> enableParticle{"enableParticle", - {defaultParameters2[0], nSpecies, nParameters2, particleNames, parameterNames2}, + {kDefaultParEnabled[0], nSpecies, kParEnabledN, particleNames, kParEnabledNames}, "Produce PID information for the various mass hypotheses. Values different than -1 override the automatic setup: the corresponding table can be set off (0) or on (1)"}; // Histograms for QA @@ -888,19 +923,24 @@ struct tofPidMerge { LOG(info) << "No PID tables are required, disabling the task"; doprocessRun3.value = false; doprocessRun2.value = false; - return; - } else if (doprocessRun3.value == false && doprocessRun2.value == false) { - LOG(fatal) << "PID tables are required but process data is disabled. Please enable it"; - } - if (doprocessRun3.value == true && doprocessRun2.value == true) { - LOG(fatal) << "Both processRun2 and processRun3 are enabled. Pick one of the two"; - } - if (metadataInfo.isFullyDefined()) { - if (metadataInfo.isRun3() && doprocessRun2) { - LOG(fatal) << "Run2 process function is enabled but the metadata says it is Run3"; + } else { + if (mTOFCalibConfig.autoSetProcessFunctions()) { + LOG(info) << "Autodetecting process functions"; + if (metadataInfo.isFullyDefined()) { + if (metadataInfo.isRun3()) { + doprocessRun3.value = true; + doprocessRun2.value = false; + } else { + doprocessRun2.value = true; + doprocessRun3.value = false; + } + } } - if (!metadataInfo.isRun3() && doprocessRun3) { - LOG(fatal) << "Run3 process function is enabled but the metadata says it is Run2"; + if (doprocessRun2 && doprocessRun3) { + LOG(fatal) << "Both processRun2 and processRun3 are enabled. Pick one of the two"; + } + if (!doprocessRun2 && !doprocessRun3) { + LOG(fatal) << "Neither processRun2 nor processRun3 are enabled. Pick one of the two"; } } mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters @@ -923,13 +963,49 @@ struct tofPidMerge { } hnsigmaFull[i] = histos.add(Form("nsigmaFull/%s", particleNames[i].c_str()), Form("N_{#sigma}^{TOF}(%s)", particleNames[i].c_str()), kTH2F, {pAxis, nSigmaAxis}); } + + // Checking the TOF mass and TOF beta tables + enableTableBeta = isTableRequiredInWorkflow(initContext, "pidTOFbeta"); + enableTableMass = isTableRequiredInWorkflow(initContext, "pidTOFmass"); + + if (!enableTableBeta && !enableTableMass) { + LOG(info) << "No table for TOF mass and beta is required. Disabling beta and mass tables"; + doprocessRun2BetaM.value = false; + doprocessRun3BetaM.value = false; + } else { + LOG(info) << "Table for TOF beta is " << (enableTableBeta ? "enabled" : "disabled"); + LOG(info) << "Table for TOF mass is " << (enableTableMass ? "enabled" : "disabled"); + if (mTOFCalibConfig.autoSetProcessFunctions()) { + LOG(info) << "Autodetecting process functions for mass and beta"; + if (metadataInfo.isInitialized()) { + if (metadataInfo.isRun3()) { + doprocessRun3BetaM.value = true; + doprocessRun2BetaM.value = false; + } else { + doprocessRun2BetaM.value = true; + doprocessRun3BetaM.value = false; + } + } else { + metadataInfo.print(); + LOG(warning) << "Metadata is not defined, cannot autodetect process functions for mass and beta"; + } + } else { + LOG(info) << "Process functions for mass and beta are set manually"; + } + if (doprocessRun2BetaM && doprocessRun3BetaM) { + LOG(fatal) << "Both processRun2BetaM and processRun3BetaM are enabled. Pick one of the two"; + } + if (!doprocessRun2BetaM && !doprocessRun3BetaM) { + LOG(fatal) << "Neither processRun2BetaM nor processRun3BetaM are enabled. Pick one of the two"; + } + } } // Reserves an empty table for the given particle ID with size of the given track table void reserveTable(const int id, const int64_t& size, const bool fullTable = false) { switch (id) { - case idxEl: { + case kIdxEl: { if (fullTable) { tablePIDFullEl.reserve(size); } else { @@ -937,7 +1013,7 @@ struct tofPidMerge { } break; } - case idxMu: { + case kIdxMu: { if (fullTable) { tablePIDFullMu.reserve(size); } else { @@ -945,7 +1021,7 @@ struct tofPidMerge { } break; } - case idxPi: { + case kIdxPi: { if (fullTable) { tablePIDFullPi.reserve(size); } else { @@ -953,7 +1029,7 @@ struct tofPidMerge { } break; } - case idxKa: { + case kIdxKa: { if (fullTable) { tablePIDFullKa.reserve(size); } else { @@ -961,7 +1037,7 @@ struct tofPidMerge { } break; } - case idxPr: { + case kIdxPr: { if (fullTable) { tablePIDFullPr.reserve(size); } else { @@ -969,7 +1045,7 @@ struct tofPidMerge { } break; } - case idxDe: { + case kIdxDe: { if (fullTable) { tablePIDFullDe.reserve(size); } else { @@ -977,7 +1053,7 @@ struct tofPidMerge { } break; } - case idxTr: { + case kIdxTr: { if (fullTable) { tablePIDFullTr.reserve(size); } else { @@ -985,7 +1061,7 @@ struct tofPidMerge { } break; } - case idxHe: { + case kIdxHe: { if (fullTable) { tablePIDFullHe.reserve(size); } else { @@ -993,7 +1069,7 @@ struct tofPidMerge { } break; } - case idxAl: { + case kIdxAl: { if (fullTable) { tablePIDFullAl.reserve(size); } else { @@ -1011,76 +1087,67 @@ struct tofPidMerge { void makeTableEmpty(const int id, bool fullTable = false) { switch (id) { - case idxEl: + case kIdxEl: if (fullTable) { tablePIDFullEl(-999.f, -999.f); } else { - aod::pidutils::packInTable(-999.f, - tablePIDEl); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDEl); } break; - case idxMu: + case kIdxMu: if (fullTable) { tablePIDFullMu(-999.f, -999.f); } else { - aod::pidutils::packInTable(-999.f, - tablePIDMu); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDMu); } break; - case idxPi: + case kIdxPi: if (fullTable) { tablePIDFullPi(-999.f, -999.f); } else { - aod::pidutils::packInTable(-999.f, - tablePIDPi); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDPi); } break; - case idxKa: + case kIdxKa: if (fullTable) { tablePIDFullKa(-999.f, -999.f); } else { - aod::pidutils::packInTable(-999.f, - tablePIDKa); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDKa); } break; - case idxPr: + case kIdxPr: if (fullTable) { tablePIDFullPr(-999.f, -999.f); } else { - aod::pidutils::packInTable(-999.f, - tablePIDPr); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDPr); } break; - case idxDe: + case kIdxDe: if (fullTable) { tablePIDFullDe(-999.f, -999.f); } else { - aod::pidutils::packInTable(-999.f, - tablePIDDe); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDDe); } break; - case idxTr: + case kIdxTr: if (fullTable) { tablePIDFullTr(-999.f, -999.f); } else { - aod::pidutils::packInTable(-999.f, - tablePIDTr); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDTr); } break; - case idxHe: + case kIdxHe: if (fullTable) { tablePIDFullHe(-999.f, -999.f); } else { - aod::pidutils::packInTable(-999.f, - tablePIDHe); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDHe); } break; - case idxAl: + case kIdxAl: if (fullTable) { tablePIDFullAl(-999.f, -999.f); } else { - aod::pidutils::packInTable(-999.f, - tablePIDAl); + aod::pidtof_tiny::binning::packInTable(-999.f, tablePIDAl); } break; default: @@ -1132,49 +1199,49 @@ struct tofPidMerge { for (auto const& pidId : mEnabledParticles) { // Loop on enabled particle hypotheses switch (pidId) { - case idxEl: { + case kIdxEl: { nsigma = responseEl.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDEl); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDEl); break; } - case idxMu: { + case kIdxMu: { nsigma = responseMu.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDMu); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDMu); break; } - case idxPi: { + case kIdxPi: { nsigma = responsePi.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDPi); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDPi); break; } - case idxKa: { + case kIdxKa: { nsigma = responseKa.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDKa); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDKa); break; } - case idxPr: { + case kIdxPr: { nsigma = responsePr.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDPr); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDPr); break; } - case idxDe: { + case kIdxDe: { nsigma = responseDe.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDDe); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDDe); break; } - case idxTr: { + case kIdxTr: { nsigma = responseTr.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDTr); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDTr); break; } - case idxHe: { + case kIdxHe: { nsigma = responseHe.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDHe); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDHe); break; } - case idxAl: { + case kIdxAl: { nsigma = responseAl.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDAl); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDAl); break; } default: @@ -1187,55 +1254,55 @@ struct tofPidMerge { } for (auto const& pidId : mEnabledParticlesFull) { // Loop on enabled particle hypotheses with full tables switch (pidId) { - case idxEl: { + case kIdxEl: { resolution = responseEl.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseEl.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullEl(resolution, nsigma); break; } - case idxMu: { + case kIdxMu: { resolution = responseMu.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseMu.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullMu(resolution, nsigma); break; } - case idxPi: { + case kIdxPi: { resolution = responsePi.GetExpectedSigma(mRespParamsV3, trk); nsigma = responsePi.GetSeparation(mRespParamsV3, trk); tablePIDFullPi(resolution, nsigma); break; } - case idxKa: { + case kIdxKa: { resolution = responseKa.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseKa.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullKa(resolution, nsigma); break; } - case idxPr: { + case kIdxPr: { resolution = responsePr.GetExpectedSigma(mRespParamsV3, trk); nsigma = responsePr.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullPr(resolution, nsigma); break; } - case idxDe: { + case kIdxDe: { resolution = responseDe.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseDe.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullDe(resolution, nsigma); break; } - case idxTr: { + case kIdxTr: { resolution = responseTr.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseTr.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullTr(resolution, nsigma); break; } - case idxHe: { + case kIdxHe: { resolution = responseHe.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseHe.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullHe(resolution, nsigma); break; } - case idxAl: { + case kIdxAl: { resolution = responseAl.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseAl.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullAl(resolution, nsigma); @@ -1251,7 +1318,7 @@ struct tofPidMerge { } } } - PROCESS_SWITCH(tofPidMerge, processRun3, "Produce tables. Set to off if the tables are not required", true); + PROCESS_SWITCH(tofPidMerge, processRun3, "Produce Run 3 Nsigma table. Set to off if the tables are not required, or autoset is on", false); template using ResponseImplementationRun2 = o2::pid::tof::ExpTimes; @@ -1294,49 +1361,49 @@ struct tofPidMerge { for (auto const& pidId : mEnabledParticles) { // Loop on enabled particle hypotheses switch (pidId) { - case idxEl: { + case kIdxEl: { nsigma = responseEl.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDEl); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDEl); break; } - case idxMu: { + case kIdxMu: { nsigma = responseMu.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDMu); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDMu); break; } - case idxPi: { + case kIdxPi: { nsigma = responsePi.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDPi); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDPi); break; } - case idxKa: { + case kIdxKa: { nsigma = responseKa.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDKa); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDKa); break; } - case idxPr: { + case kIdxPr: { nsigma = responsePr.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDPr); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDPr); break; } - case idxDe: { + case kIdxDe: { nsigma = responseDe.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDDe); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDDe); break; } - case idxTr: { + case kIdxTr: { nsigma = responseTr.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDTr); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDTr); break; } - case idxHe: { + case kIdxHe: { nsigma = responseHe.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDHe); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDHe); break; } - case idxAl: { + case kIdxAl: { nsigma = responseAl.GetSeparation(mRespParamsV3, trk); - aod::pidutils::packInTable(nsigma, tablePIDAl); + aod::pidtof_tiny::binning::packInTable(nsigma, tablePIDAl); break; } default: @@ -1349,55 +1416,55 @@ struct tofPidMerge { } for (auto const& pidId : mEnabledParticlesFull) { // Loop on enabled particle hypotheses with full tables switch (pidId) { - case idxEl: { + case kIdxEl: { resolution = responseEl.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseEl.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullEl(resolution, nsigma); break; } - case idxMu: { + case kIdxMu: { resolution = responseMu.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseMu.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullMu(resolution, nsigma); break; } - case idxPi: { + case kIdxPi: { resolution = responsePi.GetExpectedSigma(mRespParamsV3, trk); nsigma = responsePi.GetSeparation(mRespParamsV3, trk); tablePIDFullPi(resolution, nsigma); break; } - case idxKa: { + case kIdxKa: { resolution = responseKa.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseKa.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullKa(resolution, nsigma); break; } - case idxPr: { + case kIdxPr: { resolution = responsePr.GetExpectedSigma(mRespParamsV3, trk); nsigma = responsePr.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullPr(resolution, nsigma); break; } - case idxDe: { + case kIdxDe: { resolution = responseDe.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseDe.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullDe(resolution, nsigma); break; } - case idxTr: { + case kIdxTr: { resolution = responseTr.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseTr.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullTr(resolution, nsigma); break; } - case idxHe: { + case kIdxHe: { resolution = responseHe.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseHe.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullHe(resolution, nsigma); break; } - case idxAl: { + case kIdxAl: { resolution = responseAl.GetExpectedSigma(mRespParamsV3, trk); nsigma = responseAl.GetSeparation(mRespParamsV3, trk, resolution); tablePIDFullAl(resolution, nsigma); @@ -1413,55 +1480,10 @@ struct tofPidMerge { } } } - PROCESS_SWITCH(tofPidMerge, processRun2, "Produce tables. Set to off if the tables are not required", false); -}; - -// Part 4 Beta and TOF mass computation - -struct tofPidBeta { - Produces tablePIDBeta; - Produces tablePIDTOFMass; - Configurable expreso{"tof-expreso", 80, "Expected resolution for the computation of the expected beta"}; - // Detector response and input parameters - o2::pid::tof::TOFResoParamsV3 mRespParamsV3; - TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration - Service ccdb; - Configurable enableTOFParams{"enableTOFParams", false, "Flag to use TOF parameters"}; - - bool enableTableBeta = false; - bool enableTableMass = false; - void init(o2::framework::InitContext& initContext) - { - mTOFCalibConfig.inheritFromBaseTask(initContext); - enableTableBeta = isTableRequiredInWorkflow(initContext, "pidTOFbeta"); - enableTableMass = isTableRequiredInWorkflow(initContext, "pidTOFmass"); - if (!enableTableBeta && !enableTableMass && !doprocessRun2 && !doprocessRun3) { - LOG(info) << "No table or process is enabled. Disabling task"; - return; - } - - if (mTOFCalibConfig.autoSetProcessFunctions()) { - LOG(info) << "Autodetecting process functions"; - if (metadataInfo.isFullyDefined()) { - if (metadataInfo.isRun3()) { - doprocessRun3.value = true; - } else { - doprocessRun2.value = true; - } - } - } - - responseBeta.mExpectedResolution = expreso.value; - if (!enableTOFParams) { - return; - } - mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters - } - - void process(aod::BCs const&) {} + PROCESS_SWITCH(tofPidMerge, processRun2, "Produce Run 2 Nsigma table. Set to off if the tables are not required, or autoset is on", false); o2::pid::tof::Beta responseBetaRun2; - void processRun2(Run2TrksWtofWevTime const& tracks) + void processRun2BetaM(Run2TrksWtofWevTime const& tracks) { if (!enableTableBeta && !enableTableMass) { return; @@ -1474,7 +1496,7 @@ struct tofPidBeta { tablePIDBeta(beta, responseBetaRun2.GetExpectedSigma(trk)); } if (enableTableMass) { - if (enableTOFParams) { + if (enableTOFParamsForBetaMass) { tablePIDTOFMass(o2::pid::tof::TOFMass::GetTOFMass(trk.tofExpMom() / (1.f + trk.sign() * mRespParamsV3.getMomentumChargeShift(trk.eta())), beta)); } else { tablePIDTOFMass(o2::pid::tof::TOFMass::GetTOFMass(trk, beta)); @@ -1482,10 +1504,10 @@ struct tofPidBeta { } } } - PROCESS_SWITCH(tofPidBeta, processRun2, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", true); + PROCESS_SWITCH(tofPidMerge, processRun2BetaM, "Produce Run 2 Beta and Mass table. Set to off if the tables are not required, or autoset is on", false); o2::pid::tof::Beta responseBeta; - void processRun3(Run3TrksWtofWevTime const& tracks) + void processRun3BetaM(Run3TrksWtofWevTime const& tracks) { if (!enableTableBeta && !enableTableMass) { return; @@ -1499,7 +1521,7 @@ struct tofPidBeta { responseBeta.GetExpectedSigma(trk)); } if (enableTableMass) { - if (enableTOFParams) { + if (enableTOFParamsForBetaMass) { tablePIDTOFMass(o2::pid::tof::TOFMass::GetTOFMass(trk.tofExpMom() / (1.f + trk.sign() * mRespParamsV3.getMomentumChargeShift(trk.eta())), beta)); } else { tablePIDTOFMass(o2::pid::tof::TOFMass::GetTOFMass(trk, beta)); @@ -1507,7 +1529,7 @@ struct tofPidBeta { } } } - PROCESS_SWITCH(tofPidBeta, processRun3, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", true); + PROCESS_SWITCH(tofPidMerge, processRun3BetaM, "Produce Run 3 Beta and Mass table. Set to off if the tables are not required, or autoset is on", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) @@ -1517,6 +1539,5 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) auto workflow = WorkflowSpec{adaptAnalysisTask(cfgc)}; workflow.push_back(adaptAnalysisTask(cfgc)); workflow.push_back(adaptAnalysisTask(cfgc)); - workflow.push_back(adaptAnalysisTask(cfgc)); return workflow; } diff --git a/Common/TableProducer/PID/pidTPC.cxx b/Common/TableProducer/PID/pidTPC.cxx index 1fe071f2717..e9c2015afbc 100644 --- a/Common/TableProducer/PID/pidTPC.cxx +++ b/Common/TableProducer/PID/pidTPC.cxx @@ -18,10 +18,10 @@ /// \brief Task to produce PID tables for TPC split for each particle. /// Only the tables for the mass hypotheses requested are filled, and only for the requested table size ("Full" or "Tiny"). The others are sent empty. /// -#include #include #include #include +#include #include // ROOT includes #include "TFile.h" @@ -29,21 +29,23 @@ #include "TSystem.h" // O2 includes +#include "MetadataHelper.h" +#include "TableHelper.h" +#include "pidTPCBase.h" + +#include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Tools/ML/model.h" + #include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" -#include "Framework/ASoAHelpers.h" #include "ReconstructionDataFormats/Track.h" -#include "CCDB/CcdbApi.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/Core/PID/TPCPIDResponse.h" -#include "Framework/AnalysisDataModel.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/EventSelection.h" -#include "TableHelper.h" -#include "Tools/ML/model.h" -#include "pidTPCBase.h" -#include "MetadataHelper.h" using namespace o2; using namespace o2::framework; @@ -53,7 +55,7 @@ using namespace o2::framework::expressions; using namespace o2::track; using namespace o2::ml; -MetadataHelper metadataInfo; // Metadata helper +o2::common::core::MetadataHelper metadataInfo; // Metadata helper void customize(std::vector& workflowOptions) { @@ -148,15 +150,19 @@ struct tpcPid { Configurable useNetworkHe{"useNetworkHe", 1, {"Switch for applying neural network on the helium3 mass hypothesis (if network enabled) (set to 0 to disable)"}}; Configurable useNetworkAl{"useNetworkAl", 1, {"Switch for applying neural network on the alpha mass hypothesis (if network enabled) (set to 0 to disable)"}}; Configurable networkBetaGammaCutoff{"networkBetaGammaCutoff", 0.45, {"Lower value of beta-gamma to override the NN application"}}; + Configurable networkInputBatchedMode{"networkInputBatchedMode", -1, {"-1: Takes all tracks, >0: Takes networkInputBatchedMode number of tracks at once"}}; // Parametrization configuration bool useCCDBParam = false; + std::vector track_properties; void init(o2::framework::InitContext& initContext) { // Protection for process flags - if ((doprocessStandard && doprocessMcTuneOnData) || (!doprocessStandard && !doprocessMcTuneOnData)) { - LOG(fatal) << "pid-tpc must have only one of the options 'processStandard' OR 'processMcTuneOnData' enabled. Please check your configuration."; + if (!((doprocessStandard && !doprocessStandard2 && !doprocessMcTuneOnData) || + (!doprocessStandard && doprocessStandard2 && !doprocessMcTuneOnData) || + (!doprocessStandard && !doprocessStandard2 && doprocessMcTuneOnData))) { + LOG(fatal) << "pid-tpc must have only one of the options 'processStandard', 'processStandard2', 'processMcTuneOnData' enabled. Please check your configuration."; } response = new o2::pid::tpc::Response(); // Checking the tables are requested in the workflow and enabling them @@ -294,8 +300,6 @@ struct tpcPid { std::vector createNetworkPrediction(C const& collisions, T const& tracks, B const& bcs, const size_t size) { - std::vector network_prediction; - auto start_network_total = std::chrono::high_resolution_clock::now(); if (autofetchNetworks) { const auto& bc = bcs.begin(); @@ -341,20 +345,24 @@ struct tpcPid { // Defining some network parameters int input_dimensions = network.getNumInputNodes(); int output_dimensions = network.getNumOutputNodes(); - const uint64_t track_prop_size = input_dimensions * size; const uint64_t prediction_size = output_dimensions * size; + const uint8_t numSpecies = 9; + const uint64_t total_eval_size = size * numSpecies; // 9 species - network_prediction = std::vector(prediction_size * 9); // For each mass hypotheses const float nNclNormalization = response->GetNClNormalization(); float duration_network = 0; - std::vector track_properties(track_prop_size); - uint64_t counter_track_props = 0; - int loop_counter = 0; + uint64_t counter_track_props = 0, exec_counter = 0, in_batch_counter = 0, total_input_count = 0; + uint64_t track_prop_size = networkInputBatchedMode.value; + if (networkInputBatchedMode.value <= 0) { + track_prop_size = size; // If the networkInputBatchedMode is not set, we use all tracks at once + } + track_properties.resize(track_prop_size * input_dimensions); // If the networkInputBatchedMode is set, we use the number of tracks specified in the config + std::vector network_prediction(prediction_size * numSpecies); // For each mass hypotheses // Filling a std::vector to be evaluated by the network // Evaluation on single tracks brings huge overhead: Thus evaluation is done on one large vector - for (int i = 0; i < 9; i++) { // Loop over particle number for which network correction is used + for (int species = 0; species < numSpecies; species++) { // Loop over particle number for which network correction is used for (auto const& trk : tracks) { if (!trk.hasTPC()) { continue; @@ -364,30 +372,38 @@ struct tpcPid { continue; } } - track_properties[counter_track_props] = trk.tpcInnerParam(); + + if ((in_batch_counter == track_prop_size) || (total_input_count == total_eval_size)) { // If the batch size is reached, reset the counter + int32_t fill_shift = (exec_counter * track_prop_size - ((total_input_count == total_eval_size) ? (total_input_count % track_prop_size) : 0)) * output_dimensions; + auto start_network_eval = std::chrono::high_resolution_clock::now(); + float* output_network = network.evalModel(track_properties); + auto stop_network_eval = std::chrono::high_resolution_clock::now(); + duration_network += std::chrono::duration>(stop_network_eval - start_network_eval).count(); + + for (uint64_t i = 0; i < (in_batch_counter * output_dimensions); i += output_dimensions) { + for (int j = 0; j < output_dimensions; j++) { + network_prediction[i + j + fill_shift] = output_network[i + j]; + } + } + counter_track_props = 0; + in_batch_counter = 0; + exec_counter++; + } + + // LOG(info) << "counter_tracks_props: " << counter_track_props << "; in_batch_counter: " << in_batch_counter << "; total_input_count: " << total_input_count << "; exec_counter: " << exec_counter << "; track_prop_size: " << track_prop_size << "; size: " << size << "; track_properties.size(): " << track_properties.size(); + track_properties[counter_track_props] = trk.tpcInnerParam(); // (tracks.asArrowTable()->GetColumn("tpcInnerParam")).GetData(); track_properties[counter_track_props + 1] = trk.tgl(); track_properties[counter_track_props + 2] = trk.signed1Pt(); - track_properties[counter_track_props + 3] = o2::track::pid_constants::sMasses[i]; + track_properties[counter_track_props + 3] = o2::track::pid_constants::sMasses[species]; track_properties[counter_track_props + 4] = trk.has_collision() ? collisions.iteratorAt(trk.collisionId()).multTPC() / 11000. : 1.; track_properties[counter_track_props + 5] = std::sqrt(nNclNormalization / trk.tpcNClsFound()); if (input_dimensions == 7 && networkVersion == "2") { track_properties[counter_track_props + 6] = trk.has_collision() ? collisions.iteratorAt(trk.collisionId()).ft0cOccupancyInTimeRange() / 60000. : 1.; } counter_track_props += input_dimensions; + in_batch_counter++; + total_input_count++; } - - auto start_network_eval = std::chrono::high_resolution_clock::now(); - float* output_network = network.evalModel(track_properties); - auto stop_network_eval = std::chrono::high_resolution_clock::now(); - duration_network += std::chrono::duration>(stop_network_eval - start_network_eval).count(); - for (uint64_t i = 0; i < prediction_size; i += output_dimensions) { - for (int j = 0; j < output_dimensions; j++) { - network_prediction[i + j + prediction_size * loop_counter] = output_network[i + j]; - } - } - - counter_track_props = 0; - loop_counter += 1; } track_properties.clear(); @@ -431,6 +447,11 @@ struct tpcPid { } float nSigma = -999.f; + int multTPC = 0; + if (trk.has_collision()) { + auto collision = collisions.rawIteratorAt(trk.collisionId()); + multTPC = collision.multTPC(); + } float bg = trk.tpcInnerParam() / o2::track::pid_constants::sMasses[pid]; // estimated beta-gamma for network cutoff if (useNetworkCorrection && speciesNetworkFlags[pid] && trk.has_collision() && bg > networkBetaGammaCutoff) { @@ -453,12 +474,12 @@ struct tpcPid { LOGF(fatal, "Network output-dimensions incompatible!"); } } else { - nSigma = response->GetNumberOfSigmaMCTuned(collisions.iteratorAt(trk.collisionId()), trk, pid, tpcSignal); + nSigma = response->GetNumberOfSigmaMCTunedAtMultiplicity(multTPC, trk, pid, tpcSignal); } if (flagFull) tableFull(expSigma, nSigma); if (flagTiny) - aod::pidutils::packInTable(nSigma, tableTiny); + aod::pidtpc_tiny::binning::packInTable(nSigma, tableTiny); }; void processStandard(Coll const& collisions, Trks const& tracks, aod::BCsWithTimestamps const& bcs) @@ -552,6 +573,98 @@ struct tpcPid { Partition mcnotTPCStandaloneTracks = (aod::track::tpcNClsFindable > static_cast(0)) && ((aod::track::itsClusterSizes > static_cast(0)) || (aod::track::trdPattern > static_cast(0)) || (aod::track::tofExpMom > 0.f && aod::track::tofChi2 > 0.f)); // To count number of tracks for use in NN array Partition mctracksWithTPC = (aod::track::tpcNClsFindable > (uint8_t)0); + void processStandard2(Coll const& collisions, Trks const& tracks, aod::DEdxsCorrected const& dedxscorrected, aod::BCsWithTimestamps const& bcs) + { + const uint64_t outTable_size = tracks.size(); + const uint64_t dedxscorrected_size = dedxscorrected.size(); + + if (dedxscorrected_size != outTable_size) { + LOG(fatal) << "Size of dEdx corrected table does not match size of tracks! dEdx size: " << dedxscorrected_size << ", tracks size: " << outTable_size; + } + + auto reserveTable = [&outTable_size](const Configurable& flag, auto& table) { + if (flag.value != 1) { + return; + } + table.reserve(outTable_size); + }; + + // Prepare memory for enabled tables + reserveTable(pidFullEl, tablePIDFullEl); + reserveTable(pidFullMu, tablePIDFullMu); + reserveTable(pidFullPi, tablePIDFullPi); + reserveTable(pidFullKa, tablePIDFullKa); + reserveTable(pidFullPr, tablePIDFullPr); + reserveTable(pidFullDe, tablePIDFullDe); + reserveTable(pidFullTr, tablePIDFullTr); + reserveTable(pidFullHe, tablePIDFullHe); + reserveTable(pidFullAl, tablePIDFullAl); + + reserveTable(pidTinyEl, tablePIDTinyEl); + reserveTable(pidTinyMu, tablePIDTinyMu); + reserveTable(pidTinyPi, tablePIDTinyPi); + reserveTable(pidTinyKa, tablePIDTinyKa); + reserveTable(pidTinyPr, tablePIDTinyPr); + reserveTable(pidTinyDe, tablePIDTinyDe); + reserveTable(pidTinyTr, tablePIDTinyTr); + reserveTable(pidTinyHe, tablePIDTinyHe); + reserveTable(pidTinyAl, tablePIDTinyAl); + + const uint64_t tracksForNet_size = (skipTPCOnly) ? notTPCStandaloneTracks.size() : tracksWithTPC.size(); + std::vector network_prediction; + + if (useNetworkCorrection) { + network_prediction = createNetworkPrediction(collisions, tracks, bcs, tracksForNet_size); + } + + uint64_t count_tracks = 0; + uint64_t count_tracks2 = 0; + + for (auto const& trk : tracks) { + // Loop on Tracks + + const auto& bc = trk.has_collision() ? collisions.iteratorAt(trk.collisionId()).bc_as() : bcs.begin(); + auto dedx_corr = dedxscorrected.iteratorAt(count_tracks2); + count_tracks2++; + if (useCCDBParam && ccdbTimestamp.value == 0 && !ccdb->isCachedObjectValid(ccdbPath.value, bc.timestamp())) { // Updating parametrisation only if the initial timestamp is 0 + if (recoPass.value == "") { + LOGP(info, "Retrieving latest TPC response object for timestamp {}:", bc.timestamp()); + } else { + LOGP(info, "Retrieving TPC Response for timestamp {} and recoPass {}:", bc.timestamp(), recoPass.value); + } + response = ccdb->getSpecific(ccdbPath.value, bc.timestamp(), metadata); + headers = ccdbApi.retrieveHeaders(ccdbPath.value, metadata, bc.timestamp()); + if (!response) { + LOGP(warning, "!! Could not find a valid TPC response object for specific pass name {}! Falling back to latest uploaded object.", metadata["RecoPassName"]); + response = ccdb->getForTimeStamp(ccdbPath.value, bc.timestamp()); + headers = ccdbApi.retrieveHeaders(ccdbPath.value, nullmetadata, bc.timestamp()); + if (!response) { + LOGP(fatal, "Could not find ANY TPC response object for the timestamp {}!", bc.timestamp()); + } + } + LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << bc.timestamp() << ", period " << headers["LPMProductionTag"] << ", recoPass " << headers["RecoPassName"]; + response->PrintAll(); + } + auto makePidTablesDefault = [&trk, &dedx_corr, &collisions, &network_prediction, &count_tracks, &tracksForNet_size, this](const int flagFull, auto& tableFull, const int flagTiny, auto& tableTiny, const o2::track::PID::ID pid) { + makePidTables(flagFull, tableFull, flagTiny, tableTiny, pid, dedx_corr.tpcSignalCorrected(), trk, collisions, network_prediction, count_tracks, tracksForNet_size); + }; + + makePidTablesDefault(pidFullEl, tablePIDFullEl, pidTinyEl, tablePIDTinyEl, o2::track::PID::Electron); + makePidTablesDefault(pidFullMu, tablePIDFullMu, pidTinyMu, tablePIDTinyMu, o2::track::PID::Muon); + makePidTablesDefault(pidFullPi, tablePIDFullPi, pidTinyPi, tablePIDTinyPi, o2::track::PID::Pion); + makePidTablesDefault(pidFullKa, tablePIDFullKa, pidTinyKa, tablePIDTinyKa, o2::track::PID::Kaon); + makePidTablesDefault(pidFullPr, tablePIDFullPr, pidTinyPr, tablePIDTinyPr, o2::track::PID::Proton); + makePidTablesDefault(pidFullDe, tablePIDFullDe, pidTinyDe, tablePIDTinyDe, o2::track::PID::Deuteron); + makePidTablesDefault(pidFullTr, tablePIDFullTr, pidTinyTr, tablePIDTinyTr, o2::track::PID::Triton); + makePidTablesDefault(pidFullHe, tablePIDFullHe, pidTinyHe, tablePIDTinyHe, o2::track::PID::Helium3); + makePidTablesDefault(pidFullAl, tablePIDFullAl, pidTinyAl, tablePIDTinyAl, o2::track::PID::Alpha); + + if (trk.hasTPC() && (!skipTPCOnly || trk.hasITS() || trk.hasTRD() || trk.hasTOF())) { + count_tracks++; // Increment network track counter only if track has TPC, and (not skipping TPConly) or (is not TPConly) + } + } + } + PROCESS_SWITCH(tpcPid, processStandard2, "Creating PID tables with Corrected dEdx", false); void processMcTuneOnData(CollMC const& collisionsMc, TrksMC const& tracksMc, aod::BCsWithTimestamps const& bcs, aod::McParticles const&) { gRandom->SetSeed(0); // Ensure unique seed from UUID for each process call diff --git a/Common/TableProducer/PID/pidTPCBase.cxx b/Common/TableProducer/PID/pidTPCBase.cxx index cf82ea0c9d5..1f9ef4278fc 100644 --- a/Common/TableProducer/PID/pidTPCBase.cxx +++ b/Common/TableProducer/PID/pidTPCBase.cxx @@ -15,18 +15,21 @@ /// \brief Base to build tasks for TPC PID tasks. /// +#include #include #include -#include // O2 includes -#include "CCDB/BasicCCDBManager.h" -#include "Framework/AnalysisTask.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/FT0Corrected.h" #include "TableHelper.h" #include "pidTPCBase.h" + +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/DataModel/FT0Corrected.h" + +#include "CCDB/BasicCCDBManager.h" +#include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" using namespace o2; using namespace o2::framework; @@ -76,7 +79,105 @@ struct PidMultiplicity { PROCESS_SWITCH(PidMultiplicity, processStandard, "Process with tracks, needs propagated tracks", true); }; +struct DeDxCorrection { + Produces dEdxCorrected; + using BCsRun3 = soa::Join; + using ColEvSels = soa::Join; + using FullTracksIU = soa::Join; + + uint64_t minGlobalBC = 0; + Service ccdb; + ctpRateFetcher mRateFetcher; + + Str_dEdx_correction str_dedx_correction; + + // void init(InitContext& initContext) + void init(o2::framework::InitContext&) + { + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + str_dedx_correction.init(); + } + + void processRun3( + ColEvSels const& cols, + FullTracksIU const& tracks, + aod::BCsWithTimestamps const& bcs) + { + const uint64_t outTable_size = tracks.size(); + dEdxCorrected.reserve(outTable_size); + + for (auto const& trk : tracks) { + double hadronicRate; + int multTPC; + int occupancy; + if (trk.has_collision()) { + auto collision = cols.iteratorAt(trk.collisionId()); + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, "ZNC hadronic") * 1.e-3; // kHz + multTPC = collision.multTPC(); + occupancy = collision.trackOccupancyInTimeRange(); + } else { + auto bc = bcs.begin(); + const int runnumber = bc.runNumber(); + hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, "ZNC hadronic") * 1.e-3; // kHz + multTPC = 0; + occupancy = 0; + } + + float fTPCSignal = trk.tpcSignal(); + float fNormMultTPC = multTPC / 11000.; + + float fTrackOccN = occupancy / 1000.; + float fOccTPCN = fNormMultTPC * 10; //(fNormMultTPC*10).clip(0,12) + if (fOccTPCN > 12) + fOccTPCN = 12; + else if (fOccTPCN < 0) + fOccTPCN = 0; + + float fTrackOccMeanN = hadronicRate / 5; + float side = trk.tgl() > 0 ? 1 : 0; + float a1pt = std::abs(trk.signed1Pt()); + float a1pt2 = a1pt * a1pt; + float atgl = std::abs(trk.tgl()); + float mbb0R = 50 / fTPCSignal; + if (mbb0R > 1.05) + mbb0R = 1.05; + else if (mbb0R < 0.05) + mbb0R = 0.05; + // float mbb0R = max(0.05, min(50 / fTPCSignal, 1.05)); + float a1ptmbb0R = a1pt * mbb0R; + float atglmbb0R = atgl * mbb0R; + + std::vector vec_occu = {fTrackOccN, fOccTPCN, fTrackOccMeanN}; + std::vector vec_track = {mbb0R, a1pt, atgl, atglmbb0R, a1ptmbb0R, side, a1pt2}; + + float fTPCSignalN_CR0 = str_dedx_correction.fReal_fTPCSignalN(vec_occu, vec_track); + + float mbb0R1 = 50 / (fTPCSignal / fTPCSignalN_CR0); + if (mbb0R1 > 1.05) + mbb0R1 = 1.05; + else if (mbb0R1 < 0.05) + mbb0R1 = 0.05; + + std::vector vec_track1 = {mbb0R1, a1pt, atgl, atgl * mbb0R1, a1pt * mbb0R1, side, a1pt2}; + float fTPCSignalN_CR1 = str_dedx_correction.fReal_fTPCSignalN(vec_occu, vec_track1); + + float corrected_dEdx = fTPCSignal / fTPCSignalN_CR1; + dEdxCorrected(corrected_dEdx); + } + } + PROCESS_SWITCH(DeDxCorrection, processRun3, "dEdx correction process", false); + + void processDummy(aod::Collisions const&) {} + + PROCESS_SWITCH(DeDxCorrection, processDummy, "Do nothing", true); +}; + WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; } diff --git a/Common/TableProducer/PID/pidTPCBase.h b/Common/TableProducer/PID/pidTPCBase.h index a882a598ef9..42dedec46ff 100644 --- a/Common/TableProducer/PID/pidTPCBase.h +++ b/Common/TableProducer/PID/pidTPCBase.h @@ -19,15 +19,24 @@ #define COMMON_TABLEPRODUCER_PID_PIDTPCBASE_H_ #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseTPC.h" + +#include "TMatrixD.h" namespace o2::aod { +namespace pid +{ +DECLARE_SOA_COLUMN(TpcSignalCorrected, tpcSignalCorrected, float); //! +}; // namespace pid + DECLARE_SOA_TABLE(PIDMults, "AOD", "PIDMults", //! TPC auxiliary table for the PID o2::soa::Marker<1>, mult::MultTPC); +DECLARE_SOA_TABLE_FULL(DEdxsCorrected, "DEdxsCorrected", "AOD", "DEDXCORR", pid::TpcSignalCorrected); //! using PIDMult = PIDMults::iterator; +using DEdxCorrected = DEdxsCorrected::iterator; //! } // namespace o2::aod @@ -57,4 +66,41 @@ int getPIDIndex(const int pdgCode) // Get O2 PID index corresponding to MC PDG c } } +typedef struct Str_dEdx_correction { + TMatrixD fMatrix; + bool warning = true; + + // void init(std::vector& params) + void init() + { + double elements[32] = {0.99091, -0.015053, 0.0018912, -0.012305, + 0.081387, 0.003205, -0.0087404, -0.0028608, + 0.013066, 0.017012, -0.0018469, -0.0052177, + -0.0035655, 0.0017846, 0.0019127, -0.00012964, + 0.0049428, 0.0055592, -0.0010618, -0.0016134, + -0.0059098, 0.0013335, 0.00052133, 3.1119e-05, + -0.004882, 0.00077317, -0.0013827, 0.003249, + -0.00063689, 0.0016218, -0.00045215, -1.5815e-05}; + fMatrix.ResizeTo(4, 8); + fMatrix.SetMatrixArray(elements); + } + + float fReal_fTPCSignalN(std::vector vec1, std::vector vec2) + { + float result = 0.f; + // push 1. + vec1.insert(vec1.begin(), 1.0); + vec2.insert(vec2.begin(), 1.0); + for (int i = 0; i < fMatrix.GetNrows(); i++) { + for (int j = 0; j < fMatrix.GetNcols(); j++) { + double param = fMatrix(i, j); + double value1 = i > static_cast(vec1.size()) ? 0 : vec1[i]; + double value2 = j > static_cast(vec2.size()) ? 0 : vec2[j]; + result += param * value1 * value2; + } + } + return result; + } +} Str_dEdx_correction; + #endif // COMMON_TABLEPRODUCER_PID_PIDTPCBASE_H_ diff --git a/Common/TableProducer/PID/pidTPCModule.h b/Common/TableProducer/PID/pidTPCModule.h new file mode 100644 index 00000000000..321b6e39329 --- /dev/null +++ b/Common/TableProducer/PID/pidTPCModule.h @@ -0,0 +1,793 @@ +// 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. + +/// \file pidTPCModule.h +/// \brief Task to produce PID tables for TPC split for each particle. +/// Only the tables for the mass hypotheses requested are filled, and only for the requested table size +/// ("Full" or "Tiny"). The others are sent empty. +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \author Christian Sonnabend christian.sonnabend@cern.ch +/// \author Annalena Kalteyer annalena.sophie.kalteyer@cern.ch +/// \author Jeremy Wilkinson jeremy.wilkinson@cern.ch + +#ifndef COMMON_TOOLS_PIDTPCMODULE_H_ +#define COMMON_TOOLS_PIDTPCMODULE_H_ + +#include +#include +#include +#include +#include +// ROOT includes +#include "TFile.h" +#include "TRandom.h" +#include "TSystem.h" + +// O2 includes +#include "MetadataHelper.h" +#include "TableHelper.h" +#include "pidTPCBase.h" + +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Tools/ML/model.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +namespace o2::aod +{ +namespace pid +{ +struct pidTPCProducts : o2::framework::ProducesGroup { + // Intermediate tables (provide only if requested) + o2::framework::Produces dEdxCorrected; + o2::framework::Produces mult; + + // Tables produced by TPC component + o2::framework::Produces tablePIDFullEl; + o2::framework::Produces tablePIDFullMu; + o2::framework::Produces tablePIDFullPi; + o2::framework::Produces tablePIDFullKa; + o2::framework::Produces tablePIDFullPr; + o2::framework::Produces tablePIDFullDe; + o2::framework::Produces tablePIDFullTr; + o2::framework::Produces tablePIDFullHe; + o2::framework::Produces tablePIDFullAl; + + o2::framework::Produces tablePIDTinyEl; + o2::framework::Produces tablePIDTinyMu; + o2::framework::Produces tablePIDTinyPi; + o2::framework::Produces tablePIDTinyKa; + o2::framework::Produces tablePIDTinyPr; + o2::framework::Produces tablePIDTinyDe; + o2::framework::Produces tablePIDTinyTr; + o2::framework::Produces tablePIDTinyHe; + o2::framework::Produces tablePIDTinyAl; + o2::framework::Produces tableTuneOnData; +}; + +struct pidTPCConfigurables : o2::framework::ConfigurableGroup { + std::string prefix = "pidTPC"; + o2::framework::Configurable paramfile{"param-file", "", "Path to the parametrization object, if empty the parametrization is not taken from file"}; + o2::framework::Configurable ccdbPath{"ccdbPath", "Analysis/PID/TPC/Response", "Path of the TPC parametrization on the CCDB"}; + o2::framework::Configurable recoPass{"recoPass", "", "Reconstruction pass name for CCDB query (automatically takes latest object for timestamp if blank)"}; + o2::framework::Configurable ccdbTimestamp{"ccdb-timestamp", 0, "timestamp of the object used to query in CCDB the detector response. Exceptions: -1 gets the latest object, 0 gets the run dependent timestamp"}; + // Parameters for loading network from a file / downloading the file + o2::framework::Configurable useNetworkCorrection{"useNetworkCorrection", 0, "(bool) Wether or not to use the network correction for the TPC dE/dx signal"}; + o2::framework::Configurable autofetchNetworks{"autofetchNetworks", 1, "(bool) Automatically fetches networks from CCDB for the correct run number"}; + o2::framework::Configurable skipTPCOnly{"skipTPCOnly", false, "Flag to skip TPC only tracks (faster but affects the analyses that use TPC only tracks)"}; + o2::framework::Configurable networkPathLocally{"networkPathLocally", "network.onnx", "(std::string) Path to the local .onnx file. If autofetching is enabled, then this is where the files will be downloaded"}; + o2::framework::Configurable networkPathCCDB{"networkPathCCDB", "Analysis/PID/TPC/ML", "Path on CCDB"}; + o2::framework::Configurable enableNetworkOptimizations{"enableNetworkOptimizations", 1, "(bool) If the neural network correction is used, this enables GraphOptimizationLevel::ORT_ENABLE_EXTENDED in the ONNX session"}; + o2::framework::Configurable networkSetNumThreads{"networkSetNumThreads", 0, "Especially important for running on a SLURM cluster. Sets the number of threads used for execution."}; + // Configuration flags to include and exclude particle hypotheses + o2::framework::Configurable savedEdxsCorrected{"savedEdxsCorrected", -1, {"Save table with corrected dE/dx calculated on the spot. 0: off, 1: on, -1: auto"}}; + o2::framework::Configurable useCorrecteddEdx{"useCorrecteddEdx", false, "(bool) If true, use corrected dEdx value in Nsigma calculation instead of the one in the AO2D"}; + + o2::framework::Configurable pidFullEl{"pid-full-el", -1, {"Produce PID information for the Electron mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidFullMu{"pid-full-mu", -1, {"Produce PID information for the Muon mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidFullPi{"pid-full-pi", -1, {"Produce PID information for the Pion mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidFullKa{"pid-full-ka", -1, {"Produce PID information for the Kaon mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidFullPr{"pid-full-pr", -1, {"Produce PID information for the Proton mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidFullDe{"pid-full-de", -1, {"Produce PID information for the Deuterons mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidFullTr{"pid-full-tr", -1, {"Produce PID information for the Triton mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidFullHe{"pid-full-he", -1, {"Produce PID information for the Helium3 mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidFullAl{"pid-full-al", -1, {"Produce PID information for the Alpha mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidTinyEl{"pid-tiny-el", -1, {"Produce PID information for the Electron mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidTinyMu{"pid-tiny-mu", -1, {"Produce PID information for the Muon mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidTinyPi{"pid-tiny-pi", -1, {"Produce PID information for the Pion mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidTinyKa{"pid-tiny-ka", -1, {"Produce PID information for the Kaon mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidTinyPr{"pid-tiny-pr", -1, {"Produce PID information for the Proton mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidTinyDe{"pid-tiny-de", -1, {"Produce PID information for the Deuterons mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidTinyTr{"pid-tiny-tr", -1, {"Produce PID information for the Triton mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidTinyHe{"pid-tiny-he", -1, {"Produce PID information for the Helium3 mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable pidTinyAl{"pid-tiny-al", -1, {"Produce PID information for the Alpha mass hypothesis, overrides the automatic setup: the corresponding table can be set off (0) or on (1)"}}; + o2::framework::Configurable enableTuneOnDataTable{"enableTuneOnDataTable", -1, {"Produce tuned dE/dx signal table for MC to be used as raw signal in other tasks (default -1, 'only if needed'"}}; + o2::framework::Configurable useNetworkEl{"useNetworkEl", 1, {"Switch for applying neural network on the electron mass hypothesis (if network enabled) (set to 0 to disable)"}}; + o2::framework::Configurable useNetworkMu{"useNetworkMu", 1, {"Switch for applying neural network on the muon mass hypothesis (if network enabled) (set to 0 to disable)"}}; + o2::framework::Configurable useNetworkPi{"useNetworkPi", 1, {"Switch for applying neural network on the pion mass hypothesis (if network enabled) (set to 0 to disable)"}}; + o2::framework::Configurable useNetworkKa{"useNetworkKa", 1, {"Switch for applying neural network on the kaon mass hypothesis (if network enabled) (set to 0 to disable)"}}; + o2::framework::Configurable useNetworkPr{"useNetworkPr", 1, {"Switch for applying neural network on the proton mass hypothesis (if network enabled) (set to 0 to disable)"}}; + o2::framework::Configurable useNetworkDe{"useNetworkDe", 1, {"Switch for applying neural network on the deuteron mass hypothesis (if network enabled) (set to 0 to disable)"}}; + o2::framework::Configurable useNetworkTr{"useNetworkTr", 1, {"Switch for applying neural network on the triton mass hypothesis (if network enabled) (set to 0 to disable)"}}; + o2::framework::Configurable useNetworkHe{"useNetworkHe", 1, {"Switch for applying neural network on the helium3 mass hypothesis (if network enabled) (set to 0 to disable)"}}; + o2::framework::Configurable useNetworkAl{"useNetworkAl", 1, {"Switch for applying neural network on the alpha mass hypothesis (if network enabled) (set to 0 to disable)"}}; + o2::framework::Configurable networkBetaGammaCutoff{"networkBetaGammaCutoff", 0.45, {"Lower value of beta-gamma to override the NN application"}}; +}; + +// helper getter - FIXME should be separate +int getPIDIndex(const int pdgCode) // Get O2 PID index corresponding to MC PDG code +{ + switch (abs(pdgCode)) { + case 11: + return o2::track::PID::Electron; + case 13: + return o2::track::PID::Muon; + case 211: + return o2::track::PID::Pion; + case 321: + return o2::track::PID::Kaon; + case 2212: + return o2::track::PID::Proton; + case 1000010020: + return o2::track::PID::Deuteron; + case 1000010030: + return o2::track::PID::Triton; + case 1000020030: + return o2::track::PID::Helium3; + case 1000020040: + return o2::track::PID::Alpha; + default: // treat as pion if not any of the above + return o2::track::PID::Pion; + } +} + +typedef struct Str_dEdx_correction { + TMatrixD fMatrix; + bool warning = true; + + // void init(std::vector& params) + void init() + { + double elements[32] = {0.99091, -0.015053, 0.0018912, -0.012305, + 0.081387, 0.003205, -0.0087404, -0.0028608, + 0.013066, 0.017012, -0.0018469, -0.0052177, + -0.0035655, 0.0017846, 0.0019127, -0.00012964, + 0.0049428, 0.0055592, -0.0010618, -0.0016134, + -0.0059098, 0.0013335, 0.00052133, 3.1119e-05, + -0.004882, 0.00077317, -0.0013827, 0.003249, + -0.00063689, 0.0016218, -0.00045215, -1.5815e-05}; + fMatrix.ResizeTo(4, 8); + fMatrix.SetMatrixArray(elements); + } + + float fReal_fTPCSignalN(std::vector vec1, std::vector vec2) + { + float result = 0.f; + // push 1. + vec1.insert(vec1.begin(), 1.0); + vec2.insert(vec2.begin(), 1.0); + for (int i = 0; i < fMatrix.GetNrows(); i++) { + for (int j = 0; j < fMatrix.GetNcols(); j++) { + double param = fMatrix(i, j); + double value1 = i > static_cast(vec1.size()) ? 0 : vec1[i]; + double value2 = j > static_cast(vec2.size()) ? 0 : vec2[j]; + result += param * value1 * value2; + } + } + return result; + } +} Str_dEdx_correction; + +class pidTPCModule +{ + public: + pidTPCModule() + { + // constructor + } + o2::aod::pid::pidTPCConfigurables pidTPCopts; + + // TPC PID Response + o2::pid::tpc::Response* response; + + // Network correction for TPC PID response + ml::OnnxModel network; + std::map metadata; + std::map nullmetadata; + std::map headers; + std::vector speciesNetworkFlags = std::vector(9); + std::string networkVersion; + + // Parametrization configuration + bool useCCDBParam = false; + + // for dEdx correction + ctpRateFetcher mRateFetcher; + Str_dEdx_correction str_dedx_correction; + + //__________________________________________________ + template + void init(TCCDB& ccdb, TCCDBApi& ccdbApi, TContext& context, TpidTPCOpts const& external_pidtpcopts, TMetadataInfo const& metadataInfo) + { + // read in configurations from the task where it's used + pidTPCopts = external_pidtpcopts; + + if (pidTPCopts.useCorrecteddEdx.value) { + LOGF(info, "***************************************************"); + LOGF(info, " WARNING: YOU HAVE SWITCHED ON 'corrected dEdx!"); + LOGF(info, " This mode is still in development and it is meant"); + LOGF(info, " ONLY FOR EXPERTS at this time. Please switch "); + LOGF(info, " this option off UNLESS you are absolutely SURE"); + LOGF(info, " of what you're doing! You've been warned!"); + LOGF(info, "***************************************************"); + } + + // initialize PID response + response = new o2::pid::tpc::Response(); + + enableFlagIfTableRequired(context, "DEdxsCorrected", pidTPCopts.savedEdxsCorrected); + + // Checking the tables are requested in the workflow and enabling them + auto enableFlag = [&](const std::string particle, o2::framework::Configurable& flag) { + enableFlagIfTableRequired(context, "pidTPC" + particle, flag); + }; + enableFlag("FullEl", pidTPCopts.pidFullEl); + enableFlag("FullMu", pidTPCopts.pidFullMu); + enableFlag("FullPi", pidTPCopts.pidFullPi); + enableFlag("FullKa", pidTPCopts.pidFullKa); + enableFlag("FullPr", pidTPCopts.pidFullPr); + enableFlag("FullDe", pidTPCopts.pidFullDe); + enableFlag("FullTr", pidTPCopts.pidFullTr); + enableFlag("FullHe", pidTPCopts.pidFullHe); + enableFlag("FullAl", pidTPCopts.pidFullAl); + + enableFlag("El", pidTPCopts.pidTinyEl); + enableFlag("Mu", pidTPCopts.pidTinyMu); + enableFlag("Pi", pidTPCopts.pidTinyPi); + enableFlag("Ka", pidTPCopts.pidTinyKa); + enableFlag("Pr", pidTPCopts.pidTinyPr); + enableFlag("De", pidTPCopts.pidTinyDe); + enableFlag("Tr", pidTPCopts.pidTinyTr); + enableFlag("He", pidTPCopts.pidTinyHe); + enableFlag("Al", pidTPCopts.pidTinyAl); + + if (metadataInfo.isMC()) { + enableFlagIfTableRequired(context, "mcTPCTuneOnData", pidTPCopts.enableTuneOnDataTable); + } + + speciesNetworkFlags[0] = pidTPCopts.useNetworkEl; + speciesNetworkFlags[1] = pidTPCopts.useNetworkMu; + speciesNetworkFlags[2] = pidTPCopts.useNetworkPi; + speciesNetworkFlags[3] = pidTPCopts.useNetworkKa; + speciesNetworkFlags[4] = pidTPCopts.useNetworkPr; + speciesNetworkFlags[5] = pidTPCopts.useNetworkDe; + speciesNetworkFlags[6] = pidTPCopts.useNetworkTr; + speciesNetworkFlags[7] = pidTPCopts.useNetworkHe; + speciesNetworkFlags[8] = pidTPCopts.useNetworkAl; + + // Initialise metadata object for CCDB calls from AO2D metadata + if (pidTPCopts.recoPass.value == "") { + if (metadataInfo.isFullyDefined()) { + metadata["RecoPassName"] = metadataInfo.get("RecoPassName"); + LOGP(info, "Automatically setting reco pass for TPC Response to {} from AO2D", metadata["RecoPassName"]); + } + } else { + LOGP(info, "Setting reco pass for TPC response to user-defined name {}", pidTPCopts.recoPass.value); + metadata["RecoPassName"] = pidTPCopts.recoPass.value; + } + + /// TPC PID Response + const TString fname = pidTPCopts.paramfile.value; + if (fname != "") { // Loading the parametrization from file + LOGP(info, "Loading TPC response from file {}", fname.Data()); + try { + std::unique_ptr f(TFile::Open(fname, "READ")); + f->GetObject("Response", response); + } catch (...) { + LOGF(fatal, "Loading the TPC PID Response from file {} failed!", fname.Data()); + } + response->PrintAll(); + } else { + useCCDBParam = true; + const std::string path = pidTPCopts.ccdbPath.value; + const auto time = pidTPCopts.ccdbTimestamp.value; + if (time != 0) { + LOGP(info, "Initialising TPC PID response for fixed timestamp {} and reco pass {}:", time, pidTPCopts.recoPass.value); + ccdb->setTimestamp(time); + response = ccdb->template getSpecific(path, time, metadata); + headers = ccdbApi.retrieveHeaders(path, metadata, time); + if (!response) { + LOGF(warning, "Unable to find TPC parametrisation for specified pass name - falling back to latest object"); + response = ccdb->template getForTimeStamp(path, time); + headers = ccdbApi.retrieveHeaders(path, metadata, time); + networkVersion = headers["NN-Version"]; + if (!response) { + LOGF(fatal, "Unable to find any TPC object corresponding to timestamp {}!", time); + } + } + LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << time << ", period " << headers["LPMProductionTag"] << ", recoPass " << headers["RecoPassName"]; + metadata["RecoPassName"] = headers["RecoPassName"]; // Force pass number for NN request to match retrieved BB + response->PrintAll(); + } + } + + /// Neural network init for TPC PID + if (!pidTPCopts.useNetworkCorrection) { + return; + } else { + /// CCDB and auto-fetching + if (!pidTPCopts.autofetchNetworks) { + if (pidTPCopts.ccdbTimestamp > 0) { + /// Fetching network for specific timestamp + LOG(info) << "Fetching network for timestamp: " << pidTPCopts.ccdbTimestamp.value; + bool retrieveSuccess = ccdbApi.retrieveBlob(pidTPCopts.networkPathCCDB.value, ".", metadata, pidTPCopts.ccdbTimestamp.value, false, pidTPCopts.networkPathLocally.value); + headers = ccdbApi.retrieveHeaders(pidTPCopts.networkPathCCDB.value, metadata, pidTPCopts.ccdbTimestamp.value); + networkVersion = headers["NN-Version"]; + if (retrieveSuccess) { + network.initModel(pidTPCopts.networkPathLocally.value, pidTPCopts.enableNetworkOptimizations.value, pidTPCopts.networkSetNumThreads.value, strtoul(headers["Valid-From"].c_str(), NULL, 0), strtoul(headers["Valid-Until"].c_str(), NULL, 0)); + std::vector dummyInput(network.getNumInputNodes(), 1.); + network.evalModel(dummyInput); /// Init the model evaluations + LOGP(info, "Retrieved NN corrections for production tag {}, pass number {}, and NN-Version {}", headers["LPMProductionTag"], headers["RecoPassName"], headers["NN-Version"]); + } else { + LOG(fatal) << "No valid NN object found matching retrieved Bethe-Bloch parametrisation for pass " << metadata["RecoPassName"] << ". Please ensure that the requested pass has dedicated NN corrections available"; + } + } else { + /// Taking the network from local file + if (pidTPCopts.networkPathLocally.value == "") { + LOG(fatal) << "Local path must be set (flag networkPathLocally)! Aborting..."; + } + LOG(info) << "Using local file [" << pidTPCopts.networkPathLocally.value << "] for the TPC PID response correction."; + network.initModel(pidTPCopts.networkPathLocally.value, pidTPCopts.enableNetworkOptimizations.value, pidTPCopts.networkSetNumThreads.value); + std::vector dummyInput(network.getNumInputNodes(), 1.); + network.evalModel(dummyInput); // This is an initialisation and might reduce the overhead of the model + } + } else { + return; + } + } + + if (pidTPCopts.useCorrecteddEdx.value && networkVersion != "5") { + LOGF(fatal, "Using corrected dE/dx with a network version other than 5 will not work. Crashing now."); + } + } // end init + + //__________________________________________________ + template + std::vector createNetworkPrediction(TCCDB& ccdb, TCCDBApi& ccdbApi, C const& collisions, M const& mults, T const& tracks, B const& bcs, const size_t size) + { + + std::vector network_prediction; + + auto start_network_total = std::chrono::high_resolution_clock::now(); + if (pidTPCopts.autofetchNetworks) { + const auto& bc = bcs.begin(); + // Initialise correct TPC response object before NN setup (for NCl normalisation) + if (useCCDBParam && pidTPCopts.ccdbTimestamp.value == 0 && !ccdb->isCachedObjectValid(pidTPCopts.ccdbPath.value, bc.timestamp())) { // Updating parametrisation only if the initial timestamp is 0 + if (pidTPCopts.recoPass.value == "") { + LOGP(info, "Retrieving latest TPC response object for timestamp {}:", bc.timestamp()); + } else { + LOGP(info, "Retrieving TPC Response for timestamp {} and recoPass {}:", bc.timestamp(), pidTPCopts.recoPass.value); + } + response = ccdb->template getSpecific(pidTPCopts.ccdbPath.value, bc.timestamp(), metadata); + headers = ccdbApi.retrieveHeaders(pidTPCopts.ccdbPath.value, metadata, bc.timestamp()); + networkVersion = headers["NN-Version"]; + if (!response) { + LOGP(warning, "!! Could not find a valid TPC response object for specific pass name {}! Falling back to latest uploaded object.", metadata["RecoPassName"]); + headers = ccdbApi.retrieveHeaders(pidTPCopts.ccdbPath.value, nullmetadata, bc.timestamp()); + response = ccdb->template getForTimeStamp(pidTPCopts.ccdbPath.value, bc.timestamp()); + if (!response) { + LOGP(fatal, "Could not find ANY TPC response object for the timestamp {}!", bc.timestamp()); + } + } + LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << bc.timestamp() << ", period " << headers["LPMProductionTag"] << ", recoPass " << headers["RecoPassName"]; + metadata["RecoPassName"] = headers["RecoPassName"]; // Force pass number for NN request to match retrieved BB + response->PrintAll(); + } + + if (bc.timestamp() < network.getValidityFrom() || bc.timestamp() > network.getValidityUntil()) { // fetches network only if the runnumbers change + LOG(info) << "Fetching network for timestamp: " << bc.timestamp(); + bool retrieveSuccess = ccdbApi.retrieveBlob(pidTPCopts.networkPathCCDB.value, ".", metadata, bc.timestamp(), false, pidTPCopts.networkPathLocally.value); + headers = ccdbApi.retrieveHeaders(pidTPCopts.networkPathCCDB.value, metadata, bc.timestamp()); + networkVersion = headers["NN-Version"]; + if (retrieveSuccess) { + network.initModel(pidTPCopts.networkPathLocally.value, pidTPCopts.enableNetworkOptimizations.value, pidTPCopts.networkSetNumThreads.value, strtoul(headers["Valid-From"].c_str(), NULL, 0), strtoul(headers["Valid-Until"].c_str(), NULL, 0)); + std::vector dummyInput(network.getNumInputNodes(), 1.); + network.evalModel(dummyInput); + LOGP(info, "Retrieved NN corrections for production tag {}, pass number {}, NN-Version number{}", headers["LPMProductionTag"], headers["RecoPassName"], headers["NN-Version"]); + } else { + LOG(fatal) << "No valid NN object found matching retrieved Bethe-Bloch parametrisation for pass " << metadata["RecoPassName"] << ". Please ensure that the requested pass has dedicated NN corrections available"; + } + } + } + + // Defining some network parameters + int input_dimensions = network.getNumInputNodes(); + int output_dimensions = network.getNumOutputNodes(); + const uint64_t track_prop_size = input_dimensions * size; + const uint64_t prediction_size = output_dimensions * size; + + network_prediction = std::vector(prediction_size * 9); // For each mass hypotheses + const float nNclNormalization = response->GetNClNormalization(); + float duration_network = 0; + + std::vector track_properties(track_prop_size); + uint64_t counter_track_props = 0; + int loop_counter = 0; + + // Filling a std::vector to be evaluated by the network + // Evaluation on single tracks brings huge overhead: Thus evaluation is done on one large vector + for (int i = 0; i < 9; i++) { // Loop over particle number for which network correction is used + for (auto const& trk : tracks) { + if (!trk.hasTPC()) { + continue; + } + if (pidTPCopts.skipTPCOnly) { + if (!trk.hasITS() && !trk.hasTRD() && !trk.hasTOF()) { + continue; + } + } + track_properties[counter_track_props] = trk.tpcInnerParam(); + track_properties[counter_track_props + 1] = trk.tgl(); + track_properties[counter_track_props + 2] = trk.signed1Pt(); + track_properties[counter_track_props + 3] = o2::track::pid_constants::sMasses[i]; + track_properties[counter_track_props + 4] = trk.has_collision() ? mults[trk.collisionId()] / 11000. : 1.; + track_properties[counter_track_props + 5] = std::sqrt(nNclNormalization / trk.tpcNClsFound()); + if (input_dimensions == 7 && networkVersion == "2") { + track_properties[counter_track_props + 6] = trk.has_collision() ? collisions.iteratorAt(trk.collisionId()).ft0cOccupancyInTimeRange() / 60000. : 1.; + } + counter_track_props += input_dimensions; + } + + auto start_network_eval = std::chrono::high_resolution_clock::now(); + float* output_network = network.evalModel(track_properties); + auto stop_network_eval = std::chrono::high_resolution_clock::now(); + duration_network += std::chrono::duration>(stop_network_eval - start_network_eval).count(); + for (uint64_t i = 0; i < prediction_size; i += output_dimensions) { + for (int j = 0; j < output_dimensions; j++) { + network_prediction[i + j + prediction_size * loop_counter] = output_network[i + j]; + } + } + + counter_track_props = 0; + loop_counter += 1; + } + track_properties.clear(); + + auto stop_network_total = std::chrono::high_resolution_clock::now(); + LOG(debug) << "Neural Network for the TPC PID response correction: Time per track (eval ONNX): " << duration_network / (size * 9) << "ns ; Total time (eval ONNX): " << duration_network / 1000000000 << " s"; + LOG(debug) << "Neural Network for the TPC PID response correction: Time per track (eval + overhead): " << std::chrono::duration>(stop_network_total - start_network_total).count() / (size * 9) << "ns ; Total time (eval + overhead): " << std::chrono::duration>(stop_network_total - start_network_total).count() / 1000000000 << " s"; + + return network_prediction; + } + + //__________________________________________________ + template + void makePidTables(const int flagFull, NSF& tableFull, const int flagTiny, NST& tableTiny, const o2::track::PID::ID pid, const float tpcSignal, const T& trk, const long multTPC, const std::vector& network_prediction, const int& count_tracks, const int& tracksForNet_size) + { + if (flagFull != 1 && flagTiny != 1) { + return; + } + if (!trk.hasTPC() || tpcSignal < 0.f) { + if (flagFull) + tableFull(-999.f, -999.f); + if (flagTiny) + tableTiny(aod::pidtpc_tiny::binning::underflowBin); + return; + } + if (pidTPCopts.skipTPCOnly) { + if (!trk.hasITS() && !trk.hasTRD() && !trk.hasTOF()) { + if (flagFull) + tableFull(-999.f, -999.f); + if (flagTiny) + tableTiny(aod::pidtpc_tiny::binning::underflowBin); + return; + } + } + auto expSignal = response->GetExpectedSignal(trk, pid); + auto expSigma = trk.has_collision() ? response->GetExpectedSigmaAtMultiplicity(multTPC, trk, pid) : 0.07 * expSignal; // use default sigma value of 7% if no collision information to estimate resolution + if (expSignal < 0. || expSigma < 0.) { // skip if expected signal invalid + if (flagFull) + tableFull(-999.f, -999.f); + if (flagTiny) + tableTiny(aod::pidtpc_tiny::binning::underflowBin); + return; + } + + float nSigma = -999.f; + float bg = trk.tpcInnerParam() / o2::track::pid_constants::sMasses[pid]; // estimated beta-gamma for network cutoff + if (pidTPCopts.useNetworkCorrection && speciesNetworkFlags[pid] && trk.has_collision() && bg > pidTPCopts.networkBetaGammaCutoff) { + + // Here comes the application of the network. The output--dimensions of the network determine the application: 1: mean, 2: sigma, 3: sigma asymmetric + // For now only the option 2: sigma will be used. The other options are kept if there would be demand later on + if (network.getNumOutputNodes() == 1) { // Expected mean correction; no sigma correction + nSigma = (tpcSignal - network_prediction[count_tracks + tracksForNet_size * pid] * expSignal) / expSigma; + } else if (network.getNumOutputNodes() == 2) { // Symmetric sigma correction + expSigma = (network_prediction[2 * (count_tracks + tracksForNet_size * pid) + 1] - network_prediction[2 * (count_tracks + tracksForNet_size * pid)]) * expSignal; + nSigma = (tpcSignal / expSignal - network_prediction[2 * (count_tracks + tracksForNet_size * pid)]) / (network_prediction[2 * (count_tracks + tracksForNet_size * pid) + 1] - network_prediction[2 * (count_tracks + tracksForNet_size * pid)]); + } else if (network.getNumOutputNodes() == 3) { // Asymmetric sigma corection + if (tpcSignal / expSignal >= network_prediction[3 * (count_tracks + tracksForNet_size * pid)]) { + expSigma = (network_prediction[3 * (count_tracks + tracksForNet_size * pid) + 1] - network_prediction[3 * (count_tracks + tracksForNet_size * pid)]) * expSignal; + nSigma = (tpcSignal / expSignal - network_prediction[3 * (count_tracks + tracksForNet_size * pid)]) / (network_prediction[3 * (count_tracks + tracksForNet_size * pid) + 1] - network_prediction[3 * (count_tracks + tracksForNet_size * pid)]); + } else { + expSigma = (network_prediction[3 * (count_tracks + tracksForNet_size * pid)] - network_prediction[3 * (count_tracks + tracksForNet_size * pid) + 2]) * expSignal; + nSigma = (tpcSignal / expSignal - network_prediction[3 * (count_tracks + tracksForNet_size * pid)]) / (network_prediction[3 * (count_tracks + tracksForNet_size * pid)] - network_prediction[3 * (count_tracks + tracksForNet_size * pid) + 2]); + } + } else { + LOGF(fatal, "Network output-dimensions incompatible!"); + } + } else { + nSigma = response->GetNumberOfSigmaMCTunedAtMultiplicity(multTPC, trk, pid, tpcSignal); + } + if (flagFull) + tableFull(expSigma, nSigma); + if (flagTiny) + aod::pidtpc_tiny::binning::packInTable(nSigma, tableTiny); + }; + + //__________________________________________________ + template + void process(TCCDB& ccdb, TCCDBApi& ccdbApi, TBCs const& bcs, TCollisions const& cols, TTracks const& tracks, TTracksQA const& tracksQA, TProducts& products) + { + if (tracks.size() == 0) { + return; // empty protection + } + auto trackiterator = tracks.begin(); + if constexpr (requires { trackiterator.mcParticleId(); }) { + gRandom->SetSeed(0); // Ensure unique seed from UUID for each process call + } + + // preparatory step: we need the multiplicities for each collision + std::vector pidmults; + long totalTPCtracks = 0; + long totalTPCnotStandalone = 0; + pidmults.resize(cols.size(), 0); + + // faster counting + for (const auto& track : tracks) { + if (track.hasTPC()) { + if (track.collisionId() > -1) { + pidmults[track.collisionId()]++; + } + totalTPCtracks++; + if (track.hasITS() || track.hasTOF() || track.hasTRD()) { + totalTPCnotStandalone++; + } + } + } + + const uint64_t outTable_size = tracks.size(); + + auto reserveTable = [&outTable_size](const o2::framework::Configurable& flag, auto& table) { + if (flag.value != 1) { + return; + } + table.reserve(outTable_size); + }; + + // Prepare memory for enabled tables + reserveTable(pidTPCopts.pidFullEl, products.tablePIDFullEl); + reserveTable(pidTPCopts.pidFullMu, products.tablePIDFullMu); + reserveTable(pidTPCopts.pidFullPi, products.tablePIDFullPi); + reserveTable(pidTPCopts.pidFullKa, products.tablePIDFullKa); + reserveTable(pidTPCopts.pidFullPr, products.tablePIDFullPr); + reserveTable(pidTPCopts.pidFullDe, products.tablePIDFullDe); + reserveTable(pidTPCopts.pidFullTr, products.tablePIDFullTr); + reserveTable(pidTPCopts.pidFullHe, products.tablePIDFullHe); + reserveTable(pidTPCopts.pidFullAl, products.tablePIDFullAl); + + reserveTable(pidTPCopts.pidTinyEl, products.tablePIDTinyEl); + reserveTable(pidTPCopts.pidTinyMu, products.tablePIDTinyMu); + reserveTable(pidTPCopts.pidTinyPi, products.tablePIDTinyPi); + reserveTable(pidTPCopts.pidTinyKa, products.tablePIDTinyKa); + reserveTable(pidTPCopts.pidTinyPr, products.tablePIDTinyPr); + reserveTable(pidTPCopts.pidTinyDe, products.tablePIDTinyDe); + reserveTable(pidTPCopts.pidTinyTr, products.tablePIDTinyTr); + reserveTable(pidTPCopts.pidTinyHe, products.tablePIDTinyHe); + reserveTable(pidTPCopts.pidTinyAl, products.tablePIDTinyAl); + + const uint64_t tracksForNet_size = (pidTPCopts.skipTPCOnly) ? totalTPCnotStandalone : totalTPCtracks; + std::vector network_prediction; + + if (pidTPCopts.useNetworkCorrection) { + network_prediction = createNetworkPrediction(ccdb, ccdbApi, cols, pidmults, tracks, bcs, tracksForNet_size); + } + + uint64_t count_tracks = 0; + + //_______________________________________ + // process tracksQA in case present + std::vector indexTrack2TrackQA; + if constexpr (soa::is_table) { + for (const auto& trackQA : tracksQA) { + indexTrack2TrackQA[trackQA.trackId()] = trackQA.globalIndex(); + } + } + //_______________________________________ + + for (auto const& trk : tracks) { + // get the TPC signal to be used in the PID + float tpcSignalToEvaluatePID = trk.tpcSignal(); + + int multTPC = 0; + if (trk.has_collision()) { + multTPC = pidmults[trk.collisionId()]; + } + + // if corrected dE/dx is requested, correct it here on the spot and use that + if (pidTPCopts.useCorrecteddEdx) { + + //_________________________________________________________ + // bypass TPC signal in case TracksQA information present + if constexpr (soa::is_table) { + tpcSignalToEvaluatePID = -999.f; + if (indexTrack2TrackQA[trk.globalIndex()] != -1) { + auto trackQA = tracksQA.rawIteratorAt(indexTrack2TrackQA[trk.globalIndex()]); + tpcSignalToEvaluatePID = trackQA.tpcdEdxNorm(); + } + } + //_________________________________________________________ + + double hadronicRate; + int occupancy; + if (trk.has_collision()) { + auto collision = cols.iteratorAt(trk.collisionId()); + auto bc = collision.template bc_as(); + const int runnumber = bc.runNumber(); + hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, "ZNC hadronic") * 1.e-3; // kHz + occupancy = collision.trackOccupancyInTimeRange(); + } else { + auto bc = bcs.begin(); + const int runnumber = bc.runNumber(); + hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, "ZNC hadronic") * 1.e-3; // kHz + occupancy = 0; + } + + float fTPCSignal = tpcSignalToEvaluatePID; + float fNormMultTPC = multTPC / 11000.; + + float fTrackOccN = occupancy / 1000.; + float fOccTPCN = fNormMultTPC * 10; //(fNormMultTPC*10).clip(0,12) + if (fOccTPCN > 12) + fOccTPCN = 12; + else if (fOccTPCN < 0) + fOccTPCN = 0; + + float fTrackOccMeanN = hadronicRate / 5; + float side = trk.tgl() > 0 ? 1 : 0; + float a1pt = std::abs(trk.signed1Pt()); + float a1pt2 = a1pt * a1pt; + float atgl = std::abs(trk.tgl()); + float mbb0R = 50 / fTPCSignal; + if (mbb0R > 1.05) + mbb0R = 1.05; + else if (mbb0R < 0.05) + mbb0R = 0.05; + // float mbb0R = max(0.05, min(50 / fTPCSignal, 1.05)); + float a1ptmbb0R = a1pt * mbb0R; + float atglmbb0R = atgl * mbb0R; + + std::vector vec_occu = {fTrackOccN, fOccTPCN, fTrackOccMeanN}; + std::vector vec_track = {mbb0R, a1pt, atgl, atglmbb0R, a1ptmbb0R, side, a1pt2}; + + float fTPCSignalN_CR0 = str_dedx_correction.fReal_fTPCSignalN(vec_occu, vec_track); + + float mbb0R1 = 50 / (fTPCSignal / fTPCSignalN_CR0); + if (mbb0R1 > 1.05) + mbb0R1 = 1.05; + else if (mbb0R1 < 0.05) + mbb0R1 = 0.05; + + std::vector vec_track1 = {mbb0R1, a1pt, atgl, atgl * mbb0R1, a1pt * mbb0R1, side, a1pt2}; + float fTPCSignalN_CR1 = str_dedx_correction.fReal_fTPCSignalN(vec_occu, vec_track1); + + // change the signal used for PID + tpcSignalToEvaluatePID = fTPCSignal / fTPCSignalN_CR1; + + if (pidTPCopts.savedEdxsCorrected) { + // populated cursor if requested or autodetected + products.dEdxCorrected(tpcSignalToEvaluatePID); + } + } + + const auto& bc = trk.has_collision() ? cols.rawIteratorAt(trk.collisionId()).template bc_as() : bcs.begin(); + if (useCCDBParam && pidTPCopts.ccdbTimestamp.value == 0 && !ccdb->isCachedObjectValid(pidTPCopts.ccdbPath.value, bc.timestamp())) { // Updating parametrisation only if the initial timestamp is 0 + if (pidTPCopts.recoPass.value == "") { + LOGP(info, "Retrieving latest TPC response object for timestamp {}:", bc.timestamp()); + } else { + LOGP(info, "Retrieving TPC Response for timestamp {} and recoPass {}:", bc.timestamp(), pidTPCopts.recoPass.value); + } + response = ccdb->template getSpecific(pidTPCopts.ccdbPath.value, bc.timestamp(), metadata); + headers = ccdbApi.retrieveHeaders(pidTPCopts.ccdbPath.value, metadata, bc.timestamp()); + if (!response) { + LOGP(warning, "!! Could not find a valid TPC response object for specific pass name {}! Falling back to latest uploaded object.", metadata["RecoPassName"]); + response = ccdb->template getForTimeStamp(pidTPCopts.ccdbPath.value, bc.timestamp()); + headers = ccdbApi.retrieveHeaders(pidTPCopts.ccdbPath.value, nullmetadata, bc.timestamp()); + if (!response) { + LOGP(fatal, "Could not find ANY TPC response object for the timestamp {}!", bc.timestamp()); + } + } + LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << bc.timestamp() << ", period " << headers["LPMProductionTag"] << ", recoPass " << headers["RecoPassName"]; + response->PrintAll(); + } + + // if this is a MC process function, go for MC tune on data processing + if constexpr (requires { trk.mcParticleId(); }) { + // Perform TuneOnData sampling for MC dE/dx + float mcTunedTPCSignal = 0.; + if (!trk.hasTPC()) { + mcTunedTPCSignal = -999.f; + } else { + if (pidTPCopts.skipTPCOnly) { + if (!trk.hasITS() && !trk.hasTRD() && !trk.hasTOF()) { + mcTunedTPCSignal = -999.f; + } + } + int pid = getPIDIndex(trk.mcParticle().pdgCode()); + + auto expSignal = response->GetExpectedSignal(trk, pid); + auto expSigma = response->GetExpectedSigmaAtMultiplicity(multTPC, trk, pid); + if (expSignal < 0. || expSigma < 0.) { // if expectation invalid then give undefined signal + mcTunedTPCSignal = -999.f; + } + float bg = trk.tpcInnerParam() / o2::track::pid_constants::sMasses[pid]; // estimated beta-gamma for network cutoff + + if (pidTPCopts.useNetworkCorrection && speciesNetworkFlags[pid] && trk.has_collision() && bg > pidTPCopts.networkBetaGammaCutoff) { + auto mean = network_prediction[2 * (count_tracks + tracksForNet_size * pid)] * expSignal; // Absolute mean, i.e. the mean dE/dx value of the data in that slice, not the mean of the NSigma distribution + auto sigma = (network_prediction[2 * (count_tracks + tracksForNet_size * pid) + 1] - network_prediction[2 * (count_tracks + tracksForNet_size * pid)]) * expSignal; + if (mean < 0.f || sigma < 0.f) { + mcTunedTPCSignal = -999.f; + } else { + mcTunedTPCSignal = gRandom->Gaus(mean, sigma); + } + } else { + mcTunedTPCSignal = gRandom->Gaus(expSignal, expSigma); + } + } + tpcSignalToEvaluatePID = mcTunedTPCSignal; // pass this for further eval + if (pidTPCopts.enableTuneOnDataTable) + products.tableTuneOnData(mcTunedTPCSignal); + } + + auto makePidTablesDefault = [&trk, &tpcSignalToEvaluatePID, &multTPC, &network_prediction, &count_tracks, &tracksForNet_size, this](const int flagFull, auto& tableFull, const int flagTiny, auto& tableTiny, const o2::track::PID::ID pid) { + this->makePidTables(flagFull, tableFull, flagTiny, tableTiny, pid, tpcSignalToEvaluatePID, trk, multTPC, network_prediction, count_tracks, tracksForNet_size); + }; + + makePidTablesDefault(pidTPCopts.pidFullEl, products.tablePIDFullEl, pidTPCopts.pidTinyEl, products.tablePIDTinyEl, o2::track::PID::Electron); + makePidTablesDefault(pidTPCopts.pidFullMu, products.tablePIDFullMu, pidTPCopts.pidTinyMu, products.tablePIDTinyMu, o2::track::PID::Muon); + makePidTablesDefault(pidTPCopts.pidFullPi, products.tablePIDFullPi, pidTPCopts.pidTinyPi, products.tablePIDTinyPi, o2::track::PID::Pion); + makePidTablesDefault(pidTPCopts.pidFullKa, products.tablePIDFullKa, pidTPCopts.pidTinyKa, products.tablePIDTinyKa, o2::track::PID::Kaon); + makePidTablesDefault(pidTPCopts.pidFullPr, products.tablePIDFullPr, pidTPCopts.pidTinyPr, products.tablePIDTinyPr, o2::track::PID::Proton); + makePidTablesDefault(pidTPCopts.pidFullDe, products.tablePIDFullDe, pidTPCopts.pidTinyDe, products.tablePIDTinyDe, o2::track::PID::Deuteron); + makePidTablesDefault(pidTPCopts.pidFullTr, products.tablePIDFullTr, pidTPCopts.pidTinyTr, products.tablePIDTinyTr, o2::track::PID::Triton); + makePidTablesDefault(pidTPCopts.pidFullHe, products.tablePIDFullHe, pidTPCopts.pidTinyHe, products.tablePIDTinyHe, o2::track::PID::Helium3); + makePidTablesDefault(pidTPCopts.pidFullAl, products.tablePIDFullAl, pidTPCopts.pidTinyAl, products.tablePIDTinyAl, o2::track::PID::Alpha); + + if (trk.hasTPC() && (!pidTPCopts.skipTPCOnly || trk.hasITS() || trk.hasTRD() || trk.hasTOF())) { + count_tracks++; // Increment network track counter only if track has TPC, and (not skipping TPConly) or (is not TPConly) + } + } + } // end process function +}; + +} // namespace pid +} // namespace o2::aod + +#endif // COMMON_TOOLS_PIDTPCMODULE_H_ diff --git a/Common/TableProducer/PID/pidTPCService.cxx b/Common/TableProducer/PID/pidTPCService.cxx new file mode 100644 index 00000000000..cff700fca1c --- /dev/null +++ b/Common/TableProducer/PID/pidTPCService.cxx @@ -0,0 +1,118 @@ +// 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. + +/// \file trackPropagationTester.cxx +/// \brief testing ground for track propagation +/// \author ALICE + +//=============================================================== +// +// Modularized version of TPC PID task +// +//=============================================================== + +#include +#include +#include +#include +#include +// ROOT includes +#include "TFile.h" +#include "TRandom.h" +#include "TSystem.h" + +// O2 includes +#include "MetadataHelper.h" +#include "TableHelper.h" +#include "pidTPCBase.h" +#include "pidTPCModule.h" + +#include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Tools/ML/model.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +using namespace o2; +using namespace o2::framework; + +o2::common::core::MetadataHelper metadataInfo; // Metadata helper + +struct pidTpcService { + + // CCDB boilerplate declarations + o2::framework::Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + + o2::aod::pid::pidTPCProducts products; + o2::aod::pid::pidTPCConfigurables pidTPCopts; + o2::aod::pid::pidTPCModule pidTPC; + + void init(o2::framework::InitContext& initContext) + { + // CCDB boilerplate init + ccdb->setURL(ccdburl.value); + ccdb->setFatalWhenNull(false); // manual fallback in case ccdb entry empty + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + ccdbApi.init(ccdburl.value); + + // task-specific + pidTPC.init(ccdb, ccdbApi, initContext, pidTPCopts, metadataInfo); + } + + void processTracks(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs) + { + pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); + } + void processTracksWithTracksQA(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::TracksQA const& tracksQA) + { + pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, tracksQA, products); + } + + void processTracksMC(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const&) + { + pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); + } + + void processTracksIU(soa::Join const& collisions, soa::Join const& tracks, aod::BCsWithTimestamps const& bcs) + { + pidTPC.process(ccdb, ccdbApi, bcs, collisions, tracks, static_cast(nullptr), products); + } + + PROCESS_SWITCH(pidTpcService, processTracks, "Process Tracks", false); + PROCESS_SWITCH(pidTpcService, processTracksMC, "Process Tracks in MC (enables tune-on-data)", false); + PROCESS_SWITCH(pidTpcService, processTracksIU, "Process TracksIU (experimental)", true); +}; + +//**************************************************************************************** +/** + * Workflow definition. + */ +//**************************************************************************************** +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + // Parse the metadata for later too + metadataInfo.initMetadata(cfgc); + + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/Common/TableProducer/caloClusterProducer.cxx b/Common/TableProducer/caloClusterProducer.cxx index b569cf7a58f..086885beb4c 100644 --- a/Common/TableProducer/caloClusterProducer.cxx +++ b/Common/TableProducer/caloClusterProducer.cxx @@ -9,6 +9,17 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file caloClusterProducer.cxx +/// \brief Produces PHOS clusters from PHOS cells +/// +/// \author Dmitri Peresunko + +#include +#include +#include +#include +#include + #include "Framework/ConfigParamSpec.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -36,9 +47,9 @@ using namespace o2::framework; using namespace o2; -using mcCells = o2::soa::Join; +using McCells = o2::soa::Join; -struct caloClusterProducerTask { +struct CaloClusterProducer { Produces clucursor; Produces cluambcursor; Produces matchedTracks; @@ -46,13 +57,13 @@ struct caloClusterProducerTask { Produces cluambmccursor; Configurable isMC{"isMC", 0, "0 - data, 1 - MC"}; - Configurable useCoreE{"coreE", 0, "0 - full energy, 1 - core energy"}; + Configurable useCoreE{"useCoreE", 0, "0 - full energy, 1 - core energy"}; Configurable skipL1phase{"skipL1phase", false, "skip or apply L1phase time correction"}; - Configurable mNonlinType{"nonlinType", 1, "0:no corr, 1: default"}; - Configurable> cpvMinE{"cpvCluMinAmp", {20., 50., 50.}, "minimal CPV cluster amplitude per module"}; - Configurable mBadMapPath{"badmapPath", "PHS/Calib/BadMap", "path to BadMap snapshot"}; - Configurable mCalibPath{"calibPath", "PHS/Calib/CalibParams", "path to Calibration snapshot"}; - Configurable mL1PhasePath{"L1phasePath", "PHS/Calib/L1phase", "path to L1phase snapshot"}; + Configurable nonlinType{"nonlinType", 1, "0:no corr, 1: data, 2: MC"}; + Configurable> cpvMinE{"cpvMinE", {20., 50., 50.}, "minimal CPV cluster amplitude per module"}; + Configurable badMapPath{"badMapPath", "PHS/Calib/BadMap", "path to BadMap snapshot"}; + Configurable calibPath{"calibPath", "PHS/Calib/CalibParams", "path to Calibration snapshot"}; + Configurable l1phasePath{"l1phasePath", "PHS/Calib/L1phase", "path to L1phase snapshot"}; Service ccdb; @@ -71,15 +82,15 @@ struct caloClusterProducerTask { static constexpr int16_t kCpvX = 7; // grid 6 steps along z and 7 along phi as largest match ellips 20x20 cm static constexpr int16_t kCpvZ = 6; static constexpr int16_t kCpvCells = 4 * kCpvX * kCpvZ; // 4 modules - static constexpr float cpvMaxX = 73; // max CPV coordinate phi - static constexpr float cpvMaxZ = 63; // max CPV coordinate z + static constexpr float kCpvMaxX = 73; // max CPV coordinate phi + static constexpr float kCpvMaxZ = 63; // max CPV coordinate z - class trackMatch + class TrackMatch { public: - trackMatch() = default; - trackMatch(float x, float z, int i) : pX(x), pZ(z), indx(i) {} - ~trackMatch() = default; + TrackMatch() = default; + TrackMatch(float x, float z, int i) : pX(x), pZ(z), indx(i) {} + ~TrackMatch() = default; public: float pX = 9999.; // X (phi) track coordinate in PHOS plane @@ -87,11 +98,11 @@ struct caloClusterProducerTask { int indx = -1; // track global index }; - class trackTrigRec + class TrackTrigRec { public: - trackTrigRec() = default; - ~trackTrigRec() = default; + TrackTrigRec() = default; + ~TrackTrigRec() = default; public: int64_t mTR; // BC ref @@ -123,7 +134,7 @@ struct caloClusterProducerTask { } std::map bcMap; int bcId = 0; - for (auto bc : bcs) { + for (const auto& bc : bcs) { bcMap[bc.globalBC()] = bcId; bcId++; } @@ -131,7 +142,7 @@ struct caloClusterProducerTask { // If several collisions appear in BC, choose one with largers number of contributors std::map colMap; int colId = 0; - for (auto cl : colls) { + for (const auto& cl : colls) { auto colbc = colMap.find(cl.bc_as().globalBC()); if (colbc == colMap.end()) { // single collision per BC colMap[cl.bc_as().globalBC()] = colId; @@ -149,11 +160,11 @@ struct caloClusterProducerTask { // Fill output table // calibration may be updated by CCDB fetcher - const o2::phos::BadChannelsMap* badMap = ccdb->getForTimeStamp(mBadMapPath, timestamp); - const o2::phos::CalibParams* calibParams = ccdb->getForTimeStamp(mCalibPath, timestamp); + const o2::phos::BadChannelsMap* badMap = ccdb->getForTimeStamp(badMapPath, timestamp); + const o2::phos::CalibParams* calibParams = ccdb->getForTimeStamp(calibPath, timestamp); if (!isMC && !skipL1phase) { - const std::vector* vec = ccdb->getForTimeStamp>(mL1PhasePath, timestamp); + const std::vector* vec = ccdb->getForTimeStamp>(l1phasePath, timestamp); if (vec) { clusterizerPHOS->setL1phase((*vec)[0]); } else { @@ -182,7 +193,7 @@ struct caloClusterProducerTask { o2::InteractionRecord ir; const int kPHOS = 0; - for (auto& c : cells) { + for (const auto& c : cells) { if (c.caloType() != kPHOS) // PHOS continue; // Fix for bug in trigger digits @@ -216,7 +227,7 @@ struct caloClusterProducerTask { // Find CPV clusters corresponding to PHOS trigger records std::vector> cpvMatchPoints[kCpvCells]; // Number of entries in each cell per TrigRecord - std::vector cpvNMatchPoints; + std::vector cpvNMatchPoints; cpvNMatchPoints.reserve(outputPHOSClusterTrigRecs.size()); int64_t curBC = -1; if (cpvs.begin() != cpvs.end()) { @@ -245,7 +256,7 @@ struct caloClusterProducerTask { if (cpvclu.amplitude() < static_cast>(cpvMinE)[static_cast(cpvclu.moduleNumber()) - 2]) { continue; } - int index = CpvMatchIndex(cpvclu.moduleNumber(), cpvclu.posX(), cpvclu.posZ()); + int index = cpvMatchIndex(cpvclu.moduleNumber(), cpvclu.posX(), cpvclu.posZ()); cpvMatchPoints[index].emplace_back(cpvclu.posX(), cpvclu.posZ()); } if (cpvNMatchPoints.size() > 0) { @@ -255,7 +266,7 @@ struct caloClusterProducerTask { } // Fill output - for (auto& cluTR : outputPHOSClusterTrigRecs) { + for (const auto& cluTR : outputPHOSClusterTrigRecs) { int firstClusterInEvent = cluTR.getFirstEntry(); int lastClusterInEvent = firstClusterInEvent + cluTR.getNumberOfObjects(); @@ -293,7 +304,7 @@ struct caloClusterProducerTask { // Correction for the depth of the shower starting point (TDR p 127) const float para = 0.925; const float parb = 6.52; - float depth = para * TMath::Log(e) + parb; + float depth = para * std::log(e) + parb; posX -= posX * depth / 460.; posZ -= (posZ - vtx.Z()) * depth / 460.; @@ -306,51 +317,51 @@ struct caloClusterProducerTask { continue; } - e = Nonlinearity(e); + e = nonlinearity(e); mom.SetMag(e); float cpvdist = 99.; - const float cellSizeX = 2 * cpvMaxX / kCpvX; - const float cellSizeZ = 2 * cpvMaxZ / kCpvZ; + const float cellSizeX = 2 * kCpvMaxX / kCpvX; + const float cellSizeZ = 2 * kCpvMaxZ / kCpvZ; // look 9 CPV regions around PHOS cluster if (mod >= 2 && cpvExist) { // CPV exist in mods 2,3,4 - int phosIndex = CpvMatchIndex(mod, posX, posZ); + int phosIndex = cpvMatchIndex(mod, posX, posZ); std::vector regions; regions.push_back(phosIndex); - if (posX > -cpvMaxX + cellSizeX) { - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom left + if (posX > -kCpvMaxX + cellSizeX) { + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom left regions.push_back(phosIndex - kCpvZ - 1); } regions.push_back(phosIndex - kCpvZ); - if (posZ < cpvMaxZ - cellSizeZ) { // top left + if (posZ < kCpvMaxZ - cellSizeZ) { // top left regions.push_back(phosIndex - kCpvZ + 1); } } - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom regions.push_back(phosIndex - 1); } - if (posZ < cpvMaxZ - cellSizeZ) { // top + if (posZ < kCpvMaxZ - cellSizeZ) { // top regions.push_back(phosIndex + 1); } - if (posX < cpvMaxX - cellSizeX) { - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom right + if (posX < kCpvMaxX - cellSizeX) { + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom right regions.push_back(phosIndex + kCpvZ - 1); } regions.push_back(phosIndex + kCpvZ); - if (posZ < cpvMaxZ - cellSizeZ) { // top right + if (posZ < kCpvMaxZ - cellSizeZ) { // top right regions.push_back(phosIndex + kCpvZ + 1); } } - float sigmaX = 1. / TMath::Min(5.2, 1.111 + 0.56 * TMath::Exp(-0.031 * e * e) + 4.8 / TMath::Power(e + 0.61, 3)); // inverse sigma X - float sigmaZ = 1. / TMath::Min(3.3, 1.12 + 0.35 * TMath::Exp(-0.032 * e * e) + 0.75 / TMath::Power(e + 0.24, 3)); // inverse sigma Z + float sigmaX = 1. / std::min(5.2, 1.111 + 0.56 * std::exp(-0.031 * e * e) + 4.8 / std::pow(e + 0.61, 3)); // inverse sigma X + float sigmaZ = 1. / std::min(3.3, 1.12 + 0.35 * std::exp(-0.032 * e * e) + 0.75 / std::pow(e + 0.24, 3)); // inverse sigma Z - for (int indx : regions) { + for (const int& indx : regions) { if (indx >= 0 && indx < kCpvCells) { for (int ii = cpvPoints->mStart[indx]; ii < cpvPoints->mEnd[indx]; ii++) { auto p = cpvMatchPoints[indx][ii]; - float d = pow((p.first - posX) * sigmaX, 2) + pow((p.second - posZ) * sigmaZ, 2); + float d = std::pow((p.first - posX) * sigmaX, 2) + std::pow((p.second - posZ) * sigmaZ, 2); if (d < cpvdist) { cpvdist = d; } @@ -358,8 +369,8 @@ struct caloClusterProducerTask { } } } - if (cpvdist != 99.) { // was evaluated - cpvdist = sqrt(cpvdist); // was squared + if (cpvdist != 99.) { // was evaluated + cpvdist = std::sqrt(cpvdist); // was squared } int cpvindex = -2; // -2 no CPV in event if (cpvExist) { @@ -400,11 +411,11 @@ struct caloClusterProducerTask { } } - PROCESS_SWITCH(caloClusterProducerTask, processStandalone, "Process PHOS and CPV only", true); + PROCESS_SWITCH(CaloClusterProducer, processStandalone, "Process PHOS and CPV only", true); void processStandaloneMC(o2::aod::BCsWithTimestamps const& bcs, o2::aod::Collisions const& colls, - mcCells& cells, + McCells const& cells, o2::aod::CaloTriggers const&, o2::aod::CPVClusters const& cpvs) { @@ -417,7 +428,7 @@ struct caloClusterProducerTask { } std::map bcMap; int bcId = 0; - for (auto bc : bcs) { + for (auto const& bc : bcs) { bcMap[bc.globalBC()] = bcId; bcId++; } @@ -425,7 +436,7 @@ struct caloClusterProducerTask { // If several collisions appear in BC, choose one with largers number of contributors std::map colMap; int colId = 0; - for (auto cl : colls) { + for (auto const& cl : colls) { auto colbc = colMap.find(cl.bc_as().globalBC()); if (colbc == colMap.end()) { // single collision per BC colMap[cl.bc_as().globalBC()] = colId; @@ -443,11 +454,11 @@ struct caloClusterProducerTask { // Fill output table // calibration may be updated by CCDB fetcher - const o2::phos::BadChannelsMap* badMap = ccdb->getForTimeStamp(mBadMapPath, timestamp); - const o2::phos::CalibParams* calibParams = ccdb->getForTimeStamp(mCalibPath, timestamp); + const o2::phos::BadChannelsMap* badMap = ccdb->getForTimeStamp(badMapPath, timestamp); + const o2::phos::CalibParams* calibParams = ccdb->getForTimeStamp(calibPath, timestamp); if (!isMC && !skipL1phase) { - const std::vector* vec = ccdb->getForTimeStamp>(mL1PhasePath, timestamp); + const std::vector* vec = ccdb->getForTimeStamp>(l1phasePath, timestamp); if (vec) { clusterizerPHOS->setL1phase((*vec)[0]); } else { @@ -477,7 +488,7 @@ struct caloClusterProducerTask { o2::InteractionRecord ir; const int kPHOS = 0; o2::dataformats::MCTruthContainer cellTruth; - for (auto& c : cells) { + for (const auto& c : cells) { if (c.caloType() != kPHOS) // PHOS continue; // Fix for bug in trigger digits @@ -532,7 +543,7 @@ struct caloClusterProducerTask { // Find CPV clusters corresponding to PHOS trigger records std::vector> cpvMatchPoints[kCpvCells]; // Number of entries in each cell per TrigRecord - std::vector cpvNMatchPoints; + std::vector cpvNMatchPoints; cpvNMatchPoints.reserve(outputPHOSClusterTrigRecs.size()); int64_t curBC = -1; if (cpvs.begin() != cpvs.end()) { @@ -561,7 +572,7 @@ struct caloClusterProducerTask { if (cpvclu.amplitude() < static_cast>(cpvMinE)[static_cast(cpvclu.moduleNumber()) - 2]) { continue; } - int index = CpvMatchIndex(cpvclu.moduleNumber(), cpvclu.posX(), cpvclu.posZ()); + int index = cpvMatchIndex(cpvclu.moduleNumber(), cpvclu.posX(), cpvclu.posZ()); cpvMatchPoints[index].emplace_back(cpvclu.posX(), cpvclu.posZ()); } if (cpvNMatchPoints.size() > 0) { @@ -571,7 +582,7 @@ struct caloClusterProducerTask { } // Fill output - for (auto& cluTR : outputPHOSClusterTrigRecs) { + for (const auto& cluTR : outputPHOSClusterTrigRecs) { int firstClusterInEvent = cluTR.getFirstEntry(); int lastClusterInEvent = firstClusterInEvent + cluTR.getNumberOfObjects(); @@ -609,7 +620,7 @@ struct caloClusterProducerTask { // Correction for the depth of the shower starting point (TDR p 127) const float para = 0.925; const float parb = 6.52; - float depth = para * TMath::Log(e) + parb; + float depth = para * std::log(e) + parb; posX -= posX * depth / 460.; posZ -= (posZ - vtx.Z()) * depth / 460.; @@ -622,51 +633,51 @@ struct caloClusterProducerTask { continue; } - e = Nonlinearity(e); + e = nonlinearity(e); mom.SetMag(e); float cpvdist = 99.; - const float cellSizeX = 2 * cpvMaxX / kCpvX; - const float cellSizeZ = 2 * cpvMaxZ / kCpvZ; + const float cellSizeX = 2 * kCpvMaxX / kCpvX; + const float cellSizeZ = 2 * kCpvMaxZ / kCpvZ; // look 9 CPV regions around PHOS cluster if (mod >= 2 && cpvExist) { // CPV exist in mods 2,3,4 - int phosIndex = CpvMatchIndex(mod, posX, posZ); + int phosIndex = cpvMatchIndex(mod, posX, posZ); std::vector regions; regions.push_back(phosIndex); - if (posX > -cpvMaxX + cellSizeX) { - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom left + if (posX > -kCpvMaxX + cellSizeX) { + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom left regions.push_back(phosIndex - kCpvZ - 1); } regions.push_back(phosIndex - kCpvZ); - if (posZ < cpvMaxZ - cellSizeZ) { // top left + if (posZ < kCpvMaxZ - cellSizeZ) { // top left regions.push_back(phosIndex - kCpvZ + 1); } } - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom regions.push_back(phosIndex - 1); } - if (posZ < cpvMaxZ - cellSizeZ) { // top + if (posZ < kCpvMaxZ - cellSizeZ) { // top regions.push_back(phosIndex + 1); } - if (posX < cpvMaxX - cellSizeX) { - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom right + if (posX < kCpvMaxX - cellSizeX) { + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom right regions.push_back(phosIndex + kCpvZ - 1); } regions.push_back(phosIndex + kCpvZ); - if (posZ < cpvMaxZ - cellSizeZ) { // top right + if (posZ < kCpvMaxZ - cellSizeZ) { // top right regions.push_back(phosIndex + kCpvZ + 1); } } - float sigmaX = 1. / TMath::Min(5.2, 1.111 + 0.56 * TMath::Exp(-0.031 * e * e) + 4.8 / TMath::Power(e + 0.61, 3)); // inverse sigma X - float sigmaZ = 1. / TMath::Min(3.3, 1.12 + 0.35 * TMath::Exp(-0.032 * e * e) + 0.75 / TMath::Power(e + 0.24, 3)); // inverse sigma Z + float sigmaX = 1. / std::min(5.2, 1.111 + 0.56 * std::exp(-0.031 * e * e) + 4.8 / std::pow(e + 0.61, 3)); // inverse sigma X + float sigmaZ = 1. / std::min(3.3, 1.12 + 0.35 * std::exp(-0.032 * e * e) + 0.75 / std::pow(e + 0.24, 3)); // inverse sigma Z - for (int indx : regions) { + for (const int& indx : regions) { if (indx >= 0 && indx < kCpvCells) { for (int ii = cpvPoints->mStart[indx]; ii < cpvPoints->mEnd[indx]; ii++) { auto p = cpvMatchPoints[indx][ii]; - float d = pow((p.first - posX) * sigmaX, 2) + pow((p.second - posZ) * sigmaZ, 2); + float d = std::pow((p.first - posX) * sigmaX, 2) + std::pow((p.second - posZ) * sigmaZ, 2); if (d < cpvdist) { cpvdist = d; } @@ -674,8 +685,8 @@ struct caloClusterProducerTask { } } } - if (cpvdist != 99.) { // was evaluated - cpvdist = sqrt(cpvdist); // was squared + if (cpvdist != 99.) { // was evaluated + cpvdist = std::sqrt(cpvdist); // was squared } int cpvindex = -2; // -2 no CPV in event if (cpvExist) { @@ -689,7 +700,7 @@ struct caloClusterProducerTask { mclabels.clear(); mcamplitudes.clear(); gsl::span spDigList = outputTruthCont.getLabels(i); - for (auto cellLab : spDigList) { + for (const auto& cellLab : spDigList) { mclabels.push_back(cellLab.getTrackID()); // Track ID in current event? mcamplitudes.push_back(cellLab.getEdep()); } @@ -730,7 +741,7 @@ struct caloClusterProducerTask { } } - PROCESS_SWITCH(caloClusterProducerTask, processStandaloneMC, "Process MC, PHOS and CPV only", true); + PROCESS_SWITCH(CaloClusterProducer, processStandaloneMC, "Process MC, PHOS and CPV only", false); //------------------------------------------------------------ void processFull(o2::aod::BCsWithTimestamps const& bcs, @@ -760,7 +771,7 @@ struct caloClusterProducerTask { std::map bcMap; int bcId = 0; - for (auto bc : bcs) { + for (const auto& bc : bcs) { bcMap[bc.globalBC()] = bcId; bcId++; } @@ -768,7 +779,7 @@ struct caloClusterProducerTask { // If several collisions appear in BC, choose one with largers number of contributors std::map colMap; int colId = 0; - for (auto cl : colls) { + for (const auto& cl : colls) { auto colbc = colMap.find(cl.bc_as().globalBC()); if (colbc == colMap.end()) { // single collision per BC colMap[cl.bc_as().globalBC()] = colId; @@ -785,11 +796,11 @@ struct caloClusterProducerTask { // Fill output table // calibration may be updated by CCDB fetcher - const o2::phos::BadChannelsMap* badMap = ccdb->getForTimeStamp(mBadMapPath, timestamp); - const o2::phos::CalibParams* calibParams = ccdb->getForTimeStamp(mCalibPath, timestamp); + const o2::phos::BadChannelsMap* badMap = ccdb->getForTimeStamp(badMapPath, timestamp); + const o2::phos::CalibParams* calibParams = ccdb->getForTimeStamp(calibPath, timestamp); if (!isMC && !skipL1phase) { - const std::vector* vec = ccdb->getForTimeStamp>(mL1PhasePath, timestamp); + const std::vector* vec = ccdb->getForTimeStamp>(l1phasePath, timestamp); if (vec) { clusterizerPHOS->setL1phase((*vec)[0]); } else { @@ -818,7 +829,7 @@ struct caloClusterProducerTask { o2::InteractionRecord ir; const int kPHOS = 0; - for (auto& c : cells) { + for (const auto& c : cells) { if (c.caloType() != kPHOS) // PHOS continue; // Fix for bug in trigger digits @@ -852,7 +863,7 @@ struct caloClusterProducerTask { // Find CPV clusters corresponding to PHOS trigger records std::vector> cpvMatchPoints[kCpvCells]; // Number of entries in each cell per TrigRecord - std::vector cpvNMatchPoints; + std::vector cpvNMatchPoints; cpvNMatchPoints.reserve(outputPHOSClusterTrigRecs.size()); int64_t curBC = -1; @@ -881,7 +892,7 @@ struct caloClusterProducerTask { if (cpvclu.amplitude() < static_cast>(cpvMinE)[static_cast(cpvclu.moduleNumber()) - 2]) { continue; } - int index = CpvMatchIndex(cpvclu.moduleNumber(), cpvclu.posX(), cpvclu.posZ()); + int index = cpvMatchIndex(cpvclu.moduleNumber(), cpvclu.posX(), cpvclu.posZ()); cpvMatchPoints[index].emplace_back(cpvclu.posX(), cpvclu.posZ()); } if (cpvNMatchPoints.size()) { @@ -890,9 +901,9 @@ struct caloClusterProducerTask { } } // same for tracks - std::vector trackMatchPoints[kCpvCells]; // tracks hit in grid/cell in PHOS + std::vector trackMatchPoints[kCpvCells]; // tracks hit in grid/cell in PHOS // Number of entries in each cell per TrigRecord - std::vector trackNMatchPoints; + std::vector trackNMatchPoints; trackNMatchPoints.reserve(outputPHOSClusterTrigRecs.size()); curBC = 0; @@ -903,7 +914,7 @@ struct caloClusterProducerTask { } } bool keepBC = false; - for (auto& cluTR : outputPHOSClusterTrigRecs) { + for (const auto& cluTR : outputPHOSClusterTrigRecs) { if (cluTR.getBCData().toLong() == curBC) { keepBC = true; break; @@ -930,7 +941,7 @@ struct caloClusterProducerTask { curBC = track.collision().bc_as().globalBC(); } keepBC = false; - for (auto& cluTR : outputPHOSClusterTrigRecs) { + for (const auto& cluTR : outputPHOSClusterTrigRecs) { if (cluTR.getBCData().toLong() == curBC) { keepBC = true; break; @@ -954,7 +965,7 @@ struct caloClusterProducerTask { float trackX, trackZ; auto trackPar = getTrackPar(track); if (impactOnPHOS(trackPar, track.trackEtaEmcal(), track.trackPhiEmcal(), track.collision().posZ(), module, trackX, trackZ)) { - int index = CpvMatchIndex(module, trackX, trackZ); + int index = cpvMatchIndex(module, trackX, trackZ); trackMatchPoints[index].emplace_back(trackX, trackZ, track.globalIndex()); } } @@ -965,7 +976,7 @@ struct caloClusterProducerTask { } // Fill output tables - for (auto& cluTR : outputPHOSClusterTrigRecs) { + for (const auto& cluTR : outputPHOSClusterTrigRecs) { int firstClusterInEvent = cluTR.getFirstEntry(); int lastClusterInEvent = firstClusterInEvent + cluTR.getNumberOfObjects(); @@ -1012,7 +1023,7 @@ struct caloClusterProducerTask { // Correction for the depth of the shower starting point (TDR p 127) const float para = 0.925; const float parb = 6.52; - float depth = para * TMath::Log(e) + parb; + float depth = para * std::log(e) + parb; posX -= posX * depth / 460.; posZ -= (posZ - vtx.Z()) * depth / 460.; @@ -1025,53 +1036,53 @@ struct caloClusterProducerTask { continue; } - e = Nonlinearity(e); + e = nonlinearity(e); mom.SetMag(e); // CPV and track match - const float cellSizeX = 2 * cpvMaxX / kCpvX; - const float cellSizeZ = 2 * cpvMaxZ / kCpvZ; + const float cellSizeX = 2 * kCpvMaxX / kCpvX; + const float cellSizeZ = 2 * kCpvMaxZ / kCpvZ; // look 9 CPV regions around PHOS cluster - int phosIndex = CpvMatchIndex(mod, posX, posZ); + int phosIndex = cpvMatchIndex(mod, posX, posZ); std::vector regions; regions.push_back(phosIndex); - if (posX > -cpvMaxX + cellSizeX) { - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom left + if (posX > -kCpvMaxX + cellSizeX) { + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom left regions.push_back(phosIndex - kCpvZ - 1); } regions.push_back(phosIndex - kCpvZ); - if (posZ < cpvMaxZ - cellSizeZ) { // top left + if (posZ < kCpvMaxZ - cellSizeZ) { // top left regions.push_back(phosIndex - kCpvZ + 1); } } - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom regions.push_back(phosIndex - 1); } - if (posZ < cpvMaxZ - cellSizeZ) { // top + if (posZ < kCpvMaxZ - cellSizeZ) { // top regions.push_back(phosIndex + 1); } - if (posX < cpvMaxX - cellSizeX) { - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom right + if (posX < kCpvMaxX - cellSizeX) { + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom right regions.push_back(phosIndex + kCpvZ - 1); } regions.push_back(phosIndex + kCpvZ); - if (posZ < cpvMaxZ - cellSizeZ) { // top right + if (posZ < kCpvMaxZ - cellSizeZ) { // top right regions.push_back(phosIndex + kCpvZ + 1); } } - float sigmaX = 1. / TMath::Min(5.2, 1.111 + 0.56 * TMath::Exp(-0.031 * e * e) + 4.8 / TMath::Power(e + 0.61, 3)); // inverse sigma X - float sigmaZ = 1. / TMath::Min(3.3, 1.12 + 0.35 * TMath::Exp(-0.032 * e * e) + 0.75 / TMath::Power(e + 0.24, 3)); // inverse sigma Z + float sigmaX = 1. / std::min(5.2, 1.111 + 0.56 * std::exp(-0.031 * e * e) + 4.8 / std::pow(e + 0.61, 3)); // inverse sigma X + float sigmaZ = 1. / std::min(3.3, 1.12 + 0.35 * std::exp(-0.032 * e * e) + 0.75 / std::pow(e + 0.24, 3)); // inverse sigma Z float cpvdist = 99., trackdist = 99.; // float cpvDx = 0., cpvDz = 0.; float trackDx = 9999., trackDz = 9999.; int trackindex = -1; - for (int indx : regions) { + for (const int& indx : regions) { if (cpvPoints != cpvNMatchPoints.end()) { if (indx >= 0 && indx < kCpvCells) { for (int ii = cpvPoints->mStart[indx]; ii < cpvPoints->mEnd[indx]; ii++) { auto p = cpvMatchPoints[indx][ii]; - float d = pow((p.first - posX) * sigmaX, 2) + pow((p.second - posZ) * sigmaZ, 2); + float d = std::pow((p.first - posX) * sigmaX, 2) + std::pow((p.second - posZ) * sigmaZ, 2); if (d < cpvdist) { cpvdist = d; } @@ -1083,7 +1094,7 @@ struct caloClusterProducerTask { if (trackPoints != trackNMatchPoints.end()) { for (int ii = trackPoints->mStart[indx]; ii < trackPoints->mEnd[indx]; ii++) { auto pp = trackMatchPoints[indx][ii]; - float d = pow((pp.pX - posX) * sigmaX, 2) + pow((pp.pZ - posZ) * sigmaZ, 2); // TODO different sigma for tracks + float d = std::pow((pp.pX - posX) * sigmaX, 2) + std::pow((pp.pZ - posZ) * sigmaZ, 2); // TODO different sigma for tracks if (d < trackdist) { trackdist = d; trackDx = pp.pX - posX; @@ -1094,11 +1105,11 @@ struct caloClusterProducerTask { } } - if (cpvdist != 99.) { // was evaluated - cpvdist = sqrt(cpvdist); // was squared + if (cpvdist != 99.) { // was evaluated + cpvdist = std::sqrt(cpvdist); // was squared } - if (trackdist != 99.) { // was evaluated - trackdist = sqrt(trackdist); // was squared + if (trackdist != 99.) { // was evaluated + trackdist = std::sqrt(trackdist); // was squared } float lambdaShort = 0., lambdaLong = 0.; @@ -1140,12 +1151,12 @@ struct caloClusterProducerTask { } } - PROCESS_SWITCH(caloClusterProducerTask, processFull, "Process with track matching", false); + PROCESS_SWITCH(CaloClusterProducer, processFull, "Process with track matching", false); //------------------------------------------------------------ void processFullMC(o2::aod::BCsWithTimestamps const& bcs, o2::aod::Collisions const& colls, - mcCells& cells, + McCells const& cells, o2::aod::CaloTriggers const&, o2::aod::CPVClusters const& cpvs, o2::aod::FullTracks const& tracks) @@ -1169,7 +1180,7 @@ struct caloClusterProducerTask { std::map bcMap; int bcId = 0; - for (auto bc : bcs) { + for (const auto& bc : bcs) { bcMap[bc.globalBC()] = bcId; bcId++; } @@ -1177,7 +1188,7 @@ struct caloClusterProducerTask { // If several collisions appear in BC, choose one with largers number of contributors std::map colMap; int colId = 0; - for (auto cl : colls) { + for (const auto& cl : colls) { auto colbc = colMap.find(cl.bc_as().globalBC()); if (colbc == colMap.end()) { // single collision per BC colMap[cl.bc_as().globalBC()] = colId; @@ -1194,11 +1205,11 @@ struct caloClusterProducerTask { // Fill output table // calibration may be updated by CCDB fetcher - const o2::phos::BadChannelsMap* badMap = ccdb->getForTimeStamp(mBadMapPath, timestamp); - const o2::phos::CalibParams* calibParams = ccdb->getForTimeStamp(mCalibPath, timestamp); + const o2::phos::BadChannelsMap* badMap = ccdb->getForTimeStamp(badMapPath, timestamp); + const o2::phos::CalibParams* calibParams = ccdb->getForTimeStamp(calibPath, timestamp); if (!isMC && !skipL1phase) { - const std::vector* vec = ccdb->getForTimeStamp>(mL1PhasePath, timestamp); + const std::vector* vec = ccdb->getForTimeStamp>(l1phasePath, timestamp); if (vec) { clusterizerPHOS->setL1phase((*vec)[0]); } else { @@ -1228,7 +1239,7 @@ struct caloClusterProducerTask { o2::InteractionRecord ir; const int kPHOS = 0; - for (auto& c : cells) { + for (const auto& c : cells) { if (c.caloType() != kPHOS) // PHOS continue; // Fix for bug in trigger digits @@ -1283,7 +1294,7 @@ struct caloClusterProducerTask { // Find CPV clusters corresponding to PHOS trigger records std::vector> cpvMatchPoints[kCpvCells]; // Number of entries in each cell per TrigRecord - std::vector cpvNMatchPoints; + std::vector cpvNMatchPoints; cpvNMatchPoints.reserve(outputPHOSClusterTrigRecs.size()); int64_t curBC = -1; @@ -1312,7 +1323,7 @@ struct caloClusterProducerTask { if (cpvclu.amplitude() < static_cast>(cpvMinE)[static_cast(cpvclu.moduleNumber()) - 2]) { continue; } - int index = CpvMatchIndex(cpvclu.moduleNumber(), cpvclu.posX(), cpvclu.posZ()); + int index = cpvMatchIndex(cpvclu.moduleNumber(), cpvclu.posX(), cpvclu.posZ()); cpvMatchPoints[index].emplace_back(cpvclu.posX(), cpvclu.posZ()); } if (cpvNMatchPoints.size()) { @@ -1321,9 +1332,9 @@ struct caloClusterProducerTask { } } // same for tracks - std::vector trackMatchPoints[kCpvCells]; // tracks hit in grid/cell in PHOS + std::vector trackMatchPoints[kCpvCells]; // tracks hit in grid/cell in PHOS // Number of entries in each cell per TrigRecord - std::vector trackNMatchPoints; + std::vector trackNMatchPoints; trackNMatchPoints.reserve(outputPHOSClusterTrigRecs.size()); curBC = -1; @@ -1334,7 +1345,7 @@ struct caloClusterProducerTask { } } bool keepBC = false; - for (auto& cluTR : outputPHOSClusterTrigRecs) { + for (const auto& cluTR : outputPHOSClusterTrigRecs) { if (cluTR.getBCData().toLong() == curBC) { keepBC = true; break; @@ -1361,7 +1372,7 @@ struct caloClusterProducerTask { curBC = track.collision().bc_as().globalBC(); } keepBC = false; - for (auto& cluTR : outputPHOSClusterTrigRecs) { + for (const auto& cluTR : outputPHOSClusterTrigRecs) { if (cluTR.getBCData().toLong() == curBC) { keepBC = true; break; @@ -1385,7 +1396,7 @@ struct caloClusterProducerTask { float trackX, trackZ; auto trackPar = getTrackPar(track); if (impactOnPHOS(trackPar, track.trackEtaEmcal(), track.trackPhiEmcal(), track.collision().posZ(), module, trackX, trackZ)) { - int index = CpvMatchIndex(module, trackX, trackZ); + int index = cpvMatchIndex(module, trackX, trackZ); trackMatchPoints[index].emplace_back(trackX, trackZ, track.globalIndex()); } } @@ -1396,7 +1407,7 @@ struct caloClusterProducerTask { } // Fill output tables - for (auto& cluTR : outputPHOSClusterTrigRecs) { + for (const auto& cluTR : outputPHOSClusterTrigRecs) { int firstClusterInEvent = cluTR.getFirstEntry(); int lastClusterInEvent = firstClusterInEvent + cluTR.getNumberOfObjects(); @@ -1442,7 +1453,7 @@ struct caloClusterProducerTask { // Correction for the depth of the shower starting point (TDR p 127) const float para = 0.925; const float parb = 6.52; - float depth = para * TMath::Log(e) + parb; + float depth = para * std::log(e) + parb; posX -= posX * depth / 460.; posZ -= (posZ - vtx.Z()) * depth / 460.; @@ -1455,52 +1466,52 @@ struct caloClusterProducerTask { continue; } - e = Nonlinearity(e); + e = nonlinearity(e); mom.SetMag(e); // CPV and track match - const float cellSizeX = 2 * cpvMaxX / kCpvX; - const float cellSizeZ = 2 * cpvMaxZ / kCpvZ; + const float cellSizeX = 2 * kCpvMaxX / kCpvX; + const float cellSizeZ = 2 * kCpvMaxZ / kCpvZ; // look 9 CPV regions around PHOS cluster - int phosIndex = CpvMatchIndex(mod, posX, posZ); + int phosIndex = cpvMatchIndex(mod, posX, posZ); std::vector regions; regions.push_back(phosIndex); - if (posX > -cpvMaxX + cellSizeX) { - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom left + if (posX > -kCpvMaxX + cellSizeX) { + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom left regions.push_back(phosIndex - kCpvZ - 1); } regions.push_back(phosIndex - kCpvZ); - if (posZ < cpvMaxZ - cellSizeZ) { // top left + if (posZ < kCpvMaxZ - cellSizeZ) { // top left regions.push_back(phosIndex - kCpvZ + 1); } } - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom regions.push_back(phosIndex - 1); } - if (posZ < cpvMaxZ - cellSizeZ) { // top + if (posZ < kCpvMaxZ - cellSizeZ) { // top regions.push_back(phosIndex + 1); } - if (posX < cpvMaxX - cellSizeX) { - if (posZ > -cpvMaxZ + cellSizeZ) { // bottom right + if (posX < kCpvMaxX - cellSizeX) { + if (posZ > -kCpvMaxZ + cellSizeZ) { // bottom right regions.push_back(phosIndex + kCpvZ - 1); } regions.push_back(phosIndex + kCpvZ); - if (posZ < cpvMaxZ - cellSizeZ) { // top right + if (posZ < kCpvMaxZ - cellSizeZ) { // top right regions.push_back(phosIndex + kCpvZ + 1); } } - float sigmaX = 1. / TMath::Min(5.2, 1.111 + 0.56 * TMath::Exp(-0.031 * e * e) + 4.8 / TMath::Power(e + 0.61, 3)); // inverse sigma X - float sigmaZ = 1. / TMath::Min(3.3, 1.12 + 0.35 * TMath::Exp(-0.032 * e * e) + 0.75 / TMath::Power(e + 0.24, 3)); // inverse sigma Z + float sigmaX = 1. / std::min(5.2, 1.111 + 0.56 * std::exp(-0.031 * e * e) + 4.8 / std::pow(e + 0.61, 3)); // inverse sigma X + float sigmaZ = 1. / std::min(3.3, 1.12 + 0.35 * std::exp(-0.032 * e * e) + 0.75 / std::pow(e + 0.24, 3)); // inverse sigma Z float cpvdist = 99., trackdist = 99.; // float cpvDx = 0., cpvDz = 0.; float trackDx = 9999., trackDz = 9999.; int trackindex = -1; - for (int indx : regions) { + for (const int& indx : regions) { if (cpvPoints != cpvNMatchPoints.end()) { if (indx >= 0 && indx < kCpvCells) { for (int ii = cpvPoints->mStart[indx]; ii < cpvPoints->mEnd[indx]; ii++) { auto p = cpvMatchPoints[indx][ii]; - float d = pow((p.first - posX) * sigmaX, 2) + pow((p.second - posZ) * sigmaZ, 2); + float d = std::pow((p.first - posX) * sigmaX, 2) + std::pow((p.second - posZ) * sigmaZ, 2); if (d < cpvdist) { cpvdist = d; } @@ -1511,7 +1522,7 @@ struct caloClusterProducerTask { if (trackPoints != trackNMatchPoints.end()) { for (int ii = trackPoints->mStart[indx]; ii < trackPoints->mEnd[indx]; ii++) { auto pp = trackMatchPoints[indx][ii]; - float d = pow((pp.pX - posX) * sigmaX, 2) + pow((pp.pZ - posZ) * sigmaZ, 2); // TODO different sigma for tracks + float d = std::pow((pp.pX - posX) * sigmaX, 2) + std::pow((pp.pZ - posZ) * sigmaZ, 2); // TODO different sigma for tracks if (d < trackdist) { trackdist = d; trackDx = pp.pX - posX; @@ -1522,11 +1533,11 @@ struct caloClusterProducerTask { } } - if (cpvdist != 99.) { // was evaluated - cpvdist = sqrt(cpvdist); // was squared + if (cpvdist != 99.) { // was evaluated + cpvdist = std::sqrt(cpvdist); // was squared } - if (trackdist != 99.) { // was evaluated - trackdist = sqrt(trackdist); // was squared + if (trackdist != 99.) { // was evaluated + trackdist = std::sqrt(trackdist); // was squared } float lambdaShort = 0., lambdaLong = 0.; @@ -1540,7 +1551,7 @@ struct caloClusterProducerTask { mclabels.clear(); mcamplitudes.clear(); gsl::span spDigList = outputTruthCont.getLabels(i); - for (auto cellLab : spDigList) { + for (const auto& cellLab : spDigList) { mclabels.push_back(cellLab.getTrackID()); // Track ID in current event? mcamplitudes.push_back(cellLab.getEdep()); } @@ -1581,17 +1592,17 @@ struct caloClusterProducerTask { } } - PROCESS_SWITCH(caloClusterProducerTask, processFullMC, "Process MC with track matching", false); + PROCESS_SWITCH(CaloClusterProducer, processFullMC, "Process MC with track matching", false); - int CpvMatchIndex(int16_t module, float x, float z) + int cpvMatchIndex(int16_t module, float x, float z) { // calculate cell index in grid over PHOS detector - const float cellSizeX = 2 * cpvMaxX / kCpvX; - const float cellSizeZ = 2 * cpvMaxZ / kCpvZ; + const float cellSizeX = 2 * kCpvMaxX / kCpvX; + const float cellSizeZ = 2 * kCpvMaxZ / kCpvZ; // in track matching tracks can be beyond CPV surface // assign these tracks to the closest cell - int ix = std::max(0, static_cast((x + cpvMaxX) / cellSizeX)); - int iz = std::max(0, static_cast((z + cpvMaxZ) / cellSizeZ)); + int ix = std::max(0, static_cast((x + kCpvMaxX) / cellSizeX)); + int iz = std::max(0, static_cast((z + kCpvMaxZ) / cellSizeZ)); if (ix >= kCpvX) { ix = kCpvX - 1; } @@ -1612,17 +1623,12 @@ struct caloClusterProducerTask { const float etaMax = 0.178266; double bz = o2::base::Propagator::Instance()->getNominalBz(); // magnetic field - if (trackPhi < phiMin || trackPhi > phiMax || abs(trackEta) > etaMax) { // do not match even approximately + trackPhi = RecoDecay::constrainAngle(trackPhi, 0., 1); // constrain angle to range 0,twoPi + if (trackPhi < phiMin || trackPhi > phiMax || std::abs(trackEta) > etaMax) { // do not match even approximately return false; } const float dphi = 20. * 0.017453293; - if (trackPhi < 0.) { - trackPhi += TMath::TwoPi(); - } - if (trackPhi > TMath::TwoPi()) { - trackPhi -= TMath::TwoPi(); - } module = 1 + static_cast((trackPhi - phiMin) / dphi); if (module < 1) { module = 1; @@ -1632,11 +1638,11 @@ struct caloClusterProducerTask { } // get PHOS radius - constexpr float shiftY = -1.26; // Depth-optimized + const double shiftY = -1.26; // Depth-optimized double posL[3] = {0., 0., shiftY}; // local position at the center of module double posG[3] = {0}; geomPHOS->getAlignmentMatrix(module)->LocalToMaster(posL, posG); - double rPHOS = sqrt(posG[0] * posG[0] + posG[1] * posG[1]); + double rPHOS = std::sqrt(posG[0] * posG[0] + posG[1] * posG[1]); double alpha = (230. + 20. * module) * 0.017453293; // During main reconstruction track was propagated to radius 460 cm with accounting material @@ -1661,7 +1667,7 @@ struct caloClusterProducerTask { return false; } alpha = trackPar.getAlpha(); - double ca = cos(alpha), sa = sin(alpha); + double ca = std::cos(alpha), sa = std::sin(alpha); posG[0] = trackPar.getX() * ca - trackPar.getY() * sa; posG[1] = trackPar.getY() * ca + trackPar.getX() * sa; posG[2] = trackPar.getZ(); @@ -1670,7 +1676,7 @@ struct caloClusterProducerTask { trackX = posL[0]; trackZ = posL[1]; // If trackX beyond the module, switch to the next one - if (abs(trackX) < xmax || (trackX < -xmax && module == 1) || (trackX > xmax && module == 4)) { + if (std::abs(trackX) < xmax || (trackX < -xmax && module == 1) || (trackX > xmax && module == 4)) { return true; } // re-do extrapolation to correct module @@ -1687,7 +1693,7 @@ struct caloClusterProducerTask { posL[1] = 0.; posL[2] = shiftY; // local position at the center of module geomPHOS->getAlignmentMatrix(module)->LocalToMaster(posL, posG); - rPHOS = sqrt(posG[0] * posG[0] + posG[1] * posG[1]); + rPHOS = std::sqrt(posG[0] * posG[0] + posG[1] * posG[1]); if (!trackPar.rotate(alpha) || !prop->PropagateToXBxByBz(trackPar, xtrg, 0.95, 10, o2::base::Propagator::MatCorrType::USEMatCorrNONE)) { @@ -1703,8 +1709,8 @@ struct caloClusterProducerTask { return false; } alpha = trackPar.getAlpha(); - ca = cos(alpha); - sa = sin(alpha); + ca = std::cos(alpha); + sa = std::sin(alpha); posG[0] = trackPar.getX() * ca - trackPar.getY() * sa; posG[1] = trackPar.getY() * ca + trackPar.getX() * sa; posG[2] = trackPar.getZ(); @@ -1715,13 +1721,38 @@ struct caloClusterProducerTask { return true; } - float Nonlinearity(float en) + float nonlinearity(float en) { // Correct for non-linearity - switch (mNonlinType) { + switch (nonlinType) { case 0: return en; - case 1: { + case 1: { // Data Run3 + const double a = 0.885621; + const double b = 0.003864; + const double c = 0.143948; + const double d = -0.034200; + const double f = -0.038992; + const double g = 0.436003; + const double h = 0.642263; + const double k = 0.000523; + double eMin = std::max(static_cast(0.25), en); // Parameterization valid down to 250 MeV + return en * (a + b * eMin + c / eMin + d / (eMin * eMin) + f / ((eMin - g) * (eMin - g) + h * h) + k / std::pow(eMin, 4)); + } + case 2: { // MC + const double a = 1.2428430; + const double b = -0.0001866; + const double c = -0.0299751; + const double d = -0.0003103; + const double f = 0.4053021; + const double g = -0.139670; + const double h = 1.909846; + const double k = 0.00028866050; + + double eMin = std::max(static_cast(0.25), en); // Parameterization valid down to 250 MeV + return en * (a + b * eMin + c / eMin + d / (eMin * eMin) + f / ((eMin - g) * (eMin - g) + h * h) + k / std::pow(eMin, 4)); + } + case 3: { // Obsolete data Run3 const double a = 9.34913e-01; const double b = 2.33e-03; const double c = -8.10e-05; @@ -1743,5 +1774,5 @@ struct caloClusterProducerTask { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/Common/TableProducer/centralityTable.cxx b/Common/TableProducer/centralityTable.cxx index 6b18bcf6882..9198f79499e 100644 --- a/Common/TableProducer/centralityTable.cxx +++ b/Common/TableProducer/centralityTable.cxx @@ -8,9 +8,17 @@ // 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. - -/// \file centrality.cxx +// +/// \file centralityTable.cxx /// \brief Task to produce the centrality tables associated to each of the required centrality estimators +/// +/// \author ALICE +// + +#include +#include +#include +#include #include #include @@ -30,7 +38,7 @@ using namespace o2; using namespace o2::framework; -MetadataHelper metadataInfo; // Metadata helper +o2::common::core::MetadataHelper metadataInfo; // Metadata helper static constexpr int kCentRun2V0Ms = 0; static constexpr int kCentRun2V0As = 1; @@ -42,10 +50,13 @@ static constexpr int kCentFV0As = 6; static constexpr int kCentFT0Ms = 7; static constexpr int kCentFT0As = 8; static constexpr int kCentFT0Cs = 9; -static constexpr int kCentFDDMs = 10; -static constexpr int kCentNTPVs = 11; -static constexpr int nTables = 12; -static constexpr int nParameters = 1; +static constexpr int kCentFT0CVariant1s = 10; +static constexpr int kCentFDDMs = 11; +static constexpr int kCentNTPVs = 12; +static constexpr int kCentNGlobals = 13; +static constexpr int kCentMFTs = 14; +static constexpr int NTables = 15; +static constexpr int NParameters = 1; static const std::vector tableNames{"CentRun2V0Ms", "CentRun2V0As", "CentRun2SPDTrks", @@ -56,10 +67,13 @@ static const std::vector tableNames{"CentRun2V0Ms", "CentFT0Ms", "CentFT0As", "CentFT0Cs", + "CentFT0CVariant1s", "CentFDDMs", - "CentNTPVs"}; + "CentNTPVs", + "CentNGlobals", + "CentMFTs"}; static const std::vector parameterNames{"Enable"}; -static const int defaultParameters[nTables][nParameters]{{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}}; +static const int defaultParameters[NTables][NParameters]{{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}}; struct CentralityTable { Produces centRun2V0M; @@ -72,16 +86,19 @@ struct CentralityTable { Produces centFT0M; Produces centFT0A; Produces centFT0C; + Produces centFT0CVariant1; Produces centFDDM; Produces centNTPV; + Produces centNGlobals; + Produces centMFTs; Service ccdb; Configurable> enabledTables{"enabledTables", - {defaultParameters[0], nTables, nParameters, tableNames, parameterNames}, + {defaultParameters[0], NTables, NParameters, tableNames, parameterNames}, "Produce tables depending on needs. Values different than -1 override the automatic setup: the corresponding table can be set off (0) or on (1)"}; struct : ConfigurableGroup { - Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "The CCDB endpoint url address"}; - Configurable ccdbPath{"ccdbpath", "Centrality/Estimators", "The CCDB path for centrality/multiplicity information"}; - Configurable genName{"genname", "", "Genearator name: HIJING, PYTHIA8, ... Default: \"\""}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "The CCDB endpoint url address"}; + Configurable ccdbPath{"ccdbPath", "Centrality/Estimators", "The CCDB path for centrality/multiplicity information"}; + Configurable genName{"genName", "", "Genearator name: HIJING, PYTHIA8, ... Default: \"\""}; Configurable doNotCrashOnNull{"doNotCrashOnNull", false, {"Option to not crash on null and instead fill required tables with dummy info"}}; Configurable reconstructionPass{"reconstructionPass", "", {"Apass to use when fetching the calibration tables. Empty (default) does not check for any pass. Use `metadata` to fetch it from the AO2D metadata. Otherwise it will override the metadata."}}; } ccdbConfig; @@ -91,7 +108,7 @@ struct CentralityTable { ConfigurableAxis binsPercentile{"binsPercentile", {VARIABLE_WIDTH, 0, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.011, 0.012, 0.013, 0.014, 0.015, 0.016, 0.017, 0.018, 0.019, 0.02, 0.021, 0.022, 0.023, 0.024, 0.025, 0.026, 0.027, 0.028, 0.029, 0.03, 0.031, 0.032, 0.033, 0.034, 0.035, 0.036, 0.037, 0.038, 0.039, 0.04, 0.041, 0.042, 0.043, 0.044, 0.045, 0.046, 0.047, 0.048, 0.049, 0.05, 0.051, 0.052, 0.053, 0.054, 0.055, 0.056, 0.057, 0.058, 0.059, 0.06, 0.061, 0.062, 0.063, 0.064, 0.065, 0.066, 0.067, 0.068, 0.069, 0.07, 0.071, 0.072, 0.073, 0.074, 0.075, 0.076, 0.077, 0.078, 0.079, 0.08, 0.081, 0.082, 0.083, 0.084, 0.085, 0.086, 0.087, 0.088, 0.089, 0.09, 0.091, 0.092, 0.093, 0.094, 0.095, 0.096, 0.097, 0.098, 0.099, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0, 71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0, 80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0, 90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0}, "Binning of the percentile axis"}; int mRunNumber; - struct tagRun2V0MCalibration { + struct TagRun2V0MCalibration { bool mCalibrationStored = false; TFormula* mMCScale = nullptr; float mMCScalePars[6] = {0.0}; @@ -99,39 +116,39 @@ struct CentralityTable { TH1* mhVtxAmpCorrV0C = nullptr; TH1* mhMultSelCalib = nullptr; } Run2V0MInfo; - struct tagRun2V0ACalibration { + struct TagRun2V0ACalibration { bool mCalibrationStored = false; TH1* mhVtxAmpCorrV0A = nullptr; TH1* mhMultSelCalib = nullptr; } Run2V0AInfo; - struct tagRun2SPDTrackletsCalibration { + struct TagRun2SPDTrackletsCalibration { bool mCalibrationStored = false; TH1* mhVtxAmpCorr = nullptr; TH1* mhMultSelCalib = nullptr; } Run2SPDTksInfo; - struct tagRun2SPDClustersCalibration { + struct TagRun2SPDClustersCalibration { bool mCalibrationStored = false; TH1* mhVtxAmpCorrCL0 = nullptr; TH1* mhVtxAmpCorrCL1 = nullptr; TH1* mhMultSelCalib = nullptr; } Run2SPDClsInfo; - struct tagRun2CL0Calibration { + struct TagRun2CL0Calibration { bool mCalibrationStored = false; TH1* mhVtxAmpCorr = nullptr; TH1* mhMultSelCalib = nullptr; } Run2CL0Info; - struct tagRun2CL1Calibration { + struct TagRun2CL1Calibration { bool mCalibrationStored = false; TH1* mhVtxAmpCorr = nullptr; TH1* mhMultSelCalib = nullptr; } Run2CL1Info; - struct calibrationInfo { + struct CalibrationInfo { std::string name = ""; bool mCalibrationStored = false; TH1* mhMultSelCalib = nullptr; float mMCScalePars[6] = {0.0}; TFormula* mMCScale = nullptr; - explicit calibrationInfo(std::string name) + explicit CalibrationInfo(std::string name) : name(name), mCalibrationStored(false), mhMultSelCalib(nullptr), @@ -156,14 +173,17 @@ struct CentralityTable { return true; } }; - calibrationInfo FV0AInfo = calibrationInfo("FV0"); - calibrationInfo FT0MInfo = calibrationInfo("FT0"); - calibrationInfo FT0AInfo = calibrationInfo("FT0A"); - calibrationInfo FT0CInfo = calibrationInfo("FT0C"); - calibrationInfo FDDMInfo = calibrationInfo("FDD"); - calibrationInfo NTPVInfo = calibrationInfo("NTracksPV"); + CalibrationInfo fv0aInfo = CalibrationInfo("FV0"); + CalibrationInfo ft0mInfo = CalibrationInfo("FT0"); + CalibrationInfo ft0aInfo = CalibrationInfo("FT0A"); + CalibrationInfo ft0cInfo = CalibrationInfo("FT0C"); + CalibrationInfo ft0cVariant1Info = CalibrationInfo("FT0Cvar1"); + CalibrationInfo fddmInfo = CalibrationInfo("FDD"); + CalibrationInfo ntpvInfo = CalibrationInfo("NTracksPV"); + CalibrationInfo nGlobalInfo = CalibrationInfo("NGlobal"); + CalibrationInfo mftInfo = CalibrationInfo("MFT"); std::vector mEnabledTables; // Vector of enabled tables - std::array isTableEnabled; + std::array isTableEnabled; // Debug output HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -175,25 +195,25 @@ struct CentralityTable { if (doprocessRun3FT0 == true) { LOG(fatal) << "FT0 only mode is automatically enabled in Run3 mode. Please disable it and enable processRun3."; } - if (doprocessRun2 == false && doprocessRun3 == false) { - LOGF(fatal, "Neither processRun2 nor processRun3 enabled. Please choose one."); + if (doprocessRun2 == false && doprocessRun3 == false && doprocessRun3Complete == false) { + LOGF(fatal, "Neither processRun2 nor processRun3 nor processRun3Complete enabled. Please choose one."); } if (doprocessRun2 == true && doprocessRun3 == true) { LOGF(fatal, "Cannot enable processRun2 and processRun3 at the same time. Please choose one."); } /* Checking the tables which are requested in the workflow and enabling them */ - for (int i = 0; i < nTables; i++) { + for (int i = 0; i < NTables; i++) { int f = enabledTables->get(tableNames[i].c_str(), "Enable"); enableFlagIfTableRequired(context, tableNames[i], f); if (f == 1) { if (tableNames[i].find("Run2") != std::string::npos) { if (doprocessRun3) { - LOGF(fatal, "Cannot enable Run2 tables in Run3 mode. Please check and disable them."); + LOG(fatal) << "Cannot enable Run2 table `" << tableNames[i] << "` while running in Run3 mode. Please check and disable them."; } } else { if (doprocessRun2) { - LOGF(fatal, "Cannot enable Run3 tables in Run2 mode. Please check and disable them."); + LOG(fatal) << "Cannot enable Run3 table `" << tableNames[i] << "` while running in Run2 mode. Please check and disable them."; } } isTableEnabled[i] = true; @@ -213,11 +233,12 @@ struct CentralityTable { doprocessRun3.value = false; } - ccdb->setURL(ccdbConfig.ccdburl); + ccdb->setURL(ccdbConfig.ccdbUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); mRunNumber = 0; + listCalib.setObject(new TList); if (!produceHistograms.value) { return; } @@ -239,7 +260,6 @@ struct CentralityTable { histos.addClone("FT0A/", "sel8FT0A/"); histos.print(); - listCalib.setObject(new TList); } using BCsWithTimestampsAndRun2Infos = soa::Join; @@ -294,12 +314,20 @@ struct CentralityTable { Run2V0MInfo.mMCScalePars[ixpar] = Run2V0MInfo.mMCScale->GetParameter(ixpar); } } else { - LOGF(fatal, "MC Scale information from V0M for run %d not available", bc.runNumber()); + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "MC Scale information from V0M for run %d not available", bc.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(info, "MC Scale information from V0M for run %d not available", bc.runNumber()); + } } } Run2V0MInfo.mCalibrationStored = true; } else { - LOGF(fatal, "Calibration information from V0M for run %d corrupted", bc.runNumber()); + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from V0M for run %d corrupted", bc.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(info, "Calibration information from V0M for run %d corrupted, will fill V0M tables with dummy values", bc.runNumber()); + } } } if (isTableEnabled[kCentRun2V0As]) { @@ -309,7 +337,11 @@ struct CentralityTable { if ((Run2V0AInfo.mhVtxAmpCorrV0A != nullptr) && (Run2V0AInfo.mhMultSelCalib != nullptr)) { Run2V0AInfo.mCalibrationStored = true; } else { - LOGF(fatal, "Calibration information from V0A for run %d corrupted", bc.runNumber()); + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from V0A for run %d corrupted", bc.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(info, "Calibration information from V0A for run %d corrupted, will fill V0A tables with dummy values", bc.runNumber()); + } } } if (isTableEnabled[kCentRun2SPDTrks]) { @@ -319,7 +351,11 @@ struct CentralityTable { if ((Run2SPDTksInfo.mhVtxAmpCorr != nullptr) && (Run2SPDTksInfo.mhMultSelCalib != nullptr)) { Run2SPDTksInfo.mCalibrationStored = true; } else { - LOGF(fatal, "Calibration information from SPD tracklets for run %d corrupted", bc.runNumber()); + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from SPD tracklets for run %d corrupted", bc.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(info, "Calibration information from SPD tracklets for run %d corrupted, will fill SPD tracklets tables with dummy values", bc.runNumber()); + } } } if (isTableEnabled[kCentRun2SPDClss]) { @@ -330,7 +366,11 @@ struct CentralityTable { if ((Run2SPDClsInfo.mhVtxAmpCorrCL0 != nullptr) && (Run2SPDClsInfo.mhVtxAmpCorrCL1 != nullptr) && (Run2SPDClsInfo.mhMultSelCalib != nullptr)) { Run2SPDClsInfo.mCalibrationStored = true; } else { - LOGF(fatal, "Calibration information from SPD clusters for run %d corrupted", bc.runNumber()); + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from SPD clusters for run %d corrupted", bc.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(info, "Calibration information from SPD clusters for run %d corrupted, will fill SPD clusters tables with dummy values", bc.runNumber()); + } } } if (isTableEnabled[kCentRun2CL0s]) { @@ -340,7 +380,11 @@ struct CentralityTable { if ((Run2CL0Info.mhVtxAmpCorr != nullptr) && (Run2CL0Info.mhMultSelCalib != nullptr)) { Run2CL0Info.mCalibrationStored = true; } else { - LOGF(fatal, "Calibration information from CL0 multiplicity for run %d corrupted", bc.runNumber()); + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from CL0 multiplicity for run %d corrupted", bc.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(info, "Calibration information from CL0 multiplicity for run %d corrupted, will fill CL0 multiplicity tables with dummy values", bc.runNumber()); + } } } if (isTableEnabled[kCentRun2CL1s]) { @@ -350,7 +394,11 @@ struct CentralityTable { if ((Run2CL1Info.mhVtxAmpCorr != nullptr) && (Run2CL1Info.mhMultSelCalib != nullptr)) { Run2CL1Info.mCalibrationStored = true; } else { - LOGF(fatal, "Calibration information from CL1 multiplicity for run %d corrupted", bc.runNumber()); + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from CL1 multiplicity for run %d corrupted", bc.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(info, "Calibration information from CL1 multiplicity for run %d corrupted, will fill CL1 multiplicity tables with dummy values", bc.runNumber()); + } } } } else { @@ -363,7 +411,7 @@ struct CentralityTable { } auto scaleMC = [](float x, float pars[6]) { - return pow(((pars[0] + pars[1] * pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); + return std::pow(((pars[0] + pars[1] * std::pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); }; if (isTableEnabled[kCentRun2V0Ms]) { @@ -438,6 +486,8 @@ struct CentralityTable { bool enableCentFT0 = true, bool enableCentFDD = true, bool enableCentNTPV = true, + bool enableCentNGlobal = false, + bool enableCentMFT = false, typename CollisionType> void produceRun3Tables(CollisionType const& collisions) { @@ -456,12 +506,21 @@ struct CentralityTable { case kCentFT0Cs: centFT0C.reserve(collisions.size()); break; + case kCentFT0CVariant1s: + centFT0CVariant1.reserve(collisions.size()); + break; case kCentFDDMs: centFDDM.reserve(collisions.size()); break; case kCentNTPVs: centNTPV.reserve(collisions.size()); break; + case kCentNGlobals: + centNGlobals.reserve(collisions.size()); + break; + case kCentMFTs: + centMFTs.reserve(collisions.size()); + break; default: LOGF(fatal, "Table %d not supported in Run3", table); break; @@ -499,18 +558,21 @@ struct CentralityTable { } } - FV0AInfo.mCalibrationStored = false; - FT0MInfo.mCalibrationStored = false; - FT0AInfo.mCalibrationStored = false; - FT0CInfo.mCalibrationStored = false; - FDDMInfo.mCalibrationStored = false; - NTPVInfo.mCalibrationStored = false; + fv0aInfo.mCalibrationStored = false; + ft0mInfo.mCalibrationStored = false; + ft0aInfo.mCalibrationStored = false; + ft0cInfo.mCalibrationStored = false; + ft0cVariant1Info.mCalibrationStored = false; + fddmInfo.mCalibrationStored = false; + ntpvInfo.mCalibrationStored = false; + nGlobalInfo.mCalibrationStored = false; + mftInfo.mCalibrationStored = false; if (callst != nullptr) { if (produceHistograms) { listCalib->Add(callst->Clone(Form("%i", bc.runNumber()))); } LOGF(info, "Getting new histograms with %d run number for %d run number", mRunNumber, bc.runNumber()); - auto getccdb = [callst, bc](struct calibrationInfo& estimator, const Configurable generatorName) { // TODO: to consider the name inside the estimator structure + auto getccdb = [callst, bc](struct CalibrationInfo& estimator, const Configurable generatorName) { // TODO: to consider the name inside the estimator structure estimator.mhMultSelCalib = reinterpret_cast(callst->FindObject(TString::Format("hCalibZeq%s", estimator.name.c_str()).Data())); estimator.mMCScale = reinterpret_cast(callst->FindObject(TString::Format("%s-%s", generatorName->c_str(), estimator.name.c_str()).Data())); if (estimator.mhMultSelCalib != nullptr) { @@ -528,29 +590,38 @@ struct CentralityTable { estimator.mCalibrationStored = true; estimator.isSane(); } else { - LOGF(error, "Calibration information from %s for run %d not available", estimator.name.c_str(), bc.runNumber()); + LOGF(info, "Calibration information from %s for run %d not available, will fill this estimator with invalid values and continue (no crash).", estimator.name.c_str(), bc.runNumber()); } }; for (auto const& table : mEnabledTables) { switch (table) { case kCentFV0As: - getccdb(FV0AInfo, ccdbConfig.genName); + getccdb(fv0aInfo, ccdbConfig.genName); break; case kCentFT0Ms: - getccdb(FT0MInfo, ccdbConfig.genName); + getccdb(ft0mInfo, ccdbConfig.genName); break; case kCentFT0As: - getccdb(FT0AInfo, ccdbConfig.genName); + getccdb(ft0aInfo, ccdbConfig.genName); break; case kCentFT0Cs: - getccdb(FT0CInfo, ccdbConfig.genName); + getccdb(ft0cInfo, ccdbConfig.genName); + break; + case kCentFT0CVariant1s: + getccdb(ft0cVariant1Info, ccdbConfig.genName); break; case kCentFDDMs: - getccdb(FDDMInfo, ccdbConfig.genName); + getccdb(fddmInfo, ccdbConfig.genName); break; case kCentNTPVs: - getccdb(NTPVInfo, ccdbConfig.genName); + getccdb(ntpvInfo, ccdbConfig.genName); + break; + case kCentNGlobals: + getccdb(nGlobalInfo, ccdbConfig.genName); + break; + case kCentMFTs: + getccdb(mftInfo, ccdbConfig.genName); break; default: LOGF(fatal, "Table %d not supported in Run3", table); @@ -574,10 +645,10 @@ struct CentralityTable { * @param multiplicity The multiplicity value. */ - auto populateTable = [&](auto& table, struct calibrationInfo& estimator, float multiplicity) { + auto populateTable = [&](auto& table, struct CalibrationInfo& estimator, float multiplicity) { const bool assignOutOfRange = embedINELgtZEROselection && !collision.isInelGt0(); auto scaleMC = [](float x, float pars[6]) { - return pow(((pars[0] + pars[1] * pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); + return std::pow(((pars[0] + pars[1] * std::pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); }; float percentile = 105.0f; @@ -600,12 +671,12 @@ struct CentralityTable { switch (table) { case kCentFV0As: if constexpr (enableCentFV0) { - populateTable(centFV0A, FV0AInfo, collision.multZeqFV0A()); + populateTable(centFV0A, fv0aInfo, collision.multZeqFV0A()); } break; case kCentFT0Ms: if constexpr (enableCentFT0) { - const float perC = populateTable(centFT0M, FT0MInfo, collision.multZeqFT0A() + collision.multZeqFT0C()); + const float perC = populateTable(centFT0M, ft0mInfo, collision.multZeqFT0A() + collision.multZeqFT0C()); if (produceHistograms.value) { histos.fill(HIST("FT0M/percentile"), perC); histos.fill(HIST("FT0M/percentilevsPV"), perC, collision.multNTracksPV()); @@ -620,7 +691,7 @@ struct CentralityTable { break; case kCentFT0As: if constexpr (enableCentFT0) { - const float perC = populateTable(centFT0A, FT0AInfo, collision.multZeqFT0A()); + const float perC = populateTable(centFT0A, ft0aInfo, collision.multZeqFT0A()); if (produceHistograms.value) { histos.fill(HIST("FT0A/percentile"), perC); histos.fill(HIST("FT0A/percentilevsPV"), perC, collision.multNTracksPV()); @@ -635,7 +706,7 @@ struct CentralityTable { break; case kCentFT0Cs: if constexpr (enableCentFT0) { - const float perC = populateTable(centFT0C, FT0CInfo, collision.multZeqFT0C()); + const float perC = populateTable(centFT0C, ft0cInfo, collision.multZeqFT0C()); if (produceHistograms.value) { histos.fill(HIST("FT0C/percentile"), perC); histos.fill(HIST("FT0C/percentilevsPV"), perC, collision.multNTracksPV()); @@ -648,14 +719,29 @@ struct CentralityTable { } } break; + case kCentFT0CVariant1s: + if constexpr (enableCentFT0) { + populateTable(centFT0CVariant1, ft0cVariant1Info, collision.multZeqFT0C()); + } + break; case kCentFDDMs: if constexpr (enableCentFDD) { - populateTable(centFDDM, FDDMInfo, collision.multZeqFDDA() + collision.multZeqFDDC()); + populateTable(centFDDM, fddmInfo, collision.multZeqFDDA() + collision.multZeqFDDC()); } break; case kCentNTPVs: if constexpr (enableCentNTPV) { - populateTable(centNTPV, NTPVInfo, collision.multZeqNTracksPV()); + populateTable(centNTPV, ntpvInfo, collision.multZeqNTracksPV()); + } + break; + case kCentNGlobals: + if constexpr (enableCentNGlobal) { + populateTable(centNGlobals, nGlobalInfo, collision.multNTracksGlobal()); + } + break; + case kCentMFTs: + if constexpr (enableCentMFT) { + populateTable(centMFTs, mftInfo, collision.mftNtracks()); } break; default: @@ -666,6 +752,11 @@ struct CentralityTable { } } + void processRun3Complete(soa::Join const& collisions, BCsWithTimestamps const&) + { + produceRun3Tables(collisions); + } + void processRun3(soa::Join const& collisions, BCsWithTimestamps const&) { produceRun3Tables(collisions); @@ -681,6 +772,7 @@ struct CentralityTable { // Process switches PROCESS_SWITCH(CentralityTable, processRun2, "Provide Run2 calibrated centrality/multiplicity percentiles tables", true); + PROCESS_SWITCH(CentralityTable, processRun3Complete, "Provide Run3 calibrated centrality/multiplicity percentiles tables using MFT and global tracks (requires extra subscriptions)", false); PROCESS_SWITCH(CentralityTable, processRun3, "Provide Run3 calibrated centrality/multiplicity percentiles tables", false); PROCESS_SWITCH(CentralityTable, processRun3FT0, "Provide Run3 calibrated centrality/multiplicity percentiles tables for FT0 only", false); }; diff --git a/Common/TableProducer/eseTableProducer.cxx b/Common/TableProducer/eseTableProducer.cxx index 34f534dc700..098bfbe400f 100644 --- a/Common/TableProducer/eseTableProducer.cxx +++ b/Common/TableProducer/eseTableProducer.cxx @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" @@ -40,33 +42,50 @@ using namespace o2; using namespace o2::framework; -using CollWithMults = soa::Join; +using CollWithMults = soa::Join; struct EseTableProducer { Produces qPercsFT0C; Produces qPercsFT0A; Produces qPercsFV0A; - Produces qPercsTPC; - Produces fEseCol; + Produces qPercsTPCall; + Produces qPercsTPCneg; + Produces qPercsTPCpos; OutputObj FFitObj{FFitWeights("weights")}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - Configurable cfgESE{"cfgESE", 1, "ese activation step: false = no ese, true = evaluate splines and fill table"}; + Configurable cfgESE{"cfgESE", 1, "ese activation step: false = no ese, true = evaluate qSelection and fill table"}; Configurable cfgEsePath{"cfgEsePath", "Users/j/joachiha/ESE/local/ffitsplines", "CCDB path for ese splines"}; - Configurable cfgFT0C{"cfgFT0C", 1, "FT0C flag"}; - Configurable cfgFT0A{"cfgFT0A", 0, "FT0A flag"}; - Configurable cfgFV0A{"cfgFV0A", 0, "FV0A flag"}; - Configurable cfgTPC{"cfgTPC", 0, "TPC flag"}; - Configurable> cfgLoopHarmonics{"cfgLoopHarmonics", {2, 3}, "Harmonics to loop over when filling and evaluating splines"}; - Configurable cfgCentEst{"cfgCentEst", "FT0C", "centrality estimator"}; + Configurable> cfgDetectors{"cfgDetectors", {"FT0C"}, "detectors to loop over: ['FT0C', 'FT0A', 'FV0A', 'TPCall', 'TPCneg', 'TPCpos']"}; + Configurable> cfgLoopHarmonics{"cfgLoopHarmonics", {2, 3}, "Harmonics to loop over when filling and evaluating q-Selection"}; Configurable> cfgaxisqn{"cfgaxisqn", {500, 0, 25}, "q_n amplitude range"}; - Configurable cfgnResolution{"cfgnResolution", 3000, "resolution of splines"}; + Configurable cfgnResolution{"cfgnResolution", 3000, "resolution of q-Selection"}; + + Configurable cfgnTotalSystem{"cfgnTotalSystem", 7, "total qvector number // look in Qvector table for this number"}; + Configurable cfgnCorrLevel{"cfgnCorrLevel", 3, "QVector step: 0 = no corr, 1 = rect, 2 = twist, 3 = full"}; int runNumber{-1}; - FFitWeights* splines{nullptr}; + enum class DetID { FT0C, + FT0A, + FT0M, + FV0A, + TPCpos, + TPCneg, + TPCall }; + + std::unordered_map detMap = { + {"FT0C", DetID::FT0C}, + {"FT0A", DetID::FT0A}, + {"FT0M", DetID::FT0M}, + {"FV0A", DetID::FV0A}, + {"TPCpos", DetID::TPCpos}, + {"TPCneg", DetID::TPCneg}, + {"TPCall", DetID::TPCall}}; + + FFitWeights* qSelection{nullptr}; Service ccdb; @@ -85,26 +104,16 @@ struct EseTableProducer { int64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); ccdb->setCreatedNotAfter(now); - std::vector vecStr{}; - if (cfgFT0C) - vecStr.push_back("FT0C"); - if (cfgFT0A) - vecStr.push_back("FT0A"); - if (cfgFV0A) - vecStr.push_back("FV0A"); - if (cfgTPC) - vecStr.push_back("TPC"); - std::vector> veccfg; for (std::size_t i{0}; i < cfgLoopHarmonics->size(); i++) { - for (const auto& j : vecStr) { - veccfg.push_back({cfgLoopHarmonics->at(i), j}); + for (std::size_t j{0}; j < cfgDetectors->size(); j++) { + veccfg.push_back({cfgLoopHarmonics->at(i), cfgDetectors->at(j)}); } } - FFitObj->SetBinAxis(cfgaxisqn->at(0), cfgaxisqn->at(1), cfgaxisqn->at(2)); - FFitObj->SetResolution(cfgnResolution); - FFitObj->SetQnType(veccfg); - FFitObj->Init(); + FFitObj->setBinAxis(cfgaxisqn->at(0), cfgaxisqn->at(1), cfgaxisqn->at(2)); + FFitObj->setResolution(cfgnResolution); + FFitObj->setQnType(veccfg); + FFitObj->init(); } void initCCDB(aod::BCsWithTimestamps::iterator const& bc) @@ -113,10 +122,10 @@ struct EseTableProducer { auto timestamp = bc.timestamp(); if (cfgESE) { - splines = ccdb->getForTimeStamp(cfgEsePath, timestamp); - if (!splines) - LOGF(fatal, "failed loading splines with ese flag"); - LOGF(info, "successfully loaded splines"); + qSelection = ccdb->getForTimeStamp(cfgEsePath, timestamp); + if (!qSelection) + LOGF(fatal, "failed loading qSelection with ese flag"); + LOGF(info, "successfully loaded qSelection"); } } @@ -130,76 +139,88 @@ struct EseTableProducer { return qn; } - bool validQvec(const float& qVec) + constexpr int detIDN(const DetID id) { - if (qVec == 999. || qVec == -999) { - return false; - } else { - return true; + switch (id) { + case DetID::FT0C: + return 0; + case DetID::FT0A: + return 1; + case DetID::FT0M: + return 2; + case DetID::FV0A: + return 3; + case DetID::TPCpos: + return 4; + case DetID::TPCneg: + return 5; + case DetID::TPCall: + return 6; } - }; + return -1; + } - void doSpline(float& splineVal, int& eseval, const float& centr, const float& nHarm, const char* pf, const auto& QX, const auto& QY, const auto& Ampl) + void doSpline(float& splineVal, const float& centr, const float& nHarm, const char* pf, const auto& QX, const auto& QY, const auto& sumAmpl) { - if (validQvec(QX[nHarm - 2]) && validQvec(QY[nHarm - 2]) && Ampl > 1e-8) { - float qnval = Calcqn(QX[nHarm - 2] * Ampl, QY[nHarm - 2] * Ampl, Ampl); - FFitObj->Fill(centr, qnval, nHarm, pf); + if (sumAmpl > 1e-8) { + float qnval = Calcqn(QX * sumAmpl, QY * sumAmpl, sumAmpl); + FFitObj->fillWeights(centr, qnval, nHarm, pf); if (cfgESE) { - splineVal = splines->EvalSplines(centr, qnval, nHarm, pf); - eseval = cfgFT0C ? 1 : 0; + splineVal = qSelection->eval(centr, qnval, nHarm, pf); } } } + template + std::tuple getVectors(const C& col, const int& nHarm, const DetID& id) + { + const int detId = detIDN(id); + const int detInd{detId * 4 + cfgnTotalSystem * 4 * (nHarm - 2)}; + const auto Qx{col.qvecRe()[detInd + cfgnCorrLevel]}; + const auto Qy{col.qvecIm()[detInd + cfgnCorrLevel]}; + const auto sumAmpl{col.qvecAmp()[detId]}; + return {Qx, Qy, sumAmpl}; + } + template void calculateESE(T const& collision, std::vector& qnpFT0C, std::vector& qnpFT0A, std::vector& qnpFV0A, - std::vector& qnpTPC, - std::vector& fIsEseAvailable) + std::vector& qnpTPCall, + std::vector& qnpTPCneg, + std::vector& qnpTPCpos) { - const float centrality = collision.centFT0C(); - registry.fill(HIST("hESEstat"), 0.5); - for (std::size_t i{0}; i < cfgLoopHarmonics->size(); i++) { - float splineValFT0C{-1.0}; - float splineValFT0A{-1.0}; - float splineValFV0A{-1.0}; - qnpTPC.push_back(-1.0); /* not implemented yet */ - int eseAvailable{0}; - - int nHarm = cfgLoopHarmonics->at(i); - if (cfgFT0C) { - const auto QxFT0C_Qvec = collision.qvecFT0CReVec(); - const auto QyFT0C_Qvec = collision.qvecFT0CImVec(); - const auto SumAmplFT0C = collision.sumAmplFT0C(); - doSpline(splineValFT0C, eseAvailable, centrality, nHarm, "FT0C", QxFT0C_Qvec, QyFT0C_Qvec, SumAmplFT0C); - if (i == 0) - registry.fill(HIST("hESEstat"), 1.5); - } - qnpFT0C.push_back(splineValFT0C); - fIsEseAvailable.push_back(eseAvailable); - - if (cfgFT0A) { - const auto QxFT0A_Qvec = collision.qvecFT0AReVec(); - const auto QyFT0A_Qvec = collision.qvecFT0AImVec(); - const auto SumAmplFT0A = collision.sumAmplFT0A(); - doSpline(splineValFT0A, eseAvailable, centrality, nHarm, "FT0A", QxFT0A_Qvec, QyFT0A_Qvec, SumAmplFT0A); - if (i == 0) - registry.fill(HIST("hESEstat"), 2.5); - } - qnpFT0A.push_back(splineValFT0A); - - if (cfgFV0A) { - const auto QxFV0A_Qvec = collision.qvecFV0AReVec(); - const auto QyFV0A_Qvec = collision.qvecFV0AImVec(); - const auto SumAmplFV0A = collision.sumAmplFV0A(); - doSpline(splineValFV0A, eseAvailable, centrality, nHarm, "FV0A", QxFV0A_Qvec, QyFV0A_Qvec, SumAmplFV0A); - if (i == 0) - registry.fill(HIST("hESEstat"), 3.5); + float counter{0.5}; + registry.fill(HIST("hESEstat"), counter++); + + std::unordered_map*> vMap{ + {"FT0C", &qnpFT0C}, + {"FT0A", &qnpFT0A}, + {"FV0A", &qnpFV0A}, + {"TPCall", &qnpTPCall}, + {"TPCneg", &qnpTPCneg}, + {"TPCpos", &qnpTPCpos}}; + + for (std::size_t j{0}; j < cfgDetectors->size(); j++) { + const auto det{cfgDetectors->at(j)}; + const auto iter{detMap.find(det)}; + float splineVal{-1.0}; + + if (iter != detMap.end()) { + for (std::size_t i{0}; i < cfgLoopHarmonics->size(); i++) { + const int nHarm{cfgLoopHarmonics->at(i)}; + const auto [qxt, qyt, st] = getVectors(collision, nHarm, iter->second); + doSpline(splineVal, centrality, nHarm, det.c_str(), qxt, qyt, st); + if (i == 0) + registry.fill(HIST("hESEstat"), counter++); + + if (vMap.find(det) != vMap.end()) { + vMap[det]->push_back(splineVal); + } + } } - qnpFV0A.push_back(splineValFV0A); } }; @@ -211,24 +232,25 @@ struct EseTableProducer { std::vector qnpFT0C{}; std::vector qnpFT0A{}; std::vector qnpFV0A{}; - std::vector qnpTPC{}; - - std::vector fIsEseAvailable{}; + std::vector qnpTPCall{}; + std::vector qnpTPCneg{}; + std::vector qnpTPCpos{}; - auto bc = collision.bc_as(); - int currentRun = bc.runNumber(); + auto bc{collision.bc_as()}; + int currentRun{bc.runNumber()}; if (runNumber != currentRun) { runNumber = currentRun; initCCDB(bc); } registry.fill(HIST("hEventCounter"), counter++); - calculateESE(collision, qnpFT0C, qnpFT0A, qnpFV0A, qnpTPC, fIsEseAvailable); + calculateESE(collision, qnpFT0C, qnpFT0A, qnpFV0A, qnpTPCall, qnpTPCneg, qnpTPCpos); qPercsFT0C(qnpFT0C); qPercsFT0A(qnpFT0A); qPercsFV0A(qnpFV0A); - qPercsTPC(qnpTPC); - fEseCol(fIsEseAvailable); + qPercsTPCall(qnpTPCall); + qPercsTPCneg(qnpTPCneg); + qPercsTPCpos(qnpTPCpos); registry.fill(HIST("hEventCounter"), counter++); } PROCESS_SWITCH(EseTableProducer, processESE, "proccess q vectors to calculate reduced q-vector", true); diff --git a/Common/TableProducer/eventSelection.cxx b/Common/TableProducer/eventSelection.cxx index 6c323c86952..b517bb90010 100644 --- a/Common/TableProducer/eventSelection.cxx +++ b/Common/TableProducer/eventSelection.cxx @@ -16,6 +16,8 @@ #include #include +#include +#include #include "Framework/ConfigParamSpec.h" #include "Framework/runDataProcessing.h" @@ -36,6 +38,8 @@ #include "DataFormatsITSMFT/NoiseMap.h" // missing include in TimeDeadMap.h #include "DataFormatsITSMFT/TimeDeadMap.h" #include "ITSMFTReconstruction/ChipMappingITS.h" +#include "DataFormatsCTP/Configuration.h" +#include "DataFormatsCTP/Scalers.h" #include "TH1D.h" @@ -43,7 +47,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::aod::evsel; -MetadataHelper metadataInfo; // Metadata helper +o2::common::core::MetadataHelper metadataInfo; // Metadata helper using BCsWithRun2InfosTimestampsAndMatches = soa::Join; using BCsWithRun3Matchings = soa::Join; @@ -58,15 +62,18 @@ struct BcSelectionTask { Produces bcsel; Service ccdb; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - Configurable confTriggerBcShift{"triggerBcShift", 999, "set to 294 for apass2/apass3 in LHC22o-t"}; // o2-linter: disable=name/configurable - Configurable confITSROFrameStartBorderMargin{"ITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"}; // o2-linter: disable=name/configurable - Configurable confITSROFrameEndBorderMargin{"ITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"}; // o2-linter: disable=name/configurable - Configurable confTimeFrameStartBorderMargin{"TimeFrameStartBorderMargin", -1, "Number of bcs to cut at the start of the Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable - Configurable confTimeFrameEndBorderMargin{"TimeFrameEndBorderMargin", -1, "Number of bcs to cut at the end of the Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable - Configurable confCheckRunDurationLimits{"checkRunDurationLimits", false, "Check if the BCs are within the run duration limits"}; // o2-linter: disable=name/configurable + Configurable confTriggerBcShift{"triggerBcShift", 0, "set either custom shift or 999 for apass2/apass3 in LHC22o-t"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confITSROFrameStartBorderMargin{"ITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confITSROFrameEndBorderMargin{"ITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confTimeFrameStartBorderMargin{"TimeFrameStartBorderMargin", -1, "Number of bcs to cut at the start of the Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confTimeFrameEndBorderMargin{"TimeFrameEndBorderMargin", -1, "Number of bcs to cut at the end of the Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCheckRunDurationLimits{"checkRunDurationLimits", false, "Check if the BCs are within the run duration limits"}; // o2-linter: disable=name/configurable (temporary fix) Configurable> maxInactiveChipsPerLayer{"maxInactiveChipsPerLayer", {8, 8, 8, 111, 111, 195, 195}, "Maximum allowed number of inactive ITS chips per layer"}; + Configurable confNumberOfOrbitsPerTF{"NumberOfOrbitsPerTF", -1, "Number of orbits per Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) int lastRun = -1; + int64_t lastTF = -1; + uint32_t lastRCT = 0; uint64_t sorTimestamp = 0; // default SOR timestamp uint64_t eorTimestamp = 1; // default EOR timestamp int64_t bcSOR = -1; // global bc of the start of run @@ -77,49 +84,26 @@ struct BcSelectionTask { int mITSROFrameEndBorderMargin = 20; // default value int mTimeFrameStartBorderMargin = 300; // default value int mTimeFrameEndBorderMargin = 4000; // default value - bool isPP = 1; // default value + std::string strLPMProductionTag = ""; // MC production tag to be retrieved from AO2D metadata + TriggerAliases* aliases = nullptr; EventSelectionParams* par = nullptr; + std::map* mapRCT = nullptr; std::map> mapInactiveChips; // number of inactive chips vs orbit per layer int64_t prevOrbitForInactiveChips = 0; // cached next stored orbit in the inactive chip map int64_t nextOrbitForInactiveChips = 0; // cached previous stored orbit in the inactive chip map bool isGoodITSLayer3 = true; // default value bool isGoodITSLayer0123 = true; // default value bool isGoodITSLayersAll = true; // default value - void init(InitContext&) { - if (metadataInfo.isFullyDefined() && !doprocessRun2 && !doprocessRun3) { // Check if the metadata is initialized (only if not forced from the workflow configuration) - LOG(info) << "Autosetting the processing mode (Run2 or Run3) based on metadata"; - if (metadataInfo.isRun3()) { - doprocessRun3.value = true; - } else { - doprocessRun2.value = false; - } - } - // ccdb->setURL("http://ccdb-test.cern.ch:8080"); ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); + strLPMProductionTag = metadataInfo.get("LPMProductionTag"); // to extract info from ccdb by the tag - histos.add("hCounterTVX", "", kTH1D, {{1, 0., 1.}}); - histos.add("hCounterTCE", "", kTH1D, {{1, 0., 1.}}); - histos.add("hCounterZEM", "", kTH1D, {{1, 0., 1.}}); - histos.add("hCounterZNC", "", kTH1D, {{1, 0., 1.}}); - histos.add("hCounterTVXafterBCcuts", "", kTH1D, {{1, 0., 1.}}); - histos.add("hCounterTCEafterBCcuts", "", kTH1D, {{1, 0., 1.}}); - histos.add("hCounterZEMafterBCcuts", "", kTH1D, {{1, 0., 1.}}); - histos.add("hCounterZNCafterBCcuts", "", kTH1D, {{1, 0., 1.}}); histos.add("hCounterInvalidBCTimestamp", "", kTH1D, {{1, 0., 1.}}); - histos.add("hLumiTVX", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); - histos.add("hLumiTCE", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); - histos.add("hLumiZEM", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); - histos.add("hLumiZNC", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); - histos.add("hLumiTVXafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); - histos.add("hLumiTCEafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); - histos.add("hLumiZEMafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); - histos.add("hLumiZNCafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); } void processRun2( @@ -242,8 +226,9 @@ struct BcSelectionTask { histos.get(HIST("hCounterTVX"))->Fill(Form("%d", bc.runNumber()), 1); } + uint32_t rct = 0; // Fill bc selection columns - bcsel(alias, selection, foundFT0, foundFV0, foundFDD, foundZDC); + bcsel(alias, selection, rct, foundFT0, foundFV0, foundFDD, foundZDC); } } PROCESS_SWITCH(BcSelectionTask, processRun2, "Process Run2 event selection", true); @@ -260,18 +245,33 @@ struct BcSelectionTask { int run = bcs.iteratorAt(0).runNumber(); - if (run != lastRun && run >= 500000) { + if (run != lastRun) { lastRun = run; - auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run); - // first bc of the first orbit - bcSOR = runInfo.orbitSOR * nBCsPerOrbit; - // duration of TF in bcs - nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit; - // SOR and EOR timestamps - sorTimestamp = runInfo.sor; - eorTimestamp = runInfo.eor; + int run3min = 500000; + if (run < run3min) { // unanchored Run3 MC + auto runDuration = ccdb->getRunDuration(run, true); // fatalise if timestamps are not found + // SOR and EOR timestamps + sorTimestamp = runDuration.first; // timestamp of the SOR/SOX/STF in ms + eorTimestamp = runDuration.second; // timestamp of the EOR/EOX/ETF in ms + auto ctp = ccdb->getForTimeStamp>("CTP/Calib/OrbitReset", sorTimestamp / 2 + eorTimestamp / 2); + auto orbitResetMUS = (*ctp)[0]; + // first bc of the first orbit + bcSOR = static_cast((sorTimestamp * 1000 - orbitResetMUS) / o2::constants::lhc::LHCOrbitMUS) * nBCsPerOrbit; + // duration of TF in bcs + nBCsPerTF = 32; // hard-coded for Run3 MC (no info from ccdb at the moment) + } else { + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run, strLPMProductionTag); + // SOR and EOR timestamps + sorTimestamp = runInfo.sor; + eorTimestamp = runInfo.eor; + // first bc of the first orbit + bcSOR = runInfo.orbitSOR * nBCsPerOrbit; + // duration of TF in bcs + nBCsPerTF = confNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * nBCsPerOrbit : confNumberOfOrbitsPerTF * nBCsPerOrbit; + } + // timestamp of the middle of the run used to access run-wise CCDB entries - int64_t ts = runInfo.sor / 2 + runInfo.eor / 2; + int64_t ts = sorTimestamp / 2 + eorTimestamp / 2; // access ITSROF and TF border margins par = ccdb->getForTimeStamp("EventSelection/EventSelectionParams", ts); mITSROFrameStartBorderMargin = confITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : confITSROFrameStartBorderMargin; @@ -284,11 +284,7 @@ struct BcSelectionTask { rofLength = alppar->roFrameLengthInBC; // Trigger aliases aliases = ccdb->getForTimeStamp("EventSelection/TriggerAliases", ts); - // Collision system info - auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", ts); - int beamZ1 = grplhcif->getBeamZ(o2::constants::lhc::BeamA); - int beamZ2 = grplhcif->getBeamZ(o2::constants::lhc::BeamC); - isPP = beamZ1 == 1 && beamZ2 == 1; + // prepare map of inactive chips auto itsDeadMap = ccdb->getForTimeStamp("ITS/Calib/TimeDeadMap", ts); auto itsDeadMapOrbits = itsDeadMap->getEvolvingMapKeys(); // roughly every second, ~350 TFs = 350x32 orbits @@ -311,6 +307,19 @@ struct BcSelectionTask { } } // loop over vector of inactive chip ids } // loop over orbits + + // QC info + std::map metadata; + metadata["run"] = Form("%d", run); + ccdb->setFatalWhenNull(0); + mapRCT = ccdb->getSpecific>("RCT/Flags/RunFlags", ts, metadata); + ccdb->setFatalWhenNull(1); + if (mapRCT == nullptr) { + LOGP(info, "rct object missing... inserting dummy rct flags"); + mapRCT = new std::map; + uint32_t dummyValue = 1 << 31; // setting bit 31 to indicate that rct object is missing + mapRCT->insert(std::pair(sorTimestamp, dummyValue)); + } } // map from GlobalBC to BcId needed to find triggerBc @@ -320,12 +329,25 @@ struct BcSelectionTask { } int triggerBcShift = confTriggerBcShift; - if (confTriggerBcShift == 999) { - triggerBcShift = (run <= 526766 || (run >= 526886 && run <= 527237) || (run >= 527259 && run <= 527518) || run == 527523 || run == 527734 || run >= 534091) ? 0 : 294; + if (confTriggerBcShift == 999) { // o2-linter: disable=magic-number (special shift for early 2022 data) + triggerBcShift = (run <= 526766 || (run >= 526886 && run <= 527237) || (run >= 527259 && run <= 527518) || run == 527523 || run == 527734 || run >= 534091) ? 0 : 294; // o2-linter: disable=magic-number (magic list of runs) } // bc loop - for (auto bc : bcs) { // o2-linter: disable=const-ref-in-for-loop + for (auto bc : bcs) { // o2-linter: disable=const-ref-in-for-loop (use bc as nonconst iterator) + // store rct flags + uint32_t rct = lastRCT; + int64_t thisTF = (bc.globalBC() - bcSOR) / nBCsPerTF; + if (mapRCT != nullptr && thisTF != lastTF) { // skip for unanchored runs; do it once per TF + auto itrct = mapRCT->upper_bound(bc.timestamp()); + if (itrct != mapRCT->begin()) + itrct--; + rct = itrct->second; + LOGP(debug, "sor={} eor={} ts={} rct={}", sorTimestamp, eorTimestamp, bc.timestamp(), rct); + lastRCT = rct; + lastTF = thisTF; + } + uint32_t alias{0}; // workaround for pp2022 (trigger info is shifted by -294 bcs) int32_t triggerBcId = mapGlobalBCtoBcId[bc.globalBC() + triggerBcShift]; @@ -364,12 +386,14 @@ struct BcSelectionTask { } --bc; backwardMoveCount++; - if (bc.globalBC() + 1 == globalBC) { + int bcDistanceToBeamGasForFT0 = 1; + int bcDistanceToBeamGasForFDD = 5; + if (bc.globalBC() + bcDistanceToBeamGasForFT0 == globalBC) { timeV0ABG = bc.has_fv0a() ? bc.fv0a().time() : -999.f; timeT0ABG = bc.has_ft0() ? bc.ft0().timeA() : -999.f; timeT0CBG = bc.has_ft0() ? bc.ft0().timeC() : -999.f; } - if (bc.globalBC() + 5 == globalBC) { + if (bc.globalBC() + bcDistanceToBeamGasForFDD == globalBC) { timeFDABG = bc.has_fdd() ? bc.fdd().timeA() : -999.f; timeFDCBG = bc.has_fdd() ? bc.fdd().timeC() : -999.f; } @@ -424,7 +448,7 @@ struct BcSelectionTask { LOGP(debug, "prev inactive chips: {} {} {} {} {} {} {}", vPrevInactiveChips[0], vPrevInactiveChips[1], vPrevInactiveChips[2], vPrevInactiveChips[3], vPrevInactiveChips[4], vPrevInactiveChips[5], vPrevInactiveChips[6]); isGoodITSLayer3 = vPrevInactiveChips[3] <= maxInactiveChipsPerLayer->at(3) && vNextInactiveChips[3] <= maxInactiveChipsPerLayer->at(3); isGoodITSLayer0123 = true; - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 4; i++) { // o2-linter: disable=magic-number (counting first 4 ITS layers) isGoodITSLayer0123 &= vPrevInactiveChips[i] <= maxInactiveChipsPerLayer->at(i) && vNextInactiveChips[i] <= maxInactiveChipsPerLayer->at(i); } isGoodITSLayersAll = true; @@ -444,58 +468,7 @@ struct BcSelectionTask { int32_t foundZDC = bc.has_zdc() ? bc.zdc().globalIndex() : -1; LOGP(debug, "foundFT0={}", foundFT0); - // Temporary workaround to get visible cross section. TODO: store run-by-run visible cross sections in CCDB const char* srun = Form("%d", run); - - bool injectionEnergy = (run >= 500000 && run <= 520099) || (run >= 534133 && run <= 534468); - // Cross sections in ub. Using dummy -1 if lumi estimator is not reliable - float csTVX = isPP ? (injectionEnergy ? 0.0355e6 : 0.0594e6) : -1.; - float csTCE = isPP ? -1. : 10.36e6; - float csZEM = isPP ? -1. : 415.2e6; // see AN: https://alice-notes.web.cern.ch/node/1515 - float csZNC = isPP ? -1. : 214.5e6; // see AN: https://alice-notes.web.cern.ch/node/1515 - if (run > 543437 && run < 543514) { - csTCE = 8.3e6; - } - if (run >= 543514) { - csTCE = 4.10e6; // see AN: https://alice-notes.web.cern.ch/node/1515 - } - - // Fill TVX (T0 vertex) counters - if (TESTBIT(selection, kIsTriggerTVX)) { - histos.get(HIST("hCounterTVX"))->Fill(srun, 1); - histos.get(HIST("hLumiTVX"))->Fill(srun, 1. / csTVX); - if (TESTBIT(selection, kNoITSROFrameBorder) && TESTBIT(selection, kNoTimeFrameBorder)) { - histos.get(HIST("hCounterTVXafterBCcuts"))->Fill(srun, 1); - histos.get(HIST("hLumiTVXafterBCcuts"))->Fill(srun, 1. / csTVX); - } - } - // Fill counters and lumi histograms for Pb-Pb lumi monitoring - // TODO: introduce pileup correction - if (bc.has_ft0() ? (TESTBIT(selection, kIsTriggerTVX) && TESTBIT(bc.ft0().triggerMask(), o2::ft0::Triggers::bitCen)) : 0) { - histos.get(HIST("hCounterTCE"))->Fill(srun, 1); - histos.get(HIST("hLumiTCE"))->Fill(srun, 1. / csTCE); - if (TESTBIT(selection, kNoITSROFrameBorder) && TESTBIT(selection, kNoTimeFrameBorder)) { - histos.get(HIST("hCounterTCEafterBCcuts"))->Fill(srun, 1); - histos.get(HIST("hLumiTCEafterBCcuts"))->Fill(srun, 1. / csTCE); - } - } - if (TESTBIT(selection, kIsBBZNA) || TESTBIT(selection, kIsBBZNC)) { - histos.get(HIST("hCounterZEM"))->Fill(srun, 1); - histos.get(HIST("hLumiZEM"))->Fill(srun, 1. / csZEM); - if (TESTBIT(selection, kNoITSROFrameBorder) && TESTBIT(selection, kNoTimeFrameBorder)) { - histos.get(HIST("hCounterZEMafterBCcuts"))->Fill(srun, 1); - histos.get(HIST("hLumiZEMafterBCcuts"))->Fill(srun, 1. / csZEM); - } - } - if (TESTBIT(selection, kIsBBZNC)) { - histos.get(HIST("hCounterZNC"))->Fill(srun, 1); - histos.get(HIST("hLumiZNC"))->Fill(srun, 1. / csZNC); - if (TESTBIT(selection, kNoITSROFrameBorder) && TESTBIT(selection, kNoTimeFrameBorder)) { - histos.get(HIST("hCounterZNCafterBCcuts"))->Fill(srun, 1); - histos.get(HIST("hLumiZNCafterBCcuts"))->Fill(srun, 1. / csZNC); - } - } - if (bc.timestamp() < sorTimestamp || bc.timestamp() > eorTimestamp) { histos.get(HIST("hCounterInvalidBCTimestamp"))->Fill(srun, 1); if (confCheckRunDurationLimits.value) { @@ -506,7 +479,7 @@ struct BcSelectionTask { } // Fill bc selection columns - bcsel(alias, selection, foundFT0, foundFV0, foundFDD, foundZDC); + bcsel(alias, selection, rct, foundFT0, foundFV0, foundFDD, foundZDC); } } PROCESS_SWITCH(BcSelectionTask, processRun3, "Process Run3 event selection", false); @@ -521,15 +494,15 @@ struct EventSelectionTask { Configurable confSigmaBCforHighPtTracks{"confSigmaBCforHighPtTracks", 4, "Custom sigma (in bcs) for collisions with high-pt tracks"}; // configurables for occupancy-based event selection - Configurable confTimeIntervalForOccupancyCalculationMin{"TimeIntervalForOccupancyCalculationMin", -40, "Min time diff window for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable - Configurable confTimeIntervalForOccupancyCalculationMax{"TimeIntervalForOccupancyCalculationMax", 100, "Max time diff window for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable - Configurable confTimeRangeVetoOnCollStandard{"TimeRangeVetoOnCollStandard", 10.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; // o2-linter: disable=name/configurable - Configurable confTimeRangeVetoOnCollNarrow{"TimeRangeVetoOnCollNarrow", 2.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; // o2-linter: disable=name/configurable - Configurable confFT0CamplCutVetoOnCollInTimeRange{"FT0CamplPerCollCutVetoOnCollInTimeRange", 8000, "Max allowed FT0C amplitude for each nearby collision in +/- time range"}; // o2-linter: disable=name/configurable - Configurable confEpsilonDistanceForVzDependentVetoTPC{"EpsilonDistanceForVzDependentVetoTPC", 2.5, "Epsilon for vZ-dependent veto on drifting TPC tracks from nearby collisions, cm"}; // o2-linter: disable=name/configurable - Configurable confFT0CamplCutVetoOnCollInROF{"FT0CamplPerCollCutVetoOnCollInROF", 5000, "Max allowed FT0C amplitude for each nearby collision inside this ITS ROF"}; // o2-linter: disable=name/configurable - Configurable confEpsilonVzDiffVetoInROF{"EpsilonVzDiffVetoInROF", 0.3, "Minumum distance to nearby collisions along z inside this ITS ROF, cm"}; // o2-linter: disable=name/configurable - Configurable confUseWeightsForOccupancyVariable{"UseWeightsForOccupancyEstimator", 1, "Use or not the delta-time weights for the occupancy estimator"}; // o2-linter: disable=name/configurable + Configurable confTimeIntervalForOccupancyCalculationMin{"TimeIntervalForOccupancyCalculationMin", -40, "Min time diff window for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confTimeIntervalForOccupancyCalculationMax{"TimeIntervalForOccupancyCalculationMax", 100, "Max time diff window for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confTimeRangeVetoOnCollStandard{"TimeRangeVetoOnCollStandard", 10.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confTimeRangeVetoOnCollNarrow{"TimeRangeVetoOnCollNarrow", 2.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFT0CamplCutVetoOnCollInTimeRange{"FT0CamplPerCollCutVetoOnCollInTimeRange", 8000, "Max allowed FT0C amplitude for each nearby collision in +/- time range"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFT0CamplCutVetoOnCollInROF{"FT0CamplPerCollCutVetoOnCollInROF", 5000, "Max allowed FT0C amplitude for each nearby collision inside this ITS ROF"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confEpsilonVzDiffVetoInROF{"EpsilonVzDiffVetoInROF", 0.3, "Minumum distance to nearby collisions along z inside this ITS ROF, cm"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confUseWeightsForOccupancyVariable{"UseWeightsForOccupancyEstimator", 1, "Use or not the delta-time weights for the occupancy estimator"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confNumberOfOrbitsPerTF{"NumberOfOrbitsPerTF", -1, "Number of orbits per Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) Partition tracklets = (aod::track::trackType == static_cast(o2::aod::track::TrackTypeEnum::Run2Tracklet)); @@ -542,10 +515,11 @@ struct EventSelectionTask { int lastRun = -1; // last run number (needed to access ccdb only if run!=lastRun) std::bitset bcPatternB; // bc pattern of colliding bunches - int64_t bcSOR = -1; // global bc of the start of the first orbit - int64_t nBCsPerTF = -1; // duration of TF in bcs, should be 128*3564 or 32*3564 - int rofOffset = -1; // ITS ROF offset, in bc - int rofLength = -1; // ITS ROF length, in bc + int64_t bcSOR = -1; // global bc of the start of the first orbit + int64_t nBCsPerTF = -1; // duration of TF in bcs, should be 128*3564 or 32*3564 + int rofOffset = -1; // ITS ROF offset, in bc + int rofLength = -1; // ITS ROF length, in bc + std::string strLPMProductionTag = ""; // MC production tag to be retrieved from AO2D metadata int32_t findClosest(int64_t globalBC, std::map& bcs) { @@ -602,14 +576,6 @@ struct EventSelectionTask { void init(InitContext&) { if (metadataInfo.isFullyDefined()) { // Check if the metadata is initialized (only if not forced from the workflow configuration) - if (!doprocessRun2 && !doprocessRun3) { - LOG(info) << "Autosetting the processing mode (Run2 or Run3) based on metadata"; - if (metadataInfo.isRun3()) { - doprocessRun3.value = true; - } else { - doprocessRun2.value = false; - } - } if (isMC == -1) { LOG(info) << "Autosetting the MC mode based on metadata"; if (metadataInfo.isMC()) { @@ -619,6 +585,7 @@ struct EventSelectionTask { } } } + strLPMProductionTag = metadataInfo.get("LPMProductionTag"); // to extract info from ccdb by the tag ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); @@ -675,7 +642,10 @@ struct EventSelectionTask { int spdClusters = bc.spdClustersL0() + bc.spdClustersL1(); selection |= (spdClusters < par->fSPDClsVsTklA + nTkl * par->fSPDClsVsTklB) ? BIT(kNoSPDClsVsTklBG) : 0; - selection |= !(nTkl < 6 && multV0C012 > par->fV0C012vsTklA + nTkl * par->fV0C012vsTklB) ? BIT(kNoV0C012vsTklBG) : 0; + selection |= !(nTkl < 6 && multV0C012 > par->fV0C012vsTklA + nTkl * par->fV0C012vsTklB) ? BIT(kNoV0C012vsTklBG) : 0; // o2-linter: disable=magic-number (nTkl dependent parameterization) + + // copy rct flags from bcsel table + uint32_t rct = bc.rct_raw(); // apply int7-like selections bool sel7 = 1; @@ -692,7 +662,7 @@ struct EventSelectionTask { sel1 = sel1 && bc.selection_bit(kNoTPCHVdip); // INT1 (SPDFO>0 | V0A | V0C) minimum bias trigger logic used in pp2010 and pp2011 - bool isINT1period = bc.runNumber() <= 136377 || (bc.runNumber() >= 144871 && bc.runNumber() <= 159582); + bool isINT1period = bc.runNumber() <= 136377 || (bc.runNumber() >= 144871 && bc.runNumber() <= 159582); // o2-linter: disable=magic-number (magic run numbers) // fill counters if (isMC == 1 || (!isINT1period && bc.alias_bit(kINT7)) || (isINT1period && bc.alias_bit(kINT1))) { @@ -702,7 +672,7 @@ struct EventSelectionTask { } } - evsel(alias, selection, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, 0, 0, 0); + evsel(alias, selection, rct, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, 0, 0); } PROCESS_SWITCH(EventSelectionTask, processRun2, "Process Run2 event selection", true); @@ -711,13 +681,14 @@ struct EventSelectionTask { { int run = bcs.iteratorAt(0).runNumber(); // extract bc pattern from CCDB for data or anchored MC only - if (run != lastRun && run >= 500000) { + int run3min = 500000; + if (run != lastRun && run >= run3min) { lastRun = run; - auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run); + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run, strLPMProductionTag); // first bc of the first orbit bcSOR = runInfo.orbitSOR * nBCsPerOrbit; // duration of TF in bcs - nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit; + nBCsPerTF = confNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * nBCsPerOrbit : confNumberOfOrbitsPerTF * nBCsPerOrbit; // colliding bc pattern int64_t ts = bcs.iteratorAt(0).timestamp(); auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", ts); @@ -737,7 +708,7 @@ struct EventSelectionTask { for (const auto& bc : bcs) { int64_t globalBC = bc.globalBC(); // skip non-colliding bcs for data and anchored runs - if (run >= 500000 && bcPatternB[globalBC % nBCsPerOrbit] == 0) { + if (run >= run3min && bcPatternB[globalBC % nBCsPerOrbit] == 0) { continue; } if (bc.selection_bit(kIsTriggerTVX)) { @@ -756,8 +727,8 @@ struct EventSelectionTask { int32_t foundFV0 = bc.foundFV0Id(); int32_t foundFDD = bc.foundFDDId(); int32_t foundZDC = bc.foundZDCId(); - int bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; - evsel(bc.alias_raw(), bc.selection_raw(), kFALSE, kFALSE, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, bcInTF, -1, -1); + uint32_t rct = 0; + evsel(bc.alias_raw(), bc.selection_raw(), rct, kFALSE, kFALSE, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, -1, -1); } return; } @@ -806,7 +777,7 @@ struct EventSelectionTask { float sumTime = 0, sumW = 0, sumHighPtTime = 0, sumHighPtW = 0; for (const auto& track : colPvTracks) { float trackTime = track.trackTime(); - if (track.itsNCls() >= 5) + if (track.itsNCls() >= 5) // o2-linter: disable=magic-number (indeed counting layers 5 6 7) vTracksITS567perColl[colIndex]++; if (track.hasTRD()) vIsVertexTRDmatched[colIndex] = 1; @@ -1016,10 +987,9 @@ struct EventSelectionTask { std::vector vNumTracksITS567inFullTimeWin(cols.size(), 0); // counter of tracks in full time window for occupancy studies (excluding given event) std::vector vSumAmpFT0CinFullTimeWin(cols.size(), 0); // sum of FT0C of tracks in full time window for occupancy studies (excluding given event) - std::vector vNoCollInTimeRangeStrict(cols.size(), 0); // no collisions in a specified time range - std::vector vNoCollInTimeRangeNarrow(cols.size(), 0); // no collisions in a specified time range (narrow) - std::vector vNoHighMultCollInTimeRange(cols.size(), 0); // no high-mult collisions in a specified time range - std::vector vNoCollInVzDependentTimeRange(cols.size(), 0); // no collisions in a vZ-dependent time range + std::vector vNoCollInTimeRangeStrict(cols.size(), 0); // no collisions in a specified time range + std::vector vNoCollInTimeRangeNarrow(cols.size(), 0); // no collisions in a specified time range (narrow) + std::vector vNoHighMultCollInTimeRange(cols.size(), 0); // no high-mult collisions in a specified time range std::vector vNoCollInSameRofStrict(cols.size(), 0); // to veto events with other collisions in the same ITS ROF std::vector vNoCollInSameRofStandard(cols.size(), 0); // to veto events with other collisions in the same ITS ROF, with per-collision multiplicity above threshold @@ -1072,7 +1042,6 @@ struct EventSelectionTask { int nITS567tracksForVetoNarrow = 0; // to veto events with nearby collisions (narrower range) int nITS567tracksForVetoStrict = 0; // to veto events with nearby collisions int nCollsWithFT0CAboveVetoStandard = 0; // to veto events with per-collision multiplicity above threshold - int nITS567tracksForVetoVzDependent = 0; // to veto events with nearby collisions, vZ-dependent time cut for (uint32_t iCol = 0; iCol < vAssocToThisCol.size(); iCol++) { int thisColIndex = vAssocToThisCol[iCol]; float dt = vCollsTimeDeltaWrtGivenColl[iCol] / 1e3; // ns -> us @@ -1080,16 +1049,16 @@ struct EventSelectionTask { if (confUseWeightsForOccupancyVariable) { // weighted occupancy wOccup = 0; - if (dt >= -40 && dt < -5) // collisions in the past - wOccup = 1. / 1225 * (dt + 40) * (dt + 40); - else if (dt >= -5 && dt < 15) // collisions near a given one + if (dt >= -40 && dt < -5) // collisions in the past // o2-linter: disable=magic-number (to be checked by Igor) + wOccup = 1. / 1225 * (dt + 40) * (dt + 40); // o2-linter: disable=magic-number (to be checked by Igor) + else if (dt >= -5 && dt < 15) // collisions near a given one // o2-linter: disable=magic-number (to be checked by Igor) wOccup = 1; // else if (dt >= 15 && dt < 100) // collisions from the future // wOccup = -1. / 85 * dt + 20. / 17; - else if (dt >= 15 && dt < 40) // collisions from the future - wOccup = -0.4 / 25 * dt + 1.24; - else if (dt >= 40 && dt < 100) // collisions from the distant future - wOccup = -0.4 / 60 * dt + 0.6 + 0.8 / 3; + else if (dt >= 15 && dt < 40) // collisions from the future // o2-linter: disable=magic-number (to be checked by Igor) + wOccup = -0.4 / 25 * dt + 1.24; // o2-linter: disable=magic-number (to be checked by Igor) + else if (dt >= 40 && dt < 100) // collisions from the distant future // o2-linter: disable=magic-number (to be checked by Igor) + wOccup = -0.4 / 60 * dt + 0.6 + 0.8 / 3; // o2-linter: disable=magic-number (to be checked by Igor) } nITS567tracksInFullTimeWindow += wOccup * vTracksITS567perColl[thisColIndex]; sumAmpFT0CInFullTimeWindow += wOccup * vAmpFT0CperColl[thisColIndex]; @@ -1102,31 +1071,16 @@ struct EventSelectionTask { // standard cut on other collisions vs delta-times const float driftV = 2.5; // drift velocity in cm/us, TPC drift_length / drift_time = 250 cm / 100 us - if (std::fabs(dt) < 2.0) { // us, complete veto on other collisions + if (std::fabs(dt) < 2.0) { // us, complete veto on other collisions // o2-linter: disable=magic-number (to be checked by Igor) nCollsWithFT0CAboveVetoStandard++; - } else if (dt > -4.0 && dt <= -2.0) { // us, strict veto to suppress fake ITS-TPC matches more + } else if (dt > -4.0 && dt <= -2.0) { // us, strict veto to suppress fake ITS-TPC matches more // o2-linter: disable=magic-number (to be checked by Igor) if (vAmpFT0CperColl[thisColIndex] > confFT0CamplCutVetoOnCollInTimeRange / 5) nCollsWithFT0CAboveVetoStandard++; - } else if (std::fabs(dt) < 8 + std::fabs(vZ) / driftV) { // loose veto, 8 us corresponds to maximum possible |vZ|, which is ~20 cm + } else if (std::fabs(dt) < 8 + std::fabs(vZ) / driftV) { // loose veto, 8 us corresponds to maximum possible |vZ|, which is ~20 cm // o2-linter: disable=magic-number (to be checked by Igor) // counting number of other collisions with multiplicity above threshold if (vAmpFT0CperColl[thisColIndex] > confFT0CamplCutVetoOnCollInTimeRange) nCollsWithFT0CAboveVetoStandard++; } - - // vZ-dependent time cut to avoid collinear tracks from other collisions (experimental) - if (std::fabs(dt) < 8 + std::fabs(vZ) / driftV) { - if (dt < 0) { - // check distance between given vZ and (moving in two directions) vZ of drifting tracks from past collisions - if ((std::fabs(vCollVz[thisColIndex] - std::fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC) || - (std::fabs(vCollVz[thisColIndex] + std::fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC)) - nITS567tracksForVetoVzDependent += vTracksITS567perColl[thisColIndex]; - } else { // dt>0 - // check distance between drifted vZ of given collision (in two directions) and vZ of future collisions - if ((std::fabs(vZ - dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC) || - (std::fabs(vZ + dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC)) - nITS567tracksForVetoVzDependent += vTracksITS567perColl[thisColIndex]; - } - } } vNumTracksITS567inFullTimeWin[colIndex] = nITS567tracksInFullTimeWindow; // occupancy by a sum of number of ITS tracks (without a current collision) vSumAmpFT0CinFullTimeWin[colIndex] = sumAmpFT0CInFullTimeWindow; // occupancy by a sum of FT0C amplitudes (without a current collision) @@ -1134,7 +1088,6 @@ struct EventSelectionTask { vNoCollInTimeRangeNarrow[colIndex] = (nITS567tracksForVetoNarrow == 0); vNoCollInTimeRangeStrict[colIndex] = (nITS567tracksForVetoStrict == 0); vNoHighMultCollInTimeRange[colIndex] = (nCollsWithFT0CAboveVetoStandard == 0); - vNoCollInVzDependentTimeRange[colIndex] = (nITS567tracksForVetoVzDependent == 0); // experimental } for (const auto& col : cols) { @@ -1164,13 +1117,15 @@ struct EventSelectionTask { selection |= vNoCollInTimeRangeNarrow[colIndex] ? BIT(kNoCollInTimeRangeNarrow) : 0; selection |= vNoCollInTimeRangeStrict[colIndex] ? BIT(kNoCollInTimeRangeStrict) : 0; selection |= vNoHighMultCollInTimeRange[colIndex] ? BIT(kNoCollInTimeRangeStandard) : 0; - selection |= vNoCollInVzDependentTimeRange[colIndex] ? BIT(kNoCollInTimeRangeVzDependent) : 0; // selection bits based on ITS in-ROF occupancy selection |= vNoCollInSameRofStrict[colIndex] ? BIT(kNoCollInRofStrict) : 0; selection |= (vNoCollInSameRofStandard[colIndex] && vNoCollInSameRofWithCloseVz[colIndex]) ? BIT(kNoCollInRofStandard) : 0; selection |= vNoHighMultCollInPrevRof[colIndex] ? BIT(kNoHighMultCollInPrevRof) : 0; + // copy rct flags from bcsel table + uint32_t rct = bc.rct_raw(); + // apply int7-like selections bool sel7 = 0; @@ -1188,9 +1143,7 @@ struct EventSelectionTask { histos.get(HIST("hColCounterAcc"))->Fill(Form("%d", bc.runNumber()), 1); } - int bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; - - evsel(alias, selection, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, bcInTF, + evsel(alias, selection, rct, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); } } @@ -1198,6 +1151,315 @@ struct EventSelectionTask { PROCESS_SWITCH(EventSelectionTask, processRun3, "Process Run3 event selection", false); }; +struct LumiTask { + Service ccdb; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + int lastRun = -1; // last run number (needed to access ccdb only if run!=lastRun) + float csTVX = -1; // dummy -1 for the visible TVX cross section (in ub) used in lumi accounting + float csTCE = -1; // dummy -1 for the visible TCE cross section (in ub) used in lumi accounting + float csZEM = -1; // dummy -1 for the visible ZEM cross section (in ub) used in lumi accounting + float csZNC = -1; // dummy -1 for the visible ZNC cross section (in ub) used in lumi accounting + + std::vector mOrbits; + std::vector mPileupCorrectionTVX; + std::vector mPileupCorrectionTCE; + std::vector mPileupCorrectionZEM; + std::vector mPileupCorrectionZNC; + + int64_t minOrbitInRange = std::numeric_limits::max(); + int64_t maxOrbitInRange = 0; + uint32_t currentOrbitIndex = 0; + std::bitset bcPatternB; // bc pattern of colliding bunches + std::vector mRCTFlagsCheckers; + + void init(InitContext&) + { + histos.add("hCounterTVX", "", kTH1D, {{1, 0., 1.}}); + histos.add("hCounterTCE", "", kTH1D, {{1, 0., 1.}}); + histos.add("hCounterZEM", "", kTH1D, {{1, 0., 1.}}); + histos.add("hCounterZNC", "", kTH1D, {{1, 0., 1.}}); + histos.add("hCounterTVXafterBCcuts", "", kTH1D, {{1, 0., 1.}}); + histos.add("hCounterTCEafterBCcuts", "", kTH1D, {{1, 0., 1.}}); + histos.add("hCounterZEMafterBCcuts", "", kTH1D, {{1, 0., 1.}}); + histos.add("hCounterZNCafterBCcuts", "", kTH1D, {{1, 0., 1.}}); + histos.add("hLumiTVX", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); + histos.add("hLumiTCE", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); + histos.add("hLumiZEM", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); + histos.add("hLumiZNC", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); + histos.add("hLumiTVXafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); + histos.add("hLumiTCEafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); + histos.add("hLumiZEMafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); + histos.add("hLumiZNCafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}}); + + const int nLists = 6; + TString rctListNames[] = {"CBT", "CBT_hadronPID", "CBT_electronPID", "CBT_calo", "CBT_muon", "CBT_muon_glo"}; + histos.add("hLumiTVXafterBCcutsRCT", ";;Luminosity, 1/#mub", kTH2D, {{1, 0., 1.}, {4 * nLists, -0.5, 4. * nLists - 0.5}}); + histos.add("hLumiTCEafterBCcutsRCT", ";;Luminosity, 1/#mub", kTH2D, {{1, 0., 1.}, {4 * nLists, -0.5, 4. * nLists - 0.5}}); + histos.add("hLumiZEMafterBCcutsRCT", ";;Luminosity, 1/#mub", kTH2D, {{1, 0., 1.}, {4 * nLists, -0.5, 4. * nLists - 0.5}}); + histos.add("hLumiZNCafterBCcutsRCT", ";;Luminosity, 1/#mub", kTH2D, {{1, 0., 1.}, {4 * nLists, -0.5, 4. * nLists - 0.5}}); + + for (int i = 0; i < nLists; i++) { + const auto& rctListName = rctListNames[i]; + mRCTFlagsCheckers.emplace_back(rctListName.Data(), false, false); // disable zdc check, disable lim. acc. check + mRCTFlagsCheckers.emplace_back(rctListName.Data(), false, true); // disable zdc check, enable lim. acc. check + mRCTFlagsCheckers.emplace_back(rctListName.Data(), true, false); // enable zdc check, disable lim. acc. check + mRCTFlagsCheckers.emplace_back(rctListName.Data(), true, true); // enable zdc check, enable lim. acc. check + histos.get(HIST("hLumiTVXafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 1, rctListName.Data()); + histos.get(HIST("hLumiTCEafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 1, rctListName.Data()); + histos.get(HIST("hLumiZEMafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 1, rctListName.Data()); + histos.get(HIST("hLumiZNCafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 1, rctListName.Data()); + histos.get(HIST("hLumiTVXafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 2, (rctListName + "_fullacc").Data()); + histos.get(HIST("hLumiTCEafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 2, (rctListName + "_fullacc").Data()); + histos.get(HIST("hLumiZEMafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 2, (rctListName + "_fullacc").Data()); + histos.get(HIST("hLumiZNCafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 2, (rctListName + "_fullacc").Data()); + histos.get(HIST("hLumiTVXafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 3, (rctListName + "_zdc").Data()); + histos.get(HIST("hLumiTCEafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 3, (rctListName + "_zdc").Data()); + histos.get(HIST("hLumiZEMafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 3, (rctListName + "_zdc").Data()); + histos.get(HIST("hLumiZNCafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 3, (rctListName + "_zdc").Data()); + histos.get(HIST("hLumiTVXafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 4, (rctListName + "_zdc" + "_fullacc").Data()); + histos.get(HIST("hLumiTCEafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 4, (rctListName + "_zdc" + "_fullacc").Data()); + histos.get(HIST("hLumiZEMafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 4, (rctListName + "_zdc" + "_fullacc").Data()); + histos.get(HIST("hLumiZNCafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 4, (rctListName + "_zdc" + "_fullacc").Data()); + } + } + + void processRun2(aod::BCs const&) + { + LOGP(debug, "Dummy process function for Run 2"); + } + + PROCESS_SWITCH(LumiTask, processRun2, "Process Run2 lumi task", true); + + void processRun3(BCsWithBcSelsRun3 const& bcs, aod::FT0s const&) + { + if (bcs.size() == 0) + return; + int run = bcs.iteratorAt(0).runNumber(); + if (run < 500000) // o2-linter: disable=magic-number (skip for unanchored MCs) + return; + if (run != lastRun && run >= 520259) { // o2-linter: disable=magic-number (scalers available for runs above 520120) + lastRun = run; + int64_t ts = bcs.iteratorAt(0).timestamp(); + + // getting GRP LHCIF object to extract colliding system, energy and colliding bc pattern + auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", ts); + int beamZ1 = grplhcif->getBeamZ(constants::lhc::BeamA); + int beamZ2 = grplhcif->getBeamZ(constants::lhc::BeamC); + float sqrts = grplhcif->getSqrtS(); + int nCollidingBCs = grplhcif->getBunchFilling().getNBunches(); + bcPatternB = grplhcif->getBunchFilling().getBCPattern(); + + // visible cross sections in ub. Using dummy -1 if lumi estimator is not reliable for this colliding system + csTVX = -1; + csTCE = -1; + csZEM = -1; + csZNC = -1; + // Temporary workaround to get visible cross section. TODO: store run-by-run visible cross sections in CCDB + if (beamZ1 == 1 && beamZ2 == 1) { + if (std::fabs(sqrts - 900.) < 100.) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTVX = 0.0357e6; // ub + } else if (std::fabs(sqrts - 5360.) < 100.) { // pp-ref // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTVX = 0.0503e6; // ub + } else if (std::fabs(sqrts - 13600.) < 300.) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTVX = 0.0594e6; // ub + } else { + LOGP(warn, "Cross section for pp @ {} GeV is not defined", sqrts); + } + } else if (beamZ1 == 82 && beamZ2 == 82) { // o2-linter: disable=magic-number (PbPb colliding system) + // see AN: https://alice-notes.web.cern.ch/node/1515 + if (std::fabs(sqrts - 5360) < 20) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csZNC = 214.5e6; // ub + csZEM = 415.2e6; // ub + csTCE = 10.36e6; // ub + if (run > 543437 && run < 543514) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTCE = 8.3e6; // ub + } else if (run >= 543514 && run < 545367) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTCE = 4.10e6; // ub + } else if (run >= 559544) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTCE = 3.86e6; // ub + } + } else { + LOGP(warn, "Cross section for PbPb @ {} GeV is not defined", sqrts); + } + } else { + LOGP(warn, "Cross section for z={} + z={} @ {} GeV is not defined", beamZ1, beamZ2, sqrts); + } + // getting CTP config to extract lumi class indices (used for rate fetching and pileup correction) + std::map metadata; + metadata["runNumber"] = std::to_string(run); + auto config = ccdb->getSpecific("CTP/Config/Config", ts, metadata); + auto classes = config->getCTPClasses(); + TString lumiClassNameZNC = "C1ZNC-B-NOPF-CRU"; + TString lumiClassNameTCE = "CMTVXTCE-B-NOPF-CRU"; + TString lumiClassNameTVX1 = "MINBIAS_TVX"; // run >= 534467 + TString lumiClassNameTVX2 = "MINBIAS_TVX_NOMASK"; // run >= 534468 + TString lumiClassNameTVX3 = "CMTVX-NONE-NOPF-CRU"; // run >= 534996 + TString lumiClassNameTVX4 = "CMTVX-B-NOPF-CRU"; // run >= 543437 + + // find class indices + int classIdZNC = -1; + int classIdTCE = -1; + int classIdTVX = -1; + for (unsigned int i = 0; i < classes.size(); i++) { + TString clname = classes[i].name; + clname.ToUpper(); + // using position (i) in the vector of classes instead of classes[i].getIndex() + // due to bug or inconsistencies in scaler record and class indices + if (clname == lumiClassNameZNC) + classIdZNC = i; + if (clname == lumiClassNameTCE) + classIdTCE = i; + if (clname == lumiClassNameTVX4 || clname == lumiClassNameTVX3 || clname == lumiClassNameTVX2 || clname == lumiClassNameTVX1) + classIdTVX = i; + } + + // extract trigger counts from CTP scalers + auto scalers = ccdb->getSpecific("CTP/Calib/Scalers", ts, metadata); + scalers->convertRawToO2(); + std::vector mCounterTVX; + std::vector mCounterTCE; + std::vector mCounterZNC; + std::vector mCounterZEM; + mOrbits.clear(); + for (const auto& record : scalers->getScalerRecordO2()) { + mOrbits.push_back(record.intRecord.orbit); + mCounterTVX.push_back(classIdTVX >= 0 ? record.scalers[classIdTVX].lmBefore : 0); + mCounterTCE.push_back(classIdTCE >= 0 ? record.scalers[classIdTCE].lmBefore : 0); + if (run >= 543437 && run < 544448 && record.scalersInps.size() >= 26) { // o2-linter: disable=magic-number (ZNC class not defined for this run range) + mCounterZNC.push_back(record.scalersInps[25]); // see ZNC=1ZNC input index in https://indico.cern.ch/event/1153630/contributions/4844362/ + } else { + mCounterZNC.push_back(classIdZNC >= 0 ? record.scalers[classIdZNC].l1Before : 0); + } + // ZEM class not defined, using inputs instead + uint32_t indexZEM = 24; // see ZEM=1ZED input index in https://indico.cern.ch/event/1153630/contributions/4844362/ + mCounterZEM.push_back(record.scalersInps.size() >= indexZEM + 1 ? record.scalersInps[indexZEM] : 0); + } + + // calculate pileup corrections + mPileupCorrectionTVX.clear(); + mPileupCorrectionTCE.clear(); + mPileupCorrectionZEM.clear(); + mPileupCorrectionZNC.clear(); + for (uint32_t i = 0; i < mOrbits.size() - 1; i++) { + int64_t nOrbits = mOrbits[i + 1] - mOrbits[i]; + if (nOrbits <= 0 || nCollidingBCs == 0) + continue; + double perBcRateTVX = static_cast(mCounterTVX[i + 1] - mCounterTVX[i]) / nOrbits / nCollidingBCs; + double perBcRateTCE = static_cast(mCounterTCE[i + 1] - mCounterTCE[i]) / nOrbits / nCollidingBCs; + double perBcRateZNC = static_cast(mCounterZNC[i + 1] - mCounterZNC[i]) / nOrbits / nCollidingBCs; + double perBcRateZEM = static_cast(mCounterZEM[i + 1] - mCounterZEM[i]) / nOrbits / nCollidingBCs; + double muTVX = (perBcRateTVX < 1 && perBcRateTVX > 1e-10) ? -std::log(1 - perBcRateTVX) : 0; + double muTCE = (perBcRateTCE < 1 && perBcRateTCE > 1e-10) ? -std::log(1 - perBcRateTCE) : 0; + double muZNC = (perBcRateZNC < 1 && perBcRateZNC > 1e-10) ? -std::log(1 - perBcRateZNC) : 0; + double muZEM = (perBcRateZEM < 1 && perBcRateZEM > 1e-10) ? -std::log(1 - perBcRateZEM) : 0; + LOGP(debug, "orbit={} muTVX={} muTCE={} muZNC={} muZEM={}", mOrbits[i], muTVX, muTCE, muZNC, muZEM); + mPileupCorrectionTVX.push_back(muTVX > 1e-10 ? muTVX / (1 - std::exp(-muTVX)) : 1); + mPileupCorrectionTCE.push_back(muTCE > 1e-10 ? muTCE / (1 - std::exp(-muTCE)) : 1); + mPileupCorrectionZNC.push_back(muZNC > 1e-10 ? muZNC / (1 - std::exp(-muZNC)) : 1); + mPileupCorrectionZEM.push_back(muZEM > 1e-10 ? muZEM / (1 - std::exp(-muZEM)) : 1); + } + // filling last orbit range using previous orbit range + mPileupCorrectionTVX.push_back(mPileupCorrectionTVX.back()); + mPileupCorrectionTCE.push_back(mPileupCorrectionTCE.back()); + mPileupCorrectionZNC.push_back(mPileupCorrectionZNC.back()); + mPileupCorrectionZEM.push_back(mPileupCorrectionZEM.back()); + } // access ccdb once per run + + const char* srun = Form("%d", run); + + for (const auto& bc : bcs) { + auto& selection = bc.selection_raw(); + if (bcPatternB[bc.globalBC() % nBCsPerOrbit] == 0) // skip non-colliding bcs + continue; + + bool noBorder = TESTBIT(selection, kNoTimeFrameBorder) && TESTBIT(selection, kNoITSROFrameBorder); + bool isTriggerTVX = TESTBIT(selection, kIsTriggerTVX); + bool isTriggerTCE = bc.has_ft0() ? (TESTBIT(selection, kIsTriggerTVX) && TESTBIT(bc.ft0().triggerMask(), o2::ft0::Triggers::bitCen)) : 0; + bool isTriggerZNA = TESTBIT(selection, kIsBBZNA); + bool isTriggerZNC = TESTBIT(selection, kIsBBZNC); + bool isTriggerZEM = isTriggerZNA || isTriggerZNC; + + // determine pileup correction + int64_t orbit = bc.globalBC() / nBCsPerOrbit; + if ((orbit < minOrbitInRange || orbit > maxOrbitInRange) && mOrbits.size() > 1) { + auto it = std::lower_bound(mOrbits.begin(), mOrbits.end(), orbit); + uint32_t nextOrbitIndex = std::distance(mOrbits.begin(), it); + if (nextOrbitIndex == 0) // if orbit is below stored scaler orbits + nextOrbitIndex = 1; + else if (nextOrbitIndex == mOrbits.size()) // if orbit is above stored scaler orbits + nextOrbitIndex = mOrbits.size() - 1; + currentOrbitIndex = nextOrbitIndex - 1; + minOrbitInRange = mOrbits[currentOrbitIndex]; + maxOrbitInRange = mOrbits[nextOrbitIndex]; + } + double pileupCorrectionTVX = currentOrbitIndex < mPileupCorrectionTVX.size() ? mPileupCorrectionTVX[currentOrbitIndex] : 1.; + double pileupCorrectionTCE = currentOrbitIndex < mPileupCorrectionTCE.size() ? mPileupCorrectionTCE[currentOrbitIndex] : 1.; + double pileupCorrectionZNC = currentOrbitIndex < mPileupCorrectionZNC.size() ? mPileupCorrectionZNC[currentOrbitIndex] : 1.; + double pileupCorrectionZEM = currentOrbitIndex < mPileupCorrectionZEM.size() ? mPileupCorrectionZEM[currentOrbitIndex] : 1.; + + double lumiTVX = 1. / csTVX * pileupCorrectionTVX; + double lumiTCE = 1. / csTCE * pileupCorrectionTCE; + double lumiZNC = 1. / csZNC * pileupCorrectionZNC; + double lumiZEM = 1. / csZEM * pileupCorrectionZEM; + + if (isTriggerTVX) { + histos.get(HIST("hCounterTVX"))->Fill(srun, 1); + histos.get(HIST("hLumiTVX"))->Fill(srun, lumiTVX); + if (noBorder) { + histos.get(HIST("hCounterTVXafterBCcuts"))->Fill(srun, 1); + histos.get(HIST("hLumiTVXafterBCcuts"))->Fill(srun, lumiTVX); + for (size_t i = 0; i < mRCTFlagsCheckers.size(); i++) { + if (mRCTFlagsCheckers[i](bc)) + histos.get(HIST("hLumiTVXafterBCcutsRCT"))->Fill(srun, i, lumiTVX); + } + } + } + + if (isTriggerTCE) { + histos.get(HIST("hCounterTCE"))->Fill(srun, 1); + histos.get(HIST("hLumiTCE"))->Fill(srun, lumiTCE); + if (noBorder) { + histos.get(HIST("hCounterTCEafterBCcuts"))->Fill(srun, 1); + histos.get(HIST("hLumiTCEafterBCcuts"))->Fill(srun, lumiTCE); + for (size_t i = 0; i < mRCTFlagsCheckers.size(); i++) { + if (mRCTFlagsCheckers[i](bc)) + histos.get(HIST("hLumiTCEafterBCcutsRCT"))->Fill(srun, i, lumiTCE); + } + } + } + + if (isTriggerZEM) { + histos.get(HIST("hCounterZEM"))->Fill(srun, 1); + histos.get(HIST("hLumiZEM"))->Fill(srun, lumiZEM); + if (noBorder) { + histos.get(HIST("hCounterZEMafterBCcuts"))->Fill(srun, 1); + histos.get(HIST("hLumiZEMafterBCcuts"))->Fill(srun, lumiZEM); + for (size_t i = 0; i < mRCTFlagsCheckers.size(); i++) { + if (mRCTFlagsCheckers[i](bc)) + histos.get(HIST("hLumiZEMafterBCcutsRCT"))->Fill(srun, i, lumiZEM); + } + } + } + + if (isTriggerZNC) { + histos.get(HIST("hCounterZNC"))->Fill(srun, 1); + histos.get(HIST("hLumiZNC"))->Fill(srun, lumiZNC); + if (noBorder) { + histos.get(HIST("hCounterZNCafterBCcuts"))->Fill(srun, 1); + histos.get(HIST("hLumiZNCafterBCcuts"))->Fill(srun, lumiZNC); + for (size_t i = 0; i < mRCTFlagsCheckers.size(); i++) { + if (mRCTFlagsCheckers[i](bc)) + histos.get(HIST("hLumiZNCafterBCcutsRCT"))->Fill(srun, i, lumiZNC); + } + } + } + + } // bcs + } // process + PROCESS_SWITCH(LumiTask, processRun3, "Process Run3 lumi task", false); +}; + WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { // Parse the metadata @@ -1205,5 +1467,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) return WorkflowSpec{ adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; } diff --git a/Common/TableProducer/eventSelectionService.cxx b/Common/TableProducer/eventSelectionService.cxx new file mode 100644 index 00000000000..fd713773c86 --- /dev/null +++ b/Common/TableProducer/eventSelectionService.cxx @@ -0,0 +1,205 @@ +// 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. + +/// \file eventSelectionTester.cxx +/// \brief unified, self-configuring event selection task +/// \author ALICE + +//=============================================================== +// +// Unified, self-configuring event selection task +// +//=============================================================== + +#include "MetadataHelper.h" + +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Tools/EventSelectionTools.h" +#include "Common/Tools/timestampModule.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "CommonConstants/GeomConstants.h" +#include "CommonUtils/NameConf.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/DCA.h" + +using namespace o2; +using namespace o2::framework; + +o2::common::core::MetadataHelper metadataInfo; // Metadata helper + +using BCsWithRun2InfosAndMatches = soa::Join; +using BCsWithRun3Matchings = soa::Join; +using FullTracks = soa::Join; +using FullTracksIU = soa::Join; + +struct eventselectionRun2 { + o2::common::timestamp::timestampConfigurables timestampConfigurables; + o2::common::timestamp::TimestampModule timestampMod; + + o2::common::eventselection::bcselConfigurables bcselOpts; + o2::common::eventselection::BcSelectionModule bcselmodule; + + o2::common::eventselection::evselConfigurables evselOpts; + o2::common::eventselection::EventSelectionModule evselmodule; + + Produces timestampTable; /// Table with SOR timestamps produced by the task + Produces bcsel; + Produces evsel; + + // for slicing + SliceCache cache; + + // CCDB boilerplate declarations + o2::framework::Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Service ccdb; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // buffering intermediate results for passing + std::vector timestamps; + std::vector bcselsbuffer; + + // auxiliary + Partition tracklets = (aod::track::trackType == static_cast(o2::aod::track::TrackTypeEnum::Run2Tracklet)); + Preslice perCollision = aod::track::collisionId; + + void init(o2::framework::InitContext& context) + { + // CCDB boilerplate init + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setURL(ccdburl.value); + + // task-specific + timestampMod.init(timestampConfigurables, metadataInfo); + bcselmodule.init(context, bcselOpts, histos, metadataInfo); + evselmodule.init(context, evselOpts, histos, metadataInfo); + } + + void process(BCsWithRun2InfosAndMatches const& bcs, + aod::Collisions const& collisions, + aod::Zdcs const&, + aod::FV0As const&, + aod::FV0Cs const&, + aod::FT0s const&, + aod::FDDs const&, + FullTracks const&) + { + timestampMod.process(bcs, ccdb, timestamps, timestampTable); + bcselmodule.processRun2(ccdb, bcs, timestamps, bcselsbuffer, bcsel); + evselmodule.processRun2(ccdb, histos, collisions, tracklets, cache, timestamps, bcselsbuffer, evsel); + } +}; + +struct eventselectionRun3 { + o2::common::timestamp::timestampConfigurables timestampConfigurables; + o2::common::timestamp::TimestampModule timestampMod; + + o2::common::eventselection::bcselConfigurables bcselOpts; + o2::common::eventselection::BcSelectionModule bcselmodule; + + o2::common::eventselection::evselConfigurables evselOpts; + o2::common::eventselection::EventSelectionModule evselmodule; + + o2::common::eventselection::lumiConfigurables lumiOpts; + o2::common::eventselection::LumiModule lumimodule; + + Produces timestampTable; /// Table with SOR timestamps produced by the task + Produces bcsel; + Produces evsel; + + // for slicing + SliceCache cache; + + // CCDB boilerplate declarations + o2::framework::Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Service ccdb; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // the best: have readable cursors + // this: a stopgap solution to avoid spawning yet another device + std::vector timestamps; + std::vector bcselsbuffer; + + // auxiliary + Partition pvTracks = ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); + Preslice perCollisionIU = aod::track::collisionId; + + void init(o2::framework::InitContext& context) + { + // CCDB boilerplate init + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setURL(ccdburl.value); + + // task-specific + timestampMod.init(timestampConfigurables, metadataInfo); + bcselmodule.init(context, bcselOpts, histos, metadataInfo); + evselmodule.init(context, evselOpts, histos, metadataInfo); + lumimodule.init(context, lumiOpts, histos); + } + + void process(aod::Collisions const& collisions, + BCsWithRun3Matchings const& bcs, + aod::Zdcs const&, + aod::FV0As const&, + aod::FT0s const& ft0s, // to resolve iterator + aod::FDDs const&, + FullTracksIU const&) + { + timestampMod.process(bcs, ccdb, timestamps, timestampTable); + bcselmodule.processRun3(ccdb, histos, bcs, timestamps, bcselsbuffer, bcsel); + evselmodule.processRun3(ccdb, histos, bcs, collisions, pvTracks, ft0s, cache, timestamps, bcselsbuffer, evsel); + lumimodule.process(ccdb, histos, bcs, timestamps, bcselsbuffer); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + // Parse the metadata for later too + metadataInfo.initMetadata(cfgc); + + bool isRun3 = true, hasRunInfo = false; + if (cfgc.options().hasOption("aod-metadata-Run") == true) { + hasRunInfo = true; + if (cfgc.options().get("aod-metadata-Run") == "2") { + isRun3 = false; + } + } + + LOGF(info, "Event selection autoconfiguring from metadata. Availability of info for Run 2/3 is %i", hasRunInfo); + if (!hasRunInfo) { + LOGF(info, "Metadata info missing or incomplete. Make sure --aod-file is provided at the end of the last workflow and that the AO2D has metadata stored."); + LOGF(info, "Initializing with Run 3 data as default. Please note you will not be able to change settings manually."); + LOGF(info, "You should instead make sure the metadata is read in correctly."); + return WorkflowSpec{adaptAnalysisTask(cfgc)}; + } else { + LOGF(info, "Metadata successfully read in. Is this Run 3? %i - will self-configure.", isRun3); + if (isRun3) { + return WorkflowSpec{adaptAnalysisTask(cfgc)}; + } else { + return WorkflowSpec{adaptAnalysisTask(cfgc)}; + } + } + throw std::runtime_error("Unsupported run type / problem when configuring event selection!"); +} diff --git a/Common/TableProducer/ft0CorrectedTable.cxx b/Common/TableProducer/ft0CorrectedTable.cxx index bf99be86c45..a8a2787aa5a 100644 --- a/Common/TableProducer/ft0CorrectedTable.cxx +++ b/Common/TableProducer/ft0CorrectedTable.cxx @@ -73,7 +73,8 @@ struct ft0CorrectedTable { histos.add("t0A", "t0A", kTH1D, {{1000, -1, 1, "t0A (ns)"}}); histos.add("t0C", "t0C", kTH1D, {{1000, -1, 1, "t0C (ns)"}}); histos.add("t0AC", "t0AC", kTH1D, {{1000, -1000, 1000, "t0AC (ns)"}}); - histos.add("deltat0AC", "deltat0AC", kTH1D, {{1000, -10, 10, "#Deltat0AC (ns)"}}); + histos.add("deltat0AC", "deltat0AC", kTH1D, {{1000, -1, 1, "#Deltat0AC (ns)"}}); + histos.add("deltat0ACps", "deltat0ACps", kTH1D, {{1000, -1000, 1000, "#Deltat0AC (ps)"}}); if (doprocessWithBypassFT0timeInMC) { histos.add("MC/deltat0A", "t0A", kTH1D, {{1000, -50, 50, "t0A (ps)"}}); histos.add("MC/deltat0C", "t0C", kTH1D, {{1000, -50, 50, "t0C (ps)"}}); @@ -88,7 +89,7 @@ struct ft0CorrectedTable { table.reserve(collisions.size()); float t0A = 1e10f; float t0C = 1e10f; - for (auto& collision : collisions) { + for (const auto& collision : collisions) { t0A = 1e10f; t0C = 1e10f; const float vertexPV = collision.posZ(); @@ -112,8 +113,11 @@ struct ft0CorrectedTable { if (addHistograms) { histos.fill(HIST("t0A"), t0A); histos.fill(HIST("t0C"), t0C); - histos.fill(HIST("t0AC"), (t0A + t0C) * 0.5f); - histos.fill(HIST("deltat0AC"), t0A - t0C); + if (t0A < 1e10f && t0C < 1e10f) { + histos.fill(HIST("t0AC"), (t0A + t0C) * 0.5f); + histos.fill(HIST("deltat0AC"), (t0A - t0C) * 0.5f); + histos.fill(HIST("deltat0ACps"), (t0A - t0C) * 500.f); + } } table(t0A, t0C); } @@ -152,7 +156,7 @@ struct ft0CorrectedTable { float posZMC = 0; bool hasMCcoll = false; - for (auto& collision : collisions) { + for (const auto& collision : collisions) { hasMCcoll = false; eventtimeMC = 1e10f; t0A = 1e10f; diff --git a/Common/TableProducer/fwdtrackToCollisionAssociator.cxx b/Common/TableProducer/fwdtrackToCollisionAssociator.cxx index 0478b69b12d..20d6e4c6a60 100644 --- a/Common/TableProducer/fwdtrackToCollisionAssociator.cxx +++ b/Common/TableProducer/fwdtrackToCollisionAssociator.cxx @@ -64,6 +64,7 @@ struct FwdTrackToCollisionAssociation { collisionAssociator.setUsePvAssociation(false); collisionAssociator.setIncludeUnassigned(includeUnassigned); collisionAssociator.setFillTableOfCollIdsPerTrack(fillTableOfCollIdsPerTrack); + collisionAssociator.setBcWindow(bcWindowForOneSigma); } void processFwdAssocWithTime(Collisions const& collisions, diff --git a/Common/TableProducer/match-mft-mch-data-mc.cxx b/Common/TableProducer/match-mft-mch-data-mc.cxx index 4a03582489d..11d59611772 100644 --- a/Common/TableProducer/match-mft-mch-data-mc.cxx +++ b/Common/TableProducer/match-mft-mch-data-mc.cxx @@ -15,50 +15,21 @@ #include #include "CCDB/BasicCCDBManager.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/CCDB/TriggerAliases.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/MftmchMatchingML.h" +#include "Common/DataModel/MatchMFTFT0.h" #include "Common/DataModel/MatchMFTMuonData.h" -#include "Common/Core/trackUtilities.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" -#include "PWGDQ/Core/VarManager.h" -#include "PWGDQ/Core/HistogramManager.h" -#include "PWGDQ/Core/AnalysisCut.h" -#include "PWGDQ/Core/AnalysisCompositeCut.h" -#include "PWGDQ/Core/HistogramsLibrary.h" -#include "PWGDQ/Core/CutsLibrary.h" -#include "DataFormatsGlobalTracking/RecoContainerCreateTracksVariadic.h" -#include "DetectorsVertexing/VertexTrackMatcher.h" -#include "ReconstructionDataFormats/PrimaryVertex.h" -#include "ReconstructionDataFormats/VtxTrackIndex.h" -#include "ReconstructionDataFormats/VtxTrackRef.h" -#include "DataFormatsITSMFT/ROFRecord.h" -#include "CommonDataFormat/InteractionRecord.h" -#include "DetectorsVertexing/PVertexerParams.h" -#include "MathUtils/Primitive2D.h" #include "DataFormatsGlobalTracking/RecoContainer.h" #include "Common/DataModel/CollisionAssociationTables.h" -#include "Common/DataModel/MatchMFTFT0.h" #include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" #include "Field/MagneticField.h" #include "TGeoGlobalMagField.h" #include "DetectorsBase/Propagator.h" #include "DetectorsBase/GeometryManager.h" -#include "EventFiltering/Zorro.h" -#include "ReconstructionDataFormats/TrackFwd.h" -#include "Math/MatrixFunctions.h" -#include "Math/SMatrix.h" -#include "MFTTracking/Tracker.h" -#include "MCHTracking/TrackParam.h" #include "MCHTracking/TrackExtrap.h" #include "GlobalTracking/MatchGlobalFwd.h" -#include -#include +#include "Math/SMatrix.h" +#include "Math/SVector.h" +#include "TLorentzVector.h" +#include "TVector2.h" #include "TDatabasePDG.h" using namespace std; diff --git a/Common/TableProducer/match-mft-mch-data.cxx b/Common/TableProducer/match-mft-mch-data.cxx index b566d9531f8..96471ddefab 100644 --- a/Common/TableProducer/match-mft-mch-data.cxx +++ b/Common/TableProducer/match-mft-mch-data.cxx @@ -15,50 +15,21 @@ #include #include "CCDB/BasicCCDBManager.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/CCDB/TriggerAliases.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/MftmchMatchingML.h" +#include "Common/DataModel/MatchMFTFT0.h" #include "Common/DataModel/MatchMFTMuonData.h" -#include "Common/Core/trackUtilities.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" -#include "PWGDQ/Core/VarManager.h" -#include "PWGDQ/Core/HistogramManager.h" -#include "PWGDQ/Core/AnalysisCut.h" -#include "PWGDQ/Core/AnalysisCompositeCut.h" -#include "PWGDQ/Core/HistogramsLibrary.h" -#include "PWGDQ/Core/CutsLibrary.h" -#include "DataFormatsGlobalTracking/RecoContainerCreateTracksVariadic.h" -#include "DetectorsVertexing/VertexTrackMatcher.h" -#include "ReconstructionDataFormats/PrimaryVertex.h" -#include "ReconstructionDataFormats/VtxTrackIndex.h" -#include "ReconstructionDataFormats/VtxTrackRef.h" -#include "DataFormatsITSMFT/ROFRecord.h" -#include "CommonDataFormat/InteractionRecord.h" -#include "DetectorsVertexing/PVertexerParams.h" -#include "MathUtils/Primitive2D.h" #include "DataFormatsGlobalTracking/RecoContainer.h" #include "Common/DataModel/CollisionAssociationTables.h" -#include "Common/DataModel/MatchMFTFT0.h" #include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" #include "Field/MagneticField.h" #include "TGeoGlobalMagField.h" #include "DetectorsBase/Propagator.h" #include "DetectorsBase/GeometryManager.h" -#include "EventFiltering/Zorro.h" -#include "ReconstructionDataFormats/TrackFwd.h" -#include "Math/MatrixFunctions.h" -#include "Math/SMatrix.h" -#include "MFTTracking/Tracker.h" -#include "MCHTracking/TrackParam.h" #include "MCHTracking/TrackExtrap.h" #include "GlobalTracking/MatchGlobalFwd.h" -#include -#include +#include "Math/SMatrix.h" +#include "Math/SVector.h" +#include "TLorentzVector.h" +#include "TVector2.h" #include "TDatabasePDG.h" using namespace std; diff --git a/Common/TableProducer/mcCollsExtra.cxx b/Common/TableProducer/mcCollsExtra.cxx index c085969c5af..452930494ba 100644 --- a/Common/TableProducer/mcCollsExtra.cxx +++ b/Common/TableProducer/mcCollsExtra.cxx @@ -39,7 +39,6 @@ #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" #include "DetectorsBase/Propagator.h" #include "DetectorsBase/GeometryManager.h" #include "DataFormatsParameters/GRPObject.h" diff --git a/Common/TableProducer/mftmchMatchingML.cxx b/Common/TableProducer/mftmchMatchingML.cxx index fba6c1464eb..4df90bbfdd1 100644 --- a/Common/TableProducer/mftmchMatchingML.cxx +++ b/Common/TableProducer/mftmchMatchingML.cxx @@ -1,4 +1,4 @@ -// Copyright 2020-2022 CERN and copyright holders of ALICE O2. +// Copyright 2020-2025 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. // @@ -10,11 +10,7 @@ // or submit itself to any jurisdiction. #include -#if __has_include() -#include -#else #include -#endif #include #include #include @@ -77,11 +73,7 @@ struct mftmchMatchingML { Ort::Env env{ORT_LOGGING_LEVEL_WARNING, "model-explorer"}; Ort::SessionOptions session_options; -#if __has_include() - std::shared_ptr onnx_session = nullptr; -#else std::shared_ptr onnx_session = nullptr; -#endif OnnxModel model; template @@ -158,12 +150,6 @@ struct mftmchMatchingML { std::vector output_names; std::vector> output_shapes; -#if __has_include() - input_names = onnx_session->GetInputNames(); - input_shapes = onnx_session->GetInputShapes(); - output_names = onnx_session->GetOutputNames(); - output_shapes = onnx_session->GetOutputShapes(); -#else Ort::AllocatorWithDefaultOptions tmpAllocator; for (size_t i = 0; i < onnx_session->GetInputCount(); ++i) { input_names.push_back(onnx_session->GetInputNameAllocated(i, tmpAllocator).get()); @@ -177,7 +163,6 @@ struct mftmchMatchingML { for (size_t i = 0; i < onnx_session->GetOutputCount(); ++i) { output_shapes.emplace_back(onnx_session->GetOutputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape()); } -#endif auto input_shape = input_shapes[0]; input_shape[0] = 1; @@ -187,11 +172,6 @@ struct mftmchMatchingML { if (input_tensor_values[8] < cfgXYWindow) { std::vector input_tensors; -#if __has_include() - input_tensors.push_back(Ort::Experimental::Value::CreateTensor(input_tensor_values.data(), input_tensor_values.size(), input_shape)); - - std::vector output_tensors = onnx_session->Run(input_names, input_tensors, output_names); -#else Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault); input_tensors.push_back(Ort::Value::CreateTensor(mem_info, input_tensor_values.data(), input_tensor_values.size(), input_shape.data(), input_shape.size())); @@ -206,7 +186,6 @@ struct mftmchMatchingML { [&](const std::string& str) { return str.c_str(); }); std::vector output_tensors = onnx_session->Run(runOptions, inputNamesChar.data(), input_tensors.data(), input_tensors.size(), outputNamesChar.data(), outputNamesChar.size()); -#endif const float* output_value = output_tensors[0].GetTensorData(); diff --git a/Common/TableProducer/multCentTable.cxx b/Common/TableProducer/multCentTable.cxx new file mode 100644 index 00000000000..5b0e2c16d55 --- /dev/null +++ b/Common/TableProducer/multCentTable.cxx @@ -0,0 +1,205 @@ +// 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. + +/// \file multCentTable.cxx +/// \brief unified, self-configuring mult/cent provider +/// \author ALICE + +//=============================================================== +// +// Unified, self-configuring multiplicity+centrality task +// still work in progress: use at your own discretion +// +//=============================================================== + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/trackUtilities.h" +#include "ReconstructionDataFormats/DCA.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsBase/GeometryManager.h" +#include "CommonUtils/NameConf.h" +#include "CCDB/CcdbApi.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/BasicCCDBManager.h" +#include "Framework/HistogramRegistry.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "CommonConstants/GeomConstants.h" +#include "Common/Tools/TrackPropagationModule.h" +#include "Common/Tools/StandardCCDBLoader.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "MetadataHelper.h" +#include "Common/Tools/MultModule.h" + +using namespace o2; +using namespace o2::framework; +// using namespace o2::framework::expressions; + +o2::common::core::MetadataHelper metadataInfo; // Metadata helper + +struct MultCentTable { + o2::common::multiplicity::standardConfigurables opts; + o2::common::multiplicity::products products; + o2::common::multiplicity::MultModule module; + + // CCDB boilerplate declarations + o2::framework::Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Service ccdb; + Service pdg; + + // hold multiplicity values for layover to centrality calculation + std::vector mults; + + // slicers + Preslice> slicerTracksIU = o2::aod::track::collisionId; + Preslice> slicerTracksIUwithSelections = o2::aod::track::collisionId; + Preslice> slicerTrackRun2 = o2::aod::track::collisionId; + + void init(o2::framework::InitContext& initContext) + { + // CCDB boilerplate init + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setURL(ccdburl.value); + ccdb->setFatalWhenNull(false); // please never crash on your own, all exceptions captured (as they always should) + + // task-specific + module.init(metadataInfo, opts, initContext); + } + + void processRun2(soa::Join const& collisions, + soa::Join const& tracks, + soa::Join const& bcs, + aod::Zdcs const&, + aod::FV0As const&, + aod::FV0Cs const&, + aod::FT0s const&) + { + mults.clear(); + for (auto const& collision : collisions) { + o2::common::multiplicity::multEntry mult; + const auto& bc = bcs.rawIteratorAt(collision.getId()); + const uint64_t collIdx = collision.globalIndex(); + auto tracksThisCollision = tracks.sliceBy(slicerTrackRun2, collIdx); + mult = module.collisionProcessRun2(collision, tracksThisCollision, bc, products); + mults.push_back(mult); + } + } + + void processRun3(soa::Join const& collisions, + soa::Join const& tracks, + soa::Join const&, + aod::Zdcs const&, + aod::FV0As const&, + aod::FT0s const&, + aod::FDDs const&) + { + mults.clear(); + for (auto const& collision : collisions) { + o2::common::multiplicity::multEntry mult; + const auto& bc = collision.bc_as>(); + const uint64_t collIdx = collision.globalIndex(); + auto tracksThisCollision = tracks.sliceBy(slicerTracksIU, collIdx); + mult = module.collisionProcessRun3(ccdb, metadataInfo, collision, tracksThisCollision, bc, products); + mults.push_back(mult); + } + } + + void processRun3WithGlobalCounters(soa::Join const& collisions, + soa::Join const& tracks, + soa::Join const&, + aod::Zdcs const&, + aod::FV0As const&, + aod::FT0s const&, + aod::FDDs const&) + { + mults.clear(); + for (auto const& collision : collisions) { + o2::common::multiplicity::multEntry mult; + const auto& bc = collision.bc_as>(); + const uint64_t collIdx = collision.globalIndex(); + auto tracksThisCollision = tracks.sliceBy(slicerTracksIUwithSelections, collIdx); + mult = module.collisionProcessRun3(ccdb, metadataInfo, collision, tracksThisCollision, bc, products); + mults.push_back(mult); + } + } + void processMFT(soa::Join::iterator const& collision, + o2::aod::MFTTracks const& mfttracks, + soa::SmallGroups const& retracks) + { + if (opts.mEnabledTables[o2::common::multiplicity::kMFTMults]) { + // populates MFT information in the mults buffer (in addition to filling table) + module.collisionProcessMFT(collision, mfttracks, retracks, mults, products); + } + } + void processMonteCarlo(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles) + { + if (opts.mEnabledTables[o2::common::multiplicity::kMultMCExtras]) { + module.collisionProcessMonteCarlo(mcCollision, mcParticles, pdg, products); + } + } + void processMonteCarlo2Mults(soa::Join::iterator const& collision) + { + if (opts.mEnabledTables[o2::common::multiplicity::kMult2MCExtras]) { + // establish simple interlink for posterior analysis (derived data) + products.tableExtraMult2MCExtras(collision.mcCollisionId()); + } + } + void processCentralityRun2(aod::Collisions const& collisions, soa::Join const& bcs) + { + // it is important that this function is at the end of the other process functions. + // it requires `mults` to be properly set, which will only happen after the other process + // functions have been called. + + // internally, the function below will do nothing if no centrality is requested. + // it is thus safer to always keep the actual process function for centrality + // generation to true, since the requisites for being in this context are + // always fulfilled + if (collisions.size() != static_cast(mults.size())) { + LOGF(fatal, "Size of collisions doesn't match size of multiplicity buffer!"); + } + module.generateCentralitiesRun2(ccdb, metadataInfo, bcs, mults, products); + } + void processCentralityRun3(aod::Collisions const& collisions, soa::Join const& bcs, aod::FT0s const&) + { + // it is important that this function is at the end of the other process functions. + // it requires `mults` to be properly set, which will only happen after the other process + // functions have been called. + + // internally, the function below will do nothing if no centrality is requested. + // it is thus safer to always keep the actual process function for centrality + // generation to true, since the requisites for being in this context are + // always fulfilled + if (collisions.size() != static_cast(mults.size())) { + LOGF(fatal, "Size of collisions doesn't match size of multiplicity buffer!"); + } + module.generateCentralitiesRun3(ccdb, metadataInfo, bcs, mults, products); + } + + PROCESS_SWITCH(MultCentTable, processRun2, "Process Run 2", false); + PROCESS_SWITCH(MultCentTable, processRun3, "Process Run 3", true); + PROCESS_SWITCH(MultCentTable, processRun3WithGlobalCounters, "Process Run 3 + global tracking counters", false); + PROCESS_SWITCH(MultCentTable, processMFT, "Process MFT info", false); + PROCESS_SWITCH(MultCentTable, processMonteCarlo, "Process Monte Carlo information", false); + PROCESS_SWITCH(MultCentTable, processMonteCarlo2Mults, "Process Monte Carlo information", false); + PROCESS_SWITCH(MultCentTable, processCentralityRun2, "Generate Run 2 centralities", false); + PROCESS_SWITCH(MultCentTable, processCentralityRun3, "Generate Run 3 centralities", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + metadataInfo.initMetadata(cfgc); + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/Common/TableProducer/multiplicityTable.cxx b/Common/TableProducer/multiplicityTable.cxx index 6d4411f7058..12cde8a9869 100644 --- a/Common/TableProducer/multiplicityTable.cxx +++ b/Common/TableProducer/multiplicityTable.cxx @@ -8,6 +8,12 @@ // 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. +// +/// \file multiplicityTable.cxx +/// \brief Produces multiplicity tables +/// +/// \author ALICE +/// #include #include @@ -34,7 +40,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -MetadataHelper metadataInfo; // Metadata helper +o2::common::core::MetadataHelper metadataInfo; // Metadata helper static constexpr int kFV0Mults = 0; static constexpr int kFT0Mults = 1; @@ -50,7 +56,7 @@ static constexpr int kFT0MultZeqs = 10; static constexpr int kFDDMultZeqs = 11; static constexpr int kPVMultZeqs = 12; static constexpr int kMultMCExtras = 13; -static constexpr int nTables = 14; +static constexpr int Ntables = 14; // Checking that the Zeq tables are after the normal ones static_assert(kFV0Mults < kFV0MultZeqs); @@ -58,7 +64,7 @@ static_assert(kFT0Mults < kFT0MultZeqs); static_assert(kFDDMults < kFDDMultZeqs); static_assert(kPVMults < kPVMultZeqs); -static constexpr int nParameters = 1; +static constexpr int Nparameters = 1; static const std::vector tableNames{"FV0Mults", // 0 "FT0Mults", // 1 "FDDMults", // 2 @@ -74,7 +80,7 @@ static const std::vector tableNames{"FV0Mults", // 0 "PVMultZeqs", // 12 "MultMCExtras"}; // 13 static const std::vector parameterNames{"Enable"}; -static const int defaultParameters[nTables][nParameters]{{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}}; +static const int defaultParameters[Ntables][Nparameters]{{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}}; struct MultiplicityTable { SliceCache cache; @@ -94,6 +100,7 @@ struct MultiplicityTable { Produces tablePVZeqs; // 12 Produces tableExtraMc; // 13 Produces tableExtraMult2MCExtras; + Produces multHepMCHIs; // Not accounted for, produced using custom process function to avoid dependencies Produces mftMults; // Not accounted for, produced using custom process function to avoid dependencies Produces multsGlobal; // Not accounted for, produced based on process function processGlobalTrackingCounters @@ -104,8 +111,8 @@ struct MultiplicityTable { using Run2Tracks = soa::Join; Partition run2tracklets = (aod::track::trackType == static_cast(o2::aod::track::TrackTypeEnum::Run2Tracklet)); Partition tracksWithTPC = (aod::track::tpcNClsFindable > (uint8_t)0); - Partition pvContribTracks = (nabs(aod::track::eta) < 0.8f) && ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor); - Partition pvContribTracksEta1 = (nabs(aod::track::eta) < 1.0f) && ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor); + Partition pvContribTracks = (nabs(aod::track::eta) < 0.8f) && ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); + Partition pvContribTracksEta1 = (nabs(aod::track::eta) < 1.0f) && ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); Preslice perCol = aod::track::collisionId; Preslice perColIU = aod::track::collisionId; Preslice perCollisionMFT = o2::aod::fwdtrack::collisionId; @@ -116,16 +123,17 @@ struct MultiplicityTable { Configurable doVertexZeq{"doVertexZeq", 1, "if 1: do vertex Z eq mult table"}; Configurable fractionOfEvents{"fractionOfEvents", 2.0, "Fractions of events to keep in case the QA is used"}; Configurable> enabledTables{"enabledTables", - {defaultParameters[0], nTables, nParameters, tableNames, parameterNames}, + {defaultParameters[0], Ntables, Nparameters, tableNames, parameterNames}, "Produce tables depending on needs. Values different than -1 override the automatic setup: the corresponding table can be set off (0) or on (1)"}; struct : ConfigurableGroup { Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "The CCDB endpoint url address"}; - Configurable ccdbPath{"ccdbpath", "Centrality/Calibration", "The CCDB path for centrality/multiplicity information"}; + Configurable ccdbPath{"ccdbPath", "Centrality/Calibration", "The CCDB path for centrality/multiplicity information"}; Configurable reconstructionPass{"reconstructionPass", "", {"Apass to use when fetching the calibration tables. Empty (default) does not check for any pass. Use `metadata` to fetch it from the AO2D metadata. Otherwise it will override the metadata."}}; } ccdbConfig; Configurable produceHistograms{"produceHistograms", false, {"Option to produce debug histograms"}}; + Configurable autoSetupFromMetadata{"autoSetupFromMetadata", true, {"Autosetup the Run 2 and Run 3 processing from the metadata"}}; int mRunNumber; bool lCalibLoaded; @@ -146,11 +154,15 @@ struct MultiplicityTable { unsigned int randomSeed = 0; void init(InitContext& context) { - if (metadataInfo.isFullyDefined() && !doprocessRun2 && !doprocessRun3) { // Check if the metadata is initialized (only if not forced from the workflow configuration) - if (metadataInfo.isRun3()) { - doprocessRun3.value = true; - } else { - doprocessRun2.value = false; + // If both Run 2 and Run 3 data process flags are enabled then we check the metadata + if (autoSetupFromMetadata && metadataInfo.isFullyDefined()) { + LOG(info) << "Autosetting the processing from the metadata"; + if (doprocessRun2 == true && doprocessRun3 == true) { + if (metadataInfo.isRun3()) { + doprocessRun2.value = false; + } else { + doprocessRun3.value = false; + } } } @@ -162,20 +174,8 @@ struct MultiplicityTable { LOGF(fatal, "Cannot enable processRun2 and processRun3 at the same time. Please choose one."); } - // exploratory - auto& workflows = context.services().get(); - for (auto const& device : workflows.devices) { - for (auto const& input : device.inputs) { - // input.print(); - TString devNam = device.name.c_str(); - TString inBin = input.matcher.binding.c_str(); - // TString subSpec = input.matcher.subspec.c_str(); - LOGF(info, Form("device %s input binding %s subspec", devNam.Data(), inBin.Data())); - } - } - - bool tEnabled[nTables] = {false}; - for (int i = 0; i < nTables; i++) { + bool tEnabled[Ntables] = {false}; + for (int i = 0; i < Ntables; i++) { int f = enabledTables->get(tableNames[i].c_str(), "Enable"); enableFlagIfTableRequired(context, tableNames[i], f); if (f == 1) { @@ -228,6 +228,7 @@ struct MultiplicityTable { ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); // don't fatal, please - exception is caught explicitly (as it should) + listCalib.setObject(new TList); if (!produceHistograms.value) { return; } @@ -235,8 +236,6 @@ struct MultiplicityTable { histos.add("FT0C", "FT0C vs FT0C eq.", HistType::kTH2D, {{1000, 0, 1000, "FT0C multiplicity"}, {1000, 0, 1000, "FT0C multiplicity eq."}}); histos.add("FT0CMultvsPV", "FT0C vs mult.", HistType::kTH2D, {{1000, 0, 1000, "FT0C mult."}, {100, 0, 100, "PV mult."}}); histos.add("FT0AMultvsPV", "FT0A vs mult.", HistType::kTH2D, {{1000, 0, 1000, "FT0A mult."}, {100, 0, 100, "PV mult."}}); - - listCalib.setObject(new TList); } /// Dummy process function for BCs, needed in case both Run2 and Run3 process functions are disabled @@ -268,21 +267,21 @@ struct MultiplicityTable { int multNContribsEtaHalf = 0; if (collision.has_fv0a()) { - for (auto amplitude : collision.fv0a().amplitude()) { + for (const auto& amplitude : collision.fv0a().amplitude()) { multFV0A += amplitude; } } if (collision.has_fv0c()) { - for (auto amplitude : collision.fv0c().amplitude()) { + for (const auto& amplitude : collision.fv0c().amplitude()) { multFV0C += amplitude; } } if (collision.has_ft0()) { auto ft0 = collision.ft0(); - for (auto amplitude : ft0.amplitudeA()) { + for (const auto& amplitude : ft0.amplitudeA()) { multFT0A += amplitude; } - for (auto amplitude : ft0.amplitudeC()) { + for (const auto& amplitude : ft0.amplitudeC()) { multFT0C += amplitude; } } @@ -292,7 +291,20 @@ struct MultiplicityTable { multZNC = zdc.energyCommonZNC(); } - LOGF(debug, "multFV0A=%5.0f multFV0C=%5.0f multFT0A=%5.0f multFT0C=%5.0f multFDDA=%5.0f multFDDC=%5.0f multZNA=%6.0f multZNC=%6.0f multTracklets=%i multTPC=%i", multFV0A, multFV0C, multFT0A, multFT0C, multFDDA, multFDDC, multZNA, multZNC, multTracklets, multTPC); + // Try to do something Similar to https://github.com/alisw/AliPhysics/blob/22862a945004f719f8e9664c0264db46e7186a48/OADB/AliPPVsMultUtils.cxx#L541C26-L541C37 + for (const auto& tracklet : trackletsGrouped) { + if (std::abs(tracklet.eta()) < 1.0) { + multNContribsEta1++; + } + if (std::abs(tracklet.eta()) < 0.8) { + multNContribs++; + } + if (std::abs(tracklet.eta()) < 0.5) { + multNContribsEtaHalf++; + } + } + + LOGF(debug, "multFV0A=%5.0f multFV0C=%5.0f multFT0A=%5.0f multFT0C=%5.0f multFDDA=%5.0f multFDDC=%5.0f multZNA=%6.0f multZNC=%6.0f multTracklets=%i multTPC=%i multNContribsEta1=%i multNContribs=%i multNContribsEtaHalf=%i", multFV0A, multFV0C, multFT0A, multFT0C, multFDDA, multFDDC, multZNA, multZNC, multTracklets, multTPC, multNContribs, multNContribsEta1, multNContribsEtaHalf); tableFV0(multFV0A, multFV0C); tableFT0(multFT0A, multFT0C); tableFDD(multFDDA, multFDDC); @@ -304,10 +316,10 @@ struct MultiplicityTable { using Run3TracksIU = soa::Join; Partition tracksIUWithTPC = (aod::track::tpcNClsFindable > (uint8_t)0); - Partition pvAllContribTracksIU = ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor); - Partition pvContribTracksIU = (nabs(aod::track::eta) < 0.8f) && ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor); - Partition pvContribTracksIUEta1 = (nabs(aod::track::eta) < 1.0f) && ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor); - Partition pvContribTracksIUEtaHalf = (nabs(aod::track::eta) < 0.5f) && ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor); + Partition pvAllContribTracksIU = ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); + Partition pvContribTracksIU = (nabs(aod::track::eta) < 0.8f) && ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); + Partition pvContribTracksIUEta1 = (nabs(aod::track::eta) < 1.0f) && ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); + Partition pvContribTracksIUEtaHalf = (nabs(aod::track::eta) < 0.5f) && ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); void processRun3(soa::Join const& collisions, Run3TracksIU const&, @@ -318,7 +330,7 @@ struct MultiplicityTable { aod::FDDs const&) { // reserve memory - for (auto i : mEnabledTables) { + for (const auto& i : mEnabledTables) { switch (i) { case kFV0Mults: // FV0 tableFV0.reserve(collisions.size()); @@ -441,7 +453,7 @@ struct MultiplicityTable { } } - for (auto i : mEnabledTables) { + for (const auto& i : mEnabledTables) { switch (i) { case kFV0Mults: // FV0 { @@ -474,10 +486,10 @@ struct MultiplicityTable { // using FT0 row index from event selection task if (collision.has_foundFT0()) { const auto& ft0 = collision.foundFT0(); - for (auto amplitude : ft0.amplitudeA()) { + for (const auto& amplitude : ft0.amplitudeA()) { multFT0A += amplitude; } - for (auto amplitude : ft0.amplitudeC()) { + for (const auto& amplitude : ft0.amplitudeC()) { multFT0C += amplitude; } } else { @@ -494,10 +506,10 @@ struct MultiplicityTable { // using FDD row index from event selection task if (collision.has_foundFDD()) { const auto& fdd = collision.foundFDD(); - for (auto amplitude : fdd.chargeA()) { + for (const auto& amplitude : fdd.chargeA()) { multFDDA += amplitude; } - for (auto amplitude : fdd.chargeC()) { + for (const auto& amplitude : fdd.chargeC()) { multFDDC += amplitude; } } else { @@ -549,7 +561,7 @@ struct MultiplicityTable { // use only one single grouping operation, then do loop const auto& tracksThisCollision = pvContribTracksIUEta1.sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); multNContribsEta1 = tracksThisCollision.size(); - for (auto track : tracksThisCollision) { + for (const auto& track : tracksThisCollision) { if (std::abs(track.eta()) < 0.8) { multNContribs++; } @@ -568,7 +580,7 @@ struct MultiplicityTable { const auto& pvAllContribsGrouped = pvAllContribTracksIU->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); const auto& tpcTracksGrouped = tracksIUWithTPC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - for (auto track : pvAllContribsGrouped) { + for (const auto& track : pvAllContribsGrouped) { if (track.hasITS()) { nHasITS++; if (track.hasTPC()) @@ -589,7 +601,7 @@ struct MultiplicityTable { int nAllTracksTPCOnly = 0; int nAllTracksITSTPC = 0; - for (auto track : tpcTracksGrouped) { + for (const auto& track : tpcTracksGrouped) { if (track.hasITS()) { nAllTracksITSTPC++; } else { @@ -611,14 +623,14 @@ struct MultiplicityTable { } break; case kFV0MultZeqs: // Z equalized FV0 { - if (fabs(collision.posZ()) < 15.0f && lCalibLoaded) { + if (std::fabs(collision.posZ()) < 15.0f && lCalibLoaded) { multZeqFV0A = hVtxZFV0A->Interpolate(0.0) * multFV0A / hVtxZFV0A->Interpolate(collision.posZ()); } tableFV0Zeqs(multZeqFV0A); } break; case kFT0MultZeqs: // Z equalized FT0 { - if (fabs(collision.posZ()) < 15.0f && lCalibLoaded) { + if (std::fabs(collision.posZ()) < 15.0f && lCalibLoaded) { multZeqFT0A = hVtxZFT0A->Interpolate(0.0) * multFT0A / hVtxZFT0A->Interpolate(collision.posZ()); multZeqFT0C = hVtxZFT0C->Interpolate(0.0) * multFT0C / hVtxZFT0C->Interpolate(collision.posZ()); } @@ -632,7 +644,7 @@ struct MultiplicityTable { } break; case kFDDMultZeqs: // Z equalized FDD { - if (fabs(collision.posZ()) < 15.0f && lCalibLoaded) { + if (std::fabs(collision.posZ()) < 15.0f && lCalibLoaded) { multZeqFDDA = hVtxZFDDA->Interpolate(0.0) * multFDDA / hVtxZFDDA->Interpolate(collision.posZ()); multZeqFDDC = hVtxZFDDC->Interpolate(0.0) * multFDDC / hVtxZFDDC->Interpolate(collision.posZ()); } @@ -640,7 +652,7 @@ struct MultiplicityTable { } break; case kPVMultZeqs: // Z equalized PV { - if (fabs(collision.posZ()) < 15.0f && lCalibLoaded) { + if (std::fabs(collision.posZ()) < 15.0f && lCalibLoaded) { multZeqNContribs = hVtxZNTracks->Interpolate(0.0) * multNContribs / hVtxZNTracks->Interpolate(collision.posZ()); } tablePVZeqs(multZeqNContribs); @@ -661,9 +673,9 @@ struct MultiplicityTable { // FIT FT0C: -3.3 < η < -2.1 // FOT FT0A: 3.5 < η < 4.9 Filter mcParticleFilter = (aod::mcparticle::eta < 7.0f) && (aod::mcparticle::eta > -7.0f); - using mcParticlesFiltered = soa::Filtered; + using McParticlesFiltered = soa::Filtered; - void processMC(aod::McCollision const& mcCollision, mcParticlesFiltered const& mcParticles) + void processMC(aod::McCollision const& mcCollision, McParticlesFiltered const& mcParticles) { int multFT0A = 0; int multFV0A = 0; @@ -715,49 +727,61 @@ struct MultiplicityTable { tableExtraMult2MCExtras(collision.mcCollisionId()); // interlink } - Configurable min_pt_globaltrack{"min_pt_globaltrack", 0.15, "min. pT for global tracks"}; - Configurable max_pt_globaltrack{"max_pt_globaltrack", 1e+10, "max. pT for global tracks"}; - Configurable min_ncluster_its_globaltrack{"min_ncluster_its_globaltrack", 5, "min. number of ITS clusters for global tracks"}; - Configurable min_ncluster_itsib_globaltrack{"min_ncluster_itsib_globaltrack", 1, "min. number of ITSib clusters for global tracks"}; + Configurable minPtGlobalTrack{"minPtGlobalTrack", 0.15, "min. pT for global tracks"}; + Configurable maxPtGlobalTrack{"maxPtGlobalTrack", 1e+10, "max. pT for global tracks"}; + Configurable minNclsITSGlobalTrack{"minNclsITSGlobalTrack", 5, "min. number of ITS clusters for global tracks"}; + Configurable minNclsITSibGlobalTrack{"minNclsITSibGlobalTrack", 1, "min. number of ITSib clusters for global tracks"}; using Run3Tracks = soa::Join; - Partition pvContribGlobalTracksEta1 = (min_pt_globaltrack < aod::track::pt && aod::track::pt < max_pt_globaltrack) && (nabs(aod::track::eta) < 1.0f) && ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor) && requireQualityTracksInFilter(); + Partition pvContribGlobalTracksEta1 = (minPtGlobalTrack < aod::track::pt && aod::track::pt < maxPtGlobalTrack) && (nabs(aod::track::eta) < 1.0f) && ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)) && requireQualityTracksInFilter(); + + void processHepMCHeavyIons(aod::HepMCHeavyIons const& hepmchis) + { + for (auto const& hepmchi : hepmchis) { + multHepMCHIs(hepmchi.mcCollisionId(), + hepmchi.ncollHard(), + hepmchi.npartProj(), + hepmchi.npartTarg(), + hepmchi.ncoll(), + hepmchi.impactParameter()); + } + } void processGlobalTrackingCounters(aod::Collision const& collision, soa::Join const& tracksIU, Run3Tracks const&) { // counter from Igor int nGlobalTracks = 0; - int multNContribsEta05_kGlobalTrackWoDCA = 0; - int multNContribsEta08_kGlobalTrackWoDCA = 0; - int multNContribsEta10_kGlobalTrackWoDCA = 0; + int multNbrContribsEta05GlobalTrackWoDCA = 0; + int multNbrContribsEta08GlobalTrackWoDCA = 0; + int multNbrContribsEta10GlobalTrackWoDCA = 0; - auto pvContribGlobalTracksEta1_per_collision = pvContribGlobalTracksEta1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto pvContribGlobalTracksEta1PerCollision = pvContribGlobalTracksEta1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - for (auto& track : pvContribGlobalTracksEta1_per_collision) { - if (track.itsNCls() < min_ncluster_its_globaltrack || track.itsNClsInnerBarrel() < min_ncluster_itsib_globaltrack) { + for (const auto& track : pvContribGlobalTracksEta1PerCollision) { + if (track.itsNCls() < minNclsITSGlobalTrack || track.itsNClsInnerBarrel() < minNclsITSibGlobalTrack) { continue; } - multNContribsEta10_kGlobalTrackWoDCA++; + multNbrContribsEta10GlobalTrackWoDCA++; if (std::abs(track.eta()) < 0.8) { - multNContribsEta08_kGlobalTrackWoDCA++; + multNbrContribsEta08GlobalTrackWoDCA++; } if (std::abs(track.eta()) < 0.5) { - multNContribsEta05_kGlobalTrackWoDCA++; + multNbrContribsEta05GlobalTrackWoDCA++; } } - for (auto& track : tracksIU) { - if (fabs(track.eta()) < 0.8 && track.tpcNClsFound() >= 80 && track.tpcNClsCrossedRows() >= 100) { + for (const auto& track : tracksIU) { + if (std::fabs(track.eta()) < 0.8 && track.tpcNClsFound() >= 80 && track.tpcNClsCrossedRows() >= 100) { if (track.isGlobalTrack()) { nGlobalTracks++; } } } - LOGF(debug, "nGlobalTracks = %d, multNContribsEta08_kGlobalTrackWoDCA = %d, multNContribsEta10_kGlobalTrackWoDCA = %d, multNContribsEta05_kGlobalTrackWoDCA = %d", nGlobalTracks, multNContribsEta08_kGlobalTrackWoDCA, multNContribsEta10_kGlobalTrackWoDCA, multNContribsEta05_kGlobalTrackWoDCA); + LOGF(debug, "nGlobalTracks = %d, multNbrContribsEta08GlobalTrackWoDCA = %d, multNbrContribsEta10GlobalTrackWoDCA = %d, multNbrContribsEta05GlobalTrackWoDCA = %d", nGlobalTracks, multNbrContribsEta08GlobalTrackWoDCA, multNbrContribsEta10GlobalTrackWoDCA, multNbrContribsEta05GlobalTrackWoDCA); - multsGlobal(nGlobalTracks, multNContribsEta08_kGlobalTrackWoDCA, multNContribsEta10_kGlobalTrackWoDCA, multNContribsEta05_kGlobalTrackWoDCA); + multsGlobal(nGlobalTracks, multNbrContribsEta08GlobalTrackWoDCA, multNbrContribsEta10GlobalTrackWoDCA, multNbrContribsEta05GlobalTrackWoDCA); } void processRun3MFT(soa::Join::iterator const&, @@ -767,14 +791,14 @@ struct MultiplicityTable { int nAllTracks = 0; int nTracks = 0; - for (auto& track : mftTracks) { + for (const auto& track : mftTracks) { if (track.nClusters() >= 5) { // hardcoded for now nAllTracks++; } } if (retracks.size() > 0) { - for (auto& retrack : retracks) { + for (const auto& retrack : retracks) { auto track = retrack.mfttrack(); if (track.nClusters() < 5) { continue; // min cluster requirement @@ -792,11 +816,12 @@ struct MultiplicityTable { } // Process switches - PROCESS_SWITCH(MultiplicityTable, processRun2, "Produce Run 2 multiplicity tables", false); - PROCESS_SWITCH(MultiplicityTable, processRun3, "Produce Run 3 multiplicity tables", true); + PROCESS_SWITCH(MultiplicityTable, processRun2, "Produce Run 2 multiplicity tables. Autoset if both processRun2 and processRun3 are enabled", true); + PROCESS_SWITCH(MultiplicityTable, processRun3, "Produce Run 3 multiplicity tables. Autoset if both processRun2 and processRun3 are enabled", true); PROCESS_SWITCH(MultiplicityTable, processGlobalTrackingCounters, "Produce Run 3 global counters", false); PROCESS_SWITCH(MultiplicityTable, processMC, "Produce MC multiplicity tables", false); PROCESS_SWITCH(MultiplicityTable, processMC2Mults, "Produce MC -> Mult map", false); + PROCESS_SWITCH(MultiplicityTable, processHepMCHeavyIons, "Produce MultHepMCHIs tables", false); PROCESS_SWITCH(MultiplicityTable, processRun3MFT, "Produce MFT mult tables", false); }; diff --git a/Common/TableProducer/muonRealignment.cxx b/Common/TableProducer/muonRealignment.cxx new file mode 100644 index 00000000000..58745af69a6 --- /dev/null +++ b/Common/TableProducer/muonRealignment.cxx @@ -0,0 +1,392 @@ +// 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. + +/// \file muonRealignment.cxx +/// \brief Task for muon re-alignment at analysis level +/// \author Chi Zhang , CEA-Saclay + +#include +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/ASoAHelpers.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CCDBTimeStampUtils.h" +#include "CommonUtils/NameConf.h" +#include "CommonUtils/ConfigurableParam.h" +#include "DataFormatsMCH/Cluster.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/GRPGeomHelper.h" +#include "DetectorsBase/Propagator.h" +#include "MathUtils/Cartesian.h" +#include "MCHGeometryTransformer/Transformations.h" +#include "MCHTracking/Track.h" +#include "MCHTracking/TrackExtrap.h" +#include "MCHTracking/TrackParam.h" +#include "MCHTracking/TrackFitter.h" +#include "MCHBase/TrackerParam.h" +#include "GlobalTracking/MatchGlobalFwd.h" +#include "ReconstructionDataFormats/TrackFwd.h" +#include "Common/DataModel/FwdTrackReAlignTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/CollisionAssociationTables.h" + +using namespace std; +using namespace o2; +using namespace o2::framework; +using namespace o2::mch; +using namespace o2::framework::expressions; + +using MyMuonsWithCov = soa::Join; + +const int fgNDetElemCh[10] = {4, 4, 4, 4, 18, 18, 26, 26, 26, 26}; +const int fgSNDetElemCh[11] = {0, 4, 8, 12, 16, 34, 52, 78, 104, 130, 156}; + +struct FwdTrkCovRealignInfo { + float sigX = 0.f; + float sigY = 0.f; + float sigPhi = 0.f; + float sigTgl = 0.f; + float sig1Pt = 0.f; + int8_t rhoXY = 0; + int8_t rhoPhiX = 0; + int8_t rhoPhiY = 0; + int8_t rhoTglX = 0; + int8_t rhoTglY = 0; + int8_t rhoTglPhi = 0; + int8_t rho1PtX = 0; + int8_t rho1PtY = 0; + int8_t rho1PtPhi = 0; + int8_t rho1PtTgl = 0; +}; + +struct MuonRealignment { + Produces realignFwdTrks; + Produces realignFwdTrksCov; + + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable geoRefPath{"geoRefPath", "GLO/Config/GeometryAligned", "Path of the reference geometry file"}; + Configurable geoNewPath{"geoNewPath", "GLO/Config/GeometryAligned", "Path of the new geometry file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable nolaterthanRef{"ccdb-no-later-than-ref", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object of reference basis"}; + Configurable nolaterthanNew{"ccdb-no-later-than-new", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object of new basis"}; + Configurable cfgChamberResolutionX{"cfgChamberResolutionX", 0.04, "Chamber resolution along X configuration for refit"}; // 0.4cm pp, 0.2cm PbPb + Configurable cfgChamberResolutionY{"cfgChamberResolutionY", 0.04, "Chamber resolution along Y configuration for refit"}; // 0.4cm pp, 0.2cm PbPb + Configurable cfgSigmaCutImprove{"cfgSigmaCutImprove", 6., "Sigma cut for track improvement"}; // 6 for pp, 4 for PbPb + + parameters::GRPMagField* grpmag = nullptr; + base::MatLayerCylSet* lut = nullptr; + TrackFitter trackFitter; // Track fitter from MCH tracking library + geo::TransformationCreator transformation; + map transformRef; // reference geometry w.r.t track data + map transformNew; // new geometry + globaltracking::MatchGlobalFwd mMatching; + int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. + double mImproveCutChi2; // Chi2 cut for track improvement. + Service ccdb; + TGeoManager* geoNew = nullptr; + TGeoManager* geoRef = nullptr; + + Preslice perMuon = aod::fwdtrkcl::fwdtrackId; + + int GetDetElemId(int iDetElemNumber) + { + // make sure detector number is valid + if (!(iDetElemNumber >= fgSNDetElemCh[0] && + iDetElemNumber < fgSNDetElemCh[10])) { + LOGF(fatal, "Invalid detector element number: %d", iDetElemNumber); + } + /// get det element number from ID + // get chamber and element number in chamber + int iCh = 0; + int iDet = 0; + for (int i = 1; i <= 10; i++) { + if (iDetElemNumber < fgSNDetElemCh[i]) { + iCh = i; + iDet = iDetElemNumber - fgSNDetElemCh[i - 1]; + break; + } + } + + // make sure detector index is valid + if (!(iCh > 0 && iCh <= 10 && iDet < fgNDetElemCh[iCh - 1])) { + LOGF(fatal, "Invalid detector element id: %d", 100 * iCh + iDet); + } + + // add number of detectors up to this chamber + return 100 * iCh + iDet; + } + + bool RemoveTrack(mch::Track& track) + { + // Refit track with re-aligned clusters + bool removeTrack = false; + try { + trackFitter.fit(track, false); + } catch (exception const& e) { + removeTrack = true; + return removeTrack; + } + + auto itStartingParam = std::prev(track.rend()); + + while (true) { + + try { + trackFitter.fit(track, true, false, (itStartingParam == track.rbegin()) ? nullptr : &itStartingParam); + } catch (exception const&) { + removeTrack = true; + break; + } + + double worstLocalChi2 = -1.0; + + track.tagRemovableClusters(0x1F, false); + + auto itWorstParam = track.end(); + + for (auto itParam = track.begin(); itParam != track.end(); ++itParam) { + if (itParam->getLocalChi2() > worstLocalChi2) { + worstLocalChi2 = itParam->getLocalChi2(); + itWorstParam = itParam; + } + } + + if (worstLocalChi2 < mImproveCutChi2) { + break; + } + + if (!itWorstParam->isRemovable()) { + removeTrack = true; + track.removable(); + break; + } + + auto itNextParam = track.removeParamAtCluster(itWorstParam); + auto itNextToNextParam = (itNextParam == track.end()) ? itNextParam : std::next(itNextParam); + itStartingParam = track.rbegin(); + + if (track.getNClusters() < 10) { + removeTrack = true; + break; + } else { + while (itNextToNextParam != track.end()) { + if (itNextToNextParam->getClusterPtr()->getChamberId() != itNextParam->getClusterPtr()->getChamberId()) { + itStartingParam = std::make_reverse_iterator(++itNextParam); + break; + } + ++itNextToNextParam; + } + } + } + + if (!removeTrack) { + for (auto& param : track) { + param.setParameters(param.getSmoothParameters()); + param.setCovariances(param.getSmoothCovariances()); + } + } + + return removeTrack; + } + + void init(InitContext const&) + { + fCurrentRun = 0; + + // Configuration for CCDB server + ccdb->setURL(ccdburl.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + // Configuration for track fitter + const auto& trackerParam = TrackerParam::Instance(); + trackFitter.setBendingVertexDispersion(trackerParam.bendingVertexDispersion); + trackFitter.setChamberResolution(cfgChamberResolutionX.value, cfgChamberResolutionY.value); + trackFitter.smoothTracks(true); + trackFitter.useChamberResolution(); + mImproveCutChi2 = 2. * cfgSigmaCutImprove.value * cfgSigmaCutImprove.value; + } + + template + void runMuonRealignment(TMuons const& muons, TMuonCls const& clusters) + { + // Reserve storage for output table + realignFwdTrks.reserve(muons.size()); + realignFwdTrksCov.reserve(muons.size()); + + // Loop over forward tracks using association indices + FwdTrkCovRealignInfo fwdTrkCovRealignInfo; + for (auto const& muon : muons) { + int muonRealignId = muon.globalIndex(); + if (static_cast(muon.trackType() > 2)) { + + auto clustersSliced = clusters.sliceBy(perMuon, muon.globalIndex()); // Slice clusters by muon id + mch::Track convertedTrack = mch::Track(); // Temporary variable to store re-aligned clusters + int clIndex = -1; + // Get re-aligned clusters associated to current track + for (auto const& cluster : clustersSliced) { + clIndex += 1; + + mch::Cluster* clusterMCH = new mch::Cluster(); + + math_utils::Point3D local; + math_utils::Point3D master; + master.SetXYZ(cluster.x(), cluster.y(), cluster.z()); + + // Transformation from reference geometry frame to new geometry frame + transformRef[cluster.deId()].MasterToLocal(master, local); + transformNew[cluster.deId()].LocalToMaster(local, master); + + clusterMCH->x = master.x(); + clusterMCH->y = master.y(); + clusterMCH->z = master.z(); + + uint32_t ClUId = mch::Cluster::buildUniqueId(static_cast(cluster.deId() / 100) - 1, cluster.deId(), clIndex); + clusterMCH->uid = ClUId; + clusterMCH->ex = cluster.isGoodX() ? 0.2 : 10.0; + clusterMCH->ey = cluster.isGoodY() ? 0.2 : 10.0; + + // Add transformed cluster into temporary variable + convertedTrack.createParamAtCluster(*clusterMCH); + LOGF(debug, "Track %d, cluster DE%d: x:%g y:%g z:%g", muon.globalIndex(), cluster.deId(), cluster.x(), cluster.y(), cluster.z()); + LOGF(debug, "Track %d, re-aligned cluster DE%d: x:%g y:%g z:%g", muonRealignId, cluster.deId(), clusterMCH->getX(), clusterMCH->getY(), clusterMCH->getZ()); + } + + // Refit the re-aligned track + int removable = 0; + if (convertedTrack.getNClusters() != 0) { + removable = RemoveTrack(convertedTrack); + } else { + LOGF(fatal, "Muon track %d has no associated clusters.", muon.globalIndex()); + } + + // Get the re-aligned track parameter: track param at the first cluster + mch::TrackParam trackParam = mch::TrackParam(convertedTrack.first()); + + // Convert MCH track to FWD track and get new parameters + auto fwdtrack = mMatching.MCHtoFwd(trackParam); + fwdtrack.setTrackChi2(trackParam.getTrackChi2() / convertedTrack.getNDF()); + fwdTrkCovRealignInfo.sigX = TMath::Sqrt(fwdtrack.getCovariances()(0, 0)); + fwdTrkCovRealignInfo.sigY = TMath::Sqrt(fwdtrack.getCovariances()(1, 1)); + fwdTrkCovRealignInfo.sigPhi = TMath::Sqrt(fwdtrack.getCovariances()(2, 2)); + fwdTrkCovRealignInfo.sigTgl = TMath::Sqrt(fwdtrack.getCovariances()(3, 3)); + fwdTrkCovRealignInfo.sig1Pt = TMath::Sqrt(fwdtrack.getCovariances()(4, 4)); + fwdTrkCovRealignInfo.rhoXY = (Char_t)(128. * fwdtrack.getCovariances()(0, 1) / (fwdTrkCovRealignInfo.sigX * fwdTrkCovRealignInfo.sigY)); + fwdTrkCovRealignInfo.rhoPhiX = (Char_t)(128. * fwdtrack.getCovariances()(0, 2) / (fwdTrkCovRealignInfo.sigPhi * fwdTrkCovRealignInfo.sigX)); + fwdTrkCovRealignInfo.rhoPhiY = (Char_t)(128. * fwdtrack.getCovariances()(1, 2) / (fwdTrkCovRealignInfo.sigPhi * fwdTrkCovRealignInfo.sigY)); + fwdTrkCovRealignInfo.rhoTglX = (Char_t)(128. * fwdtrack.getCovariances()(0, 3) / (fwdTrkCovRealignInfo.sigTgl * fwdTrkCovRealignInfo.sigX)); + fwdTrkCovRealignInfo.rhoTglY = (Char_t)(128. * fwdtrack.getCovariances()(1, 3) / (fwdTrkCovRealignInfo.sigTgl * fwdTrkCovRealignInfo.sigY)); + fwdTrkCovRealignInfo.rhoTglPhi = (Char_t)(128. * fwdtrack.getCovariances()(2, 3) / (fwdTrkCovRealignInfo.sigTgl * fwdTrkCovRealignInfo.sigPhi)); + fwdTrkCovRealignInfo.rho1PtX = (Char_t)(128. * fwdtrack.getCovariances()(0, 4) / (fwdTrkCovRealignInfo.sig1Pt * fwdTrkCovRealignInfo.sigX)); + fwdTrkCovRealignInfo.rho1PtY = (Char_t)(128. * fwdtrack.getCovariances()(1, 4) / (fwdTrkCovRealignInfo.sig1Pt * fwdTrkCovRealignInfo.sigY)); + fwdTrkCovRealignInfo.rho1PtPhi = (Char_t)(128. * fwdtrack.getCovariances()(2, 4) / (fwdTrkCovRealignInfo.sig1Pt * fwdTrkCovRealignInfo.sigPhi)); + fwdTrkCovRealignInfo.rho1PtTgl = (Char_t)(128. * fwdtrack.getCovariances()(3, 4) / (fwdTrkCovRealignInfo.sig1Pt * fwdTrkCovRealignInfo.sigTgl)); + LOGF(debug, "TrackParm %d, x:%g y:%g z:%g phi:%g tgl:%g InvQPt:%g chi2:%g nClusters:%d", muon.globalIndex(), muon.x(), muon.y(), muon.z(), muon.phi(), muon.tgl(), muon.signed1Pt(), muon.chi2(), muon.nClusters()); + LOGF(debug, "Re-aligned trackParm %d, x:%g y:%g z:%g phi:%g tgl:%g InvQPt:%g chi2:%g nClusters:%d removable:%d", muonRealignId, fwdtrack.getX(), fwdtrack.getY(), fwdtrack.getZ(), fwdtrack.getPhi(), fwdtrack.getTgl(), fwdtrack.getInvQPt(), fwdtrack.getTrackChi2(), convertedTrack.getNClusters(), removable); + // Fill refitted track info + realignFwdTrks(muon.collisionId(), muon.trackType(), fwdtrack.getX(), fwdtrack.getY(), fwdtrack.getZ(), fwdtrack.getPhi(), fwdtrack.getTgl(), fwdtrack.getInvQPt(), convertedTrack.getNClusters(), muon.pDca(), muon.rAtAbsorberEnd(), removable, fwdtrack.getTrackChi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), + muon.matchScoreMCHMFT(), muon.matchMFTTrackId(), muon.matchMCHTrackId(), + muon.mchBitMap(), muon.midBitMap(), muon.midBoards(), + muon.trackTime(), muon.trackTimeRes()); + realignFwdTrksCov(fwdTrkCovRealignInfo.sigX, fwdTrkCovRealignInfo.sigY, fwdTrkCovRealignInfo.sigPhi, + fwdTrkCovRealignInfo.sigTgl, fwdTrkCovRealignInfo.sig1Pt, fwdTrkCovRealignInfo.rhoXY, + fwdTrkCovRealignInfo.rhoPhiX, fwdTrkCovRealignInfo.rhoPhiY, fwdTrkCovRealignInfo.rhoTglX, + fwdTrkCovRealignInfo.rhoTglY, fwdTrkCovRealignInfo.rhoTglPhi, fwdTrkCovRealignInfo.rho1PtX, + fwdTrkCovRealignInfo.rho1PtY, fwdTrkCovRealignInfo.rho1PtPhi, fwdTrkCovRealignInfo.rho1PtTgl); + muonRealignId++; + } else { + realignFwdTrks(muon.collisionId(), muon.trackType(), muon.x(), muon.y(), muon.z(), muon.phi(), muon.tgl(), muon.signed1Pt(), muon.nClusters(), muon.pDca(), muon.rAtAbsorberEnd(), 0, muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), + muon.matchScoreMCHMFT(), muon.matchMFTTrackId(), muon.matchMCHTrackId(), + muon.mchBitMap(), muon.midBitMap(), muon.midBoards(), + muon.trackTime(), muon.trackTimeRes()); + realignFwdTrksCov(muon.sigmaX(), muon.sigmaY(), muon.sigmaPhi(), muon.sigmaTgl(), muon.sigma1Pt(), muon.rhoXY(), muon.rhoPhiY(), muon.rhoPhiX(), muon.rhoTglX(), muon.rhoTglY(), muon.rhoTglPhi(), muon.rho1PtX(), muon.rho1PtY(), muon.rho1PtPhi(), muon.rho1PtTgl()); + muonRealignId++; + } + } + } + + void processMuonReAlignment(aod::Collisions const& collisions, aod::BCsWithTimestamps const&, MyMuonsWithCov const& tracks, aod::FwdTrkCls const& clusters) + { + bool FirstEvent = true; + for (auto const& collision : collisions) { + + if (!FirstEvent) { + break; + } + + auto bc = collision.template bc_as(); + if (fCurrentRun != bc.runNumber()) { + // Load magnetic field information from CCDB/local + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + grpmag = ccdb->getForTimeStamp(grpmagPath, bc.timestamp()); + if (grpmag != nullptr) { + base::Propagator::initFieldFromGRP(grpmag); + TrackExtrap::setField(); + TrackExtrap::useExtrapV2(); + } else { + LOGF(fatal, "GRP object is not available in CCDB at timestamp=%llu", bc.timestamp()); + } + + // Load geometry information from CCDB/local + LOGF(info, "Loading reference aligned geometry from CCDB no later than %d", nolaterthanRef.value); + ccdb->setCreatedNotAfter(nolaterthanRef.value); // this timestamp has to be consistent with what has been used in reco + geoRef = ccdb->getForTimeStamp(geoRefPath, bc.timestamp()); + ccdb->clearCache(geoRefPath); + if (geoRef != nullptr) { + transformation = geo::transformationFromTGeoManager(*geoRef); + } else { + LOGF(fatal, "Reference aligned geometry object is not available in CCDB at timestamp=%llu", bc.timestamp()); + } + for (int i = 0; i < 156; i++) { + int iDEN = GetDetElemId(i); + transformRef[iDEN] = transformation(iDEN); + } + + LOGF(info, "Loading new aligned geometry from CCDB no later than %d", nolaterthanNew.value); + ccdb->setCreatedNotAfter(nolaterthanNew.value); // make sure this timestamp can be resolved regarding the reference one + geoNew = ccdb->getForTimeStamp(geoNewPath, bc.timestamp()); + ccdb->clearCache(geoNewPath); + if (geoNew != nullptr) { + transformation = geo::transformationFromTGeoManager(*geoNew); + } else { + LOGF(fatal, "New aligned geometry object is not available in CCDB at timestamp=%llu", bc.timestamp()); + } + for (int i = 0; i < 156; i++) { + int iDEN = GetDetElemId(i); + transformNew[iDEN] = transformation(iDEN); + } + + fCurrentRun = bc.runNumber(); + } + FirstEvent = false; + } + + runMuonRealignment(tracks, clusters); + } + PROCESS_SWITCH(MuonRealignment, processMuonReAlignment, "Process to do muon realignment", true); +}; + +// Extends the fwdtracksrealign table with expression columns +struct MuonRealignmentSpawner { + Spawns realignFwdTrksCov; + Spawns realignFwdTrks; + void init(InitContext const&) {} +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; +} diff --git a/Common/TableProducer/occupancyTableProducer.cxx b/Common/TableProducer/occupancyTableProducer.cxx new file mode 100644 index 00000000000..a700b394772 --- /dev/null +++ b/Common/TableProducer/occupancyTableProducer.cxx @@ -0,0 +1,2764 @@ +// 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. +/// +/// \file occupancyTableProducer.cxx +/// \brief Occupancy Table Producer : TPC PID - Calibration +/// Occupancy calculater using tracks which have entry for collision and trackQA tables +/// Ambg tracks were not used +/// \author Rahul Verma (rahul.verma@iitb.ac.in) :: Marian I Ivanov (marian.ivanov@cern.ch) + +#include +#include +#include +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/O2DatabasePDGPlugin.h" + +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/DataModel/OccupancyTables.h" + +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsFT0/Digit.h" +#include "DataFormatsParameters/GRPLHCIFData.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +int32_t nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; +// const int nBCinTFgrp80 = 1425; +// nOrbitsPerTF = run < 534133 ? 128 : 32; +// for 128 => nBCsPerTF = 456192 , for 32 => nBCsPerTF = 114048 +// const int nBCinTF = 114048; /// CCDB value // to be obtained from CCDB in future +const int nBCinDrift = 114048 / 32; /// to get from ccdb in future + +template +void sortVectorOfArray(std::vector>& myVector, const int& myIDX) +{ + std::sort(myVector.begin(), myVector.end(), [myIDX](const std::array& a, const std::array& b) { + return a[myIDX] < b[myIDX]; // sort at the required index + }); +} + +template +void checkUniqueness(const std::vector>& myVector, const int& myIDX) +{ + for (size_t i = 1; i < myVector.size(); i++) { + if (myVector[i][myIDX] <= myVector[i - 1][myIDX]) { + LOG(error) << "Duplicate Entries while creating Index tables :: (vec[" << i << "][" << myIDX << "]) " << myVector[i][myIDX] << " >= " << myVector[i - 1][myIDX] << " (vec[" << i - 1 << "][" << myIDX << "])"; + } + } +} + +struct OccupancyTableProducer { + + Service ccdb; + + // declare production of tables + Produces genBCTFinfoTable; + // 0 + Produces genOccIndexTable; + Produces genOccsBCsList; + // 1 + Produces genOccsPrim; + Produces genOccsMeanPrim; + // 2 + Produces genOccsT0V0; + Produces genOccsMeanT0V0; + ; + Produces genORT0V0Prim; + Produces genOccsMeanRobustT0V0Prim; + // 3 + Produces genOccsFDD; + Produces genOccsMeanFDD; + Produces genORFDDT0V0Prim; + Produces genOccsMeanRobustFDDT0V0Prim; + // 4 + Produces genOccsNTrackDet; + Produces genOccsMeanNTrkDet; + Produces genORNtrackDet; + Produces genOccsMeanRobustNtrackDet; + // 5 + Produces genOccsMultExtra; + Produces genOccsMnMultExtra; + Produces genORMultExtra; + Produces genOccsMeanRobustMultExtraTable; + + Configurable customOrbitOffset{"customOrbitOffset", 0, "customOrbitOffset for MC"}; + Configurable bcGrouping{"bcGrouping", 80, "bcGrouping of BCs"}; + Configurable nBCinTF{"nBCinTF", 114048, "nBCinTF"}; + Configurable occVecArraySize{"occVecArraySize", 10, "occVecArraySize"}; + + Configurable cfgNOrbitsPerTF0RunValue{"cfgNOrbitsPerTF0RunValue", 534133, "cfgNOrbitsPerTF0RunValue"}; + Configurable cfgNOrbitsPerTF1TrueValue{"cfgNOrbitsPerTF1TrueValue", 128, "cfgNOrbitsPerTF1TrueValue"}; + Configurable cfgNOrbitsPerTF2FalseValue{"cfgNOrbitsPerTF2FalseValue", 32, "ccfgNOrbitsPerTF2FalseValue"}; + + // declare production of tables + Configurable buildOnlyOccsPrim{"buildOnlyOccsPrim", true, "builder of table OccsPrim"}; + Configurable buildOnlyOccsT0V0Prim{"buildOnlyOccsT0V0Prim", true, "builder of table OccsT0V0Prim"}; + Configurable buildOnlyOccsFDDT0V0Prim{"buildOnlyOccsFDDT0V0Prim", true, "builder of table OccsFDDT0V0Prim"}; + Configurable buildOnlyOccsNtrackDet{"buildOnlyOccsNtrackDet", true, "builder of table OccsNtrackDet"}; + Configurable buildOnlyOccsMultExtra{"buildOnlyOccsMultExtra", true, "builder of table OccsMultExtra"}; + Configurable buildFullOccTableProducer{"buildFullOccTableProducer", true, "builder of all Occupancy Tables"}; + + Configurable buildFlag00OccTable{"buildFlag00OccTable", true, "switch of table Occ Table"}; + Configurable buildFlag01OccMeanTable{"buildFlag01OccMeanTable", true, "switch of table Occ MeanTable"}; + Configurable buildFlag02OccRobustTable{"buildFlag02OccRobustTable", true, "switch of table Occ RobustTable"}; + Configurable buildFlag03OccMeanRobustTable{"buildFlag03OccMeanRobustTable", true, "switch of table Occ MeanRobustTable"}; + + // Histogram registry; + HistogramRegistry recoEvent{"recoEvent", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry occupancyQA{"occupancyQA", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + std::vector tfList; + std::vector> bcTFMap; + + std::vector> occPrimUnfm80; + std::vector> occFV0AUnfm80; + std::vector> occFV0CUnfm80; + std::vector> occFT0AUnfm80; + std::vector> occFT0CUnfm80; + + std::vector> occFDDAUnfm80; + std::vector> occFDDCUnfm80; + + std::vector> occNTrackITSUnfm80; + std::vector> occNTrackTPCUnfm80; + std::vector> occNTrackTRDUnfm80; + std::vector> occNTrackTOFUnfm80; + std::vector> occNTrackSizeUnfm80; + std::vector> occNTrackTPCAUnfm80; + std::vector> occNTrackTPCCUnfm80; + std::vector> occNTrackITSTPCUnfm80; + std::vector> occNTrackITSTPCAUnfm80; + std::vector> occNTrackITSTPCCUnfm80; + + std::vector> occMultNTracksHasITSUnfm80; + std::vector> occMultNTracksHasTPCUnfm80; + std::vector> occMultNTracksHasTOFUnfm80; + std::vector> occMultNTracksHasTRDUnfm80; + std::vector> occMultNTracksITSOnlyUnfm80; + std::vector> occMultNTracksTPCOnlyUnfm80; + std::vector> occMultNTracksITSTPCUnfm80; + std::vector> occMultAllTracksTPCOnlyUnfm80; + + std::vector vecRobustOccT0V0PrimUnfm80; + std::vector vecRobustOccFDDT0V0PrimUnfm80; + std::vector vecRobustOccNtrackDetUnfm80; + std::vector vecRobustOccmultTableUnfm80; + std::vector> vecRobustOccT0V0PrimUnfm80medianPosVec; // Median => one for odd and two for even entries + std::vector> vecRobustOccFDDT0V0PrimUnfm80medianPosVec; + std::vector> vecRobustOccNtrackDetUnfm80medianPosVec; + std::vector> vecRobustOccmultTableUnfm80medianPosVec; + + std::vector processStatus; + Configurable processStatusSize{"processStatusSize", 10, "processStatusSize"}; + void init(InitContext const&) + { + processStatus.resize(processStatusSize); + for (uint i = 0; i < processStatusSize; i++) { + processStatus[i] = false; + } + + // outer vector resized at runtime + tfList.resize(occVecArraySize); + bcTFMap.resize(occVecArraySize); + + if (buildFullOccTableProducer || buildOnlyOccsPrim || buildOnlyOccsT0V0Prim || buildOnlyOccsFDDT0V0Prim || buildOnlyOccsNtrackDet || buildOnlyOccsMultExtra) { + occPrimUnfm80.resize(occVecArraySize); + } + if (buildFullOccTableProducer || buildOnlyOccsT0V0Prim || buildOnlyOccsFDDT0V0Prim) { + occFV0AUnfm80.resize(occVecArraySize); + occFV0CUnfm80.resize(occVecArraySize); + occFT0AUnfm80.resize(occVecArraySize); + occFT0CUnfm80.resize(occVecArraySize); + } + if (buildFullOccTableProducer || buildOnlyOccsFDDT0V0Prim) { + occFDDAUnfm80.resize(occVecArraySize); + occFDDCUnfm80.resize(occVecArraySize); + } + if (buildFullOccTableProducer || buildOnlyOccsNtrackDet) { + occNTrackITSUnfm80.resize(occVecArraySize); + occNTrackTPCUnfm80.resize(occVecArraySize); + occNTrackTRDUnfm80.resize(occVecArraySize); + occNTrackTOFUnfm80.resize(occVecArraySize); + occNTrackSizeUnfm80.resize(occVecArraySize); + occNTrackTPCAUnfm80.resize(occVecArraySize); + occNTrackTPCCUnfm80.resize(occVecArraySize); + occNTrackITSTPCAUnfm80.resize(occVecArraySize); + occNTrackITSTPCCUnfm80.resize(occVecArraySize); + } + if (buildFullOccTableProducer || buildOnlyOccsNtrackDet || buildOnlyOccsMultExtra) { + occNTrackITSTPCUnfm80.resize(occVecArraySize); + } + if (buildFullOccTableProducer || buildOnlyOccsMultExtra) { + occMultNTracksHasITSUnfm80.resize(occVecArraySize); + occMultNTracksHasTPCUnfm80.resize(occVecArraySize); + occMultNTracksHasTOFUnfm80.resize(occVecArraySize); + occMultNTracksHasTRDUnfm80.resize(occVecArraySize); + occMultNTracksITSOnlyUnfm80.resize(occVecArraySize); + occMultNTracksTPCOnlyUnfm80.resize(occVecArraySize); + occMultNTracksITSTPCUnfm80.resize(occVecArraySize); + occMultAllTracksTPCOnlyUnfm80.resize(occVecArraySize); + } + + for (int i = 0; i < occVecArraySize; i++) { + bcTFMap[i].resize(nBCinTF / bcGrouping); + if (buildFullOccTableProducer || buildOnlyOccsPrim || buildOnlyOccsT0V0Prim || buildOnlyOccsFDDT0V0Prim || buildOnlyOccsNtrackDet || buildOnlyOccsMultExtra) { + occPrimUnfm80[i].resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsT0V0Prim || buildOnlyOccsFDDT0V0Prim) { + occFV0AUnfm80[i].resize(nBCinTF / bcGrouping); + occFV0CUnfm80[i].resize(nBCinTF / bcGrouping); + occFT0AUnfm80[i].resize(nBCinTF / bcGrouping); + occFT0CUnfm80[i].resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsFDDT0V0Prim) { + occFDDAUnfm80[i].resize(nBCinTF / bcGrouping); + occFDDCUnfm80[i].resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsNtrackDet) { + occNTrackITSUnfm80[i].resize(nBCinTF / bcGrouping); + occNTrackTPCUnfm80[i].resize(nBCinTF / bcGrouping); + occNTrackTRDUnfm80[i].resize(nBCinTF / bcGrouping); + occNTrackTOFUnfm80[i].resize(nBCinTF / bcGrouping); + occNTrackSizeUnfm80[i].resize(nBCinTF / bcGrouping); + occNTrackTPCAUnfm80[i].resize(nBCinTF / bcGrouping); + occNTrackTPCCUnfm80[i].resize(nBCinTF / bcGrouping); + occNTrackITSTPCAUnfm80[i].resize(nBCinTF / bcGrouping); + occNTrackITSTPCCUnfm80[i].resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsNtrackDet || buildOnlyOccsMultExtra) { + occNTrackITSTPCUnfm80[i].resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsMultExtra) { + occMultNTracksHasITSUnfm80[i].resize(nBCinTF / bcGrouping); + occMultNTracksHasTPCUnfm80[i].resize(nBCinTF / bcGrouping); + occMultNTracksHasTOFUnfm80[i].resize(nBCinTF / bcGrouping); + occMultNTracksHasTRDUnfm80[i].resize(nBCinTF / bcGrouping); + occMultNTracksITSOnlyUnfm80[i].resize(nBCinTF / bcGrouping); + occMultNTracksTPCOnlyUnfm80[i].resize(nBCinTF / bcGrouping); + occMultNTracksITSTPCUnfm80[i].resize(nBCinTF / bcGrouping); + occMultAllTracksTPCOnlyUnfm80[i].resize(nBCinTF / bcGrouping); + } + } + + if (buildFullOccTableProducer || buildOnlyOccsT0V0Prim || buildFlag02OccRobustTable || buildFlag03OccMeanRobustTable) { + vecRobustOccT0V0PrimUnfm80.resize(nBCinTF / bcGrouping); + vecRobustOccT0V0PrimUnfm80medianPosVec.resize(nBCinTF / bcGrouping); // Median => one for odd and two for even entries + } + if (buildFullOccTableProducer || buildOnlyOccsFDDT0V0Prim || buildFlag02OccRobustTable || buildFlag03OccMeanRobustTable) { + vecRobustOccFDDT0V0PrimUnfm80.resize(nBCinTF / bcGrouping); + vecRobustOccFDDT0V0PrimUnfm80medianPosVec.resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsNtrackDet || buildFlag02OccRobustTable || buildFlag03OccMeanRobustTable) { + vecRobustOccNtrackDetUnfm80.resize(nBCinTF / bcGrouping); + vecRobustOccNtrackDetUnfm80medianPosVec.resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsMultExtra || buildFlag02OccRobustTable || buildFlag03OccMeanRobustTable) { + vecRobustOccmultTableUnfm80.resize(nBCinTF / bcGrouping); + vecRobustOccmultTableUnfm80medianPosVec.resize(nBCinTF / bcGrouping); + } + + // Getting Info from CCDB, to be implemented Later + recoEvent.add("h_nBCinTF", "h_nBCinTF(to check nBCinTF)", {HistType::kTH1F, {{100, 114040, 114060}}}); // 114048 + recoEvent.add("h_bcInTF", "h_bcInTF", {HistType::kTH1F, {{2000, 0, 200000}}}); + recoEvent.add("h_RO_T0V0PrimUnfm80", "h_RO_T0V0PrimUnfm80:median contributors", {HistType::kTH1F, {{12 * 2, -1, 11}}}); + recoEvent.add("h_RO_FDDT0V0PrimUnfm80", "h_RO_FDDT0V0PrimUnfm80:median contributors", {HistType::kTH1F, {{12 * 2, -1, 11}}}); + recoEvent.add("h_RO_NtrackDetUnfm80", "h_RO_NtrackDetITS/TPC/TRD/TOF_80:median contributors", {HistType::kTH1F, {{12 * 2, -1, 11}}}); + recoEvent.add("h_RO_multTableUnfm80", "h_RO_multTableExtra_80:median contributors", {HistType::kTH1F, {{12 * 2, -1, 11}}}); + occupancyQA.add("h_TF_in_DataFrame", "h_TF_in_DataFrame", kTH1F, {{50, -1, 49}}); + occupancyQA.add("h_DFcount_Lvl0", "h_DFcount_Lvl0", kTH1F, {{1, 0, 1}}); + occupancyQA.add("h_DFcount_Lvl1", "h_DFcount_Lvl1", kTH1F, {{1, 0, 1}}); + occupancyQA.add("h_DFcount_Lvl2", "h_DFcount_Lvl2", kTH1F, {{1, 0, 1}}); + + recoEvent.print(); + occupancyQA.print(); + } + + void normalizeVector(std::vector& OriginalVec, const float& scaleFactor) + { + std::transform(OriginalVec.begin(), OriginalVec.end(), OriginalVec.begin(), [scaleFactor](float x) { return x * scaleFactor; }); + } + + template + void getMedianOccVect( + std::vector& medianVector, + std::vector>& medianPosVec, + const Vecs&... vectors) + { + const int n = sizeof...(Vecs); // Number of vectors + const int size = std::get<0>(std::tie(vectors...)).size(); // Size of the first vector + + for (int i = 0; i < size; i++) { + std::vector> data; // first element is entry, second is index + int iEntry = 0; + + // Lambda to iterate over all vectors + auto collect = [&](const auto& vec) { + data.push_back({vec[i], static_cast(iEntry)}); + iEntry++; + }; + (collect(vectors), ...); // Unpack variadic arguments and apply lambda + + // Sort the data + std::sort(data.begin(), data.end(), [](const std::array& a, const std::array& b) { + return a[0] < b[0]; + }); + + double median; + int two = 2; + // Find the median + if (n % two == 0) { + median = (data[(n - 1) / 2][0] + data[(n - 1) / 2 + 1][0]) / 2; + medianPosVec[i][0] = static_cast(data[(n - 1) / 2][1] + 0.001); + medianPosVec[i][1] = static_cast(data[(n - 1) / 2 + 1][1] + 0.001); + } else { + median = data[n / 2][0]; + medianPosVec[i][0] = static_cast(data[n / 2][1] + 0.001); + medianPosVec[i][1] = -10; // For odd entries, only one value can be the median + } + medianVector[i] = median; + } + } + + void getRunInfo(const int& run, int& nBCsPerTF, int64_t& bcSOR) + { + auto runDuration = ccdb->getRunDuration(run, true); + int64_t tsSOR = runDuration.first; + auto ctpx = ccdb->getForTimeStamp>("CTP/Calib/OrbitReset", tsSOR); + int64_t tsOrbitReset = (*ctpx)[0]; + uint32_t nOrbitsPerTF = run < cfgNOrbitsPerTF0RunValue ? cfgNOrbitsPerTF1TrueValue : cfgNOrbitsPerTF2FalseValue; + int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; + orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF; + bcSOR = orbitSOR * nBCsPerOrbit + customOrbitOffset * nBCsPerOrbit; // customOrbitOffset is a configurable + nBCsPerTF = nOrbitsPerTF * nBCsPerOrbit; + } + + template + void getTimingInfo(const T& bc, int& lastRun, int32_t& nBCsPerTF, int64_t& bcSOR, uint64_t& time, int64_t& tfIdThis, int& bcInTF) + { + int run = bc.runNumber(); + if (run != lastRun) { // update run info + lastRun = run; + getRunInfo(run, nBCsPerTF, bcSOR); // update nBCsPerTF && bcSOR + } + // update the information + time = bc.timestamp(); + tfIdThis = (bc.globalBC() - bcSOR) / nBCsPerTF; + bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; + } + + using MyTracks = aod::Tracks; + + Preslice tracksPerCollisionPreslice = o2::aod::track::collisionId; + + int dfCount = 0; + int32_t nBCsPerTF = -999; + int64_t bcSOR = -999; + uint64_t time = -1; + int64_t tfIdThis = -1; + int bcInTF = -1; + uint tfCounted = 0; + int tfIDX = 0; + int lastRun = -999; + //_________________________Full Exection Function_______________________________________________________________________________________ + + enum ProcessTags { + kProcessOnlyBCTFinfoTable = 0, + kProcessOnlyOccPrim, + kProcessOnlyOccT0V0Prim, + kProcessOnlyOccFDDT0V0Prim, + kProcessOnlyOccNtrackDet, + kProcessOnlyOccMultExtra, + kProcessFullOccTableProducer + }; + + static constexpr std::string_view ProcessNames[]{ + "processOnlyBCTFinfoTable", + "processOnlyOccPrimUnfm", + "processOnlyOccT0V0PrimUnfm", + "processOnlyOccFDDT0V0PrimUnfm", + "processOnlyOccNtrackDet", + "processOnlyOccMultExtra", + "processFullOccTableProduer"}; + + enum FillMode { + checkTableMode = 0, + doNotFill, + fillOccTable, + fillMeanOccTable, + fillOccRobustTable, + fillOccMeanRobustTable + }; + + template + void executeCollisionCheckAndBCprocessing(B const& BCs, C const& collisions, bool& collisionsSizeIsZero) + { + if (collisions.size() == 0) { + for (const auto& BC : BCs) { // For BCs and OccIndexTable to have same size for joining + getTimingInfo(BC, lastRun, nBCsPerTF, bcSOR, time, tfIdThis, bcInTF); + genBCTFinfoTable(tfIdThis, bcInTF); + genOccIndexTable(BC.globalIndex(), -999); // BCId, OccId + } + collisionsSizeIsZero = true; + } + } + + int processTimeCounter = 0; + template + void executeOccProducerProcessing(B const& BCs, C const& collisions, T const& tracks) + { + if (tableMode == checkTableMode) { + if (buildFlag00OccTable) { + executeOccProducerProcessing(BCs, collisions, tracks); + } else { + executeOccProducerProcessing(BCs, collisions, tracks); + } + } + if constexpr (tableMode == checkTableMode) { + return; + } + + if (meanTableMode == checkTableMode) { + if (buildFlag01OccMeanTable) { + executeOccProducerProcessing(BCs, collisions, tracks); + } else { + executeOccProducerProcessing(BCs, collisions, tracks); + } + } + if constexpr (meanTableMode == checkTableMode) { + return; + } + + if (robustTableMode == checkTableMode) { + if (buildFlag02OccRobustTable) { + executeOccProducerProcessing(BCs, collisions, tracks); + } else { + executeOccProducerProcessing(BCs, collisions, tracks); + } + } + if constexpr (robustTableMode == checkTableMode) { + return; + } + + if (meanRobustTableMode == checkTableMode) { + if (buildFlag03OccMeanRobustTable) { + executeOccProducerProcessing(BCs, collisions, tracks); + } else { + executeOccProducerProcessing(BCs, collisions, tracks); + } + } + if constexpr (meanRobustTableMode == checkTableMode) { + return; + } + + if constexpr (tableMode == checkTableMode || meanTableMode == checkTableMode || robustTableMode == checkTableMode || meanRobustTableMode == checkTableMode) { + return; + } else { + + occupancyQA.fill(HIST("h_DFcount_Lvl2"), 0.5); + + // Initialisze the vectors components to zero + tfIDX = 0; + tfCounted = 0; + for (int i = 0; i < occVecArraySize; i++) { + tfList[i] = -1; + bcTFMap[i].clear(); // list of BCs used in one time frame; + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccPrim || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim || processMode == kProcessOnlyOccNtrackDet || processMode == kProcessOnlyOccMultExtra) { + std::fill(occPrimUnfm80[i].begin(), occPrimUnfm80[i].end(), 0.); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim) { + std::fill(occFV0AUnfm80[i].begin(), occFV0AUnfm80[i].end(), 0.); + std::fill(occFV0CUnfm80[i].begin(), occFV0CUnfm80[i].end(), 0.); + std::fill(occFT0AUnfm80[i].begin(), occFT0AUnfm80[i].end(), 0.); + std::fill(occFT0CUnfm80[i].begin(), occFT0CUnfm80[i].end(), 0.); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccFDDT0V0Prim) { + std::fill(occFDDAUnfm80[i].begin(), occFDDAUnfm80[i].end(), 0.); + std::fill(occFDDCUnfm80[i].begin(), occFDDCUnfm80[i].end(), 0.); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet) { + std::fill(occNTrackITSUnfm80[i].begin(), occNTrackITSUnfm80[i].end(), 0.); + std::fill(occNTrackTPCUnfm80[i].begin(), occNTrackTPCUnfm80[i].end(), 0.); + std::fill(occNTrackTRDUnfm80[i].begin(), occNTrackTRDUnfm80[i].end(), 0.); + std::fill(occNTrackTOFUnfm80[i].begin(), occNTrackTOFUnfm80[i].end(), 0.); + std::fill(occNTrackSizeUnfm80[i].begin(), occNTrackSizeUnfm80[i].end(), 0.); + std::fill(occNTrackTPCAUnfm80[i].begin(), occNTrackTPCAUnfm80[i].end(), 0.); + std::fill(occNTrackTPCCUnfm80[i].begin(), occNTrackTPCCUnfm80[i].end(), 0.); + std::fill(occNTrackITSTPCAUnfm80[i].begin(), occNTrackITSTPCAUnfm80[i].end(), 0.); + std::fill(occNTrackITSTPCCUnfm80[i].begin(), occNTrackITSTPCCUnfm80[i].end(), 0.); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet || processMode == kProcessOnlyOccMultExtra) { + std::fill(occNTrackITSTPCUnfm80[i].begin(), occNTrackITSTPCUnfm80[i].end(), 0.); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccMultExtra) { + std::fill(occMultNTracksHasITSUnfm80[i].begin(), occMultNTracksHasITSUnfm80[i].end(), 0.); + std::fill(occMultNTracksHasTPCUnfm80[i].begin(), occMultNTracksHasTPCUnfm80[i].end(), 0.); + std::fill(occMultNTracksHasTOFUnfm80[i].begin(), occMultNTracksHasTOFUnfm80[i].end(), 0.); + std::fill(occMultNTracksHasTRDUnfm80[i].begin(), occMultNTracksHasTRDUnfm80[i].end(), 0.); + std::fill(occMultNTracksITSOnlyUnfm80[i].begin(), occMultNTracksITSOnlyUnfm80[i].end(), 0.); + std::fill(occMultNTracksTPCOnlyUnfm80[i].begin(), occMultNTracksTPCOnlyUnfm80[i].end(), 0.); + std::fill(occMultNTracksITSTPCUnfm80[i].begin(), occMultNTracksITSTPCUnfm80[i].end(), 0.); + std::fill(occMultAllTracksTPCOnlyUnfm80[i].begin(), occMultAllTracksTPCOnlyUnfm80[i].end(), 0.); + } + } + + std::vector tfIDList; + int nTrackITS = 0; + int nTrackTPC = 0; + int nTrackTRD = 0; + int nTrackTOF = 0; + int nTrackTPCA = 0; + int nTrackTPCC = 0; + int nTrackITSTPCA = 0; + int nTrackITSTPCC = 0; + + ushort fNumContrib = 0; + + float fMultFV0A = -99999, fMultFV0C = -99999; + float fMultFT0A = -99999, fMultFT0C = -99999; + float fMultFDDA = -99999, fMultFDDC = -99999; + + int fNTrackITS = -9999; + int fNTrackTPC = -9999; + int fNTrackTRD = -9999; + int fNTrackTOF = -9999; + int fNTrackTPCA = -9999; + int fNTrackTPCC = -9999; + int fNTrackSize = -9999; + int fNTrackITSTPC = -9999; + int fNTrackITSTPCA = -9999; + int fNTrackITSTPCC = -9999; + + decltype(&occPrimUnfm80[0]) tfOccPrimUnfm80 = nullptr; + decltype(&occFV0AUnfm80[0]) tfOccFV0AUnfm80 = nullptr; + decltype(&occFV0CUnfm80[0]) tfOccFV0CUnfm80 = nullptr; + decltype(&occFT0AUnfm80[0]) tfOccFT0AUnfm80 = nullptr; + decltype(&occFT0CUnfm80[0]) tfOccFT0CUnfm80 = nullptr; + + decltype(&occFDDAUnfm80[0]) tfOccFDDAUnfm80 = nullptr; + decltype(&occFDDCUnfm80[0]) tfOccFDDCUnfm80 = nullptr; + + decltype(&occNTrackITSTPCUnfm80[0]) tfOccNTrackITSTPCUnfm80 = nullptr; + + decltype(&occNTrackITSUnfm80[0]) tfOccNTrackITSUnfm80 = nullptr; + decltype(&occNTrackTPCUnfm80[0]) tfOccNTrackTPCUnfm80 = nullptr; + decltype(&occNTrackTRDUnfm80[0]) tfOccNTrackTRDUnfm80 = nullptr; + decltype(&occNTrackTOFUnfm80[0]) tfOccNTrackTOFUnfm80 = nullptr; + decltype(&occNTrackSizeUnfm80[0]) tfOccNTrackSizeUnfm80 = nullptr; + decltype(&occNTrackTPCAUnfm80[0]) tfOccNTrackTPCAUnfm80 = nullptr; + decltype(&occNTrackTPCCUnfm80[0]) tfOccNTrackTPCCUnfm80 = nullptr; + decltype(&occNTrackITSTPCAUnfm80[0]) tfOccNTrackITSTPCAUnfm80 = nullptr; + decltype(&occNTrackITSTPCCUnfm80[0]) tfOccNTrackITSTPCCUnfm80 = nullptr; + + decltype(&occMultNTracksHasITSUnfm80[0]) tfOccMultNTracksHasITSUnfm80 = nullptr; + decltype(&occMultNTracksHasTPCUnfm80[0]) tfOccMultNTracksHasTPCUnfm80 = nullptr; + decltype(&occMultNTracksHasTOFUnfm80[0]) tfOccMultNTracksHasTOFUnfm80 = nullptr; + decltype(&occMultNTracksHasTRDUnfm80[0]) tfOccMultNTracksHasTRDUnfm80 = nullptr; + decltype(&occMultNTracksITSOnlyUnfm80[0]) tfOccMultNTracksITSOnlyUnfm80 = nullptr; + decltype(&occMultNTracksTPCOnlyUnfm80[0]) tfOccMultNTracksTPCOnlyUnfm80 = nullptr; + decltype(&occMultNTracksITSTPCUnfm80[0]) tfOccMultNTracksITSTPCUnfm80 = nullptr; + decltype(&occMultAllTracksTPCOnlyUnfm80[0]) tfOccMultAllTracksTPCOnlyUnfm80 = nullptr; + + for (const auto& collision : collisions) { + const auto& bc = collision.template bc_as(); + getTimingInfo(bc, lastRun, nBCsPerTF, bcSOR, time, tfIdThis, bcInTF); + + recoEvent.fill(HIST("h_nBCinTF"), nBCsPerTF); + recoEvent.fill(HIST("h_bcInTF"), bcInTF); + + if (nBCsPerTF > nBCinTF) { + LOG(error) << "DEBUG :: FATAL ERROR :: nBCsPerTF > nBCinTF i.e " << nBCsPerTF << " > " << nBCinTF << " will cause crash in further process"; + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet) { + const uint64_t collIdx = collision.globalIndex(); + const auto tracksTablePerColl = tracks.sliceBy(tracksPerCollisionPreslice, collIdx); + + fNTrackSize = tracksTablePerColl.size(); + + nTrackITS = 0; + nTrackTPC = 0; + nTrackTRD = 0; + nTrackTOF = 0; + nTrackTPCA = 0; + nTrackTPCC = 0; + nTrackITSTPCA = 0; + nTrackITSTPCC = 0; + for (const auto& track : tracksTablePerColl) { + if (track.hasITS()) { + nTrackITS++; + } // Flag to check if track has a ITS match + if (track.hasTPC()) { + nTrackTPC++; + if (track.eta() <= 0.0) { + nTrackTPCA++; // includes tracks at eta zero as well. + } else { + nTrackTPCC++; + } + } // Flag to check if track has a TPC match + if (track.hasTRD()) { + nTrackTRD++; + } // Flag to check if track has a TRD match + if (track.hasTOF()) { + nTrackTOF++; + } // Flag to check if track has a TOF measurement + if (track.hasITS() && track.hasTPC()) { + if (track.eta() <= 0.0) { + nTrackITSTPCA++; // includes tracks at eta zero as well. + } else { + nTrackITSTPCC++; + } + } + } // track loop + } + // if (collision.multNTracksTPCOnly() != 0) { + // LOG(error) << "DEBUG :: ERROR = multNTracksTPCOnly != 0" << collision.multNTracksTPCOnly(); + // return; + // } + // if (collision.multAllTracksITSTPC() != nTrackITSTPC) { + // LOG(error) << "DEBUG :: ERROR :: 10 multAllTracksITSTPC :: " << collision.multAllTracksITSTPC() << " != " << nTrackITSTPC; + // return; + // } + + tfIDList.push_back(tfIdThis); + + if (tfList[tfIDX] != tfIdThis) { + if (tfCounted != 0) { + tfIDX++; + } // + tfList[tfIDX] = tfIdThis; + tfCounted++; + } + + bcTFMap[tfIDX].push_back(bc.globalIndex()); + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccPrim || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim || processMode == kProcessOnlyOccNtrackDet || processMode == kProcessOnlyOccMultExtra) { + tfOccPrimUnfm80 = &occPrimUnfm80[tfIDX]; + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim) { + tfOccFV0AUnfm80 = &occFV0AUnfm80[tfIDX]; + tfOccFV0CUnfm80 = &occFV0CUnfm80[tfIDX]; + tfOccFT0AUnfm80 = &occFT0AUnfm80[tfIDX]; + tfOccFT0CUnfm80 = &occFT0CUnfm80[tfIDX]; + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccFDDT0V0Prim) { + tfOccFDDAUnfm80 = &occFDDAUnfm80[tfIDX]; + tfOccFDDCUnfm80 = &occFDDCUnfm80[tfIDX]; + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet) { + tfOccNTrackITSUnfm80 = &occNTrackITSUnfm80[tfIDX]; + tfOccNTrackTPCUnfm80 = &occNTrackTPCUnfm80[tfIDX]; + tfOccNTrackTRDUnfm80 = &occNTrackTRDUnfm80[tfIDX]; + tfOccNTrackTOFUnfm80 = &occNTrackTOFUnfm80[tfIDX]; + tfOccNTrackSizeUnfm80 = &occNTrackSizeUnfm80[tfIDX]; + tfOccNTrackTPCAUnfm80 = &occNTrackTPCAUnfm80[tfIDX]; + tfOccNTrackTPCCUnfm80 = &occNTrackTPCCUnfm80[tfIDX]; + tfOccNTrackITSTPCAUnfm80 = &occNTrackITSTPCAUnfm80[tfIDX]; + tfOccNTrackITSTPCCUnfm80 = &occNTrackITSTPCCUnfm80[tfIDX]; + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet || processMode == kProcessOnlyOccMultExtra) { + tfOccNTrackITSTPCUnfm80 = &occNTrackITSTPCUnfm80[tfIDX]; + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccMultExtra) { + tfOccMultNTracksHasITSUnfm80 = &occMultNTracksHasITSUnfm80[tfIDX]; + tfOccMultNTracksHasTPCUnfm80 = &occMultNTracksHasTPCUnfm80[tfIDX]; + tfOccMultNTracksHasTOFUnfm80 = &occMultNTracksHasTOFUnfm80[tfIDX]; + tfOccMultNTracksHasTRDUnfm80 = &occMultNTracksHasTRDUnfm80[tfIDX]; + tfOccMultNTracksITSOnlyUnfm80 = &occMultNTracksITSOnlyUnfm80[tfIDX]; + tfOccMultNTracksTPCOnlyUnfm80 = &occMultNTracksTPCOnlyUnfm80[tfIDX]; + tfOccMultNTracksITSTPCUnfm80 = &occMultNTracksITSTPCUnfm80[tfIDX]; + tfOccMultAllTracksTPCOnlyUnfm80 = &occMultAllTracksTPCOnlyUnfm80[tfIDX]; + } + + // current collision bin in 80/160 bcGrouping. + int bin80Zero = bcInTF / bcGrouping; + // int bin160_0=bcInTF/160; + + // float fbin80Zero =float(bcInTF)/80; + // float fbin160_0=float(bcInTF)/160; + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccPrim || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim || processMode == kProcessOnlyOccNtrackDet || processMode == kProcessOnlyOccMultExtra) { + fNumContrib = collision.numContrib(); // only aod::Collisions will be needed + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim) { + fMultFV0A = collision.multFV0A(); + fMultFV0C = collision.multFV0C(); // o2::aod::Mults will be needed + fMultFT0A = collision.multFT0A(); + fMultFT0C = collision.multFT0C(); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccFDDT0V0Prim) { + fMultFDDA = collision.multFDDA(); + fMultFDDC = collision.multFDDC(); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet) { + fNTrackITS = nTrackITS; + fNTrackTPC = nTrackTPC; + fNTrackTRD = nTrackTRD; + fNTrackTOF = nTrackTOF; + fNTrackTPCA = nTrackTPCA; + fNTrackTPCC = nTrackTPCC; + fNTrackITSTPC = collision.multAllTracksITSTPC(); + fNTrackITSTPCA = nTrackITSTPCA; + fNTrackITSTPCC = nTrackITSTPCC; + } + // Processing for bcGrouping of 80 BCs + for (int deltaBin = 0; deltaBin < nBCinDrift / bcGrouping; deltaBin++) { + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccPrim || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim || processMode == kProcessOnlyOccNtrackDet || processMode == kProcessOnlyOccMultExtra) { + (*tfOccPrimUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNumContrib * 1; + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim) { + (*tfOccFV0AUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fMultFV0A * 1; + (*tfOccFV0CUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fMultFV0C * 1; + (*tfOccFT0AUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fMultFT0A * 1; + (*tfOccFT0CUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fMultFT0C * 1; + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccFDDT0V0Prim) { + (*tfOccFDDAUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fMultFDDA * 1; + (*tfOccFDDCUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fMultFDDC * 1; + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet) { + (*tfOccNTrackITSUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackITS * 1; + (*tfOccNTrackTPCUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackTPC * 1; + (*tfOccNTrackTRDUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackTRD * 1; + (*tfOccNTrackTOFUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackTOF * 1; + (*tfOccNTrackSizeUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackSize * 1; + (*tfOccNTrackTPCAUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackTPCA * 1; + (*tfOccNTrackTPCCUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackTPCC * 1; + (*tfOccNTrackITSTPCAUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackITSTPCA * 1; + (*tfOccNTrackITSTPCCUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackITSTPCC * 1; + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet || processMode == kProcessOnlyOccMultExtra) { + (*tfOccNTrackITSTPCUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += fNTrackITSTPC * 1; + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccMultExtra) { + (*tfOccMultNTracksHasITSUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += collision.multNTracksHasITS() * 1; + (*tfOccMultNTracksHasTPCUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += collision.multNTracksHasTPC() * 1; + (*tfOccMultNTracksHasTOFUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += collision.multNTracksHasTOF() * 1; + (*tfOccMultNTracksHasTRDUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += collision.multNTracksHasTRD() * 1; + (*tfOccMultNTracksITSOnlyUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += collision.multNTracksITSOnly() * 1; + (*tfOccMultNTracksTPCOnlyUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += collision.multNTracksTPCOnly() * 1; + (*tfOccMultNTracksITSTPCUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += collision.multNTracksITSTPC() * 1; + (*tfOccMultAllTracksTPCOnlyUnfm80)[(bin80Zero + deltaBin) % (nBCinTF / bcGrouping)] += collision.multAllTracksTPCOnly() * 1; + } + } + } + // collision Loop is over + + occupancyQA.fill(HIST("h_TF_in_DataFrame"), tfCounted); + + std::vector sortedTfIDList = tfIDList; + std::sort(sortedTfIDList.begin(), sortedTfIDList.end()); + auto last = std::unique(sortedTfIDList.begin(), sortedTfIDList.end()); + sortedTfIDList.erase(last, sortedTfIDList.end()); + + if (tfCounted != sortedTfIDList.size()) { + LOG(error) << "DEBUG :: Number mismatch for tf counted and filled :: " << tfCounted << " != " << sortedTfIDList.size(); + } + + int totalBCcountSize = 0; + for (int i = 0; i < occVecArraySize; i++) { + totalBCcountSize += bcTFMap[i].size(); + // check if the BCs are already sorted or not + if (!std::is_sorted(bcTFMap[i].begin(), bcTFMap[i].end())) { + LOG(debug) << "DEBUG :: ERROR :: BCs are not sorted"; + } + } + // + if (totalBCcountSize != collisions.size()) { + LOG(debug) << "DEBUG :: ERROR :: filled TF list and collision size mismatch :: filledTF_Size = " << totalBCcountSize << " != " << collisions.size() << " = collisions.size()"; + } + + // Fill the Producers + for (uint i = 0; i < tfCounted; i++) { + + genOccsBCsList(tfList[i], bcTFMap[i]); + + auto& vecOccPrimUnfm80 = occPrimUnfm80[i]; + float meanOccPrimUnfm80 = TMath::Mean(vecOccPrimUnfm80.size(), vecOccPrimUnfm80.data()); + normalizeVector(vecOccPrimUnfm80, meanOccPrimUnfm80 / meanOccPrimUnfm80); + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccPrim || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim || processMode == kProcessOnlyOccNtrackDet || processMode == kProcessOnlyOccMultExtra) { + if constexpr (tableMode == fillOccTable) { + genOccsPrim(vecOccPrimUnfm80); + } + if constexpr (meanTableMode == fillMeanOccTable) { + genOccsMeanPrim(meanOccPrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim) { + auto& vecOccFV0AUnfm80 = occFV0AUnfm80[i]; + auto& vecOccFV0CUnfm80 = occFV0CUnfm80[i]; + auto& vecOccFT0AUnfm80 = occFT0AUnfm80[i]; + auto& vecOccFT0CUnfm80 = occFT0CUnfm80[i]; + + float meanOccFV0AUnfm80 = TMath::Mean(vecOccFV0AUnfm80.size(), vecOccFV0AUnfm80.data()); + float meanOccFV0CUnfm80 = TMath::Mean(vecOccFV0CUnfm80.size(), vecOccFV0CUnfm80.data()); + float meanOccFT0AUnfm80 = TMath::Mean(vecOccFT0AUnfm80.size(), vecOccFT0AUnfm80.data()); + float meanOccFT0CUnfm80 = TMath::Mean(vecOccFT0CUnfm80.size(), vecOccFT0CUnfm80.data()); + + // Normalise the original vectors + normalizeVector(vecOccFV0AUnfm80, meanOccPrimUnfm80 / meanOccFV0AUnfm80); + normalizeVector(vecOccFV0CUnfm80, meanOccPrimUnfm80 / meanOccFV0CUnfm80); + normalizeVector(vecOccFT0AUnfm80, meanOccPrimUnfm80 / meanOccFT0AUnfm80); + normalizeVector(vecOccFT0CUnfm80, meanOccPrimUnfm80 / meanOccFT0CUnfm80); + + // Find Robust estimators + // T0A, T0C, V0A, Prim + if constexpr (robustTableMode == fillOccRobustTable || meanRobustTableMode == fillOccMeanRobustTable) { + getMedianOccVect(vecRobustOccT0V0PrimUnfm80, vecRobustOccT0V0PrimUnfm80medianPosVec, + vecOccPrimUnfm80, vecOccFV0AUnfm80, vecOccFT0AUnfm80, vecOccFT0CUnfm80); + for (const auto& vec : vecRobustOccT0V0PrimUnfm80medianPosVec) { + recoEvent.fill(HIST("h_RO_T0V0PrimUnfm80"), vec[0]); + recoEvent.fill(HIST("h_RO_T0V0PrimUnfm80"), vec[1]); + } + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccT0V0Prim || processMode == kProcessOnlyOccFDDT0V0Prim) { + if constexpr (tableMode == fillOccTable) { + genOccsT0V0(vecOccFV0AUnfm80, vecOccFV0CUnfm80, vecOccFT0AUnfm80, vecOccFT0CUnfm80); + } + if constexpr (meanTableMode == fillMeanOccTable) { + genOccsMeanT0V0(meanOccFV0AUnfm80, meanOccFV0CUnfm80, meanOccFT0AUnfm80, meanOccFT0CUnfm80); + } + if constexpr (robustTableMode == fillOccRobustTable) { + genORT0V0Prim(vecRobustOccT0V0PrimUnfm80); + } + if constexpr (meanRobustTableMode == fillOccMeanRobustTable) { + genOccsMeanRobustT0V0Prim(TMath::Mean(vecRobustOccT0V0PrimUnfm80.size(), vecRobustOccT0V0PrimUnfm80.data())); + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccFDDT0V0Prim) { + auto& vecOccFDDAUnfm80 = occFDDAUnfm80[i]; + auto& vecOccFDDCUnfm80 = occFDDCUnfm80[i]; + float meanOccFDDAUnfm80 = TMath::Mean(vecOccFDDAUnfm80.size(), vecOccFDDAUnfm80.data()); + float meanOccFDDCUnfm80 = TMath::Mean(vecOccFDDCUnfm80.size(), vecOccFDDCUnfm80.data()); + normalizeVector(vecOccFDDAUnfm80, meanOccPrimUnfm80 / meanOccFDDAUnfm80); + normalizeVector(vecOccFDDCUnfm80, meanOccPrimUnfm80 / meanOccFDDCUnfm80); + + // T0A, T0C, V0A, FDD, Prim + if constexpr (robustTableMode == fillOccRobustTable || meanRobustTableMode == fillOccMeanRobustTable) { + getMedianOccVect(vecRobustOccFDDT0V0PrimUnfm80, vecRobustOccFDDT0V0PrimUnfm80medianPosVec, + vecOccPrimUnfm80, vecOccFV0AUnfm80, vecOccFT0AUnfm80, vecOccFT0CUnfm80, vecOccFDDAUnfm80, vecOccFDDCUnfm80); + for (const auto& vec : vecRobustOccFDDT0V0PrimUnfm80medianPosVec) { + recoEvent.fill(HIST("h_RO_FDDT0V0PrimUnfm80"), vec[0]); + recoEvent.fill(HIST("h_RO_FDDT0V0PrimUnfm80"), vec[1]); + } + + if constexpr (tableMode == fillOccTable) { + genOccsFDD(vecOccFDDAUnfm80, vecOccFDDCUnfm80); + } + if constexpr (meanTableMode == fillMeanOccTable) { + genOccsMeanFDD(meanOccFDDAUnfm80, meanOccFDDCUnfm80); + } + if constexpr (robustTableMode == fillOccRobustTable) { + genORFDDT0V0Prim(vecRobustOccFDDT0V0PrimUnfm80); + } + if constexpr (meanRobustTableMode == fillOccMeanRobustTable) { + genOccsMeanRobustFDDT0V0Prim(TMath::Mean(vecRobustOccFDDT0V0PrimUnfm80.size(), vecRobustOccFDDT0V0PrimUnfm80.data())); + } + } + } // Block for FDDT0V0Prim + } // For T0V0Prim only and FDDT0V0Prim + } // Detector Occupancy block + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet) { + // NTrackDet + auto& vecOccNTrackITSUnfm80 = occNTrackITSUnfm80[i]; + auto& vecOccNTrackTPCUnfm80 = occNTrackTPCUnfm80[i]; + auto& vecOccNTrackTRDUnfm80 = occNTrackTRDUnfm80[i]; + auto& vecOccNTrackTOFUnfm80 = occNTrackTOFUnfm80[i]; + auto& vecOccNTrackSizeUnfm80 = occNTrackSizeUnfm80[i]; + auto& vecOccNTrackTPCAUnfm80 = occNTrackTPCAUnfm80[i]; + auto& vecOccNTrackTPCCUnfm80 = occNTrackTPCCUnfm80[i]; + auto& vecOccNTrackITSTPCUnfm80 = occNTrackITSTPCUnfm80[i]; + auto& vecOccNTrackITSTPCAUnfm80 = occNTrackITSTPCAUnfm80[i]; + auto& vecOccNTrackITSTPCCUnfm80 = occNTrackITSTPCCUnfm80[i]; + float meanOccNTrackITSUnfm80 = TMath::Mean(vecOccNTrackITSUnfm80.size(), vecOccNTrackITSUnfm80.data()); + float meanOccNTrackTPCUnfm80 = TMath::Mean(vecOccNTrackTPCUnfm80.size(), vecOccNTrackTPCUnfm80.data()); + float meanOccNTrackTRDUnfm80 = TMath::Mean(vecOccNTrackTRDUnfm80.size(), vecOccNTrackTRDUnfm80.data()); + float meanOccNTrackTOFUnfm80 = TMath::Mean(vecOccNTrackTOFUnfm80.size(), vecOccNTrackTOFUnfm80.data()); + float meanOccNTrackSizeUnfm80 = TMath::Mean(vecOccNTrackSizeUnfm80.size(), vecOccNTrackSizeUnfm80.data()); + float meanOccNTrackTPCAUnfm80 = TMath::Mean(vecOccNTrackTPCAUnfm80.size(), vecOccNTrackTPCAUnfm80.data()); + float meanOccNTrackTPCCUnfm80 = TMath::Mean(vecOccNTrackTPCCUnfm80.size(), vecOccNTrackTPCCUnfm80.data()); + float meanOccNTrackITSTPCUnfm80 = TMath::Mean(vecOccNTrackITSTPCUnfm80.size(), vecOccNTrackITSTPCUnfm80.data()); + float meanOccNTrackITSTPCAUnfm80 = TMath::Mean(vecOccNTrackITSTPCAUnfm80.size(), vecOccNTrackITSTPCAUnfm80.data()); + float meanOccNTrackITSTPCCUnfm80 = TMath::Mean(vecOccNTrackITSTPCCUnfm80.size(), vecOccNTrackITSTPCCUnfm80.data()); + + normalizeVector(vecOccNTrackITSUnfm80, meanOccPrimUnfm80 / meanOccNTrackITSUnfm80); + normalizeVector(vecOccNTrackTPCUnfm80, meanOccPrimUnfm80 / meanOccNTrackTPCUnfm80); + normalizeVector(vecOccNTrackTRDUnfm80, meanOccPrimUnfm80 / meanOccNTrackTRDUnfm80); + normalizeVector(vecOccNTrackTOFUnfm80, meanOccPrimUnfm80 / meanOccNTrackTOFUnfm80); + normalizeVector(vecOccNTrackSizeUnfm80, meanOccPrimUnfm80 / meanOccNTrackSizeUnfm80); + normalizeVector(vecOccNTrackTPCAUnfm80, meanOccPrimUnfm80 / meanOccNTrackTPCAUnfm80); + normalizeVector(vecOccNTrackTPCCUnfm80, meanOccPrimUnfm80 / meanOccNTrackTPCCUnfm80); + normalizeVector(vecOccNTrackITSTPCUnfm80, meanOccPrimUnfm80 / meanOccNTrackITSTPCUnfm80); + normalizeVector(vecOccNTrackITSTPCAUnfm80, meanOccPrimUnfm80 / meanOccNTrackITSTPCAUnfm80); + normalizeVector(vecOccNTrackITSTPCCUnfm80, meanOccPrimUnfm80 / meanOccNTrackITSTPCCUnfm80); + + if constexpr (robustTableMode == fillOccRobustTable || meanRobustTableMode == fillOccMeanRobustTable) { + getMedianOccVect(vecRobustOccNtrackDetUnfm80, vecRobustOccNtrackDetUnfm80medianPosVec, + vecOccNTrackITSUnfm80, vecOccNTrackTPCUnfm80, vecOccNTrackTRDUnfm80, vecOccNTrackTOFUnfm80); + for (const auto& vec : vecRobustOccNtrackDetUnfm80medianPosVec) { + recoEvent.fill(HIST("h_RO_NtrackDetUnfm80"), vec[0]); + recoEvent.fill(HIST("h_RO_NtrackDetUnfm80"), vec[1]); + } + } + + if constexpr (tableMode == fillOccTable) { + genOccsNTrackDet(vecOccNTrackITSUnfm80, vecOccNTrackTPCUnfm80, + vecOccNTrackTRDUnfm80, vecOccNTrackTOFUnfm80, + vecOccNTrackSizeUnfm80, vecOccNTrackTPCAUnfm80, + vecOccNTrackTPCCUnfm80, vecOccNTrackITSTPCUnfm80, + vecOccNTrackITSTPCAUnfm80, vecOccNTrackITSTPCCUnfm80); + } + if constexpr (meanTableMode == fillMeanOccTable) { + genOccsMeanNTrkDet(meanOccNTrackITSUnfm80, meanOccNTrackTPCUnfm80, + meanOccNTrackTRDUnfm80, meanOccNTrackTOFUnfm80, + meanOccNTrackSizeUnfm80, meanOccNTrackTPCAUnfm80, + meanOccNTrackTPCCUnfm80, meanOccNTrackITSTPCUnfm80, + meanOccNTrackITSTPCAUnfm80, meanOccNTrackITSTPCCUnfm80); + } + if constexpr (robustTableMode == fillOccRobustTable) { + genORNtrackDet(vecRobustOccNtrackDetUnfm80); + } + if constexpr (meanRobustTableMode == fillOccMeanRobustTable) { + genOccsMeanRobustNtrackDet(TMath::Mean(vecRobustOccNtrackDetUnfm80.size(), vecRobustOccNtrackDetUnfm80.data())); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccMultExtra) { + auto& vecOccNTrackITSTPCUnfm80 = occNTrackITSTPCUnfm80[i]; + float meanOccNTrackITSTPCUnfm80 = TMath::Mean(vecOccNTrackITSTPCUnfm80.size(), vecOccNTrackITSTPCUnfm80.data()); + normalizeVector(vecOccNTrackITSTPCUnfm80, meanOccPrimUnfm80 / meanOccNTrackITSTPCUnfm80); + + auto& vecOccMultNTracksHasITSUnfm80 = occMultNTracksHasITSUnfm80[i]; + auto& vecOccMultNTracksHasTPCUnfm80 = occMultNTracksHasTPCUnfm80[i]; + auto& vecOccMultNTracksHasTOFUnfm80 = occMultNTracksHasTOFUnfm80[i]; + auto& vecOccMultNTracksHasTRDUnfm80 = occMultNTracksHasTRDUnfm80[i]; + auto& vecOccMultNTracksITSOnlyUnfm80 = occMultNTracksITSOnlyUnfm80[i]; + auto& vecOccMultNTracksTPCOnlyUnfm80 = occMultNTracksTPCOnlyUnfm80[i]; + auto& vecOccMultNTracksITSTPCUnfm80 = occMultNTracksITSTPCUnfm80[i]; + auto& vecOccMultAllTracksTPCOnlyUnfm80 = occMultAllTracksTPCOnlyUnfm80[i]; + float meanOccMultNTracksHasITSUnfm80 = TMath::Mean(vecOccMultNTracksHasITSUnfm80.size(), vecOccMultNTracksHasITSUnfm80.data()); + float meanOccMultNTracksHasTPCUnfm80 = TMath::Mean(vecOccMultNTracksHasTPCUnfm80.size(), vecOccMultNTracksHasTPCUnfm80.data()); + float meanOccMultNTracksHasTOFUnfm80 = TMath::Mean(vecOccMultNTracksHasTOFUnfm80.size(), vecOccMultNTracksHasTOFUnfm80.data()); + float meanOccMultNTracksHasTRDUnfm80 = TMath::Mean(vecOccMultNTracksHasTRDUnfm80.size(), vecOccMultNTracksHasTRDUnfm80.data()); + float meanOccMultNTracksITSOnlyUnfm80 = TMath::Mean(vecOccMultNTracksITSOnlyUnfm80.size(), vecOccMultNTracksITSOnlyUnfm80.data()); + float meanOccMultNTracksTPCOnlyUnfm80 = TMath::Mean(vecOccMultNTracksTPCOnlyUnfm80.size(), vecOccMultNTracksTPCOnlyUnfm80.data()); + float meanOccMultNTracksITSTPCUnfm80 = TMath::Mean(vecOccMultNTracksITSTPCUnfm80.size(), vecOccMultNTracksITSTPCUnfm80.data()); + float meanOccMultAllTracksTPCOnlyUnfm80 = TMath::Mean(vecOccMultAllTracksTPCOnlyUnfm80.size(), vecOccMultAllTracksTPCOnlyUnfm80.data()); + // multExtraTable + normalizeVector(vecOccMultNTracksHasITSUnfm80, meanOccPrimUnfm80 / meanOccMultNTracksHasITSUnfm80); + normalizeVector(vecOccMultNTracksHasTPCUnfm80, meanOccPrimUnfm80 / meanOccMultNTracksHasTPCUnfm80); + normalizeVector(vecOccMultNTracksHasTOFUnfm80, meanOccPrimUnfm80 / meanOccMultNTracksHasTOFUnfm80); + normalizeVector(vecOccMultNTracksHasTRDUnfm80, meanOccPrimUnfm80 / meanOccMultNTracksHasTRDUnfm80); + normalizeVector(vecOccMultNTracksITSOnlyUnfm80, meanOccPrimUnfm80 / meanOccMultNTracksITSOnlyUnfm80); + normalizeVector(vecOccMultNTracksTPCOnlyUnfm80, meanOccPrimUnfm80 / meanOccMultNTracksTPCOnlyUnfm80); + normalizeVector(vecOccMultNTracksITSTPCUnfm80, meanOccPrimUnfm80 / meanOccMultNTracksITSTPCUnfm80); + normalizeVector(vecOccMultAllTracksTPCOnlyUnfm80, meanOccPrimUnfm80 / meanOccMultAllTracksTPCOnlyUnfm80); + + if constexpr (robustTableMode == fillOccRobustTable || meanRobustTableMode == fillOccMeanRobustTable) { + getMedianOccVect(vecRobustOccmultTableUnfm80, vecRobustOccmultTableUnfm80medianPosVec, + vecOccPrimUnfm80, vecOccMultNTracksHasITSUnfm80, vecOccMultNTracksHasTPCUnfm80, + vecOccMultNTracksHasTOFUnfm80, vecOccMultNTracksHasTRDUnfm80, vecOccMultNTracksITSOnlyUnfm80, + vecOccMultNTracksTPCOnlyUnfm80, vecOccMultNTracksITSTPCUnfm80, vecOccMultAllTracksTPCOnlyUnfm80, + vecOccNTrackITSTPCUnfm80); + for (const auto& vec : vecRobustOccmultTableUnfm80medianPosVec) { + recoEvent.fill(HIST("h_RO_multTableUnfm80"), vec[0]); + recoEvent.fill(HIST("h_RO_multTableUnfm80"), vec[1]); + } + } + + if constexpr (tableMode == fillOccTable) { + genOccsMultExtra(vecOccMultNTracksHasITSUnfm80, vecOccMultNTracksHasTPCUnfm80, + vecOccMultNTracksHasTOFUnfm80, vecOccMultNTracksHasTRDUnfm80, + vecOccMultNTracksITSOnlyUnfm80, vecOccMultNTracksTPCOnlyUnfm80, + vecOccMultNTracksITSTPCUnfm80, vecOccMultAllTracksTPCOnlyUnfm80); + } + if constexpr (meanTableMode == fillMeanOccTable) { + genOccsMnMultExtra(meanOccMultNTracksHasITSUnfm80, meanOccMultNTracksHasTPCUnfm80, + meanOccMultNTracksHasTOFUnfm80, meanOccMultNTracksHasTRDUnfm80, + meanOccMultNTracksITSOnlyUnfm80, meanOccMultNTracksTPCOnlyUnfm80, + meanOccMultNTracksITSTPCUnfm80, meanOccMultAllTracksTPCOnlyUnfm80); + } + if constexpr (robustTableMode == fillOccRobustTable) { + genORMultExtra(vecRobustOccmultTableUnfm80); + } + if constexpr (meanRobustTableMode == fillOccMeanRobustTable) { + genOccsMeanRobustMultExtraTable(TMath::Mean(vecRobustOccmultTableUnfm80.size(), vecRobustOccmultTableUnfm80.data())); + } + } + } + + // Create a BC index table. + int64_t occIDX = -1; + int idx = -1; + for (auto const& bc : BCs) { + idx = -1; + getTimingInfo(bc, lastRun, nBCsPerTF, bcSOR, time, tfIdThis, bcInTF); + + auto idxIt = std::find(tfList.begin(), tfList.end(), tfIdThis); + if (idxIt != tfList.end()) { + idx = std::distance(tfList.begin(), idxIt); + } else { + LOG(error) << "DEBUG :: SEVERE :: BC Timeframe not in the list"; + } + + auto it = std::find(bcTFMap[idx].begin(), bcTFMap[idx].end(), bc.globalIndex()); // will find the iterator where object is placed. + if (it != bcTFMap[idx].end()) { + occIDX = idx; // Element is in the vector + } else { + occIDX = -1; // Element is not in the vector + } + + genBCTFinfoTable(tfIdThis, bcInTF); + genOccIndexTable(bc.globalIndex(), occIDX); // BCId, OccId + } + } // else block for constexpr + } + + void checkAllProcessFunctionStatus(std::vector const& processStatusVector, bool& singleProcessOn) + { + int nProcessOn = 0; + const uint size = processStatusVector.size(); + for (uint i = 0; i < size; i++) { + if (processStatusVector[i]) { + nProcessOn++; + } + } + + if (nProcessOn > 1) { + singleProcessOn = false; + std::ostringstream warningLine; + warningLine << "DEBUG :: More than one track-mean-occ-table-producer process function is on :: "; + for (uint i = 0; i < size; i++) { + if (processStatusVector[i]) { + warningLine << std::string(ProcessNames[processStatusVector[i]]) << " == true :: "; + } + } + LOG(error) << warningLine.str(); + } // check nProcess + } + + //________________________________________End of Exection Function_________________________________________________________________________ + + void processOnlyBCTFinfoTable(o2::aod::BCsWithTimestamps const& BCs) + { + occupancyQA.fill(HIST("h_DFcount_Lvl0"), 0.5); + processStatus[kProcessOnlyBCTFinfoTable] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (!singleProcessOn) { + return; + } + + for (const auto& BC : BCs) { + getTimingInfo(BC, lastRun, nBCsPerTF, bcSOR, time, tfIdThis, bcInTF); + genBCTFinfoTable(tfIdThis, bcInTF); + } + occupancyQA.fill(HIST("h_DFcount_Lvl1"), 0.5); + } + PROCESS_SWITCH(OccupancyTableProducer, processOnlyBCTFinfoTable, "processOnlyBCTFinfoTable", true); + + // // Process the Data + void processOnlyOccPrimUnfm(o2::aod::BCsWithTimestamps const& BCs, aod::Collisions const& collisions) + { + occupancyQA.fill(HIST("h_DFcount_Lvl0"), 0.5); + if (!buildOnlyOccsPrim) { + LOG(error) << " DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsPrim == false"; + } + processStatus[kProcessOnlyOccPrim] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (!singleProcessOn) { + return; + } + + bool collisionsSizeIsZero = false; + executeCollisionCheckAndBCprocessing(BCs, collisions, collisionsSizeIsZero); + if (collisionsSizeIsZero) { + return; + } + executeOccProducerProcessing(BCs, collisions, nullptr); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), 0.5); + } + PROCESS_SWITCH(OccupancyTableProducer, processOnlyOccPrimUnfm, "processOnlyOccPrimUnfm", false); + + void processOnlyOccT0V0PrimUnfm(o2::aod::BCsWithTimestamps const& BCs, soa::Join const& collisions) + { + occupancyQA.fill(HIST("h_DFcount_Lvl0"), 0.5); + if (!buildOnlyOccsT0V0Prim) { + LOG(error) << " DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsT0V0Prim == false"; + } + processStatus[kProcessOnlyOccT0V0Prim] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (!singleProcessOn) { + return; + } + + bool collisionsSizeIsZero = false; + executeCollisionCheckAndBCprocessing(BCs, collisions, collisionsSizeIsZero); + if (collisionsSizeIsZero) { + return; + } + executeOccProducerProcessing(BCs, collisions, nullptr); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), 0.5); + } + PROCESS_SWITCH(OccupancyTableProducer, processOnlyOccT0V0PrimUnfm, "processOnlyOccT0V0PrimUnfm", false); + + void processOnlyOccFDDT0V0PrimUnfm(o2::aod::BCsWithTimestamps const& BCs, soa::Join const& collisions) + { + occupancyQA.fill(HIST("h_DFcount_Lvl0"), 0.5); + if (!buildOnlyOccsFDDT0V0Prim) { + LOG(error) << " DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsFDDT0V0Prim == false"; + } + processStatus[kProcessOnlyOccFDDT0V0Prim] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (!singleProcessOn) { + return; + } + + bool collisionsSizeIsZero = false; + executeCollisionCheckAndBCprocessing(BCs, collisions, collisionsSizeIsZero); + if (collisionsSizeIsZero) { + return; + } + executeOccProducerProcessing(BCs, collisions, nullptr); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), 0.5); + } + PROCESS_SWITCH(OccupancyTableProducer, processOnlyOccFDDT0V0PrimUnfm, "processOnlyOccFDDT0V0PrimUnfm", false); + + void processOnlyOccNtrackDet(o2::aod::BCsWithTimestamps const& BCs, soa::Join const& collisions, soa::Join const& tracks) + { + occupancyQA.fill(HIST("h_DFcount_Lvl0"), 0.5); + if (!buildOnlyOccsNtrackDet) { + LOG(error) << " DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsNtrackDet == false"; + } + processStatus[kProcessOnlyOccNtrackDet] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (!singleProcessOn) { + return; + } + + bool collisionsSizeIsZero = false; + executeCollisionCheckAndBCprocessing(BCs, collisions, collisionsSizeIsZero); + if (collisionsSizeIsZero) { + return; + } + executeOccProducerProcessing(BCs, collisions, tracks); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), 0.5); + } + PROCESS_SWITCH(OccupancyTableProducer, processOnlyOccNtrackDet, "processOnlyOccNtrackDet", false); + + void processOnlyOccMultExtra(o2::aod::BCsWithTimestamps const& BCs, soa::Join const& collisions) + { + occupancyQA.fill(HIST("h_DFcount_Lvl0"), 0.5); + if (!buildOnlyOccsMultExtra) { + LOG(error) << " DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsMultExtra == false"; + } + processStatus[kProcessOnlyOccMultExtra] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (!singleProcessOn) { + return; + } + + bool collisionsSizeIsZero = false; + executeCollisionCheckAndBCprocessing(BCs, collisions, collisionsSizeIsZero); + if (collisionsSizeIsZero) { + return; + } + executeOccProducerProcessing(BCs, collisions, nullptr); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), 0.5); + } + PROCESS_SWITCH(OccupancyTableProducer, processOnlyOccMultExtra, "processOnlyOccMultExtra", false); + + void processFullOccTableProduer(o2::aod::BCsWithTimestamps const& BCs, soa::Join const& collisions, soa::Join const& tracks) + { + occupancyQA.fill(HIST("h_DFcount_Lvl0"), 0.5); + if (!buildFullOccTableProducer) { + LOG(error) << " DEBUG :: ERROR ERROR ERROR :: buildFullOccTableProducer == false"; + } + processStatus[kProcessFullOccTableProducer] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (!singleProcessOn) { + return; + } + + bool collisionsSizeIsZero = false; + executeCollisionCheckAndBCprocessing(BCs, collisions, collisionsSizeIsZero); + if (collisionsSizeIsZero) { + return; + } + executeOccProducerProcessing(BCs, collisions, tracks); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), 0.5); + } // Process function ends + PROCESS_SWITCH(OccupancyTableProducer, processFullOccTableProduer, "processFullOccTableProduer", false); +}; + +struct TrackMeanOccTableProducer { + + // //declare production of tables + Produces genTmoTrackId; + Produces genTmoToTrackQA; + Produces genTrackQAToTmo; + + Produces genTmoPrim; + Produces genTmoT0V0; + Produces genTmoFDD; + Produces genTmoNTrackDet; + Produces genTmoMultExtra; + Produces genTmoRT0V0Prim; + Produces genTmoRFDDT0V0Prim; + Produces genTmoRNtrackDet; + Produces genTmoRMultExtra; + + Produces genTwmoPrim; + Produces genTwmoT0V0; + Produces genTwmoFDD; + Produces genTwmoNTrackDet; + Produces genTwmoMultExtra; + Produces genTwmoRT0V0Prim; + Produces genTwmoRFDDT0V0Pri; + Produces genTwmoRNtrackDet; + Produces genTwmoRMultExtra; + + Service ccdb; + + HistogramRegistry occupancyQA{"occupancyQA", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Configurables + Configurable customOrbitOffset{"customOrbitOffset", 0, "customOrbitOffset for MC"}; + Configurable bcGrouping{"bcGrouping", 80, "bcGrouping of BCs"}; + Configurable nBCinTF{"nBCinTF", 114048, "nBCinTF"}; + + Configurable cfgNOrbitsPerTF0RunValue{"cfgNOrbitsPerTF0RunValue", 534133, "cfgNOrbitsPerTF0RunValue"}; + Configurable cfgNOrbitsPerTF1TrueValue{"cfgNOrbitsPerTF1TrueValue", 128, "cfgNOrbitsPerTF1TrueValue"}; + Configurable cfgNOrbitsPerTF2FalseValue{"cfgNOrbitsPerTF2FalseValue", 32, "ccfgNOrbitsPerTF2FalseValue"}; + + Configurable buildOnlyOccsPrim{"buildOnlyOccsPrim", true, "builder of table OccsPrim"}; + Configurable buildOnlyOccsT0V0{"buildOnlyOccsT0V0", true, "builder of table OccsT0V0Prim"}; + Configurable buildOnlyOccsFDD{"buildOnlyOccsFDD", true, "builder of table OccsFDDT0V0Prim"}; + Configurable buildOnlyOccsNtrackDet{"buildOnlyOccsNtrackDet", true, "builder of table OccsNtrackDet"}; + Configurable buildOnlyOccsMultExtra{"buildOnlyOccsMultExtra", true, "builder of table OccsMultExtra"}; + + Configurable buildOnlyOccsRobustT0V0Prim{"buildOnlyOccsRobustT0V0Prim", true, "build buildOnlyOccsRobustT0V0Prim"}; + Configurable buildOnlyOccsRobustFDDT0V0Prim{"buildOnlyOccsRobustFDDT0V0Prim", true, "build buildOnlyOccsRobustFDDT0V0Prim"}; + Configurable buildOnlyOccsRobustNtrackDet{"buildOnlyOccsRobustNtrackDet", true, "build buildOnlyOccsRobustNtrackDet"}; + Configurable buildOnlyOccsRobustMultExtra{"buildOnlyOccsRobustMultExtra", true, "build buildOnlyOccsRobustMultExtra"}; + + Configurable buildFullOccTableProducer{"buildFullOccTableProducer", true, "builder of all Occupancy Tables"}; + + Configurable buildFlag00MeanTable{"buildFlag00MeanTable", true, "build Flag00MeanTable"}; + Configurable buildFlag01WeightMeanTable{"buildFlag01WeightMeanTable", true, "build Flag01WeightMeanTable"}; + + Configurable fillQA1{"fillQA1", true, "fill QA LOG Ratios"}; + Configurable fillQA2{"fillQA2", true, "fill QA condition dependent QAs"}; + + Configurable buildPointerTrackQAToTMOTable{"buildPointerTrackQAToTMOTable", true, "buildPointerTrackQAToTMOTable"}; + Configurable buildPointerTMOToTrackQATable{"buildPointerTMOToTrackQATable", true, "buildPointerTMOToTrackQATable"}; + + // vectors to be used for occupancy estimation + std::vector occPrimUnfm80; + + std::vector occFV0AUnfm80; + std::vector occFV0CUnfm80; + std::vector occFT0AUnfm80; + std::vector occFT0CUnfm80; + + std::vector occFDDAUnfm80; + std::vector occFDDCUnfm80; + + std::vector occNTrackITSUnfm80; + std::vector occNTrackTPCUnfm80; + std::vector occNTrackTRDUnfm80; + std::vector occNTrackTOFUnfm80; + std::vector occNTrackSizeUnfm80; + std::vector occNTrackTPCAUnfm80; + std::vector occNTrackTPCCUnfm80; + std::vector occNTrackITSTPCUnfm80; + std::vector occNTrackITSTPCAUnfm80; + std::vector occNTrackITSTPCCUnfm80; + + std::vector occMultNTracksHasITSUnfm80; + std::vector occMultNTracksHasTPCUnfm80; + std::vector occMultNTracksHasTOFUnfm80; + std::vector occMultNTracksHasTRDUnfm80; + std::vector occMultNTracksITSOnlyUnfm80; + std::vector occMultNTracksTPCOnlyUnfm80; + std::vector occMultNTracksITSTPCUnfm80; + std::vector occMultAllTracksTPCOnlyUnfm80; + + std::vector occRobustT0V0PrimUnfm80; + std::vector occRobustFDDT0V0PrimUnfm80; + std::vector occRobustNtrackDetUnfm80; + std::vector occRobustMultTableUnfm80; + + std::vector processStatus; + std::vector processInThisBlock; + void init(InitContext const&) + { + // CCDB related part to be added later + processStatus.resize(11); + processInThisBlock.resize(11); + + for (uint i = 0; i < processStatus.size(); i++) { + processStatus[i] = false; + processInThisBlock[i] = false; + } + + if (buildFullOccTableProducer || buildOnlyOccsPrim) { + occPrimUnfm80.resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsT0V0) { + occFV0AUnfm80.resize(nBCinTF / bcGrouping); + occFV0CUnfm80.resize(nBCinTF / bcGrouping); + occFT0AUnfm80.resize(nBCinTF / bcGrouping); + occFT0CUnfm80.resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsFDD) { + occFDDAUnfm80.resize(nBCinTF / bcGrouping); + occFDDCUnfm80.resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsNtrackDet) { + occNTrackITSUnfm80.resize(nBCinTF / bcGrouping); + occNTrackTPCUnfm80.resize(nBCinTF / bcGrouping); + occNTrackTRDUnfm80.resize(nBCinTF / bcGrouping); + occNTrackTOFUnfm80.resize(nBCinTF / bcGrouping); + occNTrackSizeUnfm80.resize(nBCinTF / bcGrouping); + occNTrackTPCAUnfm80.resize(nBCinTF / bcGrouping); + occNTrackTPCCUnfm80.resize(nBCinTF / bcGrouping); + occNTrackITSTPCUnfm80.resize(nBCinTF / bcGrouping); + occNTrackITSTPCAUnfm80.resize(nBCinTF / bcGrouping); + occNTrackITSTPCCUnfm80.resize(nBCinTF / bcGrouping); + } + + if (buildFullOccTableProducer || buildOnlyOccsMultExtra) { + occMultNTracksHasITSUnfm80.resize(nBCinTF / bcGrouping); + occMultNTracksHasTPCUnfm80.resize(nBCinTF / bcGrouping); + occMultNTracksHasTOFUnfm80.resize(nBCinTF / bcGrouping); + occMultNTracksHasTRDUnfm80.resize(nBCinTF / bcGrouping); + occMultNTracksITSOnlyUnfm80.resize(nBCinTF / bcGrouping); + occMultNTracksTPCOnlyUnfm80.resize(nBCinTF / bcGrouping); + occMultNTracksITSTPCUnfm80.resize(nBCinTF / bcGrouping); + occMultAllTracksTPCOnlyUnfm80.resize(nBCinTF / bcGrouping); + } + + if (buildFullOccTableProducer || buildOnlyOccsRobustT0V0Prim || fillQA1 || fillQA2) { + occRobustT0V0PrimUnfm80.resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsRobustFDDT0V0Prim) { + occRobustFDDT0V0PrimUnfm80.resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsRobustNtrackDet) { + occRobustNtrackDetUnfm80.resize(nBCinTF / bcGrouping); + } + if (buildFullOccTableProducer || buildOnlyOccsRobustMultExtra) { + occRobustMultTableUnfm80.resize(nBCinTF / bcGrouping); + } + + const AxisSpec axisQA1 = {500, 0, 50000}; + const AxisSpec axisQA2 = {200, -2, 2}; + const AxisSpec axisQA3 = {200, -20, 20}; + + occupancyQA.add("occTrackQA/Mean/OccPrimUnfm80", "OccPrimUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccFV0AUnfm80", "OccFV0AUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccFV0CUnfm80", "OccFV0CUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccFT0AUnfm80", "OccFT0AUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccFT0CUnfm80", "OccFT0CUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccFDDAUnfm80", "OccFDDAUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccFDDCUnfm80", "OccFDDCUnfm80", kTH1F, {axisQA1}); + + occupancyQA.add("occTrackQA/Mean/OccNTrackITSUnfm80", "OccNTrackITSUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccNTrackTPCUnfm80", "OccNTrackTPCUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccNTrackTRDUnfm80", "OccNTrackTRDUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccNTrackTOFUnfm80", "OccNTrackTOFUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccNTrackSizeUnfm80", "OccNTrackSizeUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccNTrackTPCAUnfm80", "OccNTrackTPCAUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccNTrackTPCCUnfm80", "OccNTrackTPCCUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccNTrackITSTPCUnfm80", "OccNTrackITSTPCUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccNTrackITSTPCAUnfm80", "OccNTrackITSTPCAUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccNTrackITSTPCCUnfm80", "OccNTrackITSTPCCUnfm80", kTH1F, {axisQA1}); + + occupancyQA.add("occTrackQA/Mean/OccMultNTracksHasITSUnfm80", "OccMultNTracksHasITSUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccMultNTracksHasTPCUnfm80", "OccMultNTracksHasTPCUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccMultNTracksHasTOFUnfm80", "OccMultNTracksHasTOFUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccMultNTracksHasTRDUnfm80", "OccMultNTracksHasTRDUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccMultNTracksITSOnlyUnfm80", "OccMultNTracksITSOnlyUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccMultNTracksTPCOnlyUnfm80", "OccMultNTracksTPCOnlyUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccMultNTracksITSTPCUnfm80", "OccMultNTracksITSTPCUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccMultAllTracksTPCOnlyUnfm80", "OccMultAllTracksTPCOnlyUnfm80", kTH1F, {axisQA1}); + + occupancyQA.add("occTrackQA/Mean/OccRobustT0V0PrimUnfm80", "OccRobustT0V0PrimUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccRobustFDDT0V0PrimUnfm80", "OccRobustFDDT0V0PrimUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccRobustNtrackDetUnfm80", "OccRobustNtrackDetUnfm80", kTH1F, {axisQA1}); + occupancyQA.add("occTrackQA/Mean/OccRobustMultExtraTableUnfm80", "OccRobustMultExtraTableUnfm80", kTH1F, {axisQA1}); + + occupancyQA.addClone("occTrackQA/Mean/", "occTrackQA/WeightMean/"); + + if (fillQA1) { + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccPrimUnfm80", "OccPrimUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccFV0AUnfm80", "OccFV0AUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccFV0CUnfm80", "OccFV0CUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccFT0AUnfm80", "OccFT0AUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccFT0CUnfm80", "OccFT0CUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccFDDAUnfm80", "OccFDDAUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccFDDCUnfm80", "OccFDDCUnfm80", kTH1F, {axisQA2}); + + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackITSUnfm80", "OccNTrackITSUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackTPCUnfm80", "OccNTrackTPCUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackTRDUnfm80", "OccNTrackTRDUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackTOFUnfm80", "OccNTrackTOFUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackSizeUnfm80", "OccNTrackSizeUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackTPCAUnfm80", "OccNTrackTPCAUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackTPCCUnfm80", "OccNTrackTPCCUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackITSTPCUnfm80", "OccNTrackITSTPCUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackITSTPCAUnfm80", "OccNTrackITSTPCAUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccNTrackITSTPCCUnfm80", "OccNTrackITSTPCCUnfm80", kTH1F, {axisQA2}); + + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccMultNTracksHasITSUnfm80", "OccMultNTracksHasITSUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccMultNTracksHasTPCUnfm80", "OccMultNTracksHasTPCUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccMultNTracksHasTOFUnfm80", "OccMultNTracksHasTOFUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccMultNTracksHasTRDUnfm80", "OccMultNTracksHasTRDUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccMultNTracksITSOnlyUnfm80", "OccMultNTracksITSOnlyUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccMultNTracksTPCOnlyUnfm80", "OccMultNTracksTPCOnlyUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccMultNTracksITSTPCUnfm80", "OccMultNTracksITSTPCUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccMultAllTracksTPCOnlyUnfm80", "OccMultAllTracksTPCOnlyUnfm80", kTH1F, {axisQA2}); + + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccRobustT0V0PrimUnfm80", "OccRobustT0V0PrimUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccRobustFDDT0V0PrimUnfm80", "OccRobustFDDT0V0PrimUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccRobustNtrackDetUnfm80", "OccRobustNtrackDetUnfm80", kTH1F, {axisQA2}); + occupancyQA.add("occTrackQA/LogRatio/RobustT0V0Prim/Mean/OccRobustMultExtraTableUnfm80", "OccRobustMultExtraTableUnfm80", kTH1F, {axisQA2}); + + occupancyQA.addClone("occTrackQA/LogRatio/RobustT0V0Prim/Mean/", "occTrackQA/LogRatio/RobustT0V0Prim/WeightMean/"); + occupancyQA.addClone("occTrackQA/LogRatio/RobustT0V0Prim/WeightMean/", "occTrackQA/LogRatio/weightRobustT0V0Prim/WeightMean/"); + } + + if (fillQA2) { + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccPrimUnfm80", "OccPrimUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccFV0AUnfm80", "OccFV0AUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccFV0CUnfm80", "OccFV0CUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccFT0AUnfm80", "OccFT0AUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccFT0CUnfm80", "OccFT0CUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccFDDAUnfm80", "OccFDDAUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccFDDCUnfm80", "OccFDDCUnfm80", kTH1F, {axisQA3}); + + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackITSUnfm80", "OccNTrackITSUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackTPCUnfm80", "OccNTrackTPCUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackTRDUnfm80", "OccNTrackTRDUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackTOFUnfm80", "OccNTrackTOFUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackSizeUnfm80", "OccNTrackSizeUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackTPCAUnfm80", "OccNTrackTPCAUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackTPCCUnfm80", "OccNTrackTPCCUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackITSTPCUnfm80", "OccNTrackITSTPCUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackITSTPCAUnfm80", "OccNTrackITSTPCAUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccNTrackITSTPCCUnfm80", "OccNTrackITSTPCCUnfm80", kTH1F, {axisQA3}); + + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccMultNTracksHasITSUnfm80", "OccMultNTracksHasITSUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccMultNTracksHasTPCUnfm80", "OccMultNTracksHasTPCUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccMultNTracksHasTOFUnfm80", "OccMultNTracksHasTOFUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccMultNTracksHasTRDUnfm80", "OccMultNTracksHasTRDUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccMultNTracksITSOnlyUnfm80", "OccMultNTracksITSOnlyUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccMultNTracksTPCOnlyUnfm80", "OccMultNTracksTPCOnlyUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccMultNTracksITSTPCUnfm80", "OccMultNTracksITSTPCUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccMultAllTracksTPCOnlyUnfm80", "OccMultAllTracksTPCOnlyUnfm80", kTH1F, {axisQA3}); + + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccRobustT0V0PrimUnfm80", "OccRobustT0V0PrimUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccRobustFDDT0V0PrimUnfm80", "OccRobustFDDT0V0PrimUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccRobustNtrackDetUnfm80", "OccRobustNtrackDetUnfm80", kTH1F, {axisQA3}); + occupancyQA.add("occTrackQA/Condition1/RobustT0V0Prim/Mean/OccRobustMultExtraTableUnfm80", "OccRobustMultExtraTableUnfm80", kTH1F, {axisQA3}); + + occupancyQA.addClone("occTrackQA/Condition1/RobustT0V0Prim/Mean/", "occTrackQA/Condition1/RobustT0V0Prim/WeightMean/"); + occupancyQA.addClone("occTrackQA/Condition1/RobustT0V0Prim/WeightMean/", "occTrackQA/Condition1/weightRobustT0V0Prim/WeightMean/"); + + occupancyQA.addClone("occTrackQA/Condition1/", "occTrackQA/Condition2/"); + occupancyQA.addClone("occTrackQA/Condition1/", "occTrackQA/Condition3/"); + occupancyQA.addClone("occTrackQA/Condition1/", "occTrackQA/Condition4/"); + } + + occupancyQA.add("h_DFcount_Lvl0", "h_DFcount_Lvl0", kTH1F, {{13, -1, 12}}); + occupancyQA.add("h_DFcount_Lvl1", "h_DFcount_Lvl1", kTH1F, {{13, -1, 12}}); + occupancyQA.add("h_DFcount_Lvl2", "h_DFcount_Lvl2", kTH1F, {{13, -1, 12}}); + + occupancyQA.print(); + } + + enum OccNamesEnum { + kOccPrimUnfm80 = 0, + kOccFV0AUnfm80, + kOccFV0CUnfm80, + kOccFT0AUnfm80, + kOccFT0CUnfm80, + kOccFDDAUnfm80, + kOccFDDCUnfm80, + + kOccNTrackITSUnfm80, + kOccNTrackTPCUnfm80, + kOccNTrackTRDUnfm80, + kOccNTrackTOFUnfm80, + kOccNTrackSizeUnfm80, + kOccNTrackTPCAUnfm80, + kOccNTrackTPCCUnfm80, + kOccNTrackITSTPCUnfm80, + kOccNTrackITSTPCAUnfm80, + kOccNTrackITSTPCCUnfm80, + + kOccMultNTracksHasITSUnfm80, + kOccMultNTracksHasTPCUnfm80, + kOccMultNTracksHasTOFUnfm80, + kOccMultNTracksHasTRDUnfm80, + kOccMultNTracksITSOnlyUnfm80, + kOccMultNTracksTPCOnlyUnfm80, + kOccMultNTracksITSTPCUnfm80, + kOccMultAllTracksTPCOnlyUnfm80, + + kOccRobustT0V0PrimUnfm80, + kOccRobustFDDT0V0PrimUnfm80, + kOccRobustNtrackDetUnfm80, + kOccRobustMultTableUnfm80 + }; + + static constexpr std::string_view OccNames[]{ + "OccPrimUnfm80", + "OccFV0AUnfm80", + "OccFV0CUnfm80", + "OccFT0AUnfm80", + "OccFT0CUnfm80", + "OccFDDAUnfm80", + "OccFDDCUnfm80", + + "OccNTrackITSUnfm80", + "OccNTrackTPCUnfm80", + "OccNTrackTRDUnfm80", + "OccNTrackTOFUnfm80", + "OccNTrackSizeUnfm80", + "OccNTrackTPCAUnfm80", + "OccNTrackTPCCUnfm80", + "OccNTrackITSTPCUnfm80", + "OccNTrackITSTPCAUnfm80", + "OccNTrackITSTPCCUnfm80", + + "OccMultNTracksHasITSUnfm80", + "OccMultNTracksHasTPCUnfm80", + "OccMultNTracksHasTOFUnfm80", + "OccMultNTracksHasTRDUnfm80", + "OccMultNTracksITSOnlyUnfm80", + "OccMultNTracksTPCOnlyUnfm80", + "OccMultNTracksITSTPCUnfm80", + "OccMultAllTracksTPCOnlyUnfm80", + + "OccRobustT0V0PrimUnfm80", + "OccRobustFDDT0V0PrimUnfm80", + "OccRobustNtrackDetUnfm80", + "OccRobustMultExtraTableUnfm80"}; + + enum OccDirEnum { + kMean = 0, + kWeightMean, + kLogRatio, + kRobustT0V0Prim, + kWeightRobustT0V0Prim, + kCondition1, + kCondition2, + kCondition3, + kCondition4 + }; + + static constexpr std::string_view OccDire[] = { + "Mean/", + "WeightMean/", + "LogRatio/", + "RobustT0V0Prim/", + "weightRobustT0V0Prim/", + "Condition1/", + "Condition2/", + "Condition3/", + "Condition4/"}; + + void getRunInfo(const int& run, int& nBCsPerTF, int64_t& bcSOR) + { + auto runDuration = ccdb->getRunDuration(run, true); + int64_t tsSOR = runDuration.first; + auto ctpx = ccdb->getForTimeStamp>("CTP/Calib/OrbitReset", tsSOR); + int64_t tsOrbitReset = (*ctpx)[0]; + uint32_t nOrbitsPerTF = run < cfgNOrbitsPerTF0RunValue ? cfgNOrbitsPerTF1TrueValue : cfgNOrbitsPerTF2FalseValue; + int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; + orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF; + bcSOR = orbitSOR * nBCsPerOrbit + customOrbitOffset * nBCsPerOrbit; // customOrbitOffset is a configurable + nBCsPerTF = nOrbitsPerTF * nBCsPerOrbit; + } + + template + void getTimingInfo(const T& bc, int& lastRun, int32_t& nBCsPerTF, int64_t& bcSOR, uint64_t& time, int64_t& tfIdThis, int& bcInTF) + { + int run = bc.runNumber(); + if (run != lastRun) { // update run info + lastRun = run; + getRunInfo(run, nBCsPerTF, bcSOR); // update nBCsPerTF && bcSOR + } + // update the information + time = bc.timestamp(); + tfIdThis = (bc.globalBC() - bcSOR) / nBCsPerTF; + bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; + } + + float getMeanOccupancy(int bcBegin, int bcEnd, const std::vector& OccVector) + { + float sumOfBins = 0; + int binStart, binEnd; + if (bcBegin <= bcEnd) { + binStart = bcBegin; + binEnd = bcEnd; + } else { + binStart = bcEnd; + binEnd = bcBegin; + } + for (int i = binStart; i <= binEnd; i++) { + sumOfBins += OccVector[i]; + } + float meanOccupancy = sumOfBins / static_cast(binEnd - binStart + 1); + return meanOccupancy; + } + + float getWeightedMeanOccupancy(int bcBegin, int bcEnd, const std::vector& OccVector) + { + float sumOfBins = 0; + int binStart, binEnd; + // Assuming linear dependence of R on bins + float m; // slope of the equation + float c; // some constant in linear + float x1, x2; //, y1 = 90., y2 = 245.; + + if (bcBegin <= bcEnd) { + binStart = bcBegin; + binEnd = bcEnd; + x1 = static_cast(binStart); + x2 = static_cast(binEnd); + } else { + binStart = bcEnd; + binEnd = bcBegin; + x1 = static_cast(binEnd); + x2 = static_cast(binStart); + } // + + if (x2 == x1) { + m = 0; + } else { + m = (245. - 90.) / (x2 - x1); + } + c = 245. - m * x2; + float weightSum = 0; + float wr = 0; + float r = 0; + for (int i = binStart; i <= binEnd; i++) { + r = m * i + c; + wr = 125. / r; + if (x2 == x1) { + wr = 1.0; + } + sumOfBins += OccVector[i] * wr; + weightSum += wr; + } + float meanOccupancy = sumOfBins / weightSum; + return meanOccupancy; + } + + template + void fillQAInfo(const float& occValue, const float& occRobustValue) + { + occupancyQA.fill(HIST("occTrackQA/") + HIST(OccDire[occMode]) + HIST(OccNames[occName]), occValue); + if (fillQA1) { + occupancyQA.fill(HIST("occTrackQA/LogRatio/") + HIST(OccDire[occRobustMode]) + HIST(OccDire[occMode]) + HIST(OccNames[occName]), std::log(std::abs(occValue / occRobustValue))); + if (fillQA2) { + int two = 2, twenty = 20, fifty = 50, twoHundred = 200; + if (std::abs(std::log(occValue / occRobustValue)) < two) { // conditional filling start + occupancyQA.fill(HIST("occTrackQA/Condition1/") + HIST(OccDire[occRobustMode]) + HIST(OccDire[occMode]) + HIST(OccNames[occName]), (std::log(occValue / occRobustValue)) * std::sqrt(occValue + occRobustValue)); + if (std::abs(occRobustValue + occValue) > twoHundred) { + occupancyQA.fill(HIST("occTrackQA/Condition4/") + HIST(OccDire[occRobustMode]) + HIST(OccDire[occMode]) + HIST(OccNames[occName]), (std::log(occValue / occRobustValue)) * std::sqrt(occValue + occRobustValue)); + occupancyQA.fill(HIST("occTrackQA/Condition3/") + HIST(OccDire[occRobustMode]) + HIST(OccDire[occMode]) + HIST(OccNames[occName]), (std::log(occValue / occRobustValue)) * std::sqrt(occValue + occRobustValue)); + occupancyQA.fill(HIST("occTrackQA/Condition2/") + HIST(OccDire[occRobustMode]) + HIST(OccDire[occMode]) + HIST(OccNames[occName]), (std::log(occValue / occRobustValue)) * std::sqrt(occValue + occRobustValue)); + } else if (std::abs(occRobustValue + occValue) > fifty) { + occupancyQA.fill(HIST("occTrackQA/Condition3/") + HIST(OccDire[occRobustMode]) + HIST(OccDire[occMode]) + HIST(OccNames[occName]), (std::log(occValue / occRobustValue)) * std::sqrt(occValue + occRobustValue)); + occupancyQA.fill(HIST("occTrackQA/Condition2/") + HIST(OccDire[occRobustMode]) + HIST(OccDire[occMode]) + HIST(OccNames[occName]), (std::log(occValue / occRobustValue)) * std::sqrt(occValue + occRobustValue)); + } else if (std::abs(occRobustValue + occValue) > twenty) { + occupancyQA.fill(HIST("occTrackQA/Condition2/") + HIST(OccDire[occRobustMode]) + HIST(OccDire[occMode]) + HIST(OccNames[occName]), (std::log(occValue / occRobustValue)) * std::sqrt(occValue + occRobustValue)); + } + } // conditional filling end + } + } + } + + using MyTracksQA = aod::TracksQAVersion; // using MyTracksQA = aod::TracksQA_002; + + // Process the Data + int dfCount = 0; + int32_t nBCsPerTF = -999; + int64_t bcSOR = -999; + int lastRun = -999; + + uint64_t time = -1; + int64_t tfIdThis = -1; + int bcInTF = -1; + + enum ProcessTags { + kProcessNothing = 0, + kProcessOnlyOccPrim, + kProcessOnlyOccT0V0, + kProcessOnlyOccFDD, + kProcessOnlyOccNtrackDet, + kProcessOnlyOccMultExtra, + kProcessOnlyRobustT0V0Prim, + kProcessOnlyRobustFDDT0V0Prim, + kProcessOnlyRobustNtrackDet, + kProcessOnlyRobustMultExtra, + kProcessFullOccTableProducer + }; + + enum FillMode { + checkTableMode = 0, + checkQAMode, + doNotFill, + fillOccRobustT0V0dependentQA, + fillMeanOccTable, + fillWeightMeanOccTable + }; + + std::vector> trackQAGIListforTMOList; + template + void executeTrackOccProducerProcessing(B const& BCs, C const& collisions, T const& tracks, U const& tracksQA, O const& occsRobustT0V0Prim, V const& occs, bool const& executeInThisBlock) + { + if (collisions.size() == 0) { + return; + } + + if (meanTableMode == checkTableMode) { + if (buildFlag00MeanTable) { + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, executeInThisBlock); + } else { + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, executeInThisBlock); + } + } + if constexpr (meanTableMode == checkTableMode) { + return; + } + + if (weightMeanTableMode == checkTableMode) { + if (buildFlag01WeightMeanTable) { + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, executeInThisBlock); + } else { + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, executeInThisBlock); + } + } + if constexpr (weightMeanTableMode == checkTableMode) { + return; + } + + if (qaMode == checkQAMode) { + if (fillQA1 || fillQA2) { + if (occsRobustT0V0Prim.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsRobustT0V0Prim.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsT0V0Prim == true\" & \"processOnlyOccT0V0PrimUnfm == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, executeInThisBlock); + } else { + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, executeInThisBlock); + } + } + if constexpr (qaMode == checkQAMode) { + return; + } + + // BCs.bindExternalIndices(&occsDet); + // BCs.bindExternalIndices(&occsNTrackDet); + // BCs.bindExternalIndices(&occsRobust); + + if constexpr (meanTableMode == checkTableMode || weightMeanTableMode == checkTableMode || qaMode == checkQAMode) { + return; + } else { + occupancyQA.fill(HIST("h_DFcount_Lvl2"), processMode); + + auto bc = BCs.begin(); + + int64_t oldTFid = -1; + + int64_t oldCollisionIndex = -100; + bool hasCollision = false; + bool isAmbgTrack = false; + bool lastTrackHadCollision = false; + bool doCollisionUpdate = false; + bool doAmbgUpdate = false; + + double rBegin = 90., rEnd = 245.; + double zBegin; // collision.posZ() + track.tgl()*rBegin; + double zEnd; // collision.posZ() + track.tgl()*rEnd; + double vdrift = 2.64; + + double dTbegin; // ((250.- TMath::Abs(zBegin))/vdrift)/0.025;//bin + double dTend; // ((250.- TMath::Abs(zEnd))/vdrift)/0.025; //bin + + double bcBegin; // tGlobalBC + dTbegin; + double bcEnd; // tGlobalBC + dTend ; + + int binBCbegin; + int binBCend; + + float meanOccPrimUnfm80 = 0; + float meanOccFV0AUnfm80 = 0; + float meanOccFV0CUnfm80 = 0; + float meanOccFT0AUnfm80 = 0; + float meanOccFT0CUnfm80 = 0; + float meanOccFDDAUnfm80 = 0; + float meanOccFDDCUnfm80 = 0; + + float meanOccNTrackITSUnfm80 = 0; + float meanOccNTrackTPCUnfm80 = 0; + float meanOccNTrackTRDUnfm80 = 0; + float meanOccNTrackTOFUnfm80 = 0; + float meanOccNTrackSizeUnfm80 = 0; + float meanOccNTrackTPCAUnfm80 = 0; + float meanOccNTrackTPCCUnfm80 = 0; + float meanOccNTrackITSTPCUnfm80 = 0; + float meanOccNTrackITSTPCAUnfm80 = 0; + float meanOccNTrackITSTPCCUnfm80 = 0; + + float meanOccMultNTracksHasITSUnfm80 = 0; + float meanOccMultNTracksHasTPCUnfm80 = 0; + float meanOccMultNTracksHasTOFUnfm80 = 0; + float meanOccMultNTracksHasTRDUnfm80 = 0; + float meanOccMultNTracksITSOnlyUnfm80 = 0; + float meanOccMultNTracksTPCOnlyUnfm80 = 0; + float meanOccMultNTracksITSTPCUnfm80 = 0; + float meanOccMultAllTracksTPCOnlyUnfm80 = 0; + + float meanOccRobustT0V0PrimUnfm80 = 0; + float meanOccRobustFDDT0V0PrimUnfm80 = 0; + float meanOccRobustNtrackDetUnfm80 = 0; + float meanOccRobustMultTableUnfm80 = 0; + + float weightMeanOccPrimUnfm80 = 0; + float weightMeanOccFV0AUnfm80 = 0; + float weightMeanOccFV0CUnfm80 = 0; + float weightMeanOccFT0AUnfm80 = 0; + float weightMeanOccFT0CUnfm80 = 0; + float weightMeanOccFDDAUnfm80 = 0; + float weightMeanOccFDDCUnfm80 = 0; + + float weightMeanOccNTrackITSUnfm80 = 0; + float weightMeanOccNTrackTPCUnfm80 = 0; + float weightMeanOccNTrackTRDUnfm80 = 0; + float weightMeanOccNTrackTOFUnfm80 = 0; + float weightMeanOccNTrackSizeUnfm80 = 0; + float weightMeanOccNTrackTPCAUnfm80 = 0; + float weightMeanOccNTrackTPCCUnfm80 = 0; + float weightMeanOccNTrackITSTPCUnfm80 = 0; + float weightMeanOccNTrackITSTPCAUnfm80 = 0; + float weightMeanOccNTrackITSTPCCUnfm80 = 0; + + float weightMeanOccMultNTracksHasITSUnfm80 = 0; + float weightMeanOccMultNTracksHasTPCUnfm80 = 0; + float weightMeanOccMultNTracksHasTOFUnfm80 = 0; + float weightMeanOccMultNTracksHasTRDUnfm80 = 0; + float weightMeanOccMultNTracksITSOnlyUnfm80 = 0; + float weightMeanOccMultNTracksTPCOnlyUnfm80 = 0; + float weightMeanOccMultNTracksITSTPCUnfm80 = 0; + float weightMeanOccMultAllTracksTPCOnlyUnfm80 = 0; + + float weightMeanOccRobustT0V0PrimUnfm80 = 0; + float weightMeanOccRobustFDDT0V0PrimUnfm80 = 0; + float weightMeanOccRobustNtrackDetUnfm80 = 0; + float weightMeanOccRobustMultTableUnfm80 = 0; + + int trackTMOcounter = -1; + trackQAGIListforTMOList.clear(); + + for (const auto& trackQA : tracksQA) { + auto const& track = trackQA.template track_as(); + auto collision = collisions.begin(); + + hasCollision = false; + isAmbgTrack = false; + + if (track.collisionId() >= 0) { // track has collision + collision = track.template collision_as(); // It will build but crash while running for tracks with track.collisionId()= -1;//ambg tracks/orphan tracks + if (track.collisionId() != collision.globalIndex()) { + LOG(error) << "DEBUG :: ERROR :: track collId and collID Mismatch"; + } + hasCollision = true; + } else { // track is ambiguous/orphan + isAmbgTrack = true; + } + + // Checking out of the range errors + if (trackQA.trackId() < 0 || tracks.size() <= trackQA.trackId()) { + LOG(error) << "DEBUG :: ERROR :: trackQA has index out of scope :: trackQA.trackId() = " << trackQA.trackId() << " :: track.collisionId() = " << track.collisionId() << " :: track.signed1Pt() = " << track.signed1Pt(); + } + if (!hasCollision && !isAmbgTrack) { + LOG(error) << "DEBUG :: ERROR :: A track with no collsiion and is not Ambiguous"; + } + if (hasCollision && isAmbgTrack) { + LOG(error) << "DEBUG :: ERROR :: A track has collision and is also ambiguous"; + } + + if (hasCollision) { + lastTrackHadCollision = true; + } + doCollisionUpdate = false; // default is false; + doAmbgUpdate = false; + if (hasCollision) { + if (lastTrackHadCollision) { + if (collision.globalIndex() == oldCollisionIndex) { // if collisions are same + doCollisionUpdate = false; + } else { // if collisions are different + doCollisionUpdate = true; + } + } else { // LastTrackWasAmbiguous + doCollisionUpdate = true; + } + } else if (isAmbgTrack) { + doAmbgUpdate = true; + // To be updated later + // if(LastTrackIsAmbg){ + // if( haveSameInfo ) { doAmbgUpdate = false;} + // else { doAmbgUpdate = true; } + // } + // else { doAmbgUpdate = true;} //Last track had Collisions + } + + if (doAmbgUpdate) { // sKipping ambiguous tracks for now, will be updated in future + continue; + } + if (doCollisionUpdate || doAmbgUpdate) { // collision.globalIndex() != oldCollisionIndex){ //don't update if info is same as old collision + if (doCollisionUpdate) { + oldCollisionIndex = collision.globalIndex(); + bc = collision.template bc_as(); + } + if (doAmbgUpdate) { + // to be updated later + // bc = collisions.iteratorAt(2).bc_as(); + // bc = ambgTracks.iteratorAt(0).bc_as(); + } + // LOG(info)<<" What happens in the case when the collision id is = -1 and it tries to obtain bc" + getTimingInfo(bc, lastRun, nBCsPerTF, bcSOR, time, tfIdThis, bcInTF); + } + + if (tfIdThis != oldTFid) { + oldTFid = tfIdThis; + auto occsList = occs.iteratorAt(bc.occId()); + + if constexpr (qaMode == fillOccRobustT0V0dependentQA) { + std::copy(occsRobustT0V0Prim.iteratorAt(bc.occId()).occRobustT0V0PrimUnfm80().begin(), occsRobustT0V0Prim.iteratorAt(bc.occId()).occRobustT0V0PrimUnfm80().end(), occRobustT0V0PrimUnfm80.begin()); + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccPrim) { + std::copy(occsList.occPrimUnfm80().begin(), occsList.occPrimUnfm80().end(), occPrimUnfm80.begin()); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccT0V0) { + std::copy(occsList.occFV0AUnfm80().begin(), occsList.occFV0AUnfm80().end(), occFV0AUnfm80.begin()); + std::copy(occsList.occFV0CUnfm80().begin(), occsList.occFV0CUnfm80().end(), occFV0CUnfm80.begin()); + std::copy(occsList.occFT0AUnfm80().begin(), occsList.occFT0AUnfm80().end(), occFT0AUnfm80.begin()); + std::copy(occsList.occFT0CUnfm80().begin(), occsList.occFT0CUnfm80().end(), occFT0CUnfm80.begin()); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccFDD) { + std::copy(occsList.occFDDAUnfm80().begin(), occsList.occFDDAUnfm80().end(), occFDDAUnfm80.begin()); + std::copy(occsList.occFDDCUnfm80().begin(), occsList.occFDDCUnfm80().end(), occFDDCUnfm80.begin()); + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet) { + std::copy(occsList.occNTrackITSUnfm80().begin(), occsList.occNTrackITSUnfm80().end(), occNTrackITSUnfm80.begin()); + std::copy(occsList.occNTrackTPCUnfm80().begin(), occsList.occNTrackTPCUnfm80().end(), occNTrackTPCUnfm80.begin()); + std::copy(occsList.occNTrackTRDUnfm80().begin(), occsList.occNTrackTRDUnfm80().end(), occNTrackTRDUnfm80.begin()); + std::copy(occsList.occNTrackTOFUnfm80().begin(), occsList.occNTrackTOFUnfm80().end(), occNTrackTOFUnfm80.begin()); + std::copy(occsList.occNTrackSizeUnfm80().begin(), occsList.occNTrackSizeUnfm80().end(), occNTrackSizeUnfm80.begin()); + std::copy(occsList.occNTrackTPCAUnfm80().begin(), occsList.occNTrackTPCAUnfm80().end(), occNTrackTPCAUnfm80.begin()); + std::copy(occsList.occNTrackTPCCUnfm80().begin(), occsList.occNTrackTPCCUnfm80().end(), occNTrackTPCCUnfm80.begin()); + std::copy(occsList.occNTrackITSTPCUnfm80().begin(), occsList.occNTrackITSTPCUnfm80().end(), occNTrackITSTPCUnfm80.begin()); + std::copy(occsList.occNTrackITSTPCAUnfm80().begin(), occsList.occNTrackITSTPCAUnfm80().end(), occNTrackITSTPCAUnfm80.begin()); + std::copy(occsList.occNTrackITSTPCCUnfm80().begin(), occsList.occNTrackITSTPCCUnfm80().end(), occNTrackITSTPCCUnfm80.begin()); + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccMultExtra) { + std::copy(occsList.occMultNTracksHasITSUnfm80().begin(), occsList.occMultNTracksHasITSUnfm80().end(), occMultNTracksHasITSUnfm80.begin()); + std::copy(occsList.occMultNTracksHasTPCUnfm80().begin(), occsList.occMultNTracksHasTPCUnfm80().end(), occMultNTracksHasTPCUnfm80.begin()); + std::copy(occsList.occMultNTracksHasTOFUnfm80().begin(), occsList.occMultNTracksHasTOFUnfm80().end(), occMultNTracksHasTOFUnfm80.begin()); + std::copy(occsList.occMultNTracksHasTRDUnfm80().begin(), occsList.occMultNTracksHasTRDUnfm80().end(), occMultNTracksHasTRDUnfm80.begin()); + std::copy(occsList.occMultNTracksITSOnlyUnfm80().begin(), occsList.occMultNTracksITSOnlyUnfm80().end(), occMultNTracksITSOnlyUnfm80.begin()); + std::copy(occsList.occMultNTracksTPCOnlyUnfm80().begin(), occsList.occMultNTracksTPCOnlyUnfm80().end(), occMultNTracksTPCOnlyUnfm80.begin()); + std::copy(occsList.occMultNTracksITSTPCUnfm80().begin(), occsList.occMultNTracksITSTPCUnfm80().end(), occMultNTracksITSTPCUnfm80.begin()); + std::copy(occsList.occMultAllTracksTPCOnlyUnfm80().begin(), occsList.occMultAllTracksTPCOnlyUnfm80().end(), occMultAllTracksTPCOnlyUnfm80.begin()); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyRobustT0V0Prim) { + std::copy(occsList.occRobustT0V0PrimUnfm80().begin(), occsList.occRobustT0V0PrimUnfm80().end(), occRobustT0V0PrimUnfm80.begin()); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyRobustFDDT0V0Prim) { + std::copy(occsList.occRobustFDDT0V0PrimUnfm80().begin(), occsList.occRobustFDDT0V0PrimUnfm80().end(), occRobustFDDT0V0PrimUnfm80.begin()); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyRobustNtrackDet) { + std::copy(occsList.occRobustNtrackDetUnfm80().begin(), occsList.occRobustNtrackDetUnfm80().end(), occRobustNtrackDetUnfm80.begin()); + } + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyRobustMultExtra) { + std::copy(occsList.occRobustMultExtraTableUnfm80().begin(), occsList.occRobustMultExtraTableUnfm80().end(), occRobustMultTableUnfm80.begin()); + } + } + + // Timebc = TGlobalBC+ΔTdrift + // ΔTdrift=((250(cm)-abs(z))/vdrift) + // vdrift=2.64 cm/μs + // z=zv+tgl*Radius + + rBegin = 90., rEnd = 245.; // in cm + zBegin = collision.posZ() + track.tgl() * rBegin; // in cm + zEnd = collision.posZ() + track.tgl() * rEnd; // in cm + vdrift = 2.64; // cm/μs + float length = 250.0; + // clip the result at 250 + if (zBegin > length) { + zBegin = 250; + } else if (zBegin < -length) { + zBegin = -250; + } + + if (zEnd > length) { + zEnd = 250; + } else if (zEnd < -length) { + zEnd = -250; + } + + dTbegin = ((length - std::abs(zBegin)) / vdrift) / 0.025; + dTend = ((length - std::abs(zEnd)) / vdrift) / 0.025; + + bcBegin = bcInTF + dTbegin; + bcEnd = bcInTF + dTend; + + binBCbegin = bcBegin / 80; + binBCend = bcEnd / 80; + + // If multiple process are on, fill this table only once + if (executeInThisBlock) { + trackTMOcounter++; + genTmoTrackId(track.globalIndex()); + trackQAGIListforTMOList.push_back({trackQA.globalIndex(), trackTMOcounter}); + } + + if constexpr (qaMode == fillOccRobustT0V0dependentQA) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccRobustT0V0PrimUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccRobustT0V0PrimUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occRobustT0V0PrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccPrim) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccPrimUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occPrimUnfm80); + genTmoPrim(meanOccPrimUnfm80); + fillQAInfo(meanOccPrimUnfm80, meanOccRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccPrimUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occPrimUnfm80); + genTwmoPrim(weightMeanOccPrimUnfm80); + fillQAInfo(weightMeanOccPrimUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccPrimUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccT0V0) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccFV0AUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occFV0AUnfm80); + meanOccFV0CUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occFV0CUnfm80); + meanOccFT0AUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occFT0AUnfm80); + meanOccFT0CUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occFT0CUnfm80); + genTmoT0V0(meanOccFV0AUnfm80, + meanOccFV0CUnfm80, + meanOccFT0AUnfm80, + meanOccFT0CUnfm80); + fillQAInfo(meanOccFV0AUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccFV0CUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccFT0AUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccFT0CUnfm80, meanOccRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccFV0AUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occFV0AUnfm80); + weightMeanOccFV0CUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occFV0CUnfm80); + weightMeanOccFT0AUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occFT0AUnfm80); + weightMeanOccFT0CUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occFT0CUnfm80); + genTwmoT0V0(weightMeanOccFV0AUnfm80, + weightMeanOccFV0CUnfm80, + weightMeanOccFT0AUnfm80, + weightMeanOccFT0CUnfm80); + fillQAInfo(weightMeanOccFV0AUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccFV0CUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccFT0AUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccFT0CUnfm80, meanOccRobustT0V0PrimUnfm80); + + fillQAInfo(weightMeanOccFV0AUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccFV0CUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccFT0AUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccFT0CUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccFDD) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccFDDAUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occFDDAUnfm80); + meanOccFDDCUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occFDDCUnfm80); + genTmoFDD(meanOccFDDAUnfm80, + meanOccFDDCUnfm80); + fillQAInfo(meanOccFDDAUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccFDDCUnfm80, meanOccRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccFDDAUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occFDDAUnfm80); + weightMeanOccFDDCUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occFDDCUnfm80); + genTwmoFDD(weightMeanOccFDDAUnfm80, + weightMeanOccFDDCUnfm80); + fillQAInfo(weightMeanOccFDDAUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccFDDCUnfm80, meanOccRobustT0V0PrimUnfm80); + + fillQAInfo(weightMeanOccFDDAUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccFDDCUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccNtrackDet) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccNTrackITSUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackITSUnfm80); + meanOccNTrackTPCUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackTPCUnfm80); + meanOccNTrackTRDUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackTRDUnfm80); + meanOccNTrackTOFUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackTOFUnfm80); + meanOccNTrackSizeUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackSizeUnfm80); + meanOccNTrackTPCAUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackTPCAUnfm80); + meanOccNTrackTPCCUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackTPCCUnfm80); + meanOccNTrackITSTPCUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackITSTPCUnfm80); + meanOccNTrackITSTPCAUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackITSTPCAUnfm80); + meanOccNTrackITSTPCCUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occNTrackITSTPCCUnfm80); + genTmoNTrackDet(meanOccNTrackITSUnfm80, + meanOccNTrackTPCUnfm80, + meanOccNTrackTRDUnfm80, + meanOccNTrackTOFUnfm80, + meanOccNTrackSizeUnfm80, + meanOccNTrackTPCAUnfm80, + meanOccNTrackTPCCUnfm80, + meanOccNTrackITSTPCUnfm80, + meanOccNTrackITSTPCAUnfm80, + meanOccNTrackITSTPCCUnfm80); + fillQAInfo(meanOccNTrackITSUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccNTrackTPCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccNTrackTRDUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccNTrackTOFUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccNTrackSizeUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccNTrackTPCAUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccNTrackTPCCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccNTrackITSTPCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccNTrackITSTPCAUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccNTrackITSTPCCUnfm80, meanOccRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccNTrackITSUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackITSUnfm80); + weightMeanOccNTrackTPCUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackTPCUnfm80); + weightMeanOccNTrackTRDUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackTRDUnfm80); + weightMeanOccNTrackTOFUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackTOFUnfm80); + weightMeanOccNTrackSizeUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackSizeUnfm80); + weightMeanOccNTrackTPCAUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackTPCAUnfm80); + weightMeanOccNTrackTPCCUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackTPCCUnfm80); + weightMeanOccNTrackITSTPCUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackITSTPCUnfm80); + weightMeanOccNTrackITSTPCAUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackITSTPCAUnfm80); + weightMeanOccNTrackITSTPCCUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occNTrackITSTPCCUnfm80); + + genTwmoNTrackDet(weightMeanOccNTrackITSUnfm80, + weightMeanOccNTrackTPCUnfm80, + weightMeanOccNTrackTRDUnfm80, + weightMeanOccNTrackTOFUnfm80, + weightMeanOccNTrackSizeUnfm80, + weightMeanOccNTrackTPCAUnfm80, + weightMeanOccNTrackTPCCUnfm80, + weightMeanOccNTrackITSTPCUnfm80, + weightMeanOccNTrackITSTPCAUnfm80, + weightMeanOccNTrackITSTPCCUnfm80); + + fillQAInfo(weightMeanOccNTrackITSUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTPCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTRDUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTOFUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackSizeUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTPCAUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTPCCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackITSTPCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackITSTPCAUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackITSTPCCUnfm80, meanOccRobustT0V0PrimUnfm80); + + fillQAInfo(weightMeanOccNTrackITSUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTPCUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTRDUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTOFUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackSizeUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTPCAUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackTPCCUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackITSTPCUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackITSTPCAUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccNTrackITSTPCCUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyOccMultExtra) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccMultNTracksHasITSUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occMultNTracksHasITSUnfm80); + meanOccMultNTracksHasTPCUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occMultNTracksHasTPCUnfm80); + meanOccMultNTracksHasTOFUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occMultNTracksHasTOFUnfm80); + meanOccMultNTracksHasTRDUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occMultNTracksHasTRDUnfm80); + meanOccMultNTracksITSOnlyUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occMultNTracksITSOnlyUnfm80); + meanOccMultNTracksTPCOnlyUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occMultNTracksTPCOnlyUnfm80); + meanOccMultNTracksITSTPCUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occMultNTracksITSTPCUnfm80); + meanOccMultAllTracksTPCOnlyUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occMultAllTracksTPCOnlyUnfm80); + genTmoMultExtra(meanOccMultNTracksHasITSUnfm80, + meanOccMultNTracksHasTPCUnfm80, + meanOccMultNTracksHasTOFUnfm80, + meanOccMultNTracksHasTRDUnfm80, + meanOccMultNTracksITSOnlyUnfm80, + meanOccMultNTracksTPCOnlyUnfm80, + meanOccMultNTracksITSTPCUnfm80, + meanOccMultAllTracksTPCOnlyUnfm80); + fillQAInfo(meanOccMultNTracksHasITSUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccMultNTracksHasTPCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccMultNTracksHasTOFUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccMultNTracksHasTRDUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccMultNTracksITSOnlyUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccMultNTracksTPCOnlyUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccMultNTracksITSTPCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccMultAllTracksTPCOnlyUnfm80, meanOccRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccMultNTracksHasITSUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occMultNTracksHasITSUnfm80); + weightMeanOccMultNTracksHasTPCUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occMultNTracksHasTPCUnfm80); + weightMeanOccMultNTracksHasTOFUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occMultNTracksHasTOFUnfm80); + weightMeanOccMultNTracksHasTRDUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occMultNTracksHasTRDUnfm80); + weightMeanOccMultNTracksITSOnlyUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occMultNTracksITSOnlyUnfm80); + weightMeanOccMultNTracksTPCOnlyUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occMultNTracksTPCOnlyUnfm80); + weightMeanOccMultNTracksITSTPCUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occMultNTracksITSTPCUnfm80); + weightMeanOccMultAllTracksTPCOnlyUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occMultAllTracksTPCOnlyUnfm80); + + genTwmoMultExtra(weightMeanOccMultNTracksHasITSUnfm80, + weightMeanOccMultNTracksHasTPCUnfm80, + weightMeanOccMultNTracksHasTOFUnfm80, + weightMeanOccMultNTracksHasTRDUnfm80, + weightMeanOccMultNTracksITSOnlyUnfm80, + weightMeanOccMultNTracksTPCOnlyUnfm80, + weightMeanOccMultNTracksITSTPCUnfm80, + weightMeanOccMultAllTracksTPCOnlyUnfm80); + + fillQAInfo(weightMeanOccMultNTracksHasITSUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksHasTPCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksHasTOFUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksHasTRDUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksITSOnlyUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksTPCOnlyUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksITSTPCUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultAllTracksTPCOnlyUnfm80, meanOccRobustT0V0PrimUnfm80); + + fillQAInfo(weightMeanOccMultNTracksHasITSUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksHasTPCUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksHasTOFUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksHasTRDUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksITSOnlyUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksTPCOnlyUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultNTracksITSTPCUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccMultAllTracksTPCOnlyUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyRobustT0V0Prim) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccRobustT0V0PrimUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occRobustT0V0PrimUnfm80); + genTmoRT0V0Prim(meanOccRobustT0V0PrimUnfm80); + fillQAInfo(meanOccRobustT0V0PrimUnfm80, meanOccRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccRobustT0V0PrimUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occRobustT0V0PrimUnfm80); + genTwmoRT0V0Prim(weightMeanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccRobustT0V0PrimUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccRobustT0V0PrimUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyRobustFDDT0V0Prim) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccRobustFDDT0V0PrimUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occRobustFDDT0V0PrimUnfm80); + genTmoRFDDT0V0Prim(meanOccRobustFDDT0V0PrimUnfm80); + fillQAInfo(meanOccRobustFDDT0V0PrimUnfm80, meanOccRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccRobustFDDT0V0PrimUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occRobustFDDT0V0PrimUnfm80); + genTwmoRFDDT0V0Pri(weightMeanOccRobustFDDT0V0PrimUnfm80); + fillQAInfo(weightMeanOccRobustFDDT0V0PrimUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccRobustFDDT0V0PrimUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyRobustNtrackDet) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccRobustNtrackDetUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occRobustNtrackDetUnfm80); + genTmoRNtrackDet(meanOccRobustNtrackDetUnfm80); + fillQAInfo(meanOccRobustNtrackDetUnfm80, meanOccRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccRobustNtrackDetUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occRobustNtrackDetUnfm80); + genTwmoRNtrackDet(weightMeanOccRobustNtrackDetUnfm80); + fillQAInfo(weightMeanOccRobustNtrackDetUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccRobustNtrackDetUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + } + } + + if constexpr (processMode == kProcessFullOccTableProducer || processMode == kProcessOnlyRobustMultExtra) { + if constexpr (meanTableMode == fillMeanOccTable) { + meanOccRobustMultTableUnfm80 = getMeanOccupancy(binBCbegin, binBCend, occRobustMultTableUnfm80); + genTmoRMultExtra(meanOccRobustMultTableUnfm80); + fillQAInfo(meanOccRobustMultTableUnfm80, meanOccRobustT0V0PrimUnfm80); + } + if constexpr (weightMeanTableMode == fillWeightMeanOccTable) { + weightMeanOccRobustMultTableUnfm80 = getWeightedMeanOccupancy(binBCbegin, binBCend, occRobustMultTableUnfm80); + genTwmoRMultExtra(weightMeanOccRobustMultTableUnfm80); + fillQAInfo(weightMeanOccRobustMultTableUnfm80, meanOccRobustT0V0PrimUnfm80); + fillQAInfo(weightMeanOccRobustMultTableUnfm80, weightMeanOccRobustT0V0PrimUnfm80); + } + } + } // end of trackQA loop + + // build the IndexTables here + if (executeInThisBlock) { + if (buildPointerTrackQAToTMOTable) { + // create pointer table from trackQA to TrackMeanOcc + sortVectorOfArray(trackQAGIListforTMOList, 0); // sort the list //Its easy to search in a sorted list + checkUniqueness(trackQAGIListforTMOList, 0); // check the uniqueness of track.globalIndex() + + int currentIDXforCheck = 0; + int listSize = trackQAGIListforTMOList.size(); + for (const auto& trackQA : tracksQA) { + while (trackQA.globalIndex() > trackQAGIListforTMOList[currentIDXforCheck][0]) { + currentIDXforCheck++; // increment the currentIDXforCheck for missing or invalid cases e.g. value = -1; + if (currentIDXforCheck >= listSize) { + break; + } + } + if (trackQA.globalIndex() == trackQAGIListforTMOList[currentIDXforCheck][0]) { + genTrackQAToTmo(trackQAGIListforTMOList[currentIDXforCheck][1]); + } else { + genTrackQAToTmo(-1); // put a dummy index when track is not found in trackQA + } + } + } + if (buildPointerTMOToTrackQATable) { + // create pointer table from TrackMeanOcc to trackQA + sortVectorOfArray(trackQAGIListforTMOList, 1); // sort the list //Its easy to search in a sorted list + checkUniqueness(trackQAGIListforTMOList, 1); // check the uniqueness of track.globalIndex() + + int currentIDXforCheck = 0; + int listSize = trackQAGIListforTMOList.size(); + for (int iCounter = 0; iCounter <= trackTMOcounter; iCounter++) { + while (iCounter > trackQAGIListforTMOList[currentIDXforCheck][1]) { + currentIDXforCheck++; // increment the currentIDXforCheck for missing or invalid cases e.g. value = -1; + if (currentIDXforCheck >= listSize) { + break; + } + } + if (iCounter == trackQAGIListforTMOList[currentIDXforCheck][1]) { + genTmoToTrackQA(trackQAGIListforTMOList[currentIDXforCheck][0]); + } else { + genTmoToTrackQA(-1); // put a dummy index when track is not found in trackQA + } + } + } + } // end of executeInThisBlock + } // end of else block of constexpr + } + + void checkAllProcessFunctionStatus(std::vector const& processStatusVector, bool& singleProcessOn) + { + int nProcessOn = 0; + const uint size = processStatusVector.size(); + for (uint i = 0; i < size; i++) { + if (processStatusVector[i]) { + nProcessOn++; + } + } + if (nProcessOn > 1) { + singleProcessOn = false; + } // check nProcess + } + + //_________________________________Process Functions start from here______________________________________________________________________________________ + void processNothing(aod::Collisions const&) + { + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessNothing); + return; + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessNothing); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processNothing, "process Nothing From Track Mean Occ Table Producer", true); + + void processOnlyOccPrim(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim, aod::OccsPrim const& occs) + { + processStatus[kProcessOnlyOccPrim] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessOnlyOccPrim] = true; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessOnlyOccPrim); + if (collisions.size() == 0) { + return; + } + if (!buildOnlyOccsPrim && !buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsPrim == false"; + return; + } + if (occs.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsPrim.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsPrim == true\" & \"processOnlyOccPrimUnfm == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, processInThisBlock[kProcessOnlyOccPrim]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessOnlyOccPrim); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processOnlyOccPrim, "processOnlyOccPrim", false); + + void processOnlyOccT0V0(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim, aod::OccsT0V0 const& occs) + { + processStatus[kProcessOnlyOccT0V0] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessOnlyOccT0V0] = true; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessOnlyOccT0V0); + if (collisions.size() == 0) { + return; + } + if (!buildOnlyOccsT0V0 && !buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsT0V0 == false"; + return; + } + if (occs.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsT0V0.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsT0V0Prim == true\" & \"processOnlyOccT0V0PrimUnfm == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, processInThisBlock[kProcessOnlyOccT0V0]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessOnlyOccT0V0); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processOnlyOccT0V0, "processOnlyOccT0V0", false); + + void processOnlyOccFDD(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim, aod::OccsFDD const& occs) + { + processStatus[kProcessOnlyOccFDD] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessOnlyOccFDD] = true; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessOnlyOccFDD); + if (collisions.size() == 0) { + return; + } + if (!buildOnlyOccsFDD && !buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsFDD == false"; + return; + } + if (occs.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsFDD.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsFDDT0V0Prim == true\" & \"processOnlyOccFDDT0V0PrimUnfm == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, processInThisBlock[kProcessOnlyOccFDD]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessOnlyOccFDD); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processOnlyOccFDD, "processOnlyOccFDD", false); + + void processOnlyOccNtrackDet(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim, aod::OccsNTrackDet const& occs) + { + processStatus[kProcessOnlyOccNtrackDet] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessOnlyOccNtrackDet] = true; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessOnlyOccNtrackDet); + if (collisions.size() == 0) { + return; + } + if (!buildOnlyOccsNtrackDet && !buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsNtrackDet == false"; + return; + } + if (occs.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsNtrackDet.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsNtrackDet == true\" & \"processOnlyOccNtrackDet == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, processInThisBlock[kProcessOnlyOccNtrackDet]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessOnlyOccNtrackDet); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processOnlyOccNtrackDet, "processOnlyOccNtrackDet", false); + + void processOnlyOccMultExtra(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim, aod::OccsMultExtra const& occs) + { + processStatus[kProcessOnlyOccMultExtra] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessOnlyOccMultExtra] = true; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessOnlyOccMultExtra); + if (collisions.size() == 0) { + return; + } + if (!buildOnlyOccsMultExtra && !buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsMultExtra == false"; + return; + } + if (occs.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsMultExtra.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsMultExtra == true\" & \"processOnlyOccMultExtra == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, processInThisBlock[kProcessOnlyOccMultExtra]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessOnlyOccMultExtra); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processOnlyOccMultExtra, "processOnlyOccMultExtra", false); + + void processOnlyRobustT0V0Prim(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim) + { + processStatus[kProcessOnlyRobustT0V0Prim] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessOnlyRobustT0V0Prim] = true; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessOnlyRobustT0V0Prim); + if (collisions.size() == 0) { + return; + } + if (!buildOnlyOccsRobustT0V0Prim && !buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsRobustT0V0Prim == false"; + return; + } + if (occsRobustT0V0Prim.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsRobustT0V0Prim.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsT0V0Prim == true\" & \"processOnlyOccT0V0PrimUnfm == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occsRobustT0V0Prim, processInThisBlock[kProcessOnlyRobustT0V0Prim]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessOnlyRobustT0V0Prim); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processOnlyRobustT0V0Prim, "processOnlyRobustT0V0Prim", false); + + void processOnlyRobustFDDT0V0Prim(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim, aod::ORFDDT0V0Prim const& occs) + { + processStatus[kProcessOnlyRobustFDDT0V0Prim] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessOnlyRobustFDDT0V0Prim] = true; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessOnlyRobustFDDT0V0Prim); + if (collisions.size() == 0) { + return; + } + if (!buildOnlyOccsRobustFDDT0V0Prim && !buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsRobustFDDT0V0Prim == false"; + return; + } + if (occs.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsRobustFDDT0V0Prim.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsFDDT0V0Prim == true\" & \"processOnlyOccFDDT0V0PrimUnfm == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, processInThisBlock[kProcessOnlyRobustFDDT0V0Prim]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessOnlyRobustFDDT0V0Prim); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processOnlyRobustFDDT0V0Prim, "processOnlyRobustFDDT0V0Prim", false); + + void processOnlyRobustNtrackDet(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim, aod::ORNtrackDet const& occs) + { + processStatus[kProcessOnlyRobustNtrackDet] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessOnlyRobustNtrackDet] = true; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessOnlyRobustNtrackDet); + if (collisions.size() == 0) { + return; + } + if (!buildOnlyOccsRobustNtrackDet && !buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsRobustNtrackDet == false"; + return; + } + if (occs.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsRobustNtrackDet.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsNtrackDet == true\" & \"processOnlyOccNtrackDet == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, processInThisBlock[kProcessOnlyRobustNtrackDet]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessOnlyRobustNtrackDet); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processOnlyRobustNtrackDet, "processOnlyRobustNtrackDet", false); + + void processOnlyRobustMultExtra(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim, aod::ORMultExtra const& occs) + { + processStatus[kProcessOnlyRobustMultExtra] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessOnlyRobustMultExtra] = true; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessOnlyRobustMultExtra); + if (collisions.size() == 0) { + return; + } + if (!buildOnlyOccsRobustMultExtra && !buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildOnlyOccsRobustMultExtra == false"; + return; + } + if (occs.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: OccsRobustMultExtra.size() == 0 :: Check \"occupancy-table-producer\" for \"buildOnlyOccsMultExtra == true\" & \"processOnlyOccMultExtra == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, processInThisBlock[kProcessOnlyRobustMultExtra]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessOnlyRobustMultExtra); + } + PROCESS_SWITCH(TrackMeanOccTableProducer, processOnlyRobustMultExtra, "processOnlyRobustMultExtra", false); + + using JoinedOccTables = soa::Join; + void processFullOccTableProduer(soa::Join const& BCs, aod::Collisions const& collisions, aod::Tracks const& tracks, MyTracksQA const& tracksQA, aod::ORT0V0Prim const& occsRobustT0V0Prim, JoinedOccTables const& occs) + { + processStatus[kProcessFullOccTableProducer] = true; + bool singleProcessOn = true; + checkAllProcessFunctionStatus(processStatus, singleProcessOn); + if (singleProcessOn) { + processInThisBlock[kProcessFullOccTableProducer] = true; + } + if (!singleProcessOn) { + LOG(error) << "More than one process functions are on in track-mean-occ-table-producer"; + return; + } + occupancyQA.fill(HIST("h_DFcount_Lvl0"), kProcessFullOccTableProducer); + if (collisions.size() == 0) { + return; + } + if (!buildFullOccTableProducer) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: buildFullOccTableProducer == false"; + return; + } + if (occs.size() == 0) { + LOG(error) << "DEBUG :: ERROR ERROR ERROR :: Full Occ Table Join size is 0 :: Check \"occupancy-table-producer\" for \"buildFullOccTableProducer == true\" & \"processFullOccTableProduer == true\""; + return; + } + executeTrackOccProducerProcessing(BCs, collisions, tracks, tracksQA, occsRobustT0V0Prim, occs, processInThisBlock[kProcessFullOccTableProducer]); + occupancyQA.fill(HIST("h_DFcount_Lvl1"), kProcessFullOccTableProducer); + } // Process function ends + PROCESS_SWITCH(TrackMeanOccTableProducer, processFullOccTableProduer, "processFullOccTableProduer", false); +}; + +struct CreatePointerTables { + + Produces genTrackToTracksQA; + Produces genTrackToTmo; + + void processNothing(aod::Collisions const&) + { + return; + } + PROCESS_SWITCH(CreatePointerTables, processNothing, "process Nothing", true); + + std::vector> trackGIForTrackQAIndexList; + using MyTracksQA = aod::TracksQAVersion; + void processTrackToTrackQAPointer(aod::Tracks const& tracks, MyTracksQA const& tracksQA) + { + trackGIForTrackQAIndexList.clear(); + for (const auto& trackQA : tracksQA) { + auto const& track = trackQA.template track_as(); + trackGIForTrackQAIndexList.push_back({track.globalIndex(), trackQA.globalIndex()}); + } + + sortVectorOfArray(trackGIForTrackQAIndexList, 0); // sort the list //Its easy to search in a sorted list + checkUniqueness(trackGIForTrackQAIndexList, 0); // check the uniqueness of track.globalIndex() + + // create pointer table + int currentIDXforCheck = 0; + int listSize = trackGIForTrackQAIndexList.size(); + + for (const auto& track : tracks) { + while (track.globalIndex() > trackGIForTrackQAIndexList[currentIDXforCheck][0]) { + currentIDXforCheck++; // increment the currentIDXforCheck for missing or invalid cases e.g. value = -1; + if (currentIDXforCheck >= listSize) { + break; + } + } + if (track.globalIndex() == trackGIForTrackQAIndexList[currentIDXforCheck][0]) { + genTrackToTracksQA(trackGIForTrackQAIndexList[currentIDXforCheck][1]); + } else { + genTrackToTracksQA(-1); // put a dummy index when track is not found in trackQA + } + } + } + PROCESS_SWITCH(CreatePointerTables, processTrackToTrackQAPointer, "processTrackToTrackQAPointer", false); + + std::vector> trackGIForTMOIndexList; + void processTrackToTrackMeanOccsPointer(aod::Tracks const& tracks, aod::TmoTrackIds const& tmoTrackIds) + { + trackGIForTMOIndexList.clear(); + int tmoCounter = -1; + for (const auto& tmoTrackId : tmoTrackIds) { + tmoCounter++; + auto const& track = tmoTrackId.template track_as(); + trackGIForTMOIndexList.push_back({track.globalIndex(), tmoCounter}); // tmoTrackId Global Index is not working :: tmoTrackId.globalIndex()}); + } + sortVectorOfArray(trackGIForTMOIndexList, 0); // sort the list //Its easy to search in a sorted list + checkUniqueness(trackGIForTMOIndexList, 0); // check the uniqueness of track.globalIndex() + + // create pointer table + int currentIDXforCheck = 0; + int listSize = trackGIForTMOIndexList.size(); + + for (const auto& track : tracks) { + while (track.globalIndex() > trackGIForTMOIndexList[currentIDXforCheck][0]) { + currentIDXforCheck++; // increment the currentIDXforCheck for missing or invalid cases e.g. value = -1; + if (currentIDXforCheck >= listSize) { + break; + } + } + if (track.globalIndex() == trackGIForTMOIndexList[currentIDXforCheck][0]) { + genTrackToTmo(trackGIForTMOIndexList[currentIDXforCheck][1]); + } else { + genTrackToTmo(-1); // put a dummy index when track is not found in trackQA + } + } + } + PROCESS_SWITCH(CreatePointerTables, processTrackToTrackMeanOccsPointer, "processTrackToTrackMeanOccsPointer", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; +} diff --git a/Common/TableProducer/qVectorsTable.cxx b/Common/TableProducer/qVectorsTable.cxx index 9de8faf028f..e27fecb3c8c 100644 --- a/Common/TableProducer/qVectorsTable.cxx +++ b/Common/TableProducer/qVectorsTable.cxx @@ -19,11 +19,13 @@ /// // C++/ROOT includes. +#include +#include + #include #include +#include #include -#include -#include // o2Physics includes. #include "Framework/AnalysisDataModel.h" @@ -78,6 +80,9 @@ struct qVectorsTable { Configurable cfgMinPtOnTPC{"cfgMinPtOnTPC", 0.15, "minimum transverse momentum selection for TPC tracks participating in Q-vector reconstruction"}; Configurable cfgMaxPtOnTPC{"cfgMaxPtOnTPC", 5., "maximum transverse momentum selection for TPC tracks participating in Q-vector reconstruction"}; + Configurable cfgEtaMax{"cfgEtaMax", 0.8, "Maximum pseudorapidiy for charged track"}; + Configurable cfgEtaMin{"cfgEtaMin", -0.8, "Minimum pseudorapidiy for charged track"}; + Configurable cfgCorrLevel{"cfgCorrLevel", 4, "calibration step: 0 = no corr, 1 = gain corr, 2 = rectr, 3 = twist, 4 = full"}; Configurable> cfgnMods{"cfgnMods", {2, 3}, "Modulation of interest"}; Configurable cfgMaxCentrality{"cfgMaxCentrality", 100.f, "max. centrality for Q vector calibration"}; @@ -437,7 +442,10 @@ struct qVectorsTable { continue; } histosQA.fill(HIST("ChTracks"), trk.pt(), trk.eta(), trk.phi(), cent); - if (std::abs(trk.eta()) > 0.8) { + if (trk.eta() > cfgEtaMax) { + continue; + } + if (trk.eta() < cfgEtaMin) { continue; } qVectTPCall[0] += trk.pt() * std::cos(trk.phi() * nmode); diff --git a/Common/TableProducer/selectionStudyTable.cxx b/Common/TableProducer/selectionStudyTable.cxx new file mode 100644 index 00000000000..4d27e358ed1 --- /dev/null +++ b/Common/TableProducer/selectionStudyTable.cxx @@ -0,0 +1,133 @@ +// 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. +// +/// \file selectionStudyTable.cxx +/// \brief Produces tables for centrality selection bias studies +/// +/// \author ALICE +/// + +#include "Common/DataModel/SelectionStudyTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ConfigParamSpec.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct SelectionStudyTable { + Produces pidpts; + + // could be done in a vector of vectors + // left for future iteration + std::vector ptpi; + std::vector ptka; + std::vector ptpr; + std::vector ptk0; + std::vector ptla; + std::vector ptxi; + std::vector ptom; + std::vector ptph; + std::vector ptks; + std::vector ptd; + std::vector ptlc; + std::vector ptjp; + + void init(InitContext&) + { + } + + void process(aod::McCollision const&, aod::McParticles const& mcParticles) + { + ptpi.clear(); + ptka.clear(); + ptpr.clear(); + ptk0.clear(); + ptla.clear(); + ptxi.clear(); + ptom.clear(); + ptph.clear(); + ptks.clear(); + ptd.clear(); + ptlc.clear(); + ptjp.clear(); + for (auto const& mcPart : mcParticles) { + if (std::fabs(mcPart.y()) > 0.5) { + continue; // only do midrapidity particles + } + + // handle resonances first to make sure phys prim crit does not reject them + if (mcPart.pdgCode() == 333) { + ptph.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 313) { + ptks.push_back(mcPart.pt()); + } + + // resonances handled, move to primaries + if (!mcPart.isPhysicalPrimary()) { + continue; + } + if (std::abs(mcPart.pdgCode()) == 211) { + ptpi.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 321) { + ptka.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 2212) { + ptpr.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 310) { + ptk0.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 3122) { + ptla.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 3312) { + ptxi.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 3334) { + ptom.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 3334) { + ptom.push_back(mcPart.pt()); + } + // inclusive HF for now + if (std::abs(mcPart.pdgCode()) == 421) { + ptd.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 4122) { + ptd.push_back(mcPart.pt()); + } + if (std::abs(mcPart.pdgCode()) == 443) { + ptjp.push_back(mcPart.pt()); + } + } + + pidpts(ptpi, ptka, ptpr, ptk0, ptla, ptxi, ptom, ptph, ptks, ptd, ptlc, ptjp); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/Common/TableProducer/timestamp.cxx b/Common/TableProducer/timestamp.cxx index e3d37f7129b..40ab7000772 100644 --- a/Common/TableProducer/timestamp.cxx +++ b/Common/TableProducer/timestamp.cxx @@ -29,7 +29,7 @@ using namespace o2::framework; using namespace o2::header; using namespace o2; -MetadataHelper metadataInfo; // Metadata helper +o2::common::core::MetadataHelper metadataInfo; // Metadata helper struct TimestampTask { Produces timestampTable; /// Table with SOR timestamps produced by the task diff --git a/Common/TableProducer/timestampTester.cxx b/Common/TableProducer/timestampTester.cxx new file mode 100644 index 00000000000..037cd4e38f3 --- /dev/null +++ b/Common/TableProducer/timestampTester.cxx @@ -0,0 +1,72 @@ +// 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. + +/// +/// \file timestamp.cxx +/// \author Nicolò Jacazio +/// \since 2020-06-22 +/// \brief A task to fill the timestamp table from run number. +/// Uses headers from CCDB +/// +#include "MetadataHelper.h" + +#include "Common/Tools/timestampModule.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonDataFormat/InteractionRecord.h" +#include "DetectorsRaw/HBFUtils.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include +#include + +using namespace o2::framework; +using namespace o2::header; +using namespace o2; + +o2::common::core::MetadataHelper metadataInfo; // Metadata helper + +struct TimestampTask { + Produces timestampTable; /// Table with SOR timestamps produced by the task + Service ccdb; /// CCDB manager to access orbit-reset timestamp + o2::ccdb::CcdbApi ccdb_api; /// API to access CCDB headers + + Configurable ccdb_url{"ccdb-url", "http://alice-ccdb.cern.ch", "URL of the CCDB database"}; + + o2::common::timestamp::timestampConfigurables timestampConfigurables; + o2::common::timestamp::TimestampModule timestampMod; + + std::vector timestampBuffer; + + void init(o2::framework::InitContext&) + { + // CCDB initialization + ccdb->setURL(ccdb_url.value); + ccdb_api.init(ccdb_url.value); + + // timestamp configuration + init + timestampMod.init(timestampConfigurables, metadataInfo); + } + + void process(aod::BCs const& bcs) + { + timestampMod.process(bcs, ccdb, timestampBuffer, timestampTable); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + // Parse the metadata + metadataInfo.initMetadata(cfgc); + + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/Common/TableProducer/trackDcaCovFillerRun2.cxx b/Common/TableProducer/trackDcaCovFillerRun2.cxx new file mode 100644 index 00000000000..d07833ae9e0 --- /dev/null +++ b/Common/TableProducer/trackDcaCovFillerRun2.cxx @@ -0,0 +1,179 @@ +// 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. + +/// \file trackDcaCovFillerRun2.cxx +/// \author Aimeric Landou , CERN +/// \brief Fills DCA and DCA Cov tables for Run 2 tracks +// Run 2 AO2Ds cannot have their dcacov filled by the current track-propagation workflow as the workflow isn't designed for them, given Run 2 tracks are already propagated to the PV. +// This task fills the DCA Cov (and DCA) tables for Run 2 tracks by "propagating" the tracks (though given they are already at the PV it doesn't actually do the propagation) and retrieving the DCA and DCA cov given by the propagateToDCABxByBz function + +#include + +#include "TableHelper.h" +#include "Common/Tools/TrackTuner.h" +#include "DataFormatsParameters/GRPObject.h" + +using namespace o2; +using namespace o2::framework; +// using namespace o2::framework::expressions; + +struct TrackDcaCovFillerRun2 { + Produces tracksDCA; + Produces tracksDCACov; + + // Produces tunertable; + + Service ccdb; + + bool fillTracksDCA = false; + bool fillTracksDCACov = false; + int runNumber = -1; + + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + + const o2::dataformats::MeanVertexObject* mMeanVtx = nullptr; + o2::parameters::GRPMagField* grpmag = nullptr; + o2::base::MatLayerCylSet* lut = nullptr; + + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPathGrp{"ccdbPathGrp", "GLO/GRP/GRP", "CCDB path of the grp file (run2)"}; + Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; + + HistogramRegistry registry{"registry"}; + + void init(o2::framework::InitContext& initContext) + { + // Checking if the tables are requested in the workflow and enabling them + fillTracksDCA = isTableRequiredInWorkflow(initContext, "TracksDCA"); + fillTracksDCACov = isTableRequiredInWorkflow(initContext, "TracksDCACov"); + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (runNumber == bc.runNumber()) { + return; + } + + // Run 2 GRP object + o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(ccdbPathGrp, bc.timestamp()); + if (grpo == nullptr) { + LOGF(fatal, "Run 2 GRP object (type o2::parameters::GRPObject) is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp()); + } + o2::base::Propagator::initFieldFromGRP(grpo); + LOGF(info, "Setting magnetic field to %d kG for run %d from its GRP CCDB object (type o2::parameters::GRPObject)", grpo->getNominalL3Field(), bc.runNumber()); + + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + runNumber = bc.runNumber(); + } + + // Running variables + std::array mDcaInfo; + o2::dataformats::DCA mDcaInfoCov; + o2::dataformats::VertexBase mVtx; + o2::track::TrackParametrization mTrackPar; + o2::track::TrackParametrizationWithError mTrackParCov; + + template + void fillTrackTables(TTrack const& tracks, + TParticle const&, + aod::Collisions const&, + aod::BCsWithTimestamps const& bcs) + { + if (bcs.size() == 0) { + return; + } + initCCDB(bcs.begin()); + + if constexpr (fillCovMat) { + if (fillTracksDCACov) { + tracksDCACov.reserve(tracks.size()); + } + } else { + if (fillTracksDCA) { + tracksDCA.reserve(tracks.size()); + } + } + + for (auto const& track : tracks) { + if constexpr (fillCovMat) { + if (fillTracksDCA || fillTracksDCACov) { + mDcaInfoCov.set(999, 999, 999, 999, 999); + } + setTrackParCov(track, mTrackParCov); + } else { + if (fillTracksDCA) { + mDcaInfo[0] = 999; + mDcaInfo[1] = 999; + } + setTrackPar(track, mTrackPar); + } + + if (track.has_collision()) { + auto const& collision = track.collision(); + if constexpr (fillCovMat) { + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, mTrackParCov, 2.f, matCorr, &mDcaInfoCov); + } else { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, mTrackPar, 2.f, matCorr, &mDcaInfo); + } + } else { + if constexpr (fillCovMat) { + mVtx.setPos({mMeanVtx->getX(), mMeanVtx->getY(), mMeanVtx->getZ()}); + mVtx.setCov(mMeanVtx->getSigmaX() * mMeanVtx->getSigmaX(), 0.0f, mMeanVtx->getSigmaY() * mMeanVtx->getSigmaY(), 0.0f, 0.0f, mMeanVtx->getSigmaZ() * mMeanVtx->getSigmaZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, mTrackParCov, 2.f, matCorr, &mDcaInfoCov); + } else { + o2::base::Propagator::Instance()->propagateToDCABxByBz({mMeanVtx->getX(), mMeanVtx->getY(), mMeanVtx->getZ()}, mTrackPar, 2.f, matCorr, &mDcaInfo); + } + } + + if constexpr (fillCovMat) { + if (fillTracksDCA) { + tracksDCA(mDcaInfoCov.getY(), mDcaInfoCov.getZ()); + } + if (fillTracksDCACov) { + tracksDCACov(mDcaInfoCov.getSigmaY2(), mDcaInfoCov.getSigmaZ2()); + } + } else { + if (fillTracksDCA) { + tracksDCA(mDcaInfo[0], mDcaInfo[1]); + } + } + } + } + + void processCovariance(soa::Join const& tracks, aod::Collisions const& collisions, aod::BCsWithTimestamps const& bcs) + { + fillTrackTables, /*Particle*/ soa::Join, /*isMc = */ false, /*fillCovMat =*/true>(tracks, tracks, collisions, bcs); + } + PROCESS_SWITCH(TrackDcaCovFillerRun2, processCovariance, "Process with covariance", false); + + void processStandard(soa::Join const& tracks, aod::Collisions const& collisions, aod::BCsWithTimestamps const& bcs) + { + fillTrackTables, /*Particle*/ soa::Join, /*isMc = */ false, /*fillCovMat =*/false>(tracks, tracks, collisions, bcs); + } + PROCESS_SWITCH(TrackDcaCovFillerRun2, processStandard, "Process without covariance", true); +}; + +//**************************************************************************************** +/** + * Workflow definition. + */ +//**************************************************************************************** +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/Common/TableProducer/trackPropagation.cxx b/Common/TableProducer/trackPropagation.cxx index 073533a191c..e1b6528ce53 100644 --- a/Common/TableProducer/trackPropagation.cxx +++ b/Common/TableProducer/trackPropagation.cxx @@ -162,7 +162,7 @@ struct TrackPropagation { } // Running variables - gpu::gpustd::array mDcaInfo; + std::array mDcaInfo; o2::dataformats::DCA mDcaInfoCov; o2::dataformats::VertexBase mVtx; o2::track::TrackParametrization mTrackPar; diff --git a/Common/TableProducer/trackPropagationTester.cxx b/Common/TableProducer/trackPropagationTester.cxx index 92139a4fceb..18543ee0994 100644 --- a/Common/TableProducer/trackPropagationTester.cxx +++ b/Common/TableProducer/trackPropagationTester.cxx @@ -9,31 +9,42 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file trackPropagationTester.cxx +/// \brief testing ground for track propagation +/// \author ALICE + +//=============================================================== +// +// Experimental version of the track propagation task +// this utilizes an analysis task module that can be employed elsewhere +// and allows for the re-utilization of a material LUT // -// Task to add a table of track parameters propagated to the primary vertex +// candidate approach for core service approach // -// FIXME: THIS IS AN EXPERIMENTAL TASK, MEANT ONLY FOR EXPLORATORY PURPOSES. -// FIXME: PLEASE ONLY USE IT WITH EXTREME CARE. IF IN DOUBT, STICK WITH THE DEFAULT -// FIXME: TRACKPROPAGATION +//=============================================================== -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/Core/trackUtilities.h" -#include "ReconstructionDataFormats/DCA.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "CommonUtils/NameConf.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Tools/StandardCCDBLoader.h" +#include "Common/Tools/TrackPropagationModule.h" +#include "Common/Tools/TrackTuner.h" + +#include "CCDB/BasicCCDBManager.h" #include "CCDB/CcdbApi.h" +#include "CommonConstants/GeomConstants.h" +#include "CommonUtils/NameConf.h" +#include "DataFormatsCalibration/MeanVertexObject.h" #include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" #include "Framework/runDataProcessing.h" -#include "DataFormatsCalibration/MeanVertexObject.h" -#include "CommonConstants/GeomConstants.h" -#include "trackSelectionRequest.h" +#include "ReconstructionDataFormats/DCA.h" + +#include // The Run 3 AO2D stores the tracks at the point of innermost update. For a track with ITS this is the innermost (or second innermost) // ITS layer. For a track without ITS, this is the TPC inner wall or for loopers in the TPC even a radius beyond that. @@ -48,294 +59,48 @@ using namespace o2::framework; // using namespace o2::framework::expressions; struct TrackPropagationTester { - Produces tracksParPropagated; - Produces tracksParExtensionPropagated; + o2::common::StandardCCDBLoaderConfigurables standardCCDBLoaderConfigurables; + o2::common::TrackPropagationProducts trackPropagationProducts; + o2::common::TrackPropagationConfigurables trackPropagationConfigurables; - Produces tracksParCovPropagated; - Produces tracksParCovExtensionPropagated; - - Produces tracksDCA; + // the track tuner object -> needs to be here as it inherits from ConfigurableGroup (+ has its own copy of ccdbApi) + TrackTuner trackTunerObj; + // CCDB boilerplate declarations + o2::framework::Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Service ccdb; - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - bool fillTracksDCA = false; - int runNumber = -1; - - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; - - const o2::dataformats::MeanVertexObject* mVtx = nullptr; - o2::parameters::GRPMagField* grpmag = nullptr; - o2::base::MatLayerCylSet* lut = nullptr; - - // Track selection object in this scope: not necessarily a configurable - trackSelectionRequest trackSels; - // Configurable based on a struct - // Configurable trackSels{"trackSels", {}, "track selections"}; - - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; - Configurable minPropagationRadius{"minPropagationDistance", o2::constants::geom::XTPCInnerRef + 0.1, "Only tracks which are at a smaller radius will be propagated, defaults to TPC inner wall"}; - - // Configurables regarding what to propagate - // FIXME: This is dangerous and error prone for general purpose use. It is meant ONLY for testing. - Configurable propagateUnassociated{"propagateUnassociated", false, "propagate tracks with no collision assoc"}; - Configurable propagateTPConly{"propagateTPConly", false, "propagate tracks with only TPC (no ITS, TRD, TOF)"}; - Configurable minTPCClusters{"minTPCClusters", 70, "min number of TPC clusters to propagate"}; - Configurable maxPropagStep{"maxPropagStep", 2.0, "max propag step"}; // to be checked systematically - // use auto-detect configuration - Configurable d_UseAutodetectMode{"d_UseAutodetectMode", false, "Autodetect requested track criteria"}; + o2::common::StandardCCDBLoader ccdbLoader; + o2::common::TrackPropagationModule trackPropagation; - bool hasEnding(std::string const& fullString, std::string const& ending) - { - if (fullString.length() >= ending.length()) { - return (0 == fullString.compare(fullString.length() - ending.length(), ending.length(), ending)); - } else { - return false; - } - } + HistogramRegistry registry{"registry"}; void init(o2::framework::InitContext& initContext) { - const AxisSpec axisX{(int)4, 0.0f, +4.0f, "Track counter"}; - histos.add("hTrackCounter", "hTrackCounter", kTH1F, {axisX}); - - if (doprocessCovariance == true && doprocessStandard == true) { - LOGF(fatal, "Cannot enable processStandard and processCovariance at the same time. Please choose one."); - } - - // Checking if the tables are requested in the workflow and enabling them - auto& workflows = initContext.services().get(); - for (DeviceSpec const& device : workflows.devices) { - for (auto const& input : device.inputs) { - if (input.matcher.binding == "TracksDCA") { - fillTracksDCA = true; - } - } - } - - ccdb->setURL(ccdburl); + // CCDB boilerplate init ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); + ccdb->setURL(ccdburl.value); - lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); - - if (d_UseAutodetectMode) { - LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); - LOGF(info, " Track propagator self-configuration"); - LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); - trackSels.SetTightSelections(); // Only loosen from this point forward - for (DeviceSpec const& device : workflows.devices) { - // Loop over options to find track selection - for (auto const& option : device.options) { - if (hasEnding(option.name, ".requireTPC")) { - bool lVal = option.defaultValue.get(); - LOGF(info, "Device %s, request TPC: %i", device.name, lVal); - if (trackSels.getRequireTPC() == false) - trackSels.setRequireTPC(lVal); - } - if (hasEnding(option.name, ".minTPCclusters")) { - int lVal = option.defaultValue.get(); - LOGF(info, "Device %s, min TPC clusters: %i", device.name, lVal); - if (trackSels.getMinTPCClusters() > lVal) - trackSels.setMinTPCClusters(lVal); - } - if (hasEnding(option.name, ".minTPCcrossedrows")) { - int lVal = option.defaultValue.get(); - LOGF(info, "Device %s, min TPC crossed rows: %i", device.name, lVal); - if (trackSels.getMinTPCCrossedRows() > lVal) - trackSels.setMinTPCCrossedRows(lVal); - } - if (hasEnding(option.name, ".minTPCcrossedrowsoverfindable")) { - float lVal = option.defaultValue.get(); - LOGF(info, "Device %s, min TPC crossed rows over findable: %.3f", device.name, lVal); - if (trackSels.getMinTPCCrossedRowsOverFindable() > lVal) - trackSels.setMinTPCCrossedRowsOverFindable(lVal); - } - if (hasEnding(option.name, ".requireITS")) { - bool lVal = option.defaultValue.get(); - LOGF(info, "Device %s, request ITS: %i", device.name, lVal); - if (trackSels.getRequireITS() == false) - trackSels.setRequireITS(lVal); - } - if (hasEnding(option.name, ".minITSclusters")) { - int lVal = option.defaultValue.get(); - LOGF(info, "Device %s, minimum ITS clusters: %i", device.name, lVal); - if (trackSels.getMinITSClusters() > lVal) - trackSels.setMinITSClusters(lVal); - } - if (hasEnding(option.name, ".maxITSChi2percluster")) { - float lVal = option.defaultValue.get(); - LOGF(info, "Device %s, max ITS chi2/clu: %.3f", device.name, lVal); - if (trackSels.getMaxITSChi2PerCluster() < lVal) - trackSels.setMaxITSChi2PerCluster(lVal); - } - } - } - LOGF(info, "-+*> Automatic self-config ended. Final settings:"); - trackSels.PrintSelections(); - } + // task-specific + trackPropagation.init(trackPropagationConfigurables, trackTunerObj, registry, initContext); } - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + void processReal(aod::Collisions const& collisions, soa::Join const& tracks, aod::Collisions const&, aod::BCs const& bcs) { - if (runNumber == bc.runNumber()) { - return; - } - grpmag = ccdb->getForTimeStamp(grpmagPath, bc.timestamp()); - LOG(info) << "Setting magnetic field to current " << grpmag->getL3Current() << " A for run " << bc.runNumber() << " from its GRPMagField CCDB object"; - o2::base::Propagator::initFieldFromGRP(grpmag); - o2::base::Propagator::Instance()->setMatLUT(lut); - if (propagateUnassociated) - mVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); - runNumber = bc.runNumber(); + // task-specific + ccdbLoader.initCCDBfromBCs(standardCCDBLoaderConfigurables, ccdb, bcs); + trackPropagation.fillTrackTables(trackPropagationConfigurables, trackTunerObj, ccdbLoader, collisions, tracks, trackPropagationProducts, registry); } + PROCESS_SWITCH(TrackPropagationTester, processReal, "Process Real Data", true); - template - void FillTracksPar(TTrack& track, aod::track::TrackTypeEnum trackType, TTrackPar& trackPar) + // ----------------------- + void processMc(aod::Collisions const& collisions, soa::Join const& tracks, aod::McParticles const&, aod::Collisions const&, aod::BCs const& bcs) { - tracksParPropagated(track.collisionId(), trackType, trackPar.getX(), trackPar.getAlpha(), trackPar.getY(), trackPar.getZ(), trackPar.getSnp(), trackPar.getTgl(), trackPar.getQ2Pt()); - tracksParExtensionPropagated(trackPar.getPt(), trackPar.getP(), trackPar.getEta(), trackPar.getPhi()); - } - - void processStandard(soa::Join const& tracks, aod::Collisions const&, aod::BCsWithTimestamps const& bcs) - { - if (bcs.size() == 0) { - return; - } - initCCDB(bcs.begin()); - - gpu::gpustd::array dcaInfo; - - int lNAll = 0; - int lNaccTPC = 0; - int lNaccNotTPCOnly = 0; - int lNPropagated = 0; - bool passTPCclu = kFALSE; - bool passNotTPCOnly = kFALSE; - - for (auto& track : tracks) { - // Selection criteria - passTPCclu = kFALSE; - passNotTPCOnly = kFALSE; - lNAll++; - if (track.tpcNClsFound() >= minTPCClusters) { - passTPCclu = kTRUE; - lNaccTPC++; - } - if ((track.hasTPC() && !track.hasITS() && !track.hasTRD() && !track.hasTOF()) || propagateTPConly) { - passNotTPCOnly = kTRUE; - lNaccNotTPCOnly++; - } - - dcaInfo[0] = 999; - dcaInfo[1] = 999; - aod::track::TrackTypeEnum trackType = (aod::track::TrackTypeEnum)track.trackType(); - auto trackPar = getTrackPar(track); - // Only propagate tracks which have passed the innermost wall of the TPC (e.g. skipping loopers etc). Others fill unpropagated. - if (track.trackType() == aod::track::TrackIU && track.x() < minPropagationRadius && passTPCclu && passNotTPCOnly) { - if (track.has_collision()) { - auto const& collision = track.collision(); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPar, maxPropagStep, matCorr, &dcaInfo); - trackType = aod::track::Track; - lNPropagated++; - } else { - if (propagateUnassociated) { - o2::base::Propagator::Instance()->propagateToDCABxByBz({mVtx->getX(), mVtx->getY(), mVtx->getZ()}, trackPar, maxPropagStep, matCorr, &dcaInfo); - trackType = aod::track::Track; - lNPropagated++; - } - } - } - FillTracksPar(track, trackType, trackPar); - if (fillTracksDCA) { - tracksDCA(dcaInfo[0], dcaInfo[1]); - } - } - // Fill only per table (not per track). ROOT FindBin is slow - histos.fill(HIST("hTrackCounter"), 0.5, lNAll); - histos.fill(HIST("hTrackCounter"), 1.5, lNaccTPC); - histos.fill(HIST("hTrackCounter"), 2.5, lNaccNotTPCOnly); - histos.fill(HIST("hTrackCounter"), 3.5, lNPropagated); - } - PROCESS_SWITCH(TrackPropagationTester, processStandard, "Process without covariance", true); - - void processCovariance(soa::Join const& tracks, aod::Collisions const&, aod::BCsWithTimestamps const& bcs) - { - if (bcs.size() == 0) { - return; - } - initCCDB(bcs.begin()); - - o2::dataformats::DCA dcaInfoCov; - o2::dataformats::VertexBase vtx; - - int lNAll = 0; - int lNaccTPC = 0; - int lNaccNotTPCOnly = 0; - int lNPropagated = 0; - bool passTPCclu = kFALSE; - bool passNotTPCOnly = kFALSE; - - for (auto& track : tracks) { - // Selection criteria - passTPCclu = kFALSE; - passNotTPCOnly = kFALSE; - lNAll++; - if (track.tpcNClsFound() >= minTPCClusters) { - passTPCclu = kTRUE; - lNaccTPC++; - } - if ((track.hasTPC() && !track.hasITS() && !track.hasTRD() && !track.hasTOF()) || propagateTPConly) { - passNotTPCOnly = kTRUE; - lNaccNotTPCOnly++; - } - - dcaInfoCov.set(999, 999, 999, 999, 999); - auto trackParCov = getTrackParCov(track); - aod::track::TrackTypeEnum trackType = (aod::track::TrackTypeEnum)track.trackType(); - // Only propagate tracks which have passed the innermost wall of the TPC (e.g. skipping loopers etc). Others fill unpropagated. - if (track.trackType() == aod::track::TrackIU && track.x() < minPropagationRadius && passTPCclu && passNotTPCOnly) { - if (track.has_collision()) { - auto const& collision = track.collision(); - vtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); - vtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); - o2::base::Propagator::Instance()->propagateToDCABxByBz(vtx, trackParCov, maxPropagStep, matCorr, &dcaInfoCov); - trackType = aod::track::Track; - lNPropagated++; - } else { - if (propagateUnassociated) { - vtx.setPos({mVtx->getX(), mVtx->getY(), mVtx->getZ()}); - vtx.setCov(mVtx->getSigmaX() * mVtx->getSigmaX(), 0.0f, mVtx->getSigmaY() * mVtx->getSigmaY(), 0.0f, 0.0f, mVtx->getSigmaZ() * mVtx->getSigmaZ()); - o2::base::Propagator::Instance()->propagateToDCABxByBz(vtx, trackParCov, maxPropagStep, matCorr, &dcaInfoCov); - trackType = aod::track::Track; - lNPropagated++; - } - } - } - FillTracksPar(track, trackType, trackParCov); - if (fillTracksDCA) { - tracksDCA(dcaInfoCov.getY(), dcaInfoCov.getZ()); - } - // TODO do we keep the rho as 0? Also the sigma's are duplicated information - tracksParCovPropagated(std::sqrt(trackParCov.getSigmaY2()), std::sqrt(trackParCov.getSigmaZ2()), std::sqrt(trackParCov.getSigmaSnp2()), - std::sqrt(trackParCov.getSigmaTgl2()), std::sqrt(trackParCov.getSigma1Pt2()), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - tracksParCovExtensionPropagated(trackParCov.getSigmaY2(), trackParCov.getSigmaZY(), trackParCov.getSigmaZ2(), trackParCov.getSigmaSnpY(), - trackParCov.getSigmaSnpZ(), trackParCov.getSigmaSnp2(), trackParCov.getSigmaTglY(), trackParCov.getSigmaTglZ(), trackParCov.getSigmaTglSnp(), - trackParCov.getSigmaTgl2(), trackParCov.getSigma1PtY(), trackParCov.getSigma1PtZ(), trackParCov.getSigma1PtSnp(), trackParCov.getSigma1PtTgl(), - trackParCov.getSigma1Pt2()); - } - // Fill only per table (not per track). ROOT FindBin is slow - histos.fill(HIST("hTrackCounter"), 0.5, lNAll); - histos.fill(HIST("hTrackCounter"), 1.5, lNaccTPC); - histos.fill(HIST("hTrackCounter"), 2.5, lNaccNotTPCOnly); - histos.fill(HIST("hTrackCounter"), 3.5, lNPropagated); + ccdbLoader.initCCDBfromBCs(standardCCDBLoaderConfigurables, ccdb, bcs); + trackPropagation.fillTrackTables(trackPropagationConfigurables, trackTunerObj, ccdbLoader, collisions, tracks, trackPropagationProducts, registry); } - PROCESS_SWITCH(TrackPropagationTester, processCovariance, "Process with covariance", false); + PROCESS_SWITCH(TrackPropagationTester, processMc, "Process Monte Carlo", false); }; //**************************************************************************************** diff --git a/Common/TableProducer/trackextension.cxx b/Common/TableProducer/trackextension.cxx index 205be621f76..210f9adc122 100644 --- a/Common/TableProducer/trackextension.cxx +++ b/Common/TableProducer/trackextension.cxx @@ -134,7 +134,7 @@ struct TrackExtension { } auto trackPar = getTrackPar(track); auto const& collision = track.collision(); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; if (o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPar, 2.f, matCorr, &dcaInfo)) { dca[0] = dcaInfo[0]; dca[1] = dcaInfo[1]; diff --git a/Common/TableProducer/zdc-task-intercalib.cxx b/Common/TableProducer/zdcTaskInterCalib.cxx similarity index 53% rename from Common/TableProducer/zdc-task-intercalib.cxx rename to Common/TableProducer/zdcTaskInterCalib.cxx index 77b590bde57..78054580b81 100644 --- a/Common/TableProducer/zdc-task-intercalib.cxx +++ b/Common/TableProducer/zdcTaskInterCalib.cxx @@ -9,12 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file zdc-task-intercalib.cxx +/// \file zdcTaskInterCalib.cxx /// \brief Task for ZDC tower inter-calibration /// \author chiara.oppedisano@cern.ch -// o2-linter: disable=name/workflow-file -// o2-linter: disable=name/file-cpp #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/HistogramRegistry.h" @@ -35,9 +33,9 @@ using namespace o2::framework::expressions; using namespace o2::aod::evsel; using BCsRun3 = soa::Join; -using ColEvSels = soa::Join; +using ColEvSels = soa::Join; -struct ZDCCalibTower { +struct ZdcTaskInterCalib { Produces zTab; @@ -48,9 +46,32 @@ struct ZDCCalibTower { Configurable tdcCut{"tdcCut", false, "Flag for TDC cut"}; Configurable tdcZNmincut{"tdcZNmincut", -2.5, "Min ZN TDC cut"}; Configurable tdcZNmaxcut{"tdcZNmaxcut", -2.5, "Max ZN TDC cut"}; + // Event selections + Configurable cfgEvSelSel8{"cfgEvSelSel8", true, "Event selection: sel8"}; + Configurable cfgEvSelVtxZ{"cfgEvSelVtxZ", 10, "Event selection: zVtx"}; + Configurable cfgEvSelsDoOccupancySel{"cfgEvSelsDoOccupancySel", true, "Event selection: do occupancy selection"}; + Configurable cfgEvSelsMaxOccupancy{"cfgEvSelsMaxOccupancy", 10000, "Event selection: set max occupancy"}; + Configurable cfgEvSelsNoSameBunchPileupCut{"cfgEvSelsNoSameBunchPileupCut", true, "Event selection: no same bunch pileup cut"}; + Configurable cfgEvSelsIsGoodZvtxFT0vsPV{"cfgEvSelsIsGoodZvtxFT0vsPV", true, "Event selection: is good ZVTX FT0 vs PV"}; + Configurable cfgEvSelsNoCollInTimeRangeStandard{"cfgEvSelsNoCollInTimeRangeStandard", true, "Event selection: no collision in time range standard"}; + Configurable cfgEvSelsIsVertexITSTPC{"cfgEvSelsIsVertexITSTPC", true, "Event selection: is vertex ITSTPC"}; + Configurable cfgEvSelsIsGoodITSLayersAll{"cfgEvSelsIsGoodITSLayersAll", true, "Event selection: is good ITS layers all"}; // HistogramRegistry registry{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + enum SelectionCriteria { + evSel_zvtx, + evSel_sel8, + evSel_occupancy, + evSel_kNoSameBunchPileup, + evSel_kIsGoodZvtxFT0vsPV, + evSel_kNoCollInTimeRangeStandard, + evSel_kIsVertexITSTPC, + evSel_kIsGoodITSLayersAll, + evSel_allEvents, + nEventSelections + }; + void init(InitContext const&) { registry.add("ZNApmc", "ZNApmc; ZNA PMC; Entries", {HistType::kTH1F, {{nBins, -0.5, maxZN}}}); @@ -65,16 +86,93 @@ struct ZDCCalibTower { registry.add("ZNCpm4", "ZNCpm4; ZNC PM4; Entries", {HistType::kTH1F, {{nBins, -0.5, maxZN}}}); registry.add("ZNAsumq", "ZNAsumq; ZNA uncalib. sum PMQ; Entries", {HistType::kTH1F, {{nBins, -0.5, maxZN}}}); registry.add("ZNCsumq", "ZNCsumq; ZNC uncalib. sum PMQ; Entries", {HistType::kTH1F, {{nBins, -0.5, maxZN}}}); + + registry.add("hEventCount", "Number of Event; Cut; #Events Passed Cut", {HistType::kTH1D, {{nEventSelections, 0, nEventSelections}}}); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_allEvents + 1, "All events"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_zvtx + 1, "vtxZ"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_sel8 + 1, "Sel8"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_occupancy + 1, "kOccupancy"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoSameBunchPileup + 1, "kNoSameBunchPileup"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoCollInTimeRangeStandard + 1, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsVertexITSTPC + 1, "kIsVertexITSTPC"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodITSLayersAll + 1, "kkIsGoodITSLayersAll"); + } + + template + uint8_t eventSelected(TCollision collision) + { + uint8_t selectionBits = 0; + bool selected; + + registry.fill(HIST("hEventCount"), evSel_allEvents); + + selected = std::fabs(collision.posZ()) < cfgEvSelVtxZ; + if (selected) { + selectionBits |= (uint8_t)(0x1u << evSel_zvtx); + registry.fill(HIST("hEventCount"), evSel_zvtx); + } + + selected = collision.sel8(); + if (selected) { + selectionBits |= (uint8_t)(0x1u << evSel_sel8); + registry.fill(HIST("hEventCount"), evSel_sel8); + } + + auto occupancy = collision.trackOccupancyInTimeRange(); + selected = occupancy <= cfgEvSelsMaxOccupancy; + if (selected) { + selectionBits |= (uint8_t)(0x1u << evSel_occupancy); + registry.fill(HIST("hEventCount"), evSel_occupancy); + } + + selected = collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup); + if (selected) { + selectionBits |= (uint8_t)(0x1u << evSel_kNoSameBunchPileup); + registry.fill(HIST("hEventCount"), evSel_kNoSameBunchPileup); + } + + selected = collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV); + if (selected) { + selectionBits |= (uint8_t)(0x1u << evSel_kIsGoodZvtxFT0vsPV); + registry.fill(HIST("hEventCount"), evSel_kIsGoodZvtxFT0vsPV); + } + + selected = collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard); + if (selected) { + selectionBits |= (uint8_t)(0x1u << evSel_kNoCollInTimeRangeStandard); + registry.fill(HIST("hEventCount"), evSel_kNoCollInTimeRangeStandard); + } + + selected = collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC); + if (selected) { + selectionBits |= (uint8_t)(0x1u << evSel_kIsVertexITSTPC); + registry.fill(HIST("hEventCount"), evSel_kIsVertexITSTPC); + } + + selected = collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll); + if (selected) { + selectionBits |= (uint8_t)(0x1u << evSel_kIsGoodITSLayersAll); + registry.fill(HIST("hEventCount"), evSel_kIsGoodITSLayersAll); + } + + return selectionBits; } void process(ColEvSels const& cols, BCsRun3 const& /*bcs*/, aod::Zdcs const& /*zdcs*/) { // collision-based event selection + int nTowers = 4; // number of ZDC towers + for (auto const& collision : cols) { const auto& foundBC = collision.foundBC_as(); if (foundBC.has_zdc()) { const auto& zdc = foundBC.zdc(); + uint8_t evSelection = eventSelected(collision); + + float centrality = collision.centFT0C(); + // To assure that ZN have a genuine signal (tagged by the relative TDC) // we can check that the amplitude is >0 or that ADC is NOT very negative (-inf) @@ -117,7 +215,7 @@ struct ZDCCalibTower { }; // if (isZNChit) { - for (int it = 0; it < 4; it++) { + for (int it = 0; it < nTowers; it++) { pmqZNC[it] = (zdc.energySectorZNC())[it]; sumZNC += pmqZNC[it]; } @@ -129,7 +227,7 @@ struct ZDCCalibTower { registry.get(HIST("ZNCsumq"))->Fill(sumZNC); } if (isZNAhit) { - for (int it = 0; it < 4; it++) { + for (int it = 0; it < nTowers; it++) { pmqZNA[it] = (zdc.energySectorZNA())[it]; sumZNA += pmqZNA[it]; } @@ -142,7 +240,7 @@ struct ZDCCalibTower { registry.get(HIST("ZNAsumq"))->Fill(sumZNA); } if (isZNAhit || isZNChit) - zTab(pmcZNA, pmqZNA[0], pmqZNA[1], pmqZNA[2], pmqZNA[3], tdcZNC, pmcZNC, pmqZNC[0], pmqZNC[1], pmqZNC[2], pmqZNC[3], tdcZNA); + zTab(pmcZNA, pmqZNA[0], pmqZNA[1], pmqZNA[2], pmqZNA[3], tdcZNC, pmcZNC, pmqZNC[0], pmqZNC[1], pmqZNC[2], pmqZNC[3], tdcZNA, centrality, foundBC.timestamp(), evSelection); } } } @@ -151,5 +249,5 @@ struct ZDCCalibTower { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) // o2-linter: disable=name/file-cpp { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/Common/Tasks/CMakeLists.txt b/Common/Tasks/CMakeLists.txt index 2884d3b8b31..932398c97a9 100644 --- a/Common/Tasks/CMakeLists.txt +++ b/Common/Tasks/CMakeLists.txt @@ -81,5 +81,15 @@ o2physics_add_dpl_workflow(qvectors-correction o2physics_add_dpl_workflow(centrality-study SOURCES centralityStudy.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-test + SOURCES flowTest.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(muon-qa + SOURCES qaMuon.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::Field O2::DetectorsBase O2::DetectorsCommonDataFormats O2::MathUtils O2::MCHTracking O2::DataFormatsMCH O2::GlobalTracking O2::MCHBase O2::MCHGeometryTransformer O2::CommonUtils COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/Common/Tasks/centralityStudy.cxx b/Common/Tasks/centralityStudy.cxx index 55a70d0e690..be975b9cecb 100644 --- a/Common/Tasks/centralityStudy.cxx +++ b/Common/Tasks/centralityStudy.cxx @@ -13,32 +13,63 @@ // Run 3 Pb-Pb centrality selections in 2023 data. It is compatible with // derived data. -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Common/DataModel/McCollisionExtra.h" -#include "Common/DataModel/Multiplicity.h" +#include "Common/CCDB/ctpRateFetcher.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/McCollisionExtra.h" +#include "Common/DataModel/Multiplicity.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPECSObject.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + #include "TH1F.h" #include "TH2F.h" +#include "TProfile.h" + +#include +#include using namespace o2; using namespace o2::framework; using BCsWithRun3Matchings = soa::Join; +#define getHist(type, name) std::get>(histPointers[name]) struct centralityStudy { // Raw multiplicities HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + std::map histPointers; + std::string histPath; + Service ccdb; + ctpRateFetcher mRateFetcher; + int mRunNumber; + uint64_t startOfRunTimestamp; + + // vertex Z equalization + TList* hCalibObjects; + TProfile* hVtxZFV0A; + TProfile* hVtxZFT0A; + TProfile* hVtxZFT0C; + TProfile* hVtxZNTracks; + TProfile* hVtxZNGlobals; + TProfile* hVtxZMFT; + TProfile* hVtxZFDDA; + TProfile* hVtxZFDDC; // Configurables + Configurable applyVertexZEqualization{"applyVertexZEqualization", false, "0 - no, 1 - yes"}; + Configurable do2DPlots{"do2DPlots", true, "0 - no, 1 - yes"}; Configurable doOccupancyStudyVsCentrality2d{"doOccupancyStudyVsCentrality2d", true, "0 - no, 1 - yes"}; Configurable doOccupancyStudyVsRawValues2d{"doOccupancyStudyVsRawValues2d", true, "0 - no, 1 - yes"}; Configurable doOccupancyStudyVsCentrality3d{"doOccupancyStudyVsCentrality3d", false, "0 - no, 1 - yes"}; Configurable doOccupancyStudyVsRawValues3d{"doOccupancyStudyVsRawValues3d", false, "0 - no, 1 - yes"}; + Configurable doTimeStudies{"doTimeStudies", true, "0 - no, 1 - yes"}; + Configurable doTimeStudyFV0AOuterVsFT0A3d{"doTimeStudyFV0AOuterVsFT0A3d", false, "0 - no, 1 - yes"}; Configurable doNGlobalTracksVsRawSignals{"doNGlobalTracksVsRawSignals", true, "0 - no, 1 - yes"}; Configurable applySel8{"applySel8", true, "0 - no, 1 - yes"}; Configurable applyVtxZ{"applyVtxZ", true, "0 - no, 1 - yes"}; @@ -46,10 +77,10 @@ struct centralityStudy { // Apply extra event selections Configurable rejectITSROFBorder{"rejectITSROFBorder", true, "reject events at ITS ROF border"}; Configurable rejectTFBorder{"rejectTFBorder", true, "reject events at TF border"}; - Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", true, "require events with at least one ITS-TPC track"}; - Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", true, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference"}; - Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", true, "require events with at least one of vertex contributors matched to TOF"}; - Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", true, "require events with at least one of vertex contributors matched to TRD"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "require events with at least one ITS-TPC track"}; + Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", false, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference"}; + Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", false, "require events with at least one of vertex contributors matched to TOF"}; + Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", false, "require events with at least one of vertex contributors matched to TRD"}; Configurable rejectSameBunchPileup{"rejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC"}; Configurable rejectITSinROFpileupStandard{"rejectITSinROFpileupStandard", false, "reject collisions in case of in-ROF ITS pileup (standard)"}; @@ -64,12 +95,19 @@ struct centralityStudy { Configurable vertexZwithT0{"vertexZwithT0", 1000.0f, "require a certain vertex-Z in BC analysis"}; Configurable minTimeDelta{"minTimeDelta", -1.0f, "reject collision if another collision is this close or less in time"}; - Configurable minFT0CforVertexZ{"minFT0CforVertexZ", 250, "minimum FT0C for vertex-Z profile calculation"}; + Configurable minFT0CforVertexZ{"minFT0CforVertexZ", -1.0f, "minimum FT0C for vertex-Z profile calculation"}; Configurable scaleSignalFT0C{"scaleSignalFT0C", 1.00f, "scale FT0C signal for convenience"}; Configurable scaleSignalFT0M{"scaleSignalFT0M", 1.00f, "scale FT0M signal for convenience"}; Configurable scaleSignalFV0A{"scaleSignalFV0A", 1.00f, "scale FV0A signal for convenience"}; + Configurable ccdbURL{"ccdbURL", "http://alice-ccdb.cern.ch", "ccdb url"}; + Configurable pathGRPECSObject{"pathGRPECSObject", "GLO/Config/GRPECS", "Path to GRPECS object"}; + Configurable pathVertexZ{"pathVertexZ", "Users/d/ddobrigk/Centrality/Calibration", "Path to vertexZ profiles"}; + Configurable irSource{"irSource", "ZNC hadronic", "Source of the interaction rate: (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"}; + Configurable irCrashOnNull{"irCrashOnNull", false, "Flag to avoid CTP RateFetcher crash."}; + Configurable irDoRateVsTime{"irDoRateVsTime", true, "Do IR plots"}; + // _______________________________________ // upc rejection criteria // reject low zna/c @@ -88,6 +126,7 @@ struct centralityStudy { ConfigurableAxis axisMultFV0A{"axisMultFV0A", {1000, 0, 100000}, "FV0A amplitude"}; ConfigurableAxis axisMultFT0A{"axisMultFT0A", {1000, 0, 100000}, "FT0A amplitude"}; ConfigurableAxis axisMultFT0C{"axisMultFT0C", {1000, 0, 100000}, "FT0C amplitude"}; + ConfigurableAxis axisMultFT0M{"axisMultFT0M", {1000, 0, 100000}, "FT0M amplitude"}; ConfigurableAxis axisMultFDDA{"axisMultFDDA", {1000, 0, 100000}, "FDDA amplitude"}; ConfigurableAxis axisMultFDDC{"axisMultFDDC", {1000, 0, 100000}, "FDDC amplitude"}; ConfigurableAxis axisMultPVContributors{"axisMultPVContributors", {200, 0, 6000}, "Number of PV Contributors"}; @@ -113,13 +152,26 @@ struct centralityStudy { ConfigurableAxis axisPVChi2{"axisPVChi2", {300, 0, 30}, "FT0C percentile"}; ConfigurableAxis axisDeltaTime{"axisDeltaTime", {300, 0, 300}, "#Delta time"}; + ConfigurableAxis axisDeltaTimestamp{"axisDeltaTimestamp", {1440, 0, 24}, "#Delta timestamp - sor (hours)"}; + ConfigurableAxis axisInteractionRate{"axisInteractionRate", {500, 0, 100}, "Binning for the interaction rate (kHz)"}; + ConfigurableAxis axisMultCoarseFV0A{"axisMultCoarseFV0A", {350, 0, 70000}, "FV0A amplitude"}; + // For profile Z ConfigurableAxis axisPVz{"axisPVz", {400, -20.0f, +20.0f}, "PVz (cm)"}; - ConfigurableAxis axisZN{"axisZN", {1100, -50.0f, +500.0f}, "ZN"}; void init(InitContext&) { + hCalibObjects = nullptr; + hVtxZFV0A = nullptr; + hVtxZFT0A = nullptr; + hVtxZFT0C = nullptr; + hVtxZNTracks = nullptr; + hVtxZNGlobals = nullptr; + hVtxZMFT = nullptr; + hVtxZFDDA = nullptr; + hVtxZFDDC = nullptr; + if (doprocessCollisions || doprocessCollisionsWithCentrality) { const AxisSpec axisCollisions{100, -0.5f, 99.5f, "Number of collisions"}; histos.add("hCollisionSelection", "hCollisionSelection", kTH1D, {{20, -0.5f, +19.5f}}); @@ -178,6 +230,7 @@ struct centralityStudy { if (doNGlobalTracksVsRawSignals) { histos.add("hNGlobalTracksVsFT0A", "hNGlobalTracksVsFT0A", kTH2F, {axisMultFT0A, axisMultGlobalTracks}); histos.add("hNGlobalTracksVsFT0C", "hNGlobalTracksVsFT0C", kTH2F, {axisMultFT0C, axisMultGlobalTracks}); + histos.add("hNGlobalTracksVsFT0M", "hNGlobalTracksVsFT0M", kTH2F, {axisMultFT0M, axisMultGlobalTracks}); histos.add("hNGlobalTracksVsFV0A", "hNGlobalTracksVsFV0A", kTH2F, {axisMultFV0A, axisMultGlobalTracks}); histos.add("hNGlobalTracksVsFDDA", "hNGlobalTracksVsFDDA", kTH2F, {axisMultFDDA, axisMultGlobalTracks}); histos.add("hNGlobalTracksVsFDDC", "hNGlobalTracksVsFDDC", kTH2F, {axisMultFDDC, axisMultGlobalTracks}); @@ -225,57 +278,260 @@ struct centralityStudy { histos.add("hFT0COccupancyVsNGlobalTracksVsCentrality", "hFT0COccupancyVsNGlobalTracksVsCentrality", kTH3F, {axisFT0COccupancy, axisMultGlobalTracks, axisCentrality}); } } + + if (doTimeStudies) { + ccdb->setURL(ccdbURL); + // ccdb->setCaching(true); + // ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + if (doTimeStudyFV0AOuterVsFT0A3d) { + histos.add((histPath + "h3dFV0AVsTime").c_str(), "", {kTH3F, {{axisDeltaTimestamp, axisMultCoarseFV0A, axisMultCoarseFV0A}}}); + } + } + } + + template + void initRun(TCollision collision) + { + if (mRunNumber == collision.multRunNumber()) { + return; + } + + mRunNumber = collision.multRunNumber(); + LOGF(info, "Setting up for run: %i", mRunNumber); + + // only get object when switching runs + o2::parameters::GRPECSObject* grpo = ccdb->getForRun(pathGRPECSObject, mRunNumber); + startOfRunTimestamp = grpo->getTimeStart(); + + if (applyVertexZEqualization.value) { + // acquire vertex-Z equalization histograms if requested + LOGF(info, "Acquiring vertex-Z profiles for run %i", mRunNumber); + hCalibObjects = ccdb->getForRun(pathVertexZ, mRunNumber); + + hVtxZFV0A = static_cast(hCalibObjects->FindObject("hVtxZFV0A")); + hVtxZFT0A = static_cast(hCalibObjects->FindObject("hVtxZFT0A")); + hVtxZFT0C = static_cast(hCalibObjects->FindObject("hVtxZFT0C")); + // hVtxZFDDA = static_cast(hCalibObjects->FindObject("hVtxZFDDA")); + // hVtxZFDDC = static_cast(hCalibObjects->FindObject("hVtxZFDDC")); + hVtxZNTracks = static_cast(hCalibObjects->FindObject("hVtxZNTracksPV")); + hVtxZNGlobals = static_cast(hCalibObjects->FindObject("hVtxZNGlobals")); + hVtxZMFT = static_cast(hCalibObjects->FindObject("hVtxZMFT")); + + // Capture error + if (!hVtxZFV0A || !hVtxZFT0A || !hVtxZFT0C || !hVtxZNTracks || !hVtxZNGlobals || !hVtxZMFT) { + LOGF(error, "Problem loading CCDB objects! Please check"); + } + } + + histPath = std::format("Run_{}/", mRunNumber); + + if (doprocessCollisions || doprocessCollisionsWithCentrality) { + histPointers.insert({histPath + "hCollisionSelection", histos.add((histPath + "hCollisionSelection").c_str(), "hCollisionSelection", {kTH1D, {{20, -0.5f, +19.5f}}})}); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(1, "All collisions"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(2, "sel8 cut"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(3, "posZ cut"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(5, "kNoTimeFrameBorder"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(6, "kIsVertexITSTPC"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(7, "kIsGoodZvtxFT0vsPV"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(8, "kIsVertexTOFmatched"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(9, "kIsVertexTRDmatched"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(10, "kNoSameBunchPileup"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(11, "Neighbour rejection"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(12, "no ITS in-ROF pileup (standard)"); + getHist(TH1, histPath + "hCollisionSelection")->GetXaxis()->SetBinLabel(13, "no ITS in-ROF pileup (strict)"); + + histPointers.insert({histPath + "hFT0C_Collisions", histos.add((histPath + "hFT0C_Collisions").c_str(), "hFT0C_Collisions", {kTH1D, {{axisMultUltraFineFT0C}}})}); + histPointers.insert({histPath + "hFT0M_Collisions", histos.add((histPath + "hFT0M_Collisions").c_str(), "hFT0M_Collisions", {kTH1D, {{axisMultUltraFineFT0M}}})}); + histPointers.insert({histPath + "hFV0A_Collisions", histos.add((histPath + "hFV0A_Collisions").c_str(), "hFV0A_Collisions", {kTH1D, {{axisMultUltraFineFV0A}}})}); + histPointers.insert({histPath + "hNGlobalTracks", histos.add((histPath + "hNGlobalTracks").c_str(), "hNGlobalTracks", {kTH1D, {{axisMultUltraFineGlobalTracks}}})}); + histPointers.insert({histPath + "hNMFTTracks", histos.add((histPath + "hNMFTTracks").c_str(), "hNMFTTracks", {kTH1D, {{axisMultUltraFineMFTTracks}}})}); + histPointers.insert({histPath + "hNPVContributors", histos.add((histPath + "hNPVContributors").c_str(), "hNPVContributors", {kTH1D, {{axisMultUltraFinePVContributors}}})}); + + if (applyVertexZEqualization) { + histPointers.insert({histPath + "hFT0C_Collisions_Unequalized", histos.add((histPath + "hFT0C_Collisions_Unequalized").c_str(), "hFT0C_Collisions_Unequalized", {kTH1D, {{axisMultUltraFineFT0C}}})}); + histPointers.insert({histPath + "hFT0M_Collisions_Unequalized", histos.add((histPath + "hFT0M_Collisions_Unequalized").c_str(), "hFT0M_Collisions_Unequalized", {kTH1D, {{axisMultUltraFineFT0M}}})}); + histPointers.insert({histPath + "hFV0A_Collisions_Unequalized", histos.add((histPath + "hFV0A_Collisions_Unequalized").c_str(), "hFV0A_Collisions_Unequalized", {kTH1D, {{axisMultUltraFineFV0A}}})}); + histPointers.insert({histPath + "hNGlobalTracks_Unequalized", histos.add((histPath + "hNGlobalTracks_Unequalized").c_str(), "hNGlobalTracks_Unequalized", {kTH1D, {{axisMultUltraFineGlobalTracks}}})}); + histPointers.insert({histPath + "hNMFTTracks_Unequalized", histos.add((histPath + "hNMFTTracks_Unequalized").c_str(), "hNMFTTracks_Unequalized", {kTH1D, {{axisMultUltraFineMFTTracks}}})}); + histPointers.insert({histPath + "hNPVContributors_Unequalized", histos.add((histPath + "hNPVContributors_Unequalized").c_str(), "hNPVContributors_Unequalized", {kTH1D, {{axisMultUltraFinePVContributors}}})}); + } + + histPointers.insert({histPath + "hFT0CvsPVz_Collisions_All", histos.add((histPath + "hFT0CvsPVz_Collisions_All").c_str(), "hFT0CvsPVz_Collisions_All", {kTProfile, {{axisPVz}}})}); + histPointers.insert({histPath + "hFT0AvsPVz_Collisions", histos.add((histPath + "hFT0AvsPVz_Collisions").c_str(), "hFT0AvsPVz_Collisions", {kTProfile, {{axisPVz}}})}); + histPointers.insert({histPath + "hFT0CvsPVz_Collisions", histos.add((histPath + "hFT0CvsPVz_Collisions").c_str(), "hFT0CvsPVz_Collisions", {kTProfile, {{axisPVz}}})}); + histPointers.insert({histPath + "hFV0AvsPVz_Collisions", histos.add((histPath + "hFV0AvsPVz_Collisions").c_str(), "hFV0AvsPVz_Collisions", {kTProfile, {{axisPVz}}})}); + histPointers.insert({histPath + "hNGlobalTracksvsPVz_Collisions", histos.add((histPath + "hNGlobalTracksvsPVz_Collisions").c_str(), "hNGlobalTracksvsPVz_Collisions", {kTProfile, {{axisPVz}}})}); + histPointers.insert({histPath + "hNMFTTracksvsPVz_Collisions", histos.add((histPath + "hNMFTTracksvsPVz_Collisions").c_str(), "hNMFTTracksvsPVz_Collisions", {kTProfile, {{axisPVz}}})}); + histPointers.insert({histPath + "hNTPVvsPVz_Collisions", histos.add((histPath + "hNTPVvsPVz_Collisions").c_str(), "hNTPVvsPVz_Collisions", {kTProfile, {{axisPVz}}})}); + } + + if (do2DPlots) { + histPointers.insert({histPath + "hNContribsVsFT0C", histos.add((histPath + "hNContribsVsFT0C").c_str(), "hNContribsVsFT0C", {kTH2F, {{axisMultFT0C, axisMultPVContributors}}})}); + histPointers.insert({histPath + "hNContribsVsFV0A", histos.add((histPath + "hNContribsVsFV0A").c_str(), "hNContribsVsFV0A", {kTH2F, {{axisMultFV0A, axisMultPVContributors}}})}); + histPointers.insert({histPath + "hMatchedVsITSOnly", histos.add((histPath + "hMatchedVsITSOnly").c_str(), "hMatchedVsITSOnly", {kTH2F, {{axisMultITSOnly, axisMultITSTPC}}})}); + + // 2d correlation of fit signals + histPointers.insert({histPath + "hFT0AVsFT0C", histos.add((histPath + "hFT0AVsFT0C").c_str(), "hFT0AVsFT0C", {kTH2F, {{axisMultFT0C, axisMultFT0A}}})}); + histPointers.insert({histPath + "hFV0AVsFT0C", histos.add((histPath + "hFV0AVsFT0C").c_str(), "hFV0AVsFT0C", {kTH2F, {{axisMultFT0C, axisMultFV0A}}})}); + histPointers.insert({histPath + "hFDDAVsFT0C", histos.add((histPath + "hFDDAVsFT0C").c_str(), "hFDDAVsFT0C", {kTH2F, {{axisMultFT0C, axisMultFDDA}}})}); + histPointers.insert({histPath + "hFDDCVsFT0C", histos.add((histPath + "hFDDCVsFT0C").c_str(), "hFDDCVsFT0C", {kTH2F, {{axisMultFT0C, axisMultFDDC}}})}); + } + + if (doprocessCollisionsWithCentrality) { + // in case requested: do vs centrality debugging + histPointers.insert({histPath + "hCentrality", histos.add((histPath + "hCentrality").c_str(), "hCentrality", {kTH1F, {{axisCentrality}}})}); + histPointers.insert({histPath + "hNContribsVsCentrality", histos.add((histPath + "hNContribsVsCentrality").c_str(), "hNContribsVsCentrality", {kTH2F, {{axisCentrality, axisMultPVContributors}}})}); + histPointers.insert({histPath + "hNITSTPCTracksVsCentrality", histos.add((histPath + "hNITSTPCTracksVsCentrality").c_str(), "hNITSTPCTracksVsCentrality", {kTH2F, {{axisCentrality, axisMultPVContributors}}})}); + histPointers.insert({histPath + "hNITSOnlyTracksVsCentrality", histos.add((histPath + "hNITSOnlyTracksVsCentrality").c_str(), "hNITSOnlyTracksVsCentrality", {kTH2F, {{axisCentrality, axisMultPVContributors}}})}); + histPointers.insert({histPath + "hNGlobalTracksVsCentrality", histos.add((histPath + "hNGlobalTracksVsCentrality").c_str(), "hNGlobalTracksVsCentrality", {kTH2F, {{axisCentrality, axisMultPVContributors}}})}); + histPointers.insert({histPath + "hNMFTTracksVsCentrality", histos.add((histPath + "hNMFTTracksVsCentrality").c_str(), "hNMFTTracksVsCentrality", {kTH2F, {{axisCentrality, axisMultMFTTracks}}})}); + histPointers.insert({histPath + "hPVChi2VsCentrality", histos.add((histPath + "hPVChi2VsCentrality").c_str(), "hPVChi2VsCentrality", {kTH2F, {{axisCentrality, axisPVChi2}}})}); + histPointers.insert({histPath + "hDeltaTimeVsCentrality", histos.add((histPath + "hDeltaTimeVsCentrality").c_str(), "hDeltaTimeVsCentrality", {kTH2F, {{axisCentrality, axisDeltaTime}}})}); + } + + if (doTimeStudies) { + histPointers.insert({histPath + "hFT0AVsTime", histos.add((histPath + "hFT0AVsTime").c_str(), "hFT0AVsTime", {kTH2D, {{axisDeltaTimestamp, axisMultFT0A}}})}); + histPointers.insert({histPath + "hFT0CVsTime", histos.add((histPath + "hFT0CVsTime").c_str(), "hFT0CVsTime", {kTH2D, {{axisDeltaTimestamp, axisMultFT0C}}})}); + histPointers.insert({histPath + "hFT0MVsTime", histos.add((histPath + "hFT0MVsTime").c_str(), "hFT0MVsTime", {kTH2D, {{axisDeltaTimestamp, axisMultFT0M}}})}); + histPointers.insert({histPath + "hFV0AVsTime", histos.add((histPath + "hFV0AVsTime").c_str(), "hFV0AVsTime", {kTH2D, {{axisDeltaTimestamp, axisMultFV0A}}})}); + histPointers.insert({histPath + "hFV0AOuterVsTime", histos.add((histPath + "hFV0AOuterVsTime").c_str(), "hFV0AOuterVsTime", {kTH2D, {{axisDeltaTimestamp, axisMultFV0A}}})}); + histPointers.insert({histPath + "hMFTTracksVsTime", histos.add((histPath + "hMFTTracksVsTime").c_str(), "hMFTTracksVsTime", {kTH2D, {{axisDeltaTimestamp, axisMultMFTTracks}}})}); + histPointers.insert({histPath + "hNGlobalVsTime", histos.add((histPath + "hNGlobalVsTime").c_str(), "hNGlobalVsTime", {kTH2D, {{axisDeltaTimestamp, axisMultGlobalTracks}}})}); + histPointers.insert({histPath + "hNTPVContributorsVsTime", histos.add((histPath + "hNTPVContributorsVsTime").c_str(), "hNTPVContributorsVsTime", {kTH2D, {{axisDeltaTimestamp, axisMultPVContributors}}})}); + histPointers.insert({histPath + "hPVzProfileCoVsTime", histos.add((histPath + "hPVzProfileCoVsTime").c_str(), "hPVzProfileCoVsTime", {kTProfile, {{axisDeltaTimestamp}}})}); + histPointers.insert({histPath + "hPVzProfileBcVsTime", histos.add((histPath + "hPVzProfileBcVsTime").c_str(), "hPVzProfileBcVsTime", {kTProfile, {{axisDeltaTimestamp}}})}); + if (irDoRateVsTime) { + histPointers.insert({histPath + "hIRProfileVsTime", histos.add((histPath + "hIRProfileVsTime").c_str(), "hIRProfileVsTime", {kTProfile, {{axisDeltaTimestamp}}})}); + } + } } template void genericProcessCollision(TCollision collision) // process this collisions { - + initRun(collision); histos.fill(HIST("hCollisionSelection"), 0); // all collisions + getHist(TH1, histPath + "hCollisionSelection")->Fill(0); + if (applySel8 && !collision.multSel8()) return; histos.fill(HIST("hCollisionSelection"), 1); + getHist(TH1, histPath + "hCollisionSelection")->Fill(1); + + // calculate vertex-Z-equalized quantities if desired + float multFV0A = collision.multFV0A(); + float multFT0A = collision.multFT0A(); + float multFT0C = collision.multFT0C(); + float multNTracksGlobal = collision.multNTracksGlobal(); + float mftNtracks = collision.mftNtracks(); + float multNTracksPV = collision.multNTracksPV(); + if (applyVertexZEqualization) { + float epsilon = 1e-2; // average value after which this collision will be disregarded + multFV0A = -1.0f; + multFT0A = -1.0f; + multFT0C = -1.0f; + multNTracksGlobal = -1.0f; + mftNtracks = -1.0f; + multNTracksPV = -1.0f; + + if (hVtxZFV0A->Interpolate(collision.multPVz()) > epsilon) { + multFV0A = hVtxZFV0A->Interpolate(0.0) * collision.multFV0A() / hVtxZFV0A->Interpolate(collision.multPVz()); + } + if (hVtxZFT0A->Interpolate(collision.multPVz()) > epsilon) { + multFT0A = hVtxZFT0A->Interpolate(0.0) * collision.multFT0A() / hVtxZFT0A->Interpolate(collision.multPVz()); + } + if (hVtxZFT0C->Interpolate(collision.multPVz()) > epsilon) { + multFT0C = hVtxZFT0C->Interpolate(0.0) * collision.multFT0C() / hVtxZFT0C->Interpolate(collision.multPVz()); + } + if (hVtxZNGlobals->Interpolate(collision.multPVz()) > epsilon) { + multNTracksGlobal = hVtxZNGlobals->Interpolate(0.0) * collision.multNTracksGlobal() / hVtxZNGlobals->Interpolate(collision.multPVz()); + } + if (hVtxZMFT->Interpolate(collision.multPVz()) > epsilon) { + mftNtracks = hVtxZMFT->Interpolate(0.0) * collision.mftNtracks() / hVtxZMFT->Interpolate(collision.multPVz()); + } + if (hVtxZNTracks->Interpolate(collision.multPVz()) > epsilon) { + multNTracksPV = hVtxZNTracks->Interpolate(0.0) * collision.multNTracksPV() / hVtxZNTracks->Interpolate(collision.multPVz()); + } + } + + bool passRejectITSROFBorder = !(rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)); + bool passRejectTFBorder = !(rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)); + bool passRequireIsVertexITSTPC = !(requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)); + bool passRequireIsGoodZvtxFT0VsPV = !(requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)); + bool passRequireIsVertexTOFmatched = !(requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)); + bool passRequireIsVertexTRDmatched = !(requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)); + bool passRejectSameBunchPileup = !(rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)); + bool passRejectITSinROFpileupStandard = !(rejectITSinROFpileupStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)); + bool passRejectITSinROFpileupStrict = !(rejectITSinROFpileupStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)); + bool passSelectUPCcollisions = !(selectUPCcollisions && collision.flags() < 1); + bool passRejectCollInTimeRangeNarrow = !(rejectCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)); + // _______________________________________________________ + // sidestep vertex-Z rejection for vertex-Z profile histograms + if (passRejectITSROFBorder && passRejectTFBorder && passRequireIsVertexITSTPC && passRequireIsGoodZvtxFT0VsPV && + passRequireIsVertexTOFmatched && passRequireIsVertexTRDmatched && passRejectSameBunchPileup && passRejectITSinROFpileupStandard && passRejectITSinROFpileupStrict && + passSelectUPCcollisions && passRejectCollInTimeRangeNarrow) { + getHist(TProfile, histPath + "hFT0CvsPVz_Collisions_All")->Fill(collision.multPVz(), multFT0C * scaleSignalFT0C); + getHist(TProfile, histPath + "hFT0CvsPVz_Collisions")->Fill(collision.multPVz(), multFT0C * scaleSignalFT0C); + getHist(TProfile, histPath + "hFT0AvsPVz_Collisions")->Fill(collision.multPVz(), multFT0A * scaleSignalFT0C); + getHist(TProfile, histPath + "hFV0AvsPVz_Collisions")->Fill(collision.multPVz(), multFV0A * scaleSignalFV0A); + getHist(TProfile, histPath + "hNGlobalTracksvsPVz_Collisions")->Fill(collision.multPVz(), multNTracksGlobal); + getHist(TProfile, histPath + "hNMFTTracksvsPVz_Collisions")->Fill(collision.multPVz(), mftNtracks); + getHist(TProfile, histPath + "hNTPVvsPVz_Collisions")->Fill(collision.multPVz(), multNTracksPV); + } + + // _______________________________________________________ + if (applyVtxZ && TMath::Abs(collision.multPVz()) > 10) return; histos.fill(HIST("hCollisionSelection"), 2); + getHist(TH1, histPath + "hCollisionSelection")->Fill(2); // _______________________________________________________ // Extra event selections start here - if (rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + if (!passRejectITSROFBorder) { return; } histos.fill(HIST("hCollisionSelection"), 3 /* Not at ITS ROF border */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(3); - if (rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + if (!passRejectTFBorder) { return; } histos.fill(HIST("hCollisionSelection"), 4 /* Not at TF border */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(4); - if (requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + if (!passRequireIsVertexITSTPC) { return; } histos.fill(HIST("hCollisionSelection"), 5 /* Contains at least one ITS-TPC track */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(5); - if (requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + if (!passRequireIsGoodZvtxFT0VsPV) { return; } histos.fill(HIST("hCollisionSelection"), 6 /* PV position consistency check */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(6); - if (requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + if (!passRequireIsVertexTOFmatched) { return; } histos.fill(HIST("hCollisionSelection"), 7 /* PV with at least one contributor matched with TOF */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(7); - if (requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + if (!passRequireIsVertexTRDmatched) { return; } histos.fill(HIST("hCollisionSelection"), 8 /* PV with at least one contributor matched with TRD */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(8); - if (rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + if (!passRejectSameBunchPileup) { return; } histos.fill(HIST("hCollisionSelection"), 9 /* Not at same bunch pile-up */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(9); // do this only if information is available if constexpr (requires { collision.timeToNext(); }) { @@ -287,27 +543,32 @@ struct centralityStudy { return; } histos.fill(HIST("hCollisionSelection"), 10 /* has suspicious neighbour */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(10); } - if (rejectITSinROFpileupStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + if (!passRejectITSinROFpileupStandard) { return; } histos.fill(HIST("hCollisionSelection"), 11 /* Not ITS ROF pileup (standard) */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(11); - if (rejectITSinROFpileupStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + if (!passRejectITSinROFpileupStrict) { return; } histos.fill(HIST("hCollisionSelection"), 12 /* Not ITS ROF pileup (strict) */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(12); - if (selectUPCcollisions && collision.flags() < 1) { // if zero then NOT upc, otherwise UPC + if (!passSelectUPCcollisions) { // if zero then NOT upc, otherwise UPC return; } histos.fill(HIST("hCollisionSelection"), 13 /* is UPC event */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(13); - if (rejectCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + if (!passRejectCollInTimeRangeNarrow) { return; } histos.fill(HIST("hCollisionSelection"), 14 /* Not ITS ROF pileup (strict) */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(14); if (collision.multFT0C() < upcRejection.maxFT0CforZNACselection && collision.multZNA() < upcRejection.minZNACsignal && @@ -323,9 +584,10 @@ struct centralityStudy { return; } histos.fill(HIST("hCollisionSelection"), 15 /* pass em/upc rejection */); + getHist(TH1, histPath + "hCollisionSelection")->Fill(15); // if we got here, we also finally fill the FT0C histogram, please - histos.fill(HIST("hNPVContributors"), collision.multPVTotalContributors()); + histos.fill(HIST("hNPVContributors"), collision.multNTracksPV()); histos.fill(HIST("hFT0C_Collisions"), collision.multFT0C() * scaleSignalFT0C); histos.fill(HIST("hFT0M_Collisions"), (collision.multFT0A() + collision.multFT0C()) * scaleSignalFT0M); histos.fill(HIST("hFV0A_Collisions"), collision.multFV0A() * scaleSignalFV0A); @@ -335,19 +597,42 @@ struct centralityStudy { histos.fill(HIST("hFV0AvsPVz_Collisions"), collision.multPVz(), collision.multFV0A() * scaleSignalFV0A); histos.fill(HIST("hNGlobalTracksvsPVz_Collisions"), collision.multPVz(), collision.multNTracksGlobal()); histos.fill(HIST("hNMFTTracksvsPVz_Collisions"), collision.multPVz(), collision.mftNtracks()); - if (collision.multFT0C() > minFT0CforVertexZ) { - histos.fill(HIST("hFT0CvsPVz_Collisions"), collision.multPVz(), collision.multFT0C() * scaleSignalFT0C); + + // save vertex-Z equalized + getHist(TH1, histPath + "hNPVContributors")->Fill(multNTracksPV); + getHist(TH1, histPath + "hFT0C_Collisions")->Fill(multFT0C * scaleSignalFT0C); + getHist(TH1, histPath + "hFT0M_Collisions")->Fill((multFT0A + multFT0C) * scaleSignalFT0M); + getHist(TH1, histPath + "hFV0A_Collisions")->Fill(multFV0A * scaleSignalFV0A); + getHist(TH1, histPath + "hNGlobalTracks")->Fill(multNTracksGlobal); + getHist(TH1, histPath + "hNMFTTracks")->Fill(mftNtracks); + + if (applyVertexZEqualization.value) { + // save unequalized for cross-checks + getHist(TH1, histPath + "hNPVContributors_Unequalized")->Fill(collision.multNTracksPV()); + getHist(TH1, histPath + "hFT0C_Collisions_Unequalized")->Fill(collision.multFT0C() * scaleSignalFT0C); + getHist(TH1, histPath + "hFT0M_Collisions_Unequalized")->Fill((collision.multFT0A() + collision.multFT0C()) * scaleSignalFT0M); + getHist(TH1, histPath + "hFV0A_Collisions_Unequalized")->Fill(collision.multFV0A() * scaleSignalFV0A); + getHist(TH1, histPath + "hNGlobalTracks_Unequalized")->Fill(collision.multNTracksGlobal()); + getHist(TH1, histPath + "hNMFTTracks_Unequalized")->Fill(collision.mftNtracks()); } + if (do2DPlots) { histos.fill(HIST("hNContribsVsFT0C"), collision.multFT0C() * scaleSignalFT0C, collision.multPVTotalContributors()); histos.fill(HIST("hNContribsVsFV0A"), collision.multFV0A() * scaleSignalFV0A, collision.multPVTotalContributors()); histos.fill(HIST("hMatchedVsITSOnly"), collision.multNTracksITSOnly(), collision.multNTracksITSTPC()); + getHist(TH2, histPath + "hNContribsVsFT0C")->Fill(collision.multFT0C() * scaleSignalFT0C, collision.multPVTotalContributors()); + getHist(TH2, histPath + "hNContribsVsFV0A")->Fill(collision.multFV0A() * scaleSignalFV0A, collision.multPVTotalContributors()); + getHist(TH2, histPath + "hMatchedVsITSOnly")->Fill(collision.multNTracksITSOnly(), collision.multNTracksITSTPC()); // correlate also FIT detector signals histos.fill(HIST("hFT0AVsFT0C"), collision.multFT0C() * scaleSignalFT0C, collision.multFT0A()); histos.fill(HIST("hFV0AVsFT0C"), collision.multFT0C() * scaleSignalFT0C, collision.multFV0A()); histos.fill(HIST("hFDDAVsFT0C"), collision.multFT0C() * scaleSignalFT0C, collision.multFDDA()); histos.fill(HIST("hFDDCVsFT0C"), collision.multFT0C() * scaleSignalFT0C, collision.multFDDC()); + getHist(TH2, histPath + "hFT0AVsFT0C")->Fill(collision.multFT0C() * scaleSignalFT0C, collision.multFT0A()); + getHist(TH2, histPath + "hFV0AVsFT0C")->Fill(collision.multFT0C() * scaleSignalFT0C, collision.multFV0A()); + getHist(TH2, histPath + "hFDDAVsFT0C")->Fill(collision.multFT0C() * scaleSignalFT0C, collision.multFDDA()); + getHist(TH2, histPath + "hFDDCVsFT0C")->Fill(collision.multFT0C() * scaleSignalFT0C, collision.multFDDC()); } if (doOccupancyStudyVsCentrality2d) { @@ -367,6 +652,7 @@ struct centralityStudy { if (doNGlobalTracksVsRawSignals) { histos.fill(HIST("hNGlobalTracksVsFT0A"), collision.multFT0A(), collision.multNTracksGlobal()); histos.fill(HIST("hNGlobalTracksVsFT0C"), collision.multFT0C(), collision.multNTracksGlobal()); + histos.fill(HIST("hNGlobalTracksVsFT0M"), collision.multFT0A() + collision.multFT0C(), collision.multNTracksGlobal()); histos.fill(HIST("hNGlobalTracksVsFV0A"), collision.multFV0A(), collision.multNTracksGlobal()); histos.fill(HIST("hNGlobalTracksVsFDDA"), collision.multFDDA(), collision.multNTracksGlobal()); histos.fill(HIST("hNGlobalTracksVsFDDC"), collision.multFDDC(), collision.multNTracksGlobal()); @@ -385,6 +671,13 @@ struct centralityStudy { histos.fill(HIST("hNGlobalTracksVsCentrality"), collision.centFT0C(), collision.multNTracksGlobal()); histos.fill(HIST("hNMFTTracksVsCentrality"), collision.centFT0C(), collision.mftNtracks()); histos.fill(HIST("hPVChi2VsCentrality"), collision.centFT0C(), collision.multPVChi2()); + getHist(TH1, histPath + "hCentrality")->Fill(collision.centFT0C()); + getHist(TH2, histPath + "hNContribsVsCentrality")->Fill(collision.centFT0C(), collision.multPVTotalContributors()); + getHist(TH2, histPath + "hNITSTPCTracksVsCentrality")->Fill(collision.centFT0C(), collision.multNTracksITSTPC()); + getHist(TH2, histPath + "hNITSOnlyTracksVsCentrality")->Fill(collision.centFT0C(), collision.multNTracksITSOnly()); + getHist(TH2, histPath + "hNGlobalTracksVsCentrality")->Fill(collision.centFT0C(), collision.multNTracksGlobal()); + getHist(TH2, histPath + "hNMFTTracksVsCentrality")->Fill(collision.centFT0C(), collision.mftNtracks()); + getHist(TH2, histPath + "hPVChi2VsCentrality")->Fill(collision.centFT0C(), collision.multPVChi2()); if (doOccupancyStudyVsCentrality2d) { histos.fill(HIST("hNcontribsProfileVsTrackOccupancyVsCentrality"), collision.trackOccupancyInTimeRange(), collision.centFT0C(), collision.multPVTotalContributors()); @@ -400,24 +693,50 @@ struct centralityStudy { histos.fill(HIST("hFT0COccupancyVsNGlobalTracksVsCentrality"), collision.ft0cOccupancyInTimeRange(), collision.multNTracksGlobal(), collision.centFT0C()); } } + + if (doTimeStudies && collision.has_multBC()) { + initRun(collision); + auto multbc = collision.template multBC_as(); + uint64_t bcTimestamp = multbc.timestamp(); + float hoursAfterStartOfRun = static_cast(bcTimestamp - startOfRunTimestamp) / 3600000.0; + + getHist(TH2, histPath + "hFT0AVsTime")->Fill(hoursAfterStartOfRun, collision.multFT0A()); + getHist(TH2, histPath + "hFT0CVsTime")->Fill(hoursAfterStartOfRun, collision.multFT0C()); + getHist(TH2, histPath + "hFT0MVsTime")->Fill(hoursAfterStartOfRun, collision.multFT0M()); + getHist(TH2, histPath + "hFV0AVsTime")->Fill(hoursAfterStartOfRun, collision.multFV0A()); + getHist(TH2, histPath + "hFV0AOuterVsTime")->Fill(hoursAfterStartOfRun, collision.multFV0AOuter()); + getHist(TH2, histPath + "hMFTTracksVsTime")->Fill(hoursAfterStartOfRun, collision.mftNtracks()); + getHist(TH2, histPath + "hNGlobalVsTime")->Fill(hoursAfterStartOfRun, collision.multNTracksGlobal()); + getHist(TH2, histPath + "hNTPVContributorsVsTime")->Fill(hoursAfterStartOfRun, collision.multPVTotalContributors()); + getHist(TProfile, histPath + "hPVzProfileCoVsTime")->Fill(hoursAfterStartOfRun, collision.multPVz()); + getHist(TProfile, histPath + "hPVzProfileBcVsTime")->Fill(hoursAfterStartOfRun, multbc.multFT0PosZ()); + if (doTimeStudyFV0AOuterVsFT0A3d) { + histos.fill(HIST("h3dFV0AVsTime"), hoursAfterStartOfRun, collision.multFV0A(), collision.multFV0AOuter()); + } + + if (irDoRateVsTime) { + float interactionRate = mRateFetcher.fetch(ccdb.service, bcTimestamp, mRunNumber, irSource.value, irCrashOnNull) / 1000.; // kHz + getHist(TProfile, histPath + "hIRProfileVsTime")->Fill(hoursAfterStartOfRun, interactionRate); + } + } } - void processCollisions(soa::Join::iterator const& collision) + void processCollisions(soa::Join::iterator const& collision, aod::MultBCs const&) { genericProcessCollision(collision); } - void processCollisionsWithCentrality(soa::Join::iterator const& collision) + void processCollisionsWithCentrality(soa::Join::iterator const& collision, aod::MultBCs const&) { genericProcessCollision(collision); } - void processCollisionsWithCentralityWithNeighbours(soa::Join::iterator const& collision) + void processCollisionsWithCentralityWithNeighbours(soa::Join::iterator const& collision, aod::MultBCs const&) { genericProcessCollision(collision); } - void processBCs(soa::Join::iterator const& multbc, soa::Join const&) + void processBCs(soa::Join::iterator const& multbc, soa::Join const&) { // process BCs, calculate FT0C distribution // conditionals suggested by FIT team (Jacek O. et al) @@ -472,7 +791,7 @@ struct centralityStudy { } if (multbc.has_ft0Mult()) { - auto multco = multbc.ft0Mult_as>(); + auto multco = multbc.ft0Mult_as>(); if (multbc.multFT0PosZValid()) { histos.fill(HIST("hVertexZ_BCvsCO"), multco.multPVz(), multbc.multFT0PosZ()); } diff --git a/Common/Tasks/flowTest.cxx b/Common/Tasks/flowTest.cxx new file mode 100644 index 00000000000..bb27c0cc504 --- /dev/null +++ b/Common/Tasks/flowTest.cxx @@ -0,0 +1,292 @@ +// 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. + +// flow test for QC of synthetic flow exercise +// cross-PWG effort in tracking studies +// includes basic tracking, V0s and Cascades + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "ReconstructionDataFormats/Track.h" +#include "Common/Core/trackUtilities.h" +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "PWGMM/Mult/DataModel/Index.h" // for Particles2Tracks table + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +#define bitcheck(var, nbit) ((var) & (1 << (nbit))) + +#include "Framework/runDataProcessing.h" + +struct flowTest { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Configurable minB{"minB", 0.0f, "min impact parameter"}; + Configurable maxB{"maxB", 20.0f, "max impact parameter"}; + Configurable pdgSelection{"pdgSelection", 0, "pdg code selection for tracking study (0: no selection)"}; + + Configurable analysisMinimumITSClusters{"analysisMinimumITSClusters", 5, "minimum ITS clusters for analysis track category"}; + Configurable analysisMinimumTPCClusters{"analysisMinimumTPCClusters", 70, "minimum TPC clusters for analysis track category"}; + + ConfigurableAxis axisB{"axisB", {100, 0.0f, 20.0f}, ""}; + ConfigurableAxis axisPhi{"axisPhi", {100, 0.0f, 2.0f * TMath::Pi()}, ""}; + ConfigurableAxis axisNch{"axisNch", {300, 0.0f, 3000.0f}, "Nch in |eta|<0.8"}; + + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f}, "pt axis"}; + + void init(InitContext&) + { + // QA and detailed studies + histos.add("hImpactParameter", "hImpactParameter", HistType::kTH1D, {axisB}); + histos.add("hNchVsImpactParameter", "hNchVsImpactParameter", HistType::kTH2D, {axisB, axisNch}); + histos.add("hEventPlaneAngle", "hEventPlaneAngle", HistType::kTH1D, {axisPhi}); + histos.add("hTrackPhiVsEventPlaneAngle", "hTrackPhiVsEventPlaneAngle", HistType::kTH2D, {axisPhi, axisPhi}); + histos.add("hTrackDeltaPhiVsEventPlaneAngle", "hTrackDeltaPhiVsEventPlaneAngle", HistType::kTH2D, {axisPhi, axisPhi}); + + // analysis + histos.add("hPtVsPhiGenerated", "hPtVsPhiGenerated", HistType::kTH2D, {axisPhi, axisPt}); + histos.add("hPtVsPhiGlobal", "hPtVsPhiGlobal", HistType::kTH2D, {axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGenerated", "hBVsPtVsPhiGenerated", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobal", "hBVsPtVsPhiGlobal", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobalFake", "hBVsPtVsPhiGlobalFake", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiAnalysis", "hBVsPtVsPhiAnalysis", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiAnalysisFake", "hBVsPtVsPhiAnalysisFake", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiAny", "hBVsPtVsPhiAny", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiTPCTrack", "hBVsPtVsPhiTPCTrack", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiITSTrack", "hBVsPtVsPhiITSTrack", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiITSTrackFake", "hBVsPtVsPhiITSTrackFake", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiITSABTrack", "hBVsPtVsPhiITSABTrack", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiITSABTrackFake", "hBVsPtVsPhiITSABTrackFake", HistType::kTH3D, {axisB, axisPhi, axisPt}); + + histos.add("hBVsPtVsPhiGeneratedK0Short", "hBVsPtVsPhiGeneratedK0Short", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobalK0Short", "hBVsPtVsPhiGlobalK0Short", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGeneratedLambda", "hBVsPtVsPhiGeneratedLambda", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobalLambda", "hBVsPtVsPhiGlobalLambda", HistType::kTH3D, {axisB, axisPhi, axisPt}); + + histos.add("hBVsPtVsPhiGeneratedXi", "hBVsPtVsPhiGeneratedXi", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobalXi", "hBVsPtVsPhiGlobalXi", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGeneratedOmega", "hBVsPtVsPhiGeneratedOmega", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobalOmega", "hBVsPtVsPhiGlobalOmega", HistType::kTH3D, {axisB, axisPhi, axisPt}); + } + + using recoTracks = soa::Join; + using recoTracksWithLabels = soa::Join; + + void process(aod::McCollision const& mcCollision, soa::Join const& mcParticles, recoTracksWithLabels const&) + { + + float imp = mcCollision.impactParameter(); + float evPhi = mcCollision.eventPlaneAngle(); + if (evPhi < 0) + evPhi += 2. * TMath::Pi(); + + long nCh = 0; + + if (imp > minB && imp < maxB) { + // event within range + histos.fill(HIST("hImpactParameter"), imp); + histos.fill(HIST("hEventPlaneAngle"), evPhi); + + for (auto const& mcParticle : mcParticles) { + // focus on bulk: e, mu, pi, k, p + int pdgCode = TMath::Abs(mcParticle.pdgCode()); + if (pdgCode != 11 && pdgCode != 13 && pdgCode != 211 && pdgCode != 321 && pdgCode != 2212) + continue; + if ((pdgSelection.value != 0) && (pdgCode != pdgSelection.value)) + continue; // isn't of desired species and pdgSelection is requested + + if (!mcParticle.isPhysicalPrimary()) + continue; + if (TMath::Abs(mcParticle.eta()) > 0.8) // main acceptance + continue; + + float deltaPhi = mcParticle.phi() - mcCollision.eventPlaneAngle(); + if (deltaPhi < 0) + deltaPhi += 2. * TMath::Pi(); + if (deltaPhi > 2. * TMath::Pi()) + deltaPhi -= 2. * TMath::Pi(); + + histos.fill(HIST("hTrackDeltaPhiVsEventPlaneAngle"), evPhi, deltaPhi); + histos.fill(HIST("hTrackPhiVsEventPlaneAngle"), evPhi, mcParticle.phi()); + histos.fill(HIST("hPtVsPhiGenerated"), deltaPhi, mcParticle.pt()); + histos.fill(HIST("hBVsPtVsPhiGenerated"), imp, deltaPhi, mcParticle.pt()); + + nCh++; + + bool validGlobal = false; + bool validGlobalFake = false; + bool validTrack = false; + bool validTPCTrack = false; + bool validITSTrack = false; + bool validITSTrackFake = false; + bool validITSABTrack = false; + bool validITSABTrackFake = false; + bool validAnalysisTrack = false; + bool validAnalysisTrackFake = false; + if (mcParticle.has_tracks()) { + auto const& tracks = mcParticle.tracks_as(); + for (auto const& track : tracks) { + bool isITSFake = false; + if (bitcheck(track.mcMask(), 13)) { // should perhaps be done better at some point + isITSFake = true; + } + + if (track.tpcNClsFound() >= analysisMinimumTPCClusters && track.itsNCls() >= analysisMinimumITSClusters) { + validAnalysisTrack = true; + if (isITSFake) { + validAnalysisTrackFake = true; + } + } + if (track.hasTPC() && track.hasITS()) { + validGlobal = true; + if (isITSFake) { + validGlobalFake = true; + } + } + if (track.hasTPC() || track.hasITS()) { + validTrack = true; + } + if (track.hasTPC()) { + validTPCTrack = true; + } + if (track.hasITS() && track.itsChi2NCl() > -1e-6) { + validITSTrack = true; + if (isITSFake) { + validITSTrackFake = true; + } + } + if (track.hasITS() && track.itsChi2NCl() < -1e-6) { + validITSABTrack = true; + if (isITSFake) { + validITSABTrackFake = true; + } + } + } + } + + // if valid global, fill + if (validGlobal) { + histos.fill(HIST("hPtVsPhiGlobal"), deltaPhi, mcParticle.pt()); + histos.fill(HIST("hBVsPtVsPhiGlobal"), imp, deltaPhi, mcParticle.pt()); + } + if (validGlobalFake) { + histos.fill(HIST("hBVsPtVsPhiGlobalFake"), imp, deltaPhi, mcParticle.pt()); + } + if (validAnalysisTrack) { + histos.fill(HIST("hBVsPtVsPhiAnalysis"), imp, deltaPhi, mcParticle.pt()); + } + if (validAnalysisTrackFake) { + histos.fill(HIST("hBVsPtVsPhiAnalysisFake"), imp, deltaPhi, mcParticle.pt()); + } + // if any track present, fill + if (validTrack) + histos.fill(HIST("hBVsPtVsPhiAny"), imp, deltaPhi, mcParticle.pt()); + if (validTPCTrack) + histos.fill(HIST("hBVsPtVsPhiTPCTrack"), imp, deltaPhi, mcParticle.pt()); + if (validITSTrack) + histos.fill(HIST("hBVsPtVsPhiITSTrack"), imp, deltaPhi, mcParticle.pt()); + if (validITSTrackFake) + histos.fill(HIST("hBVsPtVsPhiITSTrackFake"), imp, deltaPhi, mcParticle.pt()); + if (validITSABTrack) + histos.fill(HIST("hBVsPtVsPhiITSABTrack"), imp, deltaPhi, mcParticle.pt()); + if (validITSABTrackFake) + histos.fill(HIST("hBVsPtVsPhiITSABTrackFake"), imp, deltaPhi, mcParticle.pt()); + } + } + histos.fill(HIST("hNchVsImpactParameter"), imp, nCh); + } + + using LabeledCascades = soa::Join; + + void processCascade(aod::McParticle const& mcParticle, soa::SmallGroups const& cascades, recoTracks const&, aod::McCollisions const&) + { + auto mcCollision = mcParticle.mcCollision(); + float imp = mcCollision.impactParameter(); + + int pdgCode = TMath::Abs(mcParticle.pdgCode()); + if (pdgCode != 3312 && pdgCode != 3334) + return; + + if (!mcParticle.isPhysicalPrimary()) + return; + if (TMath::Abs(mcParticle.eta()) > 0.8) + return; + + float deltaPhi = mcParticle.phi() - mcCollision.eventPlaneAngle(); + if (deltaPhi < 0) + deltaPhi += 2. * TMath::Pi(); + if (deltaPhi > 2. * TMath::Pi()) + deltaPhi -= 2. * TMath::Pi(); + if (pdgCode == 3312) + histos.fill(HIST("hBVsPtVsPhiGeneratedXi"), imp, deltaPhi, mcParticle.pt()); + if (pdgCode == 3334) + histos.fill(HIST("hBVsPtVsPhiGeneratedOmega"), imp, deltaPhi, mcParticle.pt()); + + if (cascades.size() > 0) { + if (pdgCode == 3312) + histos.fill(HIST("hBVsPtVsPhiGlobalXi"), imp, deltaPhi, mcParticle.pt()); + if (pdgCode == 3334) + histos.fill(HIST("hBVsPtVsPhiGlobalOmega"), imp, deltaPhi, mcParticle.pt()); + } + } + PROCESS_SWITCH(flowTest, processCascade, "Process cascades", true); + + using LabeledV0s = soa::Join; + + void processV0s(aod::McParticle const& mcParticle, soa::SmallGroups const& v0s, recoTracks const&, aod::McCollisions const&) + { + auto mcCollision = mcParticle.mcCollision(); + float imp = mcCollision.impactParameter(); + + int pdgCode = TMath::Abs(mcParticle.pdgCode()); + if (pdgCode != 310 && pdgCode != 3122) + return; + + if (!mcParticle.isPhysicalPrimary()) + return; + if (TMath::Abs(mcParticle.eta()) > 0.8) + return; + + float deltaPhi = mcParticle.phi() - mcCollision.eventPlaneAngle(); + if (deltaPhi < 0) + deltaPhi += 2. * TMath::Pi(); + if (deltaPhi > 2. * TMath::Pi()) + deltaPhi -= 2. * TMath::Pi(); + if (pdgCode == 310) + histos.fill(HIST("hBVsPtVsPhiGeneratedK0Short"), imp, deltaPhi, mcParticle.pt()); + if (pdgCode == 3122) + histos.fill(HIST("hBVsPtVsPhiGeneratedLambda"), imp, deltaPhi, mcParticle.pt()); + + if (v0s.size() > 0) { + if (pdgCode == 310) + histos.fill(HIST("hBVsPtVsPhiGlobalK0Short"), imp, deltaPhi, mcParticle.pt()); + if (pdgCode == 3122) + histos.fill(HIST("hBVsPtVsPhiGlobalLambda"), imp, deltaPhi, mcParticle.pt()); + } + } + PROCESS_SWITCH(flowTest, processV0s, "Process V0s", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Common/Tasks/propagatorQa.cxx b/Common/Tasks/propagatorQa.cxx index b5abade3ba5..f978f8bc564 100644 --- a/Common/Tasks/propagatorQa.cxx +++ b/Common/Tasks/propagatorQa.cxx @@ -208,7 +208,7 @@ struct propagatorQa { /* check the previous run number */ auto bc = collision.bc_as(); initCCDB(bc); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; for (auto& track : tracks) { if (track.tpcNClsFound() < minTPCClustersRequired) @@ -328,7 +328,7 @@ struct propagatorQa { /* check the previous run number */ auto bc = collision.bc_as(); initCCDB(bc); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; for (auto& track : tracks) { if (track.tpcNClsFound() < minTPCClustersRequired) @@ -444,7 +444,7 @@ struct propagatorQa { /* check the previous run number */ auto bc = collision.bc_as(); initCCDB(bc); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; for (auto& trackIU : tracksIU) { if (trackIU.tpcNClsFound() < minTPCClustersRequired) diff --git a/Common/Tasks/qaMuon.cxx b/Common/Tasks/qaMuon.cxx new file mode 100644 index 00000000000..8ef5a42f824 --- /dev/null +++ b/Common/Tasks/qaMuon.cxx @@ -0,0 +1,3091 @@ +// 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. +/// \brief The task for muon QA +/// \author Andrea Ferrero +/// \author Paul Veen +/// \author Chi Zhang + +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FwdTrackReAlignTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CCDBTimeStampUtils.h" +#include "CommonUtils/ConfigurableParam.h" +#include "CommonUtils/NameConf.h" +#include "DataFormatsMCH/Cluster.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GRPGeomHelper.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Field/MagneticField.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "GlobalTracking/MatchGlobalFwd.h" +#include "MCHBase/TrackerParam.h" +#include "MCHGeometryTransformer/Transformations.h" +#include "MCHTracking/Track.h" +#include "MCHTracking/TrackExtrap.h" +#include "MCHTracking/TrackFitter.h" +#include "MCHTracking/TrackParam.h" +#include "MathUtils/Cartesian.h" +#include "ReconstructionDataFormats/TrackFwd.h" + +#include "Math/Vector4D.h" +#include "TGeoGlobalMagField.h" + +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace o2; +using namespace o2::aod; +using namespace o2::mch; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using MyEvents = soa::Join; +using MyMuonsWithCov = soa::Join; +using MyMFTs = aod::MFTTracks; + +using SMatrix55 = ROOT::Math::SMatrix>; +using SMatrix5 = ROOT::Math::SVector; + +using MuonPair = std::pair, std::pair>; +using GlobalMuonPair = std::pair>, std::pair>>; + +const int fgNCh = 10; +const int fgNDetElemCh[fgNCh] = {4, 4, 4, 4, 18, 18, 26, 26, 26, 26}; +const int fgSNDetElemCh[fgNCh + 1] = {0, 4, 8, 12, 16, 34, 52, 78, 104, 130, 156}; +const float zAtAbsEnd = -505.; + +constexpr double firstMFTPlaneZ = o2::mft::constants::mft::LayerZCoordinate()[0]; +constexpr double lastMFTPlaneZ = o2::mft::constants::mft::LayerZCoordinate()[9]; + +std::array zRefPlane{ + firstMFTPlaneZ, + lastMFTPlaneZ, + -90.0, + -300.0, + //-505.0, + -520.0}; + +std::vector> referencePlanes{ + {"MFT-begin", 10.0}, + {"MFT-end", 15.0}, + {"Absorber-begin", 20.0}, + {"Absorber-mid", 75.0}, + //{"Absorber-end", 100.0}, + {"MCH-begin", 100.0}}; + +enum MuonExtrapolation { + // Index used to set different options for muon propagation + kToVtx = 0, // propagtion to vertex by default + kToDCA, + kToAbsEnd, + kToZ +}; + +struct VarColl { + int64_t globalIndex = 0; + float x = 0.f; + float y = 0.f; + float z = 0.f; + float covXX = 0.f; + float covYY = 0.f; + int64_t bc = 0; + int multMFT = 0; +}; + +struct VarTrack { + int64_t collisionId = -1; + int64_t globalIndex = 0; + int nClusters = 0; // Only MCH + int sign = 0; + int64_t bc = 0; + int trackType = 0; + float trackTime = 0.f; + + // Basic kinematics + float x = 0.f; + float y = 0.f; + float z = 0.f; + float eta = 0.f; + float phi = 0.f; + float tgl = 0.f; + + float px = 0.f; + float py = 0.f; + float pz = 0.f; + float pT = 0.f; + float p = 0.f; + + // Propagation related infos + float dcaX = 0.f; + float dcaY = 0.f; + float pDca = 0.f; + float rabs = 0.f; + float chi2 = 0.f; + float chi2matching = 0.f; +}; + +struct VarClusters { + vector> posClusters; // (x,y,z) + vector> errorClusters; // (ex,ey) + vector DEIDs; +}; + +struct muonQa { + //// Variables for enabling QA options + struct : ConfigurableGroup { + Configurable fEnableQAMatching{"cfgEnableQAMatching", false, "Enable MCH-MFT matching QA checks"}; + Configurable fEnableQAResidual{"cfgEnableQAResidual", false, "Enable residual QA checks"}; + Configurable fEnableQADCA{"cfgEnableQADCA", false, "Enable DCA QA checks"}; + Configurable fEnableQADimuon{"cfgEnableQADimuon", false, "Enable dimuon QA checks"}; + } configQAs; + + //// Variables for selecting muon tracks + struct : ConfigurableGroup { + Configurable fPMchLow{"cfgPMchLow", 0.0f, ""}; + Configurable fPtMchLow{"cfgPtMchLow", 0.7f, ""}; + Configurable fEtaMchLow{"cfgEtaMchLow", -4.0f, ""}; + Configurable fEtaMchUp{"cfgEtaMchUp", -2.5f, ""}; + Configurable fRabsLow{"cfgRabsLow", 17.6f, ""}; + Configurable fRabsUp{"cfgRabsUp", 89.5f, ""}; + Configurable fSigmaPdcaUp{"cfgPdcaUp", 6.f, ""}; + Configurable fTrackChi2MchUp{"cfgTrackChi2MchUp", 5.f, ""}; + Configurable fMatchingChi2MchMidUp{"cfgMatchingChi2MchMidUp", 999.f, ""}; + } configMuons; + + //// Variables for selecting mft tracks + struct : ConfigurableGroup { + Configurable fEtaMftLow{"cfgEtaMftlow", -3.6f, ""}; + Configurable fEtaMftUp{"cfgEtaMftup", -2.5f, ""}; + Configurable fTrackNClustMftLow{"cfgTrackNClustMftLow", 7, ""}; + Configurable fTrackChi2MftUp{"cfgTrackChi2MftUp", 999.f, ""}; + } configMFTs; + + //// Variables for selecting global tracks + Configurable fMatchingChi2MftMchUp{"cfgMatchingChi2MftMchUp", 50.f, ""}; + + //// Variables for alignment corrections + Configurable fEnableMFTAlignmentCorrections{"cfgEnableMFTAlignmentCorrections", false, ""}; + + //// Variables for re-alignment setup + struct : ConfigurableGroup { + Configurable fDoRealign{"cfgDoRealign", false, "Switch to apply re-alignment"}; + Configurable fChamberResolutionX{"cfgChamberResolutionX", 0.4, "Chamber resolution along X configuration for refit"}; // 0.4cm pp, 0.2cm PbPb + Configurable fChamberResolutionY{"cfgChamberResolutionY", 0.4, "Chamber resolution along Y configuration for refit"}; // 0.4cm pp, 0.2cm PbPb + Configurable fSigmaCutImprove{"cfgSigmaCutImprove", 6., "Sigma cut for track improvement"}; + } configRealign; + + /// Variables to event mixing criteria + struct : ConfigurableGroup { + Configurable fEventMaxDeltaNMFT{"cfgEventMaxDeltaNMFT", 1, ""}; + Configurable fEventMaxDeltaVtxZ{"cfgEventMaxDeltaVtxZ", 1.f, ""}; + Configurable fEventMinDeltaBc{"cfgEventMinDeltaBc", 500, ""}; + } configMixing; + + //// Variables for ccdb + struct : ConfigurableGroup { + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable geoPathRealign{"geoPathRealign", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable nolaterthan{"ccdb-no-later-than-ref", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object of reference basis"}; + Configurable nolaterthanRealign{"ccdb-no-later-than-new", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object of new basis"}; + } configCCDB; + + //// Variables for histograms configuration + Configurable fNCandidatesMax{"nCandidatesMax", 5, ""}; + + parameters::GRPMagField* grpmag = nullptr; + TrackFitter trackFitter; // Track fitter from MCH tracking library + + globaltracking::MatchGlobalFwd mMatching; + int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. + double mImproveCutChi2; // Chi2 cut for track improvement. + Service ccdb; + o2::field::MagneticField* fieldB = nullptr; + double Bz; // Bz for MFT + + geo::TransformationCreator transformation; + map transformRef; // reference geometry w.r.t track data + map transformNew; // new geometry + TGeoManager* geoNew = nullptr; + TGeoManager* geoRef = nullptr; + + Preslice perMuon = aod::fwdtrkcl::fwdtrackId; + Preslice fwdtracksPerCollision = aod::fwdtrack::collisionId; + Preslice mftPerCollision = aod::fwdtrack::collisionId; + + HistogramRegistry registry{"registry", {}}; + HistogramRegistry registryDCA{"registryDCA", {}}; + HistogramRegistry registryResiduals{"registryResiduals", {}}; + HistogramRegistry registryResidualsMFT{"registryResidualsMFT", {}}; + HistogramRegistry registryResidualsMCH{"registryResidualsMCH", {}}; + HistogramRegistry registryDimuon{"registryDimuon", {}}; + + std::array quadrants = {"Q0", "Q1", "Q2", "Q3"}; + + std::array, 3>, 4>, 2> dcaHistos; + std::array, 3>, 4>, 2> dcaHistosMixedEvents; + + std::array, 4>, 6> trackResidualsHistos; + std::array, 4>, 6> trackResidualsHistosMixedEvents; + + std::array, 10>, 4> residualsHistos; + std::array, 10>, 4> residualsHistosMixedEvents; + + std::array, 10>, 2>, 2> residualsHistosPerDE; + std::array, 10>, 2>, 2> residualsHistosPerDEMixedEvents; + + std::array, 10>, 2>, 2> mchResidualsHistosPerDE; + std::array, 10>, 2>, 2> mchResidualsHistosPerDEMixedEvents; + + VarTrack fgValuesMCH; + VarTrack fgValuesMCHpv; + VarTrack fgValuesMFT; + VarTrack fgValuesGlobal; + vector fgValuesCandidates; + + void CreateBasicHistograms() + { + // ====================== + // Muons plots + // ====================== + + AxisSpec chi2Axis = {1000, 0, 1000, "chi2"}; + AxisSpec momentumAxis = {1000, 0, 1000, "p (GeV/c)"}; + AxisSpec transverseMomentumAxis = {1000, 0, 100, "p_{T} (GeV/c)"}; + AxisSpec etaAxis = {80, -5, -1, "#eta"}; + AxisSpec rAbsAxis = {100, 0., 100.0, "R_{abs} (cm)"}; + AxisSpec dcaAxis = {400, 0.0, 20.0, "DCA"}; + AxisSpec pdcaAxis = {5000, 0.0, 5000.0, "p #times DCA"}; + AxisSpec phiAxis = {360, -180.0, 180.0, "#phi (degrees)"}; + + registry.add("muons/TrackChi2", "MCH track #chi^{2}", {HistType::kTH1F, {chi2Axis}}); + registry.add("muons/TrackP", "MCH track momentum", {HistType::kTH1F, {momentumAxis}}); + registry.add("muons/TrackPt", "MCH track transverse momentum", {HistType::kTH1F, {transverseMomentumAxis}}); + registry.add("muons/TrackEta", "MCH track #eta", {HistType::kTH1F, {etaAxis}}); + registry.add("muons/TrackRabs", "MCH track R_{abs}", {HistType::kTH1F, {rAbsAxis}}); + registry.add("muons/TrackDCA", "MCH track DCA", {HistType::kTH1F, {dcaAxis}}); + registry.add("muons/TrackPDCA", "MCH track p #times DCA", {HistType::kTH1F, {pdcaAxis}}); + registry.add("muons/TrackPhi", "MCH track #phi", {HistType::kTH1F, {phiAxis}}); + + // muon origin from MCH quadrants + registry.add("muons/TrackEtaPos", "MCH #mu^{+} track #eta", {HistType::kTH1F, {etaAxis}}); + registry.add("muons/TrackEtaNeg", "MCH #mu^{-} track #eta", {HistType::kTH1F, {etaAxis}}); + // -- pT and eta + registry.add("muons/TrackPt_TrackEtaPos", "track pT and #eta", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + registry.add("muons/TrackPt_TrackEtaNeg", "track pT and #eta", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + // top-bottom + registry.add("muons/TrackEtaPos_T", "MCH #mu^{+} track #eta, top MCH CH1", {HistType::kTH1F, {etaAxis}}); + registry.add("muons/TrackEtaPos_B", "MCH #mu^{+} track #eta, bottom MCH CH1", {HistType::kTH1F, {etaAxis}}); + registry.add("muons/TrackEtaNeg_T", "MCH #mu^{-} track #eta, top MCH CH1", {HistType::kTH1F, {etaAxis}}); + registry.add("muons/TrackEtaNeg_B", "MCH #mu^{-} track #eta, bottom MCH CH1", {HistType::kTH1F, {etaAxis}}); + // -- pT and eta + registry.add("muons/TrackPt_TrackEtaPos_T", "track p_{T} and #eta, top MCH CH1", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + registry.add("muons/TrackPt_TrackEtaPos_B", "track p_{T} and #eta, bottom MCH CH1", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + registry.add("muons/TrackPt_TrackEtaNeg_T", "track p_{T} and #eta, top MCH CH1", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + registry.add("muons/TrackPt_TrackEtaNeg_B", "track p_{T} and #eta, bottom MCH CH1", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + // left-right + registry.add("muons/TrackEtaPos_L", "MCH #mu^{+} track #eta, left MCH CH1", {HistType::kTH1F, {etaAxis}}); + registry.add("muons/TrackEtaPos_R", "MCH #mu^{+} track #eta, right MCH CH1", {HistType::kTH1F, {etaAxis}}); + registry.add("muons/TrackEtaNeg_L", "MCH #mu^{-} track #eta, left MCH CH1", {HistType::kTH1F, {etaAxis}}); + registry.add("muons/TrackEtaNeg_R", "MCH #mu^{-} track #eta, right MCH CH1", {HistType::kTH1F, {etaAxis}}); + // -- pT and eta + registry.add("muons/TrackPt_TrackEtaPos_L", "track p_{T} and #eta, top MCH CH1", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + registry.add("muons/TrackPt_TrackEtaPos_R", "track p_{T} and #eta, bottom MCH CH1", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + registry.add("muons/TrackPt_TrackEtaNeg_L", "track p_{T} and #eta, top MCH CH1", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + registry.add("muons/TrackPt_TrackEtaNeg_R", "track p_{T} and #eta, bottom MCH CH1", {HistType::kTH2F, {transverseMomentumAxis, etaAxis}}); + + // ====================== + // Global muons plots + // ====================== + int nTrackTypes = static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MCHStandaloneTrack) + 1; + AxisSpec trackTypeAxis = {static_cast(nTrackTypes), 0.0, static_cast(nTrackTypes), "track type"}; + registry.add("global-muons/nTracksPerType", "Number of tracks per type", {HistType::kTH1F, {trackTypeAxis}}); + + AxisSpec nCandidatesAxis = {static_cast(fNCandidatesMax), 0.0, static_cast(fNCandidatesMax), "match candidate rank"}; + registry.add("global-muons/NCandidates", "Number of MFT-MCH match candidates", {HistType::kTH1F, {nCandidatesAxis}}); + registry.add("global-muons/MatchChi2", "MFT-MCH match chi2", {HistType::kTH2F, {chi2Axis, nCandidatesAxis}}); + + registry.add("global-muons/TrackChi2", "Muon track #chi^{2}", {HistType::kTH1F, {chi2Axis}}); + registry.add("global-muons/TrackP", "Muon track momentum", {HistType::kTH1F, {momentumAxis}}); + registry.add("global-muons/TrackPt", "Muon track transverse momentum", {HistType::kTH1F, {transverseMomentumAxis}}); + registry.add("global-muons/TrackEta", "Muon track #eta", {HistType::kTH1F, {etaAxis}}); + registry.add("global-muons/TrackRabs", "Muon track R_{abs}", {HistType::kTH1F, {rAbsAxis}}); + registry.add("global-muons/TrackDCA", "Muon track DCA", {HistType::kTH1F, {dcaAxis}}); + registry.add("global-muons/TrackPDCA", "Muon track p #times DCA", {HistType::kTH1F, {pdcaAxis}}); + registry.add("global-muons/TrackPhi", "Muon track #phi", {HistType::kTH1F, {phiAxis}}); + + // ====================== + // Global muon plots with matching cuts + // ====================== + + if (configQAs.fEnableQAMatching) { + AxisSpec dbcAxis = {1000, -500, 500, "#Delta_{BC}"}; + registry.add("global-matches/BCdifference", "MCH-MFT BC difference", {HistType::kTH1F, {dbcAxis}}); + + AxisSpec nClustersAxis = {20, 0, 20, "# of MFT clusters per track"}; + + registry.add("global-matches/MatchChi2", "MFT-MCH match chi2", {HistType::kTH1F, {chi2Axis}}); + + registry.add("global-matches/TrackChi2_MFT", "MFT track #chi^{2}", {HistType::kTH1F, {chi2Axis}}); + registry.add("global-matches/TrackNclusters_MFT", "MFT track Nclusters", {HistType::kTH1F, {nClustersAxis}}); + + registry.add("global-matches/TrackChi2", "Muon track #chi^{2}", {HistType::kTH1F, {chi2Axis}}); + registry.add("global-matches/TrackP", "Muon track momentum", {HistType::kTH1F, {momentumAxis}}); + registry.add("global-matches/TrackPt", "Muon track transverse momentum", {HistType::kTH1F, {transverseMomentumAxis}}); + registry.add("global-matches/TrackEta", "Muon track #eta", {HistType::kTH1F, {etaAxis}}); + registry.add("global-matches/TrackRabs", "Muon track R_{abs}", {HistType::kTH1F, {rAbsAxis}}); + registry.add("global-matches/TrackDCA", "Muon track DCA", {HistType::kTH1F, {dcaAxis}}); + registry.add("global-matches/TrackPDCA", "Muon track p #times DCA", {HistType::kTH1F, {pdcaAxis}}); + registry.add("global-matches/TrackPhi", "Muon track #phi", {HistType::kTH1F, {phiAxis}}); + + registry.add("global-matches/TrackP_glo", "Global muon track momentum", {HistType::kTH1F, {momentumAxis}}); + registry.add("global-matches/TrackPt_glo", "Global muon track transverse momentum", {HistType::kTH1F, {transverseMomentumAxis}}); + registry.add("global-matches/TrackEta_glo", "Global muon track #eta", {HistType::kTH1F, {etaAxis}}); + registry.add("global-matches/TrackDCA_glo", "Global muon track DCA", {HistType::kTH1F, {dcaAxis}}); + registry.add("global-matches/TrackPhi_glo", "Global muon track #phi", {HistType::kTH1F, {phiAxis}}); + } + + AxisSpec momentumCorrelationAxis = {100, 0, 100, "momentum (GeV/c)"}; + AxisSpec momentumDeltaAxis = {100, -1, 1, "#DeltaP (GeV/c)"}; + // Momentum correlations + registry.add("global-muons/MomentumCorrelation_Global_vs_Muon", + "P_{global} vs. P_{MCH}", + {HistType::kTH2F, {momentumCorrelationAxis, momentumCorrelationAxis}}); + registry.add("global-muons/MomentumDifference_Global_vs_Muon", + "(P_{global} - P_{MCH}) / P_{MCH} vs. P_{MCH}", + {HistType::kTH2F, {momentumCorrelationAxis, momentumDeltaAxis}}); + registry.add("global-muons/MomentumCorrelation_subleading_vs_leading", + "P_{subleading_match} vs. P_{leading_match}", + {HistType::kTH2F, {momentumCorrelationAxis, momentumCorrelationAxis}}); + registry.add("global-muons/MomentumDifference_subleading_vs_leading", + "(P_{subleading_match} - P_{leading_match}) / P_{leading_match} vs. P_{leading_match}", + {HistType::kTH2F, {momentumCorrelationAxis, momentumDeltaAxis}}); + + // AxisSpec etaAxis = {100, -5.0, -2.0, "#eta"}; + AxisSpec etaCorrelationAxis = {80, -5.0, -1.0, "#eta"}; + AxisSpec etaDeltaAxis = {100, -0.2, 0.2, "#Delta#eta"}; + // Eta correlations + registry.add("global-muons/EtaCorrelation_Global_vs_Muon", + "#eta_{global} vs. #eta_{MCH}", + {HistType::kTH2F, {etaCorrelationAxis, etaCorrelationAxis}}); + registry.add("global-muons/EtaDifference_Global_vs_Muon", + "(#eta_{global} - #eta_{MCH}) / #eta_{MCH} vs. #eta_{MCH}", + {HistType::kTH2F, {etaCorrelationAxis, etaDeltaAxis}}); + registry.add("global-muons/EtaCorrelation_subleading_vs_leading", + "#eta_{subleading_match} vs. #eta_{leading_match}", + {HistType::kTH2F, {etaCorrelationAxis, etaCorrelationAxis}}); + registry.add("global-muons/EtaDifference_subleading_vs_leading", + "(#eta_{subleading_match} - #eta_{leading_match}) / #eta_{leading_match} vs. #eta_{leading_match}", + {HistType::kTH2F, {etaCorrelationAxis, etaDeltaAxis}}); + } + + void CreateDetailedHistograms() + { + AxisSpec dcaxMFTAxis = {400, -0.5, 0.5, "DCA_{x} (cm)"}; + AxisSpec dcayMFTAxis = {400, -0.5, 0.5, "DCA_{y} (cm)"}; + AxisSpec dcaxMCHAxis = {400, -10.0, 10.0, "DCA_{x} (cm)"}; + AxisSpec dcayMCHAxis = {400, -10.0, 10.0, "DCA_{y} (cm)"}; + AxisSpec dcazAxis = {20, -10.0, 10.0, "DCA_{z} (cm)"}; + AxisSpec dxAxis = {600, -30.0, 30.0, "#Delta x (cm)"}; + AxisSpec dyAxis = {600, -30.0, 30.0, "#Delta y (cm)"}; + AxisSpec thetaxAxis = {10, 0.0, 20.0, "#theta_{x} (degrees)"}; + AxisSpec dThetaxAxis = {500, -5.0, 5.0, "#Delta#theta_{x} (degrees)"}; + AxisSpec thetayAxis = {10, 0.0, 20.0, "#theta_{y} (degrees)"}; + AxisSpec dThetayAxis = {500, -5.0, 5.0, "#Delta#theta_{y} (degrees)"}; + AxisSpec phiAxis = {360, -180.0, 180.0, "#phi (degrees)"}; + AxisSpec dPhiAxis = {200, -20.0, 20.0, "#Delta#phi (degrees)"}; + + if (configQAs.fEnableQAResidual) { + for (size_t i = 0; i < referencePlanes.size(); i++) { + const auto& refPLane = referencePlanes[i]; + AxisSpec xAxis = {10, 0, refPLane.second, "|x| (cm)"}; + AxisSpec yAxis = {10, 0, refPLane.second, "|y| (cm)"}; + for (size_t j = 0; j < quadrants.size(); j++) { + const auto& quadrant = quadrants[j]; + std::string histPath = std::string("Alignment/same-event/Residuals/ReferencePlanes/") + refPLane.first + "/" + quadrant + "/"; + trackResidualsHistos[i][j]["dx_vs_x"] = registry.add((histPath + "dx_vs_x").c_str(), std::format("#Delta x vs. |x| - {}", quadrant).c_str(), {HistType::kTH2F, {xAxis, dxAxis}}); + trackResidualsHistos[i][j]["dx_vs_y"] = registry.add((histPath + "dx_vs_y").c_str(), std::format("#Delta x vs. |y| - {}", quadrant).c_str(), {HistType::kTH2F, {yAxis, dxAxis}}); + trackResidualsHistos[i][j]["dy_vs_x"] = registry.add((histPath + "dy_vs_x").c_str(), std::format("#Delta y vs. |x| - {}", quadrant).c_str(), {HistType::kTH2F, {xAxis, dyAxis}}); + trackResidualsHistos[i][j]["dy_vs_y"] = registry.add((histPath + "dy_vs_y").c_str(), std::format("#Delta y vs. |y| - {}", quadrant).c_str(), {HistType::kTH2F, {yAxis, dyAxis}}); + + trackResidualsHistos[i][j]["dthetax_vs_x"] = registry.add((histPath + "dthetax_vs_x").c_str(), std::format("#Delta #theta_x vs. |x| - {}", quadrant).c_str(), {HistType::kTH2F, {xAxis, dThetaxAxis}}); + trackResidualsHistos[i][j]["dthetax_vs_y"] = registry.add((histPath + "dthetax_vs_y").c_str(), std::format("#Delta #theta_x vs. |y| - {}", quadrant).c_str(), {HistType::kTH2F, {yAxis, dThetaxAxis}}); + trackResidualsHistos[i][j]["dthetax_vs_thetax"] = registry.add((histPath + "dthetax_vs_thetax").c_str(), std::format("#Delta #theta_x vs. |#theta_x| - {}", quadrant).c_str(), {HistType::kTH2F, {thetaxAxis, dThetaxAxis}}); + + trackResidualsHistos[i][j]["dthetay_vs_x"] = registry.add((histPath + "dthetay_vs_x").c_str(), std::format("#Delta #theta_y vs. |x| - {}", quadrant).c_str(), {HistType::kTH2F, {xAxis, dThetayAxis}}); + trackResidualsHistos[i][j]["dthetay_vs_y"] = registry.add((histPath + "dthetay_vs_y").c_str(), std::format("#Delta #theta_y vs. |y| - {}", quadrant).c_str(), {HistType::kTH2F, {yAxis, dThetayAxis}}); + trackResidualsHistos[i][j]["dthetay_vs_thetay"] = registry.add((histPath + "dthetay_vs_thetay").c_str(), std::format("#Delta #theta_y vs. |#theta_y| - {}", quadrant).c_str(), {HistType::kTH2F, {thetayAxis, dThetayAxis}}); + + // mixed events + histPath = std::string("Alignment/mixed-event/Residuals/ReferencePlanes/") + refPLane.first + "/" + quadrant + "/"; + trackResidualsHistosMixedEvents[i][j]["dx_vs_x"] = registry.add((histPath + "dx_vs_x").c_str(), std::format("#Delta x vs. |x| - {}", quadrant).c_str(), {HistType::kTH2F, {xAxis, dxAxis}}); + trackResidualsHistosMixedEvents[i][j]["dx_vs_y"] = registry.add((histPath + "dx_vs_y").c_str(), std::format("#Delta x vs. |y| - {}", quadrant).c_str(), {HistType::kTH2F, {yAxis, dxAxis}}); + trackResidualsHistosMixedEvents[i][j]["dy_vs_x"] = registry.add((histPath + "dy_vs_x").c_str(), std::format("#Delta y vs. |x| - {}", quadrant).c_str(), {HistType::kTH2F, {xAxis, dyAxis}}); + trackResidualsHistosMixedEvents[i][j]["dy_vs_y"] = registry.add((histPath + "dy_vs_y").c_str(), std::format("#Delta y vs. |y| - {}", quadrant).c_str(), {HistType::kTH2F, {yAxis, dyAxis}}); + + trackResidualsHistosMixedEvents[i][j]["dthetax_vs_x"] = registry.add((histPath + "dthetax_vs_x").c_str(), std::format("#Delta #theta_x vs. |x| - {}", quadrant).c_str(), {HistType::kTH2F, {xAxis, dThetaxAxis}}); + trackResidualsHistosMixedEvents[i][j]["dthetax_vs_y"] = registry.add((histPath + "dthetax_vs_y").c_str(), std::format("#Delta #theta_x vs. |y| - {}", quadrant).c_str(), {HistType::kTH2F, {yAxis, dThetaxAxis}}); + trackResidualsHistosMixedEvents[i][j]["dthetax_vs_thetax"] = registry.add((histPath + "dthetax_vs_thetax").c_str(), std::format("#Delta #theta_x vs. |#theta_x| - {}", quadrant).c_str(), {HistType::kTH2F, {thetaxAxis, dThetaxAxis}}); + + trackResidualsHistosMixedEvents[i][j]["dthetay_vs_x"] = registry.add((histPath + "dthetay_vs_x").c_str(), std::format("#Delta #theta_y vs. |x| - {}", quadrant).c_str(), {HistType::kTH2F, {xAxis, dThetayAxis}}); + trackResidualsHistosMixedEvents[i][j]["dthetay_vs_y"] = registry.add((histPath + "dthetay_vs_y").c_str(), std::format("#Delta #theta_y vs. |y| - {}", quadrant).c_str(), {HistType::kTH2F, {yAxis, dThetayAxis}}); + trackResidualsHistosMixedEvents[i][j]["dthetay_vs_thetay"] = registry.add((histPath + "dthetay_vs_thetay").c_str(), std::format("#Delta #theta_y vs. |#theta_y| - {}", quadrant).c_str(), {HistType::kTH2F, {thetayAxis, dThetayAxis}}); + } + } + + for (size_t j = 0; j < quadrants.size(); j++) { + const auto& quadrant = quadrants[j]; + AxisSpec xAxis = {20, 0, 200, "|x| (cm)"}; + AxisSpec yAxis = {10, 0, 200, "|y| (cm)"}; + for (int chamber = 0; chamber < 10; chamber++) { + std::string histPath = std::string("Alignment/same-event/Residuals/MFT/") + quadrant + "/CH" + std::to_string(chamber + 1) + "/"; + // Delta x at cluster + residualsHistos[j][chamber]["dx_vs_x"] = registryResiduals.add((histPath + "dx_vs_x").c_str(), "Cluster x residual vs. x", {HistType::kTH2F, {xAxis, dxAxis}}); + residualsHistos[j][chamber]["dx_vs_y"] = registryResiduals.add((histPath + "dx_vs_y").c_str(), "Cluster x residual vs. y", {HistType::kTH2F, {yAxis, dxAxis}}); + residualsHistos[j][chamber]["dy_vs_x"] = registryResiduals.add((histPath + "dy_vs_x").c_str(), "Cluster y residual vs. x", {HistType::kTH2F, {xAxis, dyAxis}}); + residualsHistos[j][chamber]["dy_vs_y"] = registryResiduals.add((histPath + "dy_vs_y").c_str(), "Cluster y residual vs. y", {HistType::kTH2F, {yAxis, dyAxis}}); + + // mixed events + histPath = std::string("Alignment/mixed-event/Residuals/MFT/") + quadrant + "/CH" + std::to_string(chamber + 1) + "/"; + // Delta x at cluster + residualsHistosMixedEvents[j][chamber]["dx_vs_x"] = registryResiduals.add((histPath + "dx_vs_x").c_str(), "Cluster x residual vs. x", {HistType::kTH2F, {xAxis, dxAxis}}); + residualsHistosMixedEvents[j][chamber]["dx_vs_y"] = registryResiduals.add((histPath + "dx_vs_y").c_str(), "Cluster x residual vs. y", {HistType::kTH2F, {yAxis, dxAxis}}); + residualsHistosMixedEvents[j][chamber]["dy_vs_x"] = registryResiduals.add((histPath + "dy_vs_x").c_str(), "Cluster y residual vs. x", {HistType::kTH2F, {xAxis, dyAxis}}); + residualsHistosMixedEvents[j][chamber]["dy_vs_y"] = registryResiduals.add((histPath + "dy_vs_y").c_str(), "Cluster y residual vs. y", {HistType::kTH2F, {yAxis, dyAxis}}); + } + } + + for (size_t i = 0; i < 2; i++) { + std::string topBottom = (i == 0) ? "top" : "bottom"; + AxisSpec deAxis = {26, 0, 26, "DE index"}; + AxisSpec phiAxis = {16, -180, 180, "#phi (degrees)"}; + for (size_t j = 0; j < 2; j++) { + std::string sign = (j == 0) ? "positive" : "negative"; + for (int chamber = 0; chamber < 10; chamber++) { + std::string histPath = std::string("Alignment/same-event/Residuals/MFT/MFT_") + topBottom + "/" + sign + "/CH" + std::to_string(chamber + 1) + "/"; + // Delta x and y at cluster + residualsHistosPerDE[i][j][chamber]["dx_vs_de"] = registryResidualsMFT.add((histPath + "dx_vs_de").c_str(), "Cluster x residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}}); + residualsHistosPerDE[i][j][chamber]["dy_vs_de"] = registryResidualsMFT.add((histPath + "dy_vs_de").c_str(), "Cluster y residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}}); + + residualsHistosPerDE[i][j][chamber]["dx_vs_phi"] = registryResidualsMFT.add((histPath + "dx_vs_phi").c_str(), "Cluster x residual vs. cluster #phi", {HistType::kTH2F, {phiAxis, dxAxis}}); + residualsHistosPerDE[i][j][chamber]["dy_vs_phi"] = registryResidualsMFT.add((histPath + "dy_vs_phi").c_str(), "Cluster y residual vs. cluster #phi", {HistType::kTH2F, {phiAxis, dxAxis}}); + + // mixed events + histPath = std::string("Alignment/mixed-event/Residuals/MFT/MFT_") + topBottom + "/" + sign + "/CH" + std::to_string(chamber + 1) + "/"; + // Delta x and y at cluster + residualsHistosPerDEMixedEvents[i][j][chamber]["dx_vs_de"] = registryResidualsMFT.add((histPath + "dx_vs_de").c_str(), "Cluster x residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}}); + residualsHistosPerDEMixedEvents[i][j][chamber]["dy_vs_de"] = registryResidualsMFT.add((histPath + "dy_vs_de").c_str(), "Cluster y residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}}); + + residualsHistosPerDEMixedEvents[i][j][chamber]["dx_vs_phi"] = registryResidualsMFT.add((histPath + "dx_vs_phi").c_str(), "Cluster x residual vs. cluster #phi", {HistType::kTH2F, {phiAxis, dxAxis}}); + residualsHistosPerDEMixedEvents[i][j][chamber]["dy_vs_phi"] = registryResidualsMFT.add((histPath + "dy_vs_phi").c_str(), "Cluster y residual vs. cluster #phi", {HistType::kTH2F, {phiAxis, dxAxis}}); + } + } + } + + for (size_t i = 0; i < 2; i++) { + std::string topBottom = (i == 0) ? "top" : "bottom"; + AxisSpec deAxis = {26, 0, 26, "DE index"}; + for (size_t j = 0; j < 2; j++) { + std::string sign = (j == 0) ? "positive" : "negative"; + for (int chamber = 0; chamber < 10; chamber++) { + std::string histPath = std::string("Alignment/same-event/Residuals/MCH/MCH_") + topBottom + "/" + sign + "/CH" + std::to_string(chamber + 1) + "/"; + // Delta x and y at cluster + mchResidualsHistosPerDE[i][j][chamber]["dx_vs_de"] = registryResidualsMCH.add((histPath + "dx_vs_de").c_str(), "Cluster x residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}}); + mchResidualsHistosPerDE[i][j][chamber]["dy_vs_de"] = registryResidualsMCH.add((histPath + "dy_vs_de").c_str(), "Cluster y residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}}); + + // mixed events + histPath = std::string("Alignment/mixed-event/Residuals/MCH/MCH_") + topBottom + "/" + sign + "/CH" + std::to_string(chamber + 1) + "/"; + // Delta x and y at cluster + mchResidualsHistosPerDEMixedEvents[i][j][chamber]["dx_vs_de"] = registryResidualsMCH.add((histPath + "dx_vs_de").c_str(), "Cluster x residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}}); + mchResidualsHistosPerDEMixedEvents[i][j][chamber]["dy_vs_de"] = registryResidualsMCH.add((histPath + "dy_vs_de").c_str(), "Cluster y residual vs. DE index", {HistType::kTH2F, {deAxis, dxAxis}}); + } + } + } + } + + if (configQAs.fEnableQADCA) { + for (size_t j = 0; j < quadrants.size(); j++) { + const auto& quadrant = quadrants[j]; + std::string histPath = std::string("Alignment/same-event/DCA/MFT/") + quadrant + "/"; + dcaHistos[0][j][0]["DCA_x"] = registryDCA.add((histPath + "DCA_x").c_str(), std::format("DCA(x) - {}", quadrant).c_str(), {HistType::kTH1F, {dcaxMFTAxis}}); + dcaHistos[0][j][1]["DCA_x"] = registryDCA.add((histPath + "DCA_x_pos").c_str(), std::format("DCA(x) - {} charge > 0", quadrant).c_str(), {HistType::kTH1F, {dcaxMFTAxis}}); + dcaHistos[0][j][2]["DCA_x"] = registryDCA.add((histPath + "DCA_x_neg").c_str(), std::format("DCA(x) - {} charge < 0", quadrant).c_str(), {HistType::kTH1F, {dcaxMFTAxis}}); + dcaHistos[0][j][0]["DCA_y"] = registryDCA.add((histPath + "DCA_y").c_str(), std::format("DCA(y) - {}", quadrant).c_str(), {HistType::kTH1F, {dcayMFTAxis}}); + dcaHistos[0][j][1]["DCA_y"] = registryDCA.add((histPath + "DCA_y_pos").c_str(), std::format("DCA(y) - {} charge > 0", quadrant).c_str(), {HistType::kTH1F, {dcayMFTAxis}}); + dcaHistos[0][j][2]["DCA_y"] = registryDCA.add((histPath + "DCA_y_neg").c_str(), std::format("DCA(y) - {} charge < 0", quadrant).c_str(), {HistType::kTH1F, {dcayMFTAxis}}); + dcaHistos[0][j][0]["DCA_x_vs_z"] = registryDCA.add((histPath + "DCA_x_vs_z").c_str(), std::format("DCA(x) vs. z - {}", quadrant).c_str(), {HistType::kTH2F, {dcazAxis, dcaxMFTAxis}}); + dcaHistos[0][j][0]["DCA_y_vs_z"] = registryDCA.add((histPath + "DCA_y_vs_z").c_str(), std::format("DCA(y) vs. z - {}", quadrant).c_str(), {HistType::kTH2F, {dcazAxis, dcayMFTAxis}}); + + histPath = std::string("Alignment/same-event/DCA/MCH/") + quadrant + "/"; + dcaHistos[1][j][0]["DCA_x"] = registryDCA.add((histPath + "DCA_x").c_str(), std::format("DCA(x) - {}", quadrant).c_str(), {HistType::kTH1F, {dcaxMCHAxis}}); + dcaHistos[1][j][1]["DCA_x"] = registryDCA.add((histPath + "DCA_x_pos").c_str(), std::format("DCA(x) - {} charge > 0", quadrant).c_str(), {HistType::kTH1F, {dcaxMCHAxis}}); + dcaHistos[1][j][2]["DCA_x"] = registryDCA.add((histPath + "DCA_x_neg").c_str(), std::format("DCA(x) - {} charge < 0", quadrant).c_str(), {HistType::kTH1F, {dcaxMCHAxis}}); + dcaHistos[1][j][0]["DCA_y"] = registryDCA.add((histPath + "DCA_y").c_str(), std::format("DCA(y) - {}", quadrant).c_str(), {HistType::kTH1F, {dcayMCHAxis}}); + dcaHistos[1][j][1]["DCA_y"] = registryDCA.add((histPath + "DCA_y_pos").c_str(), std::format("DCA(y) - {} charge > 0", quadrant).c_str(), {HistType::kTH1F, {dcayMCHAxis}}); + dcaHistos[1][j][2]["DCA_y"] = registryDCA.add((histPath + "DCA_y_neg").c_str(), std::format("DCA(y) - {} charge < 0", quadrant).c_str(), {HistType::kTH1F, {dcayMCHAxis}}); + + histPath = std::string("Alignment/mixed-event/DCA/MFT/") + quadrant + "/"; + dcaHistosMixedEvents[0][j][0]["DCA_x"] = registryDCA.add((histPath + "DCA_x").c_str(), std::format("DCA(x) - {}", quadrant).c_str(), {HistType::kTH1F, {dcaxMFTAxis}}); + dcaHistosMixedEvents[0][j][1]["DCA_x"] = registryDCA.add((histPath + "DCA_x_pos").c_str(), std::format("DCA(x) - {} charge > 0", quadrant).c_str(), {HistType::kTH1F, {dcaxMFTAxis}}); + dcaHistosMixedEvents[0][j][2]["DCA_x"] = registryDCA.add((histPath + "DCA_x_neg").c_str(), std::format("DCA(x) - {} charge < 0", quadrant).c_str(), {HistType::kTH1F, {dcaxMFTAxis}}); + dcaHistosMixedEvents[0][j][0]["DCA_y"] = registryDCA.add((histPath + "DCA_y").c_str(), std::format("DCA(y) - {}", quadrant).c_str(), {HistType::kTH1F, {dcayMFTAxis}}); + dcaHistosMixedEvents[0][j][1]["DCA_y"] = registryDCA.add((histPath + "DCA_y_pos").c_str(), std::format("DCA(y) - {} charge > 0", quadrant).c_str(), {HistType::kTH1F, {dcayMFTAxis}}); + dcaHistosMixedEvents[0][j][2]["DCA_y"] = registryDCA.add((histPath + "DCA_y_neg").c_str(), std::format("DCA(y) - {} charge < 0", quadrant).c_str(), {HistType::kTH1F, {dcayMFTAxis}}); + dcaHistosMixedEvents[0][j][0]["DCA_x_vs_z"] = registryDCA.add((histPath + "DCA_x_vs_z").c_str(), std::format("DCA(x) vs. z - {}", quadrant).c_str(), {HistType::kTH2F, {dcazAxis, dcaxMFTAxis}}); + dcaHistosMixedEvents[0][j][0]["DCA_y_vs_z"] = registryDCA.add((histPath + "DCA_y_vs_z").c_str(), std::format("DCA(y) vs. z - {}", quadrant).c_str(), {HistType::kTH2F, {dcazAxis, dcayMFTAxis}}); + + histPath = std::string("Alignment/mixed-event/DCA/MCH/") + quadrant + "/"; + dcaHistosMixedEvents[1][j][0]["DCA_x"] = registryDCA.add((histPath + "DCA_x").c_str(), std::format("DCA(x) - {}", quadrant).c_str(), {HistType::kTH1F, {dcaxMCHAxis}}); + dcaHistosMixedEvents[1][j][1]["DCA_x"] = registryDCA.add((histPath + "DCA_x_pos").c_str(), std::format("DCA(x) - {} charge > 0", quadrant).c_str(), {HistType::kTH1F, {dcaxMCHAxis}}); + dcaHistosMixedEvents[1][j][2]["DCA_x"] = registryDCA.add((histPath + "DCA_x_neg").c_str(), std::format("DCA(x) - {} charge < 0", quadrant).c_str(), {HistType::kTH1F, {dcaxMCHAxis}}); + dcaHistosMixedEvents[1][j][0]["DCA_y"] = registryDCA.add((histPath + "DCA_y").c_str(), std::format("DCA(y) - {}", quadrant).c_str(), {HistType::kTH1F, {dcayMCHAxis}}); + dcaHistosMixedEvents[1][j][1]["DCA_y"] = registryDCA.add((histPath + "DCA_y_pos").c_str(), std::format("DCA(y) - {} charge > 0", quadrant).c_str(), {HistType::kTH1F, {dcayMCHAxis}}); + dcaHistosMixedEvents[1][j][2]["DCA_y"] = registryDCA.add((histPath + "DCA_y_neg").c_str(), std::format("DCA(y) - {} charge < 0", quadrant).c_str(), {HistType::kTH1F, {dcayMCHAxis}}); + } + } + + if (configQAs.fEnableQADimuon) { + // single muons + AxisSpec transverseMomentumAxis = {100, 0, 30, "p_{T} (GeV/c)"}; + AxisSpec etaAxis = {40, -5, -1, "#eta"}; + AxisSpec rAbsAxis = {10, 0., 100.0, "R_{abs} (cm)"}; + AxisSpec dcaAxis = {40, 0.0, 20.0, "DCA"}; + AxisSpec phiAxis = {36, -180.0, 180.0, "#phi (degrees)"}; + // dimuons + AxisSpec invMassAxis = {400, 1, 5, "M_{#mu^{+}#mu^{-}} (GeV/c^{2})"}; + AxisSpec invMassCorrelationAxis = {80, 0, 8, "M_{#mu^{+}#mu^{-}} (GeV/c^{2})"}; + AxisSpec invMassAxisFull = {5000, 0, 100, "M_{#mu^{+}#mu^{-}} (GeV/c^{2})"}; + AxisSpec yPairAxis = {120, 0.0, 6.0, "#y_{pair}"}; + AxisSpec invMassAxis2D = {750, 0, 15, "M_{#mu^{+}#mu^{-}} (GeV/c^{2})"}; + AxisSpec pTAxis2D = {120, 0, 30, "p_{T} (GeV/c)"}; + // Single muons - dimuons correlations + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosPt_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{+} p_{T}", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegPt_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{-} p_{T}", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, pTAxis2D}}); + // + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosEta_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{+} #eta", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, etaAxis}}); + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegEta_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{-} #eta", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, etaAxis}}); + // + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosRabs_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{+} R_{abs}", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, rAbsAxis}}); + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegRabs_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{-} R_{abs}", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, rAbsAxis}}); + // + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosDca_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{+} DCA", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, dcaAxis}}); + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegDca_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{-} DCA", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, dcaAxis}}); + // + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosPhi_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{+} #phi", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, phiAxis}}); + registryDimuon.add("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegPhi_MuonKine_MuonCuts", "#mu^{+}#mu^{-} and #mu^{-} #phi", {HistType::kTH3F, {invMassAxis2D, pTAxis2D, phiAxis}}); + // MCH-MID tracks with MCH acceptance cuts + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + // -- Mass and pT + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + // MCH-MID tracks with MCH acceptance cuts and combinations from the top and bottom halfs of MCH + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH1F, {invMassAxisFull}}); + // -- Mass and pT + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + // MCH-MID tracks with MFT acceptance cuts and combinations from the top and bottom halfs of MCH + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH1F, {invMassAxisFull}}); + // -- Mass and pT + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TPBN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} top and #mu^{-} bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TNBP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} top and #mu^{+} bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + // MCH-MID tracks with MCH acceptance cuts and combinations from the left and right halfs of MCH + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_MuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or left-right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH1F, {invMassAxisFull}}); + // -- Mass and pT + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or left-right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + // MCH-MID tracks with MFT acceptance cuts + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + // -- Mass and pT + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + // MCH-MID tracks with MFT acceptance cuts and combinations from the left and right halfs of MCH + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_RR", "#mu^{+}#mu^{-} invariant mass right-right", {HistType::kTH1F, {invMassAxisFull}}); + // -- Mass and pT + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LPRN", "#mu^{+}#mu^{-} invariant mass, #mu^{+} left and #mu^{-} right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LNRP", "#mu^{+}#mu^{-} invariant mass, #mu^{-} left and #mu^{+} right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH2F, {invMassAxis2D, pTAxis2D}}); + // Good MFT-MCH-MID tracks with MCH parameters and MFT acceptance cuts + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_GlobalMatchesCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_MuonKine_GlobalMatchesCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_MuonKine_GlobalMatchesCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMatchesCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + // Good MFT-MCH-MID tracks with global parameters MFT acceptance cuts + registryDimuon.add("dimuon/same-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + // Good MFT-MCH-MID tracks with re-scaled MFT kinematics and MFT acceptance cuts + registryDimuon.add("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_ScaledMftKine_GlobalMatchesCuts", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMassFull_ScaledMftKine_GlobalMatchesCuts", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum", {HistType::kTH1F, {invMassAxisFull}}); + // combinations of tracks from top and bottom halfs of MFT + registryDimuon.add("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_TT", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum, top-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_TB", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum, top-bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_BT", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum, bottom-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_BB", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum, bottom-bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_TT", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum, top-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_TB", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum, top-bottom", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_BT", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum, bottom-top", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_BB", "M_{#mu^{+}#mu^{-}} - rescaled MFT momentum, bottom-bottom", {HistType::kTH1F, {invMassAxis}}); + // combinations with sub-leading matches + registryDimuon.add("dimuon/same-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts_leading_subleading", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts_leading_subleading", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts_subleading_leading", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts_subleading_leading", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + registryDimuon.add("dimuon/same-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts_subleading_subleading", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxis}}); + registryDimuon.add("dimuon/same-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts_subleading_subleading", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH1F, {invMassAxisFull}}); + // invariant mass correlations + registryDimuon.add("dimuon/same-event/invariantMass_MuonKine_vs_GlobalMuonKine", "M_{#mu^{+}#mu^{-}} - muon tracks vs. global tracks", {HistType::kTH2F, {invMassCorrelationAxis, invMassCorrelationAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_ScaledMftKine_vs_GlobalMuonKine", "M_{#mu^{+}#mu^{-}} - rescaled MFT tracks vs. global tracks", {HistType::kTH2F, {invMassCorrelationAxis, invMassCorrelationAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_GlobalMuonKine_subleading_vs_leading", "M_{#mu^{+}#mu^{-}} - subleading vs. leading matches", {HistType::kTH2F, {invMassCorrelationAxis, invMassCorrelationAxis}}); + + // pseudorapidity (only for MCH acceptance cuts) + // MCH-MID tracks with MCH acceptance cuts + registryDimuon.add("dimuon/same-event/rapPair_MuonKine_MuonCuts", "#eta of dimuon pair", {HistType::kTH1F, {yPairAxis}}); + // -- Mass and eta + registryDimuon.add("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts", "#mu^{+}#mu^{-} invariant mass", {HistType::kTH2F, {invMassAxis2D, yPairAxis}}); + // -- pT and eta + registryDimuon.add("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts", "#mu^{+}#mu^{-} p_{T} and #eta", {HistType::kTH2F, {pTAxis2D, yPairAxis}}); + // MCH-MID tracks with MCH acceptance cuts and combinations from the top and bottom halfs of MCH + registryDimuon.add("dimuon/same-event/rapPair_MuonKine_MuonCuts_TT", "#eta of dimuon pair, top-top", {HistType::kTH1F, {yPairAxis}}); + registryDimuon.add("dimuon/same-event/rapPair_MuonKine_MuonCuts_TB", "#eta of dimuon pair, top-bottom or bottom-top", {HistType::kTH1F, {yPairAxis}}); + registryDimuon.add("dimuon/same-event/rapPair_MuonKine_MuonCuts_BB", "#eta of dimuon pair, bottom-bottom", {HistType::kTH1F, {yPairAxis}}); + // -- Mass and eta + registryDimuon.add("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_TT", "#mu^{+}#mu^{-} invariant mass, top-top", {HistType::kTH2F, {invMassAxis2D, yPairAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_TB", "#mu^{+}#mu^{-} invariant mass, top-bottom or bottom-top", {HistType::kTH2F, {invMassAxis2D, yPairAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_BB", "#mu^{+}#mu^{-} invariant mass, bottom-bottom", {HistType::kTH2F, {invMassAxis2D, yPairAxis}}); + // -- pT and eta + registryDimuon.add("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts_TT", "#mu^{+}#mu^{-} p_{T} and #eta, top-top", {HistType::kTH2F, {pTAxis2D, yPairAxis}}); + registryDimuon.add("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts_TB", "#mu^{+}#mu^{-} p_{T} and #eta, top-bottom or bottom-top", {HistType::kTH2F, {pTAxis2D, yPairAxis}}); + registryDimuon.add("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts_BB", "#mu^{+}#mu^{-} p_{T} and #eta, bottom-bottom", {HistType::kTH2F, {pTAxis2D, yPairAxis}}); + // MCH-MID tracks with MCH acceptance cuts and combinations from the left and right halfs of MCH + registryDimuon.add("dimuon/same-event/rapPair_MuonKine_MuonCuts_LL", "#eta of dimuon pair, left-left", {HistType::kTH1F, {yPairAxis}}); + registryDimuon.add("dimuon/same-event/rapPair_MuonKine_MuonCuts_LR", "#eta of dimuon pair, left-right or right-left", {HistType::kTH1F, {yPairAxis}}); + registryDimuon.add("dimuon/same-event/rapPair_MuonKine_MuonCuts_RR", "#eta of dimuon pair, right-right", {HistType::kTH1F, {yPairAxis}}); + // -- Mass and eta + registryDimuon.add("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_LL", "#mu^{+}#mu^{-} invariant mass, left-left", {HistType::kTH2F, {invMassAxis2D, yPairAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_LR", "#mu^{+}#mu^{-} invariant mass, left-right or right-left", {HistType::kTH2F, {invMassAxis2D, yPairAxis}}); + registryDimuon.add("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_RR", "#mu^{+}#mu^{-} invariant mass, right-right", {HistType::kTH2F, {invMassAxis2D, yPairAxis}}); + // -- pT and eta + registryDimuon.add("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts_LL", "#mu^{+}#mu^{-} p_{T} and #eta, left-left", {HistType::kTH2F, {pTAxis2D, yPairAxis}}); + registryDimuon.add("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts_LR", "#mu^{+}#mu^{-} p_{T} and #eta, left-right or right-left", {HistType::kTH2F, {pTAxis2D, yPairAxis}}); + registryDimuon.add("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts_RR", "#mu^{+}#mu^{-} p_{T} and #eta, right-right", {HistType::kTH2F, {pTAxis2D, yPairAxis}}); + } + } + + void doTransformMFT(o2::mch::TrackParam& track) + { + double zCH10 = -1437.6; + double z = track.getZ(); + // double dZ = zMCH - z; + double x = track.getNonBendingCoor(); + double y = track.getBendingCoor(); + double xSlope = track.getNonBendingSlope(); + double ySlope = track.getBendingSlope(); + + double xShiftMCH = (y > 0) ? 0.8541 : -1.5599; + double xCorrection = xShiftMCH * z / zCH10; + track.setNonBendingCoor(x + xCorrection); + double xSlopeCorrection = xShiftMCH / zCH10; + track.setNonBendingSlope(xSlope + xSlopeCorrection); + + double yShiftMCH = (y > 0) ? 3.0311 : 0.7588; + double yCorrection = yShiftMCH * z / zCH10; + track.setBendingCoor(y + yCorrection); + double ySlopeCorrection = yShiftMCH / zCH10; + track.setBendingSlope(ySlope + ySlopeCorrection); + } + + template + void TransformMFT(TTrack& track) + { + if constexpr (static_cast(GlobalFwdFillMap)) { + auto mchTrack = mMatching.FwdtoMCH(track); + doTransformMFT(mchTrack); + + auto transformedTrack = mMatching.MCHtoFwd(mchTrack); + track.setParameters(transformedTrack.getParameters()); + track.setZ(transformedTrack.getZ()); + track.setCovariances(transformedTrack.getCovariances()); + } else { + o2::dataformats::GlobalFwdTrack fwdtrack; + fwdtrack.setParameters(track.getParameters()); + fwdtrack.setZ(track.getZ()); + fwdtrack.setCovariances(track.getCovariances()); + auto mchTrack = mMatching.FwdtoMCH(fwdtrack); + doTransformMFT(mchTrack); + + auto transformedTrack = mMatching.MCHtoFwd(mchTrack); + track.setParameters(transformedTrack.getParameters()); + track.setZ(transformedTrack.getZ()); + track.setCovariances(transformedTrack.getCovariances()); + } + } + + int GetDetElemId(int iDetElemNumber) + { + // make sure detector number is valid + if (!(iDetElemNumber >= fgSNDetElemCh[0] && + iDetElemNumber < fgSNDetElemCh[10])) { + LOGF(fatal, "Invalid detector element number: %d", iDetElemNumber); + } + /// get det element number from ID + // get chamber and element number in chamber + int iCh = 0; + int iDet = 0; + for (int i = 1; i <= 10; i++) { + if (iDetElemNumber < fgSNDetElemCh[i]) { + iCh = i; + iDet = iDetElemNumber - fgSNDetElemCh[i - 1]; + break; + } + } + + // make sure detector index is valid + if (!(iCh > 0 && iCh <= 10 && iDet < fgNDetElemCh[iCh - 1])) { + LOGF(fatal, "Invalid detector element id: %d", 100 * iCh + iDet); + } + + // add number of detectors up to this chamber + return 100 * iCh + iDet; + } + + int GetQuadrantPhi(double phi) + { + if (phi >= 0 && phi < 90) { + return 0; + } + if (phi >= 90 && phi <= 180) { + return 1; + } + if (phi >= -180 && phi < -90) { + return 2; + } + if (phi >= -90 && phi < 0) { + return 3; + } + return -1; + } + + template + int GetQuadrantTrack(TTrack const& track) + { + double phi = static_cast(track.phi()) * 180 / TMath::Pi(); + return GetQuadrantPhi(phi); + } + + bool RemoveTrack(mch::Track& track) + { + // Refit track with re-aligned clusters + bool removeTrack = false; + try { + trackFitter.fit(track, false); + } catch (exception const& e) { + removeTrack = true; + return removeTrack; + } + + auto itStartingParam = std::prev(track.rend()); + + while (true) { + + try { + trackFitter.fit(track, true, false, (itStartingParam == track.rbegin()) ? nullptr : &itStartingParam); + } catch (exception const&) { + removeTrack = true; + break; + } + + double worstLocalChi2 = -1.0; + + track.tagRemovableClusters(0x1F, false); + + auto itWorstParam = track.end(); + + for (auto itParam = track.begin(); itParam != track.end(); ++itParam) { + if (itParam->getLocalChi2() > worstLocalChi2) { + worstLocalChi2 = itParam->getLocalChi2(); + itWorstParam = itParam; + } + } + + if (worstLocalChi2 < mImproveCutChi2) { + break; + } + + if (!itWorstParam->isRemovable()) { + removeTrack = true; + track.removable(); + break; + } + + auto itNextParam = track.removeParamAtCluster(itWorstParam); + auto itNextToNextParam = (itNextParam == track.end()) ? itNextParam : std::next(itNextParam); + itStartingParam = track.rbegin(); + + if (track.getNClusters() < 10) { + removeTrack = true; + break; + } else { + while (itNextToNextParam != track.end()) { + if (itNextToNextParam->getClusterPtr()->getChamberId() != itNextParam->getClusterPtr()->getChamberId()) { + itStartingParam = std::make_reverse_iterator(++itNextParam); + break; + } + ++itNextToNextParam; + } + } + } + + if (!removeTrack) { + for (auto& param : track) { + param.setParameters(param.getSmoothParameters()); + param.setCovariances(param.getSmoothCovariances()); + } + } + + return removeTrack; + } + + template + bool pDCACut(Var const& fgValues, Var const& fgValuesPV, double nSigmaPDCA) + { + static const double sigmaPDCA23 = 80.; + static const double sigmaPDCA310 = 54.; + static const double relPRes = 0.0004; + static const double slopeRes = 0.0005; + + double thetaAbs = TMath::ATan(fgValues.rabs / 505.) * TMath::RadToDeg(); + double p = fgValuesPV.p; + + double pDCA = fgValues.pDca; + double sigmaPDCA = (thetaAbs < 3) ? sigmaPDCA23 : sigmaPDCA310; + double nrp = nSigmaPDCA * relPRes * p; + double pResEffect = sigmaPDCA / (1. - nrp / (1. + nrp)); + double slopeResEffect = 535. * slopeRes * p; + double sigmaPDCAWithRes = TMath::Sqrt(pResEffect * pResEffect + slopeResEffect * slopeResEffect); + + if (pDCA > nSigmaPDCA * sigmaPDCAWithRes) { + return false; + } + + return true; + } + + template + bool IsMixedEvent(Var const& fgValues1, Var const& fgValues2) + { + if (fgValues1.bc == fgValues2.bc) { + return false; + } + + uint64_t bcDiff = (fgValues2.bc > fgValues1.bc) ? (fgValues2.bc - fgValues1.bc) : (fgValues1.bc - fgValues2.bc); + // in the event mixing case, we require a minimum BC gap between the collisions + if (bcDiff < configMixing.fEventMinDeltaBc) + return false; + + // we also require that the collisions have similar Z positions and multiplicity of MFT tracks + if (std::fabs(fgValues2.z - fgValues1.z) > configMixing.fEventMaxDeltaVtxZ) { + return false; + } + + if (std::abs(fgValues2.multMFT - fgValues1.multMFT) > configMixing.fEventMaxDeltaNMFT) { + return false; + } + + return true; + } + + template + bool IsGoodMuon(Var const& fgValues, Var const& fgValuesPV, float fTrackChi2MchUp, float fPMchLow, float fPtMchLow, float fEtaMchLow, float fEtaMchUp, float fRabsLow, float fRabsUp, float fSigmaPdcaUp) + { + // chi2 cut + if (fgValues.chi2 > fTrackChi2MchUp) + return false; + + // momentum cut + if (fgValues.p < fPMchLow) { + return false; // skip low-momentum tracks + } + + // transverse momentum cut + if (fgValues.pT < fPtMchLow) { + return false; // skip low-momentum tracks + } + + // Eta cut + if ((fgValues.eta < fEtaMchLow || fgValues.eta > fEtaMchUp)) { + return false; + } + + // RAbs cut + if ((fgValues.rabs < fRabsLow || fgValues.rabs > fRabsUp)) { + return false; + } + + // pDCA cut + if (!pDCACut(fgValues, fgValuesPV, fSigmaPdcaUp)) { + return false; + } + + return true; + } + + template + bool IsGoodMuon(Var const& fgValues, Var const& fgValuesPV) + { + return IsGoodMuon(fgValues, fgValuesPV, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMuons.fEtaMchLow, configMuons.fEtaMchUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp); + } + + template + bool IsGoodGlobalMuon(Var const& fgValues, Var const& fgValuesPV) + { + return IsGoodMuon(fgValues, fgValuesPV, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp); + } + + template + bool IsGoodMFT(Var const& fgValues, float fTrackChi2MftUp, int fTrackNClustMftLow) + { + // chi2 cut + if (fgValues.chi2 > fTrackChi2MftUp) { + return false; + } + + // number of clusters cut + if (fgValues.nClusters < fTrackNClustMftLow) { + return false; + } + + return true; + } + + template + bool IsGoodGlobalMatching(Var const& fgValues, float fTrackChi2MftUp, int fTrackNClustMftLow, float fMatchingChi2MftMchUp) + { + if (!IsGoodMFT(fgValues, fTrackChi2MftUp, fTrackNClustMftLow)) { + return false; + } + + if (fgValues.chi2matching > fMatchingChi2MftMchUp) { + return false; + } + + return true; + } + + template + bool IsGoodGlobalMatching(Var const& fgValues) + { + return IsGoodGlobalMatching(fgValues, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow, fMatchingChi2MftMchUp); + } + + template + double GetMuMuInvariantMass(VarT const& track1, VarT const& track2) + { + ROOT::Math::PxPyPzMVector muon1{ + track1.px, + track1.py, + track1.pz, + o2::constants::physics::MassMuon}; + + ROOT::Math::PxPyPzMVector muon2{ + track2.px, + track2.py, + track2.pz, + o2::constants::physics::MassMuon}; + + auto dimuon = muon1 + muon2; + + return dimuon.M(); + } + + template + double GetMuMuPt(VarT const& track1, VarT const& track2) + { + ROOT::Math::PxPyPzMVector muon1{ + track1.px, + track1.py, + track1.pz, + o2::constants::physics::MassMuon}; + + ROOT::Math::PxPyPzMVector muon2{ + track2.px, + track2.py, + track2.pz, + o2::constants::physics::MassMuon}; + + auto dimuon = muon1 + muon2; + + return dimuon.Pt(); + } + + template + double GetMuMuRap(VarT const& track1, VarT const& track2) + { + ROOT::Math::PxPyPzMVector muon1{ + track1.px, + track1.py, + track1.pz, + o2::constants::physics::MassMuon}; + + ROOT::Math::PxPyPzMVector muon2{ + track2.px, + track2.py, + track2.pz, + o2::constants::physics::MassMuon}; + + auto dimuon = muon1 + muon2; + + return dimuon.Y(); + } + + template + void GetMuonPairs(TMuons const& muons, TCandidates const& matchingCandidates, const std::map& collisionInfos, + std::vector& muonPairs, + std::vector& globalMuonPairs) + { + // muon tracks - outer loop over collisions + for (auto& [collisionIndex1, collisionInfo1] : collisionInfos) { + + // outer loop over muon tracks + auto muonCollision1 = muons.sliceBy(fwdtracksPerCollision, collisionInfo1.globalIndex); + for (auto muon1 : muonCollision1) { + + if (muon1.trackType() <= 2) { + continue; + } + auto mchIndex1 = muon1.globalIndex(); + + // inner loop over collisions + for (auto& [collisionIndex2, collisionInfo2] : collisionInfos) { + // avoid double-counting of collisions + if (collisionIndex2 < collisionIndex1) + continue; + + bool sameEvent = (collisionIndex1 == collisionIndex2); + bool mixedEvent = IsMixedEvent(collisionInfo1, collisionInfo2); + + if (!sameEvent && !mixedEvent) + continue; + + // inner loop over muon tracks + auto muonCollision2 = muons.sliceBy(fwdtracksPerCollision, collisionInfo2.globalIndex); + for (auto muon2 : muonCollision2) { + if (muon2.trackType() <= 2) { + continue; + } + auto mchIndex2 = muon2.globalIndex(); + + // avoid double-counting of muon pairs if we are not mixing events + if (sameEvent && mchIndex2 <= mchIndex1) + continue; + + MuonPair muonPair{{collisionIndex1, mchIndex1}, {collisionIndex2, mchIndex2}}; + muonPairs.emplace_back(muonPair); + } + } + } + } + + // global muon tracks - outer loop over collisions + for (auto& [collisionIndex1, collisionInfo1] : collisionInfos) { + + // outer loop over global muon tracks + auto muonCollision1 = muons.sliceBy(fwdtracksPerCollision, collisionInfo1.globalIndex); + for (auto muon1 : muonCollision1) { + + if (muon1.trackType() <= 2) { + continue; + } + auto mchIndex1 = muon1.globalIndex(); + auto matchingCandidateIt1 = matchingCandidates.find(mchIndex1); + if (matchingCandidateIt1 == matchingCandidates.end()) { + continue; + } + + // inner loop over collisions + for (auto& [collisionIndex2, collisionInfo2] : collisionInfos) { + // avoid double-counting of collisions + if (collisionIndex2 < collisionIndex1) + continue; + + bool sameEvent = (collisionIndex1 == collisionIndex2); + bool mixedEvent = IsMixedEvent(collisionInfo1, collisionInfo2); + + if (!sameEvent && !mixedEvent) + continue; + + // outer loop over global muon tracks + auto muonCollision2 = muons.sliceBy(fwdtracksPerCollision, collisionInfo2.globalIndex); + for (auto muon2 : muonCollision2) { + + if (muon2.trackType() <= 2) { + continue; + } + auto mchIndex2 = muon2.globalIndex(); + auto matchingCandidateIt2 = matchingCandidates.find(mchIndex2); + if (matchingCandidateIt2 == matchingCandidates.end()) { + continue; + } + + // avoid double-counting of muon pairs if we are not mixing events + if (sameEvent && mchIndex2 <= mchIndex1) + continue; + + GlobalMuonPair muonPair{{collisionIndex1, matchingCandidateIt1->second}, {collisionIndex2, matchingCandidateIt2->second}}; + globalMuonPairs.emplace_back(muonPair); + } + } + } + } + } + + template + void FillCollision(TEvent const& collision, Var& fgValues) + { + fgValues.globalIndex = collision.globalIndex(); + fgValues.x = collision.posX(); + fgValues.y = collision.posY(); + fgValues.z = collision.posZ(); + fgValues.covXX = collision.covXX(); + fgValues.covYY = collision.covYY(); + } + + template + void FillTrack(mch::Track const& muon, Var& fgValues) + { + mch::TrackParam trackParam = mch::TrackParam(muon.first()); + auto proptrack = mMatching.MCHtoFwd(trackParam); + + fgValues.pT = proptrack.getPt(); + fgValues.x = proptrack.getX(); + fgValues.y = proptrack.getY(); + fgValues.z = proptrack.getZ(); + fgValues.eta = proptrack.getEta(); + fgValues.tgl = proptrack.getTgl(); + fgValues.phi = proptrack.getPhi(); + + fgValues.p = proptrack.getP(); + fgValues.px = proptrack.getPx(); + fgValues.py = proptrack.getPy(); + fgValues.pz = proptrack.getPz(); + + fgValues.chi2 = trackParam.getTrackChi2(); + fgValues.nClusters = muon.getNClusters(); + fgValues.sign = trackParam.getCharge(); + } + + template + void FillTrack(TTrack const& muon, Var& fgValues) + { + fgValues.collisionId = muon.collisionId(); + fgValues.globalIndex = muon.globalIndex(); + fgValues.trackTime = muon.trackTime(); + + fgValues.pT = muon.pt(); + fgValues.x = muon.x(); + fgValues.y = muon.y(); + fgValues.z = muon.z(); + fgValues.eta = muon.eta(); + fgValues.tgl = muon.tgl(); + fgValues.phi = muon.phi(); + + fgValues.p = muon.p(); + fgValues.px = muon.px(); + fgValues.py = muon.py(); + fgValues.pz = muon.pz(); + + fgValues.chi2 = muon.chi2(); + fgValues.nClusters = muon.nClusters(); + fgValues.sign = muon.sign(); + + if constexpr (static_cast(MuonFillMap)) { + // Direct info from AO2D without re-propagation + fgValues.pDca = muon.pDca(); + fgValues.rabs = muon.rAtAbsorberEnd(); + fgValues.trackType = muon.trackType(); + } + } + + template + bool FillClusters(TMCHTrack const& muon, TFwdCls const& mchcls, Var& fgValues, mch::Track& convertedTrack) + { + int removable = 0; + auto clustersSliced = mchcls.sliceBy(perMuon, muon.globalIndex()); // Slice clusters by muon id + vector> posClusters; + + int clIndex = -1; + // Get re-aligned clusters associated to current track + for (auto const& cluster : clustersSliced) { + clIndex += 1; + + math_utils::Point3D local; + math_utils::Point3D master; + + mch::Cluster* clusterMCH = new mch::Cluster(); + master.SetXYZ(cluster.x(), cluster.y(), cluster.z()); + + if (configRealign.fDoRealign) { + // Transformation from reference geometry frame to new geometry frame + transformRef[cluster.deId()].MasterToLocal(master, local); + transformNew[cluster.deId()].LocalToMaster(local, master); + } + + clusterMCH->x = master.x(); + clusterMCH->y = master.y(); + clusterMCH->z = master.z(); + + uint32_t ClUId = mch::Cluster::buildUniqueId(static_cast(cluster.deId() / 100) - 1, cluster.deId(), clIndex); + clusterMCH->uid = ClUId; + clusterMCH->ex = cluster.isGoodX() ? 0.2 : 10.0; + clusterMCH->ey = cluster.isGoodY() ? 0.2 : 10.0; + + // Fill temporary values + vector posCls = {clusterMCH->x, clusterMCH->y, clusterMCH->z}; + vector eCls = {clusterMCH->ex, clusterMCH->ey}; + posClusters.emplace_back(posCls); + fgValues.errorClusters.emplace_back(eCls); + fgValues.DEIDs.emplace_back(cluster.deId()); + + // Add transformed cluster into temporary variable + convertedTrack.createParamAtCluster(*clusterMCH); + } + + if (configRealign.fDoRealign) { + // Refit the re-aligned track + if (convertedTrack.getNClusters() != 0) { + removable = RemoveTrack(convertedTrack); + } else { + LOGF(fatal, "Muon track %d has no associated clusters.", muon.globalIndex()); + } + + for (auto it = convertedTrack.begin(); it != convertedTrack.end(); it++) { + vector pos = {static_cast(it->getNonBendingCoor()), static_cast(it->getBendingCoor()), static_cast(it->getZ())}; + fgValues.posClusters.emplace_back(pos); + } + + } else { + fgValues.posClusters = posClusters; + } + + return !removable; + } + + template + void FillMatchingCandidates(TMuon const& muon, TMCH const& mchtrack, TMap& matchingCandidates) + { + uint64_t muonId = muon.globalIndex(); + uint64_t mchId = mchtrack.globalIndex(); + + //// Save matching candidates index pairs + auto matchingCandidateIt = matchingCandidates.find(mchId); + if (matchingCandidateIt != matchingCandidates.end()) { + matchingCandidateIt->second.push_back(muonId); + } else { + matchingCandidates[mchId].push_back(muonId); + } + } + + template + void FillPropagation(mch::Track const& muon, VarC const& collision, VarT& fgValues, int endPoint = kToVtx, int endZ = 0) + { + o2::dataformats::GlobalFwdTrack propmuon; + mch::TrackParam trackParam = mch::TrackParam(muon.first()); + fgValues.chi2 = trackParam.getTrackChi2(); + fgValues.nClusters = muon.getNClusters(); + fgValues.sign = trackParam.getCharge(); + + if (endPoint == kToVtx) { + o2::mch::TrackExtrap::extrapToVertex(trackParam, collision.x, collision.y, collision.z, collision.covXX, collision.covYY); + } + if (endPoint == kToDCA) { + o2::mch::TrackExtrap::extrapToVertexWithoutBranson(trackParam, collision.z); + } + if (endPoint == kToAbsEnd) { + o2::mch::TrackExtrap::extrapToZ(trackParam, zAtAbsEnd); + } + if (endPoint == kToZ) { + o2::mch::TrackExtrap::extrapToZ(trackParam, endZ); + } + + auto proptrack = mMatching.MCHtoFwd(trackParam); + propmuon.setParameters(proptrack.getParameters()); + propmuon.setZ(proptrack.getZ()); + propmuon.setCovariances(proptrack.getCovariances()); + + //// Fill propagation informations + if (endPoint == kToVtx || endPoint == kToZ) { + fgValues.pT = propmuon.getPt(); + fgValues.x = propmuon.getX(); + fgValues.y = propmuon.getY(); + fgValues.z = propmuon.getZ(); + fgValues.eta = propmuon.getEta(); + fgValues.tgl = propmuon.getTgl(); + fgValues.phi = propmuon.getPhi(); + + fgValues.p = propmuon.getP(); + fgValues.px = propmuon.getP() * sin(M_PI / 2 - atan(propmuon.getTgl())) * cos(propmuon.getPhi()); + fgValues.py = propmuon.getP() * sin(M_PI / 2 - atan(propmuon.getTgl())) * sin(propmuon.getPhi()); + fgValues.pz = propmuon.getP() * cos(M_PI / 2 - atan(propmuon.getTgl())); + } + + if (endPoint == kToDCA) { + fgValues.dcaX = (propmuon.getX() - collision.x); + fgValues.dcaY = (propmuon.getY() - collision.y); + float dcaXY = std::sqrt(fgValues.dcaX * fgValues.dcaX + fgValues.dcaY * fgValues.dcaY); + + mch::TrackParam trackParam = mch::TrackParam(muon.first()); + float p = trackParam.p(); + fgValues.pDca = p * dcaXY; + } + + if (endPoint == kToAbsEnd) { + double xAbs = propmuon.getX(); + double yAbs = propmuon.getY(); + fgValues.rabs = std::sqrt(xAbs * xAbs + yAbs * yAbs); + } + } + + template + void FillPropagation(TTrack const& muon, VarC const& collision, VarT const& fgValuesMCH, VarT& fgValues, int endPoint = kToVtx, int endZ = 0) + { + o2::dataformats::GlobalFwdTrack propmuon; + double chi2 = muon.chi2(); + fgValues.chi2 = chi2; + fgValues.nClusters = muon.nClusters(); + fgValues.sign = muon.sign(); + + if constexpr (static_cast(MuonFillMap)) { + o2::dataformats::GlobalFwdTrack track; + + SMatrix5 tpars(muon.x(), muon.y(), muon.phi(), muon.tgl(), muon.signed1Pt()); + std::vector v1{muon.cXX(), muon.cXY(), muon.cYY(), muon.cPhiX(), muon.cPhiY(), + muon.cPhiPhi(), muon.cTglX(), muon.cTglY(), muon.cTglPhi(), muon.cTglTgl(), + muon.c1PtX(), muon.c1PtY(), muon.c1PtPhi(), muon.c1PtTgl(), muon.c1Pt21Pt2()}; + SMatrix55 tcovs(v1.begin(), v1.end()); + o2::track::TrackParCovFwd fwdtrack{muon.z(), tpars, tcovs, chi2}; + + track.setParameters(tpars); + track.setZ(fwdtrack.getZ()); + track.setCovariances(tcovs); + auto mchTrack = mMatching.FwdtoMCH(track); + + if (endPoint == kToVtx) { + o2::mch::TrackExtrap::extrapToVertex(mchTrack, collision.x, collision.y, collision.z, collision.covXX, collision.covYY); + } + if (endPoint == kToDCA) { + o2::mch::TrackExtrap::extrapToVertexWithoutBranson(mchTrack, collision.z); + } + if (endPoint == kToAbsEnd) { + o2::mch::TrackExtrap::extrapToZ(mchTrack, zAtAbsEnd); + } + if (endPoint == kToZ) { + o2::mch::TrackExtrap::extrapToZ(mchTrack, endZ); + } + + auto proptrack = mMatching.MCHtoFwd(mchTrack); + propmuon.setParameters(proptrack.getParameters()); + propmuon.setZ(proptrack.getZ()); + propmuon.setCovariances(proptrack.getCovariances()); + + } else { + + o2::dataformats::GlobalFwdTrack track; + + if constexpr (static_cast(Scaled)) { + double pMCH = fgValuesMCH.p; + int sign = fgValuesMCH.sign; + + double px = pMCH * sin(M_PI / 2 - atan(muon.tgl())) * cos(muon.phi()); + double py = pMCH * sin(M_PI / 2 - atan(muon.tgl())) * sin(muon.phi()); + // double pz = pMCH * cos(M_PI / 2 - atan(mft.tgl())); + double pt = std::sqrt(std::pow(px, 2) + std::pow(py, 2)); + + double chi2 = muon.chi2(); + double signed1Pt = endPoint == kToDCA ? muon.signed1Pt() : sign / pt; + SMatrix5 tpars(muon.x(), muon.y(), muon.phi(), muon.tgl(), signed1Pt); + std::vector v1{0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0}; + SMatrix55 tcovs(v1.begin(), v1.end()); + o2::track::TrackParCovFwd fwdtrack{muon.z(), tpars, tcovs, chi2}; + track.setParameters(tpars); + track.setZ(fwdtrack.getZ()); + track.setCovariances(tcovs); + } else { + SMatrix5 tpars(muon.x(), muon.y(), muon.phi(), muon.tgl(), muon.signed1Pt()); + std::vector v1{muon.cXX(), muon.cXY(), muon.cYY(), muon.cPhiX(), muon.cPhiY(), + muon.cPhiPhi(), muon.cTglX(), muon.cTglY(), muon.cTglPhi(), muon.cTglTgl(), + muon.c1PtX(), muon.c1PtY(), muon.c1PtPhi(), muon.c1PtTgl(), muon.c1Pt21Pt2()}; + SMatrix55 tcovs(v1.begin(), v1.end()); + o2::track::TrackParCovFwd fwdtrack{muon.z(), tpars, tcovs, chi2}; + track.setParameters(tpars); + track.setZ(fwdtrack.getZ()); + track.setCovariances(tcovs); + } + + if (endPoint == kToVtx) { + if (fEnableMFTAlignmentCorrections) { + TransformMFT<0>(track); + } + auto geoMan = o2::base::GeometryManager::meanMaterialBudget(muon.x(), muon.y(), muon.z(), collision.x, collision.y, collision.z); + auto x2x0 = static_cast(geoMan.meanX2X0); + track.propagateToVtxhelixWithMCS(collision.z, {collision.x, collision.y}, {collision.covXX, collision.covYY}, Bz, x2x0); + } + if (endPoint == kToDCA) { + if (fEnableMFTAlignmentCorrections) { + TransformMFT<0>(track); + } + track.propagateToZ(collision.z, Bz); + } + if (endPoint == kToZ) { + auto mchTrackExt = mMatching.FwdtoMCH(track); + if (fEnableMFTAlignmentCorrections) { + doTransformMFT(mchTrackExt); + } + o2::mch::TrackExtrap::extrapToZ(mchTrackExt, endZ); + track = mMatching.MCHtoFwd(mchTrackExt); + } + + propmuon.setParameters(track.getParameters()); + propmuon.setZ(track.getZ()); + propmuon.setCovariances(track.getCovariances()); + } + + //// Fill propagation informations + if (endPoint == kToVtx || endPoint == kToZ) { + fgValues.pT = propmuon.getPt(); + fgValues.x = propmuon.getX(); + fgValues.y = propmuon.getY(); + fgValues.z = propmuon.getZ(); + fgValues.eta = propmuon.getEta(); + fgValues.tgl = propmuon.getTgl(); + fgValues.phi = propmuon.getPhi(); + + fgValues.p = propmuon.getP(); + fgValues.px = propmuon.getP() * sin(M_PI / 2 - atan(propmuon.getTgl())) * cos(propmuon.getPhi()); + fgValues.py = propmuon.getP() * sin(M_PI / 2 - atan(propmuon.getTgl())) * sin(propmuon.getPhi()); + fgValues.pz = propmuon.getP() * cos(M_PI / 2 - atan(propmuon.getTgl())); + } + + if (endPoint == kToDCA) { + fgValues.dcaX = (propmuon.getX() - collision.x); + fgValues.dcaY = (propmuon.getY() - collision.y); + float dcaXY = std::sqrt(fgValues.dcaX * fgValues.dcaX + fgValues.dcaY * fgValues.dcaY); + + if constexpr (static_cast(MuonFillMap)) { + float p = muon.p(); + fgValues.pDca = p * dcaXY; + } + } + + if (endPoint == kToAbsEnd) { + double xAbs = propmuon.getX(); + double yAbs = propmuon.getY(); + fgValues.rabs = std::sqrt(xAbs * xAbs + yAbs * yAbs); + } + } + + template + void FillMatching(TTrack const& track, Var& fgValuesMCH, Var& fgValuesMFT) + { + fgValuesMCH.chi2matching = track.chi2MatchMCHMID(); + fgValuesMFT.chi2matching = track.chi2MatchMCHMFT(); + } + + template + void FillMuonHistograms(Var const& fgValuesMCH, Var const& fgValuesMCHpv, Var const& fgValuesMFT, Var const& fgValuesGlobal, VarVector const& fgValuesCandidates) + { + if constexpr (static_cast(MuonFillMap)) { + // Muon histograms + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, 1.E10, configMuons.fPMchLow, configMuons.fPtMchLow, configMuons.fEtaMchLow, configMuons.fEtaMchUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("muons/TrackChi2"))->Fill(fgValuesMCH.chi2); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, 0., configMuons.fPtMchLow, configMuons.fEtaMchLow, configMuons.fEtaMchUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("muons/TrackP"))->Fill(fgValuesMCH.p); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, 0., configMuons.fEtaMchLow, configMuons.fEtaMchUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("muons/TrackPt"))->Fill(fgValuesMCH.pT); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, -1.E10, 1.E10, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("muons/TrackEta"))->Fill(fgValuesMCH.eta); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMuons.fEtaMchLow, configMuons.fEtaMchUp, 0., 1.E10, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("muons/TrackRabs"))->Fill(fgValuesMCH.rabs); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMuons.fEtaMchLow, configMuons.fEtaMchUp, configMuons.fRabsLow, configMuons.fRabsUp, 1.E10)) { + registry.get(HIST("muons/TrackPDCA"))->Fill(fgValuesMCH.pDca); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMuons.fEtaMchLow, configMuons.fEtaMchUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("muons/TrackPhi"))->Fill(fgValuesMCH.phi * 180.0 / TMath::Pi()); + registry.get(HIST("muons/TrackDCA"))->Fill(std::sqrt(fgValuesMCH.dcaX * fgValuesMCH.dcaX + fgValuesMCH.dcaY * fgValuesMCH.dcaY)); + } + + // muon origin for MCH top-bottom and left-right parts + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, -1.E10, 1.E10, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + int Quadrant = GetQuadrantPhi(fgValuesMCH.phi * 180.0 / TMath::Pi()); + int TopBottom = (Quadrant == 0 || Quadrant == 1) ? 0 : 1; + int LeftRight = (Quadrant == 0 || Quadrant == 3) ? 0 : 1; + int PosNeg = fgValuesMCH.sign > 0 ? 0 : 1; + float eta = fgValuesMCH.eta; + float pT = fgValuesMCH.pT; + + // same-event case + if (PosNeg == 0) { + registry.get(HIST("muons/TrackEtaPos"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaPos"))->Fill(pT, eta); + + if (TopBottom == 0) { + registry.get(HIST("muons/TrackEtaPos_T"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaPos_T"))->Fill(pT, eta); + } else if (TopBottom == 1) { + registry.get(HIST("muons/TrackEtaPos_B"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaPos_B"))->Fill(pT, eta); + } + + if (LeftRight == 0) { + registry.get(HIST("muons/TrackEtaPos_L"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaPos_L"))->Fill(pT, eta); + } else if (LeftRight == 1) { + registry.get(HIST("muons/TrackEtaPos_R"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaPos_R"))->Fill(pT, eta); + } + } else if (PosNeg == 1) { + registry.get(HIST("muons/TrackEtaNeg"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaNeg"))->Fill(pT, eta); + if (TopBottom == 0) { + registry.get(HIST("muons/TrackEtaNeg_T"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaNeg_T"))->Fill(pT, eta); + } else if (TopBottom == 1) { + registry.get(HIST("muons/TrackEtaNeg_B"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaNeg_B"))->Fill(pT, eta); + } + + if (LeftRight == 0) { + registry.get(HIST("muons/TrackEtaNeg_L"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaNeg_L"))->Fill(pT, eta); + } else if (LeftRight == 1) { + registry.get(HIST("muons/TrackEtaNeg_R"))->Fill(eta); + registry.get(HIST("muons/TrackPt_TrackEtaNeg_R"))->Fill(pT, eta); + } + } + } + } + + if constexpr (static_cast(GlobalMuonFillMap)) { + // Global muon histograms + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, 1.E10, configMuons.fPMchLow, configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("global-muons/TrackChi2"))->Fill(fgValuesMCH.chi2); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, 0., configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("global-muons/TrackP"))->Fill(fgValuesMCH.p); + + // Momentum correlations + registry.get(HIST("global-muons/MomentumCorrelation_Global_vs_Muon"))->Fill(fgValuesMCH.p, fgValuesGlobal.p); + if (fgValuesMCH.p != 0) { + registry.get(HIST("global-muons/MomentumDifference_Global_vs_Muon"))->Fill(fgValuesMCH.p, (fgValuesGlobal.p - fgValuesMCH.p) / fgValuesMCH.p); + } + + if (fgValuesCandidates.size() >= 2) { + registry.get(HIST("global-muons/MomentumCorrelation_subleading_vs_leading"))->Fill(fgValuesCandidates[0].p, fgValuesCandidates[1].p); + if (fgValuesCandidates[0].p != 0) { + registry.get(HIST("global-muons/MomentumDifference_subleading_vs_leading"))->Fill(fgValuesCandidates[0].p, (fgValuesCandidates[1].p - fgValuesCandidates[0].p) / fgValuesCandidates[0].p); + } + } + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, 0., configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("global-muons/TrackPt"))->Fill(fgValuesMCH.pT); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, -1.E10, 1.E10, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("global-muons/TrackEta"))->Fill(fgValuesMCH.eta); + + // Eta correlations + registry.get(HIST("global-muons/EtaCorrelation_Global_vs_Muon"))->Fill(fgValuesMCH.eta, fgValuesGlobal.eta); + if (fgValuesMCH.eta != 0) { + registry.get(HIST("global-muons/EtaDifference_Global_vs_Muon"))->Fill(fgValuesMCH.eta, (fgValuesGlobal.eta - fgValuesMCH.eta) / fgValuesMCH.eta); + } + + if (fgValuesCandidates.size() >= 2) { + registry.get(HIST("global-muons/EtaCorrelation_subleading_vs_leading"))->Fill(fgValuesCandidates[0].eta, fgValuesCandidates[1].eta); + if (fgValuesCandidates[0].eta != 0) { + registry.get(HIST("global-muons/EtaDifference_subleading_vs_leading"))->Fill(fgValuesCandidates[0].eta, (fgValuesCandidates[1].eta - fgValuesCandidates[0].eta) / fgValuesCandidates[0].eta); + } + } + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, 0., 1.E10, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("global-muons/TrackRabs"))->Fill(fgValuesMCH.rabs); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, 1.E10)) { + registry.get(HIST("global-muons/TrackPDCA"))->Fill(fgValuesMCH.pDca); + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + registry.get(HIST("global-muons/TrackPhi"))->Fill(fgValuesMCH.phi * 180.0 / TMath::Pi()); + registry.get(HIST("global-muons/TrackDCA"))->Fill(std::sqrt(fgValuesMCH.dcaX * fgValuesMCH.dcaX + fgValuesMCH.dcaY * fgValuesMCH.dcaY)); + } + } + + if constexpr (static_cast(GlobalMatchingFillMap)) { + // Global muon histograms + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, 1.E10, configMuons.fPMchLow, configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + if (IsGoodGlobalMatching(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow, fMatchingChi2MftMchUp)) { + registry.get(HIST("global-matches/TrackChi2"))->Fill(fgValuesMCH.chi2); + } + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, 0., configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + if (IsGoodGlobalMatching(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow, fMatchingChi2MftMchUp)) { + registry.get(HIST("global-matches/TrackP"))->Fill(fgValuesMCH.p); + } + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, 0., configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + if (IsGoodGlobalMatching(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow, fMatchingChi2MftMchUp)) { + registry.get(HIST("global-matches/TrackPt"))->Fill(fgValuesMCH.pT); + } + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, -1.E10, 1.E10, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + if (IsGoodGlobalMatching(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow, fMatchingChi2MftMchUp)) { + registry.get(HIST("global-matches/TrackEta"))->Fill(fgValuesMCH.eta); + } + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, 0., 1.E10, configMuons.fSigmaPdcaUp)) { + if (IsGoodGlobalMatching(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow, fMatchingChi2MftMchUp)) { + registry.get(HIST("global-matches/TrackRabs"))->Fill(fgValuesMCH.rabs); + } + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, 1.E10)) { + if (IsGoodGlobalMatching(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow, fMatchingChi2MftMchUp)) { + registry.get(HIST("global-matches/TrackPDCA"))->Fill(fgValuesMCH.pDca); + } + } + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, configMuons.fPMchLow, configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + if (IsGoodGlobalMatching(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow, fMatchingChi2MftMchUp)) { + registry.get(HIST("global-matches/TrackPhi"))->Fill(fgValuesMCH.phi * 180.0 / TMath::Pi()); + registry.get(HIST("global-matches/TrackDCA"))->Fill(std::sqrt(fgValuesMCH.dcaX * fgValuesMCH.dcaX + fgValuesMCH.dcaY * fgValuesMCH.dcaY)); + + registry.get(HIST("global-matches/TrackP_glo"))->Fill(fgValuesGlobal.p); + registry.get(HIST("global-matches/TrackPt_glo"))->Fill(fgValuesGlobal.pT); + registry.get(HIST("global-matches/TrackEta_glo"))->Fill(fgValuesGlobal.eta); + registry.get(HIST("global-matches/TrackPhi_glo"))->Fill(fgValuesGlobal.phi * 180.0 / TMath::Pi()); + registry.get(HIST("global-matches/TrackDCA_glo"))->Fill(std::sqrt(fgValuesGlobal.dcaX * fgValuesGlobal.dcaX + fgValuesGlobal.dcaY * fgValuesGlobal.dcaY)); + } + if (IsGoodGlobalMatching(fgValuesMFT, 1.E10, configMFTs.fTrackNClustMftLow, fMatchingChi2MftMchUp)) { + registry.get(HIST("global-matches/TrackChi2_MFT"))->Fill(fgValuesMFT.chi2); + } + if (IsGoodGlobalMatching(fgValuesMFT, configMFTs.fTrackChi2MftUp, 0, fMatchingChi2MftMchUp)) { + registry.get(HIST("global-matches/TrackNclusters_MFT"))->Fill(fgValuesMFT.nClusters); + } + if (IsGoodGlobalMatching(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow, 1.E10)) { + registry.get(HIST("global-matches/MatchChi2"))->Fill(fgValuesMFT.chi2matching); + } + } + } + } + + template + void FillTrackResidualHistograms(VarVector const& fgVectorsMCH, VarVector const& fgVectorsMFT, int quadrant, bool same, bool mixed) + { + std::vector> xPos; + std::vector> yPos; + std::vector> thetax; + std::vector> thetay; + for (int zi = 0; zi < static_cast(zRefPlane.size()); zi++) { + xPos.emplace_back(std::array{fgVectorsMCH[zi].x, fgVectorsMFT[zi].x}); + yPos.emplace_back(std::array{fgVectorsMCH[zi].y, fgVectorsMFT[zi].y}); + thetax.emplace_back(std::array{ + std::atan2(fgVectorsMCH[zi].px, -1.0 * fgVectorsMCH[zi].pz) * 180 / TMath::Pi(), + std::atan2(fgVectorsMFT[zi].px, -1.0 * fgVectorsMFT[zi].pz) * 180 / TMath::Pi()}); + thetay.emplace_back(std::array{ + std::atan2(fgVectorsMCH[zi].py, -1.0 * fgVectorsMCH[zi].pz) * 180 / TMath::Pi(), + std::atan2(fgVectorsMFT[zi].py, -1.0 * fgVectorsMFT[zi].pz) * 180 / TMath::Pi()}); + } + + for (int i = 0; i < static_cast(zRefPlane.size()); i++) { + if (same) { + std::get>(trackResidualsHistos[i][quadrant]["dx_vs_x"])->Fill(std::fabs(xPos[i][1]), xPos[i][0] - xPos[i][1]); + std::get>(trackResidualsHistos[i][quadrant]["dx_vs_y"])->Fill(std::fabs(yPos[i][1]), xPos[i][0] - xPos[i][1]); + std::get>(trackResidualsHistos[i][quadrant]["dy_vs_x"])->Fill(std::fabs(xPos[i][1]), yPos[i][0] - yPos[i][1]); + std::get>(trackResidualsHistos[i][quadrant]["dy_vs_y"])->Fill(std::fabs(yPos[i][1]), yPos[i][0] - yPos[i][1]); + + std::get>(trackResidualsHistos[i][quadrant]["dthetax_vs_x"])->Fill(std::fabs(xPos[i][1]), thetax[i][0] - thetax[i][1]); + std::get>(trackResidualsHistos[i][quadrant]["dthetax_vs_y"])->Fill(std::fabs(yPos[i][1]), thetax[i][0] - thetax[i][1]); + std::get>(trackResidualsHistos[i][quadrant]["dthetax_vs_thetax"])->Fill(std::fabs(thetax[i][1]), thetax[i][0] - thetax[i][1]); + std::get>(trackResidualsHistos[i][quadrant]["dthetay_vs_x"])->Fill(std::fabs(xPos[i][1]), thetay[i][0] - thetay[i][1]); + std::get>(trackResidualsHistos[i][quadrant]["dthetay_vs_y"])->Fill(std::fabs(yPos[i][1]), thetay[i][0] - thetay[i][1]); + std::get>(trackResidualsHistos[i][quadrant]["dthetay_vs_thetay"])->Fill(std::fabs(thetay[i][1]), thetay[i][0] - thetay[i][1]); + } + if (mixed) { + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dx_vs_x"])->Fill(std::fabs(xPos[i][1]), xPos[i][0] - xPos[i][1]); + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dx_vs_y"])->Fill(std::fabs(yPos[i][1]), xPos[i][0] - xPos[i][1]); + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dy_vs_x"])->Fill(std::fabs(xPos[i][1]), yPos[i][0] - yPos[i][1]); + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dy_vs_y"])->Fill(std::fabs(yPos[i][1]), yPos[i][0] - yPos[i][1]); + + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dthetax_vs_x"])->Fill(std::fabs(xPos[i][1]), thetax[i][0] - thetax[i][1]); + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dthetax_vs_y"])->Fill(std::fabs(yPos[i][1]), thetax[i][0] - thetax[i][1]); + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dthetax_vs_thetax"])->Fill(std::fabs(thetax[i][1]), thetax[i][0] - thetax[i][1]); + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dthetay_vs_x"])->Fill(std::fabs(xPos[i][1]), thetay[i][0] - thetay[i][1]); + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dthetay_vs_y"])->Fill(std::fabs(yPos[i][1]), thetay[i][0] - thetay[i][1]); + std::get>(trackResidualsHistosMixedEvents[i][quadrant]["dthetay_vs_thetay"])->Fill(std::fabs(thetay[i][1]), thetay[i][0] - thetay[i][1]); + } + } + } + + template + void FillDCAHistograms(VarT const& fgValues, VarC const& fgValuesColl, int sign, int quadrant, bool same, bool mixed) + { + if constexpr (static_cast(MuonFillMap)) { + if (same) { + std::get>(dcaHistos[1][quadrant][0]["DCA_x"])->Fill(fgValues.dcaX); + std::get>(dcaHistos[1][quadrant][0]["DCA_y"])->Fill(fgValues.dcaY); + std::get>(dcaHistos[1][quadrant][sign]["DCA_x"])->Fill(fgValues.dcaX); + std::get>(dcaHistos[1][quadrant][sign]["DCA_y"])->Fill(fgValues.dcaY); + } + if (mixed) { + std::get>(dcaHistosMixedEvents[1][quadrant][0]["DCA_x"])->Fill(fgValues.dcaX); + std::get>(dcaHistosMixedEvents[1][quadrant][0]["DCA_y"])->Fill(fgValues.dcaY); + std::get>(dcaHistosMixedEvents[1][quadrant][sign]["DCA_x"])->Fill(fgValues.dcaX); + std::get>(dcaHistosMixedEvents[1][quadrant][sign]["DCA_y"])->Fill(fgValues.dcaY); + } + } + + if constexpr (static_cast(GlobalMuonFillMap)) { + if (same) { + std::get>(dcaHistos[0][quadrant][0]["DCA_x"])->Fill(fgValues.dcaX); + std::get>(dcaHistos[0][quadrant][0]["DCA_y"])->Fill(fgValues.dcaY); + std::get>(dcaHistos[0][quadrant][sign]["DCA_x"])->Fill(fgValues.dcaX); + std::get>(dcaHistos[0][quadrant][sign]["DCA_y"])->Fill(fgValues.dcaY); + std::get>(dcaHistos[0][quadrant][0]["DCA_x_vs_z"])->Fill(fgValuesColl.z, fgValues.dcaX); + std::get>(dcaHistos[0][quadrant][0]["DCA_y_vs_z"])->Fill(fgValuesColl.z, fgValues.dcaY); + } + + if (mixed) { + std::get>(dcaHistosMixedEvents[0][quadrant][0]["DCA_x"])->Fill(fgValues.dcaX); + std::get>(dcaHistosMixedEvents[0][quadrant][0]["DCA_y"])->Fill(fgValues.dcaY); + std::get>(dcaHistosMixedEvents[0][quadrant][sign]["DCA_x"])->Fill(fgValues.dcaX); + std::get>(dcaHistosMixedEvents[0][quadrant][sign]["DCA_y"])->Fill(fgValues.dcaY); + std::get>(dcaHistosMixedEvents[0][quadrant][0]["DCA_x_vs_z"])->Fill(fgValuesColl.z, fgValues.dcaX); + std::get>(dcaHistosMixedEvents[0][quadrant][0]["DCA_y_vs_z"])->Fill(fgValuesColl.z, fgValues.dcaY); + } + } + } + + template + void FillResidualHistograms(Var const& fgValuesProp, Var const& fgValuesMCH, Var const& fgValuesMCHpv, Var const& fgValuesMFT, float xCls, float yCls, int topBottom, int posNeg, int quadrant, int chamber, int deIndex, bool same, bool mixed) + { + std::array xPos{xCls, fgValuesProp.x}; + std::array yPos{yCls, fgValuesProp.y}; + double phiClus = std::atan2(yCls, xCls) * 180 / TMath::Pi(); + + if constexpr (static_cast(MuonFillMap)) { + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, 20., configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + if (same) { + std::get>(mchResidualsHistosPerDE[topBottom][posNeg][chamber]["dx_vs_de"])->Fill(deIndex, xPos[0] - xPos[1]); + std::get>(mchResidualsHistosPerDE[topBottom][posNeg][chamber]["dy_vs_de"])->Fill(deIndex, yPos[0] - yPos[1]); + } + if (mixed) { + std::get>(mchResidualsHistosPerDEMixedEvents[topBottom][posNeg][chamber]["dx_vs_de"])->Fill(deIndex, xPos[0] - xPos[1]); + std::get>(mchResidualsHistosPerDEMixedEvents[topBottom][posNeg][chamber]["dy_vs_de"])->Fill(deIndex, yPos[0] - yPos[1]); + } + } + } + + if constexpr (static_cast(MFTFillMap)) { + if (IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, 20., configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + if (IsGoodMFT(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow)) { + if (same) { + std::get>(residualsHistos[quadrant][chamber]["dx_vs_x"])->Fill(std::fabs(xPos[1]), xPos[0] - xPos[1]); + std::get>(residualsHistos[quadrant][chamber]["dx_vs_y"])->Fill(std::fabs(yPos[1]), xPos[0] - xPos[1]); + std::get>(residualsHistos[quadrant][chamber]["dy_vs_x"])->Fill(std::fabs(xPos[1]), yPos[0] - yPos[1]); + std::get>(residualsHistos[quadrant][chamber]["dy_vs_y"])->Fill(std::fabs(yPos[1]), yPos[0] - yPos[1]); + + // residuals vs. DE index + std::get>(residualsHistosPerDE[topBottom][posNeg][chamber]["dx_vs_de"])->Fill(deIndex, xPos[0] - xPos[1]); + std::get>(residualsHistosPerDE[topBottom][posNeg][chamber]["dy_vs_de"])->Fill(deIndex, yPos[0] - yPos[1]); + + // residuals vs. cluster phi + std::get>(residualsHistosPerDE[topBottom][posNeg][chamber]["dx_vs_phi"])->Fill(phiClus, xPos[0] - xPos[1]); + std::get>(residualsHistosPerDE[topBottom][posNeg][chamber]["dy_vs_phi"])->Fill(phiClus, yPos[0] - yPos[1]); + } + if (mixed) { + std::get>(residualsHistosMixedEvents[quadrant][chamber]["dx_vs_x"])->Fill(std::fabs(xPos[1]), xPos[0] - xPos[1]); + std::get>(residualsHistosMixedEvents[quadrant][chamber]["dx_vs_y"])->Fill(std::fabs(yPos[1]), xPos[0] - xPos[1]); + std::get>(residualsHistosMixedEvents[quadrant][chamber]["dy_vs_x"])->Fill(std::fabs(xPos[1]), yPos[0] - yPos[1]); + std::get>(residualsHistosMixedEvents[quadrant][chamber]["dy_vs_y"])->Fill(std::fabs(yPos[1]), yPos[0] - yPos[1]); + + // residuals vs. DE index + std::get>(residualsHistosPerDEMixedEvents[topBottom][posNeg][chamber]["dx_vs_de"])->Fill(deIndex, xPos[0] - xPos[1]); + std::get>(residualsHistosPerDEMixedEvents[topBottom][posNeg][chamber]["dy_vs_de"])->Fill(deIndex, yPos[0] - yPos[1]); + + // residuals vs. cluster phi + std::get>(residualsHistosPerDEMixedEvents[topBottom][posNeg][chamber]["dx_vs_phi"])->Fill(phiClus, xPos[0] - xPos[1]); + std::get>(residualsHistosPerDEMixedEvents[topBottom][posNeg][chamber]["dy_vs_phi"])->Fill(phiClus, yPos[0] - yPos[1]); + } + } + } + } + } + + template + void resetVar(Var& fgValues) + { + fgValues = {}; + } + + void initCCDB(aod::BCsWithTimestamps const& bcs) + { + // Update CCDB informations + if (bcs.size() > 0 && fCurrentRun != bcs.begin().runNumber()) { + // Load magnetic field information from CCDB/local + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + grpmag = ccdb->getForTimeStamp(configCCDB.grpmagPath, bcs.begin().timestamp()); + if (grpmag != nullptr) { + base::Propagator::initFieldFromGRP(grpmag); + TrackExtrap::setField(); + TrackExtrap::useExtrapV2(); + fieldB = static_cast(TGeoGlobalMagField::Instance()->GetField()); // for MFT + double centerMFT[3] = {0, 0, -61.4}; // or use middle point between Vtx and MFT? + Bz = fieldB->getBz(centerMFT); // Get field at centre of MFT + } else { + LOGF(fatal, "GRP object is not available in CCDB at timestamp=%llu", bcs.begin().timestamp()); + } + + // Load geometry information from CCDB/local + LOGF(info, "Loading reference aligned geometry from CCDB no later than %d", configCCDB.nolaterthan.value); + ccdb->setCreatedNotAfter(configCCDB.nolaterthan); // this timestamp has to be consistent with what has been used in reco + geoRef = ccdb->getForTimeStamp(configCCDB.geoPath, bcs.begin().timestamp()); + ccdb->clearCache(configCCDB.geoPath); + if (geoRef != nullptr) { + transformation = geo::transformationFromTGeoManager(*geoRef); + } else { + LOGF(fatal, "Reference aligned geometry object is not available in CCDB at timestamp=%llu", bcs.begin().timestamp()); + } + for (int i = 0; i < 156; i++) { + int iDEN = GetDetElemId(i); + transformRef[iDEN] = transformation(iDEN); + } + + if (configRealign.fDoRealign) { + LOGF(info, "Loading new aligned geometry from CCDB no later than %d", configCCDB.nolaterthanRealign.value); + ccdb->setCreatedNotAfter(configCCDB.nolaterthanRealign); // make sure this timestamp can be resolved regarding the reference one + geoNew = ccdb->getForTimeStamp(configCCDB.geoPathRealign, bcs.begin().timestamp()); + ccdb->clearCache(configCCDB.geoPathRealign); + if (geoNew != nullptr) { + transformation = geo::transformationFromTGeoManager(*geoNew); + } else { + LOGF(fatal, "New aligned geometry object is not available in CCDB at timestamp=%llu", bcs.begin().timestamp()); + } + for (int i = 0; i < 156; i++) { + int iDEN = GetDetElemId(i); + transformNew[iDEN] = transformation(iDEN); + } + } + + fCurrentRun = bcs.begin().runNumber(); + } + } + + void init(InitContext const&) + { + fCurrentRun = 0; + + // Configuration for CCDB server + ccdb->setURL(configCCDB.ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + // Configuration for track fitter + const auto& trackerParam = TrackerParam::Instance(); + trackFitter.setBendingVertexDispersion(trackerParam.bendingVertexDispersion); + trackFitter.setChamberResolution(configRealign.fChamberResolutionX, configRealign.fChamberResolutionY); + trackFitter.smoothTracks(true); + trackFitter.useChamberResolution(); + mImproveCutChi2 = 2. * configRealign.fSigmaCutImprove * configRealign.fSigmaCutImprove; + + CreateBasicHistograms(); + CreateDetailedHistograms(); + } + + template + void runDCA(TEventMap const& collisions, TMFTTracks const& mfts, TTrack const& muon, mch::Track const& mchrealigned, VarC& fgValuesColl, VarT& fgValuesMCH, VarT& fgValuesMCHpv, VarT& fgValuesMFT) + { + if constexpr (static_cast(MuonFillMap)) { + + // track selection + if (!IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, 30., 4., configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + return; + } + + // Loop over collisions + for (auto& [collisionId, fgValuesColltmp] : collisions) { + + bool sameEvent = (fgValuesColltmp.bc == fgValuesColl.bc); + bool mixedEvent = IsMixedEvent(fgValuesColltmp, fgValuesColl); + + if (!sameEvent && !mixedEvent) { + continue; + } + + // Fill propagation of MCH track to DCA + if (configRealign.fDoRealign) { + FillPropagation(mchrealigned, fgValuesColltmp, fgValuesMCH, kToDCA); + } else { + FillPropagation<1>(muon, fgValuesColltmp, VarTrack{}, fgValuesMCH, kToDCA); + } + + double phi = fgValuesMCH.phi * 180 / TMath::Pi(); + int quadrant = GetQuadrantPhi(phi); + int sign = (fgValuesMCH.sign > 0) ? 1 : 2; + + // Fill DCA QA histograms + FillDCAHistograms<1, 0>(fgValuesMCH, fgValuesColltmp, sign, quadrant, sameEvent, mixedEvent); + } + } + + if constexpr (static_cast(GlobalMuonFillMap)) { + auto mftsThisCollision = mfts.sliceBy(mftPerCollision, fgValuesColl.globalIndex); + for (auto const& mft : mftsThisCollision) { + + // Fill MFT track + VarTrack fgValuesMFTtmp; + FillTrack<0>(mft, fgValuesMFTtmp); + + if (fgValuesMFT.trackTime != fgValuesMFTtmp.trackTime) { + continue; // if not time compatible + } + + if (!IsGoodMFT(fgValuesMFTtmp, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow)) { + continue; + } + + int quadrant = GetQuadrantTrack(mft); + if (quadrant < 0) { + continue; + } + + int sign = (fgValuesMFTtmp.sign > 0) ? 1 : 2; + + for (auto& [collisionId, fgValuesColltmp] : collisions) { + + bool sameEvent = (fgValuesColltmp.bc == fgValuesColl.bc); + bool mixedEvent = IsMixedEvent(fgValuesColltmp, fgValuesColl); + + if (!sameEvent && !mixedEvent) { + continue; + } + + // Propagate MFT track to DCA + FillPropagation<0, 1>(mft, fgValuesColltmp, VarTrack{}, fgValuesMFTtmp, kToDCA); + + // Fill DCA QA histograms + FillDCAHistograms<0, 1>(fgValuesMFTtmp, fgValuesColltmp, sign, quadrant, sameEvent, mixedEvent); + } + resetVar(fgValuesMFTtmp); + } + } + } + + template + void runResidual(TEventMap const& collisions, TMuons const& muons, TMFTTracks const& mfts, TMuonCls const& clusters, TMCHTrack const& mchtrack, mch::Track const& mchrealigned, TMFTTrack const& mfttrack, VarC const& fgValuesColl, VarT const& fgValuesMCH, VarT const& fgValuesMCHpv, VarT const& fgValuesMFT) + { + if (!IsGoodMuon(fgValuesMCH, fgValuesMCHpv, configMuons.fTrackChi2MchUp, 20., configMuons.fPtMchLow, configMFTs.fEtaMftLow, configMFTs.fEtaMftUp, configMuons.fRabsLow, configMuons.fRabsUp, configMuons.fSigmaPdcaUp)) { + return; + } + + double phi = fgValuesMCH.phi * 180 / TMath::Pi(); + int quadrant = GetQuadrantPhi(phi); + + //// MCH-MFT track residuals + if (mfttrack.has_collision()) { + auto& fgValuesCollMatched = collisions.at(mfttrack.collisionId()); + + // Do extrapolation for muons to all reference planes + vector mchTrackExtrap; + for (double z : zRefPlane) { + VarTrack fgValues; + if (configRealign.fDoRealign) { + FillPropagation(mchrealigned, VarColl{}, fgValues, kToZ, z); + } else { + FillPropagation<1>(mchtrack, VarColl{}, VarTrack{}, fgValues, kToZ, z); + } + mchTrackExtrap.emplace_back(fgValues); + } + + // Loop over MFT tracks + for (auto const& mft : mfts) { + + if (!mft.has_collision()) { + continue; + } + + // Fill MFT track + VarTrack fgValuesMFTtmp; + FillTrack<0>(mft, fgValuesMFTtmp); + + // Track selection + if (!IsGoodMFT(fgValuesMFTtmp, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow)) { + continue; + } + + auto& fgValuesCollMFT = collisions.at(mft.collisionId()); + + bool sameEvent = (fgValuesCollMFT.bc == fgValuesCollMatched.bc); + bool mixedEvent = IsMixedEvent(fgValuesCollMFT, fgValuesColl); + if (!sameEvent && !mixedEvent) { + continue; + } + + // Do extrapolation for MFTs to all reference planes + vector mftTrackExtrap; + for (double z : zRefPlane) { + VarTrack fgValues; + FillPropagation<0, 1>(mft, fgValuesCollMFT, mchTrackExtrap[1], fgValues, kToZ, z); + mftTrackExtrap.emplace_back(fgValues); + } + + //// Fill QA histograms for alignment checks + FillTrackResidualHistograms(mchTrackExtrap, mftTrackExtrap, quadrant, sameEvent, mixedEvent); + + resetVar(fgValuesMFTtmp); + } + } + + //// Track-Cluster residuals + for (auto const& muon : muons) { + if (static_cast(muon.trackType()) <= 2) { + continue; + } + if (!muon.has_collision()) { + continue; + } + auto& fgValuesCollMCH = collisions.at(muon.collisionId()); + + bool sameEvent = (fgValuesCollMCH.bc == fgValuesColl.bc); + bool mixedEvent = IsMixedEvent(fgValuesCollMCH, fgValuesColl); + if (!sameEvent && !mixedEvent) { + continue; + } + + //// Fill MCH clusters: do re-alignment if asked + mch::Track mchrealignedTmp; + VarClusters fgValuesClsTmp; + if (!FillClusters(muon, clusters, fgValuesClsTmp, mchrealignedTmp)) { + continue; // Refit is not valid + } + + // Loop over attached clusters + for (int iCls = 0; iCls < static_cast(fgValuesClsTmp.posClusters.size()); iCls++) { + + double phiCls = std::atan2(fgValuesClsTmp.posClusters[iCls][1], fgValuesClsTmp.posClusters[iCls][0]) * 180 / TMath::Pi(); + int quadrantCls = GetQuadrantPhi(phiCls); + int DEId = fgValuesClsTmp.DEIDs[iCls]; + int chamber = DEId / 100 - 1; + int deIndex = DEId % 100; + + //// MCH residuals + //// Propagate MCH track to given cluster + VarTrack fgValuesMCHprop; + if (configRealign.fDoRealign) { + FillPropagation(mchrealigned, VarColl{}, fgValuesMCHprop, kToZ, fgValuesClsTmp.posClusters[iCls][2]); + } else { + FillPropagation<1>(mchtrack, VarColl{}, VarTrack{}, fgValuesMCHprop, kToZ, fgValuesClsTmp.posClusters[iCls][2]); + } + + //// Fill residual QA histograms + int topBottom = (fgValuesMCH.y >= 0) ? 0 : 1; + int posNeg = (fgValuesMCH.sign >= 0) ? 0 : 1; + FillResidualHistograms<1, 0>(fgValuesMCHprop, fgValuesMCH, fgValuesMCHpv, fgValuesMFT, fgValuesClsTmp.posClusters[iCls][0], fgValuesClsTmp.posClusters[iCls][1], topBottom, posNeg, quadrantCls, chamber, deIndex, sameEvent, mixedEvent); + resetVar(fgValuesMCHprop); + + //// MFT residuals + if (IsGoodMFT(fgValuesMFT, configMFTs.fTrackChi2MftUp, configMFTs.fTrackNClustMftLow)) { + //// Propagate MFT track to given cluster + VarTrack fgValuesMFTprop; + FillPropagation<0, 1>(mfttrack, VarColl{}, fgValuesMCH, fgValuesMFTprop, kToZ, fgValuesClsTmp.posClusters[iCls][2]); + + //// Fill residual QA histograms for MFT + topBottom = (mfttrack.y() >= 0) ? 0 : 1; + posNeg = (fgValuesMCH.sign >= 0) ? 0 : 1; + FillResidualHistograms<0, 1>(fgValuesMFTprop, fgValuesMCH, fgValuesMCHpv, fgValuesMFT, fgValuesClsTmp.posClusters[iCls][0], fgValuesClsTmp.posClusters[iCls][1], topBottom, posNeg, quadrantCls, chamber, deIndex, sameEvent, mixedEvent); + resetVar(fgValuesMFTprop); + } + } + } + } + + template + void runEventSelection(TEvents const& collisions, TBcs const& bcs, TFwdTracks const& muons, TMFTTracks const& mfts, TMap& collisionSel) + { + for (auto const& collision : collisions) { + + uint64_t collisionIndex = collision.globalIndex(); + auto muonsThisCollision = muons.sliceBy(fwdtracksPerCollision, collisionIndex); + auto mftsThisCollision = mfts.sliceBy(mftPerCollision, collisionIndex); + + if (muonsThisCollision.size() < 1 && mftsThisCollision.size() < 1) { + continue; + } + + auto& fgValuesColl = collisionSel[collisionIndex]; + FillCollision(collision, fgValuesColl); + fgValuesColl.bc = bcs.rawIteratorAt(collision.bcId()).globalBC(); + fgValuesColl.multMFT = mftsThisCollision.size(); + } + } + + template + void runMuonQA(TEventMap const& collisions, TCandidateMap& matchingCandidates, TFwdTracks const& muons, TMFTTracks const& mfts, TMuonCls const& clusters) + { + //// First loop over all muon tracks + for (auto const& muon : muons) { + + //// Get collision information if associated + VarColl fgValuesColl; + if (muon.has_collision()) { + fgValuesColl = collisions.at(muon.collisionId()); + } else { + continue; + } + + if (static_cast(muon.trackType()) <= 2) { // MFT-MCH-MID(0) or MFT-MCH(2) + + registry.get(HIST("global-muons/nTracksPerType"))->Fill(static_cast(muon.trackType())); + + // auto mfttrack = muon.template matchMFTTrack_as(); // unused parameter? + auto mchtrack = muon.template matchMCHTrack_as(); + + // Fill global matching candidates: global muons per MCH track + FillMatchingCandidates(muon, mchtrack, matchingCandidates); + + } else { // MCH-MID(3) or MCH(4) + + // Fill MCH tracks + FillTrack<1>(muon, fgValuesMCH); + + // Propagate MCH to PV + FillPropagation<1>(muon, fgValuesColl, fgValuesMCH, fgValuesMCHpv); // copied in a separate variable + + //// Fill MCH clusters: re-align clusters if required + mch::Track mchrealigned; + VarClusters fgValuesCls; + if (!FillClusters(muon, clusters, fgValuesCls, mchrealigned)) { + continue; // if refit was not passed + } + + //// Update MCH tracks kinematics if using realigned muons + if (configRealign.fDoRealign) { + + // Update track info + FillTrack(mchrealigned, fgValuesMCH); + + // Update propagate of MCH to PV + FillPropagation(mchrealigned, fgValuesColl, fgValuesMCHpv); + + // Update pDCA and Rabs values + FillPropagation(mchrealigned, fgValuesColl, fgValuesMCH, kToAbsEnd); + FillPropagation(mchrealigned, fgValuesColl, fgValuesMCH, kToDCA); + } + + //// Fill muon QA histograms + FillMuonHistograms<1, 0, 0>(fgValuesMCH, fgValuesMCHpv, fgValuesMFT, VarTrack{}, nullptr); + + //// Fill muon DCA QA checks + if (configQAs.fEnableQADCA) { + runDCA<1, 0>(collisions, mfts, muon, mchrealigned, fgValuesColl, fgValuesMCH, fgValuesMCHpv, fgValuesMFT); + } + } + + resetVar(fgValuesMFT); + resetVar(fgValuesMCH); + resetVar(fgValuesMCHpv); + } + + //// Second loop over global muon tracks + for (auto& [mchIndex, globalMuonsVector] : matchingCandidates) { + + //// sort matching candidates in ascending order based on the matching chi2 + auto compareChi2 = [&muons](uint64_t trackIndex1, uint64_t trackIndex2) -> bool { + auto const& track1 = muons.rawIteratorAt(trackIndex1); + auto const& track2 = muons.rawIteratorAt(trackIndex2); + + return (track1.chi2MatchMCHMFT() < track2.chi2MatchMCHMFT()); + }; + std::sort(globalMuonsVector.begin(), globalMuonsVector.end(), compareChi2); + + //// Get tracks + auto muontrack = muons.rawIteratorAt(globalMuonsVector[0]); + auto mchtrack = muontrack.template matchMCHTrack_as(); + auto mfttrack = muontrack.template matchMFTTrack_as(); + + //// Fill matching chi2 + FillMatching(muontrack, fgValuesMCH, fgValuesMFT); + + //// Fill global informations + registry.get(HIST("global-muons/NCandidates"))->Fill(static_cast(globalMuonsVector.size())); + for (size_t candidateIndex = 0; candidateIndex < globalMuonsVector.size(); candidateIndex++) { + auto const& muon = muons.rawIteratorAt(globalMuonsVector[candidateIndex]); + registry.get(HIST("global-muons/MatchChi2"))->Fill(muon.chi2MatchMCHMFT(), candidateIndex); + } + + //// Fill collision information if avalaible + auto& fgValuesCollGlo = collisions.at(muontrack.collisionId()); + VarColl fgValuesCollMCH; // in principal should be the same as global muon + if (mchtrack.has_collision()) { + fgValuesCollMCH = collisions.at(mchtrack.collisionId()); + } + + //// Fill MCH and MFT tracks: basic info copied from input tables + FillTrack<1>(mchtrack, fgValuesMCH); + FillTrack<0>(mfttrack, fgValuesMFT); + FillTrack<1>(muontrack, fgValuesGlobal); + + //// Propagate MCH to PV + FillPropagation<1>(mchtrack, fgValuesCollMCH, VarTrack{}, fgValuesMCHpv); // saved in separate variable fgValuesMCHpv + + //// Fill MCH clusters: re-align clusters if required + mch::Track mchrealigned; + VarClusters fgValuesCls; + if (!FillClusters(mchtrack, clusters, fgValuesCls, mchrealigned)) { + continue; // if refit was not passed + } + + //// Update MCH tracks kinematics if using realigned muons + if (configRealign.fDoRealign) { + // Update track info + FillTrack(mchrealigned, fgValuesMCH); + + // Update propagation of MCH to PV + FillPropagation(mchrealigned, fgValuesCollMCH, fgValuesMCHpv); + + // Update pDCA and Rabs values + FillPropagation(mchrealigned, fgValuesCollMCH, fgValuesMCH, kToAbsEnd); + FillPropagation(mchrealigned, fgValuesCollMCH, fgValuesMCH, kToDCA); + } + + //// Fill global muon candidates info + for (int i = 0; i < static_cast(globalMuonsVector.size()); i++) { + VarTrack fgValuesTmp; + auto muonCandidate = muons.rawIteratorAt(globalMuonsVector[i]); + FillTrack<0>(muonCandidate, fgValuesTmp); + fgValuesCandidates.emplace_back(fgValuesTmp); + } + + //// Fill global muons QA : fill global matching QA if required + if (configQAs.fEnableQAMatching) { + + // Propagate global muon tracks to DCA: treat it as MFT using p from MCH? + FillPropagation<0, 1>(muontrack, fgValuesCollGlo, fgValuesMCH, fgValuesGlobal, kToDCA); + + // Fill bc difference of matched MCH and MFT + if (muontrack.has_collision() && mfttrack.has_collision()) { + fgValuesMCH.bc = collisions.at(muontrack.collisionId()).bc; + fgValuesMFT.bc = collisions.at(mfttrack.collisionId()).bc; + int64_t dbc = fgValuesMCH.bc - fgValuesMFT.bc; + registry.get(HIST("global-matches/BCdifference"))->Fill(dbc); + } + + // Fill QA histograms including global matching + FillMuonHistograms<0, 1, 1>(fgValuesMCH, fgValuesMCHpv, fgValuesMFT, fgValuesGlobal, fgValuesCandidates); + + } else { + // Fill QA histograms + FillMuonHistograms<0, 1, 0>(fgValuesMCH, fgValuesMCHpv, fgValuesMFT, fgValuesGlobal, fgValuesCandidates); + } + + //// Fill residual QA checks if requireds + if (configQAs.fEnableQAResidual) { + runResidual(collisions, muons, mfts, clusters, mchtrack, mchrealigned, mfttrack, fgValuesCollGlo, fgValuesMCH, fgValuesMCHpv, fgValuesMFT); + } + + //// Fill MFT DCA QA checks if required + if (configQAs.fEnableQADCA) { + runDCA<0, 1>(collisions, mfts, nullptr, mch::Track(), fgValuesCollGlo, fgValuesMCH, fgValuesMCHpv, fgValuesMFT); + } + + fgValuesCandidates.clear(); + resetVar(fgValuesMFT); + resetVar(fgValuesMCH); + resetVar(fgValuesMCHpv); + resetVar(fgValuesGlobal); + } + } + + template + void runDimuonQA(TEventMap const& collisions, TCandidateMap const& matchingCandidates, TFwdTracks const& muonTracks, TMuonCls const& clusters) + { + std::vector muonPairs; + std::vector globalMuonPairs; + + GetMuonPairs(muonTracks, matchingCandidates, collisions, muonPairs, globalMuonPairs); + + for (auto& [muon1, muon2] : muonPairs) { + auto collisionIndex1 = muon1.first; + auto const& collision1 = collisions.at(collisionIndex1); + auto collisionIndex2 = muon2.first; + auto const& collision2 = collisions.at(collisionIndex2); + + auto mchIndex1 = muon1.second; + auto mchIndex2 = muon2.second; + auto const& muonTrack1 = muonTracks.rawIteratorAt(mchIndex1); + auto const& muonTrack2 = muonTracks.rawIteratorAt(mchIndex2); + + VarTrack fgValuesMuon1, fgValuesMuonPV1; + VarTrack fgValuesMuon2, fgValuesMuonPV2; + mch::Track mchrealigned1, mchrealigned2; + VarClusters fgValuesCls1, fgValuesCls2; + if (!FillClusters(muonTrack1, clusters, fgValuesCls1, mchrealigned1) || !FillClusters(muonTrack2, clusters, fgValuesCls2, mchrealigned2)) { + continue; // Refit is not valid + } + + if (configRealign.fDoRealign) { + + FillTrack(mchrealigned1, fgValuesMuon1); + FillTrack(mchrealigned2, fgValuesMuon2); + + // Propagate MCH to PV + FillPropagation(mchrealigned1, collision1, fgValuesMuonPV1); + FillPropagation(mchrealigned2, collision2, fgValuesMuonPV2); + + // Recalculate pDCA and Rabs values + FillPropagation(mchrealigned1, collision1, fgValuesMuon1, kToAbsEnd); + FillPropagation(mchrealigned1, collision1, fgValuesMuon1, kToDCA); + FillPropagation(mchrealigned2, collision2, fgValuesMuon2, kToAbsEnd); + FillPropagation(mchrealigned2, collision2, fgValuesMuon2, kToDCA); + } else { + FillTrack<1>(muonTrack1, fgValuesMuon1); + FillTrack<1>(muonTrack2, fgValuesMuon2); + + // Propagate MCH to PV + FillPropagation<1>(muonTrack1, collision1, fgValuesMuon1, fgValuesMuonPV1); + FillPropagation<1>(muonTrack2, collision2, fgValuesMuon1, fgValuesMuonPV2); + } + + int sign1 = muonTrack1.sign(); + int sign2 = muonTrack2.sign(); + + // only consider opposite-sign pairs + if ((sign1 * sign2) >= 0) + continue; + + const auto& muonPos = fgValuesMuon1.sign > 0 ? fgValuesMuon1 : fgValuesMuon2; + const auto& muonNeg = fgValuesMuon1.sign < 0 ? fgValuesMuon1 : fgValuesMuon2; + // μ⁺ variables + double muPosPt = muonPos.pT; + double muPosEta = muonPos.eta; + double muPosRabs = muonPos.rabs; + double muPosPhi = muonPos.phi * 180.0 / TMath::Pi(); + double muPosDca = std::sqrt(muonPos.dcaX * muonPos.dcaX + muonPos.dcaY * muonPos.dcaY); + // μ⁻ variables + double muNegPt = muonNeg.pT; + double muNegEta = muonNeg.eta; + double muNegRabs = muonNeg.rabs; + double muNegPhi = muonNeg.phi * 180.0 / TMath::Pi(); + double muNegDca = std::sqrt(muonNeg.dcaX * muonNeg.dcaX + muonNeg.dcaY * muonNeg.dcaY); + + int Quadrant1 = GetQuadrantPhi(muonTrack1.phi() * 180.0 / TMath::Pi()); + int Quadrant2 = GetQuadrantPhi(muonTrack2.phi() * 180.0 / TMath::Pi()); + int TopBottom1 = (Quadrant1 == 0 || Quadrant1 == 1) ? 0 : 1; + int TopBottom2 = (Quadrant2 == 0 || Quadrant2 == 1) ? 0 : 1; + int LeftRight1 = (Quadrant1 == 0 || Quadrant1 == 3) ? 0 : 1; + int LeftRight2 = (Quadrant2 == 0 || Quadrant2 == 3) ? 0 : 1; + + bool goodMuonTracks = (IsGoodMuon(fgValuesMuon1, fgValuesMuonPV1) && IsGoodMuon(fgValuesMuon2, fgValuesMuonPV2)); + bool goodGlobalMuonTracks = (IsGoodGlobalMuon(fgValuesMuon1, fgValuesMuonPV1) && IsGoodGlobalMuon(fgValuesMuon2, fgValuesMuonPV2)); + + bool sameEvent = (collisionIndex1 == collisionIndex2); + + double mass = GetMuMuInvariantMass(fgValuesMuonPV1, fgValuesMuonPV2); + double pT = GetMuMuPt(fgValuesMuonPV1, fgValuesMuonPV2); + double yPair = GetMuMuRap(fgValuesMuonPV1, fgValuesMuonPV2); + if (goodMuonTracks) { + if (sameEvent) { + // same-event case + // single muons + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosPt_MuonKine_MuonCuts"))->Fill(mass, pT, muPosPt); + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegPt_MuonKine_MuonCuts"))->Fill(mass, pT, muNegPt); + // + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosEta_MuonKine_MuonCuts"))->Fill(mass, pT, muPosEta); + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegEta_MuonKine_MuonCuts"))->Fill(mass, pT, muNegEta); + // + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosRabs_MuonKine_MuonCuts"))->Fill(mass, pT, muPosRabs); + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegRabs_MuonKine_MuonCuts"))->Fill(mass, pT, muNegRabs); + // + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosDca_MuonKine_MuonCuts"))->Fill(mass, pT, muPosDca); + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegDca_MuonKine_MuonCuts"))->Fill(mass, pT, muNegDca); + // + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuPosPhi_MuonKine_MuonCuts"))->Fill(mass, pT, muPosPhi); + registryDimuon.get(HIST("dimuon/same-event/single-muon-dimuon-correlations/invariantMass_pT_MuNegPhi_MuonKine_MuonCuts"))->Fill(mass, pT, muNegPhi); + // dimuons + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts"))->Fill(mass, pT); + registryDimuon.get(HIST("dimuon/same-event/rapPair_MuonKine_MuonCuts"))->Fill(yPair); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts"))->Fill(mass, yPair); + registryDimuon.get(HIST("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts"))->Fill(pT, yPair); + + if (TopBottom1 == 0 && TopBottom2 == 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TT"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TT"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TT"))->Fill(mass, pT); + registryDimuon.get(HIST("dimuon/same-event/rapPair_MuonKine_MuonCuts_TT"))->Fill(yPair); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_TT"))->Fill(mass, yPair); + registryDimuon.get(HIST("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts_TT"))->Fill(pT, yPair); + } else if ((TopBottom1 == 0 && TopBottom2 == 1) || (TopBottom1 == 1 && TopBottom2 == 0)) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TB"))->Fill(mass, pT); + registryDimuon.get(HIST("dimuon/same-event/rapPair_MuonKine_MuonCuts_TB"))->Fill(yPair); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_TB"))->Fill(mass, yPair); + registryDimuon.get(HIST("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts_TB"))->Fill(pT, yPair); + if (TopBottom1 == 0 && TopBottom2 == 1) { + if (sign1 > 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TPBN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TNBP"))->Fill(mass, pT); + } + } else if (TopBottom1 == 1 && TopBottom2 == 0) { + if (sign2 > 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TPBN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_TNBP"))->Fill(mass, pT); + } + } + } else if (TopBottom1 == 1 && TopBottom2 == 1) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_BB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_BB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_BB"))->Fill(mass, pT); + registryDimuon.get(HIST("dimuon/same-event/rapPair_MuonKine_MuonCuts_BB"))->Fill(yPair); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_BB"))->Fill(mass, yPair); + registryDimuon.get(HIST("dimuon/same-event/pT_rapPair_MuonKine_MuonCuts_BB"))->Fill(pT, yPair); + } + + if (LeftRight1 == 0 && LeftRight2 == 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LL"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LL"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LL"))->Fill(mass, pT); + registryDimuon.get(HIST("dimuon/same-event/rapPair_MuonKine_MuonCuts_LL"))->Fill(yPair); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_LL"))->Fill(mass, yPair); + } else if ((LeftRight1 == 0 && LeftRight2 == 1) || (LeftRight1 == 1 && LeftRight2 == 0)) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LR"))->Fill(mass, pT); + registryDimuon.get(HIST("dimuon/same-event/rapPair_MuonKine_MuonCuts_LR"))->Fill(yPair); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_LR"))->Fill(mass, yPair); + if (TopBottom1 == 0 && TopBottom2 == 1) { + if (sign1 > 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LPRN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LNRP"))->Fill(mass, pT); + } + } else if (TopBottom1 == 1 && TopBottom2 == 0) { + if (sign2 > 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LPRN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_LNRP"))->Fill(mass, pT); + } + } + } else if (LeftRight1 == 1 && LeftRight2 == 1) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_MuonCuts_RR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_MuonCuts_RR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_MuonCuts_RR"))->Fill(mass, pT); + registryDimuon.get(HIST("dimuon/same-event/rapPair_MuonKine_MuonCuts_RR"))->Fill(yPair); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_rapPair_MuonKine_MuonCuts_RR"))->Fill(mass, yPair); + } + } else { + // event-mixing case + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts"))->Fill(mass, pT); + + if (TopBottom1 == 0 && TopBottom2 == 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TT"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TT"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TT"))->Fill(mass, pT); + } else if ((TopBottom1 == 0 && TopBottom2 == 1) || (TopBottom1 == 1 && TopBottom2 == 0)) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TB"))->Fill(mass, pT); + if (TopBottom1 == 0 && TopBottom2 == 1) { + if (sign1 > 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TPBN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TNBP"))->Fill(mass, pT); + } + } else if (TopBottom1 == 1 && TopBottom2 == 0) { + if (sign2 > 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TPBN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_TNBP"))->Fill(mass, pT); + } + } + } else if (TopBottom1 == 1 && TopBottom2 == 1) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_BB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_BB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_BB"))->Fill(mass, pT); + } + + if (LeftRight1 == 0 && LeftRight2 == 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LL"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LL"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LL"))->Fill(mass, pT); + } else if ((LeftRight1 == 0 && LeftRight2 == 1) || (LeftRight1 == 1 && LeftRight2 == 0)) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LR"))->Fill(mass, pT); + if (TopBottom1 == 0 && TopBottom2 == 1) { + if (sign1 > 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LPRN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LNRP"))->Fill(mass, pT); + } + } else if (TopBottom1 == 1 && TopBottom2 == 0) { + if (sign2 > 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LPRN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_LNRP"))->Fill(mass, pT); + } + } + } else if (LeftRight1 == 1 && LeftRight2 == 1) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_MuonCuts_RR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_MuonCuts_RR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_MuonCuts_RR"))->Fill(mass, pT); + } + } + } + + if (goodGlobalMuonTracks) { + if (sameEvent) { + // same-event case + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts"))->Fill(mass, pT); + + if (TopBottom1 == 0 && TopBottom2 == 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TT"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TT"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TT"))->Fill(mass, pT); + } else if ((TopBottom1 == 0 && TopBottom2 == 1) || (TopBottom1 == 1 && TopBottom2 == 0)) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TB"))->Fill(mass, pT); + if (TopBottom1 == 0 && TopBottom2 == 1) { + if (sign1 > 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass, pT); + } + } else if (TopBottom1 == 1 && TopBottom2 == 0) { + if (sign2 > 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass, pT); + } + } + } else if (TopBottom1 == 1 && TopBottom2 == 1) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_BB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_BB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_BB"))->Fill(mass, pT); + } + + if (LeftRight1 == 0 && LeftRight2 == 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LL"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LL"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LL"))->Fill(mass, pT); + } else if ((LeftRight1 == 0 && LeftRight2 == 1) || (LeftRight1 == 1 && LeftRight2 == 0)) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LR"))->Fill(mass, pT); + if (TopBottom1 == 0 && TopBottom2 == 1) { + if (sign1 > 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass, pT); + } + } else if (TopBottom1 == 1 && TopBottom2 == 0) { + if (sign2 > 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass, pT); + } + } + } else if (LeftRight1 == 1 && LeftRight2 == 1) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMuonCuts_RR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMuonCuts_RR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_pT_MuonKine_GlobalMuonCuts_RR"))->Fill(mass, pT); + } + } else { + // event-mixing case + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts"))->Fill(mass, pT); + + if (TopBottom1 == 0 && TopBottom2 == 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TT"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TT"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TT"))->Fill(mass, pT); + } else if ((TopBottom1 == 0 && TopBottom2 == 1) || (TopBottom1 == 1 && TopBottom2 == 0)) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TB"))->Fill(mass, pT); + if (TopBottom1 == 0 && TopBottom2 == 1) { + if (sign1 > 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass, pT); + } + } else if (TopBottom1 == 1 && TopBottom2 == 0) { + if (sign2 > 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TPBN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_TNBP"))->Fill(mass, pT); + } + } + } else if (TopBottom1 == 1 && TopBottom2 == 1) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_BB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_BB"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_BB"))->Fill(mass, pT); + } + + if (LeftRight1 == 0 && LeftRight2 == 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LL"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LL"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LL"))->Fill(mass, pT); + } else if ((LeftRight1 == 0 && LeftRight2 == 1) || (LeftRight1 == 1 && LeftRight2 == 0)) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LR"))->Fill(mass, pT); + if (TopBottom1 == 0 && TopBottom2 == 1) { + if (sign1 > 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass, pT); + } + } else if (TopBottom1 == 1 && TopBottom2 == 0) { + if (sign2 > 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LPRN"))->Fill(mass, pT); + } else { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_LNRP"))->Fill(mass, pT); + } + } + } else if (LeftRight1 == 1 && LeftRight2 == 1) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMuonCuts_RR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMuonCuts_RR"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_pT_MuonKine_GlobalMuonCuts_RR"))->Fill(mass, pT); + } + } + } + } + + for (auto& [muon1, muon2] : globalMuonPairs) { + auto collisionIndex1 = muon1.first; + auto collisionIndex2 = muon2.first; + auto& globalTracksVector1 = muon1.second; + auto& globalTracksVector2 = muon2.second; + + auto const& collision1 = collisions.at(collisionIndex1); + auto const& collision2 = collisions.at(collisionIndex2); + + auto const& muonTrack1 = muonTracks.rawIteratorAt(globalTracksVector1[0]); + auto const& muonTrack2 = muonTracks.rawIteratorAt(globalTracksVector2[0]); + auto const& mftTrack1 = muonTrack1.template matchMFTTrack_as(); + auto const& mftTrack2 = muonTrack2.template matchMFTTrack_as(); + auto const& mchTrack1 = muonTrack1.template matchMCHTrack_as(); + auto const& mchTrack2 = muonTrack2.template matchMCHTrack_as(); + + VarTrack fgValuesMuon1, fgValuesMuonPV1, fgValuesMCH1, fgValuesMCHpv1, fgValuesMFT1, fgValuesMFTpv1; + VarTrack fgValuesMuon2, fgValuesMuonPV2, fgValuesMCH2, fgValuesMCHpv2, fgValuesMFT2, fgValuesMFTpv2; + + // Fill MCH and MFT tracks + FillTrack<1>(mchTrack1, fgValuesMCH1); + FillTrack<0>(mftTrack1, fgValuesMFT1); + FillTrack<1>(muonTrack1, fgValuesMuon1); + FillTrack<1>(mchTrack2, fgValuesMCH2); + FillTrack<0>(mftTrack2, fgValuesMFT2); + FillTrack<1>(muonTrack2, fgValuesMuon2); + + //// Fill matching chi2 + FillMatching(muonTrack1, fgValuesMCH1, fgValuesMFT1); + FillMatching(muonTrack2, fgValuesMCH2, fgValuesMFT2); + + mch::Track mchrealigned1, mchrealigned2; + VarClusters fgValuesCls1, fgValuesCls2; + if (!FillClusters(mchTrack1, clusters, fgValuesCls1, mchrealigned1) || !FillClusters(mchTrack2, clusters, fgValuesCls2, mchrealigned2)) { + continue; // Refit is not valid + } + + if (configRealign.fDoRealign) { + + FillTrack(mchrealigned1, fgValuesMCH1); + FillTrack(mchrealigned2, fgValuesMCH2); + + // Propagate MCH to PV + FillPropagation(mchrealigned1, collision1, fgValuesMCHpv1); + FillPropagation(mchrealigned2, collision2, fgValuesMCHpv2); + + // Recalculate pDCA and Rabs values + FillPropagation(mchrealigned1, collision1, fgValuesMCH1, kToAbsEnd); + FillPropagation(mchrealigned1, collision1, fgValuesMCH1, kToDCA); + FillPropagation(mchrealigned2, collision2, fgValuesMCH2, kToAbsEnd); + FillPropagation(mchrealigned2, collision2, fgValuesMCH2, kToDCA); + + } else { + FillTrack<1>(mchTrack1, fgValuesMCH1); + FillTrack<1>(mchTrack2, fgValuesMCH2); + + // Propagate MCH to PV + FillPropagation<1>(mchTrack1, collision1, fgValuesMCH1, fgValuesMCHpv1); + FillPropagation<1>(mchTrack2, collision2, fgValuesMCH2, fgValuesMCHpv2); + } + + // Propagate global muon tracks to PV + FillPropagation<0>(muonTrack1, collision1, fgValuesMCH1, fgValuesMuonPV1); + FillPropagation<0>(muonTrack2, collision2, fgValuesMCH2, fgValuesMuonPV2); + + // Propagate MFT tracks to PV + FillPropagation<0, 1>(mftTrack1, collision1, fgValuesMCH1, fgValuesMFTpv1); + FillPropagation<0, 1>(mftTrack2, collision2, fgValuesMCH2, fgValuesMFTpv2); + + int sign1 = mchTrack1.sign(); + int sign2 = mchTrack2.sign(); + + // only consider opposite-sign pairs + if ((sign1 * sign2) >= 0) + continue; + + // indexes indicating whether the positive and negative tracks come from the top or bottom halves of MFT + int posTopBottom = (sign1 > 0) ? ((muonTrack1.y() >= 0) ? 0 : 1) : ((muonTrack2.y() >= 0) ? 0 : 1); + int negTopBottom = (sign1 < 0) ? ((muonTrack1.y() >= 0) ? 0 : 1) : ((muonTrack2.y() >= 0) ? 0 : 1); + + bool goodGlobalMuonTracks = (IsGoodGlobalMuon(fgValuesMCH1, fgValuesMCHpv1) && IsGoodGlobalMuon(fgValuesMCH2, fgValuesMCHpv2)); + bool goodGlobalMuonMatches = (IsGoodGlobalMatching(fgValuesMFT1) && IsGoodGlobalMatching(fgValuesMFT2)); + + bool sameEvent = (collisionIndex1 == collisionIndex2); + + if (goodGlobalMuonTracks && goodGlobalMuonMatches) { + + double massMCH = GetMuMuInvariantMass(fgValuesMCHpv1, fgValuesMCHpv2); + double mass = GetMuMuInvariantMass(fgValuesMuonPV1, fgValuesMuonPV2); + double massScaled = GetMuMuInvariantMass(fgValuesMFTpv1, fgValuesMFTpv2); + + if (sameEvent) { + // same-event case + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_GlobalMatchesCuts"))->Fill(massMCH); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_MuonKine_GlobalMatchesCuts"))->Fill(massMCH); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts"))->Fill(massScaled); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_ScaledMftKine_GlobalMatchesCuts"))->Fill(massScaled); + + if (posTopBottom == 0 && negTopBottom == 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_TT"))->Fill(massScaled); + } else if (posTopBottom == 0 && negTopBottom == 1) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_TB"))->Fill(massScaled); + } else if (posTopBottom == 1 && negTopBottom == 0) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_BT"))->Fill(massScaled); + } else if (posTopBottom == 1 && negTopBottom == 1) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_BB"))->Fill(massScaled); + } + + // mass correlation + registryDimuon.get(HIST("dimuon/same-event/invariantMass_MuonKine_vs_GlobalMuonKine"))->Fill(mass, massMCH); + registryDimuon.get(HIST("dimuon/same-event/invariantMass_ScaledMftKine_vs_GlobalMuonKine"))->Fill(mass, massScaled); + } else { + // event-mixing case + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_MuonKine_GlobalMatchesCuts"))->Fill(massMCH); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_MuonKine_GlobalMatchesCuts"))->Fill(massMCH); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts"))->Fill(mass); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts"))->Fill(massScaled); + registryDimuon.get(HIST("dimuon/mixed-event/invariantMassFull_ScaledMftKine_GlobalMatchesCuts"))->Fill(massScaled); + + if (posTopBottom == 0 && negTopBottom == 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_TT"))->Fill(massScaled); + } else if (posTopBottom == 0 && negTopBottom == 1) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_TB"))->Fill(massScaled); + } else if (posTopBottom == 1 && negTopBottom == 0) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_BT"))->Fill(massScaled); + } else if (posTopBottom == 1 && negTopBottom == 1) { + registryDimuon.get(HIST("dimuon/mixed-event/invariantMass_ScaledMftKine_GlobalMatchesCuts_BB"))->Fill(massScaled); + } + } + } + + // plots for sub-leading matches are only filled in the same-event case + if (sameEvent) { + if (globalTracksVector1.size() > 1) { + VarTrack fgValuesMuonb1, fgValuesMuonbpv1, fgValuesMFTb1; + auto const& muonTrack1b = muonTracks.rawIteratorAt(globalTracksVector1[1]); + FillTrack<1>(muonTrack1b, fgValuesMuonb1); + FillPropagation<0>(muonTrack1b, collision1, fgValuesMCH1, fgValuesMuonbpv1); + + goodGlobalMuonTracks = (IsGoodGlobalMuon(fgValuesMCH1, fgValuesMCHpv1) && IsGoodGlobalMuon(fgValuesMCH2, fgValuesMCHpv2)); + goodGlobalMuonMatches = (IsGoodGlobalMatching(fgValuesMFTb1) && IsGoodGlobalMatching(fgValuesMFT2)); + double mass = GetMuMuInvariantMass(fgValuesMuonbpv1, fgValuesMuonPV2); + if (goodGlobalMuonTracks && goodGlobalMuonMatches) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts_subleading_leading"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts_subleading_leading"))->Fill(mass); + } + } + + if (globalTracksVector2.size() > 1) { + VarTrack fgValuesMuonb2, fgValuesMuonbpv2, fgValuesMFTb2; + auto const& muonTrack2b = muonTracks.rawIteratorAt(globalTracksVector2[1]); + FillTrack<1>(muonTrack2b, fgValuesMuonb2); + FillPropagation<0>(muonTrack2b, collision2, fgValuesMCH2, fgValuesMuonbpv2); + + goodGlobalMuonTracks = (IsGoodGlobalMuon(fgValuesMCH1, fgValuesMCHpv1) && IsGoodGlobalMuon(fgValuesMCH2, fgValuesMCHpv2)); + goodGlobalMuonMatches = (IsGoodGlobalMatching(fgValuesMFTb2) && IsGoodGlobalMatching(fgValuesMFT1)); + double mass = GetMuMuInvariantMass(fgValuesMuonbpv2, fgValuesMuonPV1); + if (goodGlobalMuonTracks && goodGlobalMuonMatches) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts_leading_subleading"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts_leading_subleading"))->Fill(mass); + } + } + + if (globalTracksVector1.size() > 1 && globalTracksVector2.size() > 1) { + VarTrack fgValuesMuonb1, fgValuesMuonbpv1, fgValuesMFTb1; + VarTrack fgValuesMuonb2, fgValuesMuonbpv2, fgValuesMFTb2; + auto const& muonTrack1b = muonTracks.rawIteratorAt(globalTracksVector1[1]); + auto const& muonTrack2b = muonTracks.rawIteratorAt(globalTracksVector2[1]); + + FillTrack<1>(muonTrack1b, fgValuesMuonb1); + FillPropagation<0>(muonTrack1b, collision1, fgValuesMCH1, fgValuesMuonbpv1); + + FillTrack<1>(muonTrack2b, fgValuesMuonb2); + FillPropagation<0>(muonTrack2b, collision2, fgValuesMCH2, fgValuesMuonbpv2); + + goodGlobalMuonTracks = (IsGoodGlobalMuon(fgValuesMCH1, fgValuesMCHpv1) && IsGoodGlobalMuon(fgValuesMCH2, fgValuesMCHpv2)); + goodGlobalMuonMatches = (IsGoodGlobalMatching(fgValuesMFTb1) && IsGoodGlobalMatching(fgValuesMFTb2)); + double mass = GetMuMuInvariantMass(fgValuesMuonbpv1, fgValuesMuonbpv2); + double massLeading = GetMuMuInvariantMass(fgValuesMuonPV1, fgValuesMuonPV2); + if (goodGlobalMuonTracks && goodGlobalMuonMatches) { + registryDimuon.get(HIST("dimuon/same-event/invariantMass_GlobalMuonKine_GlobalMatchesCuts_subleading_subleading"))->Fill(mass); + registryDimuon.get(HIST("dimuon/same-event/invariantMassFull_GlobalMuonKine_GlobalMatchesCuts_subleading_subleading"))->Fill(mass); + + // mass correlation + registryDimuon.get(HIST("dimuon/same-event/invariantMass_GlobalMuonKine_subleading_vs_leading"))->Fill(massLeading, mass); + } + } + } + } + } + + void processMuonQa(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, MyMuonsWithCov const& muontracks, MyMFTs const& mfttracks, aod::FwdTrkCls const& muonclusters) + { + std::map collisionSel; + std::map> matchingCandidates; + + initCCDB(bcs); + + runEventSelection(collisions, bcs, muontracks, mfttracks, collisionSel); + + runMuonQA(collisionSel, matchingCandidates, muontracks, mfttracks, muonclusters); + + if (configQAs.fEnableQADimuon) { + runDimuonQA(collisionSel, matchingCandidates, muontracks, muonclusters); + } + } + PROCESS_SWITCH(muonQa, processMuonQa, "Process to run muon QA", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/Common/Tasks/trackqa.cxx b/Common/Tasks/trackqa.cxx index 7f5498e5a2a..d10d42af8da 100644 --- a/Common/Tasks/trackqa.cxx +++ b/Common/Tasks/trackqa.cxx @@ -13,6 +13,9 @@ // Task producing basic tracking qa histograms // +#include // std::swap +#include + #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" @@ -101,7 +104,7 @@ struct TrackQa { histos.fill(HIST("TrackPar/signed1Pt"), track.signed1Pt()); histos.fill(HIST("TrackPar/snp"), track.snp()); histos.fill(HIST("TrackPar/tgl"), track.tgl()); - for (unsigned int i = 0; i < 64; i++) { + for (unsigned int i = 0; i < 32; i++) { if (track.flags() & (1 << i)) { histos.fill(HIST("TrackPar/flags"), i); } @@ -161,13 +164,13 @@ struct TrackQaMc { HistogramRegistry resolution{"Resolution", {}, OutputObjHandlingPolicy::QAObject}; - void init(o2::framework::InitContext&){ - - }; - - void process(soa::Join::iterator const&){ + void init(o2::framework::InitContext&) + { + } - }; + void process(soa::Join::iterator const&) + { + } }; //**************************************************************************************** diff --git a/Common/Tools/EventSelectionTools.h b/Common/Tools/EventSelectionTools.h new file mode 100644 index 00000000000..d32cc2dcbcc --- /dev/null +++ b/Common/Tools/EventSelectionTools.h @@ -0,0 +1,1639 @@ +// 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. + +/// \file EventSelectionModule.h +/// \brief +/// \author ALICE + +#ifndef COMMON_TOOLS_EVENTSELECTIONTOOLS_H_ +#define COMMON_TOOLS_EVENTSELECTIONTOOLS_H_ + +#define bitcheck(var, nbit) ((var) & (static_cast(1) << (nbit))) +#define bitcheck64(var, nbit) ((var) & (static_cast(1) << (nbit))) + +#include "MetadataHelper.h" +#include "TableHelper.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/EventSelection.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/LHCConstants.h" +#include "DataFormatsCTP/Configuration.h" +#include "DataFormatsCTP/Scalers.h" +#include "DataFormatsFT0/Digit.h" +#include "DataFormatsITSMFT/NoiseMap.h" // missing include in TimeDeadMap.h +#include "DataFormatsITSMFT/TimeDeadMap.h" +#include "DataFormatsParameters/AggregatedRunInfo.h" +#include "DataFormatsParameters/GRPECSObject.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "ITSMFTBase/DPLAlpideParam.h" +#include "ITSMFTReconstruction/ChipMappingITS.h" + +#include +#include +#include +#include +#include + +//__________________________________________ +// MultModule + +namespace o2 +{ +namespace common +{ +namespace eventselection +{ +static const double bcNS = o2::constants::lhc::LHCBunchSpacingNS; +static const int32_t nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; + +// for providing temporary buffer +// FIXME ideally cursors could be readable +// to avoid duplicate memory allocation but ok +struct bcselEntry { + uint32_t alias{0}; + uint64_t selection{0}; + uint32_t rct{0}; + int foundFT0Id = -1; + int foundFV0Id = -1; + int foundFDDId = -1; + int foundZDCId = -1; +}; + +// bc selection configurables +struct bcselConfigurables : o2::framework::ConfigurableGroup { + std::string prefix = "bcselOpts"; + o2::framework::Configurable amIneeded{"amIneeded", -1, "run BC selection or not. -1: automatic; 0: no; 1: yes"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confTriggerBcShift{"triggerBcShift", 0, "set either custom shift or 999 for apass2/apass3 in LHC22o-t"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confITSROFrameStartBorderMargin{"ITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confITSROFrameEndBorderMargin{"ITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confTimeFrameStartBorderMargin{"TimeFrameStartBorderMargin", -1, "Number of bcs to cut at the start of the Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confTimeFrameEndBorderMargin{"TimeFrameEndBorderMargin", -1, "Number of bcs to cut at the end of the Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confCheckRunDurationLimits{"checkRunDurationLimits", false, "Check if the BCs are within the run duration limits"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable> maxInactiveChipsPerLayer{"maxInactiveChipsPerLayer", {8, 8, 8, 111, 111, 195, 195}, "Maximum allowed number of inactive ITS chips per layer"}; + o2::framework::Configurable confNumberOfOrbitsPerTF{"NumberOfOrbitsPerTF", -1, "Number of orbits per Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) +}; + +// event selection configurables +struct evselConfigurables : o2::framework::ConfigurableGroup { + std::string prefix = "evselOpts"; + bool isMC_metadata = false; + o2::framework::Configurable amIneeded{"amIneeded", -1, "run event selection or not. -1: automatic; 0: no; 1: yes"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable muonSelection{"muonSelection", 0, "0 - barrel, 1 - muon selection with pileup cuts, 2 - muon selection without pileup cuts"}; + o2::framework::Configurable maxDiffZvtxFT0vsPV{"maxDiffZvtxFT0vsPV", 1., "maximum difference (in cm) between z-vertex from FT0 and PV"}; + o2::framework::Configurable isMC{"isMC", -1, "-1 - autoset, 0 - data, 1 - MC"}; + o2::framework::Configurable confSigmaBCforHighPtTracks{"confSigmaBCforHighPtTracks", 4, "Custom sigma (in bcs) for collisions with high-pt tracks"}; + + // configurables for occupancy-based event selection + o2::framework::Configurable confTimeIntervalForOccupancyCalculationMin{"TimeIntervalForOccupancyCalculationMin", -40, "Min time diff window for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confTimeIntervalForOccupancyCalculationMax{"TimeIntervalForOccupancyCalculationMax", 100, "Max time diff window for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confTimeRangeVetoOnCollStandard{"TimeRangeVetoOnCollStandard", 10.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confTimeRangeVetoOnCollNarrow{"TimeRangeVetoOnCollNarrow", 2.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confFT0CamplCutVetoOnCollInTimeRange{"FT0CamplPerCollCutVetoOnCollInTimeRange", 8000, "Max allowed FT0C amplitude for each nearby collision in +/- time range"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confFT0CamplCutVetoOnCollInROF{"FT0CamplPerCollCutVetoOnCollInROF", 5000, "Max allowed FT0C amplitude for each nearby collision inside this ITS ROF"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confEpsilonVzDiffVetoInROF{"EpsilonVzDiffVetoInROF", 0.3, "Minumum distance to nearby collisions along z inside this ITS ROF, cm"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confUseWeightsForOccupancyVariable{"UseWeightsForOccupancyEstimator", 1, "Use or not the delta-time weights for the occupancy estimator"}; // o2-linter: disable=name/configurable (temporary fix) + o2::framework::Configurable confNumberOfOrbitsPerTF{"NumberOfOrbitsPerTF", -1, "Number of orbits per Time Frame. Take from CCDB if -1"}; // o2-linter: disable=name/configurable (temporary fix) +}; + +// luminosity configurables +struct lumiConfigurables : o2::framework::ConfigurableGroup { + std::string prefix = "lumiOpts"; + o2::framework::Configurable amIneeded{"amIneeded", -1, "run BC selection or not. -1: automatic; 0: no; 1: yes"}; // o2-linter: disable=name/configurable (temporary fix) +}; + +class BcSelectionModule +{ + public: + BcSelectionModule() + { + // constructor + } + // declaration of structs here + // (N.B.: will be invisible to the outside, create your own copies) + o2::common::eventselection::bcselConfigurables bcselOpts; + + int lastRun = -1; + int64_t lastTF = -1; + uint32_t lastRCT = 0; + uint64_t sorTimestamp = 0; // default SOR timestamp + uint64_t eorTimestamp = 1; // default EOR timestamp + int64_t bcSOR = -1; // global bc of the start of run + int64_t nBCsPerTF = -1; // duration of TF in bcs, should be 128*3564 or 32*3564 + int rofOffset = -1; // ITS ROF offset, in bc + int rofLength = -1; // ITS ROF length, in bc + int mITSROFrameStartBorderMargin = 10; // default value + int mITSROFrameEndBorderMargin = 20; // default value + int mTimeFrameStartBorderMargin = 300; // default value + int mTimeFrameEndBorderMargin = 4000; // default value + std::string strLPMProductionTag = ""; // MC production tag to be retrieved from AO2D metadata + + TriggerAliases* aliases = nullptr; + EventSelectionParams* par = nullptr; + std::map* mapRCT = nullptr; + std::map> mapInactiveChips; // number of inactive chips vs orbit per layer + int64_t prevOrbitForInactiveChips = 0; // cached next stored orbit in the inactive chip map + int64_t nextOrbitForInactiveChips = 0; // cached previous stored orbit in the inactive chip map + bool isGoodITSLayer3 = true; // default value + bool isGoodITSLayer0123 = true; // default value + bool isGoodITSLayersAll = true; // default value + + template + void init(TContext& context, TBcSelOpts const& external_bcselopts, THistoRegistry& histos, TMetadataInfo const& metadataInfo) + { + // read in configurations from the task where it's used + bcselOpts = external_bcselopts; + + if (bcselOpts.amIneeded.value < 0) { + int bcSelNeeded = -1, evSelNeeded = -1; + bcselOpts.amIneeded.value = 0; + enableFlagIfTableRequired(context, "BcSels", bcSelNeeded); + enableFlagIfTableRequired(context, "EvSels", evSelNeeded); + if (bcSelNeeded == 1) { + bcselOpts.amIneeded.value = 1; + LOGF(info, "BC Selection / Autodetection for aod::BcSels: subscription present, will generate."); + } + if (evSelNeeded == 1 && bcSelNeeded == 0) { + bcselOpts.amIneeded.value = 1; + LOGF(info, "BC Selection / Autodetection for aod::BcSels: not there, but EvSel needed. Will generate."); + } + if (bcSelNeeded == 0 && evSelNeeded == 0) { + LOGF(info, "BC Selection / Autodetection for aod::BcSels: not required. Skipping generation."); + return; + } + } + strLPMProductionTag = metadataInfo.get("LPMProductionTag"); // to extract info from ccdb by the tag + + // add counter + histos.add("bcselection/hCounterInvalidBCTimestamp", "", o2::framework::kTH1D, {{1, 0., 1.}}); + } + + //__________________________________________________ + template + bool configure(TCCDB& ccdb, TBCs const& bcs) + { + if (bcs.size() == 0) + return false; + int run = bcs.iteratorAt(0).runNumber(); + if (run != lastRun) { + lastRun = run; + int run3min = 500000; + if (run < run3min) { // unanchored Run3 MC + auto runDuration = ccdb->getRunDuration(run, true); // fatalise if timestamps are not found + // SOR and EOR timestamps + sorTimestamp = runDuration.first; // timestamp of the SOR/SOX/STF in ms + eorTimestamp = runDuration.second; // timestamp of the EOR/EOX/ETF in ms + auto ctp = ccdb->template getForTimeStamp>("CTP/Calib/OrbitReset", sorTimestamp / 2 + eorTimestamp / 2); + auto orbitResetMUS = (*ctp)[0]; + // first bc of the first orbit + bcSOR = static_cast((sorTimestamp * 1000 - orbitResetMUS) / o2::constants::lhc::LHCOrbitMUS) * nBCsPerOrbit; + // duration of TF in bcs + nBCsPerTF = 32; // hard-coded for Run3 MC (no info from ccdb at the moment) + } else { + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run, strLPMProductionTag); + // SOR and EOR timestamps + sorTimestamp = runInfo.sor; + eorTimestamp = runInfo.eor; + // first bc of the first orbit + bcSOR = runInfo.orbitSOR * nBCsPerOrbit; + // duration of TF in bcs + nBCsPerTF = bcselOpts.confNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * nBCsPerOrbit : bcselOpts.confNumberOfOrbitsPerTF * nBCsPerOrbit; + } + + // timestamp of the middle of the run used to access run-wise CCDB entries + int64_t ts = sorTimestamp / 2 + eorTimestamp / 2; + // access ITSROF and TF border margins + par = ccdb->template getForTimeStamp("EventSelection/EventSelectionParams", ts); + mITSROFrameStartBorderMargin = bcselOpts.confITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : bcselOpts.confITSROFrameStartBorderMargin; + mITSROFrameEndBorderMargin = bcselOpts.confITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : bcselOpts.confITSROFrameEndBorderMargin; + mTimeFrameStartBorderMargin = bcselOpts.confTimeFrameStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : bcselOpts.confTimeFrameStartBorderMargin; + mTimeFrameEndBorderMargin = bcselOpts.confTimeFrameEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : bcselOpts.confTimeFrameEndBorderMargin; + // ITSROF parameters + auto alppar = ccdb->template getForTimeStamp>("ITS/Config/AlpideParam", ts); + rofOffset = alppar->roFrameBiasInBC; + rofLength = alppar->roFrameLengthInBC; + // Trigger aliases + aliases = ccdb->template getForTimeStamp("EventSelection/TriggerAliases", ts); + + // prepare map of inactive chips + auto itsDeadMap = ccdb->template getForTimeStamp("ITS/Calib/TimeDeadMap", ts); + auto itsDeadMapOrbits = itsDeadMap->getEvolvingMapKeys(); // roughly every second, ~350 TFs = 350x32 orbits + std::vector vClosest; // temporary vector of inactive chip ids for the current orbit range + for (const auto& orbit : itsDeadMapOrbits) { + itsDeadMap->getMapAtOrbit(orbit, vClosest); + // insert initial (orbit,vector) pair for each layer + mapInactiveChips[orbit].resize(o2::itsmft::ChipMappingITS::NLayers, 0); + + // fill map of inactive chips + for (size_t iel = 0; iel < vClosest.size(); iel++) { + uint16_t w1 = vClosest[iel]; + bool isLastInSequence = (w1 & 0x8000) == 0; + uint16_t w2 = isLastInSequence ? w1 + 1 : vClosest[iel + 1]; + uint16_t chipId1 = w1 & 0x7FFF; + uint16_t chipId2 = w2 & 0x7FFF; + for (int chipId = chipId1; chipId < chipId2; chipId++) { + auto layer = o2::itsmft::ChipMappingITS::getLayer(chipId); + mapInactiveChips[orbit][layer]++; + } + } // loop over vector of inactive chip ids + } // loop over orbits + + // QC info + std::map metadata; + metadata["run"] = Form("%d", run); + ccdb->setFatalWhenNull(0); + mapRCT = ccdb->template getSpecific>("RCT/Flags/RunFlags", ts, metadata); + ccdb->setFatalWhenNull(1); + if (mapRCT == nullptr) { + LOGP(info, "rct object missing... inserting dummy rct flags"); + mapRCT = new std::map; + uint32_t dummyValue = 1 << 31; // setting bit 31 to indicate that rct object is missing + mapRCT->insert(std::pair(sorTimestamp, dummyValue)); + } + } + return true; + } + + //__________________________________________________ + template + void processRun2(TCCDB const& ccdb, TBCs const& bcs, TTimestamps const& timestamps, TBcSelBuffer& bcselbuffer, TBcSelCursor& bcsel) + { + if (bcselOpts.amIneeded.value == 0) { + bcselbuffer.clear(); + return; + } + bcselbuffer.clear(); + for (const auto& bc : bcs) { + uint64_t timestamp = timestamps[bc.globalIndex()]; + par = ccdb->template getForTimeStamp("EventSelection/EventSelectionParams", timestamp); + aliases = ccdb->template getForTimeStamp("EventSelection/TriggerAliases", timestamp); + // fill fired aliases + uint32_t alias{0}; + uint64_t triggerMask = bc.triggerMask(); + for (const auto& al : aliases->GetAliasToTriggerMaskMap()) { + if (triggerMask & al.second) { + alias |= BIT(al.first); + } + } + uint64_t triggerMaskNext50 = bc.triggerMaskNext50(); + for (const auto& al : aliases->GetAliasToTriggerMaskNext50Map()) { + if (triggerMaskNext50 & al.second) { + alias |= BIT(al.first); + } + } + alias |= BIT(kALL); + + // get timing info from ZDC, FV0, FT0 and FDD + float timeZNA = bc.has_zdc() ? bc.zdc().timeZNA() : -999.f; + float timeZNC = bc.has_zdc() ? bc.zdc().timeZNC() : -999.f; + float timeV0A = bc.has_fv0a() ? bc.fv0a().time() : -999.f; + float timeV0C = bc.has_fv0c() ? bc.fv0c().time() : -999.f; + float timeT0A = bc.has_ft0() ? bc.ft0().timeA() : -999.f; + float timeT0C = bc.has_ft0() ? bc.ft0().timeC() : -999.f; + float timeFDA = bc.has_fdd() ? bc.fdd().timeA() : -999.f; + float timeFDC = bc.has_fdd() ? bc.fdd().timeC() : -999.f; + + LOGF(debug, "timeZNA=%f timeZNC=%f", timeZNA, timeZNC); + LOGF(debug, "timeV0A=%f timeV0C=%f", timeV0A, timeV0C); + LOGF(debug, "timeFDA=%f timeFDC=%f", timeFDA, timeFDC); + LOGF(debug, "timeT0A=%f timeT0C=%f", timeT0A, timeT0C); + + // fill time-based selection criteria + uint64_t selection{0}; + selection |= timeV0A > par->fV0ABBlower && timeV0A < par->fV0ABBupper ? BIT(aod::evsel::kIsBBV0A) : 0; + selection |= timeV0C > par->fV0CBBlower && timeV0C < par->fV0CBBupper ? BIT(aod::evsel::kIsBBV0C) : 0; + selection |= timeFDA > par->fFDABBlower && timeFDA < par->fFDABBupper ? BIT(aod::evsel::kIsBBFDA) : 0; + selection |= timeFDC > par->fFDCBBlower && timeFDC < par->fFDCBBupper ? BIT(aod::evsel::kIsBBFDC) : 0; + selection |= !(timeV0A > par->fV0ABGlower && timeV0A < par->fV0ABGupper) ? BIT(aod::evsel::kNoBGV0A) : 0; + selection |= !(timeV0C > par->fV0CBGlower && timeV0C < par->fV0CBGupper) ? BIT(aod::evsel::kNoBGV0C) : 0; + selection |= !(timeFDA > par->fFDABGlower && timeFDA < par->fFDABGupper) ? BIT(aod::evsel::kNoBGFDA) : 0; + selection |= !(timeFDC > par->fFDCBGlower && timeFDC < par->fFDCBGupper) ? BIT(aod::evsel::kNoBGFDC) : 0; + selection |= (timeT0A > par->fT0ABBlower && timeT0A < par->fT0ABBupper) ? BIT(aod::evsel::kIsBBT0A) : 0; + selection |= (timeT0C > par->fT0CBBlower && timeT0C < par->fT0CBBupper) ? BIT(aod::evsel::kIsBBT0C) : 0; + selection |= (timeZNA > par->fZNABBlower && timeZNA < par->fZNABBupper) ? BIT(aod::evsel::kIsBBZNA) : 0; + selection |= (timeZNC > par->fZNCBBlower && timeZNC < par->fZNCBBupper) ? BIT(aod::evsel::kIsBBZNC) : 0; + selection |= !(std::fabs(timeZNA) > par->fZNABGlower && std::fabs(timeZNA) < par->fZNABGupper) ? BIT(aod::evsel::kNoBGZNA) : 0; + selection |= !(std::fabs(timeZNC) > par->fZNCBGlower && std::fabs(timeZNC) < par->fZNCBGupper) ? BIT(aod::evsel::kNoBGZNC) : 0; + selection |= (std::pow((timeZNA + timeZNC - par->fZNSumMean) / par->fZNSumSigma, 2) + std::pow((timeZNA - timeZNC - par->fZNDifMean) / par->fZNDifSigma, 2) < 1) ? BIT(aod::evsel::kIsBBZAC) : 0; + + // Calculate V0 multiplicity per ring + float multRingV0A[5] = {0.}; + float multRingV0C[4] = {0.}; + float multFV0A = 0; + float multFV0C = 0; + if (bc.has_fv0a()) { + for (unsigned int i = 0; i < bc.fv0a().amplitude().size(); ++i) { + int ring = bc.fv0a().channel()[i] / 8; + multRingV0A[ring] += bc.fv0a().amplitude()[i]; + multFV0A += bc.fv0a().amplitude()[i]; + } + } + + if (bc.has_fv0c()) { + for (unsigned int i = 0; i < bc.fv0c().amplitude().size(); ++i) { + int ring = bc.fv0c().channel()[i] / 8; + multRingV0C[ring] += bc.fv0c().amplitude()[i]; + multFV0C += bc.fv0c().amplitude()[i]; + } + } + + // Calculate pileup and background related selection flags + // V0A0 excluded from online V0A charge sum => excluding also from offline sum for consistency + float ofV0M = multFV0A + multFV0C - multRingV0A[0]; + float onV0M = bc.v0TriggerChargeA() + bc.v0TriggerChargeC(); + float ofSPD = bc.spdFiredChipsL0() + bc.spdFiredChipsL1(); + float onSPD = bc.spdFiredFastOrL0() + bc.spdFiredFastOrL1(); + float multV0C012 = multRingV0C[0] + multRingV0C[1] + multRingV0C[2]; + + selection |= (onV0M > par->fV0MOnVsOfA + par->fV0MOnVsOfB * ofV0M) ? BIT(aod::evsel::kNoV0MOnVsOfPileup) : 0; + selection |= (onSPD > par->fSPDOnVsOfA + par->fSPDOnVsOfB * ofSPD) ? BIT(aod::evsel::kNoSPDOnVsOfPileup) : 0; + selection |= (multRingV0C[3] > par->fV0CasymA + par->fV0CasymB * multV0C012) ? BIT(aod::evsel::kNoV0Casymmetry) : 0; + selection |= (TESTBIT(selection, aod::evsel::kIsBBV0A) || TESTBIT(selection, aod::evsel::kIsBBV0C) || ofSPD) ? BIT(aod::evsel::kIsINT1) : 0; + selection |= (bc.has_ft0() ? TESTBIT(bc.ft0().triggerMask(), o2::ft0::Triggers::bitVertex) : 0) ? BIT(aod::evsel::kIsTriggerTVX) : 0; + + // copy remaining selection decisions from eventCuts + uint32_t eventCuts = bc.eventCuts(); + selection |= (eventCuts & 1 << aod::kTimeRangeCut) ? BIT(aod::evsel::kIsGoodTimeRange) : 0; + selection |= (eventCuts & 1 << aod::kIncompleteDAQ) ? BIT(aod::evsel::kNoIncompleteDAQ) : 0; + selection |= !(eventCuts & 1 << aod::kIsTPCLaserWarmUp) ? BIT(aod::evsel::kNoTPCLaserWarmUp) : 0; + selection |= !(eventCuts & 1 << aod::kIsTPCHVdip) ? BIT(aod::evsel::kNoTPCHVdip) : 0; + selection |= !(eventCuts & 1 << aod::kIsPileupFromSPD) ? BIT(aod::evsel::kNoPileupFromSPD) : 0; + selection |= !(eventCuts & 1 << aod::kIsV0PFPileup) ? BIT(aod::evsel::kNoV0PFPileup) : 0; + selection |= (eventCuts & 1 << aod::kConsistencySPDandTrackVertices) ? BIT(aod::evsel::kNoInconsistentVtx) : 0; + selection |= (eventCuts & 1 << aod::kPileupInMultBins) ? BIT(aod::evsel::kNoPileupInMultBins) : 0; + selection |= (eventCuts & 1 << aod::kPileUpMV) ? BIT(aod::evsel::kNoPileupMV) : 0; + selection |= (eventCuts & 1 << aod::kTPCPileUp) ? BIT(aod::evsel::kNoPileupTPC) : 0; + + int32_t foundFT0 = bc.has_ft0() ? bc.ft0().globalIndex() : -1; + int32_t foundFV0 = bc.has_fv0a() ? bc.fv0a().globalIndex() : -1; + int32_t foundFDD = bc.has_fdd() ? bc.fdd().globalIndex() : -1; + int32_t foundZDC = bc.has_zdc() ? bc.zdc().globalIndex() : -1; + + // // Fill TVX (T0 vertex) counters FIXME - this is a bug, there's no hCounterTVX in this task + // if (TESTBIT(selection, aod::evsel::kIsTriggerTVX)) { + // histos.get(HIST("hCounterTVX"))->Fill(Form("%d", bc.runNumber()), 1); + // } + + uint32_t rct = 0; + + // initialize properties + o2::common::eventselection::bcselEntry entry; + entry.alias = alias; + entry.selection = selection; + entry.rct = rct; + entry.foundFT0Id = foundFT0; + entry.foundFV0Id = foundFV0; + entry.foundFDDId = foundFDD; + entry.foundZDCId = foundZDC; + bcselbuffer.push_back(entry); + + // Fill bc selection columns + bcsel(alias, selection, rct, foundFT0, foundFV0, foundFDD, foundZDC); + } // end bc loop + } // end processRun2 + + //__________________________________________________ + template + void processRun3(TCCDB const& ccdb, THistoRegistry& histos, TBCs const& bcs, TTimestamps const& timestamps, TBcSelBuffer& bcselbuffer, TBcSelCursor& bcsel) + { + if (bcselOpts.amIneeded.value == 0) { + bcselbuffer.clear(); + return; + } + bcselbuffer.clear(); + if (!configure(ccdb, bcs)) + return; // don't do anything in case configuration reported not ok + + int run = bcs.iteratorAt(0).runNumber(); + // map from GlobalBC to BcId needed to find triggerBc + std::map mapGlobalBCtoBcId; + for (const auto& bc : bcs) { + mapGlobalBCtoBcId[bc.globalBC()] = bc.globalIndex(); + } + + int triggerBcShift = bcselOpts.confTriggerBcShift; + if (bcselOpts.confTriggerBcShift == 999) { // o2-linter: disable=magic-number (special shift for early 2022 data) + triggerBcShift = (run <= 526766 || (run >= 526886 && run <= 527237) || (run >= 527259 && run <= 527518) || run == 527523 || run == 527734 || run >= 534091) ? 0 : 294; // o2-linter: disable=magic-number (magic list of runs) + } + + // bc loop + for (auto bc : bcs) { // o2-linter: disable=const-ref-in-for-loop (use bc as nonconst iterator) + uint64_t timestamp = timestamps[bc.globalIndex()]; + // store rct flags + uint32_t rct = lastRCT; + int64_t thisTF = (bc.globalBC() - bcSOR) / nBCsPerTF; + if (mapRCT != nullptr && thisTF != lastTF) { // skip for unanchored runs; do it once per TF + auto itrct = mapRCT->upper_bound(timestamp); + if (itrct != mapRCT->begin()) + itrct--; + rct = itrct->second; + LOGP(debug, "sor={} eor={} ts={} rct={}", sorTimestamp, eorTimestamp, timestamp, rct); + lastRCT = rct; + lastTF = thisTF; + } + + uint32_t alias{0}; + // workaround for pp2022 (trigger info is shifted by -294 bcs) + int32_t triggerBcId = mapGlobalBCtoBcId[bc.globalBC() + triggerBcShift]; + if (triggerBcId && aliases) { + auto triggerBc = bcs.iteratorAt(triggerBcId); + uint64_t triggerMask = triggerBc.triggerMask(); + for (const auto& al : aliases->GetAliasToTriggerMaskMap()) { + if (triggerMask & al.second) { + alias |= BIT(al.first); + } + } + } + alias |= BIT(kALL); + + // get timing info from ZDC, FV0, FT0 and FDD + float timeZNA = bc.has_zdc() ? bc.zdc().timeZNA() : -999.f; + float timeZNC = bc.has_zdc() ? bc.zdc().timeZNC() : -999.f; + float timeV0A = bc.has_fv0a() ? bc.fv0a().time() : -999.f; + float timeT0A = bc.has_ft0() ? bc.ft0().timeA() : -999.f; + float timeT0C = bc.has_ft0() ? bc.ft0().timeC() : -999.f; + float timeFDA = bc.has_fdd() ? bc.fdd().timeA() : -999.f; + float timeFDC = bc.has_fdd() ? bc.fdd().timeC() : -999.f; + float timeV0ABG = -999.f; + float timeT0ABG = -999.f; + float timeT0CBG = -999.f; + float timeFDABG = -999.f; + float timeFDCBG = -999.f; + + uint64_t globalBC = bc.globalBC(); + // move to previous bcs to check beam-gas in FT0, FV0 and FDD + int64_t backwardMoveCount = 0; + int64_t deltaBC = 6; // up to 6 bcs back + while (bc.globalBC() + deltaBC >= globalBC) { + if (bc == bcs.begin()) { + break; + } + --bc; + backwardMoveCount++; + int bcDistanceToBeamGasForFT0 = 1; + int bcDistanceToBeamGasForFDD = 5; + if (bc.globalBC() + bcDistanceToBeamGasForFT0 == globalBC) { + timeV0ABG = bc.has_fv0a() ? bc.fv0a().time() : -999.f; + timeT0ABG = bc.has_ft0() ? bc.ft0().timeA() : -999.f; + timeT0CBG = bc.has_ft0() ? bc.ft0().timeC() : -999.f; + } + if (bc.globalBC() + bcDistanceToBeamGasForFDD == globalBC) { + timeFDABG = bc.has_fdd() ? bc.fdd().timeA() : -999.f; + timeFDCBG = bc.has_fdd() ? bc.fdd().timeC() : -999.f; + } + } + // move back to initial position + bc.moveByIndex(backwardMoveCount); + + // fill time-based selection criteria + uint64_t selection{0}; + selection |= timeV0A > par->fV0ABBlower && timeV0A < par->fV0ABBupper ? BIT(aod::evsel::kIsBBV0A) : 0; + selection |= timeFDA > par->fFDABBlower && timeFDA < par->fFDABBupper ? BIT(aod::evsel::kIsBBFDA) : 0; + selection |= timeFDC > par->fFDCBBlower && timeFDC < par->fFDCBBupper ? BIT(aod::evsel::kIsBBFDC) : 0; + selection |= !(timeV0ABG > par->fV0ABGlower && timeV0ABG < par->fV0ABGupper) ? BIT(aod::evsel::kNoBGV0A) : 0; + selection |= !(timeFDABG > par->fFDABGlower && timeFDABG < par->fFDABGupper) ? BIT(aod::evsel::kNoBGFDA) : 0; + selection |= !(timeFDCBG > par->fFDCBGlower && timeFDCBG < par->fFDCBGupper) ? BIT(aod::evsel::kNoBGFDC) : 0; + selection |= !(timeT0ABG > par->fT0ABGlower && timeT0ABG < par->fT0ABGupper) ? BIT(aod::evsel::kNoBGT0A) : 0; + selection |= !(timeT0CBG > par->fT0CBGlower && timeT0CBG < par->fT0CBGupper) ? BIT(aod::evsel::kNoBGT0C) : 0; + selection |= (timeT0A > par->fT0ABBlower && timeT0A < par->fT0ABBupper) ? BIT(aod::evsel::kIsBBT0A) : 0; + selection |= (timeT0C > par->fT0CBBlower && timeT0C < par->fT0CBBupper) ? BIT(aod::evsel::kIsBBT0C) : 0; + selection |= (timeZNA > par->fZNABBlower && timeZNA < par->fZNABBupper) ? BIT(aod::evsel::kIsBBZNA) : 0; + selection |= (timeZNC > par->fZNCBBlower && timeZNC < par->fZNCBBupper) ? BIT(aod::evsel::kIsBBZNC) : 0; + selection |= (std::pow((timeZNA + timeZNC - par->fZNSumMean) / par->fZNSumSigma, 2) + std::pow((timeZNA - timeZNC - par->fZNDifMean) / par->fZNDifSigma, 2) < 1) ? BIT(aod::evsel::kIsBBZAC) : 0; + selection |= !(std::fabs(timeZNA) > par->fZNABGlower && std::fabs(timeZNA) < par->fZNABGupper) ? BIT(aod::evsel::kNoBGZNA) : 0; + selection |= !(std::fabs(timeZNC) > par->fZNCBGlower && std::fabs(timeZNC) < par->fZNCBGupper) ? BIT(aod::evsel::kNoBGZNC) : 0; + selection |= (bc.has_ft0() ? (bc.ft0().triggerMask() & BIT(o2::ft0::Triggers::bitVertex)) > 0 : 0) ? BIT(aod::evsel::kIsTriggerTVX) : 0; + + // check if bc is far from start and end of the ITS RO Frame border + uint16_t bcInITSROF = (globalBC + nBCsPerOrbit - rofOffset) % rofLength; + LOGP(debug, "bcInITSROF={}", bcInITSROF); + selection |= bcInITSROF > mITSROFrameStartBorderMargin && bcInITSROF < rofLength - mITSROFrameEndBorderMargin ? BIT(aod::evsel::kNoITSROFrameBorder) : 0; + + // check if bc is far from the Time Frame borders + int64_t bcInTF = (globalBC - bcSOR) % nBCsPerTF; + LOGP(debug, "bcInTF={}", bcInTF); + selection |= bcInTF > mTimeFrameStartBorderMargin && bcInTF < nBCsPerTF - mTimeFrameEndBorderMargin ? BIT(aod::evsel::kNoTimeFrameBorder) : 0; + + // check number of inactive chips and set kIsGoodITSLayer3, kIsGoodITSLayer0123, kIsGoodITSLayersAll flags + int64_t orbit = globalBC / nBCsPerOrbit; + if (mapInactiveChips.size() > 0 && (orbit < prevOrbitForInactiveChips || orbit > nextOrbitForInactiveChips)) { + auto it = mapInactiveChips.upper_bound(orbit); + bool isEnd = (it == mapInactiveChips.end()); + if (isEnd) + it--; + nextOrbitForInactiveChips = isEnd ? orbit : it->first; // setting current orbit in case we reached the end of mapInactiveChips + auto vNextInactiveChips = it->second; + if (it != mapInactiveChips.begin() && !isEnd) + it--; + prevOrbitForInactiveChips = it->first; + auto vPrevInactiveChips = it->second; + LOGP(debug, "orbit: {}, previous orbit: {}, next orbit: {} ", orbit, prevOrbitForInactiveChips, nextOrbitForInactiveChips); + LOGP(debug, "next inactive chips: {} {} {} {} {} {} {}", vNextInactiveChips[0], vNextInactiveChips[1], vNextInactiveChips[2], vNextInactiveChips[3], vNextInactiveChips[4], vNextInactiveChips[5], vNextInactiveChips[6]); + LOGP(debug, "prev inactive chips: {} {} {} {} {} {} {}", vPrevInactiveChips[0], vPrevInactiveChips[1], vPrevInactiveChips[2], vPrevInactiveChips[3], vPrevInactiveChips[4], vPrevInactiveChips[5], vPrevInactiveChips[6]); + isGoodITSLayer3 = vPrevInactiveChips[3] <= bcselOpts.maxInactiveChipsPerLayer->at(3) && vNextInactiveChips[3] <= bcselOpts.maxInactiveChipsPerLayer->at(3); + isGoodITSLayer0123 = true; + for (int i = 0; i < 4; i++) { // o2-linter: disable=magic-number (counting first 4 ITS layers) + isGoodITSLayer0123 &= vPrevInactiveChips[i] <= bcselOpts.maxInactiveChipsPerLayer->at(i) && vNextInactiveChips[i] <= bcselOpts.maxInactiveChipsPerLayer->at(i); + } + isGoodITSLayersAll = true; + for (int i = 0; i < o2::itsmft::ChipMappingITS::NLayers; i++) { + isGoodITSLayersAll &= vPrevInactiveChips[i] <= bcselOpts.maxInactiveChipsPerLayer->at(i) && vNextInactiveChips[i] <= bcselOpts.maxInactiveChipsPerLayer->at(i); + } + } + + selection |= isGoodITSLayer3 ? BIT(aod::evsel::kIsGoodITSLayer3) : 0; + selection |= isGoodITSLayer0123 ? BIT(aod::evsel::kIsGoodITSLayer0123) : 0; + selection |= isGoodITSLayersAll ? BIT(aod::evsel::kIsGoodITSLayersAll) : 0; + + // fill found indices + int32_t foundFT0 = bc.has_ft0() ? bc.ft0().globalIndex() : -1; + int32_t foundFV0 = bc.has_fv0a() ? bc.fv0a().globalIndex() : -1; + int32_t foundFDD = bc.has_fdd() ? bc.fdd().globalIndex() : -1; + int32_t foundZDC = bc.has_zdc() ? bc.zdc().globalIndex() : -1; + LOGP(debug, "foundFT0={}", foundFT0); + + const char* srun = Form("%d", run); + if (timestamp < sorTimestamp || timestamp > eorTimestamp) { + histos.template get(HIST("bcselection/hCounterInvalidBCTimestamp"))->Fill(srun, 1); + if (bcselOpts.confCheckRunDurationLimits.value) { + LOGF(warn, "Invalid BC timestamp: %d, run: %d, sor: %d, eor: %d", timestamp, run, sorTimestamp, eorTimestamp); + alias = 0u; + selection = 0u; + } + } + + // initialize properties + o2::common::eventselection::bcselEntry entry; + entry.alias = alias; + entry.selection = selection; + entry.rct = rct; + entry.foundFT0Id = foundFT0; + entry.foundFV0Id = foundFV0; + entry.foundFDDId = foundFDD; + entry.foundZDCId = foundZDC; + bcselbuffer.push_back(entry); + + // Fill bc selection columns + bcsel(alias, selection, rct, foundFT0, foundFV0, foundFDD, foundZDC); + } // end bc loop + } // end processRun3 +}; // end BcSelectionModule + +class EventSelectionModule +{ + public: + EventSelectionModule() + { + // constructor + } + + int run3min = 500000; + int lastRun = -1; // last run number (needed to access ccdb only if run!=lastRun) + std::bitset bcPatternB; // bc pattern of colliding bunches + + int64_t bcSOR = -1; // global bc of the start of the first orbit + int64_t nBCsPerTF = -1; // duration of TF in bcs, should be 128*3564 or 32*3564 + int rofOffset = -1; // ITS ROF offset, in bc + int rofLength = -1; // ITS ROF length, in bc + std::string strLPMProductionTag = ""; // MC production tag to be retrieved from AO2D metadata + + int32_t findClosest(int64_t globalBC, std::map& bcs) + { + auto it = bcs.lower_bound(globalBC); + int64_t bc1 = it->first; + int32_t index1 = it->second; + if (it != bcs.begin()) + --it; + int64_t bc2 = it->first; + int32_t index2 = it->second; + int64_t dbc1 = std::abs(bc1 - globalBC); + int64_t dbc2 = std::abs(bc2 - globalBC); + return (dbc1 <= dbc2) ? index1 : index2; + } + + // helper function to find median time in the vector of TOF or TRD-track times + float getMedian(std::vector v) + { + int medianIndex = v.size() / 2; + std::nth_element(v.begin(), v.begin() + medianIndex, v.end()); + return v[medianIndex]; + } + + // helper function to find closest TVX signal in time and in zVtx + int64_t findBestGlobalBC(int64_t meanBC, int64_t sigmaBC, int32_t nContrib, float zVtxCol, std::map& mapGlobalBcVtxZ) + { + // protection against + if (sigmaBC < 1) + sigmaBC = 1; + + int64_t minBC = meanBC - 3 * sigmaBC; + int64_t maxBC = meanBC + 3 * sigmaBC; + // TODO: use ITS ROF bounds to reduce the search range? + + float zVtxSigma = 2.7 * std::pow(nContrib, -0.466) + 0.024; + zVtxSigma += 1.0; // additional uncertainty due to imperfectections of FT0 time calibration + + auto itMin = mapGlobalBcVtxZ.lower_bound(minBC); + auto itMax = mapGlobalBcVtxZ.upper_bound(maxBC); + + float bestChi2 = 1e+10; + int64_t bestGlobalBC = 0; + for (std::map::iterator it = itMin; it != itMax; ++it) { + float chi2 = std::pow((it->second - zVtxCol) / zVtxSigma, 2) + std::pow(static_cast(it->first - meanBC) / sigmaBC, 2.); + if (chi2 < bestChi2) { + bestChi2 = chi2; + bestGlobalBC = it->first; + } + } + + return bestGlobalBC; + } + + // declaration of structs here + // (N.B.: will be invisible to the outside, create your own copies) + o2::common::eventselection::evselConfigurables evselOpts; + + template + void init(TContext& context, TEvSelOpts const& external_evselopts, THistoRegistry& histos, TMetadataInfo const& metadataInfo) + { + // read in configurations from the task where it's used + evselOpts = external_evselopts; + + if (evselOpts.amIneeded.value < 0) { + enableFlagIfTableRequired(context, "EvSels", evselOpts.amIneeded.value); + if (evselOpts.amIneeded.value == 0) { + LOGF(info, "Event Selection / Autodetecting for aod::EvSels: not required, won't generate."); + return; + } else { + LOGF(info, "Event Selection / Autodetecting for aod::EvSels: subscription present, will generate."); + } + } + + if (metadataInfo.isFullyDefined()) { // Check if the metadata is initialized (only if not forced from the workflow configuration) + if (evselOpts.isMC == -1) { + LOGF(info, "Autosetting the MC mode based on metadata (isMC? %i)", metadataInfo.isMC()); + if (metadataInfo.isMC()) { + evselOpts.isMC.value = 1; + } else { + evselOpts.isMC.value = 0; + } + } + } + strLPMProductionTag = metadataInfo.get("LPMProductionTag"); // to extract info from ccdb by the tag + + histos.add("eventselection/hColCounterAll", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("eventselection/hColCounterTVX", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("eventselection/hColCounterAcc", "", framework::kTH1D, {{1, 0., 1.}}); + } + + //__________________________________________________ + template + bool configure(TCCDB& ccdb, TTimestamps const& timestamps, TBCs const& bcs) + { + int run = bcs.iteratorAt(0).runNumber(); + // extract bc pattern from CCDB for data or anchored MC only + if (run != lastRun && run >= run3min) { + lastRun = run; + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run, strLPMProductionTag); + // first bc of the first orbit + bcSOR = runInfo.orbitSOR * nBCsPerOrbit; + // duration of TF in bcs + nBCsPerTF = evselOpts.confNumberOfOrbitsPerTF < 0 ? runInfo.orbitsPerTF * nBCsPerOrbit : evselOpts.confNumberOfOrbitsPerTF * nBCsPerOrbit; + // colliding bc pattern + int64_t ts = timestamps[0]; + + // getForTimeStamp replaced with getSpecific to set metadata to zero + // avoids crash related to specific run number + auto grplhcif = ccdb->template getSpecific("GLO/Config/GRPLHCIF", ts); + bcPatternB = grplhcif->getBunchFilling().getBCPattern(); + + // extract ITS ROF parameters + auto alppar = ccdb->template getForTimeStamp>("ITS/Config/AlpideParam", ts); + rofOffset = alppar->roFrameBiasInBC; + rofLength = alppar->roFrameLengthInBC; + LOGP(debug, "ITS ROF Offset={} ITS ROF Length={}", rofOffset, rofLength); + } // if run != lastRun + return true; + } + + //__________________________________________________ + template + void processRun2(TCCDB const& ccdb, THistoRegistry& histos, TCollisions const& collisions, TTracklets const& tracklets, TSlicecache& cache, TTimestamps const& timestamps, TBcSelBuffer const& bcselbuffer, TEvselCursor& evsel) + { + if (evselOpts.amIneeded.value == 0) { + return; // dummy process + } + for (const auto& col : collisions) { + auto bc = col.template bc_as>(); + uint64_t timestamp = timestamps[bc.globalIndex()]; + EventSelectionParams* par = ccdb->template getForTimeStamp("EventSelection/EventSelectionParams", timestamp); + bool* applySelection = par->getSelection(evselOpts.muonSelection); + if (evselOpts.isMC == 1) { + applySelection[aod::evsel::kIsBBZAC] = 0; + applySelection[aod::evsel::kNoV0MOnVsOfPileup] = 0; + applySelection[aod::evsel::kNoSPDOnVsOfPileup] = 0; + applySelection[aod::evsel::kNoV0Casymmetry] = 0; + applySelection[aod::evsel::kNoV0PFPileup] = 0; + } + + int32_t foundBC = bc.globalIndex(); + int32_t foundFT0 = bcselbuffer[foundBC].foundFT0Id; + int32_t foundFV0 = bcselbuffer[foundBC].foundFV0Id; + int32_t foundFDD = bcselbuffer[foundBC].foundFDDId; + int32_t foundZDC = bcselbuffer[foundBC].foundZDCId; + + // copy alias decisions from bcsel table + uint32_t alias = bcselbuffer[foundBC].alias; + + // copy selection decisions from bcsel table + uint64_t selection = bcselbuffer[foundBC].selection; + + // copy rct flags from bcsel table + uint32_t rct = bcselbuffer[foundBC].rct; + + // calculate V0C012 multiplicity + float multRingV0C[4] = {0.}; + if (bc.has_fv0c()) { + for (unsigned int i = 0; i < bc.fv0c().amplitude().size(); ++i) { + int ring = bc.fv0c().channel()[i] / 8; + multRingV0C[ring] += bc.fv0c().amplitude()[i]; + } + } + float multV0C012 = multRingV0C[0] + multRingV0C[1] + multRingV0C[2]; + + // applying selections depending on the number of tracklets + auto trackletsGrouped = tracklets.sliceByCached(aod::track::collisionId, col.globalIndex(), cache); + int nTkl = trackletsGrouped.size(); + int spdClusters = bc.spdClustersL0() + bc.spdClustersL1(); + + selection |= (spdClusters < par->fSPDClsVsTklA + nTkl * par->fSPDClsVsTklB) ? BIT(aod::evsel::kNoSPDClsVsTklBG) : 0; + selection |= !(nTkl < 6 && multV0C012 > par->fV0C012vsTklA + nTkl * par->fV0C012vsTklB) ? BIT(aod::evsel::kNoV0C012vsTklBG) : 0; // o2-linter: disable=magic-number (nTkl dependent parameterization) + + // apply int7-like selections + bool sel7 = 1; + for (int i = 0; i < aod::evsel::kNsel; i++) { + sel7 = sel7 && (applySelection[i] ? TESTBIT(selection, i) : 1); + } + + // TODO introduce array of sel[0]... sel[8] or similar? + bool sel8 = bitcheck64(selection, aod::evsel::kIsBBT0A) && bitcheck64(selection, aod::evsel::kIsBBT0C); // TODO apply other cuts for sel8 + bool sel1 = bitcheck64(selection, aod::evsel::kIsINT1); + sel1 = sel1 && bitcheck64(selection, aod::evsel::kNoBGV0A); + sel1 = sel1 && bitcheck64(selection, aod::evsel::kNoBGV0C); + sel1 = sel1 && bitcheck64(selection, aod::evsel::kNoTPCLaserWarmUp); + sel1 = sel1 && bitcheck64(selection, aod::evsel::kNoTPCHVdip); + + // INT1 (SPDFO>0 | V0A | V0C) minimum bias trigger logic used in pp2010 and pp2011 + bool isINT1period = bc.runNumber() <= 136377 || (bc.runNumber() >= 144871 && bc.runNumber() <= 159582); // o2-linter: disable=magic-number (magic run numbers) + + // fill counters + if (evselOpts.isMC == 1 || (!isINT1period && bitcheck(alias, kINT7)) || (isINT1period && bitcheck(alias, kINT1))) { + histos.template get(HIST("eventselection/hColCounterAll"))->Fill(Form("%d", bc.runNumber()), 1); + if ((!isINT1period && sel7) || (isINT1period && sel1)) { + histos.template get(HIST("eventselection/hColCounterAcc"))->Fill(Form("%d", bc.runNumber()), 1); + } + } + + evsel(alias, selection, rct, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, 0, 0); + } + } // end processRun2 + + //__________________________________________________ + template + void processRun3(TCCDB const& ccdb, THistoRegistry& histos, TBCs const& bcs, TCollisions const& cols, TPVTracks const& pvTracks, TFT0s const& ft0s, TSlicecache& cache, TTimestamps const& timestamps, TBcSelBuffer const& bcselbuffer, TEvselCursor& evsel) + { + if (evselOpts.amIneeded.value == 0) { + return; // dummy process + } + if (!configure(ccdb, timestamps, bcs)) + return; // don't do anything in case configuration reported not ok + + int run = bcs.iteratorAt(0).runNumber(); + // create maps from globalBC to bc index for TVX-fired bcs + // to be used for closest TVX searches + std::map mapGlobalBcWithTVX; + std::map mapGlobalBcVtxZ; + for (const auto& bc : bcs) { + int64_t globalBC = bc.globalBC(); + // skip non-colliding bcs for data and anchored runs + if (run >= run3min && bcPatternB[globalBC % nBCsPerOrbit] == 0) { + continue; + } + auto selection = bcselbuffer[bc.globalIndex()].selection; + if (bitcheck64(selection, aod::evsel::kIsTriggerTVX)) { + mapGlobalBcWithTVX[globalBC] = bc.globalIndex(); + mapGlobalBcVtxZ[globalBC] = bc.has_ft0() ? bc.ft0().posZ() : 0; + } + } + + // protection against empty FT0 maps + if (mapGlobalBcWithTVX.size() == 0) { + LOGP(error, "FT0 table is empty or corrupted. Filling evsel table with dummy values"); + for (const auto& col : cols) { + auto bc = col.template bc_as>(); + int32_t foundBC = bc.globalIndex(); + int32_t foundFT0 = bcselbuffer[bc.globalIndex()].foundFT0Id; + int32_t foundFV0 = bcselbuffer[bc.globalIndex()].foundFV0Id; + int32_t foundFDD = bcselbuffer[bc.globalIndex()].foundFDDId; + int32_t foundZDC = bcselbuffer[bc.globalIndex()].foundZDCId; + uint32_t rct = 0; + evsel(bcselbuffer[bc.globalIndex()].alias, bcselbuffer[bc.globalIndex()].selection, rct, kFALSE, kFALSE, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, -1, -1); + } + return; + } + std::vector vTracksITS567perColl(cols.size(), 0); // counter of tracks per collision for occupancy studies + std::vector vAmpFT0CperColl(cols.size(), 0); // amplitude FT0C per collision + std::vector vCollVz(cols.size(), 0); // vector with vZ positions for each collision + std::vector vIsFullInfoForOccupancy(cols.size(), 0); // info for occupancy in +/- windows is available (i.e. a given coll is not too close to the TF borders) + const float timeWinOccupancyCalcMinNS = evselOpts.confTimeIntervalForOccupancyCalculationMin * 1e3; // ns + const float timeWinOccupancyCalcMaxNS = evselOpts.confTimeIntervalForOccupancyCalculationMax * 1e3; // ns + std::vector vIsVertexITSTPC(cols.size(), 0); // at least one of vertex contributors is ITS-TPC track + std::vector vIsVertexTOFmatched(cols.size(), 0); // at least one of vertex contributors is matched to TOF + std::vector vIsVertexTRDmatched(cols.size(), 0); // at least one of vertex contributors is matched to TRD + + std::vector vCollisionsPerBc(bcs.size(), 0); // counter of collisions per found bc for pileup checks + std::vector vFoundBCindex(cols.size(), -1); // indices of found bcs + std::vector vFoundGlobalBC(cols.size(), 0); // global BCs for collisions + + std::vector vIsVertexTOF(cols.size(), 0); + std::vector vIsVertexTRD(cols.size(), 0); + std::vector vIsVertexTPC(cols.size(), 0); + std::vector vIsVertexHighPtTPC(cols.size(), 0); + std::vector vNcontributors(cols.size(), 0); + std::vector vWeightedTimesTPCnoTOFnoTRD(cols.size(), 0); + std::vector vWeightedSigmaTPCnoTOFnoTRD(cols.size(), 0); + + // temporary vectors to find tracks with median time + std::vector vTrackTimesTOF; + std::vector vTrackTimesTRDnoTOF; + + // first loop to match collisions to TVX, also extract other per-collision information for further use + for (const auto& col : cols) { + int32_t colIndex = col.globalIndex(); + auto bc = col.template bc_as>(); + + vCollVz[colIndex] = col.posZ(); + + int64_t globalBC = bc.globalBC(); + int bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; + vIsFullInfoForOccupancy[colIndex] = ((bcInTF - 300) * bcNS > -timeWinOccupancyCalcMinNS) && ((nBCsPerTF - 4000 - bcInTF) * bcNS > timeWinOccupancyCalcMaxNS) ? true : false; + + const auto& colPvTracks = pvTracks.sliceByCached(aod::track::collisionId, col.globalIndex(), cache); + vTrackTimesTOF.clear(); + vTrackTimesTRDnoTOF.clear(); + int nPvTracksTPCnoTOFnoTRD = 0; + int nPvTracksHighPtTPCnoTOFnoTRD = 0; + float sumTime = 0, sumW = 0, sumHighPtTime = 0, sumHighPtW = 0; + for (const auto& track : colPvTracks) { + float trackTime = track.trackTime(); + if (track.itsNCls() >= 5) // o2-linter: disable=magic-number (indeed counting layers 5 6 7) + vTracksITS567perColl[colIndex]++; + if (track.hasTRD()) + vIsVertexTRDmatched[colIndex] = 1; + if (track.hasTPC()) + vIsVertexITSTPC[colIndex] = 1; + if (track.hasTOF()) { + vTrackTimesTOF.push_back(trackTime); + vIsVertexTOFmatched[colIndex] = 1; + } else if (track.hasTRD()) { + vTrackTimesTRDnoTOF.push_back(trackTime); + } else if (track.hasTPC()) { + float trackTimeRes = track.trackTimeRes(); + float trackPt = track.pt(); + float w = 1. / (trackTimeRes * trackTimeRes); + sumTime += trackTime * w; + sumW += w; + nPvTracksTPCnoTOFnoTRD++; + if (trackPt > 1) { + sumHighPtTime += trackTime * w; + sumHighPtW += w; + nPvTracksHighPtTPCnoTOFnoTRD++; + } + } + } + vWeightedTimesTPCnoTOFnoTRD[colIndex] = sumW > 0 ? sumTime / sumW : 0; + vWeightedSigmaTPCnoTOFnoTRD[colIndex] = sumW > 0 ? std::sqrt(1. / sumW) : 0; + vNcontributors[colIndex] = colPvTracks.size(); + int nPvTracksTOF = vTrackTimesTOF.size(); + int nPvTracksTRDnoTOF = vTrackTimesTRDnoTOF.size(); + // collision type + vIsVertexTOF[colIndex] = nPvTracksTOF > 0; + vIsVertexTRD[colIndex] = nPvTracksTRDnoTOF > 0; + vIsVertexTPC[colIndex] = nPvTracksTPCnoTOFnoTRD > 0; + vIsVertexHighPtTPC[colIndex] = nPvTracksHighPtTPCnoTOFnoTRD > 0; + + int64_t foundGlobalBC = 0; + int32_t foundBCindex = -1; + + if (nPvTracksTOF > 0) { + // for collisions with TOF tracks: + // take bc corresponding to TOF track with median time + int64_t tofGlobalBC = globalBC + TMath::Nint(getMedian(vTrackTimesTOF) / bcNS); + std::map::iterator it = mapGlobalBcWithTVX.find(tofGlobalBC); + if (it != mapGlobalBcWithTVX.end()) { + foundGlobalBC = it->first; + foundBCindex = it->second; + } + } else if (nPvTracksTPCnoTOFnoTRD == 0 && nPvTracksTRDnoTOF > 0) { + // for collisions with TRD tracks but without TOF or ITSTPC-only tracks: + // take bc corresponding to TRD track with median time + int64_t trdGlobalBC = globalBC + TMath::Nint(getMedian(vTrackTimesTRDnoTOF) / bcNS); + std::map::iterator it = mapGlobalBcWithTVX.find(trdGlobalBC); + if (it != mapGlobalBcWithTVX.end()) { + foundGlobalBC = it->first; + foundBCindex = it->second; + } + } else if (nPvTracksHighPtTPCnoTOFnoTRD > 0) { + // for collisions with high-pt ITSTPC-nonTOF-nonTRD tracks + // search in 3*confSigmaBCforHighPtTracks range (3*4 bcs by default) + int64_t meanBC = globalBC + TMath::Nint(sumHighPtTime / sumHighPtW / bcNS); + int64_t bestGlobalBC = findBestGlobalBC(meanBC, evselOpts.confSigmaBCforHighPtTracks, vNcontributors[colIndex], col.posZ(), mapGlobalBcVtxZ); + if (bestGlobalBC > 0) { + foundGlobalBC = bestGlobalBC; + foundBCindex = mapGlobalBcWithTVX[bestGlobalBC]; + } + } + + // fill foundBC indices and global BCs + // keep current bc if TVX matching failed at this step + vFoundBCindex[colIndex] = foundBCindex >= 0 ? foundBCindex : bc.globalIndex(); + vFoundGlobalBC[colIndex] = foundGlobalBC > 0 ? foundGlobalBC : globalBC; + + // erase found global BC with TVX from the pool of bcs for the next loop over low-pt TPCnoTOFnoTRD collisions + if (foundBCindex >= 0) + mapGlobalBcVtxZ.erase(foundGlobalBC); + } + + // second loop to match remaining low-pt TPCnoTOFnoTRD collisions + for (const auto& col : cols) { + int32_t colIndex = col.globalIndex(); + if (vIsVertexTPC[colIndex] > 0 && vIsVertexTOF[colIndex] == 0 && vIsVertexHighPtTPC[colIndex] == 0) { + float weightedTime = vWeightedTimesTPCnoTOFnoTRD[colIndex]; + float weightedSigma = vWeightedSigmaTPCnoTOFnoTRD[colIndex]; + auto bc = col.template bc_as>(); + int64_t globalBC = bc.globalBC(); + int64_t meanBC = globalBC + TMath::Nint(weightedTime / bcNS); + int64_t sigmaBC = TMath::CeilNint(weightedSigma / bcNS); + int64_t bestGlobalBC = findBestGlobalBC(meanBC, sigmaBC, vNcontributors[colIndex], col.posZ(), mapGlobalBcVtxZ); + vFoundGlobalBC[colIndex] = bestGlobalBC > 0 ? bestGlobalBC : globalBC; + vFoundBCindex[colIndex] = bestGlobalBC > 0 ? mapGlobalBcWithTVX[bestGlobalBC] : bc.globalIndex(); + } + // fill pileup counter + vCollisionsPerBc[vFoundBCindex[colIndex]]++; + } + + // save indices of collisions for occupancy calculation (both in ROF and in time range) + std::vector> vCollsInSameITSROF; + std::vector> vCollsInPrevITSROF; + std::vector> vCollsInTimeWin; + std::vector> vTimeDeltaForColls; // delta time wrt a given collision + for (const auto& col : cols) { + int32_t colIndex = col.globalIndex(); + int64_t foundGlobalBC = vFoundGlobalBC[colIndex]; + auto bcselEntr = bcselbuffer[vFoundBCindex[colIndex]]; + if (bcselEntr.foundFT0Id > -1) { + // required: explicit ft0s table + auto foundFT0 = ft0s.rawIteratorAt(bcselEntr.foundFT0Id); + vAmpFT0CperColl[colIndex] = foundFT0.sumAmpC(); + } + + int64_t tfId = (foundGlobalBC - bcSOR) / nBCsPerTF; + int64_t rofId = (foundGlobalBC + nBCsPerOrbit - rofOffset) / rofLength; + + // ### for in-ROF occupancy + std::vector vAssocCollInSameROF; + // find all collisions in the same ROF before a given collision + int32_t minColIndex = colIndex - 1; + while (minColIndex >= 0) { + int64_t thisBC = vFoundGlobalBC[minColIndex]; + // check if this is still the same TF + int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; + if (thisTFid != tfId) + break; + // int thisRofIdInTF = (thisBC - rofOffset) / rofLength; + int64_t thisRofId = (thisBC + nBCsPerOrbit - rofOffset) / rofLength; + + // check if we are within the same ROF + if (thisRofId != rofId) + break; + vAssocCollInSameROF.push_back(minColIndex); + minColIndex--; + } + // find all collisions in the same ROF after the current one + int32_t maxColIndex = colIndex + 1; + while (maxColIndex < cols.size()) { + int64_t thisBC = vFoundGlobalBC[maxColIndex]; + int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; + if (thisTFid != tfId) + break; + int64_t thisRofId = (thisBC + nBCsPerOrbit - rofOffset) / rofLength; + if (thisRofId != rofId) + break; + vAssocCollInSameROF.push_back(maxColIndex); + maxColIndex++; + } + vCollsInSameITSROF.push_back(vAssocCollInSameROF); + + // ### bookkeep collisions in previous ROF + std::vector vAssocCollInPrevROF; + minColIndex = colIndex - 1; + while (minColIndex >= 0) { + int64_t thisBC = vFoundGlobalBC[minColIndex]; + // check if this is still the same TF + int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; + if (thisTFid != tfId) + break; + int64_t thisRofId = (thisBC + nBCsPerOrbit - rofOffset) / rofLength; + if (thisRofId == rofId - 1) + vAssocCollInPrevROF.push_back(minColIndex); + else if (thisRofId < rofId - 1) + break; + minColIndex--; + } + vCollsInPrevITSROF.push_back(vAssocCollInPrevROF); + + // ### for occupancy in time windows + std::vector vAssocToThisCol; + std::vector vCollsTimeDeltaWrtGivenColl; + // protection against the TF borders + if (!vIsFullInfoForOccupancy[colIndex]) { + vCollsInTimeWin.push_back(vAssocToThisCol); + vTimeDeltaForColls.push_back(vCollsTimeDeltaWrtGivenColl); + continue; + } + // find all collisions in time window before the current one + minColIndex = colIndex - 1; + while (minColIndex >= 0) { + int64_t thisBC = vFoundGlobalBC[minColIndex]; + // check if this is still the same TF + int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; + if (thisTFid != tfId) + break; + float dt = (thisBC - foundGlobalBC) * bcNS; // ns + // check if we are within the chosen time range + if (dt < timeWinOccupancyCalcMinNS) + break; + vAssocToThisCol.push_back(minColIndex); + vCollsTimeDeltaWrtGivenColl.push_back(dt); + minColIndex--; + } + // find all collisions in time window after the current one + maxColIndex = colIndex + 1; + while (maxColIndex < cols.size()) { + int64_t thisBC = vFoundGlobalBC[maxColIndex]; + int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; + if (thisTFid != tfId) + break; + float dt = (thisBC - foundGlobalBC) * bcNS; // ns + if (dt > timeWinOccupancyCalcMaxNS) + break; + vAssocToThisCol.push_back(maxColIndex); + vCollsTimeDeltaWrtGivenColl.push_back(dt); + maxColIndex++; + } + vCollsInTimeWin.push_back(vAssocToThisCol); + vTimeDeltaForColls.push_back(vCollsTimeDeltaWrtGivenColl); + } + + // perform the occupancy calculation per ITS ROF and also in the pre-defined time window + std::vector vNumTracksITS567inFullTimeWin(cols.size(), 0); // counter of tracks in full time window for occupancy studies (excluding given event) + std::vector vSumAmpFT0CinFullTimeWin(cols.size(), 0); // sum of FT0C of tracks in full time window for occupancy studies (excluding given event) + + std::vector vNoCollInTimeRangeStrict(cols.size(), 0); // no collisions in a specified time range + std::vector vNoCollInTimeRangeNarrow(cols.size(), 0); // no collisions in a specified time range (narrow) + std::vector vNoHighMultCollInTimeRange(cols.size(), 0); // no high-mult collisions in a specified time range + + std::vector vNoCollInSameRofStrict(cols.size(), 0); // to veto events with other collisions in the same ITS ROF + std::vector vNoCollInSameRofStandard(cols.size(), 0); // to veto events with other collisions in the same ITS ROF, with per-collision multiplicity above threshold + std::vector vNoCollInSameRofWithCloseVz(cols.size(), 0); // to veto events with nearby collisions with close vZ + std::vector vNoHighMultCollInPrevRof(cols.size(), 0); // veto events if FT0C amplitude in previous ITS ROF is above threshold + + for (const auto& col : cols) { + int32_t colIndex = col.globalIndex(); + float vZ = col.posZ(); + + // ### in-ROF occupancy + std::vector vAssocCollInSameROF = vCollsInSameITSROF[colIndex]; + int nITS567tracksForSameRofVetoStrict = 0; // to veto events with other collisions in the same ITS ROF + int nCollsInRofWithFT0CAboveVetoStandard = 0; // to veto events with other collisions in the same ITS ROF, with per-collision multiplicity above threshold + int nITS567tracksForRofVetoOnCloseVz = 0; // to veto events with nearby collisions with close vZ + for (uint32_t iCol = 0; iCol < vAssocCollInSameROF.size(); iCol++) { + int thisColIndex = vAssocCollInSameROF[iCol]; + nITS567tracksForSameRofVetoStrict += vTracksITS567perColl[thisColIndex]; + if (vAmpFT0CperColl[thisColIndex] > evselOpts.confFT0CamplCutVetoOnCollInROF) + nCollsInRofWithFT0CAboveVetoStandard++; + if (std::fabs(vCollVz[thisColIndex] - vZ) < evselOpts.confEpsilonVzDiffVetoInROF) + nITS567tracksForRofVetoOnCloseVz += vTracksITS567perColl[thisColIndex]; + } + // in-ROF occupancy flags + vNoCollInSameRofStrict[colIndex] = (nITS567tracksForSameRofVetoStrict == 0); + vNoCollInSameRofStandard[colIndex] = (nCollsInRofWithFT0CAboveVetoStandard == 0); + vNoCollInSameRofWithCloseVz[colIndex] = (nITS567tracksForRofVetoOnCloseVz == 0); + + // ### occupancy in previous ROF + std::vector vAssocCollInPrevROF = vCollsInPrevITSROF[colIndex]; + float totalFT0amplInPrevROF = 0; + for (uint32_t iCol = 0; iCol < vAssocCollInPrevROF.size(); iCol++) { + int thisColIndex = vAssocCollInPrevROF[iCol]; + totalFT0amplInPrevROF += vAmpFT0CperColl[thisColIndex]; + } + // veto events if FT0C amplitude in previous ITS ROF is above threshold + vNoHighMultCollInPrevRof[colIndex] = (totalFT0amplInPrevROF < evselOpts.confFT0CamplCutVetoOnCollInROF); + + // ### occupancy in time windows + // protection against TF borders + if (!vIsFullInfoForOccupancy[colIndex]) { // occupancy in undefined (too close to TF borders) + vNumTracksITS567inFullTimeWin[colIndex] = -1; + vSumAmpFT0CinFullTimeWin[colIndex] = -1; + continue; + } + std::vector vAssocToThisCol = vCollsInTimeWin[colIndex]; + std::vector vCollsTimeDeltaWrtGivenColl = vTimeDeltaForColls[colIndex]; + int nITS567tracksInFullTimeWindow = 0; + float sumAmpFT0CInFullTimeWindow = 0; + int nITS567tracksForVetoNarrow = 0; // to veto events with nearby collisions (narrower range) + int nITS567tracksForVetoStrict = 0; // to veto events with nearby collisions + int nCollsWithFT0CAboveVetoStandard = 0; // to veto events with per-collision multiplicity above threshold + for (uint32_t iCol = 0; iCol < vAssocToThisCol.size(); iCol++) { + int thisColIndex = vAssocToThisCol[iCol]; + float dt = vCollsTimeDeltaWrtGivenColl[iCol] / 1e3; // ns -> us + float wOccup = 1.; + if (evselOpts.confUseWeightsForOccupancyVariable) { + // weighted occupancy + wOccup = 0; + if (dt >= -40 && dt < -5) // collisions in the past // o2-linter: disable=magic-number (to be checked by Igor) + wOccup = 1. / 1225 * (dt + 40) * (dt + 40); // o2-linter: disable=magic-number (to be checked by Igor) + else if (dt >= -5 && dt < 15) // collisions near a given one // o2-linter: disable=magic-number (to be checked by Igor) + wOccup = 1; + // else if (dt >= 15 && dt < 100) // collisions from the future + // wOccup = -1. / 85 * dt + 20. / 17; + else if (dt >= 15 && dt < 40) // collisions from the future // o2-linter: disable=magic-number (to be checked by Igor) + wOccup = -0.4 / 25 * dt + 1.24; // o2-linter: disable=magic-number (to be checked by Igor) + else if (dt >= 40 && dt < 100) // collisions from the distant future // o2-linter: disable=magic-number (to be checked by Igor) + wOccup = -0.4 / 60 * dt + 0.6 + 0.8 / 3; // o2-linter: disable=magic-number (to be checked by Igor) + } + nITS567tracksInFullTimeWindow += wOccup * vTracksITS567perColl[thisColIndex]; + sumAmpFT0CInFullTimeWindow += wOccup * vAmpFT0CperColl[thisColIndex]; + + // counting tracks from other collisions in fixed time windows + if (std::fabs(dt) < evselOpts.confTimeRangeVetoOnCollNarrow) + nITS567tracksForVetoNarrow += vTracksITS567perColl[thisColIndex]; + if (std::fabs(dt) < evselOpts.confTimeRangeVetoOnCollStandard) + nITS567tracksForVetoStrict += vTracksITS567perColl[thisColIndex]; + + // standard cut on other collisions vs delta-times + const float driftV = 2.5; // drift velocity in cm/us, TPC drift_length / drift_time = 250 cm / 100 us + if (std::fabs(dt) < 2.0) { // us, complete veto on other collisions // o2-linter: disable=magic-number (to be checked by Igor) + nCollsWithFT0CAboveVetoStandard++; + } else if (dt > -4.0 && dt <= -2.0) { // us, strict veto to suppress fake ITS-TPC matches more // o2-linter: disable=magic-number (to be checked by Igor) + if (vAmpFT0CperColl[thisColIndex] > evselOpts.confFT0CamplCutVetoOnCollInTimeRange / 5) + nCollsWithFT0CAboveVetoStandard++; + } else if (std::fabs(dt) < 8 + std::fabs(vZ) / driftV) { // loose veto, 8 us corresponds to maximum possible |vZ|, which is ~20 cm // o2-linter: disable=magic-number (to be checked by Igor) + // counting number of other collisions with multiplicity above threshold + if (vAmpFT0CperColl[thisColIndex] > evselOpts.confFT0CamplCutVetoOnCollInTimeRange) + nCollsWithFT0CAboveVetoStandard++; + } + } + vNumTracksITS567inFullTimeWin[colIndex] = nITS567tracksInFullTimeWindow; // occupancy by a sum of number of ITS tracks (without a current collision) + vSumAmpFT0CinFullTimeWin[colIndex] = sumAmpFT0CInFullTimeWindow; // occupancy by a sum of FT0C amplitudes (without a current collision) + // occupancy flags based on nearby collisions + vNoCollInTimeRangeNarrow[colIndex] = (nITS567tracksForVetoNarrow == 0); + vNoCollInTimeRangeStrict[colIndex] = (nITS567tracksForVetoStrict == 0); + vNoHighMultCollInTimeRange[colIndex] = (nCollsWithFT0CAboveVetoStandard == 0); + } + + for (const auto& col : cols) { + int32_t colIndex = col.globalIndex(); + int32_t foundBC = vFoundBCindex[colIndex]; + auto bc = bcs.iteratorAt(foundBC); + auto bcselEntry = bcselbuffer[foundBC]; + int32_t foundFT0 = bcselEntry.foundFT0Id; + int32_t foundFV0 = bcselEntry.foundFV0Id; + int32_t foundFDD = bcselEntry.foundFDDId; + int32_t foundZDC = bcselEntry.foundZDCId; + + // compare zVtx from FT0 and from PV + bool isGoodZvtxFT0vsPV = 0; + if (bcselEntry.foundFT0Id > -1) { + auto foundFT0 = ft0s.rawIteratorAt(bcselEntry.foundFT0Id); + isGoodZvtxFT0vsPV = std::fabs(foundFT0.posZ() - col.posZ()) < evselOpts.maxDiffZvtxFT0vsPV; + } + + // copy alias decisions from bcsel table + uint32_t alias = bcselEntry.alias; + + // copy selection decisions from bcsel table + uint64_t selection = bcselbuffer[bc.globalIndex()].selection; + selection |= vCollisionsPerBc[foundBC] <= 1 ? BIT(aod::evsel::kNoSameBunchPileup) : 0; + selection |= vIsVertexITSTPC[colIndex] ? BIT(aod::evsel::kIsVertexITSTPC) : 0; + selection |= vIsVertexTOFmatched[colIndex] ? BIT(aod::evsel::kIsVertexTOFmatched) : 0; + selection |= vIsVertexTRDmatched[colIndex] ? BIT(aod::evsel::kIsVertexTRDmatched) : 0; + selection |= isGoodZvtxFT0vsPV ? BIT(aod::evsel::kIsGoodZvtxFT0vsPV) : 0; + + // selection bits based on occupancy time pattern + selection |= vNoCollInTimeRangeNarrow[colIndex] ? BIT(aod::evsel::kNoCollInTimeRangeNarrow) : 0; + selection |= vNoCollInTimeRangeStrict[colIndex] ? BIT(aod::evsel::kNoCollInTimeRangeStrict) : 0; + selection |= vNoHighMultCollInTimeRange[colIndex] ? BIT(aod::evsel::kNoCollInTimeRangeStandard) : 0; + + // selection bits based on ITS in-ROF occupancy + selection |= vNoCollInSameRofStrict[colIndex] ? BIT(aod::evsel::kNoCollInRofStrict) : 0; + selection |= (vNoCollInSameRofStandard[colIndex] && vNoCollInSameRofWithCloseVz[colIndex]) ? BIT(aod::evsel::kNoCollInRofStandard) : 0; + selection |= vNoHighMultCollInPrevRof[colIndex] ? BIT(aod::evsel::kNoHighMultCollInPrevRof) : 0; + + // copy rct flags from bcsel table + uint32_t rct = bcselEntry.rct; + + // apply int7-like selections + bool sel7 = 0; + + // TODO apply other cuts for sel8 + // TODO introduce sel1 etc? + // TODO introduce array of sel[0]... sel[8] or similar? + bool sel8 = bitcheck64(bcselEntry.selection, aod::evsel::kIsTriggerTVX) && bitcheck64(bcselEntry.selection, aod::evsel::kNoTimeFrameBorder) && bitcheck64(bcselEntry.selection, aod::evsel::kNoITSROFrameBorder); + + // fill counters + histos.template get(HIST("eventselection/hColCounterAll"))->Fill(Form("%d", bc.runNumber()), 1); + if (bitcheck64(bcselEntry.selection, aod::evsel::kIsTriggerTVX)) { + histos.template get(HIST("eventselection/hColCounterTVX"))->Fill(Form("%d", bc.runNumber()), 1); + } + if (sel8) { + histos.template get(HIST("eventselection/hColCounterAcc"))->Fill(Form("%d", bc.runNumber()), 1); + } + + evsel(alias, selection, rct, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, + vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); + } + } // end processRun3 +}; // end EventSelectionModule + +class LumiModule +{ + public: + LumiModule() + { + // constructor + } + + int lastRun = -1; // last run number (needed to access ccdb only if run!=lastRun) + float csTVX = -1; // dummy -1 for the visible TVX cross section (in ub) used in lumi accounting + float csTCE = -1; // dummy -1 for the visible TCE cross section (in ub) used in lumi accounting + float csZEM = -1; // dummy -1 for the visible ZEM cross section (in ub) used in lumi accounting + float csZNC = -1; // dummy -1 for the visible ZNC cross section (in ub) used in lumi accounting + + std::vector mOrbits; + std::vector mPileupCorrectionTVX; + std::vector mPileupCorrectionTCE; + std::vector mPileupCorrectionZEM; + std::vector mPileupCorrectionZNC; + + int64_t minOrbitInRange = std::numeric_limits::max(); + int64_t maxOrbitInRange = 0; + uint32_t currentOrbitIndex = 0; + std::bitset bcPatternB; // bc pattern of colliding bunches + std::vector mRCTFlagsCheckers; + + // declaration of structs here + // (N.B.: will be invisible to the outside, create your own copies) + o2::common::eventselection::lumiConfigurables lumiOpts; + + template + void init(TContext& context, TLumiOpts const& external_lumiopts, THistoRegistry& histos) + { + lumiOpts = external_lumiopts; + + if (lumiOpts.amIneeded.value < 0) { + int bcSelNeeded = -1, evSelNeeded = -1; + lumiOpts.amIneeded.value = 0; + enableFlagIfTableRequired(context, "BcSels", bcSelNeeded); + enableFlagIfTableRequired(context, "EvSels", evSelNeeded); + if (bcSelNeeded == 1) { + lumiOpts.amIneeded.value = 1; + LOGF(info, "Luminosity / Autodetection for aod::BcSels: subscription present, will generate."); + } + if (evSelNeeded == 1 && bcSelNeeded == 0) { + lumiOpts.amIneeded.value = 1; + LOGF(info, "Luminosity / Autodetection for aod::BcSels: not there, but EvSel needed. Will generate."); + } + if (bcSelNeeded == 0 && evSelNeeded == 0) { + LOGF(info, "Luminosity / Autodetection for aod::BcSels: not required. Skipping generation."); + return; + } + } + + histos.add("luminosity/hCounterTVX", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hCounterTCE", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hCounterZEM", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hCounterZNC", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hCounterTVXafterBCcuts", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hCounterTCEafterBCcuts", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hCounterZEMafterBCcuts", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hCounterZNCafterBCcuts", "", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hLumiTVX", ";;Luminosity, 1/#mub", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hLumiTCE", ";;Luminosity, 1/#mub", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hLumiZEM", ";;Luminosity, 1/#mub", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hLumiZNC", ";;Luminosity, 1/#mub", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hLumiTVXafterBCcuts", ";;Luminosity, 1/#mub", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hLumiTCEafterBCcuts", ";;Luminosity, 1/#mub", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hLumiZEMafterBCcuts", ";;Luminosity, 1/#mub", framework::kTH1D, {{1, 0., 1.}}); + histos.add("luminosity/hLumiZNCafterBCcuts", ";;Luminosity, 1/#mub", framework::kTH1D, {{1, 0., 1.}}); + + const int nLists = 6; + TString rctListNames[] = {"CBT", "CBT_hadronPID", "CBT_electronPID", "CBT_calo", "CBT_muon", "CBT_muon_glo"}; + histos.add("luminosity/hLumiTVXafterBCcutsRCT", ";;Luminosity, 1/#mub", framework::kTH2D, {{1, 0., 1.}, {4 * nLists, -0.5, 4. * nLists - 0.5}}); + histos.add("luminosity/hLumiTCEafterBCcutsRCT", ";;Luminosity, 1/#mub", framework::kTH2D, {{1, 0., 1.}, {4 * nLists, -0.5, 4. * nLists - 0.5}}); + histos.add("luminosity/hLumiZEMafterBCcutsRCT", ";;Luminosity, 1/#mub", framework::kTH2D, {{1, 0., 1.}, {4 * nLists, -0.5, 4. * nLists - 0.5}}); + histos.add("luminosity/hLumiZNCafterBCcutsRCT", ";;Luminosity, 1/#mub", framework::kTH2D, {{1, 0., 1.}, {4 * nLists, -0.5, 4. * nLists - 0.5}}); + + for (int i = 0; i < nLists; i++) { + const auto& rctListName = rctListNames[i]; + mRCTFlagsCheckers.emplace_back(rctListName.Data(), false, false); // disable zdc check, disable lim. acc. check + mRCTFlagsCheckers.emplace_back(rctListName.Data(), false, true); // disable zdc check, enable lim. acc. check + mRCTFlagsCheckers.emplace_back(rctListName.Data(), true, false); // enable zdc check, disable lim. acc. check + mRCTFlagsCheckers.emplace_back(rctListName.Data(), true, true); // enable zdc check, enable lim. acc. check + histos.template get(HIST("luminosity/hLumiTVXafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 1, rctListName.Data()); + histos.template get(HIST("luminosity/hLumiTCEafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 1, rctListName.Data()); + histos.template get(HIST("luminosity/hLumiZEMafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 1, rctListName.Data()); + histos.template get(HIST("luminosity/hLumiZNCafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 1, rctListName.Data()); + histos.template get(HIST("luminosity/hLumiTVXafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 2, (rctListName + "_fullacc").Data()); + histos.template get(HIST("luminosity/hLumiTCEafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 2, (rctListName + "_fullacc").Data()); + histos.template get(HIST("luminosity/hLumiZEMafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 2, (rctListName + "_fullacc").Data()); + histos.template get(HIST("luminosity/hLumiZNCafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 2, (rctListName + "_fullacc").Data()); + histos.template get(HIST("luminosity/hLumiTVXafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 3, (rctListName + "_zdc").Data()); + histos.template get(HIST("luminosity/hLumiTCEafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 3, (rctListName + "_zdc").Data()); + histos.template get(HIST("luminosity/hLumiZEMafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 3, (rctListName + "_zdc").Data()); + histos.template get(HIST("luminosity/hLumiZNCafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 3, (rctListName + "_zdc").Data()); + histos.template get(HIST("luminosity/hLumiTVXafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 4, (rctListName + "_zdc" + "_fullacc").Data()); + histos.template get(HIST("luminosity/hLumiTCEafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 4, (rctListName + "_zdc" + "_fullacc").Data()); + histos.template get(HIST("luminosity/hLumiZEMafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 4, (rctListName + "_zdc" + "_fullacc").Data()); + histos.template get(HIST("luminosity/hLumiZNCafterBCcutsRCT"))->GetYaxis()->SetBinLabel(4 * i + 4, (rctListName + "_zdc" + "_fullacc").Data()); + } + } + + template + bool configure(TCCDB& ccdb, TTimestamps const& timestamps, TBCs const& bcs) + { + if (bcs.size() == 0) + return false; + int run = bcs.iteratorAt(0).runNumber(); + if (run < 500000) // o2-linter: disable=magic-number (skip for unanchored MCs) + return false; + if (run != lastRun && run >= 520259) { // o2-linter: disable=magic-number (scalers available for runs above 520120) + lastRun = run; + int64_t ts = timestamps[0]; + + // getting GRP LHCIF object to extract colliding system, energy and colliding bc pattern + auto grplhcif = ccdb->template getForTimeStamp("GLO/Config/GRPLHCIF", ts); + int beamZ1 = grplhcif->getBeamZ(constants::lhc::BeamA); + int beamZ2 = grplhcif->getBeamZ(constants::lhc::BeamC); + float sqrts = grplhcif->getSqrtS(); + int nCollidingBCs = grplhcif->getBunchFilling().getNBunches(); + bcPatternB = grplhcif->getBunchFilling().getBCPattern(); + LOGP(info, "beamZ1={} beamZ2={} sqrts={}", beamZ1, beamZ2, sqrts); + // visible cross sections in ub. Using dummy -1 if lumi estimator is not reliable for this colliding system + csTVX = -1; + csTCE = -1; + csZEM = -1; + csZNC = -1; + // Temporary workaround to get visible cross section. TODO: store run-by-run visible cross sections in CCDB + if (beamZ1 == 8 && beamZ2 == 1) { + csTVX = 0.3874e6; // eff(TVX) = 0.807 (based on LHC25e6f); sigma(INEL)=0.48b; arxiv:2507.05853 + } else if (beamZ1 == 8 && beamZ2 == 8) { + csTVX = 1.2050e6; // eff(TVX) = 0.886 (based on LHC25e6b); sigma(INEL)=1.36b; arxiv:2507.05853 + } else if (beamZ1 == 10 && beamZ2 == 10) { + csTVX = 1.5411e6; // eff(TVX) = 0.896 (based on LHC25e6g); sigma(INEL)=1.72b; arxiv:2507.05853 + } else if (beamZ1 == 1 && beamZ2 == 1) { + if (std::fabs(sqrts - 900.) < 100.) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTVX = 0.0357e6; // ub + } else if (std::fabs(sqrts - 5360.) < 100.) { // pp-ref // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTVX = 0.0503e6; // ub + } else if (std::fabs(sqrts - 13600.) < 300.) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTVX = 0.0594e6; // ub + } else { + LOGP(warn, "Cross section for pp @ {} GeV is not defined", sqrts); + } + } else if (beamZ1 == 82 && beamZ2 == 82) { // o2-linter: disable=magic-number (PbPb colliding system) + // see AN: https://alice-notes.web.cern.ch/node/1515 + if (std::fabs(sqrts - 5360) < 20) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csZNC = 214.5e6; // ub + csZEM = 415.2e6; // ub + csTCE = 10.36e6; // ub + if (run > 543437 && run < 543514) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTCE = 8.3e6; // ub + } else if (run >= 543514 && run < 545367) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTCE = 4.10e6; // ub + } else if (run >= 559544) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb) + csTCE = 3.86e6; // ub + } + } else { + LOGP(warn, "Cross section for PbPb @ {} GeV is not defined", sqrts); + } + } else { + LOGP(warn, "Cross section for z={} + z={} @ {} GeV is not defined", beamZ1, beamZ2, sqrts); + } + // getting CTP config to extract lumi class indices (used for rate fetching and pileup correction) + std::map metadata; + metadata["runNumber"] = std::to_string(run); + auto config = ccdb->template getSpecific("CTP/Config/Config", ts, metadata); + auto classes = config->getCTPClasses(); + TString lumiClassNameZNC = "C1ZNC-B-NOPF-CRU"; + TString lumiClassNameTCE = "CMTVXTCE-B-NOPF-CRU"; + TString lumiClassNameTVX1 = "MINBIAS_TVX"; // run >= 534467 + TString lumiClassNameTVX2 = "MINBIAS_TVX_NOMASK"; // run >= 534468 + TString lumiClassNameTVX3 = "CMTVX-NONE-NOPF-CRU"; // run >= 534996 + TString lumiClassNameTVX4 = "CMTVX-B-NOPF-CRU"; // run >= 543437 + + // find class indices + int classIdZNC = -1; + int classIdTCE = -1; + int classIdTVX = -1; + for (unsigned int i = 0; i < classes.size(); i++) { + TString clname = classes[i].name; + clname.ToUpper(); + // using position (i) in the vector of classes instead of classes[i].getIndex() + // due to bug or inconsistencies in scaler record and class indices + if (clname == lumiClassNameZNC) + classIdZNC = i; + if (clname == lumiClassNameTCE) + classIdTCE = i; + if (clname == lumiClassNameTVX4 || clname == lumiClassNameTVX3 || clname == lumiClassNameTVX2 || clname == lumiClassNameTVX1) + classIdTVX = i; + } + + // extract trigger counts from CTP scalers + auto scalers = ccdb->template getSpecific("CTP/Calib/Scalers", ts, metadata); + scalers->convertRawToO2(); + std::vector mCounterTVX; + std::vector mCounterTCE; + std::vector mCounterZNC; + std::vector mCounterZEM; + mOrbits.clear(); + for (const auto& record : scalers->getScalerRecordO2()) { + mOrbits.push_back(record.intRecord.orbit); + mCounterTVX.push_back(classIdTVX >= 0 ? record.scalers[classIdTVX].lmBefore : 0); + mCounterTCE.push_back(classIdTCE >= 0 ? record.scalers[classIdTCE].lmBefore : 0); + if (run >= 543437 && run < 544448 && record.scalersInps.size() >= 26) { // o2-linter: disable=magic-number (ZNC class not defined for this run range) + mCounterZNC.push_back(record.scalersInps[25]); // see ZNC=1ZNC input index in https://indico.cern.ch/event/1153630/contributions/4844362/ + } else { + mCounterZNC.push_back(classIdZNC >= 0 ? record.scalers[classIdZNC].l1Before : 0); + } + // ZEM class not defined, using inputs instead + uint32_t indexZEM = 24; // see ZEM=1ZED input index in https://indico.cern.ch/event/1153630/contributions/4844362/ + mCounterZEM.push_back(record.scalersInps.size() >= indexZEM + 1 ? record.scalersInps[indexZEM] : 0); + } + + // calculate pileup corrections + mPileupCorrectionTVX.clear(); + mPileupCorrectionTCE.clear(); + mPileupCorrectionZEM.clear(); + mPileupCorrectionZNC.clear(); + for (uint32_t i = 0; i < mOrbits.size() - 1; i++) { + int64_t nOrbits = mOrbits[i + 1] - mOrbits[i]; + if (nOrbits <= 0 || nCollidingBCs == 0) + continue; + double perBcRateTVX = static_cast(mCounterTVX[i + 1] - mCounterTVX[i]) / nOrbits / nCollidingBCs; + double perBcRateTCE = static_cast(mCounterTCE[i + 1] - mCounterTCE[i]) / nOrbits / nCollidingBCs; + double perBcRateZNC = static_cast(mCounterZNC[i + 1] - mCounterZNC[i]) / nOrbits / nCollidingBCs; + double perBcRateZEM = static_cast(mCounterZEM[i + 1] - mCounterZEM[i]) / nOrbits / nCollidingBCs; + double muTVX = (perBcRateTVX < 1 && perBcRateTVX > 1e-10) ? -std::log(1 - perBcRateTVX) : 0; + double muTCE = (perBcRateTCE < 1 && perBcRateTCE > 1e-10) ? -std::log(1 - perBcRateTCE) : 0; + double muZNC = (perBcRateZNC < 1 && perBcRateZNC > 1e-10) ? -std::log(1 - perBcRateZNC) : 0; + double muZEM = (perBcRateZEM < 1 && perBcRateZEM > 1e-10) ? -std::log(1 - perBcRateZEM) : 0; + LOGP(debug, "orbit={} muTVX={} muTCE={} muZNC={} muZEM={}", mOrbits[i], muTVX, muTCE, muZNC, muZEM); + mPileupCorrectionTVX.push_back(muTVX > 1e-10 ? muTVX / (1 - std::exp(-muTVX)) : 1); + mPileupCorrectionTCE.push_back(muTCE > 1e-10 ? muTCE / (1 - std::exp(-muTCE)) : 1); + mPileupCorrectionZNC.push_back(muZNC > 1e-10 ? muZNC / (1 - std::exp(-muZNC)) : 1); + mPileupCorrectionZEM.push_back(muZEM > 1e-10 ? muZEM / (1 - std::exp(-muZEM)) : 1); + } + // filling last orbit range using previous orbit range + mPileupCorrectionTVX.push_back(mPileupCorrectionTVX.back()); + mPileupCorrectionTCE.push_back(mPileupCorrectionTCE.back()); + mPileupCorrectionZNC.push_back(mPileupCorrectionZNC.back()); + mPileupCorrectionZEM.push_back(mPileupCorrectionZEM.back()); + } // access ccdb once per run + return true; // carry on, please + } + + //__________________________________________________ + template + void process(TCCDB& ccdb, THistoRegistry& histos, TBCs const& bcs, TTimestamps const& timestamps, TBcSelBuffer const& bcselBuffer) + { + if (lumiOpts.amIneeded.value == 0) { + return; + } + + if (!configure(ccdb, timestamps, bcs)) + return; // don't do anything in case configuration reported not ok + + int run = bcs.iteratorAt(0).runNumber(); + const char* srun = Form("%d", run); + + // processing loop + for (const auto& bc : bcs) { + auto selection = bcselBuffer[bc.globalIndex()].selection; + if (bcPatternB[bc.globalBC() % nBCsPerOrbit] == 0) // skip non-colliding bcs + continue; + + bool noBorder = TESTBIT(selection, aod::evsel::kNoTimeFrameBorder) && TESTBIT(selection, aod::evsel::kNoITSROFrameBorder); + bool isTriggerTVX = TESTBIT(selection, aod::evsel::kIsTriggerTVX); + bool isTriggerTCE = bc.has_ft0() ? (TESTBIT(selection, aod::evsel::kIsTriggerTVX) && TESTBIT(bc.ft0().triggerMask(), o2::ft0::Triggers::bitCen)) : 0; + bool isTriggerZNA = TESTBIT(selection, aod::evsel::kIsBBZNA); + bool isTriggerZNC = TESTBIT(selection, aod::evsel::kIsBBZNC); + bool isTriggerZEM = isTriggerZNA || isTriggerZNC; + + // determine pileup correction + int64_t orbit = bc.globalBC() / nBCsPerOrbit; + if ((orbit < minOrbitInRange || orbit > maxOrbitInRange) && mOrbits.size() > 1) { + auto it = std::lower_bound(mOrbits.begin(), mOrbits.end(), orbit); + uint32_t nextOrbitIndex = std::distance(mOrbits.begin(), it); + if (nextOrbitIndex == 0) // if orbit is below stored scaler orbits + nextOrbitIndex = 1; + else if (nextOrbitIndex == mOrbits.size()) // if orbit is above stored scaler orbits + nextOrbitIndex = mOrbits.size() - 1; + currentOrbitIndex = nextOrbitIndex - 1; + minOrbitInRange = mOrbits[currentOrbitIndex]; + maxOrbitInRange = mOrbits[nextOrbitIndex]; + } + double pileupCorrectionTVX = currentOrbitIndex < mPileupCorrectionTVX.size() ? mPileupCorrectionTVX[currentOrbitIndex] : 1.; + double pileupCorrectionTCE = currentOrbitIndex < mPileupCorrectionTCE.size() ? mPileupCorrectionTCE[currentOrbitIndex] : 1.; + double pileupCorrectionZNC = currentOrbitIndex < mPileupCorrectionZNC.size() ? mPileupCorrectionZNC[currentOrbitIndex] : 1.; + double pileupCorrectionZEM = currentOrbitIndex < mPileupCorrectionZEM.size() ? mPileupCorrectionZEM[currentOrbitIndex] : 1.; + + double lumiTVX = 1. / csTVX * pileupCorrectionTVX; + double lumiTCE = 1. / csTCE * pileupCorrectionTCE; + double lumiZNC = 1. / csZNC * pileupCorrectionZNC; + double lumiZEM = 1. / csZEM * pileupCorrectionZEM; + + auto rct = bcselBuffer[bc.globalIndex()].rct; + + if (isTriggerTVX) { + histos.template get(HIST("luminosity/hCounterTVX"))->Fill(srun, 1); + histos.template get(HIST("luminosity/hLumiTVX"))->Fill(srun, lumiTVX); + if (noBorder) { + histos.template get(HIST("luminosity/hCounterTVXafterBCcuts"))->Fill(srun, 1); + histos.template get(HIST("luminosity/hLumiTVXafterBCcuts"))->Fill(srun, lumiTVX); + for (size_t i = 0; i < mRCTFlagsCheckers.size(); i++) { + if ((rct & mRCTFlagsCheckers[i].value()) == 0) + histos.template get(HIST("luminosity/hLumiTVXafterBCcutsRCT"))->Fill(srun, i, lumiTVX); + } + } + } + + if (isTriggerTCE) { + histos.template get(HIST("luminosity/hCounterTCE"))->Fill(srun, 1); + histos.template get(HIST("luminosity/hLumiTCE"))->Fill(srun, lumiTCE); + if (noBorder) { + histos.template get(HIST("luminosity/hCounterTCEafterBCcuts"))->Fill(srun, 1); + histos.template get(HIST("luminosity/hLumiTCEafterBCcuts"))->Fill(srun, lumiTCE); + for (size_t i = 0; i < mRCTFlagsCheckers.size(); i++) { + if ((rct & mRCTFlagsCheckers[i].value()) == 0) + histos.template get(HIST("luminosity/hLumiTCEafterBCcutsRCT"))->Fill(srun, i, lumiTCE); + } + } + } + + if (isTriggerZEM) { + histos.template get(HIST("luminosity/hCounterZEM"))->Fill(srun, 1); + histos.template get(HIST("luminosity/hLumiZEM"))->Fill(srun, lumiZEM); + if (noBorder) { + histos.template get(HIST("luminosity/hCounterZEMafterBCcuts"))->Fill(srun, 1); + histos.template get(HIST("luminosity/hLumiZEMafterBCcuts"))->Fill(srun, lumiZEM); + for (size_t i = 0; i < mRCTFlagsCheckers.size(); i++) { + if ((rct & mRCTFlagsCheckers[i].value()) == 0) + histos.template get(HIST("luminosity/hLumiZEMafterBCcutsRCT"))->Fill(srun, i, lumiZEM); + } + } + } + + if (isTriggerZNC) { + histos.template get(HIST("luminosity/hCounterZNC"))->Fill(srun, 1); + histos.template get(HIST("luminosity/hLumiZNC"))->Fill(srun, lumiZNC); + if (noBorder) { + histos.template get(HIST("luminosity/hCounterZNCafterBCcuts"))->Fill(srun, 1); + histos.template get(HIST("luminosity/hLumiZNCafterBCcuts"))->Fill(srun, lumiZNC); + for (size_t i = 0; i < mRCTFlagsCheckers.size(); i++) { + if ((rct & mRCTFlagsCheckers[i].value()) == 0) + histos.template get(HIST("luminosity/hLumiZNCafterBCcutsRCT"))->Fill(srun, i, lumiZNC); + } + } + } + } // bcs + } // process +}; // end LumiModule + +} // namespace eventselection +} // namespace common +} // namespace o2 + +#endif // COMMON_TOOLS_EVENTSELECTIONTOOLS_H_ diff --git a/Common/Tools/MultModule.h b/Common/Tools/MultModule.h new file mode 100644 index 00000000000..f722643fc2e --- /dev/null +++ b/Common/Tools/MultModule.h @@ -0,0 +1,1354 @@ +// 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. + +/// \file MultModule.h +/// \brief combined multiplicity + centrality module with autodetect features +/// \author ALICE + +#ifndef COMMON_TOOLS_MULTMODULE_H_ +#define COMMON_TOOLS_MULTMODULE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "Framework/AnalysisDataModel.h" +#include "Framework/Configurable.h" +#include "Framework/HistogramSpec.h" +#include "TableHelper.h" +#include "Common/Core/TPCVDriftManager.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "PWGMM/Mult/DataModel/bestCollisionTable.h" +#include "TFormula.h" + +//__________________________________________ +// MultModule + +namespace o2 +{ +namespace common +{ +namespace multiplicity +{ + +// statics necessary for the configurables in this namespace +static constexpr int nParameters = 1; +static const std::vector tableNames{ + // multiplicity subcomponent + "FV0Mults", + "FV0AOuterMults", + "FT0Mults", + "FDDMults", + "ZDCMults", + "TrackletMults", + "TPCMults", + "PVMults", + "MultsExtra", + "MultSelections", + "FV0MultZeqs", + "FT0MultZeqs", + "FDDMultZeqs", + "PVMultZeqs", + "MultMCExtras", + "Mult2MCExtras", + "MFTMults", + "MultsGlobal", + + // centrality subcomponent + "CentRun2V0Ms", + "CentRun2V0As", + "CentRun2SPDTrks", + "CentRun2SPDClss", + "CentRun2CL0s", + "CentRun2CL1s", + "CentFV0As", + "CentFT0Ms", + "CentFT0As", + "CentFT0Cs", + "CentFT0CVariant1s", + "CentFDDMs", + "CentNTPVs", + "CentNGlobals", + "CentMFTs", + "BCCentFT0Ms", + "BCCentFT0As", + "BCCentFT0Cs"}; + +static constexpr int nTablesConst = 36; + +static const std::vector parameterNames{"enable"}; +static const int defaultParameters[nTablesConst][nParameters]{ + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}}; + +// table index : match order above +enum tableIndex { kFV0Mults, // standard + kFV0AOuterMults, // standard + kFT0Mults, // standard + kFDDMults, // standard + kZDCMults, // standard + kTrackletMults, // Run 2 + kTPCMults, // standard + kPVMults, // standard + kMultsExtra, // standard + kMultSelections, // event selection + kFV0MultZeqs, // zeq calib, standard + kFT0MultZeqs, // zeq calib, standard + kFDDMultZeqs, // zeq calib, standard + kPVMultZeqs, // zeq calib, standard + kMultMCExtras, // MC exclusive + kMult2MCExtras, // MC exclusive + kMFTMults, // requires MFT task + kMultsGlobal, // requires track selection task + + // centrality subcomponent + kCentRun2V0Ms, // Run 2 + kCentRun2V0As, // Run 2 + kCentRun2SPDTrks, // Run 2 + kCentRun2SPDClss, // Run 2 + kCentRun2CL0s, // Run 2 + kCentRun2CL1s, // Run 2 + kCentFV0As, // standard Run 3 + kCentFT0Ms, // standard Run 3 + kCentFT0As, // standard Run 3 + kCentFT0Cs, // standard Run 3 + kCentFT0CVariant1s, // standard Run 3 + kCentFDDMs, // standard Run 3 + kCentNTPVs, // standard Run 3 + kCentNGlobals, // requires track selection task + kCentMFTs, // requires MFT task + kBCCentFT0Ms, // bc centrality + kBCCentFT0As, // bc centrality + kBCCentFT0Cs, // bc centrality + kNTables }; + +struct products : o2::framework::ProducesGroup { + //__________________________________________________ + // multiplicity tables + o2::framework::Produces tableFV0; + o2::framework::Produces tableFV0AOuter; + o2::framework::Produces tableFT0; + o2::framework::Produces tableFDD; + o2::framework::Produces tableZDC; + o2::framework::Produces tableTracklet; + o2::framework::Produces tableTpc; + o2::framework::Produces tablePv; + o2::framework::Produces tableExtra; + o2::framework::Produces multSelections; + o2::framework::Produces tableFV0Zeqs; + o2::framework::Produces tableFT0Zeqs; + o2::framework::Produces tableFDDZeqs; + o2::framework::Produces tablePVZeqs; + o2::framework::Produces tableExtraMc; + o2::framework::Produces tableExtraMult2MCExtras; + o2::framework::Produces mftMults; + o2::framework::Produces multsGlobal; + + //__________________________________________________ + // centrality tables (per collision / default) + o2::framework::Produces centRun2V0M; + o2::framework::Produces centRun2V0A; + o2::framework::Produces centRun2SPDTracklets; + o2::framework::Produces centRun2SPDClusters; + o2::framework::Produces centRun2CL0; + o2::framework::Produces centRun2CL1; + o2::framework::Produces centFV0A; + o2::framework::Produces centFT0M; + o2::framework::Produces centFT0A; + o2::framework::Produces centFT0C; + o2::framework::Produces centFT0CVariant1; + o2::framework::Produces centFDDM; + o2::framework::Produces centNTPV; + o2::framework::Produces centNGlobals; + o2::framework::Produces centMFTs; + o2::framework::Produces bcCentFT0A; + o2::framework::Produces bcCentFT0C; + o2::framework::Produces bcCentFT0M; + + //__________________________________________________ + // centrality tables per BC + // FIXME - future development +}; + +// for providing temporary buffer +// FIXME ideally cursors could be readable +// to avoid duplicate memory allocation but ok +struct multEntry { + float multFV0A = 0.0f; + float multFV0C = 0.0f; + float multFV0AOuter = 0.0f; + float multFT0A = 0.0f; + float multFT0C = 0.0f; + float multFDDA = 0.0f; + float multFDDC = 0.0f; + float multZNA = 0.0f; + float multZNC = 0.0f; + float multZEM1 = 0.0f; + float multZEM2 = 0.0f; + float multZPA = 0.0f; + float multZPC = 0.0f; + int multTracklets = 0; + + int multNContribs = 0; // PVMult 0.8 + int multNContribsEta1 = 0; // PVMult 1.0 + int multNContribsEtaHalf = 0; // PVMult 0.5 + int multTPC = 0; // all TPC (PV contrib unchecked) + int multHasTPC = 0; // extras + int multHasITS = 0; // extras + int multHasTOF = 0; // extras + int multHasTRD = 0; // extras + int multITSOnly = 0; // extras + int multTPCOnly = 0; // extras + int multITSTPC = 0; // extras + int multAllTracksTPCOnly = 0; // extras + int multAllTracksITSTPC = 0; // extras + + float multFV0AZeq = -999.0f; + float multFV0CZeq = -999.0f; + float multFT0AZeq = -999.0f; + float multFT0CZeq = -999.0f; + float multFDDAZeq = -999.0f; + float multFDDCZeq = -999.0f; + float multNContribsZeq = 0; + + int multGlobalTracks = 0; // multsGlobal + int multNbrContribsEta05GlobalTrackWoDCA = 0; // multsGlobal + int multNbrContribsEta08GlobalTrackWoDCA = 0; // multsGlobal + int multNbrContribsEta10GlobalTrackWoDCA = 0; // multsGlobal + + int multMFTAllTracks = 0; // mft + int multMFTTracks = 0; // mft + + // For Run2 only + float posZ = -999.0f; + uint16_t spdClustersL0 = 0; + uint16_t spdClustersL1 = 0; +}; + +// strangenessBuilder: 1st-order configurables +struct standardConfigurables : o2::framework::ConfigurableGroup { + // self-configuration configurables + o2::framework::Configurable> enabledTables{"enabledTables", + {defaultParameters[0], nTablesConst, nParameters, tableNames, parameterNames}, + "Produce this table: -1 for autodetect; otherwise, 0/1 is false/true"}; + std::vector mEnabledTables; // Vector of enabled tables + + // Autoconfigure process functions + o2::framework::Configurable autoConfigureProcess{"autoConfigureProcess", false, "if true, will configure process function switches based on metadata"}; + + // do vertex-Z equalized or not + o2::framework::Configurable doVertexZeq{"doVertexZeq", 1, "if 1: do vertex Z eq mult table"}; + + // global track counter configurables + o2::framework::Configurable minPtGlobalTrack{"minPtGlobalTrack", 0.15, "min. pT for global tracks"}; + o2::framework::Configurable maxPtGlobalTrack{"maxPtGlobalTrack", 1e+10, "max. pT for global tracks"}; + o2::framework::Configurable minNclsITSGlobalTrack{"minNclsITSGlobalTrack", 5, "min. number of ITS clusters for global tracks"}; + o2::framework::Configurable minNclsITSibGlobalTrack{"minNclsITSibGlobalTrack", 1, "min. number of ITSib clusters for global tracks"}; + + // ccdb information + o2::framework::Configurable ccdbPathVtxZ{"ccdbPathVtxZ", "Centrality/Calibration", "The CCDB path for vertex-Z calibration"}; + o2::framework::Configurable ccdbPathCentrality{"ccdbPathCentrality", "Centrality/Estimators", "The CCDB path for centrality information"}; + o2::framework::Configurable reconstructionPass{"reconstructionPass", "", {"Apass to use when fetching the calibration tables. Empty (default) does not check for any pass. Use `metadata` to fetch it from the AO2D metadata. Otherwise it will override the metadata."}}; + + // centrality operation + o2::framework::Configurable generatorName{"generatorName", "", {"Specify if and only if this is MC. Typical: PYTHIA"}}; + o2::framework::Configurable embedINELgtZEROselection{"embedINELgtZEROselection", false, {"Option to do percentile 100.5 if not INELgtZERO"}}; +}; + +class MultModule +{ + public: + MultModule() + { + // constructor + mRunNumber = 0; + mRunNumberCentrality = 0; + lCalibLoaded = false; + lCalibObjects = nullptr; + hVtxZFV0A = nullptr; + hVtxZFT0A = nullptr; + hVtxZFT0C = nullptr; + hVtxZFDDA = nullptr; + hVtxZFDDC = nullptr; + hVtxZNTracks = nullptr; + } + + // internal: calib related, vtx-z profiles + int mRunNumber; + int mRunNumberCentrality; + bool lCalibLoaded; + TList* lCalibObjects; + TProfile* hVtxZFV0A; + TProfile* hVtxZFT0A; + TProfile* hVtxZFT0C; + TProfile* hVtxZFDDA; + TProfile* hVtxZFDDC; + TProfile* hVtxZNTracks; + + // declaration of structs here + // (N.B.: will be invisible to the outside, create your own copies) + o2::common::multiplicity::standardConfigurables internalOpts; + + //_________________________________________________ + // centrality-related objects + struct TagRun2V0MCalibration { + bool mCalibrationStored = false; + TFormula* mMCScale = nullptr; + float mMCScalePars[6] = {0.0}; + TH1* mhVtxAmpCorrV0A = nullptr; + TH1* mhVtxAmpCorrV0C = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2V0MInfo; + struct TagRun2V0ACalibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorrV0A = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2V0AInfo; + struct TagRun2SPDTrackletsCalibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorr = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2SPDTksInfo; + struct TagRun2SPDClustersCalibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorrCL0 = nullptr; + TH1* mhVtxAmpCorrCL1 = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2SPDClsInfo; + struct TagRun2CL0Calibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorr = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2CL0Info; + struct TagRun2CL1Calibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorr = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2CL1Info; + struct CalibrationInfo { + std::string name = ""; + bool mCalibrationStored = false; + TH1* mhMultSelCalib = nullptr; + float mMCScalePars[6] = {0.0}; + TFormula* mMCScale = nullptr; + explicit CalibrationInfo(std::string name) + : name(name), + mCalibrationStored(false), + mhMultSelCalib(nullptr), + mMCScalePars{0.0}, + mMCScale(nullptr) + { + } + bool isSane(bool fatalize = false) + { + if (!mhMultSelCalib) { + return true; + } + for (int i = 1; i < mhMultSelCalib->GetNbinsX() + 1; i++) { + if (mhMultSelCalib->GetXaxis()->GetBinLowEdge(i) > mhMultSelCalib->GetXaxis()->GetBinUpEdge(i)) { + if (fatalize) { + LOG(fatal) << "Centrality calibration table " << name << " has bins with low edge > up edge"; + } + LOG(warning) << "Centrality calibration table " << name << " has bins with low edge > up edge"; + return false; + } + } + return true; + } + }; + + CalibrationInfo fv0aInfo = CalibrationInfo("FV0"); + CalibrationInfo ft0mInfo = CalibrationInfo("FT0"); + CalibrationInfo ft0aInfo = CalibrationInfo("FT0A"); + CalibrationInfo ft0cInfo = CalibrationInfo("FT0C"); + CalibrationInfo ft0cVariant1Info = CalibrationInfo("FT0Cvar1"); + CalibrationInfo fddmInfo = CalibrationInfo("FDD"); + CalibrationInfo ntpvInfo = CalibrationInfo("NTracksPV"); + CalibrationInfo nGlobalInfo = CalibrationInfo("NGlobal"); + CalibrationInfo mftInfo = CalibrationInfo("MFT"); + + template + void init(TMetadatainfo const& metadataInfo, TConfigurables& opts, TInitContext& context) + { + // read in configurations from the task where it's used + internalOpts = opts; + internalOpts.mEnabledTables.resize(nTablesConst, 0); + + LOGF(info, "Configuring tables to generate"); + auto& workflows = context.services().template get(); + + TString listOfRequestors[nTablesConst]; + for (int i = 0; i < nTablesConst; i++) { + int f = internalOpts.enabledTables->get(tableNames[i].c_str(), "enable"); + if (f == 1) { + internalOpts.mEnabledTables[i] = 1; + listOfRequestors[i] = "manual enabling"; + } + if (f == -1) { + // autodetect this table in other devices + for (o2::framework::DeviceSpec const& device : workflows.devices) { + // Step 1: check if this device subscribed to the V0data table + for (auto const& input : device.inputs) { + if (o2::framework::DataSpecUtils::partialMatch(input.matcher, o2::header::DataOrigin("AOD"))) { + auto&& [origin, description, version] = o2::framework::DataSpecUtils::asConcreteDataMatcher(input.matcher); + std::string tableNameWithVersion = tableNames[i]; + if (version > 0) { + tableNameWithVersion += Form("_%03d", version); + } + if (input.matcher.binding == tableNameWithVersion) { + LOGF(info, "Device %s has subscribed to %s (version %i)", device.name, tableNames[i], version); + listOfRequestors[i].Append(Form("%s ", device.name.c_str())); + internalOpts.mEnabledTables[i] = 1; + } + } + } + } + } + } + + // dependency checker + if (internalOpts.mEnabledTables[kCentFV0As] && !internalOpts.mEnabledTables[kFV0MultZeqs]) { + internalOpts.mEnabledTables[kFV0MultZeqs] = 1; + listOfRequestors[kFV0MultZeqs].Append(Form("%s ", "dependency check")); + } + if ((internalOpts.mEnabledTables[kCentFT0As] || internalOpts.mEnabledTables[kCentFT0Cs] || internalOpts.mEnabledTables[kCentFT0Ms] || internalOpts.mEnabledTables[kCentFT0CVariant1s]) && !internalOpts.mEnabledTables[kFT0MultZeqs]) { + internalOpts.mEnabledTables[kFT0MultZeqs] = 1; + listOfRequestors[kFT0MultZeqs].Append(Form("%s ", "dependency check")); + } + if (internalOpts.mEnabledTables[kCentFDDMs] && !internalOpts.mEnabledTables[kFDDMultZeqs]) { + internalOpts.mEnabledTables[kFDDMultZeqs] = 1; + listOfRequestors[kFDDMultZeqs].Append(Form("%s ", "dependency check")); + } + if (internalOpts.mEnabledTables[kCentMFTs] && !internalOpts.mEnabledTables[kMFTMults]) { + internalOpts.mEnabledTables[kMFTMults] = 1; + listOfRequestors[kMFTMults].Append(Form("%s ", "dependency check")); + } + if (internalOpts.mEnabledTables[kCentNGlobals] && !internalOpts.mEnabledTables[kMultsGlobal]) { + internalOpts.mEnabledTables[kMultsGlobal] = 1; + listOfRequestors[kMultsGlobal].Append(Form("%s ", "dependency check")); + } + if (internalOpts.embedINELgtZEROselection.value > 0 && !internalOpts.mEnabledTables[kPVMults]) { + internalOpts.mEnabledTables[kPVMults] = 1; + listOfRequestors[kPVMults].Append(Form("%s ", "dependency check")); + } + + // list enabled tables + for (int i = 0; i < nTablesConst; i++) { + // printout to be improved in the future + if (internalOpts.mEnabledTables[i]) { + LOGF(info, " -~> Table enabled: %s, requested by %s", tableNames[i], listOfRequestors[i].Data()); + } + } + + // capture the need for PYTHIA calibration in Pb-Pb runs + if (metadataInfo.isMC() && mRunNumber >= 544013 && mRunNumber <= 545367) { + internalOpts.generatorName.value = "PYTHIA"; + } + + mRunNumber = 0; + mRunNumberCentrality = 0; + lCalibLoaded = false; + hVtxZFV0A = nullptr; + hVtxZFT0A = nullptr; + hVtxZFT0C = nullptr; + hVtxZFDDA = nullptr; + hVtxZFDDC = nullptr; + hVtxZNTracks = nullptr; + + // pass to the outside + opts = internalOpts; + } + + //__________________________________________________ + template + o2::common::multiplicity::multEntry collisionProcessRun2(TCollision const& collision, TTracks const& tracks, TBC const& bc, TOutputGroup& cursors) + { + // initialize properties + o2::common::multiplicity::multEntry mults; + + mults.posZ = collision.posZ(); + mults.spdClustersL0 = bc.spdClustersL0(); + mults.spdClustersL1 = bc.spdClustersL1(); + //_______________________________________________________________________ + // forward detector signals, raw + if (collision.has_fv0a()) { + for (const auto& amplitude : collision.fv0a().amplitude()) { + mults.multFV0A += amplitude; + } + } + if (collision.has_fv0c()) { + for (const auto& amplitude : collision.fv0c().amplitude()) { + mults.multFV0C += amplitude; + } + } + if (collision.has_ft0()) { + auto ft0 = collision.ft0(); + for (const auto& amplitude : ft0.amplitudeA()) { + mults.multFT0A += amplitude; + } + for (const auto& amplitude : ft0.amplitudeC()) { + mults.multFT0C += amplitude; + } + } + if (collision.has_zdc()) { + auto zdc = collision.zdc(); + mults.multZNA = zdc.energyCommonZNA(); + mults.multZNC = zdc.energyCommonZNC(); + } + + //_______________________________________________________________________ + // determine if barrel track loop is required, do it (once!) if so but save CPU if not + if (internalOpts.mEnabledTables[kPVMults] || internalOpts.mEnabledTables[kTPCMults] || internalOpts.mEnabledTables[kTrackletMults]) { + // Try to do something Similar to https://github.com/alisw/AliPhysics/blob/22862a945004f719f8e9664c0264db46e7186a48/OADB/AliPPVsMultUtils.cxx#L541C26-L541C37 + for (const auto& track : tracks) { + // check whether the track is a tracklet + if (track.trackType() == o2::aod::track::Run2Tracklet) { + if (internalOpts.mEnabledTables[kTrackletMults]) { + mults.multTracklets++; + } + if (internalOpts.mEnabledTables[kPVMults]) { + if (std::abs(track.eta()) < 1.0) { + mults.multNContribsEta1++; // pvmults + if (std::abs(track.eta()) < 0.8) { + mults.multNContribs++; // pvmults + if (std::abs(track.eta()) < 0.5) { + mults.multNContribsEtaHalf++; // pvmults + } + } + } + } + } + // check whether the track is a global ITS-TPC track + if (track.tpcNClsFindable() > 0) { + if (internalOpts.mEnabledTables[kTPCMults]) { + mults.multTPC++; + } + } + } + } + + // fill standard cursors if required + if (internalOpts.mEnabledTables[kFV0Mults]) { + cursors.tableFV0(mults.multFV0A, mults.multFV0C); + } + if (internalOpts.mEnabledTables[kFT0Mults]) { + cursors.tableFT0(mults.multFT0A, mults.multFT0C); + } + if (internalOpts.mEnabledTables[kFDDMults]) { + cursors.tableFDD(mults.multFDDA, mults.multFDDC); + } + if (internalOpts.mEnabledTables[kZDCMults]) { + cursors.tableZDC(mults.multZNA, mults.multZNC, 0.0f, 0.0f, 0.0f, 0.0f); + } + if (internalOpts.mEnabledTables[kTrackletMults]) { // Tracklets only Run2 + cursors.tableTracklet(mults.multTracklets); + } + if (internalOpts.mEnabledTables[kTPCMults]) { + cursors.tableTpc(mults.multTPC); + } + if (internalOpts.mEnabledTables[kPVMults]) { + cursors.tablePv(mults.multNContribs, mults.multNContribsEta1, mults.multNContribsEtaHalf); + } + + return mults; + } + + //__________________________________________________ + template + o2::common::multiplicity::multEntry collisionProcessRun3(TCCDB const& ccdb, TMetadataInfo const& metadataInfo, TCollision const& collision, TTracks const& tracks, TBC const& bc, TOutputGroup& cursors) + { + // initialize properties + o2::common::multiplicity::multEntry mults; + + //_______________________________________________________________________ + // preparatory steps + if (internalOpts.doVertexZeq > 0) { + if (bc.runNumber() != mRunNumber) { + mRunNumber = bc.runNumber(); // mark this run as at least tried + if (internalOpts.reconstructionPass.value == "") { + lCalibObjects = ccdb->template getForRun(internalOpts.ccdbPathVtxZ, mRunNumber); + } else if (internalOpts.reconstructionPass.value == "metadata") { + std::map metadata; + metadata["RecoPassName"] = metadataInfo.get("RecoPassName"); + LOGF(info, "Loading CCDB for reconstruction pass (from metadata): %s", metadataInfo.get("RecoPassName")); + lCalibObjects = ccdb->template getSpecificForRun(internalOpts.ccdbPathVtxZ, mRunNumber, metadata); + } else { + std::map metadata; + metadata["RecoPassName"] = internalOpts.reconstructionPass.value; + LOGF(info, "Loading CCDB for reconstruction pass (from provided argument): %s", internalOpts.reconstructionPass.value); + lCalibObjects = ccdb->template getSpecificForRun(internalOpts.ccdbPathVtxZ, mRunNumber, metadata); + } + + if (lCalibObjects) { + hVtxZFV0A = static_cast(lCalibObjects->FindObject("hVtxZFV0A")); + hVtxZFT0A = static_cast(lCalibObjects->FindObject("hVtxZFT0A")); + hVtxZFT0C = static_cast(lCalibObjects->FindObject("hVtxZFT0C")); + hVtxZFDDA = static_cast(lCalibObjects->FindObject("hVtxZFDDA")); + hVtxZFDDC = static_cast(lCalibObjects->FindObject("hVtxZFDDC")); + hVtxZNTracks = static_cast(lCalibObjects->FindObject("hVtxZNTracksPV")); + lCalibLoaded = true; + // Capture error + if (!hVtxZFV0A || !hVtxZFT0A || !hVtxZFT0C || !hVtxZFDDA || !hVtxZFDDC || !hVtxZNTracks) { + LOGF(error, "Problem loading CCDB objects! Please check"); + lCalibLoaded = false; + } + } else { + LOGF(error, "Problem loading CCDB object! Please check"); + lCalibLoaded = false; + } + } + } + + //_______________________________________________________________________ + // forward detector signals, raw + if (collision.has_foundFV0()) { + const auto& fv0 = collision.foundFV0(); + for (size_t ii = 0; ii < fv0.amplitude().size(); ii++) { + auto amplitude = fv0.amplitude()[ii]; + auto channel = fv0.channel()[ii]; + mults.multFV0A += amplitude; + if (channel > 7) { + mults.multFV0AOuter += amplitude; + } + } + } else { + mults.multFV0A = -999.f; + mults.multFV0AOuter = -999.f; + } + if (collision.has_foundFT0()) { + const auto& ft0 = collision.foundFT0(); + for (const auto& amplitude : ft0.amplitudeA()) { + mults.multFT0A += amplitude; + } + for (const auto& amplitude : ft0.amplitudeC()) { + mults.multFT0C += amplitude; + } + } else { + mults.multFT0A = -999.f; + mults.multFT0C = -999.f; + } + if (collision.has_foundFDD()) { + const auto& fdd = collision.foundFDD(); + for (const auto& amplitude : fdd.chargeA()) { + mults.multFDDA += amplitude; + } + for (const auto& amplitude : fdd.chargeC()) { + mults.multFDDC += amplitude; + } + } else { + mults.multFDDA = -999.f; + mults.multFDDC = -999.f; + } + if (bc.has_zdc()) { + mults.multZNA = bc.zdc().amplitudeZNA(); + mults.multZNC = bc.zdc().amplitudeZNC(); + mults.multZEM1 = bc.zdc().amplitudeZEM1(); + mults.multZEM2 = bc.zdc().amplitudeZEM2(); + mults.multZPA = bc.zdc().amplitudeZPA(); + mults.multZPC = bc.zdc().amplitudeZPC(); + } else { + mults.multZNA = -999.f; + mults.multZNC = -999.f; + mults.multZEM1 = -999.f; + mults.multZEM2 = -999.f; + mults.multZPA = -999.f; + mults.multZPC = -999.f; + } + + // fill standard cursors if required + if (internalOpts.mEnabledTables[kTrackletMults]) { // Tracklets (only Run2) nothing to do (to be removed!) + cursors.tableTracklet(0); + } + if (internalOpts.mEnabledTables[kFV0Mults]) { + cursors.tableFV0(mults.multFV0A, mults.multFV0C); + } + if (internalOpts.mEnabledTables[kFV0AOuterMults]) { + cursors.tableFV0AOuter(mults.multFV0AOuter); + } + if (internalOpts.mEnabledTables[kFT0Mults]) { + cursors.tableFT0(mults.multFT0A, mults.multFT0C); + } + if (internalOpts.mEnabledTables[kFDDMults]) { + cursors.tableFDD(mults.multFDDA, mults.multFDDC); + } + if (internalOpts.mEnabledTables[kZDCMults]) { + cursors.tableZDC(mults.multZNA, mults.multZNC, mults.multZEM1, mults.multZEM2, mults.multZPA, mults.multZPC); + } + + //_______________________________________________________________________ + // forward detector signals, vertex-Z equalized + if (internalOpts.mEnabledTables[kFV0MultZeqs]) { + if (std::fabs(collision.posZ() && lCalibLoaded)) { + mults.multFV0AZeq = hVtxZFV0A->Interpolate(0.0) * mults.multFV0A / hVtxZFV0A->Interpolate(collision.posZ()); + } else { + mults.multFV0AZeq = 0.0f; + } + cursors.tableFV0Zeqs(mults.multFV0AZeq); + } + if (internalOpts.mEnabledTables[kFT0MultZeqs]) { + if (std::fabs(collision.posZ() && lCalibLoaded)) { + mults.multFT0AZeq = hVtxZFT0A->Interpolate(0.0) * mults.multFT0A / hVtxZFT0A->Interpolate(collision.posZ()); + mults.multFT0CZeq = hVtxZFT0C->Interpolate(0.0) * mults.multFT0C / hVtxZFT0C->Interpolate(collision.posZ()); + } else { + mults.multFT0AZeq = 0.0f; + mults.multFT0CZeq = 0.0f; + } + cursors.tableFT0Zeqs(mults.multFT0AZeq, mults.multFT0CZeq); + } + if (internalOpts.mEnabledTables[kFDDMultZeqs]) { + if (std::fabs(collision.posZ() && lCalibLoaded)) { + mults.multFDDAZeq = hVtxZFDDA->Interpolate(0.0) * mults.multFDDA / hVtxZFDDA->Interpolate(collision.posZ()); + mults.multFDDCZeq = hVtxZFDDC->Interpolate(0.0) * mults.multFDDC / hVtxZFDDC->Interpolate(collision.posZ()); + } else { + mults.multFDDAZeq = 0.0f; + mults.multFDDCZeq = 0.0f; + } + cursors.tableFDDZeqs(mults.multFDDAZeq, mults.multFDDCZeq); + } + + //_______________________________________________________________________ + // determine if barrel track loop is required, do it (once!) if so but save CPU if not + if (internalOpts.mEnabledTables[kTPCMults] || internalOpts.mEnabledTables[kPVMults] || internalOpts.mEnabledTables[kMultsExtra] || internalOpts.mEnabledTables[kPVMultZeqs] || internalOpts.mEnabledTables[kMultsGlobal]) { + // single loop to calculate all + for (const auto& track : tracks) { + if (track.hasTPC()) { + mults.multTPC++; + if (track.hasITS()) { + mults.multAllTracksITSTPC++; // multsextra + } else { + mults.multAllTracksTPCOnly++; // multsextra + } + } + // PV contributor checked explicitly + if (track.isPVContributor()) { + if (std::abs(track.eta()) < 1.0) { + mults.multNContribsEta1++; // pvmults + if (std::abs(track.eta()) < 0.8) { + mults.multNContribs++; // pvmults + if (std::abs(track.eta()) < 0.5) { + mults.multNContribsEtaHalf++; // pvmults + } + } + } + if (track.hasITS()) { + mults.multHasITS++; // multsextra + if (track.hasTPC()) + mults.multITSTPC++; // multsextra + if (!track.hasTPC() && !track.hasTOF() && !track.hasTRD()) { + mults.multITSOnly++; // multsextra + } + } + if (track.hasTPC()) { + mults.multHasTPC++; // multsextra + if (!track.hasITS() && !track.hasTOF() && !track.hasTRD()) { + mults.multTPCOnly++; // multsextra + } + } + if (track.hasTOF()) { + mults.multHasTOF++; // multsextra + } + if (track.hasTRD()) { + mults.multHasTRD++; // multsextra + } + } + + // global counters: do them only in case information is provided in tracks table + if constexpr (requires { track.isQualityTrack(); }) { + if (track.pt() < internalOpts.maxPtGlobalTrack.value && track.pt() > internalOpts.minPtGlobalTrack.value && std::fabs(track.eta()) < 1.0f && track.isPVContributor() && track.isQualityTrack()) { + if (track.itsNCls() < internalOpts.minNclsITSGlobalTrack || track.itsNClsInnerBarrel() < internalOpts.minNclsITSibGlobalTrack) { + continue; + } + mults.multNbrContribsEta10GlobalTrackWoDCA++; + + if (std::abs(track.eta()) < 0.8) { + mults.multNbrContribsEta08GlobalTrackWoDCA++; + } + if (std::abs(track.eta()) < 0.5) { + mults.multNbrContribsEta05GlobalTrackWoDCA++; + } + } + if (std::fabs(track.eta()) < 0.8 && track.tpcNClsFound() >= 80 && track.tpcNClsCrossedRows() >= 100) { + if (track.isGlobalTrack()) { + mults.multGlobalTracks++; + } + } + } // end constexpr requires track selection stuff + } + + cursors.multsGlobal(mults.multGlobalTracks, mults.multNbrContribsEta08GlobalTrackWoDCA, mults.multNbrContribsEta10GlobalTrackWoDCA, mults.multNbrContribsEta05GlobalTrackWoDCA); + } + + // fill track counters at this stage if requested + if (internalOpts.mEnabledTables[kTPCMults]) { + cursors.tableTpc(mults.multTPC); + } + if (internalOpts.mEnabledTables[kPVMults]) { + cursors.tablePv(mults.multNContribs, mults.multNContribsEta1, mults.multNContribsEtaHalf); + } + if (internalOpts.mEnabledTables[kMultsExtra]) { + cursors.tableExtra(collision.numContrib(), collision.chi2(), collision.collisionTimeRes(), + bc.runNumber(), collision.posZ(), collision.sel8(), + mults.multHasITS, mults.multHasTPC, mults.multHasTOF, mults.multHasTRD, + mults.multITSOnly, mults.multTPCOnly, mults.multITSTPC, + mults.multAllTracksTPCOnly, mults.multAllTracksITSTPC, + collision.trackOccupancyInTimeRange(), + collision.ft0cOccupancyInTimeRange(), + collision.flags()); + } + if (internalOpts.mEnabledTables[kPVMultZeqs]) { + if (std::fabs(collision.posZ()) && lCalibLoaded) { + mults.multNContribsZeq = hVtxZNTracks->Interpolate(0.0) * mults.multNContribs / hVtxZNTracks->Interpolate(collision.posZ()); + } else { + mults.multNContribsZeq = 0.0f; + } + cursors.tablePVZeqs(mults.multNContribsZeq); + } + + // return multiplicity object such that it is handled properly when computing centrality + return mults; + } + + //__________________________________________________ + template + void collisionProcessMonteCarlo(TMCCollision const& mccollision, TMCParticles const& mcparticles, TPDGService const& pdg, TOutputGroup& cursors) + { + int multFT0A = 0; + int multFV0A = 0; + int multFT0C = 0; + int multFDDA = 0; + int multFDDC = 0; + int multBarrelEta05 = 0; + int multBarrelEta08 = 0; + int multBarrelEta10 = 0; + for (auto const& mcPart : mcparticles) { + if (!mcPart.isPhysicalPrimary()) { + continue; + } + + auto charge = 0.; + auto* p = pdg->GetParticle(mcPart.pdgCode()); + if (p != nullptr) { + charge = p->Charge(); + } + if (std::abs(charge) < 1e-3) { + continue; // reject neutral particles in counters + } + + if (std::abs(mcPart.eta()) < 1.0) { + multBarrelEta10++; + if (std::abs(mcPart.eta()) < 0.8) { + multBarrelEta08++; + if (std::abs(mcPart.eta()) < 0.5) { + multBarrelEta05++; + } + } + } + if (-3.3 < mcPart.eta() && mcPart.eta() < -2.1) + multFT0C++; + if (3.5 < mcPart.eta() && mcPart.eta() < 4.9) + multFT0A++; + if (2.2 < mcPart.eta() && mcPart.eta() < 5.0) + multFV0A++; + if (-6.9 < mcPart.eta() && mcPart.eta() < -4.9) + multFDDC++; + if (4.7 < mcPart.eta() && mcPart.eta() < 6.3) + multFDDA++; + } + cursors.tableExtraMc(multFT0A, multFT0C, multFV0A, multFDDA, multFDDC, multBarrelEta05, multBarrelEta08, multBarrelEta10, mccollision.posZ()); + } + + //__________________________________________________ + template + void collisionProcessMFT(TCollision const& collision, TMFTTracks const& mfttracks, TBestCollisionsFwd const& retracks, TMultBuffer& mults, TOutputGroup& cursors) + { + int nAllTracks = 0; + int nTracks = 0; + + for (const auto& track : mfttracks) { + if (track.nClusters() >= 5) { // hardcoded for now + nAllTracks++; + } + } + + if (retracks.size() > 0) { + for (const auto& retrack : retracks) { + auto track = retrack.mfttrack(); + if (track.nClusters() < 5) { + continue; // min cluster requirement + } + if ((track.eta() > -2.0f) && (track.eta() < -3.9f)) { + continue; // too far to be of true interest + } + if (std::abs(retrack.bestDCAXY()) > 2.0f) { + continue; // does not point to PV properly + } + nTracks++; + } + } + cursors.mftMults(nAllTracks, nTracks); + mults[collision.globalIndex()].multMFTAllTracks = nAllTracks; + mults[collision.globalIndex()].multMFTTracks = nTracks; + } + + //__________________________________________________ + template + void ConfigureCentralityRun2(TCCDB& ccdb, TMetadata const& metadataInfo, TBC const& bc) + { + if (bc.runNumber() != mRunNumberCentrality) { + mRunNumberCentrality = bc.runNumber(); // mark that this run has been attempted already regardless of outcome + LOGF(info, "centrality loading procedure for timestamp=%llu, run number=%d", bc.timestamp(), bc.runNumber()); + TList* callst = nullptr; + // Check if the ccdb path is a root file + if (internalOpts.ccdbPathCentrality.value.find(".root") != std::string::npos) { + TFile f(internalOpts.ccdbPathCentrality.value.c_str(), "READ"); + f.GetObject(internalOpts.reconstructionPass.value.c_str(), callst); + if (!callst) { + f.ls(); + LOG(fatal) << "No calibration list " << internalOpts.reconstructionPass.value << " found."; + } + } else { + if (internalOpts.reconstructionPass.value == "") { + callst = ccdb->template getForRun(internalOpts.ccdbPathCentrality, bc.runNumber()); + } else if (internalOpts.reconstructionPass.value == "metadata") { + std::map metadata; + metadata["RecoPassName"] = metadataInfo.get("RecoPassName"); + LOGF(info, "Loading CCDB for reconstruction pass (from metadata): %s", metadataInfo.get("RecoPassName")); + callst = ccdb->template getSpecificForRun(internalOpts.ccdbPathCentrality, bc.runNumber(), metadata); + } else { + std::map metadata; + metadata["RecoPassName"] = internalOpts.reconstructionPass.value; + LOGF(info, "Loading CCDB for reconstruction pass (from provided argument): %s", internalOpts.reconstructionPass.value); + callst = ccdb->template getSpecificForRun(internalOpts.ccdbPathCentrality, bc.runNumber(), metadata); + } + } + + Run2V0MInfo.mCalibrationStored = false; + Run2V0AInfo.mCalibrationStored = false; + Run2SPDTksInfo.mCalibrationStored = false; + Run2SPDClsInfo.mCalibrationStored = false; + Run2CL0Info.mCalibrationStored = false; + Run2CL1Info.mCalibrationStored = false; + if (callst != nullptr) { + auto getccdb = [callst](const char* ccdbhname) { + TH1* h = reinterpret_cast(callst->FindObject(ccdbhname)); + return h; + }; + auto getformulaccdb = [callst](const char* ccdbhname) { + TFormula* f = reinterpret_cast(callst->FindObject(ccdbhname)); + return f; + }; + + if (internalOpts.mEnabledTables[kCentRun2V0Ms]) { + LOGF(debug, "Getting new histograms with %d run number for %d run number", mRunNumber, bc.runNumber()); + Run2V0MInfo.mhVtxAmpCorrV0A = getccdb("hVtx_fAmplitude_V0A_Normalized"); + Run2V0MInfo.mhVtxAmpCorrV0C = getccdb("hVtx_fAmplitude_V0C_Normalized"); + Run2V0MInfo.mhMultSelCalib = getccdb("hMultSelCalib_V0M"); + Run2V0MInfo.mMCScale = getformulaccdb(TString::Format("%s-V0M", internalOpts.generatorName->c_str()).Data()); + if ((Run2V0MInfo.mhVtxAmpCorrV0A != nullptr) && (Run2V0MInfo.mhVtxAmpCorrV0C != nullptr) && (Run2V0MInfo.mhMultSelCalib != nullptr)) { + if (internalOpts.generatorName->length() != 0) { + if (Run2V0MInfo.mMCScale != nullptr) { + for (int ixpar = 0; ixpar < 6; ++ixpar) { + Run2V0MInfo.mMCScalePars[ixpar] = Run2V0MInfo.mMCScale->GetParameter(ixpar); + } + } else { + // continue filling with non-valid values (105) + LOGF(info, "MC Scale information from V0M for run %d not available", bc.runNumber()); + } + } + Run2V0MInfo.mCalibrationStored = true; + } else { + // continue filling with non-valid values (105) + LOGF(info, "Calibration information from V0M for run %d corrupted, will fill V0M tables with dummy values", bc.runNumber()); + } + } + if (internalOpts.mEnabledTables[kCentRun2V0As]) { + LOGF(debug, "Getting new histograms with %d run number for %d run number", mRunNumber, bc.runNumber()); + Run2V0AInfo.mhVtxAmpCorrV0A = getccdb("hVtx_fAmplitude_V0A_Normalized"); + Run2V0AInfo.mhMultSelCalib = getccdb("hMultSelCalib_V0A"); + if ((Run2V0AInfo.mhVtxAmpCorrV0A != nullptr) && (Run2V0AInfo.mhMultSelCalib != nullptr)) { + Run2V0AInfo.mCalibrationStored = true; + } else { + // continue filling with non-valid values (105) + LOGF(info, "Calibration information from V0A for run %d corrupted, will fill V0A tables with dummy values", bc.runNumber()); + } + } + if (internalOpts.mEnabledTables[kCentRun2SPDTrks]) { + LOGF(debug, "Getting new histograms with %d run number for %d run number", mRunNumber, bc.runNumber()); + Run2SPDTksInfo.mhVtxAmpCorr = getccdb("hVtx_fnTracklets_Normalized"); + Run2SPDTksInfo.mhMultSelCalib = getccdb("hMultSelCalib_SPDTracklets"); + if ((Run2SPDTksInfo.mhVtxAmpCorr != nullptr) && (Run2SPDTksInfo.mhMultSelCalib != nullptr)) { + Run2SPDTksInfo.mCalibrationStored = true; + } else { + // continue filling with non-valid values (105) + LOGF(info, "Calibration information from SPD tracklets for run %d corrupted, will fill SPD tracklets tables with dummy values", bc.runNumber()); + } + } + if (internalOpts.mEnabledTables[kCentRun2SPDClss]) { + LOGF(debug, "Getting new histograms with %d run number for %d run number", mRunNumber, bc.runNumber()); + Run2SPDClsInfo.mhVtxAmpCorrCL0 = getccdb("hVtx_fnSPDClusters0_Normalized"); + Run2SPDClsInfo.mhVtxAmpCorrCL1 = getccdb("hVtx_fnSPDClusters1_Normalized"); + Run2SPDClsInfo.mhMultSelCalib = getccdb("hMultSelCalib_SPDClusters"); + if ((Run2SPDClsInfo.mhVtxAmpCorrCL0 != nullptr) && (Run2SPDClsInfo.mhVtxAmpCorrCL1 != nullptr) && (Run2SPDClsInfo.mhMultSelCalib != nullptr)) { + Run2SPDClsInfo.mCalibrationStored = true; + } else { + // continue filling with non-valid values (105) + LOGF(info, "Calibration information from SPD clusters for run %d corrupted, will fill SPD clusters tables with dummy values", bc.runNumber()); + } + } + if (internalOpts.mEnabledTables[kCentRun2CL0s]) { + LOGF(debug, "Getting new histograms with %d run number for %d run number", mRunNumber, bc.runNumber()); + Run2CL0Info.mhVtxAmpCorr = getccdb("hVtx_fnSPDClusters0_Normalized"); + Run2CL0Info.mhMultSelCalib = getccdb("hMultSelCalib_CL0"); + if ((Run2CL0Info.mhVtxAmpCorr != nullptr) && (Run2CL0Info.mhMultSelCalib != nullptr)) { + Run2CL0Info.mCalibrationStored = true; + } else { + // continue filling with non-valid values (105) + LOGF(info, "Calibration information from CL0 multiplicity for run %d corrupted, will fill CL0 multiplicity tables with dummy values", bc.runNumber()); + } + } + if (internalOpts.mEnabledTables[kCentRun2CL1s]) { + LOGF(debug, "Getting new histograms with %d run number for %d run number", mRunNumber, bc.runNumber()); + Run2CL1Info.mhVtxAmpCorr = getccdb("hVtx_fnSPDClusters1_Normalized"); + Run2CL1Info.mhMultSelCalib = getccdb("hMultSelCalib_CL1"); + if ((Run2CL1Info.mhVtxAmpCorr != nullptr) && (Run2CL1Info.mhMultSelCalib != nullptr)) { + Run2CL1Info.mCalibrationStored = true; + } else { + // continue filling with non-valid values (105) + LOGF(info, "Calibration information from CL1 multiplicity for run %d corrupted, will fill CL1 multiplicity tables with dummy values", bc.runNumber()); + } + } + } else { + LOGF(info, "Centrality calibration is not available in CCDB for run=%d at timestamp=%llu, will fill tables with dummy values", bc.runNumber(), bc.timestamp()); + } + } + } + + //__________________________________________________ + template + void ConfigureCentralityRun3(TCCDB& ccdb, TMetadata const& metadataInfo, TBC const& bc) + { + if (bc.runNumber() != mRunNumberCentrality) { + mRunNumberCentrality = bc.runNumber(); // mark that this run has been attempted already regardless of outcome + LOGF(info, "centrality loading procedure for timestamp=%llu, run number=%d", bc.timestamp(), bc.runNumber()); + TList* callst = nullptr; + // Check if the ccdb path is a root file + if (internalOpts.ccdbPathCentrality.value.find(".root") != std::string::npos) { + TFile f(internalOpts.ccdbPathCentrality.value.c_str(), "READ"); + f.GetObject(internalOpts.reconstructionPass.value.c_str(), callst); + if (!callst) { + f.ls(); + LOG(fatal) << "No calibration list " << internalOpts.reconstructionPass.value << " found."; + } + } else { + if (internalOpts.reconstructionPass.value == "") { + callst = ccdb->template getForRun(internalOpts.ccdbPathCentrality, bc.runNumber()); + } else if (internalOpts.reconstructionPass.value == "metadata") { + std::map metadata; + metadata["RecoPassName"] = metadataInfo.get("RecoPassName"); + LOGF(info, "Loading CCDB for reconstruction pass (from metadata): %s", metadataInfo.get("RecoPassName")); + callst = ccdb->template getSpecificForRun(internalOpts.ccdbPathCentrality, bc.runNumber(), metadata); + } else { + std::map metadata; + metadata["RecoPassName"] = internalOpts.reconstructionPass.value; + LOGF(info, "Loading CCDB for reconstruction pass (from provided argument): %s", internalOpts.reconstructionPass.value); + callst = ccdb->template getSpecificForRun(internalOpts.ccdbPathCentrality, bc.runNumber(), metadata); + } + } + + fv0aInfo.mCalibrationStored = false; + ft0mInfo.mCalibrationStored = false; + ft0aInfo.mCalibrationStored = false; + ft0cInfo.mCalibrationStored = false; + ft0cVariant1Info.mCalibrationStored = false; + fddmInfo.mCalibrationStored = false; + ntpvInfo.mCalibrationStored = false; + nGlobalInfo.mCalibrationStored = false; + mftInfo.mCalibrationStored = false; + if (callst != nullptr) { + LOGF(info, "Getting new histograms with %d run number for %d run number", mRunNumber, bc.runNumber()); + auto getccdb = [callst, bc](struct CalibrationInfo& estimator, const o2::framework::Configurable generatorName) { // TODO: to consider the name inside the estimator structure + estimator.mhMultSelCalib = reinterpret_cast(callst->FindObject(TString::Format("hCalibZeq%s", estimator.name.c_str()).Data())); + estimator.mMCScale = reinterpret_cast(callst->FindObject(TString::Format("%s-%s", generatorName->c_str(), estimator.name.c_str()).Data())); + if (estimator.mhMultSelCalib != nullptr) { + if (generatorName->length() != 0) { + LOGF(info, "Retrieving MC calibration for %d, generator name: %s", bc.runNumber(), generatorName->c_str()); + if (estimator.mMCScale != nullptr) { + for (int ixpar = 0; ixpar < 6; ++ixpar) { + estimator.mMCScalePars[ixpar] = estimator.mMCScale->GetParameter(ixpar); + LOGF(info, "Parameter index %i value %.5f", ixpar, estimator.mMCScalePars[ixpar]); + } + } else { + LOGF(warning, "MC Scale information from %s for run %d not available", estimator.name.c_str(), bc.runNumber()); + } + } + estimator.mCalibrationStored = true; + estimator.isSane(); + } else { + LOGF(info, "Calibration information from %s for run %d not available, will fill this estimator with invalid values and continue (no crash).", estimator.name.c_str(), bc.runNumber()); + } + }; + + // invoke loading only for requested centralities + if (internalOpts.mEnabledTables[kCentFV0As]) + getccdb(fv0aInfo, internalOpts.generatorName); + if (internalOpts.mEnabledTables[kCentFT0Ms]) + getccdb(ft0mInfo, internalOpts.generatorName); + if (internalOpts.mEnabledTables[kCentFT0As]) + getccdb(ft0aInfo, internalOpts.generatorName); + if (internalOpts.mEnabledTables[kCentFT0Cs]) + getccdb(ft0cInfo, internalOpts.generatorName); + if (internalOpts.mEnabledTables[kCentFT0CVariant1s]) + getccdb(ft0cVariant1Info, internalOpts.generatorName); + if (internalOpts.mEnabledTables[kCentFDDMs]) + getccdb(fddmInfo, internalOpts.generatorName); + if (internalOpts.mEnabledTables[kCentNTPVs]) + getccdb(ntpvInfo, internalOpts.generatorName); + if (internalOpts.mEnabledTables[kCentNGlobals]) + getccdb(nGlobalInfo, internalOpts.generatorName); + if (internalOpts.mEnabledTables[kCentMFTs]) + getccdb(mftInfo, internalOpts.generatorName); + } else { + LOGF(info, "Centrality calibration is not available in CCDB for run=%d at timestamp=%llu, will fill tables with dummy values", bc.runNumber(), bc.timestamp()); + } + } + } + + //__________________________________________________ + template + void generateCentralitiesRun3(TCCDB& ccdb, TMetadata const& metadataInfo, TBCs const& bcs, TMultBuffer const& mults, TOutputGroup& cursors) + { + // takes multiplicity buffer and generates the desirable centrality values (if any) + + // first step: did someone actually ask for it? Otherwise, go home + if ( + internalOpts.mEnabledTables[kCentFV0As] || internalOpts.mEnabledTables[kCentFT0Ms] || + internalOpts.mEnabledTables[kCentFT0As] || internalOpts.mEnabledTables[kCentFT0Cs] || + internalOpts.mEnabledTables[kCentFT0CVariant1s] || internalOpts.mEnabledTables[kCentFDDMs] || + internalOpts.mEnabledTables[kCentNTPVs] || internalOpts.mEnabledTables[kCentNGlobals] || + internalOpts.mEnabledTables[kCentMFTs] || internalOpts.mEnabledTables[kBCCentFT0Ms] || + internalOpts.mEnabledTables[kBCCentFT0As] || internalOpts.mEnabledTables[kBCCentFT0Cs]) { + // check and update centrality calibration objects for Run 3 + const auto& firstbc = bcs.begin(); + ConfigureCentralityRun3(ccdb, metadataInfo, firstbc); + + /************************************************************ + * @brief Populates a table with data based on the given calibration information and multiplicity. + * + * @param table The table to populate. + * @param estimator The calibration information. + * @param multiplicity The multiplicity value. + *************************************************************/ + + auto populateTable = [&](auto& table, struct CalibrationInfo& estimator, float multiplicity, bool isInelGt0) { + const bool assignOutOfRange = internalOpts.embedINELgtZEROselection && !isInelGt0; + auto scaleMC = [](float x, float pars[6]) { + return std::pow(((pars[0] + pars[1] * std::pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); + }; + + float percentile = 105.0f; + float scaledMultiplicity = multiplicity; + if (estimator.mCalibrationStored) { + if (estimator.mMCScale != nullptr) { + scaledMultiplicity = scaleMC(multiplicity, estimator.mMCScalePars); + LOGF(debug, "Unscaled %s multiplicity: %f, scaled %s multiplicity: %f", estimator.name.c_str(), multiplicity, estimator.name.c_str(), scaledMultiplicity); + } + percentile = estimator.mhMultSelCalib->GetBinContent(estimator.mhMultSelCalib->FindFixBin(scaledMultiplicity)); + if (assignOutOfRange) + percentile = 100.5f; + } + LOGF(debug, "%s centrality/multiplicity percentile = %.0f for a zvtx eq %s value %.0f", estimator.name.c_str(), percentile, estimator.name.c_str(), scaledMultiplicity); + table(percentile); + return percentile; + }; + + // populate centralities per event + for (size_t iEv = 0; iEv < mults.size(); iEv++) { + bool isInelGt0 = (mults[iEv].multNContribsEta1 > 0); + if (internalOpts.mEnabledTables[kCentFV0As]) + populateTable(cursors.centFV0A, fv0aInfo, mults[iEv].multFV0AZeq, isInelGt0); + if (internalOpts.mEnabledTables[kCentFT0Ms]) + populateTable(cursors.centFT0M, ft0mInfo, mults[iEv].multFT0AZeq + mults[iEv].multFT0CZeq, isInelGt0); + if (internalOpts.mEnabledTables[kCentFT0As]) + populateTable(cursors.centFT0A, ft0aInfo, mults[iEv].multFT0AZeq, isInelGt0); + if (internalOpts.mEnabledTables[kCentFT0Cs]) + populateTable(cursors.centFT0C, ft0cInfo, mults[iEv].multFT0CZeq, isInelGt0); + if (internalOpts.mEnabledTables[kCentFT0CVariant1s]) + populateTable(cursors.centFT0CVariant1, ft0cVariant1Info, mults[iEv].multFT0CZeq, isInelGt0); + if (internalOpts.mEnabledTables[kCentFDDMs]) + populateTable(cursors.centFDDM, fddmInfo, mults[iEv].multFDDAZeq + mults[iEv].multFDDCZeq, isInelGt0); + if (internalOpts.mEnabledTables[kCentNTPVs]) + populateTable(cursors.centNTPV, ntpvInfo, mults[iEv].multNContribs, isInelGt0); + if (internalOpts.mEnabledTables[kCentNGlobals]) + populateTable(cursors.centNGlobals, nGlobalInfo, mults[iEv].multGlobalTracks, isInelGt0); + if (internalOpts.mEnabledTables[kCentMFTs]) + populateTable(cursors.centMFTs, mftInfo, mults[iEv].multMFTTracks, isInelGt0); + } + + // populate centralities per BC + for (size_t ibc = 0; ibc < static_cast(bcs.size()); ibc++) { + float bcMultFT0A = 0; + float bcMultFT0C = 0; + + const auto& bc = bcs.rawIteratorAt(ibc); + if (bc.has_foundFT0()) { + const auto& ft0 = bc.foundFT0(); + for (const auto& amplitude : ft0.amplitudeA()) { + bcMultFT0A += amplitude; + } + for (const auto& amplitude : ft0.amplitudeC()) { + bcMultFT0C += amplitude; + } + } else { + bcMultFT0A = -999.f; + bcMultFT0C = -999.f; + } + + if (internalOpts.mEnabledTables[kBCCentFT0Ms]) + populateTable(cursors.bcCentFT0M, ft0mInfo, bcMultFT0A + bcMultFT0C, true); + if (internalOpts.mEnabledTables[kBCCentFT0As]) + populateTable(cursors.bcCentFT0A, ft0aInfo, bcMultFT0A, true); + if (internalOpts.mEnabledTables[kBCCentFT0Cs]) + populateTable(cursors.bcCentFT0C, ft0cInfo, bcMultFT0C, true); + } + } + } + //__________________________________________________ + template + void generateCentralitiesRun2(TCCDB& ccdb, TMetadata const& metadataInfo, TBCs const& bcs, TMultBuffer const& mults, TOutputGroup& cursors) + { + // takes multiplicity buffer and generates the desirable centrality values (if any) + // For Run 2 + if ( + internalOpts.mEnabledTables[kCentRun2V0Ms] || internalOpts.mEnabledTables[kCentRun2V0As] || + internalOpts.mEnabledTables[kCentRun2SPDTrks] || internalOpts.mEnabledTables[kCentRun2SPDClss] || + internalOpts.mEnabledTables[kCentRun2CL0s] || internalOpts.mEnabledTables[kCentRun2CL1s]) { + // check and update centrality calibration objects for Run 3 + const auto& firstbc = bcs.begin(); + ConfigureCentralityRun2(ccdb, metadataInfo, firstbc); + + auto scaleMC = [](float x, float pars[6]) { + return std::pow(((pars[0] + pars[1] * std::pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); + }; + + // populate centralities per event + for (size_t iEv = 0; iEv < mults.size(); iEv++) { + if (internalOpts.mEnabledTables[kCentRun2V0Ms]) { + float cV0M = 105.0f; + if (Run2V0MInfo.mCalibrationStored) { + float v0m; + if (Run2V0MInfo.mMCScale != nullptr) { + v0m = scaleMC(mults[iEv].multFV0A + mults[iEv].multFV0C, Run2V0MInfo.mMCScalePars); + LOGF(debug, "Unscaled v0m: %f, scaled v0m: %f", mults[iEv].multFV0A + mults[iEv].multFV0C, v0m); + } else { + v0m = mults[iEv].multFV0A * Run2V0MInfo.mhVtxAmpCorrV0A->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0A->FindFixBin(mults[iEv].posZ)) + + mults[iEv].multFV0C * Run2V0MInfo.mhVtxAmpCorrV0C->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0C->FindFixBin(mults[iEv].posZ)); + } + cV0M = Run2V0MInfo.mhMultSelCalib->GetBinContent(Run2V0MInfo.mhMultSelCalib->FindFixBin(v0m)); + } + LOGF(debug, "centRun2V0M=%.0f", cV0M); + // fill centrality columns + cursors.centRun2V0M(cV0M); + } + if (internalOpts.mEnabledTables[kCentRun2V0As]) { + float cV0A = 105.0f; + if (Run2V0AInfo.mCalibrationStored) { + float v0a = mults[iEv].multFV0A * Run2V0AInfo.mhVtxAmpCorrV0A->GetBinContent(Run2V0AInfo.mhVtxAmpCorrV0A->FindFixBin(mults[iEv].posZ)); + cV0A = Run2V0AInfo.mhMultSelCalib->GetBinContent(Run2V0AInfo.mhMultSelCalib->FindFixBin(v0a)); + } + LOGF(debug, "centRun2V0A=%.0f", cV0A); + // fill centrality columns + cursors.centRun2V0A(cV0A); + } + if (internalOpts.mEnabledTables[kCentRun2SPDTrks]) { + float cSPD = 105.0f; + if (Run2SPDTksInfo.mCalibrationStored) { + float spdm = mults[iEv].multTracklets * Run2SPDTksInfo.mhVtxAmpCorr->GetBinContent(Run2SPDTksInfo.mhVtxAmpCorr->FindFixBin(mults[iEv].posZ)); + cSPD = Run2SPDTksInfo.mhMultSelCalib->GetBinContent(Run2SPDTksInfo.mhMultSelCalib->FindFixBin(spdm)); + } + LOGF(debug, "centSPDTracklets=%.0f", cSPD); + cursors.centRun2SPDTracklets(cSPD); + } + if (internalOpts.mEnabledTables[kCentRun2SPDClss]) { + float cSPD = 105.0f; + if (Run2SPDClsInfo.mCalibrationStored) { + float spdm = mults[iEv].spdClustersL0 * Run2SPDClsInfo.mhVtxAmpCorrCL0->GetBinContent(Run2SPDClsInfo.mhVtxAmpCorrCL0->FindFixBin(mults[iEv].posZ)) + + mults[iEv].spdClustersL1 * Run2SPDClsInfo.mhVtxAmpCorrCL1->GetBinContent(Run2SPDClsInfo.mhVtxAmpCorrCL1->FindFixBin(mults[iEv].posZ)); + cSPD = Run2SPDClsInfo.mhMultSelCalib->GetBinContent(Run2SPDClsInfo.mhMultSelCalib->FindFixBin(spdm)); + } + LOGF(debug, "centSPDClusters=%.0f", cSPD); + cursors.centRun2SPDClusters(cSPD); + } + if (internalOpts.mEnabledTables[kCentRun2CL0s]) { + float cCL0 = 105.0f; + if (Run2CL0Info.mCalibrationStored) { + float cl0m = mults[iEv].spdClustersL0 * Run2CL0Info.mhVtxAmpCorr->GetBinContent(Run2CL0Info.mhVtxAmpCorr->FindFixBin(mults[iEv].posZ)); + cCL0 = Run2CL0Info.mhMultSelCalib->GetBinContent(Run2CL0Info.mhMultSelCalib->FindFixBin(cl0m)); + } + LOGF(debug, "centCL0=%.0f", cCL0); + cursors.centRun2CL0(cCL0); + } + if (internalOpts.mEnabledTables[kCentRun2CL1s]) { + float cCL1 = 105.0f; + if (Run2CL1Info.mCalibrationStored) { + float cl1m = mults[iEv].spdClustersL1 * Run2CL1Info.mhVtxAmpCorr->GetBinContent(Run2CL1Info.mhVtxAmpCorr->FindFixBin(mults[iEv].posZ)); + cCL1 = Run2CL1Info.mhMultSelCalib->GetBinContent(Run2CL1Info.mhMultSelCalib->FindFixBin(cl1m)); + } + LOGF(debug, "centCL1=%.0f", cCL1); + cursors.centRun2CL1(cCL1); + } + } + } + } +}; // end BuilderModule + +} // namespace multiplicity +} // namespace common +} // namespace o2 + +#endif // COMMON_TOOLS_MULTMODULE_H_ diff --git a/Common/Tools/Multiplicity/multGlauberNBDFitter.cxx b/Common/Tools/Multiplicity/multGlauberNBDFitter.cxx index f4c47b60080..a765db72448 100644 --- a/Common/Tools/Multiplicity/multGlauberNBDFitter.cxx +++ b/Common/Tools/Multiplicity/multGlauberNBDFitter.cxx @@ -309,6 +309,7 @@ Bool_t multGlauberNBDFitter::DoFit() fk = fGlauberNBD->GetParameter(1); ff = fGlauberNBD->GetParameter(2); fnorm = fGlauberNBD->GetParameter(3); + fdMu = fGlauberNBD->GetParameter(4); return fitptr.Get()->IsValid(); } @@ -369,9 +370,25 @@ Double_t multGlauberNBDFitter::ContinuousNBD(Double_t n, Double_t mu, Double_t k return F; } -void multGlauberNBDFitter::CalculateAvNpNc(TProfile* lNPartProf, TProfile* lNCollProf, TH2F* lNPart2DPlot, TH2F* lNColl2DPlot, TH1F* hPercentileMap) +void multGlauberNBDFitter::CalculateAvNpNc(TProfile* lNPartProf, TProfile* lNCollProf, TH2F* lNPart2DPlot, TH2F* lNColl2DPlot, TH1F* hPercentileMap, Double_t lLoRange, Double_t lHiRange) { cout << "Calculating , in centrality bins..." << endl; + cout << "Range to calculate: " << lLoRange << " to " << lHiRange << endl; + + cout << "Acquiring values from the fit function..." << endl; + + fMu = fGlauberNBD->GetParameter(0); + fk = fGlauberNBD->GetParameter(1); + ff = fGlauberNBD->GetParameter(2); + fnorm = fGlauberNBD->GetParameter(3); + fdMu = fGlauberNBD->GetParameter(4); + + cout << "Please inspect now: " << endl; + cout << "Glauber NBD mu ............: " << fMu << endl; + cout << "Glauber NBD k .............: " << fk << endl; + cout << "Glauber NBD f .............: " << ff << endl; + cout << "Glauber NBD norm ..........: " << fnorm << endl; + cout << "Glauber NBD dmu/dNanc .....: " << fdMu << endl; //2-fold nested loop: // + looping over all Nancestor combinations @@ -379,8 +396,9 @@ void multGlauberNBDFitter::CalculateAvNpNc(TProfile* lNPartProf, TProfile* lNCol // ^---> final product already multiplicity-binned //______________________________________________________ - Double_t lLoRange, lHiRange; - fGlauberNBD->GetRange(lLoRange, lHiRange); + if (lLoRange < -1 && lHiRange < -1) { + fGlauberNBD->GetRange(lLoRange, lHiRange); + } // bypass to zero for (int ibin = 0; ibin < fNNpNcPairs; ibin++) { if (ibin % 2000 == 0) diff --git a/Common/Tools/Multiplicity/multGlauberNBDFitter.h b/Common/Tools/Multiplicity/multGlauberNBDFitter.h index b6adb081151..42d5cab046f 100644 --- a/Common/Tools/Multiplicity/multGlauberNBDFitter.h +++ b/Common/Tools/Multiplicity/multGlauberNBDFitter.h @@ -75,7 +75,7 @@ class multGlauberNBDFitter : public TNamed Double_t ContinuousNBD(Double_t n, Double_t mu, Double_t k); //For estimating Npart, Ncoll in multiplicity bins - void CalculateAvNpNc(TProfile* lNPartProf, TProfile* lNCollProf, TH2F* lNPart2DPlot, TH2F* lNColl2DPlot, TH1F* hPercentileMap); + void CalculateAvNpNc(TProfile* lNPartProf, TProfile* lNCollProf, TH2F* lNPart2DPlot, TH2F* lNColl2DPlot, TH1F* hPercentileMap, Double_t lLoRange = -1, Double_t lHiRange = -1); //void Print(Option_t *option="") const; diff --git a/Common/Tools/PID/checkPidPacking.cxx b/Common/Tools/PID/checkPidPacking.cxx index c503ee1b288..84f72c4f48c 100644 --- a/Common/Tools/PID/checkPidPacking.cxx +++ b/Common/Tools/PID/checkPidPacking.cxx @@ -16,7 +16,10 @@ /// \since 03/05/2024 /// -#include "Common/DataModel/PIDResponse.h" +#include + +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "TH1F.h" #include "TCanvas.h" #include "TRandom.h" @@ -32,7 +35,7 @@ bool process(std::string outputName, int nevents = 100000) NsigmaContainer() {} void operator()(const int8_t& packed) { mPacked = packed; } int8_t mPacked = 0; - float unpack() { return aod::pidutils::unPackInTable(mPacked); } + float unpack() { return T::unPackInTable(mPacked); } } container; TH1F* hgaus = new TH1F("hgaus", "", 20 / T::bin_width, @@ -55,12 +58,12 @@ bool process(std::string outputName, int nevents = 100000) for (int i = 0; i < nevents; i++) { float nsigma = gRandom->Gaus(0, 1); hgaus->Fill(nsigma); - aod::pidutils::packInTable(nsigma, container); + T::packInTable(nsigma, container); hgausPacked->Fill(container.unpack()); nsigma = gRandom->Uniform(-10, 10); huniform->Fill(nsigma); - aod::pidutils::packInTable(nsigma, container); + T::packInTable(nsigma, container); huniformPacked->Fill(container.unpack()); } diff --git a/Common/Tools/StandardCCDBLoader.h b/Common/Tools/StandardCCDBLoader.h new file mode 100644 index 00000000000..2134fec2666 --- /dev/null +++ b/Common/Tools/StandardCCDBLoader.h @@ -0,0 +1,112 @@ +// 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. + +/// \file StandardCCDBLoader.cxx +/// \brief A simple object to handle ccdb queries +/// \author ALICE + +#ifndef COMMON_TOOLS_STANDARDCCDBLOADER_H_ +#define COMMON_TOOLS_STANDARDCCDBLOADER_H_ + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisDataModel.h" + +#include +#include +#include +#include + +//__________________________________________ +// Standard class to load stuff +// such as matLUT, B and mean Vertex +// partial requests possible. + +namespace o2 +{ +namespace common +{ + +// ConfigurableGroup with locations +struct StandardCCDBLoaderConfigurables : o2::framework::ConfigurableGroup { + std::string prefix = "ccdb"; + o2::framework::Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + o2::framework::Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + o2::framework::Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + o2::framework::Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; +}; + +class StandardCCDBLoader +{ + public: + StandardCCDBLoader() + { + // constructor - null pointers + mMeanVtx = nullptr; + grpmag = nullptr; + lut = nullptr; + }; + + // commonly needed objects + const o2::dataformats::MeanVertexObject* mMeanVtx = nullptr; + o2::parameters::GRPMagField* grpmag = nullptr; + o2::base::MatLayerCylSet* lut = nullptr; + int runNumber = -1; + + template + void initCCDBfromBCs(TConfigurableGroup const& cGroup, TCCDB& ccdb, TBCs& bcs, bool getMeanVertex = true) + { + // instant load from BCs table. Bonus: protect also against empty bcs + if (bcs.size() == 0) { + return; + } + auto bc = bcs.begin(); + initCCDB(cGroup, ccdb, bc.runNumber(), getMeanVertex); + } + + template + void initCCDB(TConfigurableGroup const& cGroup, TCCDB& ccdb, int currentRunNumber, bool getMeanVertex = true) + { + if (runNumber == currentRunNumber) { + return; + } + + // load matLUT for this timestamp + if (!lut) { + LOG(info) << "Loading material look-up table for timestamp: " << currentRunNumber; + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->template getForRun(cGroup.lutPath.value, currentRunNumber)); + } else { + LOG(info) << "Material look-up table already in place. Not reloading."; + } + + grpmag = ccdb->template getForRun(cGroup.grpmagPath.value, currentRunNumber); + LOG(info) << "Setting global propagator magnetic field to current " << grpmag->getL3Current() << " A for run " << currentRunNumber << " from its GRPMagField CCDB object"; + o2::base::Propagator::initFieldFromGRP(grpmag); + LOG(info) << "Setting global propagator material propagation LUT"; + o2::base::Propagator::Instance()->setMatLUT(lut); + if (getMeanVertex) { + // only try this if explicitly requested + mMeanVtx = ccdb->template getForRun(cGroup.mVtxPath.value, currentRunNumber); + } else { + mMeanVtx = nullptr; + } + + runNumber = currentRunNumber; + } +}; + +} // namespace common +} // namespace o2 + +#endif // COMMON_TOOLS_STANDARDCCDBLOADER_H_ diff --git a/Common/Tools/TrackPropagationModule.h b/Common/Tools/TrackPropagationModule.h new file mode 100644 index 00000000000..305a7c774f2 --- /dev/null +++ b/Common/Tools/TrackPropagationModule.h @@ -0,0 +1,296 @@ +// 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. + +/// \file TrackPropagationModule.h +/// \brief track propagation module functionality to be used in core services +/// \author ALICE + +#ifndef COMMON_TOOLS_TRACKPROPAGATIONMODULE_H_ +#define COMMON_TOOLS_TRACKPROPAGATIONMODULE_H_ + +#include "TableHelper.h" + +#include "Common/Tools/TrackTuner.h" + +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/Configurable.h" +#include "Framework/HistogramSpec.h" + +#include +#include +#include +#include +#include + +//__________________________________________ +// track propagation module +// +// this class is capable of performing the usual track propagation +// and table creation it is a demonstration of core service +// plug-in functionality that could be used to reduce the number of +// heavyweight (e.g. mat-LUT-using, propagating) core services to +// reduce overhead and make it easier to pipeline / parallelize +// bottlenecks in core services + +namespace o2 +{ +namespace common +{ + +struct TrackPropagationProducts : o2::framework::ProducesGroup { + o2::framework::Produces tracksParPropagated; + o2::framework::Produces tracksParExtensionPropagated; + o2::framework::Produces tracksParCovPropagated; + o2::framework::Produces tracksParCovExtensionPropagated; + o2::framework::Produces tracksDCA; + o2::framework::Produces tracksDCACov; + o2::framework::Produces tunertable; +}; + +struct TrackPropagationConfigurables : o2::framework::ConfigurableGroup { + std::string prefix = "trackPropagation"; + o2::framework::Configurable minPropagationRadius{"minPropagationDistance", o2::constants::geom::XTPCInnerRef + 0.1, "Only tracks which are at a smaller radius will be propagated, defaults to TPC inner wall"}; + // for TrackTuner only (MC smearing) + o2::framework::Configurable useTrackTuner{"useTrackTuner", false, "Apply track tuner corrections to MC"}; + o2::framework::Configurable useTrkPid{"useTrkPid", false, "use pid in tracking"}; + o2::framework::Configurable fillTrackTunerTable{"fillTrackTunerTable", false, "flag to fill track tuner table"}; + o2::framework::Configurable trackTunerConfigSource{"trackTunerConfigSource", aod::track_tuner::InputString, "1: input string; 2: TrackTuner Configurables"}; + o2::framework::Configurable trackTunerParams{"trackTunerParams", "debugInfo=0|updateTrackDCAs=1|updateTrackCovMat=1|updateCurvature=0|updateCurvatureIU=0|updatePulls=0|isInputFileFromCCDB=1|pathInputFile=Users/m/mfaggin/test/inputsTrackTuner/PbPb2022|nameInputFile=trackTuner_DataLHC22sPass5_McLHC22l1b2_run529397.root|pathFileQoverPt=Users/h/hsharma/qOverPtGraphs|nameFileQoverPt=D0sigma_Data_removal_itstps_MC_LHC22b1b.root|usePvRefitCorrections=0|qOverPtMC=-1.|qOverPtData=-1.", "TrackTuner parameter initialization (format: =|=)"}; + o2::framework::ConfigurableAxis axisPtQA{"axisPtQA", {o2::framework::VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for QA histograms"}; +}; + +class TrackPropagationModule +{ + public: + TrackPropagationModule() + { + // constructor + } + + // controls behaviour + bool fillTracks = false; + bool fillTracksCov = false; + bool fillTracksDCA = false; + bool fillTracksDCACov = false; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + + // pointers to objs needed for operation + std::shared_ptr trackTunedTracks; + + // Running variables + std::array mDcaInfo; + o2::dataformats::DCA mDcaInfoCov; + o2::dataformats::VertexBase mVtx; + o2::track::TrackParametrization mTrackPar; + o2::track::TrackParametrizationWithError mTrackParCov; + + template + void init(TConfigurableGroup const& cGroup, TrackTuner& trackTunerObj, THistoRegistry& registry, TInitContext& initContext) + { + // Checking if the tables are requested in the workflow and enabling them + fillTracks = isTableRequiredInWorkflow(initContext, "Tracks"); + fillTracksCov = isTableRequiredInWorkflow(initContext, "TracksCov"); + fillTracksDCA = isTableRequiredInWorkflow(initContext, "TracksDCA"); + fillTracksDCACov = isTableRequiredInWorkflow(initContext, "TracksDCACov"); + + if (!fillTracks) { + LOGF(info, "Track propagation to PV not required. Suppressing all further processing and logs."); + } + + LOGF(info, " Track propagation table detection results:"); + LOGF(info, " ---> Will generate Tracks table."); + if (fillTracksCov) { + LOGF(info, "---> Will generate TracksCov table."); + } + if (fillTracksDCA) { + LOGF(info, "---> Will generate TracksDCA table."); + } + if (fillTracksDCACov) { + LOGF(info, "---> Will generate TracksDCACov table."); + } + if (fillTracksCov) { + LOGF(info, "**************************************************************"); + LOGF(info, " Warning: TracksCov has been requested due to a subscription!"); + LOGF(info, " Please be mindful that generating track covariances requires"); + LOGF(info, " a significant extra amount of CPU and memory. If not strictly"); + LOGF(info, " necessary, requesting TracksCov should be avoided to save"); + LOGF(info, " these additional resouces."); + LOGF(info, "**************************************************************"); + } + + /// TrackTuner initialization + if (cGroup.useTrackTuner.value) { + std::string outputStringParams = ""; + switch (cGroup.trackTunerConfigSource.value) { + case o2::aod::track_tuner::InputString: + outputStringParams = trackTunerObj.configParams(cGroup.trackTunerParams.value); + break; + case o2::aod::track_tuner::Configurables: + outputStringParams = trackTunerObj.configParams(); + break; + + default: + LOG(fatal) << "TrackTuner configuration source not defined. Fix it! (Supported options: input string (1); Configurables (2))"; + break; + } + + trackTunerObj.getDcaGraphs(); + } + + trackTunedTracks = registry.template add("trackTunedTracks", "trackTunedTracks", o2::framework::kTH1D, {{1, 0.5f, 1.5f}}); + + // Histograms for track tuner + o2::framework::AxisSpec axisBinsDCA = {600, -0.15f, 0.15f, "#it{dca}_{xy} (cm)"}; + registry.template add("hDCAxyVsPtRec", "hDCAxyVsPtRec", o2::framework::kTH2F, {axisBinsDCA, cGroup.axisPtQA}); + registry.template add("hDCAxyVsPtMC", "hDCAxyVsPtMC", o2::framework::kTH2F, {axisBinsDCA, cGroup.axisPtQA}); + registry.template add("hDCAzVsPtRec", "hDCAzVsPtRec", o2::framework::kTH2F, {axisBinsDCA, cGroup.axisPtQA}); + registry.template add("hDCAzVsPtMC", "hDCAzVsPtMC", o2::framework::kTH2F, {axisBinsDCA, cGroup.axisPtQA}); + } + + template + void fillTrackTables(TConfigurableGroup const& cGroup, TrackTuner& trackTunerObj, TCCDBLoader const& ccdbLoader, TCollisions const& collisions, TTracks const& tracks, TOutputGroup& cursors, THistoRegistry& registry) + { + if (!fillTracks) { + return; // suppress everything + } + + if (fillTracksCov) { + cursors.tracksParCovPropagated.reserve(tracks.size()); + cursors.tracksParCovExtensionPropagated.reserve(tracks.size()); + if (fillTracksDCACov) { + cursors.tracksDCACov.reserve(tracks.size()); + } + } else { + cursors.tracksParPropagated.reserve(tracks.size()); + cursors.tracksParExtensionPropagated.reserve(tracks.size()); + if (fillTracksDCA) { + cursors.tracksDCA.reserve(tracks.size()); + } + } + + for (const auto& track : tracks) { + if (fillTracksCov) { + if (fillTracksDCA || fillTracksDCACov) { + mDcaInfoCov.set(999, 999, 999, 999, 999); + } + setTrackParCov(track, mTrackParCov); + if (cGroup.useTrkPid.value) { + mTrackParCov.setPID(track.pidForTracking()); + } + } else { + if (fillTracksDCA) { + mDcaInfo[0] = 999; + mDcaInfo[1] = 999; + } + setTrackPar(track, mTrackPar); + if (cGroup.useTrkPid.value) { + mTrackPar.setPID(track.pidForTracking()); + } + } + // auto trackParCov = getTrackParCov(track); + o2::aod::track::TrackTypeEnum trackType = (o2::aod::track::TrackTypeEnum)track.trackType(); + // std::array trackPxPyPz; + // std::array trackPxPyPzTuned = {0.0, 0.0, 0.0}; + double q2OverPtNew = -9999.; + // Only propagate tracks which have passed the innermost wall of the TPC (e.g. skipping loopers etc). Others fill unpropagated. + if (track.trackType() == o2::aod::track::TrackIU && track.x() < cGroup.minPropagationRadius.value) { + if (fillTracksCov) { + if constexpr (isMc) { // checking MC and fillCovMat block begins + // bool hasMcParticle = track.has_mcParticle(); + if (cGroup.useTrackTuner.value) { + trackTunedTracks->Fill(1); // all tracks + bool hasMcParticle = track.has_mcParticle(); + if (hasMcParticle) { + auto mcParticle = track.mcParticle(); + trackTunerObj.tuneTrackParams(mcParticle, mTrackParCov, matCorr, &mDcaInfoCov, trackTunedTracks); + q2OverPtNew = mTrackParCov.getQ2Pt(); + } + } + } // MC and fillCovMat block ends + } + bool isPropagationOK = true; + + if (track.has_collision()) { + auto const& collision = collisions.rawIteratorAt(track.collisionId()); + if (fillTracksCov) { + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + isPropagationOK = o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, mTrackParCov, 2.f, matCorr, &mDcaInfoCov); + } else { + isPropagationOK = o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, mTrackPar, 2.f, matCorr, &mDcaInfo); + } + } else { + if (fillTracksCov) { + mVtx.setPos({ccdbLoader.mMeanVtx->getX(), ccdbLoader.mMeanVtx->getY(), ccdbLoader.mMeanVtx->getZ()}); + mVtx.setCov(ccdbLoader.mMeanVtx->getSigmaX() * ccdbLoader.mMeanVtx->getSigmaX(), 0.0f, ccdbLoader.mMeanVtx->getSigmaY() * ccdbLoader.mMeanVtx->getSigmaY(), 0.0f, 0.0f, ccdbLoader.mMeanVtx->getSigmaZ() * ccdbLoader.mMeanVtx->getSigmaZ()); + isPropagationOK = o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, mTrackParCov, 2.f, matCorr, &mDcaInfoCov); + } else { + isPropagationOK = o2::base::Propagator::Instance()->propagateToDCABxByBz({ccdbLoader.mMeanVtx->getX(), ccdbLoader.mMeanVtx->getY(), ccdbLoader.mMeanVtx->getZ()}, mTrackPar, 2.f, matCorr, &mDcaInfo); + } + } + if (isPropagationOK) { + trackType = o2::aod::track::Track; + } + // filling some QA histograms for track tuner test purpose + if (fillTracksCov) { + if constexpr (isMc) { // checking MC and fillCovMat block begins + if (track.has_mcParticle() && isPropagationOK) { + auto mcParticle1 = track.mcParticle(); + // && abs(mcParticle1.pdgCode())==211 + if (mcParticle1.isPhysicalPrimary()) { + registry.fill(HIST("hDCAxyVsPtRec"), mDcaInfoCov.getY(), mTrackParCov.getPt()); + registry.fill(HIST("hDCAxyVsPtMC"), mDcaInfoCov.getY(), mcParticle1.pt()); + registry.fill(HIST("hDCAzVsPtRec"), mDcaInfoCov.getZ(), mTrackParCov.getPt()); + registry.fill(HIST("hDCAzVsPtMC"), mDcaInfoCov.getZ(), mcParticle1.pt()); + } + } + } // MC and fillCovMat block ends + } + } + // Filling modified Q/Pt values at IU/production point by track tuner in track tuner table + if (cGroup.useTrackTuner.value && cGroup.fillTrackTunerTable.value) { + cursors.tunertable(q2OverPtNew); + } + // LOG(info) << " trackPropagation (this value filled in tuner table)--> " << q2OverPtNew; + if (fillTracksCov) { + cursors.tracksParPropagated(track.collisionId(), trackType, mTrackParCov.getX(), mTrackParCov.getAlpha(), mTrackParCov.getY(), mTrackParCov.getZ(), mTrackParCov.getSnp(), mTrackParCov.getTgl(), mTrackParCov.getQ2Pt()); + cursors.tracksParExtensionPropagated(mTrackParCov.getPt(), mTrackParCov.getP(), mTrackParCov.getEta(), mTrackParCov.getPhi()); + // TODO do we keep the rho as 0? Also the sigma's are duplicated information + cursors.tracksParCovPropagated(std::sqrt(mTrackParCov.getSigmaY2()), std::sqrt(mTrackParCov.getSigmaZ2()), std::sqrt(mTrackParCov.getSigmaSnp2()), + std::sqrt(mTrackParCov.getSigmaTgl2()), std::sqrt(mTrackParCov.getSigma1Pt2()), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + cursors.tracksParCovExtensionPropagated(mTrackParCov.getSigmaY2(), mTrackParCov.getSigmaZY(), mTrackParCov.getSigmaZ2(), mTrackParCov.getSigmaSnpY(), + mTrackParCov.getSigmaSnpZ(), mTrackParCov.getSigmaSnp2(), mTrackParCov.getSigmaTglY(), mTrackParCov.getSigmaTglZ(), mTrackParCov.getSigmaTglSnp(), + mTrackParCov.getSigmaTgl2(), mTrackParCov.getSigma1PtY(), mTrackParCov.getSigma1PtZ(), mTrackParCov.getSigma1PtSnp(), mTrackParCov.getSigma1PtTgl(), + mTrackParCov.getSigma1Pt2()); + if (fillTracksDCA) { + cursors.tracksDCA(mDcaInfoCov.getY(), mDcaInfoCov.getZ()); + } + if (fillTracksDCACov) { + cursors.tracksDCACov(mDcaInfoCov.getSigmaY2(), mDcaInfoCov.getSigmaZ2()); + } + } else { + cursors.tracksParPropagated(track.collisionId(), trackType, mTrackPar.getX(), mTrackPar.getAlpha(), mTrackPar.getY(), mTrackPar.getZ(), mTrackPar.getSnp(), mTrackPar.getTgl(), mTrackPar.getQ2Pt()); + cursors.tracksParExtensionPropagated(mTrackPar.getPt(), mTrackPar.getP(), mTrackPar.getEta(), mTrackPar.getPhi()); + if (fillTracksDCA) { + cursors.tracksDCA(mDcaInfo[0], mDcaInfo[1]); + } + } + } + } +}; + +} // namespace common +} // namespace o2 + +#endif // COMMON_TOOLS_TRACKPROPAGATIONMODULE_H_ diff --git a/Common/Tools/TrackTuner.h b/Common/Tools/TrackTuner.h index 4d6876eaf39..26937eb9131 100644 --- a/Common/Tools/TrackTuner.h +++ b/Common/Tools/TrackTuner.h @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "CCDB/BasicCCDBManager.h" #include "CCDB/CcdbApi.h" @@ -77,7 +79,7 @@ struct TrackTuner : o2::framework::ConfigurableGroup { o2::framework::Configurable cfgUsePvRefitCorrections{"usePvRefitCorrections", false, "Flag to establish whether to use corrections obtained with or w/o PV refit"}; o2::framework::Configurable cfgQOverPtMC{"qOverPtMC", -1., "Scaling factor on q/pt of MC"}; o2::framework::Configurable cfgQOverPtData{"qOverPtData", -1., "Scaling factor on q/pt of data"}; - + o2::framework::Configurable cfgNPhiBins{"nPhiBins", 0, "Number of phi bins"}; /////////////////////////////// /// parameters to be configured bool debugInfo = false; @@ -97,30 +99,31 @@ struct TrackTuner : o2::framework::ConfigurableGroup { /////////////////////////////// bool isConfigFromString = false; bool isConfigFromConfigurables = false; + int nPhiBins = 1; o2::ccdb::CcdbApi ccdbApi; std::map metadata; - std::unique_ptr grDcaXYResVsPtPionMC; - std::unique_ptr grDcaXYResVsPtPionData; + std::vector> grDcaXYResVsPtPionMC; + std::vector> grDcaXYResVsPtPionData; - std::unique_ptr grDcaZResVsPtPionMC; - std::unique_ptr grDcaZResVsPtPionData; + std::vector> grDcaZResVsPtPionMC; + std::vector> grDcaZResVsPtPionData; - std::unique_ptr grDcaXYMeanVsPtPionMC; - std::unique_ptr grDcaXYMeanVsPtPionData; + std::vector> grDcaXYMeanVsPtPionMC; + std::vector> grDcaXYMeanVsPtPionData; - std::unique_ptr grDcaZMeanVsPtPionMC; - std::unique_ptr grDcaZMeanVsPtPionData; + std::vector> grDcaZMeanVsPtPionMC; + std::vector> grDcaZMeanVsPtPionData; std::unique_ptr grOneOverPtPionMC; // MC std::unique_ptr grOneOverPtPionData; // Data - std::unique_ptr grDcaXYPullVsPtPionMC; - std::unique_ptr grDcaXYPullVsPtPionData; + std::vector> grDcaXYPullVsPtPionMC; + std::vector> grDcaXYPullVsPtPionData; - std::unique_ptr grDcaZPullVsPtPionMC; - std::unique_ptr grDcaZPullVsPtPionData; + std::vector> grDcaZPullVsPtPionMC; + std::vector> grDcaZPullVsPtPionData; /// @brief Function doing a few sanity-checks on the configurations void checkConfig() @@ -191,6 +194,7 @@ struct TrackTuner : o2::framework::ConfigurableGroup { UsePvRefitCorrections, QOverPtMC, QOverPtData, + NPhiBins, NPars }; std::map mapParNames = { std::make_pair(DebugInfo, "debugInfo"), @@ -206,7 +210,8 @@ struct TrackTuner : o2::framework::ConfigurableGroup { std::make_pair(NameFileQoverPt, "nameFileQoverPt"), std::make_pair(UsePvRefitCorrections, "usePvRefitCorrections"), std::make_pair(QOverPtMC, "qOverPtMC"), - std::make_pair(QOverPtData, "qOverPtData")}; + std::make_pair(QOverPtData, "qOverPtData"), + std::make_pair(NPhiBins, "nPhiBins")}; /////////////////////////////////////////////////////////////////////////////////// LOG(info) << "[TrackTuner]"; LOG(info) << "[TrackTuner] >>> Parameters before the custom settings"; @@ -224,6 +229,7 @@ struct TrackTuner : o2::framework::ConfigurableGroup { LOG(info) << "[TrackTuner] usePvRefitCorrections = " << usePvRefitCorrections; LOG(info) << "[TrackTuner] qOverPtMC = " << qOverPtMC; LOG(info) << "[TrackTuner] qOverPtData = " << qOverPtData; + LOG(info) << "[TrackTuner] nPhiBins = " << nPhiBins; // ############################################################################################## // ######## split the original string, separating substrings delimited by "|" symbol ######## @@ -245,7 +251,7 @@ struct TrackTuner : o2::framework::ConfigurableGroup { /// check if the number of input parameters is correct if (static_cast(slices.size()) != NPars) { - LOG(fatal) << "[TrackTuner] " << slices.size() << " parameters provided, while " << NPars << " are expected. Fix it!"; + LOG(fatal) << "[TrackTuner] " << slices.size() << " parameters provided, while " << static_cast(NPars) << " are expected. Fix it!"; } // ################################################################################################################### @@ -337,7 +343,12 @@ struct TrackTuner : o2::framework::ConfigurableGroup { qOverPtData = std::stof(getValueString(QOverPtData)); outputString += ", qOverPtData=" + std::to_string(qOverPtData); LOG(info) << "[TrackTuner] qOverPtData = " << qOverPtData; - + // Configure nPhiBins + nPhiBins = std::stoi(getValueString(NPhiBins)); + outputString += ", nPhiBins=" + std::to_string(nPhiBins); + if (nPhiBins < 0) + LOG(fatal) << "[TrackTuner] negative nPhiBins!" << nPhiBins; + LOG(info) << "[TrackTuner] nPhiBins = " << nPhiBins; /// declare that the configuration is done via an input string isConfigFromString = true; @@ -417,6 +428,12 @@ struct TrackTuner : o2::framework::ConfigurableGroup { qOverPtData = cfgQOverPtData; outputString += ", qOverPtData=" + std::to_string(qOverPtData); LOG(info) << "[TrackTuner] qOverPtData = " << qOverPtData; + // Configure nPhiBins + nPhiBins = cfgNPhiBins; + outputString += ", nPhiBins=" + std::to_string(nPhiBins); + if (nPhiBins < 0) + LOG(fatal) << "[TrackTuner] negative nPhiBins!" << nPhiBins; + LOG(info) << "[TrackTuner] nPhiBins = " << nPhiBins; /// declare that the configuration is done via the Configurables isConfigFromConfigurables = true; @@ -476,38 +493,72 @@ struct TrackTuner : o2::framework::ConfigurableGroup { LOG(fatal) << "TDirectory " << td << " not found in input file" << inputFile->GetName() << ". Fix it!"; } - std::string grDcaXYResNameMC = "resCurrentDcaXY"; - std::string grDcaXYMeanNameMC = "meanCurrentDcaXY"; - std::string grDcaXYPullNameMC = "pullsCurrentDcaXY"; - std::string grDcaXYResNameData = "resUpgrDcaXY"; - std::string grDcaXYMeanNameData = "meanUpgrDcaXY"; - std::string grDcaXYPullNameData = "pullsUpgrDcaXY"; - - grDcaXYResVsPtPionMC.reset(dynamic_cast(td->Get(grDcaXYResNameMC.c_str()))); - grDcaXYResVsPtPionData.reset(dynamic_cast(td->Get(grDcaXYResNameData.c_str()))); - grDcaXYMeanVsPtPionMC.reset(dynamic_cast(td->Get(grDcaXYMeanNameMC.c_str()))); - grDcaXYMeanVsPtPionData.reset(dynamic_cast(td->Get(grDcaXYMeanNameData.c_str()))); - grDcaXYPullVsPtPionMC.reset(dynamic_cast(td->Get(grDcaXYPullNameMC.c_str()))); - grDcaXYPullVsPtPionData.reset(dynamic_cast(td->Get(grDcaXYPullNameData.c_str()))); - if (!grDcaXYResVsPtPionMC.get() || !grDcaXYResVsPtPionData.get() || !grDcaXYMeanVsPtPionMC.get() || !grDcaXYMeanVsPtPionData.get() || !grDcaXYPullVsPtPionMC.get() || !grDcaXYPullVsPtPionData.get()) { - LOG(fatal) << "Something wrong with the names of the correction graphs for dcaXY. Fix it!"; + int inputNphiBins = nPhiBins; + if (inputNphiBins == 0) + nPhiBins = 1; // old phi_independent settings + + // reserve memory and initialize vector for needed number of graphs + grDcaXYResVsPtPionMC.resize(nPhiBins); + grDcaXYResVsPtPionData.resize(nPhiBins); + + grDcaZResVsPtPionMC.resize(nPhiBins); + grDcaZResVsPtPionData.resize(nPhiBins); + + grDcaXYMeanVsPtPionMC.resize(nPhiBins); + grDcaXYMeanVsPtPionData.resize(nPhiBins); + + grDcaZMeanVsPtPionMC.resize(nPhiBins); + grDcaZMeanVsPtPionData.resize(nPhiBins); + + grDcaXYPullVsPtPionMC.resize(nPhiBins); + grDcaXYPullVsPtPionData.resize(nPhiBins); + + grDcaZPullVsPtPionMC.resize(nPhiBins); + grDcaZPullVsPtPionData.resize(nPhiBins); + + /// Lambda expression to get the TGraphErrors from file + auto loadGraph = [&](int phiBin, const std::string& strBaseName) -> TGraphErrors* { + std::string strGraphName = inputNphiBins != 0 ? fmt::format("{}_{}", strBaseName, phiBin) : strBaseName; + TObject* obj = td->Get(strGraphName.c_str()); + if (!obj) { + LOG(fatal) << "[TrackTuner] TGraphErrors not found in the Input Root file: " << strGraphName; + td->ls(); + return nullptr; + } + return dynamic_cast(obj); + }; + + if (inputNphiBins != 0) { + LOG(info) << "[TrackTuner] Loading phi-dependent XY TGraphErrors"; } + for (int iPhiBin = 0; iPhiBin < nPhiBins; ++iPhiBin) { - std::string grDcaZResNameMC = "resCurrentDcaZ"; - std::string grDcaZMeanNameMC = "meanCurrentDcaZ"; - std::string grDcaZPullNameMC = "pullsCurrentDcaZ"; - std::string grDcaZResNameData = "resUpgrDcaZ"; - std::string grDcaZMeanNameData = "meanUpgrDcaZ"; - std::string grDcaZPullNameData = "pullsUpgrDcaZ"; - - grDcaZResVsPtPionMC.reset(dynamic_cast(td->Get(grDcaZResNameMC.c_str()))); - grDcaZResVsPtPionData.reset(dynamic_cast(td->Get(grDcaZResNameData.c_str()))); - grDcaZMeanVsPtPionMC.reset(dynamic_cast(td->Get(grDcaZMeanNameMC.c_str()))); - grDcaZMeanVsPtPionData.reset(dynamic_cast(td->Get(grDcaZMeanNameData.c_str()))); - grDcaZPullVsPtPionMC.reset(dynamic_cast(td->Get(grDcaZPullNameMC.c_str()))); - grDcaZPullVsPtPionData.reset(dynamic_cast(td->Get(grDcaZPullNameData.c_str()))); - if (!grDcaZResVsPtPionMC.get() || !grDcaZResVsPtPionData.get() || !grDcaZMeanVsPtPionMC.get() || !grDcaZMeanVsPtPionData.get() || !grDcaZPullVsPtPionMC.get() || !grDcaZPullVsPtPionData.get()) { - LOG(fatal) << "Something wrong with the names of the correction graphs for dcaZ. Fix it!"; + grDcaXYResVsPtPionMC[iPhiBin].reset(loadGraph(iPhiBin, "resCurrentDcaXY")); + grDcaXYResVsPtPionData[iPhiBin].reset(loadGraph(iPhiBin, "resUpgrDcaXY")); + grDcaXYMeanVsPtPionMC[iPhiBin].reset(loadGraph(iPhiBin, "meanCurrentDcaXY")); + grDcaXYMeanVsPtPionData[iPhiBin].reset(loadGraph(iPhiBin, "meanUpgrDcaXY")); + grDcaXYPullVsPtPionMC[iPhiBin].reset(loadGraph(iPhiBin, "pullsCurrentDcaXY")); + grDcaXYPullVsPtPionData[iPhiBin].reset(loadGraph(iPhiBin, "pullsUpgrDcaXY")); + + if (!grDcaXYResVsPtPionMC[iPhiBin].get() || !grDcaXYResVsPtPionData[iPhiBin].get() || !grDcaXYMeanVsPtPionMC[iPhiBin].get() || !grDcaXYMeanVsPtPionData[iPhiBin].get() || !grDcaXYPullVsPtPionMC[iPhiBin].get() || !grDcaXYPullVsPtPionData[iPhiBin].get()) { + LOG(fatal) << "[TrackTuner] Something wrong with the names of the correction graphs for dcaXY. Fix it! Problematic phi bin is" << iPhiBin; + } + } + + if (inputNphiBins != 0) { + LOG(info) << "[TrackTuner] Loading phi-dependent Z TGraphErrors"; + } + for (int iPhiBin = 0; iPhiBin < nPhiBins; ++iPhiBin) { + grDcaZResVsPtPionMC[iPhiBin].reset(loadGraph(iPhiBin, "resCurrentDcaZ")); + grDcaZMeanVsPtPionMC[iPhiBin].reset(loadGraph(iPhiBin, "meanCurrentDcaZ")); + grDcaZPullVsPtPionMC[iPhiBin].reset(loadGraph(iPhiBin, "pullsCurrentDcaZ")); + grDcaZResVsPtPionData[iPhiBin].reset(loadGraph(iPhiBin, "resUpgrDcaZ")); + grDcaZMeanVsPtPionData[iPhiBin].reset(loadGraph(iPhiBin, "meanUpgrDcaZ")); + grDcaZPullVsPtPionData[iPhiBin].reset(loadGraph(iPhiBin, "pullsUpgrDcaZ")); + + if (!grDcaZResVsPtPionMC[iPhiBin].get() || !grDcaZResVsPtPionData[iPhiBin].get() || !grDcaZMeanVsPtPionMC[iPhiBin].get() || !grDcaZMeanVsPtPionData[iPhiBin].get() || !grDcaZPullVsPtPionMC[iPhiBin].get() || !grDcaZPullVsPtPionData[iPhiBin].get()) { + LOG(fatal) << "[TrackTuner] Something wrong with the names of the correction graphs for dcaZ. Fix it! Problematic phi bin is" << iPhiBin; + } } std::string grOneOverPtPionNameMC = "sigmaVsPtMc"; @@ -538,11 +589,17 @@ struct TrackTuner : o2::framework::ConfigurableGroup { double dcaZPullMC = 1.0; double dcaZPullData = 1.0; - dcaXYResMC = evalGraph(ptMC, grDcaXYResVsPtPionMC.get()); - dcaXYResData = evalGraph(ptMC, grDcaXYResVsPtPionData.get()); + // get phibin + double phiMC = mcparticle.phi(); + if (phiMC < 0.) + phiMC += o2::constants::math::TwoPI; // 2 * std::numbers::pi;// + int phiBin = phiMC / (o2::constants::math::TwoPI + 0.0000001) * nPhiBins; // 0.0000001 just a numerical protection - dcaZResMC = evalGraph(ptMC, grDcaZResVsPtPionMC.get()); - dcaZResData = evalGraph(ptMC, grDcaZResVsPtPionData.get()); + dcaXYResMC = evalGraph(ptMC, grDcaXYResVsPtPionMC[phiBin].get()); + dcaXYResData = evalGraph(ptMC, grDcaXYResVsPtPionData[phiBin].get()); + + dcaZResMC = evalGraph(ptMC, grDcaZResVsPtPionMC[phiBin].get()); + dcaZResData = evalGraph(ptMC, grDcaZResVsPtPionData[phiBin].get()); // For Q/Pt corrections, files on CCDB will be used if both qOverPtMC and qOverPtData are null if (updateCurvature || updateCurvatureIU) { @@ -560,14 +617,15 @@ struct TrackTuner : o2::framework::ConfigurableGroup { } // updateCurvature, updateCurvatureIU block ends here if (updateTrackDCAs) { - dcaXYMeanMC = evalGraph(ptMC, grDcaXYMeanVsPtPionMC.get()); - dcaXYMeanData = evalGraph(ptMC, grDcaXYMeanVsPtPionData.get()); - dcaXYPullMC = evalGraph(ptMC, grDcaXYPullVsPtPionMC.get()); - dcaXYPullData = evalGraph(ptMC, grDcaXYPullVsPtPionData.get()); + dcaXYMeanMC = evalGraph(ptMC, grDcaXYMeanVsPtPionMC[phiBin].get()); + dcaXYMeanData = evalGraph(ptMC, grDcaXYMeanVsPtPionData[phiBin].get()); + + dcaXYPullMC = evalGraph(ptMC, grDcaXYPullVsPtPionMC[phiBin].get()); + dcaXYPullData = evalGraph(ptMC, grDcaXYPullVsPtPionData[phiBin].get()); - dcaZPullMC = evalGraph(ptMC, grDcaZPullVsPtPionMC.get()); - dcaZPullData = evalGraph(ptMC, grDcaZPullVsPtPionData.get()); + dcaZPullMC = evalGraph(ptMC, grDcaZPullVsPtPionMC[phiBin].get()); + dcaZPullData = evalGraph(ptMC, grDcaZPullVsPtPionData[phiBin].get()); } // Unit conversion, is it required ?? dcaXYResMC *= 1.e-4; @@ -676,12 +734,17 @@ struct TrackTuner : o2::framework::ConfigurableGroup { if (updateTrackDCAs) { // propagate to DCA with respect to the Production point o2::base::Propagator::Instance()->propagateToDCABxByBz(vtxMC, trackParCov, 2.f, matCorr, dcaInfoCov); + if (debugInfo) { + LOG(info) << "phi MC" << mcparticle.phi(); + LOG(info) << "alpha track" << trackParCov.getAlpha(); + } // double d0zo =param [1]; double trackParDcaZRec = trackParCov.getZ(); // double d0rpo =param [0]; double trackParDcaXYRec = trackParCov.getY(); float mcVxRotated = mcparticle.vx() * std::cos(trackParCov.getAlpha()) + mcparticle.vy() * std::sin(trackParCov.getAlpha()); // invert float mcVyRotated = mcparticle.vy() * std::cos(trackParCov.getAlpha()) - mcparticle.vx() * std::sin(trackParCov.getAlpha()); + if (debugInfo) { // LOG(info) << "mcVy " << mcparticle.vy() << std::endl; LOG(info) << "mcVxRotated " << mcVxRotated; @@ -722,7 +785,7 @@ struct TrackTuner : o2::framework::ConfigurableGroup { double deltaDcaXYmean = dcaXYMeanData - dcaXYMeanMC; // double d0rpn =d0rpmc+dd0rpn-dd0mrpn; - double trackParDcaXYTuned = trackParDcaXYMC + deltaDcaXYTuned - deltaDcaXYmean; + double trackParDcaXYTuned = trackParDcaXYMC + deltaDcaXYTuned + deltaDcaXYmean; if (debugInfo) { LOG(info) << dcaZResMC << ", " << dcaZResData << ", diff(DcaZ - DcaZMC): " << deltaDcaZ << ", diff upgraded: " << deltaDcaZTuned << ", DcaZ Data : " << trackParDcaZTuned; @@ -954,7 +1017,7 @@ struct TrackTuner : o2::framework::ConfigurableGroup { { if (!graph) { - printf("\tevalGraph fails !\n"); + LOG(fatal) << "\t evalGraph fails !\n"; return 0.; } int nPoints = graph->GetN(); diff --git a/Common/Tools/aodDataModelGraph.cxx b/Common/Tools/aodDataModelGraph.cxx index 3b1afaba2ca..da854a700f5 100644 --- a/Common/Tools/aodDataModelGraph.cxx +++ b/Common/Tools/aodDataModelGraph.cxx @@ -8,10 +8,15 @@ // 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 +#include +#include +#include #include "Framework/AnalysisDataModel.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -87,8 +92,13 @@ template Style getStyleFor() { auto label = MetadataTrait::metadata::tableLabel(); - auto entry = std::find_if(tableStyles.begin(), tableStyles.end(), [&](auto&& x) { if (std::string(label).find(x.first) != std::string::npos) { return true; -}return false; }); + auto entry = std::find_if(tableStyles.begin(), tableStyles.end(), + [&](auto&& x) { + if (std::string(label).find(x.first) != std::string::npos) { + return true; + } + return false; + }); if (entry != tableStyles.end()) { auto value = *entry; return styles[value.second]; diff --git a/Common/Tools/timestampModule.h b/Common/Tools/timestampModule.h new file mode 100644 index 00000000000..80016dbfde3 --- /dev/null +++ b/Common/Tools/timestampModule.h @@ -0,0 +1,151 @@ +// 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. + +#ifndef COMMON_TOOLS_TIMESTAMPMODULEH_ +#define COMMON_TOOLS_TIMESTAMPMODULEH_ + +#include "Framework/AnalysisDataModel.h" + +#include +#include +#include + +namespace o2 +{ +namespace common +{ +namespace timestamp +{ + +// timestamp configurables +struct timestampConfigurables : o2::framework::ConfigurableGroup { + std::string prefix = "timestamp"; + o2::framework::Configurable verbose{"verbose", false, "verbose mode"}; + o2::framework::Configurable fatalOnInvalidTimestamp{"fatalOnInvalidTimestamp", false, "Generate fatal error for invalid timestamps"}; + o2::framework::Configurable rct_path{"rct-path", "RCT/Info/RunInformation", "path to the ccdb RCT objects for the SOR timestamps"}; + o2::framework::Configurable orbit_reset_path{"orbit-reset-path", "CTP/Calib/OrbitReset", "path to the ccdb orbit-reset objects"}; + o2::framework::Configurable isRun2MC{"isRun2MC", -1, "Running mode: enable only for Run 2 MC. Timestamps are set to SOR timestamp. Default: -1 (autoset from metadata) 0 (Standard) 1 (Run 2 MC)"}; // o2-linter: disable=name/configurable (temporary fix) +}; + +//__________________________________________ +// time stamp module +// +// class to acquire time stamps to be used in +// modular (plugin) fashion + +class TimestampModule +{ + public: + TimestampModule() + { + // constructor: initialize at defaults + lastRunNumber = 0; + orbitResetTimestamp = 0; + }; + + o2::common::timestamp::timestampConfigurables timestampOpts; + + // objects necessary during processing + std::map mapRunToOrbitReset; /// Cache of orbit reset timestamps + std::map> mapRunToRunDuration; /// Cache of run duration timestamps + int lastRunNumber; /// Last run number processed + int64_t orbitResetTimestamp; /// Orbit-reset timestamp in us + std::pair runDuration; /// Pair of SOR and EOR timestamps + + template + void init(TTimestampOpts const& external_timestampOpts, TMetadatahelper const& metadataInfo) + { + timestampOpts = external_timestampOpts; + + if (timestampOpts.isRun2MC.value == -1) { + if ((!metadataInfo.isRun3()) && metadataInfo.isMC()) { + timestampOpts.isRun2MC.value = 1; + LOG(info) << "Autosetting the Run2 MC mode based on metadata"; + } else { + timestampOpts.isRun2MC.value = 0; + } + } + } + + template + void process(TBCs const& bcs, Tccdb const& ccdb, TTimestampBuffer& timestampbuffer, TCursor& timestampTable) + { + timestampbuffer.clear(); + for (auto const& bc : bcs) { + int runNumber = bc.runNumber(); + // We need to set the orbit-reset timestamp for the run number. + // This is done with caching if the run number was already processed before. + // If not the orbit-reset timestamp for the run number is queried from CCDB and added to the cache + if (runNumber == lastRunNumber) { // The run number coincides to the last run processed + LOGF(debug, "Using orbit-reset timestamp from last call"); + } else if (mapRunToOrbitReset.count(runNumber)) { // The run number was already requested before: getting it from cache! + LOGF(debug, "Getting orbit-reset timestamp from cache"); + orbitResetTimestamp = mapRunToOrbitReset[runNumber]; + runDuration = mapRunToRunDuration[runNumber]; + } else { // The run was not requested before: need to acccess CCDB! + LOGF(debug, "Getting start-of-run and end-of-run timestamps from CCDB"); + runDuration = ccdb->getRunDuration(runNumber, true); /// fatalise if timestamps are not found + int64_t sorTimestamp = runDuration.first; // timestamp of the SOR/SOX/STF in ms + int64_t eorTimestamp = runDuration.second; // timestamp of the EOR/EOX/ETF in ms + + // clear cache to prevent interference with orbit reset queries from other code + // FIXME this should not have been a problem, to be investigated + ccdb->clearCache(timestampOpts.orbit_reset_path.value.data()); + + const bool isUnanchoredRun3MC = runNumber >= 300000 && runNumber < 500000; + if (timestampOpts.isRun2MC.value == 1 || isUnanchoredRun3MC) { + // isRun2MC: bc/orbit distributions are not simulated in Run2 MC. All bcs are set to 0. + // isUnanchoredRun3MC: assuming orbit-reset is done in the beginning of each run + // Setting orbit-reset timestamp to start-of-run timestamp + orbitResetTimestamp = sorTimestamp * 1000; // from ms to us + } else if (runNumber < 300000) { // Run 2 + LOGF(debug, "Getting orbit-reset timestamp using start-of-run timestamp from CCDB"); + auto ctp = ccdb->template getSpecific>(timestampOpts.orbit_reset_path.value.data(), sorTimestamp); + orbitResetTimestamp = (*ctp)[0]; + } else { + // sometimes orbit is reset after SOR. Using EOR timestamps for orbitReset query is more reliable + LOGF(debug, "Getting orbit-reset timestamp using end-of-run timestamp from CCDB"); + auto ctp = ccdb->template getSpecific>(timestampOpts.orbit_reset_path.value.data(), eorTimestamp / 2 + sorTimestamp / 2); + orbitResetTimestamp = (*ctp)[0]; + } + + // Adding the timestamp to the cache map + std::pair::iterator, bool> check; + check = mapRunToOrbitReset.insert(std::pair(runNumber, orbitResetTimestamp)); + if (!check.second) { + LOGF(fatal, "Run number %i already existed with a orbit-reset timestamp of %llu", runNumber, check.first->second); + } + mapRunToRunDuration[runNumber] = runDuration; + LOGF(info, "Add new run number %i with orbit-reset timestamp %llu, SOR: %llu, EOR: %llu to cache", runNumber, orbitResetTimestamp, runDuration.first, runDuration.second); + } + + if (timestampOpts.verbose) { + LOGF(info, "Orbit-reset timestamp for run number %i found: %llu us", runNumber, orbitResetTimestamp); + } + int64_t timestamp{(orbitResetTimestamp + int64_t(bc.globalBC() * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000}; // us -> ms + if (timestamp < runDuration.first || timestamp > runDuration.second) { + if (timestampOpts.fatalOnInvalidTimestamp.value) { + LOGF(fatal, "Timestamp %llu us is out of run duration [%llu, %llu] ms", timestamp, runDuration.first, runDuration.second); + } else { + LOGF(debug, "Timestamp %llu us is out of run duration [%llu, %llu] ms", timestamp, runDuration.first, runDuration.second); + } + } + timestampbuffer.push_back(timestamp); // for buffering purposes + timestampTable(timestamp); + } + } +}; + +} // namespace timestamp +} // namespace common +} // namespace o2 + +#endif // COMMON_TOOLS_TIMESTAMPMODULEH_ diff --git a/Common/Tools/trackSelectionRequest.cxx b/Common/Tools/trackSelectionRequest.cxx index 088eafab508..ed82f1ff7bf 100644 --- a/Common/Tools/trackSelectionRequest.cxx +++ b/Common/Tools/trackSelectionRequest.cxx @@ -108,6 +108,14 @@ int trackSelectionRequest::getMinTPCCrossedRowsOverFindable() const { return minTPCcrossedrowsoverfindable; } +void trackSelectionRequest::setMaxTPCFractionSharedCls(float maxTPCFractionSharedCls_) +{ + maxTPCFractionSharedCls = maxTPCFractionSharedCls_; +} +int trackSelectionRequest::getMaxTPCFractionSharedCls() const +{ + return maxTPCFractionSharedCls; +} void trackSelectionRequest::setRequireITS(bool requireITS_) { requireITS = requireITS_; @@ -159,6 +167,8 @@ void trackSelectionRequest::CombineWithLogicalOR(trackSelectionRequest const& lT minTPCcrossedrows = lTraSelRe.getMinTPCCrossedRows(); if (lTraSelRe.getMinTPCCrossedRowsOverFindable() < minTPCcrossedrowsoverfindable) minTPCcrossedrowsoverfindable = lTraSelRe.getMinTPCCrossedRowsOverFindable(); + if (lTraSelRe.getMaxTPCFractionSharedCls() > maxTPCFractionSharedCls) + maxTPCFractionSharedCls = lTraSelRe.getMaxTPCFractionSharedCls(); if (lTraSelRe.getRequireITS() == false) requireITS = false; @@ -205,7 +215,9 @@ void trackSelectionRequest::PrintSelections() const LOGF(info, "Minimum TPC clusters ...................: %i", minTPCclusters); LOGF(info, "Minimum TPC crossed rows ...............: %i", minTPCcrossedrows); LOGF(info, "Minimum TPC crossed rows over findable .: %.3f", minTPCcrossedrowsoverfindable); + LOGF(info, "Max Fraction of TPC Shared Clusters ....: %.3f", maxTPCFractionSharedCls); + LOGF(info, "Require ITS ............................: %i", requireITS); LOGF(info, "Minimum ITS clusters ...................: %i", minITSclusters); LOGF(info, "Max ITS chi2/clu ......................: %.3f", maxITSChi2percluster); -} \ No newline at end of file +} diff --git a/Common/Tools/trackSelectionRequest.h b/Common/Tools/trackSelectionRequest.h index 00931491acf..123392611f0 100644 --- a/Common/Tools/trackSelectionRequest.h +++ b/Common/Tools/trackSelectionRequest.h @@ -60,6 +60,8 @@ class trackSelectionRequest int getMinTPCCrossedRows() const; void setMinTPCCrossedRowsOverFindable(float minTPCCrossedRowsOverFindable_); int getMinTPCCrossedRowsOverFindable() const; + void setMaxTPCFractionSharedCls(float maxTPCFractionSharedCls_); + int getMaxTPCFractionSharedCls() const; void setRequireITS(bool requireITS_); bool getRequireITS() const; @@ -97,6 +99,8 @@ class trackSelectionRequest return false; if (lTrack.tpcCrossedRowsOverFindableCls() < minTPCcrossedrowsoverfindable) return false; + if (lTrack.tpcFractionSharedCls() > maxTPCFractionSharedCls) + return false; if (lTrack.hasITS() == false && requireITS) return false; if (lTrack.itsNCls() < minITSclusters) @@ -117,6 +121,8 @@ class trackSelectionRequest return false; if (lTrack.tpcCrossedRowsOverFindableCls() < minTPCcrossedrowsoverfindable) return false; + if (lTrack.tpcFractionSharedCls() > maxTPCFractionSharedCls) + return false; if (lTrack.hasITS() == false && requireITS) return false; if (lTrack.itsNCls() < minITSclusters) @@ -146,6 +152,7 @@ class trackSelectionRequest int minTPCclusters; int minTPCcrossedrows; float minTPCcrossedrowsoverfindable; + float maxTPCFractionSharedCls; // ITS parameters (TracksExtra) bool requireITS; // in Run 3, equiv to hasITS int minITSclusters; diff --git a/DPG/Tasks/AOTEvent/CMakeLists.txt b/DPG/Tasks/AOTEvent/CMakeLists.txt index 3c537de6b47..59e049e6356 100644 --- a/DPG/Tasks/AOTEvent/CMakeLists.txt +++ b/DPG/Tasks/AOTEvent/CMakeLists.txt @@ -11,7 +11,7 @@ o2physics_add_dpl_workflow(event-selection-qa SOURCES eventSelectionQa.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase O2::DataFormatsITSMFT COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(lumi-qa @@ -19,8 +19,8 @@ o2physics_add_dpl_workflow(lumi-qa PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(mshape-qa - SOURCES mshapeQa.cxx +o2physics_add_dpl_workflow(time-dependent-qa + SOURCES timeDependentQa.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase O2::TPCCalibration COMPONENT_NAME Analysis) @@ -43,3 +43,13 @@ o2physics_add_dpl_workflow(rof-occupancy-qa SOURCES rofOccupancyQa.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(light-ions-evsel-qa + SOURCES lightIonsEvSelQa.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(occupancy-vs-dedx-qa + SOURCES dEdxVsOccupancyWithTrackQAinfo.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase + COMPONENT_NAME Analysis) diff --git a/DPG/Tasks/AOTEvent/dEdxVsOccupancyWithTrackQAinfo.cxx b/DPG/Tasks/AOTEvent/dEdxVsOccupancyWithTrackQAinfo.cxx new file mode 100644 index 00000000000..c87fd48bc99 --- /dev/null +++ b/DPG/Tasks/AOTEvent/dEdxVsOccupancyWithTrackQAinfo.cxx @@ -0,0 +1,471 @@ +// 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. + +/// \file dEdxVsOccupancyWithTrackQAinfo.cxx +/// \brief dE/dx vs occupancy QA task with more detailed checks +/// +/// \author Igor Altsybeev + +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/ctpRateFetcher.h" +#include "CCDB/BasicCCDBManager.h" +#include "Framework/HistogramRegistry.h" +#include "CommonDataFormat/BunchFilling.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPECSObject.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "DataFormatsParameters/AggregatedRunInfo.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TH3.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod::evsel; + +using BCsRun3 = soa::Join; +using ColEvSels = soa::Join; +// using ColEvSels = soa::Join; +using FullTracksIU = soa::Join; + +struct dEdxVsOccupancyWithTrackQAinfoTask { + // configurables for study of occupancy in time windows + // Configurable confAddBasicQAhistos{"AddBasicQAhistos", true, "0 - add basic histograms, 1 - skip"}; // o2-linter: disable=name/configurable (temporary fix) + // Configurable confTimeIntervalForOccupancyCalculation{"TimeIntervalForOccupancyCalculation", 100, "Time interval for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable (temporary fix) + // Configurable confFlagCentralityIsAvailable{"FlagCentralityIsAvailable", true, "Fill centrality-related historams"}; // o2-linter: disable=name/configurable (temporary fix) + // Configurable confFlagManyHeavyHistos{"FlagManyHeavyHistos", true, "Fill more TH2, TH3, THn historams"}; // o2-linter: disable=name/configurable (temporary fix) + + // event and track cuts for given event + Configurable confCutVertZMinThisEvent{"VzMinThisEvent", -10, "vZ cut for a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutVertZMaxThisEvent{"VzMaxThisEvent", 10, "vZ cut for a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutPtMinThisEvent{"PtMinThisEvent", 0.2, "pt cut for particles in a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutPtMaxThisEvent{"PtMaxThisEvent", 100., "pt cut for particles in a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutEtaMinTracksThisEvent{"EtaMinTracksThisEvent", -0.8, "eta cut for particles in a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutEtaMaxTracksThisEvent{"EtaMaxTracksThisEvent", 0.8, "eta cut for particles in a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutMinTPCcls{"MinNumTPCcls", 70, "min number of TPC clusters for a current event"}; // o2-linter: disable=name/configurable (temporary fix) + + uint64_t minGlobalBC = 0; + Service ccdb; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + bool* applySelection = NULL; + int nBCsPerOrbit = 3564; + int lastRunNumber = -1; + int nOrbits; + double minOrbit; + int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 by default for unanchored MC + int64_t nBCsPerTF = 128 * nBCsPerOrbit; // duration of TF in bcs, should be 128*3564 or 32*3564, setting 128 orbits by default sfor unanchored MC + ctpRateFetcher mRateFetcher; + + // save time "slices" for several collisions for QA + bool flagFillQAtimeOccupHist = false; + int nCollisionsForTimeBinQA = 40; + int counterQAtimeOccupHistos = 0; + + void init(InitContext&) + { + // ccdb->setURL("http://ccdb-test.cern.ch:8080"); + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + // dE/dx + AxisSpec axisDeDx{800, 0.0, 800.0, "dE/dx (a. u.)"}; + histos.add("dEdx_vs_Momentum_CORRECTED", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("dEdx_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + // histos.add("dEdx_vs_Momentum_occupBelow200", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + // histos.add("dEdx_vs_Momentum_occupBelow200_kNoCollStd", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + // histos.add("dEdx_vs_Momentum_occupAbove4000", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + // histos.add("dEdx_vs_Momentum_NegativeFractionNclsPID", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + // histos.add("dEdx_vs_Momentum_HighFractionNclsNonPID", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + AxisSpec axisBinsOccupStudydEdx{{0., 500, 1000, 2000, 4000, 6000, 8000, 15000}, "p_{T}"}; + // histos.add("dEdx_vs_Momentum_vs_occup", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + // if (confFlagManyHeavyHistos) { + // histos.add("dEdx_vs_Momentum_vs_occup_eta_02_04", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + // histos.add("dEdx_vs_Momentum_vs_occup_eta_04_02", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + // } + histos.add("dEdx_3OROC_tot_vs_Momentum_vs_occup_eta_02_04", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + histos.add("dEdx_3OROC_tot_vs_Momentum_vs_occup_eta_04_02", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + histos.add("dEdx_3OROC_max_vs_Momentum_vs_occup_eta_02_04", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + histos.add("dEdx_3OROC_max_vs_Momentum_vs_occup_eta_04_02", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + + // track QA info + histos.add("tpcdEdxMax0R_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("tpcdEdxMax1R_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("tpcdEdxMax2R_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("tpcdEdxMax3R_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + + histos.add("tpcdEdxTot0R_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("tpcdEdxTot1R_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("tpcdEdxTot2R_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("tpcdEdxTot3R_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + + histos.add("tpcdEdxTot3R_vs_dEdxFromTracks", "dE/dx", kTH2F, {axisDeDx, axisDeDx}); + histos.add("tpcdEdxTotSUM_vs_dEdxFromTracks", "dE/dx", kTH2F, {axisDeDx, axisDeDx}); + histos.add("tpcdEdxMaxSUM_vs_dEdxFromTracks", "dE/dx", kTH2F, {axisDeDx, axisDeDx}); + + histos.add("tpcdEdxAverageMax_vs_dEdxFromTracks", "dE/dx", kTH2F, {axisDeDx, axisDeDx}); + histos.add("tpcdEdxAverageTot_vs_dEdxFromTracks", "dE/dx", kTH2F, {axisDeDx, axisDeDx}); + + histos.add("tpcdEdxAverageMax_3OROC_vs_dEdxFromTracks", "dE/dx", kTH2F, {axisDeDx, axisDeDx}); + histos.add("tpcdEdxAverageTot_3OROC_vs_dEdxFromTracks", "dE/dx", kTH2F, {axisDeDx, axisDeDx}); + + histos.add("tpcdEdxCORRECTED_vs_dEdxFromTracks", "dE/dx", kTH2F, {axisDeDx, axisDeDx}); + + const AxisSpec axisDcaZ{1000, -5., 5., "DCA_{z}, cm"}; + histos.add("dcaXY_vs_dcaXYqa", "dE/dx", kTH2F, {axisDcaZ, {601, -300.5, 300.5, "DCA_{z}, cm"}}); + histos.add("dcaZ_vs_dcaZqa", "dE/dx", kTH2F, {axisDcaZ, {601, -300.5, 300.5, "DCA_{z}, cm"}}); + + AxisSpec axisOccupancyForDeDxStudies{60, 0, 15000, "occupancy"}; + histos.add("dEdx_vs_centr_vs_occup_narrow_p_win", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + // histos.add("dEdx_vs_centr_vs_occup_narrow_p_win_pos", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + // histos.add("dEdx_vs_centr_vs_occup_narrow_p_win_neg", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + // histos.add("dEdx_vs_centr_vs_occup_narrow_p_win_pos_FractionPIDclsInRange", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + // histos.add("dEdx_vs_centr_vs_occup_narrow_p_win_neg_FractionPIDclsInRange", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + + histos.add("dEdx_3OROC_max_vs_centr_vs_occup_narrow_p_win", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + histos.add("dEdx_3OROC_tot_vs_centr_vs_occup_narrow_p_win", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + + histos.add("dEdx_vs_centr_vs_occup_narrow_p_win_CORRECTED", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + + // AxisSpec axisFractionNclsFindableMinusPID{110, -1.1, 1.1, "TPC nClsFindableMinusPID / nClsFindable"}; + // histos.add("fraction_tpcNClsFindableMinusPID_vs_occup", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + // histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_peripheralByV0A", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + // histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_centralByV0A", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + // histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_eta02", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + // histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_pos", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + // histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_neg", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + // histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_lowPt", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + // histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_highPt", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + + // QA dEdx correction coeff + histos.add("dEdx_CORRECTION_COEFF", "coeff", kTH1F, {{1000, -2.0, 2.0, "correction coeff"}}); + } + + Preslice perCollision = aod::track::collisionId; + + float fReal_fTPCSignalN(float mbb0R1, float a1pt, float atgl, float atglmbb0R1, float a1ptmbb0R1, float side, float a1pt2, float fTrackOccN, float fOccTPCN, float fTrackOccMeanN) + { + return ((0.017012 * mbb0R1) + (-0.0018469 * a1pt) + (-0.0052177 * atgl) + (-0.0035655 * atglmbb0R1) + (0.0017846 * a1ptmbb0R1) + (0.0019127 * side) + (-0.00012964 * a1pt2) + (0.013066)) * fTrackOccN + ((0.0055592 * mbb0R1) + (-0.0010618 * a1pt) + (-0.0016134 * atgl) + (-0.0059098 * atglmbb0R1) + (0.0013335 * a1ptmbb0R1) + (0.00052133 * side) + (3.1119e-05 * a1pt2) + (0.0049428)) * fOccTPCN + ((0.00077317 * mbb0R1) + (-0.0013827 * a1pt) + (0.003249 * atgl) + (-0.00063689 * atglmbb0R1) + (0.0016218 * a1ptmbb0R1) + (-0.00045215 * side) + (-1.5815e-05 * a1pt2) + (-0.004882)) * fTrackOccMeanN + ((-0.015053 * mbb0R1) + (0.0018912 * a1pt) + (-0.012305 * atgl) + (0.081387 * atglmbb0R1) + (0.003205 * a1ptmbb0R1) + (-0.0087404 * side) + (-0.0028608 * a1pt2) + (0.99091)); + }; + void processRun3( + ColEvSels const& cols, + FullTracksIU const& tracks, + BCsRun3 const& bcs, + aod::TracksQA_002 const& tracksQA, + aod::FT0s const&) + { + int runNumber = bcs.iteratorAt(0).runNumber(); + if (runNumber != lastRunNumber) { + lastRunNumber = runNumber; // do it only once + + if (runNumber >= 500000) { + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), runNumber); + // first bc of the first orbit + bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches; + // duration of TF in bcs + nBCsPerTF = runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches; + + LOGP(info, "bcSOR = {}, nBCsPerTF = {}", bcSOR, nBCsPerTF); + } + } + + // track QA table + std::vector labelTrack2TrackQA; + labelTrack2TrackQA.clear(); + labelTrack2TrackQA.resize(tracks.size(), -1); + for (const auto& trackQA : tracksQA) { + int64_t trackId = trackQA.trackId(); + int64_t trackQAIndex = trackQA.globalIndex(); + labelTrack2TrackQA[trackId] = trackQAIndex; + } + + for (const auto& col : cols) { + if (!col.sel8()) + continue; + + // check hadronic rate + auto bc = col.foundBC_as(); + int64_t ts = bc.timestamp(); + double hadronicRate = mRateFetcher.fetch(ccdb.service, ts, runNumber, "ZNC hadronic") * 1.e-3; // kHz + const int multTPC = col.multTPC(); + + int occupancy = col.trackOccupancyInTimeRange(); + + auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); + + // pre-calc nPV + int nPV = 0; + for (const auto& track : tracksGrouped) { + if (!track.isPVContributor()) + continue; + if (track.pt() < confCutPtMinThisEvent || track.pt() > confCutPtMaxThisEvent) + continue; + if (track.eta() < confCutEtaMinTracksThisEvent || track.eta() > confCutEtaMaxTracksThisEvent) + continue; + if (track.itsNCls() < 5) + continue; + nPV++; + } + + // main track loop + for (const auto& track : tracksGrouped) { + if (!track.isPVContributor()) + continue; + if (track.pt() < confCutPtMinThisEvent || track.pt() > confCutPtMaxThisEvent) + continue; + if (track.eta() < confCutEtaMinTracksThisEvent || track.eta() > confCutEtaMaxTracksThisEvent) + continue; + if (track.itsNCls() < 5) + continue; + if (!track.isGlobalTrack()) + continue; + if (track.tpcNClsFound() < confCutMinTPCcls) + continue; + + float signedP = track.sign() * track.tpcInnerParam(); + + aod::TracksQA_002::iterator trackQA; + // bool existPosTrkQA; + if (labelTrack2TrackQA[track.globalIndex()] != -1) { + trackQA = tracksQA.iteratorAt(labelTrack2TrackQA[track.globalIndex()]); + // existPosTrkQA = true; + + float signedP = track.sign() * track.tpcInnerParam(); + float dEdx = track.tpcSignal(); + + float tpcdEdxMax0Rabs = trackQA.tpcdEdxMax0R() * dEdx / 100; + float tpcdEdxMax1Rabs = trackQA.tpcdEdxMax1R() * dEdx / 100; + float tpcdEdxMax2Rabs = trackQA.tpcdEdxMax2R() * dEdx / 100; + float tpcdEdxMax3Rabs = trackQA.tpcdEdxMax3R() * dEdx / 100; + + float tpcdEdxTot0Rabs = trackQA.tpcdEdxTot0R() * dEdx / 100; + float tpcdEdxTot1Rabs = trackQA.tpcdEdxTot1R() * dEdx / 100; + float tpcdEdxTot2Rabs = trackQA.tpcdEdxTot2R() * dEdx / 100; + float tpcdEdxTot3Rabs = trackQA.tpcdEdxTot3R() * dEdx / 100; + + histos.fill(HIST("tpcdEdxMax0R_vs_Momentum"), signedP, tpcdEdxMax0Rabs); + histos.fill(HIST("tpcdEdxMax1R_vs_Momentum"), signedP, tpcdEdxMax1Rabs); + histos.fill(HIST("tpcdEdxMax2R_vs_Momentum"), signedP, tpcdEdxMax2Rabs); + histos.fill(HIST("tpcdEdxMax3R_vs_Momentum"), signedP, tpcdEdxMax3Rabs); + + histos.fill(HIST("tpcdEdxTot0R_vs_Momentum"), signedP, tpcdEdxTot0Rabs); + histos.fill(HIST("tpcdEdxTot1R_vs_Momentum"), signedP, tpcdEdxTot1Rabs); + histos.fill(HIST("tpcdEdxTot2R_vs_Momentum"), signedP, tpcdEdxTot2Rabs); + histos.fill(HIST("tpcdEdxTot3R_vs_Momentum"), signedP, tpcdEdxTot3Rabs); + + // FROM: https://github.com/AliceO2Group/AliceO2/blob/d4afff4276fae2d31f6c3c79d9ec4246deff95f8/Detectors/AOD/src/AODProducerWorkflowSpec.cxx#L2628C1-L2629C84 + // const float dEdxNorm = (tpcOrig.getdEdx().dEdxTotTPC > 0) ? 100. / tpcOrig.getdEdx().dEdxTotTPC : 0; + // trackQAHolder.tpcdEdxMax0R = uint8_t(tpcOrig.getdEdx().dEdxMaxIROC * dEdxNorm); + histos.fill(HIST("tpcdEdxTot3R_vs_dEdxFromTracks"), track.tpcSignal(), trackQA.tpcdEdxTot3R() * dEdx / 100); + histos.fill(HIST("tpcdEdxTotSUM_vs_dEdxFromTracks"), track.tpcSignal(), tpcdEdxTot0Rabs + tpcdEdxTot1Rabs + tpcdEdxTot2Rabs + tpcdEdxTot3Rabs); + histos.fill(HIST("tpcdEdxMaxSUM_vs_dEdxFromTracks"), track.tpcSignal(), tpcdEdxMax0Rabs + tpcdEdxMax1Rabs + tpcdEdxMax2Rabs + tpcdEdxMax3Rabs); + + // ### dEdx MAX + if (1) { + float sum_dEdx_max = 0; + int counter_has_dEdx_max = 0; + if (tpcdEdxMax1Rabs > 0) { + sum_dEdx_max += tpcdEdxMax1Rabs; + counter_has_dEdx_max++; + } + if (tpcdEdxMax2Rabs > 0) { + sum_dEdx_max += tpcdEdxMax2Rabs; + counter_has_dEdx_max++; + } + if (tpcdEdxMax3Rabs > 0) { + sum_dEdx_max += tpcdEdxMax3Rabs; + counter_has_dEdx_max++; + } + // only 3 OROC: + float sum_3OROC_dEdx_max = sum_dEdx_max; + int counter_3OROC_has_dEdx_max = counter_has_dEdx_max; + if (counter_3OROC_has_dEdx_max > 0) { + sum_3OROC_dEdx_max /= counter_3OROC_has_dEdx_max; + histos.fill(HIST("tpcdEdxAverageMax_3OROC_vs_dEdxFromTracks"), track.tpcSignal(), sum_3OROC_dEdx_max); + } + // now IROC: + if (tpcdEdxMax0Rabs > 0) { + sum_dEdx_max += tpcdEdxMax0Rabs; + counter_has_dEdx_max++; + } + // average and fill histos + if (counter_has_dEdx_max > 0) { + sum_dEdx_max /= counter_has_dEdx_max; + histos.fill(HIST("tpcdEdxAverageMax_vs_dEdxFromTracks"), track.tpcSignal(), sum_dEdx_max); + } + if (occupancy >= 0) { + if (std::fabs(signedP) > 0.38 && std::fabs(signedP) < 0.4) + histos.fill(HIST("dEdx_3OROC_max_vs_centr_vs_occup_narrow_p_win"), nPV, occupancy, sum_dEdx_max); + + if (track.eta() > 0.2 && track.eta() < 0.4) + histos.fill(HIST("dEdx_3OROC_max_vs_Momentum_vs_occup_eta_02_04"), signedP, sum_dEdx_max, occupancy); + if (track.eta() > -0.4 && track.eta() < -0.2) + histos.fill(HIST("dEdx_3OROC_max_vs_Momentum_vs_occup_eta_04_02"), signedP, sum_dEdx_max, occupancy); + } + } + // ### dEdx TOT + if (1) { + float sum_dEdx_tot = 0; + int counter_has_dEdx_tot = 0; + if (tpcdEdxTot1Rabs > 0) { + sum_dEdx_tot += tpcdEdxTot1Rabs; + counter_has_dEdx_tot++; + } + if (tpcdEdxTot2Rabs > 0) { + sum_dEdx_tot += tpcdEdxTot2Rabs; + counter_has_dEdx_tot++; + } + if (tpcdEdxTot3Rabs > 0) { + sum_dEdx_tot += tpcdEdxTot3Rabs; + counter_has_dEdx_tot++; + } + // only 3 OROC: + float sum_3OROC_dEdx_tot = sum_dEdx_tot; + int counter_3OROC_has_dEdx_tot = counter_has_dEdx_tot; + if (counter_3OROC_has_dEdx_tot > 0) { + sum_3OROC_dEdx_tot /= counter_3OROC_has_dEdx_tot; + histos.fill(HIST("tpcdEdxAverageTot_3OROC_vs_dEdxFromTracks"), track.tpcSignal(), sum_3OROC_dEdx_tot); + } + // now IROC: + if (tpcdEdxTot0Rabs > 0) { + sum_dEdx_tot += tpcdEdxTot0Rabs; + counter_has_dEdx_tot++; + } + // average and fill histos + if (counter_has_dEdx_tot > 0) { + sum_dEdx_tot /= counter_has_dEdx_tot; + histos.fill(HIST("tpcdEdxAverageTot_vs_dEdxFromTracks"), track.tpcSignal(), sum_dEdx_tot); + } + + if (occupancy >= 0) { + if (std::fabs(signedP) > 0.38 && std::fabs(signedP) < 0.4) + histos.fill(HIST("dEdx_3OROC_tot_vs_centr_vs_occup_narrow_p_win"), nPV, occupancy, sum_dEdx_tot); + + if (track.eta() > 0.2 && track.eta() < 0.4) + histos.fill(HIST("dEdx_3OROC_tot_vs_Momentum_vs_occup_eta_02_04"), signedP, sum_dEdx_tot, occupancy); + if (track.eta() > -0.4 && track.eta() < -0.2) + histos.fill(HIST("dEdx_3OROC_tot_vs_Momentum_vs_occup_eta_04_02"), signedP, sum_dEdx_tot, occupancy); + } + } + + histos.fill(HIST("dcaXY_vs_dcaXYqa"), track.dcaXY(), trackQA.tpcdcaR()); + histos.fill(HIST("dcaZ_vs_dcaZqa"), track.dcaZ(), trackQA.tpcdcaZ()); + } + // else { + // existPosTrkQA = false; + // } + + // ### dE/dx by Marian: + float fTPCSignal = track.tpcSignal(); + float fNormMultTPC = multTPC / 11000.; // IA: my guess: it's https://github.com/AliceO2Group/O2Physics/blob/f681d9cc71214c4eb5613a3f473cbea41e48a61f/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx#L575C30-L575C47 + + // df["mdEdx"]=(50/df["fTPCSignal"]).clip(0.05,1.1) + // df["fTPCSignalN"]=(df["fTPCSignal"]/df["bb0"]/50.).clip(0.5,1.5) + // df["fTrackOccN"]=df.eval("fTrackOcc/1000.") + // df["mdEdxExp"]=df.eval("1./bb0") + // df["fFt0OccN"]=df["fFt0Occ"]*df.eval("fFt0Occ/fTrackOcc").median() + // df["mdEdxExpOcc"]=df.eval("mdEdxExp*fTrackOccN") + // df["fTrackOccMeanN"]=(df["fHadronicRate"]/5) # normalization 5 - 10 bins + // df["fTrackOccN2"]=df.eval("fTrackOccN*fTrackOccN") + // df["fOccTPCN"]=(df["fNormMultTPC"]*10).clip(0,12) # normalization 10 - 12 bins + // df["mdEdxOccTPCN"]=df.eval("mdEdx*fOccTPCN") + // df["mdEdxMeanOccTPCN"]=df.eval("mdEdx*fTrackOccMeanN") + + float fTrackOccN = occupancy / 1000.; + float fOccTPCN = fNormMultTPC * 10; //(fNormMultTPC*10).clip(0,12) + if (fOccTPCN > 12) + fOccTPCN = 12; + else if (fOccTPCN < 0) + fOccTPCN = 0; + + float fTrackOccMeanN = hadronicRate / 5; + + float side = track.tgl() > 0 ? 1 : 0; + float a1pt = std::abs(track.signed1Pt()); + float a1pt2 = a1pt * a1pt; + float atgl = std::abs(track.tgl()); + float mbb0R = 50 / fTPCSignal; + if (mbb0R > 1.05) + mbb0R = 1.05; + else if (mbb0R < 0.05) + mbb0R = 0.05; + // float mbb0R = max(0.05, min(50 / fTPCSignal, 1.05)); + float a1ptmbb0R = a1pt * mbb0R; + float atglmbb0R = atgl * mbb0R; + + // tree->SetAlias("side","fTgl>0"); + // tree->SetAlias("a1pt","abs(fSigned1Pt)"); + // tree->SetAlias("a1pt2","abs(fSigned1Pt**2)"); + // tree->SetAlias("atgl","abs(fTgl)"); + // tree->SetAlias("mbb0R","max(0.05,min(50/fTPCSignal,1.05))"); + // tree->SetAlias("a1ptmbb0R","a1pt*mbb0R"); + // tree->SetAlias("atglmbb0R","atgl*mbb0R"); + + // ### iteration 1 correction + // float fTPCSignalN_CBB = fReal_fTPCSignalN(mbb0,a1pt,atgl,atglmbb0,a1ptmbb0,side,a1pt2,fTrackOccN,fOccTPCN,fTrackOccMeanN+0); // atglmbb0 is != atglmbb0R!!! etc. + float fTPCSignalN_CR0 = fReal_fTPCSignalN(mbb0R, a1pt, atgl, atglmbb0R, a1ptmbb0R, side, a1pt2, fTrackOccN, fOccTPCN, fTrackOccMeanN + 0); + + // tree->SetAlias("fTPCSignalN_CBB","fReal_fTPCSignalN(mbb0,a1pt,atgl,atglmbb0,a1ptmbb0,side,a1pt2,fTrackOccN,fOccTPCN,fTrackOccMeanN+0)"); + // tree->SetAlias("fTPCSignalN_CR0","fReal_fTPCSignalN(mbb0R,a1pt,atgl,atglmbb0R,a1ptmbb0R,side,a1pt2,fTrackOccN,fOccTPCN,fTrackOccMeanN+0)"); + + float mbb0R1 = 50 / (fTPCSignal / fTPCSignalN_CR0); + if (mbb0R1 > 1.05) + mbb0R1 = 1.05; + else if (mbb0R1 < 0.05) + mbb0R1 = 0.05; + // float mbb0R1 = max(0.05, min(50 / (fTPCSignal / fTPCSignalN_CR0), 1.05 + 0)); + // tree->SetAlias("mbb0R1","max(0.05,min(50/(fTPCSignal/fTPCSignalN_CR0),1.05+0))"); + float fTPCSignalN_CR1 = fReal_fTPCSignalN(mbb0R1, a1pt, atgl, atgl * mbb0R1, a1pt * mbb0R1, side, a1pt2, fTrackOccN, fOccTPCN, fTrackOccMeanN + 0); + // tree->SetAlias("fTPCSignalN_CR1","fReal_fTPCSignalN(mbb0R1,a1pt,atgl,atgl*mbb0R1,a1pt*mbb0R1,side,a1pt2,fTrackOccN,fOccTPCN,fTrackOccMeanN+0)"); + // + // tree->SetAlias("fTPCSignalN_mad_BB","fReal_fTPCSignalN_mad(mbb0,a1pt,atgl,atglmbb0,a1ptmbb0,side,a1pt2,fTrackOccN,fOccTPCN,fTrackOccMeanN+0)"); + // tree->SetAlias("fTPCSignalN_mad_R0","fReal_fTPCSignalN_mad(mbb0R1,a1pt,atgl,atgl*mbb0R1,a1pt*mbb0R1,side,a1pt2,fTrackOccN,fOccTPCN,fTrackOccMeanN+0)"); + // + // tree->SetAlias("fTPCSignal_CorrR1","fTPCSignal/fTPCSignalN_CR1"); + // tree->SetAlias("fTPCSignal_CorrBB","fTPCSignal/fTPCSignalN_CBB"); + + histos.fill(HIST("dEdx_vs_Momentum"), signedP, fTPCSignal); + + float corrected_dEdx = fTPCSignal / fTPCSignalN_CR1; + histos.fill(HIST("dEdx_CORRECTION_COEFF"), fTPCSignalN_CR1); + histos.fill(HIST("dEdx_vs_Momentum_CORRECTED"), signedP, corrected_dEdx); + histos.fill(HIST("tpcdEdxCORRECTED_vs_dEdxFromTracks"), fTPCSignal, corrected_dEdx); + + if (occupancy >= 0) { + if (std::fabs(signedP) > 0.38 && std::fabs(signedP) < 0.4) { + histos.fill(HIST("dEdx_vs_centr_vs_occup_narrow_p_win"), nPV, occupancy, fTPCSignal); + histos.fill(HIST("dEdx_vs_centr_vs_occup_narrow_p_win_CORRECTED"), nPV, occupancy, corrected_dEdx); + } + } + + } // end of track loop + } // end of collision loop + } + PROCESS_SWITCH(dEdxVsOccupancyWithTrackQAinfoTask, processRun3, "Process Run3 tracking vs detector occupancy QA", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/DPG/Tasks/AOTEvent/detectorOccupancyQa.cxx b/DPG/Tasks/AOTEvent/detectorOccupancyQa.cxx index bdfbde3f74e..4575146c592 100644 --- a/DPG/Tasks/AOTEvent/detectorOccupancyQa.cxx +++ b/DPG/Tasks/AOTEvent/detectorOccupancyQa.cxx @@ -15,7 +15,7 @@ /// \author Igor Altsybeev #include -#include "map" +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -42,53 +42,59 @@ using namespace o2; using namespace o2::framework; using namespace o2::aod::evsel; -using BCsRun2 = soa::Join; using BCsRun3 = soa::Join; -// using ColEvSels = soa::Join; using ColEvSels = soa::Join; -// using FullTracksIU = soa::Join; using FullTracksIU = soa::Join; struct DetectorOccupancyQaTask { // configurables for study of occupancy in time windows - Configurable confAddBasicQAhistos{"AddBasicQAhistos", true, "0 - add basic histograms, 1 - skip"}; // o2-linter: disable=name/configurable - Configurable confTimeIntervalForOccupancyCalculation{"TimeIntervalForOccupancyCalculation", 100, "Time interval for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable - Configurable confOccupancyHistCoeffNtracksForOccupancy{"HistCoeffNtracksForOccupancy", 1., "Coefficient for max nTracks in occupancy histos"}; // o2-linter: disable=name/configurable - Configurable confOccupancyHistCoeffNbins2D{"HistCoeffNbins2D", 1., "Coefficient for nBins in occupancy 2D histos"}; // o2-linter: disable=name/configurable - Configurable confOccupancyHistCoeffNbins3D{"HistCoeffNbins3D", 1., "Coefficient for nBins in occupancy 3D histos"}; // o2-linter: disable=name/configurable - Configurable confCoeffMaxNtracksThisEvent{"CoeffMaxNtracksThisEvent", 1., "Coefficient for max nTracks or FT0 ampl in histos in a given event"}; // o2-linter: disable=name/configurable - Configurable confFlagApplyROFborderCut{"ApplyROFborderCut", true, "Use ROF border cut for a current event"}; // o2-linter: disable=name/configurable - Configurable confFlagApplyTFborderCut{"ApplyTFborderCut", true, "Use TF border cut for a current event"}; // o2-linter: disable=name/configurable - Configurable confFlagWhichTimeRange{"FlagWhichTimeRange", 0, "Whicn time range for occupancy calculation: 0 - symmetric, 1 - only past, 2 - only future"}; // o2-linter: disable=name/configurable - Configurable confFlagUseGlobalTracks{"FlagUseGlobalTracks", false, "For small time bins, use global tracks counter instead of ITSTPC tracks"}; // o2-linter: disable=name/configurable - Configurable confFlagUseNoCollInRofStrict{"FlagUseNoCollInRofStrict", false, "Suppress same-ROF events for occupancy historams"}; // o2-linter: disable=name/configurable - Configurable confFlagUseNoHighMultCollInPrevRof{"FlagUseNoHighMultCollInPrevRof", false, "Suppress high-multiplicity prev-ROF events for occupancy historams"}; // o2-linter: disable=name/configurable + Configurable confAddBasicQAhistos{"AddBasicQAhistos", true, "0 - add basic histograms, 1 - skip"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confTimeIntervalForOccupancyCalculation{"TimeIntervalForOccupancyCalculation", 100, "Time interval for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confOccupancyHistCoeffNtracksForOccupancy{"HistCoeffNtracksForOccupancy", 1., "Coefficient for max nTracks in occupancy histos"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confOccupancyHistCoeffNbins2D{"HistCoeffNbins2D", 1., "Coefficient for nBins in occupancy 2D histos"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confOccupancyHistCoeffNbins3D{"HistCoeffNbins3D", 1., "Coefficient for nBins in occupancy 3D histos"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCoeffMaxNtracksThisEvent{"CoeffMaxNtracksThisEvent", 1., "Coefficient for max nTracks or FT0 ampl in histos in a given event"}; // o2-linter: disable=name/configurable (temporary fix) + // Configurable confFlagApplyROFborderCut{"ApplyROFborderCut", true, "Use ROF border cut for a current event"}; // o2-linter: disable=name/configurable (temporary fix) + // Configurable confFlagApplyTFborderCut{"ApplyTFborderCut", true, "Use TF border cut for a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagWhichTimeRange{"FlagWhichTimeRange", 0, "Whicn time range for occupancy calculation: 0 - symmetric, 1 - only past, 2 - only future"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagUseGlobalTracks{"FlagUseGlobalTracks", false, "For small time bins, use global tracks counter instead of ITSTPC tracks"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagUseNoCollInRofStrict{"FlagUseNoCollInRofStrict", false, "Suppress same-ROF events for occupancy historams"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagUseNoHighMultCollInPrevRof{"FlagUseNoHighMultCollInPrevRof", false, "Suppress high-multiplicity prev-ROF events for occupancy historams"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagCentralityIsAvailable{"FlagCentralityIsAvailable", true, "Fill centrality-related historams"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagManyHeavyHistos{"FlagManyHeavyHistos", true, "Fill more TH2, TH3, THn historams"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagIsTOFIsTRDdtStudy{"FlagIsTOFIsTRDdtStudy", true, "Fill THn dt historams with isTOF and isTRD condition"}; // o2-linter: disable=name/configurable (temporary fix) // configuration for small time binning - Configurable confTimeIntervalForSmallBins{"TimeIntervalForSmallBins", 100, "Time interval for TPC occupancy calculation in small bins, +/-, us"}; // o2-linter: disable=name/configurable - Configurable confNumberOfSmallTimeBins{"nSmallTimeBins", 40, "Number of small time bins"}; // o2-linter: disable=name/configurable + Configurable confTimeIntervalForSmallBins{"TimeIntervalForSmallBins", 100, "Time interval for TPC occupancy calculation in small bins, +/-, us"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confNumberOfSmallTimeBins{"nSmallTimeBins", 40, "Number of small time bins"}; // o2-linter: disable=name/configurable (temporary fix) // event and track cuts for given event - Configurable confCutVertZMinThisEvent{"VzMinThisEvent", -10, "vZ cut for a current event"}; // o2-linter: disable=name/configurable - Configurable confCutVertZMaxThisEvent{"VzMaxThisEvent", 10, "vZ cut for a current event"}; // o2-linter: disable=name/configurable - Configurable confCutPtMinThisEvent{"PtMinThisEvent", 0.2, "pt cut for particles in a current event"}; // o2-linter: disable=name/configurable - Configurable confCutPtMaxThisEvent{"PtMaxThisEvent", 100., "pt cut for particles in a current event"}; // o2-linter: disable=name/configurable - Configurable confCutEtaMinTracksThisEvent{"EtaMinTracksThisEvent", -0.8, "eta cut for particles in a current event"}; // o2-linter: disable=name/configurable - Configurable confCutEtaMaxTracksThisEvent{"EtaMaxTracksThisEvent", 0.8, "eta cut for particles in a current event"}; // o2-linter: disable=name/configurable - Configurable confCutMinTPCcls{"MinNumTPCcls", 70, "min number of TPC clusters for a current event"}; // o2-linter: disable=name/configurable + Configurable confCutVertZMinThisEvent{"VzMinThisEvent", -10, "vZ cut for a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutVertZMaxThisEvent{"VzMaxThisEvent", 10, "vZ cut for a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutPtMinThisEvent{"PtMinThisEvent", 0.2, "pt cut for particles in a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutPtMaxThisEvent{"PtMaxThisEvent", 100., "pt cut for particles in a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutEtaMinTracksThisEvent{"EtaMinTracksThisEvent", -0.8, "eta cut for particles in a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutEtaMaxTracksThisEvent{"EtaMaxTracksThisEvent", 0.8, "eta cut for particles in a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutMinTPCcls{"MinNumTPCcls", 50, "min number of TPC clusters for a current event"}; // o2-linter: disable=name/configurable (temporary fix) // config for QA histograms - Configurable confAddTracksVsFwdHistos{"AddTracksVsFwdHistos", true, "0 - add histograms, 1 - skip"}; // o2-linter: disable=name/configurable - Configurable nBinsTracks{"nBinsTracks", 400, "N bins in n tracks histo"}; // o2-linter: disable=name/configurable - Configurable nMaxTracks{"nMaxTracks", 8000, "N max in n tracks histo"}; // o2-linter: disable=name/configurable - Configurable nMaxGlobalTracks{"nMaxGlobalTracks", 3000, "N max in n tracks histo"}; // o2-linter: disable=name/configurable - Configurable nBinsMultFwd{"nBinsMultFwd", 400, "N bins in mult fwd histo"}; // o2-linter: disable=name/configurable - Configurable nMaxMultFwd{"nMaxMultFwd", 200000, "N max in mult fwd histo"}; // o2-linter: disable=name/configurable + Configurable confAddTracksVsFwdHistos{"AddTracksVsFwdHistos", true, "0 - add histograms, 1 - skip"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nBinsTracks{"nBinsTracks", 400, "N bins in n tracks histo"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nMaxTracks{"nMaxTracks", 8000, "N max in n tracks histo"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nMaxGlobalTracks{"nMaxGlobalTracks", 3000, "N max in n tracks histo"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nBinsMultFwd{"nBinsMultFwd", 400, "N bins in mult fwd histo"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nMaxMultFwd{"nMaxMultFwd", 200000, "N max in mult fwd histo"}; // o2-linter: disable=name/configurable (temporary fix) - Configurable nBinsOccupancy{"nBinsOccupancy", 150, "N bins for occupancy axis"}; // o2-linter: disable=name/configurable - Configurable nMaxOccupancy{"nMaxOccupancy", 15000, "N for max of the occupancy axis"}; // o2-linter: disable=name/configurable + Configurable nBinsOccupancy{"nBinsOccupancy", 150, "N bins for occupancy axis"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nMaxOccupancy{"nMaxOccupancy", 15000, "N for max of the occupancy axis"}; // o2-linter: disable=name/configurable (temporary fix) - Configurable nMaxBcInTFforAnalysis{"nMaxBcInTFforAnalysis", -1, "When to stop taking collisions in TF, if -1: take all collisions"}; // o2-linter: disable=name/configurable + Configurable nMaxBcInTFforAnalysis{"nMaxBcInTFforAnalysis", -1, "When to stop taking collisions in TF, if -1: take all collisions"}; // o2-linter: disable=name/configurable (temporary fix) + + ConfigurableAxis confAxisPtBinsForPhiStudy{"PtBinsForPhiStudy", {VARIABLE_WIDTH, 0.2, 0.6, 1.0, 2.0, 10}, "pt axis"}; + ConfigurableAxis confAxisOccupForKine{"AxisOccupForKine", {VARIABLE_WIDTH, 0, 500, 1000, 2000, 4000, 6000, 8000, 10000, 20000}, "weighted occupancy"}; + + Configurable confUsePhiAtTPCinnerR{"UsePhiAtTPCinnerR", false, "0 - not use, 1 - use"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confUseAorCsideForPhiStudy{"UseAorCsideForPhiStudy", -1, "-1 - use full eta range, 0 - A, 1 - C sides"}; // o2-linter: disable=name/configurable (temporary fix) uint64_t minGlobalBC = 0; Service ccdb; @@ -98,8 +104,8 @@ struct DetectorOccupancyQaTask { int lastRunNumber = -1; int nOrbits; double minOrbit; - int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 by default for unanchored MC - int64_t nBCsPerTF = 128 * nBCsPerOrbit; // duration of TF in bcs, should be 128*3564 or 32*3564, setting 128 orbits by default sfor unanchored MC + int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 by default for unanchored MC + int64_t nBCsPerTF = 32 * nBCsPerOrbit; // duration of TF in bcs, should be 128*3564 or 32*3564, setting 128 orbits by default sfor unanchored MC // save time "slices" for several collisions for QA bool flagFillQAtimeOccupHist = false; @@ -114,8 +120,9 @@ struct DetectorOccupancyQaTask { ccdb->setLocalObjectValidityChecking(); const AxisSpec axisBCinTF{static_cast(nBCsPerTF), 0, static_cast(nBCsPerTF), "bc in TF"}; - histos.add("hNcolVsBcInTF", ";bc in TF; n collisions", kTH1F, {axisBCinTF}); - histos.add("hNcolVsBcInTFafterMaxBcCut", ";bc in TF; n collisions", kTH1F, {axisBCinTF}); + histos.add("hNcolVsBcInTF/hNcolVsBcInTF", ";bc in TF; n collisions", kTH1F, {axisBCinTF}); + histos.add("hNcolVsBcInTF/hNcolVsBcInTF_vertexTOFmatched", ";bc in TF; n collisions", kTH1F, {axisBCinTF}); + histos.add("hNcolVsBcInTF/hNcolVsBcInTFafterMaxBcCut", ";bc in TF; n collisions", kTH1F, {axisBCinTF}); // histograms for occupancy-in-time-window study double kMaxOccup = confOccupancyHistCoeffNtracksForOccupancy; @@ -142,37 +149,122 @@ struct DetectorOccupancyQaTask { histos.add("hNumUniqueBCInTimeWindow", ";n collisions;n events", kTH1D, {{201, -0.5, 200.5}}); + // track QA counters + histos.add("nTrackCounter_after_cuts_QA", "", kTH1D, {{12, -0.5, 11.5, "track QA"}}); + TAxis* axTrackCounters = reinterpret_cast(histos.get(HIST("nTrackCounter_after_cuts_QA"))->GetXaxis()); + axTrackCounters->SetBinLabel(1, "all"); + axTrackCounters->SetBinLabel(2, "PVcontrib"); + axTrackCounters->SetBinLabel(3, "ptCut"); + axTrackCounters->SetBinLabel(4, "etaCut"); + axTrackCounters->SetBinLabel(5, "itsNCls>=5"); + axTrackCounters->SetBinLabel(6, "isGlobal,nTPCcls>=70"); + axTrackCounters->SetBinLabel(7, "passedTPCRefit"); + axTrackCounters->SetBinLabel(8, "occupancy>=0"); + axTrackCounters->SetBinLabel(9, "fracton nClsNoPID (0,0.8)"); + axTrackCounters->SetBinLabel(10, "pos"); + axTrackCounters->SetBinLabel(11, "neg"); + // dE/dx - histos.add("dEdx_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, {800, 0.0, 800.0, "dE/dx (a. u.)"}}); - histos.add("dEdx_vs_Momentum_occupBelow200", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, {800, 0.0, 800.0, "dE/dx (a. u.)"}}); - histos.add("dEdx_vs_Momentum_occupBelow200_kNoCollStd", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, {800, 0.0, 800.0, "dE/dx (a. u.)"}}); - histos.add("dEdx_vs_Momentum_occupAbove4000", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, {800, 0.0, 800.0, "dE/dx (a. u.)"}}); + AxisSpec axisDeDx{800, 0.0, 800.0, "dE/dx (a. u.)"}; + histos.add("dEdx_vs_Momentum", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("dEdx_vs_Momentum_occupBelow200", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("dEdx_vs_Momentum_occupBelow200_kNoCollStd", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("dEdx_vs_Momentum_occupAbove4000", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("dEdx_vs_Momentum_NegativeFractionNclsPID", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); + histos.add("dEdx_vs_Momentum_HighFractionNclsNonPID", "dE/dx", kTH2F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx}); AxisSpec axisBinsOccupStudydEdx{{0., 500, 1000, 2000, 4000, 6000, 8000, 15000}, "p_{T}"}; - histos.add("dEdx_vs_Momentum_vs_occup", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, {800, 0.0, 800.0, "dE/dx (a. u.)"}, axisBinsOccupStudydEdx}); - histos.add("dEdx_vs_Momentum_vs_occup_eta_02_04", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, {800, 0.0, 800.0, "dE/dx (a. u.)"}, axisBinsOccupStudydEdx}); - histos.add("dEdx_vs_Momentum_vs_occup_eta_04_02", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, {800, 0.0, 800.0, "dE/dx (a. u.)"}, axisBinsOccupStudydEdx}); + histos.add("dEdx_vs_Momentum_vs_occup", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + if (confFlagManyHeavyHistos) { + histos.add("dEdx_vs_Momentum_vs_occup_eta_02_04", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + histos.add("dEdx_vs_Momentum_vs_occup_eta_04_02", "dE/dx", kTH3F, {{1000, -5.0, 5.0, "#it{p}/Z (GeV/c)"}, axisDeDx, axisBinsOccupStudydEdx}); + } - histos.add("dEdx_vs_centr_vs_occup_narrow_p_win", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, {60, 0, 15000, "occupancy"}, {800, 0.0, 800.0, "dE/dx (a. u.)"}}); + AxisSpec axisOccupancyForDeDxStudies{60, 0, 15000, "occupancy"}; + histos.add("dEdx_vs_centr_vs_occup_narrow_p_win", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + histos.add("dEdx_vs_centr_vs_occup_narrow_p_win_pos", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + histos.add("dEdx_vs_centr_vs_occup_narrow_p_win_neg", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + histos.add("dEdx_vs_centr_vs_occup_narrow_p_win_pos_FractionPIDclsInRange", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + histos.add("dEdx_vs_centr_vs_occup_narrow_p_win_neg_FractionPIDclsInRange", "dE/dx", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisDeDx}); + + AxisSpec axisNTPCcls{160, 0, 160, "n TPC clusters"}; + histos.add("tpcNClsFound_vs_centr_vs_occup", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisNTPCcls}); + histos.add("tpcNClsFindable_vs_centr_vs_occup", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisNTPCcls}); + histos.add("tpcNClsShared_vs_centr_vs_occup", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisNTPCcls}); + histos.add("tpcNClsShared_vs_centr_vs_occup_Aside", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisNTPCcls}); + histos.add("tpcNClsShared_vs_centr_vs_occup_Cside", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisNTPCcls}); + histos.add("tpcNClsShared_vs_centr_vs_occup_pos", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisNTPCcls}); + histos.add("tpcNClsShared_vs_centr_vs_occup_neg", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisNTPCcls}); + + // July 2025: more for data vs MC + AxisSpec axisChi2TPC{150, 0, 15, "chi2Ncl TPC"}; + histos.add("QA_noTPCcuts/nPV_10_200/tpcNClsFindable_vs_occup_pt_02_05", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_10_200/tpcNClsFindable_vs_occup_pt_05_10", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_10_200/tpcNClsFindable_vs_occup_pt_above1_0", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_10_200/tpcNClsFound_vs_occup_pt_02_05", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_10_200/tpcNClsFound_vs_occup_pt_05_10", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_10_200/tpcNClsFound_vs_occup_pt_above1_0", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_10_200/tpcChi2NCl_vs_occup_pt_02_05", "", kTH2F, {axisChi2TPC, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_10_200/tpcChi2NCl_vs_occup_pt_05_10", "", kTH2F, {axisChi2TPC, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_10_200/tpcChi2NCl_vs_occup_pt_above1_0", "", kTH2F, {axisChi2TPC, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_above2000/tpcNClsFindable_vs_occup_pt_02_05", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_above2000/tpcNClsFindable_vs_occup_pt_05_10", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_above2000/tpcNClsFindable_vs_occup_pt_above1_0", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_above2000/tpcNClsFound_vs_occup_pt_02_05", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_above2000/tpcNClsFound_vs_occup_pt_05_10", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_above2000/tpcNClsFound_vs_occup_pt_above1_0", "", kTH2F, {axisNTPCcls, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_above2000/tpcChi2NCl_vs_occup_pt_02_05", "", kTH2F, {axisChi2TPC, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_above2000/tpcChi2NCl_vs_occup_pt_05_10", "", kTH2F, {axisChi2TPC, axisOccupancyForDeDxStudies}); + histos.add("QA_noTPCcuts/nPV_above2000/tpcChi2NCl_vs_occup_pt_above1_0", "", kTH2F, {axisChi2TPC, axisOccupancyForDeDxStudies}); + + AxisSpec axisFractionNclsFindableMinusPID{110, -1.1, 1.1, "TPC nClsFindableMinusPID / nClsFindable"}; + histos.add("fraction_tpcNClsFindableMinusPID_vs_occup", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_peripheralByV0A", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_centralByV0A", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_eta02", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_pos", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_neg", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_lowPt", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + histos.add("fraction_tpcNClsFindableMinusPID_vs_occup_highPt", "", kTH2D, {axisOccupancyForDeDxStudies, axisFractionNclsFindableMinusPID}); + + // more QA for TPC cls counting + histos.add("tpcNClsFindable", "", kTH1D, {{601, -300.5, 300.5}}); + histos.add("tpcNClsFindableMinusFound", "", kTH1D, {{601, -300.5, 300.5}}); + histos.add("tpcNClsFindableMinusCrossedRows", "", kTH1D, {{601, -300.5, 300.5}}); + histos.add("tpcNClsShared", "", kTH1D, {{601, -300.5, 300.5}}); + histos.add("tpcNClsFindableMinusPID", "", kTH1D, {{601, -300.5, 300.5}}); + histos.add("tpcNClUsedForPID", "", kTH1D, {{601, -300.5, 300.5}}); + histos.add("tpcNClsFound", "", kTH1D, {{601, -300.5, 300.5}}); + histos.add("tpcNClsFoundAsDiffByHand", "", kTH1D, {{601, -300.5, 300.5}}); + histos.add("tpcNClsFindableMinusPID_CORRECTED", "", kTH1D, {{601, -300.5, 300.5}}); + histos.add("tpcNClsFoundMinusPID_BY_HAND", "", kTH1D, {{601, -300.5, 300.5}}); + + histos.add("tpcNClsUsedForPID_vs_Findable", ";tpcNClsFindable;tpcNClUsedForPID", kTH2D, {{601, -300.5, 300.5}, {601, -300.5, 300.5}}); + histos.add("tpcNClsUsedForPID_vs_Findable_CORRECTED", ";tpcNClsFindable;tpcNClUsedForPID", kTH2D, {{601, -300.5, 300.5}, {601, -300.5, 300.5}}); + histos.add("tpcNClsShared_vs_Findable", ";tpcNClsFindable;tpcNClsShared", kTH2D, {{601, -300.5, 300.5}, {601, -300.5, 300.5}}); + histos.add("tpcNClsFound_vs_Findable", ";tpcNClsFindable;tpcNClsFound", kTH2D, {{601, -300.5, 300.5}, {601, -300.5, 300.5}}); + histos.add("tpcNClsUsedForPID_vs_Shared", ";tpcNClsShared;tpcNClUsedForPID", kTH2D, {{601, -300.5, 300.5}, {601, -300.5, 300.5}}); + histos.add("tpcNClsUsedForPID_vs_Found", ";tpcNClsFound;tpcNClUsedForPID", kTH2D, {{601, -300.5, 300.5}, {601, -300.5, 300.5}}); // ### kinematic distributions for events with high occupancy at specified dt ranges histos.add("track_distr_nITStrThisEv_10_200/hEventCount", ";delta-time bin id;n events", kTH1D, {{5, -0.5, 4.5}}); histos.add("track_distr_nITStrThisEv_above_2000/hEventCount", ";delta-time bin id;n events", kTH1D, {{5, -0.5, 4.5}}); const int nEtaBins = 800; - histos.add("track_distr_nITStrThisEv_10_200/hEta_lowOccupInTPC", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - histos.add("track_distr_nITStrThisEv_10_200/hEta_highOccupInRecentPast", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - histos.add("track_distr_nITStrThisEv_10_200/hEta_highOccupInCloseFuture", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - histos.add("track_distr_nITStrThisEv_10_200/hEta_highOccupInDistantFuture", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - histos.add("track_distr_nITStrThisEv_10_200/hEta_highOccupInNeighbourEvents", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - - histos.add("track_distr_nITStrThisEv_above_2000/hEta_lowOccupInTPC", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - histos.add("track_distr_nITStrThisEv_above_2000/hEta_highOccupInRecentPast", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - histos.add("track_distr_nITStrThisEv_above_2000/hEta_highOccupInCloseFuture", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - histos.add("track_distr_nITStrThisEv_above_2000/hEta_highOccupInDistantFuture", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - histos.add("track_distr_nITStrThisEv_above_2000/hEta_highOccupInNeighbourEvents", ";#eta;n tracks", kTH1D, {{nEtaBins, -1.0, 1.0}}); - - const int nPhiBins = 800; - AxisSpec axisPhi{nPhiBins, 0, TMath::TwoPi(), "#varphi"}; // o2-linter: disable=external-pi + AxisSpec axisEta{nEtaBins, -1.0, 1.0, "#eta"}; // o2-linter: disable=external-pi (temporary fix) + histos.add("track_distr_nITStrThisEv_10_200/hEta_lowOccupInTPC", ";#eta;n tracks", kTH1D, {axisEta}); + histos.add("track_distr_nITStrThisEv_10_200/hEta_highOccupInRecentPast", ";#eta;n tracks", kTH1D, {axisEta}); + histos.add("track_distr_nITStrThisEv_10_200/hEta_highOccupInCloseFuture", ";#eta;n tracks", kTH1D, {axisEta}); + histos.add("track_distr_nITStrThisEv_10_200/hEta_highOccupInDistantFuture", ";#eta;n tracks", kTH1D, {axisEta}); + histos.add("track_distr_nITStrThisEv_10_200/hEta_highOccupInNeighbourEvents", ";#eta;n tracks", kTH1D, {axisEta}); + + histos.add("track_distr_nITStrThisEv_above_2000/hEta_lowOccupInTPC", ";#eta;n tracks", kTH1D, {axisEta}); + histos.add("track_distr_nITStrThisEv_above_2000/hEta_highOccupInRecentPast", ";#eta;n tracks", kTH1D, {axisEta}); + histos.add("track_distr_nITStrThisEv_above_2000/hEta_highOccupInCloseFuture", ";#eta;n tracks", kTH1D, {axisEta}); + histos.add("track_distr_nITStrThisEv_above_2000/hEta_highOccupInDistantFuture", ";#eta;n tracks", kTH1D, {axisEta}); + histos.add("track_distr_nITStrThisEv_above_2000/hEta_highOccupInNeighbourEvents", ";#eta;n tracks", kTH1D, {axisEta}); + + const int nPhiBins = 810; // 18*45 + AxisSpec axisPhi{nPhiBins, 0, TMath::TwoPi(), "#varphi"}; // o2-linter: disable=external-pi (temporary fix) histos.add("track_distr_nITStrThisEv_10_200/hPhi_lowOccupInTPC", ";#varphi;n tracks", kTH1D, {axisPhi}); histos.add("track_distr_nITStrThisEv_10_200/hPhi_highOccupInRecentPast", ";#varphi;n tracks", kTH1D, {axisPhi}); histos.add("track_distr_nITStrThisEv_10_200/hPhi_highOccupInCloseFuture", ";#varphi;n tracks", kTH1D, {axisPhi}); @@ -200,11 +292,60 @@ struct DetectorOccupancyQaTask { histos.add("track_distr_nITStrThisEv_above_2000/hPt_highOccupInDistantFuture", ";p_{T};n tracks", kTH1D, {axisLogPt}); histos.add("track_distr_nITStrThisEv_above_2000/hPt_highOccupInNeighbourEvents", ";p_{T};n tracks", kTH1D, {axisLogPt}); + // July 2025: to compare data and MC (pt, eta, phi) + // AxisSpec confAxisOccupForKine{{0, 500, 1000, 2000, 4000, 6000, 20000}, "weighted occupancy"}; + // AxisSpec confAxisOccupForKine{{0, 500, 1000, 2000, 4000, 6000, 8000, 10000, 20000}, "weighted occupancy"}; + // AxisSpec confAxisPtBinsForPhiStudy{{0.2, 0.6, 1.0, 2.0, 10}, "pt bins for phi study"}; + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hPt_pos", ";p_{T};weighted occupancy", kTH2D, {axisLogPt, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hPt_neg", ";p_{T};weighted occupancy", kTH2D, {axisLogPt, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hEta_pos", ";#eta;weighted occupancy", kTH2D, {axisEta, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hEta_neg", ";#eta;weighted occupancy", kTH2D, {axisEta, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hPhi_pos", ";#varphi;n tracks", kTH3D, {axisPhi, confAxisOccupForKine, confAxisPtBinsForPhiStudy}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hPhi_neg", ";#varphi;n tracks", kTH3D, {axisPhi, confAxisOccupForKine, confAxisPtBinsForPhiStudy}); + + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hPt_pos", ";p_{T};weighted occupancy", kTH2D, {axisLogPt, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hPt_neg", ";p_{T};weighted occupancy", kTH2D, {axisLogPt, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hEta_pos", ";#eta;weighted occupancy", kTH2D, {axisEta, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hEta_neg", ";#eta;weighted occupancy", kTH2D, {axisEta, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hPhi_pos", ";#varphi;n tracks", kTH3D, {axisPhi, confAxisOccupForKine, confAxisPtBinsForPhiStudy}); + histos.add("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hPhi_neg", ";#varphi;n tracks", kTH3D, {axisPhi, confAxisOccupForKine, confAxisPtBinsForPhiStudy}); + + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPt_pos", ";p_{T};weighted occupancy", kTH2D, {axisLogPt, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPt_neg", ";p_{T};weighted occupancy", kTH2D, {axisLogPt, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hEta_pos", ";#eta;weighted occupancy", kTH2D, {axisEta, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hEta_neg", ";#eta;weighted occupancy", kTH2D, {axisEta, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_pos", ";#varphi;n tracks", kTH3D, {axisPhi, confAxisOccupForKine, confAxisPtBinsForPhiStudy}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_neg", ";#varphi;n tracks", kTH3D, {axisPhi, confAxisOccupForKine, confAxisPtBinsForPhiStudy}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_posInitialQA", ";#varphi;n tracks", kTH1D, {{3 * 810, -TMath::TwoPi(), 2 * TMath::TwoPi(), "#varphi"}}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_posModifiedQA", ";#varphi;n tracks", kTH1D, {{3 * 810, -TMath::TwoPi(), 2 * TMath::TwoPi(), "#varphi"}}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_negInitialQA", ";#varphi;n tracks", kTH1D, {{3 * 810, -TMath::TwoPi(), 2 * TMath::TwoPi(), "#varphi"}}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_negModifiedQA", ";#varphi;n tracks", kTH1D, {{3 * 810, -TMath::TwoPi(), 2 * TMath::TwoPi(), "#varphi"}}); + + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hPt_pos", ";p_{T};weighted occupancy", kTH2D, {axisLogPt, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hPt_neg", ";p_{T};weighted occupancy", kTH2D, {axisLogPt, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hEta_pos", ";#eta;weighted occupancy", kTH2D, {axisEta, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hEta_neg", ";#eta;weighted occupancy", kTH2D, {axisEta, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hPhi_pos", ";#varphi;n tracks", kTH3D, {axisPhi, confAxisOccupForKine, confAxisPtBinsForPhiStudy}); + histos.add("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hPhi_neg", ";#varphi;n tracks", kTH3D, {axisPhi, confAxisOccupForKine, confAxisPtBinsForPhiStudy}); + + AxisSpec axisLogPtFor2D{50, 0.05, 10, "p_{T}"}; + AxisSpec axisLogPtTpcFor2D{50, 0.05, 10, "p_{T} TPC inner"}; + histos.add("track_distr_nITStrThisEv_10_200/hPt_vs_tpcInnerPt_vs_occup", ";p_{T};p_{T} TPC inner;weighted occupancy", kTH3D, {axisLogPtFor2D, axisLogPtTpcFor2D, confAxisOccupForKine}); + histos.add("track_distr_nITStrThisEv_above_2000/hPt_vs_tpcInnerPt_vs_occup", ";p_{T};p_{T} TPC inner;weighted occupancy", kTH3D, {axisLogPtFor2D, axisLogPtTpcFor2D, confAxisOccupForKine}); + + histos.add("hNcolVsBcInTF/hNcolVsBcInTF_vs_occupancy", ";bc in TF;weighted occupancy", kTH2F, {axisBCinTF, confAxisOccupForKine}); + histos.add("hNcolVsBcInTF/hNcolVsBcInTF_vs_occupancy_vertexTOFmatched", ";bc in TF;weighted occupancy", kTH2F, {axisBCinTF, confAxisOccupForKine}); + histos.add("hNcolVsBcInTF/hNcolVsBcInTF_vs_occupancy_nPV_10_200", ";bc in TF;weighted occupancy", kTH2F, {axisBCinTF, confAxisOccupForKine}); + histos.add("hNcolVsBcInTF/hNcolVsBcInTF_vs_occupancy_nPV_above2000", ";bc in TF;weighted occupancy", kTH2F, {axisBCinTF, confAxisOccupForKine}); + // end of July 2025: to compare data and MC (pt, eta, phi) + // 3D: pt vs centr vs occup - histos.add("ptGlobal_vs_centr_vs_occup", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, {60, 0, 15000, "occupancy"}, axisLogPt}); - histos.add("ptPV_vs_centr_vs_occup", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, {60, 0, 15000, "occupancy"}, axisLogPt}); - histos.add("ptGlobal_vs_centr_vs_occup_NoCollStd", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, {60, 0, 15000, "occupancy"}, axisLogPt}); - histos.add("ptPV_vs_centr_vs_occup_NoCollStd", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, {60, 0, 15000, "occupancy"}, axisLogPt}); + // if (confFlagManyHeavyHistos) { + // histos.add("ptGlobal_vs_centr_vs_occup", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisLogPt}); + // histos.add("ptPV_vs_centr_vs_occup", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisLogPt}); + // histos.add("ptGlobal_vs_centr_vs_occup_NoCollStd", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisLogPt}); + // histos.add("ptPV_vs_centr_vs_occup_NoCollStd", "", kTH3F, {{20, 0, 4000, "nITStrk cls567"}, axisOccupancyForDeDxStudies, axisLogPt}); + // } } // 2D int nBins3D = 80 * confOccupancyHistCoeffNbins3D; @@ -245,19 +386,26 @@ struct DetectorOccupancyQaTask { const AxisSpec axisTimeBins{arrTimeBins, "#Delta t, #mus"}; int nBinsX = 20; int nBinsY = 40; - histos.add("occupancyInTimeBins_BEFORE_sel", ";time bin (#mus);n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;ITS tracks with 5,6,7 cls in time window", kTHnF, {axisTimeBins, {nBinsX, 0, kMaxThisEv * 4000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 10000}}); - histos.add("occupancyInTimeBins_occupByFT0_BEFORE_sel", ";time bin (#mus);n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBinsX, 0, kMaxThisEv * 4000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); - histos.add("occupancyInTimeBins", ";time bin (#mus);n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;ITS tracks with 5,6,7 cls in time window", kTHnF, {axisTimeBins, {nBinsX, 0, kMaxThisEv * 4000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 10000}}); - histos.add("occupancyInTimeBins_occupByFT0", ";time bin (#mus);n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBinsX, 0, kMaxThisEv * 4000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); - histos.add("occupancyInTimeBins_occupByFT0_kNoCollInTimeRangeNarrow", ";time bin (#mus);n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBinsX, 0, kMaxThisEv * 4000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); - histos.add("occupancyInTimeBins_vs_FT0thisCol_kNoCollInTimeRangeNarrow", ";time bin (#mus);FT0C this collision, this collision;n ITS-TPC tracks, this collision;ITS tracks with 5,6,7 cls in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 10000}}); - histos.add("occupancyInTimeBins_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow", ";time bin (#mus);FT0C this collision, this collision;n ITS-TPC tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); - histos.add("occupancyInTimeBins_nITS567_vs_FT0thisCol_kNoCollInTimeRangeNarrow", ";time bin (#mus);FT0C this collision, this collision;n ITS567cls tracks, this collision;ITS tracks with 5,6,7 cls in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 10000}}); - histos.add("occupancyInTimeBins_nITS567_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow", ";time bin (#mus);FT0C this collision, this collision;n ITS567cls tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); - histos.add("occupancyInTimeBins_nITS567_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow_NoCollInRofStrict", ";time bin (#mus);FT0C this collision, this collision;n ITS567cls tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); + + if (confFlagManyHeavyHistos) { + histos.add("occupancyInTimeBins_BEFORE_sel", ";time bin (#mus);n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;ITS tracks with 5,6,7 cls in time window", kTHnF, {axisTimeBins, {nBinsX, 0, kMaxThisEv * 4000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 10000}}); + histos.add("occupancyInTimeBins_occupByFT0_BEFORE_sel", ";time bin (#mus);n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBinsX, 0, kMaxThisEv * 4000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); + + histos.add("occupancyInTimeBins_occupByFT0", ";time bin (#mus);n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBinsX, 0, kMaxThisEv * 4000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); + histos.add("occupancyInTimeBins_occupByFT0_kNoCollInTimeRangeNarrow", ";time bin (#mus);n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBinsX, 0, kMaxThisEv * 4000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); + + histos.add("occupancyInTimeBins_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow", ";time bin (#mus);FT0C this collision, this collision;n ITS-TPC tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); + + histos.add("occupancyInTimeBins_nITS567_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow", ";time bin (#mus);FT0C this collision, this collision;n ITS567cls tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); + histos.add("occupancyInTimeBins_nITS567_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow_NoCollInRofStrict", ";time bin (#mus);FT0C this collision, this collision;n ITS567cls tracks, this collision;sum FT0 in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 100000}}); + } + if (confFlagIsTOFIsTRDdtStudy) { + histos.add("occupancyInTimeBins_nITSTOF_vs_FT0thisCol_kNoCollInTimeRangeNarrow", ";time bin (#mus);FT0C this collision, this collision;n ITSTOF tracks, this collision;ITS tracks with 5,6,7 cls in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 10000}}); + histos.add("occupancyInTimeBins_nITSTRD_vs_FT0thisCol_kNoCollInTimeRangeNarrow", ";time bin (#mus);FT0C this collision, this collision;n ITSTRD tracks, this collision;ITS tracks with 5,6,7 cls in time window", kTHnF, {axisTimeBins, {nBins3D, 0, kMaxThisEv * 100000}, {nBinsY, 0, kMaxThisEv * 4000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 10000}}); + } histos.add("thisEventITStracksInTimeBins", ";time bin (#mus);n tracks", kTH1F, {axisTimeBins}); histos.add("thisEventITSTPCtracksInTimeBins", ";time bin (#mus);n tracks", kTH1F, {axisTimeBins}); @@ -276,9 +424,11 @@ struct DetectorOccupancyQaTask { histos.add("hOccupancyVsOrbit", ";orbit id;weighted occupancy;n events", kTH2F, {{128, -0.5, 127.5}, {600, 0, 15000}}); AxisSpec axisOccupancyTracks{nBinsOccupancy, 0., nMaxOccupancy, "occupancy (n ITS tracks weighted)"}; - AxisSpec axisCentrality{100, 0, 100, "centrality, %"}; - histos.add("hCentrVsOccupancy", "hCentrVsOccupancy", kTH2F, {axisCentrality, axisOccupancyTracks}); - histos.add("hCentrVsOccupancyNoCollStd", "hCentrVsOccupancyNoCollStd", kTH2F, {axisCentrality, axisOccupancyTracks}); + if (confFlagCentralityIsAvailable) { + AxisSpec axisCentrality{100, 0, 100, "centrality, %"}; + histos.add("hCentrVsOccupancy", "hCentrVsOccupancy", kTH2F, {axisCentrality, axisOccupancyTracks}); + histos.add("hCentrVsOccupancyNoCollStd", "hCentrVsOccupancyNoCollStd", kTH2F, {axisCentrality, axisOccupancyTracks}); + } if (confAddTracksVsFwdHistos) { AxisSpec axisNtracks{nBinsTracks, -0.5, nMaxTracks - 0.5, "n tracks"}; @@ -330,8 +480,8 @@ struct DetectorOccupancyQaTask { histos.add("nTracksGlobal_vs_nPV_AntiNoCollInTimeRangeStandard", "nTracksGlobal_vs_nPV_AntiNoCollInTimeRangeStandard", kTH2F, {axisNtracks, axisNtracksGlobal}); histos.add("nTracksGlobal_vs_nPV_AntiNoCollInTimeRangeNarrow", "nTracksGlobal_vs_nPV_AntiNoCollInTimeRangeNarrow", kTH2F, {axisNtracks, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_nPV_QA_onlyVzCut_noTFROFborderCuts", "nTracksGlobal_vs_nPV_QA_onlyVzCut_noTFROFborderCuts", kTH2F, {axisNtracks, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_nPV_QA_after_TFborderCut", "nTracksGlobal_vs_nPV_QA_after_TFborderCut", kTH2F, {axisNtracks, axisNtracksGlobal}); + // histos.add("nTracksGlobal_vs_nPV_QA_onlyVzCut_noTFROFborderCuts", "nTracksGlobal_vs_nPV_QA_onlyVzCut_noTFROFborderCuts", kTH2F, {axisNtracks, axisNtracksGlobal}); + // histos.add("nTracksGlobal_vs_nPV_QA_after_TFborderCut", "nTracksGlobal_vs_nPV_QA_after_TFborderCut", kTH2F, {axisNtracks, axisNtracksGlobal}); histos.add("nTracksGlobal_vs_nPV_occupByFT0C_0_2500", "nTracksGlobal_vs_nPV_occupByFT0C_0_2500", kTH2F, {axisNtracks, axisNtracksGlobal}); histos.add("nTracksGlobal_vs_nPV_occupByFT0C_0_20000", "nTracksGlobal_vs_nPV_occupByFT0C_0_20000", kTH2F, {axisNtracks, axisNtracksGlobal}); @@ -344,6 +494,7 @@ struct DetectorOccupancyQaTask { // 3D histograms: nGlobalTracks with cls567 as y-axis, V0A as x-axis: histos.add("nTracksGlobal_vs_V0A_vs_occup_pure", "", kTH3F, {axisMultV0A, axisNtracksGlobal, axisOccupancyTracks}); + histos.add("nTracksGlobal_vs_V0A_vs_occup_kNoCollInTimeRangeNarrow", "", kTH3F, {axisMultV0A, axisNtracksGlobal, axisOccupancyTracks}); histos.add("nTracksGlobal_vs_V0A_vs_occup_kNoCollInTimeRangeStandard_extraCuts", "", kTH3F, {axisMultV0A, axisNtracksGlobal, axisOccupancyTracks}); // FT0C as x-axis: histos.add("nTracksGlobal_vs_FT0C_vs_occup_pure", "", kTH3F, {axisMultFT0C, axisNtracksGlobal, axisOccupancyTracks}); @@ -351,6 +502,7 @@ struct DetectorOccupancyQaTask { // 3D histograms: now - nITStracks with cls567 as y-axis, V0A as x-axis: histos.add("nPV_vs_V0A_vs_occup_pure", "", kTH3F, {axisMultV0A, axisNtracks, axisOccupancyTracks}); + histos.add("nPV_vs_V0A_vs_occup_kNoCollInTimeRangeNarrow", "", kTH3F, {axisMultV0A, axisNtracks, axisOccupancyTracks}); histos.add("nPV_vs_V0A_vs_occup_kNoCollInTimeRangeStandard_extraCuts", "", kTH3F, {axisMultV0A, axisNtracks, axisOccupancyTracks}); // FT0C as x-axis: histos.add("nPV_vs_FT0C_vs_occup_pure", "", kTH3F, {axisMultFT0C, axisNtracks, axisOccupancyTracks}); @@ -390,6 +542,8 @@ struct DetectorOccupancyQaTask { std::vector vTracksGlobalPerCollPtEtaCuts(cols.size(), 0); // counter of tracks per found bc for occupancy studies std::vector vTracksITSTPCperColl(cols.size(), 0); // counter of tracks per found bc for occupancy studies std::vector vTracksITSTPCperCollPtEtaCuts(cols.size(), 0); // counter of tracks per found bc for occupancy studies + std::vector vTracksITSTOFperCollPtEtaCuts(cols.size(), 0); // counter of tracks per found bc for occupancy studies + std::vector vTracksITSTRDperCollPtEtaCuts(cols.size(), 0); // counter of tracks per found bc for occupancy studies std::vector vAmpFT0CperColl(cols.size(), 0); // amplitude FT0C per collision std::vector vTFids(cols.size(), 0); @@ -410,6 +564,8 @@ struct DetectorOccupancyQaTask { int nGlobalPtEtaCuts = 0; int nITSTPCtracks = 0; int nITSTPCtracksPtEtaCuts = 0; + int nITSTOFtracksPtEtaCuts = 0; + int nITSTRDtracksPtEtaCuts = 0; int nTOFtracks = 0; // int nTRDtracks = 0; auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); @@ -417,26 +573,26 @@ struct DetectorOccupancyQaTask { if (!track.isPVContributor()) { continue; } - if (track.itsNCls() >= 5) - nITS567cls++; + if (track.itsNCls() < 5) + continue; + nITS567cls++; nITSTPCtracks += track.hasITS() && track.hasTPC(); nTOFtracks += track.hasTOF(); - // nTRDtracks += track.hasTRD(); if (track.pt() < confCutPtMinThisEvent || track.pt() > confCutPtMaxThisEvent) continue; if (track.eta() < confCutEtaMinTracksThisEvent || track.eta() > confCutEtaMaxTracksThisEvent) continue; - if (track.itsNCls() >= 5) - nITS567clsPtEtaCuts++; + nITS567clsPtEtaCuts++; + nITSTOFtracksPtEtaCuts += track.hasITS() && track.hasTOF(); + nITSTRDtracksPtEtaCuts += track.hasITS() && track.hasTRD(); if (track.tpcNClsFound() < confCutMinTPCcls) continue; nITSTPCtracksPtEtaCuts += track.hasITS() && track.hasTPC(); - if (track.itsNCls() >= 5) - nGlobalPtEtaCuts += track.isGlobalTrack(); + nGlobalPtEtaCuts += track.isGlobalTrack(); } int32_t foundBC = bc.globalIndex(); @@ -450,12 +606,14 @@ struct DetectorOccupancyQaTask { vIsVertexTOFmatched[colIndex] = nTOFtracks > 0; - vTracksITS567perColl[colIndex] += nITS567cls; - vTracksITS567perCollPtEtaCuts[colIndex] += nITS567clsPtEtaCuts; - vTracksGlobalPerCollPtEtaCuts[colIndex] += nGlobalPtEtaCuts; + vTracksITS567perColl[colIndex] = nITS567cls; + vTracksITS567perCollPtEtaCuts[colIndex] = nITS567clsPtEtaCuts; + vTracksGlobalPerCollPtEtaCuts[colIndex] = nGlobalPtEtaCuts; - vTracksITSTPCperColl[colIndex] += nITSTPCtracks; - vTracksITSTPCperCollPtEtaCuts[colIndex] += nITSTPCtracksPtEtaCuts; + vTracksITSTPCperColl[colIndex] = nITSTPCtracks; + vTracksITSTPCperCollPtEtaCuts[colIndex] = nITSTPCtracksPtEtaCuts; + vTracksITSTOFperCollPtEtaCuts[colIndex] = nITSTOFtracksPtEtaCuts; + vTracksITSTRDperCollPtEtaCuts[colIndex] = nITSTRDtracksPtEtaCuts; // TF ids within a given cols table int tfId = (bc.globalBC() - bcSOR) / nBCsPerTF; @@ -550,11 +708,11 @@ struct DetectorOccupancyQaTask { continue; // skip if collision is close to TF border - if (confFlagApplyTFborderCut && !col.selection_bit(kNoTimeFrameBorder)) + if (!col.selection_bit(kNoTimeFrameBorder)) continue; // skip if collision is close to ROF border - if (confFlagApplyROFborderCut && !col.selection_bit(kNoITSROFrameBorder)) + if (!col.selection_bit(kNoITSROFrameBorder)) continue; std::vector vCollsAssocToGivenColl = vCollsInTimeWin[colIndex]; @@ -699,19 +857,19 @@ struct DetectorOccupancyQaTask { float integralNeighbourEvents = histos.get(HIST("thisEventITStracksInTimeBins"))->Integral(binMin, binMax); // recent past - if (integralFullDeltaTime < 150) // ~empty detector + if (integralFullDeltaTime < 200) // ~empty detector vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 1; // recent past - if (integralPast > /*3000*/ 2500 && (integralFullDeltaTime - integralPast) < 120) // low occupancy outside the dt region of interest + if (integralPast > /*3000*/ 2500 && (integralFullDeltaTime - integralPast) < 180) // low occupancy outside the dt region of interest vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 2; // close future - if (integralFuture1 > /*3000*/ 2500 && (integralFullDeltaTime - integralFuture1) < 120) + if (integralFuture1 > /*3000*/ 2500 && (integralFullDeltaTime - integralFuture1) < 180) vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 3; // distant future - if (integralFuture2 > /*3000*/ 2500 && (integralFullDeltaTime - integralFuture2) < 120) + if (integralFuture2 > /*3000*/ 2500 && (integralFullDeltaTime - integralFuture2) < 180) vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 4; // neighbour events - if (integralNeighbourEvents > /*3000*/ 2500 && (integralFullDeltaTime - integralNeighbourEvents) < 120) + if (integralNeighbourEvents > /*3000*/ 2500 && (integralFullDeltaTime - integralNeighbourEvents) < 180) vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 5; // loop over time axis in nD histograms: @@ -725,9 +883,10 @@ struct DetectorOccupancyQaTask { int nFT0CInTimeBin = histos.get(HIST("thisEventFT0CInTimeBins"))->GetBinContent(iT + 1); - histos.fill(HIST("occupancyInTimeBins_BEFORE_sel"), dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nITStrInTimeBin); - histos.fill(HIST("occupancyInTimeBins_occupByFT0_BEFORE_sel"), dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nFT0CInTimeBin); - + if (confFlagManyHeavyHistos) { + histos.fill(HIST("occupancyInTimeBins_BEFORE_sel"), dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nITStrInTimeBin); + histos.fill(HIST("occupancyInTimeBins_occupByFT0_BEFORE_sel"), dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nFT0CInTimeBin); + } bool flagFillOccupVsDt = true; if (confFlagUseNoCollInRofStrict && !col.selection_bit(kNoCollInRofStrict)) flagFillOccupVsDt = false; @@ -736,17 +895,24 @@ struct DetectorOccupancyQaTask { if (sel && std::fabs(col.posZ()) < 10 && flagFillOccupVsDt) { histos.fill(HIST("occupancyInTimeBins"), dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nITStrInTimeBin); - histos.fill(HIST("occupancyInTimeBins_occupByFT0"), dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nFT0CInTimeBin); + if (confFlagManyHeavyHistos) + histos.fill(HIST("occupancyInTimeBins_occupByFT0"), dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nFT0CInTimeBin); if (col.selection_bit(kNoCollInTimeRangeNarrow)) { - histos.fill(HIST("occupancyInTimeBins_occupByFT0_kNoCollInTimeRangeNarrow"), dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nFT0CInTimeBin); histos.fill(HIST("occupancyInTimeBins_vs_FT0thisCol_kNoCollInTimeRangeNarrow"), dt, vAmpFT0CperColl[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nITStrInTimeBin); - histos.fill(HIST("occupancyInTimeBins_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow"), dt, vAmpFT0CperColl[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nFT0CInTimeBin); - histos.fill(HIST("occupancyInTimeBins_nITS567_vs_FT0thisCol_kNoCollInTimeRangeNarrow"), dt, vAmpFT0CperColl[colIndex], vTracksITS567perCollPtEtaCuts[colIndex], nITStrInTimeBin); - histos.fill(HIST("occupancyInTimeBins_nITS567_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow"), dt, vAmpFT0CperColl[colIndex], vTracksITS567perCollPtEtaCuts[colIndex], nFT0CInTimeBin); - if (col.selection_bit(kNoCollInRofStrict)) - histos.fill(HIST("occupancyInTimeBins_nITS567_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow_NoCollInRofStrict"), dt, vAmpFT0CperColl[colIndex], vTracksITS567perCollPtEtaCuts[colIndex], nFT0CInTimeBin); + if (confFlagIsTOFIsTRDdtStudy) { + histos.fill(HIST("occupancyInTimeBins_nITSTOF_vs_FT0thisCol_kNoCollInTimeRangeNarrow"), dt, vAmpFT0CperColl[colIndex], vTracksITSTOFperCollPtEtaCuts[colIndex], nITStrInTimeBin); + histos.fill(HIST("occupancyInTimeBins_nITSTRD_vs_FT0thisCol_kNoCollInTimeRangeNarrow"), dt, vAmpFT0CperColl[colIndex], vTracksITSTRDperCollPtEtaCuts[colIndex], nITStrInTimeBin); + } + if (confFlagManyHeavyHistos) { + histos.fill(HIST("occupancyInTimeBins_occupByFT0_kNoCollInTimeRangeNarrow"), dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nFT0CInTimeBin); + histos.fill(HIST("occupancyInTimeBins_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow"), dt, vAmpFT0CperColl[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nFT0CInTimeBin); + + histos.fill(HIST("occupancyInTimeBins_nITS567_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow"), dt, vAmpFT0CperColl[colIndex], vTracksITS567perCollPtEtaCuts[colIndex], nFT0CInTimeBin); + if (col.selection_bit(kNoCollInRofStrict)) + histos.fill(HIST("occupancyInTimeBins_nITS567_vs_FT0thisCol_occupByFT0_kNoCollInTimeRangeNarrow_NoCollInRofStrict"), dt, vAmpFT0CperColl[colIndex], vTracksITS567perCollPtEtaCuts[colIndex], nFT0CInTimeBin); + } } } @@ -775,24 +941,27 @@ struct DetectorOccupancyQaTask { // ### occupancy event selection QA for (const auto& col : cols) { - // if (!col.sel8()) { - // continue; - // } - if (!col.selection_bit(kIsTriggerTVX)) + if (!col.sel8()) continue; + + // if (!col.selection_bit(kIsTriggerTVX)) + // continue; + // cut on vZ for a given collision if (col.posZ() < confCutVertZMinThisEvent || col.posZ() > confCutVertZMaxThisEvent) continue; int32_t colIndex = col.globalIndex(); int64_t bcInTF = (vFoundGlobalBC[colIndex] - bcSOR) % nBCsPerTF; - histos.fill(HIST("hNcolVsBcInTF"), bcInTF); + histos.fill(HIST("hNcolVsBcInTF/hNcolVsBcInTF"), bcInTF); + if (col.selection_bit(kIsVertexTOFmatched)) + histos.fill(HIST("hNcolVsBcInTF/hNcolVsBcInTF_vertexTOFmatched"), bcInTF); // cut on the max bcId in the time frame (to avoid the artificial fade-out tail in the MC productions) if (!vIsMarkedCollForAnalysis[colIndex]) continue; - histos.fill(HIST("hNcolVsBcInTFafterMaxBcCut"), bcInTF); + histos.fill(HIST("hNcolVsBcInTF/hNcolVsBcInTFafterMaxBcCut"), bcInTF); auto multV0A = col.multFV0A(); // auto multT0A = col.multFT0A(); @@ -801,8 +970,9 @@ struct DetectorOccupancyQaTask { int nGlobalTracks = 0; int occupancy = col.trackOccupancyInTimeRange(); - auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); + + // pre-calc nPV for (const auto& track : tracksGrouped) { if (!track.isPVContributor()) continue; @@ -813,11 +983,82 @@ struct DetectorOccupancyQaTask { if (track.itsNCls() < 5) continue; nPV++; + } + if (occupancy >= 0) { + histos.fill(HIST("hNcolVsBcInTF/hNcolVsBcInTF_vs_occupancy"), bcInTF, occupancy); + if (col.selection_bit(kIsVertexTOFmatched)) + histos.fill(HIST("hNcolVsBcInTF/hNcolVsBcInTF_vs_occupancy_vertexTOFmatched"), bcInTF, occupancy); + if (nPV >= 10 && nPV < 200) + histos.fill(HIST("hNcolVsBcInTF/hNcolVsBcInTF_vs_occupancy_nPV_10_200"), bcInTF, occupancy); + else if (nPV >= 2000) + histos.fill(HIST("hNcolVsBcInTF/hNcolVsBcInTF_vs_occupancy_nPV_above2000"), bcInTF, occupancy); + } + + // main loop for dE/dx + for (const auto& track : tracksGrouped) { + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 0); + if (!track.isPVContributor()) + continue; + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 1); + if (track.pt() < confCutPtMinThisEvent || track.pt() > confCutPtMaxThisEvent) + continue; + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 2); + if (track.eta() < confCutEtaMinTracksThisEvent || track.eta() > confCutEtaMaxTracksThisEvent) + continue; + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 3); + if (track.itsNCls() < 5) + continue; + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 4); + // nPV++; + + // July 2025: more for data vs MC: + if (track.hasTPC() && occupancy >= 0) { + float pt = track.pt(); + // pt 0.2-0.5 + if (pt > 0.2 && pt < 0.5) { + if (nPV >= 10 && nPV < 400) { + histos.fill(HIST("QA_noTPCcuts/nPV_10_200/tpcNClsFindable_vs_occup_pt_02_05"), track.tpcNClsFindable(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_10_200/tpcNClsFound_vs_occup_pt_02_05"), track.tpcNClsFound(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_10_200/tpcChi2NCl_vs_occup_pt_02_05"), track.tpcChi2NCl(), occupancy); + } else if (nPV >= 2000) { + histos.fill(HIST("QA_noTPCcuts/nPV_above2000/tpcNClsFindable_vs_occup_pt_02_05"), track.tpcNClsFindable(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_above2000/tpcNClsFound_vs_occup_pt_02_05"), track.tpcNClsFound(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_above2000/tpcChi2NCl_vs_occup_pt_02_05"), track.tpcChi2NCl(), occupancy); + } + } + // pt 0.5-1.0 + else if (pt > 0.5 && pt < 1.0) { + if (nPV >= 10 && nPV < 400) { + histos.fill(HIST("QA_noTPCcuts/nPV_10_200/tpcNClsFindable_vs_occup_pt_05_10"), track.tpcNClsFindable(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_10_200/tpcNClsFound_vs_occup_pt_05_10"), track.tpcNClsFound(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_10_200/tpcChi2NCl_vs_occup_pt_05_10"), track.tpcChi2NCl(), occupancy); + } else if (nPV >= 2000) { + histos.fill(HIST("QA_noTPCcuts/nPV_above2000/tpcNClsFindable_vs_occup_pt_05_10"), track.tpcNClsFindable(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_above2000/tpcNClsFound_vs_occup_pt_05_10"), track.tpcNClsFound(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_above2000/tpcChi2NCl_vs_occup_pt_05_10"), track.tpcChi2NCl(), occupancy); + } + } + // pt > 1.0 + else if (pt > 1.0) { + if (nPV >= 10 && nPV < 400) { + histos.fill(HIST("QA_noTPCcuts/nPV_10_200/tpcNClsFindable_vs_occup_pt_above1_0"), track.tpcNClsFindable(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_10_200/tpcNClsFound_vs_occup_pt_above1_0"), track.tpcNClsFound(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_10_200/tpcChi2NCl_vs_occup_pt_above1_0"), track.tpcChi2NCl(), occupancy); + } else if (nPV >= 2000) { + histos.fill(HIST("QA_noTPCcuts/nPV_above2000/tpcNClsFindable_vs_occup_pt_above1_0"), track.tpcNClsFindable(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_above2000/tpcNClsFound_vs_occup_pt_above1_0"), track.tpcNClsFound(), occupancy); + histos.fill(HIST("QA_noTPCcuts/nPV_above2000/tpcChi2NCl_vs_occup_pt_above1_0"), track.tpcChi2NCl(), occupancy); + } + } + } if (track.isGlobalTrack() && track.tpcNClsFound() >= confCutMinTPCcls) { nGlobalTracks++; + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 5); if (track.passedTPCRefit()) { + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 6); + float signedP = track.sign() * track.tpcInnerParam(); histos.fill(HIST("dEdx_vs_Momentum"), signedP, track.tpcSignal()); if (occupancy >= 0 && occupancy < 200) { @@ -829,34 +1070,125 @@ struct DetectorOccupancyQaTask { histos.fill(HIST("dEdx_vs_Momentum_occupAbove4000"), signedP, track.tpcSignal()); if (occupancy >= 0) { + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 7); + histos.fill(HIST("dEdx_vs_Momentum_vs_occup"), signedP, track.tpcSignal(), occupancy); - if (track.eta() > 0.2 && track.eta() < 0.4) - histos.fill(HIST("dEdx_vs_Momentum_vs_occup_eta_02_04"), signedP, track.tpcSignal(), occupancy); - if (track.eta() > -0.4 && track.eta() < -0.2) - histos.fill(HIST("dEdx_vs_Momentum_vs_occup_eta_04_02"), signedP, track.tpcSignal(), occupancy); + if (confFlagManyHeavyHistos) { + if (track.eta() > 0.2 && track.eta() < 0.4) + histos.fill(HIST("dEdx_vs_Momentum_vs_occup_eta_02_04"), signedP, track.tpcSignal(), occupancy); + if (track.eta() > -0.4 && track.eta() < -0.2) + histos.fill(HIST("dEdx_vs_Momentum_vs_occup_eta_04_02"), signedP, track.tpcSignal(), occupancy); + } + // more QA for TPC cls counting + histos.fill(HIST("tpcNClsFindable"), track.tpcNClsFindable()); + histos.fill(HIST("tpcNClsFindableMinusFound"), track.tpcNClsFindableMinusFound()); + histos.fill(HIST("tpcNClsFindableMinusCrossedRows"), track.tpcNClsFindableMinusCrossedRows()); + histos.fill(HIST("tpcNClsShared"), track.tpcNClsShared()); + histos.fill(HIST("tpcNClsFindableMinusPID"), track.tpcNClsFindableMinusPID()); + int tpcNClUsedForPID = track.tpcNClsFindable() - track.tpcNClsFindableMinusPID(); + histos.fill(HIST("tpcNClUsedForPID"), tpcNClUsedForPID); + + histos.fill(HIST("tpcNClsFound"), track.tpcNClsFound()); + histos.fill(HIST("tpcNClsFoundAsDiffByHand"), track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()); + + histos.fill(HIST("tpcNClsUsedForPID_vs_Findable"), track.tpcNClsFindable(), tpcNClUsedForPID); + histos.fill(HIST("tpcNClsShared_vs_Findable"), track.tpcNClsFindable(), track.tpcNClsShared()); + histos.fill(HIST("tpcNClsUsedForPID_vs_Shared"), track.tpcNClsShared(), tpcNClUsedForPID); + histos.fill(HIST("tpcNClsFound_vs_Findable"), track.tpcNClsFindable(), track.tpcNClsFound()); + histos.fill(HIST("tpcNClsUsedForPID_vs_Found"), track.tpcNClsFound(), tpcNClUsedForPID); + + int tpcNClsCorrectedFindableMinusPID = track.tpcNClsFindableMinusPID(); + // correct for a buggy behaviour due to int8 and uint8 difference: + if (tpcNClsCorrectedFindableMinusPID < -70) + tpcNClsCorrectedFindableMinusPID += 256; + histos.fill(HIST("tpcNClsFindableMinusPID_CORRECTED"), tpcNClsCorrectedFindableMinusPID); + histos.fill(HIST("tpcNClsUsedForPID_vs_Findable_CORRECTED"), track.tpcNClsFindable(), track.tpcNClsFindable() - tpcNClsCorrectedFindableMinusPID); + + histos.fill(HIST("tpcNClsFoundMinusPID_BY_HAND"), (track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()) - (track.tpcNClsFindable() - tpcNClsCorrectedFindableMinusPID)); + + // check ratio tpcNClsFindableMinusPID / tpcNClsFindable + // https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L242 + // https://github.com/AliceO2Group/AliceO2/blob/dev/Detectors/AOD/src/AODProducerWorkflowSpec.cxx#L2553C21-L2553C44 + float fractionTPCcls = (1.0 * tpcNClsCorrectedFindableMinusPID) / track.tpcNClsFindable(); + histos.fill(HIST("fraction_tpcNClsFindableMinusPID_vs_occup"), occupancy, fractionTPCcls); + if (fractionTPCcls >= 0 && fractionTPCcls < 0.8) + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 8); + if (fractionTPCcls < 0) + histos.fill(HIST("dEdx_vs_Momentum_HighFractionNclsNonPID"), signedP, track.tpcSignal()); + if (fractionTPCcls > 0.8) + histos.fill(HIST("dEdx_vs_Momentum_NegativeFractionNclsPID"), signedP, track.tpcSignal()); + + if (multV0A < 6800) + histos.fill(HIST("fraction_tpcNClsFindableMinusPID_vs_occup_peripheralByV0A"), occupancy, fractionTPCcls); + else if (multV0A > 82850) + histos.fill(HIST("fraction_tpcNClsFindableMinusPID_vs_occup_centralByV0A"), occupancy, fractionTPCcls); + + if (std::fabs(track.eta()) < 0.2) + histos.fill(HIST("fraction_tpcNClsFindableMinusPID_vs_occup_eta02"), occupancy, fractionTPCcls); + + // vs charge + if (signedP > 0) { + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 9); + histos.fill(HIST("fraction_tpcNClsFindableMinusPID_vs_occup_pos"), occupancy, fractionTPCcls); + } else { + histos.fill(HIST("nTrackCounter_after_cuts_QA"), 10); + histos.fill(HIST("fraction_tpcNClsFindableMinusPID_vs_occup_neg"), occupancy, fractionTPCcls); + } + // vs pt + if (track.pt() > 0.2 && track.pt() < 0.8) + histos.fill(HIST("fraction_tpcNClsFindableMinusPID_vs_occup_lowPt"), occupancy, fractionTPCcls); + if (track.pt() > 0.8 && track.pt() < 10) + histos.fill(HIST("fraction_tpcNClsFindableMinusPID_vs_occup_highPt"), occupancy, fractionTPCcls); // dE/dx in narrow mom bin vs centrality and occupancy - if (signedP > 0.38 && signedP < 0.4) + if (std::fabs(signedP) > 0.38 && std::fabs(signedP) < 0.4) histos.fill(HIST("dEdx_vs_centr_vs_occup_narrow_p_win"), nPV, occupancy, track.tpcSignal()); + // vs charge + if (signedP > 0.38 && signedP < 0.4) { + histos.fill(HIST("dEdx_vs_centr_vs_occup_narrow_p_win_pos"), nPV, occupancy, track.tpcSignal()); + if (fractionTPCcls >= 0 && fractionTPCcls < 0.8) + histos.fill(HIST("dEdx_vs_centr_vs_occup_narrow_p_win_pos_FractionPIDclsInRange"), nPV, occupancy, track.tpcSignal()); + } else if (signedP > -0.4 && signedP < -0.38) { + histos.fill(HIST("dEdx_vs_centr_vs_occup_narrow_p_win_neg"), nPV, occupancy, track.tpcSignal()); + if (fractionTPCcls >= 0 && fractionTPCcls < 0.8) + histos.fill(HIST("dEdx_vs_centr_vs_occup_narrow_p_win_neg_FractionPIDclsInRange"), nPV, occupancy, track.tpcSignal()); + } + + // nTPCcls vs nITStr vs occup + histos.fill(HIST("tpcNClsFound_vs_centr_vs_occup"), nPV, occupancy, track.tpcNClsFound()); + histos.fill(HIST("tpcNClsFindable_vs_centr_vs_occup"), nPV, occupancy, track.tpcNClsFindable()); + histos.fill(HIST("tpcNClsShared_vs_centr_vs_occup"), nPV, occupancy, track.tpcNClsShared()); + + // nTPCsharedCls for A and C separately + if (track.tgl() > 0.) // A side + histos.fill(HIST("tpcNClsShared_vs_centr_vs_occup_Aside"), nPV, occupancy, track.tpcNClsShared()); + else // C side + histos.fill(HIST("tpcNClsShared_vs_centr_vs_occup_Cside"), nPV, occupancy, track.tpcNClsShared()); + + // nTPCsharedCls for pos and neg + if (signedP > 0) + histos.fill(HIST("tpcNClsShared_vs_centr_vs_occup_pos"), nPV, occupancy, track.tpcNClsShared()); + else + histos.fill(HIST("tpcNClsShared_vs_centr_vs_occup_neg"), nPV, occupancy, track.tpcNClsShared()); } } } - } + } // end of track loop - if (confAddTracksVsFwdHistos) - histos.fill(HIST("nTracksGlobal_vs_nPV_QA_onlyVzCut_noTFROFborderCuts"), nPV, nGlobalTracks); + // if (confAddTracksVsFwdHistos) + // histos.fill(HIST("nTracksGlobal_vs_nPV_QA_onlyVzCut_noTFROFborderCuts"), nPV, nGlobalTracks); // skip if collision is close to TF border - if (confFlagApplyTFborderCut && !col.selection_bit(kNoTimeFrameBorder)) - continue; + // if (confFlagApplyTFborderCut && !col.selection_bit(kNoTimeFrameBorder)) + // continue; - if (confAddTracksVsFwdHistos) - histos.fill(HIST("nTracksGlobal_vs_nPV_QA_after_TFborderCut"), nPV, nGlobalTracks); + // if (confAddTracksVsFwdHistos) + // histos.fill(HIST("nTracksGlobal_vs_nPV_QA_after_TFborderCut"), nPV, nGlobalTracks); // skip if collision is close to ROF border - if (confFlagApplyROFborderCut && !col.selection_bit(kNoITSROFrameBorder)) - continue; + // if (confFlagApplyROFborderCut && !col.selection_bit(kNoITSROFrameBorder)) + // continue; histos.fill(HIST("hOccupancy"), occupancy); if (occupancy >= 0) { @@ -867,7 +1199,7 @@ struct DetectorOccupancyQaTask { // another track loop to fill track-level histograms if (confAddBasicQAhistos) { int flagWhichDeltaTimeWin = vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex]; - bool flagNoCollNearby = col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard); + bool flagNoCollNearby = col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow); if (occupancy >= 0) { if (nPV >= 10 && nPV < 200) { @@ -889,81 +1221,162 @@ struct DetectorOccupancyQaTask { continue; if (track.itsNCls() < 5) continue; - if (!(track.isGlobalTrack() && track.tpcNClsFound() >= confCutMinTPCcls)) - continue; + // if (!(track.isGlobalTrack() && track.tpcNClsFound() >= confCutMinTPCcls)) + // continue; + + bool isGoodGlobal = (track.isGlobalTrack() && track.tpcNClsFound() >= confCutMinTPCcls); + bool hasTPCspecCuts = (track.hasTPC() && track.tpcNClsFound() >= confCutMinTPCcls && track.tpcNClsCrossedRows() > 80 && track.tpcChi2NCl() < 4); + + // ### kine distr vs centr vs occup + float sign = track.sign(); + float pt = track.pt(); + float eta = track.eta(); + float phi = track.phi(); + float phiInitial = phi; + + if (confUsePhiAtTPCinnerR) { + phi -= asin(0.8 /*inner TPC radius*/ / 2 * 0.3 * sign * 0.5 / pt); + if (phi < 0) + phi += TMath::TwoPi(); + else if (phi > TMath::TwoPi()) + phi -= TMath::TwoPi(); + } - // pt vs centr vs occup - if (occupancy >= 0) { - histos.fill(HIST("ptGlobal_vs_centr_vs_occup"), nPV, occupancy, track.pt()); - histos.fill(HIST("ptPV_vs_centr_vs_occup"), nPV, occupancy, track.pt()); - if (col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - histos.fill(HIST("ptGlobal_vs_centr_vs_occup_NoCollStd"), nPV, occupancy, track.pt()); - histos.fill(HIST("ptPV_vs_centr_vs_occup_NoCollStd"), nPV, occupancy, track.pt()); - } + bool etaInRange = true; + if (confUseAorCsideForPhiStudy == 0 && eta < 0.1) // check if we are in A side + etaInRange = false; + if (confUseAorCsideForPhiStudy == 1 && eta > -0.1) // check if we are in C side + etaInRange = false; + if (occupancy >= 0 && fabs(eta) < 0.8 && pt > 0.15 && etaInRange) { if (nPV >= 10 && nPV < 200) { - if (flagWhichDeltaTimeWin == 1 && flagNoCollNearby) { - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_lowOccupInTPC"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_lowOccupInTPC"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_lowOccupInTPC"), track.pt()); - } - if (flagWhichDeltaTimeWin == 2 && flagNoCollNearby) { - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_highOccupInRecentPast"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_highOccupInRecentPast"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_highOccupInRecentPast"), track.pt()); - } - if (flagWhichDeltaTimeWin == 3 && flagNoCollNearby) { - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_highOccupInCloseFuture"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_highOccupInCloseFuture"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_highOccupInCloseFuture"), track.pt()); - } - if (flagWhichDeltaTimeWin == 4 && flagNoCollNearby) { - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_highOccupInDistantFuture"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_highOccupInDistantFuture"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_highOccupInDistantFuture"), track.pt()); - } - if (flagWhichDeltaTimeWin == 5) { - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_highOccupInNeighbourEvents"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_highOccupInNeighbourEvents"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_highOccupInNeighbourEvents"), track.pt()); + if (isGoodGlobal) { + if (flagWhichDeltaTimeWin == 1 && flagNoCollNearby) { + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_lowOccupInTPC"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_lowOccupInTPC"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_lowOccupInTPC"), pt); + } + if (flagWhichDeltaTimeWin == 2 && flagNoCollNearby) { + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_highOccupInRecentPast"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_highOccupInRecentPast"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_highOccupInRecentPast"), pt); + } + if (flagWhichDeltaTimeWin == 3 && flagNoCollNearby) { + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_highOccupInCloseFuture"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_highOccupInCloseFuture"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_highOccupInCloseFuture"), pt); + } + if (flagWhichDeltaTimeWin == 4 && flagNoCollNearby) { + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_highOccupInDistantFuture"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_highOccupInDistantFuture"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_highOccupInDistantFuture"), pt); + } + if (flagWhichDeltaTimeWin == 5) { + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEta_highOccupInNeighbourEvents"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPhi_highOccupInNeighbourEvents"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_highOccupInNeighbourEvents"), pt); + } + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hPt_vs_tpcInnerPt_vs_occup"), pt, track.tpcInnerParam(), occupancy); + } // end of TPC good global + + // July 2025: for data vs MC kine distr comparison + if (sign > 0) // positive tracks + { + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hPt_pos"), pt, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hEta_pos"), eta, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hPhi_pos"), phi, occupancy, pt); + if (hasTPCspecCuts) { + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hPt_pos"), pt, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hEta_pos"), eta, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hPhi_pos"), phi, occupancy, pt); + } + } else // negative tracks + { + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hPt_neg"), pt, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hEta_neg"), eta, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/PV_hPhi_neg"), phi, occupancy, pt); + if (hasTPCspecCuts) { + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hPt_neg"), pt, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hEta_neg"), eta, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_10_200/kine_vs_weighted_occup/hPhi_neg"), phi, occupancy, pt); + } } + // end of July 2025: for data vs MC kine distr comparison + } else if (nPV >= 2000) { - if (flagWhichDeltaTimeWin == 1 && flagNoCollNearby) { - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_lowOccupInTPC"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_lowOccupInTPC"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_lowOccupInTPC"), track.pt()); - } - if (flagWhichDeltaTimeWin == 2 && flagNoCollNearby) { - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_highOccupInRecentPast"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInRecentPast"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_highOccupInRecentPast"), track.pt()); - } - if (flagWhichDeltaTimeWin == 3 && flagNoCollNearby) { - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_highOccupInCloseFuture"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInCloseFuture"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_highOccupInCloseFuture"), track.pt()); + if (isGoodGlobal) { + if (flagWhichDeltaTimeWin == 1 && flagNoCollNearby) { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_lowOccupInTPC"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_lowOccupInTPC"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_lowOccupInTPC"), pt); + } + if (flagWhichDeltaTimeWin == 2 && flagNoCollNearby) { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_highOccupInRecentPast"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInRecentPast"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_highOccupInRecentPast"), pt); + } + if (flagWhichDeltaTimeWin == 3 && flagNoCollNearby) { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_highOccupInCloseFuture"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInCloseFuture"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_highOccupInCloseFuture"), pt); + } + if (flagWhichDeltaTimeWin == 4 && flagNoCollNearby) { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_highOccupInDistantFuture"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInDistantFuture"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_highOccupInDistantFuture"), pt); + } + if (flagWhichDeltaTimeWin == 5) { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_highOccupInNeighbourEvents"), eta); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInNeighbourEvents"), phi); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_highOccupInNeighbourEvents"), pt); + } + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_vs_tpcInnerPt_vs_occup"), pt, track.tpcInnerParam(), occupancy); + } // end of TPC good global + + // July 2025: for data vs MC kine distr comparison + if (sign > 0) // positive tracks + { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hPt_pos"), pt, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hEta_pos"), eta, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hPhi_pos"), phi, occupancy, pt); + if (hasTPCspecCuts) { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPt_pos"), pt, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hEta_pos"), eta, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_pos"), phi, occupancy, pt); + if (pt > 0.7 && pt < 1.0) { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_posInitialQA"), phiInitial); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_posModifiedQA"), phi); + } + } + } else // negative tracks + { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hPt_neg"), pt, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hEta_neg"), eta, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/PV_hPhi_neg"), phi, occupancy, pt); + if (hasTPCspecCuts) { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPt_neg"), pt, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hEta_neg"), eta, occupancy); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_neg"), phi, occupancy, pt); + if (pt > 0.7 && pt < 1.0) { + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_negInitialQA"), phiInitial); + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/kine_vs_weighted_occup/hPhi_negModifiedQA"), phi); + } + } } - if (flagWhichDeltaTimeWin == 4 && flagNoCollNearby) { - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_highOccupInDistantFuture"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInDistantFuture"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_highOccupInDistantFuture"), track.pt()); - } - if (flagWhichDeltaTimeWin == 5) { - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEta_highOccupInNeighbourEvents"), track.eta()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInNeighbourEvents"), track.phi()); - histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hPt_highOccupInNeighbourEvents"), track.pt()); - } - } - } // end of if (occupancy >= 0) - } - } // end of spec track loop to fill track histograms + // end of July 2025: for data vs MC kine distr comparison + } // end of if (nPV >= 2000) + } // end of if (occupancy >= 0) && kine cuts + } // end of spec track loop to fill track histograms + } // end of if (confAddBasicQAhistos) // occupancy vs centrality - auto t0cCentr = col.centFT0C(); - if (occupancy >= 0) { - histos.fill(HIST("hCentrVsOccupancy"), t0cCentr, occupancy); - if (col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) - histos.fill(HIST("hCentrVsOccupancyNoCollStd"), t0cCentr, occupancy); + if (confFlagCentralityIsAvailable) { + auto t0cCentr = col.centFT0C(); + if (occupancy >= 0) { + histos.fill(HIST("hCentrVsOccupancy"), t0cCentr, occupancy); + if (col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) + histos.fill(HIST("hCentrVsOccupancyNoCollStd"), t0cCentr, occupancy); + } } if (!confAddTracksVsFwdHistos) { @@ -1003,8 +1416,11 @@ struct DetectorOccupancyQaTask { histos.fill(HIST("nTracksPV_vs_V0A_kNoCollInTimeRangeNarrow"), multV0A, nPV); histos.fill(HIST("nTracksGlobal_vs_V0A_kNoCollInTimeRangeNarrow"), multV0A, nGlobalTracks); histos.fill(HIST("nTracksGlobal_vs_nPV_kNoCollInTimeRangeNarrow"), nPV, nGlobalTracks); - if (occupancy >= 0) + if (occupancy >= 0) { histos.fill(HIST("nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeNarrow"), nPV, nGlobalTracks, occupancy); + histos.fill(HIST("nTracksGlobal_vs_V0A_vs_occup_kNoCollInTimeRangeNarrow"), multV0A, nGlobalTracks, occupancy); + histos.fill(HIST("nPV_vs_V0A_vs_occup_kNoCollInTimeRangeNarrow"), multV0A, nPV, occupancy); + } } if (occupancy >= 0 && occupancy < 250) { histos.fill(HIST("nTracksPV_vs_V0A_occup_0_250"), multV0A, nPV); diff --git a/DPG/Tasks/AOTEvent/eventSelectionQa.cxx b/DPG/Tasks/AOTEvent/eventSelectionQa.cxx index de37d37c00b..e890b9fbab9 100644 --- a/DPG/Tasks/AOTEvent/eventSelectionQa.cxx +++ b/DPG/Tasks/AOTEvent/eventSelectionQa.cxx @@ -12,7 +12,7 @@ /// \file eventSelectionQa.cxx /// \brief Event selection QA task /// -/// \author Evgeny Kryshen +/// \author Evgeny Kryshen and Igor Altsybeev #include #include @@ -32,6 +32,9 @@ #include "DataFormatsParameters/AggregatedRunInfo.h" #include "DataFormatsITSMFT/NoiseMap.h" // missing include in TimeDeadMap.h #include "DataFormatsITSMFT/TimeDeadMap.h" +#include "DataFormatsITSMFT/ROFRecord.h" +#include "ReconstructionDataFormats/Vertex.h" +#include "ITSMFTBase/DPLAlpideParam.h" #include "ITSMFTReconstruction/ChipMappingITS.h" #include "TH1F.h" #include "TH2F.h" @@ -61,6 +64,8 @@ struct EventSelectionQaTask { int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 for unanchored MC int32_t nOrbitsPerTF = 128; // 128 in 2022, 32 in 2023, setting 128 for unanchored MC int64_t nBCsPerTF = nOrbitsPerTF * nBCsPerOrbit; // duration of TF in bcs + int rofOffset = -1; // ITS ROF offset, in bc + int rofLength = -1; // ITS ROF length, in bc std::bitset bcPatternA; std::bitset bcPatternC; @@ -282,17 +287,22 @@ struct EventSelectionQaTask { histos.add("hNcontribAccTRD", "", kTH1F, {axisNcontrib}); histos.add("hNcontribMisTOF", "", kTH1F, {axisNcontrib}); - histos.add("hMultT0MVsNcontribAcc", "", kTH2F, {axisMultT0M, axisNcontrib}); // before ITS RO Frame border cut - histos.add("hMultT0MVsNcontribCut", "", kTH2F, {axisMultT0M, axisNcontrib}); // after ITS RO Frame border cut + histos.add("hMultT0MVsNcontribTVX", "", kTH2F, {axisMultT0M, axisNcontrib}); // before ITS RO Frame border cut + histos.add("hMultT0MVsNcontribTVXTFcuts", "", kTH2F, {axisMultT0M, axisNcontrib}); // before ITS RO Frame border cut + histos.add("hMultT0MVsNcontribTVXROFcuts", "", kTH2F, {axisMultT0M, axisNcontrib}); // after ITS RO Frame border cut + histos.add("hMultT0MVsNcontribTVXTFROFcuts", "", kTH2F, {axisMultT0M, axisNcontrib}); // after ITS RO Frame border cut + // histos.add("hMultT0MVsNcontribAcc", "", kTH2F, {axisMultT0M, axisNcontrib}); // before ITS RO Frame border cut - histos.add("hMultV0AVsNcontribAcc", "", kTH2F, {axisMultV0A, axisNcontrib}); // before ITS RO Frame border cut - histos.add("hMultV0AVsNcontribCut", "", kTH2F, {axisMultV0A, axisNcontrib}); // after ITS RO Frame border cut - histos.add("hMultV0AVsNcontribAfterVertex", "", kTH2F, {axisMultV0A, axisNcontrib}); // after good vertex cut - histos.add("hMultV0AVsNcontribGood", "", kTH2F, {axisMultV0A, axisNcontrib}); // after pileup check + histos.add("hMultV0AVsNcontribTVX", "", kTH2F, {axisMultV0A, axisNcontrib}); // before ITS RO Frame border cut + histos.add("hMultV0AVsNcontribTVXTFcuts", "", kTH2F, {axisMultV0A, axisNcontrib}); // before ITS RO Frame border cut + histos.add("hMultV0AVsNcontribTVXROFcuts", "", kTH2F, {axisMultV0A, axisNcontrib}); // before ITS RO Frame border cut + histos.add("hMultV0AVsNcontribTVXTFROFcuts", "", kTH2F, {axisMultV0A, axisNcontrib}); // after ITS RO Frame border cut + histos.add("hMultV0AVsNcontribIsVertexITSTPC", "", kTH2F, {axisMultV0A, axisNcontrib}); // after good vertex cut + histos.add("hMultV0AVsNcontribGood", "", kTH2F, {axisMultV0A, axisNcontrib}); // after pileup check - histos.add("hBcForMultV0AVsNcontribAcc", "", kTH1F, {axisBCs}); // bc distribution for V0A-vs-Ncontrib accepted - histos.add("hBcForMultV0AVsNcontribOutliers", "", kTH1F, {axisBCs}); // bc distribution for V0A-vs-Ncontrib outliers - histos.add("hBcForMultV0AVsNcontribCut", "", kTH1F, {axisBCs}); // bc distribution for V0A-vs-Ncontrib after ITS-ROF border cut + // histos.add("hFoundBcForMultV0AVsNcontribAcc", "", kTH1F, {axisBCs}); // bc distribution for V0A-vs-Ncontrib accepted + histos.add("hFoundBcForMultV0AVsNcontribOutliers", "", kTH1F, {axisBCs}); // bc distribution for V0A-vs-Ncontrib outliers + histos.add("hFoundBcAfterROFborderCut", "", kTH1F, {axisBCs}); // bc distribution for V0A-vs-Ncontrib after ITS-ROF border cut histos.add("hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); // FT0-vertex vs z-vertex from collisions histos.add("hVtxFT0MinusVtxCol", "", kTH1F, {axisVtxZ}); // FT0-vertex minus z-vertex from collisions @@ -324,6 +334,50 @@ struct EventSelectionQaTask { histos.get(HIST("hColCounterAcc"))->GetXaxis()->SetBinLabel(i + 1, aliasLabels[i].data()); histos.get(HIST("hBcCounterAll"))->GetXaxis()->SetBinLabel(i + 1, aliasLabels[i].data()); } + + // ROF border QA + histos.add("ITSROFborderQA/hFoundBC_kTVX_counter_ITSTPCtracks", "", kTH1D, {axisBCs}); + histos.add("ITSROFborderQA/hFoundBC_kTVX_nITSlayers_for_ITSTPCtracks", "", kTH1D, {axisBCs}); + + // occupancy QA + if (!isLowFlux) { + histos.add("occupancyQA/hOccupancyByTracks", "", kTH1D, {{15002, -1.5, 15000.5}}); + histos.add("occupancyQA/hOccupancyByFT0C", "", kTH1D, {{15002, -20, 150000}}); + histos.add("occupancyQA/hOccupancyByFT0CvsByTracks", "", kTH2D, {{150, 0, 15000}, {150, 0, 150000}}); + + // 3D histograms: nGlobalTracks with cls567 as y-axis, V0A as x-axis: + const AxisSpec axisNtracksPV{200, -0.5, 5000 - 0.5, "n ITS PV tracks"}; + const AxisSpec axisNtracksPVTPC{160, -0.5, 4000 - 0.5, "n ITS-TPC PV tracks"}; + const AxisSpec axisNtracksTPConly{160, -0.5, 8000 - 0.5, "n TPC-only tracks"}; + const AxisSpec axisMultV0AForOccup{20, 0., static_cast(200000), "mult V0A"}; + const AxisSpec axisOccupancyTracks{150, 0., 15000, "occupancy (n ITS tracks weighted)"}; + histos.add("occupancyQA/hNumTracksPV_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNtracksPV, axisOccupancyTracks}); + histos.add("occupancyQA/hNumTracksPVTPC_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNtracksPVTPC, axisOccupancyTracks}); + histos.add("occupancyQA/hNumTracksPVTPCLooseCuts_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNtracksPVTPC, axisOccupancyTracks}); + histos.add("occupancyQA/hNumTracksITS_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNtracksPV, axisOccupancyTracks}); + histos.add("occupancyQA/hNumTracksITSTPC_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNtracksPVTPC, axisOccupancyTracks}); + histos.add("occupancyQA/hNumTracksPV_vs_V0A_vs_occupancy_NarrowDeltaTimeCut", "", kTH3F, {axisMultV0AForOccup, axisNtracksPV, axisOccupancyTracks}); + histos.add("occupancyQA/hNumTracksPVTPC_vs_V0A_vs_occupancy_NarrowDeltaTimeCut", "", kTH3F, {axisMultV0AForOccup, axisNtracksPVTPC, axisOccupancyTracks}); + // requested by TPC experts: nTPConly tracks vs occupancy + histos.add("occupancyQA/hNumTracksTPConly_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNtracksTPConly, axisOccupancyTracks}); + histos.add("occupancyQA/hNumTracksTPConlyNoITS_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNtracksTPConly, axisOccupancyTracks}); + // request from experts to add track properties vs occupancy, to compare data vs MC + const AxisSpec axisOccupancyForTrackQA{60, 0., 15000, "occupancy (n ITS tracks weighted)"}; + const AxisSpec axisNTPCcls{150, 0, 150, "n TPC clusters"}; + histos.add("occupancyQA/tpcNClsFound_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNTPCcls, axisOccupancyForTrackQA}); + histos.add("occupancyQA/tpcNClsFindable_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNTPCcls, axisOccupancyForTrackQA}); + histos.add("occupancyQA/tpcNClsShared_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNTPCcls, axisOccupancyForTrackQA}); + histos.add("occupancyQA/tpcNCrossedRows_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisNTPCcls, axisOccupancyForTrackQA}); + const AxisSpec axisChi2TPC{150, 0, 15, "chi2Ncl TPC"}; + histos.add("occupancyQA/tpcChi2_vs_V0A_vs_occupancy", "", kTH3F, {axisMultV0AForOccup, axisChi2TPC, axisOccupancyForTrackQA}); + + // ITS in-ROF occupancy + histos.add("occupancyQA/hITSTracks_ev1_vs_ev2_2coll_in_ROF", ";nITStracks event #1;nITStracks event #2", kTH2D, {{200, 0., 6000}, {200, 0., 6000}}); + histos.add("occupancyQA/hITSTracks_ev1_vs_ev2_2coll_in_ROF_UPC", ";nITStracks event #1;nITStracks event #2", kTH2D, {{41, -0.5, 40.5}, {41, -0.5, 40.5}}); + histos.add("occupancyQA/hITSTracks_ev1_vs_ev2_2coll_in_ROF_nonUPC", ";nITStracks event #1;nITStracks event #2", kTH2D, {{200, 0., 6000}, {200, 0., 6000}}); + + histos.add("occupancyQA/dEdx_vs_centr_vs_occup_narrow_p_win", "dE/dx", kTH3F, {{20, 0, 4000, "n PV tracks"}, {60, 0, 15000, "occupancy"}, {800, 0.0, 800.0, "dE/dx (a. u.)"}}); + } } void processRun2( @@ -548,10 +602,10 @@ struct EventSelectionQaTask { auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run); // first bc of the first orbit bcSOR = runInfo.orbitSOR * nBCsPerOrbit; - // duration of TF in bcs - nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit; // number of orbits per TF nOrbitsPerTF = runInfo.orbitsPerTF; + // duration of TF in bcs + nBCsPerTF = nOrbitsPerTF * nBCsPerOrbit; // first orbit orbitSOR = runInfo.orbitSOR; // total number of orbits @@ -561,6 +615,14 @@ struct EventSelectionQaTask { // end-of-run timestamp tsEOR = runInfo.eor; + // extract ITS ROF parameters + int64_t ts = bcs.iteratorAt(0).timestamp(); + auto alppar = ccdb->getForTimeStamp>("ITS/Config/AlpideParam", ts); + rofOffset = alppar->roFrameBiasInBC; + rofLength = alppar->roFrameLengthInBC; + LOGP(info, "rofOffset={} rofLength={}", rofOffset, rofLength); + LOGP(info, "nOrbitsPerTF={} nBCsPerTF={}", nOrbitsPerTF, nBCsPerTF); + // bc patterns auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", (tsSOR + tsEOR) / 2); auto beamPatternA = grplhcif->getBunchFilling().getBeamPattern(0); @@ -669,11 +731,12 @@ struct EventSelectionQaTask { histos.add("hNcontribAfterCutsVsBcInTF", ";bc in TF; n vertex contributors", kTH1F, {axisBCinTF}); histos.add("hNcolMCVsBcInTF", ";bc in TF; n MC collisions", kTH1F, {axisBCinTF}); histos.add("hNcolVsBcInTF", ";bc in TF; n collisions", kTH1F, {axisBCinTF}); + histos.add("hNcolVsBcInTFafterTFborderCut", ";bc in TF; n collisions", kTH1F, {axisBCinTF}); histos.add("hNtvxVsBcInTF", ";bc in TF; n TVX triggers", kTH1F, {axisBCinTF}); double minSec = floor(tsSOR / 1000.); double maxSec = ceil(tsEOR / 1000.); - const AxisSpec axisSeconds{static_cast(maxSec - minSec), minSec, maxSec, "seconds"}; + const AxisSpec axisSeconds{maxSec - minSec < 5000 ? static_cast(maxSec - minSec) : 5000, minSec, maxSec, "seconds"}; const AxisSpec axisBcDif{600, -300., 300., "bc difference"}; histos.add("hSecondsTVXvsBcDif", "", kTH2F, {axisSeconds, axisBcDif}); histos.add("hSecondsTVXvsBcDifAll", "", kTH2F, {axisSeconds, axisBcDif}); @@ -932,6 +995,10 @@ struct EventSelectionQaTask { } // collision-based event selection qa + std::vector vFoundGlobalBC(cols.size(), 0); // global BCs for collisions + std::vector vCollVz(cols.size(), 0); // vector with vZ positions for each collision + std::vector vIsSel8(cols.size(), 0); // vector with sel8 decisions + std::vector vTracksITS567perColl(cols.size(), 0); // counter of tracks per collision for occupancy studies for (const auto& col : cols) { for (int iAlias = 0; iAlias < kNaliases; iAlias++) { if (!col.alias_bit(iAlias)) { @@ -959,41 +1026,23 @@ struct EventSelectionQaTask { histos.fill(HIST("hOrbitAcc"), orbit - orbitSOR); } + int32_t colIndex = col.globalIndex(); + vFoundGlobalBC[colIndex] = globalBC; + vCollVz[colIndex] = col.posZ(); + vIsSel8[colIndex] = col.sel8(); + // search for nearest ft0a&ft0c entry int32_t indexClosestTVX = findClosest(globalBC, mapGlobalBcWithTVX); int bcDiff = static_cast(globalBC - vGlobalBCs[indexClosestTVX]); - // count tracks of different types - auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); - int nContributorsAfterEtaTPCCuts = 0; - for (const auto& track : tracksGrouped) { - int trackBcDiff = bcDiff + track.trackTime() / o2::constants::lhc::LHCBunchSpacingNS; - if (!track.isPVContributor()) - continue; - if (std::fabs(track.eta()) < 0.8 && track.tpcNClsFound() > 80 && track.tpcNClsCrossedRows() > 100) - nContributorsAfterEtaTPCCuts++; - if (!track.hasTPC()) - histos.fill(HIST("hITStrackBcDiff"), trackBcDiff); - if (track.hasTOF()) { - histos.fill(HIST("hBcTrackTOF"), (globalBC + TMath::FloorNint(track.trackTime() / o2::constants::lhc::LHCBunchSpacingNS)) % nBCsPerOrbit); - } else if (track.hasTRD()) { - histos.fill(HIST("hBcTrackTRD"), (globalBC + TMath::Nint(track.trackTime() / o2::constants::lhc::LHCBunchSpacingNS)) % nBCsPerOrbit); - } - if (track.hasTOF() || track.hasTRD() || !track.hasITS() || !track.hasTPC() || track.pt() < 1) - continue; - histos.fill(HIST("hTrackBcDiffVsEta"), track.eta(), trackBcDiff); - if (track.eta() < -0.2 || track.eta() > 0.2) - continue; - histos.fill(HIST("hSecondsTVXvsBcDif"), bc.timestamp() / 1000., trackBcDiff); - } - int nContributors = col.numContrib(); float timeRes = col.collisionTimeRes(); int64_t bcInTF = (globalBC - bcSOR) % nBCsPerTF; histos.fill(HIST("hNcontribCol"), nContributors); histos.fill(HIST("hNcontribVsBcInTF"), bcInTF, nContributors); - histos.fill(HIST("hNcontribAfterCutsVsBcInTF"), bcInTF, nContributorsAfterEtaTPCCuts); histos.fill(HIST("hNcolVsBcInTF"), bcInTF); + if (col.selection_bit(kNoTimeFrameBorder)) + histos.fill(HIST("hNcolVsBcInTFafterTFborderCut"), bcInTF); histos.fill(HIST("hColBcDiffVsNcontrib"), nContributors, bcDiff); histos.fill(HIST("hColTimeResVsNcontrib"), nContributors, timeRes); if (!col.selection_bit(kIsVertexITSTPC)) { @@ -1076,10 +1125,128 @@ struct EventSelectionQaTask { histos.fill(HIST("hMultZNAcol"), multZNA); histos.fill(HIST("hMultZNCcol"), multZNC); + // count tracks of different types + auto tracksGrouped = tracks.sliceBy(perCollision, colIndex); + int nPV = 0; + int nTPConly = 0; + // int nTPConlyWithDeDxCut = 0; + int nTPConlyNoITS = 0; + int nContributorsAfterEtaTPCCuts = 0; + int nContributorsAfterEtaTPCLooseCuts = 0; + + int nTracksITS = 0; + int nTracksITSTPC = 0; + + bool isTVX = col.selection_bit(kIsTriggerTVX); + + int occupancyByTracks = col.trackOccupancyInTimeRange(); + float occupancyByFT0C = col.ft0cOccupancyInTimeRange(); + + for (const auto& track : tracksGrouped) { + int trackBcDiff = bcDiff + track.trackTime() / o2::constants::lhc::LHCBunchSpacingNS; + + if (track.hasTPC() && std::fabs(track.eta()) < 0.8 && track.pt() > 0.2 && track.tpcNClsFound() > 50 && track.tpcNClsCrossedRows() > 50 && track.tpcChi2NCl() < 4) { + nTPConly++; + // if (track.tpcSignal() > 20) + // nTPConlyWithDeDxCut++; + if (!track.hasITS()) + nTPConlyNoITS++; + } + + if (std::fabs(track.eta()) < 0.8 && track.pt() > 0.2) { + if (track.hasITS()) { + nTracksITS++; + if (track.hasTPC()) + nTracksITSTPC++; + } + } + + if (!track.isPVContributor()) + continue; + + if (track.itsNCls() >= 5) + vTracksITS567perColl[colIndex]++; + + // high-quality contributors for ROF border QA and occupancy study + if (std::fabs(track.eta()) < 0.8 && track.pt() > 0.2 && track.itsNCls() >= 5) { + nPV++; + if (track.hasTPC()) { + nContributorsAfterEtaTPCLooseCuts++; + + if (!isLowFlux && col.sel8() && col.selection_bit(kNoSameBunchPileup) && fabs(col.posZ()) < 10 && occupancyByTracks >= 0) { + histos.fill(HIST("occupancyQA/tpcNClsFound_vs_V0A_vs_occupancy"), multV0A, track.tpcNClsFound(), occupancyByTracks); + histos.fill(HIST("occupancyQA/tpcNClsFindable_vs_V0A_vs_occupancy"), multV0A, track.tpcNClsFindable(), occupancyByTracks); + histos.fill(HIST("occupancyQA/tpcNClsShared_vs_V0A_vs_occupancy"), multV0A, track.tpcNClsShared(), occupancyByTracks); + histos.fill(HIST("occupancyQA/tpcChi2_vs_V0A_vs_occupancy"), multV0A, track.tpcChi2NCl(), occupancyByTracks); + int tpcNClsFindableMinusCrossedRowsCorrected = track.tpcNClsFindableMinusCrossedRows(); + // correct for a buggy behaviour due to int8 and uint8 difference: + if (tpcNClsFindableMinusCrossedRowsCorrected < -70) + tpcNClsFindableMinusCrossedRowsCorrected += 256; + histos.fill(HIST("occupancyQA/tpcNCrossedRows_vs_V0A_vs_occupancy"), multV0A, track.tpcNClsFindable() - tpcNClsFindableMinusCrossedRowsCorrected, occupancyByTracks); + } + } // end of hasTPC + if (col.sel8() && fabs(col.posZ()) < 10 && track.tpcNClsFound() > 50 && track.tpcNClsCrossedRows() > 80 && track.itsChi2NCl() < 36 && track.tpcChi2NCl() < 4) { + nContributorsAfterEtaTPCCuts++; + // ROF border QA + histos.fill(HIST("ITSROFborderQA/hFoundBC_kTVX_nITSlayers_for_ITSTPCtracks"), localBC, track.itsNCls()); + histos.fill(HIST("ITSROFborderQA/hFoundBC_kTVX_counter_ITSTPCtracks"), localBC); + } + } + if (!track.hasTPC()) + histos.fill(HIST("hITStrackBcDiff"), trackBcDiff); + if (track.hasTOF()) { + histos.fill(HIST("hBcTrackTOF"), (globalBC + TMath::FloorNint(track.trackTime() / o2::constants::lhc::LHCBunchSpacingNS)) % nBCsPerOrbit); + } else if (track.hasTRD()) { + histos.fill(HIST("hBcTrackTRD"), (globalBC + TMath::Nint(track.trackTime() / o2::constants::lhc::LHCBunchSpacingNS)) % nBCsPerOrbit); + } + if (track.hasTOF() || track.hasTRD() || !track.hasITS() || !track.hasTPC() || track.pt() < 1) + continue; + histos.fill(HIST("hTrackBcDiffVsEta"), track.eta(), trackBcDiff); + if (track.eta() < -0.2 || track.eta() > 0.2) + continue; + histos.fill(HIST("hSecondsTVXvsBcDif"), bc.timestamp() / 1000., trackBcDiff); + } // end of track loop + + histos.fill(HIST("hNcontribAfterCutsVsBcInTF"), bcInTF, nContributorsAfterEtaTPCCuts); + + if (!isLowFlux && col.sel8() && col.selection_bit(kNoSameBunchPileup) && fabs(col.posZ()) < 10) { + histos.fill(HIST("occupancyQA/hOccupancyByTracks"), occupancyByTracks); + histos.fill(HIST("occupancyQA/hOccupancyByFT0C"), occupancyByFT0C); + if (occupancyByTracks >= 0) { + histos.fill(HIST("occupancyQA/hOccupancyByFT0CvsByTracks"), occupancyByTracks, occupancyByFT0C); + histos.fill(HIST("occupancyQA/hNumTracksPV_vs_V0A_vs_occupancy"), multV0A, nPV, occupancyByTracks); + histos.fill(HIST("occupancyQA/hNumTracksPVTPC_vs_V0A_vs_occupancy"), multV0A, nContributorsAfterEtaTPCCuts, occupancyByTracks); + histos.fill(HIST("occupancyQA/hNumTracksPVTPCLooseCuts_vs_V0A_vs_occupancy"), multV0A, nContributorsAfterEtaTPCLooseCuts, occupancyByTracks); + histos.fill(HIST("occupancyQA/hNumTracksITS_vs_V0A_vs_occupancy"), multV0A, nTracksITS, occupancyByTracks); + histos.fill(HIST("occupancyQA/hNumTracksITSTPC_vs_V0A_vs_occupancy"), multV0A, nTracksITSTPC, occupancyByTracks); + if (col.selection_bit(kNoCollInTimeRangeNarrow)) { + histos.fill(HIST("occupancyQA/hNumTracksPV_vs_V0A_vs_occupancy_NarrowDeltaTimeCut"), multV0A, nPV, occupancyByTracks); + histos.fill(HIST("occupancyQA/hNumTracksPVTPC_vs_V0A_vs_occupancy_NarrowDeltaTimeCut"), multV0A, nContributorsAfterEtaTPCCuts, occupancyByTracks); + } + histos.fill(HIST("occupancyQA/hNumTracksTPConly_vs_V0A_vs_occupancy"), multV0A, nTPConly, occupancyByTracks); + histos.fill(HIST("occupancyQA/hNumTracksTPConlyNoITS_vs_V0A_vs_occupancy"), multV0A, nTPConlyNoITS, occupancyByTracks); + + // dE/dx QA for a narrow pT bin + for (const auto& track : tracksGrouped) { + if (!track.isPVContributor()) + continue; + if (std::fabs(track.eta()) < 0.8 && track.pt() > 0.2 && track.itsNCls() >= 5) { + float signedP = track.sign() * track.tpcInnerParam(); + if (std::fabs(signedP) > 0.38 && std::fabs(signedP) < 0.4 && track.tpcNClsFound() > 50 && track.tpcNClsCrossedRows() > 80 && track.itsChi2NCl() < 36 && track.tpcChi2NCl() < 4) { + float dEdx = track.tpcSignal(); + histos.fill(HIST("occupancyQA/dEdx_vs_centr_vs_occup_narrow_p_win"), nPV, occupancyByTracks, dEdx); + } + } + } + } + } + // filling plots for events passing basic TVX selection - if (!col.selection_bit(kIsTriggerTVX)) { + if (!isTVX) { continue; } + histos.fill(HIST("hMultT0MVsNcontribTVX"), multT0A + multT0C, nContributors); + histos.fill(HIST("hMultV0AVsNcontribTVX"), multV0A, nContributors); // z-vertex from FT0 vs PV if (foundBC.has_ft0()) { @@ -1090,9 +1257,16 @@ struct EventSelectionQaTask { int foundLocalBC = foundBC.globalBC() % nBCsPerOrbit; + if (col.selection_bit(kNoITSROFrameBorder)) { + histos.fill(HIST("hMultT0MVsNcontribTVXROFcuts"), multT0A + multT0C, nContributors); + histos.fill(HIST("hMultV0AVsNcontribTVXROFcuts"), multV0A, nContributors); + } + if (col.selection_bit(kNoTimeFrameBorder)) { - histos.fill(HIST("hMultV0AVsNcontribAcc"), multV0A, nContributors); - histos.fill(HIST("hBcForMultV0AVsNcontribAcc"), foundLocalBC); + histos.fill(HIST("hMultT0MVsNcontribTVXTFcuts"), multT0A + multT0C, nContributors); + histos.fill(HIST("hMultV0AVsNcontribTVXTFcuts"), multV0A, nContributors); + + // histos.fill(HIST("hFoundBcForMultV0AVsNcontribAcc"), foundLocalBC); histos.fill(HIST("hFoundBc"), foundLocalBC); histos.fill(HIST("hFoundBcNcontrib"), foundLocalBC, nContributors); if (col.selection_bit(kIsVertexTOFmatched)) { @@ -1100,16 +1274,14 @@ struct EventSelectionQaTask { histos.fill(HIST("hFoundBcNcontribTOF"), foundLocalBC, nContributors); } if (nContributors < 0.043 * multV0A - 860) { - histos.fill(HIST("hBcForMultV0AVsNcontribOutliers"), foundLocalBC); + histos.fill(HIST("hFoundBcForMultV0AVsNcontribOutliers"), foundLocalBC); } if (col.selection_bit(kNoITSROFrameBorder)) { - histos.fill(HIST("hMultV0AVsNcontribCut"), multV0A, nContributors); - histos.fill(HIST("hBcForMultV0AVsNcontribCut"), foundLocalBC); - } - } + histos.fill(HIST("hMultT0MVsNcontribTVXTFROFcuts"), multT0A + multT0C, nContributors); + histos.fill(HIST("hMultV0AVsNcontribTVXTFROFcuts"), multV0A, nContributors); - if (col.selection_bit(kNoITSROFrameBorder)) { - histos.fill(HIST("hMultT0MVsNcontribCut"), multT0A + multT0C, nContributors); + histos.fill(HIST("hFoundBcAfterROFborderCut"), foundLocalBC); + } } // filling plots for accepted events @@ -1118,7 +1290,7 @@ struct EventSelectionQaTask { } if (col.selection_bit(kIsVertexITSTPC)) { - histos.fill(HIST("hMultV0AVsNcontribAfterVertex"), multV0A, nContributors); + histos.fill(HIST("hMultV0AVsNcontribIsVertexITSTPC"), multV0A, nContributors); if (col.selection_bit(kNoSameBunchPileup)) { histos.fill(HIST("hMultV0AVsNcontribGood"), multV0A, nContributors); } @@ -1128,7 +1300,7 @@ struct EventSelectionQaTask { histos.fill(HIST("hMultT0Mpup"), multT0A + multT0C); } - histos.fill(HIST("hMultT0MVsNcontribAcc"), multT0A + multT0C, nContributors); + // histos.fill(HIST("hMultT0MVsNcontribAcc"), multT0A + multT0C, nContributors); histos.fill(HIST("hTimeV0Aacc"), timeV0A); histos.fill(HIST("hTimeZNAacc"), timeZNA); histos.fill(HIST("hTimeZNCacc"), timeZNC); @@ -1145,9 +1317,78 @@ struct EventSelectionQaTask { histos.fill(HIST("hMultZNAacc"), multZNA); histos.fill(HIST("hMultZNCacc"), multZNC); histos.fill(HIST("hNcontribAcc"), nContributors); - } // collisions + // ### in-ROF occupancy QA + if (!isLowFlux) { + std::vector> vCollsInSameITSROF; + // save indices of collisions in same ROF + for (const auto& col : cols) { + int32_t colIndex = col.globalIndex(); + int64_t foundGlobalBC = vFoundGlobalBC[colIndex]; + int64_t tfId = (foundGlobalBC - bcSOR) / nBCsPerTF; + int64_t rofId = (foundGlobalBC + 3564 - rofOffset) / rofLength; + std::vector vAssocToSameROF; + // find all collisions in the same ROF before a given collision + int32_t minColIndex = colIndex - 1; + while (minColIndex >= 0) { + int64_t thisBC = vFoundGlobalBC[minColIndex]; + // check if this is still the same TF + int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; + if (thisTFid != tfId) + break; + int64_t thisRofId = (thisBC + 3564 - rofOffset) / rofLength; + + // check if we are within the same ROF + if (thisRofId != rofId) + break; + vAssocToSameROF.push_back(minColIndex); + minColIndex--; + } + // find all collisions in the same ROF after the current one + int32_t maxColIndex = colIndex + 1; + while (maxColIndex < cols.size()) { + int64_t thisBC = vFoundGlobalBC[maxColIndex]; + int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; + if (thisTFid != tfId) + break; + int64_t thisRofId = (thisBC + 3564 - rofOffset) / rofLength; + if (thisRofId != rofId) + break; + vAssocToSameROF.push_back(maxColIndex); + maxColIndex++; + } + vCollsInSameITSROF.push_back(vAssocToSameROF); + } // end of in-ROF occupancy 1st loop + + // nTrack correlations in ROFs with 2 collisions inside + for (const auto& col : cols) { + int32_t colIndex = col.globalIndex(); + if (!col.sel8() || !col.selection_bit(kNoSameBunchPileup)) + continue; + if (vCollsInSameITSROF[colIndex].size() != 1) // analyse only cases with 2 collisions in the same ROF + continue; + float vZ = col.posZ(); + float nPV = vTracksITS567perColl[colIndex]; + + ushort flags = col.flags(); + bool isVertexUPC = flags & dataformats::Vertex>::Flags::UPCMode; // is vertex with UPC settings + + // the second collision in ROF + std::vector vAssocToSameROF = vCollsInSameITSROF[colIndex]; + int thisColIndex = vAssocToSameROF[0]; + float vZassoc = vCollVz[thisColIndex]; // vZ of the second collision in the same ROF + float nPVassoc = vTracksITS567perColl[thisColIndex]; // n PV tracks of the second collision in the same ROF + if (std::fabs(vZ) < 10 && std::fabs(vZassoc) < 10 && thisColIndex > colIndex && vIsSel8[thisColIndex]) { + histos.fill(HIST("occupancyQA/hITSTracks_ev1_vs_ev2_2coll_in_ROF"), nPV, nPVassoc); + if (isVertexUPC) + histos.fill(HIST("occupancyQA/hITSTracks_ev1_vs_ev2_2coll_in_ROF_UPC"), nPV, nPVassoc); + else + histos.fill(HIST("occupancyQA/hITSTracks_ev1_vs_ev2_2coll_in_ROF_nonUPC"), nPV, nPVassoc); + } + } + } // end of in-ROF occupancy QA + // TVX efficiency after TF and ITS ROF border cuts for (const auto& col : cols) { if (!col.selection_bit(kNoTimeFrameBorder) || !col.selection_bit(kNoITSROFrameBorder)) diff --git a/DPG/Tasks/AOTEvent/lightIonsEvSelQa.cxx b/DPG/Tasks/AOTEvent/lightIonsEvSelQa.cxx new file mode 100644 index 00000000000..59c88b55171 --- /dev/null +++ b/DPG/Tasks/AOTEvent/lightIonsEvSelQa.cxx @@ -0,0 +1,1128 @@ +// 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. + +/// \file detectorOccupancyQa.cxx +/// \brief Occupancy QA task +/// +/// \author Igor Altsybeev + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +// #include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonDataFormat/BunchFilling.h" +#include "DataFormatsFT0/Digit.h" +#include "DataFormatsFT0/RecPoints.h" +#include "DataFormatsParameters/AggregatedRunInfo.h" +#include "DataFormatsParameters/GRPECSObject.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TH3.h" + +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod::evsel; + +using BCsRun3 = soa::Join; +using ColEvSels = soa::Join; //, aod::CentFT0Cs>; +// using FullTracksIU = soa::Join; +using FullTracksIU = soa::Join; + +struct LightIonsEvSelQa { + Configurable confCutMinTPCcls{"MinNumTPCcls", 50, "min number of TPC clusters for a current event"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nBinsTracks{"nBinsTracks", 450, "N bins in n tracks histo"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nMaxTracks{"nMaxTracks", 450, "N max in n tracks histo"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nMaxGlobalTracks{"nMaxGlobalTracks", 450, "N max in n tracks histo"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nBinsMultFwd{"nBinsMultFwd", 1000, "N bins in mult fwd histo"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable nMaxMultFwd{"nMaxMultFwd", 100000, "N max in mult fwd histo"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable timeBinWidthInSec{"TimeBinWidthInSec", 10, "Width of time bins in seconds"}; // o2-linter: disable=name/configurable (temporary fix) + + Configurable nSigmaForVzDiff{"nSigmaForVzDiff", 3.0, "n +/- sigma for diff vZ"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable safetyDiffMargin{"SafetyDiffVzMargin", 0.4, "margin for diff vZ, cm"}; // o2-linter: disable=name/configurable (temporary fix) + + uint64_t minGlobalBC = 0; + Service ccdb; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + bool* applySelection = NULL; + int nBCsPerOrbit = 3564; + int lastRunNumber = -1; + double maxSec = 1; + double minSec = 0; + int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 by default for unanchored MC + int64_t nBCsPerTF = 32 * nBCsPerOrbit; // duration of TF in bcs, should be 128*3564 or 32*3564, setting 128 orbits by default sfor unanchored MC + + // save time "slices" for several collisions for QA + bool flagFillQAtimeOccupHist = false; + int nCollisionsForTimeBinQA = 40; + int counterQAtimeOccupHistos = 0; + + void init(InitContext&) + { + // ccdb->setURL("http://ccdb-test.cern.ch:8080"); + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + // const AxisSpec axisBCinTF{static_cast(nBCsPerTF), 0, static_cast(nBCsPerTF), "bc in TF"}; + // histos.add("hNcolVsBcInTF/hNcolVsBcInTF", ";bc in TF; n collisions", kTH1F, {axisBCinTF}); + // histos.add("hNcolVsBcInTF/hNcolVsBcInTF_vertexTOFmatched", ";bc in TF; n collisions", kTH1F, {axisBCinTF}); + + // ############## + const AxisSpec axisBCs{nBCsPerOrbit, 0., static_cast(nBCsPerOrbit), ""}; + + histos.add("bcQA/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("bcQA/pastActivity/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("bcQA/futureActivity/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("bcQA/noPastActivity/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("bcQA/noFutureActivity/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("bcQA/noPastFutureActivity/hBcFV0", "", kTH1F, {axisBCs}); + + histos.add("bcQA/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("bcQA/pastActivity/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("bcQA/futureActivity/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("bcQA/noPastActivity/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("bcQA/noFutureActivity/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("bcQA/noPastFutureActivity/hBcFT0", "", kTH1F, {axisBCs}); + + histos.add("bcQA/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("bcQA/pastActivity/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("bcQA/futureActivity/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("bcQA/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("bcQA/pastActivity/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("bcQA/futureActivity/hBcZDC", "", kTH1F, {axisBCs}); + + const AxisSpec axisNtracks{nBinsTracks, -0.5, nMaxTracks - 0.5, "n tracks"}; + const AxisSpec axisNtracksGlobal{nBinsTracks, -0.5, nMaxGlobalTracks - 0.5, "n tracks"}; + const AxisSpec axisMultV0A{nBinsMultFwd, 0., static_cast(nMaxMultFwd), "mult V0A"}; + const AxisSpec axisMultFT0A{nBinsMultFwd, 0., static_cast(nMaxMultFwd * 0.4), "mult FT0C"}; + const AxisSpec axisMultFT0C{nBinsMultFwd, 0., static_cast(nMaxMultFwd * 0.15), "mult FT0C"}; + const AxisSpec axisMultT0M{nBinsMultFwd * 2, 0., static_cast(nMaxMultFwd * 0.4), "mult FT0M"}; + + const AxisSpec axisVtxZ{800, -20., 20., ""}; + const AxisSpec axisBcDiff{600, -300., 300., "bc difference"}; + + const AxisSpec axisNcontrib{801, -0.5, 800.5, "n contributors"}; + const AxisSpec axisColTimeRes{1500, 0., 1500., "collision time resolution (ns)"}; + + histos.add("noSpecSelections/hBcColNoSel8", "", kTH1F, {axisBCs}); + // histos.add("noSpecSelections/hBcColNoSel8TOF", "", kTH1F, {axisBCs}); + histos.add("noSpecSelections/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noSpecSelections/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noSpecSelections/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noSpecSelections/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noSpecSelections/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noSpecSelections/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noSpecSelections/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noSpecSelections/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noSpecSelections/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noSpecSelections/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noSpecSelections/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noSpecSelections/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noSpecSelections/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noSpecSelections/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noSpecSelections/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noSpecSelections/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("noPU/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("noPU/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noPU/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noPU/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noPU/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noPU/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noPU/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noPU/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noPU/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noPU/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noPU/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noPU/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noPU/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noPU/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noPU/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noPU/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noPU/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("noPU_pvTOFmatched/hBcColNoSel8", "", kTH1F, {axisBCs}); + // histos.add("noPU_pvTOFmatched/hBcColNoSel8TOF", "", kTH1F, {axisBCs}); + histos.add("noPU_pvTOFmatched/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noPU_pvTOFmatched/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noPU_pvTOFmatched/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noPU_pvTOFmatched/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noPU_pvTOFmatched/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noPU_pvTOFmatched/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noPU_pvTOFmatched/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noPU_pvTOFmatched/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noPU_pvTOFmatched/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noPU_pvTOFmatched/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noPU_pvTOFmatched/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noPU_pvTOFmatched/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noPU_pvTOFmatched/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noPU_pvTOFmatched/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noPU_pvTOFmatched/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noPU_pvTOFmatched/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("bcDiffCut/hBcColNoSel8", "", kTH1F, {axisBCs}); + // histos.add("bcDiffCut/hBcColNoSel8TOF", "", kTH1F, {axisBCs}); + histos.add("bcDiffCut/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("bcDiffCut/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("bcDiffCut/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("bcDiffCut/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("bcDiffCut/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("bcDiffCut/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("bcDiffCut/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("bcDiffCut/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("bcDiffCut/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("bcDiffCut/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("bcDiffCut/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("bcDiffCut/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("bcDiffCut/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("bcDiffCut/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("bcDiffCut/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("bcDiffCut/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("narrowTimeVeto/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("narrowTimeVeto/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("narrowTimeVeto/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("narrowTimeVeto/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("narrowTimeVeto/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("narrowTimeVeto/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("narrowTimeVeto/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("narrowTimeVeto/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("narrowTimeVeto/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("narrowTimeVeto/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("narrowTimeVeto/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("narrowTimeVeto/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("narrowTimeVeto/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("narrowTimeVeto/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("narrowTimeVeto/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("narrowTimeVeto/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("narrowTimeVeto/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("strictTimeVeto/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("strictTimeVeto/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("strictTimeVeto/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("strictTimeVeto/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("strictTimeVeto/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("strictTimeVeto/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("strictTimeVeto/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("strictTimeVeto/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("strictTimeVeto/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("strictTimeVeto/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("strictTimeVeto/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("strictTimeVeto/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("strictTimeVeto/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("strictTimeVeto/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("strictTimeVeto/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("strictTimeVeto/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("strictTimeVeto/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("noCollSameROF/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("noCollSameROF/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noCollSameROF/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noCollSameROF/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noCollSameROF/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noCollSameROF/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noCollSameROF/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noCollSameROF/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noCollSameROF/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noCollSameROF/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noCollSameROF/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noCollSameROF/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noCollSameROF/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noCollSameROF/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noCollSameROF/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noCollSameROF/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noCollSameROF/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("noPU_LowMultCut/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("noPU_LowMultCut/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noPU_LowMultCut/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noPU_LowMultCut/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noPU_LowMultCut/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noPU_LowMultCut/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noPU_LowMultCut/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noPU_LowMultCut/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noPU_LowMultCut/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noPU_LowMultCut/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noPU_LowMultCut/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noPU_LowMultCut/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noPU_LowMultCut/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noPU_LowMultCut/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noPU_LowMultCut/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noPU_LowMultCut/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noPU_LowMultCut/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("noPU_HighMultCloudCut/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("noPU_HighMultCloudCut/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noPU_HighMultCloudCut/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noPU_HighMultCloudCut/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noPU_HighMultCloudCut/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noPU_HighMultCloudCut/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noPU_HighMultCloudCut/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noPU_HighMultCloudCut/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noPU_HighMultCloudCut/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noPU_HighMultCloudCut/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noPU_HighMultCloudCut/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noPU_HighMultCloudCut/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noPU_HighMultCloudCut/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noPU_HighMultCloudCut/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noPU_HighMultCloudCut/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noPU_HighMultCloudCut/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noPU_HighMultCloudCut/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("badVzDiff/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("badVzDiff/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("badVzDiff/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("badVzDiff/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("badVzDiff/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("badVzDiff/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("badVzDiff/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("badVzDiff/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("badVzDiff/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("badVzDiff/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("badVzDiff/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("badVzDiff/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("badVzDiff/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("badVzDiff/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("badVzDiff/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("badVzDiff/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("badVzDiff/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("noPU_goodVzDiff/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("noPU_goodVzDiff/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noPU_goodVzDiff/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noPU_goodVzDiff/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noPU_goodVzDiff/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noPU_goodVzDiff/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noPU_goodVzDiff/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noPU_goodVzDiff/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noPU_goodVzDiff/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noPU_goodVzDiff/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noPU_goodVzDiff/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noPU_goodVzDiff/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noPU_goodVzDiff/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noPU_goodVzDiff/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noPU_goodVzDiff/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noPU_goodVzDiff/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noPU_goodVzDiff/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("noPastActivity/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("noPastActivity/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noPastActivity/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noPastActivity/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noPastActivity/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noPastActivity/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noPastActivity/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noPastActivity/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noPastActivity/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noPastActivity/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noPastActivity/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noPastActivity/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noPastActivity/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noPastActivity/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noPastActivity/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noPastActivity/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noPastActivity/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("noFT0activityNearby/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("noFT0activityNearby/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noFT0activityNearby/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noFT0activityNearby/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noFT0activityNearby/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noFT0activityNearby/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noFT0activityNearby/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noFT0activityNearby/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noFT0activityNearby/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noFT0activityNearby/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noFT0activityNearby/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noFT0activityNearby/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noFT0activityNearby/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noFT0activityNearby/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noFT0activityNearby/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noFT0activityNearby/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noFT0activityNearby/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("noPU_cutByVzDiff_pvTOF/hBcColNoSel8", "", kTH1F, {axisBCs}); + histos.add("noPU_cutByVzDiff_pvTOF/hBcTVX", "", kTH1F, {axisBCs}); + histos.add("noPU_cutByVzDiff_pvTOF/hBcFT0", "", kTH1F, {axisBCs}); + histos.add("noPU_cutByVzDiff_pvTOF/hBcFV0", "", kTH1F, {axisBCs}); + histos.add("noPU_cutByVzDiff_pvTOF/hBcFDD", "", kTH1F, {axisBCs}); + histos.add("noPU_cutByVzDiff_pvTOF/hBcZDC", "", kTH1F, {axisBCs}); + histos.add("noPU_cutByVzDiff_pvTOF/hVtxFT0VsVtxCol", "", kTH2F, {axisVtxZ, axisVtxZ}); + histos.add("noPU_cutByVzDiff_pvTOF/hVtxFT0MinusVtxColVsMultT0M", "", kTH2F, {axisVtxZ, axisMultT0M}); + histos.add("noPU_cutByVzDiff_pvTOF/nTracksPV_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("noPU_cutByVzDiff_pvTOF/nTracksPV_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracks}); + histos.add("noPU_cutByVzDiff_pvTOF/nTracksPV_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracks}); + histos.add("noPU_cutByVzDiff_pvTOF/nTracksGlobal_vs_V0A", "", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("noPU_cutByVzDiff_pvTOF/nTracksGlobal_vs_T0A", "", kTH2F, {axisMultFT0A, axisNtracksGlobal}); + histos.add("noPU_cutByVzDiff_pvTOF/nTracksGlobal_vs_T0C", "", kTH2F, {axisMultFT0C, axisNtracksGlobal}); + histos.add("noPU_cutByVzDiff_pvTOF/hTVXvsBcDiff", "", kTH1F, {axisBcDiff}); + histos.add("noPU_cutByVzDiff_pvTOF/hColTimeResVsNcontrib", "", kTH2F, {axisNcontrib, axisColTimeRes}); + histos.add("noPU_cutByVzDiff_pvTOF/hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + } + + Preslice perCollision = aod::track::collisionId; + + int32_t findClosest(int64_t globalBC, std::map& bcs) + { + auto it = bcs.lower_bound(globalBC); + int64_t bc1 = it->first; + int32_t index1 = it->second; + if (it != bcs.begin()) + --it; + int64_t bc2 = it->first; + int32_t index2 = it->second; + int64_t dbc1 = std::abs(bc1 - globalBC); + int64_t dbc2 = std::abs(bc2 - globalBC); + return (dbc1 <= dbc2) ? index1 : index2; + } + + // ##### + void processRun3( + ColEvSels const& cols, + FullTracksIU const& tracks, + BCsRun3 const& bcs, + aod::FT0s const&) + { + int runNumber = bcs.iteratorAt(0).runNumber(); + if (runNumber != lastRunNumber) { + lastRunNumber = runNumber; // do it only once + + int64_t tsSOR = 0; // dummy start-of-run timestamp + int64_t tsEOR = 1; // dummy end-of-run timestamp + + if (runNumber >= 500000) { + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), runNumber); + // first bc of the first orbit + bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches; + // duration of TF in bcs + nBCsPerTF = runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches; + + // start-of-run timestamp + tsSOR = runInfo.sor; + // end-of-run timestamp + tsEOR = runInfo.eor; + + LOGP(info, "bcSOR = {}, nBCsPerTF = {}", bcSOR, nBCsPerTF); + } + + minSec = floor(tsSOR / 1000.); + maxSec = ceil(tsEOR / 1000.); + int nTimeBins = static_cast((maxSec - minSec) / timeBinWidthInSec); + double timeInterval = nTimeBins * timeBinWidthInSec; + + const AxisSpec axisSeconds{nTimeBins, 0, timeInterval, "seconds"}; + histos.add("hSecondsCollisions/sel8", "", kTH1D, {axisSeconds}); + histos.add("hSecondsCollisions/noPU", "", kTH1D, {axisSeconds}); + histos.add("hSecondsCollisions/noPU_underLine", "", kTH1D, {axisSeconds}); + histos.add("hSecondsCollisions/noPU_grassOnTheRight", "", kTH1D, {axisSeconds}); + histos.add("hSecondsCollisions/noPU_good", "", kTH1D, {axisSeconds}); + + } // end of runNumber check + + // vectors of TVX flags used for past-future studies + int nBCs = bcs.size(); + std::vector vIsTVX(nBCs, 0); + std::vector vGlobalBCs(nBCs, 0); + + std::vector vPastActivity(nBCs, 0); + std::vector vFutureActivity(nBCs, 0); + std::vector vNearbyFT0activity(nBCs, 0); + + // create maps from globalBC to bc index for TVX or FT0-OR fired bcs + // to be used for closest TVX (FT0-OR) searches + std::map mapGlobalBcWithTVX; + std::map mapGlobalBcWithTOR; + + // ### BC loop + for (const auto& bc : bcs) { + uint64_t globalBC = bc.globalBC(); + + int indexBc = bc.globalIndex(); + + if (bc.selection_bit(kIsBBT0A) || bc.selection_bit(kIsBBT0C)) { + mapGlobalBcWithTOR[globalBC] = indexBc; + } + if (bc.selection_bit(kIsTriggerTVX)) { + mapGlobalBcWithTVX[globalBC] = indexBc; + } + + // fill TVX flags for past-future searches + vIsTVX[indexBc] = bc.selection_bit(kIsTriggerTVX); + vGlobalBCs[indexBc] = globalBC; + + // ### checking nearby activities + int deltaIndex = 0; // backward move counts + int deltaBC = 0; // current difference wrt globalBC + int maxDeltaBC = 30; // maximum difference + + bool nearbyFT0activity = 0; + + // past + bool pastActivityFT0 = 0; + bool pastActivityFDD = 0; + bool pastActivityFV0 = 0; + while (deltaBC < maxDeltaBC) { + deltaIndex++; + if (bc.globalIndex() - deltaIndex < 0) { + break; + } + const auto& bcPast = bcs.iteratorAt(bc.globalIndex() - deltaIndex); + deltaBC = globalBC - bcPast.globalBC(); + if (deltaBC < maxDeltaBC) { + pastActivityFT0 |= bcPast.has_ft0(); + pastActivityFV0 |= bcPast.has_fv0a(); + pastActivityFDD |= bcPast.has_fdd(); + } + if (deltaBC < 2) { + if (bcPast.has_ft0()) { + std::bitset<8> triggers = bcPast.ft0().triggerMask(); + nearbyFT0activity |= triggers[o2::ft0::RecPoints::ETriggerBits::kIsActiveSideA]; + } + } + } + bool pastActivity = pastActivityFT0 | pastActivityFV0 | pastActivityFDD; + vPastActivity[indexBc] = pastActivity; + + // future + deltaIndex = 0; + deltaBC = 0; + bool futureActivityFT0 = 0; + bool futureActivityFDD = 0; + bool futureActivityFV0 = 0; + while (deltaBC < maxDeltaBC) { + deltaIndex++; + if (bc.globalIndex() + deltaIndex >= bcs.size()) { + break; + } + const auto& bcFuture = bcs.iteratorAt(bc.globalIndex() + deltaIndex); + deltaBC = bcFuture.globalBC() - globalBC; + if (deltaBC < maxDeltaBC) { + futureActivityFT0 |= bcFuture.has_ft0(); + futureActivityFV0 |= bcFuture.has_fv0a(); + futureActivityFDD |= bcFuture.has_fdd(); + } + if (deltaBC < 2) { + if (bcFuture.has_ft0()) { + std::bitset<8> triggers = bcFuture.ft0().triggerMask(); + nearbyFT0activity |= triggers[o2::ft0::RecPoints::ETriggerBits::kIsActiveSideA]; + } + } + } + bool futureActivity = futureActivityFT0 | futureActivityFV0 | futureActivityFDD; + vFutureActivity[indexBc] = futureActivity; + vNearbyFT0activity[indexBc] = nearbyFT0activity; + + // monitor BCs with nearby activity: + + int localBC = globalBC % nBCsPerOrbit; + if (bc.has_fv0a()) { + histos.fill(HIST("bcQA/hBcFV0"), localBC); + if (pastActivity) + histos.fill(HIST("bcQA/pastActivity/hBcFV0"), localBC); + if (futureActivity) + histos.fill(HIST("bcQA/futureActivity/hBcFV0"), localBC); + if (!pastActivity) + histos.fill(HIST("bcQA/noPastActivity/hBcFV0"), localBC); + if (!futureActivity) + histos.fill(HIST("bcQA/noFutureActivity/hBcFV0"), localBC); + if (!pastActivity && !futureActivity) + histos.fill(HIST("bcQA/noPastFutureActivity/hBcFV0"), localBC); + } + if (bc.has_ft0()) { + histos.fill(HIST("bcQA/hBcFT0"), localBC); + if (pastActivity) + histos.fill(HIST("bcQA/pastActivity/hBcFT0"), localBC); + if (futureActivity) + histos.fill(HIST("bcQA/futureActivity/hBcFT0"), localBC); + if (!pastActivity) + histos.fill(HIST("bcQA/noPastActivity/hBcFT0"), localBC); + if (!futureActivity) + histos.fill(HIST("bcQA/noFutureActivity/hBcFT0"), localBC); + if (!pastActivity && !futureActivity) + histos.fill(HIST("bcQA/noPastFutureActivity/hBcFT0"), localBC); + } + if (bc.has_fdd()) { + histos.fill(HIST("bcQA/hBcFDD"), localBC); + if (pastActivity) + histos.fill(HIST("bcQA/pastActivity/hBcFDD"), localBC); + if (futureActivity) + histos.fill(HIST("bcQA/futureActivity/hBcFDD"), localBC); + } + if (bc.has_zdc()) { + histos.fill(HIST("bcQA/hBcZDC"), localBC); + if (pastActivity) + histos.fill(HIST("bcQA/pastActivity/hBcZDC"), localBC); + if (futureActivity) + histos.fill(HIST("bcQA/futureActivity/hBcZDC"), localBC); + } + + } // end of bc loop + + // ### collision loop + for (const auto& col : cols) { + if (std::abs(col.posZ()) > 10) + continue; + + const auto& foundBC = col.foundBC_as(); + uint64_t globalBC = foundBC.globalBC(); + // uint64_t orbit = globalBC / nBCsPerOrbit; + int localBC = globalBC % nBCsPerOrbit; + + int64_t ts = foundBC.timestamp(); + double secFromSOR = ts / 1000. - minSec; + + // search for nearest ft0a&ft0c entry + uint64_t globalOrigBC = col.bc_as().globalBC(); + int32_t indexClosestTVX = findClosest(globalOrigBC, mapGlobalBcWithTVX); + int bcToClosestTVXdiff = static_cast(globalOrigBC - vGlobalBCs[indexClosestTVX]); + + // selection decisions: + bool noPU = col.selection_bit(kNoSameBunchPileup); + bool pvTOFmatched = col.selection_bit(kIsVertexTOFmatched); + bool narrowTimeVeto = col.selection_bit(kNoCollInTimeRangeNarrow); + bool strictTimeVeto = col.selection_bit(kNoCollInTimeRangeStrict); + bool noCollSameROF = col.selection_bit(kNoCollInRofStrict); + bool bcDiffCut = (bcToClosestTVXdiff == 0); + + auto bcIndex = foundBC.globalIndex(); + // bool noNearbyActivity = (vPastActivity[bcIndex] == 0 && vFutureActivity[bcIndex] == 0); + bool noPastActivity = (vPastActivity[bcIndex] == 0); + + // ### count tracks of different types + int nPVtracks = 0; + int nGlobalTracks = 0; + // int nTOFtracks = 0; + auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); + for (const auto& track : tracksGrouped) { + if (!track.isPVContributor()) { + continue; + } + if (track.itsNCls() < 5) + continue; + if (track.pt() < 0.2 || track.pt() > 10) + continue; + if (std::abs(track.eta()) > 0.8) + continue; + + nPVtracks++; + // nTOFtracks += track.hasTOF(); + + if (track.hasITS() && track.hasTPC() && track.tpcNClsFound() > 50 && track.tpcNClsCrossedRows() > 50 && track.tpcChi2NCl() < 4) + nGlobalTracks++; + } // end of track loop + + bool hasFT0 = foundBC.has_ft0(); + bool hasFV0A = foundBC.has_fv0a(); + + // bool noFT0activityNearby = false; + bool noFT0activityNearby = (vNearbyFT0activity[bcIndex] == 0); + // check kIsFlangeEvent + if (hasFT0) { + std::bitset<8> triggers = foundBC.ft0().triggerMask(); + if (triggers[o2::ft0::RecPoints::ETriggerBits::kIsFlangeEvent]) + noFT0activityNearby = false; + } + + float vZ = col.posZ(); + float vZft0 = hasFT0 ? foundBC.ft0().posZ() : -1000; + float diffVz = vZft0 - vZ; + + float multV0A = hasFV0A ? col.multFV0A() : 0; + float multT0A = hasFT0 ? col.multFT0A() : 0; + float multT0C = hasFT0 ? col.multFT0C() : 0; + + float multT0M = multT0A + multT0C; + // bool badVzDiff = col.selection_bit(kIsGoodZvtxFT0vsPV); + // bool badVzDiff = hasFT0 && (multT0M > 5000) && (diffVz < -2.5 || diffVz > 2.5); + float meanDiff = 0.0; // cm + // O-O + if (lastRunNumber == 564356) + meanDiff = -0.01; + if (lastRunNumber == 564359) + meanDiff = -0.17; + if (lastRunNumber == 564373) + meanDiff = 0.99; + if (lastRunNumber == 564374) + meanDiff = 0.57; + // Ne-Ne + if (lastRunNumber == 564468) + meanDiff = -0.51; + if (lastRunNumber == 564468) + meanDiff = -0.60; + + // float stdDev = (multT0M > 20) ? 0.54 + 6.46 / sqrt(multT0M) : 2.0; // cm + float stdDev = (multT0M > 10) ? 0.144723 + 13.5345 / sqrt(multT0M) : 1.5; // cm + if (multT0M > 4000) + stdDev = 0.35; // cm + bool badVzDiff = diffVz < (meanDiff - stdDev * nSigmaForVzDiff - safetyDiffMargin) || diffVz > (meanDiff + stdDev * nSigmaForVzDiff + safetyDiffMargin); + + bool underLine = false; + if (hasFT0 && nPVtracks < 45. / 40000 * multV0A - 4 && nPVtracks < 20) { + underLine = true; + } + bool grassOnTheRight = false; + if (hasFT0 && nPVtracks < 220. / 40000 * multV0A - 100 && nPVtracks >= 25) { + grassOnTheRight = true; + } + + // study bc diff: + int nContributors = col.numContrib(); + float timeRes = col.collisionTimeRes(); + // int64_t bcInTF = (globalBC - bcSOR) % nBCsPerTF; + // if (col.selection_bit(kIsVertexTOFmatched)) { + // histos.fill(HIST("hColBcDiffVsNcontribWithTOF"), nContributors, bcToClosestTVXdiff); + // histos.fill(HIST("hColTimeResVsNcontribWithTOF"), nContributors, timeRes); + // histos.fill(HIST("hBcColTOF"), localBC); + // } + + histos.fill(HIST("noSpecSelections/hBcColNoSel8"), localBC); + + if (noPU) { + histos.fill(HIST("noPU/hBcColNoSel8"), localBC); + } + if (noPU && pvTOFmatched) { + histos.fill(HIST("noPU_pvTOFmatched/hBcColNoSel8"), localBC); + } + if (bcDiffCut) { + histos.fill(HIST("bcDiffCut/hBcColNoSel8"), localBC); + } + if (noPastActivity) { + histos.fill(HIST("noPastActivity/hBcColNoSel8"), localBC); + } + if (noFT0activityNearby) { + histos.fill(HIST("noFT0activityNearby/hBcColNoSel8"), localBC); + } + if (badVzDiff) { + histos.fill(HIST("badVzDiff/hBcColNoSel8"), localBC); + } + if (noPU && !badVzDiff) { + histos.fill(HIST("noPU_goodVzDiff/hBcColNoSel8"), localBC); + } + if (narrowTimeVeto) { + histos.fill(HIST("narrowTimeVeto/hBcColNoSel8"), localBC); + } + if (strictTimeVeto) { + histos.fill(HIST("strictTimeVeto/hBcColNoSel8"), localBC); + } + if (noCollSameROF) { + histos.fill(HIST("noCollSameROF/hBcColNoSel8"), localBC); + } + if (noPU && underLine) { + histos.fill(HIST("noPU_LowMultCut/hBcColNoSel8"), localBC); + } + if (noPU && grassOnTheRight) { + histos.fill(HIST("noPU_HighMultCloudCut/hBcColNoSel8"), localBC); + } + if (noPU && pvTOFmatched && !badVzDiff) { // noPileup_cutByVzDiff_pvTOF_noFT0act + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hBcColNoSel8"), localBC); + } + + // only here cut on sel8: + if (!col.sel8()) + continue; + + // vs time + histos.fill(HIST("hSecondsCollisions/sel8"), secFromSOR); + if (noPU) { + histos.fill(HIST("hSecondsCollisions/noPU"), secFromSOR); + if (underLine) + histos.fill(HIST("hSecondsCollisions/noPU_underLine"), secFromSOR); + if (grassOnTheRight) + histos.fill(HIST("hSecondsCollisions/noPU_grassOnTheRight"), secFromSOR); + if (!underLine && !grassOnTheRight) + histos.fill(HIST("hSecondsCollisions/noPU_good"), secFromSOR); + } + + histos.fill(HIST("noSpecSelections/hBcTVX"), localBC); + histos.fill(HIST("noSpecSelections/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noSpecSelections/hColTimeResVsNcontrib"), nContributors, timeRes); + + if (noPU) { + histos.fill(HIST("noPU/hBcTVX"), localBC); + histos.fill(HIST("noPU/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noPU/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (noPU && pvTOFmatched) { + histos.fill(HIST("noPU_pvTOFmatched/hBcTVX"), localBC); + histos.fill(HIST("noPU_pvTOFmatched/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noPU_pvTOFmatched/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (bcDiffCut) { + histos.fill(HIST("bcDiffCut/hBcTVX"), localBC); + histos.fill(HIST("bcDiffCut/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("bcDiffCut/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (noPastActivity) { + histos.fill(HIST("noPastActivity/hBcTVX"), localBC); + histos.fill(HIST("noPastActivity/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noPastActivity/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (noFT0activityNearby) { + histos.fill(HIST("noFT0activityNearby/hBcTVX"), localBC); + histos.fill(HIST("noFT0activityNearby/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noFT0activityNearby/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (badVzDiff) { + histos.fill(HIST("badVzDiff/hBcTVX"), localBC); + histos.fill(HIST("badVzDiff/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("badVzDiff/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (noPU && !badVzDiff) { + histos.fill(HIST("noPU_goodVzDiff/hBcTVX"), localBC); + histos.fill(HIST("noPU_goodVzDiff/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noPU_goodVzDiff/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (narrowTimeVeto) { + histos.fill(HIST("narrowTimeVeto/hBcTVX"), localBC); + histos.fill(HIST("narrowTimeVeto/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("narrowTimeVeto/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (strictTimeVeto) { + histos.fill(HIST("strictTimeVeto/hBcTVX"), localBC); + histos.fill(HIST("strictTimeVeto/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("strictTimeVeto/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (noCollSameROF) { + histos.fill(HIST("noCollSameROF/hBcTVX"), localBC); + histos.fill(HIST("noCollSameROF/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noCollSameROF/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (noPU && underLine) { + histos.fill(HIST("noPU_LowMultCut/hBcTVX"), localBC); + histos.fill(HIST("noPU_LowMultCut/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noPU_LowMultCut/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (noPU && grassOnTheRight) { + histos.fill(HIST("noPU_HighMultCloudCut/hBcTVX"), localBC); + histos.fill(HIST("noPU_HighMultCloudCut/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noPU_HighMultCloudCut/hColTimeResVsNcontrib"), nContributors, timeRes); + } + if (noPU && pvTOFmatched && !badVzDiff) { // noPileup_cutByVzDiff_pvTOF_noFT0act + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hBcTVX"), localBC); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hColBcDiffVsNcontrib"), nContributors, bcToClosestTVXdiff); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hColTimeResVsNcontrib"), nContributors, timeRes); + } + + if (foundBC.has_ft0()) { + // float multT0A = foundBC.has_ft0() ? foundBC.ft0().sumAmpA() : -999.f; + // float multT0C = foundBC.has_ft0() ? foundBC.ft0().sumAmpC() : -999.f; + + histos.fill(HIST("noSpecSelections/hBcFT0"), localBC); + histos.fill(HIST("noSpecSelections/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noSpecSelections/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noSpecSelections/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noSpecSelections/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noSpecSelections/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noSpecSelections/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + + if (noPU) { + histos.fill(HIST("noPU/hBcFT0"), localBC); + histos.fill(HIST("noPU/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noPU/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noPU/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noPU/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noPU/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noPU/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (noPU && pvTOFmatched) { + histos.fill(HIST("noPU_pvTOFmatched/hBcFT0"), localBC); + histos.fill(HIST("noPU_pvTOFmatched/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noPU_pvTOFmatched/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noPU_pvTOFmatched/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noPU_pvTOFmatched/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noPU_pvTOFmatched/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noPU_pvTOFmatched/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (bcDiffCut) { + histos.fill(HIST("bcDiffCut/hBcFT0"), localBC); + histos.fill(HIST("bcDiffCut/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("bcDiffCut/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("bcDiffCut/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("bcDiffCut/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("bcDiffCut/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("bcDiffCut/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (badVzDiff) { + histos.fill(HIST("badVzDiff/hBcFT0"), localBC); + histos.fill(HIST("badVzDiff/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("badVzDiff/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("badVzDiff/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("badVzDiff/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("badVzDiff/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("badVzDiff/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (noPU && !badVzDiff) { + histos.fill(HIST("noPU_goodVzDiff/hBcFT0"), localBC); + histos.fill(HIST("noPU_goodVzDiff/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noPU_goodVzDiff/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noPU_goodVzDiff/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noPU_goodVzDiff/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noPU_goodVzDiff/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noPU_goodVzDiff/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (noPastActivity) { + histos.fill(HIST("noPastActivity/hBcFT0"), localBC); + histos.fill(HIST("noPastActivity/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noPastActivity/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noPastActivity/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noPastActivity/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noPastActivity/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noPastActivity/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (noFT0activityNearby) { + histos.fill(HIST("noFT0activityNearby/hBcFT0"), localBC); + histos.fill(HIST("noFT0activityNearby/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noFT0activityNearby/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noFT0activityNearby/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noFT0activityNearby/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noFT0activityNearby/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noFT0activityNearby/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (narrowTimeVeto) { + histos.fill(HIST("narrowTimeVeto/hBcFT0"), localBC); + histos.fill(HIST("narrowTimeVeto/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("narrowTimeVeto/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("narrowTimeVeto/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("narrowTimeVeto/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("narrowTimeVeto/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("narrowTimeVeto/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (strictTimeVeto) { + histos.fill(HIST("strictTimeVeto/hBcFT0"), localBC); + histos.fill(HIST("strictTimeVeto/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("strictTimeVeto/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("strictTimeVeto/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("strictTimeVeto/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("strictTimeVeto/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("strictTimeVeto/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (noCollSameROF) { + histos.fill(HIST("noCollSameROF/hBcFT0"), localBC); + histos.fill(HIST("noCollSameROF/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noCollSameROF/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noCollSameROF/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noCollSameROF/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noCollSameROF/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noCollSameROF/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (noPU && underLine) { + histos.fill(HIST("noPU_LowMultCut/hBcFT0"), localBC); + histos.fill(HIST("noPU_LowMultCut/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noPU_LowMultCut/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noPU_LowMultCut/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noPU_LowMultCut/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noPU_LowMultCut/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noPU_LowMultCut/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (noPU && grassOnTheRight) { + histos.fill(HIST("noPU_HighMultCloudCut/hBcFT0"), localBC); + histos.fill(HIST("noPU_HighMultCloudCut/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noPU_HighMultCloudCut/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noPU_HighMultCloudCut/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noPU_HighMultCloudCut/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noPU_HighMultCloudCut/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noPU_HighMultCloudCut/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + if (noPU && pvTOFmatched && !badVzDiff) { // noPileup_cutByVzDiff_pvTOF_noFT0act + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hBcFT0"), localBC); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hVtxFT0VsVtxCol"), vZft0, vZ); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hVtxFT0MinusVtxColVsMultT0M"), diffVz, multT0A + multT0C); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/nTracksPV_vs_T0A"), multT0A, nPVtracks); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/nTracksGlobal_vs_T0A"), multT0A, nGlobalTracks); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/nTracksPV_vs_T0C"), multT0C, nPVtracks); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/nTracksGlobal_vs_T0C"), multT0C, nGlobalTracks); + } + } + + if (foundBC.has_fv0a()) { + histos.fill(HIST("noSpecSelections/hBcFV0"), localBC); + histos.fill(HIST("noSpecSelections/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noSpecSelections/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + if (noPU) { + histos.fill(HIST("noPU/hBcFV0"), localBC); + histos.fill(HIST("noPU/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noPU/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (noPU && pvTOFmatched) { + histos.fill(HIST("noPU_pvTOFmatched/hBcFV0"), localBC); + histos.fill(HIST("noPU_pvTOFmatched/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noPU_pvTOFmatched/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (bcDiffCut) { + histos.fill(HIST("bcDiffCut/hBcFV0"), localBC); + histos.fill(HIST("bcDiffCut/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("bcDiffCut/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (badVzDiff) { + histos.fill(HIST("badVzDiff/hBcFV0"), localBC); + histos.fill(HIST("badVzDiff/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("badVzDiff/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (noPU && !badVzDiff) { + histos.fill(HIST("noPU_goodVzDiff/hBcFV0"), localBC); + histos.fill(HIST("noPU_goodVzDiff/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noPU_goodVzDiff/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (noPastActivity) { + histos.fill(HIST("noPastActivity/hBcFV0"), localBC); + histos.fill(HIST("noPastActivity/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noPastActivity/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (noFT0activityNearby) { + histos.fill(HIST("noFT0activityNearby/hBcFV0"), localBC); + histos.fill(HIST("noFT0activityNearby/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noFT0activityNearby/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (narrowTimeVeto) { + histos.fill(HIST("narrowTimeVeto/hBcFV0"), localBC); + histos.fill(HIST("narrowTimeVeto/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("narrowTimeVeto/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (strictTimeVeto) { + histos.fill(HIST("strictTimeVeto/hBcFV0"), localBC); + histos.fill(HIST("strictTimeVeto/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("strictTimeVeto/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (noCollSameROF) { + histos.fill(HIST("noCollSameROF/hBcFV0"), localBC); + histos.fill(HIST("noCollSameROF/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noCollSameROF/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (noPU && underLine) { + histos.fill(HIST("noPU_LowMultCut/hBcFV0"), localBC); + histos.fill(HIST("noPU_LowMultCut/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noPU_LowMultCut/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (noPU && grassOnTheRight) { + histos.fill(HIST("noPU_HighMultCloudCut/hBcFV0"), localBC); + histos.fill(HIST("noPU_HighMultCloudCut/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noPU_HighMultCloudCut/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + if (noPU && pvTOFmatched && !badVzDiff) { // noPileup_cutByVzDiff_pvTOF_noFT0act + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hBcFV0"), localBC); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/nTracksPV_vs_V0A"), multV0A, nPVtracks); + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/nTracksGlobal_vs_V0A"), multV0A, nGlobalTracks); + } + } + if (foundBC.has_zdc()) { + histos.fill(HIST("noSpecSelections/hBcZDC"), localBC); + if (noPU) { + histos.fill(HIST("noPU/hBcZDC"), localBC); + } + if (noPU && pvTOFmatched) { + histos.fill(HIST("noPU_pvTOFmatched/hBcZDC"), localBC); + } + if (bcDiffCut) { + histos.fill(HIST("bcDiffCut/hBcZDC"), localBC); + } + if (badVzDiff) { + histos.fill(HIST("badVzDiff/hBcZDC"), localBC); + } + if (noPU && !badVzDiff) { + histos.fill(HIST("noPU_goodVzDiff/hBcZDC"), localBC); + } + if (noPastActivity) { + histos.fill(HIST("noPastActivity/hBcZDC"), localBC); + } + if (noFT0activityNearby) { + histos.fill(HIST("noFT0activityNearby/hBcZDC"), localBC); + } + if (narrowTimeVeto) { + histos.fill(HIST("narrowTimeVeto/hBcZDC"), localBC); + } + if (strictTimeVeto) { + histos.fill(HIST("strictTimeVeto/hBcZDC"), localBC); + } + if (noCollSameROF) { + histos.fill(HIST("noCollSameROF/hBcZDC"), localBC); + } + if (noPU && underLine) { + histos.fill(HIST("noPU_LowMultCut/hBcZDC"), localBC); + } + if (noPU && grassOnTheRight) { + histos.fill(HIST("noPU_HighMultCloudCut/hBcZDC"), localBC); + } + if (noPU && pvTOFmatched && !badVzDiff) { // noPileup_cutByVzDiff_pvTOF_noFT0act + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hBcZDC"), localBC); + } + } + + // bc diff + // auto bc = col.bc_as(); + auto bcOriginal = globalOrigBC % 3564; + float bcDiff = bcOriginal - localBC; + + histos.fill(HIST("noSpecSelections/hTVXvsBcDiff"), bcDiff); + if (noPU) { + histos.fill(HIST("noPU/hTVXvsBcDiff"), bcDiff); + } + if (noPU && pvTOFmatched) { + histos.fill(HIST("noPU_pvTOFmatched/hTVXvsBcDiff"), bcDiff); + } + if (bcDiffCut) { + histos.fill(HIST("bcDiffCut/hTVXvsBcDiff"), bcDiff); + } + if (badVzDiff) { + histos.fill(HIST("badVzDiff/hTVXvsBcDiff"), bcDiff); + } + if (noPU && !badVzDiff) { + histos.fill(HIST("noPU_goodVzDiff/hTVXvsBcDiff"), bcDiff); + } + if (noPastActivity) { + histos.fill(HIST("noPastActivity/hTVXvsBcDiff"), bcDiff); + } + if (noFT0activityNearby) { + histos.fill(HIST("noFT0activityNearby/hTVXvsBcDiff"), bcDiff); + } + if (narrowTimeVeto) { + histos.fill(HIST("narrowTimeVeto/hTVXvsBcDiff"), bcDiff); + } + if (strictTimeVeto) { + histos.fill(HIST("strictTimeVeto/hTVXvsBcDiff"), bcDiff); + } + if (noCollSameROF) { + histos.fill(HIST("noCollSameROF/hTVXvsBcDiff"), bcDiff); + } + if (noPU && underLine) { + histos.fill(HIST("noPU_LowMultCut/hTVXvsBcDiff"), bcDiff); + } + if (noPU && grassOnTheRight) { + histos.fill(HIST("noPU_HighMultCloudCut/hTVXvsBcDiff"), bcDiff); + } + if (noPU && pvTOFmatched && !badVzDiff) { // noPileup_cutByVzDiff_pvTOF_noFT0act + histos.fill(HIST("noPU_cutByVzDiff_pvTOF/hTVXvsBcDiff"), bcDiff); + } + + } // end of collisions loop + } + PROCESS_SWITCH(LightIonsEvSelQa, processRun3, "Process Run3 tracking vs detector occupancy QA", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/DPG/Tasks/AOTEvent/matchingQa.cxx b/DPG/Tasks/AOTEvent/matchingQa.cxx index b59b8faba0c..3b266f047e9 100644 --- a/DPG/Tasks/AOTEvent/matchingQa.cxx +++ b/DPG/Tasks/AOTEvent/matchingQa.cxx @@ -27,7 +27,7 @@ using FullTracksIUwithLabels = soa::Join ccdb; diff --git a/DPG/Tasks/AOTEvent/mshapeQa.cxx b/DPG/Tasks/AOTEvent/mshapeQa.cxx deleted file mode 100644 index 38f3910da21..00000000000 --- a/DPG/Tasks/AOTEvent/mshapeQa.cxx +++ /dev/null @@ -1,189 +0,0 @@ -// 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. - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "CCDB/BasicCCDBManager.h" -#include "Framework/HistogramRegistry.h" -#include "TPCCalibration/TPCMShapeCorrection.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "DataFormatsParameters/GRPECSObject.h" - -#include "TTree.h" - -using namespace o2; -using namespace o2::framework; -using BCsRun3 = soa::Join; -using BarrelTracks = soa::Join; -const AxisSpec axisQoverPt{100, -5., 5., "q/p_{T}, 1/GeV"}; -const AxisSpec axisDcaR{1000, -5., 5., "DCA_{r}, cm"}; -const AxisSpec axisDcaZ{1000, -5., 5., "DCA_{z}, cm"}; -const AxisSpec axisSparseQoverPt{20, -5., 5., "q/p_{T}, 1/GeV"}; -const AxisSpec axisSparseDcaR{100, -5., 5., "DCA_{r}, cm"}; -const AxisSpec axisSparseDcaZ{100, -5., 5., "DCA_{z}, cm"}; - -struct MshapeQaTask { - Configurable confTimeBinWidthInSec{"TimeBinWidthInSec", 0.1, "Width of time bins in seconds"}; - Service ccdb; - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - o2::tpc::TPCMShapeCorrection mshape; // object for simple access - int lastRunNumber = -1; - double maxSec = 1; - double minSec = 0; - void init(InitContext&) - { - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - histos.add("hQoverPt", "", kTH1F, {axisQoverPt}); - histos.add("hDcaR", "", kTH1F, {axisDcaR}); - histos.add("hDcaZ", "", kTH1F, {axisDcaZ}); - histos.add("hQoverPtDcaR", "", kTH2F, {axisSparseQoverPt, axisSparseDcaR}); - histos.add("hQoverPtDcaZ", "", kTH2F, {axisSparseQoverPt, axisSparseDcaZ}); - } - - void process(aod::Collision const& col, BCsRun3 const& bcs, BarrelTracks const& tracks) - { - int runNumber = bcs.iteratorAt(0).runNumber(); - if (runNumber != lastRunNumber) { - lastRunNumber = runNumber; - std::map metadata; - metadata["runNumber"] = Form("%d", runNumber); - auto grpecs = ccdb->getSpecific("GLO/Config/GRPECS", bcs.iteratorAt(0).timestamp(), metadata); - minSec = floor(grpecs->getTimeStart() / 1000.); - maxSec = ceil(grpecs->getTimeEnd() / 1000.); - int nTimeBins = static_cast((maxSec - minSec) / confTimeBinWidthInSec); - double timeInterval = nTimeBins * confTimeBinWidthInSec; - const AxisSpec axisSeconds{nTimeBins, 0, timeInterval, "seconds"}; - histos.add("hSecondsAsideQoverPtSumDcaR", "", kTH2F, {axisSeconds, axisSparseQoverPt}); - histos.add("hSecondsAsideQoverPtSumDcaZ", "", kTH2F, {axisSeconds, axisSparseQoverPt}); - histos.add("hSecondsCsideQoverPtSumDcaR", "", kTH2F, {axisSeconds, axisSparseQoverPt}); - histos.add("hSecondsCsideQoverPtSumDcaZ", "", kTH2F, {axisSeconds, axisSparseQoverPt}); - histos.add("hSecondsQoverPtSumDcaR", "", kTH2F, {axisSeconds, axisSparseQoverPt}); - histos.add("hSecondsQoverPtSumDcaZ", "", kTH2F, {axisSeconds, axisSparseQoverPt}); - - histos.add("hSecondsAsideSumDcaR", "", kTH1F, {axisSeconds}); - histos.add("hSecondsAsideSumDcaZ", "", kTH1F, {axisSeconds}); - histos.add("hSecondsCsideSumDcaR", "", kTH1F, {axisSeconds}); - histos.add("hSecondsCsideSumDcaZ", "", kTH1F, {axisSeconds}); - histos.add("hSecondsSumDcaR", "", kTH1F, {axisSeconds}); - histos.add("hSecondsSumDcaZ", "", kTH1F, {axisSeconds}); - histos.add("hSecondsTracks", "", kTH1F, {axisSeconds}); - histos.add("hSecondsTracksMshape", "", kTH1F, {axisSeconds}); - histos.add("hSecondsAsideITSTPCcontrib", "", kTH1F, {axisSeconds}); - histos.add("hSecondsCsideITSTPCcontrib", "", kTH1F, {axisSeconds}); - histos.add("hSecondsCollisions", "", kTH1F, {axisSeconds}); - - const AxisSpec axisPhi{64, 0, TMath::TwoPi(), "#varphi"}; - histos.add("hSecondsITSlayer0vsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITSlayer1vsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITSlayer2vsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITSlayer3vsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITSlayer4vsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITSlayer5vsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITSlayer6vsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITS7clsVsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITSglobalVsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITSTRDVsPhi", "", kTH2F, {axisSeconds, axisPhi}); - histos.add("hSecondsITSTOFVsPhi", "", kTH2F, {axisSeconds, axisPhi}); - } - - int64_t ts = col.bc_as().timestamp(); - auto mShapeTree = ccdb->getForTimeStamp("TPC/Calib/MShapePotential", ts); - mshape.setFromTree(*mShapeTree); - bool isMshape = !mshape.getBoundaryPotential(ts).mPotential.empty(); - - double secFromSOR = ts / 1000. - minSec; - - int nAsideITSTPCContrib = 0; - int nCsideITSTPCContrib = 0; - for (const auto& track : tracks) { - if (!track.hasTPC() || !track.hasITS()) { - continue; - } - float qpt = track.signed1Pt(); - float dcaR = track.dcaXY(); - float dcaZ = track.dcaZ(); - LOGP(debug, "dcaR = {} dcaZ = {}", dcaR, dcaZ); - histos.fill(HIST("hQoverPt"), qpt); - histos.fill(HIST("hDcaR"), dcaR); - histos.fill(HIST("hDcaZ"), dcaZ); - histos.fill(HIST("hQoverPtDcaR"), qpt, dcaR); - histos.fill(HIST("hQoverPtDcaZ"), qpt, dcaZ); - histos.fill(HIST("hSecondsSumDcaR"), secFromSOR, dcaR); - histos.fill(HIST("hSecondsSumDcaZ"), secFromSOR, dcaZ); - histos.fill(HIST("hSecondsQoverPtSumDcaR"), secFromSOR, qpt, dcaR); - histos.fill(HIST("hSecondsQoverPtSumDcaZ"), secFromSOR, qpt, dcaZ); - histos.fill(HIST("hSecondsTracks"), secFromSOR); - if (track.tgl() > 0.) { - histos.fill(HIST("hSecondsAsideQoverPtSumDcaR"), secFromSOR, qpt, dcaR); - histos.fill(HIST("hSecondsAsideQoverPtSumDcaZ"), secFromSOR, qpt, dcaZ); - histos.fill(HIST("hSecondsAsideSumDcaR"), secFromSOR, dcaR); - histos.fill(HIST("hSecondsAsideSumDcaZ"), secFromSOR, dcaZ); - - } else { - histos.fill(HIST("hSecondsCsideQoverPtSumDcaR"), secFromSOR, qpt, dcaR); - histos.fill(HIST("hSecondsCsideQoverPtSumDcaZ"), secFromSOR, qpt, dcaZ); - histos.fill(HIST("hSecondsCsideSumDcaR"), secFromSOR, dcaR); - histos.fill(HIST("hSecondsCsideSumDcaZ"), secFromSOR, dcaZ); - } - if (isMshape) { - histos.fill(HIST("hSecondsTracksMshape"), secFromSOR); - } - if (track.isPVContributor()) { - if (track.tgl() > 0.) { - nAsideITSTPCContrib++; - } else { - nCsideITSTPCContrib++; - } - - // select straight tracks - if (track.pt() < 1) { - continue; - } - // study ITS cluster pattern vs sec - if (track.itsClusterMap() & (1 << 0)) - histos.fill(HIST("hSecondsITSlayer0vsPhi"), secFromSOR, track.phi()); - if (track.itsClusterMap() & (1 << 1)) - histos.fill(HIST("hSecondsITSlayer1vsPhi"), secFromSOR, track.phi()); - if (track.itsClusterMap() & (1 << 2)) - histos.fill(HIST("hSecondsITSlayer2vsPhi"), secFromSOR, track.phi()); - if (track.itsClusterMap() & (1 << 3)) - histos.fill(HIST("hSecondsITSlayer3vsPhi"), secFromSOR, track.phi()); - if (track.itsClusterMap() & (1 << 4)) - histos.fill(HIST("hSecondsITSlayer4vsPhi"), secFromSOR, track.phi()); - if (track.itsClusterMap() & (1 << 5)) - histos.fill(HIST("hSecondsITSlayer5vsPhi"), secFromSOR, track.phi()); - if (track.itsClusterMap() & (1 << 6)) - histos.fill(HIST("hSecondsITSlayer6vsPhi"), secFromSOR, track.phi()); - if (track.itsNCls() == 7) - histos.fill(HIST("hSecondsITS7clsVsPhi"), secFromSOR, track.phi()); - if (track.hasITS() && track.hasTPC()) - histos.fill(HIST("hSecondsITSglobalVsPhi"), secFromSOR, track.phi()); - if (track.hasTRD()) - histos.fill(HIST("hSecondsITSTRDVsPhi"), secFromSOR, track.phi()); - if (track.hasTOF()) - histos.fill(HIST("hSecondsITSTOFVsPhi"), secFromSOR, track.phi()); - } - } - histos.fill(HIST("hSecondsCollisions"), secFromSOR); - histos.fill(HIST("hSecondsAsideITSTPCcontrib"), secFromSOR, nAsideITSTPCContrib); - histos.fill(HIST("hSecondsCsideITSTPCcontrib"), secFromSOR, nCsideITSTPCContrib); - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/DPG/Tasks/AOTEvent/rofOccupancyQa.cxx b/DPG/Tasks/AOTEvent/rofOccupancyQa.cxx index 76bf7e87741..cbc8d7d56d1 100644 --- a/DPG/Tasks/AOTEvent/rofOccupancyQa.cxx +++ b/DPG/Tasks/AOTEvent/rofOccupancyQa.cxx @@ -8,6 +8,12 @@ // 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. + +/// \file rofOccupancyQa.cxx +/// \brief ROF occupancy QA task +/// +/// \author Igor Altsybeev + #include #include "Framework/ConfigParamSpec.h" @@ -33,18 +39,16 @@ const double bcNS = o2::constants::lhc::LHCBunchSpacingNS; struct RofOccupancyQaTask { // configurables for occupancy-based event selection - Configurable confTimeIntervalForOccupancyCalculationMin{"TimeIntervalForOccupancyCalculationMin", -40, "Min time diff window for TPC occupancy calculation, us"}; - Configurable confTimeIntervalForOccupancyCalculationMax{"TimeIntervalForOccupancyCalculationMax", 100, "Max time diff window for TPC occupancy calculation, us"}; - Configurable confTimeRangeVetoOnCollStandard{"TimeRangeVetoOnCollStandard", 10.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; - Configurable confTimeRangeVetoOnCollNarrow{"TimeRangeVetoOnCollNarrow", 2.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; - Configurable confNtracksCutVetoOnCollInTimeRange{"NtracksCutVetoOnCollInTimeRange", 800, "Max allowed N tracks (PV contributors) for each nearby collision in +/- time range"}; - Configurable confEpsilonDistanceForVzDependentVetoTPC{"EpsilonDistanceForVzDependentVetoTPC", 2.5, "Epsilon for vZ-dependent veto on drifting TPC tracks from nearby collisions, cm"}; - // Configurable confNtracksCutVetoOnCollInROF{"NtracksCutVetoOnCollInROF", 500, "Max allowed N tracks (PV contributors) for each nearby collision inside this ITS ROF"}; - Configurable confFT0CamplCutVetoOnCollInROF{"FT0CamplPerCollCutVetoOnCollInROF", 5000, "Max allowed FT0C amplitude for each nearby collision inside this ITS ROF"}; - Configurable confEpsilonVzDiffVetoInROF{"EpsilonVzDiffVetoInROF", 0.3, "Minumum distance to nearby collisions along z inside this ITS ROF, cm"}; - Configurable confUseWeightsForOccupancyVariable{"UseWeightsForOccupancyEstimator", 1, "Use or not the delta-time weights for the occupancy estimator"}; - - Configurable confFactorForHistRange{"kFactorForHistRange", 1.0, "To change axes b/n pp and Pb-Pb"}; + Configurable confTimeIntervalForOccupancyCalculationMin{"TimeIntervalForOccupancyCalculationMin", -40, "Min time diff window for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable + Configurable confTimeIntervalForOccupancyCalculationMax{"TimeIntervalForOccupancyCalculationMax", 100, "Max time diff window for TPC occupancy calculation, us"}; // o2-linter: disable=name/configurable + Configurable confTimeRangeVetoOnCollStandard{"TimeRangeVetoOnCollStandard", 10.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; // o2-linter: disable=name/configurable + Configurable confTimeRangeVetoOnCollNarrow{"TimeRangeVetoOnCollNarrow", 2.0, "Exclusion of a collision if there are other collisions nearby, +/- us"}; // o2-linter: disable=name/configurable + Configurable confNtracksCutVetoOnCollInTimeRange{"NtracksCutVetoOnCollInTimeRange", 800, "Max allowed N tracks (PV contributors) for each nearby collision in +/- time range"}; // o2-linter: disable=name/configurable + Configurable confEpsilonDistanceForVzDependentVetoTPC{"EpsilonDistanceForVzDependentVetoTPC", 2.5, "Epsilon for vZ-dependent veto on drifting TPC tracks from nearby collisions, cm"}; // o2-linter: disable=name/configurable + Configurable confFT0CamplCutVetoOnCollInROF{"FT0CamplPerCollCutVetoOnCollInROF", 5000, "Max allowed FT0C amplitude for each nearby collision inside this ITS ROF"}; // o2-linter: disable=name/configurable + Configurable confEpsilonVzDiffVetoInROF{"EpsilonVzDiffVetoInROF", 0.3, "Minumum distance to nearby collisions along z inside this ITS ROF, cm"}; // o2-linter: disable=name/configurable + Configurable confUseWeightsForOccupancyVariable{"UseWeightsForOccupancyEstimator", 1, "Use or not the delta-time weights for the occupancy estimator"}; // o2-linter: disable=name/configurable + Configurable confFactorForHistRange{"kFactorForHistRange", 1.0, "To change axes b/n pp and Pb-Pb"}; // o2-linter: disable=name/configurable Service ccdb; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -108,7 +112,6 @@ struct RofOccupancyQaTask { histos.add("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_afterNarrowDeltaTimeCut", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); histos.add("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_afterStrictDeltaTimeCut", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); histos.add("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_afterStandardDeltaTimeCut", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); - histos.add("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_afterVzDependentDeltaTimeCut", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); histos.add("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_kNoCollInRofStrict", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); histos.add("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_kNoCollInRofStandard", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); @@ -346,7 +349,6 @@ struct RofOccupancyQaTask { histos.add("nPV_vs_occupancyByTracks/NoCollInTimeRangeNarrow", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 25000 * k}}); histos.add("nPV_vs_occupancyByTracks/NoCollInTimeRangeStrict", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 25000 * k}}); histos.add("nPV_vs_occupancyByTracks/NoCollInTimeRangeStandard", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 25000 * k}}); - histos.add("nPV_vs_occupancyByTracks/NoCollInTimeRangeVzDependent", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 25000 * k}}); histos.add("nPV_vs_occupancyByTracks/NoCollInRofStrict", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 25000 * k}}); histos.add("nPV_vs_occupancyByTracks/NoCollInRofStandard", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 25000 * k}}); histos.add("nPV_vs_occupancyByTracks/NoCollInTimeAndRofStandard", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 25000 * k}}); @@ -359,7 +361,6 @@ struct RofOccupancyQaTask { histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeRangeNarrow", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeRangeStrict", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeRangeStandard", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); - histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeRangeVzDependent", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); histos.add("nPV_vs_occupancyByFT0C/NoCollInRofStrict", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); histos.add("nPV_vs_occupancyByFT0C/NoCollInRofStandard", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeAndRofStandard", "", kTH2D, {{125, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); @@ -419,7 +420,7 @@ struct RofOccupancyQaTask { std::vector vCollRofSubIdPerOrbit(cols.size(), 0); // rof sub-Id for each collision, per orbit // first loop over collisions - collecting info - for (auto& col : cols) { + for (const auto& col : cols) { int32_t colIndex = col.globalIndex(); // auto bc = col.bc_as(); const auto& bc = col.foundBC_as(); @@ -434,9 +435,9 @@ struct RofOccupancyQaTask { vCollVz[colIndex] = col.posZ(); vIsSel8[colIndex] = col.sel8(); - vCombCond[colIndex] = vIsSel8[colIndex] && (fabs(vCollVz[colIndex]) < 8) && (vAmpFT0CperColl[colIndex] > 500 /* a.u.*/); + vCombCond[colIndex] = vIsSel8[colIndex] && (std::fabs(vCollVz[colIndex]) < 8) && (vAmpFT0CperColl[colIndex] > 500 /* a.u.*/); - int bcInTF = col.bcInTF(); //(bc.globalBC() - bcSOR) % nBCsPerTF; + int bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; vIsFullInfoForOccupancy[colIndex] = ((bcInTF - 300) * bcNS > -timeWinOccupancyCalcMinNS) && ((nBCsPerTF - 4000 - bcInTF) * bcNS > timeWinOccupancyCalcMaxNS) ? true : false; // int64_t rofId = (globalBC + 3564 - rofOffset) / rofLength; @@ -454,14 +455,14 @@ struct RofOccupancyQaTask { auto colPvTracks = pvTracks.sliceBy(perCollision, col.globalIndex()); - for (auto& track : colPvTracks) { + for (const auto& track : colPvTracks) { if (track.itsNCls() >= 5) { vTracksITS567perColl[colIndex]++; - if (fabs(track.eta()) < 0.8) + if (std::fabs(track.eta()) < 0.8) vTracksITS567eta08perColl[colIndex]++; if (track.tpcNClsFound() > 70) vTracksITSTPCperColl[colIndex]++; - if (fabs(col.posZ()) < 1) + if (std::fabs(col.posZ()) < 1) histos.fill(HIST("hEtaVz02"), track.eta()); else if (col.posZ() > 9.5 && col.posZ() < 10.5) histos.fill(HIST("hEtaVzPlus10"), track.eta()); @@ -491,7 +492,7 @@ struct RofOccupancyQaTask { // ROF-by-ROF study: int nColls = vCombCond.size(); - for (auto& col : cols) { + for (const auto& col : cols) { int32_t k = col.globalIndex(); if (k - 2 < 0 || k + 2 > nColls - 1) @@ -619,13 +620,13 @@ struct RofOccupancyQaTask { std::vector> vCollsInTimeWin; std::vector> vCollsInSameITSROF; std::vector> vTimeDeltaForColls; // delta time wrt a given collision - for (auto& col : cols) { + for (const auto& col : cols) { int32_t colIndex = col.globalIndex(); int64_t foundGlobalBC = vFoundGlobalBC[colIndex]; // int bcInTF = (foundGlobalBC - bcSOR) % nBCsPerTF; // int bcInITSROF = (foundGlobalBC + 3564 - rofOffset) % rofLength; - int64_t TFid = (foundGlobalBC - bcSOR) / nBCsPerTF; + int64_t tfId = (foundGlobalBC - bcSOR) / nBCsPerTF; int64_t rofId = (foundGlobalBC + 3564 - rofOffset) / rofLength; // int rofIdInTF = (bcInTF - rofOffset) / rofLength; @@ -637,7 +638,7 @@ struct RofOccupancyQaTask { int64_t thisBC = vFoundGlobalBC[minColIndex]; // check if this is still the same TF int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; - if (thisTFid != TFid) + if (thisTFid != tfId) break; // int thisRofIdInTF = (thisBC - rofOffset) / rofLength; int64_t thisRofId = (thisBC + 3564 - rofOffset) / rofLength; @@ -653,7 +654,7 @@ struct RofOccupancyQaTask { while (maxColIndex < cols.size()) { int64_t thisBC = vFoundGlobalBC[maxColIndex]; int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; - if (thisTFid != TFid) + if (thisTFid != tfId) break; // int thisRofIdInTF = (thisBC - rofOffset) / rofLength; int64_t thisRofId = (thisBC + 3564 - rofOffset) / rofLength; @@ -679,7 +680,7 @@ struct RofOccupancyQaTask { int64_t thisBC = vFoundGlobalBC[minColIndex]; // check if this is still the same TF int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; - if (thisTFid != TFid) + if (thisTFid != tfId) break; float dt = (thisBC - foundGlobalBC) * bcNS; // ns // check if we are within the chosen time range @@ -694,7 +695,7 @@ struct RofOccupancyQaTask { while (maxColIndex < cols.size()) { int64_t thisBC = vFoundGlobalBC[maxColIndex]; int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; - if (thisTFid != TFid) + if (thisTFid != tfId) break; float dt = (thisBC - foundGlobalBC) * bcNS; // ns if (dt > timeWinOccupancyCalcMaxNS) @@ -727,7 +728,7 @@ struct RofOccupancyQaTask { std::vector vNoCollInSameRofWithCloseVz(cols.size(), 0); // to veto events with nearby collisions with close vZ std::vector> vArrNoCollInSameRofWithCloseVz; //(cols.size(), 0); // to veto events with nearby collisions with close vZ - for (auto& col : cols) { + for (const auto& col : cols) { int32_t colIndex = col.globalIndex(); float vZ = col.posZ(); @@ -757,7 +758,7 @@ struct RofOccupancyQaTask { vInROFcollIndex[colIndex] = 0; vROFidThisColl[colIndex] = rofIdInTF; - if (fabs(vZ) < 10) + if (std::fabs(vZ) < 10) vNumCollinROFinVz10[colIndex] = 1; for (uint32_t iCol = 0; iCol < vAssocToSameROF.size(); iCol++) { int thisColIndex = vAssocToSameROF[iCol]; @@ -769,11 +770,11 @@ struct RofOccupancyQaTask { // LOGP(info, ">> assoc: bc={} bcInTF={} bcInITSROF={} rofId={} noROFborder={}", vFoundGlobalBC[thisColIndex], thisBcInTF, thisBcInITSROF, thisRofId, bcAssoc.selection_bit(kNoITSROFrameBorder)); // LOGP(info, ">> assoc: bcInTF={} bcInITSROF={} rofIdInTF={} noROFborder={} vZ={} mult={}", thisBcInTF, thisBcInITSROF, thisRofIdInTF, bcAssoc.selection_bit(kNoITSROFrameBorder), vCollVz[thisColIndex], vTracksITS567perColl[thisColIndex]); - // if (fabs(vTracksITS567perColl[thisColIndex]) > confNtracksCutVetoOnCollInROF) + // if (std::fabs(vTracksITS567perColl[thisColIndex]) > confNtracksCutVetoOnCollInROF) nITS567tracksForRofVetoStrict += vTracksITS567perColl[thisColIndex]; nSumAmplFT0CforRofVetoStrict += vAmpFT0CperColl[thisColIndex]; vNumCollinROF[colIndex]++; - if (fabs(vCollVz[thisColIndex]) < 10) + if (std::fabs(vCollVz[thisColIndex]) < 10) vNumCollinROFinVz10[colIndex]++; vInROFcollIndex[colIndex] = thisBcInITSROF > bcInITSROF ? 0 : 1; // if colIndex is for the first coll in ROF => inROFindex=0, otherwise =1 @@ -783,18 +784,18 @@ struct RofOccupancyQaTask { if (vAmpFT0CperColl[thisColIndex] > confFT0CamplCutVetoOnCollInROF) nCollsInRofWithFT0CAboveVetoStandard++; - if (fabs(vCollVz[thisColIndex] - vZ) < confEpsilonVzDiffVetoInROF) + if (std::fabs(vCollVz[thisColIndex] - vZ) < confEpsilonVzDiffVetoInROF) nITS567tracksForRofVetoOnCloseVz += vTracksITS567perColl[thisColIndex]; for (int i = 0; i < 200; i++) { - // if (fabs(vCollVz[thisColIndex] - vZ) < 0.05 * i && vTracksITS567perColl[thisColIndex] > 50) + // if (std::fabs(vCollVz[thisColIndex] - vZ) < 0.05 * i && vTracksITS567perColl[thisColIndex] > 50) // if (vTracksITS567perColl[colIndex]>100 && vTracksITS567perColl[colIndex]<1000 && if (vAmpFT0CperColl[colIndex] > 4000 && vAmpFT0CperColl[colIndex] < 15000 && - (vCollVz[thisColIndex] - vZ) > 0.05 * i && fabs(vCollVz[thisColIndex] - vZ) < (0.1 + 0.05) * i && vTracksITS567perColl[thisColIndex] > 20) // 0.05 * (i + 1)) - // fabs(vCollVz[thisColIndex] - vZ) < 0.05 * i && vTracksITS567perColl[thisColIndex] > 30) // 0.05 * (i + 1)) + (vCollVz[thisColIndex] - vZ) > 0.05 * i && std::fabs(vCollVz[thisColIndex] - vZ) < (0.1 + 0.05) * i && vTracksITS567perColl[thisColIndex] > 20) // 0.05 * (i + 1)) + // std::fabs(vCollVz[thisColIndex] - vZ) < 0.05 * i && vTracksITS567perColl[thisColIndex] > 30) // 0.05 * (i + 1)) nArrITS567tracksForRofVetoOnCloseVz[i]++; } - if (fabs(vZ) < 10) { + if (std::fabs(vZ) < 10) { histos.fill(HIST("hDeltaVz"), vCollVz[thisColIndex] - vZ); if (vTracksITS567perColl[colIndex] >= 100 && vTracksITS567perColl[thisColIndex] < 100) histos.fill(HIST("hDeltaVzGivenCollAbove100NearbyBelow100"), vCollVz[thisColIndex] - vZ); @@ -843,13 +844,13 @@ struct RofOccupancyQaTask { if (vTracksITS567perColl[colIndex] > 50 && vTracksITS567perColl[thisColIndex] > 50) histos.fill(HIST("hDeltaTimeAboveNtracksCut"), dt); - if (fabs(vCollVz[colIndex]) < 10 && fabs(vCollVz[thisColIndex]) < 10) + if (std::fabs(vCollVz[colIndex]) < 10 && std::fabs(vCollVz[thisColIndex]) < 10) histos.fill(HIST("hDeltaTime_vZ10cm"), dt); if (vIsSel8[colIndex] && vIsSel8[thisColIndex]) histos.fill(HIST("hDeltaTime_sel8"), dt); - if (fabs(vCollVz[colIndex]) < 10 && vIsSel8[colIndex] && fabs(vCollVz[thisColIndex]) < 10 && vIsSel8[thisColIndex]) { + if (std::fabs(vCollVz[colIndex]) < 10 && vIsSel8[colIndex] && std::fabs(vCollVz[thisColIndex]) < 10 && vIsSel8[thisColIndex]) { histos.fill(HIST("hDeltaTime_sel8_vZ10cm"), dt); if (vTracksITS567perColl[colIndex] > 50 && vTracksITS567perColl[thisColIndex] > 50) histos.fill(HIST("hDeltaTimeAboveNtracksCut_sel8_vZ10cm"), dt); @@ -876,48 +877,48 @@ struct RofOccupancyQaTask { sumAmpFT0CInFullTimeWindow += wOccup * vAmpFT0CperColl[thisColIndex]; // counting tracks from other collisions in fixed time windows - if (fabs(dt) < confTimeRangeVetoOnCollNarrow) + if (std::fabs(dt) < confTimeRangeVetoOnCollNarrow) nITS567tracksForVetoNarrow += vTracksITS567perColl[thisColIndex]; - if (fabs(dt) < confTimeRangeVetoOnCollStandard) + if (std::fabs(dt) < confTimeRangeVetoOnCollStandard) nITS567tracksForVetoStrict += vTracksITS567perColl[thisColIndex]; - // if (fabs(dt) < confTimeRangeVetoOnCollStandard + 0.5) { // add 0.5 us safety margin + // if (std::fabs(dt) < confTimeRangeVetoOnCollStandard + 0.5) { // add 0.5 us safety margin // standard cut on other collisions vs delta-times - const float driftV = 2.5; // drift velocity in cm/us, TPC drift_length / drift_time = 250 cm / 100 us - if (fabs(dt) < 2.0) { // us, complete veto on other collisions + const float driftV = 2.5; // drift velocity in cm/us, TPC drift_length / drift_time = 250 cm / 100 us + if (std::fabs(dt) < 2.0) { // us, complete veto on other collisions nITS567tracksForVetoStandard += vTracksITS567perColl[thisColIndex]; } else if (dt > -4.0 && dt <= -2.0) { // us, strict veto to suppress fake ITS-TPC matches more if (vTracksITS567perColl[thisColIndex] > confNtracksCutVetoOnCollInTimeRange / 5) nITS567tracksForVetoStandard += vTracksITS567perColl[thisColIndex]; - } else if (fabs(dt) < 8 + fabs(vZ) / driftV) { // loose veto, 8 us corresponds to maximum possible |vZ|, which is ~20 cm + } else if (std::fabs(dt) < 8 + std::fabs(vZ) / driftV) { // loose veto, 8 us corresponds to maximum possible |vZ|, which is ~20 cm // counting number of other collisions with mult above threshold if (vTracksITS567perColl[thisColIndex] > confNtracksCutVetoOnCollInTimeRange) nITS567tracksForVetoStandard += vTracksITS567perColl[thisColIndex]; } // vZ-dependent time cut to avoid collinear tracks from other collisions (experimental) - if (fabs(dt) < 8 + fabs(vZ) / driftV) { + if (std::fabs(dt) < 8 + std::fabs(vZ) / driftV) { if (dt < 0) { // check distance between given vZ and (moving in two directions) vZ of drifting tracks from past collisions - if ((fabs(vCollVz[thisColIndex] - fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC) || - (fabs(vCollVz[thisColIndex] + fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC)) + if ((std::fabs(vCollVz[thisColIndex] - std::fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC) || + (std::fabs(vCollVz[thisColIndex] + std::fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC)) nITS567tracksForVetoVzDependent += vTracksITS567perColl[thisColIndex]; // FOR QA: - if (fabs(vCollVz[thisColIndex] - fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC) - histos.fill(HIST("hDeltaVzVsDeltaTime1"), vCollVz[thisColIndex] - fabs(dt) * driftV - vZ, dt); - if (fabs(vCollVz[thisColIndex] + fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC) - histos.fill(HIST("hDeltaVzVsDeltaTime2"), vCollVz[thisColIndex] + fabs(dt) * driftV - vZ, dt); + if (std::fabs(vCollVz[thisColIndex] - std::fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC) + histos.fill(HIST("hDeltaVzVsDeltaTime1"), vCollVz[thisColIndex] - std::fabs(dt) * driftV - vZ, dt); + if (std::fabs(vCollVz[thisColIndex] + std::fabs(dt) * driftV - vZ) < confEpsilonDistanceForVzDependentVetoTPC) + histos.fill(HIST("hDeltaVzVsDeltaTime2"), vCollVz[thisColIndex] + std::fabs(dt) * driftV - vZ, dt); } else { // dt>0 // check distance between drifted vZ of given collision (in two directions) and vZ of future collisions - if ((fabs(vZ - dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC) || - (fabs(vZ + dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC)) + if ((std::fabs(vZ - dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC) || + (std::fabs(vZ + dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC)) nITS567tracksForVetoVzDependent += vTracksITS567perColl[thisColIndex]; // FOR QA: - if (fabs(vZ - dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC) + if (std::fabs(vZ - dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC) histos.fill(HIST("hDeltaVzVsDeltaTime3"), vZ - dt * driftV - vCollVz[thisColIndex], dt); - if (fabs(vZ + dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC) + if (std::fabs(vZ + dt * driftV - vCollVz[thisColIndex]) < confEpsilonDistanceForVzDependentVetoTPC) histos.fill(HIST("hDeltaVzVsDeltaTime4"), vZ + dt * driftV - vCollVz[thisColIndex], dt); } } @@ -935,7 +936,7 @@ struct RofOccupancyQaTask { vArrNoCollInSameRofWithCloseVz.push_back(vVzCutThisColl); } - for (auto& col : cols) { + for (const auto& col : cols) { int32_t colIndex = col.globalIndex(); bool sel8 = col.sel8(); // bc.selection_bit(kIsTriggerTVX) && bc.selection_bit(kNoTimeFrameBorder) && bc.selection_bit(kNoITSROFrameBorder); @@ -954,7 +955,7 @@ struct RofOccupancyQaTask { float ft0C = vAmpFT0CperColl[colIndex]; // ROF-by-ROF - if (fabs(vZ) < 8) { + if (std::fabs(vZ) < 8) { histos.fill(HIST("ROFbyROF/nPV_vs_ROFid"), nPV, vCollRofIdPerOrbit[colIndex]); histos.fill(HIST("ROFbyROF/nPV_vs_subROFid"), nPV, vCollRofSubIdPerOrbit[colIndex]); @@ -962,7 +963,7 @@ struct RofOccupancyQaTask { histos.fill(HIST("ROFbyROF/FT0C_vs_subROFid"), ft0C, vCollRofSubIdPerOrbit[colIndex]); } // vs occupancy - if (occTracks >= 0 && fabs(vZ) < 8) { + if (occTracks >= 0 && std::fabs(vZ) < 8) { histos.fill(HIST("nPV_vs_occupancyByTracks/sel8"), nPV, occTracks); if (col.selection_bit(kNoCollInTimeRangeNarrow)) histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInTimeRangeNarrow"), nPV, occTracks); @@ -970,8 +971,6 @@ struct RofOccupancyQaTask { histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInTimeRangeStrict"), nPV, occTracks); if (col.selection_bit(kNoCollInTimeRangeStandard)) histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInTimeRangeStandard"), nPV, occTracks); - if (col.selection_bit(kNoCollInTimeRangeVzDependent)) - histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInTimeRangeVzDependent"), nPV, occTracks); if (col.selection_bit(kNoCollInRofStrict)) histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInRofStrict"), nPV, occTracks); if (col.selection_bit(kNoCollInRofStandard)) @@ -980,14 +979,14 @@ struct RofOccupancyQaTask { histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInTimeAndRofStandard"), nPV, occTracks); if (col.selection_bit(kNoCollInTimeRangeStrict) && col.selection_bit(kNoCollInRofStrict)) histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInTimeAndRofStrict"), nPV, occTracks); - if (col.selection_bit(kNoCollInTimeRangeStrict) && col.selection_bit(kNoCollInRofStrict) && fabs(vZ) < 5) + if (col.selection_bit(kNoCollInTimeRangeStrict) && col.selection_bit(kNoCollInRofStrict) && std::fabs(vZ) < 5) histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInTimeAndRofStrict_vZ_5cm"), nPV, occTracks); if (col.selection_bit(kNoHighMultCollInPrevRof)) histos.fill(HIST("nPV_vs_occupancyByTracks/kNoHighMultCollInPrevRof"), nPV, occTracks); if (col.selection_bit(kNoHighMultCollInPrevRof) && col.selection_bit(kNoCollInRofStrict)) histos.fill(HIST("nPV_vs_occupancyByTracks/kNoHighMultCollInPrevRofAndRofStrict"), nPV, occTracks); } - if (occFT0C >= 0 && fabs(vZ) < 8) { + if (occFT0C >= 0 && std::fabs(vZ) < 8) { histos.fill(HIST("nPV_vs_occupancyByFT0C/sel8"), nPV, occFT0C); if (col.selection_bit(kNoCollInTimeRangeNarrow)) histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInTimeRangeNarrow"), nPV, occFT0C); @@ -995,8 +994,6 @@ struct RofOccupancyQaTask { histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInTimeRangeStrict"), nPV, occFT0C); if (col.selection_bit(kNoCollInTimeRangeStandard)) histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInTimeRangeStandard"), nPV, occFT0C); - if (col.selection_bit(kNoCollInTimeRangeVzDependent)) - histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInTimeRangeVzDependent"), nPV, occFT0C); if (col.selection_bit(kNoCollInRofStrict)) histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInRofStrict"), nPV, occFT0C); if (col.selection_bit(kNoCollInRofStandard)) @@ -1005,7 +1002,7 @@ struct RofOccupancyQaTask { histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInTimeAndRofStandard"), nPV, occFT0C); if (col.selection_bit(kNoCollInTimeRangeStrict) && col.selection_bit(kNoCollInRofStrict)) histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInTimeAndRofStrict"), nPV, occFT0C); - if (col.selection_bit(kNoCollInTimeRangeStrict) && col.selection_bit(kNoCollInRofStrict) && fabs(vZ) < 5) + if (col.selection_bit(kNoCollInTimeRangeStrict) && col.selection_bit(kNoCollInRofStrict) && std::fabs(vZ) < 5) histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInTimeAndRofStrict_vZ_5cm"), nPV, occFT0C); if (col.selection_bit(kNoHighMultCollInPrevRof)) histos.fill(HIST("nPV_vs_occupancyByFT0C/kNoHighMultCollInPrevRof"), nPV, occFT0C); @@ -1028,7 +1025,7 @@ struct RofOccupancyQaTask { histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/all"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/all"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); - if (sel8 && fabs(col.posZ()) < 8) { + if (sel8 && std::fabs(col.posZ()) < 8) { histos.fill(HIST("hOccupancyByFT0C_vs_ByTracks_vZ_TF_ROF_border_cuts"), vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); // if (vAmpFT0CperColl[colIndex] > 5000 && vAmpFT0CperColl[colIndex] < 10000) { @@ -1157,8 +1154,6 @@ struct RofOccupancyQaTask { histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_afterStrictDeltaTimeCut"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); if (col.selection_bit(kNoCollInTimeRangeStandard)) histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_afterStandardDeltaTimeCut"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); - if (col.selection_bit(kNoCollInTimeRangeVzDependent)) - histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_afterVzDependentDeltaTimeCut"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); if (col.selection_bit(kNoCollInRofStrict)) histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_kNoCollInRofStrict"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); @@ -1216,7 +1211,7 @@ struct RofOccupancyQaTask { if (vNoCollInTimeRangeNarrow[colIndex]) { for (int i = 0; i < 200; i++) { - if (fabs(col.posZ()) < 8 && !vArrNoCollInSameRofWithCloseVz[colIndex][i]) { + if (std::fabs(col.posZ()) < 8 && !vArrNoCollInSameRofWithCloseVz[colIndex][i]) { histos.fill(HIST("hThisEvITStr_vs_vZcut"), 0.025 + 0.05 * i, vTracksITS567perColl[colIndex]); histos.fill(HIST("hThisEvITSTPCtr_vs_vZcut"), 0.025 + 0.05 * i, vTracksITSTPCperColl[colIndex]); } diff --git a/DPG/Tasks/AOTEvent/timeDependentQa.cxx b/DPG/Tasks/AOTEvent/timeDependentQa.cxx new file mode 100644 index 00000000000..61fbb690e6c --- /dev/null +++ b/DPG/Tasks/AOTEvent/timeDependentQa.cxx @@ -0,0 +1,847 @@ +// 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. + +/// \file timeDependentQa.cxx +/// \brief Time-dependent QA for a number of observables +/// +/// \author Evgeny Kryshen and Igor Altsybeev + +#include +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "CCDB/BasicCCDBManager.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/DataModel/Multiplicity.h" +#include "TPCCalibration/TPCMShapeCorrection.h" +#include "DataFormatsParameters/AggregatedRunInfo.h" +#include "DataFormatsITSMFT/ROFRecord.h" +#include "ReconstructionDataFormats/Vertex.h" + +#include "TTree.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod::evsel; +using namespace o2::aod::rctsel; + +using ColEvSels = soa::Join; +using BCsRun3 = soa::Join; +using BarrelTracks = soa::Join; + +const AxisSpec axisQoverPt{100, -1., 1., "q/p_{T}, 1/GeV"}; +const AxisSpec axisDcaR{1000, -5., 5., "DCA_{r}, cm"}; +const AxisSpec axisDcaZ{1000, -5., 5., "DCA_{z}, cm"}; +const AxisSpec axisSparseQoverPt{20, -1., 1., "q/p_{T}, 1/GeV"}; +const AxisSpec axisSparseDcaR{100, -1., 1., "DCA_{r}, cm"}; +const AxisSpec axisSparseDcaZ{100, -1., 1., "DCA_{z}, cm"}; + +struct TimeDependentQaTask { + Configurable confTimeBinWidthInSec{"TimeBinWidthInSec", 0.5, "Width of time bins in seconds"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confTimeWiderBinFactor{"TimeWideBinFactor", 4, "Factor for wider time bins for some 2D histograms"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confTimeMuchWiderBinFactor{"TimeMuchWiderBinFactor", 20, "Factor for even wider time bins for some 2D histograms"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confTakeVerticesWithUPCsettings{"ConsiderVerticesWithUPCsettings", 0, "Take vertices: 0 - all , 1 - only without UPC settings, 2 - only with UPC settings"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagFillPhiVsTimeHist{"FlagFillPhiVsTimeHist", 2, "0 - don't fill , 1 - fill only for global/7cls/TRD/TOF tracks, 2 - fill also layer-by-layer"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagFillEtaPhiVsTimeHist{"FlagFillEtaPhiVsTimeHist", 0, "0 - don't fill , 1 - fill"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confCutOnNtpcClsForSharedFractAndDeDxCalc{"CutOnNtpcClsForSharedFractAndDeDxCalc", 70, ""}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagCheckMshape{"FlagCheckMshape", 0, "0 - don't check , 1 - check"}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confFlagCheckQoverPtHist{"FlagCheckQoverPtHist", 1, "0 - don't check , 1 - check"}; // o2-linter: disable=name/configurable (temporary fix) + + // for O-O and Ne-Ne run + Configurable confIncludeMultDistrVsTimeHistos{"IncludeMultDistrVsTimeHistos", 0, ""}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confMaxNtracksForTimeDepDistributions{"MaxNtracksForTimeDepDistributions", 800, ""}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confMaxZNACenergyForTimeDepDistributions{"MaxZNACenergyForTimeDepDistributions", 4000, ""}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confMaxT0ACamplForTimeDepDistributions{"MaxT0ACamplForTimeDepDistributions", 25000, ""}; // o2-linter: disable=name/configurable (temporary fix) + Configurable confMaxV0AamplForTimeDepDistributions{"MaxV0AamplForTimeDepDistributions", 40000, ""}; // o2-linter: disable=name/configurable (temporary fix) + + enum EvSelBitsToMonitor { + enCollisionsAll = 0, + enIsTriggerTVX, + enNoTimeFrameBorder, + enNoITSROFrameBorder, + enCollisionsSel8, + enNoSameBunchPileup, + enIsGoodZvtxFT0vsPV, + enIsVertexITSTPC, + enIsVertexTOFmatched, + enIsVertexTRDmatched, + enNoCollInTimeRangeNarrow, + enNoCollInTimeRangeStrict, + enNoCollInTimeRangeStandard, + enNoCollInRofStrict, + enNoCollInRofStandard, + enNoHighMultCollInPrevRof, + enIsGoodITSLayer3, + enIsGoodITSLayer0123, + enIsGoodITSLayersAll, + enIsLowOccupStd, + enIsLowOccupStdAlsoInPrevRof, + enIsLowOccupStdCut500, + enIsLowOccupStdCut2000, + enIsLowOccupStdCut4000, + enIsLowOccupStdAlsoInPrevRofCut2000noDeadStaves, + enNumEvSelBits, // counter + }; + + enum RctCombFlagsToMonitor { + enCBT = kNRCTSelectionFlags, + enCBT_hadronPID, + enCBT_electronPID, + enCBT_calo, + enCBT_muon, + enCBT_muon_glo, + enNumRctFlagsTotal, // counter + }; + + Service ccdb; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + o2::tpc::TPCMShapeCorrection mshape; // object for simple access + int lastRunNumber = -1; + double maxSec = 1; + double minSec = 0; + static const int32_t nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; + int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 for unanchored MC + int64_t nBCsPerTF = -1; // duration of TF in bcs + ctpRateFetcher mRateFetcher; + + // RCT flag combinations: checkers (based on presentation https://indico.cern.ch/event/1513866/#18-how-to-use-the-rct-flags-at) + RCTFlagsChecker rctCheckerCBT{"CBT"}; // o2-linter: disable=name/function-variable (temporary fix) + RCTFlagsChecker rctCheckerCBT_hadronPID{"CBT_hadronPID"}; // o2-linter: disable=name/function-variable (temporary fix) + RCTFlagsChecker rctCheckerCBT_electronPID{"CBT_electronPID"}; // o2-linter: disable=name/function-variable (temporary fix) + RCTFlagsChecker rctCheckerCBT_calo{"CBT_calo"}; // o2-linter: disable=name/function-variable (temporary fix) + RCTFlagsChecker rctCheckerCBT_muon{"CBT_muon"}; // o2-linter: disable=name/function-variable (temporary fix) + RCTFlagsChecker rctCheckerCBT_muon_glo{"CBT_muon_glo"}; // o2-linter: disable=name/function-variable (temporary fix) + + TAxis* axRctFlags; + + void init(InitContext&) + { + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + histos.add("allTracks/hQoverPt", "", kTH1F, {axisQoverPt}); + if (confFlagCheckQoverPtHist) { + histos.add("allTracks/hQoverPtDcaR", "", kTH2F, {axisSparseQoverPt, axisSparseDcaR}); + histos.add("allTracks/hQoverPtDcaZ", "", kTH2F, {axisSparseQoverPt, axisSparseDcaZ}); + } + histos.add("allTracks/hDcaR", "", kTH1F, {axisDcaR}); + histos.add("allTracks/hDcaZ", "", kTH1F, {axisDcaZ}); + histos.add("allTracks/hDcaRafterCuts", "", kTH1F, {axisDcaR}); + histos.add("allTracks/hDcaZafterCuts", "", kTH1F, {axisDcaZ}); + + histos.add("PVcontrib/hDcaRafterCuts", "", kTH1F, {axisDcaR}); + histos.add("PVcontrib/hDcaZafterCuts", "", kTH1F, {axisDcaZ}); + + histos.add("A/global/hDcaRafterCuts", "", kTH1F, {axisDcaR}); + histos.add("A/global/hDcaZafterCuts", "", kTH1F, {axisDcaZ}); + histos.add("A/globalPV/hDcaRafterCuts", "", kTH1F, {axisDcaR}); + histos.add("A/globalPV/hDcaZafterCuts", "", kTH1F, {axisDcaZ}); + + histos.add("C/global/hDcaRafterCuts", "", kTH1F, {axisDcaR}); + histos.add("C/global/hDcaZafterCuts", "", kTH1F, {axisDcaZ}); + histos.add("C/globalPV/hDcaRafterCuts", "", kTH1F, {axisDcaR}); + histos.add("C/globalPV/hDcaZafterCuts", "", kTH1F, {axisDcaZ}); + } + + Preslice perCollision = aod::track::collisionId; + + void processRun3( + ColEvSels const& cols, + BarrelTracks const& tracks, + BCsRun3 const& bcs, + aod::Zdcs const&, + aod::FT0s const&) + { + int runNumber = bcs.iteratorAt(0).runNumber(); + if (runNumber != lastRunNumber) { + LOGP(debug, " >> QA: run number = {}", runNumber); + lastRunNumber = runNumber; + + int64_t tsSOR = 0; // dummy start-of-run timestamp + int64_t tsEOR = 1; // dummy end-of-run timestamp + if (runNumber >= 500000) { + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), runNumber); + // first bc of the first orbit + bcSOR = runInfo.orbitSOR * nBCsPerOrbit; + // duration of TF in bcs + nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit; + // start-of-run timestamp + tsSOR = runInfo.sor; + // end-of-run timestamp + tsEOR = runInfo.eor; + } + + minSec = floor(tsSOR / 1000.); + maxSec = ceil(tsEOR / 1000.); + int nTimeBins = static_cast((maxSec - minSec) / confTimeBinWidthInSec); + int nTimeWideBins = static_cast((maxSec - minSec) / confTimeBinWidthInSec / confTimeWiderBinFactor); + int nTimeVeryWideBins = static_cast((maxSec - minSec) / confTimeBinWidthInSec / confTimeMuchWiderBinFactor); + double timeInterval = nTimeBins * confTimeBinWidthInSec; + + const AxisSpec axisSeconds{nTimeBins, 0, timeInterval, "seconds"}; + const AxisSpec axisSecondsWideBins{nTimeWideBins, 0, timeInterval, "seconds"}; + const AxisSpec axisSecondsVeryWideBins{nTimeVeryWideBins, 0, timeInterval, "seconds"}; + histos.add("hSecondsBCsTVX", "", kTH1D, {axisSeconds}); + histos.add("hSecondsBCsTVXandTFborderCuts", "", kTH1D, {axisSeconds}); + + histos.add("hSecondsCollisionsBeforeAllCuts", "", kTH1D, {axisSeconds}); + histos.add("hSecondsCollisionsTVXNoVzCut", "", kTH1D, {axisSeconds}); + histos.add("hSecondsCollisionsTFborderCutNoVzCut", "", kTH1D, {axisSeconds}); + histos.add("hSecondsCollisionsTVXTFborderCutNoVzCut", "", kTH1D, {axisSeconds}); + + histos.add("hSecondsCollisions", "", kTH1D, {axisSeconds}); + histos.add("hSecondsCollisionsNoPileup", "", kTH1D, {axisSeconds}); + histos.add("hSecondsIR", "", kTH1D, {axisSeconds}); + histos.add("hSecondsVz", "", kTH1D, {axisSeconds}); + histos.add("hSecondsFT0Camlp", "", kTH1D, {axisSeconds}); + histos.add("hSecondsFT0CamlpByColMult", "", kTH1D, {axisSeconds}); + histos.add("hSecondsFT0AamlpByColMult", "", kTH1D, {axisSeconds}); + histos.add("hSecondsV0Aamlp", "", kTH1D, {axisSeconds}); + histos.add("hSecondsOccupancyByTracks", "", kTH1D, {axisSeconds}); + histos.add("hSecondsOccupancyByFT0C", "", kTH1D, {axisSeconds}); + + // QA for UPC settings + histos.add("hSecondsUPCverticesBeforeAllCuts", "", kTH2F, {axisSeconds, {2, -0.5, 1.5, "Is vertex with UPC settings"}}); + histos.add("hSecondsUPCverticesBeforeSel8", "", kTH2F, {axisSeconds, {2, -0.5, 1.5, "Is vertex with UPC settings after |vZ|<10 cut"}}); + histos.add("hSecondsUPCvertices", "", kTH2F, {axisSeconds, {2, -0.5, 1.5, "Is vertex with UPC settings after |vZ|<10 and sel8 cuts"}}); + + // shapes of distributions (added for the O-O run monitoring) + if (confIncludeMultDistrVsTimeHistos) { + int maxNtracks = confMaxNtracksForTimeDepDistributions; + float maxZNACenergyForTimeDepDistributions = confMaxZNACenergyForTimeDepDistributions; + float maxT0ACamplForTimeDepDistributions = confMaxT0ACamplForTimeDepDistributions; + float maxV0AamplForTimeDepDistributions = confMaxV0AamplForTimeDepDistributions; + histos.add("multDistributions/hSecondsDistrPVtracks", "", kTH2D, {axisSecondsVeryWideBins, {maxNtracks, -0.5, maxNtracks - 0.5, "n PV tracks"}}); + histos.add("multDistributions/hSecondsDistrT0A", "", kTH2D, {axisSecondsVeryWideBins, {250, 0, maxT0ACamplForTimeDepDistributions, "T0A ampl"}}); + histos.add("multDistributions/hSecondsDistrT0C", "", kTH2D, {axisSecondsVeryWideBins, {250, 0, maxT0ACamplForTimeDepDistributions, "T0C ampl"}}); + histos.add("multDistributions/hSecondsDistrV0A", "", kTH2D, {axisSecondsVeryWideBins, {400, 0, maxV0AamplForTimeDepDistributions, "V0A ampl"}}); + histos.add("multDistributions/hSecondsDistrZNA", "", kTH2D, {axisSecondsVeryWideBins, {320, 0, maxZNACenergyForTimeDepDistributions, "ZNA ampl"}}); + histos.add("multDistributions/hSecondsDistrZNC", "", kTH2D, {axisSecondsVeryWideBins, {320, 0, maxZNACenergyForTimeDepDistributions, "ZNC ampl"}}); + histos.add("multDistributions/hSecondsDistrZNACdiff", "", kTH2D, {axisSecondsVeryWideBins, {600, -maxZNACenergyForTimeDepDistributions, maxZNACenergyForTimeDepDistributions, "ZN A-C diff"}}); + histos.add("multDistributions/hSecondsDistrZNACdiffNorm", "", kTH2D, {axisSecondsVeryWideBins, {200, -1., 1., "ZN A-C diff"}}); + histos.add("multDistributions/hSecondsDistrZNAampl", "", kTH2D, {axisSecondsVeryWideBins, {320, 0, maxZNACenergyForTimeDepDistributions, "ZNA ampl"}}); + histos.add("multDistributions/hSecondsDistrZNCampl", "", kTH2D, {axisSecondsVeryWideBins, {320, 0, maxZNACenergyForTimeDepDistributions, "ZNC ampl"}}); + histos.add("multDistributions/hSecondsDistrZNACdiffAmpl", "", kTH2D, {axisSecondsVeryWideBins, {200, -1., 1., "ZN A-C diff"}}); + histos.add("multDistributions/hSecondsDistrZNACdiffNormAmpl", "", kTH2D, {axisSecondsVeryWideBins, {200, -1., 1., "ZN A-C diff"}}); + + histos.add("multDistributionsNoPileup/hSecondsDistrPVtracks", "", kTH2D, {axisSecondsVeryWideBins, {maxNtracks, -0.5, maxNtracks - 0.5, "n PV tracks"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrT0A", "", kTH2D, {axisSecondsVeryWideBins, {250, 0, maxT0ACamplForTimeDepDistributions, "T0A ampl"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrT0C", "", kTH2D, {axisSecondsVeryWideBins, {250, 0, maxT0ACamplForTimeDepDistributions, "T0C ampl"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrV0A", "", kTH2D, {axisSecondsVeryWideBins, {400, 0, maxV0AamplForTimeDepDistributions, "V0A ampl"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrZNA", "", kTH2D, {axisSecondsVeryWideBins, {320, 0, maxZNACenergyForTimeDepDistributions, "ZNA ampl"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrZNC", "", kTH2D, {axisSecondsVeryWideBins, {320, 0, maxZNACenergyForTimeDepDistributions, "ZNC ampl"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrZNACdiff", "", kTH2D, {axisSecondsVeryWideBins, {600, -maxZNACenergyForTimeDepDistributions, maxZNACenergyForTimeDepDistributions, "ZN A-C diff"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrZNACdiffNorm", "", kTH2D, {axisSecondsVeryWideBins, {200, -1., 1., "ZN A-C diff"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrZNAampl", "", kTH2D, {axisSecondsVeryWideBins, {320, 0, maxZNACenergyForTimeDepDistributions, "ZNA ampl"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrZNCampl", "", kTH2D, {axisSecondsVeryWideBins, {320, 0, maxZNACenergyForTimeDepDistributions, "ZNC ampl"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrZNACdiffAmpl", "", kTH2D, {axisSecondsVeryWideBins, {200, -1., 1., "ZN A-C diff"}}); + histos.add("multDistributionsNoPileup/hSecondsDistrZNACdiffNormAmpl", "", kTH2D, {axisSecondsVeryWideBins, {200, -1., 1., "ZN A-C diff"}}); + } + + // ### QA event selection bits + int nEvSelBits = enNumEvSelBits; + histos.add("hSecondsEventSelBits", "", kTH2F, {axisSecondsWideBins, {nEvSelBits, -0.5, nEvSelBits - 0.5, "Monitoring of event selection bits"}}); + TAxis* axSelBits = reinterpret_cast(histos.get(HIST("hSecondsEventSelBits"))->GetYaxis()); + axSelBits->SetBinLabel(1 + enCollisionsAll, "collisionsAll"); + axSelBits->SetBinLabel(1 + enIsTriggerTVX, "IsTriggerTVX"); + axSelBits->SetBinLabel(1 + enNoTimeFrameBorder, "NoTimeFrameBorder"); + axSelBits->SetBinLabel(1 + enNoITSROFrameBorder, "NoITSROFrameBorder"); + + // bits after sel8 + axSelBits->SetBinLabel(1 + enCollisionsSel8, "collisionsSel8"); + axSelBits->SetBinLabel(1 + enNoSameBunchPileup, "NoSameBunchPileup"); + axSelBits->SetBinLabel(1 + enIsGoodZvtxFT0vsPV, "IsGoodZvtxFT0vsPV"); + axSelBits->SetBinLabel(1 + enIsVertexITSTPC, "IsVertexITSTPC"); + axSelBits->SetBinLabel(1 + enIsVertexTOFmatched, "IsVertexTOFmatched"); + axSelBits->SetBinLabel(1 + enIsVertexTRDmatched, "IsVertexTRDmatched"); + + axSelBits->SetBinLabel(1 + enNoCollInTimeRangeNarrow, "NoCollInTimeRangeNarrow"); + axSelBits->SetBinLabel(1 + enNoCollInTimeRangeStrict, "NoCollInTimeRangeStrict"); + axSelBits->SetBinLabel(1 + enNoCollInTimeRangeStandard, "NoCollInTimeRangeStandard"); + axSelBits->SetBinLabel(1 + enNoCollInRofStrict, "NoCollInRofStrict"); + axSelBits->SetBinLabel(1 + enNoCollInRofStandard, "NoCollInRofStandard"); + axSelBits->SetBinLabel(1 + enNoHighMultCollInPrevRof, "NoHighMultCollInPrevRof"); + + axSelBits->SetBinLabel(1 + enIsGoodITSLayer3, "IsGoodITSLayer3"); + axSelBits->SetBinLabel(1 + enIsGoodITSLayer0123, "IsGoodITSLayer0123"); + axSelBits->SetBinLabel(1 + enIsGoodITSLayersAll, "IsGoodITSLayersAll"); + + // combined conditions on occupancy + axSelBits->SetBinLabel(1 + enIsLowOccupStd, "isLowOccupStd"); + axSelBits->SetBinLabel(1 + enIsLowOccupStdAlsoInPrevRof, "isLowOccupStdAlsoInPrevRof"); + axSelBits->SetBinLabel(1 + enIsLowOccupStdCut500, "isLowOccupStdCut500"); + axSelBits->SetBinLabel(1 + enIsLowOccupStdCut2000, "isLowOccupStdCut2000"); + axSelBits->SetBinLabel(1 + enIsLowOccupStdCut4000, "isLowOccupStdCut4000"); + axSelBits->SetBinLabel(1 + enIsLowOccupStdAlsoInPrevRofCut2000noDeadStaves, "isLowOccupStdAlsoInPrevRofCut2000noDeadStaves"); + + // ### QA RCT flags + int nRctFlagsTotal = enNumRctFlagsTotal; + histos.add("hSecondsRCTflags", "", kTH2F, {axisSecondsWideBins, {nRctFlagsTotal + 1, -0.5, nRctFlagsTotal + 1 - 0.5, "Monitoring of RCT flags"}}); + axRctFlags = reinterpret_cast(histos.get(HIST("hSecondsRCTflags"))->GetYaxis()); + axRctFlags->SetBinLabel(1, "NcollisionsSel8"); + axRctFlags->SetBinLabel(2 + kCPVBad, "CPVBad"); + axRctFlags->SetBinLabel(2 + kEMCBad, "EMCBad"); + axRctFlags->SetBinLabel(2 + kEMCLimAccMCRepr, "EMCLimAccMCRepr"); + axRctFlags->SetBinLabel(2 + kFDDBad, "FDDBad"); + axRctFlags->SetBinLabel(2 + kFT0Bad, "FT0Bad"); + axRctFlags->SetBinLabel(2 + kFV0Bad, "FV0Bad"); + axRctFlags->SetBinLabel(2 + kHMPBad, "HMPBad"); + axRctFlags->SetBinLabel(2 + kITSBad, "ITSBad"); + axRctFlags->SetBinLabel(2 + kITSLimAccMCRepr, "ITSLimAccMCRepr"); + axRctFlags->SetBinLabel(2 + kMCHBad, "MCHBad"); + axRctFlags->SetBinLabel(2 + kMCHLimAccMCRepr, "MCHLimAccMCRepr"); + axRctFlags->SetBinLabel(2 + kMFTBad, "MFTBad"); + axRctFlags->SetBinLabel(2 + kMFTLimAccMCRepr, "MFTLimAccMCRepr"); + axRctFlags->SetBinLabel(2 + kMIDBad, "MIDBad"); + axRctFlags->SetBinLabel(2 + kMIDLimAccMCRepr, "MIDLimAccMCRepr"); + axRctFlags->SetBinLabel(2 + kPHSBad, "PHSBad"); + axRctFlags->SetBinLabel(2 + kTOFBad, "TOFBad"); + axRctFlags->SetBinLabel(2 + kTOFLimAccMCRepr, "TOFLimAccMCRepr"); + axRctFlags->SetBinLabel(2 + kTPCBadTracking, "TPCBadTracking"); + axRctFlags->SetBinLabel(2 + kTPCBadPID, "TPCBadPID"); + axRctFlags->SetBinLabel(2 + kTPCLimAccMCRepr, "TPCLimAccMCRepr"); + axRctFlags->SetBinLabel(2 + kTRDBad, "TRDBad"); + axRctFlags->SetBinLabel(2 + kZDCBad, "ZDCBad"); + // combined flags + axRctFlags->SetBinLabel(2 + enCBT, "CBT"); + axRctFlags->SetBinLabel(2 + enCBT_hadronPID, "CBT_hadronPID"); + axRctFlags->SetBinLabel(2 + enCBT_electronPID, "CBT_electronPID"); + axRctFlags->SetBinLabel(2 + enCBT_calo, "CBT_calo"); + axRctFlags->SetBinLabel(2 + enCBT_muon, "CBT_muon"); + axRctFlags->SetBinLabel(2 + enCBT_muon_glo, "CBT_muon_glo"); + + // QA for all tracks + // const AxisSpec axisChi2ITS{40, 0., 20., "chi2/ndof"}; + // const AxisSpec axisChi2TPC{40, 0., 20., "chi2/ndof"}; + const AxisSpec axisNclsITS{5, 3.5, 8.5, "n ITS cls"}; + const AxisSpec axisNclsTPC{40, -0.5, 159.5, "n TPC cls"}; + const AxisSpec axisFraction{20, 0, 1., "Fraction shared cls Tpc"}; + histos.add("allTracks/hSecondsTracks", "", kTH1D, {axisSeconds}); + if (confFlagCheckQoverPtHist) { + histos.add("allTracks/hSecondsQoverPtSumDcaR", "", kTH2D, {axisSecondsWideBins, axisSparseQoverPt}); + histos.add("allTracks/hSecondsQoverPtSumDcaZ", "", kTH2D, {axisSecondsWideBins, axisSparseQoverPt}); + } + histos.add("allTracks/hSecondsSumDcaR", "", kTH1D, {axisSeconds}); + histos.add("allTracks/hSecondsSumDcaZ", "", kTH1D, {axisSeconds}); + histos.add("allTracks/hSecondsSumPt", "", kTH1D, {axisSeconds}); + histos.add("allTracks/hSecondsNumClsIts", "", kTH1D, {axisSeconds}); + histos.add("allTracks/hSeconds2DNumClsIts", "", kTH2D, {axisSecondsWideBins, axisNclsITS}); + histos.add("allTracks/hSecondsChi2NClIts", "", kTH1D, {axisSeconds}); + if (confFlagCheckMshape) + histos.add("allTracks/hSecondsTracksMshape", "", kTH1D, {axisSeconds}); + + // QA for PV contributors + histos.add("PVcontrib/hSecondsTracks", "", kTH1D, {axisSeconds}); + histos.add("PVcontrib/hSecondsSumDcaR", "", kTH1D, {axisSeconds}); + histos.add("PVcontrib/hSecondsSumDcaZ", "", kTH1D, {axisSeconds}); + histos.add("PVcontrib/hSecondsSumPt", "", kTH1D, {axisSeconds}); + histos.add("PVcontrib/hSecondsNumClsIts", "", kTH1D, {axisSeconds}); + histos.add("PVcontrib/hSeconds2DNumClsIts", "", kTH2D, {axisSecondsWideBins, axisNclsITS}); + histos.add("PVcontrib/hSecondsChi2NClIts", "", kTH1D, {axisSeconds}); + + // QA for global tracks + // ### A side + // global tracks + histos.add("A/global/hSecondsNumTracks", "", kTH1D, {axisSeconds}); + if (confFlagCheckQoverPtHist) { + histos.add("A/global/hSecondsQoverPtSumDcaR", "", kTH2D, {axisSecondsWideBins, axisSparseQoverPt}); + histos.add("A/global/hSecondsQoverPtSumDcaZ", "", kTH2D, {axisSecondsWideBins, axisSparseQoverPt}); + } + histos.add("A/global/hSecondsSumDcaR", "", kTH1D, {axisSeconds}); + histos.add("A/global/hSecondsSumDcaZ", "", kTH1D, {axisSeconds}); + histos.add("A/global/hSecondsSumPt", "", kTH1D, {axisSeconds}); + histos.add("A/global/hSecondsNumClsIts", "", kTH1D, {axisSeconds}); + histos.add("A/global/hSeconds2DNumClsIts", "", kTH2D, {axisSecondsWideBins, axisNclsITS}); + histos.add("A/global/hSecondsChi2NClIts", "", kTH1D, {axisSeconds}); + histos.add("A/global/hSecondsNumClsTpc", "", kTH1D, {axisSeconds}); + histos.add("A/global/hSeconds2DNumClsTpc", "", kTH2D, {axisSecondsWideBins, axisNclsTPC}); + histos.add("A/global/hSecondsChi2NClTpc", "", kTH1D, {axisSeconds}); + histos.add("A/global/hSecondsTpcFractionSharedCls", "", kTH1D, {axisSeconds}); + histos.add("A/global/hSeconds2DTpcFractionSharedCls", "", kTH2D, {axisSecondsWideBins, axisFraction}); + histos.add("A/global/hSecondsDeDx", "", kTH1D, {axisSeconds}); + + // global && PV tracks + histos.add("A/globalPV/hSecondsNumPVcontributors", "", kTH1D, {axisSeconds}); + histos.add("A/globalPV/hSecondsSumDcaR", "", kTH1D, {axisSeconds}); + histos.add("A/globalPV/hSecondsSumDcaZ", "", kTH1D, {axisSeconds}); + histos.add("A/globalPV/hSecondsSumPt", "", kTH1D, {axisSeconds}); + histos.add("A/globalPV/hSecondsNumClsIts", "", kTH1D, {axisSeconds}); + histos.add("A/globalPV/hSeconds2DNumClsIts", "", kTH2D, {axisSecondsWideBins, axisNclsITS}); + histos.add("A/globalPV/hSecondsChi2NClIts", "", kTH1D, {axisSeconds}); + histos.add("A/globalPV/hSecondsNumClsTpc", "", kTH1D, {axisSeconds}); + histos.add("A/globalPV/hSeconds2DNumClsTpc", "", kTH2D, {axisSecondsWideBins, axisNclsTPC}); + histos.add("A/globalPV/hSecondsChi2NClTpc", "", kTH1D, {axisSeconds}); + histos.add("A/globalPV/hSecondsTpcFractionSharedCls", "", kTH1D, {axisSeconds}); + histos.add("A/globalPV/hSeconds2DTpcFractionSharedCls", "", kTH2D, {axisSecondsWideBins, axisFraction}); + histos.add("A/globalPV/hSecondsDeDx", "", kTH1D, {axisSeconds}); + + // ### C side + // global tracks + histos.add("C/global/hSecondsNumTracks", "", kTH1D, {axisSeconds}); + if (confFlagCheckQoverPtHist) { + histos.add("C/global/hSecondsQoverPtSumDcaR", "", kTH2D, {axisSecondsWideBins, axisSparseQoverPt}); + histos.add("C/global/hSecondsQoverPtSumDcaZ", "", kTH2D, {axisSecondsWideBins, axisSparseQoverPt}); + } + histos.add("C/global/hSecondsSumDcaR", "", kTH1D, {axisSeconds}); + histos.add("C/global/hSecondsSumDcaZ", "", kTH1D, {axisSeconds}); + histos.add("C/global/hSecondsSumPt", "", kTH1D, {axisSeconds}); + histos.add("C/global/hSecondsNumClsIts", "", kTH1D, {axisSeconds}); + histos.add("C/global/hSeconds2DNumClsIts", "", kTH2D, {axisSecondsWideBins, axisNclsITS}); + histos.add("C/global/hSecondsChi2NClIts", "", kTH1D, {axisSeconds}); + histos.add("C/global/hSecondsNumClsTpc", "", kTH1D, {axisSeconds}); + histos.add("C/global/hSeconds2DNumClsTpc", "", kTH2D, {axisSecondsWideBins, axisNclsTPC}); + histos.add("C/global/hSecondsChi2NClTpc", "", kTH1D, {axisSeconds}); + histos.add("C/global/hSecondsTpcFractionSharedCls", "", kTH1D, {axisSeconds}); + histos.add("C/global/hSeconds2DTpcFractionSharedCls", "", kTH2D, {axisSecondsWideBins, axisFraction}); + histos.add("C/global/hSecondsDeDx", "", kTH1D, {axisSeconds}); + + // global && PV tracks + histos.add("C/globalPV/hSecondsNumPVcontributors", "", kTH1D, {axisSeconds}); + histos.add("C/globalPV/hSecondsSumDcaR", "", kTH1D, {axisSeconds}); + histos.add("C/globalPV/hSecondsSumDcaZ", "", kTH1D, {axisSeconds}); + histos.add("C/globalPV/hSecondsSumPt", "", kTH1D, {axisSeconds}); + histos.add("C/globalPV/hSecondsNumClsIts", "", kTH1D, {axisSeconds}); + histos.add("C/globalPV/hSeconds2DNumClsIts", "", kTH2D, {axisSecondsWideBins, axisNclsITS}); + histos.add("C/globalPV/hSecondsChi2NClIts", "", kTH1D, {axisSeconds}); + histos.add("C/globalPV/hSecondsNumClsTpc", "", kTH1D, {axisSeconds}); + histos.add("C/globalPV/hSeconds2DNumClsTpc", "", kTH2D, {axisSecondsWideBins, axisNclsTPC}); + histos.add("C/globalPV/hSecondsChi2NClTpc", "", kTH1D, {axisSeconds}); + histos.add("C/globalPV/hSecondsTpcFractionSharedCls", "", kTH1D, {axisSeconds}); + histos.add("C/globalPV/hSeconds2DTpcFractionSharedCls", "", kTH2D, {axisSecondsWideBins, axisFraction}); + histos.add("C/globalPV/hSecondsDeDx", "", kTH1D, {axisSeconds}); + + // phi holes vs time + const AxisSpec axisPhi{64, 0, TMath::TwoPi(), "#varphi"}; // o2-linter: disable=external-pi (temporary fix) + const AxisSpec axisEta{10, -0.8, 0.8, "#eta"}; + if (confFlagFillPhiVsTimeHist == 2) { + histos.add("hSecondsITSlayer0vsPhi", "", kTH2F, {axisSeconds, axisPhi}); + histos.add("hSecondsITSlayer1vsPhi", "", kTH2F, {axisSeconds, axisPhi}); + histos.add("hSecondsITSlayer2vsPhi", "", kTH2F, {axisSeconds, axisPhi}); + histos.add("hSecondsITSlayer3vsPhi", "", kTH2F, {axisSeconds, axisPhi}); + histos.add("hSecondsITSlayer4vsPhi", "", kTH2F, {axisSeconds, axisPhi}); + histos.add("hSecondsITSlayer5vsPhi", "", kTH2F, {axisSeconds, axisPhi}); + histos.add("hSecondsITSlayer6vsPhi", "", kTH2F, {axisSeconds, axisPhi}); + } + if (confFlagFillPhiVsTimeHist > 0) { + histos.add("hSecondsITS7clsVsPhi", "", kTH2F, {axisSeconds, axisPhi}); + histos.add("hSecondsITSglobalVsPhi", "", kTH2F, {axisSeconds, axisPhi}); + histos.add("hSecondsITSTRDVsPhi", "", kTH2F, {axisSeconds, axisPhi}); + histos.add("hSecondsITSTOFVsPhi", "", kTH2F, {axisSeconds, axisPhi}); + } + if (confFlagFillEtaPhiVsTimeHist) + histos.add("hSecondsITSglobalVsEtaPhi", "", kTH3F, {axisSeconds, axisEta, axisPhi}); + } + + // count TVX triggers per DF + for (const auto& bc : bcs) { + // auto bc = col.foundBC_as(); + int64_t ts = bc.timestamp(); + double secFromSOR = ts / 1000. - minSec; + if (bc.selection_bit(kIsTriggerTVX)) { + histos.fill(HIST("hSecondsBCsTVX"), secFromSOR); + if (bc.selection_bit(kNoTimeFrameBorder)) { + histos.fill(HIST("hSecondsBCsTVXandTFborderCuts"), secFromSOR); + } + } + } + + // ### collision loop + for (const auto& col : cols) { + // check if a vertex is found in the UPC mode ITS ROF + // flags from: https://github.com/AliceO2Group/AliceO2/blob/dev/DataFormats/Reconstruction/include/ReconstructionDataFormats/Vertex.h + ushort flags = col.flags(); + bool isVertexUPC = flags & dataformats::Vertex>::Flags::UPCMode; // is vertex with UPC settings + if (confTakeVerticesWithUPCsettings > 0) { // otherwise analyse all collisions + if (confTakeVerticesWithUPCsettings == 1 && isVertexUPC) // reject vertices with UPC settings + continue; + if (confTakeVerticesWithUPCsettings == 2 && !isVertexUPC) // we want to select vertices with UPC settings --> reject vertices reconstructed with "normal" settings + continue; + // LOGP(info, "flags={} nTracks = {}", flags, tracks.size()); + } + + auto bc = col.foundBC_as(); + int64_t ts = bc.timestamp(); + double secFromSOR = ts / 1000. - minSec; + + histos.fill(HIST("hSecondsCollisionsBeforeAllCuts"), secFromSOR); + if (col.selection_bit(kIsTriggerTVX)) + histos.fill(HIST("hSecondsCollisionsTVXNoVzCut"), secFromSOR); + if (col.selection_bit(kNoTimeFrameBorder)) + histos.fill(HIST("hSecondsCollisionsTFborderCutNoVzCut"), secFromSOR); + if (col.selection_bit(kIsTriggerTVX) && col.selection_bit(kNoTimeFrameBorder)) + histos.fill(HIST("hSecondsCollisionsTVXTFborderCutNoVzCut"), secFromSOR); + + histos.fill(HIST("hSecondsUPCverticesBeforeAllCuts"), secFromSOR, isVertexUPC ? 1 : 0); + + if (std::fabs(col.posZ()) > 10) + continue; + + histos.fill(HIST("hSecondsUPCverticesBeforeSel8"), secFromSOR, isVertexUPC ? 1 : 0); + + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enCollisionsAll); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsTriggerTVX, col.selection_bit(kIsTriggerTVX)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enNoTimeFrameBorder, col.selection_bit(kNoTimeFrameBorder)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enNoITSROFrameBorder, col.selection_bit(kNoITSROFrameBorder)); + + // sel8 selection: + if (!col.sel8()) + continue; + + histos.fill(HIST("hSecondsUPCvertices"), secFromSOR, isVertexUPC ? 1 : 0); + histos.fill(HIST("hSecondsCollisions"), secFromSOR); + if (col.selection_bit(kNoSameBunchPileup)) + histos.fill(HIST("hSecondsCollisionsNoPileup"), secFromSOR); + histos.fill(HIST("hSecondsVz"), secFromSOR, col.posZ()); + histos.fill(HIST("hSecondsFT0Camlp"), secFromSOR, bc.foundFT0().sumAmpC()); + histos.fill(HIST("hSecondsFT0CamlpByColMult"), secFromSOR, col.multFT0C()); + histos.fill(HIST("hSecondsFT0AamlpByColMult"), secFromSOR, col.multFT0A()); + histos.fill(HIST("hSecondsV0Aamlp"), secFromSOR, col.multFV0A()); + + histos.fill(HIST("hSecondsOccupancyByTracks"), secFromSOR, col.trackOccupancyInTimeRange()); + histos.fill(HIST("hSecondsOccupancyByFT0C"), secFromSOR, col.ft0cOccupancyInTimeRange()); + + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enCollisionsSel8); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enNoSameBunchPileup, col.selection_bit(kNoSameBunchPileup)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsGoodZvtxFT0vsPV, col.selection_bit(kIsGoodZvtxFT0vsPV)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsVertexITSTPC, col.selection_bit(kIsVertexITSTPC)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsVertexTOFmatched, col.selection_bit(kIsVertexTOFmatched)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsVertexTRDmatched, col.selection_bit(kIsVertexTRDmatched)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enNoCollInTimeRangeNarrow, col.selection_bit(kNoCollInTimeRangeNarrow)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enNoCollInTimeRangeStrict, col.selection_bit(kNoCollInTimeRangeStrict)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enNoCollInTimeRangeStandard, col.selection_bit(kNoCollInTimeRangeStandard)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enNoCollInRofStrict, col.selection_bit(kNoCollInRofStrict)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enNoCollInRofStandard, col.selection_bit(kNoCollInRofStandard)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enNoHighMultCollInPrevRof, col.selection_bit(kNoHighMultCollInPrevRof)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsGoodITSLayer3, col.selection_bit(kIsGoodITSLayer3)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsGoodITSLayer0123, col.selection_bit(kIsGoodITSLayer0123)); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsGoodITSLayersAll, col.selection_bit(kIsGoodITSLayersAll)); + + // occupancy selection combinations + float occupByTracks = col.trackOccupancyInTimeRange(); + + bool isLowOccupStd = col.selection_bit(kNoCollInTimeRangeStandard) && col.selection_bit(kNoCollInRofStandard); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsLowOccupStd, isLowOccupStd); + + bool isLowOccupStdAlsoInPrevRof = isLowOccupStd && col.selection_bit(kNoHighMultCollInPrevRof); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsLowOccupStdAlsoInPrevRof, isLowOccupStdAlsoInPrevRof); + + bool isLowOccupStdCut500 = isLowOccupStd && occupByTracks >= 0 && occupByTracks < 500; + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsLowOccupStdCut500, isLowOccupStdCut500); + + bool isLowOccupStdCut2000 = isLowOccupStd && occupByTracks >= 0 && occupByTracks < 2000; + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsLowOccupStdCut2000, isLowOccupStdCut2000); + + bool isLowOccupStdCut4000 = isLowOccupStd && occupByTracks >= 0 && occupByTracks < 4000; + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsLowOccupStdCut4000, isLowOccupStdCut4000); + + bool isLowOccupStdAlsoInPrevRofCut2000noDeadStaves = isLowOccupStdCut2000 && col.selection_bit(kNoHighMultCollInPrevRof) && col.selection_bit(kIsGoodITSLayersAll); + histos.fill(HIST("hSecondsEventSelBits"), secFromSOR, enIsLowOccupStdAlsoInPrevRofCut2000noDeadStaves, isLowOccupStdAlsoInPrevRofCut2000noDeadStaves); + + // check RCT flags + histos.fill(HIST("hSecondsRCTflags"), secFromSOR, 0); // n collisions sel8 + for (int iFlag = 0; iFlag < kNRCTSelectionFlags; iFlag++) { + histos.fill(HIST("hSecondsRCTflags"), secFromSOR, 1 + iFlag, col.rct_bit(iFlag)); + LOGP(debug, "i = {}, bitValue = {}, binLabel={}, binCenter={}", iFlag, col.rct_bit(iFlag), axRctFlags->GetBinLabel(2 + iFlag), axRctFlags->GetBinCenter(2 + iFlag)); + } + LOGP(debug, "CBT_hadronPID = {}, kFT0Bad = {}, kITSBad = {}, kTPCBadTracking = {}, kTPCBadPID = {}, kTOFBad = {}, 1 + enCBT_hadronPID = {}, binLabel={}, binCenter={}", rctCheckerCBT_hadronPID(col), + col.rct_bit(kFT0Bad), col.rct_bit(kITSBad), col.rct_bit(kTPCBadTracking), col.rct_bit(kTPCBadPID), col.rct_bit(kTOFBad), 1 + enCBT_hadronPID, axRctFlags->GetBinLabel(2 + enCBT_hadronPID), axRctFlags->GetBinCenter(2 + enCBT_hadronPID)); + histos.fill(HIST("hSecondsRCTflags"), secFromSOR, 1 + enCBT, rctCheckerCBT(col)); + histos.fill(HIST("hSecondsRCTflags"), secFromSOR, 1 + enCBT_hadronPID, rctCheckerCBT_hadronPID(col)); + histos.fill(HIST("hSecondsRCTflags"), secFromSOR, 1 + enCBT_electronPID, rctCheckerCBT_electronPID(col)); + histos.fill(HIST("hSecondsRCTflags"), secFromSOR, 1 + enCBT_calo, rctCheckerCBT_calo(col)); + histos.fill(HIST("hSecondsRCTflags"), secFromSOR, 1 + enCBT_muon, rctCheckerCBT_muon(col)); + histos.fill(HIST("hSecondsRCTflags"), secFromSOR, 1 + enCBT_muon_glo, rctCheckerCBT_muon_glo(col)); + + // check hadronic rate + double hadronicRate = mRateFetcher.fetch(ccdb.service, ts, runNumber, "ZNC hadronic") * 1.e-3; // kHz + histos.fill(HIST("hSecondsIR"), secFromSOR, hadronicRate); + + // checking mShape flags in time: + bool isMshape = false; + if (confFlagCheckMshape) { + auto mShapeTree = ccdb->getForTimeStamp("TPC/Calib/MShapePotential", ts); + mshape.setFromTree(*mShapeTree); + isMshape = !mshape.getBoundaryPotential(ts).mPotential.empty(); + } + + // ##### track loop + auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); + int nPVtracks = 0; + for (const auto& track : tracksGrouped) { + // if (!track.hasTPC() || !track.hasITS()) + // continue; + if (std::fabs(track.eta()) > 0.8 || std::fabs(track.pt()) < 0.2) + continue; + + double dcaR = track.dcaXY(); + double dcaZ = track.dcaZ(); + LOGP(debug, "dcaR = {} dcaZ = {}", dcaR, dcaZ); + histos.fill(HIST("allTracks/hDcaR"), dcaR); + histos.fill(HIST("allTracks/hDcaZ"), dcaZ); + + // now DCA cuts: + if (std::fabs(dcaR) > 1. || std::fabs(dcaZ) > 1.) + continue; + + histos.fill(HIST("allTracks/hSecondsTracks"), secFromSOR); + + histos.fill(HIST("allTracks/hDcaRafterCuts"), dcaR); + histos.fill(HIST("allTracks/hDcaZafterCuts"), dcaZ); + + double qpt = track.signed1Pt(); + histos.fill(HIST("allTracks/hQoverPt"), qpt); + if (confFlagCheckQoverPtHist) { + histos.fill(HIST("allTracks/hQoverPtDcaR"), qpt, dcaR); + histos.fill(HIST("allTracks/hQoverPtDcaZ"), qpt, dcaZ); + } + // now consider only abs values for DCAs: + double dcaRabs = std::fabs(dcaR); + double dcaZabs = std::fabs(dcaZ); + + histos.fill(HIST("allTracks/hSecondsSumDcaR"), secFromSOR, dcaRabs); + histos.fill(HIST("allTracks/hSecondsSumDcaZ"), secFromSOR, dcaZabs); + histos.fill(HIST("allTracks/hSecondsSumPt"), secFromSOR, track.pt()); + if (confFlagCheckQoverPtHist) { + histos.fill(HIST("allTracks/hSecondsQoverPtSumDcaR"), secFromSOR, qpt, dcaRabs); + histos.fill(HIST("allTracks/hSecondsQoverPtSumDcaZ"), secFromSOR, qpt, dcaZabs); + } + histos.fill(HIST("allTracks/hSecondsNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("allTracks/hSeconds2DNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("allTracks/hSecondsChi2NClIts"), secFromSOR, track.itsChi2NCl()); + if (confFlagCheckMshape && isMshape) { + histos.fill(HIST("allTracks/hSecondsTracksMshape"), secFromSOR); + } + + // ### PV contributors + if (track.isPVContributor()) { + histos.fill(HIST("PVcontrib/hDcaRafterCuts"), dcaR); + histos.fill(HIST("PVcontrib/hDcaZafterCuts"), dcaZ); + + histos.fill(HIST("PVcontrib/hSecondsTracks"), secFromSOR); + histos.fill(HIST("PVcontrib/hSecondsSumDcaR"), secFromSOR, dcaRabs); + histos.fill(HIST("PVcontrib/hSecondsSumDcaZ"), secFromSOR, dcaZabs); + histos.fill(HIST("PVcontrib/hSecondsSumPt"), secFromSOR, track.pt()); + // histos.fill(HIST("PVcontrib/hSecondsQoverPtSumDcaR"), secFromSOR, qpt, dcaRabs); + // histos.fill(HIST("PVcontrib/hSecondsQoverPtSumDcaZ"), secFromSOR, qpt, dcaZabs); + histos.fill(HIST("PVcontrib/hSecondsNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("PVcontrib/hSeconds2DNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("PVcontrib/hSecondsChi2NClIts"), secFromSOR, track.itsChi2NCl()); + + nPVtracks++; + } + + // ### global tracks + float dedx = track.tpcSignal(); + if (track.isGlobalTrack()) { // A side + if (track.tgl() > 0.) { + histos.fill(HIST("A/global/hDcaRafterCuts"), dcaR); + histos.fill(HIST("A/global/hDcaZafterCuts"), dcaZ); + + histos.fill(HIST("A/global/hSecondsNumTracks"), secFromSOR); + if (confFlagCheckQoverPtHist) { + histos.fill(HIST("A/global/hSecondsQoverPtSumDcaR"), secFromSOR, qpt, dcaRabs); + histos.fill(HIST("A/global/hSecondsQoverPtSumDcaZ"), secFromSOR, qpt, dcaZabs); + } + histos.fill(HIST("A/global/hSecondsSumDcaR"), secFromSOR, dcaRabs); + histos.fill(HIST("A/global/hSecondsSumDcaZ"), secFromSOR, dcaZabs); + histos.fill(HIST("A/global/hSecondsSumPt"), secFromSOR, track.pt()); + histos.fill(HIST("A/global/hSecondsNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("A/global/hSeconds2DNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("A/global/hSecondsChi2NClIts"), secFromSOR, track.itsChi2NCl()); + histos.fill(HIST("A/global/hSecondsNumClsTpc"), secFromSOR, track.tpcNClsFound()); + histos.fill(HIST("A/global/hSeconds2DNumClsTpc"), secFromSOR, track.tpcNClsFound()); + histos.fill(HIST("A/global/hSecondsChi2NClTpc"), secFromSOR, track.tpcChi2NCl()); + if (track.tpcNClsFound() >= confCutOnNtpcClsForSharedFractAndDeDxCalc) { + histos.fill(HIST("A/global/hSecondsTpcFractionSharedCls"), secFromSOR, track.tpcFractionSharedCls()); + histos.fill(HIST("A/global/hSeconds2DTpcFractionSharedCls"), secFromSOR, track.tpcFractionSharedCls()); + if (dedx < 1.e4) // protection from weird values + histos.fill(HIST("A/global/hSecondsDeDx"), secFromSOR, dedx); + } + + if (track.isPVContributor()) { + histos.fill(HIST("A/globalPV/hDcaRafterCuts"), dcaR); + histos.fill(HIST("A/globalPV/hDcaZafterCuts"), dcaZ); + + histos.fill(HIST("A/globalPV/hSecondsNumPVcontributors"), secFromSOR); + histos.fill(HIST("A/globalPV/hSecondsSumDcaR"), secFromSOR, dcaRabs); + histos.fill(HIST("A/globalPV/hSecondsSumDcaZ"), secFromSOR, dcaZabs); + histos.fill(HIST("A/globalPV/hSecondsSumPt"), secFromSOR, track.pt()); + histos.fill(HIST("A/globalPV/hSecondsNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("A/globalPV/hSeconds2DNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("A/globalPV/hSecondsChi2NClIts"), secFromSOR, track.itsChi2NCl()); + histos.fill(HIST("A/globalPV/hSecondsNumClsTpc"), secFromSOR, track.tpcNClsFound()); + histos.fill(HIST("A/globalPV/hSeconds2DNumClsTpc"), secFromSOR, track.tpcNClsFound()); + histos.fill(HIST("A/globalPV/hSecondsChi2NClTpc"), secFromSOR, track.tpcChi2NCl()); + if (track.tpcNClsFound() >= confCutOnNtpcClsForSharedFractAndDeDxCalc) { + histos.fill(HIST("A/globalPV/hSecondsTpcFractionSharedCls"), secFromSOR, track.tpcFractionSharedCls()); + histos.fill(HIST("A/globalPV/hSeconds2DTpcFractionSharedCls"), secFromSOR, track.tpcFractionSharedCls()); + if (dedx < 1.e4) // protection from weird values + histos.fill(HIST("A/globalPV/hSecondsDeDx"), secFromSOR, dedx); + } + } + } else { // C side + histos.fill(HIST("C/global/hDcaRafterCuts"), dcaR); + histos.fill(HIST("C/global/hDcaZafterCuts"), dcaZ); + + histos.fill(HIST("C/global/hSecondsNumTracks"), secFromSOR); + if (confFlagCheckQoverPtHist) { + histos.fill(HIST("C/global/hSecondsQoverPtSumDcaR"), secFromSOR, qpt, dcaRabs); + histos.fill(HIST("C/global/hSecondsQoverPtSumDcaZ"), secFromSOR, qpt, dcaZabs); + } + histos.fill(HIST("C/global/hSecondsSumDcaR"), secFromSOR, dcaRabs); + histos.fill(HIST("C/global/hSecondsSumDcaZ"), secFromSOR, dcaZabs); + histos.fill(HIST("C/global/hSecondsSumPt"), secFromSOR, track.pt()); + histos.fill(HIST("C/global/hSecondsNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("C/global/hSeconds2DNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("C/global/hSecondsChi2NClIts"), secFromSOR, track.itsChi2NCl()); + histos.fill(HIST("C/global/hSecondsNumClsTpc"), secFromSOR, track.tpcNClsFound()); + histos.fill(HIST("C/global/hSeconds2DNumClsTpc"), secFromSOR, track.tpcNClsFound()); + histos.fill(HIST("C/global/hSecondsChi2NClTpc"), secFromSOR, track.tpcChi2NCl()); + if (track.tpcNClsFound() >= confCutOnNtpcClsForSharedFractAndDeDxCalc) { + histos.fill(HIST("C/global/hSecondsTpcFractionSharedCls"), secFromSOR, track.tpcFractionSharedCls()); + histos.fill(HIST("C/global/hSeconds2DTpcFractionSharedCls"), secFromSOR, track.tpcFractionSharedCls()); + if (dedx < 1.e4) // protection from weird values + histos.fill(HIST("C/global/hSecondsDeDx"), secFromSOR, dedx); + } + + if (track.isPVContributor()) { + histos.fill(HIST("C/globalPV/hDcaRafterCuts"), dcaR); + histos.fill(HIST("C/globalPV/hDcaZafterCuts"), dcaZ); + + histos.fill(HIST("C/globalPV/hSecondsNumPVcontributors"), secFromSOR); + histos.fill(HIST("C/globalPV/hSecondsSumDcaR"), secFromSOR, dcaRabs); + histos.fill(HIST("C/globalPV/hSecondsSumDcaZ"), secFromSOR, dcaZabs); + histos.fill(HIST("C/globalPV/hSecondsSumPt"), secFromSOR, track.pt()); + histos.fill(HIST("C/globalPV/hSecondsNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("C/globalPV/hSeconds2DNumClsIts"), secFromSOR, track.itsNCls()); + histos.fill(HIST("C/globalPV/hSecondsChi2NClIts"), secFromSOR, track.itsChi2NCl()); + histos.fill(HIST("C/globalPV/hSecondsNumClsTpc"), secFromSOR, track.tpcNClsFound()); + histos.fill(HIST("C/globalPV/hSeconds2DNumClsTpc"), secFromSOR, track.tpcNClsFound()); + histos.fill(HIST("C/globalPV/hSecondsChi2NClTpc"), secFromSOR, track.tpcChi2NCl()); + if (track.tpcNClsFound() >= confCutOnNtpcClsForSharedFractAndDeDxCalc) { + histos.fill(HIST("C/globalPV/hSecondsTpcFractionSharedCls"), secFromSOR, track.tpcFractionSharedCls()); + histos.fill(HIST("C/globalPV/hSeconds2DTpcFractionSharedCls"), secFromSOR, track.tpcFractionSharedCls()); + if (dedx < 1.e4) // protection from weird values + histos.fill(HIST("C/globalPV/hSecondsDeDx"), secFromSOR, dedx); + } + } + } + } // end of global tracks + + // study ITS cluster pattern vs phi vs time (pt>1 GeV/c cut selects straight tracks) + if (track.isPVContributor() && track.pt() > 1) { + // layer-by-layer check + if (confFlagFillPhiVsTimeHist == 2) { + if (track.itsClusterMap() & (1 << 0)) + histos.fill(HIST("hSecondsITSlayer0vsPhi"), secFromSOR, track.phi()); + if (track.itsClusterMap() & (1 << 1)) + histos.fill(HIST("hSecondsITSlayer1vsPhi"), secFromSOR, track.phi()); + if (track.itsClusterMap() & (1 << 2)) + histos.fill(HIST("hSecondsITSlayer2vsPhi"), secFromSOR, track.phi()); + if (track.itsClusterMap() & (1 << 3)) + histos.fill(HIST("hSecondsITSlayer3vsPhi"), secFromSOR, track.phi()); + if (track.itsClusterMap() & (1 << 4)) + histos.fill(HIST("hSecondsITSlayer4vsPhi"), secFromSOR, track.phi()); + if (track.itsClusterMap() & (1 << 5)) + histos.fill(HIST("hSecondsITSlayer5vsPhi"), secFromSOR, track.phi()); + if (track.itsClusterMap() & (1 << 6)) + histos.fill(HIST("hSecondsITSlayer6vsPhi"), secFromSOR, track.phi()); + } + // tracks with conditions + if (confFlagFillPhiVsTimeHist > 0) { + if (track.itsNCls() == 7) + histos.fill(HIST("hSecondsITS7clsVsPhi"), secFromSOR, track.phi()); + if (track.isGlobalTrack()) + histos.fill(HIST("hSecondsITSglobalVsPhi"), secFromSOR, track.phi()); + if (track.hasTRD()) + histos.fill(HIST("hSecondsITSTRDVsPhi"), secFromSOR, track.phi()); + if (track.hasTOF()) + histos.fill(HIST("hSecondsITSTOFVsPhi"), secFromSOR, track.phi()); + } + // eta-phi histogram for global tracks + if (confFlagFillEtaPhiVsTimeHist && track.isGlobalTrack()) { + histos.fill(HIST("hSecondsITSglobalVsEtaPhi"), secFromSOR, track.eta(), track.phi()); + } + } + } // end of track loop + + // fill mult distributions vs time + if (confIncludeMultDistrVsTimeHistos) { + bool noPileup = col.selection_bit(kNoSameBunchPileup); + + histos.fill(HIST("multDistributions/hSecondsDistrPVtracks"), secFromSOR, nPVtracks); + + // ZNA,C + // float multZNA = bc.has_zdc() ? bc.zdc().energyCommonZNA() : -999.f; + // float multZNC = bc.has_zdc() ? bc.zdc().energyCommonZNC() : -999.f; + histos.fill(HIST("multDistributions/hSecondsDistrZNA"), secFromSOR, col.multZNA()); + histos.fill(HIST("multDistributions/hSecondsDistrZNC"), secFromSOR, col.multZNC()); + float ZNdiff = col.multZNA() - col.multZNC(); + float ZNsum = col.multZNA() + col.multZNC(); + histos.fill(HIST("multDistributions/hSecondsDistrZNACdiff"), secFromSOR, ZNdiff); + if (ZNsum > 0) + histos.fill(HIST("multDistributions/hSecondsDistrZNACdiffNorm"), secFromSOR, ZNdiff / ZNsum); + + // ZNA,C by amplitudes (suggested by Chiara O.) + float ZNAampl = bc.has_zdc() ? bc.zdc().amplitudeZNA() : 0; + float ZNCampl = bc.has_zdc() ? bc.zdc().amplitudeZNC() : 0; + histos.fill(HIST("multDistributions/hSecondsDistrZNAampl"), secFromSOR, ZNAampl); + histos.fill(HIST("multDistributions/hSecondsDistrZNCampl"), secFromSOR, ZNCampl); + float ZNdiffAmpl = ZNAampl - ZNCampl; + float ZNsumAmpl = ZNAampl + ZNCampl; + histos.fill(HIST("multDistributions/hSecondsDistrZNACdiffAmpl"), secFromSOR, ZNdiffAmpl); + if (ZNsumAmpl > 0) + histos.fill(HIST("multDistributions/hSecondsDistrZNACdiffNormAmpl"), secFromSOR, ZNdiffAmpl / ZNsumAmpl); + + // FT0A,C, V0A + // float multT0A = bc.has_ft0() ? bc.ft0().sumAmpA() : -999.f; + // float multT0C = bc.has_ft0() ? fbcundBC.ft0().sumAmpC() : -999.f; + histos.fill(HIST("multDistributions/hSecondsDistrT0A"), secFromSOR, col.multFT0A()); + histos.fill(HIST("multDistributions/hSecondsDistrT0C"), secFromSOR, col.multFT0C()); + histos.fill(HIST("multDistributions/hSecondsDistrV0A"), secFromSOR, col.multFV0A()); + + if (noPileup) { + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrPVtracks"), secFromSOR, nPVtracks); + + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrZNA"), secFromSOR, col.multZNA()); + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrZNC"), secFromSOR, col.multZNC()); + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrZNACdiff"), secFromSOR, ZNdiff); + if (ZNsum > 0) + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrZNACdiffNorm"), secFromSOR, ZNdiff / ZNsum); + + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrZNAampl"), secFromSOR, ZNAampl); + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrZNCampl"), secFromSOR, ZNCampl); + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrZNACdiffAmpl"), secFromSOR, ZNdiffAmpl); + if (ZNsumAmpl > 0) + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrZNACdiffNormAmpl"), secFromSOR, ZNdiffAmpl / ZNsumAmpl); + + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrT0A"), secFromSOR, col.multFT0A()); + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrT0C"), secFromSOR, col.multFT0C()); + histos.fill(HIST("multDistributionsNoPileup/hSecondsDistrV0A"), secFromSOR, col.multFV0A()); + } + } + } + } // end of collision loop + PROCESS_SWITCH(TimeDependentQaTask, processRun3, "Process Run3 QA vs time", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/DPG/Tasks/AOTTrack/CMakeLists.txt b/DPG/Tasks/AOTTrack/CMakeLists.txt index 9974d3d6bc2..b125419f6d0 100644 --- a/DPG/Tasks/AOTTrack/CMakeLists.txt +++ b/DPG/Tasks/AOTTrack/CMakeLists.txt @@ -85,3 +85,8 @@ o2physics_add_dpl_workflow(tag-and-probe-dmesons PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing O2Physics::MLCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(derived-data-creator-d0-calibration + SOURCES derivedDataCreatorD0Calibration.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCore O2::DCAFitter O2Physics::MLCore + COMPONENT_NAME Analysis) + diff --git a/DPG/Tasks/AOTTrack/D0CalibTables.h b/DPG/Tasks/AOTTrack/D0CalibTables.h new file mode 100644 index 00000000000..1564b6cebdf --- /dev/null +++ b/DPG/Tasks/AOTTrack/D0CalibTables.h @@ -0,0 +1,492 @@ +// 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. + +/// \file D0CalibTables.h +/// \brief Definitions of derived tables produced by data creator for D0 calibration studies +/// \author Fabrizio Grosa , CERN + +#ifndef DPG_TASKS_AOTTRACK_D0CALIBTABLES_H_ +#define DPG_TASKS_AOTTRACK_D0CALIBTABLES_H_ + +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include + +#include + +#include +#include +#include +#include + +namespace o2 +{ +namespace hf_calib +{ +enum D0MassHypo : uint8_t { + D0 = 1, + D0Bar, + D0AndD0Bar, + ND0MassHypos +}; + +const float toMicrometers = 10000.; // from cm to µm + +/// It compresses a value to a int8_t with a given precision +///\param origValue is the original values +///\param precision is the desired precision +///\return The value compressed to a int8_t +template +int8_t getCompressedInt8(T origValue, double precision) +{ + int roundValue = static_cast(std::round(origValue / precision)); + return static_cast(std::clamp(roundValue, -128, 128)); +} + +/// It compresses a value to a uint8_t with a given precision +///\param origValue is the original values +///\param precision is the desired precision +///\return The value compressed to a uint8_t +template +uint8_t getCompressedUint8(T origValue, double precision) +{ + int roundValue = static_cast(std::round(origValue / precision)); + return static_cast(std::clamp(roundValue, 0, 255)); +} + +/// It compresses a value to a uint16_t with a given precision +///\param origValue is the original values +///\param precision is the desired precision +///\return The value compressed to a uint16_t +template +uint16_t getCompressedUint16(T origValue, double precision) +{ + int roundValue = static_cast(std::round(origValue / precision)); + return static_cast(std::clamp(roundValue, 0, 65535)); +} + +/// It uses a sinh-based scaling function, which provides a compromise between fixed-step and relative quantization. +// This approach reflects typical resolution formulas and is well-suited for detector calibration data. +///\param origValue is the original value +///\param sigma0 is a asinh parameter +///\param sigma1 is a asinh parameter +///\param clampMin is the maximum value +///\param clampMax is the minimum value +///\return The value compressed +int codeSqrtScaling(float origValue, float sigma0, float sigma1, int clampMin, int clampMax) +{ + float codeF = std::asinh((sigma1 * origValue) / sigma0) / sigma0; + return std::clamp(static_cast(std::round(codeF)), clampMin, clampMax); +} + +/// It compresses the decay length (10 micron precision) +///\param decLen is the decay length in cm +///\return The decay length compressed to a uint8_t with 10 micron precision +template +uint8_t getCompressedDecayLength(T decLen) +{ + return getCompressedUint8(decLen * hf_calib::toMicrometers, 0.1); +} + +/// It compresses the normalised decay length (0.5 precision) +///\param normDecLen is the normalised decay length +///\return The normalised decay length compressed to a uint8_t with 0.5 precision +template +uint8_t getCompressedNormDecayLength(T normDecLen) +{ + return getCompressedUint8(normDecLen, 0.5); +} + +/// It compresses the pointing angle (0.005 precision) +///\param pointAngle is the pointing angle +///\return The pointing angle compressed to a uint8_t with 0.005 precision +template +uint8_t getCompressedPointingAngle(T pointAngle) +{ + return getCompressedUint8(pointAngle, 0.005); +} + +/// It compresses the cosine of pointing angle (0.001 precision) +///\param cosPa is the cosine of pointing angle +///\return The cosine of pointing angle compressed to a uint8_t with 0.001 precision +template +int8_t getCompressedCosPa(T cosPa) +{ + return getCompressedUint8(cosPa - 0.75, 0.001); // in the range from 0.75 to 1 +} + +/// It compresses the chi2 +///\param chi2 is the chi2 +///\return The chi2 compressed to a uint8_t +template +int8_t getCompressedChi2(T chi2) +{ + uint8_t compressedChi2 = static_cast(codeSqrtScaling(chi2, 0.015, 0.015, 0, 255)); + return compressedChi2; +} + +/// It compresses the number of sigma +///\param numSigma is the number of sigma +///\return The number of sigma compressed to a int8_t +template +int8_t getCompressedNumSigmaPid(T numSigma) +{ + int8_t compressedNumSigma = static_cast(codeSqrtScaling(numSigma, 0.05, 0.05, -128, 128)); + return compressedNumSigma; +} + +/// It compresses the bdt score (1./65535 precision) +///\param bdtScore is the bdt score +///\return The bdt score compressed to a uint16_t with 1./65535 precision +template +uint16_t getCompressedBdtScoreBkg(T bdtScore) +{ + return getCompressedUint16(bdtScore, 1. / 65535); +} + +/// It compresses the bdt score (1./255 precision) +///\param bdtScore is the bdt score +///\return The bdt score compressed to a uint8_t with 1./255 precision +template +uint8_t getCompressedBdtScoreSgn(T bdtScore) +{ + return getCompressedUint8(bdtScore, 1. / 255); +} + +/// It compresses the occupancy value +///\param occupancy is the occupancy value +///\return The number of occupancy compressed to a uint8_t +template +uint8_t getCompressedOccupancy(T occupancy) +{ + uint8_t compressedOcc = static_cast(codeSqrtScaling(occupancy, 0.04, 0.04, 0, 255)); + return compressedOcc; +} + +static constexpr int NBinsPtTrack = 6; +static constexpr int NCutVarsTrack = 4; +constexpr float BinsPtTrack[NBinsPtTrack + 1] = { + 0, + 0.5, + 1.0, + 1.5, + 2.0, + 3.0, + 1000.0}; +auto vecBinsPtTrack = std::vector{BinsPtTrack, BinsPtTrack + NBinsPtTrack + 1}; + +// default values for the dca_xy and dca_z cuts of displaced tracks +constexpr float CutsTrack[NBinsPtTrack][NCutVarsTrack] = {{0.0015, 2., 0.0000, 2.}, /* 0 < pt < 0.5 */ + {0.0015, 2., 0.0000, 2.}, /* 0.5 < pt < 1 */ + {0.0015, 2., 0.0000, 2.}, /* 1 < pt < 1.5 */ + {0.0015, 2., 0.0000, 2.}, /* 1.5 < pt < 2 */ + {0.0000, 2., 0.0000, 2.}, /* 2 < pt < 3 */ + {0.0000, 2., 0.0000, 2.}}; /* 3 < pt < 1000 */ +// row labels +static const std::vector labelsPtTrack{}; + +// column labels +static const std::vector labelsCutVarTrack = {"min_dcaxytoprimary", "max_dcaxytoprimary", "min_dcaztoprimary", "max_dcaztoprimary"}; + +static constexpr int NBinsPtCand = 10; +static constexpr int NCutVarsCand = 10; +// default values for the pT bin edges (can be used to configure histogram axis) +// offset by 1 from the bin numbers in cuts array +constexpr float BinsPtCand[NBinsPtCand + 1] = { + 0, + 1.0, + 2.0, + 3.0, + 4.0, + 6.0, + 8.0, + 12.0, + 24.0, + 50.0, + 1000.0}; +auto vecBinsPtCand = std::vector{BinsPtCand, BinsPtCand + NBinsPtCand + 1}; + +// default values for the cuts +constexpr float CutsCand[NBinsPtCand][NCutVarsCand] = {{0.400, 0., 10., 10., 0.97, 0.97, 0, 2, 0.01, 0.01}, /* 0 < pT < 1 */ + {0.400, 0., 10., 10., 0.97, 0.97, 0, 2, 0.01, 0.01}, /* 1 < pT < 2 */ + {0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 2 < pT < 3 */ + {0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 3 < pT < 4 */ + {0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 4 < pT < 6 */ + {0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 6 < pT < 8 */ + {0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 8 < pT < 12 */ + {0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 12 < pT < 24 */ + {0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}, /* 24 < pT < 50 */ + {0.400, 0., 10., 10., 0.95, 0.95, 0, 2, 0.01, 0.01}}; /* 50 < pT < 1000 */ + +// row labels +static const std::vector labelsPtCand = { + "pT bin 0", + "pT bin 1", + "pT bin 2", + "pT bin 3", + "pT bin 4", + "pT bin 5", + "pT bin 6", + "pT bin 7", + "pT bin 8", + "pT bin 9"}; + +// column labels +static const std::vector labelsCutVarCand = {"delta inv. mass", "max d0d0", "max pointing angle", "max pointing angle XY", "min cos pointing angle", "min cos pointing angle XY", "min norm decay length", "min norm decay length XY", "min decay length", "min decay length XY"}; + +static constexpr int NBinsPtMl = 10; +// default values for the pT bin edges (can be used to configure histogram axis) +// offset by 1 from the bin numbers in cuts array +constexpr double BinsPtMl[NBinsPtMl + 1] = { + 0, + 1.0, + 2.0, + 3.0, + 4.0, + 6.0, + 8.0, + 12.0, + 24.0, + 50.0, + 1000.0}; +auto vecBinsPtMl = std::vector{BinsPtMl, BinsPtMl + NBinsPtMl + 1}; + +// default values for the cuts +constexpr double CutsMl[NBinsPtMl][3] = {{1., 0., 0.}, /* 0 < pT < 1 */ + {1., 0., 0.}, /* 1 < pT < 2 */ + {1., 0., 0.}, /* 2 < pT < 3 */ + {1., 0., 0.}, /* 3 < pT < 4 */ + {1., 0., 0.}, /* 4 < pT < 6 */ + {1., 0., 0.}, /* 6 < pT < 8 */ + {1., 0., 0.}, /* 8 < pT < 12 */ + {1., 0., 0.}, /* 12 < pT < 24 */ + {1., 0., 0.}, /* 24 < pT < 50 */ + {1., 0., 0.}}; /* 50 < pT < 1000 */ + +// row labels +static const std::vector labelsPtMl = { + "pT bin 0", + "pT bin 1", + "pT bin 2", + "pT bin 3", + "pT bin 4", + "pT bin 5", + "pT bin 6", + "pT bin 7", + "pT bin 8", + "pT bin 9"}; + +// column labels +static const std::vector labelsCutMl = {"max BDT score bkg", "min BDT score prompt", "min BDT score nonprompt"}; +} // namespace hf_calib + +namespace aod +{ +namespace hf_calib +{ +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); //! Run number +DECLARE_SOA_COLUMN(Orbit, orbit, uint32_t); //! orbit ID +DECLARE_SOA_COLUMN(CentFT0C, centFT0C, uint8_t); //! FTOC centrality +DECLARE_SOA_COLUMN(OccupancyTracks, occupancyTracks, uint8_t); //! FT0 occupancy +DECLARE_SOA_COLUMN(OccupancyFT0C, occupancyFT0C, uint8_t); //! FT0 occupancy +} // namespace hf_calib + +DECLARE_SOA_TABLE(D0CalibColls, "AOD", "D0CALIBCOLL", + o2::soa::Index<>, + collision::PosX, + collision::PosY, + collision::PosZ, + collision::CovXX, + collision::CovXY, + collision::CovXZ, + collision::CovYY, + collision::CovYZ, + collision::CovZZ, + collision::NumContrib, + hf_calib::CentFT0C, + hf_calib::OccupancyTracks, + hf_calib::OccupancyFT0C, + hf_calib::Orbit, + hf_calib::RunNumber); + +namespace hf_calib +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Collision, collision, int, D0CalibColls, ""); //! Index of collision +DECLARE_SOA_COLUMN(TpcNumSigmaPi, tpcNumSigmaPi, int8_t); //! compressed NsigmaTPC for pions +DECLARE_SOA_COLUMN(TpcNumSigmaKa, tpcNumSigmaKa, int8_t); //! compressed NsigmaTPC for kaons +DECLARE_SOA_COLUMN(TofNumSigmaPi, tofNumSigmaPi, int8_t); //! compressed NsigmaTOF for pions +DECLARE_SOA_COLUMN(TofNumSigmaKa, tofNumSigmaKa, int8_t); //! compressed NsigmaTOF for kaons +DECLARE_SOA_COLUMN(ITSChi2NCl, itsChi2NCl, uint8_t); //! compressed NsigmaTOF for kaons // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(TPCChi2NCl, tpcChi2NCl, uint8_t); //! compressed NsigmaTOF for kaons // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(TRDChi2, trdChi2, uint8_t); //! compressed NsigmaTOF for kaons // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(TOFChi2, tofChi2, uint8_t); //! compressed NsigmaTOF for kaons // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(CmoPrimUnfm80, cmoPrimUnfm80, uint8_t); +DECLARE_SOA_COLUMN(CmoFV0AUnfm80, cmoFV0AUnfm80, uint8_t); +DECLARE_SOA_COLUMN(CmoFT0AUnfm80, cmoFT0AUnfm80, uint8_t); +DECLARE_SOA_COLUMN(CmoFT0CUnfm80, cmoFT0CUnfm80, uint8_t); +DECLARE_SOA_COLUMN(CwmoPrimUnfm80, cwmoPrimUnfm80, uint8_t); +DECLARE_SOA_COLUMN(CwmoFV0AUnfm80, cwmoFV0AUnfm80, uint8_t); +DECLARE_SOA_COLUMN(CwmoFT0AUnfm80, cwmoFT0AUnfm80, uint8_t); +DECLARE_SOA_COLUMN(CwmoFT0CUnfm80, cwmoFT0CUnfm80, uint8_t); +DECLARE_SOA_COLUMN(CmoRobustT0V0PrimUnfm80, cmoRobustT0V0PrimUnfm80, uint8_t); +DECLARE_SOA_COLUMN(CwmoRobustT0V0PrimUnfm80, cwmoRobustT0V0PrimUnfm80, uint8_t); +} // namespace hf_calib + +DECLARE_SOA_TABLE(D0CalibTracks, "AOD", "D0CALIBTRACK", + o2::soa::Index<>, + /// *** collision index + hf_calib::CollisionId, + /// *** track pars + track::X, + track::Alpha, + track::Y, + track::Z, + track::Snp, + track::Tgl, + track::Signed1Pt, + /// *** track covs + track::CYY, + track::CZY, + track::CZZ, + track::CSnpY, + track::CSnpZ, + track::CSnpSnp, + track::CTglY, + track::CTglZ, + track::CTglSnp, + track::CTglTgl, + track::C1PtY, + track::C1PtZ, + track::C1PtSnp, + track::C1PtTgl, + track::C1Pt21Pt2, + /// *** track extra (static) + track::TPCInnerParam, + track::Flags, + track::ITSClusterSizes, + track::TPCNClsFindable, + track::TPCNClsFindableMinusFound, + track::TPCNClsFindableMinusCrossedRows, + track::TPCNClsShared, + track::TRDPattern, + hf_calib::ITSChi2NCl, + hf_calib::TPCChi2NCl, + hf_calib::TRDChi2, + hf_calib::TOFChi2, + track::TPCSignal, + track::TRDSignal, + track::Length, + track::TOFExpMom, + track::TrackTime, + track::TrackTimeRes, + /// *** track QA + trackqa::TPCTime0, + trackqa::TPCdEdxNorm, + trackqa::TPCDCAR, + trackqa::TPCDCAZ, + trackqa::TPCClusterByteMask, + trackqa::TPCdEdxMax0R, + trackqa::TPCdEdxMax1R, + trackqa::TPCdEdxMax2R, + trackqa::TPCdEdxMax3R, + trackqa::TPCdEdxTot0R, + trackqa::TPCdEdxTot1R, + trackqa::TPCdEdxTot2R, + trackqa::TPCdEdxTot3R, + trackqa::DeltaRefContParamY, + trackqa::DeltaRefContParamZ, + trackqa::DeltaRefContParamSnp, + trackqa::DeltaRefContParamTgl, + trackqa::DeltaRefContParamQ2Pt, + trackqa::DeltaRefGloParamY, + trackqa::DeltaRefGloParamZ, + trackqa::DeltaRefGloParamSnp, + trackqa::DeltaRefGloParamTgl, + trackqa::DeltaRefGloParamQ2Pt, + trackqa::DeltaTOFdX, + trackqa::DeltaTOFdZ, + /// *** DCA, Nsigma + track::DcaXY, + track::DcaZ, + hf_calib::TpcNumSigmaPi, + hf_calib::TpcNumSigmaKa, + hf_calib::TofNumSigmaPi, + hf_calib::TofNumSigmaKa, + /// *** Occupancy variables + hf_calib::CmoPrimUnfm80, + hf_calib::CmoFV0AUnfm80, + hf_calib::CmoFT0AUnfm80, + hf_calib::CmoFT0CUnfm80, + hf_calib::CwmoPrimUnfm80, + hf_calib::CwmoFV0AUnfm80, + hf_calib::CwmoFT0AUnfm80, + hf_calib::CwmoFT0CUnfm80, + hf_calib::CmoRobustT0V0PrimUnfm80, + hf_calib::CwmoRobustT0V0PrimUnfm80); + +namespace hf_calib +{ +DECLARE_SOA_INDEX_COLUMN_FULL(TrackPos, trackPos, int, D0CalibTracks, "_Pos"); //! Index of positive track +DECLARE_SOA_INDEX_COLUMN_FULL(TrackNeg, trackNeg, int, D0CalibTracks, "_Neg"); //! Index of negative track +DECLARE_SOA_COLUMN(MassHypo, massHypo, uint8_t); //! mass hypothesis for D0 (D0, D0bar, or both) +DECLARE_SOA_COLUMN(Pt, pt, float); //! D0-candidate pT +DECLARE_SOA_COLUMN(Eta, eta, float); //! D0-candidate eta +DECLARE_SOA_COLUMN(Phi, phi, float); //! D0-candidate phi +DECLARE_SOA_COLUMN(InvMassD0, invMassD0, float); //! invariant mass (D0 hypothesis) +DECLARE_SOA_COLUMN(InvMassD0bar, invMassD0bar, float); //! invariant mass (D0bar hypothesis) +DECLARE_SOA_COLUMN(DecLength, decLength, uint8_t); //! compressed decay length +DECLARE_SOA_COLUMN(DecLengthXY, decLengthXY, uint8_t); //! compressed decay length XY +DECLARE_SOA_COLUMN(NormDecLength, normDecLength, uint8_t); //! compressed normalised decay length +DECLARE_SOA_COLUMN(NormDecLengthXY, normDecLengthXY, uint8_t); //! compressed normalised decay length XY +DECLARE_SOA_COLUMN(CosPa, cosPa, uint8_t); //! compressed cosine of pointing angle +DECLARE_SOA_COLUMN(CosPaXY, cosPaXY, uint8_t); //! compressed cosine of pointing angle XY +DECLARE_SOA_COLUMN(PointingAngle, pointingAngle, uint8_t); //! compressed pointing angle +DECLARE_SOA_COLUMN(PointingAngleXY, pointingAngleXY, uint8_t); //! compressed pointing angle XY +DECLARE_SOA_COLUMN(DecVtxChi2, decVtxChi2, uint8_t); //! compressed decay vertex chi2 +DECLARE_SOA_COLUMN(BdtScoreBkgD0, bdtScoreBkgD0, uint16_t); //! compressed BDT score (bkg, D0 mass hypo) +DECLARE_SOA_COLUMN(BdtScorePromptD0, bdtScorePromptD0, uint8_t); //! compressed BDT score (prompt, D0 mass hypo) +DECLARE_SOA_COLUMN(BdtScoreNonpromptD0, bdtScoreNonpromptD0, uint8_t); //! compressed BDT score (non-prompt, D0 mass hypo) +DECLARE_SOA_COLUMN(BdtScoreBkgD0bar, bdtScoreBkgD0bar, uint16_t); //! compressed BDT score (bkg, D0bar mass hypo) +DECLARE_SOA_COLUMN(BdtScorePromptD0bar, bdtScorePromptD0bar, uint8_t); //! compressed BDT score (prompt, D0bar mass hypo) +DECLARE_SOA_COLUMN(BdtScoreNonpromptD0bar, bdtScoreNonpromptD0bar, uint8_t); //! compressed BDT score (non-prompt, D0bar mass hypo) +} // namespace hf_calib + +DECLARE_SOA_TABLE(D0CalibCands, "AOD", "D0CALIBCAND", + o2::soa::Index<>, + hf_calib::CollisionId, + hf_calib::TrackPosId, + hf_calib::TrackNegId, + hf_calib::MassHypo, + hf_calib::Pt, + hf_calib::Eta, + hf_calib::Phi, + hf_calib::InvMassD0, + hf_calib::InvMassD0bar, + hf_calib::DecLength, + hf_calib::DecLengthXY, + hf_calib::NormDecLength, + hf_calib::NormDecLengthXY, + hf_calib::CosPa, + hf_calib::CosPaXY, + hf_calib::PointingAngle, + hf_calib::PointingAngleXY, + hf_calib::DecVtxChi2, + hf_calib::BdtScoreBkgD0, + hf_calib::BdtScorePromptD0, + hf_calib::BdtScoreNonpromptD0, + hf_calib::BdtScoreBkgD0bar, + hf_calib::BdtScorePromptD0bar, + hf_calib::BdtScoreNonpromptD0bar); +} // namespace aod +} // namespace o2 +#endif // DPG_TASKS_AOTTRACK_D0CALIBTABLES_H_ diff --git a/DPG/Tasks/AOTTrack/PID/CMakeLists.txt b/DPG/Tasks/AOTTrack/PID/CMakeLists.txt index f38baceaaab..17f77acfa59 100644 --- a/DPG/Tasks/AOTTrack/PID/CMakeLists.txt +++ b/DPG/Tasks/AOTTrack/PID/CMakeLists.txt @@ -12,4 +12,5 @@ add_subdirectory(Combined) add_subdirectory(TOF) add_subdirectory(TPC) +add_subdirectory(ITS) add_subdirectory(HMPID) diff --git a/DPG/Tasks/AOTTrack/PID/HMPID/qaHMPID.cxx b/DPG/Tasks/AOTTrack/PID/HMPID/qaHMPID.cxx index 78aeb2be252..a4e01d6a980 100644 --- a/DPG/Tasks/AOTTrack/PID/HMPID/qaHMPID.cxx +++ b/DPG/Tasks/AOTTrack/PID/HMPID/qaHMPID.cxx @@ -159,8 +159,8 @@ struct pidHmpidQa { histos.fill(HIST("hmpidSignal"), t.hmpidSignal()); histos.fill(HIST("PhivsEta"), t.track_as().eta(), t.track_as().phi()); - histos.fill(HIST("hmpidMomvsTrackMom"), t.track_as().p(), abs(t.hmpidMom())); - histos.fill(HIST("hmpidCkovvsMom"), abs(t.hmpidMom()), t.hmpidSignal()); + histos.fill(HIST("hmpidMomvsTrackMom"), t.track_as().p(), std::abs(t.hmpidMom())); + histos.fill(HIST("hmpidCkovvsMom"), std::abs(t.hmpidMom()), t.hmpidSignal()); histos.fill(HIST("hmpidXTrack"), t.hmpidXTrack()); histos.fill(HIST("hmpidYTrack"), t.hmpidYTrack()); histos.fill(HIST("hmpidXMip"), t.hmpidXMip()); @@ -173,7 +173,7 @@ struct pidHmpidQa { histos.fill(HIST("hmpidQMip"), t.hmpidQMip()); histos.fill(HIST("hmpidClusSize"), (t.hmpidClusSize() % 1000000) / 1000); histos.fill(HIST("TrackMom"), t.track_as().p()); - histos.fill(HIST("hmpidMom"), abs(t.hmpidMom())); + histos.fill(HIST("hmpidMom"), std::abs(t.hmpidMom())); for (int i = 0; i < 10; i++) { if (t.hmpidPhotsCharge()[i] > 0) histos.fill(HIST("hmpidPhotsCharge"), t.hmpidPhotsCharge()[i]); @@ -190,7 +190,7 @@ struct pidHmpidQa { histos.fill(HIST("hmpidQMip0"), t.hmpidQMip()); histos.fill(HIST("hmpidClusSize0"), (t.hmpidClusSize() % 1000000) / 1000); histos.fill(HIST("TrackMom0"), t.track_as().p()); - histos.fill(HIST("hmpidMom0"), abs(t.hmpidMom())); + histos.fill(HIST("hmpidMom0"), std::abs(t.hmpidMom())); for (int i = 0; i < 10; i++) { if (t.hmpidPhotsCharge()[i] > 0) histos.fill(HIST("hmpidPhotsCharge0"), t.hmpidPhotsCharge()[i]); @@ -208,7 +208,7 @@ struct pidHmpidQa { histos.fill(HIST("hmpidQMip1"), t.hmpidQMip()); histos.fill(HIST("hmpidClusSize1"), (t.hmpidClusSize() % 1000000) / 1000); histos.fill(HIST("TrackMom1"), t.track_as().p()); - histos.fill(HIST("hmpidMom1"), abs(t.hmpidMom())); + histos.fill(HIST("hmpidMom1"), std::abs(t.hmpidMom())); for (int i = 0; i < 10; i++) { if (t.hmpidPhotsCharge()[i] > 0) histos.fill(HIST("hmpidPhotsCharge1"), t.hmpidPhotsCharge()[i]); @@ -226,7 +226,7 @@ struct pidHmpidQa { histos.fill(HIST("hmpidQMip2"), t.hmpidQMip()); histos.fill(HIST("hmpidClusSize2"), (t.hmpidClusSize() % 1000000) / 1000); histos.fill(HIST("TrackMom2"), t.track_as().p()); - histos.fill(HIST("hmpidMom2"), abs(t.hmpidMom())); + histos.fill(HIST("hmpidMom2"), std::abs(t.hmpidMom())); for (int i = 0; i < 10; i++) { if (t.hmpidPhotsCharge()[i] > 0) histos.fill(HIST("hmpidPhotsCharge2"), t.hmpidPhotsCharge()[i]); @@ -244,7 +244,7 @@ struct pidHmpidQa { histos.fill(HIST("hmpidQMip3"), t.hmpidQMip()); histos.fill(HIST("hmpidClusSize3"), (t.hmpidClusSize() % 1000000) / 1000); histos.fill(HIST("TrackMom3"), t.track_as().p()); - histos.fill(HIST("hmpidMom3"), abs(t.hmpidMom())); + histos.fill(HIST("hmpidMom3"), std::abs(t.hmpidMom())); for (int i = 0; i < 10; i++) { if (t.hmpidPhotsCharge()[i] > 0) histos.fill(HIST("hmpidPhotsCharge3"), t.hmpidPhotsCharge()[i]); @@ -262,7 +262,7 @@ struct pidHmpidQa { histos.fill(HIST("hmpidQMip4"), t.hmpidQMip()); histos.fill(HIST("hmpidClusSize4"), (t.hmpidClusSize() % 1000000) / 1000); histos.fill(HIST("TrackMom4"), t.track_as().p()); - histos.fill(HIST("hmpidMom4"), abs(t.hmpidMom())); + histos.fill(HIST("hmpidMom4"), std::abs(t.hmpidMom())); for (int i = 0; i < 10; i++) { if (t.hmpidPhotsCharge()[i] > 0) histos.fill(HIST("hmpidPhotsCharge4"), t.hmpidPhotsCharge()[i]); @@ -280,7 +280,7 @@ struct pidHmpidQa { histos.fill(HIST("hmpidQMip5"), t.hmpidQMip()); histos.fill(HIST("hmpidClusSize5"), (t.hmpidClusSize() % 1000000) / 1000); histos.fill(HIST("TrackMom5"), t.track_as().p()); - histos.fill(HIST("hmpidMom5"), abs(t.hmpidMom())); + histos.fill(HIST("hmpidMom5"), std::abs(t.hmpidMom())); for (int i = 0; i < 10; i++) { if (t.hmpidPhotsCharge()[i] > 0) histos.fill(HIST("hmpidPhotsCharge5"), t.hmpidPhotsCharge()[i]); @@ -298,7 +298,7 @@ struct pidHmpidQa { histos.fill(HIST("hmpidQMip6"), t.hmpidQMip()); histos.fill(HIST("hmpidClusSize6"), (t.hmpidClusSize() % 1000000) / 1000); histos.fill(HIST("TrackMom6"), t.track_as().p()); - histos.fill(HIST("hmpidMom6"), abs(t.hmpidMom())); + histos.fill(HIST("hmpidMom6"), std::abs(t.hmpidMom())); for (int i = 0; i < 10; i++) { if (t.hmpidPhotsCharge()[i] > 0) histos.fill(HIST("hmpidPhotsCharge6"), t.hmpidPhotsCharge()[i]); diff --git a/ALICE3/Tools/CMakeLists.txt b/DPG/Tasks/AOTTrack/PID/ITS/CMakeLists.txt similarity index 70% rename from ALICE3/Tools/CMakeLists.txt rename to DPG/Tasks/AOTTrack/PID/ITS/CMakeLists.txt index 7aecd79362b..1550742c0f4 100644 --- a/ALICE3/Tools/CMakeLists.txt +++ b/DPG/Tasks/AOTTrack/PID/ITS/CMakeLists.txt @@ -9,7 +9,8 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2physics_add_executable(pidparam-tof-reso-alice3 - SOURCES handleParamTOFResoALICE3.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::ALICE3Core - ) +# ITS +o2physics_add_dpl_workflow(pid-its-qa + SOURCES qaPIDITS.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/DPG/Tasks/AOTTrack/PID/ITS/qaPIDITS.cxx b/DPG/Tasks/AOTTrack/PID/ITS/qaPIDITS.cxx new file mode 100644 index 00000000000..f247426df34 --- /dev/null +++ b/DPG/Tasks/AOTTrack/PID/ITS/qaPIDITS.cxx @@ -0,0 +1,351 @@ +// 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. +/// +/// \file qaPIDITS.cxx +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \brief Implementation for QA tasks of the ITS PID quantities +/// + +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StaticFor.h" +#include "Framework/runDataProcessing.h" + +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::track; + +static constexpr int nParameters = 1; +static const std::vector tableNames{"Electron", // 0 + "Muon", // 1 + "Pion", // 2 + "Kaon", // 3 + "Proton", // 4 + "Deuteron", // 5 + "Triton", // 6 + "Helium", // 7 + "Alpha"}; // 8 +static const std::vector parameterNames{"enable"}; +static const std::vector selectionNames{"selection"}; +static const int defaultParameters[9][nParameters]{{0}, {0}, {1}, {1}, {1}, {0}, {0}, {0}, {0}}; +static const float defaultPIDSelection[9][nParameters]{{-1.f}, {-1.f}, {-1.f}, {-1.f}, {-1.f}, {-1.f}, {-1.f}, {-1.f}, {-1.f}}; +static constexpr int Np = 9; +bool enableParticle[Np] = {false, false, false, + false, false, false, + false, false, false}; +std::array, Np> hNsigmaPos; +std::array, Np> hNsigmaNeg; + +template +float nsigmaITS(const TrackType& track, const o2::track::PID::ID id) +{ + switch (id) { + case o2::track::PID::Electron: + return track.itsNSigmaEl(); + case o2::track::PID::Muon: + return track.itsNSigmaMu(); + case o2::track::PID::Pion: + return track.itsNSigmaPi(); + case o2::track::PID::Kaon: + return track.itsNSigmaKa(); + case o2::track::PID::Proton: + return track.itsNSigmaPr(); + case o2::track::PID::Deuteron: + return track.itsNSigmaDe(); + case o2::track::PID::Triton: + return track.itsNSigmaTr(); + case o2::track::PID::Helium3: + return track.itsNSigmaHe(); + case o2::track::PID::Alpha: + return track.itsNSigmaAl(); + default: + LOG(fatal) << "PID not implemented"; + return 0.f; + } +} +template +float nsigmaTOF(const TrackType& track, const o2::track::PID::ID id) +{ + switch (id) { + case o2::track::PID::Electron: + return track.tofNSigmaEl(); + case o2::track::PID::Muon: + return track.tofNSigmaMu(); + case o2::track::PID::Pion: + return track.tofNSigmaPi(); + case o2::track::PID::Kaon: + return track.tofNSigmaKa(); + case o2::track::PID::Proton: + return track.tofNSigmaPr(); + case o2::track::PID::Deuteron: + return track.tofNSigmaDe(); + case o2::track::PID::Triton: + return track.tofNSigmaTr(); + case o2::track::PID::Helium3: + return track.tofNSigmaHe(); + case o2::track::PID::Alpha: + return track.tofNSigmaAl(); + default: + LOG(fatal) << "PID not implemented"; + return 0.f; + } +} +template +float nsigmaTPC(const TrackType& track, const o2::track::PID::ID id) +{ + switch (id) { + case o2::track::PID::Electron: + return track.tpcNSigmaEl(); + case o2::track::PID::Muon: + return track.tpcNSigmaMu(); + case o2::track::PID::Pion: + return track.tpcNSigmaPi(); + case o2::track::PID::Kaon: + return track.tpcNSigmaKa(); + case o2::track::PID::Proton: + return track.tpcNSigmaPr(); + case o2::track::PID::Deuteron: + return track.tpcNSigmaDe(); + case o2::track::PID::Triton: + return track.tpcNSigmaTr(); + case o2::track::PID::Helium3: + return track.tpcNSigmaHe(); + case o2::track::PID::Alpha: + return track.tpcNSigmaAl(); + default: + LOG(fatal) << "PID not implemented"; + return 0.f; + } +} + +float tpcSelValues[9]; +float tofSelValues[9]; + +/// Task to produce the ITS QA plots +struct itsPidQa { + static constexpr const char* pT[Np] = {"e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha"}; + static constexpr const char* pN[Np] = {"El", "Mu", "Pi", "Ka", "Pr", "De", "Tr", "He", "Al"}; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable> enabledParticle{"enabledParticle", + {defaultParameters[0], 9, nParameters, tableNames, parameterNames}, + "Produce QA for this species: 0 - no, 1 - yes"}; + Configurable> tofSelection{"tofSelection", + {defaultPIDSelection[0], 9, nParameters, tableNames, selectionNames}, + "Selection on the TOF nsigma"}; + Configurable> tpcSelection{"tpcSelection", + {defaultPIDSelection[0], 9, nParameters, tableNames, selectionNames}, + "Selection on the TPC nsigma"}; + + Configurable logAxis{"logAxis", 1, "Flag to use a log momentum axis"}; + Configurable nBinsP{"nBinsP", 3000, "Number of bins for the momentum"}; + Configurable minP{"minP", 0.01, "Minimum momentum in range"}; + Configurable maxP{"maxP", 20, "Maximum momentum in range"}; + ConfigurableAxis etaBins{"etaBins", {100, -1.f, 1.f}, "Binning in eta"}; + ConfigurableAxis phiBins{"phiBins", {100, 0, TMath::TwoPi()}, "Binning in phi"}; + ConfigurableAxis trackLengthBins{"trackLengthBins", {100, 0, 1000.f}, "Binning in track length plot"}; + ConfigurableAxis deltaBins{"deltaBins", {200, -1000.f, 1000.f}, "Binning in Delta (dEdx - expected dEdx)"}; + ConfigurableAxis expSigmaBins{"expSigmaBins", {200, 0.f, 200.f}, "Binning in expected Sigma"}; + ConfigurableAxis nSigmaBins{"nSigmaBins", {401, -10.025f, 10.025f}, "Binning in NSigma"}; + ConfigurableAxis avClsBins{"avClsBins", {200, 0, 20}, "Binning in average cluster size"}; + Configurable trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; + Configurable applyRapidityCut{"applyRapidityCut", false, "Flag to apply rapidity cut"}; + Configurable minTPCNcls{"minTPCNcls", 0, "Minimum number or TPC Clusters for tracks"}; + ConfigurableAxis tpcNclsBins{"tpcNclsBins", {16, 0, 160}, "Binning in number of clusters in TPC"}; + + template + float averageClusterSizeTrk(const TrackType& track) + { + return o2::aod::ITSResponse::averageClusterSize(track.itsClusterSizes()); + } + + float averageClusterSizePerCoslInv(uint32_t itsClusterSizes, float eta) { return o2::aod::ITSResponse::averageClusterSize(itsClusterSizes) * std::cosh(eta); } + + template + float averageClusterSizePerCoslInv(const TrackType& track) + { + return averageClusterSizePerCoslInv(track.itsClusterSizes(), track.eta()); + } + + void init(o2::framework::InitContext& context) + { + o2::aod::ITSResponse::setParameters(context); + const AxisSpec vtxZAxis{100, -20, 20, "Vtx_{z} (cm)"}; + const AxisSpec etaAxis{etaBins, "#it{#eta}"}; + const AxisSpec phiAxis{phiBins, "#it{#phi}"}; + const AxisSpec lAxis{trackLengthBins, "Track length (cm)"}; + AxisSpec ptAxis{nBinsP, minP, maxP, "#it{p}_{T}/|Z| (GeV/#it{c})"}; + AxisSpec pAxis{nBinsP, minP, maxP, "#it{p}/|Z| (GeV/#it{c})"}; + if (logAxis) { + ptAxis.makeLogarithmic(); + pAxis.makeLogarithmic(); + } + const AxisSpec avClsAxis{avClsBins, ""}; + const AxisSpec avClsEffAxis{avClsBins, " / cosh(#eta)"}; + + // Event properties + auto h = histos.add("event/evsel", "", kTH1D, {{10, 0.5, 10.5, "Ev. Sel."}}); + h->GetXaxis()->SetBinLabel(1, "Events read"); + h->GetXaxis()->SetBinLabel(2, "Passed ev. sel."); + h->GetXaxis()->SetBinLabel(3, "Passed vtx Z"); + + h = histos.add("event/trackselection", "", kTH1D, {{10, 0.5, 10.5, "Selection passed"}}); + h->GetXaxis()->SetBinLabel(1, "Tracks read"); + h->GetXaxis()->SetBinLabel(2, "isGlobalTrack"); + h->GetXaxis()->SetBinLabel(3, "hasITS"); + h->GetXaxis()->SetBinLabel(4, "hasTPC"); + h->GetXaxis()->SetBinLabel(5, Form("tpcNClsFound > %i", minTPCNcls.value)); + + histos.add("event/vertexz", "", kTH1D, {vtxZAxis}); + h = histos.add("event/particlehypo", "", kTH1D, {{10, 0, 10, "PID in tracking"}}); + for (int id = 0; id < 9; id++) { + h->GetXaxis()->SetBinLabel(id + 1, PID::getName(id)); + tpcSelValues[id] = tpcSelection->get(tableNames[id].c_str(), "selection"); + if (tpcSelValues[id] <= 0.f) { + tpcSelValues[id] = 999.f; + } + tofSelValues[id] = tofSelection->get(tableNames[id].c_str(), "selection"); + if (tofSelValues[id] <= 0.f) { + tofSelValues[id] = 999.f; + } + } + histos.add("event/eta", "", kTH1D, {etaAxis}); + histos.add("event/phi", "", kTH1D, {phiAxis}); + histos.add("event/etaphi", "", kTH2F, {etaAxis, phiAxis}); + histos.add("event/length", "", kTH1D, {lAxis}); + histos.add("event/pt", "", kTH1D, {ptAxis}); + histos.add("event/p", "", kTH1D, {pAxis}); + + for (int id = 0; id < 9; id++) { + const int f = enabledParticle->get(tableNames[id].c_str(), "enable"); + if (f != 1) { + continue; + } + // NSigma + const char* axisTitle = Form("N_{#sigma}^{ITS}(%s)", pT[id]); + const AxisSpec nSigmaAxis{nSigmaBins, axisTitle}; + enableParticle[id] = true; + hNsigmaPos[id] = histos.add(Form("nsigmaPos/%s", pN[id]), axisTitle, kTH2F, {pAxis, nSigmaAxis}); + hNsigmaNeg[id] = histos.add(Form("nsigmaNeg/%s", pN[id]), axisTitle, kTH2F, {pAxis, nSigmaAxis}); + } + histos.add("event/averageClusterSize", "", kTH2D, {pAxis, avClsAxis}); + histos.add("event/averageClusterSizePerCoslInv", "", kTH2D, {pAxis, avClsEffAxis}); + histos.add("event/SelectedAverageClusterSize", "", kTH2D, {pAxis, avClsAxis}); + histos.add("event/SelectedAverageClusterSizePerCoslInv", "", kTH2D, {pAxis, avClsEffAxis}); + LOG(info) << "QA PID ITS histograms:"; + histos.print(); + } + + Filter eventFilter = (o2::aod::evsel::sel8 == true && nabs(o2::aod::collision::posZ) < 10.f); + // Filter trackFilter = (requireGlobalTrackInFilter()); + using CollisionCandidate = soa::Filtered>::iterator; + using TrackCandidates = soa::Join; + void process(CollisionCandidate const& collision, + TrackCandidates const& tracks) + { + auto tracksWithPid = soa::Attach(tracks); + + if (tracks.size() != tracksWithPid.size()) { + LOG(fatal) << "Mismatch in track table size!" << tracks.size() << " vs " << tracksWithPid.size(); + } + histos.fill(HIST("event/evsel"), 1); + histos.fill(HIST("event/evsel"), 2); + histos.fill(HIST("event/evsel"), 3); + histos.fill(HIST("event/vertexz"), collision.posZ()); + + for (const auto& track : tracksWithPid) { + histos.fill(HIST("event/trackselection"), 1.f); + if (!track.isGlobalTrack()) { // Skipping non global tracks + continue; + } + histos.fill(HIST("event/trackselection"), 2.f); + if (!track.hasITS()) { // Skipping tracks without ITS + continue; + } + histos.fill(HIST("event/trackselection"), 3.f); + if (!track.hasTPC()) { // Skipping tracks without TPC + continue; + } + histos.fill(HIST("event/trackselection"), 4.f); + if (track.tpcNClsFound() < minTPCNcls) { // Skipping tracks without enough TPC clusters + continue; + } + + histos.fill(HIST("event/trackselection"), 5.f); + histos.fill(HIST("event/particlehypo"), track.pidForTracking()); + histos.fill(HIST("event/eta"), track.eta()); + histos.fill(HIST("event/phi"), track.phi()); + histos.fill(HIST("event/etaphi"), track.eta(), track.phi()); + histos.fill(HIST("event/length"), track.length()); + histos.fill(HIST("event/pt"), track.pt()); + histos.fill(HIST("event/p"), track.p()); + histos.fill(HIST("event/averageClusterSize"), track.p(), averageClusterSizeTrk(track)); + histos.fill(HIST("event/averageClusterSizePerCoslInv"), track.p(), averageClusterSizePerCoslInv(track)); + bool discard = false; + for (int id = 0; id < 9; id++) { + if (std::abs(nsigmaTPC(track, id)) > tpcSelValues[id]) { + LOG(debug) << "Discarding based on TPC hypothesis " << id << " " << std::abs(nsigmaTPC(track, id)) << ">" << tpcSelValues[id]; + discard = true; + break; + } + if (track.hasTOF()) { + if (std::abs(nsigmaTOF(track, id)) > tofSelValues[id]) { + LOG(debug) << "Discarding based on TOF hypothesis " << id << " " << std::abs(nsigmaTOF(track, id)) << ">" << tofSelValues[id]; + discard = true; + break; + } + } + } + if (discard) { + continue; + } + histos.fill(HIST("event/SelectedAverageClusterSize"), track.p(), averageClusterSizeTrk(track)); + histos.fill(HIST("event/SelectedAverageClusterSizePerCoslInv"), track.p(), averageClusterSizePerCoslInv(track)); + + for (o2::track::PID::ID id = 0; id <= o2::track::PID::Last; id++) { + if (!enableParticle[id]) { + continue; + } + if (applyRapidityCut) { + if (std::abs(track.rapidity(PID::getMass(id))) > 0.5) { + continue; + } + } + const float nsigma = nsigmaITS(track, id); + if (track.sign() > 0) { + hNsigmaPos[id]->Fill(track.pt(), nsigma); + } else { + hNsigmaNeg[id]->Fill(track.pt(), nsigma); + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/DPG/Tasks/AOTTrack/PID/TOF/CMakeLists.txt b/DPG/Tasks/AOTTrack/PID/TOF/CMakeLists.txt index f4f799d4f5b..87af80a68dd 100644 --- a/DPG/Tasks/AOTTrack/PID/TOF/CMakeLists.txt +++ b/DPG/Tasks/AOTTrack/PID/TOF/CMakeLists.txt @@ -20,6 +20,11 @@ o2physics_add_dpl_workflow(pid-tof-qa-beta PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(pid-tof-qa-beta-imp + SOURCES qaPIDTOFBetaImp.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(pid-tof-qa-mc SOURCES qaPIDTOFMC.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore diff --git a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOF.cxx b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOF.cxx index 24e5a09a21a..e350f1bbf28 100644 --- a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOF.cxx +++ b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOF.cxx @@ -15,16 +15,17 @@ /// \brief Implementation for QA tasks of the TOF PID quantities /// -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StaticFor.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" #include "Common/TableProducer/PID/pidTOFBase.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StaticFor.h" +#include "Framework/runDataProcessing.h" + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -135,7 +136,7 @@ struct tofPidQa { Configurable ptDeltaTEtaPhiMapMin{"ptDeltaTEtaPhiMapMin", 1.45f, "Threshold in pT to build the map of the delta time as a function of eta and phi"}; Configurable ptDeltaTEtaPhiMapMax{"ptDeltaTEtaPhiMapMax", 1.55f, "Threshold in pT to build the map of the delta time as a function of eta and phi"}; Configurable splitSignalPerCharge{"splitSignalPerCharge", true, "Split the signal per charge (reduces memory footprint if off)"}; - Configurable enableVsMomentumHistograms{"enableVsMomentumHistograms", false, "Enables plots vs momentum instead of just pT (reduces memory footprint if off)"}; + Configurable enableVsMomentumHistograms{"enableVsMomentumHistograms", 0, "1: Enables plots vs momentum instead of just pT 2: Enables plots vs momentum vs eta instead of just pT (reduces memory footprint if off)"}; Configurable requireGoodMatchTracks{"requireGoodMatchTracks", false, "Require good match tracks"}; Configurable pvContributorsMin{"pvContributorsMin", -10, "Minimum pvContributors"}; Configurable pvContributorsMax{"pvContributorsMax", 10000, "Maximum pvContributors"}; @@ -238,11 +239,16 @@ struct tofPidQa { return; } - if (enableVsMomentumHistograms) { + if (enableVsMomentumHistograms == 1) { histos.add(hdelta_evtime_fill[id].data(), axisTitle, kTH2F, {pAxis, deltaAxis}); histos.add(hdelta_evtime_tof[id].data(), axisTitle, kTH2F, {pAxis, deltaAxis}); histos.add(hdelta_evtime_ft0[id].data(), axisTitle, kTH2F, {pAxis, deltaAxis}); histos.add(hdelta_evtime_tofft0[id].data(), axisTitle, kTH2F, {pAxis, deltaAxis}); + } else if (enableVsMomentumHistograms == 2) { + histos.add(hdelta_evtime_fill[id].data(), axisTitle, kTH3F, {pAxis, etaAxis, deltaAxis}); + histos.add(hdelta_evtime_tof[id].data(), axisTitle, kTH3F, {pAxis, etaAxis, deltaAxis}); + histos.add(hdelta_evtime_ft0[id].data(), axisTitle, kTH3F, {pAxis, etaAxis, deltaAxis}); + histos.add(hdelta_evtime_tofft0[id].data(), axisTitle, kTH3F, {pAxis, etaAxis, deltaAxis}); } if (splitSignalPerCharge) { @@ -598,8 +604,10 @@ struct tofPidQa { // Filling info split per ev. time if (enableEvTimeSplitting) { if (t.isEvTimeTOF() && t.isEvTimeT0AC()) { // TOF + FT0 Ev. Time - if (enableVsMomentumHistograms) { + if (enableVsMomentumHistograms == 1) { histos.fill(HIST(hdelta_evtime_tofft0[id]), t.p(), diff); + } else if (enableVsMomentumHistograms == 2) { + histos.fill(HIST(hdelta_evtime_tofft0[id]), t.p(), t.eta(), diff); } if (splitSignalPerCharge) { histos.fill(HIST(hdelta_pt_evtime_tofft0[id]), t.pt(), diff, t.sign()); @@ -607,8 +615,10 @@ struct tofPidQa { histos.fill(HIST(hdelta_pt_evtime_tofft0[id]), t.pt(), diff); } } else if (t.isEvTimeT0AC()) { // FT0 Ev. Time - if (enableVsMomentumHistograms) { + if (enableVsMomentumHistograms == 1) { histos.fill(HIST(hdelta_evtime_ft0[id]), t.p(), diff); + } else if (enableVsMomentumHistograms == 2) { + histos.fill(HIST(hdelta_evtime_ft0[id]), t.p(), t.eta(), diff); } if (splitSignalPerCharge) { histos.fill(HIST(hdelta_pt_evtime_ft0[id]), t.pt(), diff, t.sign()); @@ -616,8 +626,10 @@ struct tofPidQa { histos.fill(HIST(hdelta_pt_evtime_ft0[id]), t.pt(), diff); } } else if (t.isEvTimeTOF()) { // TOF Ev. Time - if (enableVsMomentumHistograms) { + if (enableVsMomentumHistograms == 1) { histos.fill(HIST(hdelta_evtime_tof[id]), t.p(), diff); + } else if (enableVsMomentumHistograms == 2) { + histos.fill(HIST(hdelta_evtime_tof[id]), t.p(), t.eta(), diff); } if (splitSignalPerCharge) { histos.fill(HIST(hdelta_pt_evtime_tof[id]), t.pt(), diff, t.sign()); @@ -625,8 +637,10 @@ struct tofPidQa { histos.fill(HIST(hdelta_pt_evtime_tof[id]), t.pt(), diff); } } else { // No Ev. Time -> Fill Ev. Time - if (enableVsMomentumHistograms) { + if (enableVsMomentumHistograms == 1) { histos.fill(HIST(hdelta_evtime_fill[id]), t.p(), diff); + } else if (enableVsMomentumHistograms == 2) { + histos.fill(HIST(hdelta_evtime_fill[id]), t.p(), t.eta(), diff); } if (splitSignalPerCharge) { histos.fill(HIST(hdelta_pt_evtime_fill[id]), t.pt(), diff, t.sign()); diff --git a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBeta.cxx b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBeta.cxx index fe928c0ddc3..60ad0a9ab38 100644 --- a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBeta.cxx +++ b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBeta.cxx @@ -231,7 +231,7 @@ struct tofPidBetaQa { histos.fill(HIST("event/evsel"), 2); - if (abs(collision.posZ()) > 10.f) { + if (std::abs(collision.posZ()) > 10.f) { return; } diff --git a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBetaImp.cxx b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBetaImp.cxx new file mode 100644 index 00000000000..f503ab1d92d --- /dev/null +++ b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBetaImp.cxx @@ -0,0 +1,426 @@ +// 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. + +/// +/// \file qaPIDTOFBetaImp.cxx +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \brief Task to produce the TOF QA plots for Beta. Version using dynamic columns. Interim solution for test and benchmarking +/// + +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StaticFor.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/TableProducer/PID/pidTOFBase.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +/// Task to produce the TOF Beta QA plots +struct tofPidBetaQaImp { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Configurable logAxis{"logAxis", 0, "Flag to use a log momentum axis"}; + Configurable nBinsP{"nBinsP", 400, "Number of bins for the momentum"}; + Configurable minP{"minP", 0.1f, "Minimum momentum in range"}; + Configurable maxP{"maxP", 5.f, "Maximum momentum in range"}; + Configurable applyEvSel{"applyEvSel", 2, "Flag to apply event selection cut: 0 -> no event selection, 1 -> Run 2 event selection, 2 -> Run 3 event selection"}; + Configurable trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; + Configurable splitTrdTracks{"splitTrdTracks", false, "Flag to fill histograms for tracks with TRD match"}; + Configurable splitSignalPerCharge{"splitSignalPerCharge", true, "Split the signal per charge (reduces memory footprint if off)"}; + Configurable splitSignalPerEvTime{"splitSignalPerEvTime", true, "Split the signal per event time (reduces memory footprint if off)"}; + Configurable lastTrdLayerForTrdMatch{"lastTrdLayerForTrdMatch", 5, "Last TRD layer to consider for TRD match"}; + + ConfigurableAxis tofMassBins{"tofMassBins", {1000, 0, 3.f}, "Binning in the TOF mass plot"}; + ConfigurableAxis tofBetaBins{"tofBetaBins", {4000, 0, 2.f}, "Binning in the TOF beta plot"}; + ConfigurableAxis trackLengthBins{"trackLengthBins", {100, 0, 1000.f}, "Binning in track length plot"}; + Configurable requireGoodMatchTracks{"requireGoodMatchTracks", false, "Require good match tracks"}; + Configurable mMaxTOFChi2{"maxTOFChi2", 3.f, "Maximum TOF Chi2"}; + Configurable mEtaWindow{"etaWindow", 0.8f, "Window in eta for tracks"}; + + void init(o2::framework::InitContext&) + { + const AxisSpec vtxZAxis{100, -20, 20, "Vtx_{z} (cm)"}; + const AxisSpec tofAxis{10000, 0, 2e6, "TOF Signal"}; + const AxisSpec betaAxis{tofBetaBins, "TOF #beta"}; + const AxisSpec massAxis{tofMassBins, "TOF mass (GeV/#it{c}^{2})"}; + const AxisSpec trdAxis{10, -0.5, 9.5, "Last TRD cluster"}; + const AxisSpec etaAxis{100, -2, 2, "#it{#eta}"}; + const AxisSpec colTimeAxis{100, -2000, 2000, "Collision time (ps)"}; + const AxisSpec lAxis{trackLengthBins, "Track length (cm)"}; + const AxisSpec tofChi2Axis{1000, 0, 20, "TOF residual (cm)"}; + const AxisSpec ptResoAxis{100, 0, 0.1, "#sigma_{#it{p}_{T}}"}; + const AxisSpec pAxisPosNeg{2 * nBinsP, -maxP, maxP, "signed #it{p} (GeV/#it{c})"}; + AxisSpec ptAxis{nBinsP, minP, maxP, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec pAxis{nBinsP, minP, maxP, "#it{p} (GeV/#it{c})"}; + if (logAxis) { + ptAxis.makeLogarithmic(); + pAxis.makeLogarithmic(); + } + + // Event properties + histos.add("event/tofsignal", "", HistType::kTH2F, {pAxis, tofAxis}); + const AxisSpec chargeAxis{2, -2.f, 2.f, "Charge"}; + + // TOF mass + if (splitSignalPerCharge) { + histos.add("tofmass/inclusive", "", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + if (splitSignalPerEvTime) { + histos.add("tofmass/EvTimeTOF", "Ev. Time TOF", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + histos.add("tofmass/EvTimeTOFOnly", "Ev. Time TOF Only", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + histos.add("tofmass/EvTimeT0AC", "Ev. Time T0AC", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + histos.add("tofmass/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + } + if (splitTrdTracks) { + histos.add("tofmass/trd/inclusive", "(hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + if (splitSignalPerEvTime) { + histos.add("tofmass/trd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + histos.add("tofmass/trd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + histos.add("tofmass/trd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + histos.add("tofmass/trd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + } + histos.add("tofmass/notrd/inclusive", "(hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + if (splitSignalPerEvTime) { + histos.add("tofmass/notrd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + histos.add("tofmass/notrd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + histos.add("tofmass/notrd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + histos.add("tofmass/notrd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH3F, {pAxis, massAxis, chargeAxis}); + } + } + } else { + histos.add("tofmass/inclusive", "", HistType::kTH2F, {pAxis, massAxis}); + if (splitSignalPerEvTime) { + histos.add("tofmass/EvTimeTOF", "Ev. Time TOF", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/EvTimeTOFOnly", "Ev. Time TOF Only", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/EvTimeT0AC", "Ev. Time T0AC", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH2F, {pAxis, massAxis}); + } + if (splitTrdTracks) { + histos.add("tofmass/trd/inclusive", "(hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + if (splitSignalPerEvTime) { + histos.add("tofmass/trd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/trd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/trd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/trd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + } + histos.add("tofmass/notrd/inclusive", "(hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + if (splitSignalPerEvTime) { + histos.add("tofmass/notrd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/notrd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/notrd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/notrd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH2F, {pAxis, massAxis}); + } + } + } + + // TOF beta + if (splitSignalPerCharge) { + histos.add("tofbeta/inclusive", "", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + if (splitSignalPerEvTime) { + histos.add("tofbeta/EvTimeTOF", "Ev. Time TOF", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + histos.add("tofbeta/EvTimeTOFOnly", "Ev. Time TOF Only", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + histos.add("tofbeta/EvTimeT0AC", "Ev. Time T0AC", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + histos.add("tofbeta/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + } + if (splitTrdTracks) { + histos.add("tofbeta/trd/inclusive", "(hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + if (splitSignalPerEvTime) { + histos.add("tofbeta/trd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + histos.add("tofbeta/trd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + histos.add("tofbeta/trd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + histos.add("tofbeta/trd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + } + histos.add("tofbeta/notrd/inclusive", "(hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + if (splitSignalPerEvTime) { + histos.add("tofbeta/notrd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + histos.add("tofbeta/notrd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + histos.add("tofbeta/notrd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + histos.add("tofbeta/notrd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); + } + } + } else { + histos.add("tofbeta/inclusive", "", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + if (splitSignalPerEvTime) { + histos.add("tofbeta/EvTimeTOF", "Ev. Time TOF", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + histos.add("tofbeta/EvTimeTOFOnly", "Ev. Time TOF Only", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + histos.add("tofbeta/EvTimeT0AC", "Ev. Time T0AC", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + histos.add("tofbeta/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + } + if (splitTrdTracks) { + histos.add("tofbeta/trd/inclusive", "(hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + if (splitSignalPerEvTime) { + histos.add("tofbeta/trd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + histos.add("tofbeta/trd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + histos.add("tofbeta/trd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + histos.add("tofbeta/trd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + } + histos.add("tofbeta/notrd/inclusive", "(hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + if (splitSignalPerEvTime) { + histos.add("tofbeta/notrd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + histos.add("tofbeta/notrd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + histos.add("tofbeta/notrd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + histos.add("tofbeta/notrd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); + } + } + } + + histos.add("event/tofchi2", "", HistType::kTH1F, {tofChi2Axis}); + histos.add("event/eta", "", HistType::kTH1F, {etaAxis}); + histos.add("event/length", "", HistType::kTH1F, {lAxis}); + if (splitTrdTracks) { + histos.add("event/trd/length", "", HistType::kTH2F, {lAxis, trdAxis}); + histos.add("event/notrd/length", "", HistType::kTH1F, {lAxis}); + } + histos.add("event/pt", "", HistType::kTH1F, {ptAxis}); + histos.add("event/p", "", HistType::kTH1F, {pAxis}); + auto h = histos.add("event/evsel", "", kTH1F, {{10, 0.5, 10.5, "Ev. Sel."}}); + h->GetXaxis()->SetBinLabel(1, "Events read"); + h->GetXaxis()->SetBinLabel(2, "Passed ev. sel."); + h->GetXaxis()->SetBinLabel(3, "Passed vtx Z"); + + h = histos.add("event/trackselection", "", kTH1F, {{10, 0.5, 10.5, "Selection passed"}}); + h->GetXaxis()->SetBinLabel(1, "Tracks read"); + h->GetXaxis()->SetBinLabel(2, "hasTOF"); + h->GetXaxis()->SetBinLabel(3, "isGlobalTrack"); + h->GetXaxis()->SetBinLabel(4, TString::Format("TOF chi2 < %.2f", mMaxTOFChi2.value)); + } + + Filter eventFilter = (applyEvSel.node() == 0) || + ((applyEvSel.node() == 1) && (o2::aod::evsel::sel7 == true)) || + ((applyEvSel.node() == 2) && (o2::aod::evsel::sel8 == true)); + Filter trackFilter = (trackSelection.node() == 0) || + ((trackSelection.node() == 1) && requireGlobalTrackInFilter()) || + ((trackSelection.node() == 2) && requireGlobalTrackWoPtEtaInFilter()) || + ((trackSelection.node() == 3) && requireGlobalTrackWoDCAInFilter()) || + ((trackSelection.node() == 4) && requireQualityTracksInFilter()) || + ((trackSelection.node() == 5) && requireInAcceptanceTracksInFilter()); + Filter etaFilter = (nabs(o2::aod::track::eta) < mEtaWindow); + + using CollisionCandidate = soa::Filtered>::iterator; + using TrackCandidates = soa::Join; + void process(CollisionCandidate const& collision, + soa::Filtered const& tracks) + { + + auto tracksWithPid = soa::Attach, aod::TOFMass, aod::TOFBeta>(tracks); + histos.fill(HIST("event/evsel"), 1); + if (applyEvSel == 1) { + if (!collision.sel7()) { + return; + } + } else if (applyEvSel == 2) { + if (!collision.sel8()) { + return; + } + } + + histos.fill(HIST("event/evsel"), 2); + + if (std::abs(collision.posZ()) > 10.f) { + return; + } + + histos.fill(HIST("event/evsel"), 3); + for (auto const& t : tracks) { + auto track = tracksWithPid.iteratorAt(t.globalIndex() - tracksWithPid.iteratorAt(0).globalIndex()); + // Check consistency + if (track.hasTOF() != t.hasTOF()) { + LOG(fatal) << "Mismatch in TOF availability!"; + } + if (track.pt() != t.pt()) { + LOG(fatal) << "Mismatch in pt!"; + } + histos.fill(HIST("event/trackselection"), 1.f); + if (!track.hasTOF()) { // Skipping tracks without TOF + continue; + } + histos.fill(HIST("event/trackselection"), 2.f); + if (!track.isGlobalTrack()) { + continue; + } + histos.fill(HIST("event/trackselection"), 3.f); + if (track.tofChi2() > mMaxTOFChi2) { // Skipping tracks with large Chi2 + continue; + } + histos.fill(HIST("event/trackselection"), 4.f); + const float tofMass = track.tofMass(); + const float tofBeta = track.tofBeta(); + if (splitSignalPerCharge) { + histos.fill(HIST("tofmass/inclusive"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/inclusive"), track.p(), tofBeta, track.sign()); + if (splitSignalPerEvTime) { + if (track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/EvTimeTOF"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/EvTimeTOF"), track.p(), tofBeta, track.sign()); + } + if (track.isEvTimeTOF() && !track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/EvTimeTOFOnly"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/EvTimeTOFOnly"), track.p(), tofBeta, track.sign()); + } + if (track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/EvTimeT0AC"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/EvTimeT0AC"), track.p(), tofBeta, track.sign()); + } + if (track.isEvTimeT0AC() && !track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/EvTimeT0ACOnly"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/EvTimeT0ACOnly"), track.p(), tofBeta, track.sign()); + } + } + } else { + histos.fill(HIST("tofmass/inclusive"), track.p(), tofMass); + histos.fill(HIST("tofbeta/inclusive"), track.p(), tofBeta); + if (splitSignalPerEvTime) { + if (track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/EvTimeTOF"), track.p(), tofMass); + histos.fill(HIST("tofbeta/EvTimeTOF"), track.p(), tofBeta); + } + if (track.isEvTimeTOF() && !track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/EvTimeTOFOnly"), track.p(), tofMass); + histos.fill(HIST("tofbeta/EvTimeTOFOnly"), track.p(), tofBeta); + } + if (track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/EvTimeT0AC"), track.p(), tofMass); + histos.fill(HIST("tofbeta/EvTimeT0AC"), track.p(), tofBeta); + } + if (track.isEvTimeT0AC() && !track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/EvTimeT0ACOnly"), track.p(), tofMass); + histos.fill(HIST("tofbeta/EvTimeT0ACOnly"), track.p(), tofBeta); + } + } + } + histos.fill(HIST("event/length"), track.length()); + histos.fill(HIST("event/tofchi2"), track.tofChi2()); + histos.fill(HIST("event/eta"), track.eta()); + histos.fill(HIST("event/tofsignal"), track.p(), track.tofSignal()); + histos.fill(HIST("event/pt"), track.pt()); + histos.fill(HIST("event/p"), track.p()); + + if (!splitTrdTracks) { // If splitting of TRD tracks is not enabled, skip + continue; + } + + if (!track.hasTRD()) { + histos.fill(HIST("event/notrd/length"), track.length()); + if (splitSignalPerCharge) { + histos.fill(HIST("tofmass/notrd/inclusive"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/notrd/inclusive"), track.p(), tofBeta, track.sign()); + if (splitSignalPerEvTime) { + if (track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/notrd/EvTimeTOF"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/notrd/EvTimeTOF"), track.p(), tofBeta, track.sign()); + } + if (track.isEvTimeTOF() && !track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/notrd/EvTimeTOFOnly"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/notrd/EvTimeTOFOnly"), track.p(), tofBeta, track.sign()); + } + if (track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/notrd/EvTimeT0AC"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/notrd/EvTimeT0AC"), track.p(), tofBeta, track.sign()); + } + if (track.isEvTimeT0AC() && !track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/notrd/EvTimeT0ACOnly"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/notrd/EvTimeT0ACOnly"), track.p(), tofBeta, track.sign()); + } + } + } else { + const float signedp = track.p() * track.sign(); + histos.fill(HIST("tofmass/notrd/inclusive"), signedp, tofMass); + histos.fill(HIST("tofbeta/notrd/inclusive"), signedp, tofBeta); + if (splitSignalPerEvTime) { + if (track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/notrd/EvTimeTOF"), signedp, tofMass); + histos.fill(HIST("tofbeta/notrd/EvTimeTOF"), signedp, tofBeta); + } + if (track.isEvTimeTOF() && !track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/notrd/EvTimeTOFOnly"), signedp, tofMass); + histos.fill(HIST("tofbeta/notrd/EvTimeTOFOnly"), signedp, tofBeta); + } + if (track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/notrd/EvTimeT0AC"), signedp, tofMass); + histos.fill(HIST("tofbeta/notrd/EvTimeT0AC"), signedp, tofBeta); + } + if (track.isEvTimeT0AC() && !track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/notrd/EvTimeT0ACOnly"), signedp, tofMass); + histos.fill(HIST("tofbeta/notrd/EvTimeT0ACOnly"), signedp, tofBeta); + } + } + } + } else { + + int lastLayer = 0; + for (int l = 7; l >= 0; l--) { + if (track.trdPattern() & (1 << l)) { + lastLayer = l; + break; + } + } + + histos.fill(HIST("event/trd/length"), track.length(), lastLayer); + if (lastLayer < lastTrdLayerForTrdMatch) { + continue; + } + if (splitSignalPerCharge) { + histos.fill(HIST("tofmass/trd/inclusive"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/trd/inclusive"), track.p(), tofBeta, track.sign()); + if (splitSignalPerEvTime) { + if (track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/trd/EvTimeTOF"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/trd/EvTimeTOF"), track.p(), tofBeta, track.sign()); + } + if (track.isEvTimeTOF() && !track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/trd/EvTimeTOFOnly"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/trd/EvTimeTOFOnly"), track.p(), tofBeta, track.sign()); + } + if (track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/trd/EvTimeT0AC"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/trd/EvTimeT0AC"), track.p(), tofBeta, track.sign()); + } + if (track.isEvTimeT0AC() && !track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/trd/EvTimeT0ACOnly"), track.p(), tofMass, track.sign()); + histos.fill(HIST("tofbeta/trd/EvTimeT0ACOnly"), track.p(), tofBeta, track.sign()); + } + } + } else { + const float signedp = track.p() * track.sign(); + histos.fill(HIST("tofmass/trd/inclusive"), signedp, tofMass); + histos.fill(HIST("tofbeta/trd/inclusive"), signedp, tofBeta); + if (splitSignalPerEvTime) { + if (track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/trd/EvTimeTOF"), signedp, tofMass); + histos.fill(HIST("tofbeta/trd/EvTimeTOF"), signedp, tofBeta); + } + if (track.isEvTimeTOF() && !track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/trd/EvTimeTOFOnly"), signedp, tofMass); + histos.fill(HIST("tofbeta/trd/EvTimeTOFOnly"), signedp, tofBeta); + } + if (track.isEvTimeT0AC()) { + histos.fill(HIST("tofmass/trd/EvTimeT0AC"), signedp, tofMass); + histos.fill(HIST("tofbeta/trd/EvTimeT0AC"), signedp, tofBeta); + } + if (track.isEvTimeT0AC() && !track.isEvTimeTOF()) { + histos.fill(HIST("tofmass/trd/EvTimeT0ACOnly"), signedp, tofMass); + histos.fill(HIST("tofbeta/trd/EvTimeT0ACOnly"), signedp, tofBeta); + } + } + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPC.cxx b/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPC.cxx index 40913b39b79..2794070498d 100644 --- a/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPC.cxx +++ b/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPC.cxx @@ -299,7 +299,7 @@ struct tpcPidQa { histos.fill(HIST("event/evsel"), 2); } - if (abs(collision.posZ()) > 10.f) { + if (std::abs(collision.posZ()) > 10.f) { return false; } if constexpr (fillHistograms) { @@ -396,7 +396,7 @@ struct tpcPidQa { } if (applyRapidityCut) { - if (abs(t.rapidity(PID::getMass(id))) > 0.5) { + if (std::abs(t.rapidity(PID::getMass(id))) > 0.5) { continue; } } diff --git a/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCSignal.cxx b/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCSignal.cxx index 837435a038e..bf8492b8036 100644 --- a/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCSignal.cxx +++ b/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCSignal.cxx @@ -219,7 +219,7 @@ struct tpcPidQaSignal { if (!t.has_collision()) { continue; } - if (abs(t.collision().posZ()) > 10.f) { + if (std::abs(t.collision().posZ()) > 10.f) { continue; } if (!isTrackSelected(t)) { @@ -269,7 +269,7 @@ struct tpcPidQaSignal { histos.fill(HIST("event/evsel"), 2); - if (abs(collision.posZ()) > 10.f) { + if (std::abs(collision.posZ()) > 10.f) { return; } histos.fill(HIST("event/evsel"), 3); diff --git a/DPG/Tasks/AOTTrack/V0Cascades/perfK0sResolution.cxx b/DPG/Tasks/AOTTrack/V0Cascades/perfK0sResolution.cxx index 2769289a732..91effcc47b4 100644 --- a/DPG/Tasks/AOTTrack/V0Cascades/perfK0sResolution.cxx +++ b/DPG/Tasks/AOTTrack/V0Cascades/perfK0sResolution.cxx @@ -9,6 +9,8 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -291,10 +293,10 @@ struct perfK0sResolution { if (!ntrack.hasTPC() || !ptrack.hasTPC()) { return false; } - if (abs(ntrack.tpcNSigmaPi()) > nMaxTPCNsigma) { + if (std::abs(ntrack.tpcNSigmaPi()) > nMaxTPCNsigma) { return false; } - if (abs(ptrack.tpcNSigmaPi()) > nMaxTPCNsigma) { + if (std::abs(ptrack.tpcNSigmaPi()) > nMaxTPCNsigma) { return false; } if (ntrack.tpcNClsCrossedRows() < extraCutTPCClusters || ptrack.tpcNClsCrossedRows() < extraCutTPCClusters) { diff --git a/DPG/Tasks/AOTTrack/V0Cascades/qaLamMomResolution.cxx b/DPG/Tasks/AOTTrack/V0Cascades/qaLamMomResolution.cxx index d1b20636bea..9ee92d0a509 100644 --- a/DPG/Tasks/AOTTrack/V0Cascades/qaLamMomResolution.cxx +++ b/DPG/Tasks/AOTTrack/V0Cascades/qaLamMomResolution.cxx @@ -339,7 +339,7 @@ struct qaLamMomResolution { return; } hist.fill(HIST("hEventSelectionFlow"), 1.f); - if (collSelection && (abs(collision.posZ()) >= 10.)) { + if (collSelection && (std::abs(collision.posZ()) >= 10.)) { return; } hist.fill(HIST("hEventSelectionFlow"), 2.f); diff --git a/DPG/Tasks/AOTTrack/derivedDataCreatorD0Calibration.cxx b/DPG/Tasks/AOTTrack/derivedDataCreatorD0Calibration.cxx new file mode 100644 index 00000000000..20b50370644 --- /dev/null +++ b/DPG/Tasks/AOTTrack/derivedDataCreatorD0Calibration.cxx @@ -0,0 +1,829 @@ +// 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. + +/// \file derivedDataCreatorD0Calibration.cxx +/// \brief Producer of derived tables of D0 candidates, daughter tracks and collisions for calibration studies +/// +/// \author Fabrizio Grosa , CERN + +#include "D0CalibTables.h" + +#include "PWGHF/Utils/utilsAnalysis.h" +#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsPid.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelectorPID.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/OccupancyTables.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Tools/ML/MlResponse.h" + +#include "CommonDataFormat/InteractionRecord.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::analysis; +using namespace o2::constants::physics; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::hf_calib; + +struct DerivedDataCreatorD0Calibration { + + Produces collTable; + Produces trackTable; + Produces candTable; + + struct : ConfigurableGroup { + Configurable ptMin{"ptMin", 0.4, "min. track pT"}; + Configurable absEtaMax{"absEtaMax", 1., "max. track absolute eta"}; + Configurable> binsPt{"binsPt", std::vector{hf_calib::vecBinsPtTrack}, "track pT bin limits for DCA pT-dependent cut"}; + Configurable> limitsDca{"limitsDca", {hf_calib::CutsTrack[0], hf_calib::NBinsPtTrack, hf_calib::NCutVarsTrack, hf_calib::labelsPtTrack, hf_calib::labelsCutVarTrack}, "Single-track selections per pT bin"}; + // TPC PID + Configurable ptPidTpcMin{"ptPidTpcMin", 0., "Lower bound of track pT for TPC PID"}; + Configurable ptPidTpcMax{"ptPidTpcMax", 1000., "Upper bound of track pT for TPC PID"}; + Configurable nSigmaTpcMax{"nSigmaTpcMax", 3., "Nsigma cut on TPC only"}; + Configurable usePidTpcOnly{"usePidTpcOnly", false, "Only use TPC PID"}; + // TOF PID + Configurable ptPidTofMin{"ptPidTofMin", 0., "Lower bound of track pT for TOF PID"}; + Configurable ptPidTofMax{"ptPidTofMax", 1000., "Upper bound of track pT for TOF PID"}; + Configurable nSigmaTofMax{"nSigmaTofMax", 3., "Nsigma cut on TOF only"}; + std::string prefix = "trackCuts"; + } cfgTrackCuts; + + struct : ConfigurableGroup { + Configurable ptMin{"ptMin", 0., "min. D0-candidate pT"}; + Configurable> binsPt{"binsPt", std::vector{hf_calib::vecBinsPtCand}, "pT bin limits"}; + Configurable> topologicalCuts{"topologicalCuts", {hf_calib::CutsCand[0], hf_calib::NBinsPtCand, hf_calib::NCutVarsCand, hf_calib::labelsPtCand, hf_calib::labelsCutVarCand}, "D0 candidate selection per pT bin"}; + std::string prefix = "candidateCuts"; + } cfgCandCuts; + + struct : ConfigurableGroup { + Configurable apply{"apply", false, "flag to apply downsampling"}; + Configurable pathCcdbWeights{"pathCcdbWeights", "", "CCDB path containing pT-differential weights"}; + std::string prefix = "downsampling"; + } cfgDownsampling; + + struct : ConfigurableGroup { + Configurable apply{"apply", false, "flag to apply downsampling"}; + Configurable> binsPt{"binsPt", std::vector{hf_calib::vecBinsPtMl}, "pT bin limits for ML models inference"}; + Configurable> thresholdMlScores{"thresholdMlScores", {hf_calib::CutsMl[0], hf_calib::NBinsPtMl, 3, hf_calib::labelsPtMl, hf_calib::labelsCutMl}, "Threshold values for Ml output scores of D0 candidates"}; + Configurable loadMlModelsFromCCDB{"loadMlModelsFromCCDB", true, "Flag to enable or disable the loading of ML models from CCDB"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"Users/f/fgrosa/D0Calib/BDT/Pt0_1"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_pT_0_1.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + std::string prefix = "ml"; + } cfgMl; + + using TracksWCovExtraPid = soa::Join; + using CollisionsWEvSel = soa::Join; + using TrackMeanOccs = soa::Join; + + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + + o2::vertexing::DCAFitterN<2> df; // 2-prong vertex fitter + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + o2::analysis::MlResponse mlResponse; + + TrackSelectorPi selectorPion; + TrackSelectorKa selectorKaon; + + int runNumber{0}; + double bz{0.}; + const float zVtxMax{10.f}; + // tolerances for preselections before vertex reconstruction + const float ptTolerance{0.1f}; + const float invMassTolerance{0.05f}; + uint32_t precisionCovMask{0xFFFFE000}; // 10 bits + uint32_t precisionDcaMask{0xFFFFFC00}; // 13 bits + + OutputObj histDownSampl{"histDownSampl"}; + + void init(InitContext const&) + { + // First we set the CCDB manager + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + if (cfgDownsampling.apply) { + histDownSampl.setObject(reinterpret_cast(ccdb->getSpecific(cfgDownsampling.pathCcdbWeights))); + } + + if (cfgMl.apply) { + std::vector cutDir = {o2::cuts_ml::CutDirection::CutGreater, o2::cuts_ml::CutDirection::CutSmaller, o2::cuts_ml::CutDirection::CutSmaller}; + mlResponse.configure(cfgMl.binsPt, cfgMl.thresholdMlScores, cutDir, 3); + if (cfgMl.loadMlModelsFromCCDB) { + ccdbApi.init("http://alice-ccdb.cern.ch"); + mlResponse.setModelPathsCCDB(cfgMl.onnxFileNames, ccdbApi, cfgMl.modelPathsCCDB, -1); + } else { + mlResponse.setModelPathsLocal(cfgMl.onnxFileNames); + } + mlResponse.init(); + } + + df.setPropagateToPCA(true); + df.setMaxR(200.f); + df.setMaxDZIni(4.f); + df.setMinParamChange(1.e-3f); + df.setMinRelChi2Change(0.9f); + df.setUseAbsDCA(false); + df.setWeightedFinalPCA(false); + df.setMatCorrType(o2::base::Propagator::MatCorrType::USEMatCorrNONE); // we are always inside the beampipe + + selectorPion.setRangePtTpc(cfgTrackCuts.ptPidTpcMin, cfgTrackCuts.ptPidTpcMax); + selectorPion.setRangeNSigmaTpc(-cfgTrackCuts.nSigmaTpcMax, cfgTrackCuts.nSigmaTpcMax); + selectorPion.setRangePtTof(cfgTrackCuts.ptPidTofMin, cfgTrackCuts.ptPidTofMax); + selectorPion.setRangeNSigmaTof(-cfgTrackCuts.nSigmaTofMax, cfgTrackCuts.nSigmaTofMax); + selectorKaon = selectorPion; + } + + void process(CollisionsWEvSel const& collisions, + aod::TrackAssoc const& trackIndices, + TracksWCovExtraPid const&, + aod::BCsWithTimestamps const&, + TrackMeanOccs const&, + aod::TracksQAVersion const&) + { + std::map selectedCollisions; // map with indices of selected collisions (key: original AOD Collision table index, value: D0 collision index) + std::map selectedTracks; // map with indices of selected tracks (key: original AOD Track table index, value: D0 daughter track index) + + for (auto const& collision : collisions) { + + // minimal event selection + if (!collision.sel8()) { + continue; + } + auto primaryVertex = getPrimaryVertex(collision); + if (std::abs(primaryVertex.getZ()) > zVtxMax) { + continue; + } + + auto covMatrixPV = primaryVertex.getCov(); + + auto bc = collision.template bc_as(); + if (runNumber != bc.runNumber()) { + initCCDB(bc, runNumber, ccdb, "GLO/Config/GRPMagField", nullptr, false); + bz = o2::base::Propagator::Instance()->getNominalBz(); + } + o2::InteractionRecord eventIR; + eventIR.setFromLong(bc.globalBC()); + + auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); + for (auto const& trackIndexPos : groupedTrackIndices) { + auto trackPos = trackIndexPos.template track_as(); + // track selections + if (trackPos.sign() < 0) { // first positive track + continue; + } + if (!trackPos.isGlobalTrackWoDCA()) { + continue; + } + if (trackPos.pt() < cfgTrackCuts.ptMin) { + continue; + } + if (std::abs(trackPos.eta()) > cfgTrackCuts.absEtaMax) { + continue; + } + auto trackParCovPos = getTrackParCov(trackPos); + o2::dataformats::DCA dcaPos; + trackParCovPos.propagateToDCA(primaryVertex, bz, &dcaPos); + if (!isSelectedTrackDca(cfgTrackCuts.binsPt, cfgTrackCuts.limitsDca, trackParCovPos.getPt(), dcaPos.getY(), dcaPos.getZ())) { + continue; + } + + int pidTrackPosKaon{-1}; + int pidTrackPosPion{-1}; + if (cfgTrackCuts.usePidTpcOnly) { + /// kaon TPC PID positive daughter + pidTrackPosKaon = selectorKaon.statusTpc(trackPos); + /// pion TPC PID positive daughter + pidTrackPosPion = selectorPion.statusTpc(trackPos); + } else { + /// kaon TPC, TOF PID positive daughter + pidTrackPosKaon = selectorKaon.statusTpcAndTof(trackPos); + /// pion TPC, TOF PID positive daughter + pidTrackPosPion = selectorPion.statusTpcAndTof(trackPos); + } + + for (auto const& trackIndexNeg : groupedTrackIndices) { + auto trackNeg = trackIndexNeg.template track_as(); + // track selections + if (trackNeg.sign() > 0) { // second negative track + continue; + } + if (!trackNeg.isGlobalTrackWoDCA()) { + continue; + } + if (trackNeg.pt() < cfgTrackCuts.ptMin) { + continue; + } + if (std::abs(trackNeg.eta()) > cfgTrackCuts.absEtaMax) { + continue; + } + auto trackParCovNeg = getTrackParCov(trackNeg); + o2::dataformats::DCA dcaNeg; + trackParCovNeg.propagateToDCA(primaryVertex, bz, &dcaNeg); + if (!isSelectedTrackDca(cfgTrackCuts.binsPt, cfgTrackCuts.limitsDca, trackParCovNeg.getPt(), dcaNeg.getY(), dcaNeg.getZ())) { + continue; + } + + int pidTrackNegKaon{-1}; + int pidTrackNegPion{-1}; + if (cfgTrackCuts.usePidTpcOnly) { + /// kaon TPC PID negative daughter + pidTrackNegKaon = selectorKaon.statusTpc(trackNeg); + /// pion TPC PID negative daughter + pidTrackNegPion = selectorPion.statusTpc(trackNeg); + } else { + /// kaon TPC, TOF PID negative daughter + pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg); + /// pion TPC, TOF PID negative daughter + pidTrackNegPion = selectorPion.statusTpcAndTof(trackNeg); + } + + // preselections + // PID + uint8_t massHypo{D0MassHypo::D0AndD0Bar}; // both mass hypotheses a priori + if (pidTrackPosPion == TrackSelectorPID::Rejected || pidTrackNegKaon == TrackSelectorPID::Rejected) { + massHypo -= D0MassHypo::D0; // exclude D0 + } + if (pidTrackNegPion == TrackSelectorPID::Rejected || pidTrackPosKaon == TrackSelectorPID::Rejected) { + massHypo -= D0MassHypo::D0Bar; // exclude D0Bar + } + if (massHypo == 0) { + continue; + } + + // pt + std::array pVecNoVtxD0 = RecoDecay::pVec(trackPos.pVector(), trackNeg.pVector()); + float ptNoVtxD0 = RecoDecay::pt(pVecNoVtxD0); + if (ptNoVtxD0 - ptTolerance < cfgCandCuts.ptMin) { + continue; + } + int ptBinNoVtxD0 = findBin(cfgTrackCuts.binsPt, ptNoVtxD0 + ptTolerance); // assuming tighter selections at lower pT + if (ptBinNoVtxD0 < 0) { + continue; + } + + // d0xd0 + if (dcaPos.getY() * dcaNeg.getY() > cfgCandCuts.topologicalCuts->get(ptBinNoVtxD0, "max d0d0")) { + continue; + } + + // invariant mass + if (massHypo == D0MassHypo::D0 || massHypo == D0MassHypo::D0AndD0Bar) { + float invMassNoVtxD0 = RecoDecay::m(std::array{trackPos.pVector(), trackNeg.pVector()}, std::array{o2::constants::physics::MassPiPlus, o2::constants::physics::MassKPlus}); + if (std::abs(invMassNoVtxD0 - o2::constants::physics::MassD0) > cfgCandCuts.topologicalCuts->get(ptBinNoVtxD0, "delta inv. mass") + invMassTolerance) { + massHypo -= D0MassHypo::D0; + } + } + if (massHypo >= D0MassHypo::D0Bar) { + float invMassNoVtxD0bar = RecoDecay::m(std::array{trackNeg.pVector(), trackPos.pVector()}, std::array{o2::constants::physics::MassPiPlus, o2::constants::physics::MassKPlus}); + if (std::abs(invMassNoVtxD0bar - o2::constants::physics::MassD0) > cfgCandCuts.topologicalCuts->get(ptBinNoVtxD0, "delta inv. mass") + invMassTolerance) { + massHypo -= D0MassHypo::D0Bar; + } + } + if (massHypo == 0) { + continue; + } + + // reconstruct vertex + if (df.process(trackParCovPos, trackParCovNeg) == 0) { + continue; + } + const auto& secondaryVertex = df.getPCACandidate(); + auto chi2PCA = df.getChi2AtPCACandidate(); + auto covMatrixPCA = df.calcPCACovMatrixFlat(); + auto trackParAtSecVtxPos = df.getTrack(0); + auto trackParAtSecVtxNeg = df.getTrack(1); + + std::array pVecPos{}; + std::array pVecNeg{}; + trackParAtSecVtxPos.getPxPyPzGlo(pVecPos); + trackParAtSecVtxNeg.getPxPyPzGlo(pVecNeg); + std::array pVecD0 = RecoDecay::pVec(pVecPos, pVecNeg); + + // select D0 + // pt + float ptD0 = RecoDecay::pt(pVecD0); + if (ptD0 < cfgCandCuts.ptMin) { + continue; + } + int ptBinD0 = findBin(cfgTrackCuts.binsPt, ptD0); + if (ptBinD0 < 0) { + continue; + } + + // random downsampling already here + if (cfgDownsampling.apply) { + int ptBinWeights{0}; + if (ptD0 < histDownSampl->GetBinLowEdge(1)) { + ptBinWeights = 1; + } else if (ptD0 > histDownSampl->GetXaxis()->GetBinUpEdge(histDownSampl->GetNbinsX())) { + ptBinWeights = histDownSampl->GetNbinsX(); + } else { + ptBinWeights = histDownSampl->GetXaxis()->FindBin(ptD0); + } + float weight = histDownSampl->GetBinContent(ptBinWeights); + if (gRandom->Rndm() > weight) { + continue; + } + } + + // d0xd0 + if (dcaPos.getY() * dcaNeg.getY() > cfgCandCuts.topologicalCuts->get(ptBinD0, "max d0d0")) { + continue; + } + // cospa + float cosPaD0 = RecoDecay::cpa(std::array{primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, secondaryVertex, pVecD0); + if (cosPaD0 < cfgCandCuts.topologicalCuts->get(ptBinD0, "min cos pointing angle")) { + continue; + } + // pointing angle + float paD0 = std::acos(cosPaD0); + if (paD0 > cfgCandCuts.topologicalCuts->get(ptBinD0, "max pointing angle")) { + continue; + } + // cospa XY + float cosPaXYD0 = RecoDecay::cpaXY(std::array{primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, secondaryVertex, pVecD0); + if (cosPaXYD0 < cfgCandCuts.topologicalCuts->get(ptBinD0, "min cos pointing angle XY")) { + continue; + } + // pointing angle XY + float paXYD0 = std::acos(cosPaXYD0); + if (paXYD0 > cfgCandCuts.topologicalCuts->get(ptBinD0, "max pointing angle XY")) { + continue; + } + // decay length + float decLenD0 = RecoDecay::distance(std::array{primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, secondaryVertex); + if (decLenD0 < cfgCandCuts.topologicalCuts->get(ptBinD0, "min decay length")) { + continue; + } + // decay length XY + float decLenXYD0 = RecoDecay::distanceXY(std::array{primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, secondaryVertex); + if (decLenXYD0 < cfgCandCuts.topologicalCuts->get(ptBinD0, "min decay length XY")) { + continue; + } + // normalised decay length + float phi{0.f}, theta{0.f}; + getPointDirection(std::array{primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, secondaryVertex, phi, theta); + float errorDecayLengthD0 = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta)); + if (decLenD0 / errorDecayLengthD0 < cfgCandCuts.topologicalCuts->get(ptBinD0, "min norm decay length")) { + continue; + } + // normalised decay length XY + float errorDecayLengthXYD0 = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.f) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.f)); + if (decLenXYD0 / errorDecayLengthXYD0 < cfgCandCuts.topologicalCuts->get(ptBinD0, "min norm decay length XY")) { + continue; + } + + float invMassD0{0.f}, invMassD0bar{0.f}; + std::vector bdtScoresD0{0.f, 1.f, 1.f}, bdtScoresD0bar{0.f, 1.f, 1.f}; // always selected a priori + if (massHypo == D0MassHypo::D0 || massHypo == D0MassHypo::D0AndD0Bar) { + invMassD0 = RecoDecay::m(std::array{pVecPos, pVecNeg}, std::array{o2::constants::physics::MassPiPlus, o2::constants::physics::MassKPlus}); + if (std::abs(invMassD0 - o2::constants::physics::MassD0) > cfgCandCuts.topologicalCuts->get(ptBinD0, "delta inv. mass")) { + massHypo -= D0MassHypo::D0; + bdtScoresD0 = std::vector{1.f, 0.f, 0.f}; + } else { + // apply BDT models + if (cfgMl.apply) { + std::vector featuresCandD0 = {dcaPos.getY(), dcaNeg.getY(), chi2PCA, cosPaD0, cosPaXYD0, decLenXYD0, decLenD0, dcaPos.getY() * dcaNeg.getY(), aod::pid_tpc_tof_utils::combineNSigma(trackPos.tpcNSigmaPi(), trackPos.tofNSigmaPi()), aod::pid_tpc_tof_utils::combineNSigma(trackNeg.tpcNSigmaKa(), trackNeg.tofNSigmaKa()), trackPos.tpcNSigmaPi(), trackPos.tpcNSigmaKa(), aod::pid_tpc_tof_utils::combineNSigma(trackPos.tpcNSigmaKa(), trackPos.tofNSigmaKa()), trackNeg.tpcNSigmaPi(), trackNeg.tpcNSigmaKa(), aod::pid_tpc_tof_utils::combineNSigma(trackNeg.tpcNSigmaPi(), trackNeg.tofNSigmaPi())}; + mlResponse.isSelectedMl(featuresCandD0, ptD0, bdtScoresD0); + } + } + } + if (massHypo >= D0MassHypo::D0Bar) { + invMassD0bar = RecoDecay::m(std::array{pVecNeg, pVecPos}, std::array{o2::constants::physics::MassPiPlus, o2::constants::physics::MassKPlus}); + if (std::abs(invMassD0bar - o2::constants::physics::MassD0) > cfgCandCuts.topologicalCuts->get(ptBinD0, "delta inv. mass")) { + massHypo -= D0MassHypo::D0Bar; + bdtScoresD0bar = std::vector{1.f, 0.f, 0.f}; + } else { + // apply BDT models + if (cfgMl.apply) { + std::vector featuresCandD0bar = {dcaPos.getY(), dcaNeg.getY(), chi2PCA, cosPaD0, cosPaXYD0, decLenXYD0, decLenD0, dcaPos.getY() * dcaNeg.getY(), aod::pid_tpc_tof_utils::combineNSigma(trackNeg.tpcNSigmaPi(), trackNeg.tofNSigmaPi()), aod::pid_tpc_tof_utils::combineNSigma(trackPos.tpcNSigmaKa(), trackPos.tofNSigmaKa()), trackNeg.tpcNSigmaPi(), trackNeg.tpcNSigmaKa(), aod::pid_tpc_tof_utils::combineNSigma(trackNeg.tpcNSigmaKa(), trackNeg.tofNSigmaKa()), trackPos.tpcNSigmaPi(), trackPos.tpcNSigmaKa(), aod::pid_tpc_tof_utils::combineNSigma(trackPos.tpcNSigmaPi(), trackPos.tofNSigmaPi())}; + mlResponse.isSelectedMl(featuresCandD0bar, ptD0, bdtScoresD0bar); + } + } + } + if (massHypo == 0) { + continue; + } + + float etaD0 = RecoDecay::eta(pVecD0); + float phiD0 = RecoDecay::phi(pVecD0); + + // fill tables + // collision + if (!selectedCollisions.count(collision.globalIndex())) { + // fill collision table if not yet present + collTable(collision.posX(), + collision.posY(), + collision.posZ(), + collision.covXX(), + collision.covXY(), + collision.covXZ(), + collision.covYY(), + collision.covYZ(), + collision.covZZ(), + collision.numContrib(), + uint8_t(std::round(collision.centFT0C())), + getCompressedOccupancy(collision.trackOccupancyInTimeRange()), + getCompressedOccupancy(collision.ft0cOccupancyInTimeRange()), + eventIR.orbit, + runNumber); + selectedCollisions[collision.globalIndex()] = collTable.lastIndex(); + } + // tracks + if (!selectedTracks.count(trackPos.globalIndex())) { + // fill track table with positive track if not yet present + uint8_t tmoPrimUnfm80{0u}; + uint8_t tmoFV0AUnfm80{0u}; + uint8_t tmoFT0AUnfm80{0u}; + uint8_t tmoFT0CUnfm80{0u}; + uint8_t twmoPrimUnfm80{0u}; + uint8_t twmoFV0AUnfm80{0u}; + uint8_t twmoFT0AUnfm80{0u}; + uint8_t twmoFT0CUnfm80{0u}; + uint8_t tmoRobustT0V0PrimUnfm80{0u}; + uint8_t twmoRobustT0V0PrimUnfm80{0u}; + if (trackPos.has_tmo()) { + auto tmoFromTrack = trackPos.tmo_as(); // obtain track mean occupancies + tmoPrimUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoPrimUnfm80()); + tmoFV0AUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoFV0AUnfm80()); + tmoFT0AUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoFT0AUnfm80()); + tmoFT0CUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoFT0CUnfm80()); + twmoPrimUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoPrimUnfm80()); + twmoFV0AUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoFV0AUnfm80()); + twmoFT0AUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoFT0AUnfm80()); + twmoFT0CUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoFT0CUnfm80()); + tmoRobustT0V0PrimUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoRobustT0V0PrimUnfm80()); + twmoRobustT0V0PrimUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoRobustT0V0PrimUnfm80()); + } + float tpcTime0{0.f}; + float tpcdEdxNorm{0.f}; + int16_t tpcDcaR{0}; + int16_t tpcDcaZ{0}; + uint8_t tpcClusterByteMask{0u}; + uint8_t tpcdEdxMax0R{0u}; + uint8_t tpcdEdxMax1R{0u}; + uint8_t tpcdEdxMax2R{0u}; + uint8_t tpcdEdxMax3R{0u}; + uint8_t tpcdEdxTot0R{0u}; + uint8_t tpcdEdxTot1R{0u}; + uint8_t tpcdEdxTot2R{0u}; + uint8_t tpcdEdxTot3R{0u}; + int8_t deltaRefContParamY{0}; + int8_t deltaRefITSParamZ{0}; + int8_t deltaRefContParamSnp{0}; + int8_t deltaRefContParamTgl{0}; + int8_t deltaRefContParamQ2Pt{0}; + int8_t deltaRefGloParamY{0}; + int8_t deltaRefGloParamZ{0}; + int8_t deltaRefGloParamSnp{0}; + int8_t deltaRefGloParamTgl{0}; + int8_t deltaRefGloParamQ2Pt{0}; + int8_t deltaTOFdX{0}; + int8_t deltaTOFdZ{0}; + if (trackPos.has_trackQA()) { + auto trackQA = trackPos.trackQA_as(); // obtain track QA + tpcTime0 = trackQA.tpcTime0(); + tpcdEdxNorm = trackQA.tpcdEdxNorm(); + tpcDcaR = trackQA.tpcdcaR(); + tpcDcaZ = trackQA.tpcdcaZ(); + tpcClusterByteMask = trackQA.tpcClusterByteMask(); + tpcdEdxMax0R = trackQA.tpcdEdxMax0R(); + tpcdEdxMax1R = trackQA.tpcdEdxMax1R(); + tpcdEdxMax2R = trackQA.tpcdEdxMax2R(); + tpcdEdxMax3R = trackQA.tpcdEdxMax3R(); + tpcdEdxTot0R = trackQA.tpcdEdxTot0R(); + tpcdEdxTot1R = trackQA.tpcdEdxTot1R(); + tpcdEdxTot2R = trackQA.tpcdEdxTot2R(); + tpcdEdxTot3R = trackQA.tpcdEdxTot3R(); + deltaRefContParamY = trackQA.deltaRefContParamY(); + deltaRefITSParamZ = trackQA.deltaRefITSParamZ(); + deltaRefContParamSnp = trackQA.deltaRefContParamSnp(); + deltaRefContParamTgl = trackQA.deltaRefContParamTgl(); + deltaRefContParamQ2Pt = trackQA.deltaRefContParamQ2Pt(); + deltaRefGloParamY = trackQA.deltaRefGloParamY(); + deltaRefGloParamZ = trackQA.deltaRefGloParamZ(); + deltaRefGloParamSnp = trackQA.deltaRefGloParamSnp(); + deltaRefGloParamTgl = trackQA.deltaRefGloParamTgl(); + deltaRefGloParamQ2Pt = trackQA.deltaRefGloParamQ2Pt(); + deltaTOFdX = trackQA.deltaTOFdX(); + deltaTOFdZ = trackQA.deltaTOFdZ(); + } + + trackTable(selectedCollisions[collision.globalIndex()], // stored at PV + trackPos.x(), + trackPos.alpha(), + trackPos.y(), + trackPos.z(), + trackPos.snp(), + trackPos.tgl(), + trackPos.signed1Pt(), + o2::math_utils::detail::truncateFloatFraction(trackPos.cYY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.cZY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.cZZ(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.cSnpY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.cSnpZ(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.cSnpSnp(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.cTglY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.cTglZ(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.cTglSnp(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.cTglTgl(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.c1PtY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.c1PtZ(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.c1PtSnp(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.c1PtTgl(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackPos.c1Pt21Pt2(), precisionCovMask), + trackPos.tpcInnerParam(), + trackPos.flags(), + trackPos.itsClusterSizes(), + trackPos.tpcNClsFindable(), + trackPos.tpcNClsFindableMinusFound(), + trackPos.tpcNClsFindableMinusCrossedRows(), + trackPos.tpcNClsShared(), + trackPos.trdPattern(), + getCompressedChi2(trackPos.itsChi2NCl()), + getCompressedChi2(trackPos.tpcChi2NCl()), + getCompressedChi2(trackPos.trdChi2()), + getCompressedChi2(trackPos.tofChi2()), + trackPos.tpcSignal(), + trackPos.trdSignal(), + trackPos.length(), + trackPos.tofExpMom(), + trackPos.trackTime(), + trackPos.trackTimeRes(), + tpcTime0, + tpcdEdxNorm, + tpcDcaR, + tpcDcaZ, + tpcClusterByteMask, + tpcdEdxMax0R, + tpcdEdxMax1R, + tpcdEdxMax2R, + tpcdEdxMax3R, + tpcdEdxTot0R, + tpcdEdxTot1R, + tpcdEdxTot2R, + tpcdEdxTot3R, + deltaRefContParamY, + deltaRefITSParamZ, + deltaRefContParamSnp, + deltaRefContParamTgl, + deltaRefContParamQ2Pt, + deltaRefGloParamY, + deltaRefGloParamZ, + deltaRefGloParamSnp, + deltaRefGloParamTgl, + deltaRefGloParamQ2Pt, + deltaTOFdX, + deltaTOFdZ, + o2::math_utils::detail::truncateFloatFraction(dcaPos.getY(), precisionDcaMask), + o2::math_utils::detail::truncateFloatFraction(dcaPos.getZ(), precisionDcaMask), + getCompressedNumSigmaPid(trackPos.tpcNSigmaPi()), + getCompressedNumSigmaPid(trackPos.tpcNSigmaKa()), + getCompressedNumSigmaPid(trackPos.tofNSigmaPi()), + getCompressedNumSigmaPid(trackPos.tofNSigmaKa()), + tmoPrimUnfm80, + tmoFV0AUnfm80, + tmoFT0AUnfm80, + tmoFT0CUnfm80, + twmoPrimUnfm80, + twmoFV0AUnfm80, + twmoFT0AUnfm80, + twmoFT0CUnfm80, + tmoRobustT0V0PrimUnfm80, + twmoRobustT0V0PrimUnfm80); + selectedTracks[trackPos.globalIndex()] = trackTable.lastIndex(); + } + if (!selectedTracks.count(trackNeg.globalIndex())) { + // fill track table with negative track if not yet present + uint8_t tmoPrimUnfm80{0u}; + uint8_t tmoFV0AUnfm80{0u}; + uint8_t tmoFT0AUnfm80{0u}; + uint8_t tmoFT0CUnfm80{0u}; + uint8_t twmoPrimUnfm80{0u}; + uint8_t twmoFV0AUnfm80{0u}; + uint8_t twmoFT0AUnfm80{0u}; + uint8_t twmoFT0CUnfm80{0u}; + uint8_t tmoRobustT0V0PrimUnfm80{0u}; + uint8_t twmoRobustT0V0PrimUnfm80{0u}; + if (trackNeg.has_tmo()) { + auto tmoFromTrack = trackNeg.tmo_as(); // obtain track mean occupancies + tmoPrimUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoPrimUnfm80()); + tmoFV0AUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoFV0AUnfm80()); + tmoFT0AUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoFT0AUnfm80()); + tmoFT0CUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoFT0CUnfm80()); + twmoPrimUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoPrimUnfm80()); + twmoFV0AUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoFV0AUnfm80()); + twmoFT0AUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoFT0AUnfm80()); + twmoFT0CUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoFT0CUnfm80()); + tmoRobustT0V0PrimUnfm80 = getCompressedOccupancy(tmoFromTrack.tmoRobustT0V0PrimUnfm80()); + twmoRobustT0V0PrimUnfm80 = getCompressedOccupancy(tmoFromTrack.twmoRobustT0V0PrimUnfm80()); + } + float tpcTime0{0.f}; + float tpcdEdxNorm{0.f}; + int16_t tpcDcaR{0}; + int16_t tpcDcaZ{0}; + uint8_t tpcClusterByteMask{0u}; + uint8_t tpcdEdxMax0R{0u}; + uint8_t tpcdEdxMax1R{0u}; + uint8_t tpcdEdxMax2R{0u}; + uint8_t tpcdEdxMax3R{0u}; + uint8_t tpcdEdxTot0R{0u}; + uint8_t tpcdEdxTot1R{0u}; + uint8_t tpcdEdxTot2R{0u}; + uint8_t tpcdEdxTot3R{0u}; + int8_t deltaRefContParamY{0}; + int8_t deltaRefITSParamZ{0}; + int8_t deltaRefContParamSnp{0}; + int8_t deltaRefContParamTgl{0}; + int8_t deltaRefContParamQ2Pt{0}; + int8_t deltaRefGloParamY{0}; + int8_t deltaRefGloParamZ{0}; + int8_t deltaRefGloParamSnp{0}; + int8_t deltaRefGloParamTgl{0}; + int8_t deltaRefGloParamQ2Pt{0}; + int8_t deltaTOFdX{0}; + int8_t deltaTOFdZ{0}; + if (trackNeg.has_trackQA()) { + auto trackQA = trackNeg.trackQA_as(); // obtain track QA + tpcTime0 = trackQA.tpcTime0(); + tpcdEdxNorm = trackQA.tpcdEdxNorm(); + tpcDcaR = trackQA.tpcdcaR(); + tpcDcaZ = trackQA.tpcdcaZ(); + tpcClusterByteMask = trackQA.tpcClusterByteMask(); + tpcdEdxMax0R = trackQA.tpcdEdxMax0R(); + tpcdEdxMax1R = trackQA.tpcdEdxMax1R(); + tpcdEdxMax2R = trackQA.tpcdEdxMax2R(); + tpcdEdxMax3R = trackQA.tpcdEdxMax3R(); + tpcdEdxTot0R = trackQA.tpcdEdxTot0R(); + tpcdEdxTot1R = trackQA.tpcdEdxTot1R(); + tpcdEdxTot2R = trackQA.tpcdEdxTot2R(); + tpcdEdxTot3R = trackQA.tpcdEdxTot3R(); + deltaRefContParamY = trackQA.deltaRefContParamY(); + deltaRefITSParamZ = trackQA.deltaRefITSParamZ(); + deltaRefContParamSnp = trackQA.deltaRefContParamSnp(); + deltaRefContParamTgl = trackQA.deltaRefContParamTgl(); + deltaRefContParamQ2Pt = trackQA.deltaRefContParamQ2Pt(); + deltaRefGloParamY = trackQA.deltaRefGloParamY(); + deltaRefGloParamZ = trackQA.deltaRefGloParamZ(); + deltaRefGloParamSnp = trackQA.deltaRefGloParamSnp(); + deltaRefGloParamTgl = trackQA.deltaRefGloParamTgl(); + deltaRefGloParamQ2Pt = trackQA.deltaRefGloParamQ2Pt(); + deltaTOFdX = trackQA.deltaTOFdX(); + deltaTOFdZ = trackQA.deltaTOFdZ(); + } + + trackTable(selectedCollisions[collision.globalIndex()], // stored at PV + trackNeg.x(), + trackNeg.alpha(), + trackNeg.y(), + trackNeg.z(), + trackNeg.snp(), + trackNeg.tgl(), + trackNeg.signed1Pt(), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cYY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cZY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cZZ(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cSnpY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cSnpZ(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cSnpSnp(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cTglY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cTglZ(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cTglSnp(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.cTglTgl(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.c1PtY(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.c1PtZ(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.c1PtSnp(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.c1PtTgl(), precisionCovMask), + o2::math_utils::detail::truncateFloatFraction(trackNeg.c1Pt21Pt2(), precisionCovMask), + trackNeg.tpcInnerParam(), + trackNeg.flags(), + trackNeg.itsClusterSizes(), + trackNeg.tpcNClsFindable(), + trackNeg.tpcNClsFindableMinusFound(), + trackNeg.tpcNClsFindableMinusCrossedRows(), + trackNeg.tpcNClsShared(), + trackNeg.trdPattern(), + getCompressedChi2(trackNeg.itsChi2NCl()), + getCompressedChi2(trackNeg.tpcChi2NCl()), + getCompressedChi2(trackNeg.trdChi2()), + getCompressedChi2(trackNeg.tofChi2()), + trackNeg.tpcSignal(), + trackNeg.trdSignal(), + trackNeg.length(), + trackNeg.tofExpMom(), + trackNeg.trackTime(), + trackNeg.trackTimeRes(), + tpcTime0, + tpcdEdxNorm, + tpcDcaR, + tpcDcaZ, + tpcClusterByteMask, + tpcdEdxMax0R, + tpcdEdxMax1R, + tpcdEdxMax2R, + tpcdEdxMax3R, + tpcdEdxTot0R, + tpcdEdxTot1R, + tpcdEdxTot2R, + tpcdEdxTot3R, + deltaRefContParamY, + deltaRefITSParamZ, + deltaRefContParamSnp, + deltaRefContParamTgl, + deltaRefContParamQ2Pt, + deltaRefGloParamY, + deltaRefGloParamZ, + deltaRefGloParamSnp, + deltaRefGloParamTgl, + deltaRefGloParamQ2Pt, + deltaTOFdX, + deltaTOFdZ, + o2::math_utils::detail::truncateFloatFraction(dcaNeg.getY(), precisionDcaMask), + o2::math_utils::detail::truncateFloatFraction(dcaNeg.getZ(), precisionDcaMask), + getCompressedNumSigmaPid(trackNeg.tpcNSigmaPi()), + getCompressedNumSigmaPid(trackNeg.tpcNSigmaKa()), + getCompressedNumSigmaPid(trackNeg.tofNSigmaPi()), + getCompressedNumSigmaPid(trackNeg.tofNSigmaKa()), + tmoPrimUnfm80, + tmoFV0AUnfm80, + tmoFT0AUnfm80, + tmoFT0CUnfm80, + twmoPrimUnfm80, + twmoFV0AUnfm80, + twmoFT0AUnfm80, + twmoFT0CUnfm80, + tmoRobustT0V0PrimUnfm80, + twmoRobustT0V0PrimUnfm80); + selectedTracks[trackNeg.globalIndex()] = trackTable.lastIndex(); + } + + // candidate + candTable(selectedCollisions[collision.globalIndex()], + selectedTracks[trackPos.globalIndex()], + selectedTracks[trackNeg.globalIndex()], + massHypo, + ptD0, + etaD0, + phiD0, + invMassD0, + invMassD0bar, + getCompressedDecayLength(decLenD0), + getCompressedDecayLength(decLenXYD0), + getCompressedNormDecayLength(decLenD0 / errorDecayLengthD0), + getCompressedNormDecayLength(decLenXYD0 / errorDecayLengthXYD0), + getCompressedCosPa(cosPaD0), + getCompressedCosPa(cosPaXYD0), + getCompressedPointingAngle(paD0), + getCompressedPointingAngle(paXYD0), + getCompressedChi2(chi2PCA), + getCompressedBdtScoreBkg(bdtScoresD0[0]), + getCompressedBdtScoreSgn(bdtScoresD0[1]), + getCompressedBdtScoreSgn(bdtScoresD0[2]), + getCompressedBdtScoreBkg(bdtScoresD0bar[0]), + getCompressedBdtScoreSgn(bdtScoresD0bar[1]), + getCompressedBdtScoreSgn(bdtScoresD0bar[2])); + } // end loop over negative tracks + } // end loop over positive tracks + } // end loop over collisions tracks + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/DPG/Tasks/AOTTrack/qaEfficiency.cxx b/DPG/Tasks/AOTTrack/qaEfficiency.cxx index e202302c950..a55d205ed57 100644 --- a/DPG/Tasks/AOTTrack/qaEfficiency.cxx +++ b/DPG/Tasks/AOTTrack/qaEfficiency.cxx @@ -71,8 +71,12 @@ static constexpr int trkCutIdxN = 23; static constexpr int nSpecies = o2::track::PID::NIDs; // One per PDG static constexpr int nCharges = 2; static constexpr int nParticles = nSpecies * nCharges; -static constexpr const char* particleTitle[nParticles] = {"e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha", - "e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha"}; +static constexpr const char* particleTitle[nParticles] = {"e^{-}", "#mu^{-}", "#pi^{+}", + "K^{+}", "p", "d", + "t", "^{3}He", "#alpha", + "e^{+}", "#mu^{+}", "#pi^{-}", + "K^{-}", "#bar{p}", "#bar{d}", + "#bar{t}", "^{3}#bar{He}", "#bar{#alpha}"}; static constexpr int PDGs[nParticles] = {11, 13, 211, 321, 2212, 1000010020, 1000010030, 1000020030, 1000020040, -11, -13, -211, -321, -2212, -1000010020, -1000010030, -1000020030, -1000020040}; @@ -203,6 +207,7 @@ struct QaEfficiency { Configurable checkForMothers{"checkForMothers", false, "Flag to use the array of mothers to check if the particle of interest come from any of those particles"}; Configurable> mothersPDGs{"mothersPDGs", std::vector{3312, -3312}, "PDGs of origin of the particle under study"}; Configurable keepOnlyHfParticles{"keepOnlyHfParticles", false, "Flag to decide wheter to consider only HF particles"}; + Configurable eventGeneratorType{"eventGeneratorType", -1, "Flag to check specific event generator (for HF): -1 -> no check, 0 -> MB events, 4 -> charm triggered, 5 -> beauty triggered"}; // Track only selection, options to select only specific tracks Configurable trackSelection{"trackSelection", true, "Local track selection"}; Configurable globalTrackSelection{"globalTrackSelection", 0, "Global track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks, 6 -> custom track cuts via Configurable"}; @@ -226,6 +231,7 @@ struct QaEfficiency { Configurable doPtEta{"doPtEta", false, "Flag to produce the efficiency vs pT and Eta"}; Configurable doPtRadius{"doPtRadius", false, "Flag to produce the efficiency vs pT and Radius"}; Configurable applyEvSel{"applyEvSel", 0, "Flag to apply event selection: 0 -> no event selection, 1 -> Run 2 event selection, 2 -> Run 3 event selection"}; + Configurable applyTimeFrameBorderCut{"applyTimeFrameBorderCut", false, "Flag to apply the TF border cut"}; // Custom track cuts for debug purposes TrackSelection customTrackCuts; struct : ConfigurableGroup { @@ -259,6 +265,7 @@ struct QaEfficiency { using CollisionCandidatesMC = o2::soa::Join; using TrackCandidates = o2::soa::Join; using TrackCandidatesMC = o2::soa::Join; + using BCsInfo = soa::Join; // Histograms HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -365,7 +372,7 @@ struct QaEfficiency { hPtItsTpcTofStr[histogramIndex] = histos.add(Form("MC/pdg%i/pt/str/its_tpc_tof", PDGs[histogramIndex]), "ITS-TPC-TOF tracks (from weak decays) " + tagPt, kTH1D, {axisPt}); hPtGeneratedStr[histogramIndex] = histos.add(Form("MC/pdg%i/pt/str/generated", PDGs[histogramIndex]), "Generated (from weak decays) " + tagPt, kTH1D, {axisPt}); hPtmotherGenerated[histogramIndex] = histos.add(Form("MC/pdg%i/pt/str/generated_mother", PDGs[histogramIndex]), "Generated Mother " + tagPt, kTH1D, {axisPt}); - hdecaylengthmother[histogramIndex] = histos.add(Form("MC/pdg%i/pt/str/decayLength", PDGs[histogramIndex]), "Decay Length of mother particle" + tagPt, kTH1D, {axisPt}); + hdecaylengthmother[histogramIndex] = histos.add(Form("MC/pdg%i/pt/str/decayLength", PDGs[histogramIndex]), "Decay Length of mother particle" + tagPt, kTH1D, {axisDecayLength}); // Ter hPtItsTpcTer[histogramIndex] = histos.add(Form("MC/pdg%i/pt/ter/its_tpc", PDGs[histogramIndex]), "ITS-TPC tracks (from secondary weak decays) " + tagPt, kTH1D, {axisPt}); @@ -967,6 +974,7 @@ struct QaEfficiency { histos.get(HIST("eventSelection"))->GetXaxis()->SetBinLabel(3, "Passed Contrib."); histos.get(HIST("eventSelection"))->GetXaxis()->SetBinLabel(4, "Passed Position"); + histos.get(HIST("eventSelection"))->GetXaxis()->SetBinLabel(5, "Passed Time Frame border cut"); if (doprocessMC) { histos.add("MC/generatedCollisions", "Generated Collisions", kTH1D, {{10, 0.5, 10.5, "Generated collisions"}}); @@ -1260,7 +1268,7 @@ struct QaEfficiency { for (const auto& mother : mothers) { for (const auto& pdgToCheck : mothersPDGs.value) { if (mother.pdgCode() == pdgToCheck) { - motherIsAccepted = true; // Mother matches the list of specified PDGs + motherIsAccepted = true; // Mother matches the list of specified PDGs hPtmotherGenerated[histogramIndex]->Fill(mother.pt()); // Fill generated pT for mother break; } @@ -1449,6 +1457,12 @@ struct QaEfficiency { if constexpr (doFillHistograms) { histos.fill(HIST("eventSelection"), 4); } + if (applyTimeFrameBorderCut && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if constexpr (doFillHistograms) { + histos.fill(HIST("eventSelection"), 5); + } return true; } @@ -1738,7 +1752,8 @@ struct QaEfficiency { // o2::soa::SmallGroups const& collisions, CollisionCandidatesMC const& collisions, TrackCandidatesMC const& tracks, - o2::aod::McParticles const& mcParticles) + o2::aod::McParticles const& mcParticles, + BCsInfo const&) { /// loop over generated collisions @@ -1778,6 +1793,11 @@ struct QaEfficiency { } histos.fill(HIST("MC/generatedCollisions"), 3); + if (eventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != eventGeneratorType) { + LOG(debug) << "Skipping event with different type of generator than the one requested"; + continue; + } + /// loop over reconstructed collisions for (const auto& collision : groupedCollisions) { histos.fill(HIST("MC/generatedCollisions"), 4); @@ -1864,6 +1884,13 @@ struct QaEfficiency { continue; } } + // apply time-frame border cut also to the generated collision + if (applyTimeFrameBorderCut) { + auto bc = mcCollision.bc_as(); + if (!bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + continue; + } + } } /// only to fill denominator of ITS-TPC matched primary tracks only in MC events with at least 1 reco. vtx @@ -1912,6 +1939,13 @@ struct QaEfficiency { continue; } } + // apply time-frame border cut also to the generated collision + if (applyTimeFrameBorderCut) { + auto bc = mcCollision.bc_as(); + if (!bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + continue; + } + } // Loop on particles to fill the denominator float dNdEta = 0; // Multiplicity @@ -1966,7 +2000,8 @@ struct QaEfficiency { void processMCWithoutCollisions(TrackCandidatesMC const& tracks, o2::aod::Collisions const&, o2::aod::McParticles const& mcParticles, - o2::aod::McCollisions const&) + o2::aod::McCollisions const&, + BCsInfo const&) { // Track loop for (const auto& track : tracks) { @@ -2018,6 +2053,14 @@ struct QaEfficiency { continue; } } + // apply time-frame border cut also to the generated collision + if (applyTimeFrameBorderCut) { + const auto mcCollision = mcParticle.mcCollision(); + auto bc = mcCollision.bc_as(); + if (!bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + continue; + } + } // search for particles from HF decays if (keepOnlyHfParticles && !RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, /*searchUpToQuark*/ true)) { diff --git a/DPG/Tasks/AOTTrack/qaEventTrack.cxx b/DPG/Tasks/AOTTrack/qaEventTrack.cxx index ffb64e1f9c2..09590267ed8 100644 --- a/DPG/Tasks/AOTTrack/qaEventTrack.cxx +++ b/DPG/Tasks/AOTTrack/qaEventTrack.cxx @@ -36,8 +36,8 @@ #include "Common/Core/TrackSelectionDefaults.h" #include "Common/TableProducer/PID/pidTOFBase.h" -#include "string" -#include "vector" +#include +#include using namespace o2; using namespace o2::framework; @@ -1562,7 +1562,7 @@ void qaEventTrack::fillRecoHistogramsGroupedTracks(const C& collision, const T& histos.fill(HIST("Tracks/signed1Pt"), track.signed1Pt()); histos.fill(HIST("Tracks/snp"), track.snp()); histos.fill(HIST("Tracks/tgl"), track.tgl()); - for (unsigned int i = 0; i < 64; i++) { + for (unsigned int i = 0; i < 32; i++) { if (track.flags() & (1 << i)) { histos.fill(HIST("Tracks/flags"), i); } diff --git a/DPG/Tasks/AOTTrack/qaEventTrackLiteProducer.cxx b/DPG/Tasks/AOTTrack/qaEventTrackLiteProducer.cxx index e3d0f3f1ec6..0184d5b39f0 100644 --- a/DPG/Tasks/AOTTrack/qaEventTrackLiteProducer.cxx +++ b/DPG/Tasks/AOTTrack/qaEventTrackLiteProducer.cxx @@ -19,6 +19,9 @@ #include "qaEventTrack.h" +#include + +#include "TRandom.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" @@ -38,7 +41,7 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::dataformats; -struct qaEventTrackLiteProducer { +struct QaEventTrackLiteProducer { // Tables to produce Produces tableCollisions; Produces tableCollsBig; @@ -178,7 +181,7 @@ struct qaEventTrackLiteProducer { { fillDerivedTable(collision, tracks, 0, bcs); } - PROCESS_SWITCH(qaEventTrackLiteProducer, processTableData, "Process data for table producing", true); + PROCESS_SWITCH(QaEventTrackLiteProducer, processTableData, "Process data for table producing", true); void processTableMC(CollisionTableMC::iterator const& collision, soa::Filtered> const& tracks, @@ -188,7 +191,7 @@ struct qaEventTrackLiteProducer { { fillDerivedTable(collision, tracks, mcParticles, bcs); } - PROCESS_SWITCH(qaEventTrackLiteProducer, processTableMC, "Process MC for table producing", false); + PROCESS_SWITCH(QaEventTrackLiteProducer, processTableMC, "Process MC for table producing", false); //************************************************************************************************** /** @@ -202,10 +205,10 @@ struct qaEventTrackLiteProducer { if (!isSelectedCollision(collision)) { return; } - if (abs(collision.posZ()) > selectMaxVtxZ) { + if (std::abs(collision.posZ()) > selectMaxVtxZ) { return; } - if (fractionOfSampledEvents < 1.f && (static_cast(rand()) / static_cast(RAND_MAX)) > fractionOfSampledEvents) { // Skip events that are not sampled + if (fractionOfSampledEvents < 1.f && (gRandom->Uniform()) > fractionOfSampledEvents) { // Skip events that are not sampled return; } if (nTableEventCounter > targetNumberOfEvents) { // Skip events if target is reached @@ -310,9 +313,9 @@ struct qaEventTrackLiteProducer { if (nTableEventCounter > targetNumberOfEvents) { // Skip events if target is reached return; } - for (auto& collision : collisions) { + for (const auto& collision : collisions) { - if (fractionOfSampledEvents < 1.f && (static_cast(rand()) / static_cast(RAND_MAX)) > fractionOfSampledEvents) { // Skip events that are not sampled + if (fractionOfSampledEvents < 1.f && (gRandom->Uniform()) > fractionOfSampledEvents) { // Skip events that are not sampled return; } nTableEventCounter++; @@ -407,7 +410,7 @@ struct qaEventTrackLiteProducer { /// Let's update the DF counter counterDF++; } - PROCESS_SWITCH(qaEventTrackLiteProducer, processTableDataCollsBig, "Process data for big collision table producing", false); + PROCESS_SWITCH(QaEventTrackLiteProducer, processTableDataCollsBig, "Process data for big collision table producing", false); /// Processing MC void processTableMCCollsBig(CollsBigTableMC const& collisions, @@ -423,10 +426,10 @@ struct qaEventTrackLiteProducer { /// Let's update the DF counter counterDF++; } - PROCESS_SWITCH(qaEventTrackLiteProducer, processTableMCCollsBig, "Process MC for big collision table producing", false); + PROCESS_SWITCH(QaEventTrackLiteProducer, processTableMCCollsBig, "Process MC for big collision table producing", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/DPG/Tasks/AOTTrack/qaImpPar.cxx b/DPG/Tasks/AOTTrack/qaImpPar.cxx index 8cb6b3d89b5..45f66123aee 100644 --- a/DPG/Tasks/AOTTrack/qaImpPar.cxx +++ b/DPG/Tasks/AOTTrack/qaImpPar.cxx @@ -9,37 +9,33 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// \author Mattia Faggin , Padova University and INFN -/// -/// Event selection: o2-analysis-timestamp --aod-file AO2D.root -b | o2-analysis-event-selection -b | ---> not working with Run2 converted data/MC -/// Track selection: o2-analysis-trackextension | o2-analysis-trackselection | ---> add --isRun3 1 with Run 3 data/MC (then global track selection works) -/// PID: o2-analysis-pid-tpc-full | o2-analysis-pid-tof-full -/// Working configuration (2021 Oct 20th): o2-analysis-trackextension -b --aod-file ./AO2D.root | o2-analysis-trackselection -b --isRun3 1 | o2-analysis-pid-tpc-full -b | o2-analysis-pid-tof-full -b | o2-analysis-pp-qa-impact-parameter -b -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "ReconstructionDataFormats/DCA.h" +#include "Common/Core/TrackSelection.h" #include "Common/Core/trackUtilities.h" // for propagation to primary vertex - #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/PIDResponse.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "CommonUtils/NameConf.h" -#include "Framework/AnalysisDataModel.h" -#include "Common/Core/TrackSelection.h" -#include "DetectorsVertexing/PVertexer.h" -#include "ReconstructionDataFormats/Vertex.h" +#include "Common/DataModel/TrackSelectionTables.h" + #include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "Framework/RunningWorkflowInfo.h" #include "CCDB/CcdbApi.h" -#include "DataFormatsCalibration/MeanVertexObject.h" #include "CommonConstants/GeomConstants.h" +#include "CommonUtils/NameConf.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsVertexing/PVertexer.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/Vertex.h" -#include "iostream" -#include "vector" -#include "set" +#include +#include +#include +#include using namespace o2::framework; using namespace o2::framework::expressions; @@ -62,7 +58,7 @@ struct QaImpactPar { ConfigurableAxis binningPulls{"binningPulls", {200, -10.f, 10.f}, "Pulls binning"}; ConfigurableAxis binningPt{"binningPt", {100, 0.f, 10.f}, "Pt binning"}; ConfigurableAxis binningEta{"binningEta", {40, -2.f, 2.f}, "Eta binning"}; - ConfigurableAxis binningPhi{"binningPhi", {24, 0.f, TMath::TwoPi()}, "Phi binning"}; + ConfigurableAxis binningPhi{"binningPhi", {24, 0.f, o2::constants::math::TwoPI}, "Phi binning"}; ConfigurableAxis binningPDG{"binningPDG", {5, -1.5f, 3.5f}, "PDG species binning (-1: not matched, 0: unknown, 1: pi, 2: K, 3: p)"}; ConfigurableAxis binningCharge{"binningCharge", {2, -2.f, 2.f}, "charge binning (-1: negative; +1: positive)"}; ConfigurableAxis binningIuPosX{"binningIuPosX", {100, -10.f, 10.f}, "Track IU x position"}; @@ -94,28 +90,29 @@ struct QaImpactPar { Configurable nSigmaTOFProtonMax{"nSigmaTOFProtonMax", 99999.f, "Maximum nSigma value in TOF, proton hypothesis"}; // PV refit Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable ccdbpath_lut{"ccdbpath_lut", "GLO/Param/MatLUT", "Path for LUT parametrization"}; + Configurable ccdbPathLut{"ccdbpath_lut", "GLO/Param/MatLUT", "Path for LUT parametrization"}; // Configurable ccdbpath_geo{"ccdbpath_geo", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - Configurable ccdbpath_grp{"ccdbpath_grp", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable ccdbPathGrp{"ccdbpath_grp", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable doPVrefit{"doPVrefit", true, "Do PV refit"}; - Configurable nBins_DeltaX_PVrefit{"nBins_DeltaX_PVrefit", 1000, "Number of bins of DeltaX for PV refit"}; - Configurable nBins_DeltaY_PVrefit{"nBins_DeltaY_PVrefit", 1000, "Number of bins of DeltaY for PV refit"}; - Configurable nBins_DeltaZ_PVrefit{"nBins_DeltaZ_PVrefit", 1000, "Number of bins of DeltaZ for PV refit"}; - Configurable minDeltaX_PVrefit{"minDeltaX_PVrefit", -0.5, "Min. DeltaX value for PV refit (cm)"}; - Configurable maxDeltaX_PVrefit{"maxDeltaX_PVrefit", 0.5, "Max. DeltaX value for PV refit (cm)"}; - Configurable minDeltaY_PVrefit{"minDeltaY_PVrefit", -0.5, "Min. DeltaY value for PV refit (cm)"}; - Configurable maxDeltaY_PVrefit{"maxDeltaY_PVrefit", 0.5, "Max. DeltaY value for PV refit (cm)"}; - Configurable minDeltaZ_PVrefit{"minDeltaZ_PVrefit", -0.5, "Min. DeltaZ value for PV refit (cm)"}; - Configurable maxDeltaZ_PVrefit{"maxDeltaZ_PVrefit", 0.5, "Max. DeltaZ value for PV refit (cm)"}; + Configurable nBinsDeltaXPVrefit{"nBins_DeltaX_PVrefit", 1000, "Number of bins of DeltaX for PV refit"}; + Configurable nBinsDeltaYPVrefit{"nBins_DeltaY_PVrefit", 1000, "Number of bins of DeltaY for PV refit"}; + Configurable nBinsDeltaZPVrefit{"nBins_DeltaZ_PVrefit", 1000, "Number of bins of DeltaZ for PV refit"}; + Configurable minDeltaXPVrefit{"minDeltaX_PVrefit", -0.5, "Min. DeltaX value for PV refit (cm)"}; + Configurable maxDeltaXPVrefit{"maxDeltaX_PVrefit", 0.5, "Max. DeltaX value for PV refit (cm)"}; + Configurable minDeltaYPVrefit{"minDeltaY_PVrefit", -0.5, "Min. DeltaY value for PV refit (cm)"}; + Configurable maxDeltaYPVrefit{"maxDeltaY_PVrefit", 0.5, "Max. DeltaY value for PV refit (cm)"}; + Configurable minDeltaZPVrefit{"minDeltaZ_PVrefit", -0.5, "Min. DeltaZ value for PV refit (cm)"}; + Configurable maxDeltaZPVrefit{"maxDeltaZ_PVrefit", 0.5, "Max. DeltaZ value for PV refit (cm)"}; Configurable minPVcontrib{"minPVcontrib", 0, "Minimum number of PV contributors"}; Configurable maxPVcontrib{"maxPVcontrib", 10000, "Maximum number of PV contributors"}; Configurable removeDiamondConstraint{"removeDiamondConstraint", true, "Remove the diamond constraint for the PV refit"}; Configurable keepAllTracksPVrefit{"keepAllTracksPVrefit", false, "Keep all tracks for PV refit (for debug)"}; - Configurable use_customITSHitMap{"use_customITSHitMap", false, "Use custom ITS hitmap selection"}; + Configurable useCustomITSHitMap{"use_customITSHitMap", false, "Use custom ITS hitmap selection"}; Configurable customITShitmap{"customITShitmap", 0, "Custom ITS hitmap (consider the binary representation)"}; Configurable customITShitmap_exclude{"customITShitmap_exclude", 0, "Custom ITS hitmap of layers to be excluded (consider the binary representation)"}; - Configurable n_customMinITShits{"n_customMinITShits", 0, "Minimum number of layers crossed by a track among those in \"customITShitmap\""}; - Configurable custom_forceITSTPCmatching{"custom_forceITSTPCmatching", false, "Consider or not only ITS-TPC macthed tracks when using custom ITS hitmap"}; + Configurable nCustomMinITShits{"n_customMinITShits", 0, "Minimum number of layers crossed by a track among those in \"customITShitmap\""}; + Configurable customForceITSTPCmatching{"custom_forceITSTPCmatching", false, "Consider or not only ITS-TPC macthed tracks when using custom ITS hitmap"}; + Configurable downsamplingFraction{"downsamplingFraction", 1.1, "Fraction of tracks to be used to fill the output objects"}; /// Custom cut selection objects TrackSelection selector_ITShitmap; @@ -153,44 +150,78 @@ struct QaImpactPar { ///////////////////////////////////////////////////////////// /// Data - using collisionRecoTable = o2::soa::Join; - using trackTable = o2::soa::Join; - using trackFullTable = o2::soa::Join; + using TrackTable = o2::soa::Join; + using TrackFullTableNoPid = o2::soa::Join; + using TrackFullTable = o2::soa::Join; - using trackTableIU = o2::soa::Join; - void processData(o2::soa::Filtered::iterator& collision, - const trackTable& tracksUnfiltered, - const o2::soa::Filtered& tracks, - const trackTableIU& tracksIU, + using TrackTableIU = o2::soa::Join; + /// + /// @brief process function in data, without the usage of PID info + void processData(o2::soa::Filtered::iterator const& collision, + const TrackTable& tracksUnfiltered, + const o2::soa::Filtered& tracks, + const TrackTableIU& tracksIU, o2::aod::BCsWithTimestamps const&) { /// here call the template processReco function auto bc = collision.bc_as(); - processReco(collision, tracksUnfiltered, tracks, tracksIU, 0, bc); + processReco(collision, tracksUnfiltered, tracks, tracksIU, 0, bc); } PROCESS_SWITCH(QaImpactPar, processData, "process data", true); + /// + /// @brief process function in data, with the possibility to use PID info + void processDataWithPid(o2::soa::Filtered::iterator const& collision, + const TrackTable& tracksUnfiltered, + const o2::soa::Filtered& tracks, + const TrackTableIU& tracksIU, + o2::aod::BCsWithTimestamps const&) + { + /// here call the template processReco function + auto bc = collision.bc_as(); + processReco(collision, tracksUnfiltered, tracks, tracksIU, 0, bc); + } + PROCESS_SWITCH(QaImpactPar, processDataWithPid, "process data with PID", false); /// MC - using collisionMCRecoTable = o2::soa::Join; - using trackMCFullTable = o2::soa::Join; - void processMC(o2::soa::Filtered::iterator& collision, - trackTable const& tracksUnfiltered, - o2::soa::Filtered const& tracks, - const trackTableIU& tracksIU, + using CollisionMCRecoTable = o2::soa::Join; + using TrackMCFullTableNoPid = o2::soa::Join; + using TrackMCFullTable = o2::soa::Join; + /// + /// @brief process function in MC, without the usage of PID info + void processMC(o2::soa::Filtered::iterator const& collision, + TrackTable const& tracksUnfiltered, + o2::soa::Filtered const& tracks, + const TrackTableIU& tracksIU, const o2::aod::McParticles& mcParticles, const o2::aod::McCollisions&, o2::aod::BCsWithTimestamps const&) { /// here call the template processReco function auto bc = collision.bc_as(); - processReco(collision, tracksUnfiltered, tracks, tracksIU, mcParticles, bc); + processReco(collision, tracksUnfiltered, tracks, tracksIU, mcParticles, bc); } PROCESS_SWITCH(QaImpactPar, processMC, "process MC", false); + /// + /// @brief process function in MC,with the possibility to use PID info + void processMCWithPid(o2::soa::Filtered::iterator const& collision, + TrackTable const& tracksUnfiltered, + o2::soa::Filtered const& tracks, + const TrackTableIU& tracksIU, + const o2::aod::McParticles& mcParticles, + const o2::aod::McCollisions&, + o2::aod::BCsWithTimestamps const&) + { + /// here call the template processReco function + auto bc = collision.bc_as(); + processReco(collision, tracksUnfiltered, tracks, tracksIU, mcParticles, bc); + } + PROCESS_SWITCH(QaImpactPar, processMCWithPid, "process MC with PID", false); /// core template process function /// template - /// void processReco(const C& collision, const trackTable& unfilteredTracks, const T& tracks, + /// void processReco(const C& collision, const TrackTable& unfilteredTracks, const T& tracks, /// const T_MC& mcParticles, /// o2::aod::BCsWithTimestamps const& bcs); @@ -199,6 +230,11 @@ struct QaImpactPar { /// init function - declare and define histograms void init(InitContext&) { + std::array processes = {doprocessData, doprocessDataWithPid, doprocessMC, doprocessMCWithPid}; + if (std::accumulate(processes.begin(), processes.end(), 0) != 1) { + LOGP(fatal, "One and only one process function for collision study must be enabled at a time."); + } + // Primary vertex const AxisSpec collisionXAxis{100, -20.f, 20.f, "X (cm)"}; const AxisSpec collisionYAxis{100, -20.f, 20.f, "Y (cm)"}; @@ -207,9 +243,9 @@ struct QaImpactPar { const AxisSpec collisionYOrigAxis{1000, -20.f, 20.f, "Y original PV (cm)"}; const AxisSpec collisionZOrigAxis{1000, -20.f, 20.f, "Z original PV (cm)"}; const AxisSpec collisionNumberContributorAxis{1000, 0, 1000, "Number of contributors"}; - const AxisSpec collisionDeltaX_PVrefit{nBins_DeltaX_PVrefit, minDeltaX_PVrefit, maxDeltaX_PVrefit, "#Delta x_{PV} (cm)"}; - const AxisSpec collisionDeltaY_PVrefit{nBins_DeltaY_PVrefit, minDeltaY_PVrefit, maxDeltaY_PVrefit, "#Delta y_{PV} (cm)"}; - const AxisSpec collisionDeltaZ_PVrefit{nBins_DeltaZ_PVrefit, minDeltaZ_PVrefit, maxDeltaZ_PVrefit, "#Delta z_{PV} (cm)"}; + const AxisSpec collisionDeltaX_PVrefit{nBinsDeltaXPVrefit, minDeltaXPVrefit, maxDeltaXPVrefit, "#Delta x_{PV} (cm)"}; + const AxisSpec collisionDeltaY_PVrefit{nBinsDeltaYPVrefit, minDeltaYPVrefit, maxDeltaYPVrefit, "#Delta y_{PV} (cm)"}; + const AxisSpec collisionDeltaZ_PVrefit{nBinsDeltaZPVrefit, minDeltaZPVrefit, maxDeltaZPVrefit, "#Delta z_{PV} (cm)"}; histograms.add("Reco/vertices", "", kTH1D, {{2, 0.5f, 2.5f, ""}}); histograms.get(HIST("Reco/vertices"))->GetXaxis()->SetBinLabel(1, "All PV"); @@ -236,7 +272,7 @@ struct QaImpactPar { ccdb->setURL(ccdburl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); - lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbpath_lut)); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); // if (!o2::base::GeometryManager::isGeometryLoaded()) { // ccdb->get(ccdbpath_geo); // } @@ -244,14 +280,15 @@ struct QaImpactPar { /// Custom cut selection objects - ITS layers that must be present std::set set_customITShitmap; // = {}; - if (use_customITSHitMap) { - for (int index_ITSlayer = 0; index_ITSlayer < 7; index_ITSlayer++) { - if ((customITShitmap & (1 << index_ITSlayer)) > 0) { - set_customITShitmap.insert(static_cast(index_ITSlayer)); + constexpr std::size_t NLayersIts = 7; + if (useCustomITSHitMap) { + for (std::size_t indexItsLayer = 0; indexItsLayer < NLayersIts; indexItsLayer++) { + if ((customITShitmap & (1 << indexItsLayer)) > 0) { + set_customITShitmap.insert(static_cast(indexItsLayer)); } } LOG(info) << "### customITShitmap: " << customITShitmap; - LOG(info) << "### n_customMinITShits: " << n_customMinITShits; + LOG(info) << "### nCustomMinITShits: " << nCustomMinITShits; LOG(info) << "### set_customITShitmap.size(): " << set_customITShitmap.size(); LOG(info) << "### Custom ITS hitmap checked: "; for (std::set::iterator it = set_customITShitmap.begin(); it != set_customITShitmap.end(); it++) { @@ -259,14 +296,14 @@ struct QaImpactPar { } LOG(info) << "############"; - selector_ITShitmap.SetRequireHitsInITSLayers(n_customMinITShits, set_customITShitmap); + selector_ITShitmap.SetRequireHitsInITSLayers(nCustomMinITShits, set_customITShitmap); } /// Custom cut selection objects - ITS layers that must be absent std::set set_customITShitmap_exclude; // = {}; - if (use_customITSHitMap) { - for (int index_ITSlayer = 0; index_ITSlayer < 7; index_ITSlayer++) { - if ((customITShitmap_exclude & (1 << index_ITSlayer)) > 0) { - set_customITShitmap_exclude.insert(static_cast(index_ITSlayer)); + if (useCustomITSHitMap) { + for (std::size_t indexItsLayer = 0; indexItsLayer < NLayersIts; indexItsLayer++) { + if ((customITShitmap_exclude & (1 << indexItsLayer)) > 0) { + set_customITShitmap_exclude.insert(static_cast(indexItsLayer)); } } LOG(info) << "### customITShitmap_exclude: " << customITShitmap_exclude; @@ -315,8 +352,8 @@ struct QaImpactPar { histograms.add("Reco/h4ImpPar", "", kTHnSparseD, {trackPtAxis, trackImpParRPhiAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); histograms.add("Reco/h4ImpParZ", "", kTHnSparseD, {trackPtAxis, trackImpParZAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); if (addTrackIUinfo) { - histograms.add("Reco/h4ClusterSizeIU", "", kTHnSparseD, {trackPaxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis, trackIUclusterSize}); - histograms.add("Reco/h4ImpParIU", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis}); + histograms.add("Reco/h4ClusterSizeIU", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis, trackIUclusterSize}); + // histograms.add("Reco/h4ImpParIU", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis}); histograms.add("Reco/h4ImpParZIU", "", kTHnSparseD, {trackPaxis, trackImpParZAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis}); } // if(fEnablePulls && !doPVrefit) { @@ -328,16 +365,25 @@ struct QaImpactPar { } isPIDPionApplied = ((nSigmaTPCPionMin > -10.001 && nSigmaTPCPionMax < 10.001) || (nSigmaTOFPionMin > -10.001 && nSigmaTOFPionMax < 10.001)); if (isPIDPionApplied) { + if (addTrackIUinfo) { + histograms.add("Reco/h4ClusterSizeIU_Pion", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis, trackIUclusterSize}); + } histograms.add("Reco/h4ImpPar_Pion", "", kTHnSparseD, {trackPtAxis, trackImpParRPhiAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); histograms.add("Reco/h4ImpParZ_Pion", "", kTHnSparseD, {trackPtAxis, trackImpParZAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); } isPIDKaonApplied = ((nSigmaTPCKaonMin > -10.001 && nSigmaTPCKaonMax < 10.001) || (nSigmaTOFKaonMin > -10.001 && nSigmaTOFKaonMax < 10.001)); if (isPIDKaonApplied) { + if (addTrackIUinfo) { + histograms.add("Reco/h4ClusterSizeIU_Kaon", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis, trackIUclusterSize}); + } histograms.add("Reco/h4ImpPar_Kaon", "", kTHnSparseD, {trackPtAxis, trackImpParRPhiAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); histograms.add("Reco/h4ImpParZ_Kaon", "", kTHnSparseD, {trackPtAxis, trackImpParZAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); } isPIDProtonApplied = ((nSigmaTPCProtonMin > -10.001 && nSigmaTPCProtonMax < 10.001) || (nSigmaTOFProtonMin > -10.001 && nSigmaTOFProtonMax < 10.001)); if (isPIDProtonApplied) { + if (addTrackIUinfo) { + histograms.add("Reco/h4ClusterSizeIU_Proton", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis, trackIUclusterSize}); + } histograms.add("Reco/h4ImpPar_Proton", "", kTHnSparseD, {trackPtAxis, trackImpParRPhiAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); histograms.add("Reco/h4ImpParZ_Proton", "", kTHnSparseD, {trackPtAxis, trackImpParZAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); } @@ -359,9 +405,9 @@ struct QaImpactPar { } /// core template process function - template - void processReco(const C& collision, const trackTable& unfilteredTracks, const T& tracks, - const trackTableIU& tracksIU, const T_MC& /*mcParticles*/, + template + void processReco(const C& collision, const TrackTable& unfilteredTracks, const T& tracks, + const TrackTableIU& tracksIU, const T_MC& /*mcParticles*/, o2::aod::BCsWithTimestamps::iterator const& bc) { constexpr float toMicrometers = 10000.f; // Conversion from [cm] to [mum] @@ -442,7 +488,7 @@ struct QaImpactPar { o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; // auto bc = collision.bc_as(); if (mRunNumber != bc.runNumber()) { - o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(ccdbpath_grp, bc.timestamp()); + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(ccdbPathGrp, bc.timestamp()); if (grpo != nullptr) { o2::base::Propagator::initFieldFromGRP(grpo); o2::base::Propagator::Instance()->setMatLUT(lut); @@ -483,6 +529,11 @@ struct QaImpactPar { /// loop over tracks float pt = -999.f; float p = -999.f; + float eta = -999.f; + float phi = -999.f; + int8_t sign = -1; + bool isPvContributor = false; + int nContributors = -1; float impParRPhi = -999.f; float impParZ = -999.f; float impParRPhiSigma = 999.f; @@ -502,7 +553,8 @@ struct QaImpactPar { int cnt = 0; for (const auto& track : tracks) { - if (keepOnlyPvContrib && !track.isPVContributor()) { + isPvContributor = track.isPVContributor(); + if (keepOnlyPvContrib && !isPvContributor) { /// let's skip all tracks that were not PV contributors originally /// this let us ignore tracks flagged as ambiguous continue; @@ -538,12 +590,12 @@ struct QaImpactPar { ///} /// apply custom ITS hitmap selections, if asked - if (use_customITSHitMap && !selector_ITShitmap.IsSelected(track, TrackSelection::TrackCuts::kITSHits)) { + if (useCustomITSHitMap && !selector_ITShitmap.IsSelected(track, TrackSelection::TrackCuts::kITSHits)) { /// skip this track and go on, because it does not satisfy the ITS hit requirements continue; } - if (use_customITSHitMap && custom_forceITSTPCmatching && (!track.hasITS() || !track.hasTPC())) { - // if (use_customITSHitMap && custom_forceITSTPCmatching && track.hasITS()) { ///ATTEMPT: REMOVE TRACKS WITH ITS + if (useCustomITSHitMap && customForceITSTPCmatching && (!track.hasITS() || !track.hasTPC())) { + // if (useCustomITSHitMap && customForceITSTPCmatching && track.hasITS()) { ///ATTEMPT: REMOVE TRACKS WITH ITS /// skip this track because it is not global (no matching ITS-TPC) continue; } @@ -582,12 +634,14 @@ struct QaImpactPar { pt = track.pt(); p = track.p(); - tpcNSigmaPion = track.tpcNSigmaPi(); - tpcNSigmaKaon = track.tpcNSigmaKa(); - tpcNSigmaProton = track.tpcNSigmaPr(); - tofNSigmaPion = track.tofNSigmaPi(); - tofNSigmaKaon = track.tofNSigmaKa(); - tofNSigmaProton = track.tofNSigmaPr(); + if constexpr (USE_PID) { + tpcNSigmaPion = track.tpcNSigmaPi(); + tpcNSigmaKaon = track.tpcNSigmaKa(); + tpcNSigmaProton = track.tpcNSigmaPr(); + tofNSigmaPion = track.tofNSigmaPi(); + tofNSigmaKaon = track.tofNSigmaKa(); + tofNSigmaProton = track.tofNSigmaPr(); + } histograms.fill(HIST("Reco/pt"), pt); histograms.fill(HIST("Reco/hNSigmaTPCPion"), pt, tpcNSigmaPion); @@ -678,7 +732,7 @@ struct QaImpactPar { } } else { auto trackPar = getTrackPar(track); - o2::gpu::gpustd::array dcaInfo{-999., -999.}; + std::array dcaInfo{-999., -999.}; if (o2::base::Propagator::Instance()->propagateToDCABxByBz({PVbase_recalculated.getX(), PVbase_recalculated.getY(), PVbase_recalculated.getZ()}, trackPar, 2.f, matCorr, &dcaInfo)) { impParRPhi = dcaInfo[0] * toMicrometers; impParZ = dcaInfo[1] * toMicrometers; @@ -701,36 +755,53 @@ struct QaImpactPar { } /// all tracks - histograms.fill(HIST("Reco/h4ImpPar"), pt, impParRPhi, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); - histograms.fill(HIST("Reco/h4ImpParZ"), pt, impParZ, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); + if ((pt * 1000 - static_cast(pt * 1000)) > downsamplingFraction) { + // downsampling - do not consider the current track + continue; + } + eta = track.eta(); + phi = track.phi(); + sign = track.sign(); + nContributors = collision.numContrib(); + histograms.fill(HIST("Reco/h4ImpPar"), pt, impParRPhi, eta, phi, pdgIndex, sign, nContributors, isPvContributor); + histograms.fill(HIST("Reco/h4ImpParZ"), pt, impParZ, eta, phi, pdgIndex, sign, nContributors, isPvContributor); if (addTrackIUinfo) { - histograms.fill(HIST("Reco/h4ClusterSizeIU"), p, clusterSizeInLayer0, trackIuPosX, trackIuPosY, trackIuPosZ); - histograms.fill(HIST("Reco/h4ImpParIU"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ); + histograms.fill(HIST("Reco/h4ClusterSizeIU"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ, clusterSizeInLayer0); + // histograms.fill(HIST("Reco/h4ImpParIU"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ); histograms.fill(HIST("Reco/h4ImpParZIU"), p, impParZ, trackIuPosX, trackIuPosY, trackIuPosZ); } if (fEnablePulls) { - histograms.fill(HIST("Reco/h4ImpParPulls"), pt, impParRPhi / impParRPhiSigma, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); - histograms.fill(HIST("Reco/h4ImpParZPulls"), pt, impParZ / impParZSigma, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); + histograms.fill(HIST("Reco/h4ImpParPulls"), pt, impParRPhi / impParRPhiSigma, eta, phi, pdgIndex, sign, nContributors, isPvContributor); + histograms.fill(HIST("Reco/h4ImpParZPulls"), pt, impParZ / impParZSigma, eta, phi, pdgIndex, sign, nContributors, isPvContributor); } if (isPIDPionApplied && nSigmaTPCPionMin < tpcNSigmaPion && tpcNSigmaPion < nSigmaTPCPionMax && nSigmaTOFPionMin < tofNSigmaPion && tofNSigmaPion < nSigmaTOFPionMax) { /// PID selected pions - histograms.fill(HIST("Reco/h4ImpPar_Pion"), pt, impParRPhi, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); - histograms.fill(HIST("Reco/h4ImpParZ_Pion"), pt, impParZ, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); + if (addTrackIUinfo) { + histograms.fill(HIST("Reco/h4ClusterSizeIU_Pion"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ, clusterSizeInLayer0); + } + histograms.fill(HIST("Reco/h4ImpPar_Pion"), pt, impParRPhi, eta, phi, pdgIndex, sign, nContributors, isPvContributor); + histograms.fill(HIST("Reco/h4ImpParZ_Pion"), pt, impParZ, eta, phi, pdgIndex, sign, nContributors, isPvContributor); histograms.fill(HIST("Reco/hNSigmaTPCPion_afterPID"), pt, tpcNSigmaPion); histograms.fill(HIST("Reco/hNSigmaTOFPion_afterPID"), pt, tofNSigmaPion); } if (isPIDKaonApplied && nSigmaTPCKaonMin < tpcNSigmaKaon && tpcNSigmaKaon < nSigmaTPCKaonMax && nSigmaTOFKaonMin < tofNSigmaKaon && tofNSigmaKaon < nSigmaTOFKaonMax) { /// PID selected kaons - histograms.fill(HIST("Reco/h4ImpPar_Kaon"), pt, impParRPhi, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); - histograms.fill(HIST("Reco/h4ImpParZ_Kaon"), pt, impParZ, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); + if (addTrackIUinfo) { + histograms.fill(HIST("Reco/h4ClusterSizeIU_Kaon"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ, clusterSizeInLayer0); + } + histograms.fill(HIST("Reco/h4ImpPar_Kaon"), pt, impParRPhi, eta, phi, pdgIndex, sign, nContributors, isPvContributor); + histograms.fill(HIST("Reco/h4ImpParZ_Kaon"), pt, impParZ, eta, phi, pdgIndex, sign, nContributors, isPvContributor); histograms.fill(HIST("Reco/hNSigmaTPCKaon_afterPID"), pt, tpcNSigmaKaon); histograms.fill(HIST("Reco/hNSigmaTOFKaon_afterPID"), pt, tofNSigmaKaon); } if (isPIDProtonApplied && nSigmaTPCProtonMin < tpcNSigmaProton && tpcNSigmaProton < nSigmaTPCProtonMax && nSigmaTOFProtonMin < tofNSigmaProton && tofNSigmaProton < nSigmaTOFProtonMax) { /// PID selected Protons - histograms.fill(HIST("Reco/h4ImpPar_Proton"), pt, impParRPhi, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); - histograms.fill(HIST("Reco/h4ImpParZ_Proton"), pt, impParZ, track.eta(), track.phi(), pdgIndex, track.sign(), collision.numContrib(), track.isPVContributor()); + if (addTrackIUinfo) { + histograms.fill(HIST("Reco/h4ClusterSizeIU_Proton"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ, clusterSizeInLayer0); + } + histograms.fill(HIST("Reco/h4ImpPar_Proton"), pt, impParRPhi, eta, phi, pdgIndex, sign, nContributors, isPvContributor); + histograms.fill(HIST("Reco/h4ImpParZ_Proton"), pt, impParZ, eta, phi, pdgIndex, sign, nContributors, isPvContributor); histograms.fill(HIST("Reco/hNSigmaTPCProton_afterPID"), pt, tpcNSigmaProton); histograms.fill(HIST("Reco/hNSigmaTOFProton_afterPID"), pt, tofNSigmaProton); } @@ -741,6 +812,6 @@ struct QaImpactPar { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec w{ - adaptAnalysisTask(cfgc, TaskName{"qa-impact-par"})}; + adaptAnalysisTask(cfgc)}; return w; } diff --git a/DPG/Tasks/AOTTrack/qaMatchEff.cxx b/DPG/Tasks/AOTTrack/qaMatchEff.cxx index ddcdf65766e..704d3fa89ad 100644 --- a/DPG/Tasks/AOTTrack/qaMatchEff.cxx +++ b/DPG/Tasks/AOTTrack/qaMatchEff.cxx @@ -32,9 +32,9 @@ #include "Framework/RunningWorkflowInfo.h" #include "Framework/runDataProcessing.h" // -#include "string" -#include "vector" -#include "set" +#include +#include +#include // namespace extConfPar { diff --git a/DPG/Tasks/AOTTrack/qaSignChargeMC.cxx b/DPG/Tasks/AOTTrack/qaSignChargeMC.cxx index 8190b075bbe..e40dd0e76e9 100644 --- a/DPG/Tasks/AOTTrack/qaSignChargeMC.cxx +++ b/DPG/Tasks/AOTTrack/qaSignChargeMC.cxx @@ -60,7 +60,7 @@ struct QaSignChargeMC { o2::aod::McParticles const&) { for (auto const& track : tracks) { - if (abs(track.eta()) > 0.8) { + if (std::abs(track.eta()) > 0.8) { continue; } if (!track.hasITS()) { @@ -73,7 +73,7 @@ struct QaSignChargeMC { continue; } if (absPDG) { - if (abs(track.mcParticle().pdgCode()) != PDG) { + if (std::abs(track.mcParticle().pdgCode()) != PDG) { continue; } } else { diff --git a/DPG/Tasks/AOTTrack/qaTrackSelection.cxx b/DPG/Tasks/AOTTrack/qaTrackSelection.cxx index 895db111497..f7ea3dd2f53 100644 --- a/DPG/Tasks/AOTTrack/qaTrackSelection.cxx +++ b/DPG/Tasks/AOTTrack/qaTrackSelection.cxx @@ -125,7 +125,7 @@ struct QaTrackCuts { customTrackCuts.SetRequireGoldenChi2(requireGoldenChi2.value); customTrackCuts.SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC.value); customTrackCuts.SetMaxChi2PerClusterITS(maxChi2PerClusterITS.value); - if (abs(maxDcaXYFactor.value - 1.f) > 1e-6) { // No DCAxy cut will be used, this is done via the member function of the task + if (std::abs(maxDcaXYFactor.value - 1.f) > 1e-6) { // No DCAxy cut will be used, this is done via the member function of the task customTrackCuts.SetMaxDcaXYPtDep([](float /*pt*/) { return 10000.f; }); } customTrackCuts.SetMaxDcaZ(maxDcaZ.value); diff --git a/DPG/Tasks/AOTTrack/tagAndProbeDmesons.cxx b/DPG/Tasks/AOTTrack/tagAndProbeDmesons.cxx index 2d236ee0230..31820a7c593 100644 --- a/DPG/Tasks/AOTTrack/tagAndProbeDmesons.cxx +++ b/DPG/Tasks/AOTTrack/tagAndProbeDmesons.cxx @@ -14,8 +14,8 @@ /// /// \author Fabrizio Grosa , CERN -#include "CCDB/BasicCCDBManager.h" -#include "CommonConstants/PhysicsConstants.h" +#include "PWGHF/Utils/utilsAnalysis.h" + #include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/trackUtilities.h" @@ -23,15 +23,22 @@ #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "Tools/ML/MlResponse.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DCAFitter/DCAFitterN.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" -#include "DCAFitter/DCAFitterN.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" -#include "PWGHF/Utils/utilsAnalysis.h" -#include "Tools/ML/MlResponse.h" + #include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -734,7 +741,7 @@ struct TagTwoProngDisplacedVertices { } else if (fillTopoVarsTable == 3 && !TESTBIT(isSignal, aod::tagandprobe::SignalFlags::BkgFromNoHf)) { // only background excluding tracks from other HF decays fillTable = false; } - float pseudoRndm = trackFirst.pt() * 1000. - (int64_t)(trackFirst.pt() * 1000); + float pseudoRndm = trackFirst.pt() * 1000. - static_cast(trackFirst.pt() * 1000); if (ptTag < ptTagMaxForDownsampling && pseudoRndm >= downsamplingForTopoVarTable) { fillTable = false; } @@ -899,7 +906,7 @@ struct TagTwoProngDisplacedVertices { } else if (fillTopoVarsTable == 3 && !TESTBIT(isSignal, aod::tagandprobe::SignalFlags::BkgFromNoHf)) { // only background excluding tracks from other HF decays fillTable = false; } - float pseudoRndm = trackPos.pt() * 1000. - (int64_t)(trackPos.pt() * 1000); + float pseudoRndm = trackPos.pt() * 1000. - static_cast(trackPos.pt() * 1000); if (ptTag < ptTagMaxForDownsampling && pseudoRndm >= downsamplingForTopoVarTable) { fillTable = false; } @@ -1150,6 +1157,7 @@ struct ProbeThirdTrack { Configurable> mlCutsDzeroFromDstar{"mlCutsDzeroFromDstar", {aod::tagandprobe::mlCuts[0], aod::tagandprobe::nBinsPt, 3, aod::tagandprobe::labelsEmpty, aod::tagandprobe::labelsMlScores}, "ML Selections for Kpi pairs from D0 <- D*+ decays"}; } mlConfig; Configurable ptCandMin{"ptCandMin", 0.f, "Minimum candidate pt for THnSparse filling"}; + Configurable fillTpcOnlyCase{"fillTpcOnlyCase", true, "Fill output for TPC only case (not needed for thinned data or Pb-Pb)"}; ConfigurableAxis axisPtProbe{"axisPtProbe", {VARIABLE_WIDTH, 0.05f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.2f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.f, 12.f, 15.f, 20.f, 25.f, 30.f}, "Axis for pt Probe"}; ConfigurableAxis axisPtTag{"axisPtTag", {VARIABLE_WIDTH, 0.05f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.2f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.f, 12.f, 15.f, 20.f, 25.f, 30.f}, "Axis for pt Tag"}; @@ -1250,6 +1258,9 @@ struct ProbeThirdTrack { for (int iChannel{0}; iChannel < aod::tagandprobe::TagChannels::NTagChannels; ++iChannel) { for (int iTrackType{0}; iTrackType < aod::tagandprobe::TrackTypes::NTrackTypes; ++iTrackType) { + if (!fillTpcOnlyCase && iTrackType == aod::tagandprobe::TrackTypes::GlobalWoDcaWoIts) { + continue; + } histos[iChannel][iTrackType] = registry.add(Form("h%sVsPtProbeTag_%s", tagChannels[iChannel].data(), trackTypes[iTrackType].data()), "; #it{p}_{T}(D) (GeV/#it{c}); #it{p}_{T}(tag) (GeV/#it{c}); #it{p}_{T}(probe) (GeV/#it{c}); #it{p}_{T}^{TPC in}(probe) (GeV/#it{c}); #it{M}(D) (GeV/#it{c}^{2}); #it{M}(tag) (GeV/#it{c}^{2}); #it{#eta}(probe); #it{N}_{cross rows}^{TPC}(probe); #chi^{2}/#it{N}_{clusters}^{TPC}(probe); #it{N}_{clusters}^{ITS}(probe);", HistType::kTHnSparseF, {axisPtD, axisPtTag, axisPtProbe, axisPtProbe, axisMass[iChannel], axisMassTag[iChannel], axisEtaProbe, axisNumCrossRowTpc, axisTpcChi2PerClus, axisNumCluIts}); @@ -1346,6 +1357,9 @@ struct ProbeThirdTrack { continue; } for (int iTrackType{0}; iTrackType < aod::tagandprobe::TrackTypes::NTrackTypes; ++iTrackType) { + if (!fillTpcOnlyCase && iTrackType == aod::tagandprobe::TrackTypes::GlobalWoDcaWoIts) { + continue; + } if (trackSelector[iTrackType].IsSelected(trackThird)) { histos[channel][iTrackType]->Fill(ptD, ptTag, ptTrackThird, ptTpcInnerTrackThird, invMass, invMassTag, etaTrackThird, numTpcCrossRowTrackThird, numTpcChi2NumCluTrackThird, numItsCluTrackThird); } diff --git a/DPG/Tasks/CMakeLists.txt b/DPG/Tasks/CMakeLists.txt index 959ed3e5637..642f8d6e772 100644 --- a/DPG/Tasks/CMakeLists.txt +++ b/DPG/Tasks/CMakeLists.txt @@ -18,3 +18,4 @@ add_subdirectory(FDD) add_subdirectory(MFT) add_subdirectory(Monitor) add_subdirectory(FT0) +add_subdirectory(ITS) diff --git a/DPG/Tasks/ITS/CMakeLists.txt b/DPG/Tasks/ITS/CMakeLists.txt new file mode 100644 index 00000000000..fc835ea769d --- /dev/null +++ b/DPG/Tasks/ITS/CMakeLists.txt @@ -0,0 +1,23 @@ +# 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. + +o2physics_add_dpl_workflow(its-impact-parameter-studies + SOURCES itsImpParStudies.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + O2::ReconstructionDataFormats + O2::DetectorsCommonDataFormats + O2::DetectorsVertexing + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(filtertracks + SOURCES filterTracks.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/DPG/Tasks/ITS/filterTracks.cxx b/DPG/Tasks/ITS/filterTracks.cxx new file mode 100644 index 00000000000..ed35c1dd95c --- /dev/null +++ b/DPG/Tasks/ITS/filterTracks.cxx @@ -0,0 +1,430 @@ +// 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. + +/// \file filterTracks.cxx +/// \brief Simple task to filter tracks and save infos to trees for DCA-related studies (alignment, HF-related issues, ...) +/// +/// \author Andrea Rossi + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod::track; +using namespace o2::aod::mctracklabel; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace filtertracks +{ + +DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! Collision index +DECLARE_SOA_COLUMN(IsInsideBeamPipe, isInsideBeamPipe, int); //! is within beam pipe +DECLARE_SOA_COLUMN(Pt, pt, float); //! track pt +DECLARE_SOA_COLUMN(Px, px, float); //! track px +DECLARE_SOA_COLUMN(Py, py, float); //! track py +DECLARE_SOA_COLUMN(Pz, pz, float); //! track pz +// DECLARE_SOA_COLUMN(Eta, eta, float); //! track eta +// DECLARE_SOA_COLUMN(X, x, float); //! track x position at the DCA to the primary vertex +// DECLARE_SOA_COLUMN(Y, y, float); //! track y position at the DCA to the primary vertex +// DECLARE_SOA_COLUMN(Z, z, float); //! track z position at the DCA to the primary vertex +// DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! track distance of closest approach at the primary vertex: in xy plane +// DECLARE_SOA_COLUMN(DcaZ, dcaz, float); //! track distance of closest approach at the primary vertex: along z (beam line) direction +DECLARE_SOA_COLUMN(Charge, charge, int); //! track sign, not really charge +DECLARE_SOA_COLUMN(NsigmaTPCpi, nsigmaTPCpi, float); //! TPC nsigma w.r.t. pion mass hypothesis +DECLARE_SOA_COLUMN(NsigmaTPCka, nsigmaTPCka, float); //! TPC nsigma w.r.t. kaon mass hypothesis +DECLARE_SOA_COLUMN(NsigmaTPCpr, nsigmaTPCpr, float); //! TPC nsigma w.r.t. proton mass hypothesis +DECLARE_SOA_COLUMN(NsigmaTOFpi, nsigmaTOFpi, float); //! TOF nsigma w.r.t. pion mass hypothesis +DECLARE_SOA_COLUMN(NsigmaTOFka, nsigmaTOFka, float); //! TOF nsigma w.r.t. kaon mass hypothesis +DECLARE_SOA_COLUMN(NsigmaTOFpr, nsigmaTOFpr, float); //! TOF nsigma w.r.t. proton mass hypothesis +DECLARE_SOA_COLUMN(TpcNCluster, tpcNCluster, int); //! TOF nsigma w.r.t. proton mass hypothesis + +///// MC INFO +DECLARE_SOA_COLUMN(MainHfMotherPdgCode, mainHfMotherPdgCode, int); //! mother pdg code for particles coming from HF, skipping intermediate resonance states. Not trustable when mother is not HF. Not suited for Sc->Lc decays, since Sc are never pointed to +DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); //! is phyiscal primary according to ALICE definition +DECLARE_SOA_COLUMN(MainBeautyAncestorPdgCode, mainBeautyAncestorPdgCode, int); //! pdgcode of beauty particle when this is an ancestor, otherwise -1 +DECLARE_SOA_COLUMN(MainMotherOrigIndex, mainMotherOrigIndex, int); //! original index in MCParticle tree of main mother: needed when checking if particles come from same mother +DECLARE_SOA_COLUMN(MainMotherNfinalStateDaught, mainMotherNfinalStateDaught, int); //! number of final state (we consider only pions, kaons, muons, electrons, protons) daughter in main mother decay. To be noted that this is computed only for decays of particles of interest (D0, Lc, K0s). If the sign is negative, it means that the decay is not in one of the desired channels (K0s->pi pi, Lc->pKpi, D0->K-pi+) + +DECLARE_SOA_COLUMN(MainMotherPt, mainMotherPt, float); //! original index in MCParticle tree of main mother: needed when chekcing if particles come from same mother +DECLARE_SOA_COLUMN(MainMotherY, mainMotherY, float); //! original index in MCParticle tree of main mother: needed when chekcing if particles come from same mother +DECLARE_SOA_COLUMN(MainBeautyAncestorPt, mainBeautyAncestorPt, float); //! original index in MCParticle tree of main mother: needed when chekcing if particles come from same mother +DECLARE_SOA_COLUMN(MainBeautyAncestorY, mainBeautyAncestorY, float); //! original index in MCParticle tree of main mother: needed when chekcing if particles come from same mother +DECLARE_SOA_COLUMN(MaxEtaDaughter, maxEtaDaughter, float); //! max (abs) eta of daughter particles, needed to reproduce acceptance cut +} // namespace filtertracks +DECLARE_SOA_TABLE(FilterColl, "AOD", "FILTERCOLL", + o2::aod::collision::BCId, + o2::aod::collision::PosX, + o2::aod::collision::PosY, + o2::aod::collision::PosZ, + o2::aod::collision::CovXX, + o2::aod::collision::CovXY, + o2::aod::collision::CovYY, + o2::aod::collision::CovXZ, + o2::aod::collision::CovYZ, + o2::aod::collision::CovZZ, + o2::aod::collision::Flags, + o2::aod::collision::Chi2, + o2::aod::collision::NumContrib, + o2::aod::collision::CollisionTime, + o2::aod::collision::CollisionTimeRes); +DECLARE_SOA_TABLE(FilterCollLite, "AOD", "FILTERCOLLLITE", + o2::aod::collision::PosX, + o2::aod::collision::PosY, + o2::aod::collision::PosZ, + o2::aod::collision::CovXX, + o2::aod::collision::CovXY, + o2::aod::collision::CovYY, + o2::aod::collision::CovXZ, + o2::aod::collision::CovYZ, + o2::aod::collision::CovZZ, + o2::aod::collision::Chi2, + o2::aod::collision::NumContrib, + o2::aod::collision::CollisionTime); +DECLARE_SOA_TABLE(FilterCollPos, "AOD", "FILTERCOLLPOS", + o2::aod::collision::PosX, + o2::aod::collision::PosY, + o2::aod::collision::PosZ, + o2::aod::collision::Chi2, + o2::aod::collision::NumContrib, + o2::aod::collision::CollisionTime); +DECLARE_SOA_TABLE(FiltTrackColIdx, "AOD", "FILTTRACKCOLIDX", + o2::aod::track::CollisionId); +DECLARE_SOA_TABLE(FilterTrack, "AOD", "FILTERTRACK", + aod::filtertracks::IsInsideBeamPipe, + o2::aod::track::TrackType, + o2::aod::track::X, + o2::aod::track::Alpha, + o2::aod::track::Y, + o2::aod::track::Z, + o2::aod::track::Snp, + o2::aod::track::Tgl, + o2::aod::track::Signed1Pt); +DECLARE_SOA_TABLE(FilterTrackExtr, "AOD", "FILTERTRACKEXTR", + // aod::filtertracks::Px,aod::filtertracks::Py, aod::filtertracks::Pz, + aod::filtertracks::Pt, o2::aod::track::Eta, + o2::aod::filtertracks::Charge, + o2::aod::track::DcaXY, + o2::aod::track::DcaZ, + o2::aod::track::SigmaDcaXY2, + o2::aod::track::SigmaDcaZ2, + aod::filtertracks::NsigmaTPCpi, aod::filtertracks::NsigmaTPCka, aod::filtertracks::NsigmaTPCpr, + aod::filtertracks::NsigmaTOFpi, aod::filtertracks::NsigmaTOFka, aod::filtertracks::NsigmaTOFpr); +DECLARE_SOA_TABLE(FiltTracExtDet, "AOD", "FILTTRACEXTDET", + o2::aod::track::ITSClusterSizes, + o2::aod::track::ITSChi2NCl, + o2::aod::track::TPCChi2NCl, + aod::filtertracks::TpcNCluster, + o2::aod::track::TrackTime); +DECLARE_SOA_TABLE(FilterTrackMC, "AOD", "FILTERTRACKMC", + // aod::filtertracks::Px,aod::filtertracks::Py, aod::filtertracks::Pz, + o2::aod::mcparticle::PdgCode, + o2::aod::filtertracks::IsPhysicalPrimary, + o2::aod::filtertracks::MainHfMotherPdgCode, + o2::aod::filtertracks::MainBeautyAncestorPdgCode, + o2::aod::filtertracks::MainMotherOrigIndex, + o2::aod::filtertracks::MainMotherNfinalStateDaught, + o2::aod::filtertracks::MainMotherPt, + o2::aod::filtertracks::MainMotherY, + o2::aod::filtertracks::MainBeautyAncestorPt, + o2::aod::filtertracks::MainBeautyAncestorY); +DECLARE_SOA_TABLE(GenParticles, "AOD", "GENPARTICLES", + // aod::filtertracks::Px,aod::filtertracks::Py, aod::filtertracks::Pz, + o2::aod::mcparticle::PdgCode, + o2::aod::mcparticle::McCollisionId, + o2::aod::filtertracks::MainBeautyAncestorPdgCode, + o2::aod::filtertracks::MainMotherPt, + o2::aod::filtertracks::MainMotherY, + o2::aod::filtertracks::MaxEtaDaughter, + o2::aod::filtertracks::MainBeautyAncestorPt, + o2::aod::filtertracks::MainBeautyAncestorY); +} // namespace o2::aod + +struct FilterTracks { + const static int nStudiedParticlesMc = 3; + + Produces filteredTracksCollIdx; + Produces filteredTracksTableExtra; + Produces filteredTracksTable; + Produces filteredTracksTableExtraDet; + Produces filteredTracksMC; + Produces selectedGenParticles; + Produces filterCollTable; + Produces filterCollLiteTable; + Produces filterCollPosTable; + + SliceCache cache; + // Configurable dummy{"dummy", 0, "dummy"}; + Configurable minTrackPt{"minTrackPt", 0.25, "min track pt"}; + Configurable trackDcaXyMax{"trackDcaXyMax", 0.5, "max track pt"}; + Configurable trackPtSampling{"trackPtSampling", 0, "track sampling mode"}; + Configurable produceCollTableFull{"produceCollTableFull", false, "produce full collision table"}; + Configurable produceCollTableLite{"produceCollTableLite", false, "produce lite collision table"}; + Configurable produceCollTableExtraLite{"produceCollTableExtraLite", 2, "produce extra lite collision table"}; + Configurable trackPtWeightLowPt{"trackPtWeightLowPt", 0.01f, "trackPtWeightLowPt"}; + Configurable trackPtWeightMidPt{"trackPtWeightMidPt", 0.10f, "trackPtWeightMidPt"}; + Configurable collFilterFraction{"collFilterFraction", 0.05f, "collFilterFraction"}; + + Filter trackFilter = requireGlobalTrackWoDCAInFilter() && aod::track::pt > minTrackPt&& nabs(aod::track::dcaXY) < trackDcaXyMax; + Filter collFilter = nabs(aod::collision::posZ * 10000.f - nround(aod::collision::posZ * 10000.f)) < collFilterFraction.node() * 2.f; + using CollisionsWithEvSel = soa::Join; + using TracksWithSelAndDca = soa::Join; + using TracksWithSelAndDcaMc = soa::Join; + using FilterCollisionsWithEvSel = soa::Filtered; + + float lowPtThreshold = 2.; + float midPtThreshold = 5.; + float nDigitScaleFactor = 10000.; + Partition> lowPtTracks = aod::track::pt < lowPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightLowPt.node() * lowPtThreshold); + Partition> midPtTracks = aod::track::pt > lowPtThreshold&& aod::track::pt < midPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightMidPt.node() * lowPtThreshold); + Partition> highPtTracks = aod::track::pt > midPtThreshold; + + Partition> lowPtTracksMC = aod::track::pt < lowPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightLowPt.node() * lowPtThreshold); + Partition> midPtTracksMC = aod::track::pt > lowPtThreshold&& aod::track::pt < midPtThreshold && (nabs(aod::track::pt * nDigitScaleFactor - nround(aod::track::pt * nDigitScaleFactor)) < trackPtWeightMidPt.node() * lowPtThreshold); + Partition> highPtTracksMC = aod::track::pt > midPtThreshold; + + std::array pdgSignalParticleArray = {kK0Short, o2::constants::physics::Pdg::kD0, o2::constants::physics::Pdg::kLambdaCPlus}; // K0s, D0 and Lc + std::array pdgDecayLc = {kProton, kKMinus, kPiPlus}; + std::array pdgDecayDzero = {kKMinus, kPiPlus}; + std::array pdgDecayKzero = {kPiMinus, kPiPlus}; + const int nK0sShortDaught = 2; + + void init(InitContext&) + { + } + + void fillTableData(auto track) + { + + filteredTracksCollIdx(track.collisionId()); + filteredTracksTableExtra(track.pt(), track.eta(), track.sign(), track.dcaXY(), track.dcaZ(), track.sigmaDcaXY2(), track.sigmaDcaZ2(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()); + filteredTracksTable(track.isWithinBeamPipe() ? 1 : 0, track.trackType(), track.x(), track.alpha(), track.y(), track.z(), track.snp(), track.tgl(), track.signed1Pt()); + + filteredTracksTableExtraDet(track.itsClusterSizes(), track.itsChi2NCl(), track.tpcChi2NCl(), track.tpcNClsFound(), track.trackTime()); + } + + void fillTableDataMC(auto track, aod::McParticles const& mcParticles) + { + + fillTableData(track); + bool hasMcParticle = track.has_mcParticle(); + if (hasMcParticle) { + /// the track is not fake + + // check whether the particle comes from a charm or beauty hadron and store its index + + auto mcparticle = track.mcParticle(); + int pdgParticleMother = 0; + for (int iSignPart = 0; iSignPart < nStudiedParticlesMc; iSignPart++) { + pdgParticleMother = pdgSignalParticleArray[iSignPart]; + auto motherIndex = RecoDecay::getMother(mcParticles, mcparticle, pdgParticleMother, true); // check whether mcparticle derives from a particle with pdg = pdgparticlemother, accepting also antiparticle (<- the true parameter) + if (motherIndex != -1) { + auto particleMother = mcParticles.rawIteratorAt(motherIndex); + // just for internal check + // double mass=particleMother.e()*particleMother.e()-particleMother.pt()*particleMother.pt()-particleMother.pz()*particleMother.pz(); + // filteredTracksMC(mcparticle.pdgCode(),mcparticle.isPhysicalPrimary(),particleMother.pdgCode(),0,motherIndex,0,particleMother.pt(),particleMother.y(),std::sqrt(mass),0); + if (pdgParticleMother == kK0Short) { + auto daughtersSlice = mcparticle.template daughters_as(); + int ndaught = daughtersSlice.size(); // might not be accurate in case K0s interact with material before decaying + if (ndaught != nK0sShortDaught) + ndaught *= -1; + filteredTracksMC(mcparticle.pdgCode(), mcparticle.isPhysicalPrimary(), particleMother.pdgCode(), 0, motherIndex, ndaught, particleMother.pt(), particleMother.y(), 0, 0); + // std::cout<<"FOUND K0s, MATCHED! size array "< indxDaughers; + if (pdgParticleMother == o2::constants::physics::Pdg::kD0) { + if (RecoDecay::isMatchedMCGen(mcParticles, particleMother, pdgParticleMother, pdgDecayDzero, true, nullptr, 3, &indxDaughers)) { + ndaught = 2; + // std::cout<<"######## FOUND D0, MATCHED! pdg: " <(mcParticles, particleMother, pdgParticleMother, pdgDecayLc, true, nullptr, 3, &indxDaughers)) { + ndaught = 3; + } else { + ndaught = -indxDaughers.size(); + } + } + // now check whether the charm hadron is prompt or comes from beauty decay + std::vector idxBhadMothers; + if (RecoDecay::getCharmHadronOrigin(mcParticles, particleMother, false, &idxBhadMothers) == RecoDecay::OriginType::NonPrompt) { + if (idxBhadMothers.size() > 1) { + LOG(info) << "more than 1 B mother hadron found, should not be: "; + for (uint64_t iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { + auto particleBhadr = mcParticles.rawIteratorAt(idxBhadMothers[iBhM]); + LOG(info) << particleBhadr.pdgCode(); + } + } + auto particleBhadr = mcParticles.rawIteratorAt(idxBhadMothers[0]); + // int pdgBhad=particleBhadr.pdgCode(); + filteredTracksMC(mcparticle.pdgCode(), mcparticle.isPhysicalPrimary(), particleMother.pdgCode(), particleBhadr.pdgCode(), motherIndex, ndaught, particleMother.pt(), particleMother.y(), particleBhadr.pt(), particleBhadr.y()); + } else { + filteredTracksMC(mcparticle.pdgCode(), mcparticle.isPhysicalPrimary(), particleMother.pdgCode(), 0, motherIndex, ndaught, particleMother.pt(), particleMother.y(), 0, 0); + } + break; + } + pdgParticleMother = 0; + } + if (pdgParticleMother == 0) + filteredTracksMC(mcparticle.pdgCode(), mcparticle.isPhysicalPrimary(), 0, 0, -1, 0, 0, 0, 0, 0); + // std::cout< const& tracks) + { + if (trackPtSampling == 0) { + for (auto const& track : tracks) { + fillTableData(track); + if (produceCollTableExtraLite == 2) { + filterCollPosTable(collision.posX(), collision.posY(), collision.posZ(), collision.chi2(), collision.numContrib(), collision.collisionTime()); + }; + } + } else { + auto lowPtTracksThisColl = lowPtTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto const& track : lowPtTracksThisColl) { + fillTableData(track); + if (produceCollTableExtraLite == 2) { + filterCollPosTable(collision.posX(), collision.posY(), collision.posZ(), collision.chi2(), collision.numContrib(), collision.collisionTime()); + }; + } + auto midPtTracksThisColl = midPtTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto const& track : midPtTracksThisColl) { + fillTableData(track); + if (produceCollTableExtraLite == 2) { + filterCollPosTable(collision.posX(), collision.posY(), collision.posZ(), collision.chi2(), collision.numContrib(), collision.collisionTime()); + }; + } + auto highPtTracksThisColl = highPtTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto const& track : highPtTracksThisColl) { + fillTableData(track); + if (produceCollTableExtraLite == 2) { + filterCollPosTable(collision.posX(), collision.posY(), collision.posZ(), collision.chi2(), collision.numContrib(), collision.collisionTime()); + }; + } + } + } + PROCESS_SWITCH(FilterTracks, processData, "process data", true); + void processCollisions(FilterCollisionsWithEvSel::iterator const& collision) + { + if (produceCollTableFull) + filterCollTable(collision.bcId(), collision.posX(), collision.posY(), collision.posZ(), collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ(), collision.flags(), collision.chi2(), collision.numContrib(), collision.collisionTime(), collision.collisionTimeRes()); + if (produceCollTableLite) + filterCollLiteTable(collision.posX(), collision.posY(), collision.posZ(), collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ(), collision.chi2(), collision.numContrib(), collision.collisionTime()); + if (produceCollTableExtraLite == 1) + filterCollPosTable(collision.posX(), collision.posY(), collision.posZ(), collision.chi2(), collision.numContrib(), collision.collisionTime()); + } + PROCESS_SWITCH(FilterTracks, processCollisions, "process collisions", true); + + void processMC(FilterCollisionsWithEvSel::iterator const& collision, soa::Filtered const& tracks, aod::McParticles const& mcParticles) + { + if (trackPtSampling == 0) { + for (auto const& track : tracks) { + fillTableDataMC(track, mcParticles); + } + } else { + auto lowPtTracksMCThisColl = lowPtTracksMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto const& track : lowPtTracksMCThisColl) { + fillTableDataMC(track, mcParticles); + } + auto midPtTracksMCThisColl = midPtTracksMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto const& track : midPtTracksMCThisColl) { + fillTableDataMC(track, mcParticles); + } + auto highPtTracksMCThisColl = highPtTracksMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto const& track : highPtTracksMCThisColl) { + fillTableDataMC(track, mcParticles); + } + } + + for (auto const& mcpart : mcParticles) { // NOTE THAT OF COURSE IN CASE OF SAMPLING THE GEN TABLE WON'T MATCH THE RECO EVEN CONSIDERING EFFICIENCY + int pdgCode = mcpart.pdgCode(); + // for(int iSignPart=0;iSignPart<3;iSignPart++){ + + std::vector indxDaughers; + float etamax = 0; + bool isMatchedToSignal = false; + if (std::abs(pdgCode) == kK0Short) { + isMatchedToSignal = RecoDecay::isMatchedMCGen(mcParticles, mcpart, kK0Short, pdgDecayKzero, true, nullptr, 1, &indxDaughers); + } + if (std::abs(pdgCode) == o2::constants::physics::Pdg::kD0) { + isMatchedToSignal = RecoDecay::isMatchedMCGen(mcParticles, mcpart, o2::constants::physics::Pdg::kD0, pdgDecayDzero, true, nullptr, 3, &indxDaughers); + } else if (std::abs(pdgCode) == o2::constants::physics::Pdg::kLambdaCPlus) { + isMatchedToSignal = RecoDecay::isMatchedMCGen(mcParticles, mcpart, o2::constants::physics::Pdg::kLambdaCPlus, pdgDecayLc, true, nullptr, 3, &indxDaughers); + // std::cout<<"Lc found, matched to MC? "<(); + // int ndaught = daughtersLxSlice.size(); + // for(auto lcDaught : daughtersLxSlice){ + // std::cout<<"Lc daught, total daught "< etamax) { + etamax = eta; + } + } + if (pdgCode == kK0Short) { + selectedGenParticles(mcpart.pdgCode(), mcpart.mcCollisionId(), 0, mcpart.pt(), mcpart.y(), etamax, 0, 0); + continue; + } + std::vector idxBhadMothers; + if (RecoDecay::getCharmHadronOrigin(mcParticles, mcpart, false, &idxBhadMothers) == RecoDecay::OriginType::NonPrompt) { + if (idxBhadMothers.size() > 1) { + LOG(info) << "loop on gen particles: more than 1 B mother hadron found, should not be: "; + for (uint64_t iBhM = 0; iBhM < idxBhadMothers.size(); iBhM++) { + auto particleBhadr = mcParticles.rawIteratorAt(idxBhadMothers[iBhM]); + LOG(info) << particleBhadr.pdgCode(); + } + } + auto particleBhadr = mcParticles.rawIteratorAt(idxBhadMothers[0]); + // int pdgBhad=particleBhadr.pdgCode(); + selectedGenParticles(mcpart.pdgCode(), mcpart.mcCollisionId(), particleBhadr.pdgCode(), mcpart.pt(), mcpart.y(), etamax, particleBhadr.pt(), particleBhadr.y()); + } else { + selectedGenParticles(mcpart.pdgCode(), mcpart.mcCollisionId(), 0, mcpart.pt(), mcpart.y(), etamax, 0, 0); + } + } + // + } + } + PROCESS_SWITCH(FilterTracks, processMC, "process MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/DPG/Tasks/ITS/itsImpParStudies.cxx b/DPG/Tasks/ITS/itsImpParStudies.cxx new file mode 100644 index 00000000000..67fba3b4989 --- /dev/null +++ b/DPG/Tasks/ITS/itsImpParStudies.cxx @@ -0,0 +1,699 @@ +// 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 Samuele Cattaruzzi + +#include + +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "ReconstructionDataFormats/DCA.h" +#include "Common/Core/trackUtilities.h" // for propagation to primary vertex + +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/PIDResponse.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsBase/GeometryManager.h" +#include "CommonUtils/NameConf.h" +#include "Framework/AnalysisDataModel.h" +#include "Common/Core/TrackSelection.h" +#include "DetectorsVertexing/PVertexer.h" +#include "ReconstructionDataFormats/Vertex.h" +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "Framework/RunningWorkflowInfo.h" +#include "CCDB/CcdbApi.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "CommonConstants/GeomConstants.h" + +#include "iostream" +#include "vector" +#include "set" + +using namespace o2::framework; +using namespace o2::framework::expressions; + +// void customize(std::vector& workflowOptions) +//{ +// ConfigParamSpec optionDoMC{"doMC", VariantType::Bool, false, {"Fill MC histograms."}}; +// workflowOptions.push_back(optionDoMC); +// } + +#include "Framework/runDataProcessing.h" + +/// QA task for impact parameter distribution monitoring +struct ItsImpactParStudies { + + /// Input parameters + Configurable fDebug{"fDebug", false, "Debug flag enabling outputs"}; + Configurable fEnablePulls{"fEnablePulls", false, "Enable storage of pulls"}; + ConfigurableAxis binningImpPar{"binningImpPar", {200, -500.f, 500.f}, "Impact parameter binning"}; + ConfigurableAxis binningPulls{"binningPulls", {200, -10.f, 10.f}, "Pulls binning"}; + ConfigurableAxis binningPt{"binningPt", {100, 0.f, 10.f}, "Pt binning"}; + ConfigurableAxis binningEta{"binningEta", {40, -2.f, 2.f}, "Eta binning"}; + ConfigurableAxis binningPhi{"binningPhi", {24, 0.f, o2::constants::math::TwoPI}, "Phi binning"}; + ConfigurableAxis binningPDG{"binningPDG", {5, -1.5f, 3.5f}, "PDG species binning (-1: not matched, 0: unknown, 1: pi, 2: K, 3: p)"}; + ConfigurableAxis binningCharge{"binningCharge", {2, -2.f, 2.f}, "charge binning (-1: negative; +1: positive)"}; + ConfigurableAxis binningIuPosX{"binningIuPosX", {100, -10.f, 10.f}, "Track IU x position"}; + ConfigurableAxis binningIuPosY{"binningIuPosY", {100, -10.f, 10.f}, "Track IU y position"}; + ConfigurableAxis binningIuPosZ{"binningIuPosZ", {100, -10.f, 10.f}, "Track IU z position"}; + ConfigurableAxis binningClusterSize{"binningClusterSize", {16, -0.5, 15.5}, "Cluster size, four bits per a layer"}; + ConfigurableAxis binsNumPvContrib{"binsNumPvContrib", {200, 0, 200}, "Number of original PV contributors"}; + Configurable keepOnlyPhysPrimary{"keepOnlyPhysPrimary", false, "Consider only phys. primary particles (MC)"}; + Configurable keepOnlyPvContrib{"keepOnlyPvContrib", false, "Consider only PV contributor tracks"}; + // Configurable numberContributorsMin{"numberContributorsMin", 0, "Minimum number of contributors for the primary vertex"}; + Configurable useTriggerkINT7{"useTriggerkINT7", false, "Use kINT7 trigger"}; + Configurable usesel8{"usesel8", true, "Use or not the sel8() (T0A & T0C) event selection"}; + Configurable addTrackIUinfo{"addTrackIUinfo", false, "Add track parameters at inner most update"}; + Configurable trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; + Configurable zVtxMax{"zVtxMax", 10.f, "Maximum value for |z_vtx|"}; + // Configurable keepOnlyGlobalTracks{"keepOnlyGlobalTracks", 1, "Keep only global tracks or not"}; + Configurable ptMin{"ptMin", 0.1f, "Minimum track pt [GeV/c]"}; + Configurable nSigmaTPCPionMin{"nSigmaTPCPionMin", -99999.f, "Minimum nSigma value in TPC, pion hypothesis"}; + Configurable nSigmaTPCPionMax{"nSigmaTPCPionMax", 99999.f, "Maximum nSigma value in TPC, pion hypothesis"}; + Configurable nSigmaTPCKaonMin{"nSigmaTPCKaonMin", -99999.f, "Minimum nSigma value in TPC, kaon hypothesis"}; + Configurable nSigmaTPCKaonMax{"nSigmaTPCKaonMax", 99999.f, "Maximum nSigma value in TPC, kaon hypothesis"}; + Configurable nSigmaTPCProtonMin{"nSigmaTPCProtonMin", -99999.f, "Minimum nSigma value in TPC, proton hypothesis"}; + Configurable nSigmaTPCProtonMax{"nSigmaTPCProtonMax", 99999.f, "Maximum nSigma value in TPC, proton hypothesis"}; + Configurable nSigmaTOFPionMin{"nSigmaTOFPionMin", -99999.f, "Minimum nSigma value in TOF, pion hypothesis"}; + Configurable nSigmaTOFPionMax{"nSigmaTOFPionMax", 99999.f, "Maximum nSigma value in TOF, pion hypothesis"}; + Configurable nSigmaTOFKaonMin{"nSigmaTOFKaonMin", -99999.f, "Minimum nSigma value in TOF, kaon hypothesis"}; + Configurable nSigmaTOFKaonMax{"nSigmaTOFKaonMax", 99999.f, "Maximum nSigma value in TOF, kaon hypothesis"}; + Configurable nSigmaTOFProtonMin{"nSigmaTOFProtonMin", -99999.f, "Minimum nSigma value in TOF, proton hypothesis"}; + Configurable nSigmaTOFProtonMax{"nSigmaTOFProtonMax", 99999.f, "Maximum nSigma value in TOF, proton hypothesis"}; + // PV refit + Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPathLut{"ccdbpath_lut", "GLO/Param/MatLUT", "Path for LUT parametrization"}; + // Configurable ccdbpath_geo{"ccdbpath_geo", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable ccdbPathGrp{"ccdbpath_grp", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable doPVrefit{"doPVrefit", true, "Do PV refit"}; + Configurable fillHistoPVrefit{"fillHistoPVrefit", false, "Do PV refit"}; + Configurable nBinsDeltaXPVrefit{"nBins_DeltaX_PVrefit", 1000, "Number of bins of DeltaX for PV refit"}; + Configurable nBinsDeltaYPVrefit{"nBins_DeltaY_PVrefit", 1000, "Number of bins of DeltaY for PV refit"}; + Configurable nBinsDeltaZPVrefit{"nBins_DeltaZ_PVrefit", 1000, "Number of bins of DeltaZ for PV refit"}; + Configurable minDeltaXPVrefit{"minDeltaX_PVrefit", -0.5, "Min. DeltaX value for PV refit (cm)"}; + Configurable maxDeltaXPVrefit{"maxDeltaX_PVrefit", 0.5, "Max. DeltaX value for PV refit (cm)"}; + Configurable minDeltaYPVrefit{"minDeltaY_PVrefit", -0.5, "Min. DeltaY value for PV refit (cm)"}; + Configurable maxDeltaYPVrefit{"maxDeltaY_PVrefit", 0.5, "Max. DeltaY value for PV refit (cm)"}; + Configurable minDeltaZPVrefit{"minDeltaZ_PVrefit", -0.5, "Min. DeltaZ value for PV refit (cm)"}; + Configurable maxDeltaZPVrefit{"maxDeltaZ_PVrefit", 0.5, "Max. DeltaZ value for PV refit (cm)"}; + Configurable minPVcontrib{"minPVcontrib", 0, "Minimum number of PV contributors"}; + Configurable maxPVcontrib{"maxPVcontrib", 10000, "Maximum number of PV contributors"}; + Configurable removeDiamondConstraint{"removeDiamondConstraint", true, "Remove the diamond constraint for the PV refit"}; + Configurable keepAllTracksPVrefit{"keepAllTracksPVrefit", false, "Keep all tracks for PV refit (for debug)"}; + Configurable useCustomITSHitMap{"use_customITSHitMap", false, "Use custom ITS hitmap selection"}; + Configurable customITShitmap{"customITShitmap", 0, "Custom ITS hitmap (consider the binary representation)"}; + Configurable customITShitmap_exclude{"customITShitmap_exclude", 0, "Custom ITS hitmap of layers to be excluded (consider the binary representation)"}; + Configurable nCustomMinITShits{"n_customMinITShits", 0, "Minimum number of layers crossed by a track among those in \"customITShitmap\""}; + Configurable customForceITSTPCmatching{"custom_forceITSTPCmatching", false, "Consider or not only ITS-TPC macthed tracks when using custom ITS hitmap"}; + Configurable downsamplingFraction{"downsamplingFraction", 1.1, "Fraction of tracks to be used to fill the output objects"}; + + /// Custom cut selection objects + TrackSelection selector_ITShitmap; + + /// Selections with Filter (from o2::framework::expressions) + // Primary vertex |z_vtx| ptMin; + + /// Histogram registry (from o2::framework) + HistogramRegistry histograms{"HistogramsImpParQA"}; + bool isPIDPionApplied; + bool isPIDKaonApplied; + bool isPIDProtonApplied; + + // Needed for PV refitting + Service ccdb; + o2::base::MatLayerCylSet* lut = nullptr; + // o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + int mRunNumber; + + ///////////////////////////////////////////////////////////// + /// Process functions /// + ///////////////////////////////////////////////////////////// + + /// Data + using CollisionRecoTable = o2::soa::Join; + using TrackTable = o2::soa::Join; + using TrackFullTable = o2::soa::Join; + using TrackTableIU = o2::soa::Join; + void processData(o2::soa::Filtered::iterator const& collision, + const TrackTable& tracksUnfiltered, + const o2::soa::Filtered& tracks, + const TrackTableIU& tracksIU, + o2::aod::BCsWithTimestamps const&) + { + /// here call the template processReco function + auto bc = collision.bc_as(); + processReco(collision, tracksUnfiltered, tracks, tracksIU, 0, bc); + } + PROCESS_SWITCH(ItsImpactParStudies, processData, "process data", true); + + /// MC + using CollisionMCRecoTable = o2::soa::Join; + using TrackMCFullTable = o2::soa::Join; + void processMC(o2::soa::Filtered::iterator const& collision, + TrackTable const& tracksUnfiltered, + o2::soa::Filtered const& tracks, + const TrackTableIU& tracksIU, + const o2::aod::McParticles& mcParticles, + const o2::aod::McCollisions&, + o2::aod::BCsWithTimestamps const&) + { + /// here call the template processReco function + auto bc = collision.bc_as(); + processReco(collision, tracksUnfiltered, tracks, tracksIU, mcParticles, bc); + } + PROCESS_SWITCH(ItsImpactParStudies, processMC, "process MC", false); + + /// core template process function + /// template + /// void processReco(const C& collision, const TrackTable& unfilteredTracks, const T& tracks, + /// const T_MC& mcParticles, + /// o2::aod::BCsWithTimestamps const& bcs); + + ///////////////////////////////////////////////////////////// + + /// init function - declare and define histograms + void init(InitContext&) + { + // Primary vertex + const AxisSpec collisionXAxis{100, -20.f, 20.f, "X (cm)"}; + const AxisSpec collisionYAxis{100, -20.f, 20.f, "Y (cm)"}; + const AxisSpec collisionZAxis{100, -20.f, 20.f, "Z (cm)"}; + const AxisSpec collisionXOrigAxis{1000, -20.f, 20.f, "X original PV (cm)"}; + const AxisSpec collisionYOrigAxis{1000, -20.f, 20.f, "Y original PV (cm)"}; + const AxisSpec collisionZOrigAxis{1000, -20.f, 20.f, "Z original PV (cm)"}; + const AxisSpec collisionNumberContributorAxis{1000, 0, 1000, "Number of contributors"}; + const AxisSpec collisionDeltaX_PVrefit{nBinsDeltaXPVrefit, minDeltaXPVrefit, maxDeltaXPVrefit, "#Delta x_{PV} (cm)"}; + const AxisSpec collisionDeltaY_PVrefit{nBinsDeltaYPVrefit, minDeltaYPVrefit, maxDeltaYPVrefit, "#Delta y_{PV} (cm)"}; + const AxisSpec collisionDeltaZ_PVrefit{nBinsDeltaZPVrefit, minDeltaZPVrefit, maxDeltaZPVrefit, "#Delta z_{PV} (cm)"}; + + histograms.add("Reco/vertices", "", kTH1D, {{2, 0.5f, 2.5f, ""}}); + histograms.get(HIST("Reco/vertices"))->GetXaxis()->SetBinLabel(1, "All PV"); + histograms.get(HIST("Reco/vertices"))->GetXaxis()->SetBinLabel(2, "PV refit doable"); + histograms.add("Reco/vertices_perTrack", "", kTH1D, {{3, 0.5f, 3.5f, ""}}); + histograms.get(HIST("Reco/vertices_perTrack"))->GetXaxis()->SetBinLabel(1, "All PV"); + histograms.get(HIST("Reco/vertices_perTrack"))->GetXaxis()->SetBinLabel(2, "PV refit doable"); + histograms.get(HIST("Reco/vertices_perTrack"))->GetXaxis()->SetBinLabel(3, "PV refit #chi^{2}!=-1"); + histograms.add("Reco/vertexZ", "", kTH1D, {collisionZAxis}); + histograms.add("Reco/numberContributors", "", kTH1D, {collisionNumberContributorAxis}); + if (doPVrefit && fillHistoPVrefit) { + histograms.add("Reco/nContrib_vs_DeltaX_PVrefit", "", kTH2D, {collisionNumberContributorAxis, collisionDeltaX_PVrefit}); + histograms.add("Reco/nContrib_vs_DeltaY_PVrefit", "", kTH2D, {collisionNumberContributorAxis, collisionDeltaY_PVrefit}); + histograms.add("Reco/nContrib_vs_DeltaZ_PVrefit", "", kTH2D, {collisionNumberContributorAxis, collisionDeltaZ_PVrefit}); + histograms.add("Reco/nContrib_vs_Chi2PVrefit", "", kTH2D, {collisionNumberContributorAxis, {102, -1.5, 100.5, "#chi^{2} PV refit"}}); + histograms.add("Reco/X_PVrefitChi2minus1", "PV refit with #chi^{2}==-1", kTH2D, {collisionXAxis, collisionXOrigAxis}); + histograms.add("Reco/Y_PVrefitChi2minus1", "PV refit with #chi^{2}==-1", kTH2D, {collisionYAxis, collisionYOrigAxis}); + histograms.add("Reco/Z_PVrefitChi2minus1", "PV refit with #chi^{2}==-1", kTH2D, {collisionZAxis, collisionZOrigAxis}); + histograms.add("Reco/nContrib_PVrefitNotDoable", "N. contributors for PV refit not doable", kTH1D, {collisionNumberContributorAxis}); + histograms.add("Reco/nContrib_PVrefitChi2minus1", "N. contributors original PV for PV refit #chi^{2}==-1", kTH1D, {collisionNumberContributorAxis}); + } + + // Needed for PV refitting + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); + + mRunNumber = -1; + + /// Custom cut selection objects - ITS layers that must be present + std::set set_customITShitmap; // = {}; + constexpr std::size_t NLayersIts = 7; + if (useCustomITSHitMap) { + for (std::size_t indexItsLayer = 0; indexItsLayer < NLayersIts; indexItsLayer++) { + if ((customITShitmap & (1 << indexItsLayer)) > 0) { + set_customITShitmap.insert(static_cast(indexItsLayer)); + } + } + LOG(info) << "### customITShitmap: " << customITShitmap; + LOG(info) << "### nCustomMinITShits: " << nCustomMinITShits; + LOG(info) << "### set_customITShitmap.size(): " << set_customITShitmap.size(); + LOG(info) << "### Custom ITS hitmap checked: "; + for (std::set::iterator it = set_customITShitmap.begin(); it != set_customITShitmap.end(); it++) { + LOG(info) << "Layer " << static_cast(*it) << " "; + } + LOG(info) << "############"; + + selector_ITShitmap.SetRequireHitsInITSLayers(nCustomMinITShits, set_customITShitmap); + } + /// Custom cut selection objects - ITS layers that must be absent + std::set set_customITShitmap_exclude; // = {}; + if (useCustomITSHitMap) { + for (std::size_t indexItsLayer = 0; indexItsLayer < NLayersIts; indexItsLayer++) { + if ((customITShitmap_exclude & (1 << indexItsLayer)) > 0) { + set_customITShitmap_exclude.insert(static_cast(indexItsLayer)); + } + } + LOG(info) << "### customITShitmap_exclude: " << customITShitmap_exclude; + LOG(info) << "### set_customITShitmap_exclude.size(): " << set_customITShitmap_exclude.size(); + LOG(info) << "### ITS layers to be excluded: "; + for (std::set::iterator it = set_customITShitmap_exclude.begin(); it != set_customITShitmap_exclude.end(); it++) { + LOG(info) << "Layer " << static_cast(*it) << " "; + } + LOG(info) << "############"; + + selector_ITShitmap.SetRequireNoHitsInITSLayers(set_customITShitmap_exclude); + } + + // tracks + const AxisSpec trackPtAxis{binningPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec trackPaxis{binningPt, "#it{p} (GeV/#it{c})"}; + const AxisSpec trackEtaAxis{binningEta, "#it{#eta}"}; + const AxisSpec trackPhiAxis{binningPhi, "#varphi"}; + const AxisSpec trackIUposXaxis{binningIuPosX, "x (cm)"}; + const AxisSpec trackIUposYaxis{binningIuPosY, "y (cm)"}; + const AxisSpec trackIUposZaxis{binningIuPosZ, "z (cm)"}; + const AxisSpec trackIUclusterSize{binningClusterSize, "cluster size"}; + const AxisSpec trackImpParRPhiAxis{binningImpPar, "#it{d}_{r#it{#varphi}} (#mum)"}; + const AxisSpec trackImpParZAxis{binningImpPar, "#it{d}_{z} (#mum)"}; + const AxisSpec trackImpParRPhiPullsAxis{binningPulls, "#it{d}_{r#it{#varphi}} / #sigma(#it{d}_{r#it{#varphi}})"}; + const AxisSpec trackImpParZPullsAxis{binningPulls, "#it{d}_{z} / #sigma(#it{d}_{z})"}; + const AxisSpec trackNSigmaTPCPionAxis{20, -10.f, 10.f, "Number of #sigma TPC #pi^{#pm}"}; + const AxisSpec trackNSigmaTPCKaonAxis{20, -10.f, 10.f, "Number of #sigma TPC K^{#pm}"}; + const AxisSpec trackNSigmaTPCProtonAxis{20, -10.f, 10.f, "Number of #sigma TPC proton"}; + const AxisSpec trackNSigmaTOFPionAxis{20, -10.f, 10.f, "Number of #sigma TOF #pi^{#pm}"}; + const AxisSpec trackNSigmaTOFKaonAxis{20, -10.f, 10.f, "Number of #sigma TOF K^{#pm}"}; + const AxisSpec trackNSigmaTOFProtonAxis{20, -10.f, 10.f, "Number of #sigma TOF proton"}; + const AxisSpec trackPDGAxis{binningPDG, "species (-1: not matched, 0: unknown, 1: pi, 2: K, 3: p)"}; + const AxisSpec trackChargeAxis{binningCharge, "charge binning (-1: negative; +1: positive)"}; + const AxisSpec axisVertexNumContrib{binsNumPvContrib, "Number of original PV contributors"}; + const AxisSpec trackIsPvContrib{2, -0.5f, 1.5f, "is PV contributor: 1=yes, 0=no"}; + + histograms.add("Reco/pt", "", kTH1D, {trackPtAxis}); + histograms.add("Reco/itsHits", "Number of hits vs ITS layer;layer ITS", kTH2D, {{8, -1.5, 6.5, "ITS layer"}, {8, -0.5, 7.5, "Number of hits"}}); + + if (addTrackIUinfo) { + histograms.add("Reco/h4ClusterSizeIU", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis, trackIUclusterSize}); + histograms.add("Reco/h4ImpParZIU", "", kTHnSparseD, {trackPaxis, trackImpParZAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis}); + } + + isPIDPionApplied = ((nSigmaTPCPionMin > -10.001 && nSigmaTPCPionMax < 10.001) || (nSigmaTOFPionMin > -10.001 && nSigmaTOFPionMax < 10.001)); + if (isPIDPionApplied) { + if (addTrackIUinfo) { + histograms.add("Reco/h4ClusterSizeIU_Pion", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis, trackIUclusterSize}); + } + } + isPIDKaonApplied = ((nSigmaTPCKaonMin > -10.001 && nSigmaTPCKaonMax < 10.001) || (nSigmaTOFKaonMin > -10.001 && nSigmaTOFKaonMax < 10.001)); + if (isPIDKaonApplied) { + if (addTrackIUinfo) { + histograms.add("Reco/h4ClusterSizeIU_Kaon", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis, trackIUclusterSize}); + } + } + isPIDProtonApplied = ((nSigmaTPCProtonMin > -10.001 && nSigmaTPCProtonMax < 10.001) || (nSigmaTOFProtonMin > -10.001 && nSigmaTOFProtonMax < 10.001)); + if (isPIDProtonApplied) { + if (addTrackIUinfo) { + histograms.add("Reco/h4ClusterSizeIU_Proton", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis, trackIUclusterSize}); + } + } + histograms.add("Reco/hNSigmaTPCPion", "", kTH2D, {trackPtAxis, trackNSigmaTPCPionAxis}); + histograms.add("Reco/hNSigmaTPCKaon", "", kTH2D, {trackPtAxis, trackNSigmaTPCKaonAxis}); + histograms.add("Reco/hNSigmaTPCProton", "", kTH2D, {trackPtAxis, trackNSigmaTPCProtonAxis}); + histograms.add("Reco/hNSigmaTOFPion", "", kTH2D, {trackPtAxis, trackNSigmaTOFPionAxis}); + histograms.add("Reco/hNSigmaTOFKaon", "", kTH2D, {trackPtAxis, trackNSigmaTOFKaonAxis}); + histograms.add("Reco/hNSigmaTOFProton", "", kTH2D, {trackPtAxis, trackNSigmaTOFProtonAxis}); + histograms.add("Reco/hNSigmaTPCPion_afterPID", "", kTH2D, {trackPtAxis, trackNSigmaTPCPionAxis}); + histograms.add("Reco/hNSigmaTPCKaon_afterPID", "", kTH2D, {trackPtAxis, trackNSigmaTPCKaonAxis}); + histograms.add("Reco/hNSigmaTPCProton_afterPID", "", kTH2D, {trackPtAxis, trackNSigmaTPCProtonAxis}); + histograms.add("Reco/hNSigmaTOFPion_afterPID", "", kTH2D, {trackPtAxis, trackNSigmaTOFPionAxis}); + histograms.add("Reco/hNSigmaTOFKaon_afterPID", "", kTH2D, {trackPtAxis, trackNSigmaTOFKaonAxis}); + histograms.add("Reco/hNSigmaTOFProton_afterPID", "", kTH2D, {trackPtAxis, trackNSigmaTOFProtonAxis}); + + histograms.add("MC/vertexZ_MCColl", "", kTH1D, {collisionZAxis}); + histograms.add("MC/ptMC", "", kTH1D, {trackPtAxis}); + } + + /// core template process function + template + void processReco(const C& collision, const TrackTable& unfilteredTracks, const T& tracks, + const TrackTableIU& tracksIU, const T_MC& /*mcParticles*/, + o2::aod::BCsWithTimestamps::iterator const& bc) + { + constexpr float toMicrometers = 10000.f; // Conversion from [cm] to [mum] + + /// trigger selection + if (useTriggerkINT7) { + // from Tutorial/src/multiplicityEventTrackSelection.cxx + if (!collision.alias_bit(kINT7)) { + return; + } + } + /// offline event selections + if (usesel8 && !collision.sel8()) { + return; + } + + histograms.fill(HIST("Reco/vertices"), 1); + histograms.fill(HIST("Reco/vertexZ"), collision.posZ()); + histograms.fill(HIST("Reco/numberContributors"), collision.numContrib()); + if constexpr (IS_MC) { + if (collision.has_mcCollision()) { + histograms.fill(HIST("MC/vertexZ_MCColl"), collision.mcCollision().posZ()); + } + } + + /////////////////////////////////// + /// For PV refit /// + /////////////////////////////////// + /// retrieve the tracks contributing to the primary vertex fitting + std::vector vec_globID_contr = {}; + std::vector vec_TrkContributos = {}; + if (fDebug) { + LOG(info) << "\n === New collision"; + } + const int nTrk = unfilteredTracks.size(); + int nContrib = 0; + int nNonContrib = 0; + for (const auto& unfilteredTrack : unfilteredTracks) { + if (!unfilteredTrack.isPVContributor()) { + /// the track di not contribute to fit the primary vertex + nNonContrib++; + continue; + } + vec_globID_contr.push_back(unfilteredTrack.globalIndex()); + vec_TrkContributos.push_back(getTrackParCov(unfilteredTrack)); + nContrib++; + if (fDebug) { + LOG(info) << "---> a contributor! stuff saved"; + LOG(info) << "vec_contrib size: " << vec_TrkContributos.size() << ", nContrib: " << nContrib; + } + } + if (fDebug) { + LOG(info) << "===> nTrk: " << nTrk << ", nContrib: " << nContrib << ", nNonContrib: " << nNonContrib; + } + + if (vec_TrkContributos.size() != collision.numContrib()) { + LOG(info) << "!!! something wrong in the number of contributor tracks for PV fit !!! " << vec_TrkContributos.size() << " vs. " << collision.numContrib(); + return; + } + + std::vector vec_useTrk_PVrefit(vec_globID_contr.size(), true); + + /// Prepare the vertex refitting + // Get the magnetic field for the Propagator + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + // auto bc = collision.bc_as(); + if (mRunNumber != bc.runNumber()) { + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(ccdbPathGrp, bc.timestamp()); + if (grpo != nullptr) { + o2::base::Propagator::initFieldFromGRP(grpo); + o2::base::Propagator::Instance()->setMatLUT(lut); + LOG(info) << "Setting magnetic field to current " << grpo->getL3Current() << " A for run " << bc.runNumber() << " from its GRP CCDB object"; + } else { + LOGF(fatal, "GRP object is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp()); + } + mRunNumber = bc.runNumber(); + } + // build the VertexBase to initialize the vertexer + o2::dataformats::VertexBase Pvtx; + Pvtx.setX(collision.posX()); + Pvtx.setY(collision.posY()); + Pvtx.setZ(collision.posZ()); + Pvtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + // configure PVertexer + o2::vertexing::PVertexer vertexer; + if (removeDiamondConstraint) { + o2::conf::ConfigurableParam::updateFromString("pvertexer.useMeanVertexConstraint=false"); // we want to refit w/o MeanVertex constraint + } + vertexer.init(); + bool PVrefit_doable = vertexer.prepareVertexRefit(vec_TrkContributos, Pvtx); + if (!PVrefit_doable) { + LOG(info) << "Not enough tracks accepted for the refit"; + if (doPVrefit) { + histograms.fill(HIST("Reco/nContrib_PVrefitNotDoable"), collision.numContrib()); + } + } else { + histograms.fill(HIST("Reco/vertices"), 2); + } + + if (fDebug) { + LOG(info) << "prepareVertexRefit = " << PVrefit_doable << " Ncontrib= " << vec_TrkContributos.size() << " Ntracks= " << collision.numContrib() << " Vtx= " << Pvtx.asString(); + } + /////////////////////////////////// + /////////////////////////////////// + + /// loop over tracks + float pt = -999.f; + float p = -999.f; + bool isPvContributor = false; + float impParRPhi = -999.f; + float impParZ = -999.f; + float tpcNSigmaPion = -999.f; + float tpcNSigmaKaon = -999.f; + float tpcNSigmaProton = -999.f; + float tofNSigmaPion = -999.f; + float tofNSigmaKaon = -999.f; + float tofNSigmaProton = -999.f; + float trackIuPosX = -999.f; + float trackIuPosY = -999.f; + float trackIuPosZ = -999.f; + std::array posXYZ = {-999.f, -999.f, -999.f}; + int clusterSizeInLayer0 = -1; + int ntr = tracks.size(); + int cnt = 0; + for (const auto& track : tracks) { + + isPvContributor = track.isPVContributor(); + if (keepOnlyPvContrib && !isPvContributor) { + /// let's skip all tracks that were not PV contributors originally + /// this let us ignore tracks flagged as ambiguous + continue; + } + + /// Specific MC selections + if constexpr (IS_MC) { + if (keepOnlyPhysPrimary) { + /// we want only physical primary particles + if (!track.has_mcParticle()) { + continue; + } + auto particle = track.mcParticle(); + if (keepOnlyPhysPrimary && particle.isPhysicalPrimary()) { + continue; + } + histograms.fill(HIST("MC/ptMC"), particle.pt()); + } else { + if (track.has_mcParticle()) { + auto particle = track.mcParticle(); + histograms.fill(HIST("MC/ptMC"), particle.pt()); + } + } + } + + /// Using the Filter instead + /// if ((keepOnlyGlobalTracks) && (!track.isGlobalTrack())) { + /// /// not a global track (FB 4 with tight DCA cuts) + /// continue; + ///} + + /// apply custom ITS hitmap selections, if asked + if (useCustomITSHitMap && !selector_ITShitmap.IsSelected(track, TrackSelection::TrackCuts::kITSHits)) { + /// skip this track and go on, because it does not satisfy the ITS hit requirements + continue; + } + if (useCustomITSHitMap && customForceITSTPCmatching && (!track.hasITS() || !track.hasTPC())) { + // if (useCustomITSHitMap && customForceITSTPCmatching && track.hasITS()) { ///ATTEMPT: REMOVE TRACKS WITH ITS + /// skip this track because it is not global (no matching ITS-TPC) + continue; + } + int itsNhits = 0; + for (unsigned int i = 0; i < 7; i++) { + if (track.itsClusterMap() & (1 << i)) { + itsNhits += 1; + } + } + bool trkHasITS = false; + for (unsigned int i = 0; i < 7; i++) { + if (track.itsClusterMap() & (1 << i)) { + trkHasITS = true; + histograms.fill(HIST("Reco/itsHits"), i, itsNhits); + } + } + if (!trkHasITS) { + histograms.fill(HIST("Reco/itsHits"), -1, itsNhits); + } + + pt = track.pt(); + p = track.p(); + tpcNSigmaPion = track.tpcNSigmaPi(); + tpcNSigmaKaon = track.tpcNSigmaKa(); + tpcNSigmaProton = track.tpcNSigmaPr(); + tofNSigmaPion = track.tofNSigmaPi(); + tofNSigmaKaon = track.tofNSigmaKa(); + tofNSigmaProton = track.tofNSigmaPr(); + + histograms.fill(HIST("Reco/pt"), pt); + histograms.fill(HIST("Reco/hNSigmaTPCPion"), pt, tpcNSigmaPion); + histograms.fill(HIST("Reco/hNSigmaTPCKaon"), pt, tpcNSigmaKaon); + histograms.fill(HIST("Reco/hNSigmaTPCProton"), pt, tpcNSigmaProton); + histograms.fill(HIST("Reco/hNSigmaTOFPion"), pt, tofNSigmaPion); + histograms.fill(HIST("Reco/hNSigmaTOFKaon"), pt, tofNSigmaKaon); + histograms.fill(HIST("Reco/hNSigmaTOFProton"), pt, tofNSigmaProton); + + histograms.fill(HIST("Reco/vertices_perTrack"), 1); + if (PVrefit_doable) { + histograms.fill(HIST("Reco/vertices_perTrack"), 2); + } + /// PV refitting, if the tracks contributed to this at the beginning + o2::dataformats::VertexBase PVbase_recalculated; + bool recalc_imppar = false; + if (doPVrefit && PVrefit_doable) { + auto it_trk = std::find(vec_globID_contr.begin(), vec_globID_contr.end(), track.globalIndex()); /// track global index + // if( it_trk==vec_globID_contr.end() ) { + // /// not found: this track did not contribute to the initial PV fitting + // continue; + // } + if (it_trk != vec_globID_contr.end()) { + /// this track contributed to the PV fit: let's do the refit without it + const int entry = std::distance(vec_globID_contr.begin(), it_trk); + if (!keepAllTracksPVrefit) { + vec_useTrk_PVrefit[entry] = false; /// remove the track from the PV refitting + } + auto Pvtx_refitted = vertexer.refitVertex(vec_useTrk_PVrefit, Pvtx); // vertex refit + if (fDebug) { + LOG(info) << "refit " << cnt << "/" << ntr << " result = " << Pvtx_refitted.asString(); + } + + /// enable the dca recalculation for the current PV contributor, after removing it from the PV refit + recalc_imppar = true; + + if (Pvtx_refitted.getChi2() < 0 && fillHistoPVrefit) { + LOG(info) << "---> Refitted vertex has bad chi2 = " << Pvtx_refitted.getChi2(); + histograms.fill(HIST("Reco/X_PVrefitChi2minus1"), Pvtx_refitted.getX(), collision.posX()); + histograms.fill(HIST("Reco/Y_PVrefitChi2minus1"), Pvtx_refitted.getY(), collision.posY()); + histograms.fill(HIST("Reco/Z_PVrefitChi2minus1"), Pvtx_refitted.getZ(), collision.posZ()); + histograms.fill(HIST("Reco/nContrib_PVrefitChi2minus1"), collision.numContrib()); + recalc_imppar = false; + } else if (fillHistoPVrefit) { + histograms.fill(HIST("Reco/vertices_perTrack"), 3); + } + // histograms.fill(HIST("Reco/nContrib_vs_Chi2PVrefit"), /*Pvtx_refitted.getNContributors()*/collision.numContrib()-1, Pvtx_refitted.getChi2()); + histograms.fill(HIST("Reco/nContrib_vs_Chi2PVrefit"), vec_useTrk_PVrefit.size() - 1, Pvtx_refitted.getChi2()); + + vec_useTrk_PVrefit[entry] = true; /// restore the track for the next PV refitting + + if (recalc_imppar) { + // fill the histograms for refitted PV with good Chi2 + const double DeltaX = Pvtx.getX() - Pvtx_refitted.getX(); + const double DeltaY = Pvtx.getY() - Pvtx_refitted.getY(); + const double DeltaZ = Pvtx.getZ() - Pvtx_refitted.getZ(); + if (fillHistoPVrefit) { + histograms.fill(HIST("Reco/nContrib_vs_DeltaX_PVrefit"), collision.numContrib(), DeltaX); + histograms.fill(HIST("Reco/nContrib_vs_DeltaY_PVrefit"), collision.numContrib(), DeltaY); + histograms.fill(HIST("Reco/nContrib_vs_DeltaZ_PVrefit"), collision.numContrib(), DeltaZ); + } + // fill the newly calculated PV + PVbase_recalculated.setX(Pvtx_refitted.getX()); + PVbase_recalculated.setY(Pvtx_refitted.getY()); + PVbase_recalculated.setZ(Pvtx_refitted.getZ()); + PVbase_recalculated.setCov(Pvtx_refitted.getSigmaX2(), Pvtx_refitted.getSigmaXY(), Pvtx_refitted.getSigmaY2(), Pvtx_refitted.getSigmaXZ(), Pvtx_refitted.getSigmaYZ(), Pvtx_refitted.getSigmaZ2()); + } + + cnt++; + } + } /// end 'if (doPVrefit && PVrefit_doable)' + + /// impact parameter to the PV + // value calculated wrt global PV (not recalculated) ---> coming from trackextension workflow + impParRPhi = toMicrometers * track.dcaXY(); // dca.getY(); + impParZ = toMicrometers * track.dcaZ(); // dca.getY(); + // updated value after PV recalculation + if (recalc_imppar) { + if (fEnablePulls) { + auto trackParCov = getTrackParCov(track); + o2::dataformats::DCA dcaInfoCov{999, 999, 999, 999, 999}; + if (o2::base::Propagator::Instance()->propagateToDCABxByBz(PVbase_recalculated, trackParCov, 2.f, matCorr, &dcaInfoCov)) { + impParRPhi = dcaInfoCov.getY() * toMicrometers; + impParZ = dcaInfoCov.getZ() * toMicrometers; + } + } else { + auto trackPar = getTrackPar(track); + std::array dcaInfo{-999., -999.}; + if (o2::base::Propagator::Instance()->propagateToDCABxByBz({PVbase_recalculated.getX(), PVbase_recalculated.getY(), PVbase_recalculated.getZ()}, trackPar, 2.f, matCorr, &dcaInfo)) { + impParRPhi = dcaInfo[0] * toMicrometers; + impParZ = dcaInfo[1] * toMicrometers; + } + } + } + + /// retrive track position at inner most update + if (addTrackIUinfo) { + for (const auto& trackIU : tracksIU) { + if (trackIU.globalIndex() == track.globalIndex()) { + o2::track::TrackParCov trackIuParCov = getTrackParCov(trackIU); + trackIuParCov.getXYZGlo(posXYZ); + trackIuPosX = posXYZ[0]; + trackIuPosY = posXYZ[1]; + trackIuPosZ = posXYZ[2]; + clusterSizeInLayer0 = trackIU.itsClsSizeInLayer(0); + } + } + } + + /// all tracks + if ((pt * 1000 - static_cast(pt * 1000)) > downsamplingFraction) { + // downsampling - do not consider the current track + continue; + } + + if (addTrackIUinfo) { + histograms.fill(HIST("Reco/h4ClusterSizeIU"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ, clusterSizeInLayer0); + histograms.fill(HIST("Reco/h4ImpParZIU"), p, impParZ, trackIuPosX, trackIuPosY, trackIuPosZ); + } + + if (isPIDPionApplied && nSigmaTPCPionMin < tpcNSigmaPion && tpcNSigmaPion < nSigmaTPCPionMax && nSigmaTOFPionMin < tofNSigmaPion && tofNSigmaPion < nSigmaTOFPionMax) { + /// PID selected pions + if (addTrackIUinfo) { + histograms.fill(HIST("Reco/h4ClusterSizeIU_Pion"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ, clusterSizeInLayer0); + } + histograms.fill(HIST("Reco/hNSigmaTPCPion_afterPID"), pt, tpcNSigmaPion); + histograms.fill(HIST("Reco/hNSigmaTOFPion_afterPID"), pt, tofNSigmaPion); + } + if (isPIDKaonApplied && nSigmaTPCKaonMin < tpcNSigmaKaon && tpcNSigmaKaon < nSigmaTPCKaonMax && nSigmaTOFKaonMin < tofNSigmaKaon && tofNSigmaKaon < nSigmaTOFKaonMax) { + /// PID selected kaons + if (addTrackIUinfo) { + histograms.fill(HIST("Reco/h4ClusterSizeIU_Kaon"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ, clusterSizeInLayer0); + } + histograms.fill(HIST("Reco/hNSigmaTPCKaon_afterPID"), pt, tpcNSigmaKaon); + histograms.fill(HIST("Reco/hNSigmaTOFKaon_afterPID"), pt, tofNSigmaKaon); + } + if (isPIDProtonApplied && nSigmaTPCProtonMin < tpcNSigmaProton && tpcNSigmaProton < nSigmaTPCProtonMax && nSigmaTOFProtonMin < tofNSigmaProton && tofNSigmaProton < nSigmaTOFProtonMax) { + /// PID selected Protons + if (addTrackIUinfo) { + histograms.fill(HIST("Reco/h4ClusterSizeIU_Proton"), p, impParRPhi, trackIuPosX, trackIuPosY, trackIuPosZ, clusterSizeInLayer0); + } + histograms.fill(HIST("Reco/hNSigmaTPCProton_afterPID"), pt, tpcNSigmaProton); + histograms.fill(HIST("Reco/hNSigmaTOFProton_afterPID"), pt, tofNSigmaProton); + } + } + } /// end processReco +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec w{ + adaptAnalysisTask(cfgc)}; + return w; +} diff --git a/DPG/Tasks/MFT/aQCMFTTracks.cxx b/DPG/Tasks/MFT/aQCMFTTracks.cxx index 8b264102150..5b5f4a71aa4 100644 --- a/DPG/Tasks/MFT/aQCMFTTracks.cxx +++ b/DPG/Tasks/MFT/aQCMFTTracks.cxx @@ -16,46 +16,73 @@ /// \author David Grund /// \since +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" + #include "CCDB/BasicCCDBManager.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "CommonConstants/LHCConstants.h" +#include "DataFormatsITSMFT/ROFRecord.h" #include "Framework/ASoAHelpers.h" - +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/DataTypes.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "CommonConstants/LHCConstants.h" #include "Framework/TimingInfo.h" -#include "DataFormatsITSMFT/ROFRecord.h" +#include "Framework/runDataProcessing.h" #include #include +#include + using namespace o2; using namespace o2::framework; using namespace o2::aod; struct CheckMFT { - HistogramRegistry registry{"registry", - {// 2d histograms - {"mMFTTrackEtaPhi_5_MinClusters", "Track #eta , #phi (NCls >= 5); #eta; #phi", {HistType::kTH2F, {{50, -4, -2}, {100, -3.2, 3.2}}}}, - {"mMFTTrackXY_5_MinClusters", "Track Position (NCls >= 5); x; y", {HistType::kTH2F, {{320, -16, 16}, {320, -16, 16}}}}, - {"mMFTTrackEtaPhi_7_MinClusters", "Track #eta , #phi (NCls >= 7); #eta; #phi", {HistType::kTH2F, {{50, -4, -2}, {100, -3.2, 3.2}}}}, - {"mMFTTrackXY_7_MinClusters", "Track Position (NCls >= 7); x; y", {HistType::kTH2F, {{320, -16, 16}, {320, -16, 16}}}}, - {"mMFTTrackEtaPhi_8_MinClusters", "Track #eta , #phi (NCls >= 8); #eta; #phi", {HistType::kTH2F, {{50, -4, -2}, {100, -3.2, 3.2}}}}, - {"mMFTTrackXY_8_MinClusters", "Track Position (NCls >= 8); x; y", {HistType::kTH2F, {{320, -16, 16}, {320, -16, 16}}}}, - // 1d histograms - {"mMFTTrackEta", "Track #eta; #eta; # entries", {HistType::kTH1F, {{50, -4, -2}}}}, - {"mMFTTrackNumberOfClusters", "Number Of Clusters Per Track; # clusters; # entries", {HistType::kTH1F, {{10, 0.5, 10.5}}}}, - {"mMFTTrackPhi", "Track #phi; #phi; # entries", {HistType::kTH1F, {{100, -3.2, 3.2}}}}, - {"mMFTTrackTanl", "Track tan #lambda; tan #lambda; # entries", {HistType::kTH1F, {{100, -25, 0}}}}, - {"mMFTTrackInvQPt", "Track q/p_{T}; q/p_{T} [1/GeV]; # entries", {HistType::kTH1F, {{250, -10, 10}}}}}}; + HistogramRegistry registry{"registry"}; + Configurable avClsPlots{"avClsPlots", false, "Enable average cluster plots"}; + + void init(o2::framework::InitContext&) + { + + const AxisSpec etaAxis{50, -4, -2, "#eta"}; + const AxisSpec phiAxis{100, -3.2, 3.2, "#phi"}; + const AxisSpec xAxis{320, -16, 16, "x"}; + const AxisSpec clsAxis{10, 0.5, 10.5, "# clusters"}; + const AxisSpec yAxis{320, -16, 16, "y"}; + const AxisSpec tanLamAxis{100, -25, 0, "tan #lambda"}; + const AxisSpec invQPtAxis{250, -10, 10, "q/p_{T} [1/GeV]"}; + + registry.add("mMFTTrackPhi", "Track #phi", {HistType::kTH1F, {phiAxis}}); + registry.add("mMFTTrackTanl", "Track tan #lambda", {HistType::kTH1F, {tanLamAxis}}); + registry.add("mMFTTrackInvQPt", "Track q/p_{T}", {HistType::kTH1F, {invQPtAxis}}); + registry.add("mMFTTrackEta", "Track #eta", {HistType::kTH1F, {etaAxis}}); + + registry.add("mMFTTrackEtaPhi_5_MinClusters", "Track Position (NCls >= 5)", {HistType::kTH2F, {etaAxis, phiAxis}}); + registry.add("mMFTTrackEtaPhi_6_MinClusters", "Track Position (NCls >= 6)", {HistType::kTH2F, {etaAxis, phiAxis}}); + registry.add("mMFTTrackEtaPhi_7_MinClusters", "Track Position (NCls >= 7)", {HistType::kTH2F, {etaAxis, phiAxis}}); + registry.add("mMFTTrackEtaPhi_8_MinClusters", "Track Position (NCls >= 8)", {HistType::kTH2F, {etaAxis, phiAxis}}); + + registry.add("mMFTTrackXY_5_MinClusters", "Track Position (NCls >= 5)", {HistType::kTH2F, {xAxis, yAxis}}); + registry.add("mMFTTrackXY_6_MinClusters", "Track Position (NCls >= 6)", {HistType::kTH2F, {xAxis, yAxis}}); + registry.add("mMFTTrackXY_7_MinClusters", "Track Position (NCls >= 7)", {HistType::kTH2F, {xAxis, yAxis}}); + registry.add("mMFTTrackXY_8_MinClusters", "Track Position (NCls >= 8)", {HistType::kTH2F, {xAxis, yAxis}}); + registry.add("mMFTTrackNumberOfClusters", "Number Of Clusters Per Track", {HistType::kTH1F, {clsAxis}}); + + if (avClsPlots) { + registry.add("mMFTTrackAvgClusters", "Average number of clusters per track; p;# clusters; # entries", {HistType::kTH2F, {{100, 0, 100}, {100, 0, 100}}}); + registry.add("mMFTTrackAvgClustersTru", "Average number of clusters per track; p;# clusters; # entries", {HistType::kTH2F, {{100, 0, 100}, {100, 0, 100}}}); + if (doprocessMC) { + registry.add("mMFTTrackAvgClustersHe", "Average number of clusters per track; p;# clusters; # entries", {HistType::kTH2F, {{100, 0, 100}, {100, 0, 100}}}); + registry.add("mMFTTrackAvgClustersTruHe", "Average number of clusters per track; p;# clusters; # entries", {HistType::kTH2F, {{100, 0, 100}, {100, 0, 100}}}); + } + } + } void process(aod::MFTTracks const& mfttracks) { - for (auto& track : mfttracks) { + for (const auto& track : mfttracks) { // 2d histograms float x = track.x(); float y = track.y(); @@ -65,14 +92,48 @@ struct CheckMFT { if (nCls >= 5) { registry.fill(HIST("mMFTTrackXY_5_MinClusters"), x, y); registry.fill(HIST("mMFTTrackEtaPhi_5_MinClusters"), eta, phi); - if (nCls >= 7) { - registry.fill(HIST("mMFTTrackXY_7_MinClusters"), x, y); - registry.fill(HIST("mMFTTrackEtaPhi_7_MinClusters"), eta, phi); - if (nCls >= 8) { - registry.fill(HIST("mMFTTrackXY_8_MinClusters"), x, y); - registry.fill(HIST("mMFTTrackEtaPhi_8_MinClusters"), eta, phi); + if (nCls >= 6) { + registry.fill(HIST("mMFTTrackXY_6_MinClusters"), x, y); + registry.fill(HIST("mMFTTrackEtaPhi_6_MinClusters"), eta, phi); + if (nCls >= 7) { + registry.fill(HIST("mMFTTrackXY_7_MinClusters"), x, y); + registry.fill(HIST("mMFTTrackEtaPhi_7_MinClusters"), eta, phi); + if (nCls >= 8) { + registry.fill(HIST("mMFTTrackXY_8_MinClusters"), x, y); + registry.fill(HIST("mMFTTrackEtaPhi_8_MinClusters"), eta, phi); + } + } + } + } + if (avClsPlots) { + static constexpr int kNcls = 10; + std::array clsSize; + for (unsigned int layer = 0; layer < kNcls; layer++) { + clsSize[layer] = (track.mftClusterSizesAndTrackFlags() >> (layer * 6)) & 0x3f; + // LOG(info) << "Layer " << layer << ": " << clsSize[layer]; + } + float avgCls = 0; + for (unsigned int layer = 0; layer < kNcls; layer++) { + avgCls += clsSize[layer]; + } + avgCls /= track.nClusters(); + + std::sort(clsSize.begin(), clsSize.end()); + float truncatedAvgCls = 0; + int ncls = 0; + for (unsigned int layer = 0; layer < kNcls; layer++) { + if (clsSize[layer] > 0) { + truncatedAvgCls += clsSize[layer]; + ncls++; + if (ncls >= 3) { + break; // we take the average of the first 5 non-zero clusters + } } } + truncatedAvgCls /= ncls; + + registry.fill(HIST("mMFTTrackAvgClusters"), track.p(), avgCls); + registry.fill(HIST("mMFTTrackAvgClustersTru"), track.p(), truncatedAvgCls); } // 1d histograms registry.fill(HIST("mMFTTrackEta"), eta); @@ -82,6 +143,49 @@ struct CheckMFT { registry.fill(HIST("mMFTTrackInvQPt"), track.signed1Pt()); } } + + void processMC(soa::Join const& mfttracks, + aod::McParticles const&) + { + static constexpr int kNcls = 10; + for (const auto& track : mfttracks) { + if (avClsPlots) { + std::array clsSize; + for (unsigned int layer = 0; layer < kNcls; layer++) { + clsSize[layer] = (track.mftClusterSizesAndTrackFlags() >> (layer * 6)) & 0x3f; + // LOG(info) << "Layer " << layer << ": " << clsSize[layer]; + } + float avgCls = 0; + for (unsigned int layer = 0; layer < kNcls; layer++) { + avgCls += clsSize[layer]; + } + avgCls /= track.nClusters(); + + std::sort(clsSize.begin(), clsSize.end()); + float truncatedAvgCls = 0; + int ncls = 0; + for (unsigned int layer = 0; layer < kNcls; layer++) { + if (clsSize[layer] > 0) { + truncatedAvgCls += clsSize[layer]; + ncls++; + if (ncls >= 3) { + break; // we take the average of the first 5 non-zero clusters + } + } + } + truncatedAvgCls /= ncls; + + if (track.has_mcParticle()) { + const auto& mcParticle = track.mcParticle(); + if (std::abs(mcParticle.pdgCode()) == 1000020040) { // He4 + registry.fill(HIST("mMFTTrackAvgClustersHe"), track.p(), avgCls); + registry.fill(HIST("mMFTTrackAvgClustersTruHe"), track.p(), truncatedAvgCls); + } + } + } + } + } + PROCESS_SWITCH(CheckMFT, processMC, "Process MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 5f1a85e607f..2a2d644e7c4 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -17,25 +17,33 @@ /// \author Jeremy Wilkinson #include "tpcSkimsTableCreator.h" + #include + #include +#include +#include /// ROOT #include "TRandom3.h" /// O2 -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" /// O2Physics +#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/CCDB/ctpRateFetcher.h" #include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/OccupancyTables.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/TableProducer/PID/pidTPCBase.h" using namespace o2; using namespace o2::framework; @@ -48,16 +56,22 @@ struct TreeWriterTpcV0 { Service ccdb; using Trks = soa::Join; - using Coll = soa::Join; + using TrksWithDEdxCorrection = soa::Join; + using Colls = soa::Join; + using MyBCTable = soa::Join; + using V0sWithID = soa::Join; /// Tables to be produced Produces rowTPCTree; + Produces rowTPCTreeWithdEdxTrkQA; + Produces rowTPCTreeWithTrkQA; /// Configurables Configurable nSigmaTOFdautrack{"nSigmaTOFdautrack", 999., "n-sigma TOF cut on the proton daughter tracks. Set 999 to switch it off."}; Configurable nClNorm{"nClNorm", 152., "Number of cluster normalization. Run 2: 159, Run 3 152"}; Configurable applyEvSel{"applyEvSel", 2, "Flag to apply rapidity cut: 0 -> no event selection, 1 -> Run 2 event selection, 2 -> Run 3 event selection"}; Configurable trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; + Configurable irSource{"irSource", "T0VTX", "Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"}; /// Configurables downsampling Configurable dwnSmplFactor_Pi{"dwnSmplFactor_Pi", 1., "downsampling factor for pions, default fraction to keep is 1."}; Configurable dwnSmplFactor_Pr{"dwnSmplFactor_Pr", 1., "downsampling factor for protons, default fraction to keep is 1."}; @@ -80,11 +94,12 @@ struct TreeWriterTpcV0 { ctpRateFetcher mRateFetcher; /// Funktion to fill skimmed tables - template + template void fillSkimmedV0Table(V0 const& v0, T const& track, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, int runnumber, double dwnSmplFactor, float hadronicRate) { const double ncl = track.tpcNClsFound(); + const double nclPID = track.tpcNClsFindableMinusPID(); const double p = track.tpcInnerParam(); const double mass = o2::track::pid_constants::sMasses[id]; const double bg = p / mass; @@ -101,7 +116,13 @@ struct TreeWriterTpcV0 { const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); if (pseudoRndm < dwnSmplFactor) { - rowTPCTree(track.tpcSignal(), + float usedDedx; + if constexpr (doUseCorreceddEdx) { + usedDedx = track.tpcSignalCorrected(); + } else { + usedDedx = track.tpcSignal(); + } + rowTPCTree(usedDedx, 1. / dEdxExp, track.tpcInnerParam(), track.tgl(), @@ -113,6 +134,7 @@ struct TreeWriterTpcV0 { bg, multTPC / 11000., std::sqrt(nClNorm / ncl), + nclPID, id, nSigmaTPC, nSigmaTOF, @@ -129,6 +151,135 @@ struct TreeWriterTpcV0 { } }; + template + void fillSkimmedV0TableWithdEdxTrQA(V0 const& v0, T const& track, TQA const& trackQA, bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, int runnumber, double dwnSmplFactor, float hadronicRate) + { + + const double ncl = track.tpcNClsFound(); + const double nclPID = track.tpcNClsFindableMinusPID(); + const double p = track.tpcInnerParam(); + const double mass = o2::track::pid_constants::sMasses[id]; + const double bg = p / mass; + const int multTPC = collision.multTPC(); + auto trackocc = collision.trackOccupancyInTimeRange(); + auto ft0occ = collision.ft0cOccupancyInTimeRange(); + + const float alpha = v0.alpha(); + const float qt = v0.qtarm(); + const float cosPA = v0.v0cosPA(); + const float pT = v0.pt(); + const float v0radius = v0.v0radius(); + const float gammapsipair = v0.psipair(); + + const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); + if (pseudoRndm < dwnSmplFactor) { + float usedDedx; + if constexpr (doUseCorreceddEdx) { + usedDedx = track.tpcSignalCorrected(); + } else { + usedDedx = track.tpcSignal(); + } + rowTPCTreeWithdEdxTrkQA(usedDedx, + 1. / dEdxExp, + track.tpcInnerParam(), + track.tgl(), + track.signed1Pt(), + track.eta(), + track.phi(), + track.y(), + mass, + bg, + multTPC / 11000., + std::sqrt(nClNorm / ncl), + nclPID, + id, + nSigmaTPC, + nSigmaTOF, + alpha, + qt, + cosPA, + pT, + v0radius, + gammapsipair, + runnumber, + trackocc, + ft0occ, + hadronicRate, + existTrkQA ? trackQA.tpcdEdxNorm() : -999); + } + }; + + /// Function to fill skimmed tables + template + void fillSkimmedV0TableWithTrQA(V0 const& v0, T const& track, TQA const& trackQA, bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, int runnumber, double dwnSmplFactor, float hadronicRate, int bcGlobalIndex, int bcTimeFrameId, int bcBcInTimeFrame) + { + + const double ncl = track.tpcNClsFound(); + const double nclPID = track.tpcNClsFindableMinusPID(); + const double p = track.tpcInnerParam(); + const double mass = o2::track::pid_constants::sMasses[id]; + const double bg = p / mass; + const int multTPC = collision.multTPC(); + auto trackocc = collision.trackOccupancyInTimeRange(); + auto ft0occ = collision.ft0cOccupancyInTimeRange(); + + const float alpha = v0.alpha(); + const float qt = v0.qtarm(); + const float cosPA = v0.v0cosPA(); + const float pT = v0.pt(); + const float v0radius = v0.v0radius(); + const float gammapsipair = v0.psipair(); + + const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); + if (pseudoRndm < dwnSmplFactor) { + float usedDedx; + if constexpr (doUseCorreceddEdx) { + usedDedx = track.tpcSignalCorrected(); + } else { + usedDedx = track.tpcSignal(); + } + rowTPCTreeWithTrkQA(usedDedx, + 1. / dEdxExp, + track.tpcInnerParam(), + track.tgl(), + track.signed1Pt(), + track.eta(), + track.phi(), + track.y(), + mass, + bg, + multTPC / 11000., + std::sqrt(nClNorm / ncl), + nclPID, + id, + nSigmaTPC, + nSigmaTOF, + alpha, + qt, + cosPA, + pT, + v0radius, + gammapsipair, + runnumber, + trackocc, + ft0occ, + hadronicRate, + bcGlobalIndex, + bcTimeFrameId, + bcBcInTimeFrame, + existTrkQA ? trackQA.tpcClusterByteMask() : -999, + existTrkQA ? trackQA.tpcdEdxMax0R() : -999, + existTrkQA ? trackQA.tpcdEdxMax1R() : -999, + existTrkQA ? trackQA.tpcdEdxMax2R() : -999, + existTrkQA ? trackQA.tpcdEdxMax3R() : -999, + existTrkQA ? trackQA.tpcdEdxTot0R() : -999, + existTrkQA ? trackQA.tpcdEdxTot1R() : -999, + existTrkQA ? trackQA.tpcdEdxTot2R() : -999, + existTrkQA ? trackQA.tpcdEdxTot3R() : -999, + existTrkQA ? trackQA.tpcdEdxNorm() : -999); + } + }; + double tsalisCharged(double pt, double mass, double sqrts) { const double a = 6.81, b = 59.24; @@ -185,7 +336,7 @@ struct TreeWriterTpcV0 { } /// Apply a track quality selection with a filter! - void process(Coll::iterator const& collision, soa::Filtered const& tracks, aod::V0Datas const& v0s, aod::BCsWithTimestamps const&) + void processStandard(Colls::iterator const& collision, soa::Filtered const& tracks, V0sWithID const& v0s, aod::BCsWithTimestamps const&) { /// Check event slection if (!isEventSelected(collision, tracks)) { @@ -193,14 +344,17 @@ struct TreeWriterTpcV0 { } auto bc = collision.bc_as(); const int runnumber = bc.runNumber(); - float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, "ZNC hadronic") * 1.e-3; + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; rowTPCTree.reserve(tracks.size()); /// Loop over v0 candidates - for (auto v0 : v0s) { + for (const auto& v0 : v0s) { auto posTrack = v0.posTrack_as>(); auto negTrack = v0.negTrack_as>(); + if (v0.v0addid() == -1) { + continue; + } // gamma if (static_cast(posTrack.pidbit() & (1 << 0)) && static_cast(negTrack.pidbit() & (1 << 0))) { if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { @@ -222,7 +376,7 @@ struct TreeWriterTpcV0 { // Lambda if (static_cast(posTrack.pidbit() & (1 << 2)) && static_cast(negTrack.pidbit() & (1 << 2))) { if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { - if (TMath::Abs(posTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + if (std::abs(posTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { fillSkimmedV0Table(v0, posTrack, collision, posTrack.tpcNSigmaPr(), posTrack.tofNSigmaPr(), posTrack.tpcExpSignalPr(posTrack.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); } } @@ -236,30 +390,490 @@ struct TreeWriterTpcV0 { fillSkimmedV0Table(v0, posTrack, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); } if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { - if (TMath::Abs(negTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + if (std::abs(negTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { fillSkimmedV0Table(v0, negTrack, collision, negTrack.tpcNSigmaPr(), negTrack.tofNSigmaPr(), negTrack.tpcExpSignalPr(negTrack.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); } } } } - } /// process -}; /// struct TreeWriterTpcV0 + } /// process Standard + PROCESS_SWITCH(TreeWriterTpcV0, processStandard, "Standard V0 Samples for PID", true); + + void processStandardWithCorrecteddEdx(Colls::iterator const& collision, soa::Filtered const& tracks, V0sWithID const& v0s, aod::BCsWithTimestamps const&) + { + /// Check event slection + if (!isEventSelected(collision, tracks)) { + return; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + + rowTPCTree.reserve(tracks.size()); + + /// Loop over v0 candidates + for (const auto& v0 : v0s) { + auto posTrack = v0.posTrack_as>(); + auto negTrack = v0.negTrack_as>(); + if (v0.v0addid() == -1) { + continue; + } + // gamma + if (static_cast(posTrack.pidbit() & (1 << 0)) && static_cast(negTrack.pidbit() & (1 << 0))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0Table(v0, posTrack, collision, posTrack.tpcNSigmaEl(), posTrack.tofNSigmaEl(), posTrack.tpcExpSignalEl(posTrack.tpcSignalCorrected()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0Table(v0, negTrack, collision, negTrack.tpcNSigmaEl(), negTrack.tofNSigmaEl(), negTrack.tpcExpSignalEl(negTrack.tpcSignalCorrected()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate); + } + } + // Ks0 + if (static_cast(posTrack.pidbit() & (1 << 1)) && static_cast(negTrack.pidbit() & (1 << 1))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0Table(v0, posTrack, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0Table(v0, negTrack, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + } + // Lambda + if (static_cast(posTrack.pidbit() & (1 << 2)) && static_cast(negTrack.pidbit() & (1 << 2))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(posTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0Table(v0, posTrack, collision, posTrack.tpcNSigmaPr(), posTrack.tofNSigmaPr(), posTrack.tpcExpSignalPr(posTrack.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0Table(v0, negTrack, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + } + // Antilambda + if (static_cast(posTrack.pidbit() & (1 << 3)) && static_cast(negTrack.pidbit() & (1 << 3))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0Table(v0, posTrack, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(negTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0Table(v0, negTrack, collision, negTrack.tpcNSigmaPr(), negTrack.tofNSigmaPr(), negTrack.tpcExpSignalPr(negTrack.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } + } + } + } + } /// process Standard + PROCESS_SWITCH(TreeWriterTpcV0, processStandardWithCorrecteddEdx, "Standard V0 Samples for PID with corrected dEdx", false); + + Preslice perCollisionTracks = aod::track::collisionId; + Preslice perCollisionV0s = aod::v0data::collisionId; + void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) + { + std::vector labelTrack2TrackQA; + labelTrack2TrackQA.clear(); + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + int64_t trackId = trackQA.trackId(); + int64_t trackQAIndex = trackQA.globalIndex(); + labelTrack2TrackQA[trackId] = trackQAIndex; + } + for (const auto& collision : collisions) { + auto tracks = myTracks.sliceBy(perCollisionTracks, collision.globalIndex()); + auto v0s = myV0s.sliceBy(perCollisionV0s, collision.globalIndex()); + /// Check event slection + if (!isEventSelected(collision, tracks)) { + continue; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + rowTPCTreeWithTrkQA.reserve(tracks.size()); + /// Loop over v0 candidates + for (const auto& v0 : v0s) { + auto posTrack = v0.posTrack_as(); + auto negTrack = v0.negTrack_as(); + if (v0.v0addid() == -1) { + continue; + } + aod::TracksQA posTrackQA; + aod::TracksQA negTrackQA; + bool existPosTrkQA; + bool existNegTrkQA; + if (labelTrack2TrackQA[posTrack.globalIndex()] != -1) { + posTrackQA = tracksQA.iteratorAt(labelTrack2TrackQA[posTrack.globalIndex()]); + existPosTrkQA = true; + } else { + posTrackQA = tracksQA.iteratorAt(0); + existPosTrkQA = false; + } + if (labelTrack2TrackQA[negTrack.globalIndex()] != -1) { + negTrackQA = tracksQA.iteratorAt(labelTrack2TrackQA[negTrack.globalIndex()]); + existNegTrkQA = true; + } else { + negTrackQA = tracksQA.iteratorAt(0); + existNegTrkQA = false; + } + + // gamma + if (static_cast(posTrack.pidbit() & (1 << 0)) && static_cast(negTrack.pidbit() & (1 << 0))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0TableWithdEdxTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaEl(), posTrack.tofNSigmaEl(), posTrack.tpcExpSignalEl(posTrack.tpcSignal()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0TableWithdEdxTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaEl(), negTrack.tofNSigmaEl(), negTrack.tpcExpSignalEl(negTrack.tpcSignal()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate); + } + } + // Ks0 + if (static_cast(posTrack.pidbit() & (1 << 1)) && static_cast(negTrack.pidbit() & (1 << 1))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithdEdxTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithdEdxTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + } + // Lambda + if (static_cast(posTrack.pidbit() & (1 << 2)) && static_cast(negTrack.pidbit() & (1 << 2))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(posTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0TableWithdEdxTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPr(), posTrack.tofNSigmaPr(), posTrack.tpcExpSignalPr(posTrack.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithdEdxTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + } + // Antilambda + if (static_cast(posTrack.pidbit() & (1 << 3)) && static_cast(negTrack.pidbit() & (1 << 3))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithdEdxTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(negTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0TableWithdEdxTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPr(), negTrack.tofNSigmaPr(), negTrack.tpcExpSignalPr(negTrack.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } + } + } + } + } + } /// process with dEdx from TrackQA + PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQA, "Standard V0 Samples with dEdx from Track QA for PID", false); + + Preslice perCollisionTracksWithNewDEdx = aod::track::collisionId; + void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) + { + std::vector labelTrack2TrackQA; + labelTrack2TrackQA.clear(); + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + int64_t trackId = trackQA.trackId(); + int64_t trackQAIndex = trackQA.globalIndex(); + labelTrack2TrackQA[trackId] = trackQAIndex; + } + for (const auto& collision : collisions) { + auto tracks = myTracks.sliceBy(perCollisionTracksWithNewDEdx, collision.globalIndex()); + auto v0s = myV0s.sliceBy(perCollisionV0s, collision.globalIndex()); + /// Check event slection + if (!isEventSelected(collision, tracks)) { + continue; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + rowTPCTreeWithTrkQA.reserve(tracks.size()); + /// Loop over v0 candidates + for (const auto& v0 : v0s) { + auto posTrack = v0.posTrack_as(); + auto negTrack = v0.negTrack_as(); + if (v0.v0addid() == -1) { + continue; + } + aod::TracksQA posTrackQA; + aod::TracksQA negTrackQA; + bool existPosTrkQA; + bool existNegTrkQA; + if (labelTrack2TrackQA[posTrack.globalIndex()] != -1) { + posTrackQA = tracksQA.iteratorAt(labelTrack2TrackQA[posTrack.globalIndex()]); + existPosTrkQA = true; + } else { + posTrackQA = tracksQA.iteratorAt(0); + existPosTrkQA = false; + } + if (labelTrack2TrackQA[negTrack.globalIndex()] != -1) { + negTrackQA = tracksQA.iteratorAt(labelTrack2TrackQA[negTrack.globalIndex()]); + existNegTrkQA = true; + } else { + negTrackQA = tracksQA.iteratorAt(0); + existNegTrkQA = false; + } + + // gamma + if (static_cast(posTrack.pidbit() & (1 << 0)) && static_cast(negTrack.pidbit() & (1 << 0))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0TableWithdEdxTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaEl(), posTrack.tofNSigmaEl(), posTrack.tpcExpSignalEl(posTrack.tpcSignalCorrected()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0TableWithdEdxTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaEl(), negTrack.tofNSigmaEl(), negTrack.tpcExpSignalEl(negTrack.tpcSignalCorrected()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate); + } + } + // Ks0 + if (static_cast(posTrack.pidbit() & (1 << 1)) && static_cast(negTrack.pidbit() & (1 << 1))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithdEdxTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithdEdxTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + } + // Lambda + if (static_cast(posTrack.pidbit() & (1 << 2)) && static_cast(negTrack.pidbit() & (1 << 2))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(posTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0TableWithdEdxTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPr(), posTrack.tofNSigmaPr(), posTrack.tpcExpSignalPr(posTrack.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithdEdxTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + } + // Antilambda + if (static_cast(posTrack.pidbit() & (1 << 3)) && static_cast(negTrack.pidbit() & (1 << 3))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithdEdxTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(negTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0TableWithdEdxTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPr(), negTrack.tofNSigmaPr(), negTrack.tpcExpSignalPr(negTrack.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } + } + } + } + } + } /// process with dEdx from TrackQA + PROCESS_SWITCH(TreeWriterTpcV0, processWithdEdxTrQAWithCorrecteddEdx, "Standard V0 Samples with dEdx from Track QA for PID with corrected dEdx", false); + + void processWithTrQA(Colls const& collisions, Trks const& myTracks, V0sWithID const& myV0s, MyBCTable const&, aod::TracksQAVersion const& tracksQA) + { + std::vector labelTrack2TrackQA; + labelTrack2TrackQA.clear(); + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + int64_t trackId = trackQA.trackId(); + int64_t trackQAIndex = trackQA.globalIndex(); + labelTrack2TrackQA[trackId] = trackQAIndex; + } + for (const auto& collision : collisions) { + auto tracks = myTracks.sliceBy(perCollisionTracks, collision.globalIndex()); + auto v0s = myV0s.sliceBy(perCollisionV0s, collision.globalIndex()); + /// Check event slection + if (!isEventSelected(collision, tracks)) { + continue; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + const int bcGlobalIndex = bc.globalIndex(); + const int bcTimeFrameId = bc.tfId(); + const int bcBcInTimeFrame = bc.bcInTF(); + rowTPCTreeWithTrkQA.reserve(tracks.size()); + /// Loop over v0 candidates + for (const auto& v0 : v0s) { + auto posTrack = v0.posTrack_as(); + auto negTrack = v0.negTrack_as(); + if (v0.v0addid() == -1) { + continue; + } + aod::TracksQA posTrackQA; + aod::TracksQA negTrackQA; + bool existPosTrkQA; + bool existNegTrkQA; + if (labelTrack2TrackQA[posTrack.globalIndex()] != -1) { + posTrackQA = tracksQA.iteratorAt(labelTrack2TrackQA[posTrack.globalIndex()]); + existPosTrkQA = true; + } else { + posTrackQA = tracksQA.iteratorAt(0); + existPosTrkQA = false; + } + if (labelTrack2TrackQA[negTrack.globalIndex()] != -1) { + negTrackQA = tracksQA.iteratorAt(labelTrack2TrackQA[negTrack.globalIndex()]); + existNegTrkQA = true; + } else { + negTrackQA = tracksQA.iteratorAt(0); + existNegTrkQA = false; + } + + // gamma + if (static_cast(posTrack.pidbit() & (1 << 0)) && static_cast(negTrack.pidbit() & (1 << 0))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0TableWithTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaEl(), posTrack.tofNSigmaEl(), posTrack.tpcExpSignalEl(posTrack.tpcSignal()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0TableWithTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaEl(), negTrack.tofNSigmaEl(), negTrack.tpcExpSignalEl(negTrack.tpcSignal()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + // Ks0 + if (static_cast(posTrack.pidbit() & (1 << 1)) && static_cast(negTrack.pidbit() & (1 << 1))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + // Lambda + if (static_cast(posTrack.pidbit() & (1 << 2)) && static_cast(negTrack.pidbit() & (1 << 2))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(posTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0TableWithTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPr(), posTrack.tofNSigmaPr(), posTrack.tpcExpSignalPr(posTrack.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + // Antilambda + if (static_cast(posTrack.pidbit() & (1 << 3)) && static_cast(negTrack.pidbit() & (1 << 3))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(negTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0TableWithTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPr(), negTrack.tofNSigmaPr(), negTrack.tpcExpSignalPr(negTrack.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + } + } + } + } /// process with TrackQA + PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQA, "Standard V0 Samples with Track QA for PID", false); + + void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, V0sWithID const& myV0s, MyBCTable const&, aod::TracksQAVersion const& tracksQA) + { + std::vector labelTrack2TrackQA; + labelTrack2TrackQA.clear(); + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + int64_t trackId = trackQA.trackId(); + int64_t trackQAIndex = trackQA.globalIndex(); + labelTrack2TrackQA[trackId] = trackQAIndex; + } + for (const auto& collision : collisions) { + auto tracks = myTracks.sliceBy(perCollisionTracksWithNewDEdx, collision.globalIndex()); + auto v0s = myV0s.sliceBy(perCollisionV0s, collision.globalIndex()); + /// Check event slection + if (!isEventSelected(collision, tracks)) { + continue; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + const int bcGlobalIndex = bc.globalIndex(); + const int bcTimeFrameId = bc.tfId(); + const int bcBcInTimeFrame = bc.bcInTF(); + rowTPCTreeWithTrkQA.reserve(tracks.size()); + /// Loop over v0 candidates + for (const auto& v0 : v0s) { + auto posTrack = v0.posTrack_as(); + auto negTrack = v0.negTrack_as(); + if (v0.v0addid() == -1) { + continue; + } + aod::TracksQA posTrackQA; + aod::TracksQA negTrackQA; + bool existPosTrkQA; + bool existNegTrkQA; + if (labelTrack2TrackQA[posTrack.globalIndex()] != -1) { + posTrackQA = tracksQA.iteratorAt(labelTrack2TrackQA[posTrack.globalIndex()]); + existPosTrkQA = true; + } else { + posTrackQA = tracksQA.iteratorAt(0); + existPosTrkQA = false; + } + if (labelTrack2TrackQA[negTrack.globalIndex()] != -1) { + negTrackQA = tracksQA.iteratorAt(labelTrack2TrackQA[negTrack.globalIndex()]); + existNegTrkQA = true; + } else { + negTrackQA = tracksQA.iteratorAt(0); + existNegTrkQA = false; + } + + // gamma + if (static_cast(posTrack.pidbit() & (1 << 0)) && static_cast(negTrack.pidbit() & (1 << 0))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0TableWithTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaEl(), posTrack.tofNSigmaEl(), posTrack.tpcExpSignalEl(posTrack.tpcSignalCorrected()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron], maxPt4dwnsmplTsalisElectrons)) { + fillSkimmedV0TableWithTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaEl(), negTrack.tofNSigmaEl(), negTrack.tpcExpSignalEl(negTrack.tpcSignalCorrected()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + // Ks0 + if (static_cast(posTrack.pidbit() & (1 << 1)) && static_cast(negTrack.pidbit() & (1 << 1))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + // Lambda + if (static_cast(posTrack.pidbit() & (1 << 2)) && static_cast(negTrack.pidbit() & (1 << 2))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(posTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0TableWithTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPr(), posTrack.tofNSigmaPr(), posTrack.tpcExpSignalPr(posTrack.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPi(), negTrack.tofNSigmaPi(), negTrack.tpcExpSignalPi(negTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + // Antilambda + if (static_cast(posTrack.pidbit() & (1 << 3)) && static_cast(negTrack.pidbit() & (1 << 3))) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion], maxPt4dwnsmplTsalisPions)) { + fillSkimmedV0TableWithTrQA(v0, posTrack, posTrackQA, existPosTrkQA, collision, posTrack.tpcNSigmaPi(), posTrack.tofNSigmaPi(), posTrack.tpcExpSignalPi(posTrack.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { + if (std::abs(negTrack.tofNSigmaPr()) <= nSigmaTOFdautrack) { + fillSkimmedV0TableWithTrQA(v0, negTrack, negTrackQA, existNegTrkQA, collision, negTrack.tpcNSigmaPr(), negTrack.tofNSigmaPr(), negTrack.tpcExpSignalPr(negTrack.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } + } + } + } + } /// process with TrackQA + PROCESS_SWITCH(TreeWriterTpcV0, processWithTrQAWithCorrecteddEdx, "Standard V0 Samples with Track QA for PID with corrected dEdx", false); + + void processDummy(Colls const&) {} + PROCESS_SWITCH(TreeWriterTpcV0, processDummy, "Dummy function", false); + +}; /// struct TreeWriterTpcV0 struct TreeWriterTPCTOF { Service ccdb; - using Trks = soa::Join; - using Coll = soa::Join; + using Trks = soa::Join; + using TrksWithDEdxCorrection = soa::Join; + using Colls = soa::Join; + using MyBCTable = soa::Join; /// Tables to be produced Produces rowTPCTOFTree; + Produces rowTPCTOFTreeWithdEdxTrkQA; + Produces rowTPCTOFTreeWithTrkQA; /// Configurables Configurable nClNorm{"nClNorm", 152., "Number of cluster normalization. Run 2: 159, Run 3 152"}; Configurable applyEvSel{"applyEvSel", 2, "Flag to apply rapidity cut: 0 -> no event selection, 1 -> Run 2 event selection, 2 -> Run 3 event selection"}; Configurable applyTrkSel{"applyTrkSel", 1, "Flag to apply track selection: 0 -> no track selection, 1 -> track selection"}; Configurable trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; + Configurable irSource{"irSource", "T0VTX", "Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"}; /// Triton Configurable maxMomTPCOnlyTr{"maxMomTPCOnlyTr", 1.5, "Maximum momentum for TPC only cut triton"}; Configurable maxMomHardCutOnlyTr{"maxMomHardCutOnlyTr", 50, "Maximum TPC inner momentum for triton"}; @@ -318,7 +932,7 @@ struct TreeWriterTPCTOF { double n = a + b / sqrts; double T = c + d / sqrts; double p0 = n * T; - double result = pow((1. + mt / p0), -n); + double result = std::pow((1. + mt / p0), -n); return result; }; @@ -340,11 +954,12 @@ struct TreeWriterTPCTOF { }; /// Function to fill trees - template + template void fillSkimmedTPCTOFTable(T const& track, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float dEdxExp, const o2::track::PID::ID id, int runnumber, double dwnSmplFactor, double hadronicRate) { const double ncl = track.tpcNClsFound(); + const double nclPID = track.tpcNClsFindableMinusPID(); const double p = track.tpcInnerParam(); const double mass = o2::track::pid_constants::sMasses[id]; const double bg = p / mass; @@ -354,7 +969,13 @@ struct TreeWriterTPCTOF { const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); if (pseudoRndm < dwnSmplFactor) { - rowTPCTOFTree(track.tpcSignal(), + float usedEdx; + if constexpr (doCorrectdEdx) { + usedEdx = track.tpcSignalCorrected(); + } else { + usedEdx = track.tpcSignal(); + } + rowTPCTOFTree(usedEdx, 1. / dEdxExp, track.tpcInnerParam(), track.tgl(), @@ -366,6 +987,7 @@ struct TreeWriterTPCTOF { bg, multTPC / 11000., std::sqrt(nClNorm / ncl), + nclPID, id, nSigmaTPC, nSigmaTOF, @@ -375,6 +997,109 @@ struct TreeWriterTPCTOF { hadronicRate); } }; + template + void fillSkimmedTPCTOFTableWithdEdxTrkQA(T const& track, TQA const& trackQA, bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, int runnumber, double dwnSmplFactor, double hadronicRate) + { + + const double ncl = track.tpcNClsFound(); + const double nclPID = track.tpcNClsFindableMinusPID(); + const double p = track.tpcInnerParam(); + const double mass = o2::track::pid_constants::sMasses[id]; + const double bg = p / mass; + const int multTPC = collision.multTPC(); + auto trackocc = collision.trackOccupancyInTimeRange(); + auto ft0occ = collision.ft0cOccupancyInTimeRange(); + + const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); + if (pseudoRndm < dwnSmplFactor) { + float usedEdx; + if constexpr (doCorrectdEdx) { + usedEdx = track.tpcSignalCorrected(); + } else { + usedEdx = track.tpcSignal(); + } + rowTPCTOFTreeWithdEdxTrkQA(usedEdx, + 1. / dEdxExp, + track.tpcInnerParam(), + track.tgl(), + track.signed1Pt(), + track.eta(), + track.phi(), + track.y(), + mass, + bg, + multTPC / 11000., + std::sqrt(nClNorm / ncl), + nclPID, + id, + nSigmaTPC, + nSigmaTOF, + nSigmaITS, + runnumber, + trackocc, + ft0occ, + hadronicRate, + existTrkQA ? trackQA.tpcdEdxNorm() : -999); + } + }; + /// Function to fill trees + template + void fillSkimmedTPCTOFTableWithTrkQA(T const& track, TQA const& trackQA, bool existTrkQA, C const& collision, const float nSigmaTPC, const float nSigmaTOF, const float nSigmaITS, const float dEdxExp, const o2::track::PID::ID id, int runnumber, double dwnSmplFactor, double hadronicRate, int bcGlobalIndex, int bcTimeFrameId, int bcBcInTimeFrame) + { + + const double ncl = track.tpcNClsFound(); + const double nclPID = track.tpcNClsFindableMinusPID(); + const double p = track.tpcInnerParam(); + const double mass = o2::track::pid_constants::sMasses[id]; + const double bg = p / mass; + const int multTPC = collision.multTPC(); + auto trackocc = collision.trackOccupancyInTimeRange(); + auto ft0occ = collision.ft0cOccupancyInTimeRange(); + + const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); + if (pseudoRndm < dwnSmplFactor) { + float usedEdx; + if constexpr (doCorrectdEdx) { + usedEdx = track.tpcSignalCorrected(); + } else { + usedEdx = track.tpcSignal(); + } + rowTPCTOFTreeWithTrkQA(usedEdx, + 1. / dEdxExp, + track.tpcInnerParam(), + track.tgl(), + track.signed1Pt(), + track.eta(), + track.phi(), + track.y(), + mass, + bg, + multTPC / 11000., + std::sqrt(nClNorm / ncl), + nclPID, + id, + nSigmaTPC, + nSigmaTOF, + nSigmaITS, + runnumber, + trackocc, + ft0occ, + hadronicRate, + bcGlobalIndex, + bcTimeFrameId, + bcBcInTimeFrame, + existTrkQA ? trackQA.tpcClusterByteMask() : -999, + existTrkQA ? trackQA.tpcdEdxMax0R() : -999, + existTrkQA ? trackQA.tpcdEdxMax1R() : -999, + existTrkQA ? trackQA.tpcdEdxMax2R() : -999, + existTrkQA ? trackQA.tpcdEdxMax3R() : -999, + existTrkQA ? trackQA.tpcdEdxTot0R() : -999, + existTrkQA ? trackQA.tpcdEdxTot1R() : -999, + existTrkQA ? trackQA.tpcdEdxTot2R() : -999, + existTrkQA ? trackQA.tpcdEdxTot3R() : -999, + existTrkQA ? trackQA.tpcdEdxNorm() : -999); + } + }; /// Event selection template @@ -399,16 +1124,15 @@ struct TreeWriterTPCTOF { ccdb->setFatalWhenNull(false); } - void process(Coll::iterator const& collision, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) + void processStandard(Colls::iterator const& collision, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) { /// Check event selection if (!isEventSelected(collision, tracks)) { return; } - auto bc = collision.bc_as(); const int runnumber = bc.runNumber(); - float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, "ZNC hadronic") * 1.e-3; + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; rowTPCTOFTree.reserve(tracks.size()); for (auto const& trk : tracks) { @@ -443,9 +1167,379 @@ struct TreeWriterTPCTOF { fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); } } /// Loop tracks - } /// process -}; /// struct TreeWriterTPCTOF + } /// process + PROCESS_SWITCH(TreeWriterTPCTOF, processStandard, "Standard Samples for PID", true); + + void processStandard2(Colls::iterator const& collision, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) + { + /// Check event selection + if (!isEventSelected(collision, tracks)) { + return; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + + rowTPCTOFTree.reserve(tracks.size()); + for (auto const& trk : tracks) { + /// Fill tree for tritons/* */ + if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() <= maxMomTPCOnlyTr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPCOnlyTr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignalCorrected()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() > maxMomTPCOnlyTr && std::abs(trk.tofNSigmaTr()) < nSigmaTOF_TPCTOF_Tr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPC_TPCTOF_Tr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignalCorrected()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate); + } + /// Fill tree for deuterons + if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() <= maxMomTPCOnlyDe && std::abs(trk.tpcNSigmaDe()) < nSigmaTPCOnlyDe && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignalCorrected()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() > maxMomTPCOnlyDe && std::abs(trk.tofNSigmaDe()) < nSigmaTOF_TPCTOF_De && std::abs(trk.tpcNSigmaDe()) < nSigmaTPC_TPCTOF_De && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignalCorrected()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate); + } + /// Fill tree for protons + if (trk.tpcInnerParam() <= maxMomTPCOnlyPr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPCOnlyPr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPr && std::abs(trk.tofNSigmaPr()) < nSigmaTOF_TPCTOF_Pr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPC_TPCTOF_Pr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } + /// Fill tree for kaons + if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() <= maxMomTPCOnlyKa && std::abs(trk.tpcNSigmaKa()) < nSigmaTPCOnlyKa && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignalCorrected()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() > maxMomTPCOnlyKa && std::abs(trk.tofNSigmaKa()) < nSigmaTOF_TPCTOF_Ka && std::abs(trk.tpcNSigmaKa()) < nSigmaTPC_TPCTOF_Ka && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignalCorrected()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate); + } + /// Fill tree pions + if (trk.tpcInnerParam() <= maxMomTPCOnlyPi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPCOnlyPi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPi && std::abs(trk.tofNSigmaPi()) < nSigmaTOF_TPCTOF_Pi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPC_TPCTOF_Pi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTable(trk, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + } /// Loop tracks + } /// process + PROCESS_SWITCH(TreeWriterTPCTOF, processStandard2, "Standard Samples for PID with corrected dEdx", false); + + Preslice perCollisionTracks = aod::track::collisionId; + void processWithdEdxTrQA(Colls const& collisions, Trks const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) + { + std::vector labelTrack2TrackQA; + labelTrack2TrackQA.clear(); + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + int64_t trackId = trackQA.trackId(); + int64_t trackQAIndex = trackQA.globalIndex(); + labelTrack2TrackQA[trackId] = trackQAIndex; + } + for (const auto& collision : collisions) { + auto tracks = myTracks.sliceBy(perCollisionTracks, collision.globalIndex()); + auto tracksWithITSPid = soa::Attach(tracks); + /// Check event selection + if (!isEventSelected(collision, tracks)) { + continue; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + rowTPCTOFTreeWithTrkQA.reserve(tracks.size()); + for (auto const& trk : tracksWithITSPid) { + if (!((trackSelection == 0) || + ((trackSelection == 1) && trk.isGlobalTrack()) || + ((trackSelection == 2) && trk.isGlobalTrackWoPtEta()) || + ((trackSelection == 3) && trk.isGlobalTrackWoDCA()) || + ((trackSelection == 4) && trk.isQualityTrack()) || + ((trackSelection == 5) && trk.isInAcceptanceTrack()))) { + continue; + } + // get the corresponding trackQA using labelTracks2TracKQA and get variables of interest + aod::TracksQA trackQA; + bool existTrkQA; + if (labelTrack2TrackQA[trk.globalIndex()] != -1) { + trackQA = tracksQA.iteratorAt(labelTrack2TrackQA[trk.globalIndex()]); + existTrkQA = true; + } else { + trackQA = tracksQA.iteratorAt(0); + existTrkQA = false; + } + /// Fill tree for tritons + if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() <= maxMomTPCOnlyTr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPCOnlyTr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.itsNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignal()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() > maxMomTPCOnlyTr && std::abs(trk.tofNSigmaTr()) < nSigmaTOF_TPCTOF_Tr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPC_TPCTOF_Tr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.itsNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignal()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate); + } + /// Fill tree for deuterons + if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() <= maxMomTPCOnlyDe && std::abs(trk.tpcNSigmaDe()) < nSigmaTPCOnlyDe && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignal()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() > maxMomTPCOnlyDe && std::abs(trk.tofNSigmaDe()) < nSigmaTOF_TPCTOF_De && std::abs(trk.tpcNSigmaDe()) < nSigmaTPC_TPCTOF_De && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignal()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate); + } + /// Fill tree for protons + if (trk.tpcInnerParam() <= maxMomTPCOnlyPr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPCOnlyPr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPr && std::abs(trk.tofNSigmaPr()) < nSigmaTOF_TPCTOF_Pr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPC_TPCTOF_Pr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } + /// Fill tree for kaons + if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() <= maxMomTPCOnlyKa && std::abs(trk.tpcNSigmaKa()) < nSigmaTPCOnlyKa && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignal()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() > maxMomTPCOnlyKa && std::abs(trk.tofNSigmaKa()) < nSigmaTOF_TPCTOF_Ka && std::abs(trk.tpcNSigmaKa()) < nSigmaTPC_TPCTOF_Ka && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignal()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate); + } + /// Fill tree pions + if (trk.tpcInnerParam() <= maxMomTPCOnlyPi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPCOnlyPi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPi && std::abs(trk.tofNSigmaPi()) < nSigmaTOF_TPCTOF_Pi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPC_TPCTOF_Pi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + } /// Loop tracks + } + } /// process + PROCESS_SWITCH(TreeWriterTPCTOF, processWithdEdxTrQA, "Samples for PID with TrackQA info", false); + + Preslice perCollisionTracksWithCorrecteddEdx = aod::track::collisionId; + void processWithdEdxTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, aod::BCsWithTimestamps const&, aod::TracksQAVersion const& tracksQA) + { + std::vector labelTrack2TrackQA; + labelTrack2TrackQA.clear(); + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + int64_t trackId = trackQA.trackId(); + int64_t trackQAIndex = trackQA.globalIndex(); + labelTrack2TrackQA[trackId] = trackQAIndex; + } + for (const auto& collision : collisions) { + auto tracks = myTracks.sliceBy(perCollisionTracksWithCorrecteddEdx, collision.globalIndex()); + auto tracksWithITSPid = soa::Attach(tracks); + /// Check event selection + if (!isEventSelected(collision, tracks)) { + continue; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + rowTPCTOFTreeWithTrkQA.reserve(tracks.size()); + for (auto const& trk : tracksWithITSPid) { + if (!((trackSelection == 0) || + ((trackSelection == 1) && trk.isGlobalTrack()) || + ((trackSelection == 2) && trk.isGlobalTrackWoPtEta()) || + ((trackSelection == 3) && trk.isGlobalTrackWoDCA()) || + ((trackSelection == 4) && trk.isQualityTrack()) || + ((trackSelection == 5) && trk.isInAcceptanceTrack()))) { + continue; + } + // get the corresponding trackQA using labelTracks2TracKQA and get variables of interest + aod::TracksQA trackQA; + bool existTrkQA; + if (labelTrack2TrackQA[trk.globalIndex()] != -1) { + trackQA = tracksQA.iteratorAt(labelTrack2TrackQA[trk.globalIndex()]); + existTrkQA = true; + } else { + trackQA = tracksQA.iteratorAt(0); + existTrkQA = false; + } + /// Fill tree for tritons + if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() <= maxMomTPCOnlyTr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPCOnlyTr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.itsNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignalCorrected()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() > maxMomTPCOnlyTr && std::abs(trk.tofNSigmaTr()) < nSigmaTOF_TPCTOF_Tr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPC_TPCTOF_Tr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.itsNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignalCorrected()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate); + } + /// Fill tree for deuterons + if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() <= maxMomTPCOnlyDe && std::abs(trk.tpcNSigmaDe()) < nSigmaTPCOnlyDe && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignalCorrected()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() > maxMomTPCOnlyDe && std::abs(trk.tofNSigmaDe()) < nSigmaTOF_TPCTOF_De && std::abs(trk.tpcNSigmaDe()) < nSigmaTPC_TPCTOF_De && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignalCorrected()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate); + } + /// Fill tree for protons + if (trk.tpcInnerParam() <= maxMomTPCOnlyPr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPCOnlyPr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPr && std::abs(trk.tofNSigmaPr()) < nSigmaTOF_TPCTOF_Pr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPC_TPCTOF_Pr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate); + } + /// Fill tree for kaons + if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() <= maxMomTPCOnlyKa && std::abs(trk.tpcNSigmaKa()) < nSigmaTPCOnlyKa && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignalCorrected()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() > maxMomTPCOnlyKa && std::abs(trk.tofNSigmaKa()) < nSigmaTOF_TPCTOF_Ka && std::abs(trk.tpcNSigmaKa()) < nSigmaTPC_TPCTOF_Ka && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignalCorrected()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate); + } + /// Fill tree pions + if (trk.tpcInnerParam() <= maxMomTPCOnlyPi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPCOnlyPi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPi && std::abs(trk.tofNSigmaPi()) < nSigmaTOF_TPCTOF_Pi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPC_TPCTOF_Pi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTableWithdEdxTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate); + } + } /// Loop tracks + } + } /// process + PROCESS_SWITCH(TreeWriterTPCTOF, processWithdEdxTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with corrected dEdx", false); + + void processWithTrQA(Colls const& collisions, Trks const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) + { + std::vector labelTrack2TrackQA; + labelTrack2TrackQA.clear(); + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + int64_t trackId = trackQA.trackId(); + int64_t trackQAIndex = trackQA.globalIndex(); + labelTrack2TrackQA[trackId] = trackQAIndex; + } + for (const auto& collision : collisions) { + auto tracks = myTracks.sliceBy(perCollisionTracks, collision.globalIndex()); + auto tracksWithITSPid = soa::Attach(tracks); + /// Check event selection + if (!isEventSelected(collision, tracks)) { + continue; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + const int bcGlobalIndex = bc.globalIndex(); + const int bcTimeFrameId = bc.tfId(); + const int bcBcInTimeFrame = bc.bcInTF(); + rowTPCTOFTreeWithTrkQA.reserve(tracks.size()); + for (auto const& trk : tracksWithITSPid) { + if (!((trackSelection == 0) || + ((trackSelection == 1) && trk.isGlobalTrack()) || + ((trackSelection == 2) && trk.isGlobalTrackWoPtEta()) || + ((trackSelection == 3) && trk.isGlobalTrackWoDCA()) || + ((trackSelection == 4) && trk.isQualityTrack()) || + ((trackSelection == 5) && trk.isInAcceptanceTrack()))) { + continue; + } + // get the corresponding trackQA using labelTracks2TracKQA and get variables of interest + aod::TracksQA trackQA; + bool existTrkQA; + if (labelTrack2TrackQA[trk.globalIndex()] != -1) { + trackQA = tracksQA.iteratorAt(labelTrack2TrackQA[trk.globalIndex()]); + existTrkQA = true; + } else { + trackQA = tracksQA.iteratorAt(0); + existTrkQA = false; + } + /// Fill tree for tritons + if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() <= maxMomTPCOnlyTr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPCOnlyTr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.itsNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignal()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() > maxMomTPCOnlyTr && std::abs(trk.tofNSigmaTr()) < nSigmaTOF_TPCTOF_Tr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPC_TPCTOF_Tr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.itsNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignal()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + /// Fill tree for deuterons + if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() <= maxMomTPCOnlyDe && std::abs(trk.tpcNSigmaDe()) < nSigmaTPCOnlyDe && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignal()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() > maxMomTPCOnlyDe && std::abs(trk.tofNSigmaDe()) < nSigmaTOF_TPCTOF_De && std::abs(trk.tpcNSigmaDe()) < nSigmaTPC_TPCTOF_De && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignal()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + /// Fill tree for protons + if (trk.tpcInnerParam() <= maxMomTPCOnlyPr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPCOnlyPr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPr && std::abs(trk.tofNSigmaPr()) < nSigmaTOF_TPCTOF_Pr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPC_TPCTOF_Pr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + /// Fill tree for kaons + if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() <= maxMomTPCOnlyKa && std::abs(trk.tpcNSigmaKa()) < nSigmaTPCOnlyKa && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignal()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() > maxMomTPCOnlyKa && std::abs(trk.tofNSigmaKa()) < nSigmaTOF_TPCTOF_Ka && std::abs(trk.tpcNSigmaKa()) < nSigmaTPC_TPCTOF_Ka && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignal()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + /// Fill tree pions + if (trk.tpcInnerParam() <= maxMomTPCOnlyPi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPCOnlyPi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPi && std::abs(trk.tofNSigmaPi()) < nSigmaTOF_TPCTOF_Pi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPC_TPCTOF_Pi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } /// Loop tracks + } + } /// process + PROCESS_SWITCH(TreeWriterTPCTOF, processWithTrQA, "Samples for PID with TrackQA info", false); + + void processWithTrQAWithCorrecteddEdx(Colls const& collisions, TrksWithDEdxCorrection const& myTracks, MyBCTable const&, aod::TracksQAVersion const& tracksQA) + { + std::vector labelTrack2TrackQA; + labelTrack2TrackQA.clear(); + labelTrack2TrackQA.resize(myTracks.size(), -1); + for (const auto& trackQA : tracksQA) { + int64_t trackId = trackQA.trackId(); + int64_t trackQAIndex = trackQA.globalIndex(); + labelTrack2TrackQA[trackId] = trackQAIndex; + } + for (const auto& collision : collisions) { + auto tracks = myTracks.sliceBy(perCollisionTracks, collision.globalIndex()); + auto tracksWithITSPid = soa::Attach(tracks); + /// Check event selection + if (!isEventSelected(collision, tracks)) { + continue; + } + auto bc = collision.bc_as(); + const int runnumber = bc.runNumber(); + float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3; + const int bcGlobalIndex = bc.globalIndex(); + const int bcTimeFrameId = bc.tfId(); + const int bcBcInTimeFrame = bc.bcInTF(); + rowTPCTOFTreeWithTrkQA.reserve(tracks.size()); + for (auto const& trk : tracksWithITSPid) { + if (!((trackSelection == 0) || + ((trackSelection == 1) && trk.isGlobalTrack()) || + ((trackSelection == 2) && trk.isGlobalTrackWoPtEta()) || + ((trackSelection == 3) && trk.isGlobalTrackWoDCA()) || + ((trackSelection == 4) && trk.isQualityTrack()) || + ((trackSelection == 5) && trk.isInAcceptanceTrack()))) { + continue; + } + // get the corresponding trackQA using labelTracks2TracKQA and get variables of interest + aod::TracksQA trackQA; + bool existTrkQA; + if (labelTrack2TrackQA[trk.globalIndex()] != -1) { + trackQA = tracksQA.iteratorAt(labelTrack2TrackQA[trk.globalIndex()]); + existTrkQA = true; + } else { + trackQA = tracksQA.iteratorAt(0); + existTrkQA = false; + } + /// Fill tree for tritons + if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() <= maxMomTPCOnlyTr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPCOnlyTr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.itsNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignalCorrected()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyTr && trk.tpcInnerParam() > maxMomTPCOnlyTr && std::abs(trk.tofNSigmaTr()) < nSigmaTOF_TPCTOF_Tr && std::abs(trk.tpcNSigmaTr()) < nSigmaTPC_TPCTOF_Tr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Triton])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaTr(), trk.tofNSigmaTr(), trk.itsNSigmaTr(), trk.tpcExpSignalTr(trk.tpcSignalCorrected()), o2::track::PID::Triton, runnumber, dwnSmplFactor_Tr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + /// Fill tree for deuterons + if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() <= maxMomTPCOnlyDe && std::abs(trk.tpcNSigmaDe()) < nSigmaTPCOnlyDe && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignalCorrected()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyDe && trk.tpcInnerParam() > maxMomTPCOnlyDe && std::abs(trk.tofNSigmaDe()) < nSigmaTOF_TPCTOF_De && std::abs(trk.tpcNSigmaDe()) < nSigmaTPC_TPCTOF_De && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Deuteron])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(trk.tpcSignalCorrected()), o2::track::PID::Deuteron, runnumber, dwnSmplFactor_De, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + /// Fill tree for protons + if (trk.tpcInnerParam() <= maxMomTPCOnlyPr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPCOnlyPr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPr && std::abs(trk.tofNSigmaPr()) < nSigmaTOF_TPCTOF_Pr && std::abs(trk.tpcNSigmaPr()) < nSigmaTPC_TPCTOF_Pr && downsampleTsalisCharged(trk.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(trk.tpcSignalCorrected()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + /// Fill tree for kaons + if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() <= maxMomTPCOnlyKa && std::abs(trk.tpcNSigmaKa()) < nSigmaTPCOnlyKa && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignalCorrected()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() < maxMomHardCutOnlyKa && trk.tpcInnerParam() > maxMomTPCOnlyKa && std::abs(trk.tofNSigmaKa()) < nSigmaTOF_TPCTOF_Ka && std::abs(trk.tpcNSigmaKa()) < nSigmaTPC_TPCTOF_Ka && downsampleTsalisCharged(trk.pt(), downsamplingTsalisKaons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Kaon])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaKa(), trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(trk.tpcSignalCorrected()), o2::track::PID::Kaon, runnumber, dwnSmplFactor_Ka, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + /// Fill tree pions + if (trk.tpcInnerParam() <= maxMomTPCOnlyPi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPCOnlyPi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } else if (trk.tpcInnerParam() > maxMomTPCOnlyPi && std::abs(trk.tofNSigmaPi()) < nSigmaTOF_TPCTOF_Pi && std::abs(trk.tpcNSigmaPi()) < nSigmaTPC_TPCTOF_Pi && downsampleTsalisCharged(trk.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + fillSkimmedTPCTOFTableWithTrkQA(trk, trackQA, existTrkQA, collision, trk.tpcNSigmaPi(), trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(trk.tpcSignalCorrected()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame); + } + } /// Loop tracks + } + } /// process + PROCESS_SWITCH(TreeWriterTPCTOF, processWithTrQAWithCorrecteddEdx, "Samples for PID with TrackQA info with correced dEdx", false); + + void processDummy(Colls const&) {} + PROCESS_SWITCH(TreeWriterTPCTOF, processDummy, "Dummy function", false); +}; /// struct TreeWriterTPCTOF WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { auto workflow = WorkflowSpec{adaptAnalysisTask(cfgc)}; diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.h b/DPG/Tasks/TPC/tpcSkimsTableCreator.h index 7c770602efd..decb3a9de60 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.h @@ -13,6 +13,8 @@ /// \author Annalena Kalteyer /// \author Christian Sonnabend /// \author Jeremy Wilkinson +/// \author Ana Marin +/// \brief Creates clean samples of particles for PID fits #ifndef DPG_TASKS_TPC_TPCSKIMSTABLECREATOR_H_ #define DPG_TASKS_TPC_TPCSKIMSTABLECREATOR_H_ @@ -31,9 +33,11 @@ DECLARE_SOA_COLUMN(Mass, mass, float); DECLARE_SOA_COLUMN(BetaGamma, bg, float); DECLARE_SOA_COLUMN(NormMultTPC, normMultTPC, float); DECLARE_SOA_COLUMN(NormNClustersTPC, normNClustersTPC, float); +DECLARE_SOA_COLUMN(NormNClustersTPCPID, normNClustersTPCPID, float); DECLARE_SOA_COLUMN(PidIndex, pidIndexTPC, uint8_t); DECLARE_SOA_COLUMN(NSigTPC, nsigTPC, float); DECLARE_SOA_COLUMN(NSigTOF, nsigTOF, float); +DECLARE_SOA_COLUMN(NSigITS, nsigITS, float); DECLARE_SOA_COLUMN(AlphaV0, alphaV0, float); DECLARE_SOA_COLUMN(QtV0, qtV0, float); DECLARE_SOA_COLUMN(CosPAV0, cosPAV0, float); @@ -44,6 +48,9 @@ DECLARE_SOA_COLUMN(RunNumber, runNumber, int); DECLARE_SOA_COLUMN(TrackOcc, trackOcc, float); DECLARE_SOA_COLUMN(Ft0Occ, ft0Occ, float); DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, float); +DECLARE_SOA_COLUMN(BcGlobalIndex, bcGlobalIndex, int); +DECLARE_SOA_COLUMN(BcTimeFrameId, bcTimeFrameId, int); +DECLARE_SOA_COLUMN(BcBcInTimeFrame, bcBcInTimeFrame, int); } // namespace tpcskims DECLARE_SOA_TABLE(SkimmedTPCV0Tree, "AOD", "TPCSKIMV0TREE", o2::aod::track::TPCSignal, @@ -58,6 +65,7 @@ DECLARE_SOA_TABLE(SkimmedTPCV0Tree, "AOD", "TPCSKIMV0TREE", tpcskims::BetaGamma, tpcskims::NormMultTPC, tpcskims::NormNClustersTPC, + tpcskims::NormNClustersTPCPID, tpcskims::PidIndex, tpcskims::NSigTPC, tpcskims::NSigTOF, @@ -71,6 +79,74 @@ DECLARE_SOA_TABLE(SkimmedTPCV0Tree, "AOD", "TPCSKIMV0TREE", tpcskims::TrackOcc, tpcskims::Ft0Occ, tpcskims::HadronicRate); +DECLARE_SOA_TABLE(SkimmedTPCV0TreeWithdEdxTrkQA, "AOD", "TPCSKIMV0WdE", + o2::aod::track::TPCSignal, + tpcskims::InvDeDxExpTPC, + o2::aod::track::TPCInnerParam, + o2::aod::track::Tgl, + o2::aod::track::Signed1Pt, + o2::aod::track::Eta, + o2::aod::track::Phi, + o2::aod::track::Y, + tpcskims::Mass, + tpcskims::BetaGamma, + tpcskims::NormMultTPC, + tpcskims::NormNClustersTPC, + tpcskims::NormNClustersTPCPID, + tpcskims::PidIndex, + tpcskims::NSigTPC, + tpcskims::NSigTOF, + tpcskims::AlphaV0, + tpcskims::QtV0, + tpcskims::CosPAV0, + tpcskims::PtV0, + tpcskims::RadiusV0, + tpcskims::GammaPsiPair, + tpcskims::RunNumber, + tpcskims::TrackOcc, + tpcskims::Ft0Occ, + tpcskims::HadronicRate, + o2::aod::trackqa::TPCdEdxNorm); +DECLARE_SOA_TABLE(SkimmedTPCV0TreeWithTrkQA, "AOD", "TPCSKIMV0WQA", + o2::aod::track::TPCSignal, + tpcskims::InvDeDxExpTPC, + o2::aod::track::TPCInnerParam, + o2::aod::track::Tgl, + o2::aod::track::Signed1Pt, + o2::aod::track::Eta, + o2::aod::track::Phi, + o2::aod::track::Y, + tpcskims::Mass, + tpcskims::BetaGamma, + tpcskims::NormMultTPC, + tpcskims::NormNClustersTPC, + tpcskims::NormNClustersTPCPID, + tpcskims::PidIndex, + tpcskims::NSigTPC, + tpcskims::NSigTOF, + tpcskims::AlphaV0, + tpcskims::QtV0, + tpcskims::CosPAV0, + tpcskims::PtV0, + tpcskims::RadiusV0, + tpcskims::GammaPsiPair, + tpcskims::RunNumber, + tpcskims::TrackOcc, + tpcskims::Ft0Occ, + tpcskims::HadronicRate, + tpcskims::BcGlobalIndex, + tpcskims::BcTimeFrameId, + tpcskims::BcBcInTimeFrame, + o2::aod::trackqa::TPCClusterByteMask, + o2::aod::trackqa::TPCdEdxMax0R, + o2::aod::trackqa::TPCdEdxMax1R, + o2::aod::trackqa::TPCdEdxMax2R, + o2::aod::trackqa::TPCdEdxMax3R, + o2::aod::trackqa::TPCdEdxTot0R, + o2::aod::trackqa::TPCdEdxTot1R, + o2::aod::trackqa::TPCdEdxTot2R, + o2::aod::trackqa::TPCdEdxTot3R, + o2::aod::trackqa::TPCdEdxNorm); DECLARE_SOA_TABLE(SkimmedTPCTOFTree, "AOD", "TPCTOFSKIMTREE", o2::aod::track::TPCSignal, @@ -85,6 +161,7 @@ DECLARE_SOA_TABLE(SkimmedTPCTOFTree, "AOD", "TPCTOFSKIMTREE", tpcskims::BetaGamma, tpcskims::NormMultTPC, tpcskims::NormNClustersTPC, + tpcskims::NormNClustersTPCPID, tpcskims::PidIndex, tpcskims::NSigTPC, tpcskims::NSigTOF, @@ -92,5 +169,64 @@ DECLARE_SOA_TABLE(SkimmedTPCTOFTree, "AOD", "TPCTOFSKIMTREE", tpcskims::TrackOcc, tpcskims::Ft0Occ, tpcskims::HadronicRate); + +DECLARE_SOA_TABLE(SkimmedTPCTOFTreeWithdEdxTrkQA, "AOD", "TPCTOFSKIMWdE", + o2::aod::track::TPCSignal, + tpcskims::InvDeDxExpTPC, + o2::aod::track::TPCInnerParam, + o2::aod::track::Tgl, + o2::aod::track::Signed1Pt, + o2::aod::track::Eta, + o2::aod::track::Phi, + o2::aod::track::Y, + tpcskims::Mass, + tpcskims::BetaGamma, + tpcskims::NormMultTPC, + tpcskims::NormNClustersTPC, + tpcskims::NormNClustersTPCPID, + tpcskims::PidIndex, + tpcskims::NSigTPC, + tpcskims::NSigTOF, + tpcskims::NSigITS, + tpcskims::RunNumber, + tpcskims::TrackOcc, + tpcskims::Ft0Occ, + tpcskims::HadronicRate, + o2::aod::trackqa::TPCdEdxNorm); +DECLARE_SOA_TABLE(SkimmedTPCTOFTreeWithTrkQA, "AOD", "TPCTOFSKIMWQA", + o2::aod::track::TPCSignal, + tpcskims::InvDeDxExpTPC, + o2::aod::track::TPCInnerParam, + o2::aod::track::Tgl, + o2::aod::track::Signed1Pt, + o2::aod::track::Eta, + o2::aod::track::Phi, + o2::aod::track::Y, + tpcskims::Mass, + tpcskims::BetaGamma, + tpcskims::NormMultTPC, + tpcskims::NormNClustersTPC, + tpcskims::NormNClustersTPCPID, + tpcskims::PidIndex, + tpcskims::NSigTPC, + tpcskims::NSigTOF, + tpcskims::NSigITS, + tpcskims::RunNumber, + tpcskims::TrackOcc, + tpcskims::Ft0Occ, + tpcskims::HadronicRate, + tpcskims::BcGlobalIndex, + tpcskims::BcTimeFrameId, + tpcskims::BcBcInTimeFrame, + o2::aod::trackqa::TPCClusterByteMask, + o2::aod::trackqa::TPCdEdxMax0R, + o2::aod::trackqa::TPCdEdxMax1R, + o2::aod::trackqa::TPCdEdxMax2R, + o2::aod::trackqa::TPCdEdxMax3R, + o2::aod::trackqa::TPCdEdxTot0R, + o2::aod::trackqa::TPCdEdxTot1R, + o2::aod::trackqa::TPCdEdxTot2R, + o2::aod::trackqa::TPCdEdxTot3R, + o2::aod::trackqa::TPCdEdxNorm); } // namespace o2::aod #endif // DPG_TASKS_TPC_TPCSKIMSTABLECREATOR_H_ diff --git a/EventFiltering/CMakeLists.txt b/EventFiltering/CMakeLists.txt index 31cd58f40ed..554431848c9 100644 --- a/EventFiltering/CMakeLists.txt +++ b/EventFiltering/CMakeLists.txt @@ -21,7 +21,7 @@ o2physics_add_dpl_workflow(selected-bc-range-task o2physics_add_dpl_workflow(nuclei-filter SOURCES PWGLF/nucleiFilter.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::TOFBase COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(diffraction-filter @@ -54,7 +54,7 @@ o2physics_add_dpl_workflow(hf-filter-prepare-ml-samples o2physics_add_dpl_workflow(cf-filter SOURCES PWGCF/CFFilterAll.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore KFParticle::KFParticle O2::ReconstructionDataFormats O2::DetectorsBase COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(cf-filter-qa @@ -84,7 +84,7 @@ o2physics_add_dpl_workflow(fje-filter o2physics_add_dpl_workflow(lf-strangeness-filter SOURCES PWGLF/strangenessFilter.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsBase + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore KFParticle::KFParticle O2::ReconstructionDataFormats O2::DetectorsBase COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(mult-filter @@ -102,8 +102,18 @@ o2physics_add_dpl_workflow(em-photon-filter-qc PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase O2Physics::PWGEMPhotonMesonCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(heavy-neutral-meson-filter + SOURCES PWGEM/HeavyNeutralMesonFilter.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(lf-f1proton-filter SOURCES PWGLF/filterf1proton.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore KFParticle::KFParticle O2::DetectorsBase + COMPONENT_NAME Analysis) + + o2physics_add_dpl_workflow(lf-doublephi-filter + SOURCES PWGLF/filterdoublephi.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase COMPONENT_NAME Analysis) @@ -114,4 +124,4 @@ o2physics_add_library(EventFilteringUtils o2physics_target_root_dictionary(EventFilteringUtils HEADERS ZorroHelper.h ZorroSummary.h - LINKDEF EventFilteringUtilsLinkDef.h) \ No newline at end of file + LINKDEF EventFilteringUtilsLinkDef.h) diff --git a/EventFiltering/PWGCF/CFFilterAll.cxx b/EventFiltering/PWGCF/CFFilterAll.cxx index 80832e661b1..efc7625b215 100644 --- a/EventFiltering/PWGCF/CFFilterAll.cxx +++ b/EventFiltering/PWGCF/CFFilterAll.cxx @@ -12,1277 +12,1198 @@ /// \file CFFilterAll.cxx /// \brief Selection of events with triplets and pairs for femtoscopic studies /// -/// \author Laura Serksnyte, TU München, laura.serksnyte@cern.ch; Anton Riedel, TU München, anton.riedel@cern.ch - -#include -#include -#include -#include -#include -#include -#include -#include +/// \author Laura Serksnyte, TU München, laura.serksnyte@cern.ch; Anton Riedel, TU München, anton.riedel@cern.ch; Maximilian Korwieser, TU Munich, maximilian.korwieser@cern.ch + #include +#include #include "../filterTables.h" -#include "Framework/ASoAHelpers.h" +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DCAFitter/DCAFitterN.h" +#include "DetectorsBase/Propagator.h" + +#include "fairlogger/Logger.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/RecoDecay.h" + #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" -#include "CommonConstants/MathConstants.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "DataFormatsTPC/BetheBlochAleph.h" -#include "CCDB/BasicCCDBManager.h" -#include "CCDB/CcdbApi.h" + +#include "PWGLF/Utils/strangenessBuilderHelper.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector4D.h" +#include "TMath.h" using namespace o2; +using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; -namespace CFTrigger +namespace cf_trigger { // enums -enum CFThreeBodyTriggers { kPPP, - kPPL, - kPLL, - kLLL, - kPPPhi, - kNThreeBodyTriggers }; -enum CFTwoBodyTriggers { kPD, - kLD, - kNTwoBodyTriggers +enum CFTriggers { + kPPP, + kPPL, + kPLL, + kLLL, + kPPPhi, + kPPRho, + kPD, + kLD, + kPhiD, + kRhoD, + kNTriggers }; -enum ParticleSpecies { - kProton, - kDeuteron, - kLambda, - kNParticleSpecies -}; -enum V0Daughters { - kDaughPion, - kDaughProton, - kNV0Daughters + +// variables for track selection +const std::vector trackNames{"Pion", "Kaon", "Proton", "Deuteron"}; +const uint32_t nTrackNames = 4; + +const std::vector trackSelectionNames{"AbsEtaMax", "TpcClusterMin", "TpcRowMin", "TpcCrossedOverFoundMin", "TpcSharedMax", "TpcFracSharedMax", "ItsClusterMin", "ItsIbClusterMin", "AbsDcaXyMax", "AbsDcaZMax", "Chi2TpcMax", "Chi2ItsMax"}; +const uint32_t nTrackSelectionNames = 12; + +const float trackSelectionTable[nTrackNames][nTrackSelectionNames] = { + {0.85, 90, 80, 0.83, 160, 1, 1, 0, 0.15, 0.15, 99, 99}, // Pion + {0.85, 90, 80, 0.83, 160, 1, 1, 0, 0.15, 0.15, 99, 99}, // Kaon + {0.85, 90, 80, 0.83, 160, 1, 1, 0, 0.15, 0.15, 99, 99}, // Proton + {0.85, 90, 80, 0.83, 160, 1, 1, 0, 0.15, 0.15, 99, 99}, // Deuteron }; -enum ParticleRejection { kRejProton, - kRejPion, - kRejElectron, - kNParticleRejection + +const std::vector pidSelectionNames{"ItsMin", "ItsMax", "TpcMin", "TpcMax", "TpcTofMax"}; +const uint32_t nPidSelectionNames = 5; + +const float pidSelectionTable[nTrackNames][nPidSelectionNames] = { + {-99, 99, -4, 4, 4}, // Pion + {-99, 99, -4, 4, 4}, // Kaon + {-99, 99, -4, 4, 4}, // Proton + {-3.5, 3.5, -3.5, 3.5, 3.5}, // Deuteron }; -enum PIDLimits { kTPCMin, - kTPCMax, - kTOFMin, - kTOFMax, - kTPCTOF, - kNPIDLimits + +const std::vector momentumSelectionNames{"PtMin", "PtMax", "PThres", "UseInnerParam"}; +const uint32_t nMomentumSelectionNames = 4; + +const float momentumSelectionTable[nTrackNames][nMomentumSelectionNames] = { + {0, 6, 0.4, -1}, // Pion + {0, 6, 0.5, -1}, // Kaon + {0.3, 6, 0.75, -1}, // Proton + {0.4, 2, 1.2, -1}, // Deuteron }; -// For configurable tables -static const std::vector CFTriggerNamesALL{"ppp", "ppL", "pLL", "LLL", "ppPhi", "pd", "Ld"}; -static const std::vector SpeciesNameAll{"Proton", "Deuteron", "Lambda"}; -static const std::vector SpeciesName{"Proton", "Deuteron"}; -static const std::vector SpeciesNameAnti{"AntiProton", "AntiDeuteron"}; -static const std::vector SpeciesV0DaughterName{"Pion", "Proton"}; -static const std::vector SpeciesRejectionName{"Proton", "Pion", "Electron"}; -static const std::vector TPCCutName{"TPC min", "TPC max"}; -static const std::vector SpeciesMinTPCClustersName{"Proton", "Deuteron"}; -static const std::vector SpeciesAvgTPCTOFName{"Proton", "AntiProton", "Deuteron", "AntiDeuteron"}; -static const std::vector TPCTOFAvgName{"TPC Avg", "TOF Avg"}; -static const std::vector PidCutsName{"TPC min", "TPC max", "TOF min", "TOF max", "TPCTOF max"}; -static const std::vector PtCutsName{"Pt min (particle)", "Pt max (particle)", "Pt min (antiparticle)", "Pt max (antiparticle)", "P thres"}; -static const std::vector MomCorCutsName{"Momemtum Correlation min", "Momemtum Correlation max"}; -static const std::vector PIDForTrackingName{"Switch", "Momemtum Threshold"}; -static const std::vector ThreeBodyFilterNames{"PPP", "PPL", "PLL", "LLL", "PPPhi"}; -static const std::vector TwoBodyFilterNames{"PD", "LD"}; -static const std::vector ParticleNames{"PPP", "aPaPaP", "PPL", "aPaPaL", "PLL", "aPaLaL", "LLL", "aLaLaL", "PPPhi", "aPaPPhi", "PD", "aPaD", "LD", "aLaD"}; - -static const int nPidRejection = 2; -static const int nTracks = 2; -static const int nPidAvg = 4; -static const int nPidCutsDaughers = 2; -static const int nPtCuts = 5; -static const int nAllTriggers = 7; -static const int nTriggerAllNames = 14; -static const int nMomCorCuts = 2; - -static const float pidcutsTable[nTracks][kNPIDLimits]{ - {-6.f, 6.f, -6.f, 6.f, 6.f}, - {-6.f, 6.f, -99.f, 99.f, 99.f}}; -static const float pidcutsTableAnti[nTracks][kNPIDLimits]{ - {-6.f, 6.f, -6.f, 6.f, 6.f}, - {-6.f, 6.f, -99.f, 99.f, 99.f}}; -static const float pidRejectionTable[kNParticleRejection][nPidRejection]{ - {-2.f, 2.f}, - {-2.f, 2.f}}; -static const double pidTPCTOFAvgTable[nPidAvg][nTracks]{ - {0.f, 0.f}, - {0.f, 0.f}, - {0.f, 0.f}, - {0.f, 0.f}}; -static const float pidcutsV0DaughterTable[kNV0Daughters][nPidCutsDaughers]{ - {-6.f, 6.f}, - {-6.f, 6.f}}; -static const float ptcutsTable[kNParticleRejection][nPtCuts]{ - {0.35f, 6.f, 0.35f, 6.0f, 0.75f}, - {0.35f, 1.6f, 0.35f, 1.6f, 99.f}, - {0.f, 6.f, 0.f, 6.f, 99.f}}; -static const float NClustersMin[1][nTracks]{ - {60.0f, 60.0f}}; -static const float MomCorLimits[2][nMomCorCuts] = - {{-99, 99}, - {-99, 99}}; -static const float PIDForTrackingTable[2][nTracks]{ - {-1, 0.75}, - {-1, 1.2}}; -static const float ITSCutsTable[1][nTracks] = { - {1, 1}}; - -static const float triggerSwitches[1][nAllTriggers]{ - {1, 1, 1, 1, 1, 1, 1}}; - -static const float Q3Limits[1][kNThreeBodyTriggers]{ - {0.6f, 0.6f, 0.6f, 0.6f, 0.6f}}; - -static const float KstarLimits[1][kNTwoBodyTriggers]{ - {1.2f, 1.2f}}; - -static const float Downsample[2][nTriggerAllNames]{ - {-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1, -1., -1.}, - {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}; - -} // namespace CFTrigger - -namespace o2::aod -{ -using FemtoFullCollision = - soa::Join::iterator; +// variables for triggers +const std::vector filterNames{"PPP", "PPL", "PLL", "LLL", "PPPhi", "PPRho", "PD", "LD", "PhiD", "RhoD"}; +const uint32_t nFilterNames = 10; -using FemtoFullTracks = - soa::Join; -} // namespace o2::aod +const std::vector switches{"Switch"}; +const uint32_t nSwitches = 1; -struct CFFilter { +const float filterTable[nSwitches][nFilterNames]{ + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; - Produces tags; +const std::vector limitNames{"Tight Limit", "Loose Limit"}; +const uint32_t nLimitNames = 2; - Service ccdb; - o2::ccdb::CcdbApi ccdbApi; +const float limitTable[nLimitNames][nFilterNames]{ + {0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.5f, 0.5f, 0.5f, 0.5f}, + {1.4f, 1.4f, 1.4f, 1.4f, 1.4f, 1.4f, 1.0f, 1.0f, 1.0f, 1.0f}}; + +using FullCollisions = soa::Join; +using FullCollision = FullCollisions::iterator; + +using FullTracks = soa::Join; - Configurable ConfRngSeed{"ConfRngSeed", 69, "Seed for downsampling"}; - TRandom3* rng; +} // namespace cf_trigger + +struct CFFilterAll { + + Produces tags; // Configs for events - Configurable ConfIsRun3{ - "ConfIsRun3", - true, - "Is Run3"}; - - Configurable ConfEvtSelectZvtx{ - "ConfEvtSelectZvtx", - true, - "Event selection includes max. z-Vertex"}; - Configurable ConfEvtZvtx{"ConfEvtZvtx", - 10.f, - "Evt sel: Max. z-Vertex (cm)"}; - Configurable ConfEvtOfflineCheck{ - "ConfEvtOfflineCheck", - false, - "Evt sel: check for offline selection"}; - Configurable ConfEvtTimeFrameBorderCheck{ - "ConfEvtTimeFrameBorderCheck", - true, - "Evt sel: check for offline selection"}; - Configurable ConfAutocorRejection{ - "ConfAutocorRejection", - true, - "Rejection autocorrelation pL pairs"}; + struct : ConfigurableGroup { + std::string prefix = "EventSel"; + Configurable zvtx{"zvtx", 10.f, "Max. z-Vertex (cm)"}; + Configurable eventSel{"eventSel", true, "Use sel8"}; + } EventSelection; // Configs for tracks - Configurable ConfDeuteronThPVMom{ - "ConfDeuteronThPVMom", - false, - "True: use momentum at PV instead of TPCinnerparameter for threshold"}; - - Configurable ConfUseManualPIDproton{ - "ConfUseManualPIDproton", - false, - "True: use home-made PID solution for proton "}; - Configurable ConfPIDBBProton{ - "ConfPIDBBProton", - "Users/l/lserksny/PIDProton", - "Path to the CCDB ocject for proton BB param"}; - Configurable ConfPIDBBAntiProton{ - "ConfPIDBBAntiProton", - "Users/l/lserksny/PIDAntiProton", - "Path to the CCDB ocject for antiproton BB param"}; - - Configurable ConfUseManualPIDdeuteron{ - "ConfUseManualPIDdeuteron", - false, - "True: use home-made PID solution for deuteron "}; - Configurable ConfPIDBBDeuteron{ - "ConfPIDBBDeuteron", - "Users/l/lserksny/PIDDeuteron", - "Path to the CCDB ocject for Deuteron BB param"}; - Configurable ConfPIDBBAntiDeuteron{ - "ConfPIDBBAntiDeuteron", - "Users/l/lserksny/PIDAntiDeuteron", - "Path to the CCDB ocject for antiDeuteron BB param"}; - - Configurable ConfUseManualPIDpion{ - "ConfUseManualPIDpion", - false, - "True: use home-made PID solution for pions"}; - Configurable ConfPIDBBPion{ - "ConfPIDBBPion", - "Users/l/lserksny/PIDPion", - "Path to the CCDB ocject for Pion BB param"}; - Configurable ConfPIDBBAntiPion{ - "ConfPIDBBAntiPion", - "Users/l/lserksny/PIDAntiPion", - "Path to the CCDB ocject for antiPion BB param"}; - - Configurable ConfUseManualPIDel{ - "ConfUseManualPIDel", - false, - "True: use home-made PID solution for electron"}; - Configurable ConfPIDBBElectron{ - "ConfPIDBBElectron", - "Users/l/lserksny/PIDElectron", - "Path to the CCDB ocject for Electron BB param"}; - Configurable ConfPIDBBAntiElectron{ - "ConfPIDBBAntiElectron", - "Users/l/lserksny/PIDAntiElectron", - "Path to the CCDB ocject for antiElectron BB param"}; - - Configurable ConfUseManualPIDdaughterPion{ - "ConfUseManualPIDdaughterPion", - false, - "True: use home-made PID solution for pion from V0"}; - Configurable ConfUseManualPIDdaughterProton{ - "ConfUseManualPIDdaughterProton", - false, - "True: use home-made PID solution for proton from V0"}; - - Configurable ConfUseAvgFromCCDB{ - "ConfUseAvgFromCCDB", - false, - "True: use TOF and TPC averages from CCDB"}; - Configurable ConfAvgPath{ - "ConfAvgPath", - "Users/l/lserksny/TPCTOFAvg", - "Path to the CCDB ocject for TOF and TPC averages"}; - - Configurable ConfRejectNotPropagatedTracks{ - "ConfRejectNotPropagatedTracks", - false, - "True: reject not propagated tracks"}; - Configurable ConfTrkEta{ - "ConfTrkEta", - 0.85, - "Eta"}; - Configurable> ConfTPCNClustersMin{ - "ConfTPCNClustersMin", - {CFTrigger::NClustersMin[0], 1, CFTrigger::nTracks, std::vector{"TPCNClusMin"}, CFTrigger::SpeciesMinTPCClustersName}, - "kstar limit for two body trigger"}; - Configurable ConfTrkTPCfCls{ - "ConfTrkTPCfCls", - 0.83, - "Minimum fraction of crossed rows over findable clusters"}; - Configurable ConfTrkTPCcRowsMin{ - "ConfTrkTPCcRowsMin", - 70, - "Minimum number of crossed TPC rows"}; - Configurable ConfTrkTPCsClsMax{ - "ConfTrkTPCsClsMax", - 160, - "Maximum number of shared TPC clusters"}; - Configurable> ConfTrkITSnclsMin{ - "ConfTrkITSnclsMin", - {CFTrigger::ITSCutsTable[0], 1, CFTrigger::nTracks, std::vector{"Cut"}, CFTrigger::SpeciesName}, - "Minimum number of ITS clusters"}; - Configurable> ConfTrkITSnclsIBMin{ - "ConfTrkITSnclsIBMin", - {CFTrigger::ITSCutsTable[0], 1, CFTrigger::nTracks, std::vector{"Cut"}, CFTrigger::SpeciesName}, - "Minimum number of ITS clusters in the inner barrel"}; - Configurable ConfTrkDCAxyMax{ - "ConfTrkDCAxyMax", - 0.15, - "Maximum DCA_xy"}; - Configurable ConfTrkDCAzMax{ - "ConfTrkDCAzMax", - 0.3, - "Maximum DCA_z"}; - // Checks taken from global track definition - Configurable ConfTrkRequireChi2MaxTPC{ - "ConfTrkRequireChi2MaxTPC", false, - "True: require max chi2 per TPC cluster"}; - Configurable ConfTrkRequireChi2MaxITS{ - "ConfTrkRequireChi2MaxITS", false, - "True: require max chi2 per ITS cluster"}; - Configurable - ConfTrkMaxChi2PerClusterTPC{ - "ConfTrkMaxChi2PerClusterTPC", - 4.0f, - "Minimal track selection: max allowed chi2 per TPC cluster"}; // 4.0 is default of - // global tracks - // on 20.01.2023 - Configurable - ConfTrkMaxChi2PerClusterITS{ - "ConfTrkMaxChi2PerClusterITS", - 36.0f, - "Minimal track selection: max allowed chi2 per ITS cluster"}; // 36.0 is default of - // global tracks - // on 20.01.2023 - Configurable ConfTrkTPCRefit{ - "ConfTrkTPCRefit", - false, - "True: require TPC refit"}; - Configurable ConfTrkITSRefit{ - "ConfTrkITSRefit", - false, - "True: require ITS refit"}; - - // PID selections - Configurable> ConfPIDCuts{ - "ConfPIDCuts", - {CFTrigger::pidcutsTable[0], CFTrigger::nTracks, CFTrigger::kNPIDLimits, CFTrigger::SpeciesName, CFTrigger::PidCutsName}, - "Particle PID selections"}; - Configurable> ConfPIDCutsAnti{ - "ConfPIDCutsAnti", - {CFTrigger::pidcutsTableAnti[0], CFTrigger::nTracks, CFTrigger::kNPIDLimits, CFTrigger::SpeciesNameAnti, CFTrigger::PidCutsName}, - "Particle PID selections for antiparticles; perfect case scenario identical to particles"}; - Configurable ConfRejectNOTDeuteron{ - "ConfRejectNOTDeuteron", - false, - "Reject deuteron candidates if they are compatible with electron, pion, proton"}; - Configurable> ConfPIDRejection{ - "ConfPIDRejection", - {CFTrigger::pidRejectionTable[0], CFTrigger::kNParticleRejection, CFTrigger::nPidRejection, CFTrigger::SpeciesRejectionName, CFTrigger::TPCCutName}, - "Particle PID Rejection selections (Deuteron candidates only)"}; - Configurable> ConfPIDTPCTOFAvg{ - "ConfPIDTPCTOFAvg", - {CFTrigger::pidTPCTOFAvgTable[0], CFTrigger::nPidAvg, CFTrigger::nTracks, CFTrigger::SpeciesAvgTPCTOFName, CFTrigger::TPCTOFAvgName}, - "Average expected nSigma of TPC and TOF, which is substracted in calculation of combined TPC and TOF nSigma"}; - - // Momentum selections - Configurable> ConfMomCorDifCut{ - "ConfMomCorDifCuts", - {CFTrigger::MomCorLimits[0], CFTrigger::nTracks, CFTrigger::nMomCorCuts, CFTrigger::SpeciesName, CFTrigger::MomCorCutsName}, - "ratio on momentum correlation difference (particle)"}; - Configurable> ConfMomCorDifCutAnti{ - "ConfMomCorDifCutsAnti", - {CFTrigger::MomCorLimits[0], CFTrigger::nTracks, CFTrigger::nMomCorCuts, CFTrigger::SpeciesNameAnti, CFTrigger::MomCorCutsName}, - "Cut on momentum correlation difference (antipartilce)"}; - Configurable ConfMomCorDifCutFlag{"ConfMomCorDifFlag", false, "Flag for cut on momentum correlation difference"}; - - Configurable> ConfMomCorRatioCut{ - "ConfMomCorRatioCuts", - {CFTrigger::MomCorLimits[0], CFTrigger::nTracks, CFTrigger::nMomCorCuts, CFTrigger::SpeciesName, CFTrigger::MomCorCutsName}, - "Cut on momentum correlation ratio (particle)"}; - Configurable> ConfMomCorRatioCutAnti{ - "ConfMomCorRatioCutsAnti", - {CFTrigger::MomCorLimits[0], CFTrigger::nTracks, CFTrigger::nMomCorCuts, CFTrigger::SpeciesNameAnti, CFTrigger::MomCorCutsName}, - "Cut on momentum correlation ratio (antipartilce)"}; - Configurable ConfMomCorRatioCutFlag{"ConfMomCorRatioFlag", false, "Flag for cut on momentum correlation ratio"}; - - Configurable> ConfPIDForTracking{ - "ConfPIDForTracking", - {CFTrigger::PIDForTrackingTable[0], CFTrigger::nTracks, 2, CFTrigger::SpeciesName, CFTrigger::PIDForTrackingName}, - "Use PID used in tracking up to momentum threshold"}; - - Configurable> ConfPtCuts{ - "ConfPtCuts", - {CFTrigger::ptcutsTable[0], CFTrigger::kNParticleSpecies, CFTrigger::nPtCuts, CFTrigger::SpeciesNameAll, CFTrigger::PtCutsName}, - "Particle Momentum selections"}; + struct : ConfigurableGroup { + std::string prefix = "TrackSel"; + Configurable> trackProperties{"trackProperties", + {cf_trigger::trackSelectionTable[0], + cf_trigger::nTrackNames, + cf_trigger::nTrackSelectionNames, + cf_trigger::trackNames, + cf_trigger::trackSelectionNames}, + "Track Selections"}; + + Configurable> momentum{"momentum", + {cf_trigger::momentumSelectionTable[0], + cf_trigger::nTrackNames, + cf_trigger::nMomentumSelectionNames, + cf_trigger::trackNames, + cf_trigger::momentumSelectionNames}, + "Momentum Selections"}; + + Configurable> pid{"pid", + {cf_trigger::pidSelectionTable[0], + cf_trigger::nTrackNames, + cf_trigger::nPidSelectionNames, + cf_trigger::trackNames, + cf_trigger::pidSelectionNames}, + "PID Selections"}; + } TrackSelections; // Configs for V0 - Configurable ConfV0PtMin{ - "ConfV0PtMin", - 0.f, - "Minimum transverse momentum of V0"}; - Configurable ConfV0DCADaughMax{ - "ConfV0DCADaughMax", - 1.8f, - "Maximum DCA between the V0 daughters"}; - Configurable ConfV0CPAMin{ - "ConfV0CPAMin", - 0.985f, - "Minimum CPA of V0"}; - Configurable ConfV0TranRadV0Min{ - "ConfV0TranRadV0Min", - 0.2f, - "Minimum transverse radius"}; - Configurable ConfV0TranRadV0Max{ - "ConfV0TranRadV0Max", - 100.f, - "Maximum transverse radius"}; - Configurable ConfV0DecVtxMax{"ConfV0DecVtxMax", - 100.f, - "Maximum distance from primary vertex"}; - Configurable ConfV0InvMassLowLimit{ - "ConfV0InvMassLowLimit", - 1.05, - "Lower limit of the V0 invariant mass"}; - Configurable ConfV0InvMassUpLimit{ - "ConfV0InvMassUpLimit", - 1.18, - "Upper limit of the V0 invariant mass"}; - - Configurable ConfV0RejectKaons{"ConfV0RejectKaons", - true, - "Switch to reject kaons"}; - Configurable ConfV0InvKaonMassLowLimit{ - "ConfV0InvKaonMassLowLimit", - 0.49, - "Lower limit of the V0 invariant mass for Kaon rejection"}; - Configurable ConfV0InvKaonMassUpLimit{ - "ConfV0InvKaonMassUpLimit", - 0.505, - "Upper limit of the V0 invariant mass for Kaon rejection"}; - - // config for V0 daughters - Configurable ConfDaughEta{ - "ConfDaughEta", - 0.85f, - "V0 Daugh sel: max eta"}; - Configurable ConfDaughTPCnclsMin{ - "ConfDaughTPCnclsMin", - 60.f, - "V0 Daugh sel: Min. nCls TPC"}; - Configurable ConfDaughDCAMin{ - "ConfDaughDCAMin", - 0.04f, - "V0 Daugh sel: Max. DCA Daugh to PV (cm)"}; - Configurable> ConfDaughPIDCuts{ - "ConfDaughPIDCuts", - {CFTrigger::pidcutsV0DaughterTable[0], CFTrigger::kNV0Daughters, CFTrigger::nPidCutsDaughers, CFTrigger::SpeciesV0DaughterName, CFTrigger::TPCCutName}, - "PID selections for Lambda daughters"}; - - // config for ppPhi struct : ConfigurableGroup { - std::string prefix = "PPPhi"; - Configurable ConfResoInvMassLowLimit{"ConfResoInvMassLowLimit", 1.011461, "Lower limit of the Reso invariant mass"}; - Configurable ConfResoInvMassUpLimit{"ConfResoInvMassUpLimit", 1.027461, "Upper limit of the Reso invariant mass"}; - - Configurable ConfTrkEtaKa{"ConfTrkEtaKa", 0.85, "Eta kaon daughters"}; // 0.8 - Configurable ConfTrkDCAxyKa{"ConfTrkDCAxyKa", 0.15, "DCAxy kaon daughters"}; // 0.1 - Configurable ConfTrkDCAzKa{"ConfTrkDCAzKa", 0.3, "DCAz kaon daughters"}; // 0.2 - Configurable ConfNClusKa{"ConfNClusKa", 70, "NClusters kaon daughters"}; // 0.2 - Configurable ConfNCrossedKa{"ConfNCrossedKa", 65, "NCrossedRows kaon daughters"}; // 0.2 - Configurable ConfTrkTPCfClsKa{"ConfTrkTPCfClsKa", 0.80, "Minimum fraction of crossed rows over findable clusters kaon daughters"}; // 0.2 - - Configurable ConfTrkPtKaUp{"ConfTrkPtKaUp", 6.0, "Pt_up kaon daughters"}; // 2.0 - Configurable ConfTrkPtKaDown{"ConfTrkPtKaDown", 0.05, "Pt_down kaon daughters"}; // 0.15 - Configurable ConfTrkPTPCKaThr{"ConfTrkPTPCKaThr", 0.40, "p_TPC,Thr kaon daughters"}; // 0.4 - Configurable ConfTrkKaSigmaPID{"ConfTrkKaSigmaPID", 3.50, "n_sigma kaon daughters"}; // 3.0 - } PPPhi; + std::string prefix = "V0BuilderOpts"; + Configurable minCrossedRows{"minCrossedRows", 70, "minimum TPC crossed rows for daughter tracks"}; + Configurable dcanegtopv{"dcanegtopv", 0.04, "DCA Neg To PV"}; + Configurable dcapostopv{"dcapostopv", 0.04, "DCA Pos To PV"}; + Configurable v0cospa{"v0cospa", 0.95, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0) + Configurable dcav0dau{"dcav0dau", 2.0, "DCA V0 Daughters"}; + Configurable v0radius{"v0radius", 0, "v0radius"}; + Configurable maxDaughterEta{"maxDaughterEta", 5, "Maximum daughter eta (in abs value)"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + } V0BuilderOpts; + + struct : ConfigurableGroup { + std::string prefix = "FitterOpts"; + Configurable propagateToPCA{"propagateToPCA", true, "Create tracks version propagated to PCA"}; + Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; + Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"}; + Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iteraterions if chi2/chi2old > this"}; + Configurable maxDzIni{"maxDzIni", 1.e9, "reject (if>0) PCA candicate if tracks DZ exceeds threshold"}; + Configurable maxDxyIni{"maxDxyIni", 4., "Same as above for DXY"}; + Configurable maxChi2{"maxChi2", 1.e9, "Maximum chi2"}; + Configurable useAbsDCA{"useAbsDCA", true, "Minimise abs. distance rather than chi2"}; + Configurable weightedFinalPCA{"weightedFinalPCA", false, "Weight final PCA"}; + } FitterOpts; + + struct : ConfigurableGroup { + std::string prefix = "LambdaSel"; + Configurable ptMin{"ptMin", 0.f, "Minimum transverse momentum of V0"}; + Configurable dcaDaughMax{"dcaDaughMax", 2.f, "Maximum DCA between the V0 daughters"}; + Configurable cpaMin{"cpaMin", 0.95f, "Minimum CPA of V0"}; + Configurable tranRadMin{"tranRadMin", 0.f, "Minimum transverse radius"}; + Configurable tranRadMax{"tranRadMax", 100.f, "Maximum transverse radius"}; + Configurable decVtxMax{"decVtxMax", 100.f, "Maximum distance from primary vertex"}; + Configurable invMassLow{"invMassLow", 1.05, "Lower limit of the V0 invariant mass"}; + Configurable invMassUp{"invMassUp", 1.18, "Upper limit of the V0 invariant mass"}; + Configurable rejectKaons{"rejectKaons", true, "Switch to reject kaons"}; + Configurable invKaonMassLow{"invKaonMassLow", 0.49, "Lower limit of the V0 invariant mass for Kaon rejection"}; + Configurable invKaonMassUp{"invKaonMassUp", 0.505, "Upper limit of the V0 invariant mass for Kaon rejection"}; + } LambdaSelections; + + struct : ConfigurableGroup { + std::string prefix = "LambdaDaughterSel"; + Configurable absEtaMax{"absEtaMax", 0.85f, "V0 Daugh sel: max eta"}; + Configurable tpcClusterMin{"tpcClusterMin", 70.f, "V0 Daugh sel: Min. nCls TPC"}; + Configurable dcaMin{"dcaMin", 0.04f, "V0 Daugh sel: Max. DCA Daugh to PV (cm)"}; + Configurable tpcMax{"tpcMax", 5, "PID selections for Lambda daughters"}; + } LambdaDaughterSelections; + + struct : ConfigurableGroup { + std::string prefix = "PhiSel"; + Configurable invMassLow{"invMassLow", 1.011461, "Lower limit of Phi invariant mass"}; + Configurable invMassUp{"invMassUp", 1.027461, "Upper limit of Phi invariant mass"}; + Configurable tightInvMassLow{"tightInvMassLow", 1.011461, "Lower tight limit of Phi invariant mass"}; + Configurable tightInvMassUp{"tightInvMassUp", 1.027461, "Upper tight limit of Phi invariant mass"}; + } PhiSelections; + + struct : ConfigurableGroup { + std::string prefix = "RhoSel"; + Configurable invMassLow{"invMassLow", 0.7, "Lower limit of Rho invariant mass"}; + Configurable invMassUp{"invMassUp", 0.85, "Upper limit of Rho invariant mass"}; + Configurable ptLow{"ptLow", 3, "Lower pt limit for rho"}; + Configurable tightInvMassLow{"tightInvMassLow", 0.73, "Lower tight limit of Rho invariant mass"}; + Configurable tightInvMassUp{"tightInvMassUp", 0.82, "Upper tight limit of Rho invariant mass"}; + } RhoSelections; // Trigger selections - Configurable> ConfTriggerSwitches{ - "ConfTriggerSwitches", - {CFTrigger::triggerSwitches[0], 1, CFTrigger::nAllTriggers, std::vector{"Switch"}, CFTrigger::CFTriggerNamesALL}, - "Turn on specific trigger"}; - - Configurable> ConfQ3Limits{ - "ConfQ3Limits", - {CFTrigger::Q3Limits[0], 1, CFTrigger::kNThreeBodyTriggers, std::vector{"Limit"}, CFTrigger::ThreeBodyFilterNames}, - "Q3 limits for three body trigger"}; - - Configurable> ConfKstarLimits{ - "ConfKstarLimits", - {CFTrigger::KstarLimits[0], 1, CFTrigger::kNTwoBodyTriggers, std::vector{"Limit"}, CFTrigger::TwoBodyFilterNames}, - "kstar limit for two body trigger"}; - - Configurable> ConfDownsample{ - "ConfDownsample", - {CFTrigger::Downsample[0], 2, CFTrigger::nTriggerAllNames, std::vector{"Switch", "Factor"}, CFTrigger::ParticleNames}, - "Downsample individual particle species (Switch has to be larger than 0, Factor has to smaller than 1)"}; - - HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; - // HistogramRegistry registryQA{"registryQA", {}, OutputObjHandlingPolicy::AnalysisObject}; - - std::vector BBProton, BBAntiproton, BBDeuteron, BBAntideuteron, BBPion, BBAntipion, BBElectron, BBAntielectron, TPCTOFAvg; + struct : ConfigurableGroup { + std::string prefix = "Triggers"; + Configurable> filterSwitches{"filterSwitches", + {cf_trigger::filterTable[0], + cf_trigger::nSwitches, + cf_trigger::nFilterNames, + cf_trigger::switches, + cf_trigger::filterNames}, + "Switch for triggers"}; + Configurable> limits{"limits", + {cf_trigger::limitTable[0], + cf_trigger::nLimitNames, + cf_trigger::nFilterNames, + cf_trigger::limitNames, + cf_trigger::filterNames}, + "Limits for trigger. Tight limit without downsampling and loose with downsampling"}; + } TriggerSelections; + + struct : ConfigurableGroup { + std::string prefix = "Binning"; + ConfigurableAxis multiplicity{"multiplicity", {200, 0, 200}, "Binning Multiplicity"}; + ConfigurableAxis zvtx{"zvtx", {30, -15, 15}, "Binning Zvertex"}; + + ConfigurableAxis momentum{"momentum", {600, 0, 6}, "Binning Momentum"}; + ConfigurableAxis eta{"eta", {200, -1, 1}, "Binning eta"}; + ConfigurableAxis phi{"phi", {720, 0, o2::constants::math::TwoPI}, "Binning phi"}; + ConfigurableAxis dca{"dca", {100, -0.2, 0.2}, "Binning Dca"}; + + ConfigurableAxis nsigma{"nsigma", {500, -5, 5}, "Binning nsigma"}; + ConfigurableAxis nsigmaComb{"nsigmaComb", {500, 0, 5}, "Binning nsigma comb"}; + ConfigurableAxis tpcSignal{"tpcSignal", {500, 0, 500}, "Binning Tpc Signal"}; + ConfigurableAxis itsSignal{"itsSignal", {150, 0, 15}, "Binning Its Signal"}; + ConfigurableAxis tofSignal{"tofSignal", {120, 0, 1.2}, "Binning Tof Signal"}; + ConfigurableAxis tpcCluster{"tpcCluster", {153, 0, 153}, "Binning Tpc Clusters"}; + ConfigurableAxis tpcChi2{"tpcChi2", {100, 0, 5}, "Binning TPC chi2"}; + ConfigurableAxis itsCluster{"itsCluster", {8, -0.5, 7.5}, "Binning Its Clusters"}; + ConfigurableAxis itsIbCluster{"itsIbCluster", {4, -0.5, 3.5}, "Binning Its Inner Barrel Clusters"}; + ConfigurableAxis itsChi2{"itsChi2", {100, 0, 50}, "Binning ITS chi2"}; + + ConfigurableAxis momCor{"momCor", {100, -1, 1}, "Binning Ratios"}; + ConfigurableAxis ratio{"ratio", {200, 0, 2}, "Binning Ratios"}; + + ConfigurableAxis invMassLambda{"invMassLambda", {200, 1, 1.2}, "Binning Invariant Mass Lambda"}; + ConfigurableAxis invMassK0short{"invMassK0short", {100, 0.48, 0.52}, "Binning Invariant Mass K0short"}; + + ConfigurableAxis dcaDaugh{"dcaDaugh", {200, 0, 2}, "Binning daughter DCA at decay vertex"}; + ConfigurableAxis cpa{"cpa", {100, 0.9, 1}, "Binning CPA"}; + ConfigurableAxis transRad{"transRad", {100, 0, 100}, "Binning Transverse Radius"}; + ConfigurableAxis decayVtx{"decayVtx", {100, 0, 100}, "Binning Decay Vertex"}; + + ConfigurableAxis invMassPhi{"invMassPhi", {600, 0.7, 1.3}, "Binning Invariant Mass Phi"}; + + ConfigurableAxis invMassRho{"invMassRho", {600, 0.47, 1.07}, "Binning Invariant Mass Rho"}; + + ConfigurableAxis q3{"q3", {300, 0, 3}, "Binning Decay Q3"}; + ConfigurableAxis kstar{"kstar", {300, 0, 3}, "Binning Decay Kstar"}; + + } Binning; + + // define histogram registry + // because we have so many histograms, we need to have 2 registries + HistogramRegistry registryParticleQA{"ParticleQA", {}, OutputObjHandlingPolicy::AnalysisObject}; // for particle histograms + HistogramRegistry registryTriggerQA{"TriggerQA", {}, OutputObjHandlingPolicy::AnalysisObject}; // for trigger histograms + + // helper object flor building lambdas + o2::pwglf::strangenessBuilderHelper mStraHelper; + Service ccdb; + int mRunNumber = 0; + float mBz = 0.; + + // 4vectors for all particles + std::vector vecProton, vecAntiProton, vecDeuteron, vecAntiDeuteron, vecLambda, vecAntiLambda, vecKaon, vecAntiKaon, vecPhi, vecPion, vecAntiPion, vecRho; + // indices for all particles + std::vector idxProton, idxAntiProton, idxDeuteron, idxAntiDeuteron, idxKaon, idxAntiKaon, idxPion, idxAntiPion; + // indices for lambda daughters + std::vector idxLambdaDaughProton, idxLambdaDaughPion, idxAntiLambdaDaughProton, idxAntiLambdaDaughPion, idxPhiDaughPos, idxPhiDaughNeg, idxRhoDaughPos, idxRhoDaughNeg; + + // arrays to store found pairs/tripplets and trigger decisions + std::array keepEventTightLimit; + std::array keepEventLooseLimit; + std::array signalTightLimit; + std::array signalLooseLimit; + void init(o2::framework::InitContext&) { - rng = new TRandom3(ConfRngSeed.value); - - // init the ccdb - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdbApi.init("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - - // Set avg if not taking from ccdb - if (!ConfUseAvgFromCCDB) { - TPCTOFAvg = {ConfPIDTPCTOFAvg->get("Proton", "TPC Avg"), - ConfPIDTPCTOFAvg->get("Proton", "TOF Avg"), - ConfPIDTPCTOFAvg->get("AntiProton", "TPC Avg"), - ConfPIDTPCTOFAvg->get("AntiProton", "TOF Avg"), - ConfPIDTPCTOFAvg->get("Deuteron", "TPC Avg"), - ConfPIDTPCTOFAvg->get("Deuteron", "TOF Avg"), - ConfPIDTPCTOFAvg->get("AntiDeuteron", "TPC Avg"), - ConfPIDTPCTOFAvg->get("AntiDeuteron", "TOF Avg")}; - } - - // global histograms - registry.add("fProcessedEvents", "CF - event filtered;;Events", HistType::kTH1F, {{9, -0.5, 8.5}}); - std::vector eventTitles = {"all", "rejected", "ppp", "ppL", "pLL", "LLL", "ppPhi", "pD", "LD"}; - for (size_t iBin = 0; iBin < eventTitles.size(); iBin++) { - registry.get(HIST("fProcessedEvents"))->GetXaxis()->SetBinLabel(iBin + 1, eventTitles[iBin].data()); + // setup strangeness builder + mStraHelper.v0selections.minCrossedRows = V0BuilderOpts.minCrossedRows.value; + mStraHelper.v0selections.dcanegtopv = V0BuilderOpts.dcanegtopv.value; + mStraHelper.v0selections.dcapostopv = V0BuilderOpts.dcapostopv.value; + mStraHelper.v0selections.v0cospa = V0BuilderOpts.v0cospa.value; + mStraHelper.v0selections.dcav0dau = V0BuilderOpts.dcav0dau.value; + mStraHelper.v0selections.v0radius = V0BuilderOpts.v0radius.value; + mStraHelper.v0selections.maxDaughterEta = V0BuilderOpts.maxDaughterEta.value; + + mStraHelper.fitter.setPropagateToPCA(FitterOpts.propagateToPCA.value); + mStraHelper.fitter.setMaxR(FitterOpts.maxR.value); + mStraHelper.fitter.setMinParamChange(FitterOpts.minParamChange.value); + mStraHelper.fitter.setMinRelChi2Change(FitterOpts.minRelChi2Change.value); + mStraHelper.fitter.setMaxDZIni(FitterOpts.maxDzIni.value); + mStraHelper.fitter.setMaxDXYIni(FitterOpts.maxDxyIni.value); + mStraHelper.fitter.setMaxChi2(FitterOpts.maxChi2.value); + mStraHelper.fitter.setUseAbsDCA(FitterOpts.useAbsDCA.value); + mStraHelper.fitter.setWeightedFinalPCA(FitterOpts.weightedFinalPCA.value); + + // setup histograms + int allTriggers = 2 * cf_trigger::nFilterNames; + int prossedEventsBins = 3 + allTriggers; + std::vector triggerTitles = {"ppp_LooseQ3", "ppp_TightQ3", + "ppL_LooseQ3", "ppL_TightQ3", + "pLL_LooseQ3", "pLL_TightQ3", + "LLL_LooseQ3", "LLL_TightQ3", + "ppPhi_LooseQ3", "ppPhi_TightQ3", + "ppRho_LooseQ3", "ppRho_TightQ3", + "pD_LooseKstar", "pD_TightKstar", + "LD_LooseKstar", "LD_TightKstar", + "PhiD_LooseKstar", "PhiD_TightKstar", + "RhoD_LooseKstar", "RhoD_TightKstar"}; + + registryTriggerQA.add("fProcessedEvents", "CF - event filtered;;Events", HistType::kTH1F, {{prossedEventsBins, -0.5, prossedEventsBins - 0.5}}); + registryTriggerQA.get(HIST("fProcessedEvents"))->GetXaxis()->SetBinLabel(1, "all"); + registryTriggerQA.get(HIST("fProcessedEvents"))->GetXaxis()->SetBinLabel(2, "accepted_loose"); + registryTriggerQA.get(HIST("fProcessedEvents"))->GetXaxis()->SetBinLabel(3, "accepted_tight"); + + registryTriggerQA.add("fTriggerCorrelations", "CF - Trigger correlations", HistType::kTH2F, {{allTriggers, -0.5, allTriggers - 0.5}, {allTriggers, -0.5, allTriggers - 0.5}}); + + for (size_t iBin = 0; iBin < triggerTitles.size(); iBin++) { + registryTriggerQA.get(HIST("fProcessedEvents"))->GetXaxis()->SetBinLabel(iBin + 4, triggerTitles[iBin].data()); // start triggers from 4th bin + registryTriggerQA.get(HIST("fTriggerCorrelations"))->GetXaxis()->SetBinLabel(iBin + 1, triggerTitles[iBin].data()); + registryTriggerQA.get(HIST("fTriggerCorrelations"))->GetYaxis()->SetBinLabel(iBin + 1, triggerTitles[iBin].data()); } // event cuts - registry.add("EventCuts/fMultiplicityBefore", "Multiplicity of all processed events;Mult;Entries", HistType::kTH1F, {{1000, 0, 1000}}); - registry.add("EventCuts/fMultiplicityAfter", "Multiplicity after event cuts;Mult;Entries", HistType::kTH1F, {{1000, 0, 1000}}); - registry.add("EventCuts/fZvtxBefore", "Zvtx of all processed events;Z_{vtx};Entries", HistType::kTH1F, {{1000, -15, 15}}); - registry.add("EventCuts/fZvtxAfter", "Zvtx after event cuts;Z_{vtx};Entries", HistType::kTH1F, {{1000, -15, 15}}); - - // mom correlations p vs pTPC - registry.add("TrackCuts/TracksBefore/fMomCorrelationPos", "fMomCorrelation;p (GeV/c);p_{TPC} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 20.0f}, {1000, 0.0f, 20.0f}}}); - registry.add("TrackCuts/TracksBefore/fMomCorrelationAfterCutsPos", "fMomCorrelationAfterCuts;p (GeV/c);p_{TPC} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 20.0f}, {1000, 0.0f, 20.0f}}}); - registry.add("TrackCuts/TracksBefore/fMomCorrelationNeg", "fMomCorrelation;p (GeV/c);p_{TPC} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 20.0f}, {1000, 0.0f, 20.0f}}}); - registry.add("TrackCuts/TracksBefore/fMomCorrelationAfterCutsNeg", "fMomCorrelationAfterCuts;p (GeV/c);p_{TPC} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 20.0f}, {1000, 0.0f, 20.0f}}}); - - registry.add("TrackCuts/TracksBefore/fMomCorrelationAfterCutsProton", "fMomCorrelation;p (GeV/c);p_{TPC} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 20.0f}, {1000, 0.0f, 20.0f}}}); - registry.add("TrackCuts/TracksBefore/fMomCorrelationAfterCutsAntiProton", "fMomCorrelation;p (GeV/c);p_{TPC} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 20.0f}, {1000, 0.0f, 20.0f}}}); - registry.add("TrackCuts/TracksBefore/fMomCorrelationAfterCutsDeuteron", "fMomCorrelation;p (GeV/c);p_{TPC} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 20.0f}, {1000, 0.0f, 20.0f}}}); - registry.add("TrackCuts/TracksBefore/fMomCorrelationAfterCutsAntiDeuteron", "fMomCorrelation;p (GeV/c);p_{TPC} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 20.0f}, {1000, 0.0f, 20.0f}}}); - - // all tracks - registry.add("TrackCuts/TracksBefore/fPtTrackBefore", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/TracksBefore/fEtaTrackBefore", "Pseudorapidity of all processed tracks;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/TracksBefore/fPhiTrackBefore", "Azimuthal angle of all processed tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); + registryParticleQA.add("EventQA/Before/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryParticleQA.add("EventQA/Before/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + + registryParticleQA.add("EventQA/After/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryParticleQA.add("EventQA/After/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + + // all tracks before cuts + registryParticleQA.add("TrackQA/Before/Particle/fPt", "Transverse;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/Before/Particle/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/Before/Particle/fPhi", "Azimuthal;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("TrackQA/Before/Particle/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/Before/Particle/fItsSignal", "ITSSignal;p_{TPC} (GeV/c);ITS Signal", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/Before/Particle/fTpcSignal", "TPCSignal;p_{TPC} (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/Before/Particle/fTofSignal", "TOFSignal;p_{TPC} (GeV/c);TOF Signal", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); + + registryParticleQA.add("TrackQA/Before/AntiParticle/fPt", "Transverse momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/Before/AntiParticle/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/Before/AntiParticle/fPhi", "Azimuthal angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("TrackQA/Before/AntiParticle/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/Before/AntiParticle/fItsSignal", "ITSSignal;p_{TPC} (GeV/c);ITS Signal", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/Before/AntiParticle/fTpcSignal", "TPCSignal;p_{TPC} (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/Before/AntiParticle/fTofSignal", "TOFSignal;p_{TPC} (GeV/c);TOF Signal", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); // PID vs momentum before cuts - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPProtonBefore", "NSigmaTPC Proton Before;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTOFvsPProtonBefore", "NSigmaTOF Proton Before;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCTOFvsPProtonBefore", "NSigmaTPCTOF Proton Before;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPAntiProtonBefore", "NSigmaTPC AntiProton Before;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTOFvsPAntiProtonBefore", "NSigmaTOF AntiProton Before;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCTOFvsPAntiProtonBefore", "NSigmaTPCTOF AntiProton Before;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPDeuteronBefore", "NSigmaTPC Deuteron Before;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTOFvsPDeuteronBefore", "NSigmaTOF Deuteron Before;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCTOFvsPDeuteronBefore", "NSigmaTPCTOF Deuteron Before;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPAntiDeuteronBefore", "NSigmaTPC AntiDeuteron Before;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTOFvsPAntiDeuteronBefore", "NSigmaTOF AntiDeuteron Before;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCTOFvsPAntiDeuteronBefore", "NSigmaTPCTOF AntiDeuteron Before;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPDeuteronBeforeP", "NSigmaTPC Deuteron BeforeP;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPAntiDeuteronBeforeP", "NSigmaTPC AntiDeuteron BeforeP;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - - // TPC signal - registry.add("TrackCuts/TPCSignal/fTPCSignal", "TPCSignal;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {2000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalP", "TPCSignalP;p (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {2000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalALLCUTS", "TPCSignalALLCUTS;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {2000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalALLCUTSP", "TPCSignalALLCUTSP;p (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {2000, -100.f, 1000.f}}}); - - // TPC signal anti - registry.add("TrackCuts/TPCSignal/fTPCSignalAnti", "TPCSignal;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {2000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalAntiP", "TPCSignalP;p (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {2000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalAntiALLCUTS", "TPCSignalALLCUTS;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {2000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalAntiALLCUTSP", "TPCSignalALLCUTSP;p(GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {2000, -100.f, 1000.f}}}); - - // TPC signal particles - registry.add("TrackCuts/TPCSignal/fTPCSignalProton", "fTPCSignalProton;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {20000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalAntiProton", "fTPCSignalAntiProton;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {20000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalDeuteron", "fTPCSignalDeuteron;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {20000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalAntiDeuteron", "fTPCSignalAntiDeuteron;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {20000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalPionMinusV0Daughter", "fTPCSignalPionMinusV0Daughter;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {20000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalPionPlusV0Daughter", "fTPCSignalPionPlusV0Daughter;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {20000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalProtonMinusV0Daughter", "fTPCSignalProtonMinusV0Daughter;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {20000, -100.f, 1000.f}}}); - registry.add("TrackCuts/TPCSignal/fTPCSignalProtonPlusV0Daughter", "fTPCSignalProtonPlusV0Daughter;p_{TPC} (GeV/c);dE/dx", {HistType::kTH2F, {{1000, 0.0f, 6.0f}, {20000, -100.f, 1000.f}}}); - - // PID vs momentum before cuts daughters - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPProtonV0DaughBefore", "NSigmaTPC Proton V0Daught Before;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPPionMinusV0DaughBefore", "NSigmaTPC AntiPion V0Daught Before;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPAntiProtonAntiV0DaughBefore", "NSigmaTPC AntiProton antiV0Daught Before;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/NSigmaBefore/fNsigmaTPCvsPPionPlusAntiV0DaughBefore", "NSigmaTPC Pion antiV0Daught Before;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + registryParticleQA.add("TrackQA/Before/Pion/fNsigmaITS", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Pion/fNsigmaTPC", "NSigmaTPC;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Pion/fNsigmaTOF", "NSigmaTOF;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Pion/fNsigmaTPCTOF", "NsigmaTPCTOF;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/Before/AntiPion/fNsigmaITS", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiPion/fNsigmaTPC", "NSigmaTPC;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiPion/fNsigmaTOF", "NSigmaTOF;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiPion/fNsigmaTPCTOF", "NsigmaTPCTOF;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/Before/Kaon/fNsigmaITS", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Kaon/fNsigmaTPC", "NSigmaTPC;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Kaon/fNsigmaTOF", "NSigmaTOF;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Kaon/fNsigmaTPCTOF", "NsigmaTPCTOF;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/Before/AntiKaon/fNsigmaITS", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiKaon/fNsigmaTPC", "NSigmaTPC;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiKaon/fNsigmaTOF", "NSigmaTOF;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiKaon/fNsigmaTPCTOF", "NsigmaTPCTOF;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/Before/Proton/fNsigmaITS", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Proton/fNsigmaTPC", "NSigmaTPC;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Proton/fNsigmaTOF", "NSigmaTOF;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Proton/fNsigmaTPCTOF", "NsigmaTPCTOF;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/Before/AntiProton/fNsigmaITS", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiProton/fNsigmaTPC", "NSigmaTPC;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiProton/fNsigmaTOF", "NSigmaTOF;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiProton/fNsigmaTPCTOF", "NsigmaTPCTOF;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/Before/Deuteron/fNsigmaITS", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Deuteron/fNsigmaTPC", "NSigmaTPC;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Deuteron/fNsigmaTOF", "NSigmaTOF;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/Deuteron/fNsigmaTPCTOF", "NsigmaTPCTOF;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/Before/AntiDeuteron/fNsigmaITS", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiDeuteron/fNsigmaTPC", "NSigmaTPC;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiDeuteron/fNsigmaTOF", "NSigmaTOF;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/Before/AntiDeuteron/fNsigmaTPCTOF", "NsigmaTPCTOF;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + // Pion + registryParticleQA.add("TrackQA/After/Pion/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/Pion/fPTpc", "Momentum at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/Pion/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/After/Pion/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/After/Pion/fPhi", "Azimuthal angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + registryParticleQA.add("TrackQA/After/Pion/fNsigmaIts", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Pion/fNsigmaTpc", "NSigmaTPC;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Pion/fNsigmaTof", "NSigmaTOF;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Pion/fNsigmaTpcTof", "NSigmaTPCTOF;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/After/Pion/fItsSignal", "ITS Signal;p (GeV/c); (cm)", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/After/Pion/fTpcSignal", "TPC Signal;p (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/After/Pion/fTofBeta", "TOF #beta;p (GeV/c);#beta_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); + + registryParticleQA.add("TrackQA/After/Pion/fDcaXy", "DCA_{xy};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("TrackQA/After/Pion/fDcaZ", "DCA_{z};p_{T} (GeV/c); DCA_{Z};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + + registryParticleQA.add("TrackQA/After/Pion/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Pion/fTpcCrossedRows", "TPC Crossed Rows;TPC Crossed Rows;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Pion/fTpcSharedClusters", "TPC Shared Clusters;TPC Shared Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Pion/fTpcSharedClusterOverClusterss", "TPC Shared Clusters/Clusters;TPC Shared Clusters/Clusters;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/Pion/fTpcFindableOverRows", "TPC Findabled/Crossed Rows;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/Pion/fTpcChi2OverCluster", "TPC #chi^{2}/Cluster;TPC #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.tpcChi2}); + + registryParticleQA.add("TrackQA/After/Pion/fItsClusters", "ITS Clusters;ITS Clusters;Entries", HistType::kTH1F, {Binning.itsCluster}); + registryParticleQA.add("TrackQA/After/Pion/fItsIbClusters", "ITS Inner Barrel Clusters;ITS Inner Barrel Clusters;Entries", HistType::kTH1F, {Binning.itsIbCluster}); + registryParticleQA.add("TrackQA/After/Pion/fItsChi2OverCluster", "ITS #chi^{2}/Cluster;ITS #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.itsChi2}); + + // antiPion + registryParticleQA.add("TrackQA/After/AntiPion/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/AntiPion/fPTpc", "Momentum at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/AntiPion/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/After/AntiPion/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/After/AntiPion/fPhi", "Azimuthal angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + registryParticleQA.add("TrackQA/After/AntiPion/fNsigmaIts", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiPion/fNsigmaTpc", "NSigmaTPC;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiPion/fNsigmaTof", "NSigmaTOF;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiPion/fNsigmaTpcTof", "NSigmaTPCTOF;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/After/AntiPion/fItsSignal", "ITS Signal;p (GeV/c); (cm)", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/After/AntiPion/fTpcSignal", "TPC Signal;p (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/After/AntiPion/fTofBeta", "TOF #beta;p (GeV/c);#beta_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); + + registryParticleQA.add("TrackQA/After/AntiPion/fDcaXy", "DCA_{xy};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("TrackQA/After/AntiPion/fDcaZ", "DCA_{z};p_{T} (GeV/c); DCA_{Z};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + + registryParticleQA.add("TrackQA/After/AntiPion/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiPion/fTpcCrossedRows", "TPC Crossed Rows;TPC Crossed Rows;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiPion/fTpcSharedClusters", "TPC Shared Clusters;TPC Shared Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiPion/fTpcSharedClusterOverClusterss", "TPC Shared Clusters/Clusters;TPC Shared Clusters/Clusters;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/AntiPion/fTpcFindableOverRows", "TPC Findabled/Crossed Rows;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/AntiPion/fTpcChi2OverCluster", "TPC #chi^{2}/Cluster;TPC #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.tpcChi2}); + + registryParticleQA.add("TrackQA/After/AntiPion/fItsClusters", "ITS Clusters;ITS Clusters;Entries", HistType::kTH1F, {Binning.itsCluster}); + registryParticleQA.add("TrackQA/After/AntiPion/fItsIbClusters", "ITS Inner Barrel Clusters;ITS Inner Barrel Clusters;Entries", HistType::kTH1F, {Binning.itsIbCluster}); + registryParticleQA.add("TrackQA/After/AntiPion/fItsChi2OverCluster", "ITS #chi^{2}/Cluster;ITS #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.itsChi2}); + + // Kaon + registryParticleQA.add("TrackQA/After/Kaon/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/Kaon/fPTpc", "Momentum at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/Kaon/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/After/Kaon/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/After/Kaon/fPhi", "Azimuthal angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + registryParticleQA.add("TrackQA/After/Kaon/fNsigmaIts", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Kaon/fNsigmaTpc", "NSigmaTPC;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Kaon/fNsigmaTof", "NSigmaTOF;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Kaon/fNsigmaTpcTof", "NSigmaTPCTOF;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/After/Kaon/fItsSignal", "ITS Signal;p (GeV/c); (cm)", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/After/Kaon/fTpcSignal", "TPC Signal;p (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/After/Kaon/fTofBeta", "TOF #beta;p (GeV/c);#beta_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); + + registryParticleQA.add("TrackQA/After/Kaon/fDcaXy", "DCA_{xy};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("TrackQA/After/Kaon/fDcaZ", "DCA_{z};p_{T} (GeV/c); DCA_{Z};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + + registryParticleQA.add("TrackQA/After/Kaon/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Kaon/fTpcCrossedRows", "TPC Crossed Rows;TPC Crossed Rows;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Kaon/fTpcSharedClusters", "TPC Shared Clusters;TPC Shared Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Kaon/fTpcSharedClusterOverClusterss", "TPC Shared Clusters/Clusters;TPC Shared Clusters/Clusters;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/Kaon/fTpcFindableOverRows", "TPC Findabled/Crossed Rows;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/Kaon/fTpcChi2OverCluster", "TPC #chi^{2}/Cluster;TPC #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.tpcChi2}); + + registryParticleQA.add("TrackQA/After/Kaon/fItsClusters", "ITS Clusters;ITS Clusters;Entries", HistType::kTH1F, {Binning.itsCluster}); + registryParticleQA.add("TrackQA/After/Kaon/fItsIbClusters", "ITS Inner Barrel Clusters;ITS Inner Barrel Clusters;Entries", HistType::kTH1F, {Binning.itsIbCluster}); + registryParticleQA.add("TrackQA/After/Kaon/fItsChi2OverCluster", "ITS #chi^{2}/Cluster;ITS #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.itsChi2}); + + // antiKaon + registryParticleQA.add("TrackQA/After/AntiKaon/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/AntiKaon/fPTpc", "Momentum at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/AntiKaon/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/After/AntiKaon/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/After/AntiKaon/fPhi", "Azimuthal angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + registryParticleQA.add("TrackQA/After/AntiKaon/fNsigmaIts", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiKaon/fNsigmaTpc", "NSigmaTPC;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiKaon/fNsigmaTof", "NSigmaTOF;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiKaon/fNsigmaTpcTof", "NSigmaTPCTOF;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/After/AntiKaon/fItsSignal", "ITS Signal;p (GeV/c); (cm)", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/After/AntiKaon/fTpcSignal", "TPC Signal;p (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/After/AntiKaon/fTofBeta", "TOF #beta;p (GeV/c);#beta_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); + + registryParticleQA.add("TrackQA/After/AntiKaon/fDcaXy", "DCA_{xy};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("TrackQA/After/AntiKaon/fDcaZ", "DCA_{z};p_{T} (GeV/c); DCA_{Z};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + + registryParticleQA.add("TrackQA/After/AntiKaon/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiKaon/fTpcCrossedRows", "TPC Crossed Rows;TPC Crossed Rows;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiKaon/fTpcSharedClusters", "TPC Shared Clusters;TPC Shared Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiKaon/fTpcSharedClusterOverClusterss", "TPC Shared Clusters/Clusters;TPC Shared Clusters/Clusters;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/AntiKaon/fTpcFindableOverRows", "TPC Findabled/Crossed Rows;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/AntiKaon/fTpcChi2OverCluster", "TPC #chi^{2}/Cluster;TPC #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.tpcChi2}); + + registryParticleQA.add("TrackQA/After/AntiKaon/fItsClusters", "ITS Clusters;ITS Clusters;Entries", HistType::kTH1F, {Binning.itsCluster}); + registryParticleQA.add("TrackQA/After/AntiKaon/fItsIbClusters", "ITS Inner Barrel Clusters;ITS Inner Barrel Clusters;Entries", HistType::kTH1F, {Binning.itsIbCluster}); + registryParticleQA.add("TrackQA/After/AntiKaon/fItsChi2OverCluster", "ITS #chi^{2}/Cluster;ITS #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.itsChi2}); // proton - // TEST P TPC - registry.add("TrackCuts/Proton/fPProton", "Momentum of protons at PV;p (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Proton/fPTPCProton", "Momentum of protons at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Proton/fPtProton", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Proton/fMomCorProtonDif", "Momentum correlation;p_{reco} (GeV/c); (p_{TPC} - p_{reco}) (GeV/c)", {HistType::kTH2F, {{500, 0, 10}, {600, -3, 3}}}); - registry.add("TrackCuts/Proton/fMomCorProtonRatio", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {{500, 0, 10}, {200, -1, 1}}}); - registry.add("TrackCuts/Proton/fEtaProton", "Pseudorapidity of all processed tracks;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Proton/fPhiProton", "Azimuthal angle of all processed tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); - registry.add("TrackCuts/Proton/fNsigmaTPCvsPProton", "NSigmaTPC Proton;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Proton/fNsigmaTOFvsPProton", "NSigmaTOF Proton;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Proton/fNsigmaTPCTOFvsPProton", "NSigmaTPCTOF Proton;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/Proton/fNsigmaTPCvsPProtonP", "NSigmaTPC Proton P;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Proton/fNsigmaTOFvsPProtonP", "NSigmaTOF Proton P;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Proton/fNsigmaTPCTOFvsPProtonP", "NSigmaTPCTOF Proton P;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/Proton/fDCAxyProton", "fDCAxy Proton;DCA_{XY};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/Proton/fDCAzProton", "fDCAz Proton;DCA_{Z};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/Proton/fTPCsClsProton", "fTPCsCls Proton;TPC Shared Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Proton/fTPCcRowsProton", "fTPCcRows Proton;TPC Crossed Rows;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Proton/fTrkTPCfClsProton", "fTrkTPCfCls Proton;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {{500, 0.0f, 3.0f}}); - registry.add("TrackCuts/Proton/fTPCnclsProton", "fTPCncls Proton;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); + registryParticleQA.add("TrackQA/After/Proton/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/Proton/fPTpc", "Momentum at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/Proton/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/After/Proton/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/After/Proton/fPhi", "Azimuthal angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + registryParticleQA.add("TrackQA/After/Proton/fNsigmaIts", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Proton/fNsigmaTpc", "NSigmaTPC;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Proton/fNsigmaTof", "NSigmaTOF;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Proton/fNsigmaTpcTof", "NSigmaTPCTOF;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/After/Proton/fItsSignal", "ITS Signal;p (GeV/c); (cm)", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/After/Proton/fTpcSignal", "TPC Signal;p (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/After/Proton/fTofBeta", "TOF #beta;p (GeV/c);#beta_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); + + registryParticleQA.add("TrackQA/After/Proton/fDcaXy", "DCA_{xy};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("TrackQA/After/Proton/fDcaZ", "DCA_{z};p_{T} (GeV/c); DCA_{Z};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + + registryParticleQA.add("TrackQA/After/Proton/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Proton/fTpcCrossedRows", "TPC Crossed Rows;TPC Crossed Rows;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Proton/fTpcSharedClusters", "TPC Shared Clusters;TPC Shared Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Proton/fTpcSharedClusterOverClusterss", "TPC Shared Clusters/Clusters;TPC Shared Clusters/Clusters;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/Proton/fTpcFindableOverRows", "TPC Findabled/Crossed Rows;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/Proton/fTpcChi2OverCluster", "TPC #chi^{2}/Cluster;TPC #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.tpcChi2}); + + registryParticleQA.add("TrackQA/After/Proton/fItsClusters", "ITS Clusters;ITS Clusters;Entries", HistType::kTH1F, {Binning.itsCluster}); + registryParticleQA.add("TrackQA/After/Proton/fItsIbClusters", "ITS Inner Barrel Clusters;ITS Inner Barrel Clusters;Entries", HistType::kTH1F, {Binning.itsIbCluster}); + registryParticleQA.add("TrackQA/After/Proton/fItsChi2OverCluster", "ITS #chi^{2}/Cluster;ITS #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.itsChi2}); // antiproton - registry.add("TrackCuts/AntiProton/fPtAntiProton", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/AntiProton/fMomCorAntiProtonDif", "Momentum correlation;p_{reco} (GeV/c); (p_{TPC} - p_{reco}) (GeV/c)", {HistType::kTH2F, {{500, 0, 10}, {600, -3, 3}}}); - registry.add("TrackCuts/AntiProton/fMomCorAntiProtonRatio", "Momentum correlation;p_{reco} (GeV/c); |p_{TPC} - p_{reco}| (GeV/c)", {HistType::kTH2F, {{500, 0, 10}, {200, -1, 1}}}); - registry.add("TrackCuts/AntiProton/fEtaAntiProton", "Pseudorapidity of all processed tracks;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/AntiProton/fPhiAntiProton", "Azimuthal angle of all processed tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); - registry.add("TrackCuts/AntiProton/fNsigmaTPCvsPAntiProton", "NSigmaTPC AntiProton;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/AntiProton/fNsigmaTOFvsPAntiProton", "NSigmaTOF AntiProton;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/AntiProton/fNsigmaTPCTOFvsPAntiProton", "NSigmaTPCTOF AntiProton;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/AntiProton/fNsigmaTPCvsPAntiProtonP", "NSigmaTPC AntiProton P;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/AntiProton/fNsigmaTOFvsPAntiProtonP", "NSigmaTOF AntiProton P;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/AntiProton/fNsigmaTPCTOFvsPAntiProtonP", "NSigmaTPCTOF AntiProton P;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/AntiProton/fDCAxyAntiProton", "fDCAxy AntiProton;DCA_{XY};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/AntiProton/fDCAzAntiProton", "fDCAz AntiProton;DCA_{Z};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/AntiProton/fTPCsClsAntiProton", "fTPCsCls AntiProton;TPC Shared Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/AntiProton/fTPCcRowsAntiProton", "fTPCcRows AntiProton;TPC Crossed Rows;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/AntiProton/fTrkTPCfClsAntiProton", "fTrkTPCfCls AntiProton;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {{500, 0.0f, 3.0f}}); - registry.add("TrackCuts/AntiProton/fTPCnclsAntiProton", "fTPCncls AntiProton;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - - // deuteron - registry.add("TrackCuts/Deuteron/fPtDeuteron", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Deuteron/fMomCorDeuteronDif", "Momentum correlation;p_{reco} (GeV/c); (p_{TPC} - p_{reco}) (GeV/c)", {HistType::kTH2F, {{500, 0, 10}, {600, -3, 3}}}); - registry.add("TrackCuts/Deuteron/fMomCorDeuteronRatio", "Momentum correlation;p_{reco} (GeV/c); |p_{TPC} - p_{reco}| (GeV/c)", {HistType::kTH2F, {{500, 0, 10}, {200, -1, 1}}}); - registry.add("TrackCuts/Deuteron/fEtaDeuteron", "Pseudorapidity of all processed tracks;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Deuteron/fPhiDeuteron", "Azimuthal angle of all processed tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); - registry.add("TrackCuts/Deuteron/fNsigmaTPCvsPDeuteron", "NSigmaTPC Deuteron;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Deuteron/fNsigmaTOFvsPDeuteron", "NSigmaTOF Deuteron;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Deuteron/fNsigmaTPCTOFvsPDeuteron", "NSigmaTPCTOF Deuteron;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/Deuteron/fNsigmaTPCvsPDeuteronP", "NSigmaTPC Deuteron vd P;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Deuteron/fNsigmaTOFvsPDeuteronP", "NSigmaTOF Deuteron P;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Deuteron/fNsigmaTPCTOFvsPDeuteronP", "NSigmaTPCTOF Deuteron P;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/Deuteron/fDCAxyDeuteron", "fDCAxy Deuteron;DCA_{XY};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/Deuteron/fDCAzDeuteron", "fDCAz Deuteron;DCA_{Z};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/Deuteron/fTPCsClsDeuteron", "fTPCsCls Deuteron;TPC Shared Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Deuteron/fTPCcRowsDeuteron", "fTPCcRows Deuteron;TPC Crossed Rows;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Deuteron/fTrkTPCfClsDeuteron", "fTrkTPCfCls Deuteron;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {{500, 0.0f, 3.0f}}); - registry.add("TrackCuts/Deuteron/fTPCnclsDeuteron", "fTPCncls Deuteron;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - - // antideuteron - registry.add("TrackCuts/AntiDeuteron/fPtAntiDeuteron", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/AntiDeuteron/fMomCorAntiDeuteronDif", "Momentum correlation;p_{reco} (GeV/c); (p_{TPC} - p_{reco}) (GeV/c)", {HistType::kTH2F, {{500, 0, 10}, {600, -3, 3}}}); - registry.add("TrackCuts/AntiDeuteron/fMomCorAntiDeuteronRatio", "Momentum correlation;p_{reco} (GeV/c); (p_{TPC} - p_{reco}) (GeV/c)", {HistType::kTH2F, {{500, 0, 10}, {200, -1, 1}}}); - registry.add("TrackCuts/AntiDeuteron/fEtaAntiDeuteron", "Pseudorapidity of all processed tracks;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/AntiDeuteron/fPhiAntiDeuteron", "Azimuthal angle of all processed tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); - registry.add("TrackCuts/AntiDeuteron/fNsigmaTPCvsPAntiDeuteron", "NSigmaTPC AntiDeuteron;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/AntiDeuteron/fNsigmaTOFvsPAntiDeuteron", "NSigmaTOF AntiDeuteron;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/AntiDeuteron/fNsigmaTPCTOFvsPAntiDeuteron", "NSigmaTPCTOF AntiDeuteron;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/AntiDeuteron/fNsigmaTPCvsPAntiDeuteronP", "NSigmaTPC AntiDeuteron vd P;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/AntiDeuteron/fNsigmaTOFvsPAntiDeuteronP", "NSigmaTOF AntiDeuteron P;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/AntiDeuteron/fNsigmaTPCTOFvsPAntiDeuteronP", "NSigmaTPCTOF AntiDeuteron P;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - - registry.add("TrackCuts/AntiDeuteron/fDCAxyAntiDeuteron", "fDCAxy AntiDeuteron;DCA_{XY};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/AntiDeuteron/fDCAzAntiDeuteron", "fDCAz AntiDeuteron;DCA_{Z};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/AntiDeuteron/fTPCsClsAntiDeuteron", "fTPCsCls AntiDeuteron;TPC Shared Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/AntiDeuteron/fTPCcRowsAntiDeuteron", "fTPCcRows AntiDeuteron;TPC Crossed Rows;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/AntiDeuteron/fTrkTPCfClsAntiDeuteron", "fTrkTPCfCls AntiDeuteron;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {{500, 0.0f, 3.0f}}); - registry.add("TrackCuts/AntiDeuteron/fTPCnclsAntiDeuteron", "fTPCncls AntiDeuteron;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - - // lambda before selections - registry.add("TrackCuts/V0Before/fInvMassLambdavsAntiLambda", "Invariant mass of Lambda vs AntiLambda;M_{#pi p};Entries", HistType::kTH2F, {{1000, 1.03, 1.5}, {1000, 1.03, 1.5}}); - registry.add("TrackCuts/V0Before/fPtLambdaBefore", "Transverse momentum of all processed V0s before cuts;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/V0Before/fInvMassLambdaBefore", "Invariant mass of all processed V0s (Lambda) before cuts;M_{#pi p};Entries", HistType::kTH1F, {{1000, 1.03, 1.5}}); - registry.add("TrackCuts/V0Before/fInvMassAntiLambdaBefore", "Invariant mass of all processed V0s (antiLambda) before cuts;M_{#pi p};Entries", HistType::kTH1F, {{1000, 1.03, 1.5}}); - registry.add("TrackCuts/V0Before/fInvMassV0BeforeKaonvsV0Before", "Invariant mass of rejected K0 vs V0s (V0Before);M_{#pi p};;M_{#pi #pi}", HistType::kTH2F, {{1000, 1.03, 1.5}, {1000, 0.3, 0.6}}); - registry.add("TrackCuts/V0Before/fV0DCADaugh", "V0DCADaugh;DCA_{daugh};Entries", HistType::kTH1F, {{1000, -4, 4}}); - registry.add("TrackCuts/V0Before/fV0CPA", "V0 CPA;CPA;Entries", HistType::kTH1F, {{1000, 0.7, 1}}); - registry.add("TrackCuts/V0Before/fV0TranRad", "V0 TranRad;TranRad;Entries", HistType::kTH1F, {{1000, 0, 150}}); - registry.add("TrackCuts/V0Before/f0DecVtxX", "V0 DecVtxX;DecVtX;Entries", HistType::kTH1F, {{1000, 0, 150}}); - registry.add("TrackCuts/V0Before/f0DecVtxY", "V0 DecVtxY;DecVtY;Entries", HistType::kTH1F, {{1000, 0, 150}}); - registry.add("TrackCuts/V0Before/f0DecVtxZ", "V0 DecVtxZ;DecVtz;Entries", HistType::kTH1F, {{1000, 0, 150}}); - - registry.add("TrackCuts/V0Before/PosDaughter/Eta", "V0Before Pos Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/V0Before/PosDaughter/DCAXY", "V0Before Pos Daugh DCAXY;DCA_{XY};Entries", HistType::kTH1F, {{1000, -2.5f, 2.5f}}); - registry.add("TrackCuts/V0Before/PosDaughter/fTPCncls", "V0Before Pos Daugh TPCncls;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/V0Before/NegDaughter/Eta", "V0Before Neg Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/V0Before/NegDaughter/DCAXY", "V0Before Neg Daugh DCAXY;DCA_{XY};Entries", HistType::kTH1F, {{1000, -2.5f, 2.5f}}); - registry.add("TrackCuts/V0Before/NegDaughter/fTPCncls", "V0Before Neg Daugh TPCncls;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/V0Before/PosDaughter/fNsigmaTPCvsPProtonV0Daugh", "NSigmaTPC Proton V0Daught;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/V0Before/NegDaughter/fNsigmaTPCvsPPionMinusV0Daugh", "NSigmaTPC AntiPion V0Daught;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/V0Before/NegDaughter/fNsigmaTPCvsPAntiProtonV0Daugh", "NSigmaTPC Proton V0Daught;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/V0Before/PosDaughter/fNsigmaTPCvsPPionPlusV0Daugh", "NSigmaTPC AntiPion V0Daught;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - - // lambda - registry.add("TrackCuts/Lambda/fPtLambda", "Transverse momentum V0s;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Lambda/fInvMassLambda", "Invariant mass V0s (Lambda);M_{#pi p};Entries", HistType::kTH1F, {{1000, 1.03, 1.5}}); - registry.add("TrackCuts/Lambda/fInvMassLambdaKaonvsLambda", "Invariant mass of rejected K0 vs V0s (Lambda);M_{#pi p};M_{#pi #pi}", HistType::kTH2F, {{1000, 1.03, 1.5}, {1000, 0.3, 0.6}}); - registry.add("TrackCuts/Lambda/fV0DCADaugh", "V0DCADaugh;DCA_{daugh};Entries", HistType::kTH1F, {{1000, -4, 4}}); - registry.add("TrackCuts/Lambda/fV0CPA", "V0 CPA;CPA;Entries", HistType::kTH1F, {{1000, 0.7, 1}}); - registry.add("TrackCuts/Lambda/fV0TranRad", "V0 TranRad;TranRad;Entries", HistType::kTH1F, {{1000, 0, 150}}); - registry.add("TrackCuts/Lambda/f0DecVtxX", "V0 DecVtxX;DecVtX;Entries", HistType::kTH1F, {{1000, 0, 150}}); - registry.add("TrackCuts/Lambda/f0DecVtxY", "V0 DecVtxY;DecVtY;Entries", HistType::kTH1F, {{1000, 0, 150}}); - registry.add("TrackCuts/Lambda/f0DecVtxZ", "V0 DecVtxZ;DecVtZ;Entries", HistType::kTH1F, {{1000, 0, 150}}); - - // Lambda daughter - registry.add("TrackCuts/Lambda/PosDaughter/Eta", "Lambda Pos Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Lambda/PosDaughter/DCAXY", "Lambda Pos Daugh DCAXY;DCA_{XY};Entries", HistType::kTH1F, {{1000, -2.5f, 2.5f}}); - registry.add("TrackCuts/Lambda/PosDaughter/fTPCncls", "Lambda Pos Daugh TPCncls;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Lambda/NegDaughter/Eta", "Lambda Neg Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Lambda/NegDaughter/DCAXY", "Lambda Neg Daugh DCAXY;DCA_{XY};Entries", HistType::kTH1F, {{1000, -2.5f, 2.5f}}); - registry.add("TrackCuts/Lambda/NegDaughter/fTPCncls", "Lambda Neg Daugh TPCncls;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Lambda/PosDaughter/fNsigmaTPCvsPProtonV0Daugh", "NSigmaTPC Proton V0Daught;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Lambda/NegDaughter/fNsigmaTPCvsPPionMinusV0Daugh", "NSigmaTPC AntiPion V0Daught;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - - // antilambda - registry.add("TrackCuts/AntiLambda/fPtAntiLambda", "Transverse momentum V0s;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/AntiLambda/fInvMassAntiLambda", "Invariant mass V0s (Lambda);M_{#pi p};Entries", HistType::kTH1F, {{1000, 1.03, 1.5}}); - registry.add("TrackCuts/AntiLambda/fInvMassAntiLambdaKaonvsAntiLambda", "Invariant mass of rejected K0 vs V0s (Lambda);M_{#pi p};M_{#pi #pi}", HistType::kTH2F, {{1000, 1.03, 1.5}, {1000, 0.3, 0.6}}); - registry.add("TrackCuts/AntiLambda/fV0DCADaugh", "V0DCADaugh;DCA_{daugh};Entries", HistType::kTH1F, {{1000, -4, 4}}); - registry.add("TrackCuts/AntiLambda/fV0CPA", "V0 CPA;CPA;Entries", HistType::kTH1F, {{1000, 0.7, 1}}); - registry.add("TrackCuts/AntiLambda/fV0TranRad", "V0 TranRad;TranRad;Entries", HistType::kTH1F, {{1000, 0, 150}}); - registry.add("TrackCuts/AntiLambda/f0DecVtxX", "V0 DecVtxX;DecVtX;Entries", HistType::kTH1F, {{1000, 0, 150}}); - registry.add("TrackCuts/AntiLambda/f0DecVtxY", "V0 DecVtxY;DecVtY;Entries", HistType::kTH1F, {{1000, 0, 150}}); - registry.add("TrackCuts/AntiLambda/f0DecVtxZ", "V0 DecVtxZ;DecVtZ;Entries", HistType::kTH1F, {{1000, 0, 150}}); - - // AntiLambda daughter - registry.add("TrackCuts/AntiLambda/PosDaughter/Eta", "AntiLambda Pos Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/AntiLambda/PosDaughter/DCAXY", "AntiLambda Pos Daugh DCAXY;DCA_{XY};Entries", HistType::kTH1F, {{1000, -2.5f, 2.5f}}); - registry.add("TrackCuts/AntiLambda/PosDaughter/fTPCncls", "AntiLambda Pos Daugh TPCncls;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/AntiLambda/NegDaughter/Eta", "AntiLambda Neg Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/AntiLambda/NegDaughter/DCAXY", "AntiLambda Neg Daugh DCAXY;DCA_{XY};Entries", HistType::kTH1F, {{1000, -2.5f, 2.5f}}); - registry.add("TrackCuts/AntiLambda/NegDaughter/fTPCncls", "AntiLambda Neg Daugh TPCncls;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/AntiLambda/NegDaughter/fNsigmaTPCvsPAntiProtonAntiV0Daugh", "NSigmaTPC AntiProton antiV0Daught;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/AntiLambda/PosDaughter/fNsigmaTPCvsPPionPlusAntiV0Daugh", "NSigmaTPC Pion antiV0Daught;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - - // Phi - - registry.add("TrackCuts/Phi/Before/fInvMass", "Invariant mass V0s;M_{KK};Entries", HistType::kTH1F, {{7000, 0.8, 1.5}}); - registry.add("TrackCuts/Phi/Before/fPt", "Transverse momentum V0s;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/Before/fEta", "Pseudorapidity of V0;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Phi/Before/fPhi", "Azimuthal angle of V0;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); - - registry.add("TrackCuts/Phi/Before/PosDaughter/fP", "Momentum of Kaons at PV;p (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fPTPC", "Momentum of Kaons at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fPt", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fMomCorDif", "Momentum correlation;p_{reco} (GeV/c); (p_{TPC} - p_{reco}) (GeV/c)", {HistType::kTH2F, {{500, 0, 10}, {600, -3, 3}}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fMomCorRatio", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {{500, 0, 10}, {200, -1, 1}}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fEta", "Pseudorapidity of all processed tracks;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fPhi", "Azimuthal angle of all processed tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fNsigmaTPCvsP", "NSigmaTPC Kaon;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fNsigmaTOFvsP", "NSigmaTOF Kaon;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fNsigmaTPCTOFvsP", "NSigmaTPCTOF Kaon;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fDCAxy", "fDCAxy Kaon;DCA_{XY};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fDCAz", "fDCAz Kaon;DCA_{Z};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fTPCsCls", "fTPCsCls Kaon;TPC Shared Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fTPCcRows", "fTPCcRows Kaon;TPC Crossed Rows;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fTrkTPCfCls", "fTrkTPCfCls Kaon;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {{500, 0.0f, 3.0f}}); - registry.add("TrackCuts/Phi/Before/PosDaughter/fTPCncls", "fTPCncls Kaon;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - - registry.add("TrackCuts/Phi/Before/NegDaughter/fP", "Momentum of Kaons at PV;p (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fPTPC", "Momentum of Kaons at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fPt", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fMomCorDif", "Momentum correlation;p_{reco} (GeV/c); (p_{TPC} - p_{reco}) (GeV/c)", {HistType::kTH2F, {{500, 0, 10}, {600, -3, 3}}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fMomCorRatio", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {{500, 0, 10}, {200, -1, 1}}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fEta", "Pseudorapidity of all processed tracks;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fPhi", "Azimuthal angle of all processed tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fNsigmaTPCvsP", "NSigmaTPC Kaon;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fNsigmaTOFvsP", "NSigmaTOF Kaon;p_{TPC} (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fNsigmaTPCTOFvsP", "NSigmaTPCTOF Kaon;p_{TPC} (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fDCAxy", "fDCAxy Kaon;DCA_{XY};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fDCAz", "fDCAz Kaon;DCA_{Z};Entries", HistType::kTH1F, {{500, -0.5f, 0.5f}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fTPCsCls", "fTPCsCls Kaon;TPC Shared Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fTPCcRows", "fTPCcRows Kaon;TPC Crossed Rows;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fTrkTPCfCls", "fTrkTPCfCls Kaon;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {{500, 0.0f, 3.0f}}); - registry.add("TrackCuts/Phi/Before/NegDaughter/fTPCncls", "fTPCncls Kaon;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); - - registry.add("TrackCuts/Phi/After/fInvMass", "Invariant mass V0s;M_{KK};Entries", HistType::kTH1F, {{7000, 0.8, 1.5}}); - registry.add("TrackCuts/Phi/After/fPt", "Transverse momentum V0s;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/After/fEta", "Pseudorapidity of V0;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Phi/After/fPhi", "Azimuthal angle of V0;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); - - // phi daughter - registry.add("TrackCuts/Phi/After/PosDaughter/fPt", "Transverse momentum Pos Daugh tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/After/PosDaughter/fEta", "Phi Pos Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Phi/After/PosDaughter/fPhi", "Azimuthal angle of Pos Daugh tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); - - registry.add("TrackCuts/Phi/After/NegDaughter/fPt", "Transverse momentum Neg Daugh tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); - registry.add("TrackCuts/Phi/After/NegDaughter/fEta", "Phi Neg Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Phi/After/NegDaughter/fPhi", "Azimuthal angle of Neg Daugh tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); + registryParticleQA.add("TrackQA/After/AntiProton/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/AntiProton/fPTpc", "Momentum at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/AntiProton/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/After/AntiProton/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/After/AntiProton/fPhi", "Azimuthal angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + registryParticleQA.add("TrackQA/After/AntiProton/fNsigmaIts", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiProton/fNsigmaTpc", "NSigmaTPC;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiProton/fNsigmaTof", "NSigmaTOF;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiProton/fNsigmaTpcTof", "NSigmaTPCTOF;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/After/AntiProton/fItsSignal", "ITS Signal;p (GeV/c); (cm)", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/After/AntiProton/fTpcSignal", "TPC Signal;p (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/After/AntiProton/fTofBeta", "TOF #beta;p (GeV/c);#beta_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); + + registryParticleQA.add("TrackQA/After/AntiProton/fDcaXy", "DCA_{xy};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("TrackQA/After/AntiProton/fDcaZ", "DCA_{z};p_{T} (GeV/c); DCA_{Z};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + + registryParticleQA.add("TrackQA/After/AntiProton/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiProton/fTpcCrossedRows", "TPC Crossed Rows;TPC Crossed Rows;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiProton/fTpcSharedClusters", "TPC Shared Clusters;TPC Shared Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiProton/fTpcSharedClusterOverClusterss", "TPC Shared Clusters/Clusters;TPC Shared Clusters/Clusters;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/AntiProton/fTpcFindableOverRows", "TPC Findabled/Crossed Rows;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/AntiProton/fTpcChi2OverCluster", "TPC #chi^{2}/Cluster;TPC #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.tpcChi2}); + + registryParticleQA.add("TrackQA/After/AntiProton/fItsClusters", "ITS Clusters;ITS Clusters;Entries", HistType::kTH1F, {Binning.itsCluster}); + registryParticleQA.add("TrackQA/After/AntiProton/fItsIbClusters", "ITS Inner Barrel Clusters;ITS Inner Barrel Clusters;Entries", HistType::kTH1F, {Binning.itsIbCluster}); + registryParticleQA.add("TrackQA/After/AntiProton/fItsChi2OverCluster", "ITS #chi^{2}/Cluster;ITS #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.itsChi2}); + + // Deuteron + registryParticleQA.add("TrackQA/After/Deuteron/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/Deuteron/fPTpc", "Momentum at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/Deuteron/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/After/Deuteron/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/After/Deuteron/fPhi", "Azimuthal angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + registryParticleQA.add("TrackQA/After/Deuteron/fNsigmaIts", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Deuteron/fNsigmaTpc", "NSigmaTPC;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Deuteron/fNsigmaTof", "NSigmaTOF;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/Deuteron/fNsigmaTpcTof", "NSigmaTPCTOF;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/After/Deuteron/fItsSignal", "ITS Signal;p (GeV/c); (cm)", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/After/Deuteron/fTpcSignal", "TPC Signal;p (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/After/Deuteron/fTofBeta", "TOF #beta;p (GeV/c);#beta_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); + + registryParticleQA.add("TrackQA/After/Deuteron/fDcaXy", "DCA_{xy};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("TrackQA/After/Deuteron/fDcaZ", "DCA_{z};p_{T} (GeV/c); DCA_{Z};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + + registryParticleQA.add("TrackQA/After/Deuteron/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Deuteron/fTpcCrossedRows", "TPC Crossed Rows;TPC Crossed Rows;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Deuteron/fTpcSharedClusters", "TPC Shared Clusters;TPC Shared Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/Deuteron/fTpcSharedClusterOverClusterss", "TPC Shared Clusters/Clusters;TPC Shared Clusters/Clusters;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/Deuteron/fTpcFindableOverRows", "TPC Findabled/Crossed Rows;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/Deuteron/fTpcChi2OverCluster", "TPC #chi^{2}/Cluster;TPC #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.tpcChi2}); + + registryParticleQA.add("TrackQA/After/Deuteron/fItsClusters", "ITS Clusters;ITS Clusters;Entries", HistType::kTH1F, {Binning.itsCluster}); + registryParticleQA.add("TrackQA/After/Deuteron/fItsIbClusters", "ITS Inner Barrel Clusters;ITS Inner Barrel Clusters;Entries", HistType::kTH1F, {Binning.itsIbCluster}); + registryParticleQA.add("TrackQA/After/Deuteron/fItsChi2OverCluster", "ITS #chi^{2}/Cluster;ITS #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.itsChi2}); + + // AntiDeuteron + registryParticleQA.add("TrackQA/After/AntiDeuteron/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fPTpc", "Momentum at TPC inner wall;p_{TPC} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fMomCor", "Momentum correlation;p_{reco} (GeV/c); p_{TPC} - p_{reco} / p_{reco}", {HistType::kTH2F, {Binning.momentum, Binning.momCor}}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fPhi", "Azimuthal angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + registryParticleQA.add("TrackQA/After/AntiDeuteron/fNsigmaIts", "NSigmaITS;p (GeV/c);n#sigma_{ITS}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fNsigmaTpc", "NSigmaTPC;p (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fNsigmaTof", "NSigmaTOF;p (GeV/c);n#sigma_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fNsigmaTpcTof", "NSigmaTPCTOF;p (GeV/c);n#sigma_{comb}", {HistType::kTH2F, {Binning.momentum, Binning.nsigmaComb}}); + + registryParticleQA.add("TrackQA/After/AntiDeuteron/fItsSignal", "ITS Signal;p (GeV/c); (cm)", {HistType::kTH2F, {Binning.momentum, Binning.itsSignal}}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fTpcSignal", "TPC Signal;p (GeV/c);TPC Signal", {HistType::kTH2F, {Binning.momentum, Binning.tpcSignal}}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fTofBeta", "TOF #beta;p (GeV/c);#beta_{TOF}", {HistType::kTH2F, {Binning.momentum, Binning.tofSignal}}); + + registryParticleQA.add("TrackQA/After/AntiDeuteron/fDcaXy", "DCA_{xy};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fDcaZ", "DCA_{z};p_{T} (GeV/c); DCA_{Z};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + + registryParticleQA.add("TrackQA/After/AntiDeuteron/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fTpcCrossedRows", "TPC Crossed Rows;TPC Crossed Rows;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fTpcSharedClusters", "TPC Shared Clusters;TPC Shared Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fTpcSharedClusterOverClusterss", "TPC Shared Clusters/Clusters;TPC Shared Clusters/Clusters;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fTpcFindableOverRows", "TPC Findabled/Crossed Rows;TPC Findable/CrossedRows;Entries", HistType::kTH1F, {Binning.ratio}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fTpcChi2OverCluster", "TPC #chi^{2}/Cluster;TPC #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.tpcChi2}); + + registryParticleQA.add("TrackQA/After/AntiDeuteron/fItsClusters", "ITS Clusters;ITS Clusters;Entries", HistType::kTH1F, {Binning.itsCluster}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fItsIbClusters", "ITS Inner Barrel Clusters;ITS Inner Barrel Clusters;Entries", HistType::kTH1F, {Binning.itsIbCluster}); + registryParticleQA.add("TrackQA/After/AntiDeuteron/fItsChi2OverCluster", "ITS #chi^{2}/Cluster;ITS #chi^{2}/Cluster;Entries", HistType::kTH1F, {Binning.itsChi2}); + + // Lambda before + registryParticleQA.add("LambdaQA/Before/fPt", "Transverse momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("LambdaQA/Before/fEta", "Psedurapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("LambdaQA/Before/fPhi", "Azimuthal Angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("LambdaQA/Before/fInvMassLambda", "Invariant mass Lambda;M_{#pi p};Entries", HistType::kTH1F, {Binning.invMassLambda}); + registryParticleQA.add("LambdaQA/Before/fInvMassAntiLambda", "Invariant mass AntiLambda;M_{#pi p};Entries", HistType::kTH1F, {Binning.invMassLambda}); + registryParticleQA.add("LambdaQA/Before/fInvMassLambdaVsAntiLambda", "Invariant mass of Lambda vs AntiLambda;M_{#pi p};Entries", HistType::kTH2F, {Binning.invMassLambda, Binning.invMassLambda}); + registryParticleQA.add("LambdaQA/Before/fInvMassLambdaVsKaon", "Invariant mass of Lambda vs K0;M_{#pi p};;M_{#pi #pi}", HistType::kTH2F, {Binning.invMassLambda, Binning.invMassK0short}); + registryParticleQA.add("LambdaQA/Before/fInvMassAntiLambdaVsKaon", "Invariant mass of AntiLambda vs K0;M_{#pi p};;M_{#pi #pi}", HistType::kTH2F, {Binning.invMassLambda, Binning.invMassK0short}); + registryParticleQA.add("LambdaQA/Before/fDcaDaugh", "DCA_{Daugh};DCA_{daugh};Entries", HistType::kTH1F, {Binning.dcaDaugh}); + registryParticleQA.add("LambdaQA/Before/fCpa", "Cosine of pointing angle;CPA;Entries", HistType::kTH1F, {Binning.cpa}); + registryParticleQA.add("LambdaQA/Before/fTranRad", "Transverse Radisu;TranRad;Entries", HistType::kTH1F, {Binning.transRad}); + registryParticleQA.add("LambdaQA/Before/fDecVtx", "Decay vertex displacement;DecVtx;Entries", HistType::kTH1F, {Binning.decayVtx}); + registryParticleQA.add("LambdaQA/Before/PosDaughter/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("LambdaQA/Before/PosDaughter/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("LambdaQA/Before/PosDaughter/fPhi", "Azimuthal Angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("LambdaQA/Before/PosDaughter/fDcaXy", "DCA_{XY};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("LambdaQA/Before/PosDaughter/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("LambdaQA/Before/PosDaughter/fNsigmaTpcProton", "NSigmaTPC Proton;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("LambdaQA/Before/PosDaughter/fNsigmaTpcPion", "NSigmaTPC Pion;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("LambdaQA/Before/NegDaughter/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("LambdaQA/Before/NegDaughter/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("LambdaQA/Before/NegDaughter/fPhi", "Azimuthal Angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("LambdaQA/Before/NegDaughter/fDcaXy", "DCA_{XY};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("LambdaQA/Before/NegDaughter/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("LambdaQA/Before/NegDaughter/fNsigmaTpcProton", "NSigmaTPC AnitProton;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("LambdaQA/Before/NegDaughter/fNsigmaTpcPion", "NSigmaTPC AntiPion;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + + // Lambda after + registryParticleQA.add("LambdaQA/After/Lambda/fPt", "Transverse momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("LambdaQA/After/Lambda/fEta", "Psedurapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("LambdaQA/After/Lambda/fPhi", "Azimuthal Angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("LambdaQA/After/Lambda/fInvMass", "Invariant mass;M_{#pi p};Entries", HistType::kTH1F, {Binning.invMassLambda}); + registryParticleQA.add("LambdaQA/After/Lambda/fInvMassLambdaVsAntiLambda", "Invariant mass of Lambda vs AntiLambda;M_{#pi p};Entries", HistType::kTH2F, {Binning.invMassLambda, Binning.invMassLambda}); + registryParticleQA.add("LambdaQA/After/Lambda/fInvMassLambdaVsKaon", "Invariant mass of rejected K0 vs V0s;M_{#pi p};;M_{#pi #pi}", HistType::kTH2F, {Binning.invMassLambda, Binning.invMassK0short}); + registryParticleQA.add("LambdaQA/After/Lambda/fDcaDaugh", "DCA_{Daugh};DCA_{daugh};Entries", HistType::kTH1F, {Binning.dcaDaugh}); + registryParticleQA.add("LambdaQA/After/Lambda/fCpa", "Cosine of pointing angle;CPA;Entries", HistType::kTH1F, {Binning.cpa}); + registryParticleQA.add("LambdaQA/After/Lambda/fTranRad", "Transverse Radisu;TranRad;Entries", HistType::kTH1F, {Binning.transRad}); + registryParticleQA.add("LambdaQA/After/Lambda/fDecVtx", "Decay vertex displacement;DecVtx;Entries", HistType::kTH1F, {Binning.decayVtx}); + registryParticleQA.add("LambdaQA/After/Lambda/PosDaughter/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("LambdaQA/After/Lambda/PosDaughter/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("LambdaQA/After/Lambda/PosDaughter/fPhi", "Azimuthal Angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("LambdaQA/After/Lambda/PosDaughter/fDcaXy", "DCA_{XY};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("LambdaQA/After/Lambda/PosDaughter/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("LambdaQA/After/Lambda/PosDaughter/fNsigmaTpc", "NSigmaTPC Proton;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("LambdaQA/After/Lambda/NegDaughter/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("LambdaQA/After/Lambda/NegDaughter/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("LambdaQA/After/Lambda/NegDaughter/fPhi", "Azimuthal Angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("LambdaQA/After/Lambda/NegDaughter/fDcaXy", "DCA_{XY};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("LambdaQA/After/Lambda/NegDaughter/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("LambdaQA/After/Lambda/NegDaughter/fNsigmaTpc", "NSigmaTPC AntiPion;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + + // AntiLambda after + registryParticleQA.add("LambdaQA/After/AntiLambda/fPt", "Transverse momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("LambdaQA/After/AntiLambda/fEta", "Psedurapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("LambdaQA/After/AntiLambda/fPhi", "Azimuthal Angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("LambdaQA/After/AntiLambda/fInvMass", "Invariant mass;M_{#pi p};Entries", HistType::kTH1F, {Binning.invMassLambda}); + registryParticleQA.add("LambdaQA/After/AntiLambda/fInvMassAntiLambdaVsLambda", "Invariant mass of Lambda vs AntiLambda;M_{#pi p};Entries", HistType::kTH2F, {Binning.invMassLambda, Binning.invMassLambda}); + registryParticleQA.add("LambdaQA/After/AntiLambda/fInvMassAntiLambdaVsKaon", "Invariant mass of rejected K0 vs V0s;M_{#pi p};;M_{#pi #pi}", HistType::kTH2F, {Binning.invMassLambda, Binning.invMassK0short}); + registryParticleQA.add("LambdaQA/After/AntiLambda/fDcaDaugh", "DCA_{Daugh};DCA_{daugh};Entries", HistType::kTH1F, {Binning.dcaDaugh}); + registryParticleQA.add("LambdaQA/After/AntiLambda/fCpa", "Cosine of pointing angle;CPA;Entries", HistType::kTH1F, {Binning.cpa}); + registryParticleQA.add("LambdaQA/After/AntiLambda/fTranRad", "Transverse Radisu;TranRad;Entries", HistType::kTH1F, {Binning.transRad}); + registryParticleQA.add("LambdaQA/After/AntiLambda/fDecVtx", "Decay vertex displacement;DecVtx;Entries", HistType::kTH1F, {Binning.decayVtx}); + registryParticleQA.add("LambdaQA/After/AntiLambda/PosDaughter/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("LambdaQA/After/AntiLambda/PosDaughter/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("LambdaQA/After/AntiLambda/PosDaughter/fPhi", "Azimuthal Angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("LambdaQA/After/AntiLambda/PosDaughter/fDcaXy", "DCA_{XY};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("LambdaQA/After/AntiLambda/PosDaughter/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("LambdaQA/After/AntiLambda/PosDaughter/fNsigmaTpc", "NSigmaTPC Proton;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + registryParticleQA.add("LambdaQA/After/AntiLambda/NegDaughter/fPt", "Transverse Momentum;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("LambdaQA/After/AntiLambda/NegDaughter/fEta", "Pseudorapidity;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("LambdaQA/After/AntiLambda/NegDaughter/fPhi", "Azimuthal Angle;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + registryParticleQA.add("LambdaQA/After/AntiLambda/NegDaughter/fDcaXy", "DCA_{XY};p_{T} (GeV/c); DCA_{XY};Entries", HistType::kTH2F, {Binning.momentum, Binning.dca}); + registryParticleQA.add("LambdaQA/After/AntiLambda/NegDaughter/fTpcClusters", "TPC Clusters;TPC Clusters;Entries", HistType::kTH1F, {Binning.tpcCluster}); + registryParticleQA.add("LambdaQA/After/AntiLambda/NegDaughter/fNsigmaTpc", "NSigmaTPC AntiPion;p_{TPC} (GeV/c);n#sigma_{TPC}", {HistType::kTH2F, {Binning.momentum, Binning.nsigma}}); + + // Phi before + registryParticleQA.add("PhiQA/Before/fInvMass", "Invariant mass #phi;M_{KK};Entries", HistType::kTH1F, {Binning.invMassPhi}); + registryParticleQA.add("PhiQA/Before/fPt", "Transverse momentum #phi;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("PhiQA/Before/fEta", "Pseudorapidity of V0;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("PhiQA/Before/fPhi", "Azimuthal angle of #phi;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + // Phi after + registryParticleQA.add("PhiQA/After/fInvMass", "Invariant mass #phi;M_{KK};Entries", HistType::kTH1F, {Binning.invMassPhi}); + registryParticleQA.add("PhiQA/After/fPt", "Transverse momentum #phi;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("PhiQA/After/fEta", "Pseudorapidity of #phi;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("PhiQA/After/fPhi", "Azimuthal angle of #Phi;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + // Rho before + registryParticleQA.add("RhoQA/Before/fInvMass", "Invariant mass #rho;M_{#pi#pi};Entries", HistType::kTH1F, {Binning.invMassRho}); + registryParticleQA.add("RhoQA/Before/fPt", "Transverse momentum #rho;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("RhoQA/Before/fEta", "Pseudorapidity of #rho;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("RhoQA/Before/fPhi", "Azimuthal angle of #rho;#varphi;Entries", HistType::kTH1F, {Binning.phi}); + + // Rho after + registryParticleQA.add("RhoQA/After/fInvMass", "Invariant mass #rho;M_{#pi#pi};Entries", HistType::kTH1F, {Binning.invMassRho}); + registryParticleQA.add("RhoQA/After/fPt", "Transverse momentum #rho;p_{T} (GeV/c);Entries", HistType::kTH1F, {Binning.momentum}); + registryParticleQA.add("RhoQA/After/fEta", "Pseudorapidity of #rho;#eta;Entries", HistType::kTH1F, {Binning.eta}); + registryParticleQA.add("RhoQA/After/fPhi", "Azimuthal angle of #rho;#phi;Entries", HistType::kTH1F, {Binning.phi}); // for ppp - registry.add("ppp/fMultiplicity", "Multiplicity of all processed events;Mult;Entries", HistType::kTH1F, {{1000, 0, 1000}}); - registry.add("ppp/fZvtx", "Zvtx of all processed events;Z_{vtx};Entries", HistType::kTH1F, {{1000, -15, 15}}); - registry.add("ppp/fSE_particle", "Same Event distribution", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppp/fSE_particle_downsample", "Same Event distribution (downsampled)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppp/fSE_antiparticle", "Same Event distribution", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppp/fSE_antiparticle_downsample", "Same Event distribution (downsampled)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppp/fProtonPtVsQ3", "pT (proton) vs Q_{3};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("ppp/fAntiProtonPtVsQ3", "pT (antiproton) vs Q_{3};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); + registryTriggerQA.add("PPP/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPP/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPP/all/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPP/all/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPP/all/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPP/all/fAntiProtonQ3VsPt", "Q_{3} vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPP/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPP/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPP/loose/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPP/loose/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPP/loose/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPP/loose/fAntiProtonQ3VsPt", "Q_{3} vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPP/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPP/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPP/tight/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPP/tight/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPP/tight/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPP/tight/fAntiProtonQ3VsPt", "Q_{3} vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); // for ppl - registry.add("ppl/fMultiplicity", "Multiplicity of all processed events;Mult;Entries", HistType::kTH1F, {{1000, 0, 1000}}); - registry.add("ppl/fZvtx", "Zvtx of all processed events;Z_{vtx};Entries", HistType::kTH1F, {{1000, -15, 15}}); - registry.add("ppl/fSE_particle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppl/fSE_particle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppl/fSE_antiparticle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppl/fSE_antiparticle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppl/fProtonPtVsQ3", "pT (proton) vs Q_{3};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("ppl/fAntiProtonPtVsQ3", "pT (proton) vs Q_{3};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("ppl/fLambdaPtVsQ3", "pT (lambda) vs Q_{3};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("ppl/fAntiLambdaPtVsQ3", "pT (antilambda) vs Q_{3};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); + registryTriggerQA.add("PPL/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPL/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPL/all/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPL/all/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPL/all/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/all/fAntiProtonQ3VsPt", "Q_{3} vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/all/fLambdaQ3VsPt", "Q_{3} vs Lambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/all/fAntiLambdaQ3VsPt", "Q_{3} vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPL/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPL/loose/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPL/loose/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPL/loose/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/loose/fAntiProtonQ3VsPt", "Q_{3} vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/loose/fLambdaQ3VsPt", "Q_{3} vs Lambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/loose/fAntiLambdaQ3VsPt", "Q_{3} vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPL/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPL/tight/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPL/tight/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPL/tight/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/tight/fAntiProtonQ3VsPt", "Q_{3} vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/tight/fLambdaQ3VsPt", "Q_{3} vs Lambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PPL/tight/fAntiLambdaQ3VsPt", "Q_{3} vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); // for pll - registry.add("pll/fMultiplicity", "Multiplicity of all processed events;Mult;Entries", HistType::kTH1F, {{1000, 0, 1000}}); - registry.add("pll/fZvtx", "Zvtx of all processed events;Z_{vtx};Entries", HistType::kTH1F, {{1000, -15, 15}}); - registry.add("pll/fSE_particle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("pll/fSE_particle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("pll/fSE_antiparticle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("pll/fSE_antiparticle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("pll/fProtonPtVsQ3", "Q3 vs pT (proton)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("pll/fAntiProtonPtVsQ3", "Q3 vs pT (antiproton)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("pll/fLambdaPtVsQ3", "Q3 vs pT (lambda)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("pll/fAntiLambdaPtVsQ3", "Q3 vs pT (antilambda)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); + registryTriggerQA.add("PLL/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PLL/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PLL/all/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PLL/all/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PLL/all/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/all/fAntiProtonQ3VsPt", "Q3 vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/all/fLambdaQ3VsPt", "Q3 vs Lambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/all/fAntiLambdaQ3VsPt", "Q3 vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PLL/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PLL/loose/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PLL/loose/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PLL/loose/fProtonQ3VsPt", "Q3 vs pT vs Proton p;Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/loose/fAntiProtonQ3VsPt", "Q3 vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/loose/fLambdaQ3VsPt", "Q3 vs Lambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/loose/fAntiLambdaQ3VsPt", "Q3 vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PLL/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PLL/tight/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PLL/tight/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PLL/tight/fProtonQ3VsPt", "Q3 vs pT vs Proton p;Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/tight/fAntiProtonQ3VsPt", "Q3 vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/tight/fLambdaQ3VsPt", "Q3 vs Lambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("PLL/tight/fAntiLambdaQ3VsPt", "Q3 vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); // for lll - registry.add("lll/fMultiplicity", "Multiplicity of all processed events;Mult;Entries", HistType::kTH1F, {{1000, 0, 1000}}); - registry.add("lll/fZvtx", "Zvtx of all processed events;Z_{vtx};Entries", HistType::kTH1F, {{1000, -15, 15}}); - registry.add("lll/fSE_particle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("lll/fSE_particle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("lll/fSE_antiparticle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("lll/fSE_antiparticle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("lll/fLambdaPtVsQ3", "Q3 vs pT (lambda)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("lll/fAntiLambdaPtVsQ3", "Q3 vs pT (antilambda)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); + registryTriggerQA.add("LLL/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("LLL/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("LLL/all/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("LLL/all/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("LLL/all/fLambdaQ3VsPt", "Q3 vs Lambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("LLL/all/fAntiLambdaQ3VsPt", "Q3 vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("LLL/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("LLL/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("LLL/loose/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("LLL/loose/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("LLL/loose/fLambdaQ3VsPt", "Q3 vs Lambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("LLL/loose/fAntiLambdaQ3VsPt", "Q3 vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("LLL/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("LLL/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("LLL/tight/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("LLL/tight/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("LLL/tight/fLambdaQ3VsPt", "Q3 vs Lambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); + registryTriggerQA.add("LLL/tight/fAntiLambdaQ3VsPt", "Q3 vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.q3, Binning.momentum}}); // for ppPhi - registry.add("ppphi/fMultiplicity", "Multiplicity of all triggered events;Mult;Entries", HistType::kTH1F, {{1000, 0, 1000}}); - registry.add("ppphi/fZvtx", "Zvtx of all triggered events;Z_{vtx};Entries", HistType::kTH1F, {{1000, -15, 15}}); - registry.add("ppphi/fSE_particle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppphi/fSE_particle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppphi/fSE_antiparticle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppphi/fSE_antiparticle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppphi/fProtonPtVsQ3", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppphi/fPhiPtVsQ3", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppphi/fAntiProtonPtVsQ3", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ppphi/fAntiPhiPtVsQ3", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); + registryTriggerQA.add("PPPhi/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPPhi/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPPhi/all/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPPhi/all/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPPhi/all/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPPhi/all/fAntiProtonQ3VsPt", "Q3 vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPPhi/all/fPhiQ3VsPt", "Q_{3} vs #phi p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPPhi/all/fPhiQ3VsInvMass", "Q_{3} vs #phi mass;Q_{3} (GeV/c);M_{K^{+}K^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.q3, Binning.invMassPhi}); + registryTriggerQA.add("PPPhi/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPPhi/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPPhi/loose/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPPhi/loose/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPPhi/loose/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPPhi/loose/fAntiProtonQ3VsPt", "Q3 vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPPhi/loose/fPhiQ3VsPt", "Q_{3} vs #phi p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPPhi/loose/fPhiQ3VsInvMass", "Q_{3} vs #phi mass;Q_{3} (GeV/c);M_{K^{+}K^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.q3, Binning.invMassPhi}); + registryTriggerQA.add("PPPhi/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPPhi/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPPhi/tight/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPPhi/tight/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);Entries", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPPhi/tight/fProtonQ3VsPt", "Q_{3} vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPPhi/tight/fAntiProtonQ3VsPt", "Q3 vs AntiLambda p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPPhi/tight/fPhiQ3VsPt", "Q_{3} vs #phi p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPPhi/tight/fPhiQ3VsInvMass", "Q_{3} vs #phi mass;Q_{3} (GeV/c);M_{K^{+}K^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.q3, Binning.invMassPhi}); + + // for ppRho + registryTriggerQA.add("PPRho/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPRho/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPRho/all/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPRho/all/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPRho/all/fProtonQ3VsPt", "Q3 vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPRho/all/fAntiProtonQ3VsPt", "Q3 vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPRho/all/fRhoQ3VsPt", "Q3 vs #rho p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPRho/all/fRhoQ3VsInvMass", "Q_{3} vs #rho mass;Q_{3} (GeV/c);M_{#pi^{+}#pi^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.q3, Binning.invMassRho}); + registryTriggerQA.add("PPRho/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPRho/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPRho/loose/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPRho/loose/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPRho/loose/fProtonQ3VsPt", "Q3 vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPRho/loose/fAntiProtonQ3VsPt", "Q3 vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPRho/loose/fRhoQ3VsPt", "Q3 vs #rho p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPRho/loose/fRhoQ3VsInvMass", "Q_{3} vs #rho mass;Q_{3} (GeV/c);M_{#pi^{+}#pi^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.q3, Binning.invMassRho}); + registryTriggerQA.add("PPRho/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PPRho/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PPRho/tight/fSE_particle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPRho/tight/fSE_antiparticle", "Same Event distribution;Q_{3} (GeV/c);SE", HistType::kTH1F, {Binning.q3}); + registryTriggerQA.add("PPRho/tight/fProtonQ3VsPt", "Q3 vs Proton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPRho/tight/fAntiProtonQ3VsPt", "Q3 vs AntiProton p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPRho/tight/fRhoQ3VsPt", "Q3 vs #rho p_{T};Q_{3} (GeV/c);p_{T} (GeV/c)", HistType::kTH2F, {Binning.q3, Binning.momentum}); + registryTriggerQA.add("PPRho/tight/fRhoQ3VsInvMass", "Q_{3} vs #rho mass;Q_{3} (GeV/c);M_{#pi^{+}#pi^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.q3, Binning.invMassRho}); // for pd - registry.add("pd/fMultiplicity", "Multiplicity of all processed events;Mult;Entries", HistType::kTH1F, {{1000, 0, 1000}}); - registry.add("pd/fZvtx", "Zvtx of all processed events;Z_{vtx};Entries", HistType::kTH1F, {{1000, -15, 15}}); - registry.add("pd/fSE_particle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("pd/fSE_particle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("pd/fSE_antiparticle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("pd/fSE_antiparticle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("pd/fProtonPtVskstar", "pT (proton) vs k^{*};k^{*} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("pd/fAntiProtonPtVskstar", "pT (antiproton) vs k^{*};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("pd/fDeuteronPtVskstar", "pT (deuteron) vs k^{*};k^{*} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("pd/fAntiDeuteronPtVskstar", "pT (antideuteron) vs k^{*};k^{*} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); + registryTriggerQA.add("PD/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PD/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PD/all/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PD/all/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PD/all/fProtonKstarVsPt", "k* vs Proton p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/all/fAntiProtonKstarVsPt", "k* vs AntiProton p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/all/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/all/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PD/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PD/loose/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PD/loose/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PD/loose/fProtonKstarVsPt", "k* vs Proton p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/loose/fAntiProtonKstarVsPt", "k* vs AntiProton p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/loose/fDeuteronKstarVsPt", "k* Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/loose/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PD/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PD/tight/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PD/tight/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PD/tight/fProtonKstarVsPt", "k* vs Proton p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/tight/fAntiProtonKstarVsPt", "k* vs AntiProton p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/tight/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PD/tight/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); // for ld - registry.add("ld/fMultiplicity", "Multiplicity of all processed events", HistType::kTH1F, {{1000, 0, 1000}}); - registry.add("ld/fZvtx", "Zvtx of all processed events;Z_{vtx};Entries", HistType::kTH1F, {{1000, -15, 15}}); - registry.add("ld/fSE_particle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ld/fSE_particle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ld/fSE_antiparticle", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ld/fSE_antiparticle_downsample", "Same Event distribution;SE;Q_{3} (GeV/c)", HistType::kTH1F, {{8000, 0, 8}}); - registry.add("ld/fDeuteronPtVskstar", "pT (deuteron) vs k^{*};k^{*} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("ld/fAntiDeuteronPtVskstar", "pT (antideuteron) vs k^{*};Q_{3} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("ld/fLambdaPtVskstar", "pT (lambda) vs k^{*};k^{*} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); - registry.add("ld/fAntiLambdaPtVskstar", "pT (antilambda) vs k^{*};k^{*} (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {{150, 0, 1.5}, {500, 0, 10}}}); + registryTriggerQA.add("LD/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("LD/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("LD/all/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("LD/all/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("LD/all/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/all/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/all/fLambdaKstarVsPt", "k* vs Lambda p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/all/fAntiLambdaKstarVsPt", "k* vs AntiLambda p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("LD/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("LD/loose/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("LD/loose/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("LD/loose/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/loose/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/loose/fLambdaKstarVsPt", "k* vs Lambda p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/loose/fAntiLambdaKstarVsPt", "k* vs AntiLambda p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("LD/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("LD/tight/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("LD/tight/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("LD/tight/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/tight/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/tight/fLambdaKstarVsPt", "k* vs Lambda p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("LD/tight/fAntiLambdaKstarVsPt", "k* vs AntiLambda p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + + // for phid + registryTriggerQA.add("PhiD/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PhiD/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PhiD/all/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PhiD/all/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PhiD/all/fPhiKstarVsPt", "k* vs Phi p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PhiD/all/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PhiD/all/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PhiD/all/fPhiKstarVsInvMass", "k* vs #phi mass;k* (GeV/c);M_{K^{+}K^{-}} (GeV/c^{2});", HistType::kTH2F, {Binning.kstar, Binning.invMassPhi}); + registryTriggerQA.add("PhiD/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PhiD/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PhiD/loose/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PhiD/loose/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PhiD/loose/fPhiKstarVsPt", "k* vs Phi p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PhiD/loose/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PhiD/loose/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PhiD/loose/fPhiKstarVsInvMass", "k* vs #phi mass;k* (GeV/c);M_{K^{+}K^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.kstar, Binning.invMassPhi}); + registryTriggerQA.add("PhiD/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("PhiD/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("PhiD/tight/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PhiD/tight/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("PhiD/tight/fPhiKstarVsPt", "k* vs Phi p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PhiD/tight/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PhiD/tight/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("PhiD/tight/fPhiKstarVsInvMass", "k* vs #phi mass;k* (GeV/c);M_{K^{+}K^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.kstar, Binning.invMassPhi}); + + // for rhod + registryTriggerQA.add("RhoD/all/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("RhoD/all/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("RhoD/all/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("RhoD/all/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("RhoD/all/fRhoKstarVsPt", "k* vs Rho p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("RhoD/all/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("RhoD/all/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("RhoD/all/fRhoKstarVsInvMass", "k* vs #rho mass;k* (GeV/c);M_{#pi^{+}#pi^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.kstar, Binning.invMassRho}); + registryTriggerQA.add("RhoD/loose/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("RhoD/loose/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("RhoD/loose/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("RhoD/loose/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("RhoD/loose/fRhoKstarVsPt", "k* vs Rho p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("RhoD/loose/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("RhoD/loose/fAntiDeuteronKstarVsPt", "k* vs AntiDeuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("RhoD/loose/fRhoKstarVsInvMass", "k* vs #rho mass;k* (GeV/c);M_{#pi^{+}#pi^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.kstar, Binning.invMassRho}); + registryTriggerQA.add("RhoD/tight/fMultiplicity", "Multiplicity;Mult;Entries", HistType::kTH1F, {Binning.multiplicity}); + registryTriggerQA.add("RhoD/tight/fZvtx", "Zvtx;Z_{vtx};Entries", HistType::kTH1F, {Binning.zvtx}); + registryTriggerQA.add("RhoD/tight/fSE_particle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("RhoD/tight/fSE_antiparticle", "Same Event distribution;k* (GeV/c);Entries", HistType::kTH1F, {Binning.kstar}); + registryTriggerQA.add("RhoD/tight/fRhoKstarVsPt", "k* vs Rho p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("RhoD/tight/fDeuteronKstarVsPt", "k* vs Deuteron p_{T};k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("RhoD/tight/fAntiDeuteronKstarVsPt", "AntiDeuteron p_{T} vs k*;k* (GeV/c);p_{T} (GeV/c)", {HistType::kTH2F, {Binning.kstar, Binning.momentum}}); + registryTriggerQA.add("RhoD/tight/fRhoKstarVsInvMass", "k* vs #rho mass;k* (GeV/c);M_{#pi^{+}#pi^{-}} (GeV/c^{2})", HistType::kTH2F, {Binning.kstar, Binning.invMassRho}); } - float mMassElectron = o2::constants::physics::MassElectron; - float mMassPion = o2::constants::physics::MassPionCharged; - float mMassProton = o2::constants::physics::MassProton; - float mMassLambda = o2::constants::physics::MassLambda; - float mMassDeuteron = o2::constants::physics::MassDeuteron; - float mMassPhi = o2::constants::physics::MassPhi; - float mMassKaonPlus = o2::constants::physics::MassKPlus; - float mMassKaonMinus = o2::constants::physics::MassKMinus; + void initCCDB(int run) + { + if (run != mRunNumber) { + mRunNumber = run; + o2::parameters::GRPMagField* grpmag = ccdb->getForRun("GLO/Config/GRPMagField", run); + o2::base::Propagator::initFieldFromGRP(grpmag); + mBz = static_cast(grpmag->getNominalL3Field()); - int currentRunNumber = -999; - int lastRunNumber = -999; + mStraHelper.fitter.setBz(mBz); + } + if (!mStraHelper.lut) { /// done only once + ccdb->setURL(V0BuilderOpts.ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(true); + auto* lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); + o2::base::Propagator::Instance()->setMatLUT(lut); + mStraHelper.lut = lut; + } + } template - bool isSelectedEvent(T const& col) + bool checkEvent(T const& col) { - if (ConfEvtSelectZvtx && std::abs(col.posZ()) > ConfEvtZvtx) { + if (std::abs(col.posZ()) > EventSelection.zvtx.value) { return false; } - if (ConfEvtOfflineCheck && !col.sel8()) { + if (EventSelection.eventSel.value && !col.sel8()) { return false; } - // if event is close to the timeframe border, return false - if (ConfEvtTimeFrameBorderCheck && !col.selection_bit(aod::evsel::kNoTimeFrameBorder)) { - return false; - } - return true; } template - bool isSelectedTrack(T const& track, CFTrigger::ParticleSpecies partSpecies) + bool checkTrack(T const& track, std::string trackName) { - const auto charge = track.sign(); - const auto pT = track.pt(); - float momCorDif = track.tpcInnerParam() - track.p(); - float momCorRatio = momCorDif / track.p(); - const auto eta = track.eta(); - const auto tpcNClsF = track.tpcNClsFound(); - const auto tpcRClsC = track.tpcCrossedRowsOverFindableCls(); - const auto tpcNClsC = track.tpcNClsCrossedRows(); - const auto tpcNClsS = track.tpcNClsShared(); - const auto itsNCls = track.itsNCls(); - const auto itsNClsIB = track.itsNClsInnerBarrel(); - const auto dcaXY = track.dcaXY(); - const auto dcaZ = track.dcaZ(); - - if (charge > 0) { - if (pT < ConfPtCuts->get(partSpecies, "Pt min (particle)")) { - return false; - } - if (pT > ConfPtCuts->get(partSpecies, "Pt max (particle)")) { - return false; - } - if (ConfMomCorDifCutFlag.value && momCorDif < ConfMomCorDifCut->get(partSpecies, "Momemtum Correlation min")) { - return false; - } - if (ConfMomCorDifCutFlag.value && momCorDif > ConfMomCorDifCut->get(partSpecies, "Momemtum Correlation max")) { - return false; - } - if (ConfMomCorRatioCutFlag.value && momCorRatio < ConfMomCorRatioCut->get(partSpecies, "Momemtum Correlation min")) { - return false; - } - if (ConfMomCorRatioCutFlag.value && momCorRatio > ConfMomCorRatioCut->get(partSpecies, "Momemtum Correlation max")) { - return false; - } - } - if (charge < 0) { - if (pT < ConfPtCuts->get(partSpecies, "Pt min (antiparticle)")) { - return false; - } - if (pT > ConfPtCuts->get(partSpecies, "Pt max (antiparticle)")) { - return false; - } - if (ConfMomCorDifCutFlag.value && momCorDif < ConfMomCorDifCutAnti->get(partSpecies, "Momemtum Correlation min")) { - return false; - } - if (ConfMomCorDifCutFlag.value && momCorDif > ConfMomCorDifCutAnti->get(partSpecies, "Momemtum Correlation max")) { - return false; - } - if (ConfMomCorRatioCutFlag.value && momCorRatio < ConfMomCorRatioCutAnti->get(partSpecies, "Momemtum Correlation min")) { - return false; - } - if (ConfMomCorRatioCutFlag.value && momCorRatio > ConfMomCorRatioCutAnti->get(partSpecies, "Momemtum Correlation max")) { - return false; - } - } - - if (std::abs(eta) > ConfTrkEta) { + if (track.pt() < TrackSelections.momentum->get(trackName.c_str(), "PtMin")) { return false; } - if (tpcNClsF < ConfTPCNClustersMin->get("TPCNClusMin", partSpecies)) { + if (track.pt() > TrackSelections.momentum->get(trackName.c_str(), "PtMax")) { return false; } - if (tpcRClsC < ConfTrkTPCfCls) { + if (std::abs(track.eta()) > TrackSelections.trackProperties->get(trackName.c_str(), "AbsEtaMax")) { return false; } - if (tpcNClsC < ConfTrkTPCcRowsMin) { + if (track.tpcNClsFound() < TrackSelections.trackProperties->get(trackName.c_str(), "TpcClusterMin")) { return false; } - if (tpcNClsS > ConfTrkTPCsClsMax) { + if (track.tpcNClsCrossedRows() < TrackSelections.trackProperties->get(trackName.c_str(), "TpcRowMin")) { return false; } - if (itsNCls < ConfTrkITSnclsMin->get(static_cast(0), partSpecies)) { + if (track.tpcCrossedRowsOverFindableCls() < TrackSelections.trackProperties->get(trackName.c_str(), "TpcCrossedOverFoundMin")) { return false; } - if (itsNClsIB < ConfTrkITSnclsIBMin->get(static_cast(0), partSpecies)) { + if (track.tpcNClsShared() > TrackSelections.trackProperties->get(trackName.c_str(), "TpcSharedMax")) { return false; } - if (std::abs(dcaXY) > ConfTrkDCAxyMax) { + if (track.tpcFractionSharedCls() > TrackSelections.trackProperties->get(trackName.c_str(), "TpcFracSharedMax")) { return false; } - if (std::abs(dcaZ) > ConfTrkDCAzMax) { + if (track.itsNCls() < TrackSelections.trackProperties->get(trackName.c_str(), "ItsClusterMin")) { return false; } - // TODO: which dca, put dcaxy for now - if (ConfRejectNotPropagatedTracks && std::abs(dcaXY) > 1e3) { + if (track.itsNClsInnerBarrel() < TrackSelections.trackProperties->get(trackName.c_str(), "ItsIbClusterMin")) { return false; } - if (ConfTrkRequireChi2MaxTPC && track.tpcChi2NCl() >= ConfTrkMaxChi2PerClusterTPC) { + if (std::abs(track.dcaXY()) > TrackSelections.trackProperties->get(trackName.c_str(), "AbsDcaXyMax")) { return false; } - if (ConfTrkRequireChi2MaxITS && track.itsChi2NCl() >= ConfTrkMaxChi2PerClusterITS) { + if (std::abs(track.dcaZ()) > TrackSelections.trackProperties->get(trackName.c_str(), "AbsDcaZMax")) { return false; } - if (ConfTrkTPCRefit && !track.hasTPC()) { + if (track.tpcChi2NCl() > TrackSelections.trackProperties->get(trackName.c_str(), "Chi2TpcMax")) { return false; } - if (ConfTrkITSRefit && !track.hasITS()) { + if (track.itsChi2NCl() > TrackSelections.trackProperties->get(trackName.c_str(), "Chi2ItsMax")) { return false; } return true; } - template - bool isSelectedV0Daughter(T const& track, V const& v0, float charge, CFTrigger::V0Daughters species, double nSigmaTPCDaug[2]) + template + bool checkTrackPid(T const& track, std::string trackName) { - const auto tpcNClsF = track.tpcNClsFound(); - float eta = -1; - float dca = -1; - if (charge > 0) { - eta = v0.positiveeta(); - dca = v0.dcapostopv(); - } else if (charge < 0) { - eta = v0.negativeeta(); - dca = v0.dcanegtopv(); - } - const auto sign = track.sign(); - double nSigmaTPC = -999.f; - - if (charge < 0 && sign > 0) { - return false; - } - if (charge > 0 && sign < 0) { - return false; - } - if (std::abs(eta) > ConfDaughEta) { - return false; - } - if (tpcNClsF < ConfDaughTPCnclsMin) { - return false; - } - if (std::abs(dca) < ConfDaughDCAMin) { - return false; - } - - switch (species) { - case CFTrigger::kDaughPion: - nSigmaTPC = nSigmaTPCDaug[1]; - break; - case CFTrigger::kDaughProton: - nSigmaTPC = nSigmaTPCDaug[0]; - break; - default: - LOG(fatal) << "Particle species for V0 daughters not found"; - } + float momentum = -99; - if (nSigmaTPC < ConfDaughPIDCuts->get(species, "TPC min") || - nSigmaTPC > ConfDaughPIDCuts->get(species, "TPC max")) { - return false; + if (TrackSelections.momentum->get(trackName.c_str(), "UseInnerParam") < 0) { + momentum = track.p(); + } else { + momentum = track.tpcInnerParam(); } - return true; - } - template - bool isSelectedTrackPID(T const& track, CFTrigger::ParticleSpecies partSpecies, bool Rejection, double nSigmaTPC[2], int charge) - { - // nSigma should have entries [proton, deuteron] - bool isSelected = false; - bool pThres = true; - float nSigma = -999.; - - // check tracking PID - uint8_t SpeciesForTracking = 0; - if (partSpecies == CFTrigger::kProton) { - SpeciesForTracking = o2::track::PID::Proton; - } else if (partSpecies == CFTrigger::kDeuteron) { - SpeciesForTracking = o2::track::PID::Deuteron; + float nsigmaITS = -99; + float nsigmaTPC = -99; + float nsigmaTPCTOF = -99; + + if (trackName == std::string("Pion")) { + nsigmaITS = track.itsNSigmaPi(); + nsigmaTPC = track.tpcNSigmaPi(); + nsigmaTPCTOF = std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi()); + } else if (trackName == std::string("Kaon")) { + nsigmaITS = track.itsNSigmaKa(); + nsigmaTPC = track.tpcNSigmaKa(); + nsigmaTPCTOF = std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa()); + } else if (trackName == std::string("Proton")) { + nsigmaITS = track.itsNSigmaPr(); + nsigmaTPC = track.tpcNSigmaPr(); + nsigmaTPCTOF = std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr()); + } else if (trackName == std::string("Deuteron")) { + nsigmaITS = track.itsNSigmaDe(); + nsigmaTPC = track.tpcNSigmaDe(); + nsigmaTPCTOF = std::hypot(track.tpcNSigmaDe(), track.tofNSigmaDe()); } else { - LOG(warn) << "Unknown PID for tracking encountered"; + LOG(fatal) << "Unsupported track type"; } - if (ConfPIDForTracking->get(partSpecies, "Switch") > 0 && track.tpcInnerParam() < ConfPIDForTracking->get(partSpecies, "Momemtum Threshold")) { - if (track.pidForTracking() != SpeciesForTracking) { + if (momentum < TrackSelections.momentum->get(trackName.c_str(), "PThres")) { + if (nsigmaITS < TrackSelections.pid->get(trackName.c_str(), "ItsMin") || nsigmaITS > TrackSelections.pid->get(trackName.c_str(), "ItsMax")) { return false; } - } - - // check momentum threshold - if (track.tpcInnerParam() <= ConfPtCuts->get(partSpecies, "P thres")) { - pThres = true; - } else { - pThres = false; - } - if (CFTrigger::kDeuteron == partSpecies && ConfDeuteronThPVMom) { - if (track.p() <= ConfPtCuts->get(partSpecies, "P thres")) { - pThres = true; - } else { - pThres = false; - } - } - // compute nsigma - switch (partSpecies) { - case CFTrigger::kProton: - if (pThres) { - nSigma = nSigmaTPC[0]; - } else { - if (charge > 0) { - nSigma = std::sqrt(std::pow(nSigmaTPC[0] - TPCTOFAvg[0], 2) + std::pow(track.tofNSigmaPr() - TPCTOFAvg[1], 2)); - } else { - nSigma = std::sqrt(std::pow(nSigmaTPC[0] - TPCTOFAvg[2], 2) + std::pow(track.tofNSigmaPr() - TPCTOFAvg[3], 2)); - } - } - break; - case CFTrigger::kDeuteron: - if (pThres) { - nSigma = nSigmaTPC[1]; - } else { - if (charge > 0) { - nSigma = std::sqrt(std::pow(nSigmaTPC[1] - TPCTOFAvg[4], 2) + std::pow(track.tofNSigmaDe() - TPCTOFAvg[5], 2)); - } else { - nSigma = std::sqrt(std::pow(nSigmaTPC[1] - TPCTOFAvg[6], 2) + std::pow(track.tofNSigmaDe() - TPCTOFAvg[7], 2)); - } - } - break; - case CFTrigger::kLambda: - LOG(fatal) << "No PID selection for Lambdas"; - break; - default: - LOG(fatal) << "Particle species not known"; - } - // check if track is selected - - auto TPCmin = (charge > 0) ? ConfPIDCuts->get(partSpecies, CFTrigger::kTPCMin) - : ConfPIDCutsAnti->get(partSpecies, CFTrigger::kTPCMin); - - auto TPCmax = (charge > 0) ? ConfPIDCuts->get(partSpecies, CFTrigger::kTPCMax) - : ConfPIDCutsAnti->get(partSpecies, CFTrigger::kTPCMax); - - auto TPCTOFmax = (charge > 0) ? ConfPIDCuts->get(partSpecies, CFTrigger::kTPCTOF) - : ConfPIDCutsAnti->get(partSpecies, CFTrigger::kTPCTOF); - - if (pThres) { - if (nSigma > TPCmin && - nSigma < TPCmax) { - isSelected = true; + if (nsigmaTPC < TrackSelections.pid->get(trackName.c_str(), "TpcMin") || nsigmaTPC > TrackSelections.pid->get(trackName.c_str(), "TpcMax")) { + return false; } } else { - if (nSigma < TPCTOFmax) { - isSelected = true; - } - } - // for deuterons normally, we want to reject tracks that have a high - // probablilty of being another particle - if (Rejection) { - double nSigmaPi = track.tpcNSigmaPi(); - double nSigmaEl = track.tpcNSigmaEl(); - if (ConfUseManualPIDpion) { - auto bgScalingPion = 1 / mMassPion; // momentum scaling? - if (BBPion.size() == 6 && charge > 0) - nSigmaPi = updatePID(track, bgScalingPion, BBPion); - if (BBAntipion.size() == 6 && charge < 0) - nSigmaPi = updatePID(track, bgScalingPion, BBAntipion); - } - if (ConfUseManualPIDel) { - auto bgScalingElectron = 1 / mMassElectron; // momentum scaling? - if (BBElectron.size() == 6 && charge < 0) - nSigmaEl = updatePID(track, bgScalingElectron, BBElectron); - if (BBAntielectron.size() == 6 && charge > 0) - nSigmaEl = updatePID(track, bgScalingElectron, BBAntielectron); - } - if ((ConfPIDRejection->get(CFTrigger::kRejProton, CFTrigger::kTPCMin) < nSigmaTPC[0] && - ConfPIDRejection->get(CFTrigger::kRejProton, CFTrigger::kTPCMax) > nSigmaTPC[0]) || - (ConfPIDRejection->get(CFTrigger::kRejPion, CFTrigger::kTPCMin) < nSigmaPi && - ConfPIDRejection->get(CFTrigger::kRejPion, CFTrigger::kTPCMax) > nSigmaPi) || - (ConfPIDRejection->get(CFTrigger::kRejElectron, CFTrigger::kTPCMin) < nSigmaEl && - ConfPIDRejection->get(CFTrigger::kRejElectron, CFTrigger::kTPCMax) > nSigmaEl)) { + if (nsigmaTPCTOF > TrackSelections.pid->get(trackName.c_str(), "TpcTofMax")) { return false; } } - return isSelected; + return true; } - template - bool isSelectedMinimalV0(C const& /*col*/, V const& v0, T const& posTrack, - T const& negTrack, float charge, double nSigmaTPCPos[2], double nSigmaTPCNeg[2]) + bool checkLambda(float lambdaPt, float lambdaDauDca, float lambdaCpa, float lambdaRadius, float lambdaPos, float kaonMass, float lambdaMass) { - const auto signPos = posTrack.sign(); - const auto signNeg = negTrack.sign(); - if (signPos < 0 || signNeg > 0) { - LOG(info) << "Something wrong in isSelectedMinimal"; - LOG(info) << "ERROR - Wrong sign for V0 daughters"; - } - const float pT = v0.pt(); - const std::vector decVtx = {v0.x(), v0.y(), v0.z()}; - const float tranRad = v0.v0radius(); - const float dcaDaughv0 = v0.dcaV0daughters(); - const float cpav0 = v0.v0cosPA(); - - const float invMassLambda = v0.mLambda(); - const float invMassAntiLambda = v0.mAntiLambda(); - - if (charge > 0 && (invMassLambda < ConfV0InvMassLowLimit || invMassLambda > ConfV0InvMassUpLimit)) { + if (lambdaPt < LambdaSelections.ptMin) { return false; } - if (charge < 0 && (invMassAntiLambda < ConfV0InvMassLowLimit || invMassAntiLambda > ConfV0InvMassUpLimit)) { + if (lambdaDauDca > LambdaSelections.dcaDaughMax) { return false; } - if (ConfV0RejectKaons) { - const float invMassKaon = v0.mK0Short(); - if (invMassKaon > ConfV0InvKaonMassLowLimit && invMassKaon < ConfV0InvKaonMassUpLimit) { - return false; - } - } - if (pT < ConfV0PtMin) { + if (lambdaCpa < LambdaSelections.cpaMin) { return false; } - if (dcaDaughv0 > ConfV0DCADaughMax) { + if (lambdaRadius < LambdaSelections.tranRadMin) { return false; } - if (cpav0 < ConfV0CPAMin) { + if (lambdaRadius > LambdaSelections.tranRadMax) { return false; } - if (tranRad < ConfV0TranRadV0Min) { + if (lambdaPos > LambdaSelections.decVtxMax) { return false; } - if (tranRad > ConfV0TranRadV0Max) { - return false; - } - for (size_t i = 0; i < decVtx.size(); i++) { - if (decVtx.at(i) > ConfV0DecVtxMax) { + if (LambdaSelections.rejectKaons) { + if (kaonMass > LambdaSelections.invKaonMassLow && kaonMass < LambdaSelections.invKaonMassUp) { return false; } } - if (charge > 0) { - if (!isSelectedV0Daughter(posTrack, v0, 1, CFTrigger::kDaughProton, nSigmaTPCPos)) { - return false; - } - if (!isSelectedV0Daughter(negTrack, v0, -1, CFTrigger::kDaughPion, nSigmaTPCNeg)) { - return false; - } + if (lambdaMass < LambdaSelections.invMassLow) { + return false; } - if (charge < 0) { - if (!isSelectedV0Daughter(posTrack, v0, 1, CFTrigger::kDaughPion, nSigmaTPCPos)) { - return false; - } - if (!isSelectedV0Daughter(negTrack, v0, -1, CFTrigger::kDaughProton, nSigmaTPCNeg)) { - return false; - } + if (lambdaMass > LambdaSelections.invMassUp) { + return false; } return true; } template - bool isSelectedTrackKaon(T const& track) + bool checkLambdaDaughter(T const& track, float eta, float dca, float nSigmaTPC) { - bool isSelected = false; - if (track.pt() <= PPPhi.ConfTrkPtKaUp.value && track.pt() >= PPPhi.ConfTrkPtKaDown.value && std::abs(track.eta()) <= PPPhi.ConfTrkEtaKa.value && std::abs(track.dcaXY()) <= PPPhi.ConfTrkDCAxyKa.value && std::abs(track.dcaZ()) <= PPPhi.ConfTrkDCAzKa.value && track.tpcNClsCrossedRows() >= PPPhi.ConfNCrossedKa.value && track.tpcNClsFound() >= PPPhi.ConfNClusKa.value && track.tpcCrossedRowsOverFindableCls() >= PPPhi.ConfTrkTPCfClsKa.value) { - if (track.tpcInnerParam() < PPPhi.ConfTrkPTPCKaThr.value && std::abs(track.tpcNSigmaKa()) <= PPPhi.ConfTrkKaSigmaPID.value) { - isSelected = true; - } - if (track.tpcInnerParam() >= PPPhi.ConfTrkPTPCKaThr.value && std::abs(std::sqrt(track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa())) <= PPPhi.ConfTrkKaSigmaPID.value) { - isSelected = true; - } + if (std::abs(eta) > LambdaDaughterSelections.absEtaMax.value) { + return false; + } + if (std::abs(dca) < LambdaDaughterSelections.dcaMin.value) { + return false; + } + if (track.tpcNClsFound() < LambdaDaughterSelections.tpcClusterMin.value) { + return false; } - return isSelected; + if (std::abs(nSigmaTPC) > LambdaDaughterSelections.tpcMax.value) { + return false; + } + return true; } float getkstar(const ROOT::Math::PtEtaPhiMVector part1, @@ -1295,18 +1216,18 @@ struct CFFilter { const float betay = beta * std::sin(trackSum.Phi()) * std::sin(trackSum.Theta()); const float betaz = beta * std::cos(trackSum.Theta()); - ROOT::Math::PxPyPzMVector PartOneCMS(part1); - ROOT::Math::PxPyPzMVector PartTwoCMS(part2); + ROOT::Math::PxPyPzMVector partOneCMS(part1); + ROOT::Math::PxPyPzMVector partTwoCMS(part2); const ROOT::Math::Boost boostPRF = ROOT::Math::Boost(-betax, -betay, -betaz); - PartOneCMS = boostPRF(PartOneCMS); - PartTwoCMS = boostPRF(PartTwoCMS); - const ROOT::Math::PxPyPzMVector trackRelK = PartOneCMS - PartTwoCMS; + partOneCMS = boostPRF(partOneCMS); + partTwoCMS = boostPRF(partTwoCMS); + const ROOT::Math::PxPyPzMVector trackRelK = partOneCMS - partTwoCMS; return 0.5 * trackRelK.P(); } - ROOT::Math::PxPyPzEVector getqij(const ROOT::Math::PtEtaPhiMVector parti, - const ROOT::Math::PtEtaPhiMVector partj) + ROOT::Math::PxPyPzEVector + getqij(const ROOT::Math::PtEtaPhiMVector parti, const ROOT::Math::PtEtaPhiMVector partj) { ROOT::Math::PxPyPzEVector vecparti(parti); ROOT::Math::PxPyPzEVector vecpartj(partj); @@ -1315,960 +1236,1374 @@ struct CFFilter { float scaling = trackDifference.Dot(trackSum) / trackSum.Dot(trackSum); return trackDifference - scaling * trackSum; } - float getQ3(const ROOT::Math::PtEtaPhiMVector part1, - const ROOT::Math::PtEtaPhiMVector part2, - const ROOT::Math::PtEtaPhiMVector part3) + float getQ3(const ROOT::Math::PtEtaPhiMVector part1, const ROOT::Math::PtEtaPhiMVector part2, const ROOT::Math::PtEtaPhiMVector part3) { ROOT::Math::PxPyPzEVector q12 = getqij(part1, part2); ROOT::Math::PxPyPzEVector q23 = getqij(part2, part3); ROOT::Math::PxPyPzEVector q31 = getqij(part3, part1); - float Q32 = q12.M2() + q23.M2() + q31.M2(); - return sqrt(-Q32); - } - - std::vector setValuesBB(aod::BCsWithTimestamps::iterator const& bunchCrossing, const std::string ccdbPath) - { - map metadata; - auto h = ccdbApi.retrieveFromTFileAny(ccdbPath, metadata, bunchCrossing.timestamp()); - // auto h = ccdb->getForTimeStamp(ccdbPath, bunchCrossing.timestamp()); //check if possible to use this without getting fatal - if (!h) { - std::vector dummy; - LOG(info) << "File from CCDB in path " << ccdbPath << " was not found for run " << bunchCrossing.runNumber() << ". Will use default PID task values!"; - return dummy; - } - LOG(info) << "File from CCDB in path " << ccdbPath << " was found for run " << bunchCrossing.runNumber() << "!"; - - TAxis* axis = h->GetXaxis(); - std::vector v{static_cast(h->GetBinContent(axis->FindBin("bb1"))), - static_cast(h->GetBinContent(axis->FindBin("bb2"))), - static_cast(h->GetBinContent(axis->FindBin("bb3"))), - static_cast(h->GetBinContent(axis->FindBin("bb4"))), - static_cast(h->GetBinContent(axis->FindBin("bb5"))), - static_cast(h->GetBinContent(axis->FindBin("Resolution")))}; - return v; - } - - std::vector setValuesAvg(aod::BCsWithTimestamps::iterator const& bunchCrossing, const std::string ccdbPath) - { - map metadata; - auto h = ccdbApi.retrieveFromTFileAny(ccdbPath, metadata, bunchCrossing.timestamp()); - // auto h = ccdb->getForTimeStamp(ccdbPath, bunchCrossing.timestamp()); //check if possible to use this without getting fatal - if (!h) { - std::vector dummy{ConfPIDTPCTOFAvg->get("Proton", "TPC Avg"), - ConfPIDTPCTOFAvg->get("Proton", "TOF Avg"), - ConfPIDTPCTOFAvg->get("AntiProton", "TPC Avg"), - ConfPIDTPCTOFAvg->get("AntiProton", "TOF Avg"), - ConfPIDTPCTOFAvg->get("Deuteron", "TPC Avg"), - ConfPIDTPCTOFAvg->get("Deuteron", "TOF Avg"), - ConfPIDTPCTOFAvg->get("AntiDeuteron", "TPC Avg"), - ConfPIDTPCTOFAvg->get("AntiDeuteron", "TOF Avg")}; - LOG(info) << "File from CCDB in path " << ccdbPath << " was not found for run " << bunchCrossing.runNumber() << ". Will use constant values from ConfPIDTPCTOFAvg!"; - return dummy; - } - LOG(info) << "File from CCDB in path " << ccdbPath << " was found for run " << bunchCrossing.runNumber() << "!"; - - TAxis* axis = h->GetXaxis(); - std::vector v{static_cast(h->GetBinContent(axis->FindBin("TPCProton"))), - static_cast(h->GetBinContent(axis->FindBin("TOFProton"))), - static_cast(h->GetBinContent(axis->FindBin("TPCAntiproton"))), - static_cast(h->GetBinContent(axis->FindBin("TOFAntiproton"))), - static_cast(h->GetBinContent(axis->FindBin("TPCDeuteron"))), - static_cast(h->GetBinContent(axis->FindBin("TOFDeuteron"))), - static_cast(h->GetBinContent(axis->FindBin("TPCAntideuteron"))), - static_cast(h->GetBinContent(axis->FindBin("TOFAntideuteron")))}; - return v; + float q32 = q12.M2() + q23.M2() + q31.M2(); + return std::sqrt(-q32); } template - double updatePID(T const& track, double bgScaling, std::vector BB) + float itsSignal(T const& track) { - double expBethe = tpc::BetheBlochAleph(static_cast(track.tpcInnerParam() * bgScaling), BB[0], BB[1], BB[2], BB[3], BB[4]); - double expSigma = expBethe * BB[5]; - return static_cast((track.tpcSignal() - expBethe) / expSigma); - } - - void process(aod::FemtoFullCollision const& col, aod::BCsWithTimestamps const&, aod::FemtoFullTracks const& tracks, o2::aod::V0Datas const& fullV0s) + uint32_t clsizeflag = track.itsClusterSizes(); + auto clSizeLayer0 = (clsizeflag >> (0 * 4)) & 0xf; + auto clSizeLayer1 = (clsizeflag >> (1 * 4)) & 0xf; + auto clSizeLayer2 = (clsizeflag >> (2 * 4)) & 0xf; + auto clSizeLayer3 = (clsizeflag >> (3 * 4)) & 0xf; + auto clSizeLayer4 = (clsizeflag >> (4 * 4)) & 0xf; + auto clSizeLayer5 = (clsizeflag >> (5 * 4)) & 0xf; + auto clSizeLayer6 = (clsizeflag >> (6 * 4)) & 0xf; + int numLayers = 7; + int sumClusterSizes = clSizeLayer1 + clSizeLayer2 + clSizeLayer3 + clSizeLayer4 + clSizeLayer5 + clSizeLayer6 + clSizeLayer0; + float cosLamnda = 1. / std::cosh(track.eta()); + return (static_cast(sumClusterSizes) / numLayers) * cosLamnda; + }; + + void process(cf_trigger::FullCollision const& col, aod::BCs const&, cf_trigger::FullTracks const& tracks, o2::aod::V0s const& v0s) { - if (!ConfIsRun3) { - LOG(fatal) << "Run 2 processing is not implemented!"; + auto tracksWithItsPid = soa::Attach(tracks); + + // reset all arrays + keepEventTightLimit.fill(false); + keepEventLooseLimit.fill(false); + signalTightLimit.fill(0); + signalLooseLimit.fill(0); + + registryTriggerQA.fill(HIST("fProcessedEvents"), 0); + registryParticleQA.fill(HIST("EventQA/Before/fMultiplicity"), col.multNTracksPV()); + registryParticleQA.fill(HIST("EventQA/Before/fZvtx"), col.posZ()); + + if (!checkEvent(col)) { + tags(keepEventTightLimit[cf_trigger::kPPP], keepEventLooseLimit[cf_trigger::kPPP], + keepEventTightLimit[cf_trigger::kPPL], keepEventLooseLimit[cf_trigger::kPPL], + keepEventTightLimit[cf_trigger::kPLL], keepEventLooseLimit[cf_trigger::kPLL], + keepEventTightLimit[cf_trigger::kLLL], keepEventLooseLimit[cf_trigger::kLLL], + keepEventTightLimit[cf_trigger::kPPPhi], keepEventLooseLimit[cf_trigger::kPPPhi], + keepEventTightLimit[cf_trigger::kPPRho], keepEventLooseLimit[cf_trigger::kPPRho], + keepEventTightLimit[cf_trigger::kPD], keepEventLooseLimit[cf_trigger::kPD], + keepEventTightLimit[cf_trigger::kLD], keepEventLooseLimit[cf_trigger::kLD], + keepEventTightLimit[cf_trigger::kPhiD], keepEventLooseLimit[cf_trigger::kPhiD], + keepEventTightLimit[cf_trigger::kRhoD], keepEventLooseLimit[cf_trigger::kRhoD]); + return; } - if (ConfUseManualPIDproton || ConfUseManualPIDdeuteron || ConfUseAvgFromCCDB) { - currentRunNumber = col.bc_as().runNumber(); - if (currentRunNumber != lastRunNumber) { - auto bc = col.bc_as(); - if (ConfUseManualPIDproton || ConfUseManualPIDdaughterProton) { - BBProton = setValuesBB(bc, ConfPIDBBProton); - BBAntiproton = setValuesBB(bc, ConfPIDBBAntiProton); + registryParticleQA.fill(HIST("EventQA/After/fMultiplicity"), col.multNTracksPV()); + registryParticleQA.fill(HIST("EventQA/After/fZvtx"), col.posZ()); + + initCCDB(col.bc().runNumber()); + + // clear particle vectors + vecProton.clear(); + vecAntiProton.clear(); + vecDeuteron.clear(); + vecAntiDeuteron.clear(); + vecLambda.clear(); + vecAntiLambda.clear(); + vecKaon.clear(); + vecAntiKaon.clear(); + vecPhi.clear(); + vecPion.clear(); + vecAntiPion.clear(); + vecRho.clear(); + // clear index vectors for all particles + idxProton.clear(); + idxAntiProton.clear(); + idxDeuteron.clear(); + idxAntiDeuteron.clear(); + idxKaon.clear(); + idxAntiKaon.clear(); + idxPion.clear(); + idxAntiPion.clear(); + // clear index vectors for daughters + idxLambdaDaughProton.clear(); + idxLambdaDaughPion.clear(); + idxAntiLambdaDaughProton.clear(); + idxAntiLambdaDaughPion.clear(); + idxPhiDaughPos.clear(); + idxPhiDaughNeg.clear(); + idxRhoDaughPos.clear(); + idxRhoDaughNeg.clear(); + + for (auto const& track : tracksWithItsPid) { + + // get paritcles + if (track.sign() > 0) { + registryParticleQA.fill(HIST("TrackQA/Before/Particle/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/Before/Particle/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/Before/Particle/fPhi"), track.phi()); + registryParticleQA.fill(HIST("TrackQA/Before/Particle/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/Before/Particle/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/Before/Particle/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/Before/Particle/fTofSignal"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/Before/Pion/fNsigmaITS"), track.p(), track.itsNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/Before/Pion/fNsigmaTPC"), track.p(), track.tpcNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/Before/Pion/fNsigmaTOF"), track.p(), track.tofNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/Before/Pion/fNsigmaTPCTOF"), track.p(), std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi())); + + registryParticleQA.fill(HIST("TrackQA/Before/Kaon/fNsigmaITS"), track.p(), track.itsNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/Before/Kaon/fNsigmaTPC"), track.p(), track.tpcNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/Before/Kaon/fNsigmaTOF"), track.p(), track.tofNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/Before/Kaon/fNsigmaTPCTOF"), track.p(), std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa())); + + registryParticleQA.fill(HIST("TrackQA/Before/Proton/fNsigmaITS"), track.p(), track.itsNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/Before/Proton/fNsigmaTPC"), track.p(), track.tpcNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/Before/Proton/fNsigmaTOF"), track.p(), track.tofNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/Before/Proton/fNsigmaTPCTOF"), track.p(), std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr())); + + registryParticleQA.fill(HIST("TrackQA/Before/Deuteron/fNsigmaITS"), track.p(), track.itsNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/Before/Deuteron/fNsigmaTPC"), track.p(), track.tpcNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/Before/Deuteron/fNsigmaTOF"), track.p(), track.tofNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/Before/Deuteron/fNsigmaTPCTOF"), track.p(), std::hypot(track.tpcNSigmaDe(), track.tofNSigmaDe())); + + if (checkTrack(track, std::string("Pion")) && checkTrackPid(track, std::string("Pion"))) { + vecPion.emplace_back(track.pt(), track.eta(), track.phi(), o2::constants::physics::MassPionCharged); + idxPion.push_back(track.globalIndex()); + + registryParticleQA.fill(HIST("TrackQA/After/Pion/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fPTpc"), track.tpcInnerParam()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fPhi"), track.phi()); + + registryParticleQA.fill(HIST("TrackQA/After/Pion/fNsigmaIts"), track.p(), track.itsNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fNsigmaTpc"), track.p(), track.tpcNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fNsigmaTof"), track.p(), track.tofNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fNsigmaTpcTof"), track.p(), std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi())); + + registryParticleQA.fill(HIST("TrackQA/After/Pion/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fTofBeta"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/After/Pion/fDcaXy"), track.pt(), track.dcaXY()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fDcaZ"), track.pt(), track.dcaZ()); + + registryParticleQA.fill(HIST("TrackQA/After/Pion/fTpcClusters"), track.tpcNClsFound()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fTpcCrossedRows"), track.tpcNClsCrossedRows()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fTpcSharedClusters"), track.tpcNClsShared()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fTpcSharedClusterOverClusterss"), track.tpcFractionSharedCls()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fTpcFindableOverRows"), track.tpcCrossedRowsOverFindableCls()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fTpcChi2OverCluster"), track.tpcChi2NCl()); + + registryParticleQA.fill(HIST("TrackQA/After/Pion/fItsClusters"), track.itsNCls()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fItsIbClusters"), track.itsNClsInnerBarrel()); + registryParticleQA.fill(HIST("TrackQA/After/Pion/fItsChi2OverCluster"), track.itsChi2NCl()); } - if (ConfUseManualPIDdeuteron) { - BBDeuteron = setValuesBB(bc, ConfPIDBBDeuteron); - BBAntideuteron = setValuesBB(bc, ConfPIDBBAntiDeuteron); - } - if (ConfUseManualPIDpion || ConfUseManualPIDdaughterPion) { - BBPion = setValuesBB(bc, ConfPIDBBPion); - BBAntipion = setValuesBB(bc, ConfPIDBBAntiPion); + + if (checkTrack(track, std::string("Kaon")) && checkTrackPid(track, std::string("Kaon"))) { + vecKaon.emplace_back(track.pt(), track.eta(), track.phi(), o2::constants::physics::MassKaonCharged); + idxKaon.push_back(track.globalIndex()); + + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fPTpc"), track.tpcInnerParam()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fPhi"), track.phi()); + + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fNsigmaIts"), track.p(), track.itsNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fNsigmaTpc"), track.p(), track.tpcNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fNsigmaTof"), track.p(), track.tofNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fNsigmaTpcTof"), track.p(), std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa())); + + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fTofBeta"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fDcaXy"), track.pt(), track.dcaXY()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fDcaZ"), track.pt(), track.dcaZ()); + + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fTpcClusters"), track.tpcNClsFound()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fTpcCrossedRows"), track.tpcNClsCrossedRows()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fTpcSharedClusters"), track.tpcNClsShared()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fTpcSharedClusterOverClusterss"), track.tpcFractionSharedCls()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fTpcFindableOverRows"), track.tpcCrossedRowsOverFindableCls()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fTpcChi2OverCluster"), track.tpcChi2NCl()); + + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fItsClusters"), track.itsNCls()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fItsIbClusters"), track.itsNClsInnerBarrel()); + registryParticleQA.fill(HIST("TrackQA/After/Kaon/fItsChi2OverCluster"), track.itsChi2NCl()); } - if (ConfUseManualPIDpion) { - BBElectron = setValuesBB(bc, ConfPIDBBElectron); - BBAntielectron = setValuesBB(bc, ConfPIDBBAntiElectron); + + if (checkTrack(track, std::string("Proton")) && checkTrackPid(track, std::string("Proton"))) { + vecProton.emplace_back(track.pt(), track.eta(), track.phi(), o2::constants::physics::MassProton); + idxProton.push_back(track.globalIndex()); + + registryParticleQA.fill(HIST("TrackQA/After/Proton/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fPTpc"), track.tpcInnerParam()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fPhi"), track.phi()); + + registryParticleQA.fill(HIST("TrackQA/After/Proton/fNsigmaIts"), track.p(), track.itsNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fNsigmaTpc"), track.p(), track.tpcNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fNsigmaTof"), track.p(), track.tofNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fNsigmaTpcTof"), track.p(), std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr())); + + registryParticleQA.fill(HIST("TrackQA/After/Proton/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fTofBeta"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/After/Proton/fDcaXy"), track.pt(), track.dcaXY()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fDcaZ"), track.pt(), track.dcaZ()); + + registryParticleQA.fill(HIST("TrackQA/After/Proton/fTpcClusters"), track.tpcNClsFound()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fTpcCrossedRows"), track.tpcNClsCrossedRows()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fTpcSharedClusters"), track.tpcNClsShared()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fTpcSharedClusterOverClusterss"), track.tpcFractionSharedCls()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fTpcFindableOverRows"), track.tpcCrossedRowsOverFindableCls()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fTpcChi2OverCluster"), track.tpcChi2NCl()); + + registryParticleQA.fill(HIST("TrackQA/After/Proton/fItsClusters"), track.itsNCls()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fItsIbClusters"), track.itsNClsInnerBarrel()); + registryParticleQA.fill(HIST("TrackQA/After/Proton/fItsChi2OverCluster"), track.itsChi2NCl()); } - if (ConfUseAvgFromCCDB) { - TPCTOFAvg = setValuesAvg(bc, ConfAvgPath); + + if (checkTrack(track, std::string("Deuteron")) && checkTrackPid(track, std::string("Deuteron"))) { + vecDeuteron.emplace_back(track.pt(), track.eta(), track.phi(), o2::constants::physics::MassDeuteron); + idxDeuteron.push_back(track.globalIndex()); + + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fPTpc"), track.tpcInnerParam()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fPhi"), track.phi()); + + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fNsigmaIts"), track.p(), track.itsNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fNsigmaTpc"), track.p(), track.tpcNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fNsigmaTof"), track.p(), track.tofNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fNsigmaTpcTof"), track.p(), std::hypot(track.tpcNSigmaDe(), track.tofNSigmaDe())); + + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fTofBeta"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fDcaXy"), track.pt(), track.dcaXY()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fDcaZ"), track.pt(), track.dcaZ()); + + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fTpcClusters"), track.tpcNClsFound()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fTpcCrossedRows"), track.tpcNClsCrossedRows()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fTpcSharedClusters"), track.tpcNClsShared()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fTpcSharedClusterOverClusterss"), track.tpcFractionSharedCls()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fTpcFindableOverRows"), track.tpcCrossedRowsOverFindableCls()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fTpcChi2OverCluster"), track.tpcChi2NCl()); + + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fItsClusters"), track.itsNCls()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fItsIbClusters"), track.itsNClsInnerBarrel()); + registryParticleQA.fill(HIST("TrackQA/After/Deuteron/fItsChi2OverCluster"), track.itsChi2NCl()); } - lastRunNumber = currentRunNumber; } - } - registry.fill(HIST("fProcessedEvents"), 0); - registry.fill(HIST("EventCuts/fMultiplicityBefore"), col.multNTracksPV()); - registry.fill(HIST("EventCuts/fZvtxBefore"), col.posZ()); + if (track.sign() < 0) { + registryParticleQA.fill(HIST("TrackQA/Before/AntiParticle/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiParticle/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiParticle/fPhi"), track.phi()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiParticle/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiParticle/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/Before/AntiParticle/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiParticle/fTofSignal"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/Before/AntiPion/fNsigmaITS"), track.p(), track.itsNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiPion/fNsigmaTPC"), track.p(), track.tpcNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiPion/fNsigmaTOF"), track.p(), track.tofNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiPion/fNsigmaTPCTOF"), track.p(), std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi())); + + registryParticleQA.fill(HIST("TrackQA/Before/AntiKaon/fNsigmaITS"), track.p(), track.itsNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiKaon/fNsigmaTPC"), track.p(), track.tpcNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiKaon/fNsigmaTOF"), track.p(), track.tofNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiKaon/fNsigmaTPCTOF"), track.p(), std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa())); + + registryParticleQA.fill(HIST("TrackQA/Before/AntiProton/fNsigmaITS"), track.p(), track.itsNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiProton/fNsigmaTPC"), track.p(), track.tpcNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiProton/fNsigmaTOF"), track.p(), track.tofNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiProton/fNsigmaTPCTOF"), track.p(), std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr())); + + registryParticleQA.fill(HIST("TrackQA/Before/AntiDeuteron/fNsigmaITS"), track.p(), track.itsNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiDeuteron/fNsigmaTPC"), track.p(), track.tpcNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiDeuteron/fNsigmaTOF"), track.p(), track.tofNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/Before/AntiDeuteron/fNsigmaTPCTOF"), track.p(), std::hypot(track.tpcNSigmaDe(), track.tofNSigmaDe())); + + if (checkTrack(track, std::string("Pion")) && checkTrackPid(track, std::string("Pion"))) { + vecAntiPion.emplace_back(track.pt(), track.eta(), track.phi(), o2::constants::physics::MassPionCharged); + idxAntiPion.push_back(track.globalIndex()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fPTpc"), track.tpcInnerParam()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fPhi"), track.phi()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fNsigmaIts"), track.p(), track.itsNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fNsigmaTpc"), track.p(), track.tpcNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fNsigmaTof"), track.p(), track.tofNSigmaPi()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fNsigmaTpcTof"), track.p(), std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi())); + + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fTofBeta"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fDcaXy"), track.pt(), track.dcaXY()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fDcaZ"), track.pt(), track.dcaZ()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fTpcClusters"), track.tpcNClsFound()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fTpcCrossedRows"), track.tpcNClsCrossedRows()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fTpcSharedClusters"), track.tpcNClsShared()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fTpcSharedClusterOverClusterss"), track.tpcFractionSharedCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fTpcFindableOverRows"), track.tpcCrossedRowsOverFindableCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fTpcChi2OverCluster"), track.tpcChi2NCl()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fItsClusters"), track.itsNCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fItsIbClusters"), track.itsNClsInnerBarrel()); + registryParticleQA.fill(HIST("TrackQA/After/AntiPion/fItsChi2OverCluster"), track.itsChi2NCl()); + } - bool keepEvent3N[CFTrigger::kNThreeBodyTriggers] = {false, false, false, false}; - int lowQ3Triplets[CFTrigger::kNThreeBodyTriggers] = {0, 0, 0, 0}; + if (checkTrack(track, std::string("Kaon")) && checkTrackPid(track, std::string("Kaon"))) { + vecAntiKaon.emplace_back(track.pt(), track.eta(), track.phi(), o2::constants::physics::MassKaonCharged); + idxAntiKaon.push_back(track.globalIndex()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fPTpc"), track.tpcInnerParam()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fPhi"), track.phi()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fNsigmaIts"), track.p(), track.itsNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fNsigmaTpc"), track.p(), track.tpcNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fNsigmaTof"), track.p(), track.tofNSigmaKa()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fNsigmaTpcTof"), track.p(), std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa())); + + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fTofBeta"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fDcaXy"), track.pt(), track.dcaXY()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fDcaZ"), track.pt(), track.dcaZ()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fTpcClusters"), track.tpcNClsFound()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fTpcCrossedRows"), track.tpcNClsCrossedRows()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fTpcSharedClusters"), track.tpcNClsShared()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fTpcSharedClusterOverClusterss"), track.tpcFractionSharedCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fTpcFindableOverRows"), track.tpcCrossedRowsOverFindableCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fTpcChi2OverCluster"), track.tpcChi2NCl()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fItsClusters"), track.itsNCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fItsIbClusters"), track.itsNClsInnerBarrel()); + registryParticleQA.fill(HIST("TrackQA/After/AntiKaon/fItsChi2OverCluster"), track.itsChi2NCl()); + } - bool keepEvent2N[CFTrigger::kNTwoBodyTriggers] = {false, false}; - int lowKstarPairs[CFTrigger::kNTwoBodyTriggers] = {0, 0}; + if (checkTrack(track, std::string("Proton")) && checkTrackPid(track, std::string("Proton"))) { + vecAntiProton.emplace_back(track.pt(), track.eta(), track.phi(), o2::constants::physics::MassProton); + idxAntiProton.push_back(track.globalIndex()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fPTpc"), track.tpcInnerParam()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fPhi"), track.phi()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fNsigmaIts"), track.p(), track.itsNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fNsigmaTpc"), track.p(), track.tpcNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fNsigmaTof"), track.p(), track.tofNSigmaPr()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fNsigmaTpcTof"), track.p(), std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr())); + + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fTofBeta"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fDcaXy"), track.pt(), track.dcaXY()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fDcaZ"), track.pt(), track.dcaZ()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fTpcClusters"), track.tpcNClsFound()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fTpcCrossedRows"), track.tpcNClsCrossedRows()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fTpcSharedClusters"), track.tpcNClsShared()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fTpcSharedClusterOverClusterss"), track.tpcFractionSharedCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fTpcFindableOverRows"), track.tpcCrossedRowsOverFindableCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fTpcChi2OverCluster"), track.tpcChi2NCl()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fItsClusters"), track.itsNCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fItsIbClusters"), track.itsNClsInnerBarrel()); + registryParticleQA.fill(HIST("TrackQA/After/AntiProton/fItsChi2OverCluster"), track.itsChi2NCl()); + } - if (isSelectedEvent(col)) { + if (checkTrack(track, std::string("Deuteron")) && checkTrackPid(track, std::string("Deuteron"))) { + vecAntiDeuteron.emplace_back(track.pt(), track.eta(), track.phi(), o2::constants::physics::MassDeuteron); + idxAntiDeuteron.push_back(track.globalIndex()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fPt"), track.pt()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fPTpc"), track.tpcInnerParam()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fMomCor"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fEta"), track.eta()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fPhi"), track.phi()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fNsigmaIts"), track.p(), track.itsNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fNsigmaTpc"), track.p(), track.tpcNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fNsigmaTof"), track.p(), track.tofNSigmaDe()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fNsigmaTpcTof"), track.p(), std::hypot(track.tpcNSigmaDe(), track.tofNSigmaDe())); + + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fItsSignal"), track.p(), itsSignal(track)); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fTpcSignal"), track.p(), track.tpcSignal()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fTofBeta"), track.p(), track.beta()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fDcaXy"), track.pt(), track.dcaXY()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fDcaZ"), track.pt(), track.dcaZ()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fTpcClusters"), track.tpcNClsFound()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fTpcCrossedRows"), track.tpcNClsCrossedRows()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fTpcSharedClusters"), track.tpcNClsShared()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fTpcSharedClusterOverClusterss"), track.tpcFractionSharedCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fTpcFindableOverRows"), track.tpcCrossedRowsOverFindableCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fTpcChi2OverCluster"), track.tpcChi2NCl()); + + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fItsClusters"), track.itsNCls()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fItsIbClusters"), track.itsNClsInnerBarrel()); + registryParticleQA.fill(HIST("TrackQA/After/AntiDeuteron/fItsChi2OverCluster"), track.itsChi2NCl()); + } + } + } - registry.fill(HIST("EventCuts/fMultiplicityAfter"), col.multNTracksPV()); - registry.fill(HIST("EventCuts/fZvtxAfter"), col.posZ()); + // loop over and build v0s + for (auto const& v0 : v0s) { - // keep track of proton indices - std::vector ProtonIndex = {}; - std::vector AntiProtonIndex = {}; + auto posTrack = v0.posTrack_as(); + auto negTrack = v0.negTrack_as(); - // Prepare vectors for different species - std::vector protons, antiprotons, deuterons, antideuterons, lambdas, antilambdas, kaons, antikaons, phi; + auto posTrackPar = getTrackParCov(posTrack); + auto negTrackPar = getTrackParCov(negTrack); - // create deuteron and proton vectors (and corresponding antiparticles) for pair and triplet creation - for (auto& track : tracks) { + if (!mStraHelper.buildV0Candidate(v0.collisionId(), col.posX(), col.posY(), col.posZ(), posTrack, negTrack, posTrackPar, negTrackPar, false, false, false)) { + continue; + } - double nTPCSigmaP[2]{track.tpcNSigmaPr(), track.tpcNSigmaDe()}; - double nTPCSigmaN[2]{track.tpcNSigmaPr(), track.tpcNSigmaDe()}; + float lambdaPt = std::hypot(mStraHelper.v0.momentum[0], mStraHelper.v0.momentum[1]); + float lambdaPos = std::hypot(mStraHelper.v0.position[0] - col.posX(), mStraHelper.v0.position[1] - col.posY(), mStraHelper.v0.position[2] - col.posZ()); + float lambdaRadius = std::hypot(mStraHelper.v0.position[0], mStraHelper.v0.position[1]); + float lambdaEta = RecoDecay::eta(std::array{mStraHelper.v0.momentum[0], mStraHelper.v0.momentum[1], mStraHelper.v0.momentum[2]}); + float lambdaPhi = RecoDecay::phi(mStraHelper.v0.momentum[0], mStraHelper.v0.momentum[1]); + float lambdaCpa = std::cos(mStraHelper.v0.pointingAngle); + float lambdaDauDca = mStraHelper.v0.daughterDCA; + float lambdaMass = mStraHelper.v0.massLambda; + float antiLambdaMass = mStraHelper.v0.massAntiLambda; + float kaonMass = mStraHelper.v0.massK0Short; + + float posTrackEta = RecoDecay::eta(std::array{mStraHelper.v0.positiveMomentum[0], mStraHelper.v0.positiveMomentum[1], mStraHelper.v0.positiveMomentum[2]}); + float posTrackDca = mStraHelper.v0.positiveDCAxy; + float negTrackEta = RecoDecay::eta(std::array{mStraHelper.v0.negativeMomentum[0], mStraHelper.v0.negativeMomentum[1], mStraHelper.v0.negativeMomentum[2]}); + float negTrackDca = mStraHelper.v0.negativeDCAxy; + + registryParticleQA.fill(HIST("LambdaQA/Before/fPt"), lambdaPt); + registryParticleQA.fill(HIST("LambdaQA/Before/fEta"), lambdaEta); + registryParticleQA.fill(HIST("LambdaQA/Before/fPhi"), lambdaPhi); + registryParticleQA.fill(HIST("LambdaQA/Before/fInvMassLambda"), lambdaMass); + registryParticleQA.fill(HIST("LambdaQA/Before/fInvMassAntiLambda"), antiLambdaMass); + registryParticleQA.fill(HIST("LambdaQA/Before/fInvMassLambdaVsAntiLambda"), lambdaMass, antiLambdaMass); + registryParticleQA.fill(HIST("LambdaQA/Before/fInvMassLambdaVsKaon"), lambdaMass, kaonMass); + registryParticleQA.fill(HIST("LambdaQA/Before/fInvMassAntiLambdaVsKaon"), antiLambdaMass, kaonMass); + registryParticleQA.fill(HIST("LambdaQA/Before/fDcaDaugh"), lambdaDauDca); + registryParticleQA.fill(HIST("LambdaQA/Before/fCpa"), lambdaCpa); + registryParticleQA.fill(HIST("LambdaQA/Before/fTranRad"), lambdaRadius); + registryParticleQA.fill(HIST("LambdaQA/Before/fDecVtx"), lambdaPos); + + registryParticleQA.fill(HIST("LambdaQA/Before/PosDaughter/fPt"), posTrack.pt()); + registryParticleQA.fill(HIST("LambdaQA/Before/PosDaughter/fEta"), posTrackEta); + registryParticleQA.fill(HIST("LambdaQA/Before/PosDaughter/fPhi"), posTrack.phi()); + registryParticleQA.fill(HIST("LambdaQA/Before/PosDaughter/fDcaXy"), posTrack.pt(), posTrackDca); + registryParticleQA.fill(HIST("LambdaQA/Before/PosDaughter/fTpcClusters"), posTrack.tpcNClsFound()); + registryParticleQA.fill(HIST("LambdaQA/Before/PosDaughter/fNsigmaTpcProton"), posTrack.p(), posTrack.tpcNSigmaPr()); + registryParticleQA.fill(HIST("LambdaQA/Before/PosDaughter/fNsigmaTpcPion"), posTrack.p(), posTrack.tpcNSigmaPi()); + + registryParticleQA.fill(HIST("LambdaQA/Before/NegDaughter/fPt"), negTrack.pt()); + registryParticleQA.fill(HIST("LambdaQA/Before/NegDaughter/fEta"), negTrackEta); + registryParticleQA.fill(HIST("LambdaQA/Before/NegDaughter/fPhi"), negTrack.phi()); + registryParticleQA.fill(HIST("LambdaQA/Before/NegDaughter/fDcaXy"), negTrack.pt(), negTrackDca); + registryParticleQA.fill(HIST("LambdaQA/Before/NegDaughter/fTpcClusters"), negTrack.tpcNClsFound()); + registryParticleQA.fill(HIST("LambdaQA/Before/NegDaughter/fNsigmaTpcProton"), negTrack.p(), negTrack.tpcNSigmaPr()); + registryParticleQA.fill(HIST("LambdaQA/Before/NegDaughter/fNsigmaTpcPion"), negTrack.p(), negTrack.tpcNSigmaPi()); + + if (checkLambda(lambdaPt, lambdaDauDca, lambdaCpa, lambdaRadius, lambdaPos, kaonMass, lambdaMass) && checkLambdaDaughter(posTrack, posTrackEta, posTrackDca, posTrack.tpcNSigmaPr()) && checkLambdaDaughter(negTrack, negTrackEta, negTrackDca, negTrack.tpcNSigmaPi())) { + vecLambda.emplace_back(lambdaPt, lambdaEta, lambdaPhi, o2::constants::physics::MassLambda0); + idxLambdaDaughProton.push_back(posTrack.globalIndex()); + idxLambdaDaughPion.push_back(negTrack.globalIndex()); + + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fPt"), lambdaPt); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fEta"), lambdaEta); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fPhi"), lambdaPhi); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fInvMass"), lambdaMass); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fInvMassLambdaVsAntiLambda"), lambdaMass, antiLambdaMass); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fInvMassLambdaVsKaon"), lambdaMass, kaonMass); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fDcaDaugh"), lambdaDauDca); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fCpa"), lambdaCpa); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fTranRad"), lambdaRadius); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/fDecVtx"), lambdaPos); + + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/PosDaughter/fPt"), posTrack.pt()); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/PosDaughter/fEta"), posTrackEta); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/PosDaughter/fPhi"), posTrack.phi()); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/PosDaughter/fDcaXy"), posTrack.pt(), posTrackDca); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/PosDaughter/fTpcClusters"), posTrack.tpcNClsFound()); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/PosDaughter/fNsigmaTpc"), posTrack.p(), posTrack.tpcNSigmaPr()); + + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/NegDaughter/fPt"), negTrack.pt()); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/NegDaughter/fEta"), negTrackEta); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/NegDaughter/fPhi"), negTrack.phi()); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/NegDaughter/fDcaXy"), negTrack.pt(), negTrackDca); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/NegDaughter/fTpcClusters"), negTrack.tpcNClsFound()); + registryParticleQA.fill(HIST("LambdaQA/After/Lambda/NegDaughter/fNsigmaTpc"), negTrack.p(), negTrack.tpcNSigmaPi()); + } - if (ConfUseManualPIDproton) { - auto bgScalingProton = 1 / mMassProton; // momentum scaling? - if (BBProton.size() == 6) - nTPCSigmaP[0] = updatePID(track, bgScalingProton, BBProton); - if (BBAntiproton.size() == 6) - nTPCSigmaN[0] = updatePID(track, bgScalingProton, BBAntiproton); - } - if (ConfUseManualPIDdeuteron) { - auto bgScalingDeuteron = 1 / mMassDeuteron; // momentum scaling? - if (BBDeuteron.size() == 6) - nTPCSigmaP[1] = updatePID(track, bgScalingDeuteron, BBDeuteron); - if (BBAntideuteron.size() == 6) - nTPCSigmaN[1] = updatePID(track, bgScalingDeuteron, BBAntideuteron); - } + if (checkLambda(lambdaPt, lambdaDauDca, lambdaCpa, lambdaRadius, lambdaPos, kaonMass, antiLambdaMass) && checkLambdaDaughter(posTrack, posTrackEta, posTrackDca, posTrack.tpcNSigmaPi()) && checkLambdaDaughter(negTrack, negTrackEta, negTrackDca, negTrack.tpcNSigmaPr())) { + vecAntiLambda.emplace_back(lambdaPt, lambdaEta, lambdaPhi, o2::constants::physics::MassLambda0); + + idxAntiLambdaDaughProton.push_back(negTrack.globalIndex()); + idxAntiLambdaDaughPion.push_back(posTrack.globalIndex()); + + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fPt"), lambdaPt); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fEta"), lambdaEta); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fPhi"), lambdaPhi); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fInvMass"), antiLambdaMass); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fInvMassAntiLambdaVsLambda"), antiLambdaMass, lambdaMass); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fInvMassAntiLambdaVsKaon"), antiLambdaMass, kaonMass); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fDcaDaugh"), lambdaDauDca); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fCpa"), lambdaCpa); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fTranRad"), lambdaRadius); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/fDecVtx"), lambdaPos); + + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/PosDaughter/fPt"), posTrack.pt()); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/PosDaughter/fEta"), posTrackEta); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/PosDaughter/fPhi"), posTrack.phi()); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/PosDaughter/fDcaXy"), posTrack.pt(), posTrackDca); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/PosDaughter/fTpcClusters"), posTrack.tpcNClsFound()); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/PosDaughter/fNsigmaTpc"), posTrack.p(), posTrack.tpcNSigmaPr()); + + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/NegDaughter/fPt"), negTrack.pt()); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/NegDaughter/fEta"), negTrackEta); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/NegDaughter/fPhi"), negTrack.phi()); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/NegDaughter/fDcaXy"), negTrack.pt(), negTrackDca); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/NegDaughter/fTpcClusters"), negTrack.tpcNClsFound()); + registryParticleQA.fill(HIST("LambdaQA/After/AntiLambda/NegDaughter/fNsigmaTpc"), negTrack.p(), negTrack.tpcNSigmaPi()); + } + } - registry.fill(HIST("TrackCuts/TracksBefore/fPtTrackBefore"), track.pt()); - registry.fill(HIST("TrackCuts/TracksBefore/fEtaTrackBefore"), track.eta()); - registry.fill(HIST("TrackCuts/TracksBefore/fPhiTrackBefore"), track.phi()); - - if (track.sign() > 0) { - // Fill PID info - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignal"), track.tpcInnerParam(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalP"), track.p(), track.tpcSignal()); - if (isSelectedTrack(track, CFTrigger::kProton)) { - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalALLCUTS"), track.tpcInnerParam(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalALLCUTSP"), track.p(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsPos"), track.p(), track.tpcInnerParam()); - } - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPProtonBefore"), track.tpcInnerParam(), nTPCSigmaP[0]); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTOFvsPProtonBefore"), track.tpcInnerParam(), track.tofNSigmaPr()); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCTOFvsPProtonBefore"), track.tpcInnerParam(), std::sqrt(std::pow(nTPCSigmaP[0] - TPCTOFAvg[0], 2) + std::pow(track.tofNSigmaPr() - TPCTOFAvg[1], 2))); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPDeuteronBefore"), track.tpcInnerParam(), nTPCSigmaP[1]); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTOFvsPDeuteronBefore"), track.tpcInnerParam(), track.tofNSigmaDe()); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCTOFvsPDeuteronBefore"), track.tpcInnerParam(), std::sqrt(std::pow(nTPCSigmaP[1] - TPCTOFAvg[4], 2) + std::pow(track.tofNSigmaDe() - TPCTOFAvg[5], 2))); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPDeuteronBeforeP"), track.p(), nTPCSigmaP[1]); - registry.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationPos"), track.p(), track.tpcInnerParam()); + // build phi candidates + for (size_t k1 = 0; k1 < vecKaon.size(); k1++) { + for (size_t k2 = 0; k2 < vecAntiKaon.size(); k2++) { + ROOT::Math::PtEtaPhiMVector phi = vecKaon.at(k1) + vecAntiKaon.at(k2); + + registryParticleQA.fill(HIST("PhiQA/Before/fInvMass"), phi.M()); + registryParticleQA.fill(HIST("PhiQA/Before/fPt"), phi.Pt()); + registryParticleQA.fill(HIST("PhiQA/Before/fEta"), phi.Eta()); + registryParticleQA.fill(HIST("PhiQA/Before/fPhi"), RecoDecay::constrainAngle(phi.Phi())); + + if ((phi.M() >= PhiSelections.invMassLow.value) && + (phi.M() <= PhiSelections.invMassUp.value)) { + vecPhi.push_back(phi); + idxPhiDaughPos.push_back(idxKaon.at(k1)); + idxPhiDaughNeg.push_back(idxAntiKaon.at(k2)); + + registryParticleQA.fill(HIST("PhiQA/After/fInvMass"), phi.M()); + registryParticleQA.fill(HIST("PhiQA/After/fPt"), phi.Pt()); + registryParticleQA.fill(HIST("PhiQA/After/fEta"), phi.Eta()); + registryParticleQA.fill(HIST("PhiQA/After/fPhi"), RecoDecay::constrainAngle(phi.Phi())); } - if (track.sign() < 0) { - - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAnti"), track.tpcInnerParam(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiP"), track.p(), track.tpcSignal()); - if (isSelectedTrack(track, CFTrigger::kProton)) { - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiALLCUTS"), track.tpcInnerParam(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiALLCUTSP"), track.p(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsNeg"), track.p(), track.tpcInnerParam()); - } + } + } - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPAntiProtonBefore"), track.tpcInnerParam(), nTPCSigmaN[0]); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTOFvsPAntiProtonBefore"), track.tpcInnerParam(), track.tofNSigmaPr()); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCTOFvsPAntiProtonBefore"), track.tpcInnerParam(), std::sqrt(std::pow(nTPCSigmaN[0] - TPCTOFAvg[2], 2) + std::pow(track.tofNSigmaPr() - TPCTOFAvg[3], 2))); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPAntiDeuteronBefore"), track.tpcInnerParam(), nTPCSigmaN[1]); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTOFvsPAntiDeuteronBefore"), track.tpcInnerParam(), track.tofNSigmaDe()); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCTOFvsPAntiDeuteronBefore"), track.tpcInnerParam(), std::sqrt(std::pow(nTPCSigmaN[1] - TPCTOFAvg[6], 2) + std::pow(track.tofNSigmaDe() - TPCTOFAvg[7], 2))); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPAntiDeuteronBeforeP"), track.p(), nTPCSigmaN[1]); - registry.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationNeg"), track.p(), track.tpcInnerParam()); + // build rho candidates + for (size_t p1 = 0; p1 < vecPion.size(); p1++) { + for (size_t p2 = 0; p2 < vecAntiPion.size(); p2++) { + ROOT::Math::PtEtaPhiMVector rho = vecPion.at(p1) + vecAntiPion.at(p2); + + registryParticleQA.fill(HIST("RhoQA/Before/fInvMass"), rho.M()); + registryParticleQA.fill(HIST("RhoQA/Before/fPt"), rho.Pt()); + registryParticleQA.fill(HIST("RhoQA/Before/fEta"), rho.Eta()); + registryParticleQA.fill(HIST("RhoQA/Before/fPhi"), RecoDecay::constrainAngle(rho.Phi())); + + if (((rho.M() >= RhoSelections.invMassLow.value) && (rho.M() <= RhoSelections.invMassUp.value)) && (rho.Pt() >= RhoSelections.ptLow)) { + vecRho.push_back(rho); + idxRhoDaughPos.push_back(idxPion.at(p1)); + idxRhoDaughNeg.push_back(idxAntiPion.at(p2)); + + registryParticleQA.fill(HIST("RhoQA/After/fInvMass"), rho.M()); + registryParticleQA.fill(HIST("RhoQA/After/fPt"), rho.Pt()); + registryParticleQA.fill(HIST("RhoQA/After/fEta"), rho.Eta()); + registryParticleQA.fill(HIST("RhoQA/After/fPhi"), RecoDecay::constrainAngle(rho.Phi())); } + } + } - // get protons - if (isSelectedTrack(track, CFTrigger::kProton)) { - ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), mMassProton); - if (track.sign() > 0 && isSelectedTrackPID(track, CFTrigger::kProton, false, nTPCSigmaP, 1)) { - protons.push_back(temp); - ProtonIndex.push_back(track.globalIndex()); - - registry.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsProton"), track.p(), track.tpcInnerParam()); - - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalProton"), track.tpcInnerParam(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/Proton/fPProton"), track.p()); - registry.fill(HIST("TrackCuts/Proton/fPTPCProton"), track.tpcInnerParam()); - registry.fill(HIST("TrackCuts/Proton/fPtProton"), track.pt()); - registry.fill(HIST("TrackCuts/Proton/fMomCorProtonDif"), track.p(), track.tpcInnerParam() - track.p()); - registry.fill(HIST("TrackCuts/Proton/fMomCorProtonRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); - registry.fill(HIST("TrackCuts/Proton/fEtaProton"), track.eta()); - registry.fill(HIST("TrackCuts/Proton/fPhiProton"), track.phi()); - registry.fill(HIST("TrackCuts/Proton/fNsigmaTPCvsPProton"), track.tpcInnerParam(), nTPCSigmaP[0]); - registry.fill(HIST("TrackCuts/Proton/fNsigmaTOFvsPProton"), track.tpcInnerParam(), track.tofNSigmaPr()); - registry.fill(HIST("TrackCuts/Proton/fNsigmaTPCTOFvsPProton"), track.tpcInnerParam(), std::sqrt(std::pow(nTPCSigmaP[0] - TPCTOFAvg[0], 2) + std::pow(track.tofNSigmaPr() - TPCTOFAvg[1], 2))); - - registry.fill(HIST("TrackCuts/Proton/fNsigmaTPCvsPProtonP"), track.p(), nTPCSigmaP[0]); - registry.fill(HIST("TrackCuts/Proton/fNsigmaTOFvsPProtonP"), track.p(), track.tofNSigmaPr()); - registry.fill(HIST("TrackCuts/Proton/fNsigmaTPCTOFvsPProtonP"), track.p(), std::sqrt(std::pow(nTPCSigmaP[0] - TPCTOFAvg[0], 2) + std::pow(track.tofNSigmaPr() - TPCTOFAvg[1], 2))); - - registry.fill(HIST("TrackCuts/Proton/fDCAxyProton"), track.dcaXY()); - registry.fill(HIST("TrackCuts/Proton/fDCAzProton"), track.dcaZ()); - registry.fill(HIST("TrackCuts/Proton/fTPCsClsProton"), track.tpcNClsShared()); - registry.fill(HIST("TrackCuts/Proton/fTPCcRowsProton"), track.tpcNClsCrossedRows()); - registry.fill(HIST("TrackCuts/Proton/fTrkTPCfClsProton"), track.tpcCrossedRowsOverFindableCls()); - registry.fill(HIST("TrackCuts/Proton/fTPCnclsProton"), track.tpcNClsFound()); - } - if (track.sign() < 0 && isSelectedTrackPID(track, CFTrigger::kProton, false, nTPCSigmaN, -1)) { - antiprotons.push_back(temp); - AntiProtonIndex.push_back(track.globalIndex()); - - registry.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsAntiProton"), track.p(), track.tpcInnerParam()); - - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiProton"), track.tpcInnerParam(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/AntiProton/fPtAntiProton"), track.pt()); - registry.fill(HIST("TrackCuts/AntiProton/fMomCorAntiProtonDif"), track.p(), track.tpcInnerParam() - track.p()); - registry.fill(HIST("TrackCuts/AntiProton/fMomCorAntiProtonRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); - registry.fill(HIST("TrackCuts/AntiProton/fEtaAntiProton"), track.eta()); - registry.fill(HIST("TrackCuts/AntiProton/fPhiAntiProton"), track.phi()); - registry.fill(HIST("TrackCuts/AntiProton/fNsigmaTPCvsPAntiProton"), track.tpcInnerParam(), nTPCSigmaN[0]); - registry.fill(HIST("TrackCuts/AntiProton/fNsigmaTOFvsPAntiProton"), track.tpcInnerParam(), track.tofNSigmaPr()); - registry.fill(HIST("TrackCuts/AntiProton/fNsigmaTPCTOFvsPAntiProton"), track.tpcInnerParam(), std::sqrt(std::pow(nTPCSigmaN[0] - TPCTOFAvg[2], 2) + std::pow(track.tofNSigmaPr() - TPCTOFAvg[3], 2))); - - registry.fill(HIST("TrackCuts/AntiProton/fNsigmaTPCvsPAntiProtonP"), track.p(), nTPCSigmaN[0]); - registry.fill(HIST("TrackCuts/AntiProton/fNsigmaTOFvsPAntiProtonP"), track.p(), track.tofNSigmaPr()); - registry.fill(HIST("TrackCuts/AntiProton/fNsigmaTPCTOFvsPAntiProtonP"), track.p(), std::sqrt(std::pow(nTPCSigmaN[0] - TPCTOFAvg[2], 2) + std::pow(track.tofNSigmaPr() - TPCTOFAvg[3], 2))); - - registry.fill(HIST("TrackCuts/AntiProton/fDCAxyAntiProton"), track.dcaXY()); - registry.fill(HIST("TrackCuts/AntiProton/fDCAzAntiProton"), track.dcaZ()); - registry.fill(HIST("TrackCuts/AntiProton/fTPCsClsAntiProton"), track.tpcNClsShared()); - registry.fill(HIST("TrackCuts/AntiProton/fTPCcRowsAntiProton"), track.tpcNClsCrossedRows()); - registry.fill(HIST("TrackCuts/AntiProton/fTrkTPCfClsAntiProton"), track.tpcCrossedRowsOverFindableCls()); - registry.fill(HIST("TrackCuts/AntiProton/fTPCnclsAntiProton"), track.tpcNClsFound()); + float q3 = 999.f, kstar = 999.f; + + // PPP + if (TriggerSelections.filterSwitches->get("Switch", "PPP") > 0) { + for (size_t p1 = 0; p1 < vecProton.size(); p1++) { + for (size_t p2 = p1 + 1; p2 < vecProton.size(); p2++) { + for (size_t p3 = p2 + 1; p3 < vecProton.size(); p3++) { + q3 = getQ3(vecProton.at(p1), vecProton.at(p2), vecProton.at(p3)); + registryTriggerQA.fill(HIST("PPP/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPP/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPP/all/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPP/all/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPP/all/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPP/all/fProtonQ3VsPt"), q3, vecProton.at(p3).Pt()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PPP")) { + signalLooseLimit[cf_trigger::kPPP] += 1; + registryTriggerQA.fill(HIST("PPP/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPP/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPP/loose/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPP/loose/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPP/loose/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPP/loose/fProtonQ3VsPt"), q3, vecProton.at(p3).Pt()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PPP")) { + signalTightLimit[cf_trigger::kPPP] += 1; + registryTriggerQA.fill(HIST("PPP/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPP/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPP/tight/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPP/tight/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPP/tight/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPP/tight/fProtonQ3VsPt"), q3, vecProton.at(p3).Pt()); + } + } } } - // get deuterons - if (isSelectedTrack(track, CFTrigger::kDeuteron)) { - ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), mMassDeuteron); - if (track.sign() > 0 && isSelectedTrackPID(track, CFTrigger::kDeuteron, ConfRejectNOTDeuteron.value, nTPCSigmaP, 1)) { - deuterons.push_back(temp); - - registry.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsDeuteron"), track.p(), track.tpcInnerParam()); - - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalDeuteron"), track.tpcInnerParam(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/Deuteron/fPtDeuteron"), track.pt()); - registry.fill(HIST("TrackCuts/Deuteron/fMomCorDeuteronDif"), track.p(), track.tpcInnerParam() - track.p()); - registry.fill(HIST("TrackCuts/Deuteron/fMomCorDeuteronRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); - registry.fill(HIST("TrackCuts/Deuteron/fEtaDeuteron"), track.eta()); - registry.fill(HIST("TrackCuts/Deuteron/fPhiDeuteron"), track.phi()); - registry.fill(HIST("TrackCuts/Deuteron/fNsigmaTPCvsPDeuteron"), track.tpcInnerParam(), nTPCSigmaP[1]); - registry.fill(HIST("TrackCuts/Deuteron/fNsigmaTOFvsPDeuteron"), track.tpcInnerParam(), track.tofNSigmaDe()); - registry.fill(HIST("TrackCuts/Deuteron/fNsigmaTPCTOFvsPDeuteron"), track.tpcInnerParam(), std::sqrt(std::pow(nTPCSigmaP[1] - TPCTOFAvg[4], 2) + std::pow(track.tofNSigmaDe() - TPCTOFAvg[5], 2))); - - registry.fill(HIST("TrackCuts/Deuteron/fNsigmaTPCvsPDeuteronP"), track.p(), nTPCSigmaP[1]); - registry.fill(HIST("TrackCuts/Deuteron/fNsigmaTOFvsPDeuteronP"), track.p(), track.tofNSigmaDe()); - registry.fill(HIST("TrackCuts/Deuteron/fNsigmaTPCTOFvsPDeuteronP"), track.p(), std::sqrt(std::pow(nTPCSigmaP[1] - TPCTOFAvg[4], 2) + std::pow(track.tofNSigmaDe() - TPCTOFAvg[5], 2))); - - registry.fill(HIST("TrackCuts/Deuteron/fDCAxyDeuteron"), track.dcaXY()); - registry.fill(HIST("TrackCuts/Deuteron/fDCAzDeuteron"), track.dcaZ()); - registry.fill(HIST("TrackCuts/Deuteron/fTPCsClsDeuteron"), track.tpcNClsShared()); - registry.fill(HIST("TrackCuts/Deuteron/fTPCcRowsDeuteron"), track.tpcNClsCrossedRows()); - registry.fill(HIST("TrackCuts/Deuteron/fTrkTPCfClsDeuteron"), track.tpcCrossedRowsOverFindableCls()); - registry.fill(HIST("TrackCuts/Deuteron/fTPCnclsDeuteron"), track.tpcNClsFound()); - } - if (track.sign() < 0 && isSelectedTrackPID(track, CFTrigger::kDeuteron, ConfRejectNOTDeuteron.value, nTPCSigmaN, -1)) { - antideuterons.push_back(temp); - - registry.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsAntiDeuteron"), track.p(), track.tpcInnerParam()); - - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiDeuteron"), track.tpcInnerParam(), track.tpcSignal()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fPtAntiDeuteron"), track.pt()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fMomCorAntiDeuteronDif"), track.p(), track.tpcInnerParam() - track.p()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fMomCorAntiDeuteronRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fEtaAntiDeuteron"), track.eta()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fPhiAntiDeuteron"), track.phi()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTPCvsPAntiDeuteron"), track.tpcInnerParam(), nTPCSigmaN[1]); - registry.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTOFvsPAntiDeuteron"), track.tpcInnerParam(), track.tofNSigmaDe()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTPCTOFvsPAntiDeuteron"), track.tpcInnerParam(), std::sqrt(std::pow(nTPCSigmaN[1] - TPCTOFAvg[6], 2) + std::pow(track.tofNSigmaDe() - TPCTOFAvg[7], 2))); - - registry.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTPCvsPAntiDeuteronP"), track.p(), nTPCSigmaN[1]); - registry.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTOFvsPAntiDeuteronP"), track.p(), track.tofNSigmaDe()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTPCTOFvsPAntiDeuteronP"), track.p(), std::sqrt(std::pow(nTPCSigmaN[1] - TPCTOFAvg[6], 2) + std::pow(track.tofNSigmaDe() - TPCTOFAvg[7], 2))); - - registry.fill(HIST("TrackCuts/AntiDeuteron/fDCAxyAntiDeuteron"), track.dcaXY()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fDCAzAntiDeuteron"), track.dcaZ()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fTPCsClsAntiDeuteron"), track.tpcNClsShared()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fTPCcRowsAntiDeuteron"), track.tpcNClsCrossedRows()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fTrkTPCfClsAntiDeuteron"), track.tpcCrossedRowsOverFindableCls()); - registry.fill(HIST("TrackCuts/AntiDeuteron/fTPCnclsAntiDeuteron"), track.tpcNClsFound()); + } + for (size_t p1 = 0; p1 < vecAntiProton.size(); p1++) { + for (size_t p2 = p1 + 1; p2 < vecAntiProton.size(); p2++) { + for (size_t p3 = p2 + 1; p3 < vecAntiProton.size(); p3++) { + q3 = getQ3(vecAntiProton.at(p1), vecAntiProton.at(p2), vecAntiProton.at(p3)); + registryTriggerQA.fill(HIST("PPP/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPP/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPP/all/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPP/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPP/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPP/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p3).Pt()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PPP")) { + signalLooseLimit[cf_trigger::kPPP] += 1; + registryTriggerQA.fill(HIST("PPP/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPP/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPP/loose/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPP/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPP/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPP/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p3).Pt()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PPP")) { + signalTightLimit[cf_trigger::kPPP] += 1; + registryTriggerQA.fill(HIST("PPP/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPP/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPP/tight/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPP/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPP/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPP/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p3).Pt()); + } + } } } - // get Kaons (Phi Daughters) - if (ConfTriggerSwitches->get("Switch", "ppPhi") > 0.) { - if (isSelectedTrackKaon(track)) { - ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), mMassKaonPlus); - if (track.sign() > 0) { - temp.SetM(mMassKaonPlus); - kaons.push_back(temp); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fP"), track.p()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fPTPC"), track.tpcInnerParam()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fPt"), track.pt()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fEta"), track.eta()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fPhi"), track.phi()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fNsigmaTPCvsP"), track.tpcInnerParam(), track.tpcNSigmaKa()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fNsigmaTOFvsP"), track.tpcInnerParam(), track.tofNSigmaKa()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fNsigmaTPCTOFvsP"), track.tpcInnerParam(), std::abs(std::sqrt(track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa()))); - - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fDCAxy"), track.dcaXY()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fDCAz"), track.dcaZ()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fTPCsCls"), track.tpcNClsShared()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fTPCcRows"), track.tpcNClsCrossedRows()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); - registry.fill(HIST("TrackCuts/Phi/Before/PosDaughter/fTPCncls"), track.tpcNClsFound()); + } + } + // PPL + if (TriggerSelections.filterSwitches->get("Switch", "PPL") > 0) { + for (size_t p1 = 0; p1 < vecProton.size(); p1++) { + for (size_t p2 = p1 + 1; p2 < vecProton.size(); p2++) { + for (size_t l1 = 0; l1 < vecLambda.size(); l1++) { + if (idxProton.at(p1) == idxLambdaDaughProton.at(l1) || idxProton.at(p2) == idxLambdaDaughProton.at(l1)) { + continue; } - if (track.sign() < 0) { - temp.SetM(mMassKaonMinus); - antikaons.push_back(temp); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fP"), track.p()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fPTPC"), track.tpcInnerParam()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fPt"), track.pt()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fEta"), track.eta()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fPhi"), track.phi()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fNsigmaTPCvsP"), track.tpcInnerParam(), track.tpcNSigmaKa()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fNsigmaTOFvsP"), track.tpcInnerParam(), track.tofNSigmaKa()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fNsigmaTPCTOFvsP"), track.tpcInnerParam(), std::abs(std::sqrt(track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa()))); - - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fDCAxy"), track.dcaXY()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fDCAz"), track.dcaZ()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fTPCsCls"), track.tpcNClsShared()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fTPCcRows"), track.tpcNClsCrossedRows()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); - registry.fill(HIST("TrackCuts/Phi/Before/NegDaughter/fTPCncls"), track.tpcNClsFound()); + q3 = getQ3(vecProton.at(p1), vecProton.at(p2), vecLambda.at(l1)); + registryTriggerQA.fill(HIST("PPL/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPL/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPL/all/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPL/all/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPL/all/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPL/all/fLambdaQ3VsPt"), q3, vecLambda.at(l1).Pt()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PPL")) { + signalLooseLimit[cf_trigger::kPPL] += 1; + registryTriggerQA.fill(HIST("PPL/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPL/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPL/loose/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPL/loose/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPL/loose/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPL/loose/fLambdaQ3VsPt"), q3, vecLambda.at(l1).Pt()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PPL")) { + signalTightLimit[cf_trigger::kPPL] += 1; + registryTriggerQA.fill(HIST("PPL/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPL/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPL/tight/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPL/tight/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPL/tight/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPL/tight/fLambdaQ3VsPt"), q3, vecLambda.at(l1).Pt()); + } } } } } - - // keep track of daugher indices to avoid selfcorrelations - std::vector LambdaPosDaughIndex = {}; - std::vector LambdaNegDaughIndex = {}; - std::vector AntiLambdaPosDaughIndex = {}; - std::vector AntiLambdaNegDaughIndex = {}; - - for (auto& v0 : fullV0s) { - - auto postrack = v0.template posTrack_as(); - auto negtrack = v0.template negTrack_as(); - double nTPCSigmaPos[2]{postrack.tpcNSigmaPr(), postrack.tpcNSigmaPi()}; - double nTPCSigmaNeg[2]{negtrack.tpcNSigmaPr(), negtrack.tpcNSigmaPi()}; - if (ConfUseManualPIDdaughterPion) { - auto bgScalingPion = 1 / mMassPion; // momentum scaling? - if (BBPion.size() == 6) - nTPCSigmaPos[1] = updatePID(postrack, bgScalingPion, BBPion); - if (BBAntipion.size() == 6) - nTPCSigmaNeg[1] = updatePID(negtrack, bgScalingPion, BBAntipion); - } - if (ConfUseManualPIDdaughterProton) { - auto bgScalingProton = 1 / mMassProton; // momentum scaling? - if (BBProton.size() == 6) - nTPCSigmaPos[0] = updatePID(postrack, bgScalingProton, BBProton); - if (BBAntiproton.size() == 6) - nTPCSigmaNeg[0] = updatePID(negtrack, bgScalingProton, BBAntiproton); - } - registry.fill(HIST("TrackCuts/V0Before/fPtLambdaBefore"), v0.pt()); - registry.fill(HIST("TrackCuts/V0Before/fInvMassLambdaBefore"), v0.mLambda()); - registry.fill(HIST("TrackCuts/V0Before/fInvMassAntiLambdaBefore"), v0.mAntiLambda()); - registry.fill(HIST("TrackCuts/V0Before/fInvMassLambdavsAntiLambda"), v0.mLambda(), v0.mAntiLambda()); - registry.fill(HIST("TrackCuts/V0Before/fInvMassV0BeforeKaonvsV0Before"), v0.mK0Short(), v0.mLambda()); - registry.fill(HIST("TrackCuts/V0Before/fV0DCADaugh"), v0.dcaV0daughters()); - registry.fill(HIST("TrackCuts/V0Before/fV0CPA"), v0.v0cosPA()); - registry.fill(HIST("TrackCuts/V0Before/fV0TranRad"), v0.v0radius()); - registry.fill(HIST("TrackCuts/V0Before/f0DecVtxX"), v0.x()); - registry.fill(HIST("TrackCuts/V0Before/f0DecVtxY"), v0.y()); - registry.fill(HIST("TrackCuts/V0Before/f0DecVtxZ"), v0.z()); - - registry.fill(HIST("TrackCuts/V0Before/PosDaughter/Eta"), postrack.eta()); - registry.fill(HIST("TrackCuts/V0Before/PosDaughter/DCAXY"), postrack.dcaXY()); - registry.fill(HIST("TrackCuts/V0Before/PosDaughter/fTPCncls"), postrack.tpcNClsFound()); - registry.fill(HIST("TrackCuts/V0Before/NegDaughter/Eta"), negtrack.eta()); - registry.fill(HIST("TrackCuts/V0Before/NegDaughter/DCAXY"), negtrack.dcaXY()); - registry.fill(HIST("TrackCuts/V0Before/NegDaughter/fTPCncls"), negtrack.tpcNClsFound()); - registry.fill(HIST("TrackCuts/V0Before/PosDaughter/fNsigmaTPCvsPProtonV0Daugh"), postrack.tpcInnerParam(), nTPCSigmaPos[0]); - registry.fill(HIST("TrackCuts/V0Before/NegDaughter/fNsigmaTPCvsPPionMinusV0Daugh"), negtrack.tpcInnerParam(), nTPCSigmaNeg[1]); - registry.fill(HIST("TrackCuts/V0Before/NegDaughter/fNsigmaTPCvsPAntiProtonV0Daugh"), negtrack.tpcInnerParam(), nTPCSigmaNeg[0]); - registry.fill(HIST("TrackCuts/V0Before/PosDaughter/fNsigmaTPCvsPPionPlusV0Daugh"), postrack.tpcInnerParam(), nTPCSigmaPos[1]); - - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPProtonV0DaughBefore"), postrack.tpcInnerParam(), nTPCSigmaPos[0]); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPPionPlusAntiV0DaughBefore"), postrack.tpcInnerParam(), nTPCSigmaNeg[1]); - - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPPionMinusV0DaughBefore"), negtrack.tpcInnerParam(), nTPCSigmaNeg[1]); - registry.fill(HIST("TrackCuts/NSigmaBefore/fNsigmaTPCvsPAntiProtonAntiV0DaughBefore"), negtrack.tpcInnerParam(), nTPCSigmaNeg[0]); - - if (isSelectedMinimalV0(col, v0, postrack, negtrack, 1, nTPCSigmaPos, nTPCSigmaNeg)) { - ROOT::Math::PtEtaPhiMVector temp(v0.pt(), v0.eta(), v0.phi(), mMassLambda); - lambdas.push_back(temp); - LambdaPosDaughIndex.push_back(postrack.globalIndex()); - LambdaNegDaughIndex.push_back(negtrack.globalIndex()); - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalProtonPlusV0Daughter"), postrack.tpcInnerParam(), postrack.tpcSignal()); - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalPionMinusV0Daughter"), negtrack.tpcInnerParam(), negtrack.tpcSignal()); - registry.fill(HIST("TrackCuts/Lambda/fPtLambda"), v0.pt()); - registry.fill(HIST("TrackCuts/Lambda/fInvMassLambda"), v0.mLambda()); - registry.fill(HIST("TrackCuts/Lambda/fInvMassLambdaKaonvsLambda"), v0.mK0Short(), v0.mLambda()); - registry.fill(HIST("TrackCuts/Lambda/fV0DCADaugh"), v0.dcaV0daughters()); - registry.fill(HIST("TrackCuts/Lambda/fV0CPA"), v0.v0cosPA()); - registry.fill(HIST("TrackCuts/Lambda/fV0TranRad"), v0.v0radius()); - registry.fill(HIST("TrackCuts/Lambda/f0DecVtxX"), v0.x()); - registry.fill(HIST("TrackCuts/Lambda/f0DecVtxY"), v0.y()); - registry.fill(HIST("TrackCuts/Lambda/f0DecVtxZ"), v0.z()); - - registry.fill(HIST("TrackCuts/Lambda/PosDaughter/Eta"), postrack.eta()); - registry.fill(HIST("TrackCuts/Lambda/PosDaughter/DCAXY"), postrack.dcaXY()); - registry.fill(HIST("TrackCuts/Lambda/PosDaughter/fTPCncls"), postrack.tpcNClsFound()); - registry.fill(HIST("TrackCuts/Lambda/NegDaughter/Eta"), negtrack.eta()); - registry.fill(HIST("TrackCuts/Lambda/NegDaughter/DCAXY"), negtrack.dcaXY()); - registry.fill(HIST("TrackCuts/Lambda/NegDaughter/fTPCncls"), negtrack.tpcNClsFound()); - registry.fill(HIST("TrackCuts/Lambda/PosDaughter/fNsigmaTPCvsPProtonV0Daugh"), postrack.tpcInnerParam(), nTPCSigmaPos[0]); - registry.fill(HIST("TrackCuts/Lambda/NegDaughter/fNsigmaTPCvsPPionMinusV0Daugh"), negtrack.tpcInnerParam(), nTPCSigmaNeg[1]); - } - if (isSelectedMinimalV0(col, v0, postrack, negtrack, -1, nTPCSigmaPos, nTPCSigmaNeg)) { - ROOT::Math::PtEtaPhiMVector temp(v0.pt(), v0.eta(), v0.phi(), mMassLambda); - antilambdas.push_back(temp); - AntiLambdaPosDaughIndex.push_back(postrack.globalIndex()); - AntiLambdaNegDaughIndex.push_back(negtrack.globalIndex()); - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalPionPlusV0Daughter"), postrack.tpcInnerParam(), postrack.tpcSignal()); - registry.fill(HIST("TrackCuts/TPCSignal/fTPCSignalProtonMinusV0Daughter"), negtrack.tpcInnerParam(), negtrack.tpcSignal()); - registry.fill(HIST("TrackCuts/AntiLambda/fPtAntiLambda"), v0.pt()); - registry.fill(HIST("TrackCuts/AntiLambda/fInvMassAntiLambda"), v0.mAntiLambda()); - registry.fill(HIST("TrackCuts/AntiLambda/fInvMassAntiLambdaKaonvsAntiLambda"), v0.mK0Short(), v0.mAntiLambda()); - registry.fill(HIST("TrackCuts/AntiLambda/fV0DCADaugh"), v0.dcaV0daughters()); - registry.fill(HIST("TrackCuts/AntiLambda/fV0CPA"), v0.v0cosPA()); - registry.fill(HIST("TrackCuts/AntiLambda/fV0TranRad"), v0.v0radius()); - registry.fill(HIST("TrackCuts/AntiLambda/f0DecVtxX"), v0.x()); - registry.fill(HIST("TrackCuts/AntiLambda/f0DecVtxY"), v0.y()); - registry.fill(HIST("TrackCuts/AntiLambda/f0DecVtxZ"), v0.z()); - - registry.fill(HIST("TrackCuts/AntiLambda/PosDaughter/Eta"), postrack.eta()); - registry.fill(HIST("TrackCuts/AntiLambda/PosDaughter/DCAXY"), postrack.dcaXY()); - registry.fill(HIST("TrackCuts/AntiLambda/PosDaughter/fTPCncls"), postrack.tpcNClsFound()); - registry.fill(HIST("TrackCuts/AntiLambda/NegDaughter/Eta"), negtrack.eta()); - registry.fill(HIST("TrackCuts/AntiLambda/NegDaughter/DCAXY"), negtrack.dcaXY()); - registry.fill(HIST("TrackCuts/AntiLambda/NegDaughter/fTPCncls"), negtrack.tpcNClsFound()); - registry.fill(HIST("TrackCuts/AntiLambda/NegDaughter/fNsigmaTPCvsPAntiProtonAntiV0Daugh"), negtrack.tpcInnerParam(), nTPCSigmaNeg[0]); - registry.fill(HIST("TrackCuts/AntiLambda/PosDaughter/fNsigmaTPCvsPPionPlusAntiV0Daugh"), postrack.tpcInnerParam(), nTPCSigmaPos[1]); - } - } - - if (ConfTriggerSwitches->get("Switch", "ppPhi") > 0.) { - for (const auto& postrack : kaons) { - for (const auto& negtrack : antikaons) { - - ROOT::Math::PtEtaPhiMVector temp = postrack + negtrack; - - registry.fill(HIST("TrackCuts/Phi/Before/fInvMass"), temp.M()); - registry.fill(HIST("TrackCuts/Phi/Before/fPt"), temp.pt()); - registry.fill(HIST("TrackCuts/Phi/Before/fEta"), temp.eta()); - registry.fill(HIST("TrackCuts/Phi/Before/fPhi"), temp.phi()); - - if ((temp.M() >= PPPhi.ConfResoInvMassLowLimit.value) && (temp.M() <= PPPhi.ConfResoInvMassUpLimit.value)) { - - phi.push_back(temp); - - registry.fill(HIST("TrackCuts/Phi/After/fInvMass"), temp.M()); - registry.fill(HIST("TrackCuts/Phi/After/fPt"), temp.pt()); - registry.fill(HIST("TrackCuts/Phi/After/fEta"), temp.eta()); - registry.fill(HIST("TrackCuts/Phi/After/fPhi"), temp.phi()); - - registry.fill(HIST("TrackCuts/Phi/After/PosDaughter/fPt"), postrack.pt()); - registry.fill(HIST("TrackCuts/Phi/After/PosDaughter/fEta"), postrack.eta()); - registry.fill(HIST("TrackCuts/Phi/After/PosDaughter/fPhi"), postrack.phi()); - - registry.fill(HIST("TrackCuts/Phi/After/NegDaughter/fPt"), negtrack.pt()); - registry.fill(HIST("TrackCuts/Phi/After/NegDaughter/fEta"), negtrack.eta()); - registry.fill(HIST("TrackCuts/Phi/After/NegDaughter/fPhi"), negtrack.phi()); + for (size_t p1 = 0; p1 < vecAntiProton.size(); p1++) { + for (size_t p2 = p1 + 1; p2 < vecAntiProton.size(); p2++) { + for (size_t l1 = 0; l1 < vecAntiLambda.size(); l1++) { + if (idxAntiProton.at(p1) == idxAntiLambdaDaughProton.at(l1) || idxAntiProton.at(p2) == idxAntiLambdaDaughProton.at(l1)) { + continue; + } + q3 = getQ3(vecAntiProton.at(p1), vecAntiProton.at(p2), vecAntiLambda.at(l1)); + registryTriggerQA.fill(HIST("PPL/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPL/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPL/all/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPL/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPL/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPL/all/fAntiLambdaQ3VsPt"), q3, vecAntiLambda.at(l1).Pt()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PPL")) { + signalLooseLimit[cf_trigger::kPPL] += 1; + registryTriggerQA.fill(HIST("PPL/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPL/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPL/loose/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPL/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPL/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPL/loose/fAntiLambdaQ3VsPt"), q3, vecAntiLambda.at(l1).Pt()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PPL")) { + signalTightLimit[cf_trigger::kPPL] += 1; + registryTriggerQA.fill(HIST("PPL/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPL/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPL/tight/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPL/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPL/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPL/tight/fAntiLambdaQ3VsPt"), q3, vecAntiLambda.at(l1).Pt()); + } } } } } - - float Q3 = 999.f, kstar = 999.f; - if (ConfTriggerSwitches->get("Switch", "ppp") > 0.) { - // ppp trigger - for (auto iProton1 = protons.begin(); iProton1 != protons.end(); ++iProton1) { - auto iProton2 = iProton1 + 1; - for (; iProton2 != protons.end(); ++iProton2) { - auto iProton3 = iProton2 + 1; - for (; iProton3 != protons.end(); ++iProton3) { - Q3 = getQ3(*iProton1, *iProton2, *iProton3); - registry.fill(HIST("ppp/fSE_particle"), Q3); - registry.fill(HIST("ppp/fProtonPtVsQ3"), Q3, (*iProton1).Pt()); - registry.fill(HIST("ppp/fProtonPtVsQ3"), Q3, (*iProton2).Pt()); - registry.fill(HIST("ppp/fProtonPtVsQ3"), Q3, (*iProton3).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kPPP)) { - if (ConfDownsample->get("Switch", "PPP") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "PPP")) { - registry.fill(HIST("ppp/fSE_particle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kPPP] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kPPP] += 1; - } + } + // PLL + if (TriggerSelections.filterSwitches->get("Switch", "PLL") > 0) { + for (size_t l1 = 0; l1 < vecLambda.size(); l1++) { + for (size_t l2 = l1 + 1; l2 < vecLambda.size(); l2++) { + for (size_t p1 = 0; p1 < vecProton.size(); p1++) { + if (idxProton.at(p1) == idxLambdaDaughProton.at(l1) || idxProton.at(p1) == idxLambdaDaughProton.at(l2)) { + continue; + } + if (idxLambdaDaughProton.at(l1) == idxLambdaDaughProton.at(l2) || idxLambdaDaughPion.at(l1) == idxLambdaDaughPion.at(l2)) { + continue; + } + q3 = getQ3(vecLambda.at(l1), vecLambda.at(l2), vecProton.at(p1)); + registryTriggerQA.fill(HIST("PLL/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PLL/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PLL/all/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PLL/all/fLambdaQ3VsPt"), q3, vecLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("PLL/all/fLambdaQ3VsPt"), q3, vecLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("PLL/all/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PLL")) { + signalLooseLimit[cf_trigger::kPLL] += 1; + registryTriggerQA.fill(HIST("PLL/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PLL/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PLL/loose/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PLL/loose/fLambdaQ3VsPt"), q3, vecLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("PLL/loose/fLambdaQ3VsPt"), q3, vecLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("PLL/loose/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PLL")) { + signalTightLimit[cf_trigger::kPLL] += 1; + registryTriggerQA.fill(HIST("PLL/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PLL/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PLL/tight/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PLL/tight/fLambdaQ3VsPt"), q3, vecLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("PLL/tight/fLambdaQ3VsPt"), q3, vecLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("PLL/tight/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); } } } } - for (auto iAntiProton1 = antiprotons.begin(); iAntiProton1 != antiprotons.end(); ++iAntiProton1) { - auto iAntiProton2 = iAntiProton1 + 1; - for (; iAntiProton2 != antiprotons.end(); ++iAntiProton2) { - auto iAntiProton3 = iAntiProton2 + 1; - for (; iAntiProton3 != antiprotons.end(); ++iAntiProton3) { - Q3 = getQ3(*iAntiProton1, *iAntiProton2, *iAntiProton3); - registry.fill(HIST("ppp/fSE_antiparticle"), Q3); - registry.fill(HIST("ppp/fAntiProtonPtVsQ3"), Q3, (*iAntiProton1).Pt()); - registry.fill(HIST("ppp/fAntiProtonPtVsQ3"), Q3, (*iAntiProton2).Pt()); - registry.fill(HIST("ppp/fAntiProtonPtVsQ3"), Q3, (*iAntiProton3).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kPPP)) { - if (ConfDownsample->get("Switch", "aPaPaP") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "aPaPaP")) { - registry.fill(HIST("ppp/fSE_antiparticle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kPPP] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kPPP] += 1; - } + } + for (size_t l1 = 0; l1 < vecAntiLambda.size(); l1++) { + for (size_t l2 = l1 + 1; l2 < vecAntiLambda.size(); l2++) { + for (size_t p1 = 0; p1 < vecAntiProton.size(); p1++) { + if (idxAntiProton.at(p1) == idxAntiLambdaDaughProton.at(l1) || idxAntiProton.at(p1) == idxAntiLambdaDaughProton.at(l2)) { + continue; + } + if (idxAntiLambdaDaughProton.at(l1) == idxAntiLambdaDaughProton.at(l2) || idxAntiLambdaDaughPion.at(l1) == idxAntiLambdaDaughPion.at(l2)) { + continue; + } + q3 = getQ3(vecAntiLambda.at(l1), vecAntiLambda.at(l2), vecAntiProton.at(p1)); + registryTriggerQA.fill(HIST("PLL/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PLL/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PLL/all/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PLL/all/fAntiLambdaQ3VsPt"), q3, vecAntiLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("PLL/all/fAntiLambdaQ3VsPt"), q3, vecAntiLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("PLL/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PLL")) { + signalLooseLimit[cf_trigger::kPLL] += 1; + registryTriggerQA.fill(HIST("PLL/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PLL/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PLL/loose/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PLL/loose/fAntiLambdaQ3VsPt"), q3, vecAntiLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("PLL/loose/fAntiLambdaQ3VsPt"), q3, vecAntiLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("PLL/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PLL")) { + signalTightLimit[cf_trigger::kPLL] += 1; + registryTriggerQA.fill(HIST("PLL/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PLL/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PLL/tight/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PLL/tight/fAntiLambdaQ3VsPt"), q3, vecAntiLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("PLL/tight/fAntiLambdaQ3VsPt"), q3, vecAntiLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("PLL/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); } } } } } - if (ConfTriggerSwitches->get("Switch", "ppL") > 0.) { - // ppl trigger - for (auto iProton1 = protons.begin(); iProton1 != protons.end(); ++iProton1) { - auto iProton2 = iProton1 + 1; - auto i1 = std::distance(protons.begin(), iProton1); - for (; iProton2 != protons.end(); ++iProton2) { - auto i2 = std::distance(protons.begin(), iProton2); - for (auto iLambda1 = lambdas.begin(); iLambda1 != lambdas.end(); ++iLambda1) { - auto i3 = std::distance(lambdas.begin(), iLambda1); - if (ConfAutocorRejection.value && - (ProtonIndex.at(i1) == LambdaPosDaughIndex.at(i3) || - ProtonIndex.at(i2) == LambdaPosDaughIndex.at(i3))) { - continue; - } - Q3 = getQ3(*iProton1, *iProton2, *iLambda1); - registry.fill(HIST("ppl/fSE_particle"), Q3); - registry.fill(HIST("ppl/fProtonPtVsQ3"), Q3, (*iProton1).Pt()); - registry.fill(HIST("ppl/fProtonPtVsQ3"), Q3, (*iProton2).Pt()); - registry.fill(HIST("ppl/fLambdaPtVsQ3"), Q3, (*iLambda1).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kPPL)) { - if (ConfDownsample->get("Switch", "PPL") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "PPL")) { - registry.fill(HIST("ppl/fSE_particle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kPPL] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kPPL] += 1; - } + } + // LLL + if (TriggerSelections.filterSwitches->get("Switch", "LLL") > 0) { + for (size_t l1 = 0; l1 < vecLambda.size(); l1++) { + for (size_t l2 = l1 + 1; l2 < vecLambda.size(); l2++) { + for (size_t l3 = l2 + 1; l3 < vecLambda.size(); l3++) { + if (idxLambdaDaughProton.at(l1) == idxLambdaDaughProton.at(l2) || idxLambdaDaughPion.at(l1) == idxLambdaDaughPion.at(l2) || + idxLambdaDaughProton.at(l2) == idxLambdaDaughProton.at(l3) || idxLambdaDaughPion.at(l2) == idxLambdaDaughPion.at(l3) || + idxLambdaDaughProton.at(l3) == idxLambdaDaughProton.at(l1) || idxLambdaDaughPion.at(l3) == idxLambdaDaughPion.at(l1)) { + continue; + } + q3 = getQ3(vecLambda.at(l1), vecLambda.at(l2), vecLambda.at(l3)); + registryTriggerQA.fill(HIST("LLL/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LLL/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LLL/all/fSE_particle"), q3); + registryTriggerQA.fill(HIST("LLL/all/fLambdaQ3VsPt"), q3, vecLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LLL/all/fLambdaQ3VsPt"), q3, vecLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("LLL/all/fLambdaQ3VsPt"), q3, vecLambda.at(l3).Pt()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "LLL")) { + signalLooseLimit[cf_trigger::kLLL] += 1; + registryTriggerQA.fill(HIST("LLL/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LLL/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LLL/loose/fSE_particle"), q3); + registryTriggerQA.fill(HIST("LLL/loose/fLambdaQ3VsPt"), q3, vecLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LLL/loose/fLambdaQ3VsPt"), q3, vecLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("LLL/loose/fLambdaQ3VsPt"), q3, vecLambda.at(l3).Pt()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "LLL")) { + signalTightLimit[cf_trigger::kLLL] += 1; + registryTriggerQA.fill(HIST("LLL/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LLL/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LLL/tight/fSE_particle"), q3); + registryTriggerQA.fill(HIST("LLL/tight/fLambdaQ3VsPt"), q3, vecLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LLL/tight/fLambdaQ3VsPt"), q3, vecLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("LLL/tight/fLambdaQ3VsPt"), q3, vecLambda.at(l3).Pt()); } } } } - for (auto iAntiProton1 = antiprotons.begin(); iAntiProton1 != antiprotons.end(); ++iAntiProton1) { - auto iAntiProton2 = iAntiProton1 + 1; - auto i1 = std::distance(antiprotons.begin(), iAntiProton1); - for (; iAntiProton2 != antiprotons.end(); ++iAntiProton2) { - auto i2 = std::distance(antiprotons.begin(), iAntiProton2); - for (auto iAntiLambda1 = antilambdas.begin(); iAntiLambda1 != antilambdas.end(); ++iAntiLambda1) { - auto i3 = std::distance(antilambdas.begin(), iAntiLambda1); - if (ConfAutocorRejection.value && - (AntiProtonIndex.at(i1) == AntiLambdaNegDaughIndex.at(i3) || - AntiProtonIndex.at(i2) == AntiLambdaNegDaughIndex.at(i3))) { - continue; - } - Q3 = getQ3(*iAntiProton1, *iAntiProton2, *iAntiLambda1); - registry.fill(HIST("ppl/fSE_antiparticle"), Q3); - registry.fill(HIST("ppl/fAntiProtonPtVsQ3"), Q3, (*iAntiProton1).Pt()); - registry.fill(HIST("ppl/fAntiProtonPtVsQ3"), Q3, (*iAntiProton2).Pt()); - registry.fill(HIST("ppl/fAntiLambdaPtVsQ3"), Q3, (*iAntiLambda1).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kPPL)) { - if (ConfDownsample->get("Switch", "aPaPaL") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "aPaPaL")) { - registry.fill(HIST("ppl/fSE_antiparticle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kPPL] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kPPL] += 1; - } + } + for (size_t l1 = 0; l1 < vecAntiLambda.size(); l1++) { + for (size_t l2 = l1 + 1; l2 < vecAntiLambda.size(); l2++) { + for (size_t l3 = l2 + 1; l3 < vecAntiLambda.size(); l3++) { + if (idxAntiLambdaDaughProton.at(l1) == idxAntiLambdaDaughProton.at(l2) || idxAntiLambdaDaughPion.at(l1) == idxAntiLambdaDaughPion.at(l2) || + idxAntiLambdaDaughProton.at(l2) == idxAntiLambdaDaughProton.at(l3) || idxAntiLambdaDaughPion.at(l2) == idxAntiLambdaDaughPion.at(l3) || + idxAntiLambdaDaughProton.at(l3) == idxAntiLambdaDaughProton.at(l1) || idxAntiLambdaDaughPion.at(l3) == idxAntiLambdaDaughPion.at(l1)) { + continue; + } + q3 = getQ3(vecAntiLambda.at(l1), vecAntiLambda.at(l2), vecAntiLambda.at(l3)); + registryTriggerQA.fill(HIST("LLL/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LLL/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LLL/all/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("LLL/all/fLambdaQ3VsPt"), q3, vecAntiLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LLL/all/fLambdaQ3VsPt"), q3, vecAntiLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("LLL/all/fLambdaQ3VsPt"), q3, vecAntiLambda.at(l3).Pt()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "LLL")) { + signalLooseLimit[cf_trigger::kLLL] += 1; + registryTriggerQA.fill(HIST("LLL/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LLL/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LLL/loose/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("LLL/loose/fLambdaQ3VsPt"), q3, vecAntiLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LLL/loose/fLambdaQ3VsPt"), q3, vecAntiLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("LLL/loose/fLambdaQ3VsPt"), q3, vecAntiLambda.at(l3).Pt()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "LLL")) { + signalTightLimit[cf_trigger::kLLL] += 1; + registryTriggerQA.fill(HIST("LLL/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LLL/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LLL/tight/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("LLL/tight/fLambdaQ3VsPt"), q3, vecAntiLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LLL/tight/fLambdaQ3VsPt"), q3, vecAntiLambda.at(l2).Pt()); + registryTriggerQA.fill(HIST("LLL/tight/fLambdaQ3VsPt"), q3, vecAntiLambda.at(l3).Pt()); } } } } } - if (ConfTriggerSwitches->get("Switch", "pLL") > 0.) { - // pll trigger - for (auto iLambda1 = lambdas.begin(); iLambda1 != lambdas.end(); ++iLambda1) { - auto iLambda2 = iLambda1 + 1; - auto i1 = std::distance(lambdas.begin(), iLambda1); - for (; iLambda2 != lambdas.end(); ++iLambda2) { - auto i2 = std::distance(lambdas.begin(), iLambda2); - if (ConfAutocorRejection.value && - (LambdaPosDaughIndex.at(i1) == LambdaPosDaughIndex.at(i2) || - LambdaNegDaughIndex.at(i1) == LambdaNegDaughIndex.at(i2))) { + } + // PPPhi + if (TriggerSelections.filterSwitches->get("Switch", "PPPhi") > 0) { + for (size_t p1 = 0; p1 < vecProton.size(); p1++) { + for (size_t p2 = p1 + 1; p2 < vecProton.size(); p2++) { + for (size_t phi1 = 0; phi1 < vecPhi.size(); phi1++) { + if (idxProton.at(p1) == idxPhiDaughPos.at(phi1) || idxProton.at(p2) == idxPhiDaughPos.at(phi1)) { continue; } - for (auto iProton1 = protons.begin(); iProton1 != protons.end(); ++iProton1) { - auto i3 = std::distance(protons.begin(), iProton1); - if (ConfAutocorRejection.value && - (LambdaPosDaughIndex.at(i1) == ProtonIndex.at(i3) || - LambdaPosDaughIndex.at(i2) == ProtonIndex.at(i3))) { - continue; - } - Q3 = getQ3(*iLambda1, *iLambda2, *iProton1); - registry.fill(HIST("pll/fSE_particle"), Q3); - registry.fill(HIST("pll/fProtonPtVsQ3"), Q3, (*iProton1).Pt()); - registry.fill(HIST("pll/fLambdaPtVsQ3"), Q3, (*iLambda1).Pt()); - registry.fill(HIST("pll/fLambdaPtVsQ3"), Q3, (*iLambda2).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kPLL)) { - if (ConfDownsample->get("Switch", "PLL") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "PLL")) { - registry.fill(HIST("pll/fSE_particle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kPLL] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kPLL] += 1; - } + q3 = getQ3(vecProton.at(p1), vecProton.at(p2), vecPhi.at(phi1)); + registryTriggerQA.fill(HIST("PPPhi/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPPhi/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPPhi/all/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPPhi/all/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/all/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPPhi/all/fPhiQ3VsPt"), q3, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/all/fPhiQ3VsInvMass"), q3, vecPhi.at(phi1).M()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PPPhi")) { + signalLooseLimit[cf_trigger::kPPPhi] += 1; + registryTriggerQA.fill(HIST("PPPhi/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPPhi/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPPhi/loose/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPPhi/loose/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/loose/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPPhi/loose/fPhiQ3VsPt"), q3, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/loose/fPhiQ3VsInvMass"), q3, vecPhi.at(phi1).M()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PPPhi") && + vecPhi.at(phi1).M() > PhiSelections.tightInvMassLow.value && vecPhi.at(phi1).M() < PhiSelections.tightInvMassUp.value) { + signalTightLimit[cf_trigger::kPPPhi] += 1; + registryTriggerQA.fill(HIST("PPPhi/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPPhi/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPPhi/tight/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPPhi/tight/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/tight/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPPhi/tight/fPhiQ3VsPt"), q3, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/tight/fPhiQ3VsInvMass"), q3, vecPhi.at(phi1).M()); } } } } - for (auto iAntiLambda1 = antilambdas.begin(); iAntiLambda1 != antilambdas.end(); ++iAntiLambda1) { - auto iAntiLambda2 = iAntiLambda1 + 1; - auto i1 = std::distance(antilambdas.begin(), iAntiLambda1); - for (; iAntiLambda2 != antilambdas.end(); ++iAntiLambda2) { - auto i2 = std::distance(antilambdas.begin(), iAntiLambda2); - if (ConfAutocorRejection.value && - (AntiLambdaPosDaughIndex.at(i1) == AntiLambdaPosDaughIndex.at(i2) || - AntiLambdaNegDaughIndex.at(i1) == AntiLambdaNegDaughIndex.at(i2))) { + } + for (size_t p1 = 0; p1 < vecAntiProton.size(); p1++) { + for (size_t p2 = p1 + 1; p2 < vecAntiProton.size(); p2++) { + for (size_t phi1 = 0; phi1 < vecPhi.size(); phi1++) { + if (idxAntiProton.at(p1) == idxPhiDaughNeg.at(phi1) || idxAntiProton.at(p2) == idxPhiDaughNeg.at(phi1)) { continue; } - for (auto iAntiProton1 = antiprotons.begin(); iAntiProton1 != antiprotons.end(); ++iAntiProton1) { - auto i3 = std::distance(antiprotons.begin(), iAntiProton1); - if (ConfAutocorRejection.value && - (AntiLambdaNegDaughIndex.at(i1) == AntiProtonIndex.at(i3) || - AntiLambdaNegDaughIndex.at(i2) == AntiProtonIndex.at(i3))) { - continue; - } - Q3 = getQ3(*iAntiLambda1, *iAntiLambda2, *iAntiProton1); - registry.fill(HIST("pll/fSE_antiparticle"), Q3); - registry.fill(HIST("pll/fAntiProtonPtVsQ3"), Q3, (*iAntiProton1).Pt()); - registry.fill(HIST("pll/fAntiLambdaPtVsQ3"), Q3, (*iAntiLambda1).Pt()); - registry.fill(HIST("pll/fAntiLambdaPtVsQ3"), Q3, (*iAntiLambda2).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kPLL)) { - if (ConfDownsample->get("Switch", "aPaLaL") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "aPaLaL")) { - registry.fill(HIST("pll/fSE_antiparticle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kPLL] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kPLL] += 1; - } + q3 = getQ3(vecAntiProton.at(p1), vecAntiProton.at(p2), vecPhi.at(phi1)); + registryTriggerQA.fill(HIST("PPPhi/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPPhi/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPPhi/all/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPPhi/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPPhi/all/fPhiQ3VsPt"), q3, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/all/fPhiQ3VsInvMass"), q3, vecPhi.at(phi1).M()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PPPhi")) { + signalLooseLimit[cf_trigger::kPPPhi] += 1; + registryTriggerQA.fill(HIST("PPPhi/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPPhi/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPPhi/loose/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPPhi/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPPhi/loose/fPhiQ3VsPt"), q3, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/loose/fPhiQ3VsInvMass"), q3, vecPhi.at(phi1).M()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PPPhi") && + vecPhi.at(phi1).M() > PhiSelections.tightInvMassLow.value && vecPhi.at(phi1).M() < PhiSelections.tightInvMassUp.value) { + signalTightLimit[cf_trigger::kPPPhi] += 1; + registryTriggerQA.fill(HIST("PPPhi/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPPhi/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPPhi/tight/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPPhi/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPPhi/tight/fPhiQ3VsPt"), q3, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PPPhi/tight/fPhiQ3VsInvMass"), q3, vecPhi.at(phi1).M()); } } } } } - if (ConfTriggerSwitches->get("Switch", "LLL") > 0.) { - // lll trigger - for (auto iLambda1 = lambdas.begin(); iLambda1 != lambdas.end(); ++iLambda1) { - auto iLambda2 = iLambda1 + 1; - auto i1 = std::distance(lambdas.begin(), iLambda1); - for (; iLambda2 != lambdas.end(); ++iLambda2) { - auto i2 = std::distance(lambdas.begin(), iLambda2); - if (ConfAutocorRejection.value && - (LambdaPosDaughIndex.at(i1) == LambdaPosDaughIndex.at(i2) || - LambdaNegDaughIndex.at(i1) == LambdaNegDaughIndex.at(i2))) { + } + // PPRho + if (TriggerSelections.filterSwitches->get("Switch", "PPRho") > 0) { + for (size_t p1 = 0; p1 < vecProton.size(); p1++) { + for (size_t p2 = p1 + 1; p2 < vecProton.size(); p2++) { + for (size_t r1 = 0; r1 < vecRho.size(); r1++) { + if (idxProton.at(p1) == idxRhoDaughPos.at(r1) || idxProton.at(p2) == idxRhoDaughPos.at(r1)) { continue; } - auto iLambda3 = iLambda2 + 1; - for (; iLambda3 != lambdas.end(); ++iLambda3) { - auto i3 = std::distance(lambdas.begin(), iLambda3); - if (ConfAutocorRejection.value && - (LambdaPosDaughIndex.at(i1) == LambdaPosDaughIndex.at(i3) || - LambdaNegDaughIndex.at(i1) == LambdaNegDaughIndex.at(i3) || - LambdaPosDaughIndex.at(i2) == LambdaPosDaughIndex.at(i3) || - LambdaNegDaughIndex.at(i2) == LambdaNegDaughIndex.at(i3))) { - continue; - } - Q3 = getQ3(*iLambda1, *iLambda2, *iLambda3); - registry.fill(HIST("lll/fSE_particle"), Q3); - registry.fill(HIST("lll/fLambdaPtVsQ3"), Q3, (*iLambda1).Pt()); - registry.fill(HIST("lll/fLambdaPtVsQ3"), Q3, (*iLambda2).Pt()); - registry.fill(HIST("lll/fLambdaPtVsQ3"), Q3, (*iLambda3).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kLLL)) { - if (ConfDownsample->get("Switch", "LLL") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "LLL")) { - registry.fill(HIST("lll/fSE_particle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kLLL] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kLLL] += 1; - } + q3 = getQ3(vecProton.at(p1), vecProton.at(p2), vecRho.at(r1)); + registryTriggerQA.fill(HIST("PPRho/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPRho/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPRho/all/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPRho/all/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPRho/all/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPRho/all/fRhoQ3VsPt"), q3, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("PPRho/all/fRhoQ3VsInvMass"), q3, vecRho.at(r1).M()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PPRho")) { + signalLooseLimit[cf_trigger::kPPRho] += 1; + registryTriggerQA.fill(HIST("PPRho/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPRho/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPRho/loose/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPRho/loose/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPRho/loose/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPRho/loose/fRhoQ3VsPt"), q3, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("PPRho/loose/fRhoQ3VsInvMass"), q3, vecRho.at(r1).M()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PPRho") && + vecRho.at(r1).M() > RhoSelections.tightInvMassLow.value && vecRho.at(r1).M() < RhoSelections.tightInvMassUp.value) { + signalTightLimit[cf_trigger::kPPRho] += 1; + registryTriggerQA.fill(HIST("PPRho/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPRho/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPRho/tight/fSE_particle"), q3); + registryTriggerQA.fill(HIST("PPRho/tight/fProtonQ3VsPt"), q3, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPRho/tight/fProtonQ3VsPt"), q3, vecProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPRho/tight/fRhoQ3VsPt"), q3, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("PPRho/tight/fRhoQ3VsInvMass"), q3, vecRho.at(r1).M()); } } } } - for (auto iAntiLambda1 = antilambdas.begin(); iAntiLambda1 != antilambdas.end(); ++iAntiLambda1) { - auto iAntiLambda2 = iAntiLambda1 + 1; - auto i1 = std::distance(antilambdas.begin(), iAntiLambda1); - for (; iAntiLambda2 != antilambdas.end(); ++iAntiLambda2) { - auto i2 = std::distance(antilambdas.begin(), iAntiLambda2); - if (ConfAutocorRejection.value && - (AntiLambdaPosDaughIndex.at(i1) == AntiLambdaPosDaughIndex.at(i2) || - AntiLambdaNegDaughIndex.at(i1) == AntiLambdaNegDaughIndex.at(i2))) { + } + for (size_t p1 = 0; p1 < vecAntiProton.size(); p1++) { + for (size_t p2 = p1 + 1; p2 < vecAntiProton.size(); p2++) { + for (size_t r1 = 0; r1 < vecRho.size(); r1++) { + if (idxAntiProton.at(p1) == idxRhoDaughNeg.at(r1) || idxAntiProton.at(p2) == idxRhoDaughNeg.at(r1)) { continue; } - auto iAntiLambda3 = iAntiLambda2 + 1; - for (; iAntiLambda3 != antilambdas.end(); ++iAntiLambda3) { - auto i3 = std::distance(antilambdas.begin(), iAntiLambda3); - if (ConfAutocorRejection.value && - (AntiLambdaPosDaughIndex.at(i1) == AntiLambdaPosDaughIndex.at(i3) || - AntiLambdaNegDaughIndex.at(i1) == AntiLambdaNegDaughIndex.at(i3) || - AntiLambdaPosDaughIndex.at(i2) == AntiLambdaPosDaughIndex.at(i3) || - AntiLambdaNegDaughIndex.at(i2) == AntiLambdaNegDaughIndex.at(i3))) { - continue; - } - Q3 = getQ3(*iAntiLambda1, *iAntiLambda2, *iAntiLambda3); - registry.fill(HIST("lll/fSE_antiparticle"), Q3); - registry.fill(HIST("lll/fAntiLambdaPtVsQ3"), Q3, (*iAntiLambda1).Pt()); - registry.fill(HIST("lll/fAntiLambdaPtVsQ3"), Q3, (*iAntiLambda2).Pt()); - registry.fill(HIST("lll/fAntiLambdaPtVsQ3"), Q3, (*iAntiLambda3).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kLLL)) { - if (ConfDownsample->get("Switch", "aLaLaL") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "aLaLaL")) { - registry.fill(HIST("lll/fSE_antiparticle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kLLL] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kLLL] += 1; - } + q3 = getQ3(vecAntiProton.at(p1), vecAntiProton.at(p2), vecRho.at(r1)); + registryTriggerQA.fill(HIST("PPRho/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPRho/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPRho/all/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPRho/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPRho/all/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPRho/all/fRhoQ3VsPt"), q3, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("PPRho/all/fRhoQ3VsInvMass"), q3, vecRho.at(r1).M()); + if (q3 < TriggerSelections.limits->get("Loose Limit", "PPRho")) { + signalLooseLimit[cf_trigger::kPPRho] += 1; + registryTriggerQA.fill(HIST("PPRho/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPRho/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPRho/loose/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPRho/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPRho/loose/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPRho/loose/fRhoQ3VsPt"), q3, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("PPRho/loose/fRhoQ3VsInvMass"), q3, vecRho.at(r1).M()); + if (q3 < TriggerSelections.limits->get("Tight Limit", "PPRho") && + vecRho.at(r1).M() > RhoSelections.tightInvMassLow.value && vecRho.at(r1).M() < RhoSelections.tightInvMassUp.value) { + signalTightLimit[cf_trigger::kPPRho] += 1; + registryTriggerQA.fill(HIST("PPRho/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PPRho/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PPRho/tight/fSE_antiparticle"), q3); + registryTriggerQA.fill(HIST("PPRho/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PPRho/tight/fAntiProtonQ3VsPt"), q3, vecAntiProton.at(p2).Pt()); + registryTriggerQA.fill(HIST("PPRho/tight/fRhoQ3VsPt"), q3, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("PPRho/tight/fRhoQ3VsInvMass"), q3, vecRho.at(r1).M()); } } } } } - if (ConfTriggerSwitches->get("Switch", "ppPhi") > 0.) { - // ppphi trigger - for (auto iProton1 = protons.begin(); iProton1 != protons.end(); ++iProton1) { - auto iProton2 = iProton1 + 1; - for (; iProton2 != protons.end(); ++iProton2) { - for (auto iPhi1 = phi.begin(); iPhi1 != phi.end(); ++iPhi1) { - Q3 = getQ3(*iProton1, *iProton2, *iPhi1); - registry.fill(HIST("ppphi/fSE_particle"), Q3); - registry.fill(HIST("ppphi/fProtonPtVsQ3"), Q3, (*iProton1).Pt()); - registry.fill(HIST("ppphi/fProtonPtVsQ3"), Q3, (*iProton2).Pt()); - registry.fill(HIST("ppphi/fPhiPtVsQ3"), Q3, (*iPhi1).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kPPPhi)) { - if (ConfDownsample->get("Switch", "PPPhi") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "PPPhi")) { - registry.fill(HIST("ppphi/fSE_particle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kPPPhi] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kPPPhi] += 1; - } - } + } + // PD + if (TriggerSelections.filterSwitches->get("Switch", "PD") > 0) { + for (size_t p1 = 0; p1 < vecProton.size(); p1++) { + for (size_t d1 = 0; d1 < vecDeuteron.size(); d1++) { + if (idxProton.at(p1) == idxDeuteron.at(d1)) { + continue; + } + kstar = getkstar(vecProton.at(p1), vecDeuteron.at(d1)); + registryTriggerQA.fill(HIST("PD/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PD/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PD/all/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("PD/all/fProtonKstarVsPt"), kstar, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PD/all/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + if (kstar < TriggerSelections.limits->get("Loose Limit", "PD")) { + signalLooseLimit[cf_trigger::kPD] += 1; + registryTriggerQA.fill(HIST("PD/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PD/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PD/loose/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("PD/loose/fProtonKstarVsPt"), kstar, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PD/loose/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + if (kstar < TriggerSelections.limits->get("Tight Limit", "PD")) { + signalTightLimit[cf_trigger::kPD] += 1; + registryTriggerQA.fill(HIST("PD/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PD/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PD/tight/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("PD/tight/fProtonKstarVsPt"), kstar, vecProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PD/tight/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); } } } - // apapphi trigger - for (auto iAntiProton1 = antiprotons.begin(); iAntiProton1 != antiprotons.end(); ++iAntiProton1) { - auto iAntiProton2 = iAntiProton1 + 1; - for (; iAntiProton2 != antiprotons.end(); ++iAntiProton2) { - for (auto iPhi1 = phi.begin(); iPhi1 != phi.end(); ++iPhi1) { - Q3 = getQ3(*iAntiProton1, *iAntiProton2, *iPhi1); - registry.fill(HIST("ppphi/fSE_antiparticle"), Q3); - registry.fill(HIST("ppphi/fAntiProtonPtVsQ3"), Q3, (*iAntiProton1).Pt()); - registry.fill(HIST("ppphi/fAntiProtonPtVsQ3"), Q3, (*iAntiProton2).Pt()); - registry.fill(HIST("ppphi/fAntiPhiPtVsQ3"), Q3, (*iPhi1).Pt()); - if (Q3 < ConfQ3Limits->get(static_cast(0), CFTrigger::kPPPhi)) { - if (ConfDownsample->get("Switch", "aPaPPhi") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "aPaPPhi")) { - registry.fill(HIST("ppphi/fSE_antiparticle_downsample"), Q3); - lowQ3Triplets[CFTrigger::kPPPhi] += 1; - } - } else { - lowQ3Triplets[CFTrigger::kPPPhi] += 1; - } - } + } + for (size_t p1 = 0; p1 < vecAntiProton.size(); p1++) { + for (size_t d1 = 0; d1 < vecAntiDeuteron.size(); d1++) { + if (idxAntiProton.at(p1) == idxAntiDeuteron.at(d1)) { + continue; + } + kstar = getkstar(vecAntiProton.at(p1), vecAntiDeuteron.at(d1)); + registryTriggerQA.fill(HIST("PD/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PD/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PD/all/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("PD/all/fAntiProtonKstarVsPt"), kstar, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PD/all/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + if (kstar < TriggerSelections.limits->get("Loose Limit", "PD")) { + signalLooseLimit[cf_trigger::kPD] += 1; + registryTriggerQA.fill(HIST("PD/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PD/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PD/loose/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("PD/loose/fAntiProtonKstarVsPt"), kstar, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PD/loose/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + if (kstar < TriggerSelections.limits->get("Tight Limit", "PD")) { + signalTightLimit[cf_trigger::kPD] += 1; + registryTriggerQA.fill(HIST("PD/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PD/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PD/tight/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("PD/tight/fAntiProtonKstarVsPt"), kstar, vecAntiProton.at(p1).Pt()); + registryTriggerQA.fill(HIST("PD/tight/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); } } } } - if (ConfTriggerSwitches->get("Switch", "pd") > 0.) { - // pd trigger - for (auto iProton = protons.begin(); iProton != protons.end(); ++iProton) { - for (auto iDeuteron = deuterons.begin(); iDeuteron != deuterons.end(); ++iDeuteron) { - kstar = getkstar(*iProton, *iDeuteron); - registry.fill(HIST("pd/fSE_particle"), kstar); - registry.fill(HIST("pd/fProtonPtVskstar"), kstar, (*iProton).Pt()); - registry.fill(HIST("pd/fDeuteronPtVskstar"), kstar, (*iDeuteron).Pt()); - if (kstar < ConfKstarLimits->get(static_cast(0), CFTrigger::kPD)) { - if (ConfDownsample->get("Switch", "PD") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "PD")) { - registry.fill(HIST("pd/fSE_particle_downsample"), kstar); - lowKstarPairs[CFTrigger::kPD] += 1; - } - } else { - lowKstarPairs[CFTrigger::kPD] += 1; - } + } + // LD + if (TriggerSelections.filterSwitches->get("Switch", "LD") > 0) { + for (size_t l1 = 0; l1 < vecLambda.size(); l1++) { + for (size_t d1 = 0; d1 < vecDeuteron.size(); d1++) { + if (idxLambdaDaughProton.at(l1) == idxDeuteron.at(d1)) { + continue; + } + kstar = getkstar(vecLambda.at(l1), vecDeuteron.at(d1)); + registryTriggerQA.fill(HIST("LD/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LD/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LD/all/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("LD/all/fLambdaKstarVsPt"), kstar, vecLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LD/all/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + if (kstar < TriggerSelections.limits->get("Loose Limit", "LD")) { + signalLooseLimit[cf_trigger::kLD] += 1; + registryTriggerQA.fill(HIST("LD/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LD/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LD/loose/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("LD/loose/fLambdaKstarVsPt"), kstar, vecLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LD/loose/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + if (kstar < TriggerSelections.limits->get("Tight Limit", "LD")) { + signalTightLimit[cf_trigger::kLD] += 1; + registryTriggerQA.fill(HIST("LD/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LD/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LD/tight/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("LD/tight/fLambdaKstarVsPt"), kstar, vecLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LD/tight/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); } } } - - for (auto iAntiProton = antiprotons.begin(); iAntiProton != antiprotons.end(); ++iAntiProton) { - for (auto iAntiDeuteron = antideuterons.begin(); iAntiDeuteron != antideuterons.end(); ++iAntiDeuteron) { - kstar = getkstar(*iAntiProton, *iAntiDeuteron); - registry.fill(HIST("pd/fSE_antiparticle"), kstar); - registry.fill(HIST("pd/fAntiProtonPtVskstar"), kstar, (*iAntiProton).Pt()); - registry.fill(HIST("pd/fAntiDeuteronPtVskstar"), kstar, (*iAntiDeuteron).Pt()); - if (kstar < ConfKstarLimits->get(static_cast(0), CFTrigger::kPD)) { - if (ConfDownsample->get("Switch", "aPaD") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "aPaD")) { - registry.fill(HIST("pd/fSE_antiparticle_downsample"), kstar); - lowKstarPairs[CFTrigger::kPD] += 1; - } - } else { - lowKstarPairs[CFTrigger::kPD] += 1; - } + } + for (size_t l1 = 0; l1 < vecAntiLambda.size(); l1++) { + for (size_t d1 = 0; d1 < vecAntiDeuteron.size(); d1++) { + if (idxAntiLambdaDaughProton.at(l1) == idxAntiDeuteron.at(d1)) { + continue; + } + kstar = getkstar(vecAntiLambda.at(l1), vecAntiDeuteron.at(d1)); + registryTriggerQA.fill(HIST("LD/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LD/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LD/all/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("LD/all/fAntiLambdaKstarVsPt"), kstar, vecAntiLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LD/all/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + if (kstar < TriggerSelections.limits->get("Loose Limit", "LD")) { + signalLooseLimit[cf_trigger::kLD] += 1; + registryTriggerQA.fill(HIST("LD/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LD/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LD/loose/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("LD/loose/fAntiLambdaKstarVsPt"), kstar, vecAntiLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LD/loose/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + if (kstar < TriggerSelections.limits->get("Tight Limit", "LD")) { + signalTightLimit[cf_trigger::kLD] += 1; + registryTriggerQA.fill(HIST("LD/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("LD/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("LD/tight/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("LD/tight/fAntiLambdaKstarVsPt"), kstar, vecAntiLambda.at(l1).Pt()); + registryTriggerQA.fill(HIST("LD/tight/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); } } } } - if (ConfTriggerSwitches->get("Switch", "Ld") > 0.) { - // ld trigger - for (auto iDeuteron = deuterons.begin(); iDeuteron != deuterons.end(); ++iDeuteron) { - for (auto iLambda = lambdas.begin(); iLambda != lambdas.end(); ++iLambda) { - kstar = getkstar(*iDeuteron, *iLambda); - registry.fill(HIST("ld/fSE_particle"), kstar); - registry.fill(HIST("ld/fDeuteronPtVskstar"), kstar, (*iDeuteron).Pt()); - registry.fill(HIST("ld/fLambdaPtVskstar"), kstar, (*iLambda).Pt()); - if (kstar < ConfKstarLimits->get(static_cast(0), CFTrigger::kLD)) { - if (ConfDownsample->get("Switch", "LD") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "LD")) { - registry.fill(HIST("ld/fSE_particle_downsample"), kstar); - lowKstarPairs[CFTrigger::kLD] += 1; - } - } else { - lowKstarPairs[CFTrigger::kLD] += 1; - } + } + // PhiD + if (TriggerSelections.filterSwitches->get("Switch", "PhiD") > 0) { + for (size_t phi1 = 0; phi1 < vecPhi.size(); phi1++) { + for (size_t d1 = 0; d1 < vecDeuteron.size(); d1++) { + if (idxPhiDaughPos.at(phi1) == idxDeuteron.at(d1)) { + continue; + } + kstar = getkstar(vecPhi.at(phi1), vecDeuteron.at(d1)); + registryTriggerQA.fill(HIST("PhiD/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PhiD/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PhiD/all/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("PhiD/all/fPhiKstarVsPt"), kstar, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PhiD/all/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("PhiD/all/fPhiKstarVsInvMass"), kstar, vecPhi.at(phi1).M()); + if (kstar < TriggerSelections.limits->get("Loose Limit", "PhiD")) { + signalLooseLimit[cf_trigger::kPhiD] += 1; + registryTriggerQA.fill(HIST("PhiD/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PhiD/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PhiD/loose/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("PhiD/loose/fPhiKstarVsPt"), kstar, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PhiD/loose/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("PhiD/loose/fPhiKstarVsInvMass"), kstar, vecPhi.at(phi1).M()); + if (kstar < TriggerSelections.limits->get("Tight Limit", "PhiD") && + vecPhi.at(phi1).M() > PhiSelections.tightInvMassLow.value && vecPhi.at(phi1).M() < PhiSelections.tightInvMassUp.value) { + signalTightLimit[cf_trigger::kPhiD] += 1; + registryTriggerQA.fill(HIST("PhiD/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PhiD/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PhiD/tight/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("PhiD/tight/fPhiKstarVsPt"), kstar, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PhiD/tight/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("PhiD/tight/fPhiKstarVsInvMass"), kstar, vecPhi.at(phi1).M()); } } } - for (auto iAntiDeuteron = antideuterons.begin(); iAntiDeuteron != antideuterons.end(); ++iAntiDeuteron) { - for (auto iAntiLambda = antilambdas.begin(); iAntiLambda != antilambdas.end(); ++iAntiLambda) { - kstar = getkstar(*iAntiDeuteron, *iAntiLambda); - registry.fill(HIST("ld/fSE_antiparticle"), kstar); - registry.fill(HIST("ld/fAntiDeuteronPtVskstar"), kstar, (*iAntiDeuteron).Pt()); - registry.fill(HIST("ld/fAntiLambdaPtVskstar"), kstar, (*iAntiLambda).Pt()); - if (kstar < ConfKstarLimits->get(static_cast(0), CFTrigger::kLD)) { - if (ConfDownsample->get("Switch", "aLaD") > 0) { - if (rng->Uniform(0., 1.) < ConfDownsample->get("Factor", "aLaD")) { - registry.fill(HIST("ld/fSE_antiparticle_downsample"), kstar); - lowKstarPairs[CFTrigger::kLD] += 1; - } - } else { - lowKstarPairs[CFTrigger::kLD] += 1; - } + } + for (size_t phi1 = 0; phi1 < vecPhi.size(); phi1++) { + for (size_t d1 = 0; d1 < vecAntiDeuteron.size(); d1++) { + if (idxPhiDaughNeg.at(phi1) == idxAntiDeuteron.at(d1)) { + continue; + } + kstar = getkstar(vecPhi.at(phi1), vecAntiDeuteron.at(d1)); + registryTriggerQA.fill(HIST("PhiD/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PhiD/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PhiD/all/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("PhiD/all/fPhiKstarVsPt"), kstar, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PhiD/all/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("PhiD/all/fPhiKstarVsInvMass"), kstar, vecPhi.at(phi1).M()); + if (kstar < TriggerSelections.limits->get("Loose Limit", "PhiD")) { + signalLooseLimit[cf_trigger::kPhiD] += 1; + registryTriggerQA.fill(HIST("PhiD/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PhiD/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PhiD/loose/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("PhiD/loose/fPhiKstarVsPt"), kstar, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PhiD/loose/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("PhiD/loose/fPhiKstarVsInvMass"), kstar, vecPhi.at(phi1).M()); + if (kstar < TriggerSelections.limits->get("Tight Limit", "PhiD") && + vecPhi.at(phi1).M() > PhiSelections.tightInvMassLow.value && vecPhi.at(phi1).M() < PhiSelections.tightInvMassUp.value) { + signalTightLimit[cf_trigger::kPhiD] += 1; + registryTriggerQA.fill(HIST("PhiD/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("PhiD/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("PhiD/tight/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("PhiD/tight/fPhiKstarVsPt"), kstar, vecPhi.at(phi1).Pt()); + registryTriggerQA.fill(HIST("PhiD/tight/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("PhiD/tight/fPhiKstarVsInvMass"), kstar, vecPhi.at(phi1).M()); } } } } - } // if(isSelectedEvent) - - // create tags for three body triggers - if (lowQ3Triplets[CFTrigger::kPPP] > 0) { - keepEvent3N[CFTrigger::kPPP] = true; - registry.fill(HIST("fProcessedEvents"), 2); - registry.fill(HIST("ppp/fMultiplicity"), col.multNTracksPV()); - registry.fill(HIST("ppp/fZvtx"), col.posZ()); } - if (lowQ3Triplets[CFTrigger::kPPL] > 0) { - keepEvent3N[CFTrigger::kPPL] = true; - registry.fill(HIST("fProcessedEvents"), 3); - registry.fill(HIST("ppl/fMultiplicity"), col.multNTracksPV()); - registry.fill(HIST("ppl/fZvtx"), col.posZ()); - } - if (lowQ3Triplets[CFTrigger::kPLL] > 0) { - keepEvent3N[CFTrigger::kPLL] = true; - registry.fill(HIST("fProcessedEvents"), 4); - registry.fill(HIST("pll/fMultiplicity"), col.multNTracksPV()); - registry.fill(HIST("pll/fZvtx"), col.posZ()); - } - if (lowQ3Triplets[CFTrigger::kLLL] > 0) { - keepEvent3N[CFTrigger::kLLL] = true; - registry.fill(HIST("fProcessedEvents"), 5); - registry.fill(HIST("lll/fMultiplicity"), col.multNTracksPV()); - registry.fill(HIST("lll/fZvtx"), col.posZ()); - } - if (lowQ3Triplets[CFTrigger::kPPPhi] > 0) { - keepEvent3N[CFTrigger::kPPPhi] = true; - registry.fill(HIST("fProcessedEvents"), 6); - registry.fill(HIST("ppphi/fMultiplicity"), col.multNTracksPV()); - registry.fill(HIST("ppphi/fZvtx"), col.posZ()); + // RhoD + if (TriggerSelections.filterSwitches->get("Switch", "RhoD") > 0) { + for (size_t r1 = 0; r1 < vecRho.size(); r1++) { + for (size_t d1 = 0; d1 < vecDeuteron.size(); d1++) { + if (idxRhoDaughPos.at(r1) == idxDeuteron.at(d1)) { + continue; + } + kstar = getkstar(vecRho.at(r1), vecDeuteron.at(d1)); + registryTriggerQA.fill(HIST("RhoD/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("RhoD/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("RhoD/all/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("RhoD/all/fRhoKstarVsPt"), kstar, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("RhoD/all/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("RhoD/all/fRhoKstarVsInvMass"), kstar, vecRho.at(r1).M()); + if (kstar < TriggerSelections.limits->get("Loose Limit", "RhoD")) { + signalLooseLimit[cf_trigger::kRhoD] += 1; + registryTriggerQA.fill(HIST("RhoD/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("RhoD/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("RhoD/loose/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("RhoD/loose/fRhoKstarVsPt"), kstar, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("RhoD/loose/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("RhoD/loose/fRhoKstarVsInvMass"), kstar, vecRho.at(r1).M()); + if (kstar < TriggerSelections.limits->get("Tight Limit", "RhoD") && + vecRho.at(r1).M() > RhoSelections.tightInvMassLow.value && vecRho.at(r1).M() < RhoSelections.tightInvMassUp.value) { + signalTightLimit[cf_trigger::kRhoD] += 1; + registryTriggerQA.fill(HIST("RhoD/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("RhoD/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("RhoD/tight/fSE_particle"), kstar); + registryTriggerQA.fill(HIST("RhoD/tight/fRhoKstarVsPt"), kstar, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("RhoD/tight/fDeuteronKstarVsPt"), kstar, vecDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("RhoD/tight/fRhoKstarVsInvMass"), kstar, vecRho.at(r1).M()); + } + } + } + } + for (size_t r1 = 0; r1 < vecRho.size(); r1++) { + for (size_t d1 = 0; d1 < vecAntiDeuteron.size(); d1++) { + if (idxRhoDaughNeg.at(r1) == idxAntiDeuteron.at(d1)) { + continue; + } + kstar = getkstar(vecRho.at(r1), vecAntiDeuteron.at(d1)); + registryTriggerQA.fill(HIST("RhoD/all/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("RhoD/all/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("RhoD/all/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("RhoD/all/fRhoKstarVsPt"), kstar, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("RhoD/all/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("RhoD/all/fRhoKstarVsInvMass"), kstar, vecRho.at(r1).M()); + if (kstar < TriggerSelections.limits->get("Loose Limit", "RhoD")) { + signalLooseLimit[cf_trigger::kRhoD] += 1; + registryTriggerQA.fill(HIST("RhoD/loose/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("RhoD/loose/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("RhoD/loose/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("RhoD/loose/fRhoKstarVsPt"), kstar, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("RhoD/loose/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("RhoD/loose/fRhoKstarVsInvMass"), kstar, vecRho.at(r1).M()); + if (kstar < TriggerSelections.limits->get("Tight Limit", "RhoD") && + vecRho.at(r1).M() > RhoSelections.tightInvMassLow.value && vecRho.at(r1).M() < RhoSelections.tightInvMassUp.value) { + signalTightLimit[cf_trigger::kRhoD] += 1; + registryTriggerQA.fill(HIST("RhoD/tight/fMultiplicity"), col.multNTracksPV()); + registryTriggerQA.fill(HIST("RhoD/tight/fZvtx"), col.posZ()); + registryTriggerQA.fill(HIST("RhoD/tight/fSE_antiparticle"), kstar); + registryTriggerQA.fill(HIST("RhoD/tight/fRhoKstarVsPt"), kstar, vecRho.at(r1).Pt()); + registryTriggerQA.fill(HIST("RhoD/tight/fAntiDeuteronKstarVsPt"), kstar, vecAntiDeuteron.at(d1).Pt()); + registryTriggerQA.fill(HIST("RhoD/tight/fRhoKstarVsInvMass"), kstar, vecRho.at(r1).M()); + } + } + } + } } - // create tags for two body triggers - if (lowKstarPairs[CFTrigger::kPD] > 0) { - keepEvent2N[CFTrigger::kPD] = true; - registry.fill(HIST("fProcessedEvents"), 7); - registry.fill(HIST("pd/fMultiplicity"), col.multNTracksPV()); - registry.fill(HIST("pd/fZvtx"), col.posZ()); + for (int i = 0; i < cf_trigger::kNTriggers; i++) { + if (signalLooseLimit[i] > 0) { + registryTriggerQA.fill(HIST("fProcessedEvents"), 3 + 2 * i); // need offset for filling + keepEventLooseLimit[i] = true; + } + if (signalTightLimit[i] > 0) { + registryTriggerQA.fill(HIST("fProcessedEvents"), 3 + 2 * i + 1); // need offset for filling + keepEventTightLimit[i] = true; + } + for (int j = i; j < cf_trigger::kNTriggers; j++) { + if (signalLooseLimit[i] > 0 && signalLooseLimit[j]) { + registryTriggerQA.fill(HIST("fTriggerCorrelations"), 2 * i, 2 * j); + } + if (signalLooseLimit[i] > 0 && signalTightLimit[j]) { // only one combination needed, fill only entries above diagonal + registryTriggerQA.fill(HIST("fTriggerCorrelations"), 2 * i, 2 * j + 1); + } + if (signalTightLimit[i] > 0 && signalTightLimit[j]) { + registryTriggerQA.fill(HIST("fTriggerCorrelations"), 2 * i + 1, 2 * j + 1); + } + } } - if (lowKstarPairs[CFTrigger::kLD] > 0) { - keepEvent2N[CFTrigger::kLD] = true; - registry.fill(HIST("fProcessedEvents"), 8); - registry.fill(HIST("ld/fMultiplicity"), col.multNTracksPV()); - registry.fill(HIST("ld/fZvtx"), col.posZ()); + + if (keepEventLooseLimit[cf_trigger::kPPP] || + keepEventLooseLimit[cf_trigger::kPPL] || + keepEventLooseLimit[cf_trigger::kPLL] || + keepEventLooseLimit[cf_trigger::kLLL] || + keepEventLooseLimit[cf_trigger::kPPPhi] || + keepEventLooseLimit[cf_trigger::kPPRho] || + keepEventLooseLimit[cf_trigger::kPD] || + keepEventLooseLimit[cf_trigger::kLD] || + keepEventLooseLimit[cf_trigger::kPhiD] || + keepEventLooseLimit[cf_trigger::kRhoD]) { + registryTriggerQA.fill(HIST("fProcessedEvents"), 1); } - tags(keepEvent3N[CFTrigger::kPPP], - keepEvent3N[CFTrigger::kPPL], - keepEvent3N[CFTrigger::kPLL], - keepEvent3N[CFTrigger::kLLL], - keepEvent3N[CFTrigger::kPPPhi], - keepEvent2N[CFTrigger::kPD], - keepEvent2N[CFTrigger::kLD]); - - if (!keepEvent3N[CFTrigger::kPPP] && !keepEvent3N[CFTrigger::kPPL] && !keepEvent3N[CFTrigger::kPLL] && !keepEvent3N[CFTrigger::kLLL] && !keepEvent3N[CFTrigger::kPPPhi] && - !keepEvent2N[CFTrigger::kPD] && !keepEvent2N[CFTrigger::kLD]) { - registry.fill(HIST("fProcessedEvents"), 1); + if (keepEventTightLimit[cf_trigger::kPPP] || + keepEventTightLimit[cf_trigger::kPPL] || + keepEventTightLimit[cf_trigger::kPLL] || + keepEventTightLimit[cf_trigger::kLLL] || + keepEventTightLimit[cf_trigger::kPPPhi] || + keepEventTightLimit[cf_trigger::kPPRho] || + keepEventTightLimit[cf_trigger::kPD] || + keepEventTightLimit[cf_trigger::kLD] || + keepEventTightLimit[cf_trigger::kPhiD] || + keepEventTightLimit[cf_trigger::kRhoD]) { + registryTriggerQA.fill(HIST("fProcessedEvents"), 2); } - } + + tags(keepEventTightLimit[cf_trigger::kPPP], keepEventLooseLimit[cf_trigger::kPPP], + keepEventTightLimit[cf_trigger::kPPL], keepEventLooseLimit[cf_trigger::kPPL], + keepEventTightLimit[cf_trigger::kPLL], keepEventLooseLimit[cf_trigger::kPLL], + keepEventTightLimit[cf_trigger::kLLL], keepEventLooseLimit[cf_trigger::kLLL], + keepEventTightLimit[cf_trigger::kPPPhi], keepEventLooseLimit[cf_trigger::kPPPhi], + keepEventTightLimit[cf_trigger::kPPRho], keepEventLooseLimit[cf_trigger::kPPRho], + keepEventTightLimit[cf_trigger::kPD], keepEventLooseLimit[cf_trigger::kPD], + keepEventTightLimit[cf_trigger::kLD], keepEventLooseLimit[cf_trigger::kLD], + keepEventTightLimit[cf_trigger::kPhiD], keepEventLooseLimit[cf_trigger::kPhiD], + keepEventTightLimit[cf_trigger::kRhoD], keepEventLooseLimit[cf_trigger::kRhoD]); + }; }; WorkflowSpec defineDataProcessing(ConfigContext const& cfg) { - return WorkflowSpec{adaptAnalysisTask(cfg)}; + return WorkflowSpec{adaptAnalysisTask(cfg)}; } diff --git a/EventFiltering/PWGCF/CFFilterQA.cxx b/EventFiltering/PWGCF/CFFilterQA.cxx index 70e80b74e78..372b3387dc1 100644 --- a/EventFiltering/PWGCF/CFFilterQA.cxx +++ b/EventFiltering/PWGCF/CFFilterQA.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/EventFiltering/PWGEM/EMPhotonFilter.cxx b/EventFiltering/PWGEM/EMPhotonFilter.cxx index a254c7245a1..b8901e6f006 100644 --- a/EventFiltering/PWGEM/EMPhotonFilter.cxx +++ b/EventFiltering/PWGEM/EMPhotonFilter.cxx @@ -12,16 +12,19 @@ // \brief software trigger for EM photon // \author daiki.sekihata@cern.ch -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "Common/DataModel/CaloClusters.h" -#include "DataFormatsPHOS/TriggerRecord.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" + +#include "Common/DataModel/CaloClusters.h" #include "EventFiltering/filterTables.h" + +#include "DataFormatsPHOS/TriggerRecord.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" using namespace o2; using namespace o2::soa; @@ -325,13 +328,10 @@ struct EMPhotonFilter { } // end of collision loop } - Filter PCMFilter = o2::aod::v0photonkf::dcaXYtopv < max_dcatopv_xy_v0 && o2::aod::v0photonkf::dcaZtopv < max_dcatopv_z_v0; - using filteredV0PhotonsKF = Filtered; - Filter DalitzEEFilter = o2::aod::dalitzee::sign == 0; // analyze only uls using filteredDalitzEEs = Filtered; - void process_PCM(MyCollisions const& collisions, filteredV0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, filteredDalitzEEs const& dielectrons, MyPrimaryElectrons const& emprimaryelectrons) + void process_PCM(MyCollisions const& collisions, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, filteredDalitzEEs const& dielectrons, MyPrimaryElectrons const& emprimaryelectrons) { const uint8_t system = EM_Filter_PhotonType::kPCM; runFilter(collisions, v0photons, nullptr, nullptr, v0legs, dielectrons, emprimaryelectrons); @@ -351,7 +351,7 @@ struct EMPhotonFilter { runFilter(collisions, nullptr, nullptr, clusters, nullptr, nullptr, nullptr); } - void process_PCM_PHOS(MyCollisions const& collisions, filteredV0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, filteredDalitzEEs const& dielectrons, MyPrimaryElectrons const& emprimaryelectrons, CluCandidates const& clusters) + void process_PCM_PHOS(MyCollisions const& collisions, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, filteredDalitzEEs const& dielectrons, MyPrimaryElectrons const& emprimaryelectrons, CluCandidates const& clusters) { const uint8_t system = EM_Filter_PhotonType::kPCM | EM_Filter_PhotonType::kPHOS; runFilter(collisions, v0photons, clusters, nullptr, v0legs, dielectrons, emprimaryelectrons); diff --git a/EventFiltering/PWGEM/HeavyNeutralMesonFilter.cxx b/EventFiltering/PWGEM/HeavyNeutralMesonFilter.cxx new file mode 100644 index 00000000000..6909d1561ee --- /dev/null +++ b/EventFiltering/PWGEM/HeavyNeutralMesonFilter.cxx @@ -0,0 +1,1286 @@ +// 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. +/// +/// \file HeavyNeutralMesonFilter.cxx +/// +/// \brief This code loops over collisions to filter events contaning heavy neutral mesons (omega or eta') using EMCal clusters and V0s (PCM) +/// +/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) - Goethe University Frankfurt; Maximilian Korwieser (maximilian.korwieser@cern.ch) - Technical University Munich +/// + +#include +#include +#include + +#include "Math/GenVector/Boost.h" +#include "Math/Vector4D.h" +#include "TMath.h" +#include "TRandom3.h" + +#include "PWGEM/PhotonMeson/Utils/HNMUtilities.h" +#include "PWGJE/DataModel/EMCALMatchedCollisions.h" + +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "fairlogger/Logger.h" +#include "Framework/Configurable.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "CommonConstants/MathConstants.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::pwgem::photonmeson; + +namespace o2::aod +{ +using MyBCs = soa::Join; +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; +using SelectedTracks = soa::Join; +} // namespace o2::aod + +namespace hnmtrigger +{ +enum FemtoTriggers { + kPPOmega, + kPPEtaPrime, + kOmegaD, + kEtaPrimeD, + kOmegaP, + kEtaPrimeP, + kNFemtoTriggers +}; + +enum TracksPID { + kProton, + kDeuteron, + kPion, + kNFemtoPartners +}; + +enum PIDLimits { kTPCMin, + kTPCMax, + kTPCTOF, + kITSmin, + kITSmax, + kNPIDLimits +}; +const std::vector speciesName{"proton", "Deuteron", "pion"}; +const std::vector pTCutsName{"Pt min", "Pt max", "P TOF thres"}; +const std::vector pidCutsName{"TPC min", "TPC max", "TPCTOF max", "ITS min", "ITS max"}; +const std::vector femtoFilterNames{"PPOmega", "PPEtaPrime", "Omegad", "EtaPrimed", "OmegaP", "EtaPrimeP"}; + +// configs for tracks +const float pidcutsTable[kNFemtoPartners][kNPIDLimits]{ + {-4.f, 4.f, 4.f, -99.f, 99.f}, + {-4.f, 4.f, 4.f, -6.f, 6.f}, + {-4.f, 4.f, 4.f, -99.f, 99.f}}; + +const float ptcutsTable[kNFemtoPartners][3]{ + {0.35f, 6.f, 0.75f}, + {0.55f, 2.f, 1.2f}, + {0.35f, 6.f, 0.75f}}; + +const float nClusterMinTPC[1][kNFemtoPartners]{{80.0f, 80.0f, 80.0f}}; +const float nClusterMinITS[1][kNFemtoPartners]{{4, 4, 4}}; + +static const float triggerSwitches[1][kNFemtoTriggers]{{1, 1, 1, 1, 1, 1}}; +const float triggerLimits[1][kNFemtoTriggers]{{1.f, 1.f, 1.f, 1.f, 1.f, 1.f}}; +} // namespace hnmtrigger + +struct HeavyNeutralMesonFilter { + Produces tags; + + // --------------------------------> Configurables <------------------------------------ + // - Event selection cuts + // - Track selection cuts + // - Cluster shifts + // - HNM mass selection windows + // - HNM min pTs / k*'s + // ------------------------------------------------------------------------------------- + // ---> Event selection + Configurable confEvtSelectZvtx{"confEvtSelectZvtx", true, "Event selection includes max. z-Vertex"}; + Configurable confEvtZvtx{"confEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable confEvtRequireSel8{"confEvtRequireSel8", false, "Evt sel: check for offline selection (sel8)"}; + + // ---> Track selection + Configurable> cfgPtCuts{"cfgPtCuts", {hnmtrigger::ptcutsTable[0], hnmtrigger::kNFemtoPartners, 3, hnmtrigger::speciesName, hnmtrigger::pTCutsName}, "Track pT selections"}; + Configurable cfgTrkEta{"cfgTrkEta", 0.9, "Eta"}; + Configurable> cfgTPCNClustersMin{"cfgTPCNClustersMin", {hnmtrigger::nClusterMinTPC[0], 1, hnmtrigger::kNFemtoPartners, std::vector{"TPCNClusMin"}, hnmtrigger::speciesName}, "Mininum of TPC Clusters"}; + Configurable cfgTrkTPCfCls{"cfgTrkTPCfCls", 0.83, "Minimum fraction of crossed rows over findable clusters"}; + Configurable cfgTrkTPCcRowsMin{"cfgTrkTPCcRowsMin", 70, "Minimum number of crossed TPC rows"}; + Configurable cfgTrkTPCsClsSharedFrac{"cfgTrkTPCsClsSharedFrac", 1.f, "Fraction of shared TPC clusters"}; + Configurable> cfgTrkITSnclsMin{"cfgTrkITSnclsMin", {hnmtrigger::nClusterMinITS[0], 1, hnmtrigger::kNFemtoPartners, std::vector{"Cut"}, hnmtrigger::speciesName}, "Minimum number of ITS clusters"}; + Configurable cfgTrkDCAxyMax{"cfgTrkDCAxyMax", 0.15, "Maximum DCA_xy"}; + Configurable cfgTrkDCAzMax{"cfgTrkDCAzMax", 0.3, "Maximum DCA_z"}; + Configurable cfgTrkMaxChi2PerClusterTPC{"cfgTrkMaxChi2PerClusterTPC", 4.0f, "Minimal track selection: max allowed chi2 per TPC cluster"}; // 4.0 is default of global tracks on 20.01.2023 + Configurable cfgTrkMaxChi2PerClusterITS{"cfgTrkMaxChi2PerClusterITS", 36.0f, "Minimal track selection: max allowed chi2 per ITS cluster"}; // 36.0 is default of global tracks on 20.01.2023 + + Configurable> cfgPIDCuts{"cfgPIDCuts", {hnmtrigger::pidcutsTable[0], hnmtrigger::kNFemtoPartners, hnmtrigger::kNPIDLimits, hnmtrigger::speciesName, hnmtrigger::pidCutsName}, "Femtopartner PID nsigma selections"}; // PID selections + + // ---> Configurables to allow for a shift in eta/phi of EMCal clusters to better align with extrapolated TPC tracks + Configurable cfgDoEMCShift{"cfgDoEMCShift", false, "Apply SM-wise shift in eta and phi to EMCal clusters to align with TPC tracks"}; + Configurable> cfgEMCEtaShift{"cfgEMCEtaShift", {0.f}, "values for SM-wise shift in eta to be added to EMCal clusters to align with TPC tracks"}; + Configurable> cfgEMCPhiShift{"cfgEMCPhiShift", {0.f}, "values for SM-wise shift in phi to be added to EMCal clusters to align with TPC tracks"}; + static const int nSMs = 20; + std::array emcEtaShift = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + std::array emcPhiShift = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + // ---> Shift the omega/eta' mass based on the difference of the reconstructed mass of the pi0/eta to its PDG mass to reduce smearing caused by EMCal/PCM in photon measurement + Configurable cfgHNMMassCorrection{"cfgHNMMassCorrection", 1, "Use GG PDG mass to correct HNM mass (0 = off, 1 = subDeltaPi0, 2 = subLambda)"}; + + // ---> Mass windows for the selection of heavy neutral mesons (also based on mass of their light neutral meson decay daughter) + static constexpr float DefaultMassWindows[2][4] = {{0., 0.4, 0.6, 1.}, {0.4, 0.8, 0.8, 1.2}}; + Configurable> cfgMassWindowOmega{"cfgMassWindowOmega", {DefaultMassWindows[0], 4, {"pi0_min", "pi0_max", "omega_min", "omega_max"}}, "Mass window for selected omegas and their decay pi0"}; + Configurable> cfgMassWindowEtaPrime{"cfgMassWindowEtaPrime", {DefaultMassWindows[1], 4, {"eta_min", "eta_max", "etaprime_min", "etaprime_max"}}, "Mass window for selected eta' and their decay eta"}; + + // ---> Minimum pT values for the trigger decisions of the spectra and femto trigger. The femto triggers additionally require a given k*/Q3 + static constexpr float DefaultSpectraMinPts[4] = {1.8, 1.8, 2.6, 2.6}; + static constexpr float DefaultFemtoMinPts[4] = {1.8, 1.8, 2.6, 2.6}; + Configurable> cfgMinHNMPtsSpectrumTrigger{"cfgMinHNMPtsSpectrumTrigger", {DefaultSpectraMinPts, 4, {"PCM_omega", "PCM_etaprime", "EMC_omega", "EMC_etaprime"}}, "Minimum pT values for the spetra trigger decisions (GeV/c)"}; + Configurable> cfgMinHNMPtsFemtoTrigger{"cfgMinHNMPtsFemtoTrigger", {DefaultFemtoMinPts, 4, {"PCM_omega", "PCM_etaprime", "EMC_omega", "EMC_etaprime"}}, "Minimum pT values for the femto trigger decisions (GeV/c)"}; + Configurable> cfgKinematicLimits{"cfgKinematicLimits", {hnmtrigger::triggerLimits[0], 1, hnmtrigger::kNFemtoTriggers, std::vector{"Limit"}, hnmtrigger::femtoFilterNames}, "Maximum K* (Q_3) for two (three) body femto trigger"}; + + Configurable> cfgTriggerSwitches{"cfgTriggerSwitches", {hnmtrigger::triggerSwitches[0], 1, hnmtrigger::kNFemtoTriggers, std::vector{"Switch"}, hnmtrigger::femtoFilterNames}, "Turn on specific trigger"}; + + HistogramRegistry mHistManager{"HeavyNeutralMesonFilterHistograms", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Prepare vectors for different species + std::vector vGGs; + std::vector vHNMs; + std::vector etaPrimeEMC, etaPrimePCM, omegaEMC, omegaPCM, proton, antiproton, deuteron, antideuteron, pion, antipion; + float mMassProton = constants::physics::MassProton; + float mMassDeuteron = constants::physics::MassDeuteron; + float mMassPionCharged = constants::physics::MassPionCharged; + + Preslice perCollisionPCM = aod::v0photonkf::collisionId; + Preslice perCollisionEMC = aod::skimmedcluster::collisionId; + + bool colContainsPCMOmega, colContainsEMCOmega, colContainsPCMEtaPrime, colContainsEMCEtaPrime = false; + + template + bool isSelectedTrack(T const& track, hnmtrigger::TracksPID partSpecies) + { + if (track.pt() < cfgPtCuts->get(partSpecies, "Pt min")) + return false; + if (track.pt() > cfgPtCuts->get(partSpecies, "Pt max")) + return false; + if (std::abs(track.eta()) > cfgTrkEta) + return false; + if (track.tpcNClsFound() < cfgTPCNClustersMin->get("TPCNClusMin", partSpecies)) + return false; + if (track.tpcCrossedRowsOverFindableCls() < cfgTrkTPCfCls) + return false; + if (track.tpcNClsCrossedRows() < cfgTrkTPCcRowsMin) + return false; + if (track.tpcFractionSharedCls() > cfgTrkTPCsClsSharedFrac) + return false; + if (track.itsNCls() < cfgTrkITSnclsMin->get(static_cast(0), partSpecies)) + return false; + if (std::abs(track.dcaXY()) > cfgTrkDCAxyMax) + return false; + if (std::abs(track.dcaZ()) > cfgTrkDCAzMax) + return false; + if (track.tpcChi2NCl() > cfgTrkMaxChi2PerClusterTPC) + return false; + if (track.itsChi2NCl() > cfgTrkMaxChi2PerClusterITS) + return false; + return true; + } + + template + bool isSelectedTrackPID(T const& track, hnmtrigger::TracksPID partSpecies) + { + // nSigma should have entries [proton, deuteron, pion] + bool isSelected = false; + + float nSigmaTrackTPC = -999.f; + float nSigmaTrackTOF = -999.f; + float nSigmaTrackITS = -999.f; + + switch (partSpecies) { + case hnmtrigger::kProton: + nSigmaTrackTPC = track.tpcNSigmaPr(); + nSigmaTrackTOF = track.tofNSigmaPr(); + nSigmaTrackITS = track.itsNSigmaPr(); + break; + case hnmtrigger::kDeuteron: + nSigmaTrackTPC = track.tpcNSigmaDe(); + nSigmaTrackTOF = track.tofNSigmaDe(); + nSigmaTrackITS = track.itsNSigmaDe(); + break; + case hnmtrigger::kPion: + nSigmaTrackTPC = track.tpcNSigmaPi(); + nSigmaTrackTOF = track.tofNSigmaPi(); + nSigmaTrackITS = track.itsNSigmaPi(); + break; + default: + LOG(fatal) << "Particle species not known"; + } + + float nSigmaTrackTPCTOF = std::sqrt(std::pow(nSigmaTrackTPC, 2) + std::pow(nSigmaTrackTOF, 2)); + + if (track.p() <= cfgPtCuts->get(partSpecies, "P TOF thres")) { + if (nSigmaTrackTPC > cfgPIDCuts->get(partSpecies, hnmtrigger::kTPCMin) && + nSigmaTrackTPC < cfgPIDCuts->get(partSpecies, hnmtrigger::kTPCMax) && + nSigmaTrackITS > cfgPIDCuts->get(partSpecies, hnmtrigger::kITSmin) && + nSigmaTrackITS < cfgPIDCuts->get(partSpecies, hnmtrigger::kITSmax)) { + isSelected = true; + } + } else { + if (nSigmaTrackTPCTOF < cfgPIDCuts->get(partSpecies, hnmtrigger::kTPCTOF)) { + isSelected = true; + } + } + return isSelected; + } + + template + bool isSelectedEvent(T const& col) + { + if (confEvtSelectZvtx && std::abs(col.posZ()) > confEvtZvtx) + return false; + if (confEvtRequireSel8 && !col.sel8()) + return false; + return true; + } + + float getkstar(const ROOT::Math::PtEtaPhiMVector part1, + const ROOT::Math::PtEtaPhiMVector part2) + { + const ROOT::Math::PtEtaPhiMVector trackSum = part1 + part2; + const float beta = trackSum.Beta(); + const float betax = beta * std::cos(trackSum.Phi()) * std::sin(trackSum.Theta()); + const float betay = beta * std::sin(trackSum.Phi()) * std::sin(trackSum.Theta()); + const float betaz = beta * std::cos(trackSum.Theta()); + ROOT::Math::PxPyPzMVector partOneCMS(part1); + ROOT::Math::PxPyPzMVector partTwoCMS(part2); + const ROOT::Math::Boost boostPRF = ROOT::Math::Boost(-betax, -betay, -betaz); + partOneCMS = boostPRF(partOneCMS); + partTwoCMS = boostPRF(partTwoCMS); + const ROOT::Math::PxPyPzMVector trackRelK = partOneCMS - partTwoCMS; + return 0.5 * trackRelK.P(); + } + + ROOT::Math::PxPyPzEVector getqij(const ROOT::Math::PtEtaPhiMVector parti, + const ROOT::Math::PtEtaPhiMVector partj) + { + ROOT::Math::PxPyPzEVector vecparti(parti); + ROOT::Math::PxPyPzEVector vecpartj(partj); + ROOT::Math::PxPyPzEVector trackSum = vecparti + vecpartj; + ROOT::Math::PxPyPzEVector trackDifference = vecparti - vecpartj; + float scaling = trackDifference.Dot(trackSum) / trackSum.Dot(trackSum); + return trackDifference - scaling * trackSum; + } + float getQ3(const ROOT::Math::PtEtaPhiMVector part1, + const ROOT::Math::PtEtaPhiMVector part2, + const ROOT::Math::PtEtaPhiMVector part3) + { + ROOT::Math::PxPyPzEVector q12 = getqij(part1, part2); + ROOT::Math::PxPyPzEVector q23 = getqij(part2, part3); + ROOT::Math::PxPyPzEVector q31 = getqij(part3, part1); + float q32 = q12.M2() + q23.M2() + q31.M2(); + return std::sqrt(-q32); + } + + void init(InitContext const&) + { + mHistManager.add("Event/nGGs", "Number of (selected) #gamma#gamma paris;#bf{#it{N}^{#gamma#gamma}};#bf{#it{N}_{selected}^{#gamma#gamma}}", HistType::kTH2F, {{51, -0.5, 50.5}, {51, -0.5, 50.5}}); + mHistManager.add("Event/nHeavyNeutralMesons", "Number of (selected) HNM candidates;#bf{#it{N}^{HNM}};#bf{#it{N}_{selected}^{HNM}}", HistType::kTH2F, {{51, -0.5, 50.5}, {51, -0.5, 50.5}}); + mHistManager.add("Event/nClustersVsV0s", "Number of clusters and V0s in the collision;#bf{#it{N}^{clusters}};#bf{#it{N}^{V0s}}", HistType::kTH2F, {{26, -0.5, 25.5}, {26, -0.5, 25.5}}); + mHistManager.add("Event/nEMCalEvents", "Number of collisions with a certain combination of EMCal triggers;;#bf{#it{N}_{collisions}}", HistType::kTH1F, {{5, -0.5, 4.5}}); + std::vector nEventTitles = {"Cells & kTVXinEMC", "Cells & L0", "Cells & !kTVXinEMC & !L0", "!Cells & kTVXinEMC", "!Cells & L0"}; + for (size_t iBin = 0; iBin < nEventTitles.size(); iBin++) + mHistManager.get(HIST("Event/nEMCalEvents"))->GetXaxis()->SetBinLabel(iBin + 1, nEventTitles[iBin].data()); + mHistManager.add("Event/fMultiplicityBefore", "Multiplicity of all processed events;#bf{#it{N}_{tracks}};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, 0, 500}}); + mHistManager.add("Event/fMultiplicityAfter", "Multiplicity after event cuts;#bf{#it{N}_{tracks}};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, 0, 500}}); + mHistManager.add("Event/fZvtxBefore", "Zvtx of all processed events;#bf{z_{vtx} (cm)};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, -15, 15}}); + mHistManager.add("Event/fZvtxAfter", "Zvtx after event cuts;#bf{z_{vtx} (cm)};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, -15, 15}}); + mHistManager.add("fProcessedEvents", "CF - event filtered;;Events", HistType::kTH1F, {{12, -0.5, 11.5}}); + std::vector pEventTitles = {"all", "rejected", "PCM #omega", "EMC #omega", "PCM #eta'", "EMC #eta'", "PPOmega", "PPEtaPrime", "Omegad", "EtaPrimed", "OmegaP", "EtaPrimeP"}; + for (size_t iBin = 0; iBin < pEventTitles.size(); iBin++) + mHistManager.get(HIST("fProcessedEvents"))->GetXaxis()->SetBinLabel(iBin + 1, pEventTitles[iBin].data()); + + mHistManager.add("GG/invMassVsPt_PCM", "Invariant mass and pT of gg candidates;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{400, 0., 0.8}, {250, 0., 25.}}); + mHistManager.add("GG/invMassVsPt_PCMEMC", "Invariant mass and pT of gg candidates;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{400, 0., 0.8}, {250, 0., 25.}}); + mHistManager.add("GG/invMassVsPt_EMC", "Invariant mass and pT of gg candidates;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{400, 0., 0.8}, {250, 0., 25.}}); + + // Momentum correlations p vs p_TPC + mHistManager.add("TrackCuts/TracksBefore/fMomCorrelationPos", "fMomCorrelation;#bf{#it{p} (GeV/#it{c})};#bf{#it{p}_{TPC} (GeV/#it{c})}", {HistType::kTH2F, {{500, 0.0f, 20.0f}, {500, 0.0f, 20.0f}}}); + mHistManager.add("TrackCuts/TracksBefore/fMomCorrelationNeg", "fMomCorrelation;#bf{#it{p} (GeV/#it{c})};#bf{#it{p}_{TPC} (GeV/#it{c})}", {HistType::kTH2F, {{500, 0.0f, 20.0f}, {500, 0.0f, 20.0f}}}); + + // All tracks + mHistManager.add("TrackCuts/TracksBefore/fPtTrackBefore", "Transverse momentum of all processed tracks;#bf{#it{p}_{T} (GeV/#it{c})};#bf{#it{N}_{tracks}}", HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add("TrackCuts/TracksBefore/fEtaTrackBefore", "Pseudorapidity of all processed tracks;#eta;#bf{#it{N}_{tracks}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("TrackCuts/TracksBefore/fPhiTrackBefore", "Azimuthal angle of all processed tracks;#phi;#bf{#it{N}_{tracks}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + // TPC signal + mHistManager.add("TrackCuts/TPCSignal/fTPCSignalTPCP", "TPCSignal;#bf{#it{p}_{TPC} (GeV/#it{c})};#bf{TPC d#it{E}/d#it{x}}", {HistType::kTH2F, {{500, 0.0f, 6.0f}, {2000, -100.f, 500.f}}}); + mHistManager.add("TrackCuts/TPCSignal/fTPCSignal", "TPCSignalP;#bf{#it{p} (GeV/#it{c})};#bf{TPC d#it{E}/d#it{x}}", {HistType::kTH2F, {{500, 0.0f, 6.0f}, {2000, -100.f, 500.f}}}); + // TPC signal antiparticles (negative charge) + mHistManager.add("TrackCuts/TPCSignal/fTPCSignalAntiTPCP", "TPCSignal;#bf{#it{p}_{TPC} (GeV/#it{c})};#bf{TPC d#it{E}/d#it{x}}", {HistType::kTH2F, {{500, 0.0f, 6.0f}, {2000, -100.f, 500.f}}}); + mHistManager.add("TrackCuts/TPCSignal/fTPCSignalAnti", "TPCSignalP;#bf{#it{p} (GeV/#it{c})};#bf{TPC d#it{E}/d#it{x}}", {HistType::kTH2F, {{500, 0.0f, 6.0f}, {2000, -100.f, 500.f}}}); + + const int nTrackSpecies = 2 * hnmtrigger::kNFemtoPartners; // x2 because of anti particles + const char* particleSpecies[nTrackSpecies] = {"Proton", "AntiProton", "Deuteron", "AntiDeuteron", "Pion", "AntiPion"}; + const char* particleSpeciesLatex[nTrackSpecies] = {"p", "#bar{p}", "d", "#bar{d}", "#pi^{+}", "#pi^{-}"}; + + for (int iParticle = 0; iParticle < nTrackSpecies; iParticle++) { + mHistManager.add(Form("TrackCuts/TracksBefore/fMomCorrelationAfterCuts%s", particleSpecies[iParticle]), Form("%s momentum correlation;#bf{#it{p} (GeV/#it{c})};#bf{#it{p}_{TPC} (GeV/#it{c})}", particleSpecies[iParticle]), {HistType::kTH2F, {{500, 0.0f, 20.0f}, {500, 0.0f, 20.0f}}}); + mHistManager.add(Form("TrackCuts/TPCSignal/fTPCSignal%s", particleSpecies[iParticle]), Form("%s TPC energy loss;#bf{#it{p}_{TPC}^{%s} (GeV/#it{c})};#bf{TPC d#it{E}/d#it{x}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{500, 0.0f, 6.0f}, {10000, -100.f, 500.f}}}); + + mHistManager.add(Form("TrackCuts/%s/fP", particleSpecies[iParticle]), Form("%s momentum at PV;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add(Form("TrackCuts/%s/fPt", particleSpecies[iParticle]), Form("%s transverse momentum;#bf{#it{p}_{T}^{%s} (GeV/#it{c})};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add(Form("TrackCuts/%s/fMomCorDif", particleSpecies[iParticle]), Form("Momentum correlation;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{#it{p}_{TPC}^{%s} - #it{p}^{%s} (GeV/#it{c})}", particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{500, 0, 10}, {600, -3, 3}}}); + mHistManager.add(Form("TrackCuts/%s/fMomCorRatio", particleSpecies[iParticle]), Form("Relative momentum correlation;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{#it{p}_{TPC}^{%s} - #it{p}^{%s} / #it{p}^{%s}}", particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{500, 0, 10}, {200, -1, 1}}}); + mHistManager.add(Form("TrackCuts/%s/fEta", particleSpecies[iParticle]), Form("%s pseudorapidity distribution;#eta;#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add(Form("TrackCuts/%s/fPhi", particleSpecies[iParticle]), Form("%s azimuthal angle distribution;#phi;#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + mHistManager.add(Form("TrackCuts/%s/fNsigmaTPCvsTPCP", particleSpecies[iParticle]), Form("NSigmaTPC %s;#bf{#it{p}_{TPC}^{%s} (GeV/#it{c})};#bf{n#sigma_{TPC}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTOFvsTPCP", particleSpecies[iParticle]), Form("NSigmaTOF %s;#bf{#it{p}_{TPC}^{%s} (GeV/#it{c})};#bf{n#sigma_{TOF}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTPCTOFvsTPCP", particleSpecies[iParticle]), Form("NSigmaTPCTOF %s;#bf{#it{p}_{TPC}^{%s} (GeV/#it{c})};n#sigma_{comb}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaITSvsP", particleSpecies[iParticle]), Form("NSigmaITS %s;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{n#sigma_{ITS}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTPCvsP", particleSpecies[iParticle]), Form("NSigmaTPC %s P;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{n#sigma_{TPC}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTOFvsP", particleSpecies[iParticle]), Form("NSigmaTOF %s P;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{n#sigma_{TOF}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTPCTOFvsP", particleSpecies[iParticle]), Form("NSigmaTPCTOF %s P;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{n#sigma_{comb}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); + + mHistManager.add(Form("TrackCuts/%s/fDCAxy", particleSpecies[iParticle]), Form("fDCAxy %s;#bf{DCA_{xy}};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, -0.5f, 0.5f}}); + mHistManager.add(Form("TrackCuts/%s/fDCAz", particleSpecies[iParticle]), Form("fDCAz %s;#bf{DCA_{z}};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, -0.5f, 0.5f}}); + mHistManager.add(Form("TrackCuts/%s/fTPCsCls", particleSpecies[iParticle]), Form("fTPCsCls %s;#bf{TPC Shared Clusters};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{163, -1.0f, 162.0f}}); + mHistManager.add(Form("TrackCuts/%s/fTPCcRows", particleSpecies[iParticle]), Form("fTPCcRows %s;#bf{TPC Crossed Rows};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{163, -1.0f, 162.0f}}); + mHistManager.add(Form("TrackCuts/%s/fTrkTPCfCls", particleSpecies[iParticle]), Form("fTrkTPCfCls %s;#bf{TPC Findable/CrossedRows};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, 0.0f, 3.0f}}); + mHistManager.add(Form("TrackCuts/%s/fTPCncls", particleSpecies[iParticle]), Form("fTPCncls %s;#bf{TPC Clusters};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{163, -1.0f, 162.0f}}); + } + + // --> HNM QA + // pi+ daughter + mHistManager.add("HNM/Before/PosDaughter/fInvMass", "Invariant mass HMN Pos Daugh;#bf{#it{M}^{#pi^{+}} (GeV/#it{c}^{2})};#bf{#it{N}^{#pi^{+}}}", HistType::kTH1F, {{200, 0, 0.2}}); + mHistManager.add("HNM/Before/PosDaughter/fPt", "Transverse momentum HMN Pos Daugh tracks;#bf{#it{p}_{T} (GeV/#it{c})};#bf{#it{N}^{#pi^{+}}}", HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add("HNM/Before/PosDaughter/fEta", "HMN Pos Daugh Eta;#eta;#bf{#it{N}^{#pi^{+}}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/PosDaughter/fPhi", "Azimuthal angle of HMN Pos Daugh tracks;#phi;#bf{#it{N}^{#pi^{+}}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + // pi- daughter + mHistManager.add("HNM/Before/NegDaughter/fInvMass", "Invariant mass HMN Neg Daugh;#bf{#it{M}^{#pi^{-}} (GeV/#it{c}^{2})};#bf{#it{N}^{#pi^{-}}}", HistType::kTH1F, {{200, 0, 0.2}}); + mHistManager.add("HNM/Before/NegDaughter/fPt", "Transverse momentum HMN Neg Daugh tracks;#bf{#it{p}_{T} (GeV/#it{c})};#bf{#it{N}^{#pi^{-}}}", HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add("HNM/Before/NegDaughter/fEta", "HMN Neg Daugh Eta;#eta;#bf{#it{N}^{#pi^{-}}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/NegDaughter/fPhi", "Azimuthal angle of HMN Neg Daugh tracks;#phi;#bf{#it{N}^{#pi^{-}}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + // Properties of the pi+pi- pair + mHistManager.add("HNM/Before/PiPlPiMi/fInvMassVsPt", "Invariant mass and pT of #pi^+pi^- pairs;#bf{#it{M}^{#pi^{+}#pi^{-}} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}} (GeV/#it{c})}", HistType::kTH2F, {{400, 0.2, 1.}, {250, 0., 25.}}); + mHistManager.add("HNM/Before/PiPlPiMi/fEta", "Pseudorapidity of HMNCand;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/PiPlPiMi/fPhi", "Azimuthal angle of HMNCand;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + for (const auto& BeforeAfterString : {"Before", "After"}) { + for (const auto& iHNM : {"Omega", "EtaPrime"}) { + for (const auto& MethodString : {"PCM", "EMC"}) { + mHistManager.add(Form("HNM/%s/%s/%s/fInvMassVsPt", BeforeAfterString, iHNM, MethodString), "Invariant mass and pT of heavy neutral meson candidates;#bf{#it{M}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{600, 0.6, 1.2}, {250, 0., 25.}}); + mHistManager.add(Form("HNM/%s/%s/%s/fEta", BeforeAfterString, iHNM, MethodString), "Pseudorapidity of HNM candidate;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add(Form("HNM/%s/%s/%s/fPhi", BeforeAfterString, iHNM, MethodString), "Azimuthal angle of HNM candidate;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + } + } + } + mHistManager.add("HNM/Before/Omega/PCMEMC/fInvMassVsPt", "Invariant mass and pT of omega meson candidates;#bf{#it{M}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{600, 0.6, 1.2}, {250, 0., 25.}}); + mHistManager.add("HNM/Before/Omega/PCMEMC/fEta", "Pseudorapidity of HMNCand;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/Omega/PCMEMC/fPhi", "Azimuthal angle of HMNCand;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + mHistManager.add("HNM/Before/EtaPrime/PCMEMC/fInvMassVsPt", "Invariant mass and pT of eta' meson candidates;#bf{#it{M}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{600, 0.8, 1.2}, {250, 0., 25.}}); + mHistManager.add("HNM/Before/EtaPrime/PCMEMC/fEta", "Pseudorapidity of HMNCand;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/EtaPrime/PCMEMC/fPhi", "Azimuthal angle of HMNCand;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + // --> Two body femto histograms + for (const auto& iFemtoPartner : {"p", "d"}) { + for (const auto& iHNM : {"omega", "etaprime"}) { + mHistManager.add(Form("%s%s/fMultiplicity", iHNM, iFemtoPartner), "Multiplicity of all processed events;#bf{#it{N}_{tracks}};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, 0, 500}}); + mHistManager.add(Form("%s%s/fZvtx", iHNM, iFemtoPartner), "Zvtx of all processed events;#bf{z_{vtx} (cm)};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, -15, 15}}); + for (const auto& iEMCPCM : {"PCM", "EMC"}) { + mHistManager.add(Form("%s%s/fSE_particle_%s", iHNM, iFemtoPartner, iEMCPCM), Form("Same Event distribution;#bf{#it{K}^{*} (GeV/#it{c})};#bf{#it{N}^{%s}}", iFemtoPartner), HistType::kTH1F, {{8000, 0, 8}}); + mHistManager.add(Form("%s%s/fSE_Antiparticle_%s", iHNM, iFemtoPartner, iEMCPCM), Form("Same Event distribution;#bf{#it{K}^{*} (GeV/#it{c})};#bf{#it{N}^{#bar{%s}}}", iFemtoPartner), HistType::kTH1F, {{8000, 0, 8}}); + mHistManager.add(Form("%s%s/f%sPtVskstar_%s", iHNM, iFemtoPartner, iHNM, iEMCPCM), Form("K* vs %s pt;#bf{#it{K}^{*} (GeV/#it{c})};#bf{#it{p}_{T}^{%s} (GeV/#it{c})}", iHNM, iHNM), HistType::kTH2F, {{{150, 0, 1.5}, {500, 0, 10}}}); + mHistManager.add(Form("%s%s/f%sPtVskstar_%s", iHNM, iFemtoPartner, iFemtoPartner, iEMCPCM), Form("K* vs %s pt;#bf{#it{K}^{*} (GeV/#it{c})};#bf{#it{p}_{T}^{%s} (GeV/#it{c})}", iFemtoPartner, iFemtoPartner), HistType::kTH2F, {{{150, 0, 1.5}, {500, 0, 10}}}); + mHistManager.add(Form("%s%s/fAnti%sPtVskstar_%s", iHNM, iFemtoPartner, iFemtoPartner, iEMCPCM), Form("K* vs #bar{%s} pt;#bf{#it{K}^{*} (GeV/#it{c})};#bf{#it{p}_{T}^{#bar{%s}} (GeV/#it{c})}", iFemtoPartner, iFemtoPartner), HistType::kTH2F, {{{150, 0, 1.5}, {500, 0, 10}}}); + mHistManager.add(Form("%s%s/fInvMassVsKStar_%s", iHNM, iFemtoPartner, iEMCPCM), "Invariant mass and K* of heavy neutral meson candidates;#bf{#it{M}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{K}^{*} (GeV/#it{c})}", HistType::kTH2F, {{600, 0.6, 1.2}, {250, 0., 1.}}); + } + } + } + + // --> Three body femto histograms + for (const auto& iHNM : {"omega", "etaprime"}) { + mHistManager.add(Form("pp%s/fMultiplicity", iHNM), "Multiplicity of all processed events;#bf{#it{N}_{tracks}};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, 0, 500}}); + mHistManager.add(Form("pp%s/fZvtx", iHNM), "Zvtx of all processed events;#bf{z_{vtx} (cm)};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, -15, 15}}); + for (const auto& iEMCPCM : {"PCM", "EMC"}) { + mHistManager.add(Form("pp%s/fSE_particle_%s", iHNM, iEMCPCM), "Same Event distribution;#bf{#it{Q}_{3} (GeV/#it{c})};#bf{#it{N}^{pp}}", HistType::kTH1F, {{8000, 0, 8}}); + mHistManager.add(Form("pp%s/fSE_Antiparticle_%s", iHNM, iEMCPCM), "Same Event distribution;#bf{#it{Q}_{3} (GeV/#it{c})};#bf{#it{N}^{#bar{p}#bar{p}}}", HistType::kTH1F, {{8000, 0, 8}}); + mHistManager.add(Form("pp%s/fProtonPtVsQ3_%s", iHNM, iEMCPCM), "pT (proton) vs Q_{3};#bf{#it{Q}_{3} (GeV/#it{c})};#bf{#it{p}_{T}^{p} (GeV/#it{c})}", HistType::kTH2F, {{{150, 0, 1.5}, {500, 0, 10}}}); + mHistManager.add(Form("pp%s/f%sCandPtVsQ3_%s", iHNM, iHNM, iEMCPCM), Form("pT (%s) vs Q_{3};#bf{#it{Q}_{3} (GeV/#it{c})};#bf{#it{p}_{T}^{%s} (GeV/#it{c})}", iHNM, iHNM), HistType::kTH2F, {{{150, 0, 1.5}, {500, 0, 10}}}); + mHistManager.add(Form("pp%s/fAntiProtonPtVsQ3_%s", iHNM, iEMCPCM), "pT (antiproton) vs Q_{3};#bf{#it{Q}_{3} (GeV/#it{c})};#bf{#it{p}_{T}^{#bar{p}} (GeV/#it{c})}", HistType::kTH2F, {{{150, 0, 1.5}, {500, 0, 10}}}); + mHistManager.add(Form("pp%s/fInvMassVsQ3_%s", iHNM, iEMCPCM), "Invariant mass and Q3 of heavy neutral meson candidates;#bf{#it{M}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{Q}_{3} (GeV/#it{c})}", HistType::kTH2F, {{600, 0.6, 1.2}, {250, 0., 1.}}); + } + } + + if (cfgDoEMCShift.value) { + for (int iSM = 0; iSM < nSMs; iSM++) { + emcEtaShift[iSM] = cfgEMCEtaShift.value[iSM]; + emcPhiShift[iSM] = cfgEMCPhiShift.value[iSM]; + LOG(info) << "SM-wise shift in eta/phi for SM " << iSM << ": " << emcEtaShift[iSM] << " / " << emcPhiShift[iSM]; + } + } + } + + void process(aod::MyCollision const& collision, aod::MyBCs const&, aod::SkimEMCClusters const& clusters, aod::V0PhotonsKF const& v0s, aod::SelectedTracks const& tracks) + { + // inlcude ITS PID information + auto tracksWithItsPid = soa::Attach(tracks); + + // QA all evts + mHistManager.fill(HIST("fProcessedEvents"), 0); + mHistManager.fill(HIST("Event/fMultiplicityBefore"), collision.multNTracksPV()); + mHistManager.fill(HIST("Event/fZvtxBefore"), collision.posZ()); + + // Ensure evts are consistent with Sel8 and Vtx-z selection + bool keepFemtoEvent[hnmtrigger::kNFemtoTriggers] = {false, false, false, false, false, false}; // Set based on number of found pairs (see above) - used to flag femto events + if (!isSelectedEvent(collision)) { + tags(keepFemtoEvent[hnmtrigger::kOmegaP], keepFemtoEvent[hnmtrigger::kPPOmega], keepFemtoEvent[hnmtrigger::kOmegaD], keepFemtoEvent[hnmtrigger::kEtaPrimeP], keepFemtoEvent[hnmtrigger::kPPEtaPrime], keepFemtoEvent[hnmtrigger::kEtaPrimeD]); + return; + } + // QA accepted evts + mHistManager.fill(HIST("Event/fMultiplicityAfter"), collision.multNTracksPV()); + mHistManager.fill(HIST("Event/fZvtxAfter"), collision.posZ()); + + colContainsPCMOmega = colContainsEMCOmega = colContainsPCMEtaPrime = colContainsEMCEtaPrime = false; // Used by spectrum trigger to flag events with high-pT omega/eta' candidates + int lowMomentumMultiplets[hnmtrigger::kNFemtoTriggers] = {0, 0, 0, 0, 0, 0}; // Number of found femto pairs/triplets for each femto trigger + + // clean vecs + // HNM candidates + etaPrimeEMC.clear(); + etaPrimePCM.clear(); + omegaEMC.clear(); + omegaPCM.clear(); + // Femto partners + proton.clear(); + antiproton.clear(); + deuteron.clear(); + antideuteron.clear(); + // Pions for HNM + pion.clear(); + antipion.clear(); + vHNMs.clear(); + // vGGs vector is cleared in reconstructGGs. + + // ---------------------------------> EMCal event QA <---------------------------------- + // - Fill Event/nEMCalEvents histogram for EMCal event QA + // ------------------------------------------------------------------------------------- + bool bcHasEMCCells = collision.isemcreadout(); + bool iskTVXinEMC = collision.foundBC_as().alias_bit(kTVXinEMC); + bool isL0Triggered = collision.foundBC_as().alias_bit(kEMC7) || collision.foundBC_as().alias_bit(kEG1) || collision.foundBC_as().alias_bit(kEG2); + + if (bcHasEMCCells && iskTVXinEMC) + mHistManager.fill(HIST("Event/nEMCalEvents"), 0); + if (bcHasEMCCells && isL0Triggered) + mHistManager.fill(HIST("Event/nEMCalEvents"), 1); + if (bcHasEMCCells && !iskTVXinEMC && !isL0Triggered) + mHistManager.fill(HIST("Event/nEMCalEvents"), 2); + if (!bcHasEMCCells && iskTVXinEMC) + mHistManager.fill(HIST("Event/nEMCalEvents"), 3); + if (!bcHasEMCCells && isL0Triggered) + mHistManager.fill(HIST("Event/nEMCalEvents"), 4); + + // --------------------------------> Process Photons <---------------------------------- + // - Slice clusters and V0s by collision ID to get the ones in this collision + // - Store the clusters and V0s in the vGammas vector + // - Reconstruct gamma-gamma pairs + // ------------------------------------------------------------------------------------- + auto v0sInThisCollision = v0s.sliceBy(perCollisionPCM, collision.globalIndex()); + auto clustersInThisCollision = clusters.sliceBy(perCollisionEMC, collision.globalIndex()); + mHistManager.fill(HIST("Event/nClustersVsV0s"), clustersInThisCollision.size(), v0sInThisCollision.size()); + + std::vector vGammas; + hnmutilities::storeGammasInVector(clustersInThisCollision, v0sInThisCollision, vGammas, emcEtaShift, emcPhiShift); + hnmutilities::reconstructGGs(vGammas, vGGs); + vGammas.clear(); + processGGs(vGGs); + + // ------------------------------> Loop over all tracks <------------------------------- + // - Sort them into vectors based on PID ((anti)protons, (anti)deuterons, (anti)pions) + // - Fill QA histograms for all tracks and per particle species + // ------------------------------------------------------------------------------------- + for (const auto& track : tracksWithItsPid) { + mHistManager.fill(HIST("TrackCuts/TracksBefore/fPtTrackBefore"), track.pt()); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fEtaTrackBefore"), track.eta()); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fPhiTrackBefore"), track.phi()); + if (track.sign() > 0) { // All particles (positive electric charge) + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalTPCP"), track.tpcInnerParam(), track.tpcSignal()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignal"), track.p(), track.tpcSignal()); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationPos"), track.p(), track.tpcInnerParam()); + } + if (track.sign() < 0) { // All anti-particles (negative electric charge) + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiTPCP"), track.tpcInnerParam(), track.tpcSignal()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAnti"), track.p(), track.tpcSignal()); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationNeg"), track.p(), track.tpcInnerParam()); + } + + // For each track, check if it fulfills track and PID criteria to be identified as a proton, deuteron or pion + bool isProton = (isSelectedTrackPID(track, hnmtrigger::kProton) && isSelectedTrack(track, hnmtrigger::kProton)); + bool isDeuteron = (isSelectedTrackPID(track, hnmtrigger::kDeuteron) && isSelectedTrack(track, hnmtrigger::kDeuteron)); + bool isPion = (isSelectedTrackPID(track, hnmtrigger::kPion) && isSelectedTrack(track, hnmtrigger::kPion)); + + if (track.sign() > 0) { // Positive charge -> Particles + if (isProton) { + proton.emplace_back(track.pt(), track.eta(), track.phi(), mMassProton); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsProton"), track.p(), track.tpcInnerParam()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalProton"), track.tpcInnerParam(), track.tpcSignal()); + + mHistManager.fill(HIST("TrackCuts/Proton/fP"), track.p()); + mHistManager.fill(HIST("TrackCuts/Proton/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/Proton/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); + mHistManager.fill(HIST("TrackCuts/Proton/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + mHistManager.fill(HIST("TrackCuts/Proton/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/Proton/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/Proton/fNsigmaTPCvsTPCP"), track.tpcInnerParam(), track.tpcNSigmaPr()); + mHistManager.fill(HIST("TrackCuts/Proton/fNsigmaTOFvsTPCP"), track.tpcInnerParam(), track.tofNSigmaPr()); + auto nSigmaTrackTPCTOF = std::sqrt(std::pow(track.tpcNSigmaPr(), 2) + std::pow(track.tofNSigmaPr(), 2)); + mHistManager.fill(HIST("TrackCuts/Proton/fNsigmaTPCTOFvsTPCP"), track.tpcInnerParam(), std::sqrt(std::pow(track.tpcNSigmaPr() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPr() - nSigmaTrackTPCTOF, 2))); + mHistManager.fill(HIST("TrackCuts/Proton/fNsigmaITSvsP"), track.p(), track.itsNSigmaPr()); + mHistManager.fill(HIST("TrackCuts/Proton/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaPr()); + mHistManager.fill(HIST("TrackCuts/Proton/fNsigmaTOFvsP"), track.p(), track.tofNSigmaPr()); + mHistManager.fill(HIST("TrackCuts/Proton/fNsigmaTPCTOFvsP"), track.p(), std::sqrt(std::pow(track.tpcNSigmaPr() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPr() - nSigmaTrackTPCTOF, 2))); + + mHistManager.fill(HIST("TrackCuts/Proton/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/Proton/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/Proton/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/Proton/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/Proton/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/Proton/fTPCncls"), track.tpcNClsFound()); + } + if (isDeuteron) { + deuteron.emplace_back(track.pt(), track.eta(), track.phi(), mMassDeuteron); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsDeuteron"), track.p(), track.tpcInnerParam()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalDeuteron"), track.tpcInnerParam(), track.tpcSignal()); + + mHistManager.fill(HIST("TrackCuts/Deuteron/fP"), track.p()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/Deuteron/fNsigmaTPCvsTPCP"), track.tpcInnerParam(), track.tpcNSigmaDe()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fNsigmaTOFvsTPCP"), track.tpcInnerParam(), track.tofNSigmaDe()); + auto nSigmaTrackTPCTOF = std::sqrt(std::pow(track.tpcNSigmaDe(), 2) + std::pow(track.tofNSigmaDe(), 2)); + mHistManager.fill(HIST("TrackCuts/Deuteron/fNsigmaTPCTOFvsTPCP"), track.tpcInnerParam(), std::sqrt(std::pow(track.tpcNSigmaDe() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaDe() - nSigmaTrackTPCTOF, 2))); + mHistManager.fill(HIST("TrackCuts/Deuteron/fNsigmaITSvsP"), track.p(), track.itsNSigmaDe()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaDe()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fNsigmaTOFvsP"), track.p(), track.tofNSigmaDe()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fNsigmaTPCTOFvsP"), track.p(), std::sqrt(std::pow(track.tpcNSigmaDe() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaDe() - nSigmaTrackTPCTOF, 2))); + + mHistManager.fill(HIST("TrackCuts/Deuteron/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/Deuteron/fTPCncls"), track.tpcNClsFound()); + } + if (isPion) { + pion.emplace_back(track.pt(), track.eta(), track.phi(), mMassPionCharged); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsPion"), track.p(), track.tpcInnerParam()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalPion"), track.tpcInnerParam(), track.tpcSignal()); + + mHistManager.fill(HIST("TrackCuts/Pion/fP"), track.p()); + mHistManager.fill(HIST("TrackCuts/Pion/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/Pion/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); + mHistManager.fill(HIST("TrackCuts/Pion/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + mHistManager.fill(HIST("TrackCuts/Pion/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/Pion/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTPCvsTPCP"), track.tpcInnerParam(), track.tpcNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTOFvsTPCP"), track.tpcInnerParam(), track.tofNSigmaPi()); + auto nSigmaTrackTPCTOF = std::sqrt(std::pow(track.tpcNSigmaPi(), 2) + std::pow(track.tofNSigmaPi(), 2)); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTPCTOFvsTPCP"), track.tpcInnerParam(), std::sqrt(std::pow(track.tpcNSigmaPi() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPi() - nSigmaTrackTPCTOF, 2))); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaITSvsP"), track.p(), track.itsNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTOFvsP"), track.p(), track.tofNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTPCTOFvsP"), track.p(), std::sqrt(std::pow(track.tpcNSigmaPi() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPi() - nSigmaTrackTPCTOF, 2))); + + mHistManager.fill(HIST("TrackCuts/Pion/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/Pion/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/Pion/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/Pion/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/Pion/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/Pion/fTPCncls"), track.tpcNClsFound()); + } + } else { // Negative charge -> Anti-particles + if (isProton) { + antiproton.emplace_back(track.pt(), track.eta(), track.phi(), mMassProton); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsAntiProton"), track.p(), track.tpcInnerParam()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiProton"), track.tpcInnerParam(), track.tpcSignal()); + + mHistManager.fill(HIST("TrackCuts/AntiProton/fP"), track.p()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/AntiProton/fNsigmaTPCvsTPCP"), track.tpcInnerParam(), track.tpcNSigmaPr()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fNsigmaTOFvsTPCP"), track.tpcInnerParam(), track.tofNSigmaPr()); + auto nSigmaTrackTPCTOF = std::sqrt(std::pow(track.tpcNSigmaPr(), 2) + std::pow(track.tofNSigmaPr(), 2)); + mHistManager.fill(HIST("TrackCuts/AntiProton/fNsigmaTPCTOFvsTPCP"), track.tpcInnerParam(), std::sqrt(std::pow(track.tpcNSigmaPr() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPr() - nSigmaTrackTPCTOF, 2))); + mHistManager.fill(HIST("TrackCuts/AntiProton/fNsigmaITSvsP"), track.p(), track.itsNSigmaPr()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaPr()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fNsigmaTOFvsP"), track.p(), track.tofNSigmaPr()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fNsigmaTPCTOFvsP"), track.p(), std::sqrt(std::pow(track.tpcNSigmaPr() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPr() - nSigmaTrackTPCTOF, 2))); + + mHistManager.fill(HIST("TrackCuts/AntiProton/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/AntiProton/fTPCncls"), track.tpcNClsFound()); + } + if (isDeuteron) { + antideuteron.emplace_back(track.pt(), track.eta(), track.phi(), mMassDeuteron); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsAntiDeuteron"), track.p(), track.tpcInnerParam()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiDeuteron"), track.tpcInnerParam(), track.tpcSignal()); + + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fP"), track.p()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTPCvsTPCP"), track.tpcInnerParam(), track.tpcNSigmaDe()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTOFvsTPCP"), track.tpcInnerParam(), track.tofNSigmaDe()); + auto nSigmaTrackTPCTOF = std::sqrt(std::pow(track.tpcNSigmaDe(), 2) + std::pow(track.tofNSigmaDe(), 2)); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTPCTOFvsTPCP"), track.tpcInnerParam(), std::sqrt(std::pow(track.tpcNSigmaDe() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaDe() - nSigmaTrackTPCTOF, 2))); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaITSvsP"), track.p(), track.itsNSigmaDe()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaDe()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTOFvsP"), track.p(), track.tofNSigmaDe()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fNsigmaTPCTOFvsP"), track.p(), std::sqrt(std::pow(track.tpcNSigmaDe() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaDe() - nSigmaTrackTPCTOF, 2))); + + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/AntiDeuteron/fTPCncls"), track.tpcNClsFound()); + } + if (isPion) { + antipion.emplace_back(track.pt(), track.eta(), track.phi(), mMassPionCharged); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsAntiPion"), track.p(), track.tpcInnerParam()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiPion"), track.tpcInnerParam(), track.tpcSignal()); + + mHistManager.fill(HIST("TrackCuts/AntiPion/fP"), track.p()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTPCvsTPCP"), track.tpcInnerParam(), track.tpcNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTOFvsTPCP"), track.tpcInnerParam(), track.tofNSigmaPi()); + auto nSigmaTrackTPCTOF = std::sqrt(std::pow(track.tpcNSigmaPi(), 2) + std::pow(track.tofNSigmaPi(), 2)); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTPCTOFvsTPCP"), track.tpcInnerParam(), std::sqrt(std::pow(track.tpcNSigmaPi() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPi() - nSigmaTrackTPCTOF, 2))); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaITSvsP"), track.p(), track.itsNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTOFvsP"), track.p(), track.tofNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTPCTOFvsP"), track.p(), std::sqrt(std::pow(track.tpcNSigmaPi() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPi() - nSigmaTrackTPCTOF, 2))); + + mHistManager.fill(HIST("TrackCuts/AntiPion/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTPCncls"), track.tpcNClsFound()); + } + } + } + + // -------------------------> Reconstruct HNM candidates <------------------------------ + // - Based on the previously filled (anti)pion vectors + // - Fill QA histograms for kinematics of the pions and their combinations + // ------------------------------------------------------------------------------------- + for (const auto& posPion : pion) { + for (const auto& negPion : antipion) { + ROOT::Math::PtEtaPhiMVector vecPiPlPiMi = posPion + negPion; + hnmutilities::reconstructHeavyNeutralMesons(vecPiPlPiMi, vGGs, vHNMs); + + mHistManager.fill(HIST("HNM/Before/PiPlPiMi/fInvMassVsPt"), vecPiPlPiMi.M(), vecPiPlPiMi.pt()); + mHistManager.fill(HIST("HNM/Before/PiPlPiMi/fEta"), vecPiPlPiMi.eta()); + mHistManager.fill(HIST("HNM/Before/PiPlPiMi/fPhi"), RecoDecay::constrainAngle(vecPiPlPiMi.phi())); + + mHistManager.fill(HIST("HNM/Before/PosDaughter/fInvMass"), posPion.M()); + mHistManager.fill(HIST("HNM/Before/PosDaughter/fPt"), posPion.pt()); + mHistManager.fill(HIST("HNM/Before/PosDaughter/fEta"), posPion.eta()); + mHistManager.fill(HIST("HNM/Before/PosDaughter/fPhi"), RecoDecay::constrainAngle(posPion.phi())); + + mHistManager.fill(HIST("HNM/Before/NegDaughter/fInvMass"), negPion.M()); + mHistManager.fill(HIST("HNM/Before/NegDaughter/fPt"), negPion.pt()); + mHistManager.fill(HIST("HNM/Before/NegDaughter/fEta"), negPion.eta()); + mHistManager.fill(HIST("HNM/Before/NegDaughter/fPhi"), RecoDecay::constrainAngle(negPion.phi())); + } + } + + // ---------------------------> Process HNM candidates <-------------------------------- + // - Fill invMassVsPt histograms separated into HNM types (based on GG mass) and gamma reco method + // - Set colContains* flags for each HNM type to be used in the high-pt spectrum trigger + // - Fill femto HNM vectors (omegaPCM, etaPrimePCM, omegaEMC, etaPrimeEMC) + // ------------------------------------------------------------------------------------- + processHNMs(vHNMs); + + // ------------------------------> Build triplets <------------------------------------- + // - Calculate Q3 for each triplet (p-p-omega, p-p-eta', anti-p-anti-p-omega, anti-p-anti-p-eta') + // - Fill QA histograms for Q3 and pT of the triplet and its daughters + // - Increment lowMomentumMultiplets for each triplet with Q3 < kinematic limit (used in femto trigger) + // ------------------------------------------------------------------------------------- + if (cfgTriggerSwitches->get("Switch", "PPOmega") > 0.) { // -----> p-p-omega femtoscopy + for (size_t i = 0; i < proton.size(); ++i) { + for (size_t j = i + 1; j < proton.size(); ++j) { + const auto& proton1 = proton[i]; + const auto& proton2 = proton[j]; + for (const auto& omegaParticles : omegaPCM) { // ---> PCM + + float q3 = getQ3(proton1, proton2, omegaParticles); + + mHistManager.fill(HIST("ppomega/fSE_particle_PCM"), q3); + mHistManager.fill(HIST("ppomega/fProtonPtVsQ3_PCM"), q3, proton1.Pt()); + mHistManager.fill(HIST("ppomega/fProtonPtVsQ3_PCM"), q3, proton2.Pt()); + mHistManager.fill(HIST("ppomega/fomegaCandPtVsQ3_PCM"), q3, omegaParticles.Pt()); + mHistManager.fill(HIST("ppomega/fInvMassVsQ3_PCM"), omegaParticles.M(), q3); + + if (q3 < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kPPOmega)) + lowMomentumMultiplets[hnmtrigger::kPPOmega] += 1; + } + for (const auto& omegaParticles : omegaEMC) { // ---> EMC + + float q3 = getQ3(proton1, proton2, omegaParticles); + + mHistManager.fill(HIST("ppomega/fSE_particle_EMC"), q3); + mHistManager.fill(HIST("ppomega/fProtonPtVsQ3_EMC"), q3, proton1.Pt()); + mHistManager.fill(HIST("ppomega/fProtonPtVsQ3_EMC"), q3, proton2.Pt()); + mHistManager.fill(HIST("ppomega/fomegaCandPtVsQ3_EMC"), q3, omegaParticles.Pt()); + mHistManager.fill(HIST("ppomega/fInvMassVsQ3_EMC"), omegaParticles.M(), q3); + + if (q3 < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kPPOmega)) + lowMomentumMultiplets[hnmtrigger::kPPOmega] += 1; + } + } + } + for (size_t i = 0; i < antiproton.size(); ++i) { // -----> antip-antip-omega femtoscopy + for (size_t j = i + 1; j < antiproton.size(); ++j) { + const auto& antiProton1 = antiproton[i]; + const auto& antiProton2 = antiproton[j]; + for (const auto& omegaParticles : omegaPCM) { // ---> PCM + + float q3 = getQ3(antiProton1, antiProton2, omegaParticles); + + mHistManager.fill(HIST("ppomega/fSE_Antiparticle_PCM"), q3); + mHistManager.fill(HIST("ppomega/fAntiProtonPtVsQ3_PCM"), q3, antiProton1.Pt()); + mHistManager.fill(HIST("ppomega/fAntiProtonPtVsQ3_PCM"), q3, antiProton2.Pt()); + mHistManager.fill(HIST("ppomega/fomegaCandPtVsQ3_PCM"), q3, omegaParticles.Pt()); + mHistManager.fill(HIST("ppomega/fInvMassVsQ3_PCM"), omegaParticles.M(), q3); + + if (q3 < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kPPOmega)) + lowMomentumMultiplets[hnmtrigger::kPPOmega] += 1; + } + for (const auto& omegaParticles : omegaEMC) { // ---> EMC + + float q3 = getQ3(antiProton1, antiProton2, omegaParticles); + + mHistManager.fill(HIST("ppomega/fSE_Antiparticle_EMC"), q3); + mHistManager.fill(HIST("ppomega/fAntiProtonPtVsQ3_EMC"), q3, antiProton1.Pt()); + mHistManager.fill(HIST("ppomega/fAntiProtonPtVsQ3_EMC"), q3, antiProton2.Pt()); + mHistManager.fill(HIST("ppomega/fomegaCandPtVsQ3_EMC"), q3, omegaParticles.Pt()); + mHistManager.fill(HIST("ppomega/fInvMassVsQ3_EMC"), omegaParticles.M(), q3); + + if (q3 < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kPPOmega)) + lowMomentumMultiplets[hnmtrigger::kPPOmega] += 1; + } + } + } + } + if (cfgTriggerSwitches->get("Switch", "PPEtaPrime") > 0.) { // -----> p-p-eta' femtoscopy + for (size_t i = 0; i < proton.size(); ++i) { + for (size_t j = i + 1; j < proton.size(); ++j) { + const auto& proton1 = proton[i]; + const auto& proton2 = proton[j]; + for (const auto& etaParticles : etaPrimePCM) { // ---> PCM + + float q3 = getQ3(proton1, proton2, etaParticles); + + mHistManager.fill(HIST("ppetaprime/fSE_particle_PCM"), q3); + mHistManager.fill(HIST("ppetaprime/fProtonPtVsQ3_PCM"), q3, proton1.Pt()); + mHistManager.fill(HIST("ppetaprime/fProtonPtVsQ3_PCM"), q3, proton2.Pt()); + mHistManager.fill(HIST("ppetaprime/fetaprimeCandPtVsQ3_PCM"), q3, etaParticles.Pt()); + mHistManager.fill(HIST("ppetaprime/fInvMassVsQ3_PCM"), etaParticles.M(), q3); + + if (q3 < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kPPEtaPrime)) + lowMomentumMultiplets[hnmtrigger::kPPEtaPrime] += 1; + } + for (const auto& etaParticles : etaPrimeEMC) { // ---> EMC + + float q3 = getQ3(proton1, proton2, etaParticles); + + mHistManager.fill(HIST("ppetaprime/fSE_particle_EMC"), q3); + mHistManager.fill(HIST("ppetaprime/fProtonPtVsQ3_EMC"), q3, proton1.Pt()); + mHistManager.fill(HIST("ppetaprime/fProtonPtVsQ3_EMC"), q3, proton2.Pt()); + mHistManager.fill(HIST("ppetaprime/fetaprimeCandPtVsQ3_EMC"), q3, etaParticles.Pt()); + mHistManager.fill(HIST("ppetaprime/fInvMassVsQ3_EMC"), etaParticles.M(), q3); + + if (q3 < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kPPEtaPrime)) + lowMomentumMultiplets[hnmtrigger::kPPEtaPrime] += 1; + } + } + } + for (size_t i = 0; i < antiproton.size(); ++i) { // -----> antip-antip-eta' femtoscopy + for (size_t j = i + 1; j < antiproton.size(); ++j) { + const auto& antiProton1 = antiproton[i]; + const auto& antiProton2 = antiproton[j]; + for (const auto& etaParticles : etaPrimePCM) { // ---> PCM + + float q3 = getQ3(antiProton1, antiProton2, etaParticles); + + mHistManager.fill(HIST("ppetaprime/fSE_Antiparticle_PCM"), q3); + mHistManager.fill(HIST("ppetaprime/fAntiProtonPtVsQ3_PCM"), q3, antiProton1.Pt()); + mHistManager.fill(HIST("ppetaprime/fAntiProtonPtVsQ3_PCM"), q3, antiProton2.Pt()); + mHistManager.fill(HIST("ppetaprime/fetaprimeCandPtVsQ3_PCM"), q3, etaParticles.Pt()); + mHistManager.fill(HIST("ppetaprime/fInvMassVsQ3_PCM"), etaParticles.M(), q3); + + if (q3 < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kPPEtaPrime)) + lowMomentumMultiplets[hnmtrigger::kPPEtaPrime] += 1; + } + for (const auto& etaParticles : etaPrimeEMC) { // ---> EMC + + float q3 = getQ3(antiProton1, antiProton2, etaParticles); + + mHistManager.fill(HIST("ppetaprime/fSE_Antiparticle_EMC"), q3); + mHistManager.fill(HIST("ppetaprime/fAntiProtonPtVsQ3_EMC"), q3, antiProton1.Pt()); + mHistManager.fill(HIST("ppetaprime/fAntiProtonPtVsQ3_EMC"), q3, antiProton2.Pt()); + mHistManager.fill(HIST("ppetaprime/fetaprimeCandPtVsQ3_EMC"), q3, etaParticles.Pt()); + mHistManager.fill(HIST("ppetaprime/fInvMassVsQ3_EMC"), etaParticles.M(), q3); + + if (q3 < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kPPEtaPrime)) + lowMomentumMultiplets[hnmtrigger::kPPEtaPrime] += 1; + } + } + } + } + + // --------------------------------> Build Pairs <-------------------------------------- + // - Calculate k* for each pair ((anti)d-omega, (anti)d-eta', (anti)p-omega, (anti)p-eta') + // - Fill QA histograms for k* and pT of the pairs + // - Increment lowMomentumMultiplets for each triplet with k* < kinematic limit (used in femto trigger) + // ------------------------------------------------------------------------------------- + if (cfgTriggerSwitches->get("Switch", "Omegad") > 0.) { + for (auto iomega = omegaPCM.begin(); iomega != omegaPCM.end(); ++iomega) { // -----> PCM + for (auto iDeuteron = deuteron.begin(); iDeuteron != deuteron.end(); ++iDeuteron) { // ---> d-omega femtoscopy + + float kstar = getkstar(*iomega, *iDeuteron); + + mHistManager.fill(HIST("omegad/fSE_particle_PCM"), kstar); + mHistManager.fill(HIST("omegad/fomegaPtVskstar_PCM"), kstar, (*iomega).Pt()); + mHistManager.fill(HIST("omegad/fdPtVskstar_PCM"), kstar, (*iDeuteron).Pt()); + mHistManager.fill(HIST("omegad/fInvMassVsKStar_PCM"), (*iomega).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kOmegaD)) + lowMomentumMultiplets[hnmtrigger::kOmegaD] += 1; + } + for (auto iAntiDeuteron = antideuteron.begin(); iAntiDeuteron != antideuteron.end(); ++iAntiDeuteron) { // ---> antid-omega femtoscopy + + float kstar = getkstar(*iomega, *iAntiDeuteron); + + mHistManager.fill(HIST("omegad/fSE_Antiparticle_PCM"), kstar); + mHistManager.fill(HIST("omegad/fomegaPtVskstar_PCM"), kstar, (*iomega).Pt()); + mHistManager.fill(HIST("omegad/fAntidPtVskstar_PCM"), kstar, (*iAntiDeuteron).Pt()); + mHistManager.fill(HIST("omegad/fInvMassVsKStar_PCM"), (*iomega).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kOmegaD)) + lowMomentumMultiplets[hnmtrigger::kOmegaD] += 1; + } + } + for (auto iomega = omegaEMC.begin(); iomega != omegaEMC.end(); ++iomega) { // -----> EMC + for (auto iDeuteron = deuteron.begin(); iDeuteron != deuteron.end(); ++iDeuteron) { // ---> d-omega femtoscopy + + float kstar = getkstar(*iomega, *iDeuteron); + + mHistManager.fill(HIST("omegad/fSE_particle_EMC"), kstar); + mHistManager.fill(HIST("omegad/fomegaPtVskstar_EMC"), kstar, (*iomega).Pt()); + mHistManager.fill(HIST("omegad/fdPtVskstar_EMC"), kstar, (*iDeuteron).Pt()); + mHistManager.fill(HIST("omegad/fInvMassVsKStar_EMC"), (*iomega).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kOmegaD)) + lowMomentumMultiplets[hnmtrigger::kOmegaD] += 1; + } + for (auto iAntiDeuteron = antideuteron.begin(); iAntiDeuteron != antideuteron.end(); ++iAntiDeuteron) { // ---> antid-omega femtoscopy + + float kstar = getkstar(*iomega, *iAntiDeuteron); + + mHistManager.fill(HIST("omegad/fSE_Antiparticle_EMC"), kstar); + mHistManager.fill(HIST("omegad/fomegaPtVskstar_EMC"), kstar, (*iomega).Pt()); + mHistManager.fill(HIST("omegad/fAntidPtVskstar_EMC"), kstar, (*iAntiDeuteron).Pt()); + mHistManager.fill(HIST("omegad/fInvMassVsKStar_EMC"), (*iomega).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kOmegaD)) + lowMomentumMultiplets[hnmtrigger::kOmegaD] += 1; + } + } + } + if (cfgTriggerSwitches->get("Switch", "EtaPrimed") > 0.) { + for (auto ietaprime = etaPrimePCM.begin(); ietaprime != etaPrimePCM.end(); ++ietaprime) { // -----> PCM + for (auto iDeuteron = deuteron.begin(); iDeuteron != deuteron.end(); ++iDeuteron) { // ---> d-eta' femtoscopy + + float kstar = getkstar(*ietaprime, *iDeuteron); + + mHistManager.fill(HIST("etaprimed/fSE_particle_PCM"), kstar); + mHistManager.fill(HIST("etaprimed/fetaprimePtVskstar_PCM"), kstar, (*ietaprime).Pt()); + mHistManager.fill(HIST("etaprimed/fdPtVskstar_PCM"), kstar, (*iDeuteron).Pt()); + mHistManager.fill(HIST("etaprimed/fInvMassVsKStar_PCM"), (*ietaprime).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kEtaPrimeD)) + lowMomentumMultiplets[hnmtrigger::kEtaPrimeD] += 1; + } + for (auto iAntiDeuteron = antideuteron.begin(); iAntiDeuteron != antideuteron.end(); ++iAntiDeuteron) { // ---> antid-eta' femtoscopy + + float kstar = getkstar(*ietaprime, *iAntiDeuteron); + + mHistManager.fill(HIST("etaprimed/fSE_Antiparticle_PCM"), kstar); + mHistManager.fill(HIST("etaprimed/fetaprimePtVskstar_PCM"), kstar, (*ietaprime).Pt()); + mHistManager.fill(HIST("etaprimed/fAntidPtVskstar_PCM"), kstar, (*iAntiDeuteron).Pt()); + mHistManager.fill(HIST("etaprimed/fInvMassVsKStar_PCM"), (*ietaprime).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kEtaPrimeD)) + lowMomentumMultiplets[hnmtrigger::kEtaPrimeD] += 1; + } + } + for (auto ietaprime = etaPrimeEMC.begin(); ietaprime != etaPrimeEMC.end(); ++ietaprime) { // -----> EMC + for (auto iDeuteron = deuteron.begin(); iDeuteron != deuteron.end(); ++iDeuteron) { // ---> d-eta' femtoscopy + + float kstar = getkstar(*ietaprime, *iDeuteron); + + mHistManager.fill(HIST("etaprimed/fSE_particle_EMC"), kstar); + mHistManager.fill(HIST("etaprimed/fetaprimePtVskstar_EMC"), kstar, (*ietaprime).Pt()); + mHistManager.fill(HIST("etaprimed/fdPtVskstar_EMC"), kstar, (*iDeuteron).Pt()); + mHistManager.fill(HIST("etaprimed/fInvMassVsKStar_EMC"), (*ietaprime).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kEtaPrimeD)) + lowMomentumMultiplets[hnmtrigger::kEtaPrimeD] += 1; + } + for (auto iAntiDeuteron = antideuteron.begin(); iAntiDeuteron != antideuteron.end(); ++iAntiDeuteron) { // ---> antid-eta' femtoscopy + + float kstar = getkstar(*ietaprime, *iAntiDeuteron); + + mHistManager.fill(HIST("etaprimed/fSE_Antiparticle_EMC"), kstar); + mHistManager.fill(HIST("etaprimed/fetaprimePtVskstar_EMC"), kstar, (*ietaprime).Pt()); + mHistManager.fill(HIST("etaprimed/fAntidPtVskstar_EMC"), kstar, (*iAntiDeuteron).Pt()); + mHistManager.fill(HIST("etaprimed/fInvMassVsKStar_EMC"), (*ietaprime).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kEtaPrimeD)) + lowMomentumMultiplets[hnmtrigger::kEtaPrimeD] += 1; + } + } + } + if (cfgTriggerSwitches->get("Switch", "OmegaP") > 0.) { + for (auto iomega = omegaPCM.begin(); iomega != omegaPCM.end(); ++iomega) { // -----> PCM + for (auto iProton = proton.begin(); iProton != proton.end(); ++iProton) { // ---> p-omega femtoscopy + + float kstar = getkstar(*iomega, *iProton); + + mHistManager.fill(HIST("omegap/fSE_particle_PCM"), kstar); + mHistManager.fill(HIST("omegap/fomegaPtVskstar_PCM"), kstar, (*iomega).Pt()); + mHistManager.fill(HIST("omegap/fpPtVskstar_PCM"), kstar, (*iProton).Pt()); + mHistManager.fill(HIST("omegap/fInvMassVsKStar_PCM"), (*iomega).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kOmegaP)) + lowMomentumMultiplets[hnmtrigger::kOmegaP] += 1; + } + for (auto iAntiProton = antiproton.begin(); iAntiProton != antiproton.end(); ++iAntiProton) { // ---> antip-omega femtoscopy + + float kstar = getkstar(*iomega, *iAntiProton); + + mHistManager.fill(HIST("omegap/fSE_Antiparticle_PCM"), kstar); + mHistManager.fill(HIST("omegap/fomegaPtVskstar_PCM"), kstar, (*iomega).Pt()); + mHistManager.fill(HIST("omegap/fAntipPtVskstar_PCM"), kstar, (*iAntiProton).Pt()); + mHistManager.fill(HIST("omegap/fInvMassVsKStar_PCM"), (*iomega).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kOmegaP)) + lowMomentumMultiplets[hnmtrigger::kOmegaP] += 1; + } + } + for (auto iomega = omegaEMC.begin(); iomega != omegaEMC.end(); ++iomega) { // -----> EMC + for (auto iProton = proton.begin(); iProton != proton.end(); ++iProton) { // ---> p-omega femtoscopy + + float kstar = getkstar(*iomega, *iProton); + + mHistManager.fill(HIST("omegap/fSE_particle_EMC"), kstar); + mHistManager.fill(HIST("omegap/fomegaPtVskstar_EMC"), kstar, (*iomega).Pt()); + mHistManager.fill(HIST("omegap/fpPtVskstar_EMC"), kstar, (*iProton).Pt()); + mHistManager.fill(HIST("omegap/fInvMassVsKStar_EMC"), (*iomega).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kOmegaP)) + lowMomentumMultiplets[hnmtrigger::kOmegaP] += 1; + } + for (auto iAntiProton = antiproton.begin(); iAntiProton != antiproton.end(); ++iAntiProton) { // ---> antip-omega femtoscopy + + float kstar = getkstar(*iomega, *iAntiProton); + + mHistManager.fill(HIST("omegap/fSE_Antiparticle_EMC"), kstar); + mHistManager.fill(HIST("omegap/fomegaPtVskstar_EMC"), kstar, (*iomega).Pt()); + mHistManager.fill(HIST("omegap/fAntipPtVskstar_EMC"), kstar, (*iAntiProton).Pt()); + mHistManager.fill(HIST("omegap/fInvMassVsKStar_EMC"), (*iomega).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kOmegaP)) + lowMomentumMultiplets[hnmtrigger::kOmegaP] += 1; + } + } + } + if (cfgTriggerSwitches->get("Switch", "EtaPrimeP") > 0.) { + for (auto ietaprime = etaPrimePCM.begin(); ietaprime != etaPrimePCM.end(); ++ietaprime) { // -----> PCM + for (auto iProton = proton.begin(); iProton != proton.end(); ++iProton) { // ---> p-eta' femtoscopy + + float kstar = getkstar(*ietaprime, *iProton); + + mHistManager.fill(HIST("etaprimep/fSE_particle_PCM"), kstar); + mHistManager.fill(HIST("etaprimep/fetaprimePtVskstar_PCM"), kstar, (*ietaprime).Pt()); + mHistManager.fill(HIST("etaprimep/fpPtVskstar_PCM"), kstar, (*iProton).Pt()); + mHistManager.fill(HIST("etaprimep/fInvMassVsKStar_PCM"), (*ietaprime).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kEtaPrimeP)) + lowMomentumMultiplets[hnmtrigger::kEtaPrimeP] += 1; + } + for (auto iAntiProton = antiproton.begin(); iAntiProton != antiproton.end(); ++iAntiProton) { // ---> antip-eta' femtoscopy + + float kstar = getkstar(*ietaprime, *iAntiProton); + + mHistManager.fill(HIST("etaprimep/fSE_Antiparticle_PCM"), kstar); + mHistManager.fill(HIST("etaprimep/fetaprimePtVskstar_PCM"), kstar, (*ietaprime).Pt()); + mHistManager.fill(HIST("etaprimep/fAntipPtVskstar_PCM"), kstar, (*iAntiProton).Pt()); + mHistManager.fill(HIST("etaprimep/fInvMassVsKStar_PCM"), (*ietaprime).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kEtaPrimeP)) + lowMomentumMultiplets[hnmtrigger::kEtaPrimeP] += 1; + } + } + for (auto ietaprime = etaPrimeEMC.begin(); ietaprime != etaPrimeEMC.end(); ++ietaprime) { // -----> EMC + for (auto iProton = proton.begin(); iProton != proton.end(); ++iProton) { // ---> p-eta' femtoscopy + + float kstar = getkstar(*ietaprime, *iProton); + + mHistManager.fill(HIST("etaprimep/fSE_particle_EMC"), kstar); + mHistManager.fill(HIST("etaprimep/fetaprimePtVskstar_EMC"), kstar, (*ietaprime).Pt()); + mHistManager.fill(HIST("etaprimep/fpPtVskstar_EMC"), kstar, (*iProton).Pt()); + mHistManager.fill(HIST("etaprimep/fInvMassVsKStar_EMC"), (*ietaprime).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kEtaPrimeP)) + lowMomentumMultiplets[hnmtrigger::kEtaPrimeP] += 1; + } + for (auto iAntiProton = antiproton.begin(); iAntiProton != antiproton.end(); ++iAntiProton) { // ---> antip-eta' femtoscopy + + float kstar = getkstar(*ietaprime, *iAntiProton); + + mHistManager.fill(HIST("etaprimep/fSE_Antiparticle_EMC"), kstar); + mHistManager.fill(HIST("etaprimep/fetaprimePtVskstar_EMC"), kstar, (*ietaprime).Pt()); + mHistManager.fill(HIST("etaprimep/fAntipPtVskstar_EMC"), kstar, (*iAntiProton).Pt()); + mHistManager.fill(HIST("etaprimep/fInvMassVsKStar_EMC"), (*ietaprime).M(), kstar); + + if (kstar < cfgKinematicLimits->get(static_cast(0), hnmtrigger::kEtaPrimeP)) + lowMomentumMultiplets[hnmtrigger::kEtaPrimeP] += 1; + } + } + } + + // -----------------------------> Create femto tags <----------------------------------- + // - Set keepFemtoEvent flags for each HNM type based on the lowMomentumMultiplets + // - Fill histograms for the multiplicity and z-vertex of femto-accepted events + // ------------------------------------------------------------------------------------- + if (lowMomentumMultiplets[hnmtrigger::kPPOmega] > 0) { + keepFemtoEvent[hnmtrigger::kPPOmega] = true; + mHistManager.fill(HIST("fProcessedEvents"), 6); + mHistManager.fill(HIST("ppomega/fMultiplicity"), collision.multNTracksPV()); + mHistManager.fill(HIST("ppomega/fZvtx"), collision.posZ()); + } + if (lowMomentumMultiplets[hnmtrigger::kPPEtaPrime] > 0) { + keepFemtoEvent[hnmtrigger::kPPEtaPrime] = true; + mHistManager.fill(HIST("fProcessedEvents"), 7); + mHistManager.fill(HIST("ppetaprime/fMultiplicity"), collision.multNTracksPV()); + mHistManager.fill(HIST("ppetaprime/fZvtx"), collision.posZ()); + } + if (lowMomentumMultiplets[hnmtrigger::kOmegaD] > 0) { + keepFemtoEvent[hnmtrigger::kOmegaD] = true; + mHistManager.fill(HIST("fProcessedEvents"), 8); + mHistManager.fill(HIST("omegad/fMultiplicity"), collision.multNTracksPV()); + mHistManager.fill(HIST("omegad/fZvtx"), collision.posZ()); + } + if (lowMomentumMultiplets[hnmtrigger::kEtaPrimeD] > 0) { + keepFemtoEvent[hnmtrigger::kEtaPrimeD] = true; + mHistManager.fill(HIST("fProcessedEvents"), 9); + mHistManager.fill(HIST("etaprimed/fMultiplicity"), collision.multNTracksPV()); + mHistManager.fill(HIST("etaprimed/fZvtx"), collision.posZ()); + } + if (lowMomentumMultiplets[hnmtrigger::kOmegaP] > 0) { + keepFemtoEvent[hnmtrigger::kOmegaP] = true; + mHistManager.fill(HIST("fProcessedEvents"), 10); + mHistManager.fill(HIST("omegap/fMultiplicity"), collision.multNTracksPV()); + mHistManager.fill(HIST("omegap/fZvtx"), collision.posZ()); + } + if (lowMomentumMultiplets[hnmtrigger::kEtaPrimeP] > 0) { + keepFemtoEvent[hnmtrigger::kEtaPrimeP] = true; + mHistManager.fill(HIST("fProcessedEvents"), 11); + mHistManager.fill(HIST("etaprimep/fMultiplicity"), collision.multNTracksPV()); + mHistManager.fill(HIST("etaprimep/fZvtx"), collision.posZ()); + } + + // -----------------------------> Set trigger flags <----------------------------------- + // - 4 high pT spectrum trigger flags (PCM & EMC * omega & eta') + // - 4 femto trigger flags (p-omega, p-eta', d-omega || pp-omega, d-eta' || pp-eta') + // ------------------------------------------------------------------------------------- + tags(keepFemtoEvent[hnmtrigger::kOmegaP], keepFemtoEvent[hnmtrigger::kPPOmega], keepFemtoEvent[hnmtrigger::kOmegaD], keepFemtoEvent[hnmtrigger::kEtaPrimeP], keepFemtoEvent[hnmtrigger::kPPEtaPrime], keepFemtoEvent[hnmtrigger::kEtaPrimeD]); + // tags(colContainsPCMOmega, colContainsEMCOmega, colContainsPCMEtaPrime, colContainsEMCEtaPrime, keepFemtoEvent[hnmtrigger::kOmegaP], keepFemtoEvent[hnmtrigger::kEtaPrimeP], + // keepFemtoEvent[hnmtrigger::kPPOmega] || keepFemtoEvent[hnmtrigger::kOmegaD], keepFemtoEvent[hnmtrigger::kPPEtaPrime] || keepFemtoEvent[hnmtrigger::kEtaPrimeD]); + + if (!keepFemtoEvent[hnmtrigger::kPPOmega] && !keepFemtoEvent[hnmtrigger::kOmegaP] && !keepFemtoEvent[hnmtrigger::kPPEtaPrime] && !keepFemtoEvent[hnmtrigger::kEtaPrimeP] && !keepFemtoEvent[hnmtrigger::kOmegaD] && !keepFemtoEvent[hnmtrigger::kEtaPrimeD]) + mHistManager.fill(HIST("fProcessedEvents"), 1); // Fill "rejected", if no trigger selected the event + } + + /// \brief Loop over the GG candidates, fill the mass/pt histograms and set the isPi0/isEta flags based on the reconstructed mass + void processGGs(std::vector& vGGs) + { + int nGGsBeforeMassCuts = vGGs.size(); + for (unsigned int iGG = 0; iGG < vGGs.size(); iGG++) { + auto lightMeson = &vGGs.at(iGG); + + if (lightMeson->reconstructionType == photonpair::kPCMPCM) { + mHistManager.fill(HIST("GG/invMassVsPt_PCM"), lightMeson->m(), lightMeson->pT()); + } else if (lightMeson->reconstructionType == photonpair::kEMCEMC) { + mHistManager.fill(HIST("GG/invMassVsPt_EMC"), lightMeson->m(), lightMeson->pT()); + } else { + mHistManager.fill(HIST("GG/invMassVsPt_PCMEMC"), lightMeson->m(), lightMeson->pT()); + } + + if (lightMeson->m() > cfgMassWindowOmega->get("pi0_min") && lightMeson->m() < cfgMassWindowOmega->get("pi0_max")) { + lightMeson->isPi0 = true; + } else if (lightMeson->m() > cfgMassWindowEtaPrime->get("eta_min") && lightMeson->m() < cfgMassWindowEtaPrime->get("eta_max")) { + lightMeson->isEta = true; + } else { + vGGs.erase(vGGs.begin() + iGG); + iGG--; + } + } + mHistManager.fill(HIST("Event/nGGs"), nGGsBeforeMassCuts, vGGs.size()); + } + + /// \brief Loop over the heavy neutral meson candidates, fill the mass/pt histograms and set the trigger flags based on the reconstructed mass + void processHNMs(std::vector& vHNMs) + { + int nHNMsBeforeMassCuts = vHNMs.size(); + + for (unsigned int iHNM = 0; iHNM < vHNMs.size(); iHNM++) { + auto heavyNeutralMeson = vHNMs.at(iHNM); + float massHNM = heavyNeutralMeson.m(cfgHNMMassCorrection); + + if (heavyNeutralMeson.gg->reconstructionType == photonpair::kPCMPCM) { + if (heavyNeutralMeson.gg->isPi0) { + mHistManager.fill(HIST("HNM/Before/Omega/PCM/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/Omega/PCM/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/Omega/PCM/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } else if (heavyNeutralMeson.gg->isEta) { + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCM/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCM/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCM/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + } else if (heavyNeutralMeson.gg->reconstructionType == photonpair::kEMCEMC) { + if (heavyNeutralMeson.gg->isPi0) { + mHistManager.fill(HIST("HNM/Before/Omega/EMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/Omega/EMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/Omega/EMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } else if (heavyNeutralMeson.gg->isEta) { + mHistManager.fill(HIST("HNM/Before/EtaPrime/EMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/EMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/EMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + } else { + if (heavyNeutralMeson.gg->isPi0) { + mHistManager.fill(HIST("HNM/Before/Omega/PCMEMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/Omega/PCMEMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/Omega/PCMEMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } else if (heavyNeutralMeson.gg->isEta) { + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCMEMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCMEMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCMEMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + } + + if (heavyNeutralMeson.gg->isPi0 && massHNM > cfgMassWindowOmega->get("omega_min") && massHNM < cfgMassWindowOmega->get("omega_max")) { + if (heavyNeutralMeson.gg->reconstructionType == photonpair::kPCMPCM) { + if (heavyNeutralMeson.pT() > cfgMinHNMPtsFemtoTrigger->get("PCM_omega")) { + omegaPCM.emplace_back(heavyNeutralMeson.pT(), heavyNeutralMeson.eta(), RecoDecay::constrainAngle(heavyNeutralMeson.phi()), massHNM); + mHistManager.fill(HIST("HNM/After/Omega/PCM/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/After/Omega/PCM/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/After/Omega/PCM/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + if (heavyNeutralMeson.pT() > cfgMinHNMPtsSpectrumTrigger->get("PCM_omega")) + colContainsPCMOmega = true; + } else if (heavyNeutralMeson.gg->reconstructionType == photonpair::kEMCEMC) { + if (heavyNeutralMeson.pT() > cfgMinHNMPtsFemtoTrigger->get("EMC_omega")) { + omegaEMC.emplace_back(heavyNeutralMeson.pT(), heavyNeutralMeson.eta(), RecoDecay::constrainAngle(heavyNeutralMeson.phi()), massHNM); + mHistManager.fill(HIST("HNM/After/Omega/EMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/After/Omega/EMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/After/Omega/EMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + if (heavyNeutralMeson.pT() > cfgMinHNMPtsSpectrumTrigger->get("EMC_omega")) + colContainsEMCOmega = true; + } + } else if (heavyNeutralMeson.gg->isEta && massHNM > cfgMassWindowEtaPrime->get("etaprime_min") && massHNM < cfgMassWindowEtaPrime->get("etaprime_max")) { + if (heavyNeutralMeson.gg->reconstructionType == photonpair::kPCMPCM) { + if (heavyNeutralMeson.pT() > cfgMinHNMPtsFemtoTrigger->get("PCM_etaprime")) { + etaPrimePCM.emplace_back(heavyNeutralMeson.pT(), heavyNeutralMeson.eta(), RecoDecay::constrainAngle(heavyNeutralMeson.phi()), massHNM); + mHistManager.fill(HIST("HNM/After/EtaPrime/PCM/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/After/EtaPrime/PCM/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/After/EtaPrime/PCM/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + if (heavyNeutralMeson.pT() > cfgMinHNMPtsSpectrumTrigger->get("PCM_etaprime")) + colContainsPCMEtaPrime = true; + } else if (heavyNeutralMeson.gg->reconstructionType == photonpair::kEMCEMC) { + if (heavyNeutralMeson.pT() > cfgMinHNMPtsFemtoTrigger->get("EMC_etaprime")) { + etaPrimeEMC.emplace_back(heavyNeutralMeson.pT(), heavyNeutralMeson.eta(), RecoDecay::constrainAngle(heavyNeutralMeson.phi()), massHNM); + mHistManager.fill(HIST("HNM/After/EtaPrime/EMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/After/EtaPrime/EMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/After/EtaPrime/EMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + if (heavyNeutralMeson.pT() > cfgMinHNMPtsSpectrumTrigger->get("EMC_etaprime")) + colContainsEMCEtaPrime = true; + } + } else { + vHNMs.erase(vHNMs.begin() + iHNM); + iHNM--; + } + } + mHistManager.fill(HIST("Event/nHeavyNeutralMesons"), nHNMsBeforeMassCuts, vHNMs.size()); + + if (colContainsPCMOmega) + mHistManager.fill(HIST("fProcessedEvents"), 2); + if (colContainsEMCOmega) + mHistManager.fill(HIST("fProcessedEvents"), 3); + if (colContainsPCMEtaPrime) + mHistManager.fill(HIST("fProcessedEvents"), 4); + if (colContainsEMCEtaPrime) + mHistManager.fill(HIST("fProcessedEvents"), 5); + } +}; + +WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/EventFiltering/PWGHF/HFFilter.cxx b/EventFiltering/PWGHF/HFFilter.cxx index 02a88ec2f47..ed03e983d04 100644 --- a/EventFiltering/PWGHF/HFFilter.cxx +++ b/EventFiltering/PWGHF/HFFilter.cxx @@ -8,7 +8,6 @@ // 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 includes /// \file HFFilter.cxx /// \brief task for selection of events with HF signals @@ -18,40 +17,66 @@ /// \author Alexandre Bigot , Strasbourg University /// \author Biao Zhang , CCNU /// \author Federica Zanone , Heidelberg University +/// \author Antonio Palasciano , INFN Bari -#include -#include -#include -#include - -#include "TRandom3.h" - -#include "CommonConstants/PhysicsConstants.h" -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DCAFitter/DCAFitterN.h" -#include "DetectorsBase/Propagator.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" +#include "EventFiltering/PWGHF/HFFilterHelpers.h" +#include "EventFiltering/filterTables.h" +// +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +// +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/CollisionAssociationTables.h" #include "Common/DataModel/EventSelection.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include -#include "EventFiltering/filterTables.h" -#include "EventFiltering/PWGHF/HFFilterHelpers.h" -#include "PWGHF/Utils/utilsTrkCandHf.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; +using namespace o2::soa; using namespace o2::analysis; using namespace o2::aod::hffilters; using namespace o2::framework; @@ -66,70 +91,73 @@ struct HfFilter { // Main struct for HF triggers Produces optimisationTreeCollisions; Configurable activateQA{"activateQA", 0, "flag to enable QA histos (0 no QA, 1 basic QA, 2 extended QA, 3 very extended QA)"}; - Configurable applyEventSelection{"applyEventSelection", true, "flag to enable event selection (sel8 + Zvt and possibly time-frame border cut)"}; Configurable activateSecVtxForB{"activateSecVtxForB", false, "flag to enable 2nd vertex fitting - only beauty hadrons"}; // parameters for all triggers // nsigma PID (except for V0 and cascades) - Configurable> nSigmaPidCuts{"nSigmaPidCuts", {cutsNsigma[0], 3, 7, labelsRowsNsigma, labelsColumnsNsigma}, "Nsigma cuts for TPC/TOF PID (except for V0 and cascades)"}; + Configurable> nSigmaPidCuts{"nSigmaPidCuts", {cutsNsigma[0], 4, 8, labelsRowsNsigma, labelsColumnsNsigma}, "Nsigma cuts for ITS/TPC/TOF PID (except for V0 and cascades)"}; // min and max pts for tracks and bachelors (except for V0 and cascades) - Configurable> ptCuts{"ptCuts", {cutsPt[0], 2, 7, labelsRowsCutsPt, labelsColumnsCutsPt}, "minimum and maximum pT for bachelor tracks (except for V0 and cascades)"}; - + Configurable> ptCuts{"ptCuts", {cutsPt[0], 2, 10, labelsRowsCutsPt, labelsColumnsCutsPt}, "minimum and maximum pT for bachelor tracks (except for V0 and cascades)"}; + Configurable> trackQaulityCuts{"trackQaulityCuts", {cutsTrackQuality[0], 2, 7, labelsColumnsPtThresholdsForFemto, labelsColumnsTrackQuality}, "Track quality cuts for proton and deuteron)"}; // parameters for high-pT triggers Configurable> ptThresholds{"ptThresholds", {cutsHighPtThresholds[0], 1, 2, labelsEmpty, labelsColumnsHighPtThresholds}, "pT treshold for high pT charm hadron candidates for kHighPt triggers in GeV/c"}; // parameters for beauty triggers Configurable> pTBinsTrack{"pTBinsTrack", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for DCAXY pT-dependent cut"}; - Configurable> cutsTrackBeauty3Prong{"cutsTrackBeauty3Prong", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 3-prong beauty candidates"}; - Configurable> cutsTrackBeauty4Prong{"cutsTrackBeauty4Prong", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 4-prong beauty candidates"}; + Configurable> cutsTrackBeauty3Prong{"cutsTrackBeauty3Prong", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 3-prong beauty candidates"}; + Configurable> cutsTrackBeauty4Prong{"cutsTrackBeauty4Prong", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 4-prong beauty candidates"}; + Configurable> cutsTrackBeautyToJPsi{"cutsTrackBeautyToJPsi", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for beauty->JPsi candidates (not muons)"}; Configurable paramCharmMassShape{"paramCharmMassShape", "2023_pass3", "Parametrisation of charm-hadron mass shape (options: 2023_pass3)"}; Configurable numSigmaDeltaMassCharmHad{"numSigmaDeltaMassCharmHad", 2.5, "Number of sigma for charm-hadron delta mass cut in B and D resonance triggers"}; Configurable> pTBinsBHadron{"pTBinsBHadron", std::vector{hf_trigger_cuts_presel_beauty::vecBinsPt}, "pT bin limits for beauty hadrons preselections"}; - Configurable> cutsBplus{"cutsBplus", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsRowsTopolBeauty}, "B+ candidate selection per pT bin"}; - Configurable> cutsBzeroToDstar{"cutsBzeroToDstar", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsRowsTopolBeauty}, "B0 -> D*+ candidate selection per pT bin"}; - Configurable> cutsBzero{"cutsBzero", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsRowsTopolBeauty}, "B0 candidate selection per pT bin"}; - Configurable> cutsBs{"cutsBs", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsRowsTopolBeauty}, "Bs candidate selection per pT bin"}; - Configurable> cutsLb{"cutsLb", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsRowsTopolBeauty}, "Lb candidate selection per pT bin"}; - Configurable> cutsXib{"cutsXib", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsRowsTopolBeauty}, "Xib candidate selection per pT bin"}; + struct : o2::framework::ConfigurableGroup { + Configurable> cutsBplus{"cutsBplus", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsColumnsTopolBeauty}, "B+ candidate selection per pT bin"}; + Configurable> cutsBzeroToDstar{"cutsBzeroToDstar", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsColumnsTopolBeauty}, "B0 -> D*+ candidate selection per pT bin"}; + Configurable> cutsBzero{"cutsBzero", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsColumnsTopolBeauty}, "B0 candidate selection per pT bin"}; + Configurable> cutsBs{"cutsBs", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsColumnsTopolBeauty}, "Bs candidate selection per pT bin"}; + Configurable> cutsBc{"cutsBc", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsColumnsTopolBeauty}, "Bc candidate selection per pT bin"}; + Configurable> cutsLb{"cutsLb", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsColumnsTopolBeauty}, "Lb candidate selection per pT bin"}; + Configurable> cutsXib{"cutsXib", {hf_trigger_cuts_presel_beauty::cuts[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVars, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsColumnsTopolBeauty}, "Xib candidate selection per pT bin"}; + Configurable> cutsBtoJPsiX{"cutsBtoJPsiX", {hf_trigger_cuts_presel_beauty::cutsBtoJPsi[0], hf_trigger_cuts_presel_beauty::nBinsPt, hf_trigger_cuts_presel_beauty::nCutVarsBtoJPsi, hf_trigger_cuts_presel_beauty::labelsPt, hf_trigger_cuts_presel_beauty::labelsColumnsCutsBeautyToJPsi}, "B->JPsiX candidate selection"}; + } cutsBtoHadrons; // parameters for femto triggers Configurable femtoMaxRelativeMomentum{"femtoMaxRelativeMomentum", 2., "Maximal allowed value for relative momentum between charm-proton pairs in GeV/c"}; Configurable> enableFemtoChannels{"enableFemtoChannels", {activeFemtoChannels[0], 2, 5, labelsRowsFemtoChannels, labelsColumnsFemtoChannels}, "Flags to enable/disable femto channels"}; - Configurable requireCharmMassForFemto{"requireCharmMassForFemto", false, "Flags to enable/disable cut on charm-hadron invariant-mass window for femto"}; Configurable> ptThresholdsForFemto{"ptThresholdsForFemto", {cutsPtThresholdsForFemto[0], 1, 2, labelsEmpty, labelsColumnsPtThresholdsForFemto}, "pT treshold for proton or deuteron for kFemto triggers in GeV/c"}; Configurable forceTofProtonForFemto{"forceTofProtonForFemto", true, "flag to force TOF PID for protons"}; Configurable forceTofDeuteronForFemto{"forceTofDeuteronForFemto", false, "flag to force TOF PID for deuterons"}; // double charm - Configurable> enableDoubleCharmChannels{"enableDoubleCharmChannels", {activeDoubleCharmChannels[0], 1, 3, labelsEmpty, labelsColumnsDoubleCharmChannels}, "Flags to enable/disable double charm channels"}; + Configurable> enableDoubleCharmChannels{"enableDoubleCharmChannels", {activeDoubleCharmChannels[0], 2, 3, labelsRowsDoubleCharmChannels, labelsColumnsDoubleCharmChannels}, "Flags to enable/disable double charm channels"}; Configurable keepOnlyDplusForDouble3Prongs{"keepOnlyDplusForDouble3Prongs", false, "Flag to enable/disable to keep only D+ in double charm 3-prongs trigger"}; // parameters for resonance triggers Configurable> cutsGammaK0sLambda{"cutsGammaK0sLambda", {cutsV0s[0], 1, 6, labelsEmpty, labelsColumnsV0s}, "Selections for V0s (gamma, K0s, Lambda) for D+V0 triggers"}; - Configurable> cutsPtDeltaMassCharmReso{"cutsPtDeltaMassCharmReso", {cutsCharmReso[0], 3, 11, labelsRowsDeltaMassCharmReso, labelsColumnsDeltaMassCharmReso}, "pt (GeV/c) and invariant-mass delta (GeV/c2) for charm hadron resonances"}; + Configurable> cutsPtDeltaMassCharmReso{"cutsPtDeltaMassCharmReso", {cutsCharmReso[0], 4, 13, labelsRowsDeltaMassCharmReso, labelsColumnsDeltaMassCharmReso}, "pt (GeV/c) and invariant-mass delta (GeV/c2) for charm hadron resonances"}; Configurable keepAlsoWrongDmesLambdaPairs{"keepAlsoWrongDmesLambdaPairs", true, "flat go keep also wrong sign D+Lambda pairs"}; + Configurable keepAlsoWrongDmesProtonPairs{"keepAlsoWrongDmesProtonPairs", true, "flat go keep also wrong sign D0p pairs"}; + Configurable keepAlsoWrongDstarMesProtonPairs{"keepAlsoWrongDstarMesProtonPairs", true, "flat go keep also wrong sign D*0p pairs"}; // parameters for charm baryons to Xi bachelor Configurable> cutsXiCascades{"cutsXiCascades", {cutsCascades[0], 1, 8, labelsEmpty, labelsColumnsCascades}, "Selections for cascades (Xi) for Xi+bachelor triggers"}; - Configurable> cutsXiBachelor{"cutsXiBachelor", {cutsCharmBaryons[0], 1, 4, labelsEmpty, labelsColumnsCharmBaryons}, "Selections for charm baryons (Xi+Pi and Xi+Ka)"}; - Configurable> cutsTrackCharmBaryonBachelor{"cutsTrackCharmBaryonBachelor", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for charm-baryon bachelor candidates"}; + Configurable> cutsXiBachelor{"cutsXiBachelor", {cutsCharmBaryons[0], 1, 11, labelsEmpty, labelsColumnsCharmBarCuts}, "Selections for charm baryons (Xi+Pi, Xi+Ka, Xi+Pi+Pi)"}; + Configurable> cutsTrackCharmBaryonBachelor{"cutsTrackCharmBaryonBachelor", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for charm-baryon bachelor candidates"}; + Configurable> requireStrangenessTracking{"requireStrangenessTracking", {requireStrangenessTrackedXi[0], 1, 2, labelsEmpty, labelsColumnsCharmBaryons}, "Flags to require strangeness tracking for channels with Xi"}; // parameters for ML application Configurable> pTBinsBDT{"pTBinsBDT", std::vector{hf_cuts_bdt_multiclass::vecBinsPt}, "track pT bin limits for BDT cut"}; - Configurable> thresholdBDTScoreD0ToKPi{"thresholdBDTScoreD0ToKPi", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of D0 candidates"}; - Configurable> thresholdBDTScoreDPlusToPiKPi{"thresholdBDTScoreDPlusToPiKPi", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of D+ candidates"}; - Configurable> thresholdBDTScoreDSToPiKK{"thresholdBDTScoreDSToPiKK", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Ds+ candidates"}; - Configurable> thresholdBDTScoreLcToPiKP{"thresholdBDTScoreLcToPiKP", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Lc+ candidates"}; - Configurable> thresholdBDTScoreXicToPiKP{"thresholdBDTScoreXicToPiKP", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Xic+ candidates"}; + Configurable> thresholdBDTScoreD0ToKPi{"thresholdBDTScoreD0ToKPi", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of D0 candidates"}; + Configurable> thresholdBDTScoreDPlusToPiKPi{"thresholdBDTScoreDPlusToPiKPi", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of D+ candidates"}; + Configurable> thresholdBDTScoreDSToPiKK{"thresholdBDTScoreDSToPiKK", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Ds+ candidates"}; + Configurable> thresholdBDTScoreLcToPiKP{"thresholdBDTScoreLcToPiKP", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Lc+ candidates"}; + Configurable> thresholdBDTScoreXicToPiKP{"thresholdBDTScoreXicToPiKP", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Xic+ candidates"}; Configurable acceptBdtBkgOnly{"acceptBdtBkgOnly", true, "Enable / disable selection based on BDT bkg score only"}; // CCDB configuration - o2::ccdb::CcdbApi ccdbApi; - Service ccdb; Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - int currentRun{0}; // needed to detect if the run changed and trigger update of calibrations etc. // TPC PID calibrations Configurable setTPCCalib{"setTPCCalib", 0, "0 is not use re-calibrations, 1 is compute TPC post-calibrated n-sigmas, 2 is using TPC Spline"}; @@ -139,7 +167,7 @@ struct HfFilter { // Main struct for HF triggers Configurable ccdbBBAntiPion{"ccdbBBAntiPion", "Users/l/lserksny/PIDAntiPion", "Path to the CCDB ocject for antiPion BB param"}; Configurable ccdbBBKaon{"ccdbBBKaon", "Users/l/lserksny/PIDPion", "Path to the CCDB ocject for Kaon BB param"}; Configurable ccdbBBAntiKaon{"ccdbBBAntiKaon", "Users/l/lserksny/PIDAntiPion", "Path to the CCDB ocject for antiKaon BB param"}; - Configurable ccdbPathTPC{"ccdbPathTPC", "Users/i/iarsene/Calib/TPCpostCalib", "base path to the CCDB object"}; + Configurable ccdbPathTPC{"ccdbPathTPC", "Users/i/iarsene/Calib/TPCpostCalib", "base path to the CCDB object"}; // parameter for Optimisation Tree Configurable applyOptimisation{"applyOptimisation", false, "Flag to enable or disable optimisation"}; @@ -148,16 +176,37 @@ struct HfFilter { // Main struct for HF triggers Configurable applyDownscale{"applyDownscale", false, "Flag to enable or disable the application of downscale factors"}; Configurable> downscaleFactors{"downscaleFactors", {defDownscaleFactors[0], kNtriggersHF, 1, hfTriggerNames, labelsDownscaleFactor}, "Downscale factors for each trigger (from 0 to 1)"}; + Service ccdb; + + using BigTracksMCPID = soa::Join; + using BigTracksPID = soa::Join; + using TracksIUPID = soa::Join; + using CollsWithEvSel = soa::Join; + + using Hf2ProngsWithMl = soa::Join; + using Hf3ProngsWithMl = soa::Join; + + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + Preslice v0sPerCollision = aod::v0::collisionId; + Preslice hf2ProngPerCollision = aod::track_association::collisionId; + Preslice hf3ProngPerCollision = aod::track_association::collisionId; + Preslice cascPerCollision = aod::cascade::collisionId; + Preslice photonsPerCollision = aod::v0photonkf::collisionId; + PresliceUnsorted trackedCascadesPerCollision = aod::track::collisionId; + + o2::ccdb::CcdbApi ccdbApi; + int currentRun{0}; // needed to detect if the run changed and trigger update of calibrations etc. + // array of BDT thresholds std::array, kNCharmParticles> thresholdBDTScores; - o2::vertexing::DCAFitterN<2> df2; // fitter for Charm Hadron vertex (2-prong vertex fitter) - o2::vertexing::DCAFitterN<3> df3; // fitter for Charm Hadron vertex (3-prong vertex fitter) - o2::vertexing::DCAFitterN<2> dfB; // fitter for Beauty Hadron vertex (2-prong vertex fitter) - o2::vertexing::DCAFitterN<3> dfBtoDstar; // fitter for Beauty Hadron to D* vertex (3-prong vertex fitter) + o2::vertexing::DCAFitterN<2> df2; // fitter for Charm Hadron vertex (2-prong vertex fitter) + o2::vertexing::DCAFitterN<3> df3; // fitter for Charm/Beauty Hadron vertex (3-prong vertex fitter) + o2::vertexing::DCAFitterN<4> df4; // fitter for Beauty Hadron vertex (4-prong vertex fitter) + o2::vertexing::DCAFitterN<2> dfB; // fitter for Beauty Hadron vertex (2-prong vertex fitter) + o2::vertexing::DCAFitterN<3> dfBtoDstar; // fitter for Beauty Hadron to D* vertex (3-prong vertex fitter) o2::vertexing::DCAFitterN<2> dfStrangeness; // fitter for V0s and cascades (2-prong vertex fitter) - HistogramRegistry registry{"registry"}; std::shared_ptr hProcessedEvents; // QA histos @@ -165,16 +214,15 @@ struct HfFilter { // Main struct for HF triggers std::array, kNCharmParticles> hCharmHighPt{}; std::array, kNCharmParticles> hCharmProtonKstarDistr{}; std::array, kNCharmParticles> hCharmDeuteronKstarDistr{}; - std::array, kNBeautyParticles> hMassVsPtB{}; - std::array, kNCharmParticles + 17> hMassVsPtC{}; // +9 for resonances (D*+, D*0, Ds*+, Ds1+, Ds2*+, Xic+* right sign, Xic+* wrong sign, Xic0* right sign, Xic0* wrong sign) +2 for SigmaC (SigmaC++, SigmaC0) +2 for SigmaCK pairs (SigmaC++K-, SigmaC0K0s) +2 for charm baryons (Xi+Pi, Xi+Ka) - std::shared_ptr hProtonTPCPID, hProtonTOFPID; - std::shared_ptr hDeuteronTPCPID, hDeuteronTOFPID; + std::array, nTotBeautyParts> hMassVsPtB{}; + std::array, kNCharmParticles + 23> hMassVsPtC{}; // +9 for resonances (D*+, D*0, Ds*+, Ds1+, Ds2*+, Xic+* right sign, Xic+* wrong sign, Xic0* right sign, Xic0* wrong sign) +2 for SigmaC (SigmaC++, SigmaC0) +2 for SigmaCK pairs (SigmaC++K-, SigmaC0K0s) +3 for charm baryons (Xi+Pi, Xi+Ka, Xi+Pi+Pi) + JPsi + 4 for charm baryons (D0+p, D0+pWrongSign, D*0p, D*0+pWrongSign) + std::array, 4> hPrDePID; // proton TPC, proton TOF, deuteron TPC, deuteron TOF std::array, kNCharmParticles> hBDTScoreBkg{}; std::array, kNCharmParticles> hBDTScorePrompt{}; std::array, kNCharmParticles> hBDTScoreNonPrompt{}; std::array, kNV0> hArmPod{}; std::shared_ptr hV0Selected; - std::shared_ptr hMassXi; + std::array, 2> hMassXi{}; // not tracked and tracked std::array, kNBeautyParticles> hCpaVsPtB{}; std::array, kNBeautyParticles> hDecayLengthVsPtB{}; std::array, kNBeautyParticles> hImpactParamProductVsPtB{}; @@ -187,28 +235,36 @@ struct HfFilter { // Main struct for HF triggers // helper object HfFilterHelper helper; - void init(InitContext&) + HistogramRegistry registry{"registry"}; + + void init(InitContext& initContext) { helper.setHighPtTriggerThresholds(ptThresholds->get(0u, 0u), ptThresholds->get(0u, 1u)); helper.setPtTriggerThresholdsForFemto(ptThresholdsForFemto->get(0u, 0u), ptThresholdsForFemto->get(0u, 1u)); helper.setPtBinsSingleTracks(pTBinsTrack); helper.setPtBinsBeautyHadrons(pTBinsBHadron); - helper.setPtLimitsBeautyBachelor(ptCuts->get(0u, 0u), ptCuts->get(1u, 0u)); + helper.setPtLimitsBeautyBachelor(ptCuts->get(0u, 0u), ptCuts->get(1u, 0u), ptCuts->get(0u, 7u), ptCuts->get(1u, 7u)); helper.setPtLimitsDstarSoftPion(ptCuts->get(0u, 1u), ptCuts->get(1u, 1u)); helper.setPtLimitsProtonForFemto(ptCuts->get(0u, 2u), ptCuts->get(1u, 2u)); helper.setPtLimitsDeuteronForFemto(ptCuts->get(0u, 6u), ptCuts->get(1u, 6u)); helper.setPtLimitsCharmBaryonBachelor(ptCuts->get(0u, 3u), ptCuts->get(1u, 3u)); - helper.setCutsSingleTrackBeauty(cutsTrackBeauty3Prong, cutsTrackBeauty4Prong); + helper.setPtLimitsLcResonanceBachelor(ptCuts->get(0u, 8u), ptCuts->get(1u, 8u)); + helper.setPtLimitsThetaCBachelor(ptCuts->get(0u, 9u), ptCuts->get(1u, 9u)); + helper.setCutsSingleTrackBeauty(cutsTrackBeauty3Prong, cutsTrackBeauty4Prong, cutsTrackBeauty4Prong); helper.setCutsSingleTrackCharmBaryonBachelor(cutsTrackCharmBaryonBachelor); - helper.setCutsBhadrons(cutsBplus, cutsBzeroToDstar, cutsBzero, cutsBs, cutsLb, cutsXib); - helper.setNsigmaProtonCutsForFemto(std::array{nSigmaPidCuts->get(0u, 3u), nSigmaPidCuts->get(1u, 3u), nSigmaPidCuts->get(2u, 3u)}); - helper.setNsigmaDeuteronCutsForFemto(std::array{nSigmaPidCuts->get(0u, 6u), nSigmaPidCuts->get(1u, 6u), nSigmaPidCuts->get(2u, 6u)}); + helper.setCutsBhadrons(cutsBtoHadrons.cutsBplus, cutsBtoHadrons.cutsBzeroToDstar, cutsBtoHadrons.cutsBc, cutsBtoHadrons.cutsBzero, cutsBtoHadrons.cutsBs, cutsBtoHadrons.cutsLb, cutsBtoHadrons.cutsXib); + helper.setCutsBtoJPsi(cutsBtoHadrons.cutsBtoJPsiX); + helper.setNsigmaProtonCutsForFemto(std::array{nSigmaPidCuts->get(0u, 3u), nSigmaPidCuts->get(1u, 3u), nSigmaPidCuts->get(2u, 3u), nSigmaPidCuts->get(3u, 3u)}); + helper.setNsigmaDeuteronCutsForFemto(std::array{nSigmaPidCuts->get(0u, 6u), nSigmaPidCuts->get(1u, 6u), nSigmaPidCuts->get(2u, 6u), nSigmaPidCuts->get(3u, 6u)}); + helper.setDeuteronTrackSelectionForFemto(trackQaulityCuts->get(1u, 0u), trackQaulityCuts->get(1u, 1u), trackQaulityCuts->get(1u, 2u), trackQaulityCuts->get(1u, 3u), trackQaulityCuts->get(1u, 4u), trackQaulityCuts->get(1u, 5u), trackQaulityCuts->get(1u, 6u)); helper.setNsigmaProtonCutsForCharmBaryons(nSigmaPidCuts->get(0u, 0u), nSigmaPidCuts->get(1u, 0u)); helper.setNsigmaPionKaonCutsForDzero(nSigmaPidCuts->get(0u, 1u), nSigmaPidCuts->get(1u, 1u)); helper.setNsigmaKaonCutsFor3Prongs(nSigmaPidCuts->get(0u, 2u), nSigmaPidCuts->get(1u, 2u)); + helper.setNsigmaKaonProtonCutsForBeautyToJPsi(nSigmaPidCuts->get(0u, 7u), nSigmaPidCuts->get(1u, 7u)); helper.setForceTofForFemto(forceTofProtonForFemto, forceTofDeuteronForFemto); helper.setV0Selections(cutsGammaK0sLambda->get(0u, 0u), cutsGammaK0sLambda->get(0u, 1u), cutsGammaK0sLambda->get(0u, 2u), cutsGammaK0sLambda->get(0u, 3u), cutsGammaK0sLambda->get(0u, 4u), cutsGammaK0sLambda->get(0u, 5u)); helper.setXiSelections(cutsXiCascades->get(0u, 0u), cutsXiCascades->get(0u, 1u), cutsXiCascades->get(0u, 2u), cutsXiCascades->get(0u, 3u), cutsXiCascades->get(0u, 4u), cutsXiCascades->get(0u, 5u), cutsXiCascades->get(0u, 6u), cutsXiCascades->get(0u, 7u)); + helper.setXiBachelorSelections(cutsXiBachelor->get(0u, 0u), cutsXiBachelor->get(0u, 1u), cutsXiBachelor->get(0u, 2u), cutsXiBachelor->get(0u, 3u), cutsXiBachelor->get(0u, 4u), cutsXiBachelor->get(0u, 5u), cutsXiBachelor->get(0u, 6u), cutsXiBachelor->get(0u, 7u), cutsXiBachelor->get(0u, 8u), cutsXiBachelor->get(0u, 9u), cutsXiBachelor->get(0u, 10u)); helper.setNsigmaPiCutsForCharmBaryonBachelor(nSigmaPidCuts->get(0u, 4u), nSigmaPidCuts->get(1u, 4u)); helper.setTpcPidCalibrationOption(setTPCCalib); helper.setMassResolParametrisation(paramCharmMassShape); @@ -218,13 +274,39 @@ struct HfFilter { // Main struct for HF triggers helper.setPtRangeSoftKaonXicResoToSigmaC(ptCuts->get(0u, 5u), ptCuts->get(1u, 5u)); helper.setVtxConfiguration(dfStrangeness, true); // (DCAFitterN, useAbsDCA) dfStrangeness.setMatCorrType(matCorr); + helper.setVtxConfiguration(df2, false); // (DCAFitterN, useAbsDCA) + helper.setVtxConfiguration(df3, false); + helper.setVtxConfiguration(df4, false); if (activateSecVtxForB) { - helper.setVtxConfiguration(df2, false); // (DCAFitterN, useAbsDCA) - helper.setVtxConfiguration(df3, false); helper.setVtxConfiguration(dfB, true); helper.setVtxConfiguration(dfBtoDstar, true); } - hProcessedEvents = registry.add("fProcessedEvents", "HF - event filtered;;counts", HistType::kTH1F, {{kNtriggersHF + 2, -0.5, +kNtriggersHF + 1.5}}); + + // fetch config of track-index-skim-creator to apply the same cut on DeltaMassKK for Ds + std::vector ptBinsDsSkimCreator{}; + LabeledArray cutsDsSkimCreator{}; + const auto& workflows = initContext.services().get(); + for (const DeviceSpec& device : workflows.devices) { + if (device.name.compare("hf-track-index-skim-creator") == 0) { + for (const auto& option : device.options) { + if (option.name.compare("binsPtDsToKKPi") == 0) { + auto ptBins = option.defaultValue.get(); + double lastEl{-1.e6}; + int iPt{0}; + while (ptBins[iPt] > lastEl) { + ptBinsDsSkimCreator.push_back(ptBins[iPt]); + lastEl = ptBins[iPt]; + iPt++; + } + } else if (option.name.compare("cutsDsToKKPi") == 0) { + cutsDsSkimCreator = option.defaultValue.get>(); + } + } + } + } + helper.setPreselDsToKKPi(ptBinsDsSkimCreator, cutsDsSkimCreator); + + hProcessedEvents = registry.add("fProcessedEvents", "HF - event filtered;;counts", HistType::kTH1D, {{kNtriggersHF + 2, -0.5, +kNtriggersHF + 1.5}}); for (auto iBin = 0; iBin < kNtriggersHF + 2; ++iBin) { if (iBin < 2) hProcessedEvents->GetXaxis()->SetBinLabel(iBin + 1, eventTitles[iBin].data()); @@ -233,56 +315,68 @@ struct HfFilter { // Main struct for HF triggers } if (activateQA) { - hN2ProngCharmCand = registry.add("fN2ProngCharmCand", "Number of 2-prong charm candidates per event;#it{N}_{candidates};counts", HistType::kTH1F, {{50, -0.5, 49.5}}); - hN3ProngCharmCand = registry.add("fN3ProngCharmCand", "Number of 3-prong charm candidates per event;#it{N}_{candidates};counts", HistType::kTH1F, {{50, -0.5, 49.5}}); + hN2ProngCharmCand = registry.add("fN2ProngCharmCand", "Number of 2-prong charm candidates per event;#it{N}_{candidates};counts", HistType::kTH1D, {{50, -0.5, 49.5}}); + hN3ProngCharmCand = registry.add("fN3ProngCharmCand", "Number of 3-prong charm candidates per event;#it{N}_{candidates};counts", HistType::kTH1D, {{50, -0.5, 49.5}}); for (int iCharmPart{0}; iCharmPart < kNCharmParticles; ++iCharmPart) { - hCharmHighPt[iCharmPart] = registry.add(Form("f%sHighPt", charmParticleNames[iCharmPart].data()), Form("#it{p}_{T} distribution of triggered high-#it{p}_{T} %s candidates;#it{p}_{T} (GeV/#it{c});counts", charmParticleNames[iCharmPart].data()), HistType::kTH1F, {ptAxis}); - hCharmProtonKstarDistr[iCharmPart] = registry.add(Form("f%sProtonKstarDistr", charmParticleNames[iCharmPart].data()), Form("#it{k}* distribution of triggered p#minus%s pairs;#it{k}* (GeV/#it{c});counts", charmParticleNames[iCharmPart].data()), HistType::kTH1F, {kstarAxis}); - hCharmDeuteronKstarDistr[iCharmPart] = registry.add(Form("f%sDeuteronKstarDistr", charmParticleNames[iCharmPart].data()), Form("#it{k}* distribution of triggered de%s pairs;#it{k}* (GeV/#it{c});counts", charmParticleNames[iCharmPart].data()), HistType::kTH1F, {kstarAxis}); - hMassVsPtC[iCharmPart] = registry.add(Form("fMassVsPt%s", charmParticleNames[iCharmPart].data()), Form("#it{M} vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", charmParticleNames[iCharmPart].data()), HistType::kTH2F, {ptAxis, massAxisC[iCharmPart]}); + hCharmHighPt[iCharmPart] = registry.add(Form("f%sHighPt", charmParticleNames[iCharmPart].data()), Form("#it{p}_{T} distribution of triggered high-#it{p}_{T} %s candidates;#it{p}_{T} (GeV/#it{c});counts", charmParticleNames[iCharmPart].data()), HistType::kTH1D, {ptAxis}); + hCharmProtonKstarDistr[iCharmPart] = registry.add(Form("f%sProtonKstarDistr", charmParticleNames[iCharmPart].data()), Form("#it{k}* distribution of triggered p#minus%s pairs;#it{k}* (GeV/#it{c});counts", charmParticleNames[iCharmPart].data()), HistType::kTH1D, {kstarAxis}); + hCharmDeuteronKstarDistr[iCharmPart] = registry.add(Form("f%sDeuteronKstarDistr", charmParticleNames[iCharmPart].data()), Form("#it{k}* distribution of triggered de%s pairs;#it{k}* (GeV/#it{c});counts", charmParticleNames[iCharmPart].data()), HistType::kTH1D, {kstarAxis}); + hMassVsPtC[iCharmPart] = registry.add(Form("fMassVsPt%s", charmParticleNames[iCharmPart].data()), Form("#it{M} vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", charmParticleNames[iCharmPart].data()), HistType::kTH2D, {ptAxis, massAxisC[iCharmPart]}); if (activateQA > 1) { - hBDTScoreBkg[iCharmPart] = registry.add(Form("f%sBDTScoreBkgDistr", charmParticleNames[iCharmPart].data()), Form("BDT background score distribution for %s;BDT background score;counts", charmParticleNames[iCharmPart].data()), HistType::kTH1F, {bdtAxis}); - hBDTScorePrompt[iCharmPart] = registry.add(Form("f%sBDTScorePromptDistr", charmParticleNames[iCharmPart].data()), Form("BDT prompt score distribution for %s;BDT prompt score;counts", charmParticleNames[iCharmPart].data()), HistType::kTH1F, {bdtAxis}); - hBDTScoreNonPrompt[iCharmPart] = registry.add(Form("f%sBDTScoreNonPromptDistr", charmParticleNames[iCharmPart].data()), Form("BDT nonprompt score distribution for %s;BDT nonprompt score;counts", charmParticleNames[iCharmPart].data()), HistType::kTH1F, {bdtAxis}); + hBDTScoreBkg[iCharmPart] = registry.add(Form("f%sBDTScoreBkgDistr", charmParticleNames[iCharmPart].data()), Form("BDT background score distribution for %s;BDT background score;counts", charmParticleNames[iCharmPart].data()), HistType::kTH1D, {bdtAxis}); + hBDTScorePrompt[iCharmPart] = registry.add(Form("f%sBDTScorePromptDistr", charmParticleNames[iCharmPart].data()), Form("BDT prompt score distribution for %s;BDT prompt score;counts", charmParticleNames[iCharmPart].data()), HistType::kTH1D, {bdtAxis}); + hBDTScoreNonPrompt[iCharmPart] = registry.add(Form("f%sBDTScoreNonPromptDistr", charmParticleNames[iCharmPart].data()), Form("BDT nonprompt score distribution for %s;BDT nonprompt score;counts", charmParticleNames[iCharmPart].data()), HistType::kTH1D, {bdtAxis}); } } // charm resonances - hMassVsPtC[kNCharmParticles] = registry.add("fMassVsPtDStarPlus", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered DStarPlus candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles]}); - hMassVsPtC[kNCharmParticles + 1] = registry.add("fMassVsPtDStarZero", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered DStarZero candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 1]}); - hMassVsPtC[kNCharmParticles + 2] = registry.add("fMassVsPtDStarS", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered DStarS candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 2]}); - hMassVsPtC[kNCharmParticles + 3] = registry.add("fMassVsPtDs1Plus", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered Ds1Plus candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 3]}); - hMassVsPtC[kNCharmParticles + 4] = registry.add("fMassVsPtDs2StarPlus", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered Ds2StarPlus candidates;#it{p}_{T} (GeV/#Delta#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 4]}); - hMassVsPtC[kNCharmParticles + 5] = registry.add("fMassVsPtXicStarToDplusLambda", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered XicStar -> Dplus Lambda candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 5]}); - hMassVsPtC[kNCharmParticles + 6] = registry.add("fMassVsPtXicStarToDplusLambdaWrongSign", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered opposite-sign XicStar -> Dplus Lambda candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 6]}); - hMassVsPtC[kNCharmParticles + 7] = registry.add("fMassVsPtXicStarToD0Lambda", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered XicStar -> D0 Lambda candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 7]}); - hMassVsPtC[kNCharmParticles + 8] = registry.add("fMassVsPtXicStarToD0LambdaWrongSign", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered opposite-sign XicStar -> D0 Lambda candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 8]}); + hMassVsPtC[kNCharmParticles] = registry.add("fMassVsPtDStarPlus", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered DStarPlus candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles]}); + hMassVsPtC[kNCharmParticles + 1] = registry.add("fMassVsPtDStarZero", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered DStarZero candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 1]}); + hMassVsPtC[kNCharmParticles + 2] = registry.add("fMassVsPtDStarS", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered DStarS candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 2]}); + hMassVsPtC[kNCharmParticles + 3] = registry.add("fMassVsPtDs1Plus", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered Ds1Plus candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 3]}); + hMassVsPtC[kNCharmParticles + 4] = registry.add("fMassVsPtDs2StarPlus", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered Ds2StarPlus candidates;#it{p}_{T} (GeV/#Delta#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 4]}); + hMassVsPtC[kNCharmParticles + 5] = registry.add("fMassVsPtXicStarToDplusLambda", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered XicStar -> Dplus Lambda candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 5]}); + hMassVsPtC[kNCharmParticles + 6] = registry.add("fMassVsPtXicStarToDplusLambdaWrongSign", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered opposite-sign XicStar -> Dplus Lambda candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 6]}); + hMassVsPtC[kNCharmParticles + 7] = registry.add("fMassVsPtXicStarToD0Lambda", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered XicStar -> D0 Lambda candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 7]}); + hMassVsPtC[kNCharmParticles + 8] = registry.add("fMassVsPtXicStarToD0LambdaWrongSign", "#Delta#it{M} vs. #it{p}_{T} distribution of triggered opposite-sign XicStar -> D0 Lambda candidates;#it{p}_{T} (GeV/#it{c});#Delta#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 8]}); // SigmaC0,++ - hMassVsPtC[kNCharmParticles + 9] = registry.add("fMassVsPtSigmaCPlusPlus", "#it{M}(pK#pi#pi)-M(pK#pi) vs. #it{p}_{T} distribution of #Sigma_{c}^{++} candidates for triggers;#it{p}_{T}(#Sigma_{c}^{++}) (GeV/#it{c});#it{M}(pK#pi#pi)-M(pK#pi);counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 9]}); - hMassVsPtC[kNCharmParticles + 10] = registry.add("fMassVsPtSigmaC0", "#it{M}(pK#pi#pi)-M(pK#pi) vs. #it{p}_{T} distribution of #Sigma_{c}^{0} candidates for triggers;#it{p}_{T}(#Sigma_{c}^{0}) (GeV/#it{c});#it{M}(pK#pi#pi)-M(pK#pi);counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 10]}); + hMassVsPtC[kNCharmParticles + 9] = registry.add("fMassVsPtSigmaCPlusPlus", "#it{M}(pK#pi#pi)-M(pK#pi) vs. #it{p}_{T} distribution of #Sigma_{c}^{++} candidates for triggers;#it{p}_{T}(#Sigma_{c}^{++}) (GeV/#it{c});#it{M}(pK#pi#pi)-M(pK#pi);counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 9]}); + hMassVsPtC[kNCharmParticles + 10] = registry.add("fMassVsPtSigmaC0", "#it{M}(pK#pi#pi)-M(pK#pi) vs. #it{p}_{T} distribution of #Sigma_{c}^{0} candidates for triggers;#it{p}_{T}(#Sigma_{c}^{0}) (GeV/#it{c});#it{M}(pK#pi#pi)-M(pK#pi);counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 10]}); // SigmaCKaon pairs - hMassVsPtC[kNCharmParticles + 11] = registry.add("fMassVsPtSigmaC2455PlusPlusKaMinus", "#it{M}(#Sigma_{c}^{++}K^{-}(2455)) vs. #it{p}_{T} distribution of of triggered #Sigma_{c}^{++}K^{-} pairs;#it{p}_{T} (GeV/#it{c});#it{M}(#Sigma_{c}^{++}K^{-});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 11]}); - hMassVsPtC[kNCharmParticles + 12] = registry.add("fMassVsPtSigmaC2520PlusPlusKaMinus", "#it{M}(#Sigma_{c}^{++}K^{-}(2520)) vs. #it{p}_{T} distribution of of triggered #Sigma_{c}^{++}K^{-} pairs;#it{p}_{T} (GeV/#it{c});#it{M}(#Sigma_{c}^{++}K^{-});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 12]}); - hMassVsPtC[kNCharmParticles + 13] = registry.add("fMassVsPtSigmaC02455Ka0s", "#it{M}(#Sigma_{c}^{0}K^{0}_{s}(2455)) vs. #it{p}_{T} distribution of of triggered #Sigma_{c}^{0}K^{0}_{s} pairs;#it{p}_{T} (GeV/#it{c});#it{M}(#Sigma_{c}^{++}K^{-});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 13]}); - hMassVsPtC[kNCharmParticles + 14] = registry.add("fMassVsPtSigmaC02520Ka0s", "#it{M}(#Sigma_{c}^{0}K^{0}_{s}(2520)) vs. #it{p}_{T} distribution of of triggered #Sigma_{c}^{0}K^{0}_{s} pairs;#it{p}_{T} (GeV/#it{c});#it{M}(#Sigma_{c}^{++}K^{-});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 14]}); + hMassVsPtC[kNCharmParticles + 11] = registry.add("fMassVsPtSigmaC2455PlusPlusKaMinus", "#it{M}(#Sigma_{c}^{++}K^{-}(2455)) vs. #it{p}_{T} distribution of of triggered #Sigma_{c}^{++}K^{-} pairs;#it{p}_{T} (GeV/#it{c});#it{M}(#Sigma_{c}^{++}K^{-});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 11]}); + hMassVsPtC[kNCharmParticles + 12] = registry.add("fMassVsPtSigmaC2520PlusPlusKaMinus", "#it{M}(#Sigma_{c}^{++}K^{-}(2520)) vs. #it{p}_{T} distribution of of triggered #Sigma_{c}^{++}K^{-} pairs;#it{p}_{T} (GeV/#it{c});#it{M}(#Sigma_{c}^{++}K^{-});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 12]}); + hMassVsPtC[kNCharmParticles + 13] = registry.add("fMassVsPtSigmaC02455Ka0s", "#it{M}(#Sigma_{c}^{0}K^{0}_{s}(2455)) vs. #it{p}_{T} distribution of of triggered #Sigma_{c}^{0}K^{0}_{s} pairs;#it{p}_{T} (GeV/#it{c});#it{M}(#Sigma_{c}^{++}K^{-});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 13]}); + hMassVsPtC[kNCharmParticles + 14] = registry.add("fMassVsPtSigmaC02520Ka0s", "#it{M}(#Sigma_{c}^{0}K^{0}_{s}(2520)) vs. #it{p}_{T} distribution of of triggered #Sigma_{c}^{0}K^{0}_{s} pairs;#it{p}_{T} (GeV/#it{c});#it{M}(#Sigma_{c}^{++}K^{-});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 14]}); // charm baryons to LF cascades - hMassVsPtC[kNCharmParticles + 15] = registry.add("fMassVsPtCharmBaryonToXiPi", "#it{M} vs. #it{p}_{T} distribution of triggered #Xi+#pi candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 15]}); - hMassVsPtC[kNCharmParticles + 16] = registry.add("fMassVsPtCharmBaryonToXiKa", "#it{M} vs. #it{p}_{T} distribution of triggered #Xi+K candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2F, {ptAxis, massAxisC[kNCharmParticles + 16]}); + hMassVsPtC[kNCharmParticles + 15] = registry.add("fMassVsPtCharmBaryonToXiPi", "#it{M} vs. #it{p}_{T} distribution of triggered #Xi+#pi candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 15]}); + hMassVsPtC[kNCharmParticles + 16] = registry.add("fMassVsPtCharmBaryonToXiKa", "#it{M} vs. #it{p}_{T} distribution of triggered #Xi+K candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 16]}); + hMassVsPtC[kNCharmParticles + 17] = registry.add("fMassVsPtCharmBaryonToXiPiPi", "#it{M} vs. #it{p}_{T} distribution of triggered #Xi+#pi+#pi candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 17]}); + // JPsi + hMassVsPtC[kNCharmParticles + 18] = registry.add("fMassVsPtJPsiToMuMu", "#it{M} vs. #it{p}_{T} distribution of triggered J/#psi to #mu#mu candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 18]}); + // Lc resonances + hMassVsPtC[kNCharmParticles + 19] = registry.add("fMassVsPtCharmBaryonToD0P", "#it{M} vs. #it{p}_{T} distribution of triggered D^{0}#p candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 19]}); + hMassVsPtC[kNCharmParticles + 20] = registry.add("fMassVsPtCharmBaryonToD0PWrongSign", "#it{M} vs. #it{p}_{T} distribution of triggered D^{0}#p wrong sign candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 20]}); + // ThetaC + hMassVsPtC[kNCharmParticles + 21] = registry.add("fMassVsPtCharmBaryonToDstarP", "#it{M} vs. #it{p}_{T} distribution of triggered D^{*0}#p candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 21]}); + hMassVsPtC[kNCharmParticles + 22] = registry.add("fMassVsPtCharmBaryonToDstarPWrongSign", "#it{M} vs. #it{p}_{T} distribution of triggered D^{*0}#p wrong sign candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", HistType::kTH2D, {ptAxis, massAxisC[kNCharmParticles + 22]}); for (int iBeautyPart{0}; iBeautyPart < kNBeautyParticles; ++iBeautyPart) { - hMassVsPtB[iBeautyPart] = registry.add(Form("fMassVsPt%s", beautyParticleNames[iBeautyPart].data()), Form("#it{M} vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", beautyParticleNames[iBeautyPart].data()), HistType::kTH2F, {ptAxis, massAxisB[iBeautyPart]}); - hCpaVsPtB[iBeautyPart] = registry.add(Form("fCpaVsPt%s", beautyParticleNames[iBeautyPart].data()), Form("CPA vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", beautyParticleNames[iBeautyPart].data()), HistType::kTH2F, {ptAxis, {100, -1, 1}}); - hDecayLengthVsPtB[iBeautyPart] = registry.add(Form("fDecayLengthVsPt%s", beautyParticleNames[iBeautyPart].data()), Form("DecayLength vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", beautyParticleNames[iBeautyPart].data()), HistType::kTH2F, {ptAxis, {100, 0, 20}}); + hMassVsPtB[iBeautyPart] = registry.add(Form("fMassVsPt%s", beautyParticleNames[iBeautyPart].data()), Form("#it{M} vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", beautyParticleNames[iBeautyPart].data()), HistType::kTH2D, {ptAxis, massAxisB[iBeautyPart]}); + hCpaVsPtB[iBeautyPart] = registry.add(Form("fCpaVsPt%s", beautyParticleNames[iBeautyPart].data()), Form("CPA vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", beautyParticleNames[iBeautyPart].data()), HistType::kTH2D, {ptAxis, {500, 0., 1}}); + hDecayLengthVsPtB[iBeautyPart] = registry.add(Form("fDecayLengthVsPt%s", beautyParticleNames[iBeautyPart].data()), Form("DecayLength vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", beautyParticleNames[iBeautyPart].data()), HistType::kTH2D, {ptAxis, {500, 0, 0.5}}); if (iBeautyPart != kB0toDStar) { - hImpactParamProductVsPtB[iBeautyPart] = registry.add(Form("fImpactParamProductVsPt%s", beautyParticleNames[iBeautyPart].data()), Form("ImpactParamProduct vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", beautyParticleNames[iBeautyPart].data()), HistType::kTH2F, {ptAxis, {100, -2.5, +2.5}}); + hImpactParamProductVsPtB[iBeautyPart] = registry.add(Form("fImpactParamProductVsPt%s", beautyParticleNames[iBeautyPart].data()), Form("ImpactParamProduct vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", beautyParticleNames[iBeautyPart].data()), HistType::kTH2D, {ptAxis, {500, -2.5e-3, +2.5e-3}}); } } + for (int iBeautyPart{kNBeautyParticles}; iBeautyPart < nTotBeautyParts; ++iBeautyPart) { + hMassVsPtB[iBeautyPart] = registry.add(Form("fMassVsPt%s", beautyParticleNames[iBeautyPart].data()), Form("#it{M} vs. #it{p}_{T} distribution of triggered %s candidates;#it{p}_{T} (GeV/#it{c});#it{M} (GeV/#it{c}^{2});counts", beautyParticleNames[iBeautyPart].data()), HistType::kTH2D, {ptAxis, massAxisB[iBeautyPart]}); + } constexpr int kNBinsHfVtxStages = kNHfVtxStage; std::string labels[kNBinsHfVtxStages]; labels[HfVtxStage::Skimmed] = "Skimm CharmHad-Pi pairs"; labels[HfVtxStage::BeautyVertex] = "vertex CharmHad-Pi pairs"; labels[HfVtxStage::CharmHadPiSelected] = "selected CharmHad-Pi pairs"; static const AxisSpec axisHfVtxStages = {kNBinsHfVtxStages, 0.5, kNBinsHfVtxStages + 0.5, ""}; - registry.add("fHfVtxStages", "HfVtxStages;;entries", HistType::kTH2F, {axisHfVtxStages, {kNBeautyParticles, -0.5, +kNBeautyParticles - 0.5}}); + registry.add("fHfVtxStages", "HfVtxStages;;entries", HistType::kTH2D, {axisHfVtxStages, {kNBeautyParticles, -0.5, +kNBeautyParticles - 0.5}}); for (int iBin = 0; iBin < kNBinsHfVtxStages; iBin++) { registry.get(HIST("fHfVtxStages"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); } @@ -291,17 +385,18 @@ struct HfFilter { // Main struct for HF triggers } for (int iV0{kPhoton}; iV0 < kNV0; ++iV0) { - hArmPod[iV0] = registry.add(Form("fArmPod%s", v0Names[iV0].data()), Form("Armenteros Podolanski plot for selected %s;#it{#alpha};#it{q}_{T} (GeV/#it{c})", v0Labels[iV0].data()), HistType::kTH2F, {alphaAxis, qtAxis}); + hArmPod[iV0] = registry.add(Form("fArmPod%s", v0Names[iV0].data()), Form("Armenteros Podolanski plot for selected %s;#it{#alpha};#it{q}_{T} (GeV/#it{c})", v0Labels[iV0].data()), HistType::kTH2D, {alphaAxis, qtAxis}); } - hMassXi = registry.add("fMassXi", "#it{M} distribution of #Xi candidates;#it{M} (GeV/#it{c}^{2});counts", HistType::kTH1F, {{100, 1.28f, 1.36f}}); + hMassXi[0] = registry.add("fMassXi", "#it{M} distribution of #Xi candidates;#it{M} (GeV/#it{c}^{2});counts", HistType::kTH1D, {{100, 1.28f, 1.36f}}); + hMassXi[1] = registry.add("fMassTrackedXi", "#it{M} distribution of #Xi candidates;#it{M} (GeV/#it{c}^{2});counts", HistType::kTH1D, {{100, 1.28f, 1.36f}}); if (activateQA > 1) { - hProtonTPCPID = registry.add("fProtonTPCPID", "#it{N}_{#sigma}^{TPC} vs. #it{p} for selected protons;#it{p} (GeV/#it{c});#it{N}_{#sigma}^{TPC}", HistType::kTH2F, {pAxis, nSigmaAxis}); - hProtonTOFPID = registry.add("fProtonTOFPID", "#it{N}_{#sigma}^{TOF} vs. #it{p} for selected protons;#it{p} (GeV/#it{c});#it{N}_{#sigma}^{TOF}", HistType::kTH2F, {pAxis, nSigmaAxis}); - hDeuteronTPCPID = registry.add("hDeuteronTPCPID", "#it{N}_{#sigma}^{TPC} vs. #it{p} for selected deuterons;#it{p} (GeV/#it{c});#it{N}_{#sigma}^{TPC}", HistType::kTH2F, {pAxis, nSigmaAxis}); - hDeuteronTOFPID = registry.add("hDeuteronTOFPID", "#it{N}_{#sigma}^{TOF} vs. #it{p} for selected deuterons;#it{p} (GeV/#it{c});#it{N}_{#sigma}^{TOF}", HistType::kTH2F, {pAxis, nSigmaAxis}); + hPrDePID[0] = registry.add("fProtonTPCPID", "#it{N}_{#sigma}^{TPC} vs. #it{p} for selected protons;#it{p} (GeV/#it{c});#it{N}_{#sigma}^{TPC}", HistType::kTH2D, {pAxis, nSigmaAxis}); + hPrDePID[1] = registry.add("fProtonTOFPID", "#it{N}_{#sigma}^{TOF} vs. #it{p} for selected protons;#it{p} (GeV/#it{c});#it{N}_{#sigma}^{TOF}", HistType::kTH2D, {pAxis, nSigmaAxis}); + hPrDePID[2] = registry.add("fDeuteronTPCPID", "#it{N}_{#sigma}^{TPC} vs. #it{p} for selected deuterons;#it{p} (GeV/#it{c});#it{N}_{#sigma}^{TPC}", HistType::kTH2D, {pAxis, nSigmaAxis}); + hPrDePID[3] = registry.add("fDeuteronTOFPID", "#it{N}_{#sigma}^{TOF} vs. #it{p} for selected deuterons;#it{p} (GeV/#it{c});#it{N}_{#sigma}^{TOF}", HistType::kTH2D, {pAxis, nSigmaAxis}); - hV0Selected = registry.add("fV0Selected", "Selections for V0s;;counts", HistType::kTH2F, {{9, -0.5, 8.5}, {kNV0, -0.5, +kNV0 - 0.5}}); + hV0Selected = registry.add("fV0Selected", "Selections for V0s;;counts", HistType::kTH2D, {{9, -0.5, 8.5}, {kNV0, -0.5, +kNV0 - 0.5}}); for (int iV0{kPhoton}; iV0 < kNV0; ++iV0) { hV0Selected->GetYaxis()->SetBinLabel(iV0 + 1, v0Labels[iV0].data()); @@ -328,25 +423,11 @@ struct HfFilter { // Main struct for HF triggers thresholdBDTScores = {thresholdBDTScoreD0ToKPi, thresholdBDTScoreDPlusToPiKPi, thresholdBDTScoreDSToPiKK, thresholdBDTScoreLcToPiKP, thresholdBDTScoreXicToPiKP}; } - using BigTracksMCPID = soa::Join; - using BigTracksPID = soa::Join; - using TracksIUPID = soa::Join; - using CollsWithEvSel = soa::Join; - - using Hf2ProngsWithMl = soa::Join; - using Hf3ProngsWithMl = soa::Join; - - Preslice trackIndicesPerCollision = aod::track_association::collisionId; - Preslice v0sPerCollision = aod::v0::collisionId; - Preslice hf2ProngPerCollision = aod::track_association::collisionId; - Preslice hf3ProngPerCollision = aod::track_association::collisionId; - Preslice cascPerCollision = aod::cascade::collisionId; - Preslice photonsPerCollision = aod::v0photonkf::collisionId; - void process(CollsWithEvSel const& collisions, aod::BCsWithTimestamps const&, aod::V0s const& v0s, aod::Cascades const& cascades, + aod::AssignedTrackedCascades const& trackedCasc, Hf2ProngsWithMl const& cand2Prongs, Hf3ProngsWithMl const& cand3Prongs, aod::TrackAssoc const& trackIndices, @@ -358,8 +439,8 @@ struct HfFilter { // Main struct for HF triggers for (const auto& collision : collisions) { bool keepEvent[kNtriggersHF]{false}; - if (applyEventSelection && (!collision.sel8() || std::fabs(collision.posZ()) > 11.f)) { // safety margin for Zvtx - tags(keepEvent[kHighPt2P], keepEvent[kHighPt3P], keepEvent[kBeauty3P], keepEvent[kBeauty4P], keepEvent[kFemto2P], keepEvent[kFemto3P], keepEvent[kDoubleCharm2P], keepEvent[kDoubleCharm3P], keepEvent[kDoubleCharmMix], keepEvent[kV0Charm2P], keepEvent[kV0Charm3P], keepEvent[kCharmBarToXiBach], keepEvent[kSigmaCPPK], keepEvent[kSigmaC0K0], keepEvent[kPhotonCharm2P], keepEvent[kPhotonCharm3P], keepEvent[kSingleCharm2P], keepEvent[kSingleCharm3P], keepEvent[kSingleNonPromptCharm2P], keepEvent[kSingleNonPromptCharm3P]); + if (!collision.sel8() || std::fabs(collision.posZ()) > 11.f) { // safety margin for Zvtx + tags(keepEvent[kHighPt2P], keepEvent[kHighPt3P], keepEvent[kBeauty3P], keepEvent[kBeauty4P], keepEvent[kFemto2P], keepEvent[kFemto3P], keepEvent[kDoubleCharm2P], keepEvent[kDoubleCharm3P], keepEvent[kDoubleCharmMix], keepEvent[kV0Charm2P], keepEvent[kV0Charm3P], keepEvent[kCharmBarToXiBach], keepEvent[kSigmaCPPK], keepEvent[kSigmaC0K0], keepEvent[kPhotonCharm2P], keepEvent[kPhotonCharm3P], keepEvent[kSingleCharm2P], keepEvent[kSingleCharm3P], keepEvent[kSingleNonPromptCharm2P], keepEvent[kSingleNonPromptCharm3P], keepEvent[kCharmBarToXi2Bach], keepEvent[kPrCharm2P], keepEvent[kBtoJPsiKa], keepEvent[kBtoJPsiKstar], keepEvent[kBtoJPsiPhi], keepEvent[kBtoJPsiPrKa], keepEvent[kBtoJPsiPi]); continue; } @@ -387,9 +468,9 @@ struct HfFilter { // Main struct for HF triggers auto bz = o2::base::Propagator::Instance()->getNominalBz(); dfStrangeness.setBz(bz); + df2.setBz(bz); + df3.setBz(bz); if (activateSecVtxForB) { - df2.setBz(bz); - df3.setBz(bz); dfB.setBz(bz); dfBtoDstar.setBz(bz); } @@ -399,26 +480,28 @@ struct HfFilter { // Main struct for HF triggers hProcessedEvents->Fill(0); - std::vector> indicesDau2Prong{}; + std::vector> indicesDau2Prong{}, indicesDau2ProngPrompt{}; auto cand2ProngsThisColl = cand2Prongs.sliceBy(hf2ProngPerCollision, thisCollId); - for (const auto& cand2Prong : cand2ProngsThisColl) { // start loop over 2 prongs - if (!TESTBIT(cand2Prong.hfflag(), o2::aod::hf_cand_2prong::DecayType::D0ToPiK)) { // check if it's a D0 + for (const auto& cand2Prong : cand2ProngsThisColl) { // start loop over 2 prongs + + int8_t preselD0 = TESTBIT(cand2Prong.hfflag(), o2::aod::hf_cand_2prong::DecayType::D0ToPiK); // check if it's a D0 + int8_t preselJPsiToMuMu = TESTBIT(cand2Prong.hfflag(), o2::aod::hf_cand_2prong::DecayType::JpsiToMuMu); // check if it's a JPsi + if (preselD0 == 0 && preselJPsiToMuMu == 0) { continue; } auto trackPos = tracks.rawIteratorAt(cand2Prong.prong0Id()); // positive daughter auto trackNeg = tracks.rawIteratorAt(cand2Prong.prong1Id()); // negative daughter - auto preselD0 = helper.isDzeroPreselected(trackPos, trackNeg); - if (!preselD0) { - continue; + if (preselD0) { + preselD0 = helper.isDzeroPreselected(trackPos, trackNeg); } auto trackParPos = getTrackParCov(trackPos); auto trackParNeg = getTrackParCov(trackNeg); - o2::gpu::gpustd::array dcaPos{trackPos.dcaXY(), trackPos.dcaZ()}; - o2::gpu::gpustd::array dcaNeg{trackNeg.dcaXY(), trackNeg.dcaZ()}; + std::array dcaPos{trackPos.dcaXY(), trackPos.dcaZ()}; + std::array dcaNeg{trackNeg.dcaXY(), trackNeg.dcaZ()}; std::array pVecPos{trackPos.pVector()}; std::array pVecNeg{trackNeg.pVector()}; if (trackPos.collisionId() != thisCollId) { @@ -430,84 +513,112 @@ struct HfFilter { // Main struct for HF triggers getPxPyPz(trackParNeg, pVecNeg); } - // apply ML models + // apply ML models for D0 + bool isD0CharmTagged{false}, isD0BeautyTagged{false}, isD0SignalTagged{false}; std::vector scores{}; - scores.insert(scores.end(), cand2Prong.mlProbSkimD0ToKPi().begin(), cand2Prong.mlProbSkimD0ToKPi().end()); - if (scores.size() != 3) { - scores.resize(3); - scores[0] = 2.; - scores[1] = -1.; - scores[2] = -1.; - } - auto tagBDT = helper.isBDTSelected(scores, thresholdBDTScores[kD0]); - bool isCharmTagged = TESTBIT(tagBDT, RecoDecay::OriginType::Prompt); - bool isBeautyTagged = TESTBIT(tagBDT, RecoDecay::OriginType::NonPrompt); - bool isSignalTagged = acceptBdtBkgOnly ? TESTBIT(tagBDT, RecoDecay::OriginType::None) : (isCharmTagged || isBeautyTagged); - - if (activateQA > 1) { - hBDTScoreBkg[kD0]->Fill(scores[0]); - hBDTScorePrompt[kD0]->Fill(scores[1]); - hBDTScoreNonPrompt[kD0]->Fill(scores[2]); - } - - if (!isSignalTagged) { - continue; - } + if (preselD0) { + scores.insert(scores.end(), cand2Prong.mlProbSkimD0ToKPi().begin(), cand2Prong.mlProbSkimD0ToKPi().end()); + if (scores.size() != 3) { + scores.resize(3); + scores[0] = 2.; + scores[1] = -1.; + scores[2] = -1.; + } + auto tagBDT = helper.isBDTSelected(scores, thresholdBDTScores[kD0]); + isD0CharmTagged = TESTBIT(tagBDT, RecoDecay::OriginType::Prompt); + isD0BeautyTagged = TESTBIT(tagBDT, RecoDecay::OriginType::NonPrompt); + isD0SignalTagged = acceptBdtBkgOnly ? TESTBIT(tagBDT, RecoDecay::OriginType::None) : (isD0CharmTagged || isD0BeautyTagged); - keepEvent[kSingleCharm2P] = true; - if (isBeautyTagged) { - keepEvent[kSingleNonPromptCharm2P] = true; + if (activateQA > 1) { + hBDTScoreBkg[kD0]->Fill(scores[0]); + hBDTScorePrompt[kD0]->Fill(scores[1]); + hBDTScoreNonPrompt[kD0]->Fill(scores[2]); + } } auto pVec2Prong = RecoDecay::pVec(pVecPos, pVecNeg); auto pt2Prong = RecoDecay::pt(pVec2Prong); - if (applyOptimisation) { - optimisationTreeCharm(thisCollId, o2::constants::physics::Pdg::kD0, pt2Prong, scores[0], scores[1], scores[2]); + if (preselJPsiToMuMu) { + float ptMuonMin = cutsBtoHadrons.cutsBtoJPsiX->get(0u, 0u); // assuming that the cut is looser in the first pT bin + auto ptPos = RecoDecay::pt(pVecPos); + auto ptNeg = RecoDecay::pt(pVecNeg); + if (ptPos < ptMuonMin || ptNeg < ptMuonMin) { + preselJPsiToMuMu = 0u; + } else { + auto massJPsiCand = RecoDecay::m(std::array{pVecPos, pVecNeg}, std::array{massMu, massMu}); + hMassVsPtC[kNCharmParticles + 18]->Fill(pt2Prong, massJPsiCand); + } } - auto selD0 = helper.isSelectedD0InMassRange(pVecPos, pVecNeg, pt2Prong, preselD0, activateQA, hMassVsPtC[kD0]); + if (!isD0SignalTagged && !preselJPsiToMuMu) { + continue; + } - if (helper.isSelectedHighPt2Prong(pt2Prong)) { - keepEvent[kHighPt2P] = true; - if (activateQA) { - hCharmHighPt[kD0]->Fill(pt2Prong); + int8_t selD0InMass{0}; + double massD0Cand{-1.}, massD0BarCand{-1.}; + if (isD0SignalTagged) { + // single D0 + keepEvent[kSingleCharm2P] = true; + if (isD0BeautyTagged) { + keepEvent[kSingleNonPromptCharm2P] = true; } - } // end high-pT selection - - if (isCharmTagged) { + // single D0 at high pT + if (helper.isSelectedHighPt2Prong(pt2Prong)) { + keepEvent[kHighPt2P] = true; + if (activateQA) { + hCharmHighPt[kD0]->Fill(pt2Prong); + } + } + // multi-charm selection indicesDau2Prong.push_back(std::vector{trackPos.globalIndex(), trackNeg.globalIndex()}); - } // end multi-charm selection + if (isD0CharmTagged) { + indicesDau2ProngPrompt.push_back(std::vector{trackPos.globalIndex(), trackNeg.globalIndex()}); + } - // compute masses already here, needed both for B0 --> D* (--> D0 Pi) Pi and Ds1 --> D* (--> D0 Pi) K0S - auto massD0Cand = RecoDecay::m(std::array{pVecPos, pVecNeg}, std::array{massPi, massKa}); - auto massD0BarCand = RecoDecay::m(std::array{pVecPos, pVecNeg}, std::array{massKa, massPi}); + if (applyOptimisation) { + optimisationTreeCharm(thisCollId, o2::constants::physics::Pdg::kD0, pt2Prong, scores[0], scores[1], scores[2]); + } + selD0InMass = helper.isSelectedD0InMassRange(pVecPos, pVecNeg, pt2Prong, preselD0, activateQA, hMassVsPtC[kD0]); + // compute masses already here, needed both for B0 --> D* (--> D0 Pi) Pi and Ds1 --> D* (--> D0 Pi) K0S + massD0Cand = RecoDecay::m(std::array{pVecPos, pVecNeg}, std::array{massPi, massKa}); + massD0BarCand = RecoDecay::m(std::array{pVecPos, pVecNeg}, std::array{massKa, massPi}); + } auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + auto tracksWithItsPid = soa::Attach(tracks); for (const auto& trackId : trackIdsThisCollision) { // start loop over tracks - auto track = tracks.rawIteratorAt(trackId.trackId()); + auto track = tracksWithItsPid.rawIteratorAt(trackId.trackId()); if (track.globalIndex() == trackPos.globalIndex() || track.globalIndex() == trackNeg.globalIndex()) { continue; } auto trackParThird = getTrackParCov(track); - o2::gpu::gpustd::array dcaThird{track.dcaXY(), track.dcaZ()}; + std::array dcaThird{track.dcaXY(), track.dcaZ()}; std::array pVecThird = track.pVector(); if (track.collisionId() != thisCollId) { o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParThird, 2.f, noMatCorr, &dcaThird); getPxPyPz(trackParThird, pVecThird); } - if (!keepEvent[kBeauty3P] && isBeautyTagged) { - auto isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(track, trackParThird, dcaThird, kBeauty3P); - if (TESTBIT(isTrackSelected, kForBeauty) && ((TESTBIT(selD0, 0) && track.sign() < 0) || (TESTBIT(selD0, 1) && track.sign() > 0))) { // D0 pi- and D0bar pi+ - auto massCand = RecoDecay::m(std::array{pVec2Prong, pVecThird}, std::array{massD0, massPi}); + // Beauty with D0 + if (!keepEvent[kBeauty3P] && isD0BeautyTagged) { + int16_t isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(track, trackParThird, dcaThird); + if (TESTBIT(isTrackSelected, kForBeauty) && ((TESTBIT(selD0InMass, 0) && track.sign() < 0) || (TESTBIT(selD0InMass, 1) && track.sign() > 0))) { // D0 pi-/K- and D0bar pi+/K+ + auto massCandD0Pi = RecoDecay::m(std::array{pVec2Prong, pVecThird}, std::array{massD0, massPi}); + auto massCandD0K = RecoDecay::m(std::array{pVec2Prong, pVecThird}, std::array{massD0, massKa}); auto pVecBeauty3Prong = RecoDecay::pVec(pVec2Prong, pVecThird); auto ptCand = RecoDecay::pt(pVecBeauty3Prong); - if (TESTBIT(isTrackSelected, kForBeauty) && helper.isSelectedBhadronInMassRange(ptCand, massCand, kBplus)) { + bool isBplusInMass = helper.isSelectedBhadronInMassRange(ptCand, massCandD0Pi, kBplus); + bool isBcInMass = helper.isSelectedBhadronInMassRange(ptCand, massCandD0K, kBc); + + if (TESTBIT(isTrackSelected, kForBeauty) && (isBplusInMass || isBcInMass)) { if (activateQA) { - registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::Skimmed, kBplus); + if (isBplusInMass) + registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::Skimmed, kBplus); + if (isBcInMass) + registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::Skimmed, kBc); } if (!activateSecVtxForB) { keepEvent[kBeauty3P] = true; @@ -516,10 +627,14 @@ struct HfFilter { // Main struct for HF triggers optimisationTreeBeauty(thisCollId, o2::constants::physics::Pdg::kD0, pt2Prong, scores[0], scores[1], scores[2], dcaThird[0]); } if (activateQA) { - hMassVsPtB[kBplus]->Fill(ptCand, massCand); + if (isBplusInMass) + hMassVsPtB[kBplus]->Fill(ptCand, massCandD0Pi); + if (isBcInMass) + hMassVsPtB[kBc]->Fill(ptCand, massCandD0K); } } else { df2.process(trackParPos, trackParNeg); + df2.propagateTracksToVertex(); std::array pVecPosVtx{}, pVecNegVtx{}; df2.getTrack(0).getPxPyPzGlo(pVecPosVtx); df2.getTrack(1).getPxPyPzGlo(pVecNegVtx); @@ -530,33 +645,44 @@ struct HfFilter { // Main struct for HF triggers if (activateQA) { registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::BeautyVertex, kBplus); } - const auto& secondaryVertexBplus = dfB.getPCACandidate(); dfB.propagateTracksToVertex(); + const auto& secondaryVertexBtoD0h = dfB.getPCACandidate(); std::array pVecThirdVtx{}; dfB.getTrack(0).getPxPyPzGlo(pVec2ProngVtx); dfB.getTrack(1).getPxPyPzGlo(pVecThirdVtx); - o2::gpu::gpustd::array dca2Prong; //{trackParD.dcaXY(), trackParD.dcaZ()}; + std::array dca2Prong; //{trackParD.dcaXY(), trackParD.dcaZ()}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParD, 2.f, noMatCorr, &dca2Prong); - bool isBplus = helper.isSelectedBhadron(pVec2ProngVtx, pVecThirdVtx, dca2Prong, dcaThird, std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBplus[0], secondaryVertexBplus[1], secondaryVertexBplus[2]}, kBplus); - if (isBplus) { + bool isBplus = helper.isSelectedBhadron(pVec2ProngVtx, pVecThirdVtx, dca2Prong, dcaThird, std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBtoD0h[0], secondaryVertexBtoD0h[1], secondaryVertexBtoD0h[2]}, kBplus); + bool isBc = helper.isSelectedBhadron(pVec2ProngVtx, pVecThirdVtx, dca2Prong, dcaThird, std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBtoD0h[0], secondaryVertexBtoD0h[1], secondaryVertexBtoD0h[2]}, kBc); + + if (isBplus || isBc) { keepEvent[kBeauty3P] = true; // fill optimisation tree for D0 if (applyOptimisation) { optimisationTreeBeauty(thisCollId, o2::constants::physics::Pdg::kD0, pt2Prong, scores[0], scores[1], scores[2], dcaThird[0]); } if (activateQA) { - registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::CharmHadPiSelected, kBplus); - hCpaVsPtB[kBplus]->Fill(ptCand, RecoDecay::cpa(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBplus[0], secondaryVertexBplus[1], secondaryVertexBplus[2]}, RecoDecay::pVec(pVec2ProngVtx, pVecThirdVtx))); - hDecayLengthVsPtB[kBplus]->Fill(ptCand, RecoDecay::distance(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBplus[0], secondaryVertexBplus[1], secondaryVertexBplus[2]})); - hImpactParamProductVsPtB[kBplus]->Fill(ptCand, dca2Prong[0] * dcaThird[0]); - hMassVsPtB[kBplus]->Fill(ptCand, massCand); + if (isBplus) { + registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::CharmHadPiSelected, kBplus); + hCpaVsPtB[kBplus]->Fill(ptCand, RecoDecay::cpa(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBtoD0h[0], secondaryVertexBtoD0h[1], secondaryVertexBtoD0h[2]}, RecoDecay::pVec(pVec2ProngVtx, pVecThirdVtx))); + hDecayLengthVsPtB[kBplus]->Fill(ptCand, RecoDecay::distance(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBtoD0h[0], secondaryVertexBtoD0h[1], secondaryVertexBtoD0h[2]})); + hImpactParamProductVsPtB[kBplus]->Fill(ptCand, dca2Prong[0] * dcaThird[0]); + hMassVsPtB[kBplus]->Fill(ptCand, massCandD0Pi); + } + if (isBc) { + registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::CharmHadPiSelected, kBc); + hCpaVsPtB[kBc]->Fill(ptCand, RecoDecay::cpa(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBtoD0h[0], secondaryVertexBtoD0h[1], secondaryVertexBtoD0h[2]}, RecoDecay::pVec(pVec2ProngVtx, pVecThirdVtx))); + hDecayLengthVsPtB[kBc]->Fill(ptCand, RecoDecay::distance(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBtoD0h[0], secondaryVertexBtoD0h[1], secondaryVertexBtoD0h[2]})); + hImpactParamProductVsPtB[kBc]->Fill(ptCand, dca2Prong[0] * dcaThird[0]); + hMassVsPtB[kBc]->Fill(ptCand, massCandD0K); + } } } } } } } - if (!keepEvent[kBeauty3P] && TESTBIT(isTrackSelected, kSoftPionForBeauty) && ((TESTBIT(selD0, 0) && track.sign() > 0) || (TESTBIT(selD0, 1) && track.sign() < 0))) { // D0 pi+ and D0bar pi- + if (!keepEvent[kBeauty3P] && TESTBIT(isTrackSelected, kSoftPionForBeauty) && ((TESTBIT(selD0InMass, 0) && track.sign() > 0) || (TESTBIT(selD0InMass, 1) && track.sign() < 0))) { // D0 pi+ and D0bar pi- auto pVecBeauty3Prong = RecoDecay::pVec(pVec2Prong, pVecThird); auto ptCand = RecoDecay::pt(pVecBeauty3Prong); std::array massDausD0{massPi, massKa}; @@ -578,14 +704,14 @@ struct HfFilter { // Main struct for HF triggers continue; } auto trackParFourth = getTrackParCov(trackB); - o2::gpu::gpustd::array dcaFourth{trackB.dcaXY(), trackB.dcaZ()}; + std::array dcaFourth{trackB.dcaXY(), trackB.dcaZ()}; std::array pVecFourth = trackB.pVector(); if (trackB.collisionId() != thisCollId) { o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParFourth, 2.f, noMatCorr, &dcaFourth); getPxPyPz(trackParFourth, pVecFourth); } - auto isTrackFourthSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackB, trackParFourth, dcaFourth, kBeauty3P); + auto isTrackFourthSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackB, trackParFourth, dcaFourth); if (track.sign() * trackB.sign() < 0 && TESTBIT(isTrackFourthSelected, kForBeauty)) { auto massCandB0 = RecoDecay::m(std::array{pVecBeauty3Prong, pVecFourth}, std::array{massDStar, massPi}); auto pVecBeauty4Prong = RecoDecay::pVec(pVec2Prong, pVecThird, pVecFourth); @@ -605,6 +731,7 @@ struct HfFilter { // Main struct for HF triggers } } else { df2.process(trackParPos, trackParNeg); + df2.propagateTracksToVertex(); std::array pVecPosVtx{}, pVecNegVtx{}; df2.getTrack(0).getPxPyPzGlo(pVecPosVtx); df2.getTrack(1).getPxPyPzGlo(pVecNegVtx); @@ -615,8 +742,8 @@ struct HfFilter { // Main struct for HF triggers if (activateQA) { registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::BeautyVertex, kB0toDStar); } - const auto& secondaryVertexBzero = dfBtoDstar.getPCACandidate(); dfBtoDstar.propagateTracksToVertex(); + const auto& secondaryVertexBzero = dfBtoDstar.getPCACandidate(); std::array pVecThirdVtx{}, pVecFourthVtx{}; dfBtoDstar.getTrack(0).getPxPyPzGlo(pVec2ProngVtx); dfBtoDstar.getTrack(1).getPxPyPzGlo(pVecThirdVtx); @@ -645,8 +772,8 @@ struct HfFilter { // Main struct for HF triggers } // end beauty selection // 2-prong femto - if (!keepEvent[kFemto2P] && enableFemtoChannels->get(0u, 0u) && isCharmTagged && track.collisionId() == thisCollId && (TESTBIT(selD0, 0) || TESTBIT(selD0, 1) || !requireCharmMassForFemto)) { - bool isProton = helper.isSelectedTrack4Femto(track, trackParThird, activateQA, hProtonTPCPID, hProtonTOFPID, kProtonForFemto); + if (!keepEvent[kFemto2P] && enableFemtoChannels->get(0u, 0u) && isD0CharmTagged && track.collisionId() == thisCollId) { + bool isProton = helper.isSelectedTrack4Femto(track, trackParThird, activateQA, hPrDePID[0], hPrDePID[1], kProtonForFemto); if (isProton) { float relativeMomentum = helper.computeRelativeMomentum(pVecThird, pVec2Prong, massD0); if (applyOptimisation) { @@ -661,10 +788,74 @@ struct HfFilter { // Main struct for HF triggers } } // end femto selection + // Beauty with JPsi + if (preselJPsiToMuMu) { + if (!TESTBIT(helper.isSelectedTrackForSoftPionOrBeauty(track, trackParThird, dcaThird), kForBeauty)) { // same for all channels + continue; + } + std::array pVecPosVtx{}, pVecNegVtx{}, pVecThirdVtx{}, pVecFourthVtx{}; + // 3-prong vertices + if (!keepEvent[kBtoJPsiKa] || !keepEvent[kBtoJPsiPi]) { + if (df3.process(trackParPos, trackParNeg, trackParThird) != 0) { + df3.propagateTracksToVertex(); + const auto& secondaryVertexBto3tracks = df3.getPCACandidate(); + df3.getTrack(0).getPxPyPzGlo(pVecPosVtx); + df3.getTrack(1).getPxPyPzGlo(pVecNegVtx); + df3.getTrack(2).getPxPyPzGlo(pVecThirdVtx); + auto isBhadSel = helper.isSelectedBhadronToJPsi<3>(std::array{pVecPosVtx, pVecNegVtx, pVecThirdVtx}, std::array{track}, std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBto3tracks[0], secondaryVertexBto3tracks[1], secondaryVertexBto3tracks[2]}, activateQA, hMassVsPtB); + if (TESTBIT(isBhadSel, kBplusToJPsi)) { + keepEvent[kBtoJPsiKa] = true; + } + if (TESTBIT(isBhadSel, kBcToJPsi)) { + keepEvent[kBtoJPsiPi] = true; + } + } + } + // 4-prong vertices + if (!keepEvent[kBtoJPsiKstar] || !keepEvent[kBtoJPsiPhi] || !keepEvent[kBtoJPsiPrKa]) { + for (const auto& trackIdB : trackIdsThisCollision) { // start loop over tracks + if (keepEvent[kBtoJPsiKstar] && keepEvent[kBtoJPsiPhi] && keepEvent[kBtoJPsiPrKa]) { + break; + } + auto trackFourth = tracksWithItsPid.rawIteratorAt(trackIdB.trackId()); + if (trackFourth.globalIndex() == track.globalIndex() || trackFourth.globalIndex() == trackPos.globalIndex() || trackFourth.globalIndex() == trackNeg.globalIndex() || trackFourth.sign() * track.sign() > 0) { + continue; + } + auto trackParFourth = getTrackParCov(trackFourth); + std::array dcaFourth{trackFourth.dcaXY(), trackFourth.dcaZ()}; + std::array pVecFourth = trackFourth.pVector(); + if (trackFourth.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParFourth, 2.f, noMatCorr, &dcaFourth); + getPxPyPz(trackParFourth, pVecFourth); + } + if (!TESTBIT(helper.isSelectedTrackForSoftPionOrBeauty(trackFourth, trackParFourth, dcaFourth), kForBeauty)) { // same for all channels + continue; + } + if (df4.process(trackParPos, trackParNeg, trackParThird, trackParFourth) != 0) { + df4.propagateTracksToVertex(); + const auto& secondaryVertexBto4tracks = df4.getPCACandidate(); + df4.getTrack(0).getPxPyPzGlo(pVecPosVtx); + df4.getTrack(1).getPxPyPzGlo(pVecNegVtx); + df4.getTrack(2).getPxPyPzGlo(pVecThirdVtx); + df4.getTrack(3).getPxPyPzGlo(pVecFourthVtx); + auto isBhadSel = helper.isSelectedBhadronToJPsi<4>(std::array{pVecPosVtx, pVecNegVtx, pVecThirdVtx, pVecFourthVtx}, std::array{track, trackFourth}, std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexBto4tracks[0], secondaryVertexBto4tracks[1], secondaryVertexBto4tracks[2]}, activateQA, hMassVsPtB); + if (TESTBIT(isBhadSel, kB0ToJPsi)) { + keepEvent[kBtoJPsiKstar] = true; + } + if (TESTBIT(isBhadSel, kBsToJPsi)) { + keepEvent[kBtoJPsiPhi] = true; + } + if (TESTBIT(isBhadSel, kLbToJPsi)) { + keepEvent[kBtoJPsiPrKa] = true; + } + } + } + } + } } // end loop over tracks // 2-prong with Gamma (conversion photon) - if (!keepEvent[kPhotonCharm2P] && isSignalTagged && (TESTBIT(selD0, 0) || TESTBIT(selD0, 1))) { + if (!keepEvent[kPhotonCharm2P] && isD0SignalTagged && (TESTBIT(selD0InMass, 0) || TESTBIT(selD0InMass, 1))) { auto photonsThisCollision = photons.sliceBy(photonsPerCollision, thisCollId); for (const auto& photon : photonsThisCollision) { auto posTrack = photon.posTrack_as(); @@ -672,7 +863,7 @@ struct HfFilter { // Main struct for HF triggers if (!helper.isSelectedPhoton(photon, std::array{posTrack, negTrack}, activateQA, hV0Selected, hArmPod)) { continue; } - gpu::gpustd::array dcaInfo; + std::array dcaInfo; std::array pVecPhoton = {photon.px(), photon.py(), photon.pz()}; std::array posVecPhoton = {photon.vx(), photon.vy(), photon.vz()}; auto trackParPhoton = o2::track::TrackPar(posVecPhoton, pVecPhoton, 0, true); @@ -685,11 +876,11 @@ struct HfFilter { // Main struct for HF triggers auto pVecReso2Prong = RecoDecay::pVec(pVec2Prong, pVecPhoton); auto ptCand = RecoDecay::pt(pVecReso2Prong); if (ptCand > cutsPtDeltaMassCharmReso->get(2u, 1u)) { - if (TESTBIT(selD0, 0)) { + if (TESTBIT(selD0InMass, 0)) { massDStarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, pVecPhoton}, std::array{massPi, massKa, massGamma}); massDiffDstar = massDStarCand - massD0Cand; } - if (TESTBIT(selD0, 1)) { + if (TESTBIT(selD0InMass, 1)) { massDStarBarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, pVecPhoton}, std::array{massKa, massPi, massGamma}); massDiffDstarBar = massDStarBarCand - massD0BarCand; } @@ -713,7 +904,7 @@ struct HfFilter { // Main struct for HF triggers } // 2-prong with K0S or Lambda - if (!keepEvent[kV0Charm2P] && isSignalTagged && (TESTBIT(selD0, 0) || TESTBIT(selD0, 1))) { + if (!keepEvent[kV0Charm2P] && isD0SignalTagged && (TESTBIT(selD0InMass, 0) || TESTBIT(selD0InMass, 1))) { auto v0sThisCollision = v0s.sliceBy(v0sPerCollision, thisCollId); for (const auto& v0 : v0sThisCollision) { V0Cand v0Cand; @@ -735,15 +926,15 @@ struct HfFilter { // Main struct for HF triggers } auto trackParBachelor = getTrackPar(trackBachelor); - o2::gpu::gpustd::array dcaBachelor{trackBachelor.dcaXY(), trackBachelor.dcaZ()}; + std::array dcaBachelor{trackBachelor.dcaXY(), trackBachelor.dcaZ()}; std::array pVecBachelor = trackBachelor.pVector(); if (trackBachelor.collisionId() != thisCollId) { o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParBachelor, 2.f, noMatCorr, &dcaBachelor); getPxPyPz(trackParBachelor, pVecBachelor); } - int isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackBachelor, trackParBachelor, dcaBachelor, -1); - if (TESTBIT(isTrackSelected, kSoftPion) && ((TESTBIT(selD0, 0) && trackBachelor.sign() > 0) || (TESTBIT(selD0, 1) && trackBachelor.sign() < 0))) { + auto isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackBachelor, trackParBachelor, dcaBachelor); + if (TESTBIT(isTrackSelected, kSoftPion) && ((TESTBIT(selD0InMass, 0) && trackBachelor.sign() > 0) || (TESTBIT(selD0InMass, 1) && trackBachelor.sign() < 0))) { std::array massDausD0{massPi, massKa}; auto massD0dau = massD0Cand; if (trackBachelor.sign() < 0) { @@ -786,12 +977,12 @@ struct HfFilter { // Main struct for HF triggers auto pVecReso2Prong = RecoDecay::pVec(pVec2Prong, v0Cand.mom); auto ptCand = RecoDecay::pt(pVecReso2Prong); if (ptCand > cutsPtDeltaMassCharmReso->get(2u, 5u)) { - if (TESTBIT(selD0, 0)) { + if (TESTBIT(selD0InMass, 0)) { massXicStarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, v0Cand.mom}, std::array{massPi, massKa, massLambda}); massDiffXicStarCand = massXicStarCand - massD0Cand; isRightSignXicStar = TESTBIT(selV0, kLambda); // right sign if Lambda } - if (TESTBIT(selD0, 1)) { + if (TESTBIT(selD0InMass, 1)) { massXicStarBarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, v0Cand.mom}, std::array{massKa, massPi, massLambda}); massDiffXicStarBarCand = massXicStarBarCand - massD0BarCand; isRightSignXicStarBar = TESTBIT(selV0, kAntiLambda); // right sign if AntiLambda @@ -824,9 +1015,160 @@ struct HfFilter { // Main struct for HF triggers } } // end V0 selection + // 2-prong (D0 or D*) with proton for Lc resonances and ThetaC (3100) + if (!keepEvent[kPrCharm2P] && isD0SignalTagged && (TESTBIT(selD0InMass, 0) || TESTBIT(selD0InMass, 1))) { + for (const auto& trackProtonId : trackIdsThisCollision) { // start loop over tracks selecting only protons + auto trackProton = tracks.rawIteratorAt(trackProtonId.trackId()); + auto trackParBachelorProton = getTrackPar(trackProton); + if (trackProton.globalIndex() == trackPos.globalIndex() || trackProton.globalIndex() == trackNeg.globalIndex()) { + continue; + } + std::array dcaInfoBachProton; + if (trackProton.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParBachelorProton, 2.f, noMatCorr, &dcaInfoBachProton); + } + std::array pVecProton = trackProton.pVector(); + bool isSelPIDProton = helper.isSelectedProton4CharmOrBeautyBaryons(trackProton); + if (isSelPIDProton) { + if (!keepEvent[kPrCharm2P]) { + // we first look for a D*+ + for (const auto& trackBachelorId : trackIdsThisCollision) { // start loop over tracks to find bachelor pion + if (!helper.isSelectedProtonFromLcResoOrThetaC(trackProton)) { + continue; + } // stop here if proton below pT threshold for thetaC to avoid computational losses + auto trackBachelor = tracks.rawIteratorAt(trackBachelorId.trackId()); + if (trackBachelor.globalIndex() == trackPos.globalIndex() || trackBachelor.globalIndex() == trackNeg.globalIndex() || trackBachelor.globalIndex() == trackProton.globalIndex()) { + continue; + } + auto trackParBachelor = getTrackPar(trackBachelor); + std::array dcaBachelor{trackBachelor.dcaXY(), trackBachelor.dcaZ()}; + std::array pVecBachelor = trackBachelor.pVector(); + if (trackBachelor.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParBachelor, 2.f, noMatCorr, &dcaBachelor); + getPxPyPz(trackParBachelor, pVecBachelor); + } + auto isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackBachelor, trackParBachelor, dcaBachelor); + if (TESTBIT(isTrackSelected, kSoftPion) && ((TESTBIT(selD0InMass, 0) && trackBachelor.sign() > 0) || (TESTBIT(selD0InMass, 1) && trackBachelor.sign() < 0))) { + if (pt2Prong < cutsPtDeltaMassCharmReso->get(3u, 12u)) { + continue; + } + std::array massDausD0{massPi, massKa}; + auto massD0dau = massD0Cand; + if (trackBachelor.sign() < 0) { + massDausD0[0] = massKa; + massDausD0[1] = massPi; + massD0dau = massD0BarCand; + } + auto pVecDStarCand = RecoDecay::pVec(pVec2Prong, pVecBachelor); + auto ptDStarCand = RecoDecay::pt(pVecDStarCand); + double massDStarCand{-999.}, massDiffDstar{-999.}; + if (ptDStarCand > cutsPtDeltaMassCharmReso->get(2u, 0u)) { + massDStarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, pVecBachelor}, std::array{massDausD0[0], massDausD0[1], massPi}); + massDiffDstar = massDStarCand - massD0dau; + if (cutsPtDeltaMassCharmReso->get(0u, 0u) <= massDiffDstar && massDiffDstar <= cutsPtDeltaMassCharmReso->get(1u, 0u)) { + if (activateQA) { // probably this is not needed, since already performed for the Xic (duplicate) + hMassVsPtC[kNCharmParticles]->Fill(ptDStarCand, massDiffDstar); + } + auto pVecReso2Prong = RecoDecay::pVec(pVecDStarCand, pVecProton); + auto ptCand = RecoDecay::pt(pVecReso2Prong); + if (ptCand > cutsPtDeltaMassCharmReso->get(2u, 12u)) { + // build D*0p candidate with the possibility of storing also the other sign hyp. + float massThetacCand{-999.}, massThetacBarCand{-999.}; + float massDiffThetacCand{-999.}, massDiffThetacBarCand{-999.}; + bool isRightSignThetaC{false}, isRightSignThetaCBar{false}; + if (TESTBIT(selD0InMass, 1)) { // Correct hyp: ThetaC -> pD*- -> D0bar\pi- (Equivalent to trackBachelor.sign() < 0) + massThetacCand = RecoDecay::m(std::array{pVecPos, pVecNeg, pVecBachelor, pVecProton}, std::array{massDausD0[0], massDausD0[1], massPi, massProton}); + massDiffThetacCand = massThetacCand - massDStarCand; + isRightSignThetaC = trackProton.sign() > 0; // right sign if proton + } + if (TESTBIT(selD0InMass, 0)) { // Correct hyp: ThetaCbar -> pD*+ -> pD0\pi+ (Equivalent to trackBachelor.sign() > 0) + massThetacBarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, pVecBachelor, pVecProton}, std::array{massDausD0[0], massDausD0[1], massPi, massProton}); + massDiffThetacBarCand = massThetacBarCand - massDStarCand; + isRightSignThetaCBar = trackProton.sign() < 0; // right sign if antiproton + } + bool isGoodThetac = (cutsPtDeltaMassCharmReso->get(0u, 12u) < massDiffThetacCand && massDiffThetacCand < cutsPtDeltaMassCharmReso->get(1u, 12u)); + bool isGoodThetacBar = (cutsPtDeltaMassCharmReso->get(0u, 12u) < massDiffThetacBarCand && massDiffThetacBarCand < cutsPtDeltaMassCharmReso->get(1u, 12u)); + + if (activateQA) { + if (isGoodThetac) { + if (isRightSignThetaC) { + hMassVsPtC[kNCharmParticles + 21]->Fill(ptCand, massDiffThetacCand); + } else if (!isRightSignThetaC && keepAlsoWrongDmesProtonPairs) { + hMassVsPtC[kNCharmParticles + 22]->Fill(ptCand, massDiffThetacBarCand); + } + } + if (isGoodThetacBar) { + if (isRightSignThetaCBar) { + hMassVsPtC[kNCharmParticles + 21]->Fill(ptCand, massDiffThetacCand); + } else if (!isRightSignThetaCBar && keepAlsoWrongDmesProtonPairs) { + hMassVsPtC[kNCharmParticles + 22]->Fill(ptCand, massDiffThetacBarCand); + } + } + } + if ((isGoodThetac && (isRightSignThetaC || keepAlsoWrongDstarMesProtonPairs)) || (isGoodThetacBar && (isRightSignThetaCBar || keepAlsoWrongDstarMesProtonPairs))) { + keepEvent[kPrCharm2P] = true; + break; + } + } + } + } + } + } // end bachelor pion for D*p pairs + // build D0p candidate with the possibility of storing also the other sign hyp. + if (pt2Prong < cutsPtDeltaMassCharmReso->get(3u, 11u)) { + continue; + } + if (!helper.isSelectedProtonFromLcResoOrThetaC(trackProton)) { + continue; + } + float massLcStarCand{-999.}, massLcStarBarCand{-999.}; + float massDiffLcStarCand{-999.}, massDiffLcStarBarCand{-999.}; + bool isRightSignLcStar{false}, isRightSignLcStarBar{false}; + auto pVecReso2Prong = RecoDecay::pVec(pVec2Prong, pVecProton); + auto ptCand = RecoDecay::pt(pVecReso2Prong); + if (ptCand > cutsPtDeltaMassCharmReso->get(2u, 11u)) { + if (TESTBIT(selD0InMass, 0)) { + massLcStarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, pVecProton}, std::array{massPi, massKa, massProton}); + massDiffLcStarCand = massLcStarCand - massD0Cand; + isRightSignLcStar = trackProton.sign() > 0; // right sign if proton + } + if (TESTBIT(selD0InMass, 1)) { + massLcStarBarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, pVecProton}, std::array{massKa, massPi, massProton}); + massDiffLcStarBarCand = massLcStarBarCand - massD0BarCand; + isRightSignLcStarBar = trackProton.sign() < 0; // right sign if antiproton + } + bool isGoodLcStar = (cutsPtDeltaMassCharmReso->get(0u, 11u) < massDiffLcStarCand && massDiffLcStarCand < cutsPtDeltaMassCharmReso->get(1u, 11u)); + bool isGoodLcStarBar = (cutsPtDeltaMassCharmReso->get(0u, 11u) < massDiffLcStarBarCand && massDiffLcStarBarCand < cutsPtDeltaMassCharmReso->get(1u, 11u)); + + if (activateQA) { + if (isGoodLcStar) { + if (isRightSignLcStar) { + hMassVsPtC[kNCharmParticles + 19]->Fill(ptCand, massDiffLcStarCand); + } else if (!isRightSignLcStar && keepAlsoWrongDmesProtonPairs) { + hMassVsPtC[kNCharmParticles + 20]->Fill(ptCand, massDiffLcStarBarCand); + } + } + if (isGoodLcStarBar) { + if (isRightSignLcStarBar) { + hMassVsPtC[kNCharmParticles + 19]->Fill(ptCand, massDiffLcStarCand); + } else if (!isRightSignLcStarBar && keepAlsoWrongDmesProtonPairs) { + hMassVsPtC[kNCharmParticles + 20]->Fill(ptCand, massDiffLcStarBarCand); + } + } + } + if ((isGoodLcStar && (isRightSignLcStar || keepAlsoWrongDmesProtonPairs)) || (isGoodLcStarBar && (isRightSignLcStarBar || keepAlsoWrongDmesProtonPairs))) { + keepEvent[kPrCharm2P] = true; + break; + } + } + } + } // end proton loop + } + } // end Lc resonances via D0-proton decays + } // end loop over 2-prong candidates - std::vector> indicesDau3Prong{}; + std::vector> indicesDau3Prong{}, indicesDau3ProngPrompt{}; auto cand3ProngsThisColl = cand3Prongs.sliceBy(hf3ProngPerCollision, thisCollId); for (const auto& cand3Prong : cand3ProngsThisColl) { // start loop over 3 prongs std::array is3Prong = { @@ -845,9 +1187,9 @@ struct HfFilter { // Main struct for HF triggers auto trackParFirst = getTrackParCov(trackFirst); auto trackParSecond = getTrackParCov(trackSecond); auto trackParThird = getTrackParCov(trackThird); - o2::gpu::gpustd::array dcaFirst{trackFirst.dcaXY(), trackFirst.dcaZ()}; - o2::gpu::gpustd::array dcaSecond{trackSecond.dcaXY(), trackSecond.dcaZ()}; - o2::gpu::gpustd::array dcaThird{trackThird.dcaXY(), trackThird.dcaZ()}; + std::array dcaFirst{trackFirst.dcaXY(), trackFirst.dcaZ()}; + std::array dcaSecond{trackSecond.dcaXY(), trackSecond.dcaZ()}; + std::array dcaThird{trackThird.dcaXY(), trackThird.dcaZ()}; std::array pVecFirst = trackFirst.pVector(); std::array pVecSecond = trackSecond.pVector(); std::array pVecThird = trackThird.pVector(); @@ -923,8 +1265,18 @@ struct HfFilter { // Main struct for HF triggers keepEvent[kSingleNonPromptCharm3P] = true; } - if ((!keepOnlyDplusForDouble3Prongs && std::accumulate(isCharmTagged.begin(), isCharmTagged.end(), 0)) || (keepOnlyDplusForDouble3Prongs && isCharmTagged[kDplus - 1])) { + if (!keepOnlyDplusForDouble3Prongs) { indicesDau3Prong.push_back(std::vector{trackFirst.globalIndex(), trackSecond.globalIndex(), trackThird.globalIndex()}); + if (std::accumulate(isCharmTagged.begin(), isCharmTagged.end(), 0)) { + indicesDau3ProngPrompt.push_back(std::vector{trackFirst.globalIndex(), trackSecond.globalIndex(), trackThird.globalIndex()}); + } + } else { + if (isSignalTagged[kDplus - 1]) { + indicesDau3Prong.push_back(std::vector{trackFirst.globalIndex(), trackSecond.globalIndex(), trackThird.globalIndex()}); + if (isCharmTagged[kDplus - 1]) { + indicesDau3ProngPrompt.push_back(std::vector{trackFirst.globalIndex(), trackSecond.globalIndex(), trackThird.globalIndex()}); + } + } } // end multiple 3-prong selection auto pVec3Prong = RecoDecay::pVec(pVecFirst, pVecSecond, pVecThird); @@ -969,34 +1321,35 @@ struct HfFilter { // Main struct for HF triggers } // end high-pT selection auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + auto tracksWithItsPid = soa::Attach(tracks); for (const auto& trackId : trackIdsThisCollision) { // start loop over track indices as associated to this collision in HF code - auto track = tracks.rawIteratorAt(trackId.trackId()); + auto track = tracksWithItsPid.rawIteratorAt(trackId.trackId()); if (track.globalIndex() == trackFirst.globalIndex() || track.globalIndex() == trackSecond.globalIndex() || track.globalIndex() == trackThird.globalIndex()) { continue; } auto trackParFourth = getTrackParCov(track); - o2::gpu::gpustd::array dcaFourth{track.dcaXY(), track.dcaZ()}; + std::array dcaFourth{track.dcaXY(), track.dcaZ()}; std::array pVecFourth = track.pVector(); if (track.collisionId() != thisCollId) { o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParFourth, 2.f, noMatCorr, &dcaFourth); getPxPyPz(trackParFourth, pVecFourth); } - int charmParticleID[kNBeautyParticles - 2] = {o2::constants::physics::Pdg::kDPlus, o2::constants::physics::Pdg::kDS, o2::constants::physics::Pdg::kLambdaCPlus, o2::constants::physics::Pdg::kXiCPlus}; + int charmParticleID[kNBeautyParticles - 3] = {o2::constants::physics::Pdg::kDPlus, o2::constants::physics::Pdg::kDS, o2::constants::physics::Pdg::kLambdaCPlus, o2::constants::physics::Pdg::kXiCPlus}; - float massCharmHypos[kNBeautyParticles - 2] = {massDPlus, massDs, massLc, massXic}; - auto isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(track, trackParFourth, dcaFourth, kBeauty4P); + float massCharmHypos[kNBeautyParticles - 3] = {massDPlus, massDs, massLc, massXic}; + auto isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(track, trackParFourth, dcaFourth); if (track.sign() * sign3Prong < 0 && TESTBIT(isTrackSelected, kForBeauty)) { - for (int iHypo{0}; iHypo < kNBeautyParticles - 2 && !keepEvent[kBeauty4P]; ++iHypo) { + for (int iHypo{0}; iHypo < kNBeautyParticles - 3 && !keepEvent[kBeauty4P]; ++iHypo) { if (isBeautyTagged[iHypo] && (TESTBIT(is3ProngInMass[iHypo], 0) || TESTBIT(is3ProngInMass[iHypo], 1))) { auto massCandB = RecoDecay::m(std::array{pVec3Prong, pVecFourth}, std::array{massCharmHypos[iHypo], massPi}); auto pVecBeauty4Prong = RecoDecay::pVec(pVec3Prong, pVecFourth); auto ptCandBeauty4Prong = RecoDecay::pt(pVecBeauty4Prong); - if (helper.isSelectedBhadronInMassRange(ptCandBeauty4Prong, massCandB, iHypo + 2)) { // + 2 to account for B+ and B0->D*+ + if (helper.isSelectedBhadronInMassRange(ptCandBeauty4Prong, massCandB, iHypo + 3)) { // + 3 to account for B+ and B0->D*+ and Bc if (activateQA) { - registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::Skimmed, iHypo + 2); + registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::Skimmed, iHypo + 3); } if (!activateSecVtxForB) { keepEvent[kBeauty4P] = true; @@ -1004,10 +1357,11 @@ struct HfFilter { // Main struct for HF triggers optimisationTreeBeauty(thisCollId, charmParticleID[iHypo], pt3Prong, scores[iHypo][0], scores[iHypo][1], scores[iHypo][2], dcaFourth[0]); } if (activateQA) { - hMassVsPtB[iHypo + 2]->Fill(ptCandBeauty4Prong, massCandB); + hMassVsPtB[iHypo + 3]->Fill(ptCandBeauty4Prong, massCandB); } } else { df3.process(trackParFirst, trackParSecond, trackParThird); + df3.propagateTracksToVertex(); std::array pVecFirstVtx{}, pVecSecondVtx{}, pVecThirdVtx{}; df3.getTrack(0).getPxPyPzGlo(pVecFirstVtx); df3.getTrack(1).getPxPyPzGlo(pVecSecondVtx); @@ -1017,16 +1371,16 @@ struct HfFilter { // Main struct for HF triggers auto pVec3ProngVtx = RecoDecay::pVec(pVecFirstVtx, pVecSecondVtx, pVecThirdVtx); if (dfB.process(trackParD, trackParFourth) != 0) { if (activateQA) { - registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::BeautyVertex, iHypo + 2); + registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::BeautyVertex, iHypo + 3); } - const auto& secondaryVertexB = dfB.getPCACandidate(); dfB.propagateTracksToVertex(); + const auto& secondaryVertexB = dfB.getPCACandidate(); std::array pVecFourtVtx{}; dfB.getTrack(0).getPxPyPzGlo(pVec3ProngVtx); dfB.getTrack(1).getPxPyPzGlo(pVecFourtVtx); - o2::gpu::gpustd::array dca3Prong; //{trackParD.dcaXY(), trackParD.dcaZ()}; + std::array dca3Prong; //{trackParD.dcaXY(), trackParD.dcaZ()}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParD, 2.f, noMatCorr, &dca3Prong); - bool isBhad = helper.isSelectedBhadron(pVec3ProngVtx, pVecFourtVtx, dca3Prong, dcaFourth, std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexB[0], secondaryVertexB[1], secondaryVertexB[2]}, iHypo + 2); + bool isBhad = helper.isSelectedBhadron(pVec3ProngVtx, pVecFourtVtx, dca3Prong, dcaFourth, std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexB[0], secondaryVertexB[1], secondaryVertexB[2]}, iHypo + 3); if (isBhad) { keepEvent[kBeauty4P] = true; // fill optimisation tree @@ -1034,11 +1388,11 @@ struct HfFilter { // Main struct for HF triggers optimisationTreeBeauty(thisCollId, charmParticleID[iHypo], pt3Prong, scores[iHypo][0], scores[iHypo][1], scores[iHypo][2], dcaFourth[0]); } if (activateQA) { - registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::CharmHadPiSelected, iHypo + 2); - hCpaVsPtB[iHypo + 2]->Fill(ptCandBeauty4Prong, RecoDecay::cpa(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexB[0], secondaryVertexB[1], secondaryVertexB[2]}, RecoDecay::pVec(pVec3ProngVtx, pVecFourtVtx))); - hDecayLengthVsPtB[iHypo + 2]->Fill(ptCandBeauty4Prong, RecoDecay::distance(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexB[0], secondaryVertexB[1], secondaryVertexB[2]})); - hImpactParamProductVsPtB[iHypo + 2]->Fill(ptCandBeauty4Prong, dca3Prong[0] * dcaFourth[0]); - hMassVsPtB[iHypo + 2]->Fill(ptCandBeauty4Prong, massCandB); + registry.fill(HIST("fHfVtxStages"), 1 + HfVtxStage::CharmHadPiSelected, iHypo + 3); + hCpaVsPtB[iHypo + 3]->Fill(ptCandBeauty4Prong, RecoDecay::cpa(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexB[0], secondaryVertexB[1], secondaryVertexB[2]}, RecoDecay::pVec(pVec3ProngVtx, pVecFourtVtx))); + hDecayLengthVsPtB[iHypo + 3]->Fill(ptCandBeauty4Prong, RecoDecay::distance(std::array{static_cast(collision.posX()), static_cast(collision.posY()), static_cast(collision.posZ())}, std::array{secondaryVertexB[0], secondaryVertexB[1], secondaryVertexB[2]})); + hImpactParamProductVsPtB[iHypo + 3]->Fill(ptCandBeauty4Prong, dca3Prong[0] * dcaFourth[0]); + hMassVsPtB[iHypo + 3]->Fill(ptCandBeauty4Prong, massCandB); } } } @@ -1049,12 +1403,12 @@ struct HfFilter { // Main struct for HF triggers } // end beauty selection // 3-prong femto - bool isProton = helper.isSelectedTrack4Femto(track, trackParFourth, activateQA, hProtonTPCPID, hProtonTOFPID, kProtonForFemto); - bool isDeuteron = helper.isSelectedTrack4Femto(track, trackParFourth, activateQA, hDeuteronTPCPID, hDeuteronTOFPID, kDeuteronForFemto); + bool isProton = helper.isSelectedTrack4Femto(track, trackParFourth, activateQA, hPrDePID[0], hPrDePID[1], kProtonForFemto); + bool isDeuteron = helper.isSelectedTrack4Femto(track, trackParFourth, activateQA, hPrDePID[2], hPrDePID[3], kDeuteronForFemto); if (isProton && track.collisionId() == thisCollId) { for (int iHypo{0}; iHypo < kNCharmParticles - 1 && !keepEvent[kFemto3P]; ++iHypo) { - if (isCharmTagged[iHypo] && enableFemtoChannels->get(0u, iHypo + 1) && (TESTBIT(is3ProngInMass[iHypo], 0) || TESTBIT(is3ProngInMass[iHypo], 1) || !requireCharmMassForFemto)) { + if (isCharmTagged[iHypo] && enableFemtoChannels->get(0u, iHypo + 1)) { float relativeMomentum = helper.computeRelativeMomentum(pVecFourth, pVec3Prong, massCharmHypos[iHypo]); if (applyOptimisation) { optimisationTreeFemto(thisCollId, charmParticleID[iHypo], pt3Prong, scores[iHypo][0], scores[iHypo][1], scores[iHypo][2], relativeMomentum, track.tpcNSigmaPr(), track.tofNSigmaPr(), track.tpcNSigmaDe(), track.tofNSigmaDe()); @@ -1067,9 +1421,10 @@ struct HfFilter { // Main struct for HF triggers } } } - } else if (isDeuteron && track.collisionId() == thisCollId) { + } + if (isDeuteron && track.collisionId() == thisCollId) { for (int iHypo{0}; iHypo < kNCharmParticles - 1 && !keepEvent[kFemto3P]; ++iHypo) { - if (isCharmTagged[iHypo] && enableFemtoChannels->get(1u, iHypo + 1) && (TESTBIT(is3ProngInMass[iHypo], 0) || TESTBIT(is3ProngInMass[iHypo], 1) || !requireCharmMassForFemto)) { + if (isCharmTagged[iHypo] && enableFemtoChannels->get(1u, iHypo + 1)) { float relativeMomentum = helper.computeRelativeMomentum(pVecFourth, pVec3Prong, massCharmHypos[iHypo]); if (applyOptimisation) { optimisationTreeFemto(thisCollId, charmParticleID[iHypo], pt3Prong, scores[iHypo][0], scores[iHypo][1], scores[iHypo][2], relativeMomentum, track.tpcNSigmaPr(), track.tofNSigmaPr(), track.tpcNSigmaDe(), track.tofNSigmaDe()); @@ -1115,7 +1470,7 @@ struct HfFilter { // Main struct for HF triggers // select soft pion candidates auto trackParSoftPi = getTrackPar(trackSoftPi); - o2::gpu::gpustd::array dcaSoftPi{trackSoftPi.dcaXY(), trackSoftPi.dcaZ()}; + std::array dcaSoftPi{trackSoftPi.dcaXY(), trackSoftPi.dcaZ()}; std::array pVecSoftPi = trackSoftPi.pVector(); if (trackSoftPi.collisionId() != thisCollId) { // This is a track reassociated to this PV by the track-to-collision-associator @@ -1123,7 +1478,7 @@ struct HfFilter { // Main struct for HF triggers o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParSoftPi, 2.f, noMatCorr, &dcaSoftPi); getPxPyPz(trackParSoftPi, pVecSoftPi); } - int8_t isSoftPionSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackSoftPi, trackParSoftPi, dcaSoftPi, kSigmaCPPK); + int16_t isSoftPionSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackSoftPi, trackParSoftPi, dcaSoftPi); if (TESTBIT(isSoftPionSelected, kSoftPionForSigmaC) /*&& (TESTBIT(is3Prong[2], 0) || TESTBIT(is3Prong[2], 1))*/) { // check the mass of the SigmaC++ candidate @@ -1200,7 +1555,7 @@ struct HfFilter { // Main struct for HF triggers if (!helper.isSelectedPhoton(photon, std::array{posTrack, negTrack}, activateQA, hV0Selected, hArmPod)) { continue; } - gpu::gpustd::array dcaInfo; + std::array dcaInfo; std::array pVecPhoton = {photon.px(), photon.py(), photon.pz()}; std::array posVecPhoton = {photon.vx(), photon.vy(), photon.vz()}; auto trackParPhoton = o2::track::TrackPar(posVecPhoton, pVecPhoton, 0, true); @@ -1321,7 +1676,7 @@ struct HfFilter { // Main struct for HF triggers // select soft pion candidates auto trackParSoftPi = getTrackPar(trackSoftPi); - o2::gpu::gpustd::array dcaSoftPi{trackSoftPi.dcaXY(), trackSoftPi.dcaZ()}; + std::array dcaSoftPi{trackSoftPi.dcaXY(), trackSoftPi.dcaZ()}; std::array pVecSoftPi = trackSoftPi.pVector(); if (trackSoftPi.collisionId() != thisCollId) { // This is a track reassociated to this PV by the track-to-collision-associator @@ -1329,7 +1684,7 @@ struct HfFilter { // Main struct for HF triggers o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParSoftPi, 2.f, noMatCorr, &dcaSoftPi); getPxPyPz(trackParSoftPi, pVecSoftPi); } - int8_t isSoftPionSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackSoftPi, trackParSoftPi, dcaSoftPi, kSigmaC0K0); + int16_t isSoftPionSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackSoftPi, trackParSoftPi, dcaSoftPi); if (TESTBIT(isSoftPionSelected, kSoftPionForSigmaC) /*&& (TESTBIT(is3Prong[2], 0) || TESTBIT(is3Prong[2], 1))*/) { // check the mass of the SigmaC0 candidate @@ -1387,10 +1742,25 @@ struct HfFilter { // Main struct for HF triggers } } // end loop over 3-prong candidates - if (!keepEvent[kCharmBarToXiBach]) { + if (!keepEvent[kCharmBarToXiBach] || !keepEvent[kCharmBarToXi2Bach]) { auto cascThisColl = cascades.sliceBy(cascPerCollision, thisCollId); for (const auto& casc : cascThisColl) { + bool hasStrangeTrack{false}; + + TracksIUPID::iterator cascTrack; + int requireStrangenessTrackingAny = requireStrangenessTracking->get(0u, 0u) + requireStrangenessTracking->get(0u, 1u); + if (requireStrangenessTrackingAny > 0) { // enabled for at least one of the two + auto trackedCascIdThisColl = trackedCasc.sliceBy(trackedCascadesPerCollision, thisCollId); + for (const auto& trackedCascId : trackedCascIdThisColl) { + if (trackedCascId.cascadeId() == casc.globalIndex()) { + hasStrangeTrack = true; + cascTrack = trackedCascId.track_as(); + break; + } + } + } + CascCand cascCand; if (!helper.buildCascade(casc, v0s, tracksIU, collision, dfStrangeness, {}, cascCand)) { continue; @@ -1401,7 +1771,10 @@ struct HfFilter { // Main struct for HF triggers } if (activateQA) { - hMassXi->Fill(cascCand.mXi); + hMassXi[0]->Fill(cascCand.mXi); + if (hasStrangeTrack) { + hMassXi[1]->Fill(cascCand.mXi); + } } auto bachelorCascId = casc.bachelorId(); @@ -1409,57 +1782,98 @@ struct HfFilter { // Main struct for HF triggers auto v0DauPosId = v0.posTrackId(); auto v0DauNegId = v0.negTrackId(); + // propagate to PV + std::array dcaInfo; + o2::track::TrackParCov trackParCasc; + o2::track::TrackParCov trackParCascTrack; + if (requireStrangenessTrackingAny < 2) { // needed for at least one of the two + trackParCasc = o2::track::TrackParCov(cascCand.vtx, cascCand.mom, cascCand.cov, cascCand.sign, true); + trackParCasc.setPID(o2::track::PID::XiMinus); + trackParCasc.setAbsCharge(1); // to be sure + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCasc, 2.f, matCorr, &dcaInfo); + } + if (requireStrangenessTrackingAny > 0 && hasStrangeTrack) { // needed for at least one of the two + trackParCascTrack = getTrackParCov(cascTrack); + trackParCascTrack.setPID(o2::track::PID::XiMinus); + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCascTrack, 2.f, matCorr, &dcaInfo); + } + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - for (const auto& trackId : trackIdsThisCollision) { // start loop over tracks + for (const auto& trackId : trackIdsThisCollision) { // start loop over tracks (first bachelor) auto track = tracks.rawIteratorAt(trackId.trackId()); - // ask for opposite sign daughters (omegac daughters) - if (track.sign() * cascCand.sign > 0) { - continue; - } - // check if track is one of the Xi daughters if (track.globalIndex() == bachelorCascId || track.globalIndex() == v0DauPosId || track.globalIndex() == v0DauNegId) { continue; } - // propagate to PV - gpu::gpustd::array dcaInfo; - std::array pVecCascade = cascCand.mom; - auto trackParCasc = o2::track::TrackPar(cascCand.vtx, cascCand.mom, cascCand.sign, true); - trackParCasc.setPID(o2::track::PID::XiMinus); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCasc, 2.f, matCorr, &dcaInfo); - getPxPyPz(trackParCasc, pVecCascade); - - auto trackParBachelor = getTrackPar(track); - std::array pVecBachelor = track.pVector(); + auto trackParBachelor = getTrackParCov(track); + std::array dcaInfoBach; if (track.collisionId() != thisCollId) { - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParBachelor, 2.f, noMatCorr, &dcaInfo); - getPxPyPz(trackParBachelor, pVecBachelor); + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParBachelor, 2.f, noMatCorr, &dcaInfoBach); } - auto isSelBachelor = helper.isSelectedBachelorForCharmBaryon(track, dcaInfo); + auto isSelBachelor = helper.isSelectedBachelorForCharmBaryon(track, dcaInfoBach); if (isSelBachelor == kRejected) { continue; } - auto ptCharmBaryon = RecoDecay::pt(RecoDecay::pVec(pVecCascade, pVecBachelor)); + if (!keepEvent[kCharmBarToXiBach] && track.sign() * cascCand.sign < 0) { // XiPi and XiKa - if (!keepEvent[kCharmBarToXiBach] && TESTBIT(isSelBachelor, kPionForCharmBaryon)) { - auto massXiPi = RecoDecay::m(std::array{pVecCascade, pVecBachelor}, std::array{massXi, massPi}); - if (ptCharmBaryon > cutsXiBachelor->get(0u, 0u) && massXiPi >= cutsXiBachelor->get(0u, 2u) && massXiPi <= 2.8f) { - keepEvent[kCharmBarToXiBach] = true; - if (activateQA) { - hMassVsPtC[kNCharmParticles + 15]->Fill(ptCharmBaryon, massXiPi); + bool isSelXiBach{false}; + if (requireStrangenessTracking->get(0u, 0u) > 0) { + if (hasStrangeTrack) { + isSelXiBach = helper.isSelectedXiBach(trackParCascTrack, trackParBachelor, isSelBachelor, collision, df2, activateQA, hMassVsPtC[kNCharmParticles + 15], hMassVsPtC[kNCharmParticles + 16]); } + } else { + isSelXiBach = helper.isSelectedXiBach(trackParCasc, trackParBachelor, isSelBachelor, collision, dfStrangeness, activateQA, hMassVsPtC[kNCharmParticles + 15], hMassVsPtC[kNCharmParticles + 16]); } - } - if (!keepEvent[kCharmBarToXiBach] && TESTBIT(isSelBachelor, kKaonForCharmBaryon)) { - auto massXiKa = RecoDecay::m(std::array{pVecCascade, pVecBachelor}, std::array{massXi, massKa}); - if (ptCharmBaryon > cutsXiBachelor->get(0u, 1u) && massXiKa >= cutsXiBachelor->get(0u, 3u) && massXiKa <= 2.8f) { + if (isSelXiBach) { keepEvent[kCharmBarToXiBach] = true; - if (activateQA) { - hMassVsPtC[kNCharmParticles + 16]->Fill(ptCharmBaryon, massXiKa); + } + } + + // only pions needed below + if (!TESTBIT(isSelBachelor, kPionForCharmBaryon)) { + continue; + } + + if (!keepEvent[kCharmBarToXi2Bach]) { + for (const auto& trackIdSecond : trackIdsThisCollision) { // start loop over tracks (second bachelor) + auto trackSecond = tracks.rawIteratorAt(trackIdSecond.trackId()); + + // check if track is one of the Xi daughters + if (trackSecond.globalIndex() == track.globalIndex() || trackSecond.globalIndex() == bachelorCascId || trackSecond.globalIndex() == v0DauPosId || trackSecond.globalIndex() == v0DauNegId) { + continue; + } + + if (track.sign() * trackSecond.sign() < 0 || track.sign() * cascCand.sign > 0) { // we want same sign pions, opposite to the xi + continue; + } + + auto trackParBachelorSecond = getTrackParCov(trackSecond); + std::array dcaInfoBachSecond; + if (trackSecond.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParBachelorSecond, 2.f, noMatCorr, &dcaInfoBachSecond); + } + + auto isSelBachelorSecond = helper.isSelectedBachelorForCharmBaryon(trackSecond, dcaInfoBachSecond); + if (!TESTBIT(isSelBachelorSecond, kPionForCharmBaryon)) { + continue; + } + if (!keepEvent[kCharmBarToXi2Bach]) { // XiPiPi + + bool isSelXiBachBach{false}; + if (requireStrangenessTracking->get(0u, 1u) > 0) { + if (hasStrangeTrack) { + isSelXiBachBach = helper.isSelectedXiBachBach<3>(trackParCascTrack, {trackParBachelor, trackParBachelorSecond}, collision, df3, activateQA, hMassVsPtC[kNCharmParticles + 17]); + } + } else { // vertex with only the two bachelors + isSelXiBachBach = helper.isSelectedXiBachBach<2>(trackParCasc, {trackParBachelor, trackParBachelorSecond}, collision, df2, activateQA, hMassVsPtC[kNCharmParticles + 17]); + } + if (isSelXiBachBach) { + keepEvent[kCharmBarToXi2Bach] = true; + } } } } @@ -1468,9 +1882,13 @@ struct HfFilter { // Main struct for HF triggers } auto n2Prongs = helper.computeNumberOfCandidates(indicesDau2Prong); + auto n2ProngsPrompt = helper.computeNumberOfCandidates(indicesDau2ProngPrompt); auto n3Prongs = helper.computeNumberOfCandidates(indicesDau3Prong); + auto n3ProngsPrompt = helper.computeNumberOfCandidates(indicesDau3ProngPrompt); indicesDau2Prong.insert(indicesDau2Prong.end(), indicesDau3Prong.begin(), indicesDau3Prong.end()); auto n23Prongs = helper.computeNumberOfCandidates(indicesDau2Prong); + indicesDau2ProngPrompt.insert(indicesDau2ProngPrompt.end(), indicesDau3ProngPrompt.begin(), indicesDau3ProngPrompt.end()); + auto n23ProngsPrompt = helper.computeNumberOfCandidates(indicesDau2ProngPrompt); if (activateQA) { hN2ProngCharmCand->Fill(n2Prongs); @@ -1478,13 +1896,31 @@ struct HfFilter { // Main struct for HF triggers } if (n2Prongs > 1 && enableDoubleCharmChannels->get(0u, 0u)) { - keepEvent[kDoubleCharm2P] = true; + if (enableDoubleCharmChannels->get(1u, 0u)) { + keepEvent[kDoubleCharm2P] = true; + } else { + if (n2ProngsPrompt > 1) { + keepEvent[kDoubleCharm2P] = true; + } + } } if (n3Prongs > 1 && enableDoubleCharmChannels->get(0u, 1u)) { - keepEvent[kDoubleCharm3P] = true; + if (enableDoubleCharmChannels->get(1u, 1u)) { + keepEvent[kDoubleCharm3P] = true; + } else { + if (n3ProngsPrompt > 1) { + keepEvent[kDoubleCharm3P] = true; + } + } } if (n23Prongs > 1 && enableDoubleCharmChannels->get(0u, 2u)) { - keepEvent[kDoubleCharmMix] = true; + if (enableDoubleCharmChannels->get(1u, 2u)) { + keepEvent[kDoubleCharmMix] = true; + } else { + if (n23ProngsPrompt > 1) { + keepEvent[kDoubleCharmMix] = true; + } + } } // apply downscale factors, if required @@ -1497,7 +1933,7 @@ struct HfFilter { // Main struct for HF triggers } } - tags(keepEvent[kHighPt2P], keepEvent[kHighPt3P], keepEvent[kBeauty3P], keepEvent[kBeauty4P], keepEvent[kFemto2P], keepEvent[kFemto3P], keepEvent[kDoubleCharm2P], keepEvent[kDoubleCharm3P], keepEvent[kDoubleCharmMix], keepEvent[kV0Charm2P], keepEvent[kV0Charm3P], keepEvent[kCharmBarToXiBach], keepEvent[kSigmaCPPK], keepEvent[kSigmaC0K0], keepEvent[kPhotonCharm2P], keepEvent[kPhotonCharm3P], keepEvent[kSingleCharm2P], keepEvent[kSingleCharm3P], keepEvent[kSingleNonPromptCharm2P], keepEvent[kSingleNonPromptCharm3P]); + tags(keepEvent[kHighPt2P], keepEvent[kHighPt3P], keepEvent[kBeauty3P], keepEvent[kBeauty4P], keepEvent[kFemto2P], keepEvent[kFemto3P], keepEvent[kDoubleCharm2P], keepEvent[kDoubleCharm3P], keepEvent[kDoubleCharmMix], keepEvent[kV0Charm2P], keepEvent[kV0Charm3P], keepEvent[kCharmBarToXiBach], keepEvent[kSigmaCPPK], keepEvent[kSigmaC0K0], keepEvent[kPhotonCharm2P], keepEvent[kPhotonCharm3P], keepEvent[kSingleCharm2P], keepEvent[kSingleCharm3P], keepEvent[kSingleNonPromptCharm2P], keepEvent[kSingleNonPromptCharm3P], keepEvent[kCharmBarToXi2Bach], keepEvent[kPrCharm2P], keepEvent[kBtoJPsiKa], keepEvent[kBtoJPsiKstar], keepEvent[kBtoJPsiPhi], keepEvent[kBtoJPsiPrKa], keepEvent[kBtoJPsiPi]); if (!std::accumulate(keepEvent, keepEvent + kNtriggersHF, 0)) { hProcessedEvents->Fill(1); diff --git a/EventFiltering/PWGHF/HFFilterCharmHadronSignals.cxx b/EventFiltering/PWGHF/HFFilterCharmHadronSignals.cxx index 11796fc9d21..3cd5a047bb9 100644 --- a/EventFiltering/PWGHF/HFFilterCharmHadronSignals.cxx +++ b/EventFiltering/PWGHF/HFFilterCharmHadronSignals.cxx @@ -8,32 +8,53 @@ // 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 includes /// \file HFFilterCharmHadronSignals.cxx /// \brief task for the quality control of the signals of D0, D+, Ds+, Lc+, and D*+ selected in the HFFilter.cxx task /// /// \author Fabrizio Grosa , CERN -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DetectorsBase/Propagator.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - +#include "EventFiltering/PWGHF/HFFilterHelpers.h" +// +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +// +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/CollisionAssociationTables.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" - -#include "EventFiltering/filterTables.h" -#include "EventFiltering/PWGHF/HFFilterHelpers.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -49,11 +70,11 @@ struct HfFilterCharmHadronSignals { // Main struct for HF triggers // parameters for ML application Configurable> pTBinsBDT{"pTBinsBDT", std::vector{hf_cuts_bdt_multiclass::vecBinsPt}, "track pT bin limits for BDT cut"}; - Configurable> thresholdBDTScoreD0ToKPi{"thresholdBDTScoreD0ToKPi", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of D0 candidates"}; - Configurable> thresholdBDTScoreDPlusToPiKPi{"thresholdBDTScoreDPlusToPiKPi", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of D+ candidates"}; - Configurable> thresholdBDTScoreDSToPiKK{"thresholdBDTScoreDSToPiKK", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Ds+ candidates"}; - Configurable> thresholdBDTScoreLcToPiKP{"thresholdBDTScoreLcToPiKP", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Lc+ candidates"}; - Configurable> thresholdBDTScoreXicToPiKP{"thresholdBDTScoreXicToPiKP", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Xic+ candidates"}; + Configurable> thresholdBDTScoreD0ToKPi{"thresholdBDTScoreD0ToKPi", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of D0 candidates"}; + Configurable> thresholdBDTScoreDPlusToPiKPi{"thresholdBDTScoreDPlusToPiKPi", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of D+ candidates"}; + Configurable> thresholdBDTScoreDSToPiKK{"thresholdBDTScoreDSToPiKK", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Ds+ candidates"}; + Configurable> thresholdBDTScoreLcToPiKP{"thresholdBDTScoreLcToPiKP", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Lc+ candidates"}; + Configurable> thresholdBDTScoreXicToPiKP{"thresholdBDTScoreXicToPiKP", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Xic+ candidates"}; Configurable paramCharmMassShape{"paramCharmMassShape", "2023_pass3", "Parametrisation of charm-hadron mass shape (options: 2023_pass3)"}; Configurable numSigmaDeltaMassCharmHad{"numSigmaDeltaMassCharmHad", 2.5, "Number of sigma for charm-hadron delta mass cut in B and D resonance triggers"}; @@ -63,7 +84,7 @@ struct HfFilterCharmHadronSignals { // Main struct for HF triggers Configurable minDeltaMassDstar{"minDeltaMassDstar", static_cast(cutsCharmReso[0][0]), "minimum invariant-mass delta for D*+ in GeV/c2"}; Configurable maxDeltaMassDstar{"maxDeltaMassDstar", static_cast(cutsCharmReso[1][0]), "maximum invariant-mass delta for D*+ in GeV/c2"}; Configurable> pTBinsTrack{"pTBinsTrack", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for DCAXY pT-dependent cut (D* from beauty)"}; - Configurable> cutsTrackBeauty3Prong{"cutsTrackBeauty3Prong", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 3-prong beauty candidates"}; + Configurable> cutsTrackBeauty3Prong{"cutsTrackBeauty3Prong", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 3-prong beauty candidates"}; // CCDB configuration Service ccdb; @@ -97,7 +118,7 @@ struct HfFilterCharmHadronSignals { // Main struct for HF triggers { helper.setPtLimitsDstarSoftPion(minPtSoftPion, maxPtSoftPion); helper.setPtBinsSingleTracks(pTBinsTrack); - helper.setCutsSingleTrackBeauty(cutsTrackBeauty3Prong, cutsTrackBeauty3Prong); + helper.setCutsSingleTrackBeauty(cutsTrackBeauty3Prong, cutsTrackBeauty3Prong, cutsTrackBeauty3Prong); helper.setMassResolParametrisation(paramCharmMassShape); helper.setNumSigmaForDeltaMassCharmHadCut(numSigmaDeltaMassCharmHad); @@ -159,8 +180,8 @@ struct HfFilterCharmHadronSignals { // Main struct for HF triggers auto trackParPos = getTrackPar(trackPos); auto trackParNeg = getTrackPar(trackNeg); - o2::gpu::gpustd::array dcaPos{trackPos.dcaXY(), trackPos.dcaZ()}; - o2::gpu::gpustd::array dcaNeg{trackNeg.dcaXY(), trackNeg.dcaZ()}; + std::array dcaPos{trackPos.dcaXY(), trackPos.dcaZ()}; + std::array dcaNeg{trackNeg.dcaXY(), trackNeg.dcaZ()}; std::array pVecPos{trackPos.pVector()}; std::array pVecNeg{trackNeg.pVector()}; if (trackPos.collisionId() != thisCollId) { @@ -215,13 +236,13 @@ struct HfFilterCharmHadronSignals { // Main struct for HF triggers } auto trackParThird = getTrackPar(track); - o2::gpu::gpustd::array dcaThird{track.dcaXY(), track.dcaZ()}; + std::array dcaThird{track.dcaXY(), track.dcaZ()}; std::array pVecThird = track.pVector(); if (track.collisionId() != thisCollId) { o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParThird, 2.f, noMatCorr, &dcaThird); getPxPyPz(trackParThird, pVecThird); } - auto isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(track, trackParThird, dcaThird, kBeauty3P); + auto isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(track, trackParThird, dcaThird); if (TESTBIT(isTrackSelected, kSoftPion)) { std::array massDausD0{massPi, massKa}; auto invMassD0dau = invMassD0; @@ -265,9 +286,9 @@ struct HfFilterCharmHadronSignals { // Main struct for HF triggers auto trackParFirst = getTrackPar(trackFirst); auto trackParSecond = getTrackPar(trackSecond); auto trackParThird = getTrackPar(trackThird); - o2::gpu::gpustd::array dcaFirst{trackFirst.dcaXY(), trackFirst.dcaZ()}; - o2::gpu::gpustd::array dcaSecond{trackSecond.dcaXY(), trackSecond.dcaZ()}; - o2::gpu::gpustd::array dcaThird{trackThird.dcaXY(), trackThird.dcaZ()}; + std::array dcaFirst{trackFirst.dcaXY(), trackFirst.dcaZ()}; + std::array dcaSecond{trackSecond.dcaXY(), trackSecond.dcaZ()}; + std::array dcaThird{trackThird.dcaXY(), trackThird.dcaZ()}; std::array pVecFirst = trackFirst.pVector(); std::array pVecSecond = trackSecond.pVector(); std::array pVecThird = trackThird.pVector(); diff --git a/EventFiltering/PWGHF/HFFilterHelpers.h b/EventFiltering/PWGHF/HFFilterHelpers.h index f651a4cc83e..e6202c5a000 100644 --- a/EventFiltering/PWGHF/HFFilterHelpers.h +++ b/EventFiltering/PWGHF/HFFilterHelpers.h @@ -8,7 +8,6 @@ // 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 includes /// \file HFFilterHelpers.h /// \brief Header file with definition of variables, methods, and tables used in the HFFilter.cxx task @@ -18,42 +17,52 @@ /// \author Alexandre Bigot , Strasbourg University /// \author Biao Zhang , CCNU /// \author Federica Zanone , Heidelberg University +/// \author Antonio Palasciano , INFN Bari #ifndef EVENTFILTERING_PWGHF_HFFILTERHELPERS_H_ #define EVENTFILTERING_PWGHF_HFFILTERHELPERS_H_ +#include "EventFiltering/filterTables.h" +// +#include "PWGHF/Core/SelectorCuts.h" +// +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) +#include +#include +#include +#include + +#include + #include #include #include +#include +#include #include -#include #include +#include #include -#include "Math/GenVector/Boost.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" - -#include "CCDB/CcdbApi.h" -#include "CCDB/BasicCCDBManager.h" -#include "CommonConstants/MathConstants.h" -#include "CommonConstants/PhysicsConstants.h" -#include "DataFormatsTPC/BetheBlochAleph.h" -#include "DCAFitter/DCAFitterN.h" -#include "DetectorsBase/Propagator.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/DataTypes.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/AnalysisHelpers.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "EventFiltering/filterTables.h" - namespace o2::aod { @@ -81,6 +90,13 @@ enum HfTriggers { kSingleCharm3P, kSingleNonPromptCharm2P, kSingleNonPromptCharm3P, + kCharmBarToXi2Bach, + kPrCharm2P, + kBtoJPsiKa, + kBtoJPsiKstar, + kBtoJPsiPhi, + kBtoJPsiPrKa, + kBtoJPsiPi, kNtriggersHF }; @@ -96,6 +112,7 @@ enum charmParticles { enum beautyParticles { kBplus = 0, kB0toDStar, + kBc, kB0, kBs, kLb, @@ -103,6 +120,15 @@ enum beautyParticles { kNBeautyParticles }; +enum beautyToJPsiParticles { + kBplusToJPsi = 0, + kB0ToJPsi, + kBsToJPsi, + kLbToJPsi, + kBcToJPsi, + kNBeautyParticlesToJPsi +}; + enum bachelorTrackSelection { kRejected = 0, kSoftPion, @@ -110,6 +136,7 @@ enum bachelorTrackSelection { kSoftPionForBeauty, kPionForCharmBaryon, kKaonForCharmBaryon, + kProtonForCharmBaryon, kSoftPionForSigmaC }; @@ -191,6 +218,7 @@ struct V0Cand { struct CascCand { std::array mom; std::array vtx; + std::array cov; V0Cand v0; float ptBach; float etaBach; @@ -213,10 +241,11 @@ struct CascCand { }; static const std::array charmParticleNames{"D0", "Dplus", "Ds", "Lc", "Xic"}; -static const std::array beautyParticleNames{"Bplus", "B0toDStar", "B0", "Bs", "Lb", "Xib"}; +static const int nTotBeautyParts = static_cast(kNBeautyParticles) + static_cast(kNBeautyParticlesToJPsi); +static const std::array beautyParticleNames{"Bplus", "B0toDStar", "Bc", "B0", "Bs", "Lb", "Xib", "BplusToJPsi", "B0ToJPsi", "BsToJPsi", "LbToJPsi", "BcToJPsi"}; static const std::array pdgCodesCharm{421, 411, 431, 4122, 4232}; static const std::array eventTitles = {"all", "rejected"}; -static const std::vector hfTriggerNames{filtering::HfHighPt2P::columnLabel(), filtering::HfHighPt3P::columnLabel(), filtering::HfBeauty3P::columnLabel(), filtering::HfBeauty4P::columnLabel(), filtering::HfFemto2P::columnLabel(), filtering::HfFemto3P::columnLabel(), filtering::HfDoubleCharm2P::columnLabel(), filtering::HfDoubleCharm3P::columnLabel(), filtering::HfDoubleCharmMix::columnLabel(), filtering::HfV0Charm2P::columnLabel(), filtering::HfV0Charm3P::columnLabel(), filtering::HfCharmBarToXiBach::columnLabel(), filtering::HfSigmaCPPK::columnLabel(), filtering::HfSigmaC0K0::columnLabel(), filtering::HfPhotonCharm2P::columnLabel(), filtering::HfPhotonCharm3P::columnLabel(), filtering::HfSingleCharm2P::columnLabel(), filtering::HfSingleCharm3P::columnLabel(), filtering::HfSingleNonPromptCharm2P::columnLabel(), filtering::HfSingleNonPromptCharm3P::columnLabel()}; +static const std::vector hfTriggerNames{filtering::HfHighPt2P::columnLabel(), filtering::HfHighPt3P::columnLabel(), filtering::HfBeauty3P::columnLabel(), filtering::HfBeauty4P::columnLabel(), filtering::HfFemto2P::columnLabel(), filtering::HfFemto3P::columnLabel(), filtering::HfDoubleCharm2P::columnLabel(), filtering::HfDoubleCharm3P::columnLabel(), filtering::HfDoubleCharmMix::columnLabel(), filtering::HfV0Charm2P::columnLabel(), filtering::HfV0Charm3P::columnLabel(), filtering::HfCharmBarToXiBach::columnLabel(), filtering::HfSigmaCPPK::columnLabel(), filtering::HfSigmaC0K0::columnLabel(), filtering::HfPhotonCharm2P::columnLabel(), filtering::HfPhotonCharm3P::columnLabel(), filtering::HfSingleCharm2P::columnLabel(), filtering::HfSingleCharm3P::columnLabel(), filtering::HfSingleNonPromptCharm2P::columnLabel(), filtering::HfSingleNonPromptCharm3P::columnLabel(), filtering::HfCharmBarToXi2Bach::columnLabel(), filtering::HfPrCharm2P::columnLabel(), filtering::HfBtoJPsiKa::columnLabel(), filtering::HfBtoJPsiKstar::columnLabel(), filtering::HfBtoJPsiPhi::columnLabel(), filtering::HfBtoJPsiPrKa::columnLabel(), filtering::HfBtoJPsiPi::columnLabel()}; static const std::array v0Labels{"#gamma", "K_{S}^{0}", "#Lambda", "#bar{#Lambda}"}; static const std::array v0Names{"Photon", "K0S", "Lambda", "AntiLambda"}; @@ -231,6 +260,7 @@ static const std::tuple pdgCharmDaughters{ constexpr float massPi = o2::constants::physics::MassPiPlus; constexpr float massKa = o2::constants::physics::MassKPlus; constexpr float massProton = o2::constants::physics::MassProton; +constexpr float massMu = o2::constants::physics::MassMuon; constexpr float massDeuteron = o2::constants::physics::MassDeuteron; constexpr float massGamma = o2::constants::physics::MassGamma; constexpr float massK0S = o2::constants::physics::MassK0Short; @@ -248,20 +278,23 @@ constexpr float massB0 = o2::constants::physics::MassB0; constexpr float massBs = o2::constants::physics::MassBS; constexpr float massLb = o2::constants::physics::MassLambdaB0; constexpr float massXib = o2::constants::physics::MassXiB0; +constexpr float massBc = o2::constants::physics::MassBCPlus; constexpr float massSigmaCPlusPlus = o2::constants::physics::MassSigmaCPlusPlus; constexpr float massSigmaC0 = o2::constants::physics::MassSigmaC0; +constexpr float massK0Star892 = o2::constants::physics::MassK0Star892; +constexpr float massJPsi = o2::constants::physics::MassJPsi; static const o2::framework::AxisSpec ptAxis{50, 0.f, 50.f}; static const o2::framework::AxisSpec pAxis{50, 0.f, 10.f}; -static const o2::framework::AxisSpec kstarAxis{100, 0.f, 1.f}; +static const o2::framework::AxisSpec kstarAxis{200, 0.f, 2.f}; static const o2::framework::AxisSpec etaAxis{30, -1.5f, 1.5f}; static const o2::framework::AxisSpec nSigmaAxis{100, -10.f, 10.f}; static const o2::framework::AxisSpec alphaAxis{100, -1.f, 1.f}; static const o2::framework::AxisSpec qtAxis{100, 0.f, 0.25f}; static const o2::framework::AxisSpec bdtAxis{100, 0.f, 1.f}; static const o2::framework::AxisSpec phiAxis{36, 0., o2::constants::math::TwoPI}; -static const std::array massAxisC = {o2::framework::AxisSpec{100, 1.65f, 2.05f}, o2::framework::AxisSpec{100, 1.65f, 2.05f}, o2::framework::AxisSpec{100, 1.75f, 2.15f}, o2::framework::AxisSpec{100, 2.05f, 2.45f}, o2::framework::AxisSpec{100, 2.25f, 2.65f}, o2::framework::AxisSpec{100, 0.139f, 0.159f}, o2::framework::AxisSpec{100, 0.f, 0.25f}, o2::framework::AxisSpec{100, 0.f, 0.25f}, o2::framework::AxisSpec{200, 0.48f, 0.88f}, o2::framework::AxisSpec{200, 0.48f, 0.88f}, o2::framework::AxisSpec{100, 1.1f, 1.4f}, o2::framework::AxisSpec{100, 1.1f, 1.4f}, o2::framework::AxisSpec{100, 1.1f, 1.4f}, o2::framework::AxisSpec{100, 1.1f, 1.4f}, o2::framework::AxisSpec{170, 0.13f, 0.3f}, o2::framework::AxisSpec{170, 0.13f, 0.3f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{100, 2.3f, 2.9f}, o2::framework::AxisSpec{100, 2.3f, 2.9f}}; -static const std::array massAxisB = {o2::framework::AxisSpec{240, 4.8f, 6.0f}, o2::framework::AxisSpec{240, 4.8f, 6.0f}, o2::framework::AxisSpec{240, 4.8f, 6.0f}, o2::framework::AxisSpec{240, 4.8f, 6.0f}, o2::framework::AxisSpec{240, 5.0f, 6.2f}, o2::framework::AxisSpec{240, 5.0f, 6.2f}}; +static const std::array massAxisC = {o2::framework::AxisSpec{250, 1.65f, 2.15f}, o2::framework::AxisSpec{250, 1.65f, 2.15f}, o2::framework::AxisSpec{250, 1.75f, 2.25f}, o2::framework::AxisSpec{250, 2.05f, 2.55f}, o2::framework::AxisSpec{250, 2.25f, 2.75f}, o2::framework::AxisSpec{200, 0.139f, 0.159f}, o2::framework::AxisSpec{250, 0.f, 0.25f}, o2::framework::AxisSpec{250, 0.f, 0.25f}, o2::framework::AxisSpec{200, 0.48f, 0.88f}, o2::framework::AxisSpec{200, 0.48f, 0.88f}, o2::framework::AxisSpec{200, 1.1f, 1.4f}, o2::framework::AxisSpec{200, 1.1f, 1.4f}, o2::framework::AxisSpec{200, 1.1f, 1.4f}, o2::framework::AxisSpec{200, 1.1f, 1.4f}, o2::framework::AxisSpec{170, 0.13f, 0.3f}, o2::framework::AxisSpec{170, 0.13f, 0.3f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{200, 0.4f, 0.8f}, o2::framework::AxisSpec{350, 2.3f, 3.0f}, o2::framework::AxisSpec{350, 2.3f, 3.0f}, o2::framework::AxisSpec{350, 2.3f, 3.0f}, o2::framework::AxisSpec{240, 2.4f, 3.6f}, o2::framework::AxisSpec{300, 0.7f, 1.3f}, o2::framework::AxisSpec{300, 0.7f, 1.3f}, o2::framework::AxisSpec{300, 0.7f, 1.3f}, o2::framework::AxisSpec{300, 0.7f, 1.3f}}; +static const std::array massAxisB = {o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 5.4f, 7.4f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.4f, 6.4f}, o2::framework::AxisSpec{400, 5.0f, 6.6f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{500, 4.2f, 6.2f}, o2::framework::AxisSpec{400, 5.0f, 6.6f}, o2::framework::AxisSpec{240, 5.8f, 7.0f}}; // default values for configurables // channels to trigger on for femto @@ -273,17 +306,25 @@ constexpr float cutsPtThresholdsForFemto[1][2] = {{8., 1.4}}; // proton, deutero static const std::vector labelsColumnsPtThresholdsForFemto = {"Proton", "Deuteron"}; // min and max pT for all tracks combined (except for V0 and cascades) -constexpr float cutsPt[2][7] = {{1., 0.1, 0.8, 0.5, 0.1, 0.2, 0.4}, - {100000., 100000., 5., 100000., 100000., 100000., 100000.}}; // beauty, D*, femto, SigmaC, Xic*+ -> SigmaC++K- -static const std::vector labelsColumnsCutsPt = {"Beauty", "DstarPlus", "PrForFemto", "CharmBaryon", "SoftPiSigmaC", "SoftKaonXicResoToSigmaC", "DeForFemto"}; +constexpr float cutsPt[2][10] = {{1., 0.1, 0.8, 0.5, 0.1, 0.2, 0.4, 0.5, 0.3, 0.3}, + {100000., 100000., 5., 100000., 100000., 100000., 100000., 100000., 100000., 100000.}}; // beauty, D*, femto, SigmaC, Xic*+ -> SigmaC++K-, beauty to JPsi, Lc*->D0p +static const std::vector labelsColumnsCutsPt = {"Beauty", "DstarPlus", "PrForFemto", "CharmBaryon", "SoftPiSigmaC", "SoftKaonXicResoToSigmaC", "DeForFemto", "BeautyToJPsi", "PrForLcReso", "PrForThetaC"}; static const std::vector labelsRowsCutsPt = {"Minimum", "Maximum"}; // PID cuts -constexpr float cutsNsigma[3][7] = {{3., 3., 3., 5., 3., 3., 5.}, // TPC proton from Lc, pi/K from D0, K from 3-prong, femto selected proton, pi/K from Xic/Omegac, K from Xic*->SigmaC-Kaon, femto selected deuteron - {3., 3., 3., 2.5, 3., 3., 5.}, // TOF proton from Lc, pi/K from D0, K from 3-prong, femto selected proton, pi/K from Xic/Omegac, K from Xic*->SigmaC-Kaon, femto selected deuteron - {999., 999., 999., 2.5, 999., 999., 5.}}; // Sum in quadrature of TPC and TOF (used only for femto selected proton and deuteron for pT < 4 GeV/c) -static const std::vector labelsColumnsNsigma = {"PrFromLc", "PiKaFromDZero", "KaFrom3Prong", "PrForFemto", "PiKaFromCharmBaryon", "SoftKaonFromXicResoToSigmaC", "DeForFemto"}; -static const std::vector labelsRowsNsigma = {"TPC", "TOF", "Comb"}; +constexpr float cutsNsigma[4][8] = { + {3., 3., 3., 5., 3., 3., 5., 3.}, // TPC proton from Lc, pi/K from D0, K from 3-prong, femto selected proton, pi/K from Xic/Omegac, K from Xic*->SigmaC-Kaon, femto selected deuteron, K/p from beauty->JPsiX + {3., 3., 3., 2.5, 3., 3., 5., 3.}, // TOF proton from Lc, pi/K from D0, K from 3-prong, femto selected proton, pi/K from Xic/Omegac, K from Xic*->SigmaC-Kaon, femto selected deuteron, K/p from beauty->JPsiX + {999., 999., 999., 2.5, 999., 999., 5., 999.}, // Sum in quadrature of TPC and TOF (used only for femto selected proton and deuteron for pT < 4 GeV/c) + {999., 999., 999., 999., 999., 999., -4., 999.} // ITS used only for femto selected deuteron for less than pt threshold +}; +static const std::vector labelsColumnsNsigma = {"PrFromLc", "PiKaFromDZero", "KaFrom3Prong", "PrForFemto", "PiKaFromCharmBaryon", "SoftKaonFromXicResoToSigmaC", "DeForFemto", "KaPrFromBeautyToJPsi"}; +static const std::vector labelsRowsNsigma = {"TPC", "TOF", "Comb", "ITS"}; + +// track cut +constexpr float cutsTrackQuality[2][7] = {{0., 0., 0., 999., 999., 0., 0.}, + {90, 80, 0.83, 160., 1., 5., 0.}}; +static const std::vector labelsColumnsTrackQuality = {"minTpcCluster", "minTpcRow", "minTpcCrossedOverFound", "maxTpcShared", "maxTpcFracShared", "minItsCluster", "minItsIbCluster"}; // high pt constexpr float cutsHighPtThresholds[1][2] = {{8., 8.}}; // 2-prongs, 3-prongs @@ -293,34 +334,41 @@ namespace hf_trigger_cuts_presel_beauty { static constexpr int nBinsPt = 2; static constexpr int nCutVars = 4; +static constexpr int nCutVarsBtoJPsi = 6; // default values for the pT bin edges (can be used to configure histogram axis) // common for any beauty candidate constexpr double binsPt[nBinsPt + 1] = { - 1., + 0., 5., 1000.0}; auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{0.4, -1, -1, 10.}, /* 1 < pt < 5 */ +constexpr double cuts[nBinsPt][nCutVars] = {{0.4, -1, -1, 10.}, /* 0 < pt < 5 */ {0.4, -1, -1, 10.}}; /* 5 < pt < 1000 */ +constexpr double cutsBtoJPsi[nBinsPt][nCutVarsBtoJPsi] = {{1., 0.6, 0.9, 0.02, 0.02, 0.1}, /* 0 < pt < 5 */ + {1., 0.8, 0.9, 0.02, 0.02, 0.1}}; /* 5 < pt < 1000 */ + // row labels static const std::vector labelsPt{}; // column labels -static const std::vector labelsRowsTopolBeauty = {"DeltaMassB", "minCPA", "minDecayLength", "maxImpParProd"}; +static const std::vector labelsColumnsTopolBeauty = {"DeltaMassB", "minCPA", "minDecayLength", "maxImpParProd"}; +static const std::vector labelsColumnsCutsBeautyToJPsi = {"minPtMuon", "DeltaMassB", "minCPA", "minDecayLength", "DeltaMassKK", "DeltaMassKPi"}; } // namespace hf_trigger_cuts_presel_beauty // double charm -constexpr int activeDoubleCharmChannels[1][3] = {{1, 1, 1}}; // kDoubleCharm2P, kDoubleCharm3P, kDoubleCharmMix +constexpr int activeDoubleCharmChannels[2][3] = {{1, 1, 1}, {1, 1, 0}}; // kDoubleCharm2P, kDoubleCharm3P, kDoubleCharmMix (second column to keep non-prompt) static const std::vector labelsColumnsDoubleCharmChannels = {"DoubleCharm2Prong", "DoubleCharm3Prong", "DoubleCharmMix"}; +static const std::vector labelsRowsDoubleCharmChannels = {"", "KeepNonprompt"}; // charm resonances -constexpr float cutsCharmReso[3][11] = {{0.0, 0.0, 0.0, 0.0, 0.4, 0., 0.0, 0.00, 0.21, 0.21, 0.0}, - {0.155, 0.3, 0.3, 0.88, 0.88, 1.35, 0.18, 0.18, 0.25, 0.25, 0.8}, - {0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 6.0, 0.0, 6.0, 0.0}}; // D*+, D*0, Ds*0, Ds1+, Ds2*+, Xic*->D, SigmaC0, SigmaC++, SigmaC(2520)0, SigmaC(2520)++, Xic*->SigmaC -static const std::vector labelsColumnsDeltaMassCharmReso = {"DstarPlus", "DstarZero", "DsStarZero", "Ds1Plus", "Ds2StarPlus", "XicResoToD", "SigmaC0", "SigmaCPlusPlus", "SigmaC02520", "SigmaCPlusPlus2520", "XicResoToSigmaC"}; -static const std::vector labelsRowsDeltaMassCharmReso = {"deltaMassMin", "deltaMassMax", "ptMin"}; +constexpr float cutsCharmReso[4][13] = {{0.0, 0.0, 0.0, 0.0, 0.4, 0., 0.0, 0.00, 0.21, 0.21, 0.0, 0.7, 0.7}, + {0.155, 0.3, 0.3, 0.88, 0.88, 1.35, 0.18, 0.18, 0.25, 0.25, 0.8, 1.3, 1.3}, + {0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 6.0, 0.0, 6.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; // D*+, D*0, Ds*0, Ds1+, Ds2*+, Xic*->D, SigmaC0, SigmaC++, SigmaC(2520)0, SigmaC(2520)++, Xic*->SigmaC, Lc*->D0P, Lc*->D*+P +static const std::vector labelsColumnsDeltaMassCharmReso = {"DstarPlus", "DstarZero", "DsStarZero", "Ds1Plus", "Ds2StarPlus", "XicResoToD", "SigmaC0", "SigmaCPlusPlus", "SigmaC02520", "SigmaCPlusPlus2520", "XicResoToSigmaC", "LcResoToD0Pr", "ThetaC"}; +static const std::vector labelsRowsDeltaMassCharmReso = {"deltaMassMin", "deltaMassMax", "ptMin", "ptMinCharmDaugh"}; // V0s for charm resonances constexpr float cutsV0s[1][6] = {{0.85, 0.97, 0.5, 4., 0.02, 0.01}}; // cosPaGamma, cosPaK0sLambda, radiusK0sLambda, nSigmaPrLambda, deltaMassK0S, deltaMassLambda static const std::vector labelsColumnsV0s = {"CosPaGamma", "CosPaK0sLambda", "RadiusK0sLambda", "NSigmaPrLambda", "DeltaMassK0s", "DeltaMassLambda"}; @@ -328,16 +376,19 @@ static const std::vector labelsColumnsV0s = {"CosPaGamma", "CosPaK0 // cascades for Xi + bachelor triggers constexpr float cutsCascades[1][8] = {{0.2, 1., 0.01, 0.01, 0.99, 0.99, 0.3, 3.}}; // ptXiBachelor, deltaMassXi, deltaMassLambda, cosPaXi, cosPaLambda, DCAxyXi, nSigmaPid static const std::vector labelsColumnsCascades = {"PtBachelor", "PtXi", "DeltaMassXi", "DeltaMassLambda", "CosPAXi", "CosPaLambda", "DCAxyXi", "NsigmaPid"}; -constexpr float cutsCharmBaryons[1][4] = {{3., 3., 2.35, 2.60}}; // MinPtXiPi, MinPtXiKa, MinMassXiPi, MinMassXiKa -static const std::vector labelsColumnsCharmBaryons = {"MinPtXiPi", "MinPtXiKa", "MinMassXiPi", "MinMassXiKa"}; +constexpr float cutsCharmBaryons[1][11] = {{5., 5., 1000., 2.35, 2.60, 2.35, 3., 3., 2.7, -2., -2.}}; // MinPtXiPi, MinPtXiKa, MinPtXiPiPi, MinMassXiPi, MinMassXiKa, MinMassXiPiPi, MaxMassXiPi, MaxMassXiKa, MaxMassXiPiPi, CosPaXiBach, CosPaXiBachBach +static const std::vector labelsColumnsCharmBarCuts = {"MinPtXiPi", "MinPtXiKa", "MinPtXiPiPi", "MinMassXiPi", "MinMassXiKa", "MinMassXiPiPi", "MaxMassXiPi", "MaxMassXiKa", "MaxMassXiPiPi", "CosPaXiBach", "CosPaXiBachBach"}; + +constexpr int requireStrangenessTrackedXi[1][2] = {{1, 0}}; +static const std::vector labelsColumnsCharmBaryons = {"CharmBarToXiBach", "CharmBarToXiBachBach"}; // dummy array static const std::vector labelsEmpty{}; -static constexpr double cutsTrackDummy[o2::analysis::hf_cuts_single_track::nBinsPtTrack][o2::analysis::hf_cuts_single_track::nCutVarsTrack] = {{0., 10.}, {0., 10.}, {0., 10.}, {0., 10.}, {0., 10.}, {0., 10.}}; -o2::framework::LabeledArray cutsSingleTrackDummy{cutsTrackDummy[0], o2::analysis::hf_cuts_single_track::nBinsPtTrack, o2::analysis::hf_cuts_single_track::nCutVarsTrack, o2::analysis::hf_cuts_single_track::labelsPtTrack, o2::analysis::hf_cuts_single_track::labelsCutVarTrack}; +static constexpr double cutsTrackDummy[o2::analysis::hf_cuts_single_track::NBinsPtTrack][o2::analysis::hf_cuts_single_track::NCutVarsTrack] = {{0., 10.}, {0., 10.}, {0., 10.}, {0., 10.}, {0., 10.}, {0., 10.}}; +o2::framework::LabeledArray cutsSingleTrackDummy{cutsTrackDummy[0], o2::analysis::hf_cuts_single_track::NBinsPtTrack, o2::analysis::hf_cuts_single_track::NCutVarsTrack, o2::analysis::hf_cuts_single_track::labelsPtTrack, o2::analysis::hf_cuts_single_track::labelsCutVarTrack}; // manual downscale factors for tests -constexpr double defDownscaleFactors[kNtriggersHF][1] = {{1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}}; // one for each trigger +constexpr double defDownscaleFactors[kNtriggersHF][1] = {{1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}, {1.1}}; // one for each trigger static const std::vector labelsDownscaleFactor = {"Downscale factor"}; // Main helper class @@ -366,20 +417,26 @@ class HfFilterHelper } void setPtBinsSingleTracks(std::vector ptBins) { mPtBinsTracks = ptBins; } void setPtBinsBeautyHadrons(std::vector ptBins) { mPtBinsBeautyHadrons = ptBins; } - void setCutsSingleTrackBeauty(o2::framework::LabeledArray cutsSingleTrack3P, o2::framework::LabeledArray cutsSingleTrack4P) + void setCutsSingleTrackBeauty(o2::framework::LabeledArray cutsSingleTrack3P, o2::framework::LabeledArray cutsSingleTrack4P, o2::framework::LabeledArray cutsSingleToJPsi) { mCutsSingleTrackBeauty3Prong = cutsSingleTrack3P; mCutsSingleTrackBeauty4Prong = cutsSingleTrack4P; + mCutsSingleTrackBeautyToJPsi = cutsSingleToJPsi; } - void setCutsBhadrons(o2::framework::LabeledArray cutsBplus, o2::framework::LabeledArray cutsB0toDstar, o2::framework::LabeledArray cutsB0, o2::framework::LabeledArray cutsBs, o2::framework::LabeledArray cutsLb, o2::framework::LabeledArray cutsXib) + void setCutsBhadrons(o2::framework::LabeledArray cutsBplus, o2::framework::LabeledArray cutsB0toDstar, o2::framework::LabeledArray cutsBc, o2::framework::LabeledArray cutsB0, o2::framework::LabeledArray cutsBs, o2::framework::LabeledArray cutsLb, o2::framework::LabeledArray cutsXib) { mCutsBhad[kBplus] = cutsBplus; mCutsBhad[kB0toDStar] = cutsB0toDstar; + mCutsBhad[kBc] = cutsBc; mCutsBhad[kB0] = cutsB0; mCutsBhad[kBs] = cutsBs; mCutsBhad[kLb] = cutsLb; mCutsBhad[kXib] = cutsXib; } + void setCutsBtoJPsi(o2::framework::LabeledArray cuts) + { + mCutsBhadToJPsi = cuts; + } void setPtLimitsProtonForFemto(float minPt, float maxPt) { mPtMinProtonForFemto = minPt; @@ -390,10 +447,12 @@ class HfFilterHelper mPtMinDeuteronForFemto = minPt; mPtMaxDeuteronForFemto = maxPt; } - void setPtLimitsBeautyBachelor(float minPt, float maxPt) + void setPtLimitsBeautyBachelor(float minPt, float maxPt, float minPtBtoJPsiBach, float maxPtBtoJPsiBach) { mPtMinBeautyBachelor = minPt; mPtMaxBeautyBachelor = maxPt; + mPtMinBeautyToJPsiBachelor = minPtBtoJPsiBach; + mPtMaxBeautyToJPsiBachelor = maxPtBtoJPsiBach; } void setPtLimitsDstarSoftPion(float minPt, float maxPt) { @@ -430,9 +489,31 @@ class HfFilterHelper mPtMinCharmBaryonBachelor = minPt; mPtMaxCharmBaryonBachelor = maxPt; } + void setPtLimitsLcResonanceBachelor(float minPt, float maxPt) + { + mPtMinLcResonanceBachelor = minPt; + mPtMaxLcResonanceBachelor = maxPt; + } + void setPtLimitsThetaCBachelor(float minPt, float maxPt) + { + mPtMinThetaCBachelor = minPt; + mPtMaxThetaCBachelor = maxPt; + } + + void setNsigmaProtonCutsForFemto(std::array nSigmaCuts) { mNSigmaPrCutsForFemto = nSigmaCuts; } + void setNsigmaDeuteronCutsForFemto(std::array nSigmaCuts) { mNSigmaDeCutsForFemto = nSigmaCuts; } + + void setDeuteronTrackSelectionForFemto(float minTpcCluster, float minTpcRow, float minTpcCrossedOverFound, float maxTpcShared, float maxTpcFracShared, float minItsCluster, float minItsIbCluster) + { + mMinTpcCluster = minTpcCluster; + mMinTpcRow = minTpcRow; + mMinTpcCrossedOverFound = minTpcCrossedOverFound; + mMaxTpcShared = maxTpcShared; + mMaxTpcFracShared = maxTpcFracShared; + mMinItsCluster = minItsCluster; + mMinItsIbCluster = minItsIbCluster; + } - void setNsigmaProtonCutsForFemto(std::array nSigmaCuts) { mNSigmaPrCutsForFemto = nSigmaCuts; } - void setNsigmaDeuteronCutsForFemto(std::array nSigmaCuts) { mNSigmaDeCutsForFemto = nSigmaCuts; } void setNsigmaProtonCutsForCharmBaryons(float nSigmaTpc, float nSigmaTof) { mNSigmaTpcPrCutForCharmBaryons = nSigmaTpc; @@ -448,6 +529,11 @@ class HfFilterHelper mNSigmaTpcPiKaCutForDzero = nSigmaTpc; mNSigmaTofPiKaCutForDzero = nSigmaTof; } + void setNsigmaKaonProtonCutsForBeautyToJPsi(float nSigmaTpc, float nSigmaTof) + { + mNSigmaTpcPrKaCutForBeautyToJPsi = nSigmaTpc; + mNSigmaTofPrKaCutForBeautyToJPsi = nSigmaTof; + } void setV0Selections(float minGammaCosPa, float minK0sLambdaCosPa, float minK0sLambdaRadius, float nSigmaPrFromLambda, float deltaMassK0s, float deltaMassLambda) { mMinGammaCosinePa = minGammaCosPa; @@ -480,6 +566,21 @@ class HfFilterHelper mNSigmaTofKaonFromXicResoToSigmaC = nSigmaTof; } + void setXiBachelorSelections(float ptMinXiPi, float ptMinXiKa, float ptMinXiPiPi, float massMinXiPi, float massMinXiKa, float massMinXiPiPi, float massMaxXiPi, float massMaxXiKa, float massMaxXiPiPi, float cosPaMinXiBach, float cosPaMinXiBachBach) + { + mPtMinXiBach[0] = ptMinXiPi; + mPtMinXiBach[1] = ptMinXiKa; + mPtMinXiBach[2] = ptMinXiPiPi; + mMassMinXiBach[0] = massMinXiPi; + mMassMinXiBach[1] = massMinXiKa; + mMassMinXiBach[2] = massMinXiPiPi; + mMassMaxXiBach[0] = massMaxXiPi; + mMassMaxXiBach[1] = massMaxXiKa; + mMassMaxXiBach[2] = massMaxXiPiPi; + mCosPaMinXiBach[0] = cosPaMinXiBach; + mCosPaMinXiBach[1] = cosPaMinXiBachBach; + } + void setTpcPidCalibrationOption(int opt) { mTpcPidCalibrationOption = opt; } void setMassResolParametrisation(std::string recoPass) @@ -493,6 +594,15 @@ class HfFilterHelper mSigmaPars3Prongs[1] = 0.00176f; mDeltaMassPars3Prongs[0] = -0.0025f; mDeltaMassPars3Prongs[1] = 0.0001f; + } else if (recoPass == "2025_pass1") { + mSigmaPars2Prongs[0] = 0.01424f; + mSigmaPars2Prongs[1] = 0.00178f; + mDeltaMassPars2Prongs[0] = -0.013f; + mDeltaMassPars2Prongs[1] = 0.00029f; + mSigmaPars3Prongs[0] = 0.00796f; + mSigmaPars3Prongs[1] = 0.00176f; + mDeltaMassPars3Prongs[0] = -0.013f; + mDeltaMassPars3Prongs[1] = 0.00029f; } else { LOGP(fatal, "Mass resolution parametrisation {} not supported! Please set 2023_pass3", recoPass.data()); } @@ -500,13 +610,19 @@ class HfFilterHelper void setNumSigmaForDeltaMassCharmHadCut(float nSigma) { mNumSigmaDeltaMassCharmHad = nSigma; } + void setPreselDsToKKPi(std::vector ptBins, o2::framework::LabeledArray preselections) + { + mPtBinsPreselDsToKKPi = ptBins; + mPreselDsToKKPi = preselections; + } + // helper functions for selections template bool isSelectedHighPt2Prong(const T& pt); template bool isSelectedHighPt3Prong(const T& pt); - template - int8_t isSelectedTrackForSoftPionOrBeauty(const T& track, const T1& trackPar, const T2& dca, const int& whichTrigger); + template + int16_t isSelectedTrackForSoftPionOrBeauty(const T& track, const T1& trackPar, const T2& dca); template bool isSelectedTrack4Femto(const T1& track, const T2& trackPar, const int& activateQA, H2 hTPCPID, H2 hTOFPID, const int& trackSpecies); template @@ -536,7 +652,9 @@ class HfFilterHelper template bool isSelectedCascade(const Casc& casc); template - int8_t isSelectedBachelorForCharmBaryon(const T& track, const T2& dca); + int16_t isSelectedBachelorForCharmBaryon(const T& track, const T2& dca); + template + bool isSelectedProton4CharmOrBeautyBaryons(const T& track); template int8_t isBDTSelected(const T& scores, const U& thresholdBDTScores); template @@ -547,9 +665,16 @@ class HfFilterHelper bool isSelectedBhadronInMassRange(T1 const& ptCand, T2 const& massCand, const int whichB); template bool isSelectedBzeroToDstar(T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, const T2& primVtx, const T3& secVtx); + template + int8_t isSelectedBhadronToJPsi(std::array pVecDauTracks, std::array tracksDauNoMu, const T3& primVtx, const T4& secVtx, const int& activateQA, std::array& hMassVsPt); template bool isCharmHadronMassInSbRegions(T1 const& massHypo1, T1 const& massHypo2, const float& lowLimitSB, const float& upLimitSB); - + template + bool isSelectedXiBach(T const& trackParCasc, T const& trackParBachelor, int8_t isSelBachelor, C const& collision, o2::vertexing::DCAFitterN<2>& dcaFitter, const int& activateQA, H2 hMassVsPtXiPi, H2 hMassVsPtXiKa); + template + bool isSelectedXiBachBach(T const& trackParCasc, std::array const& trackParBachelor, C const& collision, o2::vertexing::DCAFitterN& dcaFitter, const int& activateQA, H2 hMassVsPtXiPiPi); + template + bool isSelectedProtonFromLcResoOrThetaC(const T& track); // helpers template T computeRelativeMomentum(const std::array& pTrack, const std::array& CharmCandMomentum, const T& CharmMass); @@ -568,10 +693,8 @@ class HfFilterHelper private: // selections - template - bool isSelectedKaon4Charm3Prong(const T& track); - template - bool isSelectedProton4CharmBaryons(const T& track); + template + bool isSelectedKaon4Charm3ProngOrBeautyToJPsi(const T& track); // PID float getTPCSplineCalib(const float tpcPin, const float dEdx, const int& pidSpecies); @@ -592,34 +715,43 @@ class HfFilterHelper std::vector mPtBinsBeautyHadrons{}; // vector of pT bins for beauty hadron candidates o2::framework::LabeledArray mCutsSingleTrackBeauty3Prong{}; // dca selections for the 3-prong b-hadron pion daughter o2::framework::LabeledArray mCutsSingleTrackBeauty4Prong{}; // dca selections for the 4-prong b-hadron pion daughter + o2::framework::LabeledArray mCutsSingleTrackBeautyToJPsi{}; // dca selections for the b-hadron -> JPsi X daughters (not the muons) float mPtMinSoftPionForDstar{0.1}; // minimum pt for the D*+ soft pion float mPtMinSoftPionForSigmaC{0.1}; // minimum pt for the Σ0,++ soft pion float mPtMaxSoftPionForSigmaC{10000.f}; // maximum pt for the Σ0,++ soft pion float mPtMinSoftKaonForXicResoToSigmaC{0.1}; // minimum pt for the soft kaon of Xic* to SigmaC-Kaon float mPtMaxSoftKaonForXicResoToSigmaC{10000.f}; // maximum pt for the soft kaon of Xic* to SigmaC-Kaon float mPtMinBeautyBachelor{0.5}; // minimum pt for the b-hadron pion daughter + float mPtMinBeautyToJPsiBachelor{0.5}; // minimum pt for the b-hadron -> JPsi X daughters (not the muons) float mPtMinProtonForFemto{0.8}; // minimum pt for the proton for femto float mPtMinDeuteronForFemto{0.8}; // minimum pt for the deuteron for femto float mPtMinCharmBaryonBachelor{0.5}; // minimum pt for the bachelor pion from Xic/Omegac decays + float mPtMinLcResonanceBachelor{0.3}; // minimum pt for the bachelor proton from Lc resonance decays + float mPtMinThetaCBachelor{0.3}; // minimum pt for the bachelor proton from ThetaC decays float mPtMaxSoftPionForDstar{2.}; // maximum pt for the D*+ soft pion float mPtMaxBeautyBachelor{100000.}; // maximum pt for the b-hadron pion daughter + float mPtMaxBeautyToJPsiBachelor{100000.}; // maximum pt for the b-hadron -> JPsi X daughters (not the muons) float mPtMaxProtonForFemto{5.0}; // maximum pt for the proton for femto float mPtMaxDeuteronForFemto{5.0}; // maximum pt for the deuteron for femto float mPtMaxCharmBaryonBachelor{100000.}; // maximum pt for the bachelor pion from Xic/Omegac decays + float mPtMaxLcResonanceBachelor{100000.}; // maximum pt for the bachelor proton from Lc resonance decays + float mPtMaxThetaCBachelor{100000.}; // maximum pt for the bachelor proton from ThetaC decays float mPtThresholdProtonForFemto{8.}; // pt threshold to change strategy for proton PID for femto float mPtThresholdDeuteronForFemto{1.4}; // pt threshold to change strategy for deuteron PID for femto float mPtMinSigmaCZero{0.f}; // pt min SigmaC0 candidate float mPtMinSigmaC2520Zero{0.f}; // pt min SigmaC(2520)0 candidate float mPtMinSigmaCPlusPlus{0.f}; // pt min SigmaC++ candidate float mPtMinSigmaC2520PlusPlus{0.f}; // pt min SigmaC(2520)++ candidate - std::array mNSigmaPrCutsForFemto{3., 3., 3.}; // cut values for Nsigma TPC, TOF, combined for femto protons - std::array mNSigmaDeCutsForFemto{3., 3., 3.}; // cut values for Nsigma TPC, TOF, combined for femto deuterons + std::array mNSigmaPrCutsForFemto{3., 3., 3., -4.}; // cut values for Nsigma TPC, TOF, combined, ITS for femto protons + std::array mNSigmaDeCutsForFemto{3., 3., 3., -4.}; // cut values for Nsigma TPC, TOF, combined, ITS for femto deuterons float mNSigmaTpcPrCutForCharmBaryons{3.}; // maximum Nsigma TPC for protons in Lc and Xic decays float mNSigmaTofPrCutForCharmBaryons{3.}; // maximum Nsigma TOF for protons in Lc and Xic decays float mNSigmaTpcKaCutFor3Prongs{3.}; // maximum Nsigma TPC for kaons in 3-prong decays float mNSigmaTofKaCutFor3Prongs{3.}; // maximum Nsigma TOF for kaons in 3-prong decays float mNSigmaTpcPiKaCutForDzero{3.}; // maximum Nsigma TPC for pions/kaons in D0 decays float mNSigmaTofPiKaCutForDzero{3.}; // maximum Nsigma TOF for pions/kaons in D0 decays + float mNSigmaTpcPrKaCutForBeautyToJPsi{3.}; // maximum Nsigma TPC for kaons and protons in B->JPsiX decays + float mNSigmaTofPrKaCutForBeautyToJPsi{3.}; // maximum Nsigma TPC for kaons and protons in B->JPsiX decays float mDeltaMassMinSigmaCZero{0.155}; // minimum delta mass M(pKpipi)-M(pKpi) of SigmaC0 candidates float mDeltaMassMaxSigmaCZero{0.18}; // maximum delta mass M(pKpipi)-M(pKpi) of SigmaC0 candidates float mDeltaMassMinSigmaC2520Zero{0.2}; // minimum delta mass M(pKpipi)-M(pKpi) of SigmaC(2520)0 candidates @@ -656,12 +788,26 @@ class HfFilterHelper float mNSigmaTofKaonFromXicResoToSigmaC{3.}; // maximum Nsigma TOF for kaons in Xic*->SigmaC-Kaon bool mForceTofProtonForFemto = true; // flag to force TOF PID for protons bool mForceTofDeuteronForFemto = false; // flag to force TOF PID for deuterons + std::array mPtMinXiBach{5., 5., 5.}; // minimum pT for XiBachelor candidates + std::array mMassMinXiBach{2.35, 2.6, 2.35}; // minimum invariant-mass for XiBachelor candidates + std::array mMassMaxXiBach{3.0, 3.0, 2.7}; // maximum invariant-mass for XiBachelor candidates + std::array mCosPaMinXiBach{-2.f, -2.f}; // minimum cosine of pointing angle for XiBachelor candidates std::array, kNBeautyParticles> mCutsBhad{}; // selections for B-hadron candidates (DeltaMass, CPA, DecayLength, ImpactParameterProduct) - + o2::framework::LabeledArray mCutsBhadToJPsi{}; // selections for B->JPsi candidates (PtMinMu, DeltaMass, CPA, DecayLength) + float mMinTpcCluster{90.}; // Minimum number of TPC clusters required on a track + float mMinTpcRow{80.}; // Minimum number of TPC rows (pad rows) traversed by the track + float mMinTpcCrossedOverFound{0.83}; // Minimum ratio of crossed TPC rows over findable clusters + float mMaxTpcShared{160.}; // Maximum allowed number of shared TPC clusters between tracks + float mMaxTpcFracShared{1.}; // Maximum allowed fraction of shared TPC clusters relative to total clusters + float mMinItsCluster{1.}; // Minimum required number of ITS clusters + float mMinItsIbCluster{1.}; // Minimum required number of ITS clusters for IB // PID recalibrations int mTpcPidCalibrationOption{0}; // Option for TPC PID calibration (0 -> AO2D, 1 -> postcalibrations, 2 -> alternative bethe bloch parametrisation) std::array mHistMapPiPrKaDe{}; // Map for TPC PID postcalibrations for pions, kaon, protons and deuterons std::array, 8> mBetheBlochPiKaPrDe{}; // Bethe-Bloch parametrisations for pions, antipions, kaons, antikaons, protons, antiprotons, deuterons, antideuterons in TPC + // Ds cuts from track-index-skim-creator + std::vector mPtBinsPreselDsToKKPi{}; // pT bins for pre-selections for Ds from track-index-skim-creator + o2::framework::LabeledArray mPreselDsToKKPi{}; // pre-selections for Ds from track-index-skim-creator }; /// Selection of high-pt 2-prong candidates @@ -691,11 +837,11 @@ inline bool HfFilterHelper::isSelectedHighPt3Prong(const T& pt) /// \param trackPar is a track parameter /// \param dca is the 2d array with dcaXY and dcaZ of the track /// \return a flag that encodes the selection for soft pions BIT(kSoftPion), tracks for beauty BIT(kForBeauty), or soft pions for beauty BIT(kSoftPionForBeauty) -template -inline int8_t HfFilterHelper::isSelectedTrackForSoftPionOrBeauty(const T& track, const T1& trackPar, const T2& dca, const int& whichTrigger) +template +inline int16_t HfFilterHelper::isSelectedTrackForSoftPionOrBeauty(const T& track, const T1& trackPar, const T2& dca) { - int8_t retValue{BIT(kSoftPion) | BIT(kForBeauty) | BIT(kSoftPionForBeauty) | BIT(kSoftPionForSigmaC)}; + int16_t retValue{BIT(kSoftPion) | BIT(kForBeauty) | BIT(kSoftPionForBeauty) | BIT(kSoftPionForSigmaC)}; if (!track.isGlobalTrackWoDCA()) { return kRejected; @@ -721,7 +867,7 @@ inline int8_t HfFilterHelper::isSelectedTrackForSoftPionOrBeauty(const T& track, return kRejected; } - if (whichTrigger == kSigmaCPPK || whichTrigger == kSigmaC0K0) { + if constexpr (whichTrigger == kSigmaCPPK || whichTrigger == kSigmaC0K0) { // SigmaC0,++ soft pion pt cut if (pT < mPtMinSoftPionForSigmaC || pT > mPtMaxSoftPionForSigmaC) { @@ -739,18 +885,29 @@ inline int8_t HfFilterHelper::isSelectedTrackForSoftPionOrBeauty(const T& track, } // below only regular beauty tracks, not required for soft pions - if (pT < mPtMinBeautyBachelor || pT > mPtMaxBeautyBachelor) { + float ptMin{-1.f}, ptMax{1000.f}; + if constexpr (whichTrigger == kBeauty3P || whichTrigger == kBeauty4P) { + ptMin = mPtMinBeautyBachelor; + ptMax = mPtMaxBeautyBachelor; + } else if constexpr (whichTrigger == kBtoJPsiKa || whichTrigger == kBtoJPsiPi || whichTrigger == kBtoJPsiKstar || whichTrigger == kBtoJPsiPhi || whichTrigger == kBtoJPsiPrKa) { + ptMin = mPtMinBeautyToJPsiBachelor; + ptMax = mPtMaxBeautyToJPsiBachelor; + } + + if (pT < ptMin || pT > ptMax) { CLRBIT(retValue, kForBeauty); } - float minDca = 1000.f; - float maxDca = 0.f; - if (whichTrigger == kBeauty3P) { + float minDca{1000.f}, maxDca{0.f}; + if constexpr (whichTrigger == kBeauty3P) { minDca = mCutsSingleTrackBeauty3Prong.get(pTBinTrack, 0u); maxDca = mCutsSingleTrackBeauty3Prong.get(pTBinTrack, 1u); - } else if (whichTrigger == kBeauty4P) { + } else if constexpr (whichTrigger == kBeauty4P) { minDca = mCutsSingleTrackBeauty4Prong.get(pTBinTrack, 0u); maxDca = mCutsSingleTrackBeauty4Prong.get(pTBinTrack, 1u); + } else if constexpr (whichTrigger == kBtoJPsiKa || whichTrigger == kBtoJPsiPi || whichTrigger == kBtoJPsiKstar || whichTrigger == kBtoJPsiPhi || whichTrigger == kBtoJPsiPrKa) { + minDca = mCutsSingleTrackBeautyToJPsi.get(pTBinTrack, 0u); + maxDca = mCutsSingleTrackBeautyToJPsi.get(pTBinTrack, 1u); } if (std::fabs(dca[0]) < minDca) { // minimum DCAxy @@ -778,7 +935,7 @@ inline bool HfFilterHelper::isSelectedTrack4Femto(const T1& track, const T2& tra { float pt = trackPar.getPt(); float ptMin, ptMax, ptThresholdPidStrategy; - std::array nSigmaCuts; + std::array nSigmaCuts; bool forceTof = false; // flag to force TOF PID // Assign particle-specific parameters @@ -814,6 +971,7 @@ inline bool HfFilterHelper::isSelectedTrack4Femto(const T1& track, const T2& tra return false; // use only global tracks } // PID evaluation + float NSigmaITS = (trackSpecies == kProtonForFemto) ? track.itsNSigmaPr() : track.itsNSigmaDe(); // only used for deuteron float NSigmaTPC = (trackSpecies == kProtonForFemto) ? track.tpcNSigmaPr() : track.tpcNSigmaDe(); float NSigmaTOF = (trackSpecies == kProtonForFemto) ? track.tofNSigmaPr() : track.tofNSigmaDe(); if (!forceTof && !track.hasTOF()) { @@ -832,9 +990,9 @@ inline bool HfFilterHelper::isSelectedTrack4Femto(const T1& track, const T2& tra } float NSigma = std::sqrt(NSigmaTPC * NSigmaTPC + NSigmaTOF * NSigmaTOF); - + float momentum = track.p(); if (trackSpecies == kProtonForFemto) { - if (pt <= ptThresholdPidStrategy) { + if (momentum <= ptThresholdPidStrategy) { if (NSigma > nSigmaCuts[2]) { return false; } @@ -846,9 +1004,33 @@ inline bool HfFilterHelper::isSelectedTrack4Femto(const T1& track, const T2& tra } // For deuterons: Determine whether to apply TOF based on pt threshold if (trackSpecies == kDeuteronForFemto) { + + if (track.tpcNClsFound() < mMinTpcCluster) { + return false; + } + if (track.tpcNClsCrossedRows() < mMinTpcRow) { + return false; + } + if (track.tpcCrossedRowsOverFindableCls() < mMinTpcCrossedOverFound) { + return false; + } + if (track.tpcNClsShared() > mMaxTpcShared) { + return false; + } + if (track.tpcFractionSharedCls() > mMaxTpcFracShared) { + return false; + } + if (track.itsNCls() < mMinItsCluster) { + return false; + } + if (track.itsNClsInnerBarrel() < mMinItsIbCluster) { + return false; + } + // Apply different PID strategy in different pt range - if (pt <= ptThresholdPidStrategy) { - if (std::fabs(NSigmaTPC) > nSigmaCuts[0]) { // Use only TPC below the threshold + // one side selection only + if (momentum <= ptThresholdPidStrategy) { + if (std::fabs(NSigmaTPC) > nSigmaCuts[0] || NSigmaITS < -nSigmaCuts[3]) { // Use TPC and ITS below the threshold, NSigmaITS for deuteron with a lower limit return false; } } else { @@ -860,11 +1042,11 @@ inline bool HfFilterHelper::isSelectedTrack4Femto(const T1& track, const T2& tra if (activateQA > 1) { hTPCPID->Fill(track.p(), NSigmaTPC); - if ((forceTof || track.hasTOF())) { + if ((!forceTof || track.hasTOF())) { if (trackSpecies == kProtonForFemto) - hTOFPID->Fill(track.p(), NSigmaTOF); - else if (trackSpecies == kDeuteronForFemto && pt > ptThresholdPidStrategy) - hTOFPID->Fill(track.p(), NSigmaTOF); + hTOFPID->Fill(momentum, NSigmaTOF); + else if (trackSpecies == kDeuteronForFemto && momentum > ptThresholdPidStrategy) + hTOFPID->Fill(momentum, NSigmaTOF); } } @@ -882,7 +1064,7 @@ inline int8_t HfFilterHelper::isDplusPreselected(const T& trackOppositeCharge) int8_t retValue = 0; // check PID of opposite charge track - if (!isSelectedKaon4Charm3Prong(trackOppositeCharge)) { + if (!isSelectedKaon4Charm3ProngOrBeautyToJPsi(trackOppositeCharge)) { return retValue; } @@ -902,18 +1084,25 @@ inline int8_t HfFilterHelper::isDsPreselected(const P& pTrackSameChargeFirst, co int8_t retValue = 0; // check PID of opposite charge track - if (!isSelectedKaon4Charm3Prong(trackOppositeCharge)) { + if (!isSelectedKaon4Charm3ProngOrBeautyToJPsi(trackOppositeCharge)) { return retValue; } // check delta-mass for phi resonance + auto ptDs = RecoDecay::pt(pTrackSameChargeFirst, pTrackSameChargeSecond, pTrackOppositeCharge); + auto ptBinDs = findBin(mPtBinsPreselDsToKKPi, ptDs); + if (ptBinDs == -1) { + return retValue; + } + auto invMassKKFirst = RecoDecay::m(std::array{pTrackSameChargeFirst, pTrackOppositeCharge}, std::array{massKa, massKa}); auto invMassKKSecond = RecoDecay::m(std::array{pTrackSameChargeSecond, pTrackOppositeCharge}, std::array{massKa, massKa}); - if (std::fabs(invMassKKFirst - massPhi) < 0.02) { + float cutValueMassKK = mPreselDsToKKPi.get(ptBinDs, 4u); + if (std::fabs(invMassKKFirst - massPhi) < cutValueMassKK) { retValue |= BIT(0); } - if (std::fabs(invMassKKSecond - massPhi) < 0.02) { + if (std::fabs(invMassKKSecond - massPhi) < cutValueMassKK) { retValue |= BIT(1); } @@ -930,13 +1119,13 @@ inline int8_t HfFilterHelper::isCharmBaryonPreselected(const T& trackSameChargeF { int8_t retValue = 0; // check PID of opposite charge track - if (!isSelectedKaon4Charm3Prong(trackOppositeCharge)) { + if (!isSelectedKaon4Charm3ProngOrBeautyToJPsi(trackOppositeCharge)) { return retValue; } - if (isSelectedProton4CharmBaryons(trackSameChargeFirst)) { + if (isSelectedProton4CharmOrBeautyBaryons(trackSameChargeFirst)) { retValue |= BIT(0); } - if (isSelectedProton4CharmBaryons(trackSameChargeSecond)) { + if (isSelectedProton4CharmOrBeautyBaryons(trackSameChargeSecond)) { retValue |= BIT(1); } @@ -1539,9 +1728,9 @@ inline bool HfFilterHelper::isSelectedCascade(const Casc& casc) /// \param dca is the 2d array with dcaXY and dcaZ of the track /// \return 0 if rejected, or a bitmap that contains the information whether it is selected as pion and/or kaon template -inline int8_t HfFilterHelper::isSelectedBachelorForCharmBaryon(const T& track, const T2& dca) +inline int16_t HfFilterHelper::isSelectedBachelorForCharmBaryon(const T& track, const T2& dca) { - int8_t retValue{BIT(kPionForCharmBaryon) | BIT(kKaonForCharmBaryon)}; + int16_t retValue{BIT(kPionForCharmBaryon) | BIT(kKaonForCharmBaryon)}; if (!track.isGlobalTrackWoDCA()) { return kRejected; @@ -1744,8 +1933,8 @@ inline void HfFilterHelper::setTpcRecalibMaps(o2::framework::Service -inline bool HfFilterHelper::isSelectedProton4CharmBaryons(const T& track) +template +inline bool HfFilterHelper::isSelectedProton4CharmOrBeautyBaryons(const T& track) { float NSigmaTPC = track.tpcNSigmaPr(); float NSigmaTOF = track.tofNSigmaPr(); @@ -1760,11 +1949,20 @@ inline bool HfFilterHelper::isSelectedProton4CharmBaryons(const T& track) } } - if (std::fabs(NSigmaTPC) > mNSigmaTpcPrCutForCharmBaryons) { - return false; - } - if (track.hasTOF() && std::fabs(NSigmaTOF) > mNSigmaTofPrCutForCharmBaryons) { - return false; + if constexpr (is4beauty) { + if (std::fabs(NSigmaTPC) > mNSigmaTpcPrKaCutForBeautyToJPsi) { + return false; + } + if (track.hasTOF() && std::fabs(NSigmaTOF) > mNSigmaTofPrKaCutForBeautyToJPsi) { + return false; + } + } else { + if (std::fabs(NSigmaTPC) > mNSigmaTpcPrCutForCharmBaryons) { + return false; + } + if (track.hasTOF() && std::fabs(NSigmaTOF) > mNSigmaTofPrCutForCharmBaryons) { + return false; + } } return true; @@ -1786,7 +1984,7 @@ inline bool HfFilterHelper::isSelectedKaonFromXicResoToSigmaC(const T& track) if constexpr (isKaonTrack) { /// if the kaon is a track, and not a K0s (V0), check the PID as well - return isSelectedKaon4Charm3Prong(track); + return isSelectedKaon4Charm3ProngOrBeautyToJPsi(track); } return true; @@ -1795,8 +1993,8 @@ inline bool HfFilterHelper::isSelectedKaonFromXicResoToSigmaC(const T& track) /// Basic selection of kaon candidates for charm candidates /// \param track is a track /// \return true if track passes all cuts -template -inline bool HfFilterHelper::isSelectedKaon4Charm3Prong(const T& track) +template +inline bool HfFilterHelper::isSelectedKaon4Charm3ProngOrBeautyToJPsi(const T& track) { float NSigmaTPC = track.tpcNSigmaKa(); float NSigmaTOF = track.tofNSigmaKa(); @@ -1811,11 +2009,42 @@ inline bool HfFilterHelper::isSelectedKaon4Charm3Prong(const T& track) } } - if (std::fabs(NSigmaTPC) > mNSigmaTpcKaCutFor3Prongs) { - return false; + if constexpr (is4beauty) { + if (std::fabs(NSigmaTPC) > mNSigmaTpcPrKaCutForBeautyToJPsi) { + return false; + } + if (track.hasTOF() && std::fabs(NSigmaTOF) > mNSigmaTofPrKaCutForBeautyToJPsi) { + return false; + } + } else { + if (std::fabs(NSigmaTPC) > mNSigmaTpcKaCutFor3Prongs) { + return false; + } + if (track.hasTOF() && std::fabs(NSigmaTOF) > mNSigmaTofKaCutFor3Prongs) { + return false; + } } - if (track.hasTOF() && std::fabs(NSigmaTOF) > mNSigmaTofKaCutFor3Prongs) { - return false; + + return true; +} + +/// Basic selection of proton candidates forLc and ThetaC decays +/// \param track is a track +/// \return true if track passes all cuts +template +inline bool HfFilterHelper::isSelectedProtonFromLcResoOrThetaC(const T& track) +{ + + // pt selections + float pt = track.pt(); + if constexpr (is4ThetaC) { + if (pt < mPtMinThetaCBachelor || pt > mPtMaxThetaCBachelor) { + return false; + } + } else { + if (pt < mPtMinLcResonanceBachelor || pt > mPtMaxLcResonanceBachelor) { + return false; + } } return true; @@ -1920,6 +2149,10 @@ inline bool HfFilterHelper::isSelectedBhadronInMassRange(T1 const& ptCand, T2 co massBhad = massBs; break; } + case kBc: { + massBhad = massBc; + break; + } case kLb: { massBhad = massLb; break; @@ -1937,6 +2170,143 @@ inline bool HfFilterHelper::isSelectedBhadronInMassRange(T1 const& ptCand, T2 co return true; } +/// Method to perform selections for B -> JPsiX candidates after vertex reconstruction +/// \param pVecDauTracks is the array of momentum vectors of all daughter tracks +/// \param tracksDauNoMu is the array of tracks for the daughters that are no muons +/// \param primVtx is the primary vertex +/// \param secVtx is the secondary vertex +/// \param activateQA is the flag to enable the +/// \param hMassVsPt is the array of histograms for QA +/// \return true if the beauty candidate passes all cuts +template +inline int8_t HfFilterHelper::isSelectedBhadronToJPsi(std::array pVecDauTracks, std::array tracksDauNoMu, const T3& primVtx, const T4& secVtx, const int& activateQA, std::array& hMassVsPt) +{ + int8_t isSelected{0}; + + auto pVecJPsi = RecoDecay::pVec(pVecDauTracks[0], pVecDauTracks[1]); + const int offset = static_cast(kNBeautyParticles); + + if constexpr (Nprongs == 3) { + auto pVecBhad = RecoDecay::pVec(pVecDauTracks[0], pVecDauTracks[1], pVecDauTracks[2]); + auto ptBhad = RecoDecay::pt(pVecBhad); + auto binPtB = findBin(mPtBinsBeautyHadrons, ptBhad); + if (binPtB == -1) { + return isSelected; + } + auto ptMu1 = RecoDecay::pt(pVecDauTracks[0]); + auto ptMu2 = RecoDecay::pt(pVecDauTracks[1]); + if (ptMu1 < mCutsBhadToJPsi.get(binPtB, 0u) || ptMu2 < mCutsBhadToJPsi.get(binPtB, 0u)) { + return isSelected; + } + + if (RecoDecay::cpa(primVtx, secVtx, pVecBhad) < mCutsBhadToJPsi.get(binPtB, 2u)) { + return isSelected; + } + + if (RecoDecay::distance(primVtx, secVtx) < mCutsBhadToJPsi.get(binPtB, 3u)) { + return isSelected; + } + + if (isSelectedKaon4Charm3ProngOrBeautyToJPsi(tracksDauNoMu[0])) { + auto massJPsiKa = RecoDecay::m(std::array{pVecJPsi, pVecDauTracks[2]}, std::array{massJPsi, massKa}); + if (std::fabs(massJPsiKa - massBPlus) < mCutsBhadToJPsi.get(binPtB, 1u)) { + SETBIT(isSelected, kBplusToJPsi); + if (activateQA) { + hMassVsPt[offset + kBplusToJPsi]->Fill(ptBhad, massJPsiKa); + } + } + } + auto massJPsiPi = RecoDecay::m(std::array{pVecJPsi, pVecDauTracks[2]}, std::array{massJPsi, massPi}); + if (std::fabs(massJPsiPi - massBc) < mCutsBhadToJPsi.get(binPtB, 1u)) { + SETBIT(isSelected, kBcToJPsi); + if (activateQA) { + hMassVsPt[offset + kBcToJPsi]->Fill(ptBhad, massJPsiPi); + } + } + } else if constexpr (Nprongs == 4) { + auto pVecBhad = RecoDecay::pVec(pVecDauTracks[0], pVecDauTracks[1], pVecDauTracks[2], pVecDauTracks[3]); + auto ptBhad = RecoDecay::pt(pVecBhad); + auto binPtB = findBin(mPtBinsBeautyHadrons, ptBhad); + if (binPtB == -1) { + return isSelected; + } + auto ptMu1 = RecoDecay::pt(pVecDauTracks[0]); + auto ptMu2 = RecoDecay::pt(pVecDauTracks[1]); + if (ptMu1 < mCutsBhadToJPsi.get(binPtB, 0u) || ptMu2 < mCutsBhadToJPsi.get(binPtB, 0u)) { + return isSelected; + } + + if (RecoDecay::cpa(primVtx, secVtx, pVecBhad) < mCutsBhadToJPsi.get(binPtB, 2u)) { + return isSelected; + } + + if (RecoDecay::distance(primVtx, secVtx) < mCutsBhadToJPsi.get(binPtB, 3u)) { + return isSelected; + } + + bool isFirstKaon = isSelectedKaon4Charm3ProngOrBeautyToJPsi(tracksDauNoMu[0]); + bool isSeconKaon = isSelectedKaon4Charm3ProngOrBeautyToJPsi(tracksDauNoMu[1]); + bool isFirstProton = isSelectedProton4CharmOrBeautyBaryons(tracksDauNoMu[0]); + bool isSecondProton = isSelectedProton4CharmOrBeautyBaryons(tracksDauNoMu[1]); + auto massKaKa = RecoDecay::m(std::array{pVecDauTracks[2], pVecDauTracks[3]}, std::array{massKa, massKa}); + if (isFirstKaon && isSeconKaon) { + if (std::fabs(massKaKa - massPhi) < mCutsBhadToJPsi.get(binPtB, 4u)) { + auto massJPsiKaKa = RecoDecay::m(std::array{pVecJPsi, pVecDauTracks[2], pVecDauTracks[3]}, std::array{massJPsi, massKa, massKa}); + if (std::fabs(massJPsiKaKa - massBs) < mCutsBhadToJPsi.get(binPtB, 1u)) { + SETBIT(isSelected, kBsToJPsi); + if (activateQA) { + hMassVsPt[offset + kBsToJPsi]->Fill(ptBhad, massJPsiKaKa); + } + } + } + } + if (isFirstKaon) { + auto massKaPi = RecoDecay::m(std::array{pVecDauTracks[2], pVecDauTracks[3]}, std::array{massKa, massPi}); + if (std::fabs(massKaPi - massK0Star892) < mCutsBhadToJPsi.get(binPtB, 5u)) { + auto massJPsiKaPi = RecoDecay::m(std::array{pVecJPsi, pVecDauTracks[2], pVecDauTracks[3]}, std::array{massJPsi, massKa, massPi}); + if (std::fabs(massJPsiKaPi - massB0) < mCutsBhadToJPsi.get(binPtB, 1u)) { + SETBIT(isSelected, kB0ToJPsi); + if (activateQA) { + hMassVsPt[offset + kB0ToJPsi]->Fill(ptBhad, massJPsiKaPi); + } + } + } + } + if (isSeconKaon) { + auto massPiKa = RecoDecay::m(std::array{pVecDauTracks[2], pVecDauTracks[3]}, std::array{massPi, massKa}); + if (std::fabs(massPiKa - massK0Star892) < mCutsBhadToJPsi.get(binPtB, 5u)) { + auto massJPsiPiKa = RecoDecay::m(std::array{pVecJPsi, pVecDauTracks[2], pVecDauTracks[3]}, std::array{massJPsi, massPi, massKa}); + if (std::fabs(massJPsiPiKa - massB0) < mCutsBhadToJPsi.get(binPtB, 1u)) { + SETBIT(isSelected, kB0ToJPsi); + if (activateQA) { + hMassVsPt[offset + kB0ToJPsi]->Fill(ptBhad, massJPsiPiKa); + } + } + } + } + if (isFirstProton && isSeconKaon) { + auto massLbToJPsiPrKa = RecoDecay::m(std::array{pVecDauTracks[0], pVecDauTracks[1], pVecDauTracks[2], pVecDauTracks[3]}, std::array{massMu, massMu, massProton, massKa}); + if (std::fabs(massLbToJPsiPrKa - massLb) < mCutsBhadToJPsi.get(binPtB, 1u)) { + SETBIT(isSelected, kLbToJPsi); + if (activateQA) { + hMassVsPt[offset + kLbToJPsi]->Fill(ptBhad, massLbToJPsiPrKa); + } + } + } + if (isFirstKaon && isSecondProton) { + auto massLbToJPsiKaPr = RecoDecay::m(std::array{pVecDauTracks[0], pVecDauTracks[1], pVecDauTracks[2], pVecDauTracks[3]}, std::array{massMu, massMu, massKa, massProton}); + if (std::fabs(massLbToJPsiKaPr - massLb) < mCutsBhadToJPsi.get(binPtB, 1u)) { + SETBIT(isSelected, kLbToJPsi); + if (activateQA) { + hMassVsPt[offset + kLbToJPsi]->Fill(ptBhad, massLbToJPsiKaPr); + } + } + } + } + + return isSelected; +} + /// Method to check if charm candidates has mass between sideband limits /// \param massHypo1 is the array for the candidate D daughter momentum after reconstruction of secondary vertex /// \param massHypo2 is the array for the candidate bachelor pion momentum after reconstruction of secondary vertex @@ -1944,7 +2314,7 @@ inline bool HfFilterHelper::isSelectedBhadronInMassRange(T1 const& ptCand, T2 co /// \param upLimitSB is the dca of the pion daughter track /// \return true if the candidate passes the mass selection. template -inline bool isCharmHadronMassInSbRegions(T1 const& massHypo1, T1 const& massHypo2, const float& lowLimitSB, const float& upLimitSB) +inline bool HfFilterHelper::isCharmHadronMassInSbRegions(T1 const& massHypo1, T1 const& massHypo2, const float& lowLimitSB, const float& upLimitSB) { if ((massHypo1 < lowLimitSB || massHypo1 > upLimitSB) && (massHypo2 < lowLimitSB || massHypo2 > upLimitSB)) { @@ -1954,7 +2324,163 @@ inline bool isCharmHadronMassInSbRegions(T1 const& massHypo1, T1 const& massHypo return true; } -/// Update the TPC PID baesd on the spline of particles +/// Method to check if charm candidates has mass between sideband limits +/// \param trackParCasc is the cascade track parametrisation +/// \param trackParBachelor is the bachelor track parametrisation +/// \param isSelBachelor flag for bachelor selection (Pi/Ka) +/// \param collision is the collision containing the candidate +/// \param dcaFitter is the DCAFitter +/// \param activateQA is the flag to activate the QA +/// \param hMassVsPtXiPi is the 2D histogram with pT vs mass(XiPi) +/// \param hMassVsPtXiKa is the 2D histogram with pT vs mass(XiKa) +template +inline bool HfFilterHelper::isSelectedXiBach(T const& trackParCasc, T const& trackParBachelor, int8_t isSelBachelor, C const& collision, o2::vertexing::DCAFitterN<2>& dcaFitter, const int& activateQA, H2 hMassVsPtXiPi, H2 hMassVsPtXiKa) +{ + bool isSelectedXiPi{false}, isSelectedXiKa{false}; + + // compute pT + std::array pVecBachelor{}, pVecCascade{}; + getPxPyPz(trackParBachelor, pVecBachelor); + getPxPyPz(trackParCasc, pVecCascade); + auto ptXiBach = RecoDecay::pt(RecoDecay::pVec(pVecCascade, pVecBachelor)); + + // compute first mass hypo + float massXiPi{0.f}; + if (TESTBIT(isSelBachelor, kPionForCharmBaryon)) { + massXiPi = RecoDecay::m(std::array{pVecCascade, pVecBachelor}, std::array{massXi, massPi}); + if (ptXiBach >= mPtMinXiBach[0] && massXiPi >= mMassMinXiBach[0] && massXiPi <= mMassMaxXiBach[0]) { + isSelectedXiPi = true; + } + } + + // compute second mass hypo + float massXiKa{0.f}; + if (TESTBIT(isSelBachelor, kKaonForCharmBaryon)) { + massXiKa = RecoDecay::m(std::array{pVecCascade, pVecBachelor}, std::array{massXi, massKa}); + if (ptXiBach >= mPtMinXiBach[1] && massXiKa >= mMassMinXiBach[1] && massXiKa <= mMassMaxXiBach[1]) { + isSelectedXiKa = true; + } + } + + bool isSelected = isSelectedXiPi || isSelectedXiKa; + + if (isSelected && mCosPaMinXiBach[0] > -1.f) { // if selected by pT and mass, check topology if applicable + int nCand = 0; + try { + nCand = dcaFitter.process(trackParCasc, trackParBachelor); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call for Xi + bachelor!"; + return false; + } + if (nCand == 0) { + return false; + } + + const auto& vtx = dcaFitter.getPCACandidate(); + dcaFitter.propagateTracksToVertex(); + const auto& trackCascProp = dcaFitter.getTrack(0); + const auto& trackBachProp = dcaFitter.getTrack(1); + std::array momCasc{}, momBach{}; + trackCascProp.getPxPyPzGlo(momCasc); + trackBachProp.getPxPyPzGlo(momBach); + auto momXiBach = RecoDecay::pVec(momCasc, momBach); + + std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; + if (RecoDecay::cpa(primVtx, std::array{vtx[0], vtx[1], vtx[2]}, momXiBach) < mCosPaMinXiBach[0]) { + return false; + } + + if (activateQA) { + if (isSelectedXiPi) { + hMassVsPtXiPi->Fill(ptXiBach, massXiPi); + } + if (isSelectedXiKa) { + hMassVsPtXiKa->Fill(ptXiBach, massXiKa); + } + } + } + + return isSelected; +} + +/// Method to check if charm candidates has mass between sideband limits +/// \param trackParCasc is the cascade track parametrisation +/// \param trackParBachelor is the array with two bachelor track parametrisations +/// \param collision is the collision containing the candidate +/// \param dcaFitter is the DCAFitter +/// \param activateQA is the flag to activate the QA +/// \param hMassVsPtXiPiPi is the 2D histogram with pT vs mass(XiPiPi) +template +inline bool HfFilterHelper::isSelectedXiBachBach(T const& trackParCasc, std::array const& trackParBachelor, C const& collision, o2::vertexing::DCAFitterN& dcaFitter, const int& activateQA, H2 hMassVsPtXiPiPi) +{ + // compute pT + std::array pVecBachelorFirst{}, pVecBachelorSecond{}, pVecCascade{}; + getPxPyPz(trackParBachelor[0], pVecBachelorFirst); + getPxPyPz(trackParBachelor[1], pVecBachelorSecond); + getPxPyPz(trackParCasc, pVecCascade); + auto ptXiBachBach = RecoDecay::pt(RecoDecay::pVec(pVecCascade, pVecBachelorFirst, pVecBachelorSecond)); + if (ptXiBachBach < mPtMinXiBach[2]) { + return false; + } + + // compute mass + float massXiPiPi = RecoDecay::m(std::array{pVecCascade, pVecBachelorFirst, pVecBachelorSecond}, std::array{massXi, massPi, massPi}); + if (massXiPiPi < mMassMinXiBach[2] || massXiPiPi > mMassMaxXiBach[2]) { + return false; + } + + if (mCosPaMinXiBach[1] > -1.f) { // check topology if applicable + int nCand = 0; + if constexpr (Nprongs == 3) { + try { + nCand = dcaFitter.process(trackParBachelor[0], trackParBachelor[1], trackParCasc); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call for Xi + bachelor + bachelor!"; + return false; + } + if (nCand == 0) { + return false; + } + } else if constexpr (Nprongs == 2) { + try { + nCand = dcaFitter.process(trackParBachelor[0], trackParBachelor[1]); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call for Xi + bachelor + bachelor!"; + return false; + } + if (nCand == 0) { + return false; + } + } + + const auto& vtx = dcaFitter.getPCACandidate(); + + std::array momCasc{pVecCascade}, momBachFirst{}, momBachSecond{}; + dcaFitter.propagateTracksToVertex(); + const auto& trackBachFirstProp = dcaFitter.getTrack(0); + const auto& trackBachSecondProp = dcaFitter.getTrack(1); + trackBachFirstProp.getPxPyPzGlo(momBachFirst); + trackBachSecondProp.getPxPyPzGlo(momBachSecond); + if constexpr (Nprongs == 3) { + const auto& trackCascProp = dcaFitter.getTrack(2); + trackCascProp.getPxPyPzGlo(momCasc); + } + auto momXiBachBach = RecoDecay::pVec(momCasc, momBachFirst, momBachSecond); + + std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; + if (RecoDecay::cpa(primVtx, std::array{vtx[0], vtx[1], vtx[2]}, momXiBachBach) < mCosPaMinXiBach[1]) { + return false; + } + + if (activateQA) { + hMassVsPtXiPiPi->Fill(ptXiBachBach, massXiPiPi); + } + } + + return true; +} + +/// Update the TPC PID based on the spline of particles /// \param track is a track parameter /// \param pidSpecies is the particle species to be considered /// \return updated nsigma value for TPC PID @@ -2138,7 +2664,7 @@ inline bool HfFilterHelper::buildV0(V const& v0Indices, T const& tracks, C const auto trackParCovPos = getTrackParCov(trackPos); auto trackParCovNeg = getTrackParCov(trackNeg); std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; - gpu::gpustd::array dcaInfoPos, dcaInfoNeg; + std::array dcaInfoPos, dcaInfoNeg; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovPos, 2.f, dcaFitter.getMatCorrType(), &dcaInfoPos); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovNeg, 2.f, dcaFitter.getMatCorrType(), &dcaInfoNeg); @@ -2147,7 +2673,7 @@ inline bool HfFilterHelper::buildV0(V const& v0Indices, T const& tracks, C const try { nCand = dcaFitter.process(trackParCovPos, trackParCovNeg); } catch (...) { - LOG(error) << "Exception caught in DCA fitter process call!"; + LOG(error) << "Exception caught in DCA fitter process call in V0!"; return false; } if (nCand == 0) { @@ -2155,6 +2681,7 @@ inline bool HfFilterHelper::buildV0(V const& v0Indices, T const& tracks, C const } // compute candidate momentum from tracks propagated to decay vertex + dcaFitter.propagateTracksToVertex(); auto& trackPosProp = dcaFitter.getTrack(0); auto& trackNegProp = dcaFitter.getTrack(1); std::array momPos{}, momNeg{}; @@ -2207,7 +2734,7 @@ inline bool HfFilterHelper::buildV0(V const& v0Indices, T const& tracks, C const auto trackParV0 = dcaFitter.createParentTrackParCov(); trackParV0.setAbsCharge(0); trackParV0.setPID(o2::track::PID::K0); - gpu::gpustd::array dcaInfoV0; + std::array dcaInfoV0; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParV0, 2.f, dcaFitter.getMatCorrType(), &dcaInfoV0); v0Cand.dcav0topv = dcaInfoV0[0]; @@ -2259,7 +2786,7 @@ inline bool HfFilterHelper::buildCascade(Casc const& cascIndices, V const& v0Ind return false; } - gpu::gpustd::array dcaInfoBach; + std::array dcaInfoBach; auto bachTrackParCov = getTrackParCov(trackBachelor); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, bachTrackParCov, 2.f, dcaFitter.getMatCorrType(), &dcaInfoBach); @@ -2278,7 +2805,7 @@ inline bool HfFilterHelper::buildCascade(Casc const& cascIndices, V const& v0Ind try { nCand = dcaFitter.process(v0TrackParCov, bachTrackParCov); } catch (...) { - LOG(error) << "Exception caught in DCA fitter process call!"; + LOG(error) << "Exception caught in DCA fitter process call in Xi!"; return false; } if (nCand == 0) { @@ -2286,6 +2813,7 @@ inline bool HfFilterHelper::buildCascade(Casc const& cascIndices, V const& v0Ind } // compute candidate momentum from tracks propagated to decay vertex + dcaFitter.propagateTracksToVertex(); auto& trackV0Prop = dcaFitter.getTrack(0); auto& trackBachProp = dcaFitter.getTrack(1); std::array momV0{}, momBach{}; @@ -2309,20 +2837,35 @@ inline bool HfFilterHelper::buildCascade(Casc const& cascIndices, V const& v0Ind for (int iCoord{0}; iCoord < 3; ++iCoord) { cascCand.vtx[iCoord] = vtx[iCoord]; } + auto covVtxV = dcaFitter.calcPCACovMatrix(0); + cascCand.cov = {}; + cascCand.cov[0] = covVtxV(0, 0); + cascCand.cov[1] = covVtxV(1, 0); + cascCand.cov[2] = covVtxV(1, 1); + cascCand.cov[3] = covVtxV(2, 0); + cascCand.cov[4] = covVtxV(2, 1); + cascCand.cov[5] = covVtxV(2, 2); + std::array covTv0 = {0.}; + std::array covTbachelor = {0.}; + trackV0Prop.getCovXYZPxPyPzGlo(covTv0); + trackBachProp.getCovXYZPxPyPzGlo(covTbachelor); + constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int iCoord{0}; iCoord < 6; ++iCoord) { + cascCand.cov[MomInd[iCoord]] = covTv0[MomInd[iCoord]] + covTbachelor[MomInd[iCoord]]; + } + cascCand.cascradius = std::hypot(vtx[0], vtx[1]); - ; cascCand.casccosPA = RecoDecay::cpa(primVtx, vtx, cascCand.mom); auto trackParCasc = dcaFitter.createParentTrackParCov(); trackParCasc.setAbsCharge(1); trackParCasc.setPID(o2::track::PID::XiMinus); - gpu::gpustd::array dcaInfoCasc; + std::array dcaInfoCasc; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCasc, 2.f, dcaFitter.getMatCorrType(), &dcaInfoCasc); cascCand.dcaXYCascToPV = dcaInfoCasc[0]; cascCand.dcacascdaughters = std::sqrt(dcaFitter.getChi2AtPCACandidate()); cascCand.mXi = RecoDecay::m(std::array{momBach, momV0}, std::array{massPi, massLambda}); cascCand.mOmega = RecoDecay::m(std::array{momBach, momV0}, std::array{massKa, massLambda}); - ; cascCand.hasTofBach = trackBachelor.hasTOF(); cascCand.nSigmaPiTpcBach = trackBachelor.tpcNSigmaPi(); diff --git a/EventFiltering/PWGHF/HFFilterPrepareMLSamples.cxx b/EventFiltering/PWGHF/HFFilterPrepareMLSamples.cxx index 5e62416a75d..b7a9637ba10 100644 --- a/EventFiltering/PWGHF/HFFilterPrepareMLSamples.cxx +++ b/EventFiltering/PWGHF/HFFilterPrepareMLSamples.cxx @@ -8,7 +8,6 @@ // 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 includes /// \file HFFilterPrepareMLSamples.cxx /// \brief task for trainings of ML models to be used in the HFFilter.cxx task @@ -19,29 +18,41 @@ /// \author Biao Zhang , CCNU /// \author Antonio Palasciano , INFN Bari -#include -#if __has_include() -#include // needed for HFFilterHelpers, to be fixed -#else -#include -#endif - -#include "CommonConstants/PhysicsConstants.h" -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DetectorsBase/Propagator.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/trackUtilities.h" +#include "EventFiltering/PWGHF/HFFilterHelpers.h" +// #include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +// +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "EventFiltering/PWGHF/HFFilterHelpers.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -55,7 +66,7 @@ struct HfFilterPrepareMlSamples { // Main struct Produces train3P; // parameters for production of training samples - Configurable fillSignal{"fillSignal", true, "Flag to fill derived tables with signal for ML trainings"}; + Configurable fillOnlySignal{"fillOnlySignal", true, "Flag to fill derived tables with signal for ML trainings"}; Configurable fillOnlyBackground{"fillOnlyBackground", true, "Flag to fill derived tables with background for ML trainings"}; Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; Configurable massSbLeftMin{"massSbLeftMin", 1.72, "Left Sideband Lower Minv limit 2 Prong"}; @@ -78,6 +89,10 @@ struct HfFilterPrepareMlSamples { // Main struct void init(InitContext&) { + if (fillOnlySignal && fillOnlyBackground) { + LOGP(fatal, "fillOnlySignal and fillOnlyBackground cannot be activated simultaneously, exit"); + } + ccdb->setURL(url.value); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); @@ -110,8 +125,8 @@ struct HfFilterPrepareMlSamples { // Main struct auto trackParPos = getTrackPar(trackPos); auto trackParNeg = getTrackPar(trackNeg); - o2::gpu::gpustd::array dcaPos{trackPos.dcaXY(), trackPos.dcaZ()}; - o2::gpu::gpustd::array dcaNeg{trackNeg.dcaXY(), trackNeg.dcaZ()}; + std::array dcaPos{trackPos.dcaXY(), trackPos.dcaZ()}; + std::array dcaNeg{trackNeg.dcaXY(), trackNeg.dcaZ()}; std::array pVecPos{trackPos.pVector()}; std::array pVecNeg{trackNeg.pVector()}; if (trackPos.collisionId() != thisCollId) { @@ -131,7 +146,7 @@ struct HfFilterPrepareMlSamples { // Main struct auto flag = RecoDecay::OriginType::None; - if (fillOnlyBackground && !(isCharmHadronMassInSbRegions(invMassD0, invMassD0bar, massSbLeftMin, massSbLeftMax) || (isCharmHadronMassInSbRegions(invMassD0, invMassD0bar, massSbRightMin, massSbRightMax)))) + if (fillOnlyBackground && !(helper.isCharmHadronMassInSbRegions(invMassD0, invMassD0bar, massSbLeftMin, massSbLeftMax) || (helper.isCharmHadronMassInSbRegions(invMassD0, invMassD0bar, massSbRightMin, massSbRightMax)))) continue; float pseudoRndm = trackPos.pt() * 1000. - static_cast(trackPos.pt() * 1000); if (pseudoRndm < downSampleBkgFactor) { @@ -167,9 +182,9 @@ struct HfFilterPrepareMlSamples { // Main struct auto trackParFirst = getTrackPar(trackFirst); auto trackParSecond = getTrackPar(trackSecond); auto trackParThird = getTrackPar(trackThird); - o2::gpu::gpustd::array dcaFirst{trackFirst.dcaXY(), trackFirst.dcaZ()}; - o2::gpu::gpustd::array dcaSecond{trackSecond.dcaXY(), trackSecond.dcaZ()}; - o2::gpu::gpustd::array dcaThird{trackThird.dcaXY(), trackThird.dcaZ()}; + std::array dcaFirst{trackFirst.dcaXY(), trackFirst.dcaZ()}; + std::array dcaSecond{trackSecond.dcaXY(), trackSecond.dcaZ()}; + std::array dcaThird{trackThird.dcaXY(), trackThird.dcaZ()}; std::array pVecFirst{trackFirst.pVector()}; std::array pVecSecond{trackSecond.pVector()}; std::array pVecThird{trackThird.pVector()}; @@ -244,8 +259,8 @@ struct HfFilterPrepareMlSamples { // Main struct auto trackParPos = getTrackPar(trackPos); auto trackParNeg = getTrackPar(trackNeg); - o2::gpu::gpustd::array dcaPos{trackPos.dcaXY(), trackPos.dcaZ()}; - o2::gpu::gpustd::array dcaNeg{trackNeg.dcaXY(), trackNeg.dcaZ()}; + std::array dcaPos{trackPos.dcaXY(), trackPos.dcaZ()}; + std::array dcaNeg{trackNeg.dcaXY(), trackNeg.dcaZ()}; std::array pVecPos{trackPos.pVector()}; std::array pVecNeg{trackNeg.pVector()}; if (trackPos.collisionId() != thisCollId) { @@ -268,7 +283,15 @@ struct HfFilterPrepareMlSamples { // Main struct // D0(bar) → π± K∓ bool isInCorrectColl{false}; - auto indexRec = RecoDecay::getMatchedMCRec(mcParticles, std::array{trackPos, trackNeg}, o2::constants::physics::Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign); + auto indexRec = RecoDecay::getMatchedMCRec(mcParticles, std::array{trackPos, trackNeg}, o2::constants::physics::Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign); + + if (fillOnlySignal && indexRec < 0) { + continue; + } + if (fillOnlyBackground && indexRec >= 0) { + continue; + } + if (indexRec > -1) { auto particle = mcParticles.rawIteratorAt(indexRec); flag = RecoDecay::getCharmHadronOrigin(mcParticles, particle); @@ -311,9 +334,9 @@ struct HfFilterPrepareMlSamples { // Main struct auto trackParFirst = getTrackPar(trackFirst); auto trackParSecond = getTrackPar(trackSecond); auto trackParThird = getTrackPar(trackThird); - o2::gpu::gpustd::array dcaFirst{trackFirst.dcaXY(), trackFirst.dcaZ()}; - o2::gpu::gpustd::array dcaSecond{trackSecond.dcaXY(), trackSecond.dcaZ()}; - o2::gpu::gpustd::array dcaThird{trackThird.dcaXY(), trackThird.dcaZ()}; + std::array dcaFirst{trackFirst.dcaXY(), trackFirst.dcaZ()}; + std::array dcaSecond{trackSecond.dcaXY(), trackSecond.dcaZ()}; + std::array dcaThird{trackThird.dcaXY(), trackThird.dcaZ()}; std::array pVecFirst{trackFirst.pVector()}; std::array pVecSecond{trackSecond.pVector()}; std::array pVecThird{trackThird.pVector()}; @@ -355,32 +378,39 @@ struct HfFilterPrepareMlSamples { // Main struct int8_t channel = -1; // D± → π± K∓ π± - auto indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2); + auto indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2); if (indexRec >= 0) { channel = kDplus; } if (indexRec < 0) { // Ds± → K± K∓ π± - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kDS, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kDS, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2); if (indexRec >= 0) { channel = kDs; } } if (indexRec < 0) { // Λc± → p± K∓ π± - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2); if (indexRec >= 0) { channel = kLc; } } if (indexRec < 0) { // Ξc± → p± K∓ π± - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kXiCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, o2::constants::physics::Pdg::kXiCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2); if (indexRec >= 0) { channel = kXic; } } + if (fillOnlySignal && indexRec < 0) { + continue; + } + if (fillOnlyBackground && indexRec >= 0) { + continue; + } + bool isInCorrectColl{false}; if (indexRec > -1) { auto particle = mcParticles.rawIteratorAt(indexRec); diff --git a/EventFiltering/PWGJE/jetFilter.cxx b/EventFiltering/PWGJE/jetFilter.cxx index 54c24ee627d..277f749d22b 100644 --- a/EventFiltering/PWGJE/jetFilter.cxx +++ b/EventFiltering/PWGJE/jetFilter.cxx @@ -14,6 +14,7 @@ #include #include #include +#include #include "Framework/ASoA.h" #include "Framework/ASoAHelpers.h" @@ -94,13 +95,13 @@ struct jetFilter { Filter trackFilter = (nabs(aod::jtrack::eta) < static_cast(cfgEtaTPC)) && (aod::jtrack::pt > trackPtMin); int trackSelection = -1; - int eventSelection = -1; + std::vector eventSelectionBits; void init(o2::framework::InitContext&) { triggerJetR = TMath::Nint(cfgJetR * 100.0f); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(evSel)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(evSel)); spectra.add("fCollZpos", "collision z position", HistType::kTH1F, {{200, -20., +20., "#it{z}_{vtx} position (cm)"}}); @@ -196,7 +197,7 @@ struct jetFilter { spectra.fill(HIST("fCollZpos"), collision.posZ()); hProcessedEvents->Fill(static_cast(kBinAllEvents) + 0.1f); // all minimum bias events - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { tags(keepEvent[kJetChLowPt], keepEvent[kJetChHighPt], keepEvent[kTrackLowPt], keepEvent[kTrackHighPt]); return; } diff --git a/EventFiltering/PWGLF/filterdoublephi.cxx b/EventFiltering/PWGLF/filterdoublephi.cxx new file mode 100644 index 00000000000..0ee9f34b535 --- /dev/null +++ b/EventFiltering/PWGLF/filterdoublephi.cxx @@ -0,0 +1,282 @@ +// 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. + +/// \file filterdoublephi.cxx +/// \brief Selection of events with triplets and pairs for femtoscopic studies +/// +/// \author Sourav Kundu, sourav.kundu@cern.ch + +#include +#include +#include +#include +#include +#include // FIXME +#include // FIXME + +#include +#include +#include +#include + +#include "../filterTables.h" +#include "PWGLF/DataModel/ReducedDoublePhiTables.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "CommonConstants/MathConstants.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "Common/DataModel/PIDResponseITS.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct filterdoublephi { + + // Produce derived tables + Produces tags; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + // Configurable cfgCutCentralityMax{"cfgCutCentralityMax", 0.0f, "Accepted maximum Centrality"}; + // Configurable cfgCutCentralityMin{"cfgCutCentralityMin", 100.0f, "Accepted minimum Centrality"}; + // track + Configurable isPtdepPID1{"isPtdepPID1", false, "use pt dep PID kplus"}; + Configurable isPtdepPID2{"isPtdepPID2", false, "use pt dep PID kminus"}; + Configurable useGlobalTrack{"useGlobalTrack", true, "use Global track"}; + Configurable cfgCutTOFBeta{"cfgCutTOFBeta", 0.0, "cut TOF beta"}; + Configurable cfgCutCharge{"cfgCutCharge", 0.0, "cut on Charge"}; + Configurable cfgCutPT{"cfgCutPT", 0.2, "PT cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; + Configurable nsigmaCutTPC{"nsigmacutTPC", -2.0, "Value of the TPC Nsigma cut"}; + Configurable nsigmaCutTPCPreSel{"nsigmacutTPCPreSel", 3.0, "Value of the TPC Nsigma cut Pre selection"}; + Configurable nsigmaCutTOF{"nsigmaCutTOF", 3.0, "Value of the TOF Nsigma cut"}; + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; + Configurable isDeepAngle{"isDeepAngle", true, "Deep Angle cut"}; + Configurable cfgDeepAngle{"cfgDeepAngle", 0.04, "Deep Angle cut value"}; + ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {120, 0.98, 1.1}, "#it{M} (GeV/#it{c}^{2})"}; + ConfigurableAxis configThnAxisPt{"configThnAxisPt", {100, 0.0, 10.}, "#it{p}_{T} (GeV/#it{c})"}; + Configurable minPhiMass{"minPhiMass", 1.01, "Minimum phi mass"}; + Configurable maxPhiMass{"maxPhiMass", 1.03, "Maximum phi mass"}; + Configurable MinPhiPairPt{"MinPhiPairPt", 2.0, "Minimum phi pair Pt"}; + Configurable MinPhiPairMass{"MinPhiPairMass", 2.5, "Minimum phi pair mass"}; + Configurable MaxPhiPairMass{"MaxPhiPairMass", 3.0, "Max phi pair mass"}; + + // Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + // Filter centralityFilter = (nabs(aod::cent::centFT0C) < cfgCutCentralityMax && nabs(aod::cent::centFT0C) > cfgCutCentralityMin); + Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPT); + Filter DCAcutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + Filter PIDcutFilter = nabs(aod::pidtpc::tpcNSigmaKa) < nsigmaCutTPCPreSel; + + // using EventCandidates = soa::Filtered>; + using EventCandidates = soa::Join; + using TrackCandidates = soa::Filtered>; + + SliceCache cache; + Partition posTracks = aod::track::signed1Pt > cfgCutCharge; + Partition negTracks = aod::track::signed1Pt < cfgCutCharge; + + // Histogram + OutputObj hProcessedEvents{TH1D("hProcessedEvents", ";; Number of events", 3, 0.0f, 3.0f)}; + HistogramRegistry qaRegistry{"QAHistos", { + {"hInvMassPhi", "hInvMassPhi", {HistType::kTH2F, {{40, 1.0f, 1.04f}, {100, 0.0f, 10.0f}}}}, + {"hInvMassDoublePhi", "hInvMassDoublePhi", {HistType::kTH2F, {{1000, 2.0f, 3.0f}, {100, 0.0f, 10.0f}}}}, + {"hNsigmaPtkaonTPC", "hNsigmaPtkaonTPC", {HistType::kTH2F, {{200, -10.0f, 10.0f}, {100, 0.0f, 10.0f}}}}, + {"hNsigmaPtkaonTOF", "hNsigmaPtkaonTOF", {HistType::kTH2F, {{200, -10.0f, 10.0f}, {100, 0.0f, 10.0f}}}}, + }, + OutputObjHandlingPolicy::AnalysisObject}; + + double massKa = o2::constants::physics::MassKPlus; + + void init(o2::framework::InitContext&) + { + hProcessedEvents->GetXaxis()->SetBinLabel(1, "All events"); + hProcessedEvents->GetXaxis()->SetBinLabel(2, "Events with double Phi without sel."); + hProcessedEvents->GetXaxis()->SetBinLabel(3, aod::filtering::TriggerEventDoublePhi::columnLabel()); + } + + template + bool selectionTrack(const T& candidate) + { + if (useGlobalTrack && !(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsCrossedRows() > cfgTPCcluster)) { + return false; + } + return true; + } + template + bool selectionPID(const T& candidate) + { + if (candidate.pt() < 0.5 && candidate.tpcNSigmaKa() > nsigmaCutTPC && candidate.tpcNSigmaKa() < 3.0) { + return true; + } + if (candidate.pt() >= 0.5) { + if (!candidate.hasTOF() && candidate.tpcNSigmaKa() > nsigmaCutTPC && candidate.tpcNSigmaKa() < 2.0) { + return true; + } + if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Sqrt(candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) < nsigmaCutTOF) { + return true; + } + } + return false; + } + template + bool selectionPID2(const T& candidate) + { + if (candidate.pt() < 0.5 && candidate.tpcNSigmaKa() > nsigmaCutTPC && candidate.tpcNSigmaKa() < 3.0) { + return true; + } + if (candidate.pt() >= 0.5 && candidate.pt() < 5.0) { + if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Sqrt(candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) < nsigmaCutTOF) { + return true; + } + } + if (candidate.pt() >= 5.0 && candidate.tpcNSigmaKa() > nsigmaCutTPC && candidate.tpcNSigmaKa() < 2.0) { + return true; + } + return false; + } + // deep angle cut on pair to remove photon conversion + template + bool selectionPair(const T1& candidate1, const T2& candidate2) + { + double pt1, pt2, pz1, pz2, p1, p2, angle; + pt1 = candidate1.pt(); + pt2 = candidate2.pt(); + pz1 = candidate1.pz(); + pz2 = candidate2.pz(); + p1 = candidate1.p(); + p2 = candidate2.p(); + angle = TMath::ACos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); + if (isDeepAngle && angle < cfgDeepAngle) { + return false; + } + return true; + } + + ROOT::Math::PxPyPzMVector KaonPlus, KaonMinus, PhiMesonMother, PhiVectorDummy, PhiVectorDummy2, PhiPair; + void processPhiReducedTable(EventCandidates::iterator const& collision, TrackCandidates const&, aod::BCsWithTimestamps const&) + { + bool keepEventDoublePhi = false; + int numberPhi = 0; + o2::aod::ITSResponse itsResponse; + std::vector Phid1Index = {}; + std::vector Phid2Index = {}; + std::vector phiresonance, phiresonanced1, phiresonanced2; + int Npostrack = 0; + int Nnegtrack = 0; + hProcessedEvents->Fill(0.5); + if (collision.sel8()) { + auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto track1 : posThisColl) { + // track selection + if (!selectionTrack(track1)) { + continue; + } + // PID check + if (isPtdepPID1 && !selectionPID2(track1)) { + continue; + } + if (!isPtdepPID1 && !selectionPID(track1)) { + continue; + } + if (track1.pt() > 0.4 && track1.pt() < 1.0 && !(itsResponse.nSigmaITS(track1) > -2.0 && itsResponse.nSigmaITS(track1) < 3.0)) { + continue; + } + Npostrack = Npostrack + 1; + qaRegistry.fill(HIST("hNsigmaPtkaonTPC"), track1.tpcNSigmaKa(), track1.pt()); + if (track1.hasTOF()) { + qaRegistry.fill(HIST("hNsigmaPtkaonTOF"), track1.tofNSigmaKa(), track1.pt()); + } + auto track1ID = track1.globalIndex(); + for (auto track2 : negThisColl) { + // track selection + if (!selectionTrack(track2)) { + continue; + } + // PID check + if (isPtdepPID2 && !selectionPID2(track2)) { + continue; + } + if (!isPtdepPID2 && !selectionPID(track2)) { + continue; + } + if (track2.pt() > 0.4 && track2.pt() < 1.0 && !(itsResponse.nSigmaITS(track2) > -2.0 && itsResponse.nSigmaITS(track2) < 3.0)) { + continue; + } + if (Npostrack == 1) { + Nnegtrack = Nnegtrack + 1; + } + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) { + continue; + } + if (!selectionPair(track1, track2)) { + continue; + } + KaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + KaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + PhiMesonMother = KaonPlus + KaonMinus; + if (PhiMesonMother.M() > minPhiMass && PhiMesonMother.M() < maxPhiMass) { + numberPhi = numberPhi + 1; + ROOT::Math::PtEtaPhiMVector temp1(track1.pt(), track1.eta(), track1.phi(), massKa); + ROOT::Math::PtEtaPhiMVector temp2(track2.pt(), track2.eta(), track2.phi(), massKa); + ROOT::Math::PtEtaPhiMVector temp3(PhiMesonMother.pt(), PhiMesonMother.eta(), PhiMesonMother.phi(), PhiMesonMother.M()); + phiresonanced1.push_back(temp1); + phiresonanced2.push_back(temp2); + phiresonance.push_back(temp3); + Phid1Index.push_back(track1.globalIndex()); + Phid2Index.push_back(track2.globalIndex()); + qaRegistry.fill(HIST("hInvMassPhi"), PhiMesonMother.M(), PhiMesonMother.Pt()); + } + } + } + } // select collision + if (numberPhi > 1 && Npostrack > 1 && Nnegtrack > 1 && (phiresonance.size() == phiresonanced1.size()) && (phiresonance.size() == phiresonanced2.size())) { + hProcessedEvents->Fill(1.5); + for (auto if1 = phiresonance.begin(); if1 != phiresonance.end(); ++if1) { + auto i5 = std::distance(phiresonance.begin(), if1); + PhiVectorDummy = phiresonance.at(i5); + for (auto if2 = if1 + 1; if2 != phiresonance.end(); ++if2) { + auto i6 = std::distance(phiresonance.begin(), if2); + PhiVectorDummy2 = phiresonance.at(i6); + PhiPair = PhiVectorDummy + PhiVectorDummy2; + if (!(Phid1Index.at(i5) == Phid1Index.at(i6) || Phid2Index.at(i5) == Phid2Index.at(i6)) && PhiPair.M() > MinPhiPairMass && PhiPair.M() < MaxPhiPairMass && PhiPair.Pt() > MinPhiPairPt) { + qaRegistry.fill(HIST("hInvMassDoublePhi"), PhiPair.M(), PhiPair.Pt()); + keepEventDoublePhi = true; + } + } + } + } + if (keepEventDoublePhi) { + hProcessedEvents->Fill(2.5); + } + tags(keepEventDoublePhi); + } // process + PROCESS_SWITCH(filterdoublephi, processPhiReducedTable, "Process table creation for double phi", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfg) +{ + return WorkflowSpec{adaptAnalysisTask(cfg, TaskName{"lf-doublephi-filter"})}; +} diff --git a/EventFiltering/PWGLF/filterf1proton.cxx b/EventFiltering/PWGLF/filterf1proton.cxx index 0d3d643207e..abdfe9c272a 100644 --- a/EventFiltering/PWGLF/filterf1proton.cxx +++ b/EventFiltering/PWGLF/filterf1proton.cxx @@ -17,12 +17,20 @@ #include #include #include +#include #include #include #include #include #include - +#include + +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "ReconstructionDataFormats/Track.h" +#include "ReconstructionDataFormats/TrackParametrization.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" #include "../filterTables.h" #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" @@ -36,6 +44,8 @@ #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/Utils/strangenessBuilderHelper.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" #include "CommonConstants/PhysicsConstants.h" #include "DataFormatsTPC/BetheBlochAleph.h" #include "CCDB/BasicCCDBManager.h" @@ -151,8 +161,22 @@ struct filterf1proton { }, OutputObjHandlingPolicy::AnalysisObject}; + // helper object + o2::pwglf::strangenessBuilderHelper mStraHelper; + int mRunNumber = 0; + float mBz = 0.; + void init(o2::framework::InitContext&) { + // set V0 parameters in the helper + mStraHelper.v0selections.minCrossedRows = ConfDaughTPCnclsMin; + mStraHelper.v0selections.dcanegtopv = ConfDaughDCAMin; + mStraHelper.v0selections.dcapostopv = ConfDaughDCAMin; // get the minimum one + mStraHelper.v0selections.v0cospa = ConfV0CPAMin; + mStraHelper.v0selections.dcav0dau = ConfV0DCADaughMax; + mStraHelper.v0selections.v0radius = ConfV0TranRadV0Min; + mStraHelper.v0selections.maxDaughterEta = ConfDaughEta; + ccdb->setURL(url.value); ccdbApi.init(url); ccdb->setCaching(true); @@ -163,6 +187,26 @@ struct filterf1proton { hProcessedEvents->GetXaxis()->SetBinLabel(3, aod::filtering::TriggerEventF1Proton::columnLabel()); } + void initCCDB(int run) + { + if (run != mRunNumber) { + mRunNumber = run; + o2::parameters::GRPMagField* grpmag = ccdb->getForRun("GLO/Config/GRPMagField", run); + o2::base::Propagator::initFieldFromGRP(grpmag); + mBz = static_cast(grpmag->getNominalL3Field()); + mStraHelper.fitter.setBz(mBz); + } + if (!mStraHelper.lut) { /// done only once + ccdb->setURL(url.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(true); + auto* lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); + o2::base::Propagator::Instance()->setMatLUT(lut); + mStraHelper.lut = lut; + } + } + template bool isSelectedEvent(T const& col) { @@ -257,10 +301,10 @@ struct filterf1proton { bool isSelectedV0Daughter(T const& track, float charge, double nsigmaV0Daughter) { const auto eta = track.eta(); - const auto tpcNClsF = track.tpcNClsFound(); + // const auto tpcNClsF = track.tpcNClsFound(); + const auto tpcNClsF = track.tpcNClsCrossedRows(); const auto dcaXY = track.dcaXY(); const auto sign = track.sign(); - if (charge < 0 && sign > 0) { return false; } @@ -276,7 +320,6 @@ struct filterf1proton { if (std::abs(dcaXY) < ConfDaughDCAMin) { return false; } - if (std::abs(nsigmaV0Daughter) > ConfDaughPIDCuts) { return false; } @@ -439,6 +482,7 @@ struct filterf1proton { aod::pidTPCFullPi, aod::pidTOFFullPi, aod::pidTPCFullKa, aod::pidTOFFullKa, aod::pidTPCFullPr, aod::pidTOFFullPr>>; + using PrimaryTrackCandidatesIU = soa::Filtered>; void processF1Proton(EventCandidates::iterator const& collision, aod::BCsWithTimestamps const&, PrimaryTrackCandidates const& tracks, ResoV0s const& V0s) { @@ -572,8 +616,8 @@ struct filterf1proton { if (!SelectionV0(collision, v0)) { continue; } - auto postrack = v0.template posTrack_as(); - auto negtrack = v0.template negTrack_as(); + auto postrack = v0.posTrack_as(); + auto negtrack = v0.negTrack_as(); double nTPCSigmaPos[1]{postrack.tpcNSigmaPi()}; double nTPCSigmaNeg[1]{negtrack.tpcNSigmaPi()}; if (ConfUseManualPIDdaughterPion) { @@ -655,7 +699,207 @@ struct filterf1proton { } tags(keepEventF1Proton); } - PROCESS_SWITCH(filterf1proton, processF1Proton, "Process for trigger", true); + PROCESS_SWITCH(filterf1proton, processF1Proton, "Process for trigger", false); + TLorentzVector v0Dummy; + void processF1ProtonHelper(EventCandidates::iterator const& collision, aod::BCs const&, PrimaryTrackCandidatesIU const& tracks, aod::V0s const& V0s) + { + initCCDB(collision.bc().runNumber()); + bool keepEventF1Proton = false; + int numberF1 = 0; + if (isSelectedEvent(collision)) { + + // keep track of indices + std::vector PionIndex = {}; + std::vector KaonIndex = {}; + std::vector ProtonIndex = {}; + + // keep charge of track + std::vector PionCharge = {}; + std::vector KaonCharge = {}; + std::vector ProtonCharge = {}; + + // Prepare vectors for different species + std::vector protons, kaons, pions, kshorts; + float kstar = 999.f; + + for (auto& track : tracks) { + + if (!isSelectedTrack(track)) + continue; + qaRegistry.fill(HIST("hDCAxy"), track.dcaXY()); + qaRegistry.fill(HIST("hDCAz"), track.dcaZ()); + qaRegistry.fill(HIST("hEta"), track.eta()); + qaRegistry.fill(HIST("hPhi"), track.phi()); + double nTPCSigmaP[3]{track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; + double nTPCSigmaN[3]{track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; + + if ((track.sign() > 0 && SelectionPID(track, strategyPIDPion, 0, nTPCSigmaP[0])) || (track.sign() < 0 && SelectionPID(track, strategyPIDPion, 0, nTPCSigmaN[0]))) { + ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), massPi); + pions.push_back(temp); + PionIndex.push_back(track.globalIndex()); + PionCharge.push_back(track.sign()); + if (track.sign() > 0) { + qaRegistry.fill(HIST("hNsigmaPtpionTPC"), nTPCSigmaP[0], track.pt()); + } + if (track.sign() < 0) { + qaRegistry.fill(HIST("hNsigmaPtpionTPC"), nTPCSigmaN[0], track.pt()); + } + if (track.hasTOF()) { + qaRegistry.fill(HIST("hNsigmaPtpionTOF"), track.tofNSigmaPi(), track.pt()); + } + } + + if ((track.pt() > cMinKaonPt && track.sign() > 0 && SelectionPID(track, strategyPIDKaon, 1, nTPCSigmaP[1])) || (track.pt() > cMinKaonPt && track.sign() < 0 && SelectionPID(track, strategyPIDKaon, 1, nTPCSigmaN[1]))) { + ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), massKa); + kaons.push_back(temp); + KaonIndex.push_back(track.globalIndex()); + KaonCharge.push_back(track.sign()); + if (track.sign() > 0) { + qaRegistry.fill(HIST("hNsigmaPtkaonTPC"), nTPCSigmaP[1], track.pt()); + } + if (track.sign() < 0) { + qaRegistry.fill(HIST("hNsigmaPtkaonTPC"), nTPCSigmaN[1], track.pt()); + } + if (track.hasTOF()) { + qaRegistry.fill(HIST("hNsigmaPtkaonTOF"), track.tofNSigmaKa(), track.pt()); + } + } + + if ((track.pt() < cMaxProtonPt && track.sign() > 0 && SelectionPID(track, strategyPIDProton, 2, nTPCSigmaP[2])) || (track.pt() < cMaxProtonPt && track.sign() < 0 && SelectionPID(track, strategyPIDProton, 2, nTPCSigmaN[2]))) { + ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), massPr); + qaRegistry.fill(HIST("hMommentumCorr"), track.p() / track.sign(), track.p() - track.tpcInnerParam()); + if (ConfFakeProton && !isFakeProton(track)) { + protons.push_back(temp); + ProtonIndex.push_back(track.globalIndex()); + ProtonCharge.push_back(track.sign()); + } + if (track.sign() > 0) { + qaRegistry.fill(HIST("hNsigmaPtprotonTPC"), nTPCSigmaP[2], track.pt()); + } + if (track.sign() < 0) { + qaRegistry.fill(HIST("hNsigmaPtprotonTPC"), nTPCSigmaN[2], track.pt()); + } + if (track.hasTOF()) { + qaRegistry.fill(HIST("hNsigmaPtprotonTOF"), track.tofNSigmaPr(), track.pt()); + } + } + } // track loop end + + // keep track of daugher indices to avoid selfcorrelations + std::vector KshortPosDaughIndex = {}; + std::vector KshortNegDaughIndex = {}; + + for (auto& v0 : V0s) { + + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + auto trackparpos = getTrackParCov(postrack); + auto trackparneg = getTrackParCov(negtrack); + if (!mStraHelper.buildV0Candidate(v0.collisionId(), collision.posX(), collision.posY(), collision.posZ(), postrack, negtrack, trackparpos, trackparneg)) { + continue; + } + + if (fabs(mStraHelper.v0.dcaToPV) > cMaxV0DCA) { + continue; + } + auto v0px = mStraHelper.v0.momentum[0]; + auto v0py = mStraHelper.v0.momentum[1]; + auto v0pz = mStraHelper.v0.momentum[2]; + auto pT = std::sqrt(v0px * v0px + v0py * v0py); + if (pT < ConfV0PtMin) { + continue; + } + if (std::hypot(mStraHelper.v0.position[0], mStraHelper.v0.position[1]) < ConfV0TranRadV0Min) { + continue; + } + if (std::hypot(mStraHelper.v0.position[0], mStraHelper.v0.position[1]) > ConfV0TranRadV0Max) { + continue; + } + double distovertotmom = std::hypot(mStraHelper.v0.position[0] - collision.posX(), mStraHelper.v0.position[1] - collision.posY(), mStraHelper.v0.position[2] - collision.posZ()) / (std::hypot(mStraHelper.v0.momentum[0], mStraHelper.v0.momentum[1], mStraHelper.v0.momentum[2]) + 1e-13); + if (distovertotmom * o2::constants::physics::MassK0Short > cMaxV0LifeTime) { + continue; + } + float lowmasscutks0 = 0.497 - 2.0 * cSigmaMassKs0; + float highmasscutks0 = 0.497 + 2.0 * cSigmaMassKs0; + if (mStraHelper.v0.massK0Short < lowmasscutks0 || mStraHelper.v0.massK0Short > highmasscutks0) { + continue; + } + double nTPCSigmaPos[1]{postrack.tpcNSigmaPi()}; + double nTPCSigmaNeg[1]{negtrack.tpcNSigmaPi()}; + if (!isSelectedV0Daughter(postrack, 1, nTPCSigmaPos[0])) { + continue; + } + if (!isSelectedV0Daughter(negtrack, -1, nTPCSigmaNeg[0])) { + continue; + } + v0Dummy.SetXYZM(v0px, v0py, v0pz, mStraHelper.v0.massK0Short); + qaRegistry.fill(HIST("hInvMassk0"), v0Dummy.M(), pT); + ROOT::Math::PtEtaPhiMVector temp(pT, v0Dummy.Eta(), v0Dummy.Phi(), mStraHelper.v0.massK0Short); + kshorts.push_back(temp); + KshortPosDaughIndex.push_back(postrack.globalIndex()); + KshortNegDaughIndex.push_back(negtrack.globalIndex()); + } + + if (pions.size() != 0 && kaons.size() != 0 && kshorts.size() != 0) { + for (auto ipion = pions.begin(); ipion != pions.end(); ++ipion) { + for (auto ikaon = kaons.begin(); ikaon != kaons.end(); ++ikaon) { + auto i1 = std::distance(pions.begin(), ipion); + auto i2 = std::distance(kaons.begin(), ikaon); + // if(PionCharge.at(i1)*KaonCharge.at(i2)>0)continue; + if (PionIndex.at(i1) == KaonIndex.at(i2)) + continue; + for (auto ikshort = kshorts.begin(); ikshort != kshorts.end(); ++ikshort) { + auto i3 = std::distance(kshorts.begin(), ikshort); + if (PionIndex.at(i1) == KshortPosDaughIndex.at(i3)) + continue; + if (PionIndex.at(i1) == KshortNegDaughIndex.at(i3)) + continue; + KKs0Vector = kaons.at(i2) + kshorts.at(i3); + if (KKs0Vector.M() > cMaxMassKKs0) + continue; + F1Vector = KKs0Vector + pions.at(i1); + if (F1Vector.M() > cMaxMassF1) + continue; + if (F1Vector.Pt() < cMinF1Pt) + continue; + if (PionCharge.at(i1) * KaonCharge.at(i2) > 0) { + qaRegistry.fill(HIST("hInvMassf1Like"), F1Vector.M(), F1Vector.Pt()); + continue; + } + qaRegistry.fill(HIST("hInvMassf1"), F1Vector.M(), F1Vector.Pt()); + numberF1 = numberF1 + 1; + for (auto iproton = protons.begin(); iproton != protons.end(); ++iproton) { + auto i4 = std::distance(protons.begin(), iproton); + if (ProtonIndex.at(i4) == PionIndex.at(i1)) + continue; + if (ProtonIndex.at(i4) == KaonIndex.at(i2)) + continue; + if (ProtonIndex.at(i4) == KshortPosDaughIndex.at(i3)) + continue; + if (ProtonIndex.at(i4) == KshortNegDaughIndex.at(i3)) + continue; + kstar = getkstar(F1Vector, *iproton); + qaRegistry.fill(HIST("hkstarDist"), kstar); + if (kstar > cMaxRelMom) + continue; + qaRegistry.fill(HIST("hInvMassf1kstar"), F1Vector.M(), F1Vector.Pt(), kstar); + keepEventF1Proton = true; + } + } + } + } + } + } + hProcessedEvents->Fill(0.5); + if (numberF1 > 0) { + hProcessedEvents->Fill(1.5); + } + if (keepEventF1Proton) { + hProcessedEvents->Fill(2.5); + } + tags(keepEventF1Proton); + } + PROCESS_SWITCH(filterf1proton, processF1ProtonHelper, "Process for trigger with helper v0 task", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfg) diff --git a/EventFiltering/PWGLF/nucleiFilter.cxx b/EventFiltering/PWGLF/nucleiFilter.cxx index 914f5d9ca9c..443df675533 100644 --- a/EventFiltering/PWGLF/nucleiFilter.cxx +++ b/EventFiltering/PWGLF/nucleiFilter.cxx @@ -10,33 +10,52 @@ // or submit itself to any jurisdiction. // O2 includes -#include -#include +#include "../filterTables.h" +#include "PWGLF/DataModel/LFPIDTOFGenericTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/Vtx3BodyTables.h" +#include "PWGLF/Utils/pidTOFGeneric.h" + +#include "Common/Core/PID/PIDTOF.h" +#include "Common/Core/trackUtilities.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DCAFitter/DCAFitterN.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTOF/ParameterContainers.h" #include "DataFormatsTPC/BetheBlochAleph.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" -#include "PWGLF/DataModel/Vtx3BodyTables.h" -#include "../filterTables.h" +#include "Math/GenVector/Boost.h" +#include "Math/Vector4D.h" + +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +o2::common::core::MetadataHelper metadataInfo; + namespace { static constexpr int nNuclei{3}; -static constexpr int nHyperNuclei{1}; -static constexpr int nITStriggers{2}; static constexpr int nCutsPID{5}; static constexpr std::array masses{ constants::physics::MassDeuteron, constants::physics::MassTriton, @@ -45,7 +64,7 @@ static constexpr std::array charges{1, 1, 2}; static const std::vector matterOrNot{"Matter", "Antimatter"}; static const std::vector nucleiNames{"H2", "H3", "Helium"}; static const std::vector hypernucleiNames{"H3L"}; // 3-body decay case -static const std::vector columnsNames{o2::aod::filtering::H2::columnLabel(), "fH3", o2::aod::filtering::He::columnLabel(), o2::aod::filtering::H3L3Body::columnLabel(), o2::aod::filtering::ITSmildIonisation::columnLabel(), o2::aod::filtering::ITSextremeIonisation::columnLabel()}; +static const std::vector columnsNames{o2::aod::filtering::H2::columnLabel(), o2::aod::filtering::He::columnLabel(), o2::aod::filtering::HeV0::columnLabel(), o2::aod::filtering::TritonFemto::columnLabel(), o2::aod::filtering::H3L3Body::columnLabel(), o2::aod::filtering::Tracked3Body::columnLabel(), o2::aod::filtering::ITSmildIonisation::columnLabel(), o2::aod::filtering::ITSextremeIonisation::columnLabel()}; static const std::vector cutsNames{ "TPCnSigmaMin", "TPCnSigmaMax", "TOFnSigmaMin", "TOFnSigmaMax", "TOFpidStartPt"}; constexpr double betheBlochDefault[nNuclei][6]{ @@ -88,39 +107,66 @@ struct nucleiFilter { Configurable cfgCutNclusTPC{"cfgCutNclusTPC", 80, "Minimum number of TPC clusters"}; Configurable cfgCutDCAxy{"cfgCutDCAxy", 3, "Max DCAxy"}; Configurable cfgCutDCAz{"cfgCutDCAz", 10, "Max DCAz"}; + Configurable cfgCutKstar{"cfgCutKstar", 1.f, "Kstar cut for triton femto trigger"}; + Configurable cfgCutCosPAheV0{"cfgCutCosPAheV0", 0.99, "CosPA cut for HeV0"}; Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], nNuclei, 6, nucleiNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for light nuclei"}; Configurable> cfgMomentumScalingBetheBloch{"cfgMomentumScalingBetheBloch", {bbMomScalingDefault[0], nNuclei, 2, nucleiNames, matterOrNot}, "TPC Bethe-Bloch momentum scaling for light nuclei"}; Configurable> cfgMinTPCmom{"cfgMinTPCmom", {minTPCmom[0], nNuclei, 2, nucleiNames, matterOrNot}, "Minimum TPC p/Z for nuclei PID"}; Configurable> cfgCutsPID{"nucleiCutsPID", {cutsPID[0], nNuclei, nCutsPID, nucleiNames, cutsNames}, "Nuclei PID selections"}; - + Configurable cfgFixTPCinnerParam{"cfgFixTPCinnerParam", false, "Fix TPC inner param"}; + + // variable/tool for hypertriton 3body decay + int mRunNumber; + float mBz; + Service ccdb; + using TrackCandidates = soa::Join; // FIXME: positio has been changed + o2::aod::pidtofgeneric::TofPidNewCollision bachelorTOFPID; + o2::base::MatLayerCylSet* lut = nullptr; + o2::vertexing::DCAFitterN<2> fitter2body; + o2::vertexing::DCAFitterN<3> fitter3body; + // TOF response and input parameters + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + o2::aod::pidtofgeneric::TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration // configurable for hypertriton 3body decay - Configurable minCosPA3body{"minCosPA3body", 0.99, "minCosPA3body"}; - Configurable dcavtxdau{"dcavtxdau", 1.0, "DCA Vtx Daughters"}; - Configurable dcapiontopv{"dcapiontopv", 0.05, "DCA Pion To PV"}; - Configurable TofPidNsigmaMin{"TofPidNsigmaMin", -5, "TofPidNsigmaMin"}; - Configurable TofPidNsigmaMax{"TofPidNsigmaMax", 5, "TofPidNsigmaMax"}; - Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; - Configurable lifetimecut{"lifetimecut", 40., "lifetimecut"}; // ct - Configurable minProtonPt{"minProtonPt", 0.3, "minProtonPt"}; - Configurable maxProtonPt{"maxProtonPt", 5, "maxProtonPt"}; - Configurable minPionPt{"minPionPt", 0.1, "minPionPt"}; - Configurable maxPionPt{"maxPionPt", 1.2, "maxPionPt"}; - Configurable minDeuteronPt{"minDeuteronPt", 0.6, "minDeuteronPt"}; - Configurable maxDeuteronPt{"maxDeuteronPt", 10, "maxDeuteronPt"}; - Configurable minDeuteronPUseTOF{"minDeuteronPUseTOF", 1, "minDeuteronPt Enable TOF PID"}; - Configurable h3LMassLowerlimit{"h3LMassLowerlimit", 2.96, "Hypertriton mass lower limit"}; - Configurable h3LMassUpperlimit{"h3LMassUpperlimit", 3.04, "Hypertriton mass upper limit"}; - Configurable mintpcNClsproton{"mintpcNClsproton", 90, "min tpc Nclusters for proton"}; - Configurable mintpcNClspion{"mintpcNClspion", 70, "min tpc Nclusters for pion"}; - Configurable mintpcNClsdeuteron{"mintpcNClsdeuteron", 100, "min tpc Nclusters for deuteron"}; - Configurable fixTPCinnerParam{"fixTPCinnerParam", false, "Fix TPC inner param"}; + struct : ConfigurableGroup { + Configurable bFieldInput{"trgH3L3Body.mBz", -999, "bz field, -999 is automatic"}; + Configurable minCosPA3body{"trgH3L3Body.minCosPA3body", 0.9995, "minCosPA3body"}; + Configurable dcavtxdau{"trgH3L3Body.dcavtxdau", 0.15, "meen DCA among Daughters"}; + Configurable dcapiontopv{"trgH3L3Body.dcapiontopv", 0.05, "DCA Pion To PV"}; + Configurable tofPIDNSigmaMin{"trgH3L3Body.tofPIDNSigmaMin", -5, "tofPIDNSigmaMin"}; + Configurable tofPIDNSigmaMax{"trgH3L3Body.tofPIDNSigmaMax", 5, "tofPIDNSigmaMax"}; + Configurable tpcPIDNSigmaCut{"trgH3L3Body.tpcPIDNSigmaCut", 5, "tpcPIDNSigmaCut"}; + Configurable lifetimecut{"trgH3L3Body.lifetimecut", 40., "lifetimecut"}; + Configurable minDaughtersEta{"trgH3L3Body.minDaughtersEta", 1.f, "minDaughtersEta"}; + Configurable minProtonPt{"trgH3L3Body.minProtonPt", 0.3, "minProtonPt"}; + Configurable maxProtonPt{"trgH3L3Body.maxProtonPt", 5, "maxProtonPt"}; + Configurable minPionPt{"trgH3L3Body.minPionPt", 0.1, "minPionPt"}; + Configurable maxPionPt{"trgH3L3Body.maxPionPt", 1.2, "maxPionPt"}; + Configurable minDeuteronPt{"trgH3L3Body.minDeuteronPt", 0.6, "minDeuteronPt"}; + Configurable maxDeuteronPt{"trgH3L3Body.maxDeuteronPt", 10, "maxDeuteronPt"}; + Configurable minDeuteronPUseTOF{"trgH3L3Body.minDeuteronPUseTOF", 999, "minDeuteronPt Enable TOF PID"}; + Configurable h3LMassLowerlimit{"trgH3L3Body.h3LMassLowerlimit", 2.96, "Hypertriton mass lower limit"}; + Configurable h3LMassUpperlimit{"trgH3L3Body.h3LMassUpperlimit", 3.04, "Hypertriton mass upper limit"}; + Configurable minP3Body{"trgH3L3Body.minP3Body", 1.5, "min P3Body"}; + Configurable mintpcNClsproton{"trgH3L3Body.mintpcNClsproton", 90, "min tpc Nclusters for proton"}; + Configurable mintpcNClspion{"trgH3L3Body.mintpcNClspion", 70, "min tpc Nclusters for pion"}; + Configurable mintpcNClsdeuteron{"trgH3L3Body.mintpcNClsdeuteron", 100, "min tpc Nclusters for deuteron"}; + + Configurable useMatCorrType{"trgH3L3Body.useMatCorrType", 0, "0: none, 1: TGeo, 2: LUT"}; + // CCDB options + Configurable ccdburl{"trgH3L3Body.ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"trgH3L3Body.grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"trgH3L3Body.grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"trgH3L3Body.lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"trgH3L3Body.geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + } trgH3L3Body; HistogramRegistry qaHists{"qaHists", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - OutputObj hProcessedEvents{TH1D("hProcessedEvents", ";;Number of filtered events", nNuclei + nHyperNuclei + nITStriggers + 1, -0.5, nNuclei + nHyperNuclei + nITStriggers + 0.5)}; + OutputObj hProcessedEvents{TH1D("hProcessedEvents", ";;Number of filtered events", kNtriggers + 1, -0.5, static_cast(kNtriggers) + 0.5)}; - void init(o2::framework::InitContext&) + void init(InitContext& initContext) { std::vector ptBinning = {0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.8, 3.2, 3.6, 4., 5.}; @@ -132,6 +178,8 @@ struct nucleiFilter { qaHists.add("fDeuTOFNsigma", "Deuteron TOF Nsigma distribution", HistType::kTH2F, {{1200, -6, 6, "#it{p} (GeV/#it{c})"}, {2000, -100, 100, "TOF n#sigma"}}); qaHists.add("fBachDeuTOFNsigma", "Bachelor Deuteron TOF Nsigma distribution", HistType::kTH2F, {{1200, -6, 6, "#it{p} (GeV/#it{c})"}, {2000, -100, 100, "TOF n#sigma"}}); qaHists.add("fH3LMassVsPt", "Hypertrion mass Vs pT", HistType::kTH2F, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {80, 2.96, 3.04, "Inv. Mass (GeV/c^{2})"}}); + qaHists.add("fH3LDcaVsPt", "DCA vs pT", HistType::kTH2F, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {100, 0, 0.05, "DCA (cm)"}}); + qaHists.add("fH3LCosPAVsPt", "CosPA vs pT", HistType::kTH2F, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {100, 0.999, 1.0, "CosPA"}}); qaHists.add("fExtremeIonisationITS", "ITS clusters for extreme ionisation trigger", HistType::kTH3F, {{4, 3.5, 7.5, "Number of ITS clusters"}, {150, 0, 15, "Average cluster size in ITS x cos#lambda"}, {100, 0.1, 10, "#it{p} (GeV/#it{c})"}}); for (int iN{0}; iN < nNuclei; ++iN) { @@ -143,28 +191,131 @@ struct nucleiFilter { for (uint32_t iS{0}; iS < columnsNames.size(); ++iS) { hProcessedEvents->GetXaxis()->SetBinLabel(iS + 2, columnsNames[iS].data()); } + + // for fH3L3Body + bachelorTOFPID.SetPidType(o2::track::PID::Deuteron); + fitter3body.setPropagateToPCA(true); + fitter3body.setMaxR(200.); + fitter3body.setMinParamChange(1e-3); + fitter3body.setMinRelChi2Change(0.9); + fitter3body.setMaxDZIni(1e9); + fitter3body.setMaxChi2(1e9); + fitter3body.setUseAbsDCA(true); + + fitter2body.setPropagateToPCA(true); + fitter2body.setMaxR(200.); + fitter2body.setMinParamChange(1e-3); + fitter2body.setMinRelChi2Change(0.9); + fitter2body.setMaxDZIni(1e9); + fitter2body.setMaxChi2(1e9); + fitter2body.setUseAbsDCA(true); + + ccdb->setURL(trgH3L3Body.ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + // Initialization of TOF PID parameters for fH3L3Body + mTOFCalibConfig.metadataInfo = metadataInfo; + mTOFCalibConfig.inheritFromBaseTask(initContext); + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + + // In case override, don't proceed, please - no CCDB access required + if (trgH3L3Body.bFieldInput > -990) { + mBz = trgH3L3Body.bFieldInput; + o2::parameters::GRPMagField grpmag; + if (std::fabs(mBz) > 1e-5) { + grpmag.setL3Current(30000.f / (mBz / 5.0f)); + } + o2::base::Propagator::initFieldFromGRP(&grpmag); + mRunNumber = bc.runNumber(); + return; + } + + auto run3grp_timestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(trgH3L3Body.grpPath, run3grp_timestamp); + o2::parameters::GRPMagField* grpmag = 0x0; + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + // Fetch magnetic field from ccdb for current collision + mBz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << mBz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(trgH3L3Body.grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << trgH3L3Body.grpmagPath << " of object GRPMagField and " << trgH3L3Body.grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + // Fetch magnetic field from ccdb for current collision + // mBz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + mBz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << mBz << " kZG"; + } + mRunNumber = bc.runNumber(); + // Set magnetic field value once known + fitter2body.setBz(mBz); + fitter3body.setBz(mBz); + + if (trgH3L3Body.useMatCorrType == 2) { + // setMatLUT only after magfield has been initalized + // (setMatLUT has implicit and problematic init field call if not) + o2::base::Propagator::Instance()->setMatLUT(lut); + } + + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, bc); } - using TrackCandidates = soa::Join; - void process(soa::Join::iterator const& collision, aod::Vtx3BodyDatas const& vtx3bodydatas, TrackCandidates const& tracks) + enum { + kH2 = 0, + kHe, + kHeV0, + kTritonFemto, + kH3L3Body, + kTracked3Body, + kITSmildIonisation, + kITSextremeIonisation, + kNtriggers + } TriggerType; + // void process(soa::Join::iterator const& collision, aod::Vtx3BodyDatas const& vtx3bodydatas, TrackCandidates const& tracks) + using ColWithEvTime = soa::Join; + void process(ColWithEvTime::iterator const& collision, aod::Decay3Bodys const& decay3bodys, TrackCandidates const& tracks, aod::AssignedTracked3Bodys const& tracked3Bodys, aod::V0s const& v0s, aod::BCsWithTimestamps const&) { // collision process loop - bool keepEvent[nNuclei + nHyperNuclei + nITStriggers]{false}; + std::array keepEvent{false}; // qaHists.fill(HIST("fCollZpos"), collision.posZ()); hProcessedEvents->Fill(0); // if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { - tags(keepEvent[0], keepEvent[2], keepEvent[3], keepEvent[4], keepEvent[5]); + tags(keepEvent[kH2], keepEvent[kHe], keepEvent[kHeV0], keepEvent[kTritonFemto], keepEvent[kH3L3Body], keepEvent[kTracked3Body], keepEvent[kITSmildIonisation], keepEvent[kITSextremeIonisation]); return; } + // const double bgScalings[nNuclei][2]{ {charges[0] * cfgMomentumScalingBetheBloch->get(0u, 0u) / masses[0], charges[0] * cfgMomentumScalingBetheBloch->get(0u, 1u) / masses[0]}, {charges[1] * cfgMomentumScalingBetheBloch->get(1u, 0u) / masses[1], charges[1] * cfgMomentumScalingBetheBloch->get(1u, 1u) / masses[1]}, {charges[2] * cfgMomentumScalingBetheBloch->get(2u, 0u) / masses[2], charges[2] * cfgMomentumScalingBetheBloch->get(2u, 1u) / masses[2]}}; - for (auto& track : tracks) { // start loop over tracks + constexpr int nucleusIndex[nNuclei]{kH2, -1, kHe}; /// remap for nuclei triggers + std::vector h3indices; + std::vector h3vectors; + + auto getNsigma = [&](const auto& track, int iN, int iC) { + float fixTPCrigidity{(cfgFixTPCinnerParam && (track.pidForTracking() == track::PID::Helium3 || track.pidForTracking() == track::PID::Alpha)) ? 0.5f : 1.f}; + double expBethe{tpc::BetheBlochAleph(static_cast(track.tpcInnerParam() * fixTPCrigidity * bgScalings[iN][iC]), cfgBetheBlochParams->get(iN, 0u), cfgBetheBlochParams->get(iN, 1u), cfgBetheBlochParams->get(iN, 2u), cfgBetheBlochParams->get(iN, 3u), cfgBetheBlochParams->get(iN, 4u))}; + double expSigma{expBethe * cfgBetheBlochParams->get(iN, 5u)}; + return static_cast((track.tpcSignal() - expBethe) / expSigma); + }; + + for (const auto& track : tracks) { // start loop over tracks if (track.itsNCls() >= cfgCutNclusExtremeIonisationITS) { double avgClsSize{0.}; double cosL{std::sqrt(1. / (1. + track.tgl() * track.tgl()))}; @@ -173,8 +324,8 @@ struct nucleiFilter { } avgClsSize = avgClsSize * cosL / track.itsNCls(); qaHists.fill(HIST("fExtremeIonisationITS"), track.itsNCls(), avgClsSize, track.p()); - keepEvent[4] = track.p() > cfgMomentumCutExtremeIonisation && avgClsSize > cfgCutClsSizeMildIonisation; - keepEvent[5] = track.p() > cfgMomentumCutExtremeIonisation && avgClsSize > cfgCutClsSizeExtremeIonisation; + keepEvent[kITSmildIonisation] = track.p() > cfgMomentumCutExtremeIonisation && avgClsSize > cfgCutClsSizeMildIonisation; + keepEvent[kITSextremeIonisation] = track.p() > cfgMomentumCutExtremeIonisation && avgClsSize > cfgCutClsSizeExtremeIonisation; } if (track.itsNCls() < cfgCutNclusITS || track.tpcNClsFound() < cfgCutNclusTPC) { @@ -185,10 +336,8 @@ struct nucleiFilter { qaHists.fill(HIST("fDeuTOFNsigma"), track.p() * track.sign(), track.tofNSigmaDe()); } - if (track.sign() > 0 && (std::abs(track.dcaXY()) > cfgCutDCAxy || - std::abs(track.dcaZ()) > cfgCutDCAz)) { - continue; - } + bool passesDCAselection{(track.sign() < 0 || (std::abs(track.dcaXY()) < cfgCutDCAxy && + std::abs(track.dcaZ()) < cfgCutDCAz))}; float nSigmaTPC[nNuclei]{ track.tpcNSigmaDe(), track.tpcNSigmaTr(), track.tpcNSigmaHe()}; @@ -196,7 +345,7 @@ struct nucleiFilter { track.tofNSigmaDe(), track.tofNSigmaTr(), track.tofNSigmaHe()}; const int iC{track.sign() < 0}; - float fixTPCrigidity{(fixTPCinnerParam && (track.pidForTracking() == track::PID::Helium3 || track.pidForTracking() == track::PID::Alpha)) ? 0.5f : 1.f}; + float fixTPCrigidity{(cfgFixTPCinnerParam && (track.pidForTracking() == track::PID::Helium3 || track.pidForTracking() == track::PID::Alpha)) ? 0.5f : 1.f}; // fill QA hist: dEdx for all charged tracks qaHists.fill(HIST("fTPCsignalAll"), track.sign() * track.tpcInnerParam() * fixTPCrigidity, track.tpcSignal()); @@ -208,9 +357,7 @@ struct nucleiFilter { } if (cfgBetheBlochParams->get(iN, 5u) > 0.f) { - double expBethe{tpc::BetheBlochAleph(static_cast(track.tpcInnerParam() * fixTPCrigidity * bgScalings[iN][iC]), cfgBetheBlochParams->get(iN, 0u), cfgBetheBlochParams->get(iN, 1u), cfgBetheBlochParams->get(iN, 2u), cfgBetheBlochParams->get(iN, 3u), cfgBetheBlochParams->get(iN, 4u))}; - double expSigma{expBethe * cfgBetheBlochParams->get(iN, 5u)}; - nSigmaTPC[iN] = static_cast((track.tpcSignal() - expBethe) / expSigma); + nSigmaTPC[iN] = getNsigma(track, iN, iC); } h2TPCnSigma[iN]->Fill(track.sign() * track.tpcInnerParam() * fixTPCrigidity, nSigmaTPC[iN]); if (nSigmaTPC[iN] < cfgCutsPID->get(iN, 0u) || nSigmaTPC[iN] > cfgCutsPID->get(iN, 1u)) { @@ -219,12 +366,18 @@ struct nucleiFilter { if (track.p() > cfgCutsPID->get(iN, 4u) && (nSigmaTOF[iN] < cfgCutsPID->get(iN, 2u) || nSigmaTOF[iN] > cfgCutsPID->get(iN, 3u))) { continue; } - keepEvent[iN] = true; - if (keepEvent[iN]) { + if (iN == 1 && passesDCAselection) { + h3indices.push_back(track.globalIndex()); + h3vectors.emplace_back(track.pt(), track.eta(), track.phi(), masses[iN]); + } + if (nucleusIndex[iN] < 0) { + continue; + } + keepEvent[nucleusIndex[iN]] = passesDCAselection; + if (keepEvent[nucleusIndex[iN]]) { h2TPCsignal[iN]->Fill(track.sign() * track.tpcInnerParam() * fixTPCrigidity, track.tpcSignal()); } } - // // fill QA histograms // @@ -232,57 +385,240 @@ struct nucleiFilter { } // end loop over tracks - // hypertriton 3body loop - for (auto& vtx : vtx3bodydatas) { + for (const auto& track : tracks) { + if (track.itsNCls() < cfgCutNclusITS || + track.tpcNClsFound() < cfgCutNclusTPC || + std::abs(track.dcaXY()) > cfgCutDCAxy || + std::abs(track.dcaZ()) > cfgCutDCAz || + std::abs(track.eta()) > cfgCutEta) { + continue; + } + const ROOT::Math::PtEtaPhiMVector trackVector(track.pt(), track.eta(), track.phi(), constants::physics::MassPiMinus); + for (size_t iH3{0}; iH3 < h3vectors.size(); ++iH3) { + if (h3indices[iH3] == track.globalIndex()) { + continue; + } + const auto& h3vector = h3vectors[iH3]; + auto pivector = trackVector; + auto cm = h3vector + trackVector; + const ROOT::Math::Boost boost(cm.BoostToCM()); + boost(pivector); + if (pivector.P() < cfgCutKstar) { + keepEvent[kTritonFemto] = true; + break; + } + } + } - auto track0 = vtx.track0_as(); - auto track1 = vtx.track1_as(); - auto track2 = vtx.track2_as(); + for (const auto& v0 : v0s) { + const auto& posTrack = v0.posTrack_as(); + const auto& negTrack = v0.negTrack_as(); + if ((posTrack.itsNCls() < cfgCutNclusITS || posTrack.tpcNClsFound() < cfgCutNclusTPC) && + (negTrack.itsNCls() < cfgCutNclusITS || negTrack.tpcNClsFound() < cfgCutNclusTPC)) { + continue; + } + float nSigmas[2]{ + cfgBetheBlochParams->get(2, 5u) > 0.f ? getNsigma(posTrack, 2, 0) : posTrack.tpcNSigmaHe(), + cfgBetheBlochParams->get(2, 5u) > 0.f ? getNsigma(negTrack, 2, 1) : negTrack.tpcNSigmaHe()}; - qaHists.fill(HIST("fBachDeuTOFNsigma"), track2.p() * track2.sign(), vtx.tofNSigmaBachDe()); + bool isHe3 = nSigmas[0] > cfgCutsPID->get(2, 0u) && nSigmas[0] < cfgCutsPID->get(2, 1u); + bool isAntiHe3 = nSigmas[1] > cfgCutsPID->get(2, 0u) && nSigmas[1] < cfgCutsPID->get(2, 1u); + if (!isHe3 && !isAntiHe3) { + continue; + } + auto& he3Track = isHe3 ? posTrack : negTrack; + auto& piTrack = isHe3 ? negTrack : posTrack; - if (vtx.vtxcosPA(collision.posX(), collision.posY(), collision.posZ()) < minCosPA3body) { + int n2bodyVtx = fitter2body.process(getTrackParCov(he3Track), getTrackParCov(piTrack)); + if (n2bodyVtx == 0) { continue; } - float ct = vtx.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassHyperTriton; - if (ct > lifetimecut) { + auto vtxXYZ = fitter2body.getPCACandidate(); + vtxXYZ[0] -= collision.posX(); + vtxXYZ[1] -= collision.posY(); + vtxXYZ[2] -= collision.posZ(); + + std::array momHe3 = {0.}; + std::array momPi = {0.}; + std::array momTot = {0.}; + auto& hePropTrack = fitter2body.getTrack(0); + auto& piPropTrack = fitter2body.getTrack(1); + hePropTrack.getPxPyPzGlo(momHe3); + piPropTrack.getPxPyPzGlo(momPi); + for (int i = 0; i < 3; ++i) { + momHe3[i] *= 2; + momTot[i] = momHe3[i] + momPi[i]; + } + double cosPA = (vtxXYZ[0] * momTot[0] + vtxXYZ[1] * momTot[1] + vtxXYZ[2] * momTot[2]) / + std::sqrt((vtxXYZ[0] * vtxXYZ[0] + vtxXYZ[1] * vtxXYZ[1] + vtxXYZ[2] * vtxXYZ[2]) * + (momTot[0] * momTot[0] + momTot[1] * momTot[1] + momTot[2] * momTot[2])); + if (cosPA < cfgCutCosPAheV0) { continue; } - if (vtx.dcaVtxdaughters() > dcavtxdau) { + keepEvent[kHeV0] = true; + break; + } + + // fH3L3Body trigger + auto bc = collision.bc_as(); + initCCDB(bc); + + for (const auto& decay3body : decay3bodys) { + auto track0 = decay3body.track0_as(); + auto track1 = decay3body.track1_as(); + auto track2 = decay3body.track2_as(); + + // track selection + // keep like-sign triplets, do not check sign of deuteron, use same cut for p and pi + if (track0.tpcNClsFound() < trgH3L3Body.mintpcNClspion || track1.tpcNClsFound() < trgH3L3Body.mintpcNClspion || track2.tpcNClsFound() < trgH3L3Body.mintpcNClsdeuteron) { continue; } - if ((vtx.tofNSigmaBachDe() < TofPidNsigmaMin || vtx.tofNSigmaBachDe() > TofPidNsigmaMax) && track2.p() > minDeuteronPUseTOF) { + + if (std::abs(track0.eta()) > trgH3L3Body.minDaughtersEta || std::abs(track1.eta()) > trgH3L3Body.minDaughtersEta || std::abs(track2.eta()) > trgH3L3Body.minDaughtersEta) { continue; } - if (std::abs(track0.tpcNSigmaPr()) < TpcPidNsigmaCut && std::abs(track1.tpcNSigmaPi()) < TpcPidNsigmaCut && std::abs(track2.tpcNSigmaDe()) < TpcPidNsigmaCut && vtx.mHypertriton() > h3LMassLowerlimit && vtx.mHypertriton() < h3LMassUpperlimit) { - if (track0.tpcNClsFound() >= mintpcNClsproton && track1.tpcNClsFound() >= mintpcNClspion && track2.tpcNClsFound() >= mintpcNClsdeuteron) { - if (std::abs(vtx.dcatrack1topv()) > dcapiontopv) { - keepEvent[3] = true; - qaHists.fill(HIST("fH3LMassVsPt"), vtx.pt(), vtx.mHypertriton()); + + bool isProton = false, isPion = false, isAntiProton = false, isAntiPion = false; + if (std::abs(track0.tpcNSigmaPr()) < std::abs(track0.tpcNSigmaPi())) { + if (track0.p() >= trgH3L3Body.minProtonPt && track0.p() <= trgH3L3Body.maxProtonPt) { + if (track0.tpcNClsFound() >= trgH3L3Body.mintpcNClsproton) { + isProton = true; } } } - if (std::abs(track0.tpcNSigmaPi()) < TpcPidNsigmaCut && std::abs(track1.tpcNSigmaPr()) < TpcPidNsigmaCut && std::abs(track2.tpcNSigmaDe()) < TpcPidNsigmaCut && vtx.mAntiHypertriton() > h3LMassLowerlimit && vtx.mAntiHypertriton() < h3LMassUpperlimit) { - if (track0.tpcNClsFound() >= mintpcNClspion && track1.tpcNClsFound() >= mintpcNClsproton && track2.tpcNClsFound() >= mintpcNClsdeuteron) { - if (std::abs(vtx.dcatrack0topv()) > dcapiontopv) { - keepEvent[3] = true; - qaHists.fill(HIST("fH3LMassVsPt"), vtx.pt(), vtx.mAntiHypertriton()); + if (std::abs(track0.tpcNSigmaPi()) < std::abs(track0.tpcNSigmaPr())) { + if (track0.p() >= trgH3L3Body.minPionPt && track0.p() <= trgH3L3Body.maxPionPt) { + isPion = true; + } + } + if (std::abs(track1.tpcNSigmaPr()) < std::abs(track1.tpcNSigmaPi())) { + if (track1.p() >= trgH3L3Body.minProtonPt && track1.p() <= trgH3L3Body.maxProtonPt) { + if (track1.tpcNClsFound() >= trgH3L3Body.mintpcNClsproton) { + isAntiProton = true; } } } - } // end loop over hypertriton 3body decay candidates + if (std::abs(track1.tpcNSigmaPi()) < std::abs(track1.tpcNSigmaPr())) { + if (track1.p() >= trgH3L3Body.minPionPt && track1.p() <= trgH3L3Body.maxPionPt) { + isAntiPion = true; + } + } + + if (!(isProton && isAntiPion) && !(isAntiProton && isPion)) { + continue; + } + + if (std::abs(track2.tpcNSigmaDe()) > trgH3L3Body.tpcPIDNSigmaCut || track2.p() < trgH3L3Body.minDeuteronPt || track2.p() > trgH3L3Body.maxDeuteronPt) { + continue; + } + + float tofNSigmaDeuteron = -999; + if (track2.has_collision() && track2.hasTOF()) { + auto originalcol = track2.collision_as(); + tofNSigmaDeuteron = bachelorTOFPID.GetTOFNSigma(mRespParamsV3, track2, originalcol, collision); + } + if (track2.p() > trgH3L3Body.minDeuteronPUseTOF && (tofNSigmaDeuteron < trgH3L3Body.tofPIDNSigmaMin || tofNSigmaDeuteron > trgH3L3Body.tofPIDNSigmaMax)) { + continue; + } + + // reconstruct the secondary vertex + auto Track0 = getTrackParCov(track0); + auto Track1 = getTrackParCov(track1); + auto Track2 = getTrackParCov(track2); + int n3bodyVtx = fitter3body.process(Track0, Track1, Track2); + if (n3bodyVtx == 0) { // discard this pair + continue; + } + + std::array pos = {0.}; + const auto& vtxXYZ = fitter3body.getPCACandidate(); + for (int i = 0; i < 3; i++) { + pos[i] = vtxXYZ[i]; + } + + // Calculate DCA with respect to the collision associated to the SV, not individual tracks + std::array dcaInfo; + + auto track0Par = getTrackPar(track0); + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track0Par, 2.f, fitter3body.getMatCorrType(), &dcaInfo); + auto track0dcaXY = dcaInfo[0]; + auto track0dca = std::sqrt(track0dcaXY * track0dcaXY + dcaInfo[1] * dcaInfo[1]); + + auto track1Par = getTrackPar(track1); + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track1Par, 2.f, fitter3body.getMatCorrType(), &dcaInfo); + auto track1dcaXY = dcaInfo[0]; + auto track1dca = std::sqrt(track1dcaXY * track1dcaXY + dcaInfo[1] * dcaInfo[1]); + + std::array p0 = {0.}, p1 = {0.}, p2{0.}; + const auto& propagatedTrack0 = fitter3body.getTrack(0); + const auto& propagatedTrack1 = fitter3body.getTrack(1); + const auto& propagatedTrack2 = fitter3body.getTrack(2); + propagatedTrack0.getPxPyPzGlo(p0); + propagatedTrack1.getPxPyPzGlo(p1); + propagatedTrack2.getPxPyPzGlo(p2); + std::array p3BXYZ = {p0[0] + p1[0] + p2[0], p0[1] + p1[1] + p2[1], p0[2] + p1[2] + p2[2]}; + float sqpt3B = p3BXYZ[0] * p3BXYZ[0] + p3BXYZ[1] * p3BXYZ[1]; + float sqp3B = sqpt3B + p3BXYZ[2] * p3BXYZ[2]; + float pt3B = std::sqrt(sqpt3B), p3B = std::sqrt(sqp3B); + + if (p3B < trgH3L3Body.minP3Body) { + continue; + } + + float dcaDaughters = std::sqrt(fitter3body.getChi2AtPCACandidate()); + if (dcaDaughters > trgH3L3Body.dcavtxdau) { + continue; + } + + float vtxCosPA = RecoDecay::cpa(std::array{collision.posX(), collision.posY(), collision.posZ()}, std::array{pos[0], pos[1], pos[2]}, std::array{p3BXYZ[0], p3BXYZ[1], p3BXYZ[2]}); + if (vtxCosPA < trgH3L3Body.minCosPA3body) { + continue; + } + float ct = std::sqrt(std::pow(pos[0] - collision.posX(), 2) + std::pow(pos[1] - collision.posY(), 2) + std::pow(pos[2] - collision.posZ(), 2)) / (p3B + 1E-10) * constants::physics::MassHyperTriton; + if (ct > trgH3L3Body.lifetimecut) { + continue; + } + + float invmassH3L = RecoDecay::m(std::array{std::array{p0[0], p0[1], p0[2]}, std::array{p1[0], p1[1], p1[2]}, std::array{p2[0], p2[1], p2[2]}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); + float invmassAntiH3L = RecoDecay::m(std::array{std::array{p0[0], p0[1], p0[2]}, std::array{p1[0], p1[1], p1[2]}, std::array{p2[0], p2[1], p2[2]}}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}); + + if (invmassH3L >= trgH3L3Body.h3LMassLowerlimit && invmassH3L <= trgH3L3Body.h3LMassUpperlimit) { + // Hypertriton hypothesis + if (isProton && isAntiPion && std::abs(track1dca) >= trgH3L3Body.dcapiontopv) { + qaHists.fill(HIST("fH3LMassVsPt"), pt3B, invmassH3L); + qaHists.fill(HIST("fBachDeuTOFNsigma"), track2.p() * track2.sign(), tofNSigmaDeuteron); + qaHists.fill(HIST("fH3LDcaVsPt"), pt3B, dcaDaughters); + qaHists.fill(HIST("fH3LCosPAVsPt"), pt3B, vtxCosPA); + keepEvent[kH3L3Body] = true; + } + } + if (invmassAntiH3L >= trgH3L3Body.h3LMassLowerlimit && invmassAntiH3L <= trgH3L3Body.h3LMassUpperlimit) { + // Anti-Hypertriton hypothesis + if (isAntiProton && isPion && std::abs(track0dca) >= trgH3L3Body.dcapiontopv) { + qaHists.fill(HIST("fH3LMassVsPt"), pt3B, invmassAntiH3L); + qaHists.fill(HIST("fBachDeuTOFNsigma"), track2.p() * track2.sign(), tofNSigmaDeuteron); + qaHists.fill(HIST("fH3LDcaVsPt"), pt3B, dcaDaughters); + qaHists.fill(HIST("fH3LCosPAVsPt"), pt3B, vtxCosPA); + keepEvent[kH3L3Body] = true; + } + } + } + + keepEvent[kTracked3Body] = tracked3Bodys.size() > 0; - for (int iDecision{0}; iDecision < nNuclei + nHyperNuclei + nITStriggers; ++iDecision) { + for (int iDecision{0}; iDecision < kNtriggers; ++iDecision) { if (keepEvent[iDecision]) { hProcessedEvents->Fill(iDecision + 1); } } - tags(keepEvent[0], keepEvent[2], keepEvent[3], keepEvent[4], keepEvent[5]); + + tags(keepEvent[kH2], keepEvent[kHe], keepEvent[kHeV0], keepEvent[kTritonFemto], keepEvent[kH3L3Body], keepEvent[kTracked3Body], keepEvent[kITSmildIonisation], keepEvent[kITSextremeIonisation]); } }; WorkflowSpec defineDataProcessing(ConfigContext const& cfg) { + metadataInfo.initMetadata(cfg); return WorkflowSpec{ adaptAnalysisTask(cfg)}; } diff --git a/EventFiltering/PWGLF/strangenessFilter.cxx b/EventFiltering/PWGLF/strangenessFilter.cxx index 1f615a54706..ceabf8eddfb 100644 --- a/EventFiltering/PWGLF/strangenessFilter.cxx +++ b/EventFiltering/PWGLF/strangenessFilter.cxx @@ -15,6 +15,7 @@ /// \since June 1, 2021 #include +#include "TVector3.h" #include "CCDB/BasicCCDBManager.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" @@ -25,6 +26,7 @@ #include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" #include "ReconstructionDataFormats/Track.h" +#include "ReconstructionDataFormats/TrackParametrization.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" #include "PWGLF/DataModel/LFStrangenessTables.h" @@ -37,6 +39,7 @@ #include "Common/DataModel/Multiplicity.h" #include "CommonConstants/PhysicsConstants.h" #include "../filterTables.h" +#include "PWGLF/Utils/strangenessBuilderHelper.h" using namespace o2; using namespace o2::framework; @@ -56,11 +59,15 @@ static const std::vector massSigmaParameterNames{"p0", "p1", "p2", static const std::vector speciesNames{"Xi", "Omega"}; } // namespace stfilter +float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) +{ + return std::hypot((pvY - Y) * Pz - (pvZ - Z) * Py, (pvX - X) * Pz - (pvZ - Z) * Px, (pvX - X) * Py - (pvY - Y) * Px) / std::sqrt(Px * Px + Py * Py + Pz * Pz); +} + struct strangenessFilter { // Recall the output table Produces strgtable; - TrackSelection mTrackSelector; // Define a histograms and registries HistogramRegistry QAHistos{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; @@ -68,14 +75,43 @@ struct strangenessFilter { HistogramRegistry QAHistosTriggerParticles{"QAHistosTriggerParticles", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; HistogramRegistry QAHistosStrangenessTracking{"QAHistosStrangenessTracking", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; HistogramRegistry EventsvsMultiplicity{"EventsvsMultiplicity", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - OutputObj hProcessedEvents{TH1D("hProcessedEvents", "Strangeness - event filtered;; Number of events", 16, -1., 15.)}; + OutputObj hProcessedEvents{TH1D("hProcessedEvents", "Strangeness - event filtered;; Number of events", 17, -1., 16.)}; OutputObj hCandidate{TH1F("hCandidate", "; Candidate pass selection; Number of events", 30, 0., 30.)}; OutputObj hEvtvshMinPt{TH1F("hEvtvshMinPt", " Number of h-Omega events with pT_h higher than thrd; min p_{T, trigg} (GeV/c); Number of events", 11, 0., 11.)}; - OutputObj hhXiPairsvsPt{TH1F("hhXiPairsvsPt", "pt distributions of Xi in events with a trigger particle; #it{p}_{T} (GeV/c); Number of Xi", 100, 0., 10.)}; + + // Dedicated selection criteria for lambda-lambda + struct : ConfigurableGroup { + Configurable cfgv0radiusMin{"cfgv0radiusMin", 1.2, "minimum decay radius"}; + Configurable cfgDCAPosToPVMin{"cfgDCAPosToPVMin", 0.05, "minimum DCA to PV for positive track"}; + Configurable cfgDCANegToPVMin{"cfgDCANegToPVMin", 0.2, "minimum DCA to PV for negative track"}; + Configurable cfgv0CosPA{"cfgv0CosPA", 0.995, "minimum v0 cosine"}; + Configurable cfgDCAV0Dau{"cfgDCAV0Dau", 1.0, "maximum DCA between daughters"}; + Configurable cfgV0PtMin{"cfgV0PtMin", 0, "minimum pT for lambda"}; + Configurable cfgV0RapMin{"cfgV0RapMin", -0.5, "maximum rapidity"}; + Configurable cfgV0RapMax{"cfgV0RapMax", 0.5, "maximum rapidity"}; + Configurable cfgV0LifeTime{"cfgV0LifeTime", 30., "maximum lambda lifetime"}; + Configurable cfgDaughTPCnclsMin{"cfgDaughTPCnclsMin", 70, "minimum fired crossed rows"}; + Configurable cfgITSNclus{"cfgITSNclus", 1, "minimum its cluster"}; + Configurable cfgRCrossedFindable{"cfgRCrossedFindable", 0.0, "minimum ratio of crossed rows over findable clusters"}; + Configurable cfgDaughPIDCutsTPCPr{"cfgDaughPIDCutsTPCPr", 5, "proton nsigma for TPC"}; + Configurable cfgDaughPIDCutsTPCPi{"cfgDaughPIDCutsTPCPi", 5, "pion nsigma for TPC"}; + Configurable cfgDaughEtaMin{"cfgDaughEtaMin", -0.8, "minimum daughter eta"}; + Configurable cfgDaughEtaMax{"cfgDaughEtaMax", 0.8, "maximum daughter eta"}; + Configurable cfgDaughPrPt{"cfgDaughPrPt", 0.5, "minimum daughter proton pt"}; + Configurable cfgDaughPiPt{"cfgDaughPiPt", 0.5, "minimum daughter pion pt"}; + Configurable cfgLambdaMassWindow{"cfgLambdaMassWindow", 0.01, "window for lambda mass selection"}; + Configurable cfgCompV0Rej{"cfgCompV0Rej", 0.01, "competing V0 rejection"}; + Configurable cfgMinCPAV0V0{"cfgMinCPAV0V0", 0.8, "minimum CPA of v0v0"}; + Configurable cfgMaxRadiusV0V0{"cfgMaxRadiusV0V0", 10.0, "maximum radius of v0v0"}; + Configurable cfgMaxDistanceV0V0{"cfgMaxDistanceV0V0", 5.0, "maximum distance of v0v0"}; + Configurable cfgMaxDCAV0V0{"cfgMaxDCAV0V0", 5.0, "maximum DCA of v0v0"}; + } cfgLLCuts; // Selection criteria for cascades + Configurable useCascadeMomentumAtPrimVtx{"useCascadeMomentumAtPrimVtx", false, "use cascade momentum at PV"}; Configurable doextraQA{"doextraQA", 1, "do extra QA"}; Configurable cutzvertex{"cutzvertex", 100.0f, "Accepted z-vertex range"}; + Configurable tpcmincrossedrows{"tpcmincrossedrows", 50, "Min number of crossed TPC rows"}; Configurable v0cospa{"v0cospa", 0.95, "V0 CosPA"}; Configurable casccospaxi{"casccospaxi", 0.95, "Casc CosPA"}; Configurable casccospaomega{"casccospaomega", 0.95, "Casc CosPA"}; @@ -105,10 +141,12 @@ struct strangenessFilter { Configurable nsigmatpcpr{"nsigmatpcpr", 6, "N Sigmas TPC pr"}; Configurable hastof{"hastof", 1, "Has TOF (OOB condition)"}; Configurable ptthrtof{"ptthrtof", 1.0, "Pt threshold to apply TOF condition"}; - Configurable kint7{"kint7", 0, "Apply kINT7 event selection"}; - Configurable sel7{"sel7", 0, "Apply sel7 event selection"}; Configurable sel8{"sel8", 0, "Apply sel8 event selection"}; Configurable LowLimitFT0MMult{"LowLimitFT0MMult", 3100, "FT0M selection for omega + high multiplicity trigger"}; + Configurable LowLimitFT0MMultNorm{"LowLimitFT0MMultNorm", 70, "FT0M selection for omega + high multiplicity trigger with Normalised FT0M"}; + Configurable useNormalisedMult{"useNormalisedMult", 1, "Use avarage multiplicity for HM omega like in multFilter.cxx"}; + Configurable avPyT0C{"avPyT0C", 8.83, "nch from pythia T0C"}; + Configurable avPyT0A{"avPyT0A", 8.16, "nch from pythia T0A"}; Configurable isTimeFrameBorderCut{"isTimeFrameBorderCut", 1, "Apply timeframe border cut"}; Configurable useSigmaBasedMassCutXi{"useSigmaBasedMassCutXi", true, "Mass window based on n*sigma instead of fixed"}; Configurable useSigmaBasedMassCutOmega{"useSigmaBasedMassCutOmega", true, "Mass window based on n*sigma instead of fixed"}; @@ -122,16 +160,12 @@ struct strangenessFilter { // Settings for strangeness tracking filter Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpMagPath{"grpMagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable matLutPath{"matLutPath", "GLO/Param/MatLUT", "Path of the material LUT"}; Configurable propToDCA{"propToDCA", true, "create tracks version propagated to PCA"}; Configurable useAbsDCA{"useAbsDCA", true, "Minimise abs. distance rather than chi2"}; Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"}; Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations if chi2/chi2old > this"}; - Configurable materialCorrectionType{"materialCorrectionType", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrLUT), "Type of material correction"}; Configurable minNoClsTrackedCascade{"minNoClsTrackedCascade", 70, "Minimum number of clusters required for daughters of tracked cascades"}; Configurable minPtTrackedCascade{"minPtTrackedCascade", 0., "Min. pt for tracked cascades"}; Configurable useNsigmaCutTrackedXi{"useNsigmaCutTrackedXi", true, "Mass window based on n*sigma instead of fixed"}; @@ -157,29 +191,126 @@ struct strangenessFilter { {stfilter::massSigmaParameters[0], 4, 2, stfilter::massSigmaParameterNames, stfilter::speciesNames}, "Mass resolution parameters: [0]*exp([1]*x)+[2]*exp([3]*x)"}; - float bz = 0.; + + // helper object + o2::pwglf::strangenessBuilderHelper mStraHelper; + o2::vertexing::DCAFitterN<2> mDCAFitter; + + /// CCDB and info/objects to be fetched from it + Service ccdb; + int mRunNumber = 0; + float mBz = 0.; + std::vector* mMeanMultT0C; + std::vector* mMeanMultT0A; + + bool selectTrack(const auto& track) + { + return track.pt() > hMinPt && std::abs(track.eta()) < hEta && track.tpcNClsCrossedRows() >= tpcmincrossedrows && track.tpcCrossedRowsOverFindableCls() >= 0.8f && track.tpcChi2NCl() <= 4.f && track.itsChi2NCl() <= 36.f && (track.itsClusterMap() & 0x7) != 0; + } + + float getV0V0DCA(TVector3 v01pos, TVector3 v01mom, TVector3 v02pos, TVector3 v02mom) + { + TVector3 posdiff = v02pos - v01pos; + TVector3 cross = v01mom.Cross(v02mom); + TVector3 dcaVec = (posdiff.Dot(cross) / cross.Mag2()) * cross; + return dcaVec.Mag(); + } + float getV0V0CPA(TVector3 v01mom, TVector3 v02mom) + { + return v01mom.Dot(v02mom) / (v01mom.Mag() * v02mom.Mag()); + } + float getV0V0Distance(TVector3 v01pos, TVector3 v02pos) + { + TVector3 posdiff = v02pos - v01pos; + return posdiff.Mag(); + } + float getV0V0Radius(TVector3 v01pos, TVector3 v01mom, TVector3 v02pos, TVector3 v02mom) + { + TVector3 posdiff = v02pos - v01pos; + v01mom *= 1. / v01mom.Mag(); + v02mom *= 1. / v02mom.Mag(); + float dd = 1. - TMath::Power(v01mom.Dot(v02mom), 2); + if (dd < 1e-5) + return 999; + float tt = posdiff.Dot(v01mom - v01mom.Dot(v02mom) * v02mom) / dd; + float ss = -posdiff.Dot(v02mom - v01mom.Dot(v02mom) * v01mom) / dd; + TVector3 radVec = v01pos + v02pos + tt * v01mom + ss * v02mom; + radVec *= 0.5; + return radVec.Mag(); + } + bool isSelectedV0V0(TVector3 v01pos, TVector3 v01mom, TVector3 v02pos, TVector3 v02mom) + { + if (getV0V0DCA(v01pos, v01mom, v02pos, v02mom) > cfgLLCuts.cfgMaxDCAV0V0) + return false; + if (getV0V0CPA(v01mom, v02mom) < cfgLLCuts.cfgMinCPAV0V0) + return false; + if (getV0V0Distance(v01pos, v02pos) > cfgLLCuts.cfgMaxDistanceV0V0) + return false; + if (getV0V0Radius(v01pos, v01mom, v02pos, v02mom) > cfgLLCuts.cfgMaxRadiusV0V0) + return false; + + return true; + } + + template + bool isSelectedV0Daughter(T const& track) + { + if (track.tpcNClsCrossedRows() < cfgLLCuts.cfgDaughTPCnclsMin) + return false; + if (track.tpcCrossedRowsOverFindableCls() < cfgLLCuts.cfgRCrossedFindable) + return false; + if (track.itsNCls() < cfgLLCuts.cfgITSNclus) + return false; + if (track.eta() > cfgLLCuts.cfgDaughEtaMax) + return false; + if (track.eta() < cfgLLCuts.cfgDaughEtaMin) + return false; + + return true; + } + template + bool isSelectedV0DaughterPID(T const& track, int pid) // pid 0: proton, pid 1: pion + { + if (pid == 0 && std::abs(track.tpcNSigmaPr()) > cfgLLCuts.cfgDaughPIDCutsTPCPr) + return false; + if (pid == 1 && std::abs(track.tpcNSigmaPi()) > cfgLLCuts.cfgDaughPIDCutsTPCPi) + return false; + if (pid == 0 && track.pt() < cfgLLCuts.cfgDaughPrPt) + return false; + if (pid == 1 && track.pt() < cfgLLCuts.cfgDaughPiPt) + return false; + + return true; + } void init(o2::framework::InitContext&) { - ccdb->setURL(ccdbUrl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - mTrackSelector.SetTrackType(o2::aod::track::TrackTypeEnum::Track); - mTrackSelector.SetPtRange(hMinPt, 1e10f); - mTrackSelector.SetEtaRange(-hEta, hEta); - mTrackSelector.SetRequireITSRefit(true); - mTrackSelector.SetRequireTPCRefit(true); - mTrackSelector.SetRequireGoldenChi2(false); - mTrackSelector.SetMinNCrossedRowsTPC(70); - mTrackSelector.SetMinNCrossedRowsOverFindableClustersTPC(0.8f); - mTrackSelector.SetMaxChi2PerClusterTPC(4.f); - mTrackSelector.SetRequireHitsInITSLayers(1, {0, 1, 2}); // one hit in any of the first three layers of IB - mTrackSelector.SetMaxChi2PerClusterITS(36.f); - // mTrackSelector.SetMaxDcaXYPtDep([](float pt) { return 0.0105f + 0.0350f / pow(pt, 1.1f); }); - mTrackSelector.SetMaxDcaXY(1.f); - mTrackSelector.SetMaxDcaZ(2.f); + // set V0 parameters in the helper + mStraHelper.v0selections.minCrossedRows = tpcmincrossedrows; + if (dcamesontopv <= dcabaryontopv) + mStraHelper.v0selections.dcanegtopv = dcamesontopv; + else + mStraHelper.v0selections.dcanegtopv = dcabaryontopv; // get the minimum one + if (dcamesontopv <= dcabaryontopv) + mStraHelper.v0selections.dcapostopv = dcamesontopv; + else + mStraHelper.v0selections.dcapostopv = dcabaryontopv; // get the minimum one + mStraHelper.v0selections.v0cospa = v0cospa; + mStraHelper.v0selections.dcav0dau = dcav0dau; + mStraHelper.v0selections.v0radius = v0radius; + mStraHelper.v0selections.maxDaughterEta = etadau; + + // set cascade parameters in the helper + mStraHelper.cascadeselections.minCrossedRows = tpcmincrossedrows; + mStraHelper.cascadeselections.dcabachtopv = dcabachtopv; + mStraHelper.cascadeselections.cascradius = cascradius; + if (casccospaxi <= casccospaomega) + mStraHelper.cascadeselections.casccospa = casccospaxi; + else + mStraHelper.cascadeselections.casccospa = casccospaomega; // get the minimum one + mStraHelper.cascadeselections.dcacascdau = dcacascdau; + mStraHelper.cascadeselections.lambdaMassWindow = masslambdalimit; + mStraHelper.cascadeselections.maxDaughterEta = etadau; hProcessedEvents->GetXaxis()->SetBinLabel(1, "Events processed"); hProcessedEvents->GetXaxis()->SetBinLabel(2, "Event selection"); @@ -197,9 +328,10 @@ struct strangenessFilter { hProcessedEvents->GetXaxis()->SetBinLabel(14, aod::filtering::OmegaHighMult::columnLabel()); hProcessedEvents->GetXaxis()->SetBinLabel(15, aod::filtering::DoubleOmega::columnLabel()); hProcessedEvents->GetXaxis()->SetBinLabel(16, aod::filtering::OmegaXi::columnLabel()); + hProcessedEvents->GetXaxis()->SetBinLabel(17, "LL"); hCandidate->GetXaxis()->SetBinLabel(1, "All"); - hCandidate->GetXaxis()->SetBinLabel(2, "Has_V0"); + hCandidate->GetXaxis()->SetBinLabel(2, "PassBuilderSel"); hCandidate->GetXaxis()->SetBinLabel(3, "DCA_meson"); hCandidate->GetXaxis()->SetBinLabel(4, "DCA_baryon"); hCandidate->GetXaxis()->SetBinLabel(5, "TPCNsigma_pion"); @@ -217,10 +349,12 @@ struct strangenessFilter { hCandidate->GetXaxis()->SetBinLabel(17, "CascCosPA"); hCandidate->GetXaxis()->SetBinLabel(18, "DCAV0ToPV"); hCandidate->GetXaxis()->SetBinLabel(19, "ProperLifeTime"); + hCandidate->GetXaxis()->SetBinLabel(20, "Rapidity"); std::vector centBinning = {0., 1., 5., 10., 20., 30., 40., 50., 70., 100.}; AxisSpec multAxisNTPV = {100, 0.0f, 100.0f, "N. tracks PV estimator"}; AxisSpec multAxisT0M = {600, 0.0f, 6000.0f, "T0M multiplicity estimator"}; + AxisSpec multAxisT0MNorm = {150, 0.0f, 150.0f, "Normalised T0M multiplicity estimator"}; AxisSpec multAxisV0A = {500, 0.0f, 25000.0f, "V0A multiplicity estimator"}; AxisSpec ximassAxis = {200, 1.28f, 1.36f}; AxisSpec omegamassAxis = {200, 1.59f, 1.75f}; @@ -277,11 +411,13 @@ struct strangenessFilter { QAHistosTriggerParticles.add("hPtTriggerSelEv", "hPtTriggerSelEv", HistType::kTH1F, {{300, 0, 30, "Pt of trigger particles after selections"}}); QAHistosTriggerParticles.add("hEtaTriggerAllEv", "hEtaTriggerAllEv", HistType::kTH2F, {{180, -1.4, 1.4, "Eta of trigger particles"}, {ptTriggAxis}}); QAHistosTriggerParticles.add("hPhiTriggerAllEv", "hPhiTriggerAllEv", HistType::kTH2F, {{100, 0, 2 * TMath::Pi(), "Phi of trigger particles"}, {ptTriggAxis}}); - QAHistosTriggerParticles.add("hDCAxyTriggerAllEv", "hDCAxyTriggerAllEv", HistType::kTH2F, {{400, -0.2, 0.2, "DCAxy of trigger particles"}, {ptTriggAxis}}); - QAHistosTriggerParticles.add("hDCAzTriggerAllEv", "hDCAzTriggerAllEv", HistType::kTH2F, {{400, -0.2, 0.2, "DCAz of trigger particles"}, {ptTriggAxis}}); EventsvsMultiplicity.add("AllEventsvsMultiplicityFT0M", "T0M distribution of all events", HistType::kTH1F, {multAxisT0M}); EventsvsMultiplicity.add("AllEventsvsMultiplicityFT0MwOmega", "T0M distribution of events w/ Omega candidate", HistType::kTH1F, {multAxisT0M}); + EventsvsMultiplicity.add("AllEventsvsMultiplicityFT0MNorm", "T0M Normalised of all events", HistType::kTH1F, {multAxisT0MNorm}); + EventsvsMultiplicity.add("AllEventsvsMultiplicityFT0MwOmegaNorm", "T0M distribution of events w/ Omega candidate - Normalised FT0M", HistType::kTH1F, {multAxisT0MNorm}); + EventsvsMultiplicity.add("AllEventsvsMultiplicityFT0MNoFT0", "T0M distribution of events without FT0", HistType::kTH1F, {multAxisT0M}); + if (doextraQA) { EventsvsMultiplicity.add("AllEventsvsMultiplicityZeqV0A", "ZeqV0A distribution of all events", HistType::kTH1F, {multAxisV0A}); EventsvsMultiplicity.add("hadEventsvsMultiplicityZeqV0A", "ZeqV0A distribution of events with hight pT hadron", HistType::kTH1F, {multAxisV0A}); @@ -315,12 +451,6 @@ struct strangenessFilter { QAHistos.add("hRapXi", "Rap Xi", HistType::kTH1F, {{100, -1, 1}}); QAHistos.add("hRapOmega", "Rap Omega", HistType::kTH1F, {{100, -1, 1}}); - // strangeness tracking - if (static_cast(materialCorrectionType.value) == o2::base::Propagator::MatCorrType::USEMatCorrLUT) { - auto* lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); - o2::base::Propagator::Instance(true)->setMatLUT(lut); - } - QAHistosStrangenessTracking.add("hStRVsPtTrkCasc", "Tracked cascades;p_{T} (GeV/#it{c});R (cm)", HistType::kTH2D, {{200, 0., 10.}, {200, 0., 50}}); QAHistosStrangenessTracking.add("hMassOmegaTrkCasc", "Tracked cascades;m_{#Omega} (GeV/#it{c}^{2})", HistType::kTH1D, {{1000, 1., 3.}}); QAHistosStrangenessTracking.add("hMassXiTrkCasc", "Tracked cascades;m_{#Xi} (GeV/#it{c}^{2})", HistType::kTH1D, {{1000, 1., 3.}}); @@ -379,19 +509,41 @@ struct strangenessFilter { } } - // Filters - Filter trackFilter = (nabs(aod::track::eta) < hEta) && (aod::track::pt > hMinPt); + void initCCDB(int run) + { + if (run != mRunNumber) { + mRunNumber = run; + o2::parameters::GRPMagField* grpmag = ccdb->getForRun("GLO/Config/GRPMagField", run); + o2::base::Propagator::initFieldFromGRP(grpmag); + mBz = static_cast(grpmag->getNominalL3Field()); + if (useNormalisedMult) + mMeanMultT0C = ccdb->getForRun>("Users/e/ekryshen/meanT0C", run); + if (useNormalisedMult) + mMeanMultT0A = ccdb->getForRun>("Users/e/ekryshen/meanT0A", run); + + mDCAFitter.setBz(mBz); + mDCAFitter.setPropagateToPCA(propToDCA); + mDCAFitter.setMaxR(maxR); + mDCAFitter.setMaxDZIni(maxDZIni); + mDCAFitter.setMinParamChange(minParamChange); + mDCAFitter.setMinRelChi2Change(minRelChi2Change); + mDCAFitter.setUseAbsDCA(useAbsDCA); + mStraHelper.fitter.setBz(mBz); + } + if (!mStraHelper.lut) { /// done only once + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(true); + auto* lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); + o2::base::Propagator::Instance()->setMatLUT(lut); + mStraHelper.lut = lut; + } + } // Tables - using CollisionCandidates = soa::Join::iterator; - // using CollisionCandidatesRun3 = soa::Join::iterator; - using CollisionCandidatesRun3 = soa::Join::iterator; - using TrackCandidates = soa::Filtered>; - using DaughterTracks = soa::Join; - using Cascades = aod::CascDataExt; - - Service ccdb; - int runNumber; + using CollisionCandidates = soa::Join::iterator; + using TrackCandidates = soa::Join; float getMassWindow(const stfilter::species s, const float pt, const float nsigma = 6) { @@ -400,22 +552,23 @@ struct strangenessFilter { } //////////////////////////////////////////////////////// - ////////// Strangeness Filter - Run 2 conv ///////////// + ////////// Strangeness Filter ////////////////////////// //////////////////////////////////////////////////////// void fillTriggerTable(bool keepEvent[]) { - strgtable(keepEvent[0], keepEvent[1], keepEvent[2], keepEvent[3], keepEvent[4], keepEvent[5], keepEvent[6], keepEvent[7], keepEvent[8], keepEvent[9], keepEvent[10], keepEvent[11]); + strgtable(keepEvent[0], keepEvent[1], keepEvent[2], keepEvent[3], keepEvent[4], keepEvent[5], keepEvent[6], keepEvent[7], keepEvent[8], keepEvent[9], keepEvent[10], keepEvent[11], keepEvent[12]); } - void process(CollisionCandidatesRun3 const& collision, TrackCandidates const& tracks, Cascades const& fullCasc, DaughterTracks& /*dtracks*/, - aod::AssignedTrackedCascades const& trackedCascades, aod::Cascades const& /*cascades*/, aod::AssignedTrackedV0s const& /*trackedV0s*/, aod::AssignedTracked3Bodys const& /*tracked3Bodys*/, aod::V0s const&, aod::BCsWithTimestamps const&) + void process(CollisionCandidates const& collision, TrackCandidates const& tracks, aod::Cascades const& cascadesBase, aod::AssignedTrackedCascades const& trackedCascades, aod::AssignedTrackedV0s const& /*trackedV0s*/, aod::AssignedTracked3Bodys const& /*tracked3Bodys*/, aod::V0s const& v0Base, aod::BCs const&, aod::FT0s const& /*ft0s*/) { // Is event good? [0] = Omega, [1] = high-pT hadron + Omega, [2] = 2Xi, [3] = 3Xi, [4] = 4Xi, [5] single-Xi, [6] Omega with high radius // [7] tracked Xi, [8] tracked Omega, [9] Omega + high mult event - bool keepEvent[12]{}; // explicitly zero-initialised - std::vector> v0sFromOmegaID; - std::vector> v0sFromXiID; + bool keepEvent[13]{}; // explicitly zero-initialised + std::vector> v0sFromOmegaID; + std::vector> v0sFromXiID; + + initCCDB(collision.bc().runNumber()); if (sel8 && !collision.sel8()) { fillTriggerTable(keepEvent); @@ -430,7 +583,7 @@ struct strangenessFilter { // all processed events after event selection hProcessedEvents->Fill(0.5); - if (TMath::Abs(collision.posZ()) > cutzvertex) { + if (std::fabs(collision.posZ()) > cutzvertex) { fillTriggerTable(keepEvent); return; } @@ -442,9 +595,71 @@ struct strangenessFilter { } Bool_t isHighMultEvent = 0; + float multFT0MNorm = 0.f; EventsvsMultiplicity.fill(HIST("AllEventsvsMultiplicityFT0M"), collision.multFT0M()); - if (collision.multFT0M() > LowLimitFT0MMult) - isHighMultEvent = 1; + if (!useNormalisedMult) { + if (collision.multFT0M() > LowLimitFT0MMult) { + isHighMultEvent = 1; + } + } else { + float meanMultT0C = 0.f; + float fac_FT0C_ebe = 1.; + meanMultT0C = (*mMeanMultT0C)[0]; + if (meanMultT0C > 0) { + fac_FT0C_ebe = avPyT0C / meanMultT0C; + } + float meanMultT0A = 0.f; + meanMultT0A = (*mMeanMultT0A)[0]; + float fac_FT0A_ebe = 1.; + if (meanMultT0A > 0) { + fac_FT0A_ebe = avPyT0A / meanMultT0A; + } + LOG(debug) << "Mean mults t0:" << fac_FT0A_ebe << " " << fac_FT0C_ebe; + if (collision.has_foundFT0()) { + static int ampneg = 0; + auto ft0 = collision.foundFT0(); + float sumAmpFT0C = 0.f; + for (std::size_t i_c = 0; i_c < ft0.amplitudeC().size(); i_c++) { + float amplitude = ft0.amplitudeC()[i_c]; + sumAmpFT0C += amplitude; + } + float sumAmpFT0A = 0.f; + for (std::size_t i_a = 0; i_a < ft0.amplitudeA().size(); i_a++) { + float amplitude = ft0.amplitudeA()[i_a]; + sumAmpFT0A += amplitude; + } + const int nEta5 = 2; // FT0C + FT0A + float weigthsEta5[nEta5] = {0.0490638, 0.010958415}; + if (sumAmpFT0C >= 0 || sumAmpFT0A >= 0) { + if (meanMultT0A > 0 && meanMultT0C > 0) { + multFT0MNorm = sumAmpFT0C * fac_FT0C_ebe + sumAmpFT0A * fac_FT0A_ebe; + } else { + multFT0MNorm = sumAmpFT0C * weigthsEta5[0] + sumAmpFT0A * weigthsEta5[1]; + } + LOG(debug) << "meanMult:" << multFT0MNorm << " multFT0M:" << collision.multFT0M(); + if (sumAmpFT0A < 0 || sumAmpFT0C < 0) { + // LOG(info) << "ampa: " << sumAmpFT0A << " ampc:" << sumAmpFT0C; + ampneg++; + } + EventsvsMultiplicity.fill(HIST("AllEventsvsMultiplicityFT0MNorm"), multFT0MNorm); + if (multFT0MNorm > LowLimitFT0MMultNorm) { + isHighMultEvent = 1; + LOG(debug) << "Found FT0 using norm mult"; + } + } else { + LOG(warn) << "Found FT0 but, bith amplitudes are <=0 "; + EventsvsMultiplicity.fill(HIST("AllEventsvsMultiplicityFT0MNorm"), 148); + EventsvsMultiplicity.fill(HIST("AllEventsvsMultiplicityFT0MNoFT0"), collision.multFT0M()); + } + if (ampneg) { + LOG(warn) << "# of negative amplitudes:" << ampneg; + } + } else { + LOG(debug) << "FT0 not Found, using FT0M"; + EventsvsMultiplicity.fill(HIST("AllEventsvsMultiplicityFT0MNorm"), 149); + EventsvsMultiplicity.fill(HIST("AllEventsvsMultiplicityFT0MNoFT0"), collision.multFT0M()); + } + } // constants const float ctauxi = 4.91; // from PDG @@ -459,18 +674,121 @@ struct strangenessFilter { int xicounterYN = 0; int omegacounter = 0; int omegalargeRcounter = 0; - int triggcounter = 0; - int triggcounterAllEv = 0; - int triggcounterForEstimates = 0; + const std::array pvPos{collision.posX(), collision.posY(), collision.posZ()}; + float pvX = 0.0f, pvY = 0.0f, pvZ = 0.0f; + + // strangeness tracking selection + const auto primaryVertex = getPrimaryVertex(collision); + o2::dataformats::DCA impactParameterTrk; + + std::vector> v0sSelTuple; + for (auto& v00 : v0Base) { // loop over v0 for pre selection + hCandidate->Fill(0.5); // All candidates + + if (v00.v0Type() != 1) { + continue; + } + + const auto posTrack0 = v00.posTrack_as(); + const auto negTrack0 = v00.negTrack_as(); - for (auto& casc : fullCasc) { // loop over cascades - triggcounterForEstimates = 0; + if (!isSelectedV0Daughter(posTrack0) || !isSelectedV0Daughter(negTrack0)) { + continue; + } + + auto trackParPos0 = getTrackParCov(posTrack0); + auto trackParNeg0 = getTrackParCov(negTrack0); + + if (!mStraHelper.buildV0Candidate(v00.collisionId(), pvPos[0], pvPos[1], pvPos[2], posTrack0, negTrack0, trackParPos0, trackParNeg0)) { + continue; + } + if (std::hypot(mStraHelper.v0.position[0], mStraHelper.v0.position[1]) < cfgLLCuts.cfgv0radiusMin) { + continue; + } + if (std::fabs(mStraHelper.v0.positiveDCAxy) < cfgLLCuts.cfgDCAPosToPVMin) { + continue; + } + if (std::fabs(mStraHelper.v0.negativeDCAxy) < cfgLLCuts.cfgDCANegToPVMin) { + continue; + } + if (TMath::Cos(mStraHelper.v0.pointingAngle) < cfgLLCuts.cfgv0CosPA) { + continue; + } + if (std::fabs(mStraHelper.v0.daughterDCA) > cfgLLCuts.cfgDCAV0Dau) { + continue; + } + if (std::hypot(mStraHelper.v0.momentum[0], mStraHelper.v0.momentum[1]) < cfgLLCuts.cfgV0PtMin) { + continue; + } + double yLambda = RecoDecay::y(array{mStraHelper.v0.momentum[0], mStraHelper.v0.momentum[1], mStraHelper.v0.momentum[2]}, o2::constants::physics::MassLambda0); + if (yLambda < cfgLLCuts.cfgV0RapMin) { + continue; + } + if (yLambda > cfgLLCuts.cfgV0RapMax) { + continue; + } + double distovertotmom = std::hypot(mStraHelper.v0.position[0] - collision.posX(), mStraHelper.v0.position[1] - collision.posY(), mStraHelper.v0.position[2] - collision.posZ()) / (std::hypot(mStraHelper.v0.momentum[0], mStraHelper.v0.momentum[1], mStraHelper.v0.momentum[2]) + 1e-13); + if (distovertotmom * o2::constants::physics::MassLambda0 > cfgLLCuts.cfgV0LifeTime) { + continue; + } + + int Tag = 0; + if (isSelectedV0DaughterPID(posTrack0, 0) && isSelectedV0DaughterPID(negTrack0, 1)) { + if (cfgLLCuts.cfgLambdaMassWindow > std::fabs(mStraHelper.v0.massLambda - o2::constants::physics::MassLambda0)) { + if (cfgLLCuts.cfgCompV0Rej < std::fabs(mStraHelper.v0.massK0Short - o2::constants::physics::MassLambda0)) { + Tag++; + } + } + } // lambda + if (isSelectedV0DaughterPID(posTrack0, 1) && isSelectedV0DaughterPID(negTrack0, 0)) { + if (cfgLLCuts.cfgLambdaMassWindow > std::fabs(mStraHelper.v0.massAntiLambda - o2::constants::physics::MassLambda0)) { + if (cfgLLCuts.cfgCompV0Rej < std::fabs(mStraHelper.v0.massK0Short - o2::constants::physics::MassLambda0)) { + Tag++; + } + } + } // anti lambda + if (Tag != 1) { // Select when only one hypothesis is satisfied + continue; + } + + TVector3 v0pos(mStraHelper.v0.position[0], mStraHelper.v0.position[1], mStraHelper.v0.position[2]); + TVector3 v0mom(mStraHelper.v0.momentum[0], mStraHelper.v0.momentum[1], mStraHelper.v0.momentum[2]); + + v0sSelTuple.emplace_back(posTrack0.globalIndex(), negTrack0.globalIndex(), v0pos, v0mom); + } + + for (size_t i = 0; i < v0sSelTuple.size(); ++i) { + for (size_t j = i + 1; j < v0sSelTuple.size(); ++j) { + auto d00 = std::get<0>(v0sSelTuple[i]); + auto d01 = std::get<1>(v0sSelTuple[i]); + auto d10 = std::get<0>(v0sSelTuple[j]); + auto d11 = std::get<1>(v0sSelTuple[j]); + if (d00 == d10 || d00 == d11 || d01 == d10 || d01 == d11) { + continue; + } + auto v00pos = std::get<2>(v0sSelTuple[i]); + auto v00mom = std::get<3>(v0sSelTuple[i]); + auto v01pos = std::get<2>(v0sSelTuple[j]); + auto v01mom = std::get<3>(v0sSelTuple[j]); + if (isSelectedV0V0(v00pos, v00mom, v01pos, v01mom)) { + keepEvent[12] = true; + } + } + } + + for (auto& casc : cascadesBase) { // loop over cascades hCandidate->Fill(0.5); // All candidates - hCandidate->Fill(1.5); // V0 exists - deprecated - auto bachelor = casc.bachelor_as(); - auto posdau = casc.posTrack_as(); - auto negdau = casc.negTrack_as(); + + const auto bachTrack = casc.bachelor_as(); + const auto v0Dau = casc.v0_as(); + const auto negTrack = v0Dau.negTrack_as(); + const auto posTrack = v0Dau.posTrack_as(); + + if (!mStraHelper.buildCascadeCandidate(casc.collisionId(), pvPos[0], pvPos[1], pvPos[2], posTrack, negTrack, bachTrack, -1, useCascadeMomentumAtPrimVtx, -1)) { + continue; + } + hCandidate->Fill(1.5); // Built and selected candidates in StraBuilder bool isXi = false; bool isXiYN = false; @@ -478,282 +796,291 @@ struct strangenessFilter { bool isOmegalargeR = false; // QA - QAHistos.fill(HIST("hMassXiBefSelvsPt"), casc.mXi(), casc.pt()); - QAHistos.fill(HIST("hMassOmegaBefSelvsPt"), casc.mOmega(), casc.pt()); - + double massXi = mStraHelper.cascade.massXi; + double massOmega = mStraHelper.cascade.massOmega; + double ptCasc = RecoDecay::sqrtSumOfSquares(mStraHelper.cascade.cascadeMomentum[0], mStraHelper.cascade.cascadeMomentum[1]); + QAHistos.fill(HIST("hMassXiBefSelvsPt"), massXi, ptCasc); + QAHistos.fill(HIST("hMassOmegaBefSelvsPt"), massOmega, ptCasc); // Position - xipos = std::hypot(casc.x() - collision.posX(), casc.y() - collision.posY(), casc.z() - collision.posZ()); + xipos = std::hypot(mStraHelper.cascade.cascadePosition[0] - collision.posX(), mStraHelper.cascade.cascadePosition[1] - collision.posY(), mStraHelper.cascade.cascadePosition[2] - collision.posZ()); // Total momentum - xiptotmom = std::hypot(casc.px(), casc.py(), casc.pz()); + xiptotmom = std::hypot(mStraHelper.cascade.cascadeMomentum[0], mStraHelper.cascade.cascadeMomentum[1], mStraHelper.cascade.cascadeMomentum[2]); // Proper lifetime xiproperlifetime = o2::constants::physics::MassXiMinus * xipos / (xiptotmom + 1e-13); omegaproperlifetime = o2::constants::physics::MassOmegaMinus * xipos / (xiptotmom + 1e-13); + // Radii + double Cascv0radius = std::hypot(mStraHelper.cascade.v0Position[0], mStraHelper.cascade.v0Position[1]); + double Casccascradius = std::hypot(mStraHelper.cascade.cascadePosition[0], mStraHelper.cascade.cascadePosition[1]); + // Rapidity + double etaCasc = RecoDecay::eta(std::array{mStraHelper.cascade.cascadeMomentum[0], mStraHelper.cascade.cascadeMomentum[1], mStraHelper.cascade.cascadeMomentum[2]}); + // pointing angle + double v0DauCPA = RecoDecay::cpa(pvPos, array{mStraHelper.cascade.v0Position[0], mStraHelper.cascade.v0Position[1], mStraHelper.cascade.v0Position[2]}, array{mStraHelper.cascade.positiveMomentum[0] + mStraHelper.cascade.negativeMomentum[0], mStraHelper.cascade.positiveMomentum[1] + mStraHelper.cascade.negativeMomentum[1], mStraHelper.cascade.positiveMomentum[2] + mStraHelper.cascade.negativeMomentum[2]}); + double cascCPA = RecoDecay::cpa( + pvPos, + array{mStraHelper.cascade.cascadePosition[0], mStraHelper.cascade.cascadePosition[1], mStraHelper.cascade.cascadePosition[2]}, + array{mStraHelper.cascade.positiveMomentum[0] + mStraHelper.cascade.negativeMomentum[0] + mStraHelper.cascade.bachelorMomentum[0], mStraHelper.cascade.positiveMomentum[1] + mStraHelper.cascade.negativeMomentum[1] + mStraHelper.cascade.bachelorMomentum[1], mStraHelper.cascade.positiveMomentum[2] + mStraHelper.cascade.negativeMomentum[2] + mStraHelper.cascade.bachelorMomentum[2]}); + // dca V0 to PV + double DCAV0ToPV = CalculateDCAStraightToPV( + mStraHelper.cascade.v0Position[0], mStraHelper.cascade.v0Position[1], mStraHelper.cascade.v0Position[2], + mStraHelper.cascade.positiveMomentum[0] + mStraHelper.cascade.negativeMomentum[0], + mStraHelper.cascade.positiveMomentum[1] + mStraHelper.cascade.negativeMomentum[1], + mStraHelper.cascade.positiveMomentum[2] + mStraHelper.cascade.negativeMomentum[2], + pvX, pvY, pvZ); + // massLambda + double LambdaMass = 0; + if (mStraHelper.cascade.charge < 0) { + LambdaMass = RecoDecay::m(array{array{mStraHelper.cascade.positiveMomentum[0], mStraHelper.cascade.positiveMomentum[1], mStraHelper.cascade.positiveMomentum[2]}, array{mStraHelper.cascade.negativeMomentum[0], mStraHelper.cascade.negativeMomentum[1], mStraHelper.cascade.negativeMomentum[2]}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); + } else { + LambdaMass = RecoDecay::m(array{array{mStraHelper.cascade.positiveMomentum[0], mStraHelper.cascade.positiveMomentum[1], mStraHelper.cascade.positiveMomentum[2]}, array{mStraHelper.cascade.negativeMomentum[0], mStraHelper.cascade.negativeMomentum[1], mStraHelper.cascade.negativeMomentum[2]}}, array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton}); + } - if (casc.sign() > 0) { - if (TMath::Abs(casc.dcapostopv()) < dcamesontopv) { + // rapidity + double yXi = RecoDecay::y(array{mStraHelper.cascade.bachelorMomentum[0] + mStraHelper.cascade.positiveMomentum[0] + mStraHelper.cascade.negativeMomentum[0], mStraHelper.cascade.bachelorMomentum[1] + mStraHelper.cascade.positiveMomentum[1] + mStraHelper.cascade.negativeMomentum[1], mStraHelper.cascade.bachelorMomentum[2] + mStraHelper.cascade.positiveMomentum[2] + mStraHelper.cascade.negativeMomentum[2]}, o2::constants::physics::MassXiMinus); + double yOmega = RecoDecay::y(array{mStraHelper.cascade.bachelorMomentum[0] + mStraHelper.cascade.positiveMomentum[0] + mStraHelper.cascade.negativeMomentum[0], mStraHelper.cascade.bachelorMomentum[1] + mStraHelper.cascade.positiveMomentum[1] + mStraHelper.cascade.negativeMomentum[1], mStraHelper.cascade.bachelorMomentum[2] + mStraHelper.cascade.positiveMomentum[2] + mStraHelper.cascade.negativeMomentum[2]}, o2::constants::physics::MassOmegaMinus); + + if (mStraHelper.cascade.charge > 0) { + if (std::fabs(mStraHelper.cascade.positiveDCAxy) < dcamesontopv) { continue; } hCandidate->Fill(2.5); - if (TMath::Abs(casc.dcanegtopv()) < dcabaryontopv) { + if (std::fabs(mStraHelper.cascade.negativeDCAxy) < dcabaryontopv) { continue; } hCandidate->Fill(3.5); - if (TMath::Abs(posdau.tpcNSigmaPi()) > nsigmatpcpi) { + if (std::fabs(posTrack.tpcNSigmaPi()) > nsigmatpcpi) { continue; } hCandidate->Fill(4.5); - if (TMath::Abs(negdau.tpcNSigmaPr()) > nsigmatpcpr) { + if (std::fabs(negTrack.tpcNSigmaPr()) > nsigmatpcpr) { continue; } hCandidate->Fill(5.5); - } else if (casc.sign() < 0) { - if (TMath::Abs(casc.dcanegtopv()) < dcamesontopv) { + } else if (mStraHelper.cascade.charge < 0) { + if (std::fabs(mStraHelper.cascade.negativeDCAxy) < dcamesontopv) { continue; } hCandidate->Fill(2.5); - if (TMath::Abs(casc.dcapostopv()) < dcabaryontopv) { + if (std::fabs(mStraHelper.cascade.positiveDCAxy) < dcabaryontopv) { continue; } hCandidate->Fill(3.5); - if (TMath::Abs(negdau.tpcNSigmaPi()) > nsigmatpcpi) { + if (std::fabs(negTrack.tpcNSigmaPi()) > nsigmatpcpi) { continue; } hCandidate->Fill(4.5); - if (TMath::Abs(posdau.tpcNSigmaPr()) > nsigmatpcpr) { + if (std::fabs(posTrack.tpcNSigmaPr()) > nsigmatpcpr) { continue; } hCandidate->Fill(5.5); } - if (TMath::Abs(posdau.eta()) > etadau) { - continue; - } - if (TMath::Abs(negdau.eta()) > etadau) { - continue; - } - if (TMath::Abs(bachelor.eta()) > etadau) { - continue; - } - hCandidate->Fill(6.5); - if (TMath::Abs(casc.dcabachtopv()) < dcabachtopv) { - continue; - } - hCandidate->Fill(7.5); - if (casc.v0radius() < v0radius) { + hCandidate->Fill(6.5); // OLD: eta dau (selection now applied in strangeness helper) + hCandidate->Fill(7.5); // OLD: bachtopv (selection now applied in strangeness helper) + + // not striclty needed as selection are applied beforehand - just as QA (no change in number expected) + if (Cascv0radius < v0radius) { continue; } hCandidate->Fill(8.5); - if (casc.cascradius() < cascradius) { + if (Casccascradius < cascradius) { continue; } hCandidate->Fill(9.5); - if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < v0cospa) { + if (v0DauCPA < v0cospa) { continue; } hCandidate->Fill(10.5); - if (casc.dcaV0daughters() > dcav0dau) { + if (mStraHelper.cascade.v0DaughterDCA > dcav0dau) { continue; } hCandidate->Fill(11.5); - if (casc.dcacascdaughters() > dcacascdau) { + if (mStraHelper.cascade.cascadeDaughterDCA > dcacascdau) { continue; } hCandidate->Fill(12.5); - if (TMath::Abs(casc.mLambda() - constants::physics::MassLambda) > masslambdalimit) { + if (std::fabs(LambdaMass - constants::physics::MassLambda) > masslambdalimit) { continue; } hCandidate->Fill(13.5); - if (TMath::Abs(casc.eta()) > eta) { + if (std::fabs(etaCasc) > eta) { continue; } hCandidate->Fill(14.5); if (hastof && - (!posdau.hasTOF() && posdau.pt() > ptthrtof) && - (!negdau.hasTOF() && negdau.pt() > ptthrtof) && - (!bachelor.hasTOF() && bachelor.pt() > ptthrtof)) { + (!posTrack.hasTOF() && posTrack.pt() > ptthrtof) && + (!negTrack.hasTOF() && negTrack.pt() > ptthrtof) && + (!bachTrack.hasTOF() && bachTrack.pt() > ptthrtof)) { continue; } hCandidate->Fill(15.5); - // Fill selections QA for XiMinus - if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) > casccospaxi) { + // Fill selections QA for Xi + if (cascCPA > casccospaxi) { hCandidate->Fill(16.5); - if (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) > dcav0topv) { + if (cascCPA > dcav0topv) { hCandidate->Fill(17.5); if (xiproperlifetime < properlifetimefactor * ctauxi) { hCandidate->Fill(18.5); - if (TMath::Abs(casc.yXi()) < rapidity) { + if (std::fabs(yXi) < rapidity) { hCandidate->Fill(19.5); } } } } - const auto deltaMassXi = useSigmaBasedMassCutXi ? getMassWindow(stfilter::species::Xi, casc.pt()) : ximasswindow; - const auto deltaMassOmega = useSigmaBasedMassCutOmega ? getMassWindow(stfilter::species::Omega, casc.pt()) : omegamasswindow; - isXi = (TMath::Abs(bachelor.tpcNSigmaPi()) < nsigmatpcpi) && - (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) > casccospaxi) && - (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) > dcav0topv) && - (TMath::Abs(casc.mXi() - o2::constants::physics::MassXiMinus) < deltaMassXi) && - (TMath::Abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > omegarej) && + const auto deltaMassXi = useSigmaBasedMassCutXi ? getMassWindow(stfilter::species::Xi, ptCasc) : ximasswindow; + const auto deltaMassOmega = useSigmaBasedMassCutOmega ? getMassWindow(stfilter::species::Omega, ptCasc) : omegamasswindow; + + isXi = (std::fabs(bachTrack.tpcNSigmaPi()) < nsigmatpcpi) && + (cascCPA > casccospaxi) && + (DCAV0ToPV > dcav0topv) && + (std::fabs(massXi - o2::constants::physics::MassXiMinus) < deltaMassXi) && + (std::fabs(massOmega - o2::constants::physics::MassOmegaMinus) > omegarej) && (xiproperlifetime < properlifetimefactor * ctauxi) && - (TMath::Abs(casc.yXi()) < rapidity); - isXiYN = (TMath::Abs(bachelor.tpcNSigmaPi()) < nsigmatpcpi) && - (casc.cascradius() > lowerradiusXiYN) && - (TMath::Abs(casc.mXi() - o2::constants::physics::MassXiMinus) < deltaMassXi) && - (TMath::Abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > omegarej) && + (std::fabs(yXi) < rapidity); + isXiYN = (std::fabs(bachTrack.tpcNSigmaPi()) < nsigmatpcpi) && + (Casccascradius > lowerradiusXiYN) && + (std::fabs(massXi - o2::constants::physics::MassXiMinus) < deltaMassXi) && + (std::fabs(massOmega - o2::constants::physics::MassOmegaMinus) > omegarej) && (xiproperlifetime < properlifetimefactor * ctauxi) && - (TMath::Abs(casc.yXi()) < rapidity); - isOmega = (TMath::Abs(bachelor.tpcNSigmaKa()) < nsigmatpcka) && - (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) > casccospaomega) && - (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) > dcav0topv) && - (TMath::Abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) < deltaMassOmega) && - (TMath::Abs(casc.mXi() - o2::constants::physics::MassXiMinus) > xirej) && - (casc.cascradius() < upperradiusOmega) && + (std::fabs(yXi) < rapidity); + isOmega = (std::fabs(bachTrack.tpcNSigmaKa()) < nsigmatpcka) && + (cascCPA > casccospaomega) && + (DCAV0ToPV > dcav0topv) && + (std::fabs(massOmega - o2::constants::physics::MassOmegaMinus) < deltaMassOmega) && + (std::fabs(massXi - o2::constants::physics::MassXiMinus) > xirej) && + (Casccascradius < upperradiusOmega) && (omegaproperlifetime < properlifetimefactor * ctauomega) && - (TMath::Abs(casc.yOmega()) < rapidity); - isOmegalargeR = (TMath::Abs(bachelor.tpcNSigmaKa()) < nsigmatpcka) && - (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) > casccospaomega) && - (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) > dcav0topv) && - (casc.cascradius() > lowerradiusOmega) && - (TMath::Abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) < deltaMassOmega) && - (TMath::Abs(casc.mXi() - o2::constants::physics::MassXiMinus) > xirej) && + (std::fabs(yOmega) < rapidity); + isOmegalargeR = (std::fabs(bachTrack.tpcNSigmaKa()) < nsigmatpcka) && + (cascCPA > casccospaomega) && + (DCAV0ToPV > dcav0topv) && + (Casccascradius > lowerradiusOmega) && + (std::fabs(massOmega - o2::constants::physics::MassOmegaMinus) < deltaMassOmega) && + (std::fabs(massXi - o2::constants::physics::MassXiMinus) > xirej) && (omegaproperlifetime < properlifetimefactor * ctauomega) && - (TMath::Abs(casc.yOmega()) < rapidity); + (std::fabs(yOmega) < rapidity); if (isXi) { - QAHistos.fill(HIST("hMassXiAfterSelvsPt"), casc.mXi(), casc.pt()); - QAHistos.fill(HIST("hPtXi"), casc.pt()); - QAHistos.fill(HIST("hEtaXi"), casc.eta()); + QAHistos.fill(HIST("hMassXiAfterSelvsPt"), massXi, ptCasc); + QAHistos.fill(HIST("hPtXi"), ptCasc); + QAHistos.fill(HIST("hEtaXi"), etaCasc); QAHistosTopologicalVariables.fill(HIST("hProperLifetimeXi"), xiproperlifetime); - QAHistosTopologicalVariables.fill(HIST("hCascCosPAXi"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); - QAHistosTopologicalVariables.fill(HIST("hV0CosPAXi"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); - QAHistosTopologicalVariables.fill(HIST("hCascRadiusXi"), casc.cascradius()); - QAHistosTopologicalVariables.fill(HIST("hV0RadiusXi"), casc.v0radius()); - QAHistosTopologicalVariables.fill(HIST("hDCAV0ToPVXi"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); - QAHistosTopologicalVariables.fill(HIST("hDCAV0DaughtersXi"), casc.dcaV0daughters()); - QAHistosTopologicalVariables.fill(HIST("hDCACascDaughtersXi"), casc.dcacascdaughters()); - QAHistosTopologicalVariables.fill(HIST("hDCABachToPVXi"), TMath::Abs(casc.dcabachtopv())); - QAHistosTopologicalVariables.fill(HIST("hDCAPosToPVXi"), TMath::Abs(casc.dcapostopv())); - QAHistosTopologicalVariables.fill(HIST("hDCANegToPVXi"), TMath::Abs(casc.dcanegtopv())); - QAHistosTopologicalVariables.fill(HIST("hInvMassLambdaXi"), casc.mLambda()); + QAHistosTopologicalVariables.fill(HIST("hCascCosPAXi"), cascCPA); + QAHistosTopologicalVariables.fill(HIST("hV0CosPAXi"), v0DauCPA); + QAHistosTopologicalVariables.fill(HIST("hCascRadiusXi"), Casccascradius); + QAHistosTopologicalVariables.fill(HIST("hV0RadiusXi"), Cascv0radius); + QAHistosTopologicalVariables.fill(HIST("hDCAV0ToPVXi"), DCAV0ToPV); + QAHistosTopologicalVariables.fill(HIST("hDCAV0DaughtersXi"), mStraHelper.cascade.v0DaughterDCA); + QAHistosTopologicalVariables.fill(HIST("hDCACascDaughtersXi"), mStraHelper.cascade.cascadeDaughterDCA); + QAHistosTopologicalVariables.fill(HIST("hDCABachToPVXi"), std::fabs(mStraHelper.cascade.bachelorDCAxy)); + QAHistosTopologicalVariables.fill(HIST("hDCAPosToPVXi"), std::fabs(mStraHelper.cascade.positiveDCAxy)); + QAHistosTopologicalVariables.fill(HIST("hDCANegToPVXi"), std::fabs(mStraHelper.cascade.negativeDCAxy)); + QAHistosTopologicalVariables.fill(HIST("hInvMassLambdaXi"), LambdaMass); if (doextraQA) { - - QAHistos.fill(HIST("hHasTOFBachPi"), bachelor.hasTOF(), bachelor.pt()); + QAHistos.fill(HIST("hHasTOFBachPi"), bachTrack.hasTOF(), bachTrack.pt()); // QA PID - if (casc.sign() > 0) { - QAHistos.fill(HIST("hTPCNsigmaXiBachPiPlus"), bachelor.tpcNSigmaPi(), bachelor.tpcInnerParam()); - QAHistos.fill(HIST("hTPCNsigmaXiV0PiPlus"), posdau.tpcNSigmaPi(), posdau.tpcInnerParam()); - QAHistos.fill(HIST("hTPCNsigmaXiV0AntiProton"), negdau.tpcNSigmaPr(), negdau.tpcInnerParam()); - QAHistos.fill(HIST("hHasTOFPi"), posdau.hasTOF(), posdau.pt()); - QAHistos.fill(HIST("hHasTOFPr"), negdau.hasTOF(), negdau.pt()); + if (mStraHelper.cascade.charge > 0) { + QAHistos.fill(HIST("hTPCNsigmaXiBachPiPlus"), bachTrack.tpcNSigmaPi(), bachTrack.tpcInnerParam()); + QAHistos.fill(HIST("hTPCNsigmaXiV0PiPlus"), posTrack.tpcNSigmaPi(), posTrack.tpcInnerParam()); + QAHistos.fill(HIST("hTPCNsigmaXiV0AntiProton"), negTrack.tpcNSigmaPr(), negTrack.tpcInnerParam()); + QAHistos.fill(HIST("hHasTOFPi"), posTrack.hasTOF(), posTrack.pt()); + QAHistos.fill(HIST("hHasTOFPr"), negTrack.hasTOF(), negTrack.pt()); } else { - QAHistos.fill(HIST("hTPCNsigmaXiBachPiMinus"), bachelor.tpcNSigmaPi(), bachelor.tpcInnerParam()); - QAHistos.fill(HIST("hTPCNsigmaXiV0Proton"), posdau.tpcNSigmaPr(), posdau.tpcInnerParam()); - QAHistos.fill(HIST("hTPCNsigmaXiV0PiMinus"), negdau.tpcNSigmaPi(), negdau.tpcInnerParam()); - QAHistos.fill(HIST("hHasTOFPr"), posdau.hasTOF(), posdau.pt()); - QAHistos.fill(HIST("hHasTOFPi"), negdau.hasTOF(), negdau.pt()); + QAHistos.fill(HIST("hTPCNsigmaXiBachPiMinus"), bachTrack.tpcNSigmaPi(), bachTrack.tpcInnerParam()); + QAHistos.fill(HIST("hTPCNsigmaXiV0Proton"), posTrack.tpcNSigmaPr(), posTrack.tpcInnerParam()); + QAHistos.fill(HIST("hTPCNsigmaXiV0PiMinus"), negTrack.tpcNSigmaPi(), negTrack.tpcInnerParam()); + QAHistos.fill(HIST("hHasTOFPr"), posTrack.hasTOF(), posTrack.pt()); + QAHistos.fill(HIST("hHasTOFPi"), negTrack.hasTOF(), negTrack.pt()); } - QAHistos.fill(HIST("hRapXi"), casc.yXi()); + QAHistos.fill(HIST("hRapXi"), yXi); } // Count number of Xi candidates xicounter++; - v0sFromXiID.push_back({casc.posTrackId(), casc.negTrackId()}); - - // Plot for estimates - for (auto track : tracks) { // start loop over tracks - if (isTrackFilter && !mTrackSelector.IsSelected(track)) { - continue; - } - triggcounterForEstimates++; - if (triggcounterForEstimates > 0) - break; - } - if (triggcounterForEstimates && (TMath::Abs(casc.mXi() - o2::constants::physics::MassXiMinus) < 0.01)) - hhXiPairsvsPt->Fill(casc.pt()); // Fill the histogram with all the Xis produced in events with a trigger particle - // End plot for estimates + // v0sFromXiID.push_back({casc.posTrackId(), casc.negTrackId()}); + v0sFromXiID.push_back({posTrack.globalIndex(), negTrack.globalIndex()}); } + if (isXiYN) { // Xis for YN interactions xicounterYN++; - QAHistosTopologicalVariables.fill(HIST("hCascRadiusXiYN"), casc.cascradius()); + QAHistosTopologicalVariables.fill(HIST("hCascRadiusXiYN"), Casccascradius); } if (isOmega) { - QAHistos.fill(HIST("hMassOmegaAfterSelvsPt"), casc.mOmega(), casc.pt()); - QAHistos.fill(HIST("hPtOmega"), casc.pt()); - QAHistos.fill(HIST("hEtaOmega"), casc.eta()); + QAHistos.fill(HIST("hMassOmegaAfterSelvsPt"), massOmega, ptCasc); + QAHistos.fill(HIST("hPtOmega"), ptCasc); + QAHistos.fill(HIST("hEtaOmega"), etaCasc); QAHistosTopologicalVariables.fill(HIST("hProperLifetimeOmega"), omegaproperlifetime); - QAHistosTopologicalVariables.fill(HIST("hCascCosPAOmega"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); - QAHistosTopologicalVariables.fill(HIST("hV0CosPAOmega"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); - QAHistosTopologicalVariables.fill(HIST("hCascRadiusOmega"), casc.cascradius()); - QAHistosTopologicalVariables.fill(HIST("hV0RadiusOmega"), casc.v0radius()); - QAHistosTopologicalVariables.fill(HIST("hDCAV0ToPVOmega"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); - QAHistosTopologicalVariables.fill(HIST("hDCAV0DaughtersOmega"), casc.dcaV0daughters()); - QAHistosTopologicalVariables.fill(HIST("hDCACascDaughtersOmega"), casc.dcacascdaughters()); - QAHistosTopologicalVariables.fill(HIST("hDCABachToPVOmega"), TMath::Abs(casc.dcabachtopv())); - QAHistosTopologicalVariables.fill(HIST("hDCAPosToPVOmega"), TMath::Abs(casc.dcapostopv())); - QAHistosTopologicalVariables.fill(HIST("hDCANegToPVOmega"), TMath::Abs(casc.dcanegtopv())); - QAHistosTopologicalVariables.fill(HIST("hInvMassLambdaOmega"), casc.mLambda()); + QAHistosTopologicalVariables.fill(HIST("hCascCosPAOmega"), cascCPA); + QAHistosTopologicalVariables.fill(HIST("hV0CosPAOmega"), v0DauCPA); + QAHistosTopologicalVariables.fill(HIST("hCascRadiusOmega"), Casccascradius); + QAHistosTopologicalVariables.fill(HIST("hV0RadiusOmega"), Cascv0radius); + QAHistosTopologicalVariables.fill(HIST("hDCAV0ToPVOmega"), DCAV0ToPV); + QAHistosTopologicalVariables.fill(HIST("hDCAV0DaughtersOmega"), mStraHelper.cascade.v0DaughterDCA); + QAHistosTopologicalVariables.fill(HIST("hDCACascDaughtersOmega"), mStraHelper.cascade.cascadeDaughterDCA); + QAHistosTopologicalVariables.fill(HIST("hDCABachToPVOmega"), std::fabs(mStraHelper.cascade.bachelorDCAxy)); + QAHistosTopologicalVariables.fill(HIST("hDCAPosToPVOmega"), std::fabs(mStraHelper.cascade.positiveDCAxy)); + QAHistosTopologicalVariables.fill(HIST("hDCANegToPVOmega"), std::fabs(mStraHelper.cascade.negativeDCAxy)); + QAHistosTopologicalVariables.fill(HIST("hInvMassLambdaOmega"), LambdaMass); if (doextraQA) { // QA PID - if (casc.sign() > 0) { - QAHistos.fill(HIST("hTPCNsigmaOmegaBachKaPlus"), bachelor.tpcNSigmaKa(), bachelor.tpcInnerParam()); - QAHistos.fill(HIST("hTPCNsigmaOmegaV0PiPlus"), posdau.tpcNSigmaPi(), posdau.tpcInnerParam()); - QAHistos.fill(HIST("hTPCNsigmaOmegaV0AntiProton"), negdau.tpcNSigmaPr(), negdau.tpcInnerParam()); - QAHistos.fill(HIST("hHasTOFPi"), posdau.hasTOF(), posdau.pt()); - QAHistos.fill(HIST("hHasTOFPr"), negdau.hasTOF(), negdau.pt()); + if (mStraHelper.cascade.charge > 0) { + QAHistos.fill(HIST("hTPCNsigmaOmegaBachKaPlus"), bachTrack.tpcNSigmaKa(), bachTrack.tpcInnerParam()); + QAHistos.fill(HIST("hTPCNsigmaOmegaV0PiPlus"), posTrack.tpcNSigmaPi(), posTrack.tpcInnerParam()); + QAHistos.fill(HIST("hTPCNsigmaOmegaV0AntiProton"), negTrack.tpcNSigmaPr(), negTrack.tpcInnerParam()); + QAHistos.fill(HIST("hHasTOFPi"), posTrack.hasTOF(), posTrack.pt()); + QAHistos.fill(HIST("hHasTOFPr"), negTrack.hasTOF(), negTrack.pt()); } else { - QAHistos.fill(HIST("hTPCNsigmaOmegaBachKaMinus"), bachelor.tpcNSigmaKa(), bachelor.tpcInnerParam()); - QAHistos.fill(HIST("hTPCNsigmaOmegaV0Proton"), posdau.tpcNSigmaPr(), posdau.tpcInnerParam()); - QAHistos.fill(HIST("hTPCNsigmaOmegaV0PiMinus"), negdau.tpcNSigmaPi(), negdau.tpcInnerParam()); - QAHistos.fill(HIST("hHasTOFPr"), posdau.hasTOF(), posdau.pt()); - QAHistos.fill(HIST("hHasTOFPi"), negdau.hasTOF(), negdau.pt()); + QAHistos.fill(HIST("hTPCNsigmaOmegaBachKaMinus"), bachTrack.tpcNSigmaKa(), bachTrack.tpcInnerParam()); + QAHistos.fill(HIST("hTPCNsigmaOmegaV0Proton"), posTrack.tpcNSigmaPr(), posTrack.tpcInnerParam()); + QAHistos.fill(HIST("hTPCNsigmaOmegaV0PiMinus"), negTrack.tpcNSigmaPi(), negTrack.tpcInnerParam()); + QAHistos.fill(HIST("hHasTOFPr"), posTrack.hasTOF(), posTrack.pt()); + QAHistos.fill(HIST("hHasTOFPi"), negTrack.hasTOF(), negTrack.pt()); } - QAHistos.fill(HIST("hHasTOFBachKa"), bachelor.hasTOF(), bachelor.pt()); - QAHistos.fill(HIST("hRapOmega"), casc.yOmega()); + QAHistos.fill(HIST("hHasTOFBachKa"), bachTrack.hasTOF(), bachTrack.pt()); + QAHistos.fill(HIST("hRapOmega"), yOmega); } // Count number of Omega candidates omegacounter++; - v0sFromOmegaID.push_back({casc.posTrackId(), casc.negTrackId()}); + v0sFromOmegaID.push_back({posTrack.globalIndex(), negTrack.globalIndex()}); } + if (isOmegalargeR) { omegalargeRcounter++; - QAHistosTopologicalVariables.fill(HIST("hCascRadiusOmegaLargeR"), casc.cascradius()); + QAHistosTopologicalVariables.fill(HIST("hCascRadiusOmegaLargeR"), Casccascradius); } } // end loop over cascades - // Omega trigger definition - if (omegacounter > 0) { - keepEvent[0] = true; - } + keepEvent[0] = omegacounter > 0; - bool EvtwhMinPt[11]; - bool EvtwhMinPtCasc[11]; - float ThrdPt[11]; + std::array EvtwhMinPt{false}; + std::array ThrdPt; for (int i = 0; i < 11; i++) { - EvtwhMinPt[i] = 0.; - EvtwhMinPtCasc[i] = 0.; ThrdPt[i] = static_cast(i); } // QA tracks + int triggcounterAllEv = 0; for (auto track : tracks) { // start loop over tracks - if (isTrackFilter && !mTrackSelector.IsSelected(track)) { + if (isTrackFilter && !selectTrack(track)) { continue; } triggcounterAllEv++; QAHistosTriggerParticles.fill(HIST("hPtTriggerAllEv"), track.pt()); QAHistosTriggerParticles.fill(HIST("hPhiTriggerAllEv"), track.phi(), track.pt()); QAHistosTriggerParticles.fill(HIST("hEtaTriggerAllEv"), track.eta(), track.pt()); - QAHistosTriggerParticles.fill(HIST("hDCAxyTriggerAllEv"), track.dcaXY(), track.pt()); - QAHistosTriggerParticles.fill(HIST("hDCAzTriggerAllEv"), track.dcaZ(), track.pt()); - for (int i = 0; i < 11; i++) { - if (track.pt() > ThrdPt[i]) - EvtwhMinPt[i] = 1; + for (size_t i = 0; i < ThrdPt.size(); i++) { + EvtwhMinPt[i] = track.pt() > ThrdPt[i]; + } + + // High-pT hadron + Omega trigger definition + if (omegacounter > 0) { + keepEvent[1] = true; + QAHistosTriggerParticles.fill(HIST("hPtTriggerSelEv"), track.pt()); } } // end loop over tracks for (int i = 0; i < 11; i++) { @@ -772,32 +1099,18 @@ struct strangenessFilter { } } QAHistosTriggerParticles.fill(HIST("hTriggeredParticlesAllEv"), triggcounterAllEv); - - // High-pT hadron + Omega trigger definition - if (omegacounter > 0) { - for (auto track : tracks) { // start loop over tracks - if (isTrackFilter && !mTrackSelector.IsSelected(track)) { - continue; - } - triggcounter++; - QAHistosTriggerParticles.fill(HIST("hPtTriggerSelEv"), track.pt()); - for (int i = 0; i < 11; i++) { - if (track.pt() > ThrdPt[i]) - EvtwhMinPtCasc[i] = 1; + if (keepEvent[1]) { + QAHistosTriggerParticles.fill(HIST("hTriggeredParticlesSelEv"), triggcounterAllEv); + for (size_t i = 0; i < EvtwhMinPt.size(); i++) { + if (EvtwhMinPt[i]) { + hEvtvshMinPt->Fill(i + 0.5); } - keepEvent[1] = true; - } // end loop over tracks - QAHistosTriggerParticles.fill(HIST("hTriggeredParticlesSelEv"), triggcounter); - } - - for (int i = 0; i < 11; i++) { - if (EvtwhMinPtCasc[i]) - hEvtvshMinPt->Fill(i + 0.5); + } } // Double/triple/quad Xi trigger definition if (v0sFromXiID.size() > 0) { - std::set> uniqueXis = {v0sFromXiID.begin(), v0sFromXiID.end()}; + std::set> uniqueXis = {v0sFromXiID.begin(), v0sFromXiID.end()}; if (uniqueXis.size() > 1) { keepEvent[2] = true; } @@ -811,7 +1124,7 @@ struct strangenessFilter { // Double Omega trigger definition if (v0sFromOmegaID.size() > 0) { - std::set> uniqueOmegas = {v0sFromOmegaID.begin(), v0sFromOmegaID.end()}; + std::set> uniqueOmegas = {v0sFromOmegaID.begin(), v0sFromOmegaID.end()}; if (uniqueOmegas.size() > 1) { keepEvent[10] = true; } @@ -819,8 +1132,8 @@ struct strangenessFilter { // Omega + Xi trigger definition if (v0sFromOmegaID.size() > 0 && v0sFromXiID.size() > 0) { - std::set> uniqueOmegas = {v0sFromOmegaID.begin(), v0sFromOmegaID.end()}; - std::set> uniqueXis = {v0sFromXiID.begin(), v0sFromXiID.end()}; + std::set> uniqueOmegas = {v0sFromOmegaID.begin(), v0sFromOmegaID.end()}; + std::set> uniqueXis = {v0sFromXiID.begin(), v0sFromXiID.end()}; if (uniqueOmegas.size() > 1 || uniqueXis.size() > 1) { keepEvent[11] = true; } else { @@ -845,54 +1158,22 @@ struct strangenessFilter { } // Omega in high multiplicity events - if (omegacounter > 0) + if (omegacounter > 0) { EventsvsMultiplicity.fill(HIST("AllEventsvsMultiplicityFT0MwOmega"), collision.multFT0M()); + EventsvsMultiplicity.fill(HIST("AllEventsvsMultiplicityFT0MwOmegaNorm"), multFT0MNorm); + } if (omegacounter > 0 && isHighMultEvent) { keepEvent[9] = true; } - // strangeness tracking selection - const auto bc = collision.bc_as(); - if (runNumber != bc.runNumber()) { - runNumber = bc.runNumber(); - auto timestamp = bc.timestamp(); - - if (o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, timestamp)) { - o2::base::Propagator::initFieldFromGRP(grpo); - bz = grpo->getNominalL3Field(); - } else if (o2::parameters::GRPMagField* grpmag = ccdb->getForTimeStamp(grpMagPath, timestamp)) { - o2::base::Propagator::initFieldFromGRP(grpmag); - bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - } else { - LOG(fatal) << "Got nullptr from CCDB for path " << grpMagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << timestamp; - } - } - - const auto primaryVertex = getPrimaryVertex(collision); - o2::dataformats::DCA impactParameterTrk; - - for (const auto& casc : fullCasc) { - QAHistosStrangenessTracking.fill(HIST("hPtCascCand"), casc.pt()); - } - - const auto matCorr = static_cast(materialCorrectionType.value); - o2::vertexing::DCAFitterN<2> df2; - df2.setBz(bz); - df2.setPropagateToPCA(propToDCA); - df2.setMaxR(maxR); - df2.setMaxDZIni(maxDZIni); - df2.setMinParamChange(minParamChange); - df2.setMinRelChi2Change(minRelChi2Change); - df2.setUseAbsDCA(useAbsDCA); - for (const auto& trackedCascade : trackedCascades) { - const auto trackCasc = trackedCascade.track_as(); + const auto trackCasc = trackedCascade.track_as(); QAHistosStrangenessTracking.fill(HIST("hPtCascTracked"), trackCasc.pt()); QAHistosStrangenessTracking.fill(HIST("hStRVsPtTrkCasc"), trackCasc.pt(), RecoDecay::sqrtSumOfSquares(trackCasc.x(), trackCasc.y())); QAHistosStrangenessTracking.fill(HIST("hMatchChi2TrkCasc"), trackedCascade.matchingChi2()); auto trackParCovTrk = getTrackParCov(trackCasc); - o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, trackParCovTrk, bz, 2.f, matCorr, &impactParameterTrk); + o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, trackParCovTrk, mBz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrLUT, &impactParameterTrk); QAHistosStrangenessTracking.fill(HIST("hDcaXY"), impactParameterTrk.getY()); QAHistosStrangenessTracking.fill(HIST("hDcaXYVsPt"), trackParCovTrk.getPt(), impactParameterTrk.getY()); @@ -905,10 +1186,10 @@ struct strangenessFilter { // const auto itsTrack = trackedCascade.itsTrack(); const auto cascade = trackedCascade.cascade(); - const auto bachelor = cascade.bachelor_as(); + const auto bachelor = cascade.bachelor_as(); const auto v0 = cascade.v0_as(); - const auto negTrack = v0.negTrack_as(); - const auto posTrack = v0.posTrack_as(); + const auto negTrack = v0.negTrack_as(); + const auto posTrack = v0.posTrack_as(); if (!posTrack.hasTPC() || !negTrack.hasTPC() || !bachelor.hasTPC() || posTrack.tpcNClsFindable() < minNoClsTrackedCascade || @@ -946,17 +1227,16 @@ struct strangenessFilter { o2::track::TrackPar trackParV0; o2::track::TrackPar trackParBachelor; float cpa = -1; - if (df2.process(getTrackParCov(negTrack), getTrackParCov(posTrack))) { - trackParCovV0 = df2.createParentTrackParCov(0); - if (df2.process(trackParCovV0, getTrackParCov(bachelor))) { - trackParV0 = df2.getTrackParamAtPCA(0); - trackParBachelor = df2.getTrackParamAtPCA(1); + if (mDCAFitter.process(getTrackParCov(negTrack), getTrackParCov(posTrack))) { + trackParCovV0 = mDCAFitter.createParentTrackParCov(0); + if (mDCAFitter.process(trackParCovV0, getTrackParCov(bachelor))) { + trackParV0 = mDCAFitter.getTrackParamAtPCA(0); + trackParBachelor = mDCAFitter.getTrackParamAtPCA(1); trackParV0.getPxPyPzGlo(momenta[0]); trackParBachelor.getPxPyPzGlo(momenta[1]); std::array pVec; - df2.createParentTrackParCov().getPxPyPzGlo(pVec); - std::array pvPos = {primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}; - cpa = RecoDecay::cpa(pvPos, df2.getPCACandidate(), pVec); + mDCAFitter.createParentTrackParCov().getPxPyPzGlo(pVec); + cpa = RecoDecay::cpa(pvPos, mDCAFitter.getPCACandidate(), pVec); QAHistosStrangenessTracking.fill(HIST("hCpa"), cpa); } else { continue; @@ -1073,7 +1353,9 @@ struct strangenessFilter { if (keepEvent[11]) { hProcessedEvents->Fill(14.5); } - + if (keepEvent[12]) { + hProcessedEvents->Fill(15.5); + } // Filling the table fillTriggerTable(keepEvent); } diff --git a/EventFiltering/PWGMM/multFilter.cxx b/EventFiltering/PWGMM/multFilter.cxx index cf9057a28a3..fe641438a43 100644 --- a/EventFiltering/PWGMM/multFilter.cxx +++ b/EventFiltering/PWGMM/multFilter.cxx @@ -8,24 +8,23 @@ // 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 -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StaticFor.h" - +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" #include "EventFiltering/filterTables.h" #include "CCDB/BasicCCDBManager.h" #include "CCDB/CcdbApi.h" #include "DataFormatsFT0/Digit.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StaticFor.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/TrackSelection.h" + +#include +#include using namespace o2; using namespace o2::framework; @@ -58,6 +57,9 @@ struct multFilter { Configurable sel8{"sel8", 1, "apply sel8 event selection"}; Configurable selt0time{"selt0time", 0, "apply 1ns cut T0A and T0C"}; Configurable selt0vtx{"selt0vtx", 0, "apply T0 vertext trigger"}; + Configurable isTimeFrameBorderCut{"isTimeFrameBorderCut", 1, "apply timeframe border cut"}; + Configurable isSameBunchPileup{"isSameBunchPileup", 1, "apply same bunch pileup cut"}; + Configurable isGoodZvtxFT0vsPV{"isGoodZvtxFT0vsPV", 1, "apply good vtx FT0vsPV cut"}; Configurable avPyT0A{"avPyT0A", 8.16, "nch from pythia T0A"}; Configurable avPyT0C{"avPyT0C", 8.83, "nch from pythia T0C"}; @@ -358,6 +360,19 @@ struct multFilter { return; } + if (isTimeFrameBorderCut && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + tags(false, false, false, false, false, false, false); + return; + } + if (isSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + tags(false, false, false, false, false, false, false); + return; + } + if (isGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + tags(false, false, false, false, false, false, false); + return; + } + multiplicity.fill(HIST("hMultFV0sel"), sumAmpFV0); multiplicity.fill(HIST("hMultFV01to4Ringsel"), sumAmpFV01to4Ring); multiplicity.fill(HIST("hMultFV05Ringsel"), sumAmpFV05Ring); diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index ec661548d09..ccdf063307d 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -12,13 +12,31 @@ #include "Zorro.h" -#include -#include +#include "EventFiltering/ZorroHelper.h" + +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include +#include +#include -#include "CCDB/BasicCCDBManager.h" -#include "CommonDataFormat/InteractionRecord.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include using o2::InteractionRecord; @@ -113,7 +131,7 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto) } if (!ToiHisto) { LOGF(info, "TOI histogram not set, creating a new one"); - ToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); + ToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); } // if it is the first run, initialize the histogram if (mRunNumberHistos.size() == 0) { @@ -126,10 +144,11 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto) ZorroHisto->GetYaxis()->SetBinLabel(i + 2 + mTOIs.size(), Form("%s scalers", mTOIs[i].data())); } // TOI histogram - ToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); + ToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); ToiHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); for (size_t i{0}; i < mTOIs.size(); ++i) { - ToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data()); + ToiHisto->GetYaxis()->SetBinLabel(i * 2 + 1, mTOIs[i].data()); + ToiHisto->GetYaxis()->SetBinLabel(i * 2 + 2, Form("%s AnalysedTriggers", mTOIs[i].data())); } } if (mInspectedTVX) { @@ -137,6 +156,10 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto) ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, 1, mInspectedTVX->GetBinError(1)); } if (mSelections) { + mAnalysedTriggers = new TH1D("AnalysedTriggers", "", mSelections->GetNbinsX() - 2, -0.5, mSelections->GetNbinsX() - 2.5); + for (int iBin{2}; iBin < mSelections->GetNbinsX(); ++iBin) { // Exclude first and last bins as they are total number of analysed and selected events, respectively + mAnalysedTriggers->GetXaxis()->SetBinLabel(iBin - 1, mSelections->GetXaxis()->GetBinLabel(iBin)); + } for (size_t i{0}; i < mTOIs.size(); ++i) { int bin = findBin(mSelections, mTOIs[i]); ZorroHisto->Fill(Form("%d", runNumber), Form("%s selections", mTOIs[i].data()), mSelections->GetBinContent(bin)); @@ -176,24 +199,18 @@ std::vector Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber mLastSelectedIdx = 0; mTOIs.clear(); mTOIidx.clear(); - while (!tois.empty()) { - size_t pos = tois.find(","); - pos = (pos == std::string::npos) ? tois.size() : pos; - std::string token = tois.substr(0, pos); - // Trim leading and trailing whitespaces from the token - token.erase(0, token.find_first_not_of(" ")); - token.erase(token.find_last_not_of(" ") + 1); + std::vector tokens = o2::utils::Str::tokenize(tois, ','); // tokens are trimmed + for (auto const& token : tokens) { int bin = findBin(mSelections, token) - 2; mTOIs.push_back(token); mTOIidx.push_back(bin); - tois = tois.erase(0, pos + 1); } mTOIcounts.resize(mTOIs.size(), 0); LOGF(info, "Zorro initialized for run %d, triggers of interest:", runNumber); for (size_t i{0}; i < mTOIs.size(); ++i) { LOGF(info, ">>> %s : %i", mTOIs[i].data(), mTOIidx[i]); } - mZorroSummary.setupTOIs(mTOIs.size(), tois); + mZorroSummary.setupTOIs(mTOIs.size(), mTOIs); std::vector toiCounters(mTOIs.size(), 0.); for (size_t i{0}; i < mTOIs.size(); ++i) { toiCounters[i] = mSelections->GetBinContent(mTOIidx[i] + 2); @@ -207,7 +224,7 @@ std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance) { mLastResult.reset(); if (bcGlobalId < mBCranges.front().getMin().toLong() - tolerance || bcGlobalId > mBCranges.back().getMax().toLong() + tolerance) { - setupHelpers((mOrbitResetTimestamp + int64_t(bcGlobalId * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000); + setupHelpers((mOrbitResetTimestamp + static_cast(bcGlobalId * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000); } o2::dataformats::IRFrame bcFrame{InteractionRecord::long2IR(bcGlobalId) - tolerance, InteractionRecord::long2IR(bcGlobalId) + tolerance}; @@ -248,6 +265,11 @@ bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance, TH2* ToiHisto) if (mTOIidx[i] < 0) { continue; } else if (mLastResult.test(mTOIidx[i])) { + if (ToiHisto && mAnalysedTriggers) { + int binX = ToiHisto->GetXaxis()->FindBin(Form("%d", mRunNumber)); + int binY = ToiHisto->GetYaxis()->FindBin(Form("%s AnalysedTriggers", mTOIs[i].data())); + ToiHisto->SetBinContent(binX, binY, mAnalysedTriggers->GetBinContent(mAnalysedTriggers->GetXaxis()->FindBin(mTOIs[i].data()))); + } mTOIcounts[i] += (lastSelectedIdx != mLastSelectedIdx); /// Avoid double counting if (mAnalysedTriggersOfInterest && lastSelectedIdx != mLastSelectedIdx) { mAnalysedTriggersOfInterest->Fill(i); @@ -296,7 +318,7 @@ void Zorro::setupHelpers(int64_t timestamp) std::sort(mZorroHelpers->begin(), mZorroHelpers->end(), [](const auto& a, const auto& b) { return std::min(a.bcAOD, a.bcEvSel) < std::min(b.bcAOD, b.bcEvSel); }); mBCranges.clear(); mAccountedBCranges.clear(); - for (auto helper : *mZorroHelpers) { + for (const auto& helper : *mZorroHelpers) { mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel))); } mAccountedBCranges.resize(mBCranges.size(), false); diff --git a/EventFiltering/Zorro.h b/EventFiltering/Zorro.h index c818e45ce48..f03badab2ce 100644 --- a/EventFiltering/Zorro.h +++ b/EventFiltering/Zorro.h @@ -9,24 +9,31 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // -// Zero Obstacles Results Retriever for Offline trigger selections + +/// +/// \file Zorro.h +/// \brief Zero Obstacles Results Retriever for Offline trigger selections +/// \author M Puccio +/// #ifndef EVENTFILTERING_ZORRO_H_ #define EVENTFILTERING_ZORRO_H_ +#include "ZorroHelper.h" +#include "ZorroSummary.h" + +#include +#include + +#include +#include + #include -#include +#include #include #include #include -#include "TH1D.h" -#include "TH2D.h" -#include "CommonDataFormat/IRFrame.h" -#include "Framework/HistogramRegistry.h" -#include "ZorroHelper.h" -#include "ZorroSummary.h" - namespace o2 { namespace ccdb @@ -54,9 +61,10 @@ class Zorro std::vector getTOIcounters() const { return mTOIcounts; } std::vector getTriggerOfInterestResults(uint64_t bcGlobalId, uint64_t tolerance = 100); std::vector getTriggerOfInterestResults() const; + int getNTOIs() const { return mTOIs.size(); } - void setCCDBpath(std::string path) { mBaseCCDBPath = path; } - void setBaseCCDBPath(std::string path) { mBaseCCDBPath = path; } + void setCCDBpath(const std::string& path) { mBaseCCDBPath = path; } + void setBaseCCDBPath(const std::string& path) { mBaseCCDBPath = path; } void setBCtolerance(int tolerance) { mBCtolerance = tolerance; } ZorroSummary* getZorroSummary() { return &mZorroSummary; } @@ -70,8 +78,8 @@ class Zorro int mRunNumber = 0; std::pair mRunDuration; int64_t mOrbitResetTimestamp = 0; - TH1* mAnalysedTriggers; /// Accounting for all triggers in the current run - TH1* mAnalysedTriggersOfInterest; /// Accounting for triggers of interest in the current run + TH1* mAnalysedTriggers = nullptr; /// Accounting for all triggers in the current run + TH1* mAnalysedTriggersOfInterest = nullptr; /// Accounting for triggers of interest in the current run std::vector mRunNumberHistos; std::vector mAnalysedTriggersList; /// Per run histograms diff --git a/EventFiltering/ZorroHelper.h b/EventFiltering/ZorroHelper.h index 8bcc6240bc0..e80a07ef994 100644 --- a/EventFiltering/ZorroHelper.h +++ b/EventFiltering/ZorroHelper.h @@ -13,7 +13,8 @@ #ifndef EVENTFILTERING_ZORROHELPER_H_ #define EVENTFILTERING_ZORROHELPER_H_ -#include "Rtypes.h" +#include +#include struct ZorroHelper { ULong64_t bcAOD, bcEvSel, trigMask[2], selMask[2]; diff --git a/EventFiltering/ZorroSummary.cxx b/EventFiltering/ZorroSummary.cxx index ee241f49108..0a1012c3edc 100644 --- a/EventFiltering/ZorroSummary.cxx +++ b/EventFiltering/ZorroSummary.cxx @@ -11,7 +11,12 @@ #include "ZorroSummary.h" -#include "TCollection.h" +#include +#include + +#include + +#include void ZorroSummary::Copy(TObject& c) const { @@ -42,7 +47,7 @@ Long64_t ZorroSummary::Merge(TCollection* list) mTOIcounters[runNumber] = entry->getTOIcounters().at(runNumber); } else { auto& thisCounters = mAnalysedTOIcounters[runNumber]; - for (size_t i = 0; i < thisCounters.size(); ++i) { + for (std::size_t i = 0; i < thisCounters.size(); ++i) { thisCounters[i] += currentAnalysedToiCounters[i]; } } @@ -66,4 +71,4 @@ double ZorroSummary::getNormalisationFactor(int toiId) const } return totalTVX * totalAnalysedTOI / totalTOI; -} \ No newline at end of file +} diff --git a/EventFiltering/ZorroSummary.h b/EventFiltering/ZorroSummary.h index b4d401adba4..51019aeef18 100644 --- a/EventFiltering/ZorroSummary.h +++ b/EventFiltering/ZorroSummary.h @@ -15,6 +15,9 @@ #include +#include +#include + #include #include #include @@ -28,10 +31,16 @@ class ZorroSummary : public TNamed virtual void Copy(TObject& c) const; // NOLINT: Making this override breaks compilation for unknown reason virtual Long64_t Merge(TCollection* list); - void setupTOIs(int ntois, const std::string& toinames) + void setupTOIs(int ntois, const std::vector& toinames) { mNtois = ntois; - mTOInames = toinames; + if (toinames.size() == 0) { + return; + } + mTOInames = toinames[0]; + for (size_t i = 1; i < toinames.size(); i++) { + mTOInames += "," + toinames[i]; + } } void setupRun(int runNumber, double tvxCountes, const std::vector& toiCounters) { @@ -41,9 +50,7 @@ class ZorroSummary : public TNamed mRunNumber = runNumber; mTVXcounters[runNumber] = tvxCountes; mTOIcounters[runNumber] = toiCounters; - if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) { - mAnalysedTOIcounters[runNumber] = std::vector(mNtois, 0ull); - } + mAnalysedTOIcounters.try_emplace(runNumber, std::vector(mNtois, 0ull)); mCurrentAnalysedTOIcounters = &mAnalysedTOIcounters[runNumber]; } double getNormalisationFactor(int toiId) const; @@ -55,7 +62,7 @@ class ZorroSummary : public TNamed mCurrentAnalysedTOIcounters->at(toiId)++; } - std::string getTOInames() const { return mTOInames; } + const auto& getTOInames() const { return mTOInames; } const auto& getTOIcounters() const { return mTOIcounters; } const auto& getTVXcounters() const { return mTVXcounters; } const auto& getAnalysedTOIcounters() const { return mAnalysedTOIcounters; } @@ -73,4 +80,4 @@ class ZorroSummary : public TNamed ClassDef(ZorroSummary, 1); }; -#endif // EVENTFILTERING_ZORROSUMMARY_H_ \ No newline at end of file +#endif // EVENTFILTERING_ZORROSUMMARY_H_ diff --git a/EventFiltering/cefpTask.cxx b/EventFiltering/cefpTask.cxx index b5cfa90449a..64cf4435b85 100644 --- a/EventFiltering/cefpTask.cxx +++ b/EventFiltering/cefpTask.cxx @@ -217,6 +217,7 @@ struct centralEventFilterTask { Configurable cfgSkipUntriggeredEvents{"cfgSkipUntriggeredEvents", false, "Skip untriggered events"}; FILTER_CONFIGURABLE(F1ProtonFilters); + FILTER_CONFIGURABLE(DoublePhiFilters); FILTER_CONFIGURABLE(NucleiFilters); FILTER_CONFIGURABLE(DiffractionFilters); FILTER_CONFIGURABLE(DqFilters); @@ -227,6 +228,7 @@ struct centralEventFilterTask { FILTER_CONFIGURABLE(MultFilters); FILTER_CONFIGURABLE(FullJetFilters); FILTER_CONFIGURABLE(PhotonFilters); + FILTER_CONFIGURABLE(HeavyNeutralMesonFilters); void init(o2::framework::InitContext& initc) { @@ -358,21 +360,24 @@ struct centralEventFilterTask { mFiltered->SetBinContent(1, mFiltered->GetBinContent(1) + nEvents - startCollision); for (uint64_t iE{0}; iE < outTrigger.size(); ++iE) { + const auto& triggerWord{outTrigger[iE]}; bool triggered{false}, selected{false}; - for (uint64_t iD{0}; iD < outTrigger[0].size(); ++iD) { + for (uint64_t iD{0}; iD < triggerWord.size(); ++iD) { for (int iB{0}; iB < 64; ++iB) { - if (!(outTrigger[iE][iD] & BIT(iB))) { + if (!(triggerWord[iD] & BIT(iB))) { continue; } - for (uint64_t jD{0}; jD < outTrigger[0].size(); ++jD) { - for (int iC{iB}; iC < 64; ++iC) { - if (outTrigger[iE][iD] & BIT(iC)) { - mCovariance->Fill(iD * 64 + iB, jD * 64 + iC); + uint64_t xIndex{iD * 64 + iB}; + for (uint64_t jD{0}; jD < triggerWord.size(); ++jD) { + for (int jB{0}; jB < 64; ++jB) { + uint64_t yIndex{jD * 64 + jB}; + if (xIndex <= yIndex && triggerWord[jD] & BIT(jB)) { + mCovariance->Fill(iD * 64 + iB, jD * 64 + jB); } } } } - triggered = triggered || outTrigger[iE][iD]; + triggered = triggered || triggerWord[iD]; selected = selected || outDecision[iE][iD]; } if (triggered) { diff --git a/EventFiltering/filterTables.h b/EventFiltering/filterTables.h index 7283dec82de..1371d152e75 100644 --- a/EventFiltering/filterTables.h +++ b/EventFiltering/filterTables.h @@ -46,9 +46,11 @@ namespace o2::aod { namespace filtering { -DECLARE_SOA_COLUMN(H2, hasH2, bool); //! deuteron trigger for the helium normalisation (to be downscaled) -DECLARE_SOA_COLUMN(He, hasHe, bool); //! helium -DECLARE_SOA_COLUMN(H3L3Body, hasH3L3Body, bool); //! hypertriton 3body +DECLARE_SOA_COLUMN(H2, hasH2, bool); //! deuteron trigger for the helium normalisation (to be downscaled) +DECLARE_SOA_COLUMN(He, hasHe, bool); //! helium +DECLARE_SOA_COLUMN(HeV0, hasHeV0, bool); //! V0 containing a V0 +DECLARE_SOA_COLUMN(TritonFemto, hasTritonFemto, bool); //! Triton hadron femtoscopy +DECLARE_SOA_COLUMN(H3L3Body, hasH3L3Body, bool); //! hypertriton 3body DECLARE_SOA_COLUMN(ITSextremeIonisation, hasITSextremeIonisation, bool); //! ITS extreme ionisation DECLARE_SOA_COLUMN(ITSmildIonisation, hasITSmildIonisation, bool); //! ITS mild ionisation (normalisation of the extreme ionisation), to be downscaled @@ -67,39 +69,61 @@ DECLARE_SOA_COLUMN(DiMuon, hasDiMuon, bool); //! dimuon trigger with // EM dielectrons DECLARE_SOA_COLUMN(LMeeIMR, hasLMeeIMR, bool); //! dielectron trigger for intermediate mass region DECLARE_SOA_COLUMN(LMeeHMR, hasLMeeHMR, bool); //! dielectron trigger for high mass region +// Electron-muon pair +DECLARE_SOA_COLUMN(ElectronMuon, hasElectronMuon, bool); //! dimuon trigger with low pT on muons // heavy flavours -DECLARE_SOA_COLUMN(HfHighPt2P, hasHfHighPt2P, bool); //! high-pT 2-prong charm hadron -DECLARE_SOA_COLUMN(HfHighPt3P, hasHfHighPt3P, bool); //! high-pT 3-prong charm hadron -DECLARE_SOA_COLUMN(HfBeauty3P, hasHfBeauty3P, bool); //! 3-prong beauty hadron -DECLARE_SOA_COLUMN(HfBeauty4P, hasHfBeauty4P, bool); //! 4-prong beauty hadron -DECLARE_SOA_COLUMN(HfFemto2P, hasHfFemto2P, bool); //! 2-prong charm-hadron - N pair -DECLARE_SOA_COLUMN(HfFemto3P, hasHfFemto3P, bool); //! 3-prong charm-hadron - N pair -DECLARE_SOA_COLUMN(HfDoubleCharm2P, hasHfDoubleCharm2P, bool); //! at least two 2-prong charm-hadron candidates -DECLARE_SOA_COLUMN(HfDoubleCharm3P, hasHfDoubleCharm3P, bool); //! at least two 3-prong charm-hadron candidates -DECLARE_SOA_COLUMN(HfDoubleCharmMix, hasHfDoubleCharmMix, bool); //! at least one 2-prong and one 3-prong charm-hadron candidates -DECLARE_SOA_COLUMN(HfV0Charm2P, hasHfV0Charm2P, bool); //! V0 with 2-prong charm hadron -DECLARE_SOA_COLUMN(HfV0Charm3P, hasHfV0Charm3P, bool); //! V0 with 3-prong charm hadron -DECLARE_SOA_COLUMN(HfCharmBarToXiBach, hasHfCharmBarToXiBach, bool); //! Charm baryon to Xi + bachelor -DECLARE_SOA_COLUMN(HfSigmaCPPK, hasHfSigmaCPPK, bool); //! SigmaC(2455)++K- and SigmaC(2520)++K- + c.c. -DECLARE_SOA_COLUMN(HfSigmaC0K0, hasHfSigmaC0K0, bool); //! SigmaC(2455)0KS0 and SigmaC(2520)0KS0 -DECLARE_SOA_COLUMN(HfPhotonCharm2P, hasHfPhotonCharm2P, bool); //! photon with 2-prong charm hadron -DECLARE_SOA_COLUMN(HfPhotonCharm3P, hasHfPhotonCharm3P, bool); //! photon with 3-prong charm hadron -DECLARE_SOA_COLUMN(HfSingleCharm2P, hasHfSingleCharm2P, bool); //! 2-prong charm hadron (for efficiency studies) -DECLARE_SOA_COLUMN(HfSingleCharm3P, hasHfSingleCharm3P, bool); //! 3-prong charm hadron (for efficiency studies) +DECLARE_SOA_COLUMN(HfHighPt2P, hasHfHighPt2P, bool); //! high-pT 2-prong charm hadron +DECLARE_SOA_COLUMN(HfHighPt3P, hasHfHighPt3P, bool); //! high-pT 3-prong charm hadron +DECLARE_SOA_COLUMN(HfBeauty3P, hasHfBeauty3P, bool); //! 3-prong beauty hadron +DECLARE_SOA_COLUMN(HfBeauty4P, hasHfBeauty4P, bool); //! 4-prong beauty hadron +DECLARE_SOA_COLUMN(HfFemto2P, hasHfFemto2P, bool); //! 2-prong charm-hadron - N pair +DECLARE_SOA_COLUMN(HfFemto3P, hasHfFemto3P, bool); //! 3-prong charm-hadron - N pair +DECLARE_SOA_COLUMN(HfDoubleCharm2P, hasHfDoubleCharm2P, bool); //! at least two 2-prong charm-hadron candidates +DECLARE_SOA_COLUMN(HfDoubleCharm3P, hasHfDoubleCharm3P, bool); //! at least two 3-prong charm-hadron candidates +DECLARE_SOA_COLUMN(HfDoubleCharmMix, hasHfDoubleCharmMix, bool); //! at least one 2-prong and one 3-prong charm-hadron candidates +DECLARE_SOA_COLUMN(HfV0Charm2P, hasHfV0Charm2P, bool); //! V0 with 2-prong charm hadron +DECLARE_SOA_COLUMN(HfV0Charm3P, hasHfV0Charm3P, bool); //! V0 with 3-prong charm hadron +DECLARE_SOA_COLUMN(HfCharmBarToXiBach, hasHfCharmBarToXiBach, bool); //! Charm baryon to Xi + bachelor +DECLARE_SOA_COLUMN(HfCharmBarToXi2Bach, hasHfCharmBarToXi2Bach, bool); //! Charm baryon to Xi + 2 bachelors +DECLARE_SOA_COLUMN(HfPrCharm2P, hasHfPrCharm2P, bool); //! Charm baryon to 2-prong + bachelors +DECLARE_SOA_COLUMN(HfSigmaCPPK, hasHfSigmaCPPK, bool); //! SigmaC(2455)++K- and SigmaC(2520)++K- + c.c. +DECLARE_SOA_COLUMN(HfSigmaC0K0, hasHfSigmaC0K0, bool); //! SigmaC(2455)0KS0 and SigmaC(2520)0KS0 +DECLARE_SOA_COLUMN(HfPhotonCharm2P, hasHfPhotonCharm2P, bool); //! photon with 2-prong charm hadron +DECLARE_SOA_COLUMN(HfPhotonCharm3P, hasHfPhotonCharm3P, bool); //! photon with 3-prong charm hadron +DECLARE_SOA_COLUMN(HfSingleCharm2P, hasHfSingleCharm2P, bool); //! 2-prong charm hadron (for efficiency studies) +DECLARE_SOA_COLUMN(HfSingleCharm3P, hasHfSingleCharm3P, bool); //! 3-prong charm hadron (for efficiency studies) DECLARE_SOA_COLUMN(HfSingleNonPromptCharm2P, hasHfSingleNonPromptCharm2P, bool); //! 2-prong charm hadron (for efficiency studies) DECLARE_SOA_COLUMN(HfSingleNonPromptCharm3P, hasHfSingleNonPromptCharm3P, bool); //! 3-prong charm hadron (for efficiency studies) +DECLARE_SOA_COLUMN(HfBtoJPsiKa, hasHfBtoJPsiKa, bool); //! B+ -> JPsi(->mumu)K+ +DECLARE_SOA_COLUMN(HfBtoJPsiKstar, hasHfBtoJPsiKstar, bool); //! B0 -> JPsi(->mumu)K*+(->Kpi) +DECLARE_SOA_COLUMN(HfBtoJPsiPhi, hasHfBtoJPsiPhi, bool); //! B0s -> JPsi(->mumu)phi(->KK) +DECLARE_SOA_COLUMN(HfBtoJPsiPrKa, hasHfBtoJPsiPrKa, bool); //! Lb -> JPsi(->mumu)pK+ +DECLARE_SOA_COLUMN(HfBtoJPsiPi, hasHfBtoJPsiPi, bool); //! Bc -> JPsi(->mumu)pi+ // CF two body triggers -DECLARE_SOA_COLUMN(PD, hasPD, bool); //! has d-p pair -DECLARE_SOA_COLUMN(LD, hasLD, bool); //! has l-d pair +DECLARE_SOA_COLUMN(PD_TightKstar, hasPD_TightKstar, bool); //! has d-p pair with tight kstar limit +DECLARE_SOA_COLUMN(PD_LooseKstar, hasPD_LooseKstar, bool); //! has d-p pair with loose kstar limit +DECLARE_SOA_COLUMN(LD_TightKstar, hasLD_TightKstar, bool); //! has l-d pair with tight kstar limit +DECLARE_SOA_COLUMN(LD_LooseKstar, hasLD_LooseKstar, bool); //! has l-d pair with loose kstar limit +DECLARE_SOA_COLUMN(PHID_TightKstar, hasPHID_TightKstar, bool); //! has phi-d pair with tight kstar limit +DECLARE_SOA_COLUMN(PHID_LooseKstar, hasPHID_LooseKstar, bool); //! has phi-d pair with loose kstar limit +DECLARE_SOA_COLUMN(RHOD_TightKstar, hasRHOD_TightKstar, bool); //! has rho-d pair with tight kstar limit +DECLARE_SOA_COLUMN(RHOD_LooseKstar, hasRHOD_LooseKstar, bool); //! has rho-d pair with loose kstar limit // CF three body triggers -DECLARE_SOA_COLUMN(PPP, hasPPP, bool); //! has p-p-p triplet -DECLARE_SOA_COLUMN(PPL, hasPPL, bool); //! has p-p-L triplet -DECLARE_SOA_COLUMN(PLL, hasPLL, bool); //! has p-L-L triplet -DECLARE_SOA_COLUMN(LLL, hasLLL, bool); //! has L-L-L tripletD -DECLARE_SOA_COLUMN(PPPHI, hasPPPHI, bool); //! has P-P-PHI triplet +DECLARE_SOA_COLUMN(PPP_TightQ3, hasPPP_TightQ3, bool); //! has p-p-p triplet with tight Q3 limit +DECLARE_SOA_COLUMN(PPP_LooseQ3, hasPPP_LooseQ3, bool); //! has p-p-p triplet with loose Q3 limit +DECLARE_SOA_COLUMN(PPL_TightQ3, hasPPL_TightQ3, bool); //! has p-p-L triplet with tight Q3 limit +DECLARE_SOA_COLUMN(PPL_LooseQ3, hasPPL_LooseQ3, bool); //! has p-p-L triplet with loose Q3 limit +DECLARE_SOA_COLUMN(PLL_TightQ3, hasPLL_TightQ3, bool); //! has p-L-L triplet with tight Q3 limit +DECLARE_SOA_COLUMN(PLL_LooseQ3, hasPLL_LooseQ3, bool); //! has p-L-L triplet with loose Q3 limit +DECLARE_SOA_COLUMN(LLL_TightQ3, hasLLL_TightQ3, bool); //! has L-L-L tripletD with tight Q3 limit +DECLARE_SOA_COLUMN(LLL_LooseQ3, hasLLL_LooseQ3, bool); //! has L-L-L tripletD with loose Q3 limit +DECLARE_SOA_COLUMN(PPPHI_TightQ3, hasPPPHI_TightQ3, bool); //! has P-P-PHI triplet with tight Q3 limit +DECLARE_SOA_COLUMN(PPPHI_LooseQ3, hasPPPHI_LooseQ3, bool); //! has P-P-PHI triplet with loose Q3 limit +DECLARE_SOA_COLUMN(PPRHO_TightQ3, hasPPRHO_TightQ3, bool); //! has P-P-RHO triplet with tight Q3 limit +DECLARE_SOA_COLUMN(PPRHO_LooseQ3, hasPPRHO_highQ3, bool); //! has P-P-RHO triplet with loose Q3 limit // jets DECLARE_SOA_COLUMN(JetChLowPt, hasJetChLowPt, bool); //! low-pT charged jet @@ -143,10 +167,14 @@ DECLARE_SOA_COLUMN(TrackedXi, hasTrackedXi, bool); //! at least 1 DECLARE_SOA_COLUMN(TrackedOmega, hasTrackedOmega, bool); //! at least 1 tracked Omega DECLARE_SOA_COLUMN(Tracked3Body, hasTracked3Body, bool); //! at least 1 tracked 3Body DECLARE_SOA_COLUMN(OmegaHighMult, hasOmegaHighMult, bool); //! at least 1 Omega + high-mult event +DECLARE_SOA_COLUMN(LambdaLambda, lambdaLambda, bool); //! at least 2 lambda satisfying selection // F1-proton DECLARE_SOA_COLUMN(TriggerEventF1Proton, triggereventf1proton, bool); //! F1 - proton femto trigger event +// Double Phi +DECLARE_SOA_COLUMN(TriggerEventDoublePhi, triggereventdoublephi, bool); //! Double Phi trigger event + // multiplicity DECLARE_SOA_COLUMN(HighTrackMult, hasHighTrackMult, bool); //! high trk muliplicity DECLARE_SOA_COLUMN(HighMultFv0, hasHighMultFv0, bool); //! high FV0 muliplicity @@ -166,6 +194,19 @@ DECLARE_SOA_COLUMN(PCMHighPtPhoton, hasPCMHighPtPhoton, bool); //! PCM high pT p // DECLARE_SOA_COLUMN(PCMEtaDalitz, hasPCMEtaDalitz, bool); //! PCM eta -> ee gamma // DECLARE_SOA_COLUMN(PCMEtaGG, hasPCMEtaGG, bool); //! PCM eta -> ee gamma DECLARE_SOA_COLUMN(PCMandEE, hasPCMandEE, bool); //! PCM and ee + +// heavy meson filters +// DECLARE_SOA_COLUMN(PCMOmegaMeson, hasPCMOmegaMeson, bool); //! Omega meson candidate (3pi) in the collision +// DECLARE_SOA_COLUMN(EMCOmegaMeson, hasEMCOmegaMeson, bool); //! Omega meson candidate (3pi) in the collision +// DECLARE_SOA_COLUMN(PCMEtaPrimeMeson, hasPCMEtaPrimeMeson, bool); //! Eta' meson candidate (3pi) in the collision +// DECLARE_SOA_COLUMN(EMCEtaPrimeMeson, hasEMCEtaPrimeMeson, bool); //! Eta' meson candidate (3pi) in the collision +DECLARE_SOA_COLUMN(OmegaP, hasOmegaP, bool); //! omegaP meson candidate (3pi) in the collision +DECLARE_SOA_COLUMN(OmegaPP, hasOmegaPP, bool); //! omegaPP meson candidate (3pi) in the collision +DECLARE_SOA_COLUMN(Omegad, hasOmegad, bool); //! omegad meson candidate (3pi) in the collision +DECLARE_SOA_COLUMN(EtaPrimeP, hasEtaPrimeP, bool); //! eta'P meson candidate (3pi) in the collision +DECLARE_SOA_COLUMN(EtaPrimePP, hasEtaPrimePP, bool); //! eta'PP meson candidate (3pi) in the collision +DECLARE_SOA_COLUMN(EtaPrimed, hasEtaPrimed, bool); //! eta'd meson candidate (3pi) in the collision + } // namespace filtering namespace decision @@ -192,7 +233,7 @@ DECLARE_SOA_COLUMN(BCend, hasBCend, uint64_t); //! CEFP bcrange // nuclei DECLARE_SOA_TABLE(NucleiFilters, "AOD", "NucleiFilters", //! - filtering::H2, filtering::He, filtering::H3L3Body, filtering::ITSmildIonisation, + filtering::H2, filtering::He, filtering::HeV0, filtering::TritonFemto, filtering::H3L3Body, filtering::Tracked3Body, filtering::ITSmildIonisation, filtering::ITSextremeIonisation); using NucleiFilter = NucleiFilters::iterator; @@ -207,7 +248,7 @@ using DiffractionBCFilter = DiffractionBCFilters::iterator; // Dileptons & Quarkonia DECLARE_SOA_TABLE(DqFilters, "AOD", "DqFilters", //! - filtering::SingleE, filtering::LMeeIMR, filtering::LMeeHMR, filtering::DiElectron, filtering::SingleMuLow, filtering::SingleMuHigh, filtering::DiMuon); + filtering::SingleE, filtering::LMeeIMR, filtering::LMeeHMR, filtering::DiElectron, filtering::SingleMuLow, filtering::SingleMuHigh, filtering::DiMuon, filtering::ElectronMuon); using DqFilter = DqFilters::iterator; // heavy flavours @@ -231,12 +272,29 @@ DECLARE_SOA_TABLE(HfFilters, "AOD", "HfFilters", //! filtering::HfSingleCharm2P, filtering::HfSingleCharm3P, filtering::HfSingleNonPromptCharm2P, - filtering::HfSingleNonPromptCharm3P); + filtering::HfSingleNonPromptCharm3P, + filtering::HfCharmBarToXi2Bach, + filtering::HfPrCharm2P, + filtering::HfBtoJPsiKa, + filtering::HfBtoJPsiKstar, + filtering::HfBtoJPsiPhi, + filtering::HfBtoJPsiPrKa, + filtering::HfBtoJPsiPi); using HfFilter = HfFilters::iterator; DECLARE_SOA_TABLE(CFFilters, "AOD", "CFFilters", //! - filtering::PPP, filtering::PPL, filtering::PLL, filtering::LLL, filtering::PPPHI, filtering::PD, filtering::LD); + filtering::PPP_TightQ3, filtering::PPP_LooseQ3, + filtering::PPL_TightQ3, filtering::PPL_LooseQ3, + filtering::PLL_TightQ3, filtering::PLL_LooseQ3, + filtering::LLL_TightQ3, filtering::LLL_LooseQ3, + filtering::PPPHI_TightQ3, filtering::PPPHI_LooseQ3, + filtering::PPRHO_TightQ3, filtering::PPRHO_LooseQ3, + filtering::PD_TightKstar, filtering::PD_LooseKstar, + filtering::LD_TightKstar, filtering::LD_LooseKstar, + filtering::PHID_TightKstar, filtering::PHID_LooseKstar, + filtering::RHOD_TightKstar, filtering::RHOD_LooseKstar); + using CfFilter = CFFilters::iterator; // jets @@ -263,7 +321,7 @@ using FullJetFilter = FullJetFilters::iterator; // strangeness (lf) DECLARE_SOA_TABLE(StrangenessFilters, "AOD", "LFStrgFilters", //! - filtering::Omega, filtering::hadronOmega, filtering::DoubleXi, filtering::TripleXi, filtering::QuadrupleXi, filtering::SingleXiYN, filtering::OmegaLargeRadius, filtering::TrackedXi, filtering::TrackedOmega, filtering::OmegaHighMult, filtering::DoubleOmega, filtering::OmegaXi); + filtering::Omega, filtering::hadronOmega, filtering::DoubleXi, filtering::TripleXi, filtering::QuadrupleXi, filtering::SingleXiYN, filtering::OmegaLargeRadius, filtering::TrackedXi, filtering::TrackedOmega, filtering::OmegaHighMult, filtering::DoubleOmega, filtering::OmegaXi, filtering::LambdaLambda); using StrangenessFilter = StrangenessFilters::iterator; @@ -272,6 +330,11 @@ DECLARE_SOA_TABLE(F1ProtonFilters, "AOD", "F1ProtonFilters", //! filtering::TriggerEventF1Proton); using F1ProtonFilter = F1ProtonFilters::iterator; +// Double Phi +DECLARE_SOA_TABLE(DoublePhiFilters, "AOD", "LF2PhiFilters", //! + filtering::TriggerEventDoublePhi); +using DoublePhiFilter = DoublePhiFilters::iterator; + // multiplicity DECLARE_SOA_TABLE(MultFilters, "AOD", "MultFilters", //! filtering::HighTrackMult, filtering::HighMultFv0, filtering::HighFt0Mult, filtering::HighFt0Flat, filtering::HighFt0cFv0Mult, filtering::HighFt0cFv0Flat, filtering::LeadingPtTrack); @@ -284,6 +347,13 @@ DECLARE_SOA_TABLE(PhotonFilters, "AOD", "PhotonFilters", //! using PhotonFilter = PhotonFilters::iterator; +// heavy mesons +DECLARE_SOA_TABLE(HeavyNeutralMesonFilters, "AOD", "HNMesonFilters", //! + filtering::OmegaP, filtering::OmegaPP, filtering::Omegad, + filtering::EtaPrimeP, filtering::EtaPrimePP, filtering::EtaPrimed); + +using HeavyNeutralMesonFilter = HeavyNeutralMesonFilters::iterator; + // cefp decision DECLARE_SOA_TABLE(CefpDecisions, "AOD", "CefpDecision", //! decision::BCId, decision::GlobalBCId, decision::EvSelBC, decision::CollisionTime, decision::CollisionTimeRes, decision::CefpTriggered0, decision::CefpTriggered1, decision::CefpSelected0, decision::CefpSelected1); @@ -295,11 +365,11 @@ DECLARE_SOA_TABLE(BCRanges, "AOD", "BCRanges", //! using BCRange = BCRanges::iterator; /// List of the available filters, the description of their tables and the name of the tasks -constexpr int NumberOfFilters{12}; -constexpr std::array AvailableFilters{"NucleiFilters", "DiffractionFilters", "DqFilters", "HfFilters", "CFFilters", "JetFilters", "JetHFFilters", "FullJetFilters", "StrangenessFilters", "MultFilters", "PhotonFilters", "F1ProtonFilters"}; -constexpr std::array FilterDescriptions{"NucleiFilters", "DiffFilters", "DqFilters", "HfFilters", "CFFilters", "JetFilters", "JetHFFilters", "FullJetFilters", "LFStrgFilters", "MultFilters", "PhotonFilters", "F1ProtonFilters"}; -constexpr std::array FilteringTaskNames{"o2-analysis-nuclei-filter", "o2-analysis-diffraction-filter", "o2-analysis-dq-filter-pp-with-association", "o2-analysis-hf-filter", "o2-analysis-cf-filter", "o2-analysis-je-filter", "o2-analysis-je-hf-filter", "o2-analysis-fje-filter", "o2-analysis-lf-strangeness-filter", "o2-analysis-mult-filter", "o2-analysis-em-photon-filter", "o2-analysis-lf-f1proton-filter"}; -constexpr o2::framework::pack FiltersPack; +constexpr int NumberOfFilters{14}; +constexpr std::array AvailableFilters{"NucleiFilters", "DiffractionFilters", "DqFilters", "HfFilters", "CFFilters", "JetFilters", "JetHFFilters", "FullJetFilters", "StrangenessFilters", "MultFilters", "PhotonFilters", "F1ProtonFilters", "DoublePhiFilters", "HeavyNeutralMesonFilters"}; +constexpr std::array FilterDescriptions{"NucleiFilters", "DiffFilters", "DqFilters", "HfFilters", "CFFilters", "JetFilters", "JetHFFilters", "FullJetFilters", "LFStrgFilters", "MultFilters", "PhotonFilters", "F1ProtonFilters", "LF2PhiFilters", "HNMesonFilters"}; +constexpr std::array FilteringTaskNames{"o2-analysis-nuclei-filter", "o2-analysis-diffraction-filter", "o2-analysis-dq-filter-pp-with-association", "o2-analysis-hf-filter", "o2-analysis-cf-filter", "o2-analysis-je-filter", "o2-analysis-je-hf-filter", "o2-analysis-fje-filter", "o2-analysis-lf-strangeness-filter", "o2-analysis-mult-filter", "o2-analysis-em-photon-filter", "o2-analysis-lf-f1proton-filter", "o2-analysis-lf-doublephi-filter", "o2-analysis-heavy-neutral-meson-filter"}; +constexpr o2::framework::pack FiltersPack; static_assert(o2::framework::pack_size(FiltersPack) == NumberOfFilters); template diff --git a/EventFiltering/macros/getMenu.C b/EventFiltering/macros/getMenu.C new file mode 100644 index 00000000000..692ebe396f3 --- /dev/null +++ b/EventFiltering/macros/getMenu.C @@ -0,0 +1,31 @@ +// 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. + +#include "CCDB/BasicCCDBManager.h" + +#include +#include + +#include + +void getMenu(int runNumber, std::string baseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/Chunked/") +{ + auto& ccdb = o2::ccdb::BasicCCDBManager::instance(); + TH1* counters = ccdb.getForRun(baseCCDBPath + "FilterCounters", runNumber); + TAxis* axis = counters->GetXaxis(); + + std::vector binLabels(axis->GetNbins() - 2); // skip first and last bins + std::cout << "Menu for run " << runNumber << ":\n"; + for (int i = 2; i < axis->GetNbins(); ++i) { + binLabels[i - 1] = axis->GetBinLabel(i); + std::cout << "Id " << i - 2 << ": " << axis->GetBinLabel(i) << "\n"; + } +} diff --git a/EventFiltering/macros/uploadOTSobjects.C b/EventFiltering/macros/uploadOTSobjects.C index 77b6ac97f34..8e4c6c27136 100644 --- a/EventFiltering/macros/uploadOTSobjects.C +++ b/EventFiltering/macros/uploadOTSobjects.C @@ -64,10 +64,17 @@ void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien std::unique_ptr scalersFile{TFile::Open((path + "/AnalysisResults_fullrun.root").data(), "READ")}; TH1* scalers = static_cast(scalersFile->Get("central-event-filter-task/scalers/mScalers")); TH1* filters = static_cast(scalersFile->Get("central-event-filter-task/scalers/mFiltered")); - api.storeAsTFile(scalers, baseCCDBpath + "FilterCounters", metadata, duration.first, duration.second); - api.storeAsTFile(filters, baseCCDBpath + "SelectionCounters", metadata, duration.first, duration.second); + api.storeAsTFile(scalers, baseCCDBpath + "FilterCounters", metadata, duration.first, duration.second + 1); + api.storeAsTFile(filters, baseCCDBpath + "SelectionCounters", metadata, duration.first, duration.second + 1); TH1* hCounterTVX = static_cast(scalersFile->Get("bc-selection-task/hCounterTVX")); - api.storeAsTFile(hCounterTVX, baseCCDBpath + "InspectedTVX", metadata, duration.first, duration.second); + if (!hCounterTVX) { + hCounterTVX = static_cast(scalersFile->Get("lumi-task/hCounterTVX")); + if (!hCounterTVX) { + std::cout << "No hCounterTVX histogram found in the file, skipping upload for run " << runString << std::endl; + continue; + } + } + api.storeAsTFile(hCounterTVX, baseCCDBpath + "InspectedTVX", metadata, duration.first, duration.second + 1); std::vector zorroHelpers; std::unique_ptr bcRangesFile{TFile::Open((path + "/bcRanges_fullrun.root").data(), "READ")}; @@ -99,7 +106,7 @@ void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien return a.bcAOD < b.bcAOD; }); if (!chunkedProcessing) { - api.storeAsTFileAny(&zorroHelpers, baseCCDBpath + "ZorroHelpers", metadata, duration.first, duration.second); + api.storeAsTFileAny(&zorroHelpers, baseCCDBpath + "ZorroHelpers", metadata, duration.first, duration.second + 1); std::cout << std::endl; } else { uint32_t helperIndex{0}; @@ -126,7 +133,7 @@ void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien endIndex++; } std::cout << ">>> Chunk " << helperIndex << " - " << helperIndex + chunk.size() << " : " << startTS << " - " << endTS << " \t" << (endTS - startTS) * 1.e-3 << std::endl; - api.storeAsTFileAny(&chunk, baseCCDBpath + "ZorroHelpers", metadata, startTS, endTS); + api.storeAsTFileAny(&chunk, baseCCDBpath + "ZorroHelpers", metadata, startTS, endTS + 1); startTS = endTS + 1; helperIndex += chunk.size(); } diff --git a/PWGCF/CMakeLists.txt b/PWGCF/CMakeLists.txt index 7432d5c21b1..84f1b6c6d41 100644 --- a/PWGCF/CMakeLists.txt +++ b/PWGCF/CMakeLists.txt @@ -24,3 +24,4 @@ add_subdirectory(TwoParticleCorrelations) add_subdirectory(JCorran) add_subdirectory(Femto3D) add_subdirectory(EbyEFluctuations) +add_subdirectory(Femto) diff --git a/PWGCF/Core/CorrelationContainer.cxx b/PWGCF/Core/CorrelationContainer.cxx index a910cf2d1b9..1421288bd18 100644 --- a/PWGCF/Core/CorrelationContainer.cxx +++ b/PWGCF/Core/CorrelationContainer.cxx @@ -115,7 +115,7 @@ CorrelationContainer::CorrelationContainer(const char* name, const char* objTitl triggerAxis.insert(triggerAxis.end(), userAxis.begin(), userAxis.end()); mTriggerHist = HistFactory::createHist({"mTriggerHist", "d^{2}N_{ch}/d#varphid#eta", {HistType::kStepTHnF, triggerAxis, fgkCFSteps}}).release(); - mTrackHistEfficiency = HistFactory::createHist({"mTrackHistEfficiency", "Tracking efficiency", {HistType::kStepTHnD, {efficiencyAxis[0], efficiencyAxis[1], {4, -0.5, 3.5, "species"}, correlationAxis[3], efficiencyAxis[2]}, fgkCFSteps}}).release(); + mTrackHistEfficiency = HistFactory::createHist({"mTrackHistEfficiency", "Tracking efficiency", {HistType::kStepTHnD, {efficiencyAxis[0], efficiencyAxis[1], {5, -0.5, 4.5, "species"}, correlationAxis[3], efficiencyAxis[2]}, fgkCFSteps}}).release(); mEventCount = HistFactory::createHist({"mEventCount", ";step;centrality;count", {HistType::kTH2F, {{fgkCFSteps + 2, -2.5, -0.5 + fgkCFSteps, "step"}, correlationAxis[3]}}}).release(); } @@ -309,7 +309,7 @@ void CorrelationContainer::resetBinLimits(THnBase* grid, int max_dimension) for (Int_t i = 0; i < max_dimension; i++) { if (grid->GetAxis(i)->TestBit(TAxis::kAxisRange)) { - grid->GetAxis(i)->SetRangeUser(0, -1); + grid->GetAxis(i)->SetRange(0, 0); // reset range } } } @@ -681,8 +681,11 @@ TH2* CorrelationContainer::getSumOfRatios(CorrelationContainer* mixed, Correlati Double_t sums[] = {0, 0, 0}; Double_t errors[] = {0, 0, 0}; + Int_t checkBinYBegin = 1; // tracksSame->GetXaxis()->FindBin(-0.79); + Int_t checkBinYEnd = tracksSame->GetNbinsY(); // tracksSame->GetXaxis()->FindBin(0.79); + for (Int_t x = 1; x <= tracksSame->GetNbinsX(); x++) { - for (Int_t y = 1; y <= tracksSame->GetNbinsY(); y++) { + for (Int_t y = checkBinYBegin; y <= checkBinYEnd; y++) { sums[0] += tracksSame->GetBinContent(x, y); errors[0] += tracksSame->GetBinError(x, y); sums[1] += tracksMixed->GetBinContent(x, y); @@ -693,7 +696,7 @@ TH2* CorrelationContainer::getSumOfRatios(CorrelationContainer* mixed, Correlati tracksSame->Divide(tracksMixed); for (Int_t x = 1; x <= tracksSame->GetNbinsX(); x++) { - for (Int_t y = 1; y <= tracksSame->GetNbinsY(); y++) { + for (Int_t y = checkBinYBegin; y <= checkBinYEnd; y++) { sums[2] += tracksSame->GetBinContent(x, y); errors[2] += tracksSame->GetBinError(x, y); } diff --git a/PWGCF/DataModel/CorrelationsDerived.h b/PWGCF/DataModel/CorrelationsDerived.h index d690518012a..62bcf8716bc 100644 --- a/PWGCF/DataModel/CorrelationsDerived.h +++ b/PWGCF/DataModel/CorrelationsDerived.h @@ -11,9 +11,12 @@ #ifndef PWGCF_DATAMODEL_CORRELATIONSDERIVED_H_ #define PWGCF_DATAMODEL_CORRELATIONSDERIVED_H_ +#include "Common/DataModel/Centrality.h" + #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" -#include "Common/DataModel/Centrality.h" + +#include namespace o2::aod { @@ -83,6 +86,8 @@ using CFTrackWithLabel = CFTracksWithLabel::iterator; //------transient CF-filter to CF-2prong-filter DECLARE_SOA_TABLE(CFCollRefs, "AOD", "CFCOLLREF", o2::soa::Index<>, track::CollisionId); //! Transient cf collision index table +// Reco + using CFCollRef = CFCollRefs::iterator; namespace cftrackref @@ -92,6 +97,16 @@ DECLARE_SOA_INDEX_COLUMN(Track, track); DECLARE_SOA_TABLE(CFTrackRefs, "AOD", "CFTRACKREF", o2::soa::Index<>, track::CollisionId, cftrackref::TrackId); //! Transient cf track index table using CFTrackRef = CFTrackRefs::iterator; + +// MC + +namespace cfmcparticleref +{ +DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); +} // namespace cfmcparticleref +DECLARE_SOA_TABLE(CFMcParticleRefs, "AOD", "CFMCPARTICLEREF", o2::soa::Index<>, mcparticle::McCollisionId, cfmcparticleref::McParticleId); //! Transient cf track index table + +using CFMcParticleRef = CFMcParticleRefs::iterator; //------ namespace cf2prongtrack @@ -107,7 +122,12 @@ enum ParticleDecay { D0ToPiK, D0barToKPi, JPsiToEE, - JPsiToMuMu + JPsiToMuMu, + Generic2Prong, + PhiToKK, + K0stoPiPi, + LambdatoPPi, + AntiLambdatoPiP }; } // namespace cf2prongtrack DECLARE_SOA_TABLE(CF2ProngTracks, "AOD", "CF2PRONGTRACK", //! Reduced track table @@ -117,6 +137,38 @@ DECLARE_SOA_TABLE(CF2ProngTracks, "AOD", "CF2PRONGTRACK", //! Reduced track tabl cf2prongtrack::CFTrackProng1Id, cf2prongtrack::Pt, cf2prongtrack::Eta, cf2prongtrack::Phi, cf2prongtrack::InvMass, cf2prongtrack::Decay); using CF2ProngTrack = CF2ProngTracks::iterator; +//------ + +namespace cf2prongtrackml +{ +DECLARE_SOA_COLUMN(MlProbD0, mlProbD0, std::vector); //! +DECLARE_SOA_COLUMN(MlProbD0bar, mlProbD0bar, std::vector); //! +} // namespace cf2prongtrackml +DECLARE_SOA_TABLE(CF2ProngTrackmls, "AOD", "CF2PRONGTRACKML", //! Reduced track table + o2::soa::Index<>, + cftrack::CFCollisionId, + cf2prongtrackml::MlProbD0, cf2prongtrackml::MlProbD0bar); +using CF2ProngTrackml = CF2ProngTrackmls::iterator; +//------ + +namespace cf2prongmcpart +{ +DECLARE_SOA_INDEX_COLUMN_FULL(CFParticleDaugh0, cfParticleDaugh0, int, CFMcParticles, "_0"); //! Index to prong 1 CFMcParticle +DECLARE_SOA_INDEX_COLUMN_FULL(CFParticleDaugh1, cfParticleDaugh1, int, CFMcParticles, "_1"); //! Index to prong 2 CFMcParticle +DECLARE_SOA_COLUMN(Decay, decay, uint8_t); //! Particle decay and flags +DECLARE_SOA_DYNAMIC_COLUMN(McDecay, mcDecay, [](uint8_t decay) -> uint8_t { return decay & 0x7f; }); //! MC particle decay +enum ParticleDecayFlags { + Prompt = 0x80 +}; +} // namespace cf2prongmcpart +DECLARE_SOA_TABLE(CF2ProngMcParts, "AOD", "CF2PRONGMCPART", //! Table for the daughter particles of a 2-prong particle, to be joined with CFMcParticles + o2::soa::Index<>, + cf2prongmcpart::CFParticleDaugh0Id, + cf2prongmcpart::CFParticleDaugh1Id, + cf2prongmcpart::Decay, + cf2prongmcpart::McDecay) +using CF2ProngMcPart = CF2ProngMcParts::iterator; + } // namespace o2::aod #endif // PWGCF_DATAMODEL_CORRELATIONSDERIVED_H_ diff --git a/PWGCF/DataModel/FemtoDerived.h b/PWGCF/DataModel/FemtoDerived.h index 3e6ca985c1f..4caf0166303 100644 --- a/PWGCF/DataModel/FemtoDerived.h +++ b/PWGCF/DataModel/FemtoDerived.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -90,10 +90,12 @@ namespace femtodreamparticle { /// Distinuishes the different particle types enum ParticleType { - kTrack, //! Track - kV0, //! V0 - kV0Child, //! Child track of a V0 - kCascade, //! Cascade + kTrack, //! Track + kV0, //! V0 + kV0Child, //! Child track of a V0 + kCascade, //! Cascade + kCascadeV0, + kCascadeV0Child, kCascadeBachelor, //! Bachelor track of a cascade kCharmHadron, //! Bachelor track of a cascade kNParticleTypes //! Number of particle types @@ -105,19 +107,20 @@ enum MomentumType { kPtpc //! momentum at the inner wall of the TPC (useful for PID plots) }; -static constexpr std::string_view ParticleTypeName[kNParticleTypes] = {"Tracks", "V0", "V0Child", "Cascade", "CascadeBachelor", "CharmHadron"}; //! Naming of the different particle types -static constexpr std::string_view TempFitVarName[kNParticleTypes] = {"/hDCAxy", "/hCPA", "/hDCAxy", "/hCPA", "/hDCAxy", "/hCPA"}; +static constexpr std::string_view ParticleTypeName[kNParticleTypes] = {"Tracks", "V0", "V0Child", "Cascade", "CascadeV0", "CascadeV0Child", "CascadeBachelor", "CharmHadron"}; //! Naming of the different particle types +static constexpr std::string_view TempFitVarName[kNParticleTypes] = {"/hDCAxy", "/hCPA", "/hDCAxy", "/hCPA", "/hCPA", "/hDCAxy", "/hDCAxy", "/hCPA"}; using cutContainerType = uint32_t; //! Definition of the data type for the bit-wise container for the different selection criteria enum TrackType { - kNoChild, //! Not a V0 child + kNoChild, //! Not any child kPosChild, //! Positive V0 child kNegChild, //! Negative V0 child + kBachelor, //! Bachelor Cascade child kNTrackTypes //! Number of child types }; -static constexpr std::string_view TrackTypeName[kNTrackTypes] = {"Trk", "Pos", "Neg"}; //! Naming of the different particle types +static constexpr std::string_view TrackTypeName[kNTrackTypes] = {"Trk", "Pos", "Neg", "Bach"}; //! Naming of the different particle types DECLARE_SOA_INDEX_COLUMN(FDCollision, fdCollision); DECLARE_SOA_COLUMN(Pt, pt, float); //! p_T (GeV/c) @@ -137,11 +140,11 @@ DECLARE_SOA_DYNAMIC_COLUMN(Theta, theta, //! Compute the theta of the track }); DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! Compute the momentum in x in GeV/c [](float pt, float phi) -> float { - return pt * std::sin(phi); + return pt * std::cos(phi); }); DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! Compute the momentum in y in GeV/c [](float pt, float phi) -> float { - return pt * std::cos(phi); + return pt * std::sin(phi); }); DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //! Compute the momentum in z in GeV/c [](float pt, float eta) -> float { @@ -175,12 +178,28 @@ DECLARE_SOA_COLUMN(TOFNSigmaPr, tofNSigmaPr, float); //! Nsigma separation with DECLARE_SOA_COLUMN(TOFNSigmaDe, tofNSigmaDe, float); //! Nsigma separation with the TOF detector for deuteron DECLARE_SOA_COLUMN(TOFNSigmaTr, tofNSigmaTr, float); //! Nsigma separation with the TOF detector for triton DECLARE_SOA_COLUMN(TOFNSigmaHe, tofNSigmaHe, float); //! Nsigma separation with the TOF detector for helium3 +DECLARE_SOA_COLUMN(ITSSignal, itsSignal, float); +DECLARE_SOA_COLUMN(ITSNSigmaEl, itsNSigmaEl, float); //! Nsigma separation with the Its detector for electron +DECLARE_SOA_COLUMN(ITSNSigmaPi, itsNSigmaPi, float); //! Nsigma separation with the Its detector for pion +DECLARE_SOA_COLUMN(ITSNSigmaKa, itsNSigmaKa, float); //! Nsigma separation with the Its detector for kaon +DECLARE_SOA_COLUMN(ITSNSigmaPr, itsNSigmaPr, float); //! Nsigma separation with the Its detector for proton +DECLARE_SOA_COLUMN(ITSNSigmaDe, itsNSigmaDe, float); //! Nsigma separation with the Its detector for deuteron +DECLARE_SOA_COLUMN(ITSNSigmaTr, itsNSigmaTr, float); //! Nsigma separation with the Its detector for triton +DECLARE_SOA_COLUMN(ITSNSigmaHe, itsNSigmaHe, float); //! Nsigma separation with the Its detector for helium3 DECLARE_SOA_COLUMN(DaughDCA, daughDCA, float); //! DCA between daughters DECLARE_SOA_COLUMN(TransRadius, transRadius, float); //! Transverse radius of the decay vertex DECLARE_SOA_COLUMN(DecayVtxX, decayVtxX, float); //! X position of the decay vertex DECLARE_SOA_COLUMN(DecayVtxY, decayVtxY, float); //! Y position of the decay vertex DECLARE_SOA_COLUMN(DecayVtxZ, decayVtxZ, float); //! Z position of the decay vertex DECLARE_SOA_COLUMN(MKaon, mKaon, float); //! The invariant mass of V0 candidate, assuming kaon +// Here the cascade specific collums +DECLARE_SOA_COLUMN(CascV0DCAtoPV, cascV0DCAtoPV, float); //! DCA of the daughter V0 to the primar vertex +DECLARE_SOA_COLUMN(CascDaughDCA, cascDaughDCA, float); //! DCA between daughters +DECLARE_SOA_COLUMN(CascTransRadius, cascTransRadius, float); //! Transverse radius of the decay vertex of the cascade +DECLARE_SOA_COLUMN(CascDecayVtxX, cascDecayVtxX, float); //! X position of the decay vertex of the cascade +DECLARE_SOA_COLUMN(CascDecayVtxY, cascDecayVtxY, float); //! Y position of the decay vertex of the cascade +DECLARE_SOA_COLUMN(CascDecayVtxZ, cascDecayVtxZ, float); //! Z position of the decay vertex of the cascade +DECLARE_SOA_COLUMN(MOmega, mOmega, float); //! The invariant mass of Cascade candidate, assuming Omega } // namespace femtodreamparticle namespace fdhf @@ -191,7 +210,9 @@ enum CharmHadronMassHypo { lcToPKPi = 1, lcToPiKP = 2 }; - +DECLARE_SOA_COLUMN(GIndexCol, gIndexCol, int); //! Global index for the collision +DECLARE_SOA_COLUMN(TimeStamp, timeStamp, int64_t); //! Timestamp for the collision +DECLARE_SOA_COLUMN(VertexZ, vertexZ, float); //! VertexZ for the collision DECLARE_SOA_COLUMN(TrackId, trackId, int); //! track id to match associate particle with charm hadron prongs DECLARE_SOA_COLUMN(Charge, charge, int8_t); //! Charge of charm hadron DECLARE_SOA_COLUMN(Prong0Id, prong0Id, int); //! Track id of charm hadron prong0 @@ -214,12 +235,16 @@ DECLARE_SOA_COLUMN(FlagMc, flagMc, int8_t); //! To selec DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! flag for reconstruction level matching (1 for prompt, 2 for non-prompt) DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! flag for generator level matching (1 for prompt, 2 for non-prompt) DECLARE_SOA_COLUMN(IsCandidateSwapped, isCandidateSwapped, int8_t); //! swapping of the prongs order (0 for Lc -> pkpi, 1 for Lc -> pikp) -DECLARE_SOA_COLUMN(PtAssoc, ptAssoc, float); //! Transverse momentum of associate femto particle +DECLARE_SOA_COLUMN(TrkPt, trkPt, float); //! Transverse momentum of associate femto particle +DECLARE_SOA_COLUMN(TrkEta, trkEta, float); //! Eta of associate femto particle +DECLARE_SOA_COLUMN(TrkPhi, trkPhi, float); //! Phi of associate femto particle DECLARE_SOA_COLUMN(Kstar, kstar, float); //! Relative momentum in particles pair frame DECLARE_SOA_COLUMN(KT, kT, float); //! kT distribution of particle pairs DECLARE_SOA_COLUMN(MT, mT, float); //! Transverse mass distribution DECLARE_SOA_COLUMN(CharmM, charmM, float); //! Charm hadron mass DECLARE_SOA_COLUMN(CharmPt, charmPt, float); //! Transverse momentum of charm hadron for result task +DECLARE_SOA_COLUMN(CharmEta, charmEta, float); //! Eta of charm hadron for result task +DECLARE_SOA_COLUMN(CharmPhi, charmPhi, float); //! Phi of charm hadron for result task DECLARE_SOA_COLUMN(Mult, mult, int); //! Charge particle multiplicity DECLARE_SOA_COLUMN(MultPercentile, multPercentile, float); //! Multiplicity precentile DECLARE_SOA_COLUMN(PairSign, pairSign, int8_t); //! Selection between like sign (1) and unlike sign pair (2) @@ -262,6 +287,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, DECLARE_SOA_TABLE(FDHfCand, "AOD", "FDHFCAND", //! Table to store the derived data for charm hadron candidates o2::soa::Index<>, femtodreamparticle::FDCollisionId, + fdhf::TimeStamp, fdhf::Charge, fdhf::Prong0Id, fdhf::Prong1Id, @@ -286,24 +312,39 @@ DECLARE_SOA_TABLE(FDHfCand, "AOD", "FDHFCAND", //! Table to store the derived da fdhf::Phi, fdhf::Pt); -DECLARE_SOA_TABLE(FDResultsHF, "AOD", "FDRESULTSHF", //! table to store results for HF femtoscopy +DECLARE_SOA_TABLE(FDHfCharm, "AOD", "FDHFCHARM", //! table to store results for HF femtoscopy + fdhf::GIndexCol, + fdhf::TimeStamp, fdhf::CharmM, fdhf::CharmPt, - fdhf::PtAssoc, + fdhf::CharmEta, + fdhf::CharmPhi, + fdhf::Charge, fdhf::BDTBkg, fdhf::BDTPrompt, fdhf::BDTFD, - fdhf::Kstar, - fdhf::KT, - fdhf::MT, - fdhf::Mult, - fdhf::MultPercentile, - fdhf::Charge, - fdhf::PairSign, - fdhf::ProcessType, fdhf::FlagMc, fdhf::OriginMcRec); +DECLARE_SOA_TABLE(FDHfTrk, "AOD", "FDHFTRK", //! table to store results for HF femtoscopy + fdhf::GIndexCol, + fdhf::TimeStamp, + fdhf::TrkPt, + fdhf::TrkEta, + fdhf::TrkPhi, + femtodreamparticle::Sign, + femtodreamparticle::TPCNClsFound, + track::TPCNClsFindable, + femtodreamparticle::TPCNClsCrossedRows, + femtodreamparticle::TPCNSigmaPr, + femtodreamparticle::TOFNSigmaPr); + +DECLARE_SOA_TABLE(FDHfColl, "AOD", "FDHFCOLL", //! table to store results for HF femtoscopy + fdhf::GIndexCol, + fdhf::TimeStamp, + fdhf::VertexZ, + fdhf::Mult); + DECLARE_SOA_TABLE(FDHfCandMC, "AOD", "FDHFCANDMC", //! Table for reconstructed MC charm hadron candidates o2::soa::Index<>, fdhf::FlagMc, @@ -359,12 +400,27 @@ DECLARE_SOA_TABLE_STAGED(FDExtParticles, "FDEXTPARTICLE", femtodreamparticle::TOFNSigmaDe, femtodreamparticle::TOFNSigmaTr, femtodreamparticle::TOFNSigmaHe, + femtodreamparticle::ITSSignal, + femtodreamparticle::ITSNSigmaEl, + femtodreamparticle::ITSNSigmaPi, + femtodreamparticle::ITSNSigmaKa, + femtodreamparticle::ITSNSigmaPr, + femtodreamparticle::ITSNSigmaDe, + femtodreamparticle::ITSNSigmaTr, + femtodreamparticle::ITSNSigmaHe, femtodreamparticle::DaughDCA, femtodreamparticle::TransRadius, femtodreamparticle::DecayVtxX, femtodreamparticle::DecayVtxY, femtodreamparticle::DecayVtxZ, femtodreamparticle::MKaon, + femtodreamparticle::CascV0DCAtoPV, + femtodreamparticle::CascDaughDCA, + femtodreamparticle::CascTransRadius, + femtodreamparticle::CascDecayVtxX, + femtodreamparticle::CascDecayVtxY, + femtodreamparticle::CascDecayVtxZ, + femtodreamparticle::MOmega, femtodreamparticle::TPCCrossedRowsOverFindableCls) using FDFullParticle = FDExtParticles::iterator; @@ -381,6 +437,9 @@ enum ParticleOriginMCTruth { kWrongCollision, //! particle, that was associated wrongly to the collision kSecondaryDaughterLambda, //! Daughter from a Lambda decay kSecondaryDaughterSigmaplus, //! Daughter from a Sigma^plus decay + kSecondaryDaughterSigma0, //! Daughter from a Sigma^0 decay + kSecondaryDaughterXiMinus, //! Daughter from a Xi^- decay + kSecondaryDaughterXi0, //! Daughter from a Xi^0 decay kElse, //! none of the above; (NOTE: used to catch bugs. will be removed once MC usage is properly validated) kNOriginMCTruthTypes }; @@ -457,3 +516,4 @@ using MixingHash = MixingHashes::iterator; } // namespace o2::aod #endif // PWGCF_DATAMODEL_FEMTODERIVED_H_ + // diff --git a/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt b/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt index d22d2af4dd7..14dc66b22f0 100644 --- a/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt +++ b/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt @@ -24,8 +24,18 @@ o2physics_add_dpl_workflow(netproton-cumulants PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(identified-meanpt-fluctuations - SOURCES IdentifiedMeanPtFluctuations.cxx +o2physics_add_dpl_workflow(netproton-cumulants-mc + SOURCES netprotonCumulantsMc.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(antiproton-cumulants-mc + SOURCES antiprotonCumulantsMc.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(event-mean-pt-id + SOURCES eventMeanPtId.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) @@ -43,3 +53,23 @@ o2physics_add_dpl_workflow(factorial-moments SOURCES FactorialMomentsTask.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(kaon-isospin-fluctuations + SOURCES kaonIsospinFluctuations.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(netcharge-fluctuations + SOURCES netchargeFluctuations.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(nch-cumulants-id + SOURCES nchCumulantsId.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(v0pt-had-pi-ka-prot + SOURCES v0ptHadPiKaProt.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore + COMPONENT_NAME Analysis) diff --git a/PWGCF/EbyEFluctuations/Tasks/IdentifiedMeanPtFluctuations.cxx b/PWGCF/EbyEFluctuations/Tasks/IdentifiedMeanPtFluctuations.cxx deleted file mode 100644 index 2217a2c1f4f..00000000000 --- a/PWGCF/EbyEFluctuations/Tasks/IdentifiedMeanPtFluctuations.cxx +++ /dev/null @@ -1,1173 +0,0 @@ -// 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 Sweta Singh (sweta.singh@cern.ch) - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/Core/trackUtilities.h" -#include "Common/CCDB/EventSelectionParams.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "CommonConstants/MathConstants.h" -#include "Common/DataModel/FT0Corrected.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/RunningWorkflowInfo.h" -#include "PWGCF/Core/CorrelationContainer.h" -#include "PWGCF/Core/PairCuts.h" -#include "TDatabasePDG.h" -#include -#include "Common/CCDB/TriggerAliases.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace std; - -namespace o2::aod -{ - -using MyCollisions = soa::Join; -using MyTracks = soa::Join; - -using MyMCRecoCollisions = soa::Join; - -using MyMCRecoTracks = soa::Join; - -using MyCollision = MyCollisions::iterator; -using MyTrack = MyTracks::iterator; -} // namespace o2::aod - -double massPi = TDatabasePDG::Instance()->GetParticle(211)->Mass(); -double massKa = TDatabasePDG::Instance()->GetParticle(321)->Mass(); -double massPr = TDatabasePDG::Instance()->GetParticle(2212)->Mass(); - -struct IdentifiedMeanPtFluctuations { - - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - Configurable piluprejection{"piluprejection", false, "Pileup rejection"}; - - void init(o2::framework::InitContext&) - { - AxisSpec vtxZAxis = {100, -20, 20, "Z (cm)"}; - AxisSpec dcaAxis = {1002, -5.01, 5.01, "DCA_{xy} (cm)"}; - AxisSpec dcazAxis = {1002, -5.01, 5.01, "DCA_{z} (cm)"}; - AxisSpec ptAxis = {400, 0.0, 4.0, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec pAxis = {400, 0.0, 4.0, "#it{p} (GeV/#it{c})"}; - AxisSpec betaAxis = {200, 0.0, 2.0, "TOF_{#beta} (GeV/#it{c})"}; - AxisSpec dEdxAxis = {2000, 0.0, 200.0, "dE/dx (GeV/#it{c})"}; - AxisSpec etaAxis = {100, -1.5, 1.5, "#eta"}; - AxisSpec nSigmaTPCAxis = {170, -8.5, 8.5, "n#sigma_{TPC}^{proton}"}; - AxisSpec nSigmaTPCAxispid = {170, -8.5, 8.5, "n#sigma_{TPC}"}; - AxisSpec nSigmaTOFAxispid = {170, -8.5, 8.5, "n#sigma_{TOF}"}; - // AxisSpec nChAxis = {2500, -0.5, 2499.5, "nCh"}; - AxisSpec centAxis = {100, 0., 100., "centrality"}; - AxisSpec subAxis = {30, 0., 30., "sample"}; - AxisSpec nchAxis = {4000, 0., 4000., "nch"}; - AxisSpec varAxis1 = {400, 0., 4., "var1"}; - AxisSpec varAxis2 = {400, 0., 4., "var2"}; - AxisSpec Chi2Axis = {100, 0., 100., "Chi2"}; - AxisSpec CrossedrowTPCAxis = {600, 0., 600., "TPC Crossed rows"}; - AxisSpec Counter = {10, 0., 10., "events"}; - - // QA Plots - histos.add("hEventCounter", "event counts", kTH1D, {Counter}); - - auto h = histos.add("tracksel", "tracksel", HistType::kTH1D, {{10, 0.5, 10.5}}); - h->GetXaxis()->SetBinLabel(1, "Tracks read"); - h->GetXaxis()->SetBinLabel(2, "Global track passed"); - h->GetXaxis()->SetBinLabel(3, "DCAxy passed"); - h->GetXaxis()->SetBinLabel(4, "DCAz passed"); - h->GetXaxis()->SetBinLabel(5, "Eta-cut passed"); - h->GetXaxis()->SetBinLabel(6, "pT-cut passed"); - h->GetXaxis()->SetBinLabel(7, "TPC crossed rows passed"); - h->GetXaxis()->SetBinLabel(8, "TPC Chai2cluster passed"); - h->GetXaxis()->SetBinLabel(9, "ITS Chai2cluster passed"); - - histos.add("hEventCounter_recMC", "event counts rec MC", kTH1D, {Counter}); - - auto h_rec = histos.add("tracksel_rec", "tracksel_rec", HistType::kTH1D, {{10, 0.5, 10.5}}); - h_rec->GetXaxis()->SetBinLabel(1, "has_mcCollision() read"); - h_rec->GetXaxis()->SetBinLabel(2, "Vertex Z > 10cm passed"); - h_rec->GetXaxis()->SetBinLabel(3, "sel 8 passed"); - h_rec->GetXaxis()->SetBinLabel(4, "kNoSameBunchPileup passed"); - h_rec->GetXaxis()->SetBinLabel(5, "kNoITSROFrameBorder passed"); - h_rec->GetXaxis()->SetBinLabel(6, "klsGoodZvtxFT0vsPV passed"); - h_rec->GetXaxis()->SetBinLabel(7, "klsVertexITSTPC passed"); - - histos.add("hZvtx_before_sel", "hZvtx_before_sel", kTH1D, {vtxZAxis}); - histos.add("hZvtx_after_sel", "hZvtx_after_sel", kTH1D, {vtxZAxis}); - histos.add("hZvtx_after_sel8", "hZvtx_after_sel8", kTH1D, {vtxZAxis}); - histos.add("hP", "hP", kTH1D, {pAxis}); - histos.add("hEta", ";hEta", kTH1D, {etaAxis}); - histos.add("hPt", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); - histos.add("hNsigmaTPC", "hNsigmaTPC", kTH2D, - {pAxis, nSigmaTPCAxis}); - histos.add("hDCAxy", "hDCAxy", kTH1D, {dcaAxis}); - histos.add("hDCAz", "hDCAz", kTH1D, {dcazAxis}); - - histos.add("hPtDCAxy", "hPtDCAxy", kTH2D, {ptAxis, dcaAxis}); - histos.add("hPtDCAz", "hPtDCAz", kTH2D, {ptAxis, dcazAxis}); - histos.add("NSigamaTPCpion", "NSigamaTPCpion", kTH2D, {ptAxis, nSigmaTPCAxispid}); - histos.add("NSigamaTPCkaon", "NSigamaTPCkaon", kTH2D, {ptAxis, nSigmaTPCAxispid}); - histos.add("NSigamaTPCproton", "NSigamaTPCproton", kTH2D, {ptAxis, nSigmaTPCAxispid}); - - histos.add("NSigamaTOFpion", "NSigamaTOFpion", kTH2D, {ptAxis, nSigmaTOFAxispid}); - histos.add("NSigamaTOFkaon", "NSigamaTOFkaon", kTH2D, {ptAxis, nSigmaTOFAxispid}); - histos.add("NSigamaTOFproton", "NSigamaTOFproton", kTH2D, {ptAxis, nSigmaTOFAxispid}); - - histos.add("NSigamaTPCpion_rec", "NSigamaTPCpion_rec", kTH2D, {pAxis, nSigmaTPCAxispid}); - histos.add("NSigamaTPCkaon_rec", "NSigamaTPCkaon_rec", kTH2D, {pAxis, nSigmaTPCAxispid}); - histos.add("NSigamaTPCproton_rec", "NSigamaTPCproton_rec", kTH2D, {pAxis, nSigmaTPCAxispid}); - - histos.add("NSigamaTOFpion_rec", "NSigamaTOFpion_rec", kTH2D, {pAxis, nSigmaTOFAxispid}); - histos.add("NSigamaTOFkaon_rec", "NSigamaTOFkaon_rec", kTH2D, {pAxis, nSigmaTOFAxispid}); - histos.add("NSigamaTOFproton_rec", "NSigamaTOFproton_rec", kTH2D, {pAxis, nSigmaTOFAxispid}); - - histos.add("NSigamaTPCTOFpion", "NSigamaTPCTOFpion", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); - histos.add("NSigamaTPCTOFkaon", "NSigamaTPCTOFkaon", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); - histos.add("NSigamaTPCTOFproton", "NSigamaTPCTOFproton", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); - - histos.add("NSigamaTPCTOFpion_rec", "NSigamaTPCTOFpion_rec", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); - histos.add("NSigamaTPCTOFkaon_rec", "NSigamaTPCTOFkaon_rec", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); - histos.add("NSigamaTPCTOFproton_rec", "NSigamaTPCTOFproton_rec", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); - - histos.add("NSigamaTPCpion_rec_bf_sel", "NSigamaTPCpion_rec_bf_sel", kTH2D, {pAxis, nSigmaTPCAxispid}); - histos.add("NSigamaTPCkaon_rec_bf_sel", "NSigamaTPCkaon_rec_bf_sel", kTH2D, {pAxis, nSigmaTPCAxispid}); - histos.add("NSigamaTPCproton_rec_bf_sel", "NSigamaTPCproton_rec_bf_sel", kTH2D, {pAxis, nSigmaTPCAxispid}); - - histos.add("NSigamaTOFpion_rec_bf_sel", "NSigamaTOFpion_rec_bf_sel", kTH2D, {pAxis, nSigmaTOFAxispid}); - histos.add("NSigamaTOFkaon_rec_bf_sel", "NSigamaTOFkaon_rec_bf_sel", kTH2D, {pAxis, nSigmaTOFAxispid}); - histos.add("NSigamaTOFproton_rec_bf_sel", "NSigamaTOFproton_rec_bf_sel", kTH2D, {pAxis, nSigmaTOFAxispid}); - - histos.add("NSigamaTPCTOFpion_rec_bf_sel", "NSigamaTPCTOFpion_rec_bf_sel", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); - histos.add("NSigamaTPCTOFkaon_rec_bf_sel", "NSigamaTPCTOFkaon_rec_bf_sel", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); - histos.add("NSigamaTPCTOFproton_rec_bf_sel", "NSigamaTPCTOFproton_rec_bf_sel", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); - - histos.add("hPtPion", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); - histos.add("hPtKaon", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); - histos.add("hPtProton", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); - - histos.add("hEtaPion", ";hEta", kTH1D, {etaAxis}); - histos.add("hEtaKaon", ";hEta", kTH1D, {etaAxis}); - histos.add("hEtaProton", ";hEta", kTH1D, {etaAxis}); - //=====================rapidity===================================== - histos.add("hyPion", ";hyPion", kTH1D, {etaAxis}); - histos.add("hyKaon", ";hyKaon", kTH1D, {etaAxis}); - histos.add("hyProton", ";hyProton", kTH1D, {etaAxis}); - - histos.add("hPtCh", "hPtCh", kTH2D, {nchAxis, ptAxis}); - histos.add("hPtChPion", "hPtChPion", kTH2D, {nchAxis, ptAxis}); - histos.add("hPtChKaon", "hPtChKaon", kTH2D, {nchAxis, ptAxis}); - histos.add("hPtChProton", "hPtChProton", kTH2D, {nchAxis, ptAxis}); - - histos.add("hPtCent", "hPtCent", kTH2D, {centAxis, ptAxis}); - histos.add("hPtCentPion", "hPtCentPion", kTH2D, {centAxis, ptAxis}); - histos.add("hPtCentKaon", "hPtCentKaon", kTH2D, {centAxis, ptAxis}); - histos.add("hPtCentProton", "hPtCentProton", kTH2D, {centAxis, ptAxis}); - - histos.add("hMeanPtCh", "hMeanPtCh", kTH2D, {nchAxis, ptAxis}); - histos.add("hCent", "hCent", kTH2D, {nchAxis, centAxis}); - - histos.add("hVar1", "hVar1", kTH2D, {subAxis, centAxis}); - histos.add("hVar2", "hVar2", kTH2D, {subAxis, centAxis}); - histos.add("hVar2meanpt", "hVar2meanpt", kTH2D, {centAxis, varAxis2}); - histos.add("hVar", "hVar", kTH2D, {subAxis, centAxis}); - histos.add("hVarc", "hVarc", kTH2D, {subAxis, centAxis}); - - histos.add("hVar1pi", "hVar1pi", kTH2D, {subAxis, centAxis}); - histos.add("hVar2pi", "hVar2pi", kTH2D, {subAxis, centAxis}); - histos.add("hVarpi", "hVarpi", kTH2D, {subAxis, centAxis}); - histos.add("hVar2meanptpi", "hVar2meanptpi", kTH2D, {centAxis, varAxis2}); - - histos.add("hVar1k", "hVar1k", kTH2D, {subAxis, centAxis}); - histos.add("hVar2k", "hVar2k", kTH2D, {subAxis, centAxis}); - histos.add("hVark", "hVark", kTH2D, {subAxis, centAxis}); - histos.add("hVar2meanptk", "hVar2meanptk", kTH2D, {centAxis, varAxis2}); - - histos.add("hVar1p", "hVar1p", kTH2D, {subAxis, centAxis}); - histos.add("hVar2p", "hVar2p", kTH2D, {subAxis, centAxis}); - histos.add("hVarp", "hVarp", kTH2D, {subAxis, centAxis}); - histos.add("hVar2meanptp", "hVar2meanptp", kTH2D, {centAxis, varAxis2}); - - //--------------------------------nch---------------------------------- - histos.add("hVar1x", "hVar1x", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2x", "hVar2x", kTH2D, {subAxis, nchAxis}); - histos.add("hVarx", "hVarx", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptx", "hVar2meanptx", kTH2D, {nchAxis, varAxis2}); - - histos.add("hVar1pix", "hVar1pix", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2pix", "hVar2pix", kTH2D, {subAxis, nchAxis}); - histos.add("hVarpix", "hVarpix", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptpix", "hVar2meanptpix", kTH2D, {nchAxis, varAxis2}); - - histos.add("hVar1kx", "hVar1kx", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2kx", "hVar2kx", kTH2D, {subAxis, nchAxis}); - histos.add("hVarkx", "hVarkx", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptkx", "hVar2meanptkx", kTH2D, {nchAxis, varAxis2}); - - histos.add("hVar1px", "hVar1px", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2px", "hVar2px", kTH2D, {subAxis, nchAxis}); - histos.add("hVarpx", "hVarpx", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptpx", "hVar2meanptpx", kTH2D, {nchAxis, varAxis2}); - - histos.add("ht", "ht", kTH1D, {centAxis}); - - histos.add("hCentrality", "hCentrality", kTH1D, {centAxis}); - - histos.add("hPEta", "hPEta", kTH2D, {pAxis, etaAxis}); - histos.add("hPtEta", "hPtEta", kTH2D, {ptAxis, etaAxis}); - histos.add("hPy", "hPy", kTH2D, {pAxis, etaAxis}); - histos.add("hPty", "hPty", kTH2D, {ptAxis, etaAxis}); - - histos.add("hPtyPion", "hPtyPion", kTH2D, {ptAxis, etaAxis}); - histos.add("hPtyKaon", "hPtyKaon", kTH2D, {ptAxis, etaAxis}); - histos.add("hPtyProton", "hPtyProton", kTH2D, {ptAxis, etaAxis}); - - histos.add("hPtyPion_rec", "hPtyPion_rec", kTH2D, {ptAxis, etaAxis}); - histos.add("hPtyKaon_rec", "hPtyKaon_rec", kTH2D, {ptAxis, etaAxis}); - histos.add("hPtyProton_rec", "hPtyProton_rec", kTH2D, {ptAxis, etaAxis}); - - histos.add("hPyPion_rec", "hPyPion_rec", kTH2D, {pAxis, etaAxis}); - histos.add("hPyKaon_rec", "hPyKaon_rec", kTH2D, {pAxis, etaAxis}); - histos.add("hPyProton_rec", "hPyProton_rec", kTH2D, {pAxis, etaAxis}); - - histos.add("hTOFbeta", "hTOFbeta", kTH2D, {pAxis, betaAxis}); - histos.add("hdEdx", "hdEdx", kTH2D, {pAxis, dEdxAxis}); - - histos.add("hTOFbeta_afterselection", "hTOFbeta_afterselection", kTH2D, {pAxis, betaAxis}); - histos.add("hdEdx_afterselection", "hdEdx_afterselection", kTH2D, {pAxis, dEdxAxis}); - - histos.add("hTOFbeta_afterselection1", "hTOFbeta_afterselection1", kTH2D, {pAxis, betaAxis}); - histos.add("hdEdx_afterselection1", "hdEdx_afterselection1", kTH2D, {pAxis, dEdxAxis}); - - histos.add("hTOFbeta_afterselection_rec_afterpidcut", "hTOFbeta_afterselection_rec_afterpidcut", kTH2D, {pAxis, betaAxis}); - histos.add("hdEdx_afterselection_rec_afterpidcut", "hdEdx_afterselection_rec_afterpidcut", kTH2D, {pAxis, dEdxAxis}); - - histos.add("hTOFbeta_afterselection_rec_beforepidcut", "hTOFbeta_afterselection_rec_beforepidcut", kTH2D, {pAxis, betaAxis}); - histos.add("hdEdx_afterselection_rec_beforepidcut", "hdEdx_afterselection_rec_beforepidcut", kTH2D, {pAxis, dEdxAxis}); - - histos.add("hdEdx_rec_bf_anycut", "hdEdx_rec_bf_anycut", kTH2D, {pAxis, dEdxAxis}); - - histos.add("hTPCchi2perCluster_before", "TPC #Chi^{2}/Cluster", kTH1D, {Chi2Axis}); - histos.add("hITSchi2perCluster_before", "ITS #Chi^{2}/Cluster", kTH1D, {Chi2Axis}); - histos.add("hTPCCrossedrows_before", "Crossed TPC rows", kTH1D, {CrossedrowTPCAxis}); - - histos.add("hTPCchi2perCluster_after", "TPC #Chi^{2}/Cluster", kTH1D, {Chi2Axis}); - histos.add("hITSchi2perCluster_after", "ITS #Chi^{2}/Cluster", kTH1D, {Chi2Axis}); - histos.add("hTPCCrossedrows_after", "Crossed TPC rows", kTH1D, {CrossedrowTPCAxis}); - - //--------------------------------nch---------------------------------- - histos.add("hVar1x_rec", "hVar1x_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2x_rec", "hVar2x_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVarx_rec", "hVarx_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptx_rec", "hVar2meanptx_rec", kTH2D, {nchAxis, varAxis2}); - - histos.add("hVar1pix_rec", "hVar1pix_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2pix_rec", "hVar2pix_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVarpix_rec", "hVarpix_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptpix_rec", "hVar2meanptpix_rec", kTH2D, {nchAxis, varAxis2}); - - histos.add("hVar1kx_rec", "hVar1kx_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2kx_rec", "hVar2kx_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVarkx_rec", "hVarkx_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptkx_rec", "hVar2meanptkx_rec", kTH2D, {nchAxis, varAxis2}); - - histos.add("hVar1px_rec", "hVar1px_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2px_rec", "hVar2px_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVarpx_rec", "hVarpx_rec", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptpx_rec", "hVar2meanptpx_rec", kTH2D, {nchAxis, varAxis2}); - - //=======================MC histograms Generated ================================================ - histos.add("ptHistogram_allcharge_gen", "ptHistogram_allcharge_gen", kTH1D, {ptAxis}); - histos.add("ptHistogramPion", "ptHistogramPion", kTH1D, {ptAxis}); - histos.add("ptHistogramKaon", "ptHistogramKaon", kTH1D, {ptAxis}); - histos.add("ptHistogramProton", "ptHistogramProton", kTH1D, {ptAxis}); - - histos.add("hMC_Pt", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); - histos.add("MC_hZvtx_after_sel", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {vtxZAxis}); - - histos.add("hTOFbeta_gen_pion", "hTOFbeta_gen_pion", kTH2D, {pAxis, betaAxis}); - histos.add("hdEdx_gen_pion", "hdEdx_gen_pion", kTH2D, {pAxis, dEdxAxis}); - - histos.add("hVar1x_gen", "hVar1x_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2x_gen", "hVar2x_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVarx_gen", "hVarx_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptx_gen", "hVar2meanptx_gen", kTH2D, {nchAxis, varAxis2}); - - histos.add("hVar1pix_gen", "hVar1pix_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2pix_gen", "hVar2pix_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVarpix_gen", "hVarpix_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptpix_gen", "hVar2meanptpix_gen", kTH2D, {nchAxis, varAxis2}); - - histos.add("hVar1kx_gen", "hVar1kx_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2kx_gen", "hVar2kx_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVarkx_gen", "hVarkx_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptkx_gen", "hVar2meanptkx_gen", kTH2D, {nchAxis, varAxis2}); - - histos.add("hVar1px_gen", "hVar1px_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2px_gen", "hVar2px_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVarpx_gen", "hVarpx_gen", kTH2D, {subAxis, nchAxis}); - histos.add("hVar2meanptpx_gen", "hVar2meanptpx_gen", kTH2D, {nchAxis, varAxis2}); - - //========================MC Histograms Reconstructed================================================= - - histos.add("hZvtx_after_sel_rec", "hZvtx_after_sel_rec", kTH1D, {vtxZAxis}); - histos.add("hZvtx_after_sel8_rec", "hZvtx_after_sel8_rec", kTH1D, {vtxZAxis}); - - histos.add("ptHistogram_allcharge_rec", "ptHistogram_allcharge_rec", kTH1D, {ptAxis}); - histos.add("ptHistogramPionrec", "ptHistogramPionrec", kTH1D, {ptAxis}); - histos.add("ptHistogramKaonrec", "ptHistogramKaonrec", kTH1D, {ptAxis}); - histos.add("ptHistogramProtonrec", "ptHistogramProtonrec", kTH1D, {ptAxis}); - - histos.add("ptHistogramPionrec_purity", "ptHistogramPionrec_purity", kTH1D, {ptAxis}); - histos.add("ptHistogramKaonrec_purity", "ptHistogramKaonrec_purity", kTH1D, {ptAxis}); - histos.add("ptHistogramProtonrec_purity", "ptHistogramProtonrec_purity", kTH1D, {ptAxis}); - - histos.add("ptHistogramPionrec_pdg", "ptHistogramPionrec_pdg", kTH1D, {ptAxis}); - histos.add("ptHistogramKaonrec_pdg", "ptHistogramKaonrec_pdg", kTH1D, {ptAxis}); - histos.add("ptHistogramProtonrec_pdg", "ptHistogramProtonrec_pdg", kTH1D, {ptAxis}); - - histos.add("Histogram_mass2_p_rec_beforesel", "Histogram_mass2_p_rec_beforesel", kTH1D, {ptAxis}); - histos.add("Histogram_mass2_p_rec_aftersel", "Histogram_mass2_p_rec_aftersel", kTH1D, {ptAxis}); - } - - //++++++++++++++++++++++++Monte Carlo Reconstructed +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - template - void SelTPConlyPions(const T& track1) - { - (track1.hasTPC() && (track1.p() < 0.7) && abs(track1.tpcNSigmaPi()) < 3. && (std::abs(track1.tpcNSigmaKa()) > 3.0 && std::abs(track1.tpcNSigmaPr()) > 3.0)); - } - template - void SelTPConlyKaons(const T& track1) - { - (track1.hasTPC() && (track1.p() < 0.7) && abs(track1.tpcNSigmaKa()) < 3.0 && (std::abs(track1.tpcNSigmaPi()) > 3.0 && std::abs(track1.tpcNSigmaPr()) > 3.0)); - } - template - void SelTPConlyProtons(const T& track1) - { - (track1.hasTPC() && (track1.p() < 1.1) && abs(track1.tpcNSigmaPr()) < 3.0 && (std::abs(track1.tpcNSigmaPi()) > 3.0 && std::abs(track1.tpcNSigmaKa()) > 3.0)); - } - - template - void SelTPCTOFPions(const T& track1) - { - (track1.hasTPC() && track1.hasTOF() && track1.p() >= 0.7 && TMath::Hypot((track1.tofNSigmaPr() + 2) / 3.0, (track1.tpcNSigmaPr() - 6) / 4.0) > 3. && TMath::Hypot((track1.tofNSigmaKa() + 2) / 3.0, (track1.tpcNSigmaKa() - 6) / 4.0) > 3. && TMath::Hypot((track1.tofNSigmaPi() + 2) / 3.0, (track1.tpcNSigmaPi() - 6) / 4.0) < 3.); - } - - template - void SelTPCTOFKaons(const T& track1) - { - (track1.hasTPC() && track1.hasTOF() && track1.p() >= 0.7 && TMath::Hypot((track1.tofNSigmaPr() + 2) / 3.0, (track1.tpcNSigmaPr() - 6) / 4.0) > 3. && TMath::Hypot((track1.tofNSigmaPi() + 2) / 3.0, (track1.tpcNSigmaPi() - 6) / 4.0) > 3. && TMath::Hypot((track1.tofNSigmaKa() + 2) / 3.0, (track1.tpcNSigmaKa() - 6) / 4.0) < 3.); - } - - template - void SelTPCTOFProtons(const T& track1) - { - if (track1.hasTPC() && track1.hasTOF() && track1.p() >= 1.1 && TMath::Hypot((track1.tofNSigmaPi() + 2) / 3.0, (track1.tpcNSigmaPi() - 6) / 4.0) > 3. && TMath::Hypot((track1.tofNSigmaKa() + 2) / 3.0, (track1.tpcNSigmaKa() - 6) / 4.0) > 3. && TMath::Hypot((track1.tofNSigmaPr() + 2) / 3.0, (track1.tpcNSigmaPr() - 6) / 4.0) < 3.) { - }; - } - - void processMCReco(aod::MyMCRecoCollisions::iterator const& mccoll, aod::MyMCRecoTracks const& mcrectrack, aod::McParticles const& /*mcParticles*/) - { - if (!mccoll.has_mcCollision()) { - return; - } - histos.fill(HIST("tracksel_rec"), 1); - - if (fabs(mccoll.posZ()) > 10.f) { - return; - } - histos.fill(HIST("hZvtx_after_sel_rec"), mccoll.posZ()); - - histos.fill(HIST("tracksel_rec"), 2); - - if (!mccoll.sel8()) { - return; - } - - histos.fill(HIST("hZvtx_after_sel8_rec"), mccoll.posZ()); - - histos.fill(HIST("tracksel_rec"), 3); - - if (!mccoll.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return; - } - histos.fill(HIST("tracksel_rec"), 4); - - if (!mccoll.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - return; - } - histos.fill(HIST("tracksel_rec"), 5); - - if (!mccoll.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return; - } - histos.fill(HIST("tracksel_rec"), 6); - - if (!mccoll.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - return; - } - histos.fill(HIST("tracksel_rec"), 7); - - double nCh_rec = 0.; - double nChpi_rec = 0.; - double nChk_rec = 0.; - double nChp_rec = 0.; - - double Q1_rec = 0, Q2_rec = 0; - double Q1pi_rec = 0, Q2pi_rec = 0; - double Q1k_rec = 0, Q2k_rec = 0; - double Q1p_rec = 0, Q2p_rec = 0; - double var1_rec = 0, var2_rec = 0; - double var1pi_rec = 0, var2pi_rec = 0; - double var1k_rec = 0, var2k_rec = 0; - double var1p_rec = 0, var2p_rec = 0; - - int sample_rec = histos.get(HIST("hZvtx_after_sel8_rec"))->GetEntries(); - sample_rec = sample_rec % 30; - - for (auto track1 : mcrectrack) { - if (!(track1.has_collision())) - continue; - if (!(track1.has_mcParticle())) - continue; - if (!(track1.mcParticle().isPhysicalPrimary())) - continue; - if (!track1.isGlobalTrack()) - continue; - - if (!(track1.pt() > 0.15) || !(track1.pt() < 2.0)) - continue; // pt = 0.15 - if (!(track1.eta() > -0.8) || !(track1.eta() < 0.8)) - continue; // eta cut - - nCh_rec += 1.; - - Q1_rec += track1.pt(); - Q2_rec += (track1.pt() * track1.pt()); - - histos.fill(HIST("ptHistogram_allcharge_rec"), track1.pt()); - - if (track1.hasTPC()) - histos.fill(HIST("hdEdx_rec_bf_anycut"), track1.p(), track1.tpcSignal()); - - //======================================================================== - - if (abs(track1.mcParticle().pdgCode()) == 211) { - - histos.fill(HIST("ptHistogramPionrec_pdg"), track1.pt()); - } - if (abs(track1.mcParticle().pdgCode()) == 321) { - - histos.fill(HIST("ptHistogramKaonrec_pdg"), track1.pt()); - } - if (abs(track1.mcParticle().pdgCode()) == 2212) { - - histos.fill(HIST("ptHistogramProtonrec_pdg"), track1.pt()); - } - - //+++++++++ electron rejection ++++++++++++++++++++++++++++++++// - - if (abs(track1.tpcNSigmaEl()) < 3.0 && abs(track1.tpcNSigmaPi()) > 3. && abs(track1.tpcNSigmaKa()) > 3. && abs(track1.tpcNSigmaPr()) > 3.) - continue; - - //============Reconstructed MC=================PIONS selection==============================================================// - - if (track1.hasTPC()) - histos.fill(HIST("hdEdx_afterselection_rec_beforepidcut"), track1.p(), track1.tpcSignal()); - if (track1.hasTOF()) - histos.fill(HIST("hTOFbeta_afterselection_rec_beforepidcut"), track1.p(), track1.beta()); - - if (track1.hasTPC() && track1.hasTOF()) { - - histos.fill(HIST("NSigamaTPCpion_rec_bf_sel"), track1.p(), track1.tpcNSigmaPi()); - histos.fill(HIST("NSigamaTOFpion_rec_bf_sel"), track1.p(), track1.tofNSigmaPi()); - histos.fill(HIST("NSigamaTPCTOFpion_rec_bf_sel"), track1.tpcNSigmaPi(), track1.tofNSigmaPi()); - } - - SelTPConlyPions(track1); // Pion (TPC only) - SelTPCTOFPions(track1); // Pion passes TPC and TOF both! - - { - - histos.fill(HIST("ptHistogramPionrec"), track1.pt()); - - nChpi_rec += 1.; - Q1pi_rec += track1.pt(); - Q2pi_rec += (track1.pt() * track1.pt()); - - histos.fill(HIST("NSigamaTPCpion_rec"), track1.p(), track1.tpcNSigmaPi()); - histos.fill(HIST("NSigamaTOFpion_rec"), track1.p(), track1.tofNSigmaPi()); - histos.fill(HIST("NSigamaTPCTOFpion_rec"), track1.tpcNSigmaPi(), track1.tofNSigmaPi()); - - if (track1.beta() > 1) - continue; - - histos.fill(HIST("hdEdx_afterselection_rec_afterpidcut"), track1.p(), track1.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection_rec_afterpidcut"), track1.p(), track1.beta()); - - if (abs(track1.mcParticle().pdgCode()) == 211) { - histos.fill(HIST("ptHistogramPionrec_purity"), track1.pt()); - } - - if (abs(track1.rapidity(massPi)) < 0.5) { - - histos.fill(HIST("hPyPion_rec"), track1.p(), track1.rapidity(massPi)); - histos.fill(HIST("hPtyPion_rec"), track1.pt(), track1.rapidity(massPi)); - } - } - - //============Reconstructed MC=================KAONS selection==============================================================// - - if (track1.hasTPC()) - histos.fill(HIST("hdEdx_afterselection_rec_beforepidcut"), track1.p(), track1.tpcSignal()); - if (track1.hasTOF()) - histos.fill(HIST("hTOFbeta_afterselection_rec_beforepidcut"), track1.p(), track1.beta()); - - if (track1.hasTPC() && track1.hasTOF()) { - - histos.fill(HIST("NSigamaTPCkaon_rec_bf_sel"), track1.p(), track1.tpcNSigmaKa()); - histos.fill(HIST("NSigamaTOFkaon_rec_bf_sel"), track1.p(), track1.tofNSigmaKa()); - histos.fill(HIST("NSigamaTPCTOFkaon_rec_bf_sel"), track1.tpcNSigmaKa(), track1.tofNSigmaKa()); - } - - SelTPConlyKaons(track1); // Kaons passes from TPC only! - SelTPCTOFKaons(track1); // Kaons passes from TPC and TOF both! - - { - - histos.fill(HIST("ptHistogramKaonrec"), track1.pt()); - - nChk_rec += 1.; - Q1k_rec += track1.pt(); - Q2k_rec += (track1.pt() * track1.pt()); - - histos.fill(HIST("NSigamaTPCkaon_rec"), track1.p(), track1.tpcNSigmaKa()); - histos.fill(HIST("NSigamaTOFkaon_rec"), track1.p(), track1.tofNSigmaKa()); - histos.fill(HIST("NSigamaTPCTOFkaon_rec"), track1.tpcNSigmaKa(), track1.tofNSigmaKa()); - - if (track1.beta() > 1) - continue; - - histos.fill(HIST("hdEdx_afterselection_rec_afterpidcut"), track1.p(), track1.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection_rec_afterpidcut"), track1.p(), track1.beta()); - - if (abs(track1.mcParticle().pdgCode()) == 321) { - histos.fill(HIST("ptHistogramKaonrec_purity"), track1.pt()); - } - - if (abs(track1.rapidity(massKa)) < 0.5) { - - histos.fill(HIST("hPyKaon_rec"), track1.p(), track1.rapidity(massKa)); - histos.fill(HIST("hPtyKaon_rec"), track1.pt(), track1.rapidity(massKa)); - } - } - - //============Reconstructed MC=================PROTONS selection==============================================================// - - if (track1.hasTPC()) - histos.fill(HIST("hdEdx_afterselection_rec_beforepidcut"), track1.p(), track1.tpcSignal()); - if (track1.hasTOF()) - histos.fill(HIST("hTOFbeta_afterselection_rec_beforepidcut"), track1.p(), track1.beta()); - - if (track1.hasTPC() && track1.hasTOF()) { - - histos.fill(HIST("NSigamaTPCproton_rec_bf_sel"), track1.p(), track1.tpcNSigmaPr()); - histos.fill(HIST("NSigamaTOFproton_rec_bf_sel"), track1.p(), track1.tofNSigmaPr()); - histos.fill(HIST("NSigamaTPCTOFproton_rec_bf_sel"), track1.tpcNSigmaPr(), track1.tofNSigmaPr()); - } - - SelTPConlyProtons(track1); // Protons passes from TPC only! - SelTPCTOFProtons(track1); // Protons passes from TPC and TOF both! - - { - - histos.fill(HIST("ptHistogramProtonrec"), track1.pt()); - - nChp_rec += 1.; - Q1p_rec += track1.pt(); - Q2p_rec += (track1.pt() * track1.pt()); - - histos.fill(HIST("NSigamaTPCproton_rec"), track1.p(), track1.tpcNSigmaPr()); - histos.fill(HIST("NSigamaTOFproton_rec"), track1.p(), track1.tofNSigmaPr()); - histos.fill(HIST("NSigamaTPCTOFproton_rec"), track1.tpcNSigmaPr(), track1.tofNSigmaPr()); - - if (track1.beta() > 1) - continue; - - histos.fill(HIST("hdEdx_afterselection_rec_afterpidcut"), track1.p(), track1.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection_rec_afterpidcut"), track1.p(), track1.beta()); - - if (abs(track1.mcParticle().pdgCode()) == 2212) { - histos.fill(HIST("ptHistogramProtonrec_purity"), track1.pt()); - } - - if (abs(track1.rapidity(massPr)) < 0.5) { - - histos.fill(HIST("hPyProton_rec"), track1.p(), track1.rapidity(massPr)); - histos.fill(HIST("hPtyProton_rec"), track1.pt(), track1.rapidity(massPr)); - } - } - - //============================================================================ - - } // track loop ends - - if (nCh_rec < 2) - return; - - //------------------ all charges------------------------------------- - var1_rec = (Q1_rec * Q1_rec - Q2_rec) / (nCh_rec * (nCh_rec - 1)); - var2_rec = (Q1_rec / nCh_rec); - - //---------------------- pions ---------------------------------------- - - if (nChpi_rec > 2) { - var1pi_rec = (Q1pi_rec * Q1pi_rec - Q2pi_rec) / (nChpi_rec * (nChpi_rec - 1)); - var2pi_rec = (Q1pi_rec / nChpi_rec); - } - - //----------------------- kaons --------------------------------------- - if (nChk_rec > 2) { - var1k_rec = (Q1k_rec * Q1k_rec - Q2k_rec) / (nChk_rec * (nChk_rec - 1)); - var2k_rec = (Q1k_rec / nChk_rec); - } - - //---------------------------- protons ---------------------------------- - if (nChp_rec > 2) { - var1p_rec = (Q1p_rec * Q1p_rec - Q2p_rec) / (nChp_rec * (nChp_rec - 1)); - var2p_rec = (Q1p_rec / nChp_rec); - } - - //-----------------------nch------------------------------------- - histos.fill(HIST("hVar1x_rec"), sample_rec, nCh_rec, var1_rec); - histos.fill(HIST("hVar2x_rec"), sample_rec, nCh_rec, var2_rec); - histos.fill(HIST("hVarx_rec"), sample_rec, nCh_rec); - histos.fill(HIST("hVar2meanptx_rec"), nCh_rec, var2_rec); - - histos.fill(HIST("hVar1pix_rec"), sample_rec, nCh_rec, var1pi_rec); - histos.fill(HIST("hVar2pix_rec"), sample_rec, nCh_rec, var2pi_rec); - histos.fill(HIST("hVarpix_rec"), sample_rec, nChpi_rec); - histos.fill(HIST("hVar2meanptpix_rec"), nCh_rec, var2pi_rec); - - histos.fill(HIST("hVar1kx_rec"), sample_rec, nCh_rec, var1k_rec); - histos.fill(HIST("hVar2kx_rec"), sample_rec, nCh_rec, var2k_rec); - histos.fill(HIST("hVarkx_rec"), sample_rec, nChk_rec); - histos.fill(HIST("hVar2meanptkx_rec"), nCh_rec, var2k_rec); - - histos.fill(HIST("hVar1px_rec"), sample_rec, nCh_rec, var1p_rec); - histos.fill(HIST("hVar2px_rec"), sample_rec, nCh_rec, var2p_rec); - histos.fill(HIST("hVarpx_rec"), sample_rec, nChp_rec); - histos.fill(HIST("hVar2meanptpx_rec"), nCh_rec, var2p_rec); - - } // ends - - PROCESS_SWITCH(IdentifiedMeanPtFluctuations, processMCReco, "process reconstructed information", true); - - //++++++++++++++++++++++++++++Monte Carlo Generated ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - void processMCGen(aod::McCollision const& mcCollision, aod::McParticles& mcParticles) - - { - - if (fabs(mcCollision.posZ()) > 10.f) { - return; - } - histos.fill(HIST("MC_hZvtx_after_sel"), mcCollision.posZ()); - - double nCh_gen = 0.; - double nChpi_gen = 0.; - double nChk_gen = 0.; - double nChp_gen = 0.; - - double Q1_gen = 0, Q2_gen = 0; - double Q1pi_gen = 0, Q2pi_gen = 0; - double Q1k_gen = 0, Q2k_gen = 0; - double Q1p_gen = 0, Q2p_gen = 0; - - double var1_gen = 0, var2_gen = 0; - double var1pi_gen = 0, var2pi_gen = 0; - double var1k_gen = 0, var2k_gen = 0; - double var1p_gen = 0, var2p_gen = 0; - - int sample_gen = histos.get(HIST("hZvtx_after_sel"))->GetEntries(); - sample_gen = sample_gen % 30; - - for (auto& mcgentrack : mcParticles) - - { - auto pdgcode = std::abs(mcgentrack.pdgCode()); - if (!(mcgentrack.has_mcCollision())) - continue; - if (!(mcgentrack.isPhysicalPrimary())) - continue; - if (!(mcgentrack.pt() > 0.15) || !(mcgentrack.pt() < 2.)) - continue; - if (!(mcgentrack.eta() > -0.8) || !(mcgentrack.eta() < 0.8)) - continue; - - nCh_gen += 1.; - - Q1_gen += mcgentrack.pt(); - Q2_gen += (mcgentrack.pt() * mcgentrack.pt()); - - histos.fill(HIST("ptHistogram_allcharge_gen"), mcgentrack.pt()); - - if (pdgcode == 211) { - - histos.fill(HIST("ptHistogramPion"), mcgentrack.pt()); - - nChpi_gen += 1.; - Q1pi_gen += mcgentrack.pt(); - Q2pi_gen += (mcgentrack.pt() * mcgentrack.pt()); - } - - if (pdgcode == 321) { - - histos.fill(HIST("ptHistogramKaon"), mcgentrack.pt()); - - nChk_gen += 1.; - Q1k_gen += mcgentrack.pt(); - Q2k_gen += (mcgentrack.pt() * mcgentrack.pt()); - } - - if (pdgcode == 2212) { - - histos.fill(HIST("ptHistogramProton"), mcgentrack.pt()); - - nChp_gen += 1.; - Q1p_gen += mcgentrack.pt(); - Q2p_gen += (mcgentrack.pt() * mcgentrack.pt()); - } - - //================================= Pion Generated Calculation ==================================== - - } // track loop ends! - - if (nCh_gen < 2) - return; - - //------------------ all charges------------------------------------- - var1_gen = (Q1_gen * Q1_gen - Q2_gen) / (nCh_gen * (nCh_gen - 1)); - var2_gen = (Q1_gen / nCh_gen); - - //---------------------- pions ---------------------------------------- - - if (nChpi_gen > 2) { - var1pi_gen = (Q1pi_gen * Q1pi_gen - Q2pi_gen) / (nChpi_gen * (nChpi_gen - 1)); - var2pi_gen = (Q1pi_gen / nChpi_gen); - } - - //----------------------- kaons --------------------------------------- - if (nChk_gen > 2) { - var1k_gen = (Q1k_gen * Q1k_gen - Q2k_gen) / (nChk_gen * (nChk_gen - 1)); - var2k_gen = (Q1k_gen / nChk_gen); - } - - //---------------------------- protons ---------------------------------- - if (nChp_gen > 2) { - var1p_gen = (Q1p_gen * Q1p_gen - Q2p_gen) / (nChp_gen * (nChp_gen - 1)); - var2p_gen = (Q1p_gen / nChp_gen); - } - - //-----------------------nch------------------------------------- - histos.fill(HIST("hVar1x_gen"), sample_gen, nCh_gen, var1_gen); - histos.fill(HIST("hVar2x_gen"), sample_gen, nCh_gen, var2_gen); - histos.fill(HIST("hVarx_gen"), sample_gen, nCh_gen); - histos.fill(HIST("hVar2meanptx_gen"), nCh_gen, var2_gen); - - histos.fill(HIST("hVar1pix_gen"), sample_gen, nCh_gen, var1pi_gen); - histos.fill(HIST("hVar2pix_gen"), sample_gen, nCh_gen, var2pi_gen); - histos.fill(HIST("hVarpix_gen"), sample_gen, nChpi_gen); - histos.fill(HIST("hVar2meanptpix_gen"), nCh_gen, var2pi_gen); - - histos.fill(HIST("hVar1kx_gen"), sample_gen, nCh_gen, var1k_gen); - histos.fill(HIST("hVar2kx_gen"), sample_gen, nCh_gen, var2k_gen); - histos.fill(HIST("hVarkx_gen"), sample_gen, nChk_gen); - histos.fill(HIST("hVar2meanptkx_gen"), nCh_gen, var2k_gen); - - histos.fill(HIST("hVar1px_gen"), sample_gen, nCh_gen, var1p_gen); - histos.fill(HIST("hVar2px_gen"), sample_gen, nCh_gen, var2p_gen); - histos.fill(HIST("hVarpx_gen"), sample_gen, nChp_gen); - histos.fill(HIST("hVar2meanptpx_gen"), nCh_gen, var2p_gen); - } - PROCESS_SWITCH(IdentifiedMeanPtFluctuations, processMCGen, "process generated information", true); - - //+++++++++++++++++++++++++++++DATA CALCULATION +++++++++++++++++++++++++++++++++++++++++++++++++++++ - void process(aod::MyCollision const& coll, aod::MyTracks const& inputTracks) - - { - histos.fill(HIST("hEventCounter"), 1.); - - histos.fill(HIST("hZvtx_before_sel"), coll.posZ()); - if (fabs(coll.posZ()) > 10.f) { - return; - } - - histos.fill(HIST("hEventCounter"), 2.); - - histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); - - if (!coll.sel8()) { - return; - } - histos.fill(HIST("hZvtx_after_sel8"), coll.posZ()); - - histos.fill(HIST("hEventCounter"), 3.); - - const auto cent = coll.centFT0C(); - histos.fill(HIST("hCentrality"), cent); - - double nCh = 0.; - double nChpi = 0.; - double nChk = 0.; - double nChp = 0.; - - double Q1 = 0., Q2 = 0.; - double Q1pi = 0., Q2pi = 0.; - double Q1k = 0., Q2k = 0.; - double Q1p = 0., Q2p = 0.; - double var1 = 0., var2 = 0., twopar_allcharge = 0.; - double var1pi = 0., var2pi = 0.; - double var1k = 0., var2k = 0.; - double var1p = 0., var2p = 0.; - // cent = 0; - - // sampling - int sample = histos.get(HIST("hZvtx_after_sel8"))->GetEntries(); - sample = sample % 30; - - // Perfroming the track selection========================================== - for (auto track : inputTracks) { - // Loop over tracks - - // inital tracks - histos.fill(HIST("tracksel"), 1); - - histos.fill(HIST("hTPCchi2perCluster_before"), track.tpcChi2NCl()); - histos.fill(HIST("hITSchi2perCluster_before"), track.itsChi2NCl()); - histos.fill(HIST("hTPCCrossedrows_before"), track.tpcNClsCrossedRows()); - - // tracks passed after GlobalTrackcut - if (!track.isGlobalTrack()) - continue; - histos.fill(HIST("tracksel"), 2); - - // tracks passed after DCAxy - // if (!(fabs(track.dcaXY()) < 0.12)) continue;//global cut already includes - histos.fill(HIST("tracksel"), 3); - - // tracks passed after DCAz - // - histos.fill(HIST("hDCAxy"), track.dcaXY()); - histos.fill(HIST("hDCAz"), track.dcaZ()); - - // if (!(fabs(track.dcaZ()) < 1.)) continue;//global cut already includes (DCAz< 2.0) cm - histos.fill(HIST("tracksel"), 4); - - // tracks passed after Eta-cut - if (!(fabs(track.eta()) < 0.8)) - continue; - histos.fill(HIST("tracksel"), 5); - - // tracks passed after pT-cut - if (!(track.pt() > 0.15 && track.pt() < 2.)) - continue; // pt = 0.15 - histos.fill(HIST("tracksel"), 6); - - // if (track.tpcNClsCrossedRows() < 70.0) continue; - histos.fill(HIST("hTPCCrossedrows_after"), track.tpcNClsCrossedRows()); - histos.fill(HIST("tracksel"), 7); - - // if (track.tpcChi2NCl() > 4.0) continue; - histos.fill(HIST("hTPCchi2perCluster_after"), track.tpcChi2NCl()); - histos.fill(HIST("tracksel"), 8); - - // if (track.itsChi2NCl() > 36.0) continue; - histos.fill(HIST("hITSchi2perCluster_after"), track.itsChi2NCl()); - histos.fill(HIST("tracksel"), 9); - - nCh += 1.; - - Q1 += track.pt(); - Q2 += (track.pt() * track.pt()); - - histos.fill(HIST("hP"), track.p()); - histos.fill(HIST("hPt"), track.pt()); - histos.fill(HIST("hEta"), track.eta()); - histos.fill(HIST("hPtDCAxy"), track.pt(), track.dcaXY()); - histos.fill(HIST("hPtDCAz"), track.pt(), track.dcaZ()); - - histos.fill(HIST("hPtEta"), track.pt(), track.eta()); - histos.fill(HIST("hPEta"), track.p(), track.eta()); - - histos.fill(HIST("hNsigmaTPC"), track.p(), track.tpcNSigmaPr()); - - // only TPC tracks: Pion, Kaon, Proton - if (track.hasTPC() && abs(track.tpcNSigmaPi()) < 2.) - histos.fill(HIST("NSigamaTPCpion"), track.pt(), track.tpcNSigmaPi()); - if (track.hasTPC() && abs(track.tpcNSigmaKa()) < 2.) - histos.fill(HIST("NSigamaTPCkaon"), track.pt(), track.tpcNSigmaKa()); - if (track.hasTPC() && abs(track.tpcNSigmaPr()) < 2.) - histos.fill(HIST("NSigamaTPCproton"), track.pt(), track.tpcNSigmaPr()); - - // only TOF tracks: Pion, Kaon, Proton - if (track.hasTOF() && abs(track.tofNSigmaPi()) < 2.) - histos.fill(HIST("NSigamaTOFpion"), track.pt(), track.tofNSigmaPi()); - if (track.hasTOF() && abs(track.tofNSigmaKa()) < 2.) - histos.fill(HIST("NSigamaTOFkaon"), track.pt(), track.tofNSigmaKa()); - if (track.hasTOF() && abs(track.tofNSigmaPr()) < 2.) - histos.fill(HIST("NSigamaTOFproton"), track.pt(), track.tofNSigmaPr()); - - if (track.hasTPC()) - histos.fill(HIST("hdEdx"), track.p(), track.tpcSignal()); - if (track.hasTOF()) - histos.fill(HIST("hTOFbeta"), track.p(), track.beta()); - - //=============================pion============================================================== - // only TPC+TOF tracks: Pion, Kaon, Proton - if ((track.hasTPC() && abs(track.tpcNSigmaPi()) < 2.) && (track.hasTOF() && abs(track.tofNSigmaPi()) < 2.)) { - histos.fill(HIST("NSigamaTPCTOFpion"), track.tpcNSigmaPi(), track.tofNSigmaPi()); - - histos.fill(HIST("hdEdx_afterselection"), track.p(), track.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection"), track.p(), track.beta()); - } - - // pion-TPC----------------------------------------------------------------------------------- - - if ((track.hasTPC() && abs(track.tpcNSigmaPi()) < 2. && (track.pt() >= 0.15 && track.pt() < 0.65) && (abs(track.rapidity(massPi)) < 0.5) && (std::abs(track.tpcNSigmaEl()) > 1.0 && std::abs(track.tpcNSigmaKa()) > 2.0 && std::abs(track.tpcNSigmaPr()) > 2.0))) { - - histos.fill(HIST("hPtPion"), track.pt()); - histos.fill(HIST("hEtaPion"), track.eta()); - histos.fill(HIST("hyPion"), track.rapidity(massPi)); - histos.fill(HIST("hPtyPion"), track.pt(), track.rapidity(massPi)); - - nChpi += 1.; - Q1pi += track.pt(); - Q2pi += (track.pt() * track.pt()); - - if (track.beta() > 1) - continue; - - histos.fill(HIST("hdEdx_afterselection1"), track.p(), track.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection1"), track.p(), track.beta()); - } - - // pion->(TPC+TOF)------------------------------------------------------------------------------------ - if ((track.pt() >= 0.65 && track.pt() < 2.0) && (abs(track.rapidity(massPi)) < 0.5) && track.hasTPC() && track.hasTOF() && (std::abs(track.tofNSigmaKa()) > 2.0 && std::abs(track.tofNSigmaPr()) > 2.0) && abs(sqrt(track.tpcNSigmaPi()) * (track.tpcNSigmaPi()) + (track.tofNSigmaPi()) * (track.tofNSigmaPi())) < 2.) { - - histos.fill(HIST("hPtPion"), track.pt()); - histos.fill(HIST("hEtaPion"), track.eta()); - histos.fill(HIST("hyPion"), track.rapidity(massPi)); - histos.fill(HIST("hPtyPion"), track.pt(), track.rapidity(massPi)); - - nChpi += 1.; - Q1pi += track.pt(); - Q2pi += (track.pt() * track.pt()); - - if (track.beta() > 1) - continue; - - histos.fill(HIST("hdEdx_afterselection1"), track.p(), track.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection1"), track.p(), track.beta()); - } - - //===========================kaon=============================================================== - - if ((track.hasTPC() && abs(track.tpcNSigmaKa()) < 2.) && (track.hasTOF() && abs(track.tofNSigmaKa()) < 2.)) { - histos.fill(HIST("NSigamaTPCTOFkaon"), track.tpcNSigmaKa(), track.tofNSigmaKa()); - histos.fill(HIST("hdEdx_afterselection"), track.p(), track.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection"), track.p(), track.beta()); - } - - if (track.hasTPC() && abs(track.tpcNSigmaKa()) < 2. && (track.pt() >= 0.15 && track.pt() < 0.65) && (abs(track.rapidity(massKa)) < 0.5) && (std::abs(track.tpcNSigmaEl()) > 1.0 && std::abs(track.tpcNSigmaPi()) > 2.0 && std::abs(track.tpcNSigmaPr()) > 2.0)) { - - histos.fill(HIST("hPtKaon"), track.pt()); - histos.fill(HIST("hEtaKaon"), track.eta()); - histos.fill(HIST("hyKaon"), track.rapidity(massKa)); - histos.fill(HIST("hPtyKaon"), track.pt(), track.rapidity(massKa)); - - nChk += 1.; - Q1k += track.pt(); - Q2k += (track.pt() * track.pt()); - - if (track.beta() > 1) - continue; - - histos.fill(HIST("hdEdx_afterselection1"), track.p(), track.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection1"), track.p(), track.beta()); - } - - if ((track.pt() >= 0.65 && track.pt() < 2.0) && (abs(track.rapidity(massKa)) < 0.5) && track.hasTPC() && track.hasTOF() && (std::abs(track.tofNSigmaPi()) > 2.0 && std::abs(track.tofNSigmaPr()) > 2.0) && (abs(sqrt(track.tpcNSigmaKa()) * (track.tpcNSigmaKa()) + (track.tofNSigmaKa()) * (track.tofNSigmaKa())) < 2.)) { - - histos.fill(HIST("hPtKaon"), track.pt()); - histos.fill(HIST("hEtaKaon"), track.eta()); - histos.fill(HIST("hyKaon"), track.rapidity(massKa)); - histos.fill(HIST("hPtyKaon"), track.pt(), track.rapidity(massKa)); - - nChk += 1.; - Q1k += track.pt(); - Q2k += (track.pt() * track.pt()); - - if (track.beta() > 1) - continue; - - histos.fill(HIST("hdEdx_afterselection1"), track.p(), track.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection1"), track.p(), track.beta()); - } - - //============================proton=========================================================== - - if ((track.hasTPC() && abs(track.tpcNSigmaPr()) < 2.) && (track.hasTOF() && abs(track.tofNSigmaPr()) < 2.)) { - histos.fill(HIST("NSigamaTPCTOFproton"), track.tpcNSigmaPr(), track.tofNSigmaPr()); - - histos.fill(HIST("hdEdx_afterselection"), track.p(), track.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection"), track.p(), track.beta()); - } - - if (track.hasTPC() && abs(track.tpcNSigmaPr()) < 2. && (track.pt() >= 0.4 && track.pt() < 0.85) && (abs(track.rapidity(massPr)) < 0.5) && (std::abs(track.tpcNSigmaEl()) > 1.0 && std::abs(track.tpcNSigmaKa()) > 2.0 && std::abs(track.tpcNSigmaPi()) > 2.0)) { - - histos.fill(HIST("hPtProton"), track.pt()); - histos.fill(HIST("hEtaProton"), track.eta()); - histos.fill(HIST("hyProton"), track.rapidity(massPr)); - histos.fill(HIST("hPtyProton"), track.pt(), track.rapidity(massPr)); - - nChp += 1.; - Q1p += track.pt(); - Q2p += (track.pt() * track.pt()); - - if (track.beta() > 1) - continue; - - histos.fill(HIST("hdEdx_afterselection1"), track.p(), track.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection1"), track.p(), track.beta()); - } - - if ((track.pt() >= 0.85 && track.pt() < 2.0) && (abs(track.rapidity(massPr)) < 0.5) && track.hasTPC() && track.hasTOF() && (std::abs(track.tofNSigmaKa()) > 2.0 && std::abs(track.tofNSigmaPi()) > 2.0) && (abs(sqrt(track.tpcNSigmaPr()) * (track.tpcNSigmaPr()) + (track.tofNSigmaPr()) * (track.tofNSigmaPr())) < 2.)) { - - histos.fill(HIST("hPtProton"), track.pt()); - histos.fill(HIST("hEtaProton"), track.eta()); - histos.fill(HIST("hyProton"), track.rapidity(massPr)); - histos.fill(HIST("hPtyProton"), track.pt(), track.rapidity(massPr)); - - nChp += 1.; - Q1p += track.pt(); - Q2p += (track.pt() * track.pt()); - - if (track.beta() > 1) - continue; - - histos.fill(HIST("hdEdx_afterselection1"), track.p(), track.tpcSignal()); - histos.fill(HIST("hTOFbeta_afterselection1"), track.p(), track.beta()); - } - - //==================================================================================================== - } - // Track loop ends! - - if (nCh < 2) - return; - - //------------------ all charges------------------------------------- - var1 = (Q1 * Q1 - Q2) / (nCh * (nCh - 1)); - histos.fill(HIST("hVar1"), sample, cent, var1); - var2 = (Q1 / nCh); - histos.fill(HIST("hVar2"), sample, cent, var2); - histos.fill(HIST("hVarc"), sample, cent); - histos.fill(HIST("hVar2meanpt"), cent, var2); - - twopar_allcharge = (var1 - var2); - histos.fill(HIST("hVar"), nCh, twopar_allcharge); - - //---------------------- pions ---------------------------------------- - - if (nChpi > 2) { - var1pi = (Q1pi * Q1pi - Q2pi) / (nChpi * (nChpi - 1)); - var2pi = (Q1pi / nChpi); - } - - //----------------------- kaons --------------------------------------- - if (nChk > 2) { - var1k = (Q1k * Q1k - Q2k) / (nChk * (nChk - 1)); - var2k = (Q1k / nChk); - } - - //---------------------------- protons ---------------------------------- - if (nChp > 2) { - var1p = (Q1p * Q1p - Q2p) / (nChp * (nChp - 1)); - var2p = (Q1p / nChp); - } - - //========================centrality========================================== - - histos.fill(HIST("hVar1pi"), sample, cent, var1pi); - histos.fill(HIST("hVar2pi"), sample, cent, var2pi); - histos.fill(HIST("hVar2meanptpi"), cent, var2pi); - - histos.fill(HIST("hVar1k"), sample, cent, var1k); - histos.fill(HIST("hVar2k"), sample, cent, var2k); - histos.fill(HIST("hVar2meanptk"), cent, var2k); - - histos.fill(HIST("hVar1p"), sample, cent, var1p); - histos.fill(HIST("hVar2p"), sample, cent, var2p); - histos.fill(HIST("hVar2meanptp"), cent, var2p); - - //-----------------------nch------------------------------------- - histos.fill(HIST("hVar1x"), sample, nCh, var1); - histos.fill(HIST("hVar2x"), sample, nCh, var2); - histos.fill(HIST("hVarx"), sample, nCh); - histos.fill(HIST("hVar2meanptx"), nCh, var2); - - histos.fill(HIST("hVar1pix"), sample, nCh, var1pi); - histos.fill(HIST("hVar2pix"), sample, nCh, var2pi); - histos.fill(HIST("hVarpix"), sample, nChpi); - histos.fill(HIST("hVar2meanptpix"), nCh, var2pi); - - histos.fill(HIST("hVar1kx"), sample, nCh, var1k); - histos.fill(HIST("hVar2kx"), sample, nCh, var2k); - histos.fill(HIST("hVarkx"), sample, nChk); - histos.fill(HIST("hVar2meanptkx"), nCh, var2k); - - histos.fill(HIST("hVar1px"), sample, nCh, var1p); - histos.fill(HIST("hVar2px"), sample, nCh, var2p); - histos.fill(HIST("hVarpx"), sample, nChp); - histos.fill(HIST("hVar2meanptpx"), nCh, var2p); - - } // event loop ends! - - PROCESS_SWITCH(IdentifiedMeanPtFluctuations, process, "process real data information", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; - return workflow; -} diff --git a/PWGCF/EbyEFluctuations/Tasks/MeanptFluctuations.cxx b/PWGCF/EbyEFluctuations/Tasks/MeanptFluctuations.cxx index 99ed000b01a..e184f65c5a1 100644 --- a/PWGCF/EbyEFluctuations/Tasks/MeanptFluctuations.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/MeanptFluctuations.cxx @@ -9,32 +9,40 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include -#include -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/HistogramRegistry.h" +/// \file MeanptFluctuations.cxx +/// \brief Task for analyzing fluctuation upto fourth order of inclusive hadrons +/// \author Swati Saha -#include "Common/DataModel/EventSelection.h" #include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "CommonConstants/MathConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include + +#include "TF1.h" +#include "TH1D.h" +#include "TH2D.h" #include "TList.h" +#include "TMath.h" #include "TProfile.h" #include "TProfile2D.h" -#include "TH2D.h" -#include "TH1D.h" #include "TRandom3.h" -#include "TMath.h" -#include "TF1.h" + +#include +#include +#include +#include +#include +#include +#include namespace o2::aod { @@ -62,16 +70,23 @@ struct MeanptFluctuations_QA_QnTable { Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; Configurable cfgCutPtUpper{"cfgCutPtUpper", 3.0f, "Higher pT cut"}; Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; - // Configurable cfgCutTrackDcaXY{"cfgCutTrackDcaXY", 0.2f, "Maximum DcaXY"}; + Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; Configurable cfgCutTrackDcaZ{"cfgCutTrackDcaZ", 2.0f, "Maximum DcaZ"}; + Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; + Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; ConfigurableAxis nchAxis{"nchAxis", {5000, 0.5, 5000.5}, ""}; + Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; + Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; + Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; + Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; + Configurable cfgCentralityEstimator{"cfgCentralityEstimator", 1, "Centrlaity estimatore choice: 1-->FT0C, 2-->FT0A; 3-->FT0M, 4-->FV0A"}; O2_DEFINE_CONFIGURABLE(cfgUse22sEventCut, bool, true, "Use 22s event cut on mult correlations") // Filter command*********** Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; - Filter trackFilter = (nabs(aod::track::eta) < 0.8f) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutTrackDcaZ); - // Filter trackFilter = (nabs(aod::track::eta) < 0.8f) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (nabs(aod::track::dcaXY) < cfgCutTrackDcaZ) && (nabs(aod::track::dcaZ) < cfgCutTrackDcaZ); + Filter trackFilter = (nabs(aod::track::eta) < 0.8f) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && (requireGlobalTrackInFilter()) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutTrackDcaZ); // Connect to ccdb Service ccdb; @@ -81,7 +96,7 @@ struct MeanptFluctuations_QA_QnTable { HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; // filtering collisions and tracks*********** - using aodCollisions = soa::Filtered>; + using aodCollisions = soa::Filtered>; // using aodCollisions = soa::Filtered>; using aodTracks = soa::Filtered>; @@ -108,7 +123,7 @@ struct MeanptFluctuations_QA_QnTable { histos.add("hZvtx_after_sel", ";Z (cm)", kTH1F, {vtxZAxis}); histos.add("hP", ";#it{p} (GeV/#it{c})", kTH1F, {{35, 0.2, 4.}}); histos.add("hPt", ";#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); - histos.add("hPhi", ";#phi", kTH1F, {{100, 0., 2. * M_PI}}); + histos.add("hPhi", ";#phi", kTH1F, {{100, 0., o2::constants::math::TwoPI}}); histos.add("hEta", ";#eta", kTH1F, {{100, -2.01, 2.01}}); histos.add("hCentrality", ";centrality (%)", kTH1F, {{90, 0, 90}}); histos.add("hDcaXY", ";#it{dca}_{XY}", kTH1F, {{1000, -5, 5}}); @@ -144,7 +159,7 @@ struct MeanptFluctuations_QA_QnTable { float vtxz = -999; if (collision.numContrib() > 1) { vtxz = collision.posZ(); - float zRes = TMath::Sqrt(collision.covZZ()); + float zRes = std::sqrt(collision.covZZ()); if (zRes > 0.25 && collision.numContrib() < 20) vtxz = -999; } @@ -171,20 +186,44 @@ struct MeanptFluctuations_QA_QnTable { // void process(aod::Collision const& coll, aod::Tracks const& inputTracks) void process(aodCollisions::iterator const& coll, aod::BCsWithTimestamps const&, aodTracks const& inputTracks) { - if (!coll.sel8()) + if (!coll.sel8()) { + return; + } + if (cfgUseGoodITSLayerAllCut && !(coll.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))) { + return; + } + if (cfgEvSelkNoSameBunchPileup && !(coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + return; + } + if (cfgEvSelkNoITSROFrameBorder && !(coll.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + return; + } + if (cfgEvSelkNoTimeFrameBorder && !(coll.selection_bit(o2::aod::evsel::kNoTimeFrameBorder))) { return; + } const auto CentralityFT0C = coll.centFT0C(); if (cfgUse22sEventCut && !eventSelected(coll, inputTracks.size(), CentralityFT0C)) return; histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); - histos.fill(HIST("hCentrality"), coll.centFT0C()); + + double cent = 0.0; + if (cfgCentralityEstimator == 1) + cent = coll.centFT0C(); + else if (cfgCentralityEstimator == 2) + cent = coll.centFT0A(); + else if (cfgCentralityEstimator == 3) + cent = coll.centFT0M(); + else if (cfgCentralityEstimator == 4) + cent = coll.centFV0A(); + + histos.fill(HIST("hCentrality"), cent); + histos.fill(HIST("Hist2D_globalTracks_PVTracks"), coll.multNTracksPV(), inputTracks.size()); histos.fill(HIST("Hist2D_cent_nch"), inputTracks.size(), CentralityFT0C); // variables - double cent = coll.centFT0C(); double pT_sum = 0.0; double N = 0.0; @@ -194,7 +233,19 @@ struct MeanptFluctuations_QA_QnTable { float q4 = 0.0; float n_ch = 0.0; - for (auto track : inputTracks) { // Loop over tracks + for (const auto& track : inputTracks) { // Loop over tracks + + if (!track.has_collision()) { + continue; + } + + if (!track.isPVContributor()) { + continue; + } + + if (!(track.itsNCls() > cfgITScluster) || !(track.tpcNClsFound() >= cfgTPCcluster) || !(track.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) { + continue; + } histos.fill(HIST("hP"), track.p()); histos.fill(HIST("hPt"), track.pt()); @@ -209,10 +260,10 @@ struct MeanptFluctuations_QA_QnTable { float pT = track.pt(); // calculating Q1, Q2, Q3, Q4. N_ch if (track.pt() > cfgCutPtLower && track.pt() < cfgCutPtUpper && track.sign() != 0) { - q1 = q1 + pow(pT, 1.0); - q2 = q2 + pow(pT, 2.0); - q3 = q3 + pow(pT, 3.0); - q4 = q4 + pow(pT, 4.0); + q1 = q1 + std::pow(pT, 1.0); + q2 = q2 + std::pow(pT, 2.0); + q3 = q3 + std::pow(pT, 3.0); + q4 = q4 + std::pow(pT, 4.0); n_ch = n_ch + 1; } } @@ -280,9 +331,9 @@ struct MeanptFluctuations_analysis { // calculating observables mean_term1 = event_ptqn.q1() / event_ptqn.n_ch(); - variance_term1 = (TMath::Power(event_ptqn.q1(), 2.0f) - event_ptqn.q2()) / (event_ptqn.n_ch() * (event_ptqn.n_ch() - 1.0f)); - skewness_term1 = (TMath::Power(event_ptqn.q1(), 3.0f) - 3.0f * event_ptqn.q2() * event_ptqn.q1() + 2.0f * event_ptqn.q3()) / (event_ptqn.n_ch() * (event_ptqn.n_ch() - 1.0f) * (event_ptqn.n_ch() - 2.0f)); - kurtosis_term1 = (TMath::Power(event_ptqn.q1(), 4.0f) - (6.0f * event_ptqn.q4()) + (8.0f * event_ptqn.q1() * event_ptqn.q3()) - (6.0f * TMath::Power(event_ptqn.q1(), 2.0f) * event_ptqn.q2()) + (3.0f * TMath::Power(event_ptqn.q2(), 2.0f))) / (event_ptqn.n_ch() * (event_ptqn.n_ch() - 1.0f) * (event_ptqn.n_ch() - 2.0f) * (event_ptqn.n_ch() - 3.0f)); + variance_term1 = (std::pow(event_ptqn.q1(), 2.0f) - event_ptqn.q2()) / (event_ptqn.n_ch() * (event_ptqn.n_ch() - 1.0f)); + skewness_term1 = (std::pow(event_ptqn.q1(), 3.0f) - 3.0f * event_ptqn.q2() * event_ptqn.q1() + 2.0f * event_ptqn.q3()) / (event_ptqn.n_ch() * (event_ptqn.n_ch() - 1.0f) * (event_ptqn.n_ch() - 2.0f)); + kurtosis_term1 = (std::pow(event_ptqn.q1(), 4.0f) - (6.0f * event_ptqn.q4()) + (8.0f * event_ptqn.q1() * event_ptqn.q3()) - (6.0f * std::pow(event_ptqn.q1(), 2.0f) * event_ptqn.q2()) + (3.0f * std::pow(event_ptqn.q2(), 2.0f))) / (event_ptqn.n_ch() * (event_ptqn.n_ch() - 1.0f) * (event_ptqn.n_ch() - 2.0f) * (event_ptqn.n_ch() - 3.0f)); // filling profiles and histograms for central values registry.get(HIST("Prof_mean_t1"))->Fill(event_ptqn.centrality(), event_ptqn.n_ch(), mean_term1); diff --git a/PWGCF/EbyEFluctuations/Tasks/antiprotonCumulantsMc.cxx b/PWGCF/EbyEFluctuations/Tasks/antiprotonCumulantsMc.cxx new file mode 100644 index 00000000000..f0398450cae --- /dev/null +++ b/PWGCF/EbyEFluctuations/Tasks/antiprotonCumulantsMc.cxx @@ -0,0 +1,2950 @@ +// 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. + +/// \file antiprotonCumulantsMc.cxx +/// \brief Task for analyzing efficiency of proton, and net-proton distributions in MC reconstructed and generated, and calculating net-proton cumulants +/// \author Swati Saha + +#include +#include +#include +#include +#include +#include +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/StepTHn.h" +#include "ReconstructionDataFormats/Track.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/Core/trackUtilities.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct AntiprotonCumulantsMc { + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + // MC + Configurable cfgIsMC{"cfgIsMC", true, "Run MC"}; + // tracks + Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtUpper{"cfgCutPtUpper", 3.0f, "Higher pT cut"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; + Configurable cfgPIDchoice{"cfgPIDchoice", 1, "PID selection fucntion choice"}; + Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; + Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; + Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; + Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; + Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; + Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; + Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; + Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; + Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; + Configurable cfgUseItsPid{"cfgUseItsPid", true, "Use ITS nSigma Cut"}; + + // Calculation of cumulants central/error + Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples for ERR"}; + Configurable cfgIsCalculateCentral{"cfgIsCalculateCentral", true, "Calculate Central value"}; + Configurable cfgIsCalculateError{"cfgIsCalculateError", false, "Calculate Error"}; + + // Efficiencies + Configurable> cfgPtBins{"cfgPtBins", {0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0}, "Pt Bins for Efficiency of protons"}; + Configurable> cfgProtonEff{"cfgProtonEff", {0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9}, "Efficiency of protons"}; + Configurable> cfgAntiprotonEff{"cfgAntiprotonEff", {0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9}, "Efficiency of anti-protons"}; + + Configurable cfgLoadEff{"cfgLoadEff", true, "Load efficiency from file"}; + Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; + Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; + Configurable cfgIfRejectElectron{"cfgIfRejectElectron", true, "Remove electrons"}; + Configurable cfgIfMandatoryTOF{"cfgIfMandatoryTOF", true, "Mandatory TOF requirement to remove pileup"}; + Configurable cfgEvSelkIsVertexTOFmatched{"cfgEvSelkIsVertexTOFmatched", true, "If matched with TOF, for pileup"}; + ConfigurableAxis cfgCentralityBins{"cfgCentralityBins", {90, 0., 90.}, "Centrality/Multiplicity percentile bining"}; + + // Connect to ccdb + Service ccdb; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable ccdbUrl{"ccdbUrl", "https://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPath{"ccdbPath", "Users/s/swati/EtavsPtEfficiency_LHC24f3b_PIDchoice0", "CCDB path to ccdb object containing eff(pt, eta) in 2D hist"}; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + TRandom3* fRndm = new TRandom3(0); + + // Eff histograms 2d: eff(pT, eta) + TH2F* hRatio2DEtaVsPtProton = nullptr; + TH2F* hRatio2DEtaVsPtAntiproton = nullptr; + + // Filter command for rec (data)*********** + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy); + + // filtering collisions and tracks for real data*********** + using AodCollisions = soa::Filtered>; + using AodTracks = soa::Filtered>; + + // filtering collisions and tracks for MC rec data*********** + using MyMCRecCollisions = soa::Filtered>; + using MyMCRecCollision = MyMCRecCollisions::iterator; + using MyMCTracks = soa::Filtered>; + using EventCandidatesMC = soa::Join; + + // Equivalent of the AliRoot task UserCreateOutputObjects + void init(o2::framework::InitContext&) + { + // Loading efficiency histograms from ccdb + if (cfgLoadEff) { + + // Accessing eff histograms + ccdb->setURL(ccdbUrl.value); + // Enabling object caching, otherwise each call goes to the CCDB server + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + // Not later than now, will be replaced by the value of the train creation + // This avoids that users can replace objects **while** a train is running + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + LOGF(info, "Getting object %s", ccdbPath.value.data()); + TList* lst = ccdb->getForTimeStamp(ccdbPath.value, ccdbNoLaterThan.value); + hRatio2DEtaVsPtProton = reinterpret_cast(lst->FindObject("hRatio2DEtaVsPtProton")); + hRatio2DEtaVsPtAntiproton = reinterpret_cast(lst->FindObject("hRatio2DEtaVsPtAntiproton")); + if (!hRatio2DEtaVsPtProton || !hRatio2DEtaVsPtAntiproton) + LOGF(info, "FATAL!! could not get efficiency---------> check"); + } + + // Define your axes + // Constant bin width axis + AxisSpec vtxZAxis = {100, -20, 20}; + // Variable bin width axis + std::vector ptBinning = {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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0}; + AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/#it{c})"}; + std::vector etaBinning = {-0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; + AxisSpec etaAxis = {etaBinning, "#it{#eta}"}; + // std::vector centBining = {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90}; + // AxisSpec centAxis = {centBining, "Multiplicity percentile from FT0M (%)"}; + const AxisSpec centAxis{cfgCentralityBins, "Multiplicity percentile from FT0M (%)"}; + AxisSpec netprotonAxis = {41, -20.5, 20.5, "net-proton number"}; + AxisSpec protonAxis = {21, -0.5, 20.5, "proton number"}; + AxisSpec antiprotonAxis = {21, -0.5, 20.5, "antiproton number"}; + AxisSpec nSigmaAxis = {200, -5.0, 5.0, "nSigma(Proton)"}; + + auto noSubsample = static_cast(cfgNSubsample); + float maxSubsample = 1.0 * noSubsample; + AxisSpec subsampleAxis = {noSubsample, 0.0, maxSubsample, "subsample no."}; + + // histograms for events + histos.add("hZvtx_after_sel", "Vertex dist. after event selection;Z (cm)", kTH1F, {vtxZAxis}); + histos.add("hCentrec", "MCRec Multiplicity percentile from FT0M (%)", kTH1F, {{100, 0.0, 100.0}}); + // tracks Rec level histograms + histos.add("hrecPtAll", "Reconstructed All particles;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPtProton", "Reconstructed Protons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPtAntiproton", "Reconstructed Antiprotons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPhiAll", "Reconstructed All particles;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hrecPhiProton", "Reconstructed Protons;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hrecPhiAntiproton", "Reconstructed Antiprotons;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hrecEtaAll", "Reconstructed All particles;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hrecEtaProton", "Reconstructed Proton;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hrecEtaAntiproton", "Reconstructed Antiprotons;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hrecDcaXYAll", "Reconstructed All particles;DCA_{xy} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaXYProton", "Reconstructed Proton;DCA_{xy} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaXYAntiproton", "Reconstructed Antiprotons;DCA_{xy} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaZAll", "Reconstructed All particles;DCA_{z} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaZProton", "Reconstructed Proton;DCA_{z} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaZAntiproton", "Reconstructed Antiprotons;DCA_{z} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecPtDistProtonVsCentrality", "Reconstructed proton number vs centrality in 2D", kTH2F, {ptAxis, centAxis}); + histos.add("hrecPtDistAntiprotonVsCentrality", "Reconstructed antiproton number vs centrality in 2D", kTH2F, {ptAxis, centAxis}); + + histos.add("hrecProtonVsCentrality", "Reconstructed proton number vs centrality in 2D", kTH2F, {protonAxis, centAxis}); + histos.add("hrecAntiprotonVsCentrality", "Reconstructed antiproton number vs centrality in 2D", kTH2F, {antiprotonAxis, centAxis}); + histos.add("hrecProfileTotalProton", "Reconstructed total proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hrecProfileProton", "Reconstructed proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hrecProfileAntiproton", "Reconstructed antiproton number vs. centrality", kTProfile, {centAxis}); + histos.add("hCorrProfileTotalProton", "Eff. Corrected total proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hCorrProfileProton", "Eff. Corrected proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hCorrProfileAntiproton", "Eff. Corrected antiproton number vs. centrality", kTProfile, {centAxis}); + histos.add("hrec2DEtaVsPtProton", "2D hist of Reconstructed Proton y: eta vs. x: pT", kTH2F, {ptAxis, etaAxis}); + histos.add("hrec2DEtaVsPtAntiproton", "2D hist of Reconstructed Anti-proton y: eta vs. x: pT", kTH2F, {ptAxis, etaAxis}); + histos.add("hgen2DEtaVsPtProton", "2D hist of Generated Proton y: eta vs. x: pT", kTH2F, {ptAxis, etaAxis}); + histos.add("hgen2DEtaVsPtAntiproton", "2D hist of Generated Anti-proton y: eta vs. x: pT", kTH2F, {ptAxis, etaAxis}); + + // 2D histograms of nSigma + histos.add("h2DnsigmaTpcVsPt", "2D hist of nSigmaTPC vs. pT", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaTofVsPt", "2D hist of nSigmaTOF vs. pT", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaItsVsPt", "2D hist of nSigmaITS vs. pT", kTH2F, {ptAxis, nSigmaAxis}); + + if (cfgIsCalculateCentral) { + // uncorrected + histos.add("Prof_mu1_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu2_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu3_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu4_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu5_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu6_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu7_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu8_antiproton", "", {HistType::kTProfile, {centAxis}}); + + // eff. corrected + histos.add("Prof_Q11_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_3", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_4", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q21_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q22_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q31_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q32_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q33_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q41_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q42_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q43_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q44_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q21_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q22_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3132_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3132_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3132_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3133_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3133_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3133_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3233_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3233_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3233_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2241_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2241_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2241_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2242_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2242_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2242_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2243_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2243_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2243_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2244_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2244_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2244_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2141_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2141_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2141_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2142_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2142_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2142_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2143_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2143_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2143_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2144_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2144_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2144_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1151_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1151_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1151_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1152_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1152_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1152_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1153_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1153_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1153_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1154_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1154_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1154_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1155_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1155_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1155_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_02", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_12", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_22", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_02", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_12", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_22", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_200", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_201", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_210", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_211", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_5", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_6", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_40", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_41", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_40", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_41", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2131_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2131_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2131_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2132_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2132_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2132_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2133_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2133_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2133_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2231_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2231_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2231_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2232_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2232_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2232_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2233_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2233_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2233_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q51_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q52_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q53_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q54_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q55_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q21_3", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q22_3", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q31_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q32_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q33_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q61_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q62_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q63_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q64_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q65_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q66_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_111", "", {HistType::kTProfile, {centAxis}}); + } + + if (cfgIsCalculateError) { + // uncorrected + histos.add("Prof2D_mu1_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu2_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu3_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu4_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu5_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu6_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu7_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu8_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + + // eff. corrected + histos.add("Prof2D_Q11_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_3", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_4", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q21_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q22_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q31_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q32_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q33_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q41_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q42_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q43_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q44_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q21_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q22_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3132_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3132_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3132_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3133_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3133_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3133_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3233_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3233_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3233_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2241_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2241_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2241_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2242_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2242_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2242_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2243_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2243_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2243_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2244_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2244_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2244_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2141_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2141_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2141_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2142_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2142_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2142_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2143_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2143_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2143_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2144_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2144_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2144_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1151_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1151_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1151_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1152_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1152_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1152_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1153_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1153_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1153_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1154_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1154_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1154_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1155_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1155_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1155_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_02", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_12", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_22", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_02", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_12", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_22", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_200", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_201", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_210", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_211", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_5", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_6", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_40", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_41", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_40", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_41", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2131_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2131_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2131_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2132_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2132_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2132_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2133_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2133_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2133_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2231_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2231_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2231_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2232_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2232_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2232_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2233_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2233_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2233_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q51_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q52_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q53_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q54_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q55_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q21_3", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q22_3", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q31_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q32_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q33_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q61_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q62_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q63_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q64_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q65_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q66_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + } + + if (cfgIsMC) { + // MC event counts + histos.add("hMC", "MC Event statistics", kTH1F, {{10, 0.0f, 10.0f}}); + histos.add("hCentgen", "MCGen Multiplicity percentile from FT0M (%)", kTH1F, {{100, 0.0, 100.0}}); + // tracks Gen level histograms + histos.add("hgenPtAll", "Generated All particles;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hgenPtProton", "Generated Protons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hgenPtAntiproton", "Generated Antiprotons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPartPtAll", "Reconstructed All particles filled mcparticle pt;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPartPtProton", "Reconstructed Protons filled mcparticle pt;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPartPtAntiproton", "Reconstructed Antiprotons filled mcparticle pt;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hgenPhiAll", "Generated All particles;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hgenPhiProton", "Generated Protons;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hgenPhiAntiproton", "Generated Antiprotons;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hgenEtaAll", "Generated All particles;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hgenEtaProton", "Generated Proton;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hgenEtaAntiproton", "Generated Antiprotons;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hgenPtDistProtonVsCentrality", "Generated proton number vs centrality in 2D", kTH2F, {ptAxis, centAxis}); + histos.add("hgenPtDistAntiprotonVsCentrality", "Generated antiproton number vs centrality in 2D", kTH2F, {ptAxis, centAxis}); + histos.add("hrecTruePtProton", "Reconstructed pdgcode verified protons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecTruePtAntiproton", "Reconstructed pdgcode verified Antiprotons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + + histos.add("hgenProtonVsCentrality", "Generated proton number vs centrality in 2D", kTH2F, {protonAxis, centAxis}); + histos.add("hgenAntiprotonVsCentrality", "Generated antiproton number vs centrality in 2D", kTH2F, {antiprotonAxis, centAxis}); + histos.add("hgenProfileTotalProton", "Generated total proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hgenProfileProton", "Generated proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hgenProfileAntiproton", "Generated antiproton number vs. centrality", kTProfile, {centAxis}); + + if (cfgIsCalculateCentral) { + histos.add("GenProf_mu1_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu2_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu3_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu4_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu5_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu6_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu7_antiproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu8_antiproton", "", {HistType::kTProfile, {centAxis}}); + } + + if (cfgIsCalculateError) { + histos.add("GenProf2D_mu1_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu2_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu3_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu4_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu5_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu6_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu7_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu8_antiproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + } + } + } // end init() + + template + bool selectionPIDold(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + + //! PID checking as done in Run2 my analysis + //! ---------------------------------------------------------------------- + int flag = 0; //! pid check main flag + + if (candidate.pt() > 0.2f && candidate.pt() <= cfgCutPtUpperTPC) { + if (std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < 5.0f) { + const float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + const float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + const float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < 3.0) + flag2 += 1; + if (combNSigmaPi < 3.0) + flag2 += 1; + if (combNSigmaKa < 3.0) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { + if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + template + bool selectionPIDoldTOFveto(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + + //! PID checking as done in Run2 my analysis + //! ---------------------------------------------------------------------- + int flag = 0; //! pid check main flag + + if (candidate.pt() > 0.2f && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < 5.0f) { + const float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + const float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + const float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < 3.0) + flag2 += 1; + if (combNSigmaPi < 3.0) + flag2 += 1; + if (combNSigmaKa < 3.0) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { + if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + // electron rejection function + template + bool isElectron(const T& candidate) // Victor's BF analysis + { + if (candidate.tpcNSigmaEl() > -3.0f && candidate.tpcNSigmaEl() < 5.0f && std::abs(candidate.tpcNSigmaPi()) > 3.0f && std::abs(candidate.tpcNSigmaKa()) > 3.0f && std::abs(candidate.tpcNSigmaPr()) > 3.0f) { + return true; + } + return false; + } + + template + bool selectionPIDnew(const T& candidate) // Victor's BF analysis + { + // electron rejection + if (candidate.tpcNSigmaEl() > -3.0f && candidate.tpcNSigmaEl() < 5.0f && std::abs(candidate.tpcNSigmaPi()) > 3.0f && std::abs(candidate.tpcNSigmaKa()) > 3.0f && std::abs(candidate.tpcNSigmaPr()) > 3.0f) { + return false; + } + + //! if pt < threshold + if (candidate.pt() > 0.2f && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaPi()) > cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaKa()) > cfgnSigmaCutTPC) { + return true; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaPi()) > cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaKa()) > cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF && std::abs(candidate.tofNSigmaPi()) > cfgnSigmaCutTOF && std::abs(candidate.tofNSigmaKa()) > cfgnSigmaCutTOF) { + return true; + } + } + + //! if pt > threshold + if (candidate.pt() > cfgCutPtUpperTPC) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaPi()) > cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaKa()) > cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF && std::abs(candidate.tofNSigmaPi()) > cfgnSigmaCutTOF && std::abs(candidate.tofNSigmaKa()) > cfgnSigmaCutTOF) { + return true; + } + } + return false; + } + + // Function to check which pt bin the track lies in and assign the corresponding efficiency + + template + float getEfficiency(const T& candidate) + { + // Load eff from histograms in CCDB + if (cfgLoadEff) { + if (candidate.sign() > 0) { + float effmeanval = hRatio2DEtaVsPtProton->GetBinContent(hRatio2DEtaVsPtProton->FindBin(candidate.pt(), candidate.eta())); + return effmeanval; + } + if (candidate.sign() < 0) { + float effmeanval = hRatio2DEtaVsPtAntiproton->GetBinContent(hRatio2DEtaVsPtAntiproton->FindBin(candidate.pt(), candidate.eta())); + return effmeanval; + } + return 0.0; + } else { + // Find the pt bin index based on the track's pt value + int binIndex = -1; + + for (int i = 0; i < 16; ++i) { + if (candidate.pt() >= cfgPtBins.value[i] && candidate.pt() < cfgPtBins.value[i + 1]) { + binIndex = i; + break; + } + } + // If the pt is outside the defined bins, return a default efficiency or handle it differently + if (binIndex == -1) { + return 0.0; // Default efficiency (0% if outside bins) + } + if (candidate.sign() > 0) + return cfgProtonEff.value[binIndex]; + if (candidate.sign() < 0) + return cfgAntiprotonEff.value[binIndex]; + return 0.0; + } + } + + void processMCGen(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& collisions) + { + histos.fill(HIST("hMC"), 0.5); + if (std::abs(mcCollision.posZ()) < cfgCutVertex) { + histos.fill(HIST("hMC"), 1.5); + } + auto cent = 0; + + int nchInel = 0; + for (const auto& mcParticle : mcParticles) { + auto pdgcode = std::abs(mcParticle.pdgCode()); + if (mcParticle.isPhysicalPrimary() && (pdgcode == PDG_t::kPiPlus || pdgcode == PDG_t::kKPlus || pdgcode == PDG_t::kProton || pdgcode == PDG_t::kElectron || pdgcode == PDG_t::kMuonMinus)) { + if (std::abs(mcParticle.eta()) < 1.0) { + nchInel = nchInel + 1; + } + } + } + if (nchInel > 0 && std::abs(mcCollision.posZ()) < cfgCutVertex) + histos.fill(HIST("hMC"), 2.5); + std::vector selectedEvents(collisions.size()); + int nevts = 0; + + for (const auto& collision : collisions) { + if (!collision.sel8() || std::abs(collision.mcCollision().posZ()) > cfgCutVertex) { + continue; + } + if (cfgUseGoodITSLayerAllCut && !(collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))) { + continue; + } + if (cfgEvSelkNoSameBunchPileup && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + continue; + } + if (cfgEvSelkIsVertexTOFmatched && !(collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched))) { + continue; + } + + cent = collision.centFT0M(); + + selectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); + } + selectedEvents.resize(nevts); + const auto evtReconstructedAndSelected = std::find(selectedEvents.begin(), selectedEvents.end(), mcCollision.globalIndex()) != selectedEvents.end(); + histos.fill(HIST("hMC"), 3.5); + if (!evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection + return; + } + histos.fill(HIST("hMC"), 4.5); + histos.fill(HIST("hCentgen"), cent); + + // creating phi, pt, eta dstribution of generted MC particles + + float nProt = 0.0; + float nAntiprot = 0.0; + + for (const auto& mcParticle : mcParticles) { + if (!mcParticle.has_mcCollision()) + continue; + + if (mcParticle.isPhysicalPrimary()) { + if ((mcParticle.pt() > cfgCutPtLower) && (mcParticle.pt() < 5.0f) && (std::abs(mcParticle.eta()) < cfgCutEta)) { + histos.fill(HIST("hgenPtAll"), mcParticle.pt()); + histos.fill(HIST("hgenEtaAll"), mcParticle.eta()); + histos.fill(HIST("hgenPhiAll"), mcParticle.phi()); + + if (std::abs(mcParticle.pdgCode()) == PDG_t::kProton /*&& std::abs(mcParticle.y()) < 0.5*/) { + if (mcParticle.pdgCode() == PDG_t::kProton) { + histos.fill(HIST("hgenPtProton"), mcParticle.pt()); //! hist for p gen + histos.fill(HIST("hgenPtDistProtonVsCentrality"), mcParticle.pt(), cent); + histos.fill(HIST("hgen2DEtaVsPtProton"), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hgenEtaProton"), mcParticle.eta()); + histos.fill(HIST("hgenPhiProton"), mcParticle.phi()); + if (mcParticle.pt() < cfgCutPtUpper) + nProt = nProt + 1.0; + } + if (mcParticle.pdgCode() == PDG_t::kProtonBar) { + histos.fill(HIST("hgenPtAntiproton"), mcParticle.pt()); //! hist for anti-p gen + histos.fill(HIST("hgenPtDistAntiprotonVsCentrality"), mcParticle.pt(), cent); + histos.fill(HIST("hgen2DEtaVsPtAntiproton"), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hgenEtaAntiproton"), mcParticle.eta()); + histos.fill(HIST("hgenPhiAntiproton"), mcParticle.phi()); + if (mcParticle.pt() < cfgCutPtUpper) + nAntiprot = nAntiprot + 1.0; + } + } + } + } + } //! end particle loop + + float netProt = nAntiprot; // here we are interested in antiproton cumulants + + histos.fill(HIST("hgenProtonVsCentrality"), nProt, cent); + histos.fill(HIST("hgenAntiprotonVsCentrality"), nAntiprot, cent); + histos.fill(HIST("hgenProfileTotalProton"), cent, (nProt + nAntiprot)); + histos.fill(HIST("hgenProfileProton"), cent, nProt); + histos.fill(HIST("hgenProfileAntiproton"), cent, nAntiprot); + + // Profiles for generated level cumulants + //------------------------------------------------------------------------------------------- + + if (cfgIsCalculateCentral) { + histos.get(HIST("GenProf_mu1_antiproton"))->Fill(cent, std::pow(netProt, 1.0)); + histos.get(HIST("GenProf_mu2_antiproton"))->Fill(cent, std::pow(netProt, 2.0)); + histos.get(HIST("GenProf_mu3_antiproton"))->Fill(cent, std::pow(netProt, 3.0)); + histos.get(HIST("GenProf_mu4_antiproton"))->Fill(cent, std::pow(netProt, 4.0)); + histos.get(HIST("GenProf_mu5_antiproton"))->Fill(cent, std::pow(netProt, 5.0)); + histos.get(HIST("GenProf_mu6_antiproton"))->Fill(cent, std::pow(netProt, 6.0)); + histos.get(HIST("GenProf_mu7_antiproton"))->Fill(cent, std::pow(netProt, 7.0)); + histos.get(HIST("GenProf_mu8_antiproton"))->Fill(cent, std::pow(netProt, 8.0)); + } + + if (cfgIsCalculateError) { + + float lRandom = fRndm->Rndm(); + int sampleIndex = static_cast(cfgNSubsample * lRandom); + + histos.get(HIST("GenProf2D_mu1_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 1.0)); + histos.get(HIST("GenProf2D_mu2_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 2.0)); + histos.get(HIST("GenProf2D_mu3_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 3.0)); + histos.get(HIST("GenProf2D_mu4_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 4.0)); + histos.get(HIST("GenProf2D_mu5_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 5.0)); + histos.get(HIST("GenProf2D_mu6_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 6.0)); + histos.get(HIST("GenProf2D_mu7_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 7.0)); + histos.get(HIST("GenProf2D_mu8_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 8.0)); + } + //------------------------------------------------------------------------------------------- + } + PROCESS_SWITCH(AntiprotonCumulantsMc, processMCGen, "Process Generated", true); + + void processMCRec(MyMCRecCollision const& collision, MyMCTracks const& tracks, aod::McCollisions const&, aod::McParticles const&) + { + if (!collision.has_mcCollision()) { + return; + } + + if (!collision.sel8()) { + return; + } + if (cfgUseGoodITSLayerAllCut && !(collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))) { + return; + } + if (cfgEvSelkNoSameBunchPileup && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + return; + } + if (cfgEvSelkIsVertexTOFmatched && !(collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched))) { + return; + ; + } + + auto cent = collision.centFT0M(); + histos.fill(HIST("hCentrec"), cent); + histos.fill(HIST("hMC"), 5.5); + histos.fill(HIST("hZvtx_after_sel"), collision.posZ()); + + float nProt = 0.0; + float nAntiprot = 0.0; + std::array powerEffProt = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array powerEffAntiprot = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array fTCP0 = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array fTCP1 = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + + o2::aod::ITSResponse itsResponse; + + // Start of the Monte-Carlo reconstructed tracks + for (const auto& track : tracks) { + if (!track.has_collision()) { + continue; + } + + if (!track.has_mcParticle()) //! check if track has corresponding MC particle + { + continue; + } + if (!track.isPVContributor()) //! track check as used in data + { + continue; + } + + auto particle = track.mcParticle(); + if (!particle.has_mcCollision()) + continue; + + if ((particle.pt() < cfgCutPtLower) || (particle.pt() > 5.0f) || (std::abs(particle.eta()) > cfgCutEta)) { + continue; + } + if (!(track.itsNCls() > cfgITScluster) || !(track.tpcNClsFound() >= cfgTPCcluster) || !(track.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) { + continue; + } + + if (particle.isPhysicalPrimary()) { + histos.fill(HIST("hrecPartPtAll"), particle.pt()); + histos.fill(HIST("hrecPtAll"), track.pt()); + histos.fill(HIST("hrecEtaAll"), particle.eta()); + histos.fill(HIST("hrecPhiAll"), particle.phi()); + histos.fill(HIST("hrecDcaXYAll"), track.dcaXY()); + histos.fill(HIST("hrecDcaZAll"), track.dcaZ()); + + // rejecting electron + if (cfgIfRejectElectron && isElectron(track)) { + continue; + } + // use ITS pid as well + if (cfgUseItsPid && (std::abs(itsResponse.nSigmaITS(track)) > 3.0)) { + continue; + } + // required tracks with TOF mandatory to avoid pileup + if (cfgIfMandatoryTOF && !track.hasTOF()) { + continue; + } + + bool trackSelected = false; + if (cfgPIDchoice == 0) + trackSelected = selectionPIDoldTOFveto(track); + if (cfgPIDchoice == 1) + trackSelected = selectionPIDnew(track); + if (cfgPIDchoice == 2) + trackSelected = selectionPIDold(track); + + if (trackSelected) { + // filling nSigma distribution + histos.fill(HIST("h2DnsigmaTpcVsPt"), track.pt(), track.tpcNSigmaPr()); + histos.fill(HIST("h2DnsigmaTofVsPt"), track.pt(), track.tofNSigmaPr()); + histos.fill(HIST("h2DnsigmaItsVsPt"), track.pt(), itsResponse.nSigmaITS(track)); + + if (track.sign() > 0) { + histos.fill(HIST("hrecPartPtProton"), particle.pt()); //! hist for p rec + histos.fill(HIST("hrecPtProton"), track.pt()); //! hist for p rec + histos.fill(HIST("hrecPtDistProtonVsCentrality"), particle.pt(), cent); + histos.fill(HIST("hrec2DEtaVsPtProton"), particle.pt(), particle.eta()); + histos.fill(HIST("hrecEtaProton"), particle.eta()); + histos.fill(HIST("hrecPhiProton"), particle.phi()); + histos.fill(HIST("hrecDcaXYProton"), track.dcaXY()); + histos.fill(HIST("hrecDcaZProton"), track.dcaZ()); + if (particle.pt() < cfgCutPtUpper) { + nProt = nProt + 1.0; + float pEff = getEfficiency(track); // get efficiency of track + if (pEff != 0) { + for (int i = 1; i < 7; i++) { + powerEffProt[i] += std::pow(1.0 / pEff, i); + } + } + } + if (particle.pdgCode() == PDG_t::kProton) { + histos.fill(HIST("hrecTruePtProton"), particle.pt()); //! hist for p purity + } + } + if (track.sign() < 0) { + histos.fill(HIST("hrecPartPtAntiproton"), particle.pt()); //! hist for anti-p rec + histos.fill(HIST("hrecPtAntiproton"), track.pt()); //! hist for anti-p rec + histos.fill(HIST("hrecPtDistAntiprotonVsCentrality"), particle.pt(), cent); + histos.fill(HIST("hrec2DEtaVsPtAntiproton"), particle.pt(), particle.eta()); + histos.fill(HIST("hrecEtaAntiproton"), particle.eta()); + histos.fill(HIST("hrecPhiAntiproton"), particle.phi()); + histos.fill(HIST("hrecDcaXYAntiproton"), track.dcaXY()); + histos.fill(HIST("hrecDcaZAntiproton"), track.dcaZ()); + if (particle.pt() < cfgCutPtUpper) { + nAntiprot = nAntiprot + 1.0; + float pEff = getEfficiency(track); // get efficiency of track + if (pEff != 0) { + for (int i = 1; i < 7; i++) { + powerEffAntiprot[i] += std::pow(1.0 / pEff, i); + } + } + } + if (particle.pdgCode() == PDG_t::kProtonBar) { + histos.fill(HIST("hrecTruePtAntiproton"), particle.pt()); //! hist for anti-p purity + } + } + } //! checking PID + } //! checking if primary + } //! end track loop + + float netProt = nAntiprot; + + histos.fill(HIST("hrecProtonVsCentrality"), nProt, cent); + histos.fill(HIST("hrecAntiprotonVsCentrality"), nAntiprot, cent); + histos.fill(HIST("hrecProfileTotalProton"), cent, (nProt + nAntiprot)); + histos.fill(HIST("hrecProfileProton"), cent, nProt); + histos.fill(HIST("hrecProfileAntiproton"), cent, nAntiprot); + histos.fill(HIST("hCorrProfileTotalProton"), cent, (powerEffProt[1] + powerEffAntiprot[1])); + histos.fill(HIST("hCorrProfileProton"), cent, powerEffProt[1]); + histos.fill(HIST("hCorrProfileAntiproton"), cent, powerEffAntiprot[1]); + + // Calculating q_{r,s} as required + for (int i = 1; i < 7; i++) { + fTCP0[i] = 0.0 + powerEffAntiprot[i]; + fTCP1[i] = 0.0 - powerEffAntiprot[i]; + } + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + float fQ11_1 = fTCP1[1]; + float fQ11_2 = std::pow(fTCP1[1], 2); + float fQ11_3 = std::pow(fTCP1[1], 3); + float fQ11_4 = std::pow(fTCP1[1], 4); + float fQ11_5 = std::pow(fTCP1[1], 5); + float fQ11_6 = std::pow(fTCP1[1], 6); + + float fQ21_3 = std::pow(fTCP0[1], 3); + float fQ22_3 = std::pow(fTCP0[2], 3); + float fQ31_2 = std::pow(fTCP1[1], 2); + float fQ32_2 = std::pow(fTCP1[2], 2); + float fQ33_2 = std::pow(fTCP1[3], 2); + + float fQ61_1 = fTCP0[1]; + float fQ62_1 = fTCP0[2]; + float fQ63_1 = fTCP0[3]; + float fQ64_1 = fTCP0[4]; + float fQ65_1 = fTCP0[5]; + float fQ66_1 = fTCP0[6]; + + float fQ112122_111 = fTCP1[1] * fTCP0[1] * fTCP0[2]; + float fQ112131_111 = fTCP1[1] * fTCP0[1] * fTCP1[1]; + float fQ112132_111 = fTCP1[1] * fTCP0[1] * fTCP1[2]; + float fQ112133_111 = fTCP1[1] * fTCP0[1] * fTCP1[3]; + float fQ112231_111 = fTCP1[1] * fTCP0[2] * fTCP1[1]; + float fQ112232_111 = fTCP1[1] * fTCP0[2] * fTCP1[2]; + float fQ112233_111 = fTCP1[1] * fTCP0[2] * fTCP1[3]; + float fQ112221_111 = fTCP1[1] * fTCP0[2] * fTCP0[1]; + + float fQ21_1 = fTCP0[1]; + float fQ22_1 = fTCP0[2]; + float fQ31_1 = fTCP1[1]; + float fQ32_1 = fTCP1[2]; + float fQ33_1 = fTCP1[3]; + float fQ41_1 = fTCP0[1]; + float fQ42_1 = fTCP0[2]; + float fQ43_1 = fTCP0[3]; + float fQ44_1 = fTCP0[4]; + float fQ21_2 = std::pow(fTCP0[1], 2); + float fQ22_2 = std::pow(fTCP0[2], 2); + float fQ1121_11 = fTCP1[1] * fTCP0[1]; + float fQ1121_01 = fTCP0[1]; + float fQ1121_10 = fTCP1[1]; + float fQ1121_20 = std::pow(fTCP1[1], 2); + float fQ1121_21 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ1122_11 = fTCP1[1] * fTCP0[2]; + float fQ1122_01 = fTCP0[2]; + float fQ1122_10 = fTCP1[1]; + float fQ1122_20 = std::pow(fTCP1[1], 2); + float fQ1122_21 = std::pow(fTCP1[1], 2) * fTCP0[2]; + float fQ1131_11 = fTCP1[1] * fTCP1[1]; + float fQ1131_01 = fTCP1[1]; + float fQ1131_10 = fTCP1[1]; + float fQ1132_11 = fTCP1[1] * fTCP1[2]; + float fQ1132_01 = fTCP1[2]; + float fQ1132_10 = fTCP1[1]; + float fQ1133_11 = fTCP1[1] * fTCP1[3]; + float fQ1133_01 = fTCP1[3]; + float fQ1133_10 = fTCP1[1]; + float fQ2122_11 = fTCP0[1] * fTCP0[2]; + float fQ2122_01 = fTCP0[2]; + float fQ2122_10 = fTCP0[1]; + + ///////////////---------------------> + float fQ3132_11 = fTCP1[1] * fTCP1[2]; + float fQ3132_01 = fTCP1[2]; + float fQ3132_10 = fTCP1[1]; + float fQ3133_11 = fTCP1[1] * fTCP1[3]; + float fQ3133_01 = fTCP1[3]; + float fQ3133_10 = fTCP1[1]; + float fQ3233_11 = fTCP1[2] * fTCP1[3]; + float fQ3233_01 = fTCP1[3]; + float fQ3233_10 = fTCP1[2]; + float fQ2241_11 = fTCP0[2] * fTCP0[1]; + float fQ2241_01 = fTCP0[1]; + float fQ2241_10 = fTCP0[2]; + float fQ2242_11 = fTCP0[2] * fTCP0[2]; + float fQ2242_01 = fTCP0[2]; + float fQ2242_10 = fTCP0[2]; + float fQ2243_11 = fTCP0[2] * fTCP0[3]; + float fQ2243_01 = fTCP0[3]; + float fQ2243_10 = fTCP0[2]; + float fQ2244_11 = fTCP0[2] * fTCP0[4]; + float fQ2244_01 = fTCP0[4]; + float fQ2244_10 = fTCP0[2]; + float fQ2141_11 = fTCP0[1] * fTCP0[1]; + float fQ2141_01 = fTCP0[1]; + float fQ2141_10 = fTCP0[1]; + float fQ2142_11 = fTCP0[1] * fTCP0[2]; + float fQ2142_01 = fTCP0[2]; + float fQ2142_10 = fTCP0[1]; + float fQ2143_11 = fTCP0[1] * fTCP0[3]; + float fQ2143_01 = fTCP0[3]; + float fQ2143_10 = fTCP0[1]; + float fQ2144_11 = fTCP0[1] * fTCP0[4]; + float fQ2144_01 = fTCP0[4]; + float fQ2144_10 = fTCP0[1]; + float fQ1151_11 = fTCP1[1] * fTCP1[1]; + float fQ1151_01 = fTCP1[1]; + float fQ1151_10 = fTCP1[1]; + float fQ1152_11 = fTCP1[1] * fTCP1[2]; + float fQ1152_01 = fTCP1[2]; + float fQ1152_10 = fTCP1[1]; + float fQ1153_11 = fTCP1[1] * fTCP1[3]; + float fQ1153_01 = fTCP1[3]; + float fQ1153_10 = fTCP1[1]; + float fQ1154_11 = fTCP1[1] * fTCP1[4]; + float fQ1154_01 = fTCP1[4]; + float fQ1154_10 = fTCP1[1]; + float fQ1155_11 = fTCP1[1] * fTCP1[5]; + float fQ1155_01 = fTCP1[5]; + float fQ1155_10 = fTCP1[1]; + + float fQ112233_001 = fTCP1[3]; + float fQ112233_010 = fTCP0[2]; + float fQ112233_100 = fTCP1[1]; + float fQ112233_011 = fTCP0[2] * fTCP1[3]; + float fQ112233_101 = fTCP1[1] * fTCP1[3]; + float fQ112233_110 = fTCP1[1] * fTCP0[2]; + float fQ112232_001 = fTCP1[2]; + float fQ112232_010 = fTCP0[2]; + float fQ112232_100 = fTCP1[1]; + float fQ112232_011 = fTCP0[2] * fTCP1[2]; + float fQ112232_101 = fTCP1[1] * fTCP1[2]; + float fQ112232_110 = fTCP1[1] * fTCP0[2]; + // + float fQ112231_001 = fTCP1[1]; + float fQ112231_010 = fTCP0[2]; + float fQ112231_100 = fTCP1[1]; + float fQ112231_011 = fTCP0[2] * fTCP1[1]; + float fQ112231_101 = fTCP1[1] * fTCP1[1]; + float fQ112231_110 = fTCP1[1] * fTCP0[2]; + float fQ112133_001 = fTCP1[3]; + float fQ112133_010 = fTCP0[1]; + float fQ112133_100 = fTCP1[1]; + float fQ112133_011 = fTCP0[1] * fTCP1[3]; + float fQ112133_101 = fTCP1[1] * fTCP1[3]; + float fQ112133_110 = fTCP1[1] * fTCP0[1]; + + float fQ112132_001 = fTCP1[2]; + float fQ112132_010 = fTCP0[1]; + float fQ112132_100 = fTCP1[1]; + float fQ112132_011 = fTCP0[1] * fTCP1[2]; + float fQ112132_101 = fTCP1[1] * fTCP1[2]; + float fQ112132_110 = fTCP1[1] * fTCP0[1]; + float fQ112131_001 = fTCP1[1]; + float fQ112131_010 = fTCP0[1]; + float fQ112131_100 = fTCP1[1]; + float fQ112131_011 = fTCP0[1] * fTCP1[1]; + float fQ112131_101 = fTCP1[1] * fTCP1[1]; + float fQ112131_110 = fTCP1[1] * fTCP0[1]; + + float fQ2221_11 = fTCP0[2] * fTCP0[1]; + float fQ2221_01 = fTCP0[1]; + float fQ2221_10 = fTCP0[2]; + float fQ2221_21 = std::pow(fTCP0[2], 2) * fTCP0[1]; + float fQ2221_20 = std::pow(fTCP0[2], 2); + + float fQ2122_21 = std::pow(fTCP0[1], 2) * fTCP0[2]; + float fQ2122_20 = std::pow(fTCP0[1], 2); + float fQ1121_02 = std::pow(fTCP0[1], 2); + float fQ1121_12 = fTCP1[1] * std::pow(fTCP0[1], 2); + float fQ1121_22 = std::pow(fTCP1[1], 2) * std::pow(fTCP0[1], 2); + float fQ1122_02 = std::pow(fTCP0[2], 2); + float fQ1122_12 = fTCP1[1] * std::pow(fTCP0[2], 2); + float fQ1122_22 = std::pow(fTCP1[1], 2) * std::pow(fTCP0[2], 2); + + float fQ112221_001 = fTCP0[1]; + float fQ112221_010 = fTCP0[2]; + float fQ112221_100 = fTCP1[1]; + float fQ112221_011 = fTCP0[2] * fTCP0[1]; + float fQ112221_101 = fTCP1[1] * fTCP0[1]; + float fQ112221_110 = fTCP1[1] * fTCP0[2]; + float fQ112221_200 = std::pow(fTCP1[1], 2); + float fQ112221_201 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ112221_210 = std::pow(fTCP1[1], 2) * fTCP0[2]; + float fQ112221_211 = std::pow(fTCP1[1], 2) * fTCP0[2] * fTCP0[1]; + float fQ1131_21 = std::pow(fTCP1[1], 2) * fTCP1[1]; + float fQ1131_20 = std::pow(fTCP1[1], 2); + float fQ1131_31 = std::pow(fTCP1[1], 3) * fTCP1[1]; + float fQ1131_30 = std::pow(fTCP1[1], 3); + + float fQ1132_21 = std::pow(fTCP1[1], 2) * fTCP1[2]; + float fQ1132_20 = std::pow(fTCP1[1], 2); + float fQ1132_31 = std::pow(fTCP1[1], 3) * fTCP1[2]; + float fQ1132_30 = std::pow(fTCP1[1], 3); + float fQ1133_21 = std::pow(fTCP1[1], 2) * fTCP1[3]; + float fQ1133_20 = std::pow(fTCP1[1], 2); + float fQ1133_31 = std::pow(fTCP1[1], 3) * fTCP1[3]; + float fQ1133_30 = std::pow(fTCP1[1], 3); + float fQ1121_30 = std::pow(fTCP1[1], 3); + float fQ1121_31 = std::pow(fTCP1[1], 3) * fTCP0[1]; + float fQ1121_40 = std::pow(fTCP1[1], 4); + float fQ1121_41 = std::pow(fTCP1[1], 4) * fTCP0[1]; + float fQ1122_30 = std::pow(fTCP1[1], 3); + float fQ1122_31 = std::pow(fTCP1[1], 3) * fTCP0[2]; + float fQ1122_40 = std::pow(fTCP1[1], 4); + float fQ1122_41 = std::pow(fTCP1[1], 4) * fTCP0[2]; + + float fQ2211_11 = fTCP0[2] * fTCP1[1]; + float fQ2211_01 = fTCP1[1]; + float fQ2211_10 = fTCP0[2]; + float fQ2211_20 = std::pow(fTCP0[2], 2); + float fQ2211_21 = std::pow(fTCP0[2], 2) * fTCP1[1]; + float fQ2111_11 = fTCP0[1] * fTCP1[1]; + float fQ2111_01 = fTCP1[1]; + float fQ2111_10 = fTCP0[1]; + float fQ2111_20 = std::pow(fTCP0[1], 2); + float fQ2111_21 = std::pow(fTCP0[1], 2) * fTCP1[1]; + + float fQ112122_001 = fTCP0[2]; + float fQ112122_010 = fTCP0[1]; + float fQ112122_100 = fTCP1[1]; + float fQ112122_011 = fTCP0[1] * fTCP0[2]; + float fQ112122_101 = fTCP1[1] * fTCP0[2]; + float fQ112122_110 = fTCP1[1] * fTCP0[1]; + + float fQ1141_11 = fTCP1[1] * fTCP0[1]; + float fQ1141_01 = fTCP0[1]; + float fQ1141_10 = fTCP1[1]; + float fQ1141_20 = std::pow(fTCP1[1], 2); + float fQ1141_21 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ1142_11 = fTCP1[1] * fTCP0[2]; + float fQ1142_01 = fTCP0[2]; + float fQ1142_10 = fTCP1[1]; + float fQ1142_20 = std::pow(fTCP1[1], 2); + float fQ1142_21 = std::pow(fTCP1[1], 2) * fTCP0[2]; + + float fQ1143_11 = fTCP1[1] * fTCP0[3]; + float fQ1143_01 = fTCP0[3]; + float fQ1143_10 = fTCP1[1]; + float fQ1143_20 = std::pow(fTCP1[1], 2); + float fQ1143_21 = std::pow(fTCP1[1], 2) * fTCP0[3]; + float fQ1144_11 = fTCP1[1] * fTCP0[4]; + float fQ1144_01 = fTCP0[4]; + float fQ1144_10 = fTCP1[1]; + float fQ1144_20 = std::pow(fTCP1[1], 2); + float fQ1144_21 = std::pow(fTCP1[1], 2) * fTCP0[4]; + float fQ2131_11 = fTCP0[1] * fTCP1[1]; + float fQ2131_01 = fTCP1[1]; + float fQ2131_10 = fTCP0[1]; + + float fQ2132_11 = fTCP0[1] * fTCP1[2]; + float fQ2132_01 = fTCP1[2]; + float fQ2132_10 = fTCP0[1]; + float fQ2133_11 = fTCP0[1] * fTCP1[3]; + float fQ2133_01 = fTCP1[3]; + float fQ2133_10 = fTCP0[1]; + float fQ2231_11 = fTCP0[2] * fTCP1[1]; + float fQ2231_01 = fTCP1[1]; + float fQ2231_10 = fTCP0[2]; + float fQ2232_11 = fTCP0[2] * fTCP1[2]; + float fQ2232_01 = fTCP1[2]; + float fQ2232_10 = fTCP0[2]; + float fQ2233_11 = fTCP0[2] * fTCP1[3]; + float fQ2233_01 = fTCP1[3]; + float fQ2233_10 = fTCP0[2]; + + float fQ51_1 = fTCP1[1]; + float fQ52_1 = fTCP1[2]; + float fQ53_1 = fTCP1[3]; + float fQ54_1 = fTCP1[4]; + float fQ55_1 = fTCP1[5]; + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + if (cfgIsCalculateCentral) { + + // uncorrected + histos.get(HIST("Prof_mu1_antiproton"))->Fill(cent, std::pow(netProt, 1.0)); + histos.get(HIST("Prof_mu2_antiproton"))->Fill(cent, std::pow(netProt, 2.0)); + histos.get(HIST("Prof_mu3_antiproton"))->Fill(cent, std::pow(netProt, 3.0)); + histos.get(HIST("Prof_mu4_antiproton"))->Fill(cent, std::pow(netProt, 4.0)); + histos.get(HIST("Prof_mu5_antiproton"))->Fill(cent, std::pow(netProt, 5.0)); + histos.get(HIST("Prof_mu6_antiproton"))->Fill(cent, std::pow(netProt, 6.0)); + histos.get(HIST("Prof_mu7_antiproton"))->Fill(cent, std::pow(netProt, 7.0)); + histos.get(HIST("Prof_mu8_antiproton"))->Fill(cent, std::pow(netProt, 8.0)); + + // eff. corrected + histos.get(HIST("Prof_Q11_1"))->Fill(cent, fQ11_1); + histos.get(HIST("Prof_Q11_2"))->Fill(cent, fQ11_2); + histos.get(HIST("Prof_Q11_3"))->Fill(cent, fQ11_3); + histos.get(HIST("Prof_Q11_4"))->Fill(cent, fQ11_4); + histos.get(HIST("Prof_Q21_1"))->Fill(cent, fQ21_1); + histos.get(HIST("Prof_Q22_1"))->Fill(cent, fQ22_1); + histos.get(HIST("Prof_Q31_1"))->Fill(cent, fQ31_1); + histos.get(HIST("Prof_Q32_1"))->Fill(cent, fQ32_1); + histos.get(HIST("Prof_Q33_1"))->Fill(cent, fQ33_1); + histos.get(HIST("Prof_Q41_1"))->Fill(cent, fQ41_1); + histos.get(HIST("Prof_Q42_1"))->Fill(cent, fQ42_1); + histos.get(HIST("Prof_Q43_1"))->Fill(cent, fQ43_1); + histos.get(HIST("Prof_Q44_1"))->Fill(cent, fQ44_1); + histos.get(HIST("Prof_Q21_2"))->Fill(cent, fQ21_2); + histos.get(HIST("Prof_Q22_2"))->Fill(cent, fQ22_2); + histos.get(HIST("Prof_Q1121_11"))->Fill(cent, fQ1121_11); + histos.get(HIST("Prof_Q1121_01"))->Fill(cent, fQ1121_01); + histos.get(HIST("Prof_Q1121_10"))->Fill(cent, fQ1121_10); + histos.get(HIST("Prof_Q1121_20"))->Fill(cent, fQ1121_20); + histos.get(HIST("Prof_Q1121_21"))->Fill(cent, fQ1121_21); + histos.get(HIST("Prof_Q1122_11"))->Fill(cent, fQ1122_11); + histos.get(HIST("Prof_Q1122_01"))->Fill(cent, fQ1122_01); + histos.get(HIST("Prof_Q1122_10"))->Fill(cent, fQ1122_10); + histos.get(HIST("Prof_Q1122_20"))->Fill(cent, fQ1122_20); + histos.get(HIST("Prof_Q1122_21"))->Fill(cent, fQ1122_21); + histos.get(HIST("Prof_Q1131_11"))->Fill(cent, fQ1131_11); + histos.get(HIST("Prof_Q1131_01"))->Fill(cent, fQ1131_01); + histos.get(HIST("Prof_Q1131_10"))->Fill(cent, fQ1131_10); + histos.get(HIST("Prof_Q1132_11"))->Fill(cent, fQ1132_11); + histos.get(HIST("Prof_Q1132_01"))->Fill(cent, fQ1132_01); + histos.get(HIST("Prof_Q1132_10"))->Fill(cent, fQ1132_10); + histos.get(HIST("Prof_Q1133_11"))->Fill(cent, fQ1133_11); + histos.get(HIST("Prof_Q1133_01"))->Fill(cent, fQ1133_01); + histos.get(HIST("Prof_Q1133_10"))->Fill(cent, fQ1133_10); + histos.get(HIST("Prof_Q2122_11"))->Fill(cent, fQ2122_11); + histos.get(HIST("Prof_Q2122_01"))->Fill(cent, fQ2122_01); + histos.get(HIST("Prof_Q2122_10"))->Fill(cent, fQ2122_10); + histos.get(HIST("Prof_Q3132_11"))->Fill(cent, fQ3132_11); + histos.get(HIST("Prof_Q3132_01"))->Fill(cent, fQ3132_01); + histos.get(HIST("Prof_Q3132_10"))->Fill(cent, fQ3132_10); + histos.get(HIST("Prof_Q3133_11"))->Fill(cent, fQ3133_11); + histos.get(HIST("Prof_Q3133_01"))->Fill(cent, fQ3133_01); + histos.get(HIST("Prof_Q3133_10"))->Fill(cent, fQ3133_10); + histos.get(HIST("Prof_Q3233_11"))->Fill(cent, fQ3233_11); + histos.get(HIST("Prof_Q3233_01"))->Fill(cent, fQ3233_01); + histos.get(HIST("Prof_Q3233_10"))->Fill(cent, fQ3233_10); + histos.get(HIST("Prof_Q2241_11"))->Fill(cent, fQ2241_11); + histos.get(HIST("Prof_Q2241_01"))->Fill(cent, fQ2241_01); + histos.get(HIST("Prof_Q2241_10"))->Fill(cent, fQ2241_10); + histos.get(HIST("Prof_Q2242_11"))->Fill(cent, fQ2242_11); + histos.get(HIST("Prof_Q2242_01"))->Fill(cent, fQ2242_01); + histos.get(HIST("Prof_Q2242_10"))->Fill(cent, fQ2242_10); + histos.get(HIST("Prof_Q2243_11"))->Fill(cent, fQ2243_11); + histos.get(HIST("Prof_Q2243_01"))->Fill(cent, fQ2243_01); + histos.get(HIST("Prof_Q2243_10"))->Fill(cent, fQ2243_10); + histos.get(HIST("Prof_Q2244_11"))->Fill(cent, fQ2244_11); + histos.get(HIST("Prof_Q2244_01"))->Fill(cent, fQ2244_01); + histos.get(HIST("Prof_Q2244_10"))->Fill(cent, fQ2244_10); + histos.get(HIST("Prof_Q2141_11"))->Fill(cent, fQ2141_11); + histos.get(HIST("Prof_Q2141_01"))->Fill(cent, fQ2141_01); + histos.get(HIST("Prof_Q2141_10"))->Fill(cent, fQ2141_10); + histos.get(HIST("Prof_Q2142_11"))->Fill(cent, fQ2142_11); + histos.get(HIST("Prof_Q2142_01"))->Fill(cent, fQ2142_01); + histos.get(HIST("Prof_Q2142_10"))->Fill(cent, fQ2142_10); + histos.get(HIST("Prof_Q2143_11"))->Fill(cent, fQ2143_11); + histos.get(HIST("Prof_Q2143_01"))->Fill(cent, fQ2143_01); + histos.get(HIST("Prof_Q2143_10"))->Fill(cent, fQ2143_10); + histos.get(HIST("Prof_Q2144_11"))->Fill(cent, fQ2144_11); + histos.get(HIST("Prof_Q2144_01"))->Fill(cent, fQ2144_01); + histos.get(HIST("Prof_Q2144_10"))->Fill(cent, fQ2144_10); + histos.get(HIST("Prof_Q1151_11"))->Fill(cent, fQ1151_11); + histos.get(HIST("Prof_Q1151_01"))->Fill(cent, fQ1151_01); + histos.get(HIST("Prof_Q1151_10"))->Fill(cent, fQ1151_10); + histos.get(HIST("Prof_Q1152_11"))->Fill(cent, fQ1152_11); + histos.get(HIST("Prof_Q1152_01"))->Fill(cent, fQ1152_01); + histos.get(HIST("Prof_Q1152_10"))->Fill(cent, fQ1152_10); + histos.get(HIST("Prof_Q1153_11"))->Fill(cent, fQ1153_11); + histos.get(HIST("Prof_Q1153_01"))->Fill(cent, fQ1153_01); + histos.get(HIST("Prof_Q1153_10"))->Fill(cent, fQ1153_10); + histos.get(HIST("Prof_Q1154_11"))->Fill(cent, fQ1154_11); + histos.get(HIST("Prof_Q1154_01"))->Fill(cent, fQ1154_01); + histos.get(HIST("Prof_Q1154_10"))->Fill(cent, fQ1154_10); + histos.get(HIST("Prof_Q1155_11"))->Fill(cent, fQ1155_11); + histos.get(HIST("Prof_Q1155_01"))->Fill(cent, fQ1155_01); + histos.get(HIST("Prof_Q1155_10"))->Fill(cent, fQ1155_10); + histos.get(HIST("Prof_Q112233_001"))->Fill(cent, fQ112233_001); + histos.get(HIST("Prof_Q112233_010"))->Fill(cent, fQ112233_010); + histos.get(HIST("Prof_Q112233_100"))->Fill(cent, fQ112233_100); + histos.get(HIST("Prof_Q112233_011"))->Fill(cent, fQ112233_011); + histos.get(HIST("Prof_Q112233_101"))->Fill(cent, fQ112233_101); + histos.get(HIST("Prof_Q112233_110"))->Fill(cent, fQ112233_110); + histos.get(HIST("Prof_Q112232_001"))->Fill(cent, fQ112232_001); + histos.get(HIST("Prof_Q112232_010"))->Fill(cent, fQ112232_010); + histos.get(HIST("Prof_Q112232_100"))->Fill(cent, fQ112232_100); + histos.get(HIST("Prof_Q112232_011"))->Fill(cent, fQ112232_011); + histos.get(HIST("Prof_Q112232_101"))->Fill(cent, fQ112232_101); + histos.get(HIST("Prof_Q112232_110"))->Fill(cent, fQ112232_110); + histos.get(HIST("Prof_Q112231_001"))->Fill(cent, fQ112231_001); + histos.get(HIST("Prof_Q112231_010"))->Fill(cent, fQ112231_010); + histos.get(HIST("Prof_Q112231_100"))->Fill(cent, fQ112231_100); + histos.get(HIST("Prof_Q112231_011"))->Fill(cent, fQ112231_011); + histos.get(HIST("Prof_Q112231_101"))->Fill(cent, fQ112231_101); + histos.get(HIST("Prof_Q112231_110"))->Fill(cent, fQ112231_110); + histos.get(HIST("Prof_Q112133_001"))->Fill(cent, fQ112133_001); + histos.get(HIST("Prof_Q112133_010"))->Fill(cent, fQ112133_010); + histos.get(HIST("Prof_Q112133_100"))->Fill(cent, fQ112133_100); + histos.get(HIST("Prof_Q112133_011"))->Fill(cent, fQ112133_011); + histos.get(HIST("Prof_Q112133_101"))->Fill(cent, fQ112133_101); + histos.get(HIST("Prof_Q112133_110"))->Fill(cent, fQ112133_110); + histos.get(HIST("Prof_Q112132_001"))->Fill(cent, fQ112132_001); + histos.get(HIST("Prof_Q112132_010"))->Fill(cent, fQ112132_010); + histos.get(HIST("Prof_Q112132_100"))->Fill(cent, fQ112132_100); + histos.get(HIST("Prof_Q112132_011"))->Fill(cent, fQ112132_011); + histos.get(HIST("Prof_Q112132_101"))->Fill(cent, fQ112132_101); + histos.get(HIST("Prof_Q112132_110"))->Fill(cent, fQ112132_110); + histos.get(HIST("Prof_Q112131_001"))->Fill(cent, fQ112131_001); + histos.get(HIST("Prof_Q112131_010"))->Fill(cent, fQ112131_010); + histos.get(HIST("Prof_Q112131_100"))->Fill(cent, fQ112131_100); + histos.get(HIST("Prof_Q112131_011"))->Fill(cent, fQ112131_011); + histos.get(HIST("Prof_Q112131_101"))->Fill(cent, fQ112131_101); + histos.get(HIST("Prof_Q112131_110"))->Fill(cent, fQ112131_110); + histos.get(HIST("Prof_Q2221_11"))->Fill(cent, fQ2221_11); + histos.get(HIST("Prof_Q2221_01"))->Fill(cent, fQ2221_01); + histos.get(HIST("Prof_Q2221_10"))->Fill(cent, fQ2221_10); + histos.get(HIST("Prof_Q2221_21"))->Fill(cent, fQ2221_21); + histos.get(HIST("Prof_Q2221_20"))->Fill(cent, fQ2221_20); + histos.get(HIST("Prof_Q2122_21"))->Fill(cent, fQ2122_21); + histos.get(HIST("Prof_Q2122_20"))->Fill(cent, fQ2122_20); + histos.get(HIST("Prof_Q1121_02"))->Fill(cent, fQ1121_02); + histos.get(HIST("Prof_Q1121_12"))->Fill(cent, fQ1121_12); + histos.get(HIST("Prof_Q1121_22"))->Fill(cent, fQ1121_22); + histos.get(HIST("Prof_Q1122_02"))->Fill(cent, fQ1122_02); + histos.get(HIST("Prof_Q1122_12"))->Fill(cent, fQ1122_12); + histos.get(HIST("Prof_Q1122_22"))->Fill(cent, fQ1122_22); + histos.get(HIST("Prof_Q112221_001"))->Fill(cent, fQ112221_001); + histos.get(HIST("Prof_Q112221_010"))->Fill(cent, fQ112221_010); + histos.get(HIST("Prof_Q112221_100"))->Fill(cent, fQ112221_100); + histos.get(HIST("Prof_Q112221_011"))->Fill(cent, fQ112221_011); + histos.get(HIST("Prof_Q112221_101"))->Fill(cent, fQ112221_101); + histos.get(HIST("Prof_Q112221_110"))->Fill(cent, fQ112221_110); + histos.get(HIST("Prof_Q112221_200"))->Fill(cent, fQ112221_200); + histos.get(HIST("Prof_Q112221_201"))->Fill(cent, fQ112221_201); + histos.get(HIST("Prof_Q112221_210"))->Fill(cent, fQ112221_210); + histos.get(HIST("Prof_Q112221_211"))->Fill(cent, fQ112221_211); + histos.get(HIST("Prof_Q1131_21"))->Fill(cent, fQ1131_21); + histos.get(HIST("Prof_Q1131_20"))->Fill(cent, fQ1131_20); + histos.get(HIST("Prof_Q1131_31"))->Fill(cent, fQ1131_31); + histos.get(HIST("Prof_Q1131_30"))->Fill(cent, fQ1131_30); + histos.get(HIST("Prof_Q1132_21"))->Fill(cent, fQ1132_21); + histos.get(HIST("Prof_Q1132_20"))->Fill(cent, fQ1132_20); + histos.get(HIST("Prof_Q1132_31"))->Fill(cent, fQ1132_31); + histos.get(HIST("Prof_Q1132_30"))->Fill(cent, fQ1132_30); + histos.get(HIST("Prof_Q1133_21"))->Fill(cent, fQ1133_21); + histos.get(HIST("Prof_Q1133_20"))->Fill(cent, fQ1133_20); + histos.get(HIST("Prof_Q1133_31"))->Fill(cent, fQ1133_31); + histos.get(HIST("Prof_Q1133_30"))->Fill(cent, fQ1133_30); + histos.get(HIST("Prof_Q11_5"))->Fill(cent, fQ11_5); + histos.get(HIST("Prof_Q11_6"))->Fill(cent, fQ11_6); + histos.get(HIST("Prof_Q1121_30"))->Fill(cent, fQ1121_30); + histos.get(HIST("Prof_Q1121_31"))->Fill(cent, fQ1121_31); + histos.get(HIST("Prof_Q1121_40"))->Fill(cent, fQ1121_40); + histos.get(HIST("Prof_Q1121_41"))->Fill(cent, fQ1121_41); + histos.get(HIST("Prof_Q1122_30"))->Fill(cent, fQ1122_30); + histos.get(HIST("Prof_Q1122_31"))->Fill(cent, fQ1122_31); + histos.get(HIST("Prof_Q1122_40"))->Fill(cent, fQ1122_40); + histos.get(HIST("Prof_Q1122_41"))->Fill(cent, fQ1122_41); + histos.get(HIST("Prof_Q2211_11"))->Fill(cent, fQ2211_11); + histos.get(HIST("Prof_Q2211_01"))->Fill(cent, fQ2211_01); + histos.get(HIST("Prof_Q2211_10"))->Fill(cent, fQ2211_10); + histos.get(HIST("Prof_Q2211_20"))->Fill(cent, fQ2211_20); + histos.get(HIST("Prof_Q2211_21"))->Fill(cent, fQ2211_21); + histos.get(HIST("Prof_Q2111_11"))->Fill(cent, fQ2111_11); + histos.get(HIST("Prof_Q2111_01"))->Fill(cent, fQ2111_01); + histos.get(HIST("Prof_Q2111_10"))->Fill(cent, fQ2111_10); + histos.get(HIST("Prof_Q2111_20"))->Fill(cent, fQ2111_20); + histos.get(HIST("Prof_Q2111_21"))->Fill(cent, fQ2111_21); + histos.get(HIST("Prof_Q112122_001"))->Fill(cent, fQ112122_001); + histos.get(HIST("Prof_Q112122_010"))->Fill(cent, fQ112122_010); + histos.get(HIST("Prof_Q112122_100"))->Fill(cent, fQ112122_100); + histos.get(HIST("Prof_Q112122_011"))->Fill(cent, fQ112122_011); + histos.get(HIST("Prof_Q112122_101"))->Fill(cent, fQ112122_101); + histos.get(HIST("Prof_Q112122_110"))->Fill(cent, fQ112122_110); + histos.get(HIST("Prof_Q1141_11"))->Fill(cent, fQ1141_11); + histos.get(HIST("Prof_Q1141_01"))->Fill(cent, fQ1141_01); + histos.get(HIST("Prof_Q1141_10"))->Fill(cent, fQ1141_10); + histos.get(HIST("Prof_Q1141_20"))->Fill(cent, fQ1141_20); + histos.get(HIST("Prof_Q1141_21"))->Fill(cent, fQ1141_21); + histos.get(HIST("Prof_Q1142_11"))->Fill(cent, fQ1142_11); + histos.get(HIST("Prof_Q1142_01"))->Fill(cent, fQ1142_01); + histos.get(HIST("Prof_Q1142_10"))->Fill(cent, fQ1142_10); + histos.get(HIST("Prof_Q1142_20"))->Fill(cent, fQ1142_20); + histos.get(HIST("Prof_Q1142_21"))->Fill(cent, fQ1142_21); + histos.get(HIST("Prof_Q1143_11"))->Fill(cent, fQ1143_11); + histos.get(HIST("Prof_Q1143_01"))->Fill(cent, fQ1143_01); + histos.get(HIST("Prof_Q1143_10"))->Fill(cent, fQ1143_10); + histos.get(HIST("Prof_Q1143_20"))->Fill(cent, fQ1143_20); + histos.get(HIST("Prof_Q1143_21"))->Fill(cent, fQ1143_21); + histos.get(HIST("Prof_Q1144_11"))->Fill(cent, fQ1144_11); + histos.get(HIST("Prof_Q1144_01"))->Fill(cent, fQ1144_01); + histos.get(HIST("Prof_Q1144_10"))->Fill(cent, fQ1144_10); + histos.get(HIST("Prof_Q1144_20"))->Fill(cent, fQ1144_20); + histos.get(HIST("Prof_Q1144_21"))->Fill(cent, fQ1144_21); + histos.get(HIST("Prof_Q2131_11"))->Fill(cent, fQ2131_11); + histos.get(HIST("Prof_Q2131_01"))->Fill(cent, fQ2131_01); + histos.get(HIST("Prof_Q2131_10"))->Fill(cent, fQ2131_10); + histos.get(HIST("Prof_Q2132_11"))->Fill(cent, fQ2132_11); + histos.get(HIST("Prof_Q2132_01"))->Fill(cent, fQ2132_01); + histos.get(HIST("Prof_Q2132_10"))->Fill(cent, fQ2132_10); + histos.get(HIST("Prof_Q2133_11"))->Fill(cent, fQ2133_11); + histos.get(HIST("Prof_Q2133_01"))->Fill(cent, fQ2133_01); + histos.get(HIST("Prof_Q2133_10"))->Fill(cent, fQ2133_10); + histos.get(HIST("Prof_Q2231_11"))->Fill(cent, fQ2231_11); + histos.get(HIST("Prof_Q2231_01"))->Fill(cent, fQ2231_01); + histos.get(HIST("Prof_Q2231_10"))->Fill(cent, fQ2231_10); + histos.get(HIST("Prof_Q2232_11"))->Fill(cent, fQ2232_11); + histos.get(HIST("Prof_Q2232_01"))->Fill(cent, fQ2232_01); + histos.get(HIST("Prof_Q2232_10"))->Fill(cent, fQ2232_10); + histos.get(HIST("Prof_Q2233_11"))->Fill(cent, fQ2233_11); + histos.get(HIST("Prof_Q2233_01"))->Fill(cent, fQ2233_01); + histos.get(HIST("Prof_Q2233_10"))->Fill(cent, fQ2233_10); + histos.get(HIST("Prof_Q51_1"))->Fill(cent, fQ51_1); + histos.get(HIST("Prof_Q52_1"))->Fill(cent, fQ52_1); + histos.get(HIST("Prof_Q53_1"))->Fill(cent, fQ53_1); + histos.get(HIST("Prof_Q54_1"))->Fill(cent, fQ54_1); + histos.get(HIST("Prof_Q55_1"))->Fill(cent, fQ55_1); + histos.get(HIST("Prof_Q21_3"))->Fill(cent, fQ21_3); + histos.get(HIST("Prof_Q22_3"))->Fill(cent, fQ22_3); + histos.get(HIST("Prof_Q31_2"))->Fill(cent, fQ31_2); + histos.get(HIST("Prof_Q32_2"))->Fill(cent, fQ32_2); + histos.get(HIST("Prof_Q33_2"))->Fill(cent, fQ33_2); + histos.get(HIST("Prof_Q61_1"))->Fill(cent, fQ61_1); + histos.get(HIST("Prof_Q62_1"))->Fill(cent, fQ62_1); + histos.get(HIST("Prof_Q63_1"))->Fill(cent, fQ63_1); + histos.get(HIST("Prof_Q64_1"))->Fill(cent, fQ64_1); + histos.get(HIST("Prof_Q65_1"))->Fill(cent, fQ65_1); + histos.get(HIST("Prof_Q66_1"))->Fill(cent, fQ66_1); + histos.get(HIST("Prof_Q112122_111"))->Fill(cent, fQ112122_111); + histos.get(HIST("Prof_Q112131_111"))->Fill(cent, fQ112131_111); + histos.get(HIST("Prof_Q112132_111"))->Fill(cent, fQ112132_111); + histos.get(HIST("Prof_Q112133_111"))->Fill(cent, fQ112133_111); + histos.get(HIST("Prof_Q112231_111"))->Fill(cent, fQ112231_111); + histos.get(HIST("Prof_Q112232_111"))->Fill(cent, fQ112232_111); + histos.get(HIST("Prof_Q112233_111"))->Fill(cent, fQ112233_111); + histos.get(HIST("Prof_Q112221_111"))->Fill(cent, fQ112221_111); + } + + if (cfgIsCalculateError) { + // selecting subsample and filling profiles + float lRandom = fRndm->Rndm(); + int sampleIndex = static_cast(cfgNSubsample * lRandom); + + histos.get(HIST("Prof2D_mu1_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 1.0)); + histos.get(HIST("Prof2D_mu2_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 2.0)); + histos.get(HIST("Prof2D_mu3_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 3.0)); + histos.get(HIST("Prof2D_mu4_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 4.0)); + histos.get(HIST("Prof2D_mu5_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 5.0)); + histos.get(HIST("Prof2D_mu6_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 6.0)); + histos.get(HIST("Prof2D_mu7_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 7.0)); + histos.get(HIST("Prof2D_mu8_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 8.0)); + + histos.get(HIST("Prof2D_Q11_1"))->Fill(cent, sampleIndex, fQ11_1); + histos.get(HIST("Prof2D_Q11_2"))->Fill(cent, sampleIndex, fQ11_2); + histos.get(HIST("Prof2D_Q11_3"))->Fill(cent, sampleIndex, fQ11_3); + histos.get(HIST("Prof2D_Q11_4"))->Fill(cent, sampleIndex, fQ11_4); + histos.get(HIST("Prof2D_Q21_1"))->Fill(cent, sampleIndex, fQ21_1); + histos.get(HIST("Prof2D_Q22_1"))->Fill(cent, sampleIndex, fQ22_1); + histos.get(HIST("Prof2D_Q31_1"))->Fill(cent, sampleIndex, fQ31_1); + histos.get(HIST("Prof2D_Q32_1"))->Fill(cent, sampleIndex, fQ32_1); + histos.get(HIST("Prof2D_Q33_1"))->Fill(cent, sampleIndex, fQ33_1); + histos.get(HIST("Prof2D_Q41_1"))->Fill(cent, sampleIndex, fQ41_1); + histos.get(HIST("Prof2D_Q42_1"))->Fill(cent, sampleIndex, fQ42_1); + histos.get(HIST("Prof2D_Q43_1"))->Fill(cent, sampleIndex, fQ43_1); + histos.get(HIST("Prof2D_Q44_1"))->Fill(cent, sampleIndex, fQ44_1); + histos.get(HIST("Prof2D_Q21_2"))->Fill(cent, sampleIndex, fQ21_2); + histos.get(HIST("Prof2D_Q22_2"))->Fill(cent, sampleIndex, fQ22_2); + histos.get(HIST("Prof2D_Q1121_11"))->Fill(cent, sampleIndex, fQ1121_11); + histos.get(HIST("Prof2D_Q1121_01"))->Fill(cent, sampleIndex, fQ1121_01); + histos.get(HIST("Prof2D_Q1121_10"))->Fill(cent, sampleIndex, fQ1121_10); + histos.get(HIST("Prof2D_Q1121_20"))->Fill(cent, sampleIndex, fQ1121_20); + histos.get(HIST("Prof2D_Q1121_21"))->Fill(cent, sampleIndex, fQ1121_21); + histos.get(HIST("Prof2D_Q1122_11"))->Fill(cent, sampleIndex, fQ1122_11); + histos.get(HIST("Prof2D_Q1122_01"))->Fill(cent, sampleIndex, fQ1122_01); + histos.get(HIST("Prof2D_Q1122_10"))->Fill(cent, sampleIndex, fQ1122_10); + histos.get(HIST("Prof2D_Q1122_20"))->Fill(cent, sampleIndex, fQ1122_20); + histos.get(HIST("Prof2D_Q1122_21"))->Fill(cent, sampleIndex, fQ1122_21); + histos.get(HIST("Prof2D_Q1131_11"))->Fill(cent, sampleIndex, fQ1131_11); + histos.get(HIST("Prof2D_Q1131_01"))->Fill(cent, sampleIndex, fQ1131_01); + histos.get(HIST("Prof2D_Q1131_10"))->Fill(cent, sampleIndex, fQ1131_10); + histos.get(HIST("Prof2D_Q1132_11"))->Fill(cent, sampleIndex, fQ1132_11); + histos.get(HIST("Prof2D_Q1132_01"))->Fill(cent, sampleIndex, fQ1132_01); + histos.get(HIST("Prof2D_Q1132_10"))->Fill(cent, sampleIndex, fQ1132_10); + histos.get(HIST("Prof2D_Q1133_11"))->Fill(cent, sampleIndex, fQ1133_11); + histos.get(HIST("Prof2D_Q1133_01"))->Fill(cent, sampleIndex, fQ1133_01); + histos.get(HIST("Prof2D_Q1133_10"))->Fill(cent, sampleIndex, fQ1133_10); + histos.get(HIST("Prof2D_Q2122_11"))->Fill(cent, sampleIndex, fQ2122_11); + histos.get(HIST("Prof2D_Q2122_01"))->Fill(cent, sampleIndex, fQ2122_01); + histos.get(HIST("Prof2D_Q2122_10"))->Fill(cent, sampleIndex, fQ2122_10); + histos.get(HIST("Prof2D_Q3132_11"))->Fill(cent, sampleIndex, fQ3132_11); + histos.get(HIST("Prof2D_Q3132_01"))->Fill(cent, sampleIndex, fQ3132_01); + histos.get(HIST("Prof2D_Q3132_10"))->Fill(cent, sampleIndex, fQ3132_10); + histos.get(HIST("Prof2D_Q3133_11"))->Fill(cent, sampleIndex, fQ3133_11); + histos.get(HIST("Prof2D_Q3133_01"))->Fill(cent, sampleIndex, fQ3133_01); + histos.get(HIST("Prof2D_Q3133_10"))->Fill(cent, sampleIndex, fQ3133_10); + histos.get(HIST("Prof2D_Q3233_11"))->Fill(cent, sampleIndex, fQ3233_11); + histos.get(HIST("Prof2D_Q3233_01"))->Fill(cent, sampleIndex, fQ3233_01); + histos.get(HIST("Prof2D_Q3233_10"))->Fill(cent, sampleIndex, fQ3233_10); + histos.get(HIST("Prof2D_Q2241_11"))->Fill(cent, sampleIndex, fQ2241_11); + histos.get(HIST("Prof2D_Q2241_01"))->Fill(cent, sampleIndex, fQ2241_01); + histos.get(HIST("Prof2D_Q2241_10"))->Fill(cent, sampleIndex, fQ2241_10); + histos.get(HIST("Prof2D_Q2242_11"))->Fill(cent, sampleIndex, fQ2242_11); + histos.get(HIST("Prof2D_Q2242_01"))->Fill(cent, sampleIndex, fQ2242_01); + histos.get(HIST("Prof2D_Q2242_10"))->Fill(cent, sampleIndex, fQ2242_10); + histos.get(HIST("Prof2D_Q2243_11"))->Fill(cent, sampleIndex, fQ2243_11); + histos.get(HIST("Prof2D_Q2243_01"))->Fill(cent, sampleIndex, fQ2243_01); + histos.get(HIST("Prof2D_Q2243_10"))->Fill(cent, sampleIndex, fQ2243_10); + histos.get(HIST("Prof2D_Q2244_11"))->Fill(cent, sampleIndex, fQ2244_11); + histos.get(HIST("Prof2D_Q2244_01"))->Fill(cent, sampleIndex, fQ2244_01); + histos.get(HIST("Prof2D_Q2244_10"))->Fill(cent, sampleIndex, fQ2244_10); + histos.get(HIST("Prof2D_Q2141_11"))->Fill(cent, sampleIndex, fQ2141_11); + histos.get(HIST("Prof2D_Q2141_01"))->Fill(cent, sampleIndex, fQ2141_01); + histos.get(HIST("Prof2D_Q2141_10"))->Fill(cent, sampleIndex, fQ2141_10); + histos.get(HIST("Prof2D_Q2142_11"))->Fill(cent, sampleIndex, fQ2142_11); + histos.get(HIST("Prof2D_Q2142_01"))->Fill(cent, sampleIndex, fQ2142_01); + histos.get(HIST("Prof2D_Q2142_10"))->Fill(cent, sampleIndex, fQ2142_10); + histos.get(HIST("Prof2D_Q2143_11"))->Fill(cent, sampleIndex, fQ2143_11); + histos.get(HIST("Prof2D_Q2143_01"))->Fill(cent, sampleIndex, fQ2143_01); + histos.get(HIST("Prof2D_Q2143_10"))->Fill(cent, sampleIndex, fQ2143_10); + histos.get(HIST("Prof2D_Q2144_11"))->Fill(cent, sampleIndex, fQ2144_11); + histos.get(HIST("Prof2D_Q2144_01"))->Fill(cent, sampleIndex, fQ2144_01); + histos.get(HIST("Prof2D_Q2144_10"))->Fill(cent, sampleIndex, fQ2144_10); + histos.get(HIST("Prof2D_Q1151_11"))->Fill(cent, sampleIndex, fQ1151_11); + histos.get(HIST("Prof2D_Q1151_01"))->Fill(cent, sampleIndex, fQ1151_01); + histos.get(HIST("Prof2D_Q1151_10"))->Fill(cent, sampleIndex, fQ1151_10); + histos.get(HIST("Prof2D_Q1152_11"))->Fill(cent, sampleIndex, fQ1152_11); + histos.get(HIST("Prof2D_Q1152_01"))->Fill(cent, sampleIndex, fQ1152_01); + histos.get(HIST("Prof2D_Q1152_10"))->Fill(cent, sampleIndex, fQ1152_10); + histos.get(HIST("Prof2D_Q1153_11"))->Fill(cent, sampleIndex, fQ1153_11); + histos.get(HIST("Prof2D_Q1153_01"))->Fill(cent, sampleIndex, fQ1153_01); + histos.get(HIST("Prof2D_Q1153_10"))->Fill(cent, sampleIndex, fQ1153_10); + histos.get(HIST("Prof2D_Q1154_11"))->Fill(cent, sampleIndex, fQ1154_11); + histos.get(HIST("Prof2D_Q1154_01"))->Fill(cent, sampleIndex, fQ1154_01); + histos.get(HIST("Prof2D_Q1154_10"))->Fill(cent, sampleIndex, fQ1154_10); + histos.get(HIST("Prof2D_Q1155_11"))->Fill(cent, sampleIndex, fQ1155_11); + histos.get(HIST("Prof2D_Q1155_01"))->Fill(cent, sampleIndex, fQ1155_01); + histos.get(HIST("Prof2D_Q1155_10"))->Fill(cent, sampleIndex, fQ1155_10); + histos.get(HIST("Prof2D_Q112233_001"))->Fill(cent, sampleIndex, fQ112233_001); + histos.get(HIST("Prof2D_Q112233_010"))->Fill(cent, sampleIndex, fQ112233_010); + histos.get(HIST("Prof2D_Q112233_100"))->Fill(cent, sampleIndex, fQ112233_100); + histos.get(HIST("Prof2D_Q112233_011"))->Fill(cent, sampleIndex, fQ112233_011); + histos.get(HIST("Prof2D_Q112233_101"))->Fill(cent, sampleIndex, fQ112233_101); + histos.get(HIST("Prof2D_Q112233_110"))->Fill(cent, sampleIndex, fQ112233_110); + histos.get(HIST("Prof2D_Q112232_001"))->Fill(cent, sampleIndex, fQ112232_001); + histos.get(HIST("Prof2D_Q112232_010"))->Fill(cent, sampleIndex, fQ112232_010); + histos.get(HIST("Prof2D_Q112232_100"))->Fill(cent, sampleIndex, fQ112232_100); + histos.get(HIST("Prof2D_Q112232_011"))->Fill(cent, sampleIndex, fQ112232_011); + histos.get(HIST("Prof2D_Q112232_101"))->Fill(cent, sampleIndex, fQ112232_101); + histos.get(HIST("Prof2D_Q112232_110"))->Fill(cent, sampleIndex, fQ112232_110); + histos.get(HIST("Prof2D_Q112231_001"))->Fill(cent, sampleIndex, fQ112231_001); + histos.get(HIST("Prof2D_Q112231_010"))->Fill(cent, sampleIndex, fQ112231_010); + histos.get(HIST("Prof2D_Q112231_100"))->Fill(cent, sampleIndex, fQ112231_100); + histos.get(HIST("Prof2D_Q112231_011"))->Fill(cent, sampleIndex, fQ112231_011); + histos.get(HIST("Prof2D_Q112231_101"))->Fill(cent, sampleIndex, fQ112231_101); + histos.get(HIST("Prof2D_Q112231_110"))->Fill(cent, sampleIndex, fQ112231_110); + histos.get(HIST("Prof2D_Q112133_001"))->Fill(cent, sampleIndex, fQ112133_001); + histos.get(HIST("Prof2D_Q112133_010"))->Fill(cent, sampleIndex, fQ112133_010); + histos.get(HIST("Prof2D_Q112133_100"))->Fill(cent, sampleIndex, fQ112133_100); + histos.get(HIST("Prof2D_Q112133_011"))->Fill(cent, sampleIndex, fQ112133_011); + histos.get(HIST("Prof2D_Q112133_101"))->Fill(cent, sampleIndex, fQ112133_101); + histos.get(HIST("Prof2D_Q112133_110"))->Fill(cent, sampleIndex, fQ112133_110); + histos.get(HIST("Prof2D_Q112132_001"))->Fill(cent, sampleIndex, fQ112132_001); + histos.get(HIST("Prof2D_Q112132_010"))->Fill(cent, sampleIndex, fQ112132_010); + histos.get(HIST("Prof2D_Q112132_100"))->Fill(cent, sampleIndex, fQ112132_100); + histos.get(HIST("Prof2D_Q112132_011"))->Fill(cent, sampleIndex, fQ112132_011); + histos.get(HIST("Prof2D_Q112132_101"))->Fill(cent, sampleIndex, fQ112132_101); + histos.get(HIST("Prof2D_Q112132_110"))->Fill(cent, sampleIndex, fQ112132_110); + histos.get(HIST("Prof2D_Q112131_001"))->Fill(cent, sampleIndex, fQ112131_001); + histos.get(HIST("Prof2D_Q112131_010"))->Fill(cent, sampleIndex, fQ112131_010); + histos.get(HIST("Prof2D_Q112131_100"))->Fill(cent, sampleIndex, fQ112131_100); + histos.get(HIST("Prof2D_Q112131_011"))->Fill(cent, sampleIndex, fQ112131_011); + histos.get(HIST("Prof2D_Q112131_101"))->Fill(cent, sampleIndex, fQ112131_101); + histos.get(HIST("Prof2D_Q112131_110"))->Fill(cent, sampleIndex, fQ112131_110); + histos.get(HIST("Prof2D_Q2221_11"))->Fill(cent, sampleIndex, fQ2221_11); + histos.get(HIST("Prof2D_Q2221_01"))->Fill(cent, sampleIndex, fQ2221_01); + histos.get(HIST("Prof2D_Q2221_10"))->Fill(cent, sampleIndex, fQ2221_10); + histos.get(HIST("Prof2D_Q2221_21"))->Fill(cent, sampleIndex, fQ2221_21); + histos.get(HIST("Prof2D_Q2221_20"))->Fill(cent, sampleIndex, fQ2221_20); + histos.get(HIST("Prof2D_Q2122_21"))->Fill(cent, sampleIndex, fQ2122_21); + histos.get(HIST("Prof2D_Q2122_20"))->Fill(cent, sampleIndex, fQ2122_20); + histos.get(HIST("Prof2D_Q1121_02"))->Fill(cent, sampleIndex, fQ1121_02); + histos.get(HIST("Prof2D_Q1121_12"))->Fill(cent, sampleIndex, fQ1121_12); + histos.get(HIST("Prof2D_Q1121_22"))->Fill(cent, sampleIndex, fQ1121_22); + histos.get(HIST("Prof2D_Q1122_02"))->Fill(cent, sampleIndex, fQ1122_02); + histos.get(HIST("Prof2D_Q1122_12"))->Fill(cent, sampleIndex, fQ1122_12); + histos.get(HIST("Prof2D_Q1122_22"))->Fill(cent, sampleIndex, fQ1122_22); + histos.get(HIST("Prof2D_Q112221_001"))->Fill(cent, sampleIndex, fQ112221_001); + histos.get(HIST("Prof2D_Q112221_010"))->Fill(cent, sampleIndex, fQ112221_010); + histos.get(HIST("Prof2D_Q112221_100"))->Fill(cent, sampleIndex, fQ112221_100); + histos.get(HIST("Prof2D_Q112221_011"))->Fill(cent, sampleIndex, fQ112221_011); + histos.get(HIST("Prof2D_Q112221_101"))->Fill(cent, sampleIndex, fQ112221_101); + histos.get(HIST("Prof2D_Q112221_110"))->Fill(cent, sampleIndex, fQ112221_110); + histos.get(HIST("Prof2D_Q112221_200"))->Fill(cent, sampleIndex, fQ112221_200); + histos.get(HIST("Prof2D_Q112221_201"))->Fill(cent, sampleIndex, fQ112221_201); + histos.get(HIST("Prof2D_Q112221_210"))->Fill(cent, sampleIndex, fQ112221_210); + histos.get(HIST("Prof2D_Q112221_211"))->Fill(cent, sampleIndex, fQ112221_211); + histos.get(HIST("Prof2D_Q1131_21"))->Fill(cent, sampleIndex, fQ1131_21); + histos.get(HIST("Prof2D_Q1131_20"))->Fill(cent, sampleIndex, fQ1131_20); + histos.get(HIST("Prof2D_Q1131_31"))->Fill(cent, sampleIndex, fQ1131_31); + histos.get(HIST("Prof2D_Q1131_30"))->Fill(cent, sampleIndex, fQ1131_30); + histos.get(HIST("Prof2D_Q1132_21"))->Fill(cent, sampleIndex, fQ1132_21); + histos.get(HIST("Prof2D_Q1132_20"))->Fill(cent, sampleIndex, fQ1132_20); + histos.get(HIST("Prof2D_Q1132_31"))->Fill(cent, sampleIndex, fQ1132_31); + histos.get(HIST("Prof2D_Q1132_30"))->Fill(cent, sampleIndex, fQ1132_30); + histos.get(HIST("Prof2D_Q1133_21"))->Fill(cent, sampleIndex, fQ1133_21); + histos.get(HIST("Prof2D_Q1133_20"))->Fill(cent, sampleIndex, fQ1133_20); + histos.get(HIST("Prof2D_Q1133_31"))->Fill(cent, sampleIndex, fQ1133_31); + histos.get(HIST("Prof2D_Q1133_30"))->Fill(cent, sampleIndex, fQ1133_30); + histos.get(HIST("Prof2D_Q11_5"))->Fill(cent, sampleIndex, fQ11_5); + histos.get(HIST("Prof2D_Q11_6"))->Fill(cent, sampleIndex, fQ11_6); + histos.get(HIST("Prof2D_Q1121_30"))->Fill(cent, sampleIndex, fQ1121_30); + histos.get(HIST("Prof2D_Q1121_31"))->Fill(cent, sampleIndex, fQ1121_31); + histos.get(HIST("Prof2D_Q1121_40"))->Fill(cent, sampleIndex, fQ1121_40); + histos.get(HIST("Prof2D_Q1121_41"))->Fill(cent, sampleIndex, fQ1121_41); + histos.get(HIST("Prof2D_Q1122_30"))->Fill(cent, sampleIndex, fQ1122_30); + histos.get(HIST("Prof2D_Q1122_31"))->Fill(cent, sampleIndex, fQ1122_31); + histos.get(HIST("Prof2D_Q1122_40"))->Fill(cent, sampleIndex, fQ1122_40); + histos.get(HIST("Prof2D_Q1122_41"))->Fill(cent, sampleIndex, fQ1122_41); + histos.get(HIST("Prof2D_Q2211_11"))->Fill(cent, sampleIndex, fQ2211_11); + histos.get(HIST("Prof2D_Q2211_01"))->Fill(cent, sampleIndex, fQ2211_01); + histos.get(HIST("Prof2D_Q2211_10"))->Fill(cent, sampleIndex, fQ2211_10); + histos.get(HIST("Prof2D_Q2211_20"))->Fill(cent, sampleIndex, fQ2211_20); + histos.get(HIST("Prof2D_Q2211_21"))->Fill(cent, sampleIndex, fQ2211_21); + histos.get(HIST("Prof2D_Q2111_11"))->Fill(cent, sampleIndex, fQ2111_11); + histos.get(HIST("Prof2D_Q2111_01"))->Fill(cent, sampleIndex, fQ2111_01); + histos.get(HIST("Prof2D_Q2111_10"))->Fill(cent, sampleIndex, fQ2111_10); + histos.get(HIST("Prof2D_Q2111_20"))->Fill(cent, sampleIndex, fQ2111_20); + histos.get(HIST("Prof2D_Q2111_21"))->Fill(cent, sampleIndex, fQ2111_21); + histos.get(HIST("Prof2D_Q112122_001"))->Fill(cent, sampleIndex, fQ112122_001); + histos.get(HIST("Prof2D_Q112122_010"))->Fill(cent, sampleIndex, fQ112122_010); + histos.get(HIST("Prof2D_Q112122_100"))->Fill(cent, sampleIndex, fQ112122_100); + histos.get(HIST("Prof2D_Q112122_011"))->Fill(cent, sampleIndex, fQ112122_011); + histos.get(HIST("Prof2D_Q112122_101"))->Fill(cent, sampleIndex, fQ112122_101); + histos.get(HIST("Prof2D_Q112122_110"))->Fill(cent, sampleIndex, fQ112122_110); + histos.get(HIST("Prof2D_Q1141_11"))->Fill(cent, sampleIndex, fQ1141_11); + histos.get(HIST("Prof2D_Q1141_01"))->Fill(cent, sampleIndex, fQ1141_01); + histos.get(HIST("Prof2D_Q1141_10"))->Fill(cent, sampleIndex, fQ1141_10); + histos.get(HIST("Prof2D_Q1141_20"))->Fill(cent, sampleIndex, fQ1141_20); + histos.get(HIST("Prof2D_Q1141_21"))->Fill(cent, sampleIndex, fQ1141_21); + histos.get(HIST("Prof2D_Q1142_11"))->Fill(cent, sampleIndex, fQ1142_11); + histos.get(HIST("Prof2D_Q1142_01"))->Fill(cent, sampleIndex, fQ1142_01); + histos.get(HIST("Prof2D_Q1142_10"))->Fill(cent, sampleIndex, fQ1142_10); + histos.get(HIST("Prof2D_Q1142_20"))->Fill(cent, sampleIndex, fQ1142_20); + histos.get(HIST("Prof2D_Q1142_21"))->Fill(cent, sampleIndex, fQ1142_21); + histos.get(HIST("Prof2D_Q1143_11"))->Fill(cent, sampleIndex, fQ1143_11); + histos.get(HIST("Prof2D_Q1143_01"))->Fill(cent, sampleIndex, fQ1143_01); + histos.get(HIST("Prof2D_Q1143_10"))->Fill(cent, sampleIndex, fQ1143_10); + histos.get(HIST("Prof2D_Q1143_20"))->Fill(cent, sampleIndex, fQ1143_20); + histos.get(HIST("Prof2D_Q1143_21"))->Fill(cent, sampleIndex, fQ1143_21); + histos.get(HIST("Prof2D_Q1144_11"))->Fill(cent, sampleIndex, fQ1144_11); + histos.get(HIST("Prof2D_Q1144_01"))->Fill(cent, sampleIndex, fQ1144_01); + histos.get(HIST("Prof2D_Q1144_10"))->Fill(cent, sampleIndex, fQ1144_10); + histos.get(HIST("Prof2D_Q1144_20"))->Fill(cent, sampleIndex, fQ1144_20); + histos.get(HIST("Prof2D_Q1144_21"))->Fill(cent, sampleIndex, fQ1144_21); + histos.get(HIST("Prof2D_Q2131_11"))->Fill(cent, sampleIndex, fQ2131_11); + histos.get(HIST("Prof2D_Q2131_01"))->Fill(cent, sampleIndex, fQ2131_01); + histos.get(HIST("Prof2D_Q2131_10"))->Fill(cent, sampleIndex, fQ2131_10); + histos.get(HIST("Prof2D_Q2132_11"))->Fill(cent, sampleIndex, fQ2132_11); + histos.get(HIST("Prof2D_Q2132_01"))->Fill(cent, sampleIndex, fQ2132_01); + histos.get(HIST("Prof2D_Q2132_10"))->Fill(cent, sampleIndex, fQ2132_10); + histos.get(HIST("Prof2D_Q2133_11"))->Fill(cent, sampleIndex, fQ2133_11); + histos.get(HIST("Prof2D_Q2133_01"))->Fill(cent, sampleIndex, fQ2133_01); + histos.get(HIST("Prof2D_Q2133_10"))->Fill(cent, sampleIndex, fQ2133_10); + histos.get(HIST("Prof2D_Q2231_11"))->Fill(cent, sampleIndex, fQ2231_11); + histos.get(HIST("Prof2D_Q2231_01"))->Fill(cent, sampleIndex, fQ2231_01); + histos.get(HIST("Prof2D_Q2231_10"))->Fill(cent, sampleIndex, fQ2231_10); + histos.get(HIST("Prof2D_Q2232_11"))->Fill(cent, sampleIndex, fQ2232_11); + histos.get(HIST("Prof2D_Q2232_01"))->Fill(cent, sampleIndex, fQ2232_01); + histos.get(HIST("Prof2D_Q2232_10"))->Fill(cent, sampleIndex, fQ2232_10); + histos.get(HIST("Prof2D_Q2233_11"))->Fill(cent, sampleIndex, fQ2233_11); + histos.get(HIST("Prof2D_Q2233_01"))->Fill(cent, sampleIndex, fQ2233_01); + histos.get(HIST("Prof2D_Q2233_10"))->Fill(cent, sampleIndex, fQ2233_10); + histos.get(HIST("Prof2D_Q51_1"))->Fill(cent, sampleIndex, fQ51_1); + histos.get(HIST("Prof2D_Q52_1"))->Fill(cent, sampleIndex, fQ52_1); + histos.get(HIST("Prof2D_Q53_1"))->Fill(cent, sampleIndex, fQ53_1); + histos.get(HIST("Prof2D_Q54_1"))->Fill(cent, sampleIndex, fQ54_1); + histos.get(HIST("Prof2D_Q55_1"))->Fill(cent, sampleIndex, fQ55_1); + histos.get(HIST("Prof2D_Q21_3"))->Fill(cent, sampleIndex, fQ21_3); + histos.get(HIST("Prof2D_Q22_3"))->Fill(cent, sampleIndex, fQ22_3); + histos.get(HIST("Prof2D_Q31_2"))->Fill(cent, sampleIndex, fQ31_2); + histos.get(HIST("Prof2D_Q32_2"))->Fill(cent, sampleIndex, fQ32_2); + histos.get(HIST("Prof2D_Q33_2"))->Fill(cent, sampleIndex, fQ33_2); + histos.get(HIST("Prof2D_Q61_1"))->Fill(cent, sampleIndex, fQ61_1); + histos.get(HIST("Prof2D_Q62_1"))->Fill(cent, sampleIndex, fQ62_1); + histos.get(HIST("Prof2D_Q63_1"))->Fill(cent, sampleIndex, fQ63_1); + histos.get(HIST("Prof2D_Q64_1"))->Fill(cent, sampleIndex, fQ64_1); + histos.get(HIST("Prof2D_Q65_1"))->Fill(cent, sampleIndex, fQ65_1); + histos.get(HIST("Prof2D_Q66_1"))->Fill(cent, sampleIndex, fQ66_1); + histos.get(HIST("Prof2D_Q112122_111"))->Fill(cent, sampleIndex, fQ112122_111); + histos.get(HIST("Prof2D_Q112131_111"))->Fill(cent, sampleIndex, fQ112131_111); + histos.get(HIST("Prof2D_Q112132_111"))->Fill(cent, sampleIndex, fQ112132_111); + histos.get(HIST("Prof2D_Q112133_111"))->Fill(cent, sampleIndex, fQ112133_111); + histos.get(HIST("Prof2D_Q112231_111"))->Fill(cent, sampleIndex, fQ112231_111); + histos.get(HIST("Prof2D_Q112232_111"))->Fill(cent, sampleIndex, fQ112232_111); + histos.get(HIST("Prof2D_Q112233_111"))->Fill(cent, sampleIndex, fQ112233_111); + histos.get(HIST("Prof2D_Q112221_111"))->Fill(cent, sampleIndex, fQ112221_111); + } + } + PROCESS_SWITCH(AntiprotonCumulantsMc, processMCRec, "Process Generated", true); + + void processDataRec(AodCollisions::iterator const& coll, aod::BCsWithTimestamps const&, AodTracks const& inputTracks) + { + if (!coll.sel8()) { + return; + } + if (cfgUseGoodITSLayerAllCut && !(coll.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))) { + return; + } + if (cfgEvSelkNoSameBunchPileup && !(coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return; + } + + if (cfgEvSelkIsVertexTOFmatched && !(coll.selection_bit(o2::aod::evsel::kIsVertexTOFmatched))) { + return; + ; + } + + histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); + // variables + auto cent = coll.centFT0M(); + histos.fill(HIST("hCentrec"), cent); + + float nProt = 0.0; + float nAntiprot = 0.0; + std::array powerEffProt = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array powerEffAntiprot = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array fTCP0 = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array fTCP1 = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + + o2::aod::ITSResponse itsResponse; + + // Start of the Monte-Carlo reconstructed tracks + for (const auto& track : inputTracks) { + if (!track.has_collision()) { + continue; + } + + if (!track.isPVContributor()) //! track check as used in data + { + continue; + } + if ((track.pt() < cfgCutPtLower) || (track.pt() > 5.0f) || (std::abs(track.eta()) > cfgCutEta)) { + continue; + } + if (!(track.itsNCls() > cfgITScluster) || !(track.tpcNClsFound() >= cfgTPCcluster) || !(track.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) { + continue; + } + + histos.fill(HIST("hrecPtAll"), track.pt()); + histos.fill(HIST("hrecEtaAll"), track.eta()); + histos.fill(HIST("hrecPhiAll"), track.phi()); + histos.fill(HIST("hrecDcaXYAll"), track.dcaXY()); + histos.fill(HIST("hrecDcaZAll"), track.dcaZ()); + + // rejecting electron + if (cfgIfRejectElectron && isElectron(track)) { + continue; + } + // use ITS pid as well + if (cfgUseItsPid && (std::abs(itsResponse.nSigmaITS(track)) > 3.0)) { + continue; + } + // required tracks with TOF mandatory to avoid pileup + if (cfgIfMandatoryTOF && !track.hasTOF()) { + continue; + } + + bool trackSelected = false; + if (cfgPIDchoice == 0) + trackSelected = selectionPIDoldTOFveto(track); + if (cfgPIDchoice == 1) + trackSelected = selectionPIDnew(track); + if (cfgPIDchoice == 2) + trackSelected = selectionPIDold(track); + + if (trackSelected) { + // filling nSigma distribution + histos.fill(HIST("h2DnsigmaTpcVsPt"), track.pt(), track.tpcNSigmaPr()); + histos.fill(HIST("h2DnsigmaTofVsPt"), track.pt(), track.tofNSigmaPr()); + histos.fill(HIST("h2DnsigmaItsVsPt"), track.pt(), itsResponse.nSigmaITS(track)); + + // for protons + if (track.sign() > 0) { + histos.fill(HIST("hrecPtProton"), track.pt()); //! hist for p rec + histos.fill(HIST("hrecPtDistProtonVsCentrality"), track.pt(), cent); + histos.fill(HIST("hrecEtaProton"), track.eta()); + histos.fill(HIST("hrecPhiProton"), track.phi()); + histos.fill(HIST("hrecDcaXYProton"), track.dcaXY()); + histos.fill(HIST("hrecDcaZProton"), track.dcaZ()); + + if (track.pt() < cfgCutPtUpper) { + nProt = nProt + 1.0; + float pEff = getEfficiency(track); // get efficiency of track + if (pEff != 0) { + for (int i = 1; i < 7; i++) { + powerEffProt[i] += std::pow(1.0 / pEff, i); + } + } + } + } + // for anti-protons + if (track.sign() < 0) { + histos.fill(HIST("hrecPtAntiproton"), track.pt()); //! hist for anti-p rec + histos.fill(HIST("hrecPtDistAntiprotonVsCentrality"), track.pt(), cent); + histos.fill(HIST("hrecEtaAntiproton"), track.eta()); + histos.fill(HIST("hrecPhiAntiproton"), track.phi()); + histos.fill(HIST("hrecDcaXYAntiproton"), track.dcaXY()); + histos.fill(HIST("hrecDcaZAntiproton"), track.dcaZ()); + if (track.pt() < cfgCutPtUpper) { + nAntiprot = nAntiprot + 1.0; + float pEff = getEfficiency(track); // get efficiency of track + if (pEff != 0) { + for (int i = 1; i < 7; i++) { + powerEffAntiprot[i] += std::pow(1.0 / pEff, i); + } + } + } + } + + } //! checking PID + } //! end track loop + + float netProt = nAntiprot; + + histos.fill(HIST("hrecProtonVsCentrality"), nProt, cent); + histos.fill(HIST("hrecAntiprotonVsCentrality"), nAntiprot, cent); + histos.fill(HIST("hrecProfileTotalProton"), cent, (nProt + nAntiprot)); + histos.fill(HIST("hrecProfileProton"), cent, nProt); + histos.fill(HIST("hrecProfileAntiproton"), cent, nAntiprot); + histos.fill(HIST("hCorrProfileTotalProton"), cent, (powerEffProt[1] + powerEffAntiprot[1])); + histos.fill(HIST("hCorrProfileProton"), cent, powerEffProt[1]); + histos.fill(HIST("hCorrProfileAntiproton"), cent, powerEffAntiprot[1]); + + // Calculating q_{r,s} as required + for (int i = 1; i < 7; i++) { + fTCP0[i] = 0.0 + powerEffAntiprot[i]; + fTCP1[i] = 0.0 - powerEffAntiprot[i]; + } + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + float fQ11_1 = fTCP1[1]; + float fQ11_2 = std::pow(fTCP1[1], 2); + float fQ11_3 = std::pow(fTCP1[1], 3); + float fQ11_4 = std::pow(fTCP1[1], 4); + float fQ11_5 = std::pow(fTCP1[1], 5); + float fQ11_6 = std::pow(fTCP1[1], 6); + + float fQ21_3 = std::pow(fTCP0[1], 3); + float fQ22_3 = std::pow(fTCP0[2], 3); + float fQ31_2 = std::pow(fTCP1[1], 2); + float fQ32_2 = std::pow(fTCP1[2], 2); + float fQ33_2 = std::pow(fTCP1[3], 2); + + float fQ61_1 = fTCP0[1]; + float fQ62_1 = fTCP0[2]; + float fQ63_1 = fTCP0[3]; + float fQ64_1 = fTCP0[4]; + float fQ65_1 = fTCP0[5]; + float fQ66_1 = fTCP0[6]; + + float fQ112122_111 = fTCP1[1] * fTCP0[1] * fTCP0[2]; + float fQ112131_111 = fTCP1[1] * fTCP0[1] * fTCP1[1]; + float fQ112132_111 = fTCP1[1] * fTCP0[1] * fTCP1[2]; + float fQ112133_111 = fTCP1[1] * fTCP0[1] * fTCP1[3]; + float fQ112231_111 = fTCP1[1] * fTCP0[2] * fTCP1[1]; + float fQ112232_111 = fTCP1[1] * fTCP0[2] * fTCP1[2]; + float fQ112233_111 = fTCP1[1] * fTCP0[2] * fTCP1[3]; + float fQ112221_111 = fTCP1[1] * fTCP0[2] * fTCP0[1]; + + float fQ21_1 = fTCP0[1]; + float fQ22_1 = fTCP0[2]; + float fQ31_1 = fTCP1[1]; + float fQ32_1 = fTCP1[2]; + float fQ33_1 = fTCP1[3]; + float fQ41_1 = fTCP0[1]; + float fQ42_1 = fTCP0[2]; + float fQ43_1 = fTCP0[3]; + float fQ44_1 = fTCP0[4]; + float fQ21_2 = std::pow(fTCP0[1], 2); + float fQ22_2 = std::pow(fTCP0[2], 2); + float fQ1121_11 = fTCP1[1] * fTCP0[1]; + float fQ1121_01 = fTCP0[1]; + float fQ1121_10 = fTCP1[1]; + float fQ1121_20 = std::pow(fTCP1[1], 2); + float fQ1121_21 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ1122_11 = fTCP1[1] * fTCP0[2]; + float fQ1122_01 = fTCP0[2]; + float fQ1122_10 = fTCP1[1]; + float fQ1122_20 = std::pow(fTCP1[1], 2); + float fQ1122_21 = std::pow(fTCP1[1], 2) * fTCP0[2]; + float fQ1131_11 = fTCP1[1] * fTCP1[1]; + float fQ1131_01 = fTCP1[1]; + float fQ1131_10 = fTCP1[1]; + float fQ1132_11 = fTCP1[1] * fTCP1[2]; + float fQ1132_01 = fTCP1[2]; + float fQ1132_10 = fTCP1[1]; + float fQ1133_11 = fTCP1[1] * fTCP1[3]; + float fQ1133_01 = fTCP1[3]; + float fQ1133_10 = fTCP1[1]; + float fQ2122_11 = fTCP0[1] * fTCP0[2]; + float fQ2122_01 = fTCP0[2]; + float fQ2122_10 = fTCP0[1]; + + ///////////////---------------------> + float fQ3132_11 = fTCP1[1] * fTCP1[2]; + float fQ3132_01 = fTCP1[2]; + float fQ3132_10 = fTCP1[1]; + float fQ3133_11 = fTCP1[1] * fTCP1[3]; + float fQ3133_01 = fTCP1[3]; + float fQ3133_10 = fTCP1[1]; + float fQ3233_11 = fTCP1[2] * fTCP1[3]; + float fQ3233_01 = fTCP1[3]; + float fQ3233_10 = fTCP1[2]; + float fQ2241_11 = fTCP0[2] * fTCP0[1]; + float fQ2241_01 = fTCP0[1]; + float fQ2241_10 = fTCP0[2]; + float fQ2242_11 = fTCP0[2] * fTCP0[2]; + float fQ2242_01 = fTCP0[2]; + float fQ2242_10 = fTCP0[2]; + float fQ2243_11 = fTCP0[2] * fTCP0[3]; + float fQ2243_01 = fTCP0[3]; + float fQ2243_10 = fTCP0[2]; + float fQ2244_11 = fTCP0[2] * fTCP0[4]; + float fQ2244_01 = fTCP0[4]; + float fQ2244_10 = fTCP0[2]; + float fQ2141_11 = fTCP0[1] * fTCP0[1]; + float fQ2141_01 = fTCP0[1]; + float fQ2141_10 = fTCP0[1]; + float fQ2142_11 = fTCP0[1] * fTCP0[2]; + float fQ2142_01 = fTCP0[2]; + float fQ2142_10 = fTCP0[1]; + float fQ2143_11 = fTCP0[1] * fTCP0[3]; + float fQ2143_01 = fTCP0[3]; + float fQ2143_10 = fTCP0[1]; + float fQ2144_11 = fTCP0[1] * fTCP0[4]; + float fQ2144_01 = fTCP0[4]; + float fQ2144_10 = fTCP0[1]; + float fQ1151_11 = fTCP1[1] * fTCP1[1]; + float fQ1151_01 = fTCP1[1]; + float fQ1151_10 = fTCP1[1]; + float fQ1152_11 = fTCP1[1] * fTCP1[2]; + float fQ1152_01 = fTCP1[2]; + float fQ1152_10 = fTCP1[1]; + float fQ1153_11 = fTCP1[1] * fTCP1[3]; + float fQ1153_01 = fTCP1[3]; + float fQ1153_10 = fTCP1[1]; + float fQ1154_11 = fTCP1[1] * fTCP1[4]; + float fQ1154_01 = fTCP1[4]; + float fQ1154_10 = fTCP1[1]; + float fQ1155_11 = fTCP1[1] * fTCP1[5]; + float fQ1155_01 = fTCP1[5]; + float fQ1155_10 = fTCP1[1]; + + float fQ112233_001 = fTCP1[3]; + float fQ112233_010 = fTCP0[2]; + float fQ112233_100 = fTCP1[1]; + float fQ112233_011 = fTCP0[2] * fTCP1[3]; + float fQ112233_101 = fTCP1[1] * fTCP1[3]; + float fQ112233_110 = fTCP1[1] * fTCP0[2]; + float fQ112232_001 = fTCP1[2]; + float fQ112232_010 = fTCP0[2]; + float fQ112232_100 = fTCP1[1]; + float fQ112232_011 = fTCP0[2] * fTCP1[2]; + float fQ112232_101 = fTCP1[1] * fTCP1[2]; + float fQ112232_110 = fTCP1[1] * fTCP0[2]; + // + float fQ112231_001 = fTCP1[1]; + float fQ112231_010 = fTCP0[2]; + float fQ112231_100 = fTCP1[1]; + float fQ112231_011 = fTCP0[2] * fTCP1[1]; + float fQ112231_101 = fTCP1[1] * fTCP1[1]; + float fQ112231_110 = fTCP1[1] * fTCP0[2]; + float fQ112133_001 = fTCP1[3]; + float fQ112133_010 = fTCP0[1]; + float fQ112133_100 = fTCP1[1]; + float fQ112133_011 = fTCP0[1] * fTCP1[3]; + float fQ112133_101 = fTCP1[1] * fTCP1[3]; + float fQ112133_110 = fTCP1[1] * fTCP0[1]; + + float fQ112132_001 = fTCP1[2]; + float fQ112132_010 = fTCP0[1]; + float fQ112132_100 = fTCP1[1]; + float fQ112132_011 = fTCP0[1] * fTCP1[2]; + float fQ112132_101 = fTCP1[1] * fTCP1[2]; + float fQ112132_110 = fTCP1[1] * fTCP0[1]; + float fQ112131_001 = fTCP1[1]; + float fQ112131_010 = fTCP0[1]; + float fQ112131_100 = fTCP1[1]; + float fQ112131_011 = fTCP0[1] * fTCP1[1]; + float fQ112131_101 = fTCP1[1] * fTCP1[1]; + float fQ112131_110 = fTCP1[1] * fTCP0[1]; + + float fQ2221_11 = fTCP0[2] * fTCP0[1]; + float fQ2221_01 = fTCP0[1]; + float fQ2221_10 = fTCP0[2]; + float fQ2221_21 = std::pow(fTCP0[2], 2) * fTCP0[1]; + float fQ2221_20 = std::pow(fTCP0[2], 2); + + float fQ2122_21 = std::pow(fTCP0[1], 2) * fTCP0[2]; + float fQ2122_20 = std::pow(fTCP0[1], 2); + float fQ1121_02 = std::pow(fTCP0[1], 2); + float fQ1121_12 = fTCP1[1] * std::pow(fTCP0[1], 2); + float fQ1121_22 = std::pow(fTCP1[1], 2) * std::pow(fTCP0[1], 2); + float fQ1122_02 = std::pow(fTCP0[2], 2); + float fQ1122_12 = fTCP1[1] * std::pow(fTCP0[2], 2); + float fQ1122_22 = std::pow(fTCP1[1], 2) * std::pow(fTCP0[2], 2); + + float fQ112221_001 = fTCP0[1]; + float fQ112221_010 = fTCP0[2]; + float fQ112221_100 = fTCP1[1]; + float fQ112221_011 = fTCP0[2] * fTCP0[1]; + float fQ112221_101 = fTCP1[1] * fTCP0[1]; + float fQ112221_110 = fTCP1[1] * fTCP0[2]; + float fQ112221_200 = std::pow(fTCP1[1], 2); + float fQ112221_201 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ112221_210 = std::pow(fTCP1[1], 2) * fTCP0[2]; + float fQ112221_211 = std::pow(fTCP1[1], 2) * fTCP0[2] * fTCP0[1]; + float fQ1131_21 = std::pow(fTCP1[1], 2) * fTCP1[1]; + float fQ1131_20 = std::pow(fTCP1[1], 2); + float fQ1131_31 = std::pow(fTCP1[1], 3) * fTCP1[1]; + float fQ1131_30 = std::pow(fTCP1[1], 3); + + float fQ1132_21 = std::pow(fTCP1[1], 2) * fTCP1[2]; + float fQ1132_20 = std::pow(fTCP1[1], 2); + float fQ1132_31 = std::pow(fTCP1[1], 3) * fTCP1[2]; + float fQ1132_30 = std::pow(fTCP1[1], 3); + float fQ1133_21 = std::pow(fTCP1[1], 2) * fTCP1[3]; + float fQ1133_20 = std::pow(fTCP1[1], 2); + float fQ1133_31 = std::pow(fTCP1[1], 3) * fTCP1[3]; + float fQ1133_30 = std::pow(fTCP1[1], 3); + float fQ1121_30 = std::pow(fTCP1[1], 3); + float fQ1121_31 = std::pow(fTCP1[1], 3) * fTCP0[1]; + float fQ1121_40 = std::pow(fTCP1[1], 4); + float fQ1121_41 = std::pow(fTCP1[1], 4) * fTCP0[1]; + float fQ1122_30 = std::pow(fTCP1[1], 3); + float fQ1122_31 = std::pow(fTCP1[1], 3) * fTCP0[2]; + float fQ1122_40 = std::pow(fTCP1[1], 4); + float fQ1122_41 = std::pow(fTCP1[1], 4) * fTCP0[2]; + + float fQ2211_11 = fTCP0[2] * fTCP1[1]; + float fQ2211_01 = fTCP1[1]; + float fQ2211_10 = fTCP0[2]; + float fQ2211_20 = std::pow(fTCP0[2], 2); + float fQ2211_21 = std::pow(fTCP0[2], 2) * fTCP1[1]; + float fQ2111_11 = fTCP0[1] * fTCP1[1]; + float fQ2111_01 = fTCP1[1]; + float fQ2111_10 = fTCP0[1]; + float fQ2111_20 = std::pow(fTCP0[1], 2); + float fQ2111_21 = std::pow(fTCP0[1], 2) * fTCP1[1]; + + float fQ112122_001 = fTCP0[2]; + float fQ112122_010 = fTCP0[1]; + float fQ112122_100 = fTCP1[1]; + float fQ112122_011 = fTCP0[1] * fTCP0[2]; + float fQ112122_101 = fTCP1[1] * fTCP0[2]; + float fQ112122_110 = fTCP1[1] * fTCP0[1]; + + float fQ1141_11 = fTCP1[1] * fTCP0[1]; + float fQ1141_01 = fTCP0[1]; + float fQ1141_10 = fTCP1[1]; + float fQ1141_20 = std::pow(fTCP1[1], 2); + float fQ1141_21 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ1142_11 = fTCP1[1] * fTCP0[2]; + float fQ1142_01 = fTCP0[2]; + float fQ1142_10 = fTCP1[1]; + float fQ1142_20 = std::pow(fTCP1[1], 2); + float fQ1142_21 = std::pow(fTCP1[1], 2) * fTCP0[2]; + + float fQ1143_11 = fTCP1[1] * fTCP0[3]; + float fQ1143_01 = fTCP0[3]; + float fQ1143_10 = fTCP1[1]; + float fQ1143_20 = std::pow(fTCP1[1], 2); + float fQ1143_21 = std::pow(fTCP1[1], 2) * fTCP0[3]; + float fQ1144_11 = fTCP1[1] * fTCP0[4]; + float fQ1144_01 = fTCP0[4]; + float fQ1144_10 = fTCP1[1]; + float fQ1144_20 = std::pow(fTCP1[1], 2); + float fQ1144_21 = std::pow(fTCP1[1], 2) * fTCP0[4]; + float fQ2131_11 = fTCP0[1] * fTCP1[1]; + float fQ2131_01 = fTCP1[1]; + float fQ2131_10 = fTCP0[1]; + + float fQ2132_11 = fTCP0[1] * fTCP1[2]; + float fQ2132_01 = fTCP1[2]; + float fQ2132_10 = fTCP0[1]; + float fQ2133_11 = fTCP0[1] * fTCP1[3]; + float fQ2133_01 = fTCP1[3]; + float fQ2133_10 = fTCP0[1]; + float fQ2231_11 = fTCP0[2] * fTCP1[1]; + float fQ2231_01 = fTCP1[1]; + float fQ2231_10 = fTCP0[2]; + float fQ2232_11 = fTCP0[2] * fTCP1[2]; + float fQ2232_01 = fTCP1[2]; + float fQ2232_10 = fTCP0[2]; + float fQ2233_11 = fTCP0[2] * fTCP1[3]; + float fQ2233_01 = fTCP1[3]; + float fQ2233_10 = fTCP0[2]; + + float fQ51_1 = fTCP1[1]; + float fQ52_1 = fTCP1[2]; + float fQ53_1 = fTCP1[3]; + float fQ54_1 = fTCP1[4]; + float fQ55_1 = fTCP1[5]; + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + if (cfgIsCalculateCentral) { + + // uncorrected + histos.get(HIST("Prof_mu1_antiproton"))->Fill(cent, std::pow(netProt, 1.0)); + histos.get(HIST("Prof_mu2_antiproton"))->Fill(cent, std::pow(netProt, 2.0)); + histos.get(HIST("Prof_mu3_antiproton"))->Fill(cent, std::pow(netProt, 3.0)); + histos.get(HIST("Prof_mu4_antiproton"))->Fill(cent, std::pow(netProt, 4.0)); + histos.get(HIST("Prof_mu5_antiproton"))->Fill(cent, std::pow(netProt, 5.0)); + histos.get(HIST("Prof_mu6_antiproton"))->Fill(cent, std::pow(netProt, 6.0)); + histos.get(HIST("Prof_mu7_antiproton"))->Fill(cent, std::pow(netProt, 7.0)); + histos.get(HIST("Prof_mu8_antiproton"))->Fill(cent, std::pow(netProt, 8.0)); + + // eff. corrected + histos.get(HIST("Prof_Q11_1"))->Fill(cent, fQ11_1); + histos.get(HIST("Prof_Q11_2"))->Fill(cent, fQ11_2); + histos.get(HIST("Prof_Q11_3"))->Fill(cent, fQ11_3); + histos.get(HIST("Prof_Q11_4"))->Fill(cent, fQ11_4); + histos.get(HIST("Prof_Q21_1"))->Fill(cent, fQ21_1); + histos.get(HIST("Prof_Q22_1"))->Fill(cent, fQ22_1); + histos.get(HIST("Prof_Q31_1"))->Fill(cent, fQ31_1); + histos.get(HIST("Prof_Q32_1"))->Fill(cent, fQ32_1); + histos.get(HIST("Prof_Q33_1"))->Fill(cent, fQ33_1); + histos.get(HIST("Prof_Q41_1"))->Fill(cent, fQ41_1); + histos.get(HIST("Prof_Q42_1"))->Fill(cent, fQ42_1); + histos.get(HIST("Prof_Q43_1"))->Fill(cent, fQ43_1); + histos.get(HIST("Prof_Q44_1"))->Fill(cent, fQ44_1); + histos.get(HIST("Prof_Q21_2"))->Fill(cent, fQ21_2); + histos.get(HIST("Prof_Q22_2"))->Fill(cent, fQ22_2); + histos.get(HIST("Prof_Q1121_11"))->Fill(cent, fQ1121_11); + histos.get(HIST("Prof_Q1121_01"))->Fill(cent, fQ1121_01); + histos.get(HIST("Prof_Q1121_10"))->Fill(cent, fQ1121_10); + histos.get(HIST("Prof_Q1121_20"))->Fill(cent, fQ1121_20); + histos.get(HIST("Prof_Q1121_21"))->Fill(cent, fQ1121_21); + histos.get(HIST("Prof_Q1122_11"))->Fill(cent, fQ1122_11); + histos.get(HIST("Prof_Q1122_01"))->Fill(cent, fQ1122_01); + histos.get(HIST("Prof_Q1122_10"))->Fill(cent, fQ1122_10); + histos.get(HIST("Prof_Q1122_20"))->Fill(cent, fQ1122_20); + histos.get(HIST("Prof_Q1122_21"))->Fill(cent, fQ1122_21); + histos.get(HIST("Prof_Q1131_11"))->Fill(cent, fQ1131_11); + histos.get(HIST("Prof_Q1131_01"))->Fill(cent, fQ1131_01); + histos.get(HIST("Prof_Q1131_10"))->Fill(cent, fQ1131_10); + histos.get(HIST("Prof_Q1132_11"))->Fill(cent, fQ1132_11); + histos.get(HIST("Prof_Q1132_01"))->Fill(cent, fQ1132_01); + histos.get(HIST("Prof_Q1132_10"))->Fill(cent, fQ1132_10); + histos.get(HIST("Prof_Q1133_11"))->Fill(cent, fQ1133_11); + histos.get(HIST("Prof_Q1133_01"))->Fill(cent, fQ1133_01); + histos.get(HIST("Prof_Q1133_10"))->Fill(cent, fQ1133_10); + histos.get(HIST("Prof_Q2122_11"))->Fill(cent, fQ2122_11); + histos.get(HIST("Prof_Q2122_01"))->Fill(cent, fQ2122_01); + histos.get(HIST("Prof_Q2122_10"))->Fill(cent, fQ2122_10); + histos.get(HIST("Prof_Q3132_11"))->Fill(cent, fQ3132_11); + histos.get(HIST("Prof_Q3132_01"))->Fill(cent, fQ3132_01); + histos.get(HIST("Prof_Q3132_10"))->Fill(cent, fQ3132_10); + histos.get(HIST("Prof_Q3133_11"))->Fill(cent, fQ3133_11); + histos.get(HIST("Prof_Q3133_01"))->Fill(cent, fQ3133_01); + histos.get(HIST("Prof_Q3133_10"))->Fill(cent, fQ3133_10); + histos.get(HIST("Prof_Q3233_11"))->Fill(cent, fQ3233_11); + histos.get(HIST("Prof_Q3233_01"))->Fill(cent, fQ3233_01); + histos.get(HIST("Prof_Q3233_10"))->Fill(cent, fQ3233_10); + histos.get(HIST("Prof_Q2241_11"))->Fill(cent, fQ2241_11); + histos.get(HIST("Prof_Q2241_01"))->Fill(cent, fQ2241_01); + histos.get(HIST("Prof_Q2241_10"))->Fill(cent, fQ2241_10); + histos.get(HIST("Prof_Q2242_11"))->Fill(cent, fQ2242_11); + histos.get(HIST("Prof_Q2242_01"))->Fill(cent, fQ2242_01); + histos.get(HIST("Prof_Q2242_10"))->Fill(cent, fQ2242_10); + histos.get(HIST("Prof_Q2243_11"))->Fill(cent, fQ2243_11); + histos.get(HIST("Prof_Q2243_01"))->Fill(cent, fQ2243_01); + histos.get(HIST("Prof_Q2243_10"))->Fill(cent, fQ2243_10); + histos.get(HIST("Prof_Q2244_11"))->Fill(cent, fQ2244_11); + histos.get(HIST("Prof_Q2244_01"))->Fill(cent, fQ2244_01); + histos.get(HIST("Prof_Q2244_10"))->Fill(cent, fQ2244_10); + histos.get(HIST("Prof_Q2141_11"))->Fill(cent, fQ2141_11); + histos.get(HIST("Prof_Q2141_01"))->Fill(cent, fQ2141_01); + histos.get(HIST("Prof_Q2141_10"))->Fill(cent, fQ2141_10); + histos.get(HIST("Prof_Q2142_11"))->Fill(cent, fQ2142_11); + histos.get(HIST("Prof_Q2142_01"))->Fill(cent, fQ2142_01); + histos.get(HIST("Prof_Q2142_10"))->Fill(cent, fQ2142_10); + histos.get(HIST("Prof_Q2143_11"))->Fill(cent, fQ2143_11); + histos.get(HIST("Prof_Q2143_01"))->Fill(cent, fQ2143_01); + histos.get(HIST("Prof_Q2143_10"))->Fill(cent, fQ2143_10); + histos.get(HIST("Prof_Q2144_11"))->Fill(cent, fQ2144_11); + histos.get(HIST("Prof_Q2144_01"))->Fill(cent, fQ2144_01); + histos.get(HIST("Prof_Q2144_10"))->Fill(cent, fQ2144_10); + histos.get(HIST("Prof_Q1151_11"))->Fill(cent, fQ1151_11); + histos.get(HIST("Prof_Q1151_01"))->Fill(cent, fQ1151_01); + histos.get(HIST("Prof_Q1151_10"))->Fill(cent, fQ1151_10); + histos.get(HIST("Prof_Q1152_11"))->Fill(cent, fQ1152_11); + histos.get(HIST("Prof_Q1152_01"))->Fill(cent, fQ1152_01); + histos.get(HIST("Prof_Q1152_10"))->Fill(cent, fQ1152_10); + histos.get(HIST("Prof_Q1153_11"))->Fill(cent, fQ1153_11); + histos.get(HIST("Prof_Q1153_01"))->Fill(cent, fQ1153_01); + histos.get(HIST("Prof_Q1153_10"))->Fill(cent, fQ1153_10); + histos.get(HIST("Prof_Q1154_11"))->Fill(cent, fQ1154_11); + histos.get(HIST("Prof_Q1154_01"))->Fill(cent, fQ1154_01); + histos.get(HIST("Prof_Q1154_10"))->Fill(cent, fQ1154_10); + histos.get(HIST("Prof_Q1155_11"))->Fill(cent, fQ1155_11); + histos.get(HIST("Prof_Q1155_01"))->Fill(cent, fQ1155_01); + histos.get(HIST("Prof_Q1155_10"))->Fill(cent, fQ1155_10); + histos.get(HIST("Prof_Q112233_001"))->Fill(cent, fQ112233_001); + histos.get(HIST("Prof_Q112233_010"))->Fill(cent, fQ112233_010); + histos.get(HIST("Prof_Q112233_100"))->Fill(cent, fQ112233_100); + histos.get(HIST("Prof_Q112233_011"))->Fill(cent, fQ112233_011); + histos.get(HIST("Prof_Q112233_101"))->Fill(cent, fQ112233_101); + histos.get(HIST("Prof_Q112233_110"))->Fill(cent, fQ112233_110); + histos.get(HIST("Prof_Q112232_001"))->Fill(cent, fQ112232_001); + histos.get(HIST("Prof_Q112232_010"))->Fill(cent, fQ112232_010); + histos.get(HIST("Prof_Q112232_100"))->Fill(cent, fQ112232_100); + histos.get(HIST("Prof_Q112232_011"))->Fill(cent, fQ112232_011); + histos.get(HIST("Prof_Q112232_101"))->Fill(cent, fQ112232_101); + histos.get(HIST("Prof_Q112232_110"))->Fill(cent, fQ112232_110); + histos.get(HIST("Prof_Q112231_001"))->Fill(cent, fQ112231_001); + histos.get(HIST("Prof_Q112231_010"))->Fill(cent, fQ112231_010); + histos.get(HIST("Prof_Q112231_100"))->Fill(cent, fQ112231_100); + histos.get(HIST("Prof_Q112231_011"))->Fill(cent, fQ112231_011); + histos.get(HIST("Prof_Q112231_101"))->Fill(cent, fQ112231_101); + histos.get(HIST("Prof_Q112231_110"))->Fill(cent, fQ112231_110); + histos.get(HIST("Prof_Q112133_001"))->Fill(cent, fQ112133_001); + histos.get(HIST("Prof_Q112133_010"))->Fill(cent, fQ112133_010); + histos.get(HIST("Prof_Q112133_100"))->Fill(cent, fQ112133_100); + histos.get(HIST("Prof_Q112133_011"))->Fill(cent, fQ112133_011); + histos.get(HIST("Prof_Q112133_101"))->Fill(cent, fQ112133_101); + histos.get(HIST("Prof_Q112133_110"))->Fill(cent, fQ112133_110); + histos.get(HIST("Prof_Q112132_001"))->Fill(cent, fQ112132_001); + histos.get(HIST("Prof_Q112132_010"))->Fill(cent, fQ112132_010); + histos.get(HIST("Prof_Q112132_100"))->Fill(cent, fQ112132_100); + histos.get(HIST("Prof_Q112132_011"))->Fill(cent, fQ112132_011); + histos.get(HIST("Prof_Q112132_101"))->Fill(cent, fQ112132_101); + histos.get(HIST("Prof_Q112132_110"))->Fill(cent, fQ112132_110); + histos.get(HIST("Prof_Q112131_001"))->Fill(cent, fQ112131_001); + histos.get(HIST("Prof_Q112131_010"))->Fill(cent, fQ112131_010); + histos.get(HIST("Prof_Q112131_100"))->Fill(cent, fQ112131_100); + histos.get(HIST("Prof_Q112131_011"))->Fill(cent, fQ112131_011); + histos.get(HIST("Prof_Q112131_101"))->Fill(cent, fQ112131_101); + histos.get(HIST("Prof_Q112131_110"))->Fill(cent, fQ112131_110); + histos.get(HIST("Prof_Q2221_11"))->Fill(cent, fQ2221_11); + histos.get(HIST("Prof_Q2221_01"))->Fill(cent, fQ2221_01); + histos.get(HIST("Prof_Q2221_10"))->Fill(cent, fQ2221_10); + histos.get(HIST("Prof_Q2221_21"))->Fill(cent, fQ2221_21); + histos.get(HIST("Prof_Q2221_20"))->Fill(cent, fQ2221_20); + histos.get(HIST("Prof_Q2122_21"))->Fill(cent, fQ2122_21); + histos.get(HIST("Prof_Q2122_20"))->Fill(cent, fQ2122_20); + histos.get(HIST("Prof_Q1121_02"))->Fill(cent, fQ1121_02); + histos.get(HIST("Prof_Q1121_12"))->Fill(cent, fQ1121_12); + histos.get(HIST("Prof_Q1121_22"))->Fill(cent, fQ1121_22); + histos.get(HIST("Prof_Q1122_02"))->Fill(cent, fQ1122_02); + histos.get(HIST("Prof_Q1122_12"))->Fill(cent, fQ1122_12); + histos.get(HIST("Prof_Q1122_22"))->Fill(cent, fQ1122_22); + histos.get(HIST("Prof_Q112221_001"))->Fill(cent, fQ112221_001); + histos.get(HIST("Prof_Q112221_010"))->Fill(cent, fQ112221_010); + histos.get(HIST("Prof_Q112221_100"))->Fill(cent, fQ112221_100); + histos.get(HIST("Prof_Q112221_011"))->Fill(cent, fQ112221_011); + histos.get(HIST("Prof_Q112221_101"))->Fill(cent, fQ112221_101); + histos.get(HIST("Prof_Q112221_110"))->Fill(cent, fQ112221_110); + histos.get(HIST("Prof_Q112221_200"))->Fill(cent, fQ112221_200); + histos.get(HIST("Prof_Q112221_201"))->Fill(cent, fQ112221_201); + histos.get(HIST("Prof_Q112221_210"))->Fill(cent, fQ112221_210); + histos.get(HIST("Prof_Q112221_211"))->Fill(cent, fQ112221_211); + histos.get(HIST("Prof_Q1131_21"))->Fill(cent, fQ1131_21); + histos.get(HIST("Prof_Q1131_20"))->Fill(cent, fQ1131_20); + histos.get(HIST("Prof_Q1131_31"))->Fill(cent, fQ1131_31); + histos.get(HIST("Prof_Q1131_30"))->Fill(cent, fQ1131_30); + histos.get(HIST("Prof_Q1132_21"))->Fill(cent, fQ1132_21); + histos.get(HIST("Prof_Q1132_20"))->Fill(cent, fQ1132_20); + histos.get(HIST("Prof_Q1132_31"))->Fill(cent, fQ1132_31); + histos.get(HIST("Prof_Q1132_30"))->Fill(cent, fQ1132_30); + histos.get(HIST("Prof_Q1133_21"))->Fill(cent, fQ1133_21); + histos.get(HIST("Prof_Q1133_20"))->Fill(cent, fQ1133_20); + histos.get(HIST("Prof_Q1133_31"))->Fill(cent, fQ1133_31); + histos.get(HIST("Prof_Q1133_30"))->Fill(cent, fQ1133_30); + histos.get(HIST("Prof_Q11_5"))->Fill(cent, fQ11_5); + histos.get(HIST("Prof_Q11_6"))->Fill(cent, fQ11_6); + histos.get(HIST("Prof_Q1121_30"))->Fill(cent, fQ1121_30); + histos.get(HIST("Prof_Q1121_31"))->Fill(cent, fQ1121_31); + histos.get(HIST("Prof_Q1121_40"))->Fill(cent, fQ1121_40); + histos.get(HIST("Prof_Q1121_41"))->Fill(cent, fQ1121_41); + histos.get(HIST("Prof_Q1122_30"))->Fill(cent, fQ1122_30); + histos.get(HIST("Prof_Q1122_31"))->Fill(cent, fQ1122_31); + histos.get(HIST("Prof_Q1122_40"))->Fill(cent, fQ1122_40); + histos.get(HIST("Prof_Q1122_41"))->Fill(cent, fQ1122_41); + histos.get(HIST("Prof_Q2211_11"))->Fill(cent, fQ2211_11); + histos.get(HIST("Prof_Q2211_01"))->Fill(cent, fQ2211_01); + histos.get(HIST("Prof_Q2211_10"))->Fill(cent, fQ2211_10); + histos.get(HIST("Prof_Q2211_20"))->Fill(cent, fQ2211_20); + histos.get(HIST("Prof_Q2211_21"))->Fill(cent, fQ2211_21); + histos.get(HIST("Prof_Q2111_11"))->Fill(cent, fQ2111_11); + histos.get(HIST("Prof_Q2111_01"))->Fill(cent, fQ2111_01); + histos.get(HIST("Prof_Q2111_10"))->Fill(cent, fQ2111_10); + histos.get(HIST("Prof_Q2111_20"))->Fill(cent, fQ2111_20); + histos.get(HIST("Prof_Q2111_21"))->Fill(cent, fQ2111_21); + histos.get(HIST("Prof_Q112122_001"))->Fill(cent, fQ112122_001); + histos.get(HIST("Prof_Q112122_010"))->Fill(cent, fQ112122_010); + histos.get(HIST("Prof_Q112122_100"))->Fill(cent, fQ112122_100); + histos.get(HIST("Prof_Q112122_011"))->Fill(cent, fQ112122_011); + histos.get(HIST("Prof_Q112122_101"))->Fill(cent, fQ112122_101); + histos.get(HIST("Prof_Q112122_110"))->Fill(cent, fQ112122_110); + histos.get(HIST("Prof_Q1141_11"))->Fill(cent, fQ1141_11); + histos.get(HIST("Prof_Q1141_01"))->Fill(cent, fQ1141_01); + histos.get(HIST("Prof_Q1141_10"))->Fill(cent, fQ1141_10); + histos.get(HIST("Prof_Q1141_20"))->Fill(cent, fQ1141_20); + histos.get(HIST("Prof_Q1141_21"))->Fill(cent, fQ1141_21); + histos.get(HIST("Prof_Q1142_11"))->Fill(cent, fQ1142_11); + histos.get(HIST("Prof_Q1142_01"))->Fill(cent, fQ1142_01); + histos.get(HIST("Prof_Q1142_10"))->Fill(cent, fQ1142_10); + histos.get(HIST("Prof_Q1142_20"))->Fill(cent, fQ1142_20); + histos.get(HIST("Prof_Q1142_21"))->Fill(cent, fQ1142_21); + histos.get(HIST("Prof_Q1143_11"))->Fill(cent, fQ1143_11); + histos.get(HIST("Prof_Q1143_01"))->Fill(cent, fQ1143_01); + histos.get(HIST("Prof_Q1143_10"))->Fill(cent, fQ1143_10); + histos.get(HIST("Prof_Q1143_20"))->Fill(cent, fQ1143_20); + histos.get(HIST("Prof_Q1143_21"))->Fill(cent, fQ1143_21); + histos.get(HIST("Prof_Q1144_11"))->Fill(cent, fQ1144_11); + histos.get(HIST("Prof_Q1144_01"))->Fill(cent, fQ1144_01); + histos.get(HIST("Prof_Q1144_10"))->Fill(cent, fQ1144_10); + histos.get(HIST("Prof_Q1144_20"))->Fill(cent, fQ1144_20); + histos.get(HIST("Prof_Q1144_21"))->Fill(cent, fQ1144_21); + histos.get(HIST("Prof_Q2131_11"))->Fill(cent, fQ2131_11); + histos.get(HIST("Prof_Q2131_01"))->Fill(cent, fQ2131_01); + histos.get(HIST("Prof_Q2131_10"))->Fill(cent, fQ2131_10); + histos.get(HIST("Prof_Q2132_11"))->Fill(cent, fQ2132_11); + histos.get(HIST("Prof_Q2132_01"))->Fill(cent, fQ2132_01); + histos.get(HIST("Prof_Q2132_10"))->Fill(cent, fQ2132_10); + histos.get(HIST("Prof_Q2133_11"))->Fill(cent, fQ2133_11); + histos.get(HIST("Prof_Q2133_01"))->Fill(cent, fQ2133_01); + histos.get(HIST("Prof_Q2133_10"))->Fill(cent, fQ2133_10); + histos.get(HIST("Prof_Q2231_11"))->Fill(cent, fQ2231_11); + histos.get(HIST("Prof_Q2231_01"))->Fill(cent, fQ2231_01); + histos.get(HIST("Prof_Q2231_10"))->Fill(cent, fQ2231_10); + histos.get(HIST("Prof_Q2232_11"))->Fill(cent, fQ2232_11); + histos.get(HIST("Prof_Q2232_01"))->Fill(cent, fQ2232_01); + histos.get(HIST("Prof_Q2232_10"))->Fill(cent, fQ2232_10); + histos.get(HIST("Prof_Q2233_11"))->Fill(cent, fQ2233_11); + histos.get(HIST("Prof_Q2233_01"))->Fill(cent, fQ2233_01); + histos.get(HIST("Prof_Q2233_10"))->Fill(cent, fQ2233_10); + histos.get(HIST("Prof_Q51_1"))->Fill(cent, fQ51_1); + histos.get(HIST("Prof_Q52_1"))->Fill(cent, fQ52_1); + histos.get(HIST("Prof_Q53_1"))->Fill(cent, fQ53_1); + histos.get(HIST("Prof_Q54_1"))->Fill(cent, fQ54_1); + histos.get(HIST("Prof_Q55_1"))->Fill(cent, fQ55_1); + histos.get(HIST("Prof_Q21_3"))->Fill(cent, fQ21_3); + histos.get(HIST("Prof_Q22_3"))->Fill(cent, fQ22_3); + histos.get(HIST("Prof_Q31_2"))->Fill(cent, fQ31_2); + histos.get(HIST("Prof_Q32_2"))->Fill(cent, fQ32_2); + histos.get(HIST("Prof_Q33_2"))->Fill(cent, fQ33_2); + histos.get(HIST("Prof_Q61_1"))->Fill(cent, fQ61_1); + histos.get(HIST("Prof_Q62_1"))->Fill(cent, fQ62_1); + histos.get(HIST("Prof_Q63_1"))->Fill(cent, fQ63_1); + histos.get(HIST("Prof_Q64_1"))->Fill(cent, fQ64_1); + histos.get(HIST("Prof_Q65_1"))->Fill(cent, fQ65_1); + histos.get(HIST("Prof_Q66_1"))->Fill(cent, fQ66_1); + histos.get(HIST("Prof_Q112122_111"))->Fill(cent, fQ112122_111); + histos.get(HIST("Prof_Q112131_111"))->Fill(cent, fQ112131_111); + histos.get(HIST("Prof_Q112132_111"))->Fill(cent, fQ112132_111); + histos.get(HIST("Prof_Q112133_111"))->Fill(cent, fQ112133_111); + histos.get(HIST("Prof_Q112231_111"))->Fill(cent, fQ112231_111); + histos.get(HIST("Prof_Q112232_111"))->Fill(cent, fQ112232_111); + histos.get(HIST("Prof_Q112233_111"))->Fill(cent, fQ112233_111); + histos.get(HIST("Prof_Q112221_111"))->Fill(cent, fQ112221_111); + } + + if (cfgIsCalculateError) { + // selecting subsample and filling profiles + float lRandom = fRndm->Rndm(); + int sampleIndex = static_cast(cfgNSubsample * lRandom); + + histos.get(HIST("Prof2D_mu1_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 1.0)); + histos.get(HIST("Prof2D_mu2_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 2.0)); + histos.get(HIST("Prof2D_mu3_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 3.0)); + histos.get(HIST("Prof2D_mu4_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 4.0)); + histos.get(HIST("Prof2D_mu5_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 5.0)); + histos.get(HIST("Prof2D_mu6_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 6.0)); + histos.get(HIST("Prof2D_mu7_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 7.0)); + histos.get(HIST("Prof2D_mu8_antiproton"))->Fill(cent, sampleIndex, std::pow(netProt, 8.0)); + + histos.get(HIST("Prof2D_Q11_1"))->Fill(cent, sampleIndex, fQ11_1); + histos.get(HIST("Prof2D_Q11_2"))->Fill(cent, sampleIndex, fQ11_2); + histos.get(HIST("Prof2D_Q11_3"))->Fill(cent, sampleIndex, fQ11_3); + histos.get(HIST("Prof2D_Q11_4"))->Fill(cent, sampleIndex, fQ11_4); + histos.get(HIST("Prof2D_Q21_1"))->Fill(cent, sampleIndex, fQ21_1); + histos.get(HIST("Prof2D_Q22_1"))->Fill(cent, sampleIndex, fQ22_1); + histos.get(HIST("Prof2D_Q31_1"))->Fill(cent, sampleIndex, fQ31_1); + histos.get(HIST("Prof2D_Q32_1"))->Fill(cent, sampleIndex, fQ32_1); + histos.get(HIST("Prof2D_Q33_1"))->Fill(cent, sampleIndex, fQ33_1); + histos.get(HIST("Prof2D_Q41_1"))->Fill(cent, sampleIndex, fQ41_1); + histos.get(HIST("Prof2D_Q42_1"))->Fill(cent, sampleIndex, fQ42_1); + histos.get(HIST("Prof2D_Q43_1"))->Fill(cent, sampleIndex, fQ43_1); + histos.get(HIST("Prof2D_Q44_1"))->Fill(cent, sampleIndex, fQ44_1); + histos.get(HIST("Prof2D_Q21_2"))->Fill(cent, sampleIndex, fQ21_2); + histos.get(HIST("Prof2D_Q22_2"))->Fill(cent, sampleIndex, fQ22_2); + histos.get(HIST("Prof2D_Q1121_11"))->Fill(cent, sampleIndex, fQ1121_11); + histos.get(HIST("Prof2D_Q1121_01"))->Fill(cent, sampleIndex, fQ1121_01); + histos.get(HIST("Prof2D_Q1121_10"))->Fill(cent, sampleIndex, fQ1121_10); + histos.get(HIST("Prof2D_Q1121_20"))->Fill(cent, sampleIndex, fQ1121_20); + histos.get(HIST("Prof2D_Q1121_21"))->Fill(cent, sampleIndex, fQ1121_21); + histos.get(HIST("Prof2D_Q1122_11"))->Fill(cent, sampleIndex, fQ1122_11); + histos.get(HIST("Prof2D_Q1122_01"))->Fill(cent, sampleIndex, fQ1122_01); + histos.get(HIST("Prof2D_Q1122_10"))->Fill(cent, sampleIndex, fQ1122_10); + histos.get(HIST("Prof2D_Q1122_20"))->Fill(cent, sampleIndex, fQ1122_20); + histos.get(HIST("Prof2D_Q1122_21"))->Fill(cent, sampleIndex, fQ1122_21); + histos.get(HIST("Prof2D_Q1131_11"))->Fill(cent, sampleIndex, fQ1131_11); + histos.get(HIST("Prof2D_Q1131_01"))->Fill(cent, sampleIndex, fQ1131_01); + histos.get(HIST("Prof2D_Q1131_10"))->Fill(cent, sampleIndex, fQ1131_10); + histos.get(HIST("Prof2D_Q1132_11"))->Fill(cent, sampleIndex, fQ1132_11); + histos.get(HIST("Prof2D_Q1132_01"))->Fill(cent, sampleIndex, fQ1132_01); + histos.get(HIST("Prof2D_Q1132_10"))->Fill(cent, sampleIndex, fQ1132_10); + histos.get(HIST("Prof2D_Q1133_11"))->Fill(cent, sampleIndex, fQ1133_11); + histos.get(HIST("Prof2D_Q1133_01"))->Fill(cent, sampleIndex, fQ1133_01); + histos.get(HIST("Prof2D_Q1133_10"))->Fill(cent, sampleIndex, fQ1133_10); + histos.get(HIST("Prof2D_Q2122_11"))->Fill(cent, sampleIndex, fQ2122_11); + histos.get(HIST("Prof2D_Q2122_01"))->Fill(cent, sampleIndex, fQ2122_01); + histos.get(HIST("Prof2D_Q2122_10"))->Fill(cent, sampleIndex, fQ2122_10); + histos.get(HIST("Prof2D_Q3132_11"))->Fill(cent, sampleIndex, fQ3132_11); + histos.get(HIST("Prof2D_Q3132_01"))->Fill(cent, sampleIndex, fQ3132_01); + histos.get(HIST("Prof2D_Q3132_10"))->Fill(cent, sampleIndex, fQ3132_10); + histos.get(HIST("Prof2D_Q3133_11"))->Fill(cent, sampleIndex, fQ3133_11); + histos.get(HIST("Prof2D_Q3133_01"))->Fill(cent, sampleIndex, fQ3133_01); + histos.get(HIST("Prof2D_Q3133_10"))->Fill(cent, sampleIndex, fQ3133_10); + histos.get(HIST("Prof2D_Q3233_11"))->Fill(cent, sampleIndex, fQ3233_11); + histos.get(HIST("Prof2D_Q3233_01"))->Fill(cent, sampleIndex, fQ3233_01); + histos.get(HIST("Prof2D_Q3233_10"))->Fill(cent, sampleIndex, fQ3233_10); + histos.get(HIST("Prof2D_Q2241_11"))->Fill(cent, sampleIndex, fQ2241_11); + histos.get(HIST("Prof2D_Q2241_01"))->Fill(cent, sampleIndex, fQ2241_01); + histos.get(HIST("Prof2D_Q2241_10"))->Fill(cent, sampleIndex, fQ2241_10); + histos.get(HIST("Prof2D_Q2242_11"))->Fill(cent, sampleIndex, fQ2242_11); + histos.get(HIST("Prof2D_Q2242_01"))->Fill(cent, sampleIndex, fQ2242_01); + histos.get(HIST("Prof2D_Q2242_10"))->Fill(cent, sampleIndex, fQ2242_10); + histos.get(HIST("Prof2D_Q2243_11"))->Fill(cent, sampleIndex, fQ2243_11); + histos.get(HIST("Prof2D_Q2243_01"))->Fill(cent, sampleIndex, fQ2243_01); + histos.get(HIST("Prof2D_Q2243_10"))->Fill(cent, sampleIndex, fQ2243_10); + histos.get(HIST("Prof2D_Q2244_11"))->Fill(cent, sampleIndex, fQ2244_11); + histos.get(HIST("Prof2D_Q2244_01"))->Fill(cent, sampleIndex, fQ2244_01); + histos.get(HIST("Prof2D_Q2244_10"))->Fill(cent, sampleIndex, fQ2244_10); + histos.get(HIST("Prof2D_Q2141_11"))->Fill(cent, sampleIndex, fQ2141_11); + histos.get(HIST("Prof2D_Q2141_01"))->Fill(cent, sampleIndex, fQ2141_01); + histos.get(HIST("Prof2D_Q2141_10"))->Fill(cent, sampleIndex, fQ2141_10); + histos.get(HIST("Prof2D_Q2142_11"))->Fill(cent, sampleIndex, fQ2142_11); + histos.get(HIST("Prof2D_Q2142_01"))->Fill(cent, sampleIndex, fQ2142_01); + histos.get(HIST("Prof2D_Q2142_10"))->Fill(cent, sampleIndex, fQ2142_10); + histos.get(HIST("Prof2D_Q2143_11"))->Fill(cent, sampleIndex, fQ2143_11); + histos.get(HIST("Prof2D_Q2143_01"))->Fill(cent, sampleIndex, fQ2143_01); + histos.get(HIST("Prof2D_Q2143_10"))->Fill(cent, sampleIndex, fQ2143_10); + histos.get(HIST("Prof2D_Q2144_11"))->Fill(cent, sampleIndex, fQ2144_11); + histos.get(HIST("Prof2D_Q2144_01"))->Fill(cent, sampleIndex, fQ2144_01); + histos.get(HIST("Prof2D_Q2144_10"))->Fill(cent, sampleIndex, fQ2144_10); + histos.get(HIST("Prof2D_Q1151_11"))->Fill(cent, sampleIndex, fQ1151_11); + histos.get(HIST("Prof2D_Q1151_01"))->Fill(cent, sampleIndex, fQ1151_01); + histos.get(HIST("Prof2D_Q1151_10"))->Fill(cent, sampleIndex, fQ1151_10); + histos.get(HIST("Prof2D_Q1152_11"))->Fill(cent, sampleIndex, fQ1152_11); + histos.get(HIST("Prof2D_Q1152_01"))->Fill(cent, sampleIndex, fQ1152_01); + histos.get(HIST("Prof2D_Q1152_10"))->Fill(cent, sampleIndex, fQ1152_10); + histos.get(HIST("Prof2D_Q1153_11"))->Fill(cent, sampleIndex, fQ1153_11); + histos.get(HIST("Prof2D_Q1153_01"))->Fill(cent, sampleIndex, fQ1153_01); + histos.get(HIST("Prof2D_Q1153_10"))->Fill(cent, sampleIndex, fQ1153_10); + histos.get(HIST("Prof2D_Q1154_11"))->Fill(cent, sampleIndex, fQ1154_11); + histos.get(HIST("Prof2D_Q1154_01"))->Fill(cent, sampleIndex, fQ1154_01); + histos.get(HIST("Prof2D_Q1154_10"))->Fill(cent, sampleIndex, fQ1154_10); + histos.get(HIST("Prof2D_Q1155_11"))->Fill(cent, sampleIndex, fQ1155_11); + histos.get(HIST("Prof2D_Q1155_01"))->Fill(cent, sampleIndex, fQ1155_01); + histos.get(HIST("Prof2D_Q1155_10"))->Fill(cent, sampleIndex, fQ1155_10); + histos.get(HIST("Prof2D_Q112233_001"))->Fill(cent, sampleIndex, fQ112233_001); + histos.get(HIST("Prof2D_Q112233_010"))->Fill(cent, sampleIndex, fQ112233_010); + histos.get(HIST("Prof2D_Q112233_100"))->Fill(cent, sampleIndex, fQ112233_100); + histos.get(HIST("Prof2D_Q112233_011"))->Fill(cent, sampleIndex, fQ112233_011); + histos.get(HIST("Prof2D_Q112233_101"))->Fill(cent, sampleIndex, fQ112233_101); + histos.get(HIST("Prof2D_Q112233_110"))->Fill(cent, sampleIndex, fQ112233_110); + histos.get(HIST("Prof2D_Q112232_001"))->Fill(cent, sampleIndex, fQ112232_001); + histos.get(HIST("Prof2D_Q112232_010"))->Fill(cent, sampleIndex, fQ112232_010); + histos.get(HIST("Prof2D_Q112232_100"))->Fill(cent, sampleIndex, fQ112232_100); + histos.get(HIST("Prof2D_Q112232_011"))->Fill(cent, sampleIndex, fQ112232_011); + histos.get(HIST("Prof2D_Q112232_101"))->Fill(cent, sampleIndex, fQ112232_101); + histos.get(HIST("Prof2D_Q112232_110"))->Fill(cent, sampleIndex, fQ112232_110); + histos.get(HIST("Prof2D_Q112231_001"))->Fill(cent, sampleIndex, fQ112231_001); + histos.get(HIST("Prof2D_Q112231_010"))->Fill(cent, sampleIndex, fQ112231_010); + histos.get(HIST("Prof2D_Q112231_100"))->Fill(cent, sampleIndex, fQ112231_100); + histos.get(HIST("Prof2D_Q112231_011"))->Fill(cent, sampleIndex, fQ112231_011); + histos.get(HIST("Prof2D_Q112231_101"))->Fill(cent, sampleIndex, fQ112231_101); + histos.get(HIST("Prof2D_Q112231_110"))->Fill(cent, sampleIndex, fQ112231_110); + histos.get(HIST("Prof2D_Q112133_001"))->Fill(cent, sampleIndex, fQ112133_001); + histos.get(HIST("Prof2D_Q112133_010"))->Fill(cent, sampleIndex, fQ112133_010); + histos.get(HIST("Prof2D_Q112133_100"))->Fill(cent, sampleIndex, fQ112133_100); + histos.get(HIST("Prof2D_Q112133_011"))->Fill(cent, sampleIndex, fQ112133_011); + histos.get(HIST("Prof2D_Q112133_101"))->Fill(cent, sampleIndex, fQ112133_101); + histos.get(HIST("Prof2D_Q112133_110"))->Fill(cent, sampleIndex, fQ112133_110); + histos.get(HIST("Prof2D_Q112132_001"))->Fill(cent, sampleIndex, fQ112132_001); + histos.get(HIST("Prof2D_Q112132_010"))->Fill(cent, sampleIndex, fQ112132_010); + histos.get(HIST("Prof2D_Q112132_100"))->Fill(cent, sampleIndex, fQ112132_100); + histos.get(HIST("Prof2D_Q112132_011"))->Fill(cent, sampleIndex, fQ112132_011); + histos.get(HIST("Prof2D_Q112132_101"))->Fill(cent, sampleIndex, fQ112132_101); + histos.get(HIST("Prof2D_Q112132_110"))->Fill(cent, sampleIndex, fQ112132_110); + histos.get(HIST("Prof2D_Q112131_001"))->Fill(cent, sampleIndex, fQ112131_001); + histos.get(HIST("Prof2D_Q112131_010"))->Fill(cent, sampleIndex, fQ112131_010); + histos.get(HIST("Prof2D_Q112131_100"))->Fill(cent, sampleIndex, fQ112131_100); + histos.get(HIST("Prof2D_Q112131_011"))->Fill(cent, sampleIndex, fQ112131_011); + histos.get(HIST("Prof2D_Q112131_101"))->Fill(cent, sampleIndex, fQ112131_101); + histos.get(HIST("Prof2D_Q112131_110"))->Fill(cent, sampleIndex, fQ112131_110); + histos.get(HIST("Prof2D_Q2221_11"))->Fill(cent, sampleIndex, fQ2221_11); + histos.get(HIST("Prof2D_Q2221_01"))->Fill(cent, sampleIndex, fQ2221_01); + histos.get(HIST("Prof2D_Q2221_10"))->Fill(cent, sampleIndex, fQ2221_10); + histos.get(HIST("Prof2D_Q2221_21"))->Fill(cent, sampleIndex, fQ2221_21); + histos.get(HIST("Prof2D_Q2221_20"))->Fill(cent, sampleIndex, fQ2221_20); + histos.get(HIST("Prof2D_Q2122_21"))->Fill(cent, sampleIndex, fQ2122_21); + histos.get(HIST("Prof2D_Q2122_20"))->Fill(cent, sampleIndex, fQ2122_20); + histos.get(HIST("Prof2D_Q1121_02"))->Fill(cent, sampleIndex, fQ1121_02); + histos.get(HIST("Prof2D_Q1121_12"))->Fill(cent, sampleIndex, fQ1121_12); + histos.get(HIST("Prof2D_Q1121_22"))->Fill(cent, sampleIndex, fQ1121_22); + histos.get(HIST("Prof2D_Q1122_02"))->Fill(cent, sampleIndex, fQ1122_02); + histos.get(HIST("Prof2D_Q1122_12"))->Fill(cent, sampleIndex, fQ1122_12); + histos.get(HIST("Prof2D_Q1122_22"))->Fill(cent, sampleIndex, fQ1122_22); + histos.get(HIST("Prof2D_Q112221_001"))->Fill(cent, sampleIndex, fQ112221_001); + histos.get(HIST("Prof2D_Q112221_010"))->Fill(cent, sampleIndex, fQ112221_010); + histos.get(HIST("Prof2D_Q112221_100"))->Fill(cent, sampleIndex, fQ112221_100); + histos.get(HIST("Prof2D_Q112221_011"))->Fill(cent, sampleIndex, fQ112221_011); + histos.get(HIST("Prof2D_Q112221_101"))->Fill(cent, sampleIndex, fQ112221_101); + histos.get(HIST("Prof2D_Q112221_110"))->Fill(cent, sampleIndex, fQ112221_110); + histos.get(HIST("Prof2D_Q112221_200"))->Fill(cent, sampleIndex, fQ112221_200); + histos.get(HIST("Prof2D_Q112221_201"))->Fill(cent, sampleIndex, fQ112221_201); + histos.get(HIST("Prof2D_Q112221_210"))->Fill(cent, sampleIndex, fQ112221_210); + histos.get(HIST("Prof2D_Q112221_211"))->Fill(cent, sampleIndex, fQ112221_211); + histos.get(HIST("Prof2D_Q1131_21"))->Fill(cent, sampleIndex, fQ1131_21); + histos.get(HIST("Prof2D_Q1131_20"))->Fill(cent, sampleIndex, fQ1131_20); + histos.get(HIST("Prof2D_Q1131_31"))->Fill(cent, sampleIndex, fQ1131_31); + histos.get(HIST("Prof2D_Q1131_30"))->Fill(cent, sampleIndex, fQ1131_30); + histos.get(HIST("Prof2D_Q1132_21"))->Fill(cent, sampleIndex, fQ1132_21); + histos.get(HIST("Prof2D_Q1132_20"))->Fill(cent, sampleIndex, fQ1132_20); + histos.get(HIST("Prof2D_Q1132_31"))->Fill(cent, sampleIndex, fQ1132_31); + histos.get(HIST("Prof2D_Q1132_30"))->Fill(cent, sampleIndex, fQ1132_30); + histos.get(HIST("Prof2D_Q1133_21"))->Fill(cent, sampleIndex, fQ1133_21); + histos.get(HIST("Prof2D_Q1133_20"))->Fill(cent, sampleIndex, fQ1133_20); + histos.get(HIST("Prof2D_Q1133_31"))->Fill(cent, sampleIndex, fQ1133_31); + histos.get(HIST("Prof2D_Q1133_30"))->Fill(cent, sampleIndex, fQ1133_30); + histos.get(HIST("Prof2D_Q11_5"))->Fill(cent, sampleIndex, fQ11_5); + histos.get(HIST("Prof2D_Q11_6"))->Fill(cent, sampleIndex, fQ11_6); + histos.get(HIST("Prof2D_Q1121_30"))->Fill(cent, sampleIndex, fQ1121_30); + histos.get(HIST("Prof2D_Q1121_31"))->Fill(cent, sampleIndex, fQ1121_31); + histos.get(HIST("Prof2D_Q1121_40"))->Fill(cent, sampleIndex, fQ1121_40); + histos.get(HIST("Prof2D_Q1121_41"))->Fill(cent, sampleIndex, fQ1121_41); + histos.get(HIST("Prof2D_Q1122_30"))->Fill(cent, sampleIndex, fQ1122_30); + histos.get(HIST("Prof2D_Q1122_31"))->Fill(cent, sampleIndex, fQ1122_31); + histos.get(HIST("Prof2D_Q1122_40"))->Fill(cent, sampleIndex, fQ1122_40); + histos.get(HIST("Prof2D_Q1122_41"))->Fill(cent, sampleIndex, fQ1122_41); + histos.get(HIST("Prof2D_Q2211_11"))->Fill(cent, sampleIndex, fQ2211_11); + histos.get(HIST("Prof2D_Q2211_01"))->Fill(cent, sampleIndex, fQ2211_01); + histos.get(HIST("Prof2D_Q2211_10"))->Fill(cent, sampleIndex, fQ2211_10); + histos.get(HIST("Prof2D_Q2211_20"))->Fill(cent, sampleIndex, fQ2211_20); + histos.get(HIST("Prof2D_Q2211_21"))->Fill(cent, sampleIndex, fQ2211_21); + histos.get(HIST("Prof2D_Q2111_11"))->Fill(cent, sampleIndex, fQ2111_11); + histos.get(HIST("Prof2D_Q2111_01"))->Fill(cent, sampleIndex, fQ2111_01); + histos.get(HIST("Prof2D_Q2111_10"))->Fill(cent, sampleIndex, fQ2111_10); + histos.get(HIST("Prof2D_Q2111_20"))->Fill(cent, sampleIndex, fQ2111_20); + histos.get(HIST("Prof2D_Q2111_21"))->Fill(cent, sampleIndex, fQ2111_21); + histos.get(HIST("Prof2D_Q112122_001"))->Fill(cent, sampleIndex, fQ112122_001); + histos.get(HIST("Prof2D_Q112122_010"))->Fill(cent, sampleIndex, fQ112122_010); + histos.get(HIST("Prof2D_Q112122_100"))->Fill(cent, sampleIndex, fQ112122_100); + histos.get(HIST("Prof2D_Q112122_011"))->Fill(cent, sampleIndex, fQ112122_011); + histos.get(HIST("Prof2D_Q112122_101"))->Fill(cent, sampleIndex, fQ112122_101); + histos.get(HIST("Prof2D_Q112122_110"))->Fill(cent, sampleIndex, fQ112122_110); + histos.get(HIST("Prof2D_Q1141_11"))->Fill(cent, sampleIndex, fQ1141_11); + histos.get(HIST("Prof2D_Q1141_01"))->Fill(cent, sampleIndex, fQ1141_01); + histos.get(HIST("Prof2D_Q1141_10"))->Fill(cent, sampleIndex, fQ1141_10); + histos.get(HIST("Prof2D_Q1141_20"))->Fill(cent, sampleIndex, fQ1141_20); + histos.get(HIST("Prof2D_Q1141_21"))->Fill(cent, sampleIndex, fQ1141_21); + histos.get(HIST("Prof2D_Q1142_11"))->Fill(cent, sampleIndex, fQ1142_11); + histos.get(HIST("Prof2D_Q1142_01"))->Fill(cent, sampleIndex, fQ1142_01); + histos.get(HIST("Prof2D_Q1142_10"))->Fill(cent, sampleIndex, fQ1142_10); + histos.get(HIST("Prof2D_Q1142_20"))->Fill(cent, sampleIndex, fQ1142_20); + histos.get(HIST("Prof2D_Q1142_21"))->Fill(cent, sampleIndex, fQ1142_21); + histos.get(HIST("Prof2D_Q1143_11"))->Fill(cent, sampleIndex, fQ1143_11); + histos.get(HIST("Prof2D_Q1143_01"))->Fill(cent, sampleIndex, fQ1143_01); + histos.get(HIST("Prof2D_Q1143_10"))->Fill(cent, sampleIndex, fQ1143_10); + histos.get(HIST("Prof2D_Q1143_20"))->Fill(cent, sampleIndex, fQ1143_20); + histos.get(HIST("Prof2D_Q1143_21"))->Fill(cent, sampleIndex, fQ1143_21); + histos.get(HIST("Prof2D_Q1144_11"))->Fill(cent, sampleIndex, fQ1144_11); + histos.get(HIST("Prof2D_Q1144_01"))->Fill(cent, sampleIndex, fQ1144_01); + histos.get(HIST("Prof2D_Q1144_10"))->Fill(cent, sampleIndex, fQ1144_10); + histos.get(HIST("Prof2D_Q1144_20"))->Fill(cent, sampleIndex, fQ1144_20); + histos.get(HIST("Prof2D_Q1144_21"))->Fill(cent, sampleIndex, fQ1144_21); + histos.get(HIST("Prof2D_Q2131_11"))->Fill(cent, sampleIndex, fQ2131_11); + histos.get(HIST("Prof2D_Q2131_01"))->Fill(cent, sampleIndex, fQ2131_01); + histos.get(HIST("Prof2D_Q2131_10"))->Fill(cent, sampleIndex, fQ2131_10); + histos.get(HIST("Prof2D_Q2132_11"))->Fill(cent, sampleIndex, fQ2132_11); + histos.get(HIST("Prof2D_Q2132_01"))->Fill(cent, sampleIndex, fQ2132_01); + histos.get(HIST("Prof2D_Q2132_10"))->Fill(cent, sampleIndex, fQ2132_10); + histos.get(HIST("Prof2D_Q2133_11"))->Fill(cent, sampleIndex, fQ2133_11); + histos.get(HIST("Prof2D_Q2133_01"))->Fill(cent, sampleIndex, fQ2133_01); + histos.get(HIST("Prof2D_Q2133_10"))->Fill(cent, sampleIndex, fQ2133_10); + histos.get(HIST("Prof2D_Q2231_11"))->Fill(cent, sampleIndex, fQ2231_11); + histos.get(HIST("Prof2D_Q2231_01"))->Fill(cent, sampleIndex, fQ2231_01); + histos.get(HIST("Prof2D_Q2231_10"))->Fill(cent, sampleIndex, fQ2231_10); + histos.get(HIST("Prof2D_Q2232_11"))->Fill(cent, sampleIndex, fQ2232_11); + histos.get(HIST("Prof2D_Q2232_01"))->Fill(cent, sampleIndex, fQ2232_01); + histos.get(HIST("Prof2D_Q2232_10"))->Fill(cent, sampleIndex, fQ2232_10); + histos.get(HIST("Prof2D_Q2233_11"))->Fill(cent, sampleIndex, fQ2233_11); + histos.get(HIST("Prof2D_Q2233_01"))->Fill(cent, sampleIndex, fQ2233_01); + histos.get(HIST("Prof2D_Q2233_10"))->Fill(cent, sampleIndex, fQ2233_10); + histos.get(HIST("Prof2D_Q51_1"))->Fill(cent, sampleIndex, fQ51_1); + histos.get(HIST("Prof2D_Q52_1"))->Fill(cent, sampleIndex, fQ52_1); + histos.get(HIST("Prof2D_Q53_1"))->Fill(cent, sampleIndex, fQ53_1); + histos.get(HIST("Prof2D_Q54_1"))->Fill(cent, sampleIndex, fQ54_1); + histos.get(HIST("Prof2D_Q55_1"))->Fill(cent, sampleIndex, fQ55_1); + histos.get(HIST("Prof2D_Q21_3"))->Fill(cent, sampleIndex, fQ21_3); + histos.get(HIST("Prof2D_Q22_3"))->Fill(cent, sampleIndex, fQ22_3); + histos.get(HIST("Prof2D_Q31_2"))->Fill(cent, sampleIndex, fQ31_2); + histos.get(HIST("Prof2D_Q32_2"))->Fill(cent, sampleIndex, fQ32_2); + histos.get(HIST("Prof2D_Q33_2"))->Fill(cent, sampleIndex, fQ33_2); + histos.get(HIST("Prof2D_Q61_1"))->Fill(cent, sampleIndex, fQ61_1); + histos.get(HIST("Prof2D_Q62_1"))->Fill(cent, sampleIndex, fQ62_1); + histos.get(HIST("Prof2D_Q63_1"))->Fill(cent, sampleIndex, fQ63_1); + histos.get(HIST("Prof2D_Q64_1"))->Fill(cent, sampleIndex, fQ64_1); + histos.get(HIST("Prof2D_Q65_1"))->Fill(cent, sampleIndex, fQ65_1); + histos.get(HIST("Prof2D_Q66_1"))->Fill(cent, sampleIndex, fQ66_1); + histos.get(HIST("Prof2D_Q112122_111"))->Fill(cent, sampleIndex, fQ112122_111); + histos.get(HIST("Prof2D_Q112131_111"))->Fill(cent, sampleIndex, fQ112131_111); + histos.get(HIST("Prof2D_Q112132_111"))->Fill(cent, sampleIndex, fQ112132_111); + histos.get(HIST("Prof2D_Q112133_111"))->Fill(cent, sampleIndex, fQ112133_111); + histos.get(HIST("Prof2D_Q112231_111"))->Fill(cent, sampleIndex, fQ112231_111); + histos.get(HIST("Prof2D_Q112232_111"))->Fill(cent, sampleIndex, fQ112232_111); + histos.get(HIST("Prof2D_Q112233_111"))->Fill(cent, sampleIndex, fQ112233_111); + histos.get(HIST("Prof2D_Q112221_111"))->Fill(cent, sampleIndex, fQ112221_111); + } + } + PROCESS_SWITCH(AntiprotonCumulantsMc, processDataRec, "Process real data", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/PWGCF/EbyEFluctuations/Tasks/eventMeanPtId.cxx b/PWGCF/EbyEFluctuations/Tasks/eventMeanPtId.cxx new file mode 100644 index 00000000000..182876d39d1 --- /dev/null +++ b/PWGCF/EbyEFluctuations/Tasks/eventMeanPtId.cxx @@ -0,0 +1,1382 @@ +// 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. +// +/// \file eventMeanPtId.cxx +/// \brief Analysis task to study Mean pT Fluctuations using two particle correlator using Cumulant Method +/// \author Sweta Singh (sweta.singh@cern.ch) + +#include "PWGCF/Core/CorrelationContainer.h" +#include "PWGCF/Core/PairCuts.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" + +#include + +#include +#include +#include +#include + +double massPi = o2::constants::physics::MassPionCharged; +double massKa = o2::constants::physics::MassKaonCharged; +double massPr = o2::constants::physics::MassProton; + +using namespace o2::constants::physics; +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace std; +using o2::constants::physics::Pdg; + +namespace o2::aod +{ +using MyCollisions = soa::Join; +using MyTracks = soa::Join; + +using MyMCRecoCollisions = soa::Join; +using MyMCRecoCollision = MyMCRecoCollisions::iterator; + +using MyMCRecoTracks = soa::Join; +using MyMCRecoTrack = MyMCRecoTracks::iterator; + +using EventCandidatesMC = soa::Join; +using MyCollision = MyCollisions::iterator; +using MyTrack = MyTracks::iterator; +} // namespace o2::aod + +struct EventMeanPtId { + Service ccdb; + Service pdg; + + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable cfgUrlCCDB{"cfgUrlCCDB", "http://alice-ccdb.cern.ch", "url of ccdb"}; + Configurable cfgPathCCDB{"cfgPathCCDB", "Users/s/swsingh/My/Object/eff_Pb", "Path for ccdb-object"}; + Configurable cfgLoadEff{"cfgLoadEff", true, "Load efficiency"}; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + TH1D* ptHistogramAllchargeRec = nullptr; + TH1D* ptHistogramPionrec = nullptr; + TH1D* ptHistogramKaonrec = nullptr; + TH1D* ptHistogramProtonrec = nullptr; + TH1D* hRecoPi = nullptr; + TH1D* hRecoKa = nullptr; + TH1D* hRecoPr = nullptr; + TH2D* hPtyPion = nullptr; + TH2D* hPtyKaon = nullptr; + TH2D* hPtyProton = nullptr; + + Configurable ptMax{"ptMax", 2.0, "maximum pT"}; + Configurable ptMin{"ptMin", 0.15, "minimum pT"}; + Configurable> ptBins{"ptBins", {0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.05, 1.10, 1.15, 1.20, 1.25, 1.30, 1.35, 1.40, 1.45, 1.50, 1.55, 1.60, 1.65, 1.70, 1.75, 1.80, 1.85, 1.90, 1.95, 2.00}, "p_{T} bins"}; + Configurable piluprejection{"piluprejection", false, "Pileup rejection"}; + + void init(o2::framework::InitContext&) + { + if (cfgLoadEff) { + // Set CCDB url + ccdb->setURL(cfgUrlCCDB.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + // ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + // LOGF(info, "Getting object %s", ccdbPath.value.data()); + + TList* lst = ccdb->getForTimeStamp(cfgPathCCDB.value, -1); + ptHistogramAllchargeRec = reinterpret_cast(lst->FindObject("ptHistogramAllchargeRec")); + ptHistogramPionrec = reinterpret_cast(lst->FindObject("ptHistogramPionrec")); + ptHistogramKaonrec = reinterpret_cast(lst->FindObject("ptHistogramKaonrec")); + ptHistogramProtonrec = reinterpret_cast(lst->FindObject("ptHistogramProtonrec")); + hRecoPi = reinterpret_cast(lst->FindObject("hRecoPi")); + hRecoKa = reinterpret_cast(lst->FindObject("hRecoKa")); + hRecoPr = reinterpret_cast(lst->FindObject("hRecoPr")); + hPtyPion = reinterpret_cast(lst->FindObject("hPtyPion")); + hPtyKaon = reinterpret_cast(lst->FindObject("hPtyKaon")); + hPtyProton = reinterpret_cast(lst->FindObject("hPtyProton")); + + if (!ptHistogramAllchargeRec || !ptHistogramPionrec || !ptHistogramKaonrec || !ptHistogramProtonrec || !hRecoPi || !hRecoKa || !hRecoPr || !hPtyPion || !hPtyKaon || !hPtyProton) { + LOGF(info, "FATAL!! Could not find required histograms in CCDB"); + } + } + + std::vector ptBinning = {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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0}; + // AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec vtxZAxis = {100, -20.0, 20.0, "Z (cm)"}; + AxisSpec dcaAxis = {1002, -5.01, 5.01, "DCA_{xy} (cm)"}; + AxisSpec dcazAxis = {1002, -5.01, 5.01, "DCA_{z} (cm)"}; + AxisSpec ptAxis = {600, 0.0, 6.0, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec pAxis = {400, 0.0, 4.0, "#it{p} (GeV/#it{c})"}; + AxisSpec betaAxis = {200, 0.0, 2.0, "TOF_{#beta} (GeV/#it{c})"}; + AxisSpec dEdxAxis = {2000, 0.0, 200.0, "dE/dx (GeV/#it{c})"}; + AxisSpec etaAxis = {300, -1.5, 1.5, "#eta"}; // 300, -1.5, 1.5 + AxisSpec nSigmaTPCAxis = {170, -8.5, 8.5, "n#sigma_{TPC}^{proton}"}; + AxisSpec nSigmaTPCAxispid = {170, -8.5, 8.5, "n#sigma_{TPC}"}; + AxisSpec nSigmaTOFAxispid = {170, -8.5, 8.5, "n#sigma_{TOF}"}; + AxisSpec centAxis = {100, 0., 100., "centrality"}; + AxisSpec subAxis = {30, 0., 30., "sample"}; + AxisSpec nchAxis = {4000, 0., 4000., "nch"}; + AxisSpec varAxis1 = {400, 0., 4., "var1"}; + AxisSpec varAxis2 = {400, 0., 4., "var2"}; + AxisSpec chi2Axis = {100, 0., 100., "Chi2"}; + AxisSpec crossedRowTpcAxis = {600, 0., 600., "TPC Crossed rows"}; + AxisSpec counter = {10, 0., 10., "events"}; + + // QA Plots + histos.add("hEventcounter", "event counts", kTH1D, {counter}); + auto h = histos.add("tracksel", "tracksel", HistType::kTH1D, {{10, 0.5, 10.5}}); + h->GetXaxis()->SetBinLabel(1, "Tracks read"); + h->GetXaxis()->SetBinLabel(2, "Global track passed"); + h->GetXaxis()->SetBinLabel(3, "DCAxy passed"); + h->GetXaxis()->SetBinLabel(4, "DCAz passed"); + h->GetXaxis()->SetBinLabel(5, "Eta-cut passed"); + h->GetXaxis()->SetBinLabel(6, "pT-cut passed"); + h->GetXaxis()->SetBinLabel(7, "TPC crossed rows passed"); + h->GetXaxis()->SetBinLabel(8, "TPC Chai2cluster passed"); + h->GetXaxis()->SetBinLabel(9, "ITS Chai2cluster passed"); + + histos.add("hEventcounter_recMC", "event counts rec MC", kTH1D, {counter}); + auto hRec = histos.add("trackSelRec", "trackSelRec", HistType::kTH1D, {{10, 0.5, 10.5}}); + hRec->GetXaxis()->SetBinLabel(1, "has_mcCollision() read"); + hRec->GetXaxis()->SetBinLabel(2, "Vertex Z > 10cm passed"); + hRec->GetXaxis()->SetBinLabel(3, "sel 8 passed"); + hRec->GetXaxis()->SetBinLabel(4, "kNoSameBunchPileup passed"); + hRec->GetXaxis()->SetBinLabel(5, "kNoITSROFrameBorder passed"); + hRec->GetXaxis()->SetBinLabel(6, "klsGoodZvtxFT0vsPV passed"); + hRec->GetXaxis()->SetBinLabel(7, "klsVertexITSTPC passed"); + + histos.add("Data/hZvtx_before_sel", "hZvtx_before_sel", kTH1D, {vtxZAxis}); + histos.add("Data/hZvtx_after_sel", "hZvtx_after_sel", kTH1D, {vtxZAxis}); + histos.add("Data/hZvtx_after_sel8", "hZvtx_after_sel8", kTH1D, {vtxZAxis}); + histos.add("Data/hP", "hP", kTH1D, {pAxis}); + histos.add("Data/hEta", ";hEta", kTH1D, {etaAxis}); + histos.add("Data/hPt", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); + histos.add("Data/hNsigmaTPC", "hNsigmaTPC", kTH2D, {pAxis, nSigmaTPCAxis}); + histos.add("Data/hDCAxy", "hDCAxy", kTH1D, {dcaAxis}); + histos.add("Data/hDCAz", "hDCAz", kTH1D, {dcazAxis}); + histos.add("Data/hPtDCAxy", "hPtDCAxy", kTH2D, {ptAxis, dcaAxis}); + histos.add("Data/hPtDCAz", "hPtDCAz", kTH2D, {ptAxis, dcazAxis}); + histos.add("Data/NSigamaTPCpion", "NSigamaTPCpion", kTH2D, {ptAxis, nSigmaTPCAxispid}); + histos.add("Data/NSigamaTPCkaon", "NSigamaTPCkaon", kTH2D, {ptAxis, nSigmaTPCAxispid}); + histos.add("Data/NSigamaTPCproton", "NSigamaTPCproton", kTH2D, {ptAxis, nSigmaTPCAxispid}); + histos.add("Data/NSigamaTOFpion", "NSigamaTOFpion", kTH2D, {ptAxis, nSigmaTOFAxispid}); + histos.add("Data/NSigamaTOFkaon", "NSigamaTOFkaon", kTH2D, {ptAxis, nSigmaTOFAxispid}); + histos.add("Data/NSigamaTOFproton", "NSigamaTOFproton", kTH2D, {ptAxis, nSigmaTOFAxispid}); + histos.add("Data/NSigamaTPCTOFpion", "NSigamaTPCTOFpion", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); + histos.add("Data/NSigamaTPCTOFkaon", "NSigamaTPCTOFkaon", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); + histos.add("Data/NSigamaTPCTOFproton", "NSigamaTPCTOFproton", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); + histos.add("Data/hPtPion", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); + histos.add("Data/hPtKaon", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); + histos.add("Data/hPtProton", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); + histos.add("Data/hEtaPion", ";hEta", kTH1D, {etaAxis}); + histos.add("Data/hEtaKaon", ";hEta", kTH1D, {etaAxis}); + histos.add("Data/hEtaProton", ";hEta", kTH1D, {etaAxis}); + histos.add("Data/hyPion", ";hyPion", kTH1D, {etaAxis}); + histos.add("Data/hyKaon", ";hyKaon", kTH1D, {etaAxis}); + histos.add("Data/hyProton", ";hyProton", kTH1D, {etaAxis}); + histos.add("Data/hPtCh", "hPtCh", kTH2D, {nchAxis, ptAxis}); + histos.add("Data/hPtChPion", "hPtChPion", kTH2D, {nchAxis, ptAxis}); + histos.add("Data/hPtChKaon", "hPtChKaon", kTH2D, {nchAxis, ptAxis}); + histos.add("Data/hPtChProton", "hPtChProton", kTH2D, {nchAxis, ptAxis}); + histos.add("Data/hPtCent", "hPtCent", kTH2D, {centAxis, ptAxis}); + histos.add("Data/hPtCentPion", "hPtCentPion", kTH2D, {centAxis, ptAxis}); + histos.add("Data/hPtCentKaon", "hPtCentKaon", kTH2D, {centAxis, ptAxis}); + histos.add("Data/hPtCentProton", "hPtCentProton", kTH2D, {centAxis, ptAxis}); + histos.add("Data/hMeanPtCh", "hMeanPtCh", kTH2D, {nchAxis, ptAxis}); + histos.add("Data/hCent", "hCent", kTH2D, {nchAxis, centAxis}); + + histos.add("Data/hVar1", "hVar1", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVar2", "hVar2", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVar2meanpt", "hVar2meanpt", kTH2D, {centAxis, varAxis2}); + histos.add("Data/hVar", "hVar", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVarc", "hVarc", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVar1pi", "hVar1pi", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVar2pi", "hVar2pi", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVarpi", "hVarpi", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVar2meanptpi", "hVar2meanptpi", kTH2D, {centAxis, varAxis2}); + histos.add("Data/hVar1k", "hVar1k", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVar2k", "hVar2k", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVark", "hVark", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVar2meanptk", "hVar2meanptk", kTH2D, {centAxis, varAxis2}); + histos.add("Data/hVar1p", "hVar1p", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVar2p", "hVar2p", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVarp", "hVarp", kTH2D, {subAxis, centAxis}); + histos.add("Data/hVar2meanptp", "hVar2meanptp", kTH2D, {centAxis, varAxis2}); + + histos.add("Data/hnchAll", ";hnchAll", kTH1D, {nchAxis}); + histos.add("Data/hnchAll_bf_cut", ";hnchAll_bf_cut", kTH1D, {nchAxis}); + histos.add("Data/hnch", ";hnch", kTH1D, {nchAxis}); + histos.add("Data/hnchTrue", ";hnchTrue", kTH1D, {nchAxis}); + histos.add("Data/hnchTrue_pt", ";hnchTrue_pt", kTH1D, {nchAxis}); + + histos.add("Data/hVar1x", "hVar1x", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVar2x", "hVar2x", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVarx", "hVarx", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVar2meanptx", "hVar2meanptx", kTH2D, {nchAxis, varAxis2}); + histos.add("Data/hVar1pix", "hVar1pix", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVar2pix", "hVar2pix", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVarpix", "hVarpix", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVar2meanptpix", "hVar2meanptpix", kTH2D, {nchAxis, varAxis2}); + histos.add("Data/hVar1kx", "hVar1kx", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVar2kx", "hVar2kx", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVarkx", "hVarkx", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVar2meanptkx", "hVar2meanptkx", kTH2D, {nchAxis, varAxis2}); + histos.add("Data/hVar1px", "hVar1px", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVar2px", "hVar2px", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVarpx", "hVarpx", kTH2D, {subAxis, nchAxis}); + histos.add("Data/hVar2meanptpx", "hVar2meanptpx", kTH2D, {nchAxis, varAxis2}); + histos.add("Data/ht", "ht", kTH1D, {centAxis}); + histos.add("Data/hCentrality", "hCentrality", kTH1D, {centAxis}); + histos.add("Data/hPEta", "hPEta", kTH2D, {pAxis, etaAxis}); + histos.add("Data/hPtEta", "hPtEta", kTH2D, {ptAxis, etaAxis}); + histos.add("Data/hPy", "hPy", kTH2D, {pAxis, etaAxis}); + histos.add("Data/hPty", "hPty", kTH2D, {ptAxis, etaAxis}); + histos.add("Data/hPtyPion", "hPtyPion", kTH2D, {ptAxis, etaAxis}); + histos.add("Data/hPtyKaon", "hPtyKaon", kTH2D, {ptAxis, etaAxis}); + histos.add("Data/hPtyProton", "hPtyProton", kTH2D, {ptAxis, etaAxis}); + histos.add("Data/hTOFbeta", "hTOFbeta", kTH2D, {pAxis, betaAxis}); + histos.add("Data/hdEdx", "hdEdx", kTH2D, {pAxis, dEdxAxis}); + histos.add("Data/hTOFbeta_afterselection", "hTOFbeta_afterselection", kTH2D, {pAxis, betaAxis}); + histos.add("Data/hdEdx_afterselection", "hdEdx_afterselection", kTH2D, {pAxis, dEdxAxis}); + histos.add("Data/hTOFbeta_afterselection1", "hTOFbeta_afterselection1", kTH2D, {pAxis, betaAxis}); + histos.add("Data/hdEdx_afterselection1", "hdEdx_afterselection1", kTH2D, {pAxis, dEdxAxis}); + histos.add("Data/hTPCchi2perCluster_before", "TPC #Chi^{2}/Cluster", kTH1D, {chi2Axis}); + histos.add("Data/hITSchi2perCluster_before", "ITS #Chi^{2}/Cluster", kTH1D, {chi2Axis}); + histos.add("Data/hTPCCrossedrows_before", "Crossed TPC rows", kTH1D, {crossedRowTpcAxis}); + histos.add("Data/hTPCchi2perCluster_after", "TPC #Chi^{2}/Cluster", kTH1D, {chi2Axis}); + histos.add("Data/hITSchi2perCluster_after", "ITS #Chi^{2}/Cluster", kTH1D, {chi2Axis}); + histos.add("Data/hTPCCrossedrows_after", "Crossed TPC rows", kTH1D, {crossedRowTpcAxis}); + histos.add("Data/hdEdx_rec_bf_anycut", "hdEdx_rec_bf_anycut", kTH2D, {pAxis, dEdxAxis}); + histos.add("Data/hcent_nacc", "hcent_nacc", kTH2D, {centAxis, nchAxis}); + + histos.addClone("Data/", "Rec/"); + // rec histograms + histos.add("NSigamaTPCpion_rec", "NSigamaTPCpion_rec", kTH2D, {pAxis, nSigmaTPCAxispid}); + histos.add("NSigamaTPCkaon_rec", "NSigamaTPCkaon_rec", kTH2D, {pAxis, nSigmaTPCAxispid}); + histos.add("NSigamaTPCproton_rec", "NSigamaTPCproton_rec", kTH2D, {pAxis, nSigmaTPCAxispid}); + histos.add("NSigamaTOFpion_rec", "NSigamaTOFpion_rec", kTH2D, {pAxis, nSigmaTOFAxispid}); + histos.add("NSigamaTOFkaon_rec", "NSigamaTOFkaon_rec", kTH2D, {pAxis, nSigmaTOFAxispid}); + histos.add("NSigamaTOFproton_rec", "NSigamaTOFproton_rec", kTH2D, {pAxis, nSigmaTOFAxispid}); + histos.add("NSigamaTPCTOFpion_rec", "NSigamaTPCTOFpion_rec", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); + histos.add("NSigamaTPCTOFkaon_rec", "NSigamaTPCTOFkaon_rec", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); + histos.add("NSigamaTPCTOFproton_rec", "NSigamaTPCTOFproton_rec", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); + histos.add("NSigamaTPCpion_rec_bf_sel", "NSigamaTPCpion_rec_bf_sel", kTH2D, {pAxis, nSigmaTPCAxispid}); + histos.add("NSigamaTPCkaon_rec_bf_sel", "NSigamaTPCkaon_rec_bf_sel", kTH2D, {pAxis, nSigmaTPCAxispid}); + histos.add("NSigamaTPCproton_rec_bf_sel", "NSigamaTPCproton_rec_bf_sel", kTH2D, {pAxis, nSigmaTPCAxispid}); + histos.add("NSigamaTOFpion_rec_bf_sel", "NSigamaTOFpion_rec_bf_sel", kTH2D, {pAxis, nSigmaTOFAxispid}); + histos.add("NSigamaTOFkaon_rec_bf_sel", "NSigamaTOFkaon_rec_bf_sel", kTH2D, {pAxis, nSigmaTOFAxispid}); + histos.add("NSigamaTOFproton_rec_bf_sel", "NSigamaTOFproton_rec_bf_sel", kTH2D, {pAxis, nSigmaTOFAxispid}); + histos.add("NSigamaTPCTOFpion_rec_bf_sel", "NSigamaTPCTOFpion_rec_bf_sel", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); + histos.add("NSigamaTPCTOFkaon_rec_bf_sel", "NSigamaTPCTOFkaon_rec_bf_sel", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); + histos.add("NSigamaTPCTOFproton_rec_bf_sel", "NSigamaTPCTOFproton_rec_bf_sel", kTH2D, {nSigmaTPCAxispid, nSigmaTOFAxispid}); + histos.add("hPtyPion_rec", "hPtyPion_rec", kTH2D, {ptAxis, etaAxis}); + histos.add("hPtyKaon_rec", "hPtyKaon_rec", kTH2D, {ptAxis, etaAxis}); + histos.add("hPtyProton_rec", "hPtyProton_rec", kTH2D, {ptAxis, etaAxis}); + histos.add("hPyPion_rec", "hPyPion_rec", kTH2D, {pAxis, etaAxis}); + histos.add("hPyKaon_rec", "hPyKaon_rec", kTH2D, {pAxis, etaAxis}); + histos.add("hPyProton_rec", "hPyProton_rec", kTH2D, {pAxis, etaAxis}); + histos.add("hTOFbeta_afterselection_rec_afterpidcut", "hTOFbeta_afterselection_rec_afterpidcut", kTH2D, {pAxis, betaAxis}); + histos.add("hdEdx_afterselection_rec_afterpidcut", "hdEdx_afterselection_rec_afterpidcut", kTH2D, {pAxis, dEdxAxis}); + histos.add("hTOFbeta_afterselection_rec_beforepidcut", "hTOFbeta_afterselection_rec_beforepidcut", kTH2D, {pAxis, betaAxis}); + histos.add("hdEdx_afterselection_rec_beforepidcut", "hdEdx_afterselection_rec_beforepidcut", kTH2D, {pAxis, dEdxAxis}); + + histos.add("heffVar1x", "heffVar1x", kTH2D, {subAxis, nchAxis}); + histos.add("heffVar2x", "heffVar2x", kTH2D, {subAxis, nchAxis}); + histos.add("heffVarx", "heffVarx", kTH2D, {subAxis, nchAxis}); + histos.add("heffVar2meanptx", "heffVar2meanptx", kTH2D, {nchAxis, varAxis2}); + histos.add("hnchRec_all", ";hnchRec_all", kTH1D, {nchAxis}); + histos.add("hnchRec", ";hnchRec", kTH1D, {nchAxis}); + histos.add("hnchRec_true", ";hnchRec_true", kTH1D, {nchAxis}); + histos.add("hVar1x_rec_old", "hVar1x_rec_old", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2x_rec_old", "hVar2x_rec_old", kTH2D, {subAxis, nchAxis}); + histos.add("hVarx_rec_old", "hVarx_rec_old", kTH2D, {subAxis, nchAxis}); + histos.add("hVar1x_rec", "hVar1x_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2x_rec", "hVar2x_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVarx_rec", "hVarx_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2meanptx_rec", "hVar2meanptx_rec", kTH2D, {nchAxis, varAxis2}); + histos.add("hVar1pix_rec", "hVar1pix_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2pix_rec", "hVar2pix_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVarpix_rec", "hVarpix_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2meanptpix_rec", "hVar2meanptpix_rec", kTH2D, {nchAxis, varAxis2}); + histos.add("hVar1kx_rec", "hVar1kx_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2kx_rec", "hVar2kx_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVarkx_rec", "hVarkx_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2meanptkx_rec", "hVar2meanptkx_rec", kTH2D, {nchAxis, varAxis2}); + histos.add("hVar1px_rec", "hVar1px_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2px_rec", "hVar2px_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVarpx_rec", "hVarpx_rec", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2meanptpx_rec", "hVar2meanptpx_rec", kTH2D, {nchAxis, varAxis2}); + histos.add("hZvtx_after_sel_rec", "hZvtx_after_sel_rec", kTH1D, {vtxZAxis}); + histos.add("hZvtx_after_sel8_rec", "hZvtx_after_sel8_rec", kTH1D, {vtxZAxis}); + histos.add("etaHistogram_allcharge_rec", "etaHistogram_allcharge_rec", kTH1D, {etaAxis}); + histos.add("ptHistogram_allcharge_bfptcut_rec", "ptHistogram_allcharge_bfptcut_rec", kTH1D, {ptAxis}); + histos.add("ptHistogramAllchargeRec", "ptHistogramAllchargeRec", kTH1D, {ptAxis}); + histos.add("ptHistogramPionrec", "ptHistogramPionrec", kTH1D, {ptAxis}); + histos.add("ptHistogramKaonrec", "ptHistogramKaonrec", kTH1D, {ptAxis}); + histos.add("ptHistogramProtonrec", "ptHistogramProtonrec", kTH1D, {ptAxis}); + histos.add("ptHistogramPionrec_purity", "ptHistogramPionrec_purity", kTH1D, {ptAxis}); + histos.add("ptHistogramKaonrec_purity", "ptHistogramKaonrec_purity", kTH1D, {ptAxis}); + histos.add("ptHistogramProtonrec_purity", "ptHistogramProtonrec_purity", kTH1D, {ptAxis}); + histos.add("ptHistogramPionrec_pdg", "ptHistogramPionrec_pdg", kTH1D, {ptAxis}); + histos.add("ptHistogramKaonrec_pdg", "ptHistogramKaonrec_pdg", kTH1D, {ptAxis}); + histos.add("ptHistogramProtonrec_pdg", "ptHistogramProtonrec_pdg", kTH1D, {ptAxis}); + histos.add("Histogram_mass2_p_rec_beforesel", "Histogram_mass2_p_rec_beforesel", kTH1D, {ptAxis}); + histos.add("Histogram_mass2_p_rec_aftersel", "Histogram_mass2_p_rec_aftersel", kTH1D, {ptAxis}); + histos.add("hEffVar1x", "hEffVar1x", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVar2x", "hEffVar2x", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVarx", "hEffVarx", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVar1pix", "hEffVar1pix", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVar2pix", "hEffVar2pix", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVarpix", "hEffVarpix", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVar1kx", "hEffVar1kx", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVar2kx", "hEffVar2kx", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVarkx", "hEffVarkx", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVar1px", "hEffVar1px", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVar2px", "hEffVar2px", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVarpx", "hEffVarpx", kTH2D, {subAxis, nchAxis}); + histos.add("hEffVar2Meanptx", "hEffVar2Meanptx", kTH2D, {nchAxis, varAxis2}); + histos.add("hEffVar2Meanptpix", "hEffVar2Meanptpix", kTH2D, {nchAxis, varAxis2}); + histos.add("hEffVar2Meanptkx", "hEffVar2Meanptkx", kTH2D, {nchAxis, varAxis2}); + histos.add("hEffVar2Meanptpx", "hEffVar2Meanptpx", kTH2D, {nchAxis, varAxis2}); + //=======================MC histograms Generated ================================================ + histos.add("ptHistogram_allcharge_gen", "ptHistogram_allcharge_gen", kTH1D, {ptAxis}); + histos.add("ptHistogramPion", "ptHistogramPion", kTH1D, {ptAxis}); + histos.add("ptHistogramKaon", "ptHistogramKaon", kTH1D, {ptAxis}); + histos.add("ptHistogramProton", "ptHistogramProton", kTH1D, {ptAxis}); + histos.add("hMC_Pt", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {ptAxis}); + histos.add("MC_hZvtx_after_sel", ";#it{p}_{T} (GeV/#it{c})", kTH1D, {vtxZAxis}); + histos.add("hTOFbeta_gen_pion", "hTOFbeta_gen_pion", kTH2D, {pAxis, betaAxis}); + histos.add("hdEdx_gen_pion", "hdEdx_gen_pion", kTH2D, {pAxis, dEdxAxis}); + histos.add("hnch_gen_all", ";hnch_gen_all", kTH1D, {nchAxis}); + histos.add("hnch_gen", ";hnch_gen", kTH1D, {nchAxis}); + histos.add("hnch_gen_true", ";hnch_gen_true", kTH1D, {nchAxis}); + histos.add("hnch_gen_eta", ";hnch_gen_eta", kTH1D, {etaAxis}); + histos.add("hnch1", ";hnch1", kTH1D, {nchAxis}); + histos.add("hnch2", ";hnch2", kTH1D, {nchAxis}); + histos.add("hnch3", ";hnch3", kTH1D, {nchAxis}); + histos.add("hnch_pi", ";hnch_pi", kTH1D, {nchAxis}); + histos.add("hnch_ka", ";hnch_ka", kTH1D, {nchAxis}); + histos.add("hnch_pr", ";hnch_pr", kTH1D, {nchAxis}); + + histos.add("hVar1x_gen_old", "hVar1x_gen_old", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2x_gen_old", "hVar2x_gen_old", kTH2D, {subAxis, nchAxis}); + histos.add("hVarx_gen_old", "hVarx_gen_old", kTH2D, {subAxis, nchAxis}); + histos.add("hVar1x_gen", "hVar1x_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2x_gen", "hVar2x_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVarx_gen", "hVarx_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2meanptx_gen", "hVar2meanptx_gen", kTH2D, {nchAxis, varAxis2}); + histos.add("hVar1pix_gen", "hVar1pix_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2pix_gen", "hVar2pix_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVarpix_gen", "hVarpix_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2meanptpix_gen", "hVar2meanptpix_gen", kTH2D, {nchAxis, varAxis2}); + histos.add("hVar1kx_gen", "hVar1kx_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2kx_gen", "hVar2kx_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVarkx_gen", "hVarkx_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2meanptkx_gen", "hVar2meanptkx_gen", kTH2D, {nchAxis, varAxis2}); + histos.add("hVar1px_gen", "hVar1px_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2px_gen", "hVar2px_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVarpx_gen", "hVarpx_gen", kTH2D, {subAxis, nchAxis}); + histos.add("hVar2meanptpx_gen", "hVar2meanptpx_gen", kTH2D, {nchAxis, varAxis2}); + histos.add("hcent_nacc_rec", "hcent_nacc_rec", kTH2D, {centAxis, nchAxis}); + histos.add("hcent_nacc_gen", "hcent_nacc_gen", kTH2D, {centAxis, nchAxis}); + histos.add("hGenCentrality", "hGenCentrality", kTH1D, {centAxis}); + histos.add("hVtxZ_before_gen", "", kTH1F, {vtxZAxis}); + histos.add("hVtxZ_after_gen", "", kTH1F, {vtxZAxis}); + histos.add("hEta_gen", "", kTH1F, {etaAxis}); + histos.add("hEta_rec", "", kTH1F, {etaAxis}); + histos.add("hPt_gen", "", kTH1F, {ptAxis}); + histos.add("hPt_rec", "", kTH1F, {ptAxis}); + } + // Configurables + Configurable cVtxZcut{"cVtxZcut", 10.f, "Vertex Z"}; + Configurable cEtacut{"cEtacut", 0.8, "Eta cut"}; + Configurable cPtmincut{"cPtmincut", 0.2, "Pt min cut"}; + Configurable cPtmaxcut{"cPtmaxcut", 2.0, "Pt max cut"}; + Configurable cDcaXYcut{"cDcaXYcut", 0.12, "DCA XY cut"}; + Configurable cDcaZcut{"cDcaZcut", 0.3, "DCA Z cut"}; + Configurable cCentmincut{"cCentmincut", 0.0, "Min cent cut"}; + Configurable cCentmaxcut{"cCentmaxcut", 90.0, "Max cent cut"}; + Configurable cTPCcrosscut{"cTPCcrosscut", 70, "TPC crossrows cut"}; + Configurable cItsChiCut{"cItsChiCut", 70, "ITS chi2 cluster cut"}; + Configurable cTpcChiCut{"cTpcChiCut", 70, "TPC chi2 cluster cut"}; + + // Event selections + Configurable cSel8Trig{"cSel8Trig", true, "Sel8 (T0A + T0C) Selection Run3"}; + Configurable cTFBorder{"cTFBorder", true, "Timeframe Border Selection"}; + Configurable cNoItsROBorder{"cNoItsROBorder", true, "No ITSRO Border Cut"}; + Configurable cItsTpcVtx{"cItsTpcVtx", true, "ITS+TPC Vertex Selection"}; + Configurable cPileupReject{"cPileupReject", true, "Pileup rejection"}; + Configurable cZVtxTimeDiff{"cZVtxTimeDiff", true, "z-vtx time diff selection"}; + Configurable cIsGoodITSLayers{"cIsGoodITSLayers", true, "Good ITS Layers All"}; + Configurable cItslayerall{"cItslayerall", true, "dead staves of ITS removed"}; + Configurable cvtxtofmatched{"cvtxtofmatched", true, "TOF vertex matched"}; + Configurable cfgRejEl{"cfgRejEl", true, "Rejected electrons"}; + + // PID selection configurables + Configurable cPionPmincut{"cPionPmincut", 0.2, "pion min cut of pion"}; + Configurable cKaonPmincut{"cKaonPmincut", 0.2, "kaon min cut of kaon"}; + Configurable cProtonPmincut{"cProtonPmincut", 0.2, "proton min cut of proton"}; + Configurable cPionPmaxcut{"cPionPmaxcut", 2.0, "pion min cut of pion"}; + Configurable cKaonPmaxcut{"cKaonPmaxcut", 2.0, "kaon min cut of kaon"}; + Configurable cProtonPmaxcut{"cProtonPmaxcut", 2.0, "proton min cut of proton"}; + Configurable cPionPthcut{"cPionPthcut", 0.65, "pion threshold cut of pion"}; + Configurable cKaonPthcut{"cKaonPthcut", 0.65, "kaon threshold cut of kaon"}; + Configurable cProtonPthcut{"cProtonPthcut", 1.0, "proton threshold cut of proton"}; + Configurable cNSigCut2{"cNSigCut2", 2.0, "nSigma cut (2)"}; + Configurable cNSigCut3{"cNSigCut3", 3.0, "nSigma cut (3)"}; + Configurable cElMinCut{"cElMinCut", -3.0, "electron min cut"}; + Configurable cElMaxCut{"cElMaxCut", 5.0, "electron max cut"}; + Configurable cTwoPtlCut2{"cTwoPtlCut2", 2.0, "n2ptl cut"}; + Configurable cRapidityCut05{"cRapidityCut05", 0.5, "rapidity cut"}; + + template + bool selCollision(C const& coll) + { + + if (std::abs(coll.posZ()) > cVtxZcut) { + return false; + } // Reject the collisions with large vertex-z + histos.fill(HIST("hEventcounter"), 2.); + + // cent = coll.centFT0M(); //centrality for run3 + if (cSel8Trig && !coll.sel8()) { + return false; + } // require min bias trigger + histos.fill(HIST("hEventcounter"), 3.); + + if (cTFBorder && !coll.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (cNoItsROBorder && !coll.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return false; + } + histos.fill(HIST("trackSelRec"), 4); + + if (cPileupReject && !coll.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return false; + } + histos.fill(HIST("trackSelRec"), 5); + + if (cZVtxTimeDiff && !coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + histos.fill(HIST("trackSelRec"), 6); + + if (cItsTpcVtx && !coll.selection_bit(aod::evsel::kIsVertexITSTPC)) { + return false; + } + histos.fill(HIST("trackSelRec"), 7); + + // if (cItslayerall && !coll.selection_bit(aod::evsel::kIsGoodITSLayersAll)) {return false;} + histos.fill(HIST("trackSelRec"), 8); + + if (cvtxtofmatched && !coll.selection_bit(aod::evsel::kIsVertexTOFmatched)) { + return false; + } + histos.fill(HIST("trackSelRec"), 9); + + return true; // if all checks pass, accept the collision + } + + template + bool selTrack(T const& track) + { + if (!track.isGlobalTrack()) { + return false; + } // accept only global tracks + histos.fill(HIST("tracksel"), 2); + + // if (std::fabs(track.dcaXY()) > cDcaXYcut) {return false;} + histos.fill(HIST("tracksel"), 3); + + // if (std::fabs(track.dcaZ()) > cDcaZcut) {return false;} + histos.fill(HIST("tracksel"), 4); + + if (std::fabs(track.eta()) >= cEtacut) { + return false; + } + histos.fill(HIST("tracksel"), 5); + + if (track.pt() < cPtmincut) { + return false; + } + if (track.pt() > cPtmaxcut) { + return false; + } + histos.fill(HIST("tracksel"), 6); + + // if (track.tpcNClsCrossedRows() < cTPCcrosscut) {return false;} + histos.fill(HIST("tracksel"), 7); + + // if (track.itsChi2NCl() > cItsChiCut) {return false;} + histos.fill(HIST("tracksel"), 8); + + // if (track.tpcChi2NCl() > cTpcChiCut) {return false;} + histos.fill(HIST("tracksel"), 9); + + if (track.sign() == 0) + return false; + + return true; // if all checks pass, accept the collision + } + + template + bool rejEl(T const& track) + { + if (track.tpcNSigmaEl() > cElMinCut && track.tpcNSigmaEl() < cElMaxCut && std::fabs(track.tpcNSigmaPi()) > cNSigCut3 && std::fabs(track.tpcNSigmaKa()) > cNSigCut3 && std::fabs(track.tpcNSigmaPr()) > cNSigCut3) { + return true; + } + return false; + } + + template + bool selProton(T const& track) + { + //! if pt < threshold (For tracks without TOF information) + if (track.p() > cProtonPmincut && track.p() <= cProtonPthcut) { + if (track.hasTPC() && std::fabs(track.tpcNSigmaPr()) < cNSigCut2 && std::fabs(track.tpcNSigmaPi()) > cNSigCut2 && std::fabs(track.tpcNSigmaKa()) > cNSigCut2) { + return true; + } + } + + //! if pt < threshold (For tracks with TOF information) + if (track.p() > cProtonPmincut && track.p() <= cProtonPthcut) { + if (track.hasTOF() && std::fabs(track.tpcNSigmaPr()) < cNSigCut2 && std::fabs(track.tofNSigmaPr()) < cNSigCut2 && std::fabs(track.tpcNSigmaPi()) > cNSigCut2 && std::fabs(track.tpcNSigmaKa()) > cNSigCut2) { + return true; + } + } + + //! if pt > threshold (For tracks with TOF information) + if (track.p() > cProtonPthcut && track.p() <= cProtonPmaxcut) { + if (track.hasTPC() && track.hasTOF() && std::fabs(track.tpcNSigmaPr()) < cNSigCut2 && std::fabs(track.tofNSigmaPr()) < cNSigCut2 && std::hypot(track.tofNSigmaPi(), track.tpcNSigmaPi()) > cNSigCut2 && std::hypot(track.tofNSigmaKa(), track.tpcNSigmaKa()) > cNSigCut2) { + return true; + } + } + + return false; + } + + template + bool selKaon(T const& track) + { + //! if pt < threshold (For tracks without TOF information) + if (track.p() > cKaonPmincut && track.p() <= cKaonPthcut) { + if (track.hasTPC() && std::fabs(track.tpcNSigmaKa()) < cNSigCut2 && std::fabs(track.tpcNSigmaPi()) > cNSigCut2 && std::fabs(track.tpcNSigmaPr()) > cNSigCut2) { + return true; + } + } + + //! if pt < threshold (For tracks with TOF information) + if (track.p() > cKaonPmincut && track.p() <= cKaonPthcut) { + if (track.hasTOF() && std::fabs(track.tpcNSigmaKa()) < cNSigCut2 && std::fabs(track.tofNSigmaKa()) < cNSigCut2 && std::fabs(track.tpcNSigmaPi()) > cNSigCut2 && std::fabs(track.tpcNSigmaPr()) > cNSigCut2) { + return true; + } + } + + //! if pt > threshold (For tracks with TOF information) + if (track.p() > cKaonPthcut && track.p() <= cKaonPmaxcut) { + if (track.hasTPC() && track.hasTOF() && std::fabs(track.tpcNSigmaKa()) < cNSigCut2 && std::fabs(track.tofNSigmaKa()) < cNSigCut2 && std::hypot(track.tofNSigmaPi(), track.tpcNSigmaPi()) > cNSigCut2 && std::hypot(track.tofNSigmaPr(), track.tpcNSigmaPr()) > cNSigCut2) { + return true; + } + } + + return false; + } + + template + bool selPion(T const& track) + { + //! if pt < threshold (For tracks without TOF information) + if (track.p() > cPionPmincut && track.p() <= cPionPthcut) { + if (track.hasTPC() && std::fabs(track.tpcNSigmaPi()) < cNSigCut2 && std::fabs(track.tpcNSigmaKa()) > cNSigCut2 && std::fabs(track.tpcNSigmaPr()) > cNSigCut2) { + return true; + } + } + + //! if pt < threshold (For tracks with TOF information) + if (track.p() > cPionPmincut && track.p() <= cPionPthcut) { + if (track.hasTOF() && std::fabs(track.tpcNSigmaPi()) < cNSigCut2 && std::fabs(track.tofNSigmaPi()) < cNSigCut2 && std::fabs(track.tpcNSigmaKa()) > cNSigCut2 && std::fabs(track.tpcNSigmaPr()) > cNSigCut2) { + return true; + } + } + + //! if pt > threshold (For tracks with TOF information) + if (track.p() > cPionPthcut && track.p() <= cPionPmaxcut) { + if (track.hasTPC() && track.hasTOF() && std::fabs(track.tpcNSigmaPi()) < cNSigCut2 && std::fabs(track.tofNSigmaPi()) < cNSigCut2 && std::hypot(track.tofNSigmaKa(), track.tpcNSigmaKa()) > cNSigCut2 && std::hypot(track.tofNSigmaPr(), track.tpcNSigmaPr()) > cNSigCut2) { + return true; + } + } + + return false; + } + + double getEfficiency(double pt, TH1D* ptHistogramAllchargeRec) + { + int bin = ptHistogramAllchargeRec->FindBin(pt); + double eff = ptHistogramAllchargeRec->GetBinContent(bin); + return (eff > 0) ? eff : 1e-6; // Avoid division by zero + } + + //++++++++++++++++++++++++++++++++++++DATA CALCULATION +++++++++++++++++++++++++++++++++++++++++++++++++++++// + + void process(aod::MyCollision const& coll, aod::MyTracks const& inputTracks) + { + histos.fill(HIST("hEventcounter"), 1.); + histos.fill(HIST("Data/hZvtx_before_sel"), coll.posZ()); + + if (!selCollision(coll)) + return; + { + histos.fill(HIST("Data/hZvtx_after_sel8"), coll.posZ()); + } + + const auto cent = coll.centFT0C(); + histos.fill(HIST("Data/hCentrality"), cent); + + double nch = 0., nchPi = 0., nchKa = 0., nchPr = 0., nchAll = 0., nchAllBfCut = 0., nchEta = 0., nchPt = 0.; + double q1 = 0., q2 = 0.; + double q1Pi = 0., q2Pi = 0., q1Ka = 0., q2Ka = 0., q1Pr = 0., q2Pr = 0.; + double var1 = 0., var2 = 0., twoParAllCharge = 0.; + double var1Pi = 0., var2Pi = 0.; + double var1Ka = 0., var2Ka = 0.; + double var1Pr = 0., var2Pr = 0.; + + int sample = histos.get(HIST("Data/hZvtx_after_sel8"))->GetEntries(); + sample = sample % 30; // subsample error estimation + for (const auto& track : inputTracks) { + nchAllBfCut += 1.; + histos.fill(HIST("Data/hnchAll_bf_cut"), nchAllBfCut); + + histos.fill(HIST("tracksel"), 1); + histos.fill(HIST("Data/hTPCchi2perCluster_before"), track.tpcChi2NCl()); + histos.fill(HIST("Data/hITSchi2perCluster_before"), track.itsChi2NCl()); + histos.fill(HIST("Data/hTPCCrossedrows_before"), track.tpcNClsCrossedRows()); + + if (std::fabs(track.eta()) <= cEtacut) { + nchEta++; + histos.fill(HIST("Data/hnchTrue"), nchEta); + } + if (track.pt() >= cPtmincut && track.pt() <= cPtmaxcut) { + nchPt += 1.; + histos.fill(HIST("Data/hnchTrue_pt"), nchPt); + } + + if (track.sign() == 0) + continue; + if (!selTrack(track)) + continue; + + nchAll += 1.; + histos.fill(HIST("Data/hnchAll"), nchAll); + histos.fill(HIST("Data/hDCAxy"), track.dcaXY()); + histos.fill(HIST("Data/hDCAz"), track.dcaZ()); + histos.fill(HIST("Data/hTPCCrossedrows_after"), track.tpcNClsCrossedRows()); + histos.fill(HIST("Data/hTPCchi2perCluster_after"), track.tpcChi2NCl()); + histos.fill(HIST("Data/hITSchi2perCluster_after"), track.itsChi2NCl()); + histos.fill(HIST("Data/hP"), track.p()); + histos.fill(HIST("Data/hPt"), track.pt()); + histos.fill(HIST("Data/hEta"), track.eta()); + histos.fill(HIST("Data/hPtDCAxy"), track.pt(), track.dcaXY()); + histos.fill(HIST("Data/hPtDCAz"), track.pt(), track.dcaZ()); + histos.fill(HIST("Data/hPtEta"), track.pt(), track.eta()); + histos.fill(HIST("Data/hPEta"), track.p(), track.eta()); + histos.fill(HIST("Data/hNsigmaTPC"), track.p(), track.tpcNSigmaPr()); + + if (track.pt() >= cPtmincut || track.pt() <= cPtmaxcut) // do not change this (it is for different pt work) + { + nch += 1.; + histos.fill(HIST("Data/hnch"), nch); + } + + q1 += track.pt(); + q2 += (track.pt() * track.pt()); + + // only TPC tracks: Pion, Kaon, Proton + if (track.hasTPC() && std::abs(track.tpcNSigmaPi()) < cNSigCut3) + histos.fill(HIST("Data/NSigamaTPCpion"), track.pt(), track.tpcNSigmaPi()); + if (track.hasTPC() && std::abs(track.tpcNSigmaKa()) < cNSigCut3) + histos.fill(HIST("Data/NSigamaTPCkaon"), track.pt(), track.tpcNSigmaKa()); + if (track.hasTPC() && std::abs(track.tpcNSigmaPr()) < cNSigCut3) + histos.fill(HIST("Data/NSigamaTPCproton"), track.pt(), track.tpcNSigmaPr()); + + // only TOF tracks: Pion, Kaon, Proton + if (track.hasTOF() && std::abs(track.tofNSigmaPi()) < cNSigCut3) + histos.fill(HIST("Data/NSigamaTOFpion"), track.pt(), track.tofNSigmaPi()); + if (track.hasTOF() && std::abs(track.tofNSigmaKa()) < cNSigCut3) + histos.fill(HIST("Data/NSigamaTOFkaon"), track.pt(), track.tofNSigmaKa()); + if (track.hasTOF() && std::abs(track.tofNSigmaPr()) < cNSigCut3) + histos.fill(HIST("Data/NSigamaTOFproton"), track.pt(), track.tofNSigmaPr()); + + if (track.hasTPC()) + histos.fill(HIST("Data/hdEdx"), track.p(), track.tpcSignal()); + if (track.hasTOF()) + histos.fill(HIST("Data/hTOFbeta"), track.p(), track.beta()); + + //===================================pion============================================================== + // only TPC+TOF tracks: Pion, Kaon, Proton + if ((track.hasTPC() && std::abs(track.tpcNSigmaPi()) < cNSigCut3) && (track.hasTOF() && std::abs(track.tofNSigmaPi()) < cNSigCut3)) { + histos.fill(HIST("Data/NSigamaTPCTOFpion"), track.tpcNSigmaPi(), track.tofNSigmaPi()); + + histos.fill(HIST("Data/hdEdx_afterselection"), track.p(), track.tpcSignal()); + histos.fill(HIST("Data/hTOFbeta_afterselection"), track.p(), track.beta()); + } + + if (selPion(track)) { + histos.fill(HIST("Data/hPtPion"), track.pt()); + histos.fill(HIST("Data/hEtaPion"), track.eta()); + histos.fill(HIST("Data/hyPion"), track.rapidity(massPi)); + histos.fill(HIST("Data/hPtyPion"), track.pt(), track.rapidity(massPi)); + nchPi += 1.; + q1Pi += track.pt(); + q2Pi += (track.pt() * track.pt()); + + if (track.beta() > 1) + continue; + histos.fill(HIST("Data/hdEdx_afterselection1"), track.p(), track.tpcSignal()); + histos.fill(HIST("Data/hTOFbeta_afterselection1"), track.p(), track.beta()); + } + + //===========================kaon=============================================================== + if ((track.hasTPC() && std::abs(track.tpcNSigmaKa()) < cNSigCut3) && (track.hasTOF() && std::abs(track.tofNSigmaKa()) < cNSigCut3)) { + histos.fill(HIST("Data/NSigamaTPCTOFkaon"), track.tpcNSigmaKa(), track.tofNSigmaKa()); + histos.fill(HIST("Data/hdEdx_afterselection"), track.p(), track.tpcSignal()); + histos.fill(HIST("Data/hTOFbeta_afterselection"), track.p(), track.beta()); + } + + if (selKaon(track)) { + histos.fill(HIST("Data/hPtKaon"), track.pt()); + histos.fill(HIST("Data/hEtaKaon"), track.eta()); + histos.fill(HIST("Data/hyKaon"), track.rapidity(massKa)); + histos.fill(HIST("Data/hPtyKaon"), track.pt(), track.rapidity(massKa)); + nchKa += 1.; + q1Ka += track.pt(); + q2Ka += (track.pt() * track.pt()); + + if (track.beta() > 1) + continue; + histos.fill(HIST("Data/hdEdx_afterselection1"), track.p(), track.tpcSignal()); + histos.fill(HIST("Data/hTOFbeta_afterselection1"), track.p(), track.beta()); + } + + //============================proton=========================================================== + if ((track.hasTPC() && std::abs(track.tpcNSigmaPr()) < cNSigCut3) && (track.hasTOF() && std::abs(track.tofNSigmaPr()) < cNSigCut3)) { + histos.fill(HIST("Data/NSigamaTPCTOFproton"), track.tpcNSigmaPr(), track.tofNSigmaPr()); + histos.fill(HIST("Data/hdEdx_afterselection"), track.p(), track.tpcSignal()); + histos.fill(HIST("Data/hTOFbeta_afterselection"), track.p(), track.beta()); + } + + if (selProton(track)) { + histos.fill(HIST("Data/hPtProton"), track.pt()); + histos.fill(HIST("Data/hEtaProton"), track.eta()); + histos.fill(HIST("Data/hyProton"), track.rapidity(massPr)); + histos.fill(HIST("Data/hPtyProton"), track.pt(), track.rapidity(massPr)); + nchPr += 1.; + q1Pr += track.pt(); + q2Pr += (track.pt() * track.pt()); + + if (track.beta() > 1) + continue; + histos.fill(HIST("Data/hdEdx_afterselection1"), track.p(), track.tpcSignal()); + histos.fill(HIST("Data/hTOFbeta_afterselection1"), track.p(), track.beta()); + } + } // Track loop ends! + histos.fill(HIST("Data/hcent_nacc"), cent, nchAll); + + if (nchAll < cTwoPtlCut2) + return; + var1 = (q1 * q1 - q2) / (nchAll * (nchAll - 1)); + var2 = (q1 / nchAll); + + //------------------ all charges------------------------------------- + histos.fill(HIST("Data/hVar1"), sample, cent, var1); + histos.fill(HIST("Data/hVar2"), sample, cent, var2); + histos.fill(HIST("Data/hVarc"), sample, cent); + histos.fill(HIST("Data/hVar2meanpt"), cent, var2); + twoParAllCharge = (var1 - var2); + histos.fill(HIST("Data/hVar"), nchAll, twoParAllCharge); + + //---------------------- pions ---------------------------------------- + if (nchPi >= cTwoPtlCut2) { + var1Pi = (q1Pi * q1Pi - q2Pi) / (nchPi * (nchPi - 1)); + var2Pi = (q1Pi / nchPi); + } + + //----------------------- kaons --------------------------------------- + if (nchKa >= cTwoPtlCut2) { + var1Ka = (q1Ka * q1Ka - q2Ka) / (nchKa * (nchKa - 1)); + var2Ka = (q1Ka / nchKa); + } + + //---------------------------- protons ---------------------------------- + if (nchPr >= cTwoPtlCut2) { + var1Pr = (q1Pr * q1Pr - q2Pr) / (nchPr * (nchPr - 1)); + var2Pr = (q1Pr / nchPr); + } + + //========================centrality========================================== + histos.fill(HIST("Data/hVar1pi"), sample, cent, var1Pi); + histos.fill(HIST("Data/hVar2pi"), sample, cent, var2Pi); + histos.fill(HIST("Data/hVar2meanptpi"), cent, var2Pi); + + histos.fill(HIST("Data/hVar1k"), sample, cent, var1Ka); + histos.fill(HIST("Data/hVar2k"), sample, cent, var2Ka); + histos.fill(HIST("Data/hVar2meanptk"), cent, var2Ka); + + histos.fill(HIST("Data/hVar1p"), sample, cent, var1Pr); + histos.fill(HIST("Data/hVar2p"), sample, cent, var2Pr); + histos.fill(HIST("Data/hVar2meanptp"), cent, var2Pr); + + //-----------------------nch------------------------------------- + histos.fill(HIST("Data/hVar1x"), sample, nchAll, var1); + histos.fill(HIST("Data/hVar2x"), sample, nchAll, var2); + histos.fill(HIST("Data/hVarx"), sample, nchAll); + histos.fill(HIST("Data/hVar2meanptx"), nchAll, var2); + + histos.fill(HIST("Data/hVar1pix"), sample, nchAll, var1Pi); + histos.fill(HIST("Data/hVar2pix"), sample, nchAll, var2Pi); + histos.fill(HIST("Data/hVarpix"), sample, nchPi); + histos.fill(HIST("Data/hVar2meanptpix"), nchAll, var2Pi); + + histos.fill(HIST("Data/hVar1kx"), sample, nchAll, var1Ka); + histos.fill(HIST("Data/hVar2kx"), sample, nchAll, var2Ka); + histos.fill(HIST("Data/hVarkx"), sample, nchKa); + histos.fill(HIST("Data/hVar2meanptkx"), nchAll, var2Ka); + + histos.fill(HIST("Data/hVar1px"), sample, nchAll, var1Pr); + histos.fill(HIST("Data/hVar2px"), sample, nchAll, var2Pr); + histos.fill(HIST("Data/hVarpx"), sample, nchPr); + histos.fill(HIST("Data/hVar2meanptpx"), nchAll, var2Pr); + + } // event loop ends! + + PROCESS_SWITCH(EventMeanPtId, process, "process real data information", false); + + //++++++++++++++++++++++++++++++++++++MC Reconstructed +++++++++++++++++++++++++++++++++++++++++++++++++++++// + + SliceCache cache; + Preslice mcTrack = o2::aod::mcparticle::mcCollisionId; + void processMcReco(aod::MyMCRecoCollision const& coll, aod::MyMCRecoTracks const& inputTracks, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) + { + (void)mcCollisions; + if (!coll.has_mcCollision()) { + return; + } + histos.fill(HIST("Rec/hZvtx_before_sel"), coll.posZ()); + histos.fill(HIST("hVtxZ_before_gen"), coll.mcCollision().posZ()); + + if (cTFBorder && !coll.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return; + } + if (cNoItsROBorder && !coll.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return; + } + if (cPileupReject && !coll.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return; + } + if (cZVtxTimeDiff && !coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return; + } + if (cItsTpcVtx && !coll.selection_bit(aod::evsel::kIsVertexITSTPC)) { + return; + } + if (cvtxtofmatched && !coll.selection_bit(aod::evsel::kIsVertexTOFmatched)) { + return; + } + if (std::abs(coll.posZ()) > cVtxZcut) { + return; + } + + if (!coll.sel8()) { + return; + } + float cent = coll.centFT0C(); + histos.fill(HIST("Rec/hZvtx_after_sel8"), coll.posZ()); + + double nch = 0., nchPi = 0., nchKa = 0., nchPr = 0., nchAll = 0., nchAllBfCut = 0., nchEta = 0., nchPt = 0.; + double q1 = 0., q2 = 0.; + double q1Pi = 0., q2Pi = 0., q1Ka = 0., q2Ka = 0., q1Pr = 0., q2Pr = 0.; + double var1 = 0., var2 = 0., twoParAllCharge = 0.; + double var1Pi = 0., var2Pi = 0., var1Ka = 0., var2Ka = 0., var1Pr = 0., var2Pr = 0.; + double sumPtWeight = 0., sumWeight = 0., sumPtPtWeight = 0., var1Eff = 0., var2Eff = 0.; + double sumPtWeightPi = 0., sumWeightPi = 0., sumPtPtWeightPi = 0., var1EffPi = 0., var2EffPi = 0.; + double sumPtWeightKa = 0., sumWeightKa = 0., sumPtPtWeightKa = 0., var1EffKa = 0., var2EffKa = 0.; + double sumPtWeightPr = 0., sumWeightPr = 0., sumPtPtWeightPr = 0., var1EffPr = 0., var2EffPr = 0.; + + int sample = histos.get(HIST("Rec/hZvtx_after_sel8"))->GetEntries(); + sample = sample % 30; + + for (const auto& track : inputTracks) { + nchAllBfCut += 1.; + histos.fill(HIST("Rec/hnchAll_bf_cut"), nchAllBfCut); + histos.fill(HIST("Rec/hTPCchi2perCluster_before"), track.tpcChi2NCl()); + histos.fill(HIST("Rec/hITSchi2perCluster_before"), track.itsChi2NCl()); + histos.fill(HIST("Rec/hTPCCrossedrows_before"), track.tpcNClsCrossedRows()); + + if (std::fabs(track.eta()) <= cEtacut) { + nchEta++; + histos.fill(HIST("Rec/hnchTrue"), nchEta); + } + if (track.pt() >= cPtmincut && track.pt() <= cPtmaxcut) { + nchPt += 1.; + histos.fill(HIST("Rec/hnchTrue_pt"), nchPt); + } + if (!track.isGlobalTrack()) + continue; + if (std::fabs(track.eta()) > cEtacut) + continue; + if ((track.pt() <= cPtmincut) || (track.pt() >= cPtmaxcut)) + continue; + if (track.sign() == 0) + continue; + // if (std::fabs(track.y()) > 0.5) continue; + histos.fill(HIST("hPt_rec"), track.pt()); + histos.fill(HIST("hEta_rec"), track.eta()); + + auto mcParticle = track.mcParticle(); + nchAll += 1.; + histos.fill(HIST("Rec/hnchAll"), nchAll); + histos.fill(HIST("ptHistogramAllchargeRec"), track.pt()); + histos.fill(HIST("Rec/hDCAxy"), track.dcaXY()); + histos.fill(HIST("Rec/hDCAz"), track.dcaZ()); + histos.fill(HIST("Rec/hTPCCrossedrows_after"), track.tpcNClsCrossedRows()); + histos.fill(HIST("Rec/hTPCchi2perCluster_after"), track.tpcChi2NCl()); + histos.fill(HIST("Rec/hITSchi2perCluster_after"), track.itsChi2NCl()); + histos.fill(HIST("Rec/hP"), track.p()); + histos.fill(HIST("Rec/hPt"), track.pt()); + histos.fill(HIST("Rec/hEta"), track.eta()); + histos.fill(HIST("Rec/hPtDCAxy"), track.pt(), track.dcaXY()); + histos.fill(HIST("Rec/hPtDCAz"), track.pt(), track.dcaZ()); + histos.fill(HIST("Rec/hPtEta"), track.pt(), track.eta()); + histos.fill(HIST("Rec/hPEta"), track.p(), track.eta()); + histos.fill(HIST("Rec/hNsigmaTPC"), track.p(), track.tpcNSigmaPr()); + + if (track.pt() >= cPtmincut || track.pt() <= cPtmaxcut) // do not change this (it is for different pt work) + { + nch += 1.; + histos.fill(HIST("Rec/hnch"), nch); + } + q1 += track.pt(); + q2 += (track.pt() * track.pt()); + + double eff = getEfficiency(track.pt(), ptHistogramAllchargeRec); + // LOGF(info, " with value %.2f", eff); + sumPtWeight += track.pt() / eff; + sumPtPtWeight += (track.pt() * track.pt()) / (eff * eff); + sumWeight += 1. / eff; + + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus) + histos.fill(HIST("ptHistogramPionrec_pdg"), track.pt()); + if (std::abs(mcParticle.pdgCode()) == PDG_t::kKPlus) + histos.fill(HIST("ptHistogramKaonrec_pdg"), track.pt()); + if (std::abs(mcParticle.pdgCode()) == PDG_t::kProton) + histos.fill(HIST("ptHistogramProtonrec_pdg"), track.pt()); + + if (cfgRejEl == false && rejEl(track)) { + return; + } + + // only TPC tracks: Pion, Kaon, Proton + if (track.hasTPC() && std::abs(track.tpcNSigmaPi()) < cNSigCut3) + histos.fill(HIST("Rec/NSigamaTPCpion"), track.pt(), track.tpcNSigmaPi()); + if (track.hasTPC() && std::abs(track.tpcNSigmaKa()) < cNSigCut3) + histos.fill(HIST("Rec/NSigamaTPCkaon"), track.pt(), track.tpcNSigmaKa()); + if (track.hasTPC() && std::abs(track.tpcNSigmaPr()) < cNSigCut3) + histos.fill(HIST("Rec/NSigamaTPCproton"), track.pt(), track.tpcNSigmaPr()); + + // only TOF tracks: Pion, Kaon, Proton + if (track.hasTOF() && std::abs(track.tofNSigmaPi()) < cNSigCut3) + histos.fill(HIST("Rec/NSigamaTOFpion"), track.pt(), track.tofNSigmaPi()); + if (track.hasTOF() && std::abs(track.tofNSigmaKa()) < cNSigCut3) + histos.fill(HIST("Rec/NSigamaTOFkaon"), track.pt(), track.tofNSigmaKa()); + if (track.hasTOF() && std::abs(track.tofNSigmaPr()) < cNSigCut3) + histos.fill(HIST("Rec/NSigamaTOFproton"), track.pt(), track.tofNSigmaPr()); + + if (track.hasTPC()) + histos.fill(HIST("Rec/hdEdx"), track.p(), track.tpcSignal()); + if (track.hasTOF()) + histos.fill(HIST("Rec/hTOFbeta"), track.p(), track.beta()); + if (track.hasTPC()) + histos.fill(HIST("hdEdx_afterselection_rec_beforepidcut"), track.p(), track.tpcSignal()); + if (track.hasTOF()) + histos.fill(HIST("hTOFbeta_afterselection_rec_beforepidcut"), track.p(), track.beta()); + + //===================================pion============================================================== + if ((track.hasTPC() && std::abs(track.tpcNSigmaPi()) < cNSigCut3) && (track.hasTOF() && std::abs(track.tofNSigmaPi()) < cNSigCut3)) { + histos.fill(HIST("Rec/NSigamaTPCTOFpion"), track.tpcNSigmaPi(), track.tofNSigmaPi()); + + histos.fill(HIST("Rec/hdEdx_afterselection"), track.p(), track.tpcSignal()); + histos.fill(HIST("Rec/hTOFbeta_afterselection"), track.p(), track.beta()); + } + + if (selPion(track)) { + if (std::fabs(track.y()) > cRapidityCut05) + continue; + if (track.beta() > 1) + continue; + histos.fill(HIST("ptHistogramPionrec"), track.pt()); + histos.fill(HIST("Rec/hPtPion"), track.pt()); + histos.fill(HIST("Rec/hEtaPion"), track.eta()); + histos.fill(HIST("Rec/hyPion"), track.rapidity(massPi)); + histos.fill(HIST("Rec/hPtyPion"), track.pt(), track.rapidity(massPi)); + histos.fill(HIST("NSigamaTPCpion_rec"), track.p(), track.tpcNSigmaPi()); + histos.fill(HIST("NSigamaTOFpion_rec"), track.p(), track.tofNSigmaPi()); + histos.fill(HIST("NSigamaTPCTOFpion_rec"), track.tpcNSigmaPi(), track.tofNSigmaPi()); + histos.fill(HIST("Rec/hdEdx_afterselection1"), track.p(), track.tpcSignal()); + histos.fill(HIST("Rec/hTOFbeta_afterselection1"), track.p(), track.beta()); + if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kPiPlus) { + histos.fill(HIST("ptHistogramPionrec_purity"), track.pt()); + } + nchPi += 1.; + q1Pi += track.pt(); + q2Pi += (track.pt() * track.pt()); + + double effPi = getEfficiency(track.pt(), ptHistogramPionrec); + // LOGF(info, " with value %.2f", eff); + sumPtWeightPi += track.pt() / effPi; + sumPtPtWeightPi += (track.pt() * track.pt()) / (effPi * effPi); + sumWeightPi += 1. / effPi; + + histos.fill(HIST("hPyPion_rec"), track.p(), track.rapidity(massPi)); + histos.fill(HIST("hPtyPion_rec"), track.pt(), track.rapidity(massPi)); + } + + //===========================kaon=============================================================== + + if ((track.hasTPC() && std::abs(track.tpcNSigmaKa()) < cNSigCut3) && (track.hasTOF() && std::abs(track.tofNSigmaKa()) < cNSigCut3)) { + histos.fill(HIST("Rec/NSigamaTPCTOFkaon"), track.tpcNSigmaKa(), track.tofNSigmaKa()); + histos.fill(HIST("Rec/hdEdx_afterselection"), track.p(), track.tpcSignal()); + histos.fill(HIST("Rec/hTOFbeta_afterselection"), track.p(), track.beta()); + } + + if (selKaon(track)) { + if (std::fabs(track.y()) > cRapidityCut05) + continue; + if (track.beta() > 1) + continue; + histos.fill(HIST("ptHistogramKaonrec"), track.pt()); + histos.fill(HIST("Rec/hPtKaon"), track.pt()); + histos.fill(HIST("Rec/hEtaKaon"), track.eta()); + histos.fill(HIST("Rec/hyKaon"), track.rapidity(massKa)); + histos.fill(HIST("Rec/hPtyKaon"), track.pt(), track.rapidity(massKa)); + histos.fill(HIST("NSigamaTPCkaon_rec"), track.p(), track.tpcNSigmaKa()); + histos.fill(HIST("NSigamaTOFkaon_rec"), track.p(), track.tofNSigmaKa()); + histos.fill(HIST("NSigamaTPCTOFkaon_rec"), track.tpcNSigmaKa(), track.tofNSigmaKa()); + histos.fill(HIST("Rec/hdEdx_afterselection1"), track.p(), track.tpcSignal()); + histos.fill(HIST("Rec/hTOFbeta_afterselection1"), track.p(), track.beta()); + if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kKPlus) { + histos.fill(HIST("ptHistogramKaonrec_purity"), track.pt()); + } + nchKa += 1.; + q1Ka += track.pt(); + q2Ka += (track.pt() * track.pt()); + + double effKa = getEfficiency(track.pt(), ptHistogramKaonrec); + // LOGF(info, " with value %.2f", eff); + sumPtWeightKa += track.pt() / effKa; + sumPtPtWeightKa += (track.pt() * track.pt()) / (effKa * effKa); + sumWeightKa += 1. / effKa; + + histos.fill(HIST("hPyKaon_rec"), track.p(), track.rapidity(massKa)); + histos.fill(HIST("hPtyKaon_rec"), track.pt(), track.rapidity(massKa)); + } + + //============================proton=========================================================== + + if ((track.hasTPC() && std::abs(track.tpcNSigmaPr()) < cNSigCut3) && (track.hasTOF() && std::abs(track.tofNSigmaPr()) < cNSigCut3)) { + histos.fill(HIST("Rec/NSigamaTPCTOFproton"), track.tpcNSigmaPr(), track.tofNSigmaPr()); + histos.fill(HIST("Rec/hdEdx_afterselection"), track.p(), track.tpcSignal()); + histos.fill(HIST("Rec/hTOFbeta_afterselection"), track.p(), track.beta()); + } + + if (selProton(track)) { + if (std::fabs(track.y()) > cRapidityCut05) + continue; + if (track.beta() > 1) + continue; + histos.fill(HIST("ptHistogramProtonrec"), track.pt()); + histos.fill(HIST("Rec/hPtProton"), track.pt()); + histos.fill(HIST("Rec/hEtaProton"), track.eta()); + histos.fill(HIST("Rec/hyProton"), track.rapidity(massPr)); + histos.fill(HIST("Rec/hPtyProton"), track.pt(), track.rapidity(massPr)); + histos.fill(HIST("NSigamaTPCproton_rec"), track.p(), track.tpcNSigmaPr()); + histos.fill(HIST("NSigamaTOFproton_rec"), track.p(), track.tofNSigmaPr()); + histos.fill(HIST("NSigamaTPCTOFproton_rec"), track.tpcNSigmaPr(), track.tofNSigmaPr()); + histos.fill(HIST("Rec/hdEdx_afterselection1"), track.p(), track.tpcSignal()); + histos.fill(HIST("Rec/hTOFbeta_afterselection1"), track.p(), track.beta()); + if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kProton) { + histos.fill(HIST("ptHistogramProtonrec_purity"), track.pt()); + } + nchPr += 1.; + q1Pr += track.pt(); + q2Pr += (track.pt() * track.pt()); + + double effPr = getEfficiency(track.pt(), ptHistogramProtonrec); + // LOGF(info, " with value %.2f", eff); + sumPtWeightPr += track.pt() / effPr; + sumPtPtWeightPr += (track.pt() * track.pt()) / (effPr * effPr); + sumWeightPr += 1. / effPr; + + histos.fill(HIST("hPyProton_rec"), track.p(), track.rapidity(massPr)); + histos.fill(HIST("hPtyProton_rec"), track.pt(), track.rapidity(massPr)); + } + + } // loop over tracks + histos.fill(HIST("Rec/hcent_nacc"), cent, nchAll); + + if (nchAll < cTwoPtlCut2) + return; + var1 = (q1 * q1 - q2) / (nchAll * (nchAll - 1)); + var2 = (q1 / nchAll); + + //------------------ Efficiency corrected histograms --------------- + + var1Eff = (sumPtWeight * sumPtWeight - sumPtPtWeight) / (sumWeight * (sumWeight - 1)); + var2Eff = (sumPtWeight / sumWeight); + + histos.fill(HIST("Rec/hVar1"), sample, cent, var1); + histos.fill(HIST("Rec/hVar2"), sample, cent, var2); + histos.fill(HIST("Rec/hVarc"), sample, cent); + histos.fill(HIST("Rec/hVar2meanpt"), cent, var2); + twoParAllCharge = (var1 - var2); + histos.fill(HIST("Rec/hVar"), nchAll, twoParAllCharge); + + //---------------------- pions ---------------------------------------- + if (nchPi >= cTwoPtlCut2) { + var1Pi = (q1Pi * q1Pi - q2Pi) / (nchPi * (nchPi - 1)); + var2Pi = (q1Pi / nchPi); + + var1EffPi = (sumPtWeightPi * sumPtWeightPi - sumPtPtWeightPi) / (sumWeightPi * (sumWeightPi - 1)); + var2EffPi = (sumPtWeightPi / sumWeightPi); + } + //----------------------- kaons --------------------------------------- + if (nchKa >= cTwoPtlCut2) { + var1Ka = (q1Ka * q1Ka - q2Ka) / (nchKa * (nchKa - 1)); + var2Ka = (q1Ka / nchKa); + + var1EffKa = (sumPtWeightKa * sumPtWeightKa - sumPtPtWeightKa) / (sumWeightKa * (sumWeightKa - 1)); + var2EffKa = (sumPtWeightKa / sumWeightKa); + } + //---------------------------- protons ---------------------------------- + if (nchPr >= cTwoPtlCut2) { + var1Pr = (q1Pr * q1Pr - q2Pr) / (nchPr * (nchPr - 1)); + var2Pr = (q1Pr / nchPr); + + var1EffPr = (sumPtWeightPr * sumPtWeightPr - sumPtPtWeightPr) / (sumWeightPr * (sumWeightPr - 1)); + var2EffPr = (sumPtWeightPr / sumWeightPr); + } + //========================centrality========================================== + + histos.fill(HIST("Rec/hVar1pi"), sample, cent, var1Pi); + histos.fill(HIST("Rec/hVar2pi"), sample, cent, var2Pi); + histos.fill(HIST("Rec/hVar2meanptpi"), cent, var2Pi); + histos.fill(HIST("Rec/hVar1k"), sample, cent, var1Ka); + histos.fill(HIST("Rec/hVar2k"), sample, cent, var2Ka); + histos.fill(HIST("Rec/hVar2meanptk"), cent, var2Ka); + histos.fill(HIST("Rec/hVar1p"), sample, cent, var1Pr); + histos.fill(HIST("Rec/hVar2p"), sample, cent, var2Pr); + histos.fill(HIST("Rec/hVar2meanptp"), cent, var2Pr); + + //-----------------------nch------------------------------------- + histos.fill(HIST("Rec/hVar1x"), sample, nchAll, var1); + histos.fill(HIST("Rec/hVar2x"), sample, nchAll, var2); + histos.fill(HIST("Rec/hVarx"), sample, nchAll); + histos.fill(HIST("Rec/hVar2meanptx"), nchAll, var2); + histos.fill(HIST("Rec/hVar1pix"), sample, nchAll, var1Pi); + histos.fill(HIST("Rec/hVar2pix"), sample, nchAll, var2Pi); + histos.fill(HIST("Rec/hVarpix"), sample, nchPi); + histos.fill(HIST("Rec/hVar2meanptpix"), nchAll, var2Pi); + histos.fill(HIST("Rec/hVar1kx"), sample, nchAll, var1Ka); + histos.fill(HIST("Rec/hVar2kx"), sample, nchAll, var2Ka); + histos.fill(HIST("Rec/hVarkx"), sample, nchKa); + histos.fill(HIST("Rec/hVar2meanptkx"), nchAll, var2Ka); + histos.fill(HIST("Rec/hVar1px"), sample, nchAll, var1Pr); + histos.fill(HIST("Rec/hVar2px"), sample, nchAll, var2Pr); + histos.fill(HIST("Rec/hVarpx"), sample, nchPr); + histos.fill(HIST("Rec/hVar2meanptpx"), nchAll, var2Pr); + + histos.fill(HIST("hEffVar1x"), sample, nchAll, var1Eff); + histos.fill(HIST("hEffVar2x"), sample, nchAll, var2Eff); + histos.fill(HIST("hEffVarx"), sample, nchAll); + histos.fill(HIST("hEffVar2Meanptx"), nchAll, var2Eff); + + histos.fill(HIST("hEffVar1pix"), sample, nchAll, var1EffPi); + histos.fill(HIST("hEffVar2pix"), sample, nchAll, var2EffPi); + histos.fill(HIST("hEffVarpix"), sample, nchAll); + histos.fill(HIST("hEffVar2Meanptpix"), nchAll, var2EffPi); + + histos.fill(HIST("hEffVar1kx"), sample, nchAll, var1EffKa); + histos.fill(HIST("hEffVar2kx"), sample, nchAll, var2EffKa); + histos.fill(HIST("hEffVarkx"), sample, nchAll); + histos.fill(HIST("hEffVar2Meanptkx"), nchAll, var2EffKa); + + histos.fill(HIST("hEffVar1px"), sample, nchAll, var1EffPr); + histos.fill(HIST("hEffVar2px"), sample, nchAll, var2EffPr); + histos.fill(HIST("hEffVarpx"), sample, nchAll); + histos.fill(HIST("hEffVar2Meanptpx"), nchAll, var2EffPr); + + //================= generated level============================== + + const auto& mccolgen = coll.mcCollision_as(); + if (std::abs(mccolgen.posZ()) > cVtxZcut) { + return; + } + const auto& mcpartgen = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mccolgen.globalIndex(), cache); + histos.fill(HIST("hVtxZ_after_gen"), mccolgen.posZ()); + + double nchGen = 0., nchGenAll = 0., nchGenTrue = 0.; + double nchPiGen = 0., nchKaGen = 0., nchPrGen = 0.; + double nch1 = 0., nch2 = 0., nch3 = 0.; + double q1AllGen = 0, q2AllGen = 0.; + double q1PiGen = 0, q2PiGen = 0, q1KaGen = 0, q2KaGen = 0, q1PrGen = 0, q2PrGen = 0; + double var1AllGen = 0, var2AllGen = 0.; + double var1PiGen = 0, var2PiGen = 0, var1KaGen = 0, var2KaGen = 0, var1PrGen = 0, var2PrGen = 0; + + int sampleGen = histos.get(HIST("hVtxZ_after_gen"))->GetEntries(); + sampleGen = sampleGen % 30; + + for (const auto& mcpart : mcpartgen) { + // auto pdgcode = std::abs(mcpart.pdgCode()); + if (!mcpart.isPhysicalPrimary()) { + continue; + } + nch1++; + histos.fill(HIST("hnch1"), nch1); + nch2++; + histos.fill(HIST("hnch2"), nch2); + nch3++; + histos.fill(HIST("hnch3"), nch3); + + int pid = mcpart.pdgCode(); + auto sign = 0; + auto* pd = pdg->GetParticle(pid); + if (pd != nullptr) { + sign = pd->Charge() / 3.; + } + if (sign == 0) { + continue; + } + // histos.fill(HIST("gen_hSign"), sign); + if (std::fabs(mcpart.eta()) > cEtacut) + continue; + nchGenTrue++; + histos.fill(HIST("hnch_gen_true"), nchGenTrue); + if ((mcpart.pt() <= cPtmincut) || (mcpart.pt() >= cPtmaxcut)) + continue; + histos.fill(HIST("hPt_gen"), mcpart.pt()); + histos.fill(HIST("hEta_gen"), mcpart.eta()); + histos.fill(HIST("ptHistogram_allcharge_gen"), mcpart.pt()); + nchGenAll += 1.; + q1AllGen += mcpart.pt(); + q2AllGen += (mcpart.pt() * mcpart.pt()); + histos.fill(HIST("hnch_gen_all"), nchGenAll); + if (std::fabs(mcpart.y()) < cRapidityCut05) { + + if (mcpart.pdgCode() == PDG_t::kPiPlus || mcpart.pdgCode() == PDG_t::kPiMinus) { + histos.fill(HIST("ptHistogramPion"), mcpart.pt()); + nchPiGen += 1.; + q1PiGen += mcpart.pt(); + q2PiGen += (mcpart.pt() * mcpart.pt()); + histos.fill(HIST("hnch_pi"), nchPiGen); + } + + if (mcpart.pdgCode() == PDG_t::kKPlus || mcpart.pdgCode() == PDG_t::kKMinus) { + histos.fill(HIST("ptHistogramKaon"), mcpart.pt()); + nchKaGen += 1.; + q1KaGen += mcpart.pt(); + q2KaGen += (mcpart.pt() * mcpart.pt()); + histos.fill(HIST("hnch_ka"), nchKaGen); + } + + if (mcpart.pdgCode() == PDG_t::kProton || mcpart.pdgCode() == PDG_t::kProtonBar) { + histos.fill(HIST("ptHistogramProton"), mcpart.pt()); + nchPrGen += 1.; + q1PrGen += mcpart.pt(); + q2PrGen += (mcpart.pt() * mcpart.pt()); + histos.fill(HIST("hnch_pr"), nchPrGen); + } + + } //|y| < 0.5 cut ends! + + } // particle + histos.fill(HIST("hcent_nacc_gen"), cent, nchGen); + + if (nchGenAll < cTwoPtlCut2) + return; + var1AllGen = (q1AllGen * q1AllGen - q2AllGen) / (nchGenAll * (nchGenAll - 1)); + var2AllGen = (q1AllGen / nchGenAll); + + if (nchPiGen >= cTwoPtlCut2) { + var1PiGen = (q1PiGen * q1PiGen - q2PiGen) / (nchPiGen * (nchPiGen - 1)); + var2PiGen = (q1PiGen / nchPiGen); + } + + //----------------------- kaons --------------------------------------- + if (nchKaGen >= cTwoPtlCut2) { + var1KaGen = (q1KaGen * q1KaGen - q2KaGen) / (nchKaGen * (nchKaGen - 1)); + var2KaGen = (q1KaGen / nchKaGen); + } + //---------------------------- protons ---------------------------------- + if (nchPrGen >= cTwoPtlCut2) { + var1PrGen = (q1PrGen * q1PrGen - q2PrGen) / (nchPrGen * (nchPrGen - 1)); + var2PrGen = (q1PrGen / nchPrGen); + } + //-----------------------nch------------------------------------- + histos.fill(HIST("hVar1x_gen"), sampleGen, nchGenAll, var1AllGen); + histos.fill(HIST("hVar2x_gen"), sampleGen, nchGenAll, var2AllGen); + histos.fill(HIST("hVarx_gen"), sampleGen, nchGenAll); + histos.fill(HIST("hVar2meanptx_gen"), nchGenAll, var2AllGen); + histos.fill(HIST("hVar1pix_gen"), sampleGen, nchGenAll, var1PiGen); + histos.fill(HIST("hVar2pix_gen"), sampleGen, nchGenAll, var2PiGen); + histos.fill(HIST("hVarpix_gen"), sampleGen, nchPiGen); + histos.fill(HIST("hVar2meanptpix_gen"), nchGenAll, var2PiGen); + histos.fill(HIST("hVar1kx_gen"), sampleGen, nchGenAll, var1KaGen); + histos.fill(HIST("hVar2kx_gen"), sampleGen, nchGenAll, var2KaGen); + histos.fill(HIST("hVarkx_gen"), sampleGen, nchKaGen); + histos.fill(HIST("hVar2meanptkx_gen"), nchGenAll, var2KaGen); + histos.fill(HIST("hVar1px_gen"), sampleGen, nchGenAll, var1PrGen); + histos.fill(HIST("hVar2px_gen"), sampleGen, nchGenAll, var2PrGen); + histos.fill(HIST("hVarpx_gen"), sampleGen, nchPrGen); + histos.fill(HIST("hVar2meanptpx_gen"), nchGenAll, var2PrGen); + + } // void process + PROCESS_SWITCH(EventMeanPtId, processMcReco, "Process reconstructed", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/PWGCF/EbyEFluctuations/Tasks/kaonIsospinFluctuations.cxx b/PWGCF/EbyEFluctuations/Tasks/kaonIsospinFluctuations.cxx new file mode 100644 index 00000000000..4170d078843 --- /dev/null +++ b/PWGCF/EbyEFluctuations/Tasks/kaonIsospinFluctuations.cxx @@ -0,0 +1,2553 @@ +// 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. + +/// \file kaonIsospinFluctuations.cxx +/// \brief Kaon Isospin fluctuations +/// +/// \author Rahul Verma (rahul.verma@iitb.ac.in) :: Sadhana Dash (sadhana@phy.iitb.ac.in) + +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/O2DatabasePDGPlugin.h" + +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "PWGLF/DataModel/mcCentrality.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; // for constants + +#define ID_BIT_PI 0 // Identificationi bits for PID checks +#define ID_BIT_KA 1 +#define ID_BIT_PR 2 +#define ID_BIT_EL 3 +#define ID_BIT_DE 4 + +#define BIT_IS_K0S 0 +#define BIT_IS_LAMBDA 1 +#define BIT_IS_ANTILAMBDA 2 + +// #define kPAIRBIT_ISLAMBDA + +#define BIT_POS_DAU_HAS_SAME_COLL 0 +#define BIT_NEG_DAU_HAS_SAME_COLL 1 +#define BIT_BOTH_DAU_HAS_SAME_COLL 2 + +#define BITSET(mask, ithBit) ((mask) |= (1 << (ithBit))) // avoid name bitset as std::bitset is already there +#define BITCHECK(mask, ithBit) ((mask) & (1 << (ithBit))) // bit check will return int value, not bool, use BITCHECK != 0 in Analysi + +struct KaonIsospinFluctuations { + // Hisogram registry: + HistogramRegistry recoV0s{"recoV0s", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry recoEvent{"recoEvent", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry recoK0s{"recoK0s", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry recoTracks{"recoTracks", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry recoAnalysis{"recoAnalysis", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry genAnalysis{"genAnalysis", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // PDG data base + Service pdgDB; + + // Configurables + // Event Selection + Configurable cutZvertex{"cutZvertex", 8.0f, "Accepted z-vertex range (cm)"}; + + // Configurable parameters for V0 selection + Configurable v0settingDcaPosToPV{"v0settingDcaPosToPV", 0.06, "DCA Pos to PV"}; + Configurable v0settingDcaNegToPV{"v0settingDcaNegToPV", 0.06, "DCA Neg to PV"}; + Configurable v0settingDcaV0Dau{"v0settingDcaV0Dau", 1, "DCA V0 Daughters"}; + Configurable v0settingCosPA{"v0settingCosPA", 0.98, "V0 CosPA"}; + Configurable v0settingRadius{"v0settingRadius", 0.5, "v0radius"}; + + // Configurable K0s + struct : ConfigurableGroup { + Configurable cfgK0sMLow{"cfgK0sMLow", 0.48, "cfgK0sMLow"}; + Configurable cfgK0sMHigh{"cfgK0sMHigh", 0.515, "cfgK0sMHigh"}; + Configurable cfgK0sLowPt{"cfgK0sLowPt", 0.1, "cfgK0sLowPt"}; + Configurable cfgK0sHighPt{"cfgK0sHighPt", 1.5, "cfgK0sHighPt"}; + Configurable cfgK0sRapitidy{"cfgK0sRapitidy", 0.5, "cfgK0sRapitidy"}; + Configurable cfgK0sARMcut{"cfgK0sARMcut", 0.2, "cfgK0sARMcut"}; + } k0sSelCut; + + // Histogram Configurables + struct : ConfigurableGroup { + Configurable centBins{"centBins", 1020, "No of bins in centrality axis"}; + Configurable centBinsxLow{"centBinsxLow", -1.0, "centBinsxLow"}; + Configurable centBinsxUp{"centBinsxUp", 101.0, "centBinsxUp"}; + Configurable centAxisType{"centAxisType", 0, "centAxisType"}; + } cfgCentAxis; + // Track Configurables + struct : ConfigurableGroup { + Configurable cfgTrkTpcNClsCrossedRows{"cfgTrkTpcNClsCrossedRows", 70, "cfgTrkTpcNClsCrossedRows"}; + Configurable cfgTrkdcaXY{"cfgTrkdcaXY", 0.2, "cfgTrkdcaXY"}; + Configurable cfgDoVGselTrackCheck{"cfgDoVGselTrackCheck", false, "cfgDoVGselTrackCheck"}; + Configurable cfgTrackEta{"cfgTrackEta", 0.8, "cfgTrackEta"}; + Configurable cfgTrackPtLow{"cfgTrackPtLow", 0.15, "cfgTrackPtLow"}; + Configurable cfgTrackPtHigh{"cfgTrackPtHigh", 2.0, "cfgTrackPtHigh"}; + } cfgTrackCuts; + + // Configurables for particle Identification + Configurable cfgCheckVetoCut{"cfgCheckVetoCut", false, "cfgCheckVetoCut"}; + Configurable cfgDoElRejection{"cfgDoElRejection", true, "cfgDoElRejection"}; + Configurable cfgDoDeRejection{"cfgDoDeRejection", false, "cfgDoDeRejection"}; + Configurable cfgDoPdependentId{"cfgDoPdependentId", true, "cfgDoPdependentId"}; + Configurable cfgDoTpcInnerParamId{"cfgDoTpcInnerParamId", false, "cfgDoTpcInnerParamId"}; + + Configurable cfgPiThrPforTOF{"cfgPiThrPforTOF", 0.7, "cfgPiThrPforTOF"}; + Configurable cfgPiIdCutTypeLowP{"cfgPiIdCutTypeLowP", 0, "cfgPiIdCutTypeLowP"}; + Configurable cfgPiNSigmaTPCLowP{"cfgPiNSigmaTPCLowP", 3.0, "cfgPiNSigmaTPCLowP"}; + Configurable cfgPiNSigmaTOFLowP{"cfgPiNSigmaTOFLowP", 3.0, "cfgPiNSigmaTOFLowP"}; + Configurable cfgPiNSigmaRadLowP{"cfgPiNSigmaRadLowP", 9.0, "cfgPiNSigmaRadLowP"}; + Configurable cfgPiIdCutTypeHighP{"cfgPiIdCutTypeHighP", 0, "cfgPiIdCutTypeHighP"}; + Configurable cfgPiNSigmaTPCHighP{"cfgPiNSigmaTPCHighP", 3.0, "cfgPiNSigmaTPCHighP"}; + Configurable cfgPiNSigmaTOFHighP{"cfgPiNSigmaTOFHighP", 3.0, "cfgPiNSigmaTOFHighP"}; + Configurable cfgPiNSigmaRadHighP{"cfgPiNSigmaRadHighP", 9.0, "cfgPiNSigmaRadHighP"}; + + Configurable cfgKaThrPforTOF{"cfgKaThrPforTOF", 0.8, "cfgKaThrPforTOF"}; + Configurable cfgKaIdCutTypeLowP{"cfgKaIdCutTypeLowP", 0, "cfgKaIdCutTypeLowP"}; + Configurable cfgKaNSigmaTPCLowP{"cfgKaNSigmaTPCLowP", 3.0, "cfgKaNSigmaTPCLowP"}; + Configurable cfgKaNSigmaTOFLowP{"cfgKaNSigmaTOFLowP", 3.0, "cfgKaNSigmaTOFLowP"}; + Configurable cfgKaNSigmaRadLowP{"cfgKaNSigmaRadLowP", 9.0, "cfgKaNSigmaRadLowP"}; + Configurable cfgKaIdCutTypeHighP{"cfgKaIdCutTypeHighP", 0, "cfgKaIdCutTypeHighP"}; + Configurable cfgKaNSigmaTPCHighP{"cfgKaNSigmaTPCHighP", 3.0, "cfgKaNSigmaTPCHighP"}; + Configurable cfgKaNSigmaTOFHighP{"cfgKaNSigmaTOFHighP", 3.0, "cfgKaNSigmaTOFHighP"}; + Configurable cfgKaNSigmaRadHighP{"cfgKaNSigmaRadHighP", 9.0, "cfgKaNSigmaRadHighP"}; + + Configurable cfgPrThrPforTOF{"cfgPrThrPforTOF", 0.8, "cfgPrThrPforTOF"}; + Configurable cfgPrIdCutTypeLowP{"cfgPrIdCutTypeLowP", 0, "cfgPrIdCutTypeLowP"}; + Configurable cfgPrNSigmaTPCLowP{"cfgPrNSigmaTPCLowP", 3.0, "cfgPrNSigmaTPCLowP"}; + Configurable cfgPrNSigmaTOFLowP{"cfgPrNSigmaTOFLowP", 3.0, "cfgPrNSigmaTOFLowP"}; + Configurable cfgPrNSigmaRadLowP{"cfgPrNSigmaRadLowP", 9.0, "cfgPrNSigmaRadLowP"}; + Configurable cfgPrIdCutTypeHighP{"cfgPrIdCutTypeHighP", 0, "cfgPrIdCutTypeHighP"}; + Configurable cfgPrNSigmaTPCHighP{"cfgPrNSigmaTPCHighP", 3.0, "cfgPrNSigmaTPCHighP"}; + Configurable cfgPrNSigmaTOFHighP{"cfgPrNSigmaTOFHighP", 3.0, "cfgPrNSigmaTOFHighP"}; + Configurable cfgPrNSigmaRadHighP{"cfgPrNSigmaRadHighP", 9.0, "cfgPrNSigmaRadHighP"}; + + // configurable for process functions to reduce memory usage + Configurable cfgFillV0TableFull{"cfgFillV0TableFull", true, "cfgFillV0TableFull"}; + Configurable cfgFillV0TablePostK0sCheck{"cfgFillV0TablePostK0sCheck", false, "cfgFillV0TablePostK0sCheck"}; + Configurable cfgFillV0TablePostMassCut{"cfgFillV0TablePostMassCut", false, "cfgFillV0TablePostMassCut"}; + Configurable cfgFillV0TablePostSelectionCut{"cfgFillV0TablePostSelectionCut", true, "cfgFillV0TablePostSelectionCut"}; + + Configurable cfgFillRecoK0sPreSel{"cfgFillRecoK0sPreSel", false, "cfgFillRecoK0sPreSel"}; + Configurable cfgFillRecoK0sPostSel{"cfgFillRecoK0sPostSel", true, "cfgFillRecoK0sPostSel"}; + + Configurable cfgFillRecoTrackPreSel{"cfgFillRecoTrackPreSel", false, "cfgFillRecoTrackPreSel"}; + Configurable cfgFillRecoTrackPostSel{"cfgFillRecoTrackPostSel", true, "cfgFillRecoTrackPostSel"}; + + Configurable cfgFillPiQA{"cfgFillPiQA", true, "cfgFillPiQA"}; + Configurable cfgFillKaQA{"cfgFillKaQA", true, "cfgFillKaQA"}; + Configurable cfgFillPrQA{"cfgFillPrQA", true, "cfgFillPrQA"}; + Configurable cfgFillElQA{"cfgFillElQA", true, "cfgFillElQA"}; + Configurable cfgFillDeQA{"cfgFillDeQA", true, "cfgFillDeQA"}; + + Configurable cfgFillSparseFullK0sPiKa{"cfgFillSparseFullK0sPiKa", true, "cfgFillSparseFullK0sPiKa"}; + Configurable cfgFillSparseFullK0sPrDe{"cfgFillSparseFullK0sPrDe", true, "cfgFillSparseFullK0sPrDe"}; + Configurable cfgFillSparseFullK0sKaEl{"cfgFillSparseFullK0sKaEl", false, "cfgFillSparseFullK0sKaEl"}; + Configurable cfgFillSparseFullPiKaPr{"cfgFillSparseFullPiKaPr", false, "cfgFillSparseFullPiKaPr"}; + Configurable cfgFillSparseFullPiElDe{"cfgFillSparseFullPiElDe", false, "cfgFillSparseFullPiElDe"}; + Configurable cfgFillSparseFullKaPrDe{"cfgFillSparseFullKaPrDe", false, "cfgFillSparseFullKaPrDe"}; + Configurable cfgFillSparseFullPrElDe{"cfgFillSparseFullPrElDe", false, "cfgFillSparseFullPrElDe"}; + Configurable cfgFillSparsenewDynmK0sKa{"cfgFillSparsenewDynmK0sKa", true, "cfgFillSparsenewDynmK0sKa"}; + Configurable cfgFillSparsenewDynmKpKm{"cfgFillSparsenewDynmKpKm", true, "cfgFillSparsenewDynmKpKm"}; + + Configurable cfgVtxZCheck{"cfgVtxZCheck", 0, "cfgVtxZCheck"}; + Configurable cfgCountFinalParticles{"cfgCountFinalParticles", 1, "cfgCountFinalParticles"}; + Configurable cfgCountNonFinalParticles{"cfgCountNonFinalParticles", 0, "cfgCountNonFinalParticles"}; + Configurable cfgCountPhysicalPrimAndFinalParticles{"cfgCountPhysicalPrimAndFinalParticles", 0, "cfgCountPhysicalPrimAndFinalParticles"}; + Configurable doFWDPtDependentCheck{"doFWDPtDependentCheck", 1, "doFWDPtDependentCheck"}; + Configurable cfgFWDPtCut{"cfgFWDPtCut", 0.2, "cfgFWDPtCut"}; + Configurable> cfgFinalParticleIdList{"cfgFinalParticleIdList", {11, -11, 13, -13, 15, -15, 211, -211, 321, -321, 2212, -2212}, "cfgFinalParticleIdList"}; + Configurable> cfgNonFinalParticleIdList{"cfgNonFinalParticleIdList", {11, -11, 13, -13, 15, -15, 211, -211, 321, -321, 2212, -2212}, "cfgNonFinalParticleIdList"}; + + void init(InitContext const&) + { + // Axes + const AxisSpec axisK0sMass = {200, 0.40f, 0.60f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + const AxisSpec axisLambdaMass = {200, 1.f, 1.2f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + + const AxisSpec axisVertexZ = {30, -15., 15., "vrtx_{Z} [cm]"}; + AxisSpec axisCent = {cfgCentAxis.centBins, cfgCentAxis.centBinsxLow, cfgCentAxis.centBinsxUp, "centFT0C(percentile)"}; + if (cfgCentAxis.centAxisType == 1) { + axisCent = {cfgCentAxis.centBins, cfgCentAxis.centBinsxLow, cfgCentAxis.centBinsxUp, "centFT0M(percentile)"}; + } + if (cfgCentAxis.centAxisType == 2) { + axisCent = {cfgCentAxis.centBins, cfgCentAxis.centBinsxLow, cfgCentAxis.centBinsxUp, "multFT0M"}; + } + if (cfgCentAxis.centAxisType == 3) { + axisCent = {cfgCentAxis.centBins, cfgCentAxis.centBinsxLow, cfgCentAxis.centBinsxUp, "multFT0C"}; + } + + const AxisSpec axisP = {200, 0.0f, 10.0f, "#it{p} (GeV/#it{c})"}; + const AxisSpec axisPt = {200, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisTPCInnerParam = {200, 0.0f, 10.0f, "#it{p}_{tpcInnerParam} (GeV/#it{c})"}; + const AxisSpec axisTOFExpMom = {200, 0.0f, 10.0f, "#it{p}_{tofExpMom} (GeV/#it{c})"}; + + const AxisSpec axisEta = {100, -5, 5, "#eta"}; + const AxisSpec axisPhi = {90, -1, 8, "#phi (radians)"}; + const AxisSpec axisRapidity = {200, -5, 5, "Rapidity (y)"}; + const AxisSpec axisDcaXY = {100, -5, 5, "dcaXY"}; + const AxisSpec axisDcaZ = {100, -5, 5, "dcaZ"}; + const AxisSpec axisDcaXYwide = {2000, -100, 100, "dcaXY"}; + const AxisSpec axisDcaZwide = {2000, -100, 100, "dcaZ"}; + const AxisSpec axisSign = {10, -5, 5, "track.sign"}; + + const AxisSpec axisTPCSignal = {100, -1, 1000, "tpcSignal"}; + const AxisSpec axisTOFBeta = {40, -2.0, 2.0, "tofBeta"}; + + const AxisSpec axisTPCSignalFine = {10010, -1, 1000, "tpcSignal"}; + const AxisSpec axisTOFBetaFine = {10010, -1, 1000, "tpcSignal"}; + + const AxisSpec axisTPCNSigma = {200, -10.0, 10.0, "n#sigma_{TPC}"}; + const AxisSpec axisTOFNSigma = {200, -10.0, 10.0, "n#sigma_{TOF}"}; + + const AxisSpec axisTPCNSigmaPi = {200, -10.0, 10.0, "n#sigma_{TPC}^{Pi}"}; + const AxisSpec axisTOFNSigmaPi = {200, -10.0, 10.0, "n#sigma_{TOF}^{Pi}"}; + + const AxisSpec axisTPCNClsCrossedRows = {200, -1.5, 198.5, "tpcNClsCrossedRows"}; + const AxisSpec axisIsPVContributor = {4, -1, 3, "isPVContributor"}; + const AxisSpec axisIsGlobalTrack = {4, -1, 3, "isGobalTrack"}; + const AxisSpec axisIsK0sDau = {4, -1, 3, "isK0sDau"}; + + const AxisSpec axisDcapostopv = {100000, -50, 50, "dcapostopv"}; + const AxisSpec axisDcanegtopv = {100000, -50, 50, "dcanegtopv"}; + const AxisSpec axisDcaV0daughters = {2000, -10.0, 10.0, "dcaV0daughters"}; + const AxisSpec axisV0cosPA = {3000, -1.5, 1.5, "v0cosPA"}; + const AxisSpec axisV0radius = {100000, -50, 50, "v0radius"}; + + const AxisSpec axisParticleCount1 = {60, -10, 50, "particleCount"}; + const AxisSpec axisParticleCount2 = {260, -10, 250, "particleCount"}; + const AxisSpec axisParticleCount3 = {1060, -10, 1050, "particleCount"}; + + const AxisSpec axisArmenterosAlpha = {100, -1.0, 1.0, "ArmenterosAlpha"}; + const AxisSpec axisArmenterosQt = {150, 0, 0.3, "ArmenterosQt"}; + + HistogramConfigSpec histPDcaXY({HistType::kTH2F, {axisP, axisDcaXY}}); + HistogramConfigSpec histPtDcaXY({HistType::kTH2F, {axisPt, axisDcaXY}}); + HistogramConfigSpec histTpcInnerParamDcaXY({HistType::kTH2F, {axisTPCInnerParam, axisDcaXY}}); + HistogramConfigSpec histTofExpMomDcaXY({HistType::kTH2F, {axisTOFExpMom, axisDcaXY}}); + + HistogramConfigSpec histPDcaZ({HistType::kTH2F, {axisP, axisDcaZ}}); + HistogramConfigSpec histPtDcaZ({HistType::kTH2F, {axisPt, axisDcaZ}}); + HistogramConfigSpec histTpcInnerParamDcaZ({HistType::kTH2F, {axisTPCInnerParam, axisDcaZ}}); + HistogramConfigSpec histTofExpMomDcaZ({HistType::kTH2F, {axisTOFExpMom, axisDcaZ}}); + + HistogramConfigSpec histPPt({HistType::kTH2F, {axisP, axisPt}}); + HistogramConfigSpec histPTpcInnerParam({HistType::kTH2F, {axisP, axisTPCInnerParam}}); + HistogramConfigSpec histPTofExpMom({HistType::kTH2F, {axisP, axisTOFExpMom}}); + + HistogramConfigSpec histPTpcSignal({HistType::kTH2F, {axisP, axisTPCSignal}}); + HistogramConfigSpec histTpcInnerParamTpcSignal({HistType::kTH2F, {axisTPCInnerParam, axisTPCSignal}}); + HistogramConfigSpec histTofExpMomTpcSignal({HistType::kTH2F, {axisTOFExpMom, axisTPCSignal}}); + + HistogramConfigSpec histPBeta({HistType::kTH2F, {axisP, axisTOFBeta}}); + HistogramConfigSpec histTpcInnerParamBeta({HistType::kTH2F, {axisTPCInnerParam, axisTOFBeta}}); + HistogramConfigSpec histTofExpMomBeta({HistType::kTH2F, {axisTOFExpMom, axisTOFBeta}}); + + HistogramConfigSpec histPTpcNSigma({HistType::kTH2F, {axisP, axisTPCNSigma}}); + HistogramConfigSpec histPtTpcNSigma({HistType::kTH2F, {axisPt, axisTPCNSigma}}); + HistogramConfigSpec histTpcInnerParamTpcNSigma({HistType::kTH2F, {axisTPCInnerParam, axisTPCNSigma}}); + HistogramConfigSpec histTofExpMomTpcNSigma({HistType::kTH2F, {axisTOFExpMom, axisTPCNSigma}}); + HistogramConfigSpec histPTofNSigma({HistType::kTH2F, {axisP, axisTOFNSigma}}); + HistogramConfigSpec histPtTofNSigma({HistType::kTH2F, {axisPt, axisTOFNSigma}}); + HistogramConfigSpec histTpcInnerParamTofNSigma({HistType::kTH2F, {axisTPCInnerParam, axisTOFNSigma}}); + HistogramConfigSpec histTofExpMomTofNSigma({HistType::kTH2F, {axisTOFExpMom, axisTOFNSigma}}); + HistogramConfigSpec histTpcNSigmaTofNSigma({HistType::kTH2F, {axisTPCNSigma, axisTOFNSigma}}); + + recoV0s.add("v0Table/Full/h01_K0s_Mass", "K0s_Mass", {HistType::kTH1F, {axisK0sMass}}); + recoV0s.add("v0Table/Full/h02_Lambda_Mass", "Lambda_Mass", {HistType::kTH1F, {axisLambdaMass}}); + recoV0s.add("v0Table/Full/h03_AntiLambda_Mass", "AntiLambda_Mass", {HistType::kTH1F, {axisLambdaMass}}); + recoV0s.add("v0Table/Full/h04_v0DaughterCollisionIndexTag", "hV0s_K0s_v0DaughterCollisionIndexTag", {HistType::kTH1D, {{22, -1.0, 10.0}}}); + recoV0s.add("v0Table/Full/h05_V0Tag", "V0Tag", {HistType::kTH1F, {{12, -2, 10}}}); // 001 = Kaon, 010 = Lambda, 100 = AnitLambda + + // Topological Cuts + recoV0s.add("v0Table/Full/h06_dcapostopv", "dcapostopv", kTH1F, {axisDcapostopv}); + recoV0s.add("v0Table/Full/h07_dcanegtopv", "dcanegtopv", kTH1F, {axisDcanegtopv}); + recoV0s.add("v0Table/Full/h08_dcaV0daughters", "dcaV0daughters", kTH1F, {axisDcaV0daughters}); + recoV0s.add("v0Table/Full/h09_v0cosPA", "v0cosPA", kTH1F, {axisV0cosPA}); + recoV0s.add("v0Table/Full/h10_v0radius", "v0radius", kTH1F, {axisV0radius}); + + // K0s-FullInformation + recoV0s.add("v0Table/Full/h11_mass", "mass", kTH1F, {axisK0sMass}); + recoV0s.add("v0Table/Full/h12_p", "p", kTH1F, {axisP}); + recoV0s.add("v0Table/Full/h13_pt", "pt", kTH1F, {axisPt}); + recoV0s.add("v0Table/Full/h14_eta", "eta", kTH1F, {axisEta}); + recoV0s.add("v0Table/Full/h15_phi", "phi", kTH1F, {axisPhi}); + recoV0s.add("v0Table/Full/h16_rapidity", "rapidity", kTH1F, {axisRapidity}); + recoV0s.add("v0Table/Full/h17_alpha", "alpha", kTH1F, {axisArmenterosAlpha}); + recoV0s.add("v0Table/Full/h18_qtarm", "qtarm", kTH1F, {axisArmenterosQt}); + recoV0s.add("v0Table/Full/h19_alpha_qtarm", "alpha_qtarm", kTH2F, {axisArmenterosAlpha, axisArmenterosQt}); + recoV0s.add("v0Table/Full/h20_pt_eta", "pt_eta", kTH2F, {axisPt, axisEta}); + + // K0s-Daughter Info + recoV0s.add("v0Table/Full/Pi/tpcId/h01_p", "p", kTH1F, {axisP}); + recoV0s.add("v0Table/Full/Pi/tpcId/h02_pt", "pt", kTH1F, {axisPt}); + recoV0s.add("v0Table/Full/Pi/tpcId/h03_tpcInnerParam", "tpcInnerParam", kTH1F, {axisTPCInnerParam}); + recoV0s.add("v0Table/Full/Pi/tpcId/h04_tofExpMom", "tofExpMom", kTH1F, {axisTOFExpMom}); + recoV0s.add("v0Table/Full/Pi/tpcId/h05_eta", "eta", kTH1F, {axisEta}); + recoV0s.add("v0Table/Full/Pi/tpcId/h06_phi", "phi", kTH1F, {axisPhi}); + recoV0s.add("v0Table/Full/Pi/tpcId/h07_rapidity", "rapidity", kTH1F, {axisRapidity}); + recoV0s.add("v0Table/Full/Pi/tpcId/h08_isPVContributor", "isPVContributor", kTH1F, {axisIsPVContributor}); + recoV0s.add("v0Table/Full/Pi/tpcId/h09_isGlobalTrack", "isGlobalTrack", kTH1F, {axisIsGlobalTrack}); + recoV0s.add("v0Table/Full/Pi/tpcId/h10_dcaXY", "dcaXY", kTH1F, {axisDcaXY}); + recoV0s.add("v0Table/Full/Pi/tpcId/h11_dcaZ", "dcaZ", kTH1F, {axisDcaZ}); + + recoV0s.add("v0Table/Full/Pi/tpcId/h12_p_dcaXY", "p_dcaXY", kTH2F, {axisP, axisDcaXY}); + recoV0s.add("v0Table/Full/Pi/tpcId/h13_p_dcaZ", "p_dcaZ", kTH2F, {axisP, axisDcaZ}); + recoV0s.add("v0Table/Full/Pi/tpcId/h14_pt_dcaXY", "pt_dcaXY", kTH2F, {axisP, axisDcaXY}); + recoV0s.add("v0Table/Full/Pi/tpcId/h15_pt_dcaZ", "pt_dcaZ", kTH2F, {axisP, axisDcaZ}); + recoV0s.add("v0Table/Full/Pi/tpcId/h16_dcaXYwide", "dcaXYwide", kTH1F, {axisDcaXYwide}); + recoV0s.add("v0Table/Full/Pi/tpcId/h17_dcaZwide", "dcaZwide", kTH1F, {axisDcaZwide}); + recoV0s.add("v0Table/Full/Pi/tpcId/h20_pt_eta", "pt_eta", kTH2F, {axisPt, axisEta}); + // K0s-Daughter identification + // momemtum + recoV0s.add("v0Table/Full/Pi/tpcId/h20_p_pt", "p_pt", histPPt); + recoV0s.add("v0Table/Full/Pi/tpcId/h21_p_tpcInnerParam", "p_tpcInnerParam", histPTpcInnerParam); + recoV0s.add("v0Table/Full/Pi/tpcId/h22_p_tofExpMom", "p_tofExpMom", histPTofExpMom); + // tpcSignal + recoV0s.add("v0Table/Full/Pi/tpcId/h23_p_tpcSignal", "p_tpcSignal", histPTpcSignal); + recoV0s.add("v0Table/Full/Pi/tpcId/h24_tpcInnerParam_tpcSignal", "tpcInnerParam_tpcSignal", histTpcInnerParamTpcSignal); + recoV0s.add("v0Table/Full/Pi/tpcId/h25_tofExpMom_tpcSignal", "tofExpMom_tpcSignal", histTofExpMomTpcSignal); + // tofBeta + recoV0s.add("v0Table/Full/Pi/tpcId/h26_p_beta", "p_beta", histPBeta); + recoV0s.add("v0Table/Full/Pi/tpcId/h27_tpcInnerParam_beta", "tpcInnerParam_beta", histTpcInnerParamBeta); + recoV0s.add("v0Table/Full/Pi/tpcId/h28_tofExpMom_beta", "tofExpMom_beta", histTofExpMomBeta); + // Look at Pion + recoV0s.add("v0Table/Full/Pi/tpcId/h29_p_tpcNSigma", "p_tpcNSigma", histPTpcNSigma); + recoV0s.add("v0Table/Full/Pi/tpcId/h30_pt_tpcNSigma", "pt_tpcNSigma", histPtTpcNSigma); + recoV0s.add("v0Table/Full/Pi/tpcId/h31_tpcInnerParam_tpcNSigma", "tpcInnerParam_tpcNSigma", histTpcInnerParamTpcNSigma); + recoV0s.add("v0Table/Full/Pi/tpcId/h32_tofExpMom_tpcNSigma", "tofExpMom_tpcNSigma", histTofExpMomTpcNSigma); + recoV0s.add("v0Table/Full/Pi/tpcId/h33_p_tofNSigma", "p_tofNSigma", histPTofNSigma); + recoV0s.add("v0Table/Full/Pi/tpcId/h34_pt_tofNSigma", "pt_tofNSigma", histPtTofNSigma); + recoV0s.add("v0Table/Full/Pi/tpcId/h35_tpcInnerParam_tofNSigma", "tpcInnerParam_tofNSigma", histTpcInnerParamTofNSigma); + recoV0s.add("v0Table/Full/Pi/tpcId/h36_tofExpMom_tofNSigma", "tofExpMom_tofNSigma", histTofExpMomTofNSigma); + recoV0s.add("v0Table/Full/Pi/tpcId/h37_tpcNSigma_tofNSigma", "tpcNSigma_tofNSigma", histTpcNSigmaTofNSigma); + + recoV0s.addClone("v0Table/Full/Pi/tpcId/", "v0Table/Full/Pi/tpctofId/"); // for identification using tof+tpc + recoV0s.addClone("v0Table/Full/Pi/tpcId/", "v0Table/Full/Pi/NoId/"); // for unidentified case // to observe and debug + + if (cfgFillV0TablePostK0sCheck) { + recoV0s.addClone("v0Table/Full/", "v0Table/postK0sCheck/"); + } + if (cfgFillV0TablePostMassCut) { + recoV0s.addClone("v0Table/Full/", "v0Table/postMassCut/"); + } + if (cfgFillV0TablePostSelectionCut) { + recoV0s.addClone("v0Table/Full/", "v0Table/postSelectionCut/"); + } + + recoV0s.add("v0Table/postSelectionCut/hTrueV0TagCount", "hTrueV0TagCount", {HistType::kTH1F, {{12, -2, 10}}}); // 001 = Kaon, 010 = Lambda, 100 = AnitLambda + recoV0s.add("v0Table/postSelectionCut/nCommonPionOfDifferentK0s", "nCommonPionOfDifferentK0s", {HistType::kTH1D, {{44, -2, 20}}}); + + // Event Selection + recoEvent.add("recoEvent/ProcessType", "ProcessType", {HistType::kTH1D, {{20, -1, 9}}}); + recoEvent.add("recoEvent/h01_CollisionCount", "CollisionCount", {HistType::kTH1D, {{1, 0, 1}}}); + recoEvent.add("recoEvent/h02_VertexXRec", "VertexXRec", {HistType::kTH1D, {{1000, -0.2, 0.2}}}); + recoEvent.add("recoEvent/h03_VertexYRec", "VertexYRec", {HistType::kTH1D, {{1000, -0.2, 0.2}}}); + recoEvent.add("recoEvent/h04_VertexZRec", "VertexZRec", {HistType::kTH1F, {axisVertexZ}}); + recoEvent.add("recoEvent/h05_Centrality", "Centrality", {HistType::kTH1F, {axisCent}}); + recoEvent.add("recoEvent/h06_V0Size", "V0Size", {HistType::kTH1F, {{60, -10, 50}}}); + recoEvent.add("recoEvent/h07_TracksSize", "TracksSize", {HistType::kTH1F, {axisParticleCount2}}); + recoEvent.add("recoEvent/h08_nTrack", "nTrack", {HistType::kTH1F, {axisParticleCount2}}); + recoEvent.add("recoEvent/h09_nK0s", "nK0s", {HistType::kTH1F, {axisParticleCount1}}); + recoEvent.add("recoEvent/h10_nPiPlus", "nPiPlus", {HistType::kTH1F, {axisParticleCount2}}); + recoEvent.add("recoEvent/h11_nPiMinus", "nPiMinus", {HistType::kTH1F, {axisParticleCount2}}); + recoEvent.add("recoEvent/h12_nKaPlus", "nKaPlus", {HistType::kTH1F, {axisParticleCount1}}); + recoEvent.add("recoEvent/h13_nKaMinus", "nKaMinus", {HistType::kTH1F, {axisParticleCount1}}); + recoEvent.add("recoEvent/h14_nProton", "nProton", {HistType::kTH1F, {axisParticleCount1}}); + recoEvent.add("recoEvent/h15_nPBar", "nPBar", {HistType::kTH1F, {axisParticleCount1}}); + recoEvent.add("recoEvent/h16_nElPlus", "nElPlus", {HistType::kTH1F, {axisParticleCount1}}); + recoEvent.add("recoEvent/h17_nElMinus", "nElMinus", {HistType::kTH1F, {axisParticleCount1}}); + recoEvent.add("recoEvent/h18_nDePlus", "nDePlus", {HistType::kTH1F, {axisParticleCount1}}); + recoEvent.add("recoEvent/h19_nDeMinus", "nDeMinus", {HistType::kTH1F, {axisParticleCount1}}); + + // + // K0s reconstruction + recoK0s.add("recoK0s/PreSel/h01_K0s_Mass", "K0s_Mass", {HistType::kTH1F, {axisK0sMass}}); + recoK0s.add("recoK0s/PreSel/h02_Lambda_Mass", "Lambda_Mass", {HistType::kTH1F, {axisLambdaMass}}); + recoK0s.add("recoK0s/PreSel/h03_AntiLambda_Mass", "AntiLambda_Mass", {HistType::kTH1F, {axisLambdaMass}}); + recoK0s.add("recoK0s/PreSel/h04_v0DaughterCollisionIndexTag", "hV0s_K0s_v0DaughterCollisionIndexTag", {HistType::kTH1D, {{22, -1.0, 10.0}}}); + recoK0s.add("recoK0s/PreSel/h05_V0Tag", "V0Tag", {HistType::kTH1F, {{12, -2, 10}}}); // 001 = Kaon, 010 = Lambda, 100 = AnitLambda + + // Topological Cuts + recoK0s.add("recoK0s/PreSel/h06_dcapostopv", "dcapostopv", kTH1F, {axisDcapostopv}); + recoK0s.add("recoK0s/PreSel/h07_dcanegtopv", "dcanegtopv", kTH1F, {axisDcanegtopv}); + recoK0s.add("recoK0s/PreSel/h08_dcaV0daughters", "dcaV0daughters", kTH1F, {axisDcaV0daughters}); + recoK0s.add("recoK0s/PreSel/h09_v0cosPA", "v0cosPA", kTH1F, {axisV0cosPA}); + recoK0s.add("recoK0s/PreSel/h10_v0radius", "v0radius", kTH1F, {axisV0radius}); + + // K0s-FullInformation + recoK0s.add("recoK0s/PreSel/h11_mass", "mass", kTH1F, {axisK0sMass}); + recoK0s.add("recoK0s/PreSel/h12_p", "p", kTH1F, {axisP}); + recoK0s.add("recoK0s/PreSel/h13_pt", "pt", kTH1F, {axisPt}); + recoK0s.add("recoK0s/PreSel/h14_eta", "eta", kTH1F, {axisEta}); + recoK0s.add("recoK0s/PreSel/h15_phi", "phi", kTH1F, {axisPhi}); + recoK0s.add("recoK0s/PreSel/h16_rapidity", "rapidity", kTH1F, {axisRapidity}); + recoK0s.add("recoK0s/PreSel/h17_alpha", "alpha", kTH1F, {axisArmenterosAlpha}); + recoK0s.add("recoK0s/PreSel/h18_qtarm", "qtarm", kTH1F, {axisArmenterosQt}); + recoK0s.add("recoK0s/PreSel/h19_alpha_qtarm", "alpha_qtarm", kTH2F, {axisArmenterosAlpha, axisArmenterosQt}); + recoK0s.add("recoK0s/PreSel/h20_pt_eta", "pt_eta", kTH2F, {axisPt, axisEta}); + + // K0s-Daughter Info + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h01_p", "p", kTH1F, {axisP}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h02_pt", "pt", kTH1F, {axisPt}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h03_tpcInnerParam", "tpcInnerParam", kTH1F, {axisTPCInnerParam}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h04_tofExpMom", "tofExpMom", kTH1F, {axisTOFExpMom}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h05_eta", "eta", kTH1F, {axisEta}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h06_phi", "phi", kTH1F, {axisPhi}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h07_rapidity", "rapidity", kTH1F, {axisRapidity}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h08_isPVContributor", "isPVContributor", kTH1F, {axisIsPVContributor}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h09_isGlobalTrack", "isGlobalTrack", kTH1F, {axisIsGlobalTrack}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h10_dcaXY", "dcaXY", kTH1F, {axisDcaXY}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h11_dcaZ", "dcaZ", kTH1F, {axisDcaZ}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h12_p_dcaXY", "p_dcaXY", kTH2F, {axisP, axisDcaXY}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h13_p_dcaZ", "p_dcaZ", kTH2F, {axisP, axisDcaZ}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h14_pt_dcaXY", "pt_dcaXY", kTH2F, {axisP, axisDcaXY}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h15_pt_dcaZ", "pt_dcaZ", kTH2F, {axisP, axisDcaZ}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h16_dcaXYwide", "dcaXYwide", kTH1F, {axisDcaXYwide}); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h17_dcaZwide", "dcaZwide", kTH1F, {axisDcaZwide}); + + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h20_pt_eta", "pt_eta", kTH2F, {axisPt, axisEta}); + // K0s-Daughter identification + // momemtum + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h20_p_pt", "p_pt", histPPt); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h21_p_tpcInnerParam", "p_tpcInnerParam", histPTpcInnerParam); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h22_p_tofExpMom", "p_tofExpMom", histPTofExpMom); + // tpcSignal + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h23_p_tpcSignal", "p_tpcSignal", histPTpcSignal); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h24_tpcInnerParam_tpcSignal", "tpcInnerParam_tpcSignal", histTpcInnerParamTpcSignal); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h25_tofExpMom_tpcSignal", "tofExpMom_tpcSignal", histTofExpMomTpcSignal); + // tofBeta + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h26_p_beta", "p_beta", histPBeta); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h27_tpcInnerParam_beta", "tpcInnerParam_beta", histTpcInnerParamBeta); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h28_tofExpMom_beta", "tofExpMom_beta", histTofExpMomBeta); + // Look at Pion + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h29_p_tpcNSigma", "p_tpcNSigma", histPTpcNSigma); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h30_pt_tpcNSigma", "pt_tpcNSigma", histPtTpcNSigma); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h31_tpcInnerParam_tpcNSigma", "tpcInnerParam_tpcNSigma", histTpcInnerParamTpcNSigma); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h32_tofExpMom_tpcNSigma", "tofExpMom_tpcNSigma", histTofExpMomTpcNSigma); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h33_p_tofNSigma", "p_tofNSigma", histPTofNSigma); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h34_pt_tofNSigma", "pt_tofNSigma", histPtTofNSigma); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h35_tpcInnerParam_tofNSigma", "tpcInnerParam_tofNSigma", histTpcInnerParamTofNSigma); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h36_tofExpMom_tofNSigma", "tofExpMom_tofNSigma", histTofExpMomTofNSigma); + recoK0s.add("recoK0s/PreSel/Pi/tpcId/h37_tpcNSigma_tofNSigma", "tpcNSigma_tofNSigma", histTpcNSigmaTofNSigma); + + recoK0s.addClone("recoK0s/PreSel/Pi/tpcId/", "recoK0s/PreSel/Pi/tpctofId/"); // for identification using tof+tpc + recoK0s.addClone("recoK0s/PreSel/Pi/tpcId/", "recoK0s/PreSel/Pi/NoId/"); // for unidentified case // to observe and debug + + recoK0s.addClone("recoK0s/PreSel/", "recoK0s/PostSel/"); // for unidentified case // to observe and debug + + recoK0s.add("recoK0s/PostSel/mK0s_vs_cent", "mK0s_vs_cent", kTH2F, {axisCent, axisK0sMass}); + + // Tracks reconstruction + // FullTrack + recoTracks.add("recoTracks/PreSel/h01_p", "p", {HistType::kTH1F, {axisP}}); + recoTracks.add("recoTracks/PreSel/h02_pt", "pt", {HistType::kTH1F, {axisPt}}); + recoTracks.add("recoTracks/PreSel/h03_tpcInnerParam", "tpcInnerParam", {HistType::kTH1F, {axisTPCInnerParam}}); + recoTracks.add("recoTracks/PreSel/h04_tofExpMom", "tofExpMom", {HistType::kTH1F, {axisTOFExpMom}}); + recoTracks.add("recoTracks/PreSel/h05_eta", "eta", {HistType::kTH1F, {axisEta}}); + recoTracks.add("recoTracks/PreSel/h06_phi", "phi", {HistType::kTH1F, {axisPhi}}); + recoTracks.add("recoTracks/PreSel/h07_dcaXY", "dcaXY", {HistType::kTH1F, {axisDcaXY}}); + recoTracks.add("recoTracks/PreSel/h08_dcaZ", "dcaZ", {HistType::kTH1F, {axisDcaZ}}); + recoTracks.add("recoTracks/PreSel/h09_sign", "sign", {HistType::kTH1D, {axisSign}}); + + // DcaXY + recoTracks.add("recoTracks/PreSel/h10_p_dcaXY", "p_dcaXY", histPDcaXY); + recoTracks.add("recoTracks/PreSel/h11_pt_dcaXY", "pt_dcaXY", histPtDcaXY); + recoTracks.add("recoTracks/PreSel/h12_tpcInnerParam_dcaXY", "tpcInnerParam_dcaXY", histTpcInnerParamDcaXY); + recoTracks.add("recoTracks/PreSel/h13_tofExpMom_dcaXY", "tofExpMom_dcaXY", histTofExpMomDcaXY); + + // DcaZ + recoTracks.add("recoTracks/PreSel/h14_p_dcaZ", "p_dcaZ", histPDcaZ); + recoTracks.add("recoTracks/PreSel/h15_pt_dcaZ", "pt_dcaZ", histPtDcaZ); + recoTracks.add("recoTracks/PreSel/h16_tpcInnerParam_dcaZ", "tpcInnerParam_dcaZ", histTpcInnerParamDcaZ); + recoTracks.add("recoTracks/PreSel/h17_tofExpMom_dcaZ", "tofExpMom_dcaZ", histTofExpMomDcaZ); + + recoTracks.add("recoTracks/PreSel/h20_pt_eta", "pt_eta", kTH2F, {axisPt, axisEta}); + // momemtum + recoTracks.add("recoTracks/PreSel/h20_p_pt", "p_pt", histPPt); + recoTracks.add("recoTracks/PreSel/h21_p_tpcInnerParam", "p_tpcInnerParam", histPTpcInnerParam); + recoTracks.add("recoTracks/PreSel/h22_p_tofExpMom", "p_tofExpMom", histPTofExpMom); + + // tpcSignal + recoTracks.add("recoTracks/PreSel/h23_p_tpcSignal", "p_tpcSignal", histPTpcSignal); + recoTracks.add("recoTracks/PreSel/h24_tpcInnerParam_tpcSignal", "tpcInnerParam_tpcSignal", histTpcInnerParamTpcSignal); + recoTracks.add("recoTracks/PreSel/h25_tofExpMom_tpcSignal", "tofExpMom_tpcSignal", histTofExpMomTpcSignal); + + // tofBeta + recoTracks.add("recoTracks/PreSel/h26_p_beta", "p_beta", histPBeta); + recoTracks.add("recoTracks/PreSel/h27_tpcInnerParam_beta", "tpcInnerParam_beta", histTpcInnerParamBeta); + recoTracks.add("recoTracks/PreSel/h28_tofExpMom_beta", "tofExpMom_beta", histTofExpMomBeta); + + // Look at Pion + recoTracks.add("recoTracks/PreSel/Pi/NoId/h29_p_tpcNSigma", "p_tpcNSigma", histPTpcNSigma); + recoTracks.add("recoTracks/PreSel/Pi/NoId/h30_pt_tpcNSigma", "pt_tpcNSigma", histPtTpcNSigma); + recoTracks.add("recoTracks/PreSel/Pi/NoId/h31_tpcInnerParam_tpcNSigma", "tpcInnerParam_tpcNSigma", histTpcInnerParamTpcNSigma); + recoTracks.add("recoTracks/PreSel/Pi/NoId/h32_tofExpMom_tpcNSigma", "tofExpMom_tpcNSigma", histTofExpMomTpcNSigma); + recoTracks.add("recoTracks/PreSel/Pi/NoId/h33_p_tofNSigma", "p_tofNSigma", histPTofNSigma); + recoTracks.add("recoTracks/PreSel/Pi/NoId/h34_pt_tofNSigma", "pt_tofNSigma", histPtTofNSigma); + recoTracks.add("recoTracks/PreSel/Pi/NoId/h35_tpcInnerParam_tofNSigma", "tpcInnerParam_tofNSigma", histTpcInnerParamTofNSigma); + recoTracks.add("recoTracks/PreSel/Pi/NoId/h36_tofExpMom_tofNSigma", "tofExpMom_tofNSigma", histTofExpMomTofNSigma); + recoTracks.add("recoTracks/PreSel/Pi/NoId/h37_tpcNSigma_tofNSigma", "tpcNSigma_tofNSigma", histTpcNSigmaTofNSigma); + // Pion + + recoTracks.addClone("recoTracks/PreSel/Pi/", "recoTracks/PreSel/Ka/"); // Kaon + recoTracks.addClone("recoTracks/PreSel/Pi/", "recoTracks/PreSel/Pr/"); // Proton + recoTracks.addClone("recoTracks/PreSel/Pi/", "recoTracks/PreSel/El/"); // Electron + recoTracks.addClone("recoTracks/PreSel/Pi/", "recoTracks/PreSel/De/"); // Deuteron + + // Write Code for naming the axis for Identified Particles + + // Selection + recoTracks.addClone("recoTracks/PreSel/", "recoTracks/PostSel/"); + // + + // Analysis + recoAnalysis.add("recoAnalysis/Pi/tpcId/h20_pt_eta", "pt_eta", kTH2F, {axisPt, axisEta}); + // momemtum + recoAnalysis.add("recoAnalysis/Pi/tpcId/h20_p_pt", "p_pt", histPPt); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h21_p_tpcInnerParam", "p_tpcInnerParam", histPTpcInnerParam); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h22_p_tofExpMom", "p_tofExpMom", histPTofExpMom); + // tpcSignal + recoAnalysis.add("recoAnalysis/Pi/tpcId/h23_p_tpcSignal", "p_tpcSignal", histPTpcSignal); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h24_tpcInnerParam_tpcSignal", "tpcInnerParam_tpcSignal", histTpcInnerParamTpcSignal); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h25_tofExpMom_tpcSignal", "tofExpMom_tpcSignal", histTofExpMomTpcSignal); + // tofBeta + recoAnalysis.add("recoAnalysis/Pi/tpcId/h26_p_beta", "p_beta", histPBeta); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h27_tpcInnerParam_beta", "tpcInnerParam_beta", histTpcInnerParamBeta); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h28_tofExpMom_beta", "tofExpMom_beta", histTofExpMomBeta); + // Pion + recoAnalysis.add("recoAnalysis/Pi/tpcId/h29_p_tpcNSigma", "p_tpcNSigma", histPTpcNSigma); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h30_pt_tpcNSigma", "pt_tpcNSigma", histPtTpcNSigma); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h31_tpcInnerParam_tpcNSigma", "tpcInnerParam_tpcNSigma", histTpcInnerParamTpcNSigma); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h32_tofExpMom_tpcNSigma", "tofExpMom_tpcNSigma", histTofExpMomTpcNSigma); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h33_p_tofNSigma", "p_tofNSigma", histPTofNSigma); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h34_pt_tofNSigma", "pt_tofNSigma", histPtTofNSigma); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h35_tpcInnerParam_tofNSigma", "tpcInnerParam_tofNSigma", histTpcInnerParamTofNSigma); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h36_tofExpMom_tofNSigma", "tofExpMom_tofNSigma", histTofExpMomTofNSigma); + recoAnalysis.add("recoAnalysis/Pi/tpcId/h37_tpcNSigma_tofNSigma", "tpcNSigma_tofNSigma", histTpcNSigmaTofNSigma); + + recoAnalysis.addClone("recoAnalysis/Pi/tpcId/", "recoAnalysis/Pi/tpctofId/"); + recoAnalysis.addClone("recoAnalysis/Pi/tpcId/", "recoAnalysis/Pi/NoId/"); + recoAnalysis.addClone("recoAnalysis/Pi/", "recoAnalysis/Ka/"); // Kaon + recoAnalysis.addClone("recoAnalysis/Pi/", "recoAnalysis/Pr/"); // Proton + recoAnalysis.addClone("recoAnalysis/Pi/", "recoAnalysis/El/"); // Electron + recoAnalysis.addClone("recoAnalysis/Pi/", "recoAnalysis/De/"); // Deuteron + + recoAnalysis.add("recoAnalysis/SelectedTrack_IdentificationTag", "SelectedTrack_IdentificationTag", kTH1D, {{34, -1.5, 32.5, "trackTAG"}}); + recoAnalysis.add("recoAnalysis/RejectedTrack_RejectionTag", "RejectedTrack_RejectionTag", kTH1D, {{16, -1.5, 6.5, "rejectionTAG"}}); + + recoAnalysis.add("recoAnalysis/Sparse_Full_K0sPiKa", "Sparse_Full_K0sPiKa", kTHnSparseD, {axisCent, {2000, -1.5, 1998.5, "nTrack"}, {100, -1.5, 98.5, "nK0s"}, {100, -1.5, 98.5, "nRejectedPiPlus"}, {100, -1.5, 98.5, "nRejectedPiMinus"}, {500, -1.5, 498.5, "nPiPlus"}, {500, -1.5, 498.5, "nPiMinus"}, {500, -1.5, 498.5, "nKaPlus"}, {500, -1.5, 498.5, "nKaMinus"}}); + recoAnalysis.add("recoAnalysis/Sparse_Full_K0sPrDe", "Sparse_Full_K0sPrDe", kTHnSparseD, {axisCent, {2000, -1.5, 1998.5, "nTrack"}, {100, -1.5, 98.5, "nK0s"}, {100, -1.5, 98.5, "nRejectedPiPlus"}, {100, -1.5, 98.5, "nRejectedPiMinus"}, {500, -1.5, 498.5, "nProton"}, {500, -1.5, 498.5, "nPBar"}, {500, -1.5, 498.5, "nDePlus"}, {500, -1.5, 498.5, "nDeMinus"}}); + recoAnalysis.add("recoAnalysis/Sparse_Full_K0sKaEl", "Sparse_Full_K0sKaEl", kTHnSparseD, {axisCent, {2000, -1.5, 1998.5, "nTrack"}, {100, -1.5, 98.5, "nK0s"}, {100, -1.5, 98.5, "nRejectedPiPlus"}, {100, -1.5, 98.5, "nRejectedPiMinus"}, {500, -1.5, 498.5, "nKaPlus"}, {500, -1.5, 498.5, "nKaMinus"}, {500, -1.5, 498.5, "nElPlus"}, {500, -1.5, 498.5, "nElMinus"}}); + recoAnalysis.add("recoAnalysis/Sparse_Full_PiKaPr", "Sparse_Full_PiKaPr", kTHnSparseD, {axisCent, {2000, -1.5, 1998.5, "nTrack"}, {100, -1.5, 98.5, "nRejectedPiPlus"}, {100, -1.5, 98.5, "nRejectedPiMinus"}, {500, -1.5, 498.5, "nPiPlus"}, {500, -1.5, 498.5, "nPiMinus"}, {500, -1.5, 498.5, "nKaPlus"}, {500, -1.5, 498.5, "nKaMinus"}, {500, -1.5, 498.5, "nProton"}, {500, -1.5, 498.5, "nPBar"}}); + recoAnalysis.add("recoAnalysis/Sparse_Full_PiElDe", "Sparse_Full_PiElDe", kTHnSparseD, {axisCent, {2000, -1.5, 1998.5, "nTrack"}, {100, -1.5, 98.5, "nRejectedPiPlus"}, {100, -1.5, 98.5, "nRejectedPiMinus"}, {500, -1.5, 498.5, "nPiPlus"}, {500, -1.5, 498.5, "nPiMinus"}, {500, -1.5, 498.5, "nElPlus"}, {500, -1.5, 498.5, "nElMinus"}, {500, -1.5, 498.5, "nDePlus"}, {500, -1.5, 498.5, "nDeMinus"}}); + recoAnalysis.add("recoAnalysis/Sparse_Full_KaPrDe", "Sparse_Full_KaPrDe", kTHnSparseD, {axisCent, {2000, -1.5, 1998.5, "nTrack"}, {100, -1.5, 98.5, "nRejectedPiPlus"}, {100, -1.5, 98.5, "nRejectedPiMinus"}, {500, -1.5, 498.5, "nKaPlus"}, {500, -1.5, 498.5, "nKaMinus"}, {500, -1.5, 498.5, "nProton"}, {500, -1.5, 498.5, "nPBar"}, {500, -1.5, 498.5, "nDePlus"}, {500, -1.5, 498.5, "nDeMinus"}}); + recoAnalysis.add("recoAnalysis/Sparse_Full_PrElDe", "Sparse_Full_PrElDe", kTHnSparseD, {axisCent, {2000, -1.5, 1998.5, "nTrack"}, {100, -1.5, 98.5, "nRejectedPiPlus"}, {100, -1.5, 98.5, "nRejectedPiMinus"}, {500, -1.5, 498.5, "nProton"}, {500, -1.5, 498.5, "nPBar"}, {500, -1.5, 498.5, "nElPlus"}, {500, -1.5, 498.5, "nElMinus"}, {500, -1.5, 498.5, "nDePlus"}, {500, -1.5, 498.5, "nDeMinus"}}); + + recoAnalysis.add("recoAnalysis/Sparse_newDynm_K0s_Ka", "Sparse_newDynm_K0s_Ka", kTHnSparseD, {axisCent, {2000, -1.5, 1998.5, "nTrack"}, {100, -1.5, 98.5, "nK0s"}, {500, -1.5, 498.5, "nKaon"}, {10000, -1.5, 9998.5, "(nK0s)^{2}"}, {250000, -1.5, 249998.5, "(nKaon)^{2}"}, {500, -1.5, 498.5, "(nK0s*nKaon)"}}); + recoAnalysis.add("recoAnalysis/Sparse_newDynm_Kp_Km", "Sparse_newDynm_Kp_Km", kTHnSparseD, {axisCent, {2000, -1.5, 1998.5, "nTrack"}, {500, -1.5, 498.5, "nKaPlus"}, {500, -1.5, 498.5, "nKaMinus"}, {250000, -1.5, 249998.5, "(nKaPlus)^{2}"}, {250000, -1.5, 249998.5, "(nKaMinus)^{2}"}, {250000, -1.5, 249998.5, "(nKaPlus*nKaMinus)"}}); + // + + genAnalysis.add("genAnalysis/K0s/h12_p", "p", kTH1F, {axisP}); + genAnalysis.add("genAnalysis/K0s/h13_pt", "pt", kTH1F, {axisPt}); + genAnalysis.add("genAnalysis/K0s/h14_eta", "eta", kTH1F, {axisEta}); + genAnalysis.add("genAnalysis/K0s/h15_phi", "phi", kTH1F, {axisPhi}); + genAnalysis.add("genAnalysis/K0s/h16_rapidity", "rapidity", kTH1F, {axisRapidity}); + genAnalysis.add("genAnalysis/K0s/h20_pt_eta", "pt_eta", kTH2F, {axisPt, axisEta}); + genAnalysis.addClone("genAnalysis/K0s/", "genAnalysis/Pi/"); + genAnalysis.addClone("genAnalysis/K0s/", "genAnalysis/Ka/"); + genAnalysis.addClone("genAnalysis/K0s/", "genAnalysis/Pr/"); + genAnalysis.addClone("genAnalysis/K0s/", "genAnalysis/El/"); + genAnalysis.addClone("genAnalysis/K0s/", "genAnalysis/De/"); + + // Printing the Stored Registry information + LOG(info) << "Printing Stored Registry Information"; + LOG(info) << " DEBUG :: 01- recoV0s.print()"; + recoV0s.print(); + LOG(info) << " DEBUG :: 02- recoEvent.print()"; + recoEvent.print(); + LOG(info) << " DEBUG :: 03- recoK0s.print()"; + recoK0s.print(); + LOG(info) << " DEBUG :: 04- recoTracks.print()"; + recoTracks.print(); + LOG(info) << " DEBUG :: 05- recoAnalysis.print()"; + recoAnalysis.print(); + LOG(info) << " DEBUG :: 06- genAnalysis.print()"; + genAnalysis.print(); + } + + enum RejectionTagEnum { + kPassed = 0, + kFailTpcNClsCrossedRows, + kFailTrkdcaXY, + kFailGlobalTrack, + kFailVGSelCheck, + kFailK0ShortDaughter, + kFailPhiDaughter, + }; + + enum IdentificationType { + kTPCidentified = 0, + kTOFidentified, + kTPCTOFidentified, + kUnidentified + }; + + enum TpcTofCutType { + kRectangularCut = 0, + kCircularCut, + kEllipsoidalCut + }; + + enum ProcessTypeEnum { + doDataProcessing = 0, + doRecoProcessing, + doPurityProcessing, + doGenProcessing, + doSimProcessing + }; + + enum HistRegEnum { + v0TableFull = 0, + v0TablePostK0sCheck, + v0TablePostMassCut, + v0TablePostSelectionCut, + recoK0sPreSel, + recoK0sPostSel, + recoTrackPreSel, + recoTrackPostSel, + recoAnalysisDir, + genAnalysisDir + }; + + static constexpr std::string_view HistRegDire[] = { + "v0Table/Full/", + "v0Table/postK0sCheck/", + "v0Table/postMassCut/", + "v0Table/postSelectionCut/", + "recoK0s/PreSel/", + "recoK0s/PostSel/", + "recoTracks/PreSel/", + "recoTracks/PostSel/", + "recoAnalysis/", + "genAnalysis/"}; + + enum PidEnum { + kPi = 0, // dont use kPion, kKaon, as these enumeration + kKa, // are already defined in $ROOTSYS/root/include/TPDGCode.h + kPr, + kEl, + kDe, + kK0s + }; + + static constexpr std::string_view PidDire[] = { + "Pi/", + "Ka/", + "Pr/", + "El/", + "De/", + "K0s/"}; + + enum DetEnum { + tpcId = 0, + tofId, + tpctofId, + NoId + }; + + static constexpr std::string_view DetDire[] = { + "tpcId/", + "tofId/", + "tpctofId/", + "NoId/"}; + + // vetoRejection for particles //From Victor Luis Gonzalez Sebastian's analysis note for balance functions + template + bool selTrackForId(const T& track) + { + if (-3.0 < track.tpcNSigmaEl() && track.tpcNSigmaEl() < 5.0 && + std::fabs(track.tpcNSigmaPi()) > 3.0 && + std::fabs(track.tpcNSigmaKa()) > 3.0 && + std::fabs(track.tpcNSigmaPr()) > 3.0) { + return false; + } else { + return true; + } + } + + template + bool vetoIdOthersTPC(const T& track) + { + if (pidMode != kPi) { + if (std::fabs(track.tpcNSigmaPi()) < 3.0) + return false; + } + if (pidMode != kKa) { + if (std::fabs(track.tpcNSigmaKa()) < 3.0) + return false; + } + if (pidMode != kPr) { + if (std::fabs(track.tpcNSigmaPr()) < 3.0) + return false; + } + if (cfgDoElRejection) { + if (pidMode != kEl) { + if (std::fabs(track.tpcNSigmaEl()) < 3.0) + return false; + } + } + if (cfgDoDeRejection) { + if (pidMode != kDe) { + if (std::fabs(track.tpcNSigmaDe()) < 3.0) + return false; + } + } + return true; + } + + template + bool vetoIdOthersTOF(const T& track) + { + if (pidMode != kPi) { + if (std::fabs(track.tofNSigmaPi()) < 3.0) + return false; + } + if (pidMode != kKa) { + if (std::fabs(track.tofNSigmaKa()) < 3.0) + return false; + } + if (pidMode != kPr) { + if (std::fabs(track.tofNSigmaPr()) < 3.0) + return false; + } + if (cfgDoElRejection) { + if (pidMode != kEl) { + if (std::fabs(track.tofNSigmaEl()) < 3.0) + return false; + } + } + if (cfgDoDeRejection) { + if (pidMode != kDe) { + if (std::fabs(track.tofNSigmaDe()) < 3.0) + return false; + } + } + return true; + } + + template + bool vetoIdOthersTPCTOF(const T& track) + { + if (pidMode != kPi) { + if (std::fabs(track.tpcNSigmaPi()) < 3.0 && std::fabs(track.tofNSigmaPi()) < 3.0) + return false; + } + if (pidMode != kKa) { + if (std::fabs(track.tpcNSigmaKa()) < 3.0 && std::fabs(track.tofNSigmaKa()) < 3.0) + return false; + } + if (pidMode != kPr) { + if (std::fabs(track.tpcNSigmaPr()) < 3.0 && std::fabs(track.tofNSigmaPr()) < 3.0) + return false; + } + if (cfgDoElRejection) { + if (pidMode != kEl) { + if (std::fabs(track.tpcNSigmaEl()) < 3.0 && std::fabs(track.tofNSigmaEl()) < 3.0) + return false; + } + } + if (cfgDoDeRejection) { + if (pidMode != kDe) { + if (std::fabs(track.tpcNSigmaDe()) < 3.0 && std::fabs(track.tofNSigmaDe()) < 3.0) + return false; + } + } + return true; + } + + template + bool selIdRectangularCut(const T& track, const float& nSigmaTPC, const float& nSigmaTOF) + { + switch (pidMode) { + case kPi: + if (std::fabs(track.tpcNSigmaPi()) < nSigmaTPC && + std::fabs(track.tofNSigmaPi()) < nSigmaTOF) { + return true; + } + break; + case kKa: + if (std::fabs(track.tpcNSigmaKa()) < nSigmaTPC && + std::fabs(track.tofNSigmaKa()) < nSigmaTOF) { + return true; + } + break; + case kPr: + if (std::fabs(track.tpcNSigmaPr()) < nSigmaTPC && + std::fabs(track.tofNSigmaPr()) < nSigmaTOF) { + return true; + } + break; + default: + return false; + break; + } + return false; + } + + template + bool selIdEllipsoidalCut(const T& track, const float& nSigmaTPC, const float& nSigmaTOF) + { + switch (pidMode) { + case kPi: + if (std::pow(track.tpcNSigmaPi() / nSigmaTPC, 2) + std::pow(track.tofNSigmaPi() / nSigmaTOF, 2) < 1.0) + return true; + break; + case kKa: + if (std::pow(track.tpcNSigmaKa() / nSigmaTPC, 2) + std::pow(track.tofNSigmaKa() / nSigmaTOF, 2) < 1.0) + return true; + break; + case kPr: + if (std::pow(track.tpcNSigmaPr() / nSigmaTPC, 2) + std::pow(track.tofNSigmaPr() / nSigmaTOF, 2) < 1.0) + return true; + break; + default: + return false; + break; + } + return false; + } + + template + bool selIdCircularCut(const T& track, const float& nSigmaSquaredRad) + { + switch (pidMode) { + case kPi: + if (std::pow(track.tpcNSigmaPi(), 2) + std::pow(track.tofNSigmaPi(), 2) < nSigmaSquaredRad) + return true; + break; + case kKa: + if (std::pow(track.tpcNSigmaKa(), 2) + std::pow(track.tofNSigmaKa(), 2) < nSigmaSquaredRad) + return true; + break; + case kPr: + if (std::pow(track.tpcNSigmaPr(), 2) + std::pow(track.tofNSigmaPr(), 2) < nSigmaSquaredRad) + return true; + break; + default: + return false; + break; + } + return false; + } + + template + bool checkReliableTOF(const T& track) + { + if (track.hasTOF()) + return true; // which check makes the information of TOF relaiable? should track.beta() be checked? + else + return false; + } + + template + bool idTPC(const T& track, const float& nSigmaTPC) + { + if (cfgCheckVetoCut && !vetoIdOthersTPC(track)) + return false; + switch (pidMode) { + case kPi: + if (std::fabs(track.tpcNSigmaPi()) < nSigmaTPC) + return true; + break; + case kKa: + if (std::fabs(track.tpcNSigmaKa()) < nSigmaTPC) + return true; + break; + case kPr: + if (std::fabs(track.tpcNSigmaPr()) < nSigmaTPC) + return true; + break; + default: + return false; + break; + } + return false; + } + + template + bool idTPCTOF(const T& track, const int& pidCutType, const float& nSigmaTPC, const float& nSigmaTOF, const float& nSigmaSquaredRad) + { + if (cfgCheckVetoCut && !vetoIdOthersTPCTOF(track)) + return false; + if (pidCutType == kRectangularCut) { + return selIdRectangularCut(track, nSigmaTPC, nSigmaTOF); + } else if (pidCutType == kCircularCut) { + return selIdCircularCut(track, nSigmaSquaredRad); + } else if (pidCutType == kEllipsoidalCut) { + return selIdEllipsoidalCut(track, nSigmaTPC, nSigmaTOF); + } + return false; + } + + template + bool selPiPdependent(const T& track, int& IdMethod) + { + if (track.p() < cfgPiThrPforTOF) { + if (checkReliableTOF(track)) { + if (idTPCTOF(track, cfgPiIdCutTypeLowP, cfgPiNSigmaTPCLowP, cfgPiNSigmaTOFLowP, cfgPiNSigmaRadLowP)) { + IdMethod = kTPCTOFidentified; + return true; + } + return false; + } else { + if (idTPC(track, cfgPiNSigmaTPCLowP)) { + IdMethod = kTPCidentified; + return true; + } + return false; + } + } else { + if (checkReliableTOF(track)) { + if (idTPCTOF(track, cfgPiIdCutTypeHighP, cfgPiNSigmaTPCHighP, cfgPiNSigmaTOFHighP, cfgPiNSigmaRadHighP)) { + IdMethod = kTPCTOFidentified; + return true; + } + return false; + } + return false; + } + } + + template + bool selKaPdependent(const T& track, int& IdMethod) + { + if (track.p() < cfgKaThrPforTOF) { + if (checkReliableTOF(track)) { + if (idTPCTOF(track, cfgKaIdCutTypeLowP, cfgKaNSigmaTPCLowP, cfgKaNSigmaTOFLowP, cfgKaNSigmaRadLowP)) { + IdMethod = kTPCTOFidentified; + return true; + } + return false; + } else { + if (idTPC(track, cfgKaNSigmaTPCLowP)) { + IdMethod = kTPCidentified; + return true; + } + return false; + } + } else { + if (checkReliableTOF(track)) { + if (idTPCTOF(track, cfgKaIdCutTypeHighP, cfgKaNSigmaTPCHighP, cfgKaNSigmaTOFHighP, cfgKaNSigmaRadHighP)) { + IdMethod = kTPCTOFidentified; + return true; + } + return false; + } + return false; + } + } + + template + bool selPrPdependent(const T& track, int& IdMethod) + { + if (track.p() < cfgPrThrPforTOF) { + if (checkReliableTOF(track)) { + if (idTPCTOF(track, cfgPrIdCutTypeLowP, cfgPrNSigmaTPCLowP, cfgPrNSigmaTOFLowP, cfgPrNSigmaRadLowP)) { + IdMethod = kTPCTOFidentified; + return true; + } + return false; + } else { + if (idTPC(track, cfgPrNSigmaTPCLowP)) { + IdMethod = kTPCidentified; + return true; + } + return false; + } + } else { + if (checkReliableTOF(track)) { + if (idTPCTOF(track, cfgPrIdCutTypeHighP, cfgPrNSigmaTPCHighP, cfgPrNSigmaTOFHighP, cfgPrNSigmaRadHighP)) { + IdMethod = kTPCTOFidentified; + return true; + } + return false; + } + return false; + } + } + + //_______________________________Identification Funtions Depending on the tpcInnerParam _______________________________ + // tpc Selections + template + bool selPionTPCInnerParam(T track) + { + if (vetoIdOthersTPC(track)) { + if (0.05 <= track.tpcInnerParam() && track.tpcInnerParam() < 0.70 && std::abs(track.tpcNSigmaPi()) < cfgPiNSigmaTPCLowP) { + return true; + } + if (0.70 <= track.tpcInnerParam() && std::abs(track.tpcNSigmaPi()) < cfgPiNSigmaTPCHighP) { + return true; + } + } + return false; + } + + template + bool selKaonTPCInnerParam(T track) + { + if (vetoIdOthersTPC(track)) { + if (0.05 <= track.tpcInnerParam() && track.tpcInnerParam() < 0.70 && std::abs(track.tpcNSigmaKa()) < cfgKaNSigmaTPCLowP) { + return true; + } + if (0.70 <= track.tpcInnerParam() && std::abs(track.tpcNSigmaKa()) < cfgKaNSigmaTPCHighP) { + return true; + } + } + return false; + } + + template + bool selProtonTPCInnerParam(T track) + { + if (vetoIdOthersTPC(track)) { + if (0.05 <= track.tpcInnerParam() && track.tpcInnerParam() < 1.60 && std::abs(track.tpcNSigmaPr()) < cfgPrNSigmaTPCLowP) { + return true; + } + if (1.60 <= track.tpcInnerParam() && std::abs(track.tpcNSigmaPr()) < cfgPrNSigmaTPCHighP) { + return true; + } + } + return false; + } + + template + bool selDeuteronTPCInnerParam(T track) + { + if (vetoIdOthersTPC(track)) { + if (0.05 <= track.tpcInnerParam() && track.tpcInnerParam() < 1.80 && std::abs(track.tpcNSigmaDe()) < 3.0) { + return true; + } + if (1.80 <= track.tpcInnerParam() && std::abs(track.tpcNSigmaDe()) < 2.0) { + return true; + } + } + return false; + } + + template + bool selElectronTPCInnerParam(T track) + { + if (track.tpcNSigmaEl() < 3.0 && track.tpcNSigmaPi() > 3.0 && track.tpcNSigmaKa() > 3.0 && track.tpcNSigmaPr() > 3.0 && track.tpcNSigmaDe() > 3.0) { + return true; + } + return false; + } + // + //_____________________________________________________TOF selection Functions _______________________________________________________________________ + // TOF Selections + // Pion + template + bool selPionTOF(T track) + { + if (vetoIdOthersTOF(track)) { + if (track.p() <= 0.75 && std::abs(track.tpcNSigmaPi()) < cfgPiNSigmaTPCLowP && std::abs(track.tofNSigmaPi()) < cfgPiNSigmaTOFLowP) { + return true; + } else if (0.75 < track.p() // after p = 0.75, Pi and Ka lines of nSigma 3.0 will start intersecting + && std::abs(track.tpcNSigmaPi()) < cfgPiNSigmaTPCHighP && std::abs(track.tofNSigmaPi()) < cfgPiNSigmaTOFHighP) { + return true; + } + } + return false; + } + + // Kaon + template + bool selKaonTOF(T track) + { + if (vetoIdOthersTOF(track)) { + if (track.p() <= 0.75 && std::abs(track.tpcNSigmaKa()) < cfgKaNSigmaTPCLowP && std::abs(track.tofNSigmaKa()) < cfgKaNSigmaTOFLowP) { + return true; + } + if (0.75 < track.p() && track.p() <= 1.30 // after 0.75 Pi and Ka lines of nSigma 3.0 will start intersecting + && std::abs(track.tpcNSigmaKa()) < cfgKaNSigmaTPCLowP && std::abs(track.tofNSigmaKa()) < cfgKaNSigmaTOFLowP) { + return true; + } + if (1.30 < track.p() // after 1.30 Pr and Ka lines of nSigma 3.0 will start intersecting + && std::abs(track.tpcNSigmaKa()) < cfgKaNSigmaTPCHighP && std::abs(track.tofNSigmaKa()) < cfgKaNSigmaTOFHighP) { + return true; + } + } + return false; + } + + // Proton + template + bool selProtonTOF(T track) + { + if (vetoIdOthersTOF(track)) { + if (track.p() <= 1.30 && std::abs(track.tpcNSigmaPr()) < cfgPrNSigmaTPCLowP && std::abs(track.tofNSigmaPr()) < cfgPrNSigmaTOFLowP) { + return true; + } + if (1.30 < track.p() && track.p() <= 3.10 // after 1.30 Pr and Ka lines of nSigma 3.0 will start intersecting + && std::abs(track.tpcNSigmaPr()) < cfgPrNSigmaTPCLowP && std::abs(track.tofNSigmaPr()) < cfgPrNSigmaTOFLowP // Some Deuteron contamination is still coming in p dependent cuts + ) { + return true; + } + if (3.10 < track.p() // after 3.10 Pr and De lines of nSigma 3.0 will start intersecting + && std::abs(track.tpcNSigmaPr()) < cfgPrNSigmaTPCHighP && std::abs(track.tofNSigmaPr()) < cfgPrNSigmaTOFHighP) { + return true; + } + } + return false; + } + + // Deuteron + template + bool selDeuteronTOF(T track) + { + if (vetoIdOthersTOF(track)) { + if (track.p() <= 3.10 && std::abs(track.tpcNSigmaDe()) < 3.0 && std::abs(track.tofNSigmaDe()) < 3.0) { + return true; + } + if (3.10 < track.p() // after 3.10 De and Pr lines of nSigma 3.0 will start intersecting + && std::abs(track.tpcNSigmaDe()) < 2.0 && std::abs(track.tofNSigmaDe()) < 2.0) { + return true; + } + } + return false; + } + + // Electron + template + bool selElectronTOF(T track) + { + if ((std::pow(track.tpcNSigmaEl(), 2) + std::pow(track.tofNSigmaEl(), 2)) < 9.00 && vetoIdOthersTOF(track)) { + return true; + } + return false; + } + // + + //______________________________Identification Functions________________________________________________________________ + // Pion + template + bool selPion(T track, int& IdMethod) + { + if (cfgDoPdependentId) { + return selPiPdependent(track, IdMethod); + } else if (cfgDoTpcInnerParamId) { + if (selPionTPCInnerParam(track)) { + IdMethod = kTPCidentified; + return true; + } else if (track.hasTOF() && track.beta() > 0.0 && selPionTOF(track)) { + IdMethod = kTOFidentified; + return true; + } + return false; + } + return false; + } + + // Kaon + template + bool selKaon(T track, int& IdMethod) + { + if (cfgDoPdependentId) { + return selKaPdependent(track, IdMethod); + } else if (cfgDoTpcInnerParamId) { + if (selKaonTPCInnerParam(track)) { + IdMethod = kTPCidentified; + return true; + } else if (track.hasTOF() && track.beta() > 0.0 && selKaonTOF(track)) { + IdMethod = kTOFidentified; + return true; + } + return false; + } + return false; + } + + // Proton + template + bool selProton(T track, int& IdMethod) + { + if (cfgDoPdependentId) { + return selPrPdependent(track, IdMethod); + } else if (cfgDoTpcInnerParamId) { + if (selProtonTPCInnerParam(track)) { + IdMethod = kTPCidentified; + return true; + } else if (track.hasTOF() && track.beta() > 0.0 && selProtonTOF(track)) { + IdMethod = kTOFidentified; + return true; + } + return false; + } + return false; + } + + // Deuteron + template + bool selDeuteron(T track, int& IdMethod) + { + if (cfgDoPdependentId) { + return false; + } else if (cfgDoTpcInnerParamId) { + if (selDeuteronTPCInnerParam(track)) { + IdMethod = kTPCidentified; + return true; + } else if (track.hasTOF() && track.beta() > 0.0 && selDeuteronTOF(track)) { + IdMethod = kTOFidentified; + return true; + } + return false; + } + return false; + } + + // Electron + template + bool selElectron(T track, int& IdMethod) + { + if (cfgDoPdependentId) { + return false; + } else if (cfgDoTpcInnerParamId) { + if (selElectronTPCInnerParam(track)) { + IdMethod = kTPCidentified; + return true; + } else if (track.hasTOF() && track.beta() > 0.0 && selElectronTOF(track)) { + IdMethod = kTOFidentified; + return true; + } + return false; + } + return false; + } + + template + int findV0Tag(const T& posDaughterTrack, const T& negDaughterTrack, int& posPiIdMethod, int& posPrIdMethod, int& negPiIdMethod, int& negPrIdMethod) + { + bool posIsPion = false; + bool posIsProton = false; + bool negIsPion = false; + bool negIsProton = false; + + int v0TagValue = 0; + + // Check if positive track is pion or proton + if (selPion(posDaughterTrack, posPiIdMethod)) + posIsPion = true; // Coming From K0s -> PiPlus + PiMinus and AntiLambda -> PiPlus + AntiProton + if (selProton(posDaughterTrack, posPrIdMethod)) + posIsProton = true; // Coming From Lambda -> proton + PiMinus + if (selPion(negDaughterTrack, negPiIdMethod)) + negIsPion = true; // Coming From K0s -> PiPlus + PiMinus and Lambda -> proton + PiMinus + if (selProton(negDaughterTrack, negPrIdMethod)) + negIsProton = true; // Coming From AntiLambda -> PiPlus + AntiProton + + if (posIsPion && negIsPion) { + BITSET(v0TagValue, BIT_IS_K0S); + } + if (posIsProton && negIsPion) { + BITSET(v0TagValue, BIT_IS_LAMBDA); + } + if (posIsPion && negIsProton) { + BITSET(v0TagValue, BIT_IS_ANTILAMBDA); + } + return v0TagValue; + } + + template + int findCollisionIndexTag(const T& v0, const U& posDaughterTrack, const U& negDaughterTrack) + { + int v0daughterCollisionIndexTag = 0; + if (v0.collisionId() == posDaughterTrack.collisionId()) { + BITSET(v0daughterCollisionIndexTag, BIT_POS_DAU_HAS_SAME_COLL); + } + if (v0.collisionId() == negDaughterTrack.collisionId()) { + BITSET(v0daughterCollisionIndexTag, BIT_NEG_DAU_HAS_SAME_COLL); + } + if (posDaughterTrack.collisionId() == negDaughterTrack.collisionId()) { + BITSET(v0daughterCollisionIndexTag, BIT_BOTH_DAU_HAS_SAME_COLL); + } + return v0daughterCollisionIndexTag; + } + + template + bool selK0s(T v0) + { + if (k0sSelCut.cfgK0sMLow < v0.mK0Short() && v0.mK0Short() < k0sSelCut.cfgK0sMHigh && + k0sSelCut.cfgK0sLowPt < v0.pt() && v0.pt() < k0sSelCut.cfgK0sHighPt && + std::abs(v0.rapidity(MassK0Short)) < k0sSelCut.cfgK0sRapitidy && + v0.qtarm() > (k0sSelCut.cfgK0sARMcut * std::abs(v0.alpha()))) { + return true; + } else { + return false; + } + } + + template + void findRepeatedEntries(std::vector ParticleList, T hist) + { + for (uint ii = 0; ii < ParticleList.size(); ii++) { + int nCommonCount = 0; // checking the repeat number of track + for (uint jj = 0; jj < ParticleList.size(); jj++) { + if (ParticleList[jj] == ParticleList[ii]) { + if (jj < ii) { + break; + } // break if it was already counted + nCommonCount++; // To Calculate no of times the entry was repeated + } + } + hist->Fill(nCommonCount); + } + } + + template + bool checkTrackSelection(const T& track, int& rejectionTag) + { + if (track.tpcNClsCrossedRows() < cfgTrackCuts.cfgTrkTpcNClsCrossedRows) { + rejectionTag = kFailTpcNClsCrossedRows; + return false; + } + if (std::fabs(track.dcaXY()) > cfgTrackCuts.cfgTrkdcaXY) { + rejectionTag = kFailTrkdcaXY; + return false; + } + if (!track.isGlobalTrack()) { + rejectionTag = kFailGlobalTrack; + return false; + } + if (cfgTrackCuts.cfgDoVGselTrackCheck) { + if (!selTrackForId(track)) { + rejectionTag = kFailVGSelCheck; + return false; + } + } + return true; + } + + template + bool checkTrackInList(const T& track, const std::vector& vecList, int& rejectionTag, const int& listTagValue) + { + if (std::binary_search(vecList.begin(), vecList.end(), track.globalIndex())) { + rejectionTag = listTagValue; + return true; // Binary Search is fastest search in a sorted array. + } + return false; + } + + template + void fillIdentificationQA(H histReg, const T& track) + { + + float tpcNSigmaVal = -999, tofNSigmaVal = -999; + switch (pidMode) { + case kPi: + if (!cfgFillPiQA) + return; + tpcNSigmaVal = track.tpcNSigmaPi(); + tofNSigmaVal = track.tofNSigmaPi(); + break; + case kKa: + if (!cfgFillKaQA) + return; + tpcNSigmaVal = track.tpcNSigmaKa(); + tofNSigmaVal = track.tofNSigmaKa(); + break; + case kPr: + if (!cfgFillPrQA) + return; + tpcNSigmaVal = track.tpcNSigmaPr(); + tofNSigmaVal = track.tofNSigmaPr(); + break; + case kEl: + if (!cfgFillElQA) + return; + tpcNSigmaVal = track.tpcNSigmaEl(); + tofNSigmaVal = track.tofNSigmaEl(); + break; + case kDe: + if (!cfgFillDeQA) + return; + tpcNSigmaVal = track.tpcNSigmaDe(); + tofNSigmaVal = track.tofNSigmaDe(); + break; + default: + tpcNSigmaVal = -999, tofNSigmaVal = -999; + break; + } + + if (fillSignal) { + // momemtum + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h20_p_pt"), track.p(), track.pt()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h21_p_tpcInnerParam"), track.p(), track.tpcInnerParam()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h22_p_tofExpMom"), track.p(), track.tofExpMom()); + // tpcSignal + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h23_p_tpcSignal"), track.p(), track.tpcSignal()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h24_tpcInnerParam_tpcSignal"), track.tpcInnerParam(), track.tpcSignal()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h25_tofExpMom_tpcSignal"), track.tofExpMom(), track.tpcSignal()); + // tofBeta + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h26_p_beta"), track.p(), track.beta()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h27_tpcInnerParam_beta"), track.tpcInnerParam(), track.beta()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h28_tofExpMom_beta"), track.tofExpMom(), track.beta()); + } + // NSigma + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h29_p_tpcNSigma"), track.p(), tpcNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h30_pt_tpcNSigma"), track.pt(), tpcNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h31_tpcInnerParam_tpcNSigma"), track.tpcInnerParam(), tpcNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h32_tofExpMom_tpcNSigma"), track.tofExpMom(), tpcNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h33_p_tofNSigma"), track.p(), tofNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h34_pt_tofNSigma"), track.pt(), tofNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h35_tpcInnerParam_tofNSigma"), track.tpcInnerParam(), tofNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h36_tofExpMom_tofNSigma"), track.tofExpMom(), tofNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h37_tpcNSigma_tofNSigma"), tpcNSigmaVal, tofNSigmaVal); + } + + template + void fillTrackQA(T track) + { + // FullTrack + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h01_p"), track.p()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h02_pt"), track.pt()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h03_tpcInnerParam"), track.tpcInnerParam()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h04_tofExpMom"), track.tofExpMom()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h05_eta"), track.eta()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h06_phi"), track.phi()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h07_dcaXY"), track.dcaXY()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h08_dcaZ"), track.dcaZ()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h09_sign"), track.sign()); + // DcaXY + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h10_p_dcaXY"), track.p(), track.dcaXY()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h11_pt_dcaXY"), track.pt(), track.dcaXY()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h12_tpcInnerParam_dcaXY"), track.tpcInnerParam(), track.dcaXY()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h13_tofExpMom_dcaXY"), track.tofExpMom(), track.dcaXY()); + + // DcaZ + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h14_p_dcaZ"), track.p(), track.dcaZ()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h15_pt_dcaZ"), track.pt(), track.dcaZ()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h16_tpcInnerParam_dcaZ"), track.tpcInnerParam(), track.dcaZ()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h17_tofExpMom_dcaZ"), track.tofExpMom(), track.dcaZ()); + + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h20_pt_eta"), track.pt(), track.eta()); + // momemtum + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h20_p_pt"), track.p(), track.pt()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h21_p_tpcInnerParam"), track.p(), track.tpcInnerParam()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h22_p_tofExpMom"), track.p(), track.tofExpMom()); + + // tpcSignal + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h23_p_tpcSignal"), track.p(), track.tpcSignal()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h24_tpcInnerParam_tpcSignal"), track.tpcInnerParam(), track.tpcSignal()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h25_tofExpMom_tpcSignal"), track.tofExpMom(), track.tpcSignal()); + + // tofBeta + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h26_p_beta"), track.p(), track.beta()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h27_tpcInnerParam_beta"), track.tpcInnerParam(), track.beta()); + recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h28_tofExpMom_beta"), track.tofExpMom(), track.beta()); + + fillIdentificationQA(recoTracks, track); // Look at Pion + fillIdentificationQA(recoTracks, track); // Look at Kaon + fillIdentificationQA(recoTracks, track); // Look at Proton + fillIdentificationQA(recoTracks, track); // Look at Electron + fillIdentificationQA(recoTracks, track); // Look at Deuteron + } + + template + void fillV0DaughterQA(H histReg, const T& track, double particleMass) + { + // K0s-Daughter Info + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h01_p"), track.p()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h02_pt"), track.pt()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h03_tpcInnerParam"), track.tpcInnerParam()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h04_tofExpMom"), track.tofExpMom()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h05_eta"), track.eta()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h06_phi"), track.phi()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h07_rapidity"), track.rapidity(particleMass)); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h08_isPVContributor"), track.isPVContributor()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h09_isGlobalTrack"), track.isGlobalTrack()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h10_dcaXY"), track.dcaXY()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h11_dcaZ"), track.dcaZ()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h12_p_dcaXY"), track.p(), track.dcaXY()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h13_p_dcaZ"), track.p(), track.dcaZ()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h14_pt_dcaXY"), track.pt(), track.dcaXY()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h15_pt_dcaZ"), track.pt(), track.dcaZ()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h16_dcaXYwide"), track.dcaXY()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h17_dcaZwide"), track.dcaZ()); + + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("h20_pt_eta"), track.pt(), track.eta()); + + fillIdentificationQA(histReg, track); + } + + template + void fillV0QA(H histReg, const T& v0, const U& posDaughterTrack, const U& negDaughterTrack, const int& v0Tag, const int& v0DauCollisionIndexTag, const int& posPiIdMethod, const int& negPiIdMethod) + { + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h01_K0s_Mass"), v0.mK0Short()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h02_Lambda_Mass"), v0.mLambda()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h03_AntiLambda_Mass"), v0.mAntiLambda()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h04_v0DaughterCollisionIndexTag"), v0DauCollisionIndexTag); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h05_V0Tag"), v0Tag); + + // Topological Cuts + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h06_dcapostopv"), v0.dcapostopv()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h07_dcanegtopv"), v0.dcanegtopv()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h08_dcaV0daughters"), v0.dcaV0daughters()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h09_v0cosPA"), v0.v0cosPA()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h10_v0radius"), v0.v0radius()); + + // K0s-FullInformation + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h11_mass"), v0.mK0Short()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h12_p"), v0.p()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h13_pt"), v0.pt()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h14_eta"), v0.eta()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h15_phi"), v0.phi()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h16_rapidity"), v0.rapidity(MassK0Short)); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h17_alpha"), v0.alpha()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h18_qtarm"), v0.qtarm()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h19_alpha_qtarm"), v0.alpha(), v0.qtarm()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST("h20_pt_eta"), v0.pt(), v0.eta()); + + if (posPiIdMethod == kTPCidentified) { + fillV0DaughterQA(histReg, posDaughterTrack, MassProton); + } else if (posPiIdMethod == kTPCTOFidentified) { + fillV0DaughterQA(histReg, posDaughterTrack, MassProton); + } else if (posPiIdMethod == kUnidentified) { + fillV0DaughterQA(histReg, posDaughterTrack, MassProton); + } + + if (negPiIdMethod == kTPCidentified) { + fillV0DaughterQA(histReg, negDaughterTrack, MassProton); + } else if (negPiIdMethod == kTPCTOFidentified) { + fillV0DaughterQA(histReg, negDaughterTrack, MassProton); + } else if (negPiIdMethod == kUnidentified) { + fillV0DaughterQA(histReg, negDaughterTrack, MassProton); + } + } + + template + void fillGenTrackQA(H& histReg, const T& mcTrack) + { + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST("h12_p"), mcTrack.p()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST("h13_pt"), mcTrack.pt()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST("h14_eta"), mcTrack.eta()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST("h15_phi"), mcTrack.phi()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST("h16_rapidity"), mcTrack.y()); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST("h20_pt_eta"), mcTrack.pt(), mcTrack.eta()); + } + + template + void executeV0loop(const T& posDaughterTrack, const T& negDaughterTrack, const U& v0, H& recoV0s, + int& posPiIdMethod, int& posPrIdMethod, int& negPiIdMethod, int& negPrIdMethod, + int& v0Tag, int& trueV0TagValue, bool& isK0s, int& v0DauCollisionIndexTag, + auto& k0sPosDauList, auto& k0sNegDauList) + { + posPiIdMethod = kUnidentified; + posPrIdMethod = kUnidentified; + negPiIdMethod = kUnidentified; + negPrIdMethod = kUnidentified; + v0Tag = findV0Tag(posDaughterTrack, negDaughterTrack, posPiIdMethod, posPrIdMethod, negPiIdMethod, negPrIdMethod); + v0DauCollisionIndexTag = findCollisionIndexTag(v0, posDaughterTrack, negDaughterTrack); + + isK0s = false; + if (BITCHECK(v0Tag, BIT_IS_K0S) != 0) + isK0s = true; + trueV0TagValue = 0; + if (cfgFillV0TableFull) { + fillV0QA(recoV0s, v0, posDaughterTrack, negDaughterTrack, v0Tag, v0DauCollisionIndexTag, posPiIdMethod, negPiIdMethod); + } + // cut on dynamic columns for v0 particles + if (v0.v0cosPA() < v0settingCosPA) + return; // in place of continue; + if (v0.v0radius() < v0settingRadius) + return; // in place of continue; + + // K0s Analysis + if (isK0s) { + if (cfgFillV0TablePostK0sCheck) { + fillV0QA(recoV0s, v0, posDaughterTrack, negDaughterTrack, v0Tag, v0DauCollisionIndexTag, posPiIdMethod, negPiIdMethod); + } + // K0s mass cut + if (cfgFillV0TablePostMassCut) { + if (k0sSelCut.cfgK0sMLow < v0.mK0Short() && v0.mK0Short() < k0sSelCut.cfgK0sMHigh) { + fillV0QA(recoV0s, v0, posDaughterTrack, negDaughterTrack, v0Tag, v0DauCollisionIndexTag, posPiIdMethod, negPiIdMethod); + } + } + // Final K0s Selection. + if (selK0s(v0)) { + if (cfgFillV0TablePostSelectionCut) { + fillV0QA(recoV0s, v0, posDaughterTrack, negDaughterTrack, v0Tag, v0DauCollisionIndexTag, posPiIdMethod, negPiIdMethod); + } + trueV0TagValue += 1; + k0sPosDauList.push_back(posDaughterTrack.globalIndex()); + k0sNegDauList.push_back(negDaughterTrack.globalIndex()); + } + recoV0s.fill(HIST(HistRegDire[v0TablePostSelectionCut]) + HIST("hTrueV0TagCount"), trueV0TagValue); // 001 = Kaon, 010 = Lambda, 100 = AnitLambda + } // End of K0s block + } + + template + void executeSortPairDaughters(const auto& posDauList, const auto& negDauList, auto& fullDauList, const T& hist) + { + findRepeatedEntries(posDauList, hist); + findRepeatedEntries(negDauList, hist); + + // Obtain one single new daughter vector to remove double counting + fullDauList.insert(fullDauList.end(), posDauList.begin(), posDauList.end()); + fullDauList.insert(fullDauList.end(), negDauList.begin(), negDauList.end()); + + // Sort and Remove repeated entries + std::sort(fullDauList.begin(), fullDauList.end()); + auto last = std::unique(fullDauList.begin(), fullDauList.end()); // std::unique only moves duplicates to end of the vector + fullDauList.erase(last, fullDauList.end()); // last is the iterator position from where duplicate entries start + + // Check sorting + if (!std::is_sorted(fullDauList.begin(), fullDauList.end())) { + LOG(error) << "fullDauList is unsorted, will give wrong results when v0 and collisions will be checked"; + } + } + + template //, typename H> + void executeV0InCollisionloop(const T& posDaughterTrack, const T& negDaughterTrack, const U& v0, + int& posPiIdMethod, int& posPrIdMethod, int& negPiIdMethod, int& negPrIdMethod, + int& v0Tag, bool& isK0s, int& v0DauCollisionIndexTag, float& nK0s, const float& centrality) + { + if (v0.v0cosPA() < v0settingCosPA) + return; // for continue; // cut on dynamic columns for v0 particles + if (v0.v0radius() < v0settingRadius) + return; // for continue; + isK0s = false; + + posPiIdMethod = kUnidentified; + posPrIdMethod = kUnidentified; + negPiIdMethod = kUnidentified; + negPrIdMethod = kUnidentified; + v0Tag = findV0Tag(posDaughterTrack, negDaughterTrack, posPiIdMethod, posPrIdMethod, negPiIdMethod, negPrIdMethod); + v0DauCollisionIndexTag = findCollisionIndexTag(v0, posDaughterTrack, negDaughterTrack); + + if (BITCHECK(v0Tag, BIT_IS_K0S) != 0) + isK0s = true; + if (cfgFillRecoK0sPreSel) { + fillV0QA(recoK0s, v0, posDaughterTrack, negDaughterTrack, v0Tag, v0DauCollisionIndexTag, posPiIdMethod, negPiIdMethod); + } + // K0s Analysis + if (isK0s && selK0s(v0)) { + if (cfgFillRecoK0sPostSel) { + fillV0QA(recoK0s, v0, posDaughterTrack, negDaughterTrack, v0Tag, v0DauCollisionIndexTag, posPiIdMethod, negPiIdMethod); + } + recoK0s.fill(HIST(HistRegDire[recoK0sPostSel]) + HIST("mK0s_vs_cent"), centrality, v0.mK0Short()); // centrality dependent mass + nK0s++; + } // End of K0s block + } + + template + void executeTrackQAPart(const T& track, const auto& fullDauList, int& rejectionTag, float& nRejectedPiMinus, float& nRejectedPiPlus, int& nTrack, bool& isAcceptedTrack) + { + if (cfgFillRecoTrackPreSel) { + fillTrackQA(track); + } + rejectionTag = 0; + if (!checkTrackSelection(track, rejectionTag)) { + recoAnalysis.fill(HIST("recoAnalysis/RejectedTrack_RejectionTag"), rejectionTag); + isAcceptedTrack = false; + return; // for continue; + } else if (checkTrackInList(track, fullDauList, rejectionTag, kFailK0ShortDaughter)) { + recoAnalysis.fill(HIST("recoAnalysis/RejectedTrack_RejectionTag"), rejectionTag); + if (track.signed1Pt() > 0) { + nRejectedPiPlus++; // DOEFFCORR + } else if (track.signed1Pt() < 0) { + nRejectedPiMinus++; // DOEFFCORR + } + isAcceptedTrack = false; + return; // for continue; + } + isAcceptedTrack = true; + if (cfgFillRecoTrackPostSel) { + fillTrackQA(track); + } + nTrack++; + } + + template + void executeTrackAnalysisPart(const T& track, const int& trackIdTag, + const int& idMethodPi, const bool& trackIsPion, float& nPiMinus, float& nPiPlus, + const int& idMethodKa, const bool& trackIsKaon, float& nKaMinus, float& nKaPlus, + const int& idMethodPr, const bool& trackIsProton, float& nProton, float& nPBar, + const int& idMethodEl, const bool& trackIsElectron, float& nElPlus, float& nElMinus, + const int& idMethodDe, const bool& trackIsDeuteron, float& nDePlus, float& nDeMinus) + { + if (trackIsPion) { + if (idMethodPi == kTPCidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodPi == kTPCTOFidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodPi == kUnidentified) { + fillIdentificationQA(recoAnalysis, track); + } + if (track.sign() > 0) { + nPiPlus++; + } else if (track.sign() < 0) { + nPiMinus++; + } + } + if (trackIsKaon) { + if (idMethodKa == kTPCidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodKa == kTPCTOFidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodKa == kUnidentified) { + fillIdentificationQA(recoAnalysis, track); + } + if (track.sign() > 0) { + nKaPlus++; + } else if (track.sign() < 0) { + nKaMinus++; + } + } + if (trackIsProton) { + if (idMethodPr == kTPCidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodPr == kTPCTOFidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodPr == kUnidentified) { + fillIdentificationQA(recoAnalysis, track); + } + if (track.sign() > 0) { + nProton++; + } else if (track.sign() < 0) { + nPBar++; + } + } + if (trackIsElectron) { + if (idMethodEl == kTPCidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodEl == kTPCTOFidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodEl == kUnidentified) { + fillIdentificationQA(recoAnalysis, track); + } + if (track.sign() > 0) { + nElPlus++; + } else if (track.sign() < 0) { + nElMinus++; + } + } + if (trackIsDeuteron) { + if (idMethodDe == kTPCidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodDe == kTPCTOFidentified) { + fillIdentificationQA(recoAnalysis, track); + } else if (idMethodDe == kUnidentified) { + fillIdentificationQA(recoAnalysis, track); + } + if (track.sign() > 0) { + nDePlus++; + } + if (track.sign() < 0) { + nDeMinus++; + } + } + recoAnalysis.fill(HIST("recoAnalysis/SelectedTrack_IdentificationTag"), trackIdTag); + } + + void executeSparseAnalysisPart(const float& centFT0C, const float& nTrack, const float& nK0s, + const float& nRejectedPiPlus, const float& nRejectedPiMinus, float& nKaon, + const float& nPiPlus, const float& nKaPlus, const float& nProton, const float& nElPlus, const float& nDePlus, + const float& nPiMinus, const float& nKaMinus, const float& nPBar, const float& nElMinus, const float& nDeMinus) + { + nKaon = nKaPlus + nKaMinus; + if (cfgFillSparseFullK0sPiKa) { + recoAnalysis.fill(HIST("recoAnalysis/Sparse_Full_K0sPiKa"), + centFT0C, nTrack, nK0s, + nRejectedPiPlus, nRejectedPiMinus, + nPiPlus, nPiMinus, nKaPlus, nKaMinus); + } + if (cfgFillSparseFullK0sPrDe) { + recoAnalysis.fill(HIST("recoAnalysis/Sparse_Full_K0sPrDe"), + centFT0C, nTrack, nK0s, + nRejectedPiPlus, nRejectedPiMinus, + nProton, nPBar, nDePlus, nDeMinus); + } + if (cfgFillSparseFullK0sKaEl) { + recoAnalysis.fill(HIST("recoAnalysis/Sparse_Full_K0sKaEl"), + centFT0C, nTrack, nK0s, nRejectedPiPlus, nRejectedPiMinus, + nKaPlus, nKaMinus, nElPlus, nElMinus); + } + if (cfgFillSparseFullPiKaPr) { + recoAnalysis.fill(HIST("recoAnalysis/Sparse_Full_PiKaPr"), + centFT0C, nTrack, + nRejectedPiPlus, nRejectedPiMinus, + nPiPlus, nPiMinus, nKaPlus, nKaMinus, nProton, nPBar); + } + if (cfgFillSparseFullPiElDe) { + recoAnalysis.fill(HIST("recoAnalysis/Sparse_Full_PiElDe"), + centFT0C, nTrack, + nRejectedPiPlus, nRejectedPiMinus, + nPiPlus, nPiMinus, nElPlus, nElMinus, nDePlus, nDeMinus); + } + if (cfgFillSparseFullKaPrDe) { + recoAnalysis.fill(HIST("recoAnalysis/Sparse_Full_KaPrDe"), + centFT0C, nTrack, + nRejectedPiPlus, nRejectedPiMinus, + nKaPlus, nKaMinus, nProton, nPBar, nDePlus, nDeMinus); + } + if (cfgFillSparseFullPrElDe) { + recoAnalysis.fill(HIST("recoAnalysis/Sparse_Full_PrElDe"), + centFT0C, nTrack, + nRejectedPiPlus, nRejectedPiMinus, + nProton, nPBar, nElPlus, nElMinus, nDePlus, nDeMinus); + } + if (cfgFillSparsenewDynmK0sKa) { + recoAnalysis.fill(HIST("recoAnalysis/Sparse_newDynm_K0s_Ka"), + centFT0C, nTrack, nK0s, nKaon, + nK0s * nK0s, nKaon * nKaon, nK0s * nKaon); + } + if (cfgFillSparsenewDynmKpKm) { + recoAnalysis.fill(HIST("recoAnalysis/Sparse_newDynm_Kp_Km"), + centFT0C, nTrack, nKaPlus, nKaMinus, + nKaPlus * nKaPlus, nKaMinus * nKaMinus, nKaPlus * nKaMinus); + } + } + + template + void executeEventInfoPart(const C& collision, const float& centrality, const int v0TableSize, const T& tracksTablePerColl, + const int& nTrack, const int& nK0s, + const int& nPiPlus, const int& nKaPlus, const int& nProton, const int& nElPlus, const int& nDePlus, + const int& nPiMinus, const int& nKaMinus, const int& nPBar, const int& nElMinus, const int& nDeMinus) + { + // Collisions QA + recoEvent.fill(HIST("recoEvent/h01_CollisionCount"), 0.5); + recoEvent.fill(HIST("recoEvent/h02_VertexXRec"), collision.posX()); + recoEvent.fill(HIST("recoEvent/h03_VertexYRec"), collision.posY()); + recoEvent.fill(HIST("recoEvent/h04_VertexZRec"), collision.posZ()); + recoEvent.fill(HIST("recoEvent/h05_Centrality"), centrality); + recoEvent.fill(HIST("recoEvent/h06_V0Size"), v0TableSize); + recoEvent.fill(HIST("recoEvent/h07_TracksSize"), tracksTablePerColl.size()); + recoEvent.fill(HIST("recoEvent/h08_nTrack"), nTrack); + recoEvent.fill(HIST("recoEvent/h09_nK0s"), nK0s); + recoEvent.fill(HIST("recoEvent/h10_nPiPlus"), nPiPlus); + recoEvent.fill(HIST("recoEvent/h11_nPiMinus"), nPiMinus); + recoEvent.fill(HIST("recoEvent/h12_nKaPlus"), nKaPlus); + recoEvent.fill(HIST("recoEvent/h13_nKaMinus"), nKaMinus); + recoEvent.fill(HIST("recoEvent/h14_nProton"), nProton); + recoEvent.fill(HIST("recoEvent/h15_nPBar"), nPBar); + recoEvent.fill(HIST("recoEvent/h16_nElPlus"), nElPlus); + recoEvent.fill(HIST("recoEvent/h17_nElMinus"), nElMinus); + recoEvent.fill(HIST("recoEvent/h18_nDePlus"), nDePlus); + recoEvent.fill(HIST("recoEvent/h19_nDeMinus"), nDeMinus); + } + + // Event Filter + Filter eventFilter = (o2::aod::evsel::sel8 == true); + Filter posZFilter = (nabs(o2::aod::collision::posZ) < cutZvertex); + + // Track Filter + Filter ptFilter = (o2::aod::track::pt) > cfgTrackCuts.cfgTrackPtLow && (o2::aod::track::pt) < cfgTrackCuts.cfgTrackPtHigh; + Filter etaFilter = (nabs(o2::aod::track::eta) < cfgTrackCuts.cfgTrackEta); + + // Filters on V0s + Filter preFilterv0 = (nabs(aod::v0data::dcapostopv) > v0settingDcaPosToPV && + nabs(aod::v0data::dcanegtopv) > v0settingDcaNegToPV && + aod::v0data::dcaV0daughters < v0settingDcaV0Dau); + + using MyCollisions = soa::Filtered>; + + using MyTracks = soa::Filtered>; + + using MyV0s = soa::Filtered; + + // For manual sliceBy + Preslice tracksPerCollisionPreslice = o2::aod::track::collisionId; + Preslice v0sPerCollisionPreslice = o2::aod::track::collisionId; + + using MyCollisionsWithMcLabels = soa::Filtered>; + + using MyTracksWithMcLabels = soa::Filtered>; + + using MyV0sWithMcLabels = soa::Filtered>; + + // Declaring vectors outside the process to avoid slight overhead for stack allocation and deallocation during each iteration. + std::vector k0sPosDauList; + std::vector k0sNegDauList; + std::vector k0sFullDauList; + + template + void executeAnalysis(const C& collisions, const V& V0s, const T& tracks) + { + k0sPosDauList.clear(); + k0sNegDauList.clear(); + k0sFullDauList.clear(); + + int posPiIdMethod = kUnidentified; + int posPrIdMethod = kUnidentified; + int negPiIdMethod = kUnidentified; + int negPrIdMethod = kUnidentified; + + bool isK0s = false; + + int v0Tag = 0; + int trueV0TagValue = 0; + int v0DauCollisionIndexTag = 0; + + // Declaring variables outside the loop to avoid slight overhead for stack allocation and deallocation during each iteration. + + float nK0s = 0; + float nPiPlus = 0; + float nPiMinus = 0; + float nKaPlus = 0; + float nKaMinus = 0; + float nProton = 0; + float nPBar = 0; + float nElPlus = 0; + float nElMinus = 0; + float nDePlus = 0; + float nDeMinus = 0; + + float nKaon = 0; + int nTrack = 0; + + float centrality = 0; + + float nRejectedPiPlus = 0; + float nRejectedPiMinus = 0; + int rejectionTag = 0; + + bool trackIsPion = false; + bool trackIsKaon = false; + bool trackIsProton = false; + bool trackIsElectron = false; + bool trackIsDeuteron = false; + + int trackIdTag = 0; + int idMethodPi = kUnidentified; + int idMethodKa = kUnidentified; + int idMethodPr = kUnidentified; + int idMethodEl = kUnidentified; + int idMethodDe = kUnidentified; + + if constexpr (analysisType == doDataProcessing) { + for (const auto& v0 : V0s) { + const auto& posDaughterTrack = v0.template posTrack_as(); + const auto& negDaughterTrack = v0.template negTrack_as(); + + executeV0loop(posDaughterTrack, negDaughterTrack, v0, recoV0s, + posPiIdMethod, posPrIdMethod, negPiIdMethod, negPrIdMethod, + v0Tag, trueV0TagValue, isK0s, v0DauCollisionIndexTag, + k0sPosDauList, k0sNegDauList); + } // End of V0s Loop + + executeSortPairDaughters(k0sPosDauList, k0sNegDauList, k0sFullDauList, recoV0s.get(HIST(HistRegDire[v0TablePostSelectionCut]) + HIST("nCommonPionOfDifferentK0s"))); + + for (const auto& collision : collisions) { + + nK0s = 0; + nPiPlus = 0; + nPiMinus = 0; + nKaPlus = 0; + nKaMinus = 0; + nProton = 0; + nPBar = 0; + nElPlus = 0; + nElMinus = 0; + nDePlus = 0; + nDeMinus = 0; + nTrack = 0; + nKaon = 0; + + centrality = collision.centFT0C(); + if (cfgCentAxis.centAxisType == 1) { + centrality = collision.centFT0M(); + } else if (cfgCentAxis.centAxisType == 2) { + centrality = collision.multFT0M(); + } else if (cfgCentAxis.centAxisType == 3) { + centrality = collision.multFT0C(); + } + + // group tracks, v0s manually + const uint64_t collIdx = collision.globalIndex(); + const auto tracksTablePerColl = tracks.sliceBy(tracksPerCollisionPreslice, collIdx); + const auto v0sTablePerColl = V0s.sliceBy(v0sPerCollisionPreslice, collIdx); + + for (const auto& v0 : v0sTablePerColl) { + const auto& posDaughterTrack = v0.template posTrack_as(); + const auto& negDaughterTrack = v0.template negTrack_as(); + + executeV0InCollisionloop(posDaughterTrack, negDaughterTrack, v0, + posPiIdMethod, posPrIdMethod, negPiIdMethod, negPrIdMethod, + v0Tag, isK0s, v0DauCollisionIndexTag, nK0s, centrality); + + } // End of V0s Loop + + nTrack = 0; + nRejectedPiPlus = 0; + nRejectedPiMinus = 0; + for (const auto& track : tracksTablePerColl) { + bool isAcceptedTrack = true; + executeTrackQAPart(track, k0sFullDauList, rejectionTag, nRejectedPiMinus, nRejectedPiPlus, nTrack, isAcceptedTrack); + if (!isAcceptedTrack) { + continue; + } + + // Do Proper Track Identification + trackIsPion = false; + trackIsKaon = false; + trackIsProton = false; + trackIsElectron = false; + trackIsDeuteron = false; + + trackIdTag = 0; + idMethodPi = kUnidentified; + idMethodKa = kUnidentified; + idMethodPr = kUnidentified; + idMethodEl = kUnidentified; + idMethodDe = kUnidentified; + + if (selPion(track, idMethodPi)) { + trackIsPion = true; + BITSET(trackIdTag, ID_BIT_PI); + } + if (selKaon(track, idMethodKa)) { + trackIsKaon = true; + BITSET(trackIdTag, ID_BIT_KA); + } + if (selProton(track, idMethodPr)) { + trackIsProton = true; + BITSET(trackIdTag, ID_BIT_PR); + } + if (selElectron(track, idMethodEl)) { + trackIsElectron = true; + BITSET(trackIdTag, ID_BIT_EL); + } + if (selDeuteron(track, idMethodDe)) { + trackIsDeuteron = true; + BITSET(trackIdTag, ID_BIT_DE); + } + + executeTrackAnalysisPart(track, trackIdTag, + idMethodPi, trackIsPion, nPiMinus, nPiPlus, + idMethodKa, trackIsKaon, nKaMinus, nKaPlus, + idMethodPr, trackIsProton, nProton, nPBar, + idMethodEl, trackIsElectron, nElPlus, nElMinus, + idMethodDe, trackIsDeuteron, nDePlus, nDeMinus); + } // track loop ends + + executeSparseAnalysisPart(centrality, nTrack, nK0s, + nRejectedPiPlus, nRejectedPiMinus, nKaon, + nPiPlus, nKaPlus, nProton, nElPlus, nDePlus, + nPiMinus, nKaMinus, nPBar, nElMinus, nDeMinus); + + executeEventInfoPart(collision, centrality, v0sTablePerColl.size(), tracksTablePerColl, + nTrack, nK0s, + nPiPlus, nKaPlus, nProton, nElPlus, nDePlus, + nPiMinus, nKaMinus, nPBar, nElMinus, nDeMinus); + } // collision loop ends + } else if constexpr (analysisType == doRecoProcessing || analysisType == doPurityProcessing) { + for (const auto& v0 : V0s) { + const auto& posDaughterTrack = v0.template posTrack_as(); + const auto& negDaughterTrack = v0.template negTrack_as(); + + //__________________________Reco Level ____________________________________________________ + if (!v0.has_mcParticle() || !posDaughterTrack.has_mcParticle() || !negDaughterTrack.has_mcParticle()) { + continue; + } + + auto v0mcparticle = v0.mcParticle(); // if (v0mcparticle.pdgCode() != 310 || !v0mcparticle.isPhysicalPrimary()) + if (!v0mcparticle.isPhysicalPrimary()) + continue; + + if constexpr (analysisType == doPurityProcessing) { + auto posDauMcPart = posDaughterTrack.mcParticle(); + auto negDauMcPart = negDaughterTrack.mcParticle(); + if (v0mcparticle.pdgCode() != kK0Short || posDauMcPart.pdgCode() != kPiPlus || negDauMcPart.pdgCode() != kPiMinus) + continue; + } + + executeV0loop(posDaughterTrack, negDaughterTrack, v0, recoV0s, + posPiIdMethod, posPrIdMethod, negPiIdMethod, negPrIdMethod, + v0Tag, trueV0TagValue, isK0s, v0DauCollisionIndexTag, + k0sPosDauList, k0sNegDauList); + } // End of V0s Loop + executeSortPairDaughters(k0sPosDauList, k0sNegDauList, k0sFullDauList, recoV0s.get(HIST(HistRegDire[v0TablePostSelectionCut]) + HIST("nCommonPionOfDifferentK0s"))); + + for (const auto& collision : collisions) { + if (!collision.has_mcCollision()) { + LOG(warning) << "No MC collision for this collision, skip..."; + continue; + } + + nK0s = 0; + nPiPlus = 0; + nPiMinus = 0; + nKaPlus = 0; + nKaMinus = 0; + nProton = 0; + nPBar = 0; + nElPlus = 0; + nElMinus = 0; + nDePlus = 0; + nDeMinus = 0; + nTrack = 0; + nKaon = 0; + + centrality = collision.centFT0C(); + if (cfgCentAxis.centAxisType == 1) { + centrality = collision.centFT0M(); + } else if (cfgCentAxis.centAxisType == 2) { + centrality = collision.multFT0M(); + } else if (cfgCentAxis.centAxisType == 3) { + centrality = collision.multFT0C(); + } + + // group tracks, v0s manually + const uint64_t collIdx = collision.globalIndex(); + const auto tracksTablePerColl = tracks.sliceBy(tracksPerCollisionPreslice, collIdx); + const auto v0sTablePerColl = V0s.sliceBy(v0sPerCollisionPreslice, collIdx); + + for (const auto& v0 : v0sTablePerColl) { + const auto& posDaughterTrack = v0.template posTrack_as(); + const auto& negDaughterTrack = v0.template negTrack_as(); + + //__________________________Reco Level ____________________________________________________ + if (!v0.has_mcParticle() || !posDaughterTrack.has_mcParticle() || !negDaughterTrack.has_mcParticle()) { + continue; + } + + auto v0mcparticle = v0.mcParticle(); + if (!v0mcparticle.isPhysicalPrimary()) + continue; + + if constexpr (analysisType == doPurityProcessing) { + auto posDauMcPart = posDaughterTrack.mcParticle(); + auto negDauMcPart = negDaughterTrack.mcParticle(); + if (v0mcparticle.pdgCode() != kK0Short || posDauMcPart.pdgCode() != kPiPlus || negDauMcPart.pdgCode() != kPiMinus) + continue; + } + + executeV0InCollisionloop(posDaughterTrack, negDaughterTrack, v0, + posPiIdMethod, posPrIdMethod, negPiIdMethod, negPrIdMethod, + v0Tag, isK0s, v0DauCollisionIndexTag, nK0s, centrality); + } // End of V0s Loop + + nTrack = 0; + nRejectedPiPlus = 0; + nRejectedPiMinus = 0; + for (const auto& track : tracksTablePerColl) { + if (!track.has_mcParticle()) { + LOG(warning) << "No MC Particle for this track, skip..."; + continue; + } + + auto mcPart = track.mcParticle(); + if (!mcPart.isPhysicalPrimary()) { + continue; + } + + bool isAcceptedTrack = true; + executeTrackQAPart(track, k0sFullDauList, rejectionTag, nRejectedPiMinus, nRejectedPiPlus, nTrack, isAcceptedTrack); + if (!isAcceptedTrack) { + continue; + } + + // Do Proper Track Identification + trackIsPion = false; + trackIsKaon = false; + trackIsProton = false; + trackIsElectron = false; + trackIsDeuteron = false; + + trackIdTag = 0; + idMethodPi = kUnidentified; + idMethodKa = kUnidentified; + idMethodPr = kUnidentified; + idMethodEl = kUnidentified; + idMethodDe = kUnidentified; + + if (selPion(track, idMethodPi)) { + trackIsPion = true; + BITSET(trackIdTag, ID_BIT_PI); + } + if (selKaon(track, idMethodKa)) { + trackIsKaon = true; + BITSET(trackIdTag, ID_BIT_KA); + } + if (selProton(track, idMethodPr)) { + trackIsProton = true; + BITSET(trackIdTag, ID_BIT_PR); + } + if (selElectron(track, idMethodEl)) { + trackIsElectron = true; + BITSET(trackIdTag, ID_BIT_EL); + } + if (selDeuteron(track, idMethodDe)) { + trackIsDeuteron = true; + BITSET(trackIdTag, ID_BIT_DE); + } + + if constexpr (analysisType == doPurityProcessing) { + if (trackIsPion) { + if (track.sign() > 0 && mcPart.pdgCode() != kPiPlus) { + trackIsPion = false; + } + if (track.sign() < 0 && mcPart.pdgCode() != kPiMinus) { + trackIsPion = false; + } + } + if (trackIsKaon) { + if (track.sign() > 0 && mcPart.pdgCode() != kKPlus) { + trackIsKaon = false; + } + if (track.sign() < 0 && mcPart.pdgCode() != kKMinus) { + trackIsKaon = false; + } + } + if (trackIsProton) { + if (track.sign() > 0 && mcPart.pdgCode() != kProton) { + trackIsProton = false; + } + if (track.sign() < 0 && mcPart.pdgCode() != kProtonBar) { + trackIsProton = false; + } + } + if (trackIsElectron) { + if (track.sign() > 0 && mcPart.pdgCode() != kPositron) { + trackIsElectron = false; + } + if (track.sign() < 0 && mcPart.pdgCode() != kElectron) { + trackIsElectron = false; + } + } + if (trackIsDeuteron) { + if (track.sign() > 0 && mcPart.pdgCode() != kDeuteron) { + trackIsDeuteron = false; + } + if (track.sign() < 0 && mcPart.pdgCode() != -kDeuteron) { + trackIsDeuteron = false; + } + } + } + + executeTrackAnalysisPart(track, trackIdTag, + idMethodPi, trackIsPion, nPiMinus, nPiPlus, + idMethodKa, trackIsKaon, nKaMinus, nKaPlus, + idMethodPr, trackIsProton, nProton, nPBar, + idMethodEl, trackIsElectron, nElPlus, nElMinus, + idMethodDe, trackIsDeuteron, nDePlus, nDeMinus); + } // track loop ends + + executeSparseAnalysisPart(centrality, nTrack, nK0s, + nRejectedPiPlus, nRejectedPiMinus, nKaon, + nPiPlus, nKaPlus, nProton, nElPlus, nDePlus, + nPiMinus, nKaMinus, nPBar, nElMinus, nDeMinus); + + executeEventInfoPart(collision, centrality, v0sTablePerColl.size(), tracksTablePerColl, + nTrack, nK0s, + nPiPlus, nKaPlus, nProton, nElPlus, nDePlus, + nPiMinus, nKaMinus, nPBar, nElMinus, nDeMinus); + } // collision loop ends + } + } // + + //____________________________________Process Funtion For Analysis Starts Here____________________________________// + + void processData(MyCollisions const& collisions, MyV0s const& V0s, MyTracks const& tracks) + { + recoEvent.fill(HIST("recoEvent/ProcessType"), doDataProcessing); + executeAnalysis(collisions, V0s, tracks); + + } // Process Function Ends + PROCESS_SWITCH(KaonIsospinFluctuations, processData, "Process for Data", true); + + void processReco(MyCollisionsWithMcLabels const& collisions, MyV0sWithMcLabels const& V0s, MyTracksWithMcLabels const& tracks, aod::McParticles const&) + { + recoEvent.fill(HIST("recoEvent/ProcessType"), doRecoProcessing); + executeAnalysis(collisions, V0s, tracks); + + } // Process function is over + PROCESS_SWITCH(KaonIsospinFluctuations, processReco, "Process for Reco", false); + + void processPurity(MyCollisionsWithMcLabels const& collisions, MyV0sWithMcLabels const& V0s, MyTracksWithMcLabels const& tracks, aod::McParticles const&) + { + recoEvent.fill(HIST("recoEvent/ProcessType"), doPurityProcessing); + executeAnalysis(collisions, V0s, tracks); + + } // Process function is over + PROCESS_SWITCH(KaonIsospinFluctuations, processPurity, "Process for Purity", false); + + Preslice mcTracksPerMcCollisionPreslice = o2::aod::mcparticle::mcCollisionId; + + using MyMcCollisions = aod::McCollisions; + void processGen(MyMcCollisions const&, MyCollisionsWithMcLabels const& collisions, aod::McParticles const& mcParticles) + { + recoEvent.fill(HIST("recoEvent/ProcessType"), doGenProcessing); + float centrality = -1; + for (const auto& collision : collisions) { + if (!collision.has_mcCollision()) { + continue; + } + centrality = -1; + const auto& mcColl = collision.mcCollision(); + + centrality = collision.centFT0C(); + if (cfgCentAxis.centAxisType == 1) { + centrality = collision.centFT0M(); + } else if (cfgCentAxis.centAxisType == 2) { + centrality = collision.multFT0M(); + } else if (cfgCentAxis.centAxisType == 3) { + centrality = collision.multFT0C(); + } + + // group over mcParticles + const auto mcTracksTablePerMcColl = mcParticles.sliceBy(mcTracksPerMcCollisionPreslice, mcColl.globalIndex()); + + float nRejectedPiPlus = 0; + float nRejectedPiMinus = 0; + + float nK0s = 0; + float nPiPlus = 0; + float nPiMinus = 0; + float nKaPlus = 0; + float nKaMinus = 0; + float nProton = 0; + float nPBar = 0; + float nElPlus = 0; + float nElMinus = 0; + float nDePlus = 0; + float nDeMinus = 0; + float nTrack = 0; + float nKaon = 0; + + for (const auto& mcTrack : mcTracksTablePerMcColl) { + if (!mcTrack.isPhysicalPrimary()) { + continue; + } + + if (mcTrack.pdgCode() == kK0Short && + k0sSelCut.cfgK0sLowPt < mcTrack.pt() && mcTrack.pt() < k0sSelCut.cfgK0sHighPt && + std::abs(mcTrack.y()) < k0sSelCut.cfgK0sRapitidy) { + nK0s++; + fillGenTrackQA(genAnalysis, mcTrack); + } + + if (mcTrack.pt() <= cfgTrackCuts.cfgTrackPtLow || mcTrack.pt() >= cfgTrackCuts.cfgTrackPtHigh || std::abs(mcTrack.eta()) >= cfgTrackCuts.cfgTrackEta) { + continue; + } + + if (mcTrack.pdgCode() == kPiPlus) { + fillGenTrackQA(genAnalysis, mcTrack); + nPiPlus++; + } else if (mcTrack.pdgCode() == kPiMinus) { + fillGenTrackQA(genAnalysis, mcTrack); + nPiMinus++; + } else if (mcTrack.pdgCode() == kKPlus) { + fillGenTrackQA(genAnalysis, mcTrack); + nKaPlus++; + } else if (mcTrack.pdgCode() == kKMinus) { + fillGenTrackQA(genAnalysis, mcTrack); + nKaMinus++; + } else if (mcTrack.pdgCode() == kProton) { + fillGenTrackQA(genAnalysis, mcTrack); + nProton++; + } else if (mcTrack.pdgCode() == kProtonBar) { + fillGenTrackQA(genAnalysis, mcTrack); + nPBar++; + } else if (mcTrack.pdgCode() == kElectron) { + fillGenTrackQA(genAnalysis, mcTrack); + nElPlus++; + } else if (mcTrack.pdgCode() == kPositron) { + fillGenTrackQA(genAnalysis, mcTrack); + nElMinus++; + } else if (mcTrack.pdgCode() == kDeuteron) { + fillGenTrackQA(genAnalysis, mcTrack); + nDePlus++; + } else if (mcTrack.pdgCode() == -kDeuteron) { + fillGenTrackQA(genAnalysis, mcTrack); + nDeMinus++; + } + + nTrack++; + } // mcTrack loop is over + nKaon = nKaPlus + nKaMinus; + executeSparseAnalysisPart(centrality, nTrack, nK0s, + nRejectedPiPlus, nRejectedPiMinus, nKaon, + nPiPlus, nKaPlus, nProton, nElPlus, nDePlus, + nPiMinus, nKaMinus, nPBar, nElMinus, nDeMinus); + + executeEventInfoPart(mcColl, centrality, 0, mcTracksTablePerMcColl, + nTrack, nK0s, + nPiPlus, nKaPlus, nProton, nElPlus, nDePlus, + nPiMinus, nKaMinus, nPBar, nElMinus, nDeMinus); + } // collision loop is over + } + PROCESS_SWITCH(KaonIsospinFluctuations, processGen, "Process for Gen", false); + + template + void getV0MCount(const T& mcTrack, float& multV0M) + { + if ((-3.7 < mcTrack.eta() && mcTrack.eta() < -1.7) || (2.8 < mcTrack.eta() && mcTrack.eta() < 5.1)) { + if (doFWDPtDependentCheck) { + if (mcTrack.pt() > cfgFWDPtCut) { + multV0M++; // V0C: at -3.7 < η < -1.7 (backward direction). + // V0A: at 2.8 < η < 5.1 (forward direction). + } + } else { + multV0M++; + } + } + } + + void processSim(MyMcCollisions const& mcCollisions, aod::McParticles const& mcParticles) + { + auto finalParticleIdList = (std::vector)cfgFinalParticleIdList; + auto nonFinalParticleIdList = (std::vector)cfgNonFinalParticleIdList; + std::sort(finalParticleIdList.begin(), finalParticleIdList.end()); + std::sort(nonFinalParticleIdList.begin(), nonFinalParticleIdList.end()); + + recoEvent.fill(HIST("recoEvent/ProcessType"), doSimProcessing); + float centrality = -1; + for (const auto& mcColl : mcCollisions) { + centrality = -1; + + if (cfgVtxZCheck) { + if (std::abs(mcColl.posZ()) >= cutZvertex) { + continue; + } + } + // group over mcParticles + const auto mcTracksTablePerMcColl = mcParticles.sliceBy(mcTracksPerMcCollisionPreslice, mcColl.globalIndex()); + + float nRejectedPiPlus = 0; + float nRejectedPiMinus = 0; + float nK0s = 0; + float nPiPlus = 0; + float nPiMinus = 0; + float nKaPlus = 0; + float nKaMinus = 0; + float nProton = 0; + float nPBar = 0; + float nElPlus = 0; + float nElMinus = 0; + float nDePlus = 0; + float nDeMinus = 0; + float nTrack = 0; + float nKaon = 0; + + float multV0M = 0; + + for (const auto& mcTrack : mcTracksTablePerMcColl) { + + if (cfgCountFinalParticles) { + if (!mcTrack.has_daughters() && std::binary_search(finalParticleIdList.begin(), finalParticleIdList.end(), mcTrack.pdgCode())) { + getV0MCount(mcTrack, multV0M); + } + } + if (cfgCountNonFinalParticles) { + if (mcTrack.has_daughters() && std::binary_search(nonFinalParticleIdList.begin(), nonFinalParticleIdList.end(), mcTrack.pdgCode())) { + getV0MCount(mcTrack, multV0M); + } + } + + if (cfgCountPhysicalPrimAndFinalParticles) { + if (!mcTrack.has_daughters() && mcTrack.isPhysicalPrimary()) { + if (!(std::abs(mcTrack.pdgCode()) == kNuE || std::abs(mcTrack.pdgCode()) == kNuMu || std::abs(mcTrack.pdgCode()) == kNuTau)) { + // Removed invisible neutrinos; + getV0MCount(mcTrack, multV0M); + } + } + } + + if (!mcTrack.isPhysicalPrimary()) { + continue; + } + + if (mcTrack.pdgCode() == kK0Short && + k0sSelCut.cfgK0sLowPt < mcTrack.pt() && mcTrack.pt() < k0sSelCut.cfgK0sHighPt && + std::abs(mcTrack.y()) < k0sSelCut.cfgK0sRapitidy) { + nK0s++; + fillGenTrackQA(genAnalysis, mcTrack); + } + + if (mcTrack.pt() <= cfgTrackCuts.cfgTrackPtLow || mcTrack.pt() >= cfgTrackCuts.cfgTrackPtHigh || std::abs(mcTrack.eta()) >= cfgTrackCuts.cfgTrackEta) { + continue; + } + + if (mcTrack.pdgCode() == kPiPlus) { + fillGenTrackQA(genAnalysis, mcTrack); + nPiPlus++; + } else if (mcTrack.pdgCode() == kPiMinus) { + fillGenTrackQA(genAnalysis, mcTrack); + nPiMinus++; + } else if (mcTrack.pdgCode() == kKPlus) { + fillGenTrackQA(genAnalysis, mcTrack); + nKaPlus++; + } else if (mcTrack.pdgCode() == kKMinus) { + fillGenTrackQA(genAnalysis, mcTrack); + nKaMinus++; + } else if (mcTrack.pdgCode() == kProton) { + fillGenTrackQA(genAnalysis, mcTrack); + nProton++; + } else if (mcTrack.pdgCode() == kProtonBar) { + fillGenTrackQA(genAnalysis, mcTrack); + nPBar++; + } else if (mcTrack.pdgCode() == kElectron) { + fillGenTrackQA(genAnalysis, mcTrack); + nElPlus++; + } else if (mcTrack.pdgCode() == kPositron) { + fillGenTrackQA(genAnalysis, mcTrack); + nElMinus++; + } else if (mcTrack.pdgCode() == kDeuteron) { + fillGenTrackQA(genAnalysis, mcTrack); + nDePlus++; + } else if (mcTrack.pdgCode() == -kDeuteron) { + fillGenTrackQA(genAnalysis, mcTrack); + nDeMinus++; + } + + nTrack++; + } // mcTrack loop is over + nKaon = nKaPlus + nKaMinus; + centrality = multV0M; + executeSparseAnalysisPart(centrality, nTrack, nK0s, + nRejectedPiPlus, nRejectedPiMinus, nKaon, + nPiPlus, nKaPlus, nProton, nElPlus, nDePlus, + nPiMinus, nKaMinus, nPBar, nElMinus, nDeMinus); + + executeEventInfoPart(mcColl, centrality, 0, mcTracksTablePerMcColl, + nTrack, nK0s, + nPiPlus, nKaPlus, nProton, nElPlus, nDePlus, + nPiMinus, nKaMinus, nPBar, nElMinus, nDeMinus); + } // collision loop is over + } + PROCESS_SWITCH(KaonIsospinFluctuations, processSim, "Process for Sim", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/EbyEFluctuations/Tasks/meanPtFlucId.cxx b/PWGCF/EbyEFluctuations/Tasks/meanPtFlucId.cxx index 88c1fe856e7..d6eca57ad0e 100644 --- a/PWGCF/EbyEFluctuations/Tasks/meanPtFlucId.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/meanPtFlucId.cxx @@ -16,6 +16,11 @@ /// /// \author Tanu Gahlaut +#include +#include +#include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -30,8 +35,7 @@ #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" #include "Common/Core/RecoDecay.h" - -#include +#include "CCDB/BasicCCDBManager.h" using namespace o2; using namespace o2::framework; @@ -40,99 +44,160 @@ using namespace o2::constants::physics; using namespace std; struct MeanPtFlucId { - Configurable nPtBins{"nPtBins", 300, ""}; - Configurable nPartBins{"nPartBins", 250, ""}; - Configurable nCentBins{"nCentBins", 101, ""}; - Configurable nEtaBins{"nEtaBins", 100, ""}; + Configurable nPBins{"nPBins", 300, ""}; + Configurable nPartBins{"nPartBins", 100, ""}; Configurable nPhiBins{"nPhiBins", 100, ""}; - Configurable cfgCutPtMax{"cfgCutPtMax", 3.0, "maximum pT"}; - Configurable cfgCutPtMin{"cfgCutPtMin", 0.15, "minimum pT"}; + Configurable cfgCutPtMax{"cfgCutPtMax", 2.0, "maximum pT"}; + Configurable cfgCutPtMin{"cfgCutPtMin", 0.2, "minimum pT"}; Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut"}; Configurable cfgCutRap{"cfgCutRap", 0.5, "Rapidity Cut"}; - Configurable cfgCutDcaXY{"cfgCutDcaXY", 0.12, "DCAxy cut"}; - Configurable cfgCutDcaZ{"cfgCutDcaZ", 0.3, "DCAz cut"}; - Configurable cfgCutPosZ{"cfgCutPosZ", 10.0, "cut for vertex Z"}; - Configurable cfgGammaCut{"cfgGammaCut", 0.003, "Gamma inv Mass Cut for electron-positron rejection"}; - Configurable cfgCutNSig2{"cfgCutNSig2", 2.0, "nSigma cut (2)"}; - Configurable cfgCutNSig3{"cfgCutNSig3", 3.0, "nSigma cut (3)"}; + Configurable cfgCutDcaZ{"cfgCutDcaZ", 0.15, "DCAz cut"}; + Configurable cfgCutPosZ{"cfgCutPosZ", 7.0, "cut for vertex Z"}; + Configurable cfgPosZ{"cfgPosZ", true, "Position Z"}; + Configurable cfgCutNSig2{"cfgCutNSig2", 2.0, "nSigma cut: 2"}; + Configurable cfgCutNSig3{"cfgCutNSig3", 3.0, "nSigma cut: 3"}; + Configurable cfgCutNSig5{"cfgCutNSig5", 5.0, "nSigma cut: 5"}; + Configurable cfgSelCutNSigPi{"cfgSelCutNSigPi", 2.0, "nSigma cut for pion selection"}; + Configurable cfgSelCutNSigKa{"cfgSelCutNSigKa", 3.0, "nSigma cut for kaon selection"}; + Configurable cfgSelCutNSigPr{"cfgSelCutNSigPr", 2.0, "nSigma cut for proton selection"}; + Configurable cfgRejCutNSigPi{"cfgRejCutNSigPi", 3.0, "nSigma cut for rejection of other particles while selecting pion"}; Configurable cfgCutPiPtMin{"cfgCutPiPtMin", 0.2, "Minimum pion p_{T} cut"}; Configurable cfgCutKaPtMin{"cfgCutKaPtMin", 0.3, "Minimum kaon p_{T} cut"}; Configurable cfgCutPrPtMin{"cfgCutPrPtMin", 0.5, "Minimum proton p_{T} cut"}; Configurable cfgCutPiThrsldP{"cfgCutPiThrsldP", 0.6, "Threshold p cut pion"}; Configurable cfgCutKaThrsldP{"cfgCutKaThrsldP", 0.6, "Threshold p cut kaon"}; Configurable cfgCutPrThrsldP{"cfgCutPrThrsldP", 1.0, "Threshold p cut proton "}; - Configurable cfgCutPiP1{"cfgCutPiP1", 0.5, "pion p cut-1"}; - Configurable cfgCutPiP2{"cfgCutPiP2", 0.6, "pion p cut-2"}; - Configurable cfgCutKaP1{"cfgCutKaP1", 0.4, "kaon p cut-1"}; - Configurable cfgCutKaP2{"cfgCutKaP2", 0.6, "kaon p cut-2"}; - Configurable cfgCutKaP3{"cfgCutKaP3", 1.2, "kaon p cut-3"}; - Configurable cfgCutPrP1{"cfgCutPrP1", 0.9, "proton p cut-1"}; - Configurable cfgCutPrP2{"cfgCutPrP2", 1.0, "proton p cut-2"}; - Configurable cfgMcTpcShiftEl{"cfgMcTpcShiftEl", 0., "Electron Shift in TPC (MC data) "}; - Configurable cfgMcTpcShiftPi{"cfgMcTpcShiftPi", 0., "Pion Shift in TPC (MC data) "}; - Configurable cfgMcTpcShiftKa{"cfgMcTpcShiftKa", 0., "Kaon Shift in TPC (MC data) "}; - Configurable cfgMcTpcShiftPr{"cfgMcTpcShiftPr", 0., "Proton Shift in TPC (MC data) "}; - Configurable cfgMcTofShiftPi{"cfgMcTofShiftPi", 0., "Pion Shift in TOF (MC data) "}; - Configurable cfgMcTofShiftKa{"cfgMcTofShiftKa", 0., "Kaon Shift in TOF (MC data) "}; - Configurable cfgMcTofShiftPr{"cfgMcTofShiftPr", 0., "Proton Shift in TOF (MC data) "}; - Configurable cfgPidCut{"cfgPidCut", false, ""}; - Configurable cfgPDGCodeOnly{"cfgPDGCodeOnly", true, ""}; - Configurable cfgMCReco{"cfgMCReco", false, ""}; - Configurable cfgMCTruth{"cfgMCTruth", false, ""}; - Configurable cfgPosZ{"cfgPosZ", true, "Position Z"}; Configurable cfgSel8{"cfgSel8", true, "Sel8 trigger"}; - Configurable cfgEvSel1{"cfgEvSel1", true, "kNoSameBunchPileup"}; - Configurable cfgEvSel2{"cfgEvSel2", true, "kIsGoodZvtxFT0vsPV"}; - Configurable cfgEvSel3{"cfgEvSel3", true, "kIsVertexITSTPC"}; + Configurable cfgMinWeight{"cfgMinWeight", 1e-6, "Minimum weight for efficiency correction"}; + Configurable cfgNoSameBunchPileup{"cfgNoSameBunchPileup", true, "kNoSameBunchPileup"}; + Configurable cfgIsVertexITSTPC{"cfgIsVertexITSTPC", true, "kIsVertexITSTPC"}; Configurable cfgRejTrk{"cfgRejTrk", true, "Rejected Tracks"}; - Configurable cfgInvMass{"cfgInvMass", true, "electron Inv Mass cut selection"}; - Configurable cfgSelOR{"cfgSelOR", true, "Low OR High momentum "}; - Configurable cfgSelAND{"cfgSelAND", false, "Low AND High momentum"}; - Configurable cfgSelLow{"cfgSelLow", true, "PID selection cut for Low momentum"}; - Configurable cfgSelHigh{"cfgSelHigh", true, "PID selection cut for High momentum"}; + Configurable cfgLoadEff{"cfgLoadEff", true, "Load efficiency"}; + Configurable cfgCorrection{"cfgCorrection", true, "Correction"}; + Configurable cfgWeightPtCh{"cfgWeightPtCh", true, "Efficiency correction (pT) for charged particles"}; + Configurable cfgWeightPtId{"cfgWeightPtId", false, "Efficiency correction (pT) "}; + Configurable cfgWeightPtEtaId{"cfgWeightPtEtaId", false, "Efficiency correction (pT) "}; + Configurable cfgPurityId{"cfgPurityId", false, "Purity correction"}; ConfigurableAxis multTPCBins{"multTPCBins", {150, 0, 150}, "TPC Multiplicity bins"}; - ConfigurableAxis multFT0MBins{"multFT0MBins", {400, 0, 4000}, "Forward Multiplicity bins"}; - ConfigurableAxis multFT0MMCBins{"multFT0MMCBins", {250, 0, 250}, "Forward Multiplicity bins"}; - ConfigurableAxis dcaXYBins{"dcaXYBins", {100, -0.15, 0.15}, "dcaXY bins"}; - ConfigurableAxis dcaZBins{"dcaZBins", {100, -1.2, 1.2}, "dcaZ bins"}; + ConfigurableAxis multFT0MBins{"multFT0MBins", {1000, 0, 5000}, "Forward Multiplicity bins"}; ConfigurableAxis qNBins{"qNBins", {1000, 0., 100.}, "nth moments bins"}; - ConfigurableAxis tpNBins{"tpNBins", {300, 0., 3000.}, ""}; - ConfigurableAxis tpDBins{"tpDBins", {100, 0., 2000.}, ""}; + ConfigurableAxis nPairBins{"nPairBins", {2000, 0, 10000}, "nPair bins"}; + ConfigurableAxis dcaXYBins{"dcaXYBins", {100, -0.15, 0.15}, "dcaXY bins"}; + ConfigurableAxis dcaZBins{"dcaZBins", {500, -1.2, 1.2}, "dcaZ bins"}; - using MyAllTracks = soa::Join; - using MyCollisions = soa::Join; - using MyMCCollisions = soa::Join; - using MyMCTracks = soa::Join; + Configurable> ptBins{"ptBins", {0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.05, 1.10, 1.15, 1.20, 1.25, 1.30, 1.35, 1.40, 1.45, 1.50, 1.55, 1.60, 1.65, 1.70, 1.75, 1.80, 1.85, 1.90, 1.95, 2.00}, "p_{T} bins"}; + Configurable> etaBins{"etaBins", {-0.8, -0.75, -0.7, -0.65, -0.6, -0.55, -0.5, -0.45, -0.4, -0.35, -0.3, -0.25, -0.2, -0.15, -0.1, -0.05, 0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8}, "#eta bins"}; + + Configurable cfgUrlCCDB{"cfgUrlCCDB", "http://ccdb-test.cern.ch:8080", "url of ccdb"}; + Configurable cfgPathCCDB{"cfgPathCCDB", "Users/t/tgahlaut/weightCorr/", "Path for ccdb-object"}; + Service ccdb; Service pdg; HistogramRegistry hist{"hist", {}, OutputObjHandlingPolicy::AnalysisObject}; + + TH1D* hWeightPt = nullptr; + TH1D* hPurePt = nullptr; + TH1D* hWeightPtPi = nullptr; + TH1D* hWeightPtKa = nullptr; + TH1D* hWeightPtPr = nullptr; + TH1D* hPurePtPi = nullptr; + TH1D* hPurePtKa = nullptr; + TH1D* hPurePtPr = nullptr; + + enum CollisionLabels { + kTotCol = 1, + kPassSelCol + }; + + enum TrackLabels { + kTracksBeforeHasMcParticle = 1, + kAllTracks, + kAllSelPassed + }; + + enum SelCollisionLabels { + kBeforeSelCol = 1, + kSelColPosZ, + kSelColSel8, + kSelColNoSameBunchPileup, + kSelColIsVertexITSTPC, + }; + + enum class PIDType { + kNone, + kPions, + kKaons, + kProtons + }; + + enum Mode { + QA_Charged = 0, + QA_Pion, + QA_Kaon, + QA_Proton, + Analysis_Charged, + Analysis_Pion, + Analysis_Kaon, + Analysis_Proton, + Gen_Charged, + Gen_Pion, + Gen_Kaon, + Gen_Proton + }; + + static constexpr std::string_view Dire[] = { + "QA/after/", + "QA/Pion/", + "QA/Kaon/", + "QA/Proton/", + "Analysis/Charged/", + "Analysis/Pion/", + "Analysis/Kaon/", + "Analysis/Proton/", + "Gen/Charged/", + "Gen/Pion/", + "Gen/Kaon/", + "Gen/Proton/"}; + void init(InitContext const&) { - const AxisSpec axisEvents{6, 0, 6, "Counts"}; - const AxisSpec axisEta{nEtaBins, -1., +1., "#eta"}; + if (cfgLoadEff) { + // Set CCDB url + ccdb->setURL(cfgUrlCCDB.value); + ccdb->setCaching(true); + + TList* lst = ccdb->getForTimeStamp(cfgPathCCDB.value, -1); + hWeightPt = reinterpret_cast(lst->FindObject("hWeightPt")); + hWeightPtPi = reinterpret_cast(lst->FindObject("hWeightPtPi")); + hWeightPtKa = reinterpret_cast(lst->FindObject("hWeightPtKa")); + hWeightPtPr = reinterpret_cast(lst->FindObject("hWeightPtPr")); + hPurePtPi = reinterpret_cast(lst->FindObject("hPurePtPi")); + hPurePtKa = reinterpret_cast(lst->FindObject("hPurePtKa")); + hPurePtPr = reinterpret_cast(lst->FindObject("hPurePtPr")); + + if (!hWeightPt || !hWeightPtPi || !hWeightPtKa || !hWeightPtPr || !hPurePtPi || !hPurePtKa || !hPurePtPr) { + LOGF(info, "FATAL!! Could not find required histograms in CCDB"); + } + } + + const AxisSpec axisCol{3, 1, 4, ""}; + const AxisSpec axisTrack{5, 1, 6, ""}; + const AxisSpec axisEvents{10, 1, 11, "Counts"}; + const AxisSpec axisEta{etaBins, "#eta"}; const AxisSpec axisPhi{nPhiBins, 0., +7., "#phi (rad)"}; - const AxisSpec axisY{nEtaBins, -1., +1., "y"}; - const AxisSpec axisPt{nPtBins, 0., 3., "p_{T} (GeV/c)"}; - const AxisSpec axisP{nPtBins, 0., 3., "p (GeV/c)"}; - const AxisSpec axisInnerParam{nPtBins, 0., 3., "p_{InnerParam } (GeV/c)"}; + const AxisSpec axisY{100, -0.6, 0.6, "y"}; + const AxisSpec axisPt{ptBins, "p_{T} (GeV/c)"}; + const AxisSpec axisP{nPBins, 0., 3., "p (GeV/c)"}; + const AxisSpec axisInnerParam{nPBins, 0., 3., "p_{InnerParam } (GeV/c)"}; const AxisSpec axisPart{nPartBins, 0., 18., " "}; const AxisSpec axisQn{qNBins, ""}; - const AxisSpec axisTpN{tpNBins, "(Q_{1}^{2} - Q_{2})"}; - const AxisSpec axisTpD{tpDBins, "N_{pairs}"}; - const AxisSpec axisDeno{100, 1., 2.0, "#frac{1}{#sqrt{1 - #frac{1}{N}}}"}; + const AxisSpec axisNpair{nPairBins, "N_{pairs}"}; const AxisSpec axisMeanPt{100, 0., 3., "M(p_{T}) (GeV/c)"}; const AxisSpec axisMult{100, 0, 100, "N_{ch}"}; const AxisSpec axisMultTPC{multTPCBins, "N_{TPC} "}; const AxisSpec axisMultFT0M{multFT0MBins, "N_{FT0M}"}; - const AxisSpec axisMultFT0MMC{multFT0MMCBins, "N_{FT0M}"}; - const AxisSpec axisCentFT0C{nCentBins, 0, 101, "FT0C (%)"}; + const AxisSpec axisCentFT0M{101, 0, 101, "FT0M (%)"}; const AxisSpec axisVtxZ{80, -20., 20., "V_{Z} (cm)"}; const AxisSpec axisDCAz{dcaZBins, "DCA_{Z} (cm)"}; const AxisSpec axisDCAxy{dcaXYBins, "DCA_{XY} (cm)"}; @@ -143,238 +208,203 @@ struct MeanPtFlucId { const AxisSpec axisChi2{40, 0., 40., "Chi2"}; const AxisSpec axisCrossedTPC{300, 0, 300, "Crossed TPC"}; const AxisSpec axisM2{100, 0., 1.4, "#it{m}^{2} (GeV/#it{c}^{2})^{2}"}; - const AxisSpec axisMass{1000, 0., 0.1, "M_{inv} (GeV/#it{c}^2)"}; - - HistogramConfigSpec qNHist({HistType::kTHnSparseD, {axisMultTPC, axisQn, axisMultFT0M}}); - HistogramConfigSpec partHist({HistType::kTHnSparseD, {axisMultTPC, axisPart, axisMultFT0M}}); - HistogramConfigSpec denoHist({HistType::kTHnSparseD, {axisMultTPC, axisDeno, axisMultFT0M}}); - HistogramConfigSpec qNMCHist({HistType::kTHnSparseD, {axisMultTPC, axisQn, axisMultFT0MMC}}); - HistogramConfigSpec partMCHist({HistType::kTHnSparseD, {axisMultTPC, axisPart, axisMultFT0MMC}}); - HistogramConfigSpec denoMCHist({HistType::kTHnSparseD, {axisMultTPC, axisDeno, axisMultFT0MMC}}); + const AxisSpec axisPid{300, 0, 3000, "PID"}; + + HistogramConfigSpec qNHist({HistType::kTHnSparseD, {axisCentFT0M, axisQn}}); + HistogramConfigSpec partHist({HistType::kTHnSparseD, {axisCentFT0M, axisPart}}); + HistogramConfigSpec qNMCHist({HistType::kTHnSparseD, {axisCentFT0M, axisQn}}); + HistogramConfigSpec partMCHist({HistType::kTHnSparseD, {axisCentFT0M, axisPart}}); HistogramConfigSpec tofNSigmaHist({HistType::kTH2D, {axisP, axisTOFNsigma}}); HistogramConfigSpec tofSignalHist({HistType::kTH2D, {axisP, axisTOFSignal}}); HistogramConfigSpec tpcNSigmaHist({HistType::kTH2D, {axisP, axisTPCNsigma}}); HistogramConfigSpec tpcSignalHist({HistType::kTH2D, {axisP, axisTPCSignal}}); HistogramConfigSpec tpcTofHist({HistType::kTH2D, {axisTPCNsigma, axisTOFNsigma}}); HistogramConfigSpec pvsM2Hist({HistType::kTH2D, {axisM2, axisP}}); - - HistogramConfigSpec tofNSigmaHist1({HistType::kTH2D, {axisInnerParam, axisTOFNsigma}}); - HistogramConfigSpec tofSignalHist1({HistType::kTH2D, {axisInnerParam, axisTOFSignal}}); - HistogramConfigSpec tpcNSigmaHist1({HistType::kTH2D, {axisInnerParam, axisTPCNsigma}}); HistogramConfigSpec tpcSignalHist1({HistType::kTH2D, {axisInnerParam, axisTPCSignal}}); - HistogramConfigSpec tpcTofHist1({HistType::kTH2D, {axisTPCNsigma, axisTOFNsigma}}); HistogramConfigSpec pvsM2Hist1({HistType::kTH2D, {axisM2, axisInnerParam}}); - // QA Plots: + // QA Plots hist.add("QA/before/h_Counts", "Counts", kTH1D, {axisEvents}); hist.add("QA/before/h_VtxZ", "V_{Z}", kTH1D, {axisVtxZ}); - hist.add("QA/before/h_TPCChi2perCluster", "TPC #Chi^{2}/Cluster", kTH1D, {axisChi2}); - hist.add("QA/before/h_ITSChi2perCluster", "ITS #Chi^{2}/Cluster", kTH1D, {axisChi2}); - hist.add("QA/before/h_crossedTPC", "Crossed TPC", kTH1D, {axisCrossedTPC}); - hist.add("QA/before/h_Pt", "p_{T}", kTH1D, {axisPt}); - hist.add("QA/before/h2_PvsPinner", "p_{InnerParam} vs p", kTH2D, {{axisP}, {axisInnerParam}}); - hist.add("QA/before/h2_PtofvsPinner", "p_{InnerParam} vs p_{TOF}", kTH2D, {{axisP}, {axisInnerParam}}); - hist.add("QA/before/h_Eta", "#eta ", kTH1D, {axisEta}); - hist.add("QA/before/h_Phi", "#phi ", kTH1D, {axisPhi}); - hist.add("QA/before/h2_Pt_Eta", "p_{T} vs #eta ", kTH2D, {{axisEta}, {axisPt}}); - hist.add("QA/before/h_DcaZ", "DCA_{Z}", kTH1D, {axisDCAz}); - hist.add("QA/before/h_DcaXY", "DCA_{XY}", kTH1D, {axisDCAxy}); - hist.add("QA/before/h2_DcaZ", "DCA_{Z}", kTH2D, {{axisPt}, {axisDCAz}}); - hist.add("QA/before/h2_DcaXY", "DCA_{XY}", kTH2D, {{axisPt}, {axisDCAxy}}); hist.add("QA/before/h_NTPC", "N_{TPC}", kTH1D, {axisMultTPC}); hist.add("QA/before/h_NFT0M", "FT0M Multiplicity", kTH1D, {axisMultFT0M}); - hist.add("QA/before/h_NFT0C", "FT0C Multiplicity", kTH1D, {axisMultFT0M}); - hist.add("QA/before/h_Cent", "FT0C (%)", kTH1D, {axisCentFT0C}); - hist.add("QA/before/h2_NTPC_Cent", "N_{TPC} vs FT0C(%)", kTH2D, {{axisCentFT0C}, {axisMultTPC}}); - hist.add("QA/before/h2_NTPC_NFT0M", "N_{TPC} vs N_{FT0M}", kTH2D, {{axisMultFT0M}, {axisMultTPC}}); - hist.add("QA/before/h2_NTPC_NFT0C", "N_{TPC} vs N_{FT0C}", kTH2D, {{axisMultFT0M}, {axisMultTPC}}); + hist.add("QA/before/h_CentM", "FT0M (%)", kTH1D, {axisCentFT0M}); hist.add("QA/before/h2_TPCSignal", "TPC Signal", tpcSignalHist); hist.add("QA/before/h2_TOFSignal", "TOF Signal", tofSignalHist); hist.add("QA/before/h2_pvsm2", "p vs m^{2}", pvsM2Hist); - hist.add("QA/before/innerParam/h2_TPCSignal", "TPC Signal", tpcSignalHist1); - hist.add("QA/before/innerParam/h2_TOFSignal", "TOF Signal", tofSignalHist1); - hist.add("QA/before/innerParam/h2_pvsm2", "p vs m^{2}", pvsM2Hist1); - hist.addClone("QA/before/", "QA/after/"); + hist.add("QA/before/h_Pt", "p_{T}", kTH1D, {axisPt}); + hist.add("QA/before/h_Eta", "#eta ", kTH1D, {axisEta}); + hist.add("QA/before/h_Phi", "#phi ", kTH1D, {axisPhi}); + hist.add("QA/before/h_DcaZ", "DCA_{Z}", kTH1D, {axisDCAz}); + hist.add("QA/before/h_DcaXY", "DCA_{XY}", kTH1D, {axisDCAxy}); + hist.add("QA/before/h2_DcaZ", "DCA_{Z}", kTH2D, {{axisPt}, {axisDCAz}}); + hist.add("QA/before/h2_DcaXY", "DCA_{XY}", kTH2D, {{axisPt}, {axisDCAxy}}); + + hist.add("QA/after/h_counts_evSelCuts", "Event selection cuts", kTH1D, {axisEvents}); + hist.add("QA/after/h_TPCChi2perCluster", "TPC #Chi^{2}/Cluster", kTH1D, {axisChi2}); + hist.add("QA/after/h_ITSChi2perCluster", "ITS #Chi^{2}/Cluster", kTH1D, {axisChi2}); + hist.add("QA/after/h_crossedTPC", "Crossed TPC", kTH1D, {axisCrossedTPC}); + hist.add("QA/after/h2_NTPC_CentM", "N_{TPC} vs FT0M(%)", kTH2D, {{axisCentFT0M}, {axisMultTPC}}); + hist.add("QA/after/h2_NTPC_NFT0M", "N_{TPC} vs N_{FT0M}", kTH2D, {{axisMultFT0M}, {axisMultTPC}}); hist.add("QA/after/p_NTPC_NFT0M", "N_{TPC} vs N_{FT0M} (Profile)", kTProfile, {axisMultFT0M}); - hist.add("QA/after/p_NTPC_NFT0C", "N_{TPC} vs N_{FT0C} (Profile)", kTProfile, {axisMultFT0M}); - hist.add("QA/after/p_NTPC_Cent", "N_{TPC} vs FT0C(%) (Profile)", kTProfile, {axisCentFT0C}); - hist.add("QA/after/h2_NTPC_NCh", "N_{ch} vs N_{TPC}", kTH2D, {{axisMultTPC}, {axisMult}}); - hist.add("QA/after/h_invMass_gamma", "Inv Mass of #gamma", kTH1D, {axisMass}); - hist.add("QA/after/counts_evSelCuts", "Event selection cuts", kTH1D, {axisEvents}); - hist.add("QA/after/h_vtxZSim", "Simulated Vertex Z", kTH1D, {axisVtxZ}); - hist.add("QA/after/h_NSim", "Truth Multiplicity TPC", kTH1D, {axisMultTPC}); - hist.add("QA/after/h2_NTPC_NSim", "Reco vs Truth Multiplicty TPC", kTH2D, {{axisMultTPC}, {axisMultTPC}}); - hist.add("QA/after/h2_NChSim_NSim", "Truth Multiplicty NCh vs NTPC", kTH2D, {{axisMultTPC}, {axisMultTPC}}); - hist.add("QA/after/h2_NFT0C_NFT0CSim", "Reco vs Truth Multplicity FT0C", kTH2D, {{axisMultFT0MMC}, {axisMultFT0M}}); - - hist.add("QA/Pion/h_Pt", "p_{T} ", kTH1D, {axisPt}); - hist.add("QA/Pion/h_PtPos", "p_{T} (positive) ", kTH1D, {axisPt}); - hist.add("QA/Pion/h_PtNeg", "p_{T} (negative) ", kTH1D, {axisPt}); - hist.add("QA/Pion/h_PtTruth", "p_{T} ", kTH1D, {axisPt}); - hist.add("QA/Pion/h_PtPosTruth", "p_{T} (positive) ", kTH1D, {axisPt}); - hist.add("QA/Pion/h_PtNegTruth", "p_{T} (negative) ", kTH1D, {axisPt}); - hist.add("QA/Pion/h_rap", "y ", kTH1D, {axisY}); - hist.add("QA/Pion/h_Eta", "Pseudorapidity ", kTH1D, {axisEta}); - hist.add("QA/Pion/h_Phi", "Azimuthal Distribution ", kTH1D, {axisPhi}); - hist.add("QA/Pion/h2_Pt_rap", "p_{T} vs y", kTH2D, {{axisY}, {axisPt}}); - hist.add("QA/Pion/h_DcaZ", "DCA_{z}", kTH1D, {axisDCAz}); - hist.add("QA/Pion/h_DcaXY", "DCA_{xy}", kTH1D, {axisDCAxy}); - hist.add("QA/Pion/h2_DcaZ", "DCA_{z}", kTH2D, {{axisPt}, {axisDCAz}}); - hist.add("QA/Pion/h2_DcaXY", "DCA_{xy}", kTH2D, {{axisPt}, {axisDCAxy}}); - hist.add("QA/Pion/h2_P_Pinner", "p_{TPCinner} vs p", kTH2D, {{axisP}, {axisInnerParam}}); - hist.add("QA/Pion/h2_Pt_Pinner", "p_{TPCinner} vs p_{T}", kTH2D, {{axisPt}, {axisInnerParam}}); + hist.add("QA/after/p_NTPC_CentM", "N_{TPC} vs FT0M(%) (Profile)", kTProfile, {axisCentFT0M}); + hist.add("QA/after/h_DCAxy_primary", "DCA_{XY} (Primary)", kTH1D, {axisDCAxy}); + hist.add("QA/after/h_DCAz_primary", "DCA_{Z} (Primary)", kTH1D, {axisDCAz}); + hist.add("QA/after/h_DCAxy_secondary", "DCA_{XY} (Secondary)", kTH1D, {axisDCAxy}); + hist.add("QA/after/h_DCAz_secondary", "DCA_{Z} (Secondary)", kTH1D, {axisDCAz}); + hist.add("QA/after/innerParam/h2_TPCSignal", "TPC Signal", tpcSignalHist1); + + hist.add("QA/Charged/h_Pt", "p_{T}", kTH1D, {axisPt}); + hist.add("QA/Charged/h_Eta", "#eta ", kTH1D, {axisEta}); + hist.add("QA/Charged/h_Phi", "#phi ", kTH1D, {axisPhi}); + hist.add("QA/Charged/h_DcaZ", "DCA_{Z}", kTH1D, {axisDCAz}); + hist.add("QA/Charged/h_DcaXY", "DCA_{XY}", kTH1D, {axisDCAxy}); + hist.add("QA/Charged/h2_DcaZ", "DCA_{Z}", kTH2D, {{axisPt}, {axisDCAz}}); + hist.add("QA/Charged/h2_DcaXY", "DCA_{XY}", kTH2D, {{axisPt}, {axisDCAxy}}); + hist.add("QA/Charged/h_Pt_weighted", "weighted pT distribution", kTH1D, {axisPt}); + hist.add("QA/Charged/h2_Pt_Eta", "p_{T} vs #eta ", kTH2D, {{axisEta}, {axisPt}}); + hist.add("QA/Charged/h2_Pt_centFT0M", "p_{T} in centrality Classes ", kTH2D, {{axisCentFT0M}, {axisPt}}); + hist.add("QA/Charged/h3_PtEtaPhi", "p_{T}, #eta, #phi ", kTHnSparseD, {{axisPt}, {axisEta}, {axisPhi}}); + + hist.addClone("QA/Charged/", "QA/Pion/"); hist.add("QA/Pion/before/h2_TPCNsigma", "n #sigma_{TPC}", tpcNSigmaHist); + hist.add("QA/Pion/before/h2_TPCNsigma_tof", "n #sigma_{TPC}", tpcNSigmaHist); hist.add("QA/Pion/before/h2_TOFNsigma", "n #sigma_{TOF}", tofNSigmaHist); hist.add("QA/Pion/before/h2_TpcTofNsigma", "n #sigma_{TPC} vs n #sigma_{TOF}", tpcTofHist); + + hist.add("QA/Pion/h_Rap", "y ", kTH1D, {axisY}); + hist.add("QA/Pion/h_PtPos", "p_{T} (positive) ", kTH1D, {axisPt}); + hist.add("QA/Pion/h_PtNeg", "p_{T} (negative) ", kTH1D, {axisPt}); + hist.add("QA/Pion/h_PtTruth", "p_{T} (Truth)", kTH1D, {axisPt}); + hist.add("QA/Pion/h_PtPosTruth", "p_{T} (positive) (Truth)", kTH1D, {axisPt}); + hist.add("QA/Pion/h_PtNegTruth", "p_{T} (negative) (Truth) ", kTH1D, {axisPt}); hist.add("QA/Pion/h2_TPCNsigma", "n #sigma_{TPC}", tpcNSigmaHist); - hist.add("QA/Pion/h2_TPCNsigma_El", "n #sigma_{TPC, El}", tpcNSigmaHist); - hist.add("QA/Pion/h2_TOFNsigma_El", "n #sigma_{TOF, El}", tofNSigmaHist); hist.add("QA/Pion/h2_TOFNsigma", "n #sigma_{TOF}", tofNSigmaHist); hist.add("QA/Pion/h2_TpcTofNsigma", "n #sigma_{TPC} vs n #sigma_{TOF}", tpcTofHist); hist.add("QA/Pion/h2_TPCSignal", "TPC Signal ", tpcSignalHist); hist.add("QA/Pion/h2_TOFSignal", "TOF Signal", tofSignalHist); + hist.add("QA/Pion/innerParam/h2_TPCSignal", "TPC Signal", tpcSignalHist1); hist.add("QA/Pion/h2_pvsm2", "p vs m^{2}", pvsM2Hist); - - hist.add("QA/Pion/innerParam/before/h2_TPCNsigma", "n #sigma_{TPC}", tpcNSigmaHist1); - hist.add("QA/Pion/innerParam/before/h2_TOFNsigma", "n #sigma_{TOF}", tofNSigmaHist1); - hist.add("QA/Pion/innerParam/before/h2_TpcTofNsigma", "n #sigma_{TPC} vs n #sigma_{TOF}", tpcTofHist1); - hist.add("QA/Pion/innerParam/h2_TPCNsigma", "n #sigma_{TPC}", tpcNSigmaHist1); - hist.add("QA/Pion/innerParam/h2_TPCNsigma_El", "n #sigma_{TPC, El}", tpcNSigmaHist1); - hist.add("QA/Pion/innerParam/h2_TOFNsigma_El", "n #sigma_{TOF, El}", tofNSigmaHist1); - hist.add("QA/Pion/innerParam/h2_TOFNsigma", "n #sigma_{TOF}", tofNSigmaHist1); - hist.add("QA/Pion/innerParam/h2_TpcTofNsigma", "n #sigma_{TPC} vs n #sigma_{TOF}", tpcTofHist1); - hist.add("QA/Pion/innerParam/h2_TPCSignal", "TPC Signal ", tpcSignalHist1); - hist.add("QA/Pion/innerParam/h2_TOFSignal", "TOF Signal", tofSignalHist1); - hist.add("QA/Pion/innerParam/h2_pvsm2", "p vs m^{2}", pvsM2Hist1); - + hist.add("QA/Pion/h_PtTruth_primary", "p_{T} (Truth Primary)", kTH1D, {axisPt}); + hist.add("QA/Pion/h_PtTruth_secondary", "p_{T} (Truth Secondary)", kTH1D, {axisPt}); hist.addClone("QA/Pion/", "QA/Kaon/"); hist.addClone("QA/Pion/", "QA/Proton/"); - // Analysis Plots: + // AnalysisPlots hist.add("Analysis/Charged/h_Mult", "Multiplicity", kTH1D, {axisMult}); - hist.add("Analysis/Charged/h_Q1", "Q1", qNHist); - hist.add("Analysis/Charged/h_Q2", "Q2", qNHist); - hist.add("Analysis/Charged/h_Q3", "Q3", qNHist); - hist.add("Analysis/Charged/h_Q4", "Q4", qNHist); - hist.add("Analysis/Charged/h_mean_pT", " ", kTH1D, {axisMeanPt}); - hist.add("Analysis/Charged/p_mean_pT_Mult_var", " ", kTProfile, {axisMultTPC}); - hist.add("Analysis/Charged/p_CheckNCh", " 1/denominator vs N_{TPC} ", kTProfile, {axisMultTPC}); - hist.add("Analysis/Charged/h_CheckNCh", " 1/denominator vs N_{TPC} ", denoHist); - hist.add("Analysis/Charged/h_Q1_var", "Q1 vs N_{TPC}", qNHist); - hist.add("Analysis/Charged/h_N_var", "N vs N_{TPC}", kTHnSparseD, {axisMultTPC, axisMult, axisMultFT0M}); - hist.add("Analysis/Charged/h_twopart_nume_Mult_var", "twopart numerator", kTHnSparseD, {axisMultTPC, axisTpN, axisMultFT0M}); - hist.add("Analysis/Charged/h_twopart_deno_Mult_var", "twopart denominator", kTHnSparseD, {axisMultTPC, axisTpD, axisMultFT0M}); + hist.add("Analysis/Charged/h_N_CentFT0M", "Multiplicity vs CentFT0M", kTHnSparseD, {axisCentFT0M, axisMult}); + hist.add("Analysis/Charged/h_Npair_CentFT0M", "Npair vs CentFT0M", kTHnSparseD, {axisCentFT0M, axisNpair}); + hist.add("Analysis/Charged/h_Q1_CentFT0M", "Q1 vs CentFT0M", qNHist); + hist.add("Analysis/Charged/h_Q2_CentFT0M", "Q2 vs CentFT0M", qNHist); + hist.add("Analysis/Charged/h_twopart1_CentFT0M", "twopart (neum)", qNMCHist); hist.add("Analysis/Charged/h_mean_pT_Mult_var", " vs N_{TPC} ", partHist); - hist.add("Analysis/Charged/h_mean_pT_Mult_skew", " vs N_{TPC} ", partHist); - hist.add("Analysis/Charged/h_mean_pT_Mult_kurto", " vs N_{TPC} ", partHist); hist.add("Analysis/Charged/h_twopart_Mult_var", "Twopart vs N_{TPC} ", partHist); - hist.add("Analysis/Charged/h_twopart_Mult_skew", "Twopart vs N_{TPC} ", partHist); - hist.add("Analysis/Charged/h_twopart_Mult_kurto", "Twopart vs N_{TPC} ", partHist); - hist.add("Analysis/Charged/h_threepart_Mult_skew", "Threepart vs N_{TPC} ", partHist); - hist.add("Analysis/Charged/h_threepart_Mult_kurto", "Threepart vs N_{TPC} ", partHist); - hist.add("Analysis/Charged/h_fourpart_Mult_kurto", "Fourpart vs N_{TPC} ", partHist); + hist.add("Analysis/Charged/p_twopart_CentFT0M", "Twopart vs cent_{FT0M} ", kTProfile, {axisCentFT0M}); + hist.add("Analysis/Charged/p_mean_pT_CentFT0M", " vs cent_{FT0M} ", kTProfile, {axisCentFT0M}); hist.addClone("Analysis/Charged/", "Analysis/Pion/"); hist.addClone("Analysis/Charged/", "Analysis/Kaon/"); hist.addClone("Analysis/Charged/", "Analysis/Proton/"); // MC Generated - hist.add("Gen/Counts", "Counts", kTH1D, {axisEvents}); - hist.add("Gen/vtxZ", "Vertex Z ", kTH1D, {axisVtxZ}); - hist.add("Gen/NTPC", "Mid rapidity Multiplicity", kTH1D, {axisMultTPC}); - hist.add("Gen/NFT0C", "Forward Multiplicity", kTH1D, {axisMultFT0MMC}); - hist.add("Gen/h2_NTPC_NFT0C", "N_{TPC} vs N_{FT0C}", kTH2D, {{axisMultFT0MMC}, {axisMultTPC}}); + hist.add("Gen/h_Counts", "Counts", kTH1D, {axisEvents}); + hist.add("Gen/h_VtxZ", "Vertex Z ", kTH1D, {axisVtxZ}); + hist.add("Gen/h_VtxZ_b", "Vertex Z ", kTH1D, {axisVtxZ}); + hist.add("Gen/h_NSim", "Truth Multiplicity TPC", kTH1D, {axisMultTPC}); + hist.add("Gen/h2_NTPC_NSim", "Reco vs Truth Multiplicty TPC", kTH2D, {{axisMultTPC}, {axisMultTPC}}); + + hist.add("Gen/Charged/h_EtaTruth", "#eta ", kTH1D, {axisEta}); + hist.add("Gen/Charged/h_PhiTruth", "#phi ", kTH1D, {axisPhi}); hist.add("Gen/Charged/h_PtTruth", "p_{T} ", kTH1D, {axisPt}); - hist.add("Gen/Charged/h_PtPosTruth", "p_{T} (Positive)", kTH1D, {axisPt}); - hist.add("Gen/Charged/h_PtNegTruth", "p_{T} (negative)", kTH1D, {axisPt}); + hist.add("Gen/Charged/h2_Pt_EtaTruth", "p_{T} vs #eta", kTH2D, {{axisEta}, {axisPt}}); + hist.add("Gen/Charged/h2_PtTruth_centFT0M", "p_{T} in centrality Classes ", kTH2D, {{axisCentFT0M}, {axisPt}}); + hist.add("Gen/Charged/h_PtEtaPhiTruth", "p_{T}, #eta, #phi ", kTHnSparseD, {{axisPt}, {axisEta}, {axisPhi}}); hist.add("Gen/Charged/h_Mult", "Multiplicity", kTH1D, {axisMult}); - hist.add("Gen/Charged/h_mean_pT", " ", kTH1D, {axisMeanPt}); - - hist.add("Gen/Charged/h_Q1", "Q1", qNMCHist); - hist.add("Gen/Charged/h_Q2", "Q2", qNMCHist); - hist.add("Gen/Charged/h_Q3", "Q3", qNMCHist); - hist.add("Gen/Charged/h_Q4", "Q4", qNMCHist); - hist.add("Gen/Charged/h_Q1_var", "Q1 vs N_{TPC}", qNMCHist); - hist.add("Gen/Charged/h_N_var", "N vs N_{TPC}", kTHnSparseD, {axisMultTPC, axisMult, axisMultFT0MMC}); - hist.add("Gen/Charged/h_twopart_nume_Mult_var", "twopart numerator", kTHnSparseD, {axisMultTPC, axisTpN, axisMultFT0MMC}); - hist.add("Gen/Charged/h_twopart_deno_Mult_var", "twopart denominator", kTHnSparseD, {axisMultTPC, axisTpD, axisMultFT0MMC}); - - hist.add("Gen/Charged/p_mean_pT_Mult_var", " ", kTProfile, {axisMultTPC}); - hist.add("Gen/Charged/p_CheckNCh", " 1/denominator vs N_{TPC} ", kTProfile, {axisMultTPC}); - hist.add("Gen/Charged/h_CheckNCh", " 1/denominator vs N_{TPC} ", denoMCHist); + hist.add("Gen/Charged/h_N_CentFT0M", "Multiplicity vs CentFT0M", kTHnSparseD, {axisCentFT0M, axisMult}); + hist.add("Gen/Charged/h_Npair_CentFT0M", "Npair vs CentFT0M", kTHnSparseD, {axisCentFT0M, axisNpair}); + hist.add("Gen/Charged/h_Q1_CentFT0M", "Q1", qNMCHist); + hist.add("Gen/Charged/h_Q2_CentFT0M", "Q2", qNMCHist); + hist.add("Gen/Charged/h_twopart1_CentFT0M", "twopart (neum)", qNMCHist); hist.add("Gen/Charged/h_mean_pT_Mult_var", " vs N_{TPC} ", partMCHist); - hist.add("Gen/Charged/h_mean_pT_Mult_skew", " vs N_{TPC} ", partMCHist); - hist.add("Gen/Charged/h_mean_pT_Mult_kurto", " vs N_{TPC} ", partMCHist); hist.add("Gen/Charged/h_twopart_Mult_var", "Twopart vs N_{TPC} ", partMCHist); - hist.add("Gen/Charged/h_twopart_Mult_skew", "Twopart vs N_{TPC} ", partMCHist); - hist.add("Gen/Charged/h_twopart_Mult_kurto", "Twopart vs N_{TPC} ", partMCHist); - hist.add("Gen/Charged/h_threepart_Mult_skew", "Threepart vs N_{TPC} ", partMCHist); - hist.add("Gen/Charged/h_threepart_Mult_kurto", "Threepart vs N_{TPC} ", partMCHist); - hist.add("Gen/Charged/h_fourpart_Mult_kurto", "Fourpart vs N_{TPC} ", partMCHist); + hist.add("Gen/Charged/p_twopart_CentFT0M", "Twopart vs CentFT0M ", kTProfile, {axisCentFT0M}); + hist.add("Gen/Charged/p_mean_pT_CentFT0M", " vs CentFT0M ", kTProfile, {axisCentFT0M}); hist.addClone("Gen/Charged/", "Gen/Pion/"); - hist.addClone("Gen/Charged/", "Gen/Kaon/"); - hist.addClone("Gen/Charged/", "Gen/Proton/"); - } - enum Mode { - QA_Pion = 0, - QA_Kaon, - QA_Proton, - Analysis_Charged, - Analysis_Pion, - Analysis_Kaon, - Analysis_Proton, - Gen_Charged, - Gen_Pion, - Gen_Kaon, - Gen_Proton - }; + hist.add("Gen/Pion/h_RapTruth", "y", kTH1D, {axisY}); + hist.add("Gen/Pion/h_PtPosTruth", "p_{T} (positive) ", kTH1D, {axisPt}); + hist.add("Gen/Pion/h_PtNegTruth", "p_{T} (negative) ", kTH1D, {axisPt}); + + hist.addClone("Gen/Pion/", "Gen/Kaon/"); + hist.addClone("Gen/Pion/", "Gen/Proton/"); + + hist.add("QA/h_collisions_info", "Collisions info", kTH1D, {axisCol}); + hist.add("Gen/h_collisions_info", "Collisions info", kTH1D, {axisCol}); + hist.add("Gen/h_collision_recgen", "Number of Collisions ", kTH1D, {axisCol}); + hist.add("Gen/h2_collision_posZ", "Reco vs truth posZ ", kTH2D, {{axisVtxZ}, {axisVtxZ}}); + hist.add("Tracks/h_tracks_info", "Track info", kTH1D, {axisTrack}); + hist.add("Tracks/h2_tracks_pid_before_sel", "Track pid info before selection", kTH2D, {{axisPid}, {axisPt}}); + + hist.get(HIST("QA/h_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kTotCol, "kTotCol"); + hist.get(HIST("QA/h_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kPassSelCol, "kPassSelCol"); + hist.get(HIST("Gen/h_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kTotCol, "kTotCol"); + hist.get(HIST("Gen/h_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kPassSelCol, "kPassSelCol"); + hist.get(HIST("Tracks/h_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kTracksBeforeHasMcParticle, "kTracksBeforeHasMcParticle"); + hist.get(HIST("Tracks/h_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kAllTracks, "kAllTracks"); + hist.get(HIST("Tracks/h_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kAllSelPassed, "kAllSelPassed"); + hist.get(HIST("QA/after/h_counts_evSelCuts"))->GetXaxis()->SetBinLabel(SelCollisionLabels::kBeforeSelCol, "kBeforeSelCol"); + hist.get(HIST("QA/after/h_counts_evSelCuts"))->GetXaxis()->SetBinLabel(SelCollisionLabels::kSelColPosZ, "kSelColPosZ"); + hist.get(HIST("QA/after/h_counts_evSelCuts"))->GetXaxis()->SetBinLabel(SelCollisionLabels::kSelColSel8, "kSelColSel8"); + hist.get(HIST("QA/after/h_counts_evSelCuts"))->GetXaxis()->SetBinLabel(SelCollisionLabels::kSelColNoSameBunchPileup, "kSelColNoSameBunchPileup"); + hist.get(HIST("QA/after/h_counts_evSelCuts"))->GetXaxis()->SetBinLabel(SelCollisionLabels::kSelColIsVertexITSTPC, "kSelColIsVertexITSTPC"); + } - static constexpr std::string_view Dire[] = { - "QA/Pion/", - "QA/Kaon/", - "QA/Proton/", - "Analysis/Charged/", - "Analysis/Pion/", - "Analysis/Kaon/", - "Analysis/Proton/", - "Gen/Charged/", - "Gen/Pion/", - "Gen/Kaon/", - "Gen/Proton/"}; + float centFT0M = 0.; + int nTPC = 0, nFT0M = 0; // Event selection cuts: template bool selRun3Col(T const& col) { - hist.fill(HIST("QA/after/counts_evSelCuts"), 0); + hist.fill(HIST("QA/after/h_counts_evSelCuts"), kBeforeSelCol); - if (cfgPosZ && std::abs(col.posZ()) > cfgCutPosZ) - return false; - hist.fill(HIST("QA/after/counts_evSelCuts"), 1); - - if (cfgSel8 && !col.sel8()) - return false; - hist.fill(HIST("QA/after/counts_evSelCuts"), 2); + if (cfgPosZ) { + if (std::abs(col.posZ()) > cfgCutPosZ) { + return false; + } + hist.fill(HIST("QA/after/h_counts_evSelCuts"), kSelColPosZ); + } - if (cfgEvSel1 && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) - return false; - hist.fill(HIST("QA/after/counts_evSelCuts"), 3); + centFT0M = col.centFT0M(); + nTPC = col.multNTracksHasTPC(); + nFT0M = col.multFT0M(); - if (cfgEvSel2 && !col.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) - return false; - hist.fill(HIST("QA/after/counts_evSelCuts"), 4); + if (cfgSel8) { + if (!col.sel8()) { + return false; + } + hist.fill(HIST("QA/after/h_counts_evSelCuts"), kSelColSel8); + } + if (cfgNoSameBunchPileup) { + if (!col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + hist.fill(HIST("QA/after/h_counts_evSelCuts"), kSelColNoSameBunchPileup); + } - if (cfgEvSel3 && !col.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) - return false; - hist.fill(HIST("QA/after/counts_evSelCuts"), 5); + if (cfgIsVertexITSTPC) { + if (!col.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + hist.fill(HIST("QA/after/h_counts_evSelCuts"), kSelColIsVertexITSTPC); + } return true; } @@ -383,13 +413,13 @@ struct MeanPtFlucId { template bool selTrack(T const& track) { - if (!track.isGlobalTrackWoPtEta()) + if (!track.isGlobalTrack()) return false; if (track.pt() < cfgCutPtMin) return false; - if (track.pt() > cfgCutPtMax) + if (track.pt() >= cfgCutPtMax) return false; if (track.sign() == 0) @@ -398,7 +428,10 @@ struct MeanPtFlucId { if (std::fabs(track.dcaZ()) > cfgCutDcaZ) return false; - if (std::fabs(track.dcaXY()) > cfgCutDcaXY) + if (std::fabs(track.dcaZ()) > (0.0105 + 0.035 / std::pow(track.p(), 1.1))) + return false; + + if (std::abs(track.eta()) >= cfgCutEta) return false; return true; @@ -408,139 +441,90 @@ struct MeanPtFlucId { template bool rejectTracks(T const& track) { - if (((track.tpcNSigmaEl() - cfgMcTpcShiftEl) > -3. && - (track.tpcNSigmaEl() - cfgMcTpcShiftEl) < 5.) && - (std::fabs(track.tpcNSigmaPi() - cfgMcTpcShiftPi) > 3 && - std::fabs(track.tpcNSigmaKa() - cfgMcTpcShiftKa) > 3 && - std::fabs(track.tpcNSigmaPr() - cfgMcTpcShiftPr) > 3)) { + if (((track.tpcNSigmaEl()) > -cfgCutNSig3 && + (track.tpcNSigmaEl()) < cfgCutNSig5) && + (std::fabs(track.tpcNSigmaPi()) > cfgCutNSig3 && + std::fabs(track.tpcNSigmaKa()) > cfgCutNSig3 && + std::fabs(track.tpcNSigmaPr()) > cfgCutNSig3)) { return true; } return false; } - template - bool selElectrons(T const& track) + template + bool identifyParticle(T const& track, float momThreshold) { - if (std::fabs(track.tpcNSigmaEl() - cfgMcTpcShiftEl) < cfgCutNSig3) { - return true; - } - - return false; - } - // PID selction cuts for Low momentum Pions - template - bool selLowPi(T const& track, double p) - { - if (track.pt() >= cfgCutPiPtMin && - track.p() <= cfgCutPiThrsldP && - ((!track.hasTOF() && - ((std::fabs(track.tpcNSigmaPi() - cfgMcTpcShiftPi) < cfgCutNSig3 && p <= cfgCutPiP1) || - (std::fabs(track.tpcNSigmaPi() - cfgMcTpcShiftPi) < cfgCutNSig2 && p > cfgCutPiP1 && p <= cfgCutPiP2))) || - (track.hasTOF() && - std::fabs(track.tpcNSigmaPi() - cfgMcTpcShiftPi) < cfgCutNSig3 && - std::fabs(track.tofNSigmaPi() - cfgMcTofShiftPi) < cfgCutNSig3))) { - - if (std::abs(track.rapidity(MassPiPlus)) < cfgCutRap) { - return true; - } + const int sp = static_cast(s1); + const int sq = static_cast(s2); + const int sr = static_cast(s3); + std::vector vTpcNSigma = {-999., track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; + std::vector vTofNSigma = {-999., track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()}; + bool isTofPidFlag = false, isTpcPidFlag = false; + + float nSigmaSelCut = 0.; + float nSigmaTofRejCut = 0.; + float nSigmaTpcRejCut = 0.; + if constexpr (s1 == PIDType::kProtons) { + nSigmaSelCut = cfgSelCutNSigPr; + nSigmaTofRejCut = std::fabs(vTofNSigma[sp]); + nSigmaTpcRejCut = std::fabs(vTpcNSigma[sp]); + } else if constexpr (s1 == PIDType::kKaons) { + nSigmaSelCut = cfgSelCutNSigKa; + nSigmaTofRejCut = std::fabs(vTofNSigma[sp]); + nSigmaTpcRejCut = std::fabs(vTpcNSigma[sp]); + } else if constexpr (s1 == PIDType::kPions) { + nSigmaSelCut = cfgSelCutNSigPi; + nSigmaTofRejCut = cfgRejCutNSigPi; + nSigmaTpcRejCut = cfgRejCutNSigPi; } - return false; - } - // PID selction cuts for Low momentum Kaons - template - bool selLowKa(T const& track, double p) - { - if (track.pt() >= cfgCutKaPtMin && - track.p() <= cfgCutKaThrsldP && - ((!track.hasTOF() && - ((std::fabs(track.tpcNSigmaKa() - cfgMcTpcShiftKa) < cfgCutNSig3 && p <= cfgCutKaP1) || - (std::fabs(track.tpcNSigmaKa() - cfgMcTpcShiftKa) < cfgCutNSig2 && p > cfgCutKaP1 && p <= cfgCutKaP2))) || - (track.hasTOF() && - std::fabs(track.tpcNSigmaKa() - cfgMcTpcShiftKa) < cfgCutNSig3 && - std::fabs(track.tofNSigmaKa() - cfgMcTofShiftKa) < cfgCutNSig3))) { - - if (std::abs(track.rapidity(MassKPlus)) < cfgCutRap) { - return true; + if (track.hasTOF()) { + if (std::fabs(vTofNSigma[sp]) < nSigmaSelCut && + std::fabs(vTofNSigma[sq]) > nSigmaTofRejCut && + std::fabs(vTofNSigma[sr]) > nSigmaTofRejCut) { + isTofPidFlag = true; } - } - - return false; - } - - // PID selction cuts for Low momentum Protons - template - bool selLowPr(T const& track, double p) - { - if (track.pt() >= cfgCutPrPtMin && - track.p() <= cfgCutPrThrsldP && - ((!track.hasTOF() && - ((std::fabs(track.tpcNSigmaPr() - cfgMcTpcShiftPr) < cfgCutNSig3 && p <= cfgCutPrP1) || - (std::fabs(track.tpcNSigmaPr() - cfgMcTpcShiftPr) < cfgCutNSig2 && p > cfgCutPrP1 && p <= cfgCutPrP2))) || - (track.hasTOF() && - std::fabs(track.tpcNSigmaPr() - cfgMcTpcShiftPr) < cfgCutNSig3 && - std::fabs(track.tofNSigmaPr() - cfgMcTofShiftPr) < cfgCutNSig3))) { - - if (std::abs(track.rapidity(MassProton)) < cfgCutRap) { - return true; + if (std::fabs(vTpcNSigma[sp]) < cfgCutNSig2) { + isTpcPidFlag = true; } - } - - return false; - } - - // PID selction cuts for High momentum Protons - template - bool selHighPi(T const& track) - { - if (track.hasTOF() && - track.p() > cfgCutPiThrsldP && - std::fabs(track.tpcNSigmaPi() - cfgMcTpcShiftPi) < cfgCutNSig3 && - std::fabs(track.tofNSigmaPi() - cfgMcTofShiftPi) < cfgCutNSig3) { - - if (std::abs(track.rapidity(MassPiPlus)) < cfgCutRap) { - return true; + } else { // select from TPC Only + if (track.p() >= momThreshold) { + return false; + } + if (std::fabs(vTpcNSigma[sp]) < nSigmaSelCut && + std::fabs(vTpcNSigma[sq]) > nSigmaTpcRejCut && + std::fabs(vTpcNSigma[sr]) > nSigmaTpcRejCut) { + isTofPidFlag = true; + isTpcPidFlag = true; } } - return false; - } - - // PID selction cuts for High momentum Kaons - template - bool selHighKa(T const& track) - { - if (track.hasTOF() && - track.p() > cfgCutKaThrsldP && - std::fabs(track.tpcNSigmaKa() - cfgMcTpcShiftKa) < cfgCutNSig3 && - ((std::fabs(track.tofNSigmaKa() - cfgMcTofShiftKa) < cfgCutNSig3 && track.p() <= cfgCutKaP3) || - (std::fabs(track.tofNSigmaKa() - cfgMcTofShiftKa) < cfgCutNSig2 && track.p() > cfgCutKaP3))) { - - if (std::abs(track.rapidity(MassKPlus)) < cfgCutRap) { - return true; - } + if (isTofPidFlag && isTpcPidFlag) { + return true; // Track is identified as one of the particles } - return false; + return false; // Track is not identified as any of the particles } - // PID selction cuts for High momentum Protons - template - bool selHighPr(T const& track) + // Get corrected weight for the track: + template + float getCorrectedWeight(T1 hWeightPt, T1 hPurePt, float pt, bool cfgWeightPt, bool cfgPurity) { - if (track.hasTOF() && - track.p() > cfgCutPrThrsldP && - std::fabs(track.tpcNSigmaPr() - cfgMcTpcShiftPr) < cfgCutNSig3 && - std::fabs(track.tofNSigmaPr() - cfgMcTofShiftPr) < cfgCutNSig3) { + float weight = 1.0; + float purity = 1.0; - if (std::abs(track.rapidity(MassProton)) < cfgCutRap) { - return true; - } + if (cfgPurity) { + purity = hPurePt->GetBinContent(hPurePt->FindBin(pt)); } - return false; + if (cfgWeightPt) { + float weightPt = hWeightPt->GetBinContent(hWeightPt->FindBin(pt)); + weight = purity * weightPt; + } + + return weight; } // Fill hist before selection cuts: @@ -551,83 +535,50 @@ struct MeanPtFlucId { hist.fill(HIST("QA/before/h_Eta"), track.eta()); hist.fill(HIST("QA/before/h_Phi"), track.phi()); hist.fill(HIST("QA/before/h_Pt"), track.pt()); - hist.fill(HIST("QA/before/h2_PvsPinner"), track.p(), track.tpcInnerParam()); - hist.fill(HIST("QA/before/h2_Pt_Eta"), track.eta(), track.pt()); - hist.fill(HIST("QA/before/h_TPCChi2perCluster"), track.tpcChi2NCl()); - hist.fill(HIST("QA/before/h_ITSChi2perCluster"), track.itsChi2NCl()); - hist.fill(HIST("QA/before/h_crossedTPC"), track.tpcNClsCrossedRows()); hist.fill(HIST("QA/before/h_DcaXY"), track.dcaXY()); hist.fill(HIST("QA/before/h_DcaZ"), track.dcaZ()); hist.fill(HIST("QA/before/h2_DcaXY"), track.pt(), track.dcaXY()); hist.fill(HIST("QA/before/h2_DcaZ"), track.pt(), track.dcaZ()); - - if (track.hasTOF()) - hist.fill(HIST("QA/before/h2_PtofvsPinner"), track.p(), track.tpcInnerParam()); } hist.fill(HIST("QA/before/h_VtxZ"), col.posZ()); hist.fill(HIST("QA/before/h_Counts"), 2); - - int nTPC = col.multNTracksHasTPC(); - int nFT0M = col.multFT0M(); - int nFT0C = col.multFT0C(); - double centFT0C = col.centFT0C(); - - if (nTPC != 0 && nFT0M != 0) { - hist.fill(HIST("QA/before/h_NTPC"), nTPC); - hist.fill(HIST("QA/before/h_Cent"), centFT0C); - hist.fill(HIST("QA/before/h_NFT0M"), nFT0M); - hist.fill(HIST("QA/before/h_NFT0C"), nFT0M); - hist.fill(HIST("QA/before/h2_NTPC_NFT0M"), nFT0M, nTPC); - hist.fill(HIST("QA/before/h2_NTPC_NFT0C"), nFT0C, nTPC); - hist.fill(HIST("QA/before/h2_NTPC_Cent"), centFT0C, nTPC); - } + hist.fill(HIST("QA/before/h_NTPC"), col.multNTracksHasTPC()); + hist.fill(HIST("QA/before/h_CentM"), col.centFT0M()); + hist.fill(HIST("QA/before/h_NFT0M"), col.multFT0M()); } // Fill hist after selection cuts: template void fillAfterQAHistos(T const& col) { - int nTPC = col.multNTracksHasTPC(); - int nFT0M = col.multFT0M(); - int nFT0C = col.multFT0C(); - double centFT0C = col.centFT0C(); - hist.fill(HIST("QA/after/h_VtxZ"), col.posZ()); hist.fill(HIST("QA/after/h_Counts"), 2); - if (nTPC != 0 && nFT0M != 0) { - hist.fill(HIST("QA/after/h_NTPC"), nTPC); - hist.fill(HIST("QA/after/h_Cent"), centFT0C); - hist.fill(HIST("QA/after/h_NFT0M"), nFT0M); - hist.fill(HIST("QA/after/h_NFT0C"), nFT0C); - hist.fill(HIST("QA/after/h2_NTPC_NFT0M"), nFT0M, nTPC); - hist.fill(HIST("QA/after/h2_NTPC_NFT0C"), nFT0C, nTPC); - hist.fill(HIST("QA/after/h2_NTPC_Cent"), centFT0C, nTPC); - hist.fill(HIST("QA/after/p_NTPC_Cent"), centFT0C, nTPC); - hist.fill(HIST("QA/after/p_NTPC_NFT0M"), nFT0M, nTPC); - hist.fill(HIST("QA/after/p_NTPC_NFT0C"), nFT0C, nTPC); - } + hist.fill(HIST("QA/after/h_NTPC"), nTPC); + hist.fill(HIST("QA/after/h_CentM"), centFT0M); + hist.fill(HIST("QA/after/h_NFT0M"), nFT0M); + hist.fill(HIST("QA/after/h2_NTPC_NFT0M"), nFT0M, nTPC); + hist.fill(HIST("QA/after/h2_NTPC_CentM"), centFT0M, nTPC); + hist.fill(HIST("QA/after/p_NTPC_CentM"), centFT0M, nTPC); + hist.fill(HIST("QA/after/p_NTPC_NFT0M"), nFT0M, nTPC); } // Fill Charged particles QA: template - void fillChargedQAHistos(T const& track) + void fillChargedQAHistos(T const& track, float centFT0M) { - hist.fill(HIST("QA/after/h_Eta"), track.eta()); - hist.fill(HIST("QA/after/h_Phi"), track.phi()); - hist.fill(HIST("QA/after/h_Pt"), track.pt()); - hist.fill(HIST("QA/after/h2_PvsPinner"), track.p(), track.tpcInnerParam()); - hist.fill(HIST("QA/after/h2_Pt_Eta"), track.eta(), track.pt()); - hist.fill(HIST("QA/after/h_DcaZ"), track.dcaZ()); - hist.fill(HIST("QA/after/h_DcaXY"), track.dcaXY()); - hist.fill(HIST("QA/after/h2_DcaXY"), track.pt(), track.dcaXY()); - hist.fill(HIST("QA/after/h2_DcaZ"), track.pt(), track.dcaZ()); + hist.fill(HIST("QA/Charged/h_Eta"), track.eta()); + hist.fill(HIST("QA/Charged/h_Phi"), track.phi()); + hist.fill(HIST("QA/Charged/h2_Pt_centFT0M"), centFT0M, track.pt()); + hist.fill(HIST("QA/Charged/h3_PtEtaPhi"), track.pt(), track.eta(), track.phi()); + hist.fill(HIST("QA/Charged/h2_Pt_Eta"), track.eta(), track.pt()); + hist.fill(HIST("QA/Charged/h_DcaZ"), track.dcaZ()); + hist.fill(HIST("QA/Charged/h_DcaXY"), track.dcaXY()); + hist.fill(HIST("QA/Charged/h2_DcaXY"), track.pt(), track.dcaXY()); + hist.fill(HIST("QA/Charged/h2_DcaZ"), track.pt(), track.dcaZ()); hist.fill(HIST("QA/after/h_TPCChi2perCluster"), track.tpcChi2NCl()); hist.fill(HIST("QA/after/h_ITSChi2perCluster"), track.itsChi2NCl()); hist.fill(HIST("QA/after/h_crossedTPC"), track.tpcNClsCrossedRows()); - - if (track.hasTOF()) - hist.fill(HIST("QA/after/h2_PtofvsPinner"), track.p(), track.tpcInnerParam()); } // Fill before PID cut QA hist: @@ -638,95 +589,96 @@ struct MeanPtFlucId { hist.fill(HIST("QA/before/h2_TPCSignal"), track.p(), track.tpcSignal()); hist.fill(HIST("QA/before/h2_pvsm2"), track.mass() * track.mass(), track.p()); - hist.fill(HIST("QA/Pion/before/h2_TPCNsigma"), track.p(), track.tpcNSigmaPi()); + if (!track.hasTOF()) + hist.fill(HIST("QA/Pion/before/h2_TPCNsigma"), track.p(), track.tpcNSigmaPi()); + if (track.hasTOF()) + hist.fill(HIST("QA/Pion/before/h2_TPCNsigma_tof"), track.p(), track.tpcNSigmaPi()); hist.fill(HIST("QA/Pion/before/h2_TOFNsigma"), track.p(), track.tofNSigmaPi()); hist.fill(HIST("QA/Pion/before/h2_TpcTofNsigma"), track.tpcNSigmaPi(), track.tofNSigmaPi()); - hist.fill(HIST("QA/Proton/before/h2_TPCNsigma"), track.p(), track.tpcNSigmaPr()); + if (!track.hasTOF()) + hist.fill(HIST("QA/Proton/before/h2_TPCNsigma"), track.p(), track.tpcNSigmaPr()); + if (track.hasTOF()) + hist.fill(HIST("QA/Proton/before/h2_TPCNsigma_tof"), track.p(), track.tpcNSigmaPr()); hist.fill(HIST("QA/Proton/before/h2_TOFNsigma"), track.p(), track.tofNSigmaPr()); hist.fill(HIST("QA/Proton/before/h2_TpcTofNsigma"), track.tpcNSigmaPr(), track.tofNSigmaPr()); - hist.fill(HIST("QA/Kaon/before/h2_TPCNsigma"), track.p(), track.tpcNSigmaKa()); + if (!track.hasTOF()) + hist.fill(HIST("QA/Kaon/before/h2_TPCNsigma"), track.p(), track.tpcNSigmaKa()); + if (track.hasTOF()) + hist.fill(HIST("QA/Kaon/before/h2_TPCNsigma_tof"), track.p(), track.tpcNSigmaKa()); hist.fill(HIST("QA/Kaon/before/h2_TOFNsigma"), track.p(), track.tofNSigmaKa()); hist.fill(HIST("QA/Kaon/before/h2_TpcTofNsigma"), track.tpcNSigmaKa(), track.tofNSigmaKa()); - - hist.fill(HIST("QA/before/innerParam/h2_TOFSignal"), track.tpcInnerParam(), track.beta()); - hist.fill(HIST("QA/before/innerParam/h2_TPCSignal"), track.tpcInnerParam(), track.tpcSignal()); - hist.fill(HIST("QA/before/innerParam/h2_pvsm2"), track.mass() * track.mass(), track.tpcInnerParam()); - - hist.fill(HIST("QA/Pion/innerParam/before/h2_TPCNsigma"), track.tpcInnerParam(), track.tpcNSigmaPi()); - hist.fill(HIST("QA/Pion/innerParam/before/h2_TOFNsigma"), track.tpcInnerParam(), track.tofNSigmaPi()); - hist.fill(HIST("QA/Pion/innerParam/before/h2_TpcTofNsigma"), track.tpcNSigmaPi(), track.tofNSigmaPi()); - hist.fill(HIST("QA/Proton/innerParam/before/h2_TPCNsigma"), track.tpcInnerParam(), track.tpcNSigmaPr()); - hist.fill(HIST("QA/Proton/innerParam/before/h2_TOFNsigma"), track.tpcInnerParam(), track.tofNSigmaPr()); - hist.fill(HIST("QA/Proton/innerParam/before/h2_TpcTofNsigma"), track.tpcNSigmaPr(), track.tofNSigmaPr()); - hist.fill(HIST("QA/Kaon/innerParam/before/h2_TPCNsigma"), track.tpcInnerParam(), track.tpcNSigmaKa()); - hist.fill(HIST("QA/Kaon/innerParam/before/h2_TOFNsigma"), track.tpcInnerParam(), track.tofNSigmaKa()); - hist.fill(HIST("QA/Kaon/innerParam/before/h2_TpcTofNsigma"), track.tpcNSigmaKa(), track.tofNSigmaKa()); } // Moments Calculation: - void moments(double pt, double& Q1, double& Q2, double& Q3, double& Q4) + void moments(float pt, float weight, double& Q1, double& Q2) { - Q1 += pt; - Q2 += pt * pt; - Q3 += pt * pt * pt; - Q4 += pt * pt * pt * pt; + Q1 += pt * weight; + Q2 += pt * pt * weight * weight; } - // Fill after PID cut QA hist: - template - void fillIdParticleQAHistos(T const& track, double rap, double nSigmaTPC, double nSigmaTOF, int& N, double& Q1, double& Q2, double& Q3, double& Q4) + template + void fillIdParticleQAHistos(T const& track, float rap, float nSigmaTPC, float nSigmaTOF, float centFT0M, T1 hWeightPt, T1 hPurePt, bool cfgWeightPtId, bool cfgPurityId, double& NW, double& NW2, double& Q1, double& Q2) { - N++; - double pt = track.pt(); - moments(pt, Q1, Q2, Q3, Q4); + float pt = track.pt(); + float eta = track.eta(); + float phi = track.phi(); + float weight = getCorrectedWeight(hWeightPt, hPurePt, pt, cfgWeightPtId, cfgPurityId); + + if (std::abs(weight) < cfgMinWeight) + return; - hist.fill(HIST(Dire[Mode]) + HIST("h_Pt"), track.pt()); - if (track.sign() > 0) - hist.fill(HIST(Dire[Mode]) + HIST("h_PtPos"), track.pt()); + NW += weight; + NW2 += weight * weight; + moments(pt, weight, Q1, Q2); - if (track.sign() < 0) - hist.fill(HIST(Dire[Mode]) + HIST("h_PtNeg"), track.pt()); + if (track.sign() > 0) { + hist.fill(HIST(Dire[Mode]) + HIST("h_PtPos"), pt); + } + if (track.sign() < 0) { + hist.fill(HIST(Dire[Mode]) + HIST("h_PtNeg"), pt); + } - hist.fill(HIST(Dire[Mode]) + HIST("h_Eta"), track.eta()); - hist.fill(HIST(Dire[Mode]) + HIST("h_Phi"), track.phi()); - hist.fill(HIST(Dire[Mode]) + HIST("h_rap"), rap); - hist.fill(HIST(Dire[Mode]) + HIST("h2_Pt_rap"), rap, track.pt()); + if (cfgWeightPtEtaId) + hist.fill(HIST(Dire[Mode]) + HIST("h2_Pt_Eta_weighted"), eta, pt, weight); + + hist.fill(HIST(Dire[Mode]) + HIST("h_Pt_weighted"), pt, weight); + hist.fill(HIST(Dire[Mode]) + HIST("h2_Pt_centFT0M"), centFT0M, pt); + hist.fill(HIST(Dire[Mode]) + HIST("h3_PtEtaPhi"), pt, eta, phi); + hist.fill(HIST(Dire[Mode]) + HIST("h2_Pt_Eta"), eta, pt); + hist.fill(HIST(Dire[Mode]) + HIST("h_Eta"), eta); + hist.fill(HIST(Dire[Mode]) + HIST("h_Phi"), phi); + hist.fill(HIST(Dire[Mode]) + HIST("h_Rap"), rap); hist.fill(HIST(Dire[Mode]) + HIST("h_DcaZ"), track.dcaZ()); hist.fill(HIST(Dire[Mode]) + HIST("h_DcaXY"), track.dcaXY()); - hist.fill(HIST(Dire[Mode]) + HIST("h2_DcaZ"), track.pt(), track.dcaZ()); - hist.fill(HIST(Dire[Mode]) + HIST("h2_DcaXY"), track.pt(), track.dcaXY()); - hist.fill(HIST(Dire[Mode]) + HIST("h2_Pt_Pinner"), track.tpcInnerParam(), track.pt()); - hist.fill(HIST(Dire[Mode]) + HIST("h2_P_Pinner"), track.tpcInnerParam(), track.p()); + hist.fill(HIST(Dire[Mode]) + HIST("h2_DcaZ"), pt, track.dcaZ()); + hist.fill(HIST(Dire[Mode]) + HIST("h2_DcaXY"), pt, track.dcaXY()); - hist.fill(HIST(Dire[Mode]) + HIST("h2_TPCNsigma_El"), track.p(), track.tpcNSigmaEl()); - hist.fill(HIST(Dire[Mode]) + HIST("h2_TOFNsigma_El"), track.p(), track.tofNSigmaEl()); hist.fill(HIST(Dire[Mode]) + HIST("h2_TPCNsigma"), track.p(), nSigmaTPC); hist.fill(HIST(Dire[Mode]) + HIST("h2_TOFNsigma"), track.p(), nSigmaTOF); hist.fill(HIST(Dire[Mode]) + HIST("h2_TpcTofNsigma"), nSigmaTPC, nSigmaTOF); hist.fill(HIST(Dire[Mode]) + HIST("h2_TPCSignal"), track.p(), track.tpcSignal()); + hist.fill(HIST(Dire[Mode]) + HIST("innerParam/h2_TPCSignal"), track.tpcInnerParam(), track.tpcSignal()); hist.fill(HIST(Dire[Mode]) + HIST("h2_TOFSignal"), track.p(), track.beta()); hist.fill(HIST(Dire[Mode]) + HIST("h2_pvsm2"), track.mass() * track.mass(), track.p()); + hist.fill(HIST("QA/after/h2_TPCSignal"), track.p(), track.tpcSignal()); + hist.fill(HIST("QA/after/innerParam/h2_TPCSignal"), track.tpcInnerParam(), track.tpcSignal()); hist.fill(HIST("QA/after/h2_TOFSignal"), track.p(), track.beta()); hist.fill(HIST("QA/after/h2_pvsm2"), track.mass() * track.mass(), track.p()); - - hist.fill(HIST(Dire[Mode]) + HIST("innerParam/h2_TPCNsigma_El"), track.tpcInnerParam(), track.tpcNSigmaEl()); - hist.fill(HIST(Dire[Mode]) + HIST("innerParam/h2_TOFNsigma_El"), track.tpcInnerParam(), track.tofNSigmaEl()); - hist.fill(HIST(Dire[Mode]) + HIST("innerParam/h2_TPCNsigma"), track.tpcInnerParam(), nSigmaTPC); - hist.fill(HIST(Dire[Mode]) + HIST("innerParam/h2_TOFNsigma"), track.tpcInnerParam(), nSigmaTOF); - hist.fill(HIST(Dire[Mode]) + HIST("innerParam/h2_TpcTofNsigma"), nSigmaTPC, nSigmaTOF); - hist.fill(HIST(Dire[Mode]) + HIST("innerParam/h2_TPCSignal"), track.tpcInnerParam(), track.tpcSignal()); - hist.fill(HIST(Dire[Mode]) + HIST("innerParam/h2_TOFSignal"), track.tpcInnerParam(), track.beta()); - hist.fill(HIST(Dire[Mode]) + HIST("innerParam/h2_pvsm2"), track.mass() * track.mass(), track.tpcInnerParam()); - hist.fill(HIST("QA/after/innerParam/h2_TPCSignal"), track.tpcInnerParam(), track.tpcSignal()); - hist.fill(HIST("QA/after/innerParam/h2_TOFSignal"), track.tpcInnerParam(), track.beta()); - hist.fill(HIST("QA/after/innerParam/h2_pvsm2"), track.mass() * track.mass(), track.tpcInnerParam()); } template - void fillPtMCHist(double pt, int pid, int pdgCodePos, int pdgCodeNeg) + void fillPtMCHist(bool cfgGen, float pt, float eta, float rap, float phi, float centFT0M, int pid, int pdgCodePos, int pdgCodeNeg) { - hist.fill(HIST(Dire[Mode]) + HIST("h_PtTruth"), pt); + if (cfgGen) { + hist.fill(HIST(Dire[Mode]) + HIST("h_EtaTruth"), eta); + hist.fill(HIST(Dire[Mode]) + HIST("h_RapTruth"), rap); + hist.fill(HIST(Dire[Mode]) + HIST("h2_PtTruth_centFT0M"), centFT0M, pt); + hist.fill(HIST(Dire[Mode]) + HIST("h2_Pt_EtaTruth"), eta, pt); + hist.fill(HIST(Dire[Mode]) + HIST("h_PhiTruth"), phi); + hist.fill(HIST(Dire[Mode]) + HIST("h_PtEtaPhiTruth"), pt, eta, phi); + } + if (pid == pdgCodePos) { hist.fill(HIST(Dire[Mode]) + HIST("h_PtPosTruth"), pt); } @@ -736,430 +688,303 @@ struct MeanPtFlucId { } template - void fillAnalysisHistos(int nTPC, int nFT0M, int N, double Q1, double Q2, double Q3, double Q4) + void fillAnalysisHistos(bool cfgCorrection, float centFT0M, double nW, double nW2, double Q1, double Q2) { - if (N == 0) { + if (nW == 0) { return; } - double twopart1 = ((Q1 * Q1) - Q2); - double threepart1 = ((Q1 * Q1 * Q1) - (3 * Q2 * Q1) + 2 * Q3); - double fourpart1 = ((Q1 * Q1 * Q1 * Q1) - (6 * Q2 * Q1 * Q1) + (3 * Q2 * Q2) + (8 * Q3 * Q1) - 6 * Q4); - - hist.fill(HIST(Dire[Mode]) + HIST("h_Mult"), N); - hist.fill(HIST(Dire[Mode]) + HIST("h_Q1"), nTPC, Q1, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_Q2"), nTPC, Q2, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_Q3"), nTPC, Q3, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_Q4"), nTPC, Q4, nFT0M); - - if (N > 1) { - double meanPt = Q1 / static_cast(N); - double nPair = (static_cast(N) * (static_cast(N) - 1)); - double twopart = twopart1 / nPair; - double checkNDenoVar = (1 / std::sqrt(1 - (1 / static_cast(N)))); - hist.fill(HIST(Dire[Mode]) + HIST("h_mean_pT"), meanPt); - hist.fill(HIST(Dire[Mode]) + HIST("p_mean_pT_Mult_var"), nTPC, meanPt); - - hist.fill(HIST(Dire[Mode]) + HIST("h_Q1_var"), nTPC, Q1, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_N_var"), nTPC, N, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_twopart_nume_Mult_var"), nTPC, twopart1, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_twopart_deno_Mult_var"), nTPC, nPair, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_mean_pT_Mult_var"), nTPC, meanPt, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_twopart_Mult_var"), nTPC, twopart, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("p_CheckNCh"), nTPC, checkNDenoVar); - hist.fill(HIST(Dire[Mode]) + HIST("h_CheckNCh"), nTPC, checkNDenoVar, nFT0M); - - if (N > 2) { - double nTriplet = (static_cast(N) * (static_cast(N) - 1) * (static_cast(N) - 2)); - double threepart = threepart1 / nTriplet; - hist.fill(HIST(Dire[Mode]) + HIST("h_mean_pT_Mult_skew"), nTPC, meanPt, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_twopart_Mult_skew"), nTPC, twopart, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_threepart_Mult_skew"), nTPC, threepart, nFT0M); - - if (N > 3) { - double nQuad = (static_cast(N) * (static_cast(N) - 1) * (static_cast(N) - 2) * (static_cast(N) - 3)); - double fourpart = fourpart1 / nQuad; - hist.fill(HIST(Dire[Mode]) + HIST("h_mean_pT_Mult_kurto"), nTPC, meanPt, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_twopart_Mult_kurto"), nTPC, twopart, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_threepart_Mult_kurto"), nTPC, threepart, nFT0M); - hist.fill(HIST(Dire[Mode]) + HIST("h_fourpart_Mult_kurto"), nTPC, fourpart, nFT0M); - } - } - } - } - - template - void fillHistos(T const& col, U const& tracks) - { - int nCh = 0, nTPC = 0, nFT0M = 0; - int nPi = 0, nKa = 0, nPr = 0; - double ptCh = 0, q1Ch = 0, q2Ch = 0, q3Ch = 0, q4Ch = 0; - double ptPi = 0, q1Pi = 0, q2Pi = 0, q3Pi = 0, q4Pi = 0; - double ptPr = 0, q1Pr = 0, q2Pr = 0, q3Pr = 0, q4Pr = 0; - double ptKa = 0, q1Ka = 0, q2Ka = 0, q3Ka = 0, q4Ka = 0; - - int nChSim = 0, nSim = 0, NFT0CSim = 0; - int nPiSim = 0, nKaSim = 0, nPrSim = 0; - double ptChSim = 0, q1ChSim = 0, q2ChSim = 0, q3ChSim = 0, q4ChSim = 0; - double ptPiSim = 0, q1PiSim = 0, q2PiSim = 0, q3PiSim = 0, q4PiSim = 0; - double ptPrSim = 0, q1PrSim = 0, q2PrSim = 0, q3PrSim = 0, q4PrSim = 0; - double ptKaSim = 0, q1KaSim = 0, q2KaSim = 0, q3KaSim = 0, q4KaSim = 0; - - array p1, p2; - double invMassGamma = 0.0; - - for (const auto& [trkEl, trkPos] : soa::combinations(soa::CombinationsFullIndexPolicy(tracks, tracks))) { - if (trkEl.index() == trkPos.index()) - continue; - if (!selTrack(trkEl) || !selTrack(trkPos)) - continue; - - if (!selElectrons(trkEl) || !selElectrons(trkPos)) - continue; + hist.fill(HIST(Dire[Mode]) + HIST("h_Mult"), nW); - p1 = std::array{trkEl.px(), trkEl.py(), trkEl.pz()}; - p2 = std::array{trkPos.px(), trkPos.py(), trkPos.pz()}; + double nPair = 0., meanPt = 0., twopart1 = 0., twopart = 0.; - invMassGamma = RecoDecay::m(std::array{p1, p2}, std::array{MassElectron, MassElectron}); - hist.fill(HIST("QA/after/h_invMass_gamma"), invMassGamma); + if (cfgCorrection) { + nPair = nW * nW - nW2; + } else { + if (nW > 1) { + nPair = nW * (nW - 1); + } } - if constexpr (DataFlag) { - for (const auto& track : tracks) { - if (!selTrack(track)) { - continue; - } - - double nSigmaTPCPi = track.tpcNSigmaPi(); - double nSigmaTPCKa = track.tpcNSigmaKa(); - double nSigmaTPCPr = track.tpcNSigmaPr(); - double nSigmaTOFPi = track.tofNSigmaPi(); - double nSigmaTOFKa = track.tofNSigmaKa(); - double nSigmaTOFPr = track.tofNSigmaPr(); - double rapPi = track.rapidity(MassPiPlus); - double rapKa = track.rapidity(MassKPlus); - double rapPr = track.rapidity(MassProton); - double innerParam = track.tpcInnerParam(); - - if (std::fabs(track.eta()) < 0.8) { - nCh++; - ptCh = track.pt(); - moments(ptCh, q1Ch, q2Ch, q3Ch, q4Ch); - fillChargedQAHistos(track); - } - - fillBeforePIDQAHistos(track); + if (nPair > 0) { + meanPt = Q1 / nW; + twopart1 = (Q1 * Q1 - Q2); + twopart = twopart1 / nPair; - if (rejectTracks(track)) { - return; - } + hist.fill(HIST(Dire[Mode]) + HIST("h_mean_pT_Mult_var"), centFT0M, meanPt); + hist.fill(HIST(Dire[Mode]) + HIST("h_twopart_Mult_var"), centFT0M, twopart); + hist.fill(HIST(Dire[Mode]) + HIST("p_mean_pT_CentFT0M"), centFT0M, meanPt); + hist.fill(HIST(Dire[Mode]) + HIST("p_twopart_CentFT0M"), centFT0M, twopart); + hist.fill(HIST(Dire[Mode]) + HIST("h_twopart1_CentFT0M"), centFT0M, twopart1); + } - if (cfgInvMass == true && invMassGamma < cfgGammaCut) { - continue; - } + hist.fill(HIST(Dire[Mode]) + HIST("h_Mult"), nW); + hist.fill(HIST(Dire[Mode]) + HIST("h_N_CentFT0M"), centFT0M, nW); + hist.fill(HIST(Dire[Mode]) + HIST("h_Npair_CentFT0M"), centFT0M, nPair); + hist.fill(HIST(Dire[Mode]) + HIST("h_Q1_CentFT0M"), centFT0M, Q1); + hist.fill(HIST(Dire[Mode]) + HIST("h_Q2_CentFT0M"), centFT0M, Q2); + } - if (cfgSelOR == true && cfgSelAND == false) { - if (selLowPi(track, innerParam) == cfgSelLow || selHighPi(track) == cfgSelHigh) { - fillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi, nPi, q1Pi, q2Pi, q3Pi, q4Pi); - } - } else if (cfgSelOR == false && cfgSelAND == true) { - if (selLowPi(track, innerParam) == cfgSelLow && selHighPi(track) == cfgSelHigh) { - fillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi, nPi, q1Pi, q2Pi, q3Pi, q4Pi); - } - } + template + void fillRecoHistos(C const& col, T const& tracks) + { + double nChW = 0., nChW2 = 0., q1Ch = 0., q2Ch = 0.; + float wghtCh = 1.0; + double nPiW = 0., nPiW2 = 0., q1Pi = 0., q2Pi = 0.; + double nKaW = 0., nKaW2 = 0., q1Ka = 0., q2Ka = 0.; + double nPrW = 0., nPrW2 = 0., q1Pr = 0., q2Pr = 0.; + float pt = 0., eta = 0., phi = 0.; - if (cfgSelOR == true && cfgSelAND == false) { - if (selLowKa(track, innerParam) == cfgSelLow || selHighKa(track) == cfgSelHigh) { - fillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa, nKa, q1Ka, q2Ka, q3Ka, q4Ka); - } - } else if (cfgSelOR == false && cfgSelAND == true) { - if (selLowKa(track, innerParam) == cfgSelLow && selHighKa(track) == cfgSelHigh) { - fillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa, nKa, q1Ka, q2Ka, q3Ka, q4Ka); - } - } + hist.fill(HIST("QA/h_collisions_info"), kTotCol); - if (cfgSelOR == true && cfgSelAND == false) { - if (selLowPr(track, innerParam) == cfgSelLow && selHighPr(track) == cfgSelHigh) { - fillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr, nPr, q1Pr, q2Pr, q3Pr, q4Pr); - } - } else if (cfgSelOR == false && cfgSelAND == true) { - if (selLowPr(track, innerParam) == cfgSelLow && selHighPr(track) == cfgSelHigh) { - fillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr, nPr, q1Pr, q2Pr, q3Pr, q4Pr); - } - } - } - } else if constexpr (RecoFlag) { - if (!col.has_mcCollision()) { - LOGF(warning, "No MC collision for this collision, skip..."); + if constexpr (DataFlag) { + if (!selRun3Col(col)) { return; } + } + + hist.fill(HIST("QA/h_collisions_info"), kPassSelCol); - for (const auto& track : tracks) { + fillAfterQAHistos(col); + + for (auto const& track : tracks) { + float nSigmaTPCPi = track.tpcNSigmaPi(); + float nSigmaTPCKa = track.tpcNSigmaKa(); + float nSigmaTPCPr = track.tpcNSigmaPr(); + float nSigmaTOFPi = track.tofNSigmaPi(); + float nSigmaTOFKa = track.tofNSigmaKa(); + float nSigmaTOFPr = track.tofNSigmaPr(); + float rapPi = track.rapidity(MassPiPlus); + float rapKa = track.rapidity(MassKPlus); + float rapPr = track.rapidity(MassProton); + + if constexpr (RecoFlag) { if (!track.has_mcParticle()) { - LOGF(warning, "No MC Particle for this track, skip..."); - continue; - } - auto mcPart = track.mcParticle(); - int pid = mcPart.pdgCode(); - if (!mcPart.isPhysicalPrimary()) { + hist.fill(HIST("Tracks/h_tracks_info"), kTracksBeforeHasMcParticle); continue; } + } + hist.fill(HIST("Tracks/h_tracks_info"), kAllTracks); - //______________________________Reconstructed Level____________________________________________________// - - if (selTrack(track)) { - double nSigmaTPCPi = track.tpcNSigmaPi(); - double nSigmaTPCKa = track.tpcNSigmaKa(); - double nSigmaTPCPr = track.tpcNSigmaPr(); - double nSigmaTOFPi = track.tofNSigmaPi(); - double nSigmaTOFKa = track.tofNSigmaKa(); - double nSigmaTOFPr = track.tofNSigmaPr(); - double rapPi = track.rapidity(MassPiPlus); - double rapKa = track.rapidity(MassKPlus); - double rapPr = track.rapidity(MassProton); - double innerParam = track.tpcInnerParam(); - - if (std::fabs(track.eta()) < 0.8) { - nCh++; - ptCh = track.pt(); - moments(ptCh, q1Ch, q2Ch, q3Ch, q4Ch); - fillChargedQAHistos(track); - } - fillBeforePIDQAHistos(track); - - if (cfgRejTrk == true && rejectTracks(track)) { - return; - } + if (!selTrack(track)) { + continue; + } + hist.fill(HIST("Tracks/h_tracks_info"), kAllSelPassed); + + pt = track.pt(); + if constexpr (RecoFlag) { + hist.fill(HIST("Tracks/h2_tracks_pid_before_sel"), track.mcParticle().pdgCode(), track.pt()); + + auto mc = track.template mcParticle_as(); + pt = mc.pt(); + eta = mc.eta(); + phi = mc.phi(); + + if (mc.isPhysicalPrimary()) { + hist.fill(HIST("QA/after/h_DCAxy_primary"), track.dcaXY()); + hist.fill(HIST("QA/after/h_DCAz_primary"), track.dcaZ()); + } else { + hist.fill(HIST("QA/after/h_DCAxy_secondary"), track.dcaXY()); + hist.fill(HIST("QA/after/h_DCAz_secondary"), track.dcaZ()); + } + } - if (cfgInvMass == true && invMassGamma < cfgGammaCut) { - continue; - } + // Charged particles: + wghtCh = getCorrectedWeight(hWeightPt, hPurePt, pt, cfgWeightPtCh, false); - if (cfgPDGCodeOnly == true) { - if (std::abs(pid) == kPiPlus && std::abs(rapPi) < 0.5 && track.pt() >= cfgCutPiPtMin) { - ptPi = track.pt(); - fillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi, nPi, q1Pi, q2Pi, q3Pi, q4Pi); - fillPtMCHist(ptPi, pid, kPiPlus, kPiMinus); - } + if (std::abs(wghtCh) < cfgMinWeight) + return; - if (std::abs(pid) == kKPlus && std::abs(rapKa) < 0.5 && track.pt() >= cfgCutKaPtMin) { - ptKa = track.pt(); - fillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa, nKa, q1Ka, q2Ka, q3Ka, q4Ka); - fillPtMCHist(ptKa, pid, kKPlus, kKMinus); - } + nChW += wghtCh; + nChW2 += wghtCh * wghtCh; + moments(pt, wghtCh, q1Ch, q2Ch); + hist.fill(HIST("QA/Charged/h_Pt"), track.pt()); + fillChargedQAHistos(track, centFT0M); - if (std::abs(pid) == kProton && std::abs(rapPr) < 0.5 && track.pt() >= cfgCutPrPtMin) { - ptPr = track.pt(); - fillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr, nPr, q1Pr, q2Pr, q3Pr, q4Pr); - fillPtMCHist(ptPr, pid, kProton, kProtonBar); - } - } + fillBeforePIDQAHistos(track); - if (cfgPidCut == true) { - if (cfgSelOR == true && cfgSelAND == false) { - if (selLowPi(track, innerParam) == cfgSelLow || selHighPi(track) == cfgSelHigh) { - ptPi = track.pt(); - fillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi, nPi, q1Pi, q2Pi, q3Pi, q4Pi); - if (std::abs(pid) == kPiPlus) { - fillPtMCHist(ptPi, pid, kPiPlus, kPiMinus); - } - } - } else if (cfgSelOR == false && cfgSelAND == true) { - if (selLowPi(track, innerParam) == cfgSelLow && selHighPi(track) == cfgSelHigh) { - ptPi = track.pt(); - fillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi, nPi, q1Pi, q2Pi, q3Pi, q4Pi); - if (std::abs(pid) == kPiPlus) { - fillPtMCHist(ptPi, pid, kPiPlus, kPiMinus); - } - } - } - - if (cfgSelOR == true && cfgSelAND == false) { - if (selLowKa(track, innerParam) == cfgSelLow || selHighKa(track) == cfgSelHigh) { - ptKa = track.pt(); - fillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa, nKa, q1Ka, q2Ka, q3Ka, q4Ka); - if (std::abs(pid) == kKPlus) { - fillPtMCHist(ptKa, pid, kKPlus, kKMinus); - } - } - } else if (cfgSelOR == false && cfgSelAND == true) { - if (selLowKa(track, innerParam) == cfgSelLow && selHighKa(track) == cfgSelHigh) { - ptKa = track.pt(); - fillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa, nKa, q1Ka, q2Ka, q3Ka, q4Ka); - if (std::abs(pid) == kKPlus) { - fillPtMCHist(ptKa, pid, kKPlus, kKMinus); - } - } - } + // identified particles: + if (cfgRejTrk && rejectTracks(track)) { + continue; + } + auto selIDPion = identifyParticle(track, cfgCutPiThrsldP); + auto selIDKaon = identifyParticle(track, cfgCutKaThrsldP); + auto selIDProton = identifyParticle(track, cfgCutPrThrsldP); + if (selIDPion && pt >= cfgCutPiPtMin) { + hist.fill(HIST("QA/Pion/h_Pt"), track.pt()); + fillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi, centFT0M, hWeightPtPi, hPurePtPi, cfgWeightPtId, cfgPurityId, nPiW, nPiW2, q1Pi, q2Pi); + } + if (selIDKaon && pt >= cfgCutKaPtMin) { + hist.fill(HIST("QA/Kaon/h_Pt"), track.pt()); + fillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa, centFT0M, hWeightPtKa, hPurePtKa, cfgWeightPtId, cfgPurityId, nKaW, nKaW2, q1Ka, q2Ka); + } + if (selIDProton && pt >= cfgCutPrPtMin) { + hist.fill(HIST("QA/Proton/h_Pt"), track.pt()); + fillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr, centFT0M, hWeightPtPr, hPurePtPr, cfgWeightPtId, cfgPurityId, nPrW, nPrW2, q1Pr, q2Pr); + } - if (cfgSelOR == true && cfgSelAND == false) { - if (selLowPr(track, innerParam) == cfgSelLow || selHighPr(track) == cfgSelHigh) { - ptPr = track.pt(); - fillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr, nPr, q1Pr, q2Pr, q3Pr, q4Pr); - if (std::abs(pid) == kProton) { - fillPtMCHist(ptPr, pid, kProton, kProtonBar); - } - } - } else if (cfgSelOR == false && cfgSelAND == true) { - if (selLowPr(track, innerParam) == cfgSelLow && selHighPr(track) == cfgSelHigh) { - ptPr = track.pt(); - fillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr, nPr, q1Pr, q2Pr, q3Pr, q4Pr); - if (std::abs(pid) == kProton) { - fillPtMCHist(ptPr, pid, kProton, kProtonBar); - } - } + if constexpr (RecoFlag) { + auto mc = track.template mcParticle_as(); + int pid = mc.pdgCode(); + if (selIDPion && pt >= cfgCutPiPtMin) { + if (std::abs(pid) == kPiPlus) { + hist.fill(HIST("QA/Pion/h_PtTruth"), pt); + fillPtMCHist(false, pt, eta, rapPi, phi, centFT0M, pid, kPiPlus, kPiMinus); + if (mc.isPhysicalPrimary()) { + hist.fill(HIST("QA/Pion/h_PtTruth_primary"), pt); + } else { + hist.fill(HIST("QA/Pion/h_PtTruth_secondary"), pt); } } } - - //___________________________________Truth Level____________________________________________________// - auto charge = 0.; - auto* pd = pdg->GetParticle(pid); - if (pd != nullptr) { - charge = pd->Charge(); - } - if (std::fabs(charge) < 1e-3) { - continue; - } - if (std::abs(mcPart.eta()) < 0.8) { - nSim++; - } - if (-3.3 < mcPart.eta() && mcPart.eta() < -2.1) { - NFT0CSim++; - } - - if (mcPart.pt() > cfgCutPtMin && mcPart.pt() < cfgCutPtMax) { - - if (std::abs(mcPart.eta()) > 0.8) { - continue; - } - nChSim++; - ptChSim = mcPart.pt(); - moments(ptChSim, q1ChSim, q2ChSim, q3ChSim, q4ChSim); - hist.fill(HIST("Gen/Charged/h_PtTruth"), mcPart.pt()); - - if (std::abs(mcPart.y()) > cfgCutRap) { - continue; - } - - if (std::abs(pid) == kPiPlus && mcPart.pt() >= cfgCutPiPtMin) { - if (cfgSelOR == true && cfgSelAND == false) { - if (mcPart.p() <= cfgCutPiThrsldP || mcPart.p() > cfgCutPiThrsldP) { - nPiSim++; - ptPiSim = mcPart.pt(); - moments(ptPiSim, q1PiSim, q2PiSim, q3PiSim, q4PiSim); - fillPtMCHist(ptPiSim, pid, kPiPlus, kPiMinus); - } - } else if (cfgSelOR == false && cfgSelAND == true) { - if ((cfgSelLow == true && mcPart.p() <= cfgCutPiThrsldP) && (cfgSelHigh == true && mcPart.p() > cfgCutPiThrsldP)) { - nPiSim++; - ptPiSim = mcPart.pt(); - moments(ptPiSim, q1PiSim, q2PiSim, q3PiSim, q4PiSim); - fillPtMCHist(ptPiSim, pid, kPiPlus, kPiMinus); - } + if (selIDKaon && pt >= cfgCutKaPtMin) { + if (std::abs(pid) == kKPlus) { + hist.fill(HIST("QA/Kaon/h_PtTruth"), pt); + fillPtMCHist(false, pt, eta, rapKa, phi, centFT0M, pid, kKPlus, kKMinus); + if (mc.isPhysicalPrimary()) { + hist.fill(HIST("QA/Kaon/h_PtTruth_primary"), pt); + } else { + hist.fill(HIST("QA/Kaon/h_PtTruth_secondary"), pt); } } - - if (std::abs(pid) == kKPlus && mcPart.pt() >= cfgCutKaPtMin) { - if (cfgSelOR == true && cfgSelAND == false) { - if ((cfgSelLow == true && mcPart.p() <= cfgCutPiThrsldP) || (cfgSelHigh == true && mcPart.p() > cfgCutPiThrsldP)) { - nKaSim++; - ptKaSim = mcPart.pt(); - moments(ptKaSim, q1KaSim, q2KaSim, q3KaSim, q4KaSim); - fillPtMCHist(ptKaSim, pid, kKPlus, kKMinus); - } - } else if (cfgSelOR == false && cfgSelAND == true) { - if ((cfgSelLow == true && mcPart.p() <= cfgCutKaThrsldP) && (cfgSelHigh == true && mcPart.p() > cfgCutKaThrsldP)) { - nKaSim++; - ptKaSim = mcPart.pt(); - moments(ptKaSim, q1KaSim, q2KaSim, q3KaSim, q4KaSim); - fillPtMCHist(ptKaSim, pid, kKPlus, kKMinus); - } - } - } - - if (std::abs(pid) == kProton && mcPart.pt() >= cfgCutPrPtMin) { - if (cfgSelOR == true && cfgSelAND == false) { - if ((cfgSelLow == true && mcPart.p() <= cfgCutPrThrsldP) || (cfgSelHigh == true && mcPart.p() > cfgCutPrThrsldP)) { - nPrSim++; - ptPrSim = mcPart.pt(); - moments(ptPrSim, q1PrSim, q2PrSim, q3PrSim, q4PrSim); - fillPtMCHist(ptPrSim, pid, kProton, kProtonBar); - } - } else if (cfgSelOR == false && cfgSelAND == true) { - if ((cfgSelLow == true && mcPart.p() <= cfgCutPrThrsldP) && (cfgSelHigh == true && mcPart.p() > cfgCutPrThrsldP)) { - nPrSim++; - ptPrSim = mcPart.pt(); - moments(ptPrSim, q1PrSim, q2PrSim, q3PrSim, q4PrSim); - fillPtMCHist(ptPrSim, pid, kProton, kProtonBar); - } + } + if (selIDProton && pt >= cfgCutPrPtMin) { + if (std::abs(pid) == kProton) { + hist.fill(HIST("QA/Proton/h_PtTruth"), pt); + fillPtMCHist(false, pt, eta, rapPr, phi, centFT0M, pid, kProton, kProtonBar); + if (mc.isPhysicalPrimary()) { + hist.fill(HIST("QA/Proton/h_PtTruth_primary"), pt); + } else { + hist.fill(HIST("QA/Proton/h_PtTruth_secondary"), pt); } } } } - hist.fill(HIST("QA/after/h_vtxZSim"), col.mcCollision().posZ()); } + fillAnalysisHistos(cfgCorrection, centFT0M, nChW, nChW2, q1Ch, q2Ch); + fillAnalysisHistos(cfgCorrection, centFT0M, nPiW, nPiW2, q1Pi, q2Pi); + fillAnalysisHistos(cfgCorrection, centFT0M, nKaW, nKaW2, q1Ka, q2Ka); + fillAnalysisHistos(cfgCorrection, centFT0M, nPrW, nPrW2, q1Pr, q2Pr); + } - nTPC = col.multNTracksHasTPC(); - nFT0M = col.multFT0M(); - - if (cfgMCTruth) { - if (nSim != 0) - hist.fill(HIST("QA/after/h_NSim"), nSim); - - if (nSim != 0 && nCh != 0) - hist.fill(HIST("QA/after/h2_NChSim_NSim"), nSim, nChSim); + template + void fillGenHistos(C const& mcCol, M const& mcParticles) + { + int nSim = 0; + double nChSim = 0., q1ChSim = 0., q2ChSim = 0.; + double nPiSim = 0., q1PiSim = 0., q2PiSim = 0.; + double nKaSim = 0., q1KaSim = 0., q2KaSim = 0.; + double nPrSim = 0., q1PrSim = 0., q2PrSim = 0.; + float pt = 0, eta = 0, phi = 0, rap = 0; + for (auto const& mcPart : mcParticles) { + if (!mcPart.isPhysicalPrimary()) { + continue; + } - if (nSim != 0 && nTPC != 0) - hist.fill(HIST("QA/after/h2_NTPC_NSim"), nSim, nTPC); + auto pid = mcPart.pdgCode(); + if (std::abs(pid) != kElectron && std::abs(pid) != kMuonMinus && std::abs(pid) != kPiPlus && std::abs(pid) != kKPlus && std::abs(pid) != kProton) { + continue; + } - int nFT0C = col.multFT0C(); - if (nFT0C != 0 && NFT0CSim != 0) - hist.fill(HIST("QA/after/h2_NFT0C_NFT0CSim"), NFT0CSim, nFT0C); + pt = mcPart.pt(); + eta = mcPart.eta(); + phi = mcPart.phi(); + if (std::abs(eta) < cfgCutEta) { + nSim++; + } - nTPC = nSim; + if (pt >= cfgCutPtMin && pt < cfgCutPtMax && std::abs(eta) < cfgCutEta) { + nChSim++; + moments(pt, 1.0, q1ChSim, q2ChSim); + hist.fill(HIST("Gen/Charged/h_PtTruth"), pt); + hist.fill(HIST("Gen/Charged/h_EtaTruth"), eta); + hist.fill(HIST("Gen/Charged/h_PhiTruth"), phi); + hist.fill(HIST("Gen/Charged/h2_Pt_EtaTruth"), eta, pt); + hist.fill(HIST("Gen/Charged/h2_PtTruth_centFT0M"), centFT0M, pt); + hist.fill(HIST("Gen/Charged/h_PtEtaPhiTruth"), pt, eta, phi); + + rap = mcPart.y(); + if (std::abs(pid) == kPiPlus && mcPart.pt() > cfgCutPiPtMin) { + nPiSim++; + moments(pt, 1.0, q1PiSim, q2PiSim); + hist.fill(HIST("Gen/Pion/h_PtTruth"), pt); + fillPtMCHist(true, pt, eta, rap, phi, centFT0M, pid, kPiMinus, kPiMinus); + } + if (std::abs(pid) == kKPlus && mcPart.pt() > cfgCutKaPtMin) { + nKaSim++; + moments(pt, 1.0, q1KaSim, q2KaSim); + hist.fill(HIST("Gen/Kaon/h_PtTruth"), pt); + fillPtMCHist(true, pt, eta, rap, phi, centFT0M, pid, kKMinus, kKMinus); + } + if (std::abs(pid) == kProton && mcPart.pt() > cfgCutPrPtMin) { + nPrSim++; + moments(pt, 1.0, q1PrSim, q2PrSim); + hist.fill(HIST("Gen/Proton/h_PtTruth"), pt); + fillPtMCHist(true, pt, eta, rap, phi, centFT0M, pid, kProtonBar, kProtonBar); + } + } + } + fillAnalysisHistos(false, centFT0M, nChSim, nChSim, q1ChSim, q2ChSim); + fillAnalysisHistos(false, centFT0M, nPiSim, nPiSim, q1PiSim, q2PiSim); + fillAnalysisHistos(false, centFT0M, nKaSim, nKaSim, q1KaSim, q2KaSim); + fillAnalysisHistos(false, centFT0M, nPrSim, nPrSim, q1PrSim, q2PrSim); + hist.fill(HIST("Gen/h_Counts"), 2); + hist.fill(HIST("Gen/h_VtxZ"), mcCol.posZ()); + hist.fill(HIST("Gen/h_NSim"), nSim); + hist.fill(HIST("Gen/h2_NTPC_NSim"), nSim, nTPC); + } - hist.fill(HIST("Gen/NTPC"), nTPC); - hist.fill(HIST("Gen/NFT0C"), NFT0CSim); - hist.fill(HIST("Gen/h2_NTPC_NFT0C"), NFT0CSim, nTPC); + template + void analyzeMC(M const& mcCol, C const& cols, T const& tracks, P const& mcParts) + { + // fillBeforeQAHistos(cols.begin(), tracks); + hist.fill(HIST("Gen/h_VtxZ_b"), mcCol.posZ()); + int nRecCols = cols.size(); + if (nRecCols == 0) { + hist.fill(HIST("Gen/h_collision_recgen"), nRecCols); + } + // Do not analyze if more than one reco collision is accociated to one mc gen collision + if (nRecCols != 1) { + return; + } + hist.fill(HIST("Gen/h_collisions_info"), kTotCol); - fillAnalysisHistos(nTPC, nFT0M, nChSim, q1ChSim, q2ChSim, q3ChSim, q4ChSim); - fillAnalysisHistos(nTPC, nFT0M, nPiSim, q1PiSim, q2PiSim, q3PiSim, q4PiSim); - fillAnalysisHistos(nTPC, nFT0M, nKaSim, q1KaSim, q2KaSim, q3KaSim, q4KaSim); - fillAnalysisHistos(nTPC, nFT0M, nPrSim, q1PrSim, q2PrSim, q3PrSim, q4PrSim); + // Check the reco collision + if (!cols.begin().has_mcCollision() || !selRun3Col(cols.begin()) || cols.begin().mcCollisionId() != mcCol.globalIndex()) { + return; } - fillAfterQAHistos(col); - if (nTPC != 0 && nCh != 0) - hist.fill(HIST("QA/after/h2_NTPC_NCh"), nTPC, nCh); + hist.fill(HIST("Gen/h_collisions_info"), kPassSelCol); + hist.fill(HIST("Gen/h2_collision_posZ"), mcCol.posZ(), cols.begin().posZ()); - fillAnalysisHistos(nTPC, nFT0M, nCh, q1Ch, q2Ch, q3Ch, q4Ch); - fillAnalysisHistos(nTPC, nFT0M, nPi, q1Pi, q2Pi, q3Pi, q4Pi); - fillAnalysisHistos(nTPC, nFT0M, nKa, q1Ka, q2Ka, q3Ka, q4Ka); - fillAnalysisHistos(nTPC, nFT0M, nPr, q1Pr, q2Pr, q3Pr, q4Pr); + auto sTracks = tracks.sliceBy(perCollision, cols.begin().globalIndex()); + fillRecoHistos(cols.begin(), sTracks); + fillGenHistos(mcCol, mcParts); } - void processRun3(MyCollisions::iterator const& col, MyAllTracks const& tracks) + using MyAllTracks = soa::Join; + using MyRun3Collisions = soa::Join; + using MyRun3MCCollisions = soa::Join; + using MyMCTracks = soa::Join; + SliceCache cache; + Preslice perCollision = aod::track::collisionId; + + void processRun3(MyRun3Collisions::iterator const& col, MyAllTracks const& tracks) { - // Before Collision and Track Cuts: fillBeforeQAHistos(col, tracks); - - // After Collision and Track Cuts: - if (selRun3Col(col)) { - fillHistos(col, tracks); - } + fillRecoHistos(col, tracks); } - PROCESS_SWITCH(MeanPtFlucId, processRun3, "Process for Run3", false); + PROCESS_SWITCH(MeanPtFlucId, processRun3, "Process for Run-3", false); - void processMCRecoSimRun3(MyMCCollisions::iterator const& col, aod::McCollisions const&, MyMCTracks const& tracks, aod::McParticles const&) + void processMCRecoSimRun3(aod::McCollisions::iterator const& mcCol, soa::SmallGroups const& cols, MyMCTracks const& tracks, aod::McParticles const& mcParts) { - // Before Collision and Track Cuts: - fillBeforeQAHistos(col, tracks); - - // After Collision and Track Cuts: - if (selRun3Col(col)) { - fillHistos(col, tracks); - } + analyzeMC(mcCol, cols, tracks, mcParts); } PROCESS_SWITCH(MeanPtFlucId, processMCRecoSimRun3, "process MC Reconstructed & Truth Run-3", true); }; diff --git a/PWGCF/EbyEFluctuations/Tasks/nchCumulantsId.cxx b/PWGCF/EbyEFluctuations/Tasks/nchCumulantsId.cxx new file mode 100644 index 00000000000..2d4ba400285 --- /dev/null +++ b/PWGCF/EbyEFluctuations/Tasks/nchCumulantsId.cxx @@ -0,0 +1,760 @@ +// 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. + +/// \file nchCumulantsId.cxx +/// \brief Event by Event conserved charges fluctuations +/// \author Pravata Panigrahi :: Sadhana Dash(sadhana@phy.iitb.ac.in) + +#include +#include + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/HistogramSpec.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; // for constants +using namespace std; + +struct NchCumulantsId { + + HistogramRegistry hist{"hist", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // PDG data base + Service pdgDB; + + Configurable cfgCutPosZ{"cfgCutPosZ", 10.0, "cut for vertex Z"}; + Configurable cfgCutDcaXY{"cfgCutDcaXY", 0.12, "cut for dcaXY"}; + Configurable cfgCutDcaZ{"cfgCutDcaZ", 0.3, "cut for dcaZ"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "cut for eta"}; + Configurable cfgCutPtMax{"cfgCutPtMax", 3.0, "max cut for pT"}; + Configurable cfgCutPtMin{"cfgCutPtMin", 0.15, "min cut for pT"}; + + // Configurables for particle Identification + Configurable cfgId01CheckVetoCut{"cfgId01CheckVetoCut", false, "cfgId01CheckVetoCut"}; + Configurable cfgId02DoElRejection{"cfgId02DoElRejection", true, "cfgId02DoElRejection"}; + Configurable cfgId03DoDeRejection{"cfgId03DoDeRejection", false, "cfgId03DoDeRejection"}; + Configurable cfgId04DoPdependentId{"cfgId04DoPdependentId", true, "cfgId04DoPdependentId"}; + Configurable cfgId05DoTpcInnerParamId{"cfgId05DoTpcInnerParamId", false, "cfgId05DoTpcInnerParamId"}; + + Configurable cfgIdPi01ThrPforTOF{"cfgIdPi01ThrPforTOF", 0.7, "cfgIdPi01ThrPforTOF"}; + Configurable cfgIdPi02IdCutTypeLowP{"cfgIdPi02IdCutTypeLowP", 0, "cfgIdPi02IdCutTypeLowP"}; + Configurable cfgIdPi03NSigmaTPCLowP{"cfgIdPi03NSigmaTPCLowP", 2.0, "cfgIdPi03NSigmaTPCLowP"}; + Configurable cfgIdPi04NSigmaTOFLowP{"cfgIdPi04NSigmaTOFLowP", 2.0, "cfgIdPi04NSigmaTOFLowP"}; + Configurable cfgIdPi05NSigmaRadLowP{"cfgIdPi05NSigmaRadLowP", 4.0, "cfgIdPi05NSigmaRadLowP"}; + Configurable cfgIdPi06IdCutTypeHighP{"cfgIdPi06IdCutTypeHighP", 0, "cfgIdPi06IdCutTypeHighP"}; + Configurable cfgIdPi07NSigmaTPCHighP{"cfgIdPi07NSigmaTPCHighP", 2.0, "cfgIdPi07NSigmaTPCHighP"}; + Configurable cfgIdPi08NSigmaTOFHighP{"cfgIdPi08NSigmaTOFHighP", 2.0, "cfgIdPi08NSigmaTOFHighP"}; + Configurable cfgIdPi09NSigmaRadHighP{"cfgIdPi09NSigmaRadHighP", 4.0, "cfgIdPi09NSigmaRadHighP"}; + + Configurable cfgIdKa01ThrPforTOF{"cfgIdKa01ThrPforTOF", 0.8, "cfgIdKa01ThrPforTOF"}; + Configurable cfgIdKa02IdCutTypeLowP{"cfgIdKa02IdCutTypeLowP", 0, "cfgIdKa02IdCutTypeLowP"}; + Configurable cfgIdKa03NSigmaTPCLowP{"cfgIdKa03NSigmaTPCLowP", 2.0, "cfgIdKa03NSigmaTPCLowP"}; + Configurable cfgIdKa04NSigmaTOFLowP{"cfgIdKa04NSigmaTOFLowP", 2.0, "cfgIdKa04NSigmaTOFLowP"}; + Configurable cfgIdKa05NSigmaRadLowP{"cfgIdKa05NSigmaRadLowP", 4.0, "cfgIdKa05NSigmaRadLowP"}; + Configurable cfgIdKa06IdCutTypeHighP{"cfgIdKa06IdCutTypeHighP", 0, "cfgIdKa06IdCutTypeHighP"}; + Configurable cfgIdKa07NSigmaTPCHighP{"cfgIdKa07NSigmaTPCHighP", 2.0, "cfgIdKa07NSigmaTPCHighP"}; + Configurable cfgIdKa08NSigmaTOFHighP{"cfgIdKa08NSigmaTOFHighP", 2.0, "cfgIdKa08NSigmaTOFHighP"}; + Configurable cfgIdKa09NSigmaRadHighP{"cfgIdKa09NSigmaRadHighP", 4.0, "cfgIdKa09NSigmaRadHighP"}; + + Configurable cfgIdPr01ThrPforTOF{"cfgIdPr01ThrPforTOF", 0.8, "cfgIdPr01ThrPforTOF"}; + Configurable cfgIdPr02IdCutTypeLowP{"cfgIdPr02IdCutTypeLowP", 0, "cfgIdPr02IdCutTypeLowP"}; + Configurable cfgIdPr03NSigmaTPCLowP{"cfgIdPr03NSigmaTPCLowP", 2.0, "cfgIdPr03NSigmaTPCLowP"}; + Configurable cfgIdPr04NSigmaTOFLowP{"cfgIdPr04NSigmaTOFLowP", 2.0, "cfgIdPr04NSigmaTOFLowP"}; + Configurable cfgIdPr05NSigmaRadLowP{"cfgIdPr05NSigmaRadLowP", 4.0, "cfgIdPr05NSigmaRadLowP"}; + Configurable cfgIdPr06IdCutTypeHighP{"cfgIdPr06IdCutTypeHighP", 0, "cfgIdPr06IdCutTypeHighP"}; + Configurable cfgIdPr07NSigmaTPCHighP{"cfgIdPr07NSigmaTPCHighP", 2.0, "cfgIdPr07NSigmaTPCHighP"}; + Configurable cfgIdPr08NSigmaTOFHighP{"cfgIdPr08NSigmaTOFHighP", 2.0, "cfgIdPr08NSigmaTOFHighP"}; + Configurable cfgIdPr09NSigmaRadHighP{"cfgIdPr09NSigmaRadHighP", 4.0, "cfgIdPr09NSigmaRadHighP"}; + + struct : ConfigurableGroup { + Configurable cfgVetoId01PiTPC{"cfgVetoId01PiTPC", 3.0, "cfgVetoId01PiTPC"}; + Configurable cfgVetoId02PiTOF{"cfgVetoId02PiTOF", 3.0, "cfgVetoId02PiTOF"}; + Configurable cfgVetoId03KaTPC{"cfgVetoId03KaTPC", 3.0, "cfgVetoId03KaTPC"}; + Configurable cfgVetoId04KaTOF{"cfgVetoId04KaTOF", 3.0, "cfgVetoId04KaTOF"}; + Configurable cfgVetoId05PrTPC{"cfgVetoId05PrTPC", 3.0, "cfgVetoId05PrTPC"}; + Configurable cfgVetoId06PrTOF{"cfgVetoId06PrTOF", 3.0, "cfgVetoId06PrTOF"}; + Configurable cfgVetoId07ElTPC{"cfgVetoId07ElTPC", 3.0, "cfgVetoId07ElTPC"}; + Configurable cfgVetoId08ElTOF{"cfgVetoId08ElTOF", 3.0, "cfgVetoId08ElTOF"}; + Configurable cfgVetoId09DeTPC{"cfgVetoId09DeTPC", 3.0, "cfgVetoId09DeTPC"}; + Configurable cfgVetoId10DeTOF{"cfgVetoId10DeTOF", 3.0, "cfgVetoId10DeTOF"}; + } cfgVetoIdCut; + + void init(InitContext const&) + { + // QA check axes + const AxisSpec axisEvents{1, 0, 1, "Counts"}; + const AxisSpec axisEta{100, -1., +1., "#eta"}; + const AxisSpec axisPt{100, 0., 3., "p_{T} (GeV/c)"}; + const AxisSpec axisP{100, 0., 5., "p (GeV/c)"}; + const AxisSpec axisTPCInnerParam{100, 0, 3, "P_innerParam_Gev"}; + const AxisSpec axisdEdx(100, 20, 500, {"#frac{dE}{dx}"}); + const AxisSpec axisVtxZ{80, -20., 20., "V_{Z} (cm)"}; + const AxisSpec axisDCAz{200, -3., 3., "DCA_{Z} (cm)"}; + const AxisSpec axisDCAxy{200, -3., 3., "DCA_{XY} (cm)"}; + const AxisSpec axisMultFT0(150, 0, 1500, "MultFT0"); + const AxisSpec axisCent(103, -1., 102., "FT0C(%)"); + const AxisSpec axisPhi(80, -1, 7, "phi"); + + const AxisSpec axisTOFBeta = {40, -2.0, 2.0, "tofBeta"}; + const AxisSpec axisTPCSignal = {100, -1, 1000, "tpcSignal"}; + const AxisSpec axisTPCNSigma = {200, -10.0, 10.0, "n#sigma_{TPC}"}; + const AxisSpec axisTOFNSigma = {200, -10.0, 10.0, "n#sigma_{TOF}"}; + const AxisSpec axisTOFExpMom = {200, 0.0f, 10.0f, "#it{p}_{tofExpMom} (GeV/#it{c})"}; + + const AxisSpec axisNch(100, -50, 50, "Net_charge_dN"); + const AxisSpec axisPosCh(101, -1, 100, "Pos_charge"); + const AxisSpec axisNegCh(101, -1, 100, "Neg_charge"); + const AxisSpec axisNt(201, -1, 200, "Mult_midRap_Nch"); + const AxisSpec axisPrCh(101, -1, 100, "Pr_charge"); + const AxisSpec axisAPrCh(101, -1, 100, "APr_charge"); + const AxisSpec axisKaCh(101, -1, 100, "Ka_charge"); + const AxisSpec axisAKaCh(101, -1, 100, "AKa_charge"); + const AxisSpec axisPiCh(101, -1, 100, "Pion_Positive"); + const AxisSpec axisAPiCh(101, -1, 100, "Pion_Negative"); + + HistogramConfigSpec qnHist1({HistType::kTHnSparseD, {axisNch, axisPosCh, axisNegCh, axisPrCh, axisAPrCh, axisKaCh, axisAKaCh, axisNt, axisCent}}); + HistogramConfigSpec qnHist2({HistType::kTHnSparseD, {axisNch, axisPosCh, axisNegCh, axisPiCh, axisAPiCh, axisKaCh, axisAKaCh, axisNt, axisCent}}); + + HistogramConfigSpec histPPt({HistType::kTH2F, {axisP, axisPt}}); + HistogramConfigSpec histPTpcInnerParam({HistType::kTH2F, {axisP, axisTPCInnerParam}}); + HistogramConfigSpec histPTpcSignal({HistType::kTH2F, {axisP, axisTPCSignal}}); + HistogramConfigSpec histTpcInnerParamTpcSignal({HistType::kTH2F, {axisTPCInnerParam, axisTPCSignal}}); + HistogramConfigSpec histPBeta({HistType::kTH2F, {axisP, axisTOFBeta}}); + HistogramConfigSpec histTpcInnerParamBeta({HistType::kTH2F, {axisTPCInnerParam, axisTOFBeta}}); + HistogramConfigSpec histPTpcNSigma({HistType::kTH2F, {axisP, axisTPCNSigma}}); + HistogramConfigSpec histPtTpcNSigma({HistType::kTH2F, {axisPt, axisTPCNSigma}}); + HistogramConfigSpec histTpcInnerParamTpcNSigma({HistType::kTH2F, {axisTPCInnerParam, axisTPCNSigma}}); + HistogramConfigSpec histTofExpMomTpcNSigma({HistType::kTH2F, {axisTOFExpMom, axisTPCNSigma}}); + HistogramConfigSpec histPTofNSigma({HistType::kTH2F, {axisP, axisTOFNSigma}}); + HistogramConfigSpec histPtTofNSigma({HistType::kTH2F, {axisPt, axisTOFNSigma}}); + HistogramConfigSpec histTpcInnerParamTofNSigma({HistType::kTH2F, {axisTPCInnerParam, axisTOFNSigma}}); + HistogramConfigSpec histTofExpMomTofNSigma({HistType::kTH2F, {axisTOFExpMom, axisTOFNSigma}}); + HistogramConfigSpec histTpcNSigmaTofNSigma({HistType::kTH2F, {axisTPCNSigma, axisTOFNSigma}}); + + // QA check histos + + hist.add("QA/events/preSel/h_VtxZ", "V_{Z}", kTH1D, {axisVtxZ}); + hist.add("QA/events/preSel/h_Counts", "Counts", kTH1D, {axisEvents}); + hist.add("QA/events/preSel/multFT0", "multFT0", kTH1F, {axisMultFT0}); + hist.add("QA/events/preSel/centFT0", "centFT0", kTH1F, {axisCent}); + hist.addClone("QA/events/preSel/", "QA/events/postSel/"); + hist.add("QA/events/postSel/net_charge", "net_charge", kTH1F, {axisNch}); + hist.add("QA/events/postSel/Nt_centFT", "Mid_rap_Mult_VS_Cent", kTH2D, {{axisCent}, {axisNt}}); + + hist.add("QA/tracks/preSel/h_P", "p (Gev/c)", kTH1D, {axisP}); + hist.add("QA/tracks/preSel/h_P_InnerParameter", "p_InnerParameter (Gev/c)", kTH1D, {axisTPCInnerParam}); + hist.add("QA/tracks/preSel/h_Pt", "p_{T} (TPC & TPC+TOF)", kTH1D, {axisPt}); + hist.add("QA/tracks/preSel/h_Eta", "#eta ", kTH1D, {axisEta}); + hist.add("QA/tracks/preSel/h_phi", "#phi ", kTH1D, {axisPhi}); + hist.add("QA/tracks/preSel/h2_Pt_DcaZ", "DCA_{z}", kTH2D, {{axisPt}, {axisDCAz}}); + hist.add("QA/tracks/preSel/h2_Pt_DcaXY", "DCA_{xy}", kTH2D, {{axisPt}, {axisDCAxy}}); + hist.add("QA/tracks/preSel/h2_p_DcaZ", "DCA_{z}", kTH2D, {{axisP}, {axisDCAz}}); + hist.add("QA/tracks/preSel/h2_p_DcaXY", "DCA_{xy}", kTH2D, {{axisP}, {axisDCAxy}}); + hist.add("QA/tracks/preSel/dE_dx1", "dE/dx vs p", kTH2F, {axisP, axisdEdx}); + hist.add("QA/tracks/preSel/dE_dx2", "dE/dx vs innerparam", kTH2F, {axisTPCInnerParam, axisdEdx}); + hist.add("QA/tracks/preSel/p_pt", "p_vs_pT", kTH2F, {axisP, axisPt}); + hist.add("QA/tracks/preSel/p_pInnerParameter", "p_vs_innerparameter", kTH2F, {axisP, axisTPCInnerParam}); + + // tofBeta + hist.add("QA/tracks/preSel/p_beta", "p_beta", histPBeta); + hist.add("QA/tracks/preSel/tpcInnerParam_beta", "tpcInnerParam_beta", histTpcInnerParamBeta); + + // Look at Pion + hist.add("QA/tracks/preSel/Pi/NoId/p_tpcNSigma", "p_tpcNSigma", histPTpcNSigma); + hist.add("QA/tracks/preSel/Pi/NoId/pt_tpcNSigma", "pt_tpcNSigma", histPtTpcNSigma); + hist.add("QA/tracks/preSel/Pi/NoId/tpcInnerParam_tpcNSigma", "tpcInnerParam_tpcNSigma", histTpcInnerParamTpcNSigma); + hist.add("QA/tracks/preSel/Pi/NoId/tofExpMom_tpcNSigma", "tofExpMom_tpcNSigma", histTofExpMomTpcNSigma); + hist.add("QA/tracks/preSel/Pi/NoId/p_tofNSigma", "p_tofNSigma", histPTofNSigma); + hist.add("QA/tracks/preSel/Pi/NoId/pt_tofNSigma", "pt_tofNSigma", histPtTofNSigma); + hist.add("QA/tracks/preSel/Pi/NoId/tpcInnerParam_tofNSigma", "tpcInnerParam_tofNSigma", histTpcInnerParamTofNSigma); + hist.add("QA/tracks/preSel/Pi/NoId/tofExpMom_tofNSigma", "tofExpMom_tofNSigma", histTofExpMomTofNSigma); + hist.add("QA/tracks/preSel/Pi/NoId/tpcNSigma_tofNSigma", "tpcNSigma_tofNSigma", histTpcNSigmaTofNSigma); + + hist.addClone("QA/tracks/preSel/Pi/", "QA/tracks/preSel/Ka/"); + hist.addClone("QA/tracks/preSel/Pi/", "QA/tracks/preSel/Pr/"); + + hist.addClone("QA/tracks/preSel/", "QA/tracks/postSel/"); + + hist.add("QA/tracks/Idfd/Pi/tpcId/p_pt", "p_pt", histPPt); + hist.add("QA/tracks/Idfd/Pi/tpcId/p_tpcInnerParam", "p_tpcInnerParam", histPTpcInnerParam); + // tpcSignal + hist.add("QA/tracks/Idfd/Pi/tpcId/p_tpcSignal", "p_tpcSignal", histPTpcSignal); + hist.add("QA/tracks/Idfd/Pi/tpcId/tpcInnerParam_tpcSignal", "tpcInnerParam_tpcSignal", histTpcInnerParamTpcSignal); + // tofBeta + hist.add("QA/tracks/Idfd/Pi/tpcId/p_beta", "p_beta", histPBeta); + hist.add("QA/tracks/Idfd/Pi/tpcId/tpcInnerParam_beta", "tpcInnerParam_beta", histTpcInnerParamBeta); + // Look at Pion + hist.add("QA/tracks/Idfd/Pi/tpcId/p_tpcNSigma", "p_tpcNSigma", histPTpcNSigma); + hist.add("QA/tracks/Idfd/Pi/tpcId/pt_tpcNSigma", "pt_tpcNSigma", histPtTpcNSigma); + hist.add("QA/tracks/Idfd/Pi/tpcId/tpcInnerParam_tpcNSigma", "tpcInnerParam_tpcNSigma", histTpcInnerParamTpcNSigma); + hist.add("QA/tracks/Idfd/Pi/tpcId/tofExpMom_tpcNSigma", "tofExpMom_tpcNSigma", histTofExpMomTpcNSigma); + hist.add("QA/tracks/Idfd/Pi/tpcId/p_tofNSigma", "p_tofNSigma", histPTofNSigma); + hist.add("QA/tracks/Idfd/Pi/tpcId/pt_tofNSigma", "pt_tofNSigma", histPtTofNSigma); + hist.add("QA/tracks/Idfd/Pi/tpcId/tpcInnerParam_tofNSigma", "tpcInnerParam_tofNSigma", histTpcInnerParamTofNSigma); + hist.add("QA/tracks/Idfd/Pi/tpcId/tofExpMom_tofNSigma", "tofExpMom_tofNSigma", histTofExpMomTofNSigma); + hist.add("QA/tracks/Idfd/Pi/tpcId/tpcNSigma_tofNSigma", "tpcNSigma_tofNSigma", histTpcNSigmaTofNSigma); + + hist.addClone("QA/tracks/Idfd/Pi/tpcId/", "QA/tracks/Idfd/Pi/tpctofId/"); + hist.addClone("QA/tracks/Idfd/Pi/", "QA/tracks/Idfd/Ka/"); + hist.addClone("QA/tracks/Idfd/Pi/", "QA/tracks/Idfd/Pr/"); + + hist.add("sparse1", "sparse1", qnHist1); + hist.add("sparse2", "sparse2", qnHist2); + } // init ends + + enum IdentificationType { + kTPCidentified = 0, + kTOFidentified, + kTPCTOFidentified, + kUnidentified + }; + + enum TpcTofCutType { + kRectangularCut = 0, + kCircularCut, + kEllipsoidalCut + }; + + enum DetEnum { + tpcId = 0, + tofId, + tpctofId, + NoId + }; + + static constexpr std::string_view DetDire[] = { + "tpcId/", + "tofId/", + "tpctofId/", + "NoId/"}; + + enum HistRegEnum { + qaEventPreSel = 0, + qaEventPostSel, + qaTracksPreSel, + qaTracksPostSel, + qaTracksIdfd + }; + + static constexpr std::string_view HistRegDire[] = { + "QA/events/preSel/", + "QA/events/postSel/", + "QA/tracks/preSel/", + "QA/tracks/postSel/", + "QA/tracks/Idfd/"}; + + enum PidEnum { + kPi = 0, // dont use kPion, kKaon, as these enumeration + kKa, // are already defined in $ROOTSYS/root/include/TPDGCode.h + kPr, + kEl, + kDe + }; + + static constexpr std::string_view PidDire[] = { + "Pi/", + "Ka/", + "Pr/", + "El/", + "De/"}; + + // particle identifications + // tpc Selections + + template + bool vetoIdOthersTPC(const T& track) + { + if (pidMode != kPi) { + if (std::fabs(track.tpcNSigmaPi()) < cfgVetoIdCut.cfgVetoId01PiTPC) + return false; + } + if (pidMode != kKa) { + if (std::fabs(track.tpcNSigmaKa()) < cfgVetoIdCut.cfgVetoId03KaTPC) + return false; + } + if (pidMode != kPr) { + if (std::fabs(track.tpcNSigmaPr()) < cfgVetoIdCut.cfgVetoId05PrTPC) + return false; + } + if (cfgId02DoElRejection) { + if (pidMode != kEl) { + if (std::fabs(track.tpcNSigmaEl()) < cfgVetoIdCut.cfgVetoId07ElTPC) + return false; + } + } + if (cfgId03DoDeRejection) { + if (pidMode != kDe) { + if (std::fabs(track.tpcNSigmaDe()) < cfgVetoIdCut.cfgVetoId09DeTPC) + return false; + } + } + return true; + } + + template + bool vetoIdOthersTOF(const T& track) + { + if (pidMode != kPi) { + if (std::fabs(track.tofNSigmaPi()) < cfgVetoIdCut.cfgVetoId02PiTOF) + return false; + } + if (pidMode != kKa) { + if (std::fabs(track.tofNSigmaKa()) < cfgVetoIdCut.cfgVetoId04KaTOF) + return false; + } + if (pidMode != kPr) { + if (std::fabs(track.tofNSigmaPr()) < cfgVetoIdCut.cfgVetoId06PrTOF) + return false; + } + if (cfgId02DoElRejection) { + if (pidMode != kEl) { + if (std::fabs(track.tofNSigmaEl()) < cfgVetoIdCut.cfgVetoId08ElTOF) + return false; + } + } + if (cfgId03DoDeRejection) { + if (pidMode != kDe) { + if (std::fabs(track.tofNSigmaDe()) < cfgVetoIdCut.cfgVetoId10DeTOF) + return false; + } + } + return true; + } + + template + bool vetoIdOthersTPCTOF(const T& track) + { + if (pidMode != kPi) { + if (std::fabs(track.tpcNSigmaPi()) < cfgVetoIdCut.cfgVetoId01PiTPC && std::fabs(track.tofNSigmaPi()) < cfgVetoIdCut.cfgVetoId02PiTOF) + return false; + } + if (pidMode != kKa) { + if (std::fabs(track.tpcNSigmaKa()) < cfgVetoIdCut.cfgVetoId03KaTPC && std::fabs(track.tofNSigmaKa()) < cfgVetoIdCut.cfgVetoId04KaTOF) + return false; + } + if (pidMode != kPr) { + if (std::fabs(track.tpcNSigmaPr()) < cfgVetoIdCut.cfgVetoId05PrTPC && std::fabs(track.tofNSigmaPr()) < cfgVetoIdCut.cfgVetoId06PrTOF) + return false; + } + if (cfgId02DoElRejection) { + if (pidMode != kEl) { + if (std::fabs(track.tpcNSigmaEl()) < cfgVetoIdCut.cfgVetoId07ElTPC && std::fabs(track.tofNSigmaEl()) < cfgVetoIdCut.cfgVetoId08ElTOF) + return false; + } + } + if (cfgId03DoDeRejection) { + if (pidMode != kDe) { + if (std::fabs(track.tpcNSigmaDe()) < cfgVetoIdCut.cfgVetoId09DeTPC && std::fabs(track.tofNSigmaDe()) < cfgVetoIdCut.cfgVetoId10DeTOF) + return false; + } + } + return true; + } + + template + bool selIdRectangularCut(const T& track, const float& nSigmaTPC, const float& nSigmaTOF) + { + switch (pidMode) { + case kPi: + if (std::fabs(track.tpcNSigmaPi()) < nSigmaTPC && + std::fabs(track.tofNSigmaPi()) < nSigmaTOF) { + return true; + } + break; + case kKa: + if (std::fabs(track.tpcNSigmaKa()) < nSigmaTPC && + std::fabs(track.tofNSigmaKa()) < nSigmaTOF) { + return true; + } + break; + case kPr: + if (std::fabs(track.tpcNSigmaPr()) < nSigmaTPC && + std::fabs(track.tofNSigmaPr()) < nSigmaTOF) { + return true; + } + break; + default: + return false; + break; + } + return false; + } + + template + bool selIdEllipsoidalCut(const T& track, const float& nSigmaTPC, const float& nSigmaTOF) + { + switch (pidMode) { + case kPi: + if (std::pow(track.tpcNSigmaPi() / nSigmaTPC, 2) + std::pow(track.tofNSigmaPi() / nSigmaTOF, 2) < 1.0) + return true; + break; + case kKa: + if (std::pow(track.tpcNSigmaKa() / nSigmaTPC, 2) + std::pow(track.tofNSigmaKa() / nSigmaTOF, 2) < 1.0) + return true; + break; + case kPr: + if (std::pow(track.tpcNSigmaPr() / nSigmaTPC, 2) + std::pow(track.tofNSigmaPr() / nSigmaTOF, 2) < 1.0) + return true; + break; + default: + return false; + break; + } + return false; + } + + template + bool selIdCircularCut(const T& track, const float& nSigmaSquaredRad) + { + switch (pidMode) { + case kPi: + if (std::pow(track.tpcNSigmaPi(), 2) + std::pow(track.tofNSigmaPi(), 2) < nSigmaSquaredRad) + return true; + break; + case kKa: + if (std::pow(track.tpcNSigmaKa(), 2) + std::pow(track.tofNSigmaKa(), 2) < nSigmaSquaredRad) + return true; + break; + case kPr: + if (std::pow(track.tpcNSigmaPr(), 2) + std::pow(track.tofNSigmaPr(), 2) < nSigmaSquaredRad) + return true; + break; + default: + return false; + break; + } + return false; + } + + template + bool checkReliableTOF(const T& track) + { + if (track.hasTOF()) + return true; // which check makes the information of TOF relaiable? should track.beta() be checked? + else + return false; + } + + template + bool idTPC(const T& track, const float& nSigmaTPC) + { + if (cfgId01CheckVetoCut && !vetoIdOthersTPC(track)) + return false; + switch (pidMode) { + case kPi: + if (std::fabs(track.tpcNSigmaPi()) < nSigmaTPC) + return true; + break; + case kKa: + if (std::fabs(track.tpcNSigmaKa()) < nSigmaTPC) + return true; + break; + case kPr: + if (std::fabs(track.tpcNSigmaPr()) < nSigmaTPC) + return true; + break; + default: + return false; + break; + } + return false; + } + + template + bool idTPCTOF(const T& track, const int& pidCutType, const float& nSigmaTPC, const float& nSigmaTOF, const float& nSigmaSquaredRad) + { + if (cfgId01CheckVetoCut && !vetoIdOthersTPCTOF(track)) + return false; + if (pidCutType == kRectangularCut) { + return selIdRectangularCut(track, nSigmaTPC, nSigmaTOF); + } else if (pidCutType == kCircularCut) { + return selIdCircularCut(track, nSigmaSquaredRad); + } else if (pidCutType == kEllipsoidalCut) { + return selIdEllipsoidalCut(track, nSigmaTPC, nSigmaTOF); + } + return false; + } + + template + bool selPdependent(const T& track, int& IdMethod, const float& cfgIdThrPforTOF, + const int& idCutTypeLowP, const float& nSigmaTPCLowP, const float& nSigmaTOFLowP, const float& nSigmaRadLowP, + const int& idCutTypeHighP, const float& nSigmaTPCHighP, const float& nSigmaTOFHighP, const float& nSigmaRadHighP) + { + if (track.p() < cfgIdThrPforTOF) { + if (checkReliableTOF(track)) { + if (idTPCTOF(track, idCutTypeLowP, nSigmaTPCLowP, nSigmaTOFLowP, nSigmaRadLowP)) { + IdMethod = kTPCTOFidentified; + return true; + } + return false; + } else { + if (idTPC(track, nSigmaTPCLowP)) { + IdMethod = kTPCidentified; + return true; + } + return false; + } + } else { + if (checkReliableTOF(track)) { + if (idTPCTOF(track, idCutTypeHighP, nSigmaTPCHighP, nSigmaTOFHighP, nSigmaRadHighP)) { + IdMethod = kTPCTOFidentified; + return true; + } + return false; + } + return false; + } + } + + // + //______________________________Identification Functions________________________________________________________________ + // Pion + template + bool selPion(const T& track, int& IdMethod) + { + if (cfgId04DoPdependentId) { + return selPdependent(track, IdMethod, + cfgIdPi01ThrPforTOF, cfgIdPi02IdCutTypeLowP, cfgIdPi03NSigmaTPCLowP, cfgIdPi04NSigmaTOFLowP, cfgIdPi05NSigmaRadLowP, + cfgIdPi06IdCutTypeHighP, cfgIdPi07NSigmaTPCHighP, cfgIdPi08NSigmaTOFHighP, cfgIdPi09NSigmaRadHighP); + } + return false; + } + + // Kaon + template + bool selKaon(const T& track, int& IdMethod) + { + if (cfgId04DoPdependentId) { + return selPdependent(track, IdMethod, + cfgIdKa01ThrPforTOF, cfgIdKa02IdCutTypeLowP, cfgIdKa03NSigmaTPCLowP, cfgIdKa04NSigmaTOFLowP, cfgIdKa05NSigmaRadLowP, + cfgIdKa06IdCutTypeHighP, cfgIdKa07NSigmaTPCHighP, cfgIdKa08NSigmaTOFHighP, cfgIdKa09NSigmaRadHighP); + } + return false; + } + + // Proton + template + bool selProton(const T& track, int& IdMethod) + { + if (cfgId04DoPdependentId) { + return selPdependent(track, IdMethod, + cfgIdPr01ThrPforTOF, cfgIdPr02IdCutTypeLowP, cfgIdPr03NSigmaTPCLowP, cfgIdPr04NSigmaTOFLowP, cfgIdPr05NSigmaRadLowP, + cfgIdPr06IdCutTypeHighP, cfgIdPr07NSigmaTPCHighP, cfgIdPr08NSigmaTOFHighP, cfgIdPr09NSigmaRadHighP); + } + return false; + } + + template + void fillIdentificationQA(H histReg, const T& track) + { + float tpcNSigmaVal = -999, tofNSigmaVal = -999; + switch (pidMode) { + case kPi: + tpcNSigmaVal = track.tpcNSigmaPi(); + tofNSigmaVal = track.tofNSigmaPi(); + break; + case kKa: + tpcNSigmaVal = track.tpcNSigmaKa(); + tofNSigmaVal = track.tofNSigmaKa(); + break; + case kPr: + tpcNSigmaVal = track.tpcNSigmaPr(); + tofNSigmaVal = track.tofNSigmaPr(); + break; + case kEl: + tpcNSigmaVal = track.tpcNSigmaEl(); + tofNSigmaVal = track.tofNSigmaEl(); + break; + case kDe: + tpcNSigmaVal = track.tpcNSigmaDe(); + tofNSigmaVal = track.tofNSigmaDe(); + break; + default: + tpcNSigmaVal = -999, tofNSigmaVal = -999; + break; + } + + // NSigma + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("p_tpcNSigma"), track.p(), tpcNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("pt_tpcNSigma"), track.pt(), tpcNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("tpcInnerParam_tpcNSigma"), track.tpcInnerParam(), tpcNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("tofExpMom_tpcNSigma"), track.tofExpMom(), tpcNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("p_tofNSigma"), track.p(), tofNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("pt_tofNSigma"), track.pt(), tofNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("tpcInnerParam_tofNSigma"), track.tpcInnerParam(), tofNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("tofExpMom_tofNSigma"), track.tofExpMom(), tofNSigmaVal); + histReg.fill(HIST(HistRegDire[Mode]) + HIST(PidDire[pidMode]) + HIST(DetDire[detMode]) + HIST("tpcNSigma_tofNSigma"), tpcNSigmaVal, tofNSigmaVal); + } + + template + void fillCollQA(const T& col, const int& nCh, const int& nT) + { + hist.fill(HIST(HistRegDire[mode]) + HIST("h_VtxZ"), col.posZ()); + hist.fill(HIST(HistRegDire[mode]) + HIST("h_Counts"), 0.5); + hist.fill(HIST(HistRegDire[mode]) + HIST("multFT0"), col.multFT0C()); + hist.fill(HIST(HistRegDire[mode]) + HIST("centFT0"), col.centFT0M()); + if (mode == qaEventPostSel) { + hist.fill(HIST(HistRegDire[mode]) + HIST("net_charge"), nCh); + hist.fill(HIST(HistRegDire[mode]) + HIST("Nt_centFT"), col.centFT0M(), nT); + } + } + + template + void fillTrackQA(const T& track) + { + hist.fill(HIST(HistRegDire[mode]) + HIST("h_P"), track.p()); + hist.fill(HIST(HistRegDire[mode]) + HIST("h_P_InnerParameter"), track.tpcInnerParam()); + hist.fill(HIST(HistRegDire[mode]) + HIST("h_Pt"), track.pt()); + hist.fill(HIST(HistRegDire[mode]) + HIST("h_Eta"), track.eta()); + hist.fill(HIST(HistRegDire[mode]) + HIST("h_phi"), track.phi()); + hist.fill(HIST(HistRegDire[mode]) + HIST("h2_Pt_DcaZ"), track.pt(), track.dcaZ()); + hist.fill(HIST(HistRegDire[mode]) + HIST("h2_Pt_DcaXY"), track.pt(), track.dcaXY()); + hist.fill(HIST(HistRegDire[mode]) + HIST("h2_p_DcaZ"), track.p(), track.dcaZ()); + hist.fill(HIST(HistRegDire[mode]) + HIST("h2_p_DcaXY"), track.p(), track.dcaXY()); + hist.fill(HIST(HistRegDire[mode]) + HIST("dE_dx1"), track.p(), track.tpcSignal()); + hist.fill(HIST(HistRegDire[mode]) + HIST("dE_dx2"), track.tpcInnerParam(), track.tpcSignal()); + hist.fill(HIST(HistRegDire[mode]) + HIST("p_pt"), track.p(), track.pt()); + hist.fill(HIST(HistRegDire[mode]) + HIST("p_pInnerParameter"), track.p(), track.tpcInnerParam()); + + // tofBeta + hist.fill(HIST(HistRegDire[mode]) + HIST("p_beta"), track.p(), track.beta()); + hist.fill(HIST(HistRegDire[mode]) + HIST("tpcInnerParam_beta"), track.tpcInnerParam(), track.beta()); + + // Look at Pion + fillIdentificationQA(hist, track); // Look at Pion + fillIdentificationQA(hist, track); // Look at Kaon + fillIdentificationQA(hist, track); // Look at Proton + } + + using MyAllTracks = soa::Join; + using MyCollisions = soa::Join; + // tracks and collision filters + Filter col = aod::evsel::sel8 == true; + Filter colFilter = nabs(aod::collision::posZ) < cfgCutPosZ; + Filter trackFilter = requireGlobalTrackInFilter(); + Filter trackPt = (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax); + Filter trackDCAxy = nabs(aod::track::dcaXY) < cfgCutDcaXY; + Filter trackDCAz = nabs(aod::track::dcaZ) < cfgCutDcaZ; + Filter tracketa = nabs(aod::track::eta) < cfgCutEta; + + using MyFilteredCol = soa::Filtered; + using MyFilteredTracks = soa::Filtered; + + // manual sliceby + SliceCache cache; + Preslice tracksPerCollisionPreslice = o2::aod::track::collisionId; + + void process(MyFilteredCol const& collisions, MyFilteredTracks const& tracks) + { + for (const auto& col : collisions) { + + int nP = 0; + int nM = 0; + int nCh = 0; + int nT = 0; + int nPr = 0; + int nAPr = 0; + int nKa = 0; + int nAKa = 0; + int nPi = 0; + int nAPi = 0; + // group tracks manually with corresponding collision using col id; + const uint64_t collIdx = col.globalIndex(); + const auto tracksTablePerColl = tracks.sliceBy(tracksPerCollisionPreslice, collIdx); + + for (const auto& track : tracksTablePerColl) { + + fillTrackQA(track); + + if (track.sign() == 1) { + nP++; + } + if (track.sign() == -1) { + nM++; + } + + int idMethod; + // pion + if (selPion(track, idMethod)) { + if (track.sign() == 1) { + nPi++; + } + if (track.sign() == -1) { + nAPi++; + } + + if (idMethod == kTPCidentified) + fillIdentificationQA(hist, track); + if (idMethod == kTPCTOFidentified) + fillIdentificationQA(hist, track); + } + // kaon + if (selKaon(track, idMethod)) { + if (track.sign() == 1) { + nKa++; + } + if (track.sign() == -1) { + nAKa++; + } + + if (idMethod == kTPCidentified) + fillIdentificationQA(hist, track); + if (idMethod == kTPCTOFidentified) + fillIdentificationQA(hist, track); + } + // proton + if (selProton(track, idMethod)) { + if (track.sign() == 1) { + nPr++; + } + if (track.sign() == -1) { + nAPr++; + } + + if (idMethod == kTPCidentified) + fillIdentificationQA(hist, track); + if (idMethod == kTPCTOFidentified) + fillIdentificationQA(hist, track); + } + + } // track itteration ends + nCh = nP - nM; + nT = nP + nM; + + fillCollQA(col, nCh, nT); + + hist.fill(HIST("sparse1"), nCh, nP, nM, nPr, nAPr, nKa, nAKa, nT, col.centFT0M()); + hist.fill(HIST("sparse2"), nCh, nP, nM, nPi, nAPi, nKa, nAKa, nT, col.centFT0M()); + + } // collision ends + } // process ends +}; // structure ends + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/EbyEFluctuations/Tasks/netchargeFluctuations.cxx b/PWGCF/EbyEFluctuations/Tasks/netchargeFluctuations.cxx new file mode 100644 index 00000000000..bced27ce135 --- /dev/null +++ b/PWGCF/EbyEFluctuations/Tasks/netchargeFluctuations.cxx @@ -0,0 +1,671 @@ +// 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. + +/// \file netchargeFluctuations.cxx +/// \brief Calculate net-charge fluctuations using nu_dyn observable +/// For charged particles +/// For RUN-3 +/// +/// \author Nida Malik +#include "PWGCF/Core/CorrelationContainer.h" +#include "PWGCF/Core/PairCuts.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" + +#include "TProfile.h" +#include "TProfile2D.h" +#include "TRandom3.h" + +#include +#include // Include for std::vector + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace std; +using namespace o2::constants::physics; + +namespace o2 +{ +namespace aod +{ +using MyCollisionsRun2 = soa::Join; +using MyCollisionRun2 = MyCollisionsRun2::iterator; +using MyCollisionsRun3 = soa::Join; +using MyCollisionRun3 = MyCollisionsRun3::iterator; +using MyTracks = soa::Join; +using MyTrack = MyTracks::iterator; + +using MyMCCollisionsRun2 = soa::Join; +using MyMCCollisionRun2 = MyMCCollisionsRun2::iterator; + +using MyMCCollisionsRun3 = soa::Join; +using MyMCCollisionRun3 = MyMCCollisionsRun3::iterator; + +using MyMCTracks = soa::Join; +using MyMCTrack = MyMCTracks::iterator; +} // namespace aod +} // namespace o2 + +enum RunType { + kRun3 = 0, + kRun2 +}; + +struct NetchargeFluctuations { + Service pdgService; + Service ccdb; + TRandom3* fRndm = new TRandom3(0); + HistogramRegistry histogramRegistry{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Configurables + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable cfgUrlCCDB{"cfgUrlCCDB", "http://alice-ccdb.cern.ch", "url of ccdb"}; + Configurable cfgPathCCDB{"cfgPathCCDB", "Users/n/nimalik/efftest", "Path for ccdb-object"}; + Configurable cfgLoadEff{"cfgLoadEff", true, "Load efficiency"}; + + Configurable vertexZcut{"vertexZcut", 10.f, "Vertex Z"}; + Configurable etaCut{"etaCut", 0.8, "Eta cut"}; + Configurable ptMinCut{"ptMinCut", 0.2, "Pt min cut"}; + Configurable ptMaxCut{"ptMaxCut", 5.0, "Pt max cut"}; + Configurable dcaXYCut{"dcaXYCut", 0.12, "DCA XY cut"}; + Configurable dcaZCut{"dcaZCut", 0.3, "DCA Z cut"}; + Configurable tpcCrossCut{"tpcCrossCut", 70, "TPC crossrows cut"}; + Configurable itsChiCut{"itsChiCut", 70, "ITS chi2 cluster cut"}; + Configurable tpcChiCut{"tpcChiCut", 70, "TPC chi2 cluster cut"}; + Configurable centMin{"centMin", 0.0f, "cenrality min for delta eta"}; + Configurable centMax{"centMax", 10.0f, "cenrality max for delta eta"}; + Configurable cfgNSubsample{"cfgNSubsample", 30, "Number of subsamples for Error"}; + Configurable deltaEta{"deltaEta", 8, "Delta eta bin count"}; + Configurable threshold{"threshold", 1e-6, "Delta eta bin count"}; + // Event selections + Configurable cSel8Trig{"cSel8Trig", true, "Sel8 (T0A + T0C) Selection Run3"}; // sel8 + Configurable cInt7Trig{"cInt7Trig", true, "kINT7 MB Trigger"}; // kINT7 + Configurable cSel7Trig{"cSel7Trig", true, "Sel7 (V0A + V0C) Selection Run2"}; // sel7 + Configurable cTFBorder{"cTFBorder", false, "Timeframe Border Selection"}; // pileup + Configurable cNoItsROBorder{"cNoItsROBorder", false, "No ITSRO Border Cut"}; // pileup + Configurable cItsTpcVtx{"cItsTpcVtx", false, "ITS+TPC Vertex Selection"}; // pileup + Configurable cPileupReject{"cPileupReject", false, "Pileup rejection"}; // pileup + Configurable cZVtxTimeDiff{"cZVtxTimeDiff", false, "z-vtx time diff selection"}; // pileup + Configurable cfgUseGoodItsLayerAllCut{"cfgUseGoodItsLayerAllCut", false, "Good ITS Layers All"}; // pileup + Configurable cDcaXy{"cDcaXy", false, "Dca XY cut"}; + Configurable cDcaZ{"cDcaZ", false, "Dca Z cut"}; + Configurable cTpcCr{"cTpcCr", false, "tpc crossrows"}; + Configurable cItsChi{"cItsChi", false, "ITS chi"}; + Configurable cTpcChi{"cTpcChi", false, "TPC chi"}; + + // CCDB efficiency histograms + TH2D* efficiency = nullptr; + + // Initialization + void init(o2::framework::InitContext&) + { + const AxisSpec vtxzAxis = {800, -20, 20, "V_{Z} (cm)"}; + const AxisSpec dcaAxis = {250, -0.5, 0.5, "DCA_{xy} (cm)"}; + const AxisSpec dcazAxis = {250, -0.5, 0.5, "DCA_{z} (cm)"}; + const AxisSpec ptAxis = {70, 0.0, 7.0, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec etaAxis = {20, -1., 1., "#eta"}; + const AxisSpec deltaEtaAxis = {9, 0, 1.8, "#eta"}; + const AxisSpec centAxis = {100, 0., 100., "centrality"}; + const AxisSpec multAxis = {200, 0., 10000., "FT0M Amplitude"}; + const AxisSpec tpcChiAxis = {1400, 0., 7., "Chi2"}; + const AxisSpec itsChiAxis = {800, 0., 40., "Chi2"}; + const AxisSpec crossedRowAxis = {1600, 0., 160., "TPC Crossed rows"}; + const AxisSpec eventsAxis = {10, 0, 10, ""}; + const AxisSpec signAxis = {20, -10, 10, ""}; + const AxisSpec nchAxis = {5000, 0, 5000, "Nch"}; + const AxisSpec nch1Axis = {1500, 0, 1500, "Nch"}; + const AxisSpec nchpAxis = {50000, 0, 50000, "Nch"}; + + std::vector centBining = {0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; + AxisSpec cent1Axis = {centBining, "Multiplicity percentile from FT0M (%)"}; + + auto noSubsample = static_cast(cfgNSubsample); + float maxSubsample = 1.0 * noSubsample; + AxisSpec subsampleAxis = {noSubsample, 0.0, maxSubsample, "subsample no."}; + + histogramRegistry.add("data/hVtxZ_before", "", kTH1F, {vtxzAxis}); + histogramRegistry.add("data/hDcaXY_before", "", kTH1F, {dcaAxis}); + histogramRegistry.add("data/hDcaZ_before", "", kTH1F, {dcazAxis}); + histogramRegistry.add("data/hTPCchi2perCluster_before", "", kTH1D, {tpcChiAxis}); + histogramRegistry.add("data/hITSchi2perCluster_before", "", kTH1D, {itsChiAxis}); + histogramRegistry.add("data/hTPCCrossedrows_before", "", kTH1D, {crossedRowAxis}); + histogramRegistry.add("data/hPtDcaXY_before", "", kTH2D, {ptAxis, dcaAxis}); + histogramRegistry.add("data/hPtDcaZ_before", "", kTH2D, {ptAxis, dcazAxis}); + histogramRegistry.add("data/hVtxZ_after", "", kTH1F, {vtxzAxis}); + histogramRegistry.add("data/hDcaXY_after", "", kTH1F, {dcaAxis}); + histogramRegistry.add("data/hDcaZ_after", "", kTH1F, {dcazAxis}); + histogramRegistry.add("data/hTPCchi2perCluster_after", "", kTH1D, {tpcChiAxis}); + histogramRegistry.add("data/hITSchi2perCluster_after", "", kTH1D, {itsChiAxis}); + histogramRegistry.add("data/hTPCCrossedrows_after", "", kTH1D, {crossedRowAxis}); + histogramRegistry.add("data/hPtDcaXY_after", "", kTH2D, {ptAxis, dcaAxis}); + histogramRegistry.add("data/hPtDcaZ_after", "", kTH2D, {ptAxis, dcazAxis}); + histogramRegistry.add("data/hEta", "", kTH1F, {etaAxis}); + histogramRegistry.add("data/hEta_cent", "", kTH2F, {cent1Axis, etaAxis}); + histogramRegistry.add("data/hPt", "", kTH1F, {ptAxis}); + histogramRegistry.add("data/hPt_cent", "", kTH2F, {cent1Axis, ptAxis}); + histogramRegistry.add("data/hPt_eta", "", kTH2F, {ptAxis, etaAxis}); + histogramRegistry.add("data/hCentrality", "", kTH1F, {centAxis}); + histogramRegistry.add("data/hMultiplicity", "", kTH1F, {multAxis}); + + histogramRegistry.add("gen/hPt_eta", "", kTH2F, {ptAxis, etaAxis}); + histogramRegistry.add("gen/hVtxZ_before", "", kTH1F, {vtxzAxis}); + histogramRegistry.add("gen/hVtxZ_after", "", kTH1F, {vtxzAxis}); + histogramRegistry.add("gen/hEta", "", kTH1F, {etaAxis}); + histogramRegistry.add("gen/hEta_cent", "", kTH2F, {centAxis, etaAxis}); + histogramRegistry.add("gen/hSign", "", kTH1F, {signAxis}); + histogramRegistry.add("gen/hPt", "", kTH1F, {ptAxis}); + histogramRegistry.add("gen/hPt_cent", "", kTH2F, {centAxis, ptAxis}); + histogramRegistry.add("gen/nch", "", kTH1F, {nchAxis}); + + histogramRegistry.add("mult_dist/nch", "", kTH1D, {nchAxis}); + histogramRegistry.add("mult_dist/nch_pos", "", kTH1D, {nchAxis}); + histogramRegistry.add("mult_dist/nch_neg", "", kTH1D, {nchAxis}); + histogramRegistry.add("mult_dist/nch_negpos", "", kTH1D, {nchpAxis}); + histogramRegistry.add("mult_dist/nch_cent", "", kTH2D, {centAxis, nchAxis}); + histogramRegistry.add("mult_dist/nch_pos_cent", "", kTH2D, {centAxis, nchAxis}); + histogramRegistry.add("mult_dist/nch_neg_cent", "", kTH2D, {centAxis, nchAxis}); + histogramRegistry.add("mult_dist/nch_negpos_cent", "", kTH2D, {centAxis, nchpAxis}); + + histogramRegistry.add("delta_eta/cent", "Centrality", kTH1F, {cent1Axis}); + histogramRegistry.add("delta_eta/track_eta", "eta", kTH1F, {etaAxis}); + histogramRegistry.add("delta_eta/pos", "delta_eta vs fpos", kTProfile, {deltaEtaAxis}); + histogramRegistry.add("delta_eta/neg", "delta_eta vs fneg", kTProfile, {deltaEtaAxis}); + histogramRegistry.add("delta_eta/termp", "delta_eta vs termp", kTProfile, {deltaEtaAxis}); + histogramRegistry.add("delta_eta/termn", "delta_eta vs termn", kTProfile, {deltaEtaAxis}); + histogramRegistry.add("delta_eta/pos_sq", "delta_eta vs sqfpos", kTProfile, {deltaEtaAxis}); + histogramRegistry.add("delta_eta/neg_sq", "delta_eta vs sqfneg", kTProfile, {deltaEtaAxis}); + histogramRegistry.add("delta_eta/posneg", "delta_eta vs fpos*fneg", kTProfile, {deltaEtaAxis}); + + histogramRegistry.add("cent/pos", "cent vs fpos", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/neg", "cent vs fneg", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/termp", "cent vs termp", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/termn", "cent vs termn", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/pos_sq", "cent vs sqfpos", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/neg_sq", "cent vs sqfneg", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/posneg", "cent vs fpos*fneg", kTProfile, {cent1Axis}); + + histogramRegistry.add("cent/gen_pos", "cent vs fpos", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/gen_neg", "cent vs fneg", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/gen_termp", "cent vs termp", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/gen_termn", "cent vs termn", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/gen_pos_sq", "cent vs sqfpos", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/gen_neg_sq", "cent vs sqfneg", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/gen_posneg", "cent vs fpos*fneg", kTProfile, {cent1Axis}); + histogramRegistry.add("cent/gen_nch", "cent vs nch", kTProfile, {centAxis}); + + histogramRegistry.add("cor/hPt_cor", "", kTH1F, {ptAxis}); + histogramRegistry.add("cor/hEta_cor", "", kTH1F, {etaAxis}); + histogramRegistry.add("cor/nch_vs_nchCor", "", kTProfile, {nchAxis}); + histogramRegistry.add("cor/nchCor", "", kTH1F, {nchAxis}); + histogramRegistry.add("cor/cent_nchCor", "", kTH2F, {centAxis, nchAxis}); + histogramRegistry.add("cor/fpos_cent", "", kTProfile, {centAxis}); + histogramRegistry.add("cor/fneg_cent", "", kTProfile, {centAxis}); + + histogramRegistry.add("subsample/pos", "", kTProfile2D, {cent1Axis, subsampleAxis}); + histogramRegistry.add("subsample/neg", "", kTProfile2D, {cent1Axis, subsampleAxis}); + histogramRegistry.add("subsample/termp", "", kTProfile2D, {cent1Axis, subsampleAxis}); + histogramRegistry.add("subsample/termn", "", kTProfile2D, {cent1Axis, subsampleAxis}); + histogramRegistry.add("subsample/pos_sq", "", kTProfile2D, {cent1Axis, subsampleAxis}); + histogramRegistry.add("subsample/neg_sq", "", kTProfile2D, {cent1Axis, subsampleAxis}); + histogramRegistry.add("subsample/posneg", "", kTProfile2D, {cent1Axis, subsampleAxis}); + + if (cfgLoadEff) { + ccdb->setURL(cfgUrlCCDB.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + // ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + // LOGF(info, "Getting object %s", ccdbPath.value.data()); + + TList* list = ccdb->getForTimeStamp(cfgPathCCDB.value, -1); + efficiency = reinterpret_cast(list->FindObject("efficiency_Run3")); + if (!efficiency) { + LOGF(info, "FATAL!! Could not find required histograms in CCDB"); + } + } + } + + template + bool selCollision(C const& coll, float& cent, float& mult) + { + + if (std::abs(coll.posZ()) > vertexZcut) + return false; + + if constexpr (run == kRun3) { + if (cSel8Trig && !coll.sel8()) { + return false; + } // require min bias trigger + cent = coll.centFT0M(); // centrality for run3 + mult = coll.multFT0M(); // multiplicity for run3 + } else if constexpr (run == kRun2) { + if (cInt7Trig && !coll.alias_bit(kINT7)) { + return false; + } + if (cSel7Trig && !coll.sel7()) { + return false; + } + cent = coll.centRun2V0M(); // centrality for run2 + mult = coll.multFV0M(); // multiplicity for run2 + } + + if (cNoItsROBorder && !coll.selection_bit(aod::evsel::kNoITSROFrameBorder)) + return false; + if (cTFBorder && !coll.selection_bit(aod::evsel::kNoTimeFrameBorder)) + return false; + if (cPileupReject && !coll.selection_bit(aod::evsel::kNoSameBunchPileup)) + return false; + if (cZVtxTimeDiff && !coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) + return false; + if (cItsTpcVtx && !coll.selection_bit(aod::evsel::kIsVertexITSTPC)) + return false; + if (cfgUseGoodItsLayerAllCut && !(coll.selection_bit(aod::evsel::kIsGoodITSLayersAll))) + return false; + + return true; + } + + template + void fillBeforeQA(T const& track) + { + histogramRegistry.fill(HIST("data/hTPCchi2perCluster_before"), track.tpcChi2NCl()); + histogramRegistry.fill(HIST("data/hITSchi2perCluster_before"), track.itsChi2NCl()); + histogramRegistry.fill(HIST("data/hTPCCrossedrows_before"), track.tpcNClsCrossedRows()); + histogramRegistry.fill(HIST("data/hDcaXY_before"), track.dcaXY()); + histogramRegistry.fill(HIST("data/hDcaZ_before"), track.dcaZ()); + histogramRegistry.fill(HIST("data/hPtDcaXY_before"), track.pt(), track.dcaXY()); + histogramRegistry.fill(HIST("data/hPtDcaZ_before"), track.pt(), track.dcaZ()); + } + + template + void fillAfterQA(T const& track) + { + histogramRegistry.fill(HIST("data/hDcaXY_after"), track.dcaXY()); + histogramRegistry.fill(HIST("data/hDcaZ_after"), track.dcaZ()); + histogramRegistry.fill(HIST("data/hPt"), track.pt()); + histogramRegistry.fill(HIST("data/hEta"), track.eta()); + histogramRegistry.fill(HIST("data/hPt_eta"), track.pt(), track.eta()); + histogramRegistry.fill(HIST("data/hPtDcaXY_after"), track.pt(), track.dcaXY()); + histogramRegistry.fill(HIST("data/hPtDcaZ_after"), track.pt(), track.dcaZ()); + histogramRegistry.fill(HIST("data/hTPCCrossedrows_after"), track.tpcNClsCrossedRows()); + histogramRegistry.fill(HIST("data/hTPCchi2perCluster_after"), track.tpcChi2NCl()); + histogramRegistry.fill(HIST("data/hITSchi2perCluster_after"), track.itsChi2NCl()); + } + + template + bool selTrack(T const& track) + { + if (!track.isGlobalTrack()) + return false; + if (std::fabs(track.eta()) >= etaCut) + return false; + if (track.pt() <= ptMinCut || track.pt() >= ptMaxCut) + return false; + if (track.sign() == 0) + return false; + if (cDcaXy && std::fabs(track.dcaXY()) > dcaXYCut) + return false; + if (cDcaZ && std::fabs(track.dcaZ()) > dcaZCut) + return false; + if (cTpcCr && track.tpcNClsCrossedRows() < tpcCrossCut) + return false; + if (cItsChi && track.itsChi2NCl() > itsChiCut) + return false; + if (cTpcChi && track.tpcChi2NCl() > tpcChiCut) + return false; + + return true; + } + + double getEfficiency(double pt, double eta, TH2D* hEff) + { + if (!hEff) { + LOGF(error, "Efficiency histogram is null — check CCDB loading."); + return 1e-6; + } + int binX = hEff->GetXaxis()->FindBin(pt); + int binY = hEff->GetYaxis()->FindBin(eta); + if (binX < 1 || binX > hEff->GetNbinsX() || binY < 1 || binY > hEff->GetNbinsY()) { + LOGF(warn, "pt or eta out of histogram bounds: pt = %f, eta = %f", pt, eta); + return 1e-6; + } + double eff = hEff->GetBinContent(binX, binY); + return eff; + } + + void fillHistograms(float nch, float cent, float fpos, float fneg, float posneg, float termp, float termn) + { + histogramRegistry.fill(HIST("mult_dist/nch"), nch); + histogramRegistry.fill(HIST("mult_dist/nch_cent"), cent, nch); + histogramRegistry.fill(HIST("mult_dist/nch_pos"), fpos); + histogramRegistry.fill(HIST("mult_dist/nch_pos_cent"), cent, fpos); + histogramRegistry.fill(HIST("mult_dist/nch_neg"), fneg); + histogramRegistry.fill(HIST("mult_dist/nch_neg_cent"), cent, fneg); + histogramRegistry.fill(HIST("mult_dist/nch_negpos"), posneg); + histogramRegistry.fill(HIST("mult_dist/nch_negpos_cent"), cent, posneg); + + histogramRegistry.fill(HIST("cent/pos"), cent, fpos); + histogramRegistry.fill(HIST("cent/neg"), cent, fneg); + histogramRegistry.fill(HIST("cent/termp"), cent, termp); + histogramRegistry.fill(HIST("cent/termn"), cent, termn); + histogramRegistry.fill(HIST("cent/pos_sq"), cent, fpos * fpos); + histogramRegistry.fill(HIST("cent/neg_sq"), cent, fneg * fneg); + histogramRegistry.fill(HIST("cent/posneg"), cent, posneg); + + float lRandom = fRndm->Rndm(); + int sampleIndex = static_cast(cfgNSubsample * lRandom); + + histogramRegistry.fill(HIST("subsample/pos"), cent, sampleIndex, fpos); + histogramRegistry.fill(HIST("subsample/neg"), cent, sampleIndex, fneg); + histogramRegistry.fill(HIST("subsample/termp"), cent, sampleIndex, termp); + histogramRegistry.fill(HIST("subsample/termn"), cent, sampleIndex, termn); + histogramRegistry.fill(HIST("subsample/pos_sq"), cent, sampleIndex, fpos * fpos); + histogramRegistry.fill(HIST("subsample/neg_sq"), cent, sampleIndex, fneg * fneg); + histogramRegistry.fill(HIST("subsample/posneg"), cent, sampleIndex, posneg); + } + + template + void calculationData(C const& coll, T const& tracks) + { + float cent = -1, mult = -1; + histogramRegistry.fill(HIST("data/hVtxZ_before"), coll.posZ()); + if (!selCollision(coll, cent, mult)) { + return; + } + histogramRegistry.fill(HIST("data/hVtxZ_after"), coll.posZ()); + histogramRegistry.fill(HIST("data/hCentrality"), cent); + histogramRegistry.fill(HIST("data/hMultiplicity"), mult); + + int fpos = 0, fneg = 0, posneg = 0, termn = 0, termp = 0; + int nch = 0, nchCor = 0; + double posWeight = 0, negWeight = 0; + for (const auto& track : tracks) { + fillBeforeQA(track); + if (!selTrack(track)) + continue; + nch += 1; + fillAfterQA(track); + histogramRegistry.fill(HIST("data/hEta_cent"), cent, track.eta()); + histogramRegistry.fill(HIST("data/hPt_cent"), cent, track.pt()); + + double eff = getEfficiency(track.pt(), track.eta(), efficiency); + if (eff < threshold) + continue; + double weight = 1.0 / eff; + + histogramRegistry.fill(HIST("cor/hPt_cor"), track.pt(), weight); + histogramRegistry.fill(HIST("cor/hEta_cor"), track.eta(), weight); + + nchCor += weight; + if (track.sign() == 1) { + fpos += 1; + posWeight += weight; + } else if (track.sign() == -1) { + fneg += 1; + negWeight += weight; + } + + } // track + termp = fpos * (fpos - 1); + termn = fneg * (fneg - 1); + posneg = fpos * fneg; + histogramRegistry.fill(HIST("cor/nch_vs_nchCor"), nch, nchCor); + histogramRegistry.fill(HIST("cor/nchCor"), nchCor); + histogramRegistry.fill(HIST("cor/cent_nchCor"), cent, nchCor); + histogramRegistry.fill(HIST("cor/fpos_cent"), cent, posWeight); + histogramRegistry.fill(HIST("cor/fneg_cent"), cent, negWeight); + fillHistograms(nch, cent, fpos, fneg, posneg, termp, termn); + } + + template + void calculationMc(C const& coll, T const& inputTracks, M const& mcCollisions, P const& mcParticles) + { + (void)mcCollisions; + if (!coll.has_mcCollision()) { + return; + } + histogramRegistry.fill(HIST("gen/hVtxZ_before"), coll.mcCollision().posZ()); + float cent = -1, mult = -1; + histogramRegistry.fill(HIST("data/hVtxZ_before"), coll.posZ()); + if (!selCollision(coll, cent, mult)) { + return; + } + histogramRegistry.fill(HIST("data/hVtxZ_after"), coll.posZ()); + histogramRegistry.fill(HIST("data/hCentrality"), cent); + histogramRegistry.fill(HIST("data/hMultiplicity"), mult); + + int fpos = 0, fneg = 0, posneg = 0, termn = 0, termp = 0; + int nch = 0, nchCor = 0; + double posRecWeight = 0, negRecWeight = 0; + + for (const auto& track : inputTracks) { + fillBeforeQA(track); + if (!selTrack(track)) + continue; + nch += 1; + fillAfterQA(track); + histogramRegistry.fill(HIST("data/hEta_cent"), cent, track.eta()); + histogramRegistry.fill(HIST("data/hPt_cent"), cent, track.pt()); + + double eff = getEfficiency(track.pt(), track.eta(), efficiency); + if (eff < threshold) + continue; + double weight = 1.0 / eff; + histogramRegistry.fill(HIST("cor/hPt_cor"), track.pt(), weight); + histogramRegistry.fill(HIST("cor/hEta_cor"), track.eta(), weight); + nchCor += weight; + + if (track.sign() == 1) { + fpos += 1; + posRecWeight += weight; + } else if (track.sign() == -1) { + fneg += 1; + negRecWeight += weight; + } + } // track + termp = fpos * (fpos - 1); + + termn = fneg * (fneg - 1); + + posneg = fpos * fneg; + histogramRegistry.fill(HIST("cor/nch_vs_nchCor"), nch, nchCor); + histogramRegistry.fill(HIST("cor/nchCor"), nchCor); + histogramRegistry.fill(HIST("cor/cent_nchCor"), cent, nchCor); + histogramRegistry.fill(HIST("cor/fpos_cent"), cent, posRecWeight); + histogramRegistry.fill(HIST("cor/fneg_cent"), cent, negRecWeight); + + fillHistograms(nch, cent, fpos, fneg, posneg, termp, termn); + + int posGen = 0, negGen = 0, posNegGen = 0, termNGen = 0, termPGen = 0, nchGen = 0; + + const auto& mccolgen = coll.template mcCollision_as(); + if (std::abs(mccolgen.posZ()) > vertexZcut) + return; + const auto& mcpartgen = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mccolgen.globalIndex(), cache); + histogramRegistry.fill(HIST("gen/hVtxZ_after"), mccolgen.posZ()); + for (const auto& mcpart : mcpartgen) { + if (!mcpart.isPhysicalPrimary()) + continue; + int pid = mcpart.pdgCode(); + auto sign = 0; + auto* pd = pdgService->GetParticle(pid); + if (pd != nullptr) { + sign = pd->Charge() / 3.; + } + if (sign == 0) + continue; + if (std::abs(pid) != kElectron && std::abs(pid) != kMuonMinus && std::abs(pid) != kPiPlus && std::abs(pid) != kKPlus && std::abs(pid) != kProton) + continue; + if (std::fabs(mcpart.eta()) > etaCut) + continue; + if ((mcpart.pt() <= ptMinCut) || (mcpart.pt() >= ptMaxCut)) + continue; + histogramRegistry.fill(HIST("gen/hPt"), mcpart.pt()); + histogramRegistry.fill(HIST("gen/hPt_cent"), cent, mcpart.pt()); + histogramRegistry.fill(HIST("gen/hEta"), mcpart.eta()); + histogramRegistry.fill(HIST("gen/hEta_cent"), cent, mcpart.eta()); + histogramRegistry.fill(HIST("gen/hSign"), sign); + histogramRegistry.fill(HIST("gen/hPt_eta"), mcpart.pt(), mcpart.eta()); + nchGen += 1; + if (sign == 1) { + posGen += 1; + } + if (sign == -1) { + negGen += 1; + } + } // particle + termPGen = posGen * (posGen - 1); + termNGen = negGen * (negGen - 1); + posNegGen = posGen * negGen; + histogramRegistry.fill(HIST("cent/gen_pos"), cent, posGen); + histogramRegistry.fill(HIST("cent/gen_neg"), cent, negGen); + histogramRegistry.fill(HIST("cent/gen_termp"), cent, termPGen); + histogramRegistry.fill(HIST("cent/gen_termn"), cent, termNGen); + histogramRegistry.fill(HIST("cent/gen_pos_sq"), cent, posGen * posGen); + histogramRegistry.fill(HIST("cent/gen_neg_sq"), cent, negGen * negGen); + histogramRegistry.fill(HIST("cent/gen_posneg"), cent, posNegGen); + histogramRegistry.fill(HIST("cent/gen_nch"), cent, nchGen); + histogramRegistry.fill(HIST("gen/nch"), nchGen); + + } // void + + template + void calculationDeltaEta(C const& coll, T const& tracks, float deta1, float deta2) + { + float cent = -1, mult = -1; + if (!selCollision(coll, cent, mult)) + return; + if (!(cent >= centMin && cent < centMax)) + return; + histogramRegistry.fill(HIST("delta_eta/cent"), cent); + + int fpos = 0, fneg = 0, posneg = 0, termn = 0, termp = 0; + for (const auto& track : tracks) { + if (!selTrack(track)) + continue; + double eta = track.eta(); + if (eta < deta1 || eta > deta2) + continue; + + histogramRegistry.fill(HIST("delta_eta/track_eta"), eta); + + if (track.sign() == 1) + fpos++; + else if (track.sign() == -1) + fneg++; + } + termp = fpos * (fpos - 1); + termn = fneg * (fneg - 1); + posneg = fpos * fneg; + + float deltaEtaWidth = deta2 - deta1 + 1e-5f; + + histogramRegistry.fill(HIST("delta_eta/pos"), deltaEtaWidth, fpos); + histogramRegistry.fill(HIST("delta_eta/neg"), deltaEtaWidth, fneg); + histogramRegistry.fill(HIST("delta_eta/termp"), deltaEtaWidth, termp); + histogramRegistry.fill(HIST("delta_eta/termn"), deltaEtaWidth, termn); + histogramRegistry.fill(HIST("delta_eta/pos_sq"), deltaEtaWidth, fpos * fpos); + histogramRegistry.fill(HIST("delta_eta/neg_sq"), deltaEtaWidth, fneg * fneg); + histogramRegistry.fill(HIST("delta_eta/posneg"), deltaEtaWidth, posneg); + } + + SliceCache cache; + Preslice mcTrack = o2::aod::mcparticle::mcCollisionId; + + // process function for Data Run3 + void processDataRun3(aod::MyCollisionRun3 const& coll, aod::MyTracks const& tracks) + { + calculationData(coll, tracks); + for (int ii = 0; ii < deltaEta; ii++) { + float etaMin = -0.1f * (ii + 1); + float etaMax = 0.1f * (ii + 1); + + calculationDeltaEta(coll, tracks, etaMin, etaMax); + } + } + + PROCESS_SWITCH(NetchargeFluctuations, processDataRun3, "Process for Run3 DATA", false); + + // process function for Data Run2 + void processDataRun2(aod::MyCollisionRun2 const& coll, aod::MyTracks const& tracks) + { + calculationData(coll, tracks); + for (int ii = 0; ii < deltaEta; ii++) { + float etaMin = -0.1f * (ii + 1); // -0.1, -0.2, ..., -0.8 + float etaMax = 0.1f * (ii + 1); // +0.1, +0.2, ..., +0.8 + + calculationDeltaEta(coll, tracks, etaMin, etaMax); + } + } + + PROCESS_SWITCH(NetchargeFluctuations, processDataRun2, "Process for Run2 DATA", false); + + // process function for MC Run3 + + void processMcRun3(aod::MyMCCollisionRun3 const& coll, aod::MyMCTracks const& inputTracks, + aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) + { + calculationMc(coll, inputTracks, mcCollisions, mcParticles); + + for (int ii = 0; ii < deltaEta; ii++) { + float etaMin = -0.1f * (ii + 1); + float etaMax = 0.1f * (ii + 1); + + calculationDeltaEta(coll, inputTracks, etaMin, etaMax); + } + } + + PROCESS_SWITCH(NetchargeFluctuations, processMcRun3, "Process reconstructed", false); + + // process function for MC Run2 + + void processMcRun2(aod::MyMCCollisionRun2 const& coll, aod::MyMCTracks const& inputTracks, + aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) + { + calculationMc(coll, inputTracks, mcCollisions, mcParticles); + for (int ii = 0; ii < deltaEta; ii++) { + float etaMin = -0.1f * (ii + 1); // -0.1, -0.2, ..., -0.8 + float etaMax = 0.1f * (ii + 1); // +0.1, +0.2, ..., +0.8 + + calculationDeltaEta(coll, inputTracks, etaMin, etaMax); + } + } + + PROCESS_SWITCH(NetchargeFluctuations, processMcRun2, "Process reconstructed", true); +}; + +// struct +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + {adaptAnalysisTask(cfgc)}}; +} diff --git a/PWGCF/EbyEFluctuations/Tasks/netprotonCumulantsMc.cxx b/PWGCF/EbyEFluctuations/Tasks/netprotonCumulantsMc.cxx new file mode 100644 index 00000000000..36a797a17a9 --- /dev/null +++ b/PWGCF/EbyEFluctuations/Tasks/netprotonCumulantsMc.cxx @@ -0,0 +1,2949 @@ +// 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. + +/// \file netprotonCumulantsMc.cxx +/// \brief Task for analyzing efficiency of proton, and net-proton distributions in MC reconstructed and generated, and calculating net-proton cumulants +/// \author Swati Saha + +#include +#include +#include +#include +#include +#include +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/StepTHn.h" +#include "ReconstructionDataFormats/Track.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/Core/trackUtilities.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct NetprotonCumulantsMc { + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + // MC + Configurable cfgIsMC{"cfgIsMC", true, "Run MC"}; + // tracks + Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtUpper{"cfgCutPtUpper", 3.0f, "Higher pT cut"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; + Configurable cfgPIDchoice{"cfgPIDchoice", 1, "PID selection fucntion choice"}; + Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; + Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; + Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; + Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; + Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; + Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; + Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; + Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; + Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; + Configurable cfgUseItsPid{"cfgUseItsPid", true, "Use ITS nSigma Cut"}; + + // Calculation of cumulants central/error + Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples for ERR"}; + Configurable cfgIsCalculateCentral{"cfgIsCalculateCentral", true, "Calculate Central value"}; + Configurable cfgIsCalculateError{"cfgIsCalculateError", false, "Calculate Error"}; + + // Efficiencies + Configurable> cfgPtBins{"cfgPtBins", {0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0}, "Pt Bins for Efficiency of protons"}; + Configurable> cfgProtonEff{"cfgProtonEff", {0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9}, "Efficiency of protons"}; + Configurable> cfgAntiprotonEff{"cfgAntiprotonEff", {0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9}, "Efficiency of anti-protons"}; + + Configurable cfgLoadEff{"cfgLoadEff", true, "Load efficiency from file"}; + Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; + Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; + Configurable cfgIfRejectElectron{"cfgIfRejectElectron", true, "Remove electrons"}; + Configurable cfgIfMandatoryTOF{"cfgIfMandatoryTOF", true, "Mandatory TOF requirement to remove pileup"}; + Configurable cfgEvSelkIsVertexTOFmatched{"cfgEvSelkIsVertexTOFmatched", true, "If matched with TOF, for pileup"}; + ConfigurableAxis cfgCentralityBins{"cfgCentralityBins", {90, 0., 90.}, "Centrality/Multiplicity percentile bining"}; + + // Connect to ccdb + Service ccdb; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable ccdbUrl{"ccdbUrl", "https://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPath{"ccdbPath", "Users/s/swati/EtavsPtEfficiency_LHC24f3b_PIDchoice0", "CCDB path to ccdb object containing eff(pt, eta) in 2D hist"}; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + TRandom3* fRndm = new TRandom3(0); + + // Eff histograms 2d: eff(pT, eta) + TH2F* hRatio2DEtaVsPtProton = nullptr; + TH2F* hRatio2DEtaVsPtAntiproton = nullptr; + + // Filter command for rec (data)*********** + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < 5.0f) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy); + + // filtering collisions and tracks for real data*********** + using AodCollisions = soa::Filtered>; + using AodTracks = soa::Filtered>; + + // filtering collisions and tracks for MC rec data*********** + using MyMCRecCollisions = soa::Filtered>; + using MyMCRecCollision = MyMCRecCollisions::iterator; + using MyMCTracks = soa::Filtered>; + using EventCandidatesMC = soa::Join; + + // Equivalent of the AliRoot task UserCreateOutputObjects + void init(o2::framework::InitContext&) + { + // Loading efficiency histograms from ccdb + if (cfgLoadEff) { + + // Accessing eff histograms + ccdb->setURL(ccdbUrl.value); + // Enabling object caching, otherwise each call goes to the CCDB server + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + // Not later than now, will be replaced by the value of the train creation + // This avoids that users can replace objects **while** a train is running + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + LOGF(info, "Getting object %s", ccdbPath.value.data()); + TList* lst = ccdb->getForTimeStamp(ccdbPath.value, ccdbNoLaterThan.value); + hRatio2DEtaVsPtProton = reinterpret_cast(lst->FindObject("hRatio2DEtaVsPtProton")); + hRatio2DEtaVsPtAntiproton = reinterpret_cast(lst->FindObject("hRatio2DEtaVsPtAntiproton")); + if (!hRatio2DEtaVsPtProton || !hRatio2DEtaVsPtAntiproton) + LOGF(info, "FATAL!! could not get efficiency---------> check"); + } + + // Define your axes + // Constant bin width axis + AxisSpec vtxZAxis = {100, -20, 20}; + // Variable bin width axis + std::vector ptBinning = {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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0}; + AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/#it{c})"}; + std::vector etaBinning = {-0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; + AxisSpec etaAxis = {etaBinning, "#it{#eta}"}; + // std::vector centBining = {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90}; + // AxisSpec centAxis = {centBining, "Multiplicity percentile from FT0M (%)"}; + const AxisSpec centAxis{cfgCentralityBins, "Multiplicity percentile from FT0M (%)"}; + AxisSpec netprotonAxis = {41, -20.5, 20.5, "net-proton number"}; + AxisSpec protonAxis = {21, -0.5, 20.5, "proton number"}; + AxisSpec antiprotonAxis = {21, -0.5, 20.5, "antiproton number"}; + AxisSpec nSigmaAxis = {200, -5.0, 5.0, "nSigma(Proton)"}; + + auto noSubsample = static_cast(cfgNSubsample); + float maxSubsample = 1.0 * noSubsample; + AxisSpec subsampleAxis = {noSubsample, 0.0, maxSubsample, "subsample no."}; + + // histograms for events + histos.add("hZvtx_after_sel", "Vertex dist. after event selection;Z (cm)", kTH1F, {vtxZAxis}); + histos.add("hCentrec", "MCRec Multiplicity percentile from FT0M (%)", kTH1F, {{100, 0.0, 100.0}}); + // tracks Rec level histograms + histos.add("hrecPtAll", "Reconstructed All particles;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPtProton", "Reconstructed Protons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPtAntiproton", "Reconstructed Antiprotons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPhiAll", "Reconstructed All particles;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hrecPhiProton", "Reconstructed Protons;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hrecPhiAntiproton", "Reconstructed Antiprotons;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hrecEtaAll", "Reconstructed All particles;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hrecEtaProton", "Reconstructed Proton;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hrecEtaAntiproton", "Reconstructed Antiprotons;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hrecDcaXYAll", "Reconstructed All particles;DCA_{xy} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaXYProton", "Reconstructed Proton;DCA_{xy} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaXYAntiproton", "Reconstructed Antiprotons;DCA_{xy} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaZAll", "Reconstructed All particles;DCA_{z} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaZProton", "Reconstructed Proton;DCA_{z} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecDcaZAntiproton", "Reconstructed Antiprotons;DCA_{z} (in cm)", kTH1F, {{400, -2.0, 2.0}}); + histos.add("hrecPtDistProtonVsCentrality", "Reconstructed proton number vs centrality in 2D", kTH2F, {ptAxis, centAxis}); + histos.add("hrecPtDistAntiprotonVsCentrality", "Reconstructed antiproton number vs centrality in 2D", kTH2F, {ptAxis, centAxis}); + histos.add("hrecNetProtonVsCentrality", "Reconstructed net-proton number vs centrality in 2D", kTH2F, {netprotonAxis, centAxis}); + histos.add("hrecProtonVsCentrality", "Reconstructed proton number vs centrality in 2D", kTH2F, {protonAxis, centAxis}); + histos.add("hrecAntiprotonVsCentrality", "Reconstructed antiproton number vs centrality in 2D", kTH2F, {antiprotonAxis, centAxis}); + histos.add("hrecProfileTotalProton", "Reconstructed total proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hrecProfileProton", "Reconstructed proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hrecProfileAntiproton", "Reconstructed antiproton number vs. centrality", kTProfile, {centAxis}); + histos.add("hCorrProfileTotalProton", "Eff. Corrected total proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hCorrProfileProton", "Eff. Corrected proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hCorrProfileAntiproton", "Eff. Corrected antiproton number vs. centrality", kTProfile, {centAxis}); + histos.add("hrec2DEtaVsPtProton", "2D hist of Reconstructed Proton y: eta vs. x: pT", kTH2F, {ptAxis, etaAxis}); + histos.add("hrec2DEtaVsPtAntiproton", "2D hist of Reconstructed Anti-proton y: eta vs. x: pT", kTH2F, {ptAxis, etaAxis}); + histos.add("hgen2DEtaVsPtProton", "2D hist of Generated Proton y: eta vs. x: pT", kTH2F, {ptAxis, etaAxis}); + histos.add("hgen2DEtaVsPtAntiproton", "2D hist of Generated Anti-proton y: eta vs. x: pT", kTH2F, {ptAxis, etaAxis}); + + // 2D histograms of nSigma + histos.add("h2DnsigmaTpcVsPt", "2D hist of nSigmaTPC vs. pT", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaTofVsPt", "2D hist of nSigmaTOF vs. pT", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaItsVsPt", "2D hist of nSigmaITS vs. pT", kTH2F, {ptAxis, nSigmaAxis}); + + if (cfgIsCalculateCentral) { + // uncorrected + histos.add("Prof_mu1_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu2_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu3_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu4_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu5_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu6_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu7_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_mu8_netproton", "", {HistType::kTProfile, {centAxis}}); + + // eff. corrected + histos.add("Prof_Q11_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_3", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_4", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q21_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q22_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q31_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q32_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q33_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q41_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q42_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q43_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q44_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q21_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q22_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3132_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3132_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3132_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3133_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3133_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3133_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3233_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3233_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q3233_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2241_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2241_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2241_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2242_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2242_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2242_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2243_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2243_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2243_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2244_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2244_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2244_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2141_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2141_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2141_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2142_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2142_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2142_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2143_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2143_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2143_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2144_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2144_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2144_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1151_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1151_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1151_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1152_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1152_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1152_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1153_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1153_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1153_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1154_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1154_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1154_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1155_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1155_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1155_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2221_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2122_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_02", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_12", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_22", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_02", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_12", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_22", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_200", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_201", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_210", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_211", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1131_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1132_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1133_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_5", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q11_6", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_40", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1121_41", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_30", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_31", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_40", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1122_41", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2211_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2111_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_001", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_010", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_100", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_011", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_101", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_110", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1141_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1142_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1143_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_20", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q1144_21", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2131_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2131_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2131_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2132_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2132_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2132_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2133_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2133_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2133_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2231_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2231_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2231_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2232_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2232_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2232_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2233_11", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2233_01", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q2233_10", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q51_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q52_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q53_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q54_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q55_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q21_3", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q22_3", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q31_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q32_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q33_2", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q61_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q62_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q63_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q64_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q65_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q66_1", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112122_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112131_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112132_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112133_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112231_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112232_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112233_111", "", {HistType::kTProfile, {centAxis}}); + histos.add("Prof_Q112221_111", "", {HistType::kTProfile, {centAxis}}); + } + + if (cfgIsCalculateError) { + // uncorrected + histos.add("Prof2D_mu1_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu2_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu3_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu4_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu5_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu6_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu7_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_mu8_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + + // eff. corrected + histos.add("Prof2D_Q11_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_3", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_4", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q21_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q22_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q31_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q32_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q33_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q41_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q42_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q43_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q44_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q21_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q22_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3132_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3132_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3132_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3133_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3133_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3133_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3233_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3233_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q3233_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2241_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2241_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2241_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2242_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2242_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2242_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2243_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2243_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2243_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2244_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2244_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2244_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2141_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2141_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2141_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2142_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2142_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2142_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2143_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2143_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2143_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2144_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2144_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2144_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1151_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1151_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1151_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1152_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1152_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1152_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1153_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1153_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1153_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1154_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1154_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1154_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1155_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1155_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1155_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2221_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2122_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_02", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_12", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_22", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_02", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_12", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_22", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_200", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_201", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_210", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_211", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1131_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1132_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1133_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_5", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q11_6", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_40", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1121_41", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_30", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_31", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_40", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1122_41", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2211_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2111_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_001", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_010", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_100", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_011", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_101", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_110", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1141_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1142_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1143_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_20", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q1144_21", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2131_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2131_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2131_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2132_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2132_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2132_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2133_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2133_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2133_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2231_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2231_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2231_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2232_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2232_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2232_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2233_11", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2233_01", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q2233_10", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q51_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q52_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q53_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q54_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q55_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q21_3", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q22_3", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q31_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q32_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q33_2", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q61_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q62_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q63_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q64_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q65_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q66_1", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112122_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112131_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112132_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112133_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112231_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112232_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112233_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("Prof2D_Q112221_111", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + } + + if (cfgIsMC) { + // MC event counts + histos.add("hMC", "MC Event statistics", kTH1F, {{10, 0.0f, 10.0f}}); + histos.add("hCentgen", "MCGen Multiplicity percentile from FT0M (%)", kTH1F, {{100, 0.0, 100.0}}); + // tracks Gen level histograms + histos.add("hgenPtAll", "Generated All particles;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hgenPtProton", "Generated Protons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hgenPtAntiproton", "Generated Antiprotons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPartPtAll", "Reconstructed All particles filled mcparticle pt;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPartPtProton", "Reconstructed Protons filled mcparticle pt;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecPartPtAntiproton", "Reconstructed Antiprotons filled mcparticle pt;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hgenPhiAll", "Generated All particles;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hgenPhiProton", "Generated Protons;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hgenPhiAntiproton", "Generated Antiprotons;#phi", kTH1F, {{100, 0., 7.}}); + histos.add("hgenEtaAll", "Generated All particles;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hgenEtaProton", "Generated Proton;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hgenEtaAntiproton", "Generated Antiprotons;#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hgenPtDistProtonVsCentrality", "Generated proton number vs centrality in 2D", kTH2F, {ptAxis, centAxis}); + histos.add("hgenPtDistAntiprotonVsCentrality", "Generated antiproton number vs centrality in 2D", kTH2F, {ptAxis, centAxis}); + histos.add("hrecTruePtProton", "Reconstructed pdgcode verified protons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hrecTruePtAntiproton", "Reconstructed pdgcode verified Antiprotons;#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hgenNetProtonVsCentrality", "Generated net-proton number vs centrality in 2D", kTH2F, {netprotonAxis, centAxis}); + histos.add("hgenProtonVsCentrality", "Generated proton number vs centrality in 2D", kTH2F, {protonAxis, centAxis}); + histos.add("hgenAntiprotonVsCentrality", "Generated antiproton number vs centrality in 2D", kTH2F, {antiprotonAxis, centAxis}); + histos.add("hgenProfileTotalProton", "Generated total proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hgenProfileProton", "Generated proton number vs. centrality", kTProfile, {centAxis}); + histos.add("hgenProfileAntiproton", "Generated antiproton number vs. centrality", kTProfile, {centAxis}); + + if (cfgIsCalculateCentral) { + histos.add("GenProf_mu1_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu2_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu3_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu4_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu5_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu6_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu7_netproton", "", {HistType::kTProfile, {centAxis}}); + histos.add("GenProf_mu8_netproton", "", {HistType::kTProfile, {centAxis}}); + } + + if (cfgIsCalculateError) { + histos.add("GenProf2D_mu1_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu2_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu3_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu4_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu5_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu6_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu7_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + histos.add("GenProf2D_mu8_netproton", "", {HistType::kTProfile2D, {centAxis, subsampleAxis}}); + } + } + } // end init() + + template + bool selectionPIDold(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + + //! PID checking as done in Run2 my analysis + //! ---------------------------------------------------------------------- + int flag = 0; //! pid check main flag + + if (candidate.pt() > 0.2f && candidate.pt() <= cfgCutPtUpperTPC) { + if (std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < 5.0f) { + const float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + const float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + const float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < 3.0) + flag2 += 1; + if (combNSigmaPi < 3.0) + flag2 += 1; + if (combNSigmaKa < 3.0) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { + if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + template + bool selectionPIDoldTOFveto(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + + //! PID checking as done in Run2 my analysis + //! ---------------------------------------------------------------------- + int flag = 0; //! pid check main flag + + if (candidate.pt() > 0.2f && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < 5.0f) { + const float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + const float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + const float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < 3.0) + flag2 += 1; + if (combNSigmaPi < 3.0) + flag2 += 1; + if (combNSigmaKa < 3.0) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { + if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + // electron rejection function + template + bool isElectron(const T& candidate) // Victor's BF analysis + { + if (candidate.tpcNSigmaEl() > -3.0f && candidate.tpcNSigmaEl() < 5.0f && std::abs(candidate.tpcNSigmaPi()) > 3.0f && std::abs(candidate.tpcNSigmaKa()) > 3.0f && std::abs(candidate.tpcNSigmaPr()) > 3.0f) { + return true; + } + return false; + } + + template + bool selectionPIDnew(const T& candidate) // Victor's BF analysis + { + // electron rejection + if (candidate.tpcNSigmaEl() > -3.0f && candidate.tpcNSigmaEl() < 5.0f && std::abs(candidate.tpcNSigmaPi()) > 3.0f && std::abs(candidate.tpcNSigmaKa()) > 3.0f && std::abs(candidate.tpcNSigmaPr()) > 3.0f) { + return false; + } + + //! if pt < threshold + if (candidate.pt() > 0.2f && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaPi()) > cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaKa()) > cfgnSigmaCutTPC) { + return true; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaPi()) > cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaKa()) > cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF && std::abs(candidate.tofNSigmaPi()) > cfgnSigmaCutTOF && std::abs(candidate.tofNSigmaKa()) > cfgnSigmaCutTOF) { + return true; + } + } + + //! if pt > threshold + if (candidate.pt() > cfgCutPtUpperTPC) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaPi()) > cfgnSigmaCutTPC && std::abs(candidate.tpcNSigmaKa()) > cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF && std::abs(candidate.tofNSigmaPi()) > cfgnSigmaCutTOF && std::abs(candidate.tofNSigmaKa()) > cfgnSigmaCutTOF) { + return true; + } + } + return false; + } + + // Function to check which pt bin the track lies in and assign the corresponding efficiency + + template + float getEfficiency(const T& candidate) + { + // Load eff from histograms in CCDB + if (cfgLoadEff) { + if (candidate.sign() > 0) { + float effmeanval = hRatio2DEtaVsPtProton->GetBinContent(hRatio2DEtaVsPtProton->FindBin(candidate.pt(), candidate.eta())); + return effmeanval; + } + if (candidate.sign() < 0) { + float effmeanval = hRatio2DEtaVsPtAntiproton->GetBinContent(hRatio2DEtaVsPtAntiproton->FindBin(candidate.pt(), candidate.eta())); + return effmeanval; + } + return 0.0; + } else { + // Find the pt bin index based on the track's pt value + int binIndex = -1; + + for (int i = 0; i < 16; ++i) { + if (candidate.pt() >= cfgPtBins.value[i] && candidate.pt() < cfgPtBins.value[i + 1]) { + binIndex = i; + break; + } + } + // If the pt is outside the defined bins, return a default efficiency or handle it differently + if (binIndex == -1) { + return 0.0; // Default efficiency (0% if outside bins) + } + if (candidate.sign() > 0) + return cfgProtonEff.value[binIndex]; + if (candidate.sign() < 0) + return cfgAntiprotonEff.value[binIndex]; + return 0.0; + } + } + + void processMCGen(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& collisions) + { + histos.fill(HIST("hMC"), 0.5); + if (std::abs(mcCollision.posZ()) < cfgCutVertex) { + histos.fill(HIST("hMC"), 1.5); + } + auto cent = 0; + + int nchInel = 0; + for (const auto& mcParticle : mcParticles) { + auto pdgcode = std::abs(mcParticle.pdgCode()); + if (mcParticle.isPhysicalPrimary() && (pdgcode == PDG_t::kPiPlus || pdgcode == PDG_t::kKPlus || pdgcode == PDG_t::kProton || pdgcode == PDG_t::kElectron || pdgcode == PDG_t::kMuonMinus)) { + if (std::abs(mcParticle.eta()) < 1.0) { + nchInel = nchInel + 1; + } + } + } + if (nchInel > 0 && std::abs(mcCollision.posZ()) < cfgCutVertex) + histos.fill(HIST("hMC"), 2.5); + std::vector selectedEvents(collisions.size()); + int nevts = 0; + + for (const auto& collision : collisions) { + if (!collision.sel8() || std::abs(collision.mcCollision().posZ()) > cfgCutVertex) { + continue; + } + if (cfgUseGoodITSLayerAllCut && !(collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))) { + continue; + } + if (cfgEvSelkNoSameBunchPileup && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + continue; + } + if (cfgEvSelkIsVertexTOFmatched && !(collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched))) { + continue; + } + + cent = collision.centFT0M(); + + selectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); + } + selectedEvents.resize(nevts); + const auto evtReconstructedAndSelected = std::find(selectedEvents.begin(), selectedEvents.end(), mcCollision.globalIndex()) != selectedEvents.end(); + histos.fill(HIST("hMC"), 3.5); + if (!evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection + return; + } + histos.fill(HIST("hMC"), 4.5); + histos.fill(HIST("hCentgen"), cent); + + // creating phi, pt, eta dstribution of generted MC particles + + float nProt = 0.0; + float nAntiprot = 0.0; + + for (const auto& mcParticle : mcParticles) { + if (!mcParticle.has_mcCollision()) + continue; + + if (mcParticle.isPhysicalPrimary()) { + if ((mcParticle.pt() > cfgCutPtLower) && (mcParticle.pt() < 5.0f) && (std::abs(mcParticle.eta()) < cfgCutEta)) { + histos.fill(HIST("hgenPtAll"), mcParticle.pt()); + histos.fill(HIST("hgenEtaAll"), mcParticle.eta()); + histos.fill(HIST("hgenPhiAll"), mcParticle.phi()); + + if (std::abs(mcParticle.pdgCode()) == PDG_t::kProton /*&& std::abs(mcParticle.y()) < 0.5*/) { + if (mcParticle.pdgCode() == PDG_t::kProton) { + histos.fill(HIST("hgenPtProton"), mcParticle.pt()); //! hist for p gen + histos.fill(HIST("hgenPtDistProtonVsCentrality"), mcParticle.pt(), cent); + histos.fill(HIST("hgen2DEtaVsPtProton"), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hgenEtaProton"), mcParticle.eta()); + histos.fill(HIST("hgenPhiProton"), mcParticle.phi()); + if (mcParticle.pt() < cfgCutPtUpper) + nProt = nProt + 1.0; + } + if (mcParticle.pdgCode() == PDG_t::kProtonBar) { + histos.fill(HIST("hgenPtAntiproton"), mcParticle.pt()); //! hist for anti-p gen + histos.fill(HIST("hgenPtDistAntiprotonVsCentrality"), mcParticle.pt(), cent); + histos.fill(HIST("hgen2DEtaVsPtAntiproton"), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hgenEtaAntiproton"), mcParticle.eta()); + histos.fill(HIST("hgenPhiAntiproton"), mcParticle.phi()); + if (mcParticle.pt() < cfgCutPtUpper) + nAntiprot = nAntiprot + 1.0; + } + } + } + } + } //! end particle loop + + float netProt = nProt - nAntiprot; + histos.fill(HIST("hgenNetProtonVsCentrality"), netProt, cent); + histos.fill(HIST("hgenProtonVsCentrality"), nProt, cent); + histos.fill(HIST("hgenAntiprotonVsCentrality"), nAntiprot, cent); + histos.fill(HIST("hgenProfileTotalProton"), cent, (nProt + nAntiprot)); + histos.fill(HIST("hgenProfileProton"), cent, nProt); + histos.fill(HIST("hgenProfileAntiproton"), cent, nAntiprot); + + // Profiles for generated level cumulants + //------------------------------------------------------------------------------------------- + + if (cfgIsCalculateCentral) { + histos.get(HIST("GenProf_mu1_netproton"))->Fill(cent, std::pow(netProt, 1.0)); + histos.get(HIST("GenProf_mu2_netproton"))->Fill(cent, std::pow(netProt, 2.0)); + histos.get(HIST("GenProf_mu3_netproton"))->Fill(cent, std::pow(netProt, 3.0)); + histos.get(HIST("GenProf_mu4_netproton"))->Fill(cent, std::pow(netProt, 4.0)); + histos.get(HIST("GenProf_mu5_netproton"))->Fill(cent, std::pow(netProt, 5.0)); + histos.get(HIST("GenProf_mu6_netproton"))->Fill(cent, std::pow(netProt, 6.0)); + histos.get(HIST("GenProf_mu7_netproton"))->Fill(cent, std::pow(netProt, 7.0)); + histos.get(HIST("GenProf_mu8_netproton"))->Fill(cent, std::pow(netProt, 8.0)); + } + + if (cfgIsCalculateError) { + + float lRandom = fRndm->Rndm(); + int sampleIndex = static_cast(cfgNSubsample * lRandom); + + histos.get(HIST("GenProf2D_mu1_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 1.0)); + histos.get(HIST("GenProf2D_mu2_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 2.0)); + histos.get(HIST("GenProf2D_mu3_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 3.0)); + histos.get(HIST("GenProf2D_mu4_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 4.0)); + histos.get(HIST("GenProf2D_mu5_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 5.0)); + histos.get(HIST("GenProf2D_mu6_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 6.0)); + histos.get(HIST("GenProf2D_mu7_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 7.0)); + histos.get(HIST("GenProf2D_mu8_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 8.0)); + } + //------------------------------------------------------------------------------------------- + } + PROCESS_SWITCH(NetprotonCumulantsMc, processMCGen, "Process Generated", true); + + void processMCRec(MyMCRecCollision const& collision, MyMCTracks const& tracks, aod::McCollisions const&, aod::McParticles const&) + { + if (!collision.has_mcCollision()) { + return; + } + + if (!collision.sel8()) { + return; + } + if (cfgUseGoodITSLayerAllCut && !(collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))) { + return; + } + if (cfgEvSelkNoSameBunchPileup && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + return; + } + if (cfgEvSelkIsVertexTOFmatched && !(collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched))) { + return; + ; + } + + auto cent = collision.centFT0M(); + histos.fill(HIST("hCentrec"), cent); + histos.fill(HIST("hMC"), 5.5); + histos.fill(HIST("hZvtx_after_sel"), collision.posZ()); + + float nProt = 0.0; + float nAntiprot = 0.0; + std::array powerEffProt = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array powerEffAntiprot = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array fTCP0 = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array fTCP1 = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + + o2::aod::ITSResponse itsResponse; + + // Start of the Monte-Carlo reconstructed tracks + for (const auto& track : tracks) { + if (!track.has_collision()) { + continue; + } + + if (!track.has_mcParticle()) //! check if track has corresponding MC particle + { + continue; + } + if (!track.isPVContributor()) //! track check as used in data + { + continue; + } + + auto particle = track.mcParticle(); + if (!particle.has_mcCollision()) + continue; + if ((particle.pt() < cfgCutPtLower) || (particle.pt() > 5.0f) || (std::abs(particle.eta()) > cfgCutEta)) { + continue; + } + if (!(track.itsNCls() > cfgITScluster) || !(track.tpcNClsFound() >= cfgTPCcluster) || !(track.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) { + continue; + } + + if (particle.isPhysicalPrimary()) { + histos.fill(HIST("hrecPartPtAll"), particle.pt()); + histos.fill(HIST("hrecPtAll"), track.pt()); + histos.fill(HIST("hrecEtaAll"), particle.eta()); + histos.fill(HIST("hrecPhiAll"), particle.phi()); + histos.fill(HIST("hrecDcaXYAll"), track.dcaXY()); + histos.fill(HIST("hrecDcaZAll"), track.dcaZ()); + + // rejecting electron + if (cfgIfRejectElectron && isElectron(track)) { + continue; + } + // use ITS pid as well + if (cfgUseItsPid && (std::abs(itsResponse.nSigmaITS(track)) > 3.0)) { + continue; + } + // required tracks with TOF mandatory to avoid pileup + if (cfgIfMandatoryTOF && !track.hasTOF()) { + continue; + } + + bool trackSelected = false; + if (cfgPIDchoice == 0) + trackSelected = selectionPIDoldTOFveto(track); + if (cfgPIDchoice == 1) + trackSelected = selectionPIDnew(track); + if (cfgPIDchoice == 2) + trackSelected = selectionPIDold(track); + + if (trackSelected) { + // filling nSigma distribution + histos.fill(HIST("h2DnsigmaTpcVsPt"), track.pt(), track.tpcNSigmaPr()); + histos.fill(HIST("h2DnsigmaTofVsPt"), track.pt(), track.tofNSigmaPr()); + histos.fill(HIST("h2DnsigmaItsVsPt"), track.pt(), itsResponse.nSigmaITS(track)); + + if (track.sign() > 0) { + histos.fill(HIST("hrecPartPtProton"), particle.pt()); //! hist for p rec + histos.fill(HIST("hrecPtProton"), track.pt()); //! hist for p rec + histos.fill(HIST("hrecPtDistProtonVsCentrality"), particle.pt(), cent); + histos.fill(HIST("hrec2DEtaVsPtProton"), particle.pt(), particle.eta()); + histos.fill(HIST("hrecEtaProton"), particle.eta()); + histos.fill(HIST("hrecPhiProton"), particle.phi()); + histos.fill(HIST("hrecDcaXYProton"), track.dcaXY()); + histos.fill(HIST("hrecDcaZProton"), track.dcaZ()); + if (particle.pt() < cfgCutPtUpper) { + nProt = nProt + 1.0; + float pEff = getEfficiency(track); // get efficiency of track + if (pEff != 0) { + for (int i = 1; i < 7; i++) { + powerEffProt[i] += std::pow(1.0 / pEff, i); + } + } + } + if (particle.pdgCode() == PDG_t::kProton) { + histos.fill(HIST("hrecTruePtProton"), particle.pt()); //! hist for p purity + } + } + if (track.sign() < 0) { + histos.fill(HIST("hrecPartPtAntiproton"), particle.pt()); //! hist for anti-p rec + histos.fill(HIST("hrecPtAntiproton"), track.pt()); //! hist for anti-p rec + histos.fill(HIST("hrecPtDistAntiprotonVsCentrality"), particle.pt(), cent); + histos.fill(HIST("hrec2DEtaVsPtAntiproton"), particle.pt(), particle.eta()); + histos.fill(HIST("hrecEtaAntiproton"), particle.eta()); + histos.fill(HIST("hrecPhiAntiproton"), particle.phi()); + histos.fill(HIST("hrecDcaXYAntiproton"), track.dcaXY()); + histos.fill(HIST("hrecDcaZAntiproton"), track.dcaZ()); + if (particle.pt() < cfgCutPtUpper) { + nAntiprot = nAntiprot + 1.0; + float pEff = getEfficiency(track); // get efficiency of track + if (pEff != 0) { + for (int i = 1; i < 7; i++) { + powerEffAntiprot[i] += std::pow(1.0 / pEff, i); + } + } + } + if (particle.pdgCode() == PDG_t::kProtonBar) { + histos.fill(HIST("hrecTruePtAntiproton"), particle.pt()); //! hist for anti-p purity + } + } + } //! checking PID + } //! checking if primary + } //! end track loop + + float netProt = nProt - nAntiprot; + histos.fill(HIST("hrecNetProtonVsCentrality"), netProt, cent); + histos.fill(HIST("hrecProtonVsCentrality"), nProt, cent); + histos.fill(HIST("hrecAntiprotonVsCentrality"), nAntiprot, cent); + histos.fill(HIST("hrecProfileTotalProton"), cent, (nProt + nAntiprot)); + histos.fill(HIST("hrecProfileProton"), cent, nProt); + histos.fill(HIST("hrecProfileAntiproton"), cent, nAntiprot); + histos.fill(HIST("hCorrProfileTotalProton"), cent, (powerEffProt[1] + powerEffAntiprot[1])); + histos.fill(HIST("hCorrProfileProton"), cent, powerEffProt[1]); + histos.fill(HIST("hCorrProfileAntiproton"), cent, powerEffAntiprot[1]); + + // Calculating q_{r,s} as required + for (int i = 1; i < 7; i++) { + fTCP0[i] = powerEffProt[i] + powerEffAntiprot[i]; + fTCP1[i] = powerEffProt[i] - powerEffAntiprot[i]; + } + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + float fQ11_1 = fTCP1[1]; + float fQ11_2 = std::pow(fTCP1[1], 2); + float fQ11_3 = std::pow(fTCP1[1], 3); + float fQ11_4 = std::pow(fTCP1[1], 4); + float fQ11_5 = std::pow(fTCP1[1], 5); + float fQ11_6 = std::pow(fTCP1[1], 6); + + float fQ21_3 = std::pow(fTCP0[1], 3); + float fQ22_3 = std::pow(fTCP0[2], 3); + float fQ31_2 = std::pow(fTCP1[1], 2); + float fQ32_2 = std::pow(fTCP1[2], 2); + float fQ33_2 = std::pow(fTCP1[3], 2); + + float fQ61_1 = fTCP0[1]; + float fQ62_1 = fTCP0[2]; + float fQ63_1 = fTCP0[3]; + float fQ64_1 = fTCP0[4]; + float fQ65_1 = fTCP0[5]; + float fQ66_1 = fTCP0[6]; + + float fQ112122_111 = fTCP1[1] * fTCP0[1] * fTCP0[2]; + float fQ112131_111 = fTCP1[1] * fTCP0[1] * fTCP1[1]; + float fQ112132_111 = fTCP1[1] * fTCP0[1] * fTCP1[2]; + float fQ112133_111 = fTCP1[1] * fTCP0[1] * fTCP1[3]; + float fQ112231_111 = fTCP1[1] * fTCP0[2] * fTCP1[1]; + float fQ112232_111 = fTCP1[1] * fTCP0[2] * fTCP1[2]; + float fQ112233_111 = fTCP1[1] * fTCP0[2] * fTCP1[3]; + float fQ112221_111 = fTCP1[1] * fTCP0[2] * fTCP0[1]; + + float fQ21_1 = fTCP0[1]; + float fQ22_1 = fTCP0[2]; + float fQ31_1 = fTCP1[1]; + float fQ32_1 = fTCP1[2]; + float fQ33_1 = fTCP1[3]; + float fQ41_1 = fTCP0[1]; + float fQ42_1 = fTCP0[2]; + float fQ43_1 = fTCP0[3]; + float fQ44_1 = fTCP0[4]; + float fQ21_2 = std::pow(fTCP0[1], 2); + float fQ22_2 = std::pow(fTCP0[2], 2); + float fQ1121_11 = fTCP1[1] * fTCP0[1]; + float fQ1121_01 = fTCP0[1]; + float fQ1121_10 = fTCP1[1]; + float fQ1121_20 = std::pow(fTCP1[1], 2); + float fQ1121_21 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ1122_11 = fTCP1[1] * fTCP0[2]; + float fQ1122_01 = fTCP0[2]; + float fQ1122_10 = fTCP1[1]; + float fQ1122_20 = std::pow(fTCP1[1], 2); + float fQ1122_21 = std::pow(fTCP1[1], 2) * fTCP0[2]; + float fQ1131_11 = fTCP1[1] * fTCP1[1]; + float fQ1131_01 = fTCP1[1]; + float fQ1131_10 = fTCP1[1]; + float fQ1132_11 = fTCP1[1] * fTCP1[2]; + float fQ1132_01 = fTCP1[2]; + float fQ1132_10 = fTCP1[1]; + float fQ1133_11 = fTCP1[1] * fTCP1[3]; + float fQ1133_01 = fTCP1[3]; + float fQ1133_10 = fTCP1[1]; + float fQ2122_11 = fTCP0[1] * fTCP0[2]; + float fQ2122_01 = fTCP0[2]; + float fQ2122_10 = fTCP0[1]; + + ///////////////---------------------> + float fQ3132_11 = fTCP1[1] * fTCP1[2]; + float fQ3132_01 = fTCP1[2]; + float fQ3132_10 = fTCP1[1]; + float fQ3133_11 = fTCP1[1] * fTCP1[3]; + float fQ3133_01 = fTCP1[3]; + float fQ3133_10 = fTCP1[1]; + float fQ3233_11 = fTCP1[2] * fTCP1[3]; + float fQ3233_01 = fTCP1[3]; + float fQ3233_10 = fTCP1[2]; + float fQ2241_11 = fTCP0[2] * fTCP0[1]; + float fQ2241_01 = fTCP0[1]; + float fQ2241_10 = fTCP0[2]; + float fQ2242_11 = fTCP0[2] * fTCP0[2]; + float fQ2242_01 = fTCP0[2]; + float fQ2242_10 = fTCP0[2]; + float fQ2243_11 = fTCP0[2] * fTCP0[3]; + float fQ2243_01 = fTCP0[3]; + float fQ2243_10 = fTCP0[2]; + float fQ2244_11 = fTCP0[2] * fTCP0[4]; + float fQ2244_01 = fTCP0[4]; + float fQ2244_10 = fTCP0[2]; + float fQ2141_11 = fTCP0[1] * fTCP0[1]; + float fQ2141_01 = fTCP0[1]; + float fQ2141_10 = fTCP0[1]; + float fQ2142_11 = fTCP0[1] * fTCP0[2]; + float fQ2142_01 = fTCP0[2]; + float fQ2142_10 = fTCP0[1]; + float fQ2143_11 = fTCP0[1] * fTCP0[3]; + float fQ2143_01 = fTCP0[3]; + float fQ2143_10 = fTCP0[1]; + float fQ2144_11 = fTCP0[1] * fTCP0[4]; + float fQ2144_01 = fTCP0[4]; + float fQ2144_10 = fTCP0[1]; + float fQ1151_11 = fTCP1[1] * fTCP1[1]; + float fQ1151_01 = fTCP1[1]; + float fQ1151_10 = fTCP1[1]; + float fQ1152_11 = fTCP1[1] * fTCP1[2]; + float fQ1152_01 = fTCP1[2]; + float fQ1152_10 = fTCP1[1]; + float fQ1153_11 = fTCP1[1] * fTCP1[3]; + float fQ1153_01 = fTCP1[3]; + float fQ1153_10 = fTCP1[1]; + float fQ1154_11 = fTCP1[1] * fTCP1[4]; + float fQ1154_01 = fTCP1[4]; + float fQ1154_10 = fTCP1[1]; + float fQ1155_11 = fTCP1[1] * fTCP1[5]; + float fQ1155_01 = fTCP1[5]; + float fQ1155_10 = fTCP1[1]; + + float fQ112233_001 = fTCP1[3]; + float fQ112233_010 = fTCP0[2]; + float fQ112233_100 = fTCP1[1]; + float fQ112233_011 = fTCP0[2] * fTCP1[3]; + float fQ112233_101 = fTCP1[1] * fTCP1[3]; + float fQ112233_110 = fTCP1[1] * fTCP0[2]; + float fQ112232_001 = fTCP1[2]; + float fQ112232_010 = fTCP0[2]; + float fQ112232_100 = fTCP1[1]; + float fQ112232_011 = fTCP0[2] * fTCP1[2]; + float fQ112232_101 = fTCP1[1] * fTCP1[2]; + float fQ112232_110 = fTCP1[1] * fTCP0[2]; + // + float fQ112231_001 = fTCP1[1]; + float fQ112231_010 = fTCP0[2]; + float fQ112231_100 = fTCP1[1]; + float fQ112231_011 = fTCP0[2] * fTCP1[1]; + float fQ112231_101 = fTCP1[1] * fTCP1[1]; + float fQ112231_110 = fTCP1[1] * fTCP0[2]; + float fQ112133_001 = fTCP1[3]; + float fQ112133_010 = fTCP0[1]; + float fQ112133_100 = fTCP1[1]; + float fQ112133_011 = fTCP0[1] * fTCP1[3]; + float fQ112133_101 = fTCP1[1] * fTCP1[3]; + float fQ112133_110 = fTCP1[1] * fTCP0[1]; + + float fQ112132_001 = fTCP1[2]; + float fQ112132_010 = fTCP0[1]; + float fQ112132_100 = fTCP1[1]; + float fQ112132_011 = fTCP0[1] * fTCP1[2]; + float fQ112132_101 = fTCP1[1] * fTCP1[2]; + float fQ112132_110 = fTCP1[1] * fTCP0[1]; + float fQ112131_001 = fTCP1[1]; + float fQ112131_010 = fTCP0[1]; + float fQ112131_100 = fTCP1[1]; + float fQ112131_011 = fTCP0[1] * fTCP1[1]; + float fQ112131_101 = fTCP1[1] * fTCP1[1]; + float fQ112131_110 = fTCP1[1] * fTCP0[1]; + + float fQ2221_11 = fTCP0[2] * fTCP0[1]; + float fQ2221_01 = fTCP0[1]; + float fQ2221_10 = fTCP0[2]; + float fQ2221_21 = std::pow(fTCP0[2], 2) * fTCP0[1]; + float fQ2221_20 = std::pow(fTCP0[2], 2); + + float fQ2122_21 = std::pow(fTCP0[1], 2) * fTCP0[2]; + float fQ2122_20 = std::pow(fTCP0[1], 2); + float fQ1121_02 = std::pow(fTCP0[1], 2); + float fQ1121_12 = fTCP1[1] * std::pow(fTCP0[1], 2); + float fQ1121_22 = std::pow(fTCP1[1], 2) * std::pow(fTCP0[1], 2); + float fQ1122_02 = std::pow(fTCP0[2], 2); + float fQ1122_12 = fTCP1[1] * std::pow(fTCP0[2], 2); + float fQ1122_22 = std::pow(fTCP1[1], 2) * std::pow(fTCP0[2], 2); + + float fQ112221_001 = fTCP0[1]; + float fQ112221_010 = fTCP0[2]; + float fQ112221_100 = fTCP1[1]; + float fQ112221_011 = fTCP0[2] * fTCP0[1]; + float fQ112221_101 = fTCP1[1] * fTCP0[1]; + float fQ112221_110 = fTCP1[1] * fTCP0[2]; + float fQ112221_200 = std::pow(fTCP1[1], 2); + float fQ112221_201 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ112221_210 = std::pow(fTCP1[1], 2) * fTCP0[2]; + float fQ112221_211 = std::pow(fTCP1[1], 2) * fTCP0[2] * fTCP0[1]; + float fQ1131_21 = std::pow(fTCP1[1], 2) * fTCP1[1]; + float fQ1131_20 = std::pow(fTCP1[1], 2); + float fQ1131_31 = std::pow(fTCP1[1], 3) * fTCP1[1]; + float fQ1131_30 = std::pow(fTCP1[1], 3); + + float fQ1132_21 = std::pow(fTCP1[1], 2) * fTCP1[2]; + float fQ1132_20 = std::pow(fTCP1[1], 2); + float fQ1132_31 = std::pow(fTCP1[1], 3) * fTCP1[2]; + float fQ1132_30 = std::pow(fTCP1[1], 3); + float fQ1133_21 = std::pow(fTCP1[1], 2) * fTCP1[3]; + float fQ1133_20 = std::pow(fTCP1[1], 2); + float fQ1133_31 = std::pow(fTCP1[1], 3) * fTCP1[3]; + float fQ1133_30 = std::pow(fTCP1[1], 3); + float fQ1121_30 = std::pow(fTCP1[1], 3); + float fQ1121_31 = std::pow(fTCP1[1], 3) * fTCP0[1]; + float fQ1121_40 = std::pow(fTCP1[1], 4); + float fQ1121_41 = std::pow(fTCP1[1], 4) * fTCP0[1]; + float fQ1122_30 = std::pow(fTCP1[1], 3); + float fQ1122_31 = std::pow(fTCP1[1], 3) * fTCP0[2]; + float fQ1122_40 = std::pow(fTCP1[1], 4); + float fQ1122_41 = std::pow(fTCP1[1], 4) * fTCP0[2]; + + float fQ2211_11 = fTCP0[2] * fTCP1[1]; + float fQ2211_01 = fTCP1[1]; + float fQ2211_10 = fTCP0[2]; + float fQ2211_20 = std::pow(fTCP0[2], 2); + float fQ2211_21 = std::pow(fTCP0[2], 2) * fTCP1[1]; + float fQ2111_11 = fTCP0[1] * fTCP1[1]; + float fQ2111_01 = fTCP1[1]; + float fQ2111_10 = fTCP0[1]; + float fQ2111_20 = std::pow(fTCP0[1], 2); + float fQ2111_21 = std::pow(fTCP0[1], 2) * fTCP1[1]; + + float fQ112122_001 = fTCP0[2]; + float fQ112122_010 = fTCP0[1]; + float fQ112122_100 = fTCP1[1]; + float fQ112122_011 = fTCP0[1] * fTCP0[2]; + float fQ112122_101 = fTCP1[1] * fTCP0[2]; + float fQ112122_110 = fTCP1[1] * fTCP0[1]; + + float fQ1141_11 = fTCP1[1] * fTCP0[1]; + float fQ1141_01 = fTCP0[1]; + float fQ1141_10 = fTCP1[1]; + float fQ1141_20 = std::pow(fTCP1[1], 2); + float fQ1141_21 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ1142_11 = fTCP1[1] * fTCP0[2]; + float fQ1142_01 = fTCP0[2]; + float fQ1142_10 = fTCP1[1]; + float fQ1142_20 = std::pow(fTCP1[1], 2); + float fQ1142_21 = std::pow(fTCP1[1], 2) * fTCP0[2]; + + float fQ1143_11 = fTCP1[1] * fTCP0[3]; + float fQ1143_01 = fTCP0[3]; + float fQ1143_10 = fTCP1[1]; + float fQ1143_20 = std::pow(fTCP1[1], 2); + float fQ1143_21 = std::pow(fTCP1[1], 2) * fTCP0[3]; + float fQ1144_11 = fTCP1[1] * fTCP0[4]; + float fQ1144_01 = fTCP0[4]; + float fQ1144_10 = fTCP1[1]; + float fQ1144_20 = std::pow(fTCP1[1], 2); + float fQ1144_21 = std::pow(fTCP1[1], 2) * fTCP0[4]; + float fQ2131_11 = fTCP0[1] * fTCP1[1]; + float fQ2131_01 = fTCP1[1]; + float fQ2131_10 = fTCP0[1]; + + float fQ2132_11 = fTCP0[1] * fTCP1[2]; + float fQ2132_01 = fTCP1[2]; + float fQ2132_10 = fTCP0[1]; + float fQ2133_11 = fTCP0[1] * fTCP1[3]; + float fQ2133_01 = fTCP1[3]; + float fQ2133_10 = fTCP0[1]; + float fQ2231_11 = fTCP0[2] * fTCP1[1]; + float fQ2231_01 = fTCP1[1]; + float fQ2231_10 = fTCP0[2]; + float fQ2232_11 = fTCP0[2] * fTCP1[2]; + float fQ2232_01 = fTCP1[2]; + float fQ2232_10 = fTCP0[2]; + float fQ2233_11 = fTCP0[2] * fTCP1[3]; + float fQ2233_01 = fTCP1[3]; + float fQ2233_10 = fTCP0[2]; + + float fQ51_1 = fTCP1[1]; + float fQ52_1 = fTCP1[2]; + float fQ53_1 = fTCP1[3]; + float fQ54_1 = fTCP1[4]; + float fQ55_1 = fTCP1[5]; + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + if (cfgIsCalculateCentral) { + + // uncorrected + histos.get(HIST("Prof_mu1_netproton"))->Fill(cent, std::pow(netProt, 1.0)); + histos.get(HIST("Prof_mu2_netproton"))->Fill(cent, std::pow(netProt, 2.0)); + histos.get(HIST("Prof_mu3_netproton"))->Fill(cent, std::pow(netProt, 3.0)); + histos.get(HIST("Prof_mu4_netproton"))->Fill(cent, std::pow(netProt, 4.0)); + histos.get(HIST("Prof_mu5_netproton"))->Fill(cent, std::pow(netProt, 5.0)); + histos.get(HIST("Prof_mu6_netproton"))->Fill(cent, std::pow(netProt, 6.0)); + histos.get(HIST("Prof_mu7_netproton"))->Fill(cent, std::pow(netProt, 7.0)); + histos.get(HIST("Prof_mu8_netproton"))->Fill(cent, std::pow(netProt, 8.0)); + + // eff. corrected + histos.get(HIST("Prof_Q11_1"))->Fill(cent, fQ11_1); + histos.get(HIST("Prof_Q11_2"))->Fill(cent, fQ11_2); + histos.get(HIST("Prof_Q11_3"))->Fill(cent, fQ11_3); + histos.get(HIST("Prof_Q11_4"))->Fill(cent, fQ11_4); + histos.get(HIST("Prof_Q21_1"))->Fill(cent, fQ21_1); + histos.get(HIST("Prof_Q22_1"))->Fill(cent, fQ22_1); + histos.get(HIST("Prof_Q31_1"))->Fill(cent, fQ31_1); + histos.get(HIST("Prof_Q32_1"))->Fill(cent, fQ32_1); + histos.get(HIST("Prof_Q33_1"))->Fill(cent, fQ33_1); + histos.get(HIST("Prof_Q41_1"))->Fill(cent, fQ41_1); + histos.get(HIST("Prof_Q42_1"))->Fill(cent, fQ42_1); + histos.get(HIST("Prof_Q43_1"))->Fill(cent, fQ43_1); + histos.get(HIST("Prof_Q44_1"))->Fill(cent, fQ44_1); + histos.get(HIST("Prof_Q21_2"))->Fill(cent, fQ21_2); + histos.get(HIST("Prof_Q22_2"))->Fill(cent, fQ22_2); + histos.get(HIST("Prof_Q1121_11"))->Fill(cent, fQ1121_11); + histos.get(HIST("Prof_Q1121_01"))->Fill(cent, fQ1121_01); + histos.get(HIST("Prof_Q1121_10"))->Fill(cent, fQ1121_10); + histos.get(HIST("Prof_Q1121_20"))->Fill(cent, fQ1121_20); + histos.get(HIST("Prof_Q1121_21"))->Fill(cent, fQ1121_21); + histos.get(HIST("Prof_Q1122_11"))->Fill(cent, fQ1122_11); + histos.get(HIST("Prof_Q1122_01"))->Fill(cent, fQ1122_01); + histos.get(HIST("Prof_Q1122_10"))->Fill(cent, fQ1122_10); + histos.get(HIST("Prof_Q1122_20"))->Fill(cent, fQ1122_20); + histos.get(HIST("Prof_Q1122_21"))->Fill(cent, fQ1122_21); + histos.get(HIST("Prof_Q1131_11"))->Fill(cent, fQ1131_11); + histos.get(HIST("Prof_Q1131_01"))->Fill(cent, fQ1131_01); + histos.get(HIST("Prof_Q1131_10"))->Fill(cent, fQ1131_10); + histos.get(HIST("Prof_Q1132_11"))->Fill(cent, fQ1132_11); + histos.get(HIST("Prof_Q1132_01"))->Fill(cent, fQ1132_01); + histos.get(HIST("Prof_Q1132_10"))->Fill(cent, fQ1132_10); + histos.get(HIST("Prof_Q1133_11"))->Fill(cent, fQ1133_11); + histos.get(HIST("Prof_Q1133_01"))->Fill(cent, fQ1133_01); + histos.get(HIST("Prof_Q1133_10"))->Fill(cent, fQ1133_10); + histos.get(HIST("Prof_Q2122_11"))->Fill(cent, fQ2122_11); + histos.get(HIST("Prof_Q2122_01"))->Fill(cent, fQ2122_01); + histos.get(HIST("Prof_Q2122_10"))->Fill(cent, fQ2122_10); + histos.get(HIST("Prof_Q3132_11"))->Fill(cent, fQ3132_11); + histos.get(HIST("Prof_Q3132_01"))->Fill(cent, fQ3132_01); + histos.get(HIST("Prof_Q3132_10"))->Fill(cent, fQ3132_10); + histos.get(HIST("Prof_Q3133_11"))->Fill(cent, fQ3133_11); + histos.get(HIST("Prof_Q3133_01"))->Fill(cent, fQ3133_01); + histos.get(HIST("Prof_Q3133_10"))->Fill(cent, fQ3133_10); + histos.get(HIST("Prof_Q3233_11"))->Fill(cent, fQ3233_11); + histos.get(HIST("Prof_Q3233_01"))->Fill(cent, fQ3233_01); + histos.get(HIST("Prof_Q3233_10"))->Fill(cent, fQ3233_10); + histos.get(HIST("Prof_Q2241_11"))->Fill(cent, fQ2241_11); + histos.get(HIST("Prof_Q2241_01"))->Fill(cent, fQ2241_01); + histos.get(HIST("Prof_Q2241_10"))->Fill(cent, fQ2241_10); + histos.get(HIST("Prof_Q2242_11"))->Fill(cent, fQ2242_11); + histos.get(HIST("Prof_Q2242_01"))->Fill(cent, fQ2242_01); + histos.get(HIST("Prof_Q2242_10"))->Fill(cent, fQ2242_10); + histos.get(HIST("Prof_Q2243_11"))->Fill(cent, fQ2243_11); + histos.get(HIST("Prof_Q2243_01"))->Fill(cent, fQ2243_01); + histos.get(HIST("Prof_Q2243_10"))->Fill(cent, fQ2243_10); + histos.get(HIST("Prof_Q2244_11"))->Fill(cent, fQ2244_11); + histos.get(HIST("Prof_Q2244_01"))->Fill(cent, fQ2244_01); + histos.get(HIST("Prof_Q2244_10"))->Fill(cent, fQ2244_10); + histos.get(HIST("Prof_Q2141_11"))->Fill(cent, fQ2141_11); + histos.get(HIST("Prof_Q2141_01"))->Fill(cent, fQ2141_01); + histos.get(HIST("Prof_Q2141_10"))->Fill(cent, fQ2141_10); + histos.get(HIST("Prof_Q2142_11"))->Fill(cent, fQ2142_11); + histos.get(HIST("Prof_Q2142_01"))->Fill(cent, fQ2142_01); + histos.get(HIST("Prof_Q2142_10"))->Fill(cent, fQ2142_10); + histos.get(HIST("Prof_Q2143_11"))->Fill(cent, fQ2143_11); + histos.get(HIST("Prof_Q2143_01"))->Fill(cent, fQ2143_01); + histos.get(HIST("Prof_Q2143_10"))->Fill(cent, fQ2143_10); + histos.get(HIST("Prof_Q2144_11"))->Fill(cent, fQ2144_11); + histos.get(HIST("Prof_Q2144_01"))->Fill(cent, fQ2144_01); + histos.get(HIST("Prof_Q2144_10"))->Fill(cent, fQ2144_10); + histos.get(HIST("Prof_Q1151_11"))->Fill(cent, fQ1151_11); + histos.get(HIST("Prof_Q1151_01"))->Fill(cent, fQ1151_01); + histos.get(HIST("Prof_Q1151_10"))->Fill(cent, fQ1151_10); + histos.get(HIST("Prof_Q1152_11"))->Fill(cent, fQ1152_11); + histos.get(HIST("Prof_Q1152_01"))->Fill(cent, fQ1152_01); + histos.get(HIST("Prof_Q1152_10"))->Fill(cent, fQ1152_10); + histos.get(HIST("Prof_Q1153_11"))->Fill(cent, fQ1153_11); + histos.get(HIST("Prof_Q1153_01"))->Fill(cent, fQ1153_01); + histos.get(HIST("Prof_Q1153_10"))->Fill(cent, fQ1153_10); + histos.get(HIST("Prof_Q1154_11"))->Fill(cent, fQ1154_11); + histos.get(HIST("Prof_Q1154_01"))->Fill(cent, fQ1154_01); + histos.get(HIST("Prof_Q1154_10"))->Fill(cent, fQ1154_10); + histos.get(HIST("Prof_Q1155_11"))->Fill(cent, fQ1155_11); + histos.get(HIST("Prof_Q1155_01"))->Fill(cent, fQ1155_01); + histos.get(HIST("Prof_Q1155_10"))->Fill(cent, fQ1155_10); + histos.get(HIST("Prof_Q112233_001"))->Fill(cent, fQ112233_001); + histos.get(HIST("Prof_Q112233_010"))->Fill(cent, fQ112233_010); + histos.get(HIST("Prof_Q112233_100"))->Fill(cent, fQ112233_100); + histos.get(HIST("Prof_Q112233_011"))->Fill(cent, fQ112233_011); + histos.get(HIST("Prof_Q112233_101"))->Fill(cent, fQ112233_101); + histos.get(HIST("Prof_Q112233_110"))->Fill(cent, fQ112233_110); + histos.get(HIST("Prof_Q112232_001"))->Fill(cent, fQ112232_001); + histos.get(HIST("Prof_Q112232_010"))->Fill(cent, fQ112232_010); + histos.get(HIST("Prof_Q112232_100"))->Fill(cent, fQ112232_100); + histos.get(HIST("Prof_Q112232_011"))->Fill(cent, fQ112232_011); + histos.get(HIST("Prof_Q112232_101"))->Fill(cent, fQ112232_101); + histos.get(HIST("Prof_Q112232_110"))->Fill(cent, fQ112232_110); + histos.get(HIST("Prof_Q112231_001"))->Fill(cent, fQ112231_001); + histos.get(HIST("Prof_Q112231_010"))->Fill(cent, fQ112231_010); + histos.get(HIST("Prof_Q112231_100"))->Fill(cent, fQ112231_100); + histos.get(HIST("Prof_Q112231_011"))->Fill(cent, fQ112231_011); + histos.get(HIST("Prof_Q112231_101"))->Fill(cent, fQ112231_101); + histos.get(HIST("Prof_Q112231_110"))->Fill(cent, fQ112231_110); + histos.get(HIST("Prof_Q112133_001"))->Fill(cent, fQ112133_001); + histos.get(HIST("Prof_Q112133_010"))->Fill(cent, fQ112133_010); + histos.get(HIST("Prof_Q112133_100"))->Fill(cent, fQ112133_100); + histos.get(HIST("Prof_Q112133_011"))->Fill(cent, fQ112133_011); + histos.get(HIST("Prof_Q112133_101"))->Fill(cent, fQ112133_101); + histos.get(HIST("Prof_Q112133_110"))->Fill(cent, fQ112133_110); + histos.get(HIST("Prof_Q112132_001"))->Fill(cent, fQ112132_001); + histos.get(HIST("Prof_Q112132_010"))->Fill(cent, fQ112132_010); + histos.get(HIST("Prof_Q112132_100"))->Fill(cent, fQ112132_100); + histos.get(HIST("Prof_Q112132_011"))->Fill(cent, fQ112132_011); + histos.get(HIST("Prof_Q112132_101"))->Fill(cent, fQ112132_101); + histos.get(HIST("Prof_Q112132_110"))->Fill(cent, fQ112132_110); + histos.get(HIST("Prof_Q112131_001"))->Fill(cent, fQ112131_001); + histos.get(HIST("Prof_Q112131_010"))->Fill(cent, fQ112131_010); + histos.get(HIST("Prof_Q112131_100"))->Fill(cent, fQ112131_100); + histos.get(HIST("Prof_Q112131_011"))->Fill(cent, fQ112131_011); + histos.get(HIST("Prof_Q112131_101"))->Fill(cent, fQ112131_101); + histos.get(HIST("Prof_Q112131_110"))->Fill(cent, fQ112131_110); + histos.get(HIST("Prof_Q2221_11"))->Fill(cent, fQ2221_11); + histos.get(HIST("Prof_Q2221_01"))->Fill(cent, fQ2221_01); + histos.get(HIST("Prof_Q2221_10"))->Fill(cent, fQ2221_10); + histos.get(HIST("Prof_Q2221_21"))->Fill(cent, fQ2221_21); + histos.get(HIST("Prof_Q2221_20"))->Fill(cent, fQ2221_20); + histos.get(HIST("Prof_Q2122_21"))->Fill(cent, fQ2122_21); + histos.get(HIST("Prof_Q2122_20"))->Fill(cent, fQ2122_20); + histos.get(HIST("Prof_Q1121_02"))->Fill(cent, fQ1121_02); + histos.get(HIST("Prof_Q1121_12"))->Fill(cent, fQ1121_12); + histos.get(HIST("Prof_Q1121_22"))->Fill(cent, fQ1121_22); + histos.get(HIST("Prof_Q1122_02"))->Fill(cent, fQ1122_02); + histos.get(HIST("Prof_Q1122_12"))->Fill(cent, fQ1122_12); + histos.get(HIST("Prof_Q1122_22"))->Fill(cent, fQ1122_22); + histos.get(HIST("Prof_Q112221_001"))->Fill(cent, fQ112221_001); + histos.get(HIST("Prof_Q112221_010"))->Fill(cent, fQ112221_010); + histos.get(HIST("Prof_Q112221_100"))->Fill(cent, fQ112221_100); + histos.get(HIST("Prof_Q112221_011"))->Fill(cent, fQ112221_011); + histos.get(HIST("Prof_Q112221_101"))->Fill(cent, fQ112221_101); + histos.get(HIST("Prof_Q112221_110"))->Fill(cent, fQ112221_110); + histos.get(HIST("Prof_Q112221_200"))->Fill(cent, fQ112221_200); + histos.get(HIST("Prof_Q112221_201"))->Fill(cent, fQ112221_201); + histos.get(HIST("Prof_Q112221_210"))->Fill(cent, fQ112221_210); + histos.get(HIST("Prof_Q112221_211"))->Fill(cent, fQ112221_211); + histos.get(HIST("Prof_Q1131_21"))->Fill(cent, fQ1131_21); + histos.get(HIST("Prof_Q1131_20"))->Fill(cent, fQ1131_20); + histos.get(HIST("Prof_Q1131_31"))->Fill(cent, fQ1131_31); + histos.get(HIST("Prof_Q1131_30"))->Fill(cent, fQ1131_30); + histos.get(HIST("Prof_Q1132_21"))->Fill(cent, fQ1132_21); + histos.get(HIST("Prof_Q1132_20"))->Fill(cent, fQ1132_20); + histos.get(HIST("Prof_Q1132_31"))->Fill(cent, fQ1132_31); + histos.get(HIST("Prof_Q1132_30"))->Fill(cent, fQ1132_30); + histos.get(HIST("Prof_Q1133_21"))->Fill(cent, fQ1133_21); + histos.get(HIST("Prof_Q1133_20"))->Fill(cent, fQ1133_20); + histos.get(HIST("Prof_Q1133_31"))->Fill(cent, fQ1133_31); + histos.get(HIST("Prof_Q1133_30"))->Fill(cent, fQ1133_30); + histos.get(HIST("Prof_Q11_5"))->Fill(cent, fQ11_5); + histos.get(HIST("Prof_Q11_6"))->Fill(cent, fQ11_6); + histos.get(HIST("Prof_Q1121_30"))->Fill(cent, fQ1121_30); + histos.get(HIST("Prof_Q1121_31"))->Fill(cent, fQ1121_31); + histos.get(HIST("Prof_Q1121_40"))->Fill(cent, fQ1121_40); + histos.get(HIST("Prof_Q1121_41"))->Fill(cent, fQ1121_41); + histos.get(HIST("Prof_Q1122_30"))->Fill(cent, fQ1122_30); + histos.get(HIST("Prof_Q1122_31"))->Fill(cent, fQ1122_31); + histos.get(HIST("Prof_Q1122_40"))->Fill(cent, fQ1122_40); + histos.get(HIST("Prof_Q1122_41"))->Fill(cent, fQ1122_41); + histos.get(HIST("Prof_Q2211_11"))->Fill(cent, fQ2211_11); + histos.get(HIST("Prof_Q2211_01"))->Fill(cent, fQ2211_01); + histos.get(HIST("Prof_Q2211_10"))->Fill(cent, fQ2211_10); + histos.get(HIST("Prof_Q2211_20"))->Fill(cent, fQ2211_20); + histos.get(HIST("Prof_Q2211_21"))->Fill(cent, fQ2211_21); + histos.get(HIST("Prof_Q2111_11"))->Fill(cent, fQ2111_11); + histos.get(HIST("Prof_Q2111_01"))->Fill(cent, fQ2111_01); + histos.get(HIST("Prof_Q2111_10"))->Fill(cent, fQ2111_10); + histos.get(HIST("Prof_Q2111_20"))->Fill(cent, fQ2111_20); + histos.get(HIST("Prof_Q2111_21"))->Fill(cent, fQ2111_21); + histos.get(HIST("Prof_Q112122_001"))->Fill(cent, fQ112122_001); + histos.get(HIST("Prof_Q112122_010"))->Fill(cent, fQ112122_010); + histos.get(HIST("Prof_Q112122_100"))->Fill(cent, fQ112122_100); + histos.get(HIST("Prof_Q112122_011"))->Fill(cent, fQ112122_011); + histos.get(HIST("Prof_Q112122_101"))->Fill(cent, fQ112122_101); + histos.get(HIST("Prof_Q112122_110"))->Fill(cent, fQ112122_110); + histos.get(HIST("Prof_Q1141_11"))->Fill(cent, fQ1141_11); + histos.get(HIST("Prof_Q1141_01"))->Fill(cent, fQ1141_01); + histos.get(HIST("Prof_Q1141_10"))->Fill(cent, fQ1141_10); + histos.get(HIST("Prof_Q1141_20"))->Fill(cent, fQ1141_20); + histos.get(HIST("Prof_Q1141_21"))->Fill(cent, fQ1141_21); + histos.get(HIST("Prof_Q1142_11"))->Fill(cent, fQ1142_11); + histos.get(HIST("Prof_Q1142_01"))->Fill(cent, fQ1142_01); + histos.get(HIST("Prof_Q1142_10"))->Fill(cent, fQ1142_10); + histos.get(HIST("Prof_Q1142_20"))->Fill(cent, fQ1142_20); + histos.get(HIST("Prof_Q1142_21"))->Fill(cent, fQ1142_21); + histos.get(HIST("Prof_Q1143_11"))->Fill(cent, fQ1143_11); + histos.get(HIST("Prof_Q1143_01"))->Fill(cent, fQ1143_01); + histos.get(HIST("Prof_Q1143_10"))->Fill(cent, fQ1143_10); + histos.get(HIST("Prof_Q1143_20"))->Fill(cent, fQ1143_20); + histos.get(HIST("Prof_Q1143_21"))->Fill(cent, fQ1143_21); + histos.get(HIST("Prof_Q1144_11"))->Fill(cent, fQ1144_11); + histos.get(HIST("Prof_Q1144_01"))->Fill(cent, fQ1144_01); + histos.get(HIST("Prof_Q1144_10"))->Fill(cent, fQ1144_10); + histos.get(HIST("Prof_Q1144_20"))->Fill(cent, fQ1144_20); + histos.get(HIST("Prof_Q1144_21"))->Fill(cent, fQ1144_21); + histos.get(HIST("Prof_Q2131_11"))->Fill(cent, fQ2131_11); + histos.get(HIST("Prof_Q2131_01"))->Fill(cent, fQ2131_01); + histos.get(HIST("Prof_Q2131_10"))->Fill(cent, fQ2131_10); + histos.get(HIST("Prof_Q2132_11"))->Fill(cent, fQ2132_11); + histos.get(HIST("Prof_Q2132_01"))->Fill(cent, fQ2132_01); + histos.get(HIST("Prof_Q2132_10"))->Fill(cent, fQ2132_10); + histos.get(HIST("Prof_Q2133_11"))->Fill(cent, fQ2133_11); + histos.get(HIST("Prof_Q2133_01"))->Fill(cent, fQ2133_01); + histos.get(HIST("Prof_Q2133_10"))->Fill(cent, fQ2133_10); + histos.get(HIST("Prof_Q2231_11"))->Fill(cent, fQ2231_11); + histos.get(HIST("Prof_Q2231_01"))->Fill(cent, fQ2231_01); + histos.get(HIST("Prof_Q2231_10"))->Fill(cent, fQ2231_10); + histos.get(HIST("Prof_Q2232_11"))->Fill(cent, fQ2232_11); + histos.get(HIST("Prof_Q2232_01"))->Fill(cent, fQ2232_01); + histos.get(HIST("Prof_Q2232_10"))->Fill(cent, fQ2232_10); + histos.get(HIST("Prof_Q2233_11"))->Fill(cent, fQ2233_11); + histos.get(HIST("Prof_Q2233_01"))->Fill(cent, fQ2233_01); + histos.get(HIST("Prof_Q2233_10"))->Fill(cent, fQ2233_10); + histos.get(HIST("Prof_Q51_1"))->Fill(cent, fQ51_1); + histos.get(HIST("Prof_Q52_1"))->Fill(cent, fQ52_1); + histos.get(HIST("Prof_Q53_1"))->Fill(cent, fQ53_1); + histos.get(HIST("Prof_Q54_1"))->Fill(cent, fQ54_1); + histos.get(HIST("Prof_Q55_1"))->Fill(cent, fQ55_1); + histos.get(HIST("Prof_Q21_3"))->Fill(cent, fQ21_3); + histos.get(HIST("Prof_Q22_3"))->Fill(cent, fQ22_3); + histos.get(HIST("Prof_Q31_2"))->Fill(cent, fQ31_2); + histos.get(HIST("Prof_Q32_2"))->Fill(cent, fQ32_2); + histos.get(HIST("Prof_Q33_2"))->Fill(cent, fQ33_2); + histos.get(HIST("Prof_Q61_1"))->Fill(cent, fQ61_1); + histos.get(HIST("Prof_Q62_1"))->Fill(cent, fQ62_1); + histos.get(HIST("Prof_Q63_1"))->Fill(cent, fQ63_1); + histos.get(HIST("Prof_Q64_1"))->Fill(cent, fQ64_1); + histos.get(HIST("Prof_Q65_1"))->Fill(cent, fQ65_1); + histos.get(HIST("Prof_Q66_1"))->Fill(cent, fQ66_1); + histos.get(HIST("Prof_Q112122_111"))->Fill(cent, fQ112122_111); + histos.get(HIST("Prof_Q112131_111"))->Fill(cent, fQ112131_111); + histos.get(HIST("Prof_Q112132_111"))->Fill(cent, fQ112132_111); + histos.get(HIST("Prof_Q112133_111"))->Fill(cent, fQ112133_111); + histos.get(HIST("Prof_Q112231_111"))->Fill(cent, fQ112231_111); + histos.get(HIST("Prof_Q112232_111"))->Fill(cent, fQ112232_111); + histos.get(HIST("Prof_Q112233_111"))->Fill(cent, fQ112233_111); + histos.get(HIST("Prof_Q112221_111"))->Fill(cent, fQ112221_111); + } + + if (cfgIsCalculateError) { + // selecting subsample and filling profiles + float lRandom = fRndm->Rndm(); + int sampleIndex = static_cast(cfgNSubsample * lRandom); + + histos.get(HIST("Prof2D_mu1_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 1.0)); + histos.get(HIST("Prof2D_mu2_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 2.0)); + histos.get(HIST("Prof2D_mu3_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 3.0)); + histos.get(HIST("Prof2D_mu4_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 4.0)); + histos.get(HIST("Prof2D_mu5_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 5.0)); + histos.get(HIST("Prof2D_mu6_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 6.0)); + histos.get(HIST("Prof2D_mu7_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 7.0)); + histos.get(HIST("Prof2D_mu8_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 8.0)); + + histos.get(HIST("Prof2D_Q11_1"))->Fill(cent, sampleIndex, fQ11_1); + histos.get(HIST("Prof2D_Q11_2"))->Fill(cent, sampleIndex, fQ11_2); + histos.get(HIST("Prof2D_Q11_3"))->Fill(cent, sampleIndex, fQ11_3); + histos.get(HIST("Prof2D_Q11_4"))->Fill(cent, sampleIndex, fQ11_4); + histos.get(HIST("Prof2D_Q21_1"))->Fill(cent, sampleIndex, fQ21_1); + histos.get(HIST("Prof2D_Q22_1"))->Fill(cent, sampleIndex, fQ22_1); + histos.get(HIST("Prof2D_Q31_1"))->Fill(cent, sampleIndex, fQ31_1); + histos.get(HIST("Prof2D_Q32_1"))->Fill(cent, sampleIndex, fQ32_1); + histos.get(HIST("Prof2D_Q33_1"))->Fill(cent, sampleIndex, fQ33_1); + histos.get(HIST("Prof2D_Q41_1"))->Fill(cent, sampleIndex, fQ41_1); + histos.get(HIST("Prof2D_Q42_1"))->Fill(cent, sampleIndex, fQ42_1); + histos.get(HIST("Prof2D_Q43_1"))->Fill(cent, sampleIndex, fQ43_1); + histos.get(HIST("Prof2D_Q44_1"))->Fill(cent, sampleIndex, fQ44_1); + histos.get(HIST("Prof2D_Q21_2"))->Fill(cent, sampleIndex, fQ21_2); + histos.get(HIST("Prof2D_Q22_2"))->Fill(cent, sampleIndex, fQ22_2); + histos.get(HIST("Prof2D_Q1121_11"))->Fill(cent, sampleIndex, fQ1121_11); + histos.get(HIST("Prof2D_Q1121_01"))->Fill(cent, sampleIndex, fQ1121_01); + histos.get(HIST("Prof2D_Q1121_10"))->Fill(cent, sampleIndex, fQ1121_10); + histos.get(HIST("Prof2D_Q1121_20"))->Fill(cent, sampleIndex, fQ1121_20); + histos.get(HIST("Prof2D_Q1121_21"))->Fill(cent, sampleIndex, fQ1121_21); + histos.get(HIST("Prof2D_Q1122_11"))->Fill(cent, sampleIndex, fQ1122_11); + histos.get(HIST("Prof2D_Q1122_01"))->Fill(cent, sampleIndex, fQ1122_01); + histos.get(HIST("Prof2D_Q1122_10"))->Fill(cent, sampleIndex, fQ1122_10); + histos.get(HIST("Prof2D_Q1122_20"))->Fill(cent, sampleIndex, fQ1122_20); + histos.get(HIST("Prof2D_Q1122_21"))->Fill(cent, sampleIndex, fQ1122_21); + histos.get(HIST("Prof2D_Q1131_11"))->Fill(cent, sampleIndex, fQ1131_11); + histos.get(HIST("Prof2D_Q1131_01"))->Fill(cent, sampleIndex, fQ1131_01); + histos.get(HIST("Prof2D_Q1131_10"))->Fill(cent, sampleIndex, fQ1131_10); + histos.get(HIST("Prof2D_Q1132_11"))->Fill(cent, sampleIndex, fQ1132_11); + histos.get(HIST("Prof2D_Q1132_01"))->Fill(cent, sampleIndex, fQ1132_01); + histos.get(HIST("Prof2D_Q1132_10"))->Fill(cent, sampleIndex, fQ1132_10); + histos.get(HIST("Prof2D_Q1133_11"))->Fill(cent, sampleIndex, fQ1133_11); + histos.get(HIST("Prof2D_Q1133_01"))->Fill(cent, sampleIndex, fQ1133_01); + histos.get(HIST("Prof2D_Q1133_10"))->Fill(cent, sampleIndex, fQ1133_10); + histos.get(HIST("Prof2D_Q2122_11"))->Fill(cent, sampleIndex, fQ2122_11); + histos.get(HIST("Prof2D_Q2122_01"))->Fill(cent, sampleIndex, fQ2122_01); + histos.get(HIST("Prof2D_Q2122_10"))->Fill(cent, sampleIndex, fQ2122_10); + histos.get(HIST("Prof2D_Q3132_11"))->Fill(cent, sampleIndex, fQ3132_11); + histos.get(HIST("Prof2D_Q3132_01"))->Fill(cent, sampleIndex, fQ3132_01); + histos.get(HIST("Prof2D_Q3132_10"))->Fill(cent, sampleIndex, fQ3132_10); + histos.get(HIST("Prof2D_Q3133_11"))->Fill(cent, sampleIndex, fQ3133_11); + histos.get(HIST("Prof2D_Q3133_01"))->Fill(cent, sampleIndex, fQ3133_01); + histos.get(HIST("Prof2D_Q3133_10"))->Fill(cent, sampleIndex, fQ3133_10); + histos.get(HIST("Prof2D_Q3233_11"))->Fill(cent, sampleIndex, fQ3233_11); + histos.get(HIST("Prof2D_Q3233_01"))->Fill(cent, sampleIndex, fQ3233_01); + histos.get(HIST("Prof2D_Q3233_10"))->Fill(cent, sampleIndex, fQ3233_10); + histos.get(HIST("Prof2D_Q2241_11"))->Fill(cent, sampleIndex, fQ2241_11); + histos.get(HIST("Prof2D_Q2241_01"))->Fill(cent, sampleIndex, fQ2241_01); + histos.get(HIST("Prof2D_Q2241_10"))->Fill(cent, sampleIndex, fQ2241_10); + histos.get(HIST("Prof2D_Q2242_11"))->Fill(cent, sampleIndex, fQ2242_11); + histos.get(HIST("Prof2D_Q2242_01"))->Fill(cent, sampleIndex, fQ2242_01); + histos.get(HIST("Prof2D_Q2242_10"))->Fill(cent, sampleIndex, fQ2242_10); + histos.get(HIST("Prof2D_Q2243_11"))->Fill(cent, sampleIndex, fQ2243_11); + histos.get(HIST("Prof2D_Q2243_01"))->Fill(cent, sampleIndex, fQ2243_01); + histos.get(HIST("Prof2D_Q2243_10"))->Fill(cent, sampleIndex, fQ2243_10); + histos.get(HIST("Prof2D_Q2244_11"))->Fill(cent, sampleIndex, fQ2244_11); + histos.get(HIST("Prof2D_Q2244_01"))->Fill(cent, sampleIndex, fQ2244_01); + histos.get(HIST("Prof2D_Q2244_10"))->Fill(cent, sampleIndex, fQ2244_10); + histos.get(HIST("Prof2D_Q2141_11"))->Fill(cent, sampleIndex, fQ2141_11); + histos.get(HIST("Prof2D_Q2141_01"))->Fill(cent, sampleIndex, fQ2141_01); + histos.get(HIST("Prof2D_Q2141_10"))->Fill(cent, sampleIndex, fQ2141_10); + histos.get(HIST("Prof2D_Q2142_11"))->Fill(cent, sampleIndex, fQ2142_11); + histos.get(HIST("Prof2D_Q2142_01"))->Fill(cent, sampleIndex, fQ2142_01); + histos.get(HIST("Prof2D_Q2142_10"))->Fill(cent, sampleIndex, fQ2142_10); + histos.get(HIST("Prof2D_Q2143_11"))->Fill(cent, sampleIndex, fQ2143_11); + histos.get(HIST("Prof2D_Q2143_01"))->Fill(cent, sampleIndex, fQ2143_01); + histos.get(HIST("Prof2D_Q2143_10"))->Fill(cent, sampleIndex, fQ2143_10); + histos.get(HIST("Prof2D_Q2144_11"))->Fill(cent, sampleIndex, fQ2144_11); + histos.get(HIST("Prof2D_Q2144_01"))->Fill(cent, sampleIndex, fQ2144_01); + histos.get(HIST("Prof2D_Q2144_10"))->Fill(cent, sampleIndex, fQ2144_10); + histos.get(HIST("Prof2D_Q1151_11"))->Fill(cent, sampleIndex, fQ1151_11); + histos.get(HIST("Prof2D_Q1151_01"))->Fill(cent, sampleIndex, fQ1151_01); + histos.get(HIST("Prof2D_Q1151_10"))->Fill(cent, sampleIndex, fQ1151_10); + histos.get(HIST("Prof2D_Q1152_11"))->Fill(cent, sampleIndex, fQ1152_11); + histos.get(HIST("Prof2D_Q1152_01"))->Fill(cent, sampleIndex, fQ1152_01); + histos.get(HIST("Prof2D_Q1152_10"))->Fill(cent, sampleIndex, fQ1152_10); + histos.get(HIST("Prof2D_Q1153_11"))->Fill(cent, sampleIndex, fQ1153_11); + histos.get(HIST("Prof2D_Q1153_01"))->Fill(cent, sampleIndex, fQ1153_01); + histos.get(HIST("Prof2D_Q1153_10"))->Fill(cent, sampleIndex, fQ1153_10); + histos.get(HIST("Prof2D_Q1154_11"))->Fill(cent, sampleIndex, fQ1154_11); + histos.get(HIST("Prof2D_Q1154_01"))->Fill(cent, sampleIndex, fQ1154_01); + histos.get(HIST("Prof2D_Q1154_10"))->Fill(cent, sampleIndex, fQ1154_10); + histos.get(HIST("Prof2D_Q1155_11"))->Fill(cent, sampleIndex, fQ1155_11); + histos.get(HIST("Prof2D_Q1155_01"))->Fill(cent, sampleIndex, fQ1155_01); + histos.get(HIST("Prof2D_Q1155_10"))->Fill(cent, sampleIndex, fQ1155_10); + histos.get(HIST("Prof2D_Q112233_001"))->Fill(cent, sampleIndex, fQ112233_001); + histos.get(HIST("Prof2D_Q112233_010"))->Fill(cent, sampleIndex, fQ112233_010); + histos.get(HIST("Prof2D_Q112233_100"))->Fill(cent, sampleIndex, fQ112233_100); + histos.get(HIST("Prof2D_Q112233_011"))->Fill(cent, sampleIndex, fQ112233_011); + histos.get(HIST("Prof2D_Q112233_101"))->Fill(cent, sampleIndex, fQ112233_101); + histos.get(HIST("Prof2D_Q112233_110"))->Fill(cent, sampleIndex, fQ112233_110); + histos.get(HIST("Prof2D_Q112232_001"))->Fill(cent, sampleIndex, fQ112232_001); + histos.get(HIST("Prof2D_Q112232_010"))->Fill(cent, sampleIndex, fQ112232_010); + histos.get(HIST("Prof2D_Q112232_100"))->Fill(cent, sampleIndex, fQ112232_100); + histos.get(HIST("Prof2D_Q112232_011"))->Fill(cent, sampleIndex, fQ112232_011); + histos.get(HIST("Prof2D_Q112232_101"))->Fill(cent, sampleIndex, fQ112232_101); + histos.get(HIST("Prof2D_Q112232_110"))->Fill(cent, sampleIndex, fQ112232_110); + histos.get(HIST("Prof2D_Q112231_001"))->Fill(cent, sampleIndex, fQ112231_001); + histos.get(HIST("Prof2D_Q112231_010"))->Fill(cent, sampleIndex, fQ112231_010); + histos.get(HIST("Prof2D_Q112231_100"))->Fill(cent, sampleIndex, fQ112231_100); + histos.get(HIST("Prof2D_Q112231_011"))->Fill(cent, sampleIndex, fQ112231_011); + histos.get(HIST("Prof2D_Q112231_101"))->Fill(cent, sampleIndex, fQ112231_101); + histos.get(HIST("Prof2D_Q112231_110"))->Fill(cent, sampleIndex, fQ112231_110); + histos.get(HIST("Prof2D_Q112133_001"))->Fill(cent, sampleIndex, fQ112133_001); + histos.get(HIST("Prof2D_Q112133_010"))->Fill(cent, sampleIndex, fQ112133_010); + histos.get(HIST("Prof2D_Q112133_100"))->Fill(cent, sampleIndex, fQ112133_100); + histos.get(HIST("Prof2D_Q112133_011"))->Fill(cent, sampleIndex, fQ112133_011); + histos.get(HIST("Prof2D_Q112133_101"))->Fill(cent, sampleIndex, fQ112133_101); + histos.get(HIST("Prof2D_Q112133_110"))->Fill(cent, sampleIndex, fQ112133_110); + histos.get(HIST("Prof2D_Q112132_001"))->Fill(cent, sampleIndex, fQ112132_001); + histos.get(HIST("Prof2D_Q112132_010"))->Fill(cent, sampleIndex, fQ112132_010); + histos.get(HIST("Prof2D_Q112132_100"))->Fill(cent, sampleIndex, fQ112132_100); + histos.get(HIST("Prof2D_Q112132_011"))->Fill(cent, sampleIndex, fQ112132_011); + histos.get(HIST("Prof2D_Q112132_101"))->Fill(cent, sampleIndex, fQ112132_101); + histos.get(HIST("Prof2D_Q112132_110"))->Fill(cent, sampleIndex, fQ112132_110); + histos.get(HIST("Prof2D_Q112131_001"))->Fill(cent, sampleIndex, fQ112131_001); + histos.get(HIST("Prof2D_Q112131_010"))->Fill(cent, sampleIndex, fQ112131_010); + histos.get(HIST("Prof2D_Q112131_100"))->Fill(cent, sampleIndex, fQ112131_100); + histos.get(HIST("Prof2D_Q112131_011"))->Fill(cent, sampleIndex, fQ112131_011); + histos.get(HIST("Prof2D_Q112131_101"))->Fill(cent, sampleIndex, fQ112131_101); + histos.get(HIST("Prof2D_Q112131_110"))->Fill(cent, sampleIndex, fQ112131_110); + histos.get(HIST("Prof2D_Q2221_11"))->Fill(cent, sampleIndex, fQ2221_11); + histos.get(HIST("Prof2D_Q2221_01"))->Fill(cent, sampleIndex, fQ2221_01); + histos.get(HIST("Prof2D_Q2221_10"))->Fill(cent, sampleIndex, fQ2221_10); + histos.get(HIST("Prof2D_Q2221_21"))->Fill(cent, sampleIndex, fQ2221_21); + histos.get(HIST("Prof2D_Q2221_20"))->Fill(cent, sampleIndex, fQ2221_20); + histos.get(HIST("Prof2D_Q2122_21"))->Fill(cent, sampleIndex, fQ2122_21); + histos.get(HIST("Prof2D_Q2122_20"))->Fill(cent, sampleIndex, fQ2122_20); + histos.get(HIST("Prof2D_Q1121_02"))->Fill(cent, sampleIndex, fQ1121_02); + histos.get(HIST("Prof2D_Q1121_12"))->Fill(cent, sampleIndex, fQ1121_12); + histos.get(HIST("Prof2D_Q1121_22"))->Fill(cent, sampleIndex, fQ1121_22); + histos.get(HIST("Prof2D_Q1122_02"))->Fill(cent, sampleIndex, fQ1122_02); + histos.get(HIST("Prof2D_Q1122_12"))->Fill(cent, sampleIndex, fQ1122_12); + histos.get(HIST("Prof2D_Q1122_22"))->Fill(cent, sampleIndex, fQ1122_22); + histos.get(HIST("Prof2D_Q112221_001"))->Fill(cent, sampleIndex, fQ112221_001); + histos.get(HIST("Prof2D_Q112221_010"))->Fill(cent, sampleIndex, fQ112221_010); + histos.get(HIST("Prof2D_Q112221_100"))->Fill(cent, sampleIndex, fQ112221_100); + histos.get(HIST("Prof2D_Q112221_011"))->Fill(cent, sampleIndex, fQ112221_011); + histos.get(HIST("Prof2D_Q112221_101"))->Fill(cent, sampleIndex, fQ112221_101); + histos.get(HIST("Prof2D_Q112221_110"))->Fill(cent, sampleIndex, fQ112221_110); + histos.get(HIST("Prof2D_Q112221_200"))->Fill(cent, sampleIndex, fQ112221_200); + histos.get(HIST("Prof2D_Q112221_201"))->Fill(cent, sampleIndex, fQ112221_201); + histos.get(HIST("Prof2D_Q112221_210"))->Fill(cent, sampleIndex, fQ112221_210); + histos.get(HIST("Prof2D_Q112221_211"))->Fill(cent, sampleIndex, fQ112221_211); + histos.get(HIST("Prof2D_Q1131_21"))->Fill(cent, sampleIndex, fQ1131_21); + histos.get(HIST("Prof2D_Q1131_20"))->Fill(cent, sampleIndex, fQ1131_20); + histos.get(HIST("Prof2D_Q1131_31"))->Fill(cent, sampleIndex, fQ1131_31); + histos.get(HIST("Prof2D_Q1131_30"))->Fill(cent, sampleIndex, fQ1131_30); + histos.get(HIST("Prof2D_Q1132_21"))->Fill(cent, sampleIndex, fQ1132_21); + histos.get(HIST("Prof2D_Q1132_20"))->Fill(cent, sampleIndex, fQ1132_20); + histos.get(HIST("Prof2D_Q1132_31"))->Fill(cent, sampleIndex, fQ1132_31); + histos.get(HIST("Prof2D_Q1132_30"))->Fill(cent, sampleIndex, fQ1132_30); + histos.get(HIST("Prof2D_Q1133_21"))->Fill(cent, sampleIndex, fQ1133_21); + histos.get(HIST("Prof2D_Q1133_20"))->Fill(cent, sampleIndex, fQ1133_20); + histos.get(HIST("Prof2D_Q1133_31"))->Fill(cent, sampleIndex, fQ1133_31); + histos.get(HIST("Prof2D_Q1133_30"))->Fill(cent, sampleIndex, fQ1133_30); + histos.get(HIST("Prof2D_Q11_5"))->Fill(cent, sampleIndex, fQ11_5); + histos.get(HIST("Prof2D_Q11_6"))->Fill(cent, sampleIndex, fQ11_6); + histos.get(HIST("Prof2D_Q1121_30"))->Fill(cent, sampleIndex, fQ1121_30); + histos.get(HIST("Prof2D_Q1121_31"))->Fill(cent, sampleIndex, fQ1121_31); + histos.get(HIST("Prof2D_Q1121_40"))->Fill(cent, sampleIndex, fQ1121_40); + histos.get(HIST("Prof2D_Q1121_41"))->Fill(cent, sampleIndex, fQ1121_41); + histos.get(HIST("Prof2D_Q1122_30"))->Fill(cent, sampleIndex, fQ1122_30); + histos.get(HIST("Prof2D_Q1122_31"))->Fill(cent, sampleIndex, fQ1122_31); + histos.get(HIST("Prof2D_Q1122_40"))->Fill(cent, sampleIndex, fQ1122_40); + histos.get(HIST("Prof2D_Q1122_41"))->Fill(cent, sampleIndex, fQ1122_41); + histos.get(HIST("Prof2D_Q2211_11"))->Fill(cent, sampleIndex, fQ2211_11); + histos.get(HIST("Prof2D_Q2211_01"))->Fill(cent, sampleIndex, fQ2211_01); + histos.get(HIST("Prof2D_Q2211_10"))->Fill(cent, sampleIndex, fQ2211_10); + histos.get(HIST("Prof2D_Q2211_20"))->Fill(cent, sampleIndex, fQ2211_20); + histos.get(HIST("Prof2D_Q2211_21"))->Fill(cent, sampleIndex, fQ2211_21); + histos.get(HIST("Prof2D_Q2111_11"))->Fill(cent, sampleIndex, fQ2111_11); + histos.get(HIST("Prof2D_Q2111_01"))->Fill(cent, sampleIndex, fQ2111_01); + histos.get(HIST("Prof2D_Q2111_10"))->Fill(cent, sampleIndex, fQ2111_10); + histos.get(HIST("Prof2D_Q2111_20"))->Fill(cent, sampleIndex, fQ2111_20); + histos.get(HIST("Prof2D_Q2111_21"))->Fill(cent, sampleIndex, fQ2111_21); + histos.get(HIST("Prof2D_Q112122_001"))->Fill(cent, sampleIndex, fQ112122_001); + histos.get(HIST("Prof2D_Q112122_010"))->Fill(cent, sampleIndex, fQ112122_010); + histos.get(HIST("Prof2D_Q112122_100"))->Fill(cent, sampleIndex, fQ112122_100); + histos.get(HIST("Prof2D_Q112122_011"))->Fill(cent, sampleIndex, fQ112122_011); + histos.get(HIST("Prof2D_Q112122_101"))->Fill(cent, sampleIndex, fQ112122_101); + histos.get(HIST("Prof2D_Q112122_110"))->Fill(cent, sampleIndex, fQ112122_110); + histos.get(HIST("Prof2D_Q1141_11"))->Fill(cent, sampleIndex, fQ1141_11); + histos.get(HIST("Prof2D_Q1141_01"))->Fill(cent, sampleIndex, fQ1141_01); + histos.get(HIST("Prof2D_Q1141_10"))->Fill(cent, sampleIndex, fQ1141_10); + histos.get(HIST("Prof2D_Q1141_20"))->Fill(cent, sampleIndex, fQ1141_20); + histos.get(HIST("Prof2D_Q1141_21"))->Fill(cent, sampleIndex, fQ1141_21); + histos.get(HIST("Prof2D_Q1142_11"))->Fill(cent, sampleIndex, fQ1142_11); + histos.get(HIST("Prof2D_Q1142_01"))->Fill(cent, sampleIndex, fQ1142_01); + histos.get(HIST("Prof2D_Q1142_10"))->Fill(cent, sampleIndex, fQ1142_10); + histos.get(HIST("Prof2D_Q1142_20"))->Fill(cent, sampleIndex, fQ1142_20); + histos.get(HIST("Prof2D_Q1142_21"))->Fill(cent, sampleIndex, fQ1142_21); + histos.get(HIST("Prof2D_Q1143_11"))->Fill(cent, sampleIndex, fQ1143_11); + histos.get(HIST("Prof2D_Q1143_01"))->Fill(cent, sampleIndex, fQ1143_01); + histos.get(HIST("Prof2D_Q1143_10"))->Fill(cent, sampleIndex, fQ1143_10); + histos.get(HIST("Prof2D_Q1143_20"))->Fill(cent, sampleIndex, fQ1143_20); + histos.get(HIST("Prof2D_Q1143_21"))->Fill(cent, sampleIndex, fQ1143_21); + histos.get(HIST("Prof2D_Q1144_11"))->Fill(cent, sampleIndex, fQ1144_11); + histos.get(HIST("Prof2D_Q1144_01"))->Fill(cent, sampleIndex, fQ1144_01); + histos.get(HIST("Prof2D_Q1144_10"))->Fill(cent, sampleIndex, fQ1144_10); + histos.get(HIST("Prof2D_Q1144_20"))->Fill(cent, sampleIndex, fQ1144_20); + histos.get(HIST("Prof2D_Q1144_21"))->Fill(cent, sampleIndex, fQ1144_21); + histos.get(HIST("Prof2D_Q2131_11"))->Fill(cent, sampleIndex, fQ2131_11); + histos.get(HIST("Prof2D_Q2131_01"))->Fill(cent, sampleIndex, fQ2131_01); + histos.get(HIST("Prof2D_Q2131_10"))->Fill(cent, sampleIndex, fQ2131_10); + histos.get(HIST("Prof2D_Q2132_11"))->Fill(cent, sampleIndex, fQ2132_11); + histos.get(HIST("Prof2D_Q2132_01"))->Fill(cent, sampleIndex, fQ2132_01); + histos.get(HIST("Prof2D_Q2132_10"))->Fill(cent, sampleIndex, fQ2132_10); + histos.get(HIST("Prof2D_Q2133_11"))->Fill(cent, sampleIndex, fQ2133_11); + histos.get(HIST("Prof2D_Q2133_01"))->Fill(cent, sampleIndex, fQ2133_01); + histos.get(HIST("Prof2D_Q2133_10"))->Fill(cent, sampleIndex, fQ2133_10); + histos.get(HIST("Prof2D_Q2231_11"))->Fill(cent, sampleIndex, fQ2231_11); + histos.get(HIST("Prof2D_Q2231_01"))->Fill(cent, sampleIndex, fQ2231_01); + histos.get(HIST("Prof2D_Q2231_10"))->Fill(cent, sampleIndex, fQ2231_10); + histos.get(HIST("Prof2D_Q2232_11"))->Fill(cent, sampleIndex, fQ2232_11); + histos.get(HIST("Prof2D_Q2232_01"))->Fill(cent, sampleIndex, fQ2232_01); + histos.get(HIST("Prof2D_Q2232_10"))->Fill(cent, sampleIndex, fQ2232_10); + histos.get(HIST("Prof2D_Q2233_11"))->Fill(cent, sampleIndex, fQ2233_11); + histos.get(HIST("Prof2D_Q2233_01"))->Fill(cent, sampleIndex, fQ2233_01); + histos.get(HIST("Prof2D_Q2233_10"))->Fill(cent, sampleIndex, fQ2233_10); + histos.get(HIST("Prof2D_Q51_1"))->Fill(cent, sampleIndex, fQ51_1); + histos.get(HIST("Prof2D_Q52_1"))->Fill(cent, sampleIndex, fQ52_1); + histos.get(HIST("Prof2D_Q53_1"))->Fill(cent, sampleIndex, fQ53_1); + histos.get(HIST("Prof2D_Q54_1"))->Fill(cent, sampleIndex, fQ54_1); + histos.get(HIST("Prof2D_Q55_1"))->Fill(cent, sampleIndex, fQ55_1); + histos.get(HIST("Prof2D_Q21_3"))->Fill(cent, sampleIndex, fQ21_3); + histos.get(HIST("Prof2D_Q22_3"))->Fill(cent, sampleIndex, fQ22_3); + histos.get(HIST("Prof2D_Q31_2"))->Fill(cent, sampleIndex, fQ31_2); + histos.get(HIST("Prof2D_Q32_2"))->Fill(cent, sampleIndex, fQ32_2); + histos.get(HIST("Prof2D_Q33_2"))->Fill(cent, sampleIndex, fQ33_2); + histos.get(HIST("Prof2D_Q61_1"))->Fill(cent, sampleIndex, fQ61_1); + histos.get(HIST("Prof2D_Q62_1"))->Fill(cent, sampleIndex, fQ62_1); + histos.get(HIST("Prof2D_Q63_1"))->Fill(cent, sampleIndex, fQ63_1); + histos.get(HIST("Prof2D_Q64_1"))->Fill(cent, sampleIndex, fQ64_1); + histos.get(HIST("Prof2D_Q65_1"))->Fill(cent, sampleIndex, fQ65_1); + histos.get(HIST("Prof2D_Q66_1"))->Fill(cent, sampleIndex, fQ66_1); + histos.get(HIST("Prof2D_Q112122_111"))->Fill(cent, sampleIndex, fQ112122_111); + histos.get(HIST("Prof2D_Q112131_111"))->Fill(cent, sampleIndex, fQ112131_111); + histos.get(HIST("Prof2D_Q112132_111"))->Fill(cent, sampleIndex, fQ112132_111); + histos.get(HIST("Prof2D_Q112133_111"))->Fill(cent, sampleIndex, fQ112133_111); + histos.get(HIST("Prof2D_Q112231_111"))->Fill(cent, sampleIndex, fQ112231_111); + histos.get(HIST("Prof2D_Q112232_111"))->Fill(cent, sampleIndex, fQ112232_111); + histos.get(HIST("Prof2D_Q112233_111"))->Fill(cent, sampleIndex, fQ112233_111); + histos.get(HIST("Prof2D_Q112221_111"))->Fill(cent, sampleIndex, fQ112221_111); + } + } + PROCESS_SWITCH(NetprotonCumulantsMc, processMCRec, "Process Generated", true); + + void processDataRec(AodCollisions::iterator const& coll, aod::BCsWithTimestamps const&, AodTracks const& inputTracks) + { + if (!coll.sel8()) { + return; + } + if (cfgUseGoodITSLayerAllCut && !(coll.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))) { + return; + } + if (cfgEvSelkNoSameBunchPileup && !(coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return; + } + + if (cfgEvSelkIsVertexTOFmatched && !(coll.selection_bit(o2::aod::evsel::kIsVertexTOFmatched))) { + return; + ; + } + + histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); + // variables + auto cent = coll.centFT0M(); + histos.fill(HIST("hCentrec"), cent); + + float nProt = 0.0; + float nAntiprot = 0.0; + std::array powerEffProt = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array powerEffAntiprot = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array fTCP0 = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + std::array fTCP1 = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + + o2::aod::ITSResponse itsResponse; + + // Start of the Monte-Carlo reconstructed tracks + for (const auto& track : inputTracks) { + if (!track.has_collision()) { + continue; + } + + if (!track.isPVContributor()) //! track check as used in data + { + continue; + } + if ((track.pt() < cfgCutPtLower) || (track.pt() > 5.0f) || (std::abs(track.eta()) > cfgCutEta)) { + continue; + } + if (!(track.itsNCls() > cfgITScluster) || !(track.tpcNClsFound() >= cfgTPCcluster) || !(track.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) { + continue; + } + + histos.fill(HIST("hrecPtAll"), track.pt()); + histos.fill(HIST("hrecEtaAll"), track.eta()); + histos.fill(HIST("hrecPhiAll"), track.phi()); + histos.fill(HIST("hrecDcaXYAll"), track.dcaXY()); + histos.fill(HIST("hrecDcaZAll"), track.dcaZ()); + + // rejecting electron + if (cfgIfRejectElectron && isElectron(track)) { + continue; + } + // use ITS pid as well + if (cfgUseItsPid && (std::abs(itsResponse.nSigmaITS(track)) > 3.0)) { + continue; + } + // required tracks with TOF mandatory to avoid pileup + if (cfgIfMandatoryTOF && !track.hasTOF()) { + continue; + } + + bool trackSelected = false; + if (cfgPIDchoice == 0) + trackSelected = selectionPIDoldTOFveto(track); + if (cfgPIDchoice == 1) + trackSelected = selectionPIDnew(track); + if (cfgPIDchoice == 2) + trackSelected = selectionPIDold(track); + + if (trackSelected) { + // filling nSigma distribution + histos.fill(HIST("h2DnsigmaTpcVsPt"), track.pt(), track.tpcNSigmaPr()); + histos.fill(HIST("h2DnsigmaTofVsPt"), track.pt(), track.tofNSigmaPr()); + histos.fill(HIST("h2DnsigmaItsVsPt"), track.pt(), itsResponse.nSigmaITS(track)); + + // for protons + if (track.sign() > 0) { + histos.fill(HIST("hrecPtProton"), track.pt()); //! hist for p rec + histos.fill(HIST("hrecPtDistProtonVsCentrality"), track.pt(), cent); + histos.fill(HIST("hrecEtaProton"), track.eta()); + histos.fill(HIST("hrecPhiProton"), track.phi()); + histos.fill(HIST("hrecDcaXYProton"), track.dcaXY()); + histos.fill(HIST("hrecDcaZProton"), track.dcaZ()); + + if (track.pt() < cfgCutPtUpper) { + nProt = nProt + 1.0; + float pEff = getEfficiency(track); // get efficiency of track + if (pEff != 0) { + for (int i = 1; i < 7; i++) { + powerEffProt[i] += std::pow(1.0 / pEff, i); + } + } + } + } + // for anti-protons + if (track.sign() < 0) { + histos.fill(HIST("hrecPtAntiproton"), track.pt()); //! hist for anti-p rec + histos.fill(HIST("hrecPtDistAntiprotonVsCentrality"), track.pt(), cent); + histos.fill(HIST("hrecEtaAntiproton"), track.eta()); + histos.fill(HIST("hrecPhiAntiproton"), track.phi()); + histos.fill(HIST("hrecDcaXYAntiproton"), track.dcaXY()); + histos.fill(HIST("hrecDcaZAntiproton"), track.dcaZ()); + if (track.pt() < cfgCutPtUpper) { + nAntiprot = nAntiprot + 1.0; + float pEff = getEfficiency(track); // get efficiency of track + if (pEff != 0) { + for (int i = 1; i < 7; i++) { + powerEffAntiprot[i] += std::pow(1.0 / pEff, i); + } + } + } + } + + } //! checking PID + } //! end track loop + + float netProt = nProt - nAntiprot; + histos.fill(HIST("hrecNetProtonVsCentrality"), netProt, cent); + histos.fill(HIST("hrecProtonVsCentrality"), nProt, cent); + histos.fill(HIST("hrecAntiprotonVsCentrality"), nAntiprot, cent); + histos.fill(HIST("hrecProfileTotalProton"), cent, (nProt + nAntiprot)); + histos.fill(HIST("hrecProfileProton"), cent, nProt); + histos.fill(HIST("hrecProfileAntiproton"), cent, nAntiprot); + histos.fill(HIST("hCorrProfileTotalProton"), cent, (powerEffProt[1] + powerEffAntiprot[1])); + histos.fill(HIST("hCorrProfileProton"), cent, powerEffProt[1]); + histos.fill(HIST("hCorrProfileAntiproton"), cent, powerEffAntiprot[1]); + + // Calculating q_{r,s} as required + for (int i = 1; i < 7; i++) { + fTCP0[i] = powerEffProt[i] + powerEffAntiprot[i]; + fTCP1[i] = powerEffProt[i] - powerEffAntiprot[i]; + } + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + float fQ11_1 = fTCP1[1]; + float fQ11_2 = std::pow(fTCP1[1], 2); + float fQ11_3 = std::pow(fTCP1[1], 3); + float fQ11_4 = std::pow(fTCP1[1], 4); + float fQ11_5 = std::pow(fTCP1[1], 5); + float fQ11_6 = std::pow(fTCP1[1], 6); + + float fQ21_3 = std::pow(fTCP0[1], 3); + float fQ22_3 = std::pow(fTCP0[2], 3); + float fQ31_2 = std::pow(fTCP1[1], 2); + float fQ32_2 = std::pow(fTCP1[2], 2); + float fQ33_2 = std::pow(fTCP1[3], 2); + + float fQ61_1 = fTCP0[1]; + float fQ62_1 = fTCP0[2]; + float fQ63_1 = fTCP0[3]; + float fQ64_1 = fTCP0[4]; + float fQ65_1 = fTCP0[5]; + float fQ66_1 = fTCP0[6]; + + float fQ112122_111 = fTCP1[1] * fTCP0[1] * fTCP0[2]; + float fQ112131_111 = fTCP1[1] * fTCP0[1] * fTCP1[1]; + float fQ112132_111 = fTCP1[1] * fTCP0[1] * fTCP1[2]; + float fQ112133_111 = fTCP1[1] * fTCP0[1] * fTCP1[3]; + float fQ112231_111 = fTCP1[1] * fTCP0[2] * fTCP1[1]; + float fQ112232_111 = fTCP1[1] * fTCP0[2] * fTCP1[2]; + float fQ112233_111 = fTCP1[1] * fTCP0[2] * fTCP1[3]; + float fQ112221_111 = fTCP1[1] * fTCP0[2] * fTCP0[1]; + + float fQ21_1 = fTCP0[1]; + float fQ22_1 = fTCP0[2]; + float fQ31_1 = fTCP1[1]; + float fQ32_1 = fTCP1[2]; + float fQ33_1 = fTCP1[3]; + float fQ41_1 = fTCP0[1]; + float fQ42_1 = fTCP0[2]; + float fQ43_1 = fTCP0[3]; + float fQ44_1 = fTCP0[4]; + float fQ21_2 = std::pow(fTCP0[1], 2); + float fQ22_2 = std::pow(fTCP0[2], 2); + float fQ1121_11 = fTCP1[1] * fTCP0[1]; + float fQ1121_01 = fTCP0[1]; + float fQ1121_10 = fTCP1[1]; + float fQ1121_20 = std::pow(fTCP1[1], 2); + float fQ1121_21 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ1122_11 = fTCP1[1] * fTCP0[2]; + float fQ1122_01 = fTCP0[2]; + float fQ1122_10 = fTCP1[1]; + float fQ1122_20 = std::pow(fTCP1[1], 2); + float fQ1122_21 = std::pow(fTCP1[1], 2) * fTCP0[2]; + float fQ1131_11 = fTCP1[1] * fTCP1[1]; + float fQ1131_01 = fTCP1[1]; + float fQ1131_10 = fTCP1[1]; + float fQ1132_11 = fTCP1[1] * fTCP1[2]; + float fQ1132_01 = fTCP1[2]; + float fQ1132_10 = fTCP1[1]; + float fQ1133_11 = fTCP1[1] * fTCP1[3]; + float fQ1133_01 = fTCP1[3]; + float fQ1133_10 = fTCP1[1]; + float fQ2122_11 = fTCP0[1] * fTCP0[2]; + float fQ2122_01 = fTCP0[2]; + float fQ2122_10 = fTCP0[1]; + + ///////////////---------------------> + float fQ3132_11 = fTCP1[1] * fTCP1[2]; + float fQ3132_01 = fTCP1[2]; + float fQ3132_10 = fTCP1[1]; + float fQ3133_11 = fTCP1[1] * fTCP1[3]; + float fQ3133_01 = fTCP1[3]; + float fQ3133_10 = fTCP1[1]; + float fQ3233_11 = fTCP1[2] * fTCP1[3]; + float fQ3233_01 = fTCP1[3]; + float fQ3233_10 = fTCP1[2]; + float fQ2241_11 = fTCP0[2] * fTCP0[1]; + float fQ2241_01 = fTCP0[1]; + float fQ2241_10 = fTCP0[2]; + float fQ2242_11 = fTCP0[2] * fTCP0[2]; + float fQ2242_01 = fTCP0[2]; + float fQ2242_10 = fTCP0[2]; + float fQ2243_11 = fTCP0[2] * fTCP0[3]; + float fQ2243_01 = fTCP0[3]; + float fQ2243_10 = fTCP0[2]; + float fQ2244_11 = fTCP0[2] * fTCP0[4]; + float fQ2244_01 = fTCP0[4]; + float fQ2244_10 = fTCP0[2]; + float fQ2141_11 = fTCP0[1] * fTCP0[1]; + float fQ2141_01 = fTCP0[1]; + float fQ2141_10 = fTCP0[1]; + float fQ2142_11 = fTCP0[1] * fTCP0[2]; + float fQ2142_01 = fTCP0[2]; + float fQ2142_10 = fTCP0[1]; + float fQ2143_11 = fTCP0[1] * fTCP0[3]; + float fQ2143_01 = fTCP0[3]; + float fQ2143_10 = fTCP0[1]; + float fQ2144_11 = fTCP0[1] * fTCP0[4]; + float fQ2144_01 = fTCP0[4]; + float fQ2144_10 = fTCP0[1]; + float fQ1151_11 = fTCP1[1] * fTCP1[1]; + float fQ1151_01 = fTCP1[1]; + float fQ1151_10 = fTCP1[1]; + float fQ1152_11 = fTCP1[1] * fTCP1[2]; + float fQ1152_01 = fTCP1[2]; + float fQ1152_10 = fTCP1[1]; + float fQ1153_11 = fTCP1[1] * fTCP1[3]; + float fQ1153_01 = fTCP1[3]; + float fQ1153_10 = fTCP1[1]; + float fQ1154_11 = fTCP1[1] * fTCP1[4]; + float fQ1154_01 = fTCP1[4]; + float fQ1154_10 = fTCP1[1]; + float fQ1155_11 = fTCP1[1] * fTCP1[5]; + float fQ1155_01 = fTCP1[5]; + float fQ1155_10 = fTCP1[1]; + + float fQ112233_001 = fTCP1[3]; + float fQ112233_010 = fTCP0[2]; + float fQ112233_100 = fTCP1[1]; + float fQ112233_011 = fTCP0[2] * fTCP1[3]; + float fQ112233_101 = fTCP1[1] * fTCP1[3]; + float fQ112233_110 = fTCP1[1] * fTCP0[2]; + float fQ112232_001 = fTCP1[2]; + float fQ112232_010 = fTCP0[2]; + float fQ112232_100 = fTCP1[1]; + float fQ112232_011 = fTCP0[2] * fTCP1[2]; + float fQ112232_101 = fTCP1[1] * fTCP1[2]; + float fQ112232_110 = fTCP1[1] * fTCP0[2]; + // + float fQ112231_001 = fTCP1[1]; + float fQ112231_010 = fTCP0[2]; + float fQ112231_100 = fTCP1[1]; + float fQ112231_011 = fTCP0[2] * fTCP1[1]; + float fQ112231_101 = fTCP1[1] * fTCP1[1]; + float fQ112231_110 = fTCP1[1] * fTCP0[2]; + float fQ112133_001 = fTCP1[3]; + float fQ112133_010 = fTCP0[1]; + float fQ112133_100 = fTCP1[1]; + float fQ112133_011 = fTCP0[1] * fTCP1[3]; + float fQ112133_101 = fTCP1[1] * fTCP1[3]; + float fQ112133_110 = fTCP1[1] * fTCP0[1]; + + float fQ112132_001 = fTCP1[2]; + float fQ112132_010 = fTCP0[1]; + float fQ112132_100 = fTCP1[1]; + float fQ112132_011 = fTCP0[1] * fTCP1[2]; + float fQ112132_101 = fTCP1[1] * fTCP1[2]; + float fQ112132_110 = fTCP1[1] * fTCP0[1]; + float fQ112131_001 = fTCP1[1]; + float fQ112131_010 = fTCP0[1]; + float fQ112131_100 = fTCP1[1]; + float fQ112131_011 = fTCP0[1] * fTCP1[1]; + float fQ112131_101 = fTCP1[1] * fTCP1[1]; + float fQ112131_110 = fTCP1[1] * fTCP0[1]; + + float fQ2221_11 = fTCP0[2] * fTCP0[1]; + float fQ2221_01 = fTCP0[1]; + float fQ2221_10 = fTCP0[2]; + float fQ2221_21 = std::pow(fTCP0[2], 2) * fTCP0[1]; + float fQ2221_20 = std::pow(fTCP0[2], 2); + + float fQ2122_21 = std::pow(fTCP0[1], 2) * fTCP0[2]; + float fQ2122_20 = std::pow(fTCP0[1], 2); + float fQ1121_02 = std::pow(fTCP0[1], 2); + float fQ1121_12 = fTCP1[1] * std::pow(fTCP0[1], 2); + float fQ1121_22 = std::pow(fTCP1[1], 2) * std::pow(fTCP0[1], 2); + float fQ1122_02 = std::pow(fTCP0[2], 2); + float fQ1122_12 = fTCP1[1] * std::pow(fTCP0[2], 2); + float fQ1122_22 = std::pow(fTCP1[1], 2) * std::pow(fTCP0[2], 2); + + float fQ112221_001 = fTCP0[1]; + float fQ112221_010 = fTCP0[2]; + float fQ112221_100 = fTCP1[1]; + float fQ112221_011 = fTCP0[2] * fTCP0[1]; + float fQ112221_101 = fTCP1[1] * fTCP0[1]; + float fQ112221_110 = fTCP1[1] * fTCP0[2]; + float fQ112221_200 = std::pow(fTCP1[1], 2); + float fQ112221_201 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ112221_210 = std::pow(fTCP1[1], 2) * fTCP0[2]; + float fQ112221_211 = std::pow(fTCP1[1], 2) * fTCP0[2] * fTCP0[1]; + float fQ1131_21 = std::pow(fTCP1[1], 2) * fTCP1[1]; + float fQ1131_20 = std::pow(fTCP1[1], 2); + float fQ1131_31 = std::pow(fTCP1[1], 3) * fTCP1[1]; + float fQ1131_30 = std::pow(fTCP1[1], 3); + + float fQ1132_21 = std::pow(fTCP1[1], 2) * fTCP1[2]; + float fQ1132_20 = std::pow(fTCP1[1], 2); + float fQ1132_31 = std::pow(fTCP1[1], 3) * fTCP1[2]; + float fQ1132_30 = std::pow(fTCP1[1], 3); + float fQ1133_21 = std::pow(fTCP1[1], 2) * fTCP1[3]; + float fQ1133_20 = std::pow(fTCP1[1], 2); + float fQ1133_31 = std::pow(fTCP1[1], 3) * fTCP1[3]; + float fQ1133_30 = std::pow(fTCP1[1], 3); + float fQ1121_30 = std::pow(fTCP1[1], 3); + float fQ1121_31 = std::pow(fTCP1[1], 3) * fTCP0[1]; + float fQ1121_40 = std::pow(fTCP1[1], 4); + float fQ1121_41 = std::pow(fTCP1[1], 4) * fTCP0[1]; + float fQ1122_30 = std::pow(fTCP1[1], 3); + float fQ1122_31 = std::pow(fTCP1[1], 3) * fTCP0[2]; + float fQ1122_40 = std::pow(fTCP1[1], 4); + float fQ1122_41 = std::pow(fTCP1[1], 4) * fTCP0[2]; + + float fQ2211_11 = fTCP0[2] * fTCP1[1]; + float fQ2211_01 = fTCP1[1]; + float fQ2211_10 = fTCP0[2]; + float fQ2211_20 = std::pow(fTCP0[2], 2); + float fQ2211_21 = std::pow(fTCP0[2], 2) * fTCP1[1]; + float fQ2111_11 = fTCP0[1] * fTCP1[1]; + float fQ2111_01 = fTCP1[1]; + float fQ2111_10 = fTCP0[1]; + float fQ2111_20 = std::pow(fTCP0[1], 2); + float fQ2111_21 = std::pow(fTCP0[1], 2) * fTCP1[1]; + + float fQ112122_001 = fTCP0[2]; + float fQ112122_010 = fTCP0[1]; + float fQ112122_100 = fTCP1[1]; + float fQ112122_011 = fTCP0[1] * fTCP0[2]; + float fQ112122_101 = fTCP1[1] * fTCP0[2]; + float fQ112122_110 = fTCP1[1] * fTCP0[1]; + + float fQ1141_11 = fTCP1[1] * fTCP0[1]; + float fQ1141_01 = fTCP0[1]; + float fQ1141_10 = fTCP1[1]; + float fQ1141_20 = std::pow(fTCP1[1], 2); + float fQ1141_21 = std::pow(fTCP1[1], 2) * fTCP0[1]; + float fQ1142_11 = fTCP1[1] * fTCP0[2]; + float fQ1142_01 = fTCP0[2]; + float fQ1142_10 = fTCP1[1]; + float fQ1142_20 = std::pow(fTCP1[1], 2); + float fQ1142_21 = std::pow(fTCP1[1], 2) * fTCP0[2]; + + float fQ1143_11 = fTCP1[1] * fTCP0[3]; + float fQ1143_01 = fTCP0[3]; + float fQ1143_10 = fTCP1[1]; + float fQ1143_20 = std::pow(fTCP1[1], 2); + float fQ1143_21 = std::pow(fTCP1[1], 2) * fTCP0[3]; + float fQ1144_11 = fTCP1[1] * fTCP0[4]; + float fQ1144_01 = fTCP0[4]; + float fQ1144_10 = fTCP1[1]; + float fQ1144_20 = std::pow(fTCP1[1], 2); + float fQ1144_21 = std::pow(fTCP1[1], 2) * fTCP0[4]; + float fQ2131_11 = fTCP0[1] * fTCP1[1]; + float fQ2131_01 = fTCP1[1]; + float fQ2131_10 = fTCP0[1]; + + float fQ2132_11 = fTCP0[1] * fTCP1[2]; + float fQ2132_01 = fTCP1[2]; + float fQ2132_10 = fTCP0[1]; + float fQ2133_11 = fTCP0[1] * fTCP1[3]; + float fQ2133_01 = fTCP1[3]; + float fQ2133_10 = fTCP0[1]; + float fQ2231_11 = fTCP0[2] * fTCP1[1]; + float fQ2231_01 = fTCP1[1]; + float fQ2231_10 = fTCP0[2]; + float fQ2232_11 = fTCP0[2] * fTCP1[2]; + float fQ2232_01 = fTCP1[2]; + float fQ2232_10 = fTCP0[2]; + float fQ2233_11 = fTCP0[2] * fTCP1[3]; + float fQ2233_01 = fTCP1[3]; + float fQ2233_10 = fTCP0[2]; + + float fQ51_1 = fTCP1[1]; + float fQ52_1 = fTCP1[2]; + float fQ53_1 = fTCP1[3]; + float fQ54_1 = fTCP1[4]; + float fQ55_1 = fTCP1[5]; + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + if (cfgIsCalculateCentral) { + + // uncorrected + histos.get(HIST("Prof_mu1_netproton"))->Fill(cent, std::pow(netProt, 1.0)); + histos.get(HIST("Prof_mu2_netproton"))->Fill(cent, std::pow(netProt, 2.0)); + histos.get(HIST("Prof_mu3_netproton"))->Fill(cent, std::pow(netProt, 3.0)); + histos.get(HIST("Prof_mu4_netproton"))->Fill(cent, std::pow(netProt, 4.0)); + histos.get(HIST("Prof_mu5_netproton"))->Fill(cent, std::pow(netProt, 5.0)); + histos.get(HIST("Prof_mu6_netproton"))->Fill(cent, std::pow(netProt, 6.0)); + histos.get(HIST("Prof_mu7_netproton"))->Fill(cent, std::pow(netProt, 7.0)); + histos.get(HIST("Prof_mu8_netproton"))->Fill(cent, std::pow(netProt, 8.0)); + + // eff. corrected + histos.get(HIST("Prof_Q11_1"))->Fill(cent, fQ11_1); + histos.get(HIST("Prof_Q11_2"))->Fill(cent, fQ11_2); + histos.get(HIST("Prof_Q11_3"))->Fill(cent, fQ11_3); + histos.get(HIST("Prof_Q11_4"))->Fill(cent, fQ11_4); + histos.get(HIST("Prof_Q21_1"))->Fill(cent, fQ21_1); + histos.get(HIST("Prof_Q22_1"))->Fill(cent, fQ22_1); + histos.get(HIST("Prof_Q31_1"))->Fill(cent, fQ31_1); + histos.get(HIST("Prof_Q32_1"))->Fill(cent, fQ32_1); + histos.get(HIST("Prof_Q33_1"))->Fill(cent, fQ33_1); + histos.get(HIST("Prof_Q41_1"))->Fill(cent, fQ41_1); + histos.get(HIST("Prof_Q42_1"))->Fill(cent, fQ42_1); + histos.get(HIST("Prof_Q43_1"))->Fill(cent, fQ43_1); + histos.get(HIST("Prof_Q44_1"))->Fill(cent, fQ44_1); + histos.get(HIST("Prof_Q21_2"))->Fill(cent, fQ21_2); + histos.get(HIST("Prof_Q22_2"))->Fill(cent, fQ22_2); + histos.get(HIST("Prof_Q1121_11"))->Fill(cent, fQ1121_11); + histos.get(HIST("Prof_Q1121_01"))->Fill(cent, fQ1121_01); + histos.get(HIST("Prof_Q1121_10"))->Fill(cent, fQ1121_10); + histos.get(HIST("Prof_Q1121_20"))->Fill(cent, fQ1121_20); + histos.get(HIST("Prof_Q1121_21"))->Fill(cent, fQ1121_21); + histos.get(HIST("Prof_Q1122_11"))->Fill(cent, fQ1122_11); + histos.get(HIST("Prof_Q1122_01"))->Fill(cent, fQ1122_01); + histos.get(HIST("Prof_Q1122_10"))->Fill(cent, fQ1122_10); + histos.get(HIST("Prof_Q1122_20"))->Fill(cent, fQ1122_20); + histos.get(HIST("Prof_Q1122_21"))->Fill(cent, fQ1122_21); + histos.get(HIST("Prof_Q1131_11"))->Fill(cent, fQ1131_11); + histos.get(HIST("Prof_Q1131_01"))->Fill(cent, fQ1131_01); + histos.get(HIST("Prof_Q1131_10"))->Fill(cent, fQ1131_10); + histos.get(HIST("Prof_Q1132_11"))->Fill(cent, fQ1132_11); + histos.get(HIST("Prof_Q1132_01"))->Fill(cent, fQ1132_01); + histos.get(HIST("Prof_Q1132_10"))->Fill(cent, fQ1132_10); + histos.get(HIST("Prof_Q1133_11"))->Fill(cent, fQ1133_11); + histos.get(HIST("Prof_Q1133_01"))->Fill(cent, fQ1133_01); + histos.get(HIST("Prof_Q1133_10"))->Fill(cent, fQ1133_10); + histos.get(HIST("Prof_Q2122_11"))->Fill(cent, fQ2122_11); + histos.get(HIST("Prof_Q2122_01"))->Fill(cent, fQ2122_01); + histos.get(HIST("Prof_Q2122_10"))->Fill(cent, fQ2122_10); + histos.get(HIST("Prof_Q3132_11"))->Fill(cent, fQ3132_11); + histos.get(HIST("Prof_Q3132_01"))->Fill(cent, fQ3132_01); + histos.get(HIST("Prof_Q3132_10"))->Fill(cent, fQ3132_10); + histos.get(HIST("Prof_Q3133_11"))->Fill(cent, fQ3133_11); + histos.get(HIST("Prof_Q3133_01"))->Fill(cent, fQ3133_01); + histos.get(HIST("Prof_Q3133_10"))->Fill(cent, fQ3133_10); + histos.get(HIST("Prof_Q3233_11"))->Fill(cent, fQ3233_11); + histos.get(HIST("Prof_Q3233_01"))->Fill(cent, fQ3233_01); + histos.get(HIST("Prof_Q3233_10"))->Fill(cent, fQ3233_10); + histos.get(HIST("Prof_Q2241_11"))->Fill(cent, fQ2241_11); + histos.get(HIST("Prof_Q2241_01"))->Fill(cent, fQ2241_01); + histos.get(HIST("Prof_Q2241_10"))->Fill(cent, fQ2241_10); + histos.get(HIST("Prof_Q2242_11"))->Fill(cent, fQ2242_11); + histos.get(HIST("Prof_Q2242_01"))->Fill(cent, fQ2242_01); + histos.get(HIST("Prof_Q2242_10"))->Fill(cent, fQ2242_10); + histos.get(HIST("Prof_Q2243_11"))->Fill(cent, fQ2243_11); + histos.get(HIST("Prof_Q2243_01"))->Fill(cent, fQ2243_01); + histos.get(HIST("Prof_Q2243_10"))->Fill(cent, fQ2243_10); + histos.get(HIST("Prof_Q2244_11"))->Fill(cent, fQ2244_11); + histos.get(HIST("Prof_Q2244_01"))->Fill(cent, fQ2244_01); + histos.get(HIST("Prof_Q2244_10"))->Fill(cent, fQ2244_10); + histos.get(HIST("Prof_Q2141_11"))->Fill(cent, fQ2141_11); + histos.get(HIST("Prof_Q2141_01"))->Fill(cent, fQ2141_01); + histos.get(HIST("Prof_Q2141_10"))->Fill(cent, fQ2141_10); + histos.get(HIST("Prof_Q2142_11"))->Fill(cent, fQ2142_11); + histos.get(HIST("Prof_Q2142_01"))->Fill(cent, fQ2142_01); + histos.get(HIST("Prof_Q2142_10"))->Fill(cent, fQ2142_10); + histos.get(HIST("Prof_Q2143_11"))->Fill(cent, fQ2143_11); + histos.get(HIST("Prof_Q2143_01"))->Fill(cent, fQ2143_01); + histos.get(HIST("Prof_Q2143_10"))->Fill(cent, fQ2143_10); + histos.get(HIST("Prof_Q2144_11"))->Fill(cent, fQ2144_11); + histos.get(HIST("Prof_Q2144_01"))->Fill(cent, fQ2144_01); + histos.get(HIST("Prof_Q2144_10"))->Fill(cent, fQ2144_10); + histos.get(HIST("Prof_Q1151_11"))->Fill(cent, fQ1151_11); + histos.get(HIST("Prof_Q1151_01"))->Fill(cent, fQ1151_01); + histos.get(HIST("Prof_Q1151_10"))->Fill(cent, fQ1151_10); + histos.get(HIST("Prof_Q1152_11"))->Fill(cent, fQ1152_11); + histos.get(HIST("Prof_Q1152_01"))->Fill(cent, fQ1152_01); + histos.get(HIST("Prof_Q1152_10"))->Fill(cent, fQ1152_10); + histos.get(HIST("Prof_Q1153_11"))->Fill(cent, fQ1153_11); + histos.get(HIST("Prof_Q1153_01"))->Fill(cent, fQ1153_01); + histos.get(HIST("Prof_Q1153_10"))->Fill(cent, fQ1153_10); + histos.get(HIST("Prof_Q1154_11"))->Fill(cent, fQ1154_11); + histos.get(HIST("Prof_Q1154_01"))->Fill(cent, fQ1154_01); + histos.get(HIST("Prof_Q1154_10"))->Fill(cent, fQ1154_10); + histos.get(HIST("Prof_Q1155_11"))->Fill(cent, fQ1155_11); + histos.get(HIST("Prof_Q1155_01"))->Fill(cent, fQ1155_01); + histos.get(HIST("Prof_Q1155_10"))->Fill(cent, fQ1155_10); + histos.get(HIST("Prof_Q112233_001"))->Fill(cent, fQ112233_001); + histos.get(HIST("Prof_Q112233_010"))->Fill(cent, fQ112233_010); + histos.get(HIST("Prof_Q112233_100"))->Fill(cent, fQ112233_100); + histos.get(HIST("Prof_Q112233_011"))->Fill(cent, fQ112233_011); + histos.get(HIST("Prof_Q112233_101"))->Fill(cent, fQ112233_101); + histos.get(HIST("Prof_Q112233_110"))->Fill(cent, fQ112233_110); + histos.get(HIST("Prof_Q112232_001"))->Fill(cent, fQ112232_001); + histos.get(HIST("Prof_Q112232_010"))->Fill(cent, fQ112232_010); + histos.get(HIST("Prof_Q112232_100"))->Fill(cent, fQ112232_100); + histos.get(HIST("Prof_Q112232_011"))->Fill(cent, fQ112232_011); + histos.get(HIST("Prof_Q112232_101"))->Fill(cent, fQ112232_101); + histos.get(HIST("Prof_Q112232_110"))->Fill(cent, fQ112232_110); + histos.get(HIST("Prof_Q112231_001"))->Fill(cent, fQ112231_001); + histos.get(HIST("Prof_Q112231_010"))->Fill(cent, fQ112231_010); + histos.get(HIST("Prof_Q112231_100"))->Fill(cent, fQ112231_100); + histos.get(HIST("Prof_Q112231_011"))->Fill(cent, fQ112231_011); + histos.get(HIST("Prof_Q112231_101"))->Fill(cent, fQ112231_101); + histos.get(HIST("Prof_Q112231_110"))->Fill(cent, fQ112231_110); + histos.get(HIST("Prof_Q112133_001"))->Fill(cent, fQ112133_001); + histos.get(HIST("Prof_Q112133_010"))->Fill(cent, fQ112133_010); + histos.get(HIST("Prof_Q112133_100"))->Fill(cent, fQ112133_100); + histos.get(HIST("Prof_Q112133_011"))->Fill(cent, fQ112133_011); + histos.get(HIST("Prof_Q112133_101"))->Fill(cent, fQ112133_101); + histos.get(HIST("Prof_Q112133_110"))->Fill(cent, fQ112133_110); + histos.get(HIST("Prof_Q112132_001"))->Fill(cent, fQ112132_001); + histos.get(HIST("Prof_Q112132_010"))->Fill(cent, fQ112132_010); + histos.get(HIST("Prof_Q112132_100"))->Fill(cent, fQ112132_100); + histos.get(HIST("Prof_Q112132_011"))->Fill(cent, fQ112132_011); + histos.get(HIST("Prof_Q112132_101"))->Fill(cent, fQ112132_101); + histos.get(HIST("Prof_Q112132_110"))->Fill(cent, fQ112132_110); + histos.get(HIST("Prof_Q112131_001"))->Fill(cent, fQ112131_001); + histos.get(HIST("Prof_Q112131_010"))->Fill(cent, fQ112131_010); + histos.get(HIST("Prof_Q112131_100"))->Fill(cent, fQ112131_100); + histos.get(HIST("Prof_Q112131_011"))->Fill(cent, fQ112131_011); + histos.get(HIST("Prof_Q112131_101"))->Fill(cent, fQ112131_101); + histos.get(HIST("Prof_Q112131_110"))->Fill(cent, fQ112131_110); + histos.get(HIST("Prof_Q2221_11"))->Fill(cent, fQ2221_11); + histos.get(HIST("Prof_Q2221_01"))->Fill(cent, fQ2221_01); + histos.get(HIST("Prof_Q2221_10"))->Fill(cent, fQ2221_10); + histos.get(HIST("Prof_Q2221_21"))->Fill(cent, fQ2221_21); + histos.get(HIST("Prof_Q2221_20"))->Fill(cent, fQ2221_20); + histos.get(HIST("Prof_Q2122_21"))->Fill(cent, fQ2122_21); + histos.get(HIST("Prof_Q2122_20"))->Fill(cent, fQ2122_20); + histos.get(HIST("Prof_Q1121_02"))->Fill(cent, fQ1121_02); + histos.get(HIST("Prof_Q1121_12"))->Fill(cent, fQ1121_12); + histos.get(HIST("Prof_Q1121_22"))->Fill(cent, fQ1121_22); + histos.get(HIST("Prof_Q1122_02"))->Fill(cent, fQ1122_02); + histos.get(HIST("Prof_Q1122_12"))->Fill(cent, fQ1122_12); + histos.get(HIST("Prof_Q1122_22"))->Fill(cent, fQ1122_22); + histos.get(HIST("Prof_Q112221_001"))->Fill(cent, fQ112221_001); + histos.get(HIST("Prof_Q112221_010"))->Fill(cent, fQ112221_010); + histos.get(HIST("Prof_Q112221_100"))->Fill(cent, fQ112221_100); + histos.get(HIST("Prof_Q112221_011"))->Fill(cent, fQ112221_011); + histos.get(HIST("Prof_Q112221_101"))->Fill(cent, fQ112221_101); + histos.get(HIST("Prof_Q112221_110"))->Fill(cent, fQ112221_110); + histos.get(HIST("Prof_Q112221_200"))->Fill(cent, fQ112221_200); + histos.get(HIST("Prof_Q112221_201"))->Fill(cent, fQ112221_201); + histos.get(HIST("Prof_Q112221_210"))->Fill(cent, fQ112221_210); + histos.get(HIST("Prof_Q112221_211"))->Fill(cent, fQ112221_211); + histos.get(HIST("Prof_Q1131_21"))->Fill(cent, fQ1131_21); + histos.get(HIST("Prof_Q1131_20"))->Fill(cent, fQ1131_20); + histos.get(HIST("Prof_Q1131_31"))->Fill(cent, fQ1131_31); + histos.get(HIST("Prof_Q1131_30"))->Fill(cent, fQ1131_30); + histos.get(HIST("Prof_Q1132_21"))->Fill(cent, fQ1132_21); + histos.get(HIST("Prof_Q1132_20"))->Fill(cent, fQ1132_20); + histos.get(HIST("Prof_Q1132_31"))->Fill(cent, fQ1132_31); + histos.get(HIST("Prof_Q1132_30"))->Fill(cent, fQ1132_30); + histos.get(HIST("Prof_Q1133_21"))->Fill(cent, fQ1133_21); + histos.get(HIST("Prof_Q1133_20"))->Fill(cent, fQ1133_20); + histos.get(HIST("Prof_Q1133_31"))->Fill(cent, fQ1133_31); + histos.get(HIST("Prof_Q1133_30"))->Fill(cent, fQ1133_30); + histos.get(HIST("Prof_Q11_5"))->Fill(cent, fQ11_5); + histos.get(HIST("Prof_Q11_6"))->Fill(cent, fQ11_6); + histos.get(HIST("Prof_Q1121_30"))->Fill(cent, fQ1121_30); + histos.get(HIST("Prof_Q1121_31"))->Fill(cent, fQ1121_31); + histos.get(HIST("Prof_Q1121_40"))->Fill(cent, fQ1121_40); + histos.get(HIST("Prof_Q1121_41"))->Fill(cent, fQ1121_41); + histos.get(HIST("Prof_Q1122_30"))->Fill(cent, fQ1122_30); + histos.get(HIST("Prof_Q1122_31"))->Fill(cent, fQ1122_31); + histos.get(HIST("Prof_Q1122_40"))->Fill(cent, fQ1122_40); + histos.get(HIST("Prof_Q1122_41"))->Fill(cent, fQ1122_41); + histos.get(HIST("Prof_Q2211_11"))->Fill(cent, fQ2211_11); + histos.get(HIST("Prof_Q2211_01"))->Fill(cent, fQ2211_01); + histos.get(HIST("Prof_Q2211_10"))->Fill(cent, fQ2211_10); + histos.get(HIST("Prof_Q2211_20"))->Fill(cent, fQ2211_20); + histos.get(HIST("Prof_Q2211_21"))->Fill(cent, fQ2211_21); + histos.get(HIST("Prof_Q2111_11"))->Fill(cent, fQ2111_11); + histos.get(HIST("Prof_Q2111_01"))->Fill(cent, fQ2111_01); + histos.get(HIST("Prof_Q2111_10"))->Fill(cent, fQ2111_10); + histos.get(HIST("Prof_Q2111_20"))->Fill(cent, fQ2111_20); + histos.get(HIST("Prof_Q2111_21"))->Fill(cent, fQ2111_21); + histos.get(HIST("Prof_Q112122_001"))->Fill(cent, fQ112122_001); + histos.get(HIST("Prof_Q112122_010"))->Fill(cent, fQ112122_010); + histos.get(HIST("Prof_Q112122_100"))->Fill(cent, fQ112122_100); + histos.get(HIST("Prof_Q112122_011"))->Fill(cent, fQ112122_011); + histos.get(HIST("Prof_Q112122_101"))->Fill(cent, fQ112122_101); + histos.get(HIST("Prof_Q112122_110"))->Fill(cent, fQ112122_110); + histos.get(HIST("Prof_Q1141_11"))->Fill(cent, fQ1141_11); + histos.get(HIST("Prof_Q1141_01"))->Fill(cent, fQ1141_01); + histos.get(HIST("Prof_Q1141_10"))->Fill(cent, fQ1141_10); + histos.get(HIST("Prof_Q1141_20"))->Fill(cent, fQ1141_20); + histos.get(HIST("Prof_Q1141_21"))->Fill(cent, fQ1141_21); + histos.get(HIST("Prof_Q1142_11"))->Fill(cent, fQ1142_11); + histos.get(HIST("Prof_Q1142_01"))->Fill(cent, fQ1142_01); + histos.get(HIST("Prof_Q1142_10"))->Fill(cent, fQ1142_10); + histos.get(HIST("Prof_Q1142_20"))->Fill(cent, fQ1142_20); + histos.get(HIST("Prof_Q1142_21"))->Fill(cent, fQ1142_21); + histos.get(HIST("Prof_Q1143_11"))->Fill(cent, fQ1143_11); + histos.get(HIST("Prof_Q1143_01"))->Fill(cent, fQ1143_01); + histos.get(HIST("Prof_Q1143_10"))->Fill(cent, fQ1143_10); + histos.get(HIST("Prof_Q1143_20"))->Fill(cent, fQ1143_20); + histos.get(HIST("Prof_Q1143_21"))->Fill(cent, fQ1143_21); + histos.get(HIST("Prof_Q1144_11"))->Fill(cent, fQ1144_11); + histos.get(HIST("Prof_Q1144_01"))->Fill(cent, fQ1144_01); + histos.get(HIST("Prof_Q1144_10"))->Fill(cent, fQ1144_10); + histos.get(HIST("Prof_Q1144_20"))->Fill(cent, fQ1144_20); + histos.get(HIST("Prof_Q1144_21"))->Fill(cent, fQ1144_21); + histos.get(HIST("Prof_Q2131_11"))->Fill(cent, fQ2131_11); + histos.get(HIST("Prof_Q2131_01"))->Fill(cent, fQ2131_01); + histos.get(HIST("Prof_Q2131_10"))->Fill(cent, fQ2131_10); + histos.get(HIST("Prof_Q2132_11"))->Fill(cent, fQ2132_11); + histos.get(HIST("Prof_Q2132_01"))->Fill(cent, fQ2132_01); + histos.get(HIST("Prof_Q2132_10"))->Fill(cent, fQ2132_10); + histos.get(HIST("Prof_Q2133_11"))->Fill(cent, fQ2133_11); + histos.get(HIST("Prof_Q2133_01"))->Fill(cent, fQ2133_01); + histos.get(HIST("Prof_Q2133_10"))->Fill(cent, fQ2133_10); + histos.get(HIST("Prof_Q2231_11"))->Fill(cent, fQ2231_11); + histos.get(HIST("Prof_Q2231_01"))->Fill(cent, fQ2231_01); + histos.get(HIST("Prof_Q2231_10"))->Fill(cent, fQ2231_10); + histos.get(HIST("Prof_Q2232_11"))->Fill(cent, fQ2232_11); + histos.get(HIST("Prof_Q2232_01"))->Fill(cent, fQ2232_01); + histos.get(HIST("Prof_Q2232_10"))->Fill(cent, fQ2232_10); + histos.get(HIST("Prof_Q2233_11"))->Fill(cent, fQ2233_11); + histos.get(HIST("Prof_Q2233_01"))->Fill(cent, fQ2233_01); + histos.get(HIST("Prof_Q2233_10"))->Fill(cent, fQ2233_10); + histos.get(HIST("Prof_Q51_1"))->Fill(cent, fQ51_1); + histos.get(HIST("Prof_Q52_1"))->Fill(cent, fQ52_1); + histos.get(HIST("Prof_Q53_1"))->Fill(cent, fQ53_1); + histos.get(HIST("Prof_Q54_1"))->Fill(cent, fQ54_1); + histos.get(HIST("Prof_Q55_1"))->Fill(cent, fQ55_1); + histos.get(HIST("Prof_Q21_3"))->Fill(cent, fQ21_3); + histos.get(HIST("Prof_Q22_3"))->Fill(cent, fQ22_3); + histos.get(HIST("Prof_Q31_2"))->Fill(cent, fQ31_2); + histos.get(HIST("Prof_Q32_2"))->Fill(cent, fQ32_2); + histos.get(HIST("Prof_Q33_2"))->Fill(cent, fQ33_2); + histos.get(HIST("Prof_Q61_1"))->Fill(cent, fQ61_1); + histos.get(HIST("Prof_Q62_1"))->Fill(cent, fQ62_1); + histos.get(HIST("Prof_Q63_1"))->Fill(cent, fQ63_1); + histos.get(HIST("Prof_Q64_1"))->Fill(cent, fQ64_1); + histos.get(HIST("Prof_Q65_1"))->Fill(cent, fQ65_1); + histos.get(HIST("Prof_Q66_1"))->Fill(cent, fQ66_1); + histos.get(HIST("Prof_Q112122_111"))->Fill(cent, fQ112122_111); + histos.get(HIST("Prof_Q112131_111"))->Fill(cent, fQ112131_111); + histos.get(HIST("Prof_Q112132_111"))->Fill(cent, fQ112132_111); + histos.get(HIST("Prof_Q112133_111"))->Fill(cent, fQ112133_111); + histos.get(HIST("Prof_Q112231_111"))->Fill(cent, fQ112231_111); + histos.get(HIST("Prof_Q112232_111"))->Fill(cent, fQ112232_111); + histos.get(HIST("Prof_Q112233_111"))->Fill(cent, fQ112233_111); + histos.get(HIST("Prof_Q112221_111"))->Fill(cent, fQ112221_111); + } + + if (cfgIsCalculateError) { + // selecting subsample and filling profiles + float lRandom = fRndm->Rndm(); + int sampleIndex = static_cast(cfgNSubsample * lRandom); + + histos.get(HIST("Prof2D_mu1_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 1.0)); + histos.get(HIST("Prof2D_mu2_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 2.0)); + histos.get(HIST("Prof2D_mu3_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 3.0)); + histos.get(HIST("Prof2D_mu4_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 4.0)); + histos.get(HIST("Prof2D_mu5_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 5.0)); + histos.get(HIST("Prof2D_mu6_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 6.0)); + histos.get(HIST("Prof2D_mu7_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 7.0)); + histos.get(HIST("Prof2D_mu8_netproton"))->Fill(cent, sampleIndex, std::pow(netProt, 8.0)); + + histos.get(HIST("Prof2D_Q11_1"))->Fill(cent, sampleIndex, fQ11_1); + histos.get(HIST("Prof2D_Q11_2"))->Fill(cent, sampleIndex, fQ11_2); + histos.get(HIST("Prof2D_Q11_3"))->Fill(cent, sampleIndex, fQ11_3); + histos.get(HIST("Prof2D_Q11_4"))->Fill(cent, sampleIndex, fQ11_4); + histos.get(HIST("Prof2D_Q21_1"))->Fill(cent, sampleIndex, fQ21_1); + histos.get(HIST("Prof2D_Q22_1"))->Fill(cent, sampleIndex, fQ22_1); + histos.get(HIST("Prof2D_Q31_1"))->Fill(cent, sampleIndex, fQ31_1); + histos.get(HIST("Prof2D_Q32_1"))->Fill(cent, sampleIndex, fQ32_1); + histos.get(HIST("Prof2D_Q33_1"))->Fill(cent, sampleIndex, fQ33_1); + histos.get(HIST("Prof2D_Q41_1"))->Fill(cent, sampleIndex, fQ41_1); + histos.get(HIST("Prof2D_Q42_1"))->Fill(cent, sampleIndex, fQ42_1); + histos.get(HIST("Prof2D_Q43_1"))->Fill(cent, sampleIndex, fQ43_1); + histos.get(HIST("Prof2D_Q44_1"))->Fill(cent, sampleIndex, fQ44_1); + histos.get(HIST("Prof2D_Q21_2"))->Fill(cent, sampleIndex, fQ21_2); + histos.get(HIST("Prof2D_Q22_2"))->Fill(cent, sampleIndex, fQ22_2); + histos.get(HIST("Prof2D_Q1121_11"))->Fill(cent, sampleIndex, fQ1121_11); + histos.get(HIST("Prof2D_Q1121_01"))->Fill(cent, sampleIndex, fQ1121_01); + histos.get(HIST("Prof2D_Q1121_10"))->Fill(cent, sampleIndex, fQ1121_10); + histos.get(HIST("Prof2D_Q1121_20"))->Fill(cent, sampleIndex, fQ1121_20); + histos.get(HIST("Prof2D_Q1121_21"))->Fill(cent, sampleIndex, fQ1121_21); + histos.get(HIST("Prof2D_Q1122_11"))->Fill(cent, sampleIndex, fQ1122_11); + histos.get(HIST("Prof2D_Q1122_01"))->Fill(cent, sampleIndex, fQ1122_01); + histos.get(HIST("Prof2D_Q1122_10"))->Fill(cent, sampleIndex, fQ1122_10); + histos.get(HIST("Prof2D_Q1122_20"))->Fill(cent, sampleIndex, fQ1122_20); + histos.get(HIST("Prof2D_Q1122_21"))->Fill(cent, sampleIndex, fQ1122_21); + histos.get(HIST("Prof2D_Q1131_11"))->Fill(cent, sampleIndex, fQ1131_11); + histos.get(HIST("Prof2D_Q1131_01"))->Fill(cent, sampleIndex, fQ1131_01); + histos.get(HIST("Prof2D_Q1131_10"))->Fill(cent, sampleIndex, fQ1131_10); + histos.get(HIST("Prof2D_Q1132_11"))->Fill(cent, sampleIndex, fQ1132_11); + histos.get(HIST("Prof2D_Q1132_01"))->Fill(cent, sampleIndex, fQ1132_01); + histos.get(HIST("Prof2D_Q1132_10"))->Fill(cent, sampleIndex, fQ1132_10); + histos.get(HIST("Prof2D_Q1133_11"))->Fill(cent, sampleIndex, fQ1133_11); + histos.get(HIST("Prof2D_Q1133_01"))->Fill(cent, sampleIndex, fQ1133_01); + histos.get(HIST("Prof2D_Q1133_10"))->Fill(cent, sampleIndex, fQ1133_10); + histos.get(HIST("Prof2D_Q2122_11"))->Fill(cent, sampleIndex, fQ2122_11); + histos.get(HIST("Prof2D_Q2122_01"))->Fill(cent, sampleIndex, fQ2122_01); + histos.get(HIST("Prof2D_Q2122_10"))->Fill(cent, sampleIndex, fQ2122_10); + histos.get(HIST("Prof2D_Q3132_11"))->Fill(cent, sampleIndex, fQ3132_11); + histos.get(HIST("Prof2D_Q3132_01"))->Fill(cent, sampleIndex, fQ3132_01); + histos.get(HIST("Prof2D_Q3132_10"))->Fill(cent, sampleIndex, fQ3132_10); + histos.get(HIST("Prof2D_Q3133_11"))->Fill(cent, sampleIndex, fQ3133_11); + histos.get(HIST("Prof2D_Q3133_01"))->Fill(cent, sampleIndex, fQ3133_01); + histos.get(HIST("Prof2D_Q3133_10"))->Fill(cent, sampleIndex, fQ3133_10); + histos.get(HIST("Prof2D_Q3233_11"))->Fill(cent, sampleIndex, fQ3233_11); + histos.get(HIST("Prof2D_Q3233_01"))->Fill(cent, sampleIndex, fQ3233_01); + histos.get(HIST("Prof2D_Q3233_10"))->Fill(cent, sampleIndex, fQ3233_10); + histos.get(HIST("Prof2D_Q2241_11"))->Fill(cent, sampleIndex, fQ2241_11); + histos.get(HIST("Prof2D_Q2241_01"))->Fill(cent, sampleIndex, fQ2241_01); + histos.get(HIST("Prof2D_Q2241_10"))->Fill(cent, sampleIndex, fQ2241_10); + histos.get(HIST("Prof2D_Q2242_11"))->Fill(cent, sampleIndex, fQ2242_11); + histos.get(HIST("Prof2D_Q2242_01"))->Fill(cent, sampleIndex, fQ2242_01); + histos.get(HIST("Prof2D_Q2242_10"))->Fill(cent, sampleIndex, fQ2242_10); + histos.get(HIST("Prof2D_Q2243_11"))->Fill(cent, sampleIndex, fQ2243_11); + histos.get(HIST("Prof2D_Q2243_01"))->Fill(cent, sampleIndex, fQ2243_01); + histos.get(HIST("Prof2D_Q2243_10"))->Fill(cent, sampleIndex, fQ2243_10); + histos.get(HIST("Prof2D_Q2244_11"))->Fill(cent, sampleIndex, fQ2244_11); + histos.get(HIST("Prof2D_Q2244_01"))->Fill(cent, sampleIndex, fQ2244_01); + histos.get(HIST("Prof2D_Q2244_10"))->Fill(cent, sampleIndex, fQ2244_10); + histos.get(HIST("Prof2D_Q2141_11"))->Fill(cent, sampleIndex, fQ2141_11); + histos.get(HIST("Prof2D_Q2141_01"))->Fill(cent, sampleIndex, fQ2141_01); + histos.get(HIST("Prof2D_Q2141_10"))->Fill(cent, sampleIndex, fQ2141_10); + histos.get(HIST("Prof2D_Q2142_11"))->Fill(cent, sampleIndex, fQ2142_11); + histos.get(HIST("Prof2D_Q2142_01"))->Fill(cent, sampleIndex, fQ2142_01); + histos.get(HIST("Prof2D_Q2142_10"))->Fill(cent, sampleIndex, fQ2142_10); + histos.get(HIST("Prof2D_Q2143_11"))->Fill(cent, sampleIndex, fQ2143_11); + histos.get(HIST("Prof2D_Q2143_01"))->Fill(cent, sampleIndex, fQ2143_01); + histos.get(HIST("Prof2D_Q2143_10"))->Fill(cent, sampleIndex, fQ2143_10); + histos.get(HIST("Prof2D_Q2144_11"))->Fill(cent, sampleIndex, fQ2144_11); + histos.get(HIST("Prof2D_Q2144_01"))->Fill(cent, sampleIndex, fQ2144_01); + histos.get(HIST("Prof2D_Q2144_10"))->Fill(cent, sampleIndex, fQ2144_10); + histos.get(HIST("Prof2D_Q1151_11"))->Fill(cent, sampleIndex, fQ1151_11); + histos.get(HIST("Prof2D_Q1151_01"))->Fill(cent, sampleIndex, fQ1151_01); + histos.get(HIST("Prof2D_Q1151_10"))->Fill(cent, sampleIndex, fQ1151_10); + histos.get(HIST("Prof2D_Q1152_11"))->Fill(cent, sampleIndex, fQ1152_11); + histos.get(HIST("Prof2D_Q1152_01"))->Fill(cent, sampleIndex, fQ1152_01); + histos.get(HIST("Prof2D_Q1152_10"))->Fill(cent, sampleIndex, fQ1152_10); + histos.get(HIST("Prof2D_Q1153_11"))->Fill(cent, sampleIndex, fQ1153_11); + histos.get(HIST("Prof2D_Q1153_01"))->Fill(cent, sampleIndex, fQ1153_01); + histos.get(HIST("Prof2D_Q1153_10"))->Fill(cent, sampleIndex, fQ1153_10); + histos.get(HIST("Prof2D_Q1154_11"))->Fill(cent, sampleIndex, fQ1154_11); + histos.get(HIST("Prof2D_Q1154_01"))->Fill(cent, sampleIndex, fQ1154_01); + histos.get(HIST("Prof2D_Q1154_10"))->Fill(cent, sampleIndex, fQ1154_10); + histos.get(HIST("Prof2D_Q1155_11"))->Fill(cent, sampleIndex, fQ1155_11); + histos.get(HIST("Prof2D_Q1155_01"))->Fill(cent, sampleIndex, fQ1155_01); + histos.get(HIST("Prof2D_Q1155_10"))->Fill(cent, sampleIndex, fQ1155_10); + histos.get(HIST("Prof2D_Q112233_001"))->Fill(cent, sampleIndex, fQ112233_001); + histos.get(HIST("Prof2D_Q112233_010"))->Fill(cent, sampleIndex, fQ112233_010); + histos.get(HIST("Prof2D_Q112233_100"))->Fill(cent, sampleIndex, fQ112233_100); + histos.get(HIST("Prof2D_Q112233_011"))->Fill(cent, sampleIndex, fQ112233_011); + histos.get(HIST("Prof2D_Q112233_101"))->Fill(cent, sampleIndex, fQ112233_101); + histos.get(HIST("Prof2D_Q112233_110"))->Fill(cent, sampleIndex, fQ112233_110); + histos.get(HIST("Prof2D_Q112232_001"))->Fill(cent, sampleIndex, fQ112232_001); + histos.get(HIST("Prof2D_Q112232_010"))->Fill(cent, sampleIndex, fQ112232_010); + histos.get(HIST("Prof2D_Q112232_100"))->Fill(cent, sampleIndex, fQ112232_100); + histos.get(HIST("Prof2D_Q112232_011"))->Fill(cent, sampleIndex, fQ112232_011); + histos.get(HIST("Prof2D_Q112232_101"))->Fill(cent, sampleIndex, fQ112232_101); + histos.get(HIST("Prof2D_Q112232_110"))->Fill(cent, sampleIndex, fQ112232_110); + histos.get(HIST("Prof2D_Q112231_001"))->Fill(cent, sampleIndex, fQ112231_001); + histos.get(HIST("Prof2D_Q112231_010"))->Fill(cent, sampleIndex, fQ112231_010); + histos.get(HIST("Prof2D_Q112231_100"))->Fill(cent, sampleIndex, fQ112231_100); + histos.get(HIST("Prof2D_Q112231_011"))->Fill(cent, sampleIndex, fQ112231_011); + histos.get(HIST("Prof2D_Q112231_101"))->Fill(cent, sampleIndex, fQ112231_101); + histos.get(HIST("Prof2D_Q112231_110"))->Fill(cent, sampleIndex, fQ112231_110); + histos.get(HIST("Prof2D_Q112133_001"))->Fill(cent, sampleIndex, fQ112133_001); + histos.get(HIST("Prof2D_Q112133_010"))->Fill(cent, sampleIndex, fQ112133_010); + histos.get(HIST("Prof2D_Q112133_100"))->Fill(cent, sampleIndex, fQ112133_100); + histos.get(HIST("Prof2D_Q112133_011"))->Fill(cent, sampleIndex, fQ112133_011); + histos.get(HIST("Prof2D_Q112133_101"))->Fill(cent, sampleIndex, fQ112133_101); + histos.get(HIST("Prof2D_Q112133_110"))->Fill(cent, sampleIndex, fQ112133_110); + histos.get(HIST("Prof2D_Q112132_001"))->Fill(cent, sampleIndex, fQ112132_001); + histos.get(HIST("Prof2D_Q112132_010"))->Fill(cent, sampleIndex, fQ112132_010); + histos.get(HIST("Prof2D_Q112132_100"))->Fill(cent, sampleIndex, fQ112132_100); + histos.get(HIST("Prof2D_Q112132_011"))->Fill(cent, sampleIndex, fQ112132_011); + histos.get(HIST("Prof2D_Q112132_101"))->Fill(cent, sampleIndex, fQ112132_101); + histos.get(HIST("Prof2D_Q112132_110"))->Fill(cent, sampleIndex, fQ112132_110); + histos.get(HIST("Prof2D_Q112131_001"))->Fill(cent, sampleIndex, fQ112131_001); + histos.get(HIST("Prof2D_Q112131_010"))->Fill(cent, sampleIndex, fQ112131_010); + histos.get(HIST("Prof2D_Q112131_100"))->Fill(cent, sampleIndex, fQ112131_100); + histos.get(HIST("Prof2D_Q112131_011"))->Fill(cent, sampleIndex, fQ112131_011); + histos.get(HIST("Prof2D_Q112131_101"))->Fill(cent, sampleIndex, fQ112131_101); + histos.get(HIST("Prof2D_Q112131_110"))->Fill(cent, sampleIndex, fQ112131_110); + histos.get(HIST("Prof2D_Q2221_11"))->Fill(cent, sampleIndex, fQ2221_11); + histos.get(HIST("Prof2D_Q2221_01"))->Fill(cent, sampleIndex, fQ2221_01); + histos.get(HIST("Prof2D_Q2221_10"))->Fill(cent, sampleIndex, fQ2221_10); + histos.get(HIST("Prof2D_Q2221_21"))->Fill(cent, sampleIndex, fQ2221_21); + histos.get(HIST("Prof2D_Q2221_20"))->Fill(cent, sampleIndex, fQ2221_20); + histos.get(HIST("Prof2D_Q2122_21"))->Fill(cent, sampleIndex, fQ2122_21); + histos.get(HIST("Prof2D_Q2122_20"))->Fill(cent, sampleIndex, fQ2122_20); + histos.get(HIST("Prof2D_Q1121_02"))->Fill(cent, sampleIndex, fQ1121_02); + histos.get(HIST("Prof2D_Q1121_12"))->Fill(cent, sampleIndex, fQ1121_12); + histos.get(HIST("Prof2D_Q1121_22"))->Fill(cent, sampleIndex, fQ1121_22); + histos.get(HIST("Prof2D_Q1122_02"))->Fill(cent, sampleIndex, fQ1122_02); + histos.get(HIST("Prof2D_Q1122_12"))->Fill(cent, sampleIndex, fQ1122_12); + histos.get(HIST("Prof2D_Q1122_22"))->Fill(cent, sampleIndex, fQ1122_22); + histos.get(HIST("Prof2D_Q112221_001"))->Fill(cent, sampleIndex, fQ112221_001); + histos.get(HIST("Prof2D_Q112221_010"))->Fill(cent, sampleIndex, fQ112221_010); + histos.get(HIST("Prof2D_Q112221_100"))->Fill(cent, sampleIndex, fQ112221_100); + histos.get(HIST("Prof2D_Q112221_011"))->Fill(cent, sampleIndex, fQ112221_011); + histos.get(HIST("Prof2D_Q112221_101"))->Fill(cent, sampleIndex, fQ112221_101); + histos.get(HIST("Prof2D_Q112221_110"))->Fill(cent, sampleIndex, fQ112221_110); + histos.get(HIST("Prof2D_Q112221_200"))->Fill(cent, sampleIndex, fQ112221_200); + histos.get(HIST("Prof2D_Q112221_201"))->Fill(cent, sampleIndex, fQ112221_201); + histos.get(HIST("Prof2D_Q112221_210"))->Fill(cent, sampleIndex, fQ112221_210); + histos.get(HIST("Prof2D_Q112221_211"))->Fill(cent, sampleIndex, fQ112221_211); + histos.get(HIST("Prof2D_Q1131_21"))->Fill(cent, sampleIndex, fQ1131_21); + histos.get(HIST("Prof2D_Q1131_20"))->Fill(cent, sampleIndex, fQ1131_20); + histos.get(HIST("Prof2D_Q1131_31"))->Fill(cent, sampleIndex, fQ1131_31); + histos.get(HIST("Prof2D_Q1131_30"))->Fill(cent, sampleIndex, fQ1131_30); + histos.get(HIST("Prof2D_Q1132_21"))->Fill(cent, sampleIndex, fQ1132_21); + histos.get(HIST("Prof2D_Q1132_20"))->Fill(cent, sampleIndex, fQ1132_20); + histos.get(HIST("Prof2D_Q1132_31"))->Fill(cent, sampleIndex, fQ1132_31); + histos.get(HIST("Prof2D_Q1132_30"))->Fill(cent, sampleIndex, fQ1132_30); + histos.get(HIST("Prof2D_Q1133_21"))->Fill(cent, sampleIndex, fQ1133_21); + histos.get(HIST("Prof2D_Q1133_20"))->Fill(cent, sampleIndex, fQ1133_20); + histos.get(HIST("Prof2D_Q1133_31"))->Fill(cent, sampleIndex, fQ1133_31); + histos.get(HIST("Prof2D_Q1133_30"))->Fill(cent, sampleIndex, fQ1133_30); + histos.get(HIST("Prof2D_Q11_5"))->Fill(cent, sampleIndex, fQ11_5); + histos.get(HIST("Prof2D_Q11_6"))->Fill(cent, sampleIndex, fQ11_6); + histos.get(HIST("Prof2D_Q1121_30"))->Fill(cent, sampleIndex, fQ1121_30); + histos.get(HIST("Prof2D_Q1121_31"))->Fill(cent, sampleIndex, fQ1121_31); + histos.get(HIST("Prof2D_Q1121_40"))->Fill(cent, sampleIndex, fQ1121_40); + histos.get(HIST("Prof2D_Q1121_41"))->Fill(cent, sampleIndex, fQ1121_41); + histos.get(HIST("Prof2D_Q1122_30"))->Fill(cent, sampleIndex, fQ1122_30); + histos.get(HIST("Prof2D_Q1122_31"))->Fill(cent, sampleIndex, fQ1122_31); + histos.get(HIST("Prof2D_Q1122_40"))->Fill(cent, sampleIndex, fQ1122_40); + histos.get(HIST("Prof2D_Q1122_41"))->Fill(cent, sampleIndex, fQ1122_41); + histos.get(HIST("Prof2D_Q2211_11"))->Fill(cent, sampleIndex, fQ2211_11); + histos.get(HIST("Prof2D_Q2211_01"))->Fill(cent, sampleIndex, fQ2211_01); + histos.get(HIST("Prof2D_Q2211_10"))->Fill(cent, sampleIndex, fQ2211_10); + histos.get(HIST("Prof2D_Q2211_20"))->Fill(cent, sampleIndex, fQ2211_20); + histos.get(HIST("Prof2D_Q2211_21"))->Fill(cent, sampleIndex, fQ2211_21); + histos.get(HIST("Prof2D_Q2111_11"))->Fill(cent, sampleIndex, fQ2111_11); + histos.get(HIST("Prof2D_Q2111_01"))->Fill(cent, sampleIndex, fQ2111_01); + histos.get(HIST("Prof2D_Q2111_10"))->Fill(cent, sampleIndex, fQ2111_10); + histos.get(HIST("Prof2D_Q2111_20"))->Fill(cent, sampleIndex, fQ2111_20); + histos.get(HIST("Prof2D_Q2111_21"))->Fill(cent, sampleIndex, fQ2111_21); + histos.get(HIST("Prof2D_Q112122_001"))->Fill(cent, sampleIndex, fQ112122_001); + histos.get(HIST("Prof2D_Q112122_010"))->Fill(cent, sampleIndex, fQ112122_010); + histos.get(HIST("Prof2D_Q112122_100"))->Fill(cent, sampleIndex, fQ112122_100); + histos.get(HIST("Prof2D_Q112122_011"))->Fill(cent, sampleIndex, fQ112122_011); + histos.get(HIST("Prof2D_Q112122_101"))->Fill(cent, sampleIndex, fQ112122_101); + histos.get(HIST("Prof2D_Q112122_110"))->Fill(cent, sampleIndex, fQ112122_110); + histos.get(HIST("Prof2D_Q1141_11"))->Fill(cent, sampleIndex, fQ1141_11); + histos.get(HIST("Prof2D_Q1141_01"))->Fill(cent, sampleIndex, fQ1141_01); + histos.get(HIST("Prof2D_Q1141_10"))->Fill(cent, sampleIndex, fQ1141_10); + histos.get(HIST("Prof2D_Q1141_20"))->Fill(cent, sampleIndex, fQ1141_20); + histos.get(HIST("Prof2D_Q1141_21"))->Fill(cent, sampleIndex, fQ1141_21); + histos.get(HIST("Prof2D_Q1142_11"))->Fill(cent, sampleIndex, fQ1142_11); + histos.get(HIST("Prof2D_Q1142_01"))->Fill(cent, sampleIndex, fQ1142_01); + histos.get(HIST("Prof2D_Q1142_10"))->Fill(cent, sampleIndex, fQ1142_10); + histos.get(HIST("Prof2D_Q1142_20"))->Fill(cent, sampleIndex, fQ1142_20); + histos.get(HIST("Prof2D_Q1142_21"))->Fill(cent, sampleIndex, fQ1142_21); + histos.get(HIST("Prof2D_Q1143_11"))->Fill(cent, sampleIndex, fQ1143_11); + histos.get(HIST("Prof2D_Q1143_01"))->Fill(cent, sampleIndex, fQ1143_01); + histos.get(HIST("Prof2D_Q1143_10"))->Fill(cent, sampleIndex, fQ1143_10); + histos.get(HIST("Prof2D_Q1143_20"))->Fill(cent, sampleIndex, fQ1143_20); + histos.get(HIST("Prof2D_Q1143_21"))->Fill(cent, sampleIndex, fQ1143_21); + histos.get(HIST("Prof2D_Q1144_11"))->Fill(cent, sampleIndex, fQ1144_11); + histos.get(HIST("Prof2D_Q1144_01"))->Fill(cent, sampleIndex, fQ1144_01); + histos.get(HIST("Prof2D_Q1144_10"))->Fill(cent, sampleIndex, fQ1144_10); + histos.get(HIST("Prof2D_Q1144_20"))->Fill(cent, sampleIndex, fQ1144_20); + histos.get(HIST("Prof2D_Q1144_21"))->Fill(cent, sampleIndex, fQ1144_21); + histos.get(HIST("Prof2D_Q2131_11"))->Fill(cent, sampleIndex, fQ2131_11); + histos.get(HIST("Prof2D_Q2131_01"))->Fill(cent, sampleIndex, fQ2131_01); + histos.get(HIST("Prof2D_Q2131_10"))->Fill(cent, sampleIndex, fQ2131_10); + histos.get(HIST("Prof2D_Q2132_11"))->Fill(cent, sampleIndex, fQ2132_11); + histos.get(HIST("Prof2D_Q2132_01"))->Fill(cent, sampleIndex, fQ2132_01); + histos.get(HIST("Prof2D_Q2132_10"))->Fill(cent, sampleIndex, fQ2132_10); + histos.get(HIST("Prof2D_Q2133_11"))->Fill(cent, sampleIndex, fQ2133_11); + histos.get(HIST("Prof2D_Q2133_01"))->Fill(cent, sampleIndex, fQ2133_01); + histos.get(HIST("Prof2D_Q2133_10"))->Fill(cent, sampleIndex, fQ2133_10); + histos.get(HIST("Prof2D_Q2231_11"))->Fill(cent, sampleIndex, fQ2231_11); + histos.get(HIST("Prof2D_Q2231_01"))->Fill(cent, sampleIndex, fQ2231_01); + histos.get(HIST("Prof2D_Q2231_10"))->Fill(cent, sampleIndex, fQ2231_10); + histos.get(HIST("Prof2D_Q2232_11"))->Fill(cent, sampleIndex, fQ2232_11); + histos.get(HIST("Prof2D_Q2232_01"))->Fill(cent, sampleIndex, fQ2232_01); + histos.get(HIST("Prof2D_Q2232_10"))->Fill(cent, sampleIndex, fQ2232_10); + histos.get(HIST("Prof2D_Q2233_11"))->Fill(cent, sampleIndex, fQ2233_11); + histos.get(HIST("Prof2D_Q2233_01"))->Fill(cent, sampleIndex, fQ2233_01); + histos.get(HIST("Prof2D_Q2233_10"))->Fill(cent, sampleIndex, fQ2233_10); + histos.get(HIST("Prof2D_Q51_1"))->Fill(cent, sampleIndex, fQ51_1); + histos.get(HIST("Prof2D_Q52_1"))->Fill(cent, sampleIndex, fQ52_1); + histos.get(HIST("Prof2D_Q53_1"))->Fill(cent, sampleIndex, fQ53_1); + histos.get(HIST("Prof2D_Q54_1"))->Fill(cent, sampleIndex, fQ54_1); + histos.get(HIST("Prof2D_Q55_1"))->Fill(cent, sampleIndex, fQ55_1); + histos.get(HIST("Prof2D_Q21_3"))->Fill(cent, sampleIndex, fQ21_3); + histos.get(HIST("Prof2D_Q22_3"))->Fill(cent, sampleIndex, fQ22_3); + histos.get(HIST("Prof2D_Q31_2"))->Fill(cent, sampleIndex, fQ31_2); + histos.get(HIST("Prof2D_Q32_2"))->Fill(cent, sampleIndex, fQ32_2); + histos.get(HIST("Prof2D_Q33_2"))->Fill(cent, sampleIndex, fQ33_2); + histos.get(HIST("Prof2D_Q61_1"))->Fill(cent, sampleIndex, fQ61_1); + histos.get(HIST("Prof2D_Q62_1"))->Fill(cent, sampleIndex, fQ62_1); + histos.get(HIST("Prof2D_Q63_1"))->Fill(cent, sampleIndex, fQ63_1); + histos.get(HIST("Prof2D_Q64_1"))->Fill(cent, sampleIndex, fQ64_1); + histos.get(HIST("Prof2D_Q65_1"))->Fill(cent, sampleIndex, fQ65_1); + histos.get(HIST("Prof2D_Q66_1"))->Fill(cent, sampleIndex, fQ66_1); + histos.get(HIST("Prof2D_Q112122_111"))->Fill(cent, sampleIndex, fQ112122_111); + histos.get(HIST("Prof2D_Q112131_111"))->Fill(cent, sampleIndex, fQ112131_111); + histos.get(HIST("Prof2D_Q112132_111"))->Fill(cent, sampleIndex, fQ112132_111); + histos.get(HIST("Prof2D_Q112133_111"))->Fill(cent, sampleIndex, fQ112133_111); + histos.get(HIST("Prof2D_Q112231_111"))->Fill(cent, sampleIndex, fQ112231_111); + histos.get(HIST("Prof2D_Q112232_111"))->Fill(cent, sampleIndex, fQ112232_111); + histos.get(HIST("Prof2D_Q112233_111"))->Fill(cent, sampleIndex, fQ112233_111); + histos.get(HIST("Prof2D_Q112221_111"))->Fill(cent, sampleIndex, fQ112221_111); + } + } + PROCESS_SWITCH(NetprotonCumulantsMc, processDataRec, "Process real data", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/PWGCF/EbyEFluctuations/Tasks/v0ptHadPiKaProt.cxx b/PWGCF/EbyEFluctuations/Tasks/v0ptHadPiKaProt.cxx new file mode 100644 index 00000000000..f0ec5f81685 --- /dev/null +++ b/PWGCF/EbyEFluctuations/Tasks/v0ptHadPiKaProt.cxx @@ -0,0 +1,562 @@ +// 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. + +/// \file v0ptHadPiKaProt.cxx +/// \brief Task for analyzing v0(pT) of inclusive hadrons, pions, kaons, and, protons +/// \author Swati Saha + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct V0ptHadPiKaProt { + + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; + Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; + Configurable cfgCutTrackDcaZ{"cfgCutTrackDcaZ", 2.0f, "Maximum DcaZ"}; + Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; + Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; + Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; + Configurable cfgnSigmaOtherParticles{"cfgnSigmaOtherParticles", 3.0f, "PID nSigma cut to remove other particles (default:3)"}; + Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; + Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; + Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; + ConfigurableAxis nchAxis{"nchAxis", {5000, 0.5, 5000.5}, ""}; + ConfigurableAxis centAxis{"centAxis", {90, 0., 90.}, "Centrality/Multiplicity percentile bining"}; + Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtLowerProt{"cfgCutPtLowerProt", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtUpper{"cfgCutPtUpper", 10.0f, "Higher pT cut for inclusive hadron analysis"}; + Configurable cfgCutPtUpperPID{"cfgCutPtUpperPID", 6.0f, "Higher pT cut for identified particle analysis"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; + Configurable cfgCutEtaLeft{"cfgCutEtaLeft", 0.8f, "Left end of eta gap"}; + Configurable cfgCutEtaRight{"cfgCutEtaRight", 0.8f, "Right end of eta gap"}; + Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples"}; + Configurable cfgCentralityChoice{"cfgCentralityChoice", 1, "Which centrality estimator? 1-->FT0C, 2-->FT0A, 3-->FT0M, 4-->FV0A"}; + Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; + Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; + Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; + Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; + + // Connect to ccdb + Service ccdb; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable ccdbUrl{"ccdbUrl", "http://ccdb-test.cern.ch:8080", "url of the ccdb repository"}; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + std::vector>> subSample; + TRandom3* funRndm = new TRandom3(0); + + // Filter command*********** + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtLower) && (aod::track::pt < cfgCutPtUpper) && (requireGlobalTrackInFilter()) && (aod::track::tpcChi2NCl < cfgCutTpcChi2NCl) && (aod::track::itsChi2NCl < cfgCutItsChi2NCl) && (nabs(aod::track::dcaZ) < cfgCutTrackDcaZ); + + // Filtering collisions and tracks*********** + using AodCollisions = soa::Filtered>; + using AodTracks = soa::Filtered>; + + // Equivalent of the AliRoot task UserCreateOutputObjects + void init(o2::framework::InitContext&) + { + // Define axes + std::vector ptBin = {0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.5, 4.0, 5.0, 6.0, 8.0, 10.0}; + AxisSpec ptAxis = {ptBin, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec noAxis = {1, 0, 1, "no axis"}; + AxisSpec nSigmaAxis = {200, -5.0, 5.0, "n#sigma"}; + + // Add histograms to histogram manager (as in the output object of in AliPhysics) + + // QA hists + histos.add("hZvtx_after_sel", ";Z (cm)", kTH1F, {{240, -12, 12}}); + histos.add("hCentrality", ";centrality (%)", kTH1F, {{90, 0, 90}}); + histos.add("Hist2D_globalTracks_PVTracks", "", {HistType::kTH2D, {nchAxis, nchAxis}}); + histos.add("Hist2D_cent_nch", "", {HistType::kTH2D, {nchAxis, centAxis}}); + histos.add("hP", ";#it{p} (GeV/#it{c})", kTH1F, {{35, 0.2, 4.}}); + histos.add("hPt", ";#it{p}_{T} (GeV/#it{c})", kTH1F, {ptAxis}); + histos.add("hPhi", ";#phi", kTH1F, {{100, 0., o2::constants::math::TwoPI}}); + histos.add("hEta", ";#eta", kTH1F, {{100, -2.01, 2.01}}); + histos.add("hDcaXY", ";#it{dca}_{XY}", kTH1F, {{1000, -5, 5}}); + histos.add("hDcaZ", ";#it{dca}_{Z}", kTH1F, {{1000, -5, 5}}); + histos.add("hMeanPt", "", kTProfile, {centAxis}); + + // 2D histograms of nSigma + // before cut + histos.add("h2DnsigmaPionTpcVsPtBeforeCut", "2D hist of nSigmaTPC vs. pT (pion)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaKaonTpcVsPtBeforeCut", "2D hist of nSigmaTPC vs. pT (kaon)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaProtonTpcVsPtBeforeCut", "2D hist of nSigmaTPC vs. pT (proton)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaPionTofVsPtBeforeCut", "2D hist of nSigmaTOF vs. pT (pion)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaKaonTofVsPtBeforeCut", "2D hist of nSigmaTOF vs. pT (kaon)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaProtonTofVsPtBeforeCut", "2D hist of nSigmaTOF vs. pT (proton)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaPionTpcVsTofBeforeCut", "2D hist of nSigmaTPC vs. nSigmaTOF (pion)", kTH2F, {nSigmaAxis, nSigmaAxis}); + histos.add("h2DnsigmaKaonTpcVsTofBeforeCut", "2D hist of nSigmaTPC vs. nSigmaTOF (kaon)", kTH2F, {nSigmaAxis, nSigmaAxis}); + histos.add("h2DnsigmaProtonTpcVsTofBeforeCut", "2D hist of nSigmaTPC vs. nSigmaTOF (proton)", kTH2F, {nSigmaAxis, nSigmaAxis}); + // after cut + histos.add("h2DnsigmaPionTpcVsPtAfterCut", "2D hist of nSigmaTPC vs. pT (pion)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaKaonTpcVsPtAfterCut", "2D hist of nSigmaTPC vs. pT (kaon)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaProtonTpcVsPtAfterCut", "2D hist of nSigmaTPC vs. pT (proton)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaPionTofVsPtAfterCut", "2D hist of nSigmaTOF vs. pT (pion)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaKaonTofVsPtAfterCut", "2D hist of nSigmaTOF vs. pT (kaon)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaProtonTofVsPtAfterCut", "2D hist of nSigmaTOF vs. pT (proton)", kTH2F, {ptAxis, nSigmaAxis}); + histos.add("h2DnsigmaPionTpcVsTofAfterCut", "2D hist of nSigmaTPC vs. nSigmaTOF (pion)", kTH2F, {nSigmaAxis, nSigmaAxis}); + histos.add("h2DnsigmaKaonTpcVsTofAfterCut", "2D hist of nSigmaTPC vs. nSigmaTOF (kaon)", kTH2F, {nSigmaAxis, nSigmaAxis}); + histos.add("h2DnsigmaProtonTpcVsTofAfterCut", "2D hist of nSigmaTPC vs. nSigmaTOF (proton)", kTH2F, {nSigmaAxis, nSigmaAxis}); + + // Analysis profiles + + histos.add("Prof_A_had", "", {HistType::kTProfile2D, {centAxis, ptAxis}}); + histos.add("Prof_C_had", "", {HistType::kTProfile2D, {centAxis, ptAxis}}); + histos.add("Prof_D_had", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + histos.add("Prof_Bone_had", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + histos.add("Prof_Btwo_had", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + + histos.add("Prof_A_pi", "", {HistType::kTProfile2D, {centAxis, ptAxis}}); + histos.add("Prof_C_pi", "", {HistType::kTProfile2D, {centAxis, ptAxis}}); + histos.add("Prof_D_pi", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + histos.add("Prof_Bone_pi", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + histos.add("Prof_Btwo_pi", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + + histos.add("Prof_A_ka", "", {HistType::kTProfile2D, {centAxis, ptAxis}}); + histos.add("Prof_C_ka", "", {HistType::kTProfile2D, {centAxis, ptAxis}}); + histos.add("Prof_D_ka", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + histos.add("Prof_Bone_ka", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + histos.add("Prof_Btwo_ka", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + + histos.add("Prof_A_prot", "", {HistType::kTProfile2D, {centAxis, ptAxis}}); + histos.add("Prof_C_prot", "", {HistType::kTProfile2D, {centAxis, ptAxis}}); + histos.add("Prof_D_prot", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + histos.add("Prof_Bone_prot", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + histos.add("Prof_Btwo_prot", "", {HistType::kTProfile2D, {centAxis, noAxis}}); + + // initial array + subSample.resize(cfgNSubsample); + for (int i = 0; i < cfgNSubsample; i++) { + subSample[i].resize(20); + } + for (int i = 0; i < cfgNSubsample; i++) { + subSample[i][0] = std::get>(histos.add(Form("subSample_%d/Prof_A_had", i), "", {HistType::kTProfile2D, {centAxis, ptAxis}})); + subSample[i][1] = std::get>(histos.add(Form("subSample_%d/Prof_C_had", i), "", {HistType::kTProfile2D, {centAxis, ptAxis}})); + subSample[i][2] = std::get>(histos.add(Form("subSample_%d/Prof_D_had", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + subSample[i][3] = std::get>(histos.add(Form("subSample_%d/Prof_Bone_had", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + subSample[i][4] = std::get>(histos.add(Form("subSample_%d/Prof_Btwo_had", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + + subSample[i][5] = std::get>(histos.add(Form("subSample_%d/Prof_A_pi", i), "", {HistType::kTProfile2D, {centAxis, ptAxis}})); + subSample[i][6] = std::get>(histos.add(Form("subSample_%d/Prof_C_pi", i), "", {HistType::kTProfile2D, {centAxis, ptAxis}})); + subSample[i][7] = std::get>(histos.add(Form("subSample_%d/Prof_D_pi", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + subSample[i][8] = std::get>(histos.add(Form("subSample_%d/Prof_Bone_pi", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + subSample[i][9] = std::get>(histos.add(Form("subSample_%d/Prof_Btwo_pi", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + + subSample[i][10] = std::get>(histos.add(Form("subSample_%d/Prof_A_ka", i), "", {HistType::kTProfile2D, {centAxis, ptAxis}})); + subSample[i][11] = std::get>(histos.add(Form("subSample_%d/Prof_C_ka", i), "", {HistType::kTProfile2D, {centAxis, ptAxis}})); + subSample[i][12] = std::get>(histos.add(Form("subSample_%d/Prof_D_ka", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + subSample[i][13] = std::get>(histos.add(Form("subSample_%d/Prof_Bone_ka", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + subSample[i][14] = std::get>(histos.add(Form("subSample_%d/Prof_Btwo_ka", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + + subSample[i][15] = std::get>(histos.add(Form("subSample_%d/Prof_A_prot", i), "", {HistType::kTProfile2D, {centAxis, ptAxis}})); + subSample[i][16] = std::get>(histos.add(Form("subSample_%d/Prof_C_prot", i), "", {HistType::kTProfile2D, {centAxis, ptAxis}})); + subSample[i][17] = std::get>(histos.add(Form("subSample_%d/Prof_D_prot", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + subSample[i][18] = std::get>(histos.add(Form("subSample_%d/Prof_Bone_prot", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + subSample[i][19] = std::get>(histos.add(Form("subSample_%d/Prof_Btwo_prot", i), "", {HistType::kTProfile2D, {centAxis, noAxis}})); + } + } // end init + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + template + bool selectionProton(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; //! pid check main flag + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + const float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + const float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + const float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { + if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + template + bool selectionPion(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; //! pid check main flag + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + const float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + const float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + const float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPi > combNSigmaPr) && !(combNSigmaPi > combNSigmaKa)) { + if (combNSigmaPi < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + template + bool selectionKaon(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; //! pid check main flag + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + const float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + const float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + const float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaKa > combNSigmaPi) && !(combNSigmaKa > combNSigmaPr)) { + if (combNSigmaKa < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + // process Data + void process(AodCollisions::iterator const& coll, aod::BCsWithTimestamps const&, AodTracks const& inputTracks) + { + if (!coll.sel8()) { + return; + } + if (cfgUseGoodITSLayerAllCut && !(coll.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))) { + return; + } + if (cfgEvSelkNoSameBunchPileup && !(coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + return; + } + if (cfgEvSelkNoITSROFrameBorder && !(coll.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + return; + } + if (cfgEvSelkNoTimeFrameBorder && !(coll.selection_bit(o2::aod::evsel::kNoTimeFrameBorder))) { + return; + } + + // Centrality + double cent = 0.0; + if (cfgCentralityChoice == 1) + cent = coll.centFT0C(); + else if (cfgCentralityChoice == 2) + cent = coll.centFT0A(); + else if (cfgCentralityChoice == 3) + cent = coll.centFT0M(); + else if (cfgCentralityChoice == 4) + cent = coll.centFV0A(); + + histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); + histos.fill(HIST("hCentrality"), cent); + histos.fill(HIST("Hist2D_globalTracks_PVTracks"), coll.multNTracksPV(), inputTracks.size()); + histos.fill(HIST("Hist2D_cent_nch"), inputTracks.size(), cent); + + // Analysis variables + int nbinsHad = 20; + int nbinsPid = 18; + double binsarray[21] = {0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.5, 4.0, 5.0, 6.0, 8.0, 10.0}; + TH1D* fPtProfileHad = new TH1D("fPtProfileHad", "fPtProfileHad", 20, binsarray); + TH1D* fPtProfilePi = new TH1D("fPtProfilePi", "fPtProfilePi", 20, binsarray); + TH1D* fPtProfileKa = new TH1D("fPtProfileKa", "fPtProfileKa", 20, binsarray); + TH1D* fPtProfileProt = new TH1D("fPtProfileProt", "fPtProfileProt", 20, binsarray); + double pTsumEtaLeftHad = 0.0; + double nSumEtaLeftHad = 0.0; + double pTsumEtaRightHad = 0.0; + double nSumEtaRightHad = 0.0; + double nSumEtaLeftPi = 0.0; + double nSumEtaLeftKa = 0.0; + double nSumEtaLeftProt = 0.0; + + for (const auto& track : inputTracks) { // Loop over tracks + + if (!track.has_collision()) { + continue; + } + + if (!track.isPVContributor()) { + continue; + } + + if (!(track.itsNCls() > cfgITScluster) || !(track.tpcNClsFound() >= cfgTPCcluster) || !(track.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) { + continue; + } + + histos.fill(HIST("hP"), track.p()); + histos.fill(HIST("hPt"), track.pt()); + histos.fill(HIST("hEta"), track.eta()); + histos.fill(HIST("hPhi"), track.phi()); + histos.fill(HIST("hDcaXY"), track.dcaXY()); + histos.fill(HIST("hDcaZ"), track.dcaZ()); + + double trkPt = track.pt(); + double trkEta = track.eta(); + + // inclusive charged particles + if (track.sign() != 0) { + if (trkEta < cfgCutEtaLeft) { + fPtProfileHad->Fill(trkPt); + pTsumEtaLeftHad += trkPt; + nSumEtaLeftHad += 1.0; + } + if (trkEta > cfgCutEtaRight) { + pTsumEtaRightHad += trkPt; + nSumEtaRightHad += 1.0; + } + } + + // PID QAs before selection + double nSigmaTpcPi = track.tpcNSigmaPi(); + double nSigmaTpcKa = track.tpcNSigmaKa(); + double nSigmaTpcProt = track.tpcNSigmaPr(); + double nSigmaTofPi = track.tofNSigmaPi(); + double nSigmaTofKa = track.tofNSigmaKa(); + double nSigmaTofProt = track.tofNSigmaPr(); + histos.fill(HIST("h2DnsigmaPionTpcVsPtBeforeCut"), trkPt, nSigmaTpcPi); + histos.fill(HIST("h2DnsigmaKaonTpcVsPtBeforeCut"), trkPt, nSigmaTpcKa); + histos.fill(HIST("h2DnsigmaProtonTpcVsPtBeforeCut"), trkPt, nSigmaTpcProt); + histos.fill(HIST("h2DnsigmaPionTofVsPtBeforeCut"), trkPt, nSigmaTofPi); + histos.fill(HIST("h2DnsigmaKaonTofVsPtBeforeCut"), trkPt, nSigmaTofKa); + histos.fill(HIST("h2DnsigmaProtonTofVsPtBeforeCut"), trkPt, nSigmaTofProt); + histos.fill(HIST("h2DnsigmaPionTpcVsTofBeforeCut"), nSigmaTpcPi, nSigmaTofPi); + histos.fill(HIST("h2DnsigmaKaonTpcVsTofBeforeCut"), nSigmaTpcKa, nSigmaTofKa); + histos.fill(HIST("h2DnsigmaProtonTpcVsTofBeforeCut"), nSigmaTpcProt, nSigmaTofProt); + + // identified particles selection + bool isPion = selectionPion(track); + bool isKaon = selectionKaon(track); + bool isProton = selectionProton(track); + + // PID QAs after selection + if (isPion) { + histos.fill(HIST("h2DnsigmaPionTpcVsPtAfterCut"), trkPt, nSigmaTpcPi); + histos.fill(HIST("h2DnsigmaPionTofVsPtAfterCut"), trkPt, nSigmaTofPi); + histos.fill(HIST("h2DnsigmaPionTpcVsTofAfterCut"), nSigmaTpcPi, nSigmaTofPi); + } + if (isKaon) { + histos.fill(HIST("h2DnsigmaKaonTpcVsPtAfterCut"), trkPt, nSigmaTpcKa); + histos.fill(HIST("h2DnsigmaKaonTofVsPtAfterCut"), trkPt, nSigmaTofKa); + histos.fill(HIST("h2DnsigmaKaonTpcVsTofAfterCut"), nSigmaTpcKa, nSigmaTofKa); + } + if (isProton) { + histos.fill(HIST("h2DnsigmaProtonTpcVsPtAfterCut"), trkPt, nSigmaTpcProt); + histos.fill(HIST("h2DnsigmaProtonTofVsPtAfterCut"), trkPt, nSigmaTofProt); + histos.fill(HIST("h2DnsigmaProtonTpcVsTofAfterCut"), nSigmaTpcProt, nSigmaTofProt); + } + + if (track.sign() != 0) { + if (trkPt < cfgCutPtUpperPID) { + if (trkEta < cfgCutEtaLeft) { + if (isPion) { + fPtProfilePi->Fill(trkPt); + nSumEtaLeftPi += 1.0; + } + if (isKaon) { + fPtProfileKa->Fill(trkPt); + nSumEtaLeftKa += 1.0; + } + if (isProton && trkPt > cfgCutPtLowerProt) { + fPtProfileProt->Fill(trkPt); + nSumEtaLeftProt += 1.0; + } + } + } + } + + } // End track loop + + // selecting subsample and filling profiles + float lRandom = funRndm->Rndm(); + int sampleIndex = static_cast(cfgNSubsample * lRandom); + + if (nSumEtaRightHad > 0 && nSumEtaLeftHad > 0) { + for (int i = 0; i < nbinsHad; i++) { + histos.get(HIST("Prof_A_had"))->Fill(cent, fPtProfileHad->GetBinCenter(i + 1), (fPtProfileHad->GetBinContent(i + 1) / nSumEtaLeftHad)); + histos.get(HIST("Prof_C_had"))->Fill(cent, fPtProfileHad->GetBinCenter(i + 1), ((fPtProfileHad->GetBinContent(i + 1) / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + histos.get(HIST("Prof_Bone_had"))->Fill(cent, 0.5, (pTsumEtaLeftHad / nSumEtaLeftHad)); + histos.get(HIST("Prof_Btwo_had"))->Fill(cent, 0.5, (pTsumEtaRightHad / nSumEtaRightHad)); + histos.get(HIST("Prof_D_had"))->Fill(cent, 0.5, ((pTsumEtaLeftHad / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + + subSample[sampleIndex][0]->Fill(cent, fPtProfileHad->GetBinCenter(i + 1), (fPtProfileHad->GetBinContent(i + 1) / nSumEtaLeftHad)); + subSample[sampleIndex][1]->Fill(cent, fPtProfileHad->GetBinCenter(i + 1), ((fPtProfileHad->GetBinContent(i + 1) / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + subSample[sampleIndex][2]->Fill(cent, 0.5, ((pTsumEtaLeftHad / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + subSample[sampleIndex][3]->Fill(cent, 0.5, (pTsumEtaLeftHad / nSumEtaLeftHad)); + subSample[sampleIndex][4]->Fill(cent, 0.5, (pTsumEtaRightHad / nSumEtaRightHad)); + } + } + + if (nSumEtaRightHad > 0 && nSumEtaLeftHad > 0 && nSumEtaLeftPi > 0) { + for (int i = 0; i < nbinsPid; i++) { + histos.get(HIST("Prof_A_pi"))->Fill(cent, fPtProfilePi->GetBinCenter(i + 1), (fPtProfilePi->GetBinContent(i + 1) / nSumEtaLeftPi)); + histos.get(HIST("Prof_C_pi"))->Fill(cent, fPtProfilePi->GetBinCenter(i + 1), ((fPtProfilePi->GetBinContent(i + 1) / nSumEtaLeftPi) * (pTsumEtaRightHad / nSumEtaRightHad))); + histos.get(HIST("Prof_Bone_pi"))->Fill(cent, 0.5, (pTsumEtaLeftHad / nSumEtaLeftHad)); + histos.get(HIST("Prof_Btwo_pi"))->Fill(cent, 0.5, (pTsumEtaRightHad / nSumEtaRightHad)); + histos.get(HIST("Prof_D_pi"))->Fill(cent, 0.5, ((pTsumEtaLeftHad / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + + subSample[sampleIndex][5]->Fill(cent, fPtProfilePi->GetBinCenter(i + 1), (fPtProfilePi->GetBinContent(i + 1) / nSumEtaLeftPi)); + subSample[sampleIndex][6]->Fill(cent, fPtProfilePi->GetBinCenter(i + 1), ((fPtProfilePi->GetBinContent(i + 1) / nSumEtaLeftPi) * (pTsumEtaRightHad / nSumEtaRightHad))); + subSample[sampleIndex][7]->Fill(cent, 0.5, ((pTsumEtaLeftHad / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + subSample[sampleIndex][8]->Fill(cent, 0.5, (pTsumEtaLeftHad / nSumEtaLeftHad)); + subSample[sampleIndex][9]->Fill(cent, 0.5, (pTsumEtaRightHad / nSumEtaRightHad)); + } + } + + if (nSumEtaRightHad > 0 && nSumEtaLeftHad > 0 && nSumEtaLeftKa > 0) { + for (int i = 0; i < nbinsPid; i++) { + histos.get(HIST("Prof_A_ka"))->Fill(cent, fPtProfileKa->GetBinCenter(i + 1), (fPtProfileKa->GetBinContent(i + 1) / nSumEtaLeftKa)); + histos.get(HIST("Prof_C_ka"))->Fill(cent, fPtProfileKa->GetBinCenter(i + 1), ((fPtProfileKa->GetBinContent(i + 1) / nSumEtaLeftKa) * (pTsumEtaRightHad / nSumEtaRightHad))); + histos.get(HIST("Prof_Bone_ka"))->Fill(cent, 0.5, (pTsumEtaLeftHad / nSumEtaLeftHad)); + histos.get(HIST("Prof_Btwo_ka"))->Fill(cent, 0.5, (pTsumEtaRightHad / nSumEtaRightHad)); + histos.get(HIST("Prof_D_ka"))->Fill(cent, 0.5, ((pTsumEtaLeftHad / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + + subSample[sampleIndex][10]->Fill(cent, fPtProfileKa->GetBinCenter(i + 1), (fPtProfileKa->GetBinContent(i + 1) / nSumEtaLeftKa)); + subSample[sampleIndex][11]->Fill(cent, fPtProfileKa->GetBinCenter(i + 1), ((fPtProfileKa->GetBinContent(i + 1) / nSumEtaLeftKa) * (pTsumEtaRightHad / nSumEtaRightHad))); + subSample[sampleIndex][12]->Fill(cent, 0.5, ((pTsumEtaLeftHad / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + subSample[sampleIndex][13]->Fill(cent, 0.5, (pTsumEtaLeftHad / nSumEtaLeftHad)); + subSample[sampleIndex][14]->Fill(cent, 0.5, (pTsumEtaRightHad / nSumEtaRightHad)); + } + } + if (nSumEtaRightHad > 0 && nSumEtaLeftHad > 0 && nSumEtaLeftProt > 0) { + for (int i = 1; i < nbinsPid; i++) { + histos.get(HIST("Prof_A_prot"))->Fill(cent, fPtProfileProt->GetBinCenter(i + 1), (fPtProfileProt->GetBinContent(i + 1) / nSumEtaLeftProt)); + histos.get(HIST("Prof_C_prot"))->Fill(cent, fPtProfileProt->GetBinCenter(i + 1), ((fPtProfileProt->GetBinContent(i + 1) / nSumEtaLeftProt) * (pTsumEtaRightHad / nSumEtaRightHad))); + histos.get(HIST("Prof_Bone_prot"))->Fill(cent, 0.5, (pTsumEtaLeftHad / nSumEtaLeftHad)); + histos.get(HIST("Prof_Btwo_prot"))->Fill(cent, 0.5, (pTsumEtaRightHad / nSumEtaRightHad)); + histos.get(HIST("Prof_D_prot"))->Fill(cent, 0.5, ((pTsumEtaLeftHad / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + + subSample[sampleIndex][15]->Fill(cent, fPtProfileProt->GetBinCenter(i + 1), (fPtProfileProt->GetBinContent(i + 1) / nSumEtaLeftProt)); + subSample[sampleIndex][16]->Fill(cent, fPtProfileProt->GetBinCenter(i + 1), ((fPtProfileProt->GetBinContent(i + 1) / nSumEtaLeftProt) * (pTsumEtaRightHad / nSumEtaRightHad))); + subSample[sampleIndex][17]->Fill(cent, 0.5, ((pTsumEtaLeftHad / nSumEtaLeftHad) * (pTsumEtaRightHad / nSumEtaRightHad))); + subSample[sampleIndex][18]->Fill(cent, 0.5, (pTsumEtaLeftHad / nSumEtaLeftHad)); + subSample[sampleIndex][19]->Fill(cent, 0.5, (pTsumEtaRightHad / nSumEtaRightHad)); + } + } + + fPtProfileHad->Delete(); + fPtProfilePi->Delete(); + fPtProfileKa->Delete(); + fPtProfileProt->Delete(); + + } // End process loop +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/PWGCF/Femto/CMakeLists.txt b/PWGCF/Femto/CMakeLists.txt new file mode 100644 index 00000000000..3b94846cb86 --- /dev/null +++ b/PWGCF/Femto/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright 2019-2025 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. + +#add_subdirectory(DataModel) +add_subdirectory(TableProducer) + diff --git a/PWGCF/Femto/DataModel/PionDeuteronTables.h b/PWGCF/Femto/DataModel/PionDeuteronTables.h new file mode 100644 index 00000000000..89754a8cc97 --- /dev/null +++ b/PWGCF/Femto/DataModel/PionDeuteronTables.h @@ -0,0 +1,111 @@ +// 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. + +/// +/// \file PionDeuteronTables.h +/// \brief Slim tables for piDeuteron +/// \author CMY +/// \date 2025-04-10 + +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" + +#ifndef PWGCF_FEMTO_DATAMODEL_PIONDEUTERONTABLES_H_ +#define PWGCF_FEMTO_DATAMODEL_PIONDEUTERONTABLES_H_ + +namespace o2::aod +{ +namespace pion_deuteron_tables +{ + +DECLARE_SOA_COLUMN(PtDe, ptDe, float); +DECLARE_SOA_COLUMN(EtaDe, etaDe, float); +DECLARE_SOA_COLUMN(PhiDe, phiDe, float); +DECLARE_SOA_COLUMN(PtPi, ptPi, float); +DECLARE_SOA_COLUMN(EtaPi, etaPi, float); +DECLARE_SOA_COLUMN(PhiPi, phiPi, float); + +DECLARE_SOA_COLUMN(DcaxyDe, dcaxyDe, float); +DECLARE_SOA_COLUMN(DcazDe, dcazDe, float); +DECLARE_SOA_COLUMN(DcaxyPi, dcaxyPi, float); +DECLARE_SOA_COLUMN(DcazPi, dcazPi, float); + +DECLARE_SOA_COLUMN(SignalTPCDe, signalTPCDe, float); +DECLARE_SOA_COLUMN(InnerParamTPCDe, innerParamTPCDe, float); +DECLARE_SOA_COLUMN(SignalTPCPi, signalTPCPi, float); +DECLARE_SOA_COLUMN(InnerParamTPCPi, innerParamTPCPi, float); +DECLARE_SOA_COLUMN(NClsTPCDe, nClsTPCDe, uint8_t); +DECLARE_SOA_COLUMN(NSigmaTPCDe, nSigmaTPCDe, float); +DECLARE_SOA_COLUMN(NSigmaTPCPi, nSigmaTPCPi, float); +DECLARE_SOA_COLUMN(Chi2TPCDe, chi2TPCDe, float); +DECLARE_SOA_COLUMN(Chi2TPCPi, chi2TPCPi, float); +DECLARE_SOA_COLUMN(MassTOFDe, massTOFDe, float); +DECLARE_SOA_COLUMN(MassTOFPi, massTOFPi, float); +DECLARE_SOA_COLUMN(PidTrkDe, pidTrkDe, uint32_t); +DECLARE_SOA_COLUMN(PidTrkPi, pidTrkPi, uint32_t); + +DECLARE_SOA_COLUMN(ItsClusterSizeDe, itsClusterSizeDe, uint32_t); +DECLARE_SOA_COLUMN(ItsClusterSizePi, itsClusterSizePi, uint32_t); + +DECLARE_SOA_COLUMN(SharedClustersDe, sharedClustersDe, uint8_t); +DECLARE_SOA_COLUMN(SharedClustersPi, sharedClustersPi, uint8_t); + +DECLARE_SOA_COLUMN(IsBkgUS, isBkgUS, bool); +DECLARE_SOA_COLUMN(IsBkgEM, isBkgEM, bool); + +DECLARE_SOA_COLUMN(CollisionId, collisionId, int64_t); +DECLARE_SOA_COLUMN(ZVertex, zVertex, float); +DECLARE_SOA_COLUMN(Multiplicity, multiplicity, uint16_t); +DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); +DECLARE_SOA_COLUMN(MultiplicityFT0C, multiplicityFT0C, float); + +} // namespace pion_deuteron_tables + +DECLARE_SOA_TABLE(PionDeuteronTable, "AOD", "PIDEUTERONTABLE", + pion_deuteron_tables::PtDe, + pion_deuteron_tables::EtaDe, + pion_deuteron_tables::PhiDe, + pion_deuteron_tables::PtPi, + pion_deuteron_tables::EtaPi, + pion_deuteron_tables::PhiPi, + pion_deuteron_tables::DcaxyDe, + pion_deuteron_tables::DcazDe, + pion_deuteron_tables::DcaxyPi, + pion_deuteron_tables::DcazPi, + pion_deuteron_tables::SignalTPCDe, + pion_deuteron_tables::InnerParamTPCDe, + pion_deuteron_tables::SignalTPCPi, + pion_deuteron_tables::InnerParamTPCPi, + pion_deuteron_tables::NClsTPCDe, + pion_deuteron_tables::NSigmaTPCDe, + pion_deuteron_tables::NSigmaTPCPi, + pion_deuteron_tables::Chi2TPCDe, + pion_deuteron_tables::Chi2TPCPi, + pion_deuteron_tables::MassTOFDe, + pion_deuteron_tables::MassTOFPi, + pion_deuteron_tables::PidTrkDe, + pion_deuteron_tables::PidTrkPi, + pion_deuteron_tables::ItsClusterSizeDe, + pion_deuteron_tables::ItsClusterSizePi, + pion_deuteron_tables::SharedClustersDe, + pion_deuteron_tables::SharedClustersPi, + pion_deuteron_tables::IsBkgUS, + pion_deuteron_tables::IsBkgEM) +DECLARE_SOA_TABLE(PionDeuteronMult, "AOD", "PIDEUTERONMULT", + pion_deuteron_tables::CollisionId, + pion_deuteron_tables::ZVertex, + pion_deuteron_tables::Multiplicity, + pion_deuteron_tables::CentFT0C, + pion_deuteron_tables::MultiplicityFT0C) + +} // namespace o2::aod + +#endif // PWGCF_FEMTO_DATAMODEL_PIONDEUTERONTABLES_H_ diff --git a/PWGCF/Femto/TableProducer/CMakeLists.txt b/PWGCF/Femto/TableProducer/CMakeLists.txt new file mode 100644 index 00000000000..10a75557174 --- /dev/null +++ b/PWGCF/Femto/TableProducer/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright 2019-2025 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. + +o2physics_add_dpl_workflow(pideuteronfemto + SOURCES PiDeuteronFemto.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) diff --git a/PWGCF/Femto/TableProducer/PiDeuteronFemto.cxx b/PWGCF/Femto/TableProducer/PiDeuteronFemto.cxx new file mode 100644 index 00000000000..6eaf78e8036 --- /dev/null +++ b/PWGCF/Femto/TableProducer/PiDeuteronFemto.cxx @@ -0,0 +1,890 @@ +// 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. +// + +/// \file PiDeuteronFemto.cxx +/// \brief Analysis task for Deuteron-Pion femto analysis +/// \author CMY +/// \date 2025-04-10 + +#include "PWGCF/Femto/DataModel/PionDeuteronTables.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/Utils/svPoolCreator.h" + +#include "Common/Core/PID/PIDTOF.h" +#include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/TableProducer/PID/pidTOFBase.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/Boost.h" +#include "Math/Vector4D.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include // std::prev +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; + +using CollBracket = o2::math_utils::Bracket; +using CollisionsFull = soa::Join; +using CollisionsFullMC = soa::Join; +using TrackCandidates = soa::Join; + +namespace +{ +constexpr double betheBlochDefault[1][6]{{-136.71, 0.441, 0.2269, 1.347, 0.8035, 0.09}}; +static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; + +enum Selections { + kNoCuts = 0, + kTrackCuts, + kPID, + kAll +}; + +} // namespace + +struct PiDecandidate { + + float recoPtDe() const { return signDe * std::hypot(momDe[0], momDe[1]); } + float recoPhiDe() const { return std::atan2(momDe[1], momDe[0]); } + float recoEtaDe() const { return std::asinh(momDe[2] / std::abs(recoPtDe())); } + float recoPtPi() const { return signPi * std::hypot(momPi[0], momPi[1]); } + float recoPhiPi() const { return std::atan2(momPi[1], momPi[0]); } + float recoEtaPi() const { return std::asinh(momPi[2] / std::abs(recoPtPi())); } + + std::array momDe = {99.f, 99.f, 99.f}; + std::array momPi = {99.f, 99.f, 99.f}; + + float signDe = 1.f; + float signPi = 1.f; + float invMass = -10.f; + float dcaxyDe = -10.f; + float dcazDe = -10.f; + float dcaxyPi = -10.f; + float dcazPi = -10.f; + + uint16_t tpcSignalDe = 0u; + uint16_t tpcSignalPi = 0u; + float momDeTPC = -99.f; + float momPiTPC = -99.f; + uint8_t nTPCClustersDe = 0u; + uint8_t sharedClustersDe = 0u; + uint8_t sharedClustersPi = 0u; + float chi2TPCDe = -10.f; + float chi2TPCPi = -10.f; + float nSigmaDe = -10.f; + float nSigmaPi = -10.f; + uint32_t pidTrkDe = 0xFFFFF; // PID in tracking + uint32_t pidTrkPi = 0xFFFFF; + float massTOFDe = -10; + float massTOFPi = -10; + uint32_t itsClSizeDe = 0u; + uint32_t itsClSizePi = 0u; + + uint8_t nClsItsDe = 0u; + uint8_t nClsItsPi = 0u; + + bool isBkgUS = false; // unlike sign + bool isBkgEM = false; // event mixing + + int trackIDDe = -1; + int trackIDPi = -1; + + // collision information + int32_t collisionID = 0; +}; + +struct PiDeuteronFemto { + + Produces mOutputDataTable; + Produces mOutputMultiplicityTable; + + // Selections + Configurable settingCutVertex{"settingCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable settingCutPinMinDe{"settingCutPinMinDe", 0.0f, "Minimum Pin for De"}; + Configurable settingCutEta{"settingCutEta", 0.8f, "Eta cut on daughter track"}; + Configurable settingCutChi2tpcLow{"settingCutChi2tpcLow", 0.0f, "Low cut on TPC chi2"}; + Configurable settingCutChi2tpcHigh{"settingCutChi2tpcHigh", 999.f, "High cut on TPC chi2"}; + Configurable settingCutInvMass{"settingCutInvMass", 0.0f, "Invariant mass upper limit"}; + Configurable settingCutPtMinDePi{"settingCutPtMinDePi", 0.0f, "Minimum PT cut on DePi4"}; + Configurable settingCutClSizeItsDe{"settingCutClSizeItsDe", 4.0f, "Minimum ITS cluster size for De"}; + Configurable settingCutNCls{"settingCutNCls", 5.0f, "Minimum ITS Ncluster for tracks"}; + Configurable settingCutChi2NClITS{"settingCutChi2NClITS", 999.f, "Maximum ITS Chi2 for tracks"}; + Configurable settingCutNsigmaTPCPi{"settingCutNsigmaTPCPi", 3.0f, "Value of the TPC Nsigma cut on Pi"}; + Configurable settingCutNsigmaTPCDe{"settingCutNsigmaTPCDe", 2.5f, "Value of the TPC Nsigma cut on De"}; + Configurable settingCutNsigmaITSDe{"settingCutNsigmaITSDe", 2.5f, "Value of the ITD Nsigma cut on De"}; + Configurable settingCutPinMinTOFPi{"settingCutPinMinTOFPi", 0.5f, "Minimum Pin to apply the TOF cut on Pions"}; + Configurable settingCutPinMinTOFITSDe{"settingCutPinMinTOFITSDe", 1.2f, "Minimum p to apply the TOF ITS cut on De"}; + Configurable settingCutNsigmaTOFTPCDe{"settingCutNsigmaTOFTPCDe", 2.5f, "Value of the De TOF TPC Nsigma cut"}; + Configurable settingCutNsigmaTOFTPCPi{"settingCutNsigmaTOFTPCPi", 3.0f, "Value of the Pion TOF TPC Nsigma cut"}; + Configurable settingNoMixedEvents{"settingNoMixedEvents", 5, "Number of mixed events per event"}; + Configurable settingEnableBkgUS{"settingEnableBkgUS", false, "Enable US background"}; + + Configurable settingFillTable{"settingFillTable", false, "Enable table filling"}; + Configurable settingCutPiptMin{"settingCutPiptMin", 0.14f, "Minimum PT cut on Pi"}; + Configurable settingCutPiptMax{"settingCutPiptMax", 4.0f, "Maximum PT cut on Pi"}; + Configurable settingCutDeptMin{"settingCutDeptMin", 0.6f, "Minimum PT cut on De"}; + Configurable settingCutDeptMax{"settingCutDeptMax", 1.6f, "Maximum PT cut on De"}; + Configurable settingCutPiDCAxyMin{"settingCutPiDCAxyMin", 0.3f, "DCAxy Min for Pi"}; + Configurable settingCutPiDCAzMin{"settingCutPiDCAzMin", 0.3f, "DCAz Min for Pi"}; + Configurable settingCutDeDCAzMin{"settingCutDeDCAzMin", 0.2f, "DCAxy Min for De"}; + Configurable settingCutNsigTPCPrMin{"settingCutNsigTPCPrMin", 3.0f, "Minimum TPC Pr Nsigma cut on Pi"}; + Configurable settingCutNsigTOFPrMin{"settingCutNsigTOFPrMin", 3.0f, "Minimum TOF Pr Nsigma cut on Pi"}; + + Configurable settingSaveUSandLS{"settingSaveUSandLS", true, "Save All Pairs"}; + Configurable settingFillMultiplicity{"settingFillMultiplicity", false, "Fill multiplicity table"}; + Configurable settingUseBBcomputeDeNsigma{"settingUseBBcomputeDeNsigma", false, "Use BB params to compute De TPC Nsigma"}; + + // Zorro + Configurable settingSkimmedProcessing{"settingSkimmedProcessing", false, "Skimmed dataset processing"}; + + // CCDB options + Configurable settingDbz{"settingDbz", -999, "bz field, -999 is automatic"}; + Configurable settingCcdburl{"settingCcdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable settingGrpPath{"settingGrpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable settingGrpmagPath{"settingGrpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable settingLutPath{"settingLutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable settingGeoPath{"settingGeoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable settingPidPath{"settingPidPath", "", "Path to the PID response object"}; + + Configurable> settingBetheBlochParams{"settingBetheBlochParams", {betheBlochDefault[0], 1, 6, {"De"}, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for De"}; + Configurable settingCompensatePIDinTracking{"settingCompensatePIDinTracking", false, "If true, divide tpcInnerParam by the electric charge"}; + Configurable settingMaterialCorrection{"settingMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Material correction type"}; + + Preslice mPerCol = aod::track::collisionId; + + // binning for EM background + ConfigurableAxis axisVertex{"axisVertex", {30, -10, 10}, "Binning for multiplicity"}; + ConfigurableAxis axisCentrality{"axisCentrality", {40, 0, 100}, "Binning for centrality"}; + using BinningType = ColumnBinningPolicy; + BinningType binningPolicy{{axisVertex, axisCentrality}, true}; + SliceCache cache; + SameKindPair mPair{binningPolicy, settingNoMixedEvents, -1, &cache}; + + std::array mBBparamsDe; + + std::vector mRecoCollisionIDs; + std::vector mGoodCollisions; + std::vector mTrackPairs; + o2::vertexing::DCAFitterN<2> mFitter; + + int mRunNumber; + float mDbz; + Service mCcdb; + Zorro mZorro; + OutputObj mZorroSummary{"zorroSummary"}; + + HistogramRegistry mQaRegistry{ + "QA", + {{"hVtxZ", "Vertex distribution in Z;Z (cm)", {HistType::kTH1F, {{400, -20.0, 20.0}}}}, + {"hNcontributor", "Number of primary vertex contributor", {HistType::kTH1F, {{2000, 0.0f, 2000.0f}}}}, + {"hTrackSel", "Accepted tracks", {HistType::kTH1F, {{Selections::kAll, -0.5, static_cast(Selections::kAll) - 0.5}}}}, + {"hEvents", "; Events;", {HistType::kTH1F, {{3, -0.5, 2.5}}}}, + {"hEmptyPool", "svPoolCreator did not find track pairs false/true", {HistType::kTH1F, {{2, -0.5, 1.5}}}}, + {"hdcaxyDe", ";DCA_{xy} (cm)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, + {"hdcazDe", ";DCA_{z} (cm)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, + {"hdcazDe_min", ";DCA_{z}-min (cm)", {HistType::kTH1F, {{20, -1.0f, 1.0f}}}}, + {"hNClsDeITS", ";N_{ITS} Cluster", {HistType::kTH1F, {{20, -10.0f, 10.0f}}}}, + {"hNClsPiITS", ";N_{ITS} Cluster", {HistType::kTH1F, {{20, -10.0f, 10.0f}}}}, + {"hDePitInvMass", "; M(De + p) (GeV/#it{c}^{2})", {HistType::kTH1F, {{300, 3.74f, 4.34f}}}}, + {"hDePt", "#it{p}_{T} distribution; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{240, -6.0f, 6.0f}}}}, + {"hPiPt", "Pt distribution; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{120, -3.0f, 3.0f}}}}, + {"hDeEta", "eta distribution; #eta(De)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, + {"hPiEta", "eta distribution; #eta(#pi)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, + {"hDePhi", "phi distribution; phi(De)", {HistType::kTH1F, {{600, -4.0f, 4.0f}}}}, + {"hPiPhi", "phi distribution; phi(#pi)", {HistType::kTH1F, {{600, -4.0f, 4.0f}}}}, + {"h2dEdxDecandidates", "dEdx distribution; #it{p} (GeV/#it{c}); dE/dx (a.u.)", {HistType::kTH2F, {{200, -5.0f, 5.0f}, {100, 0.0f, 2000.0f}}}}, + {"h2dEdx", "dEdx distribution; #it{p} (GeV/#it{c}); dE/dx (a.u.)", {HistType::kTH2F, {{200, -5.0f, 5.0f}, {100, 0.0f, 2000.0f}}}}, + {"h2NsigmaDeTPC", "NsigmaDe TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(De)", {HistType::kTH2F, {{100, -2.0f, 2.0f}, {200, -5.0f, 5.0f}}}}, + {"h2NsigmaDeComb", "NsigmaDe TPCTOF comb distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{comb}(De)", {HistType::kTH2F, {{100, -2.0f, 2.0f}, {100, 0.0f, 5.0f}}}}, + {"h2NsigmaPiComb", "NsigmaPi TPCTOF comb distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{comb}(#pi)", {HistType::kTH2F, {{100, -2.0f, 2.0f}, {100, 0.0f, 5.0f}}}}, + {"h2NsigmaDeTPC_preselection", "NsigmaDe TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(De)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, + {"h2NsigmaDeTPC_preselecComp", "NsigmaDe TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(De)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, + {"h2NSigmaDeITS_preselection", "NsigmaDe ITS distribution; signed #it{p}_{T} (GeV/#it{c}); n#sigma_{ITS} De", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {120, -3.0f, 3.0f}}}}, + {"h2NSigmaDeITS", "NsigmaDe ITS distribution; signed #it{p}_{T} (GeV/#it{c}); n#sigma_{ITS} De", {HistType::kTH2F, {{100, -2.0f, 2.0f}, {120, -3.0f, 3.0f}}}}, + {"h2NsigmaPiTPC", "NsigmaPi TPC distribution; #it{p}_{T}(GeV/#it{c}); n#sigma_{TPC}(p)", {HistType::kTH2F, {{200, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, + {"h2NsigmaPiTPC_preselection", "NsigmaDe TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(De)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, + {"h2NsigmaPiTOF", "NsigmaPi TOF distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(p)", {HistType::kTH2F, {{200, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, + {"h2NsigmaDeTOF", "NsigmaDe TOF distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(De)", {HistType::kTH2F, {{200, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, + {"h2NsigmaPiTOF_preselection", "NsigmaPi TOF distribution; #iit{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(p)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, + {"hkStar_LS_M", ";kStar (GeV/c)", {HistType::kTH1F, {{300, 0.0f, 3.0f}}}}, + {"hkStar_LS_A", ";kStar (GeV/c)", {HistType::kTH1F, {{300, 0.0f, 3.0f}}}}, + {"hkStar_US_M", ";kStar (GeV/c)", {HistType::kTH1F, {{300, 0.0f, 3.0f}}}}, + {"hkStar_US_A", ";kStar (GeV/c)", {HistType::kTH1F, {{300, 0.0f, 3.0f}}}}, + {"hkStar_All", ";kStar (GeV/c)", {HistType::kTH1F, {{300, 0.0f, 3.0f}}}}, + {"hisBkgEM", "; isBkgEM;", {HistType::kTH1F, {{3, -1, 2}}}}}, + OutputObjHandlingPolicy::AnalysisObject, + false, + true}; + + void init(o2::framework::InitContext&) + { + mZorroSummary.setObject(mZorro.getZorroSummary()); + mRunNumber = 0; + + mCcdb->setURL(settingCcdburl); + mCcdb->setCaching(true); + mCcdb->setLocalObjectValidityChecking(); + mCcdb->setFatalWhenNull(false); + + mFitter.setPropagateToPCA(true); + mFitter.setMaxR(200.); + mFitter.setMinParamChange(1e-3); + mFitter.setMinRelChi2Change(0.9); + mFitter.setMaxDZIni(1e9); + mFitter.setMaxChi2(1e9); + mFitter.setUseAbsDCA(true); + int mat{static_cast(settingMaterialCorrection)}; + mFitter.setMatCorrType(static_cast(mat)); + + const int numParticles = 5; + for (int i = 0; i < numParticles; i++) { + mBBparamsDe[i] = settingBetheBlochParams->get("De", Form("p%i", i)); + } + mBBparamsDe[5] = settingBetheBlochParams->get("De", "resolution"); + + std::vector selectionLabels = {"All", "Track selection", "PID"}; + for (int i = 0; i < Selections::kAll; i++) { + mQaRegistry.get(HIST("hTrackSel"))->GetXaxis()->SetBinLabel(i + 1, selectionLabels[i].c_str()); + } + + std::vector eventsLabels = {"All", "Selected", "Zorro De events"}; + for (int i = 0; i < Selections::kAll; i++) { + mQaRegistry.get(HIST("hEvents"))->GetXaxis()->SetBinLabel(i + 1, eventsLabels[i].c_str()); + } + + mQaRegistry.get(HIST("hEmptyPool"))->GetXaxis()->SetBinLabel(1, "False"); + mQaRegistry.get(HIST("hEmptyPool"))->GetXaxis()->SetBinLabel(2, "True"); + } + + void initCCDB(const aod::BCsWithTimestamps::iterator& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + if (settingSkimmedProcessing) { + mZorro.initCCDB(mCcdb.service, bc.runNumber(), bc.timestamp(), "fDe"); + mZorro.populateHistRegistry(mQaRegistry, bc.runNumber()); + } + mRunNumber = bc.runNumber(); + const float defaultBzValue = -999.0f; + auto run3GrpTimestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = mCcdb->getForTimeStamp(settingGrpPath, run3GrpTimestamp); + o2::parameters::GRPMagField* grpmag = 0x0; + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + if (settingDbz < defaultBzValue) { + // Fetch magnetic field from ccdb for current collision + mDbz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3GrpTimestamp << " with magnetic field of " << mDbz << " kZG"; + } else { + mDbz = settingDbz; + } + } else { + grpmag = mCcdb->getForTimeStamp(settingGrpmagPath, run3GrpTimestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << settingGrpmagPath << " of object GRPMagField and " << settingGrpPath << " of object GRPObject for timestamp " << run3GrpTimestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + if (settingDbz < defaultBzValue) { + // Fetch magnetic field from ccdb for current collision + mDbz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3GrpTimestamp << " with magnetic field of " << mDbz << " kZG"; + } else { + mDbz = settingDbz; + } + } + } + + // ================================================================================================================== + + template + bool selectCollision(const Tcollision& collision, const aod::BCsWithTimestamps&) + { + mQaRegistry.fill(HIST("hEvents"), 0); + + if constexpr (isMC) { + if (/*!collision.sel8() ||*/ std::abs(collision.posZ()) > settingCutVertex) { + return false; + } + } else { + auto bc = collision.template bc_as(); + initCCDB(bc); + + if (!collision.sel8() || std::abs(collision.posZ()) > settingCutVertex) { + return false; + } + if (settingSkimmedProcessing) { + bool zorroSelected = mZorro.isSelected(collision.template bc_as().globalBC()); + if (zorroSelected) { + mQaRegistry.fill(HIST("hEvents"), 2); + } + } + } + + mQaRegistry.fill(HIST("hEvents"), 1); + mQaRegistry.fill(HIST("hNcontributor"), collision.numContrib()); + mQaRegistry.fill(HIST("hVtxZ"), collision.posZ()); + return true; + } + + template + bool selectTrack(const Ttrack& candidate) + { + if (std::abs(candidate.eta()) > settingCutEta) { + return false; + } + const int minTPCNClsFound = 90; + const int minTPCNClsCrossedRows = 100; + const float crossedRowsToFindableRatio = 0.83f; + if (candidate.itsNCls() < settingCutNCls || + candidate.tpcNClsFound() < minTPCNClsFound || + candidate.tpcNClsCrossedRows() < minTPCNClsCrossedRows || + candidate.tpcNClsCrossedRows() < crossedRowsToFindableRatio * candidate.tpcNClsFindable() || + candidate.tpcChi2NCl() > settingCutChi2tpcHigh || + candidate.tpcChi2NCl() < settingCutChi2tpcLow || + candidate.itsChi2NCl() > settingCutChi2NClITS) { + return false; + } + + return true; + } + + template + bool selectionPIDPion(const Ttrack& candidate) + { + auto tpcNSigmaPi = candidate.tpcNSigmaPi(); + mQaRegistry.fill(HIST("h2NsigmaPiTPC_preselection"), candidate.tpcInnerParam(), tpcNSigmaPi); + if (std::abs(candidate.pt()) < settingCutPiptMin || std::abs(candidate.pt()) > settingCutPiptMax) + return false; + if (candidate.hasTOF() && candidate.tpcInnerParam() >= settingCutPinMinTOFPi) { + auto tofNSigmaPi = candidate.tofNSigmaPi(); + auto combNsigma = std::sqrt(tofNSigmaPi * tofNSigmaPi + tpcNSigmaPi * tpcNSigmaPi); + + mQaRegistry.fill(HIST("h2NsigmaPiTOF_preselection"), candidate.pt(), tofNSigmaPi); + if (combNsigma > settingCutNsigmaTOFTPCPi) { + return false; + } + mQaRegistry.fill(HIST("h2NsigmaPiTPC"), candidate.sign() * candidate.pt(), tpcNSigmaPi); + mQaRegistry.fill(HIST("h2NsigmaPiTOF"), candidate.sign() * candidate.pt(), tofNSigmaPi); + mQaRegistry.fill(HIST("h2NsigmaPiComb"), candidate.sign() * candidate.pt(), combNsigma); + return true; + } else if (candidate.tpcInnerParam() < settingCutPinMinTOFPi) { + if (std::abs(tpcNSigmaPi) > settingCutNsigmaTPCPi) { + return false; + } + mQaRegistry.fill(HIST("h2NsigmaPiTPC"), candidate.sign() * candidate.pt(), tpcNSigmaPi); + return true; + } + return false; + } + + template + float computeNSigmaDe(const Ttrack& candidate) + { + float expTPCSignal = o2::tpc::BetheBlochAleph(static_cast(candidate.tpcInnerParam() / constants::physics::MassDeuteron), mBBparamsDe[0], mBBparamsDe[1], mBBparamsDe[2], mBBparamsDe[3], mBBparamsDe[4]); + double resoTPC{expTPCSignal * mBBparamsDe[5]}; + return static_cast((candidate.tpcSignal() - expTPCSignal) / resoTPC); + } + + template + bool selectionPIDDe(const Ttrack& candidate) + { + float tpcInnerParam = candidate.tpcInnerParam(); + mQaRegistry.fill(HIST("h2dEdx"), candidate.sign() * tpcInnerParam, candidate.tpcSignal()); + + if (std::abs(tpcInnerParam) < settingCutPinMinDe) { + return false; + } + float tpcNSigmaDe; + if (settingUseBBcomputeDeNsigma) { + tpcNSigmaDe = computeNSigmaDe(candidate); + } else { + tpcNSigmaDe = candidate.tpcNSigmaDe(); + } + + mQaRegistry.fill(HIST("h2NsigmaDeTPC_preselection"), candidate.sign() * candidate.pt(), tpcNSigmaDe); + mQaRegistry.fill(HIST("h2NsigmaDeTPC_preselecComp"), candidate.sign() * candidate.pt(), candidate.tpcNSigmaDe()); + if (std::abs(candidate.pt()) < settingCutDeptMin || std::abs(candidate.pt()) > settingCutDeptMax) + return false; + if (candidate.hasTOF() && candidate.tpcInnerParam() > settingCutPinMinTOFITSDe) { + auto tofNSigmaDe = candidate.tofNSigmaDe(); + auto combNsigma = std::sqrt(tofNSigmaDe * tofNSigmaDe + tpcNSigmaDe * tpcNSigmaDe); + if (combNsigma > settingCutNsigmaTOFTPCDe) { + return false; + } + mQaRegistry.fill(HIST("h2dEdxDecandidates"), candidate.sign() * tpcInnerParam, candidate.tpcSignal()); + mQaRegistry.fill(HIST("h2NsigmaDeComb"), candidate.sign() * candidate.pt(), combNsigma); + mQaRegistry.fill(HIST("h2NsigmaDeTPC"), candidate.sign() * candidate.pt(), tpcNSigmaDe); + mQaRegistry.fill(HIST("h2NsigmaDeTOF"), candidate.sign() * candidate.pt(), tofNSigmaDe); + return true; + } else if (candidate.tpcInnerParam() <= settingCutPinMinTOFITSDe) { + if (std::abs(tpcNSigmaDe) > settingCutNsigmaTPCDe) { + return false; + } + o2::aod::ITSResponse mResponseITS; + auto itsnSigmaDe = mResponseITS.nSigmaITS(candidate.itsClusterSizes(), candidate.p(), candidate.eta()); + mQaRegistry.fill(HIST("h2NSigmaDeITS_preselection"), candidate.sign() * candidate.pt(), itsnSigmaDe); + if (std::abs(itsnSigmaDe) > settingCutNsigmaITSDe) { + return false; + } + mQaRegistry.fill(HIST("h2NsigmaDeTPC"), candidate.sign() * candidate.pt(), tpcNSigmaDe); + mQaRegistry.fill(HIST("h2NSigmaDeITS"), candidate.sign() * candidate.pt(), itsnSigmaDe); + // mQaRegistry.fill(HIST("h2NsigmaDeComb"), candidate.sign() * candidate.pt(), combNsigma); + mQaRegistry.fill(HIST("h2dEdxDecandidates"), candidate.sign() * tpcInnerParam, candidate.tpcSignal()); + return true; + } + return false; + } + + // ================================================================================================================== + + template + bool fillCandidateInfo(const Ttrack& trackDe, const Ttrack& trackPi, const CollBracket& collBracket, const Tcollisions& collisions, PiDecandidate& piDecand, const Ttracks& /*trackTable*/, bool isMixedEvent) + { + const int numCoordinates = 3; + if (!isMixedEvent) { + auto trackCovDe = getTrackParCov(trackDe); + auto trackCovPi = getTrackParCov(trackPi); + int nCand = 0; + try { + nCand = mFitter.process(trackCovDe, trackCovPi); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + return false; + } + if (nCand == 0) { + return false; + } + + // associate collision id as the one that minimises the distance between the vertex and the PCAs of the daughters + double distanceMin = -1; + unsigned int collIdxMin = 0; + + for (int collIdx = collBracket.getMin(); collIdx <= collBracket.getMax(); collIdx++) { + auto collision = collisions.rawIteratorAt(collIdx); + std::array collVtx = {collision.posX(), collision.posY(), collision.posZ()}; + const auto& pca = mFitter.getPCACandidate(); + float distance = 0; + for (int i = 0; i < numCoordinates; i++) { + distance += (pca[i] - collVtx[i]) * (pca[i] - collVtx[i]); + } + if (distanceMin < 0 || distance < distanceMin) { + distanceMin = distance; + collIdxMin = collIdx; + } + } + + if (!mGoodCollisions[collIdxMin]) { + return false; + } + piDecand.collisionID = collIdxMin; + } else { + piDecand.collisionID = collBracket.getMin(); + } + + piDecand.momDe = std::array{trackDe.px(), trackDe.py(), trackDe.pz()}; + piDecand.momPi = std::array{trackPi.px(), trackPi.py(), trackPi.pz()}; + float invMass = 0; + invMass = RecoDecay::m(std::array{piDecand.momDe, piDecand.momPi}, std::array{o2::constants::physics::MassDeuteron, o2::constants::physics::MassPiPlus}); + if (settingCutInvMass > 0 && invMass > settingCutInvMass) { + return false; + } + float ptDePi = std::hypot(piDecand.momDe[0] + piDecand.momPi[0], piDecand.momDe[1] + piDecand.momPi[1]); + if (ptDePi < settingCutPtMinDePi) { + return false; + } + + piDecand.signDe = trackDe.sign(); + piDecand.signPi = trackPi.sign(); + + piDecand.dcaxyDe = trackDe.dcaXY(); + piDecand.dcaxyPi = trackPi.dcaXY(); + + piDecand.dcazDe = trackDe.dcaZ(); + piDecand.dcazPi = trackPi.dcaZ(); + + piDecand.tpcSignalDe = trackDe.tpcSignal(); + piDecand.momDeTPC = trackDe.tpcInnerParam(); + piDecand.tpcSignalPi = trackPi.tpcSignal(); + piDecand.momPiTPC = trackPi.tpcInnerParam(); + + piDecand.nTPCClustersDe = trackDe.tpcNClsFound(); + piDecand.nSigmaDe = computeNSigmaDe(trackDe); + piDecand.nSigmaPi = trackPi.tpcNSigmaPi(); + + piDecand.chi2TPCDe = trackDe.tpcChi2NCl(); + piDecand.chi2TPCPi = trackPi.tpcChi2NCl(); + + piDecand.pidTrkDe = trackDe.pidForTracking(); + piDecand.pidTrkPi = trackPi.pidForTracking(); + + piDecand.itsClSizeDe = trackDe.itsClusterSizes(); + piDecand.itsClSizePi = trackPi.itsClusterSizes(); + + piDecand.nClsItsDe = trackDe.itsNCls(); + piDecand.nClsItsPi = trackPi.itsNCls(); + + piDecand.sharedClustersDe = trackDe.tpcNClsShared(); + piDecand.sharedClustersPi = trackPi.tpcNClsShared(); + + piDecand.isBkgUS = trackDe.sign() * trackPi.sign() < 0; + piDecand.isBkgEM = isMixedEvent; + + piDecand.invMass = invMass; + + piDecand.trackIDDe = trackDe.globalIndex(); + piDecand.trackIDPi = trackPi.globalIndex(); + + if (trackDe.hasTOF()) { + float beta = o2::pid::tof::Beta::GetBeta(trackDe); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + float tpcInnerParamDe = trackDe.tpcInnerParam(); + piDecand.massTOFDe = tpcInnerParamDe * std::sqrt(1.f / (beta * beta) - 1.f); + } + if (trackPi.hasTOF()) { + float beta = o2::pid::tof::Beta::GetBeta(trackPi); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + piDecand.massTOFPi = trackPi.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f); + } + + return true; + } + + template + void pairTracksSameEvent(const Ttrack& tracks) + { + // LOG(info) << "Number of tracks: " << tracks.size(); + for (const auto& track0 : tracks) { + + mQaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); + + if (!selectTrack(track0)) { + continue; + } + mQaRegistry.fill(HIST("hTrackSel"), Selections::kTrackCuts); + + if (!selectionPIDDe(track0)) { + continue; + } + mQaRegistry.fill(HIST("hTrackSel"), Selections::kPID); + + for (const auto& track1 : tracks) { + if (track0 == track1) { + continue; + } + + if (!settingSaveUSandLS) { + if (!settingEnableBkgUS && (track0.sign() * track1.sign() < 0)) { + continue; + } + if (settingEnableBkgUS && (track0.sign() * track1.sign() > 0)) { + continue; + } + } + + if (!selectTrack(track1) || !selectionPIDPion(track1)) { + continue; + } + + SVCand trackPair; + trackPair.tr0Idx = track0.globalIndex(); + trackPair.tr1Idx = track1.globalIndex(); + const int collIdx = track0.collisionId(); + CollBracket collBracket{collIdx, collIdx}; + trackPair.collBracket = collBracket; + mTrackPairs.push_back(trackPair); + } + } + } + + template + void pairTracksEventMixing(T& DeCands, T& pionCands) + { + for (const auto& DeCand : DeCands) { + if (!selectTrack(DeCand) || !selectionPIDDe(DeCand)) { + continue; + } + for (const auto& pionCand : pionCands) { + if (!selectTrack(pionCand) || !selectionPIDPion(pionCand)) { + continue; + } + + SVCand trackPair; + trackPair.tr0Idx = DeCand.globalIndex(); + trackPair.tr1Idx = pionCand.globalIndex(); + const int collIdx = DeCand.collisionId(); + CollBracket collBracket{collIdx, collIdx}; + trackPair.collBracket = collBracket; + mTrackPairs.push_back(trackPair); + } + } + } + + template + void fillTable(const PiDecandidate& piDecand, const Tcoll& collision) + { + mOutputDataTable( + piDecand.recoPtDe(), + piDecand.recoEtaDe(), + piDecand.recoPhiDe(), + piDecand.recoPtPi(), + piDecand.recoEtaPi(), + piDecand.recoPhiPi(), + piDecand.dcaxyDe, + piDecand.dcazDe, + piDecand.dcaxyPi, + piDecand.dcazPi, + piDecand.tpcSignalDe, + piDecand.momDeTPC, + piDecand.tpcSignalPi, + piDecand.momPiTPC, + piDecand.nTPCClustersDe, + piDecand.nSigmaDe, + piDecand.nSigmaPi, + piDecand.chi2TPCDe, + piDecand.chi2TPCPi, + piDecand.massTOFDe, + piDecand.massTOFPi, + piDecand.pidTrkDe, + piDecand.pidTrkPi, + piDecand.itsClSizeDe, + piDecand.itsClSizePi, + piDecand.sharedClustersDe, + piDecand.sharedClustersPi, + piDecand.isBkgUS, + piDecand.isBkgEM); + if (settingFillMultiplicity) { + mOutputMultiplicityTable( + collision.globalIndex(), + collision.posZ(), + collision.numContrib(), + collision.centFT0C(), + collision.multFT0C()); + } + } + + void fillHistograms(const PiDecandidate& piDecand) + { + mQaRegistry.fill(HIST("hDePt"), piDecand.recoPtDe()); + mQaRegistry.fill(HIST("hPiPt"), piDecand.recoPtPi()); + mQaRegistry.fill(HIST("hDeEta"), piDecand.recoEtaDe()); + mQaRegistry.fill(HIST("hPiEta"), piDecand.recoEtaPi()); + mQaRegistry.fill(HIST("hDePhi"), piDecand.recoPhiDe()); + mQaRegistry.fill(HIST("hPiPhi"), piDecand.recoPhiPi()); + mQaRegistry.fill(HIST("hDePitInvMass"), piDecand.invMass); + mQaRegistry.fill(HIST("hdcaxyDe"), piDecand.dcaxyDe); + mQaRegistry.fill(HIST("hdcazDe"), piDecand.dcazDe); + mQaRegistry.fill(HIST("hdcazDe_min"), (abs(piDecand.dcazDe) - settingCutDeDCAzMin)); + mQaRegistry.fill(HIST("hNClsDeITS"), piDecand.nClsItsDe); + mQaRegistry.fill(HIST("hNClsPiITS"), piDecand.nClsItsPi); + mQaRegistry.fill(HIST("hisBkgEM"), piDecand.isBkgEM); + } + + double computePrTPCnsig(double InnerParamTPCHad, double SignalTPCHad) + { + double m_BBparamsProton[6] = {-54.42066571222577, 0.2857381250239097, 1.247140602468868, 0.6297483918147729, 2.985438833884555, 0.09}; + + float TPCinnerParam = InnerParamTPCHad; + float expTPCSignal = o2::tpc::BetheBlochAleph((TPCinnerParam / 0.9382721), m_BBparamsProton[0], m_BBparamsProton[1], m_BBparamsProton[2], m_BBparamsProton[3], m_BBparamsProton[4]); + double resoTPC{expTPCSignal * m_BBparamsProton[5]}; + return ((SignalTPCHad - expTPCSignal) / resoTPC); + } + + double tofNSigmaCalculation(double MassTOFHad, double ptHad) + { + double fExpTOFMassHad = 0.9487; // Proton mass in TOF + const float kp0 = 1.22204e-02; + const float kp1 = 7.48467e-01; + + double fSigmaTOFMassHad = (kp0 * TMath::Exp(kp1 * TMath::Abs(ptHad))) * fExpTOFMassHad; + double fNSigmaTOFHad = (MassTOFHad - fExpTOFMassHad) / fSigmaTOFMassHad; + return fNSigmaTOFHad; + } + + double computeKstar(const PiDecandidate& piDecand) + { + constexpr double massDe = o2::constants::physics::MassDeuteron; + constexpr double massHad = o2::constants::physics::MassPiPlus; + + const ROOT::Math::PtEtaPhiMVector De(std::abs(piDecand.recoPtDe()), piDecand.recoEtaDe(), piDecand.recoPhiDe(), massDe); + const ROOT::Math::PtEtaPhiMVector Had(std::abs(piDecand.recoPtPi()), piDecand.recoEtaPi(), piDecand.recoPhiPi(), massHad); + const ROOT::Math::PtEtaPhiMVector trackSum = De + Had; + + const float beta = trackSum.Beta(); + const float betax = beta * std::cos(trackSum.Phi()) * std::sin(trackSum.Theta()); + const float betay = beta * std::sin(trackSum.Phi()) * std::sin(trackSum.Theta()); + const float betaz = beta * std::cos(trackSum.Theta()); + + ROOT::Math::PxPyPzMVector DeCMS(De); + ROOT::Math::PxPyPzMVector HadCMS(Had); + + const ROOT::Math::Boost boostPRF = ROOT::Math::Boost(-betax, -betay, -betaz); + DeCMS = boostPRF(DeCMS); + HadCMS = boostPRF(HadCMS); + + const ROOT::Math::PxPyPzMVector RelKstar = DeCMS - HadCMS; + return 0.5 * RelKstar.P(); + } + + void fillKstar(const PiDecandidate& piDecand) + { + double PrTPCnsigma = computePrTPCnsig(piDecand.momPiTPC, piDecand.tpcSignalPi); + double PrTOFnsigma = tofNSigmaCalculation(piDecand.massTOFPi, piDecand.recoPtPi()); + if (abs(PrTPCnsigma) < settingCutNsigTPCPrMin) + return; + if (abs(PrTOFnsigma) < settingCutNsigTOFPrMin) + return; + float DeDCAxyMin = 0.015 + 0.0305 / TMath::Power(piDecand.recoPtDe(), 1.1); + if (abs(piDecand.dcaxyDe) > DeDCAxyMin || abs(piDecand.dcazDe) > settingCutDeDCAzMin || abs(piDecand.dcaxyPi) > settingCutPiDCAxyMin || abs(piDecand.dcazPi) > settingCutPiDCAzMin) + return; + fillHistograms(piDecand); + + double kstar = computeKstar(piDecand); + if (piDecand.isBkgUS == 0) { + if (piDecand.recoPtDe() > 0) { + mQaRegistry.fill(HIST("hkStar_LS_M"), kstar); + } else { + mQaRegistry.fill(HIST("hkStar_LS_A"), kstar); + } + } else { + if (piDecand.recoPtDe() > 0) { + mQaRegistry.fill(HIST("hkStar_US_M"), kstar); + } else { + mQaRegistry.fill(HIST("hkStar_US_A"), kstar); + } + } + mQaRegistry.fill(HIST("hkStar_All"), kstar); + } + + // ================================================================================================================== + + template + void fillPairs(const Tcollisions& collisions, const Ttracks& tracks, const bool isMixedEvent) + { + for (const auto& trackPair : mTrackPairs) { + + auto deTrack = tracks.rawIteratorAt(trackPair.tr0Idx); + auto piTrack = tracks.rawIteratorAt(trackPair.tr1Idx); + auto collBracket = trackPair.collBracket; + + PiDecandidate piDecand; + if (!fillCandidateInfo(deTrack, piTrack, collBracket, collisions, piDecand, tracks, isMixedEvent)) { + continue; + } + + fillKstar(piDecand); + + auto collision = collisions.rawIteratorAt(piDecand.collisionID); + + if (settingFillTable) { + fillTable(piDecand, collision); + } + } + } + + // ================================================================================================================== + + void processSameEvent(const CollisionsFull& collisions, const TrackCandidates& tracks, const aod::BCsWithTimestamps& bcs) + { + mGoodCollisions.clear(); + mGoodCollisions.resize(collisions.size(), false); + + for (const auto& collision : collisions) { + + mTrackPairs.clear(); + + if (!selectCollision(collision, bcs)) { + continue; + } + + mGoodCollisions[collision.globalIndex()] = true; + const uint64_t collIdx = collision.globalIndex(); + auto trackTableThisCollision = tracks.sliceBy(mPerCol, collIdx); + trackTableThisCollision.bindExternalIndices(&tracks); + + pairTracksSameEvent(trackTableThisCollision); + + if (mTrackPairs.size() == 0) { + continue; + } + + fillPairs(collisions, tracks, /*isMixedEvent*/ false); + } + } + PROCESS_SWITCH(PiDeuteronFemto, processSameEvent, "Process Same event", false); + + void processMixedEvent(const CollisionsFull& collisions, const TrackCandidates& tracks) + { + LOG(debug) << "Processing mixed event"; + mTrackPairs.clear(); + + for (const auto& [c1, tracks1, c2, tracks2] : mPair) { + if (!c1.sel8() || !c2.sel8()) { + continue; + } + + mQaRegistry.fill(HIST("hNcontributor"), c1.numContrib()); + mQaRegistry.fill(HIST("hVtxZ"), c1.posZ()); + + pairTracksEventMixing(tracks1, tracks2); + pairTracksEventMixing(tracks2, tracks1); + } + + fillPairs(collisions, tracks, /*isMixedEvent*/ true); + } + PROCESS_SWITCH(PiDeuteronFemto, processMixedEvent, "Process Mixed event", false); +}; + +WorkflowSpec defineDataProcessing(const ConfigContext& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Femto3D/Core/femto3dPairTask.h b/PWGCF/Femto3D/Core/femto3dPairTask.h index a3b74c36cd0..db5949f4ae0 100755 --- a/PWGCF/Femto3D/Core/femto3dPairTask.h +++ b/PWGCF/Femto3D/Core/femto3dPairTask.h @@ -16,8 +16,7 @@ #ifndef PWGCF_FEMTO3D_CORE_FEMTO3DPAIRTASK_H_ #define PWGCF_FEMTO3D_CORE_FEMTO3DPAIRTASK_H_ -#define THETA(eta) 2.0 * atan(exp(-eta)) - +#define THETA(eta) 2.0 * std::atan(std::exp(-eta)) // #include "Framework/ASoA.h" // #include "Framework/DataTypes.h" // #include "Framework/AnalysisDataModel.h" @@ -31,13 +30,28 @@ #include "TVector3.h" #include "TDatabasePDG.h" -double particle_mass(int PDGcode) +#include "CommonConstants/PhysicsConstants.h" +#include "CommonConstants/MathConstants.h" + +double particle_mass(const int PDGcode) { - // if(PDGcode == 2212) return TDatabasePDG::Instance()->GetParticle(2212)->Mass(); - if (PDGcode == 1000010020) - return 1.87561294257; - else - return TDatabasePDG::Instance()->GetParticle(PDGcode)->Mass(); + switch (std::abs(PDGcode)) { + case o2::constants::physics::kDeuteron: + return o2::constants::physics::MassDeuteron; + case o2::constants::physics::kTriton: + return o2::constants::physics::MassTriton; + case o2::constants::physics::kHelium3: + return o2::constants::physics::MassHelium3; + case 211: + return o2::constants::physics::MassPionCharged; + case 321: + return o2::constants::physics::MassKaonCharged; + case 2212: + return o2::constants::physics::MassProton; + default: + break; + } + return TDatabasePDG::Instance()->GetParticle(PDGcode)->Mass(); } // for the variable binning in 3D DCA histos in the PairMC task @@ -71,7 +85,7 @@ inline std::unique_ptr calc_var_bins(const int& N, const float& xmax, bins[N - 1] = xmax; for (int i = 1; i < 0.5 * N - 1; i++) { - bin_edge += winit * pow(q, i); + bin_edge += winit * std::pow(q, i); bins[0.5 * N - 1 - i] = -bin_edge; bins[0.5 * N + i] = bin_edge; } @@ -194,6 +208,7 @@ class FemtoPair bool IsIdentical() { return _isidentical; } bool IsClosePair(const float& deta, const float& dphi, const float& radius) const; + bool IsClosePair(const float& deta, const float& dphi) const; bool IsClosePair(const float& avgSep) const { return static_cast(GetAvgSep() < avgSep); } float GetAvgSep() const; @@ -207,11 +222,15 @@ class FemtoPair } float GetPhiStarDiff(const float& radius = 1.2) const { - if (_first != NULL && _second != NULL) - return _first->phiStar(_magfield1, radius) - _second->phiStar(_magfield2, radius); - else + if (_first != NULL && _second != NULL) { + float dphi = _first->phiStar(_magfield1, radius) - _second->phiStar(_magfield2, radius); + return std::fabs(dphi) > o2::constants::math::PI ? (1.0 - 2.0 * o2::constants::math::PI / std::fabs(dphi)) * dphi : dphi; + } else { return 1000; + } } + float GetAvgPhiStarDiff() const; + float GetKstar() const; TVector3 GetQLCMS() const; float GetKt() const; @@ -253,7 +272,9 @@ bool FemtoPair::IsClosePair(const float& deta, const float& dphi, con return true; if (_magfield1 * _magfield2 == 0) return true; - if (std::pow(std::fabs(GetEtaDiff()) / deta, 2) + std::pow(std::fabs(GetPhiStarDiff(radius)) / dphi, 2) < 1.0f) + const float relEtaDiff = GetEtaDiff() / deta; + const float relPhiStarDiff = GetPhiStarDiff(radius) / dphi; + if ((relEtaDiff * relEtaDiff + relPhiStarDiff * relPhiStarDiff) < 1.0f) return true; // if (std::fabs(GetEtaDiff()) < deta && std::fabs(GetPhiStarDiff(radius)) < dphi) // return true; @@ -261,6 +282,22 @@ bool FemtoPair::IsClosePair(const float& deta, const float& dphi, con return false; } +template +bool FemtoPair::IsClosePair(const float& deta, const float& dphi) const +{ + if (_first == NULL || _second == NULL) + return true; + if (_magfield1 * _magfield2 == 0) + return true; + const float relEtaDiff = GetEtaDiff() / deta; + const float relPhiStarDiff = GetAvgPhiStarDiff() / dphi; + if ((relEtaDiff * relEtaDiff + relPhiStarDiff * relPhiStarDiff) < 1.0f) + return true; + // if (std::fabs(GetEtaDiff()) < deta && std::fabs(GetPhiStarDiff(radius)) < dphi) + // return true; + + return false; +} template float FemtoPair::GetAvgSep() const { @@ -273,12 +310,31 @@ float FemtoPair::GetAvgSep() const float res = 0.0; for (const auto& radius : TPCradii) { - res += sqrt(pow(2.0 * radius * sin(0.5 * GetPhiStarDiff(radius)), 2) + pow(2.0 * radius * sin(0.5 * dtheta), 2)); + const float dRtrans = 2.0 * radius * std::sin(0.5 * GetPhiStarDiff(radius)); + const float dRlong = 2.0 * radius * std::sin(0.5 * dtheta); + res += std::sqrt(dRtrans * dRtrans + dRlong * dRlong); } return 100.0 * res / TPCradii.size(); } +template +float FemtoPair::GetAvgPhiStarDiff() const +{ + if (_first == NULL || _second == NULL) + return -100.f; + if (_magfield1 * _magfield2 == 0) + return -100.f; + + float res = 0.0; + + for (const auto& radius : TPCradii) { + res += GetPhiStarDiff(radius); + } + + return res / TPCradii.size(); +} + template float FemtoPair::GetKstar() const { @@ -324,8 +380,9 @@ float FemtoPair::GetKt() const return -1000; if (_PDG1 * _PDG2 == 0) return -1000; - - return 0.5 * std::sqrt(std::pow(_first->px() + _second->px(), 2) + std::pow(_first->py() + _second->py(), 2)); + const float px = _first->px() + _second->px(); + const float py = _first->py() + _second->py(); + return 0.5 * std::sqrt(px * px + py * py); } template diff --git a/PWGCF/Femto3D/DataModel/PIDutils.h b/PWGCF/Femto3D/DataModel/PIDutils.h new file mode 100644 index 00000000000..9e28f7b5863 --- /dev/null +++ b/PWGCF/Femto3D/DataModel/PIDutils.h @@ -0,0 +1,255 @@ +// 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. + +/// +/// \file PIDutils.h +/// \author Gleb Romanenko gleb.romanenko@cern.ch +/// \brief SFINAE checks for existance of PID info +/// \since 24/03/2025 +/// + +#ifndef PWGCF_FEMTO3D_DATAMODEL_PIDUTILS_H_ +#define PWGCF_FEMTO3D_DATAMODEL_PIDUTILS_H_ + +#include +#include +#include +#include "Common/DataModel/PIDResponse.h" + +namespace o2::aod::singletrackselector +{ +namespace pidutils +{ + +//========================================== SFINAE checks ========================================== + +template +struct hasTPCPi : std::false_type { +}; +template +struct hasTPCPi>> : std::true_type { +}; + +template +struct hasTPCKa : std::false_type { +}; +template +struct hasTPCKa>> : std::true_type { +}; + +template +struct hasTPCPr : std::false_type { +}; +template +struct hasTPCPr>> : std::true_type { +}; + +template +struct hasTPCDe : std::false_type { +}; +template +struct hasTPCDe>> : std::true_type { +}; + +template +struct hasTPCTr : std::false_type { +}; +template +struct hasTPCTr>> : std::true_type { +}; + +template +struct hasTPCHe : std::false_type { +}; +template +struct hasTPCHe>> : std::true_type { +}; + +template +struct hasTOFPi : std::false_type { +}; +template +struct hasTOFPi>> : std::true_type { +}; + +template +struct hasTOFKa : std::false_type { +}; +template +struct hasTOFKa>> : std::true_type { +}; + +template +struct hasTOFPr : std::false_type { +}; +template +struct hasTOFPr>> : std::true_type { +}; + +template +struct hasTOFDe : std::false_type { +}; +template +struct hasTOFDe>> : std::true_type { +}; + +template +struct hasTOFTr : std::false_type { +}; +template +struct hasTOFTr>> : std::true_type { +}; + +template +struct hasTOFHe : std::false_type { +}; +template +struct hasTOFHe>> : std::true_type { +}; + +} // namespace pidutils + +//========================================== ITS PID ========================================== + +template +inline float getITSNsigma(TrackType const& track, int const& PDG) +{ + switch (PDG) { + case 211: + return track.itsNSigmaPi(); + case 321: + return track.itsNSigmaKa(); + case 2212: + return track.itsNSigmaPr(); + case 1000010020: + return track.itsNSigmaDe(); + case 1000020030: + return track.itsNSigmaHe(); + case 1000010030: + return track.itsNSigmaTr(); + case 0: + return -1000.0; + default: + LOG(fatal) << "Cannot interpret PDG for ITS selection: " << PDG; + return -1000.0; + } +} + +template +inline bool ITSselection(TrackType const& track, std::pair> const& PIDcuts) +{ + float Nsigma = getITSNsigma(track, PIDcuts.first); + + if (Nsigma > PIDcuts.second[0] && Nsigma < PIDcuts.second[1]) { + return true; + } + return false; +} + +//========================================== TPC PID ========================================== + +template +inline float getTPCNsigma(TrackType const& track, int const& PDG) +{ + switch (PDG) { + case 211: + if constexpr (o2::aod::singletrackselector::pidutils::hasTPCPi::value) + return track.tpcNSigmaPi(); + case 321: + if constexpr (o2::aod::singletrackselector::pidutils::hasTPCKa::value) + return track.tpcNSigmaKa(); + case 2212: + if constexpr (o2::aod::singletrackselector::pidutils::hasTPCPr::value) + return track.tpcNSigmaPr(); + case 1000010020: + if constexpr (o2::aod::singletrackselector::pidutils::hasTPCDe::value) + return track.tpcNSigmaDe(); + case 1000020030: + if constexpr (o2::aod::singletrackselector::pidutils::hasTPCHe::value) + return track.tpcNSigmaHe(); + case 1000010030: + if constexpr (o2::aod::singletrackselector::pidutils::hasTPCTr::value) + return track.tpcNSigmaTr(); + case 0: + return -1000.0; + default: + LOG(fatal) << "Cannot interpret PDG for TPC selection: " << PDG; + return -1000.0; + } +} + +template +inline bool TPCselection(TrackType const& track, std::pair> const& PIDcuts, std::vector const& ITSCut = std::vector{}) +{ + int PDG = PIDcuts.first; + + if constexpr (useITS) { + if (ITSCut.size() != 0 && !ITSselection(track, std::make_pair(PDG, ITSCut))) + return false; + } + + float Nsigma = getTPCNsigma(track, PDG); + + if (Nsigma > PIDcuts.second[0] && Nsigma < PIDcuts.second[1]) { + return true; + } + return false; +} + +//========================================== TOF PID ========================================== + +template +inline float getTOFNsigma(TrackType const& track, int const& PDG) +{ + switch (PDG) { + case 211: + if constexpr (o2::aod::singletrackselector::pidutils::hasTOFPi::value) + return track.tofNSigmaPi(); + case 321: + if constexpr (o2::aod::singletrackselector::pidutils::hasTOFKa::value) + return track.tofNSigmaKa(); + case 2212: + if constexpr (o2::aod::singletrackselector::pidutils::hasTOFPr::value) + return track.tofNSigmaPr(); + case 1000010020: + if constexpr (o2::aod::singletrackselector::pidutils::hasTOFDe::value) + return track.tofNSigmaDe(); + case 1000020030: + if constexpr (o2::aod::singletrackselector::pidutils::hasTOFHe::value) + return track.tofNSigmaHe(); + case 1000010030: + if constexpr (o2::aod::singletrackselector::pidutils::hasTOFTr::value) + return track.tofNSigmaTr(); + case 0: + return -1000.0; + default: + LOG(fatal) << "Cannot interpret PDG for TOF selection: " << PDG; + return -1000.0; + } +} + +template +inline bool TOFselection(TrackType const& track, std::pair> const& PIDcuts, std::vector const& TPCresidualCut = std::vector{-5.0f, 5.0f}) +{ + int PDG = PIDcuts.first; + if (!TPCselection(track, std::make_pair(PDG, TPCresidualCut))) + return false; + + float Nsigma = getTOFNsigma(track, PDG); + + if (Nsigma > PIDcuts.second[0] && Nsigma < PIDcuts.second[1]) { + return true; + } + return false; +} +} // namespace o2::aod::singletrackselector + +#endif // PWGCF_FEMTO3D_DATAMODEL_PIDUTILS_H_ diff --git a/PWGCF/Femto3D/DataModel/singletrackselector.h b/PWGCF/Femto3D/DataModel/singletrackselector.h index a49293f1b7a..c7323d15a32 100644 --- a/PWGCF/Femto3D/DataModel/singletrackselector.h +++ b/PWGCF/Femto3D/DataModel/singletrackselector.h @@ -16,15 +16,17 @@ #ifndef PWGCF_FEMTO3D_DATAMODEL_SINGLETRACKSELECTOR_H_ #define PWGCF_FEMTO3D_DATAMODEL_SINGLETRACKSELECTOR_H_ -#include +// #include #include #include #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" #include "Framework/Logger.h" #include "Common/DataModel/Multiplicity.h" +#include "PWGCF/Femto3D/DataModel/PIDutils.h" namespace o2::aod { @@ -105,12 +107,12 @@ struct binningParent { } }; -using nsigma_v0 = binningParent(-10.f, 10.f)>; +// using nsigma_v0 = binningParent(-10.f, 10.f)>; using nsigma_v1 = binningParent(-6.35f, 6.35f)>; // Width 0.05 symmetric around 0 using nsigma = nsigma_v1; -using dca_v0 = binningParent(-1.f, 1.f)>; -using dca_v1 = binningParent(-1.f, 1.f), int16_t>; +// using dca_v0 = binningParent(-1.f, 1.f)>; +// using dca_v1 = binningParent(-1.f, 1.f), int16_t>; using dca_v2 = binningParent(-3.2767f, 3.2767f), int16_t>; // Width 0.0001 symmetric around 0 using dca = dca_v2; @@ -119,17 +121,15 @@ using rowsOverFindable = binningParent(0.f, 3.f)>; } // namespace binning +//==================================== base event characteristics ==================================== DECLARE_SOA_COLUMN(Mult, mult, int); // Multiplicity of the collision DECLARE_SOA_COLUMN(MultPercentile, multPerc, float); // Percentiles of multiplicity of the collision DECLARE_SOA_COLUMN(PosZ, posZ, float); // Vertex of the collision DECLARE_SOA_COLUMN(MagField, magField, float); // Magnetic field corresponding to a collision (in T) -DECLARE_SOA_COLUMN(IsNoSameBunchPileup, isNoSameBunchPileup, bool); -DECLARE_SOA_COLUMN(IsGoodZvtxFT0vsPV, isGoodZvtxFT0vsPV, bool); -DECLARE_SOA_COLUMN(IsVertexITSTPC, isVertexITSTPC, bool); +//==================================== extra event characteristics ==================================== DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, double); DECLARE_SOA_COLUMN(Occupancy, occupancy, int); - DECLARE_SOA_DYNAMIC_COLUMN(dIsNoSameBunchPileup, isNoSameBunchPileup, [](uint64_t selBit) -> bool { return TESTBIT(selBit, evsel::kNoSameBunchPileup); }); DECLARE_SOA_DYNAMIC_COLUMN(dIsGoodZvtxFT0vsPV, isGoodZvtxFT0vsPV, [](uint64_t selBit) -> bool { return TESTBIT(selBit, evsel::kIsGoodZvtxFT0vsPV); }); DECLARE_SOA_DYNAMIC_COLUMN(dIsVertexITSTPC, isVertexITSTPC, [](uint64_t selBit) -> bool { return TESTBIT(selBit, evsel::kIsVertexITSTPC); }); @@ -145,12 +145,6 @@ DECLARE_SOA_TABLE(SingleCollSels, "AOD", "SINGLECOLLSEL", // Table of the variab singletrackselector::PosZ, singletrackselector::MagField); -DECLARE_SOA_TABLE(SingleCollExtras_v0, "AOD", "SINGLECOLLEXTRA", // Joinable collision table with Pile-Up flags - singletrackselector::IsNoSameBunchPileup, - singletrackselector::IsGoodZvtxFT0vsPV, - singletrackselector::IsVertexITSTPC, - singletrackselector::HadronicRate); - DECLARE_SOA_TABLE(SingleCollExtras_v1, "AOD", "SINGLECOLLEXTR1", // Joinable collision table with Pile-Up flags evsel::Selection, singletrackselector::HadronicRate, @@ -166,14 +160,20 @@ using SingleCollExtras = SingleCollExtras_v1; namespace singletrackselector { +//==================================== track characteristics ==================================== + DECLARE_SOA_INDEX_COLUMN(SingleCollSel, singleCollSel); // Index to the collision DECLARE_SOA_COLUMN(P, p, float); // Momentum of the track DECLARE_SOA_COLUMN(Eta, eta, float); DECLARE_SOA_COLUMN(Phi, phi, float); DECLARE_SOA_COLUMN(Sign, sign, int8_t); -DECLARE_SOA_COLUMN(TPCNClsFound, tpcNClsFound, int16_t); // Number of TPC clusters -DECLARE_SOA_COLUMN(TPCNClsShared, tpcNClsShared, uint8_t); // Number of shared TPC clusters -DECLARE_SOA_COLUMN(ITSNCls, itsNCls, uint8_t); // Number of ITS clusters (only stored in v0) +DECLARE_SOA_COLUMN(TPCNClsFound, tpcNClsFound, int16_t); // Number of TPC clusters +DECLARE_SOA_COLUMN(TPCNClsShared, tpcNClsShared, uint8_t); // Number of shared TPC clusters +DECLARE_SOA_DYNAMIC_COLUMN(TPCFractionSharedCls, tpcFractionSharedCls, //! Fraction of shared TPC clusters + [](uint8_t tpcNClsShared, int16_t tpcNClsFound) -> float { return (float)tpcNClsShared / (float)tpcNClsFound; }); + +DECLARE_SOA_COLUMN(ITSclsMap, itsClsMap, uint8_t); +DECLARE_SOA_COLUMN(ITSclusterSizes, itsClusterSizes, uint32_t); DECLARE_SOA_DYNAMIC_COLUMN(ITSNClsDyn, itsNCls, [](uint32_t itsClusterSizes) -> uint8_t { uint8_t itsNcls = 0; for (int layer = 0; layer < 7; layer++) { @@ -182,62 +182,121 @@ DECLARE_SOA_DYNAMIC_COLUMN(ITSNClsDyn, itsNCls, [](uint32_t itsClusterSizes) -> } return itsNcls; }); -DECLARE_SOA_COLUMN(ITSclsMap, itsClsMap, uint8_t); -DECLARE_SOA_COLUMN(ITSclusterSizes, itsClusterSizes, uint32_t); -DECLARE_SOA_COLUMN(StoredDcaXY, storedDcaXY, binning::dca_v0::binned_t); // impact parameter of the track with 8 bits (v0) -DECLARE_SOA_COLUMN(StoredDcaZ, storedDcaZ, binning::dca_v0::binned_t); // impact parameter of the track with 8 bits (v0) -DECLARE_SOA_COLUMN(StoredDcaXY_v1, storedDcaXY_v1, binning::dca_v1::binned_t); // impact parameter of the track with 16 bits (v1) -DECLARE_SOA_COLUMN(StoredDcaZ_v1, storedDcaZ_v1, binning::dca_v1::binned_t); // impact parameter of the track with 16 bits (v1) -DECLARE_SOA_COLUMN(StoredDcaXY_v2, storedDcaXY_v2, binning::dca_v2::binned_t); // impact parameter of the track with 16 bits (v2, larger range) -DECLARE_SOA_COLUMN(StoredDcaZ_v2, storedDcaZ_v2, binning::dca_v2::binned_t); // impact parameter of the track with 16 bits (v2, larger range) -DECLARE_SOA_COLUMN(StoredTPCChi2NCl, storedTpcChi2NCl, binning::chi2::binned_t); // TPC chi2 -DECLARE_SOA_COLUMN(StoredITSChi2NCl, storedItsChi2NCl, binning::chi2::binned_t); // ITS chi2 +DECLARE_SOA_COLUMN(StoredTPCChi2NCl, storedTpcChi2NCl, binning::chi2::binned_t); // TPC chi2 +DECLARE_SOA_DYNAMIC_COLUMN(TPCChi2NCl, tpcChi2NCl, + [](binning::chi2::binned_t chi2_binned) -> float { return singletrackselector::unPack(chi2_binned); }); + +DECLARE_SOA_COLUMN(StoredITSChi2NCl, storedItsChi2NCl, binning::chi2::binned_t); // ITS chi2 +DECLARE_SOA_DYNAMIC_COLUMN(ITSChi2NCl, itsChi2NCl, + [](binning::chi2::binned_t chi2_binned) -> float { return singletrackselector::unPack(chi2_binned); }); + DECLARE_SOA_COLUMN(StoredTPCCrossedRowsOverFindableCls, storedTpcCrossedRowsOverFindableCls, binning::rowsOverFindable::binned_t); // Ratio of found over findable clusters +DECLARE_SOA_DYNAMIC_COLUMN(TPCCrossedRowsOverFindableCls, tpcCrossedRowsOverFindableCls, + [](binning::rowsOverFindable::binned_t rowsOverFindable_binned) -> float { return singletrackselector::unPack(rowsOverFindable_binned); }); + +//==================================== DCA ==================================== + +DECLARE_SOA_COLUMN(StoredDcaXY, storedDcaXY, binning::dca::binned_t); // impact parameter of the track with 16 bits (v2, larger range) +DECLARE_SOA_DYNAMIC_COLUMN(DcaXY, dcaXY, + [](binning::dca::binned_t dca_binned) -> float { return singletrackselector::unPackSymmetric(dca_binned); }); + +DECLARE_SOA_COLUMN(StoredDcaZ, storedDcaZ, binning::dca::binned_t); // impact parameter of the track with 16 bits (v2, larger range) +DECLARE_SOA_DYNAMIC_COLUMN(DcaZ, dcaZ, + [](binning::dca::binned_t dca_binned) -> float { return singletrackselector::unPackSymmetric(dca_binned); }); + +using StoredDcaXY_v2 = StoredDcaXY; // compatibility with the old tables of version 2 -- to be removed later +using StoredDcaZ_v2 = StoredDcaZ; // compatibility with the old tables of version 2 -- to be removed later +//==================================== PID ==================================== + +//------------------------------------ Electrons ------------------------------------ + +DECLARE_SOA_COLUMN(StoredTOFNSigmaEl, storedTofNSigmaEl, binning::nsigma::binned_t); // (v1) TOF +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaEl, tofNSigmaEl, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +DECLARE_SOA_COLUMN(StoredTPCNSigmaEl, storedTpcNSigmaEl, binning::nsigma::binned_t); // (v1) TPC +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaEl, tpcNSigmaEl, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +//------------------------------------ Pions ------------------------------------ +DECLARE_SOA_COLUMN(StoredTOFNSigmaPi, storedTofNSigmaPi, binning::nsigma::binned_t); // (v1) TOF +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPi, tofNSigmaPi, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +DECLARE_SOA_COLUMN(StoredTPCNSigmaPi, storedTpcNSigmaPi, binning::nsigma::binned_t); // (v1) TPC +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPi, tpcNSigmaPi, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +//------------------------------------ Kaons ------------------------------------ +DECLARE_SOA_COLUMN(StoredTOFNSigmaKa, storedTofNSigmaKa, binning::nsigma::binned_t); // (v1) TOF +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaKa, tofNSigmaKa, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +DECLARE_SOA_COLUMN(StoredTPCNSigmaKa, storedTpcNSigmaKa, binning::nsigma::binned_t); // (v1) TPC +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaKa, tpcNSigmaKa, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +//------------------------------------ Protons ------------------------------------ +DECLARE_SOA_COLUMN(StoredTOFNSigmaPr, storedTofNSigmaPr, binning::nsigma::binned_t); // (v1) TOF +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPr, tofNSigmaPr, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +DECLARE_SOA_COLUMN(StoredTPCNSigmaPr, storedTpcNSigmaPr, binning::nsigma::binned_t); // (v1) TPC +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPr, tpcNSigmaPr, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +//------------------------------------ Deutrons ------------------------------------ +DECLARE_SOA_COLUMN(StoredTOFNSigmaDe, storedTofNSigmaDe, binning::nsigma::binned_t); // (v1) TOF +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaDe, tofNSigmaDe, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +DECLARE_SOA_COLUMN(StoredTPCNSigmaDe, storedTpcNSigmaDe, binning::nsigma::binned_t); // (v1) TPC +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaDe, tpcNSigmaDe, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +//------------------------------------ Triton ------------------------------------ +DECLARE_SOA_COLUMN(StoredTOFNSigmaTr, storedTofNSigmaTr, binning::nsigma::binned_t); // (v1) TOF +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaTr, tofNSigmaTr, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +DECLARE_SOA_COLUMN(StoredTPCNSigmaTr, storedTpcNSigmaTr, binning::nsigma::binned_t); // (v1) TPC +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaTr, tpcNSigmaTr, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +//------------------------------------ Helium3 ------------------------------------ +DECLARE_SOA_COLUMN(StoredTOFNSigmaHe, storedTofNSigmaHe, binning::nsigma::binned_t); // (v1) TOF +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaHe, tofNSigmaHe, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +DECLARE_SOA_COLUMN(StoredTPCNSigmaHe, storedTpcNSigmaHe, binning::nsigma::binned_t); // (v1) TPC +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaHe, tpcNSigmaHe, + [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); + +using StoredTOFNSigmaPi_v1 = StoredTOFNSigmaPi; // compatibility with the old tables of version 2 -- to be removed later +using StoredTPCNSigmaPi_v1 = StoredTPCNSigmaPi; // compatibility with the old tables of version 2 -- to be removed later + +using StoredTOFNSigmaKa_v1 = StoredTOFNSigmaKa; // compatibility with the old tables of version 2 -- to be removed later +using StoredTPCNSigmaKa_v1 = StoredTPCNSigmaKa; // compatibility with the old tables of version 2 -- to be removed later -DECLARE_SOA_COLUMN(StoredTOFNSigmaPi, storedTofNSigmaPi, binning::nsigma::binned_t); // (v0) -DECLARE_SOA_COLUMN(StoredTPCNSigmaPi, storedTpcNSigmaPi, binning::nsigma::binned_t); // (v0) -DECLARE_SOA_COLUMN(StoredTOFNSigmaKa, storedTofNSigmaKa, binning::nsigma::binned_t); // (v0) -DECLARE_SOA_COLUMN(StoredTPCNSigmaKa, storedTpcNSigmaKa, binning::nsigma::binned_t); // (v0) -DECLARE_SOA_COLUMN(StoredTOFNSigmaPr, storedTofNSigmaPr, binning::nsigma::binned_t); // (v0) -DECLARE_SOA_COLUMN(StoredTPCNSigmaPr, storedTpcNSigmaPr, binning::nsigma::binned_t); // (v0) -DECLARE_SOA_COLUMN(StoredTOFNSigmaDe, storedTofNSigmaDe, binning::nsigma::binned_t); // (v0) -DECLARE_SOA_COLUMN(StoredTPCNSigmaDe, storedTpcNSigmaDe, binning::nsigma::binned_t); // (v0) -DECLARE_SOA_COLUMN(StoredTOFNSigmaHe, storedTofNSigmaHe, binning::nsigma::binned_t); // (v0) -DECLARE_SOA_COLUMN(StoredTPCNSigmaHe, storedTpcNSigmaHe, binning::nsigma::binned_t); // (v0) - -DECLARE_SOA_COLUMN(StoredTOFNSigmaPi_v1, storedTofNSigmaPi_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_COLUMN(StoredTPCNSigmaPi_v1, storedTpcNSigmaPi_v1, binning::nsigma::binned_t); // (v1) - -DECLARE_SOA_COLUMN(StoredTOFNSigmaKa_v1, storedTofNSigmaKa_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_COLUMN(StoredTPCNSigmaKa_v1, storedTpcNSigmaKa_v1, binning::nsigma::binned_t); // (v1) - -DECLARE_SOA_COLUMN(StoredTOFNSigmaPr_v1, storedTofNSigmaPr_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_COLUMN(StoredTPCNSigmaPr_v1, storedTpcNSigmaPr_v1, binning::nsigma::binned_t); // (v1) - -DECLARE_SOA_COLUMN(StoredTOFNSigmaDe_v1, storedTofNSigmaDe_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_COLUMN(StoredTPCNSigmaDe_v1, storedTpcNSigmaDe_v1, binning::nsigma::binned_t); // (v1) - -DECLARE_SOA_COLUMN(StoredTOFNSigmaHe_v1, storedTofNSigmaHe_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_COLUMN(StoredTPCNSigmaHe_v1, storedTpcNSigmaHe_v1, binning::nsigma::binned_t); // (v1) - -DECLARE_SOA_COLUMN(StoredITSNSigmaPi_v1, storedItsNSigmaPi_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaPi_v1, itsNSigmaPi, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_COLUMN(StoredITSNSigmaKa_v1, storedItsNSigmaKa_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaKa_v1, itsNSigmaKa, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_COLUMN(StoredITSNSigmaPr_v1, storedItsNSigmaPr_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaPr_v1, itsNSigmaPr, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_COLUMN(StoredITSNSigmaDe_v1, storedItsNSigmaDe_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaDe_v1, itsNSigmaDe, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_COLUMN(StoredITSNSigmaHe_v1, storedItsNSigmaHe_v1, binning::nsigma::binned_t); // (v1) -DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaHe_v1, itsNSigmaHe, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); +using StoredTOFNSigmaPr_v1 = StoredTOFNSigmaPr; // compatibility with the old tables of version 2 -- to be removed later +using StoredTPCNSigmaPr_v1 = StoredTPCNSigmaPr; // compatibility with the old tables of version 2 -- to be removed later + +using StoredTOFNSigmaDe_v1 = StoredTOFNSigmaDe; // compatibility with the old tables of version 2 -- to be removed later +using StoredTPCNSigmaDe_v1 = StoredTPCNSigmaDe; // compatibility with the old tables of version 2 -- to be removed later + +using StoredTOFNSigmaHe_v1 = StoredTOFNSigmaHe; // compatibility with the old tables of version 2 -- to be removed later +using StoredTPCNSigmaHe_v1 = StoredTPCNSigmaHe; // compatibility with the old tables of version 2 -- to be removed later + +//==================================== Dynamic cols for kinematics ==================================== DECLARE_SOA_DYNAMIC_COLUMN(Energy, energy, [](float p, float mass) -> float { return sqrt(p * p + mass * mass); }); +DECLARE_SOA_DYNAMIC_COLUMN(Rapidity, rapidity, //! Track rapidity, computed under the mass assumption given as input + [](float p, float eta, float mass) -> float { + const auto pz = p * std::tanh(eta); + const auto energy = std::sqrt(p * p + mass * mass); + return 0.5f * log((energy + pz) / (energy - pz)); + }); DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float p, float eta) -> float { return p / std::cosh(eta); }); DECLARE_SOA_DYNAMIC_COLUMN(Px, px, [](float p, float eta, float phi) -> float { return (p / std::cosh(eta)) * std::sin(phi); }); DECLARE_SOA_DYNAMIC_COLUMN(Py, py, [](float p, float eta, float phi) -> float { return (p / std::cosh(eta)) * std::cos(phi); }); @@ -251,91 +310,15 @@ DECLARE_SOA_DYNAMIC_COLUMN(PhiStar, phiStar, } }); -DECLARE_SOA_DYNAMIC_COLUMN(DcaXY_v0, dcaXY, - [](binning::dca_v0::binned_t dca_binned) -> float { return singletrackselector::unPack(dca_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(DcaZ_v0, dcaZ, - [](binning::dca_v0::binned_t dca_binned) -> float { return singletrackselector::unPack(dca_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(DcaXY_v1, dcaXY, - [](binning::dca_v1::binned_t dca_binned) -> float { return singletrackselector::unPack(dca_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(DcaZ_v1, dcaZ, - [](binning::dca_v1::binned_t dca_binned) -> float { return singletrackselector::unPack(dca_binned); }); - -DECLARE_SOA_DYNAMIC_COLUMN(DcaXY_v2, dcaXY, - [](binning::dca_v2::binned_t dca_binned) -> float { return singletrackselector::unPackSymmetric(dca_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(DcaZ_v2, dcaZ, - [](binning::dca_v2::binned_t dca_binned) -> float { return singletrackselector::unPackSymmetric(dca_binned); }); - -DECLARE_SOA_DYNAMIC_COLUMN(TPCChi2NCl, tpcChi2NCl, - [](binning::chi2::binned_t chi2_binned) -> float { return singletrackselector::unPack(chi2_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(ITSChi2NCl, itsChi2NCl, - [](binning::chi2::binned_t chi2_binned) -> float { return singletrackselector::unPack(chi2_binned); }); - -DECLARE_SOA_DYNAMIC_COLUMN(TPCCrossedRowsOverFindableCls, tpcCrossedRowsOverFindableCls, - [](binning::rowsOverFindable::binned_t rowsOverFindable_binned) -> float { return singletrackselector::unPack(rowsOverFindable_binned); }); - -DECLARE_SOA_DYNAMIC_COLUMN(TPCFractionSharedCls, tpcFractionSharedCls, //! Fraction of shared TPC clusters - [](uint8_t tpcNClsShared, int16_t tpcNClsFound) -> float { return (float)tpcNClsShared / (float)tpcNClsFound; }); - -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPi_v0, tofNSigmaPi, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPi_v0, tpcNSigmaPi, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaKa_v0, tofNSigmaKa, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaKa_v0, tpcNSigmaKa, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPr_v0, tofNSigmaPr, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPr_v0, tpcNSigmaPr, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaDe_v0, tofNSigmaDe, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaDe_v0, tpcNSigmaDe, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaHe_v0, tofNSigmaHe, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaHe_v0, tpcNSigmaHe, - [](binning::nsigma_v0::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); - -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPi_v1, tofNSigmaPi, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPi_v1, tpcNSigmaPi, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaKa_v1, tofNSigmaKa, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaKa_v1, tpcNSigmaKa, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPr_v1, tofNSigmaPr, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPr_v1, tpcNSigmaPr, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaDe_v1, tofNSigmaDe, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaDe_v1, tpcNSigmaDe, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaHe_v1, tofNSigmaHe, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaHe_v1, tpcNSigmaHe, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); +//==================================== EXtra info ==================================== DECLARE_SOA_COLUMN(TPCInnerParam, tpcInnerParam, float); // Momentum at inner wall of the TPC DECLARE_SOA_COLUMN(TPCSignal, tpcSignal, float); // dE/dx TPC DECLARE_SOA_COLUMN(Beta, beta, float); // TOF beta -DECLARE_SOA_COLUMN(StoredTPCNSigmaEl, storedTpcNSigmaEl, binning::nsigma::binned_t); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaEl, tpcNSigmaEl, - [](binning::nsigma_v1::binned_t nsigma_binned) -> float { return singletrackselector::unPackSymmetric(nsigma_binned); }); - -DECLARE_SOA_DYNAMIC_COLUMN(Rapidity, rapidity, //! Track rapidity, computed under the mass assumption given as input - [](float p, float eta, float mass) -> float { - const auto pz = p * std::tanh(eta); - const auto energy = std::sqrt(p * p + mass * mass); - return 0.5f * log((energy + pz) / (energy - pz)); - }); - } // namespace singletrackselector -DECLARE_SOA_TABLE(SingleTrackSels_v0, "AOD", "SINGLETRACKSEL", // Table of the variables for single track selection. +DECLARE_SOA_TABLE(SingleTrackSels_v3, "AOD", "SINGLETRACKSEL", // Table of the variables for single track selection. o2::soa::Index<>, singletrackselector::SingleCollSelId, singletrackselector::P, @@ -344,101 +327,39 @@ DECLARE_SOA_TABLE(SingleTrackSels_v0, "AOD", "SINGLETRACKSEL", // Table of the v singletrackselector::Sign, singletrackselector::TPCNClsFound, singletrackselector::TPCNClsShared, - singletrackselector::ITSNCls, + singletrackselector::ITSclsMap, + singletrackselector::ITSclusterSizes, singletrackselector::StoredDcaXY, singletrackselector::StoredDcaZ, singletrackselector::StoredTPCChi2NCl, singletrackselector::StoredITSChi2NCl, singletrackselector::StoredTPCCrossedRowsOverFindableCls, - singletrackselector::StoredTOFNSigmaPi, - singletrackselector::StoredTPCNSigmaPi, - singletrackselector::StoredTOFNSigmaKa, - singletrackselector::StoredTPCNSigmaKa, - singletrackselector::StoredTOFNSigmaPr, - singletrackselector::StoredTPCNSigmaPr, - singletrackselector::StoredTOFNSigmaDe, - singletrackselector::StoredTPCNSigmaDe, - - singletrackselector::DcaXY_v0, - singletrackselector::DcaZ_v0, + singletrackselector::ITSNClsDyn, + track::v001::ITSClsSizeInLayer, + singletrackselector::DcaXY, + singletrackselector::DcaZ, singletrackselector::TPCChi2NCl, singletrackselector::ITSChi2NCl, singletrackselector::TPCCrossedRowsOverFindableCls, singletrackselector::TPCFractionSharedCls, - singletrackselector::TOFNSigmaPi_v0, - singletrackselector::TPCNSigmaPi_v0, - singletrackselector::TOFNSigmaKa_v0, - singletrackselector::TPCNSigmaKa_v0, - singletrackselector::TOFNSigmaPr_v0, - singletrackselector::TPCNSigmaPr_v0, - singletrackselector::TOFNSigmaDe_v0, - singletrackselector::TPCNSigmaDe_v0, - - singletrackselector::Rapidity, singletrackselector::Energy, + singletrackselector::Rapidity, singletrackselector::Pt, singletrackselector::Px, singletrackselector::Py, singletrackselector::Pz, - singletrackselector::PhiStar); - -DECLARE_SOA_TABLE_VERSIONED(SingleTrackSels_v1, "AOD", "SINGLETRACKSEL1", 1, // Table of the variables for single track selection. - o2::soa::Index<>, - singletrackselector::SingleCollSelId, - singletrackselector::P, - singletrackselector::Eta, - singletrackselector::Phi, - singletrackselector::Sign, - singletrackselector::TPCNClsFound, - singletrackselector::TPCNClsShared, - singletrackselector::ITSclsMap, - singletrackselector::ITSclusterSizes, - singletrackselector::StoredDcaXY_v1, - singletrackselector::StoredDcaZ_v1, - singletrackselector::StoredTPCChi2NCl, - singletrackselector::StoredITSChi2NCl, - singletrackselector::StoredTPCCrossedRowsOverFindableCls, - - singletrackselector::StoredTOFNSigmaPi, - singletrackselector::StoredTPCNSigmaPi, - singletrackselector::StoredTOFNSigmaKa, - singletrackselector::StoredTPCNSigmaKa, - singletrackselector::StoredTOFNSigmaPr, - singletrackselector::StoredTPCNSigmaPr, - singletrackselector::StoredTOFNSigmaDe, - singletrackselector::StoredTPCNSigmaDe, - singletrackselector::StoredTOFNSigmaHe, - singletrackselector::StoredTPCNSigmaHe, - - singletrackselector::ITSNClsDyn, - track::v001::ITSClsSizeInLayer, - singletrackselector::DcaXY_v1, - singletrackselector::DcaZ_v1, - singletrackselector::TPCChi2NCl, - singletrackselector::ITSChi2NCl, - singletrackselector::TPCCrossedRowsOverFindableCls, - singletrackselector::TPCFractionSharedCls, + singletrackselector::PhiStar, - singletrackselector::TOFNSigmaPi_v0, - singletrackselector::TPCNSigmaPi_v0, - singletrackselector::TOFNSigmaKa_v0, - singletrackselector::TPCNSigmaKa_v0, - singletrackselector::TOFNSigmaPr_v0, - singletrackselector::TPCNSigmaPr_v0, - singletrackselector::TOFNSigmaDe_v0, - singletrackselector::TPCNSigmaDe_v0, - singletrackselector::TOFNSigmaHe_v0, - singletrackselector::TPCNSigmaHe_v0, - - singletrackselector::Rapidity, - singletrackselector::Energy, - singletrackselector::Pt, - singletrackselector::Px, - singletrackselector::Py, - singletrackselector::Pz, - singletrackselector::PhiStar); + // PID with ITS (from PIDResponseITS.h) + o2::aod::pidits::ITSNSigmaElImp, + o2::aod::pidits::ITSNSigmaPiImp, + o2::aod::pidits::ITSNSigmaKaImp, + o2::aod::pidits::ITSNSigmaPrImp, + o2::aod::pidits::ITSNSigmaDeImp, + o2::aod::pidits::ITSNSigmaTrImp, + o2::aod::pidits::ITSNSigmaHeImp); DECLARE_SOA_TABLE_VERSIONED(SingleTrackSels_v2, "AOD", "SINGLETRACKSEL2", 2, // Table of the variables for single track selection. o2::soa::Index<>, @@ -470,23 +391,23 @@ DECLARE_SOA_TABLE_VERSIONED(SingleTrackSels_v2, "AOD", "SINGLETRACKSEL2", 2, // singletrackselector::ITSNClsDyn, track::v001::ITSClsSizeInLayer, - singletrackselector::DcaXY_v2, - singletrackselector::DcaZ_v2, + singletrackselector::DcaXY, + singletrackselector::DcaZ, singletrackselector::TPCChi2NCl, singletrackselector::ITSChi2NCl, singletrackselector::TPCCrossedRowsOverFindableCls, singletrackselector::TPCFractionSharedCls, - singletrackselector::TOFNSigmaPi_v1, - singletrackselector::TPCNSigmaPi_v1, - singletrackselector::TOFNSigmaKa_v1, - singletrackselector::TPCNSigmaKa_v1, - singletrackselector::TOFNSigmaPr_v1, - singletrackselector::TPCNSigmaPr_v1, - singletrackselector::TOFNSigmaDe_v1, - singletrackselector::TPCNSigmaDe_v1, - singletrackselector::TOFNSigmaHe_v1, - singletrackselector::TPCNSigmaHe_v1, + singletrackselector::TOFNSigmaPi, + singletrackselector::TPCNSigmaPi, + singletrackselector::TOFNSigmaKa, + singletrackselector::TPCNSigmaKa, + singletrackselector::TOFNSigmaPr, + singletrackselector::TPCNSigmaPr, + singletrackselector::TOFNSigmaDe, + singletrackselector::TPCNSigmaDe, + singletrackselector::TOFNSigmaHe, + singletrackselector::TPCNSigmaHe, singletrackselector::Rapidity, singletrackselector::Energy, @@ -496,28 +417,65 @@ DECLARE_SOA_TABLE_VERSIONED(SingleTrackSels_v2, "AOD", "SINGLETRACKSEL2", 2, // singletrackselector::Pz, singletrackselector::PhiStar); -using SingleTrackSels = SingleTrackSels_v2; +using SingleTrackSels = SingleTrackSels_v3; -DECLARE_SOA_TABLE(SingleTrkExtras, "AOD", "SINGLETRKEXTRA", - singletrackselector::TPCInnerParam, - singletrackselector::TPCSignal, - singletrackselector::Beta); +DECLARE_SOA_TABLE(SinglePIDEls_v0, "AOD", "SINGLEPIDEL0", + singletrackselector::StoredTPCNSigmaEl, + singletrackselector::TPCNSigmaEl); DECLARE_SOA_TABLE(SinglePIDEls, "AOD", "SINGLEPIDEL", + singletrackselector::StoredTOFNSigmaEl, singletrackselector::StoredTPCNSigmaEl, + + singletrackselector::TOFNSigmaEl, singletrackselector::TPCNSigmaEl); -DECLARE_SOA_TABLE(SinglePIDsITSPi, "AOD", "STSPIDITSPI", - singletrackselector::StoredITSNSigmaPi_v1, - singletrackselector::ITSNSigmaPi_v1); +DECLARE_SOA_TABLE(SinglePIDPis, "AOD", "SINGLEPIDPI", + singletrackselector::StoredTOFNSigmaPi, + singletrackselector::StoredTPCNSigmaPi, + + singletrackselector::TOFNSigmaPi, + singletrackselector::TPCNSigmaPi); + +DECLARE_SOA_TABLE(SinglePIDKas, "AOD", "SINGLEPIDKA", + singletrackselector::StoredTOFNSigmaKa, + singletrackselector::StoredTPCNSigmaKa, + + singletrackselector::TOFNSigmaKa, + singletrackselector::TPCNSigmaKa); + +DECLARE_SOA_TABLE(SinglePIDPrs, "AOD", "SINGLEPIDPR", + singletrackselector::StoredTOFNSigmaPr, + singletrackselector::StoredTPCNSigmaPr, -DECLARE_SOA_TABLE(SinglePIDsITSKa, "AOD", "STSPIDITSKA", - singletrackselector::StoredITSNSigmaKa_v1, - singletrackselector::ITSNSigmaKa_v1); + singletrackselector::TOFNSigmaPr, + singletrackselector::TPCNSigmaPr); -DECLARE_SOA_TABLE(SinglePIDsITSPr, "AOD", "STSPIDITSPR", - singletrackselector::StoredITSNSigmaPr_v1, - singletrackselector::ITSNSigmaPr_v1); +DECLARE_SOA_TABLE(SinglePIDDes, "AOD", "SINGLEPIDDE", + singletrackselector::StoredTOFNSigmaDe, + singletrackselector::StoredTPCNSigmaDe, + + singletrackselector::TOFNSigmaDe, + singletrackselector::TPCNSigmaDe); + +DECLARE_SOA_TABLE(SinglePIDTrs, "AOD", "SINGLEPIDTR", + singletrackselector::StoredTOFNSigmaTr, + singletrackselector::StoredTPCNSigmaTr, + + singletrackselector::TOFNSigmaTr, + singletrackselector::TPCNSigmaTr); + +DECLARE_SOA_TABLE(SinglePIDHes, "AOD", "SINGLEPIDHE", + singletrackselector::StoredTOFNSigmaHe, + singletrackselector::StoredTPCNSigmaHe, + + singletrackselector::TOFNSigmaHe, + singletrackselector::TPCNSigmaHe); + +DECLARE_SOA_TABLE(SingleTrkExtras, "AOD", "SINGLETRKEXTRA", + singletrackselector::TPCInnerParam, + singletrackselector::TPCSignal, + singletrackselector::Beta); namespace singletrackselector { @@ -532,6 +490,10 @@ DECLARE_SOA_DYNAMIC_COLUMN(Px_MC, px_MC, [](float p, float eta, float phi) -> fl DECLARE_SOA_DYNAMIC_COLUMN(Py_MC, py_MC, [](float p, float eta, float phi) -> float { return (p / std::cosh(eta)) * std::cos(phi); }); DECLARE_SOA_DYNAMIC_COLUMN(Pz_MC, pz_MC, [](float p, float eta) -> float { return p * std::tanh(eta); }); +// DECLARE_SOA_COLUMN(Vx_MC, vx_MC, float); +// DECLARE_SOA_COLUMN(Vy_MC, vy_MC, float); +// DECLARE_SOA_COLUMN(Vz_MC, vz_MC, float); + } // namespace singletrackselector DECLARE_SOA_TABLE(SingleTrkMCs, "AOD", "SINGLETRKMC", // Table with generatad info from MC @@ -545,80 +507,11 @@ DECLARE_SOA_TABLE(SingleTrkMCs, "AOD", "SINGLETRKMC", // Table with generatad in singletrackselector::Py_MC, singletrackselector::Pz_MC); +// DECLARE_SOA_TABLE(SingleTrkMCExtras, "AOD", "SINGLETRKMCEX", // Table with generatad info from MC +// singletrackselector::Vx_MC, +// singletrackselector::Vy_MC, +// singletrackselector::Vz_MC); + } // namespace o2::aod #endif // PWGCF_FEMTO3D_DATAMODEL_SINGLETRACKSELECTOR_H_ - -namespace o2::aod::singletrackselector -{ - -template -inline bool TPCselection(TrackType const& track, std::pair> const& PIDcuts) -{ - int PDG = PIDcuts.first; - float Nsigma = -1000; - switch (PDG) { - case 2212: - Nsigma = track.tpcNSigmaPr(); - break; - case 1000010020: - Nsigma = track.tpcNSigmaDe(); - break; - case 1000020030: - Nsigma = track.tpcNSigmaHe(); - break; - case 211: - Nsigma = track.tpcNSigmaPi(); - break; - case 321: - Nsigma = track.tpcNSigmaKa(); - break; - case 0: - return false; - default: - LOG(fatal) << "Cannot interpret PDG for TPC selection: " << PIDcuts.first; - } - - if (Nsigma > PIDcuts.second[0] && Nsigma < PIDcuts.second[1]) { - return true; - } - return false; -} - -template -inline bool TOFselection(TrackType const& track, std::pair> const& PIDcuts, std::vector const& TPCresidualCut = std::vector{-5.0f, 5.0f}) -{ - int PDG = PIDcuts.first; - if (!TPCselection(track, std::make_pair(PDG, TPCresidualCut))) - return false; - - float Nsigma = -1000; - switch (PDG) { - case 2212: - Nsigma = track.tofNSigmaPr(); - break; - case 1000010020: - Nsigma = track.tofNSigmaDe(); - break; - case 1000020030: - Nsigma = track.tofNSigmaHe(); - break; - case 211: - Nsigma = track.tofNSigmaPi(); - break; - case 321: - Nsigma = track.tofNSigmaKa(); - break; - case 0: - return false; - default: - LOG(fatal) << "Cannot interpret PDG for TOF selection: " << PIDcuts.first; - } - - if (Nsigma > PIDcuts.second[0] && Nsigma < PIDcuts.second[1]) { - return true; - } - return false; -} - -} // namespace o2::aod::singletrackselector diff --git a/PWGCF/Femto3D/TableProducer/CMakeLists.txt b/PWGCF/Femto3D/TableProducer/CMakeLists.txt index a31ce326c9f..01831d63091 100644 --- a/PWGCF/Femto3D/TableProducer/CMakeLists.txt +++ b/PWGCF/Femto3D/TableProducer/CMakeLists.txt @@ -9,7 +9,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -add_subdirectory(Converters) +#add_subdirectory(Converters) o2physics_add_dpl_workflow(single-track-selector SOURCES singleTrackSelector.cxx @@ -19,4 +19,9 @@ o2physics_add_dpl_workflow(single-track-selector o2physics_add_dpl_workflow(single-track-selector-extra SOURCES singleTrackSelectorExtra.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(single-track-selector-pid-dummy + SOURCES singleTrackSelectorPIDMaker.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGCF/Femto3D/TableProducer/singleTrackSelector.cxx b/PWGCF/Femto3D/TableProducer/singleTrackSelector.cxx index 538daf6cbb2..729538a1470 100644 --- a/PWGCF/Femto3D/TableProducer/singleTrackSelector.cxx +++ b/PWGCF/Femto3D/TableProducer/singleTrackSelector.cxx @@ -58,6 +58,7 @@ struct singleTrackSelector { Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable applySkimming{"applySkimming", false, "Skimmed dataset processing"}; Configurable cfgSkimming{"cfgSkimming", "fPD", "Configurable for skimming"}; + Configurable CBThadronPID{"CBThadronPID", false, "Apply ev. sel. based on RCT flag `hadronPID`"}; // more in Common/CCDB/RCTSelectionFlags.h Configurable applyEvSel{"applyEvSel", 2, "Flag to apply rapidity cut: 0 -> no event selection, 1 -> Run 2 event selection, 2 -> Run 3 event selection"}; // Configurable trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; @@ -87,9 +88,9 @@ struct singleTrackSelector { using Trks = soa::Join; using CollRun2 = soa::Join; @@ -100,11 +101,17 @@ struct singleTrackSelector { Produces tableRowCollExtra; Produces tableRow; Produces tableRowExtra; + Produces tableRowPIDEl; - Produces tableRowPIDITSPi; - Produces tableRowPIDITSKa; - Produces tableRowPIDITSPr; + Produces tableRowPIDPi; + Produces tableRowPIDKa; + Produces tableRowPIDPr; + Produces tableRowPIDDe; + Produces tableRowPIDTr; + Produces tableRowPIDHe; + Produces tableRowMC; + // Produces tableRowMCExtra; Filter eventFilter = (applyEvSel.node() == 0) || ((applyEvSel.node() == 1) && (aod::evsel::sel7 == true)) || @@ -115,7 +122,7 @@ struct singleTrackSelector { Filter pFilter = o2::aod::track::p > _min_P&& o2::aod::track::p < _max_P; Filter etaFilter = nabs(o2::aod::track::eta) < _eta; Filter dcaFilter = ((nabs(o2::aod::track::dcaXY) <= _dcaXY) && (nabs(o2::aod::track::dcaZ) <= _dcaZ)) && - ((o2::aod::track::dcaXY >= _dcaXYmin) && (o2::aod::track::dcaZ >= _dcaZmin)); + ((nabs(o2::aod::track::dcaXY) >= _dcaXYmin) && (nabs(o2::aod::track::dcaZ) >= _dcaZmin)); Filter tofChi2Filter = o2::aod::track::tofChi2 < _maxTofChi2; ctpRateFetcher mRateFetcher; // inspired by zdcSP.cxx in PWGLF @@ -128,6 +135,8 @@ struct singleTrackSelector { HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; SliceCache cache; + rctsel::RCTFlagsChecker myChecker{"CBT_hadronPID"}; + void init(InitContext&) { @@ -142,20 +151,24 @@ struct singleTrackSelector { ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); - if (applySkimming) { - registry.add("hNEvents", "hNEvents", {HistType::kTH1D, {{2, 0.f, 2.f}}}); - registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "All"); - registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "Skimmed"); - } + myChecker.init("CBT_hadronPID", true); + + registry.add("hNEvents", "hNEvents", {HistType::kTH1D, {{2, 0.f, 2.f}}}); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "All"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "Skimmed"); + + registry.add("hNTracks", "hNTracks", {HistType::kTH1D, {{2, 0.f, 2.f}}}); + registry.get(HIST("hNTracks"))->GetXaxis()->SetBinLabel(1, "All"); + registry.get(HIST("hNTracks"))->GetXaxis()->SetBinLabel(2, "Selected"); if (enable_gen_info) { registry.add("hNEvents_MCGen", "hNEvents_MCGen", {HistType::kTH1F, {{1, 0.f, 1.f}}}); - registry.add("hGen_EtaPhiPt_Proton", "Gen (anti)protons in true collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., 2 * TMath::Pi(), "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); - registry.add("hGen_EtaPhiPt_Deuteron", "Gen (anti)deuteron in true collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., 2 * TMath::Pi(), "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); - registry.add("hGen_EtaPhiPt_Helium3", "Gen (anti)Helium3 in true collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., 2 * TMath::Pi(), "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); - registry.add("hReco_EtaPhiPt_Proton", "Gen (anti)protons in reco collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., 2 * TMath::Pi(), "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); - registry.add("hReco_EtaPhiPt_Deuteron", "Gen (anti)deuteron in reco collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., 2 * TMath::Pi(), "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); - registry.add("hReco_EtaPhiPt_Helium3", "Gen (anti)Helium3 in reco collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., 2 * TMath::Pi(), "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); + registry.add("hGen_EtaPhiPt_Proton", "Gen (anti)protons in true collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., o2::constants::math::TwoPI, "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); + registry.add("hGen_EtaPhiPt_Deuteron", "Gen (anti)deuteron in true collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., o2::constants::math::TwoPI, "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); + registry.add("hGen_EtaPhiPt_Helium3", "Gen (anti)Helium3 in true collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., o2::constants::math::TwoPI, "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); + registry.add("hReco_EtaPhiPt_Proton", "Gen (anti)protons in reco collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., o2::constants::math::TwoPI, "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); + registry.add("hReco_EtaPhiPt_Deuteron", "Gen (anti)deuteron in reco collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., o2::constants::math::TwoPI, "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); + registry.add("hReco_EtaPhiPt_Helium3", "Gen (anti)Helium3 in reco collisions", {HistType::kTH3F, {{100, -1., 1., "#eta"}, {157, 0., o2::constants::math::TwoPI, "#phi"}, {100, -5.f, 5.f, "p_{T} GeV/c"}}}); } } @@ -199,6 +212,7 @@ struct singleTrackSelector { bool skip_track = false; // flag used for track rejection for (auto& track : tracks) { + registry.fill(HIST("hNTracks"), 0.5); if constexpr (isMC) { if (!track.has_mcParticle()) continue; @@ -218,9 +232,10 @@ struct singleTrackSelector { if (skip_track) continue; + registry.fill(HIST("hNTracks"), 1.5); for (auto ii : particlesToKeep) - if (o2::aod::singletrackselector::TPCselection(track, std::make_pair(ii, keepWithinNsigmaTPC))) { + if (o2::aod::singletrackselector::TPCselection(track, std::make_pair(ii, keepWithinNsigmaTPC))) { if (track.p() > _pRemoveTofOutOfRange && !o2::aod::singletrackselector::TOFselection(track, std::make_pair(ii, std::vector{-10.0, 10.0}), std::vector{-10.0, 10.0})) continue; @@ -237,26 +252,32 @@ struct singleTrackSelector { singletrackselector::packSymmetric(track.dcaZ()), singletrackselector::packInTable(track.tpcChi2NCl()), singletrackselector::packInTable(track.itsChi2NCl()), - singletrackselector::packInTable(track.tpcCrossedRowsOverFindableCls()), - singletrackselector::packSymmetric(track.tofNSigmaPi()), - singletrackselector::packSymmetric(track.tpcNSigmaPi()), - singletrackselector::packSymmetric(track.tofNSigmaKa()), - singletrackselector::packSymmetric(track.tpcNSigmaKa()), - singletrackselector::packSymmetric(track.tofNSigmaPr()), - singletrackselector::packSymmetric(track.tpcNSigmaPr()), - singletrackselector::packSymmetric(track.tofNSigmaDe()), - singletrackselector::packSymmetric(track.tpcNSigmaDe()), - singletrackselector::packSymmetric(track.tofNSigmaHe()), - singletrackselector::packSymmetric(track.tpcNSigmaHe())); + singletrackselector::packInTable(track.tpcCrossedRowsOverFindableCls())); tableRowExtra(track.tpcInnerParam(), track.tpcSignal(), track.beta()); - tableRowPIDEl(singletrackselector::packSymmetric(track.tpcNSigmaEl())); - tableRowPIDITSPi(singletrackselector::packSymmetric(track.itsNSigmaPi())); - tableRowPIDITSKa(singletrackselector::packSymmetric(track.itsNSigmaKa())); - tableRowPIDITSPr(singletrackselector::packSymmetric(track.itsNSigmaPr())); + tableRowPIDEl(singletrackselector::packSymmetric(track.tofNSigmaEl()), + singletrackselector::packSymmetric(track.tpcNSigmaEl())); + + tableRowPIDPi(singletrackselector::packSymmetric(track.tofNSigmaPi()), + singletrackselector::packSymmetric(track.tpcNSigmaPi())); + + tableRowPIDKa(singletrackselector::packSymmetric(track.tofNSigmaKa()), + singletrackselector::packSymmetric(track.tpcNSigmaKa())); + + tableRowPIDPr(singletrackselector::packSymmetric(track.tofNSigmaPr()), + singletrackselector::packSymmetric(track.tpcNSigmaPr())); + + tableRowPIDDe(singletrackselector::packSymmetric(track.tofNSigmaDe()), + singletrackselector::packSymmetric(track.tpcNSigmaDe())); + + tableRowPIDTr(singletrackselector::packSymmetric(track.tofNSigmaTr()), + singletrackselector::packSymmetric(track.tpcNSigmaTr())); + + tableRowPIDHe(singletrackselector::packSymmetric(track.tofNSigmaHe()), + singletrackselector::packSymmetric(track.tpcNSigmaHe())); if constexpr (isMC) { int origin = -1; @@ -277,6 +298,10 @@ struct singleTrackSelector { track.mcParticle().p(), track.mcParticle().eta(), track.mcParticle().phi()); + + // tableRowMCExtra(track.mcParticle().vx(), + // track.mcParticle().vy(), + // track.mcParticle().vz()); } break; // break the loop with particlesToKeep after the 'if' condition is satisfied -- don't want double entries } @@ -288,10 +313,6 @@ struct singleTrackSelector { aod::BCsWithTimestamps const&) { - auto tracksWithITSPid = soa::Attach(tracks); auto bc = collision.bc_as(); initCCDB(bc); @@ -320,7 +341,7 @@ struct singleTrackSelector { collision.posZ(), d_bz); - fillTrackTables(tracksWithITSPid); + fillTrackTables(tracks); } } PROCESS_SWITCH(singleTrackSelector, processDataRun2, "process data Run2", false); @@ -329,21 +350,20 @@ struct singleTrackSelector { soa::Filtered const& tracks, aod::BCsWithTimestamps const&) { - auto tracksWithITSPid = soa::Attach(tracks); - auto bc = collision.bc_as(); + + const auto& bc = collision.bc_as(); initCCDB(bc); + if (!myChecker(*collision) && CBThadronPID) + return; + + registry.fill(HIST("hNEvents"), 0.5); if (applySkimming) { - registry.fill(HIST("hNEvents"), 0.5); - bool zorroSelected = zorro.isSelected(bc.globalBC()); - if (!zorroSelected) { + if (!zorro.isSelected(bc.globalBC())) { return; } - registry.fill(HIST("hNEvents"), 1.5); } + registry.fill(HIST("hNEvents"), 1.5); double hadronicRate = 0.; if (fetchRate) { @@ -403,7 +423,7 @@ struct singleTrackSelector { hadronicRate, occupancy); - fillTrackTables(tracksWithITSPid); + fillTrackTables(tracks); } } PROCESS_SWITCH(singleTrackSelector, processDataRun3, "process data Run3", true); @@ -413,10 +433,6 @@ struct singleTrackSelector { aod::McParticles const&, aod::BCsWithTimestamps const&) { - auto tracksWithITSPid = soa::Attach, - aod::pidits::ITSNSigmaPi, - aod::pidits::ITSNSigmaKa, - aod::pidits::ITSNSigmaPr>(tracks); auto bc = collision.bc_as(); initCCDB(bc); @@ -444,7 +460,7 @@ struct singleTrackSelector { collision.posZ(), d_bz); - fillTrackTables(tracksWithITSPid); + fillTrackTables(tracks); } } PROCESS_SWITCH(singleTrackSelector, processMCRun2, "process MC Run2", false); @@ -454,10 +470,7 @@ struct singleTrackSelector { aod::McParticles const& mcParticles, aod::BCsWithTimestamps const&) { - auto tracksWithITSPid = soa::Attach, - aod::pidits::ITSNSigmaPi, - aod::pidits::ITSNSigmaKa, - aod::pidits::ITSNSigmaPr>(tracks); + auto bc = collision.bc_as(); initCCDB(bc); double hadronicRate = 0.; @@ -519,7 +532,7 @@ struct singleTrackSelector { hadronicRate, occupancy); - fillTrackTables(tracksWithITSPid); + fillTrackTables(tracks); if (!enable_gen_info) { return; diff --git a/PWGCF/Femto3D/TableProducer/singleTrackSelectorExtra.cxx b/PWGCF/Femto3D/TableProducer/singleTrackSelectorExtra.cxx index d83568a18a5..0f065371ca8 100644 --- a/PWGCF/Femto3D/TableProducer/singleTrackSelectorExtra.cxx +++ b/PWGCF/Femto3D/TableProducer/singleTrackSelectorExtra.cxx @@ -34,27 +34,13 @@ struct singleTrackSelectorDummy { Produces tableRowCollExtra; - void processDefault(aod::SingleCollSels::iterator const&) + void process(aod::SingleCollSels::iterator const&) { uint64_t selection = 0; tableRowCollExtra(selection, 0.0, 0); } - PROCESS_SWITCH(singleTrackSelectorDummy, processDefault, "filling the CollExtra table with dummy values", true); - - void processExtra_v0(soa::Join::iterator const& collision) - { - uint64_t selection = 0; - selection |= collision.isNoSameBunchPileup() ? BIT(evsel::kNoSameBunchPileup) : 0; - selection |= collision.isGoodZvtxFT0vsPV() ? BIT(evsel::kIsGoodZvtxFT0vsPV) : 0; - selection |= collision.isVertexITSTPC() ? BIT(evsel::kIsVertexITSTPC) : 0; - - tableRowCollExtra(selection, - collision.hadronicRate(), - 0); - } - PROCESS_SWITCH(singleTrackSelectorDummy, processExtra_v0, "process using info from the previous version of stored CollExtra table", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/Femto3D/TableProducer/singleTrackSelectorPIDMaker.cxx b/PWGCF/Femto3D/TableProducer/singleTrackSelectorPIDMaker.cxx new file mode 100644 index 00000000000..ebdc786469b --- /dev/null +++ b/PWGCF/Femto3D/TableProducer/singleTrackSelectorPIDMaker.cxx @@ -0,0 +1,165 @@ +// 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. +// +/// \file singleTrackSelectorPIDMaker.cxx +/// \brief creates dummy tables for PID columns that are not in the derived data +/// \author Sofia Tomassini, Gleb Romanenko, Nicolò Jacazio +/// \since 22 January 2025 + +#include +#include + +#include +#include +#include + +#include "PWGCF/Femto3D/DataModel/singletrackselector.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::track; +using namespace o2::aod; +//::singletrackselector; // the namespace defined in .h + +struct StPidEl { + Produces table; + void process(o2::aod::SingleTrackSels const& tracks) + { + table.reserve(tracks.size()); + for (int i = 0; i < tracks.size(); i++) { + table(singletrackselector::binning::nsigma::underflowBin, + singletrackselector::binning::nsigma::underflowBin); + } + } +}; +struct StPidPi { + Produces table; + void process(o2::aod::SingleTrackSels const& tracks) + { + table.reserve(tracks.size()); + for (int i = 0; i < tracks.size(); i++) { + table(singletrackselector::binning::nsigma::underflowBin, + singletrackselector::binning::nsigma::underflowBin); + } + } +}; +struct StPidKa { + Produces table; + void process(o2::aod::SingleTrackSels const& tracks) + { + table.reserve(tracks.size()); + for (int i = 0; i < tracks.size(); i++) { + table(singletrackselector::binning::nsigma::underflowBin, + singletrackselector::binning::nsigma::underflowBin); + } + } +}; +struct StPidPr { + Produces table; + void process(o2::aod::SingleTrackSels const& tracks) + { + table.reserve(tracks.size()); + for (int i = 0; i < tracks.size(); i++) { + table(singletrackselector::binning::nsigma::underflowBin, + singletrackselector::binning::nsigma::underflowBin); + } + } +}; +struct StPidDe { + Produces table; + void process(o2::aod::SingleTrackSels const& tracks) + { + table.reserve(tracks.size()); + for (int i = 0; i < tracks.size(); i++) { + table(singletrackselector::binning::nsigma::underflowBin, + singletrackselector::binning::nsigma::underflowBin); + } + } +}; + +struct StPidTr { + Produces table; + void process(o2::aod::SingleTrackSels const& tracks) + { + table.reserve(tracks.size()); + for (int i = 0; i < tracks.size(); i++) { + table(singletrackselector::binning::nsigma::underflowBin, + singletrackselector::binning::nsigma::underflowBin); + } + } +}; + +struct StPidHe { + Produces table; + void process(o2::aod::SingleTrackSels const& tracks) + { + table.reserve(tracks.size()); + for (int i = 0; i < tracks.size(); i++) { + table(singletrackselector::binning::nsigma::underflowBin, + singletrackselector::binning::nsigma::underflowBin); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + auto workflow = WorkflowSpec{}; + + // Check if 'aod-metadata-tables' option is available in the config context + if (cfgc.options().hasOption("aod-metadata-tables")) { + const std::vector tables = cfgc.options().get>("aod-metadata-tables"); + + // Map of table names to their corresponding converter task functions + std::unordered_map>> tableToTasks = { + {"O2singlepidel", {[&]() { workflow.push_back(adaptAnalysisTask(cfgc)); }}}, + {"O2singlepidpi", {[&]() { workflow.push_back(adaptAnalysisTask(cfgc)); }}}, + {"O2singlepidka", {[&]() { workflow.push_back(adaptAnalysisTask(cfgc)); }}}, + {"O2singlepidpr", {[&]() { workflow.push_back(adaptAnalysisTask(cfgc)); }}}, + {"O2singlepidde", {[&]() { workflow.push_back(adaptAnalysisTask(cfgc)); }}}, + {"O2singlepidtr", {[&]() { workflow.push_back(adaptAnalysisTask(cfgc)); }}}, + {"O2singlepidhe", {[&]() { workflow.push_back(adaptAnalysisTask(cfgc)); }}}}; + + for (auto const& tableInWorkflow : tables) { + LOG(info) << tableInWorkflow; + } + + // Iterate through the tables and process based on the mapping + for (auto const& table : tableToTasks) { + bool foundIt = false; + for (auto const& tableInWorkflow : tables) { + if (tableInWorkflow == table.first) { + foundIt = true; + break; + } + } + if (foundIt) + continue; + for (auto const& task : table.second) { + LOG(info) << "Adding task " << table.first; + task(); + } + } + } else { + LOG(warning) << "AOD converter: No tables found in the meta data. Adding all workflows"; + workflow.push_back(adaptAnalysisTask(cfgc)); + workflow.push_back(adaptAnalysisTask(cfgc)); + workflow.push_back(adaptAnalysisTask(cfgc)); + workflow.push_back(adaptAnalysisTask(cfgc)); + workflow.push_back(adaptAnalysisTask(cfgc)); + workflow.push_back(adaptAnalysisTask(cfgc)); + workflow.push_back(adaptAnalysisTask(cfgc)); + } + return workflow; +} diff --git a/PWGCF/Femto3D/Tasks/CMakeLists.txt b/PWGCF/Femto3D/Tasks/CMakeLists.txt index 62a7b310690..4090fea6795 100644 --- a/PWGCF/Femto3D/Tasks/CMakeLists.txt +++ b/PWGCF/Femto3D/Tasks/CMakeLists.txt @@ -22,4 +22,9 @@ o2physics_add_dpl_workflow(femto3d-pair-task o2physics_add_dpl_workflow(femto3d-pair-task-mc SOURCES femto3dPairTaskMC.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) \ No newline at end of file + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(femto3d-pid-optimization + SOURCES PIDoptimization.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGCF/Femto3D/Tasks/PIDoptimization.cxx b/PWGCF/Femto3D/Tasks/PIDoptimization.cxx new file mode 100644 index 00000000000..acf08e13079 --- /dev/null +++ b/PWGCF/Femto3D/Tasks/PIDoptimization.cxx @@ -0,0 +1,304 @@ +// 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. +// +/// \brief optimization of particle identification for femtoscopic analysis. +/// \author Sofia Tomassini +/// \since July 2025 + +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/MathConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StaticFor.h" +#include "Framework/runDataProcessing.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector4D.h" +#include "TMath.h" +#include "TRandom3.h" +#include + +#include "fairlogger/Logger.h" + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +namespace o2::aod +{ +using SelectedTracks = soa::Join; +} +struct PidOptimization { + + HistogramRegistry histos{"Histos"}; + + Configurable _removeSameBunchPileup{"removeSameBunchPileup", false, ""}; + Configurable _requestGoodZvtxFT0vsPV{"requestGoodZvtxFT0vsPV", false, ""}; + Configurable _requestVertexITSTPC{"requestVertexITSTPC", false, ""}; + Configurable _requestVertexTOForTRDmatched{"requestVertexTOFmatched", 0, "0 -> no selectio; 1 -> vertex is matched to TOF or TRD; 2 -> matched to both;"}; + Configurable _requestNoCollInTimeRangeStandard{"requestNoCollInTimeRangeStandard", false, ""}; + Configurable> _IRcut{"IRcut", std::pair{0.f, 100.f}, "[min., max.] IR range to keep events within"}; + Configurable> _OccupancyCut{"OccupancyCut", std::pair{0, 10000}, "[min., max.] occupancy range to keep events within"}; + + Configurable _sign{"sign", 1, "sign of a track"}; + Configurable _vertexZ{"VertexZ", 20.0, "abs vertexZ value limit"}; + Configurable _min_P{"min_P", 0.0, "lower mometum limit"}; + Configurable _max_P{"max_P", 100.0, "upper mometum limit"}; + Configurable _eta{"eta", 100.0, "abs eta value limit"}; + + Configurable> _dcaXY{"dcaXY", std::vector{0.3f, 0.0f, 0.0f}, "abs dcaXY value limit; formula: [0] + [1]*pT^[2]"}; + Configurable> _dcaZ{"dcaZ", std::vector{0.3f, 0.0f, 0.0f}, "abs dcaZ value limit; formula: [0] + [1]*pT^[2]"}; + Configurable _tpcNClsFound{"minTpcNClsFound", 0, "minimum allowed number of TPC clasters"}; + Configurable _tpcChi2NCl{"tpcChi2NCl", 100.0, "upper limit for chi2 value of a fit over TPC clasters"}; + Configurable _tpcCrossedRowsOverFindableCls{"tpcCrossedRowsOverFindableCls", 0, "lower limit of TPC CrossedRows/FindableCls value"}; + Configurable _tpcFractionSharedCls{"maxTpcFractionSharedCls", 0.4, "maximum fraction of TPC shared clasters"}; + Configurable _itsNCls{"minItsNCls", 0, "minimum allowed number of ITS clasters for a track"}; + Configurable _itsChi2NCl{"itsChi2NCl", 100.0, "upper limit for chi2 value of a fit over ITS clasters for a track"}; + Configurable _particlePDG{"particlePDG", 2212, "PDG code of a particle to perform PID for (only pion, kaon, proton and deurton are supported now)"}; + Configurable> _tpcNSigma{"tpcNSigma", std::pair{-100, 100}, "Nsigma range in TPC before the TOF is used"}; + Configurable> _itsNSigma{"itsNSigma", std::pair{-100, 100}, "Nsigma range in ITS to use along with TPC"}; + Configurable _PIDtrshld{"PIDtrshld", 10.0, "value of momentum from which the PID is done with TOF (before that only TPC is used)"}; + Configurable> _tofNSigma{"tofNSigma", std::pair{-100, 100}, "Nsigma range in TOF"}; + Configurable> _tpcNSigmaResidual{"tpcNSigmaResidual", std::pair{-10, 10}, "residual TPC Nsigma cut to use with the TOF"}; + Configurable _particlePDGtoReject{"particlePDGtoReject", 211, "PDG codes of perticles that will be rejected with TOF (only pion, kaon, proton and deurton are supported now)"}; + Configurable> _rejectWithinNsigmaTOF{"rejectWithinNsigmaTOF", std::pair{-10, 10}, "TOF rejection Nsigma range for particles specified with PDG to be rejected"}; + + std::shared_ptr ITShisto; + std::shared_ptr TPChisto; + std::shared_ptr TOFhisto; + std::shared_ptr ITSvsTPChisto; + std::shared_ptr dcaxy_p; + std::shared_ptr dcaxy_pt; + std::shared_ptr dcaz_p; + std::shared_ptr dcaz_pt; + + void init(o2::framework::InitContext& context) + { + o2::aod::ITSResponse::setParameters(context); + histos.add("vtz", "vtz", kTH1F, {{100, -20., 20., "vtxz"}}); + histos.add("eta", "eta", kTH1F, {{200, -2.5, 2.5, "eta"}}); + histos.add("phi", "phi", kTH1F, {{200, 0., 2. * M_PI, "phi"}}); + histos.add("px", "px", kTH1F, {{100, 0., 5., "px"}}); + histos.add("py", "py", kTH1F, {{100, 0., 5., "py"}}); + histos.add("pz", "pz", kTH1F, {{100, 0., 5., "pz"}}); + histos.add("p", "p", kTH1F, {{100, 0., 5., "p"}}); + histos.add("pt", "pt", kTH1F, {{100, 0., 5., "pt"}}); + histos.add("sign", "sign", kTH1F, {{3, -1.5, 1.5, "sign"}}); + histos.add("TPCClusters", "TPCClusters", kTH1F, {{163, -0.5, 162.5, "NTPCClust"}}); + histos.add("TPCCrossedRowsOverFindableCls", "TPCCrossedRowsOverFindableCls", kTH1F, {{100, 0.0, 10.0, "NcrossedRowsOverFindable"}}); + histos.add("TPCFractionSharedCls", "TPCFractionSharedCls", kTH1F, {{100, 0.0, 1.0, "TPCsharedFraction"}}); + histos.add("ITSClusters", "ITSClusters", kTH1F, {{10, -0.5, 9.5, "NITSClust"}}); + histos.add("ITSchi2", "ITSchi2", kTH1F, {{100, 0.0, 40., "ITSchi2"}}); + histos.add("TPCchi2", "TPCchi2", kTH1F, {{100, 0.0, 6., "TPCchi2"}}); + + dcaxy_p = histos.add("dcaxy_p", "dcaxy_p", kTH2F, {{100, 0., 5.0, "p"}, {500, -0.5, 0.5, "dcaxy"}}); + dcaxy_pt = histos.add("dcaxy_pt", "dcaxy_pt", kTH2F, {{100, 0., 5.0, "pt"}, {500, -0.5, 0.5, "dcaxy"}}); + dcaz_p = histos.add("dcaz_p", "dcaz_p", kTH2F, {{100, 0., 5.0, "p"}, {500, -0.5, 0.5, "dcaz"}}); + dcaz_pt = histos.add("dcaz_pt", "dcaz_pt", kTH2F, {{100, 0., 5.0, "pt"}, {500, -0.5, 0.5, "dcaxy"}}); + + ITShisto = histos.add(Form("nsigmaITS_PDG%i", _particlePDG.value), Form("nsigmaITS_PDG%i", _particlePDG.value), kTH2F, {{100, 0., 10.}, {1000, -50., 50.}}); + TPChisto = histos.add(Form("nsigmaTPC_PDG%i", _particlePDG.value), Form("nsigmaTPC_PDG%i", _particlePDG.value), kTH2F, {{100, 0., 10.}, {1000, -50., 50.}}); + TOFhisto = histos.add(Form("nsigmaTOF_PDG%i", _particlePDG.value), Form("nsigmaTOF_PDG%i", _particlePDG.value), kTH2F, {{100, 0., 10.}, {2000, -100., 100.}}); + + ITSvsTPChisto = histos.add(Form("nsigmaITSvsTPC_PDG%i", _particlePDG.value), Form("nsigmaITSvsTPC_PDG%i", _particlePDG.value), kTH2F, {{1000, -50., 50.}, {1000, -50., 50.}}); + } + + template + inline float getITSNsigma(TrackType const& track, int const& PDG) + { + switch (PDG) { + case 211: + return track.itsNSigmaPi(); + case 321: + return track.itsNSigmaKa(); + case 2212: + return track.itsNSigmaPr(); + case 1000010020: + return track.itsNSigmaDe(); + case 0: + return -1000.0; + default: + LOG(fatal) << "Cannot interpret PDG for ITS selection: " << PDG; + return -1000.0; + } + } + template + inline float getTPCNsigma(TrackType const& track, int const& PDG) + { + switch (PDG) { + case 211: + return track.tpcNSigmaPi(); + case 321: + return track.tpcNSigmaKa(); + case 2212: + return track.tpcNSigmaPr(); + case 1000010020: + return track.tpcNSigmaDe(); + case 0: + return -1000.0; + default: + LOG(fatal) << "Cannot interpret PDG for TPC selection: " << PDG; + return -1000.0; + } + } + template + inline float getTOFNsigma(TrackType const& track, int const& PDG) + { + switch (PDG) { + case 211: + return track.tofNSigmaPi(); + case 321: + return track.tofNSigmaKa(); + case 2212: + return track.tofNSigmaPr(); + case 1000010020: + return track.tofNSigmaDe(); + case 0: + return -1000.0; + default: + LOG(fatal) << "Cannot interpret PDG for TOF selection: " << PDG; + return -1000.0; + } + } + + bool isInRange(float value, std::pair range) + { + return value > range.first && value < range.second; + } + + void process(soa::Join const& collisions, aod::SelectedTracks const& tracks) + { + auto tracksWithItsPid = soa::Attach(tracks); + + for (auto& collision : collisions) { + if (!collision.sel8() || abs(collision.posZ()) > _vertexZ) + continue; + if (_requestGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) + continue; + if (_removeSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + continue; + if (_requestGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) + continue; + if (_requestVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) + continue; + // if (_requestVertexTOForTRDmatched > collision.selection_bit(o2::aod::evsel::kisVertexTOForTRDmatched())) + // continue; + if (_requestNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) + continue; + // if (collision.multPerc() < _centCut.value.first || collision.multPerc() >= _centCut.value.second) + // continue; + // if (collision.hadronicRate() < _IRcut.value.first || collision.hadronicRate() >= _IRcut.value.second) + // continue; + if (collision.trackOccupancyInTimeRange() < _OccupancyCut.value.first || collision.trackOccupancyInTimeRange() >= _OccupancyCut.value.second) + continue; + + histos.fill(HIST("vtz"), collision.posZ()); + } + + for (auto& track : tracksWithItsPid) { + if (track.sign() != _sign) + continue; + if (track.p() < _min_P || track.p() > _max_P || abs(track.eta()) > _eta) + continue; + if ((track.itsChi2NCl() >= _itsChi2NCl) || (track.itsChi2NCl() <= 0.f) || (track.tpcChi2NCl() <= 0.f) || (track.tpcChi2NCl() >= _tpcChi2NCl)) + continue; + if ((track.tpcFractionSharedCls()) > _tpcFractionSharedCls || (track.tpcNClsFound()) < _tpcNClsFound || (track.tpcCrossedRowsOverFindableCls()) < _tpcCrossedRowsOverFindableCls || (track.itsNCls()) < _itsNCls) + continue; + if (std::fabs(track.dcaXY()) > _dcaXY.value[0] + _dcaXY.value[1] * std::pow(track.pt(), _dcaXY.value[2]) || std::fabs(track.dcaZ()) > _dcaZ.value[0] + _dcaZ.value[1] * std::pow(track.pt(), _dcaZ.value[2])) + continue; + + bool belowThreshold = track.p() < _PIDtrshld; + float tpcSigma = getTPCNsigma(track, _particlePDG); + float itsSigma = getITSNsigma(track, _particlePDG); + float tofSigma = getTOFNsigma(track, _particlePDG); + float tofRejection = getTOFNsigma(track, _particlePDGtoReject); + + bool passTPC = belowThreshold ? isInRange(tpcSigma, _tpcNSigma.value) : isInRange(tpcSigma, _tpcNSigmaResidual.value); + + bool passITS = belowThreshold ? isInRange(itsSigma, _itsNSigma.value) : true; + + bool passTOF = belowThreshold ? true : (isInRange(tofSigma, _tofNSigma.value) && !isInRange(tofRejection, _rejectWithinNsigmaTOF.value)); + + if (passTPC && passITS && passTOF) { + histos.fill(HIST("eta"), track.eta()); + histos.fill(HIST("phi"), track.phi()); + histos.fill(HIST("px"), track.px()); + histos.fill(HIST("py"), track.py()); + histos.fill(HIST("pz"), track.pz()); + histos.fill(HIST("p"), track.p()); + histos.fill(HIST("pt"), track.pt()); + histos.fill(HIST("sign"), track.sign()); + histos.fill(HIST("dcaxy_p"), track.p(), track.dcaXY()); + histos.fill(HIST("dcaxy_pt"), track.pt(), track.dcaXY()); + histos.fill(HIST("dcaz_p"), track.p(), track.dcaZ()); + histos.fill(HIST("dcaz_pt"), track.pt(), track.dcaZ()); + histos.fill(HIST("TPCClusters"), track.tpcNClsFound()); + histos.fill(HIST("TPCCrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); + histos.fill(HIST("TPCFractionSharedCls"), track.tpcFractionSharedCls()); + histos.fill(HIST("ITSClusters"), track.itsNCls()); + histos.fill(HIST("ITSchi2"), track.itsChi2NCl()); + histos.fill(HIST("TPCchi2"), track.tpcChi2NCl()); + + switch (_particlePDG) { + case 211: + ITShisto->Fill(track.p(), track.itsNSigmaPi()); + TPChisto->Fill(track.p(), track.tpcNSigmaPi()); + TOFhisto->Fill(track.p(), track.tofNSigmaPi()); + ITSvsTPChisto->Fill(track.itsNSigmaPi(), track.tpcNSigmaPi()); + break; + case 321: + ITShisto->Fill(track.p(), track.itsNSigmaKa()); + TPChisto->Fill(track.p(), track.tpcNSigmaKa()); + TOFhisto->Fill(track.p(), track.tofNSigmaKa()); + ITSvsTPChisto->Fill(track.itsNSigmaKa(), track.tpcNSigmaKa()); + break; + case 2212: + ITShisto->Fill(track.p(), track.itsNSigmaPr()); + TPChisto->Fill(track.p(), track.tpcNSigmaPr()); + TOFhisto->Fill(track.p(), track.tofNSigmaPr()); + ITSvsTPChisto->Fill(track.itsNSigmaPr(), track.tpcNSigmaPr()); + break; + case 1000010020: + ITShisto->Fill(track.p(), track.itsNSigmaDe()); + TPChisto->Fill(track.p(), track.tpcNSigmaDe()); + TOFhisto->Fill(track.p(), track.tofNSigmaDe()); + ITSvsTPChisto->Fill(track.itsNSigmaDe(), track.tpcNSigmaDe()); + break; + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Femto3D/Tasks/femto3dPairTask.cxx b/PWGCF/Femto3D/Tasks/femto3dPairTask.cxx index 045dc9ad2d8..83aa740795c 100644 --- a/PWGCF/Femto3D/Tasks/femto3dPairTask.cxx +++ b/PWGCF/Femto3D/Tasks/femto3dPairTask.cxx @@ -18,6 +18,9 @@ #include #include #include +#include +#include +#include #include #include @@ -71,6 +74,7 @@ struct FemtoCorrelations { Configurable _sign_1{"sign_1", 1, "sign of the first particle in a pair"}; Configurable _particlePDG_1{"particlePDG_1", 2212, "PDG code of the first particle in a pair to perform PID for (only pion, kaon, proton and deurton are supported now)"}; Configurable> _tpcNSigma_1{"tpcNSigma_1", std::vector{-3.0f, 3.0f}, "first particle PID: Nsigma range in TPC before the TOF is used"}; + Configurable> _itsNSigma_1{"itsNSigma_1", std::vector{-10.0f, 10.0f}, "first particle PID: Nsigma range in ITS with TPC is used"}; Configurable _PIDtrshld_1{"PIDtrshld_1", 10.0, "first particle PID: value of momentum from which the PID is done with TOF (before that only TPC is used)"}; Configurable> _tofNSigma_1{"tofNSigma_1", std::vector{-3.0f, 3.0f}, "first particle PID: Nsigma range in TOF"}; Configurable> _tpcNSigmaResidual_1{"tpcNSigmaResidual_1", std::vector{-5.0f, 5.0f}, "first particle PID: residual TPC Nsigma cut to use with the TOF"}; @@ -78,6 +82,7 @@ struct FemtoCorrelations { Configurable _sign_2{"sign_2", 1, "sign of the second particle in a pair"}; Configurable _particlePDG_2{"particlePDG_2", 2212, "PDG code of the second particle in a pair to perform PID for (only pion, kaon, proton and deurton are supported now)"}; Configurable> _tpcNSigma_2{"tpcNSigma_2", std::vector{-3.0f, 3.0f}, "second particle PID: Nsigma range in TPC before the TOF is used"}; + Configurable> _itsNSigma_2{"itsNSigma_2", std::vector{-10.0f, 10.0f}, "first particle PID: Nsigma range in ITS with TPC is used"}; Configurable _PIDtrshld_2{"PIDtrshld_2", 10.0, "second particle PID: value of momentum from which the PID is done with TOF (before that only TPC is used)"}; Configurable> _tofNSigma_2{"tofNSigma_2", std::vector{-3.0f, 3.0f}, "second particle PID: Nsigma range in TOF"}; Configurable> _tpcNSigmaResidual_2{"tpcNSigmaResidual_2", std::vector{-5.0f, 5.0f}, "second particle PID: residual TPC Nsigma cut to use with the TOF"}; @@ -85,9 +90,10 @@ struct FemtoCorrelations { Configurable _particlePDGtoReject{"particlePDGtoRejectFromSecond", 0, "applied only if the particles are non-identical and only to the second particle in the pair!!!"}; Configurable> _rejectWithinNsigmaTOF{"rejectWithinNsigmaTOF", std::vector{-0.0f, 0.0f}, "TOF rejection Nsigma range for the particle specified with PDG to be rejected"}; + Configurable _dPhiMode{"dPhiMode", 0, "Flag to choose how to calc. dphi*: 0 - at a fixed TPC radius; 1 - average over different TPC radii;"}; + Configurable _radiusTPC{"radiusTPC", 1.2, "TPC radius to calculate phi_star for"}; Configurable _deta{"deta", 0.01, "minimum allowed defference in eta between two tracks in a pair"}; Configurable _dphi{"dphi", 0.01, "minimum allowed defference in phi_star between two tracks in a pair"}; - Configurable _radiusTPC{"radiusTPC", 1.2, "TPC radius to calculate phi_star for"}; Configurable _avgSepTPC{"avgSepTPC", 10, "average sep. (cm) in TPC"}; Configurable _vertexNbinsToMix{"vertexNbinsToMix", 10, "Number of vertexZ bins for the mixing"}; @@ -118,7 +124,8 @@ struct FemtoCorrelations { std::pair> TOFcuts_2; using FilteredCollisions = soa::Join; - using FilteredTracks = aod::SingleTrackSels; + // using FilteredTracks = soa::Join; // main + using FilteredTracks = soa::Join; // tmp solution till the HL is fixed typedef std::shared_ptr::iterator> trkType; typedef std::shared_ptr::iterator> colType; @@ -140,6 +147,16 @@ struct FemtoCorrelations { Filter vertexFilter = nabs(o2::aod::singletrackselector::posZ) < _vertexZ; + std::shared_ptr pHisto_first; // momentum histogram for the first particle + std::shared_ptr ITShisto_first; + std::shared_ptr TPChisto_first; + std::shared_ptr TOFhisto_first; + + std::shared_ptr pHisto_second; // momentum histogram for the second particle + std::shared_ptr ITShisto_second; + std::shared_ptr TPChisto_second; + std::shared_ptr TOFhisto_second; + std::vector> MultHistos; std::vector>> kThistos; std::vector>> mThistos; // test @@ -257,13 +274,16 @@ struct FemtoCorrelations { } } - registry.add("p_first", Form("p_%i", static_cast(_particlePDG_1)), kTH1F, {{100, 0., 5., "p"}}); - registry.add("nsigmaTOF_first", Form("nsigmaTOF_%i", static_cast(_particlePDG_1)), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - registry.add("nsigmaTPC_first", Form("nsigmaTPC_%i", static_cast(_particlePDG_1)), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); + pHisto_first = registry.add(Form("p_%i", _particlePDG_1.value), Form("p_%i", _particlePDG_1.value), kTH1F, {{100, 0., 5., "p"}}); + ITShisto_first = registry.add(Form("nsigmaITS_PDG%i", _particlePDG_1.value), Form("nsigmaITS_PDG%i", _particlePDG_1.value), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); + TPChisto_first = registry.add(Form("nsigmaTPC_PDG%i", _particlePDG_1.value), Form("nsigmaTPC_PDG%i", _particlePDG_1.value), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); + TOFhisto_first = registry.add(Form("nsigmaTOF_PDG%i", _particlePDG_1.value), Form("nsigmaTOF_PDG%i", _particlePDG_1.value), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); + if (!IsIdentical) { - registry.add("p_second", Form("p_%i", static_cast(_particlePDG_2)), kTH1F, {{100, 0., 5., "p"}}); - registry.add("nsigmaTOF_second", Form("nsigmaTOF_%i", static_cast(_particlePDG_2)), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - registry.add("nsigmaTPC_second", Form("nsigmaTPC_%i", static_cast(_particlePDG_2)), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); + pHisto_second = registry.add(Form("p_%i", _particlePDG_2.value), Form("p_%i", _particlePDG_2.value), kTH1F, {{100, 0., 5., "p"}}); + ITShisto_second = registry.add(Form("nsigmaITS_PDG%i", _particlePDG_2.value), Form("nsigmaITS_PDG%i", _particlePDG_2.value), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); + TPChisto_second = registry.add(Form("nsigmaTPC_PDG%i", _particlePDG_2.value), Form("nsigmaTPC_PDG%i", _particlePDG_2.value), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); + TOFhisto_second = registry.add(Form("nsigmaTOF_PDG%i", _particlePDG_2.value), Form("nsigmaTOF_PDG%i", _particlePDG_2.value), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); } } @@ -291,15 +311,15 @@ struct FemtoCorrelations { LOGF(fatal, "kTbin value obtained for a pair exceeds the configured number of kT bins (3D)"); if (_fillDetaDphi % 2 == 0) - DoubleTrack_SE_histos_BC[multBin][kTbin]->Fill(Pair->GetPhiStarDiff(_radiusTPC), Pair->GetEtaDiff()); + DoubleTrack_SE_histos_BC[multBin][kTbin]->Fill(_dPhiMode.value == 0 ? Pair->GetPhiStarDiff(_radiusTPC) : Pair->GetAvgPhiStarDiff(), Pair->GetEtaDiff()); - if (_deta > 0 && _dphi > 0 && Pair->IsClosePair(_deta, _dphi, _radiusTPC)) + if (_deta > 0 && _dphi > 0 && (_dPhiMode.value == 0 ? Pair->IsClosePair(_deta, _dphi, _radiusTPC) : Pair->IsClosePair(_deta, _dphi))) continue; if (_avgSepTPC > 0 && Pair->IsClosePair(_avgSepTPC)) continue; if (_fillDetaDphi > 0) - DoubleTrack_SE_histos_AC[multBin][kTbin]->Fill(Pair->GetPhiStarDiff(_radiusTPC), Pair->GetEtaDiff()); + DoubleTrack_SE_histos_AC[multBin][kTbin]->Fill(_dPhiMode.value == 0 ? Pair->GetPhiStarDiff(_radiusTPC) : Pair->GetAvgPhiStarDiff(), Pair->GetEtaDiff()); kThistos[multBin][kTbin]->Fill(pair_kT); mThistos[multBin][kTbin]->Fill(Pair->GetMt()); // test @@ -340,21 +360,21 @@ struct FemtoCorrelations { if (_fillDetaDphi % 2 == 0) { if (!SE_or_ME) - DoubleTrack_SE_histos_BC[multBin][kTbin]->Fill(Pair->GetPhiStarDiff(_radiusTPC), Pair->GetEtaDiff()); + DoubleTrack_SE_histos_BC[multBin][kTbin]->Fill(_dPhiMode.value == 0 ? Pair->GetPhiStarDiff(_radiusTPC) : Pair->GetAvgPhiStarDiff(), Pair->GetEtaDiff()); else - DoubleTrack_ME_histos_BC[multBin][kTbin]->Fill(Pair->GetPhiStarDiff(_radiusTPC), Pair->GetEtaDiff()); + DoubleTrack_ME_histos_BC[multBin][kTbin]->Fill(_dPhiMode.value == 0 ? Pair->GetPhiStarDiff(_radiusTPC) : Pair->GetAvgPhiStarDiff(), Pair->GetEtaDiff()); } - if (_deta > 0 && _dphi > 0 && Pair->IsClosePair(_deta, _dphi, _radiusTPC)) + if (_deta > 0 && _dphi > 0 && (_dPhiMode.value == 0 ? Pair->IsClosePair(_deta, _dphi, _radiusTPC) : Pair->IsClosePair(_deta, _dphi))) continue; if (_avgSepTPC > 0 && Pair->IsClosePair(_avgSepTPC)) continue; if (_fillDetaDphi > 0) { if (!SE_or_ME) - DoubleTrack_SE_histos_AC[multBin][kTbin]->Fill(Pair->GetPhiStarDiff(_radiusTPC), Pair->GetEtaDiff()); + DoubleTrack_SE_histos_AC[multBin][kTbin]->Fill(_dPhiMode.value == 0 ? Pair->GetPhiStarDiff(_radiusTPC) : Pair->GetAvgPhiStarDiff(), Pair->GetEtaDiff()); else - DoubleTrack_ME_histos_AC[multBin][kTbin]->Fill(Pair->GetPhiStarDiff(_radiusTPC), Pair->GetEtaDiff()); + DoubleTrack_ME_histos_AC[multBin][kTbin]->Fill(_dPhiMode.value == 0 ? Pair->GetPhiStarDiff(_radiusTPC) : Pair->GetAvgPhiStarDiff(), Pair->GetEtaDiff()); } if (!SE_or_ME) { @@ -390,7 +410,7 @@ struct FemtoCorrelations { if (_particlePDG_1 == 0 || _particlePDG_2 == 0) LOGF(fatal, "One of passed PDG is 0!!!"); - for (auto track : tracks) { + for (const auto& track : tracks) { if (std::fabs(track.template singleCollSel_as>().posZ()) > _vertexZ) continue; if (_removeSameBunchPileup && !track.template singleCollSel_as>().isNoSameBunchPileup()) @@ -414,54 +434,28 @@ struct FemtoCorrelations { if (std::fabs(track.dcaXY()) > _dcaXY.value[0] + _dcaXY.value[1] * std::pow(track.pt(), _dcaXY.value[2]) || std::fabs(track.dcaZ()) > _dcaZ.value[0] + _dcaZ.value[1] * std::pow(track.pt(), _dcaZ.value[2])) continue; - if (track.sign() == _sign_1 && (track.p() < _PIDtrshld_1 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_1) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_1, _tpcNSigmaResidual_1.value))) { // filling the map: eventID <-> selected particles1 - selectedtracks_1[track.singleCollSelId()].push_back(std::make_shared(track)); + if (track.sign() == _sign_1 && (track.p() < _PIDtrshld_1 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_1, _itsNSigma_1.value) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_1, _tpcNSigmaResidual_1.value))) { // filling the map: eventID <-> selected particles1 + selectedtracks_1[track.singleCollSelId()].push_back(std::make_shared::iterator>(track)); - registry.fill(HIST("p_first"), track.p()); - if (_particlePDG_1 == 211) { - registry.fill(HIST("nsigmaTOF_first"), track.p(), track.tofNSigmaPi()); - registry.fill(HIST("nsigmaTPC_first"), track.p(), track.tpcNSigmaPi()); - } - if (_particlePDG_1 == 321) { - registry.fill(HIST("nsigmaTOF_first"), track.p(), track.tofNSigmaKa()); - registry.fill(HIST("nsigmaTPC_first"), track.p(), track.tpcNSigmaKa()); - } - if (_particlePDG_1 == 2212) { - registry.fill(HIST("nsigmaTOF_first"), track.p(), track.tofNSigmaPr()); - registry.fill(HIST("nsigmaTPC_first"), track.p(), track.tpcNSigmaPr()); - } - if (_particlePDG_1 == 1000010020) { - registry.fill(HIST("nsigmaTOF_first"), track.p(), track.tofNSigmaDe()); - registry.fill(HIST("nsigmaTPC_first"), track.p(), track.tpcNSigmaDe()); - } + pHisto_first->Fill(track.p()); + ITShisto_first->Fill(track.p(), o2::aod::singletrackselector::getITSNsigma(track, _particlePDG_1)); + TPChisto_first->Fill(track.p(), o2::aod::singletrackselector::getTPCNsigma(track, _particlePDG_1)); + TOFhisto_first->Fill(track.p(), o2::aod::singletrackselector::getTOFNsigma(track, _particlePDG_1)); } if (IsIdentical) { continue; - } else if (track.sign() != _sign_2 && !TOFselection(track, std::make_pair(_particlePDGtoReject, _rejectWithinNsigmaTOF)) && (track.p() < _PIDtrshld_2 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_2) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_2, _tpcNSigmaResidual_2.value))) { // filling the map: eventID <-> selected particles2 if (see condition above ^) - selectedtracks_2[track.singleCollSelId()].push_back(std::make_shared(track)); + } else if (track.sign() != _sign_2 && !TOFselection(track, std::make_pair(_particlePDGtoReject, _rejectWithinNsigmaTOF)) && (track.p() < _PIDtrshld_2 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_2, _itsNSigma_2.value) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_2, _tpcNSigmaResidual_2.value))) { // filling the map: eventID <-> selected particles2 if (see condition above ^) + selectedtracks_2[track.singleCollSelId()].push_back(std::make_shared::iterator>(track)); - registry.fill(HIST("p_second"), track.p()); - if (_particlePDG_2 == 211) { - registry.fill(HIST("nsigmaTOF_second"), track.p(), track.tofNSigmaPi()); - registry.fill(HIST("nsigmaTPC_second"), track.p(), track.tpcNSigmaPi()); - } - if (_particlePDG_2 == 321) { - registry.fill(HIST("nsigmaTOF_second"), track.p(), track.tofNSigmaKa()); - registry.fill(HIST("nsigmaTPC_second"), track.p(), track.tpcNSigmaKa()); - } - if (_particlePDG_2 == 2212) { - registry.fill(HIST("nsigmaTOF_second"), track.p(), track.tofNSigmaPr()); - registry.fill(HIST("nsigmaTPC_second"), track.p(), track.tpcNSigmaPr()); - } - if (_particlePDG_2 == 1000010020) { - registry.fill(HIST("nsigmaTOF_second"), track.p(), track.tofNSigmaDe()); - registry.fill(HIST("nsigmaTPC_second"), track.p(), track.tpcNSigmaDe()); - } + pHisto_second->Fill(track.p()); + ITShisto_second->Fill(track.p(), o2::aod::singletrackselector::getITSNsigma(track, _particlePDG_2)); + TPChisto_second->Fill(track.p(), o2::aod::singletrackselector::getTPCNsigma(track, _particlePDG_2)); + TOFhisto_second->Fill(track.p(), o2::aod::singletrackselector::getTOFNsigma(track, _particlePDG_2)); } } - for (auto collision : collisions) { + for (const auto& collision : collisions) { if (collision.multPerc() < *_centBins.value.begin() || collision.multPerc() >= *(_centBins.value.end() - 1)) continue; if (collision.hadronicRate() < _IRcut.value.first || collision.hadronicRate() >= _IRcut.value.second) @@ -489,7 +483,7 @@ struct FemtoCorrelations { int vertexBinToMix = std::floor((collision.posZ() + _vertexZ) / (2 * _vertexZ / _vertexNbinsToMix)); float centBinToMix = o2::aod::singletrackselector::getBinIndex(collision.multPerc(), _centBins, _multNsubBins); - mixbins[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); + mixbins[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared::iterator>(collision)); } //====================================== mixing starts here ====================================== diff --git a/PWGCF/Femto3D/Tasks/femto3dPairTaskMC.cxx b/PWGCF/Femto3D/Tasks/femto3dPairTaskMC.cxx index 4c095f134df..b776d34e629 100644 --- a/PWGCF/Femto3D/Tasks/femto3dPairTaskMC.cxx +++ b/PWGCF/Femto3D/Tasks/femto3dPairTaskMC.cxx @@ -14,6 +14,9 @@ /// \since 31 May 2023 #include +#include +#include +#include #include #include @@ -67,6 +70,7 @@ struct FemtoCorrelationsMC { Configurable _sign_1{"sign_1", 1, "sign of the first particle in a pair"}; Configurable _particlePDG_1{"particlePDG_1", 2212, "PDG code of the first particle in a pair to perform PID for (only pion, kaon, proton and deurton are supported now)"}; Configurable> _tpcNSigma_1{"tpcNSigma_1", std::vector{-3.0f, 3.0f}, "first particle PID: Nsigma range in TPC before the TOF is used"}; + Configurable> _itsNSigma_1{"itsNSigma_1", std::vector{-10.0f, 10.0f}, "first particle PID: Nsigma range in ITS with TPC is used"}; Configurable _PIDtrshld_1{"PIDtrshld_1", 10.0, "first particle PID: value of momentum from which the PID is done with TOF (before that only TPC is used)"}; Configurable> _tofNSigma_1{"tofNSigma_1", std::vector{-3.0f, 3.0f}, "first particle PID: Nsigma range in TOF"}; Configurable> _tpcNSigmaResidual_1{"tpcNSigmaResidual_1", std::vector{-5.0f, 5.0f}, "first particle PID: residual TPC Nsigma cut to use with the TOF"}; @@ -74,6 +78,7 @@ struct FemtoCorrelationsMC { Configurable _sign_2{"sign_2", 1, "sign of the second particle in a pair"}; Configurable _particlePDG_2{"particlePDG_2", 2212, "PDG code of the second particle in a pair to perform PID for (only pion, kaon, proton and deurton are supported now)"}; Configurable> _tpcNSigma_2{"tpcNSigma_2", std::vector{-3.0f, 3.0f}, "second particle PID: Nsigma range in TPC before the TOF is used"}; + Configurable> _itsNSigma_2{"itsNSigma_2", std::vector{-10.0f, 10.0f}, "first particle PID: Nsigma range in ITS with TPC is used"}; Configurable _PIDtrshld_2{"PIDtrshld_2", 10.0, "second particle PID: value of momentum from which the PID is done with TOF (before that only TPC is used)"}; Configurable> _tofNSigma_2{"tofNSigma_2", std::vector{-3.0f, 3.0f}, "second particle PID: Nsigma range in TOF"}; Configurable> _tpcNSigmaResidual_2{"tpcNSigmaResidual_2", std::vector{-5.0f, 5.0f}, "second particle PID: residual TPC Nsigma cut to use with the TOF"}; @@ -81,6 +86,7 @@ struct FemtoCorrelationsMC { Configurable _particlePDGtoReject{"particlePDGtoRejectFromSecond", 0, "applied only if the particles are non-identical and only to the second particle in the pair!!!"}; Configurable> _rejectWithinNsigmaTOF{"rejectWithinNsigmaTOF", std::vector{-0.0f, 0.0f}, "TOF rejection Nsigma range for the particle specified with PDG to be rejected"}; + Configurable _dPhiMode{"dPhiMode", 0, "Flag to choose how to calc. dphi*: 0 - at a fixed TPC radius; 1 - average over different TPC radii;"}; Configurable _radiusTPC{"radiusTPC", 1.2, "TPC radius to calculate phi_star for"}; Configurable _vertexNbinsToMix{"vertexNbinsToMix", 10, "Number of vertexZ bins for the mixing"}; @@ -100,7 +106,8 @@ struct FemtoCorrelationsMC { std::pair> TOFcuts_2; using FilteredCollisions = soa::Join; - using FilteredTracks = soa::Join; + using FilteredTracks = soa::Join; + // using FilteredTracks = soa::Join; typedef std::shared_ptr::iterator> trkType; typedef std::shared_ptr::iterator> colType; @@ -138,6 +145,8 @@ struct FemtoCorrelationsMC { void init(o2::framework::InitContext&) { + o2::aod::ITSResponse::setMCDefaultParameters(); // set MC parametrisation for the ITS PID + IsIdentical = (_sign_1 * _particlePDG_1 == _sign_2 * _particlePDG_2); Pair->SetIdentical(IsIdentical); @@ -249,7 +258,7 @@ struct FemtoCorrelationsMC { LOGF(fatal, "kTbin value obtained for a pair exceeds the configured number of kT bins"); kThistos[centBin][kTbin]->Fill(pair_kT); - DoubleTrack_SE_histos[centBin][kTbin]->Fill(Pair->GetPhiStarDiff(_radiusTPC), Pair->GetEtaDiff()); + DoubleTrack_SE_histos[centBin][kTbin]->Fill(_dPhiMode.value == 0 ? Pair->GetPhiStarDiff(_radiusTPC) : Pair->GetAvgPhiStarDiff(), Pair->GetEtaDiff()); AvgSep_SE_histos[centBin][kTbin]->Fill(Pair->GetAvgSep()); Pair->ResetPair(); } @@ -273,7 +282,7 @@ struct FemtoCorrelationsMC { LOGF(fatal, "kTbin value obtained for a pair exceeds the configured number of kT bins"); kThistos[centBin][kTbin]->Fill(pair_kT); - DoubleTrack_SE_histos[centBin][kTbin]->Fill(Pair->GetPhiStarDiff(_radiusTPC), Pair->GetEtaDiff()); + DoubleTrack_SE_histos[centBin][kTbin]->Fill(_dPhiMode.value == 0 ? Pair->GetPhiStarDiff(_radiusTPC) : Pair->GetAvgPhiStarDiff(), Pair->GetEtaDiff()); AvgSep_SE_histos[centBin][kTbin]->Fill(Pair->GetAvgSep()); Pair->ResetPair(); } @@ -296,7 +305,7 @@ struct FemtoCorrelationsMC { if (kTbin > Resolution_histos[centBin].size() || kTbin > DoubleTrack_ME_histos[centBin].size()) LOGF(fatal, "kTbin value obtained for a pair exceeds the configured number of kT bins"); - DoubleTrack_ME_histos[centBin][kTbin]->Fill(Pair->GetPhiStarDiff(_radiusTPC), Pair->GetEtaDiff()); + DoubleTrack_ME_histos[centBin][kTbin]->Fill(_dPhiMode.value == 0 ? Pair->GetPhiStarDiff(_radiusTPC) : Pair->GetAvgPhiStarDiff(), Pair->GetEtaDiff()); AvgSep_ME_histos[centBin][kTbin]->Fill(Pair->GetAvgSep()); if (abs(ii->pdgCode()) != _particlePDG_1.value || abs(iii->pdgCode()) != _particlePDG_2.value) @@ -344,7 +353,7 @@ struct FemtoCorrelationsMC { unsigned int centBin = o2::aod::singletrackselector::getBinIndex(track.template singleCollSel_as>().multPerc(), _centBins); - if (track.sign() == _sign_1 && (track.p() < _PIDtrshld_1 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_1) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_1, _tpcNSigmaResidual_1.value))) { + if (track.sign() == _sign_1 && (track.p() < _PIDtrshld_1 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_1, _itsNSigma_1.value) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_1, _tpcNSigmaResidual_1.value))) { trackOrigin = track.origin(); @@ -365,7 +374,7 @@ struct FemtoCorrelationsMC { if (IsIdentical) { continue; - } else if (track.sign() != _sign_2 && !TOFselection(track, std::make_pair(_particlePDGtoReject, _rejectWithinNsigmaTOF)) && (track.p() < _PIDtrshld_2 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_2) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_2, _tpcNSigmaResidual_2.value))) { // filling the map: eventID <-> selected particles2 if (see condition above ^) + } else if (track.sign() != _sign_2 && !TOFselection(track, std::make_pair(_particlePDGtoReject, _rejectWithinNsigmaTOF)) && (track.p() < _PIDtrshld_2 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_2, _itsNSigma_2.value) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_2, _tpcNSigmaResidual_2.value))) { // filling the map: eventID <-> selected particles2 if (see condition above ^) trackOrigin = track.origin(); diff --git a/PWGCF/Femto3D/Tasks/femto3dQA.cxx b/PWGCF/Femto3D/Tasks/femto3dQA.cxx index e544b1bdacb..64858324b48 100644 --- a/PWGCF/Femto3D/Tasks/femto3dQA.cxx +++ b/PWGCF/Femto3D/Tasks/femto3dQA.cxx @@ -13,6 +13,10 @@ /// \author Sofia Tomassini, Gleb Romanenko, Nicolò Jacazio /// \since 31 May 2023 +#include +#include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" @@ -28,6 +32,7 @@ #include "Framework/StaticFor.h" #include "PWGCF/Femto3D/DataModel/singletrackselector.h" +#include "PWGCF/Femto3D/Core/femto3dPairTask.h" using namespace o2; using namespace o2::soa; @@ -40,6 +45,8 @@ struct QAHistograms { /// Construct a registry object with direct declaration HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable _isMC{"isMC", false, ""}; + Configurable _removeSameBunchPileup{"removeSameBunchPileup", false, ""}; Configurable _requestGoodZvtxFT0vsPV{"requestGoodZvtxFT0vsPV", false, ""}; Configurable _requestVertexITSTPC{"requestVertexITSTPC", false, ""}; @@ -63,6 +70,7 @@ struct QAHistograms { Configurable _itsChi2NCl{"itsChi2NCl", 100.0, "upper limit for chi2 value of a fit over ITS clasters for a track"}; Configurable _particlePDG{"particlePDG", 2212, "PDG code of a particle to perform PID for (only pion, kaon, proton and deurton are supported now)"}; Configurable> _tpcNSigma{"tpcNSigma", std::vector{-4.0f, 4.0f}, "Nsigma range in TPC before the TOF is used"}; + Configurable> _itsNSigma{"itsNSigma", std::vector{-10.0f, 10.0f}, "Nsigma range in ITS to use along with TPC"}; Configurable _PIDtrshld{"PIDtrshld", 10.0, "value of momentum from which the PID is done with TOF (before that only TPC is used)"}; Configurable> _tofNSigma{"tofNSigma", std::vector{-4.0f, 4.0f}, "Nsigma range in TOF"}; Configurable> _tpcNSigmaResidual{"tpcNSigmaResidual", std::vector{-5.0f, 5.0f}, "residual TPC Nsigma cut to use with the TOF"}; @@ -72,9 +80,15 @@ struct QAHistograms { Configurable> _centCut{"centCut", std::pair{0.f, 100.f}, "[min., max.] centrality range to keep tracks within"}; + Configurable> _dcaBinning{"dcaBinning", std::vector{501, 0.5f, 1}, "setup for variable binning (geometric progression is used): 1st (int) -- N_bins (must be odd, otherwise will be increased by 1); 2nd (float) -- abs value of the edge of axises in histos (-2nd, +2nd); 3d (int) -- desired ratio between w_bin at the edges and at 0;"}; + std::pair> TPCcuts; std::pair> TOFcuts; + std::shared_ptr ITShisto; + std::shared_ptr TPChisto; + std::shared_ptr TOFhisto; + Filter signFilter = o2::aod::singletrackselector::sign == _sign; Filter pFilter = o2::aod::singletrackselector::p > _min_P&& o2::aod::singletrackselector::p < _max_P; Filter etaFilter = nabs(o2::aod::singletrackselector::eta) < _eta; @@ -89,9 +103,37 @@ struct QAHistograms { void init(o2::framework::InitContext&) { + + if (_isMC.value) + o2::aod::ITSResponse::setMCDefaultParameters(); // set MC parametrisation for the ITS PID + TPCcuts = std::make_pair(_particlePDG, _tpcNSigma); TOFcuts = std::make_pair(_particlePDG, _tofNSigma); + int N = _dcaBinning.value[0]; // number of bins -- must be odd otherwise will be increased by 1 + if (N % 2 != 1) { + N += 1; + } + + std::unique_ptr dca_bins; + if (static_cast(_dcaBinning.value[2]) != 1.0) { + dca_bins = calc_var_bins(N + 1, _dcaBinning.value[1], static_cast(_dcaBinning.value[2])); + } else { + dca_bins = calc_const_bins(N, -_dcaBinning.value[1], _dcaBinning.value[1]); + } + auto const_bins_p = calc_const_bins(100, 0., 5.0); + + auto DCA_XY_p = registry.add("dcaxy_to_p", "dcaxy_to_p", kTH2F, {{100, 0., 5.0, "p"}, {501, -0.5, 0.5, "dcaxy"}}); + auto DCA_XY_pt = registry.add("dcaxy_to_pt", "dcaxy_to_pt", kTH2F, {{100, 0., 5.0, "pt"}, {501, -0.5, 0.5, "dcaxy"}}); + + auto DCA_Z_p = registry.add("dcaz_to_p", "dcaz_to_p", kTH2F, {{100, 0., 5.0, "p"}, {501, -0.5, 0.5, "dcaz"}}); + auto DCA_Z_pt = registry.add("dcaz_to_pt", "dcaz_to_pt", kTH2F, {{100, 0., 5.0, "pt"}, {501, -0.5, 0.5, "dcaz"}}); + + DCA_XY_p->SetBins(100, &const_bins_p[0], N, &dca_bins[0]); // set variable bins in Y and Z axis; constant on X + DCA_XY_pt->SetBins(100, &const_bins_p[0], N, &dca_bins[0]); // set variable bins in Y and Z axis; constant on X + DCA_Z_p->SetBins(100, &const_bins_p[0], N, &dca_bins[0]); // set variable bins in Y and Z axis; constant on X + DCA_Z_pt->SetBins(100, &const_bins_p[0], N, &dca_bins[0]); // set variable bins in Y and Z axis; constant on X + registry.add("TPCSignal_nocuts", "TPC signal without cuts", kTH2F, {{{200, 0., 5.0, "#it{p}_{inner} (GeV/#it{c})"}, {1000, 0., 1000.0, "dE/dx in TPC (arbitrary units)"}}}); registry.add("TOFSignal_nocuts", "TOF signal without cuts", kTH2F, {{{200, 0., 5.0, "#it{p} (GeV/#it{c})"}, {100, 0., 1.5, "#beta"}}}); @@ -103,10 +145,6 @@ struct QAHistograms { registry.add("p", "p", kTH1F, {{100, 0., 5., "p"}}); registry.add("pt", "pt", kTH1F, {{100, 0., 5., "pt"}}); registry.add("sign", "sign", kTH1F, {{3, -1.5, 1.5, "sign"}}); - registry.add("dcaxy_to_p", "dcaxy_to_p", kTH2F, {{100, 0., 5.0, "p"}, {501, -0.5, 0.5, "dcaxy"}}); - registry.add("dcaxy_to_pt", "dcaxy_to_pt", kTH2F, {{100, 0., 5., "pt"}, {501, -0.5, 0.5, "dcaxy"}}); - registry.add("dcaz_to_p", "dcaz_to_p", kTH2F, {{100, 0., 5., "p"}, {501, -0.5, 0.5, "dcaz"}}); - registry.add("dcaz_to_pt", "dcaz_to_pt", kTH2F, {{100, 0., 5., "pt"}, {501, -0.5, 0.5, "dcaz"}}); registry.add("TPCClusters", "TPCClusters", kTH1F, {{163, -0.5, 162.5, "NTPCClust"}}); registry.add("TPCCrossedRowsOverFindableCls", "TPCCrossedRowsOverFindableCls", kTH1F, {{100, 0.0, 10.0, "NcrossedRowsOverFindable"}}); registry.add("TPCFractionSharedCls", "TPCFractionSharedCls", kTH1F, {{100, 0.0, 1.0, "TPCsharedFraction"}}); @@ -117,26 +155,9 @@ struct QAHistograms { registry.add("TPCSignal", "TPC Signal", kTH2F, {{{200, 0., 5.0, "#it{p}_{inner} (GeV/#it{c})"}, {1000, 0., 1000.0, "dE/dx in TPC (arbitrary units)"}}}); registry.add("TOFSignal", "TOF Signal", kTH2F, {{200, 0., 5.0, "#it{p} (GeV/#it{c})"}, {100, 0., 1.5, "#beta"}}); - switch (_particlePDG) { - case 211: - registry.add("nsigmaTOFPi", "nsigmaTOFPi", kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - registry.add("nsigmaTPCPi", "nsigmaTPCPi", kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - break; - case 321: - registry.add("nsigmaTOFKa", "nsigmaTOFKa", kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - registry.add("nsigmaTPCKa", "nsigmaTPCKa", kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - break; - case 2212: - registry.add("nsigmaTOFPr", "nsigmaTOFPr", kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - registry.add("nsigmaTPCPr", "nsigmaTPCPr", kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - break; - case 1000010020: - registry.add("nsigmaTOFDe", "nsigmaTOFDe", kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - registry.add("nsigmaTPCDe", "nsigmaTPCDe", kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); - break; - default: - break; - } + ITShisto = registry.add(Form("nsigmaITS_PDG%i", _particlePDG.value), Form("nsigmaITS_PDG%i", _particlePDG.value), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); + TPChisto = registry.add(Form("nsigmaTPC_PDG%i", _particlePDG.value), Form("nsigmaTPC_PDG%i", _particlePDG.value), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); + TOFhisto = registry.add(Form("nsigmaTOF_PDG%i", _particlePDG.value), Form("nsigmaTOF_PDG%i", _particlePDG.value), kTH2F, {{100, 0., 5.}, {100, -10., 10.}}); const AxisSpec axisMult{5001, -0.5, 5000.5, "mult."}; const AxisSpec axisPerc{101, -0.5, 100.5, "percentile"}; @@ -173,7 +194,7 @@ struct QAHistograms { registry.fill(HIST("IRvsOccupancy"), collision.occupancy(), collision.hadronicRate()); } - for (auto& track : tracks) { + for (const auto& track : tracks) { if (_removeSameBunchPileup && !track.template singleCollSel_as().isNoSameBunchPileup()) continue; @@ -204,7 +225,7 @@ struct QAHistograms { registry.fill(HIST("TOFSignal_nocuts"), track.p(), track.beta()); } - if (!TOFselection(track, std::make_pair(_particlePDGtoReject, _rejectWithinNsigmaTOF)) && (track.p() < _PIDtrshld ? o2::aod::singletrackselector::TPCselection(track, TPCcuts) : o2::aod::singletrackselector::TOFselection(track, TOFcuts, _tpcNSigmaResidual.value))) { + if (!TOFselection(track, std::make_pair(_particlePDGtoReject, _rejectWithinNsigmaTOF)) && (track.p() < _PIDtrshld ? o2::aod::singletrackselector::TPCselection(track, TPCcuts, _itsNSigma.value) : o2::aod::singletrackselector::TOFselection(track, TOFcuts, _tpcNSigmaResidual.value))) { registry.fill(HIST("eta"), track.eta()); registry.fill(HIST("phi"), track.phi()); registry.fill(HIST("px"), track.px()); @@ -224,26 +245,9 @@ struct QAHistograms { registry.fill(HIST("ITSchi2"), track.itsChi2NCl()); registry.fill(HIST("TPCchi2"), track.tpcChi2NCl()); - switch (_particlePDG) { - case 211: - registry.fill(HIST("nsigmaTOFPi"), track.p(), track.tofNSigmaPi()); - registry.fill(HIST("nsigmaTPCPi"), track.p(), track.tpcNSigmaPi()); - break; - case 321: - registry.fill(HIST("nsigmaTOFKa"), track.p(), track.tofNSigmaKa()); - registry.fill(HIST("nsigmaTPCKa"), track.p(), track.tpcNSigmaKa()); - break; - case 2212: - registry.fill(HIST("nsigmaTOFPr"), track.p(), track.tofNSigmaPr()); - registry.fill(HIST("nsigmaTPCPr"), track.p(), track.tpcNSigmaPr()); - break; - case 1000010020: - registry.fill(HIST("nsigmaTOFDe"), track.p(), track.tofNSigmaDe()); - registry.fill(HIST("nsigmaTPCDe"), track.p(), track.tpcNSigmaDe()); - break; - default: - break; - } + ITShisto->Fill(track.p(), o2::aod::singletrackselector::getITSNsigma(track, _particlePDG)); + TPChisto->Fill(track.p(), o2::aod::singletrackselector::getTPCNsigma(track, _particlePDG)); + TOFhisto->Fill(track.p(), o2::aod::singletrackselector::getTOFNsigma(track, _particlePDG)); if constexpr (FillExtra) { registry.fill(HIST("TPCSignal"), track.tpcInnerParam(), track.tpcSignal()); @@ -253,13 +257,15 @@ struct QAHistograms { } } - void processDefault(soa::Filtered> const& collisions, soa::Filtered const& tracks) + // void processDefault(soa::Filtered> const& collisions, soa::Filtered> const& tracks) // main + void processDefault(soa::Filtered> const& collisions, soa::Filtered> const& tracks) // tmp solution till the HL is fixed { fillHistograms(collisions, tracks); } PROCESS_SWITCH(QAHistograms, processDefault, "process default", true); - void processExtra(soa::Filtered> const& collisions, soa::Filtered> const& tracks) + // void processExtra(soa::Filtered> const& collisions, soa::Filtered> const& tracks) // main + void processExtra(soa::Filtered> const& collisions, soa::Filtered> const& tracks) // tmp solution till the HL is fixed { fillHistograms(collisions, tracks); } diff --git a/PWGCF/FemtoDream/CMakeLists.txt b/PWGCF/FemtoDream/CMakeLists.txt index d9a4175dd3a..549fb52a6f6 100644 --- a/PWGCF/FemtoDream/CMakeLists.txt +++ b/PWGCF/FemtoDream/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2024 CERN and copyright holders of ALICE O2. +# Copyright 2019-2025 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. # diff --git a/PWGCF/FemtoDream/Core/CMakeLists.txt b/PWGCF/FemtoDream/Core/CMakeLists.txt index 4c182222bf2..da01f4ab983 100644 --- a/PWGCF/FemtoDream/Core/CMakeLists.txt +++ b/PWGCF/FemtoDream/Core/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2024 CERN and copyright holders of ALICE O2. +# Copyright 2019-2025 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. # diff --git a/PWGCF/FemtoDream/Core/femtoDreamCascadeSelection.h b/PWGCF/FemtoDream/Core/femtoDreamCascadeSelection.h new file mode 100644 index 00000000000..2a07c851d09 --- /dev/null +++ b/PWGCF/FemtoDream/Core/femtoDreamCascadeSelection.h @@ -0,0 +1,695 @@ +// Copyright 2019-2025 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. + +/// \file femtoDreamCascadeSelection.h +/// \brief Definition of the femtoDreamCascadeSelection +/// \author Valentina Mantovani Sarti, TU München valentina.mantovani-sarti@tum.de +/// \author Andi Mathis, TU München, andreas.mathis@ph.tum.de +/// \author Luca Barioglio, TU München, luca.barioglio@cern.ch +/// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch +/// \author Barbara Chytla, WUT Warsaw, barbara.chytla@cern.ch +/// \author Shirajum Monira, WUT Warsaw, shirajum.monira@cern.ch +/// \author Georgios Mantzaridis, TU München, georgios.mantzaridis@tum.de + +#ifndef PWGCF_FEMTODREAM_CORE_FEMTODREAMCASCADESELECTION_H_ +#define PWGCF_FEMTODREAM_CORE_FEMTODREAMCASCADESELECTION_H_ + +#include +#include +#include + +#include // FIXME + +#include "PWGCF/FemtoDream/Core/femtoDreamObjectSelection.h" +#include "PWGCF/FemtoDream/Core/femtoDreamSelection.h" +#include "PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h" + +#include "Common/Core/RecoDecay.h" +#include "Framework/HistogramRegistry.h" +#include "ReconstructionDataFormats/PID.h" + +using namespace o2::framework; + +namespace o2::analysis::femtoDream +{ +namespace femtoDreamCascadeSelection +{ +/// The different selections this task is capable of doing +enum CascadeSel { + kCascadeSign, ///< +1 particle, -1 antiparticle + kCascadePtMin, + kCascadePtMax, + kCascadeEtaMax, + kCascadeDCADaughMax, + kCascadeCPAMin, + kCascadeTranRadMin, + kCascadeTranRadMax, + kCascadeDecVtxMax, + kCascadeV0DCADaughMax, + kCascadeV0CPAMin, + kCascadeV0TranRadMin, + kCascadeV0TranRadMax, + kCascadeV0DCAtoPVMin, + kCascadeV0DCAtoPVMax +}; + +enum ChildTrackType { kPosTrack, + kNegTrack, + kBachTrack }; + +enum CascadeContainerPosition { + kCascade, + kPosCuts, + kPosPID, + kNegCuts, + kNegPID, + kBachCuts, + kBachPID, +}; /// Position in the full VO cut container (for cutculator) + +} // namespace femtoDreamCascadeSelection + +/// \class FemtoDreamCascadeSelection +/// \brief Cut class to contain and execute all cuts applied to Cascades +class FemtoDreamCascadeSelection + : public FemtoDreamObjectSelection +{ + public: + FemtoDreamCascadeSelection() + : nCascadePtMin(0), + nCascadePtMax(0), + nCascadeEtaMax(0), + nCascadeDCADaughMax(0), + nCascadeCPAMin(0), + nCascadeTranRadMin(0), + nCascadeTranRadMax(0), + nCascadeDecVtxMax(0), + nCascadeV0DCADaughMax(0), + nCascadeV0CPAMin(0), + nCascadeV0TranRadMin(0), + nCascadeV0TranRadMax(0), + nCascadeV0DCAToPVMin(0), + nCascadeV0DCAToPVMax(0), + + fCascadePtMin(9999999), + fCascadePtMax(-9999999), + fCascadeEtaMax(-9999999), + fCascadeDCADaughMax(-9999999), + fCascadeCPAMin(9999999), + fCascadeTranRadMin(9999999), + fCascadeTranRadMax(-9999999), + fCascadeDecVtxMax(-9999999), + fCascadeV0DCADaughMax(-9999999), + fCascadeV0CPAMin(9999999), + fCascadeV0TranRadMin(9999999), + fCascadeV0TranRadMax(-9999999), + fCascadeV0DCAToPVMin(9999999), + fCascadeV0DCAToPVMax(-9999999), + + fV0InvMassLowLimit(1.05), + fV0InvMassUpLimit(1.3), + fInvMassLowLimit(1.25), + fInvMassUpLimit(1.4), + fRejectCompetingMass(false), + fInvMassCompetingLowLimit(1.5), + fInvMassCompetingUpLimit(2.0), + isCascOmega(false) + { + } + + /// Initializes histograms for the task + template + void init(HistogramRegistry* QAregistry, HistogramRegistry* Registry, bool isSelectCascOmega = false); + + template + bool isSelectedMinimal(Col const& col, Casc const& cascade, Track const& posTrack, Track const& negTrack, Track const& bachTrack); + + template + void fillQA(Col const& col, Casc const& cascade, Track const& posTrack, Track const& negTrack, Track const& bachTrack); + + // template + // std::array getCutContainer(Col const& col, Casc const& casc, V0 const& v0Daugh, Track const& posTrack, Track const& negTrack, Track const& bachTrack); + template + std::array getCutContainer(Col const& col, Casc const& casc, Track const& posTrack, Track const& negTrack, Track const& bachTrack); + + template + void setChildCuts(femtoDreamCascadeSelection::ChildTrackType child, + T1 selVal, + T2 selVar, + femtoDreamSelection::SelectionType selType) + { + if (child == femtoDreamCascadeSelection::kPosTrack) { + PosDaughTrack.setSelection(selVal, selVar, selType); + } else if (child == femtoDreamCascadeSelection::kNegTrack) { + NegDaughTrack.setSelection(selVal, selVar, selType); + } else if (child == femtoDreamCascadeSelection::kBachTrack) { + BachDaughTrack.setSelection(selVal, selVar, selType); + } + } + + template + void setChildPIDSpecies(femtoDreamCascadeSelection::ChildTrackType child, + T& pids) + { + if (child == femtoDreamCascadeSelection::kPosTrack) { + PosDaughTrack.setPIDSpecies(pids); + } else if (child == femtoDreamCascadeSelection::kNegTrack) { + NegDaughTrack.setPIDSpecies(pids); + } else if (child == femtoDreamCascadeSelection::kBachTrack) { + BachDaughTrack.setPIDSpecies(pids); + } + } + + /// Helper function to obtain the name of a given selection criterion for consistent naming of the configurables + /// \param iSel Track selection variable to be examined + /// \param prefix Additional prefix for the name of the configurable + /// \param suffix Additional suffix for the name of the configurable + static std::string getSelectionName(femtoDreamCascadeSelection::CascadeSel iSel, + std::string_view prefix = "", + std::string_view suffix = "") + { + std::string outString = static_cast(prefix); + outString += static_cast(mSelectionNames[iSel]); + outString += suffix; + return outString; + } + + /// Helper function to obtain the index of a given selection variable for consistent naming of the configurables + /// \param obs Cascade selection variable (together with prefix) got from file + /// \param prefix Additional prefix for the output of the configurable + static int findSelectionIndex(const std::string_view& obs, + std::string_view prefix = "") + { + for (int index = 0; index < kNcascadeSelection; index++) { + std::string comp = static_cast(prefix) + + static_cast(mSelectionNames[index]); + std::string_view cmp{comp}; + if (obs.compare(cmp) == 0) + return index; + } + LOGF(info, "Variable %s not found", obs); + return -1; + } + + /// Helper function to obtain the type of a given selection variable for consistent naming of the configurables + /// \param iSel Casc selection variable whose type is returned + static femtoDreamSelection::SelectionType getSelectionType(femtoDreamCascadeSelection::CascadeSel iSel) + { + return mSelectionTypes[iSel]; + } + + /// Helper function to obtain the helper string of a given selection criterion + /// for consistent description of the configurables + /// \param iSel Track selection variable to be examined + /// \param prefix Additional prefix for the output of the configurable + static std::string getSelectionHelper(femtoDreamCascadeSelection::CascadeSel iSel, + std::string_view prefix = "") + { + std::string outString = static_cast(prefix); + outString += static_cast(mSelectionHelper[iSel]); + return outString; + } + + /// Set limit for the selection on the invariant mass + /// \param lowLimit Lower limit for the invariant mass distribution + /// \param upLimit Upper limit for the invariant mass distribution + void setInvMassLimits(float lowLimit, float upLimit) + { + fInvMassLowLimit = lowLimit; + fInvMassUpLimit = upLimit; + } + + void setV0InvMassLimits(float lowLimit, float upLimit) + { + fV0InvMassLowLimit = lowLimit; + fV0InvMassUpLimit = upLimit; + } + + /// Set limit for the omega rejection on the invariant mass + /// \param lowLimit Lower limit for the invariant mass distribution + /// \param upLimit Upper limit for the invariant mass distribution + void setCompetingInvMassLimits(float lowLimit, float upLimit) + { + fRejectCompetingMass = true; + fInvMassCompetingLowLimit = lowLimit; + fInvMassCompetingUpLimit = upLimit; + } + + private: + int nCascadePtMin; + int nCascadePtMax; + int nCascadeEtaMax; + int nCascadeDCADaughMax; + int nCascadeCPAMin; + int nCascadeTranRadMin; + int nCascadeTranRadMax; + int nCascadeDecVtxMax; + + int nCascadeV0DCADaughMax; + int nCascadeV0CPAMin; + int nCascadeV0TranRadMin; + int nCascadeV0TranRadMax; + int nCascadeV0DCAToPVMin; + int nCascadeV0DCAToPVMax; + + float fCascadePtMin; + float fCascadePtMax; + float fCascadeEtaMax; + float fCascadeDCADaughMax; + float fCascadeCPAMin; + float fCascadeTranRadMin; + float fCascadeTranRadMax; + float fCascadeDecVtxMax; + + float fCascadeV0DCADaughMax; + float fCascadeV0CPAMin; + float fCascadeV0TranRadMin; + float fCascadeV0TranRadMax; + float fCascadeV0DCAToPVMin; + float fCascadeV0DCAToPVMax; + + float fV0InvMassLowLimit; + float fV0InvMassUpLimit; + + float fInvMassLowLimit; + float fInvMassUpLimit; + + float fRejectCompetingMass; + float fInvMassCompetingLowLimit; + float fInvMassCompetingUpLimit; + + bool isCascOmega; + + // float nSigmaPIDOffsetTPC; + + FemtoDreamTrackSelection PosDaughTrack; + FemtoDreamTrackSelection NegDaughTrack; + FemtoDreamTrackSelection BachDaughTrack; + + static constexpr int kNcascadeSelection = 16; + + static constexpr std::string_view mSelectionNames[kNcascadeSelection] = { + "Sign", "PtMin", "PtMax", "EtaMax", "DCADaughMax", "CPAMin", "TranRadMin", "TranRadMax", "DecVtxMax", // Cascade Selections + "DCAv0daughMax", "v0CPAMin", "v0TranRadMin", "v0TranRadMax", "V0DCAToPVMin", "V0DCAToPVMax"}; // CascadeV0 selections + + static constexpr femtoDreamSelection::SelectionType + mSelectionTypes[kNcascadeSelection]{ + femtoDreamSelection::kEqual, // sign + femtoDreamSelection::kLowerLimit, // pt min + femtoDreamSelection::kUpperLimit, // pt max + femtoDreamSelection::kUpperLimit, // eta max + femtoDreamSelection::kUpperLimit, // DCA cascade daughters max + femtoDreamSelection::kLowerLimit, // cascade cos PA min + femtoDreamSelection::kLowerLimit, // cascade tran rad min + femtoDreamSelection::kUpperLimit, // cascade tran rad max + femtoDreamSelection::kUpperLimit, // cascade maximum distance of decay vertex to PV + femtoDreamSelection::kUpperLimit, // v0 daughters DCA max + femtoDreamSelection::kLowerLimit, // v0 cos PA min + femtoDreamSelection::kLowerLimit, // v0 tran rad min + femtoDreamSelection::kUpperLimit, // v0 tran rad max + femtoDreamSelection::kLowerLimit, // v0 minimum distance of decay vertex to PV + femtoDreamSelection::kUpperLimit // v0 maximum distance of decay vertex to PV + + }; ///< Map to match a variable with + ///< its type + + static constexpr std::string_view mSelectionHelper[kNcascadeSelection] = { + "Cascade particle sign (+1 or -1)", + "Minimum pT (GeV/c)", + "Maximum pT (GeV/c)", + "Maximum |Eta|", + "Maximum DCA between cascade daughters (cm)", + "Minimum Cosine of Pointing Angle for cascade", + "Minimum cascade transverse radius (cm)", + "Maximum cascade transverse radius (cm)", + "Maximum distance of cascade from primary vertex", + "Maximum DCA between v0 daughters (cm)", + "Minimum Cosine of Pointing Angle for v0", + "Minimum v0 transverse radius (cm)", + "Maximum v0 transverse radius (cm)", + "Minimum distance of v0 from primary vertex", + "Maximum distance of v0 from primary vertex" + + //"Minimum V0 mass", + //"Maximum V0 mass" + }; ///< Helper information for the + ///< different selections + + static constexpr int kNcutStages = 2; + static constexpr std::string_view mCutStage[kNcutStages] = {"BeforeSel", "AfterSel"}; +}; // namespace femtoDream + +template +void FemtoDreamCascadeSelection::init(HistogramRegistry* QAregistry, HistogramRegistry* Registry, bool isSelectCascOmega) +{ + + if (QAregistry && Registry) { + mHistogramRegistry = Registry; + mQAHistogramRegistry = QAregistry; + // fillSelectionHistogram(); // cascade + // fillSelectionHistogram(); // pos, neg + // fillSelectionHistogram(); // bach + + AxisSpec ptAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec etaAxis = {100, -2.0f, 2.0f, "#it{#eta}"}; + AxisSpec phiAxis = {100, 0.0f, 6.0f, "#it{#phi}"}; + AxisSpec DCADaughAxis = {1000, 0.0f, 2.0f, "DCA (cm)"}; + AxisSpec CPAAxis = {1000, 0.95f, 1.0f, "#it{cos #theta_{p}}"}; + AxisSpec tranRadAxis = {1000, 0.0f, 100.0f, "#it{r}_{xy} (cm)"}; + AxisSpec decVtxAxis = {2000, 0, 200, "#it{Vtx}_{z} (cm)"}; + AxisSpec massAxisCascade = {2200, 1.25f, 1.8f, "m_{#Cascade} (GeV/#it{c}^{2})"}; + + AxisSpec DCAToPVAxis = {1000, -10.0f, 10.0f, "DCA to PV (cm)"}; + + AxisSpec massAxisV0 = {600, 0.0f, 3.0f, "m_{#V0} (GeV/#it{c}^{2})"}; + + /// \todo this should be an automatic check in the parent class, and the + /// return type should be templated + size_t nSelections = getNSelections(); + if (nSelections > 8 * sizeof(cutContainerType)) { + LOGF(info, "Number of selections %i", nSelections); + LOG(fatal) << "FemtoDreamCascadeCuts: Number of selections to large for your " + "container - quitting!"; + } + + std::string folderName = static_cast(o2::aod::femtodreamparticle::ParticleTypeName[part]); + for (int istage = 0; istage < kNcutStages; istage++) { + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hSign").c_str(), "; Sign of the Cascade ; Entries", kTH1I, {{3, -1, 2}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hPt").c_str(), "; #it{p}_{T} (GeV/#it{c}); Entries", kTH1F, {{1000, 0, 10}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hEta").c_str(), "; #eta; Entries", kTH1F, {{1000, -1, 1}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hPhi").c_str(), "; #phi; Entries", kTH1F, {{1000, 0, 2. * M_PI}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hDCADaugh").c_str(), "; daughters DCA; Entries", kTH1F, {DCADaughAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hCPA").c_str(), "; Cos PA; Entries", kTH1F, {CPAAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hTranRad").c_str(), "; Transverse Radius; Entries", kTH1F, {tranRadAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hDecVtxX").c_str(), "; Decay vertex x position; Entries", kTH1F, {tranRadAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hDecVtxY").c_str(), "; Decay vertex y position; Entries", kTH1F, {tranRadAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hDecVtxZ").c_str(), "; Decay vertex z position; Entries", kTH1F, {tranRadAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hInvMass").c_str(), "; Invariant mass; Entries", kTH1F, {massAxisCascade}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hV0DCADaugh").c_str(), "; V0-daughters DCA; Entries", kTH1F, {DCADaughAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hV0CPA").c_str(), "; V0 cos PA; Entries", kTH1F, {CPAAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hV0TranRad").c_str(), "; V0 transverse radius; Entries", kTH1F, {tranRadAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hV0DCAToPV").c_str(), "; DCA of the V0 to the PV; Entries", kTH1F, {DCAToPVAxis}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hV0InvMass").c_str(), "; Invariant mass Cascade V0; Entries", kTH1F, {massAxisV0}); + } + + PosDaughTrack.init(mQAHistogramRegistry, mHistogramRegistry); + + NegDaughTrack.init(mQAHistogramRegistry, mHistogramRegistry); + + BachDaughTrack.init(mQAHistogramRegistry, mHistogramRegistry); + } + + /// check whether the most open cuts are fulfilled - most of this should have + /// already be done by the filters + nCascadePtMin = getNSelections(femtoDreamCascadeSelection::kCascadePtMin); + nCascadePtMax = getNSelections(femtoDreamCascadeSelection::kCascadePtMax); + nCascadeEtaMax = getNSelections(femtoDreamCascadeSelection::kCascadeEtaMax); + nCascadeDCADaughMax = getNSelections(femtoDreamCascadeSelection::kCascadeDCADaughMax); + nCascadeCPAMin = getNSelections(femtoDreamCascadeSelection::kCascadeCPAMin); + nCascadeTranRadMin = getNSelections(femtoDreamCascadeSelection::kCascadeTranRadMin); + nCascadeTranRadMax = getNSelections(femtoDreamCascadeSelection::kCascadeTranRadMax); + nCascadeDecVtxMax = getNSelections(femtoDreamCascadeSelection::kCascadeDecVtxMax); + + nCascadeV0DCADaughMax = getNSelections(femtoDreamCascadeSelection::kCascadeV0DCADaughMax); + nCascadeV0CPAMin = getNSelections(femtoDreamCascadeSelection::kCascadeV0CPAMin); + nCascadeV0TranRadMin = getNSelections(femtoDreamCascadeSelection::kCascadeV0TranRadMin); + nCascadeV0TranRadMax = getNSelections(femtoDreamCascadeSelection::kCascadeV0TranRadMax); + + nCascadeV0DCAToPVMin = getNSelections(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMin); + nCascadeV0DCAToPVMax = getNSelections(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMax); + + fCascadePtMin = getMinimalSelection(femtoDreamCascadeSelection::kCascadePtMin, + femtoDreamSelection::kLowerLimit); + fCascadePtMax = getMinimalSelection(femtoDreamCascadeSelection::kCascadePtMax, + femtoDreamSelection::kUpperLimit); + fCascadeEtaMax = getMinimalSelection(femtoDreamCascadeSelection::kCascadeEtaMax, + femtoDreamSelection::kAbsUpperLimit); + fCascadeDCADaughMax = getMinimalSelection(femtoDreamCascadeSelection::kCascadeDCADaughMax, + femtoDreamSelection::kUpperLimit); + fCascadeCPAMin = getMinimalSelection(femtoDreamCascadeSelection::kCascadeCPAMin, + femtoDreamSelection::kLowerLimit); + fCascadeTranRadMin = getMinimalSelection(femtoDreamCascadeSelection::kCascadeTranRadMin, + femtoDreamSelection::kLowerLimit); + fCascadeTranRadMax = getMinimalSelection(femtoDreamCascadeSelection::kCascadeTranRadMax, + femtoDreamSelection::kUpperLimit); + fCascadeDecVtxMax = getMinimalSelection(femtoDreamCascadeSelection::kCascadeDecVtxMax, + femtoDreamSelection::kAbsUpperLimit); + fCascadeV0DCADaughMax = getMinimalSelection(femtoDreamCascadeSelection::kCascadeV0DCADaughMax, + femtoDreamSelection::kUpperLimit); + fCascadeV0CPAMin = getMinimalSelection(femtoDreamCascadeSelection::kCascadeV0CPAMin, + femtoDreamSelection::kLowerLimit); + fCascadeV0TranRadMin = getMinimalSelection(femtoDreamCascadeSelection::kCascadeV0TranRadMin, + femtoDreamSelection::kLowerLimit); + fCascadeV0TranRadMax = getMinimalSelection(femtoDreamCascadeSelection::kCascadeV0TranRadMax, + femtoDreamSelection::kUpperLimit); + fCascadeV0DCAToPVMin = getMinimalSelection(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMin, + femtoDreamSelection::kLowerLimit); + fCascadeV0DCAToPVMax = getMinimalSelection(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMax, + femtoDreamSelection::kUpperLimit); + isCascOmega = isSelectCascOmega; +} + +template +bool FemtoDreamCascadeSelection::isSelectedMinimal(Col const& col, Casc const& cascade, Track const& posTrack, Track const& negTrack, Track const& bachTrack) +{ + const auto signPos = posTrack.sign(); + const auto signNeg = negTrack.sign(); + + if (signPos < 0 || signNeg > 0) { + LOG(warn) << "Something wrong in isSelectedMinimal"; + LOG(warn) << "ERROR - Wrong sign for V0 daughters"; + } + + const std::vector decVtx = {cascade.x(), cascade.y(), cascade.z()}; + + const float cpav0 = cascade.v0cosPA(col.posX(), col.posY(), col.posZ()); + const float cpaCasc = cascade.casccosPA(col.posX(), col.posY(), col.posZ()); + const float v0dcatopv = cascade.dcav0topv(col.posX(), col.posY(), col.posZ()); + const float invMassLambda = cascade.mLambda(); + const float invMass = isCascOmega ? cascade.mOmega() : cascade.mXi(); + // const float invMass = cascade.mXi(); + + if (invMassLambda < fV0InvMassLowLimit || invMassLambda > fV0InvMassUpLimit) { + return false; + } + + if (invMass < fInvMassLowLimit || invMass > fInvMassUpLimit) { + return false; + } + + if (fRejectCompetingMass) { + const float invMassCompeting = isCascOmega ? cascade.mXi() : cascade.mOmega(); + if (invMassCompeting > fInvMassCompetingLowLimit && + invMassCompeting < fInvMassCompetingUpLimit) { + return false; + } + } + + if (nCascadePtMin > 0 && cascade.pt() < fCascadePtMin) { + return false; + } + if (nCascadePtMax > 0 && cascade.pt() > fCascadePtMax) { + return false; + } + if (nCascadeEtaMax > 0 && std::fabs(cascade.eta()) > fCascadeEtaMax) { + return false; + } + if (nCascadeDCADaughMax > 0 && cascade.dcacascdaughters() > fCascadeDCADaughMax) { + return false; + } + if (fCascadeCPAMin > 0 && cpaCasc < fCascadeCPAMin) { + return false; + } + if (nCascadeTranRadMin > 0 && cascade.cascradius() < fCascadeTranRadMin) { + return false; + } + if (nCascadeTranRadMax > 0 && cascade.cascradius() > fCascadeTranRadMax) { + return false; + } + for (size_t i = 0; i < decVtx.size(); i++) { + if (nCascadeDecVtxMax > 0 && decVtx.at(i) > fCascadeDecVtxMax) { + return false; + } + } + + // v0 criteria + if (nCascadeV0DCADaughMax > 0 && cascade.dcaV0daughters() > fCascadeV0DCADaughMax) { + return false; + } + if (nCascadeV0CPAMin > 0 && cpav0 < fCascadeV0CPAMin) { + return false; + } + if (nCascadeV0TranRadMin > 0 && cascade.v0radius() < fCascadeV0TranRadMin) { + return false; + } + if (nCascadeV0TranRadMax > 0 && cascade.v0radius() > fCascadeV0TranRadMax) { + return false; + } + if (nCascadeV0DCAToPVMin > 0 && std::fabs(v0dcatopv) < fCascadeV0DCAToPVMin) { + return false; + } + if (nCascadeV0DCAToPVMax > 0 && std::fabs(v0dcatopv) > fCascadeV0DCAToPVMax) { + return false; + } + + // Chech the selection criteria for the tracks as well + if (!PosDaughTrack.isSelectedMinimal(posTrack)) { + return false; + } + if (!NegDaughTrack.isSelectedMinimal(negTrack)) { + return false; + } + if (!BachDaughTrack.isSelectedMinimal(bachTrack)) { + return false; + } + + return true; +} + +template +std::array FemtoDreamCascadeSelection::getCutContainer(Col const& col, Casc const& casc, Track const& posTrack, Track const& negTrack, Track const& bachTrack) +{ + auto outputPosTrack = PosDaughTrack.getCutContainer(posTrack, posTrack.pt(), posTrack.eta(), posTrack.dcaXY()); + auto outputNegTrack = NegDaughTrack.getCutContainer(negTrack, negTrack.pt(), negTrack.eta(), negTrack.dcaXY()); + auto outputBachTrack = BachDaughTrack.getCutContainer(bachTrack, bachTrack.pt(), bachTrack.eta(), bachTrack.dcaXY()); + + cutContainerType output = 0; + size_t counter = 0; + + float sign = 0.; + if (casc.sign() < 0) { + sign = -1.; + } else { + sign = 1.; + } + + const auto cpaCasc = casc.casccosPA(col.posX(), col.posY(), col.posZ()); + const std::vector decVtx = {casc.x(), casc.y(), casc.z()}; + const auto cpav0 = casc.v0cosPA(col.posX(), col.posY(), col.posZ()); + const auto v0dcatopv = casc.dcav0topv(col.posX(), col.posY(), col.posZ()); + + float observable = 0.; + for (auto& sel : mSelections) { + + const auto selVariable = sel.getSelectionVariable(); + switch (selVariable) { + case (femtoDreamCascadeSelection::kCascadeSign): + observable = sign; + break; + case (femtoDreamCascadeSelection::kCascadePtMin): + observable = casc.pt(); + break; + case (femtoDreamCascadeSelection::kCascadePtMax): + observable = casc.pt(); + break; + case (femtoDreamCascadeSelection::kCascadeEtaMax): + observable = casc.eta(); + break; + case (femtoDreamCascadeSelection::kCascadeDCADaughMax): + observable = casc.dcacascdaughters(); + break; + case (femtoDreamCascadeSelection::kCascadeCPAMin): + observable = cpaCasc; + break; + case (femtoDreamCascadeSelection::kCascadeTranRadMin): + observable = casc.cascradius(); + break; + case (femtoDreamCascadeSelection::kCascadeTranRadMax): + observable = casc.cascradius(); + break; + // kCascadeDecVtxMax is done above + case (femtoDreamCascadeSelection::kCascadeDecVtxMax): + for (size_t i = 0; i < decVtx.size(); ++i) { + auto decVtxValue = decVtx.at(i); + sel.checkSelectionSetBit(decVtxValue, output, counter, nullptr); + } + continue; + break; + + case (femtoDreamCascadeSelection::kCascadeV0DCADaughMax): + observable = casc.dcaV0daughters(); + break; + case (femtoDreamCascadeSelection::kCascadeV0CPAMin): + observable = cpav0; + break; + case (femtoDreamCascadeSelection::kCascadeV0TranRadMin): + observable = casc.v0radius(); + break; + case (femtoDreamCascadeSelection::kCascadeV0TranRadMax): + observable = casc.v0radius(); + break; + case (femtoDreamCascadeSelection::kCascadeV0DCAtoPVMin): + observable = v0dcatopv; + break; + case (femtoDreamCascadeSelection::kCascadeV0DCAtoPVMax): + observable = v0dcatopv; + break; + } // switch + sel.checkSelectionSetBit(observable, output, counter, nullptr); + } // for loop + + return { + output, + outputPosTrack.at(femtoDreamTrackSelection::TrackContainerPosition::kCuts), + outputPosTrack.at(femtoDreamTrackSelection::TrackContainerPosition::kPID), + outputNegTrack.at(femtoDreamTrackSelection::TrackContainerPosition::kCuts), + outputNegTrack.at(femtoDreamTrackSelection::TrackContainerPosition::kPID), + outputBachTrack.at(femtoDreamTrackSelection::TrackContainerPosition::kCuts), + outputBachTrack.at(femtoDreamTrackSelection::TrackContainerPosition::kPID)}; +} + +template +void FemtoDreamCascadeSelection::fillQA(Col const& col, Casc const& casc, Track const& posTrack, Track const& negTrack, Track const& bachTrack) +{ + + const std::vector decVtx = {casc.x(), casc.y(), casc.z()}; + const float cpaCasc = casc.casccosPA(col.posX(), col.posY(), col.posZ()); + const float cpav0 = casc.v0cosPA(col.posX(), col.posY(), col.posZ()); + const float v0dcatopv = casc.dcav0topv(col.posX(), col.posY(), col.posZ()); + if (mQAHistogramRegistry) { + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hSign"), casc.sign()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hPt"), casc.pt()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hEta"), casc.eta()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hPhi"), casc.phi()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hDCADaugh"), casc.dcacascdaughters()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hCPA"), cpaCasc); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hTranRad"), casc.cascradius()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hDecVtxX"), decVtx.at(0)); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hDecVtxY"), decVtx.at(1)); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hDecVtxZ"), decVtx.at(2)); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hInvMass"), casc.mXi()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hV0DCADaugh"), casc.dcaV0daughters()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hV0CPA"), cpav0); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hV0TranRad"), casc.v0radius()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hV0DCAToPV"), v0dcatopv); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hV0InvMass"), casc.mLambda()); + + PosDaughTrack.fillQA(posTrack); + NegDaughTrack.fillQA(negTrack); + BachDaughTrack.fillQA(bachTrack); + } +} + +} // namespace o2::analysis::femtoDream + +#endif // PWGCF_FEMTODREAM_CORE_FEMTODREAMCASCADESELECTION_H_ diff --git a/PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h b/PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h index 5a43a5f6e3b..8fe58ce9d7b 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h +++ b/PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -136,6 +136,21 @@ class FemtoDreamCollisionSelection return true; } + template + bool isCollisionWithoutTrkCasc(C const& col, Casc const& Cascades, CascC& CascadeCuts, T const& /*Tracks*/) + { + // check if there is no selected Cascade + for (auto const& Cascade : Cascades) { + auto postrack = Cascade.template posTrack_as(); + auto negtrack = Cascade.template negTrack_as(); + auto bachtrack = Cascade.template bachelor_as(); + if (CascadeCuts.isSelectedMinimal(col, Cascade, postrack, negtrack, bachtrack)) { + return false; + } + } + return true; + } + /// Some basic QA of the event /// \tparam T type of the collision /// \param col Collision diff --git a/PWGCF/FemtoDream/Core/femtoDreamContainer.h b/PWGCF/FemtoDream/Core/femtoDreamContainer.h index 8a9038e6198..5e0222a4f07 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamContainer.h +++ b/PWGCF/FemtoDream/Core/femtoDreamContainer.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoDream/Core/femtoDreamContainerThreeBody.h b/PWGCF/FemtoDream/Core/femtoDreamContainerThreeBody.h index b1c2c322cd8..a6c60793060 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamContainerThreeBody.h +++ b/PWGCF/FemtoDream/Core/femtoDreamContainerThreeBody.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h b/PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h index 9d1e55aadf1..58dc6c9ded4 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h +++ b/PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -64,7 +64,7 @@ class FemtoDreamDetaDphiStar radiiTPC = radiiTPCtoCut; fillQA = fillTHSparse; - if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kTrack) { + if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && (mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kTrack || mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0Child || mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kCascadeBachelor)) { std::string dirName = static_cast(dirNames[0]); histdetadpi[0][0] = mHistogramRegistry->add((dirName + static_cast(histNames[0][0]) + static_cast(histNameSEorME[meORse])).c_str(), "; #Delta #eta; #Delta #phi^{*}", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); histdetadpi[0][1] = mHistogramRegistry->add((dirName + static_cast(histNames[1][0]) + static_cast(histNameSEorME[meORse])).c_str(), "; #Delta #eta; #Delta #phi^{*}", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); @@ -116,6 +116,24 @@ class FemtoDreamDetaDphiStar } } } + if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kCascade) { + for (int i = 0; i < 3; i++) { + std::string dirName = static_cast(dirNames[3]); + histdetadpi[i][0] = mHistogramRegistry->add((dirName + static_cast(histNames[0][i]) + static_cast(histNameSEorME[meORse])).c_str(), "; #Delta #eta; #Delta #phi^{*}", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + histdetadpi[i][1] = mHistogramRegistry->add((dirName + static_cast(histNames[1][i]) + static_cast(histNameSEorME[meORse])).c_str(), "; #Delta #eta; #Delta #phi^{*}", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + histdetadpi[i][2] = mHistogramRegistry->add((dirName + "at_PV_" + std::to_string(i) + "_before" + static_cast(histNameSEorME[meORse])).c_str(), "; #Delta #eta; #Delta #phi^{*}", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + histdetadpi[i][3] = mHistogramRegistry->add((dirName + "at_PV_" + std::to_string(i) + "_after" + static_cast(histNameSEorME[meORse])).c_str(), "; #Delta #eta; #Delta #phi^{*}", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + if (plotForEveryRadii) { + for (int j = 0; j < 9; j++) { + histdetadpiRadii[i][j] = mHistogramRegistryQA->add((dirName + static_cast(histNamesRadii[i][j]) + static_cast(histNameSEorME[meORse])).c_str(), "; #Delta #eta; #Delta #phi^{*}", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + } + } + if (fillQA) { + histdetadpi_eta[i] = mHistogramRegistry->add((dirName + "dEtadPhi_Eta_" + std::to_string(i) + static_cast(histNameSEorME[meORse])).c_str(), "; #Delta #eta; #Delta #phi^{*}; #eta_{1}; #eta_{2}", kTHnSparseF, {{100, -0.15, 0.15}, {100, -0.15, 0.15}, {100, -0.8, 0.8}, {100, -0.8, 0.8}}); + histdetadpi_phi[i] = mHistogramRegistry->add((dirName + "dEtadPhi_Phi_" + std::to_string(i) + static_cast(histNameSEorME[meORse])).c_str(), "; #Delta #eta; #Delta #phi^{*}; #phi_{1}; #phi_{2}", kTHnSparseF, {{100, -0.15, 0.15}, {100, -0.15, 0.15}, {100, 0, 6.28}, {100, 0, 6.28}}); + } + } + } } /// Check if pair is close or not template @@ -123,11 +141,12 @@ class FemtoDreamDetaDphiStar { magfield = lmagfield; - if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kTrack) { + if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && (mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kTrack || mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0Child)) { /// Track-Track combination // check if provided particles are in agreement with the class instantiation - if (part1.partType() != o2::aod::femtodreamparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtodreamparticle::ParticleType::kTrack) { - LOG(fatal) << "FemtoDreamDetaDphiStar: passed arguments don't agree with FemtoDreamDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; + if (part1.partType() != o2::aod::femtodreamparticle::ParticleType::kTrack || !(part2.partType() == o2::aod::femtodreamparticle::ParticleType::kTrack || part2.partType() == o2::aod::femtodreamparticle::ParticleType::kCascadeV0Child)) { // hotfix to use the CPR + // LOG(fatal) << "FemtoDreamDetaDphiStar: passed arguments don't agree with FemtoDreamDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; + LOGF(fatal, "FemtoDreamDetaDphiStar: passed arguments don't agree with FemtoDreamDetaDphiStar instantiation! Please provide kTrack,kTrack candidates. Currently: %i", part2.partType()); return false; } auto deta = part1.eta() - part2.eta(); @@ -376,6 +395,85 @@ class FemtoDreamDetaDphiStar return pass; + } else if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kCascade) { + /// Track-V0 combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtodreamparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtodreamparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoDreamDetaDphiStar: passed arguments don't agree with FemtoDreamDetaDphiStar instantiation! Please provide kTrack,kV0 candidates."; + return false; + } + + bool pass = false; + for (int i = 0; i < 3; i++) { + int indexOfDaughter; + if (isMixedEventLambda) { + indexOfDaughter = part2.globalIndex() - 3 + i; + } else { + indexOfDaughter = part2.index() - 3 + i; + } + auto daughter = particles.begin() + indexOfDaughter; + auto deta = part1.eta() - daughter.eta(); + auto dphi_AT_PV = part1.phi() - daughter.phi(); + auto dphi_AT_SpecificRadii = PhiAtSpecificRadiiTPC(part1, radiiTPC) - PhiAtSpecificRadiiTPC(daughter, radiiTPC); + bool sameCharge = false; + auto dphiAvg = AveragePhiStar(part1, *daughter, i, &sameCharge); + if (Q3 == 999) { + histdetadpi[i][0]->Fill(deta, dphiAvg); + histdetadpi[i][2]->Fill(deta, dphi_AT_PV); + if (fillQA) { + histdetadpi_eta[i]->Fill(deta, dphiAvg, part1.eta(), daughter.eta()); + histdetadpi_phi[i]->Fill(deta, dphiAvg, part1.phi(), daughter.phi()); + } + } else if (Q3 < upperQ3LimitForPlotting) { + histdetadpi[i][0]->Fill(deta, dphiAvg); + histdetadpi[i][2]->Fill(deta, dphi_AT_PV); + if (fillQA) { + histdetadpi_eta[i]->Fill(deta, dphiAvg, part1.eta(), daughter.eta()); + histdetadpi_phi[i]->Fill(deta, dphiAvg, part1.phi(), daughter.phi()); + } + } + if (sameCharge) { + if (atWhichRadiiToSelect == 1) { + if (pow(dphiAvg, 2) / pow(deltaPhiMax, 2) + pow(deta, 2) / pow(deltaEtaMax, 2) < 1.) { + pass = true; + } else { + if (Q3 == 999) { + histdetadpi[i][1]->Fill(deta, dphiAvg); + histdetadpi[i][3]->Fill(deta, dphi_AT_PV); + } else if (Q3 < upperQ3LimitForPlotting) { + histdetadpi[i][1]->Fill(deta, dphiAvg); + histdetadpi[i][3]->Fill(deta, dphi_AT_PV); + } + } + + } else if (atWhichRadiiToSelect == 0) { + if (pow(dphi_AT_PV, 2) / pow(deltaPhiMax, 2) + pow(deta, 2) / pow(deltaEtaMax, 2) < 1.) { + pass = true; + } else { + if (Q3 == 999) { + histdetadpi[i][1]->Fill(deta, dphiAvg); + histdetadpi[i][3]->Fill(deta, dphi_AT_PV); + } else if (Q3 < upperQ3LimitForPlotting) { + histdetadpi[i][1]->Fill(deta, dphiAvg); + histdetadpi[i][3]->Fill(deta, dphi_AT_PV); + } + } + } else if (atWhichRadiiToSelect == 2) { + if (pow(dphi_AT_SpecificRadii, 2) / pow(deltaPhiMax, 2) + pow(deta, 2) / pow(deltaEtaMax, 2) < 1.) { + pass = true; + } else { + if (Q3 == 999) { + histdetadpi[i][1]->Fill(deta, dphiAvg); + histdetadpi[i][3]->Fill(deta, dphi_AT_PV); + } else if (Q3 < upperQ3LimitForPlotting) { + histdetadpi[i][1]->Fill(deta, dphiAvg); + histdetadpi[i][3]->Fill(deta, dphi_AT_PV); + } + } + } + } + } + return pass; } else { LOG(fatal) << "FemtoDreamPairCleaner: Combination of objects not defined - quitting!"; return false; @@ -385,14 +483,14 @@ class FemtoDreamDetaDphiStar private: HistogramRegistry* mHistogramRegistry = nullptr; ///< For main output HistogramRegistry* mHistogramRegistryQA = nullptr; ///< For QA output - static constexpr std::string_view dirNames[3] = {"kTrack_kTrack/", "kTrack_kV0/", "kTrack_kCharmHadron/"}; + static constexpr std::string_view dirNames[4] = {"kTrack_kTrack/", "kTrack_kV0/", "kTrack_kCharmHadron/", "kTrack_kCascade/"}; static constexpr std::string_view histNameSEorME[3] = {"_SEandME", "_SE", "_ME"}; - static constexpr std::string_view histNames[2][3] = {{"detadphidetadphi0Before_0", "detadphidetadphi0Before_1", "detadphidetadphi0Before_2"}, - {"detadphidetadphi0After_0", "detadphidetadphi0After_1", "detadphidetadphi0After_2"}}; + static constexpr std::string_view histNames[2][4] = {{"detadphidetadphi0Before_0", "detadphidetadphi0Before_1", "detadphidetadphi0Before_2", "detadphidetadphi0Before_3"}, + {"detadphidetadphi0After_0", "detadphidetadphi0After_1", "detadphidetadphi0After_2", "detadphidetadphi0After_3"}}; - static constexpr std::string_view histNamesRadii[3][9] = { + static constexpr std::string_view histNamesRadii[4][9] = { {"detadphidetadphi0Before_0_0", "detadphidetadphi0Before_0_1", "detadphidetadphi0Before_0_2", "detadphidetadphi0Before_0_3", "detadphidetadphi0Before_0_4", "detadphidetadphi0Before_0_5", "detadphidetadphi0Before_0_6", "detadphidetadphi0Before_0_7", "detadphidetadphi0Before_0_8"}, @@ -401,7 +499,10 @@ class FemtoDreamDetaDphiStar "detadphidetadphi0Before_1_6", "detadphidetadphi0Before_1_7", "detadphidetadphi0Before_1_8"}, {"detadphidetadphi0Before_2_0", "detadphidetadphi0Before_2_1", "detadphidetadphi0Before_2_2", "detadphidetadphi0Before_2_3", "detadphidetadphi0Before_2_4", "detadphidetadphi0Before_2_5", - "detadphidetadphi0Before_2_6", "detadphidetadphi0Before_2_7", "detadphidetadphi0Before_2_8"}}; + "detadphidetadphi0Before_2_6", "detadphidetadphi0Before_2_7", "detadphidetadphi0Before_2_8"}, + {"detadphidetadphi0Before_3_0", "detadphidetadphi0Before_3_1", "detadphidetadphi0Before_3_2", + "detadphidetadphi0Before_3_3", "detadphidetadphi0Before_3_4", "detadphidetadphi0Before_3_5", + "detadphidetadphi0Before_3_6", "detadphidetadphi0Before_3_7", "detadphidetadphi0Before_3_8"}}; static constexpr o2::aod::femtodreamparticle::ParticleType mPartOneType = partOne; ///< Type of particle 1 static constexpr o2::aod::femtodreamparticle::ParticleType mPartTwoType = partTwo; ///< Type of particle 2 @@ -457,7 +558,7 @@ class FemtoDreamDetaDphiStar if (!runOldVersion) { auto arg = 0.3 * charge * magfield * tmpRadiiTPC[i] * 0.01 / (2. * pt); // for very low pT particles, this value goes outside of range -1 to 1 at at large tpc radius; asin fails - if (abs(arg) < 1) { + if (std::fabs(arg) < 1) { tmpVec.push_back(phi0 - std::asin(0.3 * charge * magfield * tmpRadiiTPC[i] * 0.01 / (2. * pt))); } else { tmpVec.push_back(999); @@ -517,7 +618,7 @@ class FemtoDreamDetaDphiStar if (!runOldVersion) { auto arg = 0.3 * charge * magfield * radii * 0.01 / (2. * pt); // for very low pT particles, this value goes outside of range -1 to 1 at at large tpc radius; asin fails - if (abs(arg) < 1) { + if (std::fabs(arg) < 1) { phiAtRadii = phi0 - std::asin(0.3 * charge * magfield * radii * 0.01 / (2. * pt)); } else { phiAtRadii = 999.; @@ -560,7 +661,7 @@ class FemtoDreamDetaDphiStar if (!runOldVersion) { auto arg = 0.3 * charge * magfield * tmpRadiiTPC[i] * 0.01 / (2. * pt); // for very low pT particles, this value goes outside of range -1 to 1 at at large tpc radius; asin fails - if (abs(arg) < 1) { + if (std::fabs(arg) < 1) { tmpVec.push_back(phi0 - std::asin(0.3 * charge * magfield * tmpRadiiTPC[i] * 0.01 / (2. * pt))); } else { tmpVec.push_back(999); diff --git a/PWGCF/FemtoDream/Core/femtoDreamEventHisto.h b/PWGCF/FemtoDream/Core/femtoDreamEventHisto.h index 4f70555a849..2d668d15c58 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamEventHisto.h +++ b/PWGCF/FemtoDream/Core/femtoDreamEventHisto.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoDream/Core/femtoDreamMath.h b/PWGCF/FemtoDream/Core/femtoDreamMath.h index 441e49066cd..aba07f96c9c 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamMath.h +++ b/PWGCF/FemtoDream/Core/femtoDreamMath.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -136,6 +136,19 @@ class FemtoDreamMath { return std::sqrt(std::pow(getkT(part1, mass1, part2, mass2), 2.) + std::pow(0.5 * (mass1 + mass2), 2.)); } + + template + static float getInvMassCascade(const T1& trackpos, const float masspos, const T1& trackneg, const float massneg, const T1& trackbach, const float massbach, const float massv0) + { + // calculate the invariant mass + const ROOT::Math::PtEtaPhiMVector posDaug(trackpos.pt(), trackpos.eta(), trackpos.phi(), masspos); + const ROOT::Math::PtEtaPhiMVector negDaug(trackneg.pt(), trackneg.eta(), trackneg.phi(), massneg); + const ROOT::Math::PtEtaPhiMVector bachDaug(trackbach.pt(), trackbach.eta(), trackbach.phi(), massbach); + const ROOT::Math::PxPyPzMVector v0(posDaug.Px() + negDaug.Px(), posDaug.Py() + negDaug.Py(), posDaug.Pz() + negDaug.Pz(), massv0); + const ROOT::Math::PxPyPzMVector casc = v0 + bachDaug; + + return casc.M(); + } }; } // namespace o2::analysis::femtoDream diff --git a/PWGCF/FemtoDream/Core/femtoDreamObjectSelection.h b/PWGCF/FemtoDream/Core/femtoDreamObjectSelection.h index 21440f35414..d01ce564f66 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamObjectSelection.h +++ b/PWGCF/FemtoDream/Core/femtoDreamObjectSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h b/PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h index 3cc1834de3f..3b248657b1f 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h +++ b/PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -85,6 +85,19 @@ class FemtoDreamPairCleaner return true; } return false; + } else if constexpr (mPartOneType == o2::aod::femtodreamparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtodreamparticle::ParticleType::kCascade) { + /// Track-Cascade combination + if (part2.partType() != o2::aod::femtodreamparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoDreamPairCleaner: passed arguments don't agree with FemtoDreamPairCleaner instantiation! Please provide second argument kCascade candidate."; + return false; + } + const auto& posChild = particles.iteratorAt(part2.index() - 3); + const auto& negChild = particles.iteratorAt(part2.index() - 2); + const auto& bachChild = particles.iteratorAt(part2.index() - 1); + if (part1.index() != posChild.childrenIds()[0] && part1.index() != negChild.childrenIds()[1] && part1.index() != bachChild.childrenIds()[2]) { + return true; + } + return false; } else { LOG(fatal) << "FemtoDreamPairCleaner: Combination of objects not defined - quitting!"; return false; diff --git a/PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h b/PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h index 30686bcad09..4148e8b3efc 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h +++ b/PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -61,18 +61,22 @@ class FemtoDreamParticleHisto if constexpr (o2::aod::femtodreamMCparticle::MCType::kRecon == mc) { mHistogramRegistry->add((folderName + folderSuffix + static_cast(o2::aod::femtodreamparticle::TempFitVarName[mParticleType])).c_str(), ("; #it{p}_{T} (GeV/#it{c}); " + tempFitVarAxisTitle).c_str(), kTH2F, {{pTAxis}, {tempFitVarAxis}}); } - if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0 && mc == o2::aod::femtodreamMCparticle::MCType::kRecon) { + if constexpr ((mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0 || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0) && mc == o2::aod::femtodreamMCparticle::MCType::kRecon) { mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassLambda").c_str(), "; M_{#Lambda}; Entries", kTH1F, {InvMassAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hpTInvMassLambda").c_str(), "; p_{T} (GeV/#it{c{}); M_{#Lambda}", kTH2F, {pTAxis, InvMassAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassAntiLambda").c_str(), "; M_{#bar{#Lambda}}; Entries", kTH1F, {InvMassAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hpTInvMassAntiLambda").c_str(), "; M_{#bar{#Lambda}}; Entries", kTH2F, {pTAxis, InvMassAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassLambdaAntiLambda").c_str(), "; M_{#Lambda}; M_{#bar{#Lambda}}", kTH2F, {InvMassAxis, InvMassAxis}); } + if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascade) { + mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassCascade").c_str(), "; M_{Cascade}; Entries", kTH1F, {InvMassAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hpTInvMassCascade").c_str(), "; p_{T} (GeV/#it{c{}); M_{Cascade}", kTH2F, {pTAxis, InvMassAxis}); + } } // comment template - void init_debug(std::string folderName, T& multAxis, T& multPercentileAxis, T& pTAxis, T& etaAxis, T& phiAxis, T& tempFitVarAxis, T& dcazAxis, T& NsigmaTPCAxis, T& NsigmaTOFAxis, T& NsigmaTPCTOFAxis, T& /*TPCclustersAxis*/, bool correlatedPlots) + void init_debug(std::string folderName, T& multAxis, T& multPercentileAxis, T& pTAxis, T& etaAxis, T& phiAxis, T& tempFitVarAxis, T& dcazAxis, T& NsigmaTPCAxis, T& NsigmaTOFAxis, T& NsigmaTPCTOFAxis, T& NsigmaITSAxis, T& InvMassCompetingAxis, bool correlatedPlots) { std::string folderSuffix = static_cast(o2::aod::femtodreamMCparticle::MCTypeName[mc]).c_str(); @@ -81,7 +85,7 @@ class FemtoDreamParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hMomentumVsPhi").c_str(), "; #it{p} (GeV/#it{c}); #phi", kTH2F, {{500, 0, 10}, {360, 0., TMath::TwoPi()}}); mHistogramRegistry->add((folderName + folderSuffix + "/hEtaVsPhi").c_str(), "; #eta; #phi", kTH2F, {{300, -1.5, 1.5}, {360, 0., TMath::TwoPi()}}); - if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kTrack || mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0Child) { + if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kTrack || mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0Child || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeBachelor) { mHistogramRegistry->add((folderName + folderSuffix + "/hCharge").c_str(), "; Charge; Entries", kTH1F, {{5, -2.5, 2.5}}); mHistogramRegistry->add((folderName + folderSuffix + "/hTPCfindable").c_str(), "; TPC findable clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); mHistogramRegistry->add((folderName + folderSuffix + "/hTPCfound").c_str(), "; TPC found clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); @@ -117,6 +121,14 @@ class FemtoDreamParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_d").c_str(), "n#sigma_{comb}^{d}", kTH2F, {pTAxis, NsigmaTPCTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_tr").c_str(), "n#sigma_{comb}^{tr}", kTH2F, {pTAxis, NsigmaTPCTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_he3").c_str(), "n#sigma_{comb}^{he3}", kTH2F, {pTAxis, NsigmaTPCTOFAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/ITSSignal").c_str(), "x", kTH2F, {pTAxis, NsigmaITSAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaITS_el").c_str(), "n#sigma_{ITS}^{e}", kTH2F, {pTAxis, NsigmaITSAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaITS_pi").c_str(), "n#sigma_{ITS}^{#pi}", kTH2F, {pTAxis, NsigmaITSAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaITS_K").c_str(), "n#sigma_{ITS}^{K}", kTH2F, {pTAxis, NsigmaITSAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaITS_p").c_str(), "n#sigma_{ITS}^{p}", kTH2F, {pTAxis, NsigmaITSAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaITS_d").c_str(), "n#sigma_{ITS}^{d}", kTH2F, {pTAxis, NsigmaITSAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaITS_tr").c_str(), "n#sigma_{ITS}^{tr}", kTH2F, {pTAxis, NsigmaITSAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaITS_he3").c_str(), "n#sigma_{ITS}^{he3}", kTH2F, {pTAxis, NsigmaITSAxis}); if (correlatedPlots) { mHistogramRegistry->add((folderName + folderSuffix + "/HighDcorrelator").c_str(), "", kTHnSparseF, {multAxis, multPercentileAxis, pTAxis, etaAxis, phiAxis, tempFitVarAxis, dcazAxis, NsigmaTPCAxis, NsigmaTOFAxis}); } @@ -126,6 +138,17 @@ class FemtoDreamParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hDecayVtxX").c_str(), "; #it{Vtx}_{x} (cm); Entries", kTH1F, {{2000, 0, 200}}); mHistogramRegistry->add((folderName + folderSuffix + "/hDecayVtxY").c_str(), "; #it{Vtx}_{y} (cm)); Entries", kTH1F, {{2000, 0, 200}}); mHistogramRegistry->add((folderName + folderSuffix + "/hDecayVtxZ").c_str(), "; #it{Vtx}_{z} (cm); Entries", kTH1F, {{2000, 0, 200}}); + } else if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascade) { + mHistogramRegistry->add((folderName + folderSuffix + "/hCascV0DCADaugh").c_str(), "; #DCA{daugh} (cm); Entries", kTH1F, {{300, 0, 3}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCascV0TransRadius").c_str(), "; #it{r}_{xy} (cm); Entries", kTH1F, {{1500, 0, 150}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCascV0DCAtoPV").c_str(), "; DCA^{PV} (cm); Entries", kTH1F, {{1000, 0, 10}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCascDaughDCA").c_str(), "; DCA^{daugh} (cm); Entries", kTH1F, {{1000, 0, 10}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCascTransRadius").c_str(), "; #it{r}_{xy} (cm); Entries", kTH1F, {{1500, 0, 150}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCascDecayVtxX").c_str(), "; #it{Vtx}_{x} (cm); Entries", kTH1F, {{2000, 0, 200}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCascDecayVtxY").c_str(), "; #it{Vtx}_{y} (cm)); Entries", kTH1F, {{2000, 0, 200}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCascDecayVtxZ").c_str(), "; #it{Vtx}_{z} (cm); Entries", kTH1F, {{2000, 0, 200}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassCompetingCascade").c_str(), "; M_{Competing Cascade}; Entries", kTH1F, {InvMassCompetingAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hpTInvMassCompetingCascade").c_str(), "; p_{T} (GeV/#it{c{}); M_{Competing Cascade}", kTH2F, {pTAxis, InvMassCompetingAxis}); } } @@ -150,7 +173,7 @@ class FemtoDreamParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hEta_DiffTruthReco").c_str(), "; #eta^{truth}; #eta^{reco} - #eta^{truth}", kTH2F, {{200, -1, 1}, {200, -1, 1}}); mHistogramRegistry->add((folderName + folderSuffix + "/hPhi_DiffTruthReco").c_str(), "; #varphi^{truth}; #varphi^{reco} - #varphi^{truth}", kTH2F, {{720, 0, TMath::TwoPi()}, {200, -1, 1}}); - if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kTrack || mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0Child) { + if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kTrack || mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0Child || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeBachelor) { /// Track histograms if (isDebug) { mHistogramRegistry->add((folderName + folderSuffix + "/Debug/hPDGmother_Primary").c_str(), "; PDG mother; Entries", kTH1I, {{6001, -3000.5, 3000.5}}); @@ -182,7 +205,7 @@ class FemtoDreamParticleHisto } // DCA plots - } else if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0) { + } else if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0 || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0) { if (isDebug) { mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Primary").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTHnSparseF, {tempFitVarpTAxis, tempFitVarAxis, multAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Secondary").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTHnSparseF, {tempFitVarpTAxis, tempFitVarAxis, multAxis}); @@ -190,6 +213,9 @@ class FemtoDreamParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_WrongCollision").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTHnSparseF, {tempFitVarpTAxis, tempFitVarAxis, multAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Fake").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTHnSparseF, {tempFitVarpTAxis, tempFitVarAxis, multAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Else").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTHnSparseF, {tempFitVarpTAxis, tempFitVarAxis, multAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Secondary_SIGMA0").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTHnSparseF, {tempFitVarpTAxis, tempFitVarAxis, multAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Secondary_XIMinus").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTHnSparseF, {tempFitVarpTAxis, tempFitVarAxis, multAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Secondary_XI0").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTHnSparseF, {tempFitVarpTAxis, tempFitVarAxis, multAxis}); } else { mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Primary").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Secondary").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); @@ -197,6 +223,9 @@ class FemtoDreamParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_WrongCollision").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Fake").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Else").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Secondary_SIGMA0").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Secondary_XIMinus").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hCPA_Secondary_XI0").c_str(), "; #it{p}_{T} (GeV/#it{c}); CPA", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); } /// V0 histograms /// to be implemented @@ -217,17 +246,17 @@ class FemtoDreamParticleHisto /// \param tempFitVarBins binning of the tempFitVar (DCA_xy in case of tracks, CPA in case of V0s, etc.) /// \param isMC add Monte Carlo truth histograms to the output file template - void init(HistogramRegistry* registry, T& MultBins, T& PercentileBins, T& pTBins, T& etaBins, T& phiBins, T& tempFitVarBins, T& NsigmaTPCBins, T& NsigmaTOFBins, T& NsigmaTPCTOFBins, T& TPCclustersBins, T& InvMassBins, bool isMC, int pdgCode, bool isDebug = false, bool correlatedPlots = false) + void init(HistogramRegistry* registry, T& MultBins, T& PercentileBins, T& pTBins, T& etaBins, T& phiBins, T& tempFitVarBins, T& NsigmaTPCBins, T& NsigmaTOFBins, T& NsigmaTPCTOFBins, T& NsigmaITSBins, T& InvMassBins, T& InvMassCompetingBins, bool isMC, int pdgCode, bool isDebug = false, bool correlatedPlots = false) { mPDG = pdgCode; if (registry) { mHistogramRegistry = registry; /// The folder names are defined by the type of the object and the suffix (if applicable) std::string tempFitVarAxisTitle; - if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kTrack || mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0Child) { + if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kTrack || mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0Child || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeBachelor) { /// Track histograms tempFitVarAxisTitle = "DCA_{xy} (cm)"; - } else if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0) { + } else if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0 || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0) { /// V0 histograms tempFitVarAxisTitle = "cos#alpha"; } else if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascade) { @@ -247,15 +276,16 @@ class FemtoDreamParticleHisto framework::AxisSpec NsigmaTPCAxis = {NsigmaTPCBins, "n#sigma_{TPC}"}; framework::AxisSpec NsigmaTOFAxis = {NsigmaTOFBins, "n#sigma_{TOF}"}; framework::AxisSpec NsigmaTPCTOFAxis = {NsigmaTPCTOFBins, "n#sigma_{TPC+TOF}"}; - framework::AxisSpec TPCclustersAxis = {TPCclustersBins, "TPC found clusters"}; + framework::AxisSpec NsigmaITSAxis = {NsigmaITSBins, "n#sigma_{ITS}"}; framework::AxisSpec InvMassAxis = {InvMassBins, "M_{inv} (GeV/#it{c}^{2})"}; + framework::AxisSpec InvMassCompetingAxis = {InvMassCompetingBins, "M_{inv} (GeV/#it{c}^{2})"}; std::string folderName = (static_cast(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]).c_str() + static_cast(mFolderSuffix[mFolderSuffixType])).c_str(); // Fill here the actual histogramms by calling init_base and init_MC init_base(folderName, tempFitVarAxisTitle, pTAxis, tempFitVarAxis, InvMassAxis, multAxis); if (isDebug) { - init_debug(folderName, multAxis, multPercentileAxis, pTAxis, etaAxis, phiAxis, tempFitVarAxis, dcazAxis, NsigmaTPCAxis, NsigmaTOFAxis, NsigmaTPCTOFAxis, TPCclustersAxis, correlatedPlots); + init_debug(folderName, multAxis, multPercentileAxis, pTAxis, etaAxis, phiAxis, tempFitVarAxis, dcazAxis, NsigmaTPCAxis, NsigmaTOFAxis, NsigmaTPCTOFAxis, NsigmaITSAxis, InvMassCompetingAxis, correlatedPlots); } if (isMC) { init_base(folderName, tempFitVarAxisTitle, pTAxis, tempFitVarAxis, InvMassAxis, multAxis); @@ -280,13 +310,19 @@ class FemtoDreamParticleHisto if constexpr (mc == o2::aod::femtodreamMCparticle::MCType::kRecon) { mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST(o2::aod::femtodreamparticle::TempFitVarName[mParticleType]), part.pt(), part.tempFitVar()); } - if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0 && mc == o2::aod::femtodreamMCparticle::MCType::kRecon) { + if constexpr ((mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0 || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0) && mc == o2::aod::femtodreamMCparticle::MCType::kRecon) { mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hInvMassLambda"), part.mLambda()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hpTInvMassLambda"), part.pt(), part.mLambda()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hInvMassAntiLambda"), part.mAntiLambda()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hpTInvMassAntiLambda"), part.pt(), part.mAntiLambda()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hInvMassLambdaAntiLambda"), part.mLambda(), part.mAntiLambda()); } + if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascade) { + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hInvMassCascade"), part.mLambda()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hpTInvMassCascade"), part.pt(), part.mLambda()); + // mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hInvMassCascade"), part.mLambda()); + // mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hpTInvMassCascade"), part.pt(), part.mLambda()); + } } template @@ -314,7 +350,7 @@ class FemtoDreamParticleHisto mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hEtaVsPhi"), part.eta(), part.phi()); // Histograms holding further debug information - if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kTrack || mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0Child) { + if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kTrack || mParticleType == o2::aod::femtodreamparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeV0Child || mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascadeBachelor) { mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hCharge"), part.sign()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hTPCfindable"), part.tpcNClsFindable()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hTPCfound"), part.tpcNClsFound()); @@ -350,6 +386,14 @@ class FemtoDreamParticleHisto mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaComb_d"), momentum, std::sqrt(part.tpcNSigmaDe() * part.tpcNSigmaDe() + part.tofNSigmaDe() * part.tofNSigmaDe())); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaComb_tr"), momentum, std::sqrt(part.tpcNSigmaTr() * part.tpcNSigmaTr() + part.tofNSigmaTr() * part.tofNSigmaTr())); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaComb_he3"), momentum, std::sqrt(part.tpcNSigmaHe() * part.tpcNSigmaHe() + part.tofNSigmaHe() * part.tofNSigmaHe())); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/ITSSignal"), momentum, part.itsSignal()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaITS_el"), momentum, part.itsNSigmaEl()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaITS_pi"), momentum, part.itsNSigmaPi()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaITS_K"), momentum, part.itsNSigmaKa()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaITS_p"), momentum, part.itsNSigmaPr()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaITS_d"), momentum, part.itsNSigmaDe()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaITS_tr"), momentum, part.itsNSigmaTr()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaITS_he3"), momentum, part.itsNSigmaHe()); if (correlatedPlots) { @@ -405,6 +449,17 @@ class FemtoDreamParticleHisto mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hDecayVtxX"), part.decayVtxX()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hDecayVtxY"), part.decayVtxY()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hDecayVtxZ"), part.decayVtxZ()); + } else if constexpr (mParticleType == o2::aod::femtodreamparticle::ParticleType::kCascade) { + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hCascV0DCADaugh"), part.daughDCA()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hCascV0TransRadius"), part.transRadius()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hCascV0DCAtoPV"), part.cascV0DCAtoPV()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hCascDaughDCA"), part.cascDaughDCA()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hCascTransRadius"), part.cascTransRadius()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hCascDecayVtxX"), part.cascDecayVtxX()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hCascDecayVtxY"), part.cascDecayVtxY()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hCascDecayVtxZ"), part.cascDecayVtxZ()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hInvMassCompetingCascade"), part.mOmega()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/hpTInvMassCompetingCascade"), part.pt(), part.mOmega()); } } @@ -544,6 +599,18 @@ class FemtoDreamParticleHisto mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST("_MC/hCPA_Else"), part.pt(), part.tempFitVar(), mult); break; + case (o2::aod::femtodreamMCparticle::kSecondaryDaughterSigma0): + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST("_MC/hCPA_Secondary_SIGMA0"), + part.pt(), part.tempFitVar(), mult); + break; + case (o2::aod::femtodreamMCparticle::kSecondaryDaughterXiMinus): + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST("_MC/hCPA_Secondary_XIMinus"), + part.pt(), part.tempFitVar(), mult); + break; + case (o2::aod::femtodreamMCparticle::kSecondaryDaughterXi0): + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST("_MC/hCPA_Secondary_XI0"), + part.pt(), part.tempFitVar(), mult); + break; default: LOG(fatal) << "femtodreamparticleMC: not known value for ParticleOriginMCTruth - please check. Quitting!"; } @@ -573,6 +640,18 @@ class FemtoDreamParticleHisto mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST("_MC/hCPA_Else"), part.pt(), part.tempFitVar()); break; + case (o2::aod::femtodreamMCparticle::kSecondaryDaughterSigma0): + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST("_MC/hCPA_Secondary_SIGMA0"), + part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtodreamMCparticle::kSecondaryDaughterXiMinus): + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST("_MC/hCPA_Secondary_XIMinus"), + part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtodreamMCparticle::kSecondaryDaughterXi0): + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST("_MC/hCPA_Secondary_XI0"), + part.pt(), part.tempFitVar()); + break; default: LOG(fatal) << "femtodreamparticleMC: not known value for ParticleOriginMCTruth - please check. Quitting!"; } @@ -611,11 +690,11 @@ class FemtoDreamParticleHisto } private: - HistogramRegistry* mHistogramRegistry; ///< For QA output - static constexpr o2::aod::femtodreamparticle::ParticleType mParticleType = particleType; ///< Type of the particle under analysis - static constexpr int mFolderSuffixType = suffixType; ///< Counter for the folder suffix specified below - static constexpr std::string_view mFolderSuffix[8] = {"", "_one", "_two", "_pos", "_neg", "_allSelected", "_allSelected_pos", "_allSelected_neg"}; ///< Suffix for the folder name in case of analyses of pairs of the same kind (T-T, V-V, C-C) - int mPDG = 0; ///< PDG code of the selected particle + HistogramRegistry* mHistogramRegistry; ///< For QA output + static constexpr o2::aod::femtodreamparticle::ParticleType mParticleType = particleType; ///< Type of the particle under analysis + static constexpr int mFolderSuffixType = suffixType; ///< Counter for the folder suffix specified below + static constexpr std::string_view mFolderSuffix[9] = {"", "_one", "_two", "_pos", "_neg", "_allSelected", "_allSelected_pos", "_allSelected_neg", "_bach"}; ///< Suffix for the folder name in case of analyses of pairs of the same kind (T-T, V-V, C-C) + int mPDG = 0; ///< PDG code of the selected particle }; } // namespace o2::analysis::femtoDream diff --git a/PWGCF/FemtoDream/Core/femtoDreamSelection.h b/PWGCF/FemtoDream/Core/femtoDreamSelection.h index 73d29ff7d51..0e3592bf650 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamSelection.h +++ b/PWGCF/FemtoDream/Core/femtoDreamSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -84,16 +84,16 @@ class FemtoDreamSelection case (femtoDreamSelection::SelectionType::kUpperLimit): return (observable <= mSelVal); case (femtoDreamSelection::SelectionType::kAbsUpperLimit): - return (std::abs(observable) <= mSelVal); + return (std::fabs(observable) <= mSelVal); break; case (femtoDreamSelection::SelectionType::kLowerLimit): return (observable >= mSelVal); case (femtoDreamSelection::SelectionType::kAbsLowerLimit): - return (std::abs(observable) >= mSelVal); + return (std::fabs(observable) >= mSelVal); break; case (femtoDreamSelection::SelectionType::kEqual): /// \todo can the comparison be done a bit nicer? - return (std::abs(observable - mSelVal) < std::abs(mSelVal * 1e-6)); + return (std::fabs(observable - mSelVal) < std::abs(mSelVal * 1e-6)); break; } return false; diff --git a/PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h b/PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h index a1c5e0dda05..9cab0f9e78b 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h +++ b/PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -24,6 +24,8 @@ #include "PWGCF/DataModel/FemtoDerived.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" #include "PWGCF/FemtoDream/Core/femtoDreamObjectSelection.h" @@ -129,6 +131,14 @@ class FemtoDreamTrackSelection : public FemtoDreamObjectSelection auto getNsigmaTOF(T const& track, o2::track::PID pid); + /// Computes the n_sigma for a track and a particle-type hypothesis in the ITS + /// \tparam T Data type of the track + /// \param track Track for which PID is evaluated + /// \param pid Particle species for which PID is evaluated + /// \return Value of n_{sigma, ITS} + template + auto getNsigmaITS(T const& track, o2::track::PID pid); + /// Checks whether the most open combination of all selection criteria is fulfilled /// \tparam T Data type of the track /// \param track Track @@ -146,7 +156,7 @@ class FemtoDreamTrackSelection : public FemtoDreamObjectSelection + template std::array getCutContainer(T const& track, R Pt, R Eta, R Dcaxy); /// Some basic QA histograms @@ -154,7 +164,7 @@ class FemtoDreamTrackSelection : public FemtoDreamObjectSelection + template void fillQA(T const& track); /// Helper function to obtain the name of a given selection criterion for consistent naming of the configurables @@ -274,7 +284,7 @@ class FemtoDreamTrackSelection : public FemtoDreamObjectSelection void FemtoDreamTrackSelection::init(HistogramRegistry* QAregistry, HistogramRegistry* Registry) @@ -306,36 +318,39 @@ void FemtoDreamTrackSelection::init(HistogramRegistry* QAregistry, HistogramRegi if (nSelections > 8 * sizeof(cutContainerType)) { LOG(fatal) << "FemtoDreamTrackCuts: Number of selections too large for your container - quitting!"; } - mQAHistogramRegistry->add((folderName + "/hPt").c_str(), "; #it{p}_{T} (GeV/#it{c}); Entries", kTH1F, {{240, 0, 6}}); - mQAHistogramRegistry->add((folderName + "/hEta").c_str(), "; #eta; Entries", kTH1F, {{200, -1.5, 1.5}}); - mQAHistogramRegistry->add((folderName + "/hPhi").c_str(), "; #phi; Entries", kTH1F, {{200, 0, 2. * M_PI}}); - mQAHistogramRegistry->add((folderName + "/hTPCfindable").c_str(), "; TPC findable clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); - mQAHistogramRegistry->add((folderName + "/hTPCfound").c_str(), "; TPC found clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); - mQAHistogramRegistry->add((folderName + "/hTPCcrossedOverFindalbe").c_str(), "; TPC ratio findable; Entries", kTH1F, {{100, 0.5, 1.5}}); - mQAHistogramRegistry->add((folderName + "/hTPCcrossedRows").c_str(), "; TPC crossed rows; Entries", kTH1F, {{163, 0, 163}}); - mQAHistogramRegistry->add((folderName + "/hTPCfindableVsCrossed").c_str(), ";TPC findable clusters ; TPC crossed rows;", kTH2F, {{163, 0, 163}, {163, 0, 163}}); - mQAHistogramRegistry->add((folderName + "/hTPCshared").c_str(), "; TPC shared clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); - mQAHistogramRegistry->add((folderName + "/hITSclusters").c_str(), "; ITS clusters; Entries", kTH1F, {{10, -0.5, 9.5}}); - mQAHistogramRegistry->add((folderName + "/hITSclustersIB").c_str(), "; ITS clusters in IB; Entries", kTH1F, {{10, -0.5, 9.5}}); - mQAHistogramRegistry->add((folderName + "/hDCAxy").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/hDCAz").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{z} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/hDCA").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA (cm)", kTH2F, {{100, 0, 10}, {301, 0., 1.5}}); - mQAHistogramRegistry->add((folderName + "/hTPCdEdX").c_str(), "; #it{p} (GeV/#it{c}); TPC Signal", kTH2F, {{100, 0, 10}, {1000, 0, 1000}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTPC_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{e}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTPC_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{#pi}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTPC_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{K}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTPC_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{p}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTPC_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{d}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTOF_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{e}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTOF_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{#pi}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTOF_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{K}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTOF_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{p}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaTOF_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{d}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaComb_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{e}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaComb_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{#pi}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaComb_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{K}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaComb_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{p}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mQAHistogramRegistry->add((folderName + "/nSigmaComb_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{d}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + + for (int istage = 0; istage < kNcutStages; istage++) { + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hPt").c_str(), "; #it{p}_{T} (GeV/#it{c}); Entries", kTH1F, {{240, 0, 6}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hEta").c_str(), "; #eta; Entries", kTH1F, {{200, -1.5, 1.5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hPhi").c_str(), "; #phi; Entries", kTH1F, {{200, 0, 2. * M_PI}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hTPCfindable").c_str(), "; TPC findable clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hTPCfound").c_str(), "; TPC found clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hTPCcrossedOverFindalbe").c_str(), "; TPC ratio findable; Entries", kTH1F, {{100, 0.5, 1.5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hTPCcrossedRows").c_str(), "; TPC crossed rows; Entries", kTH1F, {{163, 0, 163}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hTPCfindableVsCrossed").c_str(), ";TPC findable clusters ; TPC crossed rows;", kTH2F, {{163, 0, 163}, {163, 0, 163}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hTPCshared").c_str(), "; TPC shared clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hITSclusters").c_str(), "; ITS clusters; Entries", kTH1F, {{10, -0.5, 9.5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hITSclustersIB").c_str(), "; ITS clusters in IB; Entries", kTH1F, {{10, -0.5, 9.5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hDCAxy").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hDCAz").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{z} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hDCA").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA (cm)", kTH2F, {{100, 0, 10}, {301, 0., 1.5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/hTPCdEdX").c_str(), "; #it{p} (GeV/#it{c}); TPC Signal", kTH2F, {{100, 0, 10}, {1000, 0, 1000}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTPC_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{e}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTPC_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{#pi}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTPC_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{K}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTPC_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{p}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTPC_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{d}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTOF_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{e}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTOF_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{#pi}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTOF_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{K}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTOF_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{p}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaTOF_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{d}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaComb_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{e}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaComb_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{#pi}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaComb_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{K}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaComb_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{p}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mQAHistogramRegistry->add((folderName + "/" + static_cast(mCutStage[istage]) + "/nSigmaComb_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{d}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + } } /// set cuts @@ -384,6 +399,28 @@ auto FemtoDreamTrackSelection::getNsigmaTOF(T const& track, o2::track::PID pid) return o2::aod::pidutils::tofNSigma(pid, track); } +template +auto FemtoDreamTrackSelection::getNsigmaITS(T const& track, o2::track::PID pid) +{ + if (pid == o2::track::PID::Electron) { + return track.itsNSigmaEl(); + } else if (pid == o2::track::PID::Pion) { + return track.itsNSigmaPi(); + } else if (pid == o2::track::PID::Kaon) { + return track.itsNSigmaKa(); + } else if (pid == o2::track::PID::Proton) { + return track.itsNSigmaPr(); + } else if (pid == o2::track::PID::Deuteron) { + return track.itsNSigmaDe(); + } else if (pid == o2::track::PID::Triton) { + return track.itsNSigmaTr(); + } else if (pid == o2::track::PID::Helium3) { + return track.itsNSigmaHe(); + } + // if nothing matched, return default value + return -999.f; +} + template bool FemtoDreamTrackSelection::isSelectedMinimal(T const& track) { @@ -411,7 +448,7 @@ bool FemtoDreamTrackSelection::isSelectedMinimal(T const& track) if (nPtMaxSel > 0 && pT > pTMax) { return false; } - if (nEtaSel > 0 && std::abs(eta) > etaMax) { + if (nEtaSel > 0 && std::fabs(eta) > etaMax) { return false; } if (nTPCnMinSel > 0 && tpcNClsF < nClsMin) { @@ -432,16 +469,16 @@ bool FemtoDreamTrackSelection::isSelectedMinimal(T const& track) if (nITScIbMinSel > 0 && itsNClsIB < nITSclsIbMin) { return false; } - if (nDCAxyMaxSel > 0 && std::abs(dcaXY) > dcaXYMax) { + if (nDCAxyMaxSel > 0 && std::fabs(dcaXY) > dcaXYMax) { return false; } - if (nDCAzMaxSel > 0 && std::abs(dcaZ) > dcaZMax) { + if (nDCAzMaxSel > 0 && std::fabs(dcaZ) > dcaZMax) { return false; } - if (nDCAMinSel > 0 && std::abs(dca) < dcaMin) { + if (nDCAMinSel > 0 && std::fabs(dca) < dcaMin) { return false; } - if (nRejectNotPropagatedTracks && std::abs(dca) > 1e3) { + if (nRejectNotPropagatedTracks && std::fabs(dca) > 1e3) { return false; } @@ -449,7 +486,7 @@ bool FemtoDreamTrackSelection::isSelectedMinimal(T const& track) bool isFulfilled = false; for (size_t i = 0; i < pidTPC.size(); ++i) { auto pidTPCVal = pidTPC.at(i); - if (std::abs(pidTPCVal - nSigmaPIDOffsetTPC) < nSigmaPIDMax) { + if (std::fabs(pidTPCVal - nSigmaPIDOffsetTPC) < nSigmaPIDMax) { isFulfilled = true; } } @@ -460,7 +497,7 @@ bool FemtoDreamTrackSelection::isSelectedMinimal(T const& track) return true; } -template +template std::array FemtoDreamTrackSelection::getCutContainer(T const& track, R Pt, R Eta, R Dca) { cutContainerType output = 0; @@ -479,23 +516,30 @@ std::array FemtoDreamTrackSelection::getCutContainer(T cons const auto dcaZ = track.dcaZ(); const auto dca = Dca; - std::vector pidTPC, pidTOF; + std::vector pidTPC, pidTOF, pidITS; for (auto it : mPIDspecies) { pidTPC.push_back(getNsigmaTPC(track, it)); pidTOF.push_back(getNsigmaTOF(track, it)); + if constexpr (useItsPid) { + pidITS.push_back(getNsigmaITS(track, it)); + } } float observable = 0.; for (auto& sel : mSelections) { const auto selVariable = sel.getSelectionVariable(); if (selVariable == femtoDreamTrackSelection::kPIDnSigmaMax) { - /// PID needs to be handled a bit differently since we may need more than one species + /// PID needsgetNsigmaITSto be handled a bit differently since we may need more than one species for (size_t i = 0; i < mPIDspecies.size(); ++i) { auto pidTPCVal = pidTPC.at(i) - nSigmaPIDOffsetTPC; auto pidTOFVal = pidTOF.at(i) - nSigmaPIDOffsetTOF; auto pidComb = std::sqrt(pidTPCVal * pidTPCVal + pidTOFVal * pidTOFVal); sel.checkSelectionSetBitPID(pidTPCVal, outputPID); sel.checkSelectionSetBitPID(pidComb, outputPID); + if constexpr (useItsPid) { + auto pidITSVal = pidITS.at(i); + sel.checkSelectionSetBitPID(pidITSVal, outputPID); + } } } else { /// for the rest it's all the same @@ -546,42 +590,42 @@ std::array FemtoDreamTrackSelection::getCutContainer(T cons return {output, outputPID}; } -template +template void FemtoDreamTrackSelection::fillQA(T const& track) { if (mQAHistogramRegistry) { - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hPt"), track.pt()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hEta"), track.eta()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hPhi"), track.phi()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hTPCfindable"), track.tpcNClsFindable()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hTPCfound"), track.tpcNClsFound()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hTPCcrossedOverFindalbe"), track.tpcCrossedRowsOverFindableCls()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hTPCcrossedRows"), track.tpcNClsCrossedRows()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hTPCfindableVsCrossed"), track.tpcNClsFindable(), track.tpcNClsCrossedRows()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hTPCshared"), track.tpcNClsShared()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hITSclusters"), track.itsNCls()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hITSclustersIB"), track.itsNClsInnerBarrel()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hDCAxy"), track.pt(), track.dcaXY()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hDCAz"), track.pt(), track.dcaZ()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hDCA"), track.pt(), std::sqrt(pow(track.dcaXY(), 2.) + pow(track.dcaZ(), 2.))); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/hTPCdEdX"), track.p(), track.tpcSignal()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTPC_pi"), track.p(), track.tpcNSigmaPi()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTPC_K"), track.p(), track.tpcNSigmaKa()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTPC_p"), track.p(), track.tpcNSigmaPr()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTOF_pi"), track.p(), track.tofNSigmaPi()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTOF_K"), track.p(), track.tofNSigmaKa()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTOF_p"), track.p(), track.tofNSigmaPr()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaComb_pi"), track.p(), std::sqrt(track.tpcNSigmaPi() * track.tpcNSigmaPi() + track.tofNSigmaPi() * track.tofNSigmaPi())); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaComb_K"), track.p(), std::sqrt(track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa())); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaComb_p"), track.p(), std::sqrt(track.tpcNSigmaPr() * track.tpcNSigmaPr() + track.tofNSigmaPr() * track.tofNSigmaPr())); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTPC_d"), track.p(), track.tpcNSigmaDe()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaComb_d"), track.p(), std::sqrt(track.tpcNSigmaDe() * track.tpcNSigmaDe() + track.tofNSigmaDe() * track.tofNSigmaDe())); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTOF_d"), track.p(), track.tofNSigmaDe()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hPt"), track.pt()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hEta"), track.eta()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hPhi"), track.phi()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hTPCfindable"), track.tpcNClsFindable()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hTPCfound"), track.tpcNClsFound()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hTPCcrossedOverFindalbe"), track.tpcCrossedRowsOverFindableCls()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hTPCcrossedRows"), track.tpcNClsCrossedRows()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hTPCfindableVsCrossed"), track.tpcNClsFindable(), track.tpcNClsCrossedRows()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hTPCshared"), track.tpcNClsShared()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hITSclusters"), track.itsNCls()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hITSclustersIB"), track.itsNClsInnerBarrel()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hDCAxy"), track.pt(), track.dcaXY()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hDCAz"), track.pt(), track.dcaZ()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hDCA"), track.pt(), std::sqrt(pow(track.dcaXY(), 2.) + pow(track.dcaZ(), 2.))); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/hTPCdEdX"), track.p(), track.tpcSignal()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTPC_pi"), track.p(), track.tpcNSigmaPi()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTPC_K"), track.p(), track.tpcNSigmaKa()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTPC_p"), track.p(), track.tpcNSigmaPr()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTOF_pi"), track.p(), track.tofNSigmaPi()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTOF_K"), track.p(), track.tofNSigmaKa()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTOF_p"), track.p(), track.tofNSigmaPr()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaComb_pi"), track.p(), std::sqrt(track.tpcNSigmaPi() * track.tpcNSigmaPi() + track.tofNSigmaPi() * track.tofNSigmaPi())); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaComb_K"), track.p(), std::sqrt(track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa())); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaComb_p"), track.p(), std::sqrt(track.tpcNSigmaPr() * track.tpcNSigmaPr() + track.tofNSigmaPr() * track.tofNSigmaPr())); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTPC_d"), track.p(), track.tpcNSigmaDe()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaComb_d"), track.p(), std::sqrt(track.tpcNSigmaDe() * track.tpcNSigmaDe() + track.tofNSigmaDe() * track.tofNSigmaDe())); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTOF_d"), track.p(), track.tofNSigmaDe()); if constexpr (!isHF) { - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaComb_el"), track.p(), std::sqrt(track.tpcNSigmaEl() * track.tpcNSigmaEl() + track.tofNSigmaEl() * track.tofNSigmaEl())); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTOF_el"), track.p(), track.tofNSigmaEl()); - mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/nSigmaTPC_el"), track.p(), track.tpcNSigmaEl()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaComb_el"), track.p(), std::sqrt(track.tpcNSigmaEl() * track.tpcNSigmaEl() + track.tofNSigmaEl() * track.tofNSigmaEl())); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTOF_el"), track.p(), track.tofNSigmaEl()); + mQAHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtodreamparticle::TrackTypeName[tracktype]) + HIST("/") + HIST(mCutStage[cutstage]) + HIST("/nSigmaTPC_el"), track.p(), track.tpcNSigmaEl()); } } } diff --git a/PWGCF/FemtoDream/Core/femtoDreamUtils.h b/PWGCF/FemtoDream/Core/femtoDreamUtils.h index cf3ba2b1585..c5db8dcc70e 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamUtils.h +++ b/PWGCF/FemtoDream/Core/femtoDreamUtils.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -46,6 +46,9 @@ inline float getMass(int pdgCode) case kLambda0: mass = o2::constants::physics::MassLambda; break; + case kXiMinus: + mass = o2::constants::physics::MassXiMinus; + break; case o2::constants::physics::Pdg::kPhi: mass = o2::constants::physics::MassPhi; break; @@ -83,7 +86,19 @@ inline int checkDaughterType(o2::aod::femtodreamparticle::ParticleType partType, } // switch } else if (partType == o2::aod::femtodreamparticle::ParticleType::kV0) { - partOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kSecondary; + switch (abs(motherPDG)) { + case kSigma0: + partOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kSecondaryDaughterSigma0; + break; + case kXiMinus: + partOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kSecondaryDaughterXiMinus; + break; + case o2::constants::physics::Pdg::kXi0: + partOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kSecondaryDaughterXi0; + break; + default: + partOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kSecondary; + } } else if (partType == o2::aod::femtodreamparticle::ParticleType::kV0Child) { switch (abs(motherPDG)) { @@ -118,5 +133,22 @@ inline bool containsNameValuePair(const std::vector& myVector, const std::str return false; // No match found } +template +float itsSignal(T const& track) +{ + uint32_t clsizeflag = track.itsClusterSizes(); + auto clSizeLayer0 = (clsizeflag >> (0 * 4)) & 0xf; + auto clSizeLayer1 = (clsizeflag >> (1 * 4)) & 0xf; + auto clSizeLayer2 = (clsizeflag >> (2 * 4)) & 0xf; + auto clSizeLayer3 = (clsizeflag >> (3 * 4)) & 0xf; + auto clSizeLayer4 = (clsizeflag >> (4 * 4)) & 0xf; + auto clSizeLayer5 = (clsizeflag >> (5 * 4)) & 0xf; + auto clSizeLayer6 = (clsizeflag >> (6 * 4)) & 0xf; + int numLayers = 7; + int sumClusterSizes = clSizeLayer1 + clSizeLayer2 + clSizeLayer3 + clSizeLayer4 + clSizeLayer5 + clSizeLayer6 + clSizeLayer0; + float cosLamnda = 1. / std::cosh(track.eta()); + return (static_cast(sumClusterSizes) / numLayers) * cosLamnda; +}; + } // namespace o2::analysis::femtoDream #endif // PWGCF_FEMTODREAM_CORE_FEMTODREAMUTILS_H_ diff --git a/PWGCF/FemtoDream/Core/femtoDreamV0Selection.h b/PWGCF/FemtoDream/Core/femtoDreamV0Selection.h index 2ae0f46a967..40158105a5b 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamV0Selection.h +++ b/PWGCF/FemtoDream/Core/femtoDreamV0Selection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -471,10 +471,10 @@ bool FemtoDreamV0Selection::isSelectedMinimal(C const& /*col*/, V const& v0, // v0 auto nSigmaPiNeg = negTrack.tpcNSigmaPi(); auto nSigmaPrPos = posTrack.tpcNSigmaPr(); - if (!(abs(nSigmaPrNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax && - abs(nSigmaPiPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax) && - !(abs(nSigmaPrPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax && - abs(nSigmaPiNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax)) { + if (!(std::abs(nSigmaPrNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax && + std::abs(nSigmaPiPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax) && + !(std::abs(nSigmaPrPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax && + std::abs(nSigmaPiNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax)) { return false; } @@ -550,16 +550,16 @@ template std::array FemtoDreamV0Selection::getCutContainer(C const& /*col*/, V const& v0, T const& posTrack, T const& negTrack) { - auto outputPosTrack = PosDaughTrack.getCutContainer(posTrack, v0.positivept(), v0.positiveeta(), v0.dcapostopv()); - auto outputNegTrack = NegDaughTrack.getCutContainer(negTrack, v0.negativept(), v0.negativeeta(), v0.dcanegtopv()); + auto outputPosTrack = PosDaughTrack.getCutContainer(posTrack, v0.positivept(), v0.positiveeta(), v0.dcapostopv()); + auto outputNegTrack = NegDaughTrack.getCutContainer(negTrack, v0.negativept(), v0.negativeeta(), v0.dcanegtopv()); cutContainerType output = 0; size_t counter = 0; auto lambdaMassNominal = o2::constants::physics::MassLambda; auto lambdaMassHypothesis = v0.mLambda(); auto antiLambdaMassHypothesis = v0.mAntiLambda(); - auto diffLambda = abs(lambdaMassNominal - lambdaMassHypothesis); - auto diffAntiLambda = abs(antiLambdaMassHypothesis - lambdaMassHypothesis); + auto diffLambda = std::abs(lambdaMassNominal - lambdaMassHypothesis); + auto diffAntiLambda = std::abs(antiLambdaMassHypothesis - lambdaMassHypothesis); float sign = 0.; int nSigmaPIDMax = PosDaughTrack.getSigmaPIDMax(); @@ -568,15 +568,15 @@ std::array auto nSigmaPiNeg = negTrack.tpcNSigmaPi(); auto nSigmaPrPos = posTrack.tpcNSigmaPr(); // check the mass and the PID of daughters - if (abs(nSigmaPrNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax && abs(nSigmaPiPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax && diffAntiLambda > diffLambda) { + if (std::abs(nSigmaPrNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax && std::abs(nSigmaPiPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax && diffAntiLambda > diffLambda) { sign = -1.; - } else if (abs(nSigmaPrPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax && abs(nSigmaPiNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax && diffAntiLambda < diffLambda) { + } else if (std::abs(nSigmaPrPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax && std::abs(nSigmaPiNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax && diffAntiLambda < diffLambda) { sign = 1.; } else { // if it happens that none of these are true, ignore the invariant mass - if (abs(nSigmaPrNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax && abs(nSigmaPiPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax) { + if (std::abs(nSigmaPrNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax && std::abs(nSigmaPiPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax) { sign = -1.; - } else if (abs(nSigmaPrPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax && abs(nSigmaPiNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax) { + } else if (std::abs(nSigmaPrPos - nSigmaPIDOffsetTPC) < nSigmaPIDMax && std::abs(nSigmaPiNeg - nSigmaPIDOffsetTPC) < nSigmaPIDMax) { sign = 1.; } } diff --git a/PWGCF/FemtoDream/DataModel/CMakeLists.txt b/PWGCF/FemtoDream/DataModel/CMakeLists.txt index 4c182222bf2..da01f4ab983 100644 --- a/PWGCF/FemtoDream/DataModel/CMakeLists.txt +++ b/PWGCF/FemtoDream/DataModel/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2024 CERN and copyright holders of ALICE O2. +# Copyright 2019-2025 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. # diff --git a/PWGCF/FemtoDream/TableProducer/CMakeLists.txt b/PWGCF/FemtoDream/TableProducer/CMakeLists.txt index 4f48c6bf10a..77ece58f958 100644 --- a/PWGCF/FemtoDream/TableProducer/CMakeLists.txt +++ b/PWGCF/FemtoDream/TableProducer/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2024 CERN and copyright holders of ALICE O2. +# Copyright 2019-2025 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. # @@ -14,6 +14,11 @@ o2physics_add_dpl_workflow(femtodream-producer PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femtodream-producer-withcascades + SOURCES femtoDreamProducerTaskWithCascades.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(femtodream-producer-reduced SOURCES femtoDreamProducerReducedTask.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore @@ -23,4 +28,3 @@ o2physics_add_dpl_workflow(femtodream-producer-for-specific-analysis SOURCES femtoDreamProducerTaskForSpecificAnalysis.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) - diff --git a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerReducedTask.cxx b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerReducedTask.cxx index f5e72eeda89..a879a18517f 100644 --- a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerReducedTask.cxx +++ b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerReducedTask.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -15,8 +15,9 @@ /// \author Georgios Mantzaridis, TU München, georgios.mantzaridis@tum.de /// \author Anton Riedel, TU München, anton.riedel@tum.de +#include #include "TMath.h" -#include +#include "CCDB/BasicCCDBManager.h" #include "PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" @@ -28,6 +29,7 @@ #include "Framework/ASoAHelpers.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" #include "ReconstructionDataFormats/Track.h" @@ -266,7 +268,7 @@ struct femtoDreamProducerReducedTask { trackCuts.fillQA(track); // an array of two bit-wise containers of the systematic variations is obtained // one container for the track quality cuts and one for the PID cuts - auto cutContainer = trackCuts.getCutContainer(track, track.pt(), track.eta(), sqrtf(powf(track.dcaXY(), 2.f) + powf(track.dcaZ(), 2.f))); + auto cutContainer = trackCuts.getCutContainer(track, track.pt(), track.eta(), sqrtf(powf(track.dcaXY(), 2.f) + powf(track.dcaZ(), 2.f))); // now the table is filled outputParts(outputCollision.lastIndex(), @@ -307,7 +309,16 @@ struct femtoDreamProducerReducedTask { track.tofNSigmaDe(), track.tofNSigmaTr(), track.tofNSigmaHe(), - -999., -999., -999., -999., -999., -999.); + -1, + track.itsNSigmaEl(), + track.itsNSigmaPi(), + track.itsNSigmaKa(), + track.itsNSigmaPr(), + track.itsNSigmaDe(), + track.itsNSigmaTr(), + track.itsNSigmaHe(), + -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., -999.); } } } @@ -317,8 +328,11 @@ struct femtoDreamProducerReducedTask { { // get magnetic field for run getMagneticFieldTesla(col.bc_as()); + + auto tracksWithItsPid = soa::Attach(tracks); // fill the tables - fillCollisionsAndTracks(col, tracks); + fillCollisionsAndTracks(col, tracksWithItsPid); } PROCESS_SWITCH(femtoDreamProducerReducedTask, processData, "Provide experimental data", true); @@ -329,8 +343,10 @@ struct femtoDreamProducerReducedTask { { // get magnetic field for run getMagneticFieldTesla(col.bc_as()); + auto tracksWithItsPid = soa::Attach, aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaPi, aod::pidits::ITSNSigmaKa, + aod::pidits::ITSNSigmaPr, aod::pidits::ITSNSigmaDe, aod::pidits::ITSNSigmaTr, aod::pidits::ITSNSigmaHe>(tracks); // fill the tables - fillCollisionsAndTracks(col, tracks); + fillCollisionsAndTracks(col, tracksWithItsPid); } PROCESS_SWITCH(femtoDreamProducerReducedTask, processMC, "Provide MC data", false); @@ -341,8 +357,10 @@ struct femtoDreamProducerReducedTask { { // get magnetic field for run getMagneticFieldTesla(col.bc_as()); + auto tracksWithItsPid = soa::Attach, aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaPi, aod::pidits::ITSNSigmaKa, + aod::pidits::ITSNSigmaPr, aod::pidits::ITSNSigmaDe, aod::pidits::ITSNSigmaTr, aod::pidits::ITSNSigmaHe>(tracks); // fill the tables - fillCollisionsAndTracks(col, tracks); + fillCollisionsAndTracks(col, tracksWithItsPid); } PROCESS_SWITCH(femtoDreamProducerReducedTask, processMC_noCentrality, "Provide MC data", false); }; diff --git a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTask.cxx b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTask.cxx index eacdb3b96b5..7272382f357 100644 --- a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTask.cxx +++ b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTask.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -22,12 +22,14 @@ #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" #include "Common/DataModel/TrackSelectionTables.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" #include "PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamV0Selection.h" +#include "PWGCF/FemtoDream/Core/femtoDreamCascadeSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" @@ -102,6 +104,7 @@ struct femtoDreamProducerTask { Produces outputPartsExtMCLabels; Configurable ConfIsDebug{"ConfIsDebug", true, "Enable Debug tables"}; + Configurable ConfUseItsPid{"ConfUseItsPid", false, "Enable Debug tables"}; Configurable ConfIsRun3{"ConfIsRun3", false, "Running on Run3 or pilot"}; Configurable ConfIsForceGRP{"ConfIsForceGRP", false, "Set true if the magnetic field configuration is not available in the usual CCDB directory (e.g. for Run 2 converted data or unanchorad Monte Carlo)"}; /// Event cuts @@ -168,6 +171,7 @@ struct femtoDreamProducerTask { Configurable> ConfChildPIDnSigmaMax{"ConfChildPIDnSigmaMax", std::vector{5.f, 4.f}, "V0 Child sel: Max. PID nSigma TPC"}; Configurable> ConfChildPIDspecies{"ConfChildPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Proton}, "V0 Child sel: Particles species for PID"}; + // Resonances Configurable ConfResoInvMassLowLimit{"ConfResoInvMassLowLimit", 1.011461, "Lower limit of the Reso invariant mass"}; Configurable ConfResoInvMassUpLimit{"ConfResoInvMassUpLimit", 1.027461, "Upper limit of the Reso invariant mass"}; Configurable> ConfDaughterCharge{"ConfDaughterCharge", std::vector{1, -1}, "Reso Daughter sel: Charge"}; @@ -191,6 +195,16 @@ struct femtoDreamProducerTask { // (aod::v0data::v0radius > V0TranRadV0Min.value); to be added, not working // for now do not know why + /// General options + struct : o2::framework::ConfigurableGroup { + Configurable ConfTrkMinChi2PerClusterTPC{"ConfTrkMinChi2PerClusterTPC", 0.f, "Lower limit for chi2 of TPC; currently for testing only"}; + Configurable ConfTrkMaxChi2PerClusterTPC{"ConfTrkMaxChi2PerClusterTPC", 1000.f, "Upper limit for chi2 of TPC; currently for testing only"}; + Configurable ConfTrkMaxChi2PerClusterITS{"ConfTrkMaxChi2PerClusterITS", 1000.0f, "Minimal track selection: max allowed chi2 per ITS cluster"}; // 36.0 is default + Configurable ConfTrkTPCRefit{"ConfTrkTPCRefit", false, "True: require TPC refit"}; + Configurable ConfTrkITSRefit{"ConfTrkITSRefit", false, "True: require ITS refit"}; + + } OptionTrackSpecialSelections; + HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry TrackRegistry{"Tracks", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry V0Registry{"V0", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -214,6 +228,12 @@ struct femtoDreamProducerTask { int CutBits = 8 * sizeof(o2::aod::femtodreamparticle::cutContainerType); TrackRegistry.add("AnalysisQA/CutCounter", "; Bit; Counter", kTH1F, {{CutBits + 1, -0.5, CutBits + 0.5}}); + TrackRegistry.add("AnalysisQA/Chi2ITSTPCperCluster", "; ITS_Chi2; TPC_Chi2", kTH2F, {{100, 0, 50}, {100, 0, 20}}); + TrackRegistry.add("AnalysisQA/RefitITSTPC", "; ITS_Refit; TPC_Refit", kTH2F, {{2, 0, 2}, {2, 0, 2}}); + TrackRegistry.add("AnalysisQA/getGenStatusCode", "; Bit; Entries", kTH1F, {{200, 0, 200}}); + TrackRegistry.add("AnalysisQA/getProcess", "; Bit; Entries", kTH1F, {{200, 0, 200}}); + TrackRegistry.add("AnalysisQA/Mother", "; Bit; Entries", kTH1F, {{4000, -4000, 4000}}); + TrackRegistry.add("AnalysisQA/Particle", "; Bit; Entries", kTH1F, {{4000, -4000, 4000}}); V0Registry.add("AnalysisQA/CutCounter", "; Bit; Counter", kTH1F, {{CutBits + 1, -0.5, CutBits + 0.5}}); ResoRegistry.add("AnalysisQA/Reso/InvMass", "Invariant mass V0s;M_{KK};Entries", HistType::kTH1F, {{7000, 0.8, 1.5}}); ResoRegistry.add("AnalysisQA/Reso/InvMass_selected", "Invariant mass V0s;M_{KK};Entries", HistType::kTH1F, {{7000, 0.8, 1.5}}); @@ -274,6 +294,7 @@ struct femtoDreamProducerTask { v0Cuts.setChildCuts(femtoDreamV0Selection::kPosTrack, ConfChildTPCnClsMin, femtoDreamTrackSelection::kTPCnClsMin, femtoDreamSelection::kLowerLimit); v0Cuts.setChildCuts(femtoDreamV0Selection::kPosTrack, ConfChildDCAMin, femtoDreamTrackSelection::kDCAMin, femtoDreamSelection::kAbsLowerLimit); v0Cuts.setChildCuts(femtoDreamV0Selection::kPosTrack, ConfChildPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit); + v0Cuts.setChildCuts(femtoDreamV0Selection::kNegTrack, ConfChildCharge, femtoDreamTrackSelection::kSign, femtoDreamSelection::kEqual); v0Cuts.setChildCuts(femtoDreamV0Selection::kNegTrack, ConfChildEtaMax, femtoDreamTrackSelection::kEtaMax, femtoDreamSelection::kAbsUpperLimit); v0Cuts.setChildCuts(femtoDreamV0Selection::kNegTrack, ConfChildTPCnClsMin, femtoDreamTrackSelection::kTPCnClsMin, femtoDreamSelection::kLowerLimit); @@ -350,47 +371,89 @@ struct femtoDreamProducerTask { } } - template + template void fillDebugParticle(ParticleType const& particle) { if constexpr (isTrackOrV0) { - outputDebugParts(particle.sign(), - (uint8_t)particle.tpcNClsFound(), - particle.tpcNClsFindable(), - (uint8_t)particle.tpcNClsCrossedRows(), - particle.tpcNClsShared(), - particle.tpcInnerParam(), - particle.itsNCls(), - particle.itsNClsInnerBarrel(), - particle.dcaXY(), - particle.dcaZ(), - particle.tpcSignal(), - particle.tpcNSigmaEl(), - particle.tpcNSigmaPi(), - particle.tpcNSigmaKa(), - particle.tpcNSigmaPr(), - particle.tpcNSigmaDe(), - particle.tpcNSigmaTr(), - particle.tpcNSigmaHe(), - particle.tofNSigmaEl(), - particle.tofNSigmaPi(), - particle.tofNSigmaKa(), - particle.tofNSigmaPr(), - particle.tofNSigmaDe(), - particle.tofNSigmaTr(), - particle.tofNSigmaHe(), - -999., -999., -999., -999., -999., -999.); + if constexpr (hasItsPid) { + outputDebugParts(particle.sign(), + (uint8_t)particle.tpcNClsFound(), + particle.tpcNClsFindable(), + (uint8_t)particle.tpcNClsCrossedRows(), + particle.tpcNClsShared(), + particle.tpcInnerParam(), + particle.itsNCls(), + particle.itsNClsInnerBarrel(), + particle.dcaXY(), + particle.dcaZ(), + particle.tpcSignal(), + particle.tpcNSigmaEl(), + particle.tpcNSigmaPi(), + particle.tpcNSigmaKa(), + particle.tpcNSigmaPr(), + particle.tpcNSigmaDe(), + particle.tpcNSigmaTr(), + particle.tpcNSigmaHe(), + particle.tofNSigmaEl(), + particle.tofNSigmaPi(), + particle.tofNSigmaKa(), + particle.tofNSigmaPr(), + particle.tofNSigmaDe(), + particle.tofNSigmaTr(), + particle.tofNSigmaHe(), + o2::analysis::femtoDream::itsSignal(particle), + particle.itsNSigmaEl(), + particle.itsNSigmaPi(), + particle.itsNSigmaKa(), + particle.itsNSigmaPr(), + particle.itsNSigmaDe(), + particle.itsNSigmaTr(), + particle.itsNSigmaHe(), + -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., -999.); + } else { + outputDebugParts(particle.sign(), + (uint8_t)particle.tpcNClsFound(), + particle.tpcNClsFindable(), + (uint8_t)particle.tpcNClsCrossedRows(), + particle.tpcNClsShared(), + particle.tpcInnerParam(), + particle.itsNCls(), + particle.itsNClsInnerBarrel(), + particle.dcaXY(), + particle.dcaZ(), + particle.tpcSignal(), + particle.tpcNSigmaEl(), + particle.tpcNSigmaPi(), + particle.tpcNSigmaKa(), + particle.tpcNSigmaPr(), + particle.tpcNSigmaDe(), + particle.tpcNSigmaTr(), + particle.tpcNSigmaHe(), + particle.tofNSigmaEl(), + particle.tofNSigmaPi(), + particle.tofNSigmaKa(), + particle.tofNSigmaPr(), + particle.tofNSigmaDe(), + particle.tofNSigmaTr(), + particle.tofNSigmaHe(), + -999., -999., -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., -999.); + } } else { - outputDebugParts(-999., -999., -999., -999., -999., -999., -999., - -999., -999., -999., -999., -999., -999., -999., - -999., -999., -999., -999., -999., -999., -999., - -999., -999., -999., -999., + outputDebugParts(-999., // sign + -999., -999., -999., -999., -999., -999., -999., -999., -999., // track properties (DCA, NCls, crossed rows, etc.) + -999., -999., -999., -999., -999., -999., -999., -999., // TPC PID (TPC signal + particle hypothesis) + -999., -999., -999., -999., -999., -999., -999., // TOF PID + -999., -999., -999., -999., -999., -999., -999., -999., // ITS PID particle.dcaV0daughters(), particle.v0radius(), particle.x(), particle.y(), particle.z(), - particle.mK0Short()); + particle.mK0Short(), + -999., -999., -999., -999., -999., -999., -999.); // Cascade properties } } @@ -401,11 +464,14 @@ struct femtoDreamProducerTask { // get corresponding MC particle and its info auto particleMC = particle.mcParticle(); auto pdgCode = particleMC.pdgCode(); + TrackRegistry.fill(HIST("AnalysisQA/Particle"), pdgCode); int particleOrigin = 99; int pdgCodeMother = -1; // get list of mothers, but it could be empty (for example in case of injected light nuclei) auto motherparticlesMC = particleMC.template mothers_as(); // check pdg code + TrackRegistry.fill(HIST("AnalysisQA/getGenStatusCode"), particleMC.getGenStatusCode()); + TrackRegistry.fill(HIST("AnalysisQA/getProcess"), particleMC.getProcess()); // if this fails, the particle is a fake if (abs(pdgCode) == abs(ConfTrkPDGCode.value)) { // check first if particle is from pile up @@ -423,6 +489,7 @@ struct femtoDreamProducerTask { // get direct mother auto motherparticleMC = motherparticlesMC.front(); pdgCodeMother = motherparticleMC.pdgCode(); + TrackRegistry.fill(HIST("AnalysisQA/Mother"), pdgCodeMother); particleOrigin = checkDaughterType(fdparttype, motherparticleMC.pdgCode()); // check if particle is material // particle is from inelastic hadronic interaction -> getProcess() == 23 @@ -463,8 +530,8 @@ struct femtoDreamProducerTask { outputCollsMCLabels(-1); } } - template - void fillCollisionsAndTracksAndV0(CollisionType const& col, TrackType const& tracks, V0Type const& fullV0s) + template + void fillCollisionsAndTracksAndV0(CollisionType const& col, TrackType const& tracks, TrackTypeWithItsPid const& tracksWithItsPid, V0Type const& fullV0s) { // If triggering is enabled, select only events which were triggered wit our triggers if (ConfEnableTriggerSelection) { @@ -518,17 +585,34 @@ struct femtoDreamProducerTask { std::vector childIDs = {0, 0}; // these IDs are necessary to keep track of the children std::vector tmpIDtrack; // this vector keeps track of the matching of the primary track table row <-> aod::track table global index - std::vector Daughter1, Daughter2; + std::vector Daughter1, Daughter2; - for (auto& track : tracks) { + for (auto& track : tracksWithItsPid) { /// if the most open selection criteria are not fulfilled there is no /// point looking further at the track + trackCuts.fillQA(track); + + if (track.tpcChi2NCl() < OptionTrackSpecialSelections.ConfTrkMinChi2PerClusterTPC || track.tpcChi2NCl() > OptionTrackSpecialSelections.ConfTrkMaxChi2PerClusterTPC) { + continue; + } + if (track.itsChi2NCl() > OptionTrackSpecialSelections.ConfTrkMaxChi2PerClusterITS) { + continue; + } + if ((OptionTrackSpecialSelections.ConfTrkTPCRefit && !track.hasTPC()) || (OptionTrackSpecialSelections.ConfTrkITSRefit && !track.hasITS())) { + continue; + } + if (!trackCuts.isSelectedMinimal(track)) { continue; } - trackCuts.fillQA(track); + + TrackRegistry.fill(HIST("AnalysisQA/Chi2ITSTPCperCluster"), track.itsChi2NCl(), track.tpcChi2NCl()); + TrackRegistry.fill(HIST("AnalysisQA/RefitITSTPC"), track.hasITS(), track.hasTPC()); + + trackCuts.fillQA(track); // the bit-wise container of the systematic variations is obtained - auto cutContainer = trackCuts.getCutContainer(track, track.pt(), track.eta(), sqrtf(powf(track.dcaXY(), 2.f) + powf(track.dcaZ(), 2.f))); + std::array cutContainer; + cutContainer = trackCuts.getCutContainer(track, track.pt(), track.eta(), sqrtf(powf(track.dcaXY(), 2.f) + powf(track.dcaZ(), 2.f))); // now the table is filled outputParts(outputCollision.lastIndex(), @@ -541,7 +625,7 @@ struct femtoDreamProducerTask { track.dcaXY(), childIDs, 0, 0); tmpIDtrack.push_back(track.globalIndex()); if (ConfIsDebug.value) { - fillDebugParticle(track); + fillDebugParticle(track); } if constexpr (isMC) { @@ -577,6 +661,7 @@ struct femtoDreamProducerTask { if (ConfIsActivateV0.value) { for (auto& v0 : fullV0s) { + auto postrack = v0.template posTrack_as(); auto negtrack = v0.template negTrack_as(); ///\tocheck funnily enough if we apply the filter the @@ -652,9 +737,9 @@ struct femtoDreamProducerTask { v0.mLambda(), v0.mAntiLambda()); if (ConfIsDebug.value) { - fillDebugParticle(postrack); // QA for positive daughter - fillDebugParticle(negtrack); // QA for negative daughter - fillDebugParticle(v0); // QA for v0 + fillDebugParticle(postrack); // QA for positive daughter + fillDebugParticle(negtrack); // QA for negative daughter + fillDebugParticle(v0); // QA for v0 } if constexpr (isMC) { fillMCParticle(col, v0, o2::aod::femtodreamparticle::ParticleType::kV0); @@ -714,12 +799,15 @@ struct femtoDreamProducerTask { tempPhi.M(), tempPhi.M()); if (ConfIsDebug.value) { - fillDebugParticle(Daughter1.at(iDaug1)); // QA for positive daughter - fillDebugParticle(Daughter2.at(iDaug2)); // QA for negative daughter - outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., - -999., -999., -999., -999., -999., -999., -999., -999., - -999., -999., -999., -999., -999., -999., -999., -999., - -999., -999. - 999., -999., -999., -999., -999., -999.); // QA for Reso + fillDebugParticle(Daughter1.at(iDaug1)); // QA for positive daughter + fillDebugParticle(Daughter2.at(iDaug2)); // QA for negative daughter + outputDebugParts(-999., // sign + -999., -999., -999., -999., -999., -999., -999., -999., -999., // track properties (DCA, NCls, crossed rows, etc.) + -999., -999., -999., -999., -999., -999., -999., -999., // TPC PID (TPC signal + particle hypothesis) + -999., -999., -999., -999., -999., -999., -999., // TOF PID + -999., -999., -999., -999., -999., -999., -999., -999., // ITS PID + -999., -999., -999., -999., -999., -999., // V0 properties + -999., -999., -999., -999., -999., -999., -999.); // Cascade properties } } } @@ -736,7 +824,13 @@ struct femtoDreamProducerTask { // get magnetic field for run initCCDB_Mag_Trig(col.bc_as()); // fill the tables - fillCollisionsAndTracksAndV0(col, tracks, fullV0s); + auto tracksWithItsPid = soa::Attach(tracks); + if (ConfUseItsPid.value) { + fillCollisionsAndTracksAndV0(col, tracks, tracksWithItsPid, fullV0s); + } else { + fillCollisionsAndTracksAndV0(col, tracks, tracks, fullV0s); + } } PROCESS_SWITCH(femtoDreamProducerTask, processData, "Provide experimental data", true); @@ -750,21 +844,32 @@ struct femtoDreamProducerTask { // get magnetic field for run initCCDB_Mag_Trig(col.bc_as()); // fill the tables - fillCollisionsAndTracksAndV0(col, tracks, fullV0s); + auto tracksWithItsPid = soa::Attach(tracks); + if (ConfUseItsPid.value) { + fillCollisionsAndTracksAndV0(col, tracks, tracksWithItsPid, fullV0s); + } else { + fillCollisionsAndTracksAndV0(col, tracks, tracks, fullV0s); + } } PROCESS_SWITCH(femtoDreamProducerTask, processData_noCentrality, "Provide experimental data without centrality information", false); - void - processData_CentPbPb(aod::FemtoFullCollision_CentPbPb const& col, - aod::BCsWithTimestamps const&, - aod::FemtoFullTracks const& tracks, - o2::aod::V0Datas const& fullV0s) + void processData_CentPbPb(aod::FemtoFullCollision_CentPbPb const& col, + aod::BCsWithTimestamps const&, + aod::FemtoFullTracks const& tracks, + o2::aod::V0Datas const& fullV0s) { // get magnetic field for run initCCDB_Mag_Trig(col.bc_as()); // fill the tables - fillCollisionsAndTracksAndV0(col, tracks, fullV0s); + auto tracksWithItsPid = soa::Attach(tracks); + if (ConfUseItsPid.value) { + fillCollisionsAndTracksAndV0(col, tracks, tracksWithItsPid, fullV0s); + } else { + fillCollisionsAndTracksAndV0(col, tracks, tracks, fullV0s); + } } PROCESS_SWITCH(femtoDreamProducerTask, processData_CentPbPb, "Provide experimental data with centrality information for PbPb collisions", false); @@ -779,7 +884,7 @@ struct femtoDreamProducerTask { // get magnetic field for run initCCDB_Mag_Trig(col.bc_as()); // fill the tables - fillCollisionsAndTracksAndV0(col, tracks, fullV0s); + fillCollisionsAndTracksAndV0(col, tracks, tracks, fullV0s); } PROCESS_SWITCH(femtoDreamProducerTask, processMC, "Provide MC data", false); @@ -793,7 +898,7 @@ struct femtoDreamProducerTask { // get magnetic field for run initCCDB_Mag_Trig(col.bc_as()); // fill the tables - fillCollisionsAndTracksAndV0(col, tracks, fullV0s); + fillCollisionsAndTracksAndV0(col, tracks, tracks, fullV0s); } PROCESS_SWITCH(femtoDreamProducerTask, processMC_noCentrality, "Provide MC data without requiring a centrality calibration", false); @@ -807,7 +912,7 @@ struct femtoDreamProducerTask { // get magnetic field for run initCCDB_Mag_Trig(col.bc_as()); // fill the tables - fillCollisionsAndTracksAndV0(col, tracks, fullV0s); + fillCollisionsAndTracksAndV0(col, tracks, tracks, fullV0s); } PROCESS_SWITCH(femtoDreamProducerTask, processMC_CentPbPb, "Provide MC data with centrality information for PbPb collisions", false); }; diff --git a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTaskForSpecificAnalysis.cxx b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTaskForSpecificAnalysis.cxx index b6ea6cd5f90..33f07d2772e 100644 --- a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTaskForSpecificAnalysis.cxx +++ b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTaskForSpecificAnalysis.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -13,24 +13,24 @@ /// \brief Tasks that reads the track tables and creates track triplets; only three identical particles can be used /// \author Laura Serksnyte, TU München, laura.serksnyte@tum.de -#include -#include +#include "PWGCF/DataModel/FemtoDerived.h" +#include "PWGCF/FemtoDream/Core/femtoDreamContainerThreeBody.h" +#include "PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h" +#include "PWGCF/FemtoDream/Core/femtoDreamEventHisto.h" +#include "PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h" +#include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h" +#include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" + +#include "Framework/ASoAHelpers.h" #include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" -#include "Framework/ASoAHelpers.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/RunningWorkflowInfo.h" #include "Framework/StepTHn.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "TDatabasePDG.h" +#include "Framework/runDataProcessing.h" -#include "PWGCF/DataModel/FemtoDerived.h" -#include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h" -#include "PWGCF/FemtoDream/Core/femtoDreamEventHisto.h" -#include "PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h" -#include "PWGCF/FemtoDream/Core/femtoDreamContainerThreeBody.h" -#include "PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h" -#include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" +#include +#include using namespace o2; using namespace o2::analysis::femtoDream; @@ -38,7 +38,7 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -struct femtoDreamProducerTaskForSpecificAnalysis { +struct FemtoDreamProducerTaskForSpecificAnalysis { SliceCache cache; @@ -49,28 +49,47 @@ struct femtoDreamProducerTaskForSpecificAnalysis { float mMassOne = -999, mMassTwo = -999, mMassThree = -999; int collisions = 0; - Configurable ConfNumberOfTracks{"ConfNumberOfTracks", 3, "Number of tracks"}; - Configurable ConfNumberOfV0{"ConfNumberOfV0", 0, "Number of V0"}; + // Require bitmask selection for candidates + Configurable confRequireBitmask{"confRequireBitmask", false, "Require bitmask selection for candidates"}; + + // Number of candidates required + Configurable confNumberOfTracks{"confNumberOfTracks", 3, "Number of tracks"}; + Configurable confNumberOfV0{"confNumberOfV0", 0, "Number of V0"}; + Configurable confNumberOfCascades{"confNumberOfCascades", 0, "Number of Cascades"}; /// Track selection - Configurable ConfPIDthrMom{"ConfPIDthrMom", 1.f, "Momentum threshold from which TPC and TOF are required for PID"}; - Configurable ConfTPCPIDBit{"ConfTPCPIDBit", 16, "PID TPC bit from cutCulator "}; - Configurable ConfTPCTOFPIDBit{"ConfTPCTOFPIDBit", 8, "PID TPCTOF bit from cutCulator"}; + Configurable confPIDthrMom{"confPIDthrMom", 1.f, "Momentum threshold from which TPC and TOF are required for PID"}; + Configurable confTPCPIDBit{"confTPCPIDBit", 16, "PID TPC bit from cutCulator "}; + Configurable confTPCTOFPIDBit{"confTPCTOFPIDBit", 8, "PID TPCTOF bit from cutCulator"}; + Configurable confCutPart{"confCutPart", 0, "Track - Selection bit from cutCulator for part"}; + Configurable confCutPartAntiPart{"confCutPartAntiPart", 0, "Track - Selection bit from cutCulator for antipart"}; /// Partition for selected particles - Partition SelectedParts = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && - ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= ConfPIDthrMom, ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCPIDBit), ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCTOFPIDBit)); + Partition selectedParts = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && + ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= confPIDthrMom, ncheckbit(aod::femtodreamparticle::pidcut, confTPCPIDBit), ncheckbit(aod::femtodreamparticle::pidcut, confTPCTOFPIDBit)); /// V0 selection - Configurable Conf_minInvMass_V0{"Conf_minInvMass_V0", 1.08, "Minimum invariant mass of V0 (particle)"}; - Configurable Conf_maxInvMass_V0{"Conf_maxInvMass_V0", 1.15, "Maximum invariant mass of V0 (particle)"}; - Configurable Conf_minInvMassAnti_V0{"Conf_minInvMassAnti_V0", 1.08, "Minimum invariant mass of V0 (antiparticle)"}; - Configurable Conf_maxInvMassAnti_V0{"Conf_maxInvMassAnti_V0", 1.15, "Maximum invariant mass of V0 (antiparticle)"}; + Configurable confMinInvMassV0{"confMinInvMassV0", 1.08, "Minimum invariant mass of V0 (particle)"}; + Configurable confMaxInvMassV0{"confMaxInvMassV0", 1.15, "Maximum invariant mass of V0 (particle)"}; + Configurable confMinInvMassAntiV0{"confMinInvMassAntiV0", 1.08, "Minimum invariant mass of V0 (antiparticle)"}; + Configurable confMaxInvMassAntiV0{"confMaxInvMassAntiV0", 1.15, "Maximum invariant mass of V0 (antiparticle)"}; + Configurable confCutV0SameForAntipart{"confCutV0SameForAntipart", 0, "V0 - Selection bit from cutCulator for part/antipart"}; + Configurable confChildPosCutV0{"confChildPosCutV0", 149, "Selection bit for positive child of V0"}; + Configurable confChildPosTPCBitV0{"confChildPosTPCBitV0", 2, "PID TPC bit for positive child of V0"}; + Configurable confChildNegCutV0{"confChildNegCutV0", 149, "Selection bit for negative child of V0"}; + Configurable confChildNegTPCBitV0{"confChildNegTPCBitV0", 2, "PID TPC bit for negative child of V0"}; + + /// Cascade selection + Configurable confMinInvMassCascade{"confMinInvMassCascade", 1.2, "Minimum invariant mass of Cascade (particle)"}; + Configurable confMaxInvMassCascade{"confMaxInvMassCascade", 1.5, "Maximum invariant mass of Cascade (particle)"}; // Partition for selected particles - Partition SelectedV0s = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0)); + Partition selectedV0s = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0)); + Partition selectedCascades = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kCascade)); + + HistogramRegistry eventRegistry{"eventRegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry EventRegistry{"EventRegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; + static constexpr uint32_t kSignPlusMask = 1 << 1; template int getRowDaughters(int daughID, T const& vecID) @@ -87,9 +106,13 @@ struct femtoDreamProducerTaskForSpecificAnalysis { void init(InitContext&) { - EventRegistry.add("hStatistiscs", ";bin;Entries", kTH1F, {{3, 0, 3}}); - // get bit for the collision mask + eventRegistry.add("hStatistiscs", ";bin;Entries", kTH1F, {{3, 0, 3}}); + // Never run V0s and Cascades together as this will DOUBLE the track number and induce self correlations + if ((doprocessCollisionsWithNTracksAndNCascades && doprocessCollisionsWithNTracksAndNV0)) { + LOG(fatal) << "Never run V0s and Cascades together as this will DOUBLE the track number and induce self correlations!"; + } } + /// This function stores accepted collisions in derived data /// @tparam PartitionType /// @tparam PartType @@ -98,36 +121,66 @@ struct femtoDreamProducerTaskForSpecificAnalysis { /// @param groupSelectedV0s partition for the second particle passed by the process function /// @param parts femtoDreamParticles table template - void createSpecifiedDerivedData(o2::aod::FDCollision& col, PartitionType groupSelectedTracks, PartitionType groupSelectedV0s, PartType parts) + void createSpecifiedDerivedData(const o2::aod::FDCollision& col, PartitionType groupSelectedTracks, PartitionType groupSelectedV0s, PartType parts) { /// check tracks int tracksCount = 0; int antitracksCount = 0; - for (auto& part : groupSelectedTracks) { + for (const auto& part : groupSelectedTracks) { if (part.cut() & 1) { - antitracksCount++; + if (!confRequireBitmask || ncheckbit(part.cut(), confCutPartAntiPart)) { + antitracksCount++; + } } else { - tracksCount++; + if (!confRequireBitmask || ncheckbit(part.cut(), confCutPart)) { + tracksCount++; + } } } /// check V0s - int V0Count = 0; + int v0Count = 0; int antiV0Count = 0; - for (auto& V0 : groupSelectedV0s) { - if ((V0.mLambda() > Conf_minInvMass_V0) && (V0.mLambda() < Conf_maxInvMass_V0)) { - V0Count++; - } else if ((V0.mAntiLambda() > Conf_minInvMassAnti_V0) && (V0.mAntiLambda() < Conf_maxInvMassAnti_V0)) { - antiV0Count++; + for (const auto& V0 : groupSelectedV0s) { + if ((V0.mLambda() > confMinInvMassV0) && (V0.mLambda() < confMaxInvMassV0)) { + if (confRequireBitmask) { + if (ncheckbit(V0.cut(), confCutV0SameForAntipart)) { + const auto& posChild = parts.iteratorAt(V0.index() - 2); + const auto& negChild = parts.iteratorAt(V0.index() - 1); + if (((posChild.cut() & confChildPosCutV0) == confChildPosCutV0 && + (posChild.pidcut() & confChildPosTPCBitV0) == confChildPosTPCBitV0 && + (negChild.cut() & confChildNegCutV0) == confChildNegCutV0 && + (negChild.pidcut() & confChildNegTPCBitV0) == confChildNegTPCBitV0)) { + v0Count++; + } + } + } else { + v0Count++; + } + } else if ((V0.mAntiLambda() > confMinInvMassAntiV0) && (V0.mAntiLambda() < confMaxInvMassAntiV0)) { + if (confRequireBitmask) { + if (ncheckbit(V0.cut(), confCutV0SameForAntipart)) { + const auto& posChild = parts.iteratorAt(V0.index() - 2); + const auto& negChild = parts.iteratorAt(V0.index() - 1); + if (((posChild.cut() & confChildPosCutV0) == confChildPosCutV0 && + (posChild.pidcut() & confChildNegTPCBitV0) == confChildNegTPCBitV0 && // exchanged values because checking antiparticle daughters and pid of particles exchange + (negChild.cut() & confChildNegCutV0) == confChildNegCutV0 && + (negChild.pidcut() & confChildPosTPCBitV0) == confChildPosTPCBitV0)) { // exchanged values because checking antiparticle daughters and pid of particles exchange + antiV0Count++; + } + } + } else { + antiV0Count++; + } } } std::vector tmpIDtrack; - if ((V0Count >= ConfNumberOfV0 && tracksCount >= ConfNumberOfTracks) || (antiV0Count >= ConfNumberOfV0 && antitracksCount >= ConfNumberOfTracks)) { - EventRegistry.fill(HIST("hStatistiscs"), 1); + if ((v0Count >= confNumberOfV0 && tracksCount >= confNumberOfTracks) || (antiV0Count >= confNumberOfV0 && antitracksCount >= confNumberOfTracks)) { + eventRegistry.fill(HIST("hStatistiscs"), 1); outputCollision(col.posZ(), col.multV0M(), col.multNtr(), col.sphericity(), col.magField()); - for (auto& femtoParticle : parts) { + for (const auto& femtoParticle : parts) { if (aod::femtodreamparticle::ParticleType::kTrack == femtoParticle.partType()) { std::vector childIDs = {0, 0}; outputParts(outputCollision.lastIndex(), @@ -183,29 +236,162 @@ struct femtoDreamProducerTaskForSpecificAnalysis { } } } else { - EventRegistry.fill(HIST("hStatistiscs"), 2); + eventRegistry.fill(HIST("hStatistiscs"), 2); } } /// process function to create derived data with only collisions containing n tracks /// \param col subscribe to the collision table (Data) /// \param parts subscribe to the femtoDreamParticleTable - void processCollisionsWithNTracksAndNV0(o2::aod::FDCollision& col, - o2::aod::FDParticles& parts) + void processCollisionsWithNTracksAndNV0(const o2::aod::FDCollision& col, + const o2::aod::FDParticles& parts) { - EventRegistry.fill(HIST("hStatistiscs"), 0); - auto thegroupSelectedParts = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupSelectedV0s = SelectedV0s->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + eventRegistry.fill(HIST("hStatistiscs"), 0); + auto thegroupSelectedParts = selectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + auto thegroupSelectedV0s = selectedV0s->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); createSpecifiedDerivedData(col, thegroupSelectedParts, thegroupSelectedV0s, parts); } - PROCESS_SWITCH(femtoDreamProducerTaskForSpecificAnalysis, processCollisionsWithNTracksAndNV0, "Enable producing data with ppp collisions for data", true); + PROCESS_SWITCH(FemtoDreamProducerTaskForSpecificAnalysis, processCollisionsWithNTracksAndNV0, "Enable producing data with ppp collisions for data", true); + + /// This function stores accepted collisions in derived data + /// @tparam PartitionType + /// @tparam PartType + /// @tparam isMC: enables Monte Carlo truth specific histograms + /// @param groupSelectedTracks partition for the first particle passed by the process function + /// @param groupSelectedV0s partition for the second particle passed by the process function + /// @param parts femtoDreamParticles table + template + void createSpecifiedDerivedDataTrkCascade(const o2::aod::FDCollision& col, PartitionType groupSelectedTracks, PartitionType groupSelectedCascades, PartType parts) + { + + /// check tracks + int tracksCount = 0; + int antitracksCount = 0; + for (const auto& part : groupSelectedTracks) { + if (part.cut() & 1) { + antitracksCount++; + } else { + tracksCount++; + } + } + + /// check Cascades + int ascadeCount = 0; + int antiCascadeCount = 0; + for (const auto& casc : groupSelectedCascades) { + if ((casc.cut() & kSignPlusMask) == kSignPlusMask) { + ascadeCount++; + } else { + antiCascadeCount++; + } + } + + std::vector tmpIDtrack; + + if ((ascadeCount >= confNumberOfCascades && tracksCount >= confNumberOfTracks) || (antiCascadeCount >= confNumberOfCascades && antitracksCount >= confNumberOfTracks)) { + eventRegistry.fill(HIST("hStatistiscs"), 1); + outputCollision(col.posZ(), col.multV0M(), col.multNtr(), col.sphericity(), col.magField()); + + for (const auto& femtoParticle : parts) { + if (aod::femtodreamparticle::ParticleType::kTrack == femtoParticle.partType()) { + std::vector childIDs = {0, 0}; + outputParts(outputCollision.lastIndex(), + femtoParticle.pt(), + femtoParticle.eta(), + femtoParticle.phi(), + femtoParticle.partType(), + femtoParticle.cut(), + femtoParticle.pidcut(), + femtoParticle.tempFitVar(), + childIDs, + femtoParticle.mLambda(), + femtoParticle.mAntiLambda()); + tmpIDtrack.push_back(femtoParticle.index()); + } + if (aod::femtodreamparticle::ParticleType::kCascadeV0Child == femtoParticle.partType() || aod::femtodreamparticle::ParticleType::kCascadeBachelor == femtoParticle.partType()) { + std::vector childIDs = {0, 0, 0}; + const auto& children = femtoParticle.childrenIds(); + int childId = 0; + if (children[0] != 0) { + childId = children[0]; + } else if (children[1] != 0) { + childId = children[1]; + } else if (children[2] != 0) { + childId = children[2]; + } + + if (childId != -1) { + int rowInPrimaryTrackTable = getRowDaughters(childId, tmpIDtrack); + if (children[0] != 0) { + childIDs = std::vector{rowInPrimaryTrackTable, 0, 0}; + } else if (children[1] != 0) { + childIDs = std::vector{0, rowInPrimaryTrackTable, 0}; + } else if (children[2] != 0) { + childIDs = std::vector{0, 0, rowInPrimaryTrackTable}; + } + } else { + if (children[0] != 0) { + childIDs = std::vector{-1, 0, 0}; + } else if (children[1] != 0) { + childIDs = std::vector{0, -1, 0}; + } else if (children[2] != 0) { + childIDs = std::vector{0, 0, -1}; + } + } + outputParts(outputCollision.lastIndex(), + femtoParticle.pt(), + femtoParticle.eta(), + femtoParticle.phi(), + femtoParticle.partType(), + femtoParticle.cut(), + femtoParticle.pidcut(), + femtoParticle.tempFitVar(), + childIDs, + femtoParticle.mLambda(), + femtoParticle.mAntiLambda()); + } + if (aod::femtodreamparticle::ParticleType::kCascade == femtoParticle.partType()) { + // If the order in primary producer is changed of storing first pos, neg daughters and then V0 - this must be updated + const int rowOfLastTrack = outputParts.lastIndex(); + std::vector childIDs = {rowOfLastTrack - 2, rowOfLastTrack - 1, rowOfLastTrack}; + outputParts(outputCollision.lastIndex(), + femtoParticle.pt(), + femtoParticle.eta(), + femtoParticle.phi(), + femtoParticle.partType(), + femtoParticle.cut(), + femtoParticle.pidcut(), + femtoParticle.tempFitVar(), + childIDs, + femtoParticle.mLambda(), + femtoParticle.mAntiLambda()); + } + } + } else { + eventRegistry.fill(HIST("hStatistiscs"), 2); + } + } + + /// process function to create derived data with only collisions containing n tracks + /// \param col subscribe to the collision table (Data) + /// \param parts subscribe to the femtoDreamParticleTable + void processCollisionsWithNTracksAndNCascades(const o2::aod::FDCollision& col, + const o2::aod::FDParticles& parts) + { + eventRegistry.fill(HIST("hStatistiscs"), 0); + auto thegroupSelectedParts = selectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + auto thegroupSelectedCascades = selectedCascades->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + + createSpecifiedDerivedDataTrkCascade(col, thegroupSelectedParts, thegroupSelectedCascades, parts); + } + PROCESS_SWITCH(FemtoDreamProducerTaskForSpecificAnalysis, processCollisionsWithNTracksAndNCascades, "Enable producing data with tracks and Cascades collisions for data", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; return workflow; } diff --git a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTaskWithCascades.cxx b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTaskWithCascades.cxx new file mode 100644 index 00000000000..a7e02ec87e6 --- /dev/null +++ b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTaskWithCascades.cxx @@ -0,0 +1,1173 @@ +// Copyright 2019-2025 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. + +/// \file femtoDreamProducerTaskWithCascades.cxx +/// \brief Tasks that produces the track tables used for the pairing +/// \author Laura Serksnyte, TU München, laura.serksnyte@tum.de + +#include +#include +#include +#include +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h" +#include "PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h" +#include "PWGCF/FemtoDream/Core/femtoDreamV0Selection.h" +#include "PWGCF/FemtoDream/Core/femtoDreamCascadeSelection.h" +#include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "EventFiltering/Zorro.h" +#include "PWGCF/DataModel/FemtoDerived.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "ReconstructionDataFormats/Track.h" +#include "TMath.h" +#include "Math/Vector4D.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::analysis::femtoDream; + +namespace o2::aod +{ + +using FemtoFullCollision = soa::Join::iterator; +using FemtoFullCollision_noCent = soa::Join::iterator; +using FemtoFullCollision_CentPbPb = soa::Join::iterator; +using FemtoFullCollisionMC = soa::Join::iterator; +using FemtoFullCollision_noCent_MC = soa::Join::iterator; +using FemtoFullCollisionMC_CentPbPb = soa::Join::iterator; +using FemtoFullMCgenCollisions = soa::Join; +using FemtoFullMCgenCollision = FemtoFullMCgenCollisions::iterator; + +using FemtoFullTracks = + soa::Join; +} // namespace o2::aod + +namespace softwareTriggers +{ +static const int nTriggers = 6; +static const std::vector triggerNames{"fPPP", "fPPL", "fPLL", "fLLL", "fPD", "fLD"}; +static const float triggerSwitches[1][nTriggers]{ + {0, 0, 0, 0, 0, 0}}; +} // namespace softwareTriggers + +template +int getRowDaughters(int daughID, T const& vecID) +{ + int rowInPrimaryTrackTableDaugh = -1; + for (size_t i = 0; i < vecID.size(); i++) { + if (vecID.at(i) == daughID) { + rowInPrimaryTrackTableDaugh = i; + break; + } + } + return rowInPrimaryTrackTableDaugh; +} + +struct femtoDreamProducerTaskWithCascades { + + Zorro zorro; + + Produces outputCollision; + Produces outputMCCollision; + Produces outputCollsMCLabels; + Produces outputParts; + Produces outputPartsMC; + Produces outputDebugParts; + Produces outputPartsMCLabels; + Produces outputDebugPartsMC; + Produces outputPartsExtMCLabels; + + Configurable ConfIsDebug{"ConfIsDebug", true, "Enable Debug tables"}; + Configurable ConfUseItsPid{"ConfUseItsPid", false, "Enable Debug tables"}; + Configurable ConfIsRun3{"ConfIsRun3", false, "Running on Run3 or pilot"}; + Configurable ConfIsForceGRP{"ConfIsForceGRP", false, "Set true if the magnetic field configuration is not available in the usual CCDB directory (e.g. for Run 2 converted data or unanchorad Monte Carlo)"}; + /// Event cuts + FemtoDreamCollisionSelection colCuts; + // Event cuts - Triggers + Configurable ConfEnableTriggerSelection{"ConfEnableTriggerSelection", false, "Should the trigger selection be enabled for collisions?"}; + Configurable> ConfTriggerSwitches{ + "ConfTriggerSwitches", + {softwareTriggers::triggerSwitches[0], 1, softwareTriggers::nTriggers, std::vector{"Switch"}, softwareTriggers::triggerNames}, + "Turn on which trigger should be checked for recorded events to pass selection"}; + Configurable ConfBaseCCDBPathForTriggers{"ConfBaseCCDBPathForTriggers", "Users/m/mpuccio/EventFiltering/OTS/Chunked/", "Provide ccdb path for trigger table; default - trigger coordination"}; + + // Event cuts - usual selection criteria + Configurable ConfEvtZvtx{"ConfEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable ConfEvtTriggerCheck{"ConfEvtTriggerCheck", true, "Evt sel: check for trigger"}; + Configurable ConfEvtTriggerSel{"ConfEvtTriggerSel", kINT7, "Evt sel: trigger"}; + Configurable ConfEvtOfflineCheck{"ConfEvtOfflineCheck", false, "Evt sel: check for offline selection"}; + Configurable ConfEvtAddOfflineCheck{"ConfEvtAddOfflineCheck", false, "Evt sel: additional checks for offline selection (not part of sel8 yet)"}; + Configurable ConfIsActivateV0{"ConfIsActivateV0", true, "Activate filling of V0 into femtodream tables"}; + Configurable ConfIsActivateReso{"ConfIsActivateReso", false, "Activate filling of sl Resonances into femtodream tables"}; + Configurable ConfIsActivateCascade{"ConfIsActivateCascade", false, "Activate filling of Cascades into femtodream tables"}; + + Configurable ConfTrkRejectNotPropagated{"ConfTrkRejectNotPropagated", false, "True: reject not propagated tracks"}; + // Configurable ConfRejectITSHitandTOFMissing{ "ConfRejectITSHitandTOFMissing", false, "True: reject if neither ITS hit nor TOF timing satisfied"}; + Configurable ConfTrkPDGCode{"ConfTrkPDGCode", 2212, "PDG code of the selected track for Monte Carlo truth"}; + FemtoDreamTrackSelection trackCuts; + Configurable> ConfTrkCharge{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kSign, "ConfTrk"), std::vector{-1, 1}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kSign, "Track selection: ")}; + Configurable> ConfTrkPtmin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kpTMin, "ConfTrk"), std::vector{0.5f, 0.4f, 0.6f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kpTMin, "Track selection: ")}; + Configurable> ConfTrkPtmax{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kpTMax, "ConfTrk"), std::vector{5.4f, 5.6f, 5.5f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kpTMax, "Track selection: ")}; + Configurable> ConfTrkEta{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kEtaMax, "ConfTrk"), std::vector{0.8f, 0.7f, 0.9f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kEtaMax, "Track selection: ")}; + Configurable> ConfTrkTPCnclsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCnClsMin, "ConfTrk"), std::vector{80.f, 70.f, 60.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCnClsMin, "Track selection: ")}; + Configurable> ConfTrkTPCfCls{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCfClsMin, "ConfTrk"), std::vector{0.7f, 0.83f, 0.9f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCfClsMin, "Track selection: ")}; + Configurable> ConfTrkTPCcRowsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCcRowsMin, "ConfTrk"), std::vector{70.f, 60.f, 80.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCcRowsMin, "Track selection: ")}; + Configurable> ConfTrkTPCsCls{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCsClsMax, "ConfTrk"), std::vector{0.1f, 160.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCsClsMax, "Track selection: ")}; + Configurable> ConfTrkITSnclsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kITSnClsMin, "ConfTrk"), std::vector{-1.f, 2.f, 4.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kITSnClsMin, "Track selection: ")}; + Configurable> ConfTrkITSnclsIbMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kITSnClsIbMin, "ConfTrk"), std::vector{-1.f, 1.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kITSnClsIbMin, "Track selection: ")}; + Configurable> ConfTrkDCAxyMax{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kDCAxyMax, "ConfTrk"), std::vector{0.1f, 3.5f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kDCAxyMax, "Track selection: ")}; + Configurable> ConfTrkDCAzMax{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kDCAzMax, "ConfTrk"), std::vector{0.2f, 3.5f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kDCAzMax, "Track selection: ")}; + Configurable> ConfTrkPIDnSigmaMax{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kPIDnSigmaMax, "ConfTrk"), std::vector{3.5f, 3.f, 2.5f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kPIDnSigmaMax, "Track selection: ")}; + Configurable ConfTrkPIDnSigmaOffsetTPC{"ConfTrkPIDnSigmaOffsetTPC", 0., "Offset for TPC nSigma because of bad calibration"}; + Configurable ConfTrkPIDnSigmaOffsetTOF{"ConfTrkPIDnSigmaOffsetTOF", 0., "Offset for TOF nSigma because of bad calibration"}; + Configurable> ConfTrkPIDspecies{"ConfTrkPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Kaon, o2::track::PID::Proton, o2::track::PID::Deuteron}, "Trk sel: Particles species for PID"}; + + FemtoDreamV0Selection v0Cuts; + Configurable> ConfV0Sign{FemtoDreamV0Selection::getSelectionName(femtoDreamV0Selection::kV0Sign, "ConfV0"), std::vector{-1, 1}, FemtoDreamV0Selection::getSelectionHelper(femtoDreamV0Selection::kV0Sign, "V0 selection: ")}; + Configurable> ConfV0PtMin{FemtoDreamV0Selection::getSelectionName(femtoDreamV0Selection::kV0pTMin, "ConfV0"), std::vector{0.3f, 0.4f, 0.5f}, FemtoDreamV0Selection::getSelectionHelper(femtoDreamV0Selection::kV0pTMin, "V0 selection: ")}; + Configurable> ConfV0PtMax{FemtoDreamV0Selection::getSelectionName(femtoDreamV0Selection::kV0pTMax, "ConfV0"), std::vector{3.3f, 3.4f, 3.5f}, FemtoDreamV0Selection::getSelectionHelper(femtoDreamV0Selection::kV0pTMax, "V0 selection: ")}; + Configurable> ConfV0EtaMax{FemtoDreamV0Selection::getSelectionName(femtoDreamV0Selection::kV0etaMax, "ConfV0"), std::vector{0.8f, 0.7f, 0.9f}, FemtoDreamV0Selection::getSelectionHelper(femtoDreamV0Selection::kV0etaMax, "V0 selection: ")}; + Configurable> ConfV0DCADaughMax{FemtoDreamV0Selection::getSelectionName(femtoDreamV0Selection::kV0DCADaughMax, "ConfV0"), std::vector{1.2f, 1.5f}, FemtoDreamV0Selection::getSelectionHelper(femtoDreamV0Selection::kV0DCADaughMax, "V0 selection: ")}; + Configurable> ConfV0CPAMin{FemtoDreamV0Selection::getSelectionName(femtoDreamV0Selection::kV0CPAMin, "ConfV0"), std::vector{0.99f, 0.995f}, FemtoDreamV0Selection::getSelectionHelper(femtoDreamV0Selection::kV0CPAMin, "V0 selection: ")}; + Configurable> ConfV0TranRadMin{FemtoDreamV0Selection::getSelectionName(femtoDreamV0Selection::kV0TranRadMin, "ConfV0"), std::vector{0.2f}, FemtoDreamV0Selection::getSelectionHelper(femtoDreamV0Selection::kV0TranRadMin, "V0 selection: ")}; + Configurable> ConfV0TranRadMax{FemtoDreamV0Selection::getSelectionName(femtoDreamV0Selection::kV0TranRadMax, "ConfV0"), std::vector{100.f}, FemtoDreamV0Selection::getSelectionHelper(femtoDreamV0Selection::kV0TranRadMax, "V0 selection: ")}; + Configurable> ConfV0DecVtxMax{FemtoDreamV0Selection::getSelectionName(femtoDreamV0Selection::kV0DecVtxMax, "ConfV0"), std::vector{100.f}, FemtoDreamV0Selection::getSelectionHelper(femtoDreamV0Selection::kV0DecVtxMax, "V0 selection: ")}; + + Configurable ConfV0InvMassLowLimit{"ConfV0InvV0MassLowLimit", 1.05, "Lower limit of the V0 invariant mass"}; + Configurable ConfV0InvMassUpLimit{"ConfV0InvV0MassUpLimit", 1.30, "Upper limit of the V0 invariant mass"}; + Configurable ConfV0RejectKaons{"ConfV0RejectKaons", false, "Switch to reject kaons"}; + Configurable ConfV0InvKaonMassLowLimit{"ConfV0InvKaonMassLowLimit", 0.48, "Lower limit of the V0 invariant mass for Kaon rejection"}; + Configurable ConfV0InvKaonMassUpLimit{"ConfV0InvKaonMassUpLimit", 0.515, "Upper limit of the V0 invariant mass for Kaon rejection"}; + + Configurable> ConfChildCharge{"ConfChildSign", std::vector{-1, 1}, "V0 Child sel: Charge"}; + Configurable> ConfChildEtaMax{"ConfChildEtaMax", std::vector{0.8f}, "V0 Child sel: max eta"}; + Configurable> ConfChildTPCnClsMin{"ConfChildTPCnClsMin", std::vector{80.f, 70.f, 60.f}, "V0 Child sel: Min. nCls TPC"}; + Configurable> ConfChildDCAMin{"ConfChildDCAMin", std::vector{0.05f, 0.06f}, "V0 Child sel: Max. DCA Daugh to PV (cm)"}; + Configurable> ConfChildPIDnSigmaMax{"ConfChildPIDnSigmaMax", std::vector{5.f, 4.f}, "V0 Child sel: Max. PID nSigma TPC"}; + Configurable> ConfChildPIDspecies{"ConfChildPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Proton}, "V0 Child sel: Particles species for PID"}; + + FemtoDreamCascadeSelection cascadeCuts; + struct : o2::framework::ConfigurableGroup { + Configurable ConfCascInvMassLowLimit{"ConfCascInvMassLowLimit", 1.2, "Lower limit of the Cascade invariant mass"}; + Configurable ConfCascInvMassUpLimit{"ConfCascInvMassUpLimit", 1.5, "Upper limit of the Cascade invariant mass"}; + Configurable ConfCascIsSelectedOmega{"ConfCascIsSelectedOmega", false, "Select Omegas instead of Xis (invariant mass)"}; + // Cascade + Configurable> ConfCascadeSign{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeSign, "ConfCascade"), std::vector{-1, 1}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeSign, "Cascade selection: ")}; + Configurable> ConfCascadePtMin{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadePtMin, "ConfCascade"), std::vector{0.3f, 0.4f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadePtMin, "Cascade selection: ")}; + Configurable> ConfCascadePtMax{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadePtMax, "ConfCascade"), std::vector{5.5f, 6.0f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadePtMax, "Cascade selection: ")}; + Configurable> ConfCascadeEtaMax{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeEtaMax, "ConfCascade"), std::vector{0.8f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeEtaMax, "Cascade selection: ")}; + Configurable> ConfCascadeDCADaughMax{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeDCADaughMax, "ConfCascade"), std::vector{1.f, 1.2f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeDCADaughMax, "Cascade selection: ")}; + Configurable> ConfCascadeCPAMin{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeCPAMin, "ConfCascade"), std::vector{0.99f, 0.95f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeCPAMin, "Cascade selection: ")}; + Configurable> ConfCascadeTranRadMin{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeTranRadMin, "ConfCascade"), std::vector{0.2f, 0.5f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeTranRadMin, "Cascade selection: ")}; + Configurable> ConfCascadeTranRadMax{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeTranRadMax, "ConfCascade"), std::vector{100.f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeTranRadMax, "Cascade selection: ")}; + Configurable> ConfCascadeDecVtxMax{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeDecVtxMax, "ConfCascade"), std::vector{100.f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeDecVtxMax, "Cascade selection: ")}; + + // Cascade v0 daughters + Configurable> ConfCascadeV0DCADaughMax{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeV0DCADaughMax, "ConfCascade"), std::vector{1.2f, 1.5f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeV0DCADaughMax, "CascV0 selection: ")}; + Configurable> ConfCascadeV0CPAMin{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeV0CPAMin, "ConfCascade"), std::vector{0.99f, 0.995f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeV0CPAMin, "CascV0 selection: ")}; + Configurable> ConfCascadeV0TranRadMin{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeV0TranRadMin, "ConfCascade"), std::vector{0.2f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeV0TranRadMin, "CascV0 selection: ")}; + Configurable> ConfCascadeV0TranRadMax{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeV0TranRadMax, "ConfCascade"), std::vector{100.f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeV0TranRadMax, "CascV0 selection: ")}; + Configurable> ConfCascadeV0DCAtoPVMin{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMin, "ConfCascade"), std::vector{100.f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMin, "CascV0 selection: ")}; + Configurable> ConfCascadeV0DCAtoPVMax{FemtoDreamCascadeSelection::getSelectionName(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMax, "ConfCascade"), std::vector{100.f}, FemtoDreamCascadeSelection::getSelectionHelper(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMax, "CascV0 selection: ")}; + Configurable ConfCascV0InvMassLowLimit{"ConfCascV0InvMassLowLimit", 1.011461, "Lower limit of the Cascade invariant mass"}; + Configurable ConfCascV0InvMassUpLimit{"ConfCascV0InvMassUpLimit", 1.027461, "Upper limit of the Cascade invariant mass"}; + // Cascade Daughter Tracks + Configurable> ConfCascV0ChildCharge{"ConfCascV0ChildSign", std::vector{-1, 1}, "CascV0 Child sel: Charge"}; + Configurable> ConfCascV0ChildPtMin{"ConfCascV0ChildPtMin", std::vector{0.8f}, "CascV0 Child sel: min pt"}; + Configurable> ConfCascV0ChildEtaMax{"ConfCascV0ChildEtaMax", std::vector{0.8f}, "CascV0 Child sel: max eta"}; + Configurable> ConfCascV0ChildTPCnClsMin{"ConfCascV0ChildTPCnClsMin", std::vector{80.f, 70.f, 60.f}, "CascV0 Child sel: Min. nCls TPC"}; + Configurable> ConfCascV0ChildDCAMin{"ConfCascV0ChildDCAMin", std::vector{0.05f, 0.06f}, "CascV0 Child sel: Max. DCA Daugh to PV (cm)"}; + Configurable> ConfCascV0ChildPIDnSigmaMax{"ConfCascV0ChildPIDnSigmaMax", std::vector{5.f, 4.f}, "CascV0 Child sel: Max. PID nSigma TPC"}; + Configurable> ConfCascV0ChildPIDspecies{"ConfCascV0ChildPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Proton}, "CascV0 Child sel: Particles species for PID"}; + // Cascade Bachelor Track + Configurable> ConfCascBachelorCharge{"ConfCascBachelorSign", std::vector{-1, 1}, "Cascade Bachelor sel: Charge"}; + Configurable> ConfCascBachelorPtMin{"ConfCascBachelorPtMin", std::vector{0.8f}, "Cascade Bachelor sel: min pt"}; + Configurable> ConfCascBachelorEtaMax{"ConfCascBachelorEtaMax", std::vector{0.8f}, "Cascade Bachelor sel: max eta"}; + Configurable> ConfCascBachelorTPCnClsMin{"ConfCascBachelorTPCnClsMin", std::vector{80.f, 70.f, 60.f}, "Cascade Bachelor sel: Min. nCls TPC"}; + Configurable> ConfCascBachelorDCAMin{"ConfCascBachelorDCAMin", std::vector{0.05f, 0.06f}, "Cascade Bachelor sel: Max. DCA Daugh to PV (cm)"}; + Configurable> ConfCascBachelorPIDnSigmaMax{"ConfCascBachelorPIDnSigmaMax", std::vector{5.f, 4.f}, "Cascade Bachelor sel: Max. PID nSigma TPC"}; + Configurable> ConfCascBachelorPIDspecies{"ConfCascBachelorPIDspecies", std::vector{o2::track::PID::Pion}, "Cascade Bachelor sel: Particles species for PID"}; + + Configurable ConfCascRejectCompetingMass{"ConfCascRejectCompetingMass", false, "Switch on to reject Omegas (for Xi) or Xis (for Omegas)"}; + Configurable ConfCascInvCompetingMassLowLimit{"ConfCascInvCompetingMassLowLimit", 1.66, "Lower limit of the cascade invariant mass for competing mass rejection"}; + Configurable ConfCascInvCompetingMassUpLimit{"ConfCascInvCompetingMassUpLimit", 1.68, "Upper limit of the cascade invariant mass for competing mass rejection"}; + + } ConfCascSel; + + // Resonances + Configurable ConfResoInvMassLowLimit{"ConfResoInvMassLowLimit", 1.011461, "Lower limit of the Reso invariant mass"}; + Configurable ConfResoInvMassUpLimit{"ConfResoInvMassUpLimit", 1.027461, "Upper limit of the Reso invariant mass"}; + Configurable> ConfDaughterCharge{"ConfDaughterCharge", std::vector{1, -1}, "Reso Daughter sel: Charge"}; + Configurable> ConfDaughterEta{"ConfDaughterEta", std::vector{0.8, 0.8}, "Reso Daughter sel: Eta"}; // 0.8 + Configurable> ConfDaughterDCAxy{"ConfDaughterDCAxy", std::vector{0.1, 0.1}, "Reso Daughter sel: DCAxy"}; // 0.1 + Configurable> ConfDaughterDCAz{"ConfDaughterDCAz", std::vector{0.2, 0.2}, "Reso Daughter sel: DCAz"}; // 0.2 + Configurable> ConfDaughterNClus{"ConfDaughterNClus", std::vector{80, 80}, "Reso Daughter sel: NClusters"}; // 0.2 + Configurable> ConfDaughterNCrossed{"ConfDaughterNCrossed", std::vector{70, 70}, "Reso Daughter sel: NCrossedRowss"}; + Configurable> ConfDaughterTPCfCls{"ConfDaughterTPCfCls", std::vector{0.8, 0.8}, "Reso Daughter sel: Minimum fraction of crossed rows over findable cluster"}; // 0.2 + Configurable> ConfDaughterPtUp{"ConfDaughterPtUp", std::vector{2.0, 2.0}, "Reso Daughter sel: Upper limit pT"}; // 2.0 + Configurable> ConfDaughterPtLow{"ConfDaughterPtLow", std::vector{0.15, 0.15}, "Reso Daughter sel: Lower limit pT"}; // 0.15 + Configurable> ConfDaughterPTPCThr{"ConfDaughterPTPCThr", std::vector{0.40, 0.40}, "Reso Daughter sel: momentum threshold TPC only PID, p_TPC,Thr"}; // 0.4 + Configurable> ConfDaughterPIDnSigmaMax{"ConfDaughterPIDnSigmaMax", std::vector{3.00, 3.00}, "Reso Daughter sel: Max. PID nSigma TPC"}; // 3.0 + Configurable> ConfDaughterPIDspecies{"ConfDaughterPIDspecies", std::vector{o2::track::PID::Kaon, o2::track::PID::Kaon}, "Reso Daughter sel: Particles species for PID"}; + Configurable> ConfDaug1Daugh2ResoMass{"ConfDaug1Daugh2ResoMass", std::vector{o2::constants::physics::MassKPlus, o2::constants::physics::MassKMinus, o2::constants::physics::MassPhi}, "Masses: Daughter1 - Daughter2 - Resonance"}; + + /// \todo should we add filter on min value pT/eta of V0 and daughters? + /*Filter v0Filter = (nabs(aod::v0data::x) < V0DecVtxMax.value) && + (nabs(aod::v0data::y) < V0DecVtxMax.value) && + (nabs(aod::v0data::z) < V0DecVtxMax.value);*/ + // (aod::v0data::v0radius > V0TranRadV0Min.value); to be added, not working + // for now do not know why + + /// General options + struct : o2::framework::ConfigurableGroup { + Configurable ConfTrkMinChi2PerClusterTPC{"ConfTrkMinChi2PerClusterTPC", 0.f, "Lower limit for chi2 of TPC; currently for testing only"}; + Configurable ConfTrkMaxChi2PerClusterTPC{"ConfTrkMaxChi2PerClusterTPC", 1000.f, "Upper limit for chi2 of TPC; currently for testing only"}; + Configurable ConfTrkMaxChi2PerClusterITS{"ConfTrkMaxChi2PerClusterITS", 1000.0f, "Minimal track selection: max allowed chi2 per ITS cluster"}; // 36.0 is default + Configurable ConfTrkTPCRefit{"ConfTrkTPCRefit", false, "True: require TPC refit"}; + Configurable ConfTrkITSRefit{"ConfTrkITSRefit", false, "True: require ITS refit"}; + + } OptionTrackSpecialSelections; + + HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry TrackRegistry{"Tracks", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry V0Registry{"V0", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry ResoRegistry{"Reso", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry CascadeRegistry{"Cascade", {}, OutputObjHandlingPolicy::AnalysisObject}; + + int mRunNumber; + float mMagField; + std::string zorroTriggerNames = ""; + Service ccdb; /// Accessing the CCDB + + void init(InitContext&) + { + if (doprocessData == false && doprocessData_noCentrality == false && doprocessData_CentPbPb == false && doprocessMC == false && doprocessMC_noCentrality == false && doprocessMC_CentPbPb == false) { + LOGF(fatal, "Neither processData nor processMC enabled. Please choose one."); + } + if ((doprocessData == true && doprocessMC == true) || (doprocessData == true && doprocessMC_noCentrality == true) || (doprocessMC == true && doprocessMC_noCentrality == true) || (doprocessData_noCentrality == true && doprocessData == true) || (doprocessData_noCentrality == true && doprocessMC == true) || (doprocessData_noCentrality == true && doprocessMC_noCentrality == true) || (doprocessData_CentPbPb == true && doprocessData == true) || (doprocessData_CentPbPb == true && doprocessData_noCentrality == true) || (doprocessData_CentPbPb == true && doprocessMC == true) || (doprocessData_CentPbPb == true && doprocessMC_noCentrality == true) || (doprocessData_CentPbPb == true && doprocessMC_CentPbPb == true)) { + LOGF(fatal, + "Cannot enable more than one process switch at the same time. " + "Please choose one."); + } + + int CutBits = 8 * sizeof(o2::aod::femtodreamparticle::cutContainerType); + TrackRegistry.add("AnalysisQA/CutCounter", "; Bit; Counter", kTH1F, {{CutBits + 1, -0.5, CutBits + 0.5}}); + TrackRegistry.add("AnalysisQA/Chi2ITSTPCperCluster", "; ITS_Chi2; TPC_Chi2", kTH2F, {{100, 0, 50}, {100, 0, 20}}); + TrackRegistry.add("AnalysisQA/RefitITSTPC", "; ITS_Refit; TPC_Refit", kTH2F, {{2, 0, 2}, {2, 0, 2}}); + TrackRegistry.add("AnalysisQA/getGenStatusCode", "; Bit; Entries", kTH1F, {{200, 0, 200}}); + TrackRegistry.add("AnalysisQA/getProcess", "; Bit; Entries", kTH1F, {{200, 0, 200}}); + TrackRegistry.add("AnalysisQA/Mother", "; Bit; Entries", kTH1F, {{4000, -4000, 4000}}); + TrackRegistry.add("AnalysisQA/Particle", "; Bit; Entries", kTH1F, {{4000, -4000, 4000}}); + V0Registry.add("AnalysisQA/CutCounter", "; Bit; Counter", kTH1F, {{CutBits + 1, -0.5, CutBits + 0.5}}); + CascadeRegistry.add("AnalysisQA/CutCounter", "; Bit; Counter", kTH1F, {{CutBits + 1, -0.5, CutBits + 0.5}}); + ResoRegistry.add("AnalysisQA/Reso/InvMass", "Invariant mass V0s;M_{KK};Entries", HistType::kTH1F, {{7000, 0.8, 1.5}}); + ResoRegistry.add("AnalysisQA/Reso/InvMass_selected", "Invariant mass V0s;M_{KK};Entries", HistType::kTH1F, {{7000, 0.8, 1.5}}); + ResoRegistry.add("AnalysisQA/Reso/Daughter1/Pt", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); + ResoRegistry.add("AnalysisQA/Reso/Daughter1/Eta", "Pseudorapidity of all processed tracks;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); + ResoRegistry.add("AnalysisQA/Reso/Daughter1/Phi", "Azimuthal angle of all processed tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); + ResoRegistry.add("AnalysisQA/Reso/Daughter2/Pt", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); + ResoRegistry.add("AnalysisQA/Reso/Daughter2/Eta", "Pseudorapidity of all processed tracks;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); + ResoRegistry.add("AnalysisQA/Reso/Daughter2/Phi", "Azimuthal angle of all processed tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); + ResoRegistry.add("AnalysisQA/Reso/PtD1_selected", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); + ResoRegistry.add("AnalysisQA/Reso/PtD2_selected", "Transverse momentum of all processed tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); + + if (ConfEnableTriggerSelection) { + for (const std::string& triggerName : softwareTriggers::triggerNames) { + if (ConfTriggerSwitches->get("Switch", triggerName.c_str())) { + zorroTriggerNames += triggerName + ","; + } + } + zorroTriggerNames.pop_back(); + } + + colCuts.setCuts(ConfEvtZvtx.value, ConfEvtTriggerCheck.value, ConfEvtTriggerSel.value, ConfEvtOfflineCheck.value, ConfEvtAddOfflineCheck.value, ConfIsRun3.value); + colCuts.init(&qaRegistry); + + trackCuts.setSelection(ConfTrkCharge, femtoDreamTrackSelection::kSign, femtoDreamSelection::kEqual); + trackCuts.setSelection(ConfTrkPtmin, femtoDreamTrackSelection::kpTMin, femtoDreamSelection::kLowerLimit); + trackCuts.setSelection(ConfTrkPtmax, femtoDreamTrackSelection::kpTMax, femtoDreamSelection::kUpperLimit); + trackCuts.setSelection(ConfTrkEta, femtoDreamTrackSelection::kEtaMax, femtoDreamSelection::kAbsUpperLimit); + trackCuts.setSelection(ConfTrkTPCnclsMin, femtoDreamTrackSelection::kTPCnClsMin, femtoDreamSelection::kLowerLimit); + trackCuts.setSelection(ConfTrkTPCfCls, femtoDreamTrackSelection::kTPCfClsMin, femtoDreamSelection::kLowerLimit); + trackCuts.setSelection(ConfTrkTPCcRowsMin, femtoDreamTrackSelection::kTPCcRowsMin, femtoDreamSelection::kLowerLimit); + trackCuts.setSelection(ConfTrkTPCsCls, femtoDreamTrackSelection::kTPCsClsMax, femtoDreamSelection::kUpperLimit); + trackCuts.setSelection(ConfTrkITSnclsMin, femtoDreamTrackSelection::kITSnClsMin, femtoDreamSelection::kLowerLimit); + trackCuts.setSelection(ConfTrkITSnclsIbMin, femtoDreamTrackSelection::kITSnClsIbMin, femtoDreamSelection::kLowerLimit); + trackCuts.setSelection(ConfTrkDCAxyMax, femtoDreamTrackSelection::kDCAxyMax, femtoDreamSelection::kAbsUpperLimit); + trackCuts.setSelection(ConfTrkDCAzMax, femtoDreamTrackSelection::kDCAzMax, femtoDreamSelection::kAbsUpperLimit); + trackCuts.setSelection(ConfTrkPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit); + trackCuts.setPIDSpecies(ConfTrkPIDspecies); + trackCuts.setnSigmaPIDOffset(ConfTrkPIDnSigmaOffsetTPC, ConfTrkPIDnSigmaOffsetTOF); + trackCuts.init(&qaRegistry, &TrackRegistry); + + /// \todo fix how to pass array to setSelection, getRow() passing a + /// different type! + // v0Cuts.setSelection(ConfV0Selection->getRow(0), + // femtoDreamV0Selection::kDecVtxMax, femtoDreamSelection::kAbsUpperLimit); + if (ConfIsActivateV0) { + v0Cuts.setSelection(ConfV0Sign, femtoDreamV0Selection::kV0Sign, femtoDreamSelection::kEqual); + v0Cuts.setSelection(ConfV0PtMin, femtoDreamV0Selection::kV0pTMin, femtoDreamSelection::kLowerLimit); + v0Cuts.setSelection(ConfV0PtMax, femtoDreamV0Selection::kV0pTMax, femtoDreamSelection::kUpperLimit); + v0Cuts.setSelection(ConfV0EtaMax, femtoDreamV0Selection::kV0etaMax, femtoDreamSelection::kAbsUpperLimit); + v0Cuts.setSelection(ConfV0DCADaughMax, femtoDreamV0Selection::kV0DCADaughMax, femtoDreamSelection::kUpperLimit); + v0Cuts.setSelection(ConfV0CPAMin, femtoDreamV0Selection::kV0CPAMin, femtoDreamSelection::kLowerLimit); + v0Cuts.setSelection(ConfV0TranRadMin, femtoDreamV0Selection::kV0TranRadMin, femtoDreamSelection::kLowerLimit); + v0Cuts.setSelection(ConfV0TranRadMax, femtoDreamV0Selection::kV0TranRadMax, femtoDreamSelection::kUpperLimit); + v0Cuts.setSelection(ConfV0DecVtxMax, femtoDreamV0Selection::kV0DecVtxMax, femtoDreamSelection::kUpperLimit); + v0Cuts.setChildCuts(femtoDreamV0Selection::kPosTrack, ConfChildCharge, femtoDreamTrackSelection::kSign, femtoDreamSelection::kEqual); + v0Cuts.setChildCuts(femtoDreamV0Selection::kPosTrack, ConfChildEtaMax, femtoDreamTrackSelection::kEtaMax, femtoDreamSelection::kAbsUpperLimit); + v0Cuts.setChildCuts(femtoDreamV0Selection::kPosTrack, ConfChildTPCnClsMin, femtoDreamTrackSelection::kTPCnClsMin, femtoDreamSelection::kLowerLimit); + v0Cuts.setChildCuts(femtoDreamV0Selection::kPosTrack, ConfChildDCAMin, femtoDreamTrackSelection::kDCAMin, femtoDreamSelection::kAbsLowerLimit); + v0Cuts.setChildCuts(femtoDreamV0Selection::kPosTrack, ConfChildPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit); + + v0Cuts.setChildCuts(femtoDreamV0Selection::kNegTrack, ConfChildCharge, femtoDreamTrackSelection::kSign, femtoDreamSelection::kEqual); + v0Cuts.setChildCuts(femtoDreamV0Selection::kNegTrack, ConfChildEtaMax, femtoDreamTrackSelection::kEtaMax, femtoDreamSelection::kAbsUpperLimit); + v0Cuts.setChildCuts(femtoDreamV0Selection::kNegTrack, ConfChildTPCnClsMin, femtoDreamTrackSelection::kTPCnClsMin, femtoDreamSelection::kLowerLimit); + v0Cuts.setChildCuts(femtoDreamV0Selection::kNegTrack, ConfChildDCAMin, femtoDreamTrackSelection::kDCAMin, femtoDreamSelection::kAbsLowerLimit); + v0Cuts.setChildCuts(femtoDreamV0Selection::kNegTrack, ConfChildPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit); + v0Cuts.setChildPIDSpecies(femtoDreamV0Selection::kPosTrack, ConfChildPIDspecies); + v0Cuts.setChildPIDSpecies(femtoDreamV0Selection::kNegTrack, ConfChildPIDspecies); + v0Cuts.init(&qaRegistry, &V0Registry); + v0Cuts.setInvMassLimits(ConfV0InvMassLowLimit, ConfV0InvMassUpLimit); + + v0Cuts.setChildRejectNotPropagatedTracks(femtoDreamV0Selection::kPosTrack, ConfTrkRejectNotPropagated); + v0Cuts.setChildRejectNotPropagatedTracks(femtoDreamV0Selection::kNegTrack, ConfTrkRejectNotPropagated); + + v0Cuts.setnSigmaPIDOffsetTPC(ConfTrkPIDnSigmaOffsetTPC); + v0Cuts.setChildnSigmaPIDOffset(femtoDreamV0Selection::kPosTrack, ConfTrkPIDnSigmaOffsetTPC, ConfTrkPIDnSigmaOffsetTOF); + v0Cuts.setChildnSigmaPIDOffset(femtoDreamV0Selection::kNegTrack, ConfTrkPIDnSigmaOffsetTPC, ConfTrkPIDnSigmaOffsetTOF); + + if (ConfV0RejectKaons) { + v0Cuts.setKaonInvMassLimits(ConfV0InvKaonMassLowLimit, ConfV0InvKaonMassUpLimit); + } + } + if (ConfIsActivateCascade) { + // Cascades + cascadeCuts.setSelection(ConfCascSel.ConfCascadeSign, femtoDreamCascadeSelection::kCascadeSign, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeSign)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadePtMin, femtoDreamCascadeSelection::kCascadePtMin, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadePtMin)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadePtMax, femtoDreamCascadeSelection::kCascadePtMax, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadePtMax)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeEtaMax, femtoDreamCascadeSelection::kCascadeEtaMax, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeEtaMax)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeDCADaughMax, femtoDreamCascadeSelection::kCascadeDCADaughMax, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeDCADaughMax)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeCPAMin, femtoDreamCascadeSelection::kCascadeCPAMin, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeCPAMin)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeTranRadMin, femtoDreamCascadeSelection::kCascadeTranRadMin, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeTranRadMin)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeTranRadMax, femtoDreamCascadeSelection::kCascadeTranRadMax, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeTranRadMax)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeDecVtxMax, femtoDreamCascadeSelection::kCascadeDecVtxMax, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeDecVtxMax)); + // Cascade v0 + cascadeCuts.setSelection(ConfCascSel.ConfCascadeV0DCADaughMax, femtoDreamCascadeSelection::kCascadeV0DCADaughMax, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeV0DCADaughMax)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeV0CPAMin, femtoDreamCascadeSelection::kCascadeV0CPAMin, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeV0CPAMin)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeV0TranRadMin, femtoDreamCascadeSelection::kCascadeV0TranRadMin, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeV0TranRadMin)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeV0TranRadMax, femtoDreamCascadeSelection::kCascadeV0TranRadMax, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeV0TranRadMax)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeV0DCAtoPVMin, femtoDreamCascadeSelection::kCascadeV0DCAtoPVMin, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMin)); + cascadeCuts.setSelection(ConfCascSel.ConfCascadeV0DCAtoPVMax, femtoDreamCascadeSelection::kCascadeV0DCAtoPVMax, FemtoDreamCascadeSelection::getSelectionType(femtoDreamCascadeSelection::kCascadeV0DCAtoPVMax)); + + // Cascade Daughter Tracks + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kPosTrack, ConfCascSel.ConfCascV0ChildCharge, femtoDreamTrackSelection::kSign, femtoDreamSelection::kEqual); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kPosTrack, ConfCascSel.ConfCascV0ChildPtMin, femtoDreamTrackSelection::kpTMin, femtoDreamSelection::kLowerLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kPosTrack, ConfCascSel.ConfCascV0ChildEtaMax, femtoDreamTrackSelection::kEtaMax, femtoDreamSelection::kAbsUpperLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kPosTrack, ConfCascSel.ConfCascV0ChildTPCnClsMin, femtoDreamTrackSelection::kTPCnClsMin, femtoDreamSelection::kLowerLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kPosTrack, ConfCascSel.ConfCascV0ChildDCAMin, femtoDreamTrackSelection::kDCAMin, femtoDreamSelection::kAbsLowerLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kPosTrack, ConfCascSel.ConfCascV0ChildPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit); + cascadeCuts.setChildPIDSpecies(femtoDreamCascadeSelection::kPosTrack, ConfCascSel.ConfCascV0ChildPIDspecies); + + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kNegTrack, ConfCascSel.ConfCascV0ChildCharge, femtoDreamTrackSelection::kSign, femtoDreamSelection::kEqual); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kNegTrack, ConfCascSel.ConfCascV0ChildPtMin, femtoDreamTrackSelection::kpTMin, femtoDreamSelection::kLowerLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kNegTrack, ConfCascSel.ConfCascV0ChildEtaMax, femtoDreamTrackSelection::kEtaMax, femtoDreamSelection::kAbsUpperLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kNegTrack, ConfCascSel.ConfCascV0ChildTPCnClsMin, femtoDreamTrackSelection::kTPCnClsMin, femtoDreamSelection::kLowerLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kNegTrack, ConfCascSel.ConfCascV0ChildDCAMin, femtoDreamTrackSelection::kDCAMin, femtoDreamSelection::kAbsLowerLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kNegTrack, ConfCascSel.ConfCascV0ChildPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit); + cascadeCuts.setChildPIDSpecies(femtoDreamCascadeSelection::kNegTrack, ConfCascSel.ConfCascV0ChildPIDspecies); + + // Cascade Bachelor Track + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kBachTrack, ConfCascSel.ConfCascBachelorCharge, femtoDreamTrackSelection::kSign, femtoDreamSelection::kEqual); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kBachTrack, ConfCascSel.ConfCascBachelorPtMin, femtoDreamTrackSelection::kpTMin, femtoDreamSelection::kLowerLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kBachTrack, ConfCascSel.ConfCascBachelorEtaMax, femtoDreamTrackSelection::kEtaMax, femtoDreamSelection::kAbsUpperLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kBachTrack, ConfCascSel.ConfCascBachelorTPCnClsMin, femtoDreamTrackSelection::kTPCnClsMin, femtoDreamSelection::kLowerLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kBachTrack, ConfCascSel.ConfCascBachelorDCAMin, femtoDreamTrackSelection::kDCAMin, femtoDreamSelection::kAbsLowerLimit); + cascadeCuts.setChildCuts(femtoDreamCascadeSelection::kBachTrack, ConfCascSel.ConfCascBachelorPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit); + cascadeCuts.setChildPIDSpecies(femtoDreamCascadeSelection::kBachTrack, ConfCascSel.ConfCascBachelorPIDspecies); + + cascadeCuts.init(&qaRegistry, &CascadeRegistry, ConfCascSel.ConfCascIsSelectedOmega); + cascadeCuts.setInvMassLimits(ConfCascSel.ConfCascInvMassLowLimit, ConfCascSel.ConfCascInvMassUpLimit); + cascadeCuts.setV0InvMassLimits(ConfCascSel.ConfCascV0InvMassLowLimit, ConfCascSel.ConfCascV0InvMassUpLimit); + if (ConfCascSel.ConfCascRejectCompetingMass) { + cascadeCuts.setCompetingInvMassLimits(ConfCascSel.ConfCascInvCompetingMassLowLimit, ConfCascSel.ConfCascInvCompetingMassUpLimit); + } + } + + mRunNumber = 0; + mMagField = 0.0; + /// Initializing CCDB + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + int64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); + } + + /// Function to retrieve the nominal magnetic field in kG (0.1T) and convert it directly to T + void initCCDB_Mag_Trig(aod::BCsWithTimestamps::iterator bc) + { + // TODO done only once (and not per run). Will be replaced by CCDBConfigurable + // get magnetic field for run + if (mRunNumber == bc.runNumber()) + return; + auto timestamp = bc.timestamp(); + float output = -999; + + if (ConfIsRun3 && !ConfIsForceGRP) { + static o2::parameters::GRPMagField* grpo = nullptr; + grpo = ccdb->getForTimeStamp("GLO/Config/GRPMagField", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return; + } + LOGF(info, "Retrieved GRP for timestamp %llu with L3 ", timestamp, grpo->getL3Current()); + // taken from GRP onject definition of getNominalL3Field; update later to something smarter (mNominalL3Field = std::lround(5.f * mL3Current / 30000.f);) + auto NominalL3Field = std::lround(5.f * grpo->getL3Current() / 30000.f); + output = 0.1 * (NominalL3Field); + + } else { + + static o2::parameters::GRPObject* grpo = nullptr; + grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + output = 0.1 * (grpo->getNominalL3Field()); + } + mMagField = output; + mRunNumber = bc.runNumber(); + + // Init for zorro to get trigger flags + if (ConfEnableTriggerSelection) { + zorro.setCCDBpath(ConfBaseCCDBPathForTriggers); + zorro.initCCDB(ccdb.service, mRunNumber, timestamp, zorroTriggerNames); + } + } + + template + void fillDebugParticle(ParticleType const& particle) + { + if constexpr (isTrackOrV0) { + if constexpr (hasItsPid) { + outputDebugParts(particle.sign(), + (uint8_t)particle.tpcNClsFound(), + particle.tpcNClsFindable(), + (uint8_t)particle.tpcNClsCrossedRows(), + particle.tpcNClsShared(), + particle.tpcInnerParam(), + particle.itsNCls(), + particle.itsNClsInnerBarrel(), + particle.dcaXY(), + particle.dcaZ(), + particle.tpcSignal(), + particle.tpcNSigmaEl(), + particle.tpcNSigmaPi(), + particle.tpcNSigmaKa(), + particle.tpcNSigmaPr(), + particle.tpcNSigmaDe(), + particle.tpcNSigmaTr(), + particle.tpcNSigmaHe(), + particle.tofNSigmaEl(), + particle.tofNSigmaPi(), + particle.tofNSigmaKa(), + particle.tofNSigmaPr(), + particle.tofNSigmaDe(), + particle.tofNSigmaTr(), + particle.tofNSigmaHe(), + o2::analysis::femtoDream::itsSignal(particle), + particle.itsNSigmaEl(), + particle.itsNSigmaPi(), + particle.itsNSigmaKa(), + particle.itsNSigmaPr(), + particle.itsNSigmaDe(), + particle.itsNSigmaTr(), + particle.itsNSigmaHe(), + -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., -999.); + } else { + outputDebugParts(particle.sign(), + (uint8_t)particle.tpcNClsFound(), + particle.tpcNClsFindable(), + (uint8_t)particle.tpcNClsCrossedRows(), + particle.tpcNClsShared(), + particle.tpcInnerParam(), + particle.itsNCls(), + particle.itsNClsInnerBarrel(), + particle.dcaXY(), + particle.dcaZ(), + particle.tpcSignal(), + particle.tpcNSigmaEl(), + particle.tpcNSigmaPi(), + particle.tpcNSigmaKa(), + particle.tpcNSigmaPr(), + particle.tpcNSigmaDe(), + particle.tpcNSigmaTr(), + particle.tpcNSigmaHe(), + particle.tofNSigmaEl(), + particle.tofNSigmaPi(), + particle.tofNSigmaKa(), + particle.tofNSigmaPr(), + particle.tofNSigmaDe(), + particle.tofNSigmaTr(), + particle.tofNSigmaHe(), + -999., -999., -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., -999.); + } + } else { + outputDebugParts(-999., // sign + -999., -999., -999., -999., -999., -999., -999., -999., -999., // track properties (DCA, NCls, crossed rows, etc.) + -999., -999., -999., -999., -999., -999., -999., -999., // TPC PID (TPC signal + particle hypothesis) + -999., -999., -999., -999., -999., -999., -999., // TOF PID + -999., -999., -999., -999., -999., -999., -999., -999., // ITS PID + particle.dcaV0daughters(), + particle.v0radius(), + particle.x(), + particle.y(), + particle.z(), + particle.mK0Short(), + -999., -999., -999., -999., -999., -999., -999.); // Cascade properties + } + } + + template + void fillDebugCascade(ParticleType const& cascade, CollisionType const& col) + { + outputDebugParts(cascade.sign(), // sign + -999., -999., -999., -999., -999., -999., -999., -999., -999., // track properties (DCA, NCls, crossed rows, etc.) + -999., -999., -999., -999., -999., -999., -999., -999., // TPC PID (TPC signal + particle hypothesis) + -999., -999., -999., -999., -999., -999., -999., // TOF PID + -999., -999., -999., -999., -999., -999., -999., -999., // ITS PID + cascade.dcaV0daughters(), + cascade.v0radius(), + -999., // DecVtxV0 x + -999., // DecVtxV0 y + -999., // DecVtxV0 z + -999., // mKaon + cascade.dcav0topv(col.posX(), col.posY(), col.posZ()), + cascade.dcacascdaughters(), + cascade.cascradius(), + cascade.x(), + cascade.y(), + cascade.z(), + cascade.mOmega()); // QA for Reso + } + + template + void fillMCParticle(CollisionType const& col, ParticleType const& particle, o2::aod::femtodreamparticle::ParticleType fdparttype) + { + if (particle.has_mcParticle()) { + // get corresponding MC particle and its info + auto particleMC = particle.mcParticle(); + auto pdgCode = particleMC.pdgCode(); + TrackRegistry.fill(HIST("AnalysisQA/Particle"), pdgCode); + int particleOrigin = 99; + int pdgCodeMother = -1; + // get list of mothers, but it could be empty (for example in case of injected light nuclei) + auto motherparticlesMC = particleMC.template mothers_as(); + // check pdg code + TrackRegistry.fill(HIST("AnalysisQA/getGenStatusCode"), particleMC.getGenStatusCode()); + TrackRegistry.fill(HIST("AnalysisQA/getProcess"), particleMC.getProcess()); + // if this fails, the particle is a fake + if (abs(pdgCode) == abs(ConfTrkPDGCode.value)) { + // check first if particle is from pile up + // check if the collision associated with the particle is the same as the analyzed collision by checking their Ids + if ((col.has_mcCollision() && (particleMC.mcCollisionId() != col.mcCollisionId())) || !col.has_mcCollision()) { + particleOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kWrongCollision; + // check if particle is primary + } else if (particleMC.isPhysicalPrimary()) { + particleOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kPrimary; + // check if particle is secondary + // particle is from a decay -> getProcess() == 4 + // particle is generated during transport -> getGenStatusCode() == -1 + // list of mothers is not empty + } else if (particleMC.getProcess() == 4 && particleMC.getGenStatusCode() == -1 && !motherparticlesMC.empty()) { + // get direct mother + auto motherparticleMC = motherparticlesMC.front(); + pdgCodeMother = motherparticleMC.pdgCode(); + TrackRegistry.fill(HIST("AnalysisQA/Mother"), pdgCodeMother); + particleOrigin = checkDaughterType(fdparttype, motherparticleMC.pdgCode()); + // check if particle is material + // particle is from inelastic hadronic interaction -> getProcess() == 23 + // particle is generated during transport -> getGenStatusCode() == -1 + } else if (particleMC.getProcess() == 23 && particleMC.getGenStatusCode() == -1) { + particleOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kMaterial; + // cross check to see if we missed a case + } else { + particleOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kElse; + } + // if pdg code is wrong, particle is fake + } else { + particleOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kFake; + } + + outputPartsMC(particleOrigin, pdgCode, particleMC.pt(), particleMC.eta(), particleMC.phi()); + outputPartsMCLabels(outputPartsMC.lastIndex()); + if (ConfIsDebug) { + outputPartsExtMCLabels(outputPartsMC.lastIndex()); + outputDebugPartsMC(pdgCodeMother); + } + } else { + outputPartsMCLabels(-1); + if (ConfIsDebug) { + outputPartsExtMCLabels(-1); + } + } + } + + template + void fillMCCollision(CollisionType const& col) + { + if (col.has_mcCollision()) { + auto genMCcol = col.template mcCollision_as(); + outputMCCollision(genMCcol.multMCNParticlesEta08()); + outputCollsMCLabels(outputMCCollision.lastIndex()); + } else { + outputCollsMCLabels(-1); + } + } + template + void fillCollisionsAndTracksAndV0AndCascade(CollisionType const& col, TrackType const& tracks, TrackTypeWithItsPid const& tracksWithItsPid, V0Type const& fullV0s, CascadeType const& fullCascades) + { + // If triggering is enabled, select only events which were triggered wit our triggers + if (ConfEnableTriggerSelection) { + bool zorroSelected = zorro.isSelected(col.template bc_as().globalBC()); /// check if event was selected by triggers of interest + if (!zorroSelected) { + return; + } + } + + const auto vtxZ = col.posZ(); + const auto spher = colCuts.computeSphericity(col, tracks); + float mult = 0; + int multNtr = 0; + if (ConfIsRun3) { + if constexpr (useCentrality) { + if constexpr (analysePbPb) { + mult = col.centFT0C(); + } else { + mult = col.centFT0M(); + } + } else { + mult = 0; + } + multNtr = col.multNTracksPV(); + } else { + mult = 1; // multiplicity percentile is know in Run 2 + multNtr = col.multTracklets(); + } + + colCuts.fillQA(col, mult); + + // check whether the basic event selection criteria are fulfilled + // that included checking if there is at least on usable track or V0 + if (!colCuts.isSelectedCollision(col)) { + return; + } + bool emptyCollision = false; + if (ConfIsActivateCascade.value) { + if (colCuts.isEmptyCollision(col, tracks, trackCuts) && colCuts.isCollisionWithoutTrkCasc(col, fullCascades, cascadeCuts, tracks)) { + emptyCollision = true; + } + } + if (ConfIsActivateV0.value) { + if (colCuts.isEmptyCollision(col, tracks, trackCuts) && colCuts.isEmptyCollision(col, fullV0s, v0Cuts, tracks)) { + emptyCollision = true; + } + } else { + if (colCuts.isEmptyCollision(col, tracks, trackCuts)) { + emptyCollision = true; + } + } + if (emptyCollision) { + return; + } + + outputCollision(vtxZ, mult, multNtr, spher, mMagField); + if constexpr (isMC) { + fillMCCollision(col); + } + + std::vector childIDs = {0, 0}; // these IDs are necessary to keep track of the children + std::vector cascadechildIDs = {0, 0, 0}; // these IDs are necessary to keep track of the children + std::vector tmpIDtrack; // this vector keeps track of the matching of the primary track table row <-> aod::track table global index + std::vector Daughter1, Daughter2; + + for (auto& track : tracksWithItsPid) { + /// if the most open selection criteria are not fulfilled there is no + /// point looking further at the track + trackCuts.fillQA(track); + + if (track.tpcChi2NCl() < OptionTrackSpecialSelections.ConfTrkMinChi2PerClusterTPC || track.tpcChi2NCl() > OptionTrackSpecialSelections.ConfTrkMaxChi2PerClusterTPC) { + continue; + } + if (track.itsChi2NCl() > OptionTrackSpecialSelections.ConfTrkMaxChi2PerClusterITS) { + continue; + } + if ((OptionTrackSpecialSelections.ConfTrkTPCRefit && !track.hasTPC()) || (OptionTrackSpecialSelections.ConfTrkITSRefit && !track.hasITS())) { + continue; + } + + if (!trackCuts.isSelectedMinimal(track)) { + continue; + } + + TrackRegistry.fill(HIST("AnalysisQA/Chi2ITSTPCperCluster"), track.itsChi2NCl(), track.tpcChi2NCl()); + TrackRegistry.fill(HIST("AnalysisQA/RefitITSTPC"), track.hasITS(), track.hasTPC()); + + trackCuts.fillQA(track); + // the bit-wise container of the systematic variations is obtained + std::array cutContainer; + cutContainer = trackCuts.getCutContainer(track, track.pt(), track.eta(), sqrtf(powf(track.dcaXY(), 2.f) + powf(track.dcaZ(), 2.f))); + + // now the table is filled + outputParts(outputCollision.lastIndex(), + track.pt(), + track.eta(), + track.phi(), + aod::femtodreamparticle::ParticleType::kTrack, + cutContainer.at(femtoDreamTrackSelection::TrackContainerPosition::kCuts), + cutContainer.at(femtoDreamTrackSelection::TrackContainerPosition::kPID), + track.dcaXY(), childIDs, 0, 0); + tmpIDtrack.push_back(track.globalIndex()); + if (ConfIsDebug.value) { + fillDebugParticle(track); + } + + if constexpr (isMC) { + fillMCParticle(col, track, o2::aod::femtodreamparticle::ParticleType::kTrack); + } + + if (ConfIsActivateReso.value) { + // Already strict cuts for Daughter of reso selection + // TO DO: change TTV0 task to apply there the strict selection and have here only loose selection + + // select daugher 1 + if (track.sign() == ConfDaughterCharge.value[0] && track.pt() <= ConfDaughterPtUp.value[0] && track.pt() >= ConfDaughterPtLow.value[0] && std::abs(track.eta()) <= ConfDaughterEta.value[0] && std::abs(track.dcaXY()) <= ConfDaughterDCAxy.value[0] && std::abs(track.dcaZ()) <= ConfDaughterDCAz.value[0] && track.tpcNClsCrossedRows() >= ConfDaughterNCrossed.value[0] && track.tpcNClsFound() >= ConfDaughterNClus.value[0] && track.tpcCrossedRowsOverFindableCls() >= ConfDaughterTPCfCls.value[0]) { + if ((track.tpcInnerParam() < ConfDaughterPTPCThr.value[0] && std::abs(o2::aod::pidutils::tpcNSigma(ConfDaughterPIDspecies.value[0], track)) <= ConfDaughterPIDnSigmaMax.value[0]) || + (track.tpcInnerParam() >= ConfDaughterPTPCThr.value[0] && std::abs(std::sqrt(o2::aod::pidutils::tpcNSigma(ConfDaughterPIDspecies.value[0], track) * o2::aod::pidutils::tpcNSigma(ConfDaughterPIDspecies.value[0], track) + o2::aod::pidutils::tofNSigma(ConfDaughterPIDspecies.value[0], track) * o2::aod::pidutils::tofNSigma(ConfDaughterPIDspecies.value[0], track))) <= ConfDaughterPIDnSigmaMax.value[0])) { + Daughter1.push_back(track); + ResoRegistry.fill(HIST("AnalysisQA/Reso/Daughter1/Pt"), track.pt()); + ResoRegistry.fill(HIST("AnalysisQA/Reso/Daughter1/Eta"), track.eta()); + ResoRegistry.fill(HIST("AnalysisQA/Reso/Daughter1/Phi"), track.phi()); + } + } + // select daugher 2 + if (track.sign() == ConfDaughterCharge.value[1] && track.pt() <= ConfDaughterPtUp.value[1] && track.pt() >= ConfDaughterPtLow.value[1] && std::abs(track.eta()) <= ConfDaughterEta.value[1] && std::abs(track.dcaXY()) <= ConfDaughterDCAxy.value[1] && std::abs(track.dcaZ()) <= ConfDaughterDCAz.value[1] && track.tpcNClsCrossedRows() >= ConfDaughterNCrossed.value[1] && track.tpcNClsFound() >= ConfDaughterNClus.value[1] && track.tpcCrossedRowsOverFindableCls() >= ConfDaughterTPCfCls.value[1]) { + if ((track.tpcInnerParam() < ConfDaughterPTPCThr.value[1] && std::abs(o2::aod::pidutils::tpcNSigma(ConfDaughterPIDspecies.value[1], track)) <= ConfDaughterPIDnSigmaMax.value[1]) || + (track.tpcInnerParam() >= ConfDaughterPTPCThr.value[1] && std::abs(std::sqrt(o2::aod::pidutils::tpcNSigma(ConfDaughterPIDspecies.value[1], track) * o2::aod::pidutils::tpcNSigma(ConfDaughterPIDspecies.value[1], track) + o2::aod::pidutils::tofNSigma(ConfDaughterPIDspecies.value[1], track) * o2::aod::pidutils::tofNSigma(ConfDaughterPIDspecies.value[1], track))) <= ConfDaughterPIDnSigmaMax.value[1])) { + Daughter2.push_back(track); + ResoRegistry.fill(HIST("AnalysisQA/Reso/Daughter2/Pt"), track.pt()); + ResoRegistry.fill(HIST("AnalysisQA/Reso/Daughter2/Eta"), track.eta()); + ResoRegistry.fill(HIST("AnalysisQA/Reso/Daughter2/Phi"), track.phi()); + } + } + } + } + + if (ConfIsActivateV0.value) { + for (auto& v0 : fullV0s) { + + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + ///\tocheck funnily enough if we apply the filter the + /// sign of Pos and Neg track is always negative + // const auto dcaXYpos = postrack.dcaXY(); + // const auto dcaZpos = postrack.dcaZ(); + // const auto dcapos = std::sqrt(pow(dcaXYpos, 2.) + pow(dcaZpos, 2.)); + v0Cuts.fillLambdaQA(col, v0, postrack, negtrack); + + if (!v0Cuts.isSelectedMinimal(col, v0, postrack, negtrack)) { + continue; + } + + // if (ConfRejectITSHitandTOFMissing) { + // Uncomment only when TOF timing is solved + // bool itsHit = o2PhysicsTrackSelection->IsSelected(postrack, + // TrackSelection::TrackCuts::kITSHits); bool itsHit = + // o2PhysicsTrackSelection->IsSelected(negtrack, + // TrackSelection::TrackCuts::kITSHits); + // } + + v0Cuts.fillQA(col, v0, postrack, negtrack); ///\todo fill QA also for daughters + auto cutContainerV0 = v0Cuts.getCutContainer(col, v0, postrack, negtrack); + + int postrackID = v0.posTrackId(); + int rowInPrimaryTrackTablePos = -1; + rowInPrimaryTrackTablePos = getRowDaughters(postrackID, tmpIDtrack); + childIDs[0] = rowInPrimaryTrackTablePos; + childIDs[1] = 0; + outputParts(outputCollision.lastIndex(), + v0.positivept(), v0.positiveeta(), v0.positivephi(), + aod::femtodreamparticle::ParticleType::kV0Child, + cutContainerV0.at(femtoDreamV0Selection::V0ContainerPosition::kPosCuts), + cutContainerV0.at(femtoDreamV0Selection::V0ContainerPosition::kPosPID), + postrack.dcaXY(), + childIDs, + 0, + 0); + const int rowOfPosTrack = outputParts.lastIndex(); + if constexpr (isMC) { + fillMCParticle(col, postrack, o2::aod::femtodreamparticle::ParticleType::kV0Child); + } + int negtrackID = v0.negTrackId(); + int rowInPrimaryTrackTableNeg = -1; + rowInPrimaryTrackTableNeg = getRowDaughters(negtrackID, tmpIDtrack); + childIDs[0] = 0; + childIDs[1] = rowInPrimaryTrackTableNeg; + outputParts(outputCollision.lastIndex(), + v0.negativept(), + v0.negativeeta(), + v0.negativephi(), + aod::femtodreamparticle::ParticleType::kV0Child, + cutContainerV0.at(femtoDreamV0Selection::V0ContainerPosition::kNegCuts), + cutContainerV0.at(femtoDreamV0Selection::V0ContainerPosition::kNegPID), + negtrack.dcaXY(), + childIDs, + 0, + 0); + const int rowOfNegTrack = outputParts.lastIndex(); + if constexpr (isMC) { + fillMCParticle(col, negtrack, o2::aod::femtodreamparticle::ParticleType::kV0Child); + } + std::vector indexChildID = {rowOfPosTrack, rowOfNegTrack}; + outputParts(outputCollision.lastIndex(), + v0.pt(), + v0.eta(), + v0.phi(), + aod::femtodreamparticle::ParticleType::kV0, + cutContainerV0.at(femtoDreamV0Selection::V0ContainerPosition::kV0), + 0, + v0.v0cosPA(), + indexChildID, + v0.mLambda(), + v0.mAntiLambda()); + if (ConfIsDebug.value) { + fillDebugParticle(postrack); // QA for positive daughter + fillDebugParticle(negtrack); // QA for negative daughter + fillDebugParticle(v0); // QA for v0 + } + if constexpr (isMC) { + fillMCParticle(col, v0, o2::aod::femtodreamparticle::ParticleType::kV0); + } + } + } + if (ConfIsActivateCascade.value) { + for (auto& casc : fullCascades) { + // get the daughter tracks + const auto& posTrackCasc = casc.template posTrack_as(); + const auto& negTrackCasc = casc.template negTrack_as(); + const auto& bachTrackCasc = casc.template bachelor_as(); + + cascadeCuts.fillQA<0, aod::femtodreamparticle::ParticleType::kCascade>(col, casc, posTrackCasc, negTrackCasc, bachTrackCasc); + if (!cascadeCuts.isSelectedMinimal(col, casc, posTrackCasc, negTrackCasc, bachTrackCasc)) { + continue; + } + cascadeCuts.fillQA<1, aod::femtodreamparticle::ParticleType::kCascade>(col, casc, posTrackCasc, negTrackCasc, bachTrackCasc); + + // auto cutContainerCasc = cascadeCuts.getCutContainer(col, casc, v0daugh, posTrackCasc, negTrackCasc, bachTrackCasc); + auto cutContainerCasc = cascadeCuts.getCutContainer(col, casc, posTrackCasc, negTrackCasc, bachTrackCasc); + + // Fill positive child + int poscasctrackID = casc.posTrackId(); + int rowInPrimaryTrackTablePosCasc = -1; + rowInPrimaryTrackTablePosCasc = getRowDaughters(poscasctrackID, tmpIDtrack); + cascadechildIDs[0] = rowInPrimaryTrackTablePosCasc; + cascadechildIDs[1] = 0; + cascadechildIDs[2] = 0; + outputParts(outputCollision.lastIndex(), + posTrackCasc.pt(), + posTrackCasc.eta(), + posTrackCasc.phi(), + aod::femtodreamparticle::ParticleType::kCascadeV0Child, + cutContainerCasc.at(femtoDreamCascadeSelection::CascadeContainerPosition::kPosCuts), + cutContainerCasc.at(femtoDreamCascadeSelection::CascadeContainerPosition::kPosPID), + posTrackCasc.dcaXY(), + cascadechildIDs, + 0, + 0); + const int rowOfPosCascadeTrack = outputParts.lastIndex(); + // TODO: include here MC filling + //------ + + // Fill negative child + int negcasctrackID = casc.negTrackId(); + int rowInPrimaryTrackTableNegCasc = -1; + rowInPrimaryTrackTableNegCasc = getRowDaughters(negcasctrackID, tmpIDtrack); + cascadechildIDs[0] = 0; + cascadechildIDs[1] = rowInPrimaryTrackTableNegCasc; + cascadechildIDs[2] = 0; + outputParts(outputCollision.lastIndex(), + negTrackCasc.pt(), + negTrackCasc.eta(), + negTrackCasc.phi(), + aod::femtodreamparticle::ParticleType::kCascadeV0Child, + cutContainerCasc.at(femtoDreamCascadeSelection::CascadeContainerPosition::kNegCuts), + cutContainerCasc.at(femtoDreamCascadeSelection::CascadeContainerPosition::kNegPID), + negTrackCasc.dcaXY(), + cascadechildIDs, + 0, + 0); + const int rowOfNegCascadeTrack = outputParts.lastIndex(); + // TODO: include here MC filling + //------ + + // Fill bachelor child + int bachelorcasctrackID = casc.bachelorId(); + int rowInPrimaryTrackTableBachelorCasc = -1; + rowInPrimaryTrackTableBachelorCasc = getRowDaughters(bachelorcasctrackID, tmpIDtrack); + cascadechildIDs[0] = 0; + cascadechildIDs[1] = 0; + cascadechildIDs[2] = rowInPrimaryTrackTableBachelorCasc; + outputParts(outputCollision.lastIndex(), + bachTrackCasc.pt(), + bachTrackCasc.eta(), + bachTrackCasc.phi(), + aod::femtodreamparticle::ParticleType::kCascadeBachelor, + cutContainerCasc.at(femtoDreamCascadeSelection::CascadeContainerPosition::kBachCuts), + cutContainerCasc.at(femtoDreamCascadeSelection::CascadeContainerPosition::kBachPID), + bachTrackCasc.dcaXY(), + cascadechildIDs, + 0, + 0); + const int rowOfBachelorCascadeTrack = outputParts.lastIndex(); + // TODO: include here MC filling + //------ + + // Fill cascades + std::vector indexCascadeChildID = {rowOfPosCascadeTrack, rowOfNegCascadeTrack, rowOfBachelorCascadeTrack}; + outputParts(outputCollision.lastIndex(), + casc.pt(), + casc.eta(), + casc.phi(), + aod::femtodreamparticle::ParticleType::kCascade, + cutContainerCasc.at(femtoDreamCascadeSelection::CascadeContainerPosition::kCascade), + 0, + casc.casccosPA(col.posX(), col.posY(), col.posZ()), + indexCascadeChildID, + casc.mXi(), + casc.mLambda()); + // TODO: include here MC filling + //------ + + if (ConfIsDebug.value) { + fillDebugParticle(posTrackCasc); // QA for positive daughter + fillDebugParticle(negTrackCasc); // QA for negative daughter + fillDebugParticle(bachTrackCasc); // QA for negative daughter + fillDebugCascade(casc, col); // QA for Cascade + } + } + } + + if (ConfIsActivateReso.value) { + for (std::size_t iDaug1 = 0; iDaug1 < Daughter1.size(); ++iDaug1) { + for (std::size_t iDaug2 = 0; iDaug2 < Daughter2.size(); ++iDaug2) { + // MC stuff is still missing, also V0 QA + // ALSO: fix indices and other table entries which are now set to 0 as deflaut as not needed for p-p-phi cf ana + + ROOT::Math::PtEtaPhiMVector tempD1(Daughter1.at(iDaug1).pt(), Daughter1.at(iDaug1).eta(), Daughter1.at(iDaug1).phi(), ConfDaug1Daugh2ResoMass.value[0]); + ROOT::Math::PtEtaPhiMVector tempD2(Daughter2.at(iDaug2).pt(), Daughter2.at(iDaug2).eta(), Daughter2.at(iDaug2).phi(), ConfDaug1Daugh2ResoMass.value[1]); + + ROOT::Math::PtEtaPhiMVector tempPhi = tempD1 + tempD2; + + ResoRegistry.fill(HIST("AnalysisQA/Reso/InvMass"), tempPhi.M()); + + if ((tempPhi.M() >= ConfResoInvMassLowLimit.value) && (tempPhi.M() <= ConfResoInvMassUpLimit.value)) { + + ResoRegistry.fill(HIST("AnalysisQA/Reso/InvMass_selected"), tempPhi.M()); + ResoRegistry.fill(HIST("AnalysisQA/Reso/PtD1_selected"), Daughter1.at(iDaug1).pt()); + ResoRegistry.fill(HIST("AnalysisQA/Reso/PtD2_selected"), Daughter2.at(iDaug2).pt()); + + childIDs[0] = 0; + childIDs[1] = 0; + std::vector indexChildID = {0, 0}; + outputParts(outputCollision.lastIndex(), + static_cast(Daughter1.at(iDaug1).pt()), static_cast(Daughter1.at(iDaug1).eta()), static_cast(Daughter1.at(iDaug1).phi()), + aod::femtodreamparticle::ParticleType::kV0Child, + static_cast(0), + static_cast(0), + static_cast(Daughter1.at(iDaug1).dcaXY()), + childIDs, + 0, + 0); + outputParts(outputCollision.lastIndex(), + static_cast(Daughter2.at(iDaug2).pt()), static_cast(Daughter2.at(iDaug2).eta()), static_cast(Daughter2.at(iDaug2).phi()), + aod::femtodreamparticle::ParticleType::kV0Child, + static_cast(0), + static_cast(0), + static_cast(Daughter2.at(iDaug2).dcaXY()), + childIDs, + 0, + 0); + outputParts(outputCollision.lastIndex(), + static_cast(tempPhi.pt()), + static_cast(tempPhi.eta()), + static_cast(tempPhi.phi()), + aod::femtodreamparticle::ParticleType::kV0, + static_cast(0), + 0, + 0.f, + indexChildID, + tempPhi.M(), + tempPhi.M()); + if (ConfIsDebug.value) { + fillDebugParticle(Daughter1.at(iDaug1)); // QA for positive daughter + fillDebugParticle(Daughter2.at(iDaug2)); // QA for negative daughter + outputDebugParts(-999., // sign + -999., -999., -999., -999., -999., -999., -999., -999., -999., // track properties (DCA, NCls, crossed rows, etc.) + -999., -999., -999., -999., -999., -999., -999., -999., // TPC PID (TPC signal + particle hypothesis) + -999., -999., -999., -999., -999., -999., -999., // TOF PID + -999., -999., -999., -999., -999., -999., -999., -999., // ITS PID + -999., -999., -999., -999., -999., -999., // V0 properties + -999., -999., -999., -999., -999., -999., -999.); // Cascade properties + } + } + } + } + } + } + + void + processData(aod::FemtoFullCollision const& col, + aod::BCsWithTimestamps const&, + aod::FemtoFullTracks const& tracks, + o2::aod::V0Datas const& fullV0s, + o2::aod::V0sLinked const&, + o2::aod::CascDatas const& fullCascades) + { + // get magnetic field for run + initCCDB_Mag_Trig(col.bc_as()); + // fill the tables + auto tracksWithItsPid = soa::Attach(tracks); + if (ConfUseItsPid.value) { + fillCollisionsAndTracksAndV0AndCascade(col, tracks, tracksWithItsPid, fullV0s, fullCascades); + } else { + fillCollisionsAndTracksAndV0AndCascade(col, tracks, tracks, fullV0s, fullCascades); + } + } + PROCESS_SWITCH(femtoDreamProducerTaskWithCascades, processData, + "Provide experimental data", true); + + void + processData_noCentrality(aod::FemtoFullCollision_noCent const& col, + aod::BCsWithTimestamps const&, + aod::FemtoFullTracks const& tracks, + o2::aod::V0Datas const& fullV0s, + o2::aod::V0sLinked const&, + o2::aod::CascDatas const& fullCascades) + { + // get magnetic field for run + initCCDB_Mag_Trig(col.bc_as()); + // fill the tables + auto tracksWithItsPid = soa::Attach(tracks); + if (ConfUseItsPid.value) { + fillCollisionsAndTracksAndV0AndCascade(col, tracks, tracksWithItsPid, fullV0s, fullCascades); + } else { + fillCollisionsAndTracksAndV0AndCascade(col, tracks, tracks, fullV0s, fullCascades); + } + } + PROCESS_SWITCH(femtoDreamProducerTaskWithCascades, processData_noCentrality, + "Provide experimental data without centrality information", false); + + void processData_CentPbPb(aod::FemtoFullCollision_CentPbPb const& col, + aod::BCsWithTimestamps const&, + aod::FemtoFullTracks const& tracks, + o2::aod::V0Datas const& fullV0s, + o2::aod::CascDatas const& fullCascades) + { + // get magnetic field for run + initCCDB_Mag_Trig(col.bc_as()); + // fill the tables + auto tracksWithItsPid = soa::Attach(tracks); + if (ConfUseItsPid.value) { + fillCollisionsAndTracksAndV0AndCascade(col, tracks, tracksWithItsPid, fullV0s, fullCascades); + } else { + fillCollisionsAndTracksAndV0AndCascade(col, tracks, tracks, fullV0s, fullCascades); + } + } + PROCESS_SWITCH(femtoDreamProducerTaskWithCascades, processData_CentPbPb, + "Provide experimental data with centrality information for PbPb collisions", false); + + void processMC(aod::FemtoFullCollisionMC const& col, + aod::BCsWithTimestamps const&, + soa::Join const& tracks, + aod::FemtoFullMCgenCollisions const&, + aod::McParticles const&, + soa::Join const& fullV0s, /// \todo with FilteredFullV0s + soa::Join const& fullCascades) + { + // get magnetic field for run + initCCDB_Mag_Trig(col.bc_as()); + // fill the tables + fillCollisionsAndTracksAndV0AndCascade(col, tracks, tracks, fullV0s, fullCascades); + } + PROCESS_SWITCH(femtoDreamProducerTaskWithCascades, processMC, "Provide MC data", false); + + void processMC_noCentrality(aod::FemtoFullCollision_noCent_MC const& col, + aod::BCsWithTimestamps const&, + soa::Join const& tracks, + aod::FemtoFullMCgenCollisions const&, + aod::McParticles const&, + soa::Join const& fullV0s, /// \todo with FilteredFullV0s + soa::Join const& fullCascades) + { + // get magnetic field for run + initCCDB_Mag_Trig(col.bc_as()); + // fill the tables + fillCollisionsAndTracksAndV0AndCascade(col, tracks, tracks, fullV0s, fullCascades); + } + PROCESS_SWITCH(femtoDreamProducerTaskWithCascades, processMC_noCentrality, "Provide MC data without requiring a centrality calibration", false); + + void processMC_CentPbPb(aod::FemtoFullCollisionMC_CentPbPb const& col, + aod::BCsWithTimestamps const&, + soa::Join const& tracks, + aod::FemtoFullMCgenCollisions const&, + aod::McParticles const&, + soa::Join const& fullV0s, /// \todo with FilteredFullV0s + soa::Join const& fullCascades) + { + // get magnetic field for run + initCCDB_Mag_Trig(col.bc_as()); + // fill the tables + fillCollisionsAndTracksAndV0AndCascade(col, tracks, tracks, fullV0s, fullCascades); + } + PROCESS_SWITCH(femtoDreamProducerTaskWithCascades, processMC_CentPbPb, "Provide MC data with centrality information for PbPb collisions", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/PWGCF/FemtoDream/Tasks/CMakeLists.txt b/PWGCF/FemtoDream/Tasks/CMakeLists.txt index 58d9744c029..3341346bb24 100644 --- a/PWGCF/FemtoDream/Tasks/CMakeLists.txt +++ b/PWGCF/FemtoDream/Tasks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2024 CERN and copyright holders of ALICE O2. +# Copyright 2019-2025 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. # @@ -19,11 +19,21 @@ o2physics_add_dpl_workflow(femtodream-triplet-track-track-track PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femtodream-triplet-track-track-track-pb-pb + SOURCES femtoDreamTripletTaskTrackTrackTrackPbPb.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(femtodream-pair-track-v0 SOURCES femtoDreamPairTaskTrackV0.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femtodream-pair-track-cascade + SOURCES femtoDreamPairTaskTrackCascade.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(femtodream-triplet-track-track-v0 SOURCES femtoDreamTripletTaskTrackTrackV0.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore @@ -39,11 +49,21 @@ o2physics_add_dpl_workflow(femtodream-debug-v0 PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femtodream-debug-cascade + SOURCES femtoDreamDebugCascade.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(femtodream-collision-masker SOURCES femtoDreamCollisionMasker.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femtodream-pair-efficiency + SOURCES femtoDreamPairEfficiency.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(femtodream-hash SOURCES femtoDreamHashTask.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamCollisionMasker.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamCollisionMasker.cxx index 63d817a8afc..fddbee16a88 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamCollisionMasker.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamCollisionMasker.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2023 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -243,7 +244,7 @@ struct femoDreamCollisionMasker { NegChildPIDTPCBits.at(CollisionMasks::kPartTwo).push_back(option.defaultValue.get()); } } - } else if (device.name.find("femto-dream-triplet-task-track-track-track") != std::string::npos) { + } else if ((device.name.find("femto-dream-triplet-task-track-track-track") != std::string::npos) || (device.name.find("femto-dream-triplet-task-track-track-track-pb-pb") != std::string::npos)) { LOG(info) << "Matched workflow: " << device.name; TaskFinder = CollisionMasks::kTrackTrackTrack; for (auto const& option : device.options) { @@ -263,6 +264,8 @@ struct femoDreamCollisionMasker { FilterTempFitVarMax.at(CollisionMasks::kPartOne).push_back(option.defaultValue.get()); } else if (option.name.compare(std::string("ConfMinDCAxy")) == 0) { FilterTempFitVarMin.at(CollisionMasks::kPartOne).push_back(option.defaultValue.get()); + } else if (option.name.compare(std::string("ConfDCACutPtDep")) == 0) { + TrackDCACutPtDep.push_back(option.defaultValue.get()); } } } else if (device.name.find("femto-dream-triplet-task-track-track-v0") != std::string::npos) { @@ -307,6 +310,8 @@ struct femoDreamCollisionMasker { FilterPtMin.at(CollisionMasks::kPartThree).push_back(option.defaultValue.get()); } else if (option.name.compare(std::string("Conf_maxPt_V0")) == 0) { FilterPtMax.at(CollisionMasks::kPartThree).push_back(option.defaultValue.get()); + } else if (option.name.compare(std::string("ConfDCACutPtDep")) == 0) { + TrackDCACutPtDep.push_back(option.defaultValue.get()); } } } @@ -332,16 +337,18 @@ struct femoDreamCollisionMasker { // if they are not passed, skip the particle if (track.pt() < FilterPtMin.at(P).at(index) || track.pt() > FilterPtMax.at(P).at(index) || track.eta() < FilterEtaMin.at(P).at(index) || track.eta() > FilterEtaMax.at(P).at(index)) { - // check if we apply pt dependend dca cut - if (TrackDCACutPtDep.at(index)) { - if (std::fabs(track.tempFitVar()) > 0.0105f * (0.035f / std::pow(track.pt(), 1.1f))) { - continue; - } - } else { - // or cut on the DCA directly - if (track.tempFitVar() < FilterTempFitVarMin.at(P).at(index) || track.tempFitVar() > FilterTempFitVarMax.at(P).at(index)) { - continue; - } + continue; + } + // check if we apply pt dependend dca cut + // if they do not pass this cut, skip particle as well + if (TrackDCACutPtDep.at(index)) { + if (std::fabs(track.tempFitVar()) > 0.0105f + (0.035f / std::pow(track.pt(), 1.1f))) { + continue; + } + } else { + // or cut on the DCA directly + if (track.tempFitVar() < FilterTempFitVarMin.at(P).at(index) || track.tempFitVar() > FilterTempFitVarMax.at(P).at(index)) { + continue; } } // set the bit at the index of the selection equal to one if the track passes all selections @@ -385,12 +392,24 @@ struct femoDreamCollisionMasker { if (track.partType() != static_cast(femtodreamparticle::kTrack)) { continue; } + // check filter cuts - if (track.pt() < FilterPtMin.at(P).at(index) || track.pt() > FilterPtMax.at(P).at(index) || - track.tempFitVar() > FilterTempFitVarMax.at(P).at(index) || track.tempFitVar() < FilterTempFitVarMin.at(P).at(index)) { + if (track.pt() < FilterPtMin.at(P).at(index) || track.pt() > FilterPtMax.at(P).at(index)) { // if they are not passed, skip the particle continue; } + + if (TrackDCACutPtDep.at(index)) { + if (std::fabs(track.tempFitVar()) > 0.0105f + (0.035f / std::pow(track.pt(), 1.1f))) { + continue; + } + } else { + // or cut on the DCA directly + if (track.tempFitVar() < FilterTempFitVarMin.at(P).at(index) || track.tempFitVar() > FilterTempFitVarMax.at(P).at(index)) { + continue; + } + } + // set the bit at the index of the selection equal to one if the track passes all selections // check track cuts if ((track.cut() & TrackCutBits.at(P).at(index)) == TrackCutBits.at(P).at(index)) { diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamDebugCascade.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamDebugCascade.cxx new file mode 100644 index 00000000000..54324361ec0 --- /dev/null +++ b/PWGCF/FemtoDream/Tasks/femtoDreamDebugCascade.cxx @@ -0,0 +1,188 @@ +// Copyright 2019-2025 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. + +/// \file femtoDreamDebugV0.cxx +/// \brief Tasks that reads the particle tables and fills QA histograms for V0s +/// \author Luca Barioglio, TU München, luca.barioglio@cern.ch +/// \author Georgios Mantzaridis, TU München, luca.barioglio@cern.ch + +#include +#include +#include +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StepTHn.h" +#include "DataFormatsParameters/GRPObject.h" +#include "fairlogger/Logger.h" + +#include "PWGCF/DataModel/FemtoDerived.h" +#include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h" +#include "PWGCF/FemtoDream/Core/femtoDreamEventHisto.h" +#include "PWGCF/FemtoDream/Core/femtoDreamMath.h" +#include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" + +using namespace o2; +using namespace o2::analysis::femtoDream; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct femtoDreamDebugCascade { + SliceCache cache; + + Configurable ConfCascade_PDGCode{"ConfCascade_PDGCode", 3312, "Cascade - PDG code"}; + Configurable ConfCascade_ChildPos_PDGCode{"ConfCascade_PosChild_PDGCode", 2212, "Positive Child - PDG code"}; + Configurable ConfCascade_ChildNeg_PDGCode{"ConfCascade_NegChild_PDGCode", 211, "Negative Child- PDG code"}; + Configurable ConfCascade_Bach_PDGCode{"ConfCascade_Bach_PDGCode", 211, "Bachelor Child- PDG code"}; + + Configurable ConfCascade_CutBit{"ConfCascade_CutBit", 338, "Cascade - Selection bit from cutCulator"}; + ConfigurableAxis ConfCascadeTempFitVarBins{"ConfCascadeTempFitVarBins", {300, 0.95, 1.}, "Cascade: binning of the TempFitVar in the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfCascadeTempFitVarMomentumBins{"ConfCascadeTempFitVarMomentumBins", {20, 0.5, 4.05}, "Cascade: pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfBinmult{"ConfBinmult", {1, 0, 1}, "multiplicity Binning"}; + ConfigurableAxis ConfDummy{"ConfDummy", {1, 0, 1}, "Dummy axis for inv mass"}; + + Configurable ConfCascadeTempFitVarMomentum{"ConfCascadeTempFitVarMomentum", 0, "Momentum used for binning: 0 -> pt; 1 -> preco; 2 -> ptpc"}; + + ConfigurableAxis ConfCascadeInvMassBins{"ConfCascadeInvMassBins", {200, 1.25, 1.45}, "Cascade: InvMass binning"}; + ConfigurableAxis ConfCascadeInvMassCompetingBins{"ConfCascadeInvMassCompetingBins", {200, 1.57, 1.77}, "Cascade: InvMass binning of the competing candidate"}; + + ConfigurableAxis ConfCascadeChildTempFitVarMomentumBins{"ConfCascadeChildTempFitVarMomentumBins", {600, 0, 6}, "p binning for the p vs Nsigma TPC/TOF plot"}; + ConfigurableAxis ConfCascadeChildNsigmaTPCBins{"ConfCascadeChildNsigmaTPCBins", {1600, -8, 8}, "binning of Nsigma TPC plot"}; + ConfigurableAxis ConfCascadeChildNsigmaTOFBins{"ConfCascadeChildNsigmaTOFBins", {3000, -15, 15}, "binning of the Nsigma TOF plot"}; + ConfigurableAxis ConfCascadeChildNsigmaTPCTOFBins{"ConfCascadeChildNsigmaTPCTOFBins", {1000, 0, 10}, "binning of the Nsigma TPC+TOF plot"}; + + Configurable ConfCascade_ChildPos_CutBit{"ConfCascade_ChildPos_CutBit", 150, "Positive Child of Cascade - Selection bit from cutCulator"}; + Configurable ConfCascade_ChildPos_TPCBit{"ConfCascade_ChildPos_TPCBit", 4, "Positive Child of Cascade - PID bit from cutCulator"}; + Configurable ConfCascade_ChildNeg_CutBit{"ConfCascade_ChildNeg_CutBit", 149, "Negative Child of Cascade - PID bit from cutCulator"}; + Configurable ConfCascade_ChildNeg_TPCBit{"ConfCascade_ChildNeg_TPCBit", 8, "Negative Child of Cascade - PID bit from cutCulator"}; + Configurable ConfCascade_ChildBach_CutBit{"ConfCascade_ChildBach_CutBit", 149, "Bachelor Child of Cascade - PID bit from cutCulator"}; + Configurable ConfCascade_ChildBach_TPCBit{"ConfCascade_ChildBach_TPCBit", 8, "Bachelor Child of Cascade - PID bit from cutCulator"}; + Configurable ConfUseChildCuts{"ConfUseChildCuts", true, "Use cuts on the children of the Cascades additional to those of the selection of the cascade builder"}; + Configurable ConfUseChildPIDCuts{"ConfUseChildPIDCuts", true, "Use cuts on the children of the Cascades additional to those of the selection of the cascade builder"}; + + Configurable ConfIsOmega{"ConfIsOmega", false, "Switch between Xi and Omaga Cascades: If true: Omega; else: Xi"}; + Configurable ConfRejectCompetingMass{"ConfRejectCompetingMass", false, "Reject the competing Cascade Mass (use only for debugging. More efficient to exclude it already at the producer level)"}; + Configurable ConfCompetingCascadeMassLowLimit{"ConfCompetingCascadeMassLowLimit", 0., "Lower Limit of the invariant mass window within which to reject the cascade"}; + Configurable ConfCompetingCascadeMassUpLimit{"ConfCompetingCascadeMassUpLimit", 0., "Upper Limit of the invariant mass window within which to reject the cascade"}; + + ConfigurableAxis ConfCascadeChildTempFitVarBins{"ConfCascadeChildTempFitVarBins", {300, -0.15, 0.15}, "Cascade child: binning of the TempFitVar in the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfCascadeChildTempFitVarpTBins{"ConfCascadeChildTempFitVarpTBins", {20, 0.5, 4.05}, "Cascade child: pT binning of the pT vs. TempFitVar plot"}; + + using FemtoFullParticles = soa::Join; + Partition partsOne = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kCascade)) && (ncheckbit(aod::femtodreamparticle::cut, ConfCascade_CutBit)); + Preslice perCol = aod::femtodreamparticle::fdCollisionId; + + /// Histogramming + FemtoDreamEventHisto eventHisto; + FemtoDreamParticleHisto posChildHistos; + FemtoDreamParticleHisto negChildHistos; + FemtoDreamParticleHisto bachelorHistos; + FemtoDreamParticleHisto CascadeHistos; + + /// Histogram output + HistogramRegistry EventRegistry{"Event", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry CascadeRegistry{"FullCascQA", {}, OutputObjHandlingPolicy::AnalysisObject}; + + float massProton; + float massPion; + float massKaon; + float massLambda; + float massCompetingBach; + + void init(InitContext&) + { + eventHisto.init(&EventRegistry, false); + posChildHistos.init(&CascadeRegistry, ConfBinmult, ConfDummy, ConfCascadeChildTempFitVarMomentumBins, ConfDummy, ConfDummy, ConfCascadeChildTempFitVarBins, ConfCascadeChildNsigmaTPCBins, ConfCascadeChildNsigmaTOFBins, ConfCascadeChildNsigmaTPCTOFBins, ConfDummy, ConfCascadeInvMassBins, ConfCascadeInvMassCompetingBins, false, ConfCascade_ChildPos_PDGCode.value, true); + negChildHistos.init(&CascadeRegistry, ConfBinmult, ConfDummy, ConfCascadeChildTempFitVarMomentumBins, ConfDummy, ConfDummy, ConfCascadeChildTempFitVarBins, ConfCascadeChildNsigmaTPCBins, ConfCascadeChildNsigmaTOFBins, ConfCascadeChildNsigmaTPCTOFBins, ConfDummy, ConfCascadeInvMassBins, ConfCascadeInvMassCompetingBins, false, ConfCascade_ChildNeg_PDGCode.value, true); + bachelorHistos.init(&CascadeRegistry, ConfBinmult, ConfDummy, ConfCascadeChildTempFitVarMomentumBins, ConfDummy, ConfDummy, ConfCascadeChildTempFitVarBins, ConfCascadeChildNsigmaTPCBins, ConfCascadeChildNsigmaTOFBins, ConfCascadeChildNsigmaTPCTOFBins, ConfDummy, ConfCascadeInvMassBins, ConfCascadeInvMassCompetingBins, false, ConfCascade_Bach_PDGCode.value, true); + CascadeHistos.init(&CascadeRegistry, ConfBinmult, ConfDummy, ConfCascadeTempFitVarMomentumBins, ConfDummy, ConfDummy, ConfCascadeTempFitVarBins, ConfCascadeChildNsigmaTPCBins, ConfCascadeChildNsigmaTOFBins, ConfCascadeChildNsigmaTPCTOFBins, ConfDummy, ConfCascadeInvMassBins, ConfCascadeInvMassCompetingBins, false, ConfCascade_PDGCode.value, true); + + massProton = o2::analysis::femtoDream::getMass(2212); + massPion = o2::analysis::femtoDream::getMass(211); + massKaon = o2::analysis::femtoDream::getMass(321); + massLambda = o2::analysis::femtoDream::getMass(3122); + if (ConfIsOmega) { // if the Cascade is an Omega, then the bachelor is a Kaon + massCompetingBach = o2::analysis::femtoDream::getMass(211); + } else { // if the Cascade is a Xi, then the bachelor is a Pion + massCompetingBach = o2::analysis::femtoDream::getMass(321); + } + } + + /// Porduce QA plots for V0 selection in FemtoDream framework + void process(o2::aod::FDCollision const& col, FemtoFullParticles const& parts) + { + auto groupPartsOne = partsOne->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + eventHisto.fillQA(col); + for (auto& part : groupPartsOne) { + if (!part.has_children()) { + continue; + } + // check cut on v0 children + const auto& posChild = parts.iteratorAt(part.index() - 3); + const auto& negChild = parts.iteratorAt(part.index() - 2); + const auto& bachChild = parts.iteratorAt(part.index() - 1); + if (posChild.globalIndex() != part.childrenIds()[0] || negChild.globalIndex() != part.childrenIds()[1] || bachChild.globalIndex() != part.childrenIds()[2]) { + LOG(warn) << "Indices of V0 children do not match"; + continue; + } + // check cuts on V0 children + if (posChild.partType() == uint8_t(aod::femtodreamparticle::ParticleType::kCascadeV0Child) && + negChild.partType() == uint8_t(aod::femtodreamparticle::ParticleType::kCascadeV0Child) && + bachChild.partType() == uint8_t(aod::femtodreamparticle::ParticleType::kCascadeBachelor)) { + + if (ConfUseChildCuts) { + if (!((posChild.cut() & ConfCascade_ChildPos_CutBit) == ConfCascade_ChildPos_CutBit && + (negChild.cut() & ConfCascade_ChildNeg_CutBit) == ConfCascade_ChildNeg_CutBit && + (bachChild.cut() & ConfCascade_ChildBach_CutBit) == ConfCascade_ChildBach_CutBit)) { + continue; + } + } + if (ConfUseChildPIDCuts) { + if (!((posChild.pidcut() & ConfCascade_ChildPos_TPCBit) == ConfCascade_ChildPos_TPCBit && + (negChild.pidcut() & ConfCascade_ChildNeg_TPCBit) == ConfCascade_ChildNeg_TPCBit && + (bachChild.pidcut() & ConfCascade_ChildBach_TPCBit) == ConfCascade_ChildBach_TPCBit)) { + continue; + } + } + + // Competing mass rejection + if (ConfRejectCompetingMass) { + float invMassCompetingCasc; + if (part.sign() < 0) { + invMassCompetingCasc = FemtoDreamMath::getInvMassCascade(posChild, massProton, negChild, massPion, bachChild, massCompetingBach, massLambda); + } else { + invMassCompetingCasc = FemtoDreamMath::getInvMassCascade(posChild, massPion, negChild, massProton, bachChild, massCompetingBach, massLambda); + } + if (invMassCompetingCasc > ConfCompetingCascadeMassLowLimit.value && + invMassCompetingCasc < ConfCompetingCascadeMassUpLimit.value) { + continue; + } + } + CascadeHistos.fillQA(part, static_cast(ConfCascadeTempFitVarMomentum.value), col.multNtr(), col.multV0M()); + posChildHistos.fillQA(posChild, static_cast(ConfCascadeTempFitVarMomentum.value), col.multNtr(), col.multV0M()); + negChildHistos.fillQA(negChild, static_cast(ConfCascadeTempFitVarMomentum.value), col.multNtr(), col.multV0M()); + bachelorHistos.fillQA(bachChild, static_cast(ConfCascadeTempFitVarMomentum.value), col.multNtr(), col.multV0M()); + } + } + } +}; + +WorkflowSpec + defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{ + adaptAnalysisTask(cfgc), + }; + return workflow; +} diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamDebugTrack.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamDebugTrack.cxx index efeadded366..68fab988fb9 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamDebugTrack.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamDebugTrack.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -61,6 +61,7 @@ struct femtoDreamDebugTrack { ConfigurableAxis ConfNsigmaTPCBins{"ConfNsigmaTPCBins", {1600, -8, 8}, "Binning of Nsigma TPC plot"}; ConfigurableAxis ConfNsigmaTOFBins{"ConfNsigmaTOFBins", {3000, -15, 15}, "Binning of the Nsigma TOF plot"}; ConfigurableAxis ConfNsigmaTPCTOFBins{"ConfNsigmaTPCTOFBins", {3000, -15, 15}, "Binning of the Nsigma TPC+TOF plot"}; + ConfigurableAxis ConfNsigmaITSBins{"ConfNsigmaITSBins", {3000, -15, 15}, "Binning of the Nsigma ITS plot"}; ConfigurableAxis ConfTPCclustersBins{"ConfTPCClustersBins", {163, -0.5, 162.5}, "Binning of TPC found clusters plot"}; Configurable ConfTempFitVarMomentum{"ConfTempFitVarMomentum", 0, "Momentum used for binning: 0 -> pt; 1 -> preco; 2 -> ptpc"}; ConfigurableAxis ConfDummy{"ConfDummy", {1, 0, 1}, "Dummy axis for inv mass"}; @@ -101,7 +102,7 @@ struct femtoDreamDebugTrack { void init(InitContext&) { eventHisto.init(&qaRegistry, ConfIsMC); - trackHisto.init(&qaRegistry, ConfBinmult, ConfBinmultPercentile, ConfBinpT, ConfBineta, ConfBinphi, ConfTempFitVarBins, ConfNsigmaTPCBins, ConfNsigmaTOFBins, ConfNsigmaTPCTOFBins, ConfTPCclustersBins, ConfDummy, ConfIsMC, ConfTrk1_PDGCode.value, true, ConfOptCorrelatedPlots); + trackHisto.init(&qaRegistry, ConfBinmult, ConfBinmultPercentile, ConfBinpT, ConfBineta, ConfBinphi, ConfTempFitVarBins, ConfNsigmaTPCBins, ConfNsigmaTOFBins, ConfNsigmaTPCTOFBins, ConfNsigmaITSBins, ConfDummy, ConfDummy, ConfIsMC, ConfTrk1_PDGCode.value, true, ConfOptCorrelatedPlots); } /// Porduce QA plots for sigle track selection in FemtoDream framework diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamDebugV0.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamDebugV0.cxx index 9f422751008..91010d4368e 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamDebugV0.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamDebugV0.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -16,6 +16,9 @@ #include #include #include + +#include "TVector3.h" + #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" @@ -55,6 +58,7 @@ struct femtoDreamDebugV0 { ConfigurableAxis ConfV0ChildNsigmaTPCBins{"ConfV0ChildNsigmaTPCBins", {1600, -8, 8}, "binning of Nsigma TPC plot"}; ConfigurableAxis ConfV0ChildNsigmaTOFBins{"ConfV0ChildNsigmaTOFBins", {3000, -15, 15}, "binning of the Nsigma TOF plot"}; ConfigurableAxis ConfV0ChildNsigmaTPCTOFBins{"ConfV0ChildNsigmaTPCTOFBins", {1000, 0, 10}, "binning of the Nsigma TPC+TOF plot"}; + ConfigurableAxis ConfV0ChildNsigmaITSBins{"ConfV0ChildNsigmaITSBins", {600, -3, 3}, "binning of the Nsigma ITS plot"}; Configurable ConfV01_ChildPos_CutBit{"ConfV01_ChildPos_CutBit", 150, "Positive Child of V0 - Selection bit from cutCulator"}; Configurable ConfV01_ChildPos_TPCBit{"ConfV01_ChildPos_TPCBit", 4, "Positive Child of V0 - PID bit from cutCulator"}; @@ -80,9 +84,10 @@ struct femtoDreamDebugV0 { void init(InitContext&) { eventHisto.init(&EventRegistry, false); - posChildHistos.init(&V0Registry, ConfBinmult, ConfDummy, ConfV0ChildTempFitVarMomentumBins, ConfDummy, ConfDummy, ConfChildTempFitVarBins, ConfV0ChildNsigmaTPCBins, ConfV0ChildNsigmaTOFBins, ConfV0ChildNsigmaTPCTOFBins, ConfDummy, ConfV0InvMassBins, false, ConfV01_ChildPos_PDGCode.value, true); - negChildHistos.init(&V0Registry, ConfBinmult, ConfDummy, ConfV0ChildTempFitVarMomentumBins, ConfDummy, ConfDummy, ConfChildTempFitVarBins, ConfV0ChildNsigmaTPCBins, ConfV0ChildNsigmaTOFBins, ConfV0ChildNsigmaTPCTOFBins, ConfDummy, ConfV0InvMassBins, false, ConfV01_ChildNeg_PDGCode, true); - V0Histos.init(&V0Registry, ConfBinmult, ConfDummy, ConfV0TempFitVarMomentumBins, ConfDummy, ConfDummy, ConfV0TempFitVarBins, ConfV0ChildNsigmaTPCBins, ConfV0ChildNsigmaTOFBins, ConfV0ChildNsigmaTPCTOFBins, ConfDummy, ConfV0InvMassBins, false, ConfV01_PDGCode.value, true); + posChildHistos.init(&V0Registry, ConfBinmult, ConfDummy, ConfV0ChildTempFitVarMomentumBins, ConfDummy, ConfDummy, ConfChildTempFitVarBins, ConfV0ChildNsigmaTPCBins, ConfV0ChildNsigmaTOFBins, ConfV0ChildNsigmaTPCTOFBins, ConfV0ChildNsigmaITSBins, ConfV0InvMassBins, ConfDummy, false, ConfV01_ChildPos_PDGCode.value, true); + negChildHistos.init(&V0Registry, ConfBinmult, ConfDummy, ConfV0ChildTempFitVarMomentumBins, ConfDummy, ConfDummy, ConfChildTempFitVarBins, ConfV0ChildNsigmaTPCBins, ConfV0ChildNsigmaTOFBins, ConfV0ChildNsigmaTPCTOFBins, ConfV0ChildNsigmaITSBins, ConfV0InvMassBins, ConfDummy, false, ConfV01_ChildNeg_PDGCode, true); + V0Histos.init(&V0Registry, ConfBinmult, ConfDummy, ConfV0TempFitVarMomentumBins, ConfDummy, ConfDummy, ConfV0TempFitVarBins, ConfV0ChildNsigmaTPCBins, ConfV0ChildNsigmaTOFBins, ConfV0ChildNsigmaTPCTOFBins, ConfV0ChildNsigmaITSBins, ConfV0InvMassBins, ConfDummy, false, ConfV01_PDGCode.value, true); + V0Registry.add("hArmenterosPodolanski/hArmenterosPodolanskiPlot", "; #alpha; p_{T} (MeV/#it{c})", kTH2F, {{100, -1, 1}, {500, -0.3, 2}}); } /// Porduce QA plots for V0 selection in FemtoDream framework @@ -111,6 +116,20 @@ struct femtoDreamDebugV0 { negChild.partType() == uint8_t(aod::femtodreamparticle::ParticleType::kV0Child) && (negChild.cut() & ConfV01_ChildNeg_CutBit) == ConfV01_ChildNeg_CutBit && (negChild.pidcut() & ConfV01_ChildNeg_TPCBit) == ConfV01_ChildNeg_TPCBit) { + + TVector3 p_parent(part.px(), part.py(), part.pz()); // Parent momentum (px, py, pz) + TVector3 p_plus(posChild.px(), posChild.py(), posChild.pz()); // Daughter 1 momentum (px, py, pz) + TVector3 p_minus(negChild.px(), negChild.py(), negChild.pz()); // Daughter 2 momentum (px, py, pz) + + double pL_plus = p_plus.Dot(p_parent) / p_parent.Mag(); + double pL_minus = p_minus.Dot(p_parent) / p_parent.Mag(); + float alpha = (pL_plus - pL_minus) / (pL_plus + pL_minus); + + TVector3 p_perp = p_plus - (p_parent * (pL_plus / p_parent.Mag())); + double qtarm = p_perp.Mag(); + + V0Registry.fill(HIST("hArmenterosPodolanski/hArmenterosPodolanskiPlot"), alpha, qtarm); + V0Histos.fillQA(part, static_cast(ConfV0TempFitVarMomentum.value), col.multNtr(), col.multV0M()); posChildHistos.fillQA(posChild, static_cast(ConfV0TempFitVarMomentum.value), col.multNtr(), col.multV0M()); negChildHistos.fillQA(negChild, static_cast(ConfV0TempFitVarMomentum.value), col.multNtr(), col.multV0M()); diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamHashTask.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamHashTask.cxx index 78fe8c1cce4..fe0aa6c0e3d 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamHashTask.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamHashTask.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamPairEfficiency.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamPairEfficiency.cxx new file mode 100644 index 00000000000..613bc1989be --- /dev/null +++ b/PWGCF/FemtoDream/Tasks/femtoDreamPairEfficiency.cxx @@ -0,0 +1,623 @@ +// Copyright 2019-2025 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. + +/// \file femtoDreamPairEfficiency.cxx +/// \brief Task to produce dNdeta for pair triggered events +/// \author Anton Riedel, TU München, anton.riedel@cern.ch +/// heaviyly inspiered by phik0shortanalysis.cxx + +#include "PWGCF/FemtoDream/Core/femtoDreamMath.h" +#include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" +#include "PWGLF/DataModel/mcCentrality.h" +#include "PWGLF/Utils/inelGt.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "TPDGCode.h" + +#include "fairlogger/Logger.h" + +#include +#include +#include + +using namespace o2; +using namespace o2::analysis; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod; +using namespace o2::aod::track; + +struct FemtoDreamPairEfficiency { + + using Collisions = soa::Join; + using RecoCollisions = soa::Join; + using GenCollisions = soa::Join; + + // Defining the type of the tracks for data and MC + using FullTracks = soa::Join; + using FullMCTracks = soa::Join; + // filter for tracks + static constexpr TrackSelectionFlags::flagtype TrackSelectionITS = TrackSelectionFlags::kITSNCls | TrackSelectionFlags::kITSChi2NDF | TrackSelectionFlags::kITSHits; + static constexpr TrackSelectionFlags::flagtype TrackSelectionTPC = TrackSelectionFlags::kTPCNCls | TrackSelectionFlags::kTPCCrossedRowsOverNCls | TrackSelectionFlags::kTPCChi2NDF; + static constexpr TrackSelectionFlags::flagtype TrackSelectionDCA = TrackSelectionFlags::kDCAz | TrackSelectionFlags::kDCAxy; + + Filter trackFilter = ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) && + ncheckbit(aod::track::trackCutFlag, TrackSelectionITS) && + ifnode(ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC), ncheckbit(aod::track::trackCutFlag, TrackSelectionTPC), true) && + ncheckbit(aod::track::trackCutFlag, TrackSelectionDCA) && + ncheckbit(aod::track::trackCutFlag, TrackSelectionFlags::kInAcceptanceTracks); + + using FilteredFullTracks = soa::Filtered; + using FilteredFullMCTracks = soa::Filtered; + + Service pdgDB; + + SliceCache cache; + Preslice perColMc = mcparticle::mcCollisionId; + + // Event Selections + struct : ConfigurableGroup { + std::string prefix = std::string("EventSelection"); + Configurable zvtxAbsMax{"zvtxAbsMax", 10.f, "|z-Vertex| max"}; + Configurable offlineCheck{"offlineCheck", true, "Check for Sel8"}; + Configurable etaAbsMax{"etaAbsMax", 0.8f, "Common eta cut for particles in dNdEta distribution"}; + Configurable kstarMax{"kstarMax", 999.f, "Cut on kstar"}; + } eventSelection; + + struct : ConfigurableGroup { + std::string prefix = std::string("EventBinning"); + ConfigurableAxis zvtxBinning{"zvtxBinning", {240, -12, 12}, "z-vertex Binning"}; + ConfigurableAxis centBinning{"centBinning", {120, 0, 120}, "Centrality Binning"}; + ConfigurableAxis multBinning{"multBinning", {300, 0, 300}, "Multiplicity Binning"}; + ConfigurableAxis dNdetaBinning{"dNdetaBinning", {200, -1, 1}, "dNdeta Binning"}; + ConfigurableAxis kstarBinning{"kstarBinning", {200, 0, 2}, "dNdeta Binning"}; + ConfigurableAxis pairBinning{"pairBinning", {50, 0, 50}, "pair Binning"}; + } eventBinning; + + // Track 1 selections + struct : ConfigurableGroup { + std::string prefix = std::string("SelectionTrack1"); + Configurable sign{"sign", 1, "Sign of charge"}; + Configurable ptMin{"ptMin", 0.0f, "pt min"}; + Configurable ptMax{"ptMax", 3.0f, "pt max"}; + Configurable etaAbsMax{"etaAbsMax", 0.8f, "|eta| max"}; + Configurable dcazAbsMax{"dcazAbsMax", 0.1f, "|dca_z| max"}; + Configurable useDcaxyPtDepCut{"useDcaxyPtDepCut", true, "|dca_z| max"}; + Configurable tpcClusterMin{"tpcClusterMin", 80.f, "TPC clusters min"}; + Configurable tpcCrossedOverClusterMin{"tpcCrossedOverClusterMin", 0.83f, "TPC clusters/TPC crossed rows min"}; + Configurable tpcCrossedMin{"tpcCrossedMin", 70.f, "TPC crossed rows min"}; + Configurable tpcSharedMax{"tpcSharedMax", 160.f, "TPC shared clusters max"}; + Configurable itsClusterMin{"itsClusterMin", 0.f, "ITS clusters min"}; + Configurable itsIbClusterMin{"itsIbClusterMin", 0.f, "ITS inner barrle min"}; + Configurable pdgCode{"pdgCode", 2212, "PDG code"}; + Configurable pidThreshold{"pidThreshold", 0.75f, "Momentum threshold for PID"}; + Configurable itsNsigmaMax{"itsNsigmaMax", 99.f, "its nsigma max"}; + Configurable tpcNsigmaMax{"tpcNsigmaMax", 3.f, "TPC nsigma max"}; + Configurable tpctofNsigmaMax{"tpctofNsigmaMax", 3.f, "TPCTOC nsigma max"}; + } trackCuts1; + + // Track 2 selections + struct : ConfigurableGroup { + std::string prefix = std::string("SelectionTrack2"); + Configurable sign{"sign", 1, "Sign of charge"}; + Configurable ptMin{"ptMin", 0.0f, "pt min"}; + Configurable ptMax{"ptMax", 3.0f, "pt max"}; + Configurable etaAbsMax{"etaAbsMax", 0.8f, "|eta| max"}; + Configurable dcazAbsMax{"dcazAbsMax", 0.1f, "|dca_z| max"}; + Configurable useDcaxyPtDepCut{"useDcaxyPtDepCut", true, "|dca_z| max"}; + Configurable tpcClusterMin{"tpcClusterMin", 80.f, "TPC clusters min"}; + Configurable tpcCrossedOverClusterMin{"tpcCrossedOverClusterMin", 0.83f, "TPC clusters/TPC crossed rows min"}; + Configurable tpcCrossedMin{"tpcCrossedMin", 70.f, "TPC crossed rows min"}; + Configurable tpcSharedMax{"tpcSharedMax", 160.f, "TPC shared clusters max"}; + Configurable itsClusterMin{"itsClusterMin", 0.f, "ITS clusters min"}; + Configurable itsIbClusterMin{"itsIbClusterMin", 0.f, "ITS inner barrle min"}; + Configurable pdgCode{"pdgCode", 2212, "PDG code"}; + Configurable pidThreshold{"pidThreshold", 0.75f, "Momentum threshold for PID"}; + Configurable itsNsigmaMax{"itsNsigmaMax", 99.f, "its nsigma max"}; + Configurable tpcNsigmaMax{"tpcNsigmaMax", 3.f, "TPC nsigma max"}; + Configurable tpctofNsigmaMax{"tpctofNsigmaMax", 3.f, "TPCTOC nsigma max"}; + } trackCuts2; + + HistogramRegistry dataEventHist{"dataEventHist", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry mcEventHist{"mcEventHist", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + + HistogramRegistry dataTrackHist{"dataTrackHist", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + + void init(InitContext&) + { + dataEventHist.add("hDataEventSelection", "hDataEventSelection", kTH1F, {{6, -0.5f, 5.5f}}); + dataEventHist.get(HIST("hDataEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + dataEventHist.get(HIST("hDataEventSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); + dataEventHist.get(HIST("hDataEventSelection"))->GetXaxis()->SetBinLabel(3, "posZ cut"); + dataEventHist.get(HIST("hDataEventSelection"))->GetXaxis()->SetBinLabel(4, "INEL>0 cut"); + dataEventHist.get(HIST("hDataEventSelection"))->GetXaxis()->SetBinLabel(5, "With at least a pair"); + dataEventHist.get(HIST("hDataEventSelection"))->GetXaxis()->SetBinLabel(6, "With at least a lowkstar pair"); + + // Event information + dataEventHist.add("hDataVertexZ", "hVertexZ", kTH1F, {eventBinning.zvtxBinning}); + dataEventHist.add("hDataMultiplicity", "hMultiplicity", kTH1F, {eventBinning.multBinning}); + dataEventHist.add("hDataCentrality", "Centrality", kTH1F, {eventBinning.centBinning}); + + // Eta distribution for dN/deta values estimation in Data + dataEventHist.add("hDataCentralityVsEtaDistribtion", "Eta vs multiplicity in Data", kTH2F, {eventBinning.centBinning, eventBinning.dNdetaBinning}); + + dataTrackHist.add("Track1/pt", "Track 1 pt", kTH1F, {{600, 0, 6}}); + dataTrackHist.add("Track1/eta", "Track 1 eta", kTH1F, {{200, -1, 1}}); + dataTrackHist.add("Track1/phi", "Track 1 phi", kTH1F, {{720, 0, o2::constants::math::TwoPI}}); + dataTrackHist.add("Track1/tpcCluster", "Track 1 cluster", kTH1F, {{160, 0, 160}}); + dataTrackHist.add("Track1/tpcCrossed", "Track 1 crossed rows", kTH1F, {{160, 0, 160}}); + dataTrackHist.add("Track1/tpcShared", "Track 1 cluster shared", kTH1F, {{160, 0, 160}}); + dataTrackHist.add("Track1/itsCluster", "Track 1 its cluster", kTH1F, {{7, 0, 7}}); + dataTrackHist.add("Track1/itsIbCluster", "Track 1 its cluster inner barrel", kTH1F, {{3, 0, 3}}); + dataTrackHist.add("Track1/itsNsigma", "Track 1 nsigma its", kTH2F, {{600, 0, 6}, {1000, -5, 5}}); + dataTrackHist.add("Track1/tpcNsigma", "Track 1 nsigma tpc", kTH2F, {{600, 0, 6}, {1000, -5, 5}}); + dataTrackHist.add("Track1/tpctofNsigma", "Track 1 nsigma tpctof", kTH2F, {{600, 0, 6}, {500, 0, 5}}); + + dataTrackHist.add("Track2/pt", "Track 2 pt", kTH1F, {{600, 0, 6}}); + dataTrackHist.add("Track2/eta", "Track 2 eta", kTH1F, {{200, -1, 1}}); + dataTrackHist.add("Track2/phi", "Track 2 phi", kTH1F, {{720, 0, o2::constants::math::TwoPI}}); + dataTrackHist.add("Track2/tpcCluster", "Track 2 cluster", kTH1F, {{160, 0, 160}}); + dataTrackHist.add("Track2/tpcCrossed", "Track 2 crossed rows", kTH1F, {{160, 0, 160}}); + dataTrackHist.add("Track2/tpcShared", "Track 2 cluster shared", kTH1F, {{160, 0, 160}}); + dataTrackHist.add("Track2/itsCluster", "Track 2 its cluster", kTH1F, {{0, 0, 7}}); + dataTrackHist.add("Track2/itsIbCluster", "Track 2 its cluster inner barrel", kTH1F, {{3, 0, 3}}); + dataTrackHist.add("Track2/itsNsigma", "Track 2 nsigma its", kTH2F, {{600, 0, 6}, {1000, -5, 5}}); + dataTrackHist.add("Track2/tpcNsigma", "Track 2 nsigma tpc", kTH2F, {{600, 0, 6}, {1000, -5, 5}}); + dataTrackHist.add("Track2/tpctofNsigma", "Track 2 nsigma tpctof", kTH2F, {{600, 0, 6}, {500, 0, 5}}); + + mcEventHist.add("hRecoEventSelection", "hRecoEventSelection", kTH1F, {{7, -0.5f, 6.5f}}); + mcEventHist.get(HIST("hRecoEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + mcEventHist.get(HIST("hRecoEventSelection"))->GetXaxis()->SetBinLabel(2, "Sel8 cut"); + mcEventHist.get(HIST("hRecoEventSelection"))->GetXaxis()->SetBinLabel(3, "posZ cut"); + mcEventHist.get(HIST("hRecoEventSelection"))->GetXaxis()->SetBinLabel(4, "INEL>0 cut"); + mcEventHist.get(HIST("hRecoEventSelection"))->GetXaxis()->SetBinLabel(5, "With at least a gen coll"); + mcEventHist.get(HIST("hRecoEventSelection"))->GetXaxis()->SetBinLabel(6, "With at least a pair"); + mcEventHist.get(HIST("hRecoEventSelection"))->GetXaxis()->SetBinLabel(7, "With at least a lowkstar pair"); + + mcEventHist.add("hGenEventSelection", "hGenEventSelection", kTH1F, {{6, -0.5f, 5.5f}}); + mcEventHist.get(HIST("hGenEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + mcEventHist.get(HIST("hGenEventSelection"))->GetXaxis()->SetBinLabel(2, "posZ cut"); + mcEventHist.get(HIST("hGenEventSelection"))->GetXaxis()->SetBinLabel(3, "INEL>0 cut"); + mcEventHist.get(HIST("hGenEventSelection"))->GetXaxis()->SetBinLabel(4, "With at least a pair"); + mcEventHist.get(HIST("hGenEventSelection"))->GetXaxis()->SetBinLabel(5, "With at least a lowkstar pair"); + mcEventHist.get(HIST("hGenEventSelection"))->GetXaxis()->SetBinLabel(6, "With at least a reco coll"); + + // MC Event information for Rec and Gen + mcEventHist.add("hRecoMcVertexZ", "McVertexZ of reconstructed collision", kTH1F, {eventBinning.zvtxBinning}); + mcEventHist.add("hRecoMcMultiplicity", "McMultiplicity of reconstructed collision", kTH1F, {eventBinning.multBinning}); + mcEventHist.add("hRecoMcCentrality", "McCentrality of reconstructed collision", kTH1F, {eventBinning.centBinning}); + mcEventHist.add("hRecoMcKstar", "Mck* in reconstructed collision", kTH1F, {eventBinning.kstarBinning}); + mcEventHist.add("hRecoMcNumberOfPair", "McNumber of pairs in reconstructed collision", kTH1F, {eventBinning.pairBinning}); + + mcEventHist.add("hRecoMcCentralityVsEtaDistribution", "McCentrality vs Eta in Reco", kTH2F, {eventBinning.centBinning, eventBinning.dNdetaBinning}); + mcEventHist.add("hRecoMcCentralityVsMcEtaDistribution", "McCentrality vs McEta in Reco (Check)", kTH2F, {eventBinning.centBinning, eventBinning.dNdetaBinning}); + + mcEventHist.add("hGenMcVertexZ", "McVertex of generated collision", kTH1F, {eventBinning.zvtxBinning}); + mcEventHist.add("hGenMcMultiplicity", "McMultiplicity fo generated collision", kTH1F, {eventBinning.multBinning}); + mcEventHist.add("hGenMcCentrality", "McCentrality of generated collision", kTH1F, {eventBinning.centBinning}); + mcEventHist.add("hGenMcKstar", "Mckk* of generated collision", kTH1F, {eventBinning.kstarBinning}); + mcEventHist.add("hGenMcNumberOfPair", "McNumber of pairs in generated collision", kTH1F, {eventBinning.pairBinning}); + + mcEventHist.add("hGenMcCentralityWithAllAssoc", "McCentrality in all associated collision", kTH1F, {eventBinning.centBinning}); + mcEventHist.add("hGenMcCentralityWithAssoc", "McCentrality in associated collision", kTH1F, {eventBinning.centBinning}); + mcEventHist.add("hGenMcCentralityVsMcEtaDistribution", "McCentrality vs McdNdEta in generated collision", kTH2F, {eventBinning.centBinning, eventBinning.dNdetaBinning}); + mcEventHist.add("hGenMcCentralityVsMcEtaDistributionWithAllAssoc", "McCentrality vs McdNdEta in all associated collisions", kTH2F, {eventBinning.centBinning, eventBinning.dNdetaBinning}); + mcEventHist.add("hGenMcCentralityVsMcEtaDistributionWithAssoc", "McCentrality vs McdNdEta in associated collisions", kTH2F, {eventBinning.centBinning, eventBinning.dNdetaBinning}); + } + + int pairsFound = 0; + std::vector vecKstar{}; + + template + bool checkRecoTrackSelections(const T1& track, const T2& sel) + { + if (track.sign() != sel.sign.value) { + return false; + } + if (track.pt() < sel.ptMin.value || track.pt() > sel.ptMax.value) { + return false; + } + if (std::fabs(track.eta()) > sel.etaAbsMax.value) { + return false; + } + if (sel.useDcaxyPtDepCut.value && std::fabs(track.dcaXY()) > (0.0105 + (0.035 / std::powf(track.pt(), 1.1f)))) { + return false; + } + if (std::fabs(track.dcaZ()) > sel.dcazAbsMax.value) { + return false; + } + if (track.tpcNClsFound() < sel.tpcClusterMin.value) { + return false; + } + if (track.tpcNClsCrossedRows() < sel.tpcCrossedMin.value) { + return false; + } + if (track.tpcNClsShared() > sel.tpcSharedMax.value) { + return false; + } + if (track.itsNCls() < sel.itsClusterMin.value) { + return false; + } + if (track.itsNClsInnerBarrel() < sel.itsIbClusterMin.value) { + return false; + } + return true; + } + + template + std::array getNSigmaValues(const T& track, int pdgCode) + { + std::array nsigma; + switch (std::abs(pdgCode)) { + case kPiPlus: + nsigma[0] = track.itsNSigmaPi(); + nsigma[1] = track.tpcNSigmaPi(); + nsigma[2] = track.tofNSigmaPi(); + break; + case kKPlus: + nsigma[0] = track.itsNSigmaKa(); + nsigma[1] = track.tpcNSigmaKa(); + nsigma[2] = track.tofNSigmaKa(); + break; + case kProton: + nsigma[0] = track.itsNSigmaPr(); + nsigma[1] = track.tpcNSigmaPr(); + nsigma[2] = track.tofNSigmaPr(); + break; + case constants::physics::kDeuteron: + nsigma[0] = track.itsNSigmaDe(); + nsigma[1] = track.tpcNSigmaDe(); + nsigma[2] = track.tofNSigmaDe(); + break; + default: + LOG(fatal) << "PDG code " << pdgCode << " is not supported"; + } + return nsigma; + } + + template + bool checkRecoTrackPidSelections(const T1& track, const T2& sel) + { + auto nsigma = getNSigmaValues(track, sel.pdgCode.value); + if (track.p() < sel.pidThreshold.value) { + if (std::fabs(nsigma[1]) > sel.tpcNsigmaMax.value || std::fabs(nsigma[0]) > sel.itsNsigmaMax.value) { + return false; + } + } else { + if (std::hypot(nsigma[1], nsigma[2]) > sel.tpctofNsigmaMax.value) { + return false; + } + } + return true; + } + + template + bool checkEventSelections(const T& col, bool qa) + { + if constexpr (!isMc) { + if (qa) { + dataEventHist.fill(HIST("hDataEventSelection"), 0); // all collisins + } + if (!col.sel8()) { + return false; + } + if (qa) { + dataEventHist.fill(HIST("hDataEventSelection"), 1); // sel8 collisions + } + if (std::fabs(col.posZ()) > eventSelection.zvtxAbsMax.value) { + return false; + } + if (qa) { + dataEventHist.fill(HIST("hDataEventSelection"), 2); // vertex-Z selected + } + if (!col.isInelGt0()) { + return false; + } + if (qa) { + dataEventHist.fill(HIST("hDataEventSelection"), 3); // INEL>0 collisions + } + } else { + if (qa) { + mcEventHist.fill(HIST("hRecoEventSelection"), 0); // all collisions + } + if (!col.sel8()) { + return false; + } + if (qa) { + mcEventHist.fill(HIST("hRecoEventSelection"), 1); // sel8 collisions + } + if (std::fabs(col.posZ()) > eventSelection.zvtxAbsMax.value) { + return false; + } + if (qa) { + mcEventHist.fill(HIST("hRecoEventSelection"), 2); // vertex-Z selected + } + if (!col.isInelGt0()) { + return false; + } + if (qa) { + mcEventHist.fill(HIST("hRecoEventSelection"), 3); // INEL>0 collisions + } + } + return true; + } + + template + int countRecoPairs(const T& tracks) + { + int pairs = 0; + for (auto track1 = tracks.begin(); track1 != tracks.end(); track1++) { + if (!checkRecoTrackSelections(track1, trackCuts1) || !checkRecoTrackPidSelections(track1, trackCuts1)) { + continue; + } + for (auto track2 = track1 + 1; track2 != tracks.end(); track2++) { + if (!checkRecoTrackSelections(track2, trackCuts2) || !checkRecoTrackPidSelections(track2, trackCuts2)) { + continue; + } + + auto nsigma1 = getNSigmaValues(track1, trackCuts1.pdgCode.value); + dataTrackHist.fill(HIST("Track1/pt"), track1.pt()); + dataTrackHist.fill(HIST("Track1/eta"), track1.eta()); + dataTrackHist.fill(HIST("Track1/phi"), track1.phi()); + dataTrackHist.fill(HIST("Track1/tpcCluster"), track1.tpcNClsFound()); + dataTrackHist.fill(HIST("Track1/tpcCrossed"), track1.tpcNClsCrossedRows()); + dataTrackHist.fill(HIST("Track1/tpcShared"), track1.tpcNClsShared()); + dataTrackHist.fill(HIST("Track1/itsCluster"), track1.itsNCls()); + dataTrackHist.fill(HIST("Track1/itsIbCluster"), track1.itsNClsInnerBarrel()); + dataTrackHist.fill(HIST("Track1/itsNsigma"), track1.p(), nsigma1[0]); + dataTrackHist.fill(HIST("Track1/tpcNsigma"), track1.p(), nsigma1[1]); + dataTrackHist.fill(HIST("Track1/tpctofNsigma"), track1.p(), std::hypot(nsigma1[1], nsigma1[2])); + + auto nsigma2 = getNSigmaValues(track2, trackCuts2.pdgCode.value); + dataTrackHist.fill(HIST("Track2/pt"), track2.pt()); + dataTrackHist.fill(HIST("Track2/eta"), track2.eta()); + dataTrackHist.fill(HIST("Track2/phi"), track2.phi()); + dataTrackHist.fill(HIST("Track2/tpcCluster"), track2.tpcNClsFound()); + dataTrackHist.fill(HIST("Track2/tpcCrossed"), track2.tpcNClsCrossedRows()); + dataTrackHist.fill(HIST("Track2/tpcShared"), track2.tpcNClsShared()); + dataTrackHist.fill(HIST("Track2/itsCluster"), track2.itsNCls()); + dataTrackHist.fill(HIST("Track2/itsIbCluster"), track2.itsNClsInnerBarrel()); + dataTrackHist.fill(HIST("Track2/itsNsigma"), track2.p(), nsigma2[0]); + dataTrackHist.fill(HIST("Track2/tpcNsigma"), track2.p(), nsigma2[1]); + dataTrackHist.fill(HIST("Track2/tpctofNsigma"), track1.p(), std::hypot(nsigma2[1], nsigma2[2])); + + pairs++; + + vecKstar.push_back(femtoDream::FemtoDreamMath::getkstar(track1, femtoDream::getMass(trackCuts1.pdgCode.value), track2, femtoDream::getMass(trackCuts2.pdgCode.value))); + } + } + return pairs; + } + + template + int countGenPairs(const T& tracks) + { + int pairs = 0; + for (auto track1 = tracks.begin(); track1 != tracks.end(); track1++) { + if (!track1.isPhysicalPrimary() || + track1.pdgCode() != trackCuts1.pdgCode.value || + track1.pt() < trackCuts1.ptMin.value || + track1.pt() > trackCuts1.ptMax.value || + std::fabs(track1.eta()) > trackCuts1.etaAbsMax.value) { + continue; + } + for (auto track2 = track1 + 1; track2 != tracks.end(); track2++) { + if (!track2.isPhysicalPrimary() || + track2.pdgCode() != trackCuts2.pdgCode.value || + track2.pt() < trackCuts2.ptMin.value || + track2.pt() > trackCuts2.ptMax.value || + std::fabs(track2.eta()) > trackCuts2.etaAbsMax.value) { + continue; + } + vecKstar.push_back(femtoDream::FemtoDreamMath::getkstar(track1, femtoDream::getMass(trackCuts1.pdgCode.value), track2, femtoDream::getMass(trackCuts2.pdgCode.value))); + pairs++; + } + } + return pairs; + } + + void processdNdetaData(Collisions::iterator const& collision, FilteredFullTracks const& tracks) + { + if (!checkEventSelections(collision, true)) + return; + + auto tracksWithItsPid = soa::Attach(tracks); + + vecKstar.clear(); + pairsFound = countRecoPairs(tracksWithItsPid); + + if (pairsFound == 0) { + return; + } + dataEventHist.fill(HIST("hDataEventSelection"), 4); // found a pair + + if (*std::min_element(vecKstar.begin(), vecKstar.end()) > eventSelection.kstarMax) { + return; + } + + dataEventHist.fill(HIST("hDataEventSelection"), 5); // found a lowkstar pair + + float centrality = collision.centFT0M(); + + dataEventHist.fill(HIST("hDataVertexZ"), collision.posZ()); + dataEventHist.fill(HIST("hDataMultiplicity"), collision.multNTracksPV()); + dataEventHist.fill(HIST("hDataCentrality"), centrality); + + for (const auto& track : tracks) + dataEventHist.fill(HIST("hDataCentralityVsEtaDistribtion"), centrality, track.eta()); + } + + PROCESS_SWITCH(FemtoDreamPairEfficiency, processdNdetaData, "Process function for dN/deta values in MCReco", true); + + void processdNdetaMCReco(RecoCollisions::iterator const& collision, FilteredFullMCTracks const& McTracks, GenCollisions const&, McParticles const& mcParticles) + { + if (!checkEventSelections(collision, true)) { + return; + } + if (!collision.has_mcCollision()) { + return; + } + mcEventHist.fill(HIST("hRecoEventSelection"), 4); + + const auto& mcCollision = collision.mcCollision_as(); + auto mcParticlesThisColl = mcParticles.sliceByCached(mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + + vecKstar.clear(); + pairsFound = countGenPairs(mcParticlesThisColl); + + if (pairsFound == 0) { + return; + } + mcEventHist.fill(HIST("hRecoEventSelection"), 5); + + if (*std::min_element(vecKstar.begin(), vecKstar.end()) > eventSelection.kstarMax) { + return; + } + mcEventHist.fill(HIST("hRecoEventSelection"), 6); + + float genCentrality = mcCollision.centFT0M(); + + mcEventHist.fill(HIST("hRecoMcVertexZ"), mcCollision.posZ()); + mcEventHist.fill(HIST("hRecoMcMultiplicity"), mcCollision.multMCNParticlesEta08()); + mcEventHist.fill(HIST("hRecoMcCentrality"), mcCollision.centFT0M()); + mcEventHist.fill(HIST("hRecoMcNumberOfPair"), vecKstar.size()); + for (const auto& kstar : vecKstar) { + mcEventHist.fill(HIST("hRecoMcKstar"), kstar); + } + + for (const auto& track : McTracks) { + if (!track.has_mcParticle()) + continue; + auto mcTrack = track.mcParticle_as(); + if (!mcTrack.isPhysicalPrimary() || std::fabs(mcTrack.eta()) > eventSelection.etaAbsMax.value) + continue; + + mcEventHist.fill(HIST("hRecoMcCentralityVsEtaDistribution"), genCentrality, mcTrack.eta()); + } + + for (const auto& mcParticle : mcParticlesThisColl) { + if (!mcParticle.isPhysicalPrimary() || std::fabs(mcParticle.eta()) > eventSelection.etaAbsMax.value) { + continue; + } + auto pdgTrack = pdgDB->GetParticle(mcParticle.pdgCode()); + if (pdgTrack == nullptr) { + continue; + } + if (pdgTrack->Charge() == 0) { + continue; + } + mcEventHist.fill(HIST("hRecoMcCentralityVsMcEtaDistribution"), genCentrality, mcParticle.eta()); + } + } + PROCESS_SWITCH(FemtoDreamPairEfficiency, processdNdetaMCReco, "Process function for dN/deta values in MCReco", true); + + void processdNdetaMCGen(GenCollisions::iterator const& mcCollision, soa::SmallGroups const& collisions, McParticles const& mcParticles) + { + mcEventHist.fill(HIST("hGenEventSelection"), 0); + if (std::fabs(mcCollision.posZ()) > eventSelection.zvtxAbsMax.value) { + return; + } + mcEventHist.fill(HIST("hGenEventSelection"), 1); + if (!pwglf::isINELgtNmc(mcParticles, 0, pdgDB)) { + return; + } + mcEventHist.fill(HIST("hGenEventSelection"), 2); + vecKstar.clear(); + pairsFound = countGenPairs(mcParticles); + if (pairsFound == 0) { + return; + } + mcEventHist.fill(HIST("hGenEventSelection"), 3); + if (*std::min_element(vecKstar.begin(), vecKstar.end()) > eventSelection.kstarMax) { + return; + } + mcEventHist.fill(HIST("hGenEventSelection"), 4); + + mcEventHist.fill(HIST("hGenMcVertexZ"), mcCollision.posZ()); + mcEventHist.fill(HIST("hGenMcMultiplicity"), mcCollision.multMCNParticlesEta08()); + mcEventHist.fill(HIST("hGenMcCentrality"), mcCollision.centFT0M()); + mcEventHist.fill(HIST("hGenMcNumberOfPair"), vecKstar.size()); + + for (const auto& kstar : vecKstar) { + mcEventHist.fill(HIST("hGenMcKstar"), kstar); + } + + float genCentrality = mcCollision.centFT0M(); + uint64_t numberAssocCollisions = 0; + + for (const auto& collision : collisions) { + if (checkEventSelections(collision, false)) { + mcEventHist.fill(HIST("hGenMcCentralityWithAllAssoc"), genCentrality); + for (const auto& mcParticle : mcParticles) { + if (!mcParticle.isPhysicalPrimary() || std::abs(mcParticle.eta()) > eventSelection.etaAbsMax.value) + continue; + auto pdgTrack = pdgDB->GetParticle(mcParticle.pdgCode()); + if (pdgTrack == nullptr) + continue; + if (pdgTrack->Charge() == 0) + continue; + mcEventHist.fill(HIST("hGenMcCentralityVsMcEtaDistributionWithAllAssoc"), genCentrality, mcParticle.eta()); + } + numberAssocCollisions++; + } + } + + if (numberAssocCollisions > 0) { + mcEventHist.fill(HIST("hGenMcCentralityWithAssoc"), genCentrality); + mcEventHist.fill(HIST("hGenEventSelection"), 5); + } + + for (const auto& mcParticle : mcParticles) { + if (!mcParticle.isPhysicalPrimary() || std::abs(mcParticle.eta()) > eventSelection.etaAbsMax.value) + continue; + + auto pdgTrack = pdgDB->GetParticle(mcParticle.pdgCode()); + if (pdgTrack == nullptr) { + continue; + } + if (pdgTrack->Charge() == 0) { + continue; + } + + mcEventHist.fill(HIST("hGenMcCentralityVsMcEtaDistribution"), genCentrality, mcParticle.eta()); + if (numberAssocCollisions > 0) { + mcEventHist.fill(HIST("hGenMcCentralityVsMcEtaDistributionWithAssoc"), genCentrality, mcParticle.eta()); + } + } + } + PROCESS_SWITCH(FemtoDreamPairEfficiency, processdNdetaMCGen, "Process function for dN/deta values in MCReco", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackCascade.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackCascade.cxx new file mode 100644 index 00000000000..05696761afa --- /dev/null +++ b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackCascade.cxx @@ -0,0 +1,394 @@ +// Copyright 2019-2025 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. +/// \file femtoDreamPairTaskTrackTrack.cxx +/// \brief Tasks that reads the track tables used for the pairing and builds pairs of two tracks +/// \author Andi Mathis, TU München, andreas.mathis@ph.tum.de +#include +#include +#include +#include +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/Expressions.h" +#include "PWGCF/DataModel/FemtoDerived.h" +#include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h" +#include "PWGCF/FemtoDream/Core/femtoDreamEventHisto.h" +#include "PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h" +#include "PWGCF/FemtoDream/Core/femtoDreamContainer.h" +#include "PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h" +#include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" +using namespace o2; +using namespace o2::aod; +using namespace o2::soa; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::analysis::femtoDream; +struct femtoDreamPairTaskTrackCascade { + SliceCache cache; + Preslice perCol = aod::femtodreamparticle::fdCollisionId; + /// General options + struct : ConfigurableGroup { + std::string prefix = std::string("Option"); + Configurable IsMC{"IsMC", false, "Enable additional Histogramms in the case of a MonteCarlo Run"}; + Configurable Use4D{"Use4D", false, "Enable four dimensional histogramms (to be used only for analysis with high statistics): k* vs multiplicity vs multiplicity percentil vs mT"}; + Configurable ExtendedPlots{"ExtendedPlots", false, "Enable additional three dimensional histogramms. High memory consumption. Use for debugging"}; + Configurable HighkstarCut{"HighkstarCut", -1., "Set a cut for high k*, above which the pairs are rejected. Set it to -1 to deactivate it"}; + Configurable CPROn{"CPROn", true, "Close Pair Rejection"}; + Configurable CPROld{"CPROld", false, "Set to FALSE to use fixed version of CPR (for testing now, will be default soon)"}; + Configurable CPRPlotPerRadii{"CPRPlotPerRadii", false, "Plot CPR per radii"}; + Configurable CPRdeltaPhiMax{"CPRdeltaPhiMax", 0.01, "Max. Delta Phi for Close Pair Rejection"}; + Configurable CPRdeltaEtaMax{"CPRdeltaEtaMax", 0.01, "Max. Delta Eta for Close Pair Rejection"}; + Configurable DCACutPtDep{"DCACutPtDep", false, "Use pt dependent dca cut"}; + Configurable MixEventWithPairs{"MixEventWithPairs", false, "Only use events that contain particle 1 and partile 2 for the event mixing"}; + Configurable smearingByOrigin{"smearingByOrigin", false, "Obtain the smearing matrix differential in the MC origin of particle 1 and particle 2. High memory consumption. Use with care!"}; + ConfigurableAxis Dummy{"Dummy", {1, 0, 1}, "Dummy axis"}; + } Option; + /// Event selection + struct : ConfigurableGroup { + std::string prefix = std::string("EventSel"); + Configurable MultMin{"MultMin", 0, "Minimum Multiplicity (MultNtr)"}; + Configurable MultMax{"MultMax", 99999, "Maximum Multiplicity (MultNtr)"}; + Configurable MultPercentileMin{"MultPercentileMin", 0, "Minimum Multiplicity Percentile"}; + Configurable MultPercentileMax{"MultPercentileMax", 100, "Maximum Multiplicity Percentile"}; + } EventSel; + // Filter EventMultiplicity = aod::femtodreamcollision::multNtr >= EventSel.MultMin && aod::femtodreamcollision::multNtr <= EventSel.MultMax; + // Filter EventMultiplicityPercentile = aod::femtodreamcollision::multV0M >= EventSel.MultPercentileMin && aod::femtodreamcollision::multV0M <= EventSel.MultPercentileMax; + /// Histogramming for Event + FemtoDreamEventHisto eventHisto; + // using FilteredCollisions = soa::Filtered; + using FilteredCollisions = FDCollisions; + using FilteredCollision = FilteredCollisions::iterator; + using FDMCParts = soa::Join; + using FDMCPart = FDMCParts::iterator; + femtodreamcollision::BitMaskType BitMask = 1; + /// Particle 1 (track) + struct : ConfigurableGroup { + std::string prefix = std::string("Track1"); + Configurable PDGCode{"PDGCode", 2212, "PDG code of Particle 1 (Track)"}; + Configurable CutBit{"CutBit", 5542474, "Particle 1 (Track) - Selection bit from cutCulator"}; + Configurable TPCBit{"TPCBit", 4, "PID TPC bit from cutCulator for particle 1 (Track)"}; + Configurable TPCBit_Reject{"TPCBit_Reject", 0, "Reject PID TPC bit from cutCulator for particle 1 (Track). Set to 0 to turn off"}; + Configurable TPCTOFBit{"TPCTOFBit", 2, "PID TPCTOF bit from cutCulator for particle 1 (Track)"}; + Configurable PIDThres{"PIDThres", 0.75, "Momentum threshold for PID selection for particle 1 (Track)"}; + Configurable PtMin{"PtMin", 0., "Minimum pT of partricle 1 (Track)"}; + Configurable PtMax{"PtMax", 999., "Maximum pT of partricle 1 (Track)"}; + Configurable EtaMin{"EtaMin", -10., "Minimum eta of partricle 1 (Track)"}; + Configurable EtaMax{"EtaMax", 10., "Maximum eta of partricle 1 (Track)"}; + Configurable TempFitVarMin{"TempFitVarMin", -10., "Minimum DCAxy of partricle 1 (Track)"}; + Configurable TempFitVarMax{"TempFitVarMax", 10., "Maximum DCAxy of partricle 1 (Track)"}; + } Track1; + /// Partition for particle 1 + Partition PartitionTrk1 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && + (ncheckbit(aod::femtodreamparticle::cut, Track1.CutBit)) && + ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= Track1.PIDThres, ncheckbit(aod::femtodreamparticle::pidcut, Track1.TPCBit) && ((aod::femtodreamparticle::pidcut & Track1.TPCBit_Reject) == 0u), ncheckbit(aod::femtodreamparticle::pidcut, Track1.TPCTOFBit)) && + (aod::femtodreamparticle::pt > Track1.PtMin) && + (aod::femtodreamparticle::pt < Track1.PtMax) && + (aod::femtodreamparticle::eta > Track1.EtaMin) && + (aod::femtodreamparticle::eta < Track1.EtaMax) && + ifnode(Option.DCACutPtDep, (nabs(aod::femtodreamparticle::tempFitVar) <= 0.0105f + (0.035f / npow(aod::femtodreamparticle::pt, 1.1f))), + ((aod::femtodreamparticle::tempFitVar >= Track1.TempFitVarMin) && + (aod::femtodreamparticle::tempFitVar <= Track1.TempFitVarMax))); + /// Histogramming for particle 1 + FemtoDreamParticleHisto trackHistoPartOne; + /// Particle 2 (Cascade) + struct : ConfigurableGroup { + std::string prefix = std::string("Cascade2"); + Configurable PDGCode{"PDGCode", 3312, "PDG code of particle 2 (V0)"}; + Configurable CutBit{"CutBit", 32221874, "Selection bit for particle 2 (Cascade)"}; + Configurable ChildPos_CutBit{"ChildPos_CutBit", 278, "Selection bit for positive child of Cascade"}; + Configurable ChildPos_TPCBit{"ChildPos_TPCBit", 1024, "PID TPC bit for positive child of Cascade"}; + Configurable ChildNeg_CutBit{"ChildNeg_CutBit", 277, "Selection bit for negative child of Cascade"}; + Configurable ChildNeg_TPCBit{"ChildNeg_TPCBit", 4096, "PID TPC bit for negative child of Cascade"}; + Configurable ChildBach_CutBit{"ChildBach_CutBit", 277, "Selection bit for negative child of Cascade"}; + Configurable ChildBach_TPCBit{"ChildBach_TPCBit", 64, "PID TPC bit for bachelor child of Cascade"}; + Configurable InvMassMin{"InvMassMin", 1.2, "Minimum invariant mass of Partricle 2 (particle) (Cascade)"}; + Configurable InvMassMax{"InvMassMax", 1.4, "Maximum invariant mass of Partricle 2 (particle) (Cascade)"}; + Configurable InvMassV0DaughMin{"InvMassV0DaugMin", 0., "Minimum invariant mass of the V0 Daughter"}; + Configurable InvMassV0DaughMax{"InvMassV0DaugMax", 999., "Maximum invariant mass of the V0 Daughter"}; + Configurable PtMin{"PtMin", 0., "Minimum pT of Partricle 2 (V0)"}; + Configurable PtMax{"PtMax", 999., "Maximum pT of Partricle 2 (V0)"}; + Configurable EtaMin{"EtaMin", -10., "Minimum eta of Partricle 2 (V0)"}; + Configurable EtaMax{"EtaMax", 10., "Maximum eta of Partricle 2 (V0)"}; + Configurable UseChildCuts{"UseChildCuts", true, "Use cuts on the children of the Cascades additional to those of the selection of the cascade builder (for debugging purposes)"}; + Configurable UseChildPIDCuts{"UseChildPIDCuts", true, "Use PID cuts on the children of the Cascades additional to those of the selection of the cascade builder (for debugging purposes)"}; + } Cascade2; + /// Partition for particle 2 + Partition PartitionCascade2 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kCascade)) && + ((aod::femtodreamparticle::cut & Cascade2.CutBit) == Cascade2.CutBit) && + (aod::femtodreamparticle::pt > Cascade2.PtMin) && + (aod::femtodreamparticle::pt < Cascade2.PtMax) && + (aod::femtodreamparticle::eta > Cascade2.EtaMin) && + (aod::femtodreamparticle::eta < Cascade2.EtaMax) && + (aod::femtodreamparticle::mLambda > Cascade2.InvMassMin) && + (aod::femtodreamparticle::mLambda < Cascade2.InvMassMax) && + (aod::femtodreamparticle::mAntiLambda > Cascade2.InvMassV0DaughMin) && + (aod::femtodreamparticle::mAntiLambda < Cascade2.InvMassV0DaughMax); + /// Histogramming for particle 2 + FemtoDreamParticleHisto trackHistoPartTwo; + FemtoDreamParticleHisto posChildHistos; + FemtoDreamParticleHisto negChildHistos; + FemtoDreamParticleHisto bachChildHistos; + /// Binning configurables + struct : ConfigurableGroup { + std::string prefix = std::string("Binning"); + ConfigurableAxis TempFitVarTrack{"TempFitVarTrack", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot (Track)"}; + ConfigurableAxis TempFitVarCascade{"TempFitVarCascade", {300, 0.9, 1}, "binning of the TempFitVar in the pT vs. TempFitVar plot (Cascade)"}; + ConfigurableAxis TempFitVarCascadeChild{"TempFitVarCascadeChild", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot (Cascade child)"}; + ConfigurableAxis InvMass{"InvMass", {200, 1.22, 1.42}, "InvMass binning"}; + ConfigurableAxis pTTrack{"pTTrack", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (Track)"}; + ConfigurableAxis pTCascade{"pTCascade", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (Cascade)"}; + ConfigurableAxis pTCascadeChild{"pTCascadeChild", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (Cascade)"}; + ConfigurableAxis pT{"pT", {20, 0.5, 4.05}, "pT binning"}; + ConfigurableAxis kstar{"kstar", {1500, 0., 6.}, "binning kstar"}; + ConfigurableAxis kT{"kT", {150, 0., 9.}, "binning kT"}; + ConfigurableAxis mT{"mT", {225, 0., 7.5}, "binning mT"}; + ConfigurableAxis multTempFit{"multTempFit", {1, 0, 1}, "multiplicity for the TempFitVar plot"}; + } Binning; + struct : ConfigurableGroup { + std::string prefix = std::string("Binning4D"); + ConfigurableAxis kstar{"kstar", {1500, 0., 6.}, "binning kstar for the 4Dimensional plot: k* vs multiplicity vs multiplicity percentile vs mT (set <> to true in order to use)"}; + ConfigurableAxis mT{"mT", {VARIABLE_WIDTH, 1.02f, 1.14f, 1.20f, 1.26f, 1.38f, 1.56f, 1.86f, 4.50f}, "mT Binning for the 4Dimensional plot: k* vs multiplicity vs multiplicity percentile vs mT (set <> to true in order to use)"}; + ConfigurableAxis Mult{"mult", {VARIABLE_WIDTH, 0.0f, 4.0f, 8.0f, 12.0f, 16.0f, 20.0f, 24.0f, 28.0f, 32.0f, 36.0f, 40.0f, 44.0f, 48.0f, 52.0f, 56.0f, 60.0f, 64.0f, 68.0f, 72.0f, 76.0f, 80.0f, 84.0f, 88.0f, 92.0f, 96.0f, 100.0f, 200.0f}, "multiplicity Binning for the 4Dimensional plot: k* vs multiplicity vs multiplicity percentile vs mT (set <> to true in order to use)"}; + ConfigurableAxis multPercentile{"multPercentile", {10, 0.0f, 100.0f}, "multiplicity percentile Binning for the 4Dimensional plot: k* vs multiplicity vs multiplicity percentile vs mT (set <> to true in order to use)"}; + } Binning4D; + // Mixing configurables + struct : ConfigurableGroup { + std::string prefix = std::string("Mixing"); + ConfigurableAxis BinMult{"BinMult", {VARIABLE_WIDTH, 0.0f, 4.0f, 8.0f, 12.0f, 16.0f, 20.0f, 24.0f, 28.0f, 32.0f, 36.0f, 40.0f, 44.0f, 48.0f, 52.0f, 56.0f, 60.0f, 64.0f, 68.0f, 72.0f, 76.0f, 80.0f, 84.0f, 88.0f, 92.0f, 96.0f, 100.0f, 200.0f}, "bins - multiplicity"}; + ConfigurableAxis BinMultPercentile{"BinMultPercentile", {VARIABLE_WIDTH, 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.f}, "bins - multiplicity percentile"}; + ConfigurableAxis BinVztx{"BinVztx", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "bins - z-vertex"}; + Configurable Depth{"Depth", 5, "Number of events for mixing"}; + Configurable Policy{"BinPolicy", 0, "Binning policy for mixing - 0: multiplicity, 1: multipliciy percentile, 2: both"}; + } Mixing; + ColumnBinningPolicy colBinningMult{{Mixing.BinVztx, Mixing.BinMult}, true}; + ColumnBinningPolicy colBinningMultPercentile{{Mixing.BinVztx, Mixing.BinMultPercentile}, true}; + ColumnBinningPolicy colBinningMultMultPercentile{{Mixing.BinVztx, Mixing.BinMult, Mixing.BinMultPercentile}, true}; + FemtoDreamContainer sameEventCont; + FemtoDreamContainer mixedEventCont; + FemtoDreamPairCleaner pairCleaner; + FemtoDreamDetaDphiStar pairCloseRejectionSE; + FemtoDreamDetaDphiStar pairCloseRejectionME; + + static constexpr uint32_t kSignPlusMask = 1 << 1; + + /// Histogram output + HistogramRegistry Registry{"Output", {}, OutputObjHandlingPolicy::AnalysisObject}; + void init(InitContext&) + { + // setup binnnig policy for mixing + colBinningMult = {{Mixing.BinVztx, Mixing.BinMult}, true}; + colBinningMultPercentile = {{Mixing.BinVztx, Mixing.BinMultPercentile}, true}; + colBinningMultMultPercentile = {{Mixing.BinVztx, Mixing.BinMult, Mixing.BinMultPercentile}, true}; + eventHisto.init(&Registry, Option.IsMC); + trackHistoPartOne.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTTrack, Option.Dummy, Option.Dummy, Binning.TempFitVarTrack, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.IsMC, Track1.PDGCode); + trackHistoPartTwo.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTCascade, Option.Dummy, Option.Dummy, Binning.TempFitVarCascade, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Binning.InvMass, Option.Dummy, Option.IsMC, Cascade2.PDGCode); + posChildHistos.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTCascadeChild, Option.Dummy, Option.Dummy, Binning.TempFitVarCascadeChild, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, false, 0); + negChildHistos.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTCascadeChild, Option.Dummy, Option.Dummy, Binning.TempFitVarCascadeChild, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, false, 0); + bachChildHistos.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTCascadeChild, Option.Dummy, Option.Dummy, Binning.TempFitVarCascadeChild, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, false, 0); + sameEventCont.init(&Registry, + Binning.kstar, Binning.pT, Binning.kT, Binning.mT, Mixing.BinMult, Mixing.BinMultPercentile, + Binning4D.kstar, Binning4D.mT, Binning4D.Mult, Binning4D.multPercentile, + Option.IsMC, Option.Use4D, Option.ExtendedPlots, + Option.HighkstarCut, + Option.smearingByOrigin); + + sameEventCont.setPDGCodes(Track1.PDGCode, Cascade2.PDGCode); + + mixedEventCont.init(&Registry, + Binning.kstar, Binning.pT, Binning.kT, Binning.mT, Mixing.BinMult, Mixing.BinMultPercentile, + Binning4D.kstar, Binning4D.mT, Binning4D.Mult, Binning4D.multPercentile, + Option.IsMC, Option.Use4D, Option.ExtendedPlots, + Option.HighkstarCut, + Option.smearingByOrigin); + + mixedEventCont.setPDGCodes(Track1.PDGCode, Cascade2.PDGCode); + + pairCleaner.init(&Registry); + if (Option.CPROn.value) { + pairCloseRejectionSE.init(&Registry, &Registry, Option.CPRdeltaPhiMax.value, Option.CPRdeltaEtaMax.value, Option.CPRPlotPerRadii.value, 1, Option.CPROld.value); + pairCloseRejectionME.init(&Registry, &Registry, Option.CPRdeltaPhiMax.value, Option.CPRdeltaEtaMax.value, Option.CPRPlotPerRadii.value, 2, Option.CPROld.value, 99, true); + } + } + + /// This function processes the same event and takes care of all the histogramming + template + void doSameEvent(PartitionType& SliceTrk1, PartitionType& SliceCascade2, TableTracks const& parts, Collision const& col) + { + /// Histogramming same event + for (auto const& part : SliceTrk1) { + trackHistoPartOne.fillQA(part, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); + } + for (auto& casc : SliceCascade2) { + const auto& posChild = parts.iteratorAt(casc.index() - 3); + const auto& negChild = parts.iteratorAt(casc.index() - 2); + const auto& bachChild = parts.iteratorAt(casc.index() - 1); + // This is how it is supposed to work but there seems to be an issue + // with partitions and accessing elements in tables that have been declared + // with an SELF_INDEX column. Under investigation. Maybe need to change + // femtdream dataformat to take special care of v0 candidates + // auto posChild = v0.template children_as().front(); + // auto negChild = v0.template children_as().back(); + // check cuts on V0 children + if (Cascade2.UseChildCuts) { + if (!(((posChild.cut() & Cascade2.ChildPos_CutBit) == Cascade2.ChildPos_CutBit) && + ((negChild.cut() & Cascade2.ChildNeg_CutBit) == Cascade2.ChildNeg_CutBit) && + ((bachChild.cut() & Cascade2.ChildBach_CutBit) == Cascade2.ChildBach_CutBit))) { + continue; + } + } + if (Cascade2.UseChildPIDCuts) { + if (!(((posChild.pidcut() & Cascade2.ChildPos_TPCBit) == Cascade2.ChildPos_TPCBit) && + ((negChild.pidcut() & Cascade2.ChildNeg_TPCBit) == Cascade2.ChildNeg_TPCBit) && + ((bachChild.pidcut() & Cascade2.ChildBach_TPCBit) == Cascade2.ChildBach_TPCBit))) { + continue; + } + } + trackHistoPartTwo.fillQA(casc, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); + posChildHistos.fillQA(posChild, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); + negChildHistos.fillQA(negChild, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); + bachChildHistos.fillQA(bachChild, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); + } + /// Now build particle combinations + for (auto const& [p1, p2] : combinations(CombinationsFullIndexPolicy(SliceTrk1, SliceCascade2))) { + const auto& posChild = parts.iteratorAt(p2.index() - 3); + const auto& negChild = parts.iteratorAt(p2.index() - 2); + const auto& bachChild = parts.iteratorAt(p2.index() - 1); + + // cuts on Cascade children still need to be applied + if (Cascade2.UseChildCuts) { + if (!(((posChild.cut() & Cascade2.ChildPos_CutBit) == Cascade2.ChildPos_CutBit) && + ((negChild.cut() & Cascade2.ChildNeg_CutBit) == Cascade2.ChildNeg_CutBit) && + ((bachChild.cut() & Cascade2.ChildBach_CutBit) == Cascade2.ChildBach_CutBit))) { + continue; + } + } + if (Cascade2.UseChildPIDCuts) { + if (!(((posChild.pidcut() & Cascade2.ChildPos_TPCBit) == Cascade2.ChildPos_TPCBit) && + ((negChild.pidcut() & Cascade2.ChildNeg_TPCBit) == Cascade2.ChildNeg_TPCBit) && + ((bachChild.pidcut() & Cascade2.ChildBach_TPCBit) == Cascade2.ChildBach_TPCBit))) { + continue; + } + } + if (Option.CPROn.value) { + if ((p1.cut() & kSignPlusMask) == kSignPlusMask) { + if (pairCloseRejectionSE.isClosePair(p1, posChild, parts, col.magField())) { + continue; + } + } else { + if (pairCloseRejectionSE.isClosePair(p1, posChild, parts, col.magField())) { + continue; + } + } + } + + if (!pairCleaner.isCleanPair(p1, p2, parts)) { + continue; + } + sameEventCont.setPair(p1, p2, col.multNtr(), col.multV0M(), Option.Use4D, Option.ExtendedPlots, Option.smearingByOrigin); + } + } + void processSameEvent(FilteredCollision const& col, FDParticles const& parts) + { + // if ((col.bitmaskTrackOne() & BitMask) != BitMask || (col.bitmaskTrackTwo() & BitMask) != BitMask) { + // return; + // } + eventHisto.fillQA(col); + auto SliceTrk1 = PartitionTrk1->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + auto SliceCascade2 = PartitionCascade2->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + doSameEvent(SliceTrk1, SliceCascade2, parts, col); + } + PROCESS_SWITCH(femtoDreamPairTaskTrackCascade, processSameEvent, "Enable processing same event", true); + + template + void doMixedEvent(CollisionType const& cols, PartType const& parts, PartitionType& part1, PartitionType& part2, BinningType policy) + { + // Partition PartitionMaskedCol = ncheckbit(aod::femtodreamcollision::bitmaskTrackOne, BitMask) && ncheckbit(aod::femtodreamcollision::bitmaskTrackTwo, BitMask);// && aod::femtodreamcollision::downsample == true; + // PartitionMaskedCol.bindTable(cols); + + // use *Partition.mFiltered when passing the partition to mixing object + // there is an issue when the partition is passed directly + // workaround for now, change back once it is fixed + for (auto const& [collision1, collision2] : soa::selfCombinations(policy, Mixing.Depth.value, -1, cols, cols)) { + // make sure that tracks in same events are not mixed + if (collision1.globalIndex() == collision2.globalIndex()) { + continue; + } + auto SliceTrk1 = part1->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision1.globalIndex(), cache); + auto SliceCasc2 = part2->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision2.globalIndex(), cache); + for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(SliceTrk1, SliceCasc2))) { + const auto& posChild = parts.iteratorAt(p2.index() - 3); + const auto& negChild = parts.iteratorAt(p2.index() - 2); + const auto& bachChild = parts.iteratorAt(p2.index() - 1); + // check cuts on Cascade children + if (Cascade2.UseChildCuts) { + if (!(((posChild.cut() & Cascade2.ChildPos_CutBit) == Cascade2.ChildPos_CutBit) && + ((negChild.cut() & Cascade2.ChildNeg_CutBit) == Cascade2.ChildNeg_CutBit) && + ((bachChild.cut() & Cascade2.ChildBach_CutBit) == Cascade2.ChildBach_CutBit))) { + continue; + } + } + if (Cascade2.UseChildPIDCuts) { + if (!(((posChild.pidcut() & Cascade2.ChildPos_TPCBit) == Cascade2.ChildPos_TPCBit) && + ((negChild.pidcut() & Cascade2.ChildNeg_TPCBit) == Cascade2.ChildNeg_TPCBit) && + ((bachChild.pidcut() & Cascade2.ChildBach_TPCBit) == Cascade2.ChildBach_TPCBit))) { + continue; + } + } + + if (Option.CPROn.value) { + if ((p1.cut() & kSignPlusMask) == kSignPlusMask) { + if (pairCloseRejectionME.isClosePair(p1, posChild, parts, collision1.magField())) { + continue; + } + } else { + if (pairCloseRejectionME.isClosePair(p1, negChild, parts, collision1.magField())) { + continue; + } + } + } + // Pair cleaner not needed in the mixing + // if (!pairCleaner.isCleanPair(p1, p2, parts)) { + // continue; + //} + + mixedEventCont.setPair(p1, p2, collision1.multNtr(), collision1.multV0M(), Option.Use4D, Option.ExtendedPlots, Option.smearingByOrigin); + } + } + } + + void processMixedEvent(FilteredCollisions const& cols, FDParticles const& parts) + { + switch (Mixing.Policy.value) { + case femtodreamcollision::kMult: + doMixedEvent(cols, parts, PartitionTrk1, PartitionCascade2, colBinningMult); + break; + case femtodreamcollision::kMultPercentile: + doMixedEvent(cols, parts, PartitionTrk1, PartitionCascade2, colBinningMultPercentile); + break; + case femtodreamcollision::kMultMultPercentile: + doMixedEvent(cols, parts, PartitionTrk1, PartitionCascade2, colBinningMultMultPercentile); + break; + default: + LOG(fatal) << "Invalid binning policiy specifed. Breaking..."; + } + } + PROCESS_SWITCH(femtoDreamPairTaskTrackCascade, processMixedEvent, "Enable processing mixed events", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{ + adaptAnalysisTask(cfgc), + }; + return workflow; +} diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackTrack.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackTrack.cxx index 371324a96e8..9f080fd2dd0 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackTrack.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackTrack.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -242,9 +242,9 @@ struct femtoDreamPairTaskTrackTrack { random = new TRandom3(0); } eventHisto.init(&Registry, Option.IsMC); - trackHistoPartOne.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.TrackpT, Option.Dummy, Option.Dummy, Binning.TempFitVar, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.IsMC, Track1.PDGCode); + trackHistoPartOne.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.TrackpT, Option.Dummy, Option.Dummy, Binning.TempFitVar, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.IsMC, Track1.PDGCode); if (!Option.SameSpecies) { - trackHistoPartTwo.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.TrackpT, Option.Dummy, Option.Dummy, Binning.TempFitVar, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.IsMC, Track2.PDGCode); + trackHistoPartTwo.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.TrackpT, Option.Dummy, Option.Dummy, Binning.TempFitVar, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.IsMC, Track2.PDGCode); } sameEventCont.init(&Registry, diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackV0.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackV0.cxx index dbaaacedfe8..7798f3d59c8 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackV0.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackV0.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -234,10 +234,10 @@ struct femtoDreamPairTaskTrackV0 { colBinningMultMultPercentile = {{Mixing.BinVztx, Mixing.BinMult, Mixing.BinMultPercentile}, true}; eventHisto.init(&Registry, Option.IsMC); - trackHistoPartOne.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTTrack, Option.Dummy, Option.Dummy, Binning.TempFitVarTrack, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.IsMC, Track1.PDGCode); - trackHistoPartTwo.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTV0, Option.Dummy, Option.Dummy, Binning.TempFitVarV0, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Binning.InvMass, Option.IsMC, V02.PDGCode); - posChildHistos.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTV0Child, Option.Dummy, Option.Dummy, Binning.TempFitVarV0Child, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, false, 0); - negChildHistos.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTV0Child, Option.Dummy, Option.Dummy, Binning.TempFitVarV0Child, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, false, 0); + trackHistoPartOne.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTTrack, Option.Dummy, Option.Dummy, Binning.TempFitVarTrack, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.IsMC, Track1.PDGCode); + trackHistoPartTwo.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTV0, Option.Dummy, Option.Dummy, Binning.TempFitVarV0, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Binning.InvMass, Option.Dummy, Option.IsMC, V02.PDGCode); + posChildHistos.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTV0Child, Option.Dummy, Option.Dummy, Binning.TempFitVarV0Child, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, false, 0); + negChildHistos.init(&Registry, Binning.multTempFit, Option.Dummy, Binning.pTV0Child, Option.Dummy, Option.Dummy, Binning.TempFitVarV0Child, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, false, 0); sameEventCont.init(&Registry, Binning.kstar, Binning.pT, Binning.kT, Binning.mT, Mixing.BinMult, Mixing.BinMultPercentile, diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrack.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrack.cxx index d897fa90b06..899de5659b1 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrack.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrack.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -65,6 +65,7 @@ struct femtoDreamTripletTaskTrackTrackTrack { Configurable ConfTPCTOFPIDBit{"ConfTPCTOFPIDBit", 8, "PID TPCTOF bit from cutCulator"}; Configurable ConfIsMC{"ConfIsMC", false, "Enable additional Histogramms in the case of a MonteCarlo Run"}; Configurable ConfUse3D{"ConfUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; + Configurable ConfDCACutPtDep{"ConfDCACutPtDep", false, "Use pt dependent dca cut for tracks"}; // Which particles to analyse; currently support only for same species and cuts triplets Configurable ConfPDGCodePart{"ConfPDGCodePart", 2212, "Particle PDG code"}; @@ -76,15 +77,20 @@ struct femtoDreamTripletTaskTrackTrackTrack { (ncheckbit(aod::femtodreamparticle::cut, ConfCutPart)) && (aod::femtodreamparticle::pt < ConfMaxpT) && (aod::femtodreamparticle::pt > ConfMinpT) && - (aod::femtodreamparticle::tempFitVar < ConfMaxDCAxy) && - (aod::femtodreamparticle::tempFitVar > ConfMinDCAxy); + ifnode(ConfDCACutPtDep, (nabs(aod::femtodreamparticle::tempFitVar) <= 0.0105f + (0.035f / npow(aod::femtodreamparticle::pt, 1.1f))), + ((aod::femtodreamparticle::tempFitVar >= ConfMinDCAxy) && + (aod::femtodreamparticle::tempFitVar <= ConfMaxDCAxy))); + ; + Partition> SelectedPartsMC = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= ConfPIDthrMom, ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCPIDBit), ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCTOFPIDBit)) && (ncheckbit(aod::femtodreamparticle::cut, ConfCutPart)) && (aod::femtodreamparticle::pt < ConfMaxpT) && (aod::femtodreamparticle::pt > ConfMinpT) && - (aod::femtodreamparticle::tempFitVar < ConfMaxDCAxy) && - (aod::femtodreamparticle::tempFitVar > ConfMinDCAxy); + ifnode(ConfDCACutPtDep, (nabs(aod::femtodreamparticle::tempFitVar) <= 0.0105f + (0.035f / npow(aod::femtodreamparticle::pt, 1.1f))), + ((aod::femtodreamparticle::tempFitVar >= ConfMinDCAxy) && + (aod::femtodreamparticle::tempFitVar <= ConfMaxDCAxy))); + ; /// Histogramming of Selected Particles FemtoDreamParticleHisto trackHistoSelectedParts; @@ -132,8 +138,8 @@ struct femtoDreamTripletTaskTrackTrackTrack { colBinning = {{ConfVtxBins, ConfMultBins}, true}; - trackHistoSelectedParts.init(&qaRegistry, ConfBinmultTempFit, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBins, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); - trackHistoALLSelectedParts.init(&qaRegistry, ConfBinmultTempFit, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBins, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); + trackHistoSelectedParts.init(&qaRegistry, ConfBinmultTempFit, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBins, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); + trackHistoALLSelectedParts.init(&qaRegistry, ConfBinmultTempFit, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBins, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); ThreeBodyQARegistry.add("TripletTaskQA/hSECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); ThreeBodyQARegistry.add("TripletTaskQA/hMECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); @@ -142,6 +148,8 @@ struct femtoDreamTripletTaskTrackTrackTrack { std::vector tmpVecMult = ConfMultBins; framework::AxisSpec multAxis = {tmpVecMult, "Multiplicity"}; ThreeBodyQARegistry.add("TripletTaskQA/hSEMultVSGoodTracks", ";Mult;GoodT", kTH2F, {multAxis, {100, 0, 100}}); + ThreeBodyQARegistry.add("TripletTaskQA/hTripletsPerEventBelow14", ";Triplets;Entries", kTH1F, {{10, 0, 10}}); + ThreeBodyQARegistry.add("TripletTaskQA/NumberOfTacksPassingSelection", ";Triplets;Entries", kTH1F, {{30, 0, 30}}); if (ConfIsMC) { ThreeBodyQARegistry.add("TrackMC_QA/hMazzachi", ";gen;(reco-gen)/gen", kTH2F, {{100, ConfMinpT, ConfMaxpT}, {300, -1, 1}}); } @@ -214,11 +222,15 @@ struct femtoDreamTripletTaskTrackTrackTrack { void doSameEvent(PartitionType groupSelectedParts, PartType parts, float magFieldTesla, int multCol, float centCol) { /// Histogramming same event + int numberOfTracksPassingSelection = 0; for (auto& part : groupSelectedParts) { + numberOfTracksPassingSelection = numberOfTracksPassingSelection + 1; trackHistoSelectedParts.fillQA(part, aod::femtodreamparticle::kPt, multCol, centCol); } + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/NumberOfTacksPassingSelection"), numberOfTracksPassingSelection); /// Now build the combinations + int numberOfTriplets = 0; for (auto& [p1, p2, p3] : combinations(CombinationsStrictlyUpperIndexPolicy(groupSelectedParts, groupSelectedParts, groupSelectedParts))) { auto Q3 = FemtoDreamMath::getQ3(p1, mMassOne, p2, mMassTwo, p3, mMassThree); @@ -246,10 +258,14 @@ struct femtoDreamTripletTaskTrackTrackTrack { } // fill pT of all three particles as a function of Q3 for lambda calculations + if (Q3 < 1.4) { + numberOfTriplets = numberOfTriplets + 1; + } ThreeBodyQARegistry.fill(HIST("TripletTaskQA/particle_pT_in_Triplet_SE"), p1.pt(), p2.pt(), p3.pt(), Q3); sameEventCont.setTriplet(p1, p2, p3, multCol, Q3); ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hCentrality"), centCol, Q3); } + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hTripletsPerEventBelow14"), numberOfTriplets); } /// process function to call doSameEvent with Data diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrackPbPb.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrackPbPb.cxx new file mode 100644 index 00000000000..698aa5e6c63 --- /dev/null +++ b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrackPbPb.cxx @@ -0,0 +1,530 @@ +// Copyright 2019-2022 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. + +/// \file femtoDreamTripletTaskTrackTrackTrackPbPb.cxx +/// \brief Tasks that reads the track tables and creates track triplets; only three identical particles can be used +/// \author Laura Serksnyte, TU München, laura.serksnyte@tum.de + +#include "PWGCF/DataModel/FemtoDerived.h" +#include "PWGCF/FemtoDream/Core/femtoDreamContainerThreeBody.h" +#include "PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h" +#include "PWGCF/FemtoDream/Core/femtoDreamEventHisto.h" +#include "PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h" +#include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h" +#include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" + +#include "TDatabasePDG.h" + +#include +#include + +using namespace o2; +using namespace o2::analysis::femtoDream; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct femtoDreamTripletTaskTrackTrackTrackPbPb { + SliceCache cache; + Preslice perCol = aod::femtodreamparticle::fdCollisionId; + + Configurable ConfCentralityMin{"ConfCentralityMin", 0, "Minimum Centrality Percentile"}; + Configurable ConfCentralityMax{"ConfCentralityMax", 10, "Maximum Centrality Percentile"}; + + Filter EventCentrality = aod::femtodreamcollision::multV0M >= ConfCentralityMin && aod::femtodreamcollision::multV0M <= ConfCentralityMax; + using FilteredFDCollisions = soa::Filtered; + using FilteredFDCollision = FilteredFDCollisions::iterator; + + using MaskedCollisions = soa::Filtered>; + using MaskedCollision = MaskedCollisions::iterator; + aod::femtodreamcollision::BitMaskType MaskBit = -1; + float mMassOne = -999, mMassTwo = -999, mMassThree = -999; + + /// Particle selection part + + // which CPR to use, old is with a possible bug and new is fixed + Configurable ConfUseOLD_possiblyWrong_CPR{"ConfUseOLD_possiblyWrong_CPR", true, "Use for old CPR, which possibly has a bug. This is implemented only for debugging reasons to compare old and new code on hyperloop datasets."}; + + /// Table for both particles + Configurable ConfTracksInMixedEvent{"ConfTracksInMixedEvent", 1, "Number of tracks of interest, contained in the mixed event sample: 1 - only events with at least one track of interest are used in mixing; ...; 3 - only events with at least three track of interest are used in mixing. Max value is 3"}; + Configurable ConfMaxpT{"ConfMaxpT", 4.05f, "Maximum transverse momentum of the particles"}; + Configurable ConfMinpT{"ConfMinpT", 0.3f, "Minimum transverse momentum of the particles"}; + Configurable ConfMaxDCAxy{"ConfMaxDCAxy", -0.1f, "Maximum DCAxy of the particles"}; + Configurable ConfMinDCAxy{"ConfMinDCAxy", 0.1f, "Minimum DCAxy of the particles"}; + Configurable ConfPIDthrMom{"ConfPIDthrMom", 1.f, "Momentum threshold from which TPC and TOF are required for PID"}; + Configurable ConfAtWhichRadiiToCut{"ConfAtWhichRadiiToCut", 1, "At which radii perform deta dphi selection: 0 - at PV, 1 - averaged phi, 2 - at given radii"}; + Configurable ConfAtWhichTPCRadii{"ConfAtWhichTPCRadii", 85., "If ConfAtWhichRadiiToCut = 2; this allows to select at which TPC radii to cut"}; + Configurable ConfTPCPIDBit{"ConfTPCPIDBit", 16, "PID TPC bit from cutCulator "}; + Configurable ConfTPCTOFPIDBit{"ConfTPCTOFPIDBit", 8, "PID TPCTOF bit from cutCulator"}; + Configurable ConfIsMC{"ConfIsMC", false, "Enable additional Histogramms in the case of a MonteCarlo Run"}; + Configurable ConfUse3D{"ConfUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; + Configurable ConfDCACutPtDep{"ConfDCACutPtDep", false, "Use pt dependent dca cut for tracks"}; + + // Which particles to analyse; currently support only for same species and cuts triplets + Configurable ConfPDGCodePart{"ConfPDGCodePart", 2212, "Particle PDG code"}; + Configurable ConfCutPart{"ConfCutPart", 5542474, "Track - Selection bit from cutCulator"}; + + /// Partition for selected particles + Partition SelectedParts = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && + ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= ConfPIDthrMom, ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCPIDBit), ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCTOFPIDBit)) && + (ncheckbit(aod::femtodreamparticle::cut, ConfCutPart)) && + (aod::femtodreamparticle::pt < ConfMaxpT) && + (aod::femtodreamparticle::pt > ConfMinpT) && + ifnode(ConfDCACutPtDep, (nabs(aod::femtodreamparticle::tempFitVar) < 0.004f + (0.013f / aod::femtodreamparticle::pt)), + ((aod::femtodreamparticle::tempFitVar >= ConfMinDCAxy) && + (aod::femtodreamparticle::tempFitVar <= ConfMaxDCAxy))); + ; + + Partition> SelectedPartsMC = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && + ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= ConfPIDthrMom, ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCPIDBit), ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCTOFPIDBit)) && + (ncheckbit(aod::femtodreamparticle::cut, ConfCutPart)) && + (aod::femtodreamparticle::pt < ConfMaxpT) && + (aod::femtodreamparticle::pt > ConfMinpT) && + ifnode(ConfDCACutPtDep, (nabs(aod::femtodreamparticle::tempFitVar) < 0.004f + (0.013f / aod::femtodreamparticle::pt)), + ((aod::femtodreamparticle::tempFitVar >= ConfMinDCAxy) && + (aod::femtodreamparticle::tempFitVar <= ConfMaxDCAxy))); + ; + + /// Histogramming of Selected Particles + FemtoDreamParticleHisto trackHistoSelectedParts; + FemtoDreamParticleHisto trackHistoALLSelectedParts; + + /// Histogramming for Event + FemtoDreamEventHisto eventHisto; + + /// particle part + ConfigurableAxis ConfTempFitVarBins{"ConfTempFitVarBins", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfTempFitVarpTBins{"ConfTempFitVarpTBins", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfBinmultTempFit{"ConfBinmultTempFit", {1, 0, 1}, "multiplicity Binning for the TempFitVar plot"}; + + /// Correlation part + ConfigurableAxis ConfMultBins{"ConfMultBins", {VARIABLE_WIDTH, 0.0f, 20.0f, 40.0f, 60.0f, 80.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - multiplicity"}; + ConfigurableAxis ConfVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + + ColumnBinningPolicy colBinning{{ConfVtxBins, ConfMultBins}, true}; + + ConfigurableAxis ConfQ3Bins{"ConfQ3Bins", {2000, 0., 8.}, "binning Q3"}; + ConfigurableAxis ConfQ3BinsFor4D{"ConfQ3BinsFor4D", {500, 0., 2.}, "binning Q3 for 4D hist"}; + Configurable ConfNEventsMix{"ConfNEventsMix", 5, "Number of events for mixing"}; + Configurable ConfIsCPR{"ConfIsCPR", true, "Close Pair Rejection"}; + Configurable ConfFillCPRQA{"ConfFillCPRQA", false, "Fill Close Pair Rejection plots as a function of eta and phi"}; + Configurable ConfCPRPlotPerRadii{"ConfCPRPlotPerRadii", false, "Plot CPR per radii"}; + Configurable ConfCPRdeltaPhiMax{"ConfCPRdeltaPhiMax", 0.01, "Max. Delta Phi for Close Pair Rejection"}; + Configurable ConfCPRdeltaEtaMax{"ConfCPRdeltaEtaMax", 0.01, "Max. Delta Eta for Close Pair Rejection"}; + Configurable ConfMaxQ3IncludedInCPRPlots{"ConfMaxQ3IncludedInCPRPlots", 8., "Maximum Q3, for which the pair CPR is included in plots"}; + ConfigurableAxis ConfDummy{"ConfDummy", {1, 0, 1}, "Dummy axis"}; + + FemtoDreamContainerThreeBody sameEventCont; + FemtoDreamContainerThreeBody mixedEventCont; + FemtoDreamPairCleaner pairCleaner; + FemtoDreamDetaDphiStar pairCloseRejectionSE; + FemtoDreamDetaDphiStar pairCloseRejectionME; + /// Histogram output + HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry ThreeBodyQARegistry{"ThreeBodyQARegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(InitContext& context) + { + + eventHisto.init(&qaRegistry, false); + + colBinning = {{ConfVtxBins, ConfMultBins}, true}; + + trackHistoSelectedParts.init(&qaRegistry, ConfBinmultTempFit, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBins, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); + trackHistoALLSelectedParts.init(&qaRegistry, ConfBinmultTempFit, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBins, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); + + ThreeBodyQARegistry.add("TripletTaskQA/hSECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); + ThreeBodyQARegistry.add("TripletTaskQA/hMECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); + ThreeBodyQARegistry.add("TripletTaskQA/particle_pT_in_Triplet_SE", "; p_{T1} ; p_{T2} ; p_{T3} ; Q_{3}", kTHnSparseF, {ConfTempFitVarpTBins, ConfTempFitVarpTBins, ConfTempFitVarpTBins, ConfQ3BinsFor4D}); + ThreeBodyQARegistry.add("TripletTaskQA/particle_pT_in_Triplet_ME", "; p_{T1} ; p_{T2} ; p_{T3} ; Q_{3}", kTHnSparseF, {ConfTempFitVarpTBins, ConfTempFitVarpTBins, ConfTempFitVarpTBins, ConfQ3BinsFor4D}); + std::vector tmpVecMult = ConfMultBins; + framework::AxisSpec multAxis = {tmpVecMult, "Multiplicity"}; + ThreeBodyQARegistry.add("TripletTaskQA/hSEMultVSGoodTracks", ";Mult;GoodT", kTH2F, {multAxis, {100, 0, 100}}); + ThreeBodyQARegistry.add("TripletTaskQA/hTripletsPerEventBelow14", ";Triplets;Entries", kTH1F, {{10, 0, 10}}); + ThreeBodyQARegistry.add("TripletTaskQA/NumberOfTacksPassingSelection", ";Triplets;Entries", kTH1F, {{30, 0, 30}}); + if (ConfIsMC) { + ThreeBodyQARegistry.add("TrackMC_QA/hMazzachi", ";gen;(reco-gen)/gen", kTH2F, {{100, ConfMinpT, ConfMaxpT}, {300, -1, 1}}); + } + ThreeBodyQARegistry.add("TripletTaskQA/hCentrality", ";Centrality; Q3", kTH2F, {{100, 0, 100}, ConfQ3Bins}); + ThreeBodyQARegistry.add("TripletTaskQA/hCentralityME", ";Centrality;Entries", kTH1F, {{100, 0.0, 100.0}}); + + sameEventCont.init(&resultRegistry, ConfQ3Bins, ConfMultBins, ConfIsMC); + mixedEventCont.init(&resultRegistry, ConfQ3Bins, ConfMultBins, ConfIsMC); + sameEventCont.setPDGCodes(ConfPDGCodePart, ConfPDGCodePart, ConfPDGCodePart); + mixedEventCont.setPDGCodes(ConfPDGCodePart, ConfPDGCodePart, ConfPDGCodePart); + pairCleaner.init(&qaRegistry); // SERKSNYTE : later check if init should be updated to have 3 separate histos + if (ConfIsCPR.value) { + pairCloseRejectionSE.init(&resultRegistry, &qaRegistry, ConfCPRdeltaPhiMax.value, ConfCPRdeltaEtaMax.value, ConfCPRPlotPerRadii.value, 1, ConfUseOLD_possiblyWrong_CPR, ConfMaxQ3IncludedInCPRPlots, false, ConfAtWhichRadiiToCut, ConfAtWhichTPCRadii, ConfFillCPRQA); + pairCloseRejectionME.init(&resultRegistry, &qaRegistry, ConfCPRdeltaPhiMax.value, ConfCPRdeltaEtaMax.value, ConfCPRPlotPerRadii.value, 2, ConfUseOLD_possiblyWrong_CPR, ConfMaxQ3IncludedInCPRPlots, false, ConfAtWhichRadiiToCut, ConfAtWhichTPCRadii, ConfFillCPRQA); + } + + // get masses + mMassOne = TDatabasePDG::Instance()->GetParticle(ConfPDGCodePart)->Mass(); + mMassTwo = TDatabasePDG::Instance()->GetParticle(ConfPDGCodePart)->Mass(); + mMassThree = TDatabasePDG::Instance()->GetParticle(ConfPDGCodePart)->Mass(); + + // get bit for the collision mask + std::bitset<8 * sizeof(aod::femtodreamcollision::BitMaskType)> mask; + int index = 0; + auto& workflows = context.services().get(); + for (DeviceSpec const& device : workflows.devices) { + if (device.name.find("femto-dream-triplet-task-track-track-track-pb-pb") != std::string::npos) { + if (containsNameValuePair(device.options, "ConfCutPart", ConfCutPart.value) && + containsNameValuePair(device.options, "ConfTPCPIDBit", ConfTPCPIDBit.value) && + containsNameValuePair(device.options, "ConfTPCTOFPIDBit", ConfTPCTOFPIDBit.value) && + containsNameValuePair(device.options, "ConfPIDthrMom", ConfPIDthrMom.value) && + containsNameValuePair(device.options, "ConfMaxpT", ConfMaxpT.value) && + containsNameValuePair(device.options, "ConfMinpT", ConfMinpT.value) && + containsNameValuePair(device.options, "ConfMaxDCAxy", ConfMaxDCAxy.value) && + containsNameValuePair(device.options, "ConfMinDCAxy", ConfMinDCAxy.value)) { + mask.set(index); + MaskBit = static_cast(mask.to_ulong()); + LOG(info) << "Device name matched: " << device.name; + LOG(info) << "Bitmask for collisions: " << mask.to_string(); + break; + } else { + index++; + } + } + } + + if ((doprocessSameEvent && doprocessSameEventMasked) || + (doprocessMixedEvent && doprocessMixedEventMasked) || + (doprocessSameEventMC && doprocessSameEventMCMasked) || + (doprocessMixedEventMC && doprocessMixedEventMCMasked)) { + LOG(fatal) << "Normal and masked processing cannot be activated simultaneously!"; + } + } + + template + void fillCollision(CollisionType col) + { + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multNtr()})); + eventHisto.fillQA(col); + } + + /// This function processes the same event and takes care of all the histogramming + /// @tparam PartitionType + /// @tparam PartType + /// @tparam isMC: enables Monte Carlo truth specific histograms + /// @param groupSelectedParts partition for the first particle passed by the process function + /// @param parts femtoDreamParticles table (in case of Monte Carlo joined with FemtoDreamMCLabels) + /// @param magFieldTesla magnetic field of the collision + /// @param multCol multiplicity of the collision + template + void doSameEvent(PartitionType groupSelectedParts, PartType parts, float magFieldTesla, int multCol, float centCol) + { + /// Histogramming same event + int numberOfTracksPassingSelection = 0; + for (auto& part : groupSelectedParts) { + numberOfTracksPassingSelection = numberOfTracksPassingSelection + 1; + trackHistoSelectedParts.fillQA(part, aod::femtodreamparticle::kPt, multCol, centCol); + } + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/NumberOfTacksPassingSelection"), numberOfTracksPassingSelection); + + /// Now build the combinations + int numberOfTriplets = 0; + for (auto& [p1, p2, p3] : combinations(CombinationsStrictlyUpperIndexPolicy(groupSelectedParts, groupSelectedParts, groupSelectedParts))) { + auto Q3 = FemtoDreamMath::getQ3(p1, mMassOne, p2, mMassTwo, p3, mMassThree); + + if (ConfIsCPR.value) { + if (pairCloseRejectionSE.isClosePair(p1, p2, parts, magFieldTesla, Q3)) { + continue; + } + if (pairCloseRejectionSE.isClosePair(p2, p3, parts, magFieldTesla, Q3)) { + continue; + } + if (pairCloseRejectionSE.isClosePair(p1, p3, parts, magFieldTesla, Q3)) { + continue; + } + } + + // track cleaning + if (!pairCleaner.isCleanPair(p1, p2, parts)) { + continue; + } + if (!pairCleaner.isCleanPair(p2, p3, parts)) { + continue; + } + if (!pairCleaner.isCleanPair(p1, p3, parts)) { + continue; + } + + // fill pT of all three particles as a function of Q3 for lambda calculations + if (Q3 < 1.4) { + numberOfTriplets = numberOfTriplets + 1; + } + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/particle_pT_in_Triplet_SE"), p1.pt(), p2.pt(), p3.pt(), Q3); + sameEventCont.setTriplet(p1, p2, p3, multCol, Q3); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hCentrality"), centCol, Q3); + } + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hTripletsPerEventBelow14"), numberOfTriplets); + } + + /// process function to call doSameEvent with Data + /// \param col subscribe to the collision table (Data) + /// \param parts subscribe to the femtoDreamParticleTable + void processSameEvent(FilteredFDCollision& col, + o2::aod::FDParticles& parts) + { + fillCollision(col); + auto thegroupSelectedParts = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + for (auto& part : thegroupSelectedParts) { + trackHistoALLSelectedParts.fillQA(part, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); + } + + if (thegroupSelectedParts.size() < 3) { + return; + } + doSameEvent(thegroupSelectedParts, parts, col.magField(), col.multNtr(), col.multV0M()); + } + PROCESS_SWITCH(femtoDreamTripletTaskTrackTrackTrackPbPb, processSameEvent, "Enable processing same event", true); + + /// process function to call doSameEvent with Data which has a mask for containing particles or not + /// \param col subscribe to the collision table (Data) + /// \param parts subscribe to the femtoDreamParticleTable + void processSameEventMasked(MaskedCollision& col, o2::aod::FDParticles& parts) + { + fillCollision(col); + auto thegroupSelectedParts = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + for (auto& part : thegroupSelectedParts) { + trackHistoALLSelectedParts.fillQA(part, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); + } + if (thegroupSelectedParts.size() < 3) { + return; + } + doSameEvent(thegroupSelectedParts, parts, col.magField(), col.multNtr(), col.multV0M()); + } + PROCESS_SWITCH(femtoDreamTripletTaskTrackTrackTrackPbPb, processSameEventMasked, "Enable processing same event with masks", false); + + /// process function for to call doSameEvent with Monte Carlo + /// \param col subscribe to the collision table (Monte Carlo Reconstructed reconstructed) + /// \param parts subscribe to joined table FemtoDreamParticles and FemtoDreamMCLables to access Monte Carlo truth + /// \param FemtoDreamMCParticles subscribe to the Monte Carlo truth table + void processSameEventMC(o2::aod::FDCollision& col, + soa::Join& parts, + o2::aod::FDMCParticles&) + { + fillCollision(col); + auto thegroupSelectedParts = SelectedPartsMC->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + for (auto& part : thegroupSelectedParts) { + trackHistoALLSelectedParts.fillQA(part, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); + ThreeBodyQARegistry.fill(HIST("TrackMC_QA/hMazzachi"), part.fdMCParticle().pt(), (part.pt() - part.fdMCParticle().pt()) / part.fdMCParticle().pt()); + } + if (thegroupSelectedParts.size() < 3) { + return; + } + doSameEvent(thegroupSelectedParts, parts, col.magField(), col.multNtr(), col.multV0M()); + } + PROCESS_SWITCH(femtoDreamTripletTaskTrackTrackTrackPbPb, processSameEventMC, "Enable processing same event for Monte Carlo", false); + + /// process function for to call doSameEvent with Monte Carlo which has a mask for containing particles or not + /// \param col subscribe to the collision table (Monte Carlo Reconstructed reconstructed) + /// \param parts subscribe to joined table FemtoDreamParticles and FemtoDreamMCLables to access Monte Carlo truth + /// \param FemtoDreamMCParticles subscribe to the Monte Carlo truth table + void processSameEventMCMasked(MaskedCollision& col, + soa::Join& parts, + o2::aod::FDMCParticles&) + { + fillCollision(col); + auto thegroupSelectedParts = SelectedPartsMC->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + for (auto& part : thegroupSelectedParts) { + trackHistoALLSelectedParts.fillQA(part, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); + ThreeBodyQARegistry.fill(HIST("TrackMC_QA/hMazzachi"), part.fdMCParticle().pt(), (part.pt() - part.fdMCParticle().pt()) / part.fdMCParticle().pt()); + } + if (thegroupSelectedParts.size() < 3) { + return; + } + doSameEvent(thegroupSelectedParts, parts, col.magField(), col.multNtr(), col.multV0M()); + } + PROCESS_SWITCH(femtoDreamTripletTaskTrackTrackTrackPbPb, processSameEventMCMasked, "Enable processing same event for Monte Carlo", false); + + /// This function processes the mixed event + /// \tparam PartitionType + /// \tparam PartType + /// \tparam isMC: enables Monte Carlo truth specific histograms + /// \param groupPartsOne partition for the first particle passed by the process function + /// \param groupPartsTwo partition for the second particle passed by the process function + /// \param groupPartsThree partition for the third particle passed by the process function + /// \param parts femtoDreamParticles table (in case of Monte Carlo joined with FemtoDreamMCLabels) + /// \param magFieldTesla magnetic field of the collision + /// \param multCol multiplicity of the collision + template + void doMixedEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, PartitionType groupPartsThree, PartType parts, float magFieldTesla, int multCol) + { + for (auto& [p1, p2, p3] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo, groupPartsThree))) { + + auto Q3 = FemtoDreamMath::getQ3(p1, mMassOne, p2, mMassTwo, p3, mMassThree); + if (ConfIsCPR.value) { + if (pairCloseRejectionME.isClosePair(p1, p2, parts, magFieldTesla, Q3)) { + continue; + } + if (pairCloseRejectionME.isClosePair(p2, p3, parts, magFieldTesla, Q3)) { + continue; + } + + if (pairCloseRejectionME.isClosePair(p1, p3, parts, magFieldTesla, Q3)) { + continue; + } + } + // fill pT of all three particles as a function of Q3 for lambda calculations + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/particle_pT_in_Triplet_ME"), p1.pt(), p2.pt(), p3.pt(), Q3); + mixedEventCont.setTriplet(p1, p2, p3, multCol, Q3); + } + } + + /// process function for to call doMixedEvent with Data + /// @param cols subscribe to the collisions table (Data) + /// @param parts subscribe to the femtoDreamParticleTable + void processMixedEvent(FilteredFDCollisions& cols, + o2::aod::FDParticles& parts) + { + for (auto& [collision1, collision2, collision3] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols, cols)) { + const int multiplicityCol = collision1.multNtr(); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hCentralityME"), collision1.multV0M()); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hCentralityME"), collision2.multV0M()); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hCentralityME"), collision3.multV0M()); + + auto groupPartsOne = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision2.globalIndex(), cache); + auto groupPartsThree = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision3.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + const auto& magFieldTesla3 = collision3.magField(); + if ((magFieldTesla1 != magFieldTesla2) || (magFieldTesla2 != magFieldTesla3) || (magFieldTesla1 != magFieldTesla3)) { + continue; + } + + doMixedEvent(groupPartsOne, groupPartsTwo, groupPartsThree, parts, magFieldTesla1, multiplicityCol); + } + } + PROCESS_SWITCH(femtoDreamTripletTaskTrackTrackTrackPbPb, processMixedEvent, "Enable processing mixed events", true); + + /// process function for to call doMixedEvent with Data which has a mask for containing particles or not + /// @param cols subscribe to the collisions table (Data) + /// @param parts subscribe to the femtoDreamParticleTable + void processMixedEventMasked(MaskedCollisions& cols, o2::aod::FDParticles& parts) + { + Partition PartitionMaskedCol1 = (ConfTracksInMixedEvent == 1 && (aod::femtodreamcollision::bitmaskTrackOne & MaskBit) == MaskBit) || + (ConfTracksInMixedEvent == 2 && (aod::femtodreamcollision::bitmaskTrackTwo & MaskBit) == MaskBit) || + (ConfTracksInMixedEvent == 3 && (aod::femtodreamcollision::bitmaskTrackThree & MaskBit) == MaskBit); + + PartitionMaskedCol1.bindTable(cols); + for (auto& [collision1, collision2, collision3] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, *PartitionMaskedCol1.mFiltered, *PartitionMaskedCol1.mFiltered, *PartitionMaskedCol1.mFiltered)) { + const int multiplicityCol = collision1.multNtr(); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hCentralityME"), collision1.multV0M()); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hCentralityME"), collision2.multV0M()); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hCentralityME"), collision3.multV0M()); + + auto groupPartsOne = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision2.globalIndex(), cache); + auto groupPartsThree = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision3.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + const auto& magFieldTesla3 = collision3.magField(); + + if ((magFieldTesla1 != magFieldTesla2) || (magFieldTesla2 != magFieldTesla3) || (magFieldTesla1 != magFieldTesla3)) { + continue; + } + + doMixedEvent(groupPartsOne, groupPartsTwo, groupPartsThree, parts, magFieldTesla1, multiplicityCol); + } + } + PROCESS_SWITCH(femtoDreamTripletTaskTrackTrackTrackPbPb, processMixedEventMasked, "Enable processing mixed events", false); + + /// brief process function for to call doMixedEvent with Monte Carlo + /// @param cols subscribe to the collisions table (Monte Carlo Reconstructed reconstructed) + /// @param parts subscribe to joined table FemtoDreamParticles and FemtoDreamMCLables to access Monte Carlo truth + /// @param FemtoDreamMCParticles subscribe to the Monte Carlo truth table + void processMixedEventMC(o2::aod::FDCollisions& cols, + soa::Join& parts, + o2::aod::FDMCParticles&) + { + for (auto& [collision1, collision2, collision3] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols, cols)) { + + const int multiplicityCol = collision1.multNtr(); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + + auto groupPartsOne = SelectedPartsMC->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = SelectedPartsMC->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision2.globalIndex(), cache); + auto groupPartsThree = SelectedPartsMC->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision3.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + const auto& magFieldTesla3 = collision3.magField(); + + if ((magFieldTesla1 != magFieldTesla2) || (magFieldTesla2 != magFieldTesla3) || (magFieldTesla1 != magFieldTesla3)) { + continue; + } + // CONSIDER testing different strategies to which events to use + + doMixedEvent(groupPartsOne, groupPartsTwo, groupPartsThree, parts, magFieldTesla1, multiplicityCol); + } + } + PROCESS_SWITCH(femtoDreamTripletTaskTrackTrackTrackPbPb, processMixedEventMC, "Enable processing mixed events MC", false); + + /// brief process function for to call doMixedEvent with Monte Carlo which has a mask for containing particles or not + /// @param cols subscribe to the collisions table (Monte Carlo Reconstructed reconstructed) + /// @param parts subscribe to joined table FemtoDreamParticles and FemtoDreamMCLables to access Monte Carlo truth + /// @param FemtoDreamMCParticles subscribe to the Monte Carlo truth table + void processMixedEventMCMasked(MaskedCollisions& cols, + soa::Join& parts, + o2::aod::FDMCParticles&) + { + Partition PartitionMaskedCol1 = (ConfTracksInMixedEvent == 1 && (aod::femtodreamcollision::bitmaskTrackOne & MaskBit) == MaskBit) || + (ConfTracksInMixedEvent == 2 && (aod::femtodreamcollision::bitmaskTrackTwo & MaskBit) == MaskBit) || + (ConfTracksInMixedEvent == 3 && (aod::femtodreamcollision::bitmaskTrackThree & MaskBit) == MaskBit); + PartitionMaskedCol1.bindTable(cols); + + for (auto& [collision1, collision2, collision3] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, *PartitionMaskedCol1.mFiltered, *PartitionMaskedCol1.mFiltered, *PartitionMaskedCol1.mFiltered)) { + + const int multiplicityCol = collision1.multNtr(); + ThreeBodyQARegistry.fill(HIST("TripletTaskQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + + auto groupPartsOne = SelectedPartsMC->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = SelectedPartsMC->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision2.globalIndex(), cache); + auto groupPartsThree = SelectedPartsMC->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision3.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + const auto& magFieldTesla3 = collision3.magField(); + + if ((magFieldTesla1 != magFieldTesla2) || (magFieldTesla2 != magFieldTesla3) || (magFieldTesla1 != magFieldTesla3)) { + continue; + } + // CONSIDER testing different strategies to which events to use + + doMixedEvent(groupPartsOne, groupPartsTwo, groupPartsThree, parts, magFieldTesla1, multiplicityCol); + } + } + PROCESS_SWITCH(femtoDreamTripletTaskTrackTrackTrackPbPb, processMixedEventMCMasked, "Enable processing mixed events MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{ + adaptAnalysisTask(cfgc), + }; + return workflow; +} diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackV0.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackV0.cxx index c1f7a9ead68..136b8f9d5ff 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackV0.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackV0.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -69,6 +69,7 @@ struct femtoDreamTripletTaskTrackTrackV0 { Configurable ConfPIDthrMom{"ConfPIDthrMom", 1.f, "Momentum threshold from which TPC and TOF are required for PID"}; Configurable ConfIsMC{"ConfIsMC", false, "Enable additional Histogramms in the case of a MonteCarlo Run"}; Configurable ConfUse3D{"ConfUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; + Configurable ConfDCACutPtDep{"ConfDCACutPtDep", false, "Use pt dependent dca cut for tracks"}; /// Partition for selected particles Partition SelectedParts = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && @@ -76,15 +77,20 @@ struct femtoDreamTripletTaskTrackTrackV0 { (ncheckbit(aod::femtodreamparticle::cut, ConfCutPart)) && (aod::femtodreamparticle::pt < ConfMaxpT) && (aod::femtodreamparticle::pt > ConfMinpT) && - (aod::femtodreamparticle::tempFitVar < ConfMaxDCAxy) && - (aod::femtodreamparticle::tempFitVar > ConfMinDCAxy); + ifnode(ConfDCACutPtDep, (nabs(aod::femtodreamparticle::tempFitVar) <= 0.0105f + (0.035f / npow(aod::femtodreamparticle::pt, 1.1f))), + ((aod::femtodreamparticle::tempFitVar >= ConfMinDCAxy) && + (aod::femtodreamparticle::tempFitVar <= ConfMaxDCAxy))); + ; + Partition> SelectedPartsMC = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= ConfPIDthrMom, ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCPIDBit), ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCTOFPIDBit)) && (ncheckbit(aod::femtodreamparticle::cut, ConfCutPart)) && (aod::femtodreamparticle::pt < ConfMaxpT) && (aod::femtodreamparticle::pt > ConfMinpT) && - (aod::femtodreamparticle::tempFitVar < ConfMaxDCAxy) && - (aod::femtodreamparticle::tempFitVar > ConfMinDCAxy); + ifnode(ConfDCACutPtDep, (nabs(aod::femtodreamparticle::tempFitVar) <= 0.0105f + (0.035f / npow(aod::femtodreamparticle::pt, 1.1f))), + ((aod::femtodreamparticle::tempFitVar >= ConfMinDCAxy) && + (aod::femtodreamparticle::tempFitVar <= ConfMaxDCAxy))); + ; /// Histogramming of selected tracks FemtoDreamParticleHisto trackHistoSelectedParts; @@ -183,14 +189,14 @@ struct femtoDreamTripletTaskTrackTrackV0 { colBinning = {{ConfVtxBins, ConfMultBins}, true}; - trackHistoSelectedParts.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBinsTrack, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); - trackHistoALLSelectedParts.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBinsTrack, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); - particleHistoSelectedV0s.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Bins, ConfDummy, ConfDummy, ConfTempFitVarBinsV0, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfInvMassBins, ConfIsMC, ConfPDGCodeV0); - particleHistoPosChild.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Child, ConfDummy, ConfDummy, ConfTempFitVarBinsV0Child, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, 0); - particleHistoNegChild.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Child, ConfDummy, ConfDummy, ConfTempFitVarBinsV0Child, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, 0); - particleHistoALLSelectedV0s.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Bins, ConfDummy, ConfDummy, ConfTempFitVarBinsV0, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfInvMassBins, ConfIsMC, ConfPDGCodeV0); - particleHistoALLPosChild.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Child, ConfDummy, ConfDummy, ConfTempFitVarBinsV0Child, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, 0); - particleHistoALLNegChild.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Child, ConfDummy, ConfDummy, ConfTempFitVarBinsV0Child, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, 0); + trackHistoSelectedParts.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBinsTrack, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); + trackHistoALLSelectedParts.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTBins, ConfDummy, ConfDummy, ConfTempFitVarBinsTrack, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, ConfPDGCodePart); + particleHistoSelectedV0s.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Bins, ConfDummy, ConfDummy, ConfTempFitVarBinsV0, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfInvMassBins, ConfDummy, ConfIsMC, ConfPDGCodeV0); + particleHistoPosChild.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Child, ConfDummy, ConfDummy, ConfTempFitVarBinsV0Child, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, 0); + particleHistoNegChild.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Child, ConfDummy, ConfDummy, ConfTempFitVarBinsV0Child, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, 0); + particleHistoALLSelectedV0s.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Bins, ConfDummy, ConfDummy, ConfTempFitVarBinsV0, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfInvMassBins, ConfDummy, ConfIsMC, ConfPDGCodeV0); + particleHistoALLPosChild.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Child, ConfDummy, ConfDummy, ConfTempFitVarBinsV0Child, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, 0); + particleHistoALLNegChild.init(&qaRegistry, ConfDummy, ConfDummy, ConfTempFitVarpTV0Child, ConfDummy, ConfDummy, ConfTempFitVarBinsV0Child, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfDummy, ConfIsMC, 0); ThreeBodyQARegistry.add("TripletTaskQA/hSECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); ThreeBodyQARegistry.add("TripletTaskQA/hMECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); diff --git a/PWGCF/FemtoDream/Utils/CMakeLists.txt b/PWGCF/FemtoDream/Utils/CMakeLists.txt index 11e95315fba..a7e29b7839a 100644 --- a/PWGCF/FemtoDream/Utils/CMakeLists.txt +++ b/PWGCF/FemtoDream/Utils/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2024 CERN and copyright holders of ALICE O2. +# Copyright 2019-2025 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. # diff --git a/PWGCF/FemtoDream/Utils/femtoDreamCutCulator.cxx b/PWGCF/FemtoDream/Utils/femtoDreamCutCulator.cxx index 0096d6840e7..d6aa862851f 100644 --- a/PWGCF/FemtoDream/Utils/femtoDreamCutCulator.cxx +++ b/PWGCF/FemtoDream/Utils/femtoDreamCutCulator.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -13,9 +13,9 @@ /// \brief Executable that encodes physical selection criteria in a bit-wise /// selection \author Andi Mathis, TU München, andreas.mathis@ph.tum.de -#include #include #include +#include #include "PWGCF/FemtoDream/Utils/femtoDreamCutCulator.h" #include "PWGCF/FemtoDream/Core/femtoDreamSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h" @@ -29,14 +29,14 @@ using namespace o2::analysis::femtoDream; int main(int /*argc*/, char* argv[]) { std::string configFileName(argv[1]); - std::filesystem::path configFile{configFileName}; + std::ifstream configFile(configFileName); - if (std::filesystem::exists(configFile)) { + if (configFile.is_open()) { FemtoDreamCutculator cut; cut.init(argv[1]); std::cout - << "Do you want to work with tracks or V0s (T/V)? >"; + << "Do you want to work with tracks or V0s or Cascades (T/V/C)? >"; std::string choice; std::cin >> choice; @@ -49,6 +49,24 @@ int main(int /*argc*/, char* argv[]) cut.setV0SelectionFromFile("ConfV0"); cut.setTrackSelectionFromFile("ConfChild"); cut.setPIDSelectionFromFile("ConfChild"); + } else if (choice == std::string("C")) { + std::cout << "Do you want to select cascades, V0-Daughter tracks of the cascades or the Bachelor track (C/V/B)? >"; + std::cin >> choice; + if (choice == std::string("C")) { + cut.setCascadeSelectionFromFile("ConfCascade"); + choice = "C"; + } else if (choice == std::string("V")) { + cut.setTrackSelectionFromFile("ConfCascV0Child"); + cut.setPIDSelectionFromFile("ConfCascV0Child"); + choice = "T"; + } else if (choice == std::string("B")) { + cut.setTrackSelectionFromFile("ConfCascBachelor"); + cut.setPIDSelectionFromFile("ConfCascBachelor"); + choice = "T"; + } else { + std::cout << "Option not recognized. Break..."; + return 2; + } } else { std::cout << "Option not recognized. Break..."; return 2; @@ -79,7 +97,8 @@ int main(int /*argc*/, char* argv[]) } else { std::cout << "The configuration file " << configFileName - << " could not be found."; + << " could not be found or could not be opened."; + return 1; } return 0; diff --git a/PWGCF/FemtoDream/Utils/femtoDreamCutCulator.h b/PWGCF/FemtoDream/Utils/femtoDreamCutCulator.h index 7bb2035dba9..f54a9ff62a4 100644 --- a/PWGCF/FemtoDream/Utils/femtoDreamCutCulator.h +++ b/PWGCF/FemtoDream/Utils/femtoDreamCutCulator.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -32,6 +32,7 @@ #include "PWGCF/FemtoDream/Core/femtoDreamSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamV0Selection.h" +#include "PWGCF/FemtoDream/Core/femtoDreamCascadeSelection.h" namespace o2::analysis::femtoDream { @@ -59,7 +60,7 @@ class FemtoDreamCutculator // check the config file for all known producer task std::vector ProducerTasks = { - "femto-dream-producer-task", "femto-dream-producer-reduced-task"}; + "femto-dream-producer-task", "femto-dream-producer-reduced-task", "femto-dream-producer-task-with-cascades"}; for (auto& Producer : ProducerTasks) { if (root.count(Producer) > 0) { mConfigTree = root.get_child(Producer); @@ -193,6 +194,44 @@ class FemtoDreamCutculator } } + /// Specialization of the setSelection function for Cascades + + /// The selection passed to the function is retrieved from the dpl-config.json + /// \param obs Observable of the track selection + /// \param type Type of the track selection + /// \param prefix Prefix which is added to the name of the Configurable + void setCascadeSelection(femtoDreamCascadeSelection::CascadeSel obs, + femtoDreamSelection::SelectionType type, + const char* prefix) + { + auto tmpVec = + setSelection(FemtoDreamCascadeSelection::getSelectionName(obs, prefix)); + if (tmpVec.size() > 0) { + mCascadeSel.setSelection(tmpVec, obs, type); + } + } + + /// Automatically retrieves V0 selections from the dpl-config.json + /// \param prefix Prefix which is added to the name of the Configurable + void setCascadeSelectionFromFile(const char* prefix) + { + for (const auto& sel : mConfigTree) { + std::string sel_name = sel.first; + femtoDreamCascadeSelection::CascadeSel obs; + if (sel_name.find(prefix) != std::string::npos) { + int index = FemtoDreamCascadeSelection::findSelectionIndex( + std::string_view(sel_name), prefix); + if (index >= 0) { + obs = femtoDreamCascadeSelection::CascadeSel(index); + } else { + continue; + } + setCascadeSelection(obs, FemtoDreamCascadeSelection::getSelectionType(obs), + prefix); + } + } + } + /// This function investigates a given selection criterion. The available /// options are displayed in the terminal and the bit-wise container is put /// together according to the user input \tparam T1 Selection class under @@ -319,6 +358,8 @@ class FemtoDreamCutculator output = iterateSelection(mTrackSel, SysChecks, sign); } else if (choice == std::string("V")) { output = iterateSelection(mV0Sel, SysChecks, sign); + } else if (choice == std::string("C")) { + output = iterateSelection(mCascadeSel, SysChecks, sign); } else { std::cout << "Option " << choice << " not recognized - available options are (T/V)" << std::endl; @@ -338,22 +379,40 @@ class FemtoDreamCutculator std::sort(mPIDValues.begin(), mPIDValues.end(), std::greater<>()); int Bit = 0; + std::cout << "Activate ITS PID (only valid for tracks)? (y/n)"; + std::string choicePID; + std::cin >> choicePID; + std::cout << "+++++++++++++++++++++++++++++++++" << std::endl; - for (std::size_t i = 0; i < mPIDspecies.size(); i++) { - for (std::size_t j = 0; j < mPIDValues.size(); j++) { - std::cout << "Species " << o2::track::PID::getName(mPIDspecies.at(i)) << " with |NSigma|<" << mPIDValues.at(j) << std::endl; - Bit = (2 * mPIDspecies.size() * (mPIDValues.size() - (j + 1)) + 1) + (mPIDspecies.size() - (1 + i)) * 2; - std::cout << "Bit for Nsigma TPC: " << (1 << (Bit + 1)) << std::endl; - std::cout << "Bit for Nsigma TPCTOF: " << (1 << Bit) << std::endl; - std::cout << "+++++++++++++++++++++++++++++++++" << std::endl; + if (choicePID == std::string("n")) { + for (std::size_t i = 0; i < mPIDspecies.size(); i++) { + for (std::size_t j = 0; j < mPIDValues.size(); j++) { + std::cout << "Species " << o2::track::PID::getName(mPIDspecies.at(i)) << " with |NSigma|<" << mPIDValues.at(j) << std::endl; + Bit = (2 * mPIDspecies.size() * (mPIDValues.size() - (j + 1)) + 1) + (mPIDspecies.size() - (1 + i)) * 2; + std::cout << "Bit for Nsigma TPC: " << (1 << (Bit + 1)) << std::endl; + std::cout << "Bit for Nsigma TPCTOF: " << (1 << Bit) << std::endl; + std::cout << "+++++++++++++++++++++++++++++++++" << std::endl; + } + if (SysChecks) { + // Seed the random number generator + // Select a random element + randomIndex = uni(rng); + std::cout << "Nsigma TPC: " << mPIDValues[randomIndex] << std::endl; + randomIndex = uni(rng); + std::cout << "Nsigma TPCTOF: " << mPIDValues[randomIndex] << std::endl; + } } - if (SysChecks) { - // Seed the random number generator - // Select a random element - randomIndex = uni(rng); - std::cout << "Nsigma TPC: " << mPIDValues[randomIndex] << std::endl; - randomIndex = uni(rng); - std::cout << "Nsigma TPCTOF: " << mPIDValues[randomIndex] << std::endl; + } else { + for (std::size_t i = 0; i < mPIDspecies.size(); i++) { + for (std::size_t j = 0; j < mPIDValues.size(); j++) { + std::cout << "Species " << o2::track::PID::getName(mPIDspecies.at(i)) << " with |NSigma|<" << mPIDValues.at(j) << std::endl; + // Bit = (2 * mPIDspecies.size() * (mPIDValues.size() - (j + 1)) + 1) + (mPIDspecies.size() - (1 + i)) * 2; + Bit = (3 * mPIDspecies.size() * (mPIDValues.size() - (j + 1)) + 1) + (mPIDspecies.size() - (1 + i)) * 3; + std::cout << "Bit for Nsigma TPC: " << (1 << (Bit + 2)) << std::endl; + std::cout << "Bit for Nsigma TPCTOF: " << (1 << (Bit + 1)) << std::endl; + std::cout << "Bit for Nsigma ITS: " << (1 << Bit) << std::endl; + std::cout << "+++++++++++++++++++++++++++++++++" << std::endl; + } } } } @@ -362,6 +421,7 @@ class FemtoDreamCutculator boost::property_tree::ptree mConfigTree; ///< the dpl-config.json buffered into a ptree FemtoDreamTrackSelection mTrackSel; ///< for setting up the bit-wise selection container for tracks FemtoDreamV0Selection mV0Sel; ///< for setting up the bit-wise selection container for V0s + FemtoDreamCascadeSelection mCascadeSel; ///< for setting up the bit-wise selection container for Cascades std::vector mPIDspecies; ///< list of particle species for which PID is stored std::vector mPIDValues; ///< list of nsigma values for which PID is stored }; diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverse3DContainer.h b/PWGCF/FemtoUniverse/Core/FemtoUniverse3DContainer.h index 9d5eee9d2f5..864487cdcb0 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverse3DContainer.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverse3DContainer.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h index a6b80611649..4d267fb67d3 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -206,7 +206,7 @@ class FemtoUniverseAngularContainer const float mT = FemtoUniverseMath::getmT(part1, mMassOne, part2, mMassTwo); if (mHistogramRegistry) { - setPairBase(femtoObs, mT, part1, part2, mult, use3dplots); + setPairBase(femtoObs, mT, part1, part2, mult, use3dplots, weight); if constexpr (isMC) { if (part1.has_fdMCParticle() && part2.has_fdMCParticle()) { diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseCascadeSelection.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseCascadeSelection.h index 2b951e78353..3a389da705e 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseCascadeSelection.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseCascadeSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -23,18 +23,16 @@ #include #include - #include "PWGCF/FemtoUniverse/Core/FemtoUniverseObjectSelection.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseSelection.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" - #include "Common/Core/RecoDecay.h" #include "Framework/HistogramRegistry.h" #include "ReconstructionDataFormats/PID.h" -namespace o2::analysis::femto_universe // o2-linter: disable=name/namespace +namespace o2::analysis::femto_universe { -namespace femto_universe_cascade_selection // o2-linter: disable=name/namespace +namespace femto_universe_cascade_selection { /// The different selections this task is capable of doing enum CascadeSel { @@ -83,13 +81,13 @@ class FemtoUniverseCascadeSelection public: FemtoUniverseCascadeSelection() - : nPtCascadeMinSel(0), nPtCascadeMaxSel(0), nEtaCascadeMaxSel(0), nDCAV0DaughMax(0), nCPAV0Min(0), nTranRadV0Min(0), nTranRadV0Max(0), nV0DecVtxMax(0), nDCACascadeDaughMax(0), nCPACascadeMin(0), nTranRadCascadeMin(0), nTranRadCascadeMax(0), nDecVtxMax(0), nDCAPosToPV(0), nDCANegToPV(0), nDCABachToPV(0), nDCAV0ToPV(0), pTCascadeMin(9999999.), pTCascadeMax(-9999999.), etaCascadeMax(-9999999.), fDCAV0DaughMax(-9999999.), fCPAV0Min(9999999.), fTranRadV0Min(9999999.), fTranRadV0Max(-9999999.), fV0DecVtxMax(-9999999.), fDCACascadeDaughMax(-9999999.), fCPACascadeMin(9999999.), fTranRadCascadeMin(9999999.), fTranRadCascadeMax(-9999999.), fDecVtxMax(-9999999.), fDCAPosToPV(9999999.), fDCANegToPV(9999999.), fDCABachToPV(9999999.), fDCAV0ToPV(9999999.), fV0InvMassLowLimit(1.05), fV0InvMassUpLimit(1.3), fInvMassLowLimit(1.25), fInvMassUpLimit(1.4), fRejectCompetingMass(false), fInvMassCompetingLowLimit(1.5), fInvMassCompetingUpLimit(2.0), isCascOmega(false) /*, nSigmaPIDOffsetTPC(0.)*/ + : nPtCascadeMinSel(0), nPtCascadeMaxSel(0), nEtaCascadeMaxSel(0), nDCAV0DaughMax(0), nCPAV0Min(0), nTranRadV0Min(0), nTranRadV0Max(0), nV0DecVtxMax(0), nDCACascadeDaughMax(0), nCPACascadeMin(0), nTranRadCascadeMin(0), nTranRadCascadeMax(0), nDecVtxMax(0), nDCAPosToPV(0), nDCANegToPV(0), nDCABachToPV(0), nDCAV0ToPV(0), pTCascadeMin(9999999.), pTCascadeMax(-9999999.), etaCascadeMax(-9999999.), fDCAV0DaughMax(-9999999.), fCPAV0Min(9999999.), fTranRadV0Min(9999999.), fTranRadV0Max(-9999999.), fV0DecVtxMax(-9999999.), fDCACascadeDaughMax(-9999999.), fCPACascadeMin(9999999.), fTranRadCascadeMin(9999999.), fTranRadCascadeMax(-9999999.), fDecVtxMax(-9999999.), fDCAPosToPV(9999999.), fDCANegToPV(9999999.), fDCABachToPV(9999999.), fDCAV0ToPV(9999999.), fV0InvMassLowLimit(1.05), fV0InvMassUpLimit(1.3), fInvMassLowLimitXi(1.25), fInvMassUpLimitXi(1.4), fInvMassLowLimitOmega(1.6), fInvMassUpLimitOmega(1.8) /*, fRejectCompetingMass(false), fInvMassCompetingLowLimit(1.5), fInvMassCompetingUpLimit(2.0), nSigmaPIDOffsetTPC(0.)*/ { } /// Initializes histograms for the task template - void init(HistogramRegistry* registry, bool isSelectCascOmega = false); + void init(HistogramRegistry* registry /*, bool isSelectCascOmega = false*/); template bool isSelectedMinimal(Col const& col, Casc const& cascade, Track const& posTrack, Track const& negTrack, Track const& bachTrack); @@ -155,21 +153,23 @@ class FemtoUniverseCascadeSelection /// Set limit for the selection on the invariant mass /// \param lowLimit Lower limit for the invariant mass distribution /// \param upLimit Upper limit for the invariant mass distribution - void setInvMassLimits(float lowLimit, float upLimit) + void setInvMassLimits(float lowLimitXi, float lowLimitOmega, float upLimitXi, float upLimitOmega) { - fInvMassLowLimit = lowLimit; - fInvMassUpLimit = upLimit; + fInvMassLowLimitXi = lowLimitXi; + fInvMassUpLimitXi = upLimitXi; + fInvMassLowLimitOmega = lowLimitOmega; + fInvMassUpLimitOmega = upLimitOmega; } /// Set limit for the omega rejection on the invariant mass /// \param lowLimit Lower limit for the invariant mass distribution /// \param upLimit Upper limit for the invariant mass distribution - void setCompetingInvMassLimits(float lowLimit, float upLimit) + /*void setCompetingInvMassLimits(float lowLimit, float upLimit) { fRejectCompetingMass = true; fInvMassCompetingLowLimit = lowLimit; fInvMassCompetingUpLimit = upLimit; - } + }*/ private: int nPtCascadeMinSel; @@ -210,14 +210,15 @@ class FemtoUniverseCascadeSelection float fV0InvMassLowLimit; float fV0InvMassUpLimit; - float fInvMassLowLimit; - float fInvMassUpLimit; + float fInvMassLowLimitXi; + float fInvMassUpLimitXi; - float fRejectCompetingMass; - float fInvMassCompetingLowLimit; - float fInvMassCompetingUpLimit; + float fInvMassLowLimitOmega; + float fInvMassUpLimitOmega; - bool isCascOmega; + /*float fRejectCompetingMass; + float fInvMassCompetingLowLimit; + float fInvMassCompetingUpLimit;*/ // float nSigmaPIDOffsetTPC; @@ -286,7 +287,7 @@ class FemtoUniverseCascadeSelection }; // namespace femto_universe template -void FemtoUniverseCascadeSelection::init(HistogramRegistry* registry, bool isSelectCascOmega) +void FemtoUniverseCascadeSelection::init(HistogramRegistry* registry) { if (registry) { @@ -336,7 +337,8 @@ void FemtoUniverseCascadeSelection::init(HistogramRegistry* registry, bool isSel // Cascade (Xi, Omega) // mHistogramRegistry->add("CascadeQA/hInvMassCascadeNoCuts", "No cuts", kTH1F, {massAxisCascade}); - mHistogramRegistry->add("CascadeQA/hInvMassCascadeCut", "Invariant mass with cut", kTH1F, {massAxisCascade}); + mHistogramRegistry->add("CascadeQA/hInvMassXiCut", "Invariant mass with cut", kTH1F, {massAxisCascade}); + mHistogramRegistry->add("CascadeQA/hInvMassOmegaCut", "Invariant mass with cut", kTH1F, {massAxisCascade}); mHistogramRegistry->add("CascadeQA/hCascadePt", "pT distribution", kTH1F, {ptAxis}); mHistogramRegistry->add("CascadeQA/hCascadeEta", "Eta distribution", kTH1F, {etaAxis}); mHistogramRegistry->add("CascadeQA/hCascadePhi", "Phi distribution", kTH1F, {phiAxis}); @@ -408,8 +410,6 @@ void FemtoUniverseCascadeSelection::init(HistogramRegistry* registry, bool isSel femto_universe_selection::kLowerLimit); fV0InvMassUpLimit = getMinimalSelection(femto_universe_cascade_selection::kCascadeV0MassMax, femto_universe_selection::kUpperLimit); - - isCascOmega = isSelectCascOmega; } template @@ -429,21 +429,23 @@ bool FemtoUniverseCascadeSelection::isSelectedMinimal(Col const& col, Casc const const float cpaCasc = cascade.casccosPA(col.posX(), col.posY(), col.posZ()); const float dcav0topv = cascade.dcav0topv(col.posX(), col.posY(), col.posZ()); const float invMassLambda = cascade.mLambda(); - const float invMass = isCascOmega ? cascade.mOmega() : cascade.mXi(); + const float invMassXi = cascade.mXi(); + const float invMassOmega = cascade.mOmega(); if (invMassLambda < fV0InvMassLowLimit || invMassLambda > fV0InvMassUpLimit) { return false; } - if (invMass < fInvMassLowLimit || invMass > fInvMassUpLimit) { + // Accepts the cascade candidates as either Xi or Omega but not both + if ((invMassXi < fInvMassLowLimitXi || invMassXi > fInvMassUpLimitXi) == (invMassOmega < fInvMassLowLimitOmega || invMassOmega > fInvMassUpLimitOmega)) { return false; } - if (fRejectCompetingMass) { + /*if (fRejectCompetingMass) { const float invMassCompeting = isCascOmega ? cascade.mXi() : cascade.mOmega(); if (invMassCompeting > fInvMassCompetingLowLimit && invMassCompeting < fInvMassCompetingUpLimit) { return false; } - } + }*/ if (nPtCascadeMinSel > 0 && cascade.pt() < pTCascadeMin) { return false; } @@ -539,10 +541,12 @@ void FemtoUniverseCascadeSelection::fillCascadeQA(Col const& col, Casc const& ca const float dcav0topv = cascade.dcav0topv(col.posX(), col.posY(), col.posZ()); const float invMassLambda = cascade.mLambda(); - const float invMass = isCascOmega ? cascade.mOmega() : cascade.mXi(); + const float invMassXi = cascade.mXi(); + const float invMassOmega = cascade.mOmega(); mHistogramRegistry->fill(HIST("CascadeQA/hInvMassV0Cut"), invMassLambda); - mHistogramRegistry->fill(HIST("CascadeQA/hInvMassCascadeCut"), invMass); + mHistogramRegistry->fill(HIST("CascadeQA/hInvMassXiCut"), invMassXi); + mHistogramRegistry->fill(HIST("CascadeQA/hInvMassOmegaCut"), invMassOmega); mHistogramRegistry->fill(HIST("CascadeQA/hCascadePt"), cascade.pt()); mHistogramRegistry->fill(HIST("CascadeQA/hCascadeEta"), cascade.eta()); mHistogramRegistry->fill(HIST("CascadeQA/hCascadePhi"), cascade.phi()); diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseCollisionSelection.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseCollisionSelection.h index fc33b37ad9a..633bba05760 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseCollisionSelection.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseCollisionSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h index e034ec66ba7..fb2af0a02df 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -20,18 +20,21 @@ #ifndef PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSECONTAINER_H_ #define PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSECONTAINER_H_ -#include -#include -#include +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h" +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" -#include "Framework/HistogramRegistry.h" #include "Common/Core/RecoDecay.h" -#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h" + +#include "Framework/HistogramRegistry.h" #include "Math/Vector4D.h" -#include "TMath.h" #include "TDatabasePDG.h" +#include "TMath.h" + +#include + +#include +#include using namespace o2::framework; @@ -176,7 +179,12 @@ class FemtoUniverseContainer deltaEta = part1.eta() - part2.eta(); deltaPhi = part1.phi() - part2.phi(); - deltaPhi = RecoDecay::constrainAngle(deltaPhi, 0); + while (deltaPhi < mPhiLow) { + deltaPhi += o2::constants::math::TwoPI; + } + while (deltaPhi > mPhiHigh) { + deltaPhi -= o2::constants::math::TwoPI; + } mHistogramRegistry->fill(HIST(FolderSuffix[EventType]) + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/relPairDist"), femtoObs, weight); mHistogramRegistry->fill(HIST(FolderSuffix[EventType]) + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/relPairkT"), kT, weight); @@ -222,12 +230,16 @@ class FemtoUniverseContainer /// \param part2 Particle two /// \param mult Multiplicity of the event template - void setPair(T const& part1, T const& part2, const int mult, bool use3dplots, float weight = 1.0f) + void setPair(T const& part1, T const& part2, const int mult, bool use3dplots, float weight = 1.0f, bool isiden = false) { float femtoObs, femtoObsMC; // Calculate femto observable and the mT with reconstructed information if constexpr (FemtoObs == femto_universe_container::Observable::kstar) { - femtoObs = FemtoUniverseMath::getkstar(part1, mMassOne, part2, mMassTwo); + if (!isiden) { + femtoObs = FemtoUniverseMath::getkstar(part1, mMassOne, part2, mMassTwo); + } else { + femtoObs = 2.0 * FemtoUniverseMath::getkstar(part1, mMassOne, part2, mMassTwo); + } } const float mT = FemtoUniverseMath::getmT(part1, mMassOne, part2, mMassTwo); @@ -238,7 +250,11 @@ class FemtoUniverseContainer if (part1.has_fdMCParticle() && part2.has_fdMCParticle()) { // calculate the femto observable and the mT with MC truth information if constexpr (FemtoObs == femto_universe_container::Observable::kstar) { - femtoObsMC = FemtoUniverseMath::getkstar(part1.fdMCParticle(), mMassOne, part2.fdMCParticle(), mMassTwo); + if (!isiden) { + femtoObsMC = FemtoUniverseMath::getkstar(part1.fdMCParticle(), mMassOne, part2.fdMCParticle(), mMassTwo); + } else { + femtoObsMC = 2.0 * FemtoUniverseMath::getkstar(part1.fdMCParticle(), mMassOne, part2.fdMCParticle(), mMassTwo); + } } const float mTMC = FemtoUniverseMath::getmT(part1.fdMCParticle(), mMassOne, part2.fdMCParticle(), mMassTwo); diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseCutculator.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseCutculator.h index 863ecee389d..40b7c425e5c 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseCutculator.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseCutculator.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h index f891823ccf5..65344e45bba 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -14,20 +14,24 @@ /// \author Laura Serksnyte, TU München, laura.serksnyte@tum.de /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch /// \author Pritam Chakraborty, WUT Warsaw, pritam.chakraborty@cern.ch +/// \author Shirajum Monira, WUT Warsaw, shirajum.monira@cern.ch #ifndef PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEDETADPHISTAR_H_ #define PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEDETADPHISTAR_H_ -#include -#include -#include -#include "TMath.h" -#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseFemtoContainer.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h" -#include "Framework/HistogramRegistry.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseFemtoContainer.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" + +#include "Framework/HistogramRegistry.h" + +#include "TMath.h" + +#include +#include +#include namespace o2::analysis { @@ -46,7 +50,7 @@ class FemtoUniverseDetaDphiStar /// Destructor virtual ~FemtoUniverseDetaDphiStar() = default; /// Initialization of the histograms and setting required values - void init(HistogramRegistry* registry, HistogramRegistry* registryQA, float ldeltaphistarcutmin, float ldeltaphistarcutmax, float ldeltaetacutmin, float ldeltaetacutmax, float lchosenradii, bool lplotForEveryRadii, float lPhiMassMin = 1.014, float lPhiMassMax = 1.026) + void init(HistogramRegistry* registry, HistogramRegistry* registryQA, float ldeltaphistarcutmin, float ldeltaphistarcutmax, float ldeltaetacutmin, float ldeltaetacutmax, float lchosenradii, bool lplotForEveryRadii, float lPhiMassMin = 1.014, float lPhiMassMax = 1.026, bool lisSameSignCPR = false) { chosenRadii = lchosenradii; cutDeltaPhiStarMax = ldeltaphistarcutmax; @@ -58,6 +62,7 @@ class FemtoUniverseDetaDphiStar mHistogramRegistryQA = registryQA; cutPhiInvMassLow = lPhiMassMin; cutPhiInvMassHigh = lPhiMassMax; + isSameSignCPR = lisSameSignCPR; if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { std::string dirName = static_cast(DirNames[0]); @@ -66,6 +71,9 @@ class FemtoUniverseDetaDphiStar histdetadpimixed[0][0] = mHistogramRegistry->add((dirName + static_cast(HistNamesMixed[0][0])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); histdetadpimixed[0][1] = mHistogramRegistry->add((dirName + static_cast(HistNamesMixed[1][0])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + histdetadpiqlcmssame = mHistogramRegistry->add((dirName + static_cast(HistNamesSame[1][7])).c_str(), "; #it{q}_{LCMS}; #Delta #eta; #Delta #phi", kTH3F, {{100, 0.0, 0.5}, {100, -0.15, 0.15}, {100, -0.15, 0.15}}); + histdetadpiqlcmsmixed = mHistogramRegistry->add((dirName + static_cast(HistNamesMixed[1][7])).c_str(), "; #it{q}_{LCMS}; #Delta #eta; #Delta #phi", kTH3F, {{100, 0.0, 0.5}, {100, -0.15, 0.15}, {100, -0.15, 0.15}}); + if (plotForEveryRadii) { for (int i = 0; i < 9; i++) { histdetadpiRadii[0][i] = mHistogramRegistryQA->add((dirName + static_cast(HistNamesRadii[0][i])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); @@ -102,6 +110,21 @@ class FemtoUniverseDetaDphiStar } } } + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kCascade && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { + /// Xi-Xi and Omega-Omega combination + for (int k = 0; k < 7; k++) { + std::string dirName = static_cast(DirNames[5]); + histdetadpisame[k][0] = mHistogramRegistry->add((dirName + static_cast(HistNamesSame[0][k])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + histdetadpisame[k][1] = mHistogramRegistry->add((dirName + static_cast(HistNamesSame[1][k])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + histdetadpimixed[k][0] = mHistogramRegistry->add((dirName + static_cast(HistNamesMixed[0][k])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + histdetadpimixed[k][1] = mHistogramRegistry->add((dirName + static_cast(HistNamesMixed[1][k])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + if (plotForEveryRadii) { + for (int l = 0; l < 9; l++) { + histdetadpiRadii[k][l] = mHistogramRegistryQA->add((dirName + static_cast(HistNamesRadii[k][l])).c_str(), "; #Delta #eta; #Delta #phi", kTH2F, {{100, -0.15, 0.15}, {100, -0.15, 0.15}}); + } + } + } + } if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kPhi) { for (int i = 0; i < 2; i++) { std::string dirName = static_cast(DirNames[3]); @@ -209,7 +232,6 @@ class FemtoUniverseDetaDphiStar } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kV0 && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kV0) { /// V0-V0 combination - // check if provided particles are in agreement with the class instantiation if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kV0 || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kV0) { LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kV0,kV0 candidates."; return false; @@ -246,6 +268,46 @@ class FemtoUniverseDetaDphiStar } return pass; + } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kCascade && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { + /// Xi-Xi and Omega-Omega combination + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kCascade,kCascade candidates."; + return false; + } + + bool pass = false; + static constexpr int CascChildTable[][2] = {{-1, -1}, {-1, -2}, {-1, -3}, {-2, -2}, {-3, -3}, {-2, -1}, {-3, -1}}; + for (int i = 0; i < 5; i++) { + auto indexOfDaughterpart1 = (ChosenEventType == femto_universe_container::EventType::mixed ? part1.globalIndex() : part1.index()) + CascChildTable[i][0]; + auto indexOfDaughterpart2 = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) + CascChildTable[i][1]; + auto daughterpart1 = particles.begin() + indexOfDaughterpart1; + auto daughterpart2 = particles.begin() + indexOfDaughterpart2; + if (isSameSignCPR && (daughterpart1.mAntiLambda() != daughterpart2.mAntiLambda())) // mAntiLambda() is used here as sign getter + continue; + auto deta = daughterpart1.eta() - daughterpart2.eta(); + auto dphiAvg = averagePhiStar(*daughterpart1, *daughterpart2, i); + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][0]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][0]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + + if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) { + pass = true; + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[i][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[i][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + } + } + return pass; + } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kD0) { /// Track-D0 combination // check if provided particles are in agreement with the class instantiation @@ -351,22 +413,122 @@ class FemtoUniverseDetaDphiStar } } + /// Check if pair is close or not + template + bool isClosePairFrac(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, bool IsDphiAvgOrDist, float DistMax, float FracMax) + { + magfield = lmagfield; + + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { + /// Track-Track combination + // check if provided particles are in agreement with the class instantiation + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack) { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar instantiation! Please provide kTrack,kTrack candidates."; + return false; + } + auto deta = part1.eta() - part2.eta(); + auto dphiAvg = averagePhiStar(part1, part2, 0); + auto distfrac = averagePhiStarFrac(part1, part2, DistMax); + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[0][0]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[0][0]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + + if (IsDphiAvgOrDist) { + if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) { + return true; + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[0][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[0][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + return false; + } + } else { + if (distfrac > FracMax) { + return true; + } else { + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpisame[0][1]->Fill(deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpimixed[0][1]->Fill(deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + return false; + } + } + + } else { + LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!"; + return false; + } + } + + /// Check if pair is close or not + template + void ClosePairqLCMS(Part const& part1, Part const& part2, float lmagfield, uint8_t ChosenEventType, double qlcms) // add typename Parts and variable parts for adding MClabels + { + magfield = lmagfield; + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { + auto deta = part1.eta() - part2.eta(); + auto dphiAvg = averagePhiStar(part1, part2, 0); + + if (ChosenEventType == femto_universe_container::EventType::same) { + histdetadpiqlcmssame->Fill(qlcms, deta, dphiAvg); + } else if (ChosenEventType == femto_universe_container::EventType::mixed) { + histdetadpiqlcmsmixed->Fill(qlcms, deta, dphiAvg); + } else { + LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; + } + } + } + private: HistogramRegistry* mHistogramRegistry = nullptr; ///< For main output HistogramRegistry* mHistogramRegistryQA = nullptr; ///< For QA output - static constexpr std::string_view DirNames[5] = {"kTrack_kTrack/", "kTrack_kV0/", "kV0_kV0/", "kTrack_kPhi/", "kTrack_kD0/"}; - - static constexpr std::string_view HistNamesSame[2][2] = {{"detadphidetadphi0BeforeSame_0", "detadphidetadphi0BeforeSame_1"}, - {"detadphidetadphi0AfterSame_0", "detadphidetadphi0AfterSame_1"}}; - static constexpr std::string_view HistNamesMixed[2][2] = {{"detadphidetadphi0BeforeMixed_0", "detadphidetadphi0BeforeMixed_1"}, - {"detadphidetadphi0AfterMixed_0", "detadphidetadphi0AfterMixed_1"}}; - - static constexpr std::string_view HistNamesRadii[2][9] = {{"detadphidetadphi0Before_0_0", "detadphidetadphi0Before_0_1", "detadphidetadphi0Before_0_2", + static constexpr std::string_view DirNames[6] = {"kTrack_kTrack/", "kTrack_kV0/", "kV0_kV0/", "kTrack_kPhi/", "kTrack_kD0/", "kCascade_kCascade/"}; + + static constexpr std::string_view HistNamesSame[2][8] = {{"detadphidetadphi0BeforeSame_0", "detadphidetadphi0BeforeSame_1", "detadphidetadphi0BeforeSame_2", + "detadphidetadphi0BeforeSame_3", "detadphidetadphi0BeforeSame_4", "detadphidetadphi0BeforeSame_5", + "detadphidetadphi0BeforeSame_6", "detadphidetadphi0BeforeSameqLCMS"}, + {"detadphidetadphi0AfterSame_0", "detadphidetadphi0AfterSame_1", "detadphidetadphi0AfterSame_2", + "detadphidetadphi0AfterSame_3", "detadphidetadphi0AfterSame_4", "detadphidetadphi0AfterSame_5", + "detadphidetadphi0AfterSame_6", "detadphidetadphi0AfterSameqLCMS"}}; + static constexpr std::string_view HistNamesMixed[2][8] = {{"detadphidetadphi0BeforeMixed_0", "detadphidetadphi0BeforeMixed_1", "detadphidetadphi0BeforeMixed_2", + "detadphidetadphi0BeforeMixed_3", "detadphidetadphi0BeforeMixed_4", "detadphidetadphi0BeforeMixed_5", + "detadphidetadphi0BeforeMixed_6", "detadphidetadphi0BeforeMixedqLCMS"}, + {"detadphidetadphi0AfterMixed_0", "detadphidetadphi0AfterMixed_1", "detadphidetadphi0AfterMixed_2", + "detadphidetadphi0AfterMixed_3", "detadphidetadphi0AfterMixed_4", "detadphidetadphi0AfterMixed_5", + "detadphidetadphi0AfterMixed_6", "detadphidetadphi0AfterMixedqLCMS"}}; + + static constexpr std::string_view HistNamesRadii[7][9] = {{"detadphidetadphi0Before_0_0", "detadphidetadphi0Before_0_1", "detadphidetadphi0Before_0_2", "detadphidetadphi0Before_0_3", "detadphidetadphi0Before_0_4", "detadphidetadphi0Before_0_5", "detadphidetadphi0Before_0_6", "detadphidetadphi0Before_0_7", "detadphidetadphi0Before_0_8"}, {"detadphidetadphi0Before_1_0", "detadphidetadphi0Before_1_1", "detadphidetadphi0Before_1_2", "detadphidetadphi0Before_1_3", "detadphidetadphi0Before_1_4", "detadphidetadphi0Before_1_5", - "detadphidetadphi0Before_1_6", "detadphidetadphi0Before_1_7", "detadphidetadphi0Before_1_8"}}; + "detadphidetadphi0Before_1_6", "detadphidetadphi0Before_1_7", "detadphidetadphi0Before_1_8"}, + {"detadphidetadphi0Before_2_0", "detadphidetadphi0Before_2_1", "detadphidetadphi0Before_2_2", + "detadphidetadphi0Before_2_3", "detadphidetadphi0Before_2_4", "detadphidetadphi0Before_2_5", + "detadphidetadphi0Before_2_6", "detadphidetadphi0Before_2_7", "detadphidetadphi0Before_2_8"}, + {"detadphidetadphi0Before_3_0", "detadphidetadphi0Before_3_1", "detadphidetadphi0Before_3_2", + "detadphidetadphi0Before_3_3", "detadphidetadphi0Before_3_4", "detadphidetadphi0Before_3_5", + "detadphidetadphi0Before_3_6", "detadphidetadphi0Before_3_7", "detadphidetadphi0Before_3_8"}, + {"detadphidetadphi0Before_4_0", "detadphidetadphi0Before_4_1", "detadphidetadphi0Before_4_2", + "detadphidetadphi0Before_4_3", "detadphidetadphi0Before_4_4", "detadphidetadphi0Before_4_5", + "detadphidetadphi0Before_4_6", "detadphidetadphi0Before_4_7", "detadphidetadphi0Before_4_8"}, + {"detadphidetadphi0Before_5_0", "detadphidetadphi0Before_5_1", "detadphidetadphi0Before_5_2", + "detadphidetadphi0Before_5_3", "detadphidetadphi0Before_5_4", "detadphidetadphi0Before_5_5", + "detadphidetadphi0Before_5_6", "detadphidetadphi0Before_5_7", "detadphidetadphi0Before_5_8"}, + {"detadphidetadphi0Before_6_0", "detadphidetadphi0Before_6_1", "detadphidetadphi0Before_6_2", + "detadphidetadphi0Before_6_3", "detadphidetadphi0Before_6_4", "detadphidetadphi0Before_6_5", + "detadphidetadphi0Before_6_6", "detadphidetadphi0Before_6_7", "detadphidetadphi0Before_6_8"}}; static constexpr o2::aod::femtouniverseparticle::ParticleType kPartOneType = partOne; ///< Type of particle 1 static constexpr o2::aod::femtouniverseparticle::ParticleType kPartTwoType = partTwo; ///< Type of particle 2 @@ -386,10 +548,14 @@ class FemtoUniverseDetaDphiStar bool plotForEveryRadii = false; float cutPhiInvMassLow; float cutPhiInvMassHigh; + bool isSameSignCPR = false; - std::array, 2>, 2> histdetadpisame{}; - std::array, 2>, 2> histdetadpimixed{}; - std::array, 9>, 2> histdetadpiRadii{}; + std::array, 2>, 7> histdetadpisame{}; + std::array, 2>, 7> histdetadpimixed{}; + std::array, 9>, 7> histdetadpiRadii{}; + + std::shared_ptr histdetadpiqlcmssame{}; + std::shared_ptr histdetadpiqlcmsmixed{}; /// Calculate phi at all required radii stored in TmpRadiiTPC /// Magnetic field to be provided in Tesla @@ -414,7 +580,7 @@ class FemtoUniverseDetaDphiStar for (size_t i = 0; i < 9; i++) { double arg = 0.3 * charge * magfield * TmpRadiiTPC[i] * 0.01 / (2. * pt); if (std::abs(arg) < 1.0) { - tmpVec.push_back(phi0 - std::asin(arg)); + tmpVec.push_back(phi0 + std::asin(arg)); } else { tmpVec.push_back(999.0); } @@ -449,6 +615,36 @@ class FemtoUniverseDetaDphiStar return dPhiAvg / static_cast(entries); } + /// Calculate average phi + template + float averagePhiStarFrac(const T1& part1, const T2& part2, float maxdist) + { + std::vector tmpVec1; + std::vector tmpVec2; + phiAtRadiiTPC(part1, tmpVec1); + phiAtRadiiTPC(part2, tmpVec2); + int num = tmpVec1.size(); + float dphi = 0; + int entries = 0; + double distance = 0; + int badpoints = 0; + + for (int i = 0; i < num; i++) { + if (tmpVec1.at(i) != 999 && tmpVec2.at(i) != 999) { + dphi = tmpVec1.at(i) - tmpVec2.at(i); + entries++; + } else { + dphi = 0; + } + dphi = TVector2::Phi_mpi_pi(dphi); + distance = 2 * TMath::Sin(TMath::Abs(dphi) * 0.5) * TmpRadiiTPC[i]; + if (distance < maxdist) { + badpoints++; + } + } + return badpoints / entries; + } + // Get particle charge from mask template float getCharge(const T1& part) diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCalculator.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCalculator.h new file mode 100644 index 00000000000..a96b70180aa --- /dev/null +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCalculator.h @@ -0,0 +1,164 @@ +// Copyright 2019-2025 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. + +/// \file FemtoUniverseEfficiencyCalculator.h +/// \brief Abstraction for applying corrections based on efficiency from CCDB +/// \author Dawid Karpiński, WUT Warsaw, dawid.karpinski@cern.ch + +#ifndef PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEEFFICIENCYCALCULATOR_H_ +#define PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEEFFICIENCYCALCULATOR_H_ + +#include +#include +#include +#include + +#include "Framework/Configurable.h" +#include "CCDB/BasicCCDBManager.h" +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" +#include "FemtoUniverseParticleHisto.h" + +namespace o2::analysis::femto_universe::efficiency +{ +enum ParticleNo : size_t { + ONE = 1, + TWO, +}; + +template +concept isOneOrTwo = T == ParticleNo::ONE || T == ParticleNo::TWO; + +template +consteval auto getHistDim() -> int +{ + if (std::is_same_v) + return 1; + else if (std::is_same_v) + return 2; + else if (std::is_same_v) + return 3; + else + return -1; +} + +struct EfficiencyConfigurableGroup : ConfigurableGroup { + Configurable confEfficiencyApplyCorrections{"confEfficiencyApplyCorrections", false, "Should apply corrections from efficiency"}; + Configurable confEfficiencyCCDBTrainNumber{"confEfficiencyCCDBTrainNumber", 0, "Train number for which to query CCDB objects (set 0 to ignore)"}; + Configurable> confEfficiencyCCDBTimestamps{"confEfficiencyCCDBTimestamps", {}, "Timestamps of efficiency histograms in CCDB, to query for specific objects (default: [], set 0 to ignore, useful when running subwagons)"}; + + // NOTE: in the future we might move the below configurables to a separate struct, eg. CCDBConfigurableGroup + Configurable confCCDBUrl{"confCCDBUrl", "http://alice-ccdb.cern.ch", "CCDB URL to be used"}; + Configurable confCCDBPath{"confCCDBPath", "", "CCDB base path to where to upload objects"}; +}; + +template + requires std::is_base_of_v +class EfficiencyCalculator +{ + public: + explicit EfficiencyCalculator(EfficiencyConfigurableGroup* config) : config(config) // o2-linter: disable=name/function-variable + { + } + + auto init() -> void + { + ccdb.setURL(config->confCCDBUrl); + ccdb.setLocalObjectValidityChecking(); + ccdb.setFatalWhenNull(false); + + auto now = duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb.setCreatedNotAfter(now); + + shouldApplyCorrections = config->confEfficiencyApplyCorrections; + + if (config->confEfficiencyApplyCorrections && !config->confEfficiencyCCDBTimestamps.value.empty()) { + for (auto idx = 0UL; idx < config->confEfficiencyCCDBTimestamps.value.size(); idx++) { + auto timestamp = 0L; + try { + timestamp = std::max(0L, std::stol(config->confEfficiencyCCDBTimestamps.value[idx])); + } catch (const std::exception&) { + LOGF(error, notify("Could not parse CCDB timestamp \"%s\""), config->confEfficiencyCCDBTimestamps.value[idx]); + continue; + } + + hLoaded[idx] = timestamp > 0 ? loadEfficiencyFromCCDB(timestamp) : nullptr; + } + } + } + + template + requires(sizeof...(BinVars) == getHistDim()) + auto getWeight(ParticleNo partNo, const BinVars&... binVars) const -> float + { + auto weight = 1.0f; + auto hEff = hLoaded[partNo - 1]; + + if (shouldApplyCorrections && hEff) { + auto bin = hEff->FindBin(binVars...); + auto eff = hEff->GetBinContent(bin); + weight /= eff > 0 ? eff : 1.0f; + } + + return weight; + } + + private: + static inline auto notify(const std::string& msg) -> const std::string + { + return fmt::format("[EFFICIENCY] {}", msg); + } + + static auto isHistEmpty(HistType* hist) -> bool + { + if (!hist) { + return true; + } + for (auto idx = 0; idx <= hist->GetNbinsX() + 1; idx++) { + if (hist->GetBinContent(idx) > 0) { + return false; + } + } + return true; + } + + auto loadEfficiencyFromCCDB(const int64_t timestamp) const -> HistType* + { + std::map metadata{}; + + if (config->confEfficiencyCCDBTrainNumber > 0) { + metadata["trainNumber"] = std::to_string(config->confEfficiencyCCDBTrainNumber); + } + + auto hEff = ccdb.getSpecific(config->confCCDBPath, timestamp, metadata); + if (!hEff || hEff->IsZombie()) { + LOGF(error, notify("Could not load histogram \"%s/%ld\""), config->confCCDBPath.value, timestamp); + return nullptr; + } + + if (isHistEmpty(hEff)) { + LOGF(warn, notify("Histogram \"%s/%ld\" has been loaded, but it is empty"), config->confCCDBPath.value, timestamp); + } + + LOGF(info, notify("Successfully loaded %ld"), timestamp); + return hEff; + } + + EfficiencyConfigurableGroup* config{}; + + bool shouldApplyCorrections = false; + + o2::ccdb::BasicCCDBManager& ccdb{o2::ccdb::BasicCCDBManager::instance()}; + std::array hLoaded{}; +}; + +} // namespace o2::analysis::femto_universe::efficiency + +#endif // PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEEFFICIENCYCALCULATOR_H_ diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCorrection.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCorrection.h new file mode 100644 index 00000000000..74e37d27a66 --- /dev/null +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCorrection.h @@ -0,0 +1,294 @@ +// Copyright 2019-2025 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. + +/// \file FemtoUniverseEfficiencyCorrection.h +/// \brief Abstraction for applying efficiency corrections based on weights from CCDB +/// \author Dawid Karpiński, WUT Warsaw, dawid.karpinski@cern.ch + +#ifndef PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEEFFICIENCYCORRECTION_H_ +#define PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEEFFICIENCYCORRECTION_H_ + +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +namespace o2::analysis::femto_universe::efficiency_correction +{ +enum ParticleNo : size_t { + ONE = 1, + TWO, +}; + +template +concept IsOneOrTwo = T == ParticleNo::ONE || T == ParticleNo::TWO; + +struct EffCorConfigurableGroup : framework::ConfigurableGroup { + framework::Configurable confEffCorApply{"confEffCorApply", false, "[Efficiency Correction] Should apply efficiency corrections"}; + framework::Configurable confEffCorFillHist{"confEffCorFillHist", false, "[Efficiency Correction] Should fill histograms for efficiency corrections"}; + framework::Configurable confEffCorCCDBUrl{"confEffCorCCDBUrl", "http://alice-ccdb.cern.ch", "[Efficiency Correction] CCDB URL to use"}; + framework::Configurable confEffCorCCDBPath{"confEffCorCCDBPath", "", "[Efficiency Correction] CCDB path to histograms"}; + framework::Configurable> confEffCorCCDBTimestamps{"confEffCorCCDBTimestamps", {}, "[Efficiency Correction] Timestamps of histograms in CCDB (0 can be used as a placeholder, e.g. when running subwagons)"}; + framework::Configurable confEffCorVariables{"confEffCorVariables", "pt", "[Efficiency Correction] Variables for efficiency correction histogram dimensions (available: 'pt'; 'pt,eta'; 'pt,mult'; 'pt,eta,mult')"}; + framework::Configurable confEffCorSetMultToConst{"confEffCorSetMultToConst", false, "[Efficiency Correction] Multiplicity for the histograms set to the constant value"}; +}; + +class EfficiencyCorrection +{ + public: + explicit EfficiencyCorrection(EffCorConfigurableGroup* config) : config(config) // o2-linter: disable=name/function-variable + { + } + + auto init(framework::HistogramRegistry* registry, std::vector axisSpecs) -> void + { + shouldFillHistograms = config->confEffCorFillHist; + shouldSetMultToConst = config->confEffCorSetMultToConst; + + histRegistry = registry; + if (shouldFillHistograms) { + for (const auto& suffix : histSuffix) { + auto path = std::format("{}/{}", histDirectory, suffix); + registry->add((path + "/hMCTruth").c_str(), "MCTruth; #it{p}_{T} (GeV/#it{c}); #it{#eta}; Mult", framework::kTH3F, axisSpecs); + registry->add((path + "/hPrimary").c_str(), "Primary; #it{p}_{T} (GeV/#it{c}); #it{#eta}; Mult", framework::kTH3F, axisSpecs); + registry->add((path + "/hSecondary").c_str(), "Secondary; #it{p}_{T} (GeV/#it{c}); #it{#eta}; Mult", framework::kTH3F, axisSpecs); + registry->add((path + "/hMaterial").c_str(), "Material; #it{p}_{T} (GeV/#it{c}); #it{#eta}; Mult", framework::kTH3F, axisSpecs); + registry->add((path + "/hFake").c_str(), "Fake; #it{p}_{T} (GeV/#it{c}); #it{#eta}; Mult", framework::kTH3F, axisSpecs); + registry->add((path + "/hOther").c_str(), "Other; #it{p}_{T} (GeV/#it{c}); #it{#eta}; Mult", framework::kTH3F, axisSpecs); + } + } + + ccdb.setURL(config->confEffCorCCDBUrl); + ccdb.setLocalObjectValidityChecking(); + ccdb.setFatalWhenNull(false); + + auto now = duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb.setCreatedNotAfter(now); + + shouldApplyCorrection = config->confEffCorApply; + + if (shouldApplyCorrection && !config->confEffCorCCDBTimestamps.value.empty()) { + for (auto idx = 0UL; idx < config->confEffCorCCDBTimestamps.value.size(); idx++) { + auto timestamp = 0L; + try { + timestamp = std::max(0L, std::stol(config->confEffCorCCDBTimestamps.value[idx])); + } catch (const std::exception&) { + LOGF(error, notify("Could not parse CCDB timestamp \"%s\""), config->confEffCorCCDBTimestamps.value[idx]); + continue; + } + + if (timestamp > 0) { + switch (getDimensionFromVariables()) { + case 1: + hLoaded[idx] = loadHistFromCCDB(timestamp); + break; + case 2: + hLoaded[idx] = loadHistFromCCDB(timestamp); + break; + case 3: + hLoaded[idx] = loadHistFromCCDB(timestamp); + break; + default: + LOGF(fatal, notify("Unknown configuration for efficiency variables")); + break; + } + } + } + } + } + + template + requires IsOneOrTwo + void fillTruthHist(auto particle) + { + if (!shouldFillHistograms) { + return; + } + + histRegistry->fill(HIST(histDirectory) + HIST("/") + HIST(histSuffix[N - 1]) + HIST("/hMCTruth"), + particle.pt(), + particle.eta(), + shouldSetMultToConst ? 100 : particle.template fdCollision_as().multV0M()); + } + + template + requires IsOneOrTwo + void fillRecoHist(auto particle, int particlePDG) + { + if (!shouldFillHistograms) { + return; + } + + if (!particle.has_fdMCParticle()) { + return; + } + + auto mcParticle = particle.fdMCParticle(); + + if (mcParticle.pdgMCTruth() == particlePDG) { + switch (mcParticle.partOriginMCTruth()) { + case (o2::aod::femtouniverse_mc_particle::kPrimary): + histRegistry->fill(HIST(histDirectory) + HIST("/") + HIST(histSuffix[N - 1]) + HIST("/hPrimary"), + mcParticle.pt(), + mcParticle.eta(), + particle.template fdCollision_as().multV0M()); + break; + + case (o2::aod::femtouniverse_mc_particle::kDaughter): + case (o2::aod::femtouniverse_mc_particle::kDaughterLambda): + case (o2::aod::femtouniverse_mc_particle::kDaughterSigmaplus): + histRegistry->fill(HIST(histDirectory) + HIST("/") + HIST(histSuffix[N - 1]) + HIST("/hSecondary"), + mcParticle.pt(), + mcParticle.eta(), + particle.template fdCollision_as().multV0M()); + break; + + case (o2::aod::femtouniverse_mc_particle::kMaterial): + histRegistry->fill(HIST(histDirectory) + HIST("/") + HIST(histSuffix[N - 1]) + HIST("/hMaterial"), + mcParticle.pt(), + mcParticle.eta(), + particle.template fdCollision_as().multV0M()); + break; + + case (o2::aod::femtouniverse_mc_particle::kFake): + histRegistry->fill(HIST(histDirectory) + HIST("/") + HIST(histSuffix[N - 1]) + HIST("/hFake"), + mcParticle.pt(), + mcParticle.eta(), + particle.template fdCollision_as().multV0M()); + break; + + default: + histRegistry->fill(HIST(histDirectory) + HIST("/") + HIST(histSuffix[N - 1]) + HIST("/hOther"), + mcParticle.pt(), + mcParticle.eta(), + particle.template fdCollision_as().multV0M()); + break; + } + } + } + + template + auto getWeight(ParticleNo partNo, auto particle) -> float + { + auto weight = 1.0f; + auto hWeights = hLoaded[partNo - 1]; + + if (shouldApplyCorrection && hWeights) { + auto dim = static_cast(hWeights->GetDimension()); + if (dim != getDimensionFromVariables()) { + LOGF(fatal, notify("Histogram \"%s\" has wrong dimension %d != %d"), config->confEffCorCCDBPath.value, dim, config->confEffCorVariables.value.size()); + return weight; + } + + auto bin = -1; + if (config->confEffCorVariables.value == "pt") { + bin = hWeights->FindBin(particle.pt()); + } else if (config->confEffCorVariables.value == "pt,eta") { + bin = hWeights->FindBin(particle.pt(), particle.eta()); + } else if (config->confEffCorVariables.value == "pt,mult") { + bin = hWeights->FindBin(particle.pt(), particle.template fdCollision_as().multV0M()); + } else if (config->confEffCorVariables.value == "pt,eta,mult") { + bin = hWeights->FindBin(particle.pt(), particle.eta(), particle.template fdCollision_as().multV0M()); + } else { + LOGF(fatal, notify("Unknown configuration for efficiency variables")); + return weight; + } + + weight = hWeights->GetBinContent(bin); + } + + return weight; + } + + private: + static inline auto notify(const std::string& msg) -> const std::string + { + return fmt::format("[EFFICIENCY CORRECTION] {}", msg); + } + + static auto isHistEmpty(TH1* hist) -> bool + { + if (!hist) { + return true; + } + + const int nBinsX = hist->GetNbinsX() + 2; + const int nBinsY = hist->GetNbinsY() + 2; + const int nBinsZ = hist->GetNbinsZ() + 2; + + for (int x = 0; x < nBinsX; ++x) { + for (int y = 0; y < nBinsY; ++y) { + for (int z = 0; z < nBinsZ; ++z) { + if (hist->GetBinContent(x, y, z) != 0) { + return false; + } + } + } + } + + return true; + } + + template + auto loadHistFromCCDB(const int64_t timestamp) const -> H* + { + auto hWeights = ccdb.getForTimeStamp(config->confEffCorCCDBPath, timestamp); + if (!hWeights || hWeights->IsZombie()) { + LOGF(error, notify("Could not load histogram \"%s/%ld\""), config->confEffCorCCDBPath.value, timestamp); + return nullptr; + } + + if (isHistEmpty(hWeights)) { + LOGF(warn, notify("Histogram \"%s/%ld\" has been loaded, but it is empty"), config->confEffCorCCDBPath.value, timestamp); + } + + auto clonedHist = static_cast(hWeights->Clone()); + clonedHist->SetDirectory(nullptr); + + LOGF(info, notify("Successfully loaded %ld"), timestamp); + return clonedHist; + } + + auto getDimensionFromVariables() -> size_t + { + auto parts = std::views::split(config->confEffCorVariables.value, ','); + return std::ranges::distance(parts); + } + + EffCorConfigurableGroup* config{}; + + bool shouldApplyCorrection{false}; + bool shouldFillHistograms{false}; + bool shouldSetMultToConst{false}; + + o2::ccdb::BasicCCDBManager& ccdb{o2::ccdb::BasicCCDBManager::instance()}; + std::array hLoaded{nullptr, nullptr}; + + framework::HistogramRegistry* histRegistry{}; + static constexpr std::string_view histDirectory{"EfficiencyCorrection"}; + static constexpr std::string_view histSuffix[2]{"one", "two"}; +}; + +} // namespace o2::analysis::femto_universe::efficiency_correction + +#endif // PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEEFFICIENCYCORRECTION_H_ diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h index 36e81e81e76..03d4b5b1fb4 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseFemtoContainer.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseFemtoContainer.h index e973cadee90..4719561ccf6 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseFemtoContainer.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseFemtoContainer.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h index 58fa2e943d9..ec40ea035e6 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseObjectSelection.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseObjectSelection.h index 18281ac198b..07491f92c8f 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseObjectSelection.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseObjectSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h b/PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h index 0a94c2c5a0c..b27d8e25abf 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -14,6 +14,7 @@ /// \author Andi Mathis, TU München, andreas.mathis@ph.tum.de /// \author Laura Serksnyte, TU München,laura.serksnyte@cern.ch /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch +/// \author Shirajum Monira, WUT Warsaw, shirajum.monira@cern.ch #ifndef PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEPAIRCLEANER_H_ #define PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEPAIRCLEANER_H_ @@ -112,6 +113,41 @@ class FemtoUniversePairCleaner return false; } return part1.globalIndex() != part2.globalIndex(); + } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kCascade && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { + /// Cascade-Cascade combination both part1 and part2 are cascades + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoUniversePairCleaner: passed arguments don't agree with FemtoUniversePairCleaner instantiation! Please provide first and second arguments kCascade candidate."; + return false; + } + // Getting cascade children for part1 + const auto& posChild1 = particles.iteratorAt(part1.index() - 3); + const auto& negChild1 = particles.iteratorAt(part1.index() - 2); + const auto& bachelor1 = particles.iteratorAt(part1.index() - 1); + // Getting cascade children for part2 + const auto& posChild2 = particles.iteratorAt(part2.index() - 3); + const auto& negChild2 = particles.iteratorAt(part2.index() - 2); + const auto& bachelor2 = particles.iteratorAt(part2.index() - 1); + if (posChild1.globalIndex() == posChild2.globalIndex() || negChild1.globalIndex() == negChild2.globalIndex() || bachelor1.globalIndex() == bachelor2.globalIndex()) { + return false; + } + return part1.globalIndex() != part2.globalIndex(); + } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kV0 && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { + /// V0-Cascade combination where part1 is a V0 and part2 is a cascade + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kV0 || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoUniversePairCleaner: passed arguments don't agree with FemtoUniversePairCleaner instantiation! Please provide first argument kV0 candidate and second argument kCascade candidate."; + return false; + } + // part1 v0 children + const auto& posChild1 = particles.iteratorAt(part1.index() - 2); + const auto& negChild1 = particles.iteratorAt(part1.index() - 1); + // part2 cascade children + const auto& posChild2 = particles.iteratorAt(part2.index() - 3); + const auto& negChild2 = particles.iteratorAt(part2.index() - 2); + const auto& bachelor2 = particles.iteratorAt(part2.index() - 1); + if (posChild1.globalIndex() == posChild2.globalIndex() || negChild1.globalIndex() == negChild2.globalIndex() || posChild1.globalIndex() == bachelor2.globalIndex() || negChild1.globalIndex() == bachelor2.globalIndex()) { + return false; + } + return part1.globalIndex() != part2.globalIndex(); } else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kD0) { /// Track-D0 combination part1 is hadron and part2 is D0 if (part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kD0) { diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h b/PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h index 404fb540745..ea8626cbe32 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h index fd64d685416..dc46dae8df7 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -20,11 +20,13 @@ #ifndef PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEPARTICLEHISTO_H_ #define PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEPARTICLEHISTO_H_ -#include -#include #include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" -#include "Framework/HistogramRegistry.h" + #include "CommonConstants/MathConstants.h" +#include "Framework/HistogramRegistry.h" + +#include +#include using namespace o2::framework; // o2-linter: disable=using-directive @@ -55,7 +57,7 @@ class FemtoUniverseParticleHisto { std::string folderSuffix = static_cast(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]).c_str(); /// Histograms of the kinematic properties - mHistogramRegistry->add((folderName + folderSuffix + "/hPt").c_str(), "; #it{p}_{T} (GeV/#it{c}); Entries", kTH1F, {{240, 0, 6}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hPt").c_str(), "; #it{p}_{T} (GeV/#it{c}); Entries", kTH1F, {tempFitVarpTAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/hEta").c_str(), "; #eta; Entries", kTH1F, {{200, -1.5, 1.5}}); mHistogramRegistry->add((folderName + folderSuffix + "/hPhi").c_str(), "; #phi; Entries", kTH1F, {{200, 0, o2::constants::math::TwoPI}}); mHistogramRegistry->add((folderName + folderSuffix + "/hPhiEta").c_str(), "; #phi; #eta", kTH2F, {{200, 0, o2::constants::math::TwoPI}, {200, -1.5, 1.5}}); @@ -79,6 +81,7 @@ class FemtoUniverseParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hTPCcrossedRows").c_str(), "; TPC crossed rows; Entries", kTH1F, {{163, -0.5, 162.5}}); mHistogramRegistry->add((folderName + folderSuffix + "/hTPCfindableVsCrossed").c_str(), ";TPC findable clusters ; TPC crossed rows;", kTH2F, {{163, -0.5, 162.5}, {163, -0.5, 162.5}}); mHistogramRegistry->add((folderName + folderSuffix + "/hTPCshared").c_str(), "; TPC shared clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hTPCfractionSharedCls").c_str(), "; TPC fraction of shared clusters; Entries", kTH1F, {{100, 0.0, 100.0}}); mHistogramRegistry->add((folderName + folderSuffix + "/hITSclusters").c_str(), "; ITS clusters; Entries", kTH1F, {{10, -0.5, 9.5}}); mHistogramRegistry->add((folderName + folderSuffix + "/hITSclustersIB").c_str(), "; ITS clusters in IB; Entries", kTH1F, {{10, -0.5, 9.5}}); mHistogramRegistry->add((folderName + folderSuffix + "/hDCAz").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{z} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); @@ -106,7 +109,9 @@ class FemtoUniverseParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hDecayVtxY").c_str(), "; #it{Vtx}_{y} (cm)); Entries", kTH1F, {{2000, 0, 200}}); mHistogramRegistry->add((folderName + folderSuffix + "/hDecayVtxZ").c_str(), "; #it{Vtx}_{z} (cm); Entries", kTH1F, {{2000, 0, 200}}); mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassLambda").c_str(), "; M_{#Lambda}; Entries", kTH1F, {{2000, 1.f, 3.f}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassLambdaVsPt").c_str(), "; #it{p}_{T} (GeV/#it{c}); M_{#Lambda}; Entries", kTH2F, {{240, 0, 6}, {2000, 1.f, 3.f}}); mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassAntiLambda").c_str(), "; M_{#bar{#Lambda}}; Entries", kTH1F, {{2000, 1.f, 3.f}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassAntiLambdaVsPt").c_str(), "; #it{p}_{T} (GeV/#it{c}); M_{#Lambda}; Entries", kTH2F, {{240, 0, 6}, {2000, 1.f, 3.f}}); mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassLambdaAntiLambda").c_str(), "; M_{#Lambda}; M_{#bar{#Lambda}}", kTH2F, {{2000, 1.f, 3.f}, {2000, 1.f, 3.f}}); } else if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { mHistogramRegistry->add((folderName + folderSuffix + "/hDaughDCA").c_str(), "; DCA^{daugh} (cm); Entries", kTH1F, {{1000, 0, 10}}); @@ -114,8 +119,8 @@ class FemtoUniverseParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hDecayVtxX").c_str(), "; #it{Vtx}_{x} (cm); Entries", kTH1F, {{2000, 0, 200}}); mHistogramRegistry->add((folderName + folderSuffix + "/hDecayVtxY").c_str(), "; #it{Vtx}_{y} (cm)); Entries", kTH1F, {{2000, 0, 200}}); mHistogramRegistry->add((folderName + folderSuffix + "/hDecayVtxZ").c_str(), "; #it{Vtx}_{z} (cm); Entries", kTH1F, {{2000, 0, 200}}); - mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassCascade").c_str(), "; M_{Cascade}; Entries", kTH1F, {{2000, 1.f, 1.8f}}); - mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassAntiCascade").c_str(), "; M_{AntiCascade}; Entries", kTH1F, {{2000, 1.f, 1.8f}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassXi").c_str(), "; M_{Xi}; Entries", kTH1F, {{2000, 1.f, 1.8f}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hInvMassOmega").c_str(), "; M_{Omega}; Entries", kTH1F, {{2000, 1.f, 1.8f}}); } } @@ -127,25 +132,53 @@ class FemtoUniverseParticleHisto /// \param tempFitVarpTAxis axis object for the pT axis in the pT vs. tempFitVar plots /// \param tempFitVarAxis axis object for the tempFitVar axis template - void init_MC(std::string folderName, std::string /*tempFitVarAxisTitle*/, T& tempFitVarpTAxis, T& tempFitVarAxis) // o2-linter: disable=name/function-variable + void init_MC(std::string folderName, std::string /*tempFitVarAxisTitle*/, T& tempFitVarpTAxis, T& tempFitVarAxis, bool isDebug) // o2-linter: disable=name/function-variable { /// Particle-type specific histograms std::string folderSuffix = static_cast(o2::aod::femtouniverse_mc_particle::MCTypeName[o2::aod::femtouniverse_mc_particle::MCType::kTruth]).c_str(); - mHistogramRegistry->add((folderName + folderSuffix + "/hPt_ReconNoFake").c_str(), "; #it{p}_{T} (GeV/#it{c}); Entries", kTH1F, {{240, 0, 6}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hPt_ReconNoFake").c_str(), "; #it{p}_{T} (GeV/#it{c}); Entries", kTH1F, {tempFitVarpTAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hPDG").c_str(), "; PDG; Entries", kTH1I, {{6001, -3000, 3000}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hOrigin_MC").c_str(), "; Origin; Entries", kTH1I, {{100, 0, 100}}); + mHistogramRegistry->add((folderName + folderSuffix + "/hNoMCtruthCounter").c_str(), "; Counter; Entries", kTH1I, {{1, 0, 1}}); if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kTrack || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kCascadeBachelor || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kMCTruthTrack) { /// Track histograms - mHistogramRegistry->add((folderName + folderSuffix + "/hPDG").c_str(), "; PDG; Entries", kTH1I, {{6001, -3000, 3000}}); - mHistogramRegistry->add((folderName + folderSuffix + "/hOrigin_MC").c_str(), "; Origin; Entries", kTH1I, {{7, 0, 7}}); - mHistogramRegistry->add((folderName + folderSuffix + "/hNoMCtruthCounter").c_str(), "; Counter; Entries", kTH1I, {{1, 0, 1}}); - // DCA plots - mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Material").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); - mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Fake").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); - mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_DaughterLambda").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); - mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_DaughterSigmaplus").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); - mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Primary").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); - mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Daughter").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + if (isDebug) { + mHistogramRegistry->add((folderName + folderSuffix + "/Debug/hPDGmother_Primary").c_str(), "; PDG mother; Entries", kTH1I, {{6001, -3000.5, 3000.5}}); + mHistogramRegistry->add((folderName + folderSuffix + "/Debug/hPDGmother_Daughter").c_str(), "; PDG mother; Entries", kTH1I, {{6001, -3000.5, 3000.5}}); + mHistogramRegistry->add((folderName + folderSuffix + "/Debug/hPDGmother_Material").c_str(), "; PDG mother; Entries", kTH1I, {{6001, -3000.5, 3000.5}}); + mHistogramRegistry->add((folderName + folderSuffix + "/Debug/hPDGmother_WrongCollision").c_str(), "; PDG mother; Entries", kTH1I, {{6001, -3000.5, 3000.5}}); + mHistogramRegistry->add((folderName + folderSuffix + "/Debug/hPDGmother_Fake").c_str(), "; PDG mother; Entries", kTH1I, {{6001, -3000.5, 3000.5}}); + mHistogramRegistry->add((folderName + folderSuffix + "/Debug/hPDGmother_Else").c_str(), "; PDG mother; Entries", kTH1I, {{6001, -3000.5, 3000.5}}); + mHistogramRegistry->add((folderName + folderSuffix + "/Debug/hPDGmother_DaughterLambda").c_str(), "; PDG mother; Entries", kTH1I, {{12001, -6000.5, 6000.5}}); + mHistogramRegistry->add((folderName + folderSuffix + "/Debug/hPDGmother_DaughterSigmaplus").c_str(), "; PDG mother; Entries", kTH1I, {{12001, -6000.5, 6000.5}}); + + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Primary").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Daughter").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Material").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_WrongCollision").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Fake").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Else").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_DaughterLambda").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_DaughterSigmaplus").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_NoMCTruthOrigin").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hMisidentification").c_str(), "; #it{p}_{T} (GeV/#it{c}); Particle; Particle", kTH3F, {{4, 0, 4}, {4, 0, 4}, tempFitVarpTAxis}); + + } else { + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Primary").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Daughter").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Material").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_WrongCollision").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Fake").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_Else").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_NoMCTruthOrigin").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hMisidentification").c_str(), "; #it{p}_{T} (GeV/#it{c}); Particle; Particle", kTH3F, {{4, 0, 4}, {4, 0, 4}, tempFitVarpTAxis}); + + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_DaughterLambda").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/hDCAxy_DaughterSigmaplus").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {tempFitVarpTAxis, tempFitVarAxis}); + } + } else if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0) { /// V0 histograms /// to be implemented @@ -154,6 +187,7 @@ class FemtoUniverseParticleHisto /// to be implemented } else if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kPhi) { // Phi histograms + } else if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kD0) { // D0/D0bar histograms } else { @@ -212,7 +246,7 @@ class FemtoUniverseParticleHisto } if (isMC) { init_base(folderName, tempFitVarAxisTitle, tempFitVarpTAxis, tempFitVarAxis); - init_MC(folderName, tempFitVarAxisTitle, tempFitVarpTAxis, tempFitVarAxis); + init_MC(folderName, tempFitVarAxisTitle, tempFitVarpTAxis, tempFitVarAxis, isDebug); } } } @@ -234,6 +268,10 @@ class FemtoUniverseParticleHisto if constexpr (mc == o2::aod::femtouniverse_mc_particle::MCType::kRecon) { mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST(o2::aod::femtouniverseparticle::TempFitVarName[mParticleType]), part.pt(), part.tempFitVar()); } + if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { + mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hInvMassXi"), part.mLambda()); + mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hInvMassOmega"), part.mAntiLambda()); + } } template @@ -248,6 +286,7 @@ class FemtoUniverseParticleHisto mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hTPCcrossedRows"), part.tpcNClsCrossedRows()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hTPCfindableVsCrossed"), part.tpcNClsFindable(), part.tpcNClsCrossedRows()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hTPCshared"), part.tpcNClsShared()); + mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hTPCfractionSharedCls"), part.tpcFractionSharedCls()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hITSclusters"), part.itsNCls()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hITSclustersIB"), part.itsNClsInnerBarrel()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hDCAz"), part.pt(), part.dcaZ()); @@ -275,7 +314,9 @@ class FemtoUniverseParticleHisto mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hDecayVtxY"), part.decayVtxY()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hDecayVtxZ"), part.decayVtxZ()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hInvMassLambda"), part.mLambda()); + mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hInvMassLambdaVsPt"), part.pt(), part.mLambda()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hInvMassAntiLambda"), part.mAntiLambda()); + mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hInvMassAntiLambdaVsPt"), part.pt(), part.mAntiLambda()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hInvMassLambdaAntiLambda"), part.mLambda(), part.mAntiLambda()); } else if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hDaughDCA"), part.daughDCA()); @@ -283,8 +324,6 @@ class FemtoUniverseParticleHisto mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hDecayVtxX"), part.decayVtxX()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hDecayVtxY"), part.decayVtxY()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hDecayVtxZ"), part.decayVtxZ()); - mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hInvMassCascade"), part.mLambda()); - mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverse_mc_particle::MCTypeName[mc]) + HIST("/hInvMassAntiCascade"), part.mAntiLambda()); } } @@ -295,7 +334,7 @@ class FemtoUniverseParticleHisto /// \param part Particle /// \param mctruthorigin Origin of the associated mc Truth particle /// \param pdgcode PDG of the associated mc Truth particle associated to the reconstructed particle part - template + template void fillQA_MC(T const& part, int mctruthorigin, int pdgcode, H const& histFolder) // o2-linter: disable=name/function-variable { if (mHistogramRegistry) { @@ -307,34 +346,75 @@ class FemtoUniverseParticleHisto } if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kTrack || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kCascadeBachelor || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kMCTruthTrack) { - /// Track histograms - switch (mctruthorigin) { - case (o2::aod::femtouniverse_mc_particle::kPrimary): - mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Primary"), - part.pt(), part.tempFitVar()); - break; - case (o2::aod::femtouniverse_mc_particle::kDaughter): - mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Daughter"), - part.pt(), part.tempFitVar()); - break; - case (o2::aod::femtouniverse_mc_particle::kMaterial): - mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Material"), - part.pt(), part.tempFitVar()); - break; - case (o2::aod::femtouniverse_mc_particle::kFake): - mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Fake"), - part.pt(), part.tempFitVar()); - break; - case (o2::aod::femtouniverse_mc_particle::kDaughterLambda): - mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_DaughterLambda"), - part.pt(), part.tempFitVar()); - break; - case (o2::aod::femtouniverse_mc_particle::kDaughterSigmaplus): - mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_DaughterSigmaplus"), - part.pt(), part.tempFitVar()); - break; - default: - LOG(fatal) << "femtouniverseparticleMC: not known value for ParticleOriginMCTruth - please check. Quitting!"; + if constexpr (isDebug) { + switch (mctruthorigin) { + case (o2::aod::femtouniverse_mc_particle::kPrimary): + // mHistogramRegistry->fill(histFolder + HIST("_MC/Debug/hPDGmother_Primary"), part.fdMCParticle().motherPDG()); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Primary"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kDaughter): + // mHistogramRegistry->fill(histFolder + HIST("_MC/Debug/hPDGmother_Daughter"), part.fdMCParticle().motherPDG()); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Daughter"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kMaterial): + // mHistogramRegistry->fill(histFolder + HIST("_MC/Debug/hPDGmother_Material"), part.fdMCParticle().motherPDG()); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Material"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kWrongCollision): + // mHistogramRegistry->fill(histFolder + HIST("_MC/Debug/hPDGmother_WrongCollision"), part.fdMCParticle().motherPDG()); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_WrongCollision"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kFake): + // mHistogramRegistry->fill(histFolder + HIST("_MC/Debug/hPDGmother_Fake"), part.fdMCParticle().motherPDG()); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Fake"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kDaughterLambda): + // mHistogramRegistry->fill(histFolder + HIST("_MC/Debug/hPDGmother_DaughterLambda"), part.fdMCParticle().motherPDG()); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_DaughterLambda"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kDaughterSigmaplus): + // mHistogramRegistry->fill(histFolder + HIST("_MC/Debug/hPDGmother_DaughterSigmaplus"), part.fdMCParticle().motherPDG()); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_DaughterSigmaplus"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kElse): + // mHistogramRegistry->fill(histFolder + HIST("_MC/Debug/hPDGmother_Else"), part.fdMCParticle().motherPDG()); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Else"), part.pt(), part.tempFitVar()); + break; + default: + LOGF(info, "femtodreamparticleMC: not known value for ParticleOriginMCTruth --- %d - please check. Quitting!", mctruthorigin); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_NoMCTruthOrigin"), part.pt(), part.tempFitVar()); + } + } else { + switch (mctruthorigin) { + case (o2::aod::femtouniverse_mc_particle::kPrimary): + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Primary"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kDaughter): + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Daughter"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kMaterial): + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Material"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kWrongCollision): + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_WrongCollision"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kFake): + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Fake"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kDaughterLambda): + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_DaughterLambda"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kDaughterSigmaplus): + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_DaughterSigmaplus"), part.pt(), part.tempFitVar()); + break; + case (o2::aod::femtouniverse_mc_particle::kElse): + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_Else"), part.pt(), part.tempFitVar()); + break; + + default: + LOGF(info, "femtodreamparticleMC: not known value for ParticleOriginMCTruth --- %d - please check. Quitting!", mctruthorigin); + mHistogramRegistry->fill(histFolder + HIST("_MC/hDCAxy_NoMCTruthOrigin"), part.pt(), part.tempFitVar()); + } } } else if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0) { /// V0 histograms @@ -350,6 +430,39 @@ class FemtoUniverseParticleHisto } } + template + void fillQA_MC_MisIden(T const& part, int pdgcode, int confPDG, H const& histFolder) // o2-linter: disable=name/function-variable + { + if (mHistogramRegistry) { + if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kTrack) { + if (confPDG == mConfPDGCodePart[0]) { + binPDG = 0; + } else if (confPDG == mConfPDGCodePart[1]) { + binPDG = 1; + } else if (confPDG == mConfPDGCodePart[2]) { + binPDG = 2; // o2-linter: disable=pdg/explicit-code + } else { + binPDG = 3; // o2-linter: disable=pdg/explicit-code + } + if (std::abs(pdgcode) == 211) { + mHistogramRegistry->fill(histFolder + HIST("_MC/hMisidentification"), + binPDG, 0, part.pt()); + } else if (std::abs(pdgcode) == 321) { + mHistogramRegistry->fill(histFolder + HIST("_MC/hMisidentification"), + binPDG, 1, part.pt()); + } else if (std::abs(pdgcode) == 2212) { + mHistogramRegistry->fill(histFolder + HIST("_MC/hMisidentification"), + binPDG, 2, part.pt()); + } else { + mHistogramRegistry->fill(histFolder + HIST("_MC/hMisidentification"), + binPDG, 3, part.pt()); + } + } + } else { + LOG(fatal) << "FemtoUniverseParticleHisto: Histogramming for requested object not defined - quitting!"; + } + } + /// Templated function to fill particle histograms for data/ Monte Carlo reconstructed and Monte Carlo truth /// Always calls fillQA_base fill histogramms with data/ Monte Carlo reconstructed /// In case of Monte Carlo, calls fillQA_base with Monte Carlo truth info and specialized function fillQA_MC for additional histogramms @@ -374,7 +487,7 @@ class FemtoUniverseParticleHisto if constexpr (isMC) { if (part.has_fdMCParticle()) { fillQA_base(part.fdMCParticle(), histFolder); - fillQA_MC(part, (part.fdMCParticle()).partOriginMCTruth(), (part.fdMCParticle()).pdgMCTruth(), histFolder); + fillQA_MC(part, (part.fdMCParticle()).partOriginMCTruth(), (part.fdMCParticle()).pdgMCTruth(), histFolder); } else { mHistogramRegistry->fill(histFolder + HIST("_MC/hNoMCtruthCounter"), 0); } @@ -382,12 +495,39 @@ class FemtoUniverseParticleHisto } } + /// Templated function to fill particle histograms for data/ Monte Carlo reconstructed and Monte Carlo truth + /// Always calls fillQA_base fill histogramms with data/ Monte Carlo reconstructed + /// In case of Monte Carlo, calls fillQA_base with Monte Carlo truth info and specialized function fillQA_MC for additional histogramms + /// \tparam T particle type + /// \tparam isMC fills the additional histograms for Monte Carlo truth + /// \param part particle for which the histograms should be filled + template + void fillQAMisIden(T const& part, int confPDG) + { + fillQABaseMisiden(part, HIST(o2::aod::femtouniverseparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]), confPDG); + } + + template + void fillQABaseMisiden(T const& part, H const& histFolder, int confPDG) + { + std::string tempFitVarName; + if (mHistogramRegistry) { + if constexpr (isMC) { + if (part.has_fdMCParticle()) { + fillQA_MC_MisIden(part, (part.fdMCParticle()).pdgMCTruth(), confPDG, histFolder); + } + } + } + } + private: HistogramRegistry* mHistogramRegistry; ///< For QA output static constexpr o2::aod::femtouniverseparticle::ParticleType mParticleType = particleType; ///< Type of the particle under analysis // o2-linter: disable=name/constexpr-constant static constexpr int mFolderSuffixType = suffixType; ///< Counter for the folder suffix specified below // o2-linter: disable=name/constexpr-constant static constexpr std::string_view mFolderSuffix[5] = {"", "_one", "_two", "_pos", "_neg"}; ///< Suffix for the folder name in case of analyses of pairs of the same kind (T-T, V-V, C-C) // o2-linter: disable=name/constexpr-constant + int mConfPDGCodePart[4] = {211, 321, 2212, 9999}; ///< PDG code as per analysis int mPDG = 0; ///< PDG code of the selected particle + int binPDG = 0; }; } // namespace o2::analysis::femto_universe diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniversePhiSelection.h b/PWGCF/FemtoUniverse/Core/FemtoUniversePhiSelection.h index 80bf1797414..0ee0bfe4162 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniversePhiSelection.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniversePhiSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseSHContainer.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseSHContainer.h index e4a0b9d11bd..558874133cb 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseSHContainer.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseSHContainer.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseSelection.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseSelection.h index ac49b2d6f42..63d9646cdde 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseSelection.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseSoftPionRemoval.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseSoftPionRemoval.h new file mode 100644 index 00000000000..9631b5b3377 --- /dev/null +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseSoftPionRemoval.h @@ -0,0 +1,120 @@ +// Copyright 2019-2025 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. + +/// \file FemtoUniverseSoftPionRemoval.h +/// \brief FemtoUniverseSoftPionRemoval - Checking the soft pions from D* decay and removing them +/// \author Katarzyna Gwiździel, WUT, katarzyna.gwizdziel@cern.ch + +#ifndef PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSESOFTPIONREMOVAL_H_ +#define PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSESOFTPIONREMOVAL_H_ + +#include + +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" +#include "Framework/HistogramRegistry.h" + +namespace o2::analysis::femto_universe +{ + +/// \class FemtoUniverseSoftPionRemoval +/// \brief Class taking care of removing soft pions from D* decays +/// \tparam partOne Type of particle 1 (Track/D0/...) +/// \tparam partTwo Type of particle 2 (Track/D0/...) +template +class FemtoUniverseSoftPionRemoval +{ + public: + /// Destructor + virtual ~FemtoUniverseSoftPionRemoval() = default; + + /// Initialization of the QA histograms + /// \param registry HistogramRegistry + void init(HistogramRegistry* registry) + { + if (registry) { + mHistogramRegistry = registry; + mHistogramRegistry->add("SoftPion/softPionMassVsPt", "; M(K#pi#pi-K#pi); p_{T}", kTH2F, {{200, 0.0, 0.2}, {36, 0., 36.}}); + } + } + + /// Check whether a track is a soft pion from D* decay + /// \tparam Part Data type of the particle + /// \tparam Parts Data type of the collection of all particles + /// \param part1 Particle 1 + /// \param part2 Particle 2 + /// \param particles Collection of all particles passed to the task + /// \return Whether the track is a soft pion + template + bool isSoftPion(Part const& part1, Part const& part2, Parts const& particles, bool isD0Cand, bool isD0barCand, double sigma) + { + if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kD0) { + /// Track-D0 combination part1 is hadron and part2 is D0 + if (part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kD0) { + LOG(fatal) << "FemtoUniverseSoftPionRemoval: passed arguments don't agree with FemtoUniverseSoftPionRemoval instantiation! Please provide second argument kD0 candidate."; + return false; + } + // Getting D0 (part2) children + const auto& posChild = particles.iteratorAt(part2.index() - 2); + const auto& negChild = particles.iteratorAt(part2.index() - 1); + // Pion and kaon mass + double massPion = o2::constants::physics::MassPiPlus; + double massKaon = o2::constants::physics::MassKPlus; + // D* reconstruction + double pSum2 = std::pow(posChild.px() + negChild.px() + part1.px(), 2.0) + std::pow(posChild.py() + negChild.py() + part1.py(), 2.0) + std::pow(posChild.pz() + negChild.pz() + part1.pz(), 2.0); + // Energies of the daughters -> D0->K-pi+ + double e1Pi = std::sqrt(std::pow(massPion, 2.0) + std::pow(posChild.px(), 2.0) + std::pow(posChild.py(), 2.0) + std::pow(posChild.pz(), 2.0)); + double e1K = std::sqrt(std::pow(massKaon, 2.0) + std::pow(negChild.px(), 2.0) + std::pow(negChild.py(), 2.0) + std::pow(negChild.pz(), 2.0)); + // Energies of the daughters -> D0bar->K+pi- + double e2Pi = std::sqrt(std::pow(massPion, 2.0) + std::pow(negChild.px(), 2.0) + std::pow(negChild.py(), 2.0) + std::pow(negChild.pz(), 2.0)); + double e2K = std::sqrt(std::pow(massKaon, 2.0) + std::pow(posChild.px(), 2.0) + std::pow(posChild.py(), 2.0) + std::pow(posChild.pz(), 2.0)); + // Soft pion energy + auto ePion = RecoDecay::e(massPion, part1.p()); + // D* masses + double mDstar1 = std::sqrt(std::pow(e1Pi + e1K + ePion, 2.0) - pSum2); + double mDstar2 = std::sqrt(std::pow(e2Pi + e2K + ePion, 2.0) - pSum2); + + bool isSoftPion = false; + double softPiMass = 0.14542; // pion mass in D*->D0pi decay + double lowMassLimitSoftPion = softPiMass - 3.0 * sigma; + double highMassLimitSoftPion = softPiMass + 3.0 * sigma; + + if (isD0Cand) { + if (mDstar1 - part2.mLambda() > 0.) { + mHistogramRegistry->fill(HIST("SoftPion/softPionMassVsPt"), mDstar1 - part2.mLambda(), part2.pt()); + } + if ((std::abs(mDstar1 - part2.mLambda()) > lowMassLimitSoftPion) && (std::abs(mDstar1 - part2.mLambda()) < highMassLimitSoftPion)) { + isSoftPion = true; + } + } + + if (isD0barCand) { + if (mDstar2 - part2.mAntiLambda() > 0.) { + mHistogramRegistry->fill(HIST("SoftPion/softPionMassVsPt"), mDstar2 - part2.mAntiLambda(), part2.pt()); + } + if ((std::abs(mDstar2 - part2.mAntiLambda()) > lowMassLimitSoftPion) && (std::abs(mDstar2 - part2.mAntiLambda()) < highMassLimitSoftPion)) { + isSoftPion = true; + } + } + return isSoftPion; + } else { + LOG(fatal) << "FemtoUniverseSoftPionRemoval: Combination of objects not defined - quitting!"; + return false; + } + } + + private: + HistogramRegistry* mHistogramRegistry; ///< For QA output + static constexpr o2::aod::femtouniverseparticle::ParticleType kPartOneType = partOne; ///< Type of particle 1 + static constexpr o2::aod::femtouniverseparticle::ParticleType kPartTwoType = partTwo; ///< Type of particle 2 +}; +} // namespace o2::analysis::femto_universe + +#endif // PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSESOFTPIONREMOVAL_H_ diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseSpherHarMath.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseSpherHarMath.h index bb0e8bdaf22..d92560ceb72 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseSpherHarMath.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseSpherHarMath.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h index 3724e84ce83..75276f24a6d 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -37,20 +37,21 @@ namespace o2::analysis::femto_universe namespace femto_universe_track_selection { /// The different selections this task is capable of doing -enum TrackSel { kSign, ///< Sign of the track - kpTMin, ///< Min. p_T (GeV/c) - kpTMax, ///< Max. p_T (GeV/c) - kEtaMax, ///< Max. |eta| - kTPCnClsMin, ///< Min. number of TPC clusters - kTPCfClsMin, ///< Min. fraction of crossed rows/findable TPC clusters - kTPCcRowsMin, ///< Min. number of crossed TPC rows - kTPCsClsMax, ///< Max. number of shared TPC clusters - kITSnClsMin, ///< Min. number of ITS clusters - kITSnClsIbMin, ///< Min. number of ITS clusters in the inner barrel - kDCAxyMax, ///< Max. DCA_xy (cm) - kDCAzMax, ///< Max. DCA_z (cm) - kDCAMin, ///< Min. DCA_xyz (cm) - kPIDnSigmaMax ///< Max. |n_sigma| for PID +enum TrackSel { kSign, ///< Sign of the track + kpTMin, ///< Min. p_T (GeV/c) + kpTMax, ///< Max. p_T (GeV/c) + kEtaMax, ///< Max. |eta| + kTPCnClsMin, ///< Min. number of TPC clusters + kTPCfClsMin, ///< Min. fraction of crossed rows/findable TPC clusters + kTPCcRowsMin, ///< Min. number of crossed TPC rows + kTPCsClsMax, ///< Max. number of shared TPC clusters + kTPCfracsClsMax, ///< Max. number of fraction of shared TPC clusters + kITSnClsMin, ///< Min. number of ITS clusters + kITSnClsIbMin, ///< Min. number of ITS clusters in the inner barrel + kDCAxyMax, ///< Max. DCA_xy (cm) + kDCAzMax, ///< Max. DCA_z (cm) + kDCAMin, ///< Min. DCA_xyz (cm) + kPIDnSigmaMax ///< Max. |n_sigma| for PID }; enum TrackContainerPosition { @@ -86,6 +87,7 @@ class FemtoUniverseTrackSelection : public FemtoUniverseObjectSelection kPIDspecies; ///< All the particle species for which the n_sigma values need to be stored - static constexpr int kNtrackSelection = 14; + static constexpr int kNtrackSelection = 15; static constexpr std::string_view kSelectionNames[kNtrackSelection] = {"Sign", "PtMin", "PtMax", @@ -251,6 +255,7 @@ class FemtoUniverseTrackSelection : public FemtoUniverseObjectSelectionadd((folderName + "/hTPCcrossedRows").c_str(), "; TPC crossed rows; Entries", kTH1F, {{163, 0, 163}}); mHistogramRegistry->add((folderName + "/hTPCfindableVsCrossed").c_str(), ";TPC findable clusters ; TPC crossed rows;", kTH2F, {{163, 0, 163}, {163, 0, 163}}); mHistogramRegistry->add((folderName + "/hTPCshared").c_str(), "; TPC shared clusters; Entries", kTH1F, {{163, -0.5, 162.5}}); + mHistogramRegistry->add((folderName + "/hTPCfractionSharedCls").c_str(), "; TPC fraction of shared clusters; Entries", kTH1F, {{100, 0.0, 100.0}}); mHistogramRegistry->add((folderName + "/hITSclusters").c_str(), "; ITS clusters; Entries", kTH1F, {{10, -0.5, 9.5}}); mHistogramRegistry->add((folderName + "/hITSclustersIB").c_str(), "; ITS clusters in IB; Entries", kTH1F, {{10, -0.5, 9.5}}); mHistogramRegistry->add((folderName + "/hDCAxy").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); @@ -341,6 +349,7 @@ void FemtoUniverseTrackSelection::init(HistogramRegistry* registry) nTPCfMinSel = getNSelections(femto_universe_track_selection::kTPCfClsMin); nTPCcMinSel = getNSelections(femto_universe_track_selection::kTPCcRowsMin); nTPCsMaxSel = getNSelections(femto_universe_track_selection::kTPCsClsMax); + nTPCsFracMaxSel = getNSelections(femto_universe_track_selection::kTPCfracsClsMax); nITScMinSel = getNSelections(femto_universe_track_selection::kITSnClsMin); nITScIbMinSel = getNSelections(femto_universe_track_selection::kITSnClsIbMin); nDCAxyMaxSel = getNSelections(femto_universe_track_selection::kDCAxyMax); @@ -355,6 +364,7 @@ void FemtoUniverseTrackSelection::init(HistogramRegistry* registry) fClsMin = getMinimalSelection(femto_universe_track_selection::kTPCfClsMin, femto_universe_selection::kLowerLimit); cTPCMin = getMinimalSelection(femto_universe_track_selection::kTPCcRowsMin, femto_universe_selection::kLowerLimit); sTPCMax = getMinimalSelection(femto_universe_track_selection::kTPCsClsMax, femto_universe_selection::kUpperLimit); + fracsTPCMax = getMinimalSelection(femto_universe_track_selection::kTPCfracsClsMax, femto_universe_selection::kUpperLimit); nITSclsMin = getMinimalSelection(femto_universe_track_selection::kITSnClsMin, femto_universe_selection::kLowerLimit); nITSclsIbMin = getMinimalSelection(femto_universe_track_selection::kITSnClsIbMin, femto_universe_selection::kLowerLimit); dcaXYMax = getMinimalSelection(femto_universe_track_selection::kDCAxyMax, femto_universe_selection::kAbsUpperLimit); @@ -389,6 +399,7 @@ bool FemtoUniverseTrackSelection::isSelectedMinimal(T const& track) const auto tpcRClsC = track.tpcCrossedRowsOverFindableCls(); const auto tpcNClsC = track.tpcNClsCrossedRows(); const auto tpcNClsS = track.tpcNClsShared(); + const auto tpcNClsFracS = track.tpcFractionSharedCls(); const auto itsNCls = track.itsNCls(); const auto itsNClsIB = track.itsNClsInnerBarrel(); const auto dcaXY = track.dcaXY(); @@ -422,6 +433,9 @@ bool FemtoUniverseTrackSelection::isSelectedMinimal(T const& track) if (nTPCsMaxSel > 0 && tpcNClsS > sTPCMax) { return false; } + if (nTPCsFracMaxSel > 0 && tpcNClsFracS > fracsTPCMax) { + return false; + } if (nITScMinSel > 0 && itsNCls < nITSclsMin) { return false; } @@ -469,6 +483,7 @@ std::array FemtoUniverseTrackSelection::getCutContainer(T c const auto tpcRClsC = track.tpcCrossedRowsOverFindableCls(); const auto tpcNClsC = track.tpcNClsCrossedRows(); const auto tpcNClsS = track.tpcNClsShared(); + const auto tpcNClsFracS = track.tpcFractionSharedCls(); const auto itsNCls = track.itsNCls(); const auto itsNClsIB = track.itsNClsInnerBarrel(); const auto dcaXY = track.dcaXY(); @@ -519,6 +534,9 @@ std::array FemtoUniverseTrackSelection::getCutContainer(T c case (femto_universe_track_selection::kTPCsClsMax): observable = tpcNClsS; break; + case (femto_universe_track_selection::kTPCfracsClsMax): + observable = tpcNClsFracS; + break; case (femto_universe_track_selection::kITSnClsMin): observable = itsNCls; break; @@ -556,6 +574,7 @@ void FemtoUniverseTrackSelection::fillQA(T const& track) mHistogramRegistry->fill(HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtouniverseparticle::TrackTypeName[tracktype]) + HIST("/hTPCcrossedRows"), track.tpcNClsCrossedRows()); mHistogramRegistry->fill(HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtouniverseparticle::TrackTypeName[tracktype]) + HIST("/hTPCfindableVsCrossed"), track.tpcNClsFindable(), track.tpcNClsCrossedRows()); mHistogramRegistry->fill(HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtouniverseparticle::TrackTypeName[tracktype]) + HIST("/hTPCshared"), track.tpcNClsShared()); + mHistogramRegistry->fill(HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtouniverseparticle::TrackTypeName[tracktype]) + HIST("/hTPCfractionSharedCls"), track.tpcFractionSharedCls()); mHistogramRegistry->fill(HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtouniverseparticle::TrackTypeName[tracktype]) + HIST("/hITSclusters"), track.itsNCls()); mHistogramRegistry->fill(HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtouniverseparticle::TrackTypeName[tracktype]) + HIST("/hITSclustersIB"), track.itsNClsInnerBarrel()); mHistogramRegistry->fill(HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + HIST("/") + HIST(o2::aod::femtouniverseparticle::TrackTypeName[tracktype]) + HIST("/hDCAxy"), track.pt(), track.dcaXY()); diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseV0Selection.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseV0Selection.h index d5999f658e0..805da180cc3 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseV0Selection.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseV0Selection.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -329,6 +329,10 @@ void FemtoUniverseV0Selection::init(HistogramRegistry* registry) kTH1F, {massAxisAntiLambda}); mHistogramRegistry->add((folderName + "/hInvMassLambdaAntiLambda").c_str(), "", kTH2F, {massAxisLambda, massAxisAntiLambda}); + mHistogramRegistry->add((folderName + "/hInvMassAntiLambdavsPt").c_str(), + "; ; #it{p}_{T} (GeV/#it{c})", kTH2F, {massAxisAntiLambda, {8, 0.0, 5.0}}); + mHistogramRegistry->add((folderName + "/hInvMassLambdavsPt").c_str(), + "; ; #it{p}_{T} (GeV/#it{c})", kTH2F, {massAxisLambda, {8, 0.0, 5.0}}); posDaughTrack.init const std::vector decVtx = {v0.x(), v0.y(), v0.z()}; float observable = 0.; - for (auto& sel : mSelections) { + for (auto& sel : mSelections) { // o2-linter: disable=const-ref-in-for-loop const auto selVariable = sel.getSelectionVariable(); if (selVariable == femto_universe_v0_selection::kV0DecVtxMax) { for (size_t i = 0; i < decVtx.size(); ++i) { @@ -691,6 +695,14 @@ void FemtoUniverseV0Selection::fillQA(C const& /*col*/, V const& v0, T const& po HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + HIST("/hInvMassLambdaAntiLambda"), v0.mLambda(), v0.mAntiLambda()); + mHistogramRegistry->fill( + HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + + HIST("/hInvMassAntiLambdavsPt"), + v0.mAntiLambda(), v0.pt()); + mHistogramRegistry->fill( + HIST(o2::aod::femtouniverseparticle::ParticleTypeName[part]) + + HIST("/hInvMassLambdavsPt"), + v0.mLambda(), v0.pt()); } posDaughTrack.fillQA float { - return pt * std::sin(phi); + return pt * std::cos(phi); }); DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! Compute the momentum in y in GeV/c [](float pt, float phi) -> float { - return pt * std::cos(phi); + return pt * std::sin(phi); }); DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //! Compute the momentum in z in GeV/c [](float pt, float eta) -> float { @@ -123,6 +123,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! Compute the overall momentum in GeV/c DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of the track charge DECLARE_SOA_COLUMN(TpcNClsFound, tpcNClsFound, uint8_t); //! Number of TPC clusters DECLARE_SOA_COLUMN(TpcNClsCrossedRows, tpcNClsCrossedRows, uint8_t); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(TpcFractionSharedCls, tpcFractionSharedCls, float); //! Number of TPC crossed rows DECLARE_SOA_COLUMN(ItsNCls, itsNCls, uint8_t); //! Number of ITS clusters DECLARE_SOA_COLUMN(ItsNClsInnerBarrel, itsNClsInnerBarrel, uint8_t); //! Number of ITS clusters in the inner barrel //! TPC signal DECLARE_SOA_DYNAMIC_COLUMN(TpcCrossedRowsOverFindableCls, tpcCrossedRowsOverFindableCls, //! Compute the number of crossed rows over findable TPC clusters @@ -138,23 +139,6 @@ DECLARE_SOA_COLUMN(MKaon, mKaon, float); //! The invariant mass of V } // namespace femtouniverseparticle -/// FemtoUniverseCascadeTrack -namespace femtouniversecascparticle -{ - -DECLARE_SOA_COLUMN(DcaV0daughters, dcaV0daughters, float); //! DCA between V0 daughters -DECLARE_SOA_COLUMN(Cpav0, cpav0, float); //! V0 cos of pointing angle -DECLARE_SOA_COLUMN(V0radius, v0radius, float); //! V0 transverse radius -DECLARE_SOA_COLUMN(CpaCasc, cpaCasc, float); //! cascade cosinus of pointing angle -DECLARE_SOA_COLUMN(Dcacascdaughters, dcacascdaughters, float); //! DCA between cascade daughters -DECLARE_SOA_COLUMN(Cascradius, cascradius, float); //! cascade transverse radius -DECLARE_SOA_COLUMN(Dcapostopv, dcapostopv, float); //! DCA of positive daughter to PV -DECLARE_SOA_COLUMN(Dcanegtopv, dcanegtopv, float); //! DCA of negative daughter to PV -DECLARE_SOA_COLUMN(Dcabachtopv, dcabachtopv, float); //! DCA of bachelor track to PV -DECLARE_SOA_COLUMN(Dcav0topv, dcav0topv, float); //! DCA of V0 to PV - -} // namespace femtouniversecascparticle - DECLARE_SOA_TABLE(FDParticles, "AOD", "FDPARTICLE", o2::soa::Index<>, femtouniverseparticle::FdCollisionId, @@ -175,12 +159,30 @@ DECLARE_SOA_TABLE(FDParticles, "AOD", "FDPARTICLE", femtouniverseparticle::P); using FDParticle = FDParticles::iterator; +/// FemtoUniverseCascadeTrack +namespace femtouniversecascparticle +{ +DECLARE_SOA_INDEX_COLUMN(FDParticle, fdParticle); +DECLARE_SOA_COLUMN(DcaV0daughters, dcaV0daughters, float); //! DCA between V0 daughters +DECLARE_SOA_COLUMN(Cpav0, cpav0, float); //! V0 cos of pointing angle +DECLARE_SOA_COLUMN(V0radius, v0radius, float); //! V0 transverse radius*/ +DECLARE_SOA_COLUMN(CpaCasc, cpaCasc, float); //! cascade cosinus of pointing angle +DECLARE_SOA_COLUMN(Dcacascdaughters, dcacascdaughters, float); //! DCA between cascade daughters +DECLARE_SOA_COLUMN(Cascradius, cascradius, float); //! cascade transverse radius +DECLARE_SOA_COLUMN(Dcapostopv, dcapostopv, float); //! DCA of positive daughter to PV +DECLARE_SOA_COLUMN(Dcanegtopv, dcanegtopv, float); //! DCA of negative daughter to PV +DECLARE_SOA_COLUMN(Dcabachtopv, dcabachtopv, float); //! DCA of bachelor track to PV +DECLARE_SOA_COLUMN(Dcav0topv, dcav0topv, float); //! DCA of V0 to PV + +} // namespace femtouniversecascparticle + DECLARE_SOA_TABLE(FDExtParticles, "AOD", "FDEXTPARTICLE", femtouniverseparticle::Sign, femtouniverseparticle::TpcNClsFound, track::TPCNClsFindable, femtouniverseparticle::TpcNClsCrossedRows, track::TPCNClsShared, + femtouniverseparticle::TpcFractionSharedCls, track::TPCInnerParam, femtouniverseparticle::ItsNCls, femtouniverseparticle::ItsNClsInnerBarrel, @@ -219,16 +221,7 @@ using FDFullParticle = FDExtParticles::iterator; DECLARE_SOA_TABLE(FDCascParticles, "AOD", "FDCASCPARTICLE", o2::soa::Index<>, femtouniverseparticle::FdCollisionId, - femtouniverseparticle::Pt, - femtouniverseparticle::Eta, - femtouniverseparticle::Phi, - femtouniverseparticle::PartType, - femtouniverseparticle::Cut, - femtouniverseparticle::PidCut, - femtouniverseparticle::TempFitVar, - femtouniverseparticle::ChildrenIds, - femtouniverseparticle::MLambda, - femtouniverseparticle::MAntiLambda, + femtouniversecascparticle::FDParticleId, femtouniverseparticle::Theta, femtouniverseparticle::Px, femtouniverseparticle::Py, @@ -255,10 +248,14 @@ enum ParticleOriginMCTruth { kDaughter, //! Particle from a decay kMaterial, //! Particle from a material kNotPrimary, //! Not primary particles (kept for compatibility reasons with the FullProducer task. will be removed, since we look at "non primaries" more differentially now) - kFake, //! particle, that has NOT the PDG code of the current analysed particle + kFake, //! Particle, that has NOT the PDG code of the current analysed particle kDaughterLambda, //! Daughter from a Lambda decay kDaughterSigmaplus, //! Daughter from a Sigma^plus decay - kNOriginMCTruthTypes + kPrompt, //! Origin for D0/D0bar mesons + kNonPrompt, //! Origin for D0/D0bar mesons + kNOriginMCTruthTypes, + kElse, + kWrongCollision //! Origin for the wrong collision }; //! Naming of the different OriginMCTruth types @@ -269,7 +266,9 @@ static constexpr std::string_view ParticleOriginMCTruthName[kNOriginMCTruthTypes "_NotPrimary", "_Fake", "_DaughterLambda", - "DaughterSigmaPlus"}; + "DaughterSigmaPlus", + "_Prompt", + "_NonPrompt"}; /// Distinguished between reconstructed and truth enum MCType { diff --git a/PWGCF/FemtoUniverse/Macros/calculateEfficiencyCorrection.cxx b/PWGCF/FemtoUniverse/Macros/calculateEfficiencyCorrection.cxx new file mode 100644 index 00000000000..3880661d9f7 --- /dev/null +++ b/PWGCF/FemtoUniverse/Macros/calculateEfficiencyCorrection.cxx @@ -0,0 +1,248 @@ +// 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. + +/// \file calculateEfficiencyCorrection.cxx +/// \brief Macro for calculating efficiency corrections based on 3D histograms +/// \author Dawid Karpiński, WUT Warsaw, dawid.karpinski@cern.ch + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include // NOLINT +#include +#include +#include + +namespace fs = std::filesystem; + +auto* getHistogram(TFile* file, const std::string& name) +{ + return dynamic_cast(file->Get(name.c_str())); +} + +auto* projectHistogram(TH3* hist, const std::string& projection) +{ + return hist->Project3D(projection.c_str()); +} + +template +H* cloneHistogram(H* hist, const std::string& name) +{ + return dynamic_cast(hist->Clone(name.c_str())); +} + +auto forEachBin(TH1* hist, auto func) -> void +{ + if (hist->GetDimension() == 1) { + for (auto x{1}; x <= hist->GetNbinsX(); ++x) { + func(x, 0, 0); + } + } else if (hist->GetDimension() == 2) { + for (auto x{1}; x <= hist->GetNbinsX(); ++x) { + for (auto y{1}; y <= hist->GetNbinsY(); ++y) { + func(x, y, 0); + } + } + } else if (hist->GetDimension() == 3) { + for (auto x{1}; x <= hist->GetNbinsX(); ++x) { + for (auto y{1}; y <= hist->GetNbinsY(); ++y) { + for (auto z{1}; z <= hist->GetNbinsZ(); ++z) { + func(x, y, z); + } + } + } + } else { + assert(false && "should not happen"); + } +} + +auto setAxisTitles(TH1* hist, const std::string& projection) -> void +{ + auto* xAxis{hist->GetXaxis()}; + auto* yAxis{hist->GetYaxis()}; + auto* zAxis{hist->GetZaxis()}; + + xAxis->SetTitle("#it{p}_{T} (GeV/#it{c})"); + + if (hist->GetDimension() == 2) { + if (projection == "yx") { + yAxis->SetTitle("#it{#eta}"); + } else if (projection == "zx") { + yAxis->SetTitle("mult"); + } + } else if (hist->GetDimension() == 3) { + yAxis->SetTitle("#it{#eta}"); + zAxis->SetTitle("mult"); + } +} + +auto calculateEfficiencyCorrection(const fs::path& resultsPath, const fs::path& histPath, const std::string& projection) -> void +{ + assert(!resultsPath.empty() && !histPath.empty()); + if (projection != "" && projection != "x" && projection != "yx" && projection != "zx") { + std::cerr << "Error: projection must be one of: x, yx, zx\n"; + std::exit(1); + return; + } + + auto isAlien{false}; + if (resultsPath.string().starts_with("alien://")) { + TGrid::Connect("alien://"); + isAlien = true; + } + + auto* resultFile{TFile::Open(resultsPath.c_str())}; + assert(resultFile != nullptr && !resultFile->IsZombie()); + + using namespace std::chrono; + auto now{duration_cast(system_clock::now().time_since_epoch()).count()}; + auto outputPath{isAlien ? std::filesystem::current_path() : resultsPath.parent_path()}; + outputPath /= std::format("{}-effcor-{}.root", resultsPath.stem().string(), now); + + auto* outputFile{TFile::Open(outputPath.c_str(), "RECREATE")}; + assert(outputFile != nullptr && !outputFile->IsZombie()); + + auto* histTruthBase{getHistogram(resultFile, histPath / "hMCTruth")}; + auto* histPrimaryBase{getHistogram(resultFile, histPath / "hPrimary")}; + auto* histSecondaryBase{getHistogram(resultFile, histPath / "hSecondary")}; + + assert(histTruthBase); + assert(histPrimaryBase); + assert(histSecondaryBase); + + TH1* histTruth{histTruthBase}; + TH1* histPrimary{histPrimaryBase}; + TH1* histSecondary{histSecondaryBase}; + + if (projection != "") { + histPrimary = projectHistogram(histPrimaryBase, projection); + histSecondary = projectHistogram(histSecondaryBase, projection); + histTruth = projectHistogram(histTruthBase, projection); + } + + auto* histTotal{cloneHistogram(histPrimary, "hTotal")}; + histTotal->Add(histSecondary); + + auto* histEfficiency{cloneHistogram(histPrimary, "hEfficiency")}; + histEfficiency->Reset(); + setAxisTitles(histEfficiency, projection); + + auto* histWeights{cloneHistogram(histPrimary, "hWeights")}; + histWeights->Reset(); + setAxisTitles(histWeights, projection); + + auto* histCont{cloneHistogram(histPrimary, "hCont")}; + histCont->Reset(); + setAxisTitles(histCont, projection); + + forEachBin(histPrimary, [&](int x, int y, int z) { + auto primVal{histPrimary->GetBinContent(x, y, z)}; + auto primErr{histPrimary->GetBinError(x, y, z)}; + + auto secVal{histSecondary->GetBinContent(x, y, z)}; + auto secErr{histSecondary->GetBinError(x, y, z)}; + + auto truthVal{histTruth->GetBinContent(x, y, z)}; + auto truthErr{histTruth->GetBinError(x, y, z)}; + + auto effVal{0.}; + auto effErr{0.}; + if (truthVal > 0) { + effVal = primVal / truthVal; + effErr = std::sqrt(std::pow(primErr / truthVal, 2) + std::pow((primVal * truthErr / std::pow(truthVal, 2)), 2)); + } + + histEfficiency->SetBinContent(x, y, z, effVal); + histEfficiency->SetBinError(x, y, z, effErr); + + auto totalVal{primVal + secVal}; + auto totalErr{std::hypot(primErr, secErr)}; + + auto contVal{0.}; + auto contErr{0.}; + if (totalVal > 0) { + contVal = secVal / totalVal; + contErr = std::sqrt(std::pow(secErr / totalVal, 2) + std::pow((secVal * totalErr / std::pow(totalVal, 2)), 2)); + } + + histCont->SetBinContent(x, y, z, contVal); + histCont->SetBinError(x, y, z, contErr); + + auto weightVal{0.}; + auto weightErr{0.}; + if (effVal > 0) { + weightVal = (1 - contVal) / effVal; + weightErr = std::sqrt(std::pow(contErr / effVal, 2) + std::pow((1 - contVal) * effErr / std::pow(effVal, 2), 2)); + } + + histWeights->SetBinContent(x, y, z, weightVal); + histWeights->SetBinError(x, y, z, weightErr); + }); + + outputFile->WriteTObject(histEfficiency); + outputFile->WriteTObject(histCont); + outputFile->WriteTObject(histWeights); + + outputFile->Close(); + resultFile->Close(); +} + +auto printUsage(const char* name) -> void +{ + std::cerr << "Usage: " << name << "\n" + << " -f \n" + << " -d \n" + << " -p [optional, default: no projection, 3D histogram]\n" + << " Available projections:\n" + << " x - projection onto pT axis (1D histogram)\n" + << " yx - projection onto pT, eta (2D histogram)\n" + << " zx - projection onto pT, mult (2D histogram)\n"; +} + +int main(int argc, char** argv) +{ + std::string results{""}, hist{""}, proj{""}; + auto flag{0}; + + while ((flag = getopt(argc, argv, "f:d:p:")) != -1) { + switch (flag) { + case 'f': + results = optarg; + break; + case 'd': + hist = optarg; + break; + case 'p': + proj = optarg; + break; + default: + printUsage(argv[0]); + return 1; + } + } + + if (results.empty() || hist.empty()) { + printUsage(argv[0]); + return 1; + } + + calculateEfficiencyCorrection(results, hist, proj); + return 0; +} diff --git a/PWGCF/FemtoUniverse/Macros/femto_universe_efficiency_calculator.py b/PWGCF/FemtoUniverse/Macros/femto_universe_efficiency_calculator.py new file mode 100755 index 00000000000..2a0b822d215 --- /dev/null +++ b/PWGCF/FemtoUniverse/Macros/femto_universe_efficiency_calculator.py @@ -0,0 +1,216 @@ +#!/usr/bin/env python3 + +# 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. + +""" +A tool to calculate efficiency and upload it to CCDB. +Author: Dawid Karpiński (dawid.karpinski@cern.ch) +""" + +import argparse +import subprocess +import sys +import tempfile +import time +from pathlib import Path + +import ROOT # pylint: disable=import-error + + +class CustomHelpFormatter(argparse.HelpFormatter): + "Add default value to help format" + + def _get_help_string(self, action): + help_str = action.help + if help_str is not None and action.default not in [argparse.SUPPRESS, None]: + help_str += f" (default: {action.default})" + return help_str + + +parser = argparse.ArgumentParser( + description="A tool to calculate efficiency and upload it to CCDB", + formatter_class=CustomHelpFormatter, +) +parser.add_argument( + "--alien-path", + type=Path, + help="path to train run's directory in Alien with analysis results " + "[example: /alice/cern.ch/user/a/alihyperloop/outputs/0033/332611/70301]", +) +parser.add_argument( + "--mc-reco", + type=str, + nargs="+", + help="paths to MC Reco histograms, separated by space [example: task/mcreco_one/hPt task/mcreco_two/hPt]", + required=True, +) +parser.add_argument( + "--mc-truth", + type=str, + nargs="+", + help="paths to MC Truth histograms, separated by space [example: task/mctruth_one/hPt task/mctruth_one/hPt]", + required=True, +) +parser.add_argument( + "--ccdb-path", + type=str, + help="location in CCDB to where objects will be uploaded", + required=True, +) +parser.add_argument( + "--ccdb-url", + type=str, + help="URL to CCDB", + default="http://ccdb-test.cern.ch:8080", +) +parser.add_argument( + "--ccdb-labels", + type=str, + nargs="+", + help="custom labels to add to objects' metadata in CCDB [example: label1 label2]", + default=[], +) +parser.add_argument( + "--ccdb-lifetime", + type=int, + help="how long should objects in CCDB remain valid (milliseconds)", + default=365 * 24 * 60 * 60 * 1000, # one year +) +args = parser.parse_args() + +if len(args.mc_reco) != len(args.mc_truth): + print("[!] Provided number of histograms with MC Reco must match MC Truth", file=sys.stderr) + sys.exit(1) + +if len(args.ccdb_labels) > 0 and len(args.ccdb_labels) != len(args.mc_reco): + print("[!] You must provide labels for all particles", file=sys.stderr) + sys.exit(1) + +if len(args.ccdb_labels) == 0: + # if flag is not provided, fill with empty strings to match size + args.ccdb_labels = [""] * len(args.mc_reco) + +ANALYSIS_RESULTS = "AnalysisResults.root" +results_path = args.alien_path / ANALYSIS_RESULTS +job_id = results_path.parent.name +train_number = results_path.parent.parent.name + +tmp_dir = Path(tempfile.gettempdir()) + +res_dest = tmp_dir / f"{train_number}-{job_id}-{ANALYSIS_RESULTS}" +eff_dest = tmp_dir / f"{train_number}-{job_id}-Efficiency.root" + +# get file from alien +if not res_dest.is_file(): + print(f"[↓] Downloading analysis results from Alien to '{res_dest}' ...", file=sys.stderr) + ROOT.TGrid.Connect("alien://") + try: + subprocess.run( + ["alien_cp", results_path, "file://" + str(res_dest)], + capture_output=True, + check=True, + ) + print("[-] Download complete!", file=sys.stderr) + except subprocess.CalledProcessError as error: + print(f"[!] Error while downloading results file: {error.stderr}", file=sys.stderr) + sys.exit(1) +else: + print( + f"[-] Skipping download from Alien, since '{res_dest}' is already present", + file=sys.stderr, + ) + +print() + +histos_to_upload = [] + +# get reco & truth histos +with ( + ROOT.TFile.Open(res_dest.as_uri()) as res_file, + ROOT.TFile.Open(eff_dest.as_uri(), "recreate") as eff_file, +): + for idx, (mc_reco, mc_truth) in enumerate(zip(args.mc_reco, args.mc_truth)): + hist_reco = res_file.Get(mc_reco) + if not hist_reco: + print(f"[!] Cannot find MC Reco histogram in '{mc_reco}', aborting", file=sys.stderr) + sys.exit(1) + + hist_truth = res_file.Get(mc_truth) + if not hist_truth: + print(f"[!] Cannot find MC Truth histogram in '{mc_truth}', aborting", file=sys.stderr) + sys.exit(1) + + num_bins = hist_reco.GetNbinsX() + x_max = hist_reco.GetXaxis().GetBinLowEdge(num_bins) + x_max += hist_reco.GetXaxis().GetBinWidth(num_bins) + + hist_name = f"Efficiency_part{idx + 1}" + + # calculate efficiency + eff = ROOT.TH1F(hist_name, "", num_bins, 0, x_max) + for bin_idx in range(len(eff)): + denom = hist_truth.GetBinContent(bin_idx) + eff.SetBinContent(bin_idx, hist_reco.GetBinContent(bin_idx) / denom if denom > 0 else 0) + + # save efficiency object to file + eff_file.WriteObject(eff, hist_name) + histos_to_upload.append(hist_name) + +if len(histos_to_upload) == 0: + print("[-] Exiting, since there is nothing to upload", file=sys.stderr) + sys.exit(1) + +# upload objects to ccdb +try: + for idx, key in enumerate(histos_to_upload): + timestamp_start = int(time.time() * 1000) + timestamp_end = timestamp_start + args.ccdb_lifetime + + print(f"[↑] Uploading {key} to {args.ccdb_url} ... ", file=sys.stderr, end="") + upload_cmd = [ + "o2-ccdb-upload", + "--file", + eff_dest.as_uri(), + "--host", + args.ccdb_url, + "--key", + key, + "--path", + args.ccdb_path, + "--starttimestamp", + str(timestamp_start), + "--endtimestamp", + str(timestamp_end), + "--meta", + f"trainNumber={train_number};label={args.ccdb_labels[idx]}", + ] + result = subprocess.run(upload_cmd, capture_output=True, check=True) + + if "html" in result.stdout.decode("utf-8"): + print( + f"\n[!] Something went wrong with upload request: {result.stdout.decode('utf-8')}", + file=sys.stderr, + ) + sys.exit(1) + + if result.stderr: + print(f"\n[!] Error while uploading: {result.stderr.decode('utf-8')}", file=sys.stderr) + sys.exit(1) + + print("complete!", file=sys.stderr) + +except subprocess.CalledProcessError as error: + print(f"\n[!] Error while uploading: {error.stderr.decode('utf-8')}", file=sys.stderr) + sys.exit(1) + +print() +print("[✓] Success!", file=sys.stderr) diff --git a/PWGCF/FemtoUniverse/Macros/femto_universe_efficiency_phi_calculator.py b/PWGCF/FemtoUniverse/Macros/femto_universe_efficiency_phi_calculator.py new file mode 100644 index 00000000000..97f5bede27a --- /dev/null +++ b/PWGCF/FemtoUniverse/Macros/femto_universe_efficiency_phi_calculator.py @@ -0,0 +1,223 @@ +#!/usr/bin/env python3 + +# 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. + +""" +A tool to calculate efficiency and upload it to CCDB. +Author: Dawid Karpiński (dawid.karpinski@cern.ch) +Modified by: Zuzanna Chochulska (zchochul@cern.ch) +""" + +import argparse +import subprocess +import sys +import tempfile +import time +from pathlib import Path + +import ROOT # pylint: disable=import-error + + +class CustomHelpFormatter(argparse.HelpFormatter): + "Add default value to help format" + + def _get_help_string(self, action): + help_str = action.help + if help_str is not None and action.default not in [argparse.SUPPRESS, None]: + help_str += f" (default: {action.default})" + return help_str + + +parser = argparse.ArgumentParser( + description="A tool to calculate efficiency and upload it to CCDB", + formatter_class=CustomHelpFormatter, +) +parser.add_argument( + "--alien-path", + type=Path, + help="path to train run's directory in Alien with analysis results " + "[example: /alice/cern.ch/user/a/alihyperloop/outputs/0033/332611/70301]", +) +parser.add_argument( + "--mc-reco", + type=str, + nargs="+", + help="paths to MC Reco histograms, separated by space [example: task/mcreco_one/hPt task/mcreco_two/hPt]", + required=True, +) +parser.add_argument( + "--mc-truth", + type=str, + nargs="+", + help="paths to MC Truth histograms, separated by space [example: task/mctruth_one/hPt task/mctruth_one/hPt]", + required=True, +) +parser.add_argument( + "--ccdb-path", + type=str, + help="location in CCDB to where objects will be uploaded", + required=True, +) +parser.add_argument( + "--ccdb-url", + type=str, + help="URL to CCDB", + default="http://ccdb-test.cern.ch:8080", +) +parser.add_argument( + "--ccdb-labels", + type=str, + nargs="+", + help="custom labels to add to objects' metadata in CCDB [example: label1 label2]", + default=[], +) +parser.add_argument( + "--ccdb-lifetime", + type=int, + help="how long should objects in CCDB remain valid (milliseconds)", + default=365 * 24 * 60 * 60 * 1000, # one year +) +args = parser.parse_args() + +if len(args.mc_reco) != len(args.mc_truth): + print("[!] Provided number of histograms with MC Reco must match MC Truth", file=sys.stderr) + sys.exit(1) + +if len(args.ccdb_labels) > 0 and len(args.ccdb_labels) != len(args.mc_reco): + print("[!] You must provide labels for all particles", file=sys.stderr) + sys.exit(1) + +if len(args.ccdb_labels) == 0: + # if flag is not provided, fill with empty strings to match size + args.ccdb_labels = [""] * len(args.mc_reco) + +ANALYSIS_RESULTS = "AnalysisResults.root" +results_path = args.alien_path / ANALYSIS_RESULTS +job_id = results_path.parent.name +train_number = results_path.parent.parent.name + +tmp_dir = Path(tempfile.gettempdir()) + +res_dest = tmp_dir / f"{train_number}-{job_id}-{ANALYSIS_RESULTS}" +eff_dest = tmp_dir / f"{train_number}-{job_id}-Efficiency.root" + +# get file from alien +if not res_dest.is_file(): + print(f"[↓] Downloading analysis results from Alien to '{res_dest}' ...", file=sys.stderr) + ROOT.TGrid.Connect("alien://") + try: + subprocess.run( + ["alien_cp", results_path, "file://" + str(res_dest)], + capture_output=True, + check=True, + ) + print("[-] Download complete!", file=sys.stderr) + except subprocess.CalledProcessError as error: + print(f"[!] Error while downloading results file: {error.stderr}", file=sys.stderr) + sys.exit(1) +else: + print( + f"[-] Skipping download from Alien, since '{res_dest}' is already present", + file=sys.stderr, + ) + +print() + +histos_to_upload = [] + +# get reco & truth histos +with ( + ROOT.TFile.Open(res_dest.as_uri()) as res_file, + ROOT.TFile.Open(eff_dest.as_uri(), "recreate") as eff_file, +): + + for idx, (mc_reco, mc_truth) in enumerate(zip(args.mc_reco, args.mc_truth)): + hist_reco = res_file.Get(mc_reco) + if not hist_reco: + print(f"[!] Cannot find MC Reco histogram in '{mc_reco}', aborting", file=sys.stderr) + sys.exit(1) + + hist_truth = res_file.Get(mc_truth) + if not hist_truth: + print(f"[!] Cannot find MC Truth histogram in '{mc_truth}', aborting", file=sys.stderr) + sys.exit(1) + + hist_reco.Rebin(4) + hist_truth.Rebin(4) + + num_bins = hist_reco.GetNbinsX() + x_max = hist_reco.GetXaxis().GetBinLowEdge(num_bins) + x_max += hist_reco.GetXaxis().GetBinWidth(num_bins) + + hist_name = f"Efficiency_part{idx + 1}" + + # calculate efficiency + eff = ROOT.TH1F(hist_name, "", num_bins, 0, x_max) + for bin_idx in range(1, num_bins + 1): # Bins start at 1 in ROOT + denom = hist_truth.GetBinContent(bin_idx) + if idx == 0: + denom *= 0.489 + eff.SetBinContent(bin_idx, hist_reco.GetBinContent(bin_idx) / denom if denom > 0 else 0) + + # save efficiency object to file + eff_file.WriteObject(eff, hist_name) + histos_to_upload.append(hist_name) + +if len(histos_to_upload) == 0: + print("[-] Exiting, since there is nothing to upload", file=sys.stderr) + sys.exit(1) + +# upload objects to ccdb +try: + for idx, key in enumerate(histos_to_upload): + timestamp_start = int(time.time() * 1000) + timestamp_end = timestamp_start + args.ccdb_lifetime + + print(f"[↑] Uploading {key} to {args.ccdb_url} ... ", file=sys.stderr, end="") + upload_cmd = [ + "o2-ccdb-upload", + "--file", + eff_dest.as_uri(), + "--host", + args.ccdb_url, + "--key", + key, + "--path", + args.ccdb_path, + "--starttimestamp", + str(timestamp_start), + "--endtimestamp", + str(timestamp_end), + "--meta", + f"trainNumber={train_number};label={args.ccdb_labels[idx]}", + ] + result = subprocess.run(upload_cmd, capture_output=True, check=True) + + if "html" in result.stdout.decode("utf-8"): + print( + f"\n[!] Something went wrong with upload request: {result.stdout.decode('utf-8')}", + file=sys.stderr, + ) + sys.exit(1) + + if result.stderr: + print(f"\n[!] Error while uploading: {result.stderr.decode('utf-8')}", file=sys.stderr) + sys.exit(1) + + print("complete!", file=sys.stderr) + +except subprocess.CalledProcessError as error: + print(f"\n[!] Error while uploading: {error.stderr.decode('utf-8')}", file=sys.stderr) + sys.exit(1) + +print() +print("[✓] Success!", file=sys.stderr) diff --git a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx index 5eb3cab7395..9ab5dcecd68 100644 --- a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx +++ b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -14,35 +14,35 @@ /// \author Malgorzata Janik, WUT Warsaw, majanik@cern.ch /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch -#include -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseCollisionSelection.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseV0Selection.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniversePhiSelection.h" -#include "PWGCF/FemtoUniverse/Core/femtoUtils.h" -#include "Framework/ASoAHelpers.h" +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" + +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" + #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" -#include "Math/Vector4D.h" -#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "ReconstructionDataFormats/Track.h" -#include "TMath.h" -#include "TLorentzVector.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::analysis::femto_universe; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::constants::physics; namespace o2::aod { @@ -71,7 +71,7 @@ int getRowDaughters(int daughID, T const& vecID) return rowInPrimaryTrackTableDaugh; } -struct femtoUniverseProducerMCTruthTask { +struct FemtoUniverseProducerMCTruthTask { int mRunNumber; float mMagField; Service ccdb; /// Accessing the CCDB @@ -83,29 +83,26 @@ struct femtoUniverseProducerMCTruthTask { // Produces outputPartsMC; // Analysis configs - Configurable ConfIsTrigger{"ConfIsTrigger", false, "Store all collisions"}; // Choose if filtering or skimming version is run - Configurable ConfIsRun3{"ConfIsRun3", false, "Running on Run3 or pilot"}; - Configurable ConfIsMC{"ConfIsMC", false, "Running on MC; implemented only for Run3"}; - Configurable ConfIsForceGRP{"ConfIsForceGRP", false, "Set true if the magnetic field configuration is not available in the usual CCDB directory (e.g. for Run 2 converted data or unanchorad Monte Carlo)"}; - Configurable ConfIsActivateV0{"ConfIsActivateV0", true, "Activate filling of V0 into femtouniverse tables"}; - Configurable ConfIsActivatePhi{"ConfIsActivatePhi", true, "Activate filling of Phi into femtouniverse tables"}; - Configurable> ConfPDGCodes{"ConfPDGCodes", std::vector{211, -211, 2212, -2212, 333}, "PDG of particles to be stored"}; - Configurable ConfAnalysisWithPID{"ConfAnalysisWithPID", true, "1: take only particles with specified PDG, 0: all particles"}; + Configurable confIsRun3{"confIsRun3", false, "Running on Run3 or pilot"}; + Configurable confIsMC{"confIsMC", false, "Running on MC; implemented only for Run3"}; + Configurable confIsForceGRP{"confIsForceGRP", false, "Set true if the magnetic field configuration is not available in the usual CCDB directory (e.g. for Run 2 converted data or unanchorad Monte Carlo)"}; + Configurable> confPDGCodes{"confPDGCodes", std::vector{211, -211, 2212, -2212, 333}, "PDG of particles to be stored"}; + Configurable confAnalysisWithPID{"confAnalysisWithPID", true, "1: take only particles with specified PDG, 0: all particles"}; /// Event cuts - Configurable ConfEvtUseTPCmult{"ConfEvtUseTPCmult", false, "Use multiplicity based on the number of tracks with TPC information"}; - Configurable ConfEvtZvtx{"ConfEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; - Configurable ConfEvtTriggerCheck{"ConfEvtTriggerCheck", true, "Evt sel: check for trigger"}; - Configurable ConfEvtTriggerSel{"ConfEvtTriggerSel", kINT7, "Evt sel: trigger"}; - Configurable ConfEvtOfflineCheck{"ConfEvtOfflineCheck", false, "Evt sel: check for offline selection"}; - Configurable ConfCentFT0Min{"ConfCentFT0Min", 0.f, "Min CentFT0 value for centrality selection"}; - Configurable ConfCentFT0Max{"ConfCentFT0Max", 200.f, "Max CentFT0 value for centrality selection"}; + Configurable confEvtZvtx{"confEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable confEvtTriggerCheck{"confEvtTriggerCheck", true, "Evt sel: check for trigger"}; + Configurable confEvtTriggerSel{"confEvtTriggerSel", kINT7, "Evt sel: trigger"}; + Configurable confEvtOfflineCheck{"confEvtOfflineCheck", false, "Evt sel: check for offline selection"}; + Configurable confCentFT0Min{"confCentFT0Min", 0.f, "Min CentFT0 value for centrality selection"}; + Configurable confCentFT0Max{"confCentFT0Max", 200.f, "Max CentFT0 value for centrality selection"}; + Configurable confDoSpher{"confDoSpher", false, "Calculate sphericity. If false sphericity will take value of 2."}; // Track cuts struct : o2::framework::ConfigurableGroup { - Configurable ConfPtLowFilterCut{"ConfPtLowFilterCut", 0.14, "Lower limit for Pt for the filtering tracks"}; // pT low - Configurable ConfPtHighFilterCut{"ConfPtHighFilterCut", 5.0, "Higher limit for Pt for the filtering tracks"}; // pT high - Configurable ConfEtaFilterCut{"ConfEtaFilterCut", 0.8, "Eta cut for the filtering tracks"}; + Configurable confPtLowFilterCut{"confPtLowFilterCut", 0.14, "Lower limit for Pt for the filtering tracks"}; // pT low + Configurable confPtHighFilterCut{"confPtHighFilterCut", 5.0, "Higher limit for Pt for the filtering tracks"}; // pT high + Configurable confEtaFilterCut{"confEtaFilterCut", 0.8, "Eta cut for the filtering tracks"}; } ConfFilteringTracks; FemtoUniverseCollisionSelection colCuts; @@ -118,7 +115,7 @@ struct femtoUniverseProducerMCTruthTask { LOGF(fatal, "Neither processFullData nor processFullMC enabled. Please choose one."); } - colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, ConfIsRun3, ConfCentFT0Min, ConfCentFT0Max); + colCuts.setCuts(confEvtZvtx, confEvtTriggerCheck, confEvtTriggerSel, confEvtOfflineCheck, confIsRun3, confCentFT0Min, confCentFT0Max); colCuts.init(&qaRegistry); trackCuts.init(&qaRegistry); @@ -135,16 +132,23 @@ struct femtoUniverseProducerMCTruthTask { } template - void fillCollisions(CollisionType const& col, TrackType const& /*tracks*/) + void fillCollisions(CollisionType const& col, TrackType const& tracks) { - for (auto& c : col) { + for (const auto& c : col) { const auto vtxZ = c.posZ(); - const auto spher = 0; // colCuts.computeSphericity(col, tracks); - int mult = 0; - int multNtr = 0; + float mult = confIsRun3 ? c.multFV0M() : 0.5 * (c.multFV0M()); + int multNtr = confIsRun3 ? c.multNTracksPV() : c.multTracklets(); + // Removing collisions with Zvtx > 10 cm + if (std::abs(vtxZ) > confEvtZvtx) { + continue; + } // colCuts.fillQA(c); //for now, TODO: create a configurable so in the FemroUniverseCollisionSelection.h there is an option to plot QA just for the posZ - outputCollision(vtxZ, mult, multNtr, spher, mMagField); + if (confDoSpher) { + outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField); + } else { + outputCollision(vtxZ, mult, multNtr, 2, mMagField); + } } } @@ -153,24 +157,26 @@ struct femtoUniverseProducerMCTruthTask { { std::vector childIDs = {0, 0}; // these IDs are necessary to keep track of the children - for (auto& particle : tracks) { + for (const auto& particle : tracks) { /// if the most open selection criteria are not fulfilled there is no /// point looking further at the track - if (particle.eta() < -ConfFilteringTracks.ConfEtaFilterCut || particle.eta() > ConfFilteringTracks.ConfEtaFilterCut) + if (particle.eta() < -ConfFilteringTracks.confEtaFilterCut || particle.eta() > ConfFilteringTracks.confEtaFilterCut) continue; - if (particle.pt() < ConfFilteringTracks.ConfPtLowFilterCut || particle.pt() > ConfFilteringTracks.ConfPtHighFilterCut) + if (particle.pt() < ConfFilteringTracks.confPtLowFilterCut || particle.pt() > ConfFilteringTracks.confPtHighFilterCut) continue; - uint32_t pdgCode = (uint32_t)particle.pdgCode(); + int pdgCode = particle.pdgCode(); - if (ConfAnalysisWithPID) { + if (confAnalysisWithPID) { bool pass = false; - std::vector tmpPDGCodes = ConfPDGCodes; // necessary due to some features of the Configurable - for (uint32_t pdg : tmpPDGCodes) { - if (pdgCode == 333) { + std::vector tmpPDGCodes = confPDGCodes; // necessary due to some features of the Configurable + for (const int& pdg : tmpPDGCodes) { + if (pdgCode == Pdg::kPhi) { // phi meson + pass = true; + } else if (pdgCode == Pdg::kD0) { // D0 meson pass = true; - } else if (pdgCode == 421) { + } else if (pdgCode == Pdg::kDPlus) { // D+ meson pass = true; } else if (static_cast(pdg) == static_cast(pdgCode)) { if (particle.isPhysicalPrimary()) @@ -218,11 +224,11 @@ struct femtoUniverseProducerMCTruthTask { fillCollisions(collisions, mcParticles); fillParticles(mcParticles); } - PROCESS_SWITCH(femtoUniverseProducerMCTruthTask, processTrackMC, "Provide MC data for track analysis", true); + PROCESS_SWITCH(FemtoUniverseProducerMCTruthTask, processTrackMC, "Provide MC data for track analysis", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; return workflow; } diff --git a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerReducedTask.cxx b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerReducedTask.cxx index 382559100e4..4ae5b3b01f2 100644 --- a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerReducedTask.cxx +++ b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerReducedTask.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -16,8 +16,10 @@ /// \author Anton Riedel, TU München, anton.riedel@tum.de /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch -#include "TMath.h" #include +#include + +#include "TMath.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseCollisionSelection.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" #include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" @@ -100,6 +102,7 @@ struct femtoUniverseProducerReducedTask { Configurable> ConfTrkTPCfCls{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCfClsMin, "ConfTrk"), std::vector{0.7f, 0.83f, 0.9f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCfClsMin, "Track selection: ")}; Configurable> ConfTrkTPCcRowsMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCcRowsMin, "ConfTrk"), std::vector{70.f, 60.f, 80.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCcRowsMin, "Track selection: ")}; Configurable> ConfTrkTPCsCls{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCsClsMax, "ConfTrk"), std::vector{0.1f, 160.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCsClsMax, "Track selection: ")}; + Configurable> ConfTrkTPCfracsCls{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCfracsClsMax, "ConfTrk"), std::vector{0.1f, 160.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCfracsClsMax, "Track selection: ")}; Configurable> ConfTrkITSnclsMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kITSnClsMin, "ConfTrk"), std::vector{-1.f, 2.f, 4.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kITSnClsMin, "Track selection: ")}; Configurable> ConfTrkITSnclsIbMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kITSnClsIbMin, "ConfTrk"), std::vector{-1.f, 1.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kITSnClsIbMin, "Track selection: ")}; Configurable> ConfTrkDCAxyMax{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kDCAxyMax, "ConfTrk"), std::vector{0.1f, 0.5f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kDCAxyMax, "Track selection: ")}; /// here we need an open cut to do the DCA fits later on! @@ -129,6 +132,7 @@ struct femtoUniverseProducerReducedTask { trackCuts.setSelection(ConfTrkTPCfCls, femto_universe_track_selection::kTPCfClsMin, femto_universe_selection::kLowerLimit); trackCuts.setSelection(ConfTrkTPCcRowsMin, femto_universe_track_selection::kTPCcRowsMin, femto_universe_selection::kLowerLimit); trackCuts.setSelection(ConfTrkTPCsCls, femto_universe_track_selection::kTPCsClsMax, femto_universe_selection::kUpperLimit); + trackCuts.setSelection(ConfTrkTPCfracsCls, femto_universe_track_selection::kTPCfracsClsMax, femto_universe_selection::kUpperLimit); trackCuts.setSelection(ConfTrkITSnclsMin, femto_universe_track_selection::kITSnClsMin, femto_universe_selection::kLowerLimit); trackCuts.setSelection(ConfTrkITSnclsIbMin, femto_universe_track_selection::kITSnClsIbMin, femto_universe_selection::kLowerLimit); trackCuts.setSelection(ConfTrkDCAxyMax, femto_universe_track_selection::kDCAxyMax, femto_universe_selection::kAbsUpperLimit); @@ -289,6 +293,7 @@ struct femtoUniverseProducerReducedTask { track.tpcNClsFindable(), (uint8_t)track.tpcNClsCrossedRows(), track.tpcNClsShared(), + track.tpcFractionSharedCls(), track.tpcInnerParam(), track.itsNCls(), track.itsNClsInnerBarrel(), diff --git a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx index b50e35c87e3..1415e905f39 100644 --- a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx +++ b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -15,45 +15,54 @@ /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch /// \author Malgorzata Janik, WUT Warsaw, majanik@cern.ch /// \author Pritam Chakraborty, WUT Warsaw, pritam.chakraborty@cern.ch +/// \author Shirajum Monira, WUT Warsaw, shirajum.monira@cern.ch -#include -#include -#include -#include -#include +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseCascadeSelection.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseCollisionSelection.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniversePhiSelection.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseV0Selection.h" +#include "PWGCF/FemtoUniverse/Core/femtoUtils.h" +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "CommonConstants/PhysicsConstants.h" #include "Common/CCDB/ctpRateFetcher.h" -#include "Common/Core/trackUtilities.h" #include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "CommonConstants/PhysicsConstants.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseCollisionSelection.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseV0Selection.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseCascadeSelection.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniversePhiSelection.h" -#include "PWGCF/FemtoUniverse/Core/femtoUtils.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Core/HfHelper.h" #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/runDataProcessing.h" -#include "Math/Vector4D.h" -#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" #include "ReconstructionDataFormats/Track.h" -#include "TMath.h" +#include + +#include "Math/Vector4D.h" #include "TLorentzVector.h" -#include "Framework/O2DatabasePDGPlugin.h" +#include "TMath.h" +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis::femto_universe; @@ -66,12 +75,17 @@ namespace o2::aod using FemtoFullCollision = soa::Join::iterator; +using FemtoFullCollisionCentPP = + soa::Join::iterator; using FemtoFullCollisionCentRun2 = soa::Join::iterator; using FemtoFullCollisionCentRun3 = soa::Join::iterator; using FemtoFullCollisionMC = soa::Join::iterator; - +using FemtoFullCollisionCentRun3MCs = + soa::Join; +using FemtoFullCollisionCentRun3MC = + soa::Join::iterator; using FemtoFullTracks = soa::Join outputCascParts; Configurable confIsDebug{"confIsDebug", true, "Enable Debug tables"}; + Configurable confIsUseCutculator{"confIsUseCutculator", true, "Enable cutculator for track cuts"}; // Choose if filtering or skimming version is run // Configurable confIsTrigger{"confIsTrigger", false, "Store all collisions"}; //Commented: not used configurable // Choose if running on converted data or Run3 / Pilot @@ -123,33 +138,38 @@ struct FemtoUniverseProducerTask { Configurable confIsForceGRP{"confIsForceGRP", false, "Set true if the magnetic field configuration is not available in the usual CCDB directory (e.g. for Run 2 converted data or unanchorad Monte Carlo)"}; Configurable confDoSpher{"confDoSpher", false, "Calculate sphericity. If false sphericity will take value of 2."}; + Configurable confStoreMCmothers{"confStoreMCmothers", false, "MC truth: Fill with not only primary particles and store mothers' PDG in tempFitVar."}; Configurable confFillCollExt{"confFillCollExt", false, "Option to fill collision extended table"}; + /// Event filtering (used for v0-cascade analysis) + Configurable zorroMask{"zorroMask", "", "zorro trigger class to select on (empty: none)"}; + /// Event cuts FemtoUniverseCollisionSelection colCuts; - Configurable confEvtUseTPCmult{"confEvtUseTPCmult", false, "Use multiplicity based on the number of tracks with TPC information"}; - Configurable confEvtZvtx{"confEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; - Configurable confEvtTriggerCheck{"confEvtTriggerCheck", true, "Evt sel: check for trigger"}; - Configurable confEvtTriggerSel{"confEvtTriggerSel", kINT7, "Evt sel: trigger"}; - Configurable confEvtOfflineCheck{"confEvtOfflineCheck", false, "Evt sel: check for offline selection"}; - Configurable confIsActivateV0{"confIsActivateV0", false, "Activate filling of V0 into femtouniverse tables"}; - Configurable confActivateSecondaries{"confActivateSecondaries", false, "Fill secondary MC gen particles that were reconstructed"}; - Configurable confIsActivateCascade{"confIsActivateCascade", false, "Activate filling of Cascade into femtouniverse tables"}; - Configurable confIsSelectCascOmega{"confIsSelectCascOmega", false, "Select Omegas for cascade analysis"}; - Configurable confIsActivatePhi{"confIsActivatePhi", false, "Activate filling of Phi into femtouniverse tables"}; - Configurable confMCTruthAnalysisWithPID{"confMCTruthAnalysisWithPID", true, "1: take only particles with specified PDG, 0: all particles (for MC Truth)"}; - Configurable> confMCTruthPDGCodes{"confMCTruthPDGCodes", std::vector{211, -211, 2212, -2212, 333}, "PDG of particles to be stored"}; - Configurable confCentFT0Min{"confCentFT0Min", 0.f, "Min CentFT0 value for centrality selection"}; - Configurable confCentFT0Max{"confCentFT0Max", 200.f, "Max CentFT0 value for centrality selection"}; - Configurable confEvIsGoodZvtxFT0vsPV{"confEvIsGoodZvtxFT0vsPV", true, "Require kIsGoodZvtxFT0vsPV selection on Events."}; - Configurable confEvNoSameBunchPileup{"confEvNoSameBunchPileup", true, "Require kNoSameBunchPileup selection on Events."}; - Configurable confIsUsePileUp{"confIsUsePileUp", true, "Required for choosing whether to run the pile-up cuts"}; - Configurable confEvIsVertexITSTPC{"confEvIsVertexITSTPC", true, "Require kIsVertexITSTPC selection on Events"}; - Configurable confTPCOccupancyMin{"confTPCOccupancyMin", 0, "Minimum value for TPC Occupancy selection"}; - Configurable confTPCOccupancyMax{"confTPCOccupancyMax", 500, "Maximum value for TPC Occupancy selection"}; - - Filter customCollCentFilter = (aod::cent::centFT0C > confCentFT0Min) && - (aod::cent::centFT0C < confCentFT0Max); + struct : o2::framework::ConfigurableGroup { + Configurable confEvtUseTPCmult{"confEvtUseTPCmult", false, "Use multiplicity based on the number of tracks with TPC information"}; + Configurable confEvtZvtx{"confEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable confEvtTriggerCheck{"confEvtTriggerCheck", true, "Evt sel: check for trigger"}; + Configurable confEvtTriggerSel{"confEvtTriggerSel", kINT7, "Evt sel: trigger"}; + Configurable confEvtOfflineCheck{"confEvtOfflineCheck", false, "Evt sel: check for offline selection"}; + Configurable confIsActivateV0{"confIsActivateV0", false, "Activate filling of V0 into femtouniverse tables"}; + Configurable confActivateSecondaries{"confActivateSecondaries", false, "Fill secondary MC gen particles that were reconstructed"}; + Configurable confIsActivateCascade{"confIsActivateCascade", false, "Activate filling of Cascade into femtouniverse tables"}; + Configurable confIsActivatePhi{"confIsActivatePhi", false, "Activate filling of Phi into femtouniverse tables"}; + Configurable confIsActiveD0{"confIsActiveD0", false, "Activate filling FU tables for D0/D0bar mesons"}; + Configurable confMCTruthAnalysisWithPID{"confMCTruthAnalysisWithPID", true, "1: take only particles with specified PDG, 0: all particles (for MC Truth)"}; + Configurable> confMCTruthPDGCodes{"confMCTruthPDGCodes", std::vector{211, -211, 2212, -2212, 333}, "PDG of particles to be stored"}; + Configurable confCentFT0Min{"confCentFT0Min", 0.f, "Min CentFT0 value for centrality selection"}; + Configurable confCentFT0Max{"confCentFT0Max", 200.f, "Max CentFT0 value for centrality selection"}; + Configurable confEvIsGoodZvtxFT0vsPV{"confEvIsGoodZvtxFT0vsPV", true, "Require kIsGoodZvtxFT0vsPV selection on Events."}; + Configurable confEvNoSameBunchPileup{"confEvNoSameBunchPileup", true, "Require kNoSameBunchPileup selection on Events."}; + Configurable confIsUsePileUp{"confIsUsePileUp", true, "Required for choosing whether to run the pile-up cuts"}; + Configurable confEvIsVertexITSTPC{"confEvIsVertexITSTPC", true, "Require kIsVertexITSTPC selection on Events"}; + Configurable confTPCOccupancyMin{"confTPCOccupancyMin", 0, "Minimum value for TPC Occupancy selection"}; + Configurable confTPCOccupancyMax{"confTPCOccupancyMax", 500, "Maximum value for TPC Occupancy selection"}; + } ConfGeneral; + Filter customCollCentFilter = (aod::cent::centFT0C > ConfGeneral.confCentFT0Min) && + (aod::cent::centFT0C < ConfGeneral.confCentFT0Max); // just sanity check to make sure in case there are problems in conversion or // MC production it does not affect results @@ -159,23 +179,27 @@ struct FemtoUniverseProducerTask { // "True: reject if neither ITS hit nor TOF timing satisfied"}; FemtoUniverseTrackSelection trackCuts; - Configurable> confTrkCharge{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kSign, "ConfTrk"), std::vector{-1, 1}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kSign, "Track selection: ")}; - Configurable> confTrkPtmin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kpTMin, "ConfTrk"), std::vector{0.5f, 0.4f, 0.6f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kpTMin, "Track selection: ")}; - Configurable> confTrkPtmax{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kpTMax, "ConfTrk"), std::vector{5.4f, 5.6f, 5.5f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kpTMax, "Track selection: ")}; - Configurable> confTrkEta{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kEtaMax, "ConfTrk"), std::vector{0.8f, 0.7f, 0.9f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kEtaMax, "Track selection: ")}; - Configurable> confTrkTPCnclsMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCnClsMin, "ConfTrk"), std::vector{70.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCnClsMin, "Track selection: ")}; - Configurable> confTrkTPCfCls{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCfClsMin, "ConfTrk"), std::vector{0.83f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCfClsMin, "Track selection: ")}; - Configurable> confTrkTPCcRowsMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCcRowsMin, "ConfTrk"), std::vector{70.f, 60.f, 80.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCcRowsMin, "Track selection: ")}; - Configurable> confTrkTPCsCls{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCsClsMax, "ConfTrk"), std::vector{0.1f, 160.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCsClsMax, "Track selection: ")}; - Configurable> confTrkITSnclsMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kITSnClsMin, "ConfTrk"), std::vector{-1.f, 2.f, 4.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kITSnClsMin, "Track selection: ")}; - Configurable> confTrkITSnclsIbMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kITSnClsIbMin, "ConfTrk"), std::vector{-1.f, 1.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kITSnClsIbMin, "Track selection: ")}; - Configurable> confTrkDCAxyMax{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kDCAxyMax, "ConfTrk"), std::vector{0.1f, 3.5f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kDCAxyMax, "Track selection: ")}; - Configurable> confTrkDCAzMax{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kDCAzMax, "ConfTrk"), std::vector{0.2f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kDCAzMax, "Track selection: ")}; /// \todo Reintegrate PID to the general selection container - Configurable> confTrkPIDnSigmaMax{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kPIDnSigmaMax, "ConfTrk"), std::vector{3.5f, 3.f, 2.5f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kPIDnSigmaMax, "Track selection: ")}; + struct : o2::framework::ConfigurableGroup { + Configurable> confTrkCharge{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kSign, "ConfTrk"), std::vector{-1, 1}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kSign, "Track selection: ")}; + Configurable> confTrkPtmin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kpTMin, "ConfTrk"), std::vector{0.5f, 0.4f, 0.6f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kpTMin, "Track selection: ")}; + Configurable> confTrkPtmax{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kpTMax, "ConfTrk"), std::vector{5.4f, 5.6f, 5.5f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kpTMax, "Track selection: ")}; + Configurable> confTrkEta{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kEtaMax, "ConfTrk"), std::vector{0.8f, 0.7f, 0.9f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kEtaMax, "Track selection: ")}; + Configurable> confTrkTPCnclsMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCnClsMin, "ConfTrk"), std::vector{70.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCnClsMin, "Track selection: ")}; + Configurable> confTrkTPCfCls{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCfClsMin, "ConfTrk"), std::vector{0.83f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCfClsMin, "Track selection: ")}; + Configurable> confTrkTPCcRowsMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCcRowsMin, "ConfTrk"), std::vector{70.f, 60.f, 80.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCcRowsMin, "Track selection: ")}; + Configurable> confTrkTPCsCls{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCsClsMax, "ConfTrk"), std::vector{0.1f, 160.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCsClsMax, "Track selection: ")}; + Configurable> confTrkTPCfracsCls{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kTPCfracsClsMax, "ConfTrk"), std::vector{0.1f, 160.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kTPCfracsClsMax, "Track selection: ")}; + Configurable> confTrkITSnclsMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kITSnClsMin, "ConfTrk"), std::vector{-1.f, 2.f, 4.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kITSnClsMin, "Track selection: ")}; + Configurable> confTrkITSnclsIbMin{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kITSnClsIbMin, "ConfTrk"), std::vector{-1.f, 1.f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kITSnClsIbMin, "Track selection: ")}; + Configurable> confTrkDCAxyMax{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kDCAxyMax, "ConfTrk"), std::vector{0.1f, 3.5f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kDCAxyMax, "Track selection: ")}; + Configurable> confTrkDCAzMax{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kDCAzMax, "ConfTrk"), std::vector{0.2f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kDCAzMax, "Track selection: ")}; /// \todo Reintegrate PID to the general selection container + Configurable> confTrkPIDnSigmaMax{FemtoUniverseTrackSelection::getSelectionName(femto_universe_track_selection::kPIDnSigmaMax, "ConfTrk"), std::vector{3.5f, 3.f, 2.5f}, FemtoUniverseTrackSelection::getSelectionHelper(femto_universe_track_selection::kPIDnSigmaMax, "Track selection: ")}; + Configurable> confTrkPIDspecies{"confTrkPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Kaon, o2::track::PID::Proton, o2::track::PID::Deuteron}, "Trk sel: Particles species for PID (Pion=2, Kaon=3, Proton=4, Deuteron=5)"}; + // Numbers from ~/alice/O2/DataFormats/Reconstruction/include/ReconstructionDataFormats/PID.h //static constexpr ID Pion = 2; static constexpr ID Kaon = 3; static constexpr ID Proton = 4; static constexpr ID Deuteron = 5; + } ConfTrkSelection; + Configurable confTrkPIDnSigmaOffsetTPC{"confTrkPIDnSigmaOffsetTPC", 0., "Offset for TPC nSigma because of bad calibration"}; Configurable confTrkPIDnSigmaOffsetTOF{"confTrkPIDnSigmaOffsetTOF", 0., "Offset for TOF nSigma because of bad calibration"}; - Configurable> confTrkPIDspecies{"confTrkPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Kaon, o2::track::PID::Proton, o2::track::PID::Deuteron}, "Trk sel: Particles species for PID (Pion=2, Kaon=3, Proton=4, Deuteron=5)"}; - // Numbers from ~/alice/O2/DataFormats/Reconstruction/include/ReconstructionDataFormats/PID.h //static constexpr ID Pion = 2; static constexpr ID Kaon = 3; static constexpr ID Proton = 4; static constexpr ID Deuteron = 5; Configurable confTOFpTmin{"confTOFpTmin", 500, "TOF pT min"}; // TrackSelection *o2PhysicsTrackSelection; @@ -184,7 +208,6 @@ struct FemtoUniverseProducerTask { // V0 FemtoUniverseV0Selection v0Cuts; struct : o2::framework::ConfigurableGroup { - // Configurable confIsFillV0s{"confIsFillV0s", false, "Choice to fill V0s"}; //Commented: not used configurable Configurable> confV0Sign{FemtoUniverseV0Selection::getSelectionName(femto_universe_v0_selection::kV0Sign, "ConfV0"), std::vector{-1, 1}, FemtoUniverseV0Selection::getSelectionHelper(femto_universe_v0_selection::kV0Sign, "V0 selection: ")}; Configurable> confV0PtMin{FemtoUniverseV0Selection::getSelectionName(femto_universe_v0_selection::kV0pTMin, "ConfV0"), std::vector{0.3f, 0.4f, 0.5f}, FemtoUniverseV0Selection::getSelectionHelper(femto_universe_v0_selection::kV0pTMin, "V0 selection: ")}; Configurable> confV0PtMax{FemtoUniverseV0Selection::getSelectionName(femto_universe_v0_selection::kV0pTMax, "ConfV0"), std::vector{3.3f, 3.4f, 3.5f}, FemtoUniverseV0Selection::getSelectionHelper(femto_universe_v0_selection::kV0pTMax, "V0 selection: ")}; @@ -233,7 +256,6 @@ struct FemtoUniverseProducerTask { // CASCADE FemtoUniverseCascadeSelection cascadeCuts; struct : o2::framework::ConfigurableGroup { - // Configurable confIsFillCascades{"confIsFillCascades", false, "Choice to fill cascades"}; //Commented: not used configurable Configurable> confCascSign{FemtoUniverseCascadeSelection::getSelectionName(femto_universe_cascade_selection::kCascadeSign, "ConfCasc"), std::vector{-1, 1}, FemtoUniverseCascadeSelection::getSelectionHelper(femto_universe_cascade_selection::kCascadeSign, "Cascade selection: ")}; Configurable> confCascPtMin{FemtoUniverseCascadeSelection::getSelectionName(femto_universe_cascade_selection::kCascadepTMin, "ConfCasc"), std::vector{0.3f, 0.4f, 0.5f}, FemtoUniverseCascadeSelection::getSelectionHelper(femto_universe_cascade_selection::kCascadepTMin, "Cascade selection: ")}; Configurable> confCascPtMax{FemtoUniverseCascadeSelection::getSelectionName(femto_universe_cascade_selection::kCascadepTMax, "ConfCasc"), std::vector{3.3f, 3.4f, 3.5f}, FemtoUniverseCascadeSelection::getSelectionHelper(femto_universe_cascade_selection::kCascadepTMax, "Cascade selection: ")}; @@ -263,29 +285,32 @@ struct FemtoUniverseProducerTask { Configurable> confCascChildPIDnSigmaMax{"confCascChildPIDnSigmaMax", std::vector{3.f, 4.f}, "Cascade Child sel: Max. PID nSigma TPC"}; Configurable> confCascChildPIDspecies{"confCascChildPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Proton}, "Cascade Child sel: particle species for PID"}; - Configurable confCascInvMassLowLimit{"confCascInvMassLowLimit", 1.25, "Lower limit of the cascade invariant mass"}; - Configurable confCascInvMassUpLimit{"confCascInvMassUpLimit", 1.40, "Upper limit of the cascade invariant mass"}; - - Configurable confCascRejectCompetingMass{"confCascRejectCompetingMass", false, "Switch on to reject Omegas (for Xi) or Xis (for Omegas)"}; - Configurable confCascInvCompetingMassLowLimit{"confCascInvCompetingMassLowLimit", 1.66, "Lower limit of the cascade invariant mass for competing mass rejection"}; - Configurable confCascInvCompetingMassUpLimit{"confCascInvCompetingMassUpLimit", 1.68, "Upper limit of the cascade invariant mass for competing mass rejection"}; + Configurable confXiInvMassLowLimit{"confXiInvMassLowLimit", 1.25, "Lower limit of the Xi invariant mass"}; + Configurable confXiInvMassUpLimit{"confXiInvMassUpLimit", 1.40, "Upper limit of the Xi invariant mass"}; + Configurable confOmegaInvMassLowLimit{"confOmegaInvMassLowLimit", 1.60, "Lower limit of the Omega invariant mass"}; + Configurable confOmegaInvMassUpLimit{"confOmegaInvMassUpLimit", 1.80, "Upper limit of the Omega invariant mass"}; } ConfCascadeSelection; // PHI FemtoUniversePhiSelection phiCuts; struct : o2::framework::ConfigurableGroup { /// Phi meson - Configurable confInvMassLowLimitPhi{"confInvMassLowLimitPhi", 1.011, "Lower limit of the Phi invariant mass"}; // change that to do invariant mass cut - Configurable confInvMassUpLimitPhi{"confInvMassUpLimitPhi", 1.027, "Upper limit of the Phi invariant mass"}; - Configurable confPtLowLimitPhi{"confPtLowLimitPhi", 0.8, "Lower limit of the Phi pT."}; - Configurable confPtHighLimitPhi{"confPtHighLimitPhi", 4.0, "Higher limit of the Phi pT."}; + Configurable confPhiPtLowLimit{"confPhiPtLowLimit", 0.8, "Lower limit of the Phi pT."}; + Configurable confPhiPtHighLimit{"confPhiPtHighLimit", 4.0, "Higher limit of the Phi pT."}; + Configurable confPhiInvMassLowLimit{"confPhiInvMassLowLimit", 1.011, "Lower limit of the Phi invariant mass"}; + Configurable confPhiInvMassUpLimit{"confPhiInvMassUpLimit", 1.027, "Upper limit of the Phi invariant mass"}; // Phi meson daughters - Configurable confLooseTPCNSigma{"confLooseTPCNSigma", false, "Use loose TPC N sigmas for Kaon PID."}; - Configurable confLooseTPCNSigmaValue{"confLooseTPCNSigmaValue", 10, "Value for the loose TPC N Sigma for Kaon PID."}; - Configurable confLooseTOFNSigma{"confLooseTOFNSigma", false, "Use loose TPC N sigmas for Kaon PID."}; - Configurable confNsigmaRejectPion{"confNsigmaRejectPion", 3.0, "Reject if particle could be a Pion combined nsigma value."}; - Configurable confNsigmaRejectProton{"confNsigmaRejectProton", 3.0, "Reject if particle could be a Proton combined nsigma value."}; - Configurable confLooseTOFNSigmaValue{"confLooseTOFNSigmaValue", 10, "Value for the loose TOF N Sigma for Kaon PID."}; + Configurable confPhiKaonRejectPionNsigma{"confPhiKaonRejectPionNsigma", 3.0, "Reject if particle could be a Pion combined nsigma value."}; + Configurable confPhiKaonRejectProtonNsigma{"confPhiKaonRejectProtonNsigma", 3.0, "Reject if particle could be a Proton combined nsigma value."}; + // Kaons + Configurable confPhiDoLFPID4Kaons{"confPhiDoLFPID4Kaons", true, "Switch on do PID for Kaons as in LF"}; + Configurable confPhiKaonNsigmaTPCfrom0_0to0_3{"confPhiKaonNsigmaTPCfrom0_0to0_3", 3.0, "Reject if Kaons in 0.0-0.3 are have TPC n sigma above this value."}; + Configurable confPhiKaonNsigmaTPCfrom0_3to0_45{"confPhiKaonNsigmaTPCfrom0_3to0_45", 2.0, "Reject if Kaons in 0.3-0.45 are have TPC n sigma above this value."}; + Configurable confPhiKaonNsigmaTPCfrom0_45to0_55{"confPhiKaonNsigmaTPCfrom0_45to0_55", 1.0, "Reject if Kaons in 0.45-0.55 are have TPC n sigma above this value."}; + Configurable confPhiKaonNsigmaTPCfrom0_55to1_5{"confPhiKaonNsigmaTPCfrom0_55to1_5", 3.0, "Reject if Kaons in 0.55-1.5 are have TPC n sigma above this value."}; + Configurable confPhiKaonNsigmaTOFfrom0_55to1_5{"confPhiKaonNsigmaTOFfrom0_55to1_5", 3.0, "Reject if Kaons in 0.55-1.5 are have TOF n sigma above this value."}; + Configurable confPhiKaonNsigmaTPCfrom1_5{"confPhiKaonNsigmaTPCfrom1_5", 3.0, "Reject if Kaons above 1.5 are have TPC n sigma above this value."}; + Configurable confPhiKaonNsigmaTOFfrom1_5{"confPhiKaonNsigmaTOFfrom1_5", 3.0, "Reject if Kaons above 1.5 are have TOF n sigma above this value."}; } ConfPhiSelection; // PDG codes for fillMCParticle function @@ -296,33 +321,45 @@ struct FemtoUniverseProducerTask { struct : o2::framework::ConfigurableGroup { Configurable confD0D0barCandMaxY{"confD0D0barCandMaxY", -1., "max. cand. rapidity"}; Configurable confD0D0barCandEtaCut{"confD0D0barCandEtaCut", 0.8, "max. cand. pseudorapidity"}; + Configurable yD0D0barCandRecoMax{"yD0D0barCandRecoMax", 0.8, "MC Reco, max. rapidity of D0/D0bar cand."}; + Configurable yD0D0barCandGenMax{"yD0D0barCandGenMax", 0.8, "MC Truth, max. rapidity of D0/D0bar cand."}; + Configurable storeD0D0barDoubleMassHypo{"storeD0D0barDoubleMassHypo", false, "Store D0/D0bar cand. which pass selection criteria for both, D0 and D0bar"}; + Configurable> classMlD0D0bar{"classMlD0D0bar", {0, 1, 2}, "Indexes of ML scores to be stored. Three indexes max."}; } ConfD0Selection; - HfHelper hfHelper; + // PID bitmask configurables + struct : o2::framework::ConfigurableGroup { + Configurable confMinMomTOF{"confMinMomTOF", 0.75, "momentum threshold for particle identification using TOF"}; + Configurable confNsigmaTPCParticleChild{"confNsigmaTPCParticleChild", 3.0, "TPC Sigma for particle (daugh & bach) momentum < Confmom"}; + Configurable confNsigmaTOFParticleChild{"confNsigmaTOFParticleChild", 3.0, "TOF Sigma for particle (daugh & bach) momentum > Confmom"}; + Configurable confNsigmaTPCParticle{"confNsigmaTPCParticle", 3.0, "TPC Sigma for particle (track) momentum < Confmom"}; + Configurable confNsigmaCombinedParticle{"confNsigmaCombinedParticle", 3.0, "TPC and TOF Sigma (combined) for particle (track) momentum > Confmom"}; + } ConfPIDBitmask; + HfHelper hfHelper; bool isKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK) { if (mom < 0.3) { // 0.0-0.3 - if (std::abs(nsigmaTPCK) < 3.0) { + if (std::abs(nsigmaTPCK) < ConfPhiSelection.confPhiKaonNsigmaTPCfrom0_0to0_3) { return true; } else { return false; } } else if (mom < 0.45) { // 0.30 - 0.45 - if (std::abs(nsigmaTPCK) < 2.0) { + if (std::abs(nsigmaTPCK) < ConfPhiSelection.confPhiKaonNsigmaTPCfrom0_3to0_45) { return true; } else { return false; } } else if (mom < 0.55) { // 0.45-0.55 - if (std::abs(nsigmaTPCK) < 1.0) { + if (std::abs(nsigmaTPCK) < ConfPhiSelection.confPhiKaonNsigmaTPCfrom0_45to0_55) { return true; } else { return false; } } else if (mom < 1.5) { // 0.55-1.5 (now we use TPC and TOF) - if ((std::abs(nsigmaTOFK) < 3.0) && (std::abs(nsigmaTPCK) < 3.0)) { + if ((std::abs(nsigmaTOFK) < ConfPhiSelection.confPhiKaonNsigmaTOFfrom0_55to1_5) && (std::abs(nsigmaTPCK) < ConfPhiSelection.confPhiKaonNsigmaTPCfrom0_55to1_5)) { { return true; } @@ -330,45 +367,7 @@ struct FemtoUniverseProducerTask { return false; } } else if (mom > 1.5) { // 1.5 - - if ((std::abs(nsigmaTOFK) < 2.0) && (std::abs(nsigmaTPCK) < 3.0)) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - bool isKaonNSigmaTPCLoose(float mom, float nsigmaTPCK, float nsigmaTOFK) - { - - if (mom < 0.3) { // 0.0-0.3 - if (std::abs(nsigmaTPCK) < ConfPhiSelection.confLooseTPCNSigmaValue.value) { - return true; - } else { - return false; - } - } else if (mom < 0.45) { // 0.30 - 0.45 - if (std::abs(nsigmaTPCK) < ConfPhiSelection.confLooseTPCNSigmaValue.value) { - return true; - } else { - return false; - } - } else if (mom < 0.55) { // 0.45-0.55 - if (std::abs(nsigmaTPCK) < ConfPhiSelection.confLooseTPCNSigmaValue.value) { - return true; - } else { - return false; - } - } else if (mom < 1.5) { // 0.55-1.5 (now we use TPC and TOF) - if ((std::abs(nsigmaTOFK) < 3.0) && (std::abs(nsigmaTPCK) < ConfPhiSelection.confLooseTPCNSigmaValue.value)) { - return true; - } else { - return false; - } - } else if (mom > 1.5) { // 1.5 - - if ((std::abs(nsigmaTOFK) < 2.0) && (std::abs(nsigmaTPCK) < ConfPhiSelection.confLooseTPCNSigmaValue.value)) { + if ((std::abs(nsigmaTOFK) < ConfPhiSelection.confPhiKaonNsigmaTOFfrom1_5) && (std::abs(nsigmaTPCK) < ConfPhiSelection.confPhiKaonNsigmaTPCfrom1_5)) { return true; } else { return false; @@ -378,39 +377,23 @@ struct FemtoUniverseProducerTask { } } - bool isKaonNSigmaTOFLoose(float mom, float nsigmaTPCK, float nsigmaTOFK) + bool isKaonNSigmaLF(float mom, float nsigmaTPCK, float nsigmaTOFK, bool hasTOF) { - if (mom < 0.3) { // 0.0-0.3 + if (mom < 0.5) { if (std::abs(nsigmaTPCK) < 3.0) { return true; } else { return false; } - } else if (mom < 0.45) { // 0.30 - 0.45 - if (std::abs(nsigmaTPCK) < 2.0) { - return true; - } else { + } else if (mom >= 0.5) { // 0.55-1.5 (now we use TPC and TOF) + if (!hasTOF) { return false; - } - } else if (mom < 0.55) { // 0.45-0.55 - if (std::abs(nsigmaTPCK) < 1.0) { - return true; } else { - return false; - } - } else if (mom < 1.5) { // 0.55-1.5 (now we use TPC and TOF) - if ((std::abs(nsigmaTOFK) < ConfPhiSelection.confLooseTOFNSigmaValue.value) && (std::abs(nsigmaTPCK) < 3.0)) { - { + if (std::sqrt(nsigmaTPCK * nsigmaTPCK + nsigmaTOFK * nsigmaTOFK) < 3.0) { return true; + } else { + return false; } - } else { - return false; - } - } else if (mom > 1.5) { // 1.5 - - if ((std::abs(nsigmaTOFK) < ConfPhiSelection.confLooseTOFNSigmaValue.value) && (std::abs(nsigmaTPCK) < 3.0)) { - return true; - } else { - return false; } } else { return false; @@ -420,16 +403,16 @@ struct FemtoUniverseProducerTask { bool isKaonRejected(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi) { if (mom < 0.5) { - if (std::abs(nsigmaTPCPi) < ConfPhiSelection.confNsigmaRejectPion.value) { + if (std::abs(nsigmaTPCPi) < ConfPhiSelection.confPhiKaonRejectPionNsigma.value) { return true; - } else if (std::abs(nsigmaTPCPr) < ConfPhiSelection.confNsigmaRejectProton.value) { + } else if (std::abs(nsigmaTPCPr) < ConfPhiSelection.confPhiKaonRejectProtonNsigma.value) { return true; } } if (mom > 0.5) { - if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfPhiSelection.confNsigmaRejectPion.value) { + if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfPhiSelection.confPhiKaonRejectPionNsigma.value) { return true; - } else if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfPhiSelection.confNsigmaRejectProton.value) { + } else if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfPhiSelection.confPhiKaonRejectProtonNsigma.value) { return true; } else { return false; @@ -439,6 +422,65 @@ struct FemtoUniverseProducerTask { } } + bool isNSigmaTPC(float nsigmaTPCParticle) + { + return (std::abs(nsigmaTPCParticle) < ConfPIDBitmask.confNsigmaTPCParticleChild); + } + + bool isNSigmaTOF(float mom, float nsigmaTOFParticle, bool hasTOF) + { + // Cut only on daughter and bachelor tracks, that have TOF signal + if (mom > ConfPIDBitmask.confMinMomTOF && hasTOF) { + return (std::abs(nsigmaTOFParticle) < ConfPIDBitmask.confNsigmaTOFParticleChild); + } else { + return true; + } + } + + bool isNSigmaCombined(float mom, float nsigmaTPCParticle, float nsigmaTOFParticle) + { + if (mom <= ConfPIDBitmask.confMinMomTOF) { + return (std::abs(nsigmaTPCParticle) < ConfPIDBitmask.confNsigmaTPCParticle); + } else { + return (TMath::Hypot(nsigmaTOFParticle, nsigmaTPCParticle) < ConfPIDBitmask.confNsigmaCombinedParticle); + } + } + + template + aod::femtouniverseparticle::CutContainerType PIDBitmask(const TrackType& track) + { + static const o2::track::PID pids[] = {o2::track::PID::Proton, o2::track::PID::Pion, o2::track::PID::Kaon}; + aod::femtouniverseparticle::CutContainerType mask = 0u; + for (UInt_t i = 0; i < 3; ++i) { + if (isNSigmaTPC(trackCuts.getNsigmaTPC(track, pids[i]))) + mask |= (1u << i); + if (isNSigmaTOF(track.p(), trackCuts.getNsigmaTOF(track, pids[i]), track.hasTOF())) + mask |= (8u << i); + if (isNSigmaCombined(track.p(), trackCuts.getNsigmaTPC(track, pids[i]), trackCuts.getNsigmaTOF(track, pids[i]))) + mask |= (64u << i); + } + if (track.hasTOF()) + mask |= (512u); + return mask; + } + + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + int mRunNumberZorro = 0; + + HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::QAObject}; + HistogramRegistry cascadeQaRegistry{"CascadeQAHistos", {}, OutputObjHandlingPolicy::QAObject}; + + void initZorro(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumberZorro == bc.runNumber()) + return; + + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), zorroMask.value); + zorro.populateHistRegistry(qaRegistry, bc.runNumber()); + mRunNumberZorro = bc.runNumber(); + } + /// \todo should we add filter on min value pT/eta of V0 and daughters? /*Filter v0Filter = (nabs(aod::v0data::x) < V0DecVtxMax.value) && (nabs(aod::v0data::y) < V0DecVtxMax.value) && @@ -446,9 +488,6 @@ struct FemtoUniverseProducerTask { // (aod::v0data::v0radius > V0TranRadV0Min.value); to be added, not working // for now do not know why - HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::QAObject}; - HistogramRegistry cascadeQaRegistry{"CascadeQAHistos", {}, OutputObjHandlingPolicy::QAObject}; - int mRunNumber = 0; float mMagField; Service ccdb; /// Accessing the CCDB @@ -456,32 +495,35 @@ struct FemtoUniverseProducerTask { void init(InitContext&) { - if ((doprocessFullData || doprocessTrackPhiData || doprocessTrackData || doprocessTrackV0 || doprocessTrackCascadeData || doprocessTrackD0mesonData || doprocessTrackCentRun2Data || doprocessTrackCentRun3Data || doprocessV0CentRun3Data || doprocessCascadeCentRun3Data) == false && (doprocessFullMC || doprocessTrackMC || doprocessTrackMCTruth || doprocessTrackMCGen || doprocessTruthAndFullMC || doprocessFullMCCent) == false) { + if ((doprocessFullData || doprocessTrackPhiData || doprocessTrackData || doprocessTrackV0 || doprocessTrackCascadeData || doprocessTrackV0Cascade || doprocessTrackD0mesonData || doprocessTrackD0DataML || doprocessTrackCentRun2Data || doprocessTrackV0CentRun2Data || doprocessTrackCentRun3Data || doprocessV0CentRun3Data || doprocessCascadeCentRun3Data || doprocessTrackDataCentPP) == false && (doprocessFullMC || doprocessTrackMC || doprocessTrackMCTruth || doprocessTrackMCGen || doprocessTruthAndFullMCV0 || doprocessTrackD0MC || doprocessTruthAndFullMCCasc || doprocessFullMCCent || doprocessTrackCentRun3DataMC || doprocessTruthAndFullMCCentRun3 || doprocessTruthAndFullMCCentRun3V0) == false) { LOGF(fatal, "Neither processFullData nor processFullMC enabled. Please choose one."); } - if ((doprocessFullData || doprocessTrackPhiData || doprocessTrackData || doprocessTrackV0 || doprocessTrackCascadeData || doprocessTrackD0mesonData || doprocessTrackCentRun2Data || doprocessTrackCentRun3Data || doprocessV0CentRun3Data || doprocessCascadeCentRun3Data) == true && (doprocessFullMC || doprocessTrackMC || doprocessTrackMCTruth || doprocessTrackMCGen || doprocessTruthAndFullMC || doprocessFullMCCent) == true) { + if ((doprocessFullData || doprocessTrackPhiData || doprocessTrackData || doprocessTrackV0 || doprocessTrackCascadeData || doprocessTrackV0Cascade || doprocessTrackD0mesonData || doprocessTrackD0DataML || doprocessTrackCentRun2Data || doprocessTrackV0CentRun2Data || doprocessTrackCentRun3Data || doprocessV0CentRun3Data || doprocessCascadeCentRun3Data || doprocessTrackDataCentPP) == true && (doprocessFullMC || doprocessTrackMC || doprocessTrackMCTruth || doprocessTrackMCGen || doprocessTruthAndFullMCV0 || doprocessTrackD0MC || doprocessTruthAndFullMCCasc || doprocessFullMCCent || doprocessTrackCentRun3DataMC || doprocessTruthAndFullMCCentRun3 || doprocessTruthAndFullMCCentRun3V0) == true) { LOGF(fatal, "Cannot enable process Data and process MC at the same time. " "Please choose one."); } - colCuts.setCuts(confEvtZvtx, confEvtTriggerCheck, confEvtTriggerSel, confEvtOfflineCheck, confIsRun3, confCentFT0Min, confCentFT0Max); + zorroSummary.setObject(zorro.getZorroSummary()); + + colCuts.setCuts(ConfGeneral.confEvtZvtx, ConfGeneral.confEvtTriggerCheck, ConfGeneral.confEvtTriggerSel, ConfGeneral.confEvtOfflineCheck, confIsRun3, ConfGeneral.confCentFT0Min, ConfGeneral.confCentFT0Max); colCuts.init(&qaRegistry); - trackCuts.setSelection(confTrkCharge, femto_universe_track_selection::kSign, femto_universe_selection::kEqual); - trackCuts.setSelection(confTrkPtmin, femto_universe_track_selection::kpTMin, femto_universe_selection::kLowerLimit); - trackCuts.setSelection(confTrkPtmax, femto_universe_track_selection::kpTMax, femto_universe_selection::kUpperLimit); - trackCuts.setSelection(confTrkEta, femto_universe_track_selection::kEtaMax, femto_universe_selection::kAbsUpperLimit); - trackCuts.setSelection(confTrkTPCnclsMin, femto_universe_track_selection::kTPCnClsMin, femto_universe_selection::kLowerLimit); - trackCuts.setSelection(confTrkTPCfCls, femto_universe_track_selection::kTPCfClsMin, femto_universe_selection::kLowerLimit); - trackCuts.setSelection(confTrkTPCcRowsMin, femto_universe_track_selection::kTPCcRowsMin, femto_universe_selection::kLowerLimit); - trackCuts.setSelection(confTrkTPCsCls, femto_universe_track_selection::kTPCsClsMax, femto_universe_selection::kUpperLimit); - trackCuts.setSelection(confTrkITSnclsMin, femto_universe_track_selection::kITSnClsMin, femto_universe_selection::kLowerLimit); - trackCuts.setSelection(confTrkITSnclsIbMin, femto_universe_track_selection::kITSnClsIbMin, femto_universe_selection::kLowerLimit); - trackCuts.setSelection(confTrkDCAxyMax, femto_universe_track_selection::kDCAxyMax, femto_universe_selection::kAbsUpperLimit); - trackCuts.setSelection(confTrkDCAzMax, femto_universe_track_selection::kDCAzMax, femto_universe_selection::kAbsUpperLimit); - trackCuts.setSelection(confTrkPIDnSigmaMax, femto_universe_track_selection::kPIDnSigmaMax, femto_universe_selection::kAbsUpperLimit); - trackCuts.setPIDSpecies(confTrkPIDspecies); + trackCuts.setSelection(ConfTrkSelection.confTrkCharge, femto_universe_track_selection::kSign, femto_universe_selection::kEqual); + trackCuts.setSelection(ConfTrkSelection.confTrkPtmin, femto_universe_track_selection::kpTMin, femto_universe_selection::kLowerLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkPtmax, femto_universe_track_selection::kpTMax, femto_universe_selection::kUpperLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkEta, femto_universe_track_selection::kEtaMax, femto_universe_selection::kAbsUpperLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkTPCnclsMin, femto_universe_track_selection::kTPCnClsMin, femto_universe_selection::kLowerLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkTPCfCls, femto_universe_track_selection::kTPCfClsMin, femto_universe_selection::kLowerLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkTPCcRowsMin, femto_universe_track_selection::kTPCcRowsMin, femto_universe_selection::kLowerLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkTPCsCls, femto_universe_track_selection::kTPCsClsMax, femto_universe_selection::kUpperLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkTPCfracsCls, femto_universe_track_selection::kTPCfracsClsMax, femto_universe_selection::kUpperLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkITSnclsMin, femto_universe_track_selection::kITSnClsMin, femto_universe_selection::kLowerLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkITSnclsIbMin, femto_universe_track_selection::kITSnClsIbMin, femto_universe_selection::kLowerLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkDCAxyMax, femto_universe_track_selection::kDCAxyMax, femto_universe_selection::kAbsUpperLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkDCAzMax, femto_universe_track_selection::kDCAzMax, femto_universe_selection::kAbsUpperLimit); + trackCuts.setSelection(ConfTrkSelection.confTrkPIDnSigmaMax, femto_universe_track_selection::kPIDnSigmaMax, femto_universe_selection::kAbsUpperLimit); + trackCuts.setPIDSpecies(ConfTrkSelection.confTrkPIDspecies); trackCuts.setnSigmaPIDOffset(confTrkPIDnSigmaOffsetTPC, confTrkPIDnSigmaOffsetTOF); trackCuts.init(&qaRegistry); @@ -489,7 +531,7 @@ struct FemtoUniverseProducerTask { /// different type! // v0Cuts.setSelection(ConfV0Selection->getRow(0), // femto_universe_v0_selection::kDecVtxMax, femto_universe_selection::kAbsUpperLimit); - if (confIsActivateV0) { + if (ConfGeneral.confIsActivateV0) { // initializing for V0 v0Cuts.setSelection(ConfV0Selection.confV0Sign, femto_universe_v0_selection::kV0Sign, femto_universe_selection::kEqual); v0Cuts.setSelection(ConfV0Selection.confV0PtMin, femto_universe_v0_selection::kV0pTMin, femto_universe_selection::kLowerLimit); @@ -532,7 +574,7 @@ struct FemtoUniverseProducerTask { // } } - if (confIsActivateCascade) { + if (ConfGeneral.confIsActivateCascade) { // initializing for cascades cascadeCuts.setSelection(ConfCascadeSelection.confCascSign, femto_universe_cascade_selection::kCascadeSign, femto_universe_selection::kEqual); cascadeCuts.setSelection(ConfCascadeSelection.confCascPtMin, femto_universe_cascade_selection::kCascadepTMin, femto_universe_selection::kLowerLimit); @@ -576,16 +618,12 @@ struct FemtoUniverseProducerTask { cascadeCuts.setChildPIDSpecies(femto_universe_cascade_selection::kBachTrack, ConfCascadeSelection.confCascChildPIDspecies); // check if works correctly for bachelor track - cascadeCuts.init(&cascadeQaRegistry, confIsSelectCascOmega); + cascadeCuts.init(&cascadeQaRegistry); // invmass cuts - cascadeCuts.setInvMassLimits(ConfCascadeSelection.confCascInvMassLowLimit, ConfCascadeSelection.confCascInvMassUpLimit); - - if (ConfCascadeSelection.confCascRejectCompetingMass) { - cascadeCuts.setCompetingInvMassLimits(ConfCascadeSelection.confCascInvCompetingMassLowLimit, ConfCascadeSelection.confCascInvCompetingMassUpLimit); - } + cascadeCuts.setInvMassLimits(ConfCascadeSelection.confXiInvMassLowLimit, ConfCascadeSelection.confOmegaInvMassLowLimit, ConfCascadeSelection.confXiInvMassUpLimit, ConfCascadeSelection.confOmegaInvMassUpLimit); } - if (confIsActivatePhi) { + if (ConfGeneral.confIsActivatePhi) { // initializing for Phi meson phiCuts.init(&qaRegistry); } @@ -644,7 +682,7 @@ struct FemtoUniverseProducerTask { outputDebugParts(particle.sign(), (uint8_t)particle.tpcNClsFound(), particle.tpcNClsFindable(), (uint8_t)particle.tpcNClsCrossedRows(), - particle.tpcNClsShared(), particle.tpcInnerParam(), + particle.tpcNClsShared(), particle.tpcFractionSharedCls(), particle.tpcInnerParam(), particle.itsNCls(), particle.itsNClsInnerBarrel(), particle.dcaXY(), particle.dcaZ(), particle.tpcSignal(), particle.tpcNSigmaStoreEl(), particle.tpcNSigmaStorePi(), @@ -654,14 +692,14 @@ struct FemtoUniverseProducerTask { particle.tofNSigmaStorePr(), particle.tofNSigmaStoreDe(), -999., -999., -999., -999., -999., -999.); } else if constexpr (isPhiOrD0) { - outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., + outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., - -999.); // QA for phi or D0/D0bar + -999.); // QA for phi or D0/D0bar children } else if constexpr (isXi) { - outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., + outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., particle.dcacascdaughters(), particle.cascradius(), @@ -669,7 +707,7 @@ struct FemtoUniverseProducerTask { particle.mOmega()); // QA for Xi Cascades (later do the same for Omegas) } else { // LOGF(info, "isTrack0orV0: %d, isPhi: %d", isTrackOrV0, isPhiOrD0); - outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., + outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., -999., particle.dcav0topv(), -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., particle.dcaV0daughters(), particle.v0radius(), @@ -678,6 +716,53 @@ struct FemtoUniverseProducerTask { } } + template + void fillDebugD0D0barML(ParticleType const& particle) + { + if constexpr (isD0ML) { + outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., + -999., -999., + particle.mlProbD0()[0], // getter decayVtxX + particle.mlProbD0()[1], // getter decayVtxY + particle.mlProbD0()[2], // getter decayVtxZ + -999.); // Additional info for D0/D0bar + } else if constexpr (isD0barML) { + outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., + -999., -999., + particle.mlProbD0bar()[0], // getter decayVtxX + particle.mlProbD0bar()[1], // getter decayVtxY + particle.mlProbD0bar()[2], // getter decayVtxZ + -999.); // Additional info for D0/D0bar + } else { + outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., + -999., -999., -999., -999., -999., -999.); + } + } + + template + int32_t getMotherPDG(ParticleType particle) + { + auto motherparticlesMC = particle.template mothers_as(); + if (!motherparticlesMC.empty()) { + auto motherparticleMC = motherparticlesMC.front(); + return particle.isPhysicalPrimary() ? 0 : motherparticleMC.pdgCode(); + } else { + return 9999; + } + } + + template + void fillDebugParticleMC(ParticleType const& particle) + { + outputDebugPartsMC(getMotherPDG(particle)); + } + template void fillMCParticle(ParticleType const& particle, o2::aod::femtouniverseparticle::ParticleType fdparttype) { @@ -693,19 +778,22 @@ struct FemtoUniverseProducerTask { particleOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kPrimary; } else if (!motherparticlesMC.empty()) { auto motherparticleMC = motherparticlesMC.front(); - if (motherparticleMC.producedByGenerator()) + if (motherparticleMC.producedByGenerator()) { particleOrigin = checkDaughterType(fdparttype, motherparticleMC.pdgCode()); - } else { - particleOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kMaterial; + } else { + particleOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kMaterial; + } } } else { particleOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kFake; } outputPartsMC(particleOrigin, pdgCode, particleMC.pt(), particleMC.eta(), particleMC.phi()); + fillDebugParticleMC(particleMC); outputPartsMCLabels(outputPartsMC.lastIndex()); } else { outputPartsMCLabels(-1); + outputDebugPartsMC(9999); } } @@ -764,6 +852,44 @@ struct FemtoUniverseProducerTask { } } + template + void fillMCParticleD0(ParticleType const& hfCand) + { + if (std::abs(hfCand.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + // get corresponding MC particle and its info + int pdgCode = 0; + int hfCandOrigin = 99; + + if (hfCand.originMcRec() == RecoDecay::OriginType::Prompt) { + if (hfCand.isSelD0() == 1 && hfCand.isSelD0bar() == 0) { + hfCandOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kPrompt; + pdgCode = static_cast(Pdg::kD0); + } else if (hfCand.isSelD0() == 0 && hfCand.isSelD0bar() == 1) { + hfCandOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kPrompt; + pdgCode = static_cast(Pdg::kD0Bar); + } else { + hfCandOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kFake; + pdgCode = 0; + } + } else { + if (hfCand.isSelD0() == 1 && hfCand.isSelD0bar() == 0) { + hfCandOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kNonPrompt; + pdgCode = static_cast(Pdg::kD0); + } else if (hfCand.isSelD0() == 0 && hfCand.isSelD0bar() == 1) { + hfCandOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kNonPrompt; + pdgCode = static_cast(Pdg::kD0Bar); + } else { + hfCandOrigin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kFake; + pdgCode = 0; + } + } + outputPartsMC(hfCandOrigin, pdgCode, hfCand.pt(), hfHelper.yD0(hfCand), hfCand.phi()); + outputPartsMCLabels(outputPartsMC.lastIndex()); + } else { + outputPartsMCLabels(-1); + } + } + template bool fillCollisions(CollisionType const& col, TrackType const& tracks) { @@ -778,7 +904,7 @@ struct FemtoUniverseProducerTask { /// FemtoUniverseRun2 is defined V0M/2 multNtr = col.multTracklets(); } - if (confEvtUseTPCmult) { + if (ConfGeneral.confEvtUseTPCmult) { multNtr = col.multTPC(); } @@ -789,24 +915,65 @@ struct FemtoUniverseProducerTask { // particle candidates for such collisions if (!colCuts.isSelected(col)) { return false; + } + + if (zorroMask.value != "") { + auto bc = col.template bc_as(); + initZorro(bc); + if (!zorro.isSelected(col.template bc_as().globalBC())) + return false; + } + + if (!ConfGeneral.confIsUsePileUp) { + outputCollision(vtxZ, mult, multNtr, confDoSpher ? colCuts.computeSphericity(col, tracks) : 2, mMagField); + colCuts.fillQA(col); + return true; + } else if ((!ConfGeneral.confEvNoSameBunchPileup || col.selection_bit(aod::evsel::kNoSameBunchPileup)) && (!ConfGeneral.confEvIsGoodZvtxFT0vsPV || col.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) && (!ConfGeneral.confEvIsVertexITSTPC || col.selection_bit(aod::evsel::kIsVertexITSTPC))) { + outputCollision(vtxZ, mult, multNtr, confDoSpher ? colCuts.computeSphericity(col, tracks) : 2, mMagField); + colCuts.fillQA(col); + return true; + } else { + return false; + } + } + + template + bool fillCollisionsCentPP(CollisionType const& col, TrackType const& tracks) + { + const auto vtxZ = col.posZ(); + float mult = 0; + int multNtr = 0; + if (confIsRun3) { + mult = col.centFT0M(); + multNtr = col.multNTracksPV(); } else { - if (!confIsUsePileUp) { - if (confDoSpher) { - outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField); - } else { - outputCollision(vtxZ, mult, multNtr, 2, mMagField); - } - } else { - if (confDoSpher && (!confEvNoSameBunchPileup || col.selection_bit(aod::evsel::kNoSameBunchPileup)) && (!confEvIsGoodZvtxFT0vsPV || col.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) && (!confEvIsVertexITSTPC || col.selection_bit(aod::evsel::kIsVertexITSTPC))) { - outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField); - } else { - outputCollision(vtxZ, mult, multNtr, 2, mMagField); - } - } + mult = 0.5 * (col.multFV0M()); /// For benchmarking on Run 2, V0M in + /// FemtoUniverseRun2 is defined V0M/2 + multNtr = col.multTracklets(); + } + if (ConfGeneral.confEvtUseTPCmult) { + multNtr = col.multTPC(); + } + + // check whether the basic event selection criteria are fulfilled + // if the basic selection is NOT fulfilled: + // in case of skimming run - don't store such collisions + // in case of trigger run - store such collisions but don't store any + // particle candidates for such collisions + if (!colCuts.isSelected(col)) { + return false; + } + if (!ConfGeneral.confIsUsePileUp) { + outputCollision(vtxZ, mult, multNtr, confDoSpher ? colCuts.computeSphericity(col, tracks) : 2, mMagField); + colCuts.fillQA(col); + return true; + } else if ((!ConfGeneral.confEvNoSameBunchPileup || col.selection_bit(aod::evsel::kNoSameBunchPileup)) && (!ConfGeneral.confEvIsGoodZvtxFT0vsPV || col.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) && (!ConfGeneral.confEvIsVertexITSTPC || col.selection_bit(aod::evsel::kIsVertexITSTPC))) { + outputCollision(vtxZ, mult, multNtr, confDoSpher ? colCuts.computeSphericity(col, tracks) : 2, mMagField); colCuts.fillQA(col); return true; + } else { + return false; } - return true; } template @@ -814,10 +981,10 @@ struct FemtoUniverseProducerTask { { for (const auto& c : col) { const auto vtxZ = c.posZ(); - float mult = 0; - int multNtr = 0; + float mult = confIsRun3 ? c.multFV0M() : 0.5 * (c.multFV0M()); + int multNtr = confIsRun3 ? c.multNTracksPV() : c.multTracklets(); - if (std::abs(vtxZ) > confEvtZvtx) { + if (std::abs(vtxZ) > ConfGeneral.confEvtZvtx) { continue; } @@ -863,10 +1030,15 @@ struct FemtoUniverseProducerTask { // in case of trigger run - store such collisions but don't store any // particle candidates for such collisions - if (!colCuts.isSelectedRun3(col) || (occupancy < confTPCOccupancyMin || occupancy > confTPCOccupancyMax)) { + if (!colCuts.isSelectedRun3(col) || (occupancy < ConfGeneral.confTPCOccupancyMin || occupancy > ConfGeneral.confTPCOccupancyMax)) { return false; } else { - if ((col.selection_bit(aod::evsel::kNoSameBunchPileup)) && (col.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + if (col.selection_bit(aod::evsel::kNoSameBunchPileup) && + col.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && + col.selection_bit(aod::evsel::kIsGoodITSLayersAll) && + col.selection_bit(aod::evsel::kNoCollInRofStandard) && + col.selection_bit(aod::evsel::kNoHighMultCollInPrevRof) && + col.selection_bit(aod::evsel::kNoCollInTimeRangeStandard)) { outputCollision(vtxZ, cent, multNtr, 2, mMagField); return true; } else { @@ -875,6 +1047,19 @@ struct FemtoUniverseProducerTask { } } + template + bool fillMCTruthCollisionsCentRun3(CollisionType const& col) + { + const auto vtxZ = col.posZ(); + + if (std::abs(vtxZ) > ConfGeneral.confEvtZvtx) { + return false; + } else { + outputCollision(vtxZ, 0, 0, 2, mMagField); + return true; + } + } + template void fillCollisionsCentRun3ColExtra(CollisionType const& col, double irrate) { @@ -907,24 +1092,16 @@ struct FemtoUniverseProducerTask { auto cutContainer = trackCuts.getCutContainer(track); // now the table is filled - if (!confIsActivateCascade) { - outputParts(outputCollision.lastIndex(), track.pt(), track.eta(), - track.phi(), aod::femtouniverseparticle::ParticleType::kTrack, - cutContainer.at( - femto_universe_track_selection::TrackContainerPosition::kCuts), - cutContainer.at( - femto_universe_track_selection::TrackContainerPosition::kPID), - track.dcaXY(), childIDs, 0, - track.sign()); // sign getter is mAntiLambda() - } else { - outputCascParts(outputCollision.lastIndex(), track.pt(), track.eta(), - track.phi(), aod::femtouniverseparticle::ParticleType::kTrack, - cutContainer.at( - femto_universe_track_selection::TrackContainerPosition::kCuts), - cutContainer.at( - femto_universe_track_selection::TrackContainerPosition::kPID), - track.dcaXY(), childIDs, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - } + outputParts(outputCollision.lastIndex(), track.pt(), track.eta(), + track.phi(), aod::femtouniverseparticle::ParticleType::kTrack, + cutContainer.at( + femto_universe_track_selection::TrackContainerPosition::kCuts), + confIsUseCutculator ? cutContainer.at( + femto_universe_track_selection::TrackContainerPosition::kPID) + : PIDBitmask(track), + track.dcaXY(), childIDs, 0, + track.sign()); // sign getter is mAntiLambda() + tmpIDtrack.push_back(track.globalIndex()); if (confIsDebug) { fillDebugParticle(track); @@ -975,11 +1152,11 @@ struct FemtoUniverseProducerTask { v0.positiveeta(), v0.positivephi(), aod::femtouniverseparticle::ParticleType::kV0Child, cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kPosCuts), - cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kPosPID), + confIsUseCutculator ? cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kPosPID) : PIDBitmask(postrack), 0., childIDs, 0, - 0); + postrack.sign()); const int rowOfPosTrack = outputParts.lastIndex(); if constexpr (isMC) { fillMCParticle(postrack, o2::aod::femtouniverseparticle::ParticleType::kV0Child); @@ -995,11 +1172,11 @@ struct FemtoUniverseProducerTask { v0.negativephi(), aod::femtouniverseparticle::ParticleType::kV0Child, cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegCuts), - cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegPID), + confIsUseCutculator ? cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegPID) : PIDBitmask(negtrack), 0., childIDs, 0, - 0); + negtrack.sign()); const int rowOfNegTrack = outputParts.lastIndex(); if constexpr (isMC) { fillMCParticle(negtrack, o2::aod::femtouniverseparticle::ParticleType::kV0Child); @@ -1051,62 +1228,44 @@ struct FemtoUniverseProducerTask { childIDs[0] = rowInPrimaryTrackTablePos; // pos childIDs[1] = 0; // neg childIDs[2] = 0; // bachelor - outputCascParts(outputCollision.lastIndex(), - casc.positivept(), - casc.positiveeta(), - casc.positivephi(), - aod::femtouniverseparticle::ParticleType::kV0Child, - 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kPosCuts), - 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kPosPID), - 0., - childIDs, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0); - const int rowOfPosTrack = outputCascParts.lastIndex(); - // if constexpr (isMC) { - // fillMCParticle(postrack, o2::aod::femtouniverseparticle::ParticleType::kV0Child); - // } + float hasTOF = posTrackCasc.hasTOF() ? 1 : 0; + outputParts(outputCollision.lastIndex(), + casc.positivept(), + casc.positiveeta(), + casc.positivephi(), + aod::femtouniverseparticle::ParticleType::kV0Child, + 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kPosCuts), + PIDBitmask(posTrackCasc), // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kPosPID), + hasTOF, + childIDs, + 0, + posTrackCasc.sign()); + const int rowOfPosTrack = outputParts.lastIndex(); + if constexpr (isMC) { + fillMCParticle(posTrackCasc, o2::aod::femtouniverseparticle::ParticleType::kV0Child); + } int negtrackID = casc.negTrackId(); int rowInPrimaryTrackTableNeg = -1; rowInPrimaryTrackTableNeg = getRowDaughters(negtrackID, tmpIDtrack); childIDs[0] = 0; // pos childIDs[1] = rowInPrimaryTrackTableNeg; // neg childIDs[2] = 0; // bachelor - outputCascParts(outputCollision.lastIndex(), - casc.negativept(), - casc.negativeeta(), - casc.negativephi(), - aod::femtouniverseparticle::ParticleType::kV0Child, - 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegCuts), - 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegPID), - 0., - childIDs, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0); - const int rowOfNegTrack = outputCascParts.lastIndex(); - // if constexpr (isMC) { - // fillMCParticle(negtrack, o2::aod::femtouniverseparticle::ParticleType::kV0Child); - // } + hasTOF = negTrackCasc.hasTOF() ? 1 : 0; + outputParts(outputCollision.lastIndex(), + casc.negativept(), + casc.negativeeta(), + casc.negativephi(), + aod::femtouniverseparticle::ParticleType::kV0Child, + 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegCuts), + PIDBitmask(negTrackCasc), // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegPID), + hasTOF, + childIDs, + 0, + negTrackCasc.sign()); + const int rowOfNegTrack = outputParts.lastIndex(); + if constexpr (isMC) { + fillMCParticle(negTrackCasc, o2::aod::femtouniverseparticle::ParticleType::kV0Child); + } // bachelor int bachtrackID = casc.bachelorId(); int rowInPrimaryTrackTableBach = -1; @@ -1114,41 +1273,37 @@ struct FemtoUniverseProducerTask { childIDs[0] = 0; // pos childIDs[1] = 0; // neg childIDs[2] = rowInPrimaryTrackTableBach; // bachelor - outputCascParts(outputCollision.lastIndex(), - casc.bachelorpt(), - casc.bacheloreta(), - casc.bachelorphi(), - aod::femtouniverseparticle::ParticleType::kCascadeBachelor, - 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegCuts), - 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegPID), - 0., - childIDs, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0); - const int rowOfBachTrack = outputCascParts.lastIndex(); + hasTOF = bachTrackCasc.hasTOF() ? 1 : 0; + outputParts(outputCollision.lastIndex(), + casc.bachelorpt(), + casc.bacheloreta(), + casc.bachelorphi(), + aod::femtouniverseparticle::ParticleType::kCascadeBachelor, + 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegCuts), + PIDBitmask(bachTrackCasc), // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegPID), + hasTOF, + childIDs, + 0, + bachTrackCasc.sign()); + const int rowOfBachTrack = outputParts.lastIndex(); + if constexpr (isMC) { + fillMCParticle(bachTrackCasc, o2::aod::femtouniverseparticle::ParticleType::kCascadeBachelor); + } // cascade std::vector indexCascChildID = {rowOfPosTrack, rowOfNegTrack, rowOfBachTrack}; + outputParts(outputCollision.lastIndex(), + casc.pt(), + casc.eta(), + casc.phi(), + aod::femtouniverseparticle::ParticleType::kCascade, + 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kV0), + 0, + 0, + indexCascChildID, + casc.mXi(), + casc.mOmega()); outputCascParts(outputCollision.lastIndex(), - casc.pt(), - casc.eta(), - casc.phi(), - aod::femtouniverseparticle::ParticleType::kCascade, - 0, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kV0), - 0, - 0, - indexCascChildID, - confIsSelectCascOmega ? casc.mOmega() : casc.mXi(), - confIsSelectCascOmega ? casc.mOmega() : casc.mXi(), + outputParts.lastIndex(), casc.dcaV0daughters(), casc.v0cosPA(col.posX(), col.posY(), col.posZ()), casc.v0radius(), @@ -1165,6 +1320,9 @@ struct FemtoUniverseProducerTask { fillDebugParticle(bachTrackCasc); // QA for negative daughter fillDebugParticle(casc); // QA for cascade } + if constexpr (isMC) { + fillMCParticle(casc, o2::aod::femtouniverseparticle::ParticleType::kCascade); + } } } @@ -1214,8 +1372,13 @@ struct FemtoUniverseProducerTask { } else if (hfCand.isSelD0() == 1 && hfCand.isSelD0bar() == 1) { invMassD0 = hfHelper.invMassD0ToPiK(hfCand); invMassD0bar = hfHelper.invMassD0barToKPi(hfCand); - isD0D0bar = true; - daughFlag = 0; + if (ConfD0Selection.storeD0D0barDoubleMassHypo) { + isD0D0bar = true; + daughFlag = 0; + } else { + isD0D0bar = false; + daughFlag = 0; + } } else { invMassD0 = 0.0; invMassD0bar = 0.0; @@ -1269,7 +1432,7 @@ struct FemtoUniverseProducerTask { aod::femtouniverseparticle::ParticleType::kD0, -999, // cut, CutContainerType -999, // PID, CutContainerType - -999, + -999., indexChildID, invMassD0, // D0 mass (mLambda) invMassD0bar); // D0bar mass (mAntiLambda) @@ -1286,6 +1449,138 @@ struct FemtoUniverseProducerTask { } } + template + void fillD0D0barUsingML(CollisionType const&, TrackType const&, HfCandidate const& hfCands) + { + std::vector childIDs = {0, 0}; // these IDs are necessary to keep track of the children + std::vector tmpIDtrack; // this vector keeps track of the matching of the primary track table row <-> aod::track table global index + double invMassD0 = 0.0; + double invMassD0bar = 0.0; + bool isD0D0bar = false; + double mlProbD0D0barBg = 0.0; + uint8_t daughFlag = 0; // flag = 0 (daugh of D0 or D0bar), 1 (daug of D0), -1 (daugh of D0bar) + + for (const auto& hfCand : hfCands) { + + if (!(hfCand.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + continue; + } + + if (ConfD0Selection.confD0D0barCandMaxY >= 0. && std::abs(hfHelper.yD0(hfCand)) > ConfD0Selection.confD0D0barCandMaxY) { + continue; + } + + if (std::abs(hfCand.eta()) > ConfD0Selection.confD0D0barCandEtaCut) { + continue; + } + + // int postrackID = hfCand.prong0().globalIndex(); + int postrackID = hfCand.prong0Id(); // Index to first prong + int rowInPrimaryTrackTablePos = -1; + rowInPrimaryTrackTablePos = getRowDaughters(postrackID, tmpIDtrack); + childIDs[0] = rowInPrimaryTrackTablePos; + childIDs[1] = 0; + auto postrack = hfCand.template prong0_as(); + auto negtrack = hfCand.template prong1_as(); + + if (hfCand.isSelD0() == 1 && hfCand.isSelD0bar() == 0) { + invMassD0 = hfHelper.invMassD0ToPiK(hfCand); + invMassD0bar = -hfHelper.invMassD0barToKPi(hfCand); + mlProbD0D0barBg = hfCand.mlProbD0()[0]; + isD0D0bar = true; + daughFlag = 1; + } else if (hfCand.isSelD0() == 0 && hfCand.isSelD0bar() == 1) { + invMassD0 = -hfHelper.invMassD0ToPiK(hfCand); + invMassD0bar = hfHelper.invMassD0barToKPi(hfCand); + mlProbD0D0barBg = hfCand.mlProbD0bar()[0]; + isD0D0bar = true; + daughFlag = -1; + } else if (hfCand.isSelD0() == 1 && hfCand.isSelD0bar() == 1) { + invMassD0 = hfHelper.invMassD0ToPiK(hfCand); + invMassD0bar = hfHelper.invMassD0barToKPi(hfCand); + if (ConfD0Selection.storeD0D0barDoubleMassHypo) { + isD0D0bar = true; + daughFlag = 0; + } else { + isD0D0bar = false; + daughFlag = 0; + } + } else { + invMassD0 = 0.0; + invMassD0bar = 0.0; + isD0D0bar = false; + } + + if (isD0D0bar) { + outputParts(outputCollision.lastIndex(), + hfCand.ptProng0(), + RecoDecay::eta(std::array{hfCand.pxProng0(), hfCand.pyProng0(), hfCand.pzProng0()}), // eta + RecoDecay::phi(hfCand.pxProng0(), hfCand.pyProng0()), // phi + aod::femtouniverseparticle::ParticleType::kD0Child, + -999, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kPosCuts), + -999, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kPosPID), + -999, + childIDs, + postrack.sign(), // D0 mass -> positive daughter of D0/D0bar + daughFlag); // D0bar mass -> sign that the daugh is from D0 or D0 decay + const int rowOfPosTrack = outputParts.lastIndex(); + if constexpr (isMC) { + fillMCParticle(postrack, o2::aod::femtouniverseparticle::ParticleType::kD0Child); + } + // int negtrackID = hfCand.prong1().globalIndex(); + int negtrackID = hfCand.prong1Id(); + int rowInPrimaryTrackTableNeg = -1; + rowInPrimaryTrackTableNeg = getRowDaughters(negtrackID, tmpIDtrack); + childIDs[0] = 0; + childIDs[1] = rowInPrimaryTrackTableNeg; + + outputParts(outputCollision.lastIndex(), + hfCand.ptProng1(), + RecoDecay::eta(std::array{hfCand.pxProng1(), hfCand.pyProng1(), hfCand.pzProng1()}), // eta + RecoDecay::phi(hfCand.pxProng1(), hfCand.pyProng1()), // phi + aod::femtouniverseparticle::ParticleType::kD0Child, + -999, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegCuts), + -999, // cutContainerV0.at(femto_universe_v0_selection::V0ContainerPosition::kNegPID), + -999, + childIDs, + negtrack.sign(), // negative daughter of D0/D0bar + daughFlag); // sign that the daugh is from D0 or D0 decay + const int rowOfNegTrack = outputParts.lastIndex(); + if constexpr (isMC) { + fillMCParticle(negtrack, o2::aod::femtouniverseparticle::ParticleType::kD0Child); + } + std::vector indexChildID = {rowOfPosTrack, rowOfNegTrack}; + + outputParts(outputCollision.lastIndex(), + hfCand.pt(), + hfCand.eta(), + hfCand.phi(), + aod::femtouniverseparticle::ParticleType::kD0, + -999, // cut, CutContainerType + -999, // PID, CutContainerType + mlProbD0D0barBg, // saving the probability for ML score class 1 + indexChildID, + invMassD0, // D0 mass (mLambda) + invMassD0bar); // D0bar mass (mAntiLambda) + + if (confIsDebug) { + fillDebugParticle(postrack); // QA for positive daughter + fillDebugParticle(negtrack); // QA for negative daughter + if (hfCand.isSelD0() == 1 && hfCand.isSelD0bar() == 0) { + fillDebugD0D0barML(hfCand); // QA for D0/D0bar + } else if (hfCand.isSelD0() == 0 && hfCand.isSelD0bar() == 1) { + fillDebugD0D0barML(hfCand); + } else { + fillDebugD0D0barML(hfCand); + } + } + if constexpr (isMC) { + fillMCParticleD0(hfCand); + } + } + } + } + template void fillPhi(CollisionType const& col, TrackType const& tracks) { @@ -1296,20 +1591,18 @@ struct FemtoUniverseProducerTask { if (!trackCuts.isSelectedMinimal(p1) || !trackCuts.isSelectedMinimal(p1)) { continue; } + if ((!(p1.sign() == 1)) || (!(p2.sign() == -1))) { + continue; + } // implementing PID cuts for phi children - if (ConfPhiSelection.confLooseTPCNSigma.value) { - if (!(isKaonNSigmaTPCLoose(p1.pt(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon)))) { + if (ConfPhiSelection.confPhiDoLFPID4Kaons) { + if ((p1.isGlobalTrackWoDCA() == false) || (p2.isGlobalTrackWoDCA() == false) || (p1.isPVContributor() == false) || (p2.isPVContributor() == false)) { continue; } - if (!(isKaonNSigmaTPCLoose(p2.pt(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon)))) { + if (!(isKaonNSigmaLF(p1.pt(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon), p1.hasTOF()))) { continue; } - } - if (ConfPhiSelection.confLooseTOFNSigma.value) { - if (!(isKaonNSigmaTOFLoose(p1.pt(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon)))) { - continue; - } - if (!(isKaonNSigmaTOFLoose(p2.pt(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon)))) { + if (!(isKaonNSigmaLF(p2.pt(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon), p2.hasTOF()))) { continue; } } else { @@ -1327,10 +1620,6 @@ struct FemtoUniverseProducerTask { continue; } - if ((!(p1.sign() == 1)) || (!(p2.sign() == -1))) { - continue; - } - TLorentzVector part1Vec; TLorentzVector part2Vec; @@ -1349,16 +1638,15 @@ struct FemtoUniverseProducerTask { } float phiPt = sumVec.Pt(); - if ((phiPt < ConfPhiSelection.confPtLowLimitPhi.value) || (phiPt > ConfPhiSelection.confPtHighLimitPhi.value)) { + if ((phiPt < ConfPhiSelection.confPhiPtLowLimit.value) || (phiPt > ConfPhiSelection.confPhiPtHighLimit.value)) { continue; } float phiPhi = RecoDecay::constrainAngle(sumVec.Phi(), 0); float phiM = sumVec.M(); - if (((phiM < ConfPhiSelection.confInvMassLowLimitPhi.value) || (phiM > ConfPhiSelection.confInvMassUpLimitPhi.value))) { + if ((phiM < ConfPhiSelection.confPhiInvMassLowLimit) || (phiM > ConfPhiSelection.confPhiInvMassUpLimit)) continue; - } phiCuts.fillQA(col, p1, p1, p2, 321, -321); ///\todo fill QA also for daughters @@ -1443,15 +1731,15 @@ struct FemtoUniverseProducerTask { uint32_t pdgCode = static_cast(particle.pdgCode()); - if (confMCTruthAnalysisWithPID) { + if (ConfGeneral.confMCTruthAnalysisWithPID) { bool pass = false; - std::vector tmpPDGCodes = confMCTruthPDGCodes; // necessary due to some features of the Configurable + std::vector tmpPDGCodes = ConfGeneral.confMCTruthPDGCodes; // necessary due to some features of the Configurable for (auto const& pdg : tmpPDGCodes) { if (static_cast(pdg) == static_cast(pdgCode)) { if (pdgCode == 333) { // && (recoMcIds && recoMcIds->get().contains(particle.globalIndex()))) { // ATTENTION: all Phi mesons are NOT primary particles pass = true; } else { - if (particle.isPhysicalPrimary() || (confActivateSecondaries && recoMcIds && recoMcIds->get().contains(particle.globalIndex()))) + if (confStoreMCmothers || particle.isPhysicalPrimary() || (ConfGeneral.confActivateSecondaries && recoMcIds && recoMcIds->get().contains(particle.globalIndex()))) pass = true; } } @@ -1471,11 +1759,16 @@ struct FemtoUniverseProducerTask { // auto cutContainer = trackCuts.getCutContainer(track); // instead of the bitmask, the PDG of the particle is stored as uint32_t + int32_t variablePDG = confStoreMCmothers ? getMotherPDG(particle) : particle.pdgCode(); + // now the table is filled if constexpr (resolveDaughs) { tmpIDtrack.push_back(particle.globalIndex()); continue; } + + if (ConfGeneral.confIsActivateCascade) + childIDs.push_back(0); outputParts(outputCollision.lastIndex(), particle.pt(), particle.eta(), @@ -1483,10 +1776,151 @@ struct FemtoUniverseProducerTask { aod::femtouniverseparticle::ParticleType::kMCTruthTrack, 0, pdgCode, - pdgCode, + variablePDG, childIDs, 0, 0); + + if (confIsDebug) { + fillDebugParticle(particle); + } + + // Workaround to keep the FDParticles and MC label tables + // aligned, so that they can be joined in the task. + if constexpr (transientLabels) { + outputPartsMCLabels(-1); + outputDebugPartsMC(9999); + } + } + if constexpr (resolveDaughs) { + childIDs[0] = 0; + childIDs[1] = 0; + auto minDaughs = 2ul; + if (ConfGeneral.confIsActivateCascade) { + childIDs.push_back(0); + minDaughs = 3ul; + } + for (std::size_t i = 0; i < tmpIDtrack.size(); i++) { + const auto& particle = tracks.iteratorAt(tmpIDtrack[i] - tracks.begin().globalIndex()); + for (int daughIndex = 0, n = std::min(minDaughs, particle.daughtersIds().size()); daughIndex < n; daughIndex++) { + // loop to find the corresponding index of the daughters + for (std::size_t j = 0; j < tmpIDtrack.size(); j++) { + if (tmpIDtrack[j] == particle.daughtersIds()[daughIndex]) { + childIDs[daughIndex] = i - j; + break; + } + } + } + + int32_t variablePDG = confStoreMCmothers ? getMotherPDG(particle) : particle.pdgCode(); + + outputParts(outputCollision.lastIndex(), + particle.pt(), + particle.eta(), + particle.phi(), + aod::femtouniverseparticle::ParticleType::kMCTruthTrack, + 0, + static_cast(particle.pdgCode()), + variablePDG, + childIDs, + 0, + 0); + + if (confIsDebug) { + fillDebugParticle(particle); + } + + // Workaround to keep the FDParticles and MC label tables + // aligned, so that they can be joined in the task. + if constexpr (transientLabels) { + outputPartsMCLabels(-1); + outputDebugPartsMC(9999); + } + } + } + } + + template + void fillMCTruthParticlesD0(TrackType const& tracks, std::optional>> recoMcIds = std::nullopt) + { + std::vector childIDs = {0, 0}; // these IDs are necessary to keep track of the children + std::vector tmpIDtrack; + + for (const auto& particle : tracks) { + /// if the most open selection criteria are not fulfilled there is no + /// point looking further at the track + + if (particle.eta() < -ConfFilterCuts.confEtaFilterCut || particle.eta() > ConfFilterCuts.confEtaFilterCut) + continue; + if (particle.pt() < ConfFilterCuts.confPtLowFilterCut || particle.pt() > ConfFilterCuts.confPtHighFilterCut) + continue; + + uint32_t pdgCode = static_cast(particle.pdgCode()); + + if (ConfGeneral.confMCTruthAnalysisWithPID) { + bool pass = false; + std::vector tmpPDGCodes = ConfGeneral.confMCTruthPDGCodes; // necessary due to some features of the Configurable + for (auto const& pdg : tmpPDGCodes) { + if (static_cast(pdg) == static_cast(pdgCode)) { + if (pdgCode == 333) { // && (recoMcIds && recoMcIds->get().contains(particle.globalIndex()))) { // ATTENTION: all Phi mesons are NOT primary particles + pass = true; + } else if (pdgCode == 421) { + pass = true; + } else { + if (particle.isPhysicalPrimary() || (ConfGeneral.confActivateSecondaries && recoMcIds && recoMcIds->get().contains(particle.globalIndex()))) + pass = true; + } + } + } + if (!pass) + continue; + } + + // now the table is filled + if constexpr (resolveDaughs) { + tmpIDtrack.push_back(particle.globalIndex()); + continue; + } + if (ConfGeneral.confIsActiveD0) { + + auto mcD0origin = aod::femtouniverseparticle::ParticleType::kMCTruthTrack; + float ptGenB = -1; + if (std::abs(particle.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + if (ConfD0Selection.yD0D0barCandGenMax >= 0. && std::abs(RecoDecay::y(particle.pVector(), o2::constants::physics::MassD0)) > ConfD0Selection.yD0D0barCandGenMax) { + continue; + } + mcD0origin = aod::femtouniverseparticle::ParticleType::kMCTruthTrack; + // WORK IN PROGRESS: If needed changed it to prompt and non-prompt + /*if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { + mcD0origin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kPrompt; + ptGenB = -1; + } else { + mcD0origin = aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kNonPrompt; + ptGenB = particle.idxBhadMotherPart().pt(); + }*/ + outputParts(outputCollision.lastIndex(), + particle.pt(), + particle.eta(), + particle.phi(), + mcD0origin, + 0, + pdgCode, + pdgCode, + childIDs, + RecoDecay::y(particle.pVector(), o2::constants::physics::MassD0), + ptGenB); // pT of the B hadron (mother particle, only when non-prompt D0) + } + } else { + outputParts(outputCollision.lastIndex(), + particle.pt(), + particle.eta(), + particle.phi(), + aod::femtouniverseparticle::ParticleType::kMCTruthTrack, + 0, + pdgCode, + pdgCode, + childIDs, 0, 0); + } if (confIsDebug) { fillDebugParticle(particle); } @@ -1495,6 +1929,7 @@ struct FemtoUniverseProducerTask { // aligned, so that they can be joined in the task. if constexpr (transientLabels) { outputPartsMCLabels(-1); + outputDebugPartsMC(9999); } } if constexpr (resolveDaughs) { @@ -1530,6 +1965,7 @@ struct FemtoUniverseProducerTask { // aligned, so that they can be joined in the task. if constexpr (transientLabels) { outputPartsMCLabels(-1); + outputDebugPartsMC(9999); } } } @@ -1542,16 +1978,13 @@ struct FemtoUniverseProducerTask { const auto colcheck = fillCollisions(col, tracks); if (colcheck) { fillTracks(tracks); - if (confIsActivateV0) { + if (ConfGeneral.confIsActivateV0) { fillV0(col, fullV0s, tracks); } - if (confIsActivatePhi) { + if (ConfGeneral.confIsActivatePhi) { fillPhi(col, tracks); } } - // if (confIsActivateCascade) { - // fillCascade(col, fullCascades, tracks); - // } } void processFullData(aod::FemtoFullCollision const& col, @@ -1594,6 +2027,26 @@ struct FemtoUniverseProducerTask { } PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackCascadeData, "Provide experimental data for track cascades", false); + void processTrackV0Cascade(aod::FemtoFullCollision const& col, + aod::BCsWithTimestamps const&, + soa::Filtered const& tracks, + o2::aod::V0Datas const& fullV0s, + o2::aod::CascDatas const& fullCascades) + { + getMagneticFieldTesla(col.bc_as()); + const auto colcheck = fillCollisions(col, tracks); + if (colcheck) { + fillTracks(tracks); + if (ConfGeneral.confIsActivateV0) { + fillV0(col, fullV0s, tracks); + } + if (ConfGeneral.confIsActivateCascade) { + fillCascade(col, fullCascades, tracks); + } + } + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackV0Cascade, "Provide experimental data for track, v0 and cascades", false); + /*void processTrackV0CentRun3(aod::FemtoFullCollisionCentRun3 const& col, aod::BCsWithTimestamps const&, soa::Filtered const& tracks, @@ -1655,32 +2108,34 @@ struct FemtoUniverseProducerTask { } PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackPhiMC, "Provide MC data for track Phi analysis", false); - void processTrackD0MC(aod::FemtoFullCollisionMC const& col, + void processTrackData(aod::FemtoFullCollision const& col, aod::BCsWithTimestamps const&, - soa::Join const& tracks, - aod::McCollisions const&, - aod::McParticles const&) + aod::FemtoFullTracks const& tracks) { // get magnetic field for run getMagneticFieldTesla(col.bc_as()); + const double ir = 1.0; // fetch IR // fill the tables - const auto colcheck = fillCollisions(col, tracks); + const auto colcheck = fillCollisions(col, tracks); if (colcheck) { - fillTracks(tracks); - // fillD0mesons(col, tracks, candidates); + if (confFillCollExt) { + fillCollisionsCentRun3ColExtra(col, ir); + } + fillTracks(tracks); } } - PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackD0MC, "Provide MC data for track D0 analysis", false); + PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackData, + "Provide experimental data for track track", true); - void processTrackData(aod::FemtoFullCollision const& col, - aod::BCsWithTimestamps const&, - aod::FemtoFullTracks const& tracks) + void processTrackDataCentPP(aod::FemtoFullCollisionCentPP const& col, + aod::BCsWithTimestamps const&, + aod::FemtoFullTracks const& tracks) { // get magnetic field for run getMagneticFieldTesla(col.bc_as()); - const double ir = 0.0; // fetch IR + const double ir = 1.0; // fetch IR // fill the tables - const auto colcheck = fillCollisions(col, tracks); + const auto colcheck = fillCollisionsCentPP(col, tracks); if (colcheck) { if (confFillCollExt) { fillCollisionsCentRun3ColExtra(col, ir); @@ -1688,8 +2143,8 @@ struct FemtoUniverseProducerTask { fillTracks(tracks); } } - PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackData, - "Provide experimental data for track track", true); + PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackDataCentPP, + "Provide experimental data for track track", false); // using FilteredFemtoFullTracks = soa::Filtered; void processTrackPhiData(aod::FemtoFullCollision const& col, @@ -1725,6 +2180,23 @@ struct FemtoUniverseProducerTask { PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackD0mesonData, "Provide experimental data for track D0 meson", false); + void processTrackD0DataML(aod::FemtoFullCollision const& col, + aod::BCsWithTimestamps const&, + soa::Filtered const& tracks, + soa::Join const& candidates) + { + // get magnetic field for run + getMagneticFieldTesla(col.bc_as()); + // fill the tables + const auto colcheck = fillCollisions(col, tracks); + if (colcheck) { + fillTracks(tracks); + fillD0D0barUsingML(col, tracks, candidates); + } + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackD0DataML, + "Provide experimental data for track D0 meson using ML selection for D0s", false); + void processTrackMCTruth(aod::McCollision const&, soa::SmallGroups> const& collisions, aod::McParticles const& mcParticles, @@ -1745,25 +2217,40 @@ struct FemtoUniverseProducerTask { } PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackMCGen, "Provide MC Generated for model comparisons", false); + template + using HasBachelor = decltype(std::declval().bachelorphi()); + Preslice perMCCollision = aod::mcparticle::mcCollisionId; PresliceUnsorted> recoCollsPerMCColl = aod::mcparticle::mcCollisionId; + PresliceUnsorted> recoCollsPerMCCollCentPbPb = aod::mcparticle::mcCollisionId; Preslice> perCollisionTracks = aod::track::collisionId; - Preslice> perCollisionV0s = aod::track::collisionId; + + template + void processTruthAndFullMC( aod::McCollisions const& mccols, aod::McParticles const& mcParticles, soa::Join const& collisions, soa::Filtered> const& tracks, - soa::Join const& fullV0s, - aod::BCsWithTimestamps const&) + StrangePartType const& strangeParts, + aod::BCsWithTimestamps const&, + Preslice& ps) { // recos std::set recoMcIds; for (const auto& col : collisions) { auto groupedTracks = tracks.sliceBy(perCollisionTracks, col.globalIndex()); - auto groupedV0s = fullV0s.sliceBy(perCollisionV0s, col.globalIndex()); + auto groupedStrageParts = strangeParts.sliceBy(ps, col.globalIndex()); getMagneticFieldTesla(col.bc_as()); - fillCollisionsAndTracksAndV0AndPhi(col, groupedTracks, groupedV0s); + if constexpr (std::experimental::is_detected::value) { + const auto colcheck = fillCollisions(col, groupedTracks); + if (colcheck) { + fillTracks(groupedTracks); + fillCascade(col, groupedStrageParts, groupedTracks); + } + } else { + fillCollisionsAndTracksAndV0AndPhi(col, groupedTracks, groupedStrageParts); + } for (const auto& track : groupedTracks) { if (trackCuts.isSelectedMinimal(track)) recoMcIds.insert(track.mcParticleId()); @@ -1778,7 +2265,192 @@ struct FemtoUniverseProducerTask { fillParticles(groupedMCParticles, recoMcIds); // fills mc particles } } - PROCESS_SWITCH(FemtoUniverseProducerTask, processTruthAndFullMC, "Provide both MC truth and reco for tracks and V0s", false); + + void processTruthAndFullMCCentRun3(aod::McCollisions const& mccols, + aod::McParticles const& mcParticles, + aod::FemtoFullCollisionCentRun3MCs const& collisions, + soa::Filtered> const& tracks, + aod::BCsWithTimestamps const&) + { + // recos + std::set recoMcIds; + for (const auto& col : collisions) { + auto groupedTracks = tracks.sliceBy(perCollisionTracks, col.globalIndex()); + auto bc = col.bc_as(); + getMagneticFieldTesla(bc); + const auto ir = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, "ZNC hadronic") * 1.e-3; // fetch IR + + // fill the tables + const auto colcheck = fillCollisionsCentRun3(col); + if (colcheck) { + fillCollisionsCentRun3ColExtra(col, ir); + fillTracks(groupedTracks); + } + for (const auto& track : groupedTracks) { + if (trackCuts.isSelectedMinimal(track)) + recoMcIds.insert(track.mcParticleId()); + } + } + + // truth + for (const auto& mccol : mccols) { + auto groupedCollisions = collisions.sliceBy(recoCollsPerMCCollCentPbPb, mccol.globalIndex()); + for (const auto& col : groupedCollisions) { + const auto colcheck = fillMCTruthCollisionsCentRun3(col); // fills the reco collisions for mc collision + if (colcheck) { + auto groupedMCParticles = mcParticles.sliceBy(perMCCollision, mccol.globalIndex()); + outputCollExtra(1.0, 1.0); + fillParticles(groupedMCParticles, recoMcIds); // fills mc particles + } + } + } + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTruthAndFullMCCentRun3, "Provide both MC truth and reco for tracks in Pb-Pb", false); + + Preslice> perCollisionV0s = aod::track::collisionId; + void processTruthAndFullMCV0( + aod::McCollisions const& mccols, + aod::McParticles const& mcParticles, + soa::Join const& collisions, + soa::Filtered> const& tracks, + soa::Join const& fullV0s, + aod::BCsWithTimestamps const& bcs) + { + processTruthAndFullMC(mccols, mcParticles, collisions, tracks, fullV0s, bcs, perCollisionV0s); + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTruthAndFullMCV0, "Provide both MC truth and reco for tracks and V0s", false); + + void processTruthAndFullMCCentRun3V0( + aod::McCollisions const& mccols, + aod::McParticles const& mcParticles, + aod::FemtoFullCollisionCentRun3MCs const& collisions, + soa::Filtered> const& tracks, + soa::Join const& fullV0s, + aod::BCsWithTimestamps const&) + { + + // recos + std::set recoMcIds; + for (const auto& col : collisions) { + auto groupedTracks = tracks.sliceBy(perCollisionTracks, col.globalIndex()); + auto groupedV0Parts = fullV0s.sliceBy(perCollisionV0s, col.globalIndex()); + getMagneticFieldTesla(col.bc_as()); + const auto colcheck = fillCollisionsCentRun3(col); + if (colcheck) { + fillTracks(groupedTracks); + fillV0(col, groupedV0Parts, groupedTracks); + } + for (const auto& track : groupedTracks) { + if (trackCuts.isSelectedMinimal(track)) + recoMcIds.insert(track.mcParticleId()); + } + } + + // truth + for (const auto& mccol : mccols) { + auto groupedCollisions = collisions.sliceBy(recoCollsPerMCCollCentPbPb, mccol.globalIndex()); + for (const auto& col : groupedCollisions) { + const auto colcheck = fillMCTruthCollisionsCentRun3(col); // fills the reco collisions for mc collision + if (colcheck) { + auto groupedMCParticles = mcParticles.sliceBy(perMCCollision, mccol.globalIndex()); + outputCollExtra(1.0, 1.0); + fillParticles(groupedMCParticles, recoMcIds); // fills mc particles + } + } + } + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTruthAndFullMCCentRun3V0, "Provide both MC truth and reco for tracks and V0s with centrality", false); + + Preslice> perCollisionCascs = aod::track::collisionId; + void processTruthAndFullMCCasc( + aod::McCollisions const& mccols, + aod::McParticles const& mcParticles, + soa::Join const& collisions, + soa::Filtered> const& tracks, + soa::Join const& fullCascades, + aod::BCsWithTimestamps const& bcs) + { + processTruthAndFullMC(mccols, mcParticles, collisions, tracks, fullCascades, bcs, perCollisionCascs); + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTruthAndFullMCCasc, "Provide both MC truth and reco for tracks and Cascades", false); + + void processTruthAndFullMCCentRun3Casc( + aod::McCollisions const& mccols, + aod::McParticles const& mcParticles, + aod::FemtoFullCollisionCentRun3MCs const& collisions, + soa::Filtered> const& tracks, + soa::Join const& fullCascades, + aod::BCsWithTimestamps const&) + { + + // recos + std::set recoMcIds; + for (const auto& col : collisions) { + auto groupedTracks = tracks.sliceBy(perCollisionTracks, col.globalIndex()); + auto groupedCascParts = fullCascades.sliceBy(perCollisionCascs, col.globalIndex()); + getMagneticFieldTesla(col.bc_as()); + const auto colcheck = fillCollisionsCentRun3(col); + if (colcheck) { + fillTracks(groupedTracks); + fillCascade(col, groupedCascParts, groupedTracks); + } + for (const auto& track : groupedTracks) { + if (trackCuts.isSelectedMinimal(track)) + recoMcIds.insert(track.mcParticleId()); + } + } + + // truth + for (const auto& mccol : mccols) { + auto groupedCollisions = collisions.sliceBy(recoCollsPerMCCollCentPbPb, mccol.globalIndex()); + for (const auto& col : groupedCollisions) { + const auto colcheck = fillMCTruthCollisionsCentRun3(col); // fills the reco collisions for mc collision + if (colcheck) { + auto groupedMCParticles = mcParticles.sliceBy(perMCCollision, mccol.globalIndex()); + outputCollExtra(1.0, 1.0); + fillParticles(groupedMCParticles, recoMcIds); // fills mc particles + } + } + } + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTruthAndFullMCCentRun3Casc, "Provide both MC truth and reco for tracks and cascades with centrality", false); + + Preslice> perCollisionD0s = aod::track::collisionId; + void processTrackD0MC(aod::McCollisions const& mccols, + aod::TracksWMc const&, + soa::Join const& collisions, + soa::Filtered> const& tracks, + soa::Join const& hfMcGenCands, + soa::Join const& hfMcRecoCands, + aod::BCsWithTimestamps const&) + { + // MC Reco + std::set recoMcIds; + for (const auto& col : collisions) { + auto groupedTracks = tracks.sliceBy(perCollisionTracks, col.globalIndex()); + auto groupedD0s = hfMcRecoCands.sliceBy(perCollisionD0s, col.globalIndex()); + // get magnetic field for run + getMagneticFieldTesla(col.bc_as()); + // fill the tables + const auto colcheck = fillCollisions(col, tracks); + if (colcheck) { + fillTracks(tracks); + fillD0D0barUsingML(col, groupedTracks, groupedD0s); + for (const auto& track : groupedTracks) { + if (trackCuts.isSelectedMinimal(track)) + recoMcIds.insert(track.mcParticleId()); + } + } + } + // MC Truth + for (const auto& mccol : mccols) { + auto groupedMCParticles = hfMcGenCands.sliceBy(perMCCollision, mccol.globalIndex()); + auto groupedCollisions = collisions.sliceBy(recoCollsPerMCColl, mccol.globalIndex()); + fillMCTruthCollisions(groupedCollisions, groupedMCParticles); // fills the reco collisions for mc collision + fillMCTruthParticlesD0(groupedMCParticles, recoMcIds); // fills mc particles + } + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackD0MC, "Provide MC data for track D0 analysis", false); void processFullMCCent(aod::FemtoFullCollisionCentRun3 const& col, aod::BCsWithTimestamps const&, @@ -1818,6 +2490,26 @@ struct FemtoUniverseProducerTask { } PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackCentRun2Data, "Provide experimental data for Run 2 with centrality for track track", false); + void processTrackV0CentRun2Data(aod::FemtoFullCollisionCentRun2 const& col, + aod::BCsWithTimestamps const&, + soa::Filtered const& tracks, + aod::V0Datas const& fullV0s) + { + // get magnetic field for run + auto bc = col.bc_as(); + getMagneticFieldTesla(bc); + const double ir = 0.0; // fetch IR + + // fill the tables + const auto colcheck = fillCollisionsCentRun2(col); + if (colcheck) { + fillCollisionsCentRun3ColExtra(col, ir); + fillTracks(tracks); + fillV0(col, fullV0s, tracks); + } + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackV0CentRun2Data, "Provide experimental data for Run 2 with centrality for track V0", false); + void processTrackCentRun3Data(aod::FemtoFullCollisionCentRun3 const& col, aod::BCsWithTimestamps const&, soa::Filtered const& tracks) @@ -1836,6 +2528,26 @@ struct FemtoUniverseProducerTask { } PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackCentRun3Data, "Provide experimental data for Run 3 with centrality for track track", false); + void processTrackCentRun3DataMC(aod::FemtoFullCollisionCentRun3MC const& col, + aod::BCsWithTimestamps const&, + soa::Join const& tracks, + aod::McCollisions const&, + aod::McParticles const&) + { + // get magnetic field for run + auto bc = col.bc_as(); + getMagneticFieldTesla(bc); + const auto ir = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, "ZNC hadronic") * 1.e-3; // fetch IR + + // fill the tables + const auto colcheck = fillCollisionsCentRun3(col); + if (colcheck) { + fillCollisionsCentRun3ColExtra(col, ir); + fillTracks(tracks); + } + } + PROCESS_SWITCH(FemtoUniverseProducerTask, processTrackCentRun3DataMC, "Provide MC data for track analysis", false); + void processV0CentRun3Data(aod::FemtoFullCollisionCentRun3 const& col, aod::BCsWithTimestamps const&, soa::Filtered const& tracks, diff --git a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTaskV0Only.cxx b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTaskV0Only.cxx index 09ac22d0e30..968d3fab7ba 100644 --- a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTaskV0Only.cxx +++ b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTaskV0Only.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -14,6 +14,8 @@ /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch #include +#include + #include "Common/Core/trackUtilities.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" @@ -468,7 +470,7 @@ struct femtoUniverseProducerTaskV0Only { postrack.sign(), (uint8_t)postrack.tpcNClsFound(), postrack.tpcNClsFindable(), (uint8_t)postrack.tpcNClsCrossedRows(), - postrack.tpcNClsShared(), postrack.tpcInnerParam(), + postrack.tpcNClsShared(), postrack.tpcFractionSharedCls(), postrack.tpcInnerParam(), postrack.itsNCls(), postrack.itsNClsInnerBarrel(), postrack.dcaXY(), postrack.dcaZ(), postrack.tpcSignal(), postrack.tpcNSigmaStoreEl(), postrack.tpcNSigmaStorePi(), @@ -482,7 +484,7 @@ struct femtoUniverseProducerTaskV0Only { negtrack.sign(), (uint8_t)negtrack.tpcNClsFound(), negtrack.tpcNClsFindable(), (uint8_t)negtrack.tpcNClsCrossedRows(), - negtrack.tpcNClsShared(), negtrack.tpcInnerParam(), + negtrack.tpcNClsShared(), negtrack.tpcFractionSharedCls(), negtrack.tpcInnerParam(), negtrack.itsNCls(), negtrack.itsNClsInnerBarrel(), negtrack.dcaXY(), negtrack.dcaZ(), negtrack.tpcSignal(), negtrack.tpcNSigmaStoreEl(), negtrack.tpcNSigmaStorePi(), @@ -492,7 +494,7 @@ struct femtoUniverseProducerTaskV0Only { negtrack.tofNSigmaStorePr(), negtrack.tofNSigmaStoreDe(), -999., -999., -999., -999., -999., -999.); // QA for negative daughter - outputDebugParts(-999., -999., -999., -999., -999., -999., -999., + outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., v0.dcaV0daughters(), v0.v0radius(), v0.x(), v0.y(), diff --git a/PWGCF/FemtoUniverse/Tasks/CMakeLists.txt b/PWGCF/FemtoUniverse/Tasks/CMakeLists.txt index a568e8b1252..346188d08fd 100644 --- a/PWGCF/FemtoUniverse/Tasks/CMakeLists.txt +++ b/PWGCF/FemtoUniverse/Tasks/CMakeLists.txt @@ -64,6 +64,11 @@ o2physics_add_dpl_workflow(femtouniverse-pair-track-cascade-extended PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femtouniverse-pair-v0-cascade-extended + SOURCES femtoUniversePairTaskV0CascadeExtended.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(femtouniverse-pair-track-d0 SOURCES femtoUniversePairTaskTrackD0.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniverseCutCulator.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniverseCutCulator.cxx index 45edb854cc2..6e5af4e8d52 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniverseCutCulator.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniverseCutCulator.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugTrack.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugTrack.cxx index 0e07e4f4b03..984ab7d973e 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugTrack.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugTrack.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugV0.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugV0.cxx index b0700b5acae..f82657be1d9 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugV0.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugV0.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniverseEfficiencyBase.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniverseEfficiencyBase.cxx index cad94a05c60..cc0ab0077c8 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniverseEfficiencyBase.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniverseEfficiencyBase.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -14,15 +14,16 @@ /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch /// \author Alicja Płachta, WUT Warsaw, alicja.plachta@cern.ch -#include +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" + #include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" #include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" +#include using namespace o2; using namespace o2::analysis::femto_universe; @@ -30,65 +31,91 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -struct femtoUniverseEfficiencyBase { +struct FemtoUniverseEfficiencyBase { SliceCache cache; using FemtoFullParticles = soa::Join; Preslice perCol = aod::femtouniverseparticle::fdCollisionId; - Configurable ConfIsDebug{"ConfIsDebug", true, "Enable debug histograms"}; + Configurable confIsDebug{"confIsDebug", true, "Enable debug histograms"}; + Configurable confIsMCGen{"confIsMCGen", false, "Enable QA histograms for MC Gen"}; + Configurable confIsMCReco{"confIsMCReco", false, "Enable QA histograms for MC Reco"}; // Collisions - Configurable ConfZVertex{"ConfZVertex", 10.f, "Event sel: Maximum z-Vertex (cm)"}; + Configurable confZVertex{"confZVertex", 10.f, "Event sel: Maximum z-Vertex (cm)"}; - Filter collisionFilter = (nabs(aod::collision::posZ) < ConfZVertex); + Filter collisionFilter = (nabs(aod::collision::posZ) < confZVertex); using FilteredFDCollisions = soa::Filtered; using FilteredFDCollision = FilteredFDCollisions::iterator; /// Particle selection part /// Configurables for both particles - ConfigurableAxis ConfTempFitVarpTBins{"ConfTempFitVarpTBins", {20, 0.5, 4.05}, "Binning of the pT in the pT vs. TempFitVar plot"}; - ConfigurableAxis ConfTempFitVarPDGBins{"ConfTempFitVarPDGBins", {6000, -2300, 2300}, "Binning of the PDG code in the pT vs. TempFitVar plot"}; - ConfigurableAxis ConfTempFitVarCPABins{"ConfTempFitVarCPABins", {1000, 0.9, 1}, "Binning of the pointing angle cosinus in the pT vs. TempFitVar plot"}; - ConfigurableAxis ConfTempFitVarDCABins{"ConfTempFitVarDCABins", {1000, -5, 5}, "Binning of the PDG code in the pT vs. TempFitVar plot"}; + ConfigurableAxis confTempFitVarpTBins{"confTempFitVarpTBins", {20, 0.5, 4.05}, "Binning of the pT in the pT vs. TempFitVar plot"}; + ConfigurableAxis confTempFitVarPDGBins{"confTempFitVarPDGBins", {6000, -2300, 2300}, "Binning of the PDG code in the pT vs. TempFitVar plot"}; + ConfigurableAxis confTempFitVarCPABins{"confTempFitVarCPABins", {1000, 0.9, 1}, "Binning of the pointing angle cosinus in the pT vs. TempFitVar plot"}; + ConfigurableAxis confTempFitVarDCABins{"confTempFitVarDCABins", {1000, -5, 5}, "Binning of the PDG code in the pT vs. TempFitVar plot"}; struct : o2::framework::ConfigurableGroup { - Configurable ConfEtaMax{"ConfEtaMax", 0.8f, "Higher limit for |Eta| (the same for both particles)"}; - Configurable ConfMomProton{"ConfMomProton", 0.75, "Momentum threshold for proton identification using TOF"}; - Configurable ConfMomPion{"ConfMomPion", 0.75, "Momentum threshold for pion identification using TOF"}; - Configurable ConfNsigmaCombinedProton{"ConfNsigmaCombinedProton", 3.0, "TPC and TOF Proton Sigma (combined) for momentum > ConfMomProton"}; - Configurable ConfNsigmaTPCProton{"ConfNsigmaTPCProton", 3.0, "TPC Proton Sigma for momentum < ConfMomProton"}; - Configurable ConfNsigmaCombinedPion{"ConfNsigmaCombinedPion", 3.0, "TPC and TOF Pion Sigma (combined) for momentum > ConfMomPion"}; - Configurable ConfNsigmaTPCPion{"ConfNsigmaTPCPion", 3.0, "TPC Pion Sigma for momentum < ConfMomPion"}; + Configurable confEtaMax{"confEtaMax", 0.8f, "Higher limit for |Eta| (the same for both particles)"}; + Configurable confMomProton{"confMomProton", 0.75, "Momentum threshold for proton identification using TOF"}; + Configurable confMomPion{"confMomPion", 0.75, "Momentum threshold for pion identification using TOF"}; + Configurable confNsigmaCombinedProton{"confNsigmaCombinedProton", 3.0, "TPC and TOF Proton Sigma (combined) for momentum > confMomProton"}; + Configurable confNsigmaTPCProton{"confNsigmaTPCProton", 3.0, "TPC Proton Sigma for momentum < confMomProton"}; + Configurable confNsigmaCombinedPion{"confNsigmaCombinedPion", 3.0, "TPC and TOF Pion Sigma (combined) for momentum > confMomPion"}; + Configurable confNsigmaTPCPion{"confNsigmaTPCPion", 3.0, "TPC Pion Sigma for momentum < confMomPion"}; } ConfBothTracks; /// Lambda cuts - Configurable ConfV0InvMassLowLimit{"ConfV0InvV0MassLowLimit", 1.10, "Lower limit of the V0 invariant mass"}; - Configurable ConfV0InvMassUpLimit{"ConfV0InvV0MassUpLimit", 1.13, "Upper limit of the V0 invariant mass"}; + Configurable confV0InvMassLowLimit{"confV0InvMassLowLimit", 1.10, "Lower limit of the V0 invariant mass"}; + Configurable confV0InvMassUpLimit{"confV0InvMassUpLimit", 1.13, "Upper limit of the V0 invariant mass"}; /// Kaon configurable - Configurable IsKaonRun2{"IsKaonRun2", false, "Enable kaon selection used in Run2"}; // to check consistency with Run2 results + Configurable isKaonRun2{"isKaonRun2", false, "Enable kaon selection used in Run2"}; // to check consistency with Run2 results + struct : o2::framework::ConfigurableGroup { + // Momentum thresholds for Run2 and Run3 + Configurable confMomKaonRun2{"confMomKaonRun2", 0.4, "Momentum threshold for kaon identification using ToF (Run2)"}; + Configurable confMomKaonRun3{"confMomKaonRun3", 0.3, "Momentum threshold for kaon identification using ToF (Run3)"}; + Configurable confMomKaon045{"confMomKaon045", 0.45, "Momentum threshold for kaon identification pT = 0.45 GeV/c"}; + Configurable confMomKaon055{"confMomKaon055", 0.55, "Momentum threshold for kaon identification pT = 0.55 GeV/c"}; + Configurable confMomKaon08{"confMomKaon08", 0.8, "Momentum threshold for kaon identification pT = 0.8 GeV/c"}; + Configurable confMomKaon15{"confMomKaon15", 1.5, "Momentum threshold for kaon identification pT = 1.5 GeV/c"}; + // n sigma cuts for Run 2 + Configurable confKaonNsigmaTPCbelow04Run2{"confKaonNsigmaTPCbelow04Run2", 2.0, "Reject kaons with pT below 0.4 if TPC n sigma is above this value."}; + Configurable confKaonNsigmaTPCfrom04to045Run2{"confKaonNsigmaTPCfrom04to045Run2", 1.0, "Reject kaons within pT from 0.4 to 0.45 if TPC n sigma is above this value."}; + Configurable confKaonNsigmaTPCfrom045to08Run2{"confKaonNsigmaTPCfrom045to08Run2", 3.0, "Reject kaons within pT from 0.45 to 0.8 if TPC n sigma is above this value."}; + Configurable confKaonNsigmaTOFfrom045to08Run2{"confKaonNsigmaTOFfrom045to08Run2", 2.0, "Reject kaons within pT from 0.45 to 0.8 if ToF n sigma is above this value."}; + Configurable confKaonNsigmaTPCfrom08to15Run2{"confKaonNsigmaTPCfrom08to15Run2", 3.0, "Reject kaons within pT from 0.8 to 1.5 if TPC n sigma is above this value."}; + Configurable confKaonNsigmaTOFfrom08to15Run2{"confKaonNsigmaTOFfrom08to15Run2", 1.5, "Reject kaons within pT from 0.8 to 1.5 if ToF n sigma is above this value."}; + // n sigma cuts for Run 3 + Configurable confKaonNsigmaTPCfrom0to03{"confKaonNsigmaTPCfrom0to03", 3.0, "Reject kaons within pT from 0.0 to 0.3 if TPC n sigma is above this value."}; + Configurable confKaonNsigmaTPCfrom03to045{"confKaonNsigmaTPCfrom03to045", 2.0, "Reject kaons within pT from 0.3 to 0.45 if TPC n sigma is above this value."}; + Configurable confKaonNsigmaTPCfrom045to055{"confKaonNsigmaTPCfrom045to055", 1.0, "Reject kaons within pT from 0.45 to 0.55 if TPC n sigma is above this value."}; + Configurable confKaonNsigmaTPCfrom055to15{"confKaonNsigmaTPCfrom055to15", 3.0, "Reject kaons within pT from 0.55 to 1.5 if TPC n sigma is above this value."}; + Configurable confKaonNsigmaTOFfrom055to15{"confKaonNsigmaTOFfrom055to15", 3.0, "Reject kaons within pT from 0.55 to 1.5 if ToF n sigma is above this value."}; + Configurable confKaonNsigmaTPCfrom15{"confKaonNsigmaTPCfrom15", 3.0, "Reject kaons with pT above 1.5 if TPC n sigma is above this value."}; + Configurable confKaonNsigmaTOFfrom15{"confKaonNsigmaTOFfrom15", 2.0, "Reject kaons with pT above 1.5 if ToF n sigma is above this value.."}; + } ConfKaonSelection; /// Deuteron configurables struct : o2::framework::ConfigurableGroup { - Configurable ConfNsigmaTPCDe{"ConfNsigmaTPCDe", 2.0f, "TPC Deuteron Sigma for momentum < ConfTOFpMinDe"}; - Configurable ConfNsigmaTOFDe{"ConfNsigmaTOFDe", 2.0f, "TOF Deuteron Sigma"}; - Configurable ConfTOFpMinDe{"ConfTOFpMinDe", 0.5f, "Min. momentum for deuterons for which TOF is required for PID"}; - Configurable ConfPLowDe{"ConfPLowDe", 0.8f, "Lower limit for momentum for deuterons"}; - Configurable ConfPHighDe{"ConfPHighDe", 1.8f, "Higher limit for momentum for deuterons"}; + Configurable confNsigmaTPCDe{"confNsigmaTPCDe", 2.0f, "TPC Deuteron Sigma for momentum < confTOFpMinDe"}; + Configurable confNsigmaTOFDe{"confNsigmaTOFDe", 2.0f, "TOF Deuteron Sigma"}; + Configurable confTOFpMinDe{"confTOFpMinDe", 0.5f, "Min. momentum for deuterons for which TOF is required for PID"}; + Configurable confPLowDe{"confPLowDe", 0.8f, "Lower limit for momentum for deuterons"}; + Configurable confPHighDe{"confPHighDe", 1.8f, "Higher limit for momentum for deuterons"}; } deuteronconfigs; /// Particle 1 - Configurable ConfPDGCodePartOne{"ConfPDGCodePartOne", 2212, "Particle 1 - PDG code"}; - Configurable ConfParticleTypePartOne{"ConfParticleTypePartOne", aod::femtouniverseparticle::ParticleType::kTrack, "Particle 1 - particle type: 0 - track, 2 - V0, 6 - phi"}; - Configurable ConfNoPDGPartOne{"ConfNoPDGPartOne", false, "0: selecting part one by PDG, 1: no PID selection"}; - Configurable ConfPtLowPart1{"ConfPtLowPart1", 0.2, "Lower limit for Pt for the first particle"}; - Configurable ConfPtHighPart1{"ConfPtHighPart1", 2.5, "Higher limit for Pt for the first particle"}; - Configurable ConfChargePart1{"ConfChargePart1", 1, "Charge of the first particle"}; + Configurable confPDGCodePartOne{"confPDGCodePartOne", 2212, "Particle 1 - PDG code"}; + Configurable confParticleTypePartOne{"confParticleTypePartOne", aod::femtouniverseparticle::ParticleType::kTrack, "Particle 1 - particle type: 0 - track, 2 - V0, 6 - phi"}; + Configurable confNoPDGPartOne{"confNoPDGPartOne", false, "0: selecting part one by PDG, 1: no PID selection"}; + Configurable confPtLowPart1{"confPtLowPart1", 0.2, "Lower limit for Pt for the first particle"}; + Configurable confPtHighPart1{"confPtHighPart1", 2.5, "Higher limit for Pt for the first particle"}; + Configurable confChargePart1{"confChargePart1", 1, "Charge of the first particle"}; /// Partition for particle 1 - Partition partsOneMCGen = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && aod::femtouniverseparticle::pt < ConfPtHighPart1 && aod::femtouniverseparticle::pt > ConfPtLowPart1&& nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.ConfEtaMax; + Partition partsOneMCGen = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (aod::femtouniverseparticle::pt < confPtHighPart1) && (aod::femtouniverseparticle::pt > confPtLowPart1) && (nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.confEtaMax); - Partition partsTrackOneMCReco = aod::femtouniverseparticle::pt < ConfPtHighPart1 && aod::femtouniverseparticle::pt > ConfPtLowPart1&& nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.ConfEtaMax; + Partition partsTrackOneMCReco = (aod::femtouniverseparticle::pt < confPtHighPart1) && (aod::femtouniverseparticle::pt > confPtLowPart1) && (nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.confEtaMax); /// Histogramming for particle 1 FemtoUniverseParticleHisto trackHistoPartOneGen; @@ -98,18 +125,18 @@ struct femtoUniverseEfficiencyBase { FemtoUniverseParticleHisto trackHistoV0OneChildNegRec; /// Particle 2 - Configurable ConfIsSame{"ConfIsSame", false, "Pairs of the same particle"}; - Configurable ConfPDGCodePartTwo{"ConfPDGCodePartTwo", 333, "Particle 2 - PDG code"}; - Configurable ConfParticleTypePartTwo{"ConfParticleTypePartTwo", aod::femtouniverseparticle::ParticleType::kTrack, "Particle 2 - particle type: 0 - track, 2 - V0, 6 - phi"}; - Configurable ConfNoPDGPartTwo{"ConfNoPDGPartTwo", false, "0: selecting part two by PDG, 1: no PID selection"}; - Configurable ConfPtLowPart2{"ConfPtLowPart2", 0.2, "Lower limit for Pt for the second particle"}; - Configurable ConfPtHighPart2{"ConfPtHighPart2", 2.5, "Higher limit for Pt for the second particle"}; - Configurable ConfChargePart2{"ConfChargePart2", 1, "Charge of the second particle"}; + Configurable confIsSame{"confIsSame", false, "Pairs of the same particle"}; + Configurable confPDGCodePartTwo{"confPDGCodePartTwo", 333, "Particle 2 - PDG code"}; + Configurable confParticleTypePartTwo{"confParticleTypePartTwo", aod::femtouniverseparticle::ParticleType::kTrack, "Particle 2 - particle type: 0 - track, 2 - V0, 6 - phi"}; + Configurable confNoPDGPartTwo{"confNoPDGPartTwo", false, "0: selecting part two by PDG, 1: no PID selection"}; + Configurable confPtLowPart2{"confPtLowPart2", 0.2, "Lower limit for Pt for the second particle"}; + Configurable confPtHighPart2{"confPtHighPart2", 2.5, "Higher limit for Pt for the second particle"}; + Configurable confChargePart2{"confChargePart2", 1, "Charge of the second particle"}; /// Partition for particle 2 - Partition partsTwoGen = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && aod::femtouniverseparticle::pt < ConfPtHighPart2 && aod::femtouniverseparticle::pt > ConfPtLowPart2&& nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.ConfEtaMax; + Partition partsTwoMCGen = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (aod::femtouniverseparticle::pt < confPtHighPart2) && (aod::femtouniverseparticle::pt > confPtLowPart2) && (nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.confEtaMax); - Partition partsTrackTwoMCReco = aod::femtouniverseparticle::pt < ConfPtHighPart2 && aod::femtouniverseparticle::pt > ConfPtLowPart2&& nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.ConfEtaMax; + Partition partsTrackTwoMCReco = (aod::femtouniverseparticle::pt < confPtHighPart2) && (aod::femtouniverseparticle::pt > confPtLowPart2) && (nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.confEtaMax); /// Histogramming for particle 2 FemtoUniverseParticleHisto trackHistoPartTwoGen; @@ -132,43 +159,45 @@ struct femtoUniverseEfficiencyBase { { eventHisto.init(&qaRegistry); - trackHistoPartOneGen.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarPDGBins, 0, ConfPDGCodePartOne, false); - trackHistoPartOneRec.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarDCABins, 0, ConfPDGCodePartOne, ConfIsDebug); + trackHistoPartOneGen.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarPDGBins, confIsMCGen, confPDGCodePartOne, false); + trackHistoPartOneRec.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarDCABins, confIsMCReco, confPDGCodePartOne, confIsDebug); registryMCOrigin.add("part1/hPt", " ;#it{p}_{T} (GeV/c); Entries", {HistType::kTH1F, {{240, 0, 6}}}); registryPDG.add("part1/PDGvspT", "PDG;#it{p}_{T} (GeV/c); PDG", {HistType::kTH2F, {{500, 0, 5}, {16001, -8000.5, 8000.5}}}); - if (ConfParticleTypePartOne == uint8_t(aod::femtouniverseparticle::ParticleType::kV0)) { - trackHistoV0OneRec.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarCPABins, 0, ConfPDGCodePartOne, ConfIsDebug); - trackHistoV0OneChildPosRec.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarDCABins, 0, 0, ConfIsDebug, "posChildV0_1"); - trackHistoV0OneChildNegRec.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarDCABins, 0, 0, ConfIsDebug, "negChildV0_1"); + registryPDG.add("part1/PDGvspTall", "PDG;#it{p}_{T} (GeV/c); PDG", {HistType::kTH2F, {{500, 0, 5}, {16001, -8000.5, 8000.5}}}); + if (confParticleTypePartOne == uint8_t(aod::femtouniverseparticle::ParticleType::kV0)) { + trackHistoV0OneRec.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarCPABins, 0, confPDGCodePartOne, confIsDebug); + trackHistoV0OneChildPosRec.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarDCABins, 0, 0, confIsDebug, "posChildV0_1"); + trackHistoV0OneChildNegRec.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarDCABins, 0, 0, confIsDebug, "negChildV0_1"); registryPDG.add("part1/dpositive/PDGvspT", "PDG;#it{p}_{T} (GeV/c); PDG", {HistType::kTH2F, {{500, 0, 5}, {16001, -8000.5, 8000.5}}}); registryPDG.add("part1/dnegative/PDGvspT", "PDG;#it{p}_{T} (GeV/c); PDG", {HistType::kTH2F, {{500, 0, 5}, {16001, -8000.5, 8000.5}}}); } registryPDG.add("part2/PDGvspT", "PDG;#it{p}_{T} (GeV/c); PDG", {HistType::kTH2F, {{500, 0, 5}, {16001, -8000.5, 8000.5}}}); - if (!ConfIsSame) { - trackHistoPartTwoGen.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarPDGBins, 0, ConfPDGCodePartTwo, false); - trackHistoPartTwoRec.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarDCABins, 0, ConfPDGCodePartTwo, ConfIsDebug); + registryPDG.add("part2/PDGvspTall", "PDG;#it{p}_{T} (GeV/c); PDG", {HistType::kTH2F, {{500, 0, 5}, {16001, -8000.5, 8000.5}}}); + if (!confIsSame) { + trackHistoPartTwoGen.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarPDGBins, confIsMCGen, confPDGCodePartTwo, false); + trackHistoPartTwoRec.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarDCABins, confIsMCReco, confPDGCodePartTwo, confIsDebug); registryMCOrigin.add("part2/hPt", " ;#it{p}_{T} (GeV/c); Entries", {HistType::kTH1F, {{240, 0, 6}}}); - if (ConfParticleTypePartTwo == uint8_t(aod::femtouniverseparticle::ParticleType::kV0)) { - trackHistoV0TwoRec.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarCPABins, 0, ConfPDGCodePartTwo, ConfIsDebug); - trackHistoV0TwoChildPosRec.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarDCABins, 0, 0, ConfIsDebug, "posChildV0_2"); - trackHistoV0TwoChildNegRec.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarDCABins, 0, 0, ConfIsDebug, "negChildV0_2"); + if (confParticleTypePartTwo == uint8_t(aod::femtouniverseparticle::ParticleType::kV0)) { + trackHistoV0TwoRec.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarCPABins, 0, confPDGCodePartTwo, confIsDebug); + trackHistoV0TwoChildPosRec.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarDCABins, 0, 0, confIsDebug, "posChildV0_2"); + trackHistoV0TwoChildNegRec.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarDCABins, 0, 0, confIsDebug, "negChildV0_2"); registryPDG.add("part2/dpositive/PDGvspT", "PDG;#it{p}_{T} (GeV/c); PDG", {HistType::kTH2F, {{500, 0, 5}, {16001, -8000.5, 8000.5}}}); registryPDG.add("part2/dnegative/PDGvspT", "PDG;#it{p}_{T} (GeV/c); PDG", {HistType::kTH2F, {{500, 0, 5}, {16001, -8000.5, 8000.5}}}); } } } - bool IsProtonNSigma(float mom, float nsigmaTPCPr, float nsigmaTOFPr) // previous version from: https://github.com/alisw/AliPhysics/blob/master/PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoMJTrackCut.cxx + bool isProtonNSigma(float mom, float nsigmaTPCPr, float nsigmaTOFPr) // previous version from: https://github.com/alisw/AliPhysics/blob/master/PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoMJTrackCut.cxx { - if (mom < ConfBothTracks.ConfMomProton) { - if (TMath::Abs(nsigmaTPCPr) < ConfBothTracks.ConfNsigmaTPCProton) { + if (mom < ConfBothTracks.confMomProton) { + if (std::abs(nsigmaTPCPr) < ConfBothTracks.confNsigmaTPCProton) { return true; } else { return false; } } else { - if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.ConfNsigmaCombinedProton) { + if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.confNsigmaCombinedProton) { return true; } else { return false; @@ -177,49 +206,49 @@ struct femtoUniverseEfficiencyBase { return false; } - bool IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK) + bool isKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK) { - if (IsKaonRun2 == true) { - if (mom < 0.4) { - return TMath::Abs(nsigmaTPCK) < 2; - } else if (mom > 0.4 && mom < 0.45) { - return TMath::Abs(nsigmaTPCK) < 1; - } else if (mom > 0.45 && mom < 0.8) { - return (TMath::Abs(nsigmaTPCK) < 3 && TMath::Abs(nsigmaTOFK) < 2); - } else if (mom > 0.8 && mom < 1.5) { - return (TMath::Abs(nsigmaTPCK) < 3 && TMath::Abs(nsigmaTOFK) < 1.5); + if (isKaonRun2 == true) { + if (mom < ConfKaonSelection.confMomKaonRun2) { // < 0.4 GeV/c + return std::abs(nsigmaTPCK) < ConfKaonSelection.confKaonNsigmaTPCbelow04Run2; + } else if (mom > ConfKaonSelection.confMomKaonRun2 && mom < ConfKaonSelection.confMomKaon045) { // 0.4 - 0.45 + return std::abs(nsigmaTPCK) < ConfKaonSelection.confKaonNsigmaTPCfrom04to045Run2; + } else if (mom > ConfKaonSelection.confMomKaon045 && mom < ConfKaonSelection.confMomKaon08) { // 0.45 - 0.8 + return (std::abs(nsigmaTPCK) < ConfKaonSelection.confKaonNsigmaTPCfrom045to08Run2 && std::abs(nsigmaTOFK) < ConfKaonSelection.confKaonNsigmaTOFfrom045to08Run2); + } else if (mom > ConfKaonSelection.confMomKaon08 && mom < ConfKaonSelection.confMomKaon15) { // 0.8 - 1.5 + return (std::abs(nsigmaTPCK) < ConfKaonSelection.confKaonNsigmaTPCfrom08to15Run2 && std::abs(nsigmaTOFK) < ConfKaonSelection.confKaonNsigmaTOFfrom08to15Run2); } else { return false; } } else { - if (mom < 0.3) { // 0.0-0.3 - if (TMath::Abs(nsigmaTPCK) < 3.0) { + if (mom < ConfKaonSelection.confMomKaonRun3) { // 0.0-0.3 + if (std::abs(nsigmaTPCK) < ConfKaonSelection.confKaonNsigmaTPCfrom0to03) { return true; } else { return false; } - } else if (mom < 0.45) { // 0.30 - 0.45 - if (TMath::Abs(nsigmaTPCK) < 2.0) { + } else if (mom < ConfKaonSelection.confMomKaon045) { // 0.30 - 0.45 + if (std::abs(nsigmaTPCK) < ConfKaonSelection.confKaonNsigmaTPCfrom03to045) { return true; } else { return false; } - } else if (mom < 0.55) { // 0.45-0.55 - if (TMath::Abs(nsigmaTPCK) < 1.0) { + } else if (mom < ConfKaonSelection.confMomKaon055) { // 0.45-0.55 + if (std::abs(nsigmaTPCK) < ConfKaonSelection.confKaonNsigmaTPCfrom045to055) { return true; } else { return false; } - } else if (mom < 1.5) { // 0.55-1.5 (now we use TPC and TOF) - if ((TMath::Abs(nsigmaTOFK) < 3.0) && (TMath::Abs(nsigmaTPCK) < 3.0)) { + } else if (mom < ConfKaonSelection.confMomKaon15) { // 0.55-1.5 (now we use TPC and TOF) + if ((std::abs(nsigmaTOFK) < ConfKaonSelection.confKaonNsigmaTOFfrom055to15) && (std::abs(nsigmaTPCK) < ConfKaonSelection.confKaonNsigmaTPCfrom055to15)) { { return true; } } else { return false; } - } else if (mom > 1.5) { // 1.5 - - if ((TMath::Abs(nsigmaTOFK) < 2.0) && (TMath::Abs(nsigmaTPCK) < 3.0)) { + } else if (mom > ConfKaonSelection.confMomKaon15) { // > 1.5 GeV/c + if ((std::abs(nsigmaTOFK) < ConfKaonSelection.confKaonNsigmaTOFfrom15) && (std::abs(nsigmaTPCK) < ConfKaonSelection.confKaonNsigmaTPCfrom15)) { return true; } else { return false; @@ -230,16 +259,16 @@ struct femtoUniverseEfficiencyBase { } } - bool IsPionNSigma(float mom, float nsigmaTPCPi, float nsigmaTOFPi) + bool isPionNSigma(float mom, float nsigmaTPCPi, float nsigmaTOFPi) { - if (mom < ConfBothTracks.ConfMomPion) { - if (TMath::Abs(nsigmaTPCPi) < ConfBothTracks.ConfNsigmaTPCPion) { + if (mom < ConfBothTracks.confMomPion) { + if (std::abs(nsigmaTPCPi) < ConfBothTracks.confNsigmaTPCPion) { return true; } else { return false; } } else { - if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.ConfNsigmaCombinedPion) { + if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.confNsigmaCombinedPion) { return true; } else { return false; @@ -248,37 +277,37 @@ struct femtoUniverseEfficiencyBase { return false; } - bool IsDeuteronNSigma(float mom, float nsigmaTPCDe, float nsigmaTOFDe) + bool isDeuteronNSigma(float mom, float nsigmaTPCDe, float nsigmaTOFDe) { - if (mom > deuteronconfigs.ConfPLowDe && mom < deuteronconfigs.ConfPHighDe) { - if (mom < deuteronconfigs.ConfTOFpMinDe) { - return (TMath::Abs(nsigmaTPCDe) < deuteronconfigs.ConfNsigmaTPCDe); + if (mom > deuteronconfigs.confPLowDe && mom < deuteronconfigs.confPHighDe) { + if (mom < deuteronconfigs.confTOFpMinDe) { + return (std::abs(nsigmaTPCDe) < deuteronconfigs.confNsigmaTPCDe); } else { - return (TMath::Abs(nsigmaTOFDe) < deuteronconfigs.ConfNsigmaTOFDe && (TMath::Abs(nsigmaTPCDe) < deuteronconfigs.ConfNsigmaTPCDe)); + return (std::abs(nsigmaTOFDe) < deuteronconfigs.confNsigmaTOFDe && (std::abs(nsigmaTPCDe) < deuteronconfigs.confNsigmaTPCDe)); } } else { return false; } } - bool IsParticleNSigma(int pdgCode, float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK, float nsigmaTPCDe, float nsigmaTOFDe) + bool isParticleNSigma(int pdgCode, float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK, float nsigmaTPCDe, float nsigmaTOFDe) { switch (pdgCode) { case 2212: // Proton case -2212: // anty Proton - return IsProtonNSigma(mom, nsigmaTPCPr, nsigmaTOFPr); + return isProtonNSigma(mom, nsigmaTPCPr, nsigmaTOFPr); break; case 211: // Pion case -211: // Pion- - return IsPionNSigma(mom, nsigmaTPCPi, nsigmaTOFPi); + return isPionNSigma(mom, nsigmaTPCPi, nsigmaTOFPi); break; case 321: // Kaon+ case -321: // Kaon- - return IsKaonNSigma(mom, nsigmaTPCK, nsigmaTOFK); + return isKaonNSigma(mom, nsigmaTPCK, nsigmaTOFK); break; case 1000010020: // Deuteron case -1000010020: // Antideuteron - return IsDeuteronNSigma(mom, nsigmaTPCDe, nsigmaTOFDe); + return isDeuteronNSigma(mom, nsigmaTPCDe, nsigmaTOFDe); break; default: return false; @@ -287,7 +316,7 @@ struct femtoUniverseEfficiencyBase { bool invMLambda(float invMassLambda, float invMassAntiLambda) { - if ((invMassLambda < ConfV0InvMassLowLimit || invMassLambda > ConfV0InvMassUpLimit) && (invMassAntiLambda < ConfV0InvMassLowLimit || invMassAntiLambda > ConfV0InvMassUpLimit)) { + if ((invMassLambda < confV0InvMassLowLimit || invMassLambda > confV0InvMassUpLimit) && (invMassAntiLambda < confV0InvMassLowLimit || invMassAntiLambda > confV0InvMassUpLimit)) { return false; } return true; @@ -308,16 +337,16 @@ struct femtoUniverseEfficiencyBase { void doMCGen(PartitionType grouppartsOneMCGen, PartitionType grouppartsTwoMCGen) { /// Histogramming same event - for (auto& part : grouppartsOneMCGen) { - if (!ConfNoPDGPartOne && part.tempFitVar() != ConfPDGCodePartOne) { + for (const auto& part : grouppartsOneMCGen) { + if (!confNoPDGPartOne && part.tempFitVar() != confPDGCodePartOne) { continue; } trackHistoPartOneGen.fillQA(part); } - if (!ConfIsSame) { - for (auto& part : grouppartsTwoMCGen) { - if (!ConfNoPDGPartTwo && part.tempFitVar() != ConfPDGCodePartTwo) { + if (!confIsSame) { + for (const auto& part : grouppartsTwoMCGen) { + if (!confNoPDGPartTwo && part.tempFitVar() != confPDGCodePartTwo) { continue; } trackHistoPartTwoGen.fillQA(part); @@ -335,34 +364,53 @@ struct femtoUniverseEfficiencyBase { void doMCRecTrackTrack(PartitionType grouppartsOneMCRec, PartitionType grouppartsTwoMCRec) { /// Histogramming same event - for (auto& part : grouppartsOneMCRec) { - if (part.partType() != ConfParticleTypePartOne || part.sign() != ConfChargePart1 || !IsParticleNSigma(ConfPDGCodePartOne, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron))) { + for (const auto& part : grouppartsOneMCRec) { + if (part.partType() != confParticleTypePartOne || part.sign() != confChargePart1 || !isParticleNSigma(confPDGCodePartOne, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron))) { continue; } - trackHistoPartOneRec.fillQA(part); if (!part.has_fdMCParticle()) { continue; } const auto mcParticle = part.fdMCParticle(); + registryPDG.fill(HIST("part1/PDGvspTall"), part.pt(), mcParticle.pdgMCTruth()); + trackHistoPartOneRec.fillQA(part); + + if (!(mcParticle.partOriginMCTruth() == aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kPrimary)) { + continue; + } + + if (!(std::abs(mcParticle.pdgMCTruth()) == std::abs(confPDGCodePartOne))) { + continue; + } + registryPDG.fill(HIST("part1/PDGvspT"), part.pt(), mcParticle.pdgMCTruth()); registryMCOrigin.fill(HIST("part1/hPt"), mcParticle.pt()); } - if (!ConfIsSame) { - for (auto& part : grouppartsTwoMCRec) { - if (part.partType() != ConfParticleTypePartTwo || part.sign() != ConfChargePart2 || !IsParticleNSigma(ConfPDGCodePartTwo, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron))) { + if (!confIsSame) { + for (const auto& part : grouppartsTwoMCRec) { + if (part.partType() != confParticleTypePartTwo || part.sign() != confChargePart2 || !isParticleNSigma(confPDGCodePartTwo, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron))) { continue; } - trackHistoPartTwoRec.fillQA(part); - if (!part.has_fdMCParticle()) { continue; } const auto mcParticle = part.fdMCParticle(); + registryPDG.fill(HIST("part2/PDGvspTall"), part.pt(), mcParticle.pdgMCTruth()); + trackHistoPartTwoRec.fillQA(part); + + if (!(mcParticle.partOriginMCTruth() == aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kPrimary)) { + continue; + } + + if (!(std::abs(mcParticle.pdgMCTruth()) == std::abs(confPDGCodePartTwo))) { + continue; + } + registryPDG.fill(HIST("part2/PDGvspT"), part.pt(), mcParticle.pdgMCTruth()); registryMCOrigin.fill(HIST("part2/hPt"), mcParticle.pt()); } @@ -379,8 +427,8 @@ struct femtoUniverseEfficiencyBase { void doMCRecTrackPhi(PartitionType grouppartsOneMCRec, PartitionType grouppartsTwoMCRec) { // part1 is track and part2 is Phi - for (auto& part : grouppartsOneMCRec) { - if (part.partType() != ConfParticleTypePartOne || part.sign() != ConfChargePart1 || !IsParticleNSigma(ConfPDGCodePartOne, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron))) { + for (const auto& part : grouppartsOneMCRec) { + if (part.partType() != confParticleTypePartOne || part.sign() != confChargePart1 || !isParticleNSigma(confPDGCodePartOne, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron))) { continue; } trackHistoPartOneRec.fillQA(part); @@ -394,9 +442,9 @@ struct femtoUniverseEfficiencyBase { registryMCOrigin.fill(HIST("part1/hPt"), mcParticle.pt()); } - if (!ConfIsSame) { - for (auto& part : grouppartsTwoMCRec) { - if (part.partType() != ConfParticleTypePartTwo || part.sign() != ConfChargePart2) { + if (!confIsSame) { + for (const auto& part : grouppartsTwoMCRec) { + if (part.partType() != confParticleTypePartTwo || part.sign() != confChargePart2) { continue; } @@ -425,19 +473,19 @@ struct femtoUniverseEfficiencyBase { void doMCRecV0V0(PartitionType grouppartsOneMCRec, PartitionType grouppartsTwoMCRec, ParticlesType parts) { /// Histogramming same event - for (auto& part : grouppartsOneMCRec) { + for (const auto& part : grouppartsOneMCRec) { - if (part.partType() != ConfParticleTypePartOne || !invMLambda(part.mLambda(), part.mAntiLambda())) { + if (part.partType() != confParticleTypePartOne || !invMLambda(part.mLambda(), part.mAntiLambda())) { continue; } const auto& posChild = parts.iteratorAt(part.index() - 2); const auto& negChild = parts.iteratorAt(part.index() - 1); - if (ConfPDGCodePartOne > 0 && (!IsProtonNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Proton)) || !IsPionNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF + if (confPDGCodePartOne > 0 && (!isProtonNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Proton)) || !isPionNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF continue; } - if (ConfPDGCodePartOne < 0 && (!IsProtonNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Proton)) || !IsPionNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF + if (confPDGCodePartOne < 0 && (!isProtonNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Proton)) || !isPionNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF continue; } @@ -458,20 +506,20 @@ struct femtoUniverseEfficiencyBase { registryMCOrigin.fill(HIST("part1/hPt"), mcParticle.pt()); } - if (!ConfIsSame) { - for (auto& part : grouppartsTwoMCRec) { + if (!confIsSame) { + for (const auto& part : grouppartsTwoMCRec) { - if (part.partType() != ConfParticleTypePartTwo || !invMLambda(part.mLambda(), part.mAntiLambda())) { + if (part.partType() != confParticleTypePartTwo || !invMLambda(part.mLambda(), part.mAntiLambda())) { continue; } const auto& posChild = parts.iteratorAt(part.index() - 2); const auto& negChild = parts.iteratorAt(part.index() - 1); - if (ConfPDGCodePartTwo > 0 && (!IsProtonNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Proton)) || !IsPionNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF + if (confPDGCodePartTwo > 0 && (!isProtonNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Proton)) || !isPionNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF continue; } - if (ConfPDGCodePartTwo < 0 && (!IsProtonNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Proton)) || !IsPionNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF + if (confPDGCodePartTwo < 0 && (!isProtonNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Proton)) || !isPionNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF continue; } @@ -507,8 +555,8 @@ struct femtoUniverseEfficiencyBase { { // part1 is track and part2 is V0 /// Histogramming same event - for (auto& part : grouppartsOneMCRec) { - if (part.partType() != ConfParticleTypePartOne || part.sign() != ConfChargePart1 || !IsParticleNSigma(ConfPDGCodePartOne, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron))) { + for (const auto& part : grouppartsOneMCRec) { + if (part.partType() != confParticleTypePartOne || part.sign() != confChargePart1 || !isParticleNSigma(confPDGCodePartOne, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron))) { continue; } @@ -521,19 +569,19 @@ struct femtoUniverseEfficiencyBase { registryMCOrigin.fill(HIST("part1/hPt"), mcParticle.pt()); } - if (!ConfIsSame) { - for (auto& part : grouppartsTwoMCRec) { + if (!confIsSame) { + for (const auto& part : grouppartsTwoMCRec) { - if (part.partType() != ConfParticleTypePartTwo || !invMLambda(part.mLambda(), part.mAntiLambda())) { + if (part.partType() != confParticleTypePartTwo || !invMLambda(part.mLambda(), part.mAntiLambda())) { continue; } const auto& posChild = parts.iteratorAt(part.index() - 2); const auto& negChild = parts.iteratorAt(part.index() - 1); - if (ConfPDGCodePartTwo > 0 && (!IsProtonNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Proton)) || !IsPionNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF + if (confPDGCodePartTwo > 0 && (!isProtonNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Proton)) || !isPionNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF continue; } - if (ConfPDGCodePartTwo < 0 && (!IsProtonNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Proton)) || !IsPionNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF + if (confPDGCodePartTwo < 0 && (!isProtonNSigma(0, trackCuts.getNsigmaTPC(negChild, o2::track::PID::Proton), trackCuts.getNsigmaTOF(negChild, o2::track::PID::Proton)) || !isPionNSigma(0, trackCuts.getNsigmaTPC(posChild, o2::track::PID::Pion), trackCuts.getNsigmaTOF(posChild, o2::track::PID::Pion)))) { // give momentum as 0 to only check TPC nSigma, not combined with TOF continue; } @@ -558,96 +606,104 @@ struct femtoUniverseEfficiencyBase { /// process function for to call doMCRecTrackTrack with Data /// \param col subscribe to the collision table (Data) - void processTrackTrack(FilteredFDCollision& col, - FemtoFullParticles&, aod::FdMCParticles const&) + void processTrackTrack(FilteredFDCollision const& col, + FemtoFullParticles const&, aod::FdMCParticles const&) { fillCollision(col); // MCGen auto thegrouppartsOneMCGen = partsOneMCGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegrouppartsTwoMCGen = partsTwoGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - doMCGen(thegrouppartsOneMCGen, thegrouppartsTwoMCGen); + auto thegrouppartsTwoMCGen = partsTwoMCGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + if (confIsMCGen) { + doMCGen(thegrouppartsOneMCGen, thegrouppartsTwoMCGen); + } else { + doMCGen(thegrouppartsOneMCGen, thegrouppartsTwoMCGen); + } // MCRec auto thegroupPartsTrackOneRec = partsTrackOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto thegroupPartsTrackTwoRec = partsTrackTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - if (ConfIsDebug) { - doMCRecTrackTrack(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec); + if (confIsDebug) { + if (confIsMCGen) { + doMCRecTrackTrack(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec); + } else { + doMCRecTrackTrack(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec); + } } else { doMCRecTrackTrack(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec); } } - PROCESS_SWITCH(femtoUniverseEfficiencyBase, processTrackTrack, "Enable processing track-track efficiency task", true); + PROCESS_SWITCH(FemtoUniverseEfficiencyBase, processTrackTrack, "Enable processing track-track efficiency task", true); /// process function for to call doMCRecTrackPhi with Data /// \param col subscribe to the collision table (Data) - void processTrackPhi(FilteredFDCollision& col, - FemtoFullParticles&, aod::FdMCParticles const&) + void processTrackPhi(FilteredFDCollision const& col, + FemtoFullParticles const&, aod::FdMCParticles const&) { fillCollision(col); // MCGen auto thegrouppartsOneMCGen = partsOneMCGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegrouppartsTwoMCGen = partsTwoGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegrouppartsTwoMCGen = partsTwoMCGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); doMCGen(thegrouppartsOneMCGen, thegrouppartsTwoMCGen); // MCRec auto thegroupPartsTrackOneRec = partsTrackOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto thegroupPartsTrackTwoRec = partsTrackTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - if (ConfIsDebug) { + if (confIsDebug) { doMCRecTrackPhi(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec); } else { doMCRecTrackPhi(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec); } } - PROCESS_SWITCH(femtoUniverseEfficiencyBase, processTrackPhi, "Enable processing track-phi efficiency task", false); + PROCESS_SWITCH(FemtoUniverseEfficiencyBase, processTrackPhi, "Enable processing track-phi efficiency task", false); /// process function for to call doMCRecV0V0 with Data /// \param col subscribe to the collision table (Data) /// \param parts subscribe to the femtoUniverseParticleTable - void processV0V0(FilteredFDCollision& col, - FemtoFullParticles& parts, aod::FdMCParticles const&) + void processV0V0(FilteredFDCollision const& col, + FemtoFullParticles const& parts, aod::FdMCParticles const&) { fillCollision(col); // MCGen auto thegrouppartsOneMCGen = partsOneMCGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegrouppartsTwoMCGen = partsTwoGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegrouppartsTwoMCGen = partsTwoMCGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); doMCGen(thegrouppartsOneMCGen, thegrouppartsTwoMCGen); // MCRec auto thegroupPartsTrackOneRec = partsTrackOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto thegroupPartsTrackTwoRec = partsTrackTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - if (ConfIsDebug) { + if (confIsDebug) { doMCRecV0V0(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec, parts); } else { doMCRecV0V0(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec, parts); } } - PROCESS_SWITCH(femtoUniverseEfficiencyBase, processV0V0, "Enable processing V0-V0 efficiency task", false); + PROCESS_SWITCH(FemtoUniverseEfficiencyBase, processV0V0, "Enable processing V0-V0 efficiency task", false); /// process function for to call doMCRecTrackV0 with Data /// \param col subscribe to the collision table (Data) /// \param parts subscribe to the femtoUniverseParticleTable - void processTrackV0(FilteredFDCollision& col, - FemtoFullParticles& parts, aod::FdMCParticles const&) + void processTrackV0(FilteredFDCollision const& col, + FemtoFullParticles const& parts, aod::FdMCParticles const&) { fillCollision(col); // MCGen auto thegrouppartsOneMCGen = partsOneMCGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegrouppartsTwoMCGen = partsTwoGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegrouppartsTwoMCGen = partsTwoMCGen->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); doMCGen(thegrouppartsOneMCGen, thegrouppartsTwoMCGen); // MCRec auto thegroupPartsTrackOneRec = partsTrackOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto thegroupPartsTrackTwoRec = partsTrackTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - if (ConfIsDebug) { + if (confIsDebug) { doMCRecTrackV0(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec, parts); } else { doMCRecTrackV0(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec, parts); } } - PROCESS_SWITCH(femtoUniverseEfficiencyBase, processTrackV0, "Enable processing track-V0 efficiency task", false); + PROCESS_SWITCH(FemtoUniverseEfficiencyBase, processTrackV0, "Enable processing track-V0 efficiency task", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; return workflow; } diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniverseHashTask.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniverseHashTask.cxx index 7f30fda061f..6f7a7d5db2b 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniverseHashTask.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniverseHashTask.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackCascadeExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackCascadeExtended.cxx index 7062bcd4c60..11d1bf2418e 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackCascadeExtended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackCascadeExtended.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -13,22 +13,27 @@ /// \brief Task for cascade correlations and QA /// \author Barbara Chytla, WUT Warsaw, barbara.chytla@cern.ch /// \author Shirajum Monira, WUT Warsaw, shirajum.monira@cern.ch -// o2-linter: disable=name/workflow-file -#include +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" +#include "PWGCF/FemtoUniverse/Core/femtoUtils.h" +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" + +#include "Framework/ASoAHelpers.h" #include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" -#include "Framework/ASoAHelpers.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/RunningWorkflowInfo.h" #include "Framework/StepTHn.h" -#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" -#include "PWGCF/FemtoUniverse/Core/femtoUtils.h" +#include "Framework/runDataProcessing.h" + +#include + +#include +#include using namespace o2; using namespace o2::soa; @@ -37,64 +42,87 @@ using namespace o2::framework::expressions; using namespace o2::analysis::femto_universe; using namespace o2::aod::pidutils; -struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/struct +struct femtoUniversePairTaskTrackCascadeExtended { + Service pdgMC; SliceCache cache; - using FemtoFullParticles = soa::Join; - Preslice perCol = aod::femtouniverseparticle::fdCollisionId; - - Configurable confZVertexCut{"ConfZVertexCut", 10.f, "Event sel: Maximum z-Vertex (cm)"}; // o2-linter: disable=name/configurable + using FemtoFullParticles = soa::Join; + using FemtoRecoFullParticles = soa::Join; + using FemtoRecoBasicParticles = soa::Join; + + ConfigurableAxis confChildTempFitVarpTBins{"confChildTempFitVarpTBins", {20, 0.5, 4.05}, "V0 child: pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis confChildTempFitVarBins{"confChildTempFitVarBins", {300, -0.15, 0.15}, "V0 child: binning of the TempFitVar in the pT vs. TempFitVar plot"}; + Configurable confCascInvMassLowLimit{"confCascInvMassLowLimit", 1.315, "Lower limit of the Casc invariant mass"}; + Configurable confCascInvMassUpLimit{"confCascInvMassUpLimit", 1.325, "Upper limit of the Casc invariant mass"}; + Configurable confCascTranRad{"confCascTranRad", 0.5, "Cascade transverse radius"}; + + Configurable confNSigmaTPCPion{"confNSigmaTPCPion", 4, "NSigmaTPCPion"}; + Configurable confNSigmaTPCProton{"confNSigmaTPCProton", 4, "NSigmaTPCProton"}; + + /// applying narrow cut + Configurable confZVertexCut{"confZVertexCut", 10.f, "Event sel: Maximum z-Vertex (cm)"}; + Configurable confEta{"confEta", 0.8, "Eta cut for the global track"}; + + // configurations for correlation part + Configurable confTrackChoicePartOne{"confTrackChoicePartOne", 0, "0:Proton, 1:Pion, 2:Kaon"}; + Configurable confTrkPDGCodePartOne{"confTrkPDGCodePartOne", 2212, "Particle 1 (Track) - PDG code"}; + Configurable confCascType1{"confCascType1", 0, "select one of the Cascades (Omega = 0, Xi = 1, anti-Omega = 2, anti-Xi = 3) for track-cascade combination"}; + Configurable confCascType2{"confCascType2", 0, "select one of the Cascades (Omega = 0, Xi = 1, anti-Omega = 2, anti-Xi = 3) for cascade-cascade combination"}; + Configurable confIsCPR{"confIsCPR", false, "Close Pair Rejection"}; + Configurable confCPRdeltaPhiCutMax{"confCPRdeltaPhiCutMax", 0.0, "Delta Phi max cut for Close Pair Rejection"}; + Configurable confCPRdeltaPhiCutMin{"confCPRdeltaPhiCutMin", 0.0, "Delta Phi min cut for Close Pair Rejection"}; + Configurable confCPRdeltaEtaCutMax{"confCPRdeltaEtaCutMax", 0.0, "Delta Eta max cut for Close Pair Rejection"}; + Configurable confCPRdeltaEtaCutMin{"confCPRdeltaEtaCutMin", 0.0, "Delta Eta min cut for Close Pair Rejection"}; + Configurable confCPRPlotPerRadii{"confCPRPlotPerRadii", false, "Plot CPR per radii"}; + Configurable confCPRChosenRadii{"confCPRChosenRadii", 0.0, "Delta Eta cut for Close Pair Rejection"}; + Configurable confIsSameSignCPR{"confIsSameSignCPR", false, "Close Pair Rejection for same sign children of cascades"}; + Configurable confChargePart1{"confChargePart1", 1, "sign of particle 1"}; + Configurable confHPtPart1{"confHPtPart1", 4.0f, "higher limit for pt of particle 1"}; + Configurable confLPtPart1{"confLPtPart1", 0.5f, "lower limit for pt of particle 1"}; + Configurable confHPtPart2{"confHPtPart2", 4.0f, "higher limit for pt of particle 2"}; + Configurable confLPtPart2{"confLPtPart2", 0.3f, "lower limit for pt of particle 2"}; + Configurable confmom{"confmom", 0.75, "momentum threshold for particle identification using TOF"}; + Configurable confNsigmaTPCParticle{"confNsigmaTPCParticle", 3.0, "TPC Sigma for particle (track) momentum < Confmom"}; + Configurable confNsigmaCombinedParticle{"confNsigmaCombinedParticle", 3.0, "TPC and TOF Sigma (combined) for particle (track) momentum > Confmom"}; + Configurable confNsigmaTPCParticleChild{"confNsigmaTPCParticleChild", 3.0, "TPC Sigma for particle (daugh & bach) momentum < Confmom"}; + Configurable confCheckTOFBachelorOnly{"confCheckTOFBachelorOnly", false, "Enable TOF for Cascade bachelor only"}; + Configurable confNsigmaTOFParticleChild{"confNsigmaTOFParticleChild", 3.0, "TOF Sigma for particle (daugh & bach) momentum > Confmom"}; + + ConfigurableAxis confkstarBins{"confkstarBins", {1500, 0., 6.}, "binning kstar"}; + ConfigurableAxis confMultBins{"confMultBins", {VARIABLE_WIDTH, 0.0f, 20.0f, 40.0f, 60.0f, 80.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - multiplicity"}; + ConfigurableAxis confkTBins{"confkTBins", {150, 0., 9.}, "binning kT"}; + ConfigurableAxis confmTBins{"confmTBins", {225, 0., 7.5}, "binning mT"}; + ConfigurableAxis confMultBins3D{"confMultBins3D", {VARIABLE_WIDTH, 0.0f, 20.0f, 30.0f, 40.0f, 99999.0f}, "multiplicity Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; + ConfigurableAxis confmTBins3D{"confmTBins3D", {VARIABLE_WIDTH, 1.02f, 1.14f, 1.20f, 1.26f, 1.38f, 1.56f, 1.86f, 4.50f}, "mT Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; + Configurable confEtaBins{"confEtaBins", 29, "Number of eta bins in deta dphi"}; + Configurable confPhiBins{"confPhiBins", 29, "Number of phi bins in deta dphi"}; + Configurable confIsMC{"confIsMC", false, "Enable additional Histograms in the case of a MonteCarlo Run"}; + Configurable confUse3D{"confUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; + Configurable confUseCent{"confUseCent", false, "Use centrality in place of multiplicity"}; + ConfigurableAxis confVtxBins{"confVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis confTrkTempFitVarpTBins{"confTrkTempFitVarpTBins", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis confTrkTempFitVarBins{"confTrkTempFitVarBins", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; + Configurable confNEventsMix{"confNEventsMix", 5, "Number of events for mixing"}; Filter collisionFilter = (nabs(aod::collision::posZ) < confZVertexCut); using FilteredFDCollisions = soa::Filtered; using FilteredFDCollision = FilteredFDCollisions::iterator; - ConfigurableAxis confChildTempFitVarpTBins{"ConfChildTempFitVarpTBins", {20, 0.5, 4.05}, "V0 child: pT binning of the pT vs. TempFitVar plot"}; // o2-linter: disable=name/configurable - ConfigurableAxis confChildTempFitVarBins{"ConfChildTempFitVarBins", {300, -0.15, 0.15}, "V0 child: binning of the TempFitVar in the pT vs. TempFitVar plot"}; // o2-linter: disable=name/configurable - Configurable confCascInvMassLowLimit{"ConfCascInvMassLowLimit", 1.315, "Lower limit of the Casc invariant mass"}; // o2-linter: disable=name/configurable - Configurable confCascInvMassUpLimit{"ConfCascInvMassUpLimit", 1.325, "Upper limit of the Casc invariant mass"}; // o2-linter: disable=name/configurable - Configurable confCascTranRad{"ConfCascTranRad", 0.5, "Cascade transverse radius"}; // o2-linter: disable=name/configurable - - Configurable confNSigmaTPCPion{"NSigmaTPCPion", 4, "NSigmaTPCPion"}; // o2-linter: disable=name/configurable - Configurable confNSigmaTPCProton{"NSigmaTPCProton", 4, "NSigmaTPCProton"}; // o2-linter: disable=name/configurable - - // configs for correlation part - Configurable confTrackChoicePartOne{"ConfTrackChoicePartOne", 0, "0:Proton, 1:Pion, 2:Kaon"}; // o2-linter: disable=name/configurable - Configurable confTrkPDGCodePartOne{"ConfTrkPDGCodePartOne", 2212, "Particle 1 (Track) - PDG code"}; // o2-linter: disable=name/configurable - Configurable confCascType1{"ConfCascType1", 0, "select one of the V0s (Omega = 0, Xi = 1, anti-Omega = 2, anti-Xi = 3) for track-cascade combination"}; // o2-linter: disable=name/configurable - Configurable confCascType2{"ConfCascType2", 0, "select one of the V0s (Omega = 0, Xi = 1, anti-Omega = 2, anti-Xi = 3) for cascade-cascade combination"}; // o2-linter: disable=name/configurable - Configurable confChargePart1{"ConfChargePart1", 1, "sign of particle 1"}; // o2-linter: disable=name/configurable - Configurable confHPtPart1{"ConfHPtPart1", 4.0f, "higher limit for pt of particle 1"}; // o2-linter: disable=name/configurable - Configurable confLPtPart1{"ConfLPtPart1", 0.5f, "lower limit for pt of particle 1"}; // o2-linter: disable=name/configurable - Configurable confHPtPart2{"ConfHPtPart2", 4.0f, "higher limit for pt of particle 2"}; // o2-linter: disable=name/configurable - Configurable confLPtPart2{"ConfLPtPart2", 0.3f, "lower limit for pt of particle 2"}; // o2-linter: disable=name/configurable - Configurable confmom{"Confmom", 0.75, "momentum threshold for particle identification using TOF"}; // o2-linter: disable=name/configurable - Configurable confNsigmaTPCParticle{"ConfNsigmaTPCParticle", 3.0, "TPC Sigma for particle momentum < Confmom"}; // o2-linter: disable=name/configurable - Configurable confNsigmaCombinedParticle{"ConfNsigmaCombinedParticle", 3.0, "TPC and TOF Sigma (combined) for particle momentum > Confmom"}; // o2-linter: disable=name/configurable - - ConfigurableAxis confkstarBins{"ConfkstarBins", {1500, 0., 6.}, "binning kstar"}; // o2-linter: disable=name/configurable - ConfigurableAxis confMultBins{"ConfMultBins", {VARIABLE_WIDTH, 0.0f, 20.0f, 40.0f, 60.0f, 80.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - multiplicity"}; // o2-linter: disable=name/configurable - ConfigurableAxis confkTBins{"ConfkTBins", {150, 0., 9.}, "binning kT"}; // o2-linter: disable=name/configurable - ConfigurableAxis confmTBins{"ConfmTBins", {225, 0., 7.5}, "binning mT"}; // o2-linter: disable=name/configurable - ConfigurableAxis confmultBins3D{"ConfMultBins3D", {VARIABLE_WIDTH, 0.0f, 20.0f, 30.0f, 40.0f, 99999.0f}, "multiplicity Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; // o2-linter: disable=name/configurable - ConfigurableAxis confmTBins3D{"ConfmTBins3D", {VARIABLE_WIDTH, 1.02f, 1.14f, 1.20f, 1.26f, 1.38f, 1.56f, 1.86f, 4.50f}, "mT Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; // o2-linter: disable=name/configurable - Configurable confEtaBins{"ConfEtaBins", 29, "Number of eta bins in deta dphi"}; // o2-linter: disable=name/configurable - Configurable confPhiBins{"ConfPhiBins", 29, "Number of phi bins in deta dphi"}; // o2-linter: disable=name/configurable - Configurable confIsMC{"ConfIsMC", false, "Enable additional Histograms in the case of a MonteCarlo Run"}; // o2-linter: disable=name/configurable - Configurable confUse3D{"ConfUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; // o2-linter: disable=name/configurable - Configurable confUseCent{"confUseCent", false, "Use centrality in place of multiplicity"}; - ConfigurableAxis confVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; // o2-linter: disable=name/configurable - ConfigurableAxis confTrkTempFitVarpTBins{"ConfTrkTempFitVarpTBins", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot"}; // o2-linter: disable=name/configurable - ConfigurableAxis confTrkTempFitVarBins{"ConfTrkDTempFitVarBins", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; // o2-linter: disable=name/configurable + /// Partition for particle 1 using extended table (track) + Partition partsOneFull = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::mAntiLambda == confChargePart1) && (nabs(aod::femtouniverseparticle::eta) < confEta) && (aod::femtouniverseparticle::pt < confHPtPart1) && (aod::femtouniverseparticle::pt > confLPtPart1); - /// Partition for particle 1 (track) - Partition partsOne = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == confChargePart1) && (aod::femtouniverseparticle::pt < confHPtPart1) && (aod::femtouniverseparticle::pt > confLPtPart1); + /// Partition for particle 1 without extended table (track) + Partition partsOneBasic = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::mAntiLambda == confChargePart1) && (nabs(aod::femtouniverseparticle::eta) < confEta) && (aod::femtouniverseparticle::pt < confHPtPart1) && (aod::femtouniverseparticle::pt > confLPtPart1); + Partition partsOneMCgenBasic = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (nabs(aod::femtouniverseparticle::eta) < confEta) && (aod::femtouniverseparticle::pt < confHPtPart1) && (aod::femtouniverseparticle::pt > confLPtPart1); + Partition partsOneMCrecoBasic = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::mAntiLambda == confChargePart1) && (nabs(aod::femtouniverseparticle::eta) < confEta) && (aod::femtouniverseparticle::pt < confHPtPart1) && (aod::femtouniverseparticle::pt > confLPtPart1); - /// Partition for particle 2 (cascade) - Partition partsTwo = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kCascade)) && (aod::femtouniverseparticle::pt < confHPtPart2) && (aod::femtouniverseparticle::pt > confLPtPart2); + /// Partition for particle 2 using extended table (cascade) + Partition partsTwoFull = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kCascade)) && (aod::femtouniverseparticle::pt < confHPtPart2) && (aod::femtouniverseparticle::pt > confLPtPart2); - /// Partition for cascades - Partition cascs = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kCascade)); + /// Partition for particle 2 without extended table (cascade) + Partition partsTwoBasic = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kCascade)) && (aod::femtouniverseparticle::pt < confHPtPart2) && (aod::femtouniverseparticle::pt > confLPtPart2); + Partition partsTwoMCgenBasic = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (aod::femtouniverseparticle::pt < confHPtPart2) && (aod::femtouniverseparticle::pt > confLPtPart2); + Partition partsTwoMCrecoBasic = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kCascade)) && (aod::femtouniverseparticle::pt < confHPtPart2) && (aod::femtouniverseparticle::pt > confLPtPart2); /// Histogramming for track particle FemtoUniverseParticleHisto trackHistoPartOnePos; @@ -112,38 +140,55 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st FemtoUniverseContainer sameEventCont; FemtoUniverseContainer mixedEventCont; FemtoUniversePairCleaner pairCleaner; + FemtoUniversePairCleaner pairCleanerCasc; + FemtoUniverseDetaDphiStar pairCloseRejection; HistogramRegistry rXiQA{"xi", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryMCgen{"MCgenHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry registryMCreco{"MCrecoHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + + std::set cascDuplicates; // Table to select cascade daughters // Charges: = +--, +--, +-+, +-+ static constexpr unsigned int CascChildTable[][3] = {{0, 1, 2}, {0, 1, 1}, {1, 0, 2}, {1, 0, 1}}; - bool invMCascade(float invMassCascade, float invMassAntiCascade) + bool invMCascade(float invMassXi, float invMassOmega, int cascType) { - if ((invMassCascade < confCascInvMassLowLimit || invMassCascade > confCascInvMassUpLimit) && (invMassAntiCascade < confCascInvMassLowLimit || invMassAntiCascade > confCascInvMassUpLimit)) { - return false; - } - return true; + return (((cascType == 1 || cascType == 3) && (invMassXi > confCascInvMassLowLimit && invMassXi < confCascInvMassUpLimit)) || ((cascType == 0 || cascType == 2) && (invMassOmega > confCascInvMassLowLimit && invMassOmega < confCascInvMassUpLimit))); } bool isNSigmaTPC(float nsigmaTPCParticle) { - if (std::abs(nsigmaTPCParticle) < confNsigmaTPCParticle) { + if (std::abs(nsigmaTPCParticle) < confNsigmaTPCParticleChild) { return true; } else { return false; } } + bool isNSigmaTOF(float mom, float nsigmaTOFParticle, float hasTOF) + { + // Cut only on daughter and bachelor tracks, that have TOF signal + if (mom > confmom && hasTOF == 1) { + if (std::abs(nsigmaTOFParticle) < confNsigmaTOFParticleChild) { + return true; + } else { + return false; + } + } else { + return true; + } + } + bool isNSigmaCombined(float mom, float nsigmaTPCParticle, float nsigmaTOFParticle) { if (mom <= confmom) { return (std::abs(nsigmaTPCParticle) < confNsigmaTPCParticle); } else { - return (TMath::Hypot(nsigmaTOFParticle, nsigmaTPCParticle) < confNsigmaCombinedParticle); // o2-linter: disable=root-entity + return (TMath::Hypot(nsigmaTOFParticle, nsigmaTPCParticle) < confNsigmaCombinedParticle); } } @@ -155,6 +200,14 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st return isNSigmaTPC(tpcNSigmas[id]); } + template + bool isParticleTOF(const T& part, int id) + { + const float tofNSigmas[3] = {unPackInTable(part.tofNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePi()), unPackInTable(part.tofNSigmaStoreKa())}; + + return isNSigmaTOF(part.p(), tofNSigmas[id], part.tempFitVar()); + } + template bool isParticleCombined(const T& part, int id) { @@ -166,6 +219,7 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st void init(InitContext const&) { + std::vector multBinning = {0.0, 5.0, 10.0, 20.0, 30.0f, 40.0, 50.0, 60.0f, 70.0, 80.0, 100.0, 200.0, 99999.0}; // Axes AxisSpec aXiMassAxis = {200, 1.28f, 1.36f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; AxisSpec ptAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; @@ -175,6 +229,7 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st AxisSpec aCPAAxis = {1000, 0.95f, 1.0f, "#it{cos #theta_{p}}"}; AxisSpec tranRadAxis = {1000, 0.0f, 100.0f, "#it{r}_{xy} (cm)"}; AxisSpec aDCAToPVAxis = {1000, -10.0f, 10.0f, "DCA to PV (cm)"}; + AxisSpec multAxis = {multBinning, "Multiplicity"}; // Histograms rXiQA.add("hMassXi", "hMassXi", {HistType::kTH1F, {aXiMassAxis}}); @@ -192,12 +247,41 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st rXiQA.add("hDcaNegtoPV", "hDcaNegtoPV", {HistType::kTH1F, {aDCAToPVAxis}}); rXiQA.add("hDcaBachtoPV", "hDcaBachtoPV", {HistType::kTH1F, {aDCAToPVAxis}}); rXiQA.add("hDcaV0toPV", "hDcaV0toPV", {HistType::kTH1F, {aDCAToPVAxis}}); + rXiQA.add("hInvMpT", "hInvMpT", kTH2F, {{ptAxis}, {aXiMassAxis}}); + rXiQA.add("hInvMpTmult", "hInvMpTmult", kTH3F, {{ptAxis}, {aXiMassAxis}, {multAxis}}); eventHisto.init(&qaRegistry); qaRegistry.add("Tracks_pos/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); qaRegistry.add("Tracks_pos/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); qaRegistry.add("Tracks_neg/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); qaRegistry.add("Tracks_neg/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("MixingQA/hMECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); + + // MC gen + registryMCgen.add("plus/MCgenCasc", "MC gen cascades;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCgen.add("minus/MCgenCasc", "MC gen cascades;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + + registryMCgen.add("plus/MCgenAllPt", "MC gen all;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); + registryMCgen.add("minus/MCgenAllPt", "MC gen all;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); + + registryMCgen.add("plus/MCgenPr", "MC gen protons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCgen.add("minus/MCgenPr", "MC gen protons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + + registryMCgen.add("plus/MCgenPrPt", "MC gen protons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + registryMCgen.add("minus/MCgenPrPt", "MC gen protons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + + // MC reco + registryMCreco.add("plus/MCrecoCascade", "MC reco Cascades;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCreco.add("minus/MCrecoCascade", "MC reco Cascades;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + + registryMCreco.add("plus/MCrecoAllPt", "MC reco all;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); + registryMCreco.add("minus/MCrecoAllPt", "MC reco all;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); + + registryMCreco.add("plus/MCrecoPr", "MC reco protons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCreco.add("minus/MCrecoPr", "MC reco protons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + + registryMCreco.add("plus/MCrecoPrPt", "MC reco protons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + registryMCreco.add("minus/MCrecoPrPt", "MC reco protons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); trackHistoPartOnePos.init(&qaRegistry, confTrkTempFitVarpTBins, confTrkTempFitVarBins, confIsMC, confTrkPDGCodePartOne); trackHistoPartOneNeg.init(&qaRegistry, confTrkTempFitVarpTBins, confTrkTempFitVarBins, confIsMC, confTrkPDGCodePartOne); @@ -206,25 +290,30 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st bachHistos.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "hBachelor"); cascQAHistos.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true); - sameEventCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confmultBins3D, confmTBins3D, confEtaBins, confPhiBins, confIsMC, confUse3D); - mixedEventCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confmultBins3D, confmTBins3D, confEtaBins, confPhiBins, confIsMC, confUse3D); + sameEventCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confMultBins3D, confmTBins3D, confEtaBins, confPhiBins, confIsMC, confUse3D); + mixedEventCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confMultBins3D, confmTBins3D, confEtaBins, confPhiBins, confIsMC, confUse3D); pairCleaner.init(&qaRegistry); + pairCleanerCasc.init(&qaRegistry); + if (confIsCPR.value) { + pairCloseRejection.init(&resultRegistry, &qaRegistry, confCPRdeltaPhiCutMin.value, confCPRdeltaPhiCutMax.value, confCPRdeltaEtaCutMin.value, confCPRdeltaEtaCutMax.value, confCPRChosenRadii.value, confCPRPlotPerRadii.value, 0, 0, confIsSameSignCPR.value); + } } - void processCascades(const FilteredFDCollision& col, const FemtoFullParticles& parts) + void processCascades([[maybe_unused]] const FilteredFDCollision& col, const FemtoFullParticles& parts, const aod::FDCascParticles& fdcascs) { - auto groupCascs = cascs->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - // const int multCol = col.multNtr(); + // auto groupCascs = cascs->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + // const int multCol = col.multNtr(); - for (const auto& casc : groupCascs) { - rXiQA.fill(HIST("hMassXi"), casc.mLambda()); + for (const auto& casc : fdcascs) { + const auto& part = casc.fdParticle_as(); + rXiQA.fill(HIST("hMassXi"), part.mLambda()); // if (!invMCascade(casc.mLambda(), casc.mAntiLambda())) // continue; - const auto& posChild = parts.iteratorAt(casc.index() - 3); - const auto& negChild = parts.iteratorAt(casc.index() - 2); - const auto& bachelor = parts.iteratorAt(casc.index() - 1); + const auto& posChild = parts.iteratorAt(part.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild = parts.iteratorAt(part.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor = parts.iteratorAt(part.globalIndex() - 1 - parts.begin().globalIndex()); // if (casc.transRadius() < confCascTranRad) // continue; @@ -232,7 +321,8 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st // std::cout<<"TYPE:"< confNSigmaTPCProton) { continue; } @@ -251,10 +341,10 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st continue; } - rXiQA.fill(HIST("hPtXi"), casc.pt()); - rXiQA.fill(HIST("hEtaXi"), casc.eta()); - rXiQA.fill(HIST("hPhiXi"), casc.phi()); - rXiQA.fill(HIST("hMassXiSelected"), casc.mLambda()); + rXiQA.fill(HIST("hPtXi"), part.pt()); + rXiQA.fill(HIST("hEtaXi"), part.eta()); + rXiQA.fill(HIST("hPhiXi"), part.phi()); + rXiQA.fill(HIST("hMassXiSelected"), part.mLambda()); rXiQA.fill(HIST("hDCAV0Daughters"), casc.dcaV0daughters()); rXiQA.fill(HIST("hV0CosPA"), casc.cpav0()); rXiQA.fill(HIST("hV0TranRad"), casc.v0radius()); @@ -265,6 +355,7 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st rXiQA.fill(HIST("hDcaNegtoPV"), casc.dcanegtopv()); rXiQA.fill(HIST("hDcaBachtoPV"), casc.dcabachtopv()); rXiQA.fill(HIST("hDcaV0toPV"), casc.dcav0topv()); + rXiQA.fill(HIST("hInvMpT"), part.pt(), part.mLambda()); posChildHistos.fillQA(posChild); negChildHistos.fillQA(negChild); @@ -272,9 +363,15 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st } } PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processCascades, "Enable processing cascades", false); - /// track - cascade - void processSameEvent(const FilteredFDCollision& col, const FemtoFullParticles& parts) + + template + using hasSigma = decltype(std::declval().tpcNSigmaStorePr()); + + /// track - cascade correlations + template + void doSameEvent(const FilteredFDCollision& col, const TableType& parts, PartitionType& partsOne, PartitionType& partsTwo) { + auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); @@ -283,67 +380,116 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st const int multCol = confUseCent ? col.multV0M() : col.multNtr(); for (const auto& part : groupPartsTwo) { - if (!invMCascade(part.mLambda(), part.mAntiLambda())) + if (!invMCascade(part.mLambda(), part.mAntiLambda(), confCascType1)) /// mLambda stores Xi mass, mAntiLambda stores Omega mass continue; - cascQAHistos.fillQA(part); + if constexpr (std::experimental::is_detected::value) + cascQAHistos.fillQA(part); + else + cascQAHistos.fillQA(part); - const auto& posChild = parts.iteratorAt(part.index() - 3); - const auto& negChild = parts.iteratorAt(part.index() - 2); - const auto& bachelor = parts.iteratorAt(part.index() - 1); + const auto& posChild = parts.iteratorAt(part.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild = parts.iteratorAt(part.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor = parts.iteratorAt(part.globalIndex() - 1 - parts.begin().globalIndex()); /// Child particles must pass this condition to be selected - if (!isParticleTPC(posChild, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor, CascChildTable[confCascType1][2])) - continue; + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor, CascChildTable[confCascType1][2])) + continue; - posChildHistos.fillQA(posChild); - negChildHistos.fillQA(negChild); - bachHistos.fillQABase(bachelor, HIST("hBachelor")); - } + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild, CascChildTable[confCascType1][0]) || !isParticleTOF(negChild, CascChildTable[confCascType1][1]))) || !isParticleTOF(bachelor, CascChildTable[confCascType1][2])) + continue; - for (const auto& part : groupPartsOne) { - /// PID plot for track particle - const float tpcNSigmas[3] = {unPackInTable(part.tpcNSigmaStorePr()), unPackInTable(part.tpcNSigmaStorePi()), unPackInTable(part.tpcNSigmaStoreKa())}; - const float tofNSigmas[3] = {unPackInTable(part.tofNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePi()), unPackInTable(part.tofNSigmaStoreKa())}; + posChildHistos.fillQA(posChild); + negChildHistos.fillQA(negChild); + bachHistos.fillQABase(bachelor, HIST("hBachelor")); + } else { + if ((posChild.pidCut() & (1u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (1u << CascChildTable[confCascType1][1])) == 0 || (bachelor.pidCut() & (1u << CascChildTable[confCascType1][2])) == 0) + continue; - if (!isNSigmaCombined(part.p(), tpcNSigmas[confTrackChoicePartOne], tofNSigmas[confTrackChoicePartOne])) - continue; + if ((!confCheckTOFBachelorOnly && ((posChild.pidCut() & (8u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (8u << CascChildTable[confCascType1][1])) == 0)) || (bachelor.pidCut() & (8u << CascChildTable[confCascType1][2])) == 0) + continue; - if (part.sign() > 0) { - qaRegistry.fill(HIST("Tracks_pos/nSigmaTPC"), part.p(), tpcNSigmas[confTrackChoicePartOne]); - qaRegistry.fill(HIST("Tracks_pos/nSigmaTOF"), part.p(), tofNSigmas[confTrackChoicePartOne]); - trackHistoPartOnePos.fillQA(part); - } else if (part.sign() < 0) { - qaRegistry.fill(HIST("Tracks_neg/nSigmaTPC"), part.p(), tpcNSigmas[confTrackChoicePartOne]); - qaRegistry.fill(HIST("Tracks_neg/nSigmaTOF"), part.p(), tofNSigmas[confTrackChoicePartOne]); - trackHistoPartOneNeg.fillQA(part); + posChildHistos.fillQA(posChild); + negChildHistos.fillQA(negChild); + bachHistos.fillQABase(bachelor, HIST("hBachelor")); } + rXiQA.fill(HIST("hInvMpTmult"), part.pt(), part.mLambda(), multCol); } + if constexpr (std::experimental::is_detected::value) { + for (const auto& part : groupPartsOne) { + /// PID plot for track particle + const float tpcNSigmas[3] = {unPackInTable(part.tpcNSigmaStorePr()), unPackInTable(part.tpcNSigmaStorePi()), unPackInTable(part.tpcNSigmaStoreKa())}; + const float tofNSigmas[3] = {unPackInTable(part.tofNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePi()), unPackInTable(part.tofNSigmaStoreKa())}; + + if (!isNSigmaCombined(part.p(), tpcNSigmas[confTrackChoicePartOne], tofNSigmas[confTrackChoicePartOne])) + continue; + + if (part.mAntiLambda() > 0) { + qaRegistry.fill(HIST("Tracks_pos/nSigmaTPC"), part.p(), tpcNSigmas[confTrackChoicePartOne]); + qaRegistry.fill(HIST("Tracks_pos/nSigmaTOF"), part.p(), tofNSigmas[confTrackChoicePartOne]); + trackHistoPartOnePos.fillQA(part); + } else if (part.mAntiLambda() < 0) { + qaRegistry.fill(HIST("Tracks_neg/nSigmaTPC"), part.p(), tpcNSigmas[confTrackChoicePartOne]); + qaRegistry.fill(HIST("Tracks_neg/nSigmaTOF"), part.p(), tofNSigmas[confTrackChoicePartOne]); + trackHistoPartOneNeg.fillQA(part); + } + } + } for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { - // Cascade invariant mass cut - if (!invMCascade(p2.mLambda(), p2.mAntiLambda())) + // Cascade inv mass cut (mLambda stores Xi mass, mAntiLambda stores Omega mass) + if (!invMCascade(p2.mLambda(), p2.mAntiLambda(), confCascType1)) continue; // PID - if (!isParticleCombined(p1, confTrackChoicePartOne)) - continue; + if constexpr (std::experimental::is_detected::value) { + if (!isParticleCombined(p1, confTrackChoicePartOne)) + continue; + } else { + if ((p1.pidCut() & (64u << confTrackChoicePartOne)) == 0) + continue; + } // track cleaning if (!pairCleaner.isCleanPair(p1, p2, parts)) { continue; } - const auto& posChild = parts.iteratorAt(p2.index() - 3); - const auto& negChild = parts.iteratorAt(p2.index() - 2); - const auto& bachelor = parts.iteratorAt(p2.index() - 1); - /// Child particles must pass this condition to be selected - if (!isParticleTPC(posChild, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor, CascChildTable[confCascType1][2])) - continue; + const auto& posChild = parts.iteratorAt(p2.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild = parts.iteratorAt(p2.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor = parts.iteratorAt(p2.globalIndex() - 1 - parts.begin().globalIndex()); + /// Child particles must pass this condition to be selected + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor, CascChildTable[confCascType1][2])) + continue; + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild, CascChildTable[confCascType1][0]) || !isParticleTOF(negChild, CascChildTable[confCascType1][1]))) || !isParticleTOF(bachelor, CascChildTable[confCascType1][2])) + continue; + } else { + if ((posChild.pidCut() & (1u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (1u << CascChildTable[confCascType1][1])) == 0 || (bachelor.pidCut() & (1u << CascChildTable[confCascType1][2])) == 0) + continue; + if ((!confCheckTOFBachelorOnly && ((posChild.pidCut() & (8u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (8u << CascChildTable[confCascType1][1])) == 0)) || (bachelor.pidCut() & (8u << CascChildTable[confCascType1][2])) == 0) + continue; + } sameEventCont.setPair(p1, p2, multCol, confUse3D, 1.0f); } } + + void processSameEvent(const FilteredFDCollision& col, const FemtoFullParticles& parts) + { + doSameEvent(col, parts, partsOneFull, partsTwoFull); + } PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processSameEvent, "Enable processing same event for track - cascade", false); - /// cascade - cascade - void processSameEventCasc(const FilteredFDCollision& col, const FemtoFullParticles& parts) + + void processSameEventBitmask(const FilteredFDCollision& col, const aod::FDParticles& parts) + { + doSameEvent(col, parts, partsOneBasic, partsTwoBasic); + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processSameEventBitmask, "Enable processing same event for track - cascade using bitmask for PID", false); + + /// cascade - cascade correlations + template + void doSameEventCasc(const FilteredFDCollision& col, const TableType& parts, PartitionType& partsTwo) { + const auto& magFieldTesla = col.magField(); + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); eventHisto.fillQA(col); @@ -351,71 +497,141 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st const int multCol = confUseCent ? col.multV0M() : col.multNtr(); for (const auto& part : groupPartsTwo) { - if (!invMCascade(part.mLambda(), part.mAntiLambda())) + if (!invMCascade(part.mLambda(), part.mAntiLambda(), confCascType1)) /// mLambda stores Xi mass, mAntiLambda stores Omega mass continue; - cascQAHistos.fillQA(part); + if constexpr (std::experimental::is_detected::value) + cascQAHistos.fillQA(part); + else + cascQAHistos.fillQA(part); - const auto& posChild = parts.iteratorAt(part.index() - 3); - const auto& negChild = parts.iteratorAt(part.index() - 2); - const auto& bachelor = parts.iteratorAt(part.index() - 1); + const auto& posChild = parts.iteratorAt(part.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild = parts.iteratorAt(part.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor = parts.iteratorAt(part.globalIndex() - 1 - parts.begin().globalIndex()); /// Check daughters of first cascade - if (isParticleTPC(posChild, CascChildTable[confCascType1][0]) && isParticleTPC(negChild, CascChildTable[confCascType1][1]) && isParticleTPC(bachelor, CascChildTable[confCascType1][2])) { + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor, CascChildTable[confCascType1][2])) + continue; + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild, CascChildTable[confCascType1][0]) || !isParticleTOF(negChild, CascChildTable[confCascType1][1]))) || !isParticleTOF(bachelor, CascChildTable[confCascType1][2])) + continue; posChildHistos.fillQA(posChild); negChildHistos.fillQA(negChild); bachHistos.fillQABase(bachelor, HIST("hBachelor")); + } else { + if ((posChild.pidCut() & (1u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (1u << CascChildTable[confCascType1][1])) == 0 || (bachelor.pidCut() & (1u << CascChildTable[confCascType1][2])) == 0) + continue; + if ((!confCheckTOFBachelorOnly && ((posChild.pidCut() & (8u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (8u << CascChildTable[confCascType1][1])) == 0)) || (bachelor.pidCut() & (8u << CascChildTable[confCascType1][2])) == 0) + continue; + + posChildHistos.fillQA(posChild); + negChildHistos.fillQA(negChild); + bachHistos.fillQABase(bachelor, HIST("hBachelor")); } - /// Check daughters of second cascade - /*if (isParticleTPC(posChild, CascChildTable[confCascType2][0]) && isParticleTPC(negChild, CascChildTable[confCascType2][1]) && isParticleTPC(bachelor, CascChildTable[confCascType2][2])) { - }*/ } + auto pairDuplicateCheckFunc = [&](auto& p1, auto& p2) -> void { + // Cascade inv mass cut for p1 (mLambda stores Xi mass, mAntiLambda stores Omega mass) + if (!invMCascade(p1.mLambda(), p1.mAntiLambda(), confCascType1)) + return; + // Cascade inv mass cut for p2 + if (!invMCascade(p2.mLambda(), p2.mAntiLambda(), confCascType2)) + return; + // track cleaning & checking for duplicate pairs + if (!pairCleanerCasc.isCleanPair(p1, p2, parts)) { + // mark for rejection the cascades that share a daughter with other cascades + cascDuplicates.insert(p1.globalIndex()); + cascDuplicates.insert(p2.globalIndex()); + } + }; + auto pairProcessFunc = [&](auto& p1, auto& p2) -> void { - // Cascade invariant mass cut for p1 - if (!invMCascade(p1.mLambda(), p1.mAntiLambda())) + if (cascDuplicates.contains(p1.globalIndex()) || cascDuplicates.contains(p2.globalIndex())) return; - // Cascade invariant mass cut for p2 - if (!invMCascade(p2.mLambda(), p2.mAntiLambda())) + if (!invMCascade(p1.mLambda(), p1.mAntiLambda(), confCascType1)) return; - // track cleaning - if (!pairCleaner.isCleanPair(p1, p2, parts)) { + if (!invMCascade(p2.mLambda(), p2.mAntiLambda(), confCascType2)) return; + if (confIsCPR.value) { + if (pairCloseRejection.isClosePair(p1, p2, parts, magFieldTesla, femto_universe_container::EventType::same)) { + return; + } } - const auto& posChild1 = parts.iteratorAt(p1.index() - 3); - const auto& negChild1 = parts.iteratorAt(p1.index() - 2); - const auto& bachelor1 = parts.iteratorAt(p1.index() - 1); + + const auto& posChild1 = parts.iteratorAt(p1.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild1 = parts.iteratorAt(p1.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor1 = parts.iteratorAt(p1.globalIndex() - 1 - parts.begin().globalIndex()); /// Child particles must pass this condition to be selected - if (!isParticleTPC(posChild1, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild1, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor1, CascChildTable[confCascType1][2])) - return; - const auto& posChild2 = parts.iteratorAt(p2.index() - 3); - const auto& negChild2 = parts.iteratorAt(p2.index() - 2); - const auto& bachelor2 = parts.iteratorAt(p2.index() - 1); + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild1, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild1, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor1, CascChildTable[confCascType1][2])) + return; + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild1, CascChildTable[confCascType1][0]) || !isParticleTOF(negChild1, CascChildTable[confCascType1][1]))) || !isParticleTOF(bachelor1, CascChildTable[confCascType1][2])) + return; + } else { + if ((posChild1.pidCut() & (1u << CascChildTable[confCascType1][0])) == 0 || (negChild1.pidCut() & (1u << CascChildTable[confCascType1][1])) == 0 || (bachelor1.pidCut() & (1u << CascChildTable[confCascType1][2])) == 0) + return; + if ((!confCheckTOFBachelorOnly && ((posChild1.pidCut() & (8u << CascChildTable[confCascType1][0])) == 0 || (negChild1.pidCut() & (8u << CascChildTable[confCascType1][1])) == 0)) || (bachelor1.pidCut() & (8u << CascChildTable[confCascType1][2])) == 0) + return; + } + + const auto& posChild2 = parts.iteratorAt(p2.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild2 = parts.iteratorAt(p2.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor2 = parts.iteratorAt(p2.globalIndex() - 1 - parts.begin().globalIndex()); /// Child particles must pass this condition to be selected - if (!isParticleTPC(posChild2, CascChildTable[confCascType2][0]) || !isParticleTPC(negChild2, CascChildTable[confCascType2][1]) || !isParticleTPC(bachelor2, CascChildTable[confCascType2][2])) - return; + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild2, CascChildTable[confCascType2][0]) || !isParticleTPC(negChild2, CascChildTable[confCascType2][1]) || !isParticleTPC(bachelor2, CascChildTable[confCascType2][2])) + return; + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild2, CascChildTable[confCascType2][0]) || !isParticleTOF(negChild2, CascChildTable[confCascType2][1]))) || !isParticleTOF(bachelor2, CascChildTable[confCascType2][2])) + return; + } else { + if ((posChild2.pidCut() & (1u << CascChildTable[confCascType1][0])) == 0 || (negChild2.pidCut() & (1u << CascChildTable[confCascType1][1])) == 0 || (bachelor2.pidCut() & (1u << CascChildTable[confCascType1][2])) == 0) + return; + if ((!confCheckTOFBachelorOnly && ((posChild2.pidCut() & (8u << CascChildTable[confCascType1][0])) == 0 || (negChild2.pidCut() & (8u << CascChildTable[confCascType1][1])) == 0)) || (bachelor2.pidCut() & (8u << CascChildTable[confCascType1][2])) == 0) + return; + } sameEventCont.setPair(p1, p2, multCol, confUse3D, 1.0f); }; + cascDuplicates.clear(); if (confCascType1 == confCascType2) { + for (const auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsTwo, groupPartsTwo))) { + pairDuplicateCheckFunc(p1, p2); + } /// Now build the combinations for identical cascades for (const auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsTwo, groupPartsTwo))) { pairProcessFunc(p1, p2); } } else { + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsTwo, groupPartsTwo))) { + pairDuplicateCheckFunc(p1, p2); + } /// Now build the combinations for non-identical cascades for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsTwo, groupPartsTwo))) { pairProcessFunc(p1, p2); } } } + + void processSameEventCasc(const FilteredFDCollision& col, const FemtoFullParticles& parts) + { + doSameEventCasc(col, parts, partsTwoFull); + } PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processSameEventCasc, "Enable processing same event for cascade - cascade", false); - /// track - cascade - void processMixedEvent(const FilteredFDCollisions& cols, const FemtoFullParticles& parts) + + void processSameEventCascBitmask(const FilteredFDCollision& col, const aod::FDParticles& parts) { - ColumnBinningPolicy colBinning{{confVtxBins, confMultBins}, true}; + doSameEventCasc(col, parts, partsTwoBasic); + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processSameEventCascBitmask, "Enable processing same event for cascade - cascade using bitmask for PID", false); - for (const auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + /// track - cascade correlations + template + void doMixedEvent(const FilteredFDCollisions& cols, const TableType& parts, PartitionType& partsOne, PartitionType& partsTwo) + { + ColumnBinningPolicy colBinningMult{{confVtxBins, confMultBins}, true}; + ColumnBinningPolicy colBinningCent{{confVtxBins, confMultBins}, true}; + + auto mixedCollProcessFunc = [&](auto& collision1, auto& collision2) -> void { const int multCol = confUseCent ? collision1.multV0M() : collision1.multNtr(); auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); @@ -425,22 +641,37 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st const auto& magFieldTesla2 = collision2.magField(); if (magFieldTesla1 != magFieldTesla2) { - continue; + return; } for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { - // Cascade invariant mass cut - if (!invMCascade(p2.mLambda(), p2.mAntiLambda())) + // Cascade inv mass cut (mLambda stores Xi mass, mAntiLambda stores Omega mass) + if (!invMCascade(p2.mLambda(), p2.mAntiLambda(), confCascType1)) continue; // PID - if (!isParticleCombined(p1, confTrackChoicePartOne)) - continue; + if constexpr (std::experimental::is_detected::value) { + if (!isParticleCombined(p1, confTrackChoicePartOne)) + continue; + } else { + if ((p1.pidCut() & (64u << confTrackChoicePartOne)) == 0) + continue; + } - const auto& posChild = parts.iteratorAt(p2.index() - 3); - const auto& negChild = parts.iteratorAt(p2.index() - 2); - const auto& bachelor = parts.iteratorAt(p2.index() - 1); + const auto& posChild = parts.iteratorAt(p2.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild = parts.iteratorAt(p2.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor = parts.iteratorAt(p2.globalIndex() - 1 - parts.begin().globalIndex()); /// Child particles must pass this condition to be selected - if (!isParticleTPC(posChild, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor, CascChildTable[confCascType1][2])) - continue; + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor, CascChildTable[confCascType1][2])) + continue; + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild, CascChildTable[confCascType1][0]) || !isParticleTOF(negChild, CascChildTable[confCascType1][1]))) || !isParticleTOF(bachelor, CascChildTable[confCascType1][2])) + continue; + } else { + if ((posChild.pidCut() & (1u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (1u << CascChildTable[confCascType1][1])) == 0 || (bachelor.pidCut() & (1u << CascChildTable[confCascType1][2])) == 0) + continue; + if ((!confCheckTOFBachelorOnly && ((posChild.pidCut() & (8u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (8u << CascChildTable[confCascType1][1])) == 0)) || (bachelor.pidCut() & (8u << CascChildTable[confCascType1][2])) == 0) + continue; + } + // track cleaning if (!pairCleaner.isCleanPair(p1, p2, parts)) { continue; @@ -448,15 +679,41 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st mixedEventCont.setPair(p1, p2, multCol, confUse3D, 1.0f); } + }; + + if (confUseCent) { + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, confNEventsMix, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); + } + } else { + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, confNEventsMix, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); + } } } + + void processMixedEvent(const FilteredFDCollisions& cols, const FemtoFullParticles& parts) + { + doMixedEvent(cols, parts, partsOneFull, partsTwoFull); + } PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMixedEvent, "Enable processing mixed event for track - cascade", false); - /// cascade - cascade - void processMixedEventCasc(const FilteredFDCollisions& cols, const FemtoFullParticles& parts) + + void processMixedEventBitmask(const FilteredFDCollisions& cols, const aod::FDParticles& parts) + { + doMixedEvent(cols, parts, partsOneBasic, partsTwoBasic); + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMixedEventBitmask, "Enable processing mixed event for track - cascade using bitmask for PID", false); + + /// cascade - cascade correlations + template + void doMixedEventCasc(const FilteredFDCollisions& cols, const TableType& parts, PartitionType& partsTwo) { ColumnBinningPolicy colBinning{{confVtxBins, confMultBins}, true}; for (const auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + const int multCol = confUseCent ? collision1.multV0M() : collision1.multNtr(); auto groupPartsOne = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); @@ -468,35 +725,342 @@ struct femtoUniversePairTaskTrackCascadeExtended { // o2-linter: disable=name/st continue; } for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { - // Cascade invariant mass cut for p1 - if (!invMCascade(p1.mLambda(), p1.mAntiLambda())) + // Cascade inv mass cut for p1 (mLambda stores Xi mass, mAntiLambda stores Omega mass) + if (!invMCascade(p1.mLambda(), p1.mAntiLambda(), confCascType1)) continue; - // Cascade invariant mass cut for p2 - if (!invMCascade(p2.mLambda(), p2.mAntiLambda())) + // Cascade inv mass cut for p2 + if (!invMCascade(p2.mLambda(), p2.mAntiLambda(), confCascType2)) continue; - const auto& posChild1 = parts.iteratorAt(p1.index() - 3); - const auto& negChild1 = parts.iteratorAt(p1.index() - 2); - const auto& bachelor1 = parts.iteratorAt(p1.index() - 1); + const auto& posChild1 = parts.iteratorAt(p1.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild1 = parts.iteratorAt(p1.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor1 = parts.iteratorAt(p1.globalIndex() - 1 - parts.begin().globalIndex()); /// Child particles must pass this condition to be selected - if (!isParticleTPC(posChild1, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild1, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor1, CascChildTable[confCascType1][2])) - return; - const auto& posChild2 = parts.iteratorAt(p2.index() - 3); - const auto& negChild2 = parts.iteratorAt(p2.index() - 2); - const auto& bachelor2 = parts.iteratorAt(p2.index() - 1); + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild1, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild1, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor1, CascChildTable[confCascType1][2])) + return; + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild1, CascChildTable[confCascType1][0]) || !isParticleTOF(negChild1, CascChildTable[confCascType1][1]))) || !isParticleTOF(bachelor1, CascChildTable[confCascType1][2])) + return; + } else { + if ((posChild1.pidCut() & (1u << CascChildTable[confCascType1][0])) == 0 || (negChild1.pidCut() & (1u << CascChildTable[confCascType1][1])) == 0 || (bachelor1.pidCut() & (1u << CascChildTable[confCascType1][2])) == 0) + return; + if ((!confCheckTOFBachelorOnly && ((posChild1.pidCut() & (8u << CascChildTable[confCascType1][0])) == 0 || (negChild1.pidCut() & (8u << CascChildTable[confCascType1][1])) == 0)) || (bachelor1.pidCut() & (8u << CascChildTable[confCascType1][2])) == 0) + return; + } + + const auto& posChild2 = parts.iteratorAt(p2.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild2 = parts.iteratorAt(p2.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor2 = parts.iteratorAt(p2.globalIndex() - 1 - parts.begin().globalIndex()); /// Child particles must pass this condition to be selected - if (!isParticleTPC(posChild2, CascChildTable[confCascType2][0]) || !isParticleTPC(negChild2, CascChildTable[confCascType2][1]) || !isParticleTPC(bachelor2, CascChildTable[confCascType2][2])) - return; + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild2, CascChildTable[confCascType2][0]) || !isParticleTPC(negChild2, CascChildTable[confCascType2][1]) || !isParticleTPC(bachelor2, CascChildTable[confCascType2][2])) + return; + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild2, CascChildTable[confCascType2][0]) || !isParticleTOF(negChild2, CascChildTable[confCascType2][1]))) || !isParticleTOF(bachelor2, CascChildTable[confCascType2][2])) + return; + } else { + if ((posChild2.pidCut() & (1u << CascChildTable[confCascType1][0])) == 0 || (negChild2.pidCut() & (1u << CascChildTable[confCascType1][1])) == 0 || (bachelor2.pidCut() & (1u << CascChildTable[confCascType1][2])) == 0) + return; + if ((!confCheckTOFBachelorOnly && ((posChild2.pidCut() & (8u << CascChildTable[confCascType1][0])) == 0 || (negChild2.pidCut() & (8u << CascChildTable[confCascType1][1])) == 0)) || (bachelor2.pidCut() & (8u << CascChildTable[confCascType1][2])) == 0) + return; + } // track cleaning - if (!pairCleaner.isCleanPair(p1, p2, parts)) { + if (!pairCleanerCasc.isCleanPair(p1, p2, parts)) { continue; } + if (confIsCPR.value) { + if (pairCloseRejection.isClosePair(p1, p2, parts, magFieldTesla1, femto_universe_container::EventType::mixed)) { + continue; + } + } - mixedEventCont.setPair(p1, p2, collision1.multNtr(), confUse3D, 1.0f); + mixedEventCont.setPair(p1, p2, multCol, confUse3D, 1.0f); } } } + + void processMixedEventCasc(const FilteredFDCollisions& cols, const FemtoFullParticles& parts) + { + doMixedEventCasc(cols, parts, partsTwoFull); + } PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMixedEventCasc, "Enable processing mixed event for cascade - cascade", false); + + void processMixedEventCascBitmask(const FilteredFDCollisions& cols, const aod::FDParticles& parts) + { + doMixedEventCasc(cols, parts, partsTwoBasic); + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMixedEventCascBitmask, "Enable processing mixed event for cascade - cascade using bitmask for PID", false); + + // MC truth for track - cascade + void processSameEventMCgen(const FilteredFDCollision& col, [[maybe_unused]] const aod::FDParticles& parts) + { + const int multCol = confUseCent ? col.multV0M() : col.multNtr(); + + auto groupPartsOne = partsOneMCgenBasic->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsTwo = partsTwoMCgenBasic->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + + eventHisto.fillQA(col); + + for (const auto& part : groupPartsTwo) { + int pdgCode = static_cast(part.pidCut()); + if ((confCascType1 == 0 && pdgCode != kOmegaMinus) || (confCascType1 == 2 && pdgCode != kOmegaPlusBar) || (confCascType1 == 1 && pdgCode != kXiMinus) || (confCascType1 == 3 && pdgCode != kXiPlusBar)) + continue; + + cascQAHistos.fillQA(part); + + for (const auto& part : groupPartsOne) { + int pdgCode = static_cast(part.pidCut()); + if (pdgCode != confTrkPDGCodePartOne) + continue; + const auto& pdgTrackParticle = pdgMC->GetParticle(pdgCode); + if (!pdgTrackParticle) { + continue; + } + + if (pdgTrackParticle->Charge() > 0) { + trackHistoPartOnePos.fillQA(part); + } else if (pdgTrackParticle->Charge() < 0) { + trackHistoPartOneNeg.fillQA(part); + } + } + + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + if (static_cast(p1.pidCut()) != confTrkPDGCodePartOne) + continue; + int pdgCodeCasc = static_cast(p2.pidCut()); + if ((confCascType1 == 0 && pdgCodeCasc != kOmegaMinus) || (confCascType1 == 2 && pdgCodeCasc != kOmegaPlusBar) || (confCascType1 == 1 && pdgCodeCasc != kXiMinus) || (confCascType1 == 3 && pdgCodeCasc != kXiPlusBar)) + continue; + sameEventCont.setPair(p1, p2, multCol, confUse3D, 1.0f); + } + } + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processSameEventMCgen, "Enable processing same event MC truth for track - cascade", false); + + // MC truth for cascade - cascade + void processSameEventCascMCgen(const FilteredFDCollision& col, [[maybe_unused]] const aod::FDParticles& parts) + { + const int multCol = confUseCent ? col.multV0M() : col.multNtr(); + + auto groupPartsTwo = partsTwoMCgenBasic->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + + eventHisto.fillQA(col); + + for (const auto& part : groupPartsTwo) { + int pdgCode = static_cast(part.pidCut()); + if ((confCascType1 == 0 && pdgCode != kOmegaMinus) || (confCascType1 == 2 && pdgCode != kOmegaPlusBar) || (confCascType1 == 1 && pdgCode != kXiMinus) || (confCascType1 == 3 && pdgCode != kXiPlusBar)) + continue; + + cascQAHistos.fillQA(part); + + auto pairProcessFunc = [&](auto& p1, auto& p2) -> void { + int pdgCodeCasc1 = static_cast(p1.pidCut()); + if ((confCascType1 == 0 && pdgCodeCasc1 != kOmegaMinus) || (confCascType1 == 2 && pdgCodeCasc1 != kOmegaPlusBar) || (confCascType1 == 1 && pdgCodeCasc1 != kXiMinus) || (confCascType1 == 3 && pdgCodeCasc1 != kXiPlusBar)) + return; + int pdgCodeCasc2 = static_cast(p2.pidCut()); + if ((confCascType2 == 0 && pdgCodeCasc2 != kOmegaMinus) || (confCascType2 == 2 && pdgCodeCasc2 != kOmegaPlusBar) || (confCascType2 == 1 && pdgCodeCasc2 != kXiMinus) || (confCascType2 == 3 && pdgCodeCasc2 != kXiPlusBar)) + return; + sameEventCont.setPair(p1, p2, multCol, confUse3D, 1.0f); + }; + + if (confCascType1 == confCascType2) { + for (const auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsTwo, groupPartsTwo))) + pairProcessFunc(p1, p2); + } else { + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsTwo, groupPartsTwo))) + pairProcessFunc(p1, p2); + } + } + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processSameEventCascMCgen, "Enable processing same event MC truth for cascade - cascade", false); + + // MC truth for track - cascade + void processMixedEventMCgen(const FilteredFDCollisions& cols, [[maybe_unused]] const aod::FDParticles& parts) + { + ColumnBinningPolicy colBinning{{confVtxBins, confMultBins}, true}; + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + const int multCol = confUseCent ? collision1.multV0M() : collision1.multNtr(); + + auto groupPartsOne = partsOneMCgenBasic->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMCgenBasic->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + continue; + } + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + if (static_cast(p1.pidCut()) != confTrkPDGCodePartOne) + continue; + int pdgCodeCasc = static_cast(p2.pidCut()); + if ((confCascType1 == 0 && pdgCodeCasc != kOmegaMinus) || (confCascType1 == 2 && pdgCodeCasc != kOmegaPlusBar) || (confCascType1 == 1 && pdgCodeCasc != kXiMinus) || (confCascType1 == 3 && pdgCodeCasc != kXiPlusBar)) + continue; + mixedEventCont.setPair(p1, p2, multCol, confUse3D, 1.0f); + } + } + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMixedEventMCgen, "Enable processing mixed event MC truth for track - cascade", false); + + // MC truth for cascade - cascade + void processMixedEventCascMCgen(const FilteredFDCollisions& cols, [[maybe_unused]] const aod::FDParticles& parts) + { + ColumnBinningPolicy colBinning{{confVtxBins, confMultBins}, true}; + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + const int multCol = confUseCent ? collision1.multV0M() : collision1.multNtr(); + + auto groupPartsOne = partsTwoMCgenBasic->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMCgenBasic->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + continue; + } + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + int pdgCodeCasc1 = static_cast(p1.pidCut()); + if ((confCascType1 == 0 && pdgCodeCasc1 != kOmegaMinus) || (confCascType1 == 2 && pdgCodeCasc1 != kOmegaPlusBar) || (confCascType1 == 1 && pdgCodeCasc1 != kXiMinus) || (confCascType1 == 3 && pdgCodeCasc1 != kXiPlusBar)) + continue; + int pdgCodeCasc2 = static_cast(p2.pidCut()); + if ((confCascType2 == 0 && pdgCodeCasc2 != kOmegaMinus) || (confCascType2 == 2 && pdgCodeCasc2 != kOmegaPlusBar) || (confCascType2 == 1 && pdgCodeCasc2 != kXiMinus) || (confCascType2 == 3 && pdgCodeCasc2 != kXiPlusBar)) + continue; + mixedEventCont.setPair(p1, p2, multCol, confUse3D, 1.0f); + } + } + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMixedEventCascMCgen, "Enable processing mixed event MC truth for cascade - cascade", false); + + /// This function fills MC truth particles from derived MC table + void processMCgen(aod::FDParticles const& parts) + { + for (const auto& part : parts) { + if (part.partType() != uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) + continue; + + int pdgCode = static_cast(part.pidCut()); + const auto& pdgParticle = pdgMC->GetParticle(pdgCode); + if (!pdgParticle) { + continue; + } + + if ((confCascType1 == 0 && pdgCode == kOmegaMinus) || (confCascType1 == 1 && pdgCode == kXiMinus)) { + registryMCgen.fill(HIST("plus/MCgenCasc"), part.pt(), part.eta()); + continue; + } else if ((confCascType1 == 0 && pdgCode == kOmegaPlusBar) || (confCascType1 == 1 && pdgCode == kXiPlusBar)) { + registryMCgen.fill(HIST("minus/MCgenCasc"), part.pt(), part.eta()); + continue; + } + + if (pdgParticle->Charge() > 0.0) { + registryMCgen.fill(HIST("plus/MCgenAllPt"), part.pt()); + } + if (pdgCode == kProton) { + registryMCgen.fill(HIST("plus/MCgenPr"), part.pt(), part.eta()); + registryMCgen.fill(HIST("plus/MCgenPrPt"), part.pt()); + } + + if (pdgParticle->Charge() < 0.0) { + registryMCgen.fill(HIST("minus/MCgenAllPt"), part.pt()); + } + if (pdgCode == kProtonBar) { + registryMCgen.fill(HIST("minus/MCgenPr"), part.pt(), part.eta()); + registryMCgen.fill(HIST("minus/MCgenPrPt"), part.pt()); + } + } + } + + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMCgen, "Process MC truth data for cascades", false); + + template + void doMCReco(TableType const& parts, aod::FdMCParticles const& mcparts) + { + for (const auto& part : parts) { + auto mcPartId = part.fdMCParticleId(); + if (mcPartId == -1) + continue; // no MC particle + const auto& mcpart = mcparts.iteratorAt(mcPartId); + // + if (part.partType() == aod::femtouniverseparticle::ParticleType::kCascade) { + if ((confCascType1 == 0 && mcpart.pdgMCTruth() == kOmegaMinus) || (confCascType1 == 1 && mcpart.pdgMCTruth() == kXiMinus)) { + const auto& posChild = parts.iteratorAt(part.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild = parts.iteratorAt(part.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor = parts.iteratorAt(part.globalIndex() - 1 - parts.begin().globalIndex()); + /// Daughters that do not pass this condition are not selected + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild, CascChildTable[confCascType1][0]) || !isParticleTPC(negChild, CascChildTable[confCascType1][1]) || !isParticleTPC(bachelor, CascChildTable[confCascType1][2])) + continue; + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild, CascChildTable[confCascType1][0]) || !isParticleTOF(negChild, CascChildTable[confCascType1][1]))) || !isParticleTOF(bachelor, CascChildTable[confCascType1][2])) + continue; + } else { + if ((posChild.pidCut() & (1u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (1u << CascChildTable[confCascType1][1])) == 0 || (bachelor.pidCut() & (1u << CascChildTable[confCascType1][2])) == 0) + continue; + if ((!confCheckTOFBachelorOnly && ((posChild.pidCut() & (8u << CascChildTable[confCascType1][0])) == 0 || (negChild.pidCut() & (8u << CascChildTable[confCascType1][1])) == 0)) || (bachelor.pidCut() & (8u << CascChildTable[confCascType1][2])) == 0) + continue; + } + registryMCreco.fill(HIST("plus/MCrecoCascade"), mcpart.pt(), mcpart.eta()); + + } else if ((confCascType1 == 0 && mcpart.pdgMCTruth() == kOmegaPlusBar) || (confCascType1 == 1 && mcpart.pdgMCTruth() == kXiPlusBar)) { + const auto& posChild = parts.iteratorAt(part.globalIndex() - 3 - parts.begin().globalIndex()); + const auto& negChild = parts.iteratorAt(part.globalIndex() - 2 - parts.begin().globalIndex()); + const auto& bachelor = parts.iteratorAt(part.globalIndex() - 1 - parts.begin().globalIndex()); + if constexpr (std::experimental::is_detected::value) { + if (!isParticleTPC(posChild, CascChildTable[confCascType1 + 2][0]) && !isParticleTPC(negChild, CascChildTable[confCascType1 + 2][1]) && !isParticleTPC(bachelor, CascChildTable[confCascType1 + 2][2])) + continue; + if ((!confCheckTOFBachelorOnly && (!isParticleTOF(posChild, CascChildTable[confCascType1 + 2][0]) || !isParticleTOF(negChild, CascChildTable[confCascType1 + 2][1]))) || !isParticleTOF(bachelor, CascChildTable[confCascType1 + 2][2])) + continue; + } else { + if ((posChild.pidCut() & (1u << CascChildTable[confCascType1 + 2][0])) == 0 || (negChild.pidCut() & (1u << CascChildTable[confCascType1 + 2][1])) == 0 || (bachelor.pidCut() & (1u << CascChildTable[confCascType1 + 2][2])) == 0) + continue; + if ((!confCheckTOFBachelorOnly && ((posChild.pidCut() & (8u << CascChildTable[confCascType1 + 2][0])) == 0 || (negChild.pidCut() & (8u << CascChildTable[confCascType1 + 2][1])) == 0)) || (bachelor.pidCut() & (8u << CascChildTable[confCascType1 + 2][2])) == 0) + continue; + } + registryMCreco.fill(HIST("minus/MCrecoCascade"), mcpart.pt(), mcpart.eta()); + } + + } else if (part.partType() == aod::femtouniverseparticle::ParticleType::kTrack) { + if (part.mAntiLambda() > 0) { + registryMCreco.fill(HIST("plus/MCrecoAllPt"), mcpart.pt()); + if (mcpart.pdgMCTruth() != kProton) + continue; + if constexpr (std::experimental::is_detected::value) { + if (!isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePr()))) + continue; + } else { + if ((part.pidCut() & 64u) == 0) + continue; + } + registryMCreco.fill(HIST("plus/MCrecoPr"), mcpart.pt(), mcpart.eta()); + registryMCreco.fill(HIST("plus/MCrecoPrPt"), mcpart.pt()); + } else if (part.mAntiLambda() < 0) { + registryMCreco.fill(HIST("minus/MCrecoAllPt"), mcpart.pt()); + if (mcpart.pdgMCTruth() != kProtonBar) + continue; + if constexpr (std::experimental::is_detected::value) { + if (!isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePr()))) + continue; + } else { + if ((part.pidCut() & 64u) == 0) + continue; + } + registryMCreco.fill(HIST("minus/MCrecoPr"), mcpart.pt(), mcpart.eta()); + registryMCreco.fill(HIST("minus/MCrecoPrPt"), mcpart.pt()); + } + } + } + } + + void processMCReco(FemtoRecoFullParticles const& parts, aod::FdMCParticles const& mcparts) + { + doMCReco(parts, mcparts); + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMCReco, "Process MC reco data for cascades using nSigma for PID", false); + + void processMCRecoBitmask(FemtoRecoBasicParticles const& parts, aod::FdMCParticles const& mcparts) + { + doMCReco(parts, mcparts); + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMCRecoBitmask, "Process MC reco data for cascades using Bitmask for PID", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackD0.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackD0.cxx index 979a500b240..3e68a275452 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackD0.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackD0.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -19,6 +19,7 @@ #include #include + #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" @@ -27,6 +28,7 @@ #include "Framework/StepTHn.h" #include "Framework/O2DatabasePDGPlugin.h" #include "ReconstructionDataFormats/PID.h" + #include "Common/DataModel/PIDResponse.h" #include "Common/Core/RecoDecay.h" @@ -39,27 +41,22 @@ #include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" #include "PWGCF/FemtoUniverse/Core/femtoUtils.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseSoftPionRemoval.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCalculator.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" using namespace o2; using namespace o2::analysis; using namespace o2::analysis::femto_universe; +using namespace o2::analysis::femto_universe::efficiency; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -namespace -{ -static constexpr int kNPart = 2; -static constexpr int kNCuts = 5; -static const std::vector partNames{"D0", "Track"}; -static const std::vector cutNames{"MaxPt", "PIDthr", "nSigmaTPC", "nSigmaTPCTOF", "MaxP"}; -static const float cutsTable[kNPart][kNCuts]{{4.05f, 1.f, 3.f, 3.f, 100.f}, {4.05f, 1.f, 3.f, 3.f, 100.f}}; -} // namespace - /// Returns deltaPhi value within the range [-pi/2, 3/2*pi] /// double getDeltaPhi(double phiD, double phiDbar) @@ -81,10 +78,15 @@ double wrapDeltaPhi0PI(double phiD, double phiDbar) struct FemtoUniversePairTaskTrackD0 { + Service pdgMC; + using FemtoFullParticles = soa::Join; SliceCache cache; Preslice perCol = aod::femtouniverseparticle::fdCollisionId; + using FemtoMCParticles = soa::Join; + Preslice perColMC = aod::femtouniverseparticle::fdCollisionId; + /// Table for both particles struct : o2::framework::ConfigurableGroup { Configurable confNsigmaCombinedProton{"confNsigmaCombinedProton", 3.0, "TPC and TOF Proton Sigma (combined) for momentum > 0.5"}; @@ -92,8 +94,6 @@ struct FemtoUniversePairTaskTrackD0 { Configurable confNsigmaCombinedPion{"confNsigmaCombinedPion", 3.0, "TPC and TOF Pion Sigma (combined) for momentum > 0.5"}; Configurable confNsigmaTPCPion{"confNsigmaTPCPion", 3.0, "TPC Pion Sigma for momentum < 0.5"}; - Configurable> confCutTable{"confCutTable", {cutsTable[0], kNPart, kNCuts, partNames, cutNames}, "Particle selections"}; - Configurable confNspecies{"confNspecies", 2, "Number of particle spieces with PID info"}; Configurable confIsMC{"confIsMC", false, "Enable additional Histogramms in the case of a MonteCarlo Run"}; Configurable> confTrkPIDnSigmaMax{"confTrkPIDnSigmaMax", std::vector{4.f, 3.f, 2.f}, "This configurable needs to be the same as the one used in the producer task"}; Configurable confUse3D{"confUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; @@ -110,6 +110,8 @@ struct FemtoUniversePairTaskTrackD0 { Configurable confIsTrackIdentified{"confIsTrackIdentified", true, "Enable PID for the track"}; Configurable confTrackLowPtCut{"confTrackLowPtCut", 0.5, "Low pT cut of the track"}; Configurable confTrackHighPtCut{"confTrackHighPtCut", 2.5, "High pT cut of the track"}; + Configurable protonMinPtPidTpcTof{"protonMinPtPidTpcTof", 0.5, "Momentum threshold for change of the PID method (from using TPC to TPC and TOF)."}; + Configurable pionMinPtPidTpcTof{"pionMinPtPidTpcTof", 0.5, "Momentum threshold for change of the PID method (from using TPC to TPC and TOF)."}; } ConfTrack; /// Particle 2 --- D0/D0bar meson @@ -118,38 +120,57 @@ struct FemtoUniversePairTaskTrackD0 { Configurable confPDGCodeD0bar{"confPDGCodeD0bar", -421, "D0bar meson - PDG code"}; Configurable confMinPtD0D0bar{"confMinPtD0D0bar", 1.0, "D0/D0bar sel. - min. pT"}; Configurable confMaxPtD0D0bar{"confMaxPtD0D0bar", 3.0, "D0/D0bar sel. - max. pT"}; - Configurable confMinInvMassD0D0bar{"confMinInvMassD0D0bar", 1.65, "D0/D0bar sel. - min. invMass"}; - Configurable confMaxInvMassD0D0bar{"confMaxInvMassD0D0bar", 2.05, "D0/D0bar sel. - max. invMass"}; + Configurable minInvMassD0D0barSignal{"minInvMassD0D0barSignal", 1.81, "Min. inv. mass of D0/D0bar for signal region"}; + Configurable maxInvMassD0D0barSignal{"maxInvMassD0D0barSignal", 1.922, "Max. inv. mass of D0/D0bar for signal region"}; + Configurable minInvMassD0D0barLeftSB{"minInvMassD0D0barLeftSB", 1.65, "Min. inv. mass of D0/D0bar for left SB region"}; + Configurable maxInvMassD0D0barLeftSB{"maxInvMassD0D0barLeftSB", 1.754, "Max. inv. mass of D0/D0bar for left SB region"}; + Configurable minInvMassD0D0barRightSB{"minInvMassD0D0barRightSB", 1.978, "Min. inv. mass of D0/D0bar for right SB region"}; + Configurable maxInvMassD0D0barRightSB{"maxInvMassD0D0barRightSB", 2.09, "Max. inv. mass of D0/D0bar for right SB region"}; } ConfDmesons; struct : o2::framework::ConfigurableGroup { - Configurable confSignalRegionMin{"confSignalRegionMin", 1.810, "Min. inv. mass for D0/D0bar in the signal region"}; - Configurable confSignalRegionMax{"confSignalRegionMax", 1.922, "Max. inv. mass for D0/D0bar in the signal region"}; - Configurable confMinInvMassLeftSB{"confMinInvMassLeftSB", 1.642, "Min. inv. mass for D0/D0bar in the left sideband region"}; - Configurable confMaxInvMassLeftSB{"confMaxInvMassLeftSB", 1.754, "Max. inv. mass for D0/D0bar in the left sideband region"}; - Configurable confMinInvMassRightSB{"confMinInvMassRightSB", 1.978, "Min. inv. mass for D0/D0bar in the right sideband region"}; - Configurable confMaxInvMassRightSB{"confMaxInvMassRightSB", 2.090, "Max. inv. mass for D0/D0bar in the right sideband region"}; - } ConfD0D0barSideBand; + Configurable confMaxProbMlClass1Bg{"confMaxProbMlClass1Bg", 0.4, "ML: max prob. that D0/D0bar cand. is from the backgound"}; + Configurable confMinProbMlClass2Prompt{"confMinProbMlClass2Prompt", 0.05, "ML: min prob. that D0/D0bar cand. is prompt"}; + Configurable confMaxProbMlClass3NonPrompt{"confMaxProbMlClass3NonPrompt", 1.0, "ML: max prob. that D0/D0bar cand. is non-prompt"}; + Configurable confClass1BgProbStep{"confClass1BgProbStep", 0.05, "ML: prob. step for score class 1"}; + Configurable confClass1BgProbStart{"confClass1BgProbStart", 0.05, "ML: starting prob. value in optimization for score class 1"}; + Configurable confClass2PromptProbStep{"confClass2PromptProbStep", 0.05, "ML: prob. step for score class 2 - prompt"}; + Configurable confClass2PromptProbStart{"confClass2PromptProbStart", 0.1, "ML: starting prob. value in optimization for score class 2"}; + Configurable confClass3NonPromptProbStep{"confClass3NonPromptProbStep", 0.05, "ML: prob. step for score class 2 - non-prompt"}; + Configurable confClass3NonPromptProbStart{"confClass3NonPromptProbStart", 0.05, "ML: starting prob. value in optimization for score class 3"}; + } ConfMlOpt; Configurable> binsPt{"binsPt", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"}; - Configurable confChooseD0trackCorr{"confChooseD0trackCorr", 2, "If 0 - only D0s, 1 - only D0bars, 2 - D0/D0bar (one mass hypo.), 3 - all D0/D0bar cand."}; + Configurable confChooseD0trackCorr{"confChooseD0trackCorr", 0, "If 0 correlations with D0s, if 1 with D0bars"}; + + // Efficiency + Configurable doEfficiencyCorr{"doEfficiencyCorr", false, "Apply efficiency corrections"}; /// Partitions for particle 1 Partition partsTrack = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == int8_t(ConfTrack.confTrackSign)) && (aod::femtouniverseparticle::pt > ConfTrack.confTrackLowPtCut) && (aod::femtouniverseparticle::pt < ConfTrack.confTrackHighPtCut); - Partition> partsTrackMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)); + Partition partsTrackMCReco = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == int8_t(ConfTrack.confTrackSign)) && (aod::femtouniverseparticle::pt > ConfTrack.confTrackLowPtCut) && (aod::femtouniverseparticle::pt < ConfTrack.confTrackHighPtCut); + Partition partsTrackMCTruth = (aod::femtouniverseparticle::partType == static_cast(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (aod::femtouniverseparticle::pidCut == static_cast(ConfTrack.confPDGCodeTrack)) && (aod::femtouniverseparticle::pt > ConfTrack.confTrackLowPtCut) && (aod::femtouniverseparticle::pt < ConfTrack.confTrackHighPtCut); /// Partitions for particle 2 /// Partition with all D0/D0bar mesons (which pass double mass hypothesis) - Partition partsAllDmesons = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda > 0.0f) && (aod::femtouniverseparticle::mAntiLambda > 0.0f); + Partition partsAllDmesons = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && ((aod::femtouniverseparticle::mLambda > 0.0f) || (aod::femtouniverseparticle::mAntiLambda > 0.0f)); /// Partition with D0/D0bar candidates, which pass only one mass hypothesis - Partition partsOnlyD0D0bar = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda < 0.0f || aod::femtouniverseparticle::mAntiLambda < 0.0f); + Partition partsOnlyD0D0bar = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda < 0.0f || aod::femtouniverseparticle::mAntiLambda < 0.0f) && (aod::femtouniverseparticle::tempFitVar < ConfMlOpt.confMaxProbMlClass1Bg) && (aod::femtouniverseparticle::decayVtxY > ConfMlOpt.confMinProbMlClass2Prompt); + /// Partition with D0 mesons only (one and double mass hypothesis) + Partition partsAllD0s = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda > ConfDmesons.minInvMassD0D0barSignal) && (aod::femtouniverseparticle::mLambda < ConfDmesons.maxInvMassD0D0barSignal) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar); /// Partition with D0 mesons only (one mass hypothesis) - Partition partsD0s = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda > ConfDmesons.confMinInvMassD0D0bar) && (aod::femtouniverseparticle::mLambda < ConfDmesons.confMaxInvMassD0D0bar) && (aod::femtouniverseparticle::mAntiLambda < 0.0f) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar); + Partition partsD0s = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda > ConfDmesons.minInvMassD0D0barSignal) && (aod::femtouniverseparticle::mLambda < ConfDmesons.maxInvMassD0D0barSignal) && (aod::femtouniverseparticle::mAntiLambda < 0.0f) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar) && (aod::femtouniverseparticle::tempFitVar < ConfMlOpt.confMaxProbMlClass1Bg) && (aod::femtouniverseparticle::decayVtxY > ConfMlOpt.confMinProbMlClass2Prompt); + /// Partition with D0s selected from the side-band (SB) regions (candidates with double mass hypothesis included) + Partition partsD0sFromSB = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && ((aod::femtouniverseparticle::mLambda > ConfDmesons.minInvMassD0D0barLeftSB && aod::femtouniverseparticle::mLambda < ConfDmesons.maxInvMassD0D0barLeftSB) || (aod::femtouniverseparticle::mLambda > ConfDmesons.minInvMassD0D0barRightSB && aod::femtouniverseparticle::mLambda < ConfDmesons.maxInvMassD0D0barRightSB)) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar); + /// Partition with D0bar mesons only (one and double mass hypothesis) + Partition partsAllD0bars = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mAntiLambda > ConfDmesons.minInvMassD0D0barSignal) && (aod::femtouniverseparticle::mAntiLambda < ConfDmesons.maxInvMassD0D0barSignal) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar); /// Partition with D0bar mesons only (one mass hypothesis) - Partition partsD0bars = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda < 0.0f) && (aod::femtouniverseparticle::mAntiLambda > ConfDmesons.confMinInvMassD0D0bar) && (aod::femtouniverseparticle::mAntiLambda < ConfDmesons.confMaxInvMassD0D0bar) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar); + Partition partsD0bars = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda < 0.0f) && (aod::femtouniverseparticle::mAntiLambda > ConfDmesons.minInvMassD0D0barSignal) && (aod::femtouniverseparticle::mAntiLambda < ConfDmesons.maxInvMassD0D0barSignal) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar) && (aod::femtouniverseparticle::tempFitVar < ConfMlOpt.confMaxProbMlClass1Bg) && (aod::femtouniverseparticle::decayVtxY > ConfMlOpt.confMinProbMlClass2Prompt); + /// Partition with D0bars selected from the side-band (SB) regions (candidates with double mass hypothesis included) + Partition partsD0barsFromSB = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && ((aod::femtouniverseparticle::mAntiLambda > ConfDmesons.minInvMassD0D0barLeftSB && aod::femtouniverseparticle::mAntiLambda < ConfDmesons.maxInvMassD0D0barLeftSB) || (aod::femtouniverseparticle::mAntiLambda > ConfDmesons.minInvMassD0D0barRightSB && aod::femtouniverseparticle::mAntiLambda < ConfDmesons.maxInvMassD0D0barRightSB)) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar); /// Partition for D0/D0bar mesons from MC - Partition> partsD0D0barMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)); - + Partition partsD0D0barMCReco = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda < 0.0f || aod::femtouniverseparticle::mAntiLambda < 0.0f) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar) && (aod::femtouniverseparticle::tempFitVar < ConfMlOpt.confMaxProbMlClass1Bg) && (aod::femtouniverseparticle::decayVtxY > ConfMlOpt.confMinProbMlClass2Prompt); + Partition partsD0D0barMCTruth = (aod::femtouniverseparticle::partType == static_cast(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (aod::femtouniverseparticle::pidCut == static_cast(ConfDmesons.confPDGCodeD0) || aod::femtouniverseparticle::pidCut == static_cast(ConfDmesons.confPDGCodeD0bar)) && (aod::femtouniverseparticle::pt > ConfDmesons.confMinPtD0D0bar) && (aod::femtouniverseparticle::pt < ConfDmesons.confMaxPtD0D0bar); /// Partition for D0/D0bar daughters Partition partsDmesonsChildren = aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0Child); @@ -185,7 +206,6 @@ struct FemtoUniversePairTaskTrackD0 { ConfigurableAxis confmTBins{"confmTBins", {225, 0., 7.5}, "binning mT"}; ConfigurableAxis confPtBins{"confPtBins", {360, 0., 36.}, "binning pT"}; ConfigurableAxis confInvMassBins{"confInvMassBins", {500, 0., 5.0}, "binning inv. mass"}; - ConfigurableAxis confInvMassFinerBins{"confInvMassFinerBins", {120, 1.5848, 2.1848}, "finer binning of inv. mass"}; Configurable confIsCPR{"confIsCPR", true, "Close Pair Rejection"}; Configurable confCPRPlotPerRadii{"confCPRPlotPerRadii", false, "Plot CPR per radii"}; @@ -195,18 +215,35 @@ struct FemtoUniversePairTaskTrackD0 { Configurable confCPRdeltaEtaCutMin{"confCPRdeltaEtaCutMin", 0.0, "Delta Eta min cut for Close Pair Rejection"}; Configurable confCPRChosenRadii{"confCPRChosenRadii", 0.80, "Delta Eta cut for Close Pair Rejection"}; - FemtoUniverseFemtoContainer sameEventFemtoCont; - FemtoUniverseFemtoContainer mixedEventFemtoCont; + Configurable applyMLOpt{"applyMLOpt", false, "Enable for ML selection optimization"}; + Configurable confRemoveSoftPions{"confRemoveSoftPions", false, "Enable to remove soft pions from D* decays"}; + Configurable confSoftPionD0Flag{"confSoftPionD0Flag", false, "Enable soft pion check for D0s"}; + Configurable confSoftPionD0barFlag{"confSoftPionD0barFlag", false, "Enable soft pion check for D0bars"}; + Configurable sigmaSoftPiInvMass{"sigmaSoftPiInvMass", 0.1, "Sigma value from the inv. mass fit for soft pions"}; + // Event mixing configurables + Configurable confNEventsMix{"confNEventsMix", 5, "Number of events for mixing"}; + FemtoUniverseAngularContainer sameEventAngularCont; FemtoUniverseAngularContainer mixedEventAngularCont; FemtoUniversePairCleaner pairCleaner; FemtoUniverseDetaDphiStar pairCloseRejection; + FemtoUniverseSoftPionRemoval softPionRemoval; FemtoUniverseTrackSelection trackCuts; + // Axes for BDT score classes' histograms + AxisSpec axisBdtScore{100, 0.f, 1.f}; + AxisSpec axisSelStatus{2, -0.5f, 1.5f}; /// Histogram output HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry mixQaRegistry{"mixQaRegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry mcRecoRegistry{"mcRecoRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry mcTruthRegistry{"mcTruthRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + + // Efficiency + EfficiencyConfigurableGroup effConfGroup; + EfficiencyCalculator efficiencyCalculator{&effConfGroup}; + float weight = 1.0; HistogramRegistry registry{"registry", {{"hInvMassD0", ";#it{M}(K^{-}#pi^{+}) (GeV/#it{c}^{2});counts", {HistType::kTH1F, {confInvMassBins}}}, @@ -225,21 +262,19 @@ struct FemtoUniversePairTaskTrackD0 { {"hDecayLengthD0bar", ";decay length (cm);counts", {HistType::kTH1F, {{800, 0., 4.}}}}, {"hPtDaughters", ";#it{p}_{T} (GeV/#it{c});counts", {HistType::kTH1F, {{300, 0., 12.}}}}, {"hSignDaughters", ";sign ;counts", {HistType::kTH1F, {{10, -2.5, 2.5}}}}, - {"hbetaDaughters", "; p (GeV/#it{c}); TOF #beta", {HistType::kTH2F, {{300, 0., 15.}, {200, 0., 2.}}}}, - {"hdEdxDaughters", "; p (GeV/#it{c}); TPC dE/dx (KeV/cm)", {HistType::kTH2F, {{300, 0., 15.}, {500, 0., 500.}}}}, {"hDCAxyDaughters", "; #it{DCA}_{xy} (cm); counts", {HistType::kTH1F, {{140, 0., 0.14}}}}, {"hDCAzDaughters", "; #it{DCA}_{z} (cm); counts", {HistType::kTH1F, {{140, 0., 0.14}}}}}}; // PID for protons bool isProtonNSigma(float mom, float nsigmaTPCPr, float nsigmaTOFPr) // previous version from: https://github.com/alisw/AliPhysics/blob/master/PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoMJTrackCut.cxx { - if (mom < 0.5) { + if (mom < ConfTrack.protonMinPtPidTpcTof) { if (std::abs(nsigmaTPCPr) < ConfBothTracks.confNsigmaTPCProton) { return true; } else { return false; } - } else if (mom > 0.4) { + } else if (mom > ConfTrack.protonMinPtPidTpcTof) { if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.confNsigmaCombinedProton) { return true; } else { @@ -290,20 +325,17 @@ struct FemtoUniversePairTaskTrackD0 { bool isPionNSigma(float mom, float nsigmaTPCPi, float nsigmaTOFPi) { - //|nsigma_TPC| < 3 for p < 0.5 GeV/c - //|nsigma_combined| < 3 for p > 0.5 - // using configurables: - // confNsigmaTPCPion -> TPC Kaon Sigma for momentum < 0.5 - // confNsigmaCombinedPion -> TPC and TOF Pion Sigma (combined) for momentum > 0.5 + // confNsigmaTPCPion -> TPC Pion Sigma for momentum < 0.5 GeV/c + // confNsigmaCombinedPion -> TPC and TOF Pion Sigma (combined) for momentum > 0.5 GeV/c if (true) { - if (mom < 0.5) { + if (mom < ConfTrack.pionMinPtPidTpcTof) { if (std::abs(nsigmaTPCPi) < ConfBothTracks.confNsigmaTPCPion) { return true; } else { return false; } - } else if (mom > 0.5) { + } else if (mom > ConfTrack.pionMinPtPidTpcTof) { if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.confNsigmaCombinedPion) { return true; } else { @@ -336,11 +368,21 @@ struct FemtoUniversePairTaskTrackD0 { void init(InitContext&) { + // if (effConfGroup.confEfficiencyDoMCTruth) { + // WORK IN PROGRESS + // hMCTruth1.init(&qaRegistry, confBinsTempFitVarpT, confBinsTempFitVarPDG, false, ConfTrack.confTrackPDGCode, false); + // hMCTruth2.init(&qaRegistry, confBinsTempFitVarpT, confBinsTempFitVarPDG, false, 333, false); + // } + efficiencyCalculator.init(); + eventHisto.init(&qaRegistry); qaRegistry.add("QA_D0D0barSelection/hInvMassD0", ";#it{M}(K^{-}#pi^{+}) (GeV/#it{c}^{2});counts", kTH1F, {confInvMassBins}); qaRegistry.add("QA_D0D0barSelection/hPtD0", "D^{0} cand.;#it{p}_{T} (GeV/#it{c});counts", kTH1F, {confPtBins}); qaRegistry.add("QA_D0D0barSelection/hInvMassD0bar", ";#it{M}(K^{-}#pi^{+}) (GeV/#it{c}^{2});counts", kTH1F, {confInvMassBins}); qaRegistry.add("QA_D0D0barSelection/hPtD0bar", "#bar{D^{0}} cand.;#it{p}_{T} (GeV/#it{c});counts", kTH1F, {confPtBins}); + qaRegistry.add("QA_D0D0barSelection_SB/hInvMassD0", ";#it{M}(K^{-}#pi^{+}) (GeV/#it{c}^{2});counts", kTH1F, {confInvMassBins}); + qaRegistry.add("QA_D0D0barSelection_SB/hPtD0", "D^{0} cand.;#it{p}_{T} (GeV/#it{c});counts", kTH1F, {confPtBins}); + qaRegistry.add("D0_pos_daugh/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); qaRegistry.add("D0_pos_daugh/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); qaRegistry.add("D0_pos_daugh/pt", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); @@ -376,6 +418,23 @@ struct FemtoUniversePairTaskTrackD0 { qaRegistry.add("Hadron/nSigmaTPCKa", "; #it{p} (GeV/#it{c}); n#sigma_{TPCKa}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); qaRegistry.add("Hadron/nSigmaTOFKa", "; #it{p} (GeV/#it{c}); n#sigma_{TOFKa}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + // MC truth + mcTruthRegistry.add("MCTruthD0D0bar", "MC Truth D0/D0bar;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{360, 0, 36}, {400, -1.0, 1.0}}}); + mcTruthRegistry.add("MCTruthAllPositivePt", "MC Truth all positive;#it{p}_{T} (GeV/c); counts", {HistType::kTH1F, {{360, 0, 36}}}); + mcTruthRegistry.add("MCTruthAllNegativePt", "MC Truth all negative;#it{p}_{T} (GeV/c); counts", {HistType::kTH1F, {{360, 0, 36}}}); + mcTruthRegistry.add("MCTruthKpPtVsEta", "MC Truth K+;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + mcTruthRegistry.add("MCTruthKmPtVsEta", "MC Truth K-;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + mcTruthRegistry.add("MCTruthPipPtVsEta", "MC Truth #pi+;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + mcTruthRegistry.add("MCTruthPimPtVsEta", "MC Truth #pi-;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + mcTruthRegistry.add("MCTruthProtonPtVsEta", "MC Truth proton;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + mcTruthRegistry.add("MCTruthAntiProtonPtVsEta", "MC Truth antiproton;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + mcTruthRegistry.add("MCTruthKpPt", "MC Truth K+;#it{p}_{T} (GeV/c); counts", {HistType::kTH1F, {{500, 0, 5}}}); + mcTruthRegistry.add("MCTruthKmPt", "MC Truth K-;#it{p}_{T} (GeV/c); counts", {HistType::kTH1F, {{500, 0, 5}}}); + mcTruthRegistry.add("MCTruthPipPt", "MC Truth #pi+;#it{p}_{T} (GeV/c); counts", {HistType::kTH1F, {{500, 0, 5}}}); + mcTruthRegistry.add("MCTruthPimPt", "MC Truth #pi-;#it{p}_{T} (GeV/c); counts", {HistType::kTH1F, {{500, 0, 5}}}); + mcTruthRegistry.add("MCTruthProtonPt", "MC Truth proton;#it{p}_{T} (GeV/c); counts", {HistType::kTH1F, {{500, 0, 5}}}); + mcTruthRegistry.add("MCTruthAntiProtonPt", "MC Truth antiproton;#it{p}_{T} (GeV/c); counts", {HistType::kTH1F, {{500, 0, 5}}}); + trackHistoPartD0D0bar.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarInvMassBins, ConfBothTracks.confIsMC, ConfDmesons.confPDGCodeD0); if (!ConfTrack.confIsSame) { trackHistoPartTrack.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarBins, ConfBothTracks.confIsMC, ConfTrack.confPDGCodeTrack); @@ -384,16 +443,13 @@ struct FemtoUniversePairTaskTrackD0 { mixQaRegistry.add("MixingQA/hSECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); mixQaRegistry.add("MixingQA/hMECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); - sameEventFemtoCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confmultBins3D, confmTBins3D, ConfBothTracks.confIsMC, ConfBothTracks.confUse3D); - mixedEventFemtoCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confmultBins3D, confmTBins3D, ConfBothTracks.confIsMC, ConfBothTracks.confUse3D); sameEventAngularCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confmultBins3D, confmTBins3D, ConfBothTracks.confEtaBins, ConfBothTracks.confPhiBins, ConfBothTracks.confIsMC, ConfBothTracks.confUse3D); mixedEventAngularCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confmultBins3D, confmTBins3D, ConfBothTracks.confEtaBins, ConfBothTracks.confPhiBins, ConfBothTracks.confIsMC, ConfBothTracks.confUse3D); - sameEventFemtoCont.setPDGCodes(ConfDmesons.confPDGCodeD0, ConfTrack.confPDGCodeTrack); - mixedEventFemtoCont.setPDGCodes(ConfDmesons.confPDGCodeD0, ConfTrack.confPDGCodeTrack); sameEventAngularCont.setPDGCodes(ConfDmesons.confPDGCodeD0, ConfTrack.confPDGCodeTrack); mixedEventAngularCont.setPDGCodes(ConfDmesons.confPDGCodeD0, ConfTrack.confPDGCodeTrack); + softPionRemoval.init(&qaRegistry); pairCleaner.init(&qaRegistry); if (confIsCPR.value) { pairCloseRejection.init(&resultRegistry, &qaRegistry, confCPRdeltaPhiCutMin.value, confCPRdeltaPhiCutMax.value, confCPRdeltaEtaCutMin.value, confCPRdeltaEtaCutMax.value, confCPRChosenRadii.value, confCPRPlotPerRadii.value); @@ -405,13 +461,30 @@ struct FemtoUniversePairTaskTrackD0 { // D0/D0bar histograms auto vbins = (std::vector)binsPt; registry.add("D0D0bar_oneMassHypo/hMassVsPt", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("D0D0bar_oneMassHypo/hMassVsPtFinerBinning", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassFinerBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hDeltaPhiSigSig", "SxS correlation;#Delta#varphi (rad);counts", {HistType::kTH1F, {{10, 0.0, o2::constants::math::PI}}}); - registry.add("hDeltaPhiD0BgD0barSig", "B(D0)x S(D0bar) correlation;#Delta#varphi (rad);counts", {HistType::kTH1F, {{10, 0.0, o2::constants::math::PI}}}); - registry.add("hDeltaPhiD0SigD0barBg", "S(D0)x B(D0bar) correlation;#Delta#varphi (rad);counts", {HistType::kTH1F, {{10, 0.0, o2::constants::math::PI}}}); - registry.add("hDeltaPhiBgBg", "BxB correlation;#Delta#varphi (rad);counts", {HistType::kTH1F, {{10, 0.0, o2::constants::math::PI}}}); - registry.add("hPtCand1VsPtCand2", "2-prong candidates;#it{p}_{T} (GeV/#it{c});#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hDeltaEtaDeltaPhi", "2-prong candidates;#Delta #eta;#Delta #varphi (rad)", {HistType::kTH2F, {{29, -2., 2.}, {29, 0.0, o2::constants::math::PI}}}); + registry.add("D0D0bar_oneMassHypo/hMassVsPtReflected", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_oneMassHypo/hMassVsPtD0", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_oneMassHypo/hMassVsPtD0bar", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_oneMassHypo/hMassVsPtD0Reflected", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_oneMassHypo/hMassVsPtD0barReflected", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_doubleMassHypo/hMassVsPt", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_doubleMassHypo/hMassVsPtD0", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_doubleMassHypo/hMassVsPtD0bar", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + // Histograms for BDT score classes' check + registry.add("DebugBdt/hBdtScore1VsStatus", ";BDT score;status", {HistType::kTH2F, {axisBdtScore, axisSelStatus}}); + registry.add("DebugBdt/hBdtScore2VsStatus", ";BDT score;status", {HistType::kTH2F, {axisBdtScore, axisSelStatus}}); + registry.add("DebugBdt/hBdtScore3VsStatus", ";BDT score;status", {HistType::kTH2F, {axisBdtScore, axisSelStatus}}); + if (applyMLOpt) { + registry.add("D0D0bar_MLSel/hMassVsPt1", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_MLSel/hMassVsPt2", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_MLSel/hMassVsPt3", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_MLSel/hMassVsPt4", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_MLSel/hMassVsPt5", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_MLSel/hMassVsPt6", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_MLSel/hMassVsPt7", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_MLSel/hMassVsPt8", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_MLSel/hMassVsPt9", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("D0D0bar_MLSel/hMassVsPt10", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {confInvMassBins, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + } } template @@ -421,10 +494,125 @@ struct FemtoUniversePairTaskTrackD0 { eventHisto.fillQA(col); } + void processD0MLOptBg(o2::aod::FdCollision const& col, FemtoFullParticles const&) + { + auto groupD0D0barCands = partsOnlyD0D0bar->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + + // loop over selected D0/D0bar candidates + for (auto const& charmCand : groupD0D0barCands) { + // D0 candidates + if (charmCand.mLambda() > 0.0f && charmCand.mAntiLambda() < 0.0f) { + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt1"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt2"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 2.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt3"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 3.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt4"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 4.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt5"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 5.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt6"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 6.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt7"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 7.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt8"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 8.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt9"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 9.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt10"), charmCand.mLambda(), charmCand.pt()); + } + // DObar candidates + if (charmCand.mLambda() < 0.0f && charmCand.mAntiLambda() > 0.0f) { + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt1"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt2"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 2.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt3"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 3.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt4"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 4.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt5"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 5.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt6"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 6.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt7"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 7.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt8"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 8.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt9"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 9.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt10"), charmCand.mAntiLambda(), charmCand.pt()); + } + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processD0MLOptBg, "Enable filling QA plots for ML Bg D0/D0bar selection optimization", false); + + void processD0MLOptBgAndPrompt(o2::aod::FdCollision const& col, FemtoFullParticles const&) + { + auto groupD0D0barCands = partsOnlyD0D0bar->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + + // loop over selected D0/D0bar candidates + for (auto const& charmCand : groupD0D0barCands) { + // D0 candidates + if (charmCand.decayVtxY() > ConfMlOpt.confClass2PromptProbStart) { + if (charmCand.mLambda() > 0.0f && charmCand.mAntiLambda() < 0.0f) { + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt1"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt2"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 2.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt3"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 3.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt4"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 4.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt5"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 5.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt6"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 6.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt7"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 7.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt8"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 8.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt9"), charmCand.mLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 9.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt10"), charmCand.mLambda(), charmCand.pt()); + } + // DObar candidates + if (charmCand.mLambda() < 0.0f && charmCand.mAntiLambda() > 0.0f) { + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt1"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt2"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 2.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt3"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 3.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt4"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 4.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt5"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 5.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt6"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 6.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt7"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 7.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt8"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 8.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt9"), charmCand.mAntiLambda(), charmCand.pt()); + if (charmCand.tempFitVar() < ConfMlOpt.confClass1BgProbStart + 9.0 * ConfMlOpt.confClass1BgProbStep) + registry.fill(HIST("D0D0bar_MLSel/hMassVsPt10"), charmCand.mAntiLambda(), charmCand.pt()); + } + } + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processD0MLOptBgAndPrompt, "Enable filling QA plots for ML Bg and Prompt D0/D0bar selection optimization", false); + void processQAD0D0barSel(o2::aod::FdCollision const& col, FemtoFullParticles const&) { auto groupPartsD0s = partsD0s->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto groupPartsD0bars = partsD0bars->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsD0sFromSB = partsD0sFromSB->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); // loop over selected D0 candidates for (auto const& d0cand : groupPartsD0s) { @@ -438,30 +626,108 @@ struct FemtoUniversePairTaskTrackD0 { qaRegistry.fill(HIST("QA_D0D0barSelection/hInvMassD0bar"), d0barcand.mAntiLambda()); qaRegistry.fill(HIST("QA_D0D0barSelection/hPtD0bar"), d0barcand.pt()); } + + // loop over selected D0 candidates from SB regions + for (auto const& d0SB : groupPartsD0sFromSB) { + + qaRegistry.fill(HIST("QA_D0D0barSelection_SB/hInvMassD0"), d0SB.mLambda()); + qaRegistry.fill(HIST("QA_D0D0barSelection_SB/hPtD0"), d0SB.pt()); + } } PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processQAD0D0barSel, "Enable filling QA plots for selected D0/D0bar cand.", true); - void processD0mesons(o2::aod::FdCollision const& col, FemtoFullParticles const&) + void processAllDmesons(o2::aod::FdCollision const& col, FemtoFullParticles const&) { - auto groupPartsOnlyD0D0bar = partsOnlyD0D0bar->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto groupPartsAllDmesons = partsAllDmesons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsAllD0D0barCands = partsAllDmesons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto groupPartsD0D0barChildren = partsDmesonsChildren->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - // loop over all D mesons - for (auto const& dmeson : groupPartsAllDmesons) { + // loop over D0/D0bar mesons (ONLY) + for (auto const& d0d0bar : groupPartsAllD0D0barCands) { - registry.fill(HIST("hPtDmesonCand"), dmeson.pt()); - registry.fill(HIST("hPhiDmesonCand"), dmeson.phi()); - registry.fill(HIST("hEtaDmesonCand"), dmeson.eta()); + registry.fill(HIST("hPtD0D0bar"), d0d0bar.pt()); + registry.fill(HIST("hPhiDmesonCand"), d0d0bar.phi()); + registry.fill(HIST("hEtaDmesonCand"), d0d0bar.eta()); + // BDT score classes + registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), d0d0bar.decayVtxX(), 1); + registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), d0d0bar.decayVtxY(), 1); + registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), d0d0bar.decayVtxZ(), 1); + + if (d0d0bar.mLambda() > 0.0f) { + registry.fill(HIST("D0D0bar_doubleMassHypo/hMassVsPt"), d0d0bar.mLambda(), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_doubleMassHypo/hMassVsPtD0"), d0d0bar.mLambda(), d0d0bar.pt()); + if (d0d0bar.mAntiLambda() < 0.0f) { + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPt"), d0d0bar.mLambda(), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPtD0"), d0d0bar.mLambda(), d0d0bar.pt()); + registry.fill(HIST("hPtD0"), d0d0bar.pt()); + registry.fill(HIST("hPhiD0"), d0d0bar.phi()); + registry.fill(HIST("hEtaD0"), d0d0bar.eta()); + } + } + if (d0d0bar.mAntiLambda() > 0.0f) { + registry.fill(HIST("D0D0bar_doubleMassHypo/hMassVsPt"), d0d0bar.mLambda(), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_doubleMassHypo/hMassVsPtD0bar"), d0d0bar.mLambda(), d0d0bar.pt()); + if (d0d0bar.mLambda() < 0.0f) { + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPt"), d0d0bar.mAntiLambda(), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPtD0bar"), d0d0bar.mAntiLambda(), d0d0bar.pt()); + registry.fill(HIST("hPtD0bar"), d0d0bar.pt()); + registry.fill(HIST("hPhiD0bar"), d0d0bar.phi()); + registry.fill(HIST("hEtaD0bar"), d0d0bar.eta()); + } + } } + // loop over D mesons childen + for (auto const& daughD0D0bar : groupPartsD0D0barChildren) { + registry.fill(HIST("hPtDaughters"), daughD0D0bar.pt()); + registry.fill(HIST("hSignDaughters"), daughD0D0bar.mLambda()); + // filling QA plots for D0 mesons' positive daughters (K+) + if (daughD0D0bar.mLambda() == 1 && (daughD0D0bar.mAntiLambda() == 1 || daughD0D0bar.mAntiLambda() == 0)) { + qaRegistry.fill(HIST("D0_pos_daugh/pt"), daughD0D0bar.pt()); + qaRegistry.fill(HIST("D0_pos_daugh/eta"), daughD0D0bar.eta()); + qaRegistry.fill(HIST("D0_pos_daugh/phi"), daughD0D0bar.phi()); + } + // filling QA plots for D0 mesons' negative daughters (pi-) + if (daughD0D0bar.mLambda() == -1 && (daughD0D0bar.mAntiLambda() == 1 || daughD0D0bar.mAntiLambda() == 0)) { + qaRegistry.fill(HIST("D0_neg_daugh/pt"), daughD0D0bar.pt()); + qaRegistry.fill(HIST("D0_neg_daugh/eta"), daughD0D0bar.eta()); + qaRegistry.fill(HIST("D0_neg_daugh/phi"), daughD0D0bar.phi()); + } + // filling QA plots for D0bar mesons' positive daughters (pi+) + if (daughD0D0bar.mLambda() == 1 && (daughD0D0bar.mAntiLambda() == -1 || daughD0D0bar.mAntiLambda() == 0)) { + qaRegistry.fill(HIST("D0bar_pos_daugh/pt"), daughD0D0bar.pt()); + qaRegistry.fill(HIST("D0bar_pos_daugh/eta"), daughD0D0bar.eta()); + qaRegistry.fill(HIST("D0bar_pos_daugh/phi"), daughD0D0bar.phi()); + } + // filling QA plots for D0bar mesons' negative daughters (K-) + if (daughD0D0bar.mLambda() == -1 && (daughD0D0bar.mAntiLambda() == -1 || daughD0D0bar.mAntiLambda() == 0)) { + qaRegistry.fill(HIST("D0bar_neg_daugh/pt"), daughD0D0bar.pt()); + qaRegistry.fill(HIST("D0bar_neg_daugh/eta"), daughD0D0bar.eta()); + qaRegistry.fill(HIST("D0bar_neg_daugh/phi"), daughD0D0bar.phi()); + } + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processAllDmesons, "Enable processing over all D meson candidates", false); + + void processD0mesons(o2::aod::FdCollision const& col, FemtoFullParticles const&) + { + auto groupPartsAllD0D0barCands = partsAllDmesons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsOnlyD0D0bar = partsOnlyD0D0bar->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsD0D0barChildren = partsDmesonsChildren->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + // loop over D0/D0bar mesons (ONLY) for (auto const& d0d0bar : groupPartsOnlyD0D0bar) { registry.fill(HIST("hPtD0D0bar"), d0d0bar.pt()); + // BDT score classes + registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), d0d0bar.decayVtxX(), 1); + registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), d0d0bar.decayVtxY(), 1); + registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), d0d0bar.decayVtxZ(), 1); if (d0d0bar.mLambda() > 0.0f && d0d0bar.mAntiLambda() < 0.0f) { registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPt"), d0d0bar.mLambda(), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPtD0"), d0d0bar.mLambda(), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPtReflected"), std::abs(d0d0bar.mAntiLambda()), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPtD0Reflected"), std::abs(d0d0bar.mAntiLambda()), d0d0bar.pt()); registry.fill(HIST("hInvMassD0"), d0d0bar.mLambda()); registry.fill(HIST("hPtD0"), d0d0bar.pt()); registry.fill(HIST("hPhiD0"), d0d0bar.phi()); @@ -469,6 +735,9 @@ struct FemtoUniversePairTaskTrackD0 { } if (d0d0bar.mLambda() < 0.0f && d0d0bar.mAntiLambda() > 0.0f) { registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPt"), d0d0bar.mAntiLambda(), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPtD0bar"), d0d0bar.mAntiLambda(), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPtReflected"), std::abs(d0d0bar.mLambda()), d0d0bar.pt()); + registry.fill(HIST("D0D0bar_oneMassHypo/hMassVsPtD0barReflected"), std::abs(d0d0bar.mLambda()), d0d0bar.pt()); registry.fill(HIST("hInvMassD0bar"), d0d0bar.mAntiLambda()); registry.fill(HIST("hPtD0bar"), d0d0bar.pt()); registry.fill(HIST("hPhiD0bar"), d0d0bar.phi()); @@ -508,63 +777,6 @@ struct FemtoUniversePairTaskTrackD0 { } PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processD0mesons, "Enable processing D0 mesons", true); - // D0-D0bar pair correlations (side-band methode) - void processSideBand(o2::aod::FdCollision const& col, FemtoFullParticles const&) - { - auto groupPartsOnlyD0D0bar = partsOnlyD0D0bar->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - - double deltaPhi = 0.0; - double deltaEta = 0.0; - - // loop over D0/D0bar candidates (ONLY) - for (auto const& cand1 : groupPartsOnlyD0D0bar) { - // Check if the first candidate is D0 meson - if (cand1.mLambda() < 0.0f && cand1.mAntiLambda() > 0.0f) { - continue; - } - - for (auto const& cand2 : groupPartsOnlyD0D0bar) { - // Check if the second candidate is D0bar meson - if (cand2.mLambda() > 0.0f && cand2.mAntiLambda() < 0.0f) { - continue; - } - // deltaPhi = getDeltaPhi(cand1.phi(), cand2.phi()); - deltaPhi = wrapDeltaPhi0PI(cand1.phi(), cand2.phi()); - deltaEta = cand2.eta() - cand1.eta(); - - // General histograms - registry.fill(HIST("hPtCand1VsPtCand2"), cand1.pt(), cand2.pt()); - registry.fill(HIST("hDeltaEtaDeltaPhi"), deltaEta, deltaPhi); - - // ----------------------------------- Creating D0-D0bar pairs correlations ------------------------------------------------ - if (cand1.mLambda() > ConfD0D0barSideBand.confSignalRegionMin.value && cand1.mLambda() < ConfD0D0barSideBand.confSignalRegionMax.value) { - // S(D0) x S(D0bar) correlation - if (cand2.mAntiLambda() > ConfD0D0barSideBand.confSignalRegionMin.value && cand2.mAntiLambda() < ConfD0D0barSideBand.confSignalRegionMax.value) { - registry.fill(HIST("hDeltaPhiSigSig"), deltaPhi); - } - // S(D0) x B(D0bar) correlation - if ((cand2.mAntiLambda() > ConfD0D0barSideBand.confMinInvMassLeftSB.value && cand2.mAntiLambda() < ConfD0D0barSideBand.confMaxInvMassLeftSB.value) || - (cand2.mAntiLambda() > ConfD0D0barSideBand.confMinInvMassRightSB.value && cand2.mAntiLambda() < ConfD0D0barSideBand.confMaxInvMassRightSB.value)) { - registry.fill(HIST("hDeltaPhiD0SigD0barBg"), deltaPhi); - } - } - if ((cand1.mLambda() > ConfD0D0barSideBand.confMinInvMassLeftSB.value && cand1.mLambda() < ConfD0D0barSideBand.confMaxInvMassLeftSB.value) || - (cand1.mLambda() > ConfD0D0barSideBand.confMinInvMassRightSB.value && cand1.mLambda() < ConfD0D0barSideBand.confMaxInvMassRightSB.value)) { - // B(D0) x S (D0bar) correlation - if (cand2.mAntiLambda() > ConfD0D0barSideBand.confSignalRegionMin.value && cand2.mAntiLambda() < ConfD0D0barSideBand.confSignalRegionMax.value) { - registry.fill(HIST("hDeltaPhiD0BgD0barSig"), deltaPhi); - } - // B(D0) x B(D0bar) correlation - if ((cand2.mAntiLambda() > ConfD0D0barSideBand.confMinInvMassLeftSB.value && cand2.mAntiLambda() < ConfD0D0barSideBand.confMaxInvMassLeftSB.value) || - (cand2.mAntiLambda() > ConfD0D0barSideBand.confMinInvMassRightSB.value && cand2.mAntiLambda() < ConfD0D0barSideBand.confMaxInvMassRightSB.value)) { - registry.fill(HIST("hDeltaPhiBgBg"), deltaPhi); - } - } - } // It is the end of the for loop over D0bar mesons - } // It is the end of the for loop over all candidates - } - PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processSideBand, "Enable processing side-band methode", false); - /// This function processes the same event and takes care of all the histogramming /// \todo the trivial loops over the tracks should be factored out since they will be common to all combinations of T-T, T-V0, V0-V0, ... /// @tparam PartitionType @@ -617,23 +829,33 @@ struct FemtoUniversePairTaskTrackD0 { continue; } } + // Soft Pion Removal + if (confRemoveSoftPions) { + if (softPionRemoval.isSoftPion(track, d0candidate, parts, confSoftPionD0Flag, confSoftPionD0barFlag, sigmaSoftPiInvMass)) { + continue; + } + } // // Close Pair Rejection if (confIsCPR.value) { if (pairCloseRejection.isClosePair(track, d0candidate, parts, magFieldTesla, femto_universe_container::EventType::same)) { continue; } } - // Track Cleaning if (!pairCleaner.isCleanPair(track, d0candidate, parts)) { continue; } - sameEventFemtoCont.setPair(track, d0candidate, multCol, ConfBothTracks.confUse3D); - sameEventAngularCont.setPair(track, d0candidate, multCol, ConfBothTracks.confUse3D); + // Efficiency + weight = 1.0f; + if (doEfficiencyCorr) { + weight = efficiencyCalculator.getWeight(ParticleNo::ONE, track.pt()) * efficiencyCalculator.getWeight(ParticleNo::TWO, d0candidate.pt()); + } + sameEventAngularCont.setPair(track, d0candidate, multCol, ConfBothTracks.confUse3D, weight); } } /// process function for to call doSameEvent with Data + /// call this process function if you need D0/D0bar candidates which pass only one mass hypothesis /// \param col subscribe to the collision table (Data) /// \param parts subscribe to the femtoUniverseParticleTable void processSameEvent(o2::aod::FdCollision const& col, @@ -642,8 +864,6 @@ struct FemtoUniversePairTaskTrackD0 { fillCollision(col); auto thegroupPartsTrack = partsTrack->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsAllD0D0bar = partsAllDmesons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsOnlyD0D0bar = partsOnlyD0D0bar->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto theGroupPartsD0s = partsD0s->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto theGroupPartsD0bars = partsD0bars->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); @@ -654,17 +874,52 @@ struct FemtoUniversePairTaskTrackD0 { case 1: doSameEvent(thegroupPartsTrack, theGroupPartsD0bars, parts, col.magField(), col.multNtr()); break; - case 2: - doSameEvent(thegroupPartsTrack, thegroupPartsOnlyD0D0bar, parts, col.magField(), col.multNtr()); + default: + break; + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processSameEvent, "Enable processing same event", true); + + /// process function for to call doSameEvent with Data + /// call this process function to include candidates which pass as well the selection for both D0 and D0bar candidates + /// \param col subscribe to the collision table (Data) + /// \param parts subscribe to the femtoUniverseParticleTable + void processSameEventWithDoubleHypo(o2::aod::FdCollision const& col, + FemtoFullParticles const& parts) + { + fillCollision(col); + + auto thegroupPartsTrack = partsTrack->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto theGroupPartsD0s = partsAllD0s->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto theGroupPartsD0bars = partsAllD0bars->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + + switch (confChooseD0trackCorr) { + case 0: + doSameEvent(thegroupPartsTrack, theGroupPartsD0s, parts, col.magField(), col.multNtr()); break; - case 3: - doSameEvent(thegroupPartsTrack, thegroupPartsAllD0D0bar, parts, col.magField(), col.multNtr()); + case 1: + doSameEvent(thegroupPartsTrack, theGroupPartsD0bars, parts, col.magField(), col.multNtr()); break; default: break; } } - PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processSameEvent, "Enable processing same event", true); + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processSameEventWithDoubleHypo, "Enable processing same event", false); + + /// process function for to call doSameEvent with Data + /// call this process to obtain the function for D0/D0bar candidates from side-band regions + /// \param col subscribe to the collision table (Data) + /// \param parts subscribe to the femtoUniverseParticleTable + void processSameEventSB(o2::aod::FdCollision const& col, FemtoFullParticles const& parts) + { + fillCollision(col); + + auto groupPartsTrack = partsTrack->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsD0sFromSB = partsD0sFromSB->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + + doSameEvent(groupPartsTrack, groupPartsD0sFromSB, parts, col.magField(), col.multNtr()); + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processSameEventSB, "Enable processing same event", false); /// process function for to call doSameEvent with Monte Carlo /// \param col subscribe to the collision table (Monte Carlo Reconstructed reconstructed) @@ -676,8 +931,8 @@ struct FemtoUniversePairTaskTrackD0 { { fillCollision(col); - auto thegroupPartsD0 = partsD0D0barMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsTrack = partsTrackMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegroupPartsD0 = partsD0D0barMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegroupPartsTrack = partsTrackMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); doSameEvent(thegroupPartsTrack, thegroupPartsD0, parts, col.magField(), col.multNtr()); } @@ -703,32 +958,45 @@ struct FemtoUniversePairTaskTrackD0 { continue; } } + // // Soft Pion Removal + if (confRemoveSoftPions) { + if (softPionRemoval.isSoftPion(track, d0candidate, parts, confSoftPionD0Flag, confSoftPionD0barFlag, sigmaSoftPiInvMass)) { + continue; + } + } // // Close Pair Rejection if (confIsCPR.value) { if (pairCloseRejection.isClosePair(track, d0candidate, parts, magFieldTesla, femto_universe_container::EventType::mixed)) { continue; } } + // // Track Cleaning + if (!pairCleaner.isCleanPair(track, d0candidate, parts)) { + continue; + } + // Efficiency + weight = 1.0f; + if (doEfficiencyCorr) { + weight = efficiencyCalculator.getWeight(ParticleNo::ONE, track.pt()) * efficiencyCalculator.getWeight(ParticleNo::TWO, d0candidate.pt()); + } - mixedEventFemtoCont.setPair(track, d0candidate, multCol, ConfBothTracks.confUse3D); - mixedEventAngularCont.setPair(track, d0candidate, multCol, ConfBothTracks.confUse3D); + mixedEventAngularCont.setPair(track, d0candidate, multCol, ConfBothTracks.confUse3D, weight); } } /// process function for to call doMixedEvent with Data + /// call this process function if you need D0/D0bar candidates which pass only one mass hypothesis /// @param cols subscribe to the collisions table (Data) /// @param parts subscribe to the femtoUniverseParticleTable void processMixedEvent(o2::aod::FdCollisions const& cols, FemtoFullParticles const& parts) { - for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, confNEventsMix, -1, cols, cols)) { const int multiplicityCol = collision1.multNtr(); mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); auto groupPartsTrack = partsTrack->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); - auto groupPartsAllD0D0bar = partsAllDmesons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); - auto groupPartsOnlyD0D0bar = partsOnlyD0D0bar->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); auto theGroupPartsD0s = partsD0s->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); auto theGroupPartsD0bars = partsD0bars->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); @@ -748,18 +1016,79 @@ struct FemtoUniversePairTaskTrackD0 { case 1: doMixedEvent(groupPartsTrack, theGroupPartsD0bars, parts, magFieldTesla1, multiplicityCol); break; - case 2: - doMixedEvent(groupPartsTrack, groupPartsOnlyD0D0bar, parts, magFieldTesla1, multiplicityCol); + default: break; - case 3: - doMixedEvent(groupPartsTrack, groupPartsAllD0D0bar, parts, magFieldTesla1, multiplicityCol); + } + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processMixedEvent, "Enable processing mixed events", true); + + /// process function for to call doMixedEvent with Data + /// call this process function to include candidates which pass as well the selection for both D0 and D0bar candidates + /// @param cols subscribe to the collisions table (Data) + /// @param parts subscribe to the femtoUniverseParticleTable + void processMixedEventWithDoubleHypo(o2::aod::FdCollisions const& cols, + FemtoFullParticles const& parts) + { + for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, confNEventsMix, -1, cols, cols)) { + + const int multiplicityCol = collision1.multNtr(); + mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + + auto groupPartsTrack = partsTrack->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + auto theGroupPartsD0s = partsAllD0s->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto theGroupPartsD0bars = partsAllD0bars->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + continue; + } + /// \todo before mixing we should check whether both collisions contain a pair of particles! + // if (partsD0.size() == 0 || kNPart2Evt1 == 0 || kNPart1Evt2 == 0 || partsTrack.size() == 0 ) continue; + + switch (confChooseD0trackCorr) { + case 0: + doMixedEvent(groupPartsTrack, theGroupPartsD0s, parts, magFieldTesla1, multiplicityCol); + break; + case 1: + doMixedEvent(groupPartsTrack, theGroupPartsD0bars, parts, magFieldTesla1, multiplicityCol); break; default: break; } } } - PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processMixedEvent, "Enable processing mixed events", true); + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processMixedEventWithDoubleHypo, "Enable processing mixed events", false); + + /// process function for to call doMixedEvent with Data + /// call this process to obtain the function for D0/D0bar candidates from side-band regions + /// @param cols subscribe to the collisions table (Data) + /// @param parts subscribe to the femtoUniverseParticleTable + void processMixedEventSB(o2::aod::FdCollisions const& cols, FemtoFullParticles const& parts) + { + for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, confNEventsMix, -1, cols, cols)) { + + const int multiplicityCol = collision1.multNtr(); + mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + + auto groupPartsTrack = partsTrack->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + auto groupPartsD0sFromSB = partsD0sFromSB->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + continue; + } + /// \todo before mixing we should check whether both collisions contain a pair of particles! + // if (partsD0.size() == 0 || kNPart2Evt1 == 0 || kNPart1Evt2 == 0 || partsTrack.size() == 0 ) continue; + + doMixedEvent(groupPartsTrack, groupPartsD0sFromSB, parts, magFieldTesla1, multiplicityCol); + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processMixedEventSB, "Enable processing mixed events", false); /// brief process function for to call doMixedEvent with Monte Carlo /// @param cols subscribe to the collisions table (Monte Carlo Reconstructed reconstructed) @@ -769,13 +1098,13 @@ struct FemtoUniversePairTaskTrackD0 { soa::Join const& parts, o2::aod::FdMCParticles const&) { - for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, confNEventsMix, -1, cols, cols)) { const int multiplicityCol = collision1.multNtr(); mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); - auto groupPartsTrack = partsTrackMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); - auto groupPartsD0 = partsD0D0barMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTrack = partsTrackMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + auto groupPartsD0 = partsD0D0barMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); const auto& magFieldTesla1 = collision1.magField(); const auto& magFieldTesla2 = collision2.magField(); @@ -790,6 +1119,66 @@ struct FemtoUniversePairTaskTrackD0 { } } PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processMixedEventMC, "Enable processing mixed events MC", false); + + void processMCReco(FemtoMCParticles const&, aod::FdMCParticles const&) + { + // WORK IN PROGRESS + // for (auto const& part : parts) {} + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processMCReco, "Process MC reco data", false); + + void processMCTruth(aod::FDParticles const& parts) // WORK IN PROGRESS + { + for (auto const& part : parts) { + if (part.partType() != uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) + continue; + + int pdgCode = static_cast(part.pidCut()); + const auto& pdgParticle = pdgMC->GetParticle(pdgCode); + if (!pdgParticle) { + continue; + } + + if (pdgParticle->Charge() > 0.0) { + mcTruthRegistry.fill(HIST("MCTruthAllPositivePt"), part.pt()); + } + if (pdgCode == 211) { + mcTruthRegistry.fill(HIST("MCTruthPipPtVsEta"), part.pt(), part.eta()); + mcTruthRegistry.fill(HIST("MCTruthPipPt"), part.pt()); + } + if (pdgCode == 321) { + mcTruthRegistry.fill(HIST("MCTruthKpPtVsEta"), part.pt(), part.eta()); + mcTruthRegistry.fill(HIST("MCTruthKpPt"), part.pt()); + } + if (pdgCode == 421) { + mcTruthRegistry.fill(HIST("MCTruthD0D0bar"), part.pt(), part.eta()); + } + if (pdgCode == 2212) { + mcTruthRegistry.fill(HIST("MCTruthProtonPtVsEta"), part.pt(), part.eta()); + mcTruthRegistry.fill(HIST("MCTruthProtonPt"), part.pt()); + } + + if (pdgParticle->Charge() < 0.0) { + mcTruthRegistry.fill(HIST("MCTruthAllNegativePt"), part.pt()); + } + if (pdgCode == -211) { + mcTruthRegistry.fill(HIST("MCTruthPimPtVsEta"), part.pt(), part.eta()); + mcTruthRegistry.fill(HIST("MCTruthPimPt"), part.pt()); + } + if (pdgCode == -321) { + mcTruthRegistry.fill(HIST("MCTruthKmPtVsEta"), part.pt(), part.eta()); + mcTruthRegistry.fill(HIST("MCTruthKmPt"), part.pt()); + } + if (pdgCode == -421) { + mcTruthRegistry.fill(HIST("MCTruthD0D0bar"), part.pt(), part.eta()); + } + if (pdgCode == -2212) { + mcTruthRegistry.fill(HIST("MCTruthAntiProtonPtVsEta"), part.pt(), part.eta()); + mcTruthRegistry.fill(HIST("MCTruthAntiProtonPt"), part.pt()); + } + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackD0, processMCTruth, "Process MC truth data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackNucleus.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackNucleus.cxx index 2fc7a7cf2fa..f5fe1dc91a4 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackNucleus.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackNucleus.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackPhi.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackPhi.cxx index 00816d630f5..98a697434ac 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackPhi.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackPhi.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -16,32 +16,31 @@ /// \author Anton Riedel, TU München, anton.riedel@tum.de /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch -#include -#include +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCorrection.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" + +#include "Framework/ASoAHelpers.h" #include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/StepTHn.h" #include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/PID.h" -#include "Common/DataModel/PIDResponse.h" -#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" -#include "PWGCF/FemtoUniverse/Core/femtoUtils.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" #include #include -#include "CCDB/BasicCCDBManager.h" + +#include +#include using namespace o2; using namespace o2::analysis::femto_universe; +using namespace o2::analysis::femto_universe::efficiency_correction; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; @@ -61,108 +60,119 @@ struct FemtoUniversePairTaskTrackPhi { Service pdgMC; - using FemtoFullParticles = soa::Join; + using FilteredFemtoFullParticles = soa::Join; + SliceCache cache; - Preslice perCol = aod::femtouniverseparticle::fdCollisionId; + Preslice perCol = aod::femtouniverseparticle::fdCollisionId; using FemtoRecoParticles = soa::Join; Preslice perColMC = aod::femtouniverseparticle::fdCollisionId; - // Efficiency - struct : o2::framework::ConfigurableGroup { - Configurable confEfficiencyTrackPath{"confEfficiencyTrackPath", "", "Local path to proton efficiency TH2F file"}; - Configurable confEfficiencyPhiPath{"confEfficiencyPhiPath", "", "Local path to Phi efficiency TH2F file"}; - Configurable confEfficiencyTrackTimestamp{"confEfficiencyTrackTimestamp", 0, "(int64_t) Timestamp for hadron"}; - Configurable confEfficiencyPhiTimestamp{"confEfficiencyPhiTimestamp", 0, "(int64_t) Timestamp for phi"}; - } ConfEff; - - struct : o2::framework::ConfigurableGroup { - Configurable confCPRIsEnabled{"confCPRIsEnabled", false, "Close Pair Rejection"}; - Configurable confCPRPlotPerRadii{"confCPRPlotPerRadii", false, "Plot CPR per radii"}; - Configurable confCPRdeltaPhiCutMax{"confCPRdeltaPhiCutMax", 0.0, "Delta Phi max cut for Close Pair Rejection"}; - Configurable confCPRdeltaPhiCutMin{"confCPRdeltaPhiCutMin", 0.0, "Delta Phi min cut for Close Pair Rejection"}; - Configurable confCPRdeltaEtaCutMax{"confCPRdeltaEtaCutMax", 0.0, "Delta Eta max cut for Close Pair Rejection"}; - Configurable confCPRdeltaEtaCutMin{"confCPRdeltaEtaCutMin", 0.0, "Delta Eta min cut for Close Pair Rejection"}; - Configurable confCPRInvMassCutMin{"confCPRInvMassCutMin", 1.014, "Invariant mass (low) cut for Close Pair Rejection"}; - Configurable confCPRInvMassCutMax{"confCPRInvMassCutMax", 1.026, "Invariant mass (high) cut for Close Pair Rejection"}; - Configurable confCPRChosenRadii{"confCPRChosenRadii", 0.80, "Delta Eta cut for Close Pair Rejection"}; - } ConfCPR; + Configurable ConfZVertexCut{"ConfZVertexCut", 10.f, "Event sel: Maximum z-Vertex (cm)"}; + Configurable ConfNEventsMix{"ConfNEventsMix", 5, "Number of events for mixing"}; + Filter collisionFilter = (nabs(aod::collision::posZ) < ConfZVertexCut); + using FilteredFDCollisions = soa::Filtered; + using FilteredFDCollision = FilteredFDCollisions::iterator; + + Configurable ConfCPRIsEnabled{"ConfCPRIsEnabled", false, "Close Pair Rejection"}; + Configurable ConfCPRPlotPerRadii{"ConfCPRPlotPerRadii", false, "Plot CPR per radii"}; + Configurable ConfCPRdeltaPhiCutMax{"ConfCPRdeltaPhiCutMax", 0.0, "Delta Phi max cut for Close Pair Rejection"}; + Configurable ConfCPRdeltaPhiCutMin{"ConfCPRdeltaPhiCutMin", 0.0, "Delta Phi min cut for Close Pair Rejection"}; + Configurable ConfCPRdeltaEtaCutMax{"ConfCPRdeltaEtaCutMax", 0.0, "Delta Eta max cut for Close Pair Rejection"}; + Configurable ConfCPRdeltaEtaCutMin{"ConfCPRdeltaEtaCutMin", 0.0, "Delta Eta min cut for Close Pair Rejection"}; + Configurable ConfCPRInvMassCutMin{"ConfCPRInvMassCutMin", 1.014, "Invariant mass (low) cut for Close Pair Rejection"}; + Configurable ConfCPRInvMassCutMax{"ConfCPRInvMassCutMax", 1.026, "Invariant mass (high) cut for Close Pair Rejection"}; + Configurable ConfCPRChosenRadii{"ConfCPRChosenRadii", 0.80, "Delta Eta cut for Close Pair Rejection"}; /// Table for both particles - struct : o2::framework::ConfigurableGroup { - Configurable confPIDProtonNsigmaCombined{"confPIDProtonNsigmaCombined", 3.0, "TPC and TOF Proton Sigma (combined) for momentum > 0.5"}; - Configurable confPIDProtonNsigmaTPC{"confPIDProtonNsigmaTPC", 3.0, "TPC Proton Sigma for momentum < 0.5"}; - Configurable confPIDKaonNsigmaReject{"confPIDKaonNsigmaReject", 3.0, "Reject if particle could be a Kaon combined nsigma value."}; - Configurable confPIDPionNsigmaReject{"confPIDPionNsigmaReject", 3.0, "Reject if particle could be a Pion combined nsigma value."}; - Configurable confPIDProtonNsigmaReject{"confPIDProtonNsigmaReject", 3.0, "Reject if particle could be a Proton combined nsigma value."}; - Configurable confPIDPionNsigmaCombined{"confPIDPionNsigmaCombined", 3.0, "TPC and TOF Pion Sigma (combined) for momentum > 0.5"}; - Configurable confPIDPionNsigmaTPC{"confPIDPionNsigmaTPC", 3.0, "TPC Pion Sigma for momentum < 0.5"}; - - // Configurable> confCutTable{"confCutTable", {cutsTable[0], NPart, NCuts, partNames, cutNames}, "Particle selections"}; //unused - // Configurable confNspecies{"confNspecies", 2, "Number of particle spieces with PID info"}; //unused - Configurable confIsMC{"confIsMC", false, "Enable additional Histograms in the case of a MonteCarlo Run"}; - Configurable> confTrkPIDnSigmaMax{"confTrkPIDnSigmaMax", std::vector{4.f, 3.f, 2.f}, "This configurable needs to be the same as the one used in the producer task"}; - Configurable confUse3D{"confUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; - Configurable confBinsPhi{"confBinsPhi", 29, "Number of phi bins in deta dphi"}; - Configurable confBinsEta{"confBinsEta", 29, "Number of eta bins in deta dphi"}; - } ConfBothTracks; + Configurable ConfPIDProtonNsigmaCombined{"ConfPIDProtonNsigmaCombined", 3.0, "TPC and TOF Proton Sigma (combined) for momentum > 0.5"}; + Configurable ConfPIDProtonNsigmaTPC{"ConfPIDProtonNsigmaTPC", 3.0, "TPC Proton Sigma for momentum < 0.5"}; + Configurable ConfPIDKaonNsigmaReject{"ConfPIDKaonNsigmaReject", 3.0, "Reject if particle could be a Kaon combined nsigma value."}; + Configurable ConfPIDPionNsigmaReject{"ConfPIDPionNsigmaReject", 3.0, "Reject if particle could be a Pion combined nsigma value."}; + Configurable ConfPIDProtonNsigmaReject{"ConfPIDProtonNsigmaReject", 3.0, "Reject if particle could be a Proton combined nsigma value."}; + Configurable ConfPIDPionNsigmaCombined{"ConfPIDPionNsigmaCombined", 3.0, "TPC and TOF Pion Sigma (combined) for momentum > 0.5"}; + Configurable ConfPIDPionNsigmaTPC{"ConfPIDPionNsigmaTPC", 3.0, "TPC Pion Sigma for momentum < 0.5"}; + Configurable ConfIsMC{"ConfIsMC", false, "Enable additional Histograms in the case of a MonteCarlo Run"}; + Configurable ConfUse3D{"ConfUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; + Configurable ConfBinsPhi{"ConfBinsPhi", 29, "Number of phi bins in deta dphi"}; + Configurable ConfBinsEta{"ConfBinsEta", 29, "Number of eta bins in deta dphi"}; /// Particle 1 --- IDENTIFIED TRACK - struct : o2::framework::ConfigurableGroup { - Configurable confTrackIsSame{"confTrackIsSame", false, "Pairs of the same particle"}; - Configurable confTrackPDGCode{"confTrackPDGCode", 2212, "Particle 2 - PDG code"}; - Configurable confTrackPID{"confTrackPID", 2, "Particle 2 - Read from cutCulator"}; // we also need the possibility to specify whether the bit is true/false ->std>>vector> - Configurable confTrackSign{"confTrackSign", 1, "Track sign"}; - Configurable confTrackIsIdentified{"confTrackIsIdentified", true, "Enable PID for the track"}; - Configurable confTrackIsRejected{"confTrackIsRejected", true, "Enable PID rejection for the track other species than the identified one."}; - Configurable confTrackPtLowLimit{"confTrackPtLowLimit", 0.5, "Lower limit of the Phi pT."}; - Configurable confTrackPtHighLimit{"confTrackPtHighLimit", 2.5, "Higher limit of the Phi pT."}; - } ConfTrack; - - /// Partitions for particle 1 - Partition partsTrack = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == ConfTrack.confTrackSign.value) && (aod::femtouniverseparticle::pt > ConfTrack.confTrackPtLowLimit.value) && (aod::femtouniverseparticle::pt < ConfTrack.confTrackPtHighLimit.value); - Partition> partsTrackMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == ConfTrack.confTrackSign.value) && (aod::femtouniverseparticle::pt > ConfTrack.confTrackPtLowLimit.value) && (aod::femtouniverseparticle::pt < ConfTrack.confTrackPtHighLimit.value); - - /// Partitions for particle 2 - Partition partsPhi = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kPhi)); - Partition> partsPhiMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kPhi)); + Configurable ConfTrackPDGCode{"ConfTrackPDGCode", 2212, "Particle 2 - PDG code"}; + Configurable ConfTrackSign{"ConfTrackSign", 1, "Track sign"}; + Configurable ConfTrackIsIdentified{"ConfTrackIsIdentified", true, "Enable PID for the track"}; + Configurable ConfTrackIsRejected{"ConfTrackIsRejected", true, "Enable PID rejection for the track other species than the identified one."}; + Configurable ConfTrackPtPIDLimit{"ConfTrackPtPIDLimit", 0.5, "Momentum threshold for change of the PID method (from using TPC to TPC and TOF)."}; + Configurable ConfTrackPtLow{"ConfTrackPtLow", 0.5, "Lower limit of the hadron pT."}; + Configurable ConfTrackPtHigh{"ConfTrackPtHigh", 2.5, "Higher limit of the hadron pT."}; + + /// Partitions for the track (particle 1) + Partition partsTrack = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && + (aod::femtouniverseparticle::sign == ConfTrackSign) && + (aod::femtouniverseparticle::pt > ConfTrackPtLow) && + (aod::femtouniverseparticle::pt < ConfTrackPtHigh); + + Partition partsTrackMCReco = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && + (aod::femtouniverseparticle::sign == ConfTrackSign) && + (aod::femtouniverseparticle::pt > ConfTrackPtLow) && + (aod::femtouniverseparticle::pt < ConfTrackPtHigh); + + /// Particle 2 --- PHI MESON + Configurable ConfPhiPtLow{"ConfPhiPtLow", 0.8, "Lower limit of the Phi pT."}; + Configurable ConfPhiPtHigh{"ConfPhiPtHigh", 4.0, "Higher limit of the Phi pT."}; + Configurable confInvMassLowLimitPhi{"confInvMassLowLimitPhi", 1.011, "Lower limit of the Phi invariant mass"}; // change that to do invariant mass cut + Configurable confInvMassUpLimitPhi{"confInvMassUpLimitPhi", 1.027, "Upper limit of the Phi invariant mass"}; + + /// Partitions for the Phi meson (particle 2) + Partition partsPhi = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kPhi)) && + (aod::femtouniverseparticle::pt > ConfPhiPtLow) && + (aod::femtouniverseparticle::pt < ConfPhiPtHigh) && + (aod::femtouniverseparticle::tempFitVar > confInvMassLowLimitPhi) && + (aod::femtouniverseparticle::tempFitVar < confInvMassUpLimitPhi); + + Partition partsPhiMCReco = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kPhi)) && + (aod::femtouniverseparticle::pt > ConfPhiPtLow) && + (aod::femtouniverseparticle::pt < ConfPhiPtHigh) && + (aod::femtouniverseparticle::tempFitVar > confInvMassLowLimitPhi) && + (aod::femtouniverseparticle::tempFitVar < confInvMassUpLimitPhi); /// Partitions for Phi daughters kPhiChild - Partition partsPhiDaugh = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kPhiChild)); - Partition> partsPhiDaughMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kPhiChild)); + Partition partsPhiDaugh = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kPhiChild)); + Partition> partsPhiDaughMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kPhiChild)); // Partition for K+K- minv - Partition partsKaons = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)); - Partition> partsKaonsMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)); + Partition partsKaons = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)); + Partition> partsKaonsMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)); /// Histogramming for particle 1 - FemtoUniverseParticleHisto trackHistoPartTrack; + FemtoUniverseParticleHisto trackHistoPartTrack; + FemtoUniverseParticleHisto hTrackDCA; /// Histogramming for particle 2 - FemtoUniverseParticleHisto trackHistoPartPhi; + FemtoUniverseParticleHisto trackHistoPartPhi; /// Histogramming for Event FemtoUniverseEventHisto eventHisto; /// particle part - ConfigurableAxis confBinsTempFitVar{"confBinsTempFitVar", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; - ConfigurableAxis confBinsTempFitVarInvMass{"confBinsTempFitVarInvMass", {6000, 0.9, 4.0}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; - ConfigurableAxis confBinsTempFitVarpT{"confBinsTempFitVarpT", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfBinsTempFitVar{"ConfBinsTempFitVar", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfBinsTempFitVarInvMass{"ConfBinsTempFitVarInvMass", {6000, 0.9, 4.0}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfBinsTempFitVarpT{"ConfBinsTempFitVarpT", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfBinsTempFitVarPDG{"ConfBinsTempFitVarPDG", {6000, -2300, 2300}, "Binning of the PDG code in the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfBinsTempFitVarDCA{"ConfBinsTempFitVarDCA", {300, -3.0, 3.0}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; /// Correlation part - ConfigurableAxis confBinsMult{"confBinsMult", {VARIABLE_WIDTH, 0.0f, 4.0f, 8.0f, 12.0f, 16.0f, 20.0f, 24.0f, 28.0f, 32.0f, 36.0f, 40.0f, 44.0f, 48.0f, 52.0f, 56.0f, 60.0f, 64.0f, 68.0f, 72.0f, 76.0f, 80.0f, 84.0f, 88.0f, 92.0f, 96.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - multiplicity"}; // \todo to be obtained from the hash task - ConfigurableAxis confBinsVtx{"confBinsVtx", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; - ConfigurableAxis confBins3DmT{"confBins3DmT", {VARIABLE_WIDTH, 1.02f, 1.14f, 1.20f, 1.26f, 1.38f, 1.56f, 1.86f, 4.50f}, "mT Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; - ConfigurableAxis confBins3Dmult{"confBins3Dmult", {VARIABLE_WIDTH, 0.0f, 20.0f, 30.0f, 40.0f, 99999.0f}, "multiplicity Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; - - ColumnBinningPolicy colBinning{{confBinsVtx, confBinsMult}, true}; + ConfigurableAxis ConfBinsMult{"ConfBinsMult", {VARIABLE_WIDTH, 0.0f, 4.0f, 8.0f, 12.0f, 16.0f, 20.0f, 24.0f, 28.0f, 32.0f, 36.0f, 40.0f, 44.0f, 48.0f, 52.0f, 56.0f, 60.0f, 64.0f, 68.0f, 72.0f, 76.0f, 80.0f, 84.0f, 88.0f, 92.0f, 96.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - multiplicity"}; // \todo to be obtained from the hash task + ConfigurableAxis ConfBinsVtx{"ConfBinsVtx", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis ConfBins3DmT{"ConfBins3DmT", {VARIABLE_WIDTH, 1.02f, 1.14f, 1.20f, 1.26f, 1.38f, 1.56f, 1.86f, 4.50f}, "mT Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; + ConfigurableAxis ConfBins3Dmult{"ConfBins3Dmult", {VARIABLE_WIDTH, 0.0f, 20.0f, 30.0f, 40.0f, 99999.0f}, "multiplicity Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; - ConfigurableAxis confBinskstar{"confBinskstar", {1500, 0., 6.}, "binning kstar"}; - ConfigurableAxis confBinskT{"confBinskT", {150, 0., 9.}, "binning kT"}; - ConfigurableAxis confBinsmT{"confBinsmT", {225, 0., 7.5}, "binning mT"}; + ConfigurableAxis ConfBinskstar{"ConfBinskstar", {1500, 0., 6.}, "binning kstar"}; + ConfigurableAxis ConfBinskT{"ConfBinskT", {150, 0., 9.}, "binning kT"}; + ConfigurableAxis ConfBinsmT{"ConfBinsmT", {225, 0., 7.5}, "binning mT"}; - FemtoUniverseAngularContainer sameEventAngularCont; - FemtoUniverseAngularContainer mixedEventAngularCont; + FemtoUniverseContainer sameEventCont; + FemtoUniverseContainer mixedEventCont; FemtoUniversePairCleaner pairCleaner; FemtoUniverseDetaDphiStar pairCloseRejection; FemtoUniverseTrackSelection trackCuts; @@ -174,22 +184,29 @@ struct FemtoUniversePairTaskTrackPhi { HistogramRegistry registryMCtruth{"registryMCtruth", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; HistogramRegistry registryMCreco{"registryMCreco", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; HistogramRegistry registryPhiMinvBackground{"registryPhiMinvBackground", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry registryDCA{"registryDCA", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry registryMCpT{"registryMCpT", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + + ColumnBinningPolicy colBinning{{ConfBinsVtx, ConfBinsMult}, true}; + + HistogramRegistry effCorrRegistry{"EfficiencyCorrection", {}, OutputObjHandlingPolicy::AnalysisObject}; - Service ccdb; - TH2F* protoneff; - TH2F* phieff; + EffCorConfigurableGroup effCorConfGroup; + EfficiencyCorrection effCorrection{&effCorConfGroup}; + + float weight = 1; // PID for protons bool isProtonNSigma(float mom, float nsigmaTPCPr, float nsigmaTOFPr) // previous version from: https://github.com/alisw/AliPhysics/blob/master/PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoMJTrackCut.cxx { - if (mom < 0.5) { - if (std::abs(nsigmaTPCPr) < ConfBothTracks.confPIDProtonNsigmaTPC.value) { + if (mom < ConfTrackPtPIDLimit) { + if (std::abs(nsigmaTPCPr) < ConfPIDProtonNsigmaTPC) { return true; } else { return false; } - } else if (mom > 0.4) { - if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.confPIDProtonNsigmaCombined.value) { + } else if (mom > ConfTrackPtPIDLimit) { + if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfPIDProtonNsigmaCombined) { return true; } else { return false; @@ -204,9 +221,9 @@ struct FemtoUniversePairTaskTrackPhi { return true; } if (mom > 0.5) { - if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.confPIDPionNsigmaReject.value) { + if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfPIDPionNsigmaReject) { return true; - } else if (std::hypot(nsigmaTOFK, nsigmaTPCK) < ConfBothTracks.confPIDKaonNsigmaReject.value) { + } else if (std::hypot(nsigmaTOFK, nsigmaTPCK) < ConfPIDKaonNsigmaReject) { return true; } else { return false; @@ -258,16 +275,16 @@ struct FemtoUniversePairTaskTrackPhi { bool isKaonRejected(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi) { if (mom < 0.5) { - if (std::abs(nsigmaTPCPi) < ConfBothTracks.confPIDPionNsigmaReject.value) { + if (std::abs(nsigmaTPCPi) < ConfPIDPionNsigmaReject) { return true; - } else if (std::abs(nsigmaTPCPr) < ConfBothTracks.confPIDProtonNsigmaReject.value) { + } else if (std::abs(nsigmaTPCPr) < ConfPIDProtonNsigmaReject) { return true; } } if (mom > 0.5) { - if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.confPIDPionNsigmaReject.value) { + if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfPIDPionNsigmaReject) { return true; - } else if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.confPIDProtonNsigmaReject.value) { + } else if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfPIDProtonNsigmaReject) { return true; } else { return false; @@ -281,13 +298,13 @@ struct FemtoUniversePairTaskTrackPhi { { if (true) { if (mom < 0.5) { - if (std::abs(nsigmaTPCPi) < ConfBothTracks.confPIDPionNsigmaTPC.value) { + if (std::abs(nsigmaTPCPi) < ConfPIDPionNsigmaTPC) { return true; } else { return false; } } else if (mom > 0.5) { - if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.confPIDPionNsigmaCombined.value) { + if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfPIDPionNsigmaCombined) { return true; } else { return false; @@ -300,16 +317,16 @@ struct FemtoUniversePairTaskTrackPhi { bool isPionRejected(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCK, float nsigmaTOFK) { if (mom < 0.5) { - if (std::abs(nsigmaTPCK) < ConfBothTracks.confPIDKaonNsigmaReject.value) { + if (std::abs(nsigmaTPCK) < ConfPIDKaonNsigmaReject) { return true; - } else if (std::abs(nsigmaTPCPr) < ConfBothTracks.confPIDProtonNsigmaReject.value) { + } else if (std::abs(nsigmaTPCPr) < ConfPIDProtonNsigmaReject) { return true; } } if (mom > 0.5) { - if (std::hypot(nsigmaTOFK, nsigmaTPCK) < ConfBothTracks.confPIDKaonNsigmaReject.value) { + if (std::hypot(nsigmaTOFK, nsigmaTPCK) < ConfPIDKaonNsigmaReject) { return true; - } else if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.confPIDProtonNsigmaReject.value) { + } else if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfPIDProtonNsigmaReject) { return true; } else { return false; @@ -321,7 +338,7 @@ struct FemtoUniversePairTaskTrackPhi { bool isParticleNSigmaAccepted(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK) { - switch (ConfTrack.confTrackPDGCode) { + switch (ConfTrackPDGCode) { case 2212: // Proton case -2212: // anty Proton return isProtonNSigma(mom, nsigmaTPCPr, nsigmaTOFPr); @@ -341,7 +358,7 @@ struct FemtoUniversePairTaskTrackPhi { bool isParticleNSigmaRejected(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK) { - switch (ConfTrack.confTrackPDGCode) { + switch (ConfTrackPDGCode) { case 2212: // Proton case -2212: // anty Proton return isProtonRejected(mom, nsigmaTPCPi, nsigmaTOFPi, nsigmaTPCK, nsigmaTOFK); @@ -359,8 +376,32 @@ struct FemtoUniversePairTaskTrackPhi { } } + /// @returns 1 if positive, -1 if negative, 0 if zero + auto sign(auto number) -> int8_t + { + return (number > 0) - (number < 0); + } + void init(InitContext&) { + if (ConfIsMC) { + hTrackDCA.init(®istryDCA, ConfBinsTempFitVarpT, ConfBinsTempFitVarDCA, true, ConfTrackPDGCode, true); + + registryMCpT.add("MCReco/C_phi_pT", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); + registryMCpT.add("MCReco/NC_phi_pT", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); + + registryMCpT.add("MCReco/C_p_pT", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); + registryMCpT.add("MCReco/NC_p_pT", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); + } + + effCorrection.init( + &effCorrRegistry, + { + static_cast(ConfBinsTempFitVarpT), + {ConfBinsEta, -1, 1}, + ConfBinsMult, + }); + eventHisto.init(&qaRegistry); qaRegistry.add("PhiDaugh_pos/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); qaRegistry.add("PhiDaugh_pos/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); @@ -379,171 +420,158 @@ struct FemtoUniversePairTaskTrackPhi { registryPhiMinvBackground.add("InvariantMassKpKp", "; invariant mass K+K+; Counts", kTH1F, {{6000, 0.9, 4.0}}); registryPhiMinvBackground.add("InvariantMassKmKm", "; invariant mass K-K-; Counts", kTH1F, {{6000, 0.9, 4.0}}); - qaRegistry.add("Hadron/nSigmaTPCPr", "; #it{p} (GeV/#it{c}); n#sigma_{TPCPr}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); - qaRegistry.add("Hadron/nSigmaTOFPr", "; #it{p} (GeV/#it{c}); n#sigma_{TOFPr}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); - qaRegistry.add("Hadron/nSigmaTPCPi", "; #it{p} (GeV/#it{c}); n#sigma_{TPCPi}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); - qaRegistry.add("Hadron/nSigmaTOFPi", "; #it{p} (GeV/#it{c}); n#sigma_{TOFPi}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); - qaRegistry.add("Hadron/nSigmaTPCKa", "; #it{p} (GeV/#it{c}); n#sigma_{TPCKa}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); - qaRegistry.add("Hadron/nSigmaTOFKa", "; #it{p} (GeV/#it{c}); n#sigma_{TOFKa}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_pos/nSigmaTPCPr", "; #it{p} (GeV/#it{c}); n#sigma_{TPCPr}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_pos/nSigmaTOFPr", "; #it{p} (GeV/#it{c}); n#sigma_{TOFPr}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_pos/nSigmaTPCPi", "; #it{p} (GeV/#it{c}); n#sigma_{TPCPi}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_pos/nSigmaTOFPi", "; #it{p} (GeV/#it{c}); n#sigma_{TOFPi}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_pos/nSigmaTPCKa", "; #it{p} (GeV/#it{c}); n#sigma_{TPCKa}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_pos/nSigmaTOFKa", "; #it{p} (GeV/#it{c}); n#sigma_{TOFKa}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + + qaRegistry.add("Hadron_neg/nSigmaTPCPr", "; #it{p} (GeV/#it{c}); n#sigma_{TPCPr}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_neg/nSigmaTOFPr", "; #it{p} (GeV/#it{c}); n#sigma_{TOFPr}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_neg/nSigmaTPCPi", "; #it{p} (GeV/#it{c}); n#sigma_{TPCPi}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_neg/nSigmaTOFPi", "; #it{p} (GeV/#it{c}); n#sigma_{TOFPi}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_neg/nSigmaTPCKa", "; #it{p} (GeV/#it{c}); n#sigma_{TPCKa}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("Hadron_neg/nSigmaTOFKa", "; #it{p} (GeV/#it{c}); n#sigma_{TOFKa}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); // MC truth - registryMCtruth.add("MCtruthPhi", "MC truth Phi;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); registryMCtruth.add("MCtruthAllPositivePt", "MC truth all positive;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); registryMCtruth.add("MCtruthAllNegativePt", "MC truth all negative;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); + // K+ registryMCtruth.add("MCtruthKp", "MC truth K+;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); - registryMCtruth.add("MCtruthKm", "MC truth protons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); registryMCtruth.add("MCtruthKpPt", "MC truth kaons positive;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + // K- + registryMCtruth.add("MCtruthKm", "MC truth protons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); registryMCtruth.add("MCtruthKmPt", "MC truth kaons negative;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); - registryMCtruth.add("MCtruthPpos", "MC truth proton;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); - registryMCtruth.add("MCtruthPneg", "MC truth antiproton;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + // p + registryMCtruth.add("MCtruthPpos", "MC truth protons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCtruth.add("MCtruthPposPt", "MC truth protons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + // pbar + registryMCtruth.add("MCtruthPneg", "MC truth antiprotons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCtruth.add("MCtruthPnegPt", "MC truth antiproton;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + // phi + registryMCtruth.add("MCtruthPhi", "MC truth phi mesons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCtruth.add("MCtruthPhiPt", "MC truth phi mesons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); // MC reco - registryMCreco.add("MCrecoPhi", "MC reco Phi;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); registryMCreco.add("MCrecoAllPositivePt", "MC reco all;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); registryMCreco.add("MCrecoAllNegativePt", "MC reco all;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); + // p registryMCreco.add("MCrecoPpos", "MC reco proton;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCreco.add("MCrecoPposPt", "MC reco proton; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{500, 0, 5}}); + // pbar registryMCreco.add("MCrecoPneg", "MC reco antiproton;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCreco.add("MCrecoPnegPt", "MC reco antiproton; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{500, 0, 5}}); + // phi + registryMCreco.add("MCrecoPhi", "MC reco Phi;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCreco.add("MCrecoPhiPt", "MC reco Phi; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{500, 0, 5}}); - trackHistoPartPhi.init(&qaRegistry, confBinsTempFitVarpT, confBinsTempFitVarInvMass, ConfBothTracks.confIsMC, 333); - if (!ConfTrack.confTrackIsSame) { - trackHistoPartTrack.init(&qaRegistry, confBinsTempFitVarpT, confBinsTempFitVar, ConfBothTracks.confIsMC, ConfTrack.confTrackPDGCode); - } + trackHistoPartPhi.init(&qaRegistry, ConfBinsTempFitVarpT, ConfBinsTempFitVarInvMass, ConfIsMC, 333); + trackHistoPartTrack.init(&qaRegistry, ConfBinsTempFitVarpT, ConfBinsTempFitVar, ConfIsMC, ConfTrackPDGCode); mixQaRegistry.add("MixingQA/hSECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); mixQaRegistry.add("MixingQA/hMECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); - sameEventAngularCont.init(&resultRegistry, confBinskstar, confBinsMult, confBinskT, confBinsmT, confBins3Dmult, confBins3DmT, ConfBothTracks.confBinsEta, ConfBothTracks.confBinsPhi, ConfBothTracks.confIsMC, ConfBothTracks.confUse3D); - mixedEventAngularCont.init(&resultRegistry, confBinskstar, confBinsMult, confBinskT, confBinsmT, confBins3Dmult, confBins3DmT, ConfBothTracks.confBinsEta, ConfBothTracks.confBinsPhi, ConfBothTracks.confIsMC, ConfBothTracks.confUse3D); + sameEventCont.init(&resultRegistry, ConfBinskstar, ConfBinsMult, ConfBinskT, ConfBinsmT, ConfBins3Dmult, ConfBins3DmT, ConfBinsEta, ConfBinsPhi, ConfIsMC, ConfUse3D); + mixedEventCont.init(&resultRegistry, ConfBinskstar, ConfBinsMult, ConfBinskT, ConfBinsmT, ConfBins3Dmult, ConfBins3DmT, ConfBinsEta, ConfBinsPhi, ConfIsMC, ConfUse3D); - sameEventAngularCont.setPDGCodes(333, ConfTrack.confTrackPDGCode); - mixedEventAngularCont.setPDGCodes(333, ConfTrack.confTrackPDGCode); + sameEventCont.setPDGCodes(333, ConfTrackPDGCode); + mixedEventCont.setPDGCodes(333, ConfTrackPDGCode); pairCleaner.init(&qaRegistry); - if (ConfCPR.confCPRIsEnabled.value) { - pairCloseRejection.init(&resultRegistry, &qaRegistry, ConfCPR.confCPRdeltaPhiCutMin.value, ConfCPR.confCPRdeltaPhiCutMax.value, ConfCPR.confCPRdeltaEtaCutMin.value, ConfCPR.confCPRdeltaEtaCutMax.value, ConfCPR.confCPRChosenRadii.value, ConfCPR.confCPRPlotPerRadii.value, ConfCPR.confCPRInvMassCutMin.value, ConfCPR.confCPRInvMassCutMax.value); + if (ConfCPRIsEnabled) { + pairCloseRejection.init(&resultRegistry, &qaRegistry, ConfCPRdeltaPhiCutMin, ConfCPRdeltaPhiCutMax, ConfCPRdeltaEtaCutMin, ConfCPRdeltaEtaCutMax, ConfCPRChosenRadii, ConfCPRPlotPerRadii, ConfCPRInvMassCutMin, ConfCPRInvMassCutMax); } - - /// Initializing CCDB - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - - int64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - ccdb->setCreatedNotAfter(now); - - if (!ConfEff.confEfficiencyTrackPath.value.empty()) { - protoneff = ccdb->getForTimeStamp(ConfEff.confEfficiencyTrackPath.value.c_str(), ConfEff.confEfficiencyTrackTimestamp.value); - if (!protoneff || protoneff->IsZombie()) { - LOGF(fatal, "Could not load efficiency protoneff histogram from %s", ConfEff.confEfficiencyTrackPath.value.c_str()); - } - } - if (!ConfEff.confEfficiencyPhiPath.value.empty()) { - phieff = ccdb->getForTimeStamp(ConfEff.confEfficiencyPhiPath.value.c_str(), ConfEff.confEfficiencyPhiTimestamp.value); - if (!phieff || phieff->IsZombie()) { - LOGF(fatal, "Could not load efficiency phieff histogram from %s", ConfEff.confEfficiencyPhiPath.value.c_str()); - } - } - } - - template - void fillCollision(CollisionType col) - { - mixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multNtr()})); - eventHisto.fillQA(col); } - /// This function processes the same event and takes care of all the histogramming - /// \todo the trivial loops over the tracks should be factored out since they will be common to all combinations of T-T, T-V0, V0-V0, ... - /// @tparam PartitionType - /// @tparam PartType - /// @tparam isMC: enables Monte Carlo truth specific histograms - /// @param groupPartsTrack partition for the first particle passed by the process function - /// @param groupPartsPhi partition for the second particle passed by the process function - /// @param parts femtoUniverseParticles table (in case of Monte Carlo joined with FemtoUniverseMCLabels) - /// @param magFieldTesla magnetic field of the collision - /// @param multCol multiplicity of the collision - template - void doSameEvent(PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartitionType groupPartsPhiDaugh, PartitionType groupPartsKaons, PartType parts, float magFieldTesla, int multCol) + template + void doSameEvent(PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartType parts, float magFieldTesla, int multCol, [[maybe_unused]] MCParticles mcParts = nullptr) { - - /// Histogramming same event for (auto const& phicandidate : groupPartsPhi) { - trackHistoPartPhi.fillQA(phicandidate); - } - - float tpcNSigma; - float tofNSigma; - for (auto const& phidaugh : groupPartsPhiDaugh) { - if (phidaugh.mAntiLambda() == 1) { // workaround - tpcNSigma = trackCuts.getNsigmaTPC(phidaugh, o2::track::PID::Kaon); - tofNSigma = trackCuts.getNsigmaTOF(phidaugh, o2::track::PID::Kaon); - - qaRegistry.fill(HIST("PhiDaugh_pos/nSigmaTPC"), phidaugh.p(), tpcNSigma); - qaRegistry.fill(HIST("PhiDaugh_pos/nSigmaTOF"), phidaugh.p(), tofNSigma); - qaRegistry.fill(HIST("PhiDaugh_pos/hDCAxy"), phidaugh.p(), phidaugh.tempFitVar()); - qaRegistry.fill(HIST("PhiDaugh_pos/pt"), phidaugh.pt()); - qaRegistry.fill(HIST("PhiDaugh_pos/eta"), phidaugh.eta()); - qaRegistry.fill(HIST("PhiDaugh_pos/phi"), phidaugh.phi()); - } else if (phidaugh.mAntiLambda() == -1) { // workaround - tpcNSigma = trackCuts.getNsigmaTPC(phidaugh, o2::track::PID::Kaon); - tofNSigma = trackCuts.getNsigmaTOF(phidaugh, o2::track::PID::Kaon); - - qaRegistry.fill(HIST("PhiDaugh_neg/nSigmaTPC"), phidaugh.p(), tpcNSigma); - qaRegistry.fill(HIST("PhiDaugh_neg/nSigmaTOF"), phidaugh.p(), tofNSigma); - qaRegistry.fill(HIST("PhiDaugh_neg/pt"), phidaugh.pt()); - qaRegistry.fill(HIST("PhiDaugh_neg/eta"), phidaugh.eta()); - qaRegistry.fill(HIST("PhiDaugh_neg/phi"), phidaugh.phi()); - qaRegistry.fill(HIST("PhiDaugh_neg/hDCAxy"), phidaugh.p(), phidaugh.tempFitVar()); + // TODO: add phi meson minv cut here + const auto& posChild = parts.iteratorAt(phicandidate.index() - 2); + float tpcNSigmaKp = trackCuts.getNsigmaTPC(posChild, o2::track::PID::Kaon); + float tofNSigmaKp = trackCuts.getNsigmaTOF(posChild, o2::track::PID::Kaon); + qaRegistry.fill(HIST("PhiDaugh_pos/nSigmaTPC"), posChild.p(), tpcNSigmaKp); + qaRegistry.fill(HIST("PhiDaugh_pos/nSigmaTOF"), posChild.p(), tofNSigmaKp); + qaRegistry.fill(HIST("PhiDaugh_pos/hDCAxy"), posChild.p(), posChild.tempFitVar()); + qaRegistry.fill(HIST("PhiDaugh_pos/pt"), posChild.pt()); + qaRegistry.fill(HIST("PhiDaugh_pos/eta"), posChild.eta()); + qaRegistry.fill(HIST("PhiDaugh_pos/phi"), posChild.phi()); + + const auto& negChild = parts.iteratorAt(phicandidate.index() - 1); + float tpcNSigmaKm = trackCuts.getNsigmaTPC(negChild, o2::track::PID::Kaon); + float tofNSigmaKm = trackCuts.getNsigmaTOF(negChild, o2::track::PID::Kaon); + qaRegistry.fill(HIST("PhiDaugh_neg/nSigmaTPC"), negChild.p(), tpcNSigmaKm); + qaRegistry.fill(HIST("PhiDaugh_neg/nSigmaTOF"), negChild.p(), tofNSigmaKm); + qaRegistry.fill(HIST("PhiDaugh_neg/pt"), negChild.pt()); + qaRegistry.fill(HIST("PhiDaugh_neg/eta"), negChild.eta()); + qaRegistry.fill(HIST("PhiDaugh_neg/phi"), negChild.phi()); + qaRegistry.fill(HIST("PhiDaugh_neg/hDCAxy"), negChild.p(), negChild.tempFitVar()); + + trackHistoPartPhi.fillQA(phicandidate); + if constexpr (isMC) { + // reco + effCorrection.fillRecoHist(phicandidate, 333); } } - float tpcNSigmaPr, tofNSigmaPr, tpcNSigmaPi, tofNSigmaPi, tpcNSigmaKa, tofNSigmaKa; - if (!ConfTrack.confTrackIsSame) { - for (auto const& track : groupPartsTrack) { - tpcNSigmaPi = trackCuts.getNsigmaTPC(track, o2::track::PID::Pion); - tofNSigmaPi = trackCuts.getNsigmaTOF(track, o2::track::PID::Pion); - tpcNSigmaKa = trackCuts.getNsigmaTPC(track, o2::track::PID::Kaon); - tofNSigmaKa = trackCuts.getNsigmaTOF(track, o2::track::PID::Kaon); - tpcNSigmaPr = trackCuts.getNsigmaTPC(track, o2::track::PID::Proton); - tofNSigmaPr = trackCuts.getNsigmaTOF(track, o2::track::PID::Proton); - - if (ConfTrack.confTrackIsIdentified) { - if (!isParticleNSigmaAccepted(track.p(), tpcNSigmaPr, tofNSigmaPr, tpcNSigmaPi, tofNSigmaPi, tpcNSigmaKa, tofNSigmaKa)) { - continue; - } - } - if (ConfTrack.confTrackIsRejected) { + for (auto const& track : groupPartsTrack) { + float tpcNSigmaPi = trackCuts.getNsigmaTPC(track, o2::track::PID::Pion); + float tofNSigmaPi = trackCuts.getNsigmaTOF(track, o2::track::PID::Pion); + float tpcNSigmaKa = trackCuts.getNsigmaTPC(track, o2::track::PID::Kaon); + float tofNSigmaKa = trackCuts.getNsigmaTOF(track, o2::track::PID::Kaon); + float tpcNSigmaPr = trackCuts.getNsigmaTPC(track, o2::track::PID::Proton); + float tofNSigmaPr = trackCuts.getNsigmaTOF(track, o2::track::PID::Proton); + + if (ConfTrackIsIdentified) { + if (!isParticleNSigmaAccepted(track.p(), tpcNSigmaPr, tofNSigmaPr, tpcNSigmaPi, tofNSigmaPi, tpcNSigmaKa, tofNSigmaKa)) { + continue; + } + if (ConfTrackIsRejected) { if (isParticleNSigmaRejected(track.p(), tpcNSigmaPr, tofNSigmaPr, tpcNSigmaPi, tofNSigmaPi, tpcNSigmaKa, tofNSigmaKa)) { continue; } } - - trackHistoPartTrack.fillQA(track); - - qaRegistry.fill(HIST("Hadron/nSigmaTPCPi"), track.p(), tpcNSigmaPi); - qaRegistry.fill(HIST("Hadron/nSigmaTOFPi"), track.p(), tofNSigmaPi); - qaRegistry.fill(HIST("Hadron/nSigmaTPCKa"), track.p(), tpcNSigmaKa); - qaRegistry.fill(HIST("Hadron/nSigmaTOFKa"), track.p(), tofNSigmaKa); - qaRegistry.fill(HIST("Hadron/nSigmaTPCPr"), track.p(), tpcNSigmaPr); - qaRegistry.fill(HIST("Hadron/nSigmaTOFPr"), track.p(), tofNSigmaPr); + } + if (track.sign() > 0) { + qaRegistry.fill(HIST("Hadron_pos/nSigmaTPCPi"), track.p(), tpcNSigmaPi); + qaRegistry.fill(HIST("Hadron_pos/nSigmaTOFPi"), track.p(), tofNSigmaPi); + qaRegistry.fill(HIST("Hadron_pos/nSigmaTPCKa"), track.p(), tpcNSigmaKa); + qaRegistry.fill(HIST("Hadron_pos/nSigmaTOFKa"), track.p(), tofNSigmaKa); + qaRegistry.fill(HIST("Hadron_pos/nSigmaTPCPr"), track.p(), tpcNSigmaPr); + qaRegistry.fill(HIST("Hadron_pos/nSigmaTOFPr"), track.p(), tofNSigmaPr); + } else if (track.sign() < 0) { + qaRegistry.fill(HIST("Hadron_neg/nSigmaTPCPi"), track.p(), tpcNSigmaPi); + qaRegistry.fill(HIST("Hadron_neg/nSigmaTOFPi"), track.p(), tofNSigmaPi); + qaRegistry.fill(HIST("Hadron_neg/nSigmaTPCKa"), track.p(), tpcNSigmaKa); + qaRegistry.fill(HIST("Hadron_neg/nSigmaTOFKa"), track.p(), tofNSigmaKa); + qaRegistry.fill(HIST("Hadron_neg/nSigmaTPCPr"), track.p(), tpcNSigmaPr); + qaRegistry.fill(HIST("Hadron_neg/nSigmaTOFPr"), track.p(), tofNSigmaPr); + } + trackHistoPartTrack.fillQA(track); + + if constexpr (isMC) { + effCorrection.fillRecoHist(track, ConfTrackPDGCode); } } + /// Now build the combinations for (auto const& [track, phicandidate] : combinations(CombinationsFullIndexPolicy(groupPartsTrack, groupPartsPhi))) { - if (ConfTrack.confTrackIsIdentified) { + if (ConfTrackIsIdentified) { if (!isParticleNSigmaAccepted(track.p(), trackCuts.getNsigmaTPC(track, o2::track::PID::Proton), trackCuts.getNsigmaTOF(track, o2::track::PID::Proton), trackCuts.getNsigmaTPC(track, o2::track::PID::Pion), trackCuts.getNsigmaTOF(track, o2::track::PID::Pion), trackCuts.getNsigmaTPC(track, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(track, o2::track::PID::Kaon))) { continue; } } - if (ConfTrack.confTrackIsRejected) { + if (ConfTrackIsRejected) { if (isParticleNSigmaRejected(track.p(), trackCuts.getNsigmaTPC(track, o2::track::PID::Proton), trackCuts.getNsigmaTOF(track, o2::track::PID::Proton), trackCuts.getNsigmaTPC(track, o2::track::PID::Pion), trackCuts.getNsigmaTOF(track, o2::track::PID::Pion), trackCuts.getNsigmaTPC(track, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(track, o2::track::PID::Kaon))) { continue; } } // Close Pair Rejection - if (ConfCPR.confCPRIsEnabled.value) { + if (ConfCPRIsEnabled) { if (pairCloseRejection.isClosePair(track, phicandidate, parts, magFieldTesla, femto_universe_container::EventType::same)) { continue; } @@ -553,130 +581,74 @@ struct FemtoUniversePairTaskTrackPhi { if (!pairCleaner.isCleanPair(track, phicandidate, parts)) { continue; } - - float weight = 1.0f; - if (phieff) { - weight = protoneff->GetBinContent(protoneff->FindBin(track.pt(), track.eta())) * phieff->GetBinContent(phieff->FindBin(phicandidate.pt(), phicandidate.eta())); - sameEventAngularCont.setPair(track, phicandidate, multCol, ConfBothTracks.confUse3D, weight); - } else { - sameEventAngularCont.setPair(track, phicandidate, multCol, ConfBothTracks.confUse3D, weight); - } + weight = effCorrection.getWeight(ParticleNo::ONE, phicandidate) * effCorrection.getWeight(ParticleNo::TWO, track); + sameEventCont.setPair(track, phicandidate, multCol, ConfUse3D, weight); } - // Used for better fitting of invariant mass background. - - TLorentzVector part1Vec; - TLorentzVector part2Vec; - - float mMassOne = o2::constants::physics::MassKPlus; - float mMassTwo = o2::constants::physics::MassKMinus; - - for (auto const& [kaon1, kaon2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsKaons, groupPartsKaons))) { - if ((kaon1.mAntiLambda() == 1) && (kaon2.mAntiLambda() == 1)) { - part1Vec.SetPtEtaPhiM(kaon1.pt(), kaon1.eta(), kaon1.phi(), mMassOne); - part2Vec.SetPtEtaPhiM(kaon2.pt(), kaon2.eta(), kaon2.phi(), mMassOne); - TLorentzVector sumVec(part1Vec); - sumVec += part2Vec; - registryPhiMinvBackground.fill(HIST("InvariantMassKpKp"), sumVec.M()); - } - if ((kaon1.mAntiLambda() == -1) && (kaon2.mAntiLambda() == -1)) { - part1Vec.SetPtEtaPhiM(kaon1.pt(), kaon1.eta(), kaon1.phi(), mMassTwo); - part2Vec.SetPtEtaPhiM(kaon2.pt(), kaon2.eta(), kaon2.phi(), mMassTwo); - - TLorentzVector sumVec(part1Vec); - sumVec += part2Vec; - registryPhiMinvBackground.fill(HIST("InvariantMassKmKm"), sumVec.M()); - } - } + // // Used for better fitting of invariant mass background. + + // TLorentzVector part1Vec; + // TLorentzVector part2Vec; + + // float mMassOne = o2::constants::physics::MassKPlus; + // float mMassTwo = o2::constants::physics::MassKMinus; + + // for (auto const& [kaon1, kaon2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsKaons, groupPartsKaons))) { + // if ((kaon1.mAntiLambda() == 1) && (kaon2.mAntiLambda() == 1)) { + // part1Vec.SetPtEtaPhiM(kaon1.pt(), kaon1.eta(), kaon1.phi(), mMassOne); + // part2Vec.SetPtEtaPhiM(kaon2.pt(), kaon2.eta(), kaon2.phi(), mMassOne); + // TLorentzVector sumVec(part1Vec); + // sumVec += part2Vec; + // registryPhiMinvBackground.fill(HIST("InvariantMassKpKp"), sumVec.M()); + // } + // if ((kaon1.mAntiLambda() == -1) && (kaon2.mAntiLambda() == -1)) { + // part1Vec.SetPtEtaPhiM(kaon1.pt(), kaon1.eta(), kaon1.phi(), mMassTwo); + // part2Vec.SetPtEtaPhiM(kaon2.pt(), kaon2.eta(), kaon2.phi(), mMassTwo); + + // TLorentzVector sumVec(part1Vec); + // sumVec += part2Vec; + // registryPhiMinvBackground.fill(HIST("InvariantMassKmKm"), sumVec.M()); + // } + // } } - /// process function for to call doSameEvent with Data - /// \param col subscribe to the collision table (Data) - /// \param parts subscribe to the femtoUniverseParticleTable - void processSameEvent(o2::aod::FdCollision const& col, - FemtoFullParticles const& parts) - { - fillCollision(col); - - auto thegroupPartsTrack = partsTrack->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsPhi = partsPhi->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsPhiDaugh = partsPhiDaugh->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsKaons = partsKaons->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - - doSameEvent(thegroupPartsTrack, thegroupPartsPhi, thegroupPartsPhiDaugh, thegroupPartsKaons, parts, col.magField(), col.multNtr()); - } - PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processSameEvent, "Enable processing same event", true); - - /// process function for to call doSameEvent with Monte Carlo - /// \param col subscribe to the collision table (Monte Carlo Reconstructed reconstructed) - /// \param parts subscribe to joined table FemtoUniverseParticles and FemtoUniverseMCLables to access Monte Carlo truth - /// \param FemtoUniverseMCParticles subscribe to the Monte Carlo truth table - void processSameEventMC(o2::aod::FdCollision const& col, - soa::Join const& parts, - o2::aod::FdMCParticles const&) - { - fillCollision(col); - - auto thegroupPartsPhi = partsPhiMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsTrack = partsTrackMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsPhiDaugh = partsPhiDaughMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsKaons = partsKaonsMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - - doSameEvent(thegroupPartsTrack, thegroupPartsPhi, thegroupPartsPhiDaugh, thegroupPartsKaons, parts, col.magField(), col.multNtr()); - } - PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processSameEventMC, "Enable processing same event for Monte Carlo", false); - - /// This function processes the mixed event - /// \todo the trivial loops over the collisions and tracks should be factored out since they will be common to all combinations of T-T, T-V0, V0-V0, ... - /// \tparam PartitionType - /// \tparam PartType - /// \tparam isMC: enables Monte Carlo truth specific histograms - /// \param groupPartsTrack partition for the identified passed by the process function - /// \param groupPartsPhi partition for Phi meson passed by the process function - /// \param parts femtoUniverseParticles table (in case of Monte Carlo joined with FemtoUniverseMCLabels) - /// \param magFieldTesla magnetic field of the collision - /// \param multCol multiplicity of the collision - template - void doMixedEvent(PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartType parts, float magFieldTesla, int multCol) + template + void doMixedEvent(PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartType parts, float magFieldTesla, int multCol, [[maybe_unused]] MCParticles mcParts = nullptr) { - for (auto const& [track, phicandidate] : combinations(CombinationsFullIndexPolicy(groupPartsTrack, groupPartsPhi))) { - if (ConfTrack.confTrackIsIdentified) { + if (ConfTrackIsIdentified) { if (!isParticleNSigmaAccepted(track.p(), trackCuts.getNsigmaTPC(track, o2::track::PID::Proton), trackCuts.getNsigmaTOF(track, o2::track::PID::Proton), trackCuts.getNsigmaTPC(track, o2::track::PID::Pion), trackCuts.getNsigmaTOF(track, o2::track::PID::Pion), trackCuts.getNsigmaTPC(track, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(track, o2::track::PID::Kaon))) { continue; } - } - - if (ConfTrack.confTrackIsRejected) { - if (isParticleNSigmaRejected(track.p(), trackCuts.getNsigmaTPC(track, o2::track::PID::Proton), trackCuts.getNsigmaTOF(track, o2::track::PID::Proton), trackCuts.getNsigmaTPC(track, o2::track::PID::Pion), trackCuts.getNsigmaTOF(track, o2::track::PID::Pion), trackCuts.getNsigmaTPC(track, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(track, o2::track::PID::Kaon))) { - continue; + if (ConfTrackIsRejected) { + if (isParticleNSigmaRejected(track.p(), trackCuts.getNsigmaTPC(track, o2::track::PID::Proton), trackCuts.getNsigmaTOF(track, o2::track::PID::Proton), trackCuts.getNsigmaTPC(track, o2::track::PID::Pion), trackCuts.getNsigmaTOF(track, o2::track::PID::Pion), trackCuts.getNsigmaTPC(track, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(track, o2::track::PID::Kaon))) { + continue; + } } } - if (ConfCPR.confCPRIsEnabled.value) { + if (ConfCPRIsEnabled) { if (pairCloseRejection.isClosePair(track, phicandidate, parts, magFieldTesla, femto_universe_container::EventType::mixed)) { continue; } } - - float weight = 1.0f; - if (protoneff) { - weight = protoneff->GetBinContent(protoneff->FindBin(track.pt(), track.eta())) * phieff->GetBinContent(phieff->FindBin(phicandidate.pt(), phicandidate.eta())); - mixedEventAngularCont.setPair(track, phicandidate, multCol, ConfBothTracks.confUse3D, weight); - } else { - mixedEventAngularCont.setPair(track, phicandidate, multCol, ConfBothTracks.confUse3D, weight); - } + weight = effCorrection.getWeight(ParticleNo::ONE, phicandidate) * effCorrection.getWeight(ParticleNo::TWO, track); + mixedEventCont.setPair(track, phicandidate, multCol, ConfUse3D, weight); } } - /// process function for to call doMixedEvent with Data - /// @param cols subscribe to the collisions table (Data) - /// @param parts subscribe to the femtoUniverseParticleTable - void processMixedEvent(o2::aod::FdCollisions const& cols, - FemtoFullParticles const& parts) + void processSameEvent(FilteredFDCollision const& col, FilteredFemtoFullParticles const& parts) { - for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + auto thegroupPartsTrack = partsTrack->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegroupPartsPhi = partsPhi->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + eventHisto.fillQA(col); + doSameEvent(thegroupPartsTrack, thegroupPartsPhi, parts, col.magField(), col.multNtr()); + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processSameEvent, "Enable processing same event", true); + void processMixedEvent(FilteredFDCollisions const& cols, FilteredFemtoFullParticles const& parts) + { + for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { const int multiplicityCol = collision1.multNtr(); mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); @@ -689,45 +661,44 @@ struct FemtoUniversePairTaskTrackPhi { if (magFieldTesla1 != magFieldTesla2) { continue; } - /// \todo before mixing we should check whether both collisions contain a pair of particles! - // if (partsPhi.size() == 0 || NPart2Evt1 == 0 || NPart1Evt2 == 0 || partsTrack.size() == 0 ) continue; doMixedEvent(groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol); } } PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processMixedEvent, "Enable processing mixed events", true); - /// brief process function for to call doMixedEvent with Monte Carlo - /// @param cols subscribe to the collisions table (Monte Carlo Reconstructed reconstructed) - /// @param parts subscribe to joined table FemtoUniverseParticles and FemtoUniverseMCLables to access Monte Carlo truth - /// @param FemtoUniverseMCParticles subscribe to the Monte Carlo truth table - void processMixedEventMC(o2::aod::FdCollisions const& cols, - soa::Join const& parts, - o2::aod::FdMCParticles const&) + ///--------------------------------------------MC-------------------------------------------------/// + void processSameEventMCReco(FilteredFDCollision const& col, FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts) + { + eventHisto.fillQA(col); + // Reco + auto thegroupPartsTrack = partsTrackMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegroupPartsPhi = partsPhiMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + doSameEvent(thegroupPartsTrack, thegroupPartsPhi, parts, col.magField(), col.multNtr(), mcparts); + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processSameEventMCReco, "Enable processing same event for MC Reco", true); + + void processMixedEventMCReco(FilteredFDCollisions const& cols, FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts) { for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { const int multiplicityCol = collision1.multNtr(); mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); - auto groupPartsTrack = partsTrackMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); - auto groupPartsPhi = partsPhiMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); - const auto& magFieldTesla1 = collision1.magField(); const auto& magFieldTesla2 = collision2.magField(); if (magFieldTesla1 != magFieldTesla2) { continue; } - /// \todo before mixing we should check whether both collisions contain a pair of particles! - // if (partsPhi.size() == 0 || NPart2Evt1 == 0 || NPart1Evt2 == 0 || partsTrack.size() == 0 ) continue; - doMixedEvent(groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol); + auto groupPartsTrack = partsTrackMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + auto groupPartsPhi = partsPhiMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + + doMixedEvent(groupPartsTrack, groupPartsPhi, parts, magFieldTesla1, multiplicityCol, mcparts); } } - PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processMixedEventMC, "Enable processing mixed events MC", false); - - ///--------------------------------------------MC-------------------------------------------------/// + PROCESS_SWITCH(FemtoUniversePairTaskTrackPhi, processMixedEventMCReco, "Enable processing mixed events for MC Reco", false); /// This function fills MC truth particles from derived MC table void processMCTruth(aod::FDParticles const& parts) @@ -742,30 +713,44 @@ struct FemtoUniversePairTaskTrackPhi { continue; } + if (pdgCode == ConfTrackPDGCode) { + effCorrection.fillTruthHist(part); + } + + // charge + if (pdgParticle->Charge() > 0.0) { registryMCtruth.fill(HIST("MCtruthAllPositivePt"), part.pt()); + if (pdgCode == 2212) { + registryMCtruth.fill(HIST("MCtruthPpos"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("MCtruthPposPt"), part.pt()); + continue; + } else if (pdgCode == 321) { + registryMCtruth.fill(HIST("MCtruthKp"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("MCtruthKpPt"), part.pt()); + continue; + } } - if (pdgCode == 321) { - registryMCtruth.fill(HIST("MCtruthKp"), part.pt(), part.eta()); - registryMCtruth.fill(HIST("MCtruthKpPt"), part.pt()); - } + // charge 0 if (pdgCode == 333) { registryMCtruth.fill(HIST("MCtruthPhi"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("MCtruthPhiPt"), part.pt()); + effCorrection.fillTruthHist(part); continue; } - if (pdgCode == 2212) { - registryMCtruth.fill(HIST("MCtruthPpos"), part.pt(), part.eta()); - } + // charge - if (pdgParticle->Charge() < 0.0) { registryMCtruth.fill(HIST("MCtruthAllNegativePt"), part.pt()); - } - if (pdgCode == -321) { - registryMCtruth.fill(HIST("MCtruthKm"), part.pt(), part.eta()); - registryMCtruth.fill(HIST("MCtruthKmPt"), part.pt()); - } - if (pdgCode == -2212) { - registryMCtruth.fill(HIST("MCtruthPneg"), part.pt(), part.eta()); + + if (pdgCode == -321) { + registryMCtruth.fill(HIST("MCtruthKm"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("MCtruthKmPt"), part.pt()); + continue; + } else if (pdgCode == -2212) { + registryMCtruth.fill(HIST("MCtruthPneg"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("MCtruthPnegPt"), part.pt()); + continue; + } } } } @@ -778,25 +763,38 @@ struct FemtoUniversePairTaskTrackPhi { if (mcPartId == -1) continue; // no MC particle const auto& mcpart = mcparts.iteratorAt(mcPartId); - if (part.partType() == aod::femtouniverseparticle::ParticleType::kPhi) { - if ((mcpart.pdgMCTruth() == 333) && (mcpart.partOriginMCTruth() == aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kPrimary)) { - registryMCreco.fill(HIST("MCrecoPhi"), mcpart.pt(), mcpart.eta()); // phi - } + + if (mcpart.pdgMCTruth() == ConfTrackPDGCode && (part.pt() > ConfTrackPtLow) && (part.pt() < ConfTrackPtHigh) && isParticleNSigmaAccepted(part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) { + registryMCpT.fill(HIST("MCReco/NC_p_pT"), part.pt()); + float weightTrack = effCorrection.getWeight(ParticleNo::TWO, part); + registryMCpT.fill(HIST("MCReco/C_p_pT"), part.pt(), weightTrack); + } + if ((mcpart.pdgMCTruth() == 333) && (part.partType() == aod::femtouniverseparticle::ParticleType::kPhi) && (part.pt() > ConfPhiPtLow) && (part.pt() < ConfPhiPtHigh)) { + registryMCpT.fill(HIST("MCReco/NC_phi_pT"), part.pt()); + float weightPhi = effCorrection.getWeight(ParticleNo::ONE, part); + registryMCpT.fill(HIST("MCReco/C_phi_pT"), part.pt(), weightPhi); + } + + if (isParticleNSigmaAccepted(part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) + hTrackDCA.fillQA(part); + if ((part.partType() == aod::femtouniverseparticle::ParticleType::kPhi) && (mcpart.pdgMCTruth() == 333) && (mcpart.partOriginMCTruth() == aod::femtouniverse_mc_particle::ParticleOriginMCTruth::kPrimary)) { + registryMCreco.fill(HIST("MCrecoPhi"), mcpart.pt(), mcpart.eta()); // phi + registryMCreco.fill(HIST("MCrecoPhiPt"), mcpart.pt()); } else if (part.partType() == aod::femtouniverseparticle::ParticleType::kTrack) { if (part.sign() > 0) { registryMCreco.fill(HIST("MCrecoAllPositivePt"), mcpart.pt()); if (mcpart.pdgMCTruth() == 2212 && isParticleNSigmaAccepted(part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) { registryMCreco.fill(HIST("MCrecoPpos"), mcpart.pt(), mcpart.eta()); + registryMCreco.fill(HIST("MCrecoPposPt"), mcpart.pt()); } - } - - if (part.sign() < 0) { + } else if (part.sign() < 0) { registryMCreco.fill(HIST("MCrecoAllNegativePt"), mcpart.pt()); if (mcpart.pdgMCTruth() == -2212 && isParticleNSigmaAccepted(part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) { registryMCreco.fill(HIST("MCrecoPneg"), mcpart.pt(), mcpart.eta()); + registryMCreco.fill(HIST("MCrecoPnegPt"), mcpart.pt()); } } - } // partType + } // partType kTrack } } diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack.cxx index 8bb56e9d53a..f4eb45752dc 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack3DMultKtExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack3DMultKtExtended.cxx index 49c932fc008..f5c6242f456 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack3DMultKtExtended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack3DMultKtExtended.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -24,7 +24,6 @@ #include "Framework/RunningWorkflowInfo.h" #include "Framework/StepTHn.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "TDatabasePDG.h" #include "ReconstructionDataFormats/PID.h" #include "Common/DataModel/PIDResponse.h" @@ -33,6 +32,7 @@ #include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverse3DContainer.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" #include "PWGCF/FemtoUniverse/Core/femtoUtils.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h" @@ -76,15 +76,17 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { Configurable ConfUse3D{"ConfUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; } twotracksconfigs; + SliceCache cache; + using FemtoFullParticles = soa::Join; - // Filters for selecting particles (both p1 and p2) Filter trackAdditionalfilter = (nabs(aod::femtouniverseparticle::eta) < twotracksconfigs.ConfEtaMax); // example filtering on configurable using FilteredFemtoFullParticles = soa::Filtered; - // using FilteredFemtoFullParticles = FemtoFullParticles; //if no filtering is applied uncomment this option - - SliceCache cache; Preslice perCol = aod::femtouniverseparticle::fdCollisionId; + using FemtoRecoParticles = soa::Join; + using FilteredFemtoRecoParticles = soa::Filtered; + Preslice perColMC = aod::femtouniverseparticle::fdCollisionId; + /// Particle 1 struct : o2::framework::ConfigurableGroup { Configurable ConfPDGCodePartOne{"ConfPDGCodePartOne", 211, "Particle 1 - PDG code"}; @@ -98,7 +100,7 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { /// Partition for particle 1 Partition partsOne = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && aod::femtouniverseparticle::sign == trackonefilter.ConfChargePart1 && aod::femtouniverseparticle::pt < trackonefilter.ConfPtHighPart1 && aod::femtouniverseparticle::pt > trackonefilter.ConfPtLowPart1; - Partition> partsOneMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && aod::femtouniverseparticle::sign == trackonefilter.ConfChargePart1 && aod::femtouniverseparticle::pt < trackonefilter.ConfPtHighPart1 && aod::femtouniverseparticle::pt > trackonefilter.ConfPtLowPart1; + Partition partsOneMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && aod::femtouniverseparticle::sign == trackonefilter.ConfChargePart1 && aod::femtouniverseparticle::pt < trackonefilter.ConfPtHighPart1 && aod::femtouniverseparticle::pt > trackonefilter.ConfPtLowPart1; // /// Histogramming for particle 1 @@ -118,7 +120,7 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { /// Partition for particle 2 Partition partsTwo = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == tracktwofilter.ConfChargePart2) && aod::femtouniverseparticle::pt < tracktwofilter.ConfPtHighPart2 && aod::femtouniverseparticle::pt > tracktwofilter.ConfPtLowPart2; - Partition> partsTwoMC = aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack) && (aod::femtouniverseparticle::sign == tracktwofilter.ConfChargePart2) && aod::femtouniverseparticle::pt < tracktwofilter.ConfPtHighPart2 && aod::femtouniverseparticle::pt > tracktwofilter.ConfPtLowPart2; + Partition partsTwoMC = aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack) && (aod::femtouniverseparticle::sign == tracktwofilter.ConfChargePart2) && aod::femtouniverseparticle::pt < tracktwofilter.ConfPtHighPart2 && aod::femtouniverseparticle::pt > tracktwofilter.ConfPtLowPart2; /// Histogramming for particle 2 FemtoUniverseParticleHisto trackHistoPartTwo; @@ -135,9 +137,10 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { Configurable ConfV0MHigh{"ConfV0MHigh", 25000.0, "Upper limit for V0M multiplicity"}; Configurable ConfTPCOccupancyLow{"ConfTPCOccupancyLow", 0, "Lower limit for TPC occupancy"}; Configurable ConfTPCOccupancyHigh{"ConfTPCOccupancyHigh", 500, "Higher limit for TPC occupancy"}; + Configurable ConfIsCent{"ConfIsCent", true, "Condition to choose centrality of multiplicity for mixing"}; Filter collfilter = (o2::aod::femtouniversecollision::multV0M > ConfV0MLow) && (o2::aod::femtouniversecollision::multV0M < ConfV0MHigh) && - (o2::aod::femtouniversecollision::occupancy > ConfTPCOccupancyLow) && (o2::aod::femtouniversecollision::occupancy < ConfTPCOccupancyHigh); + (o2::aod::femtouniversecollision::occupancy >= ConfTPCOccupancyLow) && (o2::aod::femtouniversecollision::occupancy < ConfTPCOccupancyHigh); using FilteredFDCollisions = soa::Filtered>; using FilteredFDCollision = FilteredFDCollisions::iterator; @@ -154,7 +157,8 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { ConfigurableAxis ConfmTBins3D{"ConfmTBins3D", {VARIABLE_WIDTH, 1.02f, 1.14f, 1.20f, 1.26f, 1.38f, 1.56f, 1.86f, 4.50f}, "mT Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; ConfigurableAxis ConfmultBins3D{"ConfmultBins3D", {VARIABLE_WIDTH, 0.0f, 20.0f, 30.0f, 40.0f, 99999.0f}, "multiplicity Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; - ColumnBinningPolicy colBinning{{ConfVtxBins, ConfMultBins}, true}; + ColumnBinningPolicy colBinningCent{{ConfVtxBins, ConfMultBins}, true}; + ColumnBinningPolicy colBinningNtr{{ConfVtxBins, ConfMultBins}, true}; ConfigurableAxis ConfkstarBins{"ConfkstarBins", {300, -1.5, 1.5}, "binning kstar"}; ConfigurableAxis ConfkTBins{"ConfkTBins", {150, 0., 9.}, "binning kT"}; @@ -169,6 +173,8 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { Configurable ConfCPRdeltaEtaCutMax{"ConfCPRdeltaEtaCutMax", 0.0, "Delta Eta max cut for Close Pair Rejection"}; Configurable ConfCPRdeltaEtaCutMin{"ConfCPRdeltaEtaCutMin", 0.0, "Delta Eta min cut for Close Pair Rejection"}; Configurable ConfCPRChosenRadii{"ConfCPRChosenRadii", 0.80, "Delta Eta cut for Close Pair Rejection"}; + Configurable ConfPhiBins{"ConfPhiBins", 29, "Number of phi bins in deta dphi"}; + Configurable ConfEtaBins{"ConfEtaBins", 29, "Number of eta bins in deta dphi"}; Configurable cfgProcessPM{"cfgProcessPM", false, "Process particles of the opposite charge"}; Configurable cfgProcessPP{"cfgProcessPP", true, "Process particles of the same, positice charge"}; Configurable cfgProcessMM{"cfgProcessMM", true, "Process particles of the same, positice charge"}; @@ -176,6 +182,9 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { Configurable cfgProcessKtBins{"cfgProcessKtBins", true, "Process kstar histograms in kT bins (if cfgProcessMultBins is set false, this will not be processed regardless this Configurable state)"}; Configurable cfgProcessKtMt3DCF{"cfgProcessKtMt3DCF", false, "Process 3D histograms in kT and Mult bins"}; + FemtoUniverseContainer sameEventCont1D; + FemtoUniverseContainer mixedEventCont1D; + FemtoUniverse3DContainer sameEventCont; FemtoUniverse3DContainer mixedEventCont; @@ -204,6 +213,7 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { /// Histogram output HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry resultRegistry1D{"Correlations1D", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry resultRegistryPM{"CorrelationsPM", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry resultRegistryPP{"CorrelationsPP", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry resultRegistryMM{"CorrelationsMM", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; @@ -232,13 +242,13 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { // ConfNsigmaCombined -> TPC and TOF Sigma (combined) for momentum > 0.5 if (mom < twotracksconfigs.ConfTOFPtMin) { - if (TMath::Abs(nsigmaTPCPr) < twotracksconfigs.ConfNsigmaTPC) { + if (std::abs(nsigmaTPCPr) < twotracksconfigs.ConfNsigmaTPC) { return true; } else { return false; } } else { - if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < twotracksconfigs.ConfNsigmaCombined) { + if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < twotracksconfigs.ConfNsigmaCombined) { return true; } else { return false; @@ -250,25 +260,25 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { bool IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK) { if (mom < 0.3) { // 0.0-0.3 - if (TMath::Abs(nsigmaTPCK) < 3.0) { + if (std::abs(nsigmaTPCK) < 3.0) { return true; } else { return false; } } else if (mom < 0.45) { // 0.30 - 0.45 - if (TMath::Abs(nsigmaTPCK) < 2.0) { + if (std::abs(nsigmaTPCK) < 2.0) { return true; } else { return false; } } else if (mom < 0.55) { // 0.45-0.55 - if (TMath::Abs(nsigmaTPCK) < 1.0) { + if (std::abs(nsigmaTPCK) < 1.0) { return true; } else { return false; } } else if (mom < 1.5) { // 0.55-1.5 (now we use TPC and TOF) - if ((TMath::Abs(nsigmaTOFK) < 3.0) && (TMath::Abs(nsigmaTPCK) < 3.0)) { + if ((std::abs(nsigmaTOFK) < 3.0) && (std::abs(nsigmaTPCK) < 3.0)) { { return true; } @@ -276,7 +286,7 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { return false; } } else if (mom > 1.5) { // 1.5 - - if ((TMath::Abs(nsigmaTOFK) < 2.0) && (TMath::Abs(nsigmaTPCK) < 3.0)) { + if ((std::abs(nsigmaTOFK) < 2.0) && (std::abs(nsigmaTPCK) < 3.0)) { return true; } else { return false; @@ -297,13 +307,13 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { // ConfNsigmaCombined -> TPC and TOF Pion Sigma (combined) for momentum > 0.5 if (true) { if (mom < twotracksconfigs.ConfTOFPtMin) { - if (TMath::Abs(nsigmaTPCPi) < twotracksconfigs.ConfNsigmaTPC) { + if (std::abs(nsigmaTPCPi) < twotracksconfigs.ConfNsigmaTPC) { return true; } else { return false; } } else { - if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < twotracksconfigs.ConfNsigmaCombined) { + if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < twotracksconfigs.ConfNsigmaCombined) { return true; } else { return false; @@ -392,6 +402,10 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { sameEventMultContPP.init(&SameMultRegistryPP, ConfkstarBins, ConfMultKstarBins, ConfKtKstarBins, cfgProcessKtBins, cfgProcessKtMt3DCF); mixedEventMultContPP.init(&MixedMultRegistryPP, ConfkstarBins, ConfMultKstarBins, ConfKtKstarBins, cfgProcessKtBins, cfgProcessKtMt3DCF); } + sameEventCont1D.init(&resultRegistry1D, ConfkstarBins, ConfMultBins, ConfkTBins, ConfmTBins, ConfmultBins3D, ConfmTBins3D, ConfEtaBins, ConfPhiBins, twotracksconfigs.ConfIsMC, twotracksconfigs.ConfUse3D); + sameEventCont1D.setPDGCodes(trackonefilter.ConfPDGCodePartOne, tracktwofilter.ConfPDGCodePartTwo); + mixedEventCont1D.init(&resultRegistry1D, ConfkstarBins, ConfMultBins, ConfkTBins, ConfmTBins, ConfmultBins3D, ConfmTBins3D, ConfEtaBins, ConfPhiBins, twotracksconfigs.ConfIsMC, twotracksconfigs.ConfUse3D); + mixedEventCont1D.setPDGCodes(trackonefilter.ConfPDGCodePartOne, tracktwofilter.ConfPDGCodePartTwo); } if (cfgProcessMM) { @@ -417,9 +431,13 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { } template - void fillCollision(CollisionType col) + void fillCollision(CollisionType col, bool IsCent) { - MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multV0M()})); + if (IsCent) { + MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinningCent.getBin({col.posZ(), col.multV0M()})); + } else { + MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinningNtr.getBin({col.posZ(), col.multNtr()})); + } eventHisto.fillQA(col); } @@ -433,22 +451,23 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { /// @param parts femtoUniverseParticles table (in case of Monte Carlo joined with FemtoUniverseMCLabels) /// @param magFieldTesla magnetic field of the collision /// @param multCol multiplicity of the collision - template - void doSameEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, PartType parts, float magFieldTesla, int multCol, int ContType, bool fillQA) + template + void doSameEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, PartType parts, float magFieldTesla, int multCol, int ContType, bool fillQA, [[maybe_unused]] MCParticles mcParts = nullptr) { /// Histogramming same event if ((ContType == 1 || ContType == 2) && fillQA) { - for (auto& part : groupPartsOne) { + for (const auto& part : groupPartsOne) { if (!IsParticleNSigma((int8_t)1, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) { continue; } trackHistoPartOne.fillQA(part); + trackHistoPartOne.fillQAMisIden(part, trackonefilter.ConfPDGCodePartOne); } } if ((ContType == 1 || ContType == 3) && fillQA) { - for (auto& part : groupPartsTwo) { + for (const auto& part : groupPartsTwo) { if (!IsParticleNSigma((int8_t)2, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) { continue; } @@ -459,7 +478,7 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { if (ContType == 1) { /// Now build the combinations for non-identical particle pairs - for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { if (!IsParticleNSigma((int8_t)1, p1.p(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p1, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p1, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p1, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon))) { continue; @@ -492,7 +511,7 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { } else { /// Now build the combinations for identical particles pairs double rand; - for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsOne, groupPartsOne))) { + for (const auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsOne, groupPartsOne))) { if (!IsParticleNSigma((int8_t)2, p1.p(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p1, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p1, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p1, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon))) { continue; @@ -526,13 +545,25 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { k3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); sameEventMultContPP.fill3D(k3d[1], k3d[2], k3d[3], multCol, kT); } + float weight = 1.0f; + if constexpr (std::is_same::value) { + sameEventCont1D.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, weight, ConfIsIden); + } else { + sameEventCont1D.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, weight, ConfIsIden); + } } else { if (!cfgProcessMultBins) { - sameEventContPP.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); + sameEventContPP.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); } else { k3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); sameEventMultContPP.fill3D(k3d[1], k3d[2], k3d[3], multCol, kT); } + float weight = 1.0f; + if constexpr (std::is_same::value) { + sameEventCont1D.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, weight, ConfIsIden); + } else { + sameEventCont1D.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, weight, ConfIsIden); + } } break; } @@ -549,13 +580,25 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { k3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); sameEventMultContMM.fill3D(k3d[1], k3d[2], k3d[3], multCol, kT); } + float weight = 1.0f; + if constexpr (std::is_same::value) { + sameEventCont1D.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, weight, ConfIsIden); + } else { + sameEventCont1D.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, weight, ConfIsIden); + } } else { if (!cfgProcessMultBins) { - sameEventContMM.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); + sameEventContMM.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); } else { k3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); sameEventMultContMM.fill3D(k3d[1], k3d[2], k3d[3], multCol, kT); } + float weight = 1.0f; + if constexpr (std::is_same::value) { + sameEventCont1D.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, weight, ConfIsIden); + } else { + sameEventCont1D.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, weight, ConfIsIden); + } } break; } @@ -569,10 +612,10 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { /// process function for to call doSameEvent with Data /// \param col subscribe to the collision table (Data) /// \param parts subscribe to the femtoUniverseParticleTable - void processSameEvent(FilteredFDCollision& col, - FilteredFemtoFullParticles& parts) + void processSameEvent(FilteredFDCollision const& col, + FilteredFemtoFullParticles const& parts) { - fillCollision(col); + fillCollision(col, ConfIsCent); auto thegroupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto thegroupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); @@ -580,16 +623,26 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { bool fillQA = true; randgen = new TRandom2(0); - if (cfgProcessPM) { - doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); - } - - if (cfgProcessPP) { - doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); - } - - if (cfgProcessMM) { - doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); + if (ConfIsCent) { + if (cfgProcessPM) { + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); + } + if (cfgProcessPP) { + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); + } + if (cfgProcessMM) { + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); + } + } else { + if (cfgProcessPM) { + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 1, fillQA); + } + if (cfgProcessPP) { + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multNtr(), 2, fillQA); + } + if (cfgProcessMM) { + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 3, fillQA); + } } delete randgen; } @@ -599,28 +652,39 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { /// \param col subscribe to the collision table (Monte Carlo Reconstructed reconstructed) /// \param parts subscribe to joined table FemtoUniverseParticles and FemtoUniverseMCLables to access Monte Carlo truth /// \param FemtoUniverseMCParticles subscribe to the Monte Carlo truth table - void processSameEventMC(o2::aod::FdCollision& col, - soa::Join& parts, - o2::aod::FdMCParticles&) + void processSameEventMC(FilteredFDCollision const& col, + FilteredFemtoRecoParticles const& parts, + aod::FdMCParticles const& mcparts) { - fillCollision(col); - + fillCollision(col, ConfIsCent); auto thegroupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto thegroupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); bool fillQA = true; + randgen = new TRandom2(0); - if (cfgProcessPM) { - doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); - } - - if (cfgProcessPP) { - doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); - } - - if (cfgProcessMM) { - doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); + if (ConfIsCent) { + if (cfgProcessPM) { + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); + } + if (cfgProcessPP) { + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA, mcparts); + } + if (cfgProcessMM) { + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); + } + } else { + if (cfgProcessPM) { + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 1, fillQA); + } + if (cfgProcessPP) { + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multNtr(), 2, fillQA, mcparts); + } + if (cfgProcessMM) { + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 3, fillQA); + } } + delete randgen; } PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processSameEventMC, "Enable processing same event for Monte Carlo", false); @@ -638,7 +702,7 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { void doMixedEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, PartType parts, float magFieldTesla, int multCol, int ContType) { - for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { if (!IsParticleNSigma((int8_t)2, p1.p(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p1, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p1, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p1, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon))) { continue; @@ -729,15 +793,15 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { /// process function for to call doMixedEvent with Data /// @param cols subscribe to the collisions table (Data) /// @param parts subscribe to the femtoUniverseParticleTable - void processMixedEvent(FilteredFDCollisions& cols, - FilteredFemtoFullParticles& parts) + void processMixedEventCent(FilteredFDCollisions const& cols, + FilteredFemtoFullParticles const& parts) { randgen = new TRandom2(0); - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols)) { + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, ConfNEventsMix, -1, cols, cols)) { const int multiplicityCol = collision1.multV0M(); - MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); const auto& magFieldTesla2 = collision2.magField(); @@ -764,20 +828,22 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { } delete randgen; } - PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processMixedEvent, "Enable processing mixed events", true); + PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processMixedEventCent, "Enable processing mixed events", true); /// brief process function for to call doMixedEvent with Monte Carlo /// @param cols subscribe to the collisions table (Monte Carlo Reconstructed reconstructed) /// @param parts subscribe to joined table FemtoUniverseParticles and FemtoUniverseMCLables to access Monte Carlo truth /// @param FemtoUniverseMCParticles subscribe to the Monte Carlo truth table - void processMixedEventMC(o2::aod::FdCollisions& cols, - soa::Join& parts, - o2::aod::FdMCParticles&) + void processMixedEventMCCent(FilteredFDCollisions const& cols, + FemtoRecoParticles const& parts, + aod::FdMCParticles const&) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols)) { + randgen = new TRandom2(0); + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, ConfNEventsMix, -1, cols, cols)) { const int multiplicityCol = collision1.multV0M(); - MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); const auto& magFieldTesla2 = collision2.magField(); @@ -791,21 +857,106 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { if (cfgProcessPM) { auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); - doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 1); + doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 1); } if (cfgProcessPP) { auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); auto groupPartsTwo = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); - doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 2); + doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 2); } if (cfgProcessMM) { auto groupPartsOne = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); - doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 3); + doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 3); } } + delete randgen; + } + PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processMixedEventMCCent, "Enable processing mixed events MC", false); + + /// process function for to call doMixedEvent with Data + /// @param cols subscribe to the collisions table (Data) + /// @param parts subscribe to the femtoUniverseParticleTable + void processMixedEventNtr(FilteredFDCollisions& cols, + FilteredFemtoFullParticles& parts) + { + randgen = new TRandom2(0); + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningNtr, ConfNEventsMix, -1, cols, cols)) { + + const int multiplicityCol = collision1.multNtr(); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningNtr.getBin({collision1.posZ(), multiplicityCol})); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + continue; + } + + if (cfgProcessPM) { + auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 1); + } + if (cfgProcessPP) { + auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 2); + } + if (cfgProcessMM) { + auto groupPartsOne = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 3); + } + } + delete randgen; + } + PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processMixedEventNtr, "Enable processing mixed events", false); + + /// brief process function for to call doMixedEvent with Monte Carlo + /// @param cols subscribe to the collisions table (Monte Carlo Reconstructed reconstructed) + /// @param parts subscribe to joined table FemtoUniverseParticles and FemtoUniverseMCLables to access Monte Carlo truth + /// @param FemtoUniverseMCParticles subscribe to the Monte Carlo truth table + void processMixedEventMCNtr(FilteredFDCollisions const& cols, + FemtoRecoParticles const& parts, + aod::FdMCParticles const&) + { + randgen = new TRandom2(0); + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, ConfNEventsMix, -1, cols, cols)) { + + const int multiplicityCol = collision1.multNtr(); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningNtr.getBin({collision1.posZ(), multiplicityCol})); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + continue; + } + /// \todo before mixing we should check whether both collisions contain a pair of particles! + // if (partsOne.size() == 0 || nPart2Evt1 == 0 || nPart1Evt2 == 0 || partsTwo.size() == 0 ) continue; + + if (cfgProcessPM) { + auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 1); + } + if (cfgProcessPP) { + auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 2); + } + if (cfgProcessMM) { + auto groupPartsOne = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 3); + } + } + delete randgen; } - PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processMixedEventMC, "Enable processing mixed events MC", false); + PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processMixedEventMCNtr, "Enable processing mixed events MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackExtended.cxx index 340096ae350..06665491396 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackExtended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackExtended.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -16,16 +16,15 @@ /// \author Anton Riedel, TU München, anton.riedel@tum.de /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch +#include +#include #include + #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" #include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/StepTHn.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "ReconstructionDataFormats/PID.h" -#include "Common/DataModel/PIDResponse.h" #include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" @@ -33,11 +32,12 @@ #include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" -#include "PWGCF/FemtoUniverse/Core/femtoUtils.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCorrection.h" using namespace o2; using namespace o2::analysis::femto_universe; +using namespace o2::analysis::femto_universe::efficiency_correction; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; @@ -54,6 +54,7 @@ static const float cutsTable[NPart][NCuts]{ } // namespace struct FemtoUniversePairTaskTrackTrackExtended { + Service pdgMC; /// Particle selection part @@ -94,9 +95,14 @@ struct FemtoUniversePairTaskTrackTrackExtended { /// Partition for particle 1 Partition partsOne = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && aod::femtouniverseparticle::sign == trackonefilter.confChargePart1 && aod::femtouniverseparticle::pt < trackonefilter.confPtHighPart1 && aod::femtouniverseparticle::pt > trackonefilter.confPtLowPart1; - Partition> partsOneMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && aod::femtouniverseparticle::sign == trackonefilter.confChargePart1 && aod::femtouniverseparticle::pt < trackonefilter.confPtHighPart1 && aod::femtouniverseparticle::pt > trackonefilter.confPtLowPart1; + Partition> partsOneMCReco = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && aod::femtouniverseparticle::sign == trackonefilter.confChargePart1 && aod::femtouniverseparticle::pt < trackonefilter.confPtHighPart1 && aod::femtouniverseparticle::pt > trackonefilter.confPtLowPart1; // && ((aod::femtouniverseparticle::cut & confCutPartOne) == confCutPartOne); + Partition> partsOneMCTruth = + aod::femtouniverseparticle::partType == static_cast(aod::femtouniverseparticle::ParticleType::kMCTruthTrack) && + aod::femtouniverseparticle::pt < trackonefilter.confPtHighPart1 && + aod::femtouniverseparticle::pt > trackonefilter.confPtLowPart1; + /// Histogramming for particle 1 FemtoUniverseParticleHisto trackHistoPartOne; @@ -113,7 +119,12 @@ struct FemtoUniversePairTaskTrackTrackExtended { /// Partition for particle 2 Partition partsTwo = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == tracktwofilter.confChargePart2) && aod::femtouniverseparticle::pt < tracktwofilter.confPtHighPart2 && aod::femtouniverseparticle::pt > tracktwofilter.confPtLowPart2; - Partition> partsTwoMC = aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack) && (aod::femtouniverseparticle::sign == tracktwofilter.confChargePart2) && aod::femtouniverseparticle::pt < tracktwofilter.confPtHighPart2 && aod::femtouniverseparticle::pt > tracktwofilter.confPtLowPart2; + Partition> partsTwoMCReco = aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack) && (aod::femtouniverseparticle::sign == tracktwofilter.confChargePart2) && aod::femtouniverseparticle::pt < tracktwofilter.confPtHighPart2 && aod::femtouniverseparticle::pt > tracktwofilter.confPtLowPart2; + + Partition> partsTwoMCTruth = + aod::femtouniverseparticle::partType == static_cast(aod::femtouniverseparticle::ParticleType::kMCTruthTrack) && + aod::femtouniverseparticle::pt < tracktwofilter.confPtHighPart2 && + aod::femtouniverseparticle::pt > tracktwofilter.confPtLowPart2; /// Histogramming for particle 2 FemtoUniverseParticleHisto trackHistoPartTwo; @@ -128,6 +139,7 @@ struct FemtoUniversePairTaskTrackTrackExtended { /// particle part ConfigurableAxis confTempFitVarBins{"confTempFitVarBins", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; ConfigurableAxis confTempFitVarpTBins{"confTempFitVarpTBins", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis confTempFitVarPDGBins{"confTempFitVarPDGBins", {6000, -2300, 2300}, "Binning of the PDG code in the pT vs. TempFitVar plot"}; /// Correlation part ConfigurableAxis confMultBins{"confMultBins", {VARIABLE_WIDTH, 0.0f, 4.0f, 8.0f, 12.0f, 16.0f, 20.0f, 24.0f, 28.0f, 32.0f, 36.0f, 40.0f, 44.0f, 48.0f, 52.0f, 56.0f, 60.0f, 64.0f, 68.0f, 72.0f, 76.0f, 80.0f, 84.0f, 88.0f, 92.0f, 96.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - multiplicity"}; // \todo to be obtained from the hash task @@ -162,9 +174,14 @@ struct FemtoUniversePairTaskTrackTrackExtended { HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry mixQaRegistry{"mixQaRegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry effCorrRegistry{"EfficiencyCorrection", {}, OutputObjHandlingPolicy::AnalysisObject}; + + EffCorConfigurableGroup effCorConfGroup; + EfficiencyCorrection effCorrection{&effCorConfGroup}; /// @brief Counter for particle swapping int fNeventsProcessed = 0; + // PID for protons bool isProtonNSigma(float mom, float nsigmaTPCPr, float nsigmaTOFPr) // previous version from: https://github.com/alisw/AliPhysics/blob/master/PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoMJTrackCut.cxx { @@ -296,12 +313,18 @@ struct FemtoUniversePairTaskTrackTrackExtended { return false; } + /// @returns 1 if positive, -1 if negative, 0 if zero + auto sign(auto number) -> int8_t + { + return (number > 0) - (number < 0); + } + void init(InitContext&) { eventHisto.init(&qaRegistry); - trackHistoPartOne.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarBins, twotracksconfigs.confIsMC, trackonefilter.confPDGCodePartOne, true); // last true = isDebug + trackHistoPartOne.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarBins, twotracksconfigs.confIsMC, trackonefilter.confPDGCodePartOne, true, std::nullopt); // last true = isDebug if (!confIsSame) { - trackHistoPartTwo.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarBins, twotracksconfigs.confIsMC, tracktwofilter.confPDGCodePartTwo, true); // last true = isDebug + trackHistoPartTwo.init(&qaRegistry, confTempFitVarpTBins, confTempFitVarBins, twotracksconfigs.confIsMC, tracktwofilter.confPDGCodePartTwo, true, std::nullopt); // last true = isDebug } mixQaRegistry.add("MixingQA/hSECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); @@ -319,6 +342,14 @@ struct FemtoUniversePairTaskTrackTrackExtended { vPIDPartOne = trackonefilter.confPIDPartOne.value; vPIDPartTwo = tracktwofilter.confPIDPartTwo.value; kNsigma = twotracksconfigs.confTrkPIDnSigmaMax.value; + + effCorrection.init( + &effCorrRegistry, + { + static_cast(confTempFitVarpTBins), + {confEtaBins, -2, 2}, + confMultBins, + }); } template @@ -328,6 +359,29 @@ struct FemtoUniversePairTaskTrackTrackExtended { eventHisto.fillQA(col); } + template + requires IsOneOrTwo + auto doMCTruth(auto parts, int partPDG, int partCharge) -> void + { + for (const auto& particle : parts) { + auto pdgCode = static_cast(particle.pidCut()); + if (pdgCode != partPDG) { + continue; + } + + const auto& pdgParticle = pdgMC->GetParticle(pdgCode); + if (!pdgParticle) { + continue; + } + + if (sign(pdgParticle->Charge()) != sign(partCharge)) { + continue; + } + + effCorrection.fillTruthHist(particle); + } + } + /// This function processes the same event and takes care of all the histogramming /// \todo the trivial loops over the tracks should be factored out since they will be common to all combinations of T-T, T-V0, V0-V0, ... /// @tparam PartitionType @@ -360,6 +414,7 @@ struct FemtoUniversePairTaskTrackTrackExtended { // twotracksconfigs.confCutTable->get("PartOne", "nSigmaTPCTOF"))) { // continue; // } + if (trackonefilter.confIsTrackOneIdentified) { if (!isParticleNSigma((int8_t)1, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) { continue; @@ -367,6 +422,9 @@ struct FemtoUniversePairTaskTrackTrackExtended { } trackHistoPartOne.fillQA(part); + if constexpr (isMC) { + effCorrection.fillRecoHist(part, trackonefilter.confPDGCodePartOne); + } } if (!confIsSame) { @@ -384,12 +442,16 @@ struct FemtoUniversePairTaskTrackTrackExtended { // twotracksconfigs.confCutTable->get("PartTwo", "nSigmaTPCTOF"))) { // continue; // } + if (tracktwofilter.confIsTrackTwoIdentified) { if (!isParticleNSigma((int8_t)2, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) { continue; } } trackHistoPartTwo.fillQA(part); + if constexpr (isMC) { + effCorrection.fillRecoHist(part, tracktwofilter.confPDGCodePartTwo); + } } /// Now build the combinations for non-identical particle pairs @@ -439,10 +501,15 @@ struct FemtoUniversePairTaskTrackTrackExtended { continue; } + float weight = effCorrection.getWeight(ParticleNo::ONE, p1); + if (!confIsSame) { + weight *= effCorrection.getWeight(ParticleNo::TWO, p2); + } + if (swpart) - sameEventCont.setPair(p1, p2, multCol, twotracksconfigs.confUse3D); + sameEventCont.setPair(p1, p2, multCol, twotracksconfigs.confUse3D, weight); else - sameEventCont.setPair(p2, p1, multCol, twotracksconfigs.confUse3D); + sameEventCont.setPair(p2, p1, multCol, twotracksconfigs.confUse3D, weight); swpart = !swpart; } @@ -494,7 +561,18 @@ struct FemtoUniversePairTaskTrackTrackExtended { if (!pairCleaner.isCleanPair(p1, p2, parts)) { continue; } - sameEventCont.setPair(p1, p2, multCol, twotracksconfigs.confUse3D); + + float weight = effCorrection.getWeight(ParticleNo::ONE, p1); + if (!confIsSame) { + weight *= effCorrection.getWeight(ParticleNo::TWO, p2); + } + + if (swpart) + sameEventCont.setPair(p1, p2, multCol, twotracksconfigs.confUse3D, weight); + else + sameEventCont.setPair(p2, p1, multCol, twotracksconfigs.confUse3D, weight); + + swpart = !swpart; } } } @@ -524,10 +602,18 @@ struct FemtoUniversePairTaskTrackTrackExtended { { fillCollision(col); - auto thegroupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto thegroupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupMCTruth1 = partsOneMCTruth->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + doMCTruth(groupMCTruth1, trackonefilter.confPDGCodePartOne, trackonefilter.confChargePart1); + + if (!confIsSame) { + auto groupMCTruth2 = partsTwoMCTruth->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + doMCTruth(groupMCTruth2, tracktwofilter.confPDGCodePartTwo, tracktwofilter.confChargePart2); + } + + auto groupMCReco1 = partsOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupMCReco2 = partsTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr()); + doSameEvent(groupMCReco1, groupMCReco2, parts, col.magField(), col.multNtr()); } PROCESS_SWITCH(FemtoUniversePairTaskTrackTrackExtended, processSameEventMC, "Enable processing same event for Monte Carlo", false); @@ -589,10 +675,15 @@ struct FemtoUniversePairTaskTrackTrackExtended { } } + float weight = effCorrection.getWeight(ParticleNo::ONE, p1); + if (!confIsSame) { + weight *= effCorrection.getWeight(ParticleNo::TWO, p2); + } + if (swpart) - mixedEventCont.setPair(p1, p2, multCol, twotracksconfigs.confUse3D); + mixedEventCont.setPair(p1, p2, multCol, twotracksconfigs.confUse3D, weight); else - mixedEventCont.setPair(p2, p1, multCol, twotracksconfigs.confUse3D); + mixedEventCont.setPair(p2, p1, multCol, twotracksconfigs.confUse3D, weight); swpart = !swpart; } @@ -639,8 +730,8 @@ struct FemtoUniversePairTaskTrackTrackExtended { const int multiplicityCol = collision1.multNtr(); mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); - auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); - auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + auto groupPartsOne = partsOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); const auto& magFieldTesla1 = collision1.magField(); const auto& magFieldTesla2 = collision2.magField(); diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMC.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMC.cxx index 09386709a01..5b74f18a31e 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMC.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMC.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMcTruth.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMcTruth.cxx index 91da795ca2f..d74b76ab237 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMcTruth.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMcTruth.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMultKtExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMultKtExtended.cxx index 9d862855874..76487c59269 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMultKtExtended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMultKtExtended.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackSpherHarMultKtExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackSpherHarMultKtExtended.cxx index 807a8e96dba..05c910b0b24 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackSpherHarMultKtExtended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackSpherHarMultKtExtended.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -24,7 +24,6 @@ #include "Framework/RunningWorkflowInfo.h" #include "Framework/StepTHn.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "TDatabasePDG.h" #include "ReconstructionDataFormats/PID.h" #include "Common/DataModel/PIDResponse.h" @@ -137,10 +136,11 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { Configurable ConfTPCOccupancyHigh{"ConfTPCOccupancyHigh", 500, "Higher limit for TPC occupancy"}; Configurable ConfIntRateLow{"ConfIntRateLow", 0.0, "Lower limit for interaction rate"}; Configurable ConfIntRateHigh{"ConfIntRateHigh", 10000.0, "Higher limit for interaction rate"}; + Configurable ConfIsCent{"ConfIsCent", true, "Condition to choose centrality of multiplicity for mixing"}; Filter collfilterFDtable = (o2::aod::femtouniversecollision::multV0M > ConfV0MLow) && (o2::aod::femtouniversecollision::multV0M < ConfV0MHigh); Filter collfilterFDExttable = (o2::aod::femtouniversecollision::interactionRate > ConfIntRateLow) && (o2::aod::femtouniversecollision::interactionRate < ConfIntRateHigh) && - (o2::aod::femtouniversecollision::occupancy > ConfTPCOccupancyLow) && (o2::aod::femtouniversecollision::occupancy < ConfTPCOccupancyHigh); + (o2::aod::femtouniversecollision::occupancy >= ConfTPCOccupancyLow) && (o2::aod::femtouniversecollision::occupancy < ConfTPCOccupancyHigh); using FilteredFDCollisions = soa::Filtered>; using FilteredFDCollision = FilteredFDCollisions::iterator; // Filter trackAdditionalfilter = (nabs(aod::femtouniverseparticle::eta) < twotracksconfigs.ConfEtaMax); // example filtering on configurable @@ -150,7 +150,8 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { ConfigurableAxis ConfTempFitVarpTBins{"ConfTempFitVarpTBins", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot"}; /// Correlation part - ConfigurableAxis ConfMultBins{"ConfMultBins", {VARIABLE_WIDTH, 0.0f, 4.0f, 8.0f, 12.0f, 16.0f, 20.0f, 24.0f, 28.0f, 32.0f, 36.0f, 40.0f, 44.0f, 48.0f, 52.0f, 56.0f, 60.0f, 64.0f, 68.0f, 72.0f, 76.0f, 80.0f, 84.0f, 88.0f, 92.0f, 96.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - multiplicity or centrality"}; // \todo to be obtained from the hash task + ConfigurableAxis ConfMultBinsCent{"ConfMultBinsCent", {VARIABLE_WIDTH, 0.0f, 4.0f, 8.0f, 12.0f, 16.0f, 20.0f, 24.0f, 28.0f, 32.0f, 36.0f, 40.0f, 44.0f, 48.0f, 52.0f, 56.0f, 60.0f, 64.0f, 68.0f, 72.0f, 76.0f, 80.0f, 84.0f, 88.0f, 92.0f, 96.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - centrality"}; // \todo to be obtained from the hash task + ConfigurableAxis ConfMultBinsMult{"ConfMultBinsMult", {VARIABLE_WIDTH, 0.0f, 400.0f, 800.0f, 1200.0f, 1600.0f, 2000.0f, 2500.0f, 3000.0f, 3500.0f, 4000.0f, 4500.0f, 5000.0f, 6000.0f, 7000.0f, 8000.0f, 9000.0f, 10000.0f, 11000.0f, 12000.0f, 13000.0f, 14000.0f, 15000.0f, 16000.0f, 17000.0f, 18000.0f, 99999.f}, "Mixing bins - centrality"}; ConfigurableAxis ConfMultKstarBins{"ConfMultKstarBins", {VARIABLE_WIDTH, 0.0f, 200.0f}, "Bins for kstar analysis in multiplicity or centrality bins (10 is maximum)"}; ConfigurableAxis ConfKtKstarBins{"ConfKtKstarBins", {VARIABLE_WIDTH, 0.1f, 0.2f, 0.3f, 0.4f}, "Bins for kstar analysis in kT bins"}; ConfigurableAxis ConfVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; @@ -158,7 +159,8 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { ConfigurableAxis ConfmTBins3D{"ConfmTBins3D", {VARIABLE_WIDTH, 1.02f, 1.14f, 1.20f, 1.26f, 1.38f, 1.56f, 1.86f, 4.50f}, "mT Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; ConfigurableAxis ConfmultBins3D{"ConfmultBins3D", {VARIABLE_WIDTH, 0.0f, 20.0f, 30.0f, 40.0f, 99999.0f}, "multiplicity Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; - ColumnBinningPolicy colBinning{{ConfVtxBins, ConfMultBins}, true}; + ColumnBinningPolicy colBinningCent{{ConfVtxBins, ConfMultBinsCent}, true}; + ColumnBinningPolicy colBinningNtr{{ConfVtxBins, ConfMultBinsMult}, true}; ConfigurableAxis ConfkstarBins{"ConfkstarBins", {60, 0.0, 0.3}, "binning kstar"}; ConfigurableAxis ConfkTBins{"ConfkTBins", {150, 0., 9.}, "binning kT"}; @@ -180,6 +182,10 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { Configurable cfgProcessMultBins{"cfgProcessMultBins", true, "Process kstar histograms in multiplicity bins (in multiplicity bins)"}; Configurable cfgProcessKtBins{"cfgProcessKtBins", true, "Process kstar histograms in kT bins (if cfgProcessMultBins is set false, this will not be processed regardless this Configurable state)"}; Configurable cfgProcessKtMt3DCF{"cfgProcessKtMt3DCF", false, "Process 3D histograms in kT and Mult bins"}; + Configurable ConfIsFillAngqLCMS{"ConfIsFillAngqLCMS", true, "Fill qLCMS vs dEta vs dPhi"}; + Configurable confCPRDistMax{"confCPRDistMax", 0.0, "Max. radial seperation between two closed-pairs"}; + Configurable confCPRFracMax{"confCPRFracMax", 0.0, "Max. allowed fraction bad to all TPC points of radial seperation between two closed-pairs"}; + Configurable confCPRDphiAvgOrDist{"confCPRDphiAvgOrDist", true, "Close Pair Rejection by radial or angular seperation"}; FemtoUniverseSHContainer sameEventCont; FemtoUniverseSHContainer mixedEventCont; @@ -237,13 +243,13 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { // ConfNsigmaCombined -> TPC and TOF Sigma (combined) for momentum > 0.5 if (mom < twotracksconfigs.ConfTOFPtMin) { - if (TMath::Abs(nsigmaTPCPr) < twotracksconfigs.ConfNsigmaTPC) { + if (std::abs(nsigmaTPCPr) < twotracksconfigs.ConfNsigmaTPC) { return true; } else { return false; } } else { - if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < twotracksconfigs.ConfNsigmaCombined) { + if (std::hypot(nsigmaTOFPr, nsigmaTPCPr) < twotracksconfigs.ConfNsigmaCombined) { return true; } else { return false; @@ -255,25 +261,25 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { bool IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK) { if (mom < 0.3) { // 0.0-0.3 - if (TMath::Abs(nsigmaTPCK) < 3.0) { + if (std::abs(nsigmaTPCK) < 3.0) { return true; } else { return false; } } else if (mom < 0.45) { // 0.30 - 0.45 - if (TMath::Abs(nsigmaTPCK) < 2.0) { + if (std::abs(nsigmaTPCK) < 2.0) { return true; } else { return false; } } else if (mom < 0.55) { // 0.45-0.55 - if (TMath::Abs(nsigmaTPCK) < 1.0) { + if (std::abs(nsigmaTPCK) < 1.0) { return true; } else { return false; } } else if (mom < 1.5) { // 0.55-1.5 (now we use TPC and TOF) - if ((TMath::Abs(nsigmaTOFK) < 3.0) && (TMath::Abs(nsigmaTPCK) < 3.0)) { + if ((std::abs(nsigmaTOFK) < 3.0) && (std::abs(nsigmaTPCK) < 3.0)) { { return true; } @@ -281,7 +287,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { return false; } } else if (mom > 1.5) { // 1.5 - - if ((TMath::Abs(nsigmaTOFK) < 2.0) && (TMath::Abs(nsigmaTPCK) < 3.0)) { + if ((std::abs(nsigmaTOFK) < 2.0) && (std::abs(nsigmaTPCK) < 3.0)) { return true; } else { return false; @@ -302,13 +308,13 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { // ConfNsigmaCombined -> TPC and TOF Pion Sigma (combined) for momentum > 0.5 if (true) { if (mom < twotracksconfigs.ConfTOFPtMin) { - if (TMath::Abs(nsigmaTPCPi) < twotracksconfigs.ConfNsigmaTPC) { + if (std::abs(nsigmaTPCPi) < twotracksconfigs.ConfNsigmaTPC) { return true; } else { return false; } } else { - if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < twotracksconfigs.ConfNsigmaCombined) { + if (std::hypot(nsigmaTOFPi, nsigmaTPCPi) < twotracksconfigs.ConfNsigmaCombined) { return true; } else { return false; @@ -422,9 +428,13 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { } template - void fillCollision(CollisionType col) + void fillCollision(CollisionType col, bool IsCent) { - MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multV0M()})); + if (IsCent) { + MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinningCent.getBin({col.posZ(), col.multV0M()})); + } else { + MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinningNtr.getBin({col.posZ(), col.multNtr()})); + } eventHisto.fillQA(col); } @@ -444,7 +454,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { /// Histogramming same event if ((ContType == 1 || ContType == 2) && fillQA) { - for (auto& part : groupPartsOne) { + for (const auto& part : groupPartsOne) { if (!IsParticleNSigma((int8_t)1, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) { continue; } @@ -453,7 +463,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { } if ((ContType == 1 || ContType == 3) && fillQA) { - for (auto& part : groupPartsTwo) { + for (const auto& part : groupPartsTwo) { if (!IsParticleNSigma((int8_t)2, part.p(), trackCuts.getNsigmaTPC(part, o2::track::PID::Proton), trackCuts.getNsigmaTOF(part, o2::track::PID::Proton), trackCuts.getNsigmaTPC(part, o2::track::PID::Pion), trackCuts.getNsigmaTOF(part, o2::track::PID::Pion), trackCuts.getNsigmaTPC(part, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(part, o2::track::PID::Kaon))) { continue; } @@ -464,7 +474,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { if (ContType == 1) { /// Now build the combinations for non-identical particle pairs - for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { if (!IsParticleNSigma((int8_t)1, p1.p(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p1, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p1, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p1, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon))) { continue; @@ -475,7 +485,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { } if (ConfIsCPR.value) { - if (pairCloseRejection.isClosePair(p1, p2, parts, magFieldTesla, femto_universe_container::EventType::same)) { + if (pairCloseRejection.isClosePairFrac(p1, p2, magFieldTesla, femto_universe_container::EventType::same, confCPRDphiAvgOrDist, confCPRDistMax, confCPRFracMax)) { continue; } } @@ -488,7 +498,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { sameEventMultCont.fillMultNumDen(p1, p2, femto_universe_sh_container::EventType::same, 2, multCol, kT, ConfIsIden); } } else { - for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsOne, groupPartsOne))) { + for (const auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsOne, groupPartsOne))) { if (!IsParticleNSigma((int8_t)2, p1.p(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p1, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p1, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p1, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon))) { continue; @@ -499,7 +509,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { } if (ConfIsCPR.value) { - if (pairCloseRejection.isClosePair(p1, p2, parts, magFieldTesla, femto_universe_container::EventType::same)) { + if (pairCloseRejection.isClosePairFrac(p1, p2, magFieldTesla, femto_universe_container::EventType::same, confCPRDphiAvgOrDist, confCPRDistMax, confCPRFracMax)) { continue; } } @@ -513,12 +523,21 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { double rand; rand = randgen->Rndm(); + std::vector f3d; + double kv; + switch (ContType) { case 2: { if (rand > 0.5) { sameEventMultContPP.fillMultNumDen(p1, p2, femto_universe_sh_container::EventType::same, 2, multCol, kT, ConfIsIden); + f3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); } else if (rand <= 0.5) { sameEventMultContPP.fillMultNumDen(p2, p1, femto_universe_sh_container::EventType::same, 2, multCol, kT, ConfIsIden); + f3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); + } + if (ConfIsFillAngqLCMS) { + kv = std::sqrt(f3d[1] * f3d[1] + f3d[2] * f3d[2] + f3d[3] * f3d[3]); + pairCloseRejection.ClosePairqLCMS(p1, p2, magFieldTesla, femto_universe_container::EventType::same, kv); } break; } @@ -526,8 +545,14 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { case 3: { if (rand > 0.5) { sameEventMultContMM.fillMultNumDen(p1, p2, femto_universe_sh_container::EventType::same, 2, multCol, kT, ConfIsIden); + f3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); } else if (rand <= 0.5) { sameEventMultContMM.fillMultNumDen(p2, p1, femto_universe_sh_container::EventType::same, 2, multCol, kT, ConfIsIden); + f3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); + } + if (ConfIsFillAngqLCMS) { + kv = std::sqrt(f3d[1] * f3d[1] + f3d[2] * f3d[2] + f3d[3] * f3d[3]); + pairCloseRejection.ClosePairqLCMS(p1, p2, magFieldTesla, femto_universe_container::EventType::same, kv); } break; } @@ -541,10 +566,10 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { /// process function for to call doSameEvent with Data /// \param col subscribe to the collision table (Data) /// \param parts subscribe to the femtoUniverseParticleTable - void processSameEvent(FilteredFDCollision& col, - FilteredFemtoFullParticles& parts) + void processSameEvent(FilteredFDCollision const& col, + FilteredFemtoFullParticles const& parts) { - fillCollision(col); + fillCollision(col, ConfIsCent); auto thegroupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto thegroupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); @@ -552,16 +577,26 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { bool fillQA = true; randgen = new TRandom2(0); - if (cfgProcessPM) { - doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); - } - - if (cfgProcessPP) { - doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); - } - - if (cfgProcessMM) { - doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); + if (ConfIsCent) { + if (cfgProcessPM) { + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); + } + if (cfgProcessPP) { + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); + } + if (cfgProcessMM) { + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); + } + } else { + if (cfgProcessPM) { + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 1, fillQA); + } + if (cfgProcessPP) { + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multNtr(), 2, fillQA); + } + if (cfgProcessMM) { + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 3, fillQA); + } } delete randgen; } @@ -571,14 +606,39 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { /// \param col subscribe to the collision table (Monte Carlo Reconstructed reconstructed) /// \param parts subscribe to joined table FemtoUniverseParticles and FemtoUniverseMCLables to access Monte Carlo truth /// \param FemtoUniverseMCParticles subscribe to the Monte Carlo truth table - void processSameEventMC(o2::aod::FdCollision& col, - soa::Join& /*parts*/, - o2::aod::FdMCParticles&) + void processSameEventMC(o2::aod::FdCollision const& col, + soa::Join const& parts, + o2::aod::FdMCParticles const&) { - fillCollision(col); + fillCollision(col, ConfIsCent); auto thegroupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); auto thegroupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + bool fillQA = true; + randgen = new TRandom2(0); + + if (ConfIsCent) { + if (cfgProcessPM) { + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); + } + if (cfgProcessPP) { + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); + } + if (cfgProcessMM) { + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); + } + } else { + if (cfgProcessPM) { + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 1, fillQA); + } + if (cfgProcessPP) { + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multNtr(), 2, fillQA); + } + if (cfgProcessMM) { + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 3, fillQA); + } + } + delete randgen; } PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processSameEventMC, "Enable processing same event for Monte Carlo", false); @@ -592,11 +652,11 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { /// \param parts femtoUniverseParticles table (in case of Monte Carlo joined with FemtoUniverseMCLabels) /// \param magFieldTesla magnetic field of the collision /// \param multCol multiplicity of the collision - template - void doMixedEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, PartType parts, float magFieldTesla, int multCol, int ContType) + template + void doMixedEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, float magFieldTesla, int multCol, int ContType) { - for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { if (!IsParticleNSigma((int8_t)2, p1.p(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p1, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p1, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p1, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon))) { continue; @@ -607,7 +667,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { } if (ConfIsCPR.value) { - if (pairCloseRejection.isClosePair(p1, p2, parts, magFieldTesla, femto_universe_container::EventType::mixed)) { + if (pairCloseRejection.isClosePairFrac(p1, p2, magFieldTesla, femto_universe_container::EventType::mixed, confCPRDphiAvgOrDist, confCPRDistMax, confCPRFracMax)) { continue; } } @@ -616,6 +676,9 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { double rand; rand = randgen->Rndm(); + std::vector f3d; + double kv; + switch (ContType) { case 1: { if (rand > 0.5) { @@ -629,8 +692,14 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { case 2: { if (rand > 0.5) { mixedEventMultContPP.fillMultNumDen(p1, p2, femto_universe_sh_container::EventType::mixed, 2, multCol, kT, ConfIsIden); + f3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); } else { mixedEventMultContPP.fillMultNumDen(p2, p1, femto_universe_sh_container::EventType::mixed, 2, multCol, kT, ConfIsIden); + f3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); + } + if (ConfIsFillAngqLCMS) { + kv = std::sqrt(f3d[1] * f3d[1] + f3d[2] * f3d[2] + f3d[3] * f3d[3]); + pairCloseRejection.ClosePairqLCMS(p1, p2, magFieldTesla, femto_universe_container::EventType::mixed, kv); } break; } @@ -638,8 +707,14 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { case 3: { if (rand > 0.5) { mixedEventMultContMM.fillMultNumDen(p1, p2, femto_universe_sh_container::EventType::mixed, 2, multCol, kT, ConfIsIden); + f3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); } else { mixedEventMultContMM.fillMultNumDen(p2, p1, femto_universe_sh_container::EventType::mixed, 2, multCol, kT, ConfIsIden); + f3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); + } + if (ConfIsFillAngqLCMS) { + kv = std::sqrt(f3d[1] * f3d[1] + f3d[2] * f3d[2] + f3d[3] * f3d[3]); + pairCloseRejection.ClosePairqLCMS(p1, p2, magFieldTesla, femto_universe_container::EventType::mixed, kv); } break; } @@ -652,16 +727,16 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { /// process function for to call doMixedEvent with Data /// @param cols subscribe to the collisions table (Data) - /// @param parts subscribe to the femtoUniverseParticleTable - void processMixedEvent(FilteredFDCollisions& cols, - FilteredFemtoFullParticles& parts) + /// @param subscribe to the femtoUniverseParticleTable + void processMixedEventCent(FilteredFDCollisions const& cols, + FilteredFemtoFullParticles const&) { randgen = new TRandom2(0); - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols)) { + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, ConfNEventsMix, -1, cols, cols)) { const int multiplicityCol = collision1.multV0M(); - MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); const auto& magFieldTesla2 = collision2.magField(); @@ -673,27 +748,68 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { if (cfgProcessPM) { auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); - doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 1); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 1); } if (cfgProcessPP) { auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); auto groupPartsTwo = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); - doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 2); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 2); } if (cfgProcessMM) { auto groupPartsOne = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); - doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 3); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 3); } } delete randgen; } + PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processMixedEventCent, "Enable processing mixed events for centrality", true); + + /// process function for to call doMixedEvent with Data + /// @param cols subscribe to the collisions table (Data) + /// @param parts subscribe to the femtoUniverseParticleTable + void processMixedEventNtr(FilteredFDCollisions const& cols, + FilteredFemtoFullParticles const&) + { + randgen = new TRandom2(0); + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningNtr, ConfNEventsMix, -1, cols, cols)) { + + const int multiplicityCol = collision1.multNtr(); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningNtr.getBin({collision1.posZ(), multiplicityCol})); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + continue; + } + + if (cfgProcessPM) { + auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 1); + } + if (cfgProcessPP) { + auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 2); + } + if (cfgProcessMM) { + auto groupPartsOne = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 3); + } + } + delete randgen; + } + PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processMixedEventNtr, "Enable processing mixed events for centrality", false); /// process function for to fill covariance histograms /// \param col subscribe to the collision table (Data) /// \param parts subscribe to the femtoUniverseParticleTable - void processCov(soa::Filtered::iterator& /*col*/, - FilteredFemtoFullParticles& /*parts*/) + void processCov(soa::Filtered::iterator const& /*col*/, + FilteredFemtoFullParticles const& /*parts*/) { int JMax = (ConfLMax + 1) * (ConfLMax + 1); if (cfgProcessMM) { @@ -707,22 +823,66 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { mixedEventMultCont.fillMultkTCov(femto_universe_sh_container::EventType::mixed, JMax); } } - PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processCov, "Enable processing same event covariance", true); + PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processCov, "Enable processing same event covariance", false); + + /// brief process function for to call doMixedEvent with Monte Carlo + /// @param cols subscribe to the collisions table (Monte Carlo Reconstructed reconstructed) + /// @param parts subscribe to joined table FemtoUniverseParticles and FemtoUniverseMCLables to access Monte Carlo truth + /// @param FemtoUniverseMCParticles subscribe to the Monte Carlo truth table + void processMixedEventMCCent(o2::aod::FdCollisions const& cols, + soa::Join const&, + o2::aod::FdMCParticles const&) + { + randgen = new TRandom2(0); + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, ConfNEventsMix, -1, cols, cols)) { + + const int multiplicityCol = collision1.multV0M(); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), multiplicityCol})); - PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processMixedEvent, "Enable processing mixed events", true); + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + continue; + } + /// \todo before mixing we should check whether both collisions contain a pair of particles! + // if (partsOne.size() == 0 || nPart2Evt1 == 0 || nPart1Evt2 == 0 || partsTwo.size() == 0 ) continue; + + if (cfgProcessPM) { + auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 1); + } + if (cfgProcessPP) { + auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 2); + } + if (cfgProcessMM) { + auto groupPartsOne = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 3); + } + } + delete randgen; + } + PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processMixedEventMCCent, "Enable processing mixed events MC", false); /// brief process function for to call doMixedEvent with Monte Carlo /// @param cols subscribe to the collisions table (Monte Carlo Reconstructed reconstructed) /// @param parts subscribe to joined table FemtoUniverseParticles and FemtoUniverseMCLables to access Monte Carlo truth /// @param FemtoUniverseMCParticles subscribe to the Monte Carlo truth table - void processMixedEventMC(o2::aod::FdCollisions& cols, - soa::Join& /*parts*/, - o2::aod::FdMCParticles&) + void processMixedEventMCNtr(o2::aod::FdCollisions const& cols, + soa::Join const&, + o2::aod::FdMCParticles const&) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols)) { + randgen = new TRandom2(0); + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningNtr, ConfNEventsMix, -1, cols, cols)) { const int multiplicityCol = collision1.multV0M(); - MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningNtr.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); const auto& magFieldTesla2 = collision2.magField(); @@ -732,9 +892,26 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { } /// \todo before mixing we should check whether both collisions contain a pair of particles! // if (partsOne.size() == 0 || nPart2Evt1 == 0 || nPart1Evt2 == 0 || partsTwo.size() == 0 ) continue; + + if (cfgProcessPM) { + auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 1); + } + if (cfgProcessPP) { + auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 2); + } + if (cfgProcessMM) { + auto groupPartsOne = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + doMixedEvent(groupPartsOne, groupPartsTwo, magFieldTesla1, multiplicityCol, 3); + } } + delete randgen; } - PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processMixedEventMC, "Enable processing mixed events MC", false); + PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processMixedEventMCNtr, "Enable processing mixed events MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackV0Extended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackV0Extended.cxx index 2b61f46291d..cd7cf167027 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackV0Extended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackV0Extended.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -15,25 +15,26 @@ /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch /// \author Shirajum Monira, WUT Warsaw, shirajum.monira.dokt@pw.edu.pl -#include -#include -#include -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/StepTHn.h" -#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" -#include "PWGCF/FemtoUniverse/Core/femtoUtils.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCorrection.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" #include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + #include #include +#include + +#include +#include +#include using namespace o2; using namespace o2::soa; @@ -42,6 +43,7 @@ using namespace o2::framework::expressions; using namespace o2::analysis::femto_universe; using namespace o2::aod::pidutils; using namespace o2::track; +using namespace o2::analysis::femto_universe::efficiency_correction; struct FemtoUniversePairTaskTrackV0Extended { @@ -51,7 +53,7 @@ struct FemtoUniversePairTaskTrackV0Extended { using FemtoFullParticles = soa::Join; Preslice perCol = aod::femtouniverseparticle::fdCollisionId; - using FemtoRecoParticles = soa::Join; + using FemtoRecoParticles = soa::Join; Preslice perColMC = aod::femtouniverseparticle::fdCollisionId; /// To apply narrow cut @@ -142,6 +144,9 @@ struct FemtoUniversePairTaskTrackV0Extended { // Efficiency Configurable confLocalEfficiency{"confLocalEfficiency", "", "Local path to efficiency .root file"}; + EffCorConfigurableGroup effCorConfGroup; + EfficiencyCorrection effCorrection{&effCorConfGroup}; + static constexpr unsigned int V0ChildTable[][2] = {{0, 1}, {1, 0}, {1, 1}}; // Table to select the V0 children FemtoUniverseContainer sameEventCont; @@ -156,8 +161,6 @@ struct FemtoUniversePairTaskTrackV0Extended { HistogramRegistry registryMCtruth{"MCtruthHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; HistogramRegistry registryMCreco{"MCrecoHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; - HistogramRegistry mixQaRegistry{"mixQaRegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; - std::unique_ptr plocalEffFile; std::unique_ptr plocalEffp1; std::unique_ptr plocalEffp2; @@ -219,6 +222,10 @@ struct FemtoUniversePairTaskTrackV0Extended { posChildHistos.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true); negChildHistos.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true); + qaRegistry.add("V0Type1/hInvMassLambdaVsCent", "; Centrality; M_{#Lambda}; Entries", kTH2F, {confMultBins, {2000, 1.f, 3.f}}); + qaRegistry.add("V0Type2/hInvMassLambdaVsCent", "; Centrality; M_{#Lambda}; Entries", kTH2F, {confMultBins, {2000, 1.f, 3.f}}); + qaRegistry.add("V0Type1/hInvMassAntiLambdaVsCent", "; Centrality; M_{#Lambda}; Entries", kTH2F, {confMultBins, {2000, 1.f, 3.f}}); + qaRegistry.add("V0Type2/hInvMassAntiLambdaVsCent", "; Centrality; M_{#Lambda}; Entries", kTH2F, {confMultBins, {2000, 1.f, 3.f}}); trackHistoV0Type1.init(&qaRegistry, confV0TempFitVarpTBins, confV0TempFitVarBins, confIsMC, confV0PDGCodePartTwo, true, "V0Type1"); posChildV0Type1.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "posChildV0Type1"); negChildV0Type1.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "negChildV0Type1"); @@ -226,7 +233,7 @@ struct FemtoUniversePairTaskTrackV0Extended { posChildV0Type2.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "posChildV0Type2"); negChildV0Type2.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "negChildV0Type2"); - mixQaRegistry.add("MixingQA/hMECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); + qaRegistry.add("MixingQA/hMECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); // MC truth registryMCtruth.add("plus/MCtruthLambda", "MC truth Lambdas;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); @@ -246,6 +253,8 @@ struct FemtoUniversePairTaskTrackV0Extended { registryMCtruth.add("minus/MCtruthPiPt", "MC truth pions;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); registryMCtruth.add("minus/MCtruthPrPt", "MC truth protons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + registryMCtruth.add("motherParticle", "pair fractions;part1 mother PDG;part2 mother PDG", {HistType::kTH2F, {{8001, -4000, 4000}, {8001, -4000, 4000}}}); + // MC reco registryMCreco.add("plus/MCrecoLambda", "MC reco Lambdas;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); registryMCreco.add("plus/MCrecoLambdaChildPr", "MC reco Lambdas;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); @@ -268,6 +277,8 @@ struct FemtoUniversePairTaskTrackV0Extended { registryMCreco.add("minus/MCrecoPiPt", "MC reco pions;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); registryMCreco.add("minus/MCrecoPrPt", "MC reco protons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + registryMCreco.add("motherParticle", "pair fractions;part1 mother PDG;part2 mother PDG", {HistType::kTH2F, {{8001, -4000, 4000}, {8001, -4000, 4000}}}); + sameEventCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confMultBins3D, confmTBins3D, confEtaBins, confPhiBins, confIsMC, confUse3D); sameEventCont.setPDGCodes(confTrkPDGCodePartOne, confV0PDGCodePartTwo); mixedEventCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confMultBins3D, confmTBins3D, confEtaBins, confPhiBins, confIsMC, confUse3D); @@ -294,6 +305,8 @@ struct FemtoUniversePairTaskTrackV0Extended { LOGF(info, "Loaded efficiency histograms for V0-V0."); } } + + effCorrection.init(&qaRegistry, {static_cast(confV0TempFitVarpTBins), {confEtaBins, -2, 2}, confMultBins}); } /// This function processes the same event for track - V0 template @@ -372,28 +385,12 @@ struct FemtoUniversePairTaskTrackV0Extended { } } - void processSameEvent(FilteredFDCollision const& col, FemtoFullParticles const& parts) - { - auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - doSameEvent(col, parts, groupPartsOne, groupPartsTwo); - } - PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processSameEvent, "Enable processing same event for track - V0", false); - - void processSameEventMCReco(FilteredFDCollision const& col, FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts) - { - auto groupPartsOne = partsOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto groupPartsTwo = partsTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - doSameEvent(col, parts, groupPartsOne, groupPartsTwo, mcparts); - } - PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processSameEventMCReco, "Enable processing same event for track - V0 MC Reco", false); - /// This function processes the same event for V0 - V0 - void processSameEventV0(FilteredFDCollision const& col, FemtoFullParticles const& parts) + template + void doSameEventV0(FilteredFDCollision const& col, PartType const& parts, PartitionType& groupPartsTwo, [[maybe_unused]] MCParticles mcParts = nullptr) { const auto& magFieldTesla = col.magField(); - auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); const int multCol = confUseCent ? col.multV0M() : col.multNtr(); eventHisto.fillQA(col); @@ -410,12 +407,22 @@ struct FemtoUniversePairTaskTrackV0Extended { trackHistoV0Type1.fillQABase(part, HIST("V0Type1")); posChildV0Type1.fillQABase(posChild, HIST("posChildV0Type1")); negChildV0Type1.fillQABase(negChild, HIST("negChildV0Type1")); + qaRegistry.fill(HIST("V0Type1/hInvMassLambdaVsCent"), multCol, part.mLambda()); + qaRegistry.fill(HIST("V0Type1/hInvMassAntiLambdaVsCent"), multCol, part.mAntiLambda()); + if constexpr (isMC) { + effCorrection.fillRecoHist(part, kLambda0); + } } /// Check daughters of second V0 particle if (isParticleTPC(posChild, V0ChildTable[confV0Type2][0]) && isParticleTPC(negChild, V0ChildTable[confV0Type2][1])) { trackHistoV0Type2.fillQABase(part, HIST("V0Type2")); posChildV0Type2.fillQABase(posChild, HIST("posChildV0Type2")); negChildV0Type2.fillQABase(negChild, HIST("negChildV0Type2")); + qaRegistry.fill(HIST("V0Type2/hInvMassLambdaVsCent"), multCol, part.mLambda()); + qaRegistry.fill(HIST("V0Type2/hInvMassAntiLambdaVsCent"), multCol, part.mAntiLambda()); + if constexpr (isMC) { + effCorrection.fillRecoHist(part, kLambda0Bar); + } } } @@ -447,8 +454,12 @@ struct FemtoUniversePairTaskTrackV0Extended { if (!isParticleTPC(posChild2, V0ChildTable[confV0Type2][0]) || !isParticleTPC(negChild2, V0ChildTable[confV0Type2][1])) return; - sameEventCont.setPair(p1, p2, multCol, confUse3D); + if constexpr (std::is_same::value) + sameEventCont.setPair(p1, p2, multCol, confUse3D); + else + sameEventCont.setPair(p1, p2, multCol, confUse3D); }; + if (confV0Type1 == confV0Type2) { /// Now build the combinations for identical V0s for (const auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsTwo, groupPartsTwo))) { @@ -462,8 +473,38 @@ struct FemtoUniversePairTaskTrackV0Extended { } } + void + processSameEvent(FilteredFDCollision const& col, FemtoFullParticles const& parts) + { + auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + doSameEvent(col, parts, groupPartsOne, groupPartsTwo); + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processSameEvent, "Enable processing same event for track - V0", false); + + void processSameEventMCReco(FilteredFDCollision const& col, FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts) + { + auto groupPartsOne = partsOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsTwo = partsTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + doSameEvent(col, parts, groupPartsOne, groupPartsTwo, mcparts); + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processSameEventMCReco, "Enable processing same event for track - V0 MC Reco", false); + + /// This function processes the same event for V0 - V0 + void processSameEventV0(FilteredFDCollision const& col, FemtoFullParticles const& parts) + { + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + doSameEventV0(col, parts, groupPartsTwo); + } PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processSameEventV0, "Enable processing same event for V0 - V0", false); + void processSameEventV0MCReco(FilteredFDCollision const& col, FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts) + { + auto groupPartsTwo = partsTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + doSameEventV0(col, parts, groupPartsTwo, mcparts); + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processSameEventV0MCReco, "Enable processing same event for V0 - V0 MC Reco", false); + /// This function processes MC same events for Track - V0 void processMCSameEvent(FilteredFDCollision const& col, FemtoFullParticles const& parts) { @@ -478,7 +519,7 @@ struct FemtoUniversePairTaskTrackV0Extended { /// Histogramming same event for (const auto& part : groupPartsTwo) { int pdgCode = static_cast(part.pidCut()); - if ((confV0Type1 == 0 && pdgCode != 3122) || (confV0Type1 == 1 && pdgCode != -3122)) + if ((confV0Type1 == 0 && pdgCode != kLambda0) || (confV0Type1 == 1 && pdgCode != kLambda0Bar)) continue; trackHistoPartTwo.fillQA(part); } @@ -504,7 +545,7 @@ struct FemtoUniversePairTaskTrackV0Extended { if (static_cast(p1.pidCut()) != confTrkPDGCodePartOne) continue; int pdgCode2 = static_cast(p2.pidCut()); - if ((confV0Type1 == 0 && pdgCode2 != 3122) || (confV0Type1 == 1 && pdgCode2 != -3122)) + if ((confV0Type1 == 0 && pdgCode2 != kLambda0) || (confV0Type1 == 1 && pdgCode2 != kLambda0Bar)) continue; // track cleaning if (confIsCPR.value) { @@ -519,7 +560,7 @@ struct FemtoUniversePairTaskTrackV0Extended { PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processMCSameEvent, "Enable processing same event for MC truth track - V0", false); /// This function processes MC same events for V0 - V0 - void processMCSameEventV0(FilteredFDCollision const& col, FemtoFullParticles const& /*parts*/) + void processMCSameEventV0(FilteredFDCollision const& col, FemtoFullParticles const& parts) { auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); const int multCol = confUseCent ? col.multV0M() : col.multNtr(); @@ -528,18 +569,33 @@ struct FemtoUniversePairTaskTrackV0Extended { /// Histogramming same event for (const auto& part : groupPartsTwo) { + const auto& posChild = parts.iteratorAt(part.index() - 2); + const auto& negChild = parts.iteratorAt(part.index() - 1); int pdgCode = static_cast(part.pidCut()); - if ((confV0Type1 == 0 && pdgCode != 3122) || (confV0Type1 == 1 && pdgCode != -3122)) - continue; - trackHistoPartTwo.fillQA(part); + if ((confV0Type1 == 0 && pdgCode == kLambda0) || (confV0Type1 == 1 && pdgCode == kLambda0Bar)) { + trackHistoV0Type1.fillQABase(part, HIST("V0Type1")); + posChildV0Type1.fillQABase(posChild, HIST("posChildV0Type1")); + negChildV0Type1.fillQABase(negChild, HIST("negChildV0Type1")); + qaRegistry.fill(HIST("V0Type1/hInvMassLambdaVsCent"), multCol, part.mLambda()); + qaRegistry.fill(HIST("V0Type1/hInvMassAntiLambdaVsCent"), multCol, part.mAntiLambda()); + effCorrection.fillTruthHist(part); + } + if ((confV0Type2 == 0 && pdgCode == kLambda0) || (confV0Type2 == 1 && pdgCode == kLambda0Bar)) { + trackHistoV0Type2.fillQABase(part, HIST("V0Type2")); + posChildV0Type2.fillQABase(posChild, HIST("posChildV0Type2")); + negChildV0Type2.fillQABase(negChild, HIST("negChildV0Type2")); + qaRegistry.fill(HIST("V0Type2/hInvMassLambdaVsCent"), multCol, part.mLambda()); + qaRegistry.fill(HIST("V0Type2/hInvMassAntiLambdaVsCent"), multCol, part.mAntiLambda()); + effCorrection.fillTruthHist(part); + } } auto pairProcessFunc = [&](auto& p1, auto& p2) -> void { int pdgCode1 = static_cast(p1.pidCut()); - if ((confV0Type1 == 0 && pdgCode1 != 3122) || (confV0Type1 == 1 && pdgCode1 != -3122)) + if ((confV0Type1 == 0 && pdgCode1 != kLambda0) || (confV0Type1 == 1 && pdgCode1 != kLambda0Bar)) return; int pdgCode2 = static_cast(p2.pidCut()); - if ((confV0Type2 == 0 && pdgCode2 != 3122) || (confV0Type2 == 1 && pdgCode2 != -3122)) + if ((confV0Type2 == 0 && pdgCode2 != kLambda0) || (confV0Type2 == 1 && pdgCode2 != kLambda0Bar)) return; sameEventCont.setPair(p1, p2, multCol, confUse3D); }; @@ -616,30 +672,19 @@ struct FemtoUniversePairTaskTrackV0Extended { if (confUseCent) { for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, confNEventsMix, -1, cols, cols)) { mixedCollProcessFunc(collision1, collision2); - mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); } } else { for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, confNEventsMix, -1, cols, cols)) { mixedCollProcessFunc(collision1, collision2); - mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); } } } - void processMixedEvent(FilteredFDCollisions const& cols, FemtoFullParticles const& parts) - { - doMixedEvent(cols, parts, partsOne, partsTwo); - } - PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processMixedEvent, "Enable processing mixed event for track - V0", false); - - void processMixedEventMCReco(FilteredFDCollisions const& cols, FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts) - { - doMixedEvent(cols, parts, partsOneMCReco, partsTwoMCReco, mcparts); - } - PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processMixedEventMCReco, "Enable processing mixed event for track - V0 for MC Reco", false); - /// This function processes the mixed event for V0 - V0 - void processMixedEventV0(FilteredFDCollisions const& cols, FemtoFullParticles const& parts) + template + void doMixedEventV0(FilteredFDCollisions const& cols, PartType const& parts, PartitionType& partitionTwo, [[maybe_unused]] MCParticles mcParts = nullptr) { ColumnBinningPolicy colBinningMult{{confVtxBins, confMultBins}, true}; ColumnBinningPolicy colBinningCent{{confVtxBins, confMultBins}, true}; @@ -647,8 +692,8 @@ struct FemtoUniversePairTaskTrackV0Extended { auto mixedCollProcessFunc = [&](auto& collision1, auto& collision2) -> void { const int multCol = confUseCent ? collision1.multV0M() : collision1.multNtr(); - auto groupPartsOne = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); - auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + auto groupPartsOne = partitionTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partitionTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); const auto& magFieldTesla1 = collision1.magField(); const auto& magFieldTesla2 = collision2.magField(); @@ -688,24 +733,51 @@ struct FemtoUniversePairTaskTrackV0Extended { continue; } } - mixedEventCont.setPair(p1, p2, multCol, confUse3D); + + if constexpr (std::is_same::value) + mixedEventCont.setPair(p1, p2, multCol, confUse3D); + else + mixedEventCont.setPair(p1, p2, multCol, confUse3D); } }; if (confUseCent) { for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, confNEventsMix, -1, cols, cols)) { mixedCollProcessFunc(collision1, collision2); - mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); } } else { for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, confNEventsMix, -1, cols, cols)) { mixedCollProcessFunc(collision1, collision2); - mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); } } } + + void processMixedEvent(FilteredFDCollisions const& cols, FemtoFullParticles const& parts) + { + doMixedEvent(cols, parts, partsOne, partsTwo); + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processMixedEvent, "Enable processing mixed event for track - V0", false); + + void processMixedEventMCReco(FilteredFDCollisions const& cols, FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts) + { + doMixedEvent(cols, parts, partsOneMCReco, partsTwoMCReco, mcparts); + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processMixedEventMCReco, "Enable processing mixed event for track - V0 for MC Reco", false); + + void processMixedEventV0(FilteredFDCollisions const& cols, FemtoFullParticles const& parts) + { + doMixedEventV0(cols, parts, partsTwo); + } PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processMixedEventV0, "Enable processing mixed events for V0 - V0", false); + void processMixedEventV0MCReco(FilteredFDCollisions const& cols, FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts) + { + doMixedEventV0(cols, parts, partsTwoMCReco, mcparts); + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processMixedEventV0MCReco, "Enable processing mixed event for V0 - V0 for MC Reco", false); + /// This function processes MC mixed events for Track - V0 void processMCMixedEvent(FilteredFDCollisions const& cols, FemtoFullParticles const& parts) { @@ -728,7 +800,7 @@ struct FemtoUniversePairTaskTrackV0Extended { if (static_cast(p1.pidCut()) != confTrkPDGCodePartOne) continue; int pdgCode2 = static_cast(p2.pidCut()); - if ((confV0Type1 == 0 && pdgCode2 != 3122) || (confV0Type1 == 1 && pdgCode2 != -3122)) + if ((confV0Type1 == 0 && pdgCode2 != kLambda0) || (confV0Type1 == 1 && pdgCode2 != kLambda0Bar)) continue; if (confIsCPR.value) { if (pairCloseRejection.isClosePair(p1, p2, parts, magFieldTesla1, femto_universe_container::EventType::mixed)) { @@ -742,12 +814,12 @@ struct FemtoUniversePairTaskTrackV0Extended { if (confUseCent) { for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, confNEventsMix, -1, cols, cols)) { mixedCollProcessFunc(collision1, collision2); - mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); } } else { for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, confNEventsMix, -1, cols, cols)) { mixedCollProcessFunc(collision1, collision2); - mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); } } } @@ -768,10 +840,10 @@ struct FemtoUniversePairTaskTrackV0Extended { for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { int pdgCode1 = static_cast(p1.pidCut()); - if ((confV0Type1 == 0 && pdgCode1 != 3122) || (confV0Type1 == 1 && pdgCode1 != -3122)) + if ((confV0Type1 == 0 && pdgCode1 != kLambda0) || (confV0Type1 == 1 && pdgCode1 != kLambda0Bar)) continue; int pdgCode2 = static_cast(p2.pidCut()); - if ((confV0Type2 == 0 && pdgCode2 != 3122) || (confV0Type2 == 1 && pdgCode2 != -3122)) + if ((confV0Type2 == 0 && pdgCode2 != kLambda0) || (confV0Type2 == 1 && pdgCode2 != kLambda0Bar)) continue; mixedEventCont.setPair(p1, p2, multCol, confUse3D); } @@ -780,17 +852,18 @@ struct FemtoUniversePairTaskTrackV0Extended { if (confUseCent) { for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, confNEventsMix, -1, cols, cols)) { mixedCollProcessFunc(collision1, collision2); - mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); } } else { for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, confNEventsMix, -1, cols, cols)) { mixedCollProcessFunc(collision1, collision2); - mixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); + qaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); } } } PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processMCMixedEventV0, "Enable processing mixed events for MC truth V0 - V0", false); + ///--------------------------------------------MC-------------------------------------------------/// /// This function fills MC truth particles from derived MC table @@ -806,10 +879,10 @@ struct FemtoUniversePairTaskTrackV0Extended { continue; } - if (pdgCode == 3122) { + if (pdgCode == kLambda0) { registryMCtruth.fill(HIST("plus/MCtruthLambda"), part.pt(), part.eta()); continue; - } else if (pdgCode == -3122) { + } else if (pdgCode == kLambda0Bar) { registryMCtruth.fill(HIST("minus/MCtruthLambda"), part.pt(), part.eta()); continue; } @@ -817,11 +890,11 @@ struct FemtoUniversePairTaskTrackV0Extended { if (pdgParticle->Charge() > 0.0) { registryMCtruth.fill(HIST("plus/MCtruthAllPt"), part.pt()); } - if (pdgCode == 211) { + if (pdgCode == kPiPlus) { registryMCtruth.fill(HIST("plus/MCtruthPi"), part.pt(), part.eta()); registryMCtruth.fill(HIST("plus/MCtruthPiPt"), part.pt()); } - if (pdgCode == 2212) { + if (pdgCode == kProton) { registryMCtruth.fill(HIST("plus/MCtruthPr"), part.pt(), part.eta()); registryMCtruth.fill(HIST("plus/MCtruthPrPt"), part.pt()); } @@ -829,11 +902,11 @@ struct FemtoUniversePairTaskTrackV0Extended { if (pdgParticle->Charge() < 0.0) { registryMCtruth.fill(HIST("minus/MCtruthAllPt"), part.pt()); } - if (pdgCode == -211) { + if (pdgCode == kPiMinus) { registryMCtruth.fill(HIST("minus/MCtruthPi"), part.pt(), part.eta()); registryMCtruth.fill(HIST("minus/MCtruthPiPt"), part.pt()); } - if (pdgCode == -2212) { + if (pdgCode == kProtonBar) { registryMCtruth.fill(HIST("minus/MCtruthPr"), part.pt(), part.eta()); registryMCtruth.fill(HIST("minus/MCtruthPrPt"), part.pt()); } @@ -842,6 +915,154 @@ struct FemtoUniversePairTaskTrackV0Extended { PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processMCTruth, "Process MC truth data", false); + void processPairFractions(FilteredFDCollisions const& cols, FemtoRecoParticles const& parts) + { + + ColumnBinningPolicy colBinningMult{{confVtxBins, confMultBins}, true}; + ColumnBinningPolicy colBinningCent{{confVtxBins, confMultBins}, true}; + + auto mixedCollProcessFunc = [&](auto& collision1, auto& collision2) -> void { + auto groupPartsOne = partsOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + return; + } + + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + // Lambda invariant mass cut + if (!invMLambda(p2.mLambda(), p2.mAntiLambda())) + continue; + /// PID using stored binned nsigma + if (!isParticleCombined(p1, confTrackChoicePartOne)) + continue; + + const auto& posChild = parts.iteratorAt(p2.globalIndex() - 2); + const auto& negChild = parts.iteratorAt(p2.globalIndex() - 1); + /// Daughters that do not pass this condition are not selected + if (!isParticleTPC(posChild, V0ChildTable[confV0Type1][0]) || !isParticleTPC(negChild, V0ChildTable[confV0Type1][1])) + continue; + + // track cleaning + if (!pairCleaner.isCleanPair(p1, p2, parts)) { + continue; + } + if (confIsCPR.value) { + if (pairCloseRejection.isClosePair(p1, p2, parts, magFieldTesla1, femto_universe_container::EventType::mixed)) { + continue; + } + } + registryMCreco.fill(HIST("motherParticle"), p1.motherPDG(), p2.motherPDG()); + } + }; + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, confNEventsMix, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processPairFractions, "Process MC data to obtain pair fractions", false); + + void processPairFractionsV0(FilteredFDCollisions const& cols, FemtoRecoParticles const& parts) + { + + ColumnBinningPolicy colBinningMult{{confVtxBins, confMultBins}, true}; + ColumnBinningPolicy colBinningCent{{confVtxBins, confMultBins}, true}; + + auto mixedCollProcessFunc = [&](auto& collision1, auto& collision2) -> void { + auto groupPartsOne = partsTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + return; + } + + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + // Lambda invariant mass cut for p1 + if (!invMLambda(p1.mLambda(), p1.mAntiLambda())) { + continue; + } + // Lambda invariant mass cut for p2 + if (!invMLambda(p2.mLambda(), p2.mAntiLambda())) { + continue; + } + + const auto& posChild1 = parts.iteratorAt(p1.globalIndex() - 2); + const auto& negChild1 = parts.iteratorAt(p1.globalIndex() - 1); + /// Daughters that do not pass this condition are not selected + if (!isParticleTPC(posChild1, V0ChildTable[confV0Type1][0]) || !isParticleTPC(negChild1, V0ChildTable[confV0Type1][1])) + continue; + + const auto& posChild2 = parts.iteratorAt(p2.globalIndex() - 2); + const auto& negChild2 = parts.iteratorAt(p2.globalIndex() - 1); + /// Daughters that do not pass this condition are not selected + if (!isParticleTPC(posChild2, V0ChildTable[confV0Type2][0]) || !isParticleTPC(negChild2, V0ChildTable[confV0Type2][1])) + continue; + + // track cleaning + if (!pairCleanerV0.isCleanPair(p1, p2, parts)) { + continue; + } + if (confIsCPR.value) { + if (pairCloseRejectionV0.isClosePair(p1, p2, parts, magFieldTesla1, femto_universe_container::EventType::mixed)) { + continue; + } + } + + registryMCreco.fill(HIST("motherParticle"), p1.motherPDG(), p2.motherPDG()); + } + }; + + if (confUseCent) { + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, confNEventsMix, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + } + } else { + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, confNEventsMix, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + } + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processPairFractionsV0, "Process MC data to obtain pair fractions for V0V0 pairs", false); + + void processPairFractionsMCTruthV0(FilteredFDCollisions const& cols, FemtoFullParticles const& /*parts*/) + { + ColumnBinningPolicy colBinningMult{{confVtxBins, confMultBins}, true}; + ColumnBinningPolicy colBinningCent{{confVtxBins, confMultBins}, true}; + + auto mixedCollProcessFunc = [&](auto& collision1, auto& collision2) -> void { + auto groupPartsOne = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + int pdgCode1 = static_cast(p1.pidCut()); + if ((confV0Type1 == 0 && pdgCode1 != kLambda0) || (confV0Type1 == 1 && pdgCode1 != kLambda0Bar)) + continue; + int pdgCode2 = static_cast(p2.pidCut()); + if ((confV0Type2 == 0 && pdgCode2 != kLambda0) || (confV0Type2 == 1 && pdgCode2 != kLambda0Bar)) + continue; + + registryMCtruth.fill(HIST("motherParticle"), p1.tempFitVar(), p2.tempFitVar()); + } + }; + + if (confUseCent) { + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, confNEventsMix, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + } + } else { + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, confNEventsMix, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + } + } + } + PROCESS_SWITCH(FemtoUniversePairTaskTrackV0Extended, processPairFractionsMCTruthV0, "Process MC data to obtain pair fractions for V0V0 MC truth pairs", false); + void processMCReco(FemtoRecoParticles const& parts, aod::FdMCParticles const& mcparts) { for (const auto& part : parts) { @@ -851,7 +1072,7 @@ struct FemtoUniversePairTaskTrackV0Extended { const auto& mcpart = mcparts.iteratorAt(mcPartId); // if (part.partType() == aod::femtouniverseparticle::ParticleType::kV0) { - if (mcpart.pdgMCTruth() == 3122) { + if (mcpart.pdgMCTruth() == kLambda0) { const auto& posChild = parts.iteratorAt(part.globalIndex() - 2); const auto& negChild = parts.iteratorAt(part.globalIndex() - 1); /// Daughters that do not pass this condition are not selected @@ -866,7 +1087,7 @@ struct FemtoUniversePairTaskTrackV0Extended { registryMCreco.fill(HIST("plus/MCrecoLambdaChildPi"), mcpartChild.pt(), mcpartChild.eta()); // lambda pion child } } - } else if (mcpart.pdgMCTruth() == -3122) { + } else if (mcpart.pdgMCTruth() == kLambda0Bar) { const auto& posChild = parts.iteratorAt(part.globalIndex() - 2); const auto& negChild = parts.iteratorAt(part.globalIndex() - 1); /// Daughters that do not pass this condition are not selected @@ -885,10 +1106,10 @@ struct FemtoUniversePairTaskTrackV0Extended { } else if (part.partType() == aod::femtouniverseparticle::ParticleType::kTrack) { if (part.sign() > 0) { registryMCreco.fill(HIST("plus/MCrecoAllPt"), mcpart.pt()); - if (mcpart.pdgMCTruth() == 211 && isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePi()), unPackInTable(part.tofNSigmaStorePi()))) { + if (mcpart.pdgMCTruth() == kPiPlus && isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePi()), unPackInTable(part.tofNSigmaStorePi()))) { registryMCreco.fill(HIST("plus/MCrecoPi"), mcpart.pt(), mcpart.eta()); registryMCreco.fill(HIST("plus/MCrecoPiPt"), mcpart.pt()); - } else if (mcpart.pdgMCTruth() == 2212 && isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePr()))) { + } else if (mcpart.pdgMCTruth() == kProton && isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePr()))) { registryMCreco.fill(HIST("plus/MCrecoPr"), mcpart.pt(), mcpart.eta()); registryMCreco.fill(HIST("plus/MCrecoPrPt"), mcpart.pt()); } @@ -896,10 +1117,10 @@ struct FemtoUniversePairTaskTrackV0Extended { if (part.sign() < 0) { registryMCreco.fill(HIST("minus/MCrecoAllPt"), mcpart.pt()); - if (mcpart.pdgMCTruth() == -211 && isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePi()), unPackInTable(part.tofNSigmaStorePi()))) { + if (mcpart.pdgMCTruth() == kPiMinus && isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePi()), unPackInTable(part.tofNSigmaStorePi()))) { registryMCreco.fill(HIST("minus/MCrecoPi"), mcpart.pt(), mcpart.eta()); registryMCreco.fill(HIST("minus/MCrecoPiPt"), mcpart.pt()); - } else if (mcpart.pdgMCTruth() == -2212 && isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePr()))) { + } else if (mcpart.pdgMCTruth() == kProtonBar && isNSigmaCombined(part.p(), unPackInTable(part.tpcNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePr()))) { registryMCreco.fill(HIST("minus/MCrecoPr"), mcpart.pt(), mcpart.eta()); registryMCreco.fill(HIST("minus/MCrecoPrPt"), mcpart.pt()); } diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskV0CascadeExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskV0CascadeExtended.cxx new file mode 100644 index 00000000000..a9212ab208a --- /dev/null +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskV0CascadeExtended.cxx @@ -0,0 +1,329 @@ +// Copyright 2019-2025 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. + +/// \file femtoUniversePairTaskV0CascadeExtended.cxx +/// \brief Task for v0-cascade correlations and QA +/// \author Shirajum Monira, WUT Warsaw, shirajum.monira@cern.ch + +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" +#include "PWGCF/FemtoUniverse/Core/femtoUtils.h" +#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" + +#include +#include + +using namespace o2; +using namespace o2::soa; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::analysis::femto_universe; +using namespace o2::aod::pidutils; + +struct FemtoUniversePairTaskV0CascadeExtended { + + SliceCache cache; + using FemtoParticles = soa::Join; + Preslice perCol = aod::femtouniverseparticle::fdCollisionId; + + /// applying narrow cut + Configurable confZVertexCut{"confZVertexCut", 10.f, "Event sel: Maximum z-Vertex (cm)"}; + + Filter collisionFilter = (nabs(aod::collision::posZ) < confZVertexCut); + using FilteredFDCollisions = soa::Filtered; + using FilteredFDCollision = FilteredFDCollisions::iterator; + + /// particle 1 (v0) + Configurable confHPtPart1{"confHPtPart1", 4.0f, "higher limit for pt of particle 1"}; + Configurable confLPtPart1{"confLPtPart1", 0.5f, "lower limit for pt of particle 1"}; + Configurable confV0Type{"confV0Type", 0, "select one of the V0s (lambda = 0, anti-lambda = 1, k0 = 2)"}; + Configurable confV0InvMassLowLimit{"confV0InvMassLowLimit", 1.10, "Lower limit of the V0 invariant mass"}; + Configurable confV0InvMassUpLimit{"confV0InvMassUpLimit", 1.13, "Upper limit of the V0 invariant mass"}; + Configurable confV0PDGCode{"confV0PDGCode", 3122, "Particle 1 (V0) - PDG code"}; + + /// particle 2 (cascade) + Configurable confHPtPart2{"confHPtPart2", 4.0f, "higher limit for pt of particle 2"}; + Configurable confLPtPart2{"confLPtPart2", 0.3f, "lower limit for pt of particle 2"}; + Configurable confCascType{"confCascType", 0, "select one of the cascades (Omega = 0, Xi = 1, anti-Omega = 2, anti-Xi = 3)"}; + Configurable confCascInvMassLowLimit{"confCascInvMassLowLimit", 1.315, "Lower limit of the cascade invariant mass"}; + Configurable confCascInvMassUpLimit{"confCascInvMassUpLimit", 1.325, "Upper limit of the cascade invariant mass"}; + + /// nSigma cuts + Configurable confmom{"confmom", 0.75, "momentum threshold for particle identification using TOF"}; + Configurable confNsigmaTPCParticleChild{"confNsigmaTPCParticleChild", 3.0, "TPC Sigma for cascade (daugh & bach) momentum < Confmom"}; + Configurable confNsigmaTOFParticleChild{"confNsigmaTOFParticleChild", 3.0, "TOF Sigma for cascade (daugh & bach) momentum > Confmom"}; + + /// for correlation part + Configurable confIsMC{"confIsMC", false, "Enable additional Histograms in the case of a MonteCarlo Run"}; + ConfigurableAxis confkstarBins{"confkstarBins", {1500, 0., 6.}, "binning kstar"}; + ConfigurableAxis confMultBins{"confMultBins", {VARIABLE_WIDTH, 0.0f, 20.0f, 40.0f, 60.0f, 80.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - multiplicity"}; + ConfigurableAxis confkTBins{"confkTBins", {150, 0., 9.}, "binning kT"}; + ConfigurableAxis confmTBins{"confmTBins", {225, 0., 7.5}, "binning mT"}; + ConfigurableAxis confMultBins3D{"confMultBins3D", {VARIABLE_WIDTH, 0.0f, 20.0f, 30.0f, 40.0f, 99999.0f}, "multiplicity Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; + ConfigurableAxis confmTBins3D{"confmTBins3D", {VARIABLE_WIDTH, 1.02f, 1.14f, 1.20f, 1.26f, 1.38f, 1.56f, 1.86f, 4.50f}, "mT Binning for the 3Dimensional plot: k* vs multiplicity vs mT (set <> to true in order to use)"}; + Configurable confEtaBins{"confEtaBins", 29, "Number of eta bins in deta dphi"}; + Configurable confPhiBins{"confPhiBins", 29, "Number of phi bins in deta dphi"}; + Configurable confUse3D{"confUse3D", false, "Enable three dimensional histogramms (to be used only for analysis with high statistics): k* vs mT vs multiplicity"}; + ConfigurableAxis confVtxBins{"confVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis confTrkTempFitVarpTBins{"confTrkTempFitVarpTBins", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis confTrkTempFitVarBins{"confTrkTempFitVarBins", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; + ConfigurableAxis confChildTempFitVarBins{"confChildTempFitVarBins", {300, -0.15, 0.15}, "V0 child: binning of the TempFitVar in the pT vs. TempFitVar plot"}; + ConfigurableAxis confChildTempFitVarpTBins{"confChildTempFitVarpTBins", {20, 0.5, 4.05}, "V0 child: pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis confV0TempFitVarpTBins{"confV0TempFitVarpTBins", {20, 0.5, 4.05}, "V0: pT binning of the pT vs. TempFitVar plot"}; + ConfigurableAxis confV0TempFitVarBins{"confV0TempFitVarBins", {300, 0.95, 1.}, "V0: binning of the TempFitVar in the pT vs. TempFitVar plot"}; + + /// Partition for particle 1 + Partition partsOne = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kV0)) && (aod::femtouniverseparticle::pt < confHPtPart1) && (aod::femtouniverseparticle::pt > confLPtPart1); + + /// Partition for particle 2 + Partition partsTwo = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kCascade)) && (aod::femtouniverseparticle::pt < confHPtPart2) && (aod::femtouniverseparticle::pt > confLPtPart2); + + /// Histogramming for v0 + FemtoUniverseParticleHisto trackHistoV0; + FemtoUniverseParticleHisto posChildV0; + FemtoUniverseParticleHisto negChildV0; + + /// Histogramming for cascade + FemtoUniverseParticleHisto posChildHistosCasc; + FemtoUniverseParticleHisto negChildHistosCasc; + FemtoUniverseParticleHisto bachHistosCasc; + FemtoUniverseParticleHisto cascQAHistos; + + /// Histogramming for Event + FemtoUniverseEventHisto eventHisto; + + FemtoUniverseContainer sameEventCont; + FemtoUniverseContainer mixedEventCont; + FemtoUniversePairCleaner pairCleaner; + + HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Table to select v0 daughters + static constexpr unsigned int V0ChildTable[][2] = {{0, 1}, {1, 0}, {1, 1}}; + + bool invMLambda(float invMassLambda, float invMassAntiLambda) + { + if ((invMassLambda < confV0InvMassLowLimit || invMassLambda > confV0InvMassUpLimit) && (invMassAntiLambda < confV0InvMassLowLimit || invMassAntiLambda > confV0InvMassUpLimit)) { + return false; + } + return true; + } + + // Table to select cascade daughters + // Charges: = +--, +--, +-+, +-+ + static constexpr unsigned int CascChildTable[][3] = {{0, 1, 2}, {0, 1, 1}, {1, 0, 2}, {1, 0, 1}}; + + bool invMCascade(float invMassXi, float invMassOmega, int cascType) + { + return (((cascType == 1 || cascType == 3) && (invMassXi > confCascInvMassLowLimit && invMassXi < confCascInvMassUpLimit)) || ((cascType == 0 || cascType == 2) && (invMassOmega > confCascInvMassLowLimit && invMassOmega < confCascInvMassUpLimit))); + } + + bool isNSigmaTPC(float nsigmaTPCParticle) + { + if (std::abs(nsigmaTPCParticle) < confNsigmaTPCParticleChild) { + return true; + } else { + return false; + } + } + + bool isNSigmaTOF(float mom, float nsigmaTOFParticle, float hasTOF) + { + // Cut only on daughter and bachelor tracks, that have TOF signal + if (mom > confmom && hasTOF == 1) { + if (std::abs(nsigmaTOFParticle) < confNsigmaTOFParticleChild) { + return true; + } else { + return false; + } + } else { + return true; + } + } + + template + bool isParticleTPC(const T& part, int id) + { + const float tpcNSigmas[3] = {unPackInTable(part.tpcNSigmaStorePr()), unPackInTable(part.tpcNSigmaStorePi()), unPackInTable(part.tpcNSigmaStoreKa())}; + + return isNSigmaTPC(tpcNSigmas[id]); + } + + template + bool isParticleTOF(const T& part, int id) + { + const float tofNSigmas[3] = {unPackInTable(part.tofNSigmaStorePr()), unPackInTable(part.tofNSigmaStorePi()), unPackInTable(part.tofNSigmaStoreKa())}; + + return isNSigmaTOF(part.p(), tofNSigmas[id], part.tempFitVar()); + } + + void init(InitContext const&) + { + trackHistoV0.init(&qaRegistry, confV0TempFitVarpTBins, confV0TempFitVarBins, confIsMC, confV0PDGCode, true, "trackHistoV0"); + posChildV0.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "posChildV0"); + negChildV0.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "negChildV0"); + + posChildHistosCasc.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "posChildCasc"); + negChildHistosCasc.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "negChildCasc"); + bachHistosCasc.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true, "hBachelor"); + cascQAHistos.init(&qaRegistry, confChildTempFitVarpTBins, confChildTempFitVarBins, false, 0, true); + + sameEventCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confMultBins3D, confmTBins3D, confEtaBins, confPhiBins, confIsMC, confUse3D); + mixedEventCont.init(&resultRegistry, confkstarBins, confMultBins, confkTBins, confmTBins, confMultBins3D, confmTBins3D, confEtaBins, confPhiBins, confIsMC, confUse3D); + pairCleaner.init(&qaRegistry); + } + + /// v0-cascade correlations same event + void processSameEvent(const FilteredFDCollision& col, const FemtoParticles& parts) + { + auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + + eventHisto.fillQA(col); + + for (const auto& part : groupPartsTwo) { + /// inv Mass check for cascade + if (!invMCascade(part.mLambda(), part.mAntiLambda(), confCascType)) + continue; + + cascQAHistos.fillQA(part); + + const auto& posChild1 = parts.iteratorAt(part.index() - 3); + const auto& negChild1 = parts.iteratorAt(part.index() - 2); + const auto& bachelor1 = parts.iteratorAt(part.index() - 1); + /// Children of cascade must pass this condition to be selected + if (!isParticleTPC(posChild1, CascChildTable[confCascType][0]) || !isParticleTPC(negChild1, CascChildTable[confCascType][1]) || !isParticleTPC(bachelor1, CascChildTable[confCascType][2])) + continue; + + if (!isParticleTOF(posChild1, CascChildTable[confCascType][0]) || !isParticleTOF(negChild1, CascChildTable[confCascType][1]) || !isParticleTOF(bachelor1, CascChildTable[confCascType][2])) + continue; + + posChildHistosCasc.fillQABase(posChild1, HIST("posChildCasc")); + negChildHistosCasc.fillQABase(negChild1, HIST("negChildCasc")); + bachHistosCasc.fillQABase(bachelor1, HIST("hBachelor")); + } + for (const auto& part : groupPartsOne) { + /// inv Mass check for V0s + if (!invMLambda(part.mLambda(), part.mAntiLambda())) + continue; + const auto& posChild2 = parts.iteratorAt(part.index() - 2); + const auto& negChild2 = parts.iteratorAt(part.index() - 1); + /// Daughters of v0 must pass this condition to be selected + if (!isParticleTPC(posChild2, V0ChildTable[confV0Type][0]) || !isParticleTPC(negChild2, V0ChildTable[confV0Type][1])) + continue; + + trackHistoV0.fillQABase(part, HIST("trackHistoV0")); + posChildV0.fillQABase(posChild2, HIST("posChildV0")); + negChildV0.fillQABase(negChild2, HIST("negChildV0")); + } + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + if (!invMLambda(p1.mLambda(), p1.mAntiLambda())) + continue; + // Cascase inv Mass cut (mLambda stores Xi mass, mAntiLambda stored Omega mass) + if (!invMCascade(p2.mLambda(), p2.mAntiLambda(), confCascType)) + continue; + // track cleaning + if (!pairCleaner.isCleanPair(p1, p2, parts)) { + continue; + } + // V0 + const auto& posChild2 = parts.iteratorAt(p1.index() - 2); + const auto& negChild2 = parts.iteratorAt(p1.index() - 1); + /// Daughters of v0 must pass this condition to be selected + if (!isParticleTPC(posChild2, V0ChildTable[confV0Type][0]) || !isParticleTPC(negChild2, V0ChildTable[confV0Type][1])) + continue; + // cascade + const auto& posChild1 = parts.iteratorAt(p2.index() - 3); + const auto& negChild1 = parts.iteratorAt(p2.index() - 2); + const auto& bachelor1 = parts.iteratorAt(p2.index() - 1); + /// Daughters of cascade must pass this condition to be selected + if (!isParticleTPC(posChild1, CascChildTable[confCascType][0]) || !isParticleTPC(negChild1, CascChildTable[confCascType][1]) || !isParticleTPC(bachelor1, CascChildTable[confCascType][2])) + continue; + + if (!isParticleTOF(posChild1, CascChildTable[confCascType][0]) || !isParticleTOF(negChild1, CascChildTable[confCascType][1]) || !isParticleTOF(bachelor1, CascChildTable[confCascType][2])) + continue; + + sameEventCont.setPair(p1, p2, col.multNtr(), confUse3D, 1.0f); + } + } + PROCESS_SWITCH(FemtoUniversePairTaskV0CascadeExtended, processSameEvent, "Enable processing same event for v0 - cascade", false); + + /// v0-cascade correlations mixed event + void processMixedEvent(const FilteredFDCollisions& cols, const FemtoParticles& parts) + { + ColumnBinningPolicy colBinning{{confVtxBins, confMultBins}, true}; + + for (const auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + const int multCol = collision1.multNtr(); + + auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + continue; + } + for (const auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + if (!invMLambda(p1.mLambda(), p1.mAntiLambda())) + continue; + // Cascase inv Mass cut (mLambda stores Xi mass, mAntiLambda stored Omega mass) + if (!invMCascade(p2.mLambda(), p2.mAntiLambda(), confCascType)) + continue; + // V0 + const auto& posChild2 = parts.iteratorAt(p1.index() - 2); + const auto& negChild2 = parts.iteratorAt(p1.index() - 1); + /// Daughters of v0 must pass this condition to be selected + if (!isParticleTPC(posChild2, V0ChildTable[confV0Type][0]) || !isParticleTPC(negChild2, V0ChildTable[confV0Type][1])) + continue; + // cascade + const auto& posChild1 = parts.iteratorAt(p2.index() - 3); + const auto& negChild1 = parts.iteratorAt(p2.index() - 2); + const auto& bachelor1 = parts.iteratorAt(p2.index() - 1); + /// Daughters of cascade must pass this condition to be selected + if (!isParticleTPC(posChild1, CascChildTable[confCascType][0]) || !isParticleTPC(negChild1, CascChildTable[confCascType][1]) || !isParticleTPC(bachelor1, CascChildTable[confCascType][2])) + continue; + + if (!isParticleTOF(posChild1, CascChildTable[confCascType][0]) || !isParticleTOF(negChild1, CascChildTable[confCascType][1]) || !isParticleTOF(bachelor1, CascChildTable[confCascType][2])) + continue; + + // track cleaning + if (!pairCleaner.isCleanPair(p1, p2, parts)) { + continue; + } + + mixedEventCont.setPair(p1, p2, multCol, confUse3D, 1.0f); + } + } + } + PROCESS_SWITCH(FemtoUniversePairTaskV0CascadeExtended, processMixedEvent, "Enable processing mixed event for v0 - cascade", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{ + adaptAnalysisTask(cfgc), + }; + return workflow; +} diff --git a/PWGCF/Flow/TableProducer/zdcQVectors.cxx b/PWGCF/Flow/TableProducer/zdcQVectors.cxx index 43cdb24087b..c748b1f51ec 100644 --- a/PWGCF/Flow/TableProducer/zdcQVectors.cxx +++ b/PWGCF/Flow/TableProducer/zdcQVectors.cxx @@ -64,22 +64,10 @@ using namespace o2::framework::expressions; using namespace o2::aod::track; using namespace o2::aod::evsel; -// define my..... -using UsedCollisions = soa::Join; -using BCsRun3 = soa::Join; - namespace o2::analysis::qvectortask { - int counter = 0; -// step0 -> Energy calib -std::shared_ptr energyZN[10] = {{nullptr}}; -std::shared_ptr hQxvsQy[6] = {{nullptr}}; - -// and -std::shared_ptr hCOORDcorrelations[6][4] = {{nullptr}}; - // Define histogrm names here to use same names for creating and later uploading and retrieving data from ccdb // Energy calibration: std::vector namesEcal(10, ""); @@ -91,8 +79,9 @@ std::vector pxZDC = {-1.75, 1.75, -1.75, 1.75}; std::vector pyZDC = {-1.75, -1.75, 1.75, 1.75}; double alphaZDC = 0.395; -// step 0 tm 5 A&C -std::vector>> q(6, std::vector>(7, std::vector(4, 0.0))); // 5 iterations with 5 steps, each with 4 values +// q-vectors before (q) and after (qRec) recentering. +std::vector q(4); // start values of [QxA, QyA, QxC, QyC] +std::vector qNoEq(4); // start values of [QxA, QyA, QxC, QyC] // for energy calibration std::vector eZN(8); // uncalibrated energy for the 2x4 towers (a1, a2, a3, a4, c1, c2, c3, c4) @@ -102,6 +91,7 @@ std::vector e(8, 0.); // calibrated energies (a1, a2, a3, a4, c1, c2, // Define variables needed to do the recentring steps. double centrality = 0; int runnumber = 0; +int lastRunNumber = 0; std::vector v(3, 0); // vx, vy, vz bool isSelected = true; @@ -119,27 +109,60 @@ struct ZdcQVectors { ConfigurableAxis axisVxBig{"axisVxBig", {3, -0.01, 0.01}, "for Pos X of collision"}; ConfigurableAxis axisVyBig{"axisVyBig", {3, -0.01, 0.01}, "for Pos Y of collision"}; ConfigurableAxis axisVzBig{"axisVzBig", {3, -10, 10}, "for Pos Z of collision"}; - ConfigurableAxis axisVx{"axisVx", {10, -0.01, 0.01}, "for Pos X of collision"}; - ConfigurableAxis axisVy{"axisVy", {10, -0.01, 0.01}, "for Pos Y of collision"}; - ConfigurableAxis axisVz{"axisVz", {10, -10, 1}, "for vz of collision"}; - - O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") - O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal.q pT for poi tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 3.0f, "Maximal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") - O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") + ConfigurableAxis axisVx{"axisVx", {100, -0.01, 0.01}, "for Pos X of collision"}; + ConfigurableAxis axisVy{"axisVy", {100, -0.01, 0.01}, "for Pos Y of collision"}; + ConfigurableAxis axisVz{"axisVz", {100, -10, 10}, "for vz of collision"}; + + // Centrality Estimators -> standard is FT0C + O2_DEFINE_CONFIGURABLE(cfgFT0Cvariant1, bool, false, "Set centrality estimator to cfgFT0Cvariant1"); + O2_DEFINE_CONFIGURABLE(cfgFT0M, bool, false, "Set centrality estimator to cfgFT0M"); + O2_DEFINE_CONFIGURABLE(cfgFV0A, bool, false, "Set centrality estimator to cfgFV0A"); + O2_DEFINE_CONFIGURABLE(cfgNGlobal, bool, false, "Set centrality estimator to cfgNGlobal"); + + O2_DEFINE_CONFIGURABLE(cfgVtxZ, float, 10.0f, "Accepted z-vertex range") O2_DEFINE_CONFIGURABLE(cfgMagField, float, 99999, "Configurable magnetic field; default CCDB will be queried") O2_DEFINE_CONFIGURABLE(cfgEnergyCal, std::string, "Users/c/ckoster/ZDC/LHC23_zzh_pass4/Energy", "ccdb path for energy calibration histos") O2_DEFINE_CONFIGURABLE(cfgMeanv, std::string, "Users/c/ckoster/ZDC/LHC23_zzh_pass4/vmean", "ccdb path for mean v histos") O2_DEFINE_CONFIGURABLE(cfgMinEntriesSparseBin, int, 100, "Minimal number of entries allowed in 4D recentering histogram to use for recentering.") - - Configurable> cfgRec1{"cfgRec1", {"Users/c/ckoster/ZDC/LHC23_zzh_pass4/it1_step1", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it1_step2", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it1_step3", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it1_step4", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it1_step5"}, "ccdb paths for recentering calibration histos iteration 1"}; - Configurable> cfgRec2{"cfgRec2", {"Users/c/ckoster/ZDC/LHC23_zzh_pass4/it2_step1", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it2_step2", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it2_step3", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it2_step4", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it2_step5"}, "ccdb paths for recentering calibration histos iteration 2"}; - Configurable> cfgRec3{"cfgRec3", {"Users/c/ckoster/ZDC/LHC23_zzh_pass4/it3_step1", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it3_step2", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it3_step3", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it3_step4", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it3_step5"}, "ccdb paths for recentering calibration histos iteration 3"}; - Configurable> cfgRec4{"cfgRec4", {"Users/c/ckoster/ZDC/LHC23_zzh_pass4/it4_step1", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it4_step2", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it4_step3", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it4_step4", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it4_step5"}, "ccdb paths for recentering calibration histos iteration 4"}; - Configurable> cfgRec5{"cfgRec5", {"Users/c/ckoster/ZDC/LHC23_zzh_pass4/it5_step1", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it5_step2", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it5_step3", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it5_step4", "Users/c/ckoster/ZDC/LHC23_zzh_pass4/it5_step5"}, "ccdb paths for recentering calibration histos iteration 5"}; + O2_DEFINE_CONFIGURABLE(cfgRec, std::string, "Users/c/ckoster/ZDC/LHC23_PbPb_pass4", "ccdb path for recentering histos"); + O2_DEFINE_CONFIGURABLE(cfgFillCommonRegistry, bool, true, "Fill common registry with histograms"); + + // Additional event selections + O2_DEFINE_CONFIGURABLE(cfgEvSelsMaxOccupancy, int, 10000, "Maximum occupancy of selected events"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsNoSameBunchPileupCut, bool, true, "kNoSameBunchPileupCut"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsIsGoodZvtxFT0vsPV, bool, true, "kIsGoodZvtxFT0vsPV"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsNoCollInTimeRangeStandard, bool, true, "kNoCollInTimeRangeStandard"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsDoOccupancySel, bool, true, "Bool for event selection on detector occupancy"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsIsVertexITSTPC, bool, true, "Selects collisions with at least one ITS-TPC track"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsIsGoodITSLayersAll, bool, true, "Cut time intervals with dead ITS staves"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsCentMin, float, 0, "Minimum cenrality for selected events"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsCentMax, float, 90, "Maximum cenrality for selected events"); + + // define my..... + // Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZ; + using UsedCollisions = soa::Join; + using BCsRun3 = soa::Join; + + enum SelectionCriteria { + evSel_FilteredEvent, + evSel_Zvtx, + evSel_sel8, + evSel_occupancy, + evSel_kNoSameBunchPileup, + evSel_kIsGoodZvtxFT0vsPV, + evSel_kNoCollInTimeRangeStandard, + evSel_kIsVertexITSTPC, + evSel_CentCuts, + evSel_kIsGoodITSLayersAll, + evSel_isSelectedZDC, + nEventSelections + }; + + enum CalibModes { + kEnergyCal, + kMeanv, + kRec + }; // Define output HistogramRegistry registry{"Registry"}; @@ -148,12 +171,17 @@ struct ZdcQVectors { // keep track of calibration histos for each given step and iteration struct Calib { - std::vector> calibList = std::vector>(7, std::vector(8, nullptr)); - std::vector> calibfilesLoaded = std::vector>(7, std::vector(8, false)); + std::vector calibList = std::vector(3, nullptr); // [0] Enerfy cal, [1] vmean, [2] recentering + std::vector calibfilesLoaded = std::vector(3, false); int atStep = 0; int atIteration = 0; } cal; + enum FillType { + kBefore, + kAfter + }; + void init(InitContext const&) { ccdb->setURL("http://alice-ccdb.cern.ch"); @@ -166,26 +194,21 @@ struct ZdcQVectors { std::vector sides = {"A", "C"}; std::vector capCOORDS = {"X", "Y"}; - // Tower mean energies vs. centrality used for tower gain equalisation - for (int tower = 0; tower < 10; tower++) { - namesEcal[tower] = TString::Format("hZN%s_mean_t%i_cent", sides[(tower < 5) ? 0 : 1], tower % 5); - energyZN[tower] = registry.add(Form("Energy/%s", namesEcal[tower].Data()), Form("%s", namesEcal[tower].Data()), kTProfile2D, {{1, 0, 1}, axisCent}); - } - - // Qx_vs_Qy for each step for ZNA and ZNC - for (int step = 0; step < 6; step++) { - registry.add(Form("step%i/QA/hSPplaneA", step), "hSPplaneA", kTH2D, {{100, -4, 4}, axisCent10}); - registry.add(Form("step%i/QA/hSPplaneC", step), "hSPplaneC", kTH2D, {{100, -4, 4}, axisCent10}); - registry.add(Form("step%i/QA/hSPplaneFull", step), "hSPplaneFull", kTH2D, {{100, -4, 4}, axisCent10}); + if (cfgFillCommonRegistry) { + registry.add(Form("QA/before/hSPplaneA"), "hSPplaneA", kTH2D, {{100, -4, 4}, axisCent10}); + registry.add(Form("QA/before/hSPplaneC"), "hSPplaneC", kTH2D, {{100, -4, 4}, axisCent10}); + registry.add(Form("QA/before/hSPplaneFull"), "hSPplaneFull", kTH2D, {{100, -4, 4}, axisCent10}); for (const auto& side : sides) { - hQxvsQy[step] = registry.add(Form("step%i/hZN%s_Qx_vs_Qy", step, side), Form("hZN%s_Qx_vs_Qy", side), kTH2F, {axisQ, axisQ}); + registry.add(Form("QA/before/hZN%s_Qx_vs_Qy", side), Form("hZN%s_Qx_vs_Qy", side), kTH2F, {axisQ, axisQ}); } - int i = 0; + for (const auto& COORD1 : capCOORDS) { for (const auto& COORD2 : capCOORDS) { // Now we get: & vs. Centrality - hCOORDcorrelations[step][i] = registry.add(Form("step%i/QA/hQ%sA_Q%sC_vs_cent", step, COORD1, COORD2), Form("hQ%sA_Q%sC_vs_cent", COORD1, COORD2), kTProfile, {axisCent10}); - i++; + registry.add(Form("QA/before/hQ%sA_Q%sC_vs_cent", COORD1, COORD2), Form("hQ%sA_Q%sC_vs_cent", COORD1, COORD2), kTProfile, {axisCent}); + registry.add(Form("QA/before/hQ%sA_Q%sC_vs_vx", COORD1, COORD2), Form("hQ%sA_Q%sC_vs_vx", COORD1, COORD2), kTProfile, {axisVx}); + registry.add(Form("QA/before/hQ%sA_Q%sC_vs_vy", COORD1, COORD2), Form("hQ%sA_Q%sC_vs_vy", COORD1, COORD2), kTProfile, {axisVy}); + registry.add(Form("QA/before/hQ%sA_Q%sC_vs_vz", COORD1, COORD2), Form("hQ%sA_Q%sC_vs_vz", COORD1, COORD2), kTProfile, {axisVz}); } } @@ -193,265 +216,273 @@ struct ZdcQVectors { // Sides is {A,C} and capcoords is {X,Y} for (const auto& side : sides) { for (const auto& coord : capCOORDS) { - registry.add(Form("step%i/QA/hQ%s%s_vs_cent", step, coord, side), Form("hQ%s%s_vs_cent", coord, side), {HistType::kTProfile, {axisCent10}}); - registry.add(Form("step%i/QA/hQ%s%s_vs_vx", step, coord, side), Form("hQ%s%s_vs_vx", coord, side), {HistType::kTProfile, {axisVx}}); - registry.add(Form("step%i/QA/hQ%s%s_vs_vy", step, coord, side), Form("hQ%s%s_vs_vy", coord, side), {HistType::kTProfile, {axisVy}}); - registry.add(Form("step%i/QA/hQ%s%s_vs_vz", step, coord, side), Form("hQ%s%s_vs_vz", coord, side), {HistType::kTProfile, {axisVz}}); - - if (step == 1 || step == 5) { - TString name = TString::Format("hQ%s%s_mean_Cent_V_run", coord, side); - registry.add(Form("step%i/%s", step, name.Data()), Form("hQ%s%s_mean_Cent_V_run", coord, side), {HistType::kTHnSparseD, {axisCent10, axisVxBig, axisVyBig, axisVzBig, axisQ}}); - if (step == 1) - names[step - 1].push_back(name); - } - if (step == 2) { - TString name = TString::Format("hQ%s%s_mean_cent_run", coord, side); - registry.add(Form("step%i/%s", step, name.Data()), Form("hQ%s%s_mean_cent_run", coord, side), kTProfile, {axisCent}); - names[step - 1].push_back(name); - } - if (step == 3) { - TString name = TString::Format("hQ%s%s_mean_vx_run", coord, side); - registry.add(Form("step%i/%s", step, name.Data()), Form("hQ%s%s_mean_vx_run", coord, side), kTProfile, {axisVx}); - names[step - 1].push_back(name); - } - if (step == 4) { - TString name = TString::Format("hQ%s%s_mean_vy_run", coord, side); - registry.add(Form("step%i/%s", step, name.Data()), Form("hQ%s%s_mean_vy_run", coord, side), kTProfile, {axisVy}); - names[step - 1].push_back(name); - } - if (step == 5) { - TString name = TString::Format("hQ%s%s_mean_vz_run", coord, side); - registry.add(Form("step%i/%s", step, name.Data()), Form("hQ%s%s_mean_vz_run", coord, side), kTProfile, {axisVz}); - names[step - 1].push_back(name); - } + registry.add(Form("QA/before/hQ%s%s_vs_cent", coord, side), Form("hQ%s%s_vs_cent", coord, side), {HistType::kTProfile, {axisCent10}}); + registry.add(Form("QA/before/hQ%s%s_vs_vx", coord, side), Form("hQ%s%s_vs_vx", coord, side), {HistType::kTProfile, {axisVx}}); + registry.add(Form("QA/before/hQ%s%s_vs_vy", coord, side), Form("hQ%s%s_vs_vy", coord, side), {HistType::kTProfile, {axisVy}}); + registry.add(Form("QA/before/hQ%s%s_vs_vz", coord, side), Form("hQ%s%s_vs_vz", coord, side), {HistType::kTProfile, {axisVz}}); + + names[0].push_back(TString::Format("hQ%s%s_mean_Cent_V_run", coord, side)); + names[1].push_back(TString::Format("hQ%s%s_mean_cent_run", coord, side)); + names[2].push_back(TString::Format("hQ%s%s_mean_vx_run", coord, side)); + names[3].push_back(TString::Format("hQ%s%s_mean_vy_run", coord, side)); + names[4].push_back(TString::Format("hQ%s%s_mean_vz_run", coord, side)); } // end of capCOORDS } // end of sides - } // end of sum over steps - // recentered q-vectors (to check what steps are finished in the end) - registry.add("hStep", "hStep", {HistType::kTH1D, {{10, 0., 10.}}}); - registry.add("hIteration", "hIteration", {HistType::kTH1D, {{10, 0., 10.}}}); + registry.add("QA/centrality_before", "centrality_before", kTH1D, {{100, 0, 100}}); + registry.add("QA/centrality_after", "centrality_after", kTH1D, {{100, 0, 100}}); + + registry.add("QA/ZNA_Energy", "ZNA_Energy", kTProfile, {{8, 0, 8}}); + registry.add("QA/ZNC_Energy", "ZNC_Energy", kTProfile, {{8, 0, 8}}); + + registry.add("QA/before/ZNA_pmC", "ZNA_pmC", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNA_pm1", "ZNA_pm1", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNA_pm2", "ZNA_pm2", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNA_pm3", "ZNA_pm3", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNA_pm4", "ZNA_pm4", kTProfile, {{1, 0, 1.}}); + + registry.add("QA/before/ZNC_pmC", "ZNC_pmC", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNC_pm1", "ZNC_pm1", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNC_pm2", "ZNC_pm2", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNC_pm3", "ZNC_pm3", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNC_pm4", "ZNC_pm4", kTProfile, {{1, 0, 1.}}); + + registry.add("QA/before/ZNA_Qx", "ZNA_Qx", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNA_Qy", "ZNA_Qy", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNC_Qx", "ZNC_Qx", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNC_Qy", "ZNC_Qy", kTProfile, {{1, 0, 1.}}); + + registry.add("QA/before/ZNA_Qx_vs_Centrality", "ZNA_Qx_vs_Centrality", kTH2D, {{100, 0, 100}, {200, -2, 2}}); + registry.add("QA/before/ZNA_Qy_vs_Centrality", "ZNA_Qy_vs_Centrality", kTH2D, {{100, 0, 100}, {200, -2, 2}}); + registry.add("QA/before/ZNC_Qx_vs_Centrality", "ZNC_Qx_vs_Centrality", kTH2D, {{100, 0, 100}, {200, -2, 2}}); + registry.add("QA/before/ZNC_Qy_vs_Centrality", "ZNC_Qy_vs_Centrality", kTH2D, {{100, 0, 100}, {200, -2, 2}}); + + registry.add("QA/before/ZNA_pmC_vs_Centrality", "ZNA_pmC_vs_Centrality", kTH2D, {{100, 0, 100}, {300, 0, 300}}); + registry.add("QA/before/ZNA_pmSUM_vs_Centrality", "ZNA_pmSUM_vs_Centrality", kTH2D, {{100, 0, 100}, {300, 0, 300}}); + registry.add("QA/before/ZNA_pm1_vs_Centrality", "ZNA_pm1_vs_Centrality", kTH2D, {{100, 0, 100}, {100, 0, 1}}); + registry.add("QA/before/ZNA_pm2_vs_Centrality", "ZNA_pm2_vs_Centrality", kTH2D, {{100, 0, 100}, {100, 0, 1}}); + registry.add("QA/before/ZNA_pm3_vs_Centrality", "ZNA_pm3_vs_Centrality", kTH2D, {{100, 0, 100}, {100, 0, 1}}); + registry.add("QA/before/ZNA_pm4_vs_Centrality", "ZNA_pm4_vs_Centrality", kTH2D, {{100, 0, 100}, {100, 0, 1}}); + + registry.add("QA/before/ZNC_pmC_vs_Centrality", "ZNC_pmC_vs_Centrality", kTH2D, {{100, 0, 100}, {300, 0, 300}}); + registry.add("QA/before/ZNC_pmSUM_vs_Centrality", "ZNC_pmSUM_vs_Centrality", kTH2D, {{100, 0, 100}, {300, 0, 300}}); + registry.add("QA/before/ZNC_pm1_vs_Centrality", "ZNC_pm1_vs_Centrality", kTH2D, {{100, 0, 100}, {100, 0, 1}}); + registry.add("QA/before/ZNC_pm2_vs_Centrality", "ZNC_pm2_vs_Centrality", kTH2D, {{100, 0, 100}, {100, 0, 1}}); + registry.add("QA/before/ZNC_pm3_vs_Centrality", "ZNC_pm3_vs_Centrality", kTH2D, {{100, 0, 100}, {100, 0, 1}}); + registry.add("QA/before/ZNC_pm4_vs_Centrality", "ZNC_pm4_vs_Centrality", kTH2D, {{100, 0, 100}, {100, 0, 1}}); + + registry.addClone("QA/before/", "QA/after/"); + + registry.add("QA/before/ZNA_Qx_noEq", "ZNA_Qx_noEq", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNA_Qy_noEq", "ZNA_Qy_noEq", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNC_Qx_noEq", "ZNC_Qx_noEq", kTProfile, {{1, 0, 1.}}); + registry.add("QA/before/ZNC_Qy_noEq", "ZNC_Qy_noEq", kTProfile, {{1, 0, 1.}}); + } + + // Tower mean energies vs. centrality used for tower gain equalisation + int totalTowers = 10; + int totalTowersPerSide = 5; + for (int tower = 0; tower < totalTowers; tower++) { + namesEcal[tower] = TString::Format("hZN%s_mean_t%i_cent", sides[(tower < totalTowersPerSide) ? 0 : 1], tower % 5); + registry.add(Form("Energy/%s", namesEcal[tower].Data()), Form("%s", namesEcal[tower].Data()), kTProfile2D, {{1, 0, 1}, axisCent}); + } + // recentered q-vectors (to check what steps are finished in the end) registry.add("vmean/hvertex_vx", "hvertex_vx", kTProfile, {{1, 0., 1.}}); registry.add("vmean/hvertex_vy", "hvertex_vy", kTProfile, {{1, 0., 1.}}); registry.add("vmean/hvertex_vz", "hvertex_vz", kTProfile, {{1, 0., 1.}}); - registry.add("QA/centrality_before", "centrality_before", kTH1D, {{200, 0, 100}}); - registry.add("QA/centrality_after", "centrality_after", kTH1D, {{200, 0, 100}}); - - registry.add("QA/ZNA_Energy", "ZNA_Energy", kTProfile, {{8, 0, 8}}); - registry.add("QA/ZNC_Energy", "ZNC_Energy", kTProfile, {{8, 0, 8}}); + registry.add("hEventCount", "Number of Event; Cut; #Events Passed Cut", {HistType::kTH1D, {{nEventSelections, 0, nEventSelections}}}); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_FilteredEvent + 1, "Filtered events"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_Zvtx + 1, "Z vertex cut event"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_sel8 + 1, "Sel8"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_occupancy + 1, "kOccupancy"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoSameBunchPileup + 1, "kNoSameBunchPileup"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoCollInTimeRangeStandard + 1, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsVertexITSTPC + 1, "kIsVertexITSTPC"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_CentCuts + 1, "Cenrality range"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodITSLayersAll + 1, "kkIsGoodITSLayersAll"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_isSelectedZDC + 1, "isSelected"); } - inline void fillRegistry(int iteration, int step) + template + bool eventSelected(TCollision collision, const float& centrality) { - if (step == 0 && iteration == 1) { - registry.fill(HIST("hIteration"), iteration, 1); - - registry.fill(HIST("step1/hQXA_mean_Cent_V_run"), runnumber, centrality, v[0], v[1], v[2], q[0][step][0]); - registry.fill(HIST("step1/hQYA_mean_Cent_V_run"), runnumber, centrality, v[0], v[1], v[2], q[0][step][1]); - registry.fill(HIST("step1/hQXC_mean_Cent_V_run"), runnumber, centrality, v[0], v[1], v[2], q[0][step][2]); - registry.fill(HIST("step1/hQYC_mean_Cent_V_run"), runnumber, centrality, v[0], v[1], v[2], q[0][step][3]); - registry.fill(HIST("hStep"), step, 1); + if (std::fabs(collision.posZ()) > cfgVtxZ) + return 0; + registry.fill(HIST("hEventCount"), evSel_Zvtx); + + if (!collision.sel8()) + return 0; + registry.fill(HIST("hEventCount"), evSel_sel8); + + // Occupancy + if (cfgEvSelsDoOccupancySel) { + auto occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy > cfgEvSelsMaxOccupancy) { + return 0; + } + registry.fill(HIST("hEventCount"), evSel_occupancy); } - if (step == 1) { - registry.get(HIST("step2/hQXA_mean_cent_run"))->Fill(centrality, q[iteration][step][0]); - registry.get(HIST("step2/hQYA_mean_cent_run"))->Fill(centrality, q[iteration][step][1]); - registry.get(HIST("step2/hQXC_mean_cent_run"))->Fill(centrality, q[iteration][step][2]); - registry.get(HIST("step2/hQYC_mean_cent_run"))->Fill(centrality, q[iteration][step][3]); - registry.fill(HIST("hStep"), step, 1); + if (cfgEvSelsNoSameBunchPileupCut) { + if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return 0; + } + registry.fill(HIST("hEventCount"), evSel_kNoSameBunchPileup); } - - if (step == 2) { - registry.get(HIST("step3/hQXA_mean_vx_run"))->Fill(v[0], q[iteration][step][0]); - registry.get(HIST("step3/hQYA_mean_vx_run"))->Fill(v[0], q[iteration][step][1]); - registry.get(HIST("step3/hQXC_mean_vx_run"))->Fill(v[0], q[iteration][step][2]); - registry.get(HIST("step3/hQYC_mean_vx_run"))->Fill(v[0], q[iteration][step][3]); - registry.fill(HIST("hStep"), step, 1); + if (cfgEvSelsIsGoodZvtxFT0vsPV) { + if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return 0; + } + registry.fill(HIST("hEventCount"), evSel_kIsGoodZvtxFT0vsPV); } - - if (step == 3) { - registry.get(HIST("step4/hQXA_mean_vy_run"))->Fill(v[1], q[iteration][step][0]); - registry.get(HIST("step4/hQYA_mean_vy_run"))->Fill(v[1], q[iteration][step][1]); - registry.get(HIST("step4/hQXC_mean_vy_run"))->Fill(v[1], q[iteration][step][2]); - registry.get(HIST("step4/hQYC_mean_vy_run"))->Fill(v[1], q[iteration][step][3]); - registry.fill(HIST("hStep"), step, 1); + if (cfgEvSelsNoCollInTimeRangeStandard) { + if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // Rejection of the collisions which have other events nearby + return 0; + } + registry.fill(HIST("hEventCount"), evSel_kNoCollInTimeRangeStandard); } - if (step == 4) { - registry.get(HIST("step5/hQXA_mean_vz_run"))->Fill(v[2], q[iteration][step][0]); - registry.get(HIST("step5/hQYA_mean_vz_run"))->Fill(v[2], q[iteration][step][1]); - registry.get(HIST("step5/hQXC_mean_vz_run"))->Fill(v[2], q[iteration][step][2]); - registry.get(HIST("step5/hQYC_mean_vz_run"))->Fill(v[2], q[iteration][step][3]); - registry.fill(HIST("hStep"), step, 1); + if (cfgEvSelsIsVertexITSTPC) { + if (!collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + // selects collisions with at least one ITS-TPC track, and thus rejects vertices built from ITS-only tracks + return 0; + } + registry.fill(HIST("hEventCount"), evSel_kIsVertexITSTPC); } - if (step == 5) { - registry.fill(HIST("step5/hQXA_mean_Cent_V_run"), centrality, v[0], v[1], v[2], q[iteration][step][0]); - registry.fill(HIST("step5/hQYA_mean_Cent_V_run"), centrality, v[0], v[1], v[2], q[iteration][step][1]); - registry.fill(HIST("step5/hQXC_mean_Cent_V_run"), centrality, v[0], v[1], v[2], q[iteration][step][2]); - registry.fill(HIST("step5/hQYC_mean_Cent_V_run"), centrality, v[0], v[1], v[2], q[iteration][step][3]); - registry.fill(HIST("hStep"), step, 1); + if (centrality > cfgEvSelsCentMax || centrality < cfgEvSelsCentMin) + return 0; + registry.fill(HIST("hEventCount"), evSel_CentCuts); + + if (cfgEvSelsIsGoodITSLayersAll) { + if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // New event selection bits to cut time intervals with dead ITS staves + // https://indico.cern.ch/event/1493023/ (09-01-2025) + return 0; + } + registry.fill(HIST("hEventCount"), evSel_kIsGoodITSLayersAll); } + + return 1; } - inline void fillCommonRegistry(int iteration) + template + inline void fillCommonRegistry(double qxa, double qya, double qxc, double qyc, std::vector v, double centrality) { // loop for filling multiple histograms with different naming patterns // Always fill the uncentered "raw" Q-vector histos! - - registry.fill(HIST("step0/hZNA_Qx_vs_Qy"), q[0][0][0], q[0][0][1]); - registry.fill(HIST("step0/hZNC_Qx_vs_Qy"), q[0][0][2], q[0][0][3]); - - registry.fill(HIST("step0/QA/hQXA_QXC_vs_cent"), centrality, q[0][0][0] * q[0][0][2]); - registry.fill(HIST("step0/QA/hQYA_QYC_vs_cent"), centrality, q[0][0][1] * q[0][0][3]); - registry.fill(HIST("step0/QA/hQYA_QXC_vs_cent"), centrality, q[0][0][1] * q[0][0][2]); - registry.fill(HIST("step0/QA/hQXA_QYC_vs_cent"), centrality, q[0][0][0] * q[0][0][3]); - - registry.fill(HIST("step0/QA/hQXA_vs_cent"), centrality, q[0][0][0]); - registry.fill(HIST("step0/QA/hQYA_vs_cent"), centrality, q[0][0][1]); - registry.fill(HIST("step0/QA/hQXC_vs_cent"), centrality, q[0][0][2]); - registry.fill(HIST("step0/QA/hQYC_vs_cent"), centrality, q[0][0][3]); - - registry.fill(HIST("step0/QA/hQXA_vs_vx"), v[0], q[0][0][0]); - registry.fill(HIST("step0/QA/hQYA_vs_vx"), v[0], q[0][0][1]); - registry.fill(HIST("step0/QA/hQXC_vs_vx"), v[0], q[0][0][2]); - registry.fill(HIST("step0/QA/hQYC_vs_vx"), v[0], q[0][0][3]); - - registry.fill(HIST("step0/QA/hQXA_vs_vy"), v[1], q[0][0][0]); - registry.fill(HIST("step0/QA/hQYA_vs_vy"), v[1], q[0][0][1]); - registry.fill(HIST("step0/QA/hQXC_vs_vy"), v[1], q[0][0][2]); - registry.fill(HIST("step0/QA/hQYC_vs_vy"), v[1], q[0][0][3]); - - registry.fill(HIST("step0/QA/hQXA_vs_vz"), v[2], q[0][0][0]); - registry.fill(HIST("step0/QA/hQYA_vs_vz"), v[2], q[0][0][1]); - registry.fill(HIST("step0/QA/hQXC_vs_vz"), v[2], q[0][0][2]); - registry.fill(HIST("step0/QA/hQYC_vs_vz"), v[2], q[0][0][3]); + static constexpr std::string_view Time[] = {"before", "after"}; + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hZNA_Qx_vs_Qy"), qxa, qya); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hZNC_Qx_vs_Qy"), qxc, qyc); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QXC_vs_cent"), centrality, qxa * qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QYC_vs_cent"), centrality, qya * qyc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QXC_vs_cent"), centrality, qya * qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QYC_vs_cent"), centrality, qxa * qyc); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_vs_cent"), centrality, qxa); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_vs_cent"), centrality, qya); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXC_vs_cent"), centrality, qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYC_vs_cent"), centrality, qyc); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_vs_vx"), v[0], qxa); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_vs_vx"), v[0], qya); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXC_vs_vx"), v[0], qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYC_vs_vx"), v[0], qyc); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QXC_vs_vx"), v[0], qxa * qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QYC_vs_vx"), v[0], qya * qyc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QXC_vs_vx"), v[0], qya * qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QYC_vs_vx"), v[0], qxa * qyc); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_vs_vy"), v[1], qxa); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_vs_vy"), v[1], qya); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXC_vs_vy"), v[1], qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYC_vs_vy"), v[1], qyc); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QXC_vs_vy"), v[1], qxa * qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QYC_vs_vy"), v[1], qya * qyc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QXC_vs_vy"), v[1], qya * qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QYC_vs_vy"), v[1], qxa * qyc); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_vs_vz"), v[2], qxa); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_vs_vz"), v[2], qya); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXC_vs_vz"), v[2], qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYC_vs_vz"), v[2], qyc); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QXC_vs_vz"), v[2], qxa * qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QYC_vs_vz"), v[2], qya * qyc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QXC_vs_vz"), v[2], qya * qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QYC_vs_vz"), v[2], qxa * qyc); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/ZNA_Qx_vs_Centrality"), centrality, qxa); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/ZNA_Qy_vs_Centrality"), centrality, qya); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/ZNC_Qx_vs_Centrality"), centrality, qxc); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/ZNC_Qy_vs_Centrality"), centrality, qyc); // add psi!! - double psiA = 1.0 * std::atan2(q[0][0][2], q[0][0][0]); - registry.fill(HIST("step0/QA/hSPplaneA"), psiA, centrality, 1); - double psiC = 1.0 * std::atan2(q[0][0][3], q[0][0][1]); - registry.fill(HIST("step0/QA/hSPplaneC"), psiC, centrality, 1); - double psiFull = 1.0 * std::atan2(q[0][0][2] + q[0][0][3], q[0][0][0] + q[0][0][1]); - registry.fill(HIST("step0/QA/hSPplaneFull"), psiFull, centrality, 1); - - static constexpr std::string_view SubDir[] = {"step1/", "step2/", "step3/", "step4/", "step5/"}; - static_for<0, 4>([&](auto Ind) { - constexpr int Index = Ind.value; - int indexRt = Index + 1; - - registry.fill(HIST(SubDir[Index]) + HIST("hZNA_Qx_vs_Qy"), q[iteration][indexRt][0], q[iteration][indexRt][1]); - registry.fill(HIST(SubDir[Index]) + HIST("hZNC_Qx_vs_Qy"), q[iteration][indexRt][2], q[iteration][indexRt][3]); - - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXA_QXC_vs_cent"), centrality, q[iteration][indexRt][0] * q[iteration][indexRt][2]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYA_QYC_vs_cent"), centrality, q[iteration][indexRt][1] * q[iteration][indexRt][3]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYA_QXC_vs_cent"), centrality, q[iteration][indexRt][1] * q[iteration][indexRt][2]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXA_QYC_vs_cent"), centrality, q[iteration][indexRt][0] * q[iteration][indexRt][3]); - - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXA_vs_cent"), centrality, q[iteration][indexRt][0]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYA_vs_cent"), centrality, q[iteration][indexRt][1]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXC_vs_cent"), centrality, q[iteration][indexRt][2]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYC_vs_cent"), centrality, q[iteration][indexRt][3]); - - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXA_vs_vx"), v[0], q[iteration][indexRt][0]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYA_vs_vx"), v[0], q[iteration][indexRt][1]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXC_vs_vx"), v[0], q[iteration][indexRt][2]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYC_vs_vx"), v[0], q[iteration][indexRt][3]); - - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXA_vs_vy"), v[1], q[iteration][indexRt][0]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYA_vs_vy"), v[1], q[iteration][indexRt][1]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXC_vs_vy"), v[1], q[iteration][indexRt][2]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYC_vs_vy"), v[1], q[iteration][indexRt][3]); - - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXA_vs_vz"), v[2], q[iteration][indexRt][0]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYA_vs_vz"), v[2], q[iteration][indexRt][1]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQXC_vs_vz"), v[2], q[iteration][indexRt][2]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hQYC_vs_vz"), v[2], q[iteration][indexRt][3]); - - psiA = 1.0 * std::atan2(q[iteration][indexRt][2], q[iteration][indexRt][0]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hSPplaneA"), psiA, centrality, 1); - psiC = 1.0 * std::atan2(q[iteration][indexRt][3], q[iteration][indexRt][1]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hSPplaneC"), psiC, centrality, 1); - psiFull = 1.0 * std::atan2(q[iteration][indexRt][2] + q[iteration][indexRt][3], q[iteration][indexRt][0] + q[iteration][indexRt][1]); - registry.fill(HIST(SubDir[Index]) + HIST("QA/hSPplaneFull"), psiFull, centrality, 1); - }); + double psiA = 1.0 * std::atan2(qxc, qxa); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hSPplaneA"), psiA, centrality, 1); + double psiC = 1.0 * std::atan2(qyc, qya); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hSPplaneC"), psiC, centrality, 1); + double psiFull = 1.0 * std::atan2(qxc + qyc, qxa + qya); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hSPplaneFull"), psiFull, centrality, 1); } - void loadCalibrations(int iteration, int step, uint64_t timestamp, std::string ccdb_dir, std::vector names) + template + void loadCalibrations(uint64_t timestamp, std::string ccdb_dir) { // iteration = 0 (Energy calibration) -> step 0 only // iteration 1,2,3,4,5 = recentering -> 5 steps per iteration (1x 4D + 4x 1D) - if (ccdb_dir.empty() == false) { - cal.calibList[iteration][step] = ccdb->getForTimeStamp(ccdb_dir, timestamp); - - if (cal.calibList[iteration][step]) { - for (std::size_t i = 0; i < names.size(); i++) { - TObject* obj = reinterpret_cast(cal.calibList[iteration][step]->FindObject(Form("%s", names[i].Data()))); - if (!obj) { - if (counter < 1) { - LOGF(error, "Object %s not found!!", names[i].Data()); - return; - } - } - // Try to cast to TProfile - if (TProfile* profile2D = dynamic_cast(obj)) { - if (profile2D->GetEntries() < 1) { - if (counter < 1) - LOGF(info, "%s (TProfile) is empty! Produce calibration file at given step", names[i].Data()); - cal.calibfilesLoaded[iteration][step] = false; - return; - } - if (counter < 1) - LOGF(info, "Loaded TProfile: %s", names[i].Data()); - } else if (TProfile2D* profile2D = dynamic_cast(obj)) { - if (profile2D->GetEntries() < 1) { - if (counter < 1) - LOGF(info, "%s (TProfile2D) is empty! Produce calibration file at given step", names[i].Data()); - cal.calibfilesLoaded[iteration][step] = false; - return; - } - if (counter < 1) - LOGF(info, "Loaded TProfile2D: %s", names[i].Data()); - } else if (THnSparse* sparse = dynamic_cast(obj)) { - if (sparse->GetEntries() < 1) { - if (counter < 1) - LOGF(info, "%s (THnSparse) is empty! Produce calibration file at given step", names[i].Data()); - cal.calibfilesLoaded[iteration][step] = false; - return; - } - if (counter < 1) - LOGF(info, "Loaded THnSparse: %s", names[i].Data()); - } - } // end of for loop - } else { - // when (cal.calib[iteration][step])=false! - if (counter < 1) - LOGF(warning, "Could not load TList with calibration histos from %s", ccdb_dir.c_str()); - cal.calibfilesLoaded[iteration][step] = false; - return; - } - if (counter < 1) - LOGF(info, "<--------OK----------> Calibrations loaded for cal.calibfilesLoaded[%i][%i]", iteration, step); - cal.calibfilesLoaded[iteration][step] = true; - cal.atIteration = iteration; - cal.atStep = step; + if (cal.calibfilesLoaded[cm]) return; - } else { - if (counter < 1) - LOGF(info, "<--------X-----------> Calibrations not loaded for iteration %i and step %i cfg = empty!", iteration, step); + + if (ccdb_dir.empty() == false) { + cal.calibList[cm] = ccdb->getForTimeStamp(ccdb_dir, timestamp); + cal.calibfilesLoaded[cm] = true; + LOGF(info, "Loaded calibration histos from %s", ccdb_dir.c_str()); + if (cm == kRec) { + cal.atStep = 5; + cal.atIteration = 5; + } } } - template - double getCorrection(int iteration, int step, const char* objName) + template + double getCorrection(const char* objName, int iteration = 0, int step = 0) { T* hist = nullptr; double calibConstant{0}; - hist = reinterpret_cast(cal.calibList[iteration][step]->FindObject(Form("%s", objName))); + if (cm == kEnergyCal) { + TList* list = cal.calibList[cm]; + hist = reinterpret_cast(list->FindObject(Form("%s", objName))); + } else if (cm == kMeanv) { + TList* list = cal.calibList[cm]; + hist = reinterpret_cast(list->FindObject(Form("%s", objName))); + } else if (cm == kRec) { + TList* list = reinterpret_cast(cal.calibList[cm]->FindObject(Form("it%i_step%i", iteration, step))); + if (!list) { + LOGF(fatal, "No calibration list for iteration %i and step %i", iteration, step); + } + hist = reinterpret_cast(list->FindObject(Form("%s", objName))); + if (!hist) { + LOGF(fatal, "No calibration histo for iteration %i and step %i -> %s", iteration, step, objName); + } + cal.atStep = step; + cal.atIteration = iteration; + } + if (!hist) { LOGF(fatal, "%s not available.. Abort..", objName); } @@ -489,22 +520,20 @@ struct ZdcQVectors { for (std::size_t i = 0; i < sparsePars.size(); i++) { h->GetAxis(i)->SetRange(sparsePars[i], sparsePars[i]); } - calibConstant = h->Projection(4)->GetMean(); - if (h->Projection(4)->GetEntries() < cfgMinEntriesSparseBin) { + TH1D* tempProj = h->Projection(4); + calibConstant = tempProj->GetMean(); + + if (tempProj->GetEntries() < cfgMinEntriesSparseBin) { LOGF(debug, "1 entry in sparse bin! Not used... (increase binsize)"); calibConstant = 0; isSelected = false; } + + delete tempProj; } - return calibConstant; - } - void fillAllRegistries(int iteration, int step) - { - for (int s = 0; s <= step; s++) - fillRegistry(iteration, s); - fillCommonRegistry(iteration); + return calibConstant; } void process(UsedCollisions::iterator const& collision, @@ -513,27 +542,42 @@ struct ZdcQVectors { { // for Q-vector calculation // A[0] & C[1] - std::vector sumZN(2, 0.); - std::vector xEnZN(2, 0.); - std::vector yEnZN(2, 0.); + std::vector sumZN(2, 0.), sumZN_noEq(2, 0.); + std::vector xEnZN(2, 0.), xEnZN_noEq(2, 0.); + std::vector yEnZN(2, 0.), yEnZN_noEq(2, 0.); isSelected = true; + // TODO Implement other ZDC estimators auto cent = collision.centFT0C(); - - if (cent < 0 || cent > 90) { + if (cfgFT0Cvariant1) + cent = collision.centFT0CVariant1(); + if (cfgFT0M) + cent = collision.centFT0M(); + if (cfgFV0A) + cent = collision.centFV0A(); + if (cfgNGlobal) + cent = collision.centNGlobal(); + + if (cfgFillCommonRegistry) + registry.fill(HIST("QA/centrality_before"), cent); + + registry.fill(HIST("hEventCount"), evSel_FilteredEvent); + + if (!eventSelected(collision, cent)) { + // event not selected isSelected = false; spTableZDC(runnumber, cent, v[0], v[1], v[2], 0, 0, 0, 0, isSelected, 0, 0); + counter++; return; } - registry.fill(HIST("QA/centrality_before"), cent); - const auto& foundBC = collision.foundBC_as(); if (!foundBC.has_zdc()) { isSelected = false; spTableZDC(runnumber, cent, v[0], v[1], v[2], 0, 0, 0, 0, isSelected, 0, 0); + counter++; return; } @@ -543,42 +587,46 @@ struct ZdcQVectors { centrality = cent; runnumber = foundBC.runNumber(); + // load new calibrations for new runs only + // UPLOAD Energy calibration and vmean in 1 histogram! + if (runnumber != lastRunNumber) { + cal.calibfilesLoaded[2] = false; + cal.calibList[2] = nullptr; + lastRunNumber = runnumber; + } + const auto& zdcCol = foundBC.zdc(); // Get the raw energies eZN[8] (not the common A,C) - for (int tower = 0; tower < 8; tower++) { - eZN[tower] = (tower < 4) ? zdcCol.energySectorZNA()[tower] : zdcCol.energySectorZNC()[tower % 4]; + int nTowers = 8; + int nTowersPerSide = 4; + + for (int tower = 0; tower < nTowers; tower++) { + eZN[tower] = (tower < nTowersPerSide) ? zdcCol.energySectorZNA()[tower] : zdcCol.energySectorZNC()[tower % nTowersPerSide]; } // load the calibration histos for iteration 0 step 0 (Energy Calibration) - loadCalibrations(0, 0, foundBC.timestamp(), cfgEnergyCal.value, namesEcal); + loadCalibrations(foundBC.timestamp(), cfgEnergyCal.value); - if (!cal.calibfilesLoaded[0][0]) { + if (!cal.calibfilesLoaded[0]) { if (counter < 1) { LOGF(info, " --> No Energy calibration files found.. -> Only Energy calibration will be done. "); } } // load the calibrations for the mean v - loadCalibrations(0, 1, foundBC.timestamp(), cfgMeanv.value, vnames); - - if (!cal.calibfilesLoaded[0][1]) { - if (counter < 1) - LOGF(warning, " --> No mean V found.. -> THis wil lead to wrong axis for vx, vy (will be created in vmean/)"); - registry.get(HIST("vmean/hvertex_vx"))->Fill(Form("%d", runnumber), v[0]); - registry.get(HIST("vmean/hvertex_vy"))->Fill(Form("%d", runnumber), v[1]); - registry.get(HIST("vmean/hvertex_vz"))->Fill(Form("%d", runnumber), v[2]); - } + loadCalibrations(foundBC.timestamp(), cfgMeanv.value); - if (counter < 1) - LOGF(info, "=====================> .....Start Energy Calibration..... <====================="); + registry.get(HIST("vmean/hvertex_vx"))->Fill(Form("%d", runnumber), v[0]); + registry.get(HIST("vmean/hvertex_vy"))->Fill(Form("%d", runnumber), v[1]); + registry.get(HIST("vmean/hvertex_vz"))->Fill(Form("%d", runnumber), v[2]); bool isZNAhit = true; bool isZNChit = true; - for (int i = 0; i < 8; ++i) { - if (i < 4 && eZN[i] <= 0) + for (int i = 0; i < nTowers; ++i) { + if (i < nTowersPerSide && eZN[i] <= 0) isZNAhit = false; - if (i > 3 && eZN[i] <= 0) + if (i >= nTowersPerSide && eZN[i] <= 0) isZNChit = false; } @@ -588,20 +636,19 @@ struct ZdcQVectors { isZNChit = false; // Fill to get mean energy per tower in 1% centrality bins - for (int tower = 0; tower < 5; tower++) { - if (tower == 0) { - if (isZNAhit) - energyZN[tower]->Fill(Form("%d", runnumber), cent, zdcCol.energyCommonZNA(), 1); - if (isZNChit) - energyZN[tower + 5]->Fill(Form("%d", runnumber), cent, zdcCol.energyCommonZNC(), 1); - LOGF(debug, "Common A tower filled with: %i, %.2f, %.2f", runnumber, cent, zdcCol.energyCommonZNA()); - } else { - if (isZNAhit) - energyZN[tower]->Fill(Form("%d", runnumber), cent, eZN[tower - 1], 1); - if (isZNChit) - energyZN[tower + 5]->Fill(Form("%d", runnumber), cent, eZN[tower - 1 + 4], 1); - LOGF(debug, "Tower ZNC[%i] filled with: %i, %.2f, %.2f", tower, runnumber, cent, eZN[tower - 1 + 4]); - } + if (isZNAhit) { + registry.get(HIST("Energy/hZNA_mean_t0_cent"))->Fill(Form("%d", runnumber), cent, zdcCol.energyCommonZNA(), 1); + registry.get(HIST("Energy/hZNA_mean_t1_cent"))->Fill(Form("%d", runnumber), cent, eZN[0], 1); + registry.get(HIST("Energy/hZNA_mean_t2_cent"))->Fill(Form("%d", runnumber), cent, eZN[1], 1); + registry.get(HIST("Energy/hZNA_mean_t3_cent"))->Fill(Form("%d", runnumber), cent, eZN[2], 1); + registry.get(HIST("Energy/hZNA_mean_t4_cent"))->Fill(Form("%d", runnumber), cent, eZN[3], 1); + } + if (isZNChit) { + registry.get(HIST("Energy/hZNC_mean_t0_cent"))->Fill(Form("%d", runnumber), cent, zdcCol.energyCommonZNC(), 1); + registry.get(HIST("Energy/hZNC_mean_t1_cent"))->Fill(Form("%d", runnumber), cent, eZN[4], 1); + registry.get(HIST("Energy/hZNC_mean_t2_cent"))->Fill(Form("%d", runnumber), cent, eZN[5], 1); + registry.get(HIST("Energy/hZNC_mean_t3_cent"))->Fill(Form("%d", runnumber), cent, eZN[6], 1); + registry.get(HIST("Energy/hZNC_mean_t4_cent"))->Fill(Form("%d", runnumber), cent, eZN[7], 1); } // if ZNA or ZNC not hit correctly.. do not use event in q-vector calculation @@ -612,24 +659,20 @@ struct ZdcQVectors { return; } - if (!cal.calibfilesLoaded[0][0]) { + registry.fill(HIST("hEventCount"), evSel_isSelectedZDC); + + // Do not continue if Energy calibration is not loaded + if (!cal.calibfilesLoaded[0]) { counter++; isSelected = false; spTableZDC(runnumber, centrality, v[0], v[1], v[2], 0, 0, 0, 0, isSelected, 0, 0); return; } - if (counter < 1) - LOGF(info, "files for step 0 (energy Calibraton) are open!"); - - if (counter < 1) { - LOGF(info, "=====================> .....Start Calculating Q-Vectors..... <====================="); - } - // Now start gain equalisation! // Fill the list with calibration constants. - for (int tower = 0; tower < 10; tower++) { - meanEZN[tower] = getCorrection(0, 0, namesEcal[tower].Data()); + for (int tower = 0; tower < (nTowers + 2); tower++) { + meanEZN[tower] = getCorrection(namesEcal[tower].Data()); } // Use the calibration constants but now only loop over towers 1-4 @@ -638,103 +681,184 @@ struct ZdcQVectors { for (const auto& tower : towersNocom) { if (meanEZN[tower] > 0) { - double ecommon = (tower > 4) ? meanEZN[5] : meanEZN[0]; + double ecommon = (tower > nTowersPerSide) ? meanEZN[5] : meanEZN[0]; e[calibtower] = eZN[calibtower] * (0.25 * ecommon) / meanEZN[tower]; } calibtower++; } - for (int i = 0; i < 4; i++) { + for (int i = 0; i < nTowersPerSide; i++) { float bincenter = i + .5; registry.fill(HIST("QA/ZNA_Energy"), bincenter, eZN[i]); registry.fill(HIST("QA/ZNA_Energy"), bincenter + 4, e[i]); registry.fill(HIST("QA/ZNC_Energy"), bincenter, eZN[i + 4]); registry.fill(HIST("QA/ZNC_Energy"), bincenter + 4, e[i + 4]); + + registry.get(HIST("QA/before/ZNA_pmC"))->Fill(Form("%d", runnumber), meanEZN[0]); + registry.get(HIST("QA/before/ZNA_pm1"))->Fill(Form("%d", runnumber), eZN[0]); + registry.get(HIST("QA/before/ZNA_pm2"))->Fill(Form("%d", runnumber), eZN[1]); + registry.get(HIST("QA/before/ZNA_pm3"))->Fill(Form("%d", runnumber), eZN[2]); + registry.get(HIST("QA/before/ZNA_pm4"))->Fill(Form("%d", runnumber), eZN[3]); + + registry.get(HIST("QA/before/ZNC_pmC"))->Fill(Form("%d", runnumber), meanEZN[5]); + registry.get(HIST("QA/before/ZNC_pm1"))->Fill(Form("%d", runnumber), eZN[4]); + registry.get(HIST("QA/before/ZNC_pm2"))->Fill(Form("%d", runnumber), eZN[5]); + registry.get(HIST("QA/before/ZNC_pm3"))->Fill(Form("%d", runnumber), eZN[6]); + registry.get(HIST("QA/before/ZNC_pm4"))->Fill(Form("%d", runnumber), eZN[7]); + + registry.get(HIST("QA/after/ZNA_pm1"))->Fill(Form("%d", runnumber), e[0]); + registry.get(HIST("QA/after/ZNA_pm2"))->Fill(Form("%d", runnumber), e[1]); + registry.get(HIST("QA/after/ZNA_pm3"))->Fill(Form("%d", runnumber), e[2]); + registry.get(HIST("QA/after/ZNA_pm4"))->Fill(Form("%d", runnumber), e[3]); + registry.get(HIST("QA/after/ZNC_pm1"))->Fill(Form("%d", runnumber), e[4]); + registry.get(HIST("QA/after/ZNC_pm2"))->Fill(Form("%d", runnumber), e[5]); + registry.get(HIST("QA/after/ZNC_pm3"))->Fill(Form("%d", runnumber), e[6]); + registry.get(HIST("QA/after/ZNC_pm4"))->Fill(Form("%d", runnumber), e[7]); + + double sumZNAbefore = eZN[0] + eZN[1] + eZN[2] + eZN[3]; + double sumZNAafter = e[0] + e[1] + e[2] + e[3]; + + double sumZNCbefore = eZN[4] + eZN[5] + eZN[6] + eZN[7]; + double sumZNCafter = e[4] + e[5] + e[6] + e[7]; + + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNA_pmC_vs_Centrality"), centrality, zdcCol.energyCommonZNA()); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNA_pmSUM_vs_Centrality"), centrality, sumZNAbefore); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNA_pm1_vs_Centrality"), centrality, eZN[0] / sumZNAbefore); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNA_pm2_vs_Centrality"), centrality, eZN[1] / sumZNAbefore); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNA_pm3_vs_Centrality"), centrality, eZN[2] / sumZNAbefore); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNA_pm4_vs_Centrality"), centrality, eZN[3] / sumZNAbefore); + + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNC_pmC_vs_Centrality"), centrality, zdcCol.energyCommonZNC()); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNC_pmSUM_vs_Centrality"), centrality, sumZNCbefore); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNC_pm1_vs_Centrality"), centrality, eZN[4] / sumZNCbefore); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNC_pm2_vs_Centrality"), centrality, eZN[5] / sumZNCbefore); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNC_pm3_vs_Centrality"), centrality, eZN[6] / sumZNCbefore); + registry.fill(HIST("QA/") + HIST("before") + HIST("/ZNC_pm4_vs_Centrality"), centrality, eZN[7] / sumZNCbefore); + + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNA_pmC_vs_Centrality"), centrality, zdcCol.energyCommonZNA()); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNA_pmSUM_vs_Centrality"), centrality, sumZNAafter); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNA_pm1_vs_Centrality"), centrality, e[0] / sumZNAafter); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNA_pm2_vs_Centrality"), centrality, e[1] / sumZNAafter); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNA_pm3_vs_Centrality"), centrality, e[2] / sumZNAafter); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNA_pm4_vs_Centrality"), centrality, e[3] / sumZNAafter); + + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNC_pmC_vs_Centrality"), centrality, zdcCol.energyCommonZNC()); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNC_pmSUM_vs_Centrality"), centrality, sumZNCafter); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNC_pm1_vs_Centrality"), centrality, e[4] / sumZNCafter); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNC_pm2_vs_Centrality"), centrality, e[5] / sumZNCafter); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNC_pm3_vs_Centrality"), centrality, e[6] / sumZNCafter); + registry.fill(HIST("QA/") + HIST("after") + HIST("/ZNC_pm4_vs_Centrality"), centrality, e[7] / sumZNCafter); } // Now calculate Q-vector - for (int tower = 0; tower < 8; tower++) { - int side = (tower > 3) ? 1 : 0; - int sector = tower % 4; + for (int tower = 0; tower < nTowers; tower++) { + int side = (tower >= nTowersPerSide) ? 1 : 0; + int sector = tower % nTowersPerSide; double energy = std::pow(e[tower], alphaZDC); sumZN[side] += energy; xEnZN[side] += (side == 0) ? -1.0 * pxZDC[sector] * energy : pxZDC[sector] * energy; yEnZN[side] += pyZDC[sector] * energy; + + // Also calculate the Q-vector for the non-equalized energy + double energyNoEq = std::pow(eZN[tower], alphaZDC); + sumZN_noEq[side] += energyNoEq; + xEnZN_noEq[side] += (side == 0) ? -1.0 * pxZDC[sector] * energyNoEq : pxZDC[sector] * energyNoEq; + yEnZN_noEq[side] += pyZDC[sector] * energyNoEq; } // "QXA", "QYA", "QXC", "QYC" - for (int i = 0; i < 2; ++i) { + int sides = 2; + for (int i = 0; i < sides; ++i) { if (sumZN[i] > 0) { - q[0][0][i * 2] = xEnZN[i] / sumZN[i]; // for QXA[0] and QXC[2] - q[0][0][i * 2 + 1] = yEnZN[i] / sumZN[i]; // for QYA[1] and QYC[3] + q[i * 2] = xEnZN[i] / sumZN[i]; // for QXA[0] and QXC[2] + q[i * 2 + 1] = yEnZN[i] / sumZN[i]; // for QYA[1] and QYC[3] + } + if (sumZN_noEq[i] > 0) { + qNoEq[i * 2] = xEnZN_noEq[i] / sumZN_noEq[i]; // for QXA[0] and QXC[2] + qNoEq[i * 2 + 1] = yEnZN_noEq[i] / sumZN_noEq[i]; // for QYA[1] and QYC[3] } } - if (cal.calibfilesLoaded[0][1]) { - if (counter < 1) - LOGF(info, "=====================> Setting v to vmean!"); - v[0] = v[0] - getCorrection(0, 1, vnames[0].Data()); - v[1] = v[1] - getCorrection(0, 1, vnames[1].Data()); + if (cal.calibfilesLoaded[1]) { + v[0] = v[0] - getCorrection(vnames[0].Data()); + v[1] = v[1] - getCorrection(vnames[1].Data()); + } else { + LOGF(warning, " --> No mean V found.. -> THis wil lead to wrong axis for vx, vy (will be created in vmean/)"); + return; } - for (int iteration = 1; iteration < 6; iteration++) { - std::vector ccdbDirs; - if (iteration == 1) - ccdbDirs = cfgRec1.value; - if (iteration == 2) - ccdbDirs = cfgRec2.value; - if (iteration == 3) - ccdbDirs = cfgRec3.value; - if (iteration == 4) - ccdbDirs = cfgRec4.value; - if (iteration == 5) - ccdbDirs = cfgRec5.value; - - for (int step = 0; step < 5; step++) { - loadCalibrations(iteration, step, foundBC.timestamp(), (ccdbDirs)[step], names[step]); - } - } + loadCalibrations(foundBC.timestamp(), cfgRec.value); + + std::vector qRec(q); - if (counter < 1) - LOGF(info, "We evaluate cal.atIteration=%i and cal.atStep=%i ", cal.atIteration, cal.atStep); + registry.get(HIST("QA/before/ZNA_Qx"))->Fill(Form("%d", runnumber), q[0]); + registry.get(HIST("QA/before/ZNA_Qy"))->Fill(Form("%d", runnumber), q[1]); + registry.get(HIST("QA/before/ZNC_Qx"))->Fill(Form("%d", runnumber), q[2]); + registry.get(HIST("QA/before/ZNC_Qy"))->Fill(Form("%d", runnumber), q[3]); + + registry.get(HIST("QA/before/ZNA_Qx_noEq"))->Fill(Form("%d", runnumber), qNoEq[0]); + registry.get(HIST("QA/before/ZNA_Qy_noEq"))->Fill(Form("%d", runnumber), qNoEq[1]); + registry.get(HIST("QA/before/ZNC_Qx_noEq"))->Fill(Form("%d", runnumber), qNoEq[2]); + registry.get(HIST("QA/before/ZNC_Qy_noEq"))->Fill(Form("%d", runnumber), qNoEq[3]); if (cal.atIteration == 0) { - if (counter < 1) - LOGF(warning, "Calibation files missing!!! Output created with q-vectors right after energy gain eq. !!"); - if (isSelected) - fillAllRegistries(0, 0); - spTableZDC(runnumber, centrality, v[0], v[1], v[2], q[0][0][0], q[0][0][1], q[0][0][2], q[0][0][3], isSelected, 0, 0); + if (isSelected && cfgFillCommonRegistry) + fillCommonRegistry(q[0], q[1], q[2], q[3], v, centrality); + + spTableZDC(runnumber, centrality, v[0], v[1], v[2], q[0], q[1], q[2], q[3], isSelected, 0, 0); counter++; return; } else { - for (int iteration = 1; iteration <= cal.atIteration; iteration++) { - for (int step = 0; step < cal.atStep + 1; step++) { - if (cal.calibfilesLoaded[iteration][step]) { - for (int i = 0; i < 4; i++) { - if (step == 0) { - if (iteration == 1) { - q[iteration][step + 1][i] = q[0][0][i] - getCorrection(iteration, step, names[step][i].Data()); - } else { - q[iteration][step + 1][i] = q[iteration - 1][5][i] - getCorrection(iteration, step, names[step][i].Data()); - } - } else { - q[iteration][step + 1][i] = q[iteration][step][i] - getCorrection(iteration, step, names[step][i].Data()); - } - } - } else { - if (counter < 1) - LOGF(warning, "Something went wrong in calibration loop! File not loaded but bool set to tue"); - } // end of (cal.calibLoaded) - } // end of step - } // end of iteration - - if (counter < 1) - LOGF(info, "Output created with q-vectors at iteration %i and step %i!!!!", cal.atIteration, cal.atStep + 1); - if (isSelected) { - fillAllRegistries(cal.atIteration, cal.atStep + 1); + if (cfgFillCommonRegistry) + fillCommonRegistry(q[0], q[1], q[2], q[3], v, centrality); + + // vector of 4 + std::vector corrQxA; + std::vector corrQyA; + std::vector corrQxC; + std::vector corrQyC; + + int pb = 0; + + int nIterations = 5; + int nSteps = 5; + + for (int it = 1; it <= nIterations; it++) { + corrQxA.push_back(getCorrection(names[0][0].Data(), it, 1)); + corrQyA.push_back(getCorrection(names[0][1].Data(), it, 1)); + corrQxC.push_back(getCorrection(names[0][2].Data(), it, 1)); + corrQyC.push_back(getCorrection(names[0][3].Data(), it, 1)); + pb++; + + for (int step = 2; step <= nSteps; step++) { + corrQxA.push_back(getCorrection(names[step - 1][0].Data(), it, step)); + corrQyA.push_back(getCorrection(names[step - 1][1].Data(), it, step)); + corrQxC.push_back(getCorrection(names[step - 1][2].Data(), it, step)); + corrQyC.push_back(getCorrection(names[step - 1][3].Data(), it, step)); + pb++; + } + } + + for (int cor = 0; cor < pb; cor++) { + qRec[0] -= corrQxA[cor]; + qRec[1] -= corrQyA[cor]; + qRec[2] -= corrQxC[cor]; + qRec[3] -= corrQyC[cor]; + } + + if (isSelected && cfgFillCommonRegistry) { + fillCommonRegistry(qRec[0], qRec[1], qRec[2], qRec[3], v, centrality); registry.fill(HIST("QA/centrality_after"), centrality); + registry.get(HIST("QA/after/ZNA_Qx"))->Fill(Form("%d", runnumber), qRec[0]); + registry.get(HIST("QA/after/ZNA_Qy"))->Fill(Form("%d", runnumber), qRec[1]); + registry.get(HIST("QA/after/ZNC_Qx"))->Fill(Form("%d", runnumber), qRec[2]); + registry.get(HIST("QA/after/ZNC_Qy"))->Fill(Form("%d", runnumber), qRec[3]); } - spTableZDC(runnumber, centrality, v[0], v[1], v[2], q[cal.atIteration][cal.atStep][0], q[cal.atIteration][cal.atStep][1], q[cal.atIteration][cal.atStep][2], q[cal.atIteration][cal.atStep][3], isSelected, cal.atIteration, cal.atStep); + + spTableZDC(runnumber, centrality, v[0], v[1], v[2], qRec[0], qRec[1], qRec[2], qRec[3], isSelected, cal.atIteration, cal.atStep); + + qRec.clear(); + counter++; return; } diff --git a/PWGCF/Flow/Tasks/CMakeLists.txt b/PWGCF/Flow/Tasks/CMakeLists.txt index 34a3dafcf30..e368eef4c73 100644 --- a/PWGCF/Flow/Tasks/CMakeLists.txt +++ b/PWGCF/Flow/Tasks/CMakeLists.txt @@ -11,7 +11,7 @@ o2physics_add_dpl_workflow(flow-pt-efficiency SOURCES flowPtEfficiency.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(flow-task @@ -24,13 +24,23 @@ o2physics_add_dpl_workflow(flow-runby-run PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::GFWCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(flow-gfw-pbpb - SOURCES FlowGFWPbPb.cxx +o2physics_add_dpl_workflow(flow-mc + SOURCES flowMc.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-qa + SOURCES flowQa.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::GFWCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-gfw-task + SOURCES flowGfwTask.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(flow-zdc-task - SOURCES FlowZDCtask.cxx + SOURCES flowZdcTask.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore COMPONENT_NAME Analysis) @@ -44,13 +54,13 @@ o2physics_add_dpl_workflow(flow-pbpb-pikp PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(flow-gfw-omegaxi - SOURCES flowGFWOmegaXi.cxx +o2physics_add_dpl_workflow(flow-gfw-omega-xi + SOURCES flowGfwOmegaXi.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(flow-pid-cme - SOURCES pidcme.cxx + SOURCES flowPidCme.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore COMPONENT_NAME Analysis) @@ -58,3 +68,23 @@ o2physics_add_dpl_workflow(flow-sp SOURCES flowSP.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(resonances-gfw-flow + SOURCES resonancesGfwFlow.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-efficiency-casc + SOURCES flowEfficiencyCasc.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-ese-p-he3 + SOURCES flowEsePHe3.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-ese-task + SOURCES flowEseTask.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore + COMPONENT_NAME Analysis) diff --git a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx deleted file mode 100644 index 39cddafbd2a..00000000000 --- a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx +++ /dev/null @@ -1,663 +0,0 @@ -// 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. - -#include -#include -#include -#include -#include -#include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/AnalysisDataModel.h" - -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" - -#include "GFWPowerArray.h" -#include "GFW.h" -#include "GFWCumulant.h" -#include "GFWWeights.h" -#include "FlowContainer.h" -#include "TList.h" -#include -#include -#include - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::aod::track; -using namespace o2::aod::evsel; - -#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; - -struct FlowGFWPbPb { - - O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") - O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 3.0f, "Maximal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") - O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 70.0f, "minimum TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") - O2_DEFINE_CONFIGURABLE(cfgUseAdditionalTrackCut, bool, false, "Use additional track cut on phi") - O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables") - O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") - O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights") - O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") - O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") - O2_DEFINE_CONFIGURABLE(cfgMagnetField, std::string, "GLO/Config/GRPMagField", "CCDB path to Magnet field object") - O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") - O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") - O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2, "Custom DCA Z cut") - O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 0.2f, "Custom DCA XY cut") - O2_DEFINE_CONFIGURABLE(cfgTVXinTRD, bool, false, "Use kTVXinTRD (reject TRD triggered events)"); - O2_DEFINE_CONFIGURABLE(cfgNoTimeFrameBorder, bool, false, "kNoTimeFrameBorder"); - O2_DEFINE_CONFIGURABLE(cfgNoITSROFrameBorder, bool, false, "kNoITSROFrameBorder"); - O2_DEFINE_CONFIGURABLE(cfgNoSameBunchPileup, bool, false, "kNoSameBunchPileup"); - O2_DEFINE_CONFIGURABLE(cfgIsGoodZvtxFT0vsPV, bool, false, "kIsGoodZvtxFT0vsPV"); - O2_DEFINE_CONFIGURABLE(cfgNoCollInTimeRangeStandard, bool, false, "kNoCollInTimeRangeStandard"); - O2_DEFINE_CONFIGURABLE(cfgOccupancy, bool, false, "Bool for event selection on detector occupancy"); - O2_DEFINE_CONFIGURABLE(cfgMultCut, bool, false, "Use additional event cut on mult correlations"); - O2_DEFINE_CONFIGURABLE(ITSonly, bool, false, "ITS only tracks") - O2_DEFINE_CONFIGURABLE(Global, bool, false, "Global tracks") - - ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for histograms"}; - ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; - ConfigurableAxis axisPhiMod{"axisPhiMod", {100, 0, constants::math::PI / 9}, "fmod(#varphi,#pi/9)"}; - ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; - ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.30, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00}, "pt axis for histograms"}; - ConfigurableAxis axisPtHist{"axisPtHist", {100, 0., 10.}, "pt axis for histograms"}; - ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, "centrality axis for histograms"}; - ConfigurableAxis axisNch{"axisNch", {4000, 0, 4000}, "N_{ch}"}; - ConfigurableAxis axisCentForQA{"axisCentForQA", {100, 0, 100}, "centrality for QA"}; - ConfigurableAxis axisT0C{"axisT0C", {70, 0, 70000}, "N_{ch} (T0C)"}; - ConfigurableAxis axisT0A{"axisT0A", {200, 0, 200000}, "N_{ch} (T0A)"}; - ConfigurableAxis axisNchPV{"axisNchPV", {4000, 0, 4000}, "N_{ch} (PV)"}; - ConfigurableAxis axisDCAz{"axisDCAz", {200, -2, 2}, "DCA_{z} (cm)"}; - ConfigurableAxis axisDCAxy{"axisDCAxy", {200, -1, 1}, "DCA_{xy} (cm)"}; - - // Corrections - TH1D* mEfficiency = nullptr; - GFWWeights* mAcceptance = nullptr; - bool correctionsLoaded = false; - - // Connect to ccdb - Service ccdb; - Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; - Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - - // Define output - OutputObj fFC{FlowContainer("FlowContainer")}; - OutputObj fWeights{GFWWeights("weights")}; - HistogramRegistry registry{"registry"}; - - // define global variables - GFW* fGFW = new GFW(); // GFW class used from main src - std::vector corrconfigs; - TRandom3* fRndm = new TRandom3(0); - TAxis* fPtAxis; - std::vector>> BootstrapArray; // TProfile is a shared pointer - - enum ExtraProfile { - - // here are TProfiles for vn-pt correlations that are not implemented in GFW - kc22, - kc24, - kc26, - kc28, - kc22etagap, - kc32etagap, - kc34, - - // Count the total number of enum - kCount_ExtraProfile - }; - - enum eventprogress { - kFILTERED, - kSEL8, - kOCCUPANCY, - kTVXINTRD, - kNOTIMEFRAMEBORDER, - kNOITSROFRAMEBORDER, - kNOPSAMEBUNCHPILEUP, - kISGOODZVTXFT0VSPV, - kNOCOLLINTIMERANGESTANDART, - kAFTERMULTCUTS, - kCENTRALITY, - kNOOFEVENTSTEPS - }; - - // Additional Event selection cuts - Copy from flowGenericFramework.cxx - TF1* fPhiCutLow = nullptr; - TF1* fPhiCutHigh = nullptr; - TF1* fMultPVCutLow = nullptr; - TF1* fMultPVCutHigh = nullptr; - TF1* fMultCutLow = nullptr; - TF1* fMultCutHigh = nullptr; - TF1* fMultMultPVCut = nullptr; - TF1* fT0AV0AMean = nullptr; - TF1* fT0AV0ASigma = nullptr; - - void init(InitContext const&) // Initialization - { - ccdb->setURL(url.value); - ccdb->setCaching(true); - ccdb->setCreatedNotAfter(nolaterthan.value); - - // Add some output objects to the histogram registry - registry.add("hEventCount", "Number of Events;; No. of Events", {HistType::kTH1D, {{kNOOFEVENTSTEPS, -0.5, +kNOOFEVENTSTEPS - 0.5}}}); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kFILTERED + 1, "Filtered events"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kSEL8 + 1, "Sel8"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kOCCUPANCY + 1, "Occupancy"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kTVXINTRD + 1, "kTVXinTRD"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kNOTIMEFRAMEBORDER + 1, "kNoTimeFrameBorder"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kNOITSROFRAMEBORDER + 1, "kNoITSROFrameBorder"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kNOPSAMEBUNCHPILEUP + 1, "kNoSameBunchPileup"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kISGOODZVTXFT0VSPV + 1, "kIsGoodZvtxFT0vsPV"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kNOCOLLINTIMERANGESTANDART + 1, "kNoCollInTimeRangeStandard"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kAFTERMULTCUTS + 1, "After Mult cuts"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kCENTRALITY + 1, "Centrality"); - registry.add("hPhi", "#phi distribution", {HistType::kTH1D, {axisPhi}}); - registry.add("hPhiWeighted", "corrected #phi distribution", {HistType::kTH1D, {axisPhi}}); - registry.add("hEta", "", {HistType::kTH1D, {axisEta}}); - registry.add("hVtxZ", "Vexter Z distribution", {HistType::kTH1D, {axisVertex}}); - registry.add("hMult", "Multiplicity distribution", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); - registry.add("hCent", "Centrality distribution", {HistType::kTH1D, {{90, 0, 90}}}); - registry.add("cent_vs_Nch", ";Centrality (%); M (|#eta| < 0.8);", {HistType::kTH2D, {axisCentrality, axisNch}}); - - // Before cuts - registry.add("BeforeCut_globalTracks_centT0C", "before cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); - registry.add("BeforeCut_PVTracks_centT0C", "before cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNchPV}}); - registry.add("BeforeCut_globalTracks_PVTracks", "before cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNchPV, axisNch}}); - registry.add("BeforeCut_globalTracks_multT0A", "before cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); - registry.add("BeforeCut_globalTracks_multV0A", "before cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); - registry.add("BeforeCut_multV0A_multT0A", "before cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); - registry.add("BeforeCut_multT0C_centT0C", "before cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); - - // After cuts - registry.add("globalTracks_centT0C_Aft", "after cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); - registry.add("PVTracks_centT0C_Aft", "after cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNchPV}}); - registry.add("globalTracks_PVTracks_Aft", "after cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNchPV, axisNch}}); - registry.add("globalTracks_multT0A_Aft", "after cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); - registry.add("globalTracks_multV0A_Aft", "after cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); - registry.add("multV0A_multT0A_Aft", "after cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); - registry.add("multT0C_centT0C_Aft", "after cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); - - // Track types - registry.add("Global_Tracks", "Global Tracks;Centrality FT0C;No. of Events", kTH1F, {axisCentrality}); - registry.add("Events_per_Centrality_Bin", "Events_per_Centrality_Bin;Centrality FT0C;No. of Events", kTH1F, {axisCentrality}); - registry.add("Global_Tracks_Nch_vs_Cent", "Global Tracks;Centrality (%); M (|#eta| < 0.8);", {HistType::kTH2D, {axisCentrality, axisNch}}); - registry.add("ITSonly", "ITS only;Centrality FT0C;Nch", kTH1F, {axisCentrality}); - registry.add("ITSOnly_Tracks_Nch_vs_Cent", "ITSOnly Tracks;Centrality (%); M (|#eta| < 0.8);", {HistType::kTH2D, {axisCentrality, axisNch}}); - - // Track QA - registry.add("hPt", "p_{T} distribution before cut", {HistType::kTH1D, {axisPtHist}}); - registry.add("hPtRef", "p_{T} distribution after cut", {HistType::kTH1D, {axisPtHist}}); - registry.add("pt_phi_bef", "before cut;p_{T};#phi_{modn}", {HistType::kTH2D, {axisPt, axisPhiMod}}); - registry.add("pt_phi_aft", "after cut;p_{T};#phi_{modn}", {HistType::kTH2D, {axisPt, axisPhiMod}}); - registry.add("hChi2prTPCcls", "#chi^{2}/cluster for the TPC track segment", {HistType::kTH1D, {{100, 0., 5.}}}); - registry.add("hnTPCClu", "Number of found TPC clusters", {HistType::kTH1D, {{100, 40, 180}}}); - registry.add("hnTPCCrossedRow", "Number of crossed TPC Rows", {HistType::kTH1D, {{100, 40, 180}}}); - registry.add("hDCAz", "DCAz after cuts", {HistType::kTH1D, {{100, -3, 3}}}); - registry.add("hDCAxy", "DCAxy after cuts; DCAxy (cm); Pt", {HistType::kTH2D, {{50, -1, 1}, {50, 0, 10}}}); - - // additional Output histograms - registry.add("c22", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisCentrality}}); - registry.add("c24", ";Centrality (%) ; C_{2}{4}", {HistType::kTProfile, {axisCentrality}}); - registry.add("c26", ";Centrality (%) ; C_{2}{6}", {HistType::kTProfile, {axisCentrality}}); - registry.add("c28", ";Centrality (%) ; C_{2}{8}", {HistType::kTProfile, {axisCentrality}}); - registry.add("c22etagap", ";Centrality (%) ; C_{2}{2} (|#eta| < 0.8) ", {HistType::kTProfile, {axisCentrality}}); - registry.add("c32etagap", ";Centrality (%) ; C_{3}{2} (|#eta| < 0.8) ", {HistType::kTProfile, {axisCentrality}}); - registry.add("c34", ";Centrality (%) ; C_{3}{4} ", {HistType::kTProfile, {axisCentrality}}); - - // initial array - BootstrapArray.resize(cfgNbootstrap); - for (int i = 0; i < cfgNbootstrap; i++) { - BootstrapArray[i].resize(kCount_ExtraProfile); - } - - for (int i = 0; i < cfgNbootstrap; i++) { - BootstrapArray[i][kc22] = registry.add(Form("BootstrapContainer_%d/c22", i), ";Centrality (%) ; C_{2}{2}", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kc24] = registry.add(Form("BootstrapContainer_%d/c24", i), ";Centrality (%) ; C_{2}{4}", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kc26] = registry.add(Form("BootstrapContainer_%d/c26", i), ";Centrality (%) ; C_{2}{6}", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kc28] = registry.add(Form("BootstrapContainer_%d/c28", i), ";Centrality (%) ; C_{2}{8}", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kc22etagap] = registry.add(Form("BootstrapContainer_%d/c22etagap", i), ";Centrality (%) ; C_{2}{2} (|#eta| < 0.8)", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kc32etagap] = registry.add(Form("BootstrapContainer_%d/c32etagap", i), ";Centrality (%) ; C_{3}{2} (|#eta| < 0.8)", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kc34] = registry.add(Form("BootstrapContainer_%d/c34", i), ";Centrality (%) ; C_{3}{4}", {HistType::kTProfile, {axisCentrality}}); - } - - o2::framework::AxisSpec axis = axisPt; - int nPtBins = axis.binEdges.size() - 1; - double* PtBins = &(axis.binEdges)[0]; - fPtAxis = new TAxis(nPtBins, PtBins); - - if (cfgOutputNUAWeights) { - fWeights->SetPtBins(nPtBins, PtBins); - fWeights->Init(true, false); - } - - // add in FlowContainer to Get boostrap sample automatically - TObjArray* oba = new TObjArray(); - fFC->SetXAxis(fPtAxis); - fFC->SetName("FlowContainer"); - fFC->Initialize(oba, axisCentrality, cfgNbootstrap); - delete oba; - - fGFW->AddRegion("full", -0.8, 0.8, 1, 1); // eta region -0.8 to 0.8 - fGFW->AddRegion("refN10", -0.8, -0.5, 1, 1); - fGFW->AddRegion("refP10", 0.5, 0.8, 1, 1); - - corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 -2 -2}", "ChFull24", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 2 -2 -2 -2}", "ChFull26", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 2 2 -2 -2 -2 -2}", "ChFull28", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {3} refP10 {-3}", "Ch10Gap32", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {3 3 -3 -3}", "ChFull34", kFALSE)); - fGFW->CreateRegions(); // finalize the initialization - - if (cfgUseAdditionalEventCut) { - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - - fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - - fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); - fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); - fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); - fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); - } - - if (cfgUseAdditionalTrackCut) { - fPhiCutLow = new TF1("fPhiCutLow", "0.06/x+pi/18.0-0.06", 0, 100); - fPhiCutHigh = new TF1("fPhiCutHigh", "0.1/x+pi/18.0+0.06", 0, 100); - } - - } // end of Initialization - - template - void FillProfile(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const double& cent) - { - double dnx, val; - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; - if (!corrconf.pTDif) { - val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; - if (TMath::Abs(val) < 1) - registry.fill(tarName, cent, val, dnx); - return; - } - return; - } - - void FillProfile(const GFW::CorrConfig& corrconf, std::shared_ptr tarName, const double& cent) - { - double dnx, val; - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; - if (!corrconf.pTDif) { - val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; - if (TMath::Abs(val) < 1) { - tarName->Fill(cent, val, dnx); - } - return; - } - return; - } - - void FillFC(const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) - { - double dnx, val; - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; - if (!corrconf.pTDif) { - val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; - if (TMath::Abs(val) < 1) - fFC->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); - return; - } - for (Int_t i = 1; i <= fPtAxis->GetNbins(); i++) { - dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); - if (dnx == 0) - continue; - val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; - if (TMath::Abs(val) < 1) - fFC->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); - } - return; - } - - void loadCorrections(uint64_t timestamp) - { - if (correctionsLoaded) - return; - if (cfgAcceptance.value.empty() == false) { - mAcceptance = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - if (mAcceptance) - LOGF(info, "Loaded acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); - else - LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); - } - if (cfgEfficiency.value.empty() == false) { - mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); - if (mEfficiency == nullptr) { - LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str()); - } - LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency); - } - correctionsLoaded = true; - } - - bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz) - { - float eff = 1.; - if (mEfficiency) - eff = mEfficiency->GetBinContent(mEfficiency->FindBin(pt)); - else - eff = 1.0; - if (eff == 0) - return false; - weight_nue = 1. / eff; - if (mAcceptance) - weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); - else - weight_nua = 1; - return true; - } - - template - bool eventSelected(o2::aod::mult::MultNTracksPV, TCollision collision, const int multTrk, const float centrality) - { - if (cfgTVXinTRD) { - if (collision.alias_bit(kTVXinTRD)) { - // TRD triggered - return false; - } - registry.fill(HIST("hEventCount"), kTVXINTRD); - } - if (cfgNoTimeFrameBorder) { - if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - // reject collisions close to Time Frame borders - // https://its.cern.ch/jira/browse/O2-4623 - return false; - } - registry.fill(HIST("hEventCount"), kNOTIMEFRAMEBORDER); - } - if (cfgNoITSROFrameBorder) { - if (!collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - // reject events affected by the ITS ROF border - // https://its.cern.ch/jira/browse/O2-4309 - return false; - } - registry.fill(HIST("hEventCount"), kNOITSROFRAMEBORDER); - } - if (cfgNoSameBunchPileup) { - if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - // rejects collisions which are associated with the same "found-by-T0" bunch crossing - // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof - return false; - } - registry.fill(HIST("hEventCount"), kNOPSAMEBUNCHPILEUP); - } - if (cfgIsGoodZvtxFT0vsPV) { - if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference - // use this cut at low multiplicities with caution - return false; - } - registry.fill(HIST("hEventCount"), kISGOODZVTXFT0VSPV); - } - if (cfgNoCollInTimeRangeStandard) { - if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - // no collisions in specified time range - return false; - } - registry.fill(HIST("hEventCount"), kNOCOLLINTIMERANGESTANDART); - } - - float vtxz = -999; - if (collision.numContrib() > 1) { - vtxz = collision.posZ(); - float zRes = TMath::Sqrt(collision.covZZ()); - if (zRes > 0.25 && collision.numContrib() < 20) - vtxz = -999; - } - - auto multNTracksPV = collision.multNTracksPV(); - - if (abs(vtxz) > cfgCutVertex) - return false; - - if (cfgMultCut) { - if (multNTracksPV < fMultPVCutLow->Eval(centrality)) - return false; - if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) - return false; - if (multTrk < fMultCutLow->Eval(centrality)) - return false; - if (multTrk > fMultCutHigh->Eval(centrality)) - return false; - registry.fill(HIST("hEventCount"), kAFTERMULTCUTS); - } - - // V0A T0A 5 sigma cut - if (abs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > 5 * fT0AV0ASigma->Eval(collision.multFT0A())) - return false; - - return true; - } - - int getMagneticField(uint64_t timestamp) - { - static o2::parameters::GRPMagField* grpo = nullptr; - if (grpo == nullptr) { - grpo = ccdb->getForTimeStamp(cfgMagnetField, timestamp); - if (grpo == nullptr) { - LOGF(fatal, "GRP object not found in %s for timestamp %llu", cfgMagnetField.value.c_str(), timestamp); - return 0; - } - LOGF(info, "Retrieved GRP from %s for timestamp %llu with magnetic field of %d kG", cfgMagnetField.value.c_str(), timestamp, grpo->getNominalL3Field()); - } - return grpo->getNominalL3Field(); - } - - template - bool trackSelected(TTrack track, const int field) - { - double phimodn = track.phi(); - if (field < 0) // for negative polarity field - phimodn = TMath::TwoPi() - phimodn; - if (track.sign() < 0) // for negative charge - phimodn = TMath::TwoPi() - phimodn; - if (phimodn < 0) - LOGF(warning, "phi < 0: %g", phimodn); - - phimodn += TMath::Pi() / 18.0; // to center gap in the middle - phimodn = fmod(phimodn, TMath::Pi() / 9.0); - registry.fill(HIST("pt_phi_bef"), track.pt(), phimodn); - if (phimodn < fPhiCutHigh->Eval(track.pt()) && phimodn > fPhiCutLow->Eval(track.pt())) - return false; // reject track - registry.fill(HIST("pt_phi_aft"), track.pt(), phimodn); - return true; - } - - // Apply process filters - Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; - Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy); - - using Colls = soa::Filtered>; // collisions filter - using aodTracks = soa::Filtered>; // tracks filter - - void process(Colls::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks) - { - registry.fill(HIST("hEventCount"), kFILTERED); - if (!collision.sel8()) - return; - - int Ntot = tracks.size(); - if (Ntot < 1) - return; - - // fill event QA before cuts - registry.fill(HIST("BeforeCut_globalTracks_centT0C"), collision.centFT0C(), tracks.size()); - registry.fill(HIST("BeforeCut_PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV()); - registry.fill(HIST("BeforeCut_globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size()); - registry.fill(HIST("BeforeCut_globalTracks_multT0A"), collision.multFT0A(), tracks.size()); - registry.fill(HIST("BeforeCut_globalTracks_multV0A"), collision.multFV0A(), tracks.size()); - registry.fill(HIST("BeforeCut_multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); - registry.fill(HIST("BeforeCut_multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); - registry.fill(HIST("hEventCount"), kSEL8); - - const auto centrality = collision.centFT0C(); - - if (cfgOccupancy) { - int occupancy = collision.trackOccupancyInTimeRange(); - if (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh) - return; - registry.fill(HIST("hEventCount"), kOCCUPANCY); - } - - if (cfgUseAdditionalEventCut && !eventSelected(o2::aod::mult::MultNTracksPV(), collision, tracks.size(), centrality)) { - return; - } - - if (centrality < 0 || centrality >= 70.) - return; - - float vtxz = collision.posZ(); - float l_Random = fRndm->Rndm(); - registry.fill(HIST("hVtxZ"), vtxz); - registry.fill(HIST("hMult"), Ntot); - registry.fill(HIST("hCent"), centrality); - registry.fill(HIST("cent_vs_Nch"), centrality, Ntot); - fGFW->Clear(); - - auto bc = collision.bc_as(); - loadCorrections(bc.timestamp()); - registry.fill(HIST("hEventCount"), kCENTRALITY); - - // fill event QA after cuts - registry.fill(HIST("globalTracks_centT0C_Aft"), collision.centFT0C(), tracks.size()); - registry.fill(HIST("PVTracks_centT0C_Aft"), collision.centFT0C(), collision.multNTracksPV()); - registry.fill(HIST("globalTracks_PVTracks_Aft"), collision.multNTracksPV(), tracks.size()); - registry.fill(HIST("globalTracks_multT0A_Aft"), collision.multFT0A(), tracks.size()); - registry.fill(HIST("globalTracks_multV0A_Aft"), collision.multFV0A(), tracks.size()); - registry.fill(HIST("multV0A_multT0A_Aft"), collision.multFT0A(), collision.multFV0A()); - registry.fill(HIST("multT0C_centT0C_Aft"), collision.centFT0C(), collision.multFT0C()); - - // track weights - float weff = 1, wacc = 1; - int Magnetfield = 0; - - if (cfgUseAdditionalTrackCut) { - // magnet field dependence cut - Magnetfield = getMagneticField(bc.timestamp()); - } - - // track loop - int globaltracks_nch{0}; - int itstracks_nch{0}; - - for (auto& track : tracks) { - - if (track.tpcNClsFound() < cfgCutTPCclu) - continue; - if (cfgUseAdditionalTrackCut && !trackSelected(track, Magnetfield)) - continue; - if (cfgOutputNUAWeights) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); - if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) - continue; - - bool WithinPtRef = (cfgCutPtMin < track.pt()) && (track.pt() < cfgCutPtMax); // within RF pT range - registry.fill(HIST("hPt"), track.pt()); - - if (WithinPtRef) { - registry.fill(HIST("hPhi"), track.phi()); - registry.fill(HIST("hPhiWeighted"), track.phi(), wacc); - registry.fill(HIST("hEta"), track.eta()); - registry.fill(HIST("hPtRef"), track.pt()); - registry.fill(HIST("hChi2prTPCcls"), track.tpcChi2NCl()); - registry.fill(HIST("hnTPCClu"), track.tpcNClsFound()); - registry.fill(HIST("hnTPCCrossedRow"), track.tpcNClsCrossedRows()); - registry.fill(HIST("hDCAz"), track.dcaZ()); - registry.fill(HIST("hDCAxy"), track.dcaXY(), track.pt()); - } - - globaltracks_nch++; - itstracks_nch++; - if (Global == true) { - registry.fill(HIST("Global_Tracks"), collision.centFT0C()); - if (WithinPtRef) - fGFW->Fill(track.eta(), 1, track.phi(), wacc * weff, 1); - } - - if (track.hasITS() && ITSonly == true) { - registry.fill(HIST("ITSonly"), collision.centFT0C()); - if (WithinPtRef) - fGFW->Fill(track.eta(), 1, track.phi(), wacc * weff, 1); - } - - } // End of track loop - - registry.fill(HIST("Events_per_Centrality_Bin"), centrality); - registry.fill(HIST("Global_Tracks_Nch_vs_Cent"), centrality, globaltracks_nch); - registry.fill(HIST("ITSOnly_Tracks_Nch_vs_Cent"), centrality, itstracks_nch); - - // Filling c22 with ROOT TProfile - FillProfile(corrconfigs.at(0), HIST("c22"), centrality); - FillProfile(corrconfigs.at(1), HIST("c24"), centrality); - FillProfile(corrconfigs.at(2), HIST("c26"), centrality); - FillProfile(corrconfigs.at(3), HIST("c28"), centrality); - FillProfile(corrconfigs.at(4), HIST("c22etagap"), centrality); - FillProfile(corrconfigs.at(5), HIST("c32etagap"), centrality); - FillProfile(corrconfigs.at(6), HIST("c34"), centrality); - - // Filling Bootstrap Samples - int SampleIndex = static_cast(cfgNbootstrap * l_Random); - FillProfile(corrconfigs.at(0), BootstrapArray[SampleIndex][kc22], centrality); - FillProfile(corrconfigs.at(1), BootstrapArray[SampleIndex][kc24], centrality); - FillProfile(corrconfigs.at(2), BootstrapArray[SampleIndex][kc26], centrality); - FillProfile(corrconfigs.at(3), BootstrapArray[SampleIndex][kc28], centrality); - FillProfile(corrconfigs.at(4), BootstrapArray[SampleIndex][kc22etagap], centrality); - FillProfile(corrconfigs.at(5), BootstrapArray[SampleIndex][kc32etagap], centrality); - FillProfile(corrconfigs.at(6), BootstrapArray[SampleIndex][kc34], centrality); - - // Filling Flow Container - for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { - FillFC(corrconfigs.at(l_ind), centrality, l_Random); - } - - } // End of process -}; // End of struct - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGCF/Flow/Tasks/FlowZDCtask.cxx b/PWGCF/Flow/Tasks/FlowZDCtask.cxx deleted file mode 100644 index d4255c156f3..00000000000 --- a/PWGCF/Flow/Tasks/FlowZDCtask.cxx +++ /dev/null @@ -1,410 +0,0 @@ -// 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. - -#include -#include -#include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/HistogramRegistry.h" - -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" - -#include "TList.h" -#include -#include -#include -#include -#include -#include -#include -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::aod::mult; -using ColEvSels = soa::Join; -using aodCollisions = soa::Filtered>; -using aodTracks = soa::Filtered>; -using BCsRun3 = soa::Join; -using aodZDCs = soa::Join; - -#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; - -struct FlowZDCtask { - SliceCache cache; - - O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") - O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 3.0f, "Maximal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.9f, "Eta range for tracks") // changed from .8 bc zdc is at eta 8.78 - O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables") - O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") - - Configurable nBinsPt{"nBinsPt", 100, "N bins in pT histo"}; - Configurable eventSelection{"eventSelection", 1, "event selection"}; - Configurable MaxZP{"MaxZP", 3099.5, "Max ZP signal"}; - Configurable vtxCut{"vtxCut", 10.0, "Z vertex cut"}; - Configurable etaCut{"etaCut", 0.8, "Eta cut"}; - Configurable etaGap{"etaGap", 0.5, "Eta gap"}; - Configurable minPt{"minPt", 0.2, "Minimum pt"}; - Configurable maxPt{"maxPt", 20.0, "Maximum pt"}; - Configurable MaxZEM{"MaxZEM", 3099.5, "Max ZEM signal"}; - // for ZDC info and analysis - Configurable nBinsADC{"nBinsADC", 1000, "nbinsADC"}; - Configurable nBinsAmp{"nBinsAmp", 1025, "nbinsAmp"}; - Configurable MaxZN{"MaxZN", 4099.5, "Max ZN signal"}; - Configurable acceptnace_ZNA{"acceptnace_ZNA", 0.92, "ZNA acceptance factor"}; - Configurable acceptnace_ZNC{"acceptnace_ZNC", 0.90, "ZNC acceptance factor"}; - Configurable acceptnace_ZPA{"acceptnace_ZPA", 0.52, "ZPA acceptance factor"}; - Configurable acceptnace_ZPC{"acceptnace_ZPC", 0.50, "ZPC acceptance factor"}; - - ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for histograms"}; - ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; - ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; - ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.30, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00}, "pt axis for histograms"}; - ConfigurableAxis axisMultiplicity{"axisMultiplicity", {2500, 0, 2500}, "centrality axis for histograms"}; - ConfigurableAxis axisEnergy{"axisEnergy", {100, 0, 700}, "energy axis for zdc histos"}; - Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; - Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); - Partition tracksIUWithTPC = (aod::track::tpcNClsFindable > (uint8_t)0); - - TComplex qTPC; // init q TPC - TComplex qZNA{0, 0}; // init qZNA - TComplex qZNC{0, 0}; // init qZNC - - // Begin Histogram Registry - - HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - OutputObj Q2_real_mean{TProfile("Q2_real_mean", "q2 real vs centrality", 10, 0, 100.)}; - OutputObj Q2_imag_mean{TProfile("Q2_imag_mean", "q2 imag vs centrality", 10, 0, 100.)}; - OutputObj Q2_after{TProfile("Q2_after", "q2 recentered vs centrality", 10, 0, 100.)}; - OutputObj Q2before{TProfile("Q2_imag_mean", "q2 re vs imag", 10, 0, 100.)}; - OutputObj Q2_ZNA_real{TProfile("Q2_ZNA_real", "q2_ZNA real vs centrality", 10, 0, 100.)}; - OutputObj Q2_ZNA_imag{TProfile("Q2_ZNA_imag", "q2_ZNA imag vs centrality", 10, 0, 100.)}; - OutputObj Q2_ZNC_real{TProfile("Q2_ZNC_real", "q2_ZNC real vs centrality", 10, 0, 100.)}; - OutputObj Q2_ZNC_imag{TProfile("Q2_ZNC_imag", "q2_ZNC imag vs centrality", 10, 0, 100.)}; - OutputObj avgQ2TPCRe{TProfile("avgQ2TPCRe", "Average Q2 Real part vs Centrality", 10, 0, 100)}; - OutputObj avgQ2TPCIm{TProfile("avgQ2TPCIm", "Average Q2 Imaginary part vs Centrality", 10, 0, 100)}; - OutputObj ZDC_ZEM_Energy{TProfile("ZDC_ZEM_Energy", "ZDC vs ZEM Energy", 10, 0, 1000)}; - OutputObj pCosPsiDifferences{TProfile("pCosPsiDifferences", "Differences in cos(psi) vs Centrality;Centrality;Mean cos(psi) Difference", 200, 0, 100, -1, 1)}; - OutputObj pSinPsiDifferences{TProfile("pSinPsiDifferences", "Differences in sin(psi) vs Centrality;Centrality;Mean sin(psi) Difference", 200, 0, 100, -1, 1)}; - OutputObj pZNvsFT0MAmp{TProfile("pZNvsFT0MAmp", "ZN Energy vs FT0M Amplitude", 1025, 0, 1e7, 0, 500)}; - OutputObj pZPvsFT0MAmp{TProfile("pZPvsFT0MAmp", "ZP Energy vs FT0M Amplitude", 1025, 0, 1e7, 0, 500)}; - OutputObj pZNvsFT0Ccent{TProfile("pZNvsFT0Ccent", "ZN Energy vs FT0C Centrality", 100, 0, 100, 0, 500)}; - OutputObj pZPvsFT0Ccent{TProfile("pZPvsFT0Ccent", "ZP Energy vs FT0C Centrality", 100, 0, 100, 0, 500)}; - OutputObj pZNratiovscent{TProfile("pZNratiovscent", "Ratio ZNC/ZNA vs FT0C Centrality", 100, 0, 100, 0, 5)}; - OutputObj pZPratiovscent{TProfile("pZPratiovscent", "Ratio ZPC/ZPA vs FT0C Centrality", 100, 0, 100, 0, 5)}; - - double sumCosPsiDiff = 0.0; // Sum of cos(psiZNC) - cos(psiZNA) - int countEvents = 0; // Count of processed events - - void init(InitContext const&) - { - // define axes - const AxisSpec axisEta{30, -1.5, +1.5, "#eta"}; - const AxisSpec axispt{100, 0, 2, "#pt"}; - - const AxisSpec axisPt{nBinsPt, 0, 10, "p_{T} (GeV/c)"}; - const AxisSpec axisCounter{1, 0, +1, ""}; - const AxisSpec axisPhi{100, 0, 2 * TMath::Pi(), "#phi"}; - const AxisSpec axisQ{100, -1, 1, "Q"}; - const AxisSpec axisZNA{100, 0, 200, "energy"}; - const AxisSpec axisQZNA{100, -1, 1, "Q"}; - const AxisSpec axisREQ{100, -1, 1, "real Q"}; - const AxisSpec axisIMQ{100, -1, 1, "imag Q"}; - - AxisSpec axisVtxcounts{2, -0.5f, 1.5f, "Vtx info (0=no, 1=yes)"}; - AxisSpec axisZvert{120, -30.f, 30.f, "Vtx z (cm)"}; - AxisSpec axisCent{8, 0.f, 105.f, "centrality"}; - AxisSpec axisMult{2500, 0, 2500.0f, "multiplicity"}; - AxisSpec axisMultTPC{1000, -0.5f, 1999.5f, "TPCmultiplicity"}; - AxisSpec axisCentBins{{0, 5., 10., 20., 30., 40., 50., 60., 70., 80.}, "centrality percentile"}; - AxisSpec axisPtBins{{0., 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.25, 2.5, 2.75, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10., 13., 16., 20.}, "p_{T} (GeV/c)"}; - - // create histograms - histos.add("etaHistogram", "etaHistogram", kTH1F, {axisEta}); - histos.add("ptHistogram", "ptHistogram", kTH1F, {axisPt}); - - histos.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); - histos.add("centHistogram", "centHistogram", kTH1F, {axisCent}); - histos.add("multHistogram", "multHistogram", kTH1F, {axisMultiplicity}); - histos.add("multvsCent", "centrality vs multiplicity", kTH2F, {axisCent, axisMult}); - histos.add("phiHistogram", "phiHistogram", kTH1F, {axisPhi}); - histos.add("TPCmultiplicity", "TPCmultiplicity", kTH1F, {axisMultTPC}); - - histos.add("REqHistogram", "REqHistogram", kTH1F, {axisQ}); - histos.add("IMqHistogram", "IMqHistogram", kTH1F, {axisQ}); - - histos.add("REqHistogramZNA", "REqHistogramZNA", kTH1F, {axisQZNA}); - histos.add("IMqHistogramZNA", "IMqHistogramZNA", kTH1F, {axisQZNA}); - - histos.add("REqHistogramZNC", "REqHistogramZNC", kTH1F, {axisQZNA}); - histos.add("IMqHistogramZNC", "IMqHistogramZNC", kTH1F, {axisQZNA}); - - histos.add("EnergyZNA", "ZNA Sector Energy", kTH1F, {axisEnergy}); - histos.add("EnergyZNC", "ZNC Sector Energy", kTH1F, {axisEnergy}); - histos.add("hCentFT0C", "FT0C Centrality Distribution", kTH1F, {{100, 0, 105}}); - histos.add("hZNvsFT0Ccent", - "ZN Energy vs FT0C Centrality;Centrality [%];ZN Energy [TeV]", - kTH2F, - {AxisSpec{100, 0, 100, "Centrality [%]"}, AxisSpec{100, 0, 500, "ZN Energy [TeV]"}}); - - histos.add("hZPvsFT0Ccent", - "ZP Energy vs FT0C Centrality;Centrality [%];ZP Energy [TeV]", - kTH2F, - {AxisSpec{100, 0, 100, "Centrality [%]"}, AxisSpec{100, 0, 500, "ZP Energy [TeV]"}}); - // for q vector recentering - histos.add("revsimag", "revsimag", kTH2F, {axisREQ, axisIMQ}); - - if (doprocessZdcCollAssoc) { // Check if the process function for ZDCCollAssoc is enabled - histos.add("ZNAcoll", "ZNAcoll; ZNA amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, MaxZN}}}); - histos.add("ZNCcoll", "ZNCcoll; ZNC amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, MaxZN}}}); - histos.add("ZEM1coll", "ZEM1coll; ZEM1 amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, MaxZEM}}}); - histos.add("ZEM2coll", "ZEM2coll; ZEM2 amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, MaxZEM}}}); - histos.add("ZNvsZEMcoll", "ZNvsZEMcoll; ZEM; ZNA+ZNC", {HistType::kTH2F, {{{nBinsAmp, -0.5, MaxZEM}, {nBinsAmp, -0.5, 2. * MaxZN}}}}); - histos.add("ZNAvsZNCcoll", "ZNAvsZNCcoll; ZNC; ZNA", {HistType::kTH2F, {{{nBinsAmp, -0.5, MaxZN}, {nBinsAmp, -0.5, MaxZN}}}}); - - histos.add("RealQHistogramZNA", "RealQHistogramZNA", kTH1F, {axisQZNA}); - histos.add("ImagQHistogramZNA", "ImagQHistogramZNA", kTH1F, {axisQZNA}); - histos.add("RealQHistogramZNC", "RealQHistogramZNC", kTH1F, {axisQZNA}); - histos.add("ImagQHistogramZNC", "ImagQHistogramZNC", kTH1F, {axisQZNA}); - - histos.add("Acorrelations", "Acorrelations", kTH2F, {{axisQZNA}, {axisQZNA}}); - histos.add("SPAngleZNA", "Spectator Plane Angle ZNA;Angle (radians);Entries", {HistType::kTH1F, {{100, -TMath::Pi(), TMath::Pi()}}}); - histos.add("SPAngleZNC", "Spectator Plane Angle ZNC;Angle (radians);Entries", {HistType::kTH1F, {{100, -TMath::Pi(), TMath::Pi()}}}); - - histos.add("RunningAverageCosPsiDiff", "Running Average of cos(psi) Differences;Running Average;Entries", {HistType::kTH1F, {{100, -1, 1}}}); - - histos.add("CosPsiDifferences", "Differences in cos(psi);cos(psiZNC) - cos(psiZNA);Entries", {HistType::kTH1F, {{100, -2, 2}}}); - histos.add("hSinDifferences", "Differences in sin(psi);sin(psiZNC) - sin(psiZNA);Entries", {HistType::kTH1F, {{100, -2, 2}}}); - histos.add("CosPsiDifferencesAvg", "Differences in cos(psi);cos(psiZNC) - cos(psiZNA);Entries", {HistType::kTH2F, {{axisCent}, {100, -2, 2}}}); - histos.add("ZDC_energy_vs_ZEM", "ZDCvsZEM; ZEM; ZNA+ZNC+ZPA+ZPC", {HistType::kTH2F, {{{nBinsAmp, -0.5, MaxZEM}, {nBinsAmp, -0.5, 2. * MaxZN}}}}); - // common energies information for ZDC - histos.add("ZNCenergy", "ZN energy side c", kTH1F, {axisEnergy}); - histos.add("ZNAenergy", "ZN energy side a", kTH1F, {axisEnergy}); - histos.add("ZPCenergy", "ZP energy side c", kTH1F, {axisEnergy}); - histos.add("ZPAenergy", "ZP energy side a", kTH1F, {axisEnergy}); - histos.add("ZNenergy", "common zn (a + c sides) energy", kTH1F, {axisEnergy}); - histos.add("ZPenergy", "common zp energy (a + c sides)", kTH1F, {axisEnergy}); - histos.add("hFT0CAmp", ";Amplitude;counts", kTH1F, {{nBinsAmp, 0, 1e7}}); - histos.add("hFT0AAmp", ";Amplitude;counts", kTH1F, {{nBinsAmp, 0, 1e7}}); - histos.add("hFT0MAmp", ";Amplitude;counts", kTH1F, {{nBinsAmp, 0, 1e7}}); - histos.add("hMultT0A", ";Amplitude;counts", kTH1F, {{nBinsAmp, 0, 250000}}); - histos.add("hMultT0C", ";Amplitude;counts", kTH1F, {{nBinsAmp, 0, 250000}}); - histos.add("hMultT0M", ";Amplitude;counts", kTH1F, {{nBinsAmp, 0, 250000}}); - } - } - - void processQVector(aodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks, BCsRun3 const& /*bcs*/, aod::Zdcs const& /*zdcsData*/, aod::ZDCMults const& /*zdcMults*/) - { - histos.fill(HIST("eventCounter"), 0.5); - histos.fill(HIST("centHistogram"), collision.centFT0C()); - const auto& tracksGrouped = tracksIUWithTPC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - const int multTPC = tracksGrouped.size(); - const auto cent = collision.centFT0C(); - int Ntot = tracks.size(); - - // this is the q vector for the TPC data. it is a complex function - double qTPC_real = 0.0; // Initialize qTPC_real - double qTPC_im = 0.0; // init qTPC_imaginary - - Int_t multTrk = tracks.size(); // Tracks are already filtered with GlobalTrack || GlobalTrackSDD - - if (cent < 0.0 && cent > 70) - return; - TComplex qTPC(0, 0); // Starting with a q-vector of zero - - for (auto& track : tracks) { - double phi = track.phi(); - - histos.fill(HIST("etaHistogram"), track.eta()); - histos.fill(HIST("phiHistogram"), track.phi()); - histos.fill(HIST("ptHistogram"), track.pt()); - - qTPC += TComplex(TMath::Cos(2.0 * phi), TMath::Sin(2.0 * phi)); - - histos.fill(HIST("multvsCent"), cent, Ntot); - - } // end track loop - - qTPC_real = qTPC.Re() / Ntot; // normalize these vectors by the total number of particles - qTPC_im = qTPC.Im() / Ntot; - - histos.fill(HIST("REqHistogram"), qTPC_real); - histos.fill(HIST("IMqHistogram"), qTPC_im); - - histos.fill(HIST("multHistogram"), multTrk); - histos.fill(HIST("TPCmultiplicity"), multTPC); - - histos.fill(HIST("revsimag"), qTPC_real, qTPC_im); - } - void processZdcCollAssoc( - ColEvSels const& cols, - BCsRun3 const& /*bcs*/, - aod::Zdcs const& /*zdcs*/, - aod::FT0s const& /*ft0s*/) - { - double sumCosPsiDiff = 0.0; // initialize Sum of cosPsiDiff for averaging - double sumSinPsiDiff = 0.0; // initialize Sum of cosPsiDiff for averaging - int countEvents = 0; // initialize Counter for the number of events processed - double FT0AAmp = 0; - double FT0CAmp = 0; - // init values for ft0 multiplicity - float multFT0A = 0.f; - float multFT0C = 0.f; - float multFT0M = 0.f; - - // collision-based event selection - for (auto& collision : cols) { - const auto& foundBC = collision.foundBC_as(); - multFT0A = collision.multFT0A(); - multFT0C = collision.multFT0C(); - multFT0M = multFT0A + multFT0C; - - histos.fill(HIST("hMultT0A"), multFT0A); - histos.fill(HIST("hMultT0C"), multFT0C); - histos.fill(HIST("hMultT0M"), multFT0M); - if (collision.has_foundFT0()) { - auto ft0 = collision.foundFT0(); - for (auto amplitude : ft0.amplitudeA()) { - FT0AAmp += amplitude; - histos.fill(HIST("hFT0AAmp"), FT0AAmp); - } - for (auto amplitude : ft0.amplitudeC()) { - FT0CAmp += amplitude; - histos.fill(HIST("hFT0CAmp"), FT0CAmp); - } - } - double FT0MAmp = FT0AAmp + FT0CAmp; - histos.fill(HIST("hFT0MAmp"), FT0MAmp); - if (foundBC.has_zdc()) { - const auto& zdcread = foundBC.zdc(); - const auto cent = collision.centFT0C(); - - // ZDC data and histogram filling - histos.get(HIST("ZNAcoll"))->Fill(zdcread.amplitudeZNA()); - histos.get(HIST("ZNCcoll"))->Fill(zdcread.amplitudeZNC()); - histos.get(HIST("ZNvsZEMcoll"))->Fill(zdcread.amplitudeZEM1() + zdcread.amplitudeZEM2(), zdcread.amplitudeZNA() + zdcread.amplitudeZNC()); - histos.get(HIST("ZNAvsZNCcoll"))->Fill(zdcread.amplitudeZNC(), zdcread.amplitudeZNA()); - - histos.get(HIST("ZEM1coll"))->Fill(zdcread.amplitudeZEM1()); - histos.get(HIST("ZEM2coll"))->Fill(zdcread.amplitudeZEM2()); - - float sumZNC = (zdcread.energySectorZNC())[0] + (zdcread.energySectorZNC())[1] + (zdcread.energySectorZNC())[2] + (zdcread.energySectorZNC())[3]; - float sumZNA = (zdcread.energySectorZNA())[0] + (zdcread.energySectorZNA())[1] + (zdcread.energySectorZNA())[2] + (zdcread.energySectorZNA())[3]; - float sumZPC = (zdcread.energySectorZPC())[0] + (zdcread.energySectorZPC())[1] + (zdcread.energySectorZPC())[2] + (zdcread.energySectorZPC())[3]; - float sumZPA = (zdcread.energySectorZPA())[0] + (zdcread.energySectorZPA())[1] + (zdcread.energySectorZPA())[2] + (zdcread.energySectorZPA())[3]; - float sumZDC = sumZPA + sumZPC + sumZNA + sumZNC; - float sumZEM = zdcread.amplitudeZEM1() + zdcread.amplitudeZEM2(); - - // common energies - float common_sumZNC = (zdcread.energyCommonZNC()) / acceptnace_ZNC; - float common_sumZNA = (zdcread.energyCommonZNA()) / acceptnace_ZNA; - float common_sumZPC = (zdcread.energyCommonZPC()) / acceptnace_ZPC; - float common_sumZPA = (zdcread.energyCommonZPA()) / acceptnace_ZPA; - float sumZN = (sumZNC) + (sumZNA); - float sumZP = (sumZPC) + (sumZPA); - - histos.fill(HIST("ZNenergy"), sumZN); - histos.fill(HIST("ZPenergy"), sumZP); - histos.fill(HIST("ZNCenergy"), common_sumZNC); - histos.fill(HIST("ZNAenergy"), common_sumZNA); - histos.fill(HIST("ZPAenergy"), common_sumZPA); - histos.fill(HIST("ZPCenergy"), common_sumZPC); - histos.fill(HIST("hZNvsFT0Ccent"), cent, sumZN); - histos.fill(HIST("hZPvsFT0Ccent"), cent, sumZP); - float ratioZN = sumZNC / sumZNA; - float ratioZP = sumZPC / sumZPA; - pZNratiovscent->Fill(cent, ratioZN); - pZPratiovscent->Fill(cent, ratioZP); - pZNvsFT0Ccent->Fill(cent, sumZN); - pZPvsFT0Ccent->Fill(cent, sumZP); - pZPvsFT0MAmp->Fill(sumZP, FT0MAmp); - pZNvsFT0MAmp->Fill(sumZN, FT0MAmp); - - histos.get(HIST("ZDC_energy_vs_ZEM"))->Fill(sumZEM, sumZDC); - - // Spectator plane angle calculations and histograms - const auto Ntot_ZNA = zdcread.amplitudeZNA(); - const auto Ntot_ZNC = zdcread.amplitudeZNC(); - double qZNA_real = 0.0; - double qZNA_im = 0.0; - double qZNC_real = 0.0; - double qZNC_im = 0.0; - const double phiRadians[4] = {45 * TMath::Pi() / 180, 135 * TMath::Pi() / 180, 225 * TMath::Pi() / 180, 315 * TMath::Pi() / 180}; - TComplex qZNA(0, 0), qZNC(0, 0); - - for (int sector = 0; sector < 4; ++sector) { - float energyZNA = zdcread.energySectorZNA()[sector]; - float energyZNC = zdcread.energySectorZNC()[sector]; - - qZNA += TComplex(TMath::Cos(2 * phiRadians[sector]) * energyZNA / sumZNA, TMath::Sin(2 * phiRadians[sector]) * energyZNA / sumZNA); - qZNC += TComplex(TMath::Cos(2 * phiRadians[sector]) * energyZNC / sumZNC, TMath::Sin(2 * phiRadians[sector]) * energyZNC / sumZNC); - } - - qZNA_real = qZNA.Re() / Ntot_ZNA; - qZNA_im = qZNA.Im() / Ntot_ZNA; - qZNC_real = qZNC.Re() / Ntot_ZNC; - qZNC_im = qZNC.Im() / Ntot_ZNC; - - histos.fill(HIST("Acorrelations"), qZNA.Re(), qZNA.Im()); - histos.fill(HIST("RealQHistogramZNA"), qZNA_real); - histos.fill(HIST("ImagQHistogramZNA"), qZNA_im); - histos.fill(HIST("RealQHistogramZNC"), qZNC_real); - histos.fill(HIST("ImagQHistogramZNC"), qZNC_im); - - // Calculate the spectator plane angles for ZNA and ZNC - double psiZNA = TMath::ATan2(qZNA.Im(), qZNA.Re()) / 2; - double psiZNC = TMath::ATan2(qZNC.Im(), qZNC.Re()) / 2; - - // Fill the histograms with the calculated angles - histos.fill(HIST("SPAngleZNA"), psiZNA); - histos.fill(HIST("SPAngleZNC"), psiZNC); - - double cosPsiDiff = TMath::Cos(psiZNA) - TMath::Cos(psiZNC); - double sinPsiDiff = TMath::Sin(psiZNA) - TMath::Sin(psiZNC); - - sumCosPsiDiff += cosPsiDiff; - sumSinPsiDiff += sinPsiDiff; - ++countEvents; - - if (countEvents > 0) { - double runningAverageCosPsiDiff = sumCosPsiDiff / countEvents; - double runningAverageSinPsiDiff = sumSinPsiDiff / countEvents; - histos.fill(HIST("RunningAverageCosPsiDiff"), runningAverageCosPsiDiff); - pCosPsiDifferences->Fill(cent, runningAverageCosPsiDiff); - pSinPsiDifferences->Fill(cent, runningAverageSinPsiDiff); - } - histos.fill(HIST("CosPsiDifferences"), cosPsiDiff); - histos.fill(HIST("hSinDifferences"), sinPsiDiff); - } - } - } - - PROCESS_SWITCH(FlowZDCtask, processZdcCollAssoc, "Processing ZDC w. collision association", true); - PROCESS_SWITCH(FlowZDCtask, processQVector, "Process before recentering", true); - -}; // end of struct function - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx index e6e60d89b8c..08e223befb6 100644 --- a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx +++ b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx @@ -214,8 +214,8 @@ struct flowAnalysisGF { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (cfgFillWeights) { - fWeights->SetPtBins(ptbins, &ptbinning[0]); - fWeights->Init(true, false); + fWeights->setPtBins(ptbins, &ptbinning[0]); + fWeights->init(true, false); } if (doprocessMCGen) { @@ -388,7 +388,7 @@ struct flowAnalysisGF { return false; weight_nue = 1. / eff; if (cfg.mAcceptance) - weight_nua = cfg.mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = cfg.mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -582,7 +582,7 @@ struct flowAnalysisGF { return false; if (cfgFillWeights) - fWeights->Fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); + fWeights->fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, particle.phi(), particle.eta(), particle.pt(), vtxz)) return false; diff --git a/PWGCF/Flow/Tasks/flowEfficiencyCasc.cxx b/PWGCF/Flow/Tasks/flowEfficiencyCasc.cxx new file mode 100644 index 00000000000..25e23838586 --- /dev/null +++ b/PWGCF/Flow/Tasks/flowEfficiencyCasc.cxx @@ -0,0 +1,379 @@ +// 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. +/// +/// \file flowEfficiencyCasc.cxx +/// \author Fuchun Cui(fcui@cern.ch) +/// \since Feb/21/2025 +/// \brief This task is to calculate V0s and cascades local density efficiency + +#include +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/DataModel/PIDResponse.h" +#include "PWGLF/DataModel/cascqaanalysis.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "CommonConstants/PhysicsConstants.h" +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +struct FlowEfficiencyCasc { + O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 3.0f, "Maximal pT for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5f, "max chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") + // topological cut for V0 + O2_DEFINE_CONFIGURABLE(cfgv0_radius, float, 5.0f, "minimum decay radius") + O2_DEFINE_CONFIGURABLE(cfgv0_v0cospa, float, 0.995f, "minimum cosine of pointing angle") + O2_DEFINE_CONFIGURABLE(cfgv0_dcadautopv, float, 0.1f, "minimum daughter DCA to PV") + O2_DEFINE_CONFIGURABLE(cfgv0_dcav0dau, float, 0.5f, "maximum DCA among V0 daughters") + O2_DEFINE_CONFIGURABLE(cfgv0_mk0swindow, float, 0.1f, "Invariant mass window of K0s") + O2_DEFINE_CONFIGURABLE(cfgv0_mlambdawindow, float, 0.04f, "Invariant mass window of lambda") + O2_DEFINE_CONFIGURABLE(cfgv0_ArmPodocut, float, 0.2f, "Armenteros Podolski cut for K0") + // topological cut for cascade + O2_DEFINE_CONFIGURABLE(cfgcasc_radius, float, 0.5f, "minimum decay radius") + O2_DEFINE_CONFIGURABLE(cfgcasc_casccospa, float, 0.999f, "minimum cosine of pointing angle") + O2_DEFINE_CONFIGURABLE(cfgcasc_v0cospa, float, 0.998f, "minimum cosine of pointing angle") + O2_DEFINE_CONFIGURABLE(cfgcasc_dcav0topv, float, 0.01f, "minimum daughter DCA to PV") + O2_DEFINE_CONFIGURABLE(cfgcasc_dcabachtopv, float, 0.01f, "minimum bachelor DCA to PV") + O2_DEFINE_CONFIGURABLE(cfgcasc_dcacascdau, float, 0.3f, "maximum DCA among cascade daughters") + O2_DEFINE_CONFIGURABLE(cfgcasc_dcav0dau, float, 1.0f, "maximum DCA among V0 daughters") + O2_DEFINE_CONFIGURABLE(cfgcasc_mlambdawindow, float, 0.04f, "Invariant mass window of lambda") + // track quality and type selections + O2_DEFINE_CONFIGURABLE(cfgtpcclusters, int, 0, "minimum number of TPC clusters requirement") + O2_DEFINE_CONFIGURABLE(cfgitsclusters, int, 0, "minimum number of ITS clusters requirement") + O2_DEFINE_CONFIGURABLE(cfgtpcclufindable, int, 0, "minimum number of findable TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgtpccrossoverfindable, int, 0, "minimum number of Ratio crossed rows over findable clusters") + O2_DEFINE_CONFIGURABLE(cfgcheckDauTPC, bool, true, "check daughter tracks TPC or not") + O2_DEFINE_CONFIGURABLE(cfgcheckDauTOF, bool, false, "check daughter tracks TOF or not") + O2_DEFINE_CONFIGURABLE(cfgcheckMCParticle, bool, false, "check the particle and deacy channel match or not") + O2_DEFINE_CONFIGURABLE(cfgCasc_rapidity, float, 0.5, "rapidity") + + O2_DEFINE_CONFIGURABLE(cfgNSigmatpctof, std::vector, (std::vector{3, 3, 3}), "tpc and tof NSigma for Pion Kaon Proton") + + ConfigurableAxis cfgaxisPt{"cfgaxisPt", {VARIABLE_WIDTH, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00, 3.50, 4.00, 4.50, 5.00, 5.50, 6.00, 10.0}, "pt (GeV)"}; + ConfigurableAxis cfgaxisPtXi{"cfgaxisPtXi", {VARIABLE_WIDTH, 0, 0.1, 0.5, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; + ConfigurableAxis cfgaxisPtOmega{"cfgaxisPtOmega", {VARIABLE_WIDTH, 0, 0.1, 0.5, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; + ConfigurableAxis cfgaxisPtV0{"cfgaxisPtV0", {VARIABLE_WIDTH, 0, 0.1, 0.5, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; + ConfigurableAxis cfgaxisMultiplicity{"cfgaxisMultiplicity", {1000, 0, 5000}, "Nch"}; + ConfigurableAxis cfgaxisCentrality{"cfgaxisCentrality", {0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "Centrality (%)"}; + + AxisSpec axisOmegaMass = {80, 1.63f, 1.71f, "Inv. Mass (GeV)"}; + AxisSpec axisXiMass = {70, 1.3f, 1.37f, "Inv. Mass (GeV)"}; + AxisSpec axisK0sMass = {400, 0.4f, 0.6f, "Inv. Mass (GeV)"}; + AxisSpec axisLambdaMass = {160, 1.08f, 1.16f, "Inv. Mass (GeV)"}; + + using MyCollisions = soa::Join; + using MyMcCollisions = soa::Join; + using CascMCCandidates = soa::Join; + using V0MCCandidates = soa::Join; + using DaughterTracks = soa::Join; + + // Define the output + HistogramRegistry registry{"registry"}; + + std::vector cfgNSigma = cfgNSigmatpctof; + + void init(InitContext const&) + { + const AxisSpec axisCounter{2, 0, 2, ""}; + // create histograms + registry.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); + registry.add("mcEventCounter", "Monte Carlo Truth EventCounter", kTH1F, {axisCounter}); + registry.add("h2DCentvsNch", "", {HistType::kTH2D, {cfgaxisCentrality, cfgaxisMultiplicity}}); + + registry.add("h2DGenK0s", "", {HistType::kTH2D, {cfgaxisPtV0, cfgaxisMultiplicity}}); + registry.add("h2DGenLambda", "", {HistType::kTH2D, {cfgaxisPtV0, cfgaxisMultiplicity}}); + registry.add("h2DGenXi", "", {HistType::kTH2D, {cfgaxisPtXi, cfgaxisMultiplicity}}); + registry.add("h2DGenOmega", "", {HistType::kTH2D, {cfgaxisPtOmega, cfgaxisMultiplicity}}); + registry.add("h3DRecK0s", "", {HistType::kTH3D, {cfgaxisPtV0, cfgaxisMultiplicity, axisK0sMass}}); + registry.add("h3DRecLambda", "", {HistType::kTH3D, {cfgaxisPtV0, cfgaxisMultiplicity, axisLambdaMass}}); + registry.add("h3DRecXi", "", {HistType::kTH3D, {cfgaxisPtXi, cfgaxisMultiplicity, axisXiMass}}); + registry.add("h3DRecOmega", "", {HistType::kTH3D, {cfgaxisPtOmega, cfgaxisMultiplicity, axisOmegaMass}}); + + // V0 QA + registry.add("QAhisto/V0/hqaV0radiusbefore", "", {HistType::kTH1D, {{200, 0, 200}}}); + registry.add("QAhisto/V0/hqaV0radiusafter", "", {HistType::kTH1D, {{200, 0, 200}}}); + registry.add("QAhisto/V0/hqaV0cosPAbefore", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/V0/hqaV0cosPAafter", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/V0/hqadcaV0daubefore", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/V0/hqadcaV0dauafter", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/V0/hqaarm_podobefore", "", {HistType::kTH2D, {{100, -1, 1}, {50, 0, 0.3}}}); + registry.add("QAhisto/V0/hqaarm_podoafter", "", {HistType::kTH2D, {{100, -1, 1}, {50, 0, 0.3}}}); + registry.add("QAhisto/V0/hqadcapostoPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/V0/hqadcapostoPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/V0/hqadcanegtoPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/V0/hqadcanegtoPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); + // Cascade QA + registry.add("QAhisto/Casc/hqaCasccosPAbefore", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/Casc/hqaCasccosPAafter", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/Casc/hqaCascV0cosPAbefore", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/Casc/hqaCascV0cosPAafter", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/Casc/hqadcaCascV0toPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/Casc/hqadcaCascV0toPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/Casc/hqadcaCascBachtoPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/Casc/hqadcaCascBachtoPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/Casc/hqadcaCascdaubefore", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/Casc/hqadcaCascdauafter", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/Casc/hqadcaCascV0daubefore", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/Casc/hqadcaCascV0dauafter", "", {HistType::kTH1D, {{100, 0, 1}}}); + } + template + bool eventSelected(TCollision collision) + { + if (collision.alias_bit(kTVXinTRD)) { + // TRD triggered + return false; + } + if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + // reject collisions close to Time Frame borders + // https://its.cern.ch/jira/browse/O2-4623 + return false; + } + if (!collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + // reject events affected by the ITS ROF border + // https://its.cern.ch/jira/browse/O2-4309 + return false; + } + if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return false; + } + if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return false; + } + if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // no collisions in specified time range + return false; + } + if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // cut time intervals with dead ITS staves + return false; + } + + auto occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy > cfgCutOccupancyHigh) + return false; + + // // V0A T0A 5 sigma cut + // if (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > 5 * fT0AV0ASigma->Eval(collision.multFT0A())) + // return false; + + return true; + } + + void processRec(MyCollisions::iterator const& collision, V0MCCandidates const& V0s, CascMCCandidates const& Cascades, DaughterTracks const&, soa::Join const&, soa::Join const&) + { + registry.fill(HIST("eventCounter"), 0.5); + if (!collision.sel8()) + return; + if (eventSelected(collision)) + return; + registry.fill(HIST("eventCounter"), 1.5); + int rectracknum = collision.multNTracksGlobal(); + registry.fill(HIST("h2DCentvsNch"), collision.centFT0C(), rectracknum); + for (const auto& casc : Cascades) { + if (!casc.has_cascMCCore()) + continue; + auto cascMC = casc.cascMCCore_as>(); + auto negdau = casc.negTrackExtra_as(); + auto posdau = casc.posTrackExtra_as(); + auto bachelor = casc.bachTrackExtra_as(); + // fill QA + registry.fill(HIST("QAhisto/Casc/hqaCasccosPAbefore"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqaCascV0cosPAbefore"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0toPVbefore"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascBachtoPVbefore"), casc.dcabachtopv()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascdaubefore"), casc.dcacascdaughters()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0daubefore"), casc.dcaV0daughters()); + // track quality check + if (bachelor.tpcNClsFound() < cfgtpcclusters) + continue; + if (posdau.tpcNClsFound() < cfgtpcclusters) + continue; + if (negdau.tpcNClsFound() < cfgtpcclusters) + continue; + if (bachelor.itsNCls() < cfgitsclusters) + continue; + if (posdau.itsNCls() < cfgitsclusters) + continue; + if (negdau.itsNCls() < cfgitsclusters) + continue; + // topological cut + if (casc.cascradius() < cfgcasc_radius) + continue; + if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cfgcasc_casccospa) + continue; + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cfgcasc_v0cospa) + continue; + if (std::fabs(casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())) < cfgcasc_dcav0topv) + continue; + if (std::fabs(casc.dcabachtopv()) < cfgcasc_dcabachtopv) + continue; + if (casc.dcacascdaughters() > cfgcasc_dcacascdau) + continue; + if (casc.dcaV0daughters() > cfgcasc_dcav0dau) + continue; + if (std::fabs(casc.mLambda() - o2::constants::physics::MassLambda0) > cfgcasc_mlambdawindow) + continue; + // fill QA + registry.fill(HIST("QAhisto/Casc/hqaCasccosPAafter"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqaCascV0cosPAafter"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0toPVafter"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascBachtoPVafter"), casc.dcabachtopv()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascdauafter"), casc.dcacascdaughters()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0dauafter"), casc.dcaV0daughters()); + // Omega and antiOmega + int pdgCode{cascMC.pdgCode()}; + if (!cfgcheckMCParticle || (std::abs(pdgCode) == kOmegaMinus && std::abs(cascMC.pdgCodeV0()) == kLambda0 && std::abs(cascMC.pdgCodeBachelor()) == kKPlus)) { + if (casc.sign() < 0 && (casc.mOmega() > 1.63) && (casc.mOmega() < 1.71) && std::fabs(casc.yOmega()) < cfgCasc_rapidity && + (!cfgcheckDauTPC || (std::fabs(bachelor.tpcNSigmaKa()) < cfgNSigma[2] && std::fabs(posdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(negdau.tpcNSigmaPi()) < cfgNSigma[0]))) { + registry.fill(HIST("h3DRecOmega"), casc.pt(), rectracknum, casc.mOmega()); + } else if (casc.sign() > 0 && (casc.mOmega() > 1.63) && (casc.mOmega() < 1.71) && std::fabs(casc.yOmega()) < cfgCasc_rapidity && + (!cfgcheckDauTPC || (std::fabs(bachelor.tpcNSigmaKa()) < cfgNSigma[2] && std::fabs(negdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(posdau.tpcNSigmaPi()) < cfgNSigma[0]))) { + registry.fill(HIST("h3DRecOmega"), casc.pt(), rectracknum, casc.mOmega()); + } + } + // Xi and antiXi + if (!cfgcheckMCParticle || (std::abs(pdgCode) == kXiMinus && std::abs(cascMC.pdgCodeV0()) == kLambda0 && std::abs(cascMC.pdgCodeBachelor()) == kPiPlus)) { + if (casc.sign() < 0 && (casc.mXi() > 1.30) && (casc.mXi() < 1.37) && std::fabs(casc.yXi()) < cfgCasc_rapidity && + (!cfgcheckDauTPC || (std::fabs(bachelor.tpcNSigmaPi()) < cfgNSigma[0] && std::fabs(posdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(negdau.tpcNSigmaPi()) < cfgNSigma[0]))) { + registry.fill(HIST("h3DRecXi"), casc.pt(), rectracknum, casc.mXi()); + } else if (casc.sign() > 0 && (casc.mXi() > 1.30) && (casc.mXi() < 1.37) && std::fabs(casc.yXi()) < cfgCasc_rapidity && + (!cfgcheckDauTPC || (std::fabs(bachelor.tpcNSigmaPi()) < cfgNSigma[0] && std::fabs(negdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(posdau.tpcNSigmaPi()) < cfgNSigma[0]))) { + registry.fill(HIST("h3DRecXi"), casc.pt(), rectracknum, casc.mXi()); + } + } + } + + for (const auto& v0 : V0s) { + if (!v0.has_v0MCCore()) + continue; + auto v0MC = v0.v0MCCore_as>(); + auto v0negdau = v0.negTrackExtra_as(); + auto v0posdau = v0.posTrackExtra_as(); + + // fill QA before cut + registry.fill(HIST("QAhisto/V0/hqaV0radiusbefore"), v0.v0radius()); + registry.fill(HIST("QAhisto/V0/hqaV0cosPAbefore"), v0.v0cosPA()); + registry.fill(HIST("QAhisto/V0/hqadcaV0daubefore"), v0.dcaV0daughters()); + registry.fill(HIST("QAhisto/V0/hqadcapostoPVbefore"), v0.dcapostopv()); + registry.fill(HIST("QAhisto/V0/hqadcanegtoPVbefore"), v0.dcanegtopv()); + registry.fill(HIST("QAhisto/V0/hqaarm_podobefore"), v0.alpha(), v0.qtarm()); + // track quality check + if (v0posdau.tpcNClsFound() < cfgtpcclusters) + continue; + if (v0negdau.tpcNClsFound() < cfgtpcclusters) + continue; + if (v0posdau.tpcNClsFindable() < cfgtpcclufindable) + continue; + if (v0negdau.tpcNClsFindable() < cfgtpcclufindable) + continue; + if (v0posdau.tpcCrossedRowsOverFindableCls() < cfgtpccrossoverfindable) + continue; + if (v0posdau.itsNCls() < cfgitsclusters) + continue; + if (v0negdau.itsNCls() < cfgitsclusters) + continue; + // topological cut + if (v0.v0radius() < cfgv0_radius) + continue; + if (v0.v0cosPA() < cfgv0_v0cospa) + continue; + if (v0.dcaV0daughters() > cfgv0_dcav0dau) + continue; + if (std::fabs(v0.dcapostopv()) < cfgv0_dcadautopv) + continue; + if (std::fabs(v0.dcanegtopv()) < cfgv0_dcadautopv) + continue; + // fill QA after cut + registry.fill(HIST("QAhisto/V0/hqaV0radiusafter"), v0.v0radius()); + registry.fill(HIST("QAhisto/V0/hqaV0cosPAafter"), v0.v0cosPA()); + registry.fill(HIST("QAhisto/V0/hqadcaV0dauafter"), v0.dcaV0daughters()); + registry.fill(HIST("QAhisto/V0/hqadcapostoPVafter"), v0.dcapostopv()); + registry.fill(HIST("QAhisto/V0/hqadcanegtoPVafter"), v0.dcanegtopv()); + + int pdgCode{v0MC.pdgCode()}; + // K0short + if (!cfgcheckMCParticle || (std::abs(pdgCode) == kK0Short && v0MC.pdgCodePositive() == kPiPlus && v0MC.pdgCodeNegative() == kPiMinus)) { + if (v0.qtarm() / std::fabs(v0.alpha()) > cfgv0_ArmPodocut && std::fabs(v0.y()) < 0.5 && std::fabs(v0.mK0Short() - o2::constants::physics::MassK0Short) < cfgv0_mk0swindow && + (!cfgcheckDauTPC || (std::fabs(v0posdau.tpcNSigmaPi()) < cfgNSigma[0] && std::fabs(v0negdau.tpcNSigmaPi()) < cfgNSigma[0]))) { + registry.fill(HIST("h3DRecK0s"), v0.pt(), rectracknum, v0.mK0Short()); + registry.fill(HIST("QAhisto/V0/hqaarm_podoafter"), v0.alpha(), v0.qtarm()); + } + } + // Lambda and antiLambda + if (std::fabs(v0.mLambda() - o2::constants::physics::MassLambda) < cfgv0_mlambdawindow && + (!cfgcheckDauTPC || (std::fabs(v0posdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(v0negdau.tpcNSigmaPi()) < cfgNSigma[0]))) { + if (!cfgcheckMCParticle || (std::abs(pdgCode) == kLambda0 && v0MC.pdgCodePositive() == kProton && v0MC.pdgCodeNegative() == kPiMinus)) + registry.fill(HIST("h3DRecLambda"), v0.pt(), rectracknum, v0.mLambda()); + } else if (std::fabs(v0.mLambda() - o2::constants::physics::MassLambda) < cfgv0_mlambdawindow && + (!cfgcheckDauTPC || (std::fabs(v0negdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(v0posdau.tpcNSigmaPi()) < cfgNSigma[0]))) { + if (!cfgcheckMCParticle || (std::abs(pdgCode) == kLambda0 && v0MC.pdgCodePositive() == kPiPlus && v0MC.pdgCodeNegative() == kProtonBar)) + registry.fill(HIST("h3DRecLambda"), v0.pt(), rectracknum, v0.mLambda()); + } + } + } + PROCESS_SWITCH(FlowEfficiencyCasc, processRec, "process reconstructed information", true); + + void processGen(MyMcCollisions::iterator const&, soa::SmallGroups> const& coll, const soa::SmallGroups>& cascMCs, const soa::SmallGroups>& v0MCs) + { + registry.fill(HIST("mcEventCounter"), 0.5); + int rectracknum = 0; + for (const auto& col : coll) { + rectracknum = col.multNTracksGlobal(); + } + for (auto const& cascmc : cascMCs) { + if (std::abs(cascmc.pdgCode()) == kXiMinus) { + if (std::fabs(cascmc.yMC()) < cfgCasc_rapidity) + registry.fill(HIST("h2DGenXi"), cascmc.ptMC(), rectracknum); + } + if (std::abs(cascmc.pdgCode()) == kOmegaMinus) { + if (std::fabs(cascmc.yMC()) < cfgCasc_rapidity) + registry.fill(HIST("h2DGenOmega"), cascmc.ptMC(), rectracknum); + } + } + for (auto const& v0mc : v0MCs) { + if (std::abs(v0mc.pdgCode()) == kK0Short) { + if (std::fabs(v0mc.yMC()) < cfgCasc_rapidity) + registry.fill(HIST("h2DGenK0s"), v0mc.ptMC(), rectracknum); + } + if (std::abs(v0mc.pdgCode()) == kLambda0) { + if (std::fabs(v0mc.yMC()) < cfgCasc_rapidity) + registry.fill(HIST("h2DGenLambda"), v0mc.ptMC(), rectracknum); + } + } + } + PROCESS_SWITCH(FlowEfficiencyCasc, processGen, "process gen information", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/flowEsePHe3.cxx b/PWGCF/Flow/Tasks/flowEsePHe3.cxx new file mode 100644 index 00000000000..2a4955c1419 --- /dev/null +++ b/PWGCF/Flow/Tasks/flowEsePHe3.cxx @@ -0,0 +1,1326 @@ +// 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 ZhengqingWang(zhengqing.wang@cern.ch) +/// \file flowEsePHe3.cxx +/// \brief task to calculate the P He3 flow correlation. +// C++/ROOT includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// o2Physics includes. +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StaticFor.h" + +#include "DataFormatsTPC/BetheBlochAleph.h" + +#include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" + +#include "CommonConstants/PhysicsConstants.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +namespace o2::aod +{ +namespace ese_var_table +{ +DECLARE_SOA_COLUMN(EseVtz, eseVtz, float); +DECLARE_SOA_COLUMN(EseCentFT0C, eseCentFT0C, float); +DECLARE_SOA_COLUMN(EsePsi2FT0C, esePsi2FT0C, float); +DECLARE_SOA_COLUMN(Eseq2Tar, eseq2Tar, float); +DECLARE_SOA_COLUMN(Eseq2Ref, eseq2Ref, float); +DECLARE_SOA_COLUMN(EseTarSign, eseTarSign, int8_t); +DECLARE_SOA_COLUMN(EseTarTPCInnerParam, eseTarTPCInnerParam, float); +DECLARE_SOA_COLUMN(EseTarTPCSignal, eseTarTPCSignal, float); +DECLARE_SOA_COLUMN(EseTarPt, eseTarPt, float); +DECLARE_SOA_COLUMN(EseTarEta, eseTarEta, float); +DECLARE_SOA_COLUMN(EseTarPhi, eseTarPhi, float); +DECLARE_SOA_COLUMN(EseTarDCAxy, eseTarDCAxy, float); +DECLARE_SOA_COLUMN(EseTarDCAz, eseTarDCAz, float); +DECLARE_SOA_COLUMN(EseTarTPCNcls, eseTarTPCNcls, uint8_t); +DECLARE_SOA_COLUMN(EseTarITSNcls, eseTarITSNcls, uint8_t); +DECLARE_SOA_COLUMN(EseTarTPCChi2NDF, eseTarTPCChi2NDF, float); +DECLARE_SOA_COLUMN(EseTarITSChi2NDF, eseTarITSChi2NDF, float); +DECLARE_SOA_COLUMN(EseTarTPCNSigma, eseTarTPCNSigma, float); +DECLARE_SOA_COLUMN(EseTarTOFNSigma, eseTarTOFNSigma, float); +DECLARE_SOA_COLUMN(EseTarITSNSigma, eseTarITSNSigma, float); +DECLARE_SOA_COLUMN(EseTarITSClusSize, eseTarITSClusSize, uint32_t); +} // namespace ese_var_table + +DECLARE_SOA_TABLE(ESETable, "AOD", "ESETable", + ese_var_table::EseVtz, + ese_var_table::EseCentFT0C, + ese_var_table::EsePsi2FT0C, + ese_var_table::Eseq2Tar, + ese_var_table::Eseq2Ref, + ese_var_table::EseTarSign, + ese_var_table::EseTarTPCInnerParam, + ese_var_table::EseTarTPCSignal, + ese_var_table::EseTarPt, + ese_var_table::EseTarEta, + ese_var_table::EseTarPhi, + ese_var_table::EseTarDCAxy, + ese_var_table::EseTarDCAz, + ese_var_table::EseTarTPCNcls, + ese_var_table::EseTarITSNcls, + ese_var_table::EseTarTPCChi2NDF, + ese_var_table::EseTarITSChi2NDF, + ese_var_table::EseTarTPCNSigma, + ese_var_table::EseTarTOFNSigma, + ese_var_table::EseTarITSNSigma, + ese_var_table::EseTarITSClusSize); +} // namespace o2::aod + +struct ESECandidate { + float vtz; + float centFT0C; + float psi2FT0C; + float q2Tar; + float q2Ref; + int8_t signTar; + float tpcInnerParamTar; + float tpcSignalTar; + float ptTar; + float etaTar; + float phiTar; + float dcaXYTar; + float dcaZTar; + uint8_t tpcNclsTar; + uint8_t itsNclsTar; + float tpcChi2NDFTar; + float itsChi2NDFTar; + float tpcNSigmaTar; + float tofNSigmaTar; + float itsNSigmaTar; + uint32_t itsClusSizeTar; +}; + +struct ESEReference { + int8_t signRef; + float ptRef; + float v2Ref; +}; + +namespace ese_parameters +{ +constexpr uint8_t kProton = 0; +constexpr uint8_t kDeuteron = 1; +constexpr uint8_t kTriton = 2; +constexpr uint8_t kHe3 = 3; +constexpr uint8_t kAlpha = 4; +constexpr uint8_t kPion = 5; +constexpr uint8_t kKaon = 6; +constexpr uint8_t kHadron = 7; +constexpr int kFT0AV0ASigma = 5; +constexpr int kRMSMode = 0; +constexpr int kTPCMode = 1; +constexpr int kTOFOnlyMode = 2; +constexpr float Amplitudelow = 1e-8; +constexpr float Charges[8]{1.f, 1.f, 1.f, 2.f, 2.f, 1.f, 1.f, 1.f}; +constexpr float Masses[5]{MassProton, MassDeuteron, MassTriton, MassHelium3, MassAlpha}; +constexpr double BetheBlochDefault[5][6]{ + {-136.71, 0.441, 0.2269, 1.347, 0.8035, 0.09}, + {-136.71, 0.441, 0.2269, 1.347, 0.8035, 0.09}, + {-239.99, 1.155, 1.099, 1.137, 1.006, 0.09}, + {-321.34, 0.6539, 1.591, 0.8225, 2.363, 0.09}, + {-586.66, 1.859, 4.435, 0.282, 3.201, 0.09}}; +constexpr double BbMomScalingDefault[5][2]{// 0:poscharged 1:negcharged + {1., 1.}, + {1., 1.}, + {1., 1.}, + {1., 1.}, + {1., 1.}}; +constexpr int Open3DPIDPlots[3][1]{ + {0}, + {0}, + {0}}; +constexpr int OpenEvSel[10][1]{ + {1}, + {1}, + {1}, + {1}, + {1}, + {1}, + {1}, + {1}, + {0}, + {1}}; +constexpr int OpenTrackSel[7][1]{ + {1}, + {1}, + {1}, + {1}, + {1}, + {1}, + {1}}; +constexpr double TPCnSigmaCutDefault[7][2]{ + {-3., 3.}, + {-3., 3.}, + {-3., 3.}, + {-3., 3.}, + {-3., 3.}, + {-3., 3.}, + {-3., 3.}}; +constexpr double ITSnSigmaCutDefault[7][2]{ + {-3., 3.}, + {-3., 3.}, + {-3., 3.}, + {-3., 3.}, + {-3., 3.}, + {-3., 3.}, + {-3., 3.}}; +constexpr double POverZPreselection[7][2]{ + {0.15, 99.}, + {0.15, 99.}, + {0.15, 99.}, + {0.15, 99.}, + {0.15, 99.}, + {0.15, 99.}, + {0.15, 99.}}; +constexpr double EtaPreselection[7][2]{ + {0.9}, + {0.9}, + {0.9}, + {0.8}, + {0.9}, + {0.9}, + {0.9}}; +constexpr double TPCNclsPreselection[7][2]{ + {50, 160}, + {50, 160}, + {50, 160}, + {100, 160}, + {50, 160}, + {50, 160}, + {50, 160}}; +constexpr double ITSNclsPreselection[7][2]{ + {5, 7}, + {5, 7}, + {5, 7}, + {5, 7}, + {5, 7}, + {5, 7}, + {5, 7}}; +constexpr double TPCChi2Preselection[7][2]{ + {0, 10}, + {0, 10}, + {0, 10}, + {0.5, 4}, + {0, 10}, + {0, 10}, + {0, 10}}; +constexpr double ITSChi2Preselection[7][2]{ + {0, 36}, + {0, 36}, + {0, 36}, + {0, 36}, + {0, 36}, + {0, 36}, + {0, 36}}; +constexpr double DCAxyPreselection[7][2]{ + {1}, + {1}, + {1}, + {0.1}, + {1}, + {1}, + {1}, +}; +constexpr double DCAzPreselection[7][2]{ + {5}, + {5}, + {5}, + {1}, + {5}, + {5}, + {5}, +}; +static const std::vector names{"proton", "deuteron", "triton", "He3", "alpha"}; +static const std::vector namesFull{"proton", "deuteron", "triton", "He3", "alpha", "pion", "kaon"}; +static const std::vector chargeLabelNames{"Positive", "Negative"}; +static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; +static const std::vector plot3DPIDNames{"TOF vs ITS", "ITS vs TPC", "TOF vs TPC"}; +static const std::vector openEventSelNames{"EvSelkIsGoodZvtxFT0vsPV", "EvSelkNoSameBunchPileup", "EvSelkNoCollInTimeRangeStandard", "EvSelkIsGoodITSLayersAll", "EvSelkNoCollInRofStandard", "EvSelkNoHighMultCollInPrevRof", "EvSelOccupancy", "EvSelMultCorrelationPVTracks", "EvSelMultCorrelationGlobalTracks", "EvSelV0AT0ACut"}; +static const std::vector openTrackSelNames{"passedITSNCls", "passedITSChi2NDF", "passedITSHits", "passedTPCChi2NDF", "passedTPCCrossedRowsOverNCls", "passedDCAxy", "passedDCAz"}; +static const std::vector plot3DConfigNames{"Open related 3D nSigma plots"}; +static const std::vector openEventSelConfigNames{"Open related event selection options"}; +static const std::vector openTrackSelConfigNames{"Open track selection from TrackSelection table"}; +static const std::vector pidTPCnSigmaNames{"n#sigma_{TPC} Low", "n#sigma_{TPC} High"}; +static const std::vector pidITSnSigmaNames{"n#sigma_{ITS} Low", "n#sigma_{ITS} High"}; +static const std::vector pidPOverZNames{"p/z Low", "p/z High"}; +static const std::vector pidEtaNames{"Abs Eta Max"}; +static const std::vector pidTPCNclsNames{"TPCNcls Low", "TPCNcls High"}; +static const std::vector pidITSNclsNames{"ITSNcls Low", "ITSNcls High"}; +static const std::vector pidTPCChi2Names{"TPCChi2 Low", "TPCChi2 High"}; +static const std::vector pidITSChi2Names{"ITSChi2 Low", "ITSChi2 High"}; +static const std::vector pidDCAxyNames{"Abs DCAxy Max"}; +static const std::vector pidDCAzNames{"Abs DCAz Max"}; +std::vector eseCandidates; +std::vector eseReferences; +// Tar ptr +std::shared_ptr hPIDQATar1D[12]; +std::shared_ptr hPIDQATar2D[4]; +std::shared_ptr hPIDQATar3D[3]; +std::shared_ptr hv2Tar[2]; +std::shared_ptr hESEQATar1D[4]; +std::shared_ptr hESEQATar2D; +std::shared_ptr hESETar; +// Ref ptr +std::shared_ptr hPIDQARef1D[12]; +std::shared_ptr hPIDQARef2D[4]; +std::shared_ptr hPIDQARef3D[3]; +std::shared_ptr hv2Ref[2]; +std::shared_ptr hESEQARef1D[4]; +std::shared_ptr hESEQARef2D; +} // namespace ese_parameters + +using TracksPIDFull = soa::Join; + +struct FlowEsePHe3 { + + EventPlaneHelper helperEP; + o2::aod::ITSResponse itsResponse; + HistogramRegistry histsESE{"histsESE", {}, OutputObjHandlingPolicy::AnalysisObject}; + // process POI control + Configurable cfgTarName{"cfgTarName", "kHe3", "Name of the v2 particle: kProton, kDeuteron, kTriton, kHe3, kAlpha"}; + Configurable cfgRefName{"cfgRefName", "kProton", "Name of the q2 reference particle: kProton, kDeuteron, kTriton, kHe3, kAlpha"}; + // total control config + Configurable cfgOpenAllowCrossTrack{"cfgOpenAllowCrossTrack", true, "Allow one track to be identified as different kind of PID particles"}; + Configurable cfgOpenFullEventQA{"cfgOpenFullEventQA", true, "Open full QA plots for event QA"}; + Configurable cfgOpenPIDQA{"cfgOpenPIDQA", true, "Open PID QA plots"}; + Configurable cfgOpenv2Tar{"cfgOpenv2Tar", true, "Open v2(EP) for Tar patricle"}; + Configurable cfgOpenv2Ref{"cfgOpenv2Ref", true, "Open v2(EP) for Ref patricle"}; + Configurable cfgOpenESE{"cfgOpenESE", true, "Open ESE plots"}; + Configurable cfgOpenESEQA{"cfgOpenESEQA", true, "Open ESE QA plots"}; + Configurable> cfgOpen3DPIDPlots{"cfgOpen3DPIDPlots", {ese_parameters::Open3DPIDPlots[0], 3, 1, ese_parameters::plot3DPIDNames, ese_parameters::plot3DConfigNames}, "3D PID QA Plots switch configuration"}; + // Qvec configs + Configurable cfgDetName{"cfgDetName", "FT0C", "The name of detector to be analyzed"}; + Configurable cfgRefAName{"cfgRefAName", "TPCpos", "The name of detector for reference A"}; + Configurable cfgRefBName{"cfgRefBName", "TPCneg", "The name of detector for reference B"}; + Configurable cfgnTotalSystem{"cfgnTotalSystem", 7, "total qvector number"}; + // pre event selection(filter) + Configurable cfgVtzCut{"cfgVtzCut", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCentMin{"cfgCentMin", 0.0f, "Centrality min"}; + Configurable cfgCentMax{"cfgCentMax", 100.0f, "Centrality max"}; + // event selection configs + Configurable cfgCutOccupancyLow{"cfgCutOccupancyLow", 0, "Low boundary cut on TPC occupancy"}; + Configurable cfgCutOccupancyHigh{"cfgCutOccupancyHigh", 3000, "High boundary cut on TPC occupancy"}; + Configurable> cfgOpenEvSel{"cfgOpenEvSel", {ese_parameters::OpenEvSel[0], 10, 1, ese_parameters::openEventSelNames, ese_parameters::openEventSelConfigNames}, "Event selection switch configuration"}; + // track selection configs + Configurable> cfgOpenTrackSel{"cfgOpenTrackSel", {ese_parameters::OpenTrackSel[0], 7, 1, ese_parameters::openTrackSelNames, ese_parameters::openTrackSelConfigNames}, "Track selection switch configuration"}; + Configurable cfgMinPtPID{"cfgMinPtPID", 0.15, "Minimum track #P_{t} for PID"}; + Configurable cfgMaxPtPID{"cfgMaxPtPID", 99.9, "Maximum track #P_{t} for PID"}; + Configurable cfgMaxEtaPID{"cfgMaxEtaPID", 0.9, "Maximum track #eta for PID"}; + Configurable cfgMinTPCChi2NCl{"cfgMinTPCChi2NCl", 0, "Minimum chi2 per cluster TPC for PID if not use costom track cuts"}; + Configurable cfgMinChi2NClITS{"cfgMinChi2NClITS", 0, "Minimum chi2 per cluster ITS for PID if not use costom track cuts"}; + Configurable cfgMaxTPCChi2NCl{"cfgMaxTPCChi2NCl", 4, "Maximum chi2 per cluster TPC for PID if not use costom track cuts"}; + Configurable cfgMaxChi2NClITS{"cfgMaxChi2NClITS", 36, "Maximum chi2 per cluster ITS for PID if not use costom track cuts"}; + Configurable cfgMinTPCCls{"cfgMinTPCCls", 70, "Minimum TPC clusters for PID if not use costom track cuts"}; + Configurable cfgMinITSCls{"cfgMinITSCls", 1, "Minimum ITS clusters for PID if not use costom track cuts"}; + Configurable cfgMaxTPCCls{"cfgMaxTPCCls", 999, "Max TPC clusters for PID if not use costom track cuts"}; + Configurable cfgMaxITSCls{"cfgMaxITSCls", 999, "Max ITS clusters for PID if not use costom track cuts"}; + Configurable cfgMaxDCAxy{"cfgMaxDCAxy", 99, "Maxium DCAxy for standard PID tracking"}; + Configurable cfgMaxDCAz{"cfgMaxDCAz", 2, "Maxium DCAz for standard PID tracking"}; + Configurable cfgPtMaxforTPCOnlyPIDProton{"cfgPtMaxforTPCOnlyPIDProton", 0.4, "Maxmium track pt for TPC only PID, at RMS PID mode for proton"}; + Configurable cfgPtMaxforTPCOnlyPIDPion{"cfgPtMaxforTPCOnlyPIDPion", 0.4, "Maxmium track pt for TPC only PID, at RMS PID mode for pion"}; + Configurable cfgPtMaxforTPCOnlyPIDKaon{"cfgPtMaxforTPCOnlyPIDKaon", 0.4, "Maxmium track pt for TPC only PID, at RMS PID mode for kaon"}; + // PID configs + Configurable cfgOpenITSPreselection{"cfgOpenITSPreselection", false, "Use nSigma ITS preselection for light nuclei"}; + Configurable> cfgPOverZPreselection{"cfgPOverZPreselection", {ese_parameters::POverZPreselection[0], 7, 2, ese_parameters::namesFull, ese_parameters::pidPOverZNames}, "P/Z preselection for light nuclei"}; + Configurable> cfgEtaPreselection{"cfgEtaPreselection", {ese_parameters::EtaPreselection[0], 7, 1, ese_parameters::namesFull, ese_parameters::pidEtaNames}, "Eta preselection for light nuclei"}; + Configurable> cfgTPCNclsPreselection{"cfgTPCNclsPreselection", {ese_parameters::TPCNclsPreselection[0], 7, 2, ese_parameters::namesFull, ese_parameters::pidTPCNclsNames}, "TPCNcls preselection for light nuclei"}; + Configurable> cfgITSNclsPreselection{"cfgITSNclsPreselection", {ese_parameters::ITSNclsPreselection[0], 7, 2, ese_parameters::namesFull, ese_parameters::pidITSNclsNames}, "ITSNcls preselection for light nuclei"}; + Configurable> cfgTPCChi2Preselection{"cfgTPCChi2Preselection", {ese_parameters::TPCChi2Preselection[0], 7, 2, ese_parameters::namesFull, ese_parameters::pidTPCChi2Names}, "TPCChi2 preselection for light nuclei"}; + Configurable> cfgITSChi2Preselection{"cfgITSChi2Preselection", {ese_parameters::ITSChi2Preselection[0], 7, 2, ese_parameters::namesFull, ese_parameters::pidITSChi2Names}, "ITSChi2 preselection for light nuclei"}; + Configurable> cfgDCAxyPreselection{"cfgDCAxyPreselection", {ese_parameters::DCAxyPreselection[0], 7, 1, ese_parameters::namesFull, ese_parameters::pidDCAxyNames}, "DCAxy preselection for light nuclei"}; + Configurable> cfgDCAzPreselection{"cfgDCAzPreselection", {ese_parameters::DCAzPreselection[0], 7, 1, ese_parameters::namesFull, ese_parameters::pidDCAzNames}, "DCAz preselection for light nuclei"}; + Configurable> cfgnSigmaCutTOFProton{"cfgnSigmaCutTOFProton", {-1.5, 1.5}, "TOF nsigma cut limit for Proton"}; + Configurable> cfgnSigmaCutRMSProton{"cfgnSigmaCutRMSProton", {-3, 3}, "RMS nsigma cut limit for Proton"}; + Configurable> cfgnSigmaCutTOFPion{"cfgnSigmaCutTOFPion", {-1.5, 1.5}, "TOF nsigma cut limit for Pion"}; + Configurable> cfgnSigmaCutRMSPion{"cfgnSigmaCutRMSPion", {-3, 3}, "RMS nsigma cut limit for Pion"}; + Configurable> cfgnSigmaCutTOFKaon{"cfgnSigmaCutTOFKaon", {-1.5, 1.5}, "TOF nsigma cut limit for Kaon"}; + Configurable> cfgnSigmaCutRMSKaon{"cfgnSigmaCutRMSKaon", {-3, 3}, "RMS nsigma cut limit for Kaon"}; + Configurable cfgUseSelfnSigmaTPCProton{"cfgUseSelfnSigmaTPCProton", true, "Use self nSigma TPC for Proton PID"}; + Configurable cfgProtonPIDMode{"cfgProtonPIDMode", 2, "Proton PID mode: 0 for TPC + RMS(TPC,TOF), 1 for TPC only, 2 for TOF only"}; + Configurable cfgPionPIDMode{"cfgPionPIDMode", 2, "Pion PID mode: 0 for TPC + RMS(TPC,TOF), 1 for TPC only, 2 for TOF only"}; + Configurable cfgKaonPIDMode{"cfgKaonPIDMode", 2, "Kaon PID mode: 0 for TPC + RMS(TPC,TOF), 1 for TPC only, 2 for TOF only"}; + Configurable> cfgnSigmaTPC{"cfgnSigmaTPC", {ese_parameters::TPCnSigmaCutDefault[0], 7, 2, ese_parameters::namesFull, ese_parameters::pidTPCnSigmaNames}, "TPC nSigma selection for light nuclei"}; + Configurable> cfgnSigmaITS{"cfgnSigmaITS", {ese_parameters::ITSnSigmaCutDefault[0], 7, 2, ese_parameters::namesFull, ese_parameters::pidITSnSigmaNames}, "ITS nSigma selection for light nuclei"}; + // PID BBself paras config + Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {ese_parameters::BetheBlochDefault[0], 5, 6, ese_parameters::names, ese_parameters::betheBlochParNames}, "TPC Bethe-Bloch parameterisation for light nuclei"}; + Configurable> cfgMomentumScalingBetheBloch{"cfgMomentumScalingBetheBloch", {ese_parameters::BbMomScalingDefault[0], 5, 2, ese_parameters::names, ese_parameters::chargeLabelNames}, "TPC Bethe-Bloch momentum scaling for light nuclei"}; + Configurable cfgCompensatePIDinTracking{"cfgCompensatePIDinTracking", true, "If true, divide tpcInnerParam by the electric charge"}; + // Axias configs + ConfigurableAxis cfgnSigmaBinsTPC{"cfgnSigmaBinsTPC", {200, -5.f, 5.f}, "Binning for n sigma TPC"}; + ConfigurableAxis cfgnSigmaBinsTOF{"cfgnSigmaBinsTOF", {200, -5.f, 5.f}, "Binning for n sigma TOF"}; + ConfigurableAxis cfgnSigmaBinsITS{"cfgnSigmaBinsITS", {200, -5.f, 5.f}, "Binning for n sigma ITS"}; + ConfigurableAxis cfgaxispt{"cfgaxispt", {100, 0, 10}, "Binning for P_{t}"}; + ConfigurableAxis cfgaxisDCAz{"cfgaxisDCAz", {200, -1, 1}, "Binning for DCAz"}; + ConfigurableAxis cfgaxisDCAxy{"cfgaxisDCAxy", {100, -0.5, 0.5}, "Binning for DCAxy"}; + ConfigurableAxis cfgaxisChi2Ncls{"cfgaxisChi2Ncls", {100, 0, 30}, "Binning for Chi2Ncls TPC/ITS"}; + ConfigurableAxis cfgaxisCent{"cfgaxisCent", {90, 0, 90}, ""}; + ConfigurableAxis cfgaxisq2Tar{"cfgaxisq2Tar", {100, 0, 2}, "Binning for q_{2} traget particle"}; + ConfigurableAxis cfgaxisq2Ref{"cfgaxisq2Ref", {120, 0, 12}, "Binning for q_{2} reference particle"}; + ConfigurableAxis cfgq2NumeratorTar{"cfgq2NumeratorTar", {20, 0, 2}, "q2 Numerator bin for tar particle"}; + ConfigurableAxis cfgq2NumeratorRef{"cfgq2NumeratorRef", {100, 0, 10}, "q2 Numerator bin for ref particle"}; + ConfigurableAxis cfgq2DenominatorTar{"cfgq2DenominatorTar", {20, 0, 2}, "q2 Denominator bin for tar particle"}; + ConfigurableAxis cfgq2DenominatorRef{"cfgq2DenominatorRef", {50, 0, 5}, "q2 Denominator bin for ref particle"}; + + uint8_t poiTar; + uint8_t poiRef; + int detId; + int refAId; + int refBId; + int detInd; + int refAInd; + int refBInd; + // Function for He3 purity cut refered from luca's slides + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + + Filter collisionFilter = (nabs(aod::collision::posZ) < cfgVtzCut) && (aod::cent::centFT0C > cfgCentMin) && (aod::cent::centFT0C < cfgCentMax); + + Produces eseTable; + + template + float getNSigmaTPCSelfBB(const TrackType track, uint8_t POI) + { + bool heliumPID = track.pidForTracking() == o2::track::PID::Helium3 || track.pidForTracking() == o2::track::PID::Alpha; + float correctedTpcInnerParam = (heliumPID && cfgCompensatePIDinTracking) ? track.tpcInnerParam() / 2 : track.tpcInnerParam(); + const int iC{track.sign() < 0}; + switch (POI) { + case ese_parameters::kProton: { + const double bgScaling[2]{ese_parameters::Charges[0] * cfgMomentumScalingBetheBloch->get(0u, 0u) / ese_parameters::Masses[0], ese_parameters::Charges[0] * cfgMomentumScalingBetheBloch->get(0u, 1u) / ese_parameters::Masses[0]}; + double expBethe{tpc::BetheBlochAleph(static_cast(correctedTpcInnerParam * bgScaling[iC]), cfgBetheBlochParams->get(0u, 0u), cfgBetheBlochParams->get(0u, 1u), cfgBetheBlochParams->get(0u, 2u), cfgBetheBlochParams->get(0u, 3u), cfgBetheBlochParams->get(0u, 4u))}; + double expSigma{expBethe * cfgBetheBlochParams->get(0u, 5u)}; + double nSigmaTPC{static_cast((track.tpcSignal() - expBethe) / expSigma)}; + return nSigmaTPC; + } + case ese_parameters::kDeuteron: { + const double bgScaling[2]{ese_parameters::Charges[1] * cfgMomentumScalingBetheBloch->get(1u, 0u) / ese_parameters::Masses[1], ese_parameters::Charges[1] * cfgMomentumScalingBetheBloch->get(1u, 1u) / ese_parameters::Masses[1]}; + double expBethe{tpc::BetheBlochAleph(static_cast(correctedTpcInnerParam * bgScaling[iC]), cfgBetheBlochParams->get(1u, 0u), cfgBetheBlochParams->get(1u, 1u), cfgBetheBlochParams->get(1u, 2u), cfgBetheBlochParams->get(1u, 3u), cfgBetheBlochParams->get(1u, 4u))}; + double expSigma{expBethe * cfgBetheBlochParams->get(1u, 5u)}; + double nSigmaTPC{static_cast((track.tpcSignal() - expBethe) / expSigma)}; + return nSigmaTPC; + } + case ese_parameters::kTriton: { + const double bgScaling[2]{ese_parameters::Charges[2] * cfgMomentumScalingBetheBloch->get(2u, 0u) / ese_parameters::Masses[2], ese_parameters::Charges[2] * cfgMomentumScalingBetheBloch->get(2u, 1u) / ese_parameters::Masses[2]}; + double expBethe{tpc::BetheBlochAleph(static_cast(correctedTpcInnerParam * bgScaling[iC]), cfgBetheBlochParams->get(2u, 0u), cfgBetheBlochParams->get(2u, 1u), cfgBetheBlochParams->get(2u, 2u), cfgBetheBlochParams->get(2u, 3u), cfgBetheBlochParams->get(2u, 4u))}; + double expSigma{expBethe * cfgBetheBlochParams->get(2u, 5u)}; + double nSigmaTPC{static_cast((track.tpcSignal() - expBethe) / expSigma)}; + return nSigmaTPC; + } + case ese_parameters::kHe3: { + const double bgScaling[2]{ese_parameters::Charges[3] * cfgMomentumScalingBetheBloch->get(3u, 0u) / ese_parameters::Masses[3], ese_parameters::Charges[3] * cfgMomentumScalingBetheBloch->get(3u, 1u) / ese_parameters::Masses[3]}; + double expBethe{tpc::BetheBlochAleph(static_cast(correctedTpcInnerParam * bgScaling[iC]), cfgBetheBlochParams->get(3u, 0u), cfgBetheBlochParams->get(3u, 1u), cfgBetheBlochParams->get(3u, 2u), cfgBetheBlochParams->get(3u, 3u), cfgBetheBlochParams->get(3u, 4u))}; + double expSigma{expBethe * cfgBetheBlochParams->get(3u, 5u)}; + double nSigmaTPC{static_cast((track.tpcSignal() - expBethe) / expSigma)}; + return nSigmaTPC; + } + case ese_parameters::kAlpha: { + const double bgScaling[2]{ese_parameters::Charges[4] * cfgMomentumScalingBetheBloch->get(4u, 0u) / ese_parameters::Masses[4], ese_parameters::Charges[4] * cfgMomentumScalingBetheBloch->get(4u, 1u) / ese_parameters::Masses[4]}; + double expBethe{tpc::BetheBlochAleph(static_cast(correctedTpcInnerParam * bgScaling[iC]), cfgBetheBlochParams->get(4u, 0u), cfgBetheBlochParams->get(4u, 1u), cfgBetheBlochParams->get(4u, 2u), cfgBetheBlochParams->get(4u, 3u), cfgBetheBlochParams->get(4u, 4u))}; + double expSigma{expBethe * cfgBetheBlochParams->get(4u, 5u)}; + double nSigmaTPC{static_cast((track.tpcSignal() - expBethe) / expSigma)}; + return nSigmaTPC; + } + default: + return -99.f; + } + } + + template + float getNSigmaTPC(const TrackType track, uint8_t POI) + { + switch (POI) { + case ese_parameters::kProton: { + float nSigmaUse = (cfgUseSelfnSigmaTPCProton ? getNSigmaTPCSelfBB(track, ese_parameters::kProton) : track.tpcNSigmaPr()); + return nSigmaUse; + } + + case ese_parameters::kDeuteron: { + return getNSigmaTPCSelfBB(track, ese_parameters::kDeuteron); + } + + case ese_parameters::kTriton: { + return getNSigmaTPCSelfBB(track, ese_parameters::kTriton); + } + + case ese_parameters::kHe3: { + return getNSigmaTPCSelfBB(track, ese_parameters::kHe3); + } + + case ese_parameters::kAlpha: { + return getNSigmaTPCSelfBB(track, ese_parameters::kAlpha); + } + + case ese_parameters::kPion: { + return track.tpcNSigmaPi(); + } + + case ese_parameters::kKaon: { + return track.tpcNSigmaKa(); + } + + default: + LOGF(error, "Unknown POI: %d", POI); + return 0; + } + } + + template + float getNSigmaTOF(const TrackType track, uint8_t POI) + { + switch (POI) { + case ese_parameters::kProton: { + return track.tofNSigmaPr(); + } + case ese_parameters::kDeuteron: { + return track.tofNSigmaDe(); + } + case ese_parameters::kTriton: { + return track.tofNSigmaTr(); + } + case ese_parameters::kHe3: { + return track.tofNSigmaHe(); + } + case ese_parameters::kAlpha: { + return track.tofNSigmaAl(); + } + case ese_parameters::kPion: { + return track.tofNSigmaPi(); + } + case ese_parameters::kKaon: { + return track.tofNSigmaKa(); + } + default: + return -99.f; + } + } + + template + float getNSigmaITS(const TrackType track, uint8_t POI) + { + switch (POI) { + case ese_parameters::kProton: { + return itsResponse.nSigmaITS(track); + } + case ese_parameters::kDeuteron: { + return itsResponse.nSigmaITS(track); + } + case ese_parameters::kTriton: { + return itsResponse.nSigmaITS(track); + } + case ese_parameters::kHe3: { + return itsResponse.nSigmaITS(track); + } + case ese_parameters::kAlpha: { + return itsResponse.nSigmaITS(track); + } + case ese_parameters::kPion: { + return itsResponse.nSigmaITS(track); + } + case ese_parameters::kKaon: { + return itsResponse.nSigmaITS(track); + } + default: + return -99.f; + } + } + + template + int getDetId(const T& name) + { + if (name.value == "BPos" || name.value == "BNeg" || name.value == "BTot") { + LOGF(warning, "Using deprecated label: %s. Please use TPCpos, TPCneg, TPCall instead.", name.value); + } + if (name.value == "FT0C") { + return 0; + } else if (name.value == "FT0A") { + return 1; + } else if (name.value == "FT0M") { + return 2; + } else if (name.value == "FV0A") { + return 3; + } else if (name.value == "TPCpos" || name.value == "BPos") { + return 4; + } else if (name.value == "TPCneg" || name.value == "BNeg") { + return 5; + } else if (name.value == "TPCall" || name.value == "BTot") { + return 6; + } else { + return 0; + } + } + + template + uint8_t getPOI(const T& POI) + { + if (POI.value == "kProton") { + return ese_parameters::kProton; + } else if (POI.value == "kDeuteron") { + return ese_parameters::kDeuteron; + } else if (POI.value == "kTriton") { + return ese_parameters::kTriton; + } else if (POI.value == "kHe3") { + return ese_parameters::kHe3; + } else if (POI.value == "kAlpha") { + return ese_parameters::kAlpha; + } else if (POI.value == "kPion") { + return ese_parameters::kPion; + } else if (POI.value == "kKaon") { + return ese_parameters::kKaon; + } else if (POI.value == "kHadron") { + return ese_parameters::kHadron; + } else { + LOGF(error, "Unknown POIstr: %s", POI.value.c_str()); + return 0; + } + } + + float calculateq2(const float qx, const float qy, const int multi) + { + if (multi <= 0) { + return 0.f; + } else { + return std::hypot(qx, qy) / std::sqrt(static_cast(multi)); + } + } + + template + bool eventSelBasic(const CollType& collision, const int64_t multTrk, const float centrality, bool fillQA) + { + if (!collision.sel8()) + return false; + if (fillQA) { + histsESE.fill(HIST("EventQA/histEventCount"), 0.5); + } + if (cfgOpenEvSel->get(0u) && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if (fillQA && cfgOpenEvSel->get(0u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 1.5); + } + if (cfgOpenEvSel->get(1u) && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return false; + } + if (fillQA && cfgOpenEvSel->get(1u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 2.5); + } + if (cfgOpenEvSel->get(2u) && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + if (fillQA && cfgOpenEvSel->get(2u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 3.5); + } + if (cfgOpenEvSel->get(3u) && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return false; + } + if (fillQA && cfgOpenEvSel->get(3u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 4.5); + } + if (cfgOpenEvSel->get(4u) && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + if (fillQA && cfgOpenEvSel->get(4u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 5.5); + } + if (cfgOpenEvSel->get(5u) && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return false; + } + if (fillQA && cfgOpenEvSel->get(5u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 6.5); + } + auto multNTracksPV = collision.multNTracksPV(); + auto occupancy = collision.trackOccupancyInTimeRange(); + if (cfgOpenEvSel->get(6u) && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) { + return false; + } + if (fillQA && cfgOpenEvSel->get(6u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 7.5); + } + if (cfgOpenEvSel->get(7u)) { + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return false; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return false; + } + if (fillQA && cfgOpenEvSel->get(7u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 8.5); + } + if (cfgOpenEvSel->get(8u)) { + if (multTrk < fMultCutLow->Eval(centrality)) + return false; + if (multTrk > fMultCutHigh->Eval(centrality)) + return false; + } + if (fillQA && cfgOpenEvSel->get(8u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 9.5); + } + if (cfgOpenEvSel->get(9u) && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > ese_parameters::kFT0AV0ASigma * fT0AV0ASigma->Eval(collision.multFT0A()))) { + return false; + } + if (fillQA && cfgOpenEvSel->get(9u)) { + histsESE.fill(HIST("EventQA/histEventCount"), 10.5); + } + if (fillQA) { + histsESE.fill(HIST("EventQA/histVtz"), collision.posZ()); + histsESE.fill(HIST("EventQA/histCent"), centrality); + } + return true; + } + + template + bool trackSelBasic(const TrackType track) + { + if ((track.pt() < cfgMinPtPID) || (track.pt() > cfgMaxPtPID)) + return false; + if (std::abs(track.eta()) > cfgMaxEtaPID) + return false; + if (cfgOpenTrackSel->get(0u)) { + if (!track.passedITSNCls()) + return false; + } else { + if (track.itsNCls() < cfgMinITSCls || track.itsNCls() > cfgMaxITSCls) + return false; + } + if (cfgOpenTrackSel->get(1u)) { + if (!track.passedITSChi2NDF()) + return false; + } else { + if (track.itsChi2NCl() < cfgMinChi2NClITS || track.itsChi2NCl() > cfgMaxChi2NClITS) + return false; + } + if (cfgOpenTrackSel->get(2u)) { + if (!track.passedITSHits()) + return false; + } + if (cfgOpenTrackSel->get(3u)) { + if (!track.passedTPCChi2NDF()) + return false; + } else { + if (track.tpcChi2NCl() < cfgMinTPCChi2NCl || track.tpcChi2NCl() > cfgMaxTPCChi2NCl) + return false; + } + if (cfgOpenTrackSel->get(4u)) { + if (!track.passedTPCCrossedRowsOverNCls()) + return false; + } + if (cfgOpenTrackSel->get(5u)) { + if (!track.passedDCAxy()) + return false; + } else { + if (std::abs(track.dcaXY()) > cfgMaxDCAxy) + return false; + } + if (cfgOpenTrackSel->get(6u)) { + if (!track.passedDCAz()) + return false; + } else { + if (std::abs(track.dcaZ()) > cfgMaxDCAz) + return false; + } + if (track.tpcNClsFound() < cfgMinTPCCls || track.tpcNClsFound() > cfgMaxTPCCls) + return false; + return true; + } + + template + void fillEventQAhistBe(const CollType collision, const int multTrk, const float centrality) + { + histsESE.fill(HIST("EventQA/hist_globalTracks_centT0C_before"), centrality, multTrk); + histsESE.fill(HIST("EventQA/hist_PVTracks_centT0C_before"), centrality, collision.multNTracksPV()); + histsESE.fill(HIST("EventQA/hist_globalTracks_PVTracks_before"), collision.multNTracksPV(), multTrk); + histsESE.fill(HIST("EventQA/hist_globalTracks_multT0A_before"), collision.multFT0A(), multTrk); + histsESE.fill(HIST("EventQA/hist_globalTracks_multV0A_before"), collision.multFV0A(), multTrk); + histsESE.fill(HIST("EventQA/hist_multV0A_multT0A_before"), collision.multFT0A(), collision.multFV0A()); + histsESE.fill(HIST("EventQA/hist_multT0C_centT0C_before"), centrality, collision.multFT0C()); + } + + template + void fillEventQAhistAf(const CollType collision, const int multTrk, const float centrality) + { + histsESE.fill(HIST("EventQA/hist_globalTracks_centT0C_after"), centrality, multTrk); + histsESE.fill(HIST("EventQA/hist_PVTracks_centT0C_after"), centrality, collision.multNTracksPV()); + histsESE.fill(HIST("EventQA/hist_globalTracks_PVTracks_after"), collision.multNTracksPV(), multTrk); + histsESE.fill(HIST("EventQA/hist_globalTracks_multT0A_after"), collision.multFT0A(), multTrk); + histsESE.fill(HIST("EventQA/hist_globalTracks_multV0A_after"), collision.multFV0A(), multTrk); + histsESE.fill(HIST("EventQA/hist_multV0A_multT0A_after"), collision.multFT0A(), collision.multFV0A()); + histsESE.fill(HIST("EventQA/hist_multT0C_centT0C_after"), centrality, collision.multFT0C()); + } + + template + void fillTrackQAhist(const TrackType track) + { + bool heliumPID = track.pidForTracking() == o2::track::PID::Helium3 || track.pidForTracking() == o2::track::PID::Alpha; + float correctedTpcInnerParam = (heliumPID && cfgCompensatePIDinTracking) ? track.tpcInnerParam() / 2 : track.tpcInnerParam(); + histsESE.fill(HIST("TrackQA/hist_dEdxTPC_All"), track.sign() * correctedTpcInnerParam, track.tpcSignal()); + histsESE.fill(HIST("TrackQA/hist_pt_All"), track.pt()); + histsESE.fill(HIST("TrackQA/hist_eta_All"), track.eta()); + histsESE.fill(HIST("TrackQA/hist_phi_All"), track.phi()); + histsESE.fill(HIST("TrackQA/hist_DCAxy_All"), track.dcaXY()); + histsESE.fill(HIST("TrackQA/hist_DCAz_All"), track.dcaZ()); + histsESE.fill(HIST("TrackQA/hist_ITSNcls_All"), track.itsNCls()); + histsESE.fill(HIST("TrackQA/hist_TPCNcls_All"), track.tpcNClsFound()); + histsESE.fill(HIST("TrackQA/hist_ITSChi2NDF_All"), track.itsChi2NCl()); + histsESE.fill(HIST("TrackQA/hist_TPCChi2NDF_All"), track.tpcChi2NCl()); + histsESE.fill(HIST("TrackQA/hist_MomRes_All"), track.p(), 1 - (correctedTpcInnerParam / track.p())); + if (heliumPID) { + histsESE.fill(HIST("TrackQA/hist_He3AlphaTrackcounts_All"), 1.5); + } else { + histsESE.fill(HIST("TrackQA/hist_He3AlphaTrackcounts_All"), 0.5); + } + } + + template + void fillHistosQvec(const CollType& collision) + { + if (collision.qvecAmp()[detId] > ese_parameters::Amplitudelow) { + histsESE.fill(HIST("PlanQA/histQvec_CorrL0_V2"), collision.qvecRe()[detInd], collision.qvecIm()[detInd], collision.centFT0C()); + histsESE.fill(HIST("PlanQA/histQvec_CorrL1_V2"), collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], collision.centFT0C()); + histsESE.fill(HIST("PlanQA/histQvec_CorrL2_V2"), collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], collision.centFT0C()); + histsESE.fill(HIST("PlanQA/histQvec_CorrL3_V2"), collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], collision.centFT0C()); + histsESE.fill(HIST("PlanQA/histEvtPl_CorrL0_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], 2), collision.centFT0C()); + histsESE.fill(HIST("PlanQA/histEvtPl_CorrL1_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], 2), collision.centFT0C()); + histsESE.fill(HIST("PlanQA/histEvtPl_CorrL2_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], 2), collision.centFT0C()); + histsESE.fill(HIST("PlanQA/histEvtPl_CorrL3_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], 2), collision.centFT0C()); + } + if (collision.qvecAmp()[detId] > ese_parameters::Amplitudelow && collision.qvecAmp()[refAId] > ese_parameters::Amplitudelow && collision.qvecAmp()[refBId] > ese_parameters::Amplitudelow) { + histsESE.fill(HIST("PlanQA/histQvecRes_SigRefAV2"), collision.centFT0C(), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], 2), helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], 2), 2)); + histsESE.fill(HIST("PlanQA/histQvecRes_SigRefBV2"), collision.centFT0C(), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], 2), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], 2), 2)); + histsESE.fill(HIST("PlanQA/histQvecRes_RefARefBV2"), collision.centFT0C(), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], 2), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], 2), 2)); + } + } + + template + bool pidSel(const TrackType& track, uint8_t POI) + { + // Hadron + if (POI == ese_parameters::kHadron) + return true; + // PID particles + bool heliumPID = track.pidForTracking() == o2::track::PID::Helium3 || track.pidForTracking() == o2::track::PID::Alpha; + float correctedTpcInnerParam = (heliumPID && cfgCompensatePIDinTracking) ? track.tpcInnerParam() / 2 : track.tpcInnerParam(); + if (correctedTpcInnerParam < cfgPOverZPreselection->get(POI, 0u) || correctedTpcInnerParam > cfgPOverZPreselection->get(POI, 1u)) { + return false; + } + if (std::abs(track.eta()) > cfgEtaPreselection->get(POI)) { + return false; + } + if (track.tpcNClsFound() < cfgTPCNclsPreselection->get(POI, 0u) || track.tpcNClsFound() > cfgTPCNclsPreselection->get(POI, 1u)) { + return false; + } + if (track.itsNCls() < cfgITSNclsPreselection->get(POI, 0u) || track.itsNCls() > cfgITSNclsPreselection->get(POI, 1u)) { + return false; + } + if (track.tpcChi2NCl() < cfgTPCChi2Preselection->get(POI, 0u) || track.tpcChi2NCl() > cfgTPCChi2Preselection->get(POI, 1u)) { + return false; + } + if (track.itsChi2NCl() < cfgITSChi2Preselection->get(POI, 0u) || track.itsChi2NCl() > cfgITSChi2Preselection->get(POI, 1u)) { + return false; + } + if (std::abs(track.dcaXY()) > cfgDCAxyPreselection->get(POI)) { + return false; + } + if (std::abs(track.dcaZ()) > cfgDCAzPreselection->get(POI)) { + return false; + } + float nSigmaTPC{0.f}; + switch (POI) { + case ese_parameters::kProton: { + if (cfgProtonPIDMode == ese_parameters::kRMSMode) { // RMS mode + float nSigmaUse = (track.pt() > cfgPtMaxforTPCOnlyPIDProton) ? std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr()) : track.tpcNSigmaPr(); + if (nSigmaUse < cfgnSigmaCutRMSProton.value[0] || nSigmaUse > cfgnSigmaCutRMSProton.value[1]) { + return false; + } + } else if (cfgProtonPIDMode == ese_parameters::kTPCMode) { // TPC mode + nSigmaTPC = getNSigmaTPC(track, ese_parameters::kProton); + } else if (cfgProtonPIDMode == ese_parameters::kTOFOnlyMode) { // TOF only mode + if (!track.hasTOF()) + return false; + if (track.tofNSigmaPr() < cfgnSigmaCutTOFProton.value[0] || track.tofNSigmaPr() > cfgnSigmaCutTOFProton.value[1]) { + return false; + } + } + break; + } + + case ese_parameters::kDeuteron: { + nSigmaTPC = getNSigmaTPC(track, ese_parameters::kDeuteron); + break; + } + + case ese_parameters::kTriton: { + nSigmaTPC = getNSigmaTPC(track, ese_parameters::kTriton); + break; + } + + case ese_parameters::kHe3: { + nSigmaTPC = getNSigmaTPC(track, ese_parameters::kHe3); + break; + } + + case ese_parameters::kAlpha: { + nSigmaTPC = getNSigmaTPC(track, ese_parameters::kAlpha); + break; + } + + case ese_parameters::kPion: { + if (cfgPionPIDMode == ese_parameters::kRMSMode) { // RMS mode + float nSigmaUse = (track.pt() > cfgPtMaxforTPCOnlyPIDPion) ? std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi()) : track.tpcNSigmaPi(); + if (nSigmaUse < cfgnSigmaCutRMSPion.value[0] || nSigmaUse > cfgnSigmaCutRMSPion.value[1]) { + return false; + } + } else if (cfgPionPIDMode == ese_parameters::kTPCMode) { // TPC mode + nSigmaTPC = getNSigmaTPC(track, ese_parameters::kPion); + } else if (cfgPionPIDMode == ese_parameters::kTOFOnlyMode) { // TOF only mode + if (!track.hasTOF()) + return false; + if (track.tofNSigmaPi() < cfgnSigmaCutTOFPion.value[0] || track.tofNSigmaPi() > cfgnSigmaCutTOFPion.value[1]) { + return false; + } + } + break; + } + + case ese_parameters::kKaon: { + if (cfgKaonPIDMode == ese_parameters::kRMSMode) { // RMS mode + float nSigmaUse = (track.pt() > cfgPtMaxforTPCOnlyPIDKaon) ? std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa()) : track.tpcNSigmaKa(); + if (nSigmaUse < cfgnSigmaCutRMSKaon.value[0] || nSigmaUse > cfgnSigmaCutRMSKaon.value[1]) { + return false; + } + } else if (cfgKaonPIDMode == ese_parameters::kTPCMode) { // TPC mode + nSigmaTPC = getNSigmaTPC(track, ese_parameters::kKaon); + } else if (cfgKaonPIDMode == ese_parameters::kTOFOnlyMode) { // TOF only mode + if (!track.hasTOF()) + return false; + if (track.tofNSigmaKa() < cfgnSigmaCutTOFKaon.value[0] || track.tofNSigmaKa() > cfgnSigmaCutTOFKaon.value[1]) { + return false; + } + } + break; + } + + default: + LOGF(error, "Unknown POI: %d", POI); + return false; + } + if (nSigmaTPC < cfgnSigmaTPC->get(POI, 0u) || nSigmaTPC > cfgnSigmaTPC->get(POI, 1u)) { + return false; + } + if (cfgOpenITSPreselection) { + float nSigmaITS{getNSigmaITS(track, POI)}; + if (nSigmaITS < cfgnSigmaITS->get(POI, 0u) || nSigmaITS > cfgnSigmaITS->get(POI, 1u)) { + return false; + } + } + return true; + } + + template + void fillESECandidates(Tcoll const& collision, Ttrks const& tracks, float& q2Tarx, float& q2Tary, int& multiTar, float& q2Refx, float& q2Refy, int& multiRef) + { + float psi2 = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], 2); + float q2Tarinit{0.f}; + float q2Refinit{0.f}; + for (const auto& track : tracks) { // loop on tracks + if (!trackSelBasic(track)) { + continue; + } + // we fill the track info QA in the main process + fillTrackQAhist(track); + bool kIsTar{false}; + bool kIsRef{false}; + kIsTar = pidSel(track, poiTar); + kIsRef = pidSel(track, poiRef); + if (kIsTar && kIsRef && !cfgOpenAllowCrossTrack && poiRef != ese_parameters::kHadron) { + if (getNSigmaTPC(track, poiTar) < getNSigmaTPC(track, poiRef)) { + kIsRef = false; + } else { + kIsTar = false; + } + } + if (kIsTar) { + multiTar++; + q2Tarx += std::cos(2 * track.phi()); + q2Tary += std::sin(2 * track.phi()); + bool heliumPID = track.pidForTracking() == o2::track::PID::Helium3 || track.pidForTracking() == o2::track::PID::Alpha; + float correctedTpcInnerParam = (heliumPID && cfgCompensatePIDinTracking) ? track.tpcInnerParam() / 2 : track.tpcInnerParam(); + float nSigmaTPCTar{getNSigmaTPC(track, poiTar)}; + float nSigmaTOFTar{getNSigmaTOF(track, poiTar)}; + float nSigmaITSTar{getNSigmaITS(track, poiTar)}; + if (cfgOpenPIDQA) { + ese_parameters::hPIDQATar1D[0]->Fill(ese_parameters::Charges[poiTar] * track.pt()); + ese_parameters::hPIDQATar1D[1]->Fill(track.eta()); + ese_parameters::hPIDQATar1D[2]->Fill(track.phi()); + ese_parameters::hPIDQATar1D[3]->Fill(track.itsNCls()); + ese_parameters::hPIDQATar1D[4]->Fill(track.tpcNClsFound()); + ese_parameters::hPIDQATar1D[5]->Fill(track.itsChi2NCl()); + ese_parameters::hPIDQATar1D[6]->Fill(track.tpcChi2NCl()); + ese_parameters::hPIDQATar1D[7]->Fill(track.dcaXY()); + ese_parameters::hPIDQATar1D[8]->Fill(track.dcaZ()); + ese_parameters::hPIDQATar1D[9]->Fill(nSigmaTPCTar); + ese_parameters::hPIDQATar1D[10]->Fill(nSigmaTOFTar); + ese_parameters::hPIDQATar1D[11]->Fill(nSigmaITSTar); + ese_parameters::hPIDQATar2D[0]->Fill(track.sign() * correctedTpcInnerParam, track.tpcSignal()); + ese_parameters::hPIDQATar2D[1]->Fill(ese_parameters::Charges[poiTar] * track.pt(), nSigmaTPCTar); + ese_parameters::hPIDQATar2D[2]->Fill(ese_parameters::Charges[poiTar] * track.pt(), nSigmaTOFTar); + ese_parameters::hPIDQATar2D[3]->Fill(ese_parameters::Charges[poiTar] * track.pt(), nSigmaITSTar); + if (cfgOpen3DPIDPlots->get(0u)) { + ese_parameters::hPIDQATar3D[0]->Fill(nSigmaTOFTar, nSigmaITSTar, ese_parameters::Charges[poiTar] * track.pt()); + } + if (cfgOpen3DPIDPlots->get(1u)) { + ese_parameters::hPIDQATar3D[1]->Fill(nSigmaITSTar, nSigmaTPCTar, ese_parameters::Charges[poiTar] * track.pt()); + } + if (cfgOpen3DPIDPlots->get(2u)) { + ese_parameters::hPIDQATar3D[2]->Fill(nSigmaTOFTar, nSigmaTPCTar, ese_parameters::Charges[poiTar] * track.pt()); + } + } + ese_parameters::eseCandidates.emplace_back(ESECandidate{ + collision.posZ(), collision.centFT0C(), psi2, q2Tarinit, q2Refinit, static_cast(track.sign()), correctedTpcInnerParam, track.tpcSignal(), ese_parameters::Charges[poiTar] * track.pt(), track.eta(), track.phi(), + track.dcaXY(), track.dcaZ(), static_cast(track.tpcNClsFound()), track.itsNCls(), track.tpcChi2NCl(), track.itsChi2NCl(), + nSigmaTPCTar, nSigmaTOFTar, nSigmaITSTar, track.itsClusterSizes()}); + } + if (kIsRef) { + multiRef++; + q2Refx += std::cos(2 * track.phi()); + q2Refy += std::sin(2 * track.phi()); + if (cfgOpenPIDQA && poiRef != ese_parameters::kHadron) { + bool heliumPID = track.pidForTracking() == o2::track::PID::Helium3 || track.pidForTracking() == o2::track::PID::Alpha; + float correctedTpcInnerParam = (heliumPID && cfgCompensatePIDinTracking) ? track.tpcInnerParam() / 2 : track.tpcInnerParam(); + float nSigmaTPCRef{getNSigmaTPC(track, poiRef)}; + float nSigmaTOFRef{getNSigmaTOF(track, poiRef)}; + float nSigmaITSRef{getNSigmaITS(track, poiRef)}; + ese_parameters::hPIDQARef1D[0]->Fill(ese_parameters::Charges[poiRef] * track.pt()); + ese_parameters::hPIDQARef1D[1]->Fill(track.eta()); + ese_parameters::hPIDQARef1D[2]->Fill(track.phi()); + ese_parameters::hPIDQARef1D[3]->Fill(track.itsNCls()); + ese_parameters::hPIDQARef1D[4]->Fill(track.tpcNClsFound()); + ese_parameters::hPIDQARef1D[5]->Fill(track.itsChi2NCl()); + ese_parameters::hPIDQARef1D[6]->Fill(track.tpcChi2NCl()); + ese_parameters::hPIDQARef1D[7]->Fill(track.dcaXY()); + ese_parameters::hPIDQARef1D[8]->Fill(track.dcaZ()); + ese_parameters::hPIDQARef1D[9]->Fill(nSigmaTPCRef); + ese_parameters::hPIDQARef1D[10]->Fill(nSigmaTOFRef); + ese_parameters::hPIDQARef1D[11]->Fill(nSigmaITSRef); + ese_parameters::hPIDQARef2D[0]->Fill(track.sign() * correctedTpcInnerParam, track.tpcSignal()); + ese_parameters::hPIDQARef2D[1]->Fill(ese_parameters::Charges[poiRef] * track.pt(), nSigmaTPCRef); + ese_parameters::hPIDQARef2D[2]->Fill(ese_parameters::Charges[poiRef] * track.pt(), nSigmaTOFRef); + ese_parameters::hPIDQARef2D[3]->Fill(ese_parameters::Charges[poiRef] * track.pt(), nSigmaITSRef); + if (cfgOpen3DPIDPlots->get(0u)) { + ese_parameters::hPIDQARef3D[0]->Fill(nSigmaTOFRef, nSigmaITSRef, ese_parameters::Charges[poiRef] * track.pt()); + } + if (cfgOpen3DPIDPlots->get(1u)) { + ese_parameters::hPIDQARef3D[1]->Fill(nSigmaITSRef, nSigmaTPCRef, ese_parameters::Charges[poiRef] * track.pt()); + } + if (cfgOpen3DPIDPlots->get(2u)) { + ese_parameters::hPIDQARef3D[2]->Fill(nSigmaTOFRef, nSigmaTPCRef, ese_parameters::Charges[poiRef] * track.pt()); + } + } + if (cfgOpenv2Ref) { + ese_parameters::eseReferences.emplace_back(ESEReference{static_cast(track.sign()), ese_parameters::Charges[poiRef] * track.pt(), std::cos(2 * (track.phi() - psi2))}); + } + } + } + } + + void init(InitContext const&) + { + poiTar = getPOI(cfgTarName); + if (poiTar == ese_parameters::kHadron) { + LOGF(info, "This work flow is not designed to run over inclusive hadrons v2 ESE, you can only set the reference to be hadron, Reset Tar to He3"); + poiTar = ese_parameters::kHe3; + } + if (poiTar == poiRef) { + LOGF(error, "The POI and the reference cannot be the same, please change the configuration, Reset Tar to He3 Ref to Proton"); + poiTar = ese_parameters::kHe3; + poiRef = ese_parameters::kProton; + } + poiRef = getPOI(cfgRefName); + detId = getDetId(cfgDetName); + refAId = getDetId(cfgRefAName); + refBId = getDetId(cfgRefBName); + if (detId == refAId || detId == refBId || refAId == refBId) { + LOGF(info, "Wrong detector configuration \n The FT0C will be used to get Q-Vector \n The TPCpos and TPCneg will be used as reference systems"); + detId = 0; + refAId = 4; + refBId = 5; + } + detInd = detId * 4 + cfgnTotalSystem * 4 * (2 - 2); + refAInd = refAId * 4 + cfgnTotalSystem * 4 * (2 - 2); + refBInd = refBId * 4 + cfgnTotalSystem * 4 * (2 - 2); + + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + + AxisSpec axisITSNcls = {10, -1.5, 8.5, "ITSNcls"}; + AxisSpec axisTPCNcls = {160, 0, 160, "TPCNcls"}; + AxisSpec axisEvtPl = {100, -1.0 * constants::math::PI, constants::math::PI}; + AxisSpec axisPhi = {200, -2.1 * constants::math::PI, 2.1 * constants::math::PI}; + AxisSpec axisCentForQA = {100, 0, 100}; + AxisSpec axisCharge = {4, -2, 2, "Charge"}; + AxisSpec axisRigidity = {200, -10, 10, "#it{p}^{TPC}/#it{z}"}; + AxisSpec axisdEdx = {1400, 0, 1400, "dE/dx [arb. units]"}; + AxisSpec axisEta = {200, -1.0, 1.0, "#eta"}; + AxisSpec axisQvecF = {300, -1, 1, "Qvec"}; + AxisSpec axisNch = {4000, 0, 4000, "N_{ch}"}; + AxisSpec axisT0C = {70, 0, 70000, "N_{ch} (T0C)"}; + AxisSpec axisT0A = {70, 0, 70000, "N_{ch} (T0A)"}; + AxisSpec axisNchPV = {4000, 0, 4000, "N_{ch} (PV)"}; + AxisSpec axisCos = {102, -1.02, 1.02, "Cos"}; + // hists for event level QA + histsESE.add("EventQA/histEventCount", ";Event Count;Counts", {HistType::kTH1F, {{11, 0, 11}}}); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(1, "after sel8"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(2, "kIsGoodZvtxFT0vsPV"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(3, "kNoSameBunchPileup"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(4, "kNoCollInTimeRangeStandard"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(5, "kIsGoodITSLayersAll"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(6, "kNoCollInRofStandard"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(7, "kNoHighMultCollInPrevRof"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(8, "occupancy"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(9, "MultCorrelationPVTracks"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(10, "MultCorrelationGlobalTracks"); + histsESE.get(HIST("EventQA/histEventCount"))->GetXaxis()->SetBinLabel(11, "cfgEvSelV0AT0ACut"); + histsESE.add("EventQA/histVtz", ";#it{Vtz} (cm);Counts", {HistType::kTH1F, {{200, -20., +20.}}}); + histsESE.add("EventQA/histCent", ";Centrality (%);Counts", {HistType::kTH1F, {{100, 0., 100.}}}); + if (cfgOpenFullEventQA) { + histsESE.add("EventQA/hist_globalTracks_centT0C_before", "before cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + histsESE.add("EventQA/hist_PVTracks_centT0C_before", "before cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNchPV}}); + histsESE.add("EventQA/hist_globalTracks_PVTracks_before", "before cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNchPV, axisNch}}); + histsESE.add("EventQA/hist_globalTracks_multT0A_before", "before cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + histsESE.add("EventQA/hist_globalTracks_multV0A_before", "before cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + histsESE.add("EventQA/hist_multV0A_multT0A_before", "before cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); + histsESE.add("EventQA/hist_multT0C_centT0C_before", "before cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); + histsESE.add("EventQA/hist_globalTracks_centT0C_after", "after cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + histsESE.add("EventQA/hist_PVTracks_centT0C_after", "after cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNchPV}}); + histsESE.add("EventQA/hist_globalTracks_PVTracks_after", "after cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNchPV, axisNch}}); + histsESE.add("EventQA/hist_globalTracks_multT0A_after", "after cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + histsESE.add("EventQA/hist_globalTracks_multV0A_after", "after cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + histsESE.add("EventQA/hist_multV0A_multT0A_after", "after cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); + histsESE.add("EventQA/hist_multT0C_centT0C_after", "after cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); + } + histsESE.add("PlanQA/histQvec_CorrL0_V2", ";#it{Q_{x}};#it{Q_{y}};Centrality", {HistType::kTH3F, {axisQvecF, axisQvecF, cfgaxisCent}}); + histsESE.add("PlanQA/histQvec_CorrL1_V2", ";#it{Q_{x}};#it{Q_{y}};Centrality", {HistType::kTH3F, {axisQvecF, axisQvecF, cfgaxisCent}}); + histsESE.add("PlanQA/histQvec_CorrL2_V2", ";#it{Q_{x}};#it{Q_{y}};Centrality", {HistType::kTH3F, {axisQvecF, axisQvecF, cfgaxisCent}}); + histsESE.add("PlanQA/histQvec_CorrL3_V2", ";#it{Q_{x}};#it{Q_{y}};Centrality", {HistType::kTH3F, {axisQvecF, axisQvecF, cfgaxisCent}}); + histsESE.add("PlanQA/histEvtPl_CorrL0_V2", ";EventPlane angle;Centrality", {HistType::kTH2F, {axisEvtPl, cfgaxisCent}}); + histsESE.add("PlanQA/histEvtPl_CorrL1_V2", ";EventPlane angle;Centrality", {HistType::kTH2F, {axisEvtPl, cfgaxisCent}}); + histsESE.add("PlanQA/histEvtPl_CorrL2_V2", ";EventPlane angle;Centrality", {HistType::kTH2F, {axisEvtPl, cfgaxisCent}}); + histsESE.add("PlanQA/histEvtPl_CorrL3_V2", ";EventPlane angle;Centrality", {HistType::kTH2F, {axisEvtPl, cfgaxisCent}}); + histsESE.add("PlanQA/histQvecRes_SigRefAV2", ";Centrality;Cos(Sig-RefA)", {HistType::kTProfile, {cfgaxisCent}}); + histsESE.add("PlanQA/histQvecRes_SigRefBV2", ";Centrality;Cos(Sig-RefB)", {HistType::kTProfile, {cfgaxisCent}}); + histsESE.add("PlanQA/histQvecRes_RefARefBV2", ";Centrality;Cos(RefA-RefB)", {HistType::kTProfile, {cfgaxisCent}}); + // hists for track level QA + histsESE.add("TrackQA/hist_dEdxTPC_All", ";#it{p}^{TPC}/#it{z} (GeV/c);d#it{E}/d#it{x} [arb. units]", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histsESE.add("TrackQA/hist_pt_All", ";#it{p}_{T};counts", {HistType::kTH1F, {cfgaxispt}}); + histsESE.add("TrackQA/hist_eta_All", ";#it{#eta};counts", {HistType::kTH1F, {axisEta}}); + histsESE.add("TrackQA/hist_phi_All", ";#it{#phi};counts", {HistType::kTH1F, {axisPhi}}); + histsESE.add("TrackQA/hist_ITSNcls_All", ";ITSNcls;counts", {HistType::kTH1F, {axisITSNcls}}); + histsESE.add("TrackQA/hist_TPCNcls_All", ";TPCNcls;counts", {HistType::kTH1F, {axisTPCNcls}}); + histsESE.add("TrackQA/hist_ITSChi2NDF_All", ";ITS#it{#chi^{2}}/NDF;counts", {HistType::kTH1F, {cfgaxisChi2Ncls}}); + histsESE.add("TrackQA/hist_TPCChi2NDF_All", ";TPC#it{#chi^{2}}/NDF;counts", {HistType::kTH1F, {cfgaxisChi2Ncls}}); + histsESE.add("TrackQA/hist_DCAxy_All", ";#it{DCA_{xy}};counts", {HistType::kTH1F, {cfgaxisDCAxy}}); + histsESE.add("TrackQA/hist_DCAz_All", ";#it{DCA_{xy}};counts", {HistType::kTH1F, {cfgaxisDCAz}}); + histsESE.add("TrackQA/hist_MomRes_All", ";#it{p};Res(1 - corrted_p/track_p)", {HistType::kTH2F, {{100, 0, 10}, {100, -1, 1}}}); + histsESE.add("TrackQA/hist_He3AlphaTrackcounts_All", ";Track counts;Counts", {HistType::kTH1F, {{2, 0, 2}}}); + histsESE.get(HIST("TrackQA/hist_He3AlphaTrackcounts_All"))->GetXaxis()->SetBinLabel(1, "All Tracks"); + histsESE.get(HIST("TrackQA/hist_He3AlphaTrackcounts_All"))->GetXaxis()->SetBinLabel(2, "He3+Alpha"); + // v2 and ESEPlots + /// QA plots + if (cfgOpenPIDQA) { + ese_parameters::hPIDQATar2D[0] = histsESE.add(Form("ESE/TrackQA/hist_dEdxTPC_%s", cfgTarName.value.c_str()), ";#it{p}^{TPC}/#it{z} (GeV/c);d#it{E}/d#it{x} [arb. units]", HistType::kTH2F, {axisRigidity, axisdEdx}); + ese_parameters::hPIDQATar1D[0] = histsESE.add(Form("ESE/TrackQA/hist_pt_%s", cfgTarName.value.c_str()), ";#it{p}_{T};counts", HistType::kTH1F, {cfgaxispt}); + ese_parameters::hPIDQATar1D[1] = histsESE.add(Form("ESE/TrackQA/hist_eta_%s", cfgTarName.value.c_str()), ";#it{#eta};counts", HistType::kTH1F, {axisEta}); + ese_parameters::hPIDQATar1D[2] = histsESE.add(Form("ESE/TrackQA/hist_phi_%s", cfgTarName.value.c_str()), ";#it{#phi};counts", HistType::kTH1F, {axisPhi}); + ese_parameters::hPIDQATar1D[3] = histsESE.add(Form("ESE/TrackQA/hist_ITSNcls_%s", cfgTarName.value.c_str()), ";ITSNcls;counts", HistType::kTH1F, {axisITSNcls}); + ese_parameters::hPIDQATar1D[4] = histsESE.add(Form("ESE/TrackQA/hist_TPCNcls_%s", cfgTarName.value.c_str()), ";TPCNcls;counts", HistType::kTH1F, {axisTPCNcls}); + ese_parameters::hPIDQATar1D[5] = histsESE.add(Form("ESE/TrackQA/hist_ITSChi2NDF_%s", cfgTarName.value.c_str()), ";ITS#it{#chi^{2}}/NDF;counts", HistType::kTH1F, {cfgaxisChi2Ncls}); + ese_parameters::hPIDQATar1D[6] = histsESE.add(Form("ESE/TrackQA/hist_TPCChi2NDF_%s", cfgTarName.value.c_str()), ";TPC#it{#chi^{2}}/NDF;counts", HistType::kTH1F, {cfgaxisChi2Ncls}); + ese_parameters::hPIDQATar1D[7] = histsESE.add(Form("ESE/TrackQA/hist_DCAxy_%s", cfgTarName.value.c_str()), ";#it{DCA_{xy}};counts", HistType::kTH1F, {cfgaxisDCAxy}); + ese_parameters::hPIDQATar1D[8] = histsESE.add(Form("ESE/TrackQA/hist_DCAz_%s", cfgTarName.value.c_str()), ";#it{DCA_{xy}};counts", HistType::kTH1F, {cfgaxisDCAz}); + ese_parameters::hPIDQATar1D[9] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTPC_%s", cfgTarName.value.c_str()), ";n#sigmaTPC;counts", HistType::kTH1F, {cfgnSigmaBinsTPC}); + ese_parameters::hPIDQATar2D[1] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTPC_pt_%s", cfgTarName.value.c_str()), ";#it{p}_{T};n#sigmaTPC", HistType::kTH2F, {cfgaxispt, cfgnSigmaBinsTPC}); + ese_parameters::hPIDQATar1D[10] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTOF_%s", cfgTarName.value.c_str()), ";n#sigmaTOF;counts", HistType::kTH1F, {cfgnSigmaBinsTOF}); + ese_parameters::hPIDQATar2D[2] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTOF_pt_%s", cfgTarName.value.c_str()), ";#it{p}_{T};n#sigmaTOF", HistType::kTH2F, {cfgaxispt, cfgnSigmaBinsTOF}); + ese_parameters::hPIDQATar1D[11] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaITS_%s", cfgTarName.value.c_str()), ";n#sigmaITS;counts", HistType::kTH1F, {cfgnSigmaBinsITS}); + ese_parameters::hPIDQATar2D[3] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaITS_pt_%s", cfgTarName.value.c_str()), ";#it{p}_{T};n#sigmaITS", HistType::kTH2F, {cfgaxispt, cfgnSigmaBinsITS}); + if (cfgRefName.value != "kHadron") { + ese_parameters::hPIDQARef2D[0] = histsESE.add(Form("ESE/TrackQA/hist_dEdxTPC_%s", cfgRefName.value.c_str()), ";#it{p}^{TPC}/#it{z} (GeV/c);d#it{E}/d#it{x} [arb. units]", HistType::kTH2F, {axisRigidity, axisdEdx}); + ese_parameters::hPIDQARef1D[0] = histsESE.add(Form("ESE/TrackQA/hist_pt_%s", cfgRefName.value.c_str()), ";#it{p}_{T};counts", HistType::kTH1F, {cfgaxispt}); + ese_parameters::hPIDQARef1D[1] = histsESE.add(Form("ESE/TrackQA/hist_eta_%s", cfgRefName.value.c_str()), ";#it{#eta};counts", HistType::kTH1F, {axisEta}); + ese_parameters::hPIDQARef1D[2] = histsESE.add(Form("ESE/TrackQA/hist_phi_%s", cfgRefName.value.c_str()), ";#it{#phi};counts", HistType::kTH1F, {axisPhi}); + ese_parameters::hPIDQARef1D[3] = histsESE.add(Form("ESE/TrackQA/hist_ITSNcls_%s", cfgRefName.value.c_str()), ";ITSNcls;counts", HistType::kTH1F, {axisITSNcls}); + ese_parameters::hPIDQARef1D[4] = histsESE.add(Form("ESE/TrackQA/hist_TPCNcls_%s", cfgRefName.value.c_str()), ";TPCNcls;counts", HistType::kTH1F, {axisTPCNcls}); + ese_parameters::hPIDQARef1D[5] = histsESE.add(Form("ESE/TrackQA/hist_ITSChi2NDF_%s", cfgRefName.value.c_str()), ";ITS#it{#chi^{2}}/NDF;counts", HistType::kTH1F, {cfgaxisChi2Ncls}); + ese_parameters::hPIDQARef1D[6] = histsESE.add(Form("ESE/TrackQA/hist_TPCChi2NDF_%s", cfgRefName.value.c_str()), ";TPC#it{#chi^{2}}/NDF;counts", HistType::kTH1F, {cfgaxisChi2Ncls}); + ese_parameters::hPIDQARef1D[7] = histsESE.add(Form("ESE/TrackQA/hist_DCAxy_%s", cfgRefName.value.c_str()), ";#it{DCA_{xy}};counts", HistType::kTH1F, {cfgaxisDCAxy}); + ese_parameters::hPIDQARef1D[8] = histsESE.add(Form("ESE/TrackQA/hist_DCAz_%s", cfgRefName.value.c_str()), ";#it{DCA_{xy}};counts", HistType::kTH1F, {cfgaxisDCAz}); + ese_parameters::hPIDQARef1D[9] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTPC_%s", cfgRefName.value.c_str()), ";n#sigmaTPC;counts", HistType::kTH1F, {cfgnSigmaBinsTPC}); + ese_parameters::hPIDQARef2D[1] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTPC_pt_%s", cfgRefName.value.c_str()), ";#it{p}_{T};n#sigmaTPC", HistType::kTH2F, {cfgaxispt, cfgnSigmaBinsTPC}); + ese_parameters::hPIDQARef1D[10] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTOF_%s", cfgRefName.value.c_str()), ";n#sigmaTOF;counts", HistType::kTH1F, {cfgnSigmaBinsTOF}); + ese_parameters::hPIDQARef2D[2] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTOF_pt_%s", cfgRefName.value.c_str()), ";#it{p}_{T};n#sigmaTOF", HistType::kTH2F, {cfgaxispt, cfgnSigmaBinsTOF}); + ese_parameters::hPIDQARef1D[11] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaITS_%s", cfgRefName.value.c_str()), ";n#sigmaITS;counts", HistType::kTH1F, {cfgnSigmaBinsITS}); + ese_parameters::hPIDQARef2D[3] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaITS_pt_%s", cfgRefName.value.c_str()), ";#it{p}_{T};n#sigmaITS", HistType::kTH2F, {cfgaxispt, cfgnSigmaBinsITS}); + } + if (cfgOpen3DPIDPlots->get(0u)) { + ese_parameters::hPIDQATar3D[0] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTOFITSPt_%s", cfgTarName.value.c_str()), ";n_{#sigma}TOF;n_{#sigma}ITS;#it{p}_{T}", HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxispt}); + if (cfgRefName.value != "kHadron") { + ese_parameters::hPIDQARef3D[0] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTOFITSPt_%s", cfgRefName.value.c_str()), ";n_{#sigma}TOF;n_{#sigma}ITS;#it{p}_{T}", HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxispt}); + } + } + if (cfgOpen3DPIDPlots->get(1u)) { + ese_parameters::hPIDQATar3D[1] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaITSTPCPt_%s", cfgTarName.value.c_str()), ";n_{#sigma}ITS;n_{#sigma}TPC;#it{p}_{T}", HistType::kTH3F, {cfgnSigmaBinsITS, cfgnSigmaBinsTPC, cfgaxispt}); + if (cfgRefName.value != "kHadron") { + ese_parameters::hPIDQARef3D[1] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaITSTPCPt_%s", cfgRefName.value.c_str()), ";n_{#sigma}ITS;n_{#sigma}TPC;#it{p}_{T}", HistType::kTH3F, {cfgnSigmaBinsITS, cfgnSigmaBinsTPC, cfgaxispt}); + } + } + if (cfgOpen3DPIDPlots->get(2u)) { + ese_parameters::hPIDQATar3D[2] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTOFTPCPt_%s", cfgTarName.value.c_str()), ";n_{#sigma}TOF;n_{#sigma}TPC;#it{p}_{T}", HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxispt}); + if (cfgRefName.value != "kHadron") { + ese_parameters::hPIDQARef3D[2] = histsESE.add(Form("ESE/TrackQA/hist_nSigmaTOFTPCPt_%s", cfgRefName.value.c_str()), ";n_{#sigma}TOF;n_{#sigma}TPC;#it{p}_{T}", HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxispt}); + } + } + } + // v2 plots + if (cfgOpenv2Tar) { + ese_parameters::hv2Tar[0] = histsESE.add(Form("ESE/V2/hist_%sPosV2", cfgTarName.value.c_str()), ";#it{p}_{T};Centrality (%);#it{q}_{2}", {HistType::kTProfile3D, {cfgaxispt, cfgaxisCent, cfgaxisq2Tar}}); + ese_parameters::hv2Tar[1] = histsESE.add(Form("ESE/V2/hist_%sNegV2", cfgTarName.value.c_str()), ";#it{p}_{T};Centrality (%);#it{q}_{2}", {HistType::kTProfile3D, {cfgaxispt, cfgaxisCent, cfgaxisq2Tar}}); + } + if (cfgOpenv2Ref) { + ese_parameters::hv2Ref[0] = histsESE.add(Form("ESE/V2/hist_%sPosV2", cfgRefName.value.c_str()), ";#it{p}_{T};Centrality (%);#it{q}_{2}", {HistType::kTProfile3D, {cfgaxispt, cfgaxisCent, cfgaxisq2Ref}}); + ese_parameters::hv2Ref[1] = histsESE.add(Form("ESE/V2/hist_%sNegV2", cfgRefName.value.c_str()), ";#it{p}_{T};Centrality (%);#it{q}_{2}", {HistType::kTProfile3D, {cfgaxispt, cfgaxisCent, cfgaxisq2Ref}}); + } + // ESE plots + if (cfgOpenESEQA) { + ese_parameters::hESEQATar1D[0] = histsESE.add(Form("ESE/ESEQA/hist_%sNum", cfgTarName.value.c_str()), ";Num_{Proton}/Event;counts", HistType::kTH1F, {{100, 0, 100}}); + ese_parameters::hESEQATar1D[1] = histsESE.add(Form("ESE/ESEQA/hist_%sq2", cfgTarName.value.c_str()), ";#it{q}_{2};counts", HistType::kTH1F, {cfgaxisq2Tar}); + ese_parameters::hESEQATar1D[2] = histsESE.add(Form("ESE/ESEQA/hist_%sq2Numerator", cfgTarName.value.c_str()), ";#it{q}_{2} numerator;counts", HistType::kTH1F, {cfgq2NumeratorTar}); + ese_parameters::hESEQATar1D[3] = histsESE.add(Form("ESE/ESEQA/hist_%sq2Denominator", cfgTarName.value.c_str()), ";#it{q}_{2} denominator;counts", HistType::kTH1F, {cfgq2DenominatorTar}); + ese_parameters::hESEQATar2D = histsESE.add(Form("ESE/ESEQA/hist_%sq2_Cent", cfgTarName.value.c_str()), ";#it{q}_{2};Centrality (%)", HistType::kTH2F, {cfgaxisq2Tar, cfgaxisCent}); + ese_parameters::hESEQARef1D[0] = histsESE.add(Form("ESE/ESEQA/hist_%sNum", cfgRefName.value.c_str()), ";Num_{He3}/Event;counts", HistType::kTH1F, {{10, 0, 10}}); + ese_parameters::hESEQARef1D[1] = histsESE.add(Form("ESE/ESEQA/hist_%sq2", cfgRefName.value.c_str()), ";#it{q}_{2};counts", HistType::kTH1F, {cfgaxisq2Ref}); + ese_parameters::hESEQARef1D[2] = histsESE.add(Form("ESE/ESEQA/hist_%sq2Numerator", cfgRefName.value.c_str()), ";#it{q}_{2} numerator;counts", HistType::kTH1F, {cfgq2NumeratorRef}); + ese_parameters::hESEQARef1D[3] = histsESE.add(Form("ESE/ESEQA/hist_%sq2Denominator", cfgRefName.value.c_str()), ";#it{q}_{2} denominator;counts", HistType::kTH1F, {cfgq2DenominatorRef}); + ese_parameters::hESEQARef2D = histsESE.add(Form("ESE/ESEQA/hist_%sq2_Cent", cfgRefName.value.c_str()), ";#it{q}_{2};Centrality (%)", HistType::kTH2F, {cfgaxisq2Ref, cfgaxisCent}); + } + if (cfgOpenESE) { + ese_parameters::hESETar = histsESE.add(Form("ESE/ESE/histESE_%s", cfgTarName.value.c_str()), ";#it{p}_{T};Centrality (%);#it{q}_{2};cos(#phi-#Psi_{2});Charge", HistType::kTHnSparseF, {cfgaxispt, cfgaxisCent, cfgaxisq2Ref, axisCos, axisCharge}); + } + } + + void process(soa::Filtered>::iterator const& collision, TracksPIDFull const& tracks) + { + ese_parameters::eseCandidates.clear(); + ese_parameters::eseReferences.clear(); + const float centrality{collision.centFT0C()}; + const int64_t multTrk{tracks.size()}; + if (cfgOpenFullEventQA) + fillEventQAhistBe(collision, multTrk, centrality); + if (!eventSelBasic(collision, multTrk, centrality, true)) + return; + if (cfgOpenFullEventQA) + fillEventQAhistAf(collision, multTrk, centrality); + float q2Tarx{0.}; + float q2Tary{0.}; + float q2Refx{0.}; + float q2Refy{0.}; + int multiTar{0}; + int multiRef{0}; + fillHistosQvec(collision); + fillESECandidates(collision, tracks, q2Tarx, q2Tary, multiTar, q2Refx, q2Refy, multiRef); + float q2Tar{calculateq2(q2Tarx, q2Tary, multiTar)}; + float q2Ref{calculateq2(q2Refx, q2Refy, multiRef)}; + if (cfgOpenESEQA) { + ese_parameters::hESEQATar1D[0]->Fill(multiTar); + ese_parameters::hESEQATar1D[1]->Fill(q2Tar); + ese_parameters::hESEQATar1D[2]->Fill(std::hypot(q2Tarx, q2Tary)); + ese_parameters::hESEQATar1D[3]->Fill(std::sqrt(static_cast(multiTar))); + ese_parameters::hESEQATar2D->Fill(q2Tar, centrality); + ese_parameters::hESEQARef1D[0]->Fill(multiRef); + ese_parameters::hESEQARef1D[1]->Fill(q2Ref); + ese_parameters::hESEQARef2D->Fill(q2Ref, centrality); + ese_parameters::hESEQARef1D[2]->Fill(std::hypot(q2Refx, q2Refy)); + ese_parameters::hESEQARef1D[3]->Fill(std::sqrt(static_cast(multiRef))); + } + if (cfgOpenv2Ref) { + for (const auto& c : ese_parameters::eseReferences) { + if (c.signRef > 0) { + ese_parameters::hv2Ref[0]->Fill(c.ptRef, centrality, q2Ref, c.v2Ref); + } else { + ese_parameters::hv2Ref[1]->Fill(c.ptRef, centrality, q2Ref, c.v2Ref); + } + } + } + if (multiTar == 0) + return; + for (const auto& c : ese_parameters::eseCandidates) { + eseTable(c.vtz, c.centFT0C, c.psi2FT0C, q2Tar, q2Ref, c.signTar, c.tpcInnerParamTar, c.tpcSignalTar, c.ptTar, c.etaTar, c.phiTar, c.dcaXYTar, c.dcaZTar, c.tpcNclsTar, c.itsNclsTar, c.tpcChi2NDFTar, c.itsChi2NDFTar, c.tpcNSigmaTar, c.tofNSigmaTar, c.itsNSigmaTar, c.itsClusSizeTar); + if (cfgOpenESE) { + ese_parameters::hESETar->Fill(c.ptTar, c.centFT0C, q2Ref, std::cos(2 * (c.phiTar - c.psi2FT0C)), c.signTar); + } + if (cfgOpenv2Tar) { + if (c.signTar > 0) { + ese_parameters::hv2Tar[0]->Fill(c.ptTar, c.centFT0C, q2Tar, std::cos(2 * (c.phiTar - c.psi2FT0C))); + } else { + ese_parameters::hv2Tar[1]->Fill(c.ptTar, c.centFT0C, q2Tar, std::cos(2 * (c.phiTar - c.psi2FT0C))); + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGCF/Flow/Tasks/flowEseTask.cxx b/PWGCF/Flow/Tasks/flowEseTask.cxx new file mode 100644 index 00000000000..15bb95d27be --- /dev/null +++ b/PWGCF/Flow/Tasks/flowEseTask.cxx @@ -0,0 +1,455 @@ +// 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. + +/// \file flowEseTask.cxx +/// \brief Task for flow and event shape engineering correlation with other observation. +/// \author Alice Collaboration +/// \since 2023-05-15 +/// \version 1.0 +/// +/// This task calculates flow and event shape engineering +/// using Q-vector and event plane methods. + +// C++/ROOT includes. +#include +#include +#include +#include +#include + +#include +#include +#include + +// o2Physics includes. +#include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StaticFor.h" +#include "Framework/runDataProcessing.h" + +// o2 includes. + +using namespace o2; +using namespace o2::framework; + +using MyCollisions = soa::Join; +using MyTracks = soa::Join; +using BCsWithRun3Matchings = soa::Join; + +struct FlowEseTask { + HistogramRegistry histosQA{"histosQA", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + Configurable> cfgNmods{"cfgNmods", {2}, "Modulation of interest"}; + Configurable cfgDetName{"cfgDetName", "FT0C", "The name of detector to be analyzed"}; + Configurable cfgRefAName{"cfgRefAName", "TPCpos", "The name of detector for reference A"}; + Configurable cfgRefBName{"cfgRefBName", "TPCneg", "The name of detector for reference B"}; + + Configurable cfgMinPt{"cfgMinPt", 0.15f, "Minimum transverse momentum for charged track"}; + Configurable cfgMaxEta{"cfgMaxEta", 0.8f, "Maximum pseudorapidiy for charged track"}; + Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.1f, "Maximum transverse DCA"}; + Configurable cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 1.0f, "Maximum longitudinal DCA"}; + + ConfigurableAxis cfgAxisQvecF{"cfgAxisQvecF", {300, -1, 1}, ""}; + ConfigurableAxis cfgAxisQvec{"cfgAxisQvec", {100, -3, 3}, ""}; + ConfigurableAxis cfgAxisCent{"cfgAxisCent", {100, 0, 100}, ""}; + + ConfigurableAxis cfgAxisCos{"cfgAxisCos", {102, -1.02, 1.02}, ""}; + ConfigurableAxis cfgAxisPt{"cfgAxisPt", {100, 0, 10}, ""}; + ConfigurableAxis cfgAxisCentMerged{"cfgAxisCentMerged", {20, 0, 100}, ""}; + ConfigurableAxis cfgAxisMultNum{"cfgAxisMultNum", {300, 0, 2700}, ""}; + ConfigurableAxis cfgaxisQ{"cfgaxisQ", {1000, 0, 1000}, ""}; + + static constexpr float kMinAmplitudeThreshold = 1e-4f; + static constexpr int kDefaultModulation = 2; + static constexpr std::array kCent = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; + static constexpr std::array kSeparator = {125, 204, 110, 172, 92, 143, 74, 116, 57, 92, 43, 70, 31, 50, 21, 34, 14, 22, 5, 9}; + + EventPlaneHelper helperEP; + + void init(InitContext const&) + { + AxisSpec axisCent{cfgAxisCent, "centrality"}; + AxisSpec axisQvec{cfgAxisQvec, "Q"}; + AxisSpec axisQvecF{cfgAxisQvecF, "Q"}; + AxisSpec axisEvtPl = {100, -1.0 * constants::math::PI, constants::math::PI}; + + AxisSpec axisCos{cfgAxisCos, "angle function"}; + AxisSpec axisPt{cfgAxisPt, "trasverse momentum"}; + AxisSpec axisCentMerged{cfgAxisCentMerged, "merged centrality"}; + AxisSpec axisMultNum{cfgAxisMultNum, "statistic of mult"}; + AxisSpec axisQ{cfgaxisQ, "result of q2"}; + + histosQA.add(Form("histQvecV2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); + histosQA.add(Form("histQvecCent"), "", {HistType::kTH2F, {axisQ, axisCent}}); + histosQA.add(Form("histEvtPlV2"), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("histQvecRes_SigRefAV2"), "", {HistType::kTH2F, {axisQvecF, axisCent}}); + histosQA.add(Form("histCosDetV2"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_0010Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_0010Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_0010Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_1020Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_1020Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_1020Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_2030Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_2030Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_2030Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_3040Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_3040Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_3040Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_4050Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_4050Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_4050Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_5060Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_5060Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_5060Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_6070Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_6070Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_6070Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_7080Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_7080Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_7080Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_8090Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_8090Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_8090Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_9010Left"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_9010Mid"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histCosDetV2_9010Right"), "", {HistType::kTH3F, {axisQvecF, axisPt, axisCos}}); + histosQA.add(Form("histMult_Cent"), "", {HistType::kTH2F, {axisMultNum, axisCent}}); + } + + template + bool selectEvent(CollType const& collision) + { + if (!collision.sel8()) { + return false; + } + if (!collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if (!collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return false; + } + if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + + return true; + } + + template + bool selectTrack(TrackType const& track) + { + if (track.pt() < cfgMinPt) { + return false; + } + if (std::abs(track.eta()) > cfgMaxEta) { + return false; + } + if (!track.passedITSNCls()) { + return false; + } + if (!track.passedITSChi2NDF()) { + return false; + } + if (!track.passedITSHits()) { + return false; + } + if (!track.passedTPCCrossedRowsOverNCls()) { + return false; + } + if (!track.passedTPCChi2NDF()) { + return false; + } + if (!track.passedDCAxy()) { + return false; + } + if (!track.passedDCAz()) { + return false; + } + + return true; + } + + template + void fillHistosQvec(CollType const& collision, int nmode) + { + if (nmode == kDefaultModulation) { + histosQA.fill(HIST("histQvecV2"), collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], + collision.centFT0C()); + histosQA.fill(HIST("histQvecCent"), std::sqrt(collision.qvecFT0CReVec()[0] * collision.qvecFT0CReVec()[0] + collision.qvecFT0CImVec()[0] * collision.qvecFT0CImVec()[0]) * std::sqrt(collision.sumAmplFT0C()), collision.centFT0C()); + histosQA.fill(HIST("histEvtPlV2"), + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), + collision.centFT0C()); + histosQA.fill(HIST("histQvecRes_SigRefAV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), + collision.centFT0C()); + histosQA.fill(HIST("histMult_Cent"), collision.sumAmplFT0C(), collision.centFT0C()); + } + } + + template + void fillHistosFlow(CollType const& collision, TrackType const& tracks, int nmode) + { + double q2 = std::sqrt(collision.qvecFT0CReVec()[0] * collision.qvecFT0CReVec()[0] + collision.qvecFT0CImVec()[0] * collision.qvecFT0CImVec()[0]) * std::sqrt(collision.sumAmplFT0C()); + if (collision.sumAmplFT0C() < kMinAmplitudeThreshold) { + return; + } + for (auto const& trk : tracks) { + if (!selectTrack(trk)) { + continue; + } + if (nmode == kDefaultModulation) { + histosQA.fill(HIST("histCosDetV2"), collision.centFT0C(), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + if (collision.centFT0C() > kCent[0] && collision.centFT0C() <= kCent[1] && q2 < kSeparator[0]) { + histosQA.fill(HIST("histCosDetV2_0010Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[0] && collision.centFT0C() <= kCent[1] && q2 > kSeparator[0] && q2 <= kSeparator[1]) { + histosQA.fill(HIST("histCosDetV2_0010Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[0] && collision.centFT0C() <= kCent[1] && q2 > kSeparator[1]) { + histosQA.fill(HIST("histCosDetV2_0010Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[1] && collision.centFT0C() <= kCent[2] && q2 < kSeparator[2]) { + histosQA.fill(HIST("histCosDetV2_1020Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[1] && collision.centFT0C() <= kCent[2] && q2 > kSeparator[2] && q2 <= kSeparator[3]) { + histosQA.fill(HIST("histCosDetV2_1020Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[1] && collision.centFT0C() <= kCent[2] && q2 > kSeparator[3]) { + histosQA.fill(HIST("histCosDetV2_1020Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[2] && collision.centFT0C() <= kCent[3] && q2 < kSeparator[4]) { + histosQA.fill(HIST("histCosDetV2_2030Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[2] && collision.centFT0C() <= kCent[3] && q2 > kSeparator[4] && q2 <= kSeparator[5]) { + histosQA.fill(HIST("histCosDetV2_2030Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[2] && collision.centFT0C() <= kCent[3] && q2 > kSeparator[5]) { + histosQA.fill(HIST("histCosDetV2_2030Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[3] && collision.centFT0C() <= kCent[4] && q2 < kSeparator[6]) { + histosQA.fill(HIST("histCosDetV2_3040Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[3] && collision.centFT0C() <= kCent[4] && q2 > kSeparator[6] && q2 <= kSeparator[7]) { + histosQA.fill(HIST("histCosDetV2_3040Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[3] && collision.centFT0C() <= kCent[4] && q2 > kSeparator[7]) { + histosQA.fill(HIST("histCosDetV2_3040Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[4] && collision.centFT0C() <= kCent[5] && q2 < kSeparator[8]) { + histosQA.fill(HIST("histCosDetV2_4050Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[4] && collision.centFT0C() <= kCent[5] && q2 > kSeparator[8] && q2 <= kSeparator[9]) { + histosQA.fill(HIST("histCosDetV2_4050Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[4] && collision.centFT0C() <= kCent[5] && q2 > kSeparator[9]) { + histosQA.fill(HIST("histCosDetV2_4050Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[5] && collision.centFT0C() <= kCent[6] && q2 < kSeparator[10]) { + histosQA.fill(HIST("histCosDetV2_5060Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[5] && collision.centFT0C() <= kCent[6] && q2 > kSeparator[10] && q2 <= kSeparator[11]) { + histosQA.fill(HIST("histCosDetV2_5060Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[5] && collision.centFT0C() <= kCent[6] && q2 > kSeparator[11]) { + histosQA.fill(HIST("histCosDetV2_5060Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[6] && collision.centFT0C() <= kCent[7] && q2 < kSeparator[12]) { + histosQA.fill(HIST("histCosDetV2_6070Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[6] && collision.centFT0C() <= kCent[7] && q2 > kSeparator[12] && q2 <= kSeparator[13]) { + histosQA.fill(HIST("histCosDetV2_6070Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[6] && collision.centFT0C() <= kCent[7] && q2 > kSeparator[13]) { + histosQA.fill(HIST("histCosDetV2_6070Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[7] && collision.centFT0C() <= kCent[8] && q2 < kSeparator[14]) { + histosQA.fill(HIST("histCosDetV2_7080Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[7] && collision.centFT0C() <= kCent[8] && q2 > kSeparator[14] && q2 <= kSeparator[15]) { + histosQA.fill(HIST("histCosDetV2_7080Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[7] && collision.centFT0C() <= kCent[8] && q2 > kSeparator[15]) { + histosQA.fill(HIST("histCosDetV2_7080Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[8] && collision.centFT0C() <= kCent[9] && q2 < kSeparator[16]) { + histosQA.fill(HIST("histCosDetV2_8090Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[8] && collision.centFT0C() <= kCent[9] && q2 > kSeparator[16] && q2 <= kSeparator[17]) { + histosQA.fill(HIST("histCosDetV2_8090Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[8] && collision.centFT0C() <= kCent[9] && q2 > kSeparator[17]) { + histosQA.fill(HIST("histCosDetV2_8090Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[9] && collision.centFT0C() <= kCent[10] && q2 < kSeparator[18]) { + histosQA.fill(HIST("histCosDetV2_9010Left"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[9] && collision.centFT0C() <= kCent[10] && q2 > kSeparator[18] && q2 <= kSeparator[19]) { + histosQA.fill(HIST("histCosDetV2_9010Mid"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + if (collision.centFT0C() > kCent[9] && collision.centFT0C() <= kCent[10] && q2 > kSeparator[19]) { + histosQA.fill(HIST("histCosDetV2_9010Right"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], nmode), helperEP.GetEventPlane(collision.qvecTPCposReVec()[0], collision.qvecTPCposImVec()[0], nmode), nmode), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - + helperEP.GetEventPlane(collision.qvecFT0CReVec()[0], + collision.qvecFT0CImVec()[0], + nmode)))); + } + } + } + } + + void process(MyCollisions::iterator const& collision, MyTracks const& tracks) + { + if (!selectEvent(collision)) { + return; + } + for (std::size_t i = 0; i < cfgNmods->size(); i++) { + fillHistosQvec(collision, cfgNmods->at(i)); + fillHistosFlow(collision, tracks, cfgNmods->at(i)); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx deleted file mode 100644 index 8a491e46d28..00000000000 --- a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx +++ /dev/null @@ -1,906 +0,0 @@ -// 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. - -/// In case of questions please write to: -/// \author Fuchun Cui(fcui@cern.ch) - -#include -#include -#include -#include -#include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/HistogramRegistry.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" -#include "GFWPowerArray.h" -#include "GFW.h" -#include "GFWCumulant.h" -#include "GFWWeights.h" -#include "Common/DataModel/Qvectors.h" -#include "Common/Core/EventPlaneHelper.h" -#include "ReconstructionDataFormats/Track.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "TList.h" -#include -#include -#include -#include -#include - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -namespace -{ -std::shared_ptr REFc22[10]; -std::shared_ptr REFc24[10]; -std::shared_ptr K0sc22[10]; -std::shared_ptr K0sc24[10]; -std::shared_ptr Lambdac22[10]; -std::shared_ptr Lambdac24[10]; -std::shared_ptr Xic22[10]; -std::shared_ptr Xic24[10]; -std::shared_ptr Omegac22[10]; -std::shared_ptr Omegac24[10]; -} // namespace - -#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; - -struct FlowGFWOmegaXi { - - O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") - O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 10.0f, "Maximal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") - O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") - O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") - O2_DEFINE_CONFIGURABLE(cfgOmegaMassbins, int, 16, "Number of Omega mass axis bins for c22") - O2_DEFINE_CONFIGURABLE(cfgXiMassbins, int, 14, "Number of Xi mass axis bins for c22") - O2_DEFINE_CONFIGURABLE(cfgK0sMassbins, int, 80, "Number of K0s mass axis bins for c22") - O2_DEFINE_CONFIGURABLE(cfgLambdaMassbins, int, 32, "Number of Lambda mass axis bins for c22") - // topological cut for V0 - O2_DEFINE_CONFIGURABLE(cfgv0_radius, float, 5.0f, "minimum decay radius") - O2_DEFINE_CONFIGURABLE(cfgv0_v0cospa, float, 0.995f, "minimum cosine of pointing angle") - O2_DEFINE_CONFIGURABLE(cfgv0_dcadautopv, float, 0.1f, "minimum daughter DCA to PV") - O2_DEFINE_CONFIGURABLE(cfgv0_dcav0dau, float, 0.5f, "maximum DCA among V0 daughters") - O2_DEFINE_CONFIGURABLE(cfgv0_mk0swindow, float, 0.1f, "Invariant mass window of K0s") - O2_DEFINE_CONFIGURABLE(cfgv0_mlambdawindow, float, 0.04f, "Invariant mass window of lambda") - O2_DEFINE_CONFIGURABLE(cfgv0_ArmPodocut, float, 0.2f, "Armenteros Podolski cut for K0") - // topological cut for cascade - O2_DEFINE_CONFIGURABLE(cfgcasc_radius, float, 0.5f, "minimum decay radius") - O2_DEFINE_CONFIGURABLE(cfgcasc_casccospa, float, 0.999f, "minimum cosine of pointing angle") - O2_DEFINE_CONFIGURABLE(cfgcasc_v0cospa, float, 0.998f, "minimum cosine of pointing angle") - O2_DEFINE_CONFIGURABLE(cfgcasc_dcav0topv, float, 0.01f, "minimum daughter DCA to PV") - O2_DEFINE_CONFIGURABLE(cfgcasc_dcabachtopv, float, 0.01f, "minimum bachelor DCA to PV") - O2_DEFINE_CONFIGURABLE(cfgcasc_dcacascdau, float, 0.3f, "maximum DCA among cascade daughters") - O2_DEFINE_CONFIGURABLE(cfgcasc_dcav0dau, float, 1.0f, "maximum DCA among V0 daughters") - O2_DEFINE_CONFIGURABLE(cfgcasc_mlambdawindow, float, 0.04f, "Invariant mass window of lambda") - // track quality and type selections - O2_DEFINE_CONFIGURABLE(cfgtpcclusters, int, 70, "minimum number of TPC clusters requirement") - O2_DEFINE_CONFIGURABLE(cfgitsclusters, int, 1, "minimum number of ITS clusters requirement") - O2_DEFINE_CONFIGURABLE(cfgtpcclufindable, int, 1, "minimum number of findable TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgtpccrossoverfindable, int, 1, "minimum number of Ratio crossed rows over findable clusters") - O2_DEFINE_CONFIGURABLE(cfgcheckDauTPC, bool, true, "check daughter tracks TPC or not") - O2_DEFINE_CONFIGURABLE(cfgcheckDauTOF, bool, false, "check daughter tracks TOF or not") - O2_DEFINE_CONFIGURABLE(cfgCasc_rapidity, float, 0.5, "rapidity") - O2_DEFINE_CONFIGURABLE(cfgtpcNSigmaCascPion, float, 3, "NSigmaCascPion") - O2_DEFINE_CONFIGURABLE(cfgtpcNSigmaCascProton, float, 3, "NSigmaCascProton") - O2_DEFINE_CONFIGURABLE(cfgtpcNSigmaCascKaon, float, 3, "NSigmaCascKaon") - O2_DEFINE_CONFIGURABLE(cfgtofNSigmaCascPion, float, 3, "NSigmaCascPion") - O2_DEFINE_CONFIGURABLE(cfgtofNSigmaCascProton, float, 3, "NSigmaCascProton") - O2_DEFINE_CONFIGURABLE(cfgtofNSigmaCascKaon, float, 3, "NSigmaCascKaon") - O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, true, "Fill and output NUA weights") - O2_DEFINE_CONFIGURABLE(cfgAcceptancePath, std::vector, (std::vector{"Users/f/fcui/NUA/NUAREFPartical", "Users/f/fcui/NUA/NUAK0s", "Users/f/fcui/NUA/NUALambda", "Users/f/fcui/NUA/NUAXi", "Users/f/fcui/NUA/NUAOmega"}), "CCDB path to acceptance object") - O2_DEFINE_CONFIGURABLE(cfgEfficiencyPath, std::vector, (std::vector{"PathtoRef"}), "CCDB path to efficiency object") - - ConfigurableAxis cfgaxisVertex{"axisVertex", {20, -10, 10}, "vertex axis for histograms"}; - ConfigurableAxis cfgaxisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; - ConfigurableAxis cfgaxisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; - ConfigurableAxis cfgaxisPt{"axisPtREF", {VARIABLE_WIDTH, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00, 3.50, 4.00, 4.50, 5.00, 5.50, 6.00, 10.0}, "pt (GeV)"}; - ConfigurableAxis cfgaxisPtXi{"axisPtXi", {VARIABLE_WIDTH, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; - ConfigurableAxis cfgaxisPtOmega{"axisPtOmega", {VARIABLE_WIDTH, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; - ConfigurableAxis cfgaxisPtV0{"axisPtV0", {VARIABLE_WIDTH, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; - ConfigurableAxis cfgaxisOmegaminusMassforflow{"axismassOmegaFlow", {16, 1.63f, 1.71f}, "Inv. Mass (GeV)"}; - ConfigurableAxis cfgaxisXiminusMassforflow{"axismassXiFlow", {14, 1.3f, 1.37f}, "Inv. Mass (GeV)"}; - ConfigurableAxis cfgaxisK0sMassforflow{"axismassK0sFlow", {40, 0.4f, 0.6f}, "Inv. Mass (GeV)"}; - ConfigurableAxis cfgaxisLambdaMassforflow{"axismassLambdaFlow", {32, 1.08f, 1.16f}, "Inv. Mass (GeV)"}; - - AxisSpec axisMultiplicity{{0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "Centrality (%)"}; - AxisSpec axisOmegaminusMass = {80, 1.63f, 1.71f, "Inv. Mass (GeV)"}; - AxisSpec axisXiminusMass = {70, 1.3f, 1.37f, "Inv. Mass (GeV)"}; - AxisSpec axisK0sMass = {400, 0.4f, 0.6f, "Inv. Mass (GeV)"}; - AxisSpec axisLambdaMass = {160, 1.08f, 1.16f, "Inv. Mass (GeV)"}; - - Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; - Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtPOIMin) && (aod::track::pt < cfgCutPtPOIMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); - - // Connect to ccdb - Service ccdb; - O2_DEFINE_CONFIGURABLE(cfgnolaterthan, int64_t, std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object") - O2_DEFINE_CONFIGURABLE(cfgurl, std::string, "http://alice-ccdb.cern.ch", "url of the ccdb repository") - - // Define output - HistogramRegistry registry{"registry"}; - OutputObj fWeightsREF{GFWWeights("weightsREF")}; - OutputObj fWeightsK0s{GFWWeights("weightsK0s")}; - OutputObj fWeightsLambda{GFWWeights("weightsLambda")}; - OutputObj fWeightsXi{GFWWeights("weightsXiMinus")}; - OutputObj fWeightsOmega{GFWWeights("weightsOmegaMinus")}; - - // define global variables - GFW* fGFW = new GFW(); // GFW class used from main src - std::vector corrconfigs; - std::vector cfgAcceptance = cfgAcceptancePath; - std::vector cfgEfficiency = cfgEfficiencyPath; - - std::vector mEfficiency; - std::vector mAcceptance; - bool correctionsLoaded = false; - - TF1* fMultPVCutLow = nullptr; - TF1* fMultPVCutHigh = nullptr; - TF1* fMultCutLow = nullptr; - TF1* fMultCutHigh = nullptr; - TF1* fT0AV0AMean = nullptr; - TF1* fT0AV0ASigma = nullptr; - - using TracksPID = soa::Join; - using aodTracks = soa::Filtered>; // tracks filter - using aodCollisions = soa::Filtered>; // collisions filter - using DaughterTracks = soa::Join; - - // Declare the pt, mult and phi Axis; - int nPtBins = 0; - TAxis* fPtAxis = nullptr; - - int nXiPtBins = 0; - TAxis* fXiPtAxis = nullptr; - - int nV0PtBins = 0; - TAxis* fV0PtAxis = nullptr; - - int nMultBins = 0; - TAxis* fMultAxis = nullptr; - - int nPhiBins = 60; - TAxis* fPhiAxis = new TAxis(nPhiBins, 0, constants::math::TwoPI); - - TAxis* fOmegaMass = nullptr; - - TAxis* fXiMass = nullptr; - - TAxis* fK0sMass = nullptr; - - TAxis* fLambdaMass = nullptr; - - void init(InitContext const&) // Initialization - { - ccdb->setURL(cfgurl.value); - ccdb->setCaching(true); - ccdb->setCreatedNotAfter(cfgnolaterthan.value); - - // Add some output objects to the histogram registry - registry.add("hPhi", "", {HistType::kTH1D, {cfgaxisPhi}}); - registry.add("hEta", "", {HistType::kTH1D, {cfgaxisEta}}); - registry.add("hVtxZ", "", {HistType::kTH1D, {cfgaxisVertex}}); - registry.add("hMult", "", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); - registry.add("hCent", "", {HistType::kTH1D, {{90, 0, 90}}}); - registry.add("hPt", "", {HistType::kTH1D, {cfgaxisPt}}); - registry.add("hEtaPhiVtxzREF", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); - registry.add("hEtaPhiVtxzPOIXi", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); - registry.add("hEtaPhiVtxzPOIOmega", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); - registry.add("hEtaPhiVtxzPOIK0s", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); - registry.add("hEtaPhiVtxzPOILambda", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); - registry.add("hEventCount", "", {HistType::kTH2D, {{4, 0, 4}, {4, 0, 4}}}); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(1, "Filtered event"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(2, "after sel8"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(3, "before topological cut"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(4, "after topological cut"); - registry.get(HIST("hEventCount"))->GetYaxis()->SetBinLabel(1, "K0s"); - registry.get(HIST("hEventCount"))->GetYaxis()->SetBinLabel(2, "Lambda"); - registry.get(HIST("hEventCount"))->GetYaxis()->SetBinLabel(3, "XiMinus"); - registry.get(HIST("hEventCount"))->GetYaxis()->SetBinLabel(4, "Omega"); - - // QA - registry.add("hqaV0radiusbefore", "", {HistType::kTH1D, {{200, 0, 200}}}); - registry.add("hqaV0radiusafter", "", {HistType::kTH1D, {{200, 0, 200}}}); - registry.add("hqaV0cosPAbefore", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); - registry.add("hqaV0cosPAafter", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); - registry.add("hqadcaV0daubefore", "", {HistType::kTH1D, {{100, 0, 1}}}); - registry.add("hqadcaV0dauafter", "", {HistType::kTH1D, {{100, 0, 1}}}); - registry.add("hqaarm_podobefore", "", {HistType::kTH2D, {{100, -1, 1}, {50, 0, 0.3}}}); - registry.add("hqaarm_podoafter", "", {HistType::kTH2D, {{100, -1, 1}, {50, 0, 0.3}}}); - registry.add("hqadcapostoPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); - registry.add("hqadcapostoPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); - registry.add("hqadcanegtoPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); - registry.add("hqadcanegtoPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); - - // cumulant of flow - registry.add("c22", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); - registry.add("c24", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); - registry.add("K0sc22", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); - registry.add("Lambdac22", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); - registry.add("c22dpt", ";Centrality (%) ; C_{2}{2}", {HistType::kTProfile2D, {cfgaxisPt, axisMultiplicity}}); - registry.add("c24dpt", ";Centrality (%) ; C_{2}{4}", {HistType::kTProfile2D, {cfgaxisPt, axisMultiplicity}}); - // pt-diff cumulant of flow - registry.add("Xic22dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiminusMassforflow, axisMultiplicity}}); - registry.add("Omegac22dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisOmegaminusMassforflow, axisMultiplicity}}); - registry.add("K0sc22dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtV0, cfgaxisK0sMassforflow, axisMultiplicity}}); - registry.add("Lambdac22dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtV0, cfgaxisLambdaMassforflow, axisMultiplicity}}); - registry.add("Xic24dpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiminusMassforflow, axisMultiplicity}}); - registry.add("Omegac24dpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisOmegaminusMassforflow, axisMultiplicity}}); - registry.add("K0sc24dpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtV0, cfgaxisK0sMassforflow, axisMultiplicity}}); - registry.add("Lambdac24dpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtV0, cfgaxisLambdaMassforflow, axisMultiplicity}}); - // for Jackknife - for (int i = 1; i <= 10; i++) { - REFc22[i - 1] = registry.add(Form("Jackknife/REF/c22_%d", i), ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); - REFc24[i - 1] = registry.add(Form("Jackknife/REF/c24_%d", i), ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); - Xic22[i - 1] = registry.add(Form("Jackknife/Xi/Xic22dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiminusMassforflow, axisMultiplicity}}); - Omegac22[i - 1] = registry.add(Form("Jackknife/Omega/Omegac22dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisOmegaminusMassforflow, axisMultiplicity}}); - K0sc22[i - 1] = registry.add(Form("Jackknife/K0s/K0sc22dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtV0, cfgaxisK0sMassforflow, axisMultiplicity}}); - Lambdac22[i - 1] = registry.add(Form("Jackknife/Lambda/Lambdac22dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtV0, cfgaxisLambdaMassforflow, axisMultiplicity}}); - Xic24[i - 1] = registry.add(Form("Jackknife/Xi/Xic24dpt_%d", i), ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiminusMassforflow, axisMultiplicity}}); - Omegac24[i - 1] = registry.add(Form("Jackknife/Omega/Omegac24dpt_%d", i), ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisOmegaminusMassforflow, axisMultiplicity}}); - K0sc24[i - 1] = registry.add(Form("Jackknife/K0s/K0sc24dpt_%d", i), ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtV0, cfgaxisK0sMassforflow, axisMultiplicity}}); - Lambdac24[i - 1] = registry.add(Form("Jackknife/Lambda/Lambdac24dpt_%d", i), ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtV0, cfgaxisLambdaMassforflow, axisMultiplicity}}); - } - // InvMass(GeV) of casc and v0 - registry.add("InvMassXiMinus_all", "", {HistType::kTHnSparseF, {cfgaxisPtXi, axisXiminusMass, cfgaxisEta, axisMultiplicity}}); - registry.add("InvMassOmegaMinus_all", "", {HistType::kTHnSparseF, {cfgaxisPtXi, axisOmegaminusMass, cfgaxisEta, axisMultiplicity}}); - registry.add("InvMassOmegaMinus", "", {HistType::kTHnSparseF, {cfgaxisPtXi, axisOmegaminusMass, cfgaxisEta, axisMultiplicity}}); - registry.add("InvMassXiMinus", "", {HistType::kTHnSparseF, {cfgaxisPtXi, axisXiminusMass, cfgaxisEta, axisMultiplicity}}); - registry.add("InvMassK0s_all", "", {HistType::kTHnSparseF, {cfgaxisPtV0, axisK0sMass, cfgaxisEta, axisMultiplicity}}); - registry.add("InvMassLambda_all", "", {HistType::kTHnSparseF, {cfgaxisPtV0, axisLambdaMass, cfgaxisEta, axisMultiplicity}}); - registry.add("InvMassK0s", "", {HistType::kTHnSparseF, {cfgaxisPtV0, axisK0sMass, cfgaxisEta, axisMultiplicity}}); - registry.add("InvMassLambda", "", {HistType::kTHnSparseF, {cfgaxisPtV0, axisLambdaMass, cfgaxisEta, axisMultiplicity}}); - - // Set the pt, mult and phi Axis; - o2::framework::AxisSpec axisPt = cfgaxisPt; - nPtBins = axisPt.binEdges.size() - 1; - fPtAxis = new TAxis(nPtBins, &(axisPt.binEdges)[0]); - - o2::framework::AxisSpec axisXiPt = cfgaxisPtXi; - nXiPtBins = axisXiPt.binEdges.size() - 1; - fXiPtAxis = new TAxis(nXiPtBins, &(axisXiPt.binEdges)[0]); - - o2::framework::AxisSpec axisV0Pt = cfgaxisPtV0; - nV0PtBins = axisV0Pt.binEdges.size() - 1; - fV0PtAxis = new TAxis(nV0PtBins, &(axisV0Pt.binEdges)[0]); - - o2::framework::AxisSpec axisMult = axisMultiplicity; - nMultBins = axisMult.binEdges.size() - 1; - fMultAxis = new TAxis(nMultBins, &(axisMult.binEdges)[0]); - - fOmegaMass = new TAxis(cfgOmegaMassbins, 1.63, 1.71); - - fXiMass = new TAxis(cfgXiMassbins, 1.3, 1.37); - - fK0sMass = new TAxis(cfgK0sMassbins, 0.4, 0.6); - - fLambdaMass = new TAxis(cfgLambdaMassbins, 1.08, 1.16); - - fGFW->AddRegion("reffull", -0.8, 0.8, 1, 1); // ("name", etamin, etamax, ptbinnum, bitmask)eta region -0.8 to 0.8 - fGFW->AddRegion("refN10", -0.8, -0.4, 1, 1); - fGFW->AddRegion("refP10", 0.4, 0.8, 1, 1); - // POI - fGFW->AddRegion("poiN10dpt", -0.8, -0.4, nPtBins, 32); - fGFW->AddRegion("poiP10dpt", 0.4, 0.8, nPtBins, 32); - fGFW->AddRegion("poifulldpt", -0.8, 0.8, nPtBins, 32); - fGFW->AddRegion("poioldpt", -0.8, 0.8, nPtBins, 1); - int nXiptMassBins = nXiPtBins * cfgXiMassbins; - fGFW->AddRegion("poiXiPdpt", 0.4, 0.8, nXiptMassBins, 2); - fGFW->AddRegion("poiXiNdpt", -0.8, -0.4, nXiptMassBins, 2); - fGFW->AddRegion("poiXifulldpt", -0.8, 0.8, nXiptMassBins, 2); - fGFW->AddRegion("poiXiP", 0.4, 0.8, 1, 2); - fGFW->AddRegion("poiXiN", -0.8, -0.4, 1, 2); - int nOmegaptMassBins = nXiPtBins * cfgOmegaMassbins; - fGFW->AddRegion("poiOmegaPdpt", 0.4, 0.8, nOmegaptMassBins, 4); - fGFW->AddRegion("poiOmegaNdpt", -0.8, -0.4, nOmegaptMassBins, 4); - fGFW->AddRegion("poiOmegafulldpt", -0.8, 0.8, nOmegaptMassBins, 4); - fGFW->AddRegion("poiOmegaP", 0.4, 0.8, 1, 4); - fGFW->AddRegion("poiOmegaN", -0.8, -0.4, 1, 4); - int nK0sptMassBins = nV0PtBins * cfgK0sMassbins; - fGFW->AddRegion("poiK0sPdpt", 0.4, 0.8, nK0sptMassBins, 8); - fGFW->AddRegion("poiK0sNdpt", -0.8, -0.4, nK0sptMassBins, 8); - fGFW->AddRegion("poiK0sfulldpt", -0.8, 0.8, nK0sptMassBins, 8); - fGFW->AddRegion("poiK0sP", 0.4, 0.8, 1, 8); - fGFW->AddRegion("poiK0sN", -0.8, 0.4, 1, 8); - int nLambdaptMassBins = nV0PtBins * cfgLambdaMassbins; - fGFW->AddRegion("poiLambdaPdpt", 0.4, 0.8, nLambdaptMassBins, 16); - fGFW->AddRegion("poiLambdaNdpt", -0.8, -0.4, nLambdaptMassBins, 16); - fGFW->AddRegion("poiLambdafulldpt", -0.8, 0.8, nLambdaptMassBins, 16); - fGFW->AddRegion("poiLambdaP", 0.4, 0.8, 1, 16); - fGFW->AddRegion("poiLambdaN", -0.8, -0.4, 1, 16); - // pushback - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiP10dpt {2} refN10 {-2}", "Poi10Gap22dpta", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10dpt {2} refP10 {-2}", "Poi10Gap22dptb", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifulldpt reffull | poioldpt {2 2 -2 -2}", "Poi10Gap24dpt", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiPdpt {2} refN10 {-2}", "Xi10Gap22a", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiNdpt {2} refP10 {-2}", "Xi10Gap22b", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXifulldpt reffull {2 2 -2 -2}", "Xi10Gap24", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaPdpt {2} refN10 {-2}", "Omega10Gap22a", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaNdpt {2} refP10 {-2}", "Omega10Gap22b", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegafulldpt reffull {2 2 -2 -2}", "Xi10Gap24", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sPdpt {2} refN10 {-2}", "K0short10Gap22a", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sNdpt {2} refP10 {-2}", "K0short10Gap22b", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sfulldpt reffull {2 2 -2 -2}", "Xi10Gap24", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaPdpt {2} refN10 {-2}", "Lambda10Gap22a", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaNdpt {2} refP10 {-2}", "Lambda10Gap22b", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdafulldpt reffull {2 2 -2 -2}", "Xi10Gap24a", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("refP10 {2} refN10 {-2}", "Ref10Gap22a", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("reffull reffull {2 2 -2 -2}", "Ref10Gap24", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sP {2} refN10 {-2}", "K0s10Gap22inta", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sN {2} refP10 {-2}", "K0s10Gap22intb", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaP {2} refN10 {-2}", "Lambda10Gap22inta", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaN {2} refP10 {-2}", "Lambda10Gap22intb", kFALSE)); - fGFW->CreateRegions(); // finalize the initialization - - // used for event selection - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6must ]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); - fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); - fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); - fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); - - // fWeight output - if (cfgOutputNUAWeights) { - fWeightsREF->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsREF->Init(true, false); - fWeightsK0s->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsK0s->Init(true, false); - fWeightsLambda->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsLambda->Init(true, false); - fWeightsXi->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsXi->Init(true, false); - fWeightsOmega->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsOmega->Init(true, false); - } - } - - // input HIST("name") - template - void FillProfile(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const double& cent) - { - double dnx, val; - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; - if (!corrconf.pTDif) { - val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; - if (std::fabs(val) < 1) - registry.fill(tarName, cent, val, dnx); - return; - } - return; - } - - // input shared_ptr - void FillProfile(const GFW::CorrConfig& corrconf, std::shared_ptr TProfile, const double& cent) - { - double dnx, val; - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; - if (!corrconf.pTDif) { - val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; - if (std::fabs(val) < 1) - TProfile->Fill(cent, val, dnx); - return; - } - return; - } - - template - void FillProfilepT(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const int& ptbin, const double& cent) - { - float dnx = 0; - float val = 0; - dnx = fGFW->Calculate(corrconf, ptbin - 1, kTRUE).real(); - if (dnx == 0) - return; - val = fGFW->Calculate(corrconf, ptbin - 1, kFALSE).real() / dnx; - if (std::fabs(val) < 1) { - registry.fill(tarName, fPtAxis->GetBinCenter(ptbin), cent, val, dnx); - } - return; - } - - // input HIST("name") - template - void FillProfilepTMass(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const int& ptbin, const int& PDGCode, const float& cent) - { - int nMassBins = 0; - int nptbins = 0; - TAxis* fMass = nullptr; - TAxis* fpt = nullptr; - if (PDGCode == kXiMinus) { - nMassBins = cfgXiMassbins; - nptbins = nXiPtBins; - fpt = fXiPtAxis; - fMass = fXiMass; - } else if (PDGCode == kOmegaMinus) { - nMassBins = cfgOmegaMassbins; - nptbins = nXiPtBins; - fpt = fXiPtAxis; - fMass = fOmegaMass; - } else if (PDGCode == kK0Short) { - nMassBins = cfgK0sMassbins; - nptbins = nV0PtBins; - fpt = fV0PtAxis; - fMass = fK0sMass; - } else if (PDGCode == kLambda0) { - nMassBins = cfgLambdaMassbins; - nptbins = nV0PtBins; - fpt = fV0PtAxis; - fMass = fLambdaMass; - } else { - LOGF(error, "Error, please put in correct PDGCode of K0s, Lambda, Xi or Omega"); - return; - } - for (int massbin = 1; massbin <= nMassBins; massbin++) { - float dnx = 0; - float val = 0; - dnx = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kTRUE).real(); - if (dnx == 0) - continue; - val = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kFALSE).real() / dnx; - if (std::fabs(val) < 1) { - registry.fill(tarName, fpt->GetBinCenter(ptbin), fMass->GetBinCenter(massbin), cent, val, dnx); - } - } - return; - } - - // input shared_ptr - void FillProfilepTMass(const GFW::CorrConfig& corrconf, std::shared_ptr TProfile3D, const int& ptbin, const int& PDGCode, const float& cent) - { - int nMassBins = 0; - int nptbins = 0; - TAxis* fMass = nullptr; - TAxis* fpt = nullptr; - if (PDGCode == kXiMinus) { - nMassBins = cfgXiMassbins; - nptbins = nXiPtBins; - fpt = fXiPtAxis; - fMass = fXiMass; - } else if (PDGCode == kOmegaMinus) { - nMassBins = cfgOmegaMassbins; - nptbins = nXiPtBins; - fpt = fXiPtAxis; - fMass = fOmegaMass; - } else if (PDGCode == kK0Short) { - nMassBins = cfgK0sMassbins; - nptbins = nV0PtBins; - fpt = fV0PtAxis; - fMass = fK0sMass; - } else if (PDGCode == kLambda0) { - nMassBins = cfgLambdaMassbins; - nptbins = nV0PtBins; - fpt = fV0PtAxis; - fMass = fLambdaMass; - } else { - LOGF(error, "Error, please put in correct PDGCode of K0s, Lambda, Xi or Omega"); - return; - } - for (int massbin = 1; massbin <= nMassBins; massbin++) { - float dnx = 0; - float val = 0; - dnx = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kTRUE).real(); - if (dnx == 0) - continue; - val = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kFALSE).real() / dnx; - if (std::fabs(val) < 1) { - TProfile3D->Fill(fpt->GetBinCenter(ptbin), fMass->GetBinCenter(massbin), cent, val, dnx); - } - } - return; - } - - void loadCorrections(uint64_t timestamp) - { - if (correctionsLoaded) - return; - if (cfgAcceptance.size() == 5) { - for (int i = 0; i <= 4; i++) { - mAcceptance.push_back(ccdb->getForTimeStamp(cfgAcceptance[i], timestamp)); - } - if (mAcceptance.size() == 5) - LOGF(info, "Loaded acceptance weights"); - else - LOGF(warning, "Could not load acceptance weights"); - } - if (cfgEfficiency.size() == 5) { - for (int i = 0; i <= 4; i++) { - mAcceptance.push_back(ccdb->getForTimeStamp(cfgAcceptance[i], timestamp)); - } - if (mEfficiency.size() == 5) - LOGF(info, "Loaded efficiency histogram"); - else - LOGF(fatal, "Could not load efficiency histogram"); - } - correctionsLoaded = true; - } - - template - bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, TrackObject track, float vtxz, int ispecies) - { - float eff = 1.; - if (mEfficiency.size() == 5) - eff = mEfficiency[ispecies]->GetBinContent(mEfficiency[ispecies]->FindBin(track.pt())); - else - eff = 1.0; - if (eff == 0) - return false; - weight_nue = 1. / eff; - if (mAcceptance.size() == 5) - weight_nua = mAcceptance[ispecies]->GetNUA(track.phi(), track.eta(), vtxz); - else - weight_nua = 1; - return true; - } - // event selection - template - bool eventSelected(TCollision collision, const int multTrk, const float centrality) - { - if (collision.alias_bit(kTVXinTRD)) { - // TRD triggered - return false; - } - if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - // reject collisions close to Time Frame borders - // https://its.cern.ch/jira/browse/O2-4623 - return false; - } - if (!collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - // reject events affected by the ITS ROF border - // https://its.cern.ch/jira/browse/O2-4309 - return false; - } - if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - // rejects collisions which are associated with the same "found-by-T0" bunch crossing - // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof - return false; - } - if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference - // use this cut at low multiplicities with caution - return false; - } - if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - // no collisions in specified time range - return 0; - } - float vtxz = -999; - if (collision.numContrib() > 1) { - vtxz = collision.posZ(); - float zRes = TMath::Sqrt(collision.covZZ()); - if (zRes > 0.25 && collision.numContrib() < 20) - vtxz = -999; - } - auto multNTracksPV = collision.multNTracksPV(); - auto occupancy = collision.trackOccupancyInTimeRange(); - - if (std::fabs(vtxz) > cfgCutVertex) - return false; - if (multNTracksPV < fMultPVCutLow->Eval(centrality)) - return false; - if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) - return false; - if (multTrk < fMultCutLow->Eval(centrality)) - return false; - if (multTrk > fMultCutHigh->Eval(centrality)) - return false; - if (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh) - return 0; - - // V0A T0A 5 sigma cut - if (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > 5 * fT0AV0ASigma->Eval(collision.multFT0A())) - return 0; - - return true; - } - - void process(aodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks, aod::CascDataExt const& Cascades, aod::V0Datas const& V0s, DaughterTracks&) - { - int Ntot = tracks.size(); - int CandNum_all[4] = {0, 0, 0, 0}; - int CandNum[4] = {0, 0, 0, 0}; - for (int i = 0; i < 4; i++) { - registry.fill(HIST("hEventCount"), 0.5, i + 0.5); - } - if (Ntot < 1) - return; - fGFW->Clear(); - const auto cent = collision.centFT0C(); - if (!collision.sel8()) - return; - if (eventSelected(collision, tracks.size(), cent)) - return; - auto bc = collision.bc_as(); - loadCorrections(bc.timestamp()); - float vtxz = collision.posZ(); - registry.fill(HIST("hVtxZ"), vtxz); - registry.fill(HIST("hMult"), Ntot); - registry.fill(HIST("hCent"), collision.centFT0C()); - for (int i = 0; i < 4; i++) { - registry.fill(HIST("hEventCount"), 1.5, i + 0.5); - } - - float weff = 1; - float wacc = 1; - // fill GFW ref flow - for (auto& track : tracks) { - if (!setCurrentParticleWeights(weff, wacc, track, vtxz, 0)) - continue; - registry.fill(HIST("hPhi"), track.phi()); - registry.fill(HIST("hEta"), track.eta()); - registry.fill(HIST("hEtaPhiVtxzREF"), track.phi(), track.eta(), vtxz, wacc); - registry.fill(HIST("hPt"), track.pt()); - int ptbin = fPtAxis->FindBin(track.pt()) - 1; - if ((track.pt() > cfgCutPtMin) && (track.pt() < cfgCutPtMax)) { - fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 1); //(eta, ptbin, phi, wacc*weff, bitmask) - } - if ((track.pt() > cfgCutPtPOIMin) && (track.pt() < cfgCutPtPOIMax)) { - fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 32); - } - if (cfgOutputNUAWeights) - fWeightsREF->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); - } - // fill GFW of V0 flow - for (auto& v0 : V0s) { - auto v0posdau = v0.posTrack_as(); - auto v0negdau = v0.negTrack_as(); - // check tpc - int PDGCode = 0; - // fill QA - registry.fill(HIST("hqaarm_podobefore"), v0.alpha(), v0.qtarm()); - // check daughter TPC and TOF - if (v0.qtarm() / std::fabs(v0.alpha()) > cfgv0_ArmPodocut && - (!cfgcheckDauTPC || (std::fabs(v0posdau.tpcNSigmaPi()) < cfgtpcNSigmaCascPion && std::fabs(v0negdau.tpcNSigmaPi()) < cfgtpcNSigmaCascPion)) && - (!cfgcheckDauTOF || (std::fabs(v0posdau.tofNSigmaPi()) < cfgtofNSigmaCascPion && std::fabs(v0negdau.tofNSigmaPi()) < cfgtofNSigmaCascPion))) { - registry.fill(HIST("InvMassK0s_all"), v0.pt(), v0.mK0Short(), v0.eta(), cent); - if (!setCurrentParticleWeights(weff, wacc, v0, vtxz, 1)) - continue; - PDGCode = kK0Short; - CandNum_all[0] = CandNum_all[0] + 1; - registry.fill(HIST("hqaarm_podoafter"), v0.alpha(), v0.qtarm()); - } else if ((!cfgcheckDauTPC || (std::fabs(v0posdau.tpcNSigmaPr()) < cfgtpcNSigmaCascProton && std::fabs(v0negdau.tpcNSigmaPi()) < cfgtpcNSigmaCascPion)) && - (!cfgcheckDauTOF || (std::fabs(v0posdau.tofNSigmaPr()) < cfgtofNSigmaCascProton && std::fabs(v0negdau.tofNSigmaPi()) < cfgtofNSigmaCascPion))) { - registry.fill(HIST("InvMassLambda_all"), v0.pt(), v0.mLambda(), v0.eta(), cent); - if (!setCurrentParticleWeights(weff, wacc, v0, vtxz, 2)) - continue; - PDGCode = kLambda0; - CandNum_all[1] = CandNum_all[1] + 1; - } - // fill QA before cut - registry.fill(HIST("hqaV0radiusbefore"), v0.v0radius()); - registry.fill(HIST("hqaV0cosPAbefore"), v0.v0cosPA()); - registry.fill(HIST("hqadcaV0daubefore"), v0.dcaV0daughters()); - registry.fill(HIST("hqadcapostoPVbefore"), v0.dcapostopv()); - registry.fill(HIST("hqadcanegtoPVbefore"), v0.dcanegtopv()); - - // track quality check - if (v0posdau.tpcNClsFound() < cfgtpcclusters) - continue; - if (v0negdau.tpcNClsFound() < cfgtpcclusters) - continue; - if (v0posdau.tpcNClsFindable() < cfgtpcclufindable) - continue; - if (v0negdau.tpcNClsFindable() < cfgtpcclufindable) - continue; - if (v0posdau.tpcCrossedRowsOverFindableCls() < cfgtpccrossoverfindable) - continue; - if (v0posdau.itsNCls() < cfgitsclusters) - continue; - if (v0negdau.itsNCls() < cfgitsclusters) - continue; - // topological cut - if (v0.v0radius() < cfgv0_radius) - continue; - if (v0.v0cosPA() < cfgv0_v0cospa) - continue; - if (v0.dcaV0daughters() > cfgv0_dcav0dau) - continue; - if (std::fabs(v0.dcapostopv()) < cfgv0_dcadautopv) - continue; - if (std::fabs(v0.dcanegtopv()) < cfgv0_dcadautopv) - continue; - // fill QA after cut - registry.fill(HIST("hqaV0radiusafter"), v0.v0radius()); - registry.fill(HIST("hqaV0cosPAafter"), v0.v0cosPA()); - registry.fill(HIST("hqadcaV0dauafter"), v0.dcaV0daughters()); - registry.fill(HIST("hqadcapostoPVafter"), v0.dcapostopv()); - registry.fill(HIST("hqadcanegtoPVafter"), v0.dcanegtopv()); - if (PDGCode == kK0Short) { - if (std::fabs(v0.mK0Short() - o2::constants::physics::MassK0Short) < cfgv0_mk0swindow) { - CandNum[0] = CandNum[0] + 1; - registry.fill(HIST("InvMassK0s"), v0.pt(), v0.mK0Short(), v0.eta(), cent); - registry.fill(HIST("hEtaPhiVtxzPOIK0s"), v0.phi(), v0.eta(), vtxz, wacc); - fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fK0sMass->FindBin(v0.mK0Short()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 8); - if (cfgOutputNUAWeights) - fWeightsK0s->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); - } - } else if (PDGCode == kLambda0) { - if (std::fabs(v0.mLambda() - o2::constants::physics::MassLambda0) < cfgv0_mlambdawindow) { - CandNum[1] = CandNum[1] + 1; - registry.fill(HIST("InvMassLambda"), v0.pt(), v0.mLambda(), v0.eta(), cent); - registry.fill(HIST("hEtaPhiVtxzPOILambda"), v0.phi(), v0.eta(), vtxz, wacc); - fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fLambdaMass->FindBin(v0.mLambda()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 16); - if (cfgOutputNUAWeights) - fWeightsLambda->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); - } - } - } - // fill GFW of casc flow - for (auto& casc : Cascades) { - auto bachelor = casc.bachelor_as(); - auto posdau = casc.posTrack_as(); - auto negdau = casc.negTrack_as(); - // check TPC - if (cfgcheckDauTPC && (!posdau.hasTPC() || !negdau.hasTPC() || !bachelor.hasTPC())) { - continue; - } - int PDGCode = 0; - if (casc.sign() < 0 && std::fabs(casc.yOmega()) < cfgCasc_rapidity && std::fabs(bachelor.tpcNSigmaKa()) < cfgtpcNSigmaCascKaon && std::fabs(posdau.tpcNSigmaPr()) < cfgtpcNSigmaCascProton && std::fabs(negdau.tpcNSigmaPi()) < cfgtpcNSigmaCascPion && std::fabs(bachelor.tofNSigmaKa()) < cfgtofNSigmaCascKaon && std::fabs(posdau.tofNSigmaPr()) < cfgtofNSigmaCascProton && std::fabs(negdau.tofNSigmaPi()) < cfgtofNSigmaCascPion) { - registry.fill(HIST("InvMassOmegaMinus_all"), casc.pt(), casc.mOmega(), casc.eta(), cent); - if (!setCurrentParticleWeights(weff, wacc, casc, vtxz, 4)) - continue; - PDGCode = kOmegaMinus; - CandNum_all[3] = CandNum_all[3] + 1; - } else if (casc.sign() < 0 && std::fabs(casc.yXi()) < cfgCasc_rapidity && std::fabs(bachelor.tpcNSigmaPi()) < cfgtpcNSigmaCascPion && std::fabs(posdau.tpcNSigmaPr()) < cfgtpcNSigmaCascProton && std::fabs(negdau.tpcNSigmaPi()) < cfgtpcNSigmaCascPion && std::fabs(bachelor.tofNSigmaPi()) < cfgtofNSigmaCascPion && std::fabs(posdau.tofNSigmaPr()) < cfgtofNSigmaCascProton && std::fabs(negdau.tofNSigmaPi()) < cfgtofNSigmaCascPion) { - registry.fill(HIST("InvMassXiMinus_all"), casc.pt(), casc.mXi(), casc.eta(), cent); - if (!setCurrentParticleWeights(weff, wacc, casc, vtxz, 3)) - continue; - PDGCode = kXiMinus; - CandNum_all[2] = CandNum_all[2] + 1; - } else { - continue; - } - // topological cut - if (casc.cascradius() < cfgcasc_radius) - continue; - if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cfgcasc_casccospa) - continue; - if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cfgcasc_v0cospa) - continue; - if (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) < cfgcasc_dcav0topv) - continue; - if (casc.dcabachtopv() < cfgcasc_dcabachtopv) - continue; - if (casc.dcacascdaughters() > cfgcasc_dcacascdau) - continue; - if (casc.dcaV0daughters() > cfgcasc_dcav0dau) - continue; - if (std::fabs(casc.mLambda() - o2::constants::physics::MassLambda0) > cfgcasc_mlambdawindow) - continue; - // track quality check - if (bachelor.tpcNClsFound() < cfgtpcclusters) - continue; - if (posdau.tpcNClsFound() < cfgtpcclusters) - continue; - if (negdau.tpcNClsFound() < cfgtpcclusters) - continue; - if (bachelor.itsNCls() < cfgitsclusters) - continue; - if (posdau.itsNCls() < cfgitsclusters) - continue; - if (negdau.itsNCls() < cfgitsclusters) - continue; - if (PDGCode == kOmegaMinus) { - CandNum[3] = CandNum[3] + 1; - registry.fill(HIST("hEtaPhiVtxzPOIOmega"), casc.phi(), casc.eta(), vtxz, wacc); - registry.fill(HIST("InvMassOmegaMinus"), casc.pt(), casc.mOmega(), casc.eta(), cent); - if ((casc.pt() < cfgCutPtPOIMax) && (casc.pt() > cfgCutPtPOIMin) && (casc.mOmega() > 1.63) && (casc.mOmega() < 1.71)) { - fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fOmegaMass->FindBin(casc.mOmega()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 4); - } - if (cfgOutputNUAWeights) - fWeightsOmega->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); - } - if (PDGCode == kXiMinus) { - CandNum[2] = CandNum[2] + 1; - registry.fill(HIST("hEtaPhiVtxzPOIXi"), casc.phi(), casc.eta(), vtxz, wacc); - registry.fill(HIST("InvMassXiMinus"), casc.pt(), casc.mXi(), casc.eta(), cent); - if ((casc.pt() < cfgCutPtPOIMax) && (casc.pt() > cfgCutPtPOIMin) && (casc.mXi() > 1.30) && (casc.mXi() < 1.37)) { - fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fXiMass->FindBin(casc.mXi()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 2); - } - if (cfgOutputNUAWeights) - fWeightsXi->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); - } - } - for (int i = 0; i < 4; i++) { - if (CandNum_all[i] > 0) { - registry.fill(HIST("hEventCount"), 2.5, i + 0.5); - } - if (CandNum[i] > 0) { - registry.fill(HIST("hEventCount"), 3.5, i + 0.5); - } - } - // Filling cumulant with ROOT TProfile and loop for all ptBins - FillProfile(corrconfigs.at(15), HIST("c22"), cent); - FillProfile(corrconfigs.at(16), HIST("c24"), cent); - FillProfile(corrconfigs.at(17), HIST("K0sc22"), cent); - FillProfile(corrconfigs.at(18), HIST("K0sc22"), cent); - FillProfile(corrconfigs.at(19), HIST("Lambdac22"), cent); - FillProfile(corrconfigs.at(20), HIST("Lambdac22"), cent); - for (int i = 1; i <= nPtBins; i++) { - FillProfilepT(corrconfigs.at(0), HIST("c22dpt"), i, cent); - FillProfilepT(corrconfigs.at(1), HIST("c22dpt"), i, cent); - FillProfilepT(corrconfigs.at(2), HIST("c24dpt"), i, cent); - } - for (int i = 1; i <= nV0PtBins; i++) { - FillProfilepTMass(corrconfigs.at(9), HIST("K0sc22dpt"), i, kK0Short, cent); - FillProfilepTMass(corrconfigs.at(10), HIST("K0sc22dpt"), i, kK0Short, cent); - FillProfilepTMass(corrconfigs.at(11), HIST("K0sc24dpt"), i, kK0Short, cent); - FillProfilepTMass(corrconfigs.at(12), HIST("Lambdac22dpt"), i, kLambda0, cent); - FillProfilepTMass(corrconfigs.at(13), HIST("Lambdac22dpt"), i, kLambda0, cent); - FillProfilepTMass(corrconfigs.at(14), HIST("Lambdac24dpt"), i, kLambda0, cent); - } - for (int i = 1; i <= nXiPtBins; i++) { - FillProfilepTMass(corrconfigs.at(3), HIST("Xic22dpt"), i, kXiMinus, cent); - FillProfilepTMass(corrconfigs.at(4), HIST("Xic22dpt"), i, kXiMinus, cent); - FillProfilepTMass(corrconfigs.at(5), HIST("Xic24dpt"), i, kXiMinus, cent); - FillProfilepTMass(corrconfigs.at(6), HIST("Omegac22dpt"), i, kOmegaMinus, cent); - FillProfilepTMass(corrconfigs.at(7), HIST("Omegac22dpt"), i, kOmegaMinus, cent); - FillProfilepTMass(corrconfigs.at(8), HIST("Omegac24dpt"), i, kOmegaMinus, cent); - } - // Fill subevents flow - TRandom3* fRdm = new TRandom3(0); - double Eventrdm = 10 * fRdm->Rndm(); - for (int j = 1; j <= 10; j++) { - if (Eventrdm > (j - 1) && Eventrdm < j) - continue; - FillProfile(corrconfigs.at(15), REFc22[j - 1], cent); - FillProfile(corrconfigs.at(16), REFc24[j - 1], cent); - for (int i = 1; i <= nV0PtBins; i++) { - FillProfilepTMass(corrconfigs.at(9), K0sc22[j - 1], i, kK0Short, cent); - FillProfilepTMass(corrconfigs.at(10), K0sc22[j - 1], i, kK0Short, cent); - FillProfilepTMass(corrconfigs.at(11), K0sc24[j - 1], i, kK0Short, cent); - FillProfilepTMass(corrconfigs.at(12), Lambdac22[j - 1], i, kLambda0, cent); - FillProfilepTMass(corrconfigs.at(13), Lambdac22[j - 1], i, kLambda0, cent); - FillProfilepTMass(corrconfigs.at(14), Lambdac24[j - 1], i, kLambda0, cent); - } - for (int i = 1; i <= nXiPtBins; i++) { - FillProfilepTMass(corrconfigs.at(3), Xic22[j - 1], i, kXiMinus, cent); - FillProfilepTMass(corrconfigs.at(4), Xic22[j - 1], i, kXiMinus, cent); - FillProfilepTMass(corrconfigs.at(5), Xic24[j - 1], i, kXiMinus, cent); - FillProfilepTMass(corrconfigs.at(6), Omegac22[j - 1], i, kOmegaMinus, cent); - FillProfilepTMass(corrconfigs.at(7), Omegac22[j - 1], i, kOmegaMinus, cent); - FillProfilepTMass(corrconfigs.at(8), Omegac24[j - 1], i, kOmegaMinus, cent); - } - } - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGCF/Flow/Tasks/flowGfwOmegaXi.cxx b/PWGCF/Flow/Tasks/flowGfwOmegaXi.cxx new file mode 100644 index 00000000000..bf001b02df2 --- /dev/null +++ b/PWGCF/Flow/Tasks/flowGfwOmegaXi.cxx @@ -0,0 +1,1927 @@ +// 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. + +/// \file flowGfwOmegaXi.cxx +/// \author Fuchun Cui(fcui@cern.ch) +/// \since Sep/13/2024 +/// \brief This task is to caculate V0s and cascades flow by GenericFramework + +#include "GFW.h" +#include "GFWCumulant.h" +#include "GFWPowerArray.h" +#include "GFWWeights.h" + +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGMM/Mult/DataModel/Index.h" + +#include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" +#include + +#include "TList.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +namespace +{ +std::shared_ptr refc22[10]; +std::shared_ptr refc24[10]; +std::shared_ptr refc22Full[10]; +std::shared_ptr refc32[10]; +std::shared_ptr k0sc22[10]; +std::shared_ptr k0sc24[10]; +std::shared_ptr k0sc22Full[10]; +std::shared_ptr k0sc32[10]; +std::shared_ptr lambdac22[10]; +std::shared_ptr lambdac24[10]; +std::shared_ptr lambdac22Full[10]; +std::shared_ptr lambdac32[10]; +std::shared_ptr xic22[10]; +std::shared_ptr xic24[10]; +std::shared_ptr xic22Full[10]; +std::shared_ptr xic32[10]; +std::shared_ptr omegac22[10]; +std::shared_ptr omegac24[10]; +std::shared_ptr omegac22Full[10]; +std::shared_ptr omegac32[10]; +} // namespace + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +struct FlowGfwOmegaXi { + + O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgMassBins, std::vector, (std::vector{80, 32, 14, 16}), "Number of K0s, Lambda, Xi, Omega mass axis bins for c22") + O2_DEFINE_CONFIGURABLE(cfgDeltaPhiLocDen, int, 3, "Number of delta phi for local density, 200 bins in 2 pi") + + struct : ConfigurableGroup { + std::string prefix = "v0BuilderOpts"; + // topological cut for V0 + O2_DEFINE_CONFIGURABLE(cfgv0_radius, float, 5.0f, "minimum decay radius") + O2_DEFINE_CONFIGURABLE(cfgv0_v0cospa, float, 0.995f, "minimum cosine of pointing angle") + O2_DEFINE_CONFIGURABLE(cfgv0_dcadautopv, float, 0.1f, "minimum daughter DCA to PV") + O2_DEFINE_CONFIGURABLE(cfgv0_dcav0dau, float, 0.5f, "maximum DCA among V0 daughters") + O2_DEFINE_CONFIGURABLE(cfgv0_mk0swindow, float, 0.1f, "Invariant mass window of K0s") + O2_DEFINE_CONFIGURABLE(cfgv0_mlambdawindow, float, 0.04f, "Invariant mass window of lambda") + O2_DEFINE_CONFIGURABLE(cfgv0_ArmPodocut, float, 0.2f, "Armenteros Podolski cut for K0") + } v0BuilderOpts; + + struct : ConfigurableGroup { + std::string prefix = "cascBuilderOpts"; + // topological cut for cascade + O2_DEFINE_CONFIGURABLE(cfgcasc_radius, float, 0.5f, "minimum decay radius") + O2_DEFINE_CONFIGURABLE(cfgcasc_casccospa, float, 0.999f, "minimum cosine of pointing angle") + O2_DEFINE_CONFIGURABLE(cfgcasc_v0cospa, float, 0.998f, "minimum cosine of pointing angle") + O2_DEFINE_CONFIGURABLE(cfgcasc_dcav0topv, float, 0.01f, "minimum daughter DCA to PV") + O2_DEFINE_CONFIGURABLE(cfgcasc_dcabachtopv, float, 0.01f, "minimum bachelor DCA to PV") + O2_DEFINE_CONFIGURABLE(cfgcasc_dcacascdau, float, 0.3f, "maximum DCA among cascade daughters") + O2_DEFINE_CONFIGURABLE(cfgcasc_dcav0dau, float, 1.0f, "maximum DCA among V0 daughters") + O2_DEFINE_CONFIGURABLE(cfgcasc_mlambdawindow, float, 0.04f, "Invariant mass window of lambda") + O2_DEFINE_CONFIGURABLE(cfgcasc_compmassrej, float, 0.008f, "Invariant mass window of lambda") + } cascBuilderOpts; + + struct : ConfigurableGroup { + std::string prefix = "trkQualityOpts"; + // track selections + O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 10.0f, "Maximal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtDauMin, float, 0.2f, "Minimal pT for daughter tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtDauMax, float, 10.0f, "Maximal pT for daughter tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtK0sMin, float, 0.2f, "Minimal pT for K0s") + O2_DEFINE_CONFIGURABLE(cfgCutPtK0sMax, float, 10.0f, "Maximal pT for K0s") + O2_DEFINE_CONFIGURABLE(cfgCutPtLambdaMin, float, 0.2f, "Minimal pT for Lambda") + O2_DEFINE_CONFIGURABLE(cfgCutPtLambdaMax, float, 10.0f, "Maximal pT for Lambda") + O2_DEFINE_CONFIGURABLE(cfgCutPtXiMin, float, 0.2f, "Minimal pT for Xi") + O2_DEFINE_CONFIGURABLE(cfgCutPtXiMax, float, 10.0f, "Maximal pT for Xi") + O2_DEFINE_CONFIGURABLE(cfgCutPtOmegaMin, float, 0.2f, "Minimal pT for Omega") + O2_DEFINE_CONFIGURABLE(cfgCutPtOmegaMax, float, 10.0f, "Maximal pT for Omega") + O2_DEFINE_CONFIGURABLE(cfgCutPtPIDDauMin, float, 0.15f, "Minimal pT for daughter PID") + // track quality selections for daughter track + O2_DEFINE_CONFIGURABLE(cfgCheckITSNCls, bool, false, "check minimum number of ITS clusters") + O2_DEFINE_CONFIGURABLE(cfgCheckITSHits, bool, false, "check minimum number of ITS hits") + O2_DEFINE_CONFIGURABLE(cfgCheckITSChi2NDF, bool, false, "check ITS Chi2NDF") + O2_DEFINE_CONFIGURABLE(cfgCheckGlobalTrack, bool, false, "check global track") + } trkQualityOpts; + + struct : ConfigurableGroup { + std::string prefix = "evtSelOpts"; + O2_DEFINE_CONFIGURABLE(cfgDoTVXinTRD, bool, true, "check kTVXinTRD") + O2_DEFINE_CONFIGURABLE(cfgDoNoTimeFrameBorder, bool, true, "check kNoTimeFrameBorder") + O2_DEFINE_CONFIGURABLE(cfgDoNoITSROFrameBorder, bool, true, "check kNoITSROFrameBorder") + O2_DEFINE_CONFIGURABLE(cfgDoNoSameBunchPileup, bool, true, "check kNoITSROFrameBorder") + O2_DEFINE_CONFIGURABLE(cfgDoIsGoodZvtxFT0vsPV, bool, true, "check kIsGoodZvtxFT0vsPV") + O2_DEFINE_CONFIGURABLE(cfgDoNoCollInTimeRangeStandard, bool, true, "check kNoCollInTimeRangeStandard") + O2_DEFINE_CONFIGURABLE(cfgDoIsGoodITSLayersAll, bool, true, "check kIsGoodITSLayersAll") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgMultPVCut, int, 5, "Use apassX MultPVCut function or not (-1)") + O2_DEFINE_CONFIGURABLE(cfgDoV0AT0Acut, bool, true, "do V0A-T0A cut") + } evtSeleOpts; + + O2_DEFINE_CONFIGURABLE(cfgCasc_rapidity, float, 0.5, "rapidity") + O2_DEFINE_CONFIGURABLE(cfgNSigmapid, std::vector, (std::vector{9, 9, 9, 3, 3, 3, 3, 3, 3}), "tpc, tof and its NSigma for Pion Proton Kaon") + O2_DEFINE_CONFIGURABLE(cfgAcceptancePath, std::vector, (std::vector{"Users/f/fcui/NUA/NUAREFPartical", "Users/f/fcui/NUA/NUAK0s", "Users/f/fcui/NUA/NUALambda", "Users/f/fcui/NUA/NUAXi", "Users/f/fcui/NUA/NUAOmega"}), "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgEfficiencyPath, std::vector, (std::vector{"PathtoRef"}), "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgLocDenParaXi, std::vector, (std::vector{-0.000986187, -3.86861, -0.000912481, -3.29206, -0.000859271, -2.89389, -0.000817039, -2.61201, -0.000788792, -2.39079, -0.000780182, -2.19276, -0.000750457, -2.07205, -0.000720279, -1.96865, -0.00073247, -1.85642, -0.000695091, -1.82625, -0.000693332, -1.72679, -0.000681225, -1.74305, -0.000652818, -1.92608, -0.000618892, -2.31985}), "Local density efficiency function parameter for Xi, exp(Ax + B)") + O2_DEFINE_CONFIGURABLE(cfgLocDenParaOmega, std::vector, (std::vector{-0.000444324, -6.0424, -0.000566208, -5.42168, -0.000580338, -4.96967, -0.000721054, -4.41994, -0.000626394, -4.27934, -0.000652167, -3.9543, -0.000592327, -3.79053, -0.000544721, -3.73292, -0.000613419, -3.43849, -0.000402506, -3.47687, -0.000602687, -3.24491, -0.000460848, -3.056, -0.00039428, -2.35188, -0.00041908, -2.03642}), "Local density efficiency function parameter for Omega, exp(Ax + B)") + O2_DEFINE_CONFIGURABLE(cfgLocDenParaK0s, std::vector, (std::vector{-0.00043057, -3.2435, -0.000385085, -2.97687, -0.000350298, -2.81502, -0.000326159, -2.71091, -0.000299563, -2.65448, -0.000294284, -2.60865, -0.000277938, -2.589, -0.000277091, -2.56983, -0.000272783, -2.56825, -0.000252706, -2.58996, -0.000247834, -2.63158, -0.00024379, -2.76976, -0.000286468, -2.92484, -0.000310149, -3.27746}), "Local density efficiency function parameter for K0s, exp(Ax + B)") + O2_DEFINE_CONFIGURABLE(cfgLocDenParaLambda, std::vector, (std::vector{-0.000510948, -4.4846, -0.000460629, -4.14465, -0.000433729, -3.94173, -0.000412751, -3.81839, -0.000411211, -3.72502, -0.000401511, -3.68426, -0.000407461, -3.67005, -0.000379371, -3.71153, -0.000392828, -3.73214, -0.000403996, -3.80717, -0.000403376, -3.90917, -0.000354624, -4.34629, -0.000477606, -4.66307, -0.000541139, -4.61364}), "Local density efficiency function parameter for Lambda, exp(Ax + B)") + // switch + O2_DEFINE_CONFIGURABLE(cfgDoAccEffCorr, bool, false, "do acc and eff corr") + O2_DEFINE_CONFIGURABLE(cfgDoLocDenCorr, bool, false, "do local density corr") + O2_DEFINE_CONFIGURABLE(cfgDoJackknife, bool, false, "do jackknife") + O2_DEFINE_CONFIGURABLE(cfgOutputV0, bool, true, "Fill and output V0s flow") + O2_DEFINE_CONFIGURABLE(cfgOutputCasc, bool, true, "Fill and output cascades flow") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights") + O2_DEFINE_CONFIGURABLE(cfgOutputLocDenWeights, bool, false, "Fill and output local density weights") + O2_DEFINE_CONFIGURABLE(cfgOutputQA, bool, false, "do QA") + + ConfigurableAxis cfgaxisVertex{"cfgaxisVertex", {20, -10, 10}, "vertex axis for histograms"}; + ConfigurableAxis cfgaxisPhi{"cfgaxisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; + ConfigurableAxis cfgaxisEta{"cfgaxisEta", {40, -1., 1.}, "eta axis for histograms"}; + ConfigurableAxis cfgaxisPt{"cfgaxisPt", {VARIABLE_WIDTH, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00, 3.50, 4.00, 4.50, 5.00, 5.50, 6.00, 10.0}, "pt (GeV)"}; + ConfigurableAxis cfgaxisPtXi{"cfgaxisPtXi", {VARIABLE_WIDTH, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; + ConfigurableAxis cfgaxisPtOmega{"cfgaxisPtOmega", {VARIABLE_WIDTH, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; + ConfigurableAxis cfgaxisPtK0s{"cfgaxisPtK0s", {VARIABLE_WIDTH, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; + ConfigurableAxis cfgaxisPtLambda{"cfgaxisPtLambda", {VARIABLE_WIDTH, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3, 2.5, 2.7, 2.9, 3.9, 4.9, 5.9, 9.9}, "pt (GeV)"}; + ConfigurableAxis cfgaxisOmegaMassforflow{"cfgaxisOmegaMassforflow", {16, 1.63f, 1.71f}, "Inv. Mass (GeV)"}; + ConfigurableAxis cfgaxisXiMassforflow{"cfgaxisXiMassforflow", {14, 1.3f, 1.37f}, "Inv. Mass (GeV)"}; + ConfigurableAxis cfgaxisK0sMassforflow{"cfgaxisK0sMassforflow", {40, 0.4f, 0.6f}, "Inv. Mass (GeV)"}; + ConfigurableAxis cfgaxisLambdaMassforflow{"cfgaxisLambdaMassforflow", {32, 1.08f, 1.16f}, "Inv. Mass (GeV)"}; + ConfigurableAxis cfgaxisNch{"cfgaxisNch", {3000, 0.5, 3000.5}, "Nch"}; + ConfigurableAxis cfgaxisLocalDensity{"cfgaxisLocalDensity", {200, 0, 600}, "local density"}; + + AxisSpec axisMultiplicity{{0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "Centrality (%)"}; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter trackFilter = (nabs(aod::track::eta) < trkQualityOpts.cfgCutEta.value) && (aod::track::pt > trkQualityOpts.cfgCutPtPOIMin.value) && (aod::track::pt < trkQualityOpts.cfgCutPtPOIMax.value) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); + + using TracksPID = soa::Join; + using AodTracks = soa::Filtered>; // tracks filter + using AodCollisions = soa::Filtered>; // collisions filter + using DaughterTracks = soa::Join; + + // Connect to ccdb + Service ccdb; + O2_DEFINE_CONFIGURABLE(cfgnolaterthan, int64_t, std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object") + O2_DEFINE_CONFIGURABLE(cfgurl, std::string, "http://alice-ccdb.cern.ch", "url of the ccdb repository") + + // Define output + HistogramRegistry registry{"registry"}; + OutputObj fWeightsREF{GFWWeights("weightsREF")}; + OutputObj fWeightsK0s{GFWWeights("weightsK0s")}; + OutputObj fWeightsLambda{GFWWeights("weightsLambda")}; + OutputObj fWeightsXi{GFWWeights("weightsXi")}; + OutputObj fWeightsOmega{GFWWeights("weightsOmega")}; + + // define global variables + GFW* fGFW = new GFW(); // GFW class used from main src + std::vector corrconfigs; + std::vector cfgAcceptance; + std::vector cfgEfficiency; + std::vector cfgNSigma; + std::vector cfgmassbins; + + std::vector mAcceptance; + std::vector mEfficiency; + bool correctionsLoaded = false; + + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + + // Declare the pt, mult and phi Axis; + int nPtBins = 0; + TAxis* fPtAxis = nullptr; + + int nXiPtBins = 0; + TAxis* fXiPtAxis = nullptr; + + int nOmegaPtBins = 0; + TAxis* fOmegaPtAxis = nullptr; + + int nK0sPtBins = 0; + TAxis* fK0sPtAxis = nullptr; + + int nLambdaPtBins = 0; + TAxis* fLambdaPtAxis = nullptr; + + TAxis* fMultAxis = nullptr; + + TAxis* fOmegaMass = nullptr; + + TAxis* fXiMass = nullptr; + + TAxis* fK0sMass = nullptr; + + TAxis* fLambdaMass = nullptr; + + void init(InitContext const&) // Initialization + { + ccdb->setURL(cfgurl.value); + ccdb->setCaching(true); + ccdb->setCreatedNotAfter(cfgnolaterthan.value); + + cfgAcceptance = cfgAcceptancePath; + cfgEfficiency = cfgEfficiencyPath; + cfgNSigma = cfgNSigmapid; + cfgmassbins = cfgMassBins; + + // Set the pt, mult and phi Axis; + o2::framework::AxisSpec axisPt = cfgaxisPt; + nPtBins = axisPt.binEdges.size() - 1; + fPtAxis = new TAxis(nPtBins, &(axisPt.binEdges)[0]); + + o2::framework::AxisSpec axisXiPt = cfgaxisPtXi; + nXiPtBins = axisXiPt.binEdges.size() - 1; + fXiPtAxis = new TAxis(nXiPtBins, &(axisXiPt.binEdges)[0]); + + o2::framework::AxisSpec axisOmegaPt = cfgaxisPtOmega; + nOmegaPtBins = axisOmegaPt.binEdges.size() - 1; + fOmegaPtAxis = new TAxis(nOmegaPtBins, &(axisOmegaPt.binEdges)[0]); + + o2::framework::AxisSpec axisK0sPt = cfgaxisPtK0s; + nK0sPtBins = axisK0sPt.binEdges.size() - 1; + fK0sPtAxis = new TAxis(nK0sPtBins, &(axisK0sPt.binEdges)[0]); + + o2::framework::AxisSpec axisLambdaPt = cfgaxisPtLambda; + nLambdaPtBins = axisLambdaPt.binEdges.size() - 1; + fLambdaPtAxis = new TAxis(nLambdaPtBins, &(axisLambdaPt.binEdges)[0]); + + o2::framework::AxisSpec axisMult = axisMultiplicity; + int nMultBins = axisMult.binEdges.size() - 1; + fMultAxis = new TAxis(nMultBins, &(axisMult.binEdges)[0]); + + fOmegaMass = new TAxis(cfgmassbins[3], 1.63, 1.71); + + fXiMass = new TAxis(cfgmassbins[2], 1.29, 1.36); + + fK0sMass = new TAxis(cfgmassbins[0], 0.4, 0.6); + + fLambdaMass = new TAxis(cfgmassbins[1], 1.08, 1.16); + + // Add some output objects to the histogram registry + registry.add("hPhi", "", {HistType::kTH1D, {cfgaxisPhi}}); + registry.add("hPhicorr", "", {HistType::kTH1D, {cfgaxisPhi}}); + registry.add("hEta", "", {HistType::kTH1D, {cfgaxisEta}}); + registry.add("hVtxZ", "", {HistType::kTH1D, {cfgaxisVertex}}); + registry.add("hMult", "", {HistType::kTH1D, {cfgaxisNch}}); + registry.add("hCent", "", {HistType::kTH1D, {{90, 0, 90}}}); + registry.add("hCentvsNch", "", {HistType::kTH2D, {{18, 0, 90}, cfgaxisNch}}); + registry.add("MC/hCentvsNchMC", "", {HistType::kTH2D, {{18, 0, 90}, cfgaxisNch}}); + registry.add("hPt", "", {HistType::kTH1D, {cfgaxisPt}}); + registry.add("hEtaPhiVtxzREF", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); + registry.add("hEtaPhiVtxzPOIXi", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); + registry.add("hEtaPhiVtxzPOIOmega", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); + registry.add("hEtaPhiVtxzPOIK0s", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); + registry.add("hEtaPhiVtxzPOILambda", "", {HistType::kTH3D, {cfgaxisPhi, cfgaxisEta, {20, -10, 10}}}); + + registry.add("hEventCount", "", {HistType::kTH1D, {{12, 0, 12}}}); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(1, "Filtered event"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(2, "after sel8"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(3, "after kTVXinTRD"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(4, "after kNoTimeFrameBorder"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(5, "after kNoITSROFrameBorder"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(6, "after kDoNoSameBunchPileup"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(7, "after kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(8, "after kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(9, "after kIsGoodITSLayersAll"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(10, "after MultPVCut"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(11, "after TPC occupancy cut"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(12, "after V0AT0Acut"); + + // QA + if (cfgOutputQA) { + // V0 QA + registry.add("QAhisto/V0/hqaV0radiusbefore", "", {HistType::kTH1D, {{200, 0, 200}}}); + registry.add("QAhisto/V0/hqaV0radiusafter", "", {HistType::kTH1D, {{200, 0, 200}}}); + registry.add("QAhisto/V0/hqaV0cosPAbefore", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/V0/hqaV0cosPAafter", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/V0/hqadcaV0daubefore", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/V0/hqadcaV0dauafter", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/V0/hqaarm_podobefore", "", {HistType::kTH2D, {{100, -1, 1}, {50, 0, 0.3}}}); + registry.add("QAhisto/V0/hqaarm_podoafter", "", {HistType::kTH2D, {{100, -1, 1}, {50, 0, 0.3}}}); + registry.add("QAhisto/V0/hqadcapostoPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/V0/hqadcapostoPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/V0/hqadcanegtoPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/V0/hqadcanegtoPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); + // Cascade QA + registry.add("QAhisto/Casc/hqaCasccosPAbefore", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/Casc/hqaCasccosPAafter", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/Casc/hqaCascV0cosPAbefore", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/Casc/hqaCascV0cosPAafter", "", {HistType::kTH1D, {{1000, 0.95, 1}}}); + registry.add("QAhisto/Casc/hqadcaCascV0toPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/Casc/hqadcaCascV0toPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/Casc/hqadcaCascBachtoPVbefore", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/Casc/hqadcaCascBachtoPVafter", "", {HistType::kTH1D, {{1000, -10, 10}}}); + registry.add("QAhisto/Casc/hqadcaCascdaubefore", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/Casc/hqadcaCascdauafter", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/Casc/hqadcaCascV0daubefore", "", {HistType::kTH1D, {{100, 0, 1}}}); + registry.add("QAhisto/Casc/hqadcaCascV0dauafter", "", {HistType::kTH1D, {{100, 0, 1}}}); + } + + // cumulant of flow + registry.add("c22", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); + registry.add("c32", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); + registry.add("c24", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); + registry.add("c22Full", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); + registry.add("c22dpt", ";Centrality (%) ; C_{2}{2}", {HistType::kTProfile2D, {cfgaxisPt, axisMultiplicity}}); + registry.add("c24dpt", ";Centrality (%) ; C_{2}{4}", {HistType::kTProfile2D, {cfgaxisPt, axisMultiplicity}}); + registry.add("c22Fulldpt", ";Centrality (%) ; C_{2}{2}", {HistType::kTProfile2D, {cfgaxisPt, axisMultiplicity}}); + // pt-diff cumulant of flow + // v2 + registry.add("Xic22dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}}); + registry.add("Omegac22dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtOmega, cfgaxisOmegaMassforflow, axisMultiplicity}}); + registry.add("K0sc22dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtK0s, cfgaxisK0sMassforflow, axisMultiplicity}}); + registry.add("Lambdac22dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtLambda, cfgaxisLambdaMassforflow, axisMultiplicity}}); + registry.add("Xic24dpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}}); + registry.add("Omegac24dpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtOmega, cfgaxisOmegaMassforflow, axisMultiplicity}}); + registry.add("K0sc24dpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtK0s, cfgaxisK0sMassforflow, axisMultiplicity}}); + registry.add("Lambdac24dpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtK0s, cfgaxisLambdaMassforflow, axisMultiplicity}}); + registry.add("Xic22Fulldpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}}); + registry.add("Omegac22Fulldpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtOmega, cfgaxisOmegaMassforflow, axisMultiplicity}}); + registry.add("K0sc22Fulldpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtK0s, cfgaxisK0sMassforflow, axisMultiplicity}}); + registry.add("Lambdac22Fulldpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtLambda, cfgaxisLambdaMassforflow, axisMultiplicity}}); + + registry.add("Xic24_gapdpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}}); + registry.add("Omegac24_gapdpt", ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtOmega, cfgaxisOmegaMassforflow, axisMultiplicity}}); + // v3 + registry.add("Xic32dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}}); + registry.add("Omegac32dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtOmega, cfgaxisOmegaMassforflow, axisMultiplicity}}); + registry.add("K0sc32dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtK0s, cfgaxisK0sMassforflow, axisMultiplicity}}); + registry.add("Lambdac32dpt", ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtLambda, cfgaxisLambdaMassforflow, axisMultiplicity}}); + // for Jackknife + if (cfgDoJackknife) { + int nsubevent = 10; + for (int i = 1; i <= nsubevent; i++) { + refc22[i - 1] = registry.add(Form("Jackknife/REF/c22_%d", i), ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); + refc24[i - 1] = registry.add(Form("Jackknife/REF/c24_%d", i), ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); + refc22Full[i - 1] = registry.add(Form("Jackknife/REF/c22Full_%d", i), ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); + xic22[i - 1] = registry.add(Form("Jackknife/Xi/Xic22dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}}); + omegac22[i - 1] = registry.add(Form("Jackknife/Omega/Omegac22dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtOmega, cfgaxisOmegaMassforflow, axisMultiplicity}}); + k0sc22[i - 1] = registry.add(Form("Jackknife/K0s/K0sc22dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtK0s, cfgaxisK0sMassforflow, axisMultiplicity}}); + lambdac22[i - 1] = registry.add(Form("Jackknife/Lambda/Lambdac22dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtLambda, cfgaxisLambdaMassforflow, axisMultiplicity}}); + xic24[i - 1] = registry.add(Form("Jackknife/Xi/Xic24dpt_%d", i), ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}}); + omegac24[i - 1] = registry.add(Form("Jackknife/Omega/Omegac24dpt_%d", i), ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtOmega, cfgaxisOmegaMassforflow, axisMultiplicity}}); + k0sc24[i - 1] = registry.add(Form("Jackknife/K0s/K0sc24dpt_%d", i), ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtK0s, cfgaxisK0sMassforflow, axisMultiplicity}}); + lambdac24[i - 1] = registry.add(Form("Jackknife/Lambda/Lambdac24dpt_%d", i), ";pt ; C_{2}{4} ", {HistType::kTProfile3D, {cfgaxisPtLambda, cfgaxisLambdaMassforflow, axisMultiplicity}}); + refc32[i - 1] = registry.add(Form("Jackknife/REF/c32_%d", i), ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); + xic22Full[i - 1] = registry.add(Form("Jackknife/Xi/Xic22Fulldpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}}); + omegac22Full[i - 1] = registry.add(Form("Jackknife/Omega/Omegac22Fulldpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtOmega, cfgaxisOmegaMassforflow, axisMultiplicity}}); + k0sc22Full[i - 1] = registry.add(Form("Jackknife/K0s/K0sc22Fulldpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtK0s, cfgaxisK0sMassforflow, axisMultiplicity}}); + lambdac22Full[i - 1] = registry.add(Form("Jackknife/Lambda/Lambdac22Fulldpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtLambda, cfgaxisLambdaMassforflow, axisMultiplicity}}); + xic32[i - 1] = registry.add(Form("Jackknife/Xi/Xic32dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtXi, cfgaxisXiMassforflow, axisMultiplicity}}); + omegac32[i - 1] = registry.add(Form("Jackknife/Omega/Omegac32dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtOmega, cfgaxisOmegaMassforflow, axisMultiplicity}}); + k0sc32[i - 1] = registry.add(Form("Jackknife/K0s/K0sc32dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtK0s, cfgaxisK0sMassforflow, axisMultiplicity}}); + lambdac32[i - 1] = registry.add(Form("Jackknife/Lambda/Lambdac32dpt_%d", i), ";pt ; C_{2}{2} ", {HistType::kTProfile3D, {cfgaxisPtLambda, cfgaxisLambdaMassforflow, axisMultiplicity}}); + } + } + // MC True flow + registry.add("MC/c22MC", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisMultiplicity}}); + registry.add("MC/Xic22dptMC", ";pt ; C_{2}{2} ", {HistType::kTProfile2D, {cfgaxisPtXi, axisMultiplicity}}); + registry.add("MC/Omegac22dptMC", ";pt ; C_{2}{2} ", {HistType::kTProfile2D, {cfgaxisPtOmega, axisMultiplicity}}); + registry.add("MC/K0sc22dptMC", ";pt ; C_{2}{2} ", {HistType::kTProfile2D, {cfgaxisPtK0s, axisMultiplicity}}); + registry.add("MC/Lambdac22dptMC", ";pt ; C_{2}{2} ", {HistType::kTProfile2D, {cfgaxisPtLambda, axisMultiplicity}}); + // InvMass(GeV) of casc and v0 + AxisSpec axisOmegaMass = {80, 1.63f, 1.71f, "Inv. Mass (GeV)"}; + AxisSpec axisXiMass = {70, 1.3f, 1.37f, "Inv. Mass (GeV)"}; + AxisSpec axisK0sMass = {400, 0.4f, 0.6f, "Inv. Mass (GeV)"}; + AxisSpec axisLambdaMass = {160, 1.08f, 1.16f, "Inv. Mass (GeV)"}; + registry.add("InvMassXi_all", "", {HistType::kTHnSparseF, {cfgaxisPtXi, axisXiMass, cfgaxisEta, axisMultiplicity}}); + registry.add("InvMassOmega_all", "", {HistType::kTHnSparseF, {cfgaxisPtOmega, axisOmegaMass, cfgaxisEta, axisMultiplicity}}); + registry.add("InvMassXi", "", {HistType::kTHnSparseF, {cfgaxisPtXi, axisXiMass, cfgaxisEta, axisMultiplicity}}); + registry.add("InvMassOmega", "", {HistType::kTHnSparseF, {cfgaxisPtOmega, axisOmegaMass, cfgaxisEta, axisMultiplicity}}); + registry.add("InvMassK0s_all", "", {HistType::kTHnSparseF, {cfgaxisPtK0s, axisK0sMass, cfgaxisEta, axisMultiplicity}}); + registry.add("InvMassLambda_all", "", {HistType::kTHnSparseF, {cfgaxisPtLambda, axisLambdaMass, cfgaxisEta, axisMultiplicity}}); + registry.add("InvMassK0s", "", {HistType::kTHnSparseF, {cfgaxisPtK0s, axisK0sMass, cfgaxisEta, axisMultiplicity}}); + registry.add("InvMassLambda", "", {HistType::kTHnSparseF, {cfgaxisPtLambda, axisLambdaMass, cfgaxisEta, axisMultiplicity}}); + // for local density correlation + registry.add("MC/densityMCGenK0s", "", {HistType::kTH3D, {cfgaxisPtK0s, cfgaxisNch, cfgaxisLocalDensity}}); + registry.add("MC/densityMCGenLambda", "", {HistType::kTH3D, {cfgaxisPtLambda, cfgaxisNch, cfgaxisLocalDensity}}); + registry.add("MC/densityMCGenXi", "", {HistType::kTH3D, {cfgaxisPtXi, cfgaxisNch, cfgaxisLocalDensity}}); + registry.add("MC/densityMCGenOmega", "", {HistType::kTH3D, {cfgaxisPtOmega, cfgaxisNch, cfgaxisLocalDensity}}); + registry.add("MC/densityMCRecK0s", "", {HistType::kTHnSparseF, {cfgaxisPtK0s, cfgaxisNch, cfgaxisLocalDensity, axisK0sMass}}); + registry.add("MC/densityMCRecLambda", "", {HistType::kTHnSparseF, {cfgaxisPtLambda, cfgaxisNch, cfgaxisLocalDensity, axisLambdaMass}}); + registry.add("MC/densityMCRecXi", "", {HistType::kTHnSparseF, {cfgaxisPtXi, cfgaxisNch, cfgaxisLocalDensity, axisXiMass}}); + registry.add("MC/densityMCRecOmega", "", {HistType::kTHnSparseF, {cfgaxisPtOmega, cfgaxisNch, cfgaxisLocalDensity, axisOmegaMass}}); + + // Data + fGFW->AddRegion("reffull", -0.8, 0.8, 1, 1); // ("name", etamin, etamax, ptbinnum, bitmask)eta region -0.8 to 0.8 + fGFW->AddRegion("refN10", -0.8, -0.4, 1, 1); + fGFW->AddRegion("refP10", 0.4, 0.8, 1, 1); + fGFW->AddRegion("olxidaudpt", -0.8, 0.8, 1, 2048); + fGFW->AddRegion("olomegadaudpt", -0.8, 0.8, 1, 4096); + // POI + fGFW->AddRegion("poiN10dpt", -0.8, -0.4, nPtBins, 32); + fGFW->AddRegion("poiP10dpt", 0.4, 0.8, nPtBins, 32); + fGFW->AddRegion("poifulldpt", -0.8, 0.8, nPtBins, 32); + fGFW->AddRegion("poioldpt", -0.8, 0.8, nPtBins, 1); + + int nXiptMassBins = nXiPtBins * cfgmassbins[2]; + fGFW->AddRegion("poiXiPdpt", 0.4, 0.8, nXiptMassBins, 2); + fGFW->AddRegion("poiXiNdpt", -0.8, -0.4, nXiptMassBins, 2); + fGFW->AddRegion("poiXifulldpt", -0.8, 0.8, nXiptMassBins, 2); + fGFW->AddRegion("poiXiP", 0.4, 0.8, 1, 2); + fGFW->AddRegion("poiXiN", -0.8, -0.4, 1, 2); + int nOmegaptMassBins = nXiPtBins * cfgmassbins[3]; + fGFW->AddRegion("poiOmegaPdpt", 0.4, 0.8, nOmegaptMassBins, 4); + fGFW->AddRegion("poiOmegaNdpt", -0.8, -0.4, nOmegaptMassBins, 4); + fGFW->AddRegion("poiOmegafulldpt", -0.8, 0.8, nOmegaptMassBins, 4); + fGFW->AddRegion("poiOmegaP", 0.4, 0.8, 1, 4); + fGFW->AddRegion("poiOmegaN", -0.8, -0.4, 1, 4); + int nK0sptMassBins = nK0sPtBins * cfgmassbins[0]; + fGFW->AddRegion("poiK0sPdpt", 0.4, 0.8, nK0sptMassBins, 8); + fGFW->AddRegion("poiK0sNdpt", -0.8, -0.4, nK0sptMassBins, 8); + fGFW->AddRegion("poiK0sfulldpt", -0.8, 0.8, nK0sptMassBins, 8); + int nLambdaptMassBins = nLambdaPtBins * cfgmassbins[1]; + fGFW->AddRegion("poiLambdaPdpt", 0.4, 0.8, nLambdaptMassBins, 16); + fGFW->AddRegion("poiLambdaNdpt", -0.8, -0.4, nLambdaptMassBins, 16); + fGFW->AddRegion("poiLambdafulldpt", -0.8, 0.8, nLambdaptMassBins, 16); + // MC + fGFW->AddRegion("refN10MC", -0.8, -0.4, 1, 64); + fGFW->AddRegion("refP10MC", 0.4, 0.8, 1, 64); + fGFW->AddRegion("poiXiPdptMC", 0.4, 0.8, nXiptMassBins, 128); + fGFW->AddRegion("poiXiNdptMC", -0.8, -0.4, nXiptMassBins, 128); + fGFW->AddRegion("poiOmegaPdptMC", 0.4, 0.8, nOmegaptMassBins, 256); + fGFW->AddRegion("poiOmegaNdptMC", -0.8, -0.4, nOmegaptMassBins, 256); + fGFW->AddRegion("poiK0sPdptMC", 0.4, 0.8, nK0sptMassBins, 512); + fGFW->AddRegion("poiK0sNdptMC", -0.8, -0.4, nK0sptMassBins, 512); + fGFW->AddRegion("poiLambdaPdptMC", 0.4, 0.8, nLambdaptMassBins, 1024); + fGFW->AddRegion("poiLambdaNdptMC", -0.8, -0.4, nLambdaptMassBins, 1024); + // pushback + // Data + // v2 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiP10dpt {2} refN10 {-2}", "Poi10Gap22dpta", kTRUE)); // 0 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10dpt {2} refP10 {-2}", "Poi10Gap22dptb", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifulldpt reffull | poioldpt {2 2 -2 -2}", "Poi10Gap24dpt", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifulldpt reffull | poioldpt {2 -2}", "PoiFull22dpt", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiPdpt {2} refN10 {-2}", "Xi10Gap22a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiNdpt {2} refP10 {-2}", "Xi10Gap22b", kTRUE)); // 5 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXifulldpt reffull {2 2 -2 -2}", "Xi10Gap24", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXifulldpt {2} reffull {-2}", "XiFull22", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaPdpt {2} refN10 {-2}", "Omega10Gap22a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaNdpt {2} refP10 {-2}", "Omega10Gap22b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegafulldpt reffull {2 2 -2 -2}", "Omega10Gap24", kTRUE)); // 10 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegafulldpt {2} reffull {-2}", "OmegaFull22", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sPdpt {2} refN10 {-2}", "K0short10Gap22a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sNdpt {2} refP10 {-2}", "K0short10Gap22b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sfulldpt reffull {2 2 -2 -2}", "K0short10Gap24", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sfulldpt {2} reffull {-2}", "K0shortFull22", kTRUE)); // 15 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaPdpt {2} refN10 {-2}", "Lambda10Gap22a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaNdpt {2} refP10 {-2}", "Lambda10Gap22b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdafulldpt reffull {2 2 -2 -2}", "LambdaFull24", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdafulldpt {2} reffull {-2}", "LambdaFull22", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refP10 {2} refN10 {-2}", "Ref10Gap22a", kFALSE)); // 20 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("reffull reffull {2 2 -2 -2}", "Ref10Gap24", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("reffull reffull {2 -2}", "RefFull22", kFALSE)); + // v3 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiPdpt {3} refN10 {-3}", "Xi10Gap32a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiNdpt {3} refP10 {-3}", "Xi10Gap32b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaPdpt {3} refN10 {-3}", "Omega10Gap32a", kTRUE)); // 25 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaNdpt {3} refP10 {-3}", "Omega10Gap32b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sPdpt {3} refN10 {-3}", "K0short10Gap32a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sNdpt {3} refP10 {-3}", "K0short10Gap32b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaPdpt {3} refN10 {-3}", "Lambda10Gap32a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaNdpt {3} refP10 {-3}", "Lambda10Gap32b", kTRUE)); // 30 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refP10 {3} refN10 {-3}", "Ref10Gap32a", kFALSE)); + // MC + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiPdptMC {2} refN10MC {-2}", "MCXi10Gap22a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiNdptMC {2} refP10MC {-2}", "MCXi10Gap22b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaPdptMC {2} refN10MC {-2}", "MCOmega10Gap22a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaNdptMC {2} refP10MC {-2}", "MCOmega10Gap22b", kTRUE)); // 35 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sPdptMC {2} refN10MC {-2}", "MCK0s10Gap22a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiK0sNdptMC {2} refP10MC {-2}", "MCK0s10Gap22b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaPdptMC {2} refN10MC {-2}", "MCLambda10Gap22a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiLambdaNdptMC {2} refP10MC {-2}", "MCLambda10Gap22b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refP10MC {2} refN10MC {-2}", "MCRef10Gap22a", kFALSE)); // 40 + + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiPdpt refN10 {2 2 -2 -2}", "Xi10Gap24a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXiNdpt refP10 {2 2 -2 -2}", "Xi10Gap24b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXifulldpt {2} olxidaudpt {-2}", "XiFullol22", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiXifulldpt olxidaudpt {2 2 -2 -2}", "XiFullol24", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaPdpt refN10 {2 2 -2 -2}", "Omega10Gap24a", kTRUE)); // 45 + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegaNdpt refP10 {2 2 -2 -2}", "Omega10Gap24b", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegafulldpt {2} olomegadaudpt {-2}", "OmegaFullol22", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiOmegafulldpt olomegadaudpt {2 2 -2 -2}", "OmegaFullol24", kTRUE)); + fGFW->CreateRegions(); // finalize the initialization + + // used for event selection + int caseapass4 = 4; + int caseapass5 = 5; + if (evtSeleOpts.cfgMultPVCut.value == caseapass4) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + } + if (evtSeleOpts.cfgMultPVCut.value == caseapass5) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3074.43, -106.192, 1.46176, -0.00968364, 2.61923e-05, 182.128, -7.43492, 0.193901, -0.00256715, 1.22594e-05); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3074.43, -106.192, 1.46176, -0.00968364, 2.61923e-05, 182.128, -7.43492, 0.193901, -0.00256715, 1.22594e-05); + } + + fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + + // fWeight output + if (cfgOutputNUAWeights) { + fWeightsREF->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsREF->init(true, false); + fWeightsK0s->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsK0s->init(true, false); + fWeightsLambda->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsLambda->init(true, false); + fWeightsXi->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsXi->init(true, false); + fWeightsOmega->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsOmega->init(true, false); + } + } + + // input HIST("name") + template + void fillProfile(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const double& cent) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) + registry.fill(tarName, cent, val, dnx); + return; + } + return; + } + + // input shared_ptr + void fillProfile(const GFW::CorrConfig& corrconf, std::shared_ptr TProfile, const double& cent) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) + TProfile->Fill(cent, val, dnx); + return; + } + return; + } + + template + void fillProfilepT(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const int& ptbin, const double& cent) + { + float dnx = 0; + float val = 0; + dnx = fGFW->Calculate(corrconf, ptbin - 1, kTRUE).real(); + if (dnx == 0) + return; + val = fGFW->Calculate(corrconf, ptbin - 1, kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + registry.fill(tarName, fPtAxis->GetBinCenter(ptbin), cent, val, dnx); + } + return; + } + + template + void fillProfilepTMC(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const int& ptbin, const int& PDGCode, const double& cent) + { + TAxis* fpt = nullptr; + if (PDGCode == kXiMinus) { + fpt = fXiPtAxis; + } else if (PDGCode == kOmegaMinus) { + fpt = fOmegaPtAxis; + } else if (PDGCode == kK0Short) { + fpt = fK0sPtAxis; + } else if (PDGCode == kLambda0) { + fpt = fLambdaPtAxis; + } else { + LOGF(error, "Error, please put in correct PDGCode of K0s, Lambda, Xi or Omega"); + return; + } + float dnx = 0; + float val = 0; + dnx = fGFW->Calculate(corrconf, ptbin - 1, kTRUE).real(); + if (dnx == 0) + return; + val = fGFW->Calculate(corrconf, ptbin - 1, kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + registry.fill(tarName, fpt->GetBinCenter(ptbin), cent, val, dnx); + } + return; + } + + // input HIST("name") + template + void fillProfilepTMass(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const int& ptbin, const int& PDGCode, const float& cent) + { + int nMassBins = 0; + int nptbins = 0; + TAxis* fMass = nullptr; + TAxis* fpt = nullptr; + if (PDGCode == kXiMinus) { + nMassBins = cfgmassbins[2]; + nptbins = nXiPtBins; + fpt = fXiPtAxis; + fMass = fXiMass; + } else if (PDGCode == kOmegaMinus) { + nMassBins = cfgmassbins[3]; + nptbins = nOmegaPtBins; + fpt = fOmegaPtAxis; + fMass = fOmegaMass; + } else if (PDGCode == kK0Short) { + nMassBins = cfgmassbins[0]; + nptbins = nK0sPtBins; + fpt = fK0sPtAxis; + fMass = fK0sMass; + } else if (PDGCode == kLambda0) { + nMassBins = cfgmassbins[1]; + nptbins = nLambdaPtBins; + fpt = fLambdaPtAxis; + fMass = fLambdaMass; + } else { + LOGF(error, "Error, please put in correct PDGCode of K0s, Lambda, Xi or Omega"); + return; + } + for (int massbin = 1; massbin <= nMassBins; massbin++) { + float dnx = 0; + float val = 0; + dnx = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kTRUE).real(); + if (dnx == 0) + continue; + val = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + registry.fill(tarName, fpt->GetBinCenter(ptbin), fMass->GetBinCenter(massbin), cent, val, dnx); + } + } + return; + } + + // remove auto-corr + template + void fillProfilepTMass(const GFW::CorrConfig& corrconf, const GFW::CorrConfig& corrconfol, const ConstStr& tarName, const int& ptbin, const int& PDGCode, const float& cent) + { + int nMassBins = 0; + int nptbins = 0; + TAxis* fMass = nullptr; + TAxis* fpt = nullptr; + if (PDGCode == kXiMinus) { + nMassBins = cfgmassbins[2]; + nptbins = nXiPtBins; + fpt = fXiPtAxis; + fMass = fXiMass; + } else if (PDGCode == kOmegaMinus) { + nMassBins = cfgmassbins[3]; + nptbins = nOmegaPtBins; + fpt = fOmegaPtAxis; + fMass = fOmegaMass; + } else if (PDGCode == kK0Short) { + nMassBins = cfgmassbins[0]; + nptbins = nK0sPtBins; + fpt = fK0sPtAxis; + fMass = fK0sMass; + } else if (PDGCode == kLambda0) { + nMassBins = cfgmassbins[1]; + nptbins = nLambdaPtBins; + fpt = fLambdaPtAxis; + fMass = fLambdaMass; + } else { + LOGF(error, "Error, please put in correct PDGCode of K0s, Lambda, Xi or Omega"); + return; + } + for (int massbin = 1; massbin <= nMassBins; massbin++) { + float dnx = 0; + float val = 0; + float dnxol = 0; + dnx = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kTRUE).real(); + dnxol = fGFW->Calculate(corrconfol, (ptbin - 1) + ((massbin - 1) * nptbins), kTRUE).real(); + dnx = dnx - dnxol; + if (dnx == 0) + continue; + val = (fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kFALSE).real() - fGFW->Calculate(corrconfol, (ptbin - 1) + ((massbin - 1) * nptbins), kFALSE).real()) / dnx; + + if (std::fabs(val) < 1) { + registry.fill(tarName, fpt->GetBinCenter(ptbin), fMass->GetBinCenter(massbin), cent, val, dnx); + } + } + return; + } + + // input shared_ptr + void fillProfilepTMass(const GFW::CorrConfig& corrconf, std::shared_ptr TProfile3D, const int& ptbin, const int& PDGCode, const float& cent) + { + int nMassBins = 0; + int nptbins = 0; + TAxis* fMass = nullptr; + TAxis* fpt = nullptr; + if (PDGCode == kXiMinus) { + nMassBins = cfgmassbins[2]; + nptbins = nXiPtBins; + fpt = fXiPtAxis; + fMass = fXiMass; + } else if (PDGCode == kOmegaMinus) { + nMassBins = cfgmassbins[3]; + nptbins = nOmegaPtBins; + fpt = fOmegaPtAxis; + fMass = fOmegaMass; + } else if (PDGCode == kK0Short) { + nMassBins = cfgmassbins[0]; + nptbins = nK0sPtBins; + fpt = fK0sPtAxis; + fMass = fK0sMass; + } else if (PDGCode == kLambda0) { + nMassBins = cfgmassbins[1]; + nptbins = nLambdaPtBins; + fpt = fLambdaPtAxis; + fMass = fLambdaMass; + } else { + LOGF(error, "Error, please put in correct PDGCode of K0s, Lambda, Xi or Omega"); + return; + } + for (int massbin = 1; massbin <= nMassBins; massbin++) { + float dnx = 0; + float val = 0; + dnx = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kTRUE).real(); + if (dnx == 0) + continue; + val = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + TProfile3D->Fill(fpt->GetBinCenter(ptbin), fMass->GetBinCenter(massbin), cent, val, dnx); + } + } + return; + } + + // remove auto-corr + void fillProfilepTMass(const GFW::CorrConfig& corrconf, const GFW::CorrConfig& corrconfol, std::shared_ptr TProfile3D, const int& ptbin, const int& PDGCode, const float& cent) + { + int nMassBins = 0; + int nptbins = 0; + TAxis* fMass = nullptr; + TAxis* fpt = nullptr; + if (PDGCode == kXiMinus) { + nMassBins = cfgmassbins[2]; + nptbins = nXiPtBins; + fpt = fXiPtAxis; + fMass = fXiMass; + } else if (PDGCode == kOmegaMinus) { + nMassBins = cfgmassbins[3]; + nptbins = nOmegaPtBins; + fpt = fOmegaPtAxis; + fMass = fOmegaMass; + } else if (PDGCode == kK0Short) { + nMassBins = cfgmassbins[0]; + nptbins = nK0sPtBins; + fpt = fK0sPtAxis; + fMass = fK0sMass; + } else if (PDGCode == kLambda0) { + nMassBins = cfgmassbins[1]; + nptbins = nLambdaPtBins; + fpt = fLambdaPtAxis; + fMass = fLambdaMass; + } else { + LOGF(error, "Error, please put in correct PDGCode of K0s, Lambda, Xi or Omega"); + return; + } + for (int massbin = 1; massbin <= nMassBins; massbin++) { + float dnx = 0; + float val = 0; + float dnxol = 0; + dnx = fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kTRUE).real(); + dnxol = fGFW->Calculate(corrconfol, (ptbin - 1) + ((massbin - 1) * nptbins), kTRUE).real(); + dnx = dnx - dnxol; + if (dnx == 0) + continue; + val = (fGFW->Calculate(corrconf, (ptbin - 1) + ((massbin - 1) * nptbins), kFALSE).real() - fGFW->Calculate(corrconfol, (ptbin - 1) + ((massbin - 1) * nptbins), kFALSE).real()) / dnx; + if (std::fabs(val) < 1) { + TProfile3D->Fill(fpt->GetBinCenter(ptbin), fMass->GetBinCenter(massbin), cent, val, dnx); + } + } + return; + } + + void loadCorrections(uint64_t timestamp) + { + if (correctionsLoaded) + return; + int nspecies = 5; + if (cfgAcceptance.size() == static_cast(nspecies)) { + for (int i = 0; i <= nspecies - 1; i++) { + mAcceptance.push_back(ccdb->getForTimeStamp(cfgAcceptance[i], timestamp)); + } + if (mAcceptance.size() == static_cast(nspecies)) + LOGF(info, "Loaded acceptance weights"); + else + LOGF(warning, "Could not load acceptance weights"); + } + if (cfgEfficiency.size() == static_cast(nspecies)) { + for (int i = 0; i <= nspecies - 1; i++) { + mEfficiency.push_back(ccdb->getForTimeStamp(cfgEfficiency[i], timestamp)); + } + if (mEfficiency.size() == static_cast(nspecies)) + LOGF(info, "Loaded efficiency histogram"); + else + LOGF(fatal, "Could not load efficiency histogram"); + } + correctionsLoaded = true; + } + + template + bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, TrackObject track, float vtxz, int ispecies) + { + float eff = 1.; + int nspecies = 5; + if (mEfficiency.size() == static_cast(nspecies)) + eff = mEfficiency[ispecies]->GetBinContent(mEfficiency[ispecies]->FindBin(track.pt())); + else + eff = 1.0; + if (eff == 0) + return false; + weight_nue = 1. / eff; + if (mAcceptance.size() == static_cast(nspecies)) + weight_nua = mAcceptance[ispecies]->getNUA(track.phi(), track.eta(), vtxz); + else + weight_nua = 1; + return true; + } + + template + bool setCurrentLocalDensityWeights(float& weight_loc, TrackObject track, double locDensity, int ispecies) + { + auto cfgLocDenPara = (std::vector>){cfgLocDenParaK0s, cfgLocDenParaLambda, cfgLocDenParaXi, cfgLocDenParaOmega}; + int ptbin = fXiPtAxis->FindBin(track.pt()); + if (ptbin == 0 || ptbin == (fXiPtAxis->GetNbins() + 1)) { + weight_loc = 1.0; + return true; + } + double paraA = cfgLocDenPara[ispecies - 1][2 * ptbin - 2]; + double paraB = cfgLocDenPara[ispecies - 1][2 * ptbin - 1]; + double density = locDensity * 200 / (2 * cfgDeltaPhiLocDen + 1); + double eff = std::exp(paraA * density + paraB); + weight_loc = 1 / eff; + return true; + } + // event selection + template + bool eventSelected(TCollision collision, const float centrality) + { + if (evtSeleOpts.cfgDoTVXinTRD.value && collision.alias_bit(kTVXinTRD)) { + // TRD triggered + return false; + } + registry.fill(HIST("hEventCount"), 2.5); + if (evtSeleOpts.cfgDoNoTimeFrameBorder.value && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + // reject collisions close to Time Frame borders + // https://its.cern.ch/jira/browse/O2-4623 + return false; + } + registry.fill(HIST("hEventCount"), 3.5); + if (evtSeleOpts.cfgDoNoITSROFrameBorder.value && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + // reject events affected by the ITS ROF border + // https://its.cern.ch/jira/browse/O2-4309 + return false; + } + registry.fill(HIST("hEventCount"), 4.5); + if (evtSeleOpts.cfgDoNoSameBunchPileup.value && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return false; + } + registry.fill(HIST("hEventCount"), 5.5); + if (evtSeleOpts.cfgDoIsGoodZvtxFT0vsPV.value && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return false; + } + registry.fill(HIST("hEventCount"), 6.5); + if (evtSeleOpts.cfgDoNoCollInTimeRangeStandard.value && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // no collisions in specified time range + return 0; + } + registry.fill(HIST("hEventCount"), 7.5); + if (evtSeleOpts.cfgDoIsGoodITSLayersAll.value && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // cut time intervals with dead ITS staves + return 0; + } + registry.fill(HIST("hEventCount"), 8.5); + float vtxz = -999; + if (collision.numContrib() > 1) { + vtxz = collision.posZ(); + float zRes = std::sqrt(collision.covZZ()); + double zResMin = 0.25; + int numContMax = 20; + if (zRes > zResMin && collision.numContrib() < numContMax) + vtxz = -999; + } + auto multNTracksPV = collision.multNTracksPV(); + auto occupancy = collision.trackOccupancyInTimeRange(); + + if (std::fabs(vtxz) > cfgCutVertex) + return false; + int caseapass4 = 4; + int caseapass5 = 5; + if (evtSeleOpts.cfgMultPVCut.value == caseapass4 || evtSeleOpts.cfgMultPVCut.value == caseapass5) { + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return false; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return false; + } + registry.fill(HIST("hEventCount"), 9.5); + + if (occupancy > evtSeleOpts.cfgCutOccupancyHigh.value) + return 0; + registry.fill(HIST("hEventCount"), 10.5); + + // V0A T0A 5 sigma cut + if (evtSeleOpts.cfgDoV0AT0Acut.value) { + int nsigma = 5; + if (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > nsigma * fT0AV0ASigma->Eval(collision.multFT0A())) + return 0; + } + registry.fill(HIST("hEventCount"), 11.5); + + return true; + } + + void processData(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracks const& tracks, aod::CascDataExt const& Cascades, aod::V0Datas const& V0s, DaughterTracks const&) + { + o2::aod::ITSResponse itsResponse; + int nTot = tracks.size(); + registry.fill(HIST("hEventCount"), 0.5); + if (nTot < 1) + return; + fGFW->Clear(); + const auto cent = collision.centFT0C(); + if (!collision.sel8()) + return; + registry.fill(HIST("hEventCount"), 1.5); + if (eventSelected(collision, cent)) + return; + TH1D* hLocalDensity = new TH1D("hphi", "hphi", 400, -constants::math::TwoPI, constants::math::TwoPI); + auto bc = collision.bc_as(); + loadCorrections(bc.timestamp()); + float vtxz = collision.posZ(); + registry.fill(HIST("hVtxZ"), vtxz); + registry.fill(HIST("hMult"), nTot); + registry.fill(HIST("hCent"), cent); + + float weff = 1; + float wacc = 1; + float wloc = 1; + double nch = 0; + // fill GFW ref flow + for (const auto& track : tracks) { + if (cfgDoAccEffCorr) { + if (!setCurrentParticleWeights(weff, wacc, track, vtxz, 0)) + continue; + } + registry.fill(HIST("hPhi"), track.phi()); + registry.fill(HIST("hPhicorr"), track.phi(), wacc); + registry.fill(HIST("hEta"), track.eta()); + registry.fill(HIST("hEtaPhiVtxzREF"), track.phi(), track.eta(), vtxz, wacc); + registry.fill(HIST("hPt"), track.pt()); + int ptbin = fPtAxis->FindBin(track.pt()) - 1; + if ((track.pt() > trkQualityOpts.cfgCutPtMin.value) && (track.pt() < trkQualityOpts.cfgCutPtMax.value)) { + fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 1); //(eta, ptbin, phi, wacc*weff, bitmask) + } + if ((track.pt() > trkQualityOpts.cfgCutPtPOIMin.value) && (track.pt() < trkQualityOpts.cfgCutPtPOIMax.value)) { + fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 32); + if (cfgDoLocDenCorr) { + hLocalDensity->Fill(track.phi(), wacc * weff); + hLocalDensity->Fill(RecoDecay::constrainAngle(track.phi(), -constants::math::TwoPI), wacc * weff); + nch += wacc * weff; + } + } + if (cfgOutputNUAWeights) + fWeightsREF->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + } + if (cfgDoLocDenCorr) { + registry.fill(HIST("hCentvsNch"), cent, nch); + } + // fill GFW of V0 flow + double lowpt = trkQualityOpts.cfgCutPtPIDDauMin.value; + + if (cfgOutputV0) { + for (const auto& v0 : V0s) { + auto v0posdau = v0.posTrack_as(); + auto v0negdau = v0.negTrack_as(); + // check tpc + bool isK0s = false; + bool isLambda = false; + + if (v0posdau.pt() < trkQualityOpts.cfgCutPtDauMin.value || v0posdau.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + if (v0negdau.pt() < trkQualityOpts.cfgCutPtDauMin.value || v0negdau.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + + // fill QA + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/V0/hqaarm_podobefore"), v0.alpha(), v0.qtarm()); + } + // check daughter TPC and TOF + // K0short + if (v0.pt() > trkQualityOpts.cfgCutPtK0sMin.value && v0.pt() < trkQualityOpts.cfgCutPtK0sMax.value) { + if (v0.qtarm() / std::fabs(v0.alpha()) > v0BuilderOpts.cfgv0_ArmPodocut.value && + std::fabs(v0.mK0Short() - o2::constants::physics::MassK0Short) < v0BuilderOpts.cfgv0_mk0swindow.value && + (std::fabs(v0posdau.tpcNSigmaPi()) < cfgNSigma[0] && std::fabs(v0negdau.tpcNSigmaPi()) < cfgNSigma[0]) && + ((std::fabs(v0posdau.tofNSigmaPi()) < cfgNSigma[3] || v0posdau.pt() < lowpt) && (std::fabs(v0negdau.tofNSigmaPi()) < cfgNSigma[3] || v0negdau.pt() < lowpt)) && + ((std::fabs(itsResponse.nSigmaITS(v0posdau)) < cfgNSigma[6]) || v0posdau.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(v0negdau)) < cfgNSigma[6]) || v0negdau.pt() < lowpt)) { + registry.fill(HIST("InvMassK0s_all"), v0.pt(), v0.mK0Short(), v0.eta(), cent); + isK0s = true; + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/V0/hqaarm_podoafter"), v0.alpha(), v0.qtarm()); + } + } + } + // Lambda and antiLambda + if (v0.pt() > trkQualityOpts.cfgCutPtLambdaMin.value && v0.pt() < trkQualityOpts.cfgCutPtLambdaMax.value) { + if (std::fabs(v0.mLambda() - o2::constants::physics::MassLambda) < v0BuilderOpts.cfgv0_mlambdawindow.value && + (std::fabs(v0posdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(v0negdau.tpcNSigmaPi()) < cfgNSigma[0]) && + ((std::fabs(v0posdau.tofNSigmaPr()) < cfgNSigma[4] || v0posdau.pt() < lowpt) && (std::fabs(v0negdau.tofNSigmaPi()) < cfgNSigma[3] || v0negdau.pt() < lowpt)) && + ((std::fabs(itsResponse.nSigmaITS(v0posdau)) < cfgNSigma[7]) || v0posdau.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(v0negdau)) < cfgNSigma[6]) || v0negdau.pt() < lowpt)) { + registry.fill(HIST("InvMassLambda_all"), v0.pt(), v0.mLambda(), v0.eta(), cent); + isLambda = true; + } else if (std::fabs(v0.mLambda() - o2::constants::physics::MassLambda) < v0BuilderOpts.cfgv0_mlambdawindow.value && + (std::fabs(v0negdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(v0posdau.tpcNSigmaPi()) < cfgNSigma[0]) && + ((std::fabs(v0negdau.tofNSigmaPr()) < cfgNSigma[4] || v0negdau.pt() < lowpt) && (std::fabs(v0posdau.tofNSigmaPi()) < cfgNSigma[3] || v0posdau.pt() < lowpt)) && + ((std::fabs(itsResponse.nSigmaITS(v0posdau)) < cfgNSigma[7]) || v0posdau.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(v0negdau)) < cfgNSigma[6]) || v0negdau.pt() < lowpt)) { + registry.fill(HIST("InvMassLambda_all"), v0.pt(), v0.mLambda(), v0.eta(), cent); + isLambda = true; + } + } + // fill QA before cut + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/V0/hqaV0radiusbefore"), v0.v0radius()); + registry.fill(HIST("QAhisto/V0/hqaV0cosPAbefore"), v0.v0cosPA()); + registry.fill(HIST("QAhisto/V0/hqadcaV0daubefore"), v0.dcaV0daughters()); + registry.fill(HIST("QAhisto/V0/hqadcapostoPVbefore"), v0.dcapostopv()); + registry.fill(HIST("QAhisto/V0/hqadcanegtoPVbefore"), v0.dcanegtopv()); + } + if (!isK0s && !isLambda) + continue; + // track quality check + if (!v0posdau.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!v0negdau.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!v0posdau.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!v0negdau.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!v0posdau.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (!v0negdau.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (trkQualityOpts.cfgCheckGlobalTrack.value) { + if (!v0posdau.hasTPC() || !v0posdau.hasITS()) + continue; + if (!v0negdau.hasTPC() || !v0negdau.hasITS()) + continue; + } + // // topological cut + if (v0.v0radius() < v0BuilderOpts.cfgv0_radius.value) + continue; + if (v0.v0cosPA() < v0BuilderOpts.cfgv0_v0cospa.value) + continue; + if (v0.dcaV0daughters() > v0BuilderOpts.cfgv0_dcav0dau.value) + continue; + if (std::fabs(v0.dcapostopv()) < v0BuilderOpts.cfgv0_dcadautopv.value) + continue; + if (std::fabs(v0.dcanegtopv()) < v0BuilderOpts.cfgv0_dcadautopv.value) + continue; + + // fill QA after cut + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/V0/hqaV0radiusafter"), v0.v0radius()); + registry.fill(HIST("QAhisto/V0/hqaV0cosPAafter"), v0.v0cosPA()); + registry.fill(HIST("QAhisto/V0/hqadcaV0dauafter"), v0.dcaV0daughters()); + registry.fill(HIST("QAhisto/V0/hqadcapostoPVafter"), v0.dcapostopv()); + registry.fill(HIST("QAhisto/V0/hqadcanegtoPVafter"), v0.dcanegtopv()); + } + if (isK0s) { + if (cfgDoAccEffCorr) + setCurrentParticleWeights(weff, wacc, v0, vtxz, 1); + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(v0.phi(), -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, v0, density, 1); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecK0s"), v0.pt(), nch, density, v0.mK0Short()); + } + registry.fill(HIST("InvMassK0s"), v0.pt(), v0.mK0Short(), v0.eta(), cent); + registry.fill(HIST("hEtaPhiVtxzPOIK0s"), v0.phi(), v0.eta(), vtxz, wacc); + fGFW->Fill(v0.eta(), fK0sPtAxis->FindBin(v0.pt()) - 1 + ((fK0sMass->FindBin(v0.mK0Short()) - 1) * nK0sPtBins), v0.phi(), wacc * weff * wloc, 8); + if (cfgOutputNUAWeights) + fWeightsK0s->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + } + if (isLambda) { + if (cfgDoAccEffCorr) + setCurrentParticleWeights(weff, wacc, v0, vtxz, 2); + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(v0.phi(), -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, v0, density, 2); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecLambda"), v0.pt(), nch, density, v0.mLambda()); + } + registry.fill(HIST("InvMassLambda"), v0.pt(), v0.mLambda(), v0.eta(), cent); + registry.fill(HIST("hEtaPhiVtxzPOILambda"), v0.phi(), v0.eta(), vtxz, wacc); + fGFW->Fill(v0.eta(), fK0sPtAxis->FindBin(v0.pt()) - 1 + ((fLambdaMass->FindBin(v0.mLambda()) - 1) * nK0sPtBins), v0.phi(), wacc * weff * wloc, 16); + if (cfgOutputNUAWeights) + fWeightsLambda->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + } + } + } + + // fill GFW of casc flow + if (cfgOutputCasc) { + for (const auto& casc : Cascades) { + auto bachelor = casc.bachelor_as(); + auto posdau = casc.posTrack_as(); + auto negdau = casc.negTrack_as(); + // check TPC + bool isOmega = false; + bool isXi = false; + + if (bachelor.pt() < trkQualityOpts.cfgCutPtDauMin.value || bachelor.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + if (posdau.pt() < trkQualityOpts.cfgCutPtDauMin.value || posdau.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + if (negdau.pt() < trkQualityOpts.cfgCutPtDauMin.value || negdau.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + + // Omega and antiOmega + if (casc.pt() > trkQualityOpts.cfgCutPtOmegaMin.value && casc.pt() < trkQualityOpts.cfgCutPtOmegaMax.value) { + if (casc.sign() < 0 && std::fabs(casc.yOmega()) < cfgCasc_rapidity && + (std::fabs(bachelor.tpcNSigmaKa()) < cfgNSigma[2] && std::fabs(posdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(negdau.tpcNSigmaPi()) < cfgNSigma[0]) && + ((std::fabs(bachelor.tofNSigmaKa()) < cfgNSigma[5] || bachelor.pt() < lowpt) && (std::fabs(posdau.tofNSigmaPr()) < cfgNSigma[4] || posdau.pt() < lowpt) && (std::fabs(negdau.tofNSigmaPi()) < cfgNSigma[3] || negdau.pt() < lowpt)) && + ((std::fabs(itsResponse.nSigmaITS(bachelor)) < cfgNSigma[8]) || bachelor.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(posdau)) < cfgNSigma[7]) || posdau.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(negdau)) < cfgNSigma[6]) || negdau.pt() < lowpt)) { + registry.fill(HIST("InvMassOmega_all"), casc.pt(), casc.mOmega(), casc.eta(), cent); + isOmega = true; + } else if (casc.sign() > 0 && std::fabs(casc.yOmega()) < cfgCasc_rapidity && + (std::fabs(bachelor.tpcNSigmaKa()) < cfgNSigma[2] && std::fabs(negdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(posdau.tpcNSigmaPi()) < cfgNSigma[0]) && + ((std::fabs(bachelor.tofNSigmaKa()) < cfgNSigma[5] || bachelor.pt() < lowpt) && (std::fabs(negdau.tofNSigmaPr()) < cfgNSigma[4] || negdau.pt() < lowpt) && (std::fabs(posdau.tofNSigmaPi()) < cfgNSigma[3] || posdau.pt() < lowpt)) && + ((std::fabs(itsResponse.nSigmaITS(bachelor)) < cfgNSigma[8]) || bachelor.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(posdau)) < cfgNSigma[7]) || posdau.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(negdau)) < cfgNSigma[6]) || negdau.pt() < lowpt)) { + registry.fill(HIST("InvMassOmega_all"), casc.pt(), casc.mOmega(), casc.eta(), cent); + isOmega = true; + } + } + // Xi and antiXi + if (casc.pt() > trkQualityOpts.cfgCutPtXiMin.value && casc.pt() < trkQualityOpts.cfgCutPtXiMax.value) { + if (casc.sign() < 0 && std::fabs(casc.yXi()) < cfgCasc_rapidity && + (std::fabs(bachelor.tpcNSigmaPi()) < cfgNSigma[0] && std::fabs(posdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(negdau.tpcNSigmaPi()) < cfgNSigma[0]) && + ((std::fabs(bachelor.tofNSigmaPi()) < cfgNSigma[3] || bachelor.pt() < lowpt) && (std::fabs(posdau.tofNSigmaPr()) < cfgNSigma[4] || posdau.pt() < lowpt) && (std::fabs(negdau.tofNSigmaPi()) < cfgNSigma[3] || negdau.pt() < lowpt)) && + ((std::fabs(itsResponse.nSigmaITS(bachelor)) < cfgNSigma[6]) || bachelor.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(posdau)) < cfgNSigma[7]) || posdau.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(negdau)) < cfgNSigma[6]) || negdau.pt() < lowpt)) { + registry.fill(HIST("InvMassXi_all"), casc.pt(), casc.mXi(), casc.eta(), cent); + isXi = true; + } else if (casc.sign() > 0 && std::fabs(casc.yXi()) < cfgCasc_rapidity && + (std::fabs(bachelor.tpcNSigmaPi()) < cfgNSigma[0] && std::fabs(negdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(posdau.tpcNSigmaPi()) < cfgNSigma[0]) && + ((std::fabs(bachelor.tofNSigmaPi()) < cfgNSigma[3] || bachelor.pt() < lowpt) && (std::fabs(negdau.tofNSigmaPr()) < cfgNSigma[4] || negdau.pt() < lowpt) && (std::fabs(posdau.tofNSigmaPi()) < cfgNSigma[3] || posdau.pt() < lowpt)) && + ((std::fabs(itsResponse.nSigmaITS(bachelor)) < cfgNSigma[6]) || bachelor.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(posdau)) < cfgNSigma[7]) || posdau.pt() < lowpt) && ((std::fabs(itsResponse.nSigmaITS(negdau)) < cfgNSigma[6]) || negdau.pt() < lowpt)) { + registry.fill(HIST("InvMassXi_all"), casc.pt(), casc.mXi(), casc.eta(), cent); + isXi = true; + } + } + // fill QA + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/Casc/hqaCasccosPAbefore"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqaCascV0cosPAbefore"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0toPVbefore"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascBachtoPVbefore"), casc.dcabachtopv()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascdaubefore"), casc.dcacascdaughters()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0daubefore"), casc.dcaV0daughters()); + } + + if (!isXi && !isOmega) + continue; + // // topological cut + if (casc.cascradius() < cascBuilderOpts.cfgcasc_radius.value) + continue; + if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cascBuilderOpts.cfgcasc_casccospa.value) + continue; + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cascBuilderOpts.cfgcasc_v0cospa.value) + continue; + if (std::fabs(casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())) < cascBuilderOpts.cfgcasc_dcav0topv.value) + continue; + if (std::fabs(casc.dcabachtopv()) < cascBuilderOpts.cfgcasc_dcabachtopv.value) + continue; + if (casc.dcacascdaughters() > cascBuilderOpts.cfgcasc_dcacascdau.value) + continue; + if (casc.dcaV0daughters() > cascBuilderOpts.cfgcasc_dcav0dau.value) + continue; + if (std::fabs(casc.mLambda() - o2::constants::physics::MassLambda0) > cascBuilderOpts.cfgcasc_mlambdawindow.value) + continue; + // // track quality check + if (!bachelor.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!posdau.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!negdau.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!bachelor.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!posdau.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!negdau.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!bachelor.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (!posdau.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (!negdau.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (trkQualityOpts.cfgCheckGlobalTrack.value) { + if (!bachelor.hasTPC() || !bachelor.hasITS()) + continue; + if (!posdau.hasTPC() || !posdau.hasITS()) + continue; + if (!negdau.hasTPC() || !negdau.hasITS()) + continue; + } + if (isXi && std::fabs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) < cascBuilderOpts.cfgcasc_compmassrej.value) { + isXi = false; + } + if (isOmega && std::fabs(casc.mXi() - o2::constants::physics::MassXiMinus) < cascBuilderOpts.cfgcasc_compmassrej.value) { + isXi = false; + } + // fill QA + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/Casc/hqaCasccosPAafter"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqaCascV0cosPAafter"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0toPVafter"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascBachtoPVafter"), casc.dcabachtopv()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascdauafter"), casc.dcacascdaughters()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0dauafter"), casc.dcaV0daughters()); + } + + float weffBac = 1; + float weffPos = 1; + float weffNeg = 1; + float waccBac = 1; + float waccPos = 1; + float waccNeg = 1; + if (isOmega) { + if (cfgDoAccEffCorr) { + setCurrentParticleWeights(weff, wacc, casc, vtxz, 4); + setCurrentParticleWeights(weffBac, waccBac, bachelor, vtxz, 0); + setCurrentParticleWeights(weffPos, waccPos, posdau, vtxz, 0); + setCurrentParticleWeights(weffNeg, waccNeg, negdau, vtxz, 0); + } + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(casc.phi(), -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, casc, density, 4); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecOmega"), casc.pt(), nch, density, casc.mOmega()); + } + registry.fill(HIST("hEtaPhiVtxzPOIOmega"), casc.phi(), casc.eta(), vtxz, wacc); + registry.fill(HIST("InvMassOmega"), casc.pt(), casc.mOmega(), casc.eta(), cent); + fGFW->Fill(casc.eta(), fOmegaPtAxis->FindBin(casc.pt()) - 1 + ((fOmegaMass->FindBin(casc.mOmega()) - 1) * nOmegaPtBins), casc.phi(), wacc * weff * wloc, 4); + fGFW->Fill(bachelor.eta(), 1, bachelor.phi(), waccBac * weffBac * wloc, 4096); + fGFW->Fill(posdau.eta(), 1, posdau.phi(), waccPos * weffPos * wloc, 4096); + fGFW->Fill(negdau.eta(), 1, negdau.phi(), waccNeg * weffNeg * wloc, 4096); + + if (cfgOutputNUAWeights) + fWeightsOmega->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + } + if (isXi) { + if (cfgDoAccEffCorr) { + setCurrentParticleWeights(weff, wacc, casc, vtxz, 3); + setCurrentParticleWeights(weffBac, waccBac, bachelor, vtxz, 0); + setCurrentParticleWeights(weffPos, waccPos, posdau, vtxz, 0); + setCurrentParticleWeights(weffNeg, waccNeg, negdau, vtxz, 0); + } + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(casc.phi(), -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, casc, density, 3); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecXi"), casc.pt(), nch, density, casc.mXi()); + } + registry.fill(HIST("hEtaPhiVtxzPOIXi"), casc.phi(), casc.eta(), vtxz, wacc); + registry.fill(HIST("InvMassXi"), casc.pt(), casc.mXi(), casc.eta(), cent); + fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fXiMass->FindBin(casc.mXi()) - 1) * nXiPtBins), casc.phi(), wacc * weff * wloc, 2); + fGFW->Fill(bachelor.eta(), 1, bachelor.phi(), waccBac * weffBac * wloc, 2048); + fGFW->Fill(posdau.eta(), 1, posdau.phi(), waccPos * weffPos * wloc, 2048); + fGFW->Fill(negdau.eta(), 1, negdau.phi(), waccNeg * weffNeg * wloc, 2048); + + if (cfgOutputNUAWeights) + fWeightsXi->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + } + } + } + + delete hLocalDensity; + // Filling cumulant with ROOT TProfile and loop for all ptBins + fillProfile(corrconfigs.at(20), HIST("c22"), cent); + fillProfile(corrconfigs.at(21), HIST("c24"), cent); + fillProfile(corrconfigs.at(22), HIST("c22Full"), cent); + fillProfile(corrconfigs.at(31), HIST("c32"), cent); + for (int i = 1; i <= nPtBins; i++) { + fillProfilepT(corrconfigs.at(0), HIST("c22dpt"), i, cent); + fillProfilepT(corrconfigs.at(1), HIST("c22dpt"), i, cent); + fillProfilepT(corrconfigs.at(2), HIST("c24dpt"), i, cent); + fillProfilepT(corrconfigs.at(3), HIST("c22Fulldpt"), i, cent); + } + if (cfgOutputV0) { + for (int i = 1; i <= nK0sPtBins; i++) { + fillProfilepTMass(corrconfigs.at(12), HIST("K0sc22dpt"), i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(13), HIST("K0sc22dpt"), i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(14), HIST("K0sc24dpt"), i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(15), HIST("K0sc22Fulldpt"), i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(27), HIST("K0sc32dpt"), i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(28), HIST("K0sc32dpt"), i, kK0Short, cent); + } + for (int i = 1; i <= nLambdaPtBins; i++) { + fillProfilepTMass(corrconfigs.at(16), HIST("Lambdac22dpt"), i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(17), HIST("Lambdac22dpt"), i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(18), HIST("Lambdac24dpt"), i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(19), HIST("Lambdac22Fulldpt"), i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(29), HIST("Lambdac32dpt"), i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(30), HIST("Lambdac32dpt"), i, kLambda0, cent); + } + } + if (cfgOutputCasc) { + for (int i = 1; i <= nXiPtBins; i++) { + fillProfilepTMass(corrconfigs.at(4), HIST("Xic22dpt"), i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(5), HIST("Xic22dpt"), i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(6), corrconfigs.at(44), HIST("Xic24dpt"), i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(7), corrconfigs.at(43), HIST("Xic22Fulldpt"), i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(23), HIST("Xic32dpt"), i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(24), HIST("Xic32dpt"), i, kXiMinus, cent); + + fillProfilepTMass(corrconfigs.at(41), HIST("Xic24_gapdpt"), i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(42), HIST("Xic24_gapdpt"), i, kXiMinus, cent); + } + for (int i = 1; i <= nOmegaPtBins; i++) { + fillProfilepTMass(corrconfigs.at(8), HIST("Omegac22dpt"), i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(9), HIST("Omegac22dpt"), i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(10), corrconfigs.at(48), HIST("Omegac24dpt"), i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(11), corrconfigs.at(47), HIST("Omegac22Fulldpt"), i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(25), HIST("Omegac32dpt"), i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(26), HIST("Omegac32dpt"), i, kOmegaMinus, cent); + + fillProfilepTMass(corrconfigs.at(45), HIST("Omegac24_gapdpt"), i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(46), HIST("Omegac24_gapdpt"), i, kOmegaMinus, cent); + } + } + // Fill subevents flow + if (cfgDoJackknife) { + TRandom3* fRdm = new TRandom3(0); + int nsubevent = 10; + double eventrdm = nsubevent * fRdm->Rndm(); + for (int j = 1; j <= nsubevent; j++) { + if (eventrdm > (j - 1) && eventrdm < j) + continue; + fillProfile(corrconfigs.at(20), refc22[j - 1], cent); + fillProfile(corrconfigs.at(21), refc24[j - 1], cent); + fillProfile(corrconfigs.at(22), refc22Full[j - 1], cent); + fillProfile(corrconfigs.at(31), refc32[j - 1], cent); + if (cfgOutputV0) { + for (int i = 1; i <= nK0sPtBins; i++) { + fillProfilepTMass(corrconfigs.at(12), k0sc22[j - 1], i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(13), k0sc22[j - 1], i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(14), k0sc24[j - 1], i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(15), k0sc22Full[j - 1], i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(27), k0sc32[j - 1], i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(28), k0sc32[j - 1], i, kK0Short, cent); + } + for (int i = 1; i <= nLambdaPtBins; i++) { + fillProfilepTMass(corrconfigs.at(16), lambdac22[j - 1], i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(17), lambdac22[j - 1], i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(18), lambdac24[j - 1], i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(19), lambdac22Full[j - 1], i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(29), lambdac32[j - 1], i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(30), lambdac32[j - 1], i, kLambda0, cent); + } + } + if (cfgOutputCasc) { + for (int i = 1; i <= nXiPtBins; i++) { + fillProfilepTMass(corrconfigs.at(4), xic22[j - 1], i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(5), xic22[j - 1], i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(6), corrconfigs.at(44), xic24[j - 1], i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(7), corrconfigs.at(43), xic22Full[j - 1], i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(23), xic32[j - 1], i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(24), xic32[j - 1], i, kXiMinus, cent); + } + for (int i = 1; i <= nOmegaPtBins; i++) { + fillProfilepTMass(corrconfigs.at(8), omegac22[j - 1], i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(9), omegac22[j - 1], i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(10), corrconfigs.at(48), omegac24[j - 1], i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(11), corrconfigs.at(47), omegac22Full[j - 1], i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(25), omegac32[j - 1], i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(26), omegac32[j - 1], i, kOmegaMinus, cent); + } + } + } + } + } + PROCESS_SWITCH(FlowGfwOmegaXi, processData, "", true); + + void processMCGen(aod::McCollisions::iterator const&, soa::Join const& tracksGen, soa::SmallGroups> const& collisionsRec, AodTracks const&) + { + fGFW->Clear(); + int nch = 0; + double cent = -1; + TH1D* hLocalDensity = new TH1D("hphi", "hphi", 400, -constants::math::TwoPI, constants::math::TwoPI); + for (const auto& collision : collisionsRec) { + if (!collision.sel8()) + return; + if (eventSelected(collision, cent)) + return; + cent = collision.centFT0C(); + } + if (cent < 0) + return; + + for (auto const& mcParticle : tracksGen) { + if (!mcParticle.isPhysicalPrimary()) + continue; + + if (mcParticle.has_tracks()) { + auto const& tracks = mcParticle.tracks_as(); + for (const auto& track : tracks) { + if (std::fabs(track.eta()) > trkQualityOpts.cfgCutEta.value) { + continue; + } + if (!(track.isGlobalTrack())) { + continue; + } + if (track.tpcChi2NCl() > cfgCutChi2prTPCcls) { + continue; + } + int ptbin = fPtAxis->FindBin(mcParticle.pt()) - 1; + if ((mcParticle.pt() > trkQualityOpts.cfgCutPtMin.value) && (mcParticle.pt() < trkQualityOpts.cfgCutPtMax.value)) { + fGFW->Fill(mcParticle.eta(), ptbin, mcParticle.phi(), 1, 64); //(eta, ptbin, phi, wacc*weff, bitmask) + } + if ((mcParticle.pt() > trkQualityOpts.cfgCutPtPOIMin.value) && (mcParticle.pt() < trkQualityOpts.cfgCutPtPOIMax.value)) { + hLocalDensity->Fill(mcParticle.phi(), 1); + hLocalDensity->Fill(RecoDecay::constrainAngle(mcParticle.phi(), -constants::math::TwoPI), 1); + nch++; + } + } + } + } + registry.fill(HIST("MC/hCentvsNchMC"), cent, nch); + + for (const auto& straGen : tracksGen) { + if (!straGen.isPhysicalPrimary()) + continue; + int pdgCode = std::abs(straGen.pdgCode()); + if (pdgCode != PDG_t::kXiMinus && pdgCode != PDG_t::kOmegaMinus && pdgCode != PDG_t::kK0Short && pdgCode != PDG_t::kLambda0) + continue; + if (std::fabs(straGen.eta()) > trkQualityOpts.cfgCutEta.value) + continue; + + if (pdgCode == PDG_t::kXiMinus) { + int phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(straGen.phi(), -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCGenXi"), straGen.pt(), nch, density); + fGFW->Fill(straGen.eta(), fXiPtAxis->FindBin(straGen.pt()) - 1, straGen.phi(), 1, 128); + } + if (pdgCode == PDG_t::kOmegaMinus) { + int phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(straGen.phi(), -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCGenOmega"), straGen.pt(), nch, density); + fGFW->Fill(straGen.eta(), fOmegaPtAxis->FindBin(straGen.pt()) - 1, straGen.phi(), 1, 256); + } + + if (pdgCode == PDG_t::kK0Short) { + int phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(straGen.phi(), -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCGenK0s"), straGen.pt(), nch, density); + fGFW->Fill(straGen.eta(), fK0sPtAxis->FindBin(straGen.pt()) - 1, straGen.phi(), 1, 512); + } + if (pdgCode == PDG_t::kLambda0) { + int phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(straGen.phi(), -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCGenLambda"), straGen.pt(), nch, density); + fGFW->Fill(straGen.eta(), fLambdaPtAxis->FindBin(straGen.pt()) - 1, straGen.phi(), 1, 1024); + } + } + fillProfile(corrconfigs.at(40), HIST("MC/c22MC"), cent); + for (int i = 1; i <= nK0sPtBins; i++) { + fillProfilepTMC(corrconfigs.at(36), HIST("MC/K0sc22dptMC"), i, kK0Short, cent); + fillProfilepTMC(corrconfigs.at(37), HIST("MC/K0sc22dptMC"), i, kK0Short, cent); + } + for (int i = 1; i <= nLambdaPtBins; i++) { + fillProfilepTMC(corrconfigs.at(38), HIST("MC/Lambdac22dptMC"), i, kLambda0, cent); + fillProfilepTMC(corrconfigs.at(39), HIST("MC/Lambdac22dptMC"), i, kLambda0, cent); + } + for (int i = 1; i <= nXiPtBins; i++) { + fillProfilepTMC(corrconfigs.at(32), HIST("MC/Xic22dptMC"), i, kXiMinus, cent); + fillProfilepTMC(corrconfigs.at(33), HIST("MC/Xic22dptMC"), i, kXiMinus, cent); + } + for (int i = 1; i <= nOmegaPtBins; i++) { + fillProfilepTMC(corrconfigs.at(34), HIST("MC/Omegac22dptMC"), i, kOmegaMinus, cent); + fillProfilepTMC(corrconfigs.at(35), HIST("MC/Omegac22dptMC"), i, kOmegaMinus, cent); + } + + delete hLocalDensity; + } + PROCESS_SWITCH(FlowGfwOmegaXi, processMCGen, "", true); + + void processMCRec(AodCollisions::iterator const& collision, soa::Join const& tracks, aod::BCsWithTimestamps const&, soa::Join const& V0s, soa::Join const& Cascades, DaughterTracks const&, aod::McParticles const&) + { + fGFW->Clear(); + const auto cent = collision.centFT0C(); + if (!collision.sel8()) + return; + if (eventSelected(collision, cent)) + return; + TH1D* hLocalDensity = new TH1D("hphi", "hphi", 400, -constants::math::TwoPI, constants::math::TwoPI); + auto bc = collision.bc_as(); + loadCorrections(bc.timestamp()); + float vtxz = collision.posZ(); + registry.fill(HIST("hVtxZ"), vtxz); + registry.fill(HIST("hCent"), cent); + + float weff = 1; + float wacc = 1; + float wloc = 1; + double nch = 0; + + for (const auto& track : tracks) { + if (track.pt() < trkQualityOpts.cfgCutPtPOIMin.value || track.pt() > trkQualityOpts.cfgCutPtPOIMax.value) + continue; + if (std::fabs(track.eta()) > trkQualityOpts.cfgCutEta.value) + continue; + if (!(track.isGlobalTrack())) + continue; + if (track.tpcChi2NCl() > cfgCutChi2prTPCcls) + continue; + if (cfgDoAccEffCorr) { + if (!setCurrentParticleWeights(weff, wacc, track, vtxz, 0)) + continue; + } + nch += wacc * weff; + if (!track.has_mcParticle()) + continue; + auto mcParticle = track.mcParticle_as(); + registry.fill(HIST("hPhi"), track.phi()); + registry.fill(HIST("hPhicorr"), track.phi(), wacc); + registry.fill(HIST("hEta"), track.eta()); + registry.fill(HIST("hEtaPhiVtxzREF"), track.phi(), track.eta(), vtxz, wacc); + registry.fill(HIST("hPt"), track.pt()); + int ptbin = fPtAxis->FindBin(track.pt()) - 1; + if ((track.pt() > trkQualityOpts.cfgCutPtMin.value) && (track.pt() < trkQualityOpts.cfgCutPtMax.value)) { + fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 1); //(eta, ptbin, phi, wacc*weff, bitmask) + } + if ((track.pt() > trkQualityOpts.cfgCutPtPOIMin.value) && (track.pt() < trkQualityOpts.cfgCutPtPOIMax.value)) { + fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 32); + if (cfgDoLocDenCorr) { + hLocalDensity->Fill(mcParticle.phi(), wacc * weff); + hLocalDensity->Fill(RecoDecay::constrainAngle(mcParticle.phi(), -constants::math::TwoPI), wacc * weff); + } + } + } + + if (cfgDoLocDenCorr) { + registry.fill(HIST("hCentvsNch"), cent, nch); + } + + for (const auto& casc : Cascades) { + if (!casc.has_mcParticle()) + continue; + auto cascMC = casc.mcParticle_as(); + auto negdau = casc.negTrack_as(); + auto posdau = casc.posTrack_as(); + auto bachelor = casc.bachelor_as(); + if (bachelor.pt() < trkQualityOpts.cfgCutPtDauMin.value || bachelor.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + if (posdau.pt() < trkQualityOpts.cfgCutPtDauMin.value || posdau.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + if (negdau.pt() < trkQualityOpts.cfgCutPtDauMin.value || negdau.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + // fill QA + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/Casc/hqaCasccosPAbefore"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqaCascV0cosPAbefore"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0toPVbefore"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascBachtoPVbefore"), casc.dcabachtopv()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascdaubefore"), casc.dcacascdaughters()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0daubefore"), casc.dcaV0daughters()); + } + // track quality check + if (!bachelor.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!posdau.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!negdau.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!bachelor.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!posdau.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!negdau.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!bachelor.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (!posdau.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (!negdau.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (trkQualityOpts.cfgCheckGlobalTrack.value) { + if (!bachelor.hasTPC() || !bachelor.hasITS()) + continue; + if (!posdau.hasTPC() || !posdau.hasITS()) + continue; + if (!negdau.hasTPC() || !negdau.hasITS()) + continue; + } + // // topological cut + if (casc.cascradius() < cascBuilderOpts.cfgcasc_radius.value) + continue; + if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cascBuilderOpts.cfgcasc_casccospa.value) + continue; + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cascBuilderOpts.cfgcasc_v0cospa.value) + continue; + if (std::fabs(casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())) < cascBuilderOpts.cfgcasc_dcav0topv.value) + continue; + if (std::fabs(casc.dcabachtopv()) < cascBuilderOpts.cfgcasc_dcabachtopv.value) + continue; + if (casc.dcacascdaughters() > cascBuilderOpts.cfgcasc_dcacascdau.value) + continue; + if (casc.dcaV0daughters() > cascBuilderOpts.cfgcasc_dcav0dau.value) + continue; + if (std::fabs(casc.mLambda() - o2::constants::physics::MassLambda0) > cascBuilderOpts.cfgcasc_mlambdawindow.value) + continue; + // fill QA + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/Casc/hqaCasccosPAafter"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqaCascV0cosPAafter"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0toPVafter"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("QAhisto/Casc/hqadcaCascBachtoPVafter"), casc.dcabachtopv()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascdauafter"), casc.dcacascdaughters()); + registry.fill(HIST("QAhisto/Casc/hqadcaCascV0dauafter"), casc.dcaV0daughters()); + } + // Omega and antiOmega + int pdgCode{cascMC.pdgCode()}; + double cascPt{cascMC.pt()}; + double cascPhi{cascMC.phi()}; + double cascEta{cascMC.eta()}; + if (std::abs(pdgCode) == kOmegaMinus) { + if (casc.sign() < 0 && std::fabs(casc.yOmega()) < cfgCasc_rapidity && + (std::fabs(bachelor.tpcNSigmaKa()) < cfgNSigma[2] && std::fabs(posdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(negdau.tpcNSigmaPi()) < cfgNSigma[0])) { + if (cfgDoAccEffCorr) + setCurrentParticleWeights(weff, wacc, casc, vtxz, 4); + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(cascPhi, -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, casc, density, 4); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecOmega"), cascPt, nch, density, casc.mOmega()); + } + fGFW->Fill(cascEta, fOmegaPtAxis->FindBin(cascPt) - 1, cascPhi, wacc * weff * wloc, 4); + } else if (casc.sign() > 0 && std::fabs(casc.yOmega()) < cfgCasc_rapidity && + (std::fabs(bachelor.tpcNSigmaKa()) < cfgNSigma[2] && std::fabs(negdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(posdau.tpcNSigmaPi()) < cfgNSigma[0])) { + if (cfgDoAccEffCorr) + setCurrentParticleWeights(weff, wacc, casc, vtxz, 4); + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(cascPhi, -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, casc, density, 4); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecOmega"), cascPt, nch, density, casc.mOmega()); + } + fGFW->Fill(cascEta, fOmegaPtAxis->FindBin(cascPt) - 1, cascPhi, wacc * weff * wloc, 4); + } + } + // Xi and antiXi + if (std::abs(pdgCode) == kXiMinus) { + if (casc.sign() < 0 && std::fabs(casc.yXi()) < cfgCasc_rapidity && + (std::fabs(bachelor.tpcNSigmaPi()) < cfgNSigma[0] && std::fabs(posdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(negdau.tpcNSigmaPi()) < cfgNSigma[0])) { + if (cfgDoAccEffCorr) + setCurrentParticleWeights(weff, wacc, casc, vtxz, 3); + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(cascPhi, -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, casc, density, 3); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecXi"), cascPt, nch, density, casc.mXi()); + } + fGFW->Fill(cascEta, fXiPtAxis->FindBin(cascPt) - 1, cascPhi, wacc * weff * wloc, 2); + } else if (casc.sign() > 0 && std::fabs(casc.yXi()) < cfgCasc_rapidity && + (std::fabs(bachelor.tpcNSigmaPi()) < cfgNSigma[0] && std::fabs(negdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(posdau.tpcNSigmaPi()) < cfgNSigma[0])) { + if (cfgDoAccEffCorr) + setCurrentParticleWeights(weff, wacc, casc, vtxz, 3); + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(cascPhi, -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, casc, density, 3); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecXi"), cascPt, nch, density, casc.mXi()); + } + fGFW->Fill(cascEta, fXiPtAxis->FindBin(cascPt) - 1, cascPhi, wacc * weff * wloc, 2); + } + } + } + + for (const auto& v0 : V0s) { + if (!v0.has_mcParticle()) + continue; + auto v0MC = v0.mcParticle_as(); + auto v0negdau = v0.negTrack_as(); + auto v0posdau = v0.posTrack_as(); + + if (v0posdau.pt() < trkQualityOpts.cfgCutPtDauMin.value || v0posdau.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + if (v0negdau.pt() < trkQualityOpts.cfgCutPtDauMin.value || v0negdau.pt() > trkQualityOpts.cfgCutPtDauMax.value) + continue; + + // fill QA before cut + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/V0/hqaV0radiusbefore"), v0.v0radius()); + registry.fill(HIST("QAhisto/V0/hqaV0cosPAbefore"), v0.v0cosPA()); + registry.fill(HIST("QAhisto/V0/hqadcaV0daubefore"), v0.dcaV0daughters()); + registry.fill(HIST("QAhisto/V0/hqadcapostoPVbefore"), v0.dcapostopv()); + registry.fill(HIST("QAhisto/V0/hqadcanegtoPVbefore"), v0.dcanegtopv()); + registry.fill(HIST("QAhisto/V0/hqaarm_podobefore"), v0.alpha(), v0.qtarm()); + } + // // track quality check + if (!v0posdau.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!v0negdau.passedITSNCls() && trkQualityOpts.cfgCheckITSNCls.value) + continue; + if (!v0posdau.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!v0negdau.passedITSHits() && trkQualityOpts.cfgCheckITSHits.value) + continue; + if (!v0posdau.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (!v0negdau.passedITSChi2NDF() && trkQualityOpts.cfgCheckITSChi2NDF.value) + continue; + if (trkQualityOpts.cfgCheckGlobalTrack.value) { + if (!v0posdau.hasTPC() || !v0posdau.hasITS()) + continue; + if (!v0negdau.hasTPC() || !v0negdau.hasITS()) + continue; + } + // topological cut + if (v0.v0radius() < v0BuilderOpts.cfgv0_radius.value) + continue; + if (v0.v0cosPA() < v0BuilderOpts.cfgv0_v0cospa.value) + continue; + if (v0.dcaV0daughters() > v0BuilderOpts.cfgv0_dcav0dau.value) + continue; + if (std::fabs(v0.dcapostopv()) < v0BuilderOpts.cfgv0_dcadautopv.value) + continue; + if (std::fabs(v0.dcanegtopv()) < v0BuilderOpts.cfgv0_dcadautopv.value) + continue; + // fill QA after cut + if (cfgOutputQA) { + registry.fill(HIST("QAhisto/V0/hqaV0radiusafter"), v0.v0radius()); + registry.fill(HIST("QAhisto/V0/hqaV0cosPAafter"), v0.v0cosPA()); + registry.fill(HIST("QAhisto/V0/hqadcaV0dauafter"), v0.dcaV0daughters()); + registry.fill(HIST("QAhisto/V0/hqadcapostoPVafter"), v0.dcapostopv()); + registry.fill(HIST("QAhisto/V0/hqadcanegtoPVafter"), v0.dcanegtopv()); + } + + int pdgCode{v0MC.pdgCode()}; + double v0Pt{v0MC.pt()}; + double v0Phi{v0MC.phi()}; + double v0Eta{v0MC.eta()}; + // K0short + if (std::abs(pdgCode) == kK0Short) { + if (v0.qtarm() / std::fabs(v0.alpha()) > v0BuilderOpts.cfgv0_ArmPodocut.value && + std::fabs(v0.mK0Short() - o2::constants::physics::MassK0Short) < v0BuilderOpts.cfgv0_mk0swindow.value && + (std::fabs(v0posdau.tpcNSigmaPi()) < cfgNSigma[0] && std::fabs(v0negdau.tpcNSigmaPi()) < cfgNSigma[0])) { + if (cfgDoAccEffCorr) + setCurrentParticleWeights(weff, wacc, v0, vtxz, 1); + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(v0Phi, -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, v0, density, 1); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecK0s"), v0Pt, nch, density, v0.mK0Short()); + } + fGFW->Fill(v0Eta, fK0sPtAxis->FindBin(v0Pt) - 1, v0Phi, wacc * weff * wloc, 8); + } + } + // Lambda and antiLambda + if (std::fabs(v0.mLambda() - o2::constants::physics::MassLambda) < v0BuilderOpts.cfgv0_mlambdawindow.value && + (std::fabs(v0posdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(v0negdau.tpcNSigmaPi()) < cfgNSigma[0])) { + if (std::abs(pdgCode) == kLambda0) { + if (cfgDoAccEffCorr) + setCurrentParticleWeights(weff, wacc, v0, vtxz, 2); + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(v0Phi, -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, v0, density, 2); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecLambda"), v0Pt, nch, density, v0.mLambda()); + } + fGFW->Fill(v0Eta, fLambdaPtAxis->FindBin(v0Pt) - 1, v0Phi, wacc * weff * wloc, 16); + } + } else if (std::fabs(v0.mLambda() - o2::constants::physics::MassLambda) < v0BuilderOpts.cfgv0_mlambdawindow.value && + (std::fabs(v0negdau.tpcNSigmaPr()) < cfgNSigma[1] && std::fabs(v0posdau.tpcNSigmaPi()) < cfgNSigma[0])) { + if (std::abs(pdgCode) == kLambda0) { + if (cfgDoAccEffCorr) + setCurrentParticleWeights(weff, wacc, v0, vtxz, 2); + if (cfgDoLocDenCorr) { + int phibin = -999; + phibin = hLocalDensity->FindBin(RecoDecay::constrainAngle(v0Phi, -constants::math::PI)); + double density = hLocalDensity->Integral(phibin - cfgDeltaPhiLocDen, phibin + cfgDeltaPhiLocDen); + setCurrentLocalDensityWeights(wloc, v0, density, 2); + if (cfgOutputLocDenWeights) + registry.fill(HIST("MC/densityMCRecLambda"), v0Pt, nch, density, v0.mLambda()); + } + fGFW->Fill(v0Eta, fLambdaPtAxis->FindBin(v0Pt) - 1, v0Phi, wacc * weff * wloc, 16); + } + } + } + delete hLocalDensity; + fillProfile(corrconfigs.at(20), HIST("c22"), cent); + fillProfile(corrconfigs.at(31), HIST("c32"), cent); + for (int i = 1; i <= nK0sPtBins; i++) { + fillProfilepTMass(corrconfigs.at(12), HIST("K0sc22dpt"), i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(13), HIST("K0sc22dpt"), i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(27), HIST("K0sc32dpt"), i, kK0Short, cent); + fillProfilepTMass(corrconfigs.at(28), HIST("K0sc32dpt"), i, kK0Short, cent); + } + for (int i = 1; i <= nLambdaPtBins; i++) { + fillProfilepTMass(corrconfigs.at(16), HIST("Lambdac22dpt"), i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(17), HIST("Lambdac22dpt"), i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(29), HIST("Lambdac32dpt"), i, kLambda0, cent); + fillProfilepTMass(corrconfigs.at(30), HIST("Lambdac32dpt"), i, kLambda0, cent); + } + for (int i = 1; i <= nXiPtBins; i++) { + fillProfilepTMass(corrconfigs.at(4), HIST("Xic22dpt"), i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(5), HIST("Xic22dpt"), i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(23), HIST("Xic32dpt"), i, kXiMinus, cent); + fillProfilepTMass(corrconfigs.at(24), HIST("Xic32dpt"), i, kXiMinus, cent); + } + for (int i = 1; i <= nOmegaPtBins; i++) { + fillProfilepTMass(corrconfigs.at(8), HIST("Omegac22dpt"), i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(9), HIST("Omegac22dpt"), i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(25), HIST("Omegac32dpt"), i, kOmegaMinus, cent); + fillProfilepTMass(corrconfigs.at(26), HIST("Omegac32dpt"), i, kOmegaMinus, cent); + } + } + PROCESS_SWITCH(FlowGfwOmegaXi, processMCRec, "", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/flowGfwTask.cxx b/PWGCF/Flow/Tasks/flowGfwTask.cxx new file mode 100644 index 00000000000..e5854dcf43b --- /dev/null +++ b/PWGCF/Flow/Tasks/flowGfwTask.cxx @@ -0,0 +1,1287 @@ +// 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. + +/// \file flowGfwTask.cxx +/// \author Iris Likmeta (iris.likmeta@cern.ch) +/// \since Mar 28, 2024 +/// \brief Multiparticle flow measurements with FT0 and ZDC + +#include +#include +#include +#include +#include +#include +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/AnalysisDataModel.h" + +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include "Framework/O2DatabasePDGPlugin.h" +#include "ReconstructionDataFormats/GlobalTrackID.h" +#include "ReconstructionDataFormats/Track.h" +#include "TPDGCode.h" + +#include "GFWPowerArray.h" +#include "GFW.h" +#include "GFWCumulant.h" +#include "GFWWeights.h" +#include "FlowContainer.h" +#include "TList.h" +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::track; +using namespace o2::aod::evsel; + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +using MyCollisions = soa::Join; +using MyTracks = soa::Join; +using Colls = soa::Filtered>; +using AodTracks = soa::Filtered>; +using BCsRun3 = soa::Join; + +struct FlowGfwTask { + + O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 3.0f, "Maximal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 70.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters") + O2_DEFINE_CONFIGURABLE(cfgTrackSel, bool, false, "ITS and TPC cluster selection") + O2_DEFINE_CONFIGURABLE(cfgMinCentFT0C, float, 0.0f, "Minimum FT0C Centrality") + O2_DEFINE_CONFIGURABLE(cfgMaxCentFT0C, float, 100.0f, "Maximum FT0C Centrality") + O2_DEFINE_CONFIGURABLE(cfgcentEstFt0c, bool, false, "Centrality estimator based on FT0C signal") + O2_DEFINE_CONFIGURABLE(cfgcentEstFt0a, bool, false, "Centrality estimator based on FT0A signal") + O2_DEFINE_CONFIGURABLE(cfgcentEstFt0m, bool, false, " A centrality estimator based on FT0A+FT0C signals.") + O2_DEFINE_CONFIGURABLE(cfgcentEstFv0a, bool, false, "Centrality estimator based on FV0A signal") + O2_DEFINE_CONFIGURABLE(cfgcentEstFt0cVariant1, bool, false, "A variant of FT0C") + O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") + O2_DEFINE_CONFIGURABLE(cfgUseAdditionalTrackCut, bool, false, "Use additional track cut on phi") + O2_DEFINE_CONFIGURABLE(cfgTrackSelRun3ITSMatch, bool, false, "Track selection for ITS matches") + O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables") + O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights") + O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgEfficiencyNch, std::string, "", "CCDB path to Nch efficiency object") + O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgMagnetField, std::string, "GLO/Config/GRPMagField", "CCDB path to Magnet field object") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2, "Custom DCA Z cut") + O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 0.2f, "Custom DCA XY cut") + O2_DEFINE_CONFIGURABLE(cfgDCAzPt, bool, false, "switch for DCAz pt dependent") + O2_DEFINE_CONFIGURABLE(cfgNoTimeFrameBorder, bool, false, "kNoTimeFrameBorder"); + O2_DEFINE_CONFIGURABLE(cfgNoITSROFrameBorder, bool, false, "kNoITSROFrameBorder"); + O2_DEFINE_CONFIGURABLE(cfgNoSameBunchPileup, bool, false, "kNoSameBunchPileup"); + O2_DEFINE_CONFIGURABLE(cfgIsGoodZvtxFT0vsPV, bool, false, "kIsGoodZvtxFT0vsPV"); + O2_DEFINE_CONFIGURABLE(cfgIsVertexITSTPC, bool, false, "kIsVertexITSTPC"); + O2_DEFINE_CONFIGURABLE(cfgNoCollInTimeRangeStandard, bool, false, "kNoCollInTimeRangeStandard"); + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodITSLayersAll, bool, false, "kIsGoodITSLayersAll") + O2_DEFINE_CONFIGURABLE(cfgOccupancy, bool, false, "Bool for event selection on detector occupancy"); + O2_DEFINE_CONFIGURABLE(cfgMultCut, bool, false, "Use additional event cut on mult correlations"); + O2_DEFINE_CONFIGURABLE(cfgV0AT0A5Sigma, bool, false, "V0A T0A 5 sigma cut") + O2_DEFINE_CONFIGURABLE(cfgGlobalplusITS, bool, false, "Global and ITS tracks") + O2_DEFINE_CONFIGURABLE(cfgGlobalonly, bool, false, "Global only tracks") + O2_DEFINE_CONFIGURABLE(cfgITSonly, bool, false, "ITS only tracks") + O2_DEFINE_CONFIGURABLE(cfgFineBinning, bool, false, "Manually change to fine binning") + + ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for histograms"}; + ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; + ConfigurableAxis axisPhiMod{"axisPhiMod", {100, 0, constants::math::PI / 9}, "fmod(#varphi,#pi/9)"}; + ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.30, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00}, "pt axis for histograms"}; + ConfigurableAxis axisPtHist{"axisPtHist", {100, 0., 10.}, "pt axis for histograms"}; + ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, "centrality axis for histograms"}; + ConfigurableAxis axisNch{"axisNch", {4000, 0, 4000}, "N_{ch}"}; + ConfigurableAxis axisCentForQA{"axisCentForQA", {100, 0, 100}, "centrality for QA"}; + ConfigurableAxis axisT0C{"axisT0C", {70, 0, 70000}, "N_{ch} (T0C)"}; + ConfigurableAxis axisT0A{"axisT0A", {200, 0, 200000}, "N_{ch} (T0A)"}; + ConfigurableAxis axisT0M{"axisT0M", {70, 0, 70000}, "N_{ch} (T0M)"}; + ConfigurableAxis axisFT0CAmp{"axisFT0CAmp", {50000, 0, 50000}, "axisFT0CAmp"}; + ConfigurableAxis axisFT0AAmp{"axisFT0AAmp", {50000, 0, 50000}, "axisFT0AAmp"}; + ConfigurableAxis axisFT0MAmp{"axisFT0MAmp", {50000, 0, 50000}, "axisFT0MAmp"}; + ConfigurableAxis axisNchPV{"axisNchPV", {4000, 0, 4000}, "N_{ch} (PV)"}; + ConfigurableAxis axisDCAz{"axisDCAz", {200, -2, 2}, "DCA_{z} (cm)"}; + ConfigurableAxis axisDCAxy{"axisDCAxy", {200, -1, 1}, "DCA_{xy} (cm)"}; + + // Configurables for ZDC + Configurable nBinsAmp{"nBinsAmp", 1025, "nbinsAmp"}; + Configurable maxZN{"maxZN", 4099.5, "Max ZN signal"}; + Configurable maxZP{"maxZP", 3099.5, "Max ZP signal"}; + Configurable maxZEM{"maxZEM", 3099.5, "Max ZEM signal"}; + Configurable nBinsFit{"nBinsFit", 1000, "nbinsFit"}; + Configurable maxMultFT0{"maxMultFT0", 5000, "Max FT0 signal"}; + + // Corrections + TH1D* mEfficiency = nullptr; + TH1D* mEfficiencyNch = nullptr; + GFWWeights* mAcceptance = nullptr; + bool correctionsLoaded = false; + + // Connect to ccdb + Service ccdb; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + // Define output + OutputObj fFC{FlowContainer("FlowContainer")}; + OutputObj fWeights{GFWWeights("weights")}; + HistogramRegistry registry{"registry"}; + + // define global variables + GFW* fGFW = new GFW(); // GFW class used from main src + std::vector corrconfigs; + TRandom3* fRndm = new TRandom3(0); + TAxis* fPtAxis; + std::vector>> bootstrapArray; // TProfile is a shared pointer + + enum ExtraProfile { + + // here are TProfiles for vn-ft0 correlations that are not implemented in GFW + kc22, + kc24, + kc26, + kc28, + kc22etagap, + kc32, + kc32etagap, + kc34, + kc22Nch, + kc24Nch, + kc26Nch, + kc28Nch, + kc22Nchetagap, + kc32Nch, + kc32Nchetagap, + kc34Nch, + kc22Nch05, + kc24Nch05, + kc26Nch05, + kc28Nch05, + kc22Nch05etagap, + kc32Nch05, + kc32Nch05etagap, + kc34Nch05, + + // Count the total number of enum + kCount_ExtraProfile + }; + + enum EventProgress { + kFILTERED, + kSEL8, + kOCCUPANCY, + kNOTIMEFRAMEBORDER, + kNOITSROFRAMEBORDER, + kNOPSAMEBUNCHPILEUP, + kISGOODZVTXFT0VSPV, + kISVERTEXITSTPC, + kNOCOLLINTIMERANGESTANDART, + kISGOODITSLAYERSALL, + kAFTERMULTCUTS, + kCENTRALITY, + kNOOFEVENTSTEPS + }; + + enum CentEstimators { + kCentFT0C, + kCentFT0A, + kCentFT0M, + kCentFV0A, + kCentFT0CVariant1, + kNoCentEstimators + }; + + // Contruct Global+ITS sample + static constexpr TrackSelectionFlags::flagtype TrackSelectionITS = + TrackSelectionFlags::kITSNCls | TrackSelectionFlags::kITSChi2NDF | + TrackSelectionFlags::kITSHits; + static constexpr TrackSelectionFlags::flagtype TrackSelectionTPC = + TrackSelectionFlags::kTPCNCls | + TrackSelectionFlags::kTPCCrossedRowsOverNCls | + TrackSelectionFlags::kTPCChi2NDF; + static constexpr TrackSelectionFlags::flagtype TrackSelectionDCA = + TrackSelectionFlags::kDCAz | TrackSelectionFlags::kDCAxy; + static constexpr TrackSelectionFlags::flagtype TrackSelectionDCAXYonly = + TrackSelectionFlags::kDCAxy; + + // Additional Event selection cuts - Copy from flowGenericFramework.cxx + TrackSelection myTrackSel; + TF1* fPhiCutLow = nullptr; + TF1* fPhiCutHigh = nullptr; + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fMultMultPVCut = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + + bool isStable(int pdg) + { + if (std::abs(pdg) == kPiPlus) + return true; + if (std::abs(pdg) == kKPlus) + return true; + if (std::abs(pdg) == kProton) + return true; + if (std::abs(pdg) == kElectron) + return true; + if (std::abs(pdg) == kMuonMinus) + return true; + return false; + } + + void init(InitContext const&) // Initialization + { + ccdb->setURL(ccdbUrl.value); + ccdb->setCaching(true); + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + + // Add some output objects to the histogram registry + registry.add("hEventCount", "Number of Events;; No. of Events", {HistType::kTH1D, {{kNOOFEVENTSTEPS, -0.5, static_cast(kNOOFEVENTSTEPS) - 0.5}}}); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kFILTERED + 1, "Filtered events"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kSEL8 + 1, "Sel8"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kOCCUPANCY + 1, "Occupancy"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kNOTIMEFRAMEBORDER + 1, "kNoTimeFrameBorder"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kNOITSROFRAMEBORDER + 1, "kNoITSROFrameBorder"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kNOPSAMEBUNCHPILEUP + 1, "kNoSameBunchPileup"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kISGOODZVTXFT0VSPV + 1, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kISVERTEXITSTPC + 1, "kIsVertexITSTPC"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kNOCOLLINTIMERANGESTANDART + 1, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kISGOODITSLAYERSALL + 1, "kIsGoodITSLayersAll"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kAFTERMULTCUTS + 1, "After Mult cuts"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kCENTRALITY + 1, "Centrality"); + + if (doprocessData) { + registry.add("hPhi", "#phi distribution", {HistType::kTH1D, {axisPhi}}); + registry.add("hPhiWeighted", "corrected #phi distribution", {HistType::kTH1D, {axisPhi}}); + registry.add("hEta", "", {HistType::kTH1D, {axisEta}}); + registry.add("hVtxZ", "Vexter Z distribution", {HistType::kTH1D, {axisVertex}}); + registry.add("hMult", "Multiplicity distribution", {HistType::kTH1D, {axisNch}}); + registry.add("hMultCorr", "Corrected Multiplicity distribution", {HistType::kTH1D, {axisNch}}); + registry.add("hCent", "Centrality distribution", {HistType::kTH1D, {{90, 0, 90}}}); + registry.add("cent_vs_Nch", ";Centrality (%); M (|#eta| < 0.8);", {HistType::kTH2D, {axisCentrality, axisNch}}); + registry.add("cent_vs_NchCorr", ";Centrality (%); M (|#eta| < 0.8);", {HistType::kTH2D, {axisCentrality, axisNch}}); + + // Centrality estimators + registry.add("hCentEstimators", "Number of Unfiltered Events;; No. of Events", {HistType::kTH1D, {{kNoCentEstimators, -0.5, static_cast(kNoCentEstimators) - 0.5}}}); + registry.get(HIST("hCentEstimators"))->GetXaxis()->SetBinLabel(kCentFT0C + 1, "FT0C"); + registry.get(HIST("hCentEstimators"))->GetXaxis()->SetBinLabel(kCentFT0A + 1, "FT0A"); + registry.get(HIST("hCentEstimators"))->GetXaxis()->SetBinLabel(kCentFT0M + 1, "FT0M"); + registry.get(HIST("hCentEstimators"))->GetXaxis()->SetBinLabel(kCentFV0A + 1, "FV0A"); + registry.get(HIST("hCentEstimators"))->GetXaxis()->SetBinLabel(kCentFT0CVariant1 + 1, "FT0CVar1"); + registry.add("hCentFT0C", "Uncorrected FT0C;Centrality FT0C ;Events", kTH1F, {axisCentrality}); + registry.add("hCentFT0A", "Uncorrected FT0A;Centrality FT0A ;Events", kTH1F, {axisCentrality}); + registry.add("hCentFT0M", "Uncorrected FT0M;Centrality FT0M ;Events", kTH1F, {axisCentrality}); + registry.add("hCentFV0A", "Uncorrected FV0A;Centrality FV0A ;Events", kTH1F, {axisCentrality}); + registry.add("hCentFT0CVariant1", "Uncorrected FT0CVariant1;Centrality FT0CVariant1 ;Events", kTH1F, {axisCentrality}); + + // Before cuts + registry.add("BeforeCut_globalTracks_centT0C", "before cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("BeforeCut_PVTracks_centT0C", "before cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNchPV}}); + registry.add("BeforeCut_globalTracks_PVTracks", "before cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNchPV, axisNch}}); + registry.add("BeforeCut_globalTracks_multT0A", "before cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("BeforeCut_globalTracks_multV0A", "before cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("BeforeCut_multV0A_multT0A", "before cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); + registry.add("BeforeCut_multT0C_centT0C", "before cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); + registry.add("BeforeCut_multT0A_centT0A", "before cut;Centrality T0C;mulplicity T0A", {HistType::kTH2D, {axisCentForQA, axisT0A}}); + registry.add("BeforeCut_multFT0M_centFT0M", "before cut;Centrality FT0M;mulplicity FT0M", {HistType::kTH2D, {axisCentForQA, axisT0M}}); + + // After cuts + registry.add("globalTracks_centT0C_Aft", "after cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("PVTracks_centT0C_Aft", "after cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNchPV}}); + registry.add("globalTracks_PVTracks_Aft", "after cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNchPV, axisNch}}); + registry.add("globalTracks_multT0A_Aft", "after cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("globalTracks_multV0A_Aft", "after cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("multV0A_multT0A_Aft", "after cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); + registry.add("multT0C_centT0C_Aft", "after cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); + registry.add("multT0A_centT0A_Aft", "after cut;Centrality T0A;mulplicity T0A", {HistType::kTH2D, {axisCentForQA, axisT0A}}); + registry.add("multFT0M_centFT0M_Aft", "after cut;Centrality FT0M;mulplicity FT0M", {HistType::kTH2D, {axisCentForQA, axisT0M}}); + + // FT0 plots + registry.add("FT0CAmp", ";FT0C amplitude;Events", kTH1F, {axisFT0CAmp}); + registry.add("FT0AAmp", ";FT0A amplitude;Events", kTH1F, {axisFT0AAmp}); + registry.add("FT0MAmp", ";FT0M amplitude;Events", kTH1F, {axisFT0MAmp}); + + // ZDC plots + const AxisSpec axisEvent{3, 0., +3.0, ""}; + registry.add("hEventCounterForZDC", "Event counter", kTH1F, {axisEvent}); + registry.add("ZNAcoll", "ZNAcoll; ZNA amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZN}}}); + registry.add("ZPAcoll", "ZPAcoll; ZPA amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZP}}}); + registry.add("ZNCcoll", "ZNCcoll; ZNC amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZN}}}); + registry.add("ZPCcoll", "ZPCcoll; ZPC amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZP}}}); + registry.add("ZNvsFT0correl", "ZNvsFT0correl; FT0 amplitude; ZN", {HistType::kTH2F, {{{nBinsFit, 0., maxMultFT0}, {nBinsAmp, -0.5, 2. * maxZN}}}}); + registry.add("ZDCAmp", "ZDC Amplitude; ZDC Amplitude; Events", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZP}}}); + registry.add("ZNAmp", "ZNA+ZNC Amplitude; ZN Amplitude; Events", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZN}}}); + registry.add("ZPAmp", "ZPA+ZPC Amplitude; ZP Amplitude; Events", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZP}}}); + registry.add("ZNvsZEMcoll", "ZNvsZEMcoll; ZEM; ZDC energy (GeV)", {HistType::kTH2F, {{{nBinsAmp, -0.5, maxZEM}, {nBinsAmp, -0.5, 2. * maxZN}}}}); + registry.add("ZNvsZEMcoll05", "ZNvsZEMcoll; ZEM; ZDC energy (GeV)", {HistType::kTH2F, {{{nBinsAmp, -0.5, maxZEM}, {nBinsAmp, -0.5, 2. * maxZN}}}}); + registry.add("ZNvsZEMcoll510", "ZNvsZEMcoll; ZEM; ZDC energy (GeV)", {HistType::kTH2F, {{{nBinsAmp, -0.5, maxZEM}, {nBinsAmp, -0.5, 2. * maxZN}}}}); + registry.add("ZNvsZEMcoll1020", "ZNvsZEMcoll; ZEM; ZDC energy (GeV)", {HistType::kTH2F, {{{nBinsAmp, -0.5, maxZEM}, {nBinsAmp, -0.5, 2. * maxZN}}}}); + registry.add("ZNvsZEMcoll2030", "ZNvsZEMcoll; ZEM; ZDC energy (GeV)", {HistType::kTH2F, {{{nBinsAmp, -0.5, maxZEM}, {nBinsAmp, -0.5, 2. * maxZN}}}}); + registry.add("ZNvsZEMcollrest", "ZNvsZEMcoll; ZEM; ZDC energy (GeV)", {HistType::kTH2F, {{{nBinsAmp, -0.5, maxZEM}, {nBinsAmp, -0.5, 2. * maxZN}}}}); + + // Track plots + registry.add("Nch", "N_{ch} vs #Events;N_{ch};No. of Events", {HistType::kTH1D, {axisNch}}); + registry.add("Nch05", "N_{ch 0-5%} vs #Events;N_{ch 0-5%};No. of Events", {HistType::kTH1D, {axisNch}}); + registry.add("Events_per_Centrality_Bin", "Events_per_Centrality_Bin;Centrality FT0C;No. of Events", kTH1F, {axisCentrality}); + registry.add("Tracks_per_Centrality_Bin", "Tracks_per_Centrality_Bin;Centrality FT0C;No. of Tracks", kTH1F, {axisCentrality}); + registry.add("pt_Cen_GlobalOnly", "pt_Cen_Global;Centrality (%); p_{T} (GeV/c);", {HistType::kTH2D, {axisCentrality, axisPt}}); + registry.add("phi_Cen_GlobalOnly", "phi_Cen_Global;Centrality (%); #phi;", {HistType::kTH2D, {axisCentrality, axisPhi}}); + registry.add("pt_Cen_ITSOnly", "pt_Cen_ITS;Centrality (%); p_{T} (GeV/c);", {HistType::kTH2D, {axisCentrality, axisPt}}); + registry.add("phi_Cen_ITSOnly", "phi_Cen_ITS;Centrality (%); #phi;", {HistType::kTH2D, {axisCentrality, axisPhi}}); + + // Track types + registry.add("GlobalplusITS", "Global plus ITS;Centrality FT0C;Nch", {HistType::kTH2D, {axisCentrality, axisNch}}); + registry.add("Globalonly", "Global only;Centrality FT0C;Nch", {HistType::kTH2D, {axisCentrality, axisNch}}); + registry.add("ITSonly", "ITS only;Centrality FT0C;Nch", {HistType::kTH2D, {axisCentrality, axisNch}}); + + // Track QA + registry.add("hPt", "p_{T} distribution before cut", {HistType::kTH1D, {axisPtHist}}); + registry.add("hPtRef", "p_{T} distribution after cut", {HistType::kTH1D, {axisPtHist}}); + registry.add("pt_phi_bef", "before cut;p_{T};#phi_{modn}", {HistType::kTH2D, {axisPt, axisPhiMod}}); + registry.add("pt_phi_aft", "after cut;p_{T};#phi_{modn}", {HistType::kTH2D, {axisPt, axisPhiMod}}); + registry.add("hChi2prTPCcls", "#chi^{2}/cluster for the TPC track segment", {HistType::kTH1D, {{100, 0., 5.}}}); + registry.add("hnTPCClu", "Number of found TPC clusters", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("hnTPCCrossedRow", "Number of crossed TPC Rows", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("hDCAz", "DCAz after cuts", {HistType::kTH1D, {{100, -3, 3}}}); + registry.add("hDCAxy", "DCAxy after cuts; DCAxy (cm); Pt", {HistType::kTH2D, {{50, -1, 1}, {50, 0, 10}}}); + + // Additional Output histograms + registry.add("c22", ";Centrality (%) ; C_{2}{2} ", {HistType::kTProfile, {axisCentrality}}); + registry.add("c24", ";Centrality (%) ; C_{2}{4}", {HistType::kTProfile, {axisCentrality}}); + registry.add("c26", ";Centrality (%) ; C_{2}{6}", {HistType::kTProfile, {axisCentrality}}); + registry.add("c28", ";Centrality (%) ; C_{2}{8}", {HistType::kTProfile, {axisCentrality}}); + registry.add("c22etagap", ";Centrality (%) ; C_{2}{2} (|#eta| < 0.8) ", {HistType::kTProfile, {axisCentrality}}); + registry.add("c32", ";Centrality (%) ; C_{3}{2} ", {HistType::kTProfile, {axisCentrality}}); + registry.add("c32etagap", ";Centrality (%) ; C_{3}{2} (|#eta| < 0.8) ", {HistType::kTProfile, {axisCentrality}}); + registry.add("c34", ";Centrality (%) ; C_{3}{4} ", {HistType::kTProfile, {axisCentrality}}); + + registry.add("c22Nch", ";N_{ch}(|#eta| < 0.8) ; C_{2}{2} ", {HistType::kTProfile, {axisNch}}); + registry.add("c24Nch", ";N_{ch}(|#eta| < 0.8) ; C_{2}{4}", {HistType::kTProfile, {axisNch}}); + registry.add("c26Nch", ";N_{ch}(|#eta| < 0.8) ; C_{2}{6}", {HistType::kTProfile, {axisNch}}); + registry.add("c28Nch", ";N_{ch}(|#eta| < 0.8) ; C_{2}{8}", {HistType::kTProfile, {axisNch}}); + registry.add("c22Nchetagap", ";N_ch(|#eta| < 0.8) ; C_{2}{2} (|#eta| < 0.8) ", {HistType::kTProfile, {axisNch}}); + registry.add("c32Nch", ";N_{ch}(|#eta| < 0.8) ; C_{3}{2} ", {HistType::kTProfile, {axisNch}}); + registry.add("c32Nchetagap", ";N_ch(|#eta| < 0.8) ; C_{3}{2} (|#eta| < 0.8) ", {HistType::kTProfile, {axisNch}}); + registry.add("c34Nch", ";N_{ch}(|#eta| < 0.8) ; C_{3}{4} ", {HistType::kTProfile, {axisNch}}); + + registry.add("c22Nch05", ";N_{ch 0-5%}(|#eta| < 0.8) ; C_{2}{2} ", {HistType::kTProfile, {axisNch}}); + registry.add("c24Nch05", ";N_{ch 0-5%}(|#eta| < 0.8) ; C_{2}{4}", {HistType::kTProfile, {axisNch}}); + registry.add("c26Nch05", ";N_{ch 0-5%}(|#eta| < 0.8) ; C_{2}{6}", {HistType::kTProfile, {axisNch}}); + registry.add("c28Nch05", ";N_{ch 0-5%}(|#eta| < 0.8) ; C_{2}{8}", {HistType::kTProfile, {axisNch}}); + registry.add("c22Nch05etagap", ";N_{ch 0-5%}(|#eta| < 0.8) ; C_{2}{2} (|#eta| < 0.8) ", {HistType::kTProfile, {axisNch}}); + registry.add("c32Nch05", ";N_{ch 0-5%}(|#eta| < 0.8) ; C_{3}{2} ", {HistType::kTProfile, {axisNch}}); + registry.add("c32Nch05etagap", ";N_{ch 0-5%}(|#eta| < 0.8) ; C_{3}{2} (|#eta| < 0.8) ", {HistType::kTProfile, {axisNch}}); + registry.add("c34Nch05", ";N_{ch 0-5%}(|#eta| < 0.8) ; C_{3}{4} ", {HistType::kTProfile, {axisNch}}); + } // End doprocessData + + const AxisSpec axisZpos{48, -12., 12., "Vtx_{z} (cm)"}; + const AxisSpec axisEvent{3, 0, 3, ""}; + // MC Histograms + if (doprocesspTEff) { + registry.add("hEventCounterMCRec", "Event counter", kTH1F, {axisEvent}); + registry.add("zPos", ";;Entries;", kTH1F, {axisZpos}); + registry.add("T0Ccent", ";;Entries", kTH1F, {axisCentrality}); + registry.add("nRecColvsCent", "", kTH2F, {{6, -0.5, 5.5}, {{axisCentrality}}}); + registry.add("Pt_all_ch", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("Pt_ch", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("hPtMCRec", "Monte Carlo Reco; pT (GeV/c)", {HistType::kTH1D, {axisPt}}); + registry.add("hCenMCRec", "Monte Carlo Reco; Centrality (%)", {HistType::kTH1D, {axisCentrality}}); + registry.add("hPtNchMCRec", "Reco production; pT (GeV/c); Multiplicity", {HistType::kTH2D, {axisPt, axisNch}}); + registry.add("hPtMCRec05", "Monte Carlo Reco 0-5%; pT (GeV/c)", {HistType::kTH1D, {axisPt}}); + registry.add("hCenMCRec05", "Monte Carlo Reco 0-5%; Centrality (%)", {HistType::kTH1D, {axisCentrality}}); + registry.add("hPtNchMCRec05", "Reco production 0-5%; pT (GeV/c); Multiplicity", {HistType::kTH2D, {axisPt, axisNch}}); + registry.add("Pt_pi", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("Pt_ka", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("Pt_pr", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("Pt_sigpos", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("Pt_signeg", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("Pt_re", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("EtaVsPhi", ";;#varphi;", kTH2F, + {{{axisEta}, {100, -0.1 * o2::constants::math::PI, +2.1 * o2::constants::math::PI}}}); + registry.add("hEventCounterMCGen", "Event counter", kTH1F, {axisEvent}); + registry.add("zPosMC", ";;Entries;", kTH1F, {axisZpos}); + registry.add("PtMC_ch", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("hPtMCGen", "Monte Carlo Truth; pT (GeV/c)", {HistType::kTH1D, {axisPt}}); + registry.add("hCenMCGen", "Monte Carlo Truth; Centrality (%)", {HistType::kTH1D, {axisCentrality}}); + registry.add("hPtNchMCGen", "Truth production; pT (GeV/c); multiplicity", {HistType::kTH2D, {axisPt, axisNch}}); + registry.add("hPtMCGen05", "Monte Carlo Truth 0-5%; pT (GeV/c)", {HistType::kTH1D, {axisPt}}); + registry.add("hCenMCGen05", "Monte Carlo Truth 0-5%; Centrality (%)", {HistType::kTH1D, {axisCentrality}}); + registry.add("hPtNchMCGen05", "Truth production 0-5%; pT (GeV/c); multiplicity", {HistType::kTH2D, {axisPt, axisNch}}); + + registry.add("hCorr", "Correlation Matrix; N_{ch True}; N_{ch Reco}", {HistType::kTH2D, {axisNch, axisNch}}); + registry.add("hCorr05", "Correlation Matrix 0-5%; N_{ch True}; N_{ch Reco}", {HistType::kTH2D, {axisNch, axisNch}}); + + registry.add("PtMC_pi", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("PtMC_ka", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("PtMC_pr", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("PtMC_sigpos", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("PtMC_signeg", "", kTH2F, {{axisCentrality}, {axisPt}}); + registry.add("PtMC_re", "", kTH2F, {{axisCentrality}, {axisPt}}); + } + + // initial array + bootstrapArray.resize(cfgNbootstrap); + for (int i = 0; i < cfgNbootstrap; i++) { + bootstrapArray[i].resize(kCount_ExtraProfile); + } + + for (int i = 0; i < cfgNbootstrap; i++) { + bootstrapArray[i][kc22] = registry.add(Form("BootstrapContainer_%d/c22", i), ";Centrality (%) ; C_{2}{2}", {HistType::kTProfile, {axisCentrality}}); + bootstrapArray[i][kc24] = registry.add(Form("BootstrapContainer_%d/c24", i), ";Centrality (%) ; C_{2}{4}", {HistType::kTProfile, {axisCentrality}}); + bootstrapArray[i][kc26] = registry.add(Form("BootstrapContainer_%d/c26", i), ";Centrality (%) ; C_{2}{6}", {HistType::kTProfile, {axisCentrality}}); + bootstrapArray[i][kc28] = registry.add(Form("BootstrapContainer_%d/c28", i), ";Centrality (%) ; C_{2}{8}", {HistType::kTProfile, {axisCentrality}}); + bootstrapArray[i][kc22etagap] = registry.add(Form("BootstrapContainer_%d/c22etagap", i), ";Centrality (%) ; C_{2}{2} (|#eta| < 0.8)", {HistType::kTProfile, {axisCentrality}}); + bootstrapArray[i][kc32] = registry.add(Form("BootstrapContainer_%d/c32", i), ";Centrality (%) ; C_{3}{2}", {HistType::kTProfile, {axisCentrality}}); + bootstrapArray[i][kc32etagap] = registry.add(Form("BootstrapContainer_%d/c32etagap", i), ";Centrality (%) ; C_{3}{2} (|#eta| < 0.8)", {HistType::kTProfile, {axisCentrality}}); + bootstrapArray[i][kc34] = registry.add(Form("BootstrapContainer_%d/c34", i), ";Centrality (%) ; C_{3}{4}", {HistType::kTProfile, {axisCentrality}}); + + bootstrapArray[i][kc22Nch] = registry.add(Form("BootstrapContainer_%d/c22Nch", i), ";N_ch(|#eta| < 0.8) ; C_{2}{2}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc24Nch] = registry.add(Form("BootstrapContainer_%d/c24Nch", i), ";N_ch(|#eta| < 0.8) ; C_{2}{4}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc26Nch] = registry.add(Form("BootstrapContainer_%d/c26Nch", i), ";N_ch(|#eta| < 0.8) ; C_{2}{6}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc28Nch] = registry.add(Form("BootstrapContainer_%d/c28Nch", i), ";N_ch(|#eta| < 0.8) ; C_{2}{8}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc22Nchetagap] = registry.add(Form("BootstrapContainer_%d/c22Nchetagap", i), ";N_ch(|#eta| < 0.8) ; C_{2}{2} (|#eta| < 0.8)", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc32Nch] = registry.add(Form("BootstrapContainer_%d/c32Nch", i), ";N_ch(|#eta| < 0.8) ; C_{3}{2}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc32Nchetagap] = registry.add(Form("BootstrapContainer_%d/c32Nchetagap", i), ";N_ch(|#eta| < 0.8) ; C_{3}{2} (|#eta| < 0.8)", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc34Nch] = registry.add(Form("BootstrapContainer_%d/c34Nch", i), ";N_ch(|#eta| < 0.8) ; C_{3}{4}", {HistType::kTProfile, {axisNch}}); + + bootstrapArray[i][kc22Nch05] = registry.add(Form("BootstrapContainer_%d/c22Nch05", i), ";N_ch05(|#eta| < 0.8) ; C_{2}{2}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc24Nch05] = registry.add(Form("BootstrapContainer_%d/c24Nch05", i), ";N_ch05(|#eta| < 0.8) ; C_{2}{4}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc26Nch05] = registry.add(Form("BootstrapContainer_%d/c26Nch05", i), ";N_ch05(|#eta| < 0.8) ; C_{2}{6}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc28Nch05] = registry.add(Form("BootstrapContainer_%d/c28Nch05", i), ";N_ch05(|#eta| < 0.8) ; C_{2}{8}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc22Nch05etagap] = registry.add(Form("BootstrapContainer_%d/c22Nch05etagap", i), ";N_ch05(|#eta| < 0.8) ; C_{2}{2} (|#eta| < 0.8)", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc32Nch05] = registry.add(Form("BootstrapContainer_%d/c32Nch05", i), ";N_ch05(|#eta| < 0.8) ; C_{3}{2}", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc32Nch05etagap] = registry.add(Form("BootstrapContainer_%d/c32Nch05etagap", i), ";N_ch05(|#eta| < 0.8) ; C_{3}{2} (|#eta| < 0.8)", {HistType::kTProfile, {axisNch}}); + bootstrapArray[i][kc34Nch05] = registry.add(Form("BootstrapContainer_%d/c34Nch05", i), ";N_ch05(|#eta| < 0.8) ; C_{3}{4}", {HistType::kTProfile, {axisNch}}); + } + + o2::framework::AxisSpec axis = axisPt; + int nPtBins = axis.binEdges.size() - 1; + double* ptBins = &(axis.binEdges)[0]; + fPtAxis = new TAxis(nPtBins, ptBins); + + if (cfgOutputNUAWeights) { + fWeights->setPtBins(nPtBins, ptBins); + fWeights->init(true, false); + } + + // add in FlowContainer to Get boostrap sample automatically -- Use post process flow task + TObjArray* oba = new TObjArray(); + fFC->SetXAxis(fPtAxis); + fFC->SetName("FlowContainer"); + fFC->Initialize(oba, axisCentrality, cfgNbootstrap); + delete oba; + + fGFW->AddRegion("full", -0.8, 0.8, 1, 1); // eta region -0.8 to 0.8 + fGFW->AddRegion("refN10", -0.8, -0.5, 1, 1); + fGFW->AddRegion("refP10", 0.5, 0.8, 1, 1); + + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 -2 -2}", "ChFull24", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 2 -2 -2 -2}", "ChFull26", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 2 2 -2 -2 -2 -2}", "ChFull28", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {3 -3}", "ChFull32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {3} refP10 {-3}", "Ch10Gap32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {3 3 -3 -3}", "ChFull34", kFALSE)); + fGFW->CreateRegions(); // finalize the initialization + + if (cfgUseAdditionalEventCut) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + + fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + + fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } + + if (cfgUseAdditionalTrackCut) { + fPhiCutLow = new TF1("fPhiCutLow", "0.06/x+pi/18.0-0.06", 0, 100); + fPhiCutHigh = new TF1("fPhiCutHigh", "0.1/x+pi/18.0+0.06", 0, 100); + } + + if (cfgTrackSelRun3ITSMatch) { + myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + } else { + myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + } + + myTrackSel.SetMinNClustersTPC(cfgCutTPCclu); + myTrackSel.SetMinNClustersITS(cfgCutITSclu); + + } // end of Initialization + + template + void fillProfile(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const double& cent) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::abs(val) < 1) + registry.fill(tarName, cent, val, dnx); + return; + } + return; + } + + void fillProfile(const GFW::CorrConfig& corrconf, std::shared_ptr tarName, const double& cent) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::abs(val) < 1) { + tarName->Fill(cent, val, dnx); + } + return; + } + return; + } + + void fillFC(const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::abs(val) < 1) + fFC->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); + return; + } + for (int i = 1; i <= fPtAxis->GetNbins(); i++) { + dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); + if (dnx == 0) + continue; + val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; + if (std::abs(val) < 1) + fFC->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); + } + return; + } + + void loadCorrections(uint64_t timestamp) + { + if (correctionsLoaded) + return; + if (cfgAcceptance.value.empty() == false) { + mAcceptance = ccdb->getForTimeStamp(cfgAcceptance, timestamp); + if (mAcceptance) + LOGF(info, "Loaded acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); + else + LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); + } + if (cfgEfficiency.value.empty() == false) { + mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); + if (mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency); + } + + if (cfgEfficiencyNch.value.empty() == false) { + mEfficiencyNch = ccdb->getForTimeStamp(cfgEfficiencyNch, timestamp); + if (mEfficiencyNch == nullptr) { + LOGF(fatal, "Could not load Nch efficiency histogram for trigger particles from %s", cfgEfficiencyNch.value.c_str()); + } + LOGF(info, "Loaded Nch efficiency histogram from %s (%p)", cfgEfficiencyNch.value.c_str(), (void*)mEfficiencyNch); + } + + correctionsLoaded = true; + } + + bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz) + { + float eff = 1.; + if (mEfficiency) + eff = mEfficiency->GetBinContent(mEfficiency->FindBin(pt)); + else + eff = 1.0; + if (eff == 0) + return false; + weight_nue = 1. / eff; + if (mAcceptance) + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + else + weight_nua = 1; + return true; + } + + bool setNch(float& weight_nueNch, float nch) + { + float effNch = 1.; + if (mEfficiencyNch) + effNch = mEfficiencyNch->GetBinContent(mEfficiencyNch->FindBin(nch)); + else + effNch = 1.0; + if (effNch == 0.0) + return false; + weight_nueNch = 1. / effNch; + return true; + } + + template + bool eventSelected(o2::aod::mult::MultNTracksPV, TCollision collision, const int multTrk, const float centrality) + { + if (cfgNoTimeFrameBorder) { + if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + // reject collisions close to Time Frame borders + // https://its.cern.ch/jira/browse/O2-4623 + return false; + } + registry.fill(HIST("hEventCount"), kNOTIMEFRAMEBORDER); + } + if (cfgNoITSROFrameBorder) { + if (!collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + // reject events affected by the ITS ROF border + // https://its.cern.ch/jira/browse/O2-4309 + return false; + } + registry.fill(HIST("hEventCount"), kNOITSROFRAMEBORDER); + } + if (cfgNoSameBunchPileup) { + if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return false; + } + registry.fill(HIST("hEventCount"), kNOPSAMEBUNCHPILEUP); + } + if (cfgIsGoodZvtxFT0vsPV) { + if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return false; + } + registry.fill(HIST("hEventCount"), kISGOODZVTXFT0VSPV); + } + if (cfgIsVertexITSTPC) { + if (!collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + // removes collisions without vertex match between ITS-TPC + return false; + } + registry.fill(HIST("hEventCount"), kISVERTEXITSTPC); + } + if (cfgNoCollInTimeRangeStandard) { + if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // no collisions in specified time range + return false; + } + registry.fill(HIST("hEventCount"), kNOCOLLINTIMERANGESTANDART); + } + if (cfgEvSelkIsGoodITSLayersAll) { + if (cfgEvSelkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // removes dead staves of ITS + return false; + } + registry.fill(HIST("hEventCount"), kISGOODITSLAYERSALL); + } + + float vtxz = -999; + if (collision.numContrib() > 1) { + vtxz = collision.posZ(); + float zRes = std::sqrt(collision.covZZ()); + if (zRes > 0.25 && collision.numContrib() < 20) + vtxz = -999; + } + + auto multNTracksPV = collision.multNTracksPV(); + + if (std::abs(vtxz) > cfgCutVertex) + return false; + + if (cfgMultCut) { + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return false; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return false; + if (multTrk < fMultCutLow->Eval(centrality)) + return false; + if (multTrk > fMultCutHigh->Eval(centrality)) + return false; + registry.fill(HIST("hEventCount"), kAFTERMULTCUTS); + } + + // V0A T0A 5 sigma cut + if (cfgV0AT0A5Sigma) { + if (std::abs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > 5 * fT0AV0ASigma->Eval(collision.multFT0A())) + return false; + } + + return true; + } + + int getMagneticField(uint64_t timestamp) + { + static o2::parameters::GRPMagField* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp(cfgMagnetField, timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found in %s for timestamp %llu", cfgMagnetField.value.c_str(), timestamp); + return 0; + } + LOGF(info, "Retrieved GRP from %s for timestamp %llu with magnetic field of %d kG", cfgMagnetField.value.c_str(), timestamp, grpo->getNominalL3Field()); + } + return grpo->getNominalL3Field(); + } + + template + bool trackSelected(TTrack track, const int field) + { + double phimodn = track.phi(); + if (field < 0) // for negative polarity field + phimodn = o2::constants::math::TwoPI - phimodn; + if (track.sign() < 0) // for negative charge + phimodn = o2::constants::math::TwoPI - phimodn; + if (phimodn < 0) + LOGF(warning, "phi < 0: %g", phimodn); + + phimodn += o2::constants::math::PI / 18.0; // to center gap in the middle + phimodn = fmod(phimodn, o2::constants::math::PI / 9.0); + registry.fill(HIST("pt_phi_bef"), track.pt(), phimodn); + if (phimodn < fPhiCutHigh->Eval(track.pt()) && phimodn > fPhiCutLow->Eval(track.pt())) + return false; // reject track + registry.fill(HIST("pt_phi_aft"), track.pt(), phimodn); + return true; + } + + template + bool trackSelected(TTrack track) + { + if (cfgDCAzPt && (std::fabs(track.dcaZ()) > (0.004f + 0.013f / track.pt()))) + return false; + + if (cfgTrackSel) { + return myTrackSel.IsSelected(track); + } else if (cfgGlobalplusITS) { + return ((track.tpcNClsFound() >= cfgCutTPCclu) || (track.itsNCls() >= cfgCutITSclu)); + } else if (cfgGlobalonly) { + return ((track.tpcNClsFound() >= cfgCutTPCclu) && (track.itsNCls() >= cfgCutITSclu)); + } else if (cfgITSonly) { + return ((track.itsNCls() >= cfgCutITSclu)); + } else { + return false; + } + } + + // Apply process filters + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex && (aod::cent::centFT0C > cfgMinCentFT0C) && (aod::cent::centFT0C < cfgMaxCentFT0C); + Filter trackFilter = ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) && + ncheckbit(aod::track::trackCutFlag, TrackSelectionITS) && + ifnode(ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC), + ncheckbit(aod::track::trackCutFlag, TrackSelectionTPC), true) && + ifnode(dcaZ > 0.f, nabs(aod::track::dcaZ) <= dcaZ && ncheckbit(aod::track::trackCutFlag, TrackSelectionDCAXYonly), + ncheckbit(aod::track::trackCutFlag, TrackSelectionDCA)) && + (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); + + void processData(Colls::iterator const& collision, aod::BCsWithTimestamps const&, AodTracks const& tracks, aod::FT0s const&, aod::Zdcs const&, BCsRun3 const&) + { + registry.fill(HIST("hEventCount"), kFILTERED); + if (!collision.sel8()) + return; + + if (tracks.size() < 1) + return; + + registry.fill(HIST("hEventCount"), kSEL8); + + // Choose centrality estimator -- Only one can be true + auto centrality = -1; + if (cfgcentEstFt0c) { + centrality = collision.centFT0C(); + registry.fill(HIST("hCentEstimators"), kCentFT0C); + registry.fill(HIST("hCentFT0C"), centrality); + } + if (cfgcentEstFt0a) { + centrality = collision.centFT0A(); + registry.fill(HIST("hCentEstimators"), kCentFT0A); + registry.fill(HIST("hCentFT0A"), centrality); + } + if (cfgcentEstFt0m) { + centrality = collision.centFT0M(); + registry.fill(HIST("hCentEstimators"), kCentFT0M); + registry.fill(HIST("hCentFT0M"), centrality); + } + if (cfgcentEstFv0a) { + centrality = collision.centFV0A(); + registry.fill(HIST("hCentEstimators"), kCentFV0A); + registry.fill(HIST("hCentFV0A"), centrality); + } + if (cfgcentEstFt0cVariant1) { + centrality = collision.centFT0CVariant1(); + registry.fill(HIST("hCentEstimators"), kCentFT0CVariant1); + registry.fill(HIST("hCentFT0CVariant1"), centrality); + } + + // fill event QA before cuts + registry.fill(HIST("BeforeCut_globalTracks_centT0C"), collision.centFT0C(), tracks.size()); + registry.fill(HIST("BeforeCut_PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV()); + registry.fill(HIST("BeforeCut_globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size()); + registry.fill(HIST("BeforeCut_globalTracks_multT0A"), collision.multFT0A(), tracks.size()); + registry.fill(HIST("BeforeCut_globalTracks_multV0A"), collision.multFV0A(), tracks.size()); + registry.fill(HIST("BeforeCut_multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); + registry.fill(HIST("BeforeCut_multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); + registry.fill(HIST("BeforeCut_multT0A_centT0A"), collision.centFT0A(), collision.multFT0A()); + registry.fill(HIST("BeforeCut_multFT0M_centFT0M"), collision.centFT0M(), collision.multFT0M()); + + if (cfgOccupancy) { + int occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh) + return; + registry.fill(HIST("hEventCount"), kOCCUPANCY); + } + + if (cfgUseAdditionalEventCut && !eventSelected(o2::aod::mult::MultNTracksPV(), collision, tracks.size(), centrality)) { + return; + } + + const auto& foundBC = collision.foundBC_as(); + if (foundBC.has_zdc()) { + registry.fill(HIST("hEventCounterForZDC"), 1); + + // FT0 amplitude to use in fine binning + double ft0aAmp = 0; + double ft0cAmp = 0; + double ft0mAmp = 0; + + if (foundBC.has_ft0()) { + for (const auto& amplitude : foundBC.ft0().amplitudeA()) { + ft0aAmp += amplitude; + } + for (const auto& amplitude : foundBC.ft0().amplitudeC()) { + ft0cAmp += amplitude; + } + } else { + ft0aAmp = ft0cAmp = -999; + } + + registry.fill(HIST("FT0AAmp"), ft0aAmp); + registry.fill(HIST("FT0CAmp"), ft0cAmp); + + ft0mAmp = ft0aAmp + ft0cAmp; + registry.fill(HIST("FT0MAmp"), ft0mAmp); + + // ZDC amplitude to use in fine binning + const auto& zdcread = foundBC.zdc(); + auto aZNA = zdcread.amplitudeZNA(); + auto aZNC = zdcread.amplitudeZNC(); + auto aZPA = zdcread.amplitudeZPA(); + auto aZPC = zdcread.amplitudeZPC(); + auto aZEM1 = zdcread.amplitudeZEM1(); + auto aZEM2 = zdcread.amplitudeZEM2(); + + registry.fill(HIST("ZNAcoll"), aZNA); + registry.fill(HIST("ZNCcoll"), aZNC); + registry.fill(HIST("ZPAcoll"), aZPA); + registry.fill(HIST("ZPCcoll"), aZPC); + + registry.fill(HIST("ZNvsFT0correl"), (ft0aAmp + ft0cAmp) / 100., aZNC + aZNA); + + double aZDC = aZNC + aZNA + aZPA + aZPC; + registry.fill(HIST("ZDCAmp"), aZDC); + registry.fill(HIST("ZNAmp"), aZNC + aZNA); + registry.fill(HIST("ZPAmp"), aZPA + aZPC); + + registry.fill(HIST("ZNvsZEMcoll"), aZEM1 + aZEM2, aZNA + aZNC); + + if (centrality >= 0 && centrality <= 5) { + registry.fill(HIST("ZNvsZEMcoll05"), aZEM1 + aZEM2, aZNA + aZNC); + } else if (centrality > 5 && centrality <= 10) { + registry.fill(HIST("ZNvsZEMcoll510"), aZEM1 + aZEM2, aZNA + aZNC); + } else if (centrality > 10 && centrality <= 20) { + registry.fill(HIST("ZNvsZEMcoll1020"), aZEM1 + aZEM2, aZNA + aZNC); + } else if (centrality > 20 && centrality <= 30) { + registry.fill(HIST("ZNvsZEMcoll2030"), aZEM1 + aZEM2, aZNA + aZNC); + } else { + registry.fill(HIST("ZNvsZEMcollrest"), aZEM1 + aZEM2, aZNA + aZNC); + } + } // End of ZDC + + float vtxz = collision.posZ(); + float lRandom = fRndm->Rndm(); + registry.fill(HIST("hVtxZ"), vtxz); + registry.fill(HIST("hMult"), tracks.size()); + registry.fill(HIST("hCent"), centrality); + registry.fill(HIST("cent_vs_Nch"), centrality, tracks.size()); + + float weffNch = 1; + if (!setNch(weffNch, tracks.size())) + return; + + // Corrected nch + float nch = tracks.size() * weffNch; + registry.fill(HIST("hMultCorr"), nch); + registry.fill(HIST("cent_vs_NchCorr"), centrality, nch); + + fGFW->Clear(); + + auto bc = collision.bc_as(); + loadCorrections(bc.timestamp()); + registry.fill(HIST("hEventCount"), kCENTRALITY); + + // fill event QA after cuts + registry.fill(HIST("globalTracks_centT0C_Aft"), collision.centFT0C(), tracks.size()); + registry.fill(HIST("PVTracks_centT0C_Aft"), collision.centFT0C(), collision.multNTracksPV()); + registry.fill(HIST("globalTracks_PVTracks_Aft"), collision.multNTracksPV(), tracks.size()); + registry.fill(HIST("globalTracks_multT0A_Aft"), collision.multFT0A(), tracks.size()); + registry.fill(HIST("globalTracks_multV0A_Aft"), collision.multFV0A(), tracks.size()); + registry.fill(HIST("multV0A_multT0A_Aft"), collision.multFT0A(), collision.multFV0A()); + registry.fill(HIST("multT0C_centT0C_Aft"), collision.centFT0C(), collision.multFT0C()); + registry.fill(HIST("multT0A_centT0A_Aft"), collision.centFT0A(), collision.multFT0A()); + registry.fill(HIST("multFT0M_centFT0M_Aft"), collision.centFT0M(), collision.multFT0M()); + + // track weights + float weff = 1, wacc = 1; + int magnetfield = 0; + + if (cfgUseAdditionalTrackCut) { + // magnet field dependence cut + magnetfield = getMagneticField(bc.timestamp()); + } + + // track loop + + for (const auto& track : tracks) { + if (!trackSelected(track)) + continue; + + if (cfgUseAdditionalTrackCut && !trackSelected(track, magnetfield)) + continue; + + if (cfgOutputNUAWeights) + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); + + if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) + continue; + + bool withinPtRef = (cfgCutPtMin < track.pt()) && (track.pt() < cfgCutPtMax); // within RF pT range + registry.fill(HIST("hPt"), track.pt()); + + if (withinPtRef) { + registry.fill(HIST("hPhi"), track.phi()); + registry.fill(HIST("hPhiWeighted"), track.phi(), wacc); + registry.fill(HIST("hEta"), track.eta()); + registry.fill(HIST("hPtRef"), track.pt()); + registry.fill(HIST("hChi2prTPCcls"), track.tpcChi2NCl()); + registry.fill(HIST("hnTPCClu"), track.tpcNClsFound()); + registry.fill(HIST("hnTPCCrossedRow"), track.tpcNClsCrossedRows()); + registry.fill(HIST("hDCAz"), track.dcaZ()); + registry.fill(HIST("hDCAxy"), track.dcaXY(), track.pt()); + } + + if (cfgGlobalplusITS) { + if (withinPtRef) { + registry.fill(HIST("GlobalplusITS"), centrality, nch); + fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 1); + } + } + + if (track.hasTPC()) { + if (cfgGlobalonly) { + if (withinPtRef) { + registry.fill(HIST("Globalonly"), centrality, nch); + registry.fill(HIST("pt_Cen_GlobalOnly"), centrality, track.pt()); + registry.fill(HIST("phi_Cen_GlobalOnly"), centrality, track.phi()); + fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 1); + } + } + } else { + if (cfgITSonly) { + if (withinPtRef) { + registry.fill(HIST("ITSonly"), centrality, nch); + registry.fill(HIST("pt_Cen_ITSOnly"), centrality, track.pt()); + registry.fill(HIST("phi_Cen_ITSOnly"), centrality, track.phi()); + fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 1); + } + } + } + + if (cfgFineBinning) + fGFW->Fill(track.eta(), 1, track.phi(), wacc * weff, 1); + + } // End of track loop + + // Only one type of track will be plotted + registry.fill(HIST("Events_per_Centrality_Bin"), centrality); + registry.fill(HIST("Tracks_per_Centrality_Bin"), centrality, nch); + + // Filling c22 with ROOT TProfile + fillProfile(corrconfigs.at(0), HIST("c22"), centrality); + fillProfile(corrconfigs.at(1), HIST("c24"), centrality); + fillProfile(corrconfigs.at(2), HIST("c26"), centrality); + fillProfile(corrconfigs.at(3), HIST("c28"), centrality); + fillProfile(corrconfigs.at(4), HIST("c22etagap"), centrality); + fillProfile(corrconfigs.at(5), HIST("c32"), centrality); + fillProfile(corrconfigs.at(6), HIST("c32etagap"), centrality); + fillProfile(corrconfigs.at(7), HIST("c34"), centrality); + + fillProfile(corrconfigs.at(0), HIST("c22Nch"), nch); + fillProfile(corrconfigs.at(1), HIST("c24Nch"), nch); + fillProfile(corrconfigs.at(2), HIST("c26Nch"), nch); + fillProfile(corrconfigs.at(3), HIST("c28Nch"), nch); + fillProfile(corrconfigs.at(4), HIST("c22Nchetagap"), nch); + fillProfile(corrconfigs.at(5), HIST("c32Nch"), nch); + fillProfile(corrconfigs.at(6), HIST("c32Nchetagap"), nch); + fillProfile(corrconfigs.at(7), HIST("c34Nch"), nch); + + // 0-5% centrality Nch + if (centrality >= 0 && centrality <= 5) { + fillProfile(corrconfigs.at(0), HIST("c22Nch05"), nch); + fillProfile(corrconfigs.at(1), HIST("c24Nch05"), nch); + fillProfile(corrconfigs.at(2), HIST("c26Nch05"), nch); + fillProfile(corrconfigs.at(3), HIST("c28Nch05"), nch); + fillProfile(corrconfigs.at(4), HIST("c22Nch05etagap"), nch); + fillProfile(corrconfigs.at(5), HIST("c32Nch05"), nch); + fillProfile(corrconfigs.at(6), HIST("c32Nch05etagap"), nch); + fillProfile(corrconfigs.at(7), HIST("c34Nch05"), nch); + } + + // Filling Bootstrap Samples + int sampleIndex = static_cast(cfgNbootstrap * lRandom); + fillProfile(corrconfigs.at(0), bootstrapArray[sampleIndex][kc22], centrality); + fillProfile(corrconfigs.at(1), bootstrapArray[sampleIndex][kc24], centrality); + fillProfile(corrconfigs.at(2), bootstrapArray[sampleIndex][kc26], centrality); + fillProfile(corrconfigs.at(3), bootstrapArray[sampleIndex][kc28], centrality); + fillProfile(corrconfigs.at(4), bootstrapArray[sampleIndex][kc22etagap], centrality); + fillProfile(corrconfigs.at(5), bootstrapArray[sampleIndex][kc32], centrality); + fillProfile(corrconfigs.at(6), bootstrapArray[sampleIndex][kc32etagap], centrality); + fillProfile(corrconfigs.at(7), bootstrapArray[sampleIndex][kc34], centrality); + + fillProfile(corrconfigs.at(0), bootstrapArray[sampleIndex][kc22Nch], nch); + fillProfile(corrconfigs.at(1), bootstrapArray[sampleIndex][kc24Nch], nch); + fillProfile(corrconfigs.at(2), bootstrapArray[sampleIndex][kc26Nch], nch); + fillProfile(corrconfigs.at(3), bootstrapArray[sampleIndex][kc28Nch], nch); + fillProfile(corrconfigs.at(4), bootstrapArray[sampleIndex][kc22Nchetagap], nch); + fillProfile(corrconfigs.at(5), bootstrapArray[sampleIndex][kc32Nch], nch); + fillProfile(corrconfigs.at(6), bootstrapArray[sampleIndex][kc32Nchetagap], nch); + fillProfile(corrconfigs.at(7), bootstrapArray[sampleIndex][kc34Nch], nch); + + if (centrality >= 0 && centrality <= 5) { + fillProfile(corrconfigs.at(0), bootstrapArray[sampleIndex][kc22Nch05], nch); + fillProfile(corrconfigs.at(1), bootstrapArray[sampleIndex][kc24Nch05], nch); + fillProfile(corrconfigs.at(2), bootstrapArray[sampleIndex][kc26Nch05], nch); + fillProfile(corrconfigs.at(3), bootstrapArray[sampleIndex][kc28Nch05], nch); + fillProfile(corrconfigs.at(4), bootstrapArray[sampleIndex][kc22Nch05etagap], nch); + fillProfile(corrconfigs.at(5), bootstrapArray[sampleIndex][kc32Nch05], nch); + fillProfile(corrconfigs.at(6), bootstrapArray[sampleIndex][kc32Nch05etagap], nch); + fillProfile(corrconfigs.at(7), bootstrapArray[sampleIndex][kc34Nch05], nch); + + registry.fill(HIST("Nch05"), nch); + } + + registry.fill(HIST("Nch"), nch); + + // Filling Flow Container + for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { + fillFC(corrconfigs.at(l_ind), centrality, lRandom); + } + + } // End of process + PROCESS_SWITCH(FlowGfwTask, processData, "Process analysis for Run 3 data", false); + + using TheFilteredMyTracks = soa::Filtered; + using TheFilteredMyCollisions = soa::Filtered; + + Preslice perMCCollision = aod::mcparticle::mcCollisionId; + Preslice perCollision = aod::track::collisionId; + void processpTEff(aod::McCollisions::iterator const& mccollision, + soa::SmallGroups const& collisions, + aod::McParticles const& mcParticles, + TheFilteredMyTracks const& tracks) + { + // MC reconstructed + for (const auto& collision : collisions) { + if (!collision.sel8()) + return; + + if (tracks.size() < 1) + return; + + const auto& centrality = collision.centFT0C(); + + if (cfgUseAdditionalEventCut && !eventSelected(o2::aod::mult::MultNTracksPV(), collision, tracks.size(), centrality)) { + return; + } + + if (!collision.has_mcCollision()) + continue; + + registry.fill(HIST("zPos"), collision.posZ()); + registry.fill(HIST("nRecColvsCent"), collisions.size(), collision.centFT0C()); + registry.fill(HIST("T0Ccent"), centrality); + + const auto& groupedTracksReco = tracks.sliceBy(perCollision, collision.globalIndex()); + for (const auto& track : groupedTracksReco) { + + if (!trackSelected(track)) + continue; + + if (!track.has_mcParticle()) + continue; + + const auto& particle = track.mcParticle(); + + if (isStable(particle.pdgCode())) { + + registry.fill(HIST("hEventCounterMCRec"), 0.5); + registry.fill(HIST("hPtMCRec"), track.pt()); + registry.fill(HIST("hCenMCRec"), centrality); + registry.fill(HIST("hPtNchMCRec"), track.pt(), track.size()); + + if (centrality >= 0 && centrality <= 5) { + registry.fill(HIST("hPtMCRec05"), track.pt()); + registry.fill(HIST("hCenMCRec05"), centrality); + registry.fill(HIST("hPtNchMCRec05"), track.pt(), track.size()); + } + } + + registry.fill(HIST("Pt_all_ch"), centrality, track.pt()); + registry.fill(HIST("EtaVsPhi"), track.eta(), track.phi()); + + if (!particle.isPhysicalPrimary()) + continue; + + registry.fill(HIST("Pt_ch"), centrality, track.pt()); + if (particle.pdgCode() == kPiPlus || + particle.pdgCode() == kPiMinus) { + registry.fill(HIST("Pt_pi"), centrality, track.pt()); + } else if (particle.pdgCode() == kKPlus || + particle.pdgCode() == kKMinus) { + registry.fill(HIST("Pt_ka"), centrality, track.pt()); + } else if (particle.pdgCode() == kProton || + particle.pdgCode() == kProtonBar) { + registry.fill(HIST("Pt_pr"), centrality, track.pt()); + } else if (particle.pdgCode() == kSigmaPlus || + particle.pdgCode() == kSigmaBarMinus) { + registry.fill(HIST("Pt_sigpos"), centrality, track.pt()); + } else if (particle.pdgCode() == kSigmaMinus || + particle.pdgCode() == kSigmaBarPlus) { + registry.fill(HIST("Pt_signeg"), centrality, track.pt()); + } else { + registry.fill(HIST("Pt_re"), centrality, track.pt()); + } + } + + // Generated MC + registry.fill(HIST("hEventCounterMCGen"), 0.5); + if (std::fabs(mccollision.posZ()) > cfgCutVertex) + continue; + registry.fill(HIST("zPosMC"), mccollision.posZ()); + registry.fill(HIST("hEventCounterMCGen"), 1.5); + + std::vector numberOfTracks; + for (auto const& collision : collisions) { + auto groupedTracks = tracks.sliceBy(perCollision, collision.globalIndex()); + numberOfTracks.emplace_back(groupedTracks.size()); + } + + for (const auto& particle : mcParticles) { + if (particle.eta() < -cfgCutEta || particle.eta() > cfgCutEta) { + continue; + } + if (particle.pt() < cfgCutPtMin || particle.pt() > cfgCutPtMax) { + continue; + } + + if (!particle.isPhysicalPrimary()) { + continue; + } + + if (isStable(particle.pdgCode())) { + registry.fill(HIST("hEventCounterMCGen"), 2.5); + registry.fill(HIST("hPtMCGen"), particle.pt()); + registry.fill(HIST("hCenMCGen"), centrality); + + if (centrality >= 0 && centrality <= 5) { + registry.fill(HIST("hPtMCGen05"), particle.pt()); + registry.fill(HIST("hCenMCGen05"), centrality); + registry.fill(HIST("hPtNchMCGen05"), particle.pt(), numberOfTracks[0]); + } + + if (collisions.size() > 0) { + registry.fill(HIST("hPtNchMCGen"), particle.pt(), numberOfTracks[0]); + } + } + + for (const auto& track : groupedTracksReco) { + + registry.fill(HIST("hCorr"), numberOfTracks[0], track.size()); + if (centrality >= 0 && centrality <= 5) { + registry.fill(HIST("hCorr05"), numberOfTracks[0], track.size()); + } + } + + registry.fill(HIST("PtMC_ch"), centrality, particle.pt()); + if (particle.pdgCode() == kPiPlus || + particle.pdgCode() == kPiMinus) { // pion + registry.fill(HIST("PtMC_pi"), centrality, particle.pt()); + } else if (particle.pdgCode() == kKPlus || + particle.pdgCode() == kKMinus) { // kaon + registry.fill(HIST("PtMC_ka"), centrality, particle.pt()); + } else if (particle.pdgCode() == kProton || + particle.pdgCode() == kProtonBar) { // proton + registry.fill(HIST("PtMC_pr"), centrality, particle.pt()); + } else if (particle.pdgCode() == kSigmaPlus || + particle.pdgCode() == + kSigmaBarMinus) { // positive sigma + registry.fill(HIST("PtMC_sigpos"), centrality, particle.pt()); + } else if (particle.pdgCode() == kSigmaMinus || + particle.pdgCode() == + kSigmaBarPlus) { // negative sigma + registry.fill(HIST("PtMC_signeg"), centrality, particle.pt()); + } else { // rest + registry.fill(HIST("PtMC_re"), centrality, particle.pt()); + } + } + } + } + PROCESS_SWITCH(FlowGfwTask, processpTEff, "Process pT Eff", false); + +}; // End of struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/flowMc.cxx b/PWGCF/Flow/Tasks/flowMc.cxx new file mode 100644 index 00000000000..5884fa0e127 --- /dev/null +++ b/PWGCF/Flow/Tasks/flowMc.cxx @@ -0,0 +1,675 @@ +// 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. + +/// \file flowMc.cxx +/// \author Zhiyong Lu (zhiyong.lu@cern.ch) +/// \since Feb/5/2025 +/// \brief QC of synthetic flow exercise + +#include +#include +#include +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/Core/trackUtilities.h" +#include "ReconstructionDataFormats/Track.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGMM/Mult/DataModel/Index.h" // for Particles2Tracks table +#include "GFWPowerArray.h" +#include "GFW.h" +#include "GFWCumulant.h" +#include "GFWWeights.h" +#include "FlowContainer.h" +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +struct FlowMc { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Configurable minB{"minB", 0.0f, "min impact parameter"}; + Configurable maxB{"maxB", 20.0f, "max impact parameter"}; + O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 1000.0f, "Maximal pT for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights") + O2_DEFINE_CONFIGURABLE(cfgCutPtRefMin, float, 0.2f, "Minimal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtRefMax, float, 3.0f, "Maximal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 50.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters") + O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5f, "max chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCcrossedrows, float, 70.0f, "minimum TPC crossed rows") + O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 0.2f, "DCAxy cut for tracks") + O2_DEFINE_CONFIGURABLE(cfgDCAxyNSigma, float, 7, "Cut on number of sigma deviations from expected DCA in the transverse direction"); + O2_DEFINE_CONFIGURABLE(cfgDCAxyFunction, std::string, "(0.0015+0.005/(x^1.1))", "Functional form of pt-dependent DCAxy cut"); + O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "DCAz cut for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutDCAzPtDepEnabled, bool, false, "switch of DCAz pt dependent cut") + O2_DEFINE_CONFIGURABLE(cfgEnableITSCuts, bool, true, "switch of enabling ITS based track selection cuts") + O2_DEFINE_CONFIGURABLE(cfgTrkSelRun3ITSMatch, bool, false, "GlobalTrackRun3ITSMatching::Run3ITSall7Layers selection") + O2_DEFINE_CONFIGURABLE(cfgFlowAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgFlowEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgCentVsIPTruth, std::string, "", "CCDB path to centrality vs IP truth") + O2_DEFINE_CONFIGURABLE(cfgIsGlobalTrack, bool, false, "Use global tracks instead of hasTPC&&hasITS") + O2_DEFINE_CONFIGURABLE(cfgK0Lambda0Enabled, bool, false, "Add K0 and Lambda0") + O2_DEFINE_CONFIGURABLE(cfgFlowCumulantEnabled, bool, false, "switch of calculating flow") + O2_DEFINE_CONFIGURABLE(cfgFlowCumulantNbootstrap, int, 30, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrUse, bool, false, "Use track density efficiency correction") + O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrSlopeFactor, float, 1.0f, "A factor to scale the track density efficiency slope") + O2_DEFINE_CONFIGURABLE(cfgRecoEvRejectMC, bool, false, "reject both MC and Reco events when reco do not pass") + O2_DEFINE_CONFIGURABLE(cfgRecoEvSel8, bool, false, "require sel8 for reconstruction events") + O2_DEFINE_CONFIGURABLE(cfgRecoEvkIsGoodITSLayersAll, bool, false, "require kIsGoodITSLayersAll for reconstruction events") + O2_DEFINE_CONFIGURABLE(cfgRecoEvkNoSameBunchPileup, bool, false, "require kNoSameBunchPileup for reconstruction events") + Configurable> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector{0.6003720411, 0.6152630970, 0.6288860646, 0.6360694031, 0.6409494798, 0.6450540203, 0.6482117301, 0.6512592056, 0.6640008690, 0.6862631416, 0.7005738691, 0.7106567432, 0.7170728333}, "parameter 0 for track density efficiency correction"}; + Configurable> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector{-1.007592e-05, -8.932635e-06, -9.114538e-06, -1.054818e-05, -1.220212e-05, -1.312304e-05, -1.376433e-05, -1.412813e-05, -1.289562e-05, -1.050065e-05, -8.635725e-06, -7.380821e-06, -6.201250e-06}, "parameter 1 for track density efficiency correction"}; + float maxEta = 0.8; + + ConfigurableAxis axisB{"axisB", {100, 0.0f, 20.0f}, ""}; + ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "X axis for histograms"}; + ConfigurableAxis axisPhi{"axisPhi", {100, 0.0f, constants::math::TwoPI}, ""}; + ConfigurableAxis axisNch{"axisNch", {300, 0.0f, 3000.0f}, "Nch in |eta|<0.8"}; + + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f}, "pt axis"}; + + // Filter for MCcollisions + Filter mccollisionFilter = nabs(aod::mccollision::posZ) < cfgCutVertex; + using FilteredMcCollisions = soa::Filtered; + // Filter for MCParticle + Filter particleFilter = (nabs(aod::mcparticle::eta) < cfgCutEta) && (aod::mcparticle::pt > cfgCutPtMin) && (aod::mcparticle::pt < cfgCutPtMax); + using FilteredMcParticles = soa::Filtered>; + // Filter for reco tracks + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); + using FilteredTracks = soa::Filtered>; + + // using FilteredTracks = soa::Join; + + // Additional filters for tracks + TrackSelection myTrackSel; + TF1* fPtDepDCAxy = nullptr; + + // Cent vs IP + TH1D* mCentVsIPTruth = nullptr; + bool centVsIPTruthLoaded = false; + + // Corrections + TH1D* mEfficiency = nullptr; + GFWWeights* mAcceptance = nullptr; + bool correctionsLoaded = false; + + std::vector funcEff; + TH1D* hFindPtBin; + TF1* funcV2; + TF1* funcV3; + TF1* funcV4; + + // Connect to ccdb + Service ccdb; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + OutputObj fWeights{GFWWeights("weights")}; + OutputObj fFCTrue{FlowContainer("FlowContainerTrue")}; + OutputObj fFCReco{FlowContainer("FlowContainerReco")}; + GFW* fGFWTrue = new GFW(); + GFW* fGFWReco = new GFW(); + TAxis* fPtAxis; + std::vector corrconfigsTruth; + std::vector corrconfigsReco; + TRandom3* fRndm = new TRandom3(0); + double epsilon = 1e-6; + + void init(InitContext&) + { + ccdb->setURL(ccdbUrl.value); + ccdb->setCaching(true); + auto now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); + + const AxisSpec axisVertex{20, -10, 10, "Vtxz (cm)"}; + const AxisSpec axisEta{20, -1., 1., "#eta"}; + const AxisSpec axisCounter{1, 0, +1, ""}; + // QA histograms + histos.add("mcEventCounter", "Monte Carlo Truth EventCounter", HistType::kTH1F, {axisCounter}); + histos.add("numberOfRecoCollisions", "numberOfRecoCollisions", HistType::kTH1F, {{10, -0.5f, 9.5f}}); + histos.add("RecoEventCounter", "Reconstruction EventCounter", HistType::kTH1F, {axisCounter}); + histos.add("hnTPCClu", "Number of found TPC clusters", HistType::kTH1D, {{100, 40, 180}}); + histos.add("hnITSClu", "Number of found ITS clusters", HistType::kTH1D, {{100, 0, 20}}); + // pT histograms + histos.add("hImpactParameter", "hImpactParameter", HistType::kTH1D, {axisB}); + histos.add("hNchVsImpactParameter", "hNchVsImpactParameter", HistType::kTH2D, {axisB, axisNch}); + histos.add("hEventPlaneAngle", "hEventPlaneAngle", HistType::kTH1D, {axisPhi}); + histos.add("hPtVsPhiGenerated", "hPtVsPhiGenerated", HistType::kTH2D, {axisPhi, axisPt}); + histos.add("hPtVsPhiGlobal", "hPtVsPhiGlobal", HistType::kTH2D, {axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGenerated", "hBVsPtVsPhiGenerated", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobal", "hBVsPtVsPhiGlobal", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiAny", "hBVsPtVsPhiAny", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiTPCTrack", "hBVsPtVsPhiTPCTrack", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiITSTrack", "hBVsPtVsPhiITSTrack", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiITSABTrack", "hBVsPtVsPhiITSABTrack", HistType::kTH3D, {axisB, axisPhi, axisPt}); + + histos.add("hBVsPtVsPhiGeneratedK0Short", "hBVsPtVsPhiGeneratedK0Short", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobalK0Short", "hBVsPtVsPhiGlobalK0Short", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGeneratedLambda", "hBVsPtVsPhiGeneratedLambda", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobalLambda", "hBVsPtVsPhiGlobalLambda", HistType::kTH3D, {axisB, axisPhi, axisPt}); + + histos.add("hBVsPtVsPhiGeneratedXi", "hBVsPtVsPhiGeneratedXi", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobalXi", "hBVsPtVsPhiGlobalXi", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGeneratedOmega", "hBVsPtVsPhiGeneratedOmega", HistType::kTH3D, {axisB, axisPhi, axisPt}); + histos.add("hBVsPtVsPhiGlobalOmega", "hBVsPtVsPhiGlobalOmega", HistType::kTH3D, {axisB, axisPhi, axisPt}); + + histos.add("hPhi", "#phi distribution", HistType::kTH1D, {axisPhi}); + histos.add("hPhiWeighted", "corrected #phi distribution", HistType::kTH1D, {axisPhi}); + histos.add("hEPVsPhiMC", "hEPVsPhiMC;Event Plane Angle; #varphi", HistType::kTH2D, {axisPhi, axisPhi}); + histos.add("hEPVsPhi", "hEPVsPhi;Event Plane Angle; #varphi", HistType::kTH2D, {axisPhi, axisPhi}); + histos.add("hPtNchGenerated", "Reco production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGlobal", "Global production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGeneratedPion", "Reco production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGlobalPion", "Global production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGeneratedKaon", "Reco production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGlobalKaon", "Global production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGeneratedProton", "Reco production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGlobalProton", "Global production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGeneratedK0", "Reco production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGlobalK0", "Global production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGeneratedLambda", "Reco production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtNchGlobalLambda", "Global production; pT (GeV/c); multiplicity", HistType::kTH2D, {axisPt, axisNch}); + histos.add("hPtMCGen", "Monte Carlo Truth; pT (GeV/c);", {HistType::kTH1D, {axisPt}}); + histos.add("hEtaPtVtxzMCGen", "Monte Carlo Truth; #eta; p_{T} (GeV/c); V_{z} (cm);", {HistType::kTH3D, {axisEta, axisPt, axisVertex}}); + histos.add("hPtMCGlobal", "Monte Carlo Global; pT (GeV/c);", {HistType::kTH1D, {axisPt}}); + histos.add("hEtaPtVtxzMCGlobal", "Monte Carlo Global; #eta; p_{T} (GeV/c); V_{z} (cm);", {HistType::kTH3D, {axisEta, axisPt, axisVertex}}); + histos.add("hPhiWeightedTrDen", "corrected #phi distribution, considering track density", {HistType::kTH1D, {axisPhi}}); + + o2::framework::AxisSpec axis = axisPt; + int nPtBins = axis.binEdges.size() - 1; + double* ptBins = &(axis.binEdges)[0]; + fPtAxis = new TAxis(nPtBins, ptBins); + + if (cfgOutputNUAWeights) { + fWeights->setPtBins(nPtBins, ptBins); + fWeights->init(true, false); + } + + if (cfgFlowCumulantEnabled) { + TObjArray* oba = new TObjArray(); + oba->Add(new TNamed("ChFull22", "ChFull22")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull22_pt_%i", i + 1), "ChFull22_pTDiff")); + oba->Add(new TNamed("Ch10Gap22", "Ch10Gap22")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap22_pt_%i", i + 1), "Ch10Gap22_pTDiff")); + fFCTrue->SetName("FlowContainerTrue"); + fFCTrue->SetXAxis(fPtAxis); + fFCTrue->Initialize(oba, axisCentrality, cfgFlowCumulantNbootstrap); + fFCReco->SetName("FlowContainerReco"); + fFCReco->SetXAxis(fPtAxis); + fFCReco->Initialize(oba, axisCentrality, cfgFlowCumulantNbootstrap); + delete oba; + + fGFWTrue->AddRegion("full", -0.8, 0.8, 1, 1); + fGFWTrue->AddRegion("refN10", -0.8, -0.5, 1, 1); + fGFWTrue->AddRegion("refP10", 0.5, 0.8, 1, 1); + fGFWTrue->AddRegion("poiN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 2); + fGFWTrue->AddRegion("poifull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 2); + fGFWTrue->AddRegion("olN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 4); + fGFWTrue->AddRegion("olfull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 4); + corrconfigsTruth.push_back(fGFWTrue->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); + corrconfigsTruth.push_back(fGFWTrue->GetCorrelatorConfig("poifull full | olfull {2 -2}", "ChFull22", kTRUE)); + corrconfigsTruth.push_back(fGFWTrue->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE)); + corrconfigsTruth.push_back(fGFWTrue->GetCorrelatorConfig("poiN10 refN10 | olN10 {2} refP10 {-2}", "Ch10Gap22", kTRUE)); + fGFWTrue->CreateRegions(); + + fGFWReco->AddRegion("full", -0.8, 0.8, 1, 1); + fGFWReco->AddRegion("refN10", -0.8, -0.5, 1, 1); + fGFWReco->AddRegion("refP10", 0.5, 0.8, 1, 1); + fGFWReco->AddRegion("poiN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 2); + fGFWReco->AddRegion("poifull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 2); + fGFWReco->AddRegion("olN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 4); + fGFWReco->AddRegion("olfull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 4); + corrconfigsReco.push_back(fGFWReco->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); + corrconfigsReco.push_back(fGFWReco->GetCorrelatorConfig("poifull full | olfull {2 -2}", "ChFull22", kTRUE)); + corrconfigsReco.push_back(fGFWReco->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE)); + corrconfigsReco.push_back(fGFWReco->GetCorrelatorConfig("poiN10 refN10 | olN10 {2} refP10 {-2}", "Ch10Gap22", kTRUE)); + fGFWReco->CreateRegions(); + } + + if (cfgEnableITSCuts) { + if (cfgTrkSelRun3ITSMatch) { + myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + } else { + myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + } + } + if (cfgCutDCAxy != 0.0) { + myTrackSel.SetMaxDcaXY(cfgCutDCAxy); + } else { + fPtDepDCAxy = new TF1("ptDepDCAxy", Form("[0]*%s", cfgDCAxyFunction->c_str()), 0.001, 100); + fPtDepDCAxy->SetParameter(0, cfgDCAxyNSigma); + LOGF(info, "DCAxy pt-dependence function: %s", Form("[0]*%s", cfgDCAxyFunction->c_str())); + myTrackSel.SetMaxDcaXYPtDep([fPtDepDCAxy = this->fPtDepDCAxy](float pt) { return fPtDepDCAxy->Eval(pt); }); + } + myTrackSel.SetMinNClustersTPC(cfgCutTPCclu); + myTrackSel.SetMinNCrossedRowsTPC(cfgCutTPCcrossedrows); + if (cfgEnableITSCuts) + myTrackSel.SetMinNClustersITS(cfgCutITSclu); + if (!cfgCutDCAzPtDepEnabled) + myTrackSel.SetMaxDcaZ(cfgCutDCAz); + + if (cfgTrackDensityCorrUse) { + std::vector pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0}; + hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]); + funcEff.resize(pTEffBins.size() - 1); + // LHC24g3 Eff + std::vector f1p0 = cfgTrackDensityP0; + std::vector f1p1 = cfgTrackDensityP1; + for (uint ifunc = 0; ifunc < pTEffBins.size() - 1; ifunc++) { + funcEff[ifunc] = new TF1(Form("funcEff%i", ifunc), "[0]+[1]*x", 0, 3000); + funcEff[ifunc]->SetParameters(f1p0[ifunc], f1p1[ifunc] * cfgTrackDensityCorrSlopeFactor); + } + funcV2 = new TF1("funcV2", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV2->SetParameters(0.0186111, 0.00351907, -4.38264e-05, 1.35383e-07, -3.96266e-10); + funcV3 = new TF1("funcV3", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV3->SetParameters(0.0174056, 0.000703329, -1.45044e-05, 1.91991e-07, -1.62137e-09); + funcV4 = new TF1("funcV4", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV4->SetParameters(0.008845, 0.000259668, -3.24435e-06, 4.54837e-08, -6.01825e-10); + } + } + + void loadCorrections(uint64_t timestamp) + { + if (correctionsLoaded) + return; + if (cfgFlowAcceptance.value.empty() == false) { + mAcceptance = ccdb->getForTimeStamp(cfgFlowAcceptance, timestamp); + if (mAcceptance) + LOGF(info, "Loaded acceptance weights from %s (%p)", cfgFlowAcceptance.value.c_str(), (void*)mAcceptance); + else + LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgFlowAcceptance.value.c_str(), (void*)mAcceptance); + } + if (cfgFlowEfficiency.value.empty() == false) { + mEfficiency = ccdb->getForTimeStamp(cfgFlowEfficiency, timestamp); + if (mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgFlowEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgFlowEfficiency.value.c_str(), (void*)mEfficiency); + } + correctionsLoaded = true; + } + + bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz) + { + float eff = 1.; + if (mEfficiency) + eff = mEfficiency->GetBinContent(mEfficiency->FindBin(pt)); + else + eff = 1.0; + if (eff == 0) + return false; + weight_nue = 1. / eff; + if (mAcceptance) + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + else + weight_nua = 1; + return true; + } + + void fillFC(GFW* fGFW, bool isMCTruth, const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (!corrconf.pTDif) { + if (dnx == 0) + return; + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + if (isMCTruth) + fFCTrue->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); + else + fFCReco->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); + } + return; + } + for (auto i = 1; i <= fPtAxis->GetNbins(); i++) { + dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); + if (dnx == 0) + continue; + val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + if (isMCTruth) + fFCTrue->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); + else + fFCReco->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); + } + } + return; + } + + void loadCentVsIPTruth(uint64_t timestamp) + { + if (centVsIPTruthLoaded) + return; + if (cfgCentVsIPTruth.value.empty() == false) { + mCentVsIPTruth = ccdb->getForTimeStamp(cfgCentVsIPTruth, timestamp); + if (mCentVsIPTruth) + LOGF(info, "Loaded CentVsIPTruth weights from %s (%p)", cfgCentVsIPTruth.value.c_str(), (void*)mCentVsIPTruth); + else + LOGF(fatal, "Failed to load CentVsIPTruth weights from %s", cfgCentVsIPTruth.value.c_str()); + + centVsIPTruthLoaded = true; + } else { + LOGF(fatal, "when calculate flow, Cent Vs IP distribution must be provided"); + } + } + + template + bool eventSelected(TCollision collision) + { + if (std::fabs(collision.posZ()) > cfgCutVertex) { + return 0; + } + if (cfgRecoEvSel8 && !collision.sel8()) { + return 0; + } + if (cfgRecoEvkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return 0; + } + if (cfgRecoEvkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // from Jan 9 2025 AOT meeting + // cut time intervals with dead ITS staves + return 0; + } + return 1; + } + + template + bool trackSelected(TTrack track) + { + if (cfgCutDCAzPtDepEnabled && (track.dcaZ() > (0.004f + 0.013f / track.pt()))) { + return false; + } + return myTrackSel.IsSelected(track); + } + + void process(FilteredMcCollisions::iterator const& mcCollision, aod::BCsWithTimestamps const&, soa::SmallGroups> const& collisions, FilteredMcParticles const& mcParticles, FilteredTracks const&) + { + + float imp = mcCollision.impactParameter(); + float evPhi = mcCollision.eventPlaneAngle(); + float vtxz = mcCollision.posZ(); + evPhi = RecoDecay::constrainAngle(evPhi); + + int64_t nCh = 0; + int64_t nChGlobal = 0; + float centrality = 0; + float lRandom = fRndm->Rndm(); + float weff = 1.; + float wacc = 1.; + auto bc = mcCollision.bc_as(); + loadCorrections(bc.timestamp()); + + if (collisions.size() > -1) { + histos.fill(HIST("mcEventCounter"), 0.5); + histos.fill(HIST("numberOfRecoCollisions"), collisions.size()); // number of times coll was reco-ed + if (cfgRecoEvRejectMC) { + if (collisions.size() != 1) { // only pass those have one reconstruction event + return; + } + for (auto const& collision : collisions) { + if (!eventSelected(collision)) + return; + } + } + histos.fill(HIST("RecoEventCounter"), 0.5); + } + + if (imp > minB && imp < maxB) { + // event within range + histos.fill(HIST("hImpactParameter"), imp); + histos.fill(HIST("hEventPlaneAngle"), evPhi); + if (cfgFlowCumulantEnabled) { + loadCentVsIPTruth(bc.timestamp()); + centrality = mCentVsIPTruth->GetBinContent(mCentVsIPTruth->GetXaxis()->FindBin(imp)); + fGFWTrue->Clear(); + fGFWReco->Clear(); + } + + double psi2Est = 0, psi3Est = 0, psi4Est = 0; + float wEPeff = 1; + double v2 = 0, v3 = 0, v4 = 0; + double q2x = 0, q2y = 0; + double q3x = 0, q3y = 0; + double q4x = 0, q4y = 0; + for (auto const& mcParticle : mcParticles) { + int pdgCode = std::abs(mcParticle.pdgCode()); + if (pdgCode != PDG_t::kElectron && pdgCode != PDG_t::kMuonMinus && pdgCode != PDG_t::kPiPlus && pdgCode != kKPlus && pdgCode != PDG_t::kProton) + continue; + if (!mcParticle.isPhysicalPrimary()) + continue; + if (std::fabs(mcParticle.eta()) > maxEta) // main acceptance + continue; + if (mcParticle.has_tracks()) { + auto const& tracks = mcParticle.tracks_as(); + for (auto const& track : tracks) { + if (!trackSelected(track)) { + continue; + } + if (cfgIsGlobalTrack && track.isGlobalTrack()) { + nChGlobal++; + } + if (!cfgIsGlobalTrack && track.hasTPC() && track.hasITS()) { + nChGlobal++; + } + if (cfgTrackDensityCorrUse && cfgFlowCumulantEnabled) { + bool withinPtRef = (cfgCutPtRefMin < track.pt()) && (track.pt() < cfgCutPtRefMax); // within RF pT rang + if (withinPtRef) { + q2x += std::cos(2 * track.phi()); + q2y += std::sin(2 * track.phi()); + q3x += std::cos(3 * track.phi()); + q3y += std::sin(3 * track.phi()); + q4x += std::cos(4 * track.phi()); + q4y += std::sin(4 * track.phi()); + } + } + } + } + } + if (cfgTrackDensityCorrUse && cfgFlowCumulantEnabled) { + psi2Est = std::atan2(q2y, q2x) / 2.; + psi3Est = std::atan2(q3y, q3x) / 3.; + psi4Est = std::atan2(q4y, q4x) / 4.; + v2 = funcV2->Eval(centrality); + v3 = funcV3->Eval(centrality); + v4 = funcV4->Eval(centrality); + } + + for (auto const& mcParticle : mcParticles) { + // focus on bulk: e, mu, pi, k, p + int pdgCode = std::abs(mcParticle.pdgCode()); + bool extraPDGType = true; + if (cfgK0Lambda0Enabled) { + extraPDGType = (pdgCode != PDG_t::kK0Short && pdgCode != PDG_t::kLambda0); + } + if (extraPDGType && pdgCode != PDG_t::kElectron && pdgCode != PDG_t::kMuonMinus && pdgCode != PDG_t::kPiPlus && pdgCode != kKPlus && pdgCode != PDG_t::kProton) + continue; + + if (!mcParticle.isPhysicalPrimary()) + continue; + if (std::fabs(mcParticle.eta()) > maxEta) // main acceptance + continue; + + float deltaPhi = mcParticle.phi() - mcCollision.eventPlaneAngle(); + deltaPhi = RecoDecay::constrainAngle(deltaPhi); + histos.fill(HIST("hPtVsPhiGenerated"), deltaPhi, mcParticle.pt()); + histos.fill(HIST("hBVsPtVsPhiGenerated"), imp, deltaPhi, mcParticle.pt()); + histos.fill(HIST("hPtNchGenerated"), mcParticle.pt(), nChGlobal); + histos.fill(HIST("hPtMCGen"), mcParticle.pt()); + histos.fill(HIST("hEtaPtVtxzMCGen"), mcParticle.eta(), mcParticle.pt(), vtxz); + if (pdgCode == PDG_t::kPiPlus) + histos.fill(HIST("hPtNchGeneratedPion"), mcParticle.pt(), nChGlobal); + if (pdgCode == PDG_t::kKPlus) + histos.fill(HIST("hPtNchGeneratedKaon"), mcParticle.pt(), nChGlobal); + if (pdgCode == PDG_t::kProton) + histos.fill(HIST("hPtNchGeneratedProton"), mcParticle.pt(), nChGlobal); + if (pdgCode == PDG_t::kK0Short) + histos.fill(HIST("hPtNchGeneratedK0"), mcParticle.pt(), nChGlobal); + if (pdgCode == PDG_t::kLambda0) + histos.fill(HIST("hPtNchGeneratedLambda"), mcParticle.pt(), nChGlobal); + + nCh++; + + bool validGlobal = false; + bool validTrack = false; + bool validTPCTrack = false; + bool validITSTrack = false; + bool validITSABTrack = false; + if (mcParticle.has_tracks()) { + auto const& tracks = mcParticle.tracks_as(); + for (auto const& track : tracks) { + if (!trackSelected(track)) { + continue; + } + histos.fill(HIST("hnTPCClu"), track.tpcNClsFound()); + histos.fill(HIST("hnITSClu"), track.itsNCls()); + if (cfgIsGlobalTrack && track.isGlobalTrack()) { + validGlobal = true; + } + if (!cfgIsGlobalTrack && track.hasTPC() && track.hasITS()) { + validGlobal = true; + } + if (track.hasTPC() || track.hasITS()) { + validTrack = true; + } + if (track.hasTPC()) { + validTPCTrack = true; + } + if (track.hasITS() && track.itsChi2NCl() > -1. * epsilon) { + validITSTrack = true; + } + if (track.hasITS() && track.itsChi2NCl() < -1. * epsilon) { + validITSABTrack = true; + } + } + } + + bool withinPtRef = (cfgCutPtRefMin < mcParticle.pt()) && (mcParticle.pt() < cfgCutPtRefMax); // within RF pT range + bool withinPtPOI = (cfgCutPtPOIMin < mcParticle.pt()) && (mcParticle.pt() < cfgCutPtPOIMax); // within POI pT range + if (cfgOutputNUAWeights && withinPtRef) + fWeights->fill(mcParticle.phi(), mcParticle.eta(), vtxz, mcParticle.pt(), 0, 0); + if (!setCurrentParticleWeights(weff, wacc, mcParticle.phi(), mcParticle.eta(), mcParticle.pt(), vtxz)) + continue; + if (cfgTrackDensityCorrUse && cfgFlowCumulantEnabled && withinPtRef) { + double fphi = v2 * std::cos(2 * (mcParticle.phi() - psi2Est)) + v3 * std::cos(3 * (mcParticle.phi() - psi3Est)) + v4 * std::cos(4 * (mcParticle.phi() - psi4Est)); + fphi = (1 + 2 * fphi); + int pTBinForEff = hFindPtBin->FindBin(mcParticle.pt()); + if (pTBinForEff >= 1 && pTBinForEff <= hFindPtBin->GetNbinsX()) { + wEPeff = funcEff[pTBinForEff - 1]->Eval(fphi * nChGlobal); + if (wEPeff > 0.) { + wEPeff = 1. / wEPeff; + weff *= wEPeff; + histos.fill(HIST("hPhiWeightedTrDen"), mcParticle.phi(), wacc * wEPeff); + } + } + } + + if (cfgFlowCumulantEnabled) { + if (withinPtRef) + fGFWTrue->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), wacc * weff, 1); + if (withinPtPOI) + fGFWTrue->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), wacc * weff, 2); + if (withinPtPOI && withinPtRef) + fGFWTrue->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), wacc * weff, 4); + + if (validGlobal) { + if (withinPtRef) + fGFWReco->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), wacc * weff, 1); + if (withinPtPOI) + fGFWReco->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), wacc * weff, 2); + if (withinPtPOI && withinPtRef) + fGFWReco->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), wacc * weff, 4); + } + } + + if (withinPtRef) { + histos.fill(HIST("hEPVsPhiMC"), evPhi, mcParticle.phi()); + } + + if (validGlobal && withinPtRef) { + histos.fill(HIST("hPhi"), mcParticle.phi()); + histos.fill(HIST("hPhiWeighted"), mcParticle.phi(), wacc); + histos.fill(HIST("hEPVsPhi"), evPhi, mcParticle.phi()); + } + + // if valid global, fill + if (validGlobal) { + histos.fill(HIST("hPtVsPhiGlobal"), deltaPhi, mcParticle.pt(), wacc * weff); + histos.fill(HIST("hBVsPtVsPhiGlobal"), imp, deltaPhi, mcParticle.pt(), wacc * weff); + histos.fill(HIST("hPtNchGlobal"), mcParticle.pt(), nChGlobal); + histos.fill(HIST("hPtMCGlobal"), mcParticle.pt()); + histos.fill(HIST("hEtaPtVtxzMCGlobal"), mcParticle.eta(), mcParticle.pt(), vtxz); + if (pdgCode == PDG_t::kPiPlus) + histos.fill(HIST("hPtNchGlobalPion"), mcParticle.pt(), nChGlobal); + if (pdgCode == PDG_t::kKPlus) + histos.fill(HIST("hPtNchGlobalKaon"), mcParticle.pt(), nChGlobal); + if (pdgCode == PDG_t::kProton) + histos.fill(HIST("hPtNchGlobalProton"), mcParticle.pt(), nChGlobal); + if (pdgCode == PDG_t::kK0Short) + histos.fill(HIST("hPtNchGlobalK0"), mcParticle.pt(), nChGlobal); + if (pdgCode == PDG_t::kLambda0) + histos.fill(HIST("hPtNchGlobalLambda"), mcParticle.pt(), nChGlobal); + } + // if any track present, fill + if (validTrack) + histos.fill(HIST("hBVsPtVsPhiAny"), imp, deltaPhi, mcParticle.pt(), wacc * weff); + if (validTPCTrack) + histos.fill(HIST("hBVsPtVsPhiTPCTrack"), imp, deltaPhi, mcParticle.pt(), wacc * weff); + if (validITSTrack) + histos.fill(HIST("hBVsPtVsPhiITSTrack"), imp, deltaPhi, mcParticle.pt(), wacc * weff); + if (validITSABTrack) + histos.fill(HIST("hBVsPtVsPhiITSABTrack"), imp, deltaPhi, mcParticle.pt(), wacc * weff); + } + + if (cfgFlowCumulantEnabled) { + for (uint l_ind = 0; l_ind < corrconfigsTruth.size(); l_ind++) { + fillFC(fGFWTrue, true, corrconfigsTruth.at(l_ind), centrality, lRandom); + } + for (uint l_ind = 0; l_ind < corrconfigsReco.size(); l_ind++) { + fillFC(fGFWReco, false, corrconfigsReco.at(l_ind), centrality, lRandom); + } + } + } + histos.fill(HIST("hNchVsImpactParameter"), imp, nCh); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/flowPbpbPikp.cxx b/PWGCF/Flow/Tasks/flowPbpbPikp.cxx index 5aecd0a5fa4..c022cad77c2 100644 --- a/PWGCF/Flow/Tasks/flowPbpbPikp.cxx +++ b/PWGCF/Flow/Tasks/flowPbpbPikp.cxx @@ -13,43 +13,47 @@ /// \brief PID flow using the generic framework /// \author Preet Bhanjan Pati -#include -#include -#include -#include -#include -#include - -#include "Math/Vector4D.h" - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/StepTHn.h" +#include "PWGCF/GenericFramework/Core/FlowContainer.h" +#include "PWGCF/GenericFramework/Core/GFW.h" +#include "PWGCF/GenericFramework/Core/GFWConfig.h" +#include "PWGCF/GenericFramework/Core/GFWCumulant.h" +#include "PWGCF/GenericFramework/Core/GFWPowerArray.h" +#include "PWGCF/GenericFramework/Core/GFWWeights.h" +#include "PWGCF/GenericFramework/Core/GFWWeightsList.h" -#include "Common/DataModel/EventSelection.h" #include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" #include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "CommonConstants/PhysicsConstants.h" - -#include "PWGCF/GenericFramework/Core/GFWPowerArray.h" -#include "PWGCF/GenericFramework/Core/GFW.h" -#include "PWGCF/GenericFramework/Core/GFWCumulant.h" -#include "PWGCF/GenericFramework/Core/FlowContainer.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "ReconstructionDataFormats/Track.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/PID.h" +#include "ReconstructionDataFormats/Track.h" +#include +#include "Math/Vector4D.h" +#include #include #include +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -57,10 +61,19 @@ using namespace std; #define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; +namespace o2::analysis::genericframework +{ +GFWRegions regions; +GFWCorrConfigs configs; +} // namespace o2::analysis::genericframework + +using namespace o2::analysis::genericframework; + struct FlowPbpbPikp { + o2::aod::ITSResponse itsResponse; Service ccdb; Configurable noLaterThan{"noLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; - Configurable ccdbUrl{"ccdbUrl", "http://ccdb-test.cern.ch:8080", "url of the ccdb repository"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") @@ -68,33 +81,65 @@ struct FlowPbpbPikp { O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for ref tracks") O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 3.0f, "Maximal pT for ref tracks") O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgTpcCluster, int, 70, "Number of TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgTpcCrossRows, int, 70, "Number of TPC clusters") O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables") O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") - O2_DEFINE_CONFIGURABLE(cfgTpcNsigmaCut, float, 2.0f, "TPC N-sigma cut for pions, kaons, protons") - O2_DEFINE_CONFIGURABLE(cfgTofPtCut, float, 1.8f, "Minimum pt to use TOF N-sigma") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, true, "Fill and output NUA weights") + O2_DEFINE_CONFIGURABLE(cfgOutputRunByRun, bool, true, "Fill and output NUA weights run by run") + O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgTpcCut, float, 2.0f, "TPC N-sigma cut for pions, kaons, protons") + O2_DEFINE_CONFIGURABLE(cfgTofPtCut, float, 0.5f, "Minimum pt to use TOF N-sigma") + O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 2.0f, "DCAxy range for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "DCAz range for tracks") + + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyMin, int, 0, "Minimum occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyMax, int, 2000, "Maximum occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgUseGlobalTrack, bool, true, "use Global track") + O2_DEFINE_CONFIGURABLE(cfgITScluster, int, 5, "Number of ITS cluster") + O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrUse, bool, false, "Use track density efficiency correction") + + O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiEtaVtxz, bool, false, "Use Phi, Eta, VertexZ dependent NUA weights") + O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiPtCent, bool, false, "Use Phi, Pt, Centrality dependent NUA weights") + O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiEtaPt, bool, true, "Use Phi, Eta, Pt dependent NUA weights") + O2_DEFINE_CONFIGURABLE(cfgUseStrictPID, bool, true, "Use strict PID cuts for TPC") + O2_DEFINE_CONFIGURABLE(cfgV0AT0Acut, int, 5, "V0AT0A cut") + O2_DEFINE_CONFIGURABLE(cfgUseAsymmetricPID, bool, false, "Use asymmetric PID cuts") + O2_DEFINE_CONFIGURABLE(cfgUseItsPID, bool, true, "Use ITS PID for particle identification") + + Configurable> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector{0.7217476707, 0.7384792571, 0.7542625668, 0.7640680200, 0.7701951667, 0.7755299053, 0.7805901710, 0.7849446786, 0.7957356586, 0.8113039262, 0.8211968966, 0.8280558878, 0.8329342135}, "parameter 0 for track density efficiency correction"}; + Configurable> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector{-2.169488e-05, -2.191913e-05, -2.295484e-05, -2.556538e-05, -2.754463e-05, -2.816832e-05, -2.846502e-05, -2.843857e-05, -2.705974e-05, -2.477018e-05, -2.321730e-05, -2.203315e-05, -2.109474e-05}, "parameter 1 for track density efficiency correction"}; + Configurable> cfgTofNsigmaCut{"cfgTofNsigmaCut", std::vector{1.5, 1.5, 1.5, -1.5, -1.5, -1.5}, "TOF n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"}; + Configurable> cfgItsNsigmaCut{"cfgItsNsigmaCut", std::vector{3, 3, 3, -3, -3, -3}, "ITS n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"}; + Configurable> cfgTpcNsigmaCut{"cfgTpcNsigmaCut", std::vector{10, 10, 10, -10, -10, -10}, "TOF n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"}; + Configurable> cfgUseEventCuts{"cfgUseEventCuts", std::vector{1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0}, "Switch for various event cuts [Filtered Events, Sel8, kNoTimeFrameBorder, kNoITSROFrameBorder, kNoSameBunchPileup, kIsGoodZvtxFT0vsPV, kNoCollInTimeRangeStandard, kIsGoodITSLayersAll, kNoCollInRofStandard, kNoHighMultCollInPrevRof, Occupancy, Multiplicity correlation, T0AV0A 3 sigma cut, kIsVertexITSTPC, kTVXinTRD]"}; + + Configurable cfgRegions{"cfgRegions", {{"refN08", "refP08", "full", "poiN", "olN", "poiP", "olP", "poi", "ol", "poiNpi", "olNpi", "poiPpi", "olPpi", "poifullpi", "olfullpi", "poiNka", "olNka", "poiPka", "olPka", "poifullka", "olfullka", "poiNpr", "olNpr", "poiPpr", "olPpr", "poifullpr", "olfullpr"}, {-0.8, 0.4, -0.8, -0.8, -0.8, 0.4, 0.4, -0.8, -0.8, -0.8, -0.8, 0.4, 0.4, -0.8, -0.8, -0.8, -0.8, 0.4, 0.4, -0.8, -0.8, -0.8, -0.8, 0.4, 0.4, -0.8, -0.8}, {-0.4, 0.8, 0.8, -0.4, -0.4, 0.8, 0.8, 0.8, 0.8, -0.4, -0.4, 0.8, 0.8, 0.8, 0.8, -0.4, -0.4, 0.8, 0.8, 0.8, 0.8, -0.4, -0.4, 0.8, 0.8, 0.8, 0.8}, {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 128, 256, 128, 256, 128, 256, 2, 16, 2, 16, 2, 16, 4, 32, 4, 32, 4, 32, 8, 64, 8, 64, 8, 64}}, "Configurations for GFW regions"}; + Configurable cfgCorrConfig{"cfgCorrConfig", {{"full {2 -2}", "full {2 -2}", "full {2 -2}", "full {2 -2}", "refN08 {2} refP08 {-2}", "refN08 {2} refP08 {-2}", "refN08 {2} refP08 {-2}", "refN08 {2} refP08 {-2}", "refP08 {-2} refN08 {2}", "refP08 {-2} refN08 {2}", "refP08 {-2} refN08 {2}", "refP08 {-2} refN08 {2}", "full {2 2 -2 -2}", "full {2 2 -2 -2}", "full {2 2 -2 -2}", "full {2 2 -2 -2}", "poi full | ol {2 -2}", "poifullpi full | olfullpi {2 -2}", "poifullka full | olfullka {2 -2}", "poifullpr full | olfullpr {2 -2}", "poiN refN08 | olN {2} refP08 {-2}", "poiNpi refN08 | olNpi {2} refP08 {-2}", "poiNka refN08 | olNka {2} refP08 {-2}", "poiNpr refN08 | olNpr {2} refP08 {-2}", "poiP refP08 | olP {2} refN08 {-2}", "poiPpi refP08 | olPpi {2} refN08 {-2}", "poiPka refP08 | olPka {2} refN08 {-2}", "poiPpr refP08 | olPpr {2} refN08 {-2}", "poi full | ol {2 2 -2 -2}", "poifullpi full | olfullpi {2 2 -2 -2}", "poifullka full | olfullka {2 2 -2 -2}", "poifullpr full | olfullpr {2 2 -2 -2}", "refN08 {2 2} refP08 {-2 -2}", "refP08 {-2 -2} refN08 {2 2}", "poiNka refN08 | olNka {2 2} refP08 {-2 -2}", "poiPka refP08 | olPka {2 2} refN08 {-2 -2}"}, {"ChFull22", "PiFull22", "KaFull22", "PrFull22", "Ch08FGap22", "Pi08FGap22", "Ka08FGap22", "Pr08FGap22", "Ch08BGap22", "Pi08BGap22", "Ka08BGap22", "Pr08BGap22", "ChFull24", "PiFull24", "KaFull24", "PrFull24", "ChFull22", "PiFull22", "KaFull22", "PrFull22", "Ch08FGap22", "Pi08FGap22", "Ka08FGap22", "Pr08FGap22", "Ch08BGap22", "Pi08BGap22", "Ka08BGap22", "Pr08BGap22", "ChFull24", "PiFull24", "KaFull24", "PrFull24", "Ka08FGap24", "Ka08BGap24", "Ka08FGap24", "Ka08BGap24"}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, "Configurations for each correlation to calculate"}; ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for histograms"}; ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; - ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; + ConfigurableAxis axisEta{"axisEta", {16, -0.8, 0.8}, "eta axis for histograms"}; ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.20, 1.40, 1.60, 1.80, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00, 3.50, 4.00, 5.00, 6.00, 8.00, 10.00}, "pt axis for histograms"}; ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "centrality axis for histograms"}; ConfigurableAxis axisNsigmaTPC{"axisNsigmaTPC", {80, -5, 5}, "nsigmaTPC axis"}; ConfigurableAxis axisNsigmaTOF{"axisNsigmaTOF", {80, -5, 5}, "nsigmaTOF axis"}; + ConfigurableAxis axisNsigmaITS{"axisNsigmaITS", {80, -5, 5}, "nsigmaITS axis"}; ConfigurableAxis axisParticles{"axisParticles", {3, 0, 3}, "axis for different hadrons"}; - ConfigurableAxis axisPhiMass{"axisPhiMass", {10000, 0, 2}, "axis for invariant mass distibution for Phi"}; ConfigurableAxis axisTPCsignal{"axisTPCsignal", {10000, 0, 1000}, "axis for TPC signal"}; + ConfigurableAxis axisTOFbeta{"axisTOFbeta", {200, 0, 2}, "axis for TOF beta"}; - Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; - Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtPOIMin) && (aod::track::pt < cfgCutPtPOIMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); + std::vector tofNsigmaCut; + std::vector itsNsigmaCut; + std::vector tpcNsigmaCut; + std::vector eventCuts; - using AodCollisions = soa::Filtered>; - // using AodTracks = soa::Filtered>; - using AodTracks = soa::Filtered>; + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter trackFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtPOIMin) && (aod::track::pt < cfgCutPtPOIMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); - SliceCache cache; - Partition posTracks = aod::track::signed1Pt > 0.0f; - Partition negTracks = aod::track::signed1Pt < 0.0f; + using AodCollisions = soa::Filtered>; + using AodTracksWithoutBayes = soa::Filtered>; OutputObj fFC{FlowContainer("FlowContainer")}; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -104,92 +149,261 @@ struct FlowPbpbPikp { TAxis* fPtAxis; TRandom3* fRndm = new TRandom3(0); + std::map>> th3sList; + enum OutputSpecies { + hRef = 0, + hCharge, + hPion, + hKaon, + hProton, + kCount_OutputSpecies + }; + + enum EventCutTypes { + kFilteredEvents = 0, + kAfterSel8, + kUseNoTimeFrameBorder, + kUseNoITSROFrameBorder, + kUseNoSameBunchPileup, + kUseGoodZvtxFT0vsPV, + kUseNoCollInTimeRangeStandard, + kUseGoodITSLayersAll, + kUseNoCollInRofStandard, + kUseNoHighMultCollInPrevRof, + kUseOccupancy, + kUseMultCorrCut, + kUseT0AV0ACut, + kUseVertexITSTPC, + kUseTVXinTRD + }; + + enum TrackCutTypes { + kFilteredTracks = 0, + kUseGlobalTracks, + kUsePvContributor, + kItsClustersCut, + kHasTpcSignal, + kTpcClustersCut, + kTpcCrossedRowsCut, + kNumPions, + kNumKaons, + kNumProtons + }; + + int lastRunNumer = -1; + std::vector runNumbers; + std::vector mAcceptance; + bool correctionsLoaded = false; + + // Local track density correction - Copy from flowTask.cxx + std::vector funcEff; + TH1D* hFindPtBin; + TF1* funcV2; + TF1* funcV3; + TF1* funcV4; + + // Additional Event selection cuts - Copy from flowGenericFramework.cxx + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fMultMultPVCut = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + void init(InitContext const&) { + eventCuts = cfgUseEventCuts; + ccdb->setURL(ccdbUrl.value); ccdb->setCaching(true); ccdb->setCreatedNotAfter(noLaterThan.value); - histos.add("hPhi", "", {HistType::kTH1D, {axisPhi}}); - histos.add("hEta", "", {HistType::kTH1D, {axisEta}}); + LOGF(info, "flowGenericFramework::init()"); + regions.SetNames(cfgRegions->GetNames()); + regions.SetEtaMin(cfgRegions->GetEtaMin()); + regions.SetEtaMax(cfgRegions->GetEtaMax()); + regions.SetpTDifs(cfgRegions->GetpTDifs()); + regions.SetBitmasks(cfgRegions->GetBitmasks()); + configs.SetCorrs(cfgCorrConfig->GetCorrs()); + configs.SetHeads(cfgCorrConfig->GetHeads()); + configs.SetpTDifs(cfgCorrConfig->GetpTDifs()); + configs.SetpTCorrMasks(cfgCorrConfig->GetpTCorrMasks()); + regions.Print(); + configs.Print(); + histos.add("hVtxZ", "", {HistType::kTH1D, {axisVertex}}); histos.add("hMult", "", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); histos.add("hCent", "", {HistType::kTH1D, {{90, 0, 90}}}); + histos.add("hPhi", "", {HistType::kTH1D, {axisPhi}}); + histos.add("hPhiWeighted", "", {HistType::kTH1D, {axisPhi}}); + histos.add("hEta", "", {HistType::kTH1D, {axisEta}}); histos.add("hPt", "", {HistType::kTH1D, {axisPt}}); - histos.add("hPhiMass", "", {HistType::kTH1D, {axisPhiMass}}); - histos.add("c22_gap08", "", {HistType::kTProfile, {axisMultiplicity}}); - histos.add("c22_gap08_pi", "", {HistType::kTProfile, {axisMultiplicity}}); - histos.add("c22_gap08_ka", "", {HistType::kTProfile, {axisMultiplicity}}); - histos.add("c22_gap08_pr", "", {HistType::kTProfile, {axisMultiplicity}}); - histos.add("c24_full", "", {HistType::kTProfile, {axisMultiplicity}}); - histos.add("KplusTPC", "", {HistType::kTH2D, {{axisPt, axisTPCsignal}}}); - histos.add("KminusTPC", "", {HistType::kTH2D, {{axisPt, axisTPCsignal}}}); - histos.add("TofTpcNsigma", "", {HistType::kTHnSparseD, {{axisParticles, axisNsigmaTPC, axisNsigmaTOF, axisPt}}}); + histos.add("c22_full_ch", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_full_pi", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_full_ka", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_full_pr", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_gap08F_ch", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_gap08F_pi", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_gap08F_ka", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_gap08F_pr", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_gap08B_ch", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_gap08B_pi", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_gap08B_ka", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c22_gap08B_pr", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c24_full_ch", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c24_full_pi", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c24_full_ka", "", {HistType::kTProfile, {axisMultiplicity}}); + histos.add("c24_full_pr", "", {HistType::kTProfile, {axisMultiplicity}}); + + histos.add("TpcdEdx", "", {HistType::kTH2D, {axisPt, axisTPCsignal}}); + histos.add("TofBeta", "", {HistType::kTH2D, {axisPt, axisTOFbeta}}); + + histos.add("TofTpcNsigma_before", "", {HistType::kTHnSparseD, {{axisParticles, axisNsigmaTPC, axisNsigmaTOF, axisPt}}}); + if (!cfgUseItsPID) + histos.add("TofTpcNsigma_after", "", {HistType::kTHnSparseD, {{axisParticles, axisNsigmaTPC, axisNsigmaTOF, axisPt}}}); + + histos.add("TofItsNsigma_before", "", {HistType::kTHnSparseD, {{axisParticles, axisNsigmaITS, axisNsigmaTOF, axisPt}}}); + if (cfgUseItsPID) + histos.add("TofItsNsigma_after", "", {HistType::kTHnSparseD, {{axisParticles, axisNsigmaITS, axisNsigmaTOF, axisPt}}}); + histos.add("partCount", "", {HistType::kTHnSparseD, {{axisParticles, axisMultiplicity, axisPt}}}); + histos.add("hEventCount", "Number of Events;; Count", {HistType::kTH1D, {{15, -0.5, 14.5}}}); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kFilteredEvents + 1, "Filtered event"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kAfterSel8 + 1, "After sel8"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoTimeFrameBorder + 1, "kNoTimeFrameBorder"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoITSROFrameBorder + 1, "kNoITSROFrameBorder"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoSameBunchPileup + 1, "kNoSameBunchPileup"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoCollInRofStandard + 1, "kNoCollInTimeRangeStandard"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseGoodITSLayersAll + 1, "kIsGoodITSLayersAll"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoCollInRofStandard + 1, "kNoCollInRofStandard"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoHighMultCollInPrevRof + 1, "kNoHighMultCollInPrevRof"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseOccupancy + 1, "Occupancy Cut"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseMultCorrCut + 1, "Multiplicity correlation Cut"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseT0AV0ACut + 1, "T0AV0A cut"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseVertexITSTPC + 1, "kIsVertexITSTPC"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseTVXinTRD + 1, "kTVXinTRD"); + + histos.add("hTrackCount", "Number of Tracks;; Count", {HistType::kTH1D, {{10, -0.5, 9.5}}}); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kFilteredTracks + 1, "Filtered track"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kUseGlobalTracks + 1, "Global tracks"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kUsePvContributor + 1, "PV contributor"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kItsClustersCut + 1, "ITS clusters"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kHasTpcSignal + 1, "TPC signal"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kTpcClustersCut + 1, "TPC clusters"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kTpcCrossedRowsCut + 1, "TPC crossed rows"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kNumPions + 1, "Pions"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kNumKaons + 1, "Kaons"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kNumProtons + 1, "Protons"); + + if (cfgOutputNUAWeights && !cfgOutputRunByRun) { + histos.add("NUA/hPhiEtaVtxz_ref", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("NUA/hPhiEtaVtxz_ch", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("NUA/hPhiEtaVtxz_pi", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("NUA/hPhiEtaVtxz_ka", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("NUA/hPhiEtaVtxz_pr", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + + histos.add("NUA/hPhiPtCent_ref", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); + histos.add("NUA/hPhiPtCent_ch", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); + histos.add("NUA/hPhiPtCent_pi", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); + histos.add("NUA/hPhiPtCent_ka", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); + histos.add("NUA/hPhiPtCent_pr", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); + + histos.add("NUA/hPhiEtaPt_ref", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); + histos.add("NUA/hPhiEtaPt_ch", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); + histos.add("NUA/hPhiEtaPt_pi", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); + histos.add("NUA/hPhiEtaPt_ka", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); + histos.add("NUA/hPhiEtaPt_pr", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); + } + + if (!cfgAcceptance.value.empty()) { + if (cfgUseWeightPhiEtaVtxz) { + histos.add("PhiCorrected/hPhiEtaVtxz_pi_corrd", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("PhiCorrected/hPhiEtaVtxz_ka_corrd", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("PhiCorrected/hPhiEtaVtxz_pr_corrd", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + } + if (cfgUseWeightPhiPtCent) { + histos.add("PhiCorrected/hPhiPtCent_pi_corrd", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); + histos.add("PhiCorrected/hPhiPtCent_ka_corrd", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); + histos.add("PhiCorrected/hPhiPtCent_pr_corrd", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); + } + if (cfgUseWeightPhiEtaPt) { + histos.add("PhiCorrected/hPhiEtaPt_pi_corrd", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); + histos.add("PhiCorrected/hPhiEtaPt_ka_corrd", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); + histos.add("PhiCorrected/hPhiEtaPt_pr_corrd", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); + } + } + o2::framework::AxisSpec axis = axisPt; int nPtBins = axis.binEdges.size() - 1; double* ptBins = &(axis.binEdges)[0]; fPtAxis = new TAxis(nPtBins, ptBins); + // Defining the regions + for (auto i(0); i < regions.GetSize(); ++i) { + fGFW->AddRegion(regions.GetNames()[i], regions.GetEtaMin()[i], regions.GetEtaMax()[i], (regions.GetpTDifs()[i]) ? nPtBins + 1 : 1, regions.GetBitmasks()[i]); + } + + // Defining the correlators + for (auto i = 0; i < configs.GetSize(); ++i) { + corrconfigs.push_back(fGFW->GetCorrelatorConfig(configs.GetCorrs()[i], configs.GetHeads()[i], configs.GetpTDifs()[i])); + } + if (corrconfigs.empty()) + LOGF(error, "Configuration contains vectors of different size - check the GFWCorrConfig configurable"); + fGFW->CreateRegions(); + + // Defining the flow container TObjArray* oba = new TObjArray(); - oba->Add(new TNamed("Ch08Gap22", "Ch08Gap22")); - for (int i = 0; i < fPtAxis->GetNbins(); i++) - oba->Add(new TNamed(Form("Ch08Gap22_pt_%i", i + 1), "Ch08Gap22_pTDiff")); - oba->Add(new TNamed("Pi08Gap22", "Pi08Gap22")); - for (int i = 0; i < fPtAxis->GetNbins(); i++) - oba->Add(new TNamed(Form("Pi08Gap22_pt_%i", i + 1), "Pi08Gap22_pTDiff")); - oba->Add(new TNamed("Ka08Gap22", "Ka08Gap22")); - for (int i = 0; i < fPtAxis->GetNbins(); i++) - oba->Add(new TNamed(Form("Ka08Gap22_pt_%i", i + 1), "Ka08Gap22_pTDiff")); - oba->Add(new TNamed("Pr08Gap22", "Pr08Gap22")); - for (int i = 0; i < fPtAxis->GetNbins(); i++) - oba->Add(new TNamed(Form("Pr08Gap22_pt_%i", i + 1), "Pr08Gap22_pTDiff")); - oba->Add(new TNamed("ChFull24", "ChFull24")); - for (int i = 0; i < fPtAxis->GetNbins(); i++) - oba->Add(new TNamed(Form("ChFull24_pt_%i", i + 1), "ChFull24_pTDiff")); + addConfigObjectsToObjArray(oba, corrconfigs); fFC->SetName("FlowContainer"); fFC->SetXAxis(fPtAxis); fFC->Initialize(oba, axisMultiplicity, cfgNbootstrap); delete oba; - fGFW->AddRegion("refN08", -0.8, -0.4, 1, 1); - fGFW->AddRegion("refP08", 0.4, 0.8, 1, 1); - fGFW->AddRegion("full", -0.8, 0.8, 1, 512); - fGFW->AddRegion("poi", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 1024); - fGFW->AddRegion("ol", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 2048); - - // charged parts - fGFW->AddRegion("poiN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 128); - fGFW->AddRegion("olN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 256); - - // pion - fGFW->AddRegion("poiNpi", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 2); - fGFW->AddRegion("olNpi", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 16); + if (eventCuts[kUseMultCorrCut]) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - // kaon - fGFW->AddRegion("poiNk", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 4); - fGFW->AddRegion("olNk", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 32); - - // proton - fGFW->AddRegion("poiNpr", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 8); - fGFW->AddRegion("olNpr", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 64); - - corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN08 {2} refP08 {-2}", "Ch08Gap22", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN08 {2} refP08 {-2}", "Pi08Gap22", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN08 {2} refP08 {-2}", "Ka08Gap22", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN08 {2} refP08 {-2}", "Pr08Gap22", kFALSE)); + fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + } + if (eventCuts[kUseT0AV0ACut]) { + fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN refN08 | olN {2} refP08 {-2}", "Ch08Gap22", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiNpi refN08 | olNpi {2} refP08 {-2}", "Pi08Gap22", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiNk refN08 | olNk {2} refP08 {-2}", "Ka08Gap22", kTRUE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiNpr refN08 | olNpr {2} refP08 {-2}", "Pr08Gap22", kTRUE)); + if (cfgTrackDensityCorrUse) { + std::vector pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0}; + hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]); + funcEff.resize(pTEffBins.size() - 1); + // LHC24g3 Eff + std::vector f1p0 = cfgTrackDensityP0; + std::vector f1p1 = cfgTrackDensityP1; + for (uint ifunc = 0; ifunc < pTEffBins.size() - 1; ifunc++) { + funcEff[ifunc] = new TF1(Form("funcEff%i", ifunc), "[0]+[1]*x", 0, 3000); + funcEff[ifunc]->SetParameters(f1p0[ifunc], f1p1[ifunc]); + } + funcV2 = new TF1("funcV2", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV2->SetParameters(0.0186111, 0.00351907, -4.38264e-05, 1.35383e-07, -3.96266e-10); + funcV3 = new TF1("funcV3", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV3->SetParameters(0.0174056, 0.000703329, -1.45044e-05, 1.91991e-07, -1.62137e-09); + funcV4 = new TF1("funcV4", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV4->SetParameters(0.008845, 0.000259668, -3.24435e-06, 4.54837e-08, -6.01825e-10); + } - corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 -2 -2}", "ChFull24", kFALSE)); - corrconfigs.push_back(fGFW->GetCorrelatorConfig("poi full | ol {2 2 -2 -2}", "ChFull24", kTRUE)); - fGFW->CreateRegions(); - } + tofNsigmaCut = cfgTofNsigmaCut; + itsNsigmaCut = cfgItsNsigmaCut; + tpcNsigmaCut = cfgTpcNsigmaCut; + } // End of init() enum Particles { PIONS, @@ -197,101 +411,194 @@ struct FlowPbpbPikp { PROTONS }; + void addConfigObjectsToObjArray(TObjArray* oba, const std::vector& configs) + { + for (auto it = configs.begin(); it != configs.end(); ++it) { + if (it->pTDif) { + std::string suffix = "_ptDiff"; + for (auto i = 0; i < fPtAxis->GetNbins(); ++i) { + std::string index = Form("_pt_%i", i + 1); + oba->Add(new TNamed(it->Head.c_str() + index, it->Head.c_str() + suffix)); + } + } else { + oba->Add(new TNamed(it->Head.c_str(), it->Head.c_str())); + } + } + } + template - bool isFakeKaon(TTrack track) + bool selectionTrack(const TTrack& track) { - const auto pglobal = track.p(); - const auto ptpc = track.tpcInnerParam(); - if (std::abs(pglobal - ptpc) > 0.1) { - return true; + histos.fill(HIST("hTrackCount"), kFilteredTracks); // Filtered tracks + if (cfgUseGlobalTrack && !(track.isGlobalTrack())) { + return 0; } - return false; + if (cfgUseGlobalTrack) + histos.fill(HIST("hTrackCount"), kUseGlobalTracks); // After global track selection + + if (!(track.isPVContributor())) { + return 0; + } + histos.fill(HIST("hTrackCount"), kUsePvContributor); // After PV contributor selection + + if (!(track.itsNCls() > cfgITScluster)) { + return 0; + } + histos.fill(HIST("hTrackCount"), kItsClustersCut); // After ITS cluster selection + + if (!(track.hasTPC())) { + return 0; + } + histos.fill(HIST("hTrackCount"), kHasTpcSignal); // If track has TPC signal + + if (!(track.tpcNClsFound() > cfgTpcCluster)) { + return 0; + } + histos.fill(HIST("hTrackCount"), kTpcClustersCut); // After TPC cluster selection + + if (!(track.tpcNClsCrossedRows() > cfgTpcCrossRows)) { + return 0; + } + histos.fill(HIST("hTrackCount"), kTpcCrossedRowsCut); // After TPC crossed rows selection + return 1; } + template + void fillQA(const TCollision collision, const TTrack track, int pidIndex, double wacc) + { + histos.fill(HIST("partCount"), pidIndex - 1, collision.centFT0C(), track.pt()); + switch (pidIndex) { + case 1: + if (!cfgUseItsPID) + histos.fill(HIST("TofTpcNsigma_after"), pidIndex - 1, track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt()); + if (cfgUseItsPID) + histos.fill(HIST("TofItsNsigma_after"), pidIndex - 1, itsResponse.nSigmaITS(track), track.tofNSigmaPi(), track.pt()); + histos.fill(HIST("hTrackCount"), kNumPions); // Pion count + if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaVtxz) + histos.fill(HIST("PhiCorrected/hPhiEtaVtxz_pi_corrd"), track.phi(), track.eta(), collision.posZ(), wacc); // pion weights + if (!cfgAcceptance.value.empty() && cfgUseWeightPhiPtCent) + histos.fill(HIST("PhiCorrected/hPhiPtCent_pi_corrd"), track.phi(), track.pt(), collision.centFT0C(), wacc); + if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaPt) + histos.fill(HIST("PhiCorrected/hPhiEtaPt_pi_corrd"), track.phi(), track.eta(), track.pt(), wacc); + break; + case 2: + if (!cfgUseItsPID) + histos.fill(HIST("TofTpcNsigma_after"), pidIndex - 1, track.tpcNSigmaKa(), track.tofNSigmaKa(), track.pt()); + if (cfgUseItsPID) + histos.fill(HIST("TofItsNsigma_after"), pidIndex - 1, itsResponse.nSigmaITS(track), track.tofNSigmaKa(), track.pt()); + histos.fill(HIST("hTrackCount"), kNumKaons); // Kaon count + if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaVtxz) + histos.fill(HIST("PhiCorrected/hPhiEtaVtxz_ka_corrd"), track.phi(), track.eta(), collision.posZ(), wacc); // kaon weights + if (!cfgAcceptance.value.empty() && cfgUseWeightPhiPtCent) + histos.fill(HIST("PhiCorrected/hPhiPtCent_ka_corrd"), track.phi(), track.pt(), collision.centFT0C(), wacc); + if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaPt) + histos.fill(HIST("PhiCorrected/hPhiEtaPt_ka_corrd"), track.phi(), track.eta(), track.pt(), wacc); + break; + case 3: + if (!cfgUseItsPID) + histos.fill(HIST("TofTpcNsigma_after"), pidIndex - 1, track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); + if (cfgUseItsPID) + histos.fill(HIST("TofItsNsigma_after"), pidIndex - 1, itsResponse.nSigmaITS(track), track.tofNSigmaPr(), track.pt()); + histos.fill(HIST("hTrackCount"), kNumProtons); // Proton count + if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaVtxz) + histos.fill(HIST("PhiCorrected/hPhiEtaVtxz_pr_corrd"), track.phi(), track.eta(), collision.posZ(), wacc); // proton weights + if (!cfgAcceptance.value.empty() && cfgUseWeightPhiPtCent) + histos.fill(HIST("PhiCorrected/hPhiPtCent_pr_corrd"), track.phi(), track.pt(), collision.centFT0C(), wacc); + if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaPt) + histos.fill(HIST("PhiCorrected/hPhiEtaPt_pr_corrd"), track.phi(), track.eta(), track.pt(), wacc); + break; + } // end of switch + } // end of fillQA + template - int getNsigmaPID(TTrack track) + int getNsigmaPIDTpcTof(TTrack track) { // Computing Nsigma arrays for pion, kaon, and protons std::array nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; std::array nSigmaCombined = {std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi()), std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa()), std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr())}; int pid = -1; - float nsigma = cfgTpcNsigmaCut; + float nsigma = cfgTpcCut; // Choose which nSigma to use std::array nSigmaToUse = (track.pt() > cfgTofPtCut && track.hasTOF()) ? nSigmaCombined : nSigmaTPC; + if (track.pt() > cfgTofPtCut && !track.hasTOF()) + return 0; + const int numSpecies = 3; + int pidCount = 0; // Select particle with the lowest nsigma - for (int i = 0; i < 3; ++i) { + for (int i = 0; i < numSpecies; ++i) { if (std::abs(nSigmaToUse[i]) < nsigma) { + if (pidCount > 0 && cfgUseStrictPID) + return 0; // more than one particle with low nsigma + + pidCount++; pid = i; - nsigma = std::abs(nSigmaToUse[i]); + if (!cfgUseStrictPID) + nsigma = std::abs(nSigmaToUse[i]); } } return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton } - /*template - std::pair getBayesID(TTrack track) - { - std::array bayesprobs = {static_cast(track.bayesPi()), static_cast(track.bayesKa()), static_cast(track.bayesPr())}; - int bayesid = -1; - int prob = 0; - - for (int i = 0; i < 3; ++i) { - if (bayesprobs[i] > prob && bayesprobs[i] > 80) { - bayesid = i; - prob = bayesprobs[i]; - } - } - return std::make_pair(bayesid, prob); - } - template - int getBayesPIDIndex(TTrack track) + int getNsigmaPIDAssymmetric(TTrack track) { - int maxProb[3] = {80, 80, 80}; - int pidID = -1; - std::pair idprob = getBayesID(track); - if (idprob.first == PIONS || idprob.first == KAONS || idprob.first == PROTONS) { // 0 = pion, 1 = kaon, 2 = proton - pidID = idprob.first; - float nsigmaTPC[3] = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; - if (idprob.second > maxProb[pidID]) { - if (std::fabs(nsigmaTPC[pidID]) > 3) - return 0; - return pidID + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton - } else { - return 0; - } - } - return 0; - }*/ + // Computing Nsigma arrays for pion, kaon, and protons + std::array nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; + std::array nSigmaTOF = {track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()}; + std::array nSigmaITS = {itsResponse.nSigmaITS(track), itsResponse.nSigmaITS(track), itsResponse.nSigmaITS(track)}; + int pid = -1; - template - void resurrectParticle(TTrack trackplus, TTrack trackminus, vector plusdaug, vector minusdaug, vector mom, double plusmass, double minusmass, const ConstStr& hist) - { - for (auto const& [partplus, partminus] : o2::soa::combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(trackplus, trackminus))) { - if (getNsigmaPID(partplus) != 2) - continue; - if (getNsigmaPID(partminus) != 2) - continue; + std::array nSigmaToUse = cfgUseItsPID ? nSigmaITS : nSigmaTPC; // Choose which nSigma to use: TPC or ITS + std::vector detectorNsigmaCut = cfgUseItsPID ? itsNsigmaCut : tpcNsigmaCut; // Choose which nSigma to use: TPC or ITS + + bool isPion, isKaon, isProton; + bool isDetectedPion = nSigmaToUse[0] < detectorNsigmaCut[0] && nSigmaToUse[0] > detectorNsigmaCut[0 + 3]; + bool isDetectedKaon = nSigmaToUse[1] < detectorNsigmaCut[1] && nSigmaToUse[1] > detectorNsigmaCut[1 + 3]; + bool isDetectedProton = nSigmaToUse[2] < detectorNsigmaCut[2] && nSigmaToUse[2] > detectorNsigmaCut[2 + 3]; + + bool isTofPion = nSigmaTOF[0] < tofNsigmaCut[0] && nSigmaTOF[0] > tofNsigmaCut[0 + 3]; + bool isTofKaon = nSigmaTOF[1] < tofNsigmaCut[1] && nSigmaTOF[1] > tofNsigmaCut[1 + 3]; + bool isTofProton = nSigmaTOF[2] < tofNsigmaCut[2] && nSigmaTOF[2] > tofNsigmaCut[2 + 3]; + + if (track.pt() > cfgTofPtCut && !track.hasTOF()) { + return 0; + } else if (track.pt() > cfgTofPtCut && track.hasTOF()) { + isPion = isTofPion && isDetectedPion; + isKaon = isTofKaon && isDetectedKaon; + isProton = isTofProton && isDetectedProton; + } else { + isPion = isDetectedPion; + isKaon = isDetectedKaon; + isProton = isDetectedProton; + } - plusdaug = ROOT::Math::PxPyPzMVector(partplus.px(), partplus.py(), partplus.pz(), plusmass); - minusdaug = ROOT::Math::PxPyPzMVector(partminus.px(), partminus.py(), partminus.pz(), minusmass); - mom = plusdaug + minusdaug; + if ((isPion && isKaon) || (isPion && isProton) || (isKaon && isProton)) { + return 0; // more than one particle satisfy the criteria + } - histos.fill(hist, mom.M()); + if (isPion) { + pid = PIONS; + } else if (isKaon) { + pid = KAONS; + } else if (isProton) { + pid = PROTONS; + } else { + return 0; // no particle satisfies the criteria } - return; + + return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton } template void fillProfile(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const double& cent) { double dnx, val; - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; if (!corrconf.pTDif) { + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; if (std::fabs(val) < 1) histos.fill(tarName, cent, val, dnx); @@ -311,11 +618,11 @@ struct FlowPbpbPikp { void fillFC(const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) { double dnx, val; - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) { - return; - } if (!corrconf.pTDif) { + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) { + return; + } val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; if (std::fabs(val) < 1) { fFC->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); @@ -333,104 +640,389 @@ struct FlowPbpbPikp { return; } - ROOT::Math::PxPyPzMVector Phimom, kplusdaug, kminusdaug; - double massKplus = o2::constants::physics::MassKPlus; - double massKminus = o2::constants::physics::MassKMinus; + void createRunByRunHistos(int runNumber) + { + if (cfgOutputNUAWeights) { + std::vector> tH3s(kCount_OutputSpecies); + tH3s[hRef] = histos.add(Form("NUA/%d/hPhiEtaVtxz_ref", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + tH3s[hCharge] = histos.add(Form("NUA/%d/hPhiEtaVtxz_ch", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + tH3s[hPion] = histos.add(Form("NUA/%d/hPhiEtaVtxz_pi", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + tH3s[hKaon] = histos.add(Form("NUA/%d/hPhiEtaVtxz_ka", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + tH3s[hProton] = histos.add(Form("NUA/%d/hPhiEtaVtxz_pr", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + th3sList.insert(std::make_pair(runNumber, tH3s)); + } + } + + void loadCorrections(aod::BCsWithTimestamps::iterator const& bc) + { + if (correctionsLoaded) + return; + if (!cfgAcceptance.value.empty()) { + uint64_t timestamp = bc.timestamp(); + mAcceptance.clear(); + mAcceptance.resize(kCount_OutputSpecies); + mAcceptance[hRef] = ccdb->getForTimeStamp(cfgAcceptance.value + "_ref", timestamp); + if (mAcceptance[hRef]) + LOGF(info, "Loaded acceptance weights from %s_ref (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hRef]); + else + LOGF(fatal, "Could not load acceptance weights from %s_ref (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hRef]); + + mAcceptance[hCharge] = ccdb->getForTimeStamp(cfgAcceptance.value + "_ch", timestamp); + if (mAcceptance[hCharge]) + LOGF(info, "Loaded acceptance weights from %s_ch (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hCharge]); + else + LOGF(fatal, "Could not load acceptance weights from %s_ch (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hCharge]); + + mAcceptance[hPion] = ccdb->getForTimeStamp(cfgAcceptance.value + "_pi", timestamp); + if (mAcceptance[hPion]) + LOGF(info, "Loaded acceptance weights from %s_pi (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hPion]); + else + LOGF(fatal, "Could not load acceptance weights from %s_pi (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hPion]); + + mAcceptance[hKaon] = ccdb->getForTimeStamp(cfgAcceptance.value + "_ka", timestamp); + if (mAcceptance[hKaon]) + LOGF(info, "Loaded acceptance weights from %s_ka (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hKaon]); + else + LOGF(fatal, "Could not load acceptance weights from %s_ka (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hKaon]); + + mAcceptance[hProton] = ccdb->getForTimeStamp(cfgAcceptance.value + "_pr", timestamp); + if (mAcceptance[hProton]) + LOGF(info, "Loaded acceptance weights from %s_pr (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hProton]); + else + LOGF(fatal, "Could not load acceptance weights from %s_pr (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hProton]); + } + + correctionsLoaded = true; + } + + template + double getAcceptance(TTrack track, const TCollision collision, int index) + { // 0 = ref, 1 = ch, 2 = pi, 3 = ka, 4 = pr + if (index < 0 || index >= kCount_OutputSpecies) { + return 1; + } + double wacc = 1; + double cent = collision.centFT0C(); + double vtxz = collision.posZ(); + + if ((cfgUseWeightPhiEtaVtxz && cfgUseWeightPhiPtCent) || (cfgUseWeightPhiEtaPt && cfgUseWeightPhiPtCent) || (cfgUseWeightPhiEtaVtxz && cfgUseWeightPhiEtaPt)) { + LOGF(fatal, "Only one of the three weight options can be used at a time"); + } + + if (!mAcceptance.empty() && correctionsLoaded) { + if (!mAcceptance[index]) { + LOGF(fatal, "Acceptance weights not loaded for index %d", index); + return 1; + } + if (cfgUseWeightPhiEtaVtxz) + wacc = mAcceptance[index]->getNUA(track.phi(), track.eta(), vtxz); + if (cfgUseWeightPhiPtCent) + wacc = mAcceptance[index]->getNUA(track.phi(), track.pt(), cent); + if (cfgUseWeightPhiEtaPt) + wacc = mAcceptance[index]->getNUA(track.phi(), track.eta(), track.pt()); + } + return wacc; + } + + template + void fillWeights(const TTrack track, const TCollision collision, const int& pid_index, const int& run) + { + double cent = collision.centFT0C(); + double vtxz = collision.posZ(); + double pt = track.pt(); + bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtMin < pt) && (pt < cfgCutPtMax); // within RF pT range + + if (cfgOutputRunByRun) { + if (withinPtRef && !pid_index) + th3sList[run][hRef]->Fill(track.phi(), track.eta(), vtxz); // pt-subset of charged particles for ref flow + if (withinPtPOI) + th3sList[run][hCharge + pid_index]->Fill(track.phi(), track.eta(), vtxz); // charged and id'ed particle weights + } else { + if (withinPtRef && !pid_index) { + histos.fill(HIST("NUA/hPhiEtaVtxz_ref"), track.phi(), track.eta(), vtxz); // pt-subset of charged particles for ref flow + histos.fill(HIST("NUA/hPhiPtCent_ref"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_ref"), track.phi(), track.eta(), track.pt()); + } + + if (withinPtPOI) { + switch (pid_index) { + case 0: + histos.fill(HIST("NUA/hPhiEtaVtxz_ch"), track.phi(), track.eta(), vtxz); // charged particle weights + histos.fill(HIST("NUA/hPhiPtCent_ch"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_ch"), track.phi(), track.eta(), track.pt()); + break; + case 1: + histos.fill(HIST("NUA/hPhiEtaVtxz_pi"), track.phi(), track.eta(), vtxz); // pion weights + histos.fill(HIST("NUA/hPhiPtCent_pi"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_pi"), track.phi(), track.eta(), track.pt()); + break; + case 2: + histos.fill(HIST("NUA/hPhiEtaVtxz_ka"), track.phi(), track.eta(), vtxz); // kaon weights + histos.fill(HIST("NUA/hPhiPtCent_ka"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_ka"), track.phi(), track.eta(), track.pt()); + break; + case 3: + histos.fill(HIST("NUA/hPhiEtaVtxz_pr"), track.phi(), track.eta(), vtxz); // proton weights + histos.fill(HIST("NUA/hPhiPtCent_pr"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_pr"), track.phi(), track.eta(), track.pt()); + break; + } + } + } + } - void process(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracks const& tracks) + template + bool selectionEvent(TCollision collision, const int mult, const float cent) + { + histos.fill(HIST("hEventCount"), kFilteredEvents); + if (!collision.sel8()) { + return 0; + } + histos.fill(HIST("hEventCount"), kAfterSel8); + + if (eventCuts[kUseNoTimeFrameBorder] && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return 0; + } + if (eventCuts[kUseNoTimeFrameBorder]) + histos.fill(HIST("hEventCount"), kUseNoTimeFrameBorder); + + if (eventCuts[kUseNoITSROFrameBorder] && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return 0; + } + if (eventCuts[kUseNoITSROFrameBorder]) + histos.fill(HIST("hEventCount"), kUseNoITSROFrameBorder); + + if (eventCuts[kUseNoSameBunchPileup] && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return 0; + } + if (eventCuts[kUseNoSameBunchPileup]) + histos.fill(HIST("hEventCount"), kUseNoSameBunchPileup); + + if (eventCuts[kUseGoodZvtxFT0vsPV] && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return 0; + } + if (eventCuts[kUseGoodZvtxFT0vsPV]) + histos.fill(HIST("hEventCount"), kUseGoodZvtxFT0vsPV); + + if (eventCuts[kUseNoCollInTimeRangeStandard] && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return 0; + } + if (eventCuts[kUseNoCollInTimeRangeStandard]) + histos.fill(HIST("hEventCount"), kUseNoCollInTimeRangeStandard); + + if (eventCuts[kUseGoodITSLayersAll] && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return 0; + } + if (eventCuts[kUseGoodITSLayersAll]) + histos.fill(HIST("hEventCount"), kUseGoodITSLayersAll); + + if (eventCuts[kUseNoCollInRofStandard] && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return 0; + } + if (eventCuts[kUseNoCollInRofStandard]) + histos.fill(HIST("hEventCount"), kUseNoCollInRofStandard); + + if (eventCuts[kUseNoHighMultCollInPrevRof] && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return 0; + } + if (eventCuts[kUseNoHighMultCollInPrevRof]) + histos.fill(HIST("hEventCount"), kUseNoHighMultCollInPrevRof); + + auto multNTracksPV = collision.multNTracksPV(); + auto occupancy = collision.trackOccupancyInTimeRange(); + + if (eventCuts[kUseOccupancy] && (occupancy < cfgCutOccupancyMin || occupancy > cfgCutOccupancyMax)) { + return 0; + } + if (eventCuts[kUseOccupancy]) + histos.fill(HIST("hEventCount"), kUseOccupancy); + + if (eventCuts[kUseMultCorrCut]) { + if (multNTracksPV < fMultPVCutLow->Eval(cent)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(cent)) + return 0; + if (mult < fMultCutLow->Eval(cent)) + return 0; + if (mult > fMultCutHigh->Eval(cent)) + return 0; + } + if (eventCuts[kUseMultCorrCut]) + histos.fill(HIST("hEventCount"), kUseMultCorrCut); + + // V0A T0A 5 sigma cut + if (eventCuts[kUseT0AV0ACut] && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > cfgV0AT0Acut * fT0AV0ASigma->Eval(collision.multFT0A()))) + return 0; + if (eventCuts[kUseT0AV0ACut]) + histos.fill(HIST("hEventCount"), kUseT0AV0ACut); + + if (eventCuts[kUseVertexITSTPC] && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) + return 0; + if (eventCuts[kUseVertexITSTPC]) + histos.fill(HIST("hEventCount"), kUseVertexITSTPC); + + if (eventCuts[kUseTVXinTRD] && collision.alias_bit(kTVXinTRD)) { + return 0; + } + if (eventCuts[kUseTVXinTRD]) + histos.fill(HIST("hEventCount"), kUseTVXinTRD); + + return 1; + } + + void process(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracksWithoutBayes const& tracks) { int nTot = tracks.size(); if (nTot < 1) return; - if (!collision.sel8()) - return; - float lRandom = fRndm->Rndm(); + float lRandom = fRndm->Rndm(); float vtxz = collision.posZ(); + const auto cent = collision.centFT0C(); + + if (!selectionEvent(collision, nTot, cent)) + return; + + auto bc = collision.bc_as(); + int runNumber = bc.runNumber(); + if (cfgOutputRunByRun && runNumber != lastRunNumer) { + lastRunNumer = runNumber; + if (std::find(runNumbers.begin(), runNumbers.end(), runNumber) == runNumbers.end()) { + // if run number is not in the preconfigured list, create new output histograms for this run + createRunByRunHistos(runNumber); + runNumbers.push_back(runNumber); + } + } + histos.fill(HIST("hVtxZ"), vtxz); histos.fill(HIST("hMult"), nTot); - histos.fill(HIST("hCent"), collision.centFT0C()); + histos.fill(HIST("hCent"), cent); fGFW->Clear(); - const auto cent = collision.centFT0C(); - auto posSlicedTracks = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto negSlicedTracks = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - - float weff = 1, wacc = 1; + float weff = 1; int pidIndex; + loadCorrections(bc); // load corrections for the each event + + // Track loop for calculating the Qn angles + double psi2Est = 0, psi3Est = 0, psi4Est = 0; + float wEPeff = 1; + double v2 = 0, v3 = 0, v4 = 0; + // be cautious, this only works for Pb-Pb + // esimate the Qn angles and vn for this event + if (cfgTrackDensityCorrUse) { + double q2x = 0, q2y = 0; + double q3x = 0, q3y = 0; + double q4x = 0, q4y = 0; + for (const auto& track : tracks) { + bool withinPtRef = (cfgCutPtMin < track.pt()) && (track.pt() < cfgCutPtMax); // within RF pT range + if (withinPtRef) { + q2x += std::cos(2 * track.phi()); + q2y += std::sin(2 * track.phi()); + q3x += std::cos(3 * track.phi()); + q3y += std::sin(3 * track.phi()); + q4x += std::cos(4 * track.phi()); + q4y += std::sin(4 * track.phi()); + } + } + psi2Est = std::atan2(q2y, q2x) / 2.; + psi3Est = std::atan2(q3y, q3x) / 3.; + psi4Est = std::atan2(q4y, q4x) / 4.; - // resurrectParticle(posSlicedTracks, negSlicedTracks, kplusdaug, kminusdaug, Phimom, massKplus, massKminus, HIST("hPhiMass")); + v2 = funcV2->Eval(cent); + v3 = funcV3->Eval(cent); + v4 = funcV4->Eval(cent); + } - for (auto const& trackA : posSlicedTracks) { - if (getNsigmaPID(trackA) != 2) - continue; - if (isFakeKaon(trackA)) + // Actual track loop + for (auto const& track : tracks) { + if (!selectionTrack(track)) continue; - auto trackAID = trackA.globalIndex(); - - for (auto const& trackB : negSlicedTracks) { - auto trackBID = trackB.globalIndex(); - if (getNsigmaPID(trackB) != 2) - continue; - if (isFakeKaon(trackB)) - continue; - if (trackAID == trackBID) - continue; - histos.fill(HIST("KplusTPC"), trackA.pt(), trackA.tpcSignal()); - histos.fill(HIST("KminusTPC"), trackB.pt(), trackB.tpcSignal()); - - kplusdaug = ROOT::Math::PxPyPzMVector(trackA.px(), trackA.py(), trackA.pz(), massKplus); - kminusdaug = ROOT::Math::PxPyPzMVector(trackB.px(), trackB.py(), trackB.pz(), massKminus); - Phimom = kplusdaug + kminusdaug; + double pt = track.pt(); + histos.fill(HIST("hPhi"), track.phi()); + histos.fill(HIST("hEta"), track.eta()); + histos.fill(HIST("hPt"), pt); - histos.fill(HIST("hPhiMass"), Phimom.M()); - } - } + histos.fill(HIST("TpcdEdx"), pt, track.tpcSignal()); + histos.fill(HIST("TofBeta"), pt, track.beta()); - for (auto const& track1 : tracks) { - double pt = track1.pt(); - histos.fill(HIST("hPhi"), track1.phi()); - histos.fill(HIST("hEta"), track1.eta()); - histos.fill(HIST("hPt"), pt); + histos.fill(HIST("TofTpcNsigma_before"), PIONS, track.tpcNSigmaPi(), track.tofNSigmaPi(), pt); + histos.fill(HIST("TofTpcNsigma_before"), KAONS, track.tpcNSigmaKa(), track.tofNSigmaKa(), pt); + histos.fill(HIST("TofTpcNsigma_before"), PROTONS, track.tpcNSigmaPr(), track.tofNSigmaPr(), pt); - histos.fill(HIST("TofTpcNsigma"), PIONS, track1.tpcNSigmaPi(), track1.tofNSigmaPi(), pt); - histos.fill(HIST("TofTpcNsigma"), KAONS, track1.tpcNSigmaKa(), track1.tofNSigmaKa(), pt); - histos.fill(HIST("TofTpcNsigma"), PROTONS, track1.tpcNSigmaPr(), track1.tofNSigmaPr(), pt); + histos.fill(HIST("TofItsNsigma_before"), PIONS, itsResponse.nSigmaITS(track), track.tofNSigmaPi(), pt); + histos.fill(HIST("TofItsNsigma_before"), KAONS, itsResponse.nSigmaITS(track), track.tofNSigmaKa(), pt); + histos.fill(HIST("TofItsNsigma_before"), PROTONS, itsResponse.nSigmaITS(track), track.tofNSigmaPr(), pt); bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range bool withinPtRef = (cfgCutPtMin < pt) && (pt < cfgCutPtMax); // within RF pT range - // pidIndex = getBayesPIDIndex(track1); - pidIndex = getNsigmaPID(track1); + pidIndex = cfgUseAsymmetricPID ? getNsigmaPIDAssymmetric(track) : getNsigmaPIDTpcTof(track); + + weff = 1; // Initializing weff for each track + // NUA weights + if (cfgOutputNUAWeights) + fillWeights(track, collision, pidIndex, runNumber); + + if (!withinPtPOI && !withinPtRef) + return; + double waccRef = getAcceptance(track, collision, 0); + double waccPOI = withinPtPOI ? getAcceptance(track, collision, pidIndex + 1) : getAcceptance(track, collision, 0); + if (withinPtRef && withinPtPOI && pidIndex) + waccRef = waccPOI; // if particle is both (then it's overlap), override ref with POI + + // Track density correction + if (cfgTrackDensityCorrUse && withinPtRef) { + double fphi = v2 * std::cos(2 * (track.phi() - psi2Est)) + v3 * std::cos(3 * (track.phi() - psi3Est)) + v4 * std::cos(4 * (track.phi() - psi4Est)); + fphi = (1 + 2 * fphi); + int pTBinForEff = hFindPtBin->FindBin(track.pt()); + if (pTBinForEff >= 1 && pTBinForEff <= hFindPtBin->GetNbinsX()) { + wEPeff = funcEff[pTBinForEff - 1]->Eval(fphi * tracks.size()); + if (wEPeff > 0.) { + wEPeff = 1. / wEPeff; + weff *= wEPeff; + } + } + } // end of track density correction loop + if (withinPtRef) { - fGFW->Fill(track1.eta(), fPtAxis->FindBin(pt) - 1, track1.phi(), wacc * weff, 1); - fGFW->Fill(track1.eta(), 1, track1.phi(), wacc * weff, 512); + histos.fill(HIST("hPhiWeighted"), track.phi(), waccRef); + fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccRef * weff, 1); } if (withinPtPOI) { - fGFW->Fill(track1.eta(), fPtAxis->FindBin(pt) - 1, track1.phi(), wacc * weff, 128); - fGFW->Fill(track1.eta(), fPtAxis->FindBin(pt) - 1, track1.phi(), wacc * weff, 1024); + fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccPOI * weff, 128); } if (withinPtPOI && withinPtRef) { - fGFW->Fill(track1.eta(), fPtAxis->FindBin(pt) - 1, track1.phi(), wacc * weff, 256); - fGFW->Fill(track1.eta(), fPtAxis->FindBin(pt) - 1, track1.phi(), wacc * weff, 2048); + fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccPOI * weff, 256); } if (pidIndex) { - histos.fill(HIST("partCount"), pidIndex - 1, cent, pt); + fillQA(collision, track, pidIndex, waccPOI); if (withinPtPOI) - fGFW->Fill(track1.eta(), fPtAxis->FindBin(pt) - 1, track1.phi(), wacc * weff, 1 << (pidIndex)); + fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccPOI * weff, 1 << (pidIndex)); if (withinPtPOI && withinPtRef) - fGFW->Fill(track1.eta(), fPtAxis->FindBin(pt) - 1, track1.phi(), wacc * weff, 1 << (pidIndex + 3)); + fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccPOI * weff, 1 << (pidIndex + 3)); } - } // track1 loop ends - - // Filling c22 with ROOT TProfile - fillProfile(corrconfigs.at(0), HIST("c22_gap08"), cent); - fillProfile(corrconfigs.at(1), HIST("c22_gap08_pi"), cent); - fillProfile(corrconfigs.at(2), HIST("c22_gap08_ka"), cent); - fillProfile(corrconfigs.at(3), HIST("c22_gap08_pr"), cent); - fillProfile(corrconfigs.at(4), HIST("c24_full"), cent); + } // track loop ends + + // Filling cumulants with ROOT TProfile + fillProfile(corrconfigs.at(0), HIST("c22_full_ch"), cent); + fillProfile(corrconfigs.at(1), HIST("c22_full_pi"), cent); + fillProfile(corrconfigs.at(2), HIST("c22_full_ka"), cent); + fillProfile(corrconfigs.at(3), HIST("c22_full_pr"), cent); + fillProfile(corrconfigs.at(4), HIST("c22_gap08F_ch"), cent); + fillProfile(corrconfigs.at(5), HIST("c22_gap08F_pi"), cent); + fillProfile(corrconfigs.at(6), HIST("c22_gap08F_ka"), cent); + fillProfile(corrconfigs.at(7), HIST("c22_gap08F_pr"), cent); + fillProfile(corrconfigs.at(8), HIST("c22_gap08B_ch"), cent); + fillProfile(corrconfigs.at(9), HIST("c22_gap08B_pi"), cent); + fillProfile(corrconfigs.at(10), HIST("c22_gap08B_ka"), cent); + fillProfile(corrconfigs.at(11), HIST("c22_gap08B_pr"), cent); + fillProfile(corrconfigs.at(12), HIST("c24_full_ch"), cent); + fillProfile(corrconfigs.at(13), HIST("c24_full_pi"), cent); + fillProfile(corrconfigs.at(14), HIST("c24_full_ka"), cent); + fillProfile(corrconfigs.at(15), HIST("c24_full_pr"), cent); for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { fillFC(corrconfigs.at(l_ind), cent, lRandom); diff --git a/PWGCF/Flow/Tasks/flowPidCme.cxx b/PWGCF/Flow/Tasks/flowPidCme.cxx new file mode 100644 index 00000000000..bd91bdc4450 --- /dev/null +++ b/PWGCF/Flow/Tasks/flowPidCme.cxx @@ -0,0 +1,3472 @@ +// 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 ZhengqingWang(zhengqing.wang@cern.ch) +/// \file flowPidCme.cxx +/// \brief task to calculate the pikp cme signal and bacground. +// C++/ROOT includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// o2Physics includes. +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StaticFor.h" + +#include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" + +#include "CommonConstants/PhysicsConstants.h" + +// o2 includes. + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace cme_track_pid_columns +{ +DECLARE_SOA_COLUMN(NPidFlag, nPidFlag, int8_t); // Flag tracks without proper binning as -1, and indicate type of particle [0->(un_Id) 1->(pi_only), 2->(ka_only), 3->(pr_only), 4->(pi_ITSleft), 5->(ka_ITSleft), 6->(pr_ITSleft), 7->(pi_ka), 8->(pi_Pr), 9->(ka_pr), 10->(pi_ka_pr), 11->(pi_ka_ITSleft), 12->(pi_pr_ITSleft), 13->(ka_pr_ITSleft), 14->(pi_ka_pr_ITSleft)] +DECLARE_SOA_COLUMN(AverClusterSizeCosl, averClusterSizeCosl, float); +DECLARE_SOA_COLUMN(NSigmaPiITS, nSigmaPiITS, float); +DECLARE_SOA_COLUMN(NSigmaKaITS, nSigmaKaITS, float); +DECLARE_SOA_COLUMN(NSigmaPrITS, nSigmaPrITS, float); +DECLARE_SOA_COLUMN(NSigmaPiTPC, nSigmaPiTPC, float); +DECLARE_SOA_COLUMN(NSigmaKaTPC, nSigmaKaTPC, float); +DECLARE_SOA_COLUMN(NSigmaPrTPC, nSigmaPrTPC, float); +DECLARE_SOA_COLUMN(NSigmaPiTOF, nSigmaPiTOF, float); +DECLARE_SOA_COLUMN(NSigmaKaTOF, nSigmaKaTOF, float); +DECLARE_SOA_COLUMN(NSigmaPrTOF, nSigmaPrTOF, float); +} // namespace cme_track_pid_columns +DECLARE_SOA_TABLE(Flags, "AOD", "Flags", cme_track_pid_columns::NPidFlag); +DECLARE_SOA_TABLE(PidInfo, "AOD", "PidInfo", cme_track_pid_columns::AverClusterSizeCosl, cme_track_pid_columns::NSigmaPiITS, cme_track_pid_columns::NSigmaKaITS, cme_track_pid_columns::NSigmaPrITS, cme_track_pid_columns::NSigmaPiTPC, cme_track_pid_columns::NSigmaKaTPC, cme_track_pid_columns::NSigmaPrTPC, cme_track_pid_columns::NSigmaPiTOF, cme_track_pid_columns::NSigmaKaTOF, cme_track_pid_columns::NSigmaPrTOF); +} // namespace o2::aod + +namespace pid_flags +{ +constexpr int8_t kUnqualified = -1; +constexpr int8_t kUnPOIHadron = 0; +constexpr int8_t kPion = 1; +constexpr int8_t kKaon = 2; +constexpr int8_t kProton = 3; +constexpr int8_t kPionITSleft = 4; +constexpr int8_t kKaonITSleft = 5; +constexpr int8_t kProtonITSleft = 6; +constexpr int8_t kPionKaon = 7; +constexpr int8_t kPionProton = 8; +constexpr int8_t kKaonProton = 9; +constexpr int8_t kPionKaonProton = 10; +constexpr int8_t kPionKaonITSleft = 11; +constexpr int8_t kPionProtonITSleft = 12; +constexpr int8_t kKaonProtonITSleft = 13; +constexpr int8_t kPionKaonProtonITSleft = 14; +} // namespace pid_flags + +namespace event_selection +{ +constexpr int kFT0AV0ASigma = 5; +} + +namespace fourier_mode +{ +// constexpr int kMode1 = 1; +constexpr int kMode2 = 2; +// constexpr int kMode3 = 3; +} // namespace fourier_mode + +using TracksPID = soa::Join; +using CollisionPID = soa::Join; +struct FillPIDcolums { + Configurable cfgPtMaxforTPCOnlyPID{"cfgPtMaxforTPCOnlyPID", 0.4, "Maxmium track pt for TPC only PID,only when onlyTOF and onlyTOFHIT closed"}; + Configurable cfgMinPtPID{"cfgMinPtPID", 0.15, "Minimum track #P_{t} for PID"}; + Configurable cfgMaxPtPID{"cfgMaxPtPID", 99.9, "Maximum track #P_{t} for PID"}; + Configurable cfgMaxEtaPID{"cfgMaxEtaPID", 0.8, "Maximum track #eta for PID"}; + Configurable cfgMaxTPCChi2NCl{"cfgMaxTPCChi2NCl", 2.5, "Maximum chi2 per cluster TPC for PID if not use costom track cuts"}; + Configurable cfgMaxChi2NClITS{"cfgMaxChi2NClITS", 2.5, "Maximum chi2 per cluster ITS for PID if not use costom track cuts"}; + Configurable cfgMinTPCCls{"cfgMinTPCCls", 70, "Minimum TPC clusters for PID if not use costom track cuts"}; + Configurable cfgMinITSCls{"cfgMinITSCls", 1, "Minimum ITS clusters for PID if not use costom track cuts"}; + Configurable cfgMaxTPCCls{"cfgMaxTPCCls", 999, "Max TPC clusters for PID if not use costom track cuts"}; + Configurable cfgMaxITSCls{"cfgMaxITSCls", 999, "Max ITS clusters for PID if not use costom track cuts"}; + Configurable cfgMaxDCAxy{"cfgMaxDCAxy", 99, "Maxium DCAxy for standard PID tracking"}; + Configurable cfgMaxDCAz{"cfgMaxDCAz", 2, "Maxium DCAz for standard PID tracking"}; + Configurable cfgAveClusSizeCoslMinPi{"cfgAveClusSizeCoslMinPi", 0, "Base line for minmum ITS cluster size x cos(#lambda) for Pions"}; + Configurable cfgAveClusSizeCoslMaxPi{"cfgAveClusSizeCoslMaxPi", 1e9, "Base line for maxmum ITS cluster size x cos(#lambda) for Pions"}; + Configurable cfgAveClusSizeCoslMinKa{"cfgAveClusSizeCoslMinKa", 0, "Base line for minmum ITS cluster size x cos(#lambda) for Kaons"}; + Configurable cfgAveClusSizeCoslMaxKa{"cfgAveClusSizeCoslMaxKa", 1e9, "Base line for maxmum ITS cluster size x cos(#lambda) for Kaons"}; + Configurable cfgAveClusSizeCoslMinPr{"cfgAveClusSizeCoslMinPr", 0, "Base line for minmum ITS cluster size x cos(#lambda) for Protons"}; + Configurable cfgAveClusSizeCoslMaxPr{"cfgAveClusSizeCoslMaxPr", 1e9, "Base line for maxmum ITS cluster size x cos(#lambda) for Protons"}; + + ConfigurableAxis cfgrigidityBins{"cfgrigidityBins", {200, -10.f, 10.f}, "Binning for rigidity #it{p}^{TPC}/#it{z}"}; + ConfigurableAxis cfgdedxBins{"cfgdedxBins", {1000, 0.f, 1000.f}, "Binning for dE/dx"}; + ConfigurableAxis cfgnSigmaBinsTPC{"cfgnSigmaBinsTPC", {200, -5.f, 5.f}, "Binning for n sigma TPC"}; + ConfigurableAxis cfgnSigmaBinsTOF{"cfgnSigmaBinsTOF", {200, -5.f, 5.f}, "Binning for n sigma TOF"}; + ConfigurableAxis cfgnSigmaBinsITS{"cfgnSigmaBinsITS", {200, -5.f, 5.f}, "Binning for n sigma ITS"}; + ConfigurableAxis cfgnSigmaBinsCom{"cfgnSigmaBinsCom", {100, 0.f, 10.f}, "Combination Binning for TPC&TOF nsigma"}; + ConfigurableAxis cfgaxisptPID{"cfgaxisptPID", {120, 0, 12}, "Binning for P_{t} PID"}; + ConfigurableAxis cfgaxispPID{"cfgaxispPID", {50, 0, 5}, "Binning for P PID"}; + ConfigurableAxis cfgaxisAverClusterCosl{"cfgaxisAverClusterCosl", {50, 0, 10}, "Binning for average cluster size x cos(#lambda)"}; + ConfigurableAxis cfgaxisAverClusterCoslnSigma{"cfgaxisAverClusterCoslnSigma", {50, 0, 5}, "Binning for average cluster size x cos(#lambda) vs nSigam"}; + ConfigurableAxis cfgaxisetaPID{"cfgaxisetaPID", {90, -0.9, 0.9}, "Binning for Pt QA"}; + ConfigurableAxis cfgaxisDCAz{"cfgaxisDCAz", {200, -1, 1}, "Binning for DCAz"}; + ConfigurableAxis cfgaxisDCAxy{"cfgaxisDCAxy", {100, -0.5, 0.5}, "Binning for DCAxy"}; + ConfigurableAxis cfgaxisChi2Ncls{"cfgaxisChi2Ncls", {50, 0, 5}, "Binning for Chi2Ncls TPC/ITS"}; + + Configurable cfgQuietMode{"cfgQuietMode", false, "open quiet mode for saving cpu cost and only do some basic QA plots"}; + Configurable cfgRequireGlobalTrack{"cfgRequireGlobalTrack", false, "Require track used must be the global track"}; + Configurable cfgOpenPIDPtSelection{"cfgOpenPIDPtSelection", false, "Cut Pt reign PID particles for use"}; + Configurable cfgOpenPlotnSigmaOrigin{"cfgOpenPlotnSigmaOrigin", true, "Open origin nSigma plots before PID selections"}; + Configurable cfgOpenPlotnSigmaTOFITSPt{"cfgOpenPlotnSigmaTOFITSPt", true, "plot nSigmaTOF vs nSigmaITS vs Pt"}; + Configurable cfgOpenPlotnSigmaITSTPCPt{"cfgOpenPlotnSigmaITSTPCPt", true, "plot nSigmaITS vs nSigmaTOF vs Pt"}; + Configurable cfgOpenPlotnSigmaTOFTPCPt{"cfgOpenPlotnSigmaTOFTPCPt", true, "plot nSigmaTOF vs nSigmaTPC vs Pt"}; + Configurable cfgOpenPlotAverClus{"cfgOpenPlotAverClus", true, "plot average cluster size x cos(#lambda)"}; + Configurable cfgOpenPlotAverClusP{"cfgOpenPlotAverClusP", true, "plot average cluster size x cos(#lambda) vs p"}; + Configurable cfgOpenPlotAverClusnSigmaTPC{"cfgOpenPlotAverClusnSigmaTPC", true, "plot average cluster size x cos(#lambda) vs nSigmaTPC"}; + Configurable cfgOpenPlotPhiDis{"cfgOpenPlotPhiDis", true, "plot phi distribution QA"}; + Configurable cfgOpenPlotPhiDisPtEta{"cfgOpenPlotPhiDisPtEta", true, "plot phi pt eta distribution QA"}; + Configurable cfgOpenITSCut{"cfgOpenITSCut", true, "open ITSnsigma cut"}; + Configurable cfgOpenITSCutQAPlots{"cfgOpenITSCutQAPlots", true, "open QA plots after ITS nsigma cut"}; + Configurable cfgOpenDetailPlotsTPCITSContaimination{"cfgOpenDetailPlotsTPCITSContaimination", false, "open detail TH3D plots for nSigmaTPC-ITS Pt-eta-Phi nSigmaITS-clustersize"}; + Configurable cfgOpenAllowCrossTrack{"cfgOpenAllowCrossTrack", false, "Allow one track to be identified as different kind of PID particles"}; + Configurable cfgOpenCrossTrackQAPlots{"cfgOpenCrossTrackQAPlots", true, "open cross pid track QA plots"}; + Configurable cfgOpenTOFOnlyPID{"cfgOpenTOFOnlyPID", true, "only accept tracks who has TOF infomation and use TOFnsigma for PID(priority greater than TPConly and combined"}; + Configurable cfgOpenTPCAssistanceTOFOnlyPID{"cfgOpenTPCAssistanceTOFOnlyPID", false, "Set loose TPC nsigma cut for TOFOnlyPID mode using cfg nsigmaTPC configurations"}; + Configurable cfgOpenTPCOnlyPID{"cfgOpenTPCOnlyPID", false, "only use TPCnsigma for PID(priority grater than combined less than TOFOnly)"}; + Configurable cfgUseCostomTrackCuts{"cfgUseCostomTrackCuts", true, "use track cuts from default track selection table producer"}; + Configurable cfgOpenPtRangedTOFnSigmacutPi{"cfgOpenPtRangedTOFnSigmacutPi", false, "use nSigma TOF cut for different pt Pion"}; + Configurable cfgOpenPtRangedTPCnSigmacutPi{"cfgOpenPtRangedTPCnSigmacutPi", false, "use nSigma TPC cut for different pt Pion"}; + Configurable cfgOpenPtRangedITSnSigmacutPi{"cfgOpenPtRangedITSnSigmacutPi", false, "use nSigma ITS cut for different pt Pion"}; + Configurable cfgOpenPtRangedTOFnSigmacutKa{"cfgOpenPtRangedTOFnSigmacutKa", false, "use nSigma TOF cut for different pt Kaon"}; + Configurable cfgOpenPtRangedTPCnSigmacutKa{"cfgOpenPtRangedTPCnSigmacutKa", false, "use nSigma TPC cut for different pt Kaon"}; + Configurable cfgOpenPtRangedITSnSigmacutKa{"cfgOpenPtRangedITSnSigmacutKa", false, "use nSigma ITS cut for different pt Kaon"}; + Configurable cfgOpenPtRangedTOFnSigmacutPr{"cfgOpenPtRangedTOFnSigmacutPr", false, "use nSigma TOF cut for different pt Proton"}; + Configurable cfgOpenPtRangedTPCnSigmacutPr{"cfgOpenPtRangedTPCnSigmacutPr", false, "use nSigma TPC cut for different pt Proton"}; + Configurable cfgOpenPtRangedITSnSigmacutPr{"cfgOpenPtRangedITSnSigmacutPr", false, "use nSigma ITS cut for different pt Proton"}; + Configurable cfgOpenPlotCheckITSOnlytrackInfo{"cfgOpenPlotCheckITSOnlytrackInfo", true, "plot checks if track NclsTPC is 0 for assure it has p info or not"}; + Configurable cfgOpenTrackingInfoCheck{"cfgOpenTrackingInfoCheck", true, "plot track infomation check"}; + + Configurable> cfgPtCutLower{"cfgPtCutLower", {0.15, 0.15, 0.15}, "Pt lower limit for pi k p respectively"}; + Configurable> cfgPtCutUpper{"cfgPtCutUpper", {99., 99., 99.}, "Pt upper limit for pi k p respectively"}; + Configurable> cfgnSigmaCutTPCUpper{"cfgnSigmaCutTPCUpper", {3, 3, 3}, "TPC nsigma cut upper limit for pi k p respectively at low pt and for the TPCOnly case"}; + Configurable> cfgnSigmaCutTOFUpper{"cfgnSigmaCutTOFUpper", {1.5, 1.5, 1.5}, "TOF nsigma cut upper limit for pi k p respectively for the TOFonly case"}; + Configurable> cfgnSigmaCutRMSUpper{"cfgnSigmaCutRMSUpper", {3, 3, 3}, "TPC_TOF combined cut upper limit for pi k p respectively at high pt"}; + Configurable> cfgnSigmaCutITSUpper{"cfgnSigmaCutITSUpper", {3, 2.5, 2}, "ITS nSigma cut upper limit for pi k p"}; + Configurable> cfgnSigmaCutTPCLower{"cfgnSigmaCutTPCLower", {-3, -3, -3}, "TPC nsigma cut lower limit for pi k p respectively at low pt and for the TPCOnly case"}; + Configurable> cfgnSigmaCutTOFLower{"cfgnSigmaCutTOFLower", {-1.5, -1.5, -1.5}, "TOF nsigma cut lower limit for pi k p respectively for the TOFonly case"}; + Configurable> cfgnSigmaCutRMSLower{"cfgnSigmaCutRMSLower", {-3, -3, -3}, "TPC_TOF combined cut lower limit for pi k p respectively at high pt"}; + Configurable> cfgnSigmaCutITSLower{"cfgnSigmaCutITSLower", {-3, -2.5, -2}, "ITS nSigma cut lower limit for pi k p"}; + Configurable> cfgPtBinPionPID{"cfgPtBinPionPID", {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 8.0, 10.0}, "pt bin for pion PIDnsigma"}; + Configurable> cfgPtBinKaonPID{"cfgPtBinKaonPID", {0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0}, "pt bin for pion PIDnsigma"}; + Configurable> cfgPtBinProtonPID{"cfgPtBinProtonPID", {0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0}, "pt bin for pion PIDnsigma"}; + Configurable> cfgnSigmaTPCPionPtUpper{"cfgnSigmaTPCPionPtUpper", {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, "nSigmaTPC cut upper limit anchored to pion pt bins"}; + Configurable> cfgnSigmaTOFPionPtUpper{"cfgnSigmaTOFPionPtUpper", {1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5}, "nSigmaTOF cut upper limit anchored to pion pt bins"}; + Configurable> cfgnSigmaITSPionPtUpper{"cfgnSigmaITSPionPtUpper", {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, "nSigmaITS cut upper limit anchored to pion pt bins"}; + Configurable> cfgnSigmaTPCKaonPtUpper{"cfgnSigmaTPCKaonPtUpper", {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, "nSigmaTPC cut upper limit anchored to kaon pt bins"}; + Configurable> cfgnSigmaTOFKaonPtUpper{"cfgnSigmaTOFKaonPtUpper", {1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5}, "nSigmaTOF cut upper limit anchored to kaon pt bins"}; + Configurable> cfgnSigmaITSKaonPtUpper{"cfgnSigmaITSKaonPtUpper", {2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5}, "nSigmaITS cut upper limit anchored to kaon pt bins"}; + Configurable> cfgnSigmaTPCProtonPtUpper{"cfgnSigmaTPCProtonPtUpper", {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, "nSigmaTPC cut upper limit anchored to proton pt bins"}; + Configurable> cfgnSigmaTOFProtonPtUpper{"cfgnSigmaTOFProtonPtUpper", {1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5}, "nSigmaTOF cut upper limit anchored to proton pt bins"}; + Configurable> cfgnSigmaITSProtonPtUpper{"cfgnSigmaITSProtonPtUpper", {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, "nSigmaITS cut upper limit anchored to proton pt bins"}; + Configurable> cfgnSigmaTPCPionPtLower{"cfgnSigmaTPCPionPtLower", {-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3}, "nSigmaTPC cut lower limit anchored to pion pt bins"}; + Configurable> cfgnSigmaTOFPionPtLower{"cfgnSigmaTOFPionPtLower", {-1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5}, "nSigmaTOF cut lower limit anchored to pion pt bins"}; + Configurable> cfgnSigmaITSPionPtLower{"cfgnSigmaITSPionPtLower", {-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3}, "nSigmaITS cut lower limit anchored to pion pt bins"}; + Configurable> cfgnSigmaTPCKaonPtLower{"cfgnSigmaTPCKaonPtLower", {-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3}, "nSigmaTPC cut lower limit anchored to kaon pt bins"}; + Configurable> cfgnSigmaTOFKaonPtLower{"cfgnSigmaTOFKaonPtLower", {-1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5}, "nSigmaTOF cut lower limit anchored to kaon pt bins"}; + Configurable> cfgnSigmaITSKaonPtLower{"cfgnSigmaITSKaonPtLower", {-2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5}, "nSigmaITS cut lower limit anchored to kaon pt bins"}; + Configurable> cfgnSigmaTPCProtonPtLower{"cfgnSigmaTPCProtonPtLower", {-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3}, "nSigmaTPC cut lower limit anchored to proton pt bins"}; + Configurable> cfgnSigmaTOFProtonPtLower{"cfgnSigmaTOFProtonPtLower", {-1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.5}, "nSigmaTOF cut lower limit anchored to proton pt bins"}; + Configurable> cfgnSigmaITSProtonPtLower{"cfgnSigmaITSProtonPtLower", {-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, "nSigmaITS cut lower limit anchored to proton pt bins"}; + + static float averageClusterSizeCosl(uint32_t itsClusterSizes, float eta) + { + float average = 0; + int nclusters = 0; + const float cosl = 1. / std::cosh(eta); + const int nlayerITS = 7; + + for (int layer = 0; layer < nlayerITS; layer++) { + if ((itsClusterSizes >> (layer * 4)) & 0xf) { + nclusters++; + average += (itsClusterSizes >> (layer * 4)) & 0xf; + } + } + if (nclusters == 0) { + return 0; + } + return average * cosl / nclusters; + }; + + template + bool selTrackPid(const TrackType track) + { + if ((track.pt() < cfgMinPtPID) || (track.pt() > cfgMaxPtPID)) + return false; + if (std::abs(track.eta()) > cfgMaxEtaPID) + return false; + if (cfgRequireGlobalTrack) { + if (!(track.isGlobalTrackSDD() == (uint8_t) true)) + return false; + } + if (cfgUseCostomTrackCuts) { + if (!track.passedITSNCls()) + return false; + if (!track.passedITSChi2NDF()) + return false; + if (!track.passedITSHits()) + return false; + if (!track.passedTPCChi2NDF()) + return false; + if (!track.passedTPCCrossedRowsOverNCls()) + return false; + if (!track.passedDCAxy()) + return false; + if (!track.passedDCAz()) + return false; + } else { + if (track.tpcChi2NCl() > cfgMaxTPCChi2NCl) + return false; + if (track.tpcNClsFound() < cfgMinTPCCls || track.tpcNClsFound() > cfgMaxTPCCls) + return false; + if (track.itsChi2NCl() > cfgMaxChi2NClITS) + return false; + if (track.itsNCls() < cfgMinITSCls || track.itsNCls() > cfgMaxITSCls) + return false; + if (std::abs(track.dcaXY()) > cfgMaxDCAxy) + return false; + if (std::abs(track.dcaZ()) > cfgMaxDCAz) + return false; + } + return true; + } + + template + int selectionPidtpctof(const T& candidate, std::array nSigmaTOFCutPtUpper, std::array nSigmaTOFCutPtLower, std::array nSigmaTPCCutPtUpper, std::array nSigmaTPCCutPtLower) + { + // initialization for basic parameter + float averClusSizeCosl = averageClusterSizeCosl(candidate.itsClusterSizes(), candidate.eta()); + std::array nSigmaTPC = {candidate.tpcNSigmaPi(), candidate.tpcNSigmaKa(), candidate.tpcNSigmaPr()}; + std::array nSigmaTOF = {candidate.tofNSigmaPi(), candidate.tofNSigmaKa(), candidate.tofNSigmaPr()}; + std::array nSigmaCombined = {std::hypot(candidate.tpcNSigmaPi(), candidate.tofNSigmaPi()), std::hypot(candidate.tpcNSigmaKa(), candidate.tofNSigmaKa()), std::hypot(candidate.tpcNSigmaPr(), candidate.tofNSigmaPr())}; + std::array nSigmaToUse; + std::vector pidVectorUpper; + std::vector pidVectorLower; + std::vector pidVectorTOFPtUpper; + std::vector pidVectorTOFPtLower; + std::vector pidVectorTPCPtUpper; + std::vector pidVectorTPCPtLower; + int pid = -1; + bool kIsPi = false, kIsKa = false, kIsPr = false; + pidVectorTOFPtUpper.push_back(nSigmaTOFCutPtUpper[0]); + pidVectorTOFPtUpper.push_back(nSigmaTOFCutPtUpper[1]); + pidVectorTOFPtUpper.push_back(nSigmaTOFCutPtUpper[2]); + pidVectorTOFPtLower.push_back(nSigmaTOFCutPtLower[0]); + pidVectorTOFPtLower.push_back(nSigmaTOFCutPtLower[1]); + pidVectorTOFPtLower.push_back(nSigmaTOFCutPtLower[2]); + pidVectorTPCPtUpper.push_back(nSigmaTPCCutPtUpper[0]); + pidVectorTPCPtUpper.push_back(nSigmaTPCCutPtUpper[1]); + pidVectorTPCPtUpper.push_back(nSigmaTPCCutPtUpper[2]); + pidVectorTPCPtLower.push_back(nSigmaTPCCutPtLower[0]); + pidVectorTPCPtLower.push_back(nSigmaTPCCutPtLower[1]); + pidVectorTPCPtLower.push_back(nSigmaTPCCutPtLower[2]); + // Choose which nSigma array and PIDcut array to use + if (cfgOpenTOFOnlyPID) { + if (!candidate.hasTOF()) + return 0; + nSigmaToUse = nSigmaTOF; + pidVectorUpper = pidVectorTOFPtUpper; + pidVectorLower = pidVectorTOFPtLower; + } else if (cfgOpenTPCOnlyPID) { + nSigmaToUse = nSigmaTPC; + pidVectorUpper = pidVectorTPCPtUpper; + pidVectorLower = pidVectorTPCPtLower; + } else { + nSigmaToUse = (candidate.pt() > cfgPtMaxforTPCOnlyPID && candidate.hasTOF()) ? nSigmaCombined : nSigmaTPC; + pidVectorUpper = (candidate.pt() > cfgPtMaxforTPCOnlyPID && candidate.hasTOF()) ? cfgnSigmaCutRMSUpper.value : cfgnSigmaCutTPCUpper.value; + pidVectorLower = (candidate.pt() > cfgPtMaxforTPCOnlyPID && candidate.hasTOF()) ? cfgnSigmaCutRMSLower.value : cfgnSigmaCutTPCLower.value; + } + float nsigma = 9999.99; + const int nPOI = 3; + const int piCase = 0; + const int kaCase = 1; + const int prCase = 2; + // Fill cross pid QA + for (int i = 0; i < nPOI; ++i) { + if (nSigmaToUse[i] > pidVectorLower[i] && nSigmaToUse[i] < pidVectorUpper[i]) { + if (i == piCase) { + kIsPi = true; + if (!cfgQuietMode) { + if (cfgOpenCrossTrackQAPlots) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_nSigmaTPC_cross_Pi"), candidate.itsNSigmaPi(), candidate.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaITS_cross_Pi"), candidate.tofNSigmaPi(), candidate.itsNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaTPC_cross_Pi"), candidate.tofNSigmaPi(), candidate.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histdEdxTPC_cross_Pi"), candidate.sign() * candidate.tpcInnerParam(), candidate.tpcSignal()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_cross_Pi"), candidate.tofNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pt_cross_Pi"), candidate.pt(), candidate.tofNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_cross_Pi"), candidate.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_Pt_cross_Pi"), candidate.pt(), candidate.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_cross_Pi"), candidate.itsNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pt_cross_Pi"), candidate.pt(), candidate.itsNSigmaPi()); + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_ITS_Pt_cross_Pi"), candidate.pt(), candidate.tofNSigmaPi(), candidate.itsNSigmaPi()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_TPC_Pt_cross_Pi"), candidate.pt(), candidate.tofNSigmaPi(), candidate.tpcNSigmaPi()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_ITS_TPC_Pt_cross_Pi"), candidate.pt(), candidate.itsNSigmaPi(), candidate.tpcNSigmaPi()); + } + if (cfgOpenPlotAverClus) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_cross_Pi"), averClusSizeCosl); + } + if (cfgOpenPlotAverClusP) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_cross_Pi"), candidate.p(), averClusSizeCosl); + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Pi"), candidate.tpcNSigmaPi(), averClusSizeCosl); + } + if (cfgOpenPlotPhiDis) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_cross_Pi"), candidate.phi()); + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pt_Eta_cross_Pi"), candidate.phi(), candidate.pt(), candidate.eta()); + } + } + } + } + if (i == kaCase) { + kIsKa = true; + if (!cfgQuietMode) { + if (cfgOpenCrossTrackQAPlots) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_nSigmaTPC_cross_Ka"), candidate.itsNSigmaKa(), candidate.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaITS_cross_Ka"), candidate.tofNSigmaKa(), candidate.itsNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaTPC_cross_Ka"), candidate.tofNSigmaKa(), candidate.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histdEdxTPC_cross_Ka"), candidate.sign() * candidate.tpcInnerParam(), candidate.tpcSignal()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_cross_Ka"), candidate.tofNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pt_cross_Ka"), candidate.pt(), candidate.tofNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_cross_Ka"), candidate.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_Pt_cross_Ka"), candidate.pt(), candidate.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_cross_Ka"), candidate.itsNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pt_cross_Ka"), candidate.pt(), candidate.itsNSigmaKa()); + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_ITS_Pt_cross_Ka"), candidate.pt(), candidate.tofNSigmaKa(), candidate.itsNSigmaKa()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_TPC_Pt_cross_Ka"), candidate.pt(), candidate.tofNSigmaKa(), candidate.tpcNSigmaKa()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_ITS_TPC_Pt_cross_Ka"), candidate.pt(), candidate.itsNSigmaKa(), candidate.tpcNSigmaKa()); + } + if (cfgOpenPlotAverClus) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_cross_Ka"), averClusSizeCosl); + } + if (cfgOpenPlotAverClusP) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_cross_Ka"), candidate.p(), averClusSizeCosl); + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Ka"), candidate.tpcNSigmaKa(), averClusSizeCosl); + } + if (cfgOpenPlotPhiDis) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_cross_Ka"), candidate.phi()); + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pt_Eta_cross_Ka"), candidate.phi(), candidate.pt(), candidate.eta()); + } + } + } + } + if (i == prCase) { + kIsPr = true; + if (!cfgQuietMode) { + if (cfgOpenCrossTrackQAPlots) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_nSigmaTPC_cross_Pr"), candidate.itsNSigmaPr(), candidate.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaITS_cross_Pr"), candidate.tofNSigmaPr(), candidate.itsNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaTPC_cross_Pr"), candidate.tofNSigmaPr(), candidate.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histdEdxTPC_cross_Pr"), candidate.sign() * candidate.tpcInnerParam(), candidate.tpcSignal()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_cross_Pr"), candidate.tofNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pt_cross_Pr"), candidate.pt(), candidate.tofNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_cross_Pr"), candidate.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_Pt_cross_Pr"), candidate.pt(), candidate.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_cross_Pr"), candidate.itsNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pt_cross_Pr"), candidate.pt(), candidate.itsNSigmaPr()); + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_ITS_Pt_cross_Pr"), candidate.pt(), candidate.tofNSigmaPr(), candidate.itsNSigmaPr()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_TPC_Pt_cross_Pr"), candidate.pt(), candidate.tofNSigmaPr(), candidate.tpcNSigmaPr()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_ITS_TPC_Pt_cross_Pr"), candidate.pt(), candidate.itsNSigmaPr(), candidate.tpcNSigmaPr()); + } + if (cfgOpenPlotAverClus) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_cross_Pr"), averClusSizeCosl); + } + if (cfgOpenPlotAverClusP) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_cross_Pr"), candidate.p(), averClusSizeCosl); + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Pr"), candidate.tpcNSigmaPr(), averClusSizeCosl); + } + if (cfgOpenPlotPhiDis) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_cross_Pr"), candidate.phi()); + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pt_Eta_cross_Pr"), candidate.phi(), candidate.pt(), candidate.eta()); + } + } + } + } + } + } + if (cfgOpenAllowCrossTrack) { + // one track can be recognized as different PID particles + int index = (kIsPr << 2) | (kIsKa << 1) | kIsPi; + const int map[] = {0, 1, 2, 7, 3, 8, 9, 10}; + return map[index]; + } else { + // Select particle with the lowest nsigma (If not allow cross track) + for (int i = 0; i < nPOI; ++i) { + if (std::abs(nSigmaToUse[i]) < nsigma && (nSigmaToUse[i] > pidVectorLower[i] && nSigmaToUse[i] < pidVectorUpper[i])) { + pid = i; + nsigma = std::abs(nSigmaToUse[i]); + } + } + return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton + } + // Clear the vectors + std::vector().swap(pidVectorLower); + std::vector().swap(pidVectorUpper); + std::vector().swap(pidVectorTOFPtUpper); + std::vector().swap(pidVectorTPCPtLower); + std::vector().swap(pidVectorTOFPtUpper); + std::vector().swap(pidVectorTPCPtLower); + } + + template + bool selectionITS(const T& candidate, int mode, float avgclssize, std::array nSigmaITSToUseUpper, std::array nSigmaITSToUseLower) + { + switch (mode) { + case 1: // For Pion + if (!((candidate.itsNSigmaPi() > nSigmaITSToUseLower[0] && candidate.itsNSigmaPi() < nSigmaITSToUseUpper[0]) && avgclssize > cfgAveClusSizeCoslMinPi && avgclssize < cfgAveClusSizeCoslMaxPi)) { + return false; + } else { + return true; + } + break; + + case 2: // For Kaon + if (!((candidate.itsNSigmaKa() > nSigmaITSToUseLower[1] && candidate.itsNSigmaKa() < nSigmaITSToUseUpper[1]) && avgclssize > cfgAveClusSizeCoslMinKa && avgclssize < cfgAveClusSizeCoslMaxKa)) { + return false; + } else { + return true; + } + break; + + case 3: // For Proton + if (!((candidate.itsNSigmaPr() > nSigmaITSToUseLower[2] && candidate.itsNSigmaPr() < nSigmaITSToUseUpper[2]) && avgclssize > cfgAveClusSizeCoslMinPr && avgclssize < cfgAveClusSizeCoslMaxPr)) { + return false; + } else { + return true; + } + break; + } + return false; + } + + HistogramRegistry histosQA{"histosQAPID", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(InitContext const&) + { + + AxisSpec axisRigidity{cfgrigidityBins, "#it{p}^{TPC}/#it{z}"}; + AxisSpec axisdEdx{cfgdedxBins, "d#it{E}/d#it{x}"}; + AxisSpec axisnSigmaTPC{cfgnSigmaBinsTPC, "n_{#sigma}TPC"}; + AxisSpec axisnSigmaTOF{cfgnSigmaBinsTOF, "n_{#sigma}TOF"}; + AxisSpec axisnSigmaITS{cfgnSigmaBinsITS, "n_{#sigma}ITS"}; + AxisSpec axisnSigmaCom{cfgnSigmaBinsCom, "hypot(n_{#sigma}TPC,TOF)"}; + AxisSpec axisPtPID{cfgaxisptPID, "#it{p}_{T}"}; + AxisSpec axisPPID{cfgaxispPID, "#it{p}"}; + AxisSpec axisEtaPID{cfgaxisetaPID, "#it{#eta}"}; + AxisSpec axisClusterSize{cfgaxisAverClusterCosl, " x "}; + AxisSpec axisClusterSizenSigma{cfgaxisAverClusterCoslnSigma, " x "}; + AxisSpec axisPhi = {100, 0, 2.1 * constants::math::PI, "#phi"}; + AxisSpec axisDCAz{cfgaxisDCAz, "#it{DCA_{z}}"}; + AxisSpec axisDCAxy{cfgaxisDCAxy, "#it{DCA_{xy}}"}; + AxisSpec axisITSNcls = {10, -1.5, 8.5, "ITSNcls"}; + AxisSpec axisTPCNcls = {160, 0, 160, "TPCNcls"}; + AxisSpec axisP{50, -5, 5, "#it{p}"}; + AxisSpec axisChi2Ncls = {cfgaxisChi2Ncls, "#chi^{2}/Ncls"}; + + if (!cfgQuietMode) { + // ITSOnly track check + if (cfgOpenPlotCheckITSOnlytrackInfo) { + histosQA.add(Form("QA/PID/histDCAz_ITSOnly_Px"), "", {HistType::kTH1F, {axisP}}); + histosQA.add(Form("QA/PID/histDCAz_ITSOnly_Py"), "", {HistType::kTH1F, {axisP}}); + histosQA.add(Form("QA/PID/histDCAz_ITSOnly_Pz"), "", {HistType::kTH1F, {axisP}}); + } + // TPCChi2Ncls Checking + if (cfgOpenTrackingInfoCheck) { + histosQA.add(Form("QA/PID/histTPCChi2Ncls_total_origin"), "#chi^{2}/Ncls_{TPC},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histTPCChi2Ncls_total"), "#chi^{2}/Ncls_{TPC},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histTPCChi2Ncls_Pi"), "#chi^{2}/Ncls_{TPC},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histTPCChi2Ncls_Ka"), "#chi^{2}/Ncls_{TPC},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histTPCChi2Ncls_Pr"), "#chi^{2}/Ncls_{TPC},counts", {HistType::kTH1F, {axisChi2Ncls}}); + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histTPCChi2Ncls_total_AfterITS"), ",#chi^{2}/Ncls_{TPC},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histTPCChi2Ncls_Pi_AfterITS"), "#chi^{2}/Ncls_{TPC},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histTPCChi2Ncls_Ka_AfterITS"), "#chi^{2}/Ncls_{TPC},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histTPCChi2Ncls_Pr_AfterITS"), "#chi^{2}/Ncls_{TPC},counts", {HistType::kTH1F, {axisChi2Ncls}}); + } + } + // ITSChi2Ncls Checking + if (cfgOpenTrackingInfoCheck) { + histosQA.add(Form("QA/PID/histITSChi2Ncls_total_origin"), "#chi^{2}/Ncls_{ITS},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histITSChi2Ncls_total"), "#chi^{2}/Ncls_{ITS},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histITSChi2Ncls_Pi"), "#chi^{2}/Ncls_{ITS},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histITSChi2Ncls_Ka"), "#chi^{2}/Ncls_{ITS},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histITSChi2Ncls_Pr"), "#chi^{2}/Ncls_{ITS},counts", {HistType::kTH1F, {axisChi2Ncls}}); + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histITSChi2Ncls_total_AfterITS"), ",#chi^{2}/Ncls_{ITS},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histITSChi2Ncls_Pi_AfterITS"), "#chi^{2}/Ncls_{ITS},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histITSChi2Ncls_Ka_AfterITS"), "#chi^{2}/Ncls_{ITS},counts", {HistType::kTH1F, {axisChi2Ncls}}); + histosQA.add(Form("QA/PID/histITSChi2Ncls_Pr_AfterITS"), "#chi^{2}/Ncls_{ITS},counts", {HistType::kTH1F, {axisChi2Ncls}}); + } + } + // DCA Chencks + if (cfgOpenTrackingInfoCheck) { + histosQA.add(Form("QA/PID/histDCAz_total_origin"), "", {HistType::kTH1F, {axisDCAz}}); + histosQA.add(Form("QA/PID/histDCAxy_total_origin"), "", {HistType::kTH1F, {axisDCAxy}}); + histosQA.add(Form("QA/PID/histDCAz_total"), "", {HistType::kTH1F, {axisDCAz}}); + histosQA.add(Form("QA/PID/histDCAxy_total"), "", {HistType::kTH1F, {axisDCAxy}}); + histosQA.add(Form("QA/PID/histDCAz_Pi"), "", {HistType::kTH1F, {axisDCAz}}); + histosQA.add(Form("QA/PID/histDCAxy_Pi"), "", {HistType::kTH1F, {axisDCAxy}}); + histosQA.add(Form("QA/PID/histDCAz_Ka"), "", {HistType::kTH1F, {axisDCAz}}); + histosQA.add(Form("QA/PID/histDCAxy_Ka"), "", {HistType::kTH1F, {axisDCAxy}}); + histosQA.add(Form("QA/PID/histDCAz_Pr"), "", {HistType::kTH1F, {axisDCAz}}); + histosQA.add(Form("QA/PID/histDCAxy_Pr"), "", {HistType::kTH1F, {axisDCAxy}}); + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histDCAz_total_AfterITS"), "", {HistType::kTH1F, {axisDCAz}}); + histosQA.add(Form("QA/PID/histDCAxy_total_AfterITS"), "", {HistType::kTH1F, {axisDCAxy}}); + histosQA.add(Form("QA/PID/histDCAz_Pi_AfterITS"), "", {HistType::kTH1F, {axisDCAz}}); + histosQA.add(Form("QA/PID/histDCAxy_Pi_AfterITS"), "", {HistType::kTH1F, {axisDCAxy}}); + histosQA.add(Form("QA/PID/histDCAz_Ka_AfterITS"), "", {HistType::kTH1F, {axisDCAz}}); + histosQA.add(Form("QA/PID/histDCAxy_Ka_AfterITS"), "", {HistType::kTH1F, {axisDCAxy}}); + histosQA.add(Form("QA/PID/histDCAz_Pr_AfterITS"), "", {HistType::kTH1F, {axisDCAz}}); + histosQA.add(Form("QA/PID/histDCAxy_Pr_AfterITS"), "", {HistType::kTH1F, {axisDCAxy}}); + } + } + // ITSNcls Checks + if (cfgOpenTrackingInfoCheck) { + histosQA.add(Form("QA/PID/histITSNcls_total_origin"), "", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/PID/histITSNcls_total"), "", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/PID/histITSNcls_Pi"), "", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/PID/histITSNcls_Ka"), "", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/PID/histITSNcls_Pr"), "", {HistType::kTH1F, {axisITSNcls}}); + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histITSNcls_total_AfterITS"), "", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/PID/histITSNcls_Pi_AfterITS"), "", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/PID/histITSNcls_Ka_AfterITS"), "", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/PID/histITSNcls_Pr_AfterITS"), "", {HistType::kTH1F, {axisITSNcls}}); + } + } + // TPCNcls Checks + if (cfgOpenTrackingInfoCheck) { + histosQA.add(Form("QA/PID/histTPCNcls_total_origin"), "", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/PID/histTPCNcls_total"), "", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/PID/histTPCNcls_Pi"), "", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/PID/histTPCNcls_Ka"), "", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/PID/histTPCNcls_Pr"), "", {HistType::kTH1F, {axisTPCNcls}}); + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histTPCNcls_total_AfterITS"), "", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/PID/histTPCNcls_Pi_AfterITS"), "", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/PID/histTPCNcls_Ka_AfterITS"), "", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/PID/histTPCNcls_Pr_AfterITS"), "", {HistType::kTH1F, {axisTPCNcls}}); + } + } + // PID Origin plots + if (cfgOpenPlotnSigmaOrigin) { + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_ITS_Pt_Pi"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_ITS_Pt_Ka"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_ITS_Pt_Pr"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_TPC_Pt_Pi"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_TPC_Pt_Ka"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_TPC_Pt_Pr"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.add(Form("QA/PID/histnSigma_Origin_ITS_TPC_Pt_Pi"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_ITS_TPC_Pt_Ka"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_ITS_TPC_Pt_Pr"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + } + histosQA.add(Form("QA/PID/histnSigma_Origin_TPC_Pi"), "", {HistType::kTH1F, {axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TPC_Ka"), "", {HistType::kTH1F, {axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TPC_Pr"), "", {HistType::kTH1F, {axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TPC_Pt_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TPC_Pt_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TPC_Pt_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_Pi"), "", {HistType::kTH1F, {axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_Ka"), "", {HistType::kTH1F, {axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_Pr"), "", {HistType::kTH1F, {axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_Pt_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_Pt_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_TOF_Pt_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_ITS_Pi"), "", {HistType::kTH1F, {axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_ITS_Ka"), "", {HistType::kTH1F, {axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_ITS_Pr"), "", {HistType::kTH1F, {axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_ITS_Pt_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_ITS_Pt_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_Origin_ITS_Pt_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + } + // TH3D NSigmaTPC,NSigmaTOF,NSigmaITS combo vs pt(if necessary for whole centrality) + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.add(Form("QA/PID/histnSigma_TOF_ITS_Pt_Pi"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_ITS_Pt_Ka"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_ITS_Pt_Pr"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histnSigma_TOF_ITS_Pt_cross_Pi"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_ITS_Pt_cross_Ka"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_ITS_Pt_cross_Pr"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histnSigma_TOF_ITS_Pt_AfterITS_Pi"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_ITS_Pt_AfterITS_Ka"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_ITS_Pt_AfterITS_Pr"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaITS, axisPtPID}}); + } + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.add(Form("QA/PID/histnSigma_TOF_TPC_Pt_Pi"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_TPC_Pt_Ka"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_TPC_Pt_Pr"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histnSigma_TOF_TPC_Pt_cross_Pi"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_TPC_Pt_cross_Ka"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_TPC_Pt_cross_Pr"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histnSigma_TOF_TPC_Pt_AfterITS_Pi"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_TPC_Pt_AfterITS_Ka"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_TPC_Pt_AfterITS_Pr"), "", {HistType::kTH3F, {axisnSigmaTOF, axisnSigmaTPC, axisPtPID}}); + } + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.add(Form("QA/PID/histnSigma_ITS_TPC_Pt_Pi"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_TPC_Pt_Ka"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_TPC_Pt_Pr"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histnSigma_ITS_TPC_Pt_cross_Pi"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_TPC_Pt_cross_Ka"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_TPC_Pt_cross_Pr"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histnSigma_ITS_TPC_Pt_AfterITS_Pi"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_TPC_Pt_AfterITS_Ka"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_TPC_Pt_AfterITS_Pr"), "", {HistType::kTH3F, {axisnSigmaITS, axisnSigmaTPC, axisPtPID}}); + } + } + if (cfgOpenPlotAverClus) { + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_Pi"), "", {HistType::kTH1F, {axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_Ka"), "", {HistType::kTH1F, {axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_Pr"), "", {HistType::kTH1F, {axisClusterSize}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_cross_Pi"), "", {HistType::kTH1F, {axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_cross_Ka"), "", {HistType::kTH1F, {axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_cross_Pr"), "", {HistType::kTH1F, {axisClusterSize}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_AfterITS_Pi"), "", {HistType::kTH1F, {axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_AfterITS_Ka"), "", {HistType::kTH1F, {axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_AfterITS_Pr"), "", {HistType::kTH1F, {axisClusterSize}}); + } + } + if (cfgOpenPlotAverClusP) { + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_Pi"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_Ka"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_Pr"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_cross_Pi"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_cross_Ka"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_cross_Pr"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_AfterITS_Pi"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_AfterITS_Ka"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_AfterITS_Pr"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); + } + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pi"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSizenSigma}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Ka"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSizenSigma}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pr"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSizenSigma}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Pi"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSizenSigma}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Ka"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSizenSigma}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Pr"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSizenSigma}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_AfterITS_Pi"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSizenSigma}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_AfterITS_Ka"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSizenSigma}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_AfterITS_Pr"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSizenSigma}}); + } + } + if (cfgOpenPlotPhiDis) { + histosQA.add(Form("QA/PID/histPhi_Dis_Pi"), "", {HistType::kTH1F, {axisPhi}}); + histosQA.add(Form("QA/PID/histPhi_Dis_Ka"), "", {HistType::kTH1F, {axisPhi}}); + histosQA.add(Form("QA/PID/histPhi_Dis_Pr"), "", {HistType::kTH1F, {axisPhi}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histPhi_Dis_cross_Pi"), "", {HistType::kTH1F, {axisPhi}}); + histosQA.add(Form("QA/PID/histPhi_Dis_cross_Ka"), "", {HistType::kTH1F, {axisPhi}}); + histosQA.add(Form("QA/PID/histPhi_Dis_cross_Pr"), "", {HistType::kTH1F, {axisPhi}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histPhi_Dis_AfterITS_Pi"), "", {HistType::kTH1F, {axisPhi}}); + histosQA.add(Form("QA/PID/histPhi_Dis_AfterITS_Ka"), "", {HistType::kTH1F, {axisPhi}}); + histosQA.add(Form("QA/PID/histPhi_Dis_AfterITS_Pr"), "", {HistType::kTH1F, {axisPhi}}); + } + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.add(Form("QA/PID/histPhi_Dis_Pt_Eta_Pi"), "", {HistType::kTH3F, {axisPhi, axisPtPID, axisEtaPID}}); + histosQA.add(Form("QA/PID/histPhi_Dis_Pt_Eta_Ka"), "", {HistType::kTH3F, {axisPhi, axisPtPID, axisEtaPID}}); + histosQA.add(Form("QA/PID/histPhi_Dis_Pt_Eta_Pr"), "", {HistType::kTH3F, {axisPhi, axisPtPID, axisEtaPID}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histPhi_Dis_Pt_Eta_cross_Pi"), "", {HistType::kTH3F, {axisPhi, axisPtPID, axisEtaPID}}); + histosQA.add(Form("QA/PID/histPhi_Dis_Pt_Eta_cross_Ka"), "", {HistType::kTH3F, {axisPhi, axisPtPID, axisEtaPID}}); + histosQA.add(Form("QA/PID/histPhi_Dis_Pt_Eta_cross_Pr"), "", {HistType::kTH3F, {axisPhi, axisPtPID, axisEtaPID}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histPhi_Dis_Pt_Eta_AfterITS_Pi"), "", {HistType::kTH3F, {axisPhi, axisPtPID, axisEtaPID}}); + histosQA.add(Form("QA/PID/histPhi_Dis_Pt_Eta_AfterITS_Ka"), "", {HistType::kTH3F, {axisPhi, axisPtPID, axisEtaPID}}); + histosQA.add(Form("QA/PID/histPhi_Dis_Pt_Eta_AfterITS_Pr"), "", {HistType::kTH3F, {axisPhi, axisPtPID, axisEtaPID}}); + } + } + // some basic plots should be ploted (except for the quite mode) + // nSigma TPC TOF ITS combo plots + histosQA.add(Form("QA/PID/histnSigmaITS_nSigmaTPC_Pi"), "", {HistType::kTH2F, {axisnSigmaITS, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaITS_nSigmaTPC_Ka"), "", {HistType::kTH2F, {axisnSigmaITS, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaITS_nSigmaTPC_Pr"), "", {HistType::kTH2F, {axisnSigmaITS, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaITS_Pi"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaITS_Ka"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaITS_Pr"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaTPC_Pi"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaTPC_Ka"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaTPC_Pr"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaTPC}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histnSigmaITS_nSigmaTPC_cross_Pi"), "", {HistType::kTH2F, {axisnSigmaITS, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaITS_nSigmaTPC_cross_Ka"), "", {HistType::kTH2F, {axisnSigmaITS, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaITS_nSigmaTPC_cross_Pr"), "", {HistType::kTH2F, {axisnSigmaITS, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaITS_cross_Pi"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaITS_cross_Ka"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaITS_cross_Pr"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaTPC_cross_Pi"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaTPC_cross_Ka"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaTPC_cross_Pr"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaTPC}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histnSigmaITS_nSigmaTPC_AfterITS_Pi"), "", {HistType::kTH2F, {axisnSigmaITS, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaITS_nSigmaTPC_AfterITS_Ka"), "", {HistType::kTH2F, {axisnSigmaITS, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaITS_nSigmaTPC_AfterITS_Pr"), "", {HistType::kTH2F, {axisnSigmaITS, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaITS_AfterITS_Pi"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaITS_AfterITS_Ka"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaITS_AfterITS_Pr"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaTPC_AfterITS_Pi"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaTPC_AfterITS_Ka"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigmaTOF_nSigmaTPC_AfterITS_Pr"), "", {HistType::kTH2F, {axisnSigmaTOF, axisnSigmaTPC}}); + } + // nSigma TPC TOF ITS signle and some simple QA plots + histosQA.add(Form("QA/PID/histdEdxTPC_All"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histosQA.add(Form("QA/PID/histdEdxTPC_Pi"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histosQA.add(Form("QA/PID/histdEdxTPC_Ka"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histosQA.add(Form("QA/PID/histdEdxTPC_Pr"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histosQA.add(Form("QA/PID/histnSigma_TPC_Pi"), "", {HistType::kTH1F, {axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_TPC_Ka"), "", {HistType::kTH1F, {axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_TPC_Pr"), "", {HistType::kTH1F, {axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_TPC_Pt_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_TPC_Pt_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_TPC_Pt_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_com_Pi"), "", {HistType::kTH1F, {axisnSigmaCom}}); + histosQA.add(Form("QA/PID/histnSigma_com_Ka"), "", {HistType::kTH1F, {axisnSigmaCom}}); + histosQA.add(Form("QA/PID/histnSigma_com_Pr"), "", {HistType::kTH1F, {axisnSigmaCom}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pi"), "", {HistType::kTH1F, {axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Ka"), "", {HistType::kTH1F, {axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pr"), "", {HistType::kTH1F, {axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pt_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pt_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pt_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pi"), "", {HistType::kTH1F, {axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Ka"), "", {HistType::kTH1F, {axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pr"), "", {HistType::kTH1F, {axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pt_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pt_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pt_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + if (cfgOpenCrossTrackQAPlots) { + histosQA.add(Form("QA/PID/histdEdxTPC_cross_Pi"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histosQA.add(Form("QA/PID/histdEdxTPC_cross_Ka"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histosQA.add(Form("QA/PID/histdEdxTPC_cross_Pr"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_cross_Pi"), "", {HistType::kTH1F, {axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_cross_Ka"), "", {HistType::kTH1F, {axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_cross_Pr"), "", {HistType::kTH1F, {axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pt_cross_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pt_cross_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pt_cross_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_cross_Pi"), "", {HistType::kTH1F, {axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_cross_Ka"), "", {HistType::kTH1F, {axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_cross_Pr"), "", {HistType::kTH1F, {axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_Pt_cross_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_Pt_cross_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_Pt_cross_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_cross_Pi"), "", {HistType::kTH1F, {axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_cross_Ka"), "", {HistType::kTH1F, {axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_cross_Pr"), "", {HistType::kTH1F, {axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pt_cross_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pt_cross_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pt_cross_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + } + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histnSigma_TOF_Pt_AfterITS_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pt_AfterITS_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TOF_Pt_AfterITS_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTOF}}); + histosQA.add(Form("QA/PID/histnSigma_TPC_Pt_AfterITS_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_TPC_Pt_AfterITS_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_TPC_Pt_AfterITS_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pt_AfterITS_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pt_AfterITS_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + histosQA.add(Form("QA/PID/histnSigma_ITS_Pt_AfterITS_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaITS}}); + } + // plots for TPC-ITS contamination (whole centrality) + if (cfgOpenDetailPlotsTPCITSContaimination) { + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosPi_Before"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosKa_Before"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosPr_Before"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegPi_Before"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegKa_Before"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegPr_Before"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPi_Before"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosKa_Before"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPr_Before"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPi_Before"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegKa_Before"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPr_Before"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + if (cfgOpenITSCutQAPlots) { + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosPi_After"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosKa_After"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosPr_After"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegPi_After"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegKa_After"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegPr_After"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaITS, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSIgmaTPC_Pt_PosPi_After"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSIgmaTPC_Pt_PosKa_After"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSIgmaTPC_Pt_PosPr_After"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSIgmaTPC_Pt_NegPi_After"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSIgmaTPC_Pt_NegKa_After"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSIgmaTPC_Pt_NegPr_After"), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {axisnSigmaTPC, axisClusterSizenSigma, axisPtPID}}); + } + } + } + } + Produces pidCmeTable; + Produces pidInfoTable; + void process(TracksPID const& tracks) + { + auto tracksWithITSPid = soa::Attach(tracks); + int8_t pidFlag; + for (const auto& track : tracksWithITSPid) { + // Fill the original plots first + if (!cfgQuietMode) { + if (cfgOpenTrackingInfoCheck) { + histosQA.fill(HIST("QA/PID/histDCAz_total_origin"), track.dcaZ()); + histosQA.fill(HIST("QA/PID/histDCAxy_total_origin"), track.dcaXY()); + histosQA.fill(HIST("QA/PID/histTPCNcls_total_origin"), track.tpcNClsFound()); + histosQA.fill(HIST("QA/PID/histITSNcls_total_origin"), track.itsNCls()); + histosQA.fill(HIST("QA/PID/histTPCChi2Ncls_total_origin"), track.tpcChi2NCl()); + histosQA.fill(HIST("QA/PID/histITSChi2Ncls_total_origin"), track.itsChi2NCl()); + } + if (cfgOpenPlotCheckITSOnlytrackInfo && track.tpcNClsFound() == 0) { + histosQA.fill(HIST("QA/PID/histDCAz_ITSOnly_Px"), track.px()); + histosQA.fill(HIST("QA/PID/histDCAz_ITSOnly_Py"), track.py()); + histosQA.fill(HIST("QA/PID/histDCAz_ITSOnly_Pz"), track.pz()); + } + if (cfgOpenPlotnSigmaOrigin) { + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_ITS_Pt_Pi"), track.tofNSigmaPi(), track.itsNSigmaPi(), track.pt()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_ITS_Pt_Ka"), track.tofNSigmaKa(), track.itsNSigmaKa(), track.pt()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_ITS_Pt_Pr"), track.tofNSigmaPr(), track.itsNSigmaPr(), track.pt()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_TPC_Pt_Pi"), track.tofNSigmaPi(), track.tpcNSigmaPi(), track.pt()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_TPC_Pt_Ka"), track.tofNSigmaKa(), track.tpcNSigmaKa(), track.pt()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_TPC_Pt_Pr"), track.tofNSigmaPr(), track.tpcNSigmaPr(), track.pt()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_Origin_ITS_TPC_Pt_Pi"), track.itsNSigmaPi(), track.tpcNSigmaPi(), track.pt()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_ITS_TPC_Pt_Ka"), track.itsNSigmaKa(), track.tpcNSigmaKa(), track.pt()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_ITS_TPC_Pt_Pr"), track.itsNSigmaPr(), track.tpcNSigmaPr(), track.pt()); + } + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TPC_Pi"), track.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TPC_Ka"), track.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TPC_Pr"), track.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_Pi"), track.tofNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_Ka"), track.tofNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_Pr"), track.tofNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_ITS_Pi"), track.itsNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_ITS_Ka"), track.itsNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_ITS_Pr"), track.itsNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TPC_Pt_Pi"), track.pt(), track.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TPC_Pt_Ka"), track.pt(), track.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TPC_Pt_Pr"), track.pt(), track.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_Pt_Pi"), track.pt(), track.tofNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_Pt_Ka"), track.pt(), track.tofNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_TOF_Pt_Pr"), track.pt(), track.tofNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_ITS_Pt_Pi"), track.pt(), track.itsNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_ITS_Pt_Ka"), track.pt(), track.itsNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_Origin_ITS_Pt_Pr"), track.pt(), track.itsNSigmaPr()); + } + } + int currentPtBinPi = -1, currentPtBinKa = -1, currentPtBinPr = -1; + if (cfgOpenPtRangedTOFnSigmacutPi || cfgOpenPtRangedTPCnSigmacutPi || cfgOpenPtRangedITSnSigmacutPi) { + for (int i = 0; i < static_cast(cfgPtBinPionPID.value.size()) - 1; ++i) { + if (track.pt() >= cfgPtBinPionPID.value[i] && track.pt() < cfgPtBinPionPID.value[i + 1]) { + currentPtBinPi = i; + break; + } + } + } + if (cfgOpenPtRangedTOFnSigmacutKa || cfgOpenPtRangedTPCnSigmacutKa || cfgOpenPtRangedITSnSigmacutKa) { + for (int i = 0; i < static_cast(cfgPtBinKaonPID.value.size()) - 1; ++i) { + if (track.pt() >= cfgPtBinKaonPID.value[i] && track.pt() < cfgPtBinKaonPID.value[i + 1]) { + currentPtBinKa = i; + break; + } + } + } + if (cfgOpenPtRangedTOFnSigmacutPr || cfgOpenPtRangedTPCnSigmacutPr || cfgOpenPtRangedITSnSigmacutPr) { + for (int i = 0; i < static_cast(cfgPtBinProtonPID.value.size()) - 1; ++i) { + if (track.pt() >= cfgPtBinProtonPID.value[i] && track.pt() < cfgPtBinProtonPID.value[i + 1]) { + currentPtBinPr = i; + break; + } + } + } + float nSigmaTOFCutPiPtUpper = (currentPtBinPi == -1) ? cfgnSigmaCutTOFUpper.value[0] : cfgnSigmaTOFPionPtUpper.value[currentPtBinPi]; + float nSigmaTOFCutKaPtUpper = (currentPtBinKa == -1) ? cfgnSigmaCutTOFUpper.value[1] : cfgnSigmaTOFKaonPtUpper.value[currentPtBinKa]; + float nSigmaTOFCutPrPtUpper = (currentPtBinPr == -1) ? cfgnSigmaCutTOFUpper.value[2] : cfgnSigmaTOFProtonPtUpper.value[currentPtBinPr]; + float nSigmaTPCCutPiPtUpper = (currentPtBinPi == -1) ? cfgnSigmaCutTPCUpper.value[0] : cfgnSigmaTPCPionPtUpper.value[currentPtBinPi]; + float nSigmaTPCCutKaPtUpper = (currentPtBinKa == -1) ? cfgnSigmaCutTPCUpper.value[1] : cfgnSigmaTPCKaonPtUpper.value[currentPtBinKa]; + float nSigmaTPCCutPrPtUpper = (currentPtBinPr == -1) ? cfgnSigmaCutTPCUpper.value[2] : cfgnSigmaTPCProtonPtUpper.value[currentPtBinPr]; + float nSigmaTOFCutPiPtLower = (currentPtBinPi == -1) ? cfgnSigmaCutTOFLower.value[0] : cfgnSigmaTOFPionPtLower.value[currentPtBinPi]; + float nSigmaTOFCutKaPtLower = (currentPtBinKa == -1) ? cfgnSigmaCutTOFLower.value[1] : cfgnSigmaTOFKaonPtLower.value[currentPtBinKa]; + float nSigmaTOFCutPrPtLower = (currentPtBinPr == -1) ? cfgnSigmaCutTOFLower.value[2] : cfgnSigmaTOFProtonPtLower.value[currentPtBinPr]; + float nSigmaTPCCutPiPtLower = (currentPtBinPi == -1) ? cfgnSigmaCutTPCLower.value[0] : cfgnSigmaTPCPionPtLower.value[currentPtBinPi]; + float nSigmaTPCCutKaPtLower = (currentPtBinKa == -1) ? cfgnSigmaCutTPCLower.value[1] : cfgnSigmaTPCKaonPtLower.value[currentPtBinKa]; + float nSigmaTPCCutPrPtLower = (currentPtBinPr == -1) ? cfgnSigmaCutTPCLower.value[2] : cfgnSigmaTPCProtonPtLower.value[currentPtBinPr]; + float nSigmaITSCutPiPtUpper = (currentPtBinPi == -1) ? cfgnSigmaCutITSUpper.value[0] : cfgnSigmaITSPionPtUpper.value[currentPtBinPi]; + float nSigmaITSCutKaPtUpper = (currentPtBinKa == -1) ? cfgnSigmaCutITSUpper.value[1] : cfgnSigmaITSKaonPtUpper.value[currentPtBinKa]; + float nSigmaITSCutPrPtUpper = (currentPtBinPr == -1) ? cfgnSigmaCutITSUpper.value[2] : cfgnSigmaITSProtonPtUpper.value[currentPtBinPr]; + float nSigmaITSCutPiPtLower = (currentPtBinPi == -1) ? cfgnSigmaCutITSLower.value[0] : cfgnSigmaITSPionPtLower.value[currentPtBinPi]; + float nSigmaITSCutKaPtLower = (currentPtBinKa == -1) ? cfgnSigmaCutITSLower.value[1] : cfgnSigmaITSKaonPtLower.value[currentPtBinKa]; + float nSigmaITSCutPrPtLower = (currentPtBinPr == -1) ? cfgnSigmaCutITSLower.value[2] : cfgnSigmaITSProtonPtLower.value[currentPtBinPr]; + std::array nSigmaTOFCutPtUpper = {nSigmaTOFCutPiPtUpper, nSigmaTOFCutKaPtUpper, nSigmaTOFCutPrPtUpper}; + std::array nSigmaTPCCutPtUpper = {nSigmaTPCCutPiPtUpper, nSigmaTPCCutKaPtUpper, nSigmaTPCCutPrPtUpper}; + std::array nSigmaTOFCutPtLower = {nSigmaTOFCutPiPtLower, nSigmaTOFCutKaPtLower, nSigmaTOFCutPrPtLower}; + std::array nSigmaTPCCutPtLower = {nSigmaTPCCutPiPtLower, nSigmaTPCCutKaPtLower, nSigmaTPCCutPrPtLower}; + std::array nSigmaITSCutPtUpper = {nSigmaITSCutPiPtUpper, nSigmaITSCutKaPtUpper, nSigmaITSCutPrPtUpper}; + std::array nSigmaITSCutPtLower = {nSigmaITSCutPiPtLower, nSigmaITSCutKaPtLower, nSigmaITSCutPrPtLower}; + const float averClusSizeCosl = averageClusterSizeCosl(track.itsClusterSizes(), track.eta()); + if (!selTrackPid(track)) { + pidFlag = -1; + } else { + if (!cfgQuietMode) { + histosQA.fill(HIST("QA/PID/histdEdxTPC_All"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); + if (cfgOpenTrackingInfoCheck) { + histosQA.fill(HIST("QA/PID/histDCAz_total"), track.dcaZ()); + histosQA.fill(HIST("QA/PID/histDCAxy_total"), track.dcaXY()); + histosQA.fill(HIST("QA/PID/histITSNcls_total"), track.itsNCls()); + histosQA.fill(HIST("QA/PID/histTPCNcls_total"), track.tpcNClsFound()); + histosQA.fill(HIST("QA/PID/histTPCChi2Ncls_total"), track.tpcChi2NCl()); + histosQA.fill(HIST("QA/PID/histITSChi2Ncls_total"), track.itsChi2NCl()); + } + } + pidFlag = selectionPidtpctof(track, nSigmaTOFCutPtUpper, nSigmaTOFCutPtLower, nSigmaTPCCutPtUpper, nSigmaTPCCutPtLower); + if (!(pidFlag == pid_flags::kUnqualified || pidFlag == pid_flags::kUnPOIHadron)) { + // First fill ITS uncut plots + if ((pidFlag == pid_flags::kPion) || (pidFlag == pid_flags::kPionKaon) || (pidFlag == pid_flags::kPionProton) || (pidFlag == pid_flags::kPionKaonProton)) { + if (cfgOpenTPCAssistanceTOFOnlyPID && !(track.tpcNSigmaPi() > nSigmaTPCCutPiPtLower && track.tpcNSigmaPi() < nSigmaTPCCutPiPtUpper)) { + pidFlag = 0; + } + if (cfgOpenPIDPtSelection && !(track.pt() > cfgPtCutLower.value[0] && track.pt() < cfgPtCutUpper.value[0])) { + pidFlag = 0; + } + if (!(cfgQuietMode || pidFlag == pid_flags::kUnPOIHadron)) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_nSigmaTPC_Pi"), track.itsNSigmaPi(), track.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaITS_Pi"), track.tofNSigmaPi(), track.itsNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaTPC_Pi"), track.tofNSigmaPi(), track.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histdEdxTPC_Pi"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); + histosQA.fill(HIST("QA/PID/histnSigma_TPC_Pi"), track.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_TPC_Pt_Pi"), track.pt(), track.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_com_Pi"), std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi())); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pi"), track.tofNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pt_Pi"), track.pt(), track.tofNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pi"), track.itsNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pt_Pi"), track.pt(), track.itsNSigmaPi()); + if (cfgOpenTrackingInfoCheck) { + histosQA.fill(HIST("QA/PID/histDCAz_Pi"), track.dcaZ()); + histosQA.fill(HIST("QA/PID/histDCAxy_Pi"), track.dcaXY()); + histosQA.fill(HIST("QA/PID/histITSNcls_Pi"), track.itsNCls()); + histosQA.fill(HIST("QA/PID/histTPCNcls_Pi"), track.tpcNClsFound()); + histosQA.fill(HIST("QA/PID/histTPCChi2Ncls_Pi"), track.tpcChi2NCl()); + histosQA.fill(HIST("QA/PID/histITSChi2Ncls_Pi"), track.itsChi2NCl()); + } + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_ITS_Pt_Pi"), track.tofNSigmaPi(), track.itsNSigmaPi(), track.pt()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_TPC_Pt_Pi"), track.tofNSigmaPi(), track.tpcNSigmaPi(), track.pt()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_ITS_TPC_Pt_Pi"), track.itsNSigmaPi(), track.tpcNSigmaPi(), track.pt()); + } + if (cfgOpenPlotAverClus) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_Pi"), averClusSizeCosl); + } + if (cfgOpenPlotAverClusP) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_Pi"), track.p(), averClusSizeCosl); + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pi"), track.tpcNSigmaPi(), averClusSizeCosl); + } + if (cfgOpenPlotPhiDis) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pi"), track.phi()); + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pt_Eta_Pi"), track.phi(), track.pt(), track.eta()); + } + if (cfgOpenDetailPlotsTPCITSContaimination) { + if (track.sign() > 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_PosPi_Before"), track.tpcNSigmaPi(), track.itsNSigmaPi(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPi_Before"), track.tpcNSigmaPi(), averClusSizeCosl, track.pt()); + } else if (track.sign() < 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_NegPi_Before"), track.tpcNSigmaPi(), track.itsNSigmaPi(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPi_Before"), track.tpcNSigmaPi(), averClusSizeCosl, track.pt()); + } + } + } + } + if ((pidFlag == pid_flags::kKaon) || (pidFlag == pid_flags::kPionKaon) || (pidFlag == pid_flags::kKaonProton) || (pidFlag == pid_flags::kPionKaonProton)) { + if (cfgOpenTPCAssistanceTOFOnlyPID && !(track.tpcNSigmaKa() > nSigmaTPCCutKaPtLower && track.tpcNSigmaKa() < nSigmaTPCCutKaPtUpper)) { + pidFlag = 0; + } + if (cfgOpenPIDPtSelection && !(track.pt() > cfgPtCutLower.value[1] && track.pt() < cfgPtCutUpper.value[1])) { + pidFlag = 0; + } + if (!(cfgQuietMode || pid_flags::kUnPOIHadron)) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_nSigmaTPC_Ka"), track.itsNSigmaKa(), track.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaITS_Ka"), track.tofNSigmaKa(), track.itsNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaTPC_Ka"), track.tofNSigmaKa(), track.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histdEdxTPC_Ka"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); + histosQA.fill(HIST("QA/PID/histnSigma_TPC_Ka"), track.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_TPC_Pt_Ka"), track.pt(), track.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_com_Ka"), std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa())); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Ka"), track.tofNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pt_Ka"), track.pt(), track.tofNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Ka"), track.itsNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pt_Ka"), track.pt(), track.itsNSigmaKa()); + if (cfgOpenTrackingInfoCheck) { + histosQA.fill(HIST("QA/PID/histDCAz_Ka"), track.dcaZ()); + histosQA.fill(HIST("QA/PID/histDCAxy_Ka"), track.dcaXY()); + histosQA.fill(HIST("QA/PID/histITSNcls_Ka"), track.itsNCls()); + histosQA.fill(HIST("QA/PID/histTPCNcls_Ka"), track.tpcNClsFound()); + histosQA.fill(HIST("QA/PID/histTPCChi2Ncls_Ka"), track.tpcChi2NCl()); + histosQA.fill(HIST("QA/PID/histITSChi2Ncls_Ka"), track.itsChi2NCl()); + } + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_ITS_Pt_Ka"), track.tofNSigmaKa(), track.itsNSigmaKa(), track.pt()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_TPC_Pt_Ka"), track.tofNSigmaKa(), track.tpcNSigmaKa(), track.pt()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_ITS_TPC_Pt_Ka"), track.itsNSigmaKa(), track.tpcNSigmaKa(), track.pt()); + } + if (cfgOpenPlotAverClus) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_Ka"), averClusSizeCosl); + } + if (cfgOpenPlotAverClusP) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_Ka"), track.p(), averClusSizeCosl); + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Ka"), track.tpcNSigmaKa(), averClusSizeCosl); + } + if (cfgOpenPlotPhiDis) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Ka"), track.phi()); + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pt_Eta_Ka"), track.phi(), track.pt(), track.eta()); + } + if (cfgOpenDetailPlotsTPCITSContaimination) { + if (track.sign() > 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_PosKa_Before"), track.tpcNSigmaKa(), track.itsNSigmaKa(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosKa_Before"), track.tpcNSigmaKa(), averClusSizeCosl, track.pt()); + } else if (track.sign() < 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_NegKa_Before"), track.tpcNSigmaKa(), track.itsNSigmaKa(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegKa_Before"), track.tpcNSigmaKa(), averClusSizeCosl, track.pt()); + } + } + } + } + if ((pidFlag == pid_flags::kProton) || (pidFlag == pid_flags::kPionProton) || (pidFlag == pid_flags::kKaonProton) || (pidFlag == pid_flags::kPionKaonProton)) { + if (cfgOpenTPCAssistanceTOFOnlyPID && !(track.tpcNSigmaPr() > nSigmaTPCCutPrPtLower && track.tpcNSigmaPr() < nSigmaTPCCutPrPtUpper)) { + pidFlag = 0; + } + if (cfgOpenPIDPtSelection && !(track.pt() > cfgPtCutLower.value[2] && track.pt() < cfgPtCutUpper.value[2])) { + pidFlag = 0; + } + if (!(cfgQuietMode || pidFlag == pid_flags::kUnPOIHadron)) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_nSigmaTPC_Pr"), track.itsNSigmaPr(), track.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaITS_Pr"), track.tofNSigmaPr(), track.itsNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaTPC_Pr"), track.tofNSigmaPr(), track.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histdEdxTPC_Pr"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); + histosQA.fill(HIST("QA/PID/histnSigma_TPC_Pr"), track.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_TPC_Pt_Pr"), track.pt(), track.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_com_Pr"), std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr())); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pr"), track.tofNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pt_Pr"), track.pt(), track.tofNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pr"), track.itsNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pt_Pr"), track.pt(), track.itsNSigmaPr()); + if (cfgOpenTrackingInfoCheck) { + histosQA.fill(HIST("QA/PID/histDCAz_Pr"), track.dcaZ()); + histosQA.fill(HIST("QA/PID/histDCAxy_Pr"), track.dcaXY()); + histosQA.fill(HIST("QA/PID/histITSNcls_Pr"), track.itsNCls()); + histosQA.fill(HIST("QA/PID/histTPCNcls_Pr"), track.tpcNClsFound()); + histosQA.fill(HIST("QA/PID/histTPCChi2Ncls_Pr"), track.tpcChi2NCl()); + histosQA.fill(HIST("QA/PID/histITSChi2Ncls_Pr"), track.itsChi2NCl()); + } + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_ITS_Pt_Pr"), track.tofNSigmaPr(), track.itsNSigmaPr(), track.pt()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_TPC_Pt_Pr"), track.tofNSigmaPr(), track.tpcNSigmaPr(), track.pt()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_ITS_TPC_Pt_Pr"), track.itsNSigmaPr(), track.tpcNSigmaPr(), track.pt()); + } + if (cfgOpenPlotAverClus) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_Pr"), averClusSizeCosl); + } + if (cfgOpenPlotAverClusP) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_Pr"), track.p(), averClusSizeCosl); + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pr"), track.tpcNSigmaPr(), averClusSizeCosl); + } + if (cfgOpenPlotPhiDis) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pr"), track.phi()); + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pt_Eta_Pr"), track.phi(), track.pt(), track.eta()); + } + if (cfgOpenDetailPlotsTPCITSContaimination) { + if (track.sign() > 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_PosPr_Before"), track.tpcNSigmaPr(), track.itsNSigmaPr(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPr_Before"), track.tpcNSigmaPr(), averClusSizeCosl, track.pt()); + } else if (track.sign() < 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_NegPr_Before"), track.tpcNSigmaPr(), track.itsNSigmaPr(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPr_Before"), track.tpcNSigmaPr(), averClusSizeCosl, track.pt()); + } + } + } + } + // Second proform ITS cut + if (cfgOpenITSCut) { + int idx = -1; + switch (pidFlag) { + case 1: + if (!selectionITS(track, 1, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower)) { + pidFlag = 4; + } + break; + case 2: + if (!selectionITS(track, 2, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower)) { + pidFlag = 5; + } + break; + case 3: + if (!selectionITS(track, 3, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower)) { + pidFlag = 6; + } + break; + case 7: + idx = (selectionITS(track, 1, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower) << 1) | selectionITS(track, 2, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower); + switch (idx) { + case 0: + pidFlag = 11; + break; + + case 1: + pidFlag = 2; + break; + + case 2: + pidFlag = 1; + break; + } + break; + case 8: + idx = (selectionITS(track, 1, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower) << 1) | selectionITS(track, 3, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower); + switch (idx) { + case 0: + pidFlag = 12; + break; + + case 1: + pidFlag = 3; + break; + + case 2: + pidFlag = 1; + break; + } + break; + case 9: + idx = (selectionITS(track, 2, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower) << 1) | selectionITS(track, 3, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower); + switch (idx) { + case 0: + pidFlag = 13; + break; + + case 1: + pidFlag = 3; + break; + + case 2: + pidFlag = 2; + break; + } + break; + case 10: + idx = (selectionITS(track, 1, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower) << 2) | (selectionITS(track, 2, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower) << 1) | selectionITS(track, 3, averClusSizeCosl, nSigmaITSCutPtUpper, nSigmaITSCutPtLower); + switch (idx) { + case 0: + pidFlag = 14; + break; + + case 1: + pidFlag = 3; + break; + + case 2: + pidFlag = 2; + break; + + case 3: + pidFlag = 9; + break; + + case 4: + pidFlag = 1; + break; + + case 5: + pidFlag = 8; + break; + + case 6: + pidFlag = 7; + break; + } + break; + } + } + // Third Fill ITS cut plots + if (cfgOpenITSCutQAPlots) { + if (!cfgQuietMode) { + if (cfgOpenTrackingInfoCheck) { + histosQA.fill(HIST("QA/PID/histDCAz_total_AfterITS"), track.dcaZ()); + histosQA.fill(HIST("QA/PID/histDCAxy_total_AfterITS"), track.dcaXY()); + histosQA.fill(HIST("QA/PID/histITSNcls_total_AfterITS"), track.itsNCls()); + histosQA.fill(HIST("QA/PID/histTPCNcls_total_AfterITS"), track.tpcNClsFound()); + histosQA.fill(HIST("QA/PID/histTPCChi2Ncls_total_AfterITS"), track.tpcChi2NCl()); + histosQA.fill(HIST("QA/PID/histITSChi2Ncls_total_AfterITS"), track.itsChi2NCl()); + } + if ((pidFlag == pid_flags::kPion) || (pidFlag == pid_flags::kPionKaon) || (pidFlag == pid_flags::kPionProton) || (pidFlag == pid_flags::kPionKaonProton)) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_nSigmaTPC_AfterITS_Pi"), track.itsNSigmaPi(), track.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaITS_AfterITS_Pi"), track.tofNSigmaPi(), track.itsNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaTPC_AfterITS_Pi"), track.tofNSigmaPi(), track.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_TPC_Pt_AfterITS_Pi"), track.pt(), track.tpcNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pt_AfterITS_Pi"), track.pt(), track.tofNSigmaPi()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pt_AfterITS_Pi"), track.pt(), track.itsNSigmaPi()); + if (cfgOpenTrackingInfoCheck) { + histosQA.fill(HIST("QA/PID/histDCAz_Pi_AfterITS"), track.dcaZ()); + histosQA.fill(HIST("QA/PID/histDCAxy_Pi_AfterITS"), track.dcaXY()); + histosQA.fill(HIST("QA/PID/histITSNcls_Pi_AfterITS"), track.itsNCls()); + histosQA.fill(HIST("QA/PID/histTPCNcls_Pi_AfterITS"), track.tpcNClsFound()); + histosQA.fill(HIST("QA/PID/histTPCChi2Ncls_Pi_AfterITS"), track.tpcChi2NCl()); + histosQA.fill(HIST("QA/PID/histITSChi2Ncls_Pi_AfterITS"), track.itsChi2NCl()); + } + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_ITS_Pt_AfterITS_Pi"), track.tofNSigmaPi(), track.itsNSigmaPi(), track.pt()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_TPC_Pt_AfterITS_Pi"), track.tofNSigmaPi(), track.tpcNSigmaPi(), track.pt()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_ITS_TPC_Pt_AfterITS_Pi"), track.itsNSigmaPi(), track.tpcNSigmaPi(), track.pt()); + } + if (cfgOpenPlotAverClus) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_AfterITS_Pi"), averClusSizeCosl); + } + if (cfgOpenPlotAverClusP) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_AfterITS_Pi"), track.p(), averClusSizeCosl); + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_AfterITS_Pi"), track.tpcNSigmaPi(), averClusSizeCosl); + } + if (cfgOpenPlotPhiDis) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_AfterITS_Pi"), track.phi()); + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pt_Eta_AfterITS_Pi"), track.phi(), track.pt(), track.eta()); + } + if (cfgOpenDetailPlotsTPCITSContaimination) { + if (track.sign() > 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_PosPi_After"), track.tpcNSigmaPi(), track.itsNSigmaPi(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPi_After"), track.tpcNSigmaPi(), averClusSizeCosl, track.pt()); + } else if (track.sign() < 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_NegPi_After"), track.tpcNSigmaPi(), track.itsNSigmaPi(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPi_After"), track.tpcNSigmaPi(), averClusSizeCosl, track.pt()); + } + } + } + if ((pidFlag == pid_flags::kKaon) || (pidFlag == pid_flags::kPionKaon) || (pidFlag == pid_flags::kKaonProton) || (pidFlag == pid_flags::kPionKaonProton)) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_nSigmaTPC_AfterITS_Ka"), track.itsNSigmaKa(), track.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaITS_AfterITS_Ka"), track.tofNSigmaKa(), track.itsNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaTPC_AfterITS_Ka"), track.tofNSigmaKa(), track.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_TPC_Pt_AfterITS_Ka"), track.pt(), track.tpcNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pt_AfterITS_Ka"), track.pt(), track.tofNSigmaKa()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pt_AfterITS_Ka"), track.pt(), track.itsNSigmaKa()); + if (cfgOpenTrackingInfoCheck) { + histosQA.fill(HIST("QA/PID/histDCAz_Ka_AfterITS"), track.dcaZ()); + histosQA.fill(HIST("QA/PID/histDCAxy_Ka_AfterITS"), track.dcaXY()); + histosQA.fill(HIST("QA/PID/histITSNcls_Ka_AfterITS"), track.itsNCls()); + histosQA.fill(HIST("QA/PID/histTPCNcls_Ka_AfterITS"), track.tpcNClsFound()); + histosQA.fill(HIST("QA/PID/histTPCChi2Ncls_Ka_AfterITS"), track.tpcChi2NCl()); + histosQA.fill(HIST("QA/PID/histITSChi2Ncls_Ka_AfterITS"), track.itsChi2NCl()); + } + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_ITS_Pt_AfterITS_Ka"), track.tofNSigmaKa(), track.itsNSigmaKa(), track.pt()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_TPC_Pt_AfterITS_Ka"), track.tofNSigmaKa(), track.tpcNSigmaKa(), track.pt()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_ITS_TPC_Pt_AfterITS_Ka"), track.itsNSigmaKa(), track.tpcNSigmaKa(), track.pt()); + } + if (cfgOpenPlotAverClus) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_AfterITS_Ka"), averClusSizeCosl); + } + if (cfgOpenPlotAverClusP) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_AfterITS_Ka"), track.p(), averClusSizeCosl); + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_AfterITS_Ka"), track.tpcNSigmaKa(), averClusSizeCosl); + } + if (cfgOpenPlotPhiDis) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_AfterITS_Ka"), track.phi()); + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pt_Eta_AfterITS_Ka"), track.phi(), track.pt(), track.eta()); + } + if (cfgOpenDetailPlotsTPCITSContaimination) { + if (track.sign() > 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_PosKa_After"), track.tpcNSigmaKa(), track.itsNSigmaKa(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosKa_After"), track.tpcNSigmaKa(), averClusSizeCosl, track.pt()); + } else if (track.sign() < 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_NegKa_After"), track.tpcNSigmaKa(), track.itsNSigmaKa(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegKa_After"), track.tpcNSigmaKa(), averClusSizeCosl, track.pt()); + } + } + } + if ((pidFlag == pid_flags::kProton) || (pidFlag == pid_flags::kPionProton) || (pidFlag == pid_flags::kKaonProton) || (pidFlag == pid_flags::kPionKaonProton)) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_nSigmaTPC_AfterITS_Pr"), track.itsNSigmaPr(), track.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaITS_AfterITS_Pr"), track.tofNSigmaPr(), track.itsNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigmaTOF_nSigmaTPC_AfterITS_Pr"), track.tofNSigmaPr(), track.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_TPC_Pt_AfterITS_Pr"), track.pt(), track.tpcNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pt_AfterITS_Pr"), track.pt(), track.tofNSigmaPr()); + histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pt_AfterITS_Pr"), track.pt(), track.itsNSigmaPr()); + if (cfgOpenTrackingInfoCheck) { + histosQA.fill(HIST("QA/PID/histDCAz_Pr_AfterITS"), track.dcaZ()); + histosQA.fill(HIST("QA/PID/histDCAxy_Pr_AfterITS"), track.dcaXY()); + histosQA.fill(HIST("QA/PID/histITSNcls_Pr_AfterITS"), track.itsNCls()); + histosQA.fill(HIST("QA/PID/histTPCNcls_Pr_AfterITS"), track.tpcNClsFound()); + histosQA.fill(HIST("QA/PID/histTPCChi2Ncls_Pr_AfterITS"), track.tpcChi2NCl()); + histosQA.fill(HIST("QA/PID/histITSChi2Ncls_Pr_AfterITS"), track.itsChi2NCl()); + } + if (cfgOpenPlotnSigmaTOFITSPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_ITS_Pt_AfterITS_Pr"), track.tofNSigmaPr(), track.itsNSigmaPr(), track.pt()); + } + if (cfgOpenPlotnSigmaTOFTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_TOF_TPC_Pt_AfterITS_Pr"), track.tofNSigmaPr(), track.tpcNSigmaPr(), track.pt()); + } + if (cfgOpenPlotnSigmaITSTPCPt) { + histosQA.fill(HIST("QA/PID/histnSigma_ITS_TPC_Pt_AfterITS_Pr"), track.itsNSigmaPr(), track.tpcNSigmaPr(), track.pt()); + } + if (cfgOpenPlotAverClus) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_AfterITS_Pr"), averClusSizeCosl); + } + if (cfgOpenPlotAverClusP) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_AfterITS_Pr"), track.p(), averClusSizeCosl); + } + if (cfgOpenPlotAverClusnSigmaTPC) { + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_AfterITS_Pr"), track.tpcNSigmaPr(), averClusSizeCosl); + } + if (cfgOpenPlotPhiDis) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_AfterITS_Pr"), track.phi()); + } + if (cfgOpenPlotPhiDisPtEta) { + histosQA.fill(HIST("QA/PID/histPhi_Dis_Pt_Eta_AfterITS_Pr"), track.phi(), track.pt(), track.eta()); + } + if (cfgOpenDetailPlotsTPCITSContaimination) { + if (track.sign() > 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_PosPr_After"), track.tpcNSigmaPr(), track.itsNSigmaPr(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPr_After"), track.tpcNSigmaPr(), averClusSizeCosl, track.pt()); + } else if (track.sign() < 0) { + histosQA.fill(HIST("QA/PID/histnSigmaITS_TPC_Pt_NegPr_After"), track.tpcNSigmaPr(), track.itsNSigmaPr(), track.pt()); + histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPr_After"), track.tpcNSigmaPr(), averClusSizeCosl, track.pt()); + } + } + } + } + } + } + } + pidCmeTable(pidFlag); + pidInfoTable(averClusSizeCosl, track.itsNSigmaPi(), track.itsNSigmaKa(), track.itsNSigmaPr(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()); + } + } +}; + +struct QAProcessCent { + HistogramRegistry histosQA{"histosQAwithcent", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable> cfgCentralitybinsforQA{"cfgCentralitybinsforQA", {0, 30, 60}, "Centrality bins for track phi and TPC_ITS matching check"}; + Configurable cfgOpenDetailPlots{"cfgOpenDetailPlots", true, "open detail TH3D plots for nSigmaTPC-ITS Pt-eta-Phi nSigmaITS-clustersize"}; + Configurable cfgOpenITSafter{"cfgOpenITSafter", true, "open check for after ITS cut check(if used ITScut in table producer it need else close to save cpu usage)"}; + Configurable cfgOpenPtEtaPhi{"cfgOpenPtEtaPhi", true, "open pt-#eta-#phi PID QA (Optional for limited memory usage)"}; + Configurable cfgOpenITSTPCnSigma{"cfgOpenITSTPCnSigma", true, "open ITS-TPC nSigma QA (Optional for limited memory usage)"}; + Configurable cfgOpenClusSizenSigmaTPC{"cfgOpenClusSizenSigmaTPC", true, "open ITSClustersize-TPCnsigma QA (Optional for limited memory usage)"}; + Configurable cfgOpenPi{"cfgOpenPi", true, "open Pion QA (Optional for limited memory usage)"}; + Configurable cfgOpenKa{"cfgOpenKa", true, "open Kaon QA (Optional for limited memory usage)"}; + Configurable cfgOpenPr{"cfgOpenPr", true, "open Proton QA (Optional for limited memory usage)"}; + Configurable cfgOpenTOFITSnSigma{"cfgOpenTOFITSnSigma", false, "open TOF-ITS nsigma 2D plots vs pt at a certain centrality"}; + Configurable cfgOpenTOFTPCnSigma{"cfgOpenTOFTPCnSigma", false, "open TOF-TPC nsigma 2D plots vs pt at a certain centrality"}; + ConfigurableAxis cfgaxisetaPID{"cfgaxisetaPID", {90, -0.9, 0.9}, "Binning for Pt QA"}; + ConfigurableAxis cfgaxisptPID{"cfgaxisptPID", {120, 0, 12}, "Binning for P_{t} PID"}; + ConfigurableAxis cfgnSigmaBinsTPC{"cfgnSigmaBinsTPC", {200, -5.f, 5.f}, "Binning for n sigma TPC"}; + ConfigurableAxis cfgnSigmaBinsITS{"cfgnSigmaBinsITS", {200, -5.f, 5.f}, "Binning for n sigma ITS"}; + ConfigurableAxis cfgnSigmaBinsTOF{"cfgnSigmaBinsTOF", {200, -5.f, 5.f}, "Binning for n sigma TOF"}; + ConfigurableAxis cfgaxisAverClusterCoslnSigma{"cfgaxisAverClusterCoslnSigma", {50, 0, 5}, "Binning for average cluster size x cos(#lambda) vs nSigam"}; + + std::vector> vhistPhiPtEtaPosPiCen; + std::vector> vhistPhiPtEtaNegPiCen; + std::vector> vhistPhiPtEtaPosKaCen; + std::vector> vhistPhiPtEtaNegKaCen; + std::vector> vhistPhiPtEtaPosPrCen; + std::vector> vhistPhiPtEtaNegPrCen; + std::vector> vhistnSigmaITSTPCPtPosPiBeforeCen; + std::vector> vhistnSigmaITSTPCPtNegPiBeforeCen; + std::vector> vhistnSigmaITSTPCPtPosKaBeforeCen; + std::vector> vhistnSigmaITSTPCPtNegKaBeforeCen; + std::vector> vhistnSigmaITSTPCPtPosPrBeforeCen; + std::vector> vhistnSigmaITSTPCPtNegPrBeforeCen; + std::vector> vhistnSigmaITSTPCPtPosPiAfterCen; + std::vector> vhistnSigmaITSTPCPtNegPiAfterCen; + std::vector> vhistnSigmaITSTPCPtPosKaAfterCen; + std::vector> vhistnSigmaITSTPCPtNegKaAfterCen; + std::vector> vhistnSigmaITSTPCPtPosPrAfterCen; + std::vector> vhistnSigmaITSTPCPtNegPrAfterCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtPosPiBeforeCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtNegPiBeforeCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtPosKaBeforeCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtNegKaBeforeCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtPosPrBeforeCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtNegPrBeforeCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtPosPiAfterCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtNegPiAfterCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtPosKaAfterCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtNegKaAfterCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtPosPrAfterCen; + std::vector> vhistAverClusterSizeCoslnSigmaTPCPtNegPrAfterCen; + std::vector> vhistnSigmaTOFITSPtPosPiBeforeCen; + std::vector> vhistnSigmaTOFITSPtNegPiBeforeCen; + std::vector> vhistnSigmaTOFITSPtPosKaBeforeCen; + std::vector> vhistnSigmaTOFITSPtNegKaBeforeCen; + std::vector> vhistnSigmaTOFITSPtPosPrBeforeCen; + std::vector> vhistnSigmaTOFITSPtNegPrBeforeCen; + std::vector> vhistnSigmaTOFITSPtPosPiAfterCen; + std::vector> vhistnSigmaTOFITSPtNegPiAfterCen; + std::vector> vhistnSigmaTOFITSPtPosKaAfterCen; + std::vector> vhistnSigmaTOFITSPtNegKaAfterCen; + std::vector> vhistnSigmaTOFITSPtPosPrAfterCen; + std::vector> vhistnSigmaTOFITSPtNegPrAfterCen; + std::vector> vhistnSigmaTOFTPCPtPosPiBeforeCen; + std::vector> vhistnSigmaTOFTPCPtNegPiBeforeCen; + std::vector> vhistnSigmaTOFTPCPtPosKaBeforeCen; + std::vector> vhistnSigmaTOFTPCPtNegKaBeforeCen; + std::vector> vhistnSigmaTOFTPCPtPosPrBeforeCen; + std::vector> vhistnSigmaTOFTPCPtNegPrBeforeCen; + std::vector> vhistnSigmaTOFTPCPtPosPiAfterCen; + std::vector> vhistnSigmaTOFTPCPtNegPiAfterCen; + std::vector> vhistnSigmaTOFTPCPtPosKaAfterCen; + std::vector> vhistnSigmaTOFTPCPtNegKaAfterCen; + std::vector> vhistnSigmaTOFTPCPtPosPrAfterCen; + std::vector> vhistnSigmaTOFTPCPtNegPrAfterCen; + Filter trackPIDfilter = aod::cme_track_pid_columns::nPidFlag > (int8_t)0; + void init(InitContext const&) + { + AxisSpec axisPhicme = {100, 0, 2.1 * constants::math::PI, "#phi"}; + // Additional QA histograms for PID + if (cfgOpenDetailPlots) { + for (int i = 0; i < static_cast(cfgCentralitybinsforQA.value.size()) - 1; ++i) { + if (cfgOpenPtEtaPhi) { + if (cfgOpenPi) { + auto hPhiPtEtaPosPi = histosQA.add(Form("QA/PID/histPhi_Pt_Eta_PosPi_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";#phi;#p_{t};#eta", {HistType::kTH3F, {axisPhicme, cfgaxisptPID, cfgaxisetaPID}}); + auto hPhiPtEtaNegPi = histosQA.add(Form("QA/PID/histPhi_Pt_Eta_NegPi_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";#phi;#p_{t};#eta", {HistType::kTH3F, {axisPhicme, cfgaxisptPID, cfgaxisetaPID}}); + vhistPhiPtEtaPosPiCen.push_back(std::move(hPhiPtEtaPosPi)); + vhistPhiPtEtaNegPiCen.push_back(std::move(hPhiPtEtaNegPi)); + } + if (cfgOpenKa) { + auto hPhiPtEtaPosKa = histosQA.add(Form("QA/PID/histPhi_Pt_Eta_PosKa_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";#phi;#p_{t};#eta", {HistType::kTH3F, {axisPhicme, cfgaxisptPID, cfgaxisetaPID}}); + auto hPhiPtEtaNegKa = histosQA.add(Form("QA/PID/histPhi_Pt_Eta_NegKa_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";#phi;#p_{t};#eta", {HistType::kTH3F, {axisPhicme, cfgaxisptPID, cfgaxisetaPID}}); + vhistPhiPtEtaPosKaCen.push_back(std::move(hPhiPtEtaPosKa)); + vhistPhiPtEtaNegKaCen.push_back(std::move(hPhiPtEtaNegKa)); + } + if (cfgOpenPr) { + auto hPhiPtEtaPosPr = histosQA.add(Form("QA/PID/histPhi_Pt_Eta_PosPr_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";#phi;#p_{t};#eta", {HistType::kTH3F, {axisPhicme, cfgaxisptPID, cfgaxisetaPID}}); + auto hPhiPtEtaNegPr = histosQA.add(Form("QA/PID/histPhi_Pt_Eta_NegPr_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";#phi;#p_{t};#eta", {HistType::kTH3F, {axisPhicme, cfgaxisptPID, cfgaxisetaPID}}); + vhistPhiPtEtaPosPrCen.push_back(std::move(hPhiPtEtaPosPr)); + vhistPhiPtEtaNegPrCen.push_back(std::move(hPhiPtEtaNegPr)); + } + } + if (cfgOpenITSTPCnSigma) { + if (cfgOpenPi) { + auto hnSigmaITSTPCPtPosPiBefore = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosPi_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaITSTPCPtNegPiBefore = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegPi_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaITSTPCPtPosPiBeforeCen.push_back(std::move(hnSigmaITSTPCPtPosPiBefore)); + vhistnSigmaITSTPCPtNegPiBeforeCen.push_back(std::move(hnSigmaITSTPCPtNegPiBefore)); + if (cfgOpenITSafter) { + auto hnSigmaITSTPCPtPosPiAfter = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosPi_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaITSTPCPtNegPiAfter = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegPi_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaITSTPCPtPosPiAfterCen.push_back(std::move(hnSigmaITSTPCPtPosPiAfter)); + vhistnSigmaITSTPCPtNegPiAfterCen.push_back(std::move(hnSigmaITSTPCPtNegPiAfter)); + } + } + if (cfgOpenKa) { + auto hnSigmaITSTPCPtPosKaBefore = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosKa_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaITSTPCPtNegKaBefore = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegKa_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaITSTPCPtPosKaBeforeCen.push_back(std::move(hnSigmaITSTPCPtPosKaBefore)); + vhistnSigmaITSTPCPtNegKaBeforeCen.push_back(std::move(hnSigmaITSTPCPtNegKaBefore)); + if (cfgOpenITSafter) { + auto hnSigmaITSTPCPtPosKaAfter = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosKa_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaITSTPCPtNegKaAfter = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegKa_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaITSTPCPtPosKaAfterCen.push_back(std::move(hnSigmaITSTPCPtPosKaAfter)); + vhistnSigmaITSTPCPtNegKaAfterCen.push_back(std::move(hnSigmaITSTPCPtNegKaAfter)); + } + } + if (cfgOpenPr) { + auto hnSigmaITSTPCPtPosPrBefore = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosPr_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaITSTPCPtNegPrBefore = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegPr_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaITSTPCPtPosPrBeforeCen.push_back(std::move(hnSigmaITSTPCPtPosPrBefore)); + vhistnSigmaITSTPCPtNegPrBeforeCen.push_back(std::move(hnSigmaITSTPCPtNegPrBefore)); + if (cfgOpenITSafter) { + auto hnSigmaITSTPCPtPosPrAfter = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_PosPr_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaITSTPCPtNegPrAfter = histosQA.add(Form("QA/PID/histnSigmaITS_TPC_Pt_NegPr_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaITSTPCPtPosPrAfterCen.push_back(std::move(hnSigmaITSTPCPtPosPrAfter)); + vhistnSigmaITSTPCPtNegPrAfterCen.push_back(std::move(hnSigmaITSTPCPtNegPrAfter)); + } + } + } + if (cfgOpenClusSizenSigmaTPC) { + if (cfgOpenPi) { + auto hAverClusterSizeCoslnSigmaTPCPtPosPiBefore = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPi_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + auto hAverClusterSizeCoslnSigmaTPCPtNegPiBefore = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPi_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + vhistAverClusterSizeCoslnSigmaTPCPtPosPiBeforeCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtPosPiBefore)); + vhistAverClusterSizeCoslnSigmaTPCPtNegPiBeforeCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtNegPiBefore)); + if (cfgOpenITSafter) { + auto hAverClusterSizeCoslnSigmaTPCPtPosPiAfter = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPi_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + auto hAverClusterSizeCoslnSigmaTPCPtNegPiAfter = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPi_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + vhistAverClusterSizeCoslnSigmaTPCPtPosPiAfterCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtPosPiAfter)); + vhistAverClusterSizeCoslnSigmaTPCPtNegPiAfterCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtNegPiAfter)); + } + } + if (cfgOpenKa) { + auto hAverClusterSizeCoslnSigmaTPCPtPosKaBefore = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosKa_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + auto hAverClusterSizeCoslnSigmaTPCPtNegKaBefore = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegKa_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + vhistAverClusterSizeCoslnSigmaTPCPtPosKaBeforeCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtPosKaBefore)); + vhistAverClusterSizeCoslnSigmaTPCPtNegKaBeforeCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtNegKaBefore)); + if (cfgOpenITSafter) { + auto hAverClusterSizeCoslnSigmaTPCPtPosKaAfter = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosKa_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + auto hAverClusterSizeCoslnSigmaTPCPtNegKaAfter = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegKa_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + vhistAverClusterSizeCoslnSigmaTPCPtPosKaAfterCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtPosKaAfter)); + vhistAverClusterSizeCoslnSigmaTPCPtNegKaAfterCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtNegKaAfter)); + } + } + if (cfgOpenPr) { + auto hAverClusterSizeCoslnSigmaTPCPtPosPrBefore = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPr_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + auto hAverClusterSizeCoslnSigmaTPCPtNegPrBefore = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPr_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + vhistAverClusterSizeCoslnSigmaTPCPtPosPrBeforeCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtPosPrBefore)); + vhistAverClusterSizeCoslnSigmaTPCPtNegPrBeforeCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtNegPrBefore)); + if (cfgOpenITSafter) { + auto hAverClusterSizeCoslnSigmaTPCPtPosPrAfter = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_PosPr_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + auto hAverClusterSizeCoslnSigmaTPCPtNegPrAfter = histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pt_NegPr_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TPC}; x ;#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgaxisAverClusterCoslnSigma, cfgaxisptPID}}); + vhistAverClusterSizeCoslnSigmaTPCPtPosPrAfterCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtPosPrAfter)); + vhistAverClusterSizeCoslnSigmaTPCPtNegPrAfterCen.push_back(std::move(hAverClusterSizeCoslnSigmaTPCPtNegPrAfter)); + } + } + } + if (cfgOpenTOFITSnSigma) { + if (cfgOpenPi) { + auto hnSigmaTOFITSPtPosPiBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_PosPi_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaTOFITSPtNegPiBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_NegPi_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaTOFITSPtPosPiBeforeCen.push_back(std::move(hnSigmaTOFITSPtPosPiBefore)); + vhistnSigmaTOFITSPtNegPiBeforeCen.push_back(std::move(hnSigmaTOFITSPtNegPiBefore)); + if (cfgOpenITSafter) { + auto hnSigmaTOFITSPtPosPiAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_PosPi_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaTOFITSPtNegPiAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_NegPi_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaTOFITSPtPosPiAfterCen.push_back(std::move(hnSigmaTOFITSPtPosPiAfter)); + vhistnSigmaTOFITSPtNegPiAfterCen.push_back(std::move(hnSigmaTOFITSPtNegPiAfter)); + } + } + if (cfgOpenKa) { + auto hnSigmaTOFITSPtPosKaBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_PosKa_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaTOFITSPtNegKaBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_NegKa_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaTOFITSPtPosKaBeforeCen.push_back(std::move(hnSigmaTOFITSPtPosKaBefore)); + vhistnSigmaTOFITSPtNegKaBeforeCen.push_back(std::move(hnSigmaTOFITSPtNegKaBefore)); + if (cfgOpenITSafter) { + auto hnSigmaTOFITSPtPosKaAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_PosKa_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaTOFITSPtNegKaAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_NegKa_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaTOFITSPtPosKaAfterCen.push_back(std::move(hnSigmaTOFITSPtPosKaAfter)); + vhistnSigmaTOFITSPtNegKaAfterCen.push_back(std::move(hnSigmaTOFITSPtNegKaAfter)); + } + } + if (cfgOpenPr) { + auto hnSigmaTOFITSPtPosPrBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_PosPr_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaTOFITSPtNegPrBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_NegPr_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaTOFITSPtPosPrBeforeCen.push_back(std::move(hnSigmaTOFITSPtPosPrBefore)); + vhistnSigmaTOFITSPtNegPrBeforeCen.push_back(std::move(hnSigmaTOFITSPtNegPrBefore)); + if (cfgOpenITSafter) { + auto hnSigmaTOFITSPtPosPrAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_PosPr_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + auto hnSigmaTOFITSPtNegPrAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_ITS_Pt_NegPr_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsITS, cfgaxisptPID}}); + vhistnSigmaTOFITSPtPosPrAfterCen.push_back(std::move(hnSigmaTOFITSPtPosPrAfter)); + vhistnSigmaTOFITSPtNegPrAfterCen.push_back(std::move(hnSigmaTOFITSPtNegPrAfter)); + } + } + } + if (cfgOpenTOFTPCnSigma) { + if (cfgOpenPi) { + auto hnSigmaTOFTPCPtPosPiBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_PosPi_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + auto hnSigmaTOFTPCPtNegPiBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_NegPi_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + vhistnSigmaTOFTPCPtPosPiBeforeCen.push_back(std::move(hnSigmaTOFTPCPtPosPiBefore)); + vhistnSigmaTOFTPCPtNegPiBeforeCen.push_back(std::move(hnSigmaTOFTPCPtNegPiBefore)); + if (cfgOpenITSafter) { + auto hnSigmaTOFTPCPtPosPiAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_PosPi_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + auto hnSigmaTOFTPCPtNegPiAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_NegPi_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + vhistnSigmaTOFTPCPtPosPiAfterCen.push_back(std::move(hnSigmaTOFTPCPtPosPiAfter)); + vhistnSigmaTOFTPCPtNegPiAfterCen.push_back(std::move(hnSigmaTOFTPCPtNegPiAfter)); + } + } + if (cfgOpenKa) { + auto hnSigmaTOFTPCPtPosKaBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_PosKa_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + auto hnSigmaTOFTPCPtNegKaBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_NegKa_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + vhistnSigmaTOFTPCPtPosKaBeforeCen.push_back(std::move(hnSigmaTOFTPCPtPosKaBefore)); + vhistnSigmaTOFTPCPtNegKaBeforeCen.push_back(std::move(hnSigmaTOFTPCPtNegKaBefore)); + if (cfgOpenITSafter) { + auto hnSigmaTOFTPCPtPosKaAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_PosKa_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + auto hnSigmaTOFTPCPtNegKaAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_NegKa_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + vhistnSigmaTOFTPCPtPosKaAfterCen.push_back(std::move(hnSigmaTOFTPCPtPosKaAfter)); + vhistnSigmaTOFTPCPtNegKaAfterCen.push_back(std::move(hnSigmaTOFTPCPtNegKaAfter)); + } + } + if (cfgOpenPr) { + auto hnSigmaTOFTPCPtPosPrBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_PosPr_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + auto hnSigmaTOFTPCPtNegPrBefore = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_NegPr_Before_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + vhistnSigmaTOFTPCPtPosPrBeforeCen.push_back(std::move(hnSigmaTOFTPCPtPosPrBefore)); + vhistnSigmaTOFTPCPtNegPrBeforeCen.push_back(std::move(hnSigmaTOFTPCPtNegPrBefore)); + if (cfgOpenITSafter) { + auto hnSigmaTOFTPCPtPosPrAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_PosPr_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + auto hnSigmaTOFTPCPtNegPrAfter = histosQA.add(Form("QA/PID/histnSigmaTOF_TPC_Pt_NegPr_After_Cen_%d_%d", cfgCentralitybinsforQA.value[i], cfgCentralitybinsforQA.value[i + 1]), ";n#sigma_{TOF};n#sigma_{TPC};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTOF, cfgnSigmaBinsTPC, cfgaxisptPID}}); + vhistnSigmaTOFTPCPtPosPrAfterCen.push_back(std::move(hnSigmaTOFTPCPtPosPrAfter)); + vhistnSigmaTOFTPCPtNegPrAfterCen.push_back(std::move(hnSigmaTOFTPCPtNegPrAfter)); + } + } + } + } + } + } + void process(CollisionPID::iterator const& collision, soa::Filtered> const& tracks) + { + if (cfgOpenDetailPlots) { + const auto cent = collision.centFT0C(); + int currentBin = -1; + for (int i = 0; i < static_cast(cfgCentralitybinsforQA.value.size()) - 1; ++i) { + if (cent >= cfgCentralitybinsforQA.value[i] && cent < cfgCentralitybinsforQA.value[i + 1]) { + currentBin = i; + break; + } + } + if (currentBin >= 0) { + for (const auto& trk : tracks) { + int8_t pidFlag = trk.nPidFlag(); + if (cfgOpenPi) { + if ((pidFlag == pid_flags::kPion) || (pidFlag == pid_flags::kPionITSleft) || (pidFlag == pid_flags::kPionKaon) || (pidFlag == pid_flags::kPionProton) || (pidFlag == pid_flags::kPionKaonProton) || (pidFlag == pid_flags::kPionKaonITSleft) || (pidFlag == pid_flags::kPionProtonITSleft) || (pidFlag == pid_flags::kPionKaonProtonITSleft)) { + if (trk.sign() > 0) { + if (!((pidFlag == pid_flags::kPionITSleft) || (pidFlag == pid_flags::kPionKaonITSleft) || (pidFlag == pid_flags::kPionProtonITSleft) || (pidFlag == pid_flags::kPionKaonProtonITSleft))) { + if (cfgOpenPtEtaPhi) { + vhistPhiPtEtaPosPiCen[currentBin]->Fill(trk.phi(), trk.pt(), trk.eta()); + } + if (cfgOpenITSafter) { + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtPosPiAfterCen[currentBin]->Fill(trk.nSigmaPiTPC(), trk.nSigmaPiITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtPosPiAfterCen[currentBin]->Fill(trk.nSigmaPiTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtPosPiAfterCen[currentBin]->Fill(trk.nSigmaPiTOF(), trk.nSigmaPiITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtPosPiAfterCen[currentBin]->Fill(trk.nSigmaPiTOF(), trk.nSigmaPiTPC(), trk.pt()); + } + } + } + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtPosPiBeforeCen[currentBin]->Fill(trk.nSigmaPiTPC(), trk.nSigmaPiITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtPosPiBeforeCen[currentBin]->Fill(trk.nSigmaPiTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtPosPiBeforeCen[currentBin]->Fill(trk.nSigmaPiTOF(), trk.nSigmaPiITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtPosPiBeforeCen[currentBin]->Fill(trk.nSigmaPiTOF(), trk.nSigmaPiTPC(), trk.pt()); + } + } else if (trk.sign() < 0) { + if (!((pidFlag == pid_flags::kPionITSleft) || (pidFlag == pid_flags::kPionKaonITSleft) || (pidFlag == pid_flags::kPionProtonITSleft) || (pidFlag == pid_flags::kPionKaonProtonITSleft))) { + if (cfgOpenPtEtaPhi) { + vhistPhiPtEtaNegPiCen[currentBin]->Fill(trk.phi(), trk.pt(), trk.eta()); + } + if (cfgOpenITSafter) { + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtNegPiAfterCen[currentBin]->Fill(trk.nSigmaPiTPC(), trk.nSigmaPiITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtNegPiAfterCen[currentBin]->Fill(trk.nSigmaPiTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtNegPiAfterCen[currentBin]->Fill(trk.nSigmaPiTOF(), trk.nSigmaPiITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtNegPiAfterCen[currentBin]->Fill(trk.nSigmaPiTOF(), trk.nSigmaPiTPC(), trk.pt()); + } + } + } + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtNegPiBeforeCen[currentBin]->Fill(trk.nSigmaPiTPC(), trk.nSigmaPiITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtNegPiBeforeCen[currentBin]->Fill(trk.nSigmaPiTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtNegPiBeforeCen[currentBin]->Fill(trk.nSigmaPiTOF(), trk.nSigmaPiITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtNegPiBeforeCen[currentBin]->Fill(trk.nSigmaPiTOF(), trk.nSigmaPiTPC(), trk.pt()); + } + } + } + } + if (cfgOpenKa) { + if ((pidFlag == pid_flags::kKaon) || (pidFlag == pid_flags::kKaonITSleft) || (pidFlag == pid_flags::kPionKaon) || (pidFlag == pid_flags::kKaonProton) || (pidFlag == pid_flags::kPionKaonProton) || (pidFlag == pid_flags::kPionKaonITSleft) || (pidFlag == pid_flags::kKaonProtonITSleft) || (pidFlag == pid_flags::kPionKaonProtonITSleft)) { + if (trk.sign() > 0) { + if (!((pidFlag == pid_flags::kKaonITSleft) || (pidFlag == pid_flags::kPionKaonITSleft) || (pidFlag == pid_flags::kKaonProtonITSleft) || (pidFlag == pid_flags::kPionKaonProtonITSleft))) { + if (cfgOpenPtEtaPhi) { + vhistPhiPtEtaPosKaCen[currentBin]->Fill(trk.phi(), trk.pt(), trk.eta()); + } + if (cfgOpenITSafter) { + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtPosKaAfterCen[currentBin]->Fill(trk.nSigmaKaTPC(), trk.nSigmaKaITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtPosKaAfterCen[currentBin]->Fill(trk.nSigmaKaTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtPosKaAfterCen[currentBin]->Fill(trk.nSigmaKaTOF(), trk.nSigmaKaITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtPosKaAfterCen[currentBin]->Fill(trk.nSigmaKaTOF(), trk.nSigmaKaTPC(), trk.pt()); + } + } + } + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtPosKaBeforeCen[currentBin]->Fill(trk.nSigmaKaTPC(), trk.nSigmaKaITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtPosKaBeforeCen[currentBin]->Fill(trk.nSigmaKaTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtPosKaBeforeCen[currentBin]->Fill(trk.nSigmaKaTOF(), trk.nSigmaKaITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtPosKaBeforeCen[currentBin]->Fill(trk.nSigmaKaTOF(), trk.nSigmaKaTPC(), trk.pt()); + } + } else if (trk.sign() < 0) { + if (!((pidFlag == pid_flags::kKaonITSleft) || (pidFlag == pid_flags::kPionKaonITSleft) || (pidFlag == pid_flags::kKaonProtonITSleft) || (pidFlag == pid_flags::kPionKaonProtonITSleft))) { + if (cfgOpenPtEtaPhi) { + vhistPhiPtEtaNegKaCen[currentBin]->Fill(trk.phi(), trk.pt(), trk.eta()); + } + if (cfgOpenITSafter) { + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtNegKaAfterCen[currentBin]->Fill(trk.nSigmaKaTPC(), trk.nSigmaKaITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtNegKaAfterCen[currentBin]->Fill(trk.nSigmaKaTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtNegKaAfterCen[currentBin]->Fill(trk.nSigmaKaTOF(), trk.nSigmaKaITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtNegKaAfterCen[currentBin]->Fill(trk.nSigmaKaTOF(), trk.nSigmaKaTPC(), trk.pt()); + } + } + } + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtNegKaBeforeCen[currentBin]->Fill(trk.nSigmaKaTPC(), trk.nSigmaKaITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtNegKaBeforeCen[currentBin]->Fill(trk.nSigmaKaTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtNegKaBeforeCen[currentBin]->Fill(trk.nSigmaKaTOF(), trk.nSigmaKaITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtNegKaBeforeCen[currentBin]->Fill(trk.nSigmaKaTOF(), trk.nSigmaKaTPC(), trk.pt()); + } + } + } + } + if (cfgOpenPr) { + if ((pidFlag == pid_flags::kProton) || (pidFlag == pid_flags::kProtonITSleft) || (pidFlag == pid_flags::kPionProton) || (pidFlag == pid_flags::kKaonProton) || (pidFlag == pid_flags::kPionKaonProton) || (pidFlag == pid_flags::kPionProtonITSleft) || (pidFlag == pid_flags::kKaonProtonITSleft) || (pidFlag == pid_flags::kPionKaonProtonITSleft)) { + if (trk.sign() > 0) { + if (!((pidFlag == pid_flags::kProtonITSleft) || (pidFlag == pid_flags::kPionProtonITSleft) || (pidFlag == pid_flags::kKaonProtonITSleft) || (pidFlag == pid_flags::kPionKaonProtonITSleft))) { + if (cfgOpenPtEtaPhi) { + vhistPhiPtEtaPosPrCen[currentBin]->Fill(trk.phi(), trk.pt(), trk.eta()); + } + if (cfgOpenITSafter) { + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtPosPrAfterCen[currentBin]->Fill(trk.nSigmaPrTPC(), trk.nSigmaPrITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtPosPrAfterCen[currentBin]->Fill(trk.nSigmaPrTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtPosPrAfterCen[currentBin]->Fill(trk.nSigmaPrTOF(), trk.nSigmaPrITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtPosPrAfterCen[currentBin]->Fill(trk.nSigmaPrTOF(), trk.nSigmaPrTPC(), trk.pt()); + } + } + } + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtPosPrBeforeCen[currentBin]->Fill(trk.nSigmaPrTPC(), trk.nSigmaPrITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtPosPrBeforeCen[currentBin]->Fill(trk.nSigmaPrTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtPosPrBeforeCen[currentBin]->Fill(trk.nSigmaPrTOF(), trk.nSigmaPrITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtPosPrBeforeCen[currentBin]->Fill(trk.nSigmaPrTOF(), trk.nSigmaPrTPC(), trk.pt()); + } + } else if (trk.sign() < 0) { + if (!((pidFlag == pid_flags::kProtonITSleft) || (pidFlag == pid_flags::kPionProtonITSleft) || (pidFlag == pid_flags::kKaonProtonITSleft) || (pidFlag == pid_flags::kPionKaonProtonITSleft))) { + if (cfgOpenPtEtaPhi) { + vhistPhiPtEtaNegPrCen[currentBin]->Fill(trk.phi(), trk.pt(), trk.eta()); + } + if (cfgOpenITSafter) { + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtNegPrAfterCen[currentBin]->Fill(trk.nSigmaPrTPC(), trk.nSigmaPrITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtNegPrAfterCen[currentBin]->Fill(trk.nSigmaPrTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtNegPrAfterCen[currentBin]->Fill(trk.nSigmaPrTOF(), trk.nSigmaPrITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtNegPrAfterCen[currentBin]->Fill(trk.nSigmaPrTOF(), trk.nSigmaPrTPC(), trk.pt()); + } + } + } + if (cfgOpenITSTPCnSigma) { + vhistnSigmaITSTPCPtNegPrBeforeCen[currentBin]->Fill(trk.nSigmaPrTPC(), trk.nSigmaPrITS(), trk.pt()); + } + if (cfgOpenClusSizenSigmaTPC) { + vhistAverClusterSizeCoslnSigmaTPCPtNegPrBeforeCen[currentBin]->Fill(trk.nSigmaPrTPC(), trk.averClusterSizeCosl(), trk.pt()); + } + if (cfgOpenTOFITSnSigma) { + vhistnSigmaTOFITSPtNegPrBeforeCen[currentBin]->Fill(trk.nSigmaPrTOF(), trk.nSigmaPrITS(), trk.pt()); + } + if (cfgOpenTOFTPCnSigma) { + vhistnSigmaTOFTPCPtNegPrBeforeCen[currentBin]->Fill(trk.nSigmaPrTOF(), trk.nSigmaPrTPC(), trk.pt()); + } + } + } + } + } + } + } + } +}; + +struct FlowPidCme { + HistogramRegistry histosQA{"histosmain", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Configurable> cfgnMods{"cfgnMods", {2}, "Modulation of interest"}; + Configurable cfgDetName{"cfgDetName", "FT0C", "The name of detector to be analyzed"}; + Configurable cfgRefAName{"cfgRefAName", "TPCpos", "The name of detector for reference A"}; + Configurable cfgRefBName{"cfgRefBName", "TPCneg", "The name of detector for reference B"}; + + Configurable cfgnTotalSystem{"cfgnTotalSystem", 7, "total qvector number"}; + Configurable cfgCutOccupancyLow{"cfgCutOccupancyLow", 0, "Low boundary cut on TPC occupancy"}; + Configurable cfgCutOccupancyHigh{"cfgCutOccupancyHigh", 3000, "High boundary cut on TPC occupancy"}; + + Configurable cfgVtzCut{"cfgVtzCut", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCentMin{"cfgCentMin", 0.0f, "Centrality min"}; + Configurable cfgCentMax{"cfgCentMax", 100.0f, "Centrality max"}; + Configurable cfgMinPt{"cfgMinPt", 0.15, "Minimum transverse momentum for charged track"}; + Configurable cfgMaxEta{"cfgMaxEta", 0.8, "Maximum pseudorapidiy for charged track"}; + Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.1, "Maximum transverse DCA"}; + Configurable cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 1.0, "Maximum longitudinal DCA"}; + + ConfigurableAxis cfgaxisQvecF{"cfgaxisQvecF", {300, -1, 1}, ""}; + ConfigurableAxis cfgaxisQvec{"cfgaxisQvec", {100, -3, 3}, ""}; + ConfigurableAxis cfgaxisCent{"cfgaxisCent", {100, 0, 100}, ""}; + + ConfigurableAxis cfgaxiscos{"cfgaxiscos", {102, -1.02, 1.02}, ""}; + ConfigurableAxis cfgaxispt{"cfgaxispt", {100, 0, 10}, ""}; + ConfigurableAxis cfgaxisCentMerged{"cfgaxisCentMerged", {20, 0, 100}, ""}; + ConfigurableAxis cfgaxisCentForQA{"cfgaxisCentForQA", {100, 0, 100}, "centrality for event QA"}; + ConfigurableAxis cfgaxisNch{"cfgaxisNch", {4000, 0, 4000}, "N_{ch}"}; + ConfigurableAxis cfgaxisT0C{"cfgaxisT0C", {70, 0, 70000}, "N_{ch} (T0C)"}; + ConfigurableAxis cfgaxisT0A{"cfgaxisT0A", {200, 0, 200000}, "N_{ch} (T0A)"}; + ConfigurableAxis cfgaxisNchPV{"cfgaxisNchPV", {4000, 0, 4000}, "N_{ch} (PV)"}; + ConfigurableAxis cfgaxisptPID{"cfgaxisptPID", {120, 0, 12}, "Binning for P_{t} PID"}; + ConfigurableAxis cfgnSigmaBinsTPC{"cfgnSigmaBinsTPC", {200, -5.f, 5.f}, "Binning for n sigma TPC"}; + ConfigurableAxis cfgnSigmaBinsITS{"cfgnSigmaBinsITS", {200, -5.f, 5.f}, "Binning for n sigma TPC"}; + + ConfigurableAxis cfgaxissumpt{"cfgaxissumpt", {16, 0, 16}, "Binning for #gamma and #delta sum p_{t}(particle1 + particle2)"}; + ConfigurableAxis cfgaxisdeltaeta{"cfgaxisdeltaeta", {16, -1.6, 1.6}, "Binning for #gamma and #delta #eta(particle1 - particle2)"}; + ConfigurableAxis cfgaxisdeltapt{"cfgaxisdeltapt", {16, -8, 8}, "Binning for #gamma and #delta p_{t}(particle1 - particle2)"}; + + Configurable cfgUseAdditionalEventCut{"cfgUseAdditionalEventCut", true, "Use additional event cut beyond sel8"}; + Configurable cfgOpenEvSelkIsGoodZvtxFT0vsPV{"cfgOpenEvSelkIsGoodZvtxFT0vsPV", true, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference, use this cut at low multiplicities with caution"}; + Configurable cfgOpenEvSelkNoSameBunchPileup{"cfgOpenEvSelkNoSameBunchPileup", true, "rejects collisions which are associated with the same found-by-T0 bunch crossing"}; + Configurable cfgOpenEvSelkNoCollInTimeRangeStandard{"cfgOpenEvSelkNoCollInTimeRangeStandard", true, "no collisions in specified time range"}; + Configurable cfgOpenEvSelkIsGoodITSLayersAll{"cfgOpenEvSelkIsGoodITSLayersAll", true, "cut time intervals with dead ITS staves"}; + Configurable cfgOpenEvSelkNoCollInRofStandard{"cfgOpenEvSelkNoCollInRofStandard", true, "no other collisions in this Readout Frame with per-collision multiplicity above threshold"}; + Configurable cfgOpenEvSelkNoHighMultCollInPrevRof{"cfgOpenEvSelkNoHighMultCollInPrevRof", true, "veto an event if FT0C amplitude in previous ITS ROF is above threshold"}; + Configurable cfgOpenEvSelOccupancy{"cfgOpenEvSelOccupancy", true, "Occupancy cut"}; + Configurable cfgOpenEvSelMultCorrelationPVTracks{"cfgOpenEvSelMultCorrelationPVTracks", true, "Multiplicity correlation cut for PVtracks vs centrality(FT0C)"}; + Configurable cfgOpenEvSelMultCorrelationGlobalTracks{"cfgOpenEvSelMultCorrelationGlobalTracks", false, "Multiplicity correlation cut for Globaltracks vs centrality(FT0C)"}; + Configurable cfgOpenEvSelV0AT0ACut{"cfgOpenEvSelV0AT0ACut", true, "V0A T0A 5 sigma cut"}; + Configurable cfgOpenFullEventQA{"cfgOpenFullEventQA", true, "Open full QA plots for event QA"}; + Configurable cfgkOpenV2{"cfgkOpenV2", true, "open V2 plots"}; + Configurable cfgkOpenCME{"cfgkOpenCME", true, "open PID CME"}; + Configurable cfgkOpenCMEDifferential{"cfgkOpenCMEDifferential", true, "open Differential plot(#delta pt, #delta eta, #average pt) for cme #delta and #gamma"}; + Configurable cfgkOpenDeltaPt{"cfgkOpenDeltaPt", true, "open CME Differential #Delta Pt"}; + Configurable cfgkOpenDeltaEta{"cfgkOpenDeltaEta", true, "open CME Differential #Delta Eta"}; + Configurable cfgkOpenAveragePt{"cfgkOpenAveragePt", true, "open CME Differential #Average Pt"}; + Configurable cfgkOpenPiPi{"cfgkOpenPiPi", true, "open Pi-Pi"}; + Configurable cfgkOpenKaKa{"cfgkOpenKaKa", true, "open Ka-Ka"}; + Configurable cfgkOpenPrPr{"cfgkOpenPrPr", true, "open Pr-Pr"}; + Configurable cfgkOpenPiKa{"cfgkOpenPiKa", true, "open Pi-Ka"}; + Configurable cfgkOpenPiPr{"cfgkOpenPiPr", true, "open Pi-Pr"}; + Configurable cfgkOpenKaPr{"cfgkOpenKaPr", true, "open Ka-Pr"}; + Configurable cfgkOpenHaHa{"cfgkOpenHaHa", true, "open Ha-Ha"}; + Configurable cfgkOpenSsOsCrossCheck{"cfgkOpenSsOsCrossCheck", false, "open check for matter an antimatter #gamma#delta"}; + Configurable cfgkOpenTPCITSPurityCut{"cfgkOpenTPCITSPurityCut", true, "open ITS-TPC purity cut"}; + Configurable cfgkOpenTPCITSPurityCutQA{"cfgkOpenTPCITSPurityCutQA", true, "open ITS-TPC purity cut QA plots"}; + Configurable cfgkOpenDebugPIDCME{"cfgkOpenDebugPIDCME", false, "open pidcme workflow debug mode"}; + Configurable cfgOpenPlotITSNcls{"cfgOpenPlotITSNcls", true, "open QA for overall ITSNcls distribution"}; + Configurable cfgOpenPlotITSNclsPtCent{"cfgOpenPlotITSNclsPtCent", false, "open QA for ITSNcls distribution vs centality and pt"}; + Configurable cfgOpenPlotTPCNcls{"cfgOpenPlotTPCNcls", true, "open QA for overall TPCNcls distribution"}; + Configurable cfgOpenPlotTPCNclsPtCent{"cfgOpenPlotTPCNclsPtCent", false, "open QA for TPCNcls distribution vs centality and pt"}; + Configurable cfgOpenCustomTrackCutAssurance{"cfgOpenCustomTrackCutAssurance", true, "Assure track using for v2 and cme pass the custom track cuts"}; + + Configurable> cfgITSPurityCen{"cfgITSPurityCen", {20, 30}, "ITS purity cut centrality"}; + Configurable> cfgPtPrCut{"cfgPtPrCut", {0.5, 0.6, 0.7, 0.8, 0.9}, "pt binings for proton ITS purity cut"}; + Configurable cfgCCDBPurityPath{"cfgCCDBPurityPath", "Users/z/zhengqiw/PurityCut", "CCDB path for nsigmaITS - nSigmaTPC purity cut"}; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + Service ccdb; + EventPlaneHelper helperEP; + SliceCache cache; + + unsigned int mult1, mult2, mult3; + int detId; + int refAId; + int refBId; + // Additional Event selection cuts - Copy from flowGenericFramework.cxx + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fMultMultPVCut = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + // vectors for ITS-TPC contanmination cut + std::vector>> hPosPrCut; + std::vector>> hNegPrCut; + + template + int getDetId(const T& name) + { + if (name.value == "BPos" || name.value == "BNeg" || name.value == "BTot") { + LOGF(warning, "Using deprecated label: %s. Please use TPCpos, TPCneg, TPCall instead.", name.value); + } + if (name.value == "FT0C") { + return 0; + } else if (name.value == "FT0A") { + return 1; + } else if (name.value == "FT0M") { + return 2; + } else if (name.value == "FV0A") { + return 3; + } else if (name.value == "TPCpos" || name.value == "BPos") { + return 4; + } else if (name.value == "TPCneg" || name.value == "BNeg") { + return 5; + } else if (name.value == "TPCall" || name.value == "BTot") { + return 6; + } else { + return 0; + } + } + + Filter collisionFilter = (nabs(aod::collision::posZ) < cfgVtzCut) && (aod::cent::centFT0C > cfgCentMin) && (aod::cent::centFT0C < cfgCentMax); + Filter ptfilter = aod::track::pt > cfgMinPt; + Filter etafilter = aod::track::eta < cfgMaxEta; + Filter properPIDfilter = aod::cme_track_pid_columns::nPidFlag >= (int8_t)0; + + Partition>> tracksSet1 = ((aod::cme_track_pid_columns::nPidFlag == pid_flags::kPion) || (aod::cme_track_pid_columns::nPidFlag == pid_flags::kPionKaon) || (aod::cme_track_pid_columns::nPidFlag == pid_flags::kPionProton) || (aod::cme_track_pid_columns::nPidFlag == pid_flags::kPionKaonProton)); + Partition>> tracksSet2 = ((aod::cme_track_pid_columns::nPidFlag == pid_flags::kKaon) || (aod::cme_track_pid_columns::nPidFlag == pid_flags::kPionKaon) || (aod::cme_track_pid_columns::nPidFlag == pid_flags::kKaonProton) || (aod::cme_track_pid_columns::nPidFlag == pid_flags::kPionKaonProton)); + Partition>> tracksSet3 = ((aod::cme_track_pid_columns::nPidFlag == pid_flags::kProton) || (aod::cme_track_pid_columns::nPidFlag == pid_flags::kPionProton) || (aod::cme_track_pid_columns::nPidFlag == pid_flags::kKaonProton) || (aod::cme_track_pid_columns::nPidFlag == pid_flags::kPionKaonProton)); + void init(InitContext const&) + { + + ccdb->setURL(ccdbUrl.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + ccdb->setFatalWhenNull(false); + + detId = getDetId(cfgDetName); + refAId = getDetId(cfgRefAName); + refBId = getDetId(cfgRefBName); + + if (detId == refAId || detId == refBId || refAId == refBId) { + LOGF(info, "Wrong detector configuration \n The FT0C will be used to get Q-Vector \n The TPCpos and TPCneg will be used as reference systems"); + detId = 0; + refAId = 4; + refBId = 5; + } + + if (cfgUseAdditionalEventCut) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + + fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + + fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } + + AxisSpec axisCent{cfgaxisCent, "centrality"}; + AxisSpec axisQvec{cfgaxisQvec, "Q"}; + AxisSpec axisQvecF{cfgaxisQvecF, "Q"}; + AxisSpec axisEvtPl = {100, -1.0 * constants::math::PI, constants::math::PI}; + + AxisSpec axisCos{cfgaxiscos, "angle function"}; + AxisSpec axisPt{cfgaxispt, "trasverse momentum"}; + AxisSpec axisCentMerged{cfgaxisCentMerged, "merged centrality for cme and PID v2"}; + + AxisSpec axissumpt{cfgaxissumpt, "#it{p}_{T}^{sum}"}; + AxisSpec axisdeltaeta{cfgaxisdeltaeta, "#Delta#eta"}; + AxisSpec axisdeltapt{cfgaxisdeltapt, "#Delta#it{p}_{T}"}; + AxisSpec axisvertexz = {100, -15., 15., "vrtx_{Z} [cm]"}; + AxisSpec axisITSNcls = {10, -0.5, 9.5, "ITSNcls"}; + AxisSpec axisTPCNcls = {160, 0, 160, "TPCNcls"}; + + histosQA.add(Form("QA/histEventCount"), "", {HistType::kTH1F, {{3, 0.0, 3.0}}}); + histosQA.get(HIST("QA/histEventCount"))->GetXaxis()->SetBinLabel(1, "Filtered event"); + histosQA.get(HIST("QA/histEventCount"))->GetXaxis()->SetBinLabel(2, "after sel8"); + histosQA.get(HIST("QA/histEventCount"))->GetXaxis()->SetBinLabel(3, "after additional event cut"); + if (cfgUseAdditionalEventCut) { + histosQA.add(Form("QA/histEventCountDetail"), "Number of Event;; Count", {HistType::kTH1F, {{11, 0, 11}}}); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(1, "after sel8"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(2, "kIsGoodZvtxFT0vsPV"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(3, "kNoSameBunchPileup"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(4, "kNoCollInTimeRangeStandard"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(5, "kIsGoodITSLayersAll"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(6, "kNoCollInRofStandard"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(7, "kNoHighMultCollInPrevRof"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(8, "occupancy"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(9, "MultCorrelationPVTracks"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(10, "MultCorrelationGlobalTracks"); + histosQA.get(HIST("QA/histEventCountDetail"))->GetXaxis()->SetBinLabel(11, "cfgEvSelV0AT0ACut"); + } + if (cfgOpenFullEventQA) { + histosQA.add("QA/hist_globalTracks_centT0C_before", "before cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {cfgaxisCentForQA, cfgaxisNch}}); + histosQA.add("QA/hist_PVTracks_centT0C_before", "before cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {cfgaxisCentForQA, cfgaxisNchPV}}); + histosQA.add("QA/hist_globalTracks_PVTracks_before", "before cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {cfgaxisNchPV, cfgaxisNch}}); + histosQA.add("QA/hist_globalTracks_multT0A_before", "before cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {cfgaxisT0A, cfgaxisNch}}); + histosQA.add("QA/hist_globalTracks_multV0A_before", "before cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {cfgaxisT0A, cfgaxisNch}}); + histosQA.add("QA/hist_multV0A_multT0A_before", "before cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {cfgaxisT0A, cfgaxisT0A}}); + histosQA.add("QA/hist_multT0C_centT0C_before", "before cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {cfgaxisCentForQA, cfgaxisT0C}}); + histosQA.add("QA/hist_globalTracks_centT0C_after", "after cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {cfgaxisCentForQA, cfgaxisNch}}); + histosQA.add("QA/hist_PVTracks_centT0C_after", "after cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {cfgaxisCentForQA, cfgaxisNchPV}}); + histosQA.add("QA/hist_globalTracks_PVTracks_after", "after cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {cfgaxisNchPV, cfgaxisNch}}); + histosQA.add("QA/hist_globalTracks_multT0A_after", "after cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {cfgaxisT0A, cfgaxisNch}}); + histosQA.add("QA/hist_globalTracks_multV0A_after", "after cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {cfgaxisT0A, cfgaxisNch}}); + histosQA.add("QA/hist_multV0A_multT0A_after", "after cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {cfgaxisT0A, cfgaxisT0A}}); + histosQA.add("QA/hist_multT0C_centT0C_after", "after cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {cfgaxisCentForQA, cfgaxisT0C}}); + } + histosQA.add(Form("QA/histVertexZRec"), "", {HistType::kTH1F, {axisvertexz}}); + histosQA.add(Form("QA/histCentrality"), "", {HistType::kTH1F, {axisCent}}); + histosQA.add(Form("QA/histQvec_CorrL0_V2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); + histosQA.add(Form("QA/histQvec_CorrL1_V2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); + histosQA.add(Form("QA/histQvec_CorrL2_V2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); + histosQA.add(Form("QA/histQvec_CorrL3_V2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); + histosQA.add(Form("QA/histEvtPl_CorrL0_V2"), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("QA/histEvtPl_CorrL1_V2"), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("QA/histEvtPl_CorrL2_V2"), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("QA/histEvtPl_CorrL3_V2"), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("QA/histQvecRes_SigRefAV2"), "", {HistType::kTH2F, {axisQvecF, axisCent}}); + histosQA.add(Form("QA/histQvecRes_SigRefBV2"), "", {HistType::kTH2F, {axisQvecF, axisCent}}); + histosQA.add(Form("QA/histQvecRes_RefARefBV2"), "", {HistType::kTH2F, {axisQvecF, axisCent}}); + + if (cfgkOpenV2) { + histosQA.add(Form("V2/histCosDetV2"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("V2/histSinDetV2"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("V2/PID/histCosDetV2_Pi"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("V2/PID/histCosDetV2_Ka"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("V2/PID/histCosDetV2_Pr"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("V2/PID/histCosDetV2_Pi_Neg"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("V2/PID/histCosDetV2_Ka_Neg"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("V2/PID/histCosDetV2_Pr_Neg"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + } + + if (cfgkOpenTPCITSPurityCut && cfgkOpenTPCITSPurityCutQA) { + histosQA.add(Form("QA/histITSPuritycheck_Pr_Pos_Cen_20_30"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + histosQA.add(Form("QA/histITSPuritycheck_Pr_Neg_Cen_20_30"), ";n#sigma_{TPC};n#sigma_{ITS};#p_{t}", {HistType::kTH3F, {cfgnSigmaBinsTPC, cfgnSigmaBinsITS, cfgaxisptPID}}); + } + if (cfgOpenPlotITSNcls) { + histosQA.add(Form("QA/histITSNcls_PosPi"), ";ITSNcls;counts", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/histITSNcls_NegPi"), ";ITSNcls;counts", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/histITSNcls_PosKa"), ";ITSNcls;counts", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/histITSNcls_NegKa"), ";ITSNcls;counts", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/histITSNcls_PosPr"), ";ITSNcls;counts", {HistType::kTH1F, {axisITSNcls}}); + histosQA.add(Form("QA/histITSNcls_NegPr"), ";ITSNcls;counts", {HistType::kTH1F, {axisITSNcls}}); + } + if (cfgOpenPlotITSNclsPtCent) { + histosQA.add(Form("QA/histITSNclsPtCent_PosPi"), ";ITSNcls;Pt;Centrality", {HistType::kTH3F, {axisITSNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histITSNclsPtCent_NegPi"), ";ITSNcls;Pt;Centrality", {HistType::kTH3F, {axisITSNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histITSNclsPtCent_PosKa"), ";ITSNcls;Pt;Centrality", {HistType::kTH3F, {axisITSNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histITSNclsPtCent_NegKa"), ";ITSNcls;Pt;Centrality", {HistType::kTH3F, {axisITSNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histITSNclsPtCent_PosPr"), ";ITSNcls;Pt;Centrality", {HistType::kTH3F, {axisITSNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histITSNclsPtCent_NegPr"), ";ITSNcls;Pt;Centrality", {HistType::kTH3F, {axisITSNcls, axisPt, axisCentMerged}}); + } + if (cfgOpenPlotTPCNcls) { + histosQA.add(Form("QA/histTPCNcls_PosPi"), ";TPCNcls;counts", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/histTPCNcls_NegPi"), ";TPCNcls;counts", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/histTPCNcls_PosKa"), ";TPCNcls;counts", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/histTPCNcls_NegKa"), ";TPCNcls;counts", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/histTPCNcls_PosPr"), ";TPCNcls;counts", {HistType::kTH1F, {axisTPCNcls}}); + histosQA.add(Form("QA/histTPCNcls_NegPr"), ";TPCNcls;counts", {HistType::kTH1F, {axisTPCNcls}}); + } + if (cfgOpenPlotTPCNclsPtCent) { + histosQA.add(Form("QA/histTPCNclsPtCent_PosPi"), ";TPCNcls;Pt;Centrality", {HistType::kTH3F, {axisTPCNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histTPCNclsPtCent_NegPi"), ";TPCNcls;Pt;Centrality", {HistType::kTH3F, {axisTPCNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histTPCNclsPtCent_PosKa"), ";TPCNcls;Pt;Centrality", {HistType::kTH3F, {axisTPCNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histTPCNclsPtCent_NegKa"), ";TPCNcls;Pt;Centrality", {HistType::kTH3F, {axisTPCNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histTPCNclsPtCent_PosPr"), ";TPCNcls;Pt;Centrality", {HistType::kTH3F, {axisTPCNcls, axisPt, axisCentMerged}}); + histosQA.add(Form("QA/histTPCNclsPtCent_NegPr"), ";TPCNcls;Pt;Centrality", {HistType::kTH3F, {axisTPCNcls, axisPt, axisCentMerged}}); + } + + if (cfgkOpenCME) { + if (cfgkOpenPiPi) { + histosQA.add(Form("PIDCME/histgamma_PiPi_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiPi_os"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPi_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPi_os"), "", {HistType::kTProfile, {axisCentMerged}}); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.add("PIDCME/Differential/histgamma_PiPi_ss_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histgamma_PiPi_os_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_PiPi_ss_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_PiPi_os_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + } + if (cfgkOpenDeltaEta) { + histosQA.add("PIDCME/Differential/histgamma_PiPi_ss_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histgamma_PiPi_os_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_PiPi_ss_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_PiPi_os_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + } + if (cfgkOpenAveragePt) { + histosQA.add("PIDCME/Differential/histgamma_PiPi_ss_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histgamma_PiPi_os_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_PiPi_ss_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_PiPi_os_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + } + } + if (cfgkOpenSsOsCrossCheck) { + histosQA.add(Form("PIDCME/histgamma_PiPi_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiPi_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiPi_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiPi_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPi_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPi_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPi_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPi_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + } + } + if (cfgkOpenKaKa) { + histosQA.add(Form("PIDCME/histgamma_KaKa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_KaKa_os"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaKa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaKa_os"), "", {HistType::kTProfile, {axisCentMerged}}); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.add("PIDCME/Differential/histgamma_KaKa_ss_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histgamma_KaKa_os_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_KaKa_ss_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_KaKa_os_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + } + if (cfgkOpenDeltaEta) { + histosQA.add("PIDCME/Differential/histgamma_KaKa_ss_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histgamma_KaKa_os_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_KaKa_ss_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_KaKa_os_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + } + if (cfgkOpenAveragePt) { + histosQA.add("PIDCME/Differential/histgamma_KaKa_ss_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histgamma_KaKa_os_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_KaKa_ss_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_KaKa_os_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + } + } + if (cfgkOpenSsOsCrossCheck) { + histosQA.add(Form("PIDCME/histgamma_KaKa_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_KaKa_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_KaKa_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_KaKa_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaKa_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaKa_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaKa_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaKa_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + } + } + if (cfgkOpenPrPr) { + histosQA.add(Form("PIDCME/histgamma_PrPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PrPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PrPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PrPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.add("PIDCME/Differential/histgamma_PrPr_ss_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histgamma_PrPr_os_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_PrPr_ss_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_PrPr_os_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + } + if (cfgkOpenDeltaEta) { + histosQA.add("PIDCME/Differential/histgamma_PrPr_ss_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histgamma_PrPr_os_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_PrPr_ss_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_PrPr_os_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + } + if (cfgkOpenAveragePt) { + histosQA.add("PIDCME/Differential/histgamma_PrPr_ss_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histgamma_PrPr_os_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_PrPr_ss_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_PrPr_os_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + } + } + if (cfgkOpenSsOsCrossCheck) { + histosQA.add(Form("PIDCME/histgamma_PrPr_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PrPr_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PrPr_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PrPr_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PrPr_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PrPr_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PrPr_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PrPr_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + } + } + if (cfgkOpenPiKa) { + histosQA.add(Form("PIDCME/histgamma_PiKa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiKa_os"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiKa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiKa_os"), "", {HistType::kTProfile, {axisCentMerged}}); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.add("PIDCME/Differential/histgamma_PiKa_ss_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histgamma_PiKa_os_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_PiKa_ss_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_PiKa_os_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + } + if (cfgkOpenDeltaEta) { + histosQA.add("PIDCME/Differential/histgamma_PiKa_ss_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histgamma_PiKa_os_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_PiKa_ss_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_PiKa_os_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + } + if (cfgkOpenAveragePt) { + histosQA.add("PIDCME/Differential/histgamma_PiKa_ss_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histgamma_PiKa_os_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_PiKa_ss_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_PiKa_os_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + } + } + if (cfgkOpenSsOsCrossCheck) { + histosQA.add(Form("PIDCME/histgamma_PiKa_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiKa_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiKa_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiKa_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiKa_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiKa_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiKa_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiKa_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + } + } + if (cfgkOpenPiPr) { + histosQA.add(Form("PIDCME/histgamma_PiPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.add("PIDCME/Differential/histgamma_PiPr_ss_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histgamma_PiPr_os_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_PiPr_ss_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_PiPr_os_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + } + if (cfgkOpenDeltaEta) { + histosQA.add("PIDCME/Differential/histgamma_PiPr_ss_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histgamma_PiPr_os_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_PiPr_ss_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_PiPr_os_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + } + if (cfgkOpenAveragePt) { + histosQA.add("PIDCME/Differential/histgamma_PiPr_ss_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histgamma_PiPr_os_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_PiPr_ss_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_PiPr_os_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + } + } + if (cfgkOpenSsOsCrossCheck) { + histosQA.add(Form("PIDCME/histgamma_PiPr_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiPr_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiPr_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_PiPr_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPr_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPr_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPr_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_PiPr_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + } + } + if (cfgkOpenKaPr) { + histosQA.add(Form("PIDCME/histgamma_KaPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_KaPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.add("PIDCME/Differential/histgamma_KaPr_ss_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histgamma_KaPr_os_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_KaPr_ss_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_KaPr_os_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + } + if (cfgkOpenDeltaEta) { + histosQA.add("PIDCME/Differential/histgamma_KaPr_ss_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histgamma_KaPr_os_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_KaPr_ss_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_KaPr_os_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + } + if (cfgkOpenAveragePt) { + histosQA.add("PIDCME/Differential/histgamma_KaPr_ss_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histgamma_KaPr_os_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_KaPr_ss_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_KaPr_os_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + } + } + if (cfgkOpenSsOsCrossCheck) { + histosQA.add(Form("PIDCME/histgamma_KaPr_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_KaPr_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_KaPr_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_KaPr_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaPr_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaPr_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaPr_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_KaPr_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + } + } + if (cfgkOpenHaHa) { + histosQA.add(Form("PIDCME/histgamma_HaHa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_HaHa_os"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_HaHa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_HaHa_os"), "", {HistType::kTProfile, {axisCentMerged}}); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.add("PIDCME/Differential/histgamma_HaHa_ss_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histgamma_HaHa_os_DPt", ";centrality;#Delta #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_HaHa_ss_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + histosQA.add("PIDCME/Differential/histdelta_HaHa_os_DPt", ";centrality;#Delta #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltapt}}); + } + if (cfgkOpenDeltaEta) { + histosQA.add("PIDCME/Differential/histgamma_HaHa_ss_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histgamma_HaHa_os_DEt", ";centrality;#Delta #eta;#gamma", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_HaHa_ss_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + histosQA.add("PIDCME/Differential/histdelta_HaHa_os_DEt", ";centrality;#Delta #eta;#delta", {HistType::kTProfile2D, {axisCentMerged, axisdeltaeta}}); + } + if (cfgkOpenAveragePt) { + histosQA.add("PIDCME/Differential/histgamma_HaHa_ss_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histgamma_HaHa_os_SPt", ";centrality;Sum #p_{T};#gamma", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_HaHa_ss_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + histosQA.add("PIDCME/Differential/histdelta_HaHa_os_SPt", ";centrality;Sum #p_{T};#delta", {HistType::kTProfile2D, {axisCentMerged, axissumpt}}); + } + } + if (cfgkOpenSsOsCrossCheck) { + histosQA.add(Form("PIDCME/histgamma_HaHa_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_HaHa_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_HaHa_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histgamma_HaHa_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_HaHa_PP"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_HaHa_NN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_HaHa_PN"), "", {HistType::kTProfile, {axisCentMerged}}); + histosQA.add(Form("PIDCME/histdelta_HaHa_NP"), "", {HistType::kTProfile, {axisCentMerged}}); + } + } + } + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + std::string fullPath; + auto timestamp = bc.timestamp(); + // hPosPrCut.clear(); + // hNegPrCut.clear(); + for (auto i = 0; i < static_cast(cfgITSPurityCen->size()) - 1; i++) { + std::vector> hPosPrCutCen; + std::vector> hNegPrCutCen; + for (auto j = 0; j < static_cast(cfgPtPrCut->size()) - 1; j++) { + fullPath = cfgCCDBPurityPath; + fullPath += Form("/ProtonPos/Cen_%d_%d/Pt_%d_%d", cfgITSPurityCen->at(i), cfgITSPurityCen->at(i + 1), static_cast(std::round(1e3 * cfgPtPrCut->at(j))), static_cast(std::round(1e3 * cfgPtPrCut->at(j + 1)))); + auto posPrHist = ccdb->getForTimeStamp(fullPath, timestamp); + fullPath = cfgCCDBPurityPath; + fullPath += Form("/ProtonNeg/Cen_%d_%d/Pt_%d_%d", cfgITSPurityCen->at(i), cfgITSPurityCen->at(i + 1), static_cast(std::round(1e3 * cfgPtPrCut->at(j))), static_cast(std::round(1e3 * cfgPtPrCut->at(j + 1)))); + auto negPrHist = ccdb->getForTimeStamp(fullPath, timestamp); + if (!posPrHist) { + LOGF(fatal, Form("could not load Pos Proton ITS TPC purity hist for Cent_%d_%d Pt_%d_%d(MeV)", cfgITSPurityCen->at(i), cfgITSPurityCen->at(i + 1), static_cast(std::round(1e3 * cfgPtPrCut->at(j))), static_cast(std::round(1e3 * cfgPtPrCut->at(j + 1))))); + } + if (!negPrHist) { + LOGF(fatal, Form("could not load Neg Proton ITS TPC purity hist for Cent_%d_%d Pt_%d_%d(MeV)", cfgITSPurityCen->at(i), cfgITSPurityCen->at(i + 1), static_cast(std::round(1e3 * cfgPtPrCut->at(j))), static_cast(std::round(1e3 * cfgPtPrCut->at(j + 1))))); + } + std::shared_ptr sharedPosPrHist(posPrHist); + std::shared_ptr sharedNegPrHist(negPrHist); + hPosPrCutCen.push_back(std::move(sharedPosPrHist)); + hNegPrCutCen.push_back(std::move(sharedNegPrHist)); + } + hPosPrCut.push_back(std::move(hPosPrCutCen)); + hNegPrCut.push_back(std::move(hNegPrCutCen)); + } + } + + template + bool selEvent(const CollType& collision, const int multTrk, const float centrality) + { + histosQA.fill(HIST("QA/histEventCountDetail"), 0.5); + if (cfgOpenEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return 0; + } + if (cfgOpenEvSelkIsGoodZvtxFT0vsPV) { + histosQA.fill(HIST("QA/histEventCountDetail"), 1.5); + } + if (cfgOpenEvSelkNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return 0; + } + if (cfgOpenEvSelkNoSameBunchPileup) { + histosQA.fill(HIST("QA/histEventCountDetail"), 2.5); + } + if (cfgOpenEvSelkNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return 0; + } + if (cfgOpenEvSelkNoCollInTimeRangeStandard) { + histosQA.fill(HIST("QA/histEventCountDetail"), 3.5); + } + if (cfgOpenEvSelkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return 0; + } + if (cfgOpenEvSelkIsGoodITSLayersAll) { + histosQA.fill(HIST("QA/histEventCountDetail"), 4.5); + } + if (cfgOpenEvSelkNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return 0; + } + if (cfgOpenEvSelkNoCollInRofStandard) { + histosQA.fill(HIST("QA/histEventCountDetail"), 5.5); + } + if (cfgOpenEvSelkNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return 0; + } + if (cfgOpenEvSelkNoHighMultCollInPrevRof) { + histosQA.fill(HIST("QA/histEventCountDetail"), 6.5); + } + auto multNTracksPV = collision.multNTracksPV(); + auto occupancy = collision.trackOccupancyInTimeRange(); + if (cfgOpenEvSelOccupancy && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) { + return 0; + } + if (cfgOpenEvSelOccupancy) { + histosQA.fill(HIST("QA/histEventCountDetail"), 7.5); + } + if (cfgOpenEvSelMultCorrelationPVTracks) { + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return 0; + } + if (cfgOpenEvSelMultCorrelationPVTracks) { + histosQA.fill(HIST("QA/histEventCountDetail"), 8.5); + } + if (cfgOpenEvSelMultCorrelationGlobalTracks) { + if (multTrk < fMultCutLow->Eval(centrality)) + return 0; + if (multTrk > fMultCutHigh->Eval(centrality)) + return 0; + } + if (cfgOpenEvSelMultCorrelationGlobalTracks) { + histosQA.fill(HIST("QA/histEventCountDetail"), 9.5); + } + if (cfgOpenEvSelV0AT0ACut && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > event_selection::kFT0AV0ASigma * fT0AV0ASigma->Eval(collision.multFT0A()))) { + return 0; + } + if (cfgOpenEvSelV0AT0ACut) { + histosQA.fill(HIST("QA/histEventCountDetail"), 10.5); + } + return 1; + } + + template + bool selTrack(const TrackType track, float centrality) + { + if (cfgkOpenDebugPIDCME) { + LOGF(info, "====================Entering track selection============================="); + } + if (cfgOpenCustomTrackCutAssurance) { + if (!track.passedITSNCls()) + return false; + if (!track.passedITSChi2NDF()) + return false; + if (!track.passedITSHits()) + return false; + if (!track.passedTPCCrossedRowsOverNCls()) + return false; + if (!track.passedTPCChi2NDF()) + return false; + if (!track.passedDCAxy()) + return false; + if (!track.passedDCAz()) + return false; + } + if (cfgkOpenTPCITSPurityCut) { + int cenBin = -1; + int ptBin = -1; + for (int i = 0; i < static_cast(cfgITSPurityCen.value.size()) - 1; ++i) { + if (centrality >= cfgITSPurityCen.value[i] && centrality < cfgITSPurityCen.value[i + 1]) { + cenBin = i; + break; + } + } + for (int i = 0; i < static_cast(cfgPtPrCut.value.size()) - 1; ++i) { + if (track.pt() >= cfgPtPrCut.value[i] && track.pt() < cfgPtPrCut.value[i + 1]) { + ptBin = i; + break; + } + } + if ((cenBin >= 0) && (ptBin >= 0)) { + if ((track.nPidFlag() == pid_flags::kProton) || (track.nPidFlag() == pid_flags::kPionProton) || (track.nPidFlag() == pid_flags::kKaonProton) || (track.nPidFlag() == pid_flags::kPionKaonProton)) { + if (cfgkOpenDebugPIDCME) { + LOGF(info, Form("=========cen_bin: %d pt_bin: %d=========", cenBin, ptBin)); + } + float nSigmaITSPr = track.nSigmaPrITS(); + int xBin = hPosPrCut[cenBin][ptBin]->GetXaxis()->FindBin(nSigmaITSPr); + float binContentPosPr = hPosPrCut[cenBin][ptBin]->GetBinContent(xBin); + float binContentNegPr = hNegPrCut[cenBin][ptBin]->GetBinContent(xBin); + if (track.sign() > 0) { + if ((binContentPosPr != 0) && (track.nSigmaPrTPC() < binContentPosPr)) { + if (cfgkOpenDebugPIDCME) { + LOGF(info, "====================Track selection Finished with cut============================="); + } + return false; + } + } else { + if ((binContentNegPr != 0) && (track.nSigmaPrTPC() < binContentNegPr)) { + if (cfgkOpenDebugPIDCME) { + LOGF(info, "====================Track selection Finished with cut============================="); + } + return false; + } + } + } + } + } + if (cfgkOpenDebugPIDCME) { + LOGF(info, "====================Track selection Finished without cut============================="); + } + return true; + } + + template + void fillHistosQvec(const CollType& collision, int nmode) + { + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + int refAInd = refAId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + int refBInd = refBId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + if (nmode == fourier_mode::kMode2) { + if (collision.qvecAmp()[detId] > 1e-8) { + histosQA.fill(HIST("QA/histQvec_CorrL0_V2"), collision.qvecRe()[detInd], collision.qvecIm()[detInd], collision.centFT0C()); + histosQA.fill(HIST("QA/histQvec_CorrL1_V2"), collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], collision.centFT0C()); + histosQA.fill(HIST("QA/histQvec_CorrL2_V2"), collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], collision.centFT0C()); + histosQA.fill(HIST("QA/histQvec_CorrL3_V2"), collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], collision.centFT0C()); + histosQA.fill(HIST("QA/histEvtPl_CorrL0_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode), collision.centFT0C()); + histosQA.fill(HIST("QA/histEvtPl_CorrL1_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], nmode), collision.centFT0C()); + histosQA.fill(HIST("QA/histEvtPl_CorrL2_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], nmode), collision.centFT0C()); + histosQA.fill(HIST("QA/histEvtPl_CorrL3_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), collision.centFT0C()); + } + if (collision.qvecAmp()[detId] > 1e-8 && collision.qvecAmp()[refAId] > 1e-8 && collision.qvecAmp()[refBId] > 1e-8) { + histosQA.fill(HIST("QA/histQvecRes_SigRefAV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), nmode), collision.centFT0C()); + histosQA.fill(HIST("QA/histQvecRes_SigRefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.centFT0C()); + histosQA.fill(HIST("QA/histQvecRes_RefARefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.centFT0C()); + } + } + } + + template + void fillHistosFlowGammaDelta(const CollType& collision, const TrackType& track1, const TrackType& track2, const TrackType& track3, int nmode) + { + if (collision.qvecAmp()[detId] < 1e-8) { + return; + } + auto cent = collision.centFT0C(); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + float psiN = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); + if (cfgkOpenV2) { + for (const auto& trk : track1) { + if (!selTrack(trk, cent)) + continue; + if (nmode == fourier_mode::kMode2) { + if (trk.sign() > 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Pi"), cent, trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - psiN))); + if (cfgOpenPlotITSNcls) { + histosQA.fill(HIST("QA/histITSNcls_PosPi"), trk.itsNCls()); + } + if (cfgOpenPlotITSNclsPtCent) { + histosQA.fill(HIST("QA/histITSNclsPtCent_PosPi"), trk.itsNCls(), trk.pt(), cent); + } + if (cfgOpenPlotTPCNcls) { + histosQA.fill(HIST("QA/histTPCNcls_PosPi"), trk.tpcNClsFound()); + } + if (cfgOpenPlotTPCNclsPtCent) { + histosQA.fill(HIST("QA/histTPCNclsPtCent_PosPi"), trk.tpcNClsFound(), trk.pt(), cent); + } + } else if (trk.sign() < 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Pi_Neg"), cent, trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - psiN))); + if (cfgOpenPlotITSNcls) { + histosQA.fill(HIST("QA/histITSNcls_NegPi"), trk.itsNCls()); + } + if (cfgOpenPlotITSNclsPtCent) { + histosQA.fill(HIST("QA/histITSNclsPtCent_NegPi"), trk.itsNCls(), trk.pt(), cent); + } + if (cfgOpenPlotTPCNcls) { + histosQA.fill(HIST("QA/histTPCNcls_NegPi"), trk.tpcNClsFound()); + } + if (cfgOpenPlotTPCNclsPtCent) { + histosQA.fill(HIST("QA/histTPCNclsPtCent_NegPi"), trk.tpcNClsFound(), trk.pt(), cent); + } + } + } + } + for (const auto& trk : track2) { + if (!selTrack(trk, cent)) + continue; + if (nmode == fourier_mode::kMode2) { + if (trk.sign() > 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Ka"), cent, trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - psiN))); + if (cfgOpenPlotITSNcls) { + histosQA.fill(HIST("QA/histITSNcls_PosKa"), trk.itsNCls()); + } + if (cfgOpenPlotITSNclsPtCent) { + histosQA.fill(HIST("QA/histITSNclsPtCent_PosKa"), trk.itsNCls(), trk.pt(), cent); + } + if (cfgOpenPlotTPCNcls) { + histosQA.fill(HIST("QA/histTPCNcls_PosKa"), trk.tpcNClsFound()); + } + if (cfgOpenPlotTPCNclsPtCent) { + histosQA.fill(HIST("QA/histTPCNclsPtCent_PosKa"), trk.tpcNClsFound(), trk.pt(), cent); + } + } else if (trk.sign() < 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Ka_Neg"), cent, trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - psiN))); + if (cfgOpenPlotITSNcls) { + histosQA.fill(HIST("QA/histITSNcls_NegKa"), trk.itsNCls()); + } + if (cfgOpenPlotITSNclsPtCent) { + histosQA.fill(HIST("QA/histITSNclsPtCent_NegKa"), trk.itsNCls(), trk.pt(), cent); + } + if (cfgOpenPlotTPCNcls) { + histosQA.fill(HIST("QA/histTPCNcls_NegKa"), trk.tpcNClsFound()); + } + if (cfgOpenPlotTPCNclsPtCent) { + histosQA.fill(HIST("QA/histTPCNclsPtCent_NegKa"), trk.tpcNClsFound(), trk.pt(), cent); + } + } + } + } + for (const auto& trk : track3) { + if (!selTrack(trk, cent)) + continue; + if (nmode == fourier_mode::kMode2) { + if (trk.sign() > 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Pr"), cent, trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - psiN))); + if (cfgOpenPlotITSNcls) { + histosQA.fill(HIST("QA/histITSNcls_PosPr"), trk.itsNCls()); + } + if (cfgOpenPlotITSNclsPtCent) { + histosQA.fill(HIST("QA/histITSNclsPtCent_PosPr"), trk.itsNCls(), trk.pt(), cent); + } + if (cfgOpenPlotTPCNcls) { + histosQA.fill(HIST("QA/histTPCNcls_PosPr"), trk.tpcNClsFound()); + } + if (cfgOpenPlotTPCNclsPtCent) { + histosQA.fill(HIST("QA/histTPCNclsPtCent_PosPr"), trk.tpcNClsFound(), trk.pt(), cent); + } + } else if (trk.sign() < 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Pr_Neg"), cent, trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - psiN))); + if (cfgOpenPlotITSNcls) { + histosQA.fill(HIST("QA/histITSNcls_NegPr"), trk.itsNCls()); + } + if (cfgOpenPlotITSNclsPtCent) { + histosQA.fill(HIST("QA/histITSNclsPtCent_NegPr"), trk.itsNCls(), trk.pt(), cent); + } + if (cfgOpenPlotTPCNcls) { + histosQA.fill(HIST("QA/histTPCNcls_NegPr"), trk.tpcNClsFound()); + } + if (cfgOpenPlotTPCNclsPtCent) { + histosQA.fill(HIST("QA/histTPCNclsPtCent_NegPr"), trk.tpcNClsFound(), trk.pt(), cent); + } + } + } + } + } + if (cfgkOpenCME) { + if (cfgkOpenPiPi) { + for (const auto& trk1 : track1) { + if (!selTrack(trk1, cent)) + continue; + for (const auto& trk2 : track1) { + if (trk1.globalIndex() == trk2.globalIndex()) + continue; + if (!selTrack(trk2, cent)) + continue; + if (nmode == fourier_mode::kMode2) { + if (trk1.sign() == trk2.sign()) { + histosQA.fill(HIST("PIDCME/histgamma_PiPi_ss"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPi_ss"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPi_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPi_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPi_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPi_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPi_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPi_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() > 0) { + histosQA.fill(HIST("PIDCME/histgamma_PiPi_PP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPi_PP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_PiPi_NN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPi_NN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } else { + histosQA.fill(HIST("PIDCME/histgamma_PiPi_os"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPi_os"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPi_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPi_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPi_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPi_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPi_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPi_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() < 0) { + histosQA.fill(HIST("PIDCME/histgamma_PiPi_PN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPi_PN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_PiPi_NP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPi_NP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } + } + } + } + } + if (cfgkOpenKaKa) { + for (const auto& trk1 : track2) { + if (!selTrack(trk1, cent)) + continue; + for (const auto& trk2 : track2) { + if (trk1.globalIndex() == trk2.globalIndex()) + continue; + if (!selTrack(trk2, cent)) + continue; + if (nmode == fourier_mode::kMode2) { + if (trk1.sign() == trk2.sign()) { + histosQA.fill(HIST("PIDCME/histgamma_KaKa_ss"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaKa_ss"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaKa_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaKa_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaKa_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaKa_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaKa_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaKa_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() > 0) { + histosQA.fill(HIST("PIDCME/histgamma_KaKa_PP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaKa_PP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_KaKa_NN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaKa_NN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } else { + histosQA.fill(HIST("PIDCME/histgamma_KaKa_os"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaKa_os"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaKa_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaKa_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaKa_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaKa_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaKa_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaKa_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() < 0) { + histosQA.fill(HIST("PIDCME/histgamma_KaKa_PN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaKa_PN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_KaKa_NP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaKa_NP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } + } + } + } + } + if (cfgkOpenPrPr) { + for (const auto& trk1 : track3) { + if (!selTrack(trk1, cent)) + continue; + for (const auto& trk2 : track3) { + if (trk1.globalIndex() == trk2.globalIndex()) + continue; + if (!selTrack(trk2, cent)) + continue; + if (nmode == fourier_mode::kMode2) { + if (trk1.sign() == trk2.sign()) { + histosQA.fill(HIST("PIDCME/histgamma_PrPr_ss"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PrPr_ss"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PrPr_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PrPr_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PrPr_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PrPr_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PrPr_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PrPr_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() > 0) { + histosQA.fill(HIST("PIDCME/histgamma_PrPr_PP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PrPr_PP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_PrPr_NN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PrPr_NN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } else { + histosQA.fill(HIST("PIDCME/histgamma_PrPr_os"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PrPr_os"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PrPr_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PrPr_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PrPr_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PrPr_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PrPr_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PrPr_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() < 0) { + histosQA.fill(HIST("PIDCME/histgamma_PrPr_PN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PrPr_PN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_PrPr_NP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PrPr_NP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } + } + } + } + } + if (cfgkOpenPiKa) { + for (const auto& trk1 : track1) { + if (!selTrack(trk1, cent)) + continue; + for (const auto& trk2 : track2) { + if (trk1.globalIndex() == trk2.globalIndex()) + continue; + if (!selTrack(trk2, cent)) + continue; + if (nmode == fourier_mode::kMode2) { + if (trk1.sign() == trk2.sign()) { + histosQA.fill(HIST("PIDCME/histgamma_PiKa_ss"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiKa_ss"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiKa_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiKa_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiKa_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiKa_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiKa_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiKa_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() > 0) { + histosQA.fill(HIST("PIDCME/histgamma_PiKa_PP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiKa_PP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_PiKa_NN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiKa_NN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } else { + histosQA.fill(HIST("PIDCME/histgamma_PiKa_os"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiKa_os"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiKa_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiKa_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiKa_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiKa_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiKa_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiKa_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() < 0) { + histosQA.fill(HIST("PIDCME/histgamma_PiKa_PN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiKa_PN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_PiKa_NP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiKa_NP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } + } + } + } + } + if (cfgkOpenPiPr) { + for (const auto& trk1 : track1) { + if (!selTrack(trk1, cent)) + continue; + for (const auto& trk3 : track3) { + if (trk1.globalIndex() == trk3.globalIndex()) + continue; + if (!selTrack(trk3, cent)) + continue; + if (nmode == fourier_mode::kMode2) { + if (trk1.sign() == trk3.sign()) { + histosQA.fill(HIST("PIDCME/histgamma_PiPr_ss"), cent, std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPr_ss"), cent, std::cos((trk1.phi() - trk3.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPr_ss_DPt"), cent, trk1.pt() - trk3.pt(), + std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPr_ss_DPt"), cent, trk1.pt() - trk3.pt(), + std::cos((trk1.phi() - trk3.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPr_ss_DEt"), cent, trk1.eta() - trk3.eta(), + std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPr_ss_DEt"), cent, trk1.eta() - trk3.eta(), + std::cos((trk1.phi() - trk3.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPr_ss_SPt"), cent, trk1.pt() + trk3.pt(), + std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPr_ss_SPt"), cent, trk1.pt() + trk3.pt(), + std::cos((trk1.phi() - trk3.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk3.sign() > 0) { + histosQA.fill(HIST("PIDCME/histgamma_PiPr_PP"), cent, std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPr_PP"), cent, std::cos((trk1.phi() - trk3.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_PiPr_NN"), cent, std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPr_NN"), cent, std::cos((trk1.phi() - trk3.phi()))); + } + } + } else { + histosQA.fill(HIST("PIDCME/histgamma_PiPr_os"), cent, std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPr_os"), cent, std::cos((trk1.phi() - trk3.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPr_os_DPt"), cent, trk1.pt() - trk3.pt(), + std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPr_os_DPt"), cent, trk1.pt() - trk3.pt(), + std::cos((trk1.phi() - trk3.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPr_os_DEt"), cent, trk1.eta() - trk3.eta(), + std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPr_os_DEt"), cent, trk1.eta() - trk3.eta(), + std::cos((trk1.phi() - trk3.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_PiPr_os_SPt"), cent, trk1.pt() + trk3.pt(), + std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPr_os_SPt"), cent, trk1.pt() + trk3.pt(), + std::cos((trk1.phi() - trk3.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk3.sign() < 0) { + histosQA.fill(HIST("PIDCME/histgamma_PiPr_PN"), cent, std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPr_PN"), cent, std::cos((trk1.phi() - trk3.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_PiPr_NP"), cent, std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_PiPr_NP"), cent, std::cos((trk1.phi() - trk3.phi()))); + } + } + } + } + } + } + } + if (cfgkOpenKaPr) { + for (const auto& trk2 : track2) { + if (!selTrack(trk2, cent)) + continue; + for (const auto& trk3 : track3) { + if (trk2.globalIndex() == trk3.globalIndex()) + continue; + if (!selTrack(trk3, cent)) + continue; + if (nmode == fourier_mode::kMode2) { + if (trk2.sign() == trk3.sign()) { + histosQA.fill(HIST("PIDCME/histgamma_KaPr_ss"), cent, std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaPr_ss"), cent, std::cos((trk2.phi() - trk3.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaPr_ss_DPt"), cent, trk2.pt() - trk3.pt(), + std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaPr_ss_DPt"), cent, trk2.pt() - trk3.pt(), + std::cos((trk2.phi() - trk3.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaPr_ss_DEt"), cent, trk2.eta() - trk3.eta(), + std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaPr_ss_DEt"), cent, trk2.eta() - trk3.eta(), + std::cos((trk2.phi() - trk3.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaPr_ss_SPt"), cent, trk2.pt() + trk3.pt(), + std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaPr_ss_SPt"), cent, trk2.pt() + trk3.pt(), + std::cos((trk2.phi() - trk3.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk2.sign() > 0 && trk3.sign() > 0) { + histosQA.fill(HIST("PIDCME/histgamma_KaPr_PP"), cent, std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaPr_PP"), cent, std::cos((trk2.phi() - trk3.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_KaPr_NN"), cent, std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaPr_NN"), cent, std::cos((trk2.phi() - trk3.phi()))); + } + } + } else { + histosQA.fill(HIST("PIDCME/histgamma_KaPr_os"), cent, std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaPr_os"), cent, std::cos((trk2.phi() - trk3.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaPr_os_DPt"), cent, trk2.pt() - trk3.pt(), + std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaPr_os_DPt"), cent, trk2.pt() - trk3.pt(), + std::cos((trk2.phi() - trk3.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaPr_os_DEt"), cent, trk2.eta() - trk3.eta(), + std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaPr_os_DEt"), cent, trk2.eta() - trk3.eta(), + std::cos((trk2.phi() - trk3.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_KaPr_os_SPt"), cent, trk2.pt() + trk3.pt(), + std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_KaPr_os_SPt"), cent, trk2.pt() + trk3.pt(), + std::cos((trk2.phi() - trk3.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk2.sign() > 0 && trk3.sign() < 0) { + histosQA.fill(HIST("PIDCME/histgamma_KaPr_PN"), cent, std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaPr_PN"), cent, std::cos((trk2.phi() - trk3.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_KaPr_NP"), cent, std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); + histosQA.fill(HIST("PIDCME/histdelta_KaPr_NP"), cent, std::cos((trk2.phi() - trk3.phi()))); + } + } + } + } + } + } + } + } + } + + void process(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks) + { + auto bc = collision.bc_as(); + if ((hPosPrCut.empty()) || (hNegPrCut.empty())) { + initCCDB(bc); + LOGF(info, "==================CCDB file successfuly applied===================="); + LOGF(info, Form("size of hPosPrCut is %lu x %lu", hPosPrCut.size(), hPosPrCut[0].size())); + LOGF(info, Form("size of hNegPrCut is %lu x %lu", hNegPrCut.size(), hNegPrCut[0].size())); + LOGF(info, "==================================================================="); + } + const auto cent = collision.centFT0C(); + histosQA.fill(HIST("QA/histEventCount"), 0.5); + if (!collision.sel8()) + return; + if (tracks.size() < 1) + return; + histosQA.fill(HIST("QA/histEventCount"), 1.5); + if (cfgOpenFullEventQA) { + histosQA.fill(HIST("QA/hist_globalTracks_centT0C_before"), cent, tracks.size()); + histosQA.fill(HIST("QA/hist_PVTracks_centT0C_before"), cent, collision.multNTracksPV()); + histosQA.fill(HIST("QA/hist_globalTracks_PVTracks_before"), collision.multNTracksPV(), tracks.size()); + histosQA.fill(HIST("QA/hist_globalTracks_multT0A_before"), collision.multFT0A(), tracks.size()); + histosQA.fill(HIST("QA/hist_globalTracks_multV0A_before"), collision.multFV0A(), tracks.size()); + histosQA.fill(HIST("QA/hist_multV0A_multT0A_before"), collision.multFT0A(), collision.multFV0A()); + histosQA.fill(HIST("QA/hist_multT0C_centT0C_before"), cent, collision.multFT0C()); + } + if (cfgUseAdditionalEventCut && !selEvent(collision, tracks.size(), cent)) { + return; + } + histosQA.fill(HIST("QA/histEventCount"), 2.5); + histosQA.fill(HIST("QA/histCentrality"), cent); + histosQA.fill(HIST("QA/histVertexZRec"), collision.posZ()); + if (cfgOpenFullEventQA) { + histosQA.fill(HIST("QA/hist_globalTracks_centT0C_after"), cent, tracks.size()); + histosQA.fill(HIST("QA/hist_PVTracks_centT0C_after"), cent, collision.multNTracksPV()); + histosQA.fill(HIST("QA/hist_globalTracks_PVTracks_after"), collision.multNTracksPV(), tracks.size()); + histosQA.fill(HIST("QA/hist_globalTracks_multT0A_after"), collision.multFT0A(), tracks.size()); + histosQA.fill(HIST("QA/hist_globalTracks_multV0A_after"), collision.multFV0A(), tracks.size()); + histosQA.fill(HIST("QA/hist_multV0A_multT0A_after"), collision.multFT0A(), collision.multFV0A()); + histosQA.fill(HIST("QA/hist_multT0C_centT0C_after"), cent, collision.multFT0C()); + } + if (cfgkOpenDebugPIDCME) { + LOGF(info, "==================Event Cut Finished===================="); + } + auto tracks1 = tracksSet1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto tracks2 = tracksSet2->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto tracks3 = tracksSet3->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + mult1 = tracks1.size(); + mult2 = tracks2.size(); + mult3 = tracks3.size(); + if (mult1 < 1 || mult2 < 1 || mult3 < 1) // Reject Collisions without sufficient particles + return; + const float cenPlotMin = 20; + const float cenPlotMax = 30; + for (auto i = 0; i < static_cast(cfgnMods->size()); i++) { + int detIndGlobal = detId * 4 + cfgnTotalSystem * 4 * (cfgnMods->at(i) - 2); + float psiNGlobal = helperEP.GetEventPlane(collision.qvecRe()[detIndGlobal + 3], collision.qvecIm()[detIndGlobal + 3], cfgnMods->at(i)); + for (const auto& trk : tracks) { + if (!selTrack(trk, cent)) + continue; + if (cfgkOpenTPCITSPurityCut && cfgkOpenTPCITSPurityCutQA) { + if (cent >= cenPlotMin && cent < cenPlotMax) { + if ((trk.nPidFlag() == pid_flags::kProton) || (trk.nPidFlag() == pid_flags::kPionProton) || (trk.nPidFlag() == pid_flags::kKaonProton) || (trk.nPidFlag() == pid_flags::kPionKaonProton)) { + if (trk.sign() > 0) { + histosQA.fill(HIST("QA/histITSPuritycheck_Pr_Pos_Cen_20_30"), trk.nSigmaPrTPC(), trk.nSigmaPrITS(), trk.pt()); + } else { + histosQA.fill(HIST("QA/histITSPuritycheck_Pr_Neg_Cen_20_30"), trk.nSigmaPrTPC(), trk.nSigmaPrITS(), trk.pt()); + } + } + } + } + if (cfgkOpenV2) { + histosQA.fill(HIST("V2/histSinDetV2"), cent, trk.pt(), + std::sin(static_cast(cfgnMods->at(i)) * (trk.phi() - psiNGlobal))); + histosQA.fill(HIST("V2/histCosDetV2"), cent, trk.pt(), + std::cos(static_cast(cfgnMods->at(i)) * (trk.phi() - psiNGlobal))); + } + } + if (cfgkOpenCME && cfgkOpenHaHa && cfgnMods->at(i) == fourier_mode::kMode2) { + for (const auto& trk1 : tracks) { + if (!selTrack(trk1, cent)) + continue; + for (const auto& trk2 : tracks) { + if (trk1.globalIndex() == trk2.globalIndex()) + continue; + if (!selTrack(trk2, cent)) + continue; + if (trk1.sign() == trk2.sign()) { + histosQA.fill(HIST("PIDCME/histgamma_HaHa_ss"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/histdelta_HaHa_ss"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_HaHa_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_HaHa_ss_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_HaHa_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_HaHa_ss_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_HaHa_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_HaHa_ss_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() > 0) { + histosQA.fill(HIST("PIDCME/histgamma_HaHa_PP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/histdelta_HaHa_PP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_HaHa_NN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/histdelta_HaHa_NN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } else { + histosQA.fill(HIST("PIDCME/histgamma_HaHa_os"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/histdelta_HaHa_os"), cent, std::cos((trk1.phi() - trk2.phi()))); + if (cfgkOpenCMEDifferential) { + if (cfgkOpenDeltaPt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_HaHa_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_HaHa_os_DPt"), cent, trk1.pt() - trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenDeltaEta) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_HaHa_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_HaHa_os_DEt"), cent, trk1.eta() - trk2.eta(), + std::cos((trk1.phi() - trk2.phi()))); + } + if (cfgkOpenAveragePt) { + histosQA.fill(HIST("PIDCME/Differential/histgamma_HaHa_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/Differential/histdelta_HaHa_os_SPt"), cent, trk1.pt() + trk2.pt(), + std::cos((trk1.phi() - trk2.phi()))); + } + } + if (cfgkOpenSsOsCrossCheck) { + if (trk1.sign() > 0 && trk2.sign() < 0) { + histosQA.fill(HIST("PIDCME/histgamma_HaHa_PN"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/histdelta_HaHa_PN"), cent, std::cos((trk1.phi() - trk2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamma_HaHa_NP"), cent, std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); + histosQA.fill(HIST("PIDCME/histdelta_HaHa_NP"), cent, std::cos((trk1.phi() - trk2.phi()))); + } + } + } + } + } + } + fillHistosQvec(collision, cfgnMods->at(i)); + fillHistosFlowGammaDelta(collision, tracks1, tracks2, tracks3, cfgnMods->at(i)); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGCF/Flow/Tasks/flowPtEfficiency.cxx b/PWGCF/Flow/Tasks/flowPtEfficiency.cxx index 874f0c3d2df..27657e0f435 100644 --- a/PWGCF/Flow/Tasks/flowPtEfficiency.cxx +++ b/PWGCF/Flow/Tasks/flowPtEfficiency.cxx @@ -8,21 +8,38 @@ // 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. -/// -/// \brief This task is an empty skeleton that fills a simple eta histogram. -/// it is meant to be a blank page for further developments. -/// \author everyone -#include -#include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Common/DataModel/TrackSelectionTables.h" +/// \file flowPtEfficiency.cxx +/// \author Mingrui Zhao (mingrui.zhao@cern.ch), Zhiyong Lu (zhiyong.lu@cern.ch), Tao Jiang (tao.jiang@cern.ch) +/// \since Jun/08/2023 +/// \brief a task to calculate the pt efficiency + +#include "FlowContainer.h" +#include "GFW.h" +#include "GFWCumulant.h" +#include "GFWPowerArray.h" +#include "GFWWeights.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include + +#include +#include +#include +#include + +#include +#include using namespace o2; using namespace o2::framework; @@ -30,144 +47,494 @@ using namespace o2::framework::expressions; #define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; -struct flowPtEfficiency { +struct FlowPtEfficiency { O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 3.0f, "Maximal pT for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 1000.0f, "Maximal pT for tracks") O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgkIsTrackGlobal, bool, false, "GlobalTrack requirement for tracks") O2_DEFINE_CONFIGURABLE(cfgTrkSelRun3ITSMatch, bool, false, "GlobalTrackRun3ITSMatching::Run3ITSall7Layers selection") O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5f, "max chi2 per TPC clusters") O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 70.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters") O2_DEFINE_CONFIGURABLE(cfgCutTPCcrossedrows, float, 70.0f, "minimum TPC crossed rows") O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 0.2f, "DCAxy cut for tracks") + O2_DEFINE_CONFIGURABLE(cfgDCAxyNSigma, float, 7, "Cut on number of sigma deviations from expected DCA in the transverse direction"); + O2_DEFINE_CONFIGURABLE(cfgDCAxyFunction, std::string, "(0.0015+0.005/(x^1.1))", "Functional form of pt-dependent DCAxy cut"); O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "DCAz cut for tracks") O2_DEFINE_CONFIGURABLE(cfgCutDCAxyppPass3Enabled, bool, false, "switch of ppPass3 DCAxy pt dependent cut") O2_DEFINE_CONFIGURABLE(cfgCutDCAzPtDepEnabled, bool, false, "switch of DCAz pt dependent cut") + O2_DEFINE_CONFIGURABLE(cfgEnableITSCuts, bool, true, "switch of enabling ITS based track selection cuts") O2_DEFINE_CONFIGURABLE(cfgSelRunNumberEnabled, bool, false, "switch of run number selection") + O2_DEFINE_CONFIGURABLE(cfgFlowEnabled, bool, false, "switch of calculating flow") + O2_DEFINE_CONFIGURABLE(cfgFlowNbootstrap, int, 30, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgFlowCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgFlowCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgFlowCutPtRefMin, float, 0.2f, "Minimal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgFlowCutPtRefMax, float, 3.0f, "Maximal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCentVsIPTruth, std::string, "", "CCDB path to centrality vs IP truth") + O2_DEFINE_CONFIGURABLE(cfgCentVsIPReco, std::string, "", "CCDB path to centrality vs IP reco") + O2_DEFINE_CONFIGURABLE(cfgFlowAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgFlowEfficiency, std::string, "", "CCDB path to efficiency object") Configurable> cfgRunNumberList{"cfgRunNumberList", std::vector{-1}, "runnumber list in consideration for analysis"}; - ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.30, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00}, "pt axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}, "pt axis for histograms"}; + ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "X axis for histograms"}; + ConfigurableAxis axisPhi{"axisPhi", {100, 0.0f, constants::math::TwoPI}, ""}; + ConfigurableAxis axisB{"axisB", {100, 0.0f, 20.0f}, "b (fm)"}; + ConfigurableAxis axisNch{"axisNch", {6000, 0, 6000}, "N_{ch}"}; // Filter the tracks Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); - using myTracks = soa::Filtered>; + using MyTracks = soa::Filtered>; // Filter for collisions Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; - using myCollisions = soa::Filtered>; + using MyCollisions = soa::Filtered>; // Filter for MCParticle Filter particleFilter = (nabs(aod::mcparticle::eta) < cfgCutEta) && (aod::mcparticle::pt > cfgCutPtMin) && (aod::mcparticle::pt < cfgCutPtMax); - using myMcParticles = soa::Filtered; + using MyMcParticles = soa::Filtered; // Filter for MCcollisions Filter mccollisionFilter = nabs(aod::mccollision::posZ) < cfgCutVertex; - using myMcCollisions = soa::Filtered; + using MyMcCollisions = soa::Filtered; + + Preslice perCollision = aod::track::collisionId; // Additional filters for tracks TrackSelection myTrackSel; + // Cent vs IP + TH1D* mCentVsIPTruth = nullptr; + bool centVsIPTruthLoaded = false; + TH1D* mCentVsIPReco = nullptr; + bool centVsIPRecoLoaded = false; + + // corrections + TH1D* mEfficiency = nullptr; + GFWWeights* mAcceptance = nullptr; + bool correctionsLoaded = false; + + // Connect to ccdb + Service ccdb; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + // Define the output HistogramRegistry registry{"registry"}; + OutputObj fFCTrue{FlowContainer("FlowContainerTrue")}; + OutputObj fFCReco{FlowContainer("FlowContainerReco")}; + OutputObj fWeights{GFWWeights("weights")}; + GFW* fGFWTrue = new GFW(); + GFW* fGFWReco = new GFW(); + TAxis* fPtAxis; + std::vector corrconfigsTruth; + std::vector corrconfigsReco; + TRandom3* fRndm = new TRandom3(0); + TF1* fPtDepDCAxy = nullptr; bool isStable(int pdg) { - if (abs(pdg) == 211) + if (std::abs(pdg) == PDG_t::kPiPlus) return true; - if (abs(pdg) == 321) + if (std::abs(pdg) == PDG_t::kKPlus) return true; - if (abs(pdg) == 2212) + if (std::abs(pdg) == PDG_t::kProton) return true; - if (abs(pdg) == 11) + if (std::abs(pdg) == PDG_t::kElectron) return true; - if (abs(pdg) == 13) + if (std::abs(pdg) == PDG_t::kMuonMinus) return true; return false; } void init(InitContext const&) { + const AxisSpec axisVertex{20, -10, 10, "Vtxz (cm)"}; + const AxisSpec axisEta{20, -1., 1., "#eta"}; const AxisSpec axisCounter{1, 0, +1, ""}; // create histograms registry.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); registry.add("hPtMCRec", "Monte Carlo Reco", {HistType::kTH1D, {axisPt}}); + registry.add("hPtNchMCRec", "Reco production; pT (GeV/c); multiplicity", {HistType::kTH2D, {axisPt, axisNch}}); + registry.add("hBVsPtVsPhiRec", "hBVsPtVsPhiRec", HistType::kTH3D, {axisB, axisPhi, axisPt}); + registry.add("hEtaPtVzRec", "hEtaPtVz Reconstructed", HistType::kTH3D, {axisEta, axisPt, axisVertex}); registry.add("mcEventCounter", "Monte Carlo Truth EventCounter", kTH1F, {axisCounter}); registry.add("hPtMCGen", "Monte Carlo Truth", {HistType::kTH1D, {axisPt}}); + registry.add("hPtNchMCGen", "Truth production; pT (GeV/c); multiplicity", {HistType::kTH2D, {axisPt, axisNch}}); + registry.add("numberOfRecoCollisions", "numberOfRecoCollisions", kTH1F, {{10, -0.5f, 9.5f}}); + registry.add("hBVsPtVsPhiTrue", "hBVsPtVsPhiTrue", HistType::kTH3D, {axisB, axisPhi, axisPt}); + registry.add("hEtaPtVzTrue", "hEtaPtVz True", HistType::kTH3D, {axisEta, axisPt, axisVertex}); - if (cfgTrkSelRun3ITSMatch) { - myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default); - } else { - myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + if (cfgFlowEnabled) { + registry.add("hImpactParameterReco", "hImpactParameterReco", {HistType::kTH1D, {axisB}}); + registry.add("hImpactParameterTruth", "hImpactParameterTruth", {HistType::kTH1D, {axisB}}); + registry.add("hPhi", "#phi distribution", {HistType::kTH1D, {axisPhi}}); + registry.add("hPhiMCTruth", "#phi distribution", {HistType::kTH1D, {axisPhi}}); + registry.add("hPhiWeighted", "corrected #phi distribution", {HistType::kTH1D, {axisPhi}}); + + o2::framework::AxisSpec axis = axisPt; + int nPtBins = axis.binEdges.size() - 1; + double* ptBins = &(axis.binEdges)[0]; + fPtAxis = new TAxis(nPtBins, ptBins); + + fWeights->setPtBins(nPtBins, ptBins); + fWeights->init(true, false); + + TObjArray* oba = new TObjArray(); + oba->Add(new TNamed("ChFull22", "ChFull22")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull22_pt_%i", i + 1), "ChFull22_pTDiff")); + oba->Add(new TNamed("Ch10Gap22", "Ch10Gap22")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap22_pt_%i", i + 1), "Ch10Gap22_pTDiff")); + fFCTrue->SetName("FlowContainerTrue"); + fFCTrue->SetXAxis(fPtAxis); + fFCTrue->Initialize(oba, axisCentrality, cfgFlowNbootstrap); + fFCReco->SetName("FlowContainerReco"); + fFCReco->SetXAxis(fPtAxis); + fFCReco->Initialize(oba, axisCentrality, cfgFlowNbootstrap); + delete oba; + + fGFWTrue->AddRegion("full", -0.8, 0.8, 1, 1); + fGFWTrue->AddRegion("refN10", -0.8, -0.5, 1, 1); + fGFWTrue->AddRegion("refP10", 0.5, 0.8, 1, 1); + fGFWTrue->AddRegion("poiN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 2); + fGFWTrue->AddRegion("poifull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 2); + fGFWTrue->AddRegion("olN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 4); + fGFWTrue->AddRegion("olfull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 4); + corrconfigsTruth.push_back(fGFWTrue->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); + corrconfigsTruth.push_back(fGFWTrue->GetCorrelatorConfig("poifull full | olfull {2 -2}", "ChFull22", kTRUE)); + corrconfigsTruth.push_back(fGFWTrue->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE)); + corrconfigsTruth.push_back(fGFWTrue->GetCorrelatorConfig("poiN10 refN10 | olN10 {2} refP10 {-2}", "Ch10Gap22", kTRUE)); + fGFWTrue->CreateRegions(); + + fGFWReco->AddRegion("full", -0.8, 0.8, 1, 1); + fGFWReco->AddRegion("refN10", -0.8, -0.5, 1, 1); + fGFWReco->AddRegion("refP10", 0.5, 0.8, 1, 1); + fGFWReco->AddRegion("poiN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 2); + fGFWReco->AddRegion("poifull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 2); + fGFWReco->AddRegion("olN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 4); + fGFWReco->AddRegion("olfull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 4); + corrconfigsReco.push_back(fGFWReco->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); + corrconfigsReco.push_back(fGFWReco->GetCorrelatorConfig("poifull full | olfull {2 -2}", "ChFull22", kTRUE)); + corrconfigsReco.push_back(fGFWReco->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE)); + corrconfigsReco.push_back(fGFWReco->GetCorrelatorConfig("poiN10 refN10 | olN10 {2} refP10 {-2}", "Ch10Gap22", kTRUE)); + fGFWReco->CreateRegions(); + } + + if (cfgEnableITSCuts) { + if (cfgTrkSelRun3ITSMatch) { + myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + } else { + myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + } } if (cfgCutDCAxyppPass3Enabled) { myTrackSel.SetMaxDcaXYPtDep([](float pt) { return 0.004f + 0.013f / pt; }); } else { - myTrackSel.SetMaxDcaXY(cfgCutDCAxy); + if (cfgCutDCAxy != 0.0) { + myTrackSel.SetMaxDcaXY(cfgCutDCAxy); + } else { + fPtDepDCAxy = new TF1("ptDepDCAxy", Form("[0]*%s", cfgDCAxyFunction->c_str()), 0.001, 100); + fPtDepDCAxy->SetParameter(0, cfgDCAxyNSigma); + LOGF(info, "DCAxy pt-dependence function: %s", Form("[0]*%s", cfgDCAxyFunction->c_str())); + myTrackSel.SetMaxDcaXYPtDep([fPtDepDCAxy = this->fPtDepDCAxy](float pt) { return fPtDepDCAxy->Eval(pt); }); + } } myTrackSel.SetMinNClustersTPC(cfgCutTPCclu); myTrackSel.SetMinNCrossedRowsTPC(cfgCutTPCcrossedrows); + if (cfgEnableITSCuts) + myTrackSel.SetMinNClustersITS(cfgCutITSclu); if (!cfgCutDCAzPtDepEnabled) myTrackSel.SetMaxDcaZ(cfgCutDCAz); } + template + void fillProfile(GFW* fGFW, const GFW::CorrConfig& corrconf, const ConstStr& tarName, const double& cent) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) + registry.fill(tarName, cent, val, dnx); + return; + } + return; + } + + void fillFC(GFW* fGFW, bool isMCTruth, const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + if (isMCTruth) + fFCTrue->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); + else + fFCReco->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); + } + return; + } + for (auto i = 1; i <= fPtAxis->GetNbins(); i++) { + dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); + if (dnx == 0) + continue; + val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + if (isMCTruth) + fFCTrue->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); + else + fFCReco->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); + } + } + return; + } + + void loadCentVsIPTruth(uint64_t timestamp) + { + if (centVsIPTruthLoaded) + return; + if (cfgCentVsIPTruth.value.empty() == false) { + mCentVsIPTruth = ccdb->getForTimeStamp(cfgCentVsIPTruth, timestamp); + if (mCentVsIPTruth) + LOGF(info, "Loaded CentVsIPTruth weights from %s (%p)", cfgCentVsIPTruth.value.c_str(), (void*)mCentVsIPTruth); + else + LOGF(fatal, "Failed to load CentVsIPTruth weights from %s", cfgCentVsIPTruth.value.c_str()); + + centVsIPTruthLoaded = true; + } else { + LOGF(fatal, "when calculate flow, Cent Vs IP distribution must be provided"); + } + } + + void loadCentVsIPReco(uint64_t timestamp) + { + if (centVsIPRecoLoaded) + return; + if (cfgCentVsIPReco.value.empty() == false) { + mCentVsIPReco = ccdb->getForTimeStamp(cfgCentVsIPReco, timestamp); + if (mCentVsIPReco) + LOGF(info, "Loaded CentVsIPReco weights from %s (%p)", cfgCentVsIPReco.value.c_str(), (void*)mCentVsIPReco); + else + LOGF(fatal, "Failed to load CentVsIPReco weights from %s", cfgCentVsIPReco.value.c_str()); + + centVsIPRecoLoaded = true; + } else { + LOGF(fatal, "when calculate flow, Cent Vs IP distribution must be provided"); + } + } + + void loadCorrections(uint64_t timestamp) + { + if (correctionsLoaded) + return; + if (cfgFlowAcceptance.value.empty() == false) { + mAcceptance = ccdb->getForTimeStamp(cfgFlowAcceptance, timestamp); + if (mAcceptance) + LOGF(info, "Loaded acceptance weights from %s (%p)", cfgFlowAcceptance.value.c_str(), (void*)mAcceptance); + else + LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgFlowAcceptance.value.c_str(), (void*)mAcceptance); + } + if (cfgFlowEfficiency.value.empty() == false) { + mEfficiency = ccdb->getForTimeStamp(cfgFlowEfficiency, timestamp); + if (mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgFlowEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgFlowEfficiency.value.c_str(), (void*)mEfficiency); + } + correctionsLoaded = true; + } + + bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz) + { + float eff = 1.; + if (mEfficiency) + eff = mEfficiency->GetBinContent(mEfficiency->FindBin(pt)); + else + eff = 1.0; + if (eff == 0) + return false; + weight_nue = 1. / eff; + if (mAcceptance) + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + else + weight_nua = 1; + return true; + } + template bool trackSelected(TTrack track) { - if (cfgCutDCAzPtDepEnabled && (track.dcaZ() > (0.004f + 0.013f / track.pt()))) + if (cfgkIsTrackGlobal && !track.isGlobalTrack()) { return false; + } + if (cfgCutDCAzPtDepEnabled && (track.dcaZ() > (0.004f + 0.013f / track.pt()))) { + return false; + } return myTrackSel.IsSelected(track); } - void processReco(myCollisions::iterator const& collision, aod::BCsWithTimestamps const&, myTracks const& tracks, aod::McParticles const&) + void processReco(MyCollisions::iterator const& collision, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::McParticles const&, aod::McCollisions const&) { registry.fill(HIST("eventCounter"), 0.5); if (!collision.sel8()) return; if (tracks.size() < 1) return; + auto bc = collision.bc_as(); + int runNumber = bc.runNumber(); if (cfgSelRunNumberEnabled) { - auto bc = collision.bc_as(); - int RunNumber = bc.runNumber(); - if (!std::count(cfgRunNumberList.value.begin(), cfgRunNumberList.value.end(), RunNumber)) + if (!std::count(cfgRunNumberList.value.begin(), cfgRunNumberList.value.end(), runNumber)) return; } + float imp = 0; + bool impFetched = false; + float evPhi = 0; + float centrality = 0.; + float lRandom = fRndm->Rndm(); + float vtxz = collision.posZ(); + float wacc = 1.0f; + float weff = 1.0f; + if (cfgFlowEnabled) { + loadCentVsIPReco(bc.timestamp()); + loadCorrections(bc.timestamp()); + + fGFWReco->Clear(); + } for (const auto& track : tracks) { if (!trackSelected(track)) continue; if (track.has_mcParticle()) { auto mcParticle = track.mcParticle(); + if (cfgFlowEnabled && !impFetched) { + auto mcCollision = mcParticle.mcCollision(); + imp = mcCollision.impactParameter(); + registry.fill(HIST("hImpactParameterReco"), imp); + centrality = mCentVsIPReco->GetBinContent(mCentVsIPReco->GetXaxis()->FindBin(imp)); + evPhi = RecoDecay::constrainAngle(mcCollision.eventPlaneAngle()); + impFetched = true; + } if (isStable(mcParticle.pdgCode())) { registry.fill(HIST("hPtMCRec"), track.pt()); + registry.fill(HIST("hPtNchMCRec"), track.pt(), tracks.size()); + registry.fill(HIST("hEtaPtVzRec"), track.eta(), track.pt(), vtxz); + + if (cfgFlowEnabled) { + float deltaPhi = RecoDecay::constrainAngle(track.phi() - evPhi); + registry.fill(HIST("hBVsPtVsPhiRec"), imp, deltaPhi, track.pt()); + bool withinPtPOI = (cfgFlowCutPtPOIMin < track.pt()) && (track.pt() < cfgFlowCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgFlowCutPtRefMin < track.pt()) && (track.pt() < cfgFlowCutPtRefMax); // within RF pT range + if (withinPtRef) + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); + if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) + continue; + if (withinPtRef) { + registry.fill(HIST("hPhi"), track.phi()); + registry.fill(HIST("hPhiWeighted"), track.phi(), wacc); + } + if (withinPtRef) + fGFWReco->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 1); + if (withinPtPOI) + fGFWReco->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 2); + if (withinPtPOI && withinPtRef) + fGFWReco->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 4); + } } } } + if (cfgFlowEnabled) { + // Filling Flow Container + for (uint l_ind = 0; l_ind < corrconfigsReco.size(); l_ind++) { + fillFC(fGFWReco, false, corrconfigsReco.at(l_ind), centrality, lRandom); + } + } } - PROCESS_SWITCH(flowPtEfficiency, processReco, "process reconstructed information", true); + PROCESS_SWITCH(FlowPtEfficiency, processReco, "process reconstructed information", true); - void processSim(myMcCollisions::iterator const& collision, aod::BCsWithTimestamps const&, soa::SmallGroups> const& collisions, myMcParticles const& mcParticles) + void processSim(MyMcCollisions::iterator const& mcCollision, aod::BCsWithTimestamps const&, soa::SmallGroups> const& collisions, MyMcParticles const& mcParticles, MyTracks const& tracks) { if (cfgSelRunNumberEnabled) { - auto bc = collision.bc_as(); - int RunNumber = bc.runNumber(); - if (!std::count(cfgRunNumberList.value.begin(), cfgRunNumberList.value.end(), RunNumber)) + auto bc = mcCollision.bc_as(); + int runNumber = bc.runNumber(); + if (!std::count(cfgRunNumberList.value.begin(), cfgRunNumberList.value.end(), runNumber)) return; } + + float imp = mcCollision.impactParameter(); + float evPhi = RecoDecay::constrainAngle(mcCollision.eventPlaneAngle()); + float centrality = 0.; + if (cfgFlowEnabled) { + registry.fill(HIST("hImpactParameterTruth"), imp); + auto bc = mcCollision.bc_as(); + loadCentVsIPTruth(bc.timestamp()); + centrality = mCentVsIPTruth->GetBinContent(mCentVsIPTruth->GetXaxis()->FindBin(imp)); + + fGFWTrue->Clear(); + } + float lRandom = fRndm->Rndm(); + float wacc = 1.0f; + float weff = 1.0f; + float vtxz = mcCollision.posZ(); + if (collisions.size() > -1) { registry.fill(HIST("mcEventCounter"), 0.5); + + registry.fill(HIST("numberOfRecoCollisions"), collisions.size()); // number of times coll was reco-ed + + std::vector numberOfTracks; + for (auto const& collision : collisions) { + auto groupedTracks = tracks.sliceBy(perCollision, collision.globalIndex()); + numberOfTracks.emplace_back(groupedTracks.size()); + } + for (const auto& mcParticle : mcParticles) { if (mcParticle.isPhysicalPrimary() && isStable(mcParticle.pdgCode())) { registry.fill(HIST("hPtMCGen"), mcParticle.pt()); + if (collisions.size() > 0) { + registry.fill(HIST("hPtNchMCGen"), mcParticle.pt(), numberOfTracks[0]); + } + registry.fill(HIST("hEtaPtVzTrue"), mcParticle.eta(), mcParticle.pt(), vtxz); + + if (cfgFlowEnabled) { + float deltaPhi = RecoDecay::constrainAngle(mcParticle.phi() - evPhi); + registry.fill(HIST("hBVsPtVsPhiTrue"), imp, deltaPhi, mcParticle.pt()); + bool withinPtPOI = (cfgFlowCutPtPOIMin < mcParticle.pt()) && (mcParticle.pt() < cfgFlowCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgFlowCutPtRefMin < mcParticle.pt()) && (mcParticle.pt() < cfgFlowCutPtRefMax); // within RF pT range + if (withinPtRef) { + registry.fill(HIST("hPhiMCTruth"), mcParticle.phi()); + } + if (withinPtRef) + fGFWTrue->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), wacc * weff, 1); + if (withinPtPOI) + fGFWTrue->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), wacc * weff, 2); + if (withinPtPOI && withinPtRef) + fGFWTrue->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), wacc * weff, 4); + } + } + } + if (cfgFlowEnabled) { + // Filling Flow Container + for (uint l_ind = 0; l_ind < corrconfigsTruth.size(); l_ind++) { + fillFC(fGFWTrue, true, corrconfigsTruth.at(l_ind), centrality, lRandom); } } } } - PROCESS_SWITCH(flowPtEfficiency, processSim, "process pure simulation information", true); + PROCESS_SWITCH(FlowPtEfficiency, processSim, "process pure simulation information", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGCF/Flow/Tasks/flowQa.cxx b/PWGCF/Flow/Tasks/flowQa.cxx new file mode 100644 index 00000000000..1eaa6d8437d --- /dev/null +++ b/PWGCF/Flow/Tasks/flowQa.cxx @@ -0,0 +1,792 @@ +// 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. + +/// \file flowQa.cxx +/// \author Zhiyong Lu (zhiyong.lu@cern.ch) +/// \since Feb/23/2025 +/// \brief jira: PWGCF-254, QA for flow analysis + +#include +#include +#include +#include +#include +#include +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/HistogramRegistry.h" + +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/CCDB/ctpRateFetcher.h" + +#include "GFWPowerArray.h" +#include "GFW.h" +#include "GFWCumulant.h" +#include "GFWWeights.h" +#include "FlowContainer.h" +#include "TList.h" +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +struct FlowQa { + + O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FT0A") + O2_DEFINE_CONFIGURABLE(cfgCentFT0CMin, float, 0.0f, "Minimum centrality (FT0C) to cut events in filter") + O2_DEFINE_CONFIGURABLE(cfgCentFT0CMax, float, 100.0f, "Maximum centrality (FT0C) to cut events in filter") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtRefMin, float, 0.2f, "Minimal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtRefMax, float, 3.0f, "Maximal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for all tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 10.0f, "Maximal pT for all tracks") + O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 30.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters") + O2_DEFINE_CONFIGURABLE(cfgCutITSTPCcluEnabled, bool, false, "switch of minimum ITS/TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "max DCA to vertex z") + O2_DEFINE_CONFIGURABLE(cfgCutDCAxyppPass3Enabled, bool, false, "switch of ppPass3 DCAxy pt dependent cut") + O2_DEFINE_CONFIGURABLE(cfgCutDCAzPtDepEnabled, bool, false, "switch of DCAz pt dependent cut") + O2_DEFINE_CONFIGURABLE(cfgTrackType, int, 0, "0:Global; 1:GlobalSDD; 2:QualityITS; 3:QualityTPC; 4:ITS; 5: TPC; 6:GloalorITS; 7: GlobalorTPC") + O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") + O2_DEFINE_CONFIGURABLE(cfgUseTentativeEventCounter, bool, false, "After sel8(), count events regardless of real event selection") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoSameBunchPileup, bool, false, "rejects collisions which are associated with the same found-by-T0 bunch crossing") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodZvtxFT0vsPV, bool, false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference, use this cut at low multiplicities with caution") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInTimeRangeStandard, bool, false, "no collisions in specified time range") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodITSLayersAll, bool, true, "cut time intervals with dead ITS staves") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInRofStandard, bool, false, "no other collisions in this Readout Frame with per-collision multiplicity above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoHighMultCollInPrevRof, bool, false, "veto an event if FT0C amplitude in previous ITS ROF is above threshold") + O2_DEFINE_CONFIGURABLE(cfgGetInteractionRate, bool, false, "Get interaction rate from CCDB") + O2_DEFINE_CONFIGURABLE(cfgUseInteractionRateCut, bool, false, "Use events with low interaction rate") + O2_DEFINE_CONFIGURABLE(cfgCutMaxIR, float, 50.0f, "maximum interaction rate (kHz)") + O2_DEFINE_CONFIGURABLE(cfgCutMinIR, float, 0.0f, "minimum interaction rate (kHz)") + O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables") + O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 30, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeightsRefPt, bool, false, "NUA weights are filled in ref pt bins") + O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgAcceptanceList, std::string, "", "CCDB path to acceptance lsit object") + O2_DEFINE_CONFIGURABLE(cfgAcceptanceListEnabled, bool, false, "switch of acceptance list") + O2_DEFINE_CONFIGURABLE(cfgEvSelOccupancy, bool, true, "Occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgUseSmallMemory, bool, false, "Use small memory mode") + O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrUse, bool, false, "Use track density efficiency correction") + O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrSlopeFactor, float, 1.0f, "A factor to scale the track density efficiency slope") + Configurable> cfgUserDefineGFWCorr{"cfgUserDefineGFWCorr", std::vector{"refN02 {2} refP02 {-2}", "refN12 {2} refP12 {-2}"}, "User defined GFW CorrelatorConfig"}; + Configurable> cfgUserDefineGFWName{"cfgUserDefineGFWName", std::vector{"Ch02Gap22", "Ch12Gap22"}, "User defined GFW Name"}; + Configurable> cfgRunRemoveList{"cfgRunRemoveList", std::vector{-1}, "excluded run numbers"}; + Configurable> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector{0.6003720411, 0.6152630970, 0.6288860646, 0.6360694031, 0.6409494798, 0.6450540203, 0.6482117301, 0.6512592056, 0.6640008690, 0.6862631416, 0.7005738691, 0.7106567432, 0.7170728333}, "parameter 0 for track density efficiency correction"}; + Configurable> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector{-1.007592e-05, -8.932635e-06, -9.114538e-06, -1.054818e-05, -1.220212e-05, -1.312304e-05, -1.376433e-05, -1.412813e-05, -1.289562e-05, -1.050065e-05, -8.635725e-06, -7.380821e-06, -6.201250e-06}, "parameter 1 for track density efficiency correction"}; + + ConfigurableAxis axisPtHist{"axisPtHist", {100, 0., 10.}, "pt axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}, "pt axis for histograms"}; + ConfigurableAxis axisIndependent{"axisIndependent", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "X axis for histograms"}; + ConfigurableAxis axisNch{"axisNch", {4000, 0, 4000}, "N_{ch}"}; + ConfigurableAxis axisDCAz{"axisDCAz", {200, -2, 2}, "DCA_{z} (cm)"}; + ConfigurableAxis axisDCAxy{"axisDCAxy", {200, -1, 1}, "DCA_{xy} (cm)"}; + + Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVertex) && (aod::cent::centFT0C > cfgCentFT0CMin) && (aod::cent::centFT0C < cfgCentFT0CMax); + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + + // Corrections + TH1D* mEfficiency = nullptr; + GFWWeights* mAcceptance = nullptr; + TObjArray* mAcceptanceList = nullptr; + bool correctionsLoaded = false; + + // Connect to ccdb + Service ccdb; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + // Define output + OutputObj fFC{FlowContainer("FlowContainer")}; + OutputObj fWeights{GFWWeights("weights")}; + HistogramRegistry registry{"registry"}; + + // define global variables + GFW* fGFW = new GFW(); + std::vector corrconfigs; + TAxis* fPtAxis; + TRandom3* fRndm = new TRandom3(0); + enum CentEstimators { + kCentFT0C = 0, + kCentFT0CVariant1, + kCentFT0M, + kCentFV0A, + // Count the total number of enum + kCount_CentEstimators + }; + enum TrackType { + kGlobalTrack = 0, + kGlobalTrackSDD, + kQualityTracksITS, + kQualityTracksTPC, + kITSTracks, + kTPCTracks, + kGlobalOrITSTracks, + kGlobalOrTPCTracks, + // Count the total number of enum + kCount_TrackType + }; + int mRunNumber{-1}; + uint64_t mSOR{0}; + double mMinSeconds{-1.}; + std::unordered_map gHadronicRate; + ctpRateFetcher mRateFetcher; + TH2* gCurrentHadronicRate; + + std::vector funcEff; + TH1D* hFindPtBin; + TF1* funcV2; + TF1* funcV3; + TF1* funcV4; + + using AodCollisions = soa::Filtered>; + using AodTracks = soa::Filtered>; + + void init(InitContext const&) + { + const AxisSpec axisVertex{40, -20, 20, "Vtxz (cm)"}; + const AxisSpec axisPhi{60, 0.0, constants::math::TwoPI, "#varphi"}; + const AxisSpec axisEta{40, -1., 1., "#eta"}; + const AxisSpec axisCentForQA{100, 0, 100, "centrality (%)"}; + const AxisSpec axisT0C{70, 0, 70000, "N_{ch} (T0C)"}; + const AxisSpec axisT0A{200, 0, 200000, "N_{ch} (T0A)"}; + + ccdb->setURL(ccdbUrl.value); + ccdb->setCaching(true); + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + + // Add some output objects to the histogram registry + // Event QA + registry.add("hEventCount", "Number of Event;; Count", {HistType::kTH1D, {{5, 0, 5}}}); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(1, "Filtered event"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(2, "after sel8"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(3, "after supicious Runs removal"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(4, "after additional event cut"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(5, "after correction loads"); + registry.add("hEventCountSpecific", "Number of Event;; Count", {HistType::kTH1D, {{8, 0, 8}}}); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(1, "after sel8"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(2, "kNoSameBunchPileup"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(3, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(4, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(5, "kIsGoodITSLayersAll"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(6, "kNoCollInRofStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(7, "kNoHighMultCollInPrevRof"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(8, "occupancy"); + if (cfgUseTentativeEventCounter) { + registry.add("hEventCountTentative", "Number of Event;; Count", {HistType::kTH1D, {{8, 0, 8}}}); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(1, "after sel8"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(2, "kNoSameBunchPileup"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(3, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(4, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(5, "kIsGoodITSLayersAll"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(6, "kNoCollInRofStandard"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(7, "kNoHighMultCollInPrevRof"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(8, "occupancy"); + } + registry.add("hVtxZ", "Vexter Z distribution", {HistType::kTH1D, {axisVertex}}); + std::string hMultTitle = "Multiplicity distribution, TrackType " + std::to_string(cfgTrackType); + registry.add("hMult", hMultTitle.c_str(), {HistType::kTH1D, {{6000, 0, 6000}}}); + std::string hCentTitle = "Centrality distribution, Estimator " + std::to_string(cfgCentEstimator); + registry.add("hCent", hCentTitle.c_str(), {HistType::kTH1D, {{90, 0, 90}}}); + if (!cfgUseSmallMemory) { + registry.add("BeforeSel8_Tracks_centT0C", "before sel8;Centrality T0C;mulplicity tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("BeforeCut_Tracks_centT0C", "before cut;Centrality T0C;mulplicity tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("BeforeCut_PVTracks_centT0C", "before cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("BeforeCut_Tracks_PVTracks", "before cut;mulplicity PV tracks;mulplicity tracks", {HistType::kTH2D, {axisNch, axisNch}}); + registry.add("BeforeCut_Tracks_multT0A", "before cut;mulplicity T0A;mulplicity tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("BeforeCut_Tracks_multV0A", "before cut;mulplicity V0A;mulplicity tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("BeforeCut_multV0A_multT0A", "before cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); + registry.add("BeforeCut_multT0C_centT0C", "before cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); + registry.add("Tracks_centT0C", "after cut;Centrality T0C;mulplicity tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("PVTracks_centT0C", "after cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("Tracks_PVTracks", "after cut;mulplicity PV tracks;mulplicity tracks", {HistType::kTH2D, {axisNch, axisNch}}); + registry.add("Tracks_multT0A", "after cut;mulplicity T0A;mulplicity tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("Tracks_multV0A", "after cut;mulplicity V0A;mulplicity tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("multV0A_multT0A", "after cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); + registry.add("multT0C_centT0C", "after cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); + registry.add("centFT0CVar_centFT0C", "after cut;Centrality T0C;Centrality T0C Var", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); + registry.add("centFT0M_centFT0C", "after cut;Centrality T0C;Centrality T0M", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); + registry.add("centFV0A_centFT0C", "after cut;Centrality T0C;Centrality V0A", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); + } + // Track QA + registry.add("hPhi", "#phi distribution", {HistType::kTH1D, {axisPhi}}); + registry.add("hPhiWeighted", "corrected #phi distribution", {HistType::kTH1D, {axisPhi}}); + registry.add("hPhiWeightedTrDen", "corrected #phi distribution, considering track density", {HistType::kTH1D, {axisPhi}}); + registry.add("hEta", "#eta distribution", {HistType::kTH1D, {axisEta}}); + registry.add("hPt", "p_{T} distribution before cut", {HistType::kTH1D, {axisPtHist}}); + registry.add("hPtRef", "p_{T} distribution after cut", {HistType::kTH1D, {axisPtHist}}); + registry.add("hChi2prTPCcls", "#chi^{2}/cluster for the TPC track segment", {HistType::kTH1D, {{100, 0., 5.}}}); + registry.add("hChi2prITScls", "#chi^{2}/cluster for the ITS track", {HistType::kTH1D, {{100, 0., 50.}}}); + registry.add("hnTPCClu", "Number of found TPC clusters", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("hnITSClu", "Number of found ITS clusters", {HistType::kTH1D, {{100, 0, 20}}}); + registry.add("hnTPCCrossedRow", "Number of crossed TPC Rows", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("hDCAz", "DCAz after cuts; DCAz (cm); Pt", {HistType::kTH2D, {{200, -0.5, 0.5}, {200, 0, 5}}}); + registry.add("hDCAxy", "DCAxy after cuts; DCAxy (cm); Pt", {HistType::kTH2D, {{200, -0.5, 0.5}, {200, 0, 5}}}); + registry.add("hTrackCorrection2d", "Correlation table for number of tracks table; uncorrected track; corrected track", {HistType::kTH2D, {axisNch, axisNch}}); + + o2::framework::AxisSpec axis = axisPt; + int nPtBins = axis.binEdges.size() - 1; + double* ptBins = &(axis.binEdges)[0]; + fPtAxis = new TAxis(nPtBins, ptBins); + + if (cfgOutputNUAWeights) { + fWeights->setPtBins(nPtBins, ptBins); + fWeights->init(true, false); + } + + // add in FlowContainer to Get boostrap sample automatically + TObjArray* oba = new TObjArray(); + oba->Add(new TNamed("ChGap22", "ChGap22")); + oba->Add(new TNamed("ChFull22", "ChFull22")); + oba->Add(new TNamed("ChFull32", "ChFull32")); + oba->Add(new TNamed("ChFull42", "ChFull42")); + oba->Add(new TNamed("ChFull24", "ChFull24")); + oba->Add(new TNamed("ChFull26", "ChFull26")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull22_pt_%i", i + 1), "ChFull22_pTDiff")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull24_pt_%i", i + 1), "ChFull24_pTDiff")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull26_pt_%i", i + 1), "ChFull26_pTDiff")); + oba->Add(new TNamed("Ch10Gap22", "Ch10Gap22")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap22_pt_%i", i + 1), "Ch10Gap22_pTDiff")); + oba->Add(new TNamed("Ch10Gap32", "Ch10Gap32")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap32_pt_%i", i + 1), "Ch10Gap32_pTDiff")); + oba->Add(new TNamed("Ch10Gap42", "Ch10Gap42")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap42_pt_%i", i + 1), "Ch10Gap42_pTDiff")); + oba->Add(new TNamed("Ch10GapA422", "Ch10GapA422")); + oba->Add(new TNamed("Ch10GapB422", "Ch10GapB422")); + oba->Add(new TNamed("ChFull3232", "ChFull3232")); + oba->Add(new TNamed("ChFull4242", "ChFull4242")); + oba->Add(new TNamed("Ch10Gap24", "Ch10Gap24")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap24_pt_%i", i + 1), "Ch10Gap24_pTDiff")); + std::vector userDefineGFWCorr = cfgUserDefineGFWCorr; + std::vector userDefineGFWName = cfgUserDefineGFWName; + if (!userDefineGFWCorr.empty() && !userDefineGFWName.empty()) { + for (uint i = 0; i < userDefineGFWName.size(); i++) { + oba->Add(new TNamed(userDefineGFWName.at(i).c_str(), userDefineGFWName.at(i).c_str())); + } + } + fFC->SetName("FlowContainer"); + fFC->SetXAxis(fPtAxis); + fFC->Initialize(oba, axisIndependent, cfgNbootstrap); + delete oba; + + // eta region + fGFW->AddRegion("full", -0.8, 0.8, 1, 1); + fGFW->AddRegion("refN00", -0.8, 0., 1, 1); // gap0 negative region + fGFW->AddRegion("refP00", 0., 0.8, 1, 1); // gap0 positve region + fGFW->AddRegion("refN02", -0.8, -0.1, 1, 1); // gap2 negative region + fGFW->AddRegion("refP02", 0.1, 0.8, 1, 1); // gap2 positve region + fGFW->AddRegion("refN04", -0.8, -0.2, 1, 1); // gap4 negative region + fGFW->AddRegion("refP04", 0.2, 0.8, 1, 1); // gap4 positve region + fGFW->AddRegion("refN06", -0.8, -0.3, 1, 1); // gap6 negative region + fGFW->AddRegion("refP06", 0.3, 0.8, 1, 1); // gap6 positve region + fGFW->AddRegion("refN08", -0.8, -0.4, 1, 1); + fGFW->AddRegion("refP08", 0.4, 0.8, 1, 1); + fGFW->AddRegion("refN10", -0.8, -0.5, 1, 1); + fGFW->AddRegion("refP10", 0.5, 0.8, 1, 1); + fGFW->AddRegion("refN12", -0.8, -0.6, 1, 1); + fGFW->AddRegion("refP12", 0.6, 0.8, 1, 1); + fGFW->AddRegion("refN14", -0.8, -0.7, 1, 1); + fGFW->AddRegion("refP14", 0.7, 0.8, 1, 1); + fGFW->AddRegion("refN", -0.8, -0.4, 1, 1); + fGFW->AddRegion("refP", 0.4, 0.8, 1, 1); + fGFW->AddRegion("refM", -0.4, 0.4, 1, 1); + fGFW->AddRegion("poiN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 2); + fGFW->AddRegion("poiN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 2); + fGFW->AddRegion("poifull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 2); + fGFW->AddRegion("olN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 4); + fGFW->AddRegion("olN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 4); + fGFW->AddRegion("olfull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 4); + + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {3 -3}", "ChFull32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {4 -4}", "ChFull42", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 -2 -2}", "ChFull24", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 2 -2 -2 -2}", "ChFull26", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {3} refP10 {-3}", "Ch10Gap32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {4} refP10 {-4}", "Ch10Gap42", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN {2} refP {-2}", "ChGap22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifull full | olfull {2 -2}", "ChFull22", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifull full | olfull {2 2 -2 -2}", "ChFull24", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifull full | olfull {2 2 2 -2 -2 -2}", "ChFull26", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {2} refP10 {-2}", "Ch10Gap22", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {3} refP10 {-3}", "Ch10Gap32", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {4} refP10 {-4}", "Ch10Gap42", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {-2 -2} refP10 {4}", "Ch10GapA422", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {4} refP10 {-2 -2}", "Ch10GapB422", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {3 2 -3 -2}", "ChFull3232", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {4 2 -4 -2}", "ChFull4242", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {2 2} refP10 {-2 -2}", "Ch10Gap24", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {2 2} refP10 {-2 -2}", "Ch10Gap24", kTRUE)); + if (!userDefineGFWCorr.empty() && !userDefineGFWName.empty()) { + LOGF(info, "User adding GFW CorrelatorConfig:"); + // attentaion: here we follow the index of cfgUserDefineGFWCorr + for (uint i = 0; i < userDefineGFWCorr.size(); i++) { + if (i >= userDefineGFWName.size()) { + LOGF(fatal, "The names you provided are more than configurations. userDefineGFWName.size(): %d > userDefineGFWCorr.size(): %d", userDefineGFWName.size(), userDefineGFWCorr.size()); + break; + } + LOGF(info, "%d: %s %s", i, userDefineGFWCorr.at(i).c_str(), userDefineGFWName.at(i).c_str()); + corrconfigs.push_back(fGFW->GetCorrelatorConfig(userDefineGFWCorr.at(i).c_str(), userDefineGFWName.at(i).c_str(), kFALSE)); + } + } + fGFW->CreateRegions(); + + if (cfgTrackDensityCorrUse) { + std::vector pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0}; + hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]); + funcEff.resize(pTEffBins.size() - 1); + // LHC24g3 Eff + std::vector f1p0 = cfgTrackDensityP0; + std::vector f1p1 = cfgTrackDensityP1; + for (uint ifunc = 0; ifunc < pTEffBins.size() - 1; ifunc++) { + funcEff[ifunc] = new TF1(Form("funcEff%i", ifunc), "[0]+[1]*x", 0, 3000); + funcEff[ifunc]->SetParameters(f1p0[ifunc], f1p1[ifunc] * cfgTrackDensityCorrSlopeFactor); + } + funcV2 = new TF1("funcV2", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV2->SetParameters(0.0186111, 0.00351907, -4.38264e-05, 1.35383e-07, -3.96266e-10); + funcV3 = new TF1("funcV3", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV3->SetParameters(0.0174056, 0.000703329, -1.45044e-05, 1.91991e-07, -1.62137e-09); + funcV4 = new TF1("funcV4", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV4->SetParameters(0.008845, 0.000259668, -3.24435e-06, 4.54837e-08, -6.01825e-10); + } + } + + template + void fillProfile(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const double& cent) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) + registry.fill(tarName, cent, val, dnx); + return; + } + return; + } + + void fillFC(const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) + fFC->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); + return; + } + for (auto i = 1; i <= fPtAxis->GetNbins(); i++) { + dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); + if (dnx == 0) + continue; + val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; + if (std::fabs(val) < 1) + fFC->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); + } + return; + } + + void loadCorrections(uint64_t timestamp, int runNumber) + { + if (correctionsLoaded) + return; + if (!cfgAcceptanceListEnabled && cfgAcceptance.value.empty() == false) { + mAcceptance = ccdb->getForTimeStamp(cfgAcceptance, timestamp); + if (mAcceptance) + LOGF(info, "Loaded acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); + else + LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); + } + if (cfgAcceptanceListEnabled && cfgAcceptanceList.value.empty() == false) { + mAcceptanceList = ccdb->getForTimeStamp(cfgAcceptanceList, timestamp); + if (mAcceptanceList == nullptr) { + LOGF(fatal, "Could not load acceptance weights list from %s", cfgAcceptanceList.value.c_str()); + } + LOGF(info, "Loaded acceptance weights list from %s (%p)", cfgAcceptanceList.value.c_str(), (void*)mAcceptanceList); + + mAcceptance = static_cast(mAcceptanceList->FindObject(Form("%d", runNumber))); + if (mAcceptance == nullptr) { + LOGF(fatal, "Could not find acceptance weights for run %d in acceptance list", runNumber); + } + LOGF(info, "Loaded acceptance weights (%p) for run %d from list (%p)", (void*)mAcceptance, runNumber, (void*)mAcceptanceList); + } + if (cfgEfficiency.value.empty() == false) { + mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); + if (mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency); + } + correctionsLoaded = true; + } + + bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz) + { + float eff = 1.; + if (mEfficiency) + eff = mEfficiency->GetBinContent(mEfficiency->FindBin(pt)); + else + eff = 1.0; + if (eff == 0) + return false; + weight_nue = 1. / eff; + + if (mAcceptance) + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + else + weight_nua = 1; + return true; + } + + template + bool eventSelected(TCollision collision) + { + registry.fill(HIST("hEventCountSpecific"), 0.5); + if (cfgEvSelkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return 0; + } + if (cfgEvSelkNoSameBunchPileup) + registry.fill(HIST("hEventCountSpecific"), 1.5); + if (cfgEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return 0; + } + if (cfgEvSelkIsGoodZvtxFT0vsPV) + registry.fill(HIST("hEventCountSpecific"), 2.5); + if (cfgEvSelkNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // no collisions in specified time range + return 0; + } + if (cfgEvSelkNoCollInTimeRangeStandard) + registry.fill(HIST("hEventCountSpecific"), 3.5); + if (cfgEvSelkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // from Jan 9 2025 AOT meeting + // cut time intervals with dead ITS staves + return 0; + } + if (cfgEvSelkIsGoodITSLayersAll) + registry.fill(HIST("hEventCountSpecific"), 4.5); + if (cfgEvSelkNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + // no other collisions in this Readout Frame with per-collision multiplicity above threshold + return 0; + } + if (cfgEvSelkNoCollInRofStandard) + registry.fill(HIST("hEventCountSpecific"), 5.5); + if (cfgEvSelkNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + // veto an event if FT0C amplitude in previous ITS ROF is above threshold + return 0; + } + if (cfgEvSelkNoHighMultCollInPrevRof) + registry.fill(HIST("hEventCountSpecific"), 6.5); + auto occupancy = collision.trackOccupancyInTimeRange(); + if (cfgEvSelOccupancy && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) + return 0; + if (cfgEvSelOccupancy) + registry.fill(HIST("hEventCountSpecific"), 7.5); + + return 1; + } + + template + void eventCounterQA(TCollision collision) + { + registry.fill(HIST("hEventCountTentative"), 0.5); + // Regradless of the event selection, fill the event counter histograms + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + registry.fill(HIST("hEventCountTentative"), 1.5); + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) + registry.fill(HIST("hEventCountTentative"), 2.5); + if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) + registry.fill(HIST("hEventCountTentative"), 3.5); + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) + registry.fill(HIST("hEventCountTentative"), 4.5); + if (collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) + registry.fill(HIST("hEventCountTentative"), 5.5); + if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) + registry.fill(HIST("hEventCountTentative"), 6.5); + auto occupancy = collision.trackOccupancyInTimeRange(); + if (!(occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) + registry.fill(HIST("hEventCountTentative"), 7.5); + } + + template + bool trackSelected(TTrack track) + { + // track type selection + bool passTrackTypeSelection = false; + switch (cfgTrackType) { + case kGlobalTrack: + passTrackTypeSelection = track.isGlobalTrack(); + break; + case kGlobalTrackSDD: + passTrackTypeSelection = track.isGlobalTrackSDD(); + break; + case kQualityTracksITS: + passTrackTypeSelection = track.isQualityTrackITS(); + break; + case kQualityTracksTPC: + passTrackTypeSelection = track.isQualityTrackTPC(); + break; + case kITSTracks: + passTrackTypeSelection = (track.isQualityTrackITS() && track.isPrimaryTrack() && track.isInAcceptanceTrack()); + break; + case kTPCTracks: + passTrackTypeSelection = (track.isQualityTrackTPC() && track.isPrimaryTrack() && track.isInAcceptanceTrack()); + break; + case kGlobalOrITSTracks: + passTrackTypeSelection = (track.isGlobalTrack() || (track.isQualityTrackITS() && track.isPrimaryTrack() && track.isInAcceptanceTrack())); + break; + case kGlobalOrTPCTracks: + passTrackTypeSelection = (track.isGlobalTrack() || (track.isQualityTrackTPC() && track.isPrimaryTrack() && track.isInAcceptanceTrack())); + break; + } + if (!passTrackTypeSelection) + return false; + + if (cfgCutDCAzPtDepEnabled && (std::fabs(track.dcaZ()) > (0.004f + 0.013f / track.pt()))) + return false; + + if (cfgCutITSTPCcluEnabled && (track.tpcNClsFound() < cfgCutTPCclu || track.itsNCls() < cfgCutITSclu)) + return false; + + return true; + } + + void initHadronicRate(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + if (gHadronicRate.find(mRunNumber) == gHadronicRate.end()) { + auto runDuration = ccdb->getRunDuration(mRunNumber); + mSOR = runDuration.first; + mMinSeconds = std::floor(mSOR * 1.e-3); /// round tsSOR to the highest integer lower than tsSOR + double maxSec = std::ceil(runDuration.second * 1.e-3); /// round tsEOR to the lowest integer higher than tsEOR + const AxisSpec axisSeconds{static_cast((maxSec - mMinSeconds) / 20.f), 0, maxSec - mMinSeconds, "Seconds since SOR"}; + gHadronicRate[mRunNumber] = registry.add(Form("HadronicRate/%i", mRunNumber), ";Time since SOR (s);Hadronic rate (kHz)", kTH2D, {axisSeconds, {510, 0., 51.}}).get(); + } + gCurrentHadronicRate = gHadronicRate[mRunNumber]; + } + + void process(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracks const& tracks) + { + registry.fill(HIST("hEventCount"), 0.5); + if (!cfgUseSmallMemory && tracks.size() >= 1) { + registry.fill(HIST("BeforeSel8_Tracks_centT0C"), collision.centFT0C(), tracks.size()); + } + if (!collision.sel8()) + return; + if (tracks.size() < 1) + return; + registry.fill(HIST("hEventCount"), 1.5); + auto bc = collision.bc_as(); + int currentRunNumber = bc.runNumber(); + for (const auto& ExcludedRun : cfgRunRemoveList.value) { + if (currentRunNumber == ExcludedRun) { + return; + } + } + registry.fill(HIST("hEventCount"), 2.5); + if (!cfgUseSmallMemory) { + registry.fill(HIST("BeforeCut_Tracks_centT0C"), collision.centFT0C(), tracks.size()); + registry.fill(HIST("BeforeCut_PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV()); + registry.fill(HIST("BeforeCut_Tracks_PVTracks"), collision.multNTracksPV(), tracks.size()); + registry.fill(HIST("BeforeCut_Tracks_multT0A"), collision.multFT0A(), tracks.size()); + registry.fill(HIST("BeforeCut_Tracks_multV0A"), collision.multFV0A(), tracks.size()); + registry.fill(HIST("BeforeCut_multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); + registry.fill(HIST("BeforeCut_multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); + } + float cent; + switch (cfgCentEstimator) { + case kCentFT0C: + cent = collision.centFT0C(); + break; + case kCentFT0CVariant1: + cent = collision.centFT0CVariant1(); + break; + case kCentFT0M: + cent = collision.centFT0M(); + break; + case kCentFV0A: + cent = collision.centFV0A(); + break; + default: + cent = collision.centFT0C(); + } + if (cfgUseTentativeEventCounter) + eventCounterQA(collision); + if (cfgUseAdditionalEventCut && !eventSelected(collision)) + return; + registry.fill(HIST("hEventCount"), 3.5); + float lRandom = fRndm->Rndm(); + float vtxz = collision.posZ(); + registry.fill(HIST("hVtxZ"), vtxz); + registry.fill(HIST("hMult"), tracks.size()); + registry.fill(HIST("hCent"), cent); + fGFW->Clear(); + if (cfgGetInteractionRate) { + initHadronicRate(bc); + double hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, "ZNC hadronic") * 1.e-3; // + double seconds = bc.timestamp() * 1.e-3 - mMinSeconds; + if (cfgUseInteractionRateCut && (hadronicRate < cfgCutMinIR || hadronicRate > cfgCutMaxIR)) // cut on hadronic rate + return; + gCurrentHadronicRate->Fill(seconds, hadronicRate); + } + loadCorrections(bc.timestamp(), currentRunNumber); + registry.fill(HIST("hEventCount"), 4.5); + + // fill event QA + if (!cfgUseSmallMemory) { + registry.fill(HIST("Tracks_centT0C"), collision.centFT0C(), tracks.size()); + registry.fill(HIST("PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV()); + registry.fill(HIST("Tracks_PVTracks"), collision.multNTracksPV(), tracks.size()); + registry.fill(HIST("Tracks_multT0A"), collision.multFT0A(), tracks.size()); + registry.fill(HIST("Tracks_multV0A"), collision.multFV0A(), tracks.size()); + registry.fill(HIST("multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); + registry.fill(HIST("multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); + registry.fill(HIST("centFT0CVar_centFT0C"), collision.centFT0C(), collision.centFT0CVariant1()); + registry.fill(HIST("centFT0M_centFT0C"), collision.centFT0C(), collision.centFT0M()); + registry.fill(HIST("centFV0A_centFT0C"), collision.centFT0C(), collision.centFV0A()); + } + + // track weights + float weff = 1, wacc = 1; + double nTracksCorrected = 0; + float independent = cent; + if (cfgUseNch) + independent = static_cast(tracks.size()); + + double psi2Est = 0, psi3Est = 0, psi4Est = 0; + float wEPeff = 1; + double v2 = 0, v3 = 0, v4 = 0; + if (cfgTrackDensityCorrUse) { + double q2x = 0, q2y = 0; + double q3x = 0, q3y = 0; + double q4x = 0, q4y = 0; + for (const auto& track : tracks) { + bool withinPtRef = (cfgCutPtRefMin < track.pt()) && (track.pt() < cfgCutPtRefMax); // within RF pT rang + if (withinPtRef) { + q2x += std::cos(2 * track.phi()); + q2y += std::sin(2 * track.phi()); + q3x += std::cos(3 * track.phi()); + q3y += std::sin(3 * track.phi()); + q4x += std::cos(4 * track.phi()); + q4y += std::sin(4 * track.phi()); + } + } + psi2Est = std::atan2(q2y, q2x) / 2.; + psi3Est = std::atan2(q3y, q3x) / 3.; + psi4Est = std::atan2(q4y, q4x) / 4.; + v2 = funcV2->Eval(cent); + v3 = funcV3->Eval(cent); + v4 = funcV4->Eval(cent); + } + + for (const auto& track : tracks) { + if (!trackSelected(track)) + continue; + bool withinPtPOI = (cfgCutPtPOIMin < track.pt()) && (track.pt() < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtRefMin < track.pt()) && (track.pt() < cfgCutPtRefMax); // within RF pT range + if (cfgOutputNUAWeights) { + if (cfgOutputNUAWeightsRefPt) { + if (withinPtRef) + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + } else { + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + } + } + if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) + continue; + if (cfgTrackDensityCorrUse && withinPtRef) { + double fphi = v2 * std::cos(2 * (track.phi() - psi2Est)) + v3 * std::cos(3 * (track.phi() - psi3Est)) + v4 * std::cos(4 * (track.phi() - psi4Est)); + fphi = (1 + 2 * fphi); + int pTBinForEff = hFindPtBin->FindBin(track.pt()); + if (pTBinForEff >= 1 && pTBinForEff <= hFindPtBin->GetNbinsX()) { + wEPeff = funcEff[pTBinForEff - 1]->Eval(fphi * tracks.size()); + if (wEPeff > 0.) { + wEPeff = 1. / wEPeff; + weff *= wEPeff; + registry.fill(HIST("hPhiWeightedTrDen"), track.phi(), wacc * wEPeff); + } + } + } + registry.fill(HIST("hPt"), track.pt()); + if (withinPtRef) { + registry.fill(HIST("hPhi"), track.phi()); + registry.fill(HIST("hPhiWeighted"), track.phi(), wacc); + registry.fill(HIST("hEta"), track.eta()); + registry.fill(HIST("hPtRef"), track.pt()); + registry.fill(HIST("hChi2prTPCcls"), track.tpcChi2NCl()); + registry.fill(HIST("hChi2prITScls"), track.itsChi2NCl()); + registry.fill(HIST("hnTPCClu"), track.tpcNClsFound()); + registry.fill(HIST("hnITSClu"), track.itsNCls()); + registry.fill(HIST("hnTPCCrossedRow"), track.tpcNClsCrossedRows()); + registry.fill(HIST("hDCAz"), track.dcaZ(), track.pt()); + registry.fill(HIST("hDCAxy"), track.dcaXY(), track.pt()); + nTracksCorrected += weff; + } + if (withinPtRef) + fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 1); + if (withinPtPOI) + fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 2); + if (withinPtPOI && withinPtRef) + fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 4); + } + registry.fill(HIST("hTrackCorrection2d"), tracks.size(), nTracksCorrected); + + // Filling Flow Container + for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { + fillFC(corrconfigs.at(l_ind), independent, lRandom); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/flowRunbyRun.cxx b/PWGCF/Flow/Tasks/flowRunbyRun.cxx index 03c596c9d2a..9259eb8be9e 100644 --- a/PWGCF/Flow/Tasks/flowRunbyRun.cxx +++ b/PWGCF/Flow/Tasks/flowRunbyRun.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -33,16 +34,17 @@ #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/Multiplicity.h" +#include "Common/CCDB/ctpRateFetcher.h" #include "GFWPowerArray.h" #include "GFW.h" #include "GFWCumulant.h" #include "GFWWeights.h" -#include "GFWWeightsList.h" #include "FlowContainer.h" #include "TList.h" #include #include +#include using namespace o2; using namespace o2::framework; @@ -61,11 +63,36 @@ struct FlowRunbyRun { O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 10.0f, "Maximal pT for all tracks") O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 70.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters") O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "max DCA to vertex z") + O2_DEFINE_CONFIGURABLE(cfgCutDCAzPtDepEnabled, bool, false, "switch of DCAz pt dependent cut") + O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") + O2_DEFINE_CONFIGURABLE(cfgOutputCorrelationQA, bool, false, "Fill correlation QA histograms") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoSameBunchPileup, bool, false, "rejects collisions which are associated with the same found-by-T0 bunch crossing") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodZvtxFT0vsPV, bool, false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference, use this cut at low multiplicities with caution") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInTimeRangeStandard, bool, false, "no collisions in specified time range") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodITSLayersAll, bool, true, "cut time intervals with dead ITS staves") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInRofStandard, bool, false, "no other collisions in this Readout Frame with per-collision multiplicity above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoHighMultCollInPrevRof, bool, false, "veto an event if FT0C amplitude in previous ITS ROF is above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelMultCorrelation, bool, true, "Multiplicity correlation cut") + O2_DEFINE_CONFIGURABLE(cfgEvSelV0AT0ACut, bool, true, "V0A T0A 5 sigma cut") + O2_DEFINE_CONFIGURABLE(cfgEvSelOccupancy, bool, true, "Occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables") O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 30, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "NUA weights are filled in ref pt bins") O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeightsRefPt, bool, false, "NUA weights are filled in ref pt bins") + O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgAcceptanceList, std::string, "", "CCDB path to acceptance lsit object") + O2_DEFINE_CONFIGURABLE(cfgAcceptanceListEnabled, bool, false, "switch of acceptance list") O2_DEFINE_CONFIGURABLE(cfgDynamicRunNumber, bool, false, "Add runNumber during runtime") + O2_DEFINE_CONFIGURABLE(cfgGetInteractionRate, bool, false, "Get interaction rate from CCDB") + O2_DEFINE_CONFIGURABLE(cfgUseInteractionRateCut, bool, false, "Use events with low interaction rate") + O2_DEFINE_CONFIGURABLE(cfgCutMaxIR, float, 50.0f, "maximum interaction rate (kHz)") + O2_DEFINE_CONFIGURABLE(cfgCutMinIR, float, 0.0f, "minimum interaction rate (kHz)") Configurable> cfgRunNumbers{"cfgRunNumbers", std::vector{544095, 544098, 544116, 544121, 544122, 544123, 544124}, "Preconfigured run numbers"}; Configurable> cfgUserDefineGFWCorr{"cfgUserDefineGFWCorr", std::vector{"refN10 {2} refP10 {-2}"}, "User defined GFW CorrelatorConfig"}; Configurable> cfgUserDefineGFWName{"cfgUserDefineGFWName", std::vector{"Ch10Gap22"}, "User defined GFW Name"}; @@ -75,18 +102,26 @@ struct FlowRunbyRun { ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}, "pt axis for histograms"}; ConfigurableAxis axisIndependent{"axisIndependent", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "X axis for histograms"}; + ConfigurableAxis axisNch{"axisNch", {4000, 0, 4000}, "N_{ch}"}; + ConfigurableAxis axisCentForQA{"axisCentForQA", {100, 0, 100}, "centrality (%)"}; + ConfigurableAxis axisT0C{"axisT0C", {70, 0, 70000}, "N_{ch} (T0C)"}; + ConfigurableAxis axisT0A{"axisT0A", {200, 0, 200000}, "N_{ch} (T0A)"}; Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter trackFilter = ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + // Corrections + TH1D* mEfficiency = nullptr; + GFWWeights* mAcceptance = nullptr; + TObjArray* mAcceptanceList = nullptr; + bool correctionsLoaded = false; + // Connect to ccdb Service ccdb; - Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; // Define output OutputObj fFC{FlowContainer("FlowContainer")}; - OutputObj fGFWWeightsList{GFWWeightsList("GFWWeightsList")}; HistogramRegistry registry{"registry"}; // define global variables @@ -98,32 +133,65 @@ struct FlowRunbyRun { int lastRunNumer = -1; std::vector runNumbers; // vector of run numbers std::map>> th1sList; // map of histograms for all runs + std::map>> th2sList; // map of TH2 histograms for all runs + std::map>> th3sList; // map of TH3 histograms for all runs std::map>> profilesList; // map of profiles for all runs enum OutputTH1Names { // here are TProfiles for vn-pt correlations that are not implemented in GFW hPhi = 0, + hPhiWeighted, hEta, hVtxZ, hMult, hCent, + hEventCountSpecific, kCount_TH1Names }; + enum OutputTH2Names { + // here are TH2 histograms + hglobalTracks_centT0C = 0, + hglobalTracks_PVTracks, + hglobalTracks_multV0A, + hcentFV0A_centFT0C, + kCount_TH2Names + }; + enum OutputTH3Names { + hPhiEtaVtxz = 0, + kCount_TH3Names + }; enum OutputTProfileNames { c22 = 0, c22_gap10, + c32, + c32_gap10, + c3232, kCount_TProfileNames }; + int mRunNumber{-1}; + uint64_t mSOR{0}; + double mMinSeconds{-1.}; + std::unordered_map gHadronicRate; + ctpRateFetcher mRateFetcher; + TH2* gCurrentHadronicRate; - using AodCollisions = soa::Filtered>; + // Additional Event selection cuts - Copy from flowGenericFramework.cxx + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fMultMultPVCut = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + + using AodCollisions = soa::Filtered>; using AodTracks = soa::Filtered>; void init(InitContext const&) { ccdb->setURL(ccdbUrl.value); ccdb->setCaching(true); - ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); - - fGFWWeightsList->init("weightList"); + auto now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); // Add output histograms to the registry runNumbers = cfgRunNumbers; @@ -156,6 +224,9 @@ struct FlowRunbyRun { corrconfigs.resize(kCount_TProfileNames); corrconfigs[c22] = fGFW->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE); corrconfigs[c22_gap10] = fGFW->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE); + corrconfigs[c32] = fGFW->GetCorrelatorConfig("full {3 -3}", "ChFull32", kFALSE); + corrconfigs[c32_gap10] = fGFW->GetCorrelatorConfig("refN10 {3} refP10 {-3}", "Ch10Gap32", kFALSE); + corrconfigs[c3232] = fGFW->GetCorrelatorConfig("full {3 2 -3 -2}", "ChFull3232", kFALSE); if (!userDefineGFWCorr.empty() && !userDefineGFWName.empty()) { LOGF(info, "User adding GFW CorrelatorConfig:"); // attentaion: here we follow the index of cfgUserDefineGFWCorr @@ -169,6 +240,23 @@ struct FlowRunbyRun { } } fGFW->CreateRegions(); + + if (cfgUseAdditionalEventCut) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + + fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + + fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } } template @@ -210,26 +298,202 @@ struct FlowRunbyRun { return; } + void loadCorrections(uint64_t timestamp, int runNumber) + { + if (correctionsLoaded) + return; + if (!cfgAcceptanceListEnabled && cfgAcceptance.value.empty() == false) { + mAcceptance = ccdb->getForTimeStamp(cfgAcceptance, timestamp); + if (mAcceptance) + LOGF(info, "Loaded acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); + else + LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); + } + if (cfgAcceptanceListEnabled && cfgAcceptanceList.value.empty() == false) { + mAcceptanceList = ccdb->getForTimeStamp(cfgAcceptanceList, timestamp); + if (mAcceptanceList == nullptr) { + LOGF(fatal, "Could not load acceptance weights list from %s", cfgAcceptanceList.value.c_str()); + } + LOGF(info, "Loaded acceptance weights list from %s (%p)", cfgAcceptanceList.value.c_str(), (void*)mAcceptanceList); + + mAcceptance = static_cast(mAcceptanceList->FindObject(Form("%d", runNumber))); + if (mAcceptance == nullptr) { + LOGF(fatal, "Could not find acceptance weights for run %d in acceptance list", runNumber); + } + LOGF(info, "Loaded acceptance weights (%p) for run %d from list (%p)", (void*)mAcceptance, runNumber, (void*)mAcceptanceList); + } + if (cfgEfficiency.value.empty() == false) { + mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); + if (mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency); + } + correctionsLoaded = true; + } + + bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz) + { + float eff = 1.; + if (mEfficiency) + eff = mEfficiency->GetBinContent(mEfficiency->FindBin(pt)); + else + eff = 1.0; + if (eff == 0) + return false; + weight_nue = 1. / eff; + + if (mAcceptance) + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + else + weight_nua = 1; + return true; + } + void createOutputObjectsForRun(int runNumber) { std::vector> histos(kCount_TH1Names); histos[hPhi] = registry.add(Form("%d/hPhi", runNumber), "", {HistType::kTH1D, {axisPhi}}); + histos[hPhiWeighted] = registry.add(Form("%d/hPhiWeighted", runNumber), "", {HistType::kTH1D, {axisPhi}}); histos[hEta] = registry.add(Form("%d/hEta", runNumber), "", {HistType::kTH1D, {axisEta}}); histos[hVtxZ] = registry.add(Form("%d/hVtxZ", runNumber), "", {HistType::kTH1D, {axisVertex}}); histos[hMult] = registry.add(Form("%d/hMult", runNumber), "", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); histos[hCent] = registry.add(Form("%d/hCent", runNumber), "", {HistType::kTH1D, {{90, 0, 90}}}); + histos[hEventCountSpecific] = registry.add(Form("%d/hEventCountSpecific", runNumber), "", {HistType::kTH1D, {{10, 0, 10}}}); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(1, "after sel8"); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(2, "kNoSameBunchPileup"); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(3, "kIsGoodZvtxFT0vsPV"); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(4, "kNoCollInTimeRangeStandard"); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(5, "kIsGoodITSLayersAll"); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(6, "kNoCollInRofStandard"); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(7, "kNoHighMultCollInPrevRof"); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(8, "occupancy"); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(9, "MultCorrelation"); + histos[hEventCountSpecific]->GetXaxis()->SetBinLabel(10, "cfgEvSelV0AT0ACut"); th1sList.insert(std::make_pair(runNumber, histos)); + if (cfgOutputCorrelationQA) { + std::vector> th2s(kCount_TH2Names); + th2s[hglobalTracks_centT0C] = registry.add(Form("%d/globalTracks_centT0C", runNumber), "after cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + th2s[hglobalTracks_PVTracks] = registry.add(Form("%d/globalTracks_PVTracks", runNumber), "after cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNch, axisNch}}); + th2s[hglobalTracks_multV0A] = registry.add(Form("%d/globalTracks_multV0A", runNumber), "after cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + th2s[hcentFV0A_centFT0C] = registry.add(Form("%d/centFV0A_centFT0C", runNumber), "after cut;Centrality T0C;Centrality V0A", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); + th2sList.insert(std::make_pair(runNumber, th2s)); + } + std::vector> profiles(kCount_TProfileNames); profiles[c22] = registry.add(Form("%d/c22", runNumber), "", {HistType::kTProfile, {axisIndependent}}); profiles[c22_gap10] = registry.add(Form("%d/c22_gap10", runNumber), "", {HistType::kTProfile, {axisIndependent}}); + profiles[c32] = registry.add(Form("%d/c32", runNumber), "", {HistType::kTProfile, {axisIndependent}}); + profiles[c32_gap10] = registry.add(Form("%d/c32_gap10", runNumber), "", {HistType::kTProfile, {axisIndependent}}); + profiles[c3232] = registry.add(Form("%d/c3232", runNumber), "", {HistType::kTProfile, {axisIndependent}}); profilesList.insert(std::make_pair(runNumber, profiles)); - // weightsList - o2::framework::AxisSpec axis = axisPt; - int nPtBins = axis.binEdges.size() - 1; - double* ptBins = &(axis.binEdges)[0]; - fGFWWeightsList->addGFWWeightsByRun(runNumber, nPtBins, ptBins, true, false); + if (cfgOutputNUAWeights) { + std::vector> tH3s(kCount_TH3Names); + tH3s[hPhiEtaVtxz] = registry.add(Form("%d/hPhiEtaVtxz", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, {40, -10, 10}}}); + th3sList.insert(std::make_pair(runNumber, tH3s)); + } + } + + void initHadronicRate(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + if (gHadronicRate.find(mRunNumber) == gHadronicRate.end()) { + auto runDuration = ccdb->getRunDuration(mRunNumber); + mSOR = runDuration.first; + mMinSeconds = std::floor(mSOR * 1.e-3); /// round tsSOR to the highest integer lower than tsSOR + double maxSec = std::ceil(runDuration.second * 1.e-3); /// round tsEOR to the lowest integer higher than tsEOR + const AxisSpec axisSeconds{static_cast((maxSec - mMinSeconds) / 20.f), 0, maxSec - mMinSeconds, "Seconds since SOR"}; + int hadronicRateBins = static_cast(cfgCutMaxIR - cfgCutMinIR); + gHadronicRate[mRunNumber] = registry.add(Form("HadronicRate/%i", mRunNumber), ";Time since SOR (s);Hadronic rate (kHz)", kTH2D, {axisSeconds, {hadronicRateBins, cfgCutMinIR, cfgCutMaxIR}}).get(); + } + gCurrentHadronicRate = gHadronicRate[mRunNumber]; + } + + template + bool eventSelected(TCollision collision, const int multTrk, const float centrality, const int runNumber) + { + th1sList[runNumber][hEventCountSpecific]->Fill(0.5); + if (cfgEvSelkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return 0; + } + if (cfgEvSelkNoSameBunchPileup) + th1sList[runNumber][hEventCountSpecific]->Fill(1.5); + if (cfgEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return 0; + } + if (cfgEvSelkIsGoodZvtxFT0vsPV) + th1sList[runNumber][hEventCountSpecific]->Fill(2.5); + if (cfgEvSelkNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // no collisions in specified time range + return 0; + } + if (cfgEvSelkNoCollInTimeRangeStandard) + th1sList[runNumber][hEventCountSpecific]->Fill(3.5); + if (cfgEvSelkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // from Jan 9 2025 AOT meeting + // cut time intervals with dead ITS staves + return 0; + } + if (cfgEvSelkIsGoodITSLayersAll) + th1sList[runNumber][hEventCountSpecific]->Fill(4.5); + if (cfgEvSelkNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + // no other collisions in this Readout Frame with per-collision multiplicity above threshold + return 0; + } + if (cfgEvSelkNoCollInRofStandard) + th1sList[runNumber][hEventCountSpecific]->Fill(5.5); + if (cfgEvSelkNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + // veto an event if FT0C amplitude in previous ITS ROF is above threshold + return 0; + } + if (cfgEvSelkNoHighMultCollInPrevRof) + th1sList[runNumber][hEventCountSpecific]->Fill(6.5); + auto multNTracksPV = collision.multNTracksPV(); + auto occupancy = collision.trackOccupancyInTimeRange(); + if (cfgEvSelOccupancy && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) + return 0; + if (cfgEvSelOccupancy) + th1sList[runNumber][hEventCountSpecific]->Fill(7.5); + + if (cfgEvSelMultCorrelation) { + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return 0; + if (multTrk < fMultCutLow->Eval(centrality)) + return 0; + if (multTrk > fMultCutHigh->Eval(centrality)) + return 0; + } + if (cfgEvSelMultCorrelation) + th1sList[runNumber][hEventCountSpecific]->Fill(8.5); + + // V0A T0A 5 sigma cut + float nSigma = 5.; // 5 sigma cut + if (cfgEvSelV0AT0ACut && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > nSigma * fT0AV0ASigma->Eval(collision.multFT0A()))) + return 0; + if (cfgEvSelV0AT0ACut) + th1sList[runNumber][hEventCountSpecific]->Fill(9.5); + + return 1; + } + + template + bool trackSelected(TTrack track) + { + if (cfgCutDCAzPtDepEnabled && (std::fabs(track.dcaZ()) > (0.004f + 0.013f / track.pt()))) + return false; + + return ((track.tpcNClsFound() >= cfgCutTPCclu) && (track.itsNCls() >= cfgCutITSclu)); } void process(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracks const& tracks) @@ -240,8 +504,8 @@ struct FlowRunbyRun { return; // detect run number auto bc = collision.bc_as(); + const auto cent = collision.centFT0C(); int runNumber = bc.runNumber(); - float lRandom = fRndm->Rndm(); if (runNumber != lastRunNumer) { lastRunNumer = runNumber; if (cfgDynamicRunNumber && std::find(runNumbers.begin(), runNumbers.end(), runNumber) == runNumbers.end()) { @@ -256,37 +520,55 @@ struct FlowRunbyRun { } } + if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), cent, runNumber)) + return; + if (cfgGetInteractionRate) { + initHadronicRate(bc); + double hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, "ZNC hadronic") * 1.e-3; // + double seconds = bc.timestamp() * 1.e-3 - mMinSeconds; + if (cfgUseInteractionRateCut && (hadronicRate < cfgCutMinIR || hadronicRate > cfgCutMaxIR)) // cut on hadronic rate + return; + gCurrentHadronicRate->Fill(seconds, hadronicRate); + } + float lRandom = fRndm->Rndm(); + th1sList[runNumber][hVtxZ]->Fill(collision.posZ()); th1sList[runNumber][hMult]->Fill(tracks.size()); th1sList[runNumber][hCent]->Fill(collision.centFT0C()); + if (cfgOutputCorrelationQA) { + th2sList[runNumber][hglobalTracks_centT0C]->Fill(collision.centFT0C(), tracks.size()); + th2sList[runNumber][hglobalTracks_PVTracks]->Fill(collision.multNTracksPV(), tracks.size()); + th2sList[runNumber][hglobalTracks_multV0A]->Fill(collision.multFV0A(), tracks.size()); + th2sList[runNumber][hcentFV0A_centFT0C]->Fill(collision.centFT0C(), collision.centFV0A()); + } + + loadCorrections(bc.timestamp(), runNumber); fGFW->Clear(); - const auto cent = collision.centFT0C(); float weff = 1, wacc = 1; for (const auto& track : tracks) { - th1sList[runNumber][hPhi]->Fill(track.phi()); - th1sList[runNumber][hEta]->Fill(track.eta()); + if (!trackSelected(track)) + continue; // bool WithinPtPOI = (cfgCutPtPOIMin < track.pt()) && (track.pt() < cfgCutPtPOIMax); // within POI pT range bool withinPtRef = (cfgCutPtRefMin < track.pt()) && (track.pt() < cfgCutPtRefMax); // within RF pT range - if (withinPtRef) { - fGFW->Fill(track.eta(), 1, track.phi(), wacc * weff, 1); - } - if (cfgOutputNUAWeightsRefPt) { - if (withinPtRef) { - GFWWeights* weight = fGFWWeightsList->getGFWWeightsByRun(runNumber); - if (!weight) { - LOGF(fatal, "Could not find the weight for run %d", runNumber); - return; + if (cfgOutputNUAWeights) { + if (cfgOutputNUAWeightsRefPt) { + if (withinPtRef) { + th3sList[runNumber][hPhiEtaVtxz]->Fill(track.phi(), track.eta(), collision.posZ()); } - weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); - } - } else { - GFWWeights* weight = fGFWWeightsList->getGFWWeightsByRun(runNumber); - if (!weight) { - LOGF(fatal, "Could not find the weight for run %d", runNumber); - return; + } else { + th3sList[runNumber][hPhiEtaVtxz]->Fill(track.phi(), track.eta(), collision.posZ()); } - weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + } + if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), collision.posZ())) + continue; + if (withinPtRef) { + th1sList[runNumber][hPhi]->Fill(track.phi()); + th1sList[runNumber][hPhiWeighted]->Fill(track.phi(), wacc); + th1sList[runNumber][hEta]->Fill(track.eta()); + } + if (withinPtRef) { + fGFW->Fill(track.eta(), 1, track.phi(), wacc * weff, 1); } } diff --git a/PWGCF/Flow/Tasks/flowSP.cxx b/PWGCF/Flow/Tasks/flowSP.cxx index 993d06da8b1..1442509bba0 100644 --- a/PWGCF/Flow/Tasks/flowSP.cxx +++ b/PWGCF/Flow/Tasks/flowSP.cxx @@ -14,29 +14,38 @@ /// \since 01/12/2024 /// \brief task to evaluate flow with respect to spectator plane. -#include -#include -#include -#include -#include -#include -#include +#include "GFWWeights.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/HistogramRegistry.h" +#include "PWGCF/DataModel/SPTableZDC.h" -#include "Common/DataModel/EventSelection.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" -#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" -#include "PWGCF/DataModel/SPTableZDC.h" #include "TF1.h" +#include "TPDGCode.h" + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -46,56 +55,123 @@ using namespace o2::framework::expressions; #define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; struct FlowSP { - - O2_DEFINE_CONFIGURABLE(cfgDCAxy, float, 0.2, "Cut on DCA in the transverse direction (cm)"); - O2_DEFINE_CONFIGURABLE(cfgDCAz, float, 2, "Cut on DCA in the longitudinal direction (cm)"); - O2_DEFINE_CONFIGURABLE(cfgNcls, float, 70, "Cut on number of TPC clusters found"); - O2_DEFINE_CONFIGURABLE(cfgPtmin, float, 0.2, "minimum pt (GeV/c)"); - O2_DEFINE_CONFIGURABLE(cfgPtmax, float, 10, "maximum pt (GeV/c)"); - O2_DEFINE_CONFIGURABLE(cfgEta, float, 0.8, "eta cut"); - O2_DEFINE_CONFIGURABLE(cfgVtxZ, float, 10, "vertex cut (cm)"); - O2_DEFINE_CONFIGURABLE(cfgMagField, float, 99999, "Configurable magnetic field; default CCDB will be queried"); - O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, true, "Bool to enable Additional Event Cut"); - O2_DEFINE_CONFIGURABLE(cfgUseAdditionalTrackCut, bool, true, "Bool to enable Additional Track Cut"); - O2_DEFINE_CONFIGURABLE(cfgCentMax, float, 90, "Maximum cenrality for selected events"); + // QA Plots + O2_DEFINE_CONFIGURABLE(cfgFillEventQA, bool, false, "Fill histograms for event QA"); + O2_DEFINE_CONFIGURABLE(cfgFillTrackQA, bool, false, "Fill histograms for track QA"); + O2_DEFINE_CONFIGURABLE(cfgFillPIDQA, bool, false, "Fill histograms for PID QA"); + O2_DEFINE_CONFIGURABLE(cfgFillEventPlaneQA, bool, false, "Fill histograms for Event Plane QA"); + O2_DEFINE_CONFIGURABLE(cfgFillQABefore, bool, false, "Fill QA histograms before cuts, only for processData"); + // Flags to make and fill histograms + O2_DEFINE_CONFIGURABLE(cfgFillGeneralV1Histos, bool, true, "Fill histograms for vn analysis"); + O2_DEFINE_CONFIGURABLE(cfgFillMixedHarmonics, bool, true, "Flag to make and fill histos for mixed harmonics"); + O2_DEFINE_CONFIGURABLE(cfgFillEventPlane, bool, false, "Flag to make and fill histos with Event Plane"); + O2_DEFINE_CONFIGURABLE(cfgFillXandYterms, bool, false, "Flag to make and fill histos for with separate x and y terms for SPM"); + O2_DEFINE_CONFIGURABLE(cfgFillChargeDependence, bool, true, "Flag to make and fill histos for charge dependent flow"); + O2_DEFINE_CONFIGURABLE(cfgFillPID, bool, false, "Flag to make and fill histos for PID flow"); + // Centrality Estimators -> standard is FT0C + O2_DEFINE_CONFIGURABLE(cfgCentFT0Cvariant1, bool, false, "Set centrality estimator to cfgCentFT0Cvariant1"); + O2_DEFINE_CONFIGURABLE(cfgCentFT0M, bool, false, "Set centrality estimator to cfgCentFT0M"); + O2_DEFINE_CONFIGURABLE(cfgCentFV0A, bool, false, "Set centrality estimator to cfgCentFV0A"); + O2_DEFINE_CONFIGURABLE(cfgCentNGlobal, bool, false, "Set centrality estimator to cfgCentNGlobal"); + // Standard selections + O2_DEFINE_CONFIGURABLE(cfgTrackSelsDCAxy, float, 0.2, "Cut on DCA in the transverse direction (cm)"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsDCAz, float, 2, "Cut on DCA in the longitudinal direction (cm)"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsNcls, float, 70, "Cut on number of TPC clusters found"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsFshcls, float, 0.4, "Cut on fraction of shared TPC clusters found"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsPtmin, float, 0.2, "minimum pt (GeV/c)"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsPtmax, float, 10, "maximum pt (GeV/c)"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsEta, float, 0.8, "eta cut"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsVtxZ, float, 10, "vertex cut (cm)"); + O2_DEFINE_CONFIGURABLE(cfgMagField, float, 99999, "Configurable magnetic field;default CCDB will be queried"); O2_DEFINE_CONFIGURABLE(cfgCentMin, float, 0, "Minimum cenrality for selected events"); - O2_DEFINE_CONFIGURABLE(cfgFillWeights, bool, false, "Fill NUA weights") - - O2_DEFINE_CONFIGURABLE(cfgDoubleTrackFunction, bool, true, "Include track cut at low pt"); - O2_DEFINE_CONFIGURABLE(cfgTrackCutSize, float, 0.06, "Spread of track cut"); - O2_DEFINE_CONFIGURABLE(cfgMaxOccupancy, int, 500, "Maximum occupancy of selected events"); - O2_DEFINE_CONFIGURABLE(cfgNoSameBunchPileupCut, bool, true, "kNoSameBunchPileupCut"); - O2_DEFINE_CONFIGURABLE(cfgIsGoodZvtxFT0vsPV, bool, true, "kIsGoodZvtxFT0vsPV"); - O2_DEFINE_CONFIGURABLE(cfgNoCollInTimeRangeStandard, bool, true, "kNoCollInTimeRangeStandard"); - O2_DEFINE_CONFIGURABLE(cfgDoOccupancySel, bool, true, "Bool for event selection on detector occupancy"); - O2_DEFINE_CONFIGURABLE(cfgMultCut, bool, true, "Use additional evenr cut on mult correlations"); - O2_DEFINE_CONFIGURABLE(cfgTVXinTRD, bool, false, "Use kTVXinTRD (reject TRD triggered events)"); - O2_DEFINE_CONFIGURABLE(cfgIsVertexITSTPC, bool, true, "Selects collisions with at least one ITS-TPC track"); - O2_DEFINE_CONFIGURABLE(cfgCCDBdir, std::string, "Users/c/ckoster/ZDC/LHC23_zzh_pass4_small/meanQQ", "ccdb dir for average QQ values in 1% centrality bins"); - O2_DEFINE_CONFIGURABLE(cfgLoadAverageQQ, bool, true, "Load average values for QQ (in centrality bins)"); + O2_DEFINE_CONFIGURABLE(cfgCentMax, float, 90, "Maximum cenrality for selected events"); + // NUA and NUE weights + O2_DEFINE_CONFIGURABLE(cfgFillWeights, bool, true, "Fill NUA weights"); + O2_DEFINE_CONFIGURABLE(cfgFillWeightsPOS, bool, true, "Fill NUA weights only for positive charges"); + O2_DEFINE_CONFIGURABLE(cfgFillWeightsNEG, bool, true, "Fill NUA weights only for negative charges"); + O2_DEFINE_CONFIGURABLE(cfguseNUA1D, bool, false, "Use 1D NUA weights (only phi)"); + O2_DEFINE_CONFIGURABLE(cfguseNUA2D, bool, true, "Use 2D NUA weights (phi and eta)"); + // Additional track Selections + O2_DEFINE_CONFIGURABLE(cfgTrackSelsUseAdditionalTrackCut, bool, false, "Bool to enable Additional Track Cut"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsDoDCApt, bool, false, "Apply Pt dependent DCAz cut"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsDCApt1, float, 0.1, "DcaZ < a * b / pt^1.1 -> this sets a"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsDCApt2, float, 0.035, "DcaZ < a * b / pt^1.1 -> this sets b"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelsPIDNsigma, float, 2.0, "nSigma cut for PID"); + O2_DEFINE_CONFIGURABLE(cfgTrackSelDoTrackQAvsCent, bool, true, "Do track selection QA plots as function of centrality"); + // Additional event selections + O2_DEFINE_CONFIGURABLE(cfgEvSelsUseAdditionalEventCut, bool, true, "Bool to enable Additional Event Cut"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsMaxOccupancy, int, 10000, "Maximum occupancy of selected events"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsNoSameBunchPileupCut, bool, true, "kNoSameBunchPileupCut"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsIsGoodZvtxFT0vsPV, bool, true, "kIsGoodZvtxFT0vsPV"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsNoCollInTimeRangeStandard, bool, true, "kNoCollInTimeRangeStandard"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsDoOccupancySel, bool, true, "Bool for event selection on detector occupancy"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsTVXinTRD, bool, false, "Use kTVXinTRD (reject TRD triggered events)"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsIsVertexITSTPC, bool, true, "Selects collisions with at least one ITS-TPC track"); + O2_DEFINE_CONFIGURABLE(cfgEvSelsIsGoodITSLayersAll, bool, true, "Cut time intervals with dead ITS staves"); + // harmonics for v coefficients O2_DEFINE_CONFIGURABLE(cfgHarm, int, 1, "Flow harmonic n for ux and uy: (Cos(n*phi), Sin(n*phi))"); - O2_DEFINE_CONFIGURABLE(cfgLoadSPPlaneRes, bool, false, "Load ZDC spectator plane resolution"); - O2_DEFINE_CONFIGURABLE(cfgCCDBdir_SP, std::string, "Users/c/ckoster/ZDC/LHC23_zzh_pass4_small/SPPlaneRes", "ccdb dir for average event plane resolution in 1% centrality bins"); - - ConfigurableAxis axisDCAz{"axisDCAz", {200, -.5, .5}, "DCA_{z} (cm)"}; - ConfigurableAxis axisDCAxy{"axisDCAxy", {200, -.5, .5}, "DCA_{xy} (cm)"}; - ConfigurableAxis axisPhiMod = {"axisPhiMod", {100, 0, constants::math::PI / 9}, "fmod(#varphi,#pi/9)"}; - ConfigurableAxis axisPhi = {"axisPhi", {60, 0, constants::math::TwoPI}, "#varphi"}; - ConfigurableAxis axisEta = {"axisEta", {64, -1, 1}, "#eta"}; - ConfigurableAxis axisEtaVn = {"axisEtaVn", {8, -.8, .8}, "#eta"}; - ConfigurableAxis axisVx = {"axisVx", {40, -0.01, 0.01}, "v_{x}"}; - ConfigurableAxis axisVy = {"axisVy", {40, -0.01, 0.01}, "v_{y}"}; - ConfigurableAxis axisVz = {"axisVz", {40, -10, 10}, "v_{z}"}; - ConfigurableAxis axisCent = {"axisCent", {90, 0, 90}, "Centrality(%)"}; - ConfigurableAxis axisPhiPlane = {"axisPhiPlane", {100, -constants::math::PI, constants::math::PI}, "#Psi"}; - - Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZ; - Filter trackFilter = nabs(aod::track::eta) < cfgEta && aod::track::pt > cfgPtmin&& aod::track::pt < cfgPtmax && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && nabs(aod::track::dcaXY) < cfgDCAxy&& nabs(aod::track::dcaZ) < cfgDCAz; - using UsedCollisions = soa::Filtered>; - using UsedTracks = soa::Filtered>; + O2_DEFINE_CONFIGURABLE(cfgHarmMixed1, int, 2, "Flow harmonic n for ux and uy in mixed harmonics (MH): (Cos(n*phi), Sin(n*phi))"); + O2_DEFINE_CONFIGURABLE(cfgHarmMixed2, int, 3, "Flow harmonic n for ux and uy in mixed harmonics (MH): (Cos(n*phi), Sin(n*phi))"); + // settings for CCDB data + O2_DEFINE_CONFIGURABLE(cfgCCDBdir_QQ, std::string, "Users/c/ckoster/ZDC/LHC23_PbPb_pass4/meanQQ/Default", "ccdb dir for average QQ values in 1% centrality bins"); + O2_DEFINE_CONFIGURABLE(cfgCCDBdir_SP, std::string, "", "ccdb dir for average event plane resolution in 1% centrality bins"); + O2_DEFINE_CONFIGURABLE(cfgCCDB_NUA, std::string, "Users/c/ckoster/flowSP/LHC23_PbPb_pass4/Default", "ccdb dir for NUA corrections"); + O2_DEFINE_CONFIGURABLE(cfgCCDB_NUE, std::string, "Users/c/ckoster/flowSP/LHC23_PbPb_pass4/NUE/Default", "ccdb dir for NUE corrections"); + O2_DEFINE_CONFIGURABLE(cfgCCDBdir_centrality, std::string, "", "ccdb dir for Centrality corrections"); + // Confogirable axis + ConfigurableAxis axisCentrality{"axisCentrality", {10, 0, 100}, "Centrality bins for vn "}; + ConfigurableAxis axisNch = {"axisNch", {400, 0, 4000}, "Global N_{ch}"}; + ConfigurableAxis axisMultpv = {"axisMultpv", {400, 0, 4000}, "N_{ch} (PV)"}; + // Configurables containing vector + Configurable> cfgEvSelsMultPv{"cfgEvSelsMultPv", std::vector{2389.99, -83.8483, 1.11062, -0.00672263, 1.54725e-05, 4067.4, -145.485, 2.27273, -0.0186308, 6.5501e-05}, "Multiplicity cuts (PV) first 5 parameters cutLOW last 5 cutHIGH (Default is +-3sigma pass4) "}; + Configurable> cfgEvSelsMult{"cfgEvSelsMult", std::vector{1048.48, -31.4568, 0.287794, -0.00046847, -3.5909e-06, 2610.98, -83.3983, 1.0893, -0.00735094, 2.26929e-05}, "Multiplicity cuts (Global) first 5 parameters cutLOW last 5 cutHIGH (Default is +-3sigma pass4) "}; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgEvSelsVtxZ; + Filter trackFilter = nabs(aod::track::eta) < cfgTrackSelsEta && aod::track::pt > cfgTrackSelsPtmin&& aod::track::pt < cfgTrackSelsPtmax && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && nabs(aod::track::dcaXY) < cfgTrackSelsDCAxy&& nabs(aod::track::dcaZ) < cfgTrackSelsDCAz; + Filter trackFilterMC = nabs(aod::mcparticle::eta) < cfgTrackSelsEta && aod::mcparticle::pt > cfgTrackSelsPtmin&& aod::mcparticle::pt < cfgTrackSelsPtmax; + using UsedCollisions = soa::Filtered>; + using UsedTracks = soa::Filtered>; + + // For MC Reco and Gen + using CCs = soa::Filtered>; + using CC = CCs::iterator; + using TCs = soa::Join; + using FilteredTCs = soa::Filtered>; + using TC = TCs::iterator; + using MCs = soa::Filtered; + + Preslice partPerMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted trackPerMcParticle = aod::mctracklabel::mcParticleId; + Preslice trackPerCollision = aod::track::collisionId; // Connect to ccdb Service ccdb; + Service pdg; + + // struct to hold the correction histos/ + struct Config { + std::vector mEfficiency = {}; + std::vector mAcceptance = {}; + std::vector mAcceptance2D = {}; + bool correctionsLoaded = false; + int lastRunNumber = 0; + + TProfile* hcorrQQ = nullptr; + TProfile* hcorrQQx = nullptr; + TProfile* hcorrQQy = nullptr; + TProfile* hEvPlaneRes = nullptr; + TH1D* hCentrality = nullptr; + + bool clQQ = false; + bool clEvPlaneRes = false; + bool clCentrality = false; + + } cfg; + + OutputObj fWeights{GFWWeights("weights")}; + OutputObj fWeightsPOS{GFWWeights("weights_positive")}; + OutputObj fWeightsNEG{GFWWeights("weights_negative")}; HistogramRegistry registry{"registry"}; @@ -108,8 +184,66 @@ struct FlowSP { TF1* fMultCutHigh = nullptr; TF1* fMultMultPVCut = nullptr; + enum SelectionCriteria { + evSel_FilteredEvent, + evSel_sel8, + evSel_occupancy, + evSel_kTVXinTRD, + evSel_kNoSameBunchPileup, + evSel_kIsGoodZvtxFT0vsPV, + evSel_kNoCollInTimeRangeStandard, + evSel_kIsVertexITSTPC, + evSel_MultCuts, + evSel_kIsGoodITSLayersAll, + evSel_isSelectedZDC, + evSel_CentCuts, + nEventSelections + }; + + enum TrackSelections { + trackSel_ZeroCharge, + trackSel_Eta, + trackSel_Pt, + trackSel_DCAxy, + trackSel_DCAz, + trackSel_GlobalTracks, + trackSel_NCls, + trackSel_FshCls, + trackSel_TPCBoundary, + trackSel_ParticleWeights, + nTrackSelections + }; + + enum ChargeType { + kInclusive, + kPositive, + kNegative + }; + + enum FillType { + kBefore, + kAfter + }; + + enum ModeType { + kGen, + kReco + }; + + enum ParticleType { + kUnidentified, + kPion, + kKaon, + kProton + }; + + static constexpr std::string_view Charge[] = {"incl/", "pos/", "neg/"}; + static constexpr std::string_view Species[] = {"", "pion/", "kaon/", "proton/"}; + static constexpr std::string_view Time[] = {"before/", "after/"}; + void init(InitContext const&) { + ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); @@ -117,132 +251,419 @@ struct FlowSP { int64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); ccdb->setCreatedNotAfter(now); + AxisSpec axisDCAz = {100, -.5, .5, "DCA_{z} (cm)"}; + AxisSpec axisDCAxy = {100, -.5, .5, "DCA_{xy} (cm)"}; + AxisSpec axisPhiMod = {100, 0, constants::math::PI / 9, "fmod(#varphi,#pi/9)"}; + AxisSpec axisPhi = {60, 0, constants::math::TwoPI, "#varphi"}; + AxisSpec axisEta = {64, -1.6, 1.6, "#eta"}; + AxisSpec axisEtaVn = {8, -.8, .8, "#eta"}; + AxisSpec axisVx = {40, -0.01, 0.01, "v_{x}"}; + AxisSpec axisVy = {40, -0.01, 0.01, "v_{y}"}; + AxisSpec axisVz = {40, -10, 10, "v_{z}"}; + AxisSpec axisCent = {90, 0, 90, "Centrality(%)"}; + AxisSpec axisPhiPlane = {100, -constants::math::PI, constants::math::PI, "#Psi"}; + AxisSpec axisT0c = {70, 0, 100000, "N_{ch} (T0C)"}; + AxisSpec axisT0a = {70, 0, 200000, "N_{ch} (T0A)"}; + AxisSpec axisV0a = {70, 0, 200000, "N_{ch} (V0A)"}; + AxisSpec axisShCl = {40, 0, 1, "Fraction shared cl. TPC"}; + AxisSpec axisCl = {80, 0, 160, "Number of cl. TPC"}; + AxisSpec axisNsigma = {100, -10, 10, "Nsigma for TPC and TOF"}; + AxisSpec axisdEdx = {300, 0, 300, "dEdx for PID"}; + AxisSpec axisBeta = {150, 0, 1.5, "Beta for PID"}; + std::vector ptbinning = {0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}; AxisSpec axisPt = {ptbinning, "#it{p}_{T} GeV/#it{c}"}; - AxisSpec nchAxis = {4000, 0, 4000, "N_{ch}"}; - AxisSpec t0cAxis = {70, 0, 70000, "N_{ch} (T0C)"}; - AxisSpec t0aAxis = {200, 0, 200, "N_{ch}"}; - AxisSpec multpvAxis = {4000, 0, 4000, "N_{ch} (PV)"}; - - registry.add("hSPplaneA", "hSPplaneA", kTH1D, {axisPhiPlane}); - registry.add("hSPplaneC", "hSPplaneC", kTH1D, {axisPhiPlane}); - registry.add("hSPplaneFull", "hSPplaneFull", kTH1D, {axisPhiPlane}); - - registry.add("hCosPhiACosPhiC", "hCosPhiACosPhiC; Centrality(%); #LT Cos(#Psi^{A})Cos(#Psi^{C})#GT", kTProfile, {axisCent}); - registry.add("hSinPhiASinPhiC", "hSinPhiASinPhiC; Centrality(%); #LT Sin(#Psi^{A})Sin(#Psi^{C})#GT", kTProfile, {axisCent}); - registry.add("hSinPhiACosPhiC", "hSinPhiACosPhiC; Centrality(%); #LT Sin(#Psi^{A})Cos(#Psi^{C})#GT", kTProfile, {axisCent}); - registry.add("hCosPhiASinsPhiC", "hCosPhiASinsPhiC; Centrality(%); #LT Cos(#Psi^{A})Sin(#Psi^{C})#GT", kTProfile, {axisCent}); - registry.add("hFullEvPlaneRes", "hFullEvPlaneRes; Centrality(%); -#LT Cos(#Psi^{A} - #Psi^{C})#GT ", kTProfile, {axisCent}); - - registry.add("QA/after/hCent", "", {HistType::kTH1D, {axisCent}}); - registry.add("QA/after/globalTracks_centT0C", "", {HistType::kTH2D, {axisCent, nchAxis}}); - registry.add("QA/after/PVTracks_centT0C", "", {HistType::kTH2D, {axisCent, multpvAxis}}); - registry.add("QA/after/globalTracks_PVTracks", "", {HistType::kTH2D, {multpvAxis, nchAxis}}); - registry.add("QA/after/globalTracks_multT0A", "", {HistType::kTH2D, {t0aAxis, nchAxis}}); - registry.add("QA/after/globalTracks_multV0A", "", {HistType::kTH2D, {t0aAxis, nchAxis}}); - registry.add("QA/after/multV0A_multT0A", "", {HistType::kTH2D, {t0aAxis, t0aAxis}}); - registry.add("QA/after/multT0C_centT0C", "", {HistType::kTH2D, {axisCent, t0cAxis}}); - - registry.add("QA/after/PsiA_vs_Cent", "", {HistType::kTH2D, {axisPhiPlane, axisCent}}); - registry.add("QA/after/PsiC_vs_Cent", "", {HistType::kTH2D, {axisPhiPlane, axisCent}}); - registry.add("QA/after/PsiFull_vs_Cent", "", {HistType::kTH2D, {axisPhiPlane, axisCent}}); - - registry.add("QA/after/PsiA_vs_Vx", "", {HistType::kTH2D, {axisPhiPlane, axisVx}}); - registry.add("QA/after/PsiC_vs_Vx", "", {HistType::kTH2D, {axisPhiPlane, axisVx}}); - registry.add("QA/after/PsiFull_vs_Vx", "", {HistType::kTH2D, {axisPhiPlane, axisVx}}); - - registry.add("QA/after/PsiA_vs_Vy", "", {HistType::kTH2D, {axisPhiPlane, axisVy}}); - registry.add("QA/after/PsiC_vs_Vy", "", {HistType::kTH2D, {axisPhiPlane, axisVy}}); - registry.add("QA/after/PsiFull_vs_Vy", "", {HistType::kTH2D, {axisPhiPlane, axisVy}}); - - registry.add("QA/after/PsiA_vs_Vz", "", {HistType::kTH2D, {axisPhiPlane, axisVz}}); - registry.add("QA/after/PsiC_vs_Vz", "", {HistType::kTH2D, {axisPhiPlane, axisVz}}); - registry.add("QA/after/PsiFull_vs_Vz", "", {HistType::kTH2D, {axisPhiPlane, axisVz}}); - - registry.addClone("QA/after/", "QA/before/"); - - registry.add("QA/after/pt_phi_bef", "", {HistType::kTH2D, {axisPt, axisPhiMod}}); - registry.add("QA/after/pt_phi_aft", "", {HistType::kTH2D, {axisPt, axisPhiMod}}); - registry.add("QA/after/hPhi_Eta_vz", "", {HistType::kTH3D, {axisPhi, axisEta, axisVz}}); - registry.add("QA/after/hDCAxy", "", {HistType::kTH1D, {axisDCAxy}}); - registry.add("QA/after/hDCAz", "", {HistType::kTH1D, {axisDCAz}}); - - // track properties per centrality and per eta, pt bin - registry.add("incl/vnAx_eta", "", kTProfile, {axisEtaVn}); - registry.add("incl/vnAy_eta", "", kTProfile, {axisEtaVn}); - registry.add("incl/vnCx_eta", "", kTProfile, {axisEtaVn}); - registry.add("incl/vnCy_eta", "", kTProfile, {axisEtaVn}); - registry.add("incl/vnC_eta", "", kTProfile, {axisEtaVn}); - registry.add("incl/vnA_eta", "", kTProfile, {axisEtaVn}); - registry.add("incl/vnA_eta_EP", "", kTProfile, {axisEtaVn}); - registry.add("incl/vnC_eta_EP", "", kTProfile, {axisEtaVn}); - registry.add("incl/vnFull_eta_EP", "", kTProfile, {axisEtaVn}); - - registry.add("incl/vnAx_pt", "", kTProfile, {axisPt}); - registry.add("incl/vnAy_pt", "", kTProfile, {axisPt}); - registry.add("incl/vnCx_pt", "", kTProfile, {axisPt}); - registry.add("incl/vnCy_pt", "", kTProfile, {axisPt}); - registry.add("incl/vnC_pt", "", kTProfile, {axisPt}); - registry.add("incl/vnA_pt", "", kTProfile, {axisPt}); - registry.add("incl/vnA_pt_EP", "", kTProfile, {axisPt}); - registry.add("incl/vnC_pt_EP", "", kTProfile, {axisPt}); - registry.add("incl/vnFull_pt_EP", "", kTProfile, {axisPt}); - - registry.add("incl/vnAx_cent", "", kTProfile, {axisCent}); - registry.add("incl/vnAy_cent", "", kTProfile, {axisCent}); - registry.add("incl/vnCx_cent", "", kTProfile, {axisCent}); - registry.add("incl/vnCy_cent", "", kTProfile, {axisCent}); - registry.add("incl/vnC_cent", "", kTProfile, {axisCent}); - registry.add("incl/vnA_cent", "", kTProfile, {axisCent}); - registry.add("incl/vnA_cent_EP", "", kTProfile, {axisCent}); - registry.add("incl/vnC_cent_EP", "", kTProfile, {axisCent}); - registry.add("incl/vnFull_cent_EP", "", kTProfile, {axisCent}); - - registry.addClone("incl/", "pos/"); - registry.addClone("incl/", "neg/"); - - registry.add("qAqCX", "", kTProfile, {axisCent}); - registry.add("qAqCY", "", kTProfile, {axisCent}); - registry.add("qAqCXY", "", kTProfile, {axisCent}); - - registry.add("hEventCount", "Number of Event;; Count", {HistType::kTH1D, {{11, 0, 11}}}); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(1, "Filtered event"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(2, "sel8"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(3, "occupancy"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(4, "kTVXinTRD"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(5, "kNoSameBunchPileup"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(6, "kIsGoodZvtxFT0vsPV"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(7, "kNoCollInTimeRangeStandard"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(8, "kIsVertexITSTPC"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(9, "after Mult cuts"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(10, "after Cent cuts"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(11, "isSelected"); - - if (cfgUseAdditionalEventCut) { - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - - fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - } - - if (cfgUseAdditionalTrackCut) { + + int ptbins = ptbinning.size() - 1; + + registry.add("hEventCount", "Number of Event; Cut; #Events Passed Cut", {HistType::kTH1D, {{nEventSelections, 0, nEventSelections}}}); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_FilteredEvent + 1, "Filtered event"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_sel8 + 1, "Sel8"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_occupancy + 1, "kOccupancy"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kTVXinTRD + 1, "kTVXinTRD"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoSameBunchPileup + 1, "kNoSameBunchPileup"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoCollInTimeRangeStandard + 1, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsVertexITSTPC + 1, "kIsVertexITSTPC"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_MultCuts + 1, "Multiplicity cuts"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodITSLayersAll + 1, "kkIsGoodITSLayersAll"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_isSelectedZDC + 1, "isSelected"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_CentCuts + 1, "Cenrality range"); + + registry.add("hTrackCount", "Number of Tracks; Cut; #Tracks Passed Cut", {HistType::kTH1D, {{nTrackSelections, 0, nTrackSelections}}}); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_Eta + 1, "Eta"); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_Pt + 1, "Pt"); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_DCAxy + 1, "DCAxy"); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_DCAz + 1, "DCAz"); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_GlobalTracks + 1, "GlobalTracks"); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_NCls + 1, "nClusters TPC"); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_FshCls + 1, "Frac. sh. Cls TPC"); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_TPCBoundary + 1, "TPC Boundary"); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_ZeroCharge + 1, "Only charged"); + registry.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(trackSel_ParticleWeights + 1, "Apply weights"); + + if (cfgFillWeights) { + if (cfguseNUA2D) { + registry.add("weights/hPhi_Eta_vz", "", kTH3D, {axisPhi, axisEta, axisVz}); + registry.add("weights/hPhi_Eta_vz_positive", "", kTH3D, {axisPhi, axisEta, axisVz}); + registry.add("weights/hPhi_Eta_vz_negative", "", kTH3D, {axisPhi, axisEta, axisVz}); + } else { + // define output objects + fWeights->setPtBins(ptbins, &ptbinning[0]); + fWeights->init(true, false); + + fWeightsPOS->setPtBins(ptbins, &ptbinning[0]); + fWeightsPOS->init(true, false); + + fWeightsNEG->setPtBins(ptbins, &ptbinning[0]); + fWeightsNEG->init(true, false); + } + } + + if (cfgFillEventQA) { + registry.add("QA/after/hCentFT0C", " ; Cent FT0C (%); ", {HistType::kTH1D, {axisCent}}); + registry.add("QA/after/hCentFT0M", "; Cent FT0M (%); ", {HistType::kTH1D, {axisCent}}); + registry.add("QA/after/hCentFV0A", "; Cent FV0A (%); ", {HistType::kTH1D, {axisCent}}); + registry.add("QA/after/hCentNGlobal", "; Cent NGlobal (%); ", {HistType::kTH1D, {axisCent}}); + registry.add("QA/after/globalTracks_centT0C", "", {HistType::kTH2D, {axisCent, axisNch}}); + registry.add("QA/after/PVTracks_centT0C", "", {HistType::kTH2D, {axisCent, axisMultpv}}); + registry.add("QA/after/globalTracks_PVTracks", "", {HistType::kTH2D, {axisMultpv, axisNch}}); + registry.add("QA/after/globalTracks_multT0A", "", {HistType::kTH2D, {axisT0a, axisNch}}); + registry.add("QA/after/globalTracks_multV0A", "", {HistType::kTH2D, {axisV0a, axisNch}}); + registry.add("QA/after/multV0A_multT0A", "", {HistType::kTH2D, {axisT0a, axisV0a}}); + registry.add("QA/after/multT0C_centT0C", "", {HistType::kTH2D, {axisCent, axisT0c}}); + registry.add("QA/after/CentFT0C_vs_CentFT0Cvariant1", " ; Cent FT0C (%); Cent FT0Cvariant1 (%) ", {HistType::kTH2D, {axisCent, axisCent}}); + registry.add("QA/after/CentFT0C_vs_CentFT0M", " ; Cent FT0C (%); Cent FT0M (%) ", {HistType::kTH2D, {axisCent, axisCent}}); + registry.add("QA/after/CentFT0C_vs_CentFV0A", " ; Cent FT0C (%); Cent FV0A (%) ", {HistType::kTH2D, {axisCent, axisCent}}); + registry.add("QA/after/CentFT0C_vs_CentNGlobal", " ; Cent FT0C (%); Cent NGlobal (%) ", {HistType::kTH2D, {axisCent, axisCent}}); + } + + if (doprocessData || doprocessMCReco) { + // track QA for pos, neg, incl + if (cfgFillPIDQA) { + registry.add("hPIDcounts", "", kTH2D, {{{4, 0, 4}, axisPt}}); + registry.get(HIST("hPIDcounts"))->GetXaxis()->SetBinLabel(1, "UFO"); + registry.get(HIST("hPIDcounts"))->GetXaxis()->SetBinLabel(2, "Pion"); + registry.get(HIST("hPIDcounts"))->GetXaxis()->SetBinLabel(3, "Kaon"); + registry.get(HIST("hPIDcounts"))->GetXaxis()->SetBinLabel(4, "Proton"); + + registry.add("incl/QA/after/hdEdxTPC_pt", "", {HistType::kTH2D, {axisPt, axisdEdx}}); + registry.add("incl/QA/after/hBetaTOF_pt", "", {HistType::kTH2D, {axisPt, axisBeta}}); + registry.add("incl/pion/QA/after/hNsigmaTPC_pt", "", {HistType::kTH2D, {axisPt, axisNsigma}}); + registry.add("incl/pion/QA/after/hNsigmaTOF_pt", "", {HistType::kTH2D, {axisPt, axisNsigma}}); + + if (cfgFillTrackQA) { + registry.add("incl/pion/QA/after/hPt", "", kTH1D, {axisPt}); + registry.add("incl/pion/QA/after/hPhi", "", kTH1D, {axisPhi}); + registry.add("incl/pion/QA/after/hPhi_uncorrected", "", kTH1D, {axisPhi}); + registry.add("incl/pion/QA/after/hEta", "", kTH1D, {axisEta}); + registry.add("incl/pion/QA/after/hPhi_Eta_vz", "", kTH3D, {axisPhi, axisEta, axisVz}); + registry.add("incl/pion/QA/after/hPhi_Eta_vz_corrected", "", kTH3D, {axisPhi, axisEta, axisVz}); + registry.add("incl/pion/QA/after/hDCAxy_pt", "", kTH2D, {axisPt, axisDCAxy}); + registry.add("incl/pion/QA/after/hDCAz_pt", "", kTH2D, {axisPt, axisDCAz}); + registry.add("incl/pion/QA/after/hSharedClusters_pt", "", {HistType::kTH2D, {axisPt, axisShCl}}); + registry.add("incl/pion/QA/after/hCrossedRows_pt", "", {HistType::kTH2D, {axisPt, axisCl}}); + registry.add("incl/pion/QA/after/hCrossedRows_vs_SharedClusters", "", {HistType::kTH2D, {axisCl, axisShCl}}); + } + if (cfgFillQABefore) + registry.addClone("incl/pion/QA/after/", "incl/pion/QA/before/"); + } + + if (cfgFillTrackQA) { + registry.add("QA/after/pt_phi", "", {HistType::kTH2D, {axisPt, axisPhiMod}}); + registry.add("incl/QA/after/hPhi_Eta_vz", "", kTH3D, {axisPhi, axisEta, axisVz}); + registry.add("incl/QA/after/hPhi_Eta_vz_corrected", "", kTH3D, {axisPhi, axisEta, axisVz}); + registry.add("incl/QA/after/hDCAxy_pt", "", kTH2D, {axisPt, axisDCAxy}); + registry.add("incl/QA/after/hDCAz_pt", "", kTH2D, {axisPt, axisDCAz}); + registry.add("incl/QA/after/hSharedClusters_pt", "", {HistType::kTH2D, {axisPt, axisShCl}}); + registry.add("incl/QA/after/hCrossedRows_pt", "", {HistType::kTH2D, {axisPt, axisCl}}); + registry.add("incl/QA/after/hCrossedRows_vs_SharedClusters", "", {HistType::kTH2D, {axisCl, axisShCl}}); + + if (cfgTrackSelDoTrackQAvsCent) { + registry.add("incl/QA/after/hPt", "", kTH2D, {axisPt, axisCent}); + registry.add("incl/QA/after/hPt_forward", "", kTH2D, {axisPt, axisCent}); + registry.add("incl/QA/after/hPt_forward_uncorrected", "", kTH2D, {axisPt, axisCent}); + registry.add("incl/QA/after/hPt_backward", "", kTH2D, {axisPt, axisCent}); + registry.add("incl/QA/after/hPt_backward_uncorrected", "", kTH2D, {axisPt, axisCent}); + registry.add("incl/QA/after/hPhi", "", kTH2D, {axisPhi, axisCent}); + registry.add("incl/QA/after/hPhi_uncorrected", "", kTH2D, {axisPhi, axisCent}); + registry.add("incl/QA/after/hEta", "", kTH2D, {axisEta, axisCent}); + registry.add("incl/QA/after/hEta_uncorrected", "", kTH2D, {axisEta, axisCent}); + } else { + registry.add("incl/QA/after/hPt", "", kTH1D, {axisPt}); + registry.add("incl/QA/after/hPt_forward", "", kTH1D, {axisPt}); + registry.add("incl/QA/after/hPt_forward_uncorrected", "", kTH1D, {axisPt}); + registry.add("incl/QA/after/hPt_backward", "", kTH1D, {axisPt}); + registry.add("incl/QA/after/hPt_backward_uncorrected", "", kTH1D, {axisPt}); + registry.add("incl/QA/after/hPhi", "", kTH1D, {axisPhi}); + registry.add("incl/QA/after/hPhi_uncorrected", "", kTH1D, {axisPhi}); + registry.add("incl/QA/after/hEta", "", kTH1D, {axisEta}); + registry.add("incl/QA/after/hEta_uncorrected", "", kTH1D, {axisEta}); + } + + if (cfgFillQABefore) + registry.addClone("incl/QA/after/", "incl/QA/before/"); + } + + if (doprocessMCReco) { + registry.add("trackMCReco/after/hIsPhysicalPrimary", "", {HistType::kTH1D, {{2, 0, 2}}}); + registry.add("trackMCReco/hTrackSize_unFiltered", "", {HistType::kTH1D, {{100, 0, 200000}}}); + registry.add("trackMCReco/hTrackSize_Filtered", "", {HistType::kTH1D, {{100, 0, 20000}}}); + registry.get(HIST("trackMCReco/after/hIsPhysicalPrimary"))->GetXaxis()->SetBinLabel(1, "Secondary"); + registry.get(HIST("trackMCReco/after/hIsPhysicalPrimary"))->GetXaxis()->SetBinLabel(2, "Primary"); + registry.add("trackMCReco/after/incl/hPt_hadron", "", {HistType::kTH1D, {axisPt}}); + registry.add("trackMCReco/after/incl/hPt_proton", "", {HistType::kTH1D, {axisPt}}); + registry.add("trackMCReco/after/incl/hPt_pion", "", {HistType::kTH1D, {axisPt}}); + registry.add("trackMCReco/after/incl/hPt_kaon", "", {HistType::kTH1D, {axisPt}}); + registry.addClone("trackMCReco/after/incl/", "trackMCReco/before/pos/"); + registry.addClone("trackMCReco/after/incl/", "trackMCReco/before/neg/"); + registry.addClone("trackMCReco/after/", "trackMCReco/before/"); + } + if (doprocessData) { + if (cfgFillGeneralV1Histos) { + // track properties per centrality and per eta, pt bin + registry.add("incl/vnC_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/vnA_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/vnC_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnA_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnC_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnA_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnC_cent_minEta", "", kTProfile, {axisCent}); + registry.add("incl/vnA_cent_minEta", "", kTProfile, {axisCent}); + registry.add("incl/vnC_cent_plusEta", "", kTProfile, {axisCent}); + registry.add("incl/vnA_cent_plusEta", "", kTProfile, {axisCent}); + } + if (cfgFillPID) { + registry.add("incl/pion/vnC_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/pion/vnA_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/pion/vnC_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnA_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnC_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnA_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnC_cent_minEta", "", kTProfile, {axisCent}); + registry.add("incl/pion/vnA_cent_minEta", "", kTProfile, {axisCent}); + registry.add("incl/pion/vnC_cent_plusEta", "", kTProfile, {axisCent}); + registry.add("incl/pion/vnA_cent_plusEta", "", kTProfile, {axisCent}); + } + if (cfgFillXandYterms) { + registry.add("incl/vnAx_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/vnAy_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/vnCx_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/vnCy_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/vnAx_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnAy_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnCx_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnCy_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnCx_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnAx_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnCy_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnAy_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + if (cfgFillPID) { + registry.add("incl/pion/vnAx_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/pion/vnAy_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/pion/vnCx_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/pion/vnCy_eta", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/pion/vnAx_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnAy_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnCx_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnCy_pt", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnCx_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnAx_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnCy_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/vnAy_pt_odd", "", kTProfile2D, {axisPt, axisCentrality}); + } + } + if (cfgFillMixedHarmonics) { + registry.add("incl/v2/vnAxCxUx_pt_MH", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/v2/vnAxCyUx_pt_MH", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/v2/vnAxCyUy_pt_MH", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/v2/vnAyCxUy_pt_MH", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/v2/vnAxCxUx_cent_MH", "", kTProfile, {axisCent}); + registry.add("incl/v2/vnAxCyUx_cent_MH", "", kTProfile, {axisCent}); + registry.add("incl/v2/vnAxCyUy_cent_MH", "", kTProfile, {axisCent}); + registry.add("incl/v2/vnAyCxUy_cent_MH", "", kTProfile, {axisCent}); + registry.add("incl/v2/vnAxCxUx_eta_MH", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/v2/vnAxCyUx_eta_MH", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/v2/vnAxCyUy_eta_MH", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/v2/vnAyCxUy_eta_MH", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.addClone("incl/v2/", "incl/v3/"); + if (cfgFillPID) { + registry.add("incl/pion/v2/vnAxCxUx_pt_MH", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/v2/vnAxCyUx_pt_MH", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/v2/vnAxCyUy_pt_MH", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/v2/vnAyCxUy_pt_MH", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/pion/v2/vnAxCxUx_cent_MH", "", kTProfile, {axisCent}); + registry.add("incl/pion/v2/vnAxCyUx_cent_MH", "", kTProfile, {axisCent}); + registry.add("incl/pion/v2/vnAxCyUy_cent_MH", "", kTProfile, {axisCent}); + registry.add("incl/pion/v2/vnAyCxUy_cent_MH", "", kTProfile, {axisCent}); + registry.add("incl/pion/v2/vnAxCxUx_eta_MH", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/pion/v2/vnAxCyUx_eta_MH", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/pion/v2/vnAxCyUy_eta_MH", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/pion/v2/vnAyCxUy_eta_MH", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.addClone("incl/pion/v2/", "incl/pion/v3/"); + } + } + if (cfgFillEventPlane) { + registry.add("incl/vnA_cent_EP", "", kTProfile, {axisCent}); + registry.add("incl/vnC_cent_EP", "", kTProfile, {axisCent}); + registry.add("incl/vnFull_cent_EP", "", kTProfile, {axisCent}); + registry.add("incl/vnA_pt_EP", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnC_pt_EP", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnFull_pt_EP", "", kTProfile2D, {axisPt, axisCentrality}); + registry.add("incl/vnA_eta_EP", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/vnC_eta_EP", "", kTProfile2D, {axisEtaVn, axisCentrality}); + registry.add("incl/vnFull_eta_EP", "", kTProfile2D, {axisEtaVn, axisCentrality}); + } + if (cfgFillEventPlaneQA) { + registry.add("QA/hSPplaneA", "hSPplaneA", kTH1D, {axisPhiPlane}); + registry.add("QA/hSPplaneC", "hSPplaneC", kTH1D, {axisPhiPlane}); + registry.add("QA/hSPplaneFull", "hSPplaneFull", kTH1D, {axisPhiPlane}); + registry.add("QA/hCosPhiACosPhiC", "hCosPhiACosPhiC; Centrality(%); #LT Cos(#Psi^{A})Cos(#Psi^{C})#GT", kTProfile, {axisCent}); + registry.add("QA/hSinPhiASinPhiC", "hSinPhiASinPhiC; Centrality(%); #LT Sin(#Psi^{A})Sin(#Psi^{C})#GT", kTProfile, {axisCent}); + registry.add("QA/hSinPhiACosPhiC", "hSinPhiACosPhiC; Centrality(%); #LT Sin(#Psi^{A})Cos(#Psi^{C})#GT", kTProfile, {axisCent}); + registry.add("QA/hCosPhiASinsPhiC", "hCosPhiASinsPhiC; Centrality(%); #LT Cos(#Psi^{A})Sin(#Psi^{C})#GT", kTProfile, {axisCent}); + registry.add("QA/hFullEvPlaneRes", "hFullEvPlaneRes; Centrality(%); -#LT Cos(#Psi^{A} - #Psi^{C})#GT ", kTProfile, {axisCent}); + registry.add("QA/after/PsiA_vs_Cent", "", {HistType::kTH2D, {axisPhiPlane, axisCent}}); + registry.add("QA/after/PsiC_vs_Cent", "", {HistType::kTH2D, {axisPhiPlane, axisCent}}); + registry.add("QA/after/PsiFull_vs_Cent", "", {HistType::kTH2D, {axisPhiPlane, axisCent}}); + registry.add("QA/after/PsiA_vs_Vx", "", {HistType::kTH2D, {axisPhiPlane, axisVx}}); + registry.add("QA/after/PsiC_vs_Vx", "", {HistType::kTH2D, {axisPhiPlane, axisVx}}); + registry.add("QA/after/PsiFull_vs_Vx", "", {HistType::kTH2D, {axisPhiPlane, axisVx}}); + registry.add("QA/after/PsiA_vs_Vy", "", {HistType::kTH2D, {axisPhiPlane, axisVy}}); + registry.add("QA/after/PsiC_vs_Vy", "", {HistType::kTH2D, {axisPhiPlane, axisVy}}); + registry.add("QA/after/PsiFull_vs_Vy", "", {HistType::kTH2D, {axisPhiPlane, axisVy}}); + registry.add("QA/after/PsiA_vs_Vz", "", {HistType::kTH2D, {axisPhiPlane, axisVz}}); + registry.add("QA/after/PsiC_vs_Vz", "", {HistType::kTH2D, {axisPhiPlane, axisVz}}); + registry.add("QA/after/PsiFull_vs_Vz", "", {HistType::kTH2D, {axisPhiPlane, axisVz}}); + } + if (cfgFillEventQA) { + registry.add("QA/qAqCX", "", kTProfile, {axisCent}); + registry.add("QA/qAqCY", "", kTProfile, {axisCent}); + registry.add("QA/qAqCXY", "", kTProfile, {axisCent}); + registry.add("QA/qAXqCY", "", kTProfile, {axisCent}); + registry.add("QA/qAYqCX", "", kTProfile, {axisCent}); + registry.add("QA/qAXYqCXY", "", kTProfile, {axisCent}); + registry.add("QA/hCentFull", " ; Centrality (%); ", {HistType::kTH1D, {axisCent}}); + } + } // end of doprocessData + if (cfgFillQABefore && (cfgFillEventQA || cfgFillPIDQA)) + registry.addClone("QA/after/", "QA/before/"); + + if (cfgFillPID || cfgFillPIDQA) { + registry.addClone("incl/pion/", "incl/kaon/"); + registry.addClone("incl/pion/", "incl/proton/"); + registry.addClone("incl/pion/", "incl/unidentified/"); + } + if (cfgFillChargeDependence || cfgFillPIDQA) { + registry.addClone("incl/", "pos/"); + registry.addClone("incl/", "neg/"); + } + } else if (doprocessMCGen) { + registry.add("trackMCGen/nCollReconstructedPerMcCollision", "", {HistType::kTH1D, {{10, -5, 5}}}); + registry.add("trackMCGen/after/incl/hPt_hadron", "", {HistType::kTH1D, {axisPt}}); + registry.add("trackMCGen/after/incl/hPt_proton", "", {HistType::kTH1D, {axisPt}}); + registry.add("trackMCGen/after/incl/hPt_pion", "", {HistType::kTH1D, {axisPt}}); + registry.add("trackMCGen/after/incl/hPt_kaon", "", {HistType::kTH1D, {axisPt}}); + registry.add("trackMCGen/after/incl/phi_eta_vtxZ_gen", "", {HistType::kTH3D, {axisPhi, axisEta, axisVz}}); + registry.addClone("trackMCGen/after/incl/", "trackMCGen/before/pos/"); + registry.addClone("trackMCGen/after/incl/", "trackMCGen/before/neg/"); + if (cfgFillQABefore) + registry.addClone("trackMCGen/after/", "trackMCGen/before/"); + } + + if (cfgEvSelsUseAdditionalEventCut) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + + std::vector paramsMultPVCut = cfgEvSelsMultPv; + std::vector paramsMultCut = cfgEvSelsMult; + + // number of parameters required in cfgEvSelsMultPv and cfgEvSelsMult. (5 Low + 5 High) + uint64_t nParams = 10; + + if (paramsMultPVCut.size() < nParams) { + LOGF(fatal, "cfgEvSelsMultPv not set properly.. size = %d (should be 10) --> Check your config files!", paramsMultPVCut.size()); + } else if (paramsMultCut.size() < nParams) { + LOGF(fatal, "cfgEvSelsMult not set properly.. size = %d (should be 10) --> Check your config files!", paramsMultCut.size()); + } else { + fMultPVCutLow->SetParameters(paramsMultPVCut[0], paramsMultPVCut[1], paramsMultPVCut[2], paramsMultPVCut[3], paramsMultPVCut[4]); + fMultPVCutHigh->SetParameters(paramsMultPVCut[5], paramsMultPVCut[6], paramsMultPVCut[7], paramsMultPVCut[8], paramsMultPVCut[9]); + fMultCutLow->SetParameters(paramsMultCut[0], paramsMultCut[1], paramsMultCut[2], paramsMultCut[3], paramsMultCut[4]); + fMultCutHigh->SetParameters(paramsMultCut[5], paramsMultCut[6], paramsMultCut[7], paramsMultCut[8], paramsMultCut[9]); + } + } + + if (cfgTrackSelsUseAdditionalTrackCut) { fPhiCutLow = new TF1("fPhiCutLow", "0.06/x+pi/18.0-0.06", 0, 100); fPhiCutHigh = new TF1("fPhiCutHigh", "0.1/x+pi/18.0+0.06", 0, 100); } + } // end of init + + float getNUA2D(TH3D* hNUA, float eta, float phi, float vtxz) + { + int xind = hNUA->GetXaxis()->FindBin(phi); + int etaind = hNUA->GetYaxis()->FindBin(eta); + int vzind = hNUA->GetZaxis()->FindBin(vtxz); + float weight = hNUA->GetBinContent(xind, etaind, vzind); + if (weight != 0) + return 1. / weight; + return 1; + } + + template + int getTrackPID(TrackObject track) + { + + float usedNSigmaPi = -1; + float usedNSigmaKa = -1; + float usedNSigmaPr = -1; + + if (track.hasTOF() && track.hasTPC()) { + usedNSigmaPi = std::hypot(track.tofNSigmaPi(), track.tpcNSigmaPi()); + usedNSigmaKa = std::hypot(track.tofNSigmaKa(), track.tpcNSigmaKa()); + usedNSigmaPr = std::hypot(track.tofNSigmaPr(), track.tpcNSigmaPr()); + } else if (track.hasTOF()) { + usedNSigmaPi = track.tofNSigmaPi(); + usedNSigmaKa = track.tofNSigmaKa(); + usedNSigmaPr = track.tofNSigmaPr(); + } else if (track.hasTPC()) { + usedNSigmaPi = track.tpcNSigmaPi(); + usedNSigmaKa = track.tpcNSigmaKa(); + usedNSigmaPr = track.tpcNSigmaPr(); + } else { + return kUnidentified; // No PID information available + } + + std::unordered_map usedNSigma = {{usedNSigmaPi, kPion}, {usedNSigmaKa, kKaon}, {usedNSigmaPr, kProton}}; + + int nIdentified = 0; + int valPID = 0; + + for (const auto& nsigma : usedNSigma) { + if (std::abs(nsigma.first) < cfgTrackSelsPIDNsigma) { + valPID = nsigma.second; + nIdentified++; + } + } + + if (nIdentified == 0) { + return kUnidentified; // No PID match found + } else if (nIdentified == 1) { + return valPID; + } else { + return kUnidentified; // Multiple PID matches found + } + + return -1; } int getMagneticField(uint64_t timestamp) { // TODO done only once (and not per run). Will be replaced by CCDBConfigurable - // static o2::parameters::GRPObject* grpo = nullptr; static o2::parameters::GRPMagField* grpo = nullptr; if (grpo == nullptr) { - // grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); grpo = ccdb->getForTimeStamp("GLO/Config/GRPMagField", timestamp); if (grpo == nullptr) { LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); @@ -253,86 +674,231 @@ struct FlowSP { return grpo->getNominalL3Field(); } + std::pair getCrossingAngleCCDB(uint64_t timestamp) + { + // TODO done only once (and not per run). Will be replaced by CCDBConfigurable + auto grpo = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object for Crossing Angle not found for timestamp %llu", timestamp); + return {0, 0}; + } + float crossingAngle = grpo->getCrossingAngle(); + uint16_t crossingAngleTime = grpo->getCrossingAngleTime(); + return {crossingAngle, crossingAngleTime}; + } + + // From Generic Framework + void loadCorrections(uint64_t timestamp) + { + // corrections saved on CCDB as TList {incl, pos, neg} of GFWWeights (acc) TH1D (eff) objects! + if (cfg.correctionsLoaded) + return; + + int nWeights = 3; + + if (cfguseNUA1D) { + if (cfgCCDB_NUA.value.empty() == false) { + TList* listCorrections = ccdb->getForTimeStamp(cfgCCDB_NUA, timestamp); + cfg.mAcceptance.push_back(reinterpret_cast(listCorrections->FindObject("weights"))); + cfg.mAcceptance.push_back(reinterpret_cast(listCorrections->FindObject("weights_positive"))); + cfg.mAcceptance.push_back(reinterpret_cast(listCorrections->FindObject("weights_negative"))); + int sizeAcc = cfg.mAcceptance.size(); + if (sizeAcc < nWeights) + LOGF(fatal, "Could not load acceptance weights from %s", cfgCCDB_NUA.value.c_str()); + else + LOGF(info, "Loaded acceptance weights from %s", cfgCCDB_NUA.value.c_str()); + } else { + LOGF(info, "cfgCCDB_NUA empty! No corrections loaded"); + } + } else if (cfguseNUA2D) { + if (cfgCCDB_NUA.value.empty() == false) { + TH3D* hNUA2D = ccdb->getForTimeStamp(cfgCCDB_NUA, timestamp); + if (!hNUA2D) { + LOGF(fatal, "Could not load acceptance weights from %s", cfgCCDB_NUA.value.c_str()); + } else { + LOGF(info, "Loaded acceptance weights from %s", cfgCCDB_NUA.value.c_str()); + cfg.mAcceptance2D.push_back(hNUA2D); + } + } else { + LOGF(info, "cfgCCDB_NUA empty! No corrections loaded"); + } + } + // Get Efficiency correction + if (cfgCCDB_NUE.value.empty() == false) { + TList* listCorrections = ccdb->getForTimeStamp(cfgCCDB_NUE, timestamp); + cfg.mEfficiency.push_back(reinterpret_cast(listCorrections->FindObject("Efficiency"))); + cfg.mEfficiency.push_back(reinterpret_cast(listCorrections->FindObject("Efficiency_pos"))); + cfg.mEfficiency.push_back(reinterpret_cast(listCorrections->FindObject("Efficiency_neg"))); + int sizeEff = cfg.mEfficiency.size(); + if (sizeEff < nWeights) + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgCCDB_NUE.value.c_str()); + else + LOGF(info, "Loaded efficiency histogram from %s", cfgCCDB_NUE.value.c_str()); + } else { + LOGF(info, "cfgCCDB_NUE empty! No corrections loaded"); + } + cfg.correctionsLoaded = true; + } + + // From Generic Framework + bool setCurrentParticleWeights(int pID, float& weight_nue, float& weight_nua, const float& phi, const float& eta, const float& pt, const float& vtxz) + { + float eff = 1.; + int sizeEff = cfg.mEfficiency.size(); + if (sizeEff > pID) + eff = cfg.mEfficiency[pID]->GetBinContent(cfg.mEfficiency[pID]->FindBin(pt)); + else + eff = 1.0; + if (eff == 0) + return false; + weight_nue = 1. / eff; + + if (cfguseNUA1D) { + int sizeAcc = cfg.mAcceptance.size(); + if (sizeAcc > pID) { + weight_nua = cfg.mAcceptance[pID]->getNUA(phi, eta, vtxz); + } else { + weight_nua = 1; + } + } else if (cfguseNUA2D) { + if (cfg.mAcceptance2D.size() > 0) { + weight_nua = getNUA2D(cfg.mAcceptance2D[0], eta, phi, vtxz); + } else { + weight_nua = 1; + } + } + return true; + } + template - bool eventSelected(TCollision collision, const int& multTrk, const float& centrality) + bool eventSelected(TCollision collision, const int& multTrk) { - if (cfgTVXinTRD) { + if (!collision.sel8()) + return 0; + registry.fill(HIST("hEventCount"), evSel_sel8); + + // Occupancy + if (cfgEvSelsDoOccupancySel) { + auto occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy > cfgEvSelsMaxOccupancy) { + return 0; + } + registry.fill(HIST("hEventCount"), evSel_occupancy); + } + + if (cfgEvSelsTVXinTRD) { if (collision.alias_bit(kTVXinTRD)) { // TRD triggered // "CMTVX-B-NOPF-TRD,minbias_TVX" return 0; } - registry.fill(HIST("hEventCount"), 3.5); + registry.fill(HIST("hEventCount"), evSel_kTVXinTRD); } - if (cfgNoSameBunchPileupCut) { + if (cfgEvSelsNoSameBunchPileupCut) { if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { // rejects collisions which are associated with the same "found-by-T0" bunch crossing // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof return 0; } - registry.fill(HIST("hEventCount"), 4.5); + registry.fill(HIST("hEventCount"), evSel_kNoSameBunchPileup); } - if (cfgIsGoodZvtxFT0vsPV) { + if (cfgEvSelsIsGoodZvtxFT0vsPV) { if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference // use this cut at low multiplicities with caution return 0; } - registry.fill(HIST("hEventCount"), 5.5); + registry.fill(HIST("hEventCount"), evSel_kIsGoodZvtxFT0vsPV); } - if (cfgNoCollInTimeRangeStandard) { + if (cfgEvSelsNoCollInTimeRangeStandard) { if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { // Rejection of the collisions which have other events nearby return 0; } - registry.fill(HIST("hEventCount"), 6.5); + registry.fill(HIST("hEventCount"), evSel_kNoCollInTimeRangeStandard); } - if (cfgIsVertexITSTPC) { + if (cfgEvSelsIsVertexITSTPC) { if (!collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { // selects collisions with at least one ITS-TPC track, and thus rejects vertices built from ITS-only tracks return 0; } - registry.fill(HIST("hEventCount"), 7.5); + registry.fill(HIST("hEventCount"), evSel_kIsVertexITSTPC); } - float vtxz = -999; - if (collision.numContrib() > 1) { - vtxz = collision.posZ(); - float zRes = std::sqrt(collision.covZZ()); - if (zRes > 0.25 && collision.numContrib() < 20) - vtxz = -999; - } - // auto multV0A = collision.multFV0A(); - // auto multT0A = collision.multFT0A(); - // auto multT0C = collision.multFT0C(); - auto multNTracksPV = collision.multNTracksPV(); + if (cfgEvSelsUseAdditionalEventCut) { + float vtxz = -999; + if (collision.numContrib() > 1) { + vtxz = collision.posZ(); + float zRes = std::sqrt(collision.covZZ()); + float minzRes = 0.25; + int maxNumContrib = 20; + if (zRes > minzRes && collision.numContrib() < maxNumContrib) + vtxz = -999; + } - if (vtxz > 10 || vtxz < -10) - return 0; - if (multNTracksPV < fMultPVCutLow->Eval(centrality)) - return 0; - if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) - return 0; - if (multTrk < fMultCutLow->Eval(centrality)) - return 0; - if (multTrk > fMultCutHigh->Eval(centrality)) - return 0; + auto multNTracksPV = collision.multNTracksPV(); - registry.fill(HIST("hEventCount"), 8.5); + if (vtxz > cfgEvSelsVtxZ || vtxz < -cfgEvSelsVtxZ) + return 0; + if (multNTracksPV < fMultPVCutLow->Eval(collision.centFT0C())) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(collision.centFT0C())) + return 0; + if (multTrk < fMultCutLow->Eval(collision.centFT0C())) + return 0; + if (multTrk > fMultCutHigh->Eval(collision.centFT0C())) + return 0; - if (centrality > cfgCentMax || centrality < cfgCentMin) - return 0; + registry.fill(HIST("hEventCount"), evSel_MultCuts); + } - registry.fill(HIST("hEventCount"), 9.5); + if (cfgEvSelsIsGoodITSLayersAll) { + if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // New event selection bits to cut time intervals with dead ITS staves + // https://indico.cern.ch/event/1493023/ (09-01-2025) + return 0; + } + registry.fill(HIST("hEventCount"), evSel_kIsGoodITSLayersAll); + } return 1; } - template - bool trackSelected(TTrack track, const int& field) + template + bool trackSelected(TrackObject track, const int& field) { + if (std::fabs(track.eta()) > cfgTrackSelsEta) + return false; + registry.fill(HIST("hTrackCount"), trackSel_Eta); + + if (track.pt() < cfgTrackSelsPtmin || track.pt() > cfgTrackSelsPtmax) + return false; + + registry.fill(HIST("hTrackCount"), trackSel_Pt); + + if (track.dcaXY() > cfgTrackSelsDCAxy) + return false; + + registry.fill(HIST("hTrackCount"), trackSel_DCAxy); + + if (track.dcaZ() > cfgTrackSelsDCAz) + return false; + + if (cfgTrackSelsDoDCApt && std::fabs(track.dcaZ()) > (cfgTrackSelsDCApt1 * cfgTrackSelsDCApt2) / (std::pow(track.pt(), 1.1))) + return false; + + registry.fill(HIST("hTrackCount"), trackSel_DCAz); + + if (track.tpcNClsFound() < cfgTrackSelsNcls) + return false; + registry.fill(HIST("hTrackCount"), trackSel_NCls); + + if (track.tpcFractionSharedCls() > cfgTrackSelsFshcls) + return false; + registry.fill(HIST("hTrackCount"), trackSel_FshCls); + double phimodn = track.phi(); if (field < 0) // for negative polarity field phimodn = o2::constants::math::TwoPI - phimodn; @@ -343,253 +909,721 @@ struct FlowSP { phimodn += o2::constants::math::PI / 18.0; // to center gap in the middle phimodn = fmod(phimodn, o2::constants::math::PI / 9.0); - registry.fill(HIST("QA/after/pt_phi_bef"), track.pt(), phimodn); - if (phimodn < fPhiCutHigh->Eval(track.pt()) && phimodn > fPhiCutLow->Eval(track.pt())) - return false; // reject track - registry.fill(HIST("QA/after/pt_phi_aft"), track.pt(), phimodn); + if (cfgFillTrackQA) + registry.fill(HIST("QA/before/pt_phi"), track.pt(), phimodn); + + if (cfgTrackSelsUseAdditionalTrackCut) { + if (phimodn < fPhiCutHigh->Eval(track.pt()) && phimodn > fPhiCutLow->Eval(track.pt())) + return false; // reject track + } + if (cfgFillTrackQA) + registry.fill(HIST("QA/after/pt_phi"), track.pt(), phimodn); + registry.fill(HIST("hTrackCount"), trackSel_TPCBoundary); return true; } - template - inline void fillEventQA(CollisionObject collision, TracksObject tracks, bool before) + template + inline void fillEventQA(CollisionObject collision, TracksObject tracks, double centWeight = 1.0) { - if (before) { - registry.fill(HIST("QA/before/hCent"), collision.centFT0C()); - registry.fill(HIST("QA/before/globalTracks_centT0C"), collision.centFT0C(), tracks.size()); - registry.fill(HIST("QA/before/PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV()); - registry.fill(HIST("QA/before/globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size()); - registry.fill(HIST("QA/before/globalTracks_multT0A"), collision.multFT0A(), tracks.size()); - registry.fill(HIST("QA/before/globalTracks_multV0A"), collision.multFV0A(), tracks.size()); - registry.fill(HIST("QA/before/multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); - registry.fill(HIST("QA/before/multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); - } else { - registry.fill(HIST("QA/after/hCent"), collision.centFT0C()); - registry.fill(HIST("QA/after/globalTracks_centT0C"), collision.centFT0C(), tracks.size()); - registry.fill(HIST("QA/after/PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV()); - registry.fill(HIST("QA/after/globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size()); - registry.fill(HIST("QA/after/globalTracks_multT0A"), collision.multFT0A(), tracks.size()); - registry.fill(HIST("QA/after/globalTracks_multV0A"), collision.multFV0A(), tracks.size()); - registry.fill(HIST("QA/after/multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); - registry.fill(HIST("QA/after/multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); - - double psiA = 1.0 * std::atan2(collision.qyA(), collision.qxA()); - double psiC = 1.0 * std::atan2(collision.qyC(), collision.qxC()); - double psiFull = 1.0 * std::atan2(collision.qyA() + collision.qyC(), collision.qxA() + collision.qxC()); - - registry.fill(HIST("QA/after/PsiA_vs_Cent"), psiA, collision.centFT0C()); - registry.fill(HIST("QA/after/PsiC_vs_Cent"), psiC, collision.centFT0C()); - registry.fill(HIST("QA/after/PsiFull_vs_Cent"), psiFull, collision.centFT0C()); - registry.fill(HIST("QA/after/PsiA_vs_Vx"), psiA, collision.vx()); - registry.fill(HIST("QA/after/PsiC_vs_Vx"), psiC, collision.vx()); - registry.fill(HIST("QA/after/PsiFull_vs_Vx"), psiFull, collision.vx()); - registry.fill(HIST("QA/after/PsiA_vs_Vy"), psiA, collision.vy()); - registry.fill(HIST("QA/after/PsiC_vs_Vy"), psiC, collision.vy()); - registry.fill(HIST("QA/after/PsiFull_vs_Vy"), psiFull, collision.vy()); - registry.fill(HIST("QA/after/PsiA_vs_Vz"), psiA, collision.posZ()); - registry.fill(HIST("QA/after/PsiC_vs_Vz"), psiC, collision.posZ()); - registry.fill(HIST("QA/after/PsiFull_vs_Vz"), psiFull, collision.posZ()); + if (!cfgFillEventQA) + return; + + static constexpr std::string_view Time[] = {"before", "after"}; + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hCentFT0C"), collision.centFT0C(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hCentNGlobal"), collision.centNGlobal(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hCentFT0M"), collision.centFT0M(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hCentFV0A"), collision.centFV0A(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/globalTracks_centT0C"), collision.centFT0C(), tracks.size(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/globalTracks_multT0A"), collision.multFT0A(), tracks.size(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/globalTracks_multV0A"), collision.multFV0A(), tracks.size(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/multV0A_multT0A"), collision.multFT0A(), collision.multFV0A(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/multT0C_centT0C"), collision.centFT0C(), collision.multFT0C(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/CentFT0C_vs_CentFT0Cvariant1"), collision.centFT0C(), collision.centFT0CVariant1(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/CentFT0C_vs_CentFT0M"), collision.centFT0C(), collision.centFT0M(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/CentFT0C_vs_CentFV0A"), collision.centFT0C(), collision.centFV0A(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/CentFT0C_vs_CentNGlobal"), collision.centFT0C(), collision.centNGlobal(), centWeight); + + if (cfgFillEventPlaneQA) { + if constexpr (o2::framework::has_type_v) { + double psiA = 1.0 * std::atan2(collision.qyA(), collision.qxA()); + double psiC = 1.0 * std::atan2(collision.qyC(), collision.qxC()); + double psiFull = 1.0 * std::atan2(collision.qyA() + collision.qyC(), collision.qxA() + collision.qxC()); + + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiA_vs_Cent"), psiA, collision.centFT0C(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiC_vs_Cent"), psiC, collision.centFT0C(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiFull_vs_Cent"), psiFull, collision.centFT0C(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiA_vs_Vx"), psiA, collision.vx(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiC_vs_Vx"), psiC, collision.vx(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiFull_vs_Vx"), psiFull, collision.vx(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiA_vs_Vy"), psiA, collision.vy(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiC_vs_Vy"), psiC, collision.vy(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiFull_vs_Vy"), psiFull, collision.vy(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiA_vs_Vz"), psiA, collision.posZ(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiC_vs_Vz"), psiC, collision.posZ(), centWeight); + registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/PsiFull_vs_Vz"), psiFull, collision.posZ(), centWeight); + } } return; } - void process(UsedCollisions::iterator const& collision, aod::BCsWithTimestamps const&, UsedTracks const& tracks) + template + inline void fillHistograms(TrackObject track, float wacc, float weff, double centWeight, double ux, double uy, double uxMH, double uyMH, double uxMH2, double uyMH2, double qxA, double qyA, double qxC, double qyC, double corrQQx, double corrQQy, double corrQQ, double vnA, double vnC, double vnFull, double centrality) { - // Hier sum over collisions and get ZDC data. - registry.fill(HIST("hEventCount"), .5); - if (!collision.sel8()) + double weight = wacc * weff * centWeight; + + if (cfgFillGeneralV1Histos) { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnA_eta"), track.eta(), centrality, (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnC_eta"), track.eta(), centrality, (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ)), weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnA_pt"), track.pt(), centrality, (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnC_pt"), track.pt(), centrality, (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ)), weight); + } + + if (cfgFillMixedHarmonics) { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAxCxUx_eta_MH"), track.eta(), centrality, (uxMH * qxA * qxC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAxCyUx_eta_MH"), track.eta(), centrality, (uxMH * qyA * qyC) / corrQQy, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAxCyUy_eta_MH"), track.eta(), centrality, (uyMH * qxA * qyC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAyCxUy_eta_MH"), track.eta(), centrality, (uyMH * qyA * qxC) / corrQQy, weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAxCxUx_pt_MH"), track.pt(), centrality, (uxMH * qxA * qxC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAxCyUx_pt_MH"), track.pt(), centrality, (uxMH * qyA * qyC) / corrQQy, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAxCyUy_pt_MH"), track.pt(), centrality, (uyMH * qxA * qyC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAyCxUy_pt_MH"), track.pt(), centrality, (uyMH * qyA * qxC) / corrQQy, weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAxCxUx_cent_MH"), centrality, (uxMH * qxA * qxC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAxCyUx_cent_MH"), centrality, (uxMH * qyA * qyC) / corrQQy, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAxCyUy_cent_MH"), centrality, (uyMH * qxA * qyC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v2/vnAyCxUy_cent_MH"), centrality, (uyMH * qyA * qxC) / corrQQy, weight); + + // -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAxCxUx_eta_MH"), track.eta(), centrality, (uxMH2 * qxA * qxC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAxCyUx_eta_MH"), track.eta(), centrality, (uxMH2 * qyA * qyC) / corrQQy, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAxCyUy_eta_MH"), track.eta(), centrality, (uyMH2 * qxA * qyC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAyCxUy_eta_MH"), track.eta(), centrality, (uyMH2 * qyA * qxC) / corrQQy, weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAxCxUx_pt_MH"), track.pt(), centrality, (uxMH2 * qxA * qxC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAxCyUx_pt_MH"), track.pt(), centrality, (uxMH2 * qyA * qyC) / corrQQy, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAxCyUy_pt_MH"), track.pt(), centrality, (uyMH2 * qxA * qyC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAyCxUy_pt_MH"), track.pt(), centrality, (uyMH2 * qyA * qxC) / corrQQy, weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAxCxUx_cent_MH"), centrality, (uxMH2 * qxA * qxC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAxCyUx_cent_MH"), centrality, (uxMH2 * qyA * qyC) / corrQQy, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAxCyUy_cent_MH"), centrality, (uyMH2 * qxA * qyC) / corrQQx, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("v3/vnAyCxUy_cent_MH"), centrality, (uyMH2 * qyA * qxC) / corrQQy, weight); + } + + if (cfgFillXandYterms) { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnAx_eta"), track.eta(), centrality, (ux * qxA) / std::sqrt(std::fabs(corrQQx)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnAy_eta"), track.eta(), centrality, (uy * qyA) / std::sqrt(std::fabs(corrQQy)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnCx_eta"), track.eta(), centrality, (ux * qxC) / std::sqrt(std::fabs(corrQQx)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnCy_eta"), track.eta(), centrality, (uy * qyC) / std::sqrt(std::fabs(corrQQy)), weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnAx_pt"), track.pt(), centrality, (ux * qxA) / std::sqrt(std::fabs(corrQQx)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnAy_pt"), track.pt(), centrality, (uy * qyA) / std::sqrt(std::fabs(corrQQy)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnCx_pt"), track.pt(), centrality, (ux * qxC) / std::sqrt(std::fabs(corrQQx)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnCy_pt"), track.pt(), centrality, (uy * qyC) / std::sqrt(std::fabs(corrQQy)), weight); + } + + if (cfgFillEventPlane) { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnA_eta_EP"), track.eta(), centrality, vnA, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnC_eta_EP"), track.eta(), centrality, vnC, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnFull_eta_EP"), track.eta(), centrality, vnFull, weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnA_pt_EP"), track.pt(), centrality, vnA, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnC_pt_EP"), track.pt(), centrality, vnC, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnFull_pt_EP"), track.pt(), centrality, vnFull, weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnA_cent_EP"), centrality, vnA, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnC_cent_EP"), centrality, vnC, weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnFull_cent_EP"), centrality, vnFull, weight); + } + + // For integrated v1 take only tracks from eta>0. + // Following https://arxiv.org/pdf/1306.4145 + if (cfgFillGeneralV1Histos) { + if (track.eta() < 0 && cfgHarm == 1) { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnA_cent_minEta"), centrality, -1.0 * (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnC_cent_minEta"), centrality, -1.0 * (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ)), weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnA_pt_odd"), track.pt(), centrality, -1.0 * (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnC_pt_odd"), track.pt(), centrality, -1.0 * (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ)), weight); + + if (cfgFillXandYterms) { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnAx_pt_odd"), track.pt(), centrality, -1.0 * (ux * qxA) / std::sqrt(std::fabs(corrQQx)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnAy_pt_odd"), track.pt(), centrality, -1.0 * (uy * qyA) / std::sqrt(std::fabs(corrQQy)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnCx_pt_odd"), track.pt(), centrality, -1.0 * (ux * qxC) / std::sqrt(std::fabs(corrQQx)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnCy_pt_odd"), track.pt(), centrality, -1.0 * (uy * qyC) / std::sqrt(std::fabs(corrQQy)), weight); + } + } else { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnA_cent_plusEta"), centrality, (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnC_cent_plusEta"), centrality, (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ)), weight); + + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnA_pt_odd"), track.pt(), centrality, (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnC_pt_odd"), track.pt(), centrality, (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ)), weight); + + if (cfgFillXandYterms) { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnAx_pt_odd"), track.pt(), centrality, (ux * qxA) / std::sqrt(std::fabs(corrQQx)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnAy_pt_odd"), track.pt(), centrality, (uy * qyA) / std::sqrt(std::fabs(corrQQy)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnCx_pt_odd"), track.pt(), centrality, (ux * qxC) / std::sqrt(std::fabs(corrQQx)), weight); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("vnCy_pt_odd"), track.pt(), centrality, (uy * qyC) / std::sqrt(std::fabs(corrQQy)), weight); + } + } + } + } + + template + inline void fillTrackQA(TrackObject track, double vz, float wacc = 1, float weff = 1) + { + if (!cfgFillTrackQA) return; - registry.fill(HIST("hEventCount"), 1.5); - auto bc = collision.bc_as(); - auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; + static constexpr std::string_view Time[] = {"before/", "after/"}; + // NOTE: species[kUnidentified] = "" (when no PID) + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt"), track.pt(), wacc * weff); + if (track.eta() > 0) { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt_forward"), track.pt(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt_forward_uncorrected"), track.pt()); + } else { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt_backward"), track.pt(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt_backward_uncorrected"), track.pt()); + } + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPhi"), track.phi(), wacc); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPhi_uncorrected"), track.phi()); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hEta"), track.eta(), wacc); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hEta_uncorrected"), track.eta()); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPhi_Eta_vz"), track.phi(), track.eta(), vz); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPhi_Eta_vz_corrected"), track.phi(), track.eta(), vz, wacc); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hDCAxy_pt"), track.pt(), track.dcaXY(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hDCAz_pt"), track.pt(), track.dcaZ(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hSharedClusters_pt"), track.pt(), track.tpcFractionSharedCls(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hCrossedRows_pt"), track.pt(), track.tpcNClsFound(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hCrossedRows_vs_SharedClusters"), track.tpcNClsFound(), track.tpcFractionSharedCls(), wacc * weff); + } - auto centrality = collision.centFT0C(); - // auto bc = collision.template bc_as(); - if (!eventSelected(collision, tracks.size(), centrality)) + template + inline void fillTrackQA(TrackObject track, double vz, double centrality, float wacc = 1, float weff = 1) + { + if (!cfgFillTrackQA) return; - fillEventQA(collision, tracks, true); + static constexpr std::string_view Time[] = {"before/", "after/"}; + // NOTE: species[kUnidentified] = "" (when no PID) + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt"), track.pt(), centrality, wacc * weff); + if (track.eta() > 0) { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt_forward"), track.pt(), centrality, wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt_forward_uncorrected"), track.pt(), centrality); + } else { + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt_backward"), track.pt(), centrality, wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPt_backward_uncorrected"), track.pt(), centrality); + } + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPhi"), track.phi(), centrality, wacc); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPhi_uncorrected"), track.phi(), centrality); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hEta"), track.eta(), centrality, wacc); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hEta_uncorrected"), track.eta(), centrality); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPhi_Eta_vz"), track.phi(), track.eta(), vz); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hPhi_Eta_vz_corrected"), track.phi(), track.eta(), vz, wacc); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hDCAxy_pt"), track.pt(), track.dcaXY(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hDCAz_pt"), track.pt(), track.dcaZ(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hSharedClusters_pt"), track.pt(), track.tpcFractionSharedCls(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hCrossedRows_pt"), track.pt(), track.tpcNClsFound(), wacc * weff); + registry.fill(HIST(Charge[ct]) + HIST(Species[pt]) + HIST("QA/") + HIST(Time[ft]) + HIST("hCrossedRows_vs_SharedClusters"), track.tpcNClsFound(), track.tpcFractionSharedCls(), wacc * weff); + } + + template + inline void fillPIDQA(TrackObject track) + { + if (!cfgFillPIDQA) + return; + + registry.fill(HIST(Charge[ct]) + HIST("pion/") + HIST("QA/") + HIST(Time[ft]) + HIST("hNsigmaTOF_pt"), track.pt(), track.tofNSigmaPi()); + registry.fill(HIST(Charge[ct]) + HIST("pion/") + HIST("QA/") + HIST(Time[ft]) + HIST("hNsigmaTPC_pt"), track.pt(), track.tpcNSigmaPi()); + registry.fill(HIST(Charge[ct]) + HIST("kaon/") + HIST("QA/") + HIST(Time[ft]) + HIST("hNsigmaTOF_pt"), track.pt(), track.tofNSigmaKa()); + registry.fill(HIST(Charge[ct]) + HIST("kaon/") + HIST("QA/") + HIST(Time[ft]) + HIST("hNsigmaTPC_pt"), track.pt(), track.tpcNSigmaKa()); + registry.fill(HIST(Charge[ct]) + HIST("proton/") + HIST("QA/") + HIST(Time[ft]) + HIST("hNsigmaTOF_pt"), track.pt(), track.tofNSigmaPr()); + registry.fill(HIST(Charge[ct]) + HIST("proton/") + HIST("QA/") + HIST(Time[ft]) + HIST("hNsigmaTPC_pt"), track.pt(), track.tpcNSigmaPr()); + + registry.fill(HIST(Charge[ct]) + HIST("QA/") + HIST(Time[ft]) + HIST("hdEdxTPC_pt"), track.pt(), track.tpcSignal()); + registry.fill(HIST(Charge[ct]) + HIST("QA/") + HIST(Time[ft]) + HIST("hBetaTOF_pt"), track.pt(), track.beta()); + } + + template + inline void fillMCPtHistos(TrackObject track, int pdgCode) + { + static constexpr std::string_view Time[] = {"before/", "after/"}; + static constexpr std::string_view Mode[] = {"Gen/", "Reco/"}; + + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("incl/hPt_hadron"), track.pt()); + if (pdgCode > 0) { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("pos/hPt_hadron"), track.pt()); + } else { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("neg/hPt_hadron"), track.pt()); + } + + if (pdgCode == kPiPlus || pdgCode == kPiMinus) { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("incl/hPt_pion"), track.pt()); + if (pdgCode == kPiPlus) { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("pos/hPt_pion"), track.pt()); + } else { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("neg/hPt_pion"), track.pt()); + } + } else if (pdgCode == kKPlus || pdgCode == kKMinus) { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("incl/hPt_kaon"), track.pt()); + if (pdgCode == kKPlus) { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("pos/hPt_kaon"), track.pt()); + } else { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("neg/hPt_kaon"), track.pt()); + } + } else if (pdgCode == kProton || pdgCode == kProtonBar) { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("incl/hPt_proton"), track.pt()); + if (pdgCode == kProton) { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("pos/hPt_proton"), track.pt()); + } else { + registry.fill(HIST("trackMC") + HIST(Mode[md]) + HIST(Time[ft]) + HIST("neg/hPt_proton"), track.pt()); + } + } + } + + template + inline void fillPrimaryHistos(McParticleObject mcparticle) + { + static constexpr std::string_view Time[] = {"/before", "/after"}; + + if (!mcparticle.isPhysicalPrimary()) { + registry.fill(HIST("trackMCReco") + HIST(Time[md]) + HIST("/hIsPhysicalPrimary"), 0); + } else { + registry.fill(HIST("trackMCReco") + HIST(Time[md]) + HIST("/hIsPhysicalPrimary"), 1); + } + } + + template + void fillAllQA(TrackObject track, double vtxz, double centrality, bool pos, float wacc = 1, float weff = 1, float waccP = 1, float weffP = 1, float waccN = 1, float weffN = 1) + { + if (!cfgTrackSelDoTrackQAvsCent) { + fillTrackQA(track, vtxz, wacc, weff); + } else { + fillTrackQA(track, vtxz, centrality, wacc, weff); + } + fillPIDQA(track); + if (pos) { + if (!cfgTrackSelDoTrackQAvsCent) { + fillTrackQA(track, vtxz, waccP, weffP); + } else { + fillTrackQA(track, vtxz, centrality, waccP, weffP); + } + fillPIDQA(track); + } else { + if (!cfgTrackSelDoTrackQAvsCent) { + fillTrackQA(track, vtxz, waccN, weffN); + } else { + fillTrackQA(track, vtxz, centrality, waccN, weffN); + } + fillPIDQA(track); + } + } + + void processData(UsedCollisions::iterator const& collision, aod::BCsWithTimestamps const&, UsedTracks const& tracks) + { + registry.fill(HIST("hEventCount"), evSel_FilteredEvent); + auto bc = collision.bc_as(); + int standardMagField = 99999; + auto field = (cfgMagField == standardMagField) ? getMagneticField(bc.timestamp()) : cfgMagField; + + if (bc.runNumber() != cfg.lastRunNumber) { + cfg.correctionsLoaded = false; + cfg.clCentrality = false; + cfg.lastRunNumber = bc.runNumber(); + cfg.mAcceptance.clear(); + LOGF(info, "Size of mAcceptance: %i (should be 0)", (int)cfg.mAcceptance.size()); + } + + if (cfgFillQABefore) + fillEventQA(collision, tracks); + + loadCorrections(bc.timestamp()); + + float centrality = collision.centFT0C(); + + if (cfgCentFT0Cvariant1) + centrality = collision.centFT0CVariant1(); + if (cfgCentFT0M) + centrality = collision.centFT0M(); + if (cfgCentFV0A) + centrality = collision.centFV0A(); + if (cfgCentNGlobal) + centrality = collision.centNGlobal(); + + if (!eventSelected(collision, tracks.size())) + return; if (collision.isSelected()) { - registry.fill(HIST("hEventCount"), 10.5); + registry.fill(HIST("hEventCount"), evSel_isSelectedZDC); double qxA = collision.qxA(); double qyA = collision.qyA(); double qxC = collision.qxC(); double qyC = collision.qyC(); + double vtxz = collision.posZ(); double psiA = 1.0 * std::atan2(qyA, qxA); - registry.fill(HIST("hSPplaneA"), psiA, 1); - double psiC = 1.0 * std::atan2(qyC, qxC); - registry.fill(HIST("hSPplaneC"), psiC, 1); // https://twiki.cern.ch/twiki/pub/ALICE/DirectedFlowAnalysisNote/vn_ZDC_ALICE_INT_NOTE_version02.pdf double psiFull = 1.0 * std::atan2(qyA + qyC, qxA + qxC); - registry.fill(HIST("hSPplaneFull"), psiFull, 1); - - fillEventQA(collision, tracks, false); - - registry.fill(HIST("hCosPhiACosPhiC"), centrality, std::cos(psiA) * std::cos(psiC)); - registry.fill(HIST("hSinPhiASinPhiC"), centrality, std::sin(psiA) * std::sin(psiC)); - registry.fill(HIST("hSinPhiACosPhiC"), centrality, std::sin(psiA) * std::cos(psiC)); - registry.fill(HIST("hCosPhiASinsPhiC"), centrality, std::cos(psiA) * std::sin(psiC)); - registry.fill(HIST("hFullEvPlaneRes"), centrality, -1 * std::cos(psiA - psiC)); - - registry.fill(HIST("qAqCXY"), centrality, qxA * qxC + qyA * qyC); - registry.fill(HIST("qAqCX"), centrality, qxA * qxC); - registry.fill(HIST("qAqCY"), centrality, qyA * qyC); + if (cfgFillEventQA) { + registry.fill(HIST("QA/hCentFull"), centrality, 1); + registry.fill(HIST("QA/qAqCXY"), centrality, qxA * qxC + qyA * qyC); + registry.fill(HIST("QA/qAXqCY"), centrality, qxA * qyC); + registry.fill(HIST("QA/qAYqCX"), centrality, qyA * qxC); + registry.fill(HIST("QA/qAXYqCXY"), centrality, qyA * qxC + qxA * qyC); + registry.fill(HIST("QA/qAqCX"), centrality, qxA * qxC); + registry.fill(HIST("QA/qAqCY"), centrality, qyA * qyC); + } + if (cfgFillEventPlaneQA) { + registry.fill(HIST("QA/hSPplaneA"), psiA, 1); + registry.fill(HIST("QA/hSPplaneC"), psiC, 1); + registry.fill(HIST("QA/hSPplaneFull"), psiFull, 1); + registry.fill(HIST("QA/hCosPhiACosPhiC"), centrality, std::cos(psiA) * std::cos(psiC)); + registry.fill(HIST("QA/hSinPhiASinPhiC"), centrality, std::sin(psiA) * std::sin(psiC)); + registry.fill(HIST("QA/hSinPhiACosPhiC"), centrality, std::sin(psiA) * std::cos(psiC)); + registry.fill(HIST("QA/hCosPhiASinsPhiC"), centrality, std::cos(psiA) * std::sin(psiC)); + registry.fill(HIST("QA/hFullEvPlaneRes"), centrality, -1 * std::cos(psiA - psiC)); + } - double corrQQ = 1.; - if (cfgLoadAverageQQ) { - TProfile* hcorrQQ = ccdb->getForTimeStamp(cfgCCDBdir.value, bc.timestamp()); - corrQQ = hcorrQQ->GetBinContent(hcorrQQ->FindBin(centrality)); + if (centrality > cfgCentMax || centrality < cfgCentMin) + return; + + registry.fill(HIST("hEventCount"), evSel_CentCuts); + + // Load correlations and SP resolution needed for Scalar Product and event plane methods. + // Only load once! + // If not loaded set to 1 + double corrQQ = 1., corrQQx = 1., corrQQy = 1.; + if (cfgCCDBdir_QQ.value.empty() == false) { + if (!cfg.clQQ) { + TList* hcorrList = ccdb->getForTimeStamp(cfgCCDBdir_QQ.value, bc.timestamp()); + cfg.hcorrQQ = reinterpret_cast(hcorrList->FindObject("qAqCXY")); + cfg.hcorrQQx = reinterpret_cast(hcorrList->FindObject("qAqCX")); + cfg.hcorrQQy = reinterpret_cast(hcorrList->FindObject("qAqCY")); + cfg.clQQ = true; + } + corrQQ = cfg.hcorrQQ->GetBinContent(cfg.hcorrQQ->FindBin(centrality)); + corrQQx = cfg.hcorrQQx->GetBinContent(cfg.hcorrQQx->FindBin(centrality)); + corrQQy = cfg.hcorrQQy->GetBinContent(cfg.hcorrQQy->FindBin(centrality)); } double evPlaneRes = 1.; - if (cfgLoadSPPlaneRes) { - TProfile* hEvPlaneRes = ccdb->getForTimeStamp(cfgCCDBdir_SP.value, bc.timestamp()); - evPlaneRes = hEvPlaneRes->GetBinContent(hEvPlaneRes->FindBin(centrality)); + if (cfgCCDBdir_SP.value.empty() == false) { + if (!cfg.clEvPlaneRes) { + cfg.hEvPlaneRes = ccdb->getForTimeStamp(cfgCCDBdir_SP.value, bc.timestamp()); + cfg.clEvPlaneRes = true; + } + evPlaneRes = cfg.hEvPlaneRes->GetBinContent(cfg.hEvPlaneRes->FindBin(centrality)); if (evPlaneRes < 0) LOGF(fatal, " > 0 for centrality %.2f! Cannot determine resolution.. Change centrality ranges!!!", centrality); evPlaneRes = std::sqrt(evPlaneRes); } + double centWeight = 1.0; + if (cfgCCDBdir_centrality.value.empty() == false) { + if (!cfg.clCentrality) { + cfg.hCentrality = ccdb->getForTimeStamp(cfgCCDBdir_centrality.value, bc.timestamp()); + cfg.clCentrality = true; + } + centWeight = cfg.hCentrality->GetBinContent(cfg.hCentrality->FindBin(centrality)); + if (centWeight < 0) + LOGF(fatal, "Centrality weight cannot be negative.. abort for (%.2f)", centrality); + } + + fillEventQA(collision, tracks, centWeight); + for (const auto& track : tracks) { - if (!trackSelected(track, field)) - continue; + + int trackPID = (cfgFillPID || cfgFillPIDQA) ? getTrackPID(track) : kUnidentified; + + if (cfgFillPIDQA) + registry.fill(HIST("hPIDcounts"), trackPID, track.pt()); + + float weff = 1., wacc = 1.; + float weffP = 1., waccP = 1.; + float weffN = 1., waccN = 1.; if (track.sign() == 0.0) continue; + + registry.fill(HIST("hTrackCount"), trackSel_ZeroCharge); bool pos = (track.sign() > 0) ? true : false; + if (cfgFillQABefore) { + switch (trackPID) { + case kUnidentified: + fillAllQA(track, vtxz, centrality, pos); + break; + case kPion: + fillAllQA(track, vtxz, centrality, pos); + break; + case kKaon: + fillAllQA(track, vtxz, centrality, pos); + break; + case kProton: + fillAllQA(track, vtxz, centrality, pos); + break; + } + } + + if (!trackSelected(track, field)) + continue; + // constrain angle to 0 -> [0,0+2pi] auto phi = RecoDecay::constrainAngle(track.phi(), 0); + if (cfguseNUA2D && cfgFillWeights) { + registry.fill(HIST("weights/hPhi_Eta_vz"), phi, track.eta(), vtxz, 1); + if (pos) { + registry.fill(HIST("weights/hPhi_Eta_vz_positive"), phi, track.eta(), vtxz, 1); + } else { + registry.fill(HIST("weights/hPhi_Eta_vz_negative"), phi, track.eta(), vtxz, 1); + } + } + + // Fill NUA weights (last 0 is for Data see GFWWeights class (not a weight)) + if (cfgFillWeights) { + fWeights->fill(phi, track.eta(), vtxz, track.pt(), centrality, 0); + } + if (cfgFillWeightsPOS) { + if (pos) + fWeightsPOS->fill(phi, track.eta(), vtxz, track.pt(), centrality, 0); + } + if (cfgFillWeightsNEG) { + if (!pos) + fWeightsNEG->fill(phi, track.eta(), vtxz, track.pt(), centrality, 0); + } + + // Set weff and wacc for inclusive, negative and positive hadrons + if (!setCurrentParticleWeights(kInclusive, weff, wacc, phi, track.eta(), track.pt(), vtxz)) + continue; + if (pos && !setCurrentParticleWeights(kPositive, weffP, waccP, phi, track.eta(), track.pt(), vtxz)) + continue; + if (!pos && !setCurrentParticleWeights(kNegative, weffN, waccN, phi, track.eta(), track.pt(), vtxz)) + continue; + + registry.fill(HIST("hTrackCount"), trackSel_ParticleWeights); + + switch (trackPID) { + case kUnidentified: + fillAllQA(track, vtxz, centrality, pos, wacc, weff, waccP, weffP, waccN, weffN); + break; + case kPion: + fillAllQA(track, vtxz, centrality, pos, wacc, weff, waccP, weffP, waccN, weffN); + break; + case kKaon: + fillAllQA(track, vtxz, centrality, pos, wacc, weff, waccP, weffP, waccN, weffN); + break; + case kProton: + fillAllQA(track, vtxz, centrality, pos, wacc, weff, waccP, weffP, waccN, weffN); + break; + } + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - auto ux = std::cos(cfgHarm * phi); auto uy = std::sin(cfgHarm * phi); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - registry.fill(HIST("incl/vnAx_eta"), track.eta(), (ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnAy_eta"), track.eta(), (uy * qyA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnCx_eta"), track.eta(), (ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnCy_eta"), track.eta(), (uy * qyC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnA_eta"), track.eta(), (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnC_eta"), track.eta(), (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ))); - - registry.fill(HIST("incl/vnAx_pt"), track.pt(), (ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnAy_pt"), track.pt(), (uy * qyA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnCx_pt"), track.pt(), (ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnCy_pt"), track.pt(), (uy * qyC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnA_pt"), track.pt(), (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnC_pt"), track.pt(), (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ))); - - registry.fill(HIST("incl/vnAx_cent"), centrality, (ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnAy_cent"), centrality, (uy * qyA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnCx_cent"), centrality, (ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnCy_cent"), centrality, (uy * qyC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnA_cent"), centrality, (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("incl/vnC_cent"), centrality, (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ))); + auto uxMH = std::cos(cfgHarmMixed1 * phi); + auto uyMH = std::sin(cfgHarmMixed1 * phi); + + auto uxMH2 = std::cos(cfgHarmMixed2 * phi); + auto uyMH2 = std::sin(cfgHarmMixed2 * phi); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - double vnA = std::cos(cfgHarm * (phi - psiA)) / evPlaneRes; double vnC = std::cos(cfgHarm * (phi - psiC)) / evPlaneRes; double vnFull = std::cos(cfgHarm * (phi - psiFull)) / evPlaneRes; - registry.fill(HIST("incl/vnA_eta_EP"), track.eta(), vnA); - registry.fill(HIST("incl/vnC_eta_EP"), track.eta(), vnC); - registry.fill(HIST("incl/vnFull_eta_EP"), track.eta(), vnFull); + fillHistograms(track, wacc, weff, centWeight, ux, uy, uxMH, uyMH, uxMH2, uyMH2, qxA, qyA, qxC, qyC, corrQQx, corrQQy, corrQQ, vnA, vnC, vnFull, centrality); + if (cfgFillChargeDependence) { + if (pos) { + fillHistograms(track, waccP, weffP, centWeight, ux, uy, uxMH, uyMH, uxMH2, uyMH2, qxA, qyA, qxC, qyC, corrQQx, corrQQy, corrQQ, vnA, vnC, vnFull, centrality); + } else { + fillHistograms(track, waccN, weffN, centWeight, ux, uy, uxMH, uyMH, uxMH2, uyMH2, qxA, qyA, qxC, qyC, corrQQx, corrQQy, corrQQ, vnA, vnC, vnFull, centrality); + } + } + } // end of track loop + } // end of collision isSelected loop + } + + PROCESS_SWITCH(FlowSP, processData, "Process analysis for non-derived data", true); + + void processMCReco(CC const& collision, aod::BCsWithTimestamps const&, TCs const& tracks, FilteredTCs const& filteredTracks, aod::McParticles const&) + { + auto bc = collision.template bc_as(); + int standardMagField = 99999; + auto field = (cfgMagField == standardMagField) ? getMagneticField(bc.timestamp()) : cfgMagField; + + double vtxz = collision.posZ(); + float centrality = collision.centFT0C(); + if (cfgCentFT0Cvariant1) + centrality = collision.centFT0CVariant1(); + if (cfgCentFT0M) + centrality = collision.centFT0M(); + if (cfgCentFV0A) + centrality = collision.centFV0A(); + if (cfgCentNGlobal) + centrality = collision.centNGlobal(); + + if (cfgFillQABefore) + fillEventQA(collision, tracks); + + if (!eventSelected(collision, filteredTracks.size())) + return; + + if (centrality > cfgCentMax || centrality < cfgCentMin) + return; + + registry.fill(HIST("hEventCount"), evSel_CentCuts); + + if (!collision.has_mcCollision()) { + LOGF(info, "No mccollision found for this collision"); + return; + } + + fillEventQA(collision, tracks); + + registry.fill(HIST("trackMCReco/hTrackSize_unFiltered"), tracks.size()); + registry.fill(HIST("trackMCReco/hTrackSize_Filtered"), filteredTracks.size()); + + for (const auto& track : filteredTracks) { + auto mcParticle = track.mcParticle(); + if (track.sign() == 0.0) + continue; + registry.fill(HIST("hTrackCount"), trackSel_ZeroCharge); + + fillMCPtHistos(track, mcParticle.pdgCode()); + + fillTrackQA(track, vtxz); + + if (!trackSelected(track, field)) + continue; - registry.fill(HIST("incl/vnA_pt_EP"), track.pt(), vnA); - registry.fill(HIST("incl/vnC_pt_EP"), track.pt(), vnC); - registry.fill(HIST("incl/vnFull_pt_EP"), track.pt(), vnFull); + fillMCPtHistos(track, mcParticle.pdgCode()); - registry.fill(HIST("incl/vnA_cent_EP"), centrality, vnA); - registry.fill(HIST("incl/vnC_cent_EP"), centrality, vnC); - registry.fill(HIST("incl/vnFull_cent_EP"), centrality, vnFull); + fillTrackQA(track, vtxz); + + } // end of track loop + } + PROCESS_SWITCH(FlowSP, processMCReco, "Process analysis for MC reconstructed events", false); + + void processMCGen(aod::McCollisions const& mcCollisions, CCs const& collisions, TCs const& tracks, FilteredTCs const& filteredTracks, MCs const& McParts) + { + + for (const auto& mcCollision : mcCollisions) { + float centrality = -1; + bool colSelected = true; + + // get McParticles which belong to mccollision + auto partSlice = McParts.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + + // get reconstructed collision which belongs to mccollision + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + registry.fill(HIST("trackMCGen/nCollReconstructedPerMcCollision"), colSlice.size()); + if (colSlice.size() != 1) { // check if MC collision is only reconstructed once! (https://indico.cern.ch/event/1425820/contributions/6170879/attachments/2947721/5180548/DDChinellato-O2AT4-HandsOn-03a.pdf) + continue; + } + + for (const auto& col : colSlice) { + // get tracks that belong to reconstructed collision + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + + auto filteredTrackSlice = filteredTracks.sliceBy(trackPerCollision, col.globalIndex()); + + centrality = col.centFT0C(); + if (cfgCentFT0Cvariant1) + centrality = col.centFT0CVariant1(); + if (cfgCentFT0M) + centrality = col.centFT0M(); + if (cfgCentFV0A) + centrality = col.centFV0A(); + if (cfgCentNGlobal) + centrality = col.centNGlobal(); + + fillEventQA(col, trackSlice); + + if (trackSlice.size() < 1) { + colSelected = false; + continue; + } + if (!eventSelected(col, filteredTrackSlice.size())) { + colSelected = false; + continue; + } + + if (centrality > cfgCentMax || centrality < cfgCentMin) { + colSelected = false; + continue; + } + registry.fill(HIST("hEventCount"), evSel_CentCuts); + + fillEventQA(col, trackSlice); + + } // leave reconstructed collision loop + + if (!colSelected) + continue; + + float vtxz = mcCollision.posZ(); + + for (const auto& particle : partSlice) { + if (!particle.isPhysicalPrimary()) + continue; + + int charge = 0; + + auto pdgCode = particle.pdgCode(); + auto pdgInfo = pdg->GetParticle(pdgCode); + if (pdgInfo != nullptr) { + charge = pdgInfo->Charge(); + } + + if (std::fabs(charge) < 1) + continue; + + bool pos = (charge > 0) ? true : false; + + fillMCPtHistos(particle, pdgCode); + + registry.fill(HIST("trackMCGen/before/incl/phi_eta_vtxZ_gen"), particle.phi(), particle.eta(), vtxz); if (pos) { - registry.fill(HIST("pos/vnAx_eta"), track.eta(), (ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnAy_eta"), track.eta(), (uy * qyA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnCx_eta"), track.eta(), (ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnCy_eta"), track.eta(), (uy * qyC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnA_eta"), track.eta(), (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnC_eta"), track.eta(), (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ))); - - registry.fill(HIST("pos/vnAx_pt"), track.pt(), (ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnAy_pt"), track.pt(), (uy * qyA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnCx_pt"), track.pt(), (ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnCy_pt"), track.pt(), (uy * qyC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnA_pt"), track.pt(), (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnC_pt"), track.pt(), (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ))); - - registry.fill(HIST("pos/vnAx_cent"), centrality, (ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnAy_cent"), centrality, (uy * qyA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnCx_cent"), centrality, (ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnCy_cent"), centrality, (uy * qyC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnA_cent"), centrality, (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("pos/vnC_cent"), centrality, (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ))); - - registry.fill(HIST("pos/vnA_eta_EP"), track.eta(), vnA); - registry.fill(HIST("pos/vnC_eta_EP"), track.eta(), vnC); - registry.fill(HIST("pos/vnFull_eta_EP"), track.eta(), vnFull); - - registry.fill(HIST("pos/vnA_pt_EP"), track.pt(), vnA); - registry.fill(HIST("pos/vnC_pt_EP"), track.pt(), vnC); - registry.fill(HIST("pos/vnFull_pt_EP"), track.pt(), vnFull); - - registry.fill(HIST("pos/vnA_cent_EP"), centrality, vnA); - registry.fill(HIST("pos/vnC_cent_EP"), centrality, vnC); - registry.fill(HIST("pos/vnFull_cent_EP"), centrality, vnFull); + registry.fill(HIST("trackMCGen/before/pos/phi_eta_vtxZ_gen"), particle.phi(), particle.eta(), vtxz); + } else { + registry.fill(HIST("trackMCGen/before/neg/phi_eta_vtxZ_gen"), particle.phi(), particle.eta(), vtxz); + } + + if (particle.eta() < -cfgTrackSelsEta || particle.eta() > cfgTrackSelsEta || particle.pt() < cfgTrackSelsPtmin || particle.pt() > cfgTrackSelsPtmax) + continue; + + fillMCPtHistos(particle, pdgCode); + + registry.fill(HIST("trackMCGen/after/incl/phi_eta_vtxZ_gen"), particle.phi(), particle.eta(), vtxz); + if (pos) { + registry.fill(HIST("trackMCGen/after/pos/phi_eta_vtxZ_gen"), particle.phi(), particle.eta(), vtxz); } else { - registry.fill(HIST("neg/vnAx_eta"), track.eta(), (ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnAy_eta"), track.eta(), (uy * qyA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnCx_eta"), track.eta(), (ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnCy_eta"), track.eta(), (uy * qyC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnA_eta"), track.eta(), (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnC_eta"), track.eta(), (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ))); - - registry.fill(HIST("neg/vnAx_pt"), track.pt(), (ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnAy_pt"), track.pt(), (uy * qyA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnCx_pt"), track.pt(), (ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnCy_pt"), track.pt(), (uy * qyC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnA_pt"), track.pt(), (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnC_pt"), track.pt(), (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnAx_cent"), centrality, (ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnAy_cent"), centrality, (uy * qyA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnCx_cent"), centrality, (ux * qxC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnCy_cent"), centrality, (uy * qyC) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnA_cent"), centrality, (uy * qyA + ux * qxA) / std::sqrt(std::fabs(corrQQ))); - registry.fill(HIST("neg/vnC_cent"), centrality, (uy * qyC + ux * qxC) / std::sqrt(std::fabs(corrQQ))); - - registry.fill(HIST("neg/vnA_eta_EP"), track.eta(), vnA); - registry.fill(HIST("neg/vnC_eta_EP"), track.eta(), vnC); - registry.fill(HIST("neg/vnFull_eta_EP"), track.eta(), vnFull); - - registry.fill(HIST("neg/vnA_pt_EP"), track.pt(), vnA); - registry.fill(HIST("neg/vnC_pt_EP"), track.pt(), vnC); - registry.fill(HIST("neg/vnFull_pt_EP"), track.pt(), vnFull); - - registry.fill(HIST("neg/vnA_cent_EP"), centrality, vnA); - registry.fill(HIST("neg/vnC_cent_EP"), centrality, vnC); - registry.fill(HIST("neg/vnFull_cent_EP"), centrality, vnFull); + registry.fill(HIST("trackMCGen/after/neg/phi_eta_vtxZ_gen"), particle.phi(), particle.eta(), vtxz); } - // QA plots - registry.fill(HIST("QA/after/hPhi_Eta_vz"), track.phi(), track.eta(), collision.posZ()); - registry.fill(HIST("QA/after/hDCAxy"), track.dcaXY()); - registry.fill(HIST("QA/after/hDCAz"), track.dcaZ()); } } } + PROCESS_SWITCH(FlowSP, processMCGen, "Process analysis for MC generated events", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), - }; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGCF/Flow/Tasks/flowTask.cxx b/PWGCF/Flow/Tasks/flowTask.cxx index 87d43fcd3dc..9f27ffa0005 100644 --- a/PWGCF/Flow/Tasks/flowTask.cxx +++ b/PWGCF/Flow/Tasks/flowTask.cxx @@ -14,36 +14,40 @@ /// \since Dec/10/2023 /// \brief jira: PWGCF-254, task to measure flow observables with cumulant method -#include -#include -#include -#include -#include -#include -#include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/HistogramRegistry.h" +#include "FlowContainer.h" +#include "FlowPtContainer.h" +#include "GFW.h" +#include "GFWConfig.h" +#include "GFWCumulant.h" +#include "GFWPowerArray.h" +#include "GFWWeights.h" -#include "Common/DataModel/EventSelection.h" +#include "Common/CCDB/ctpRateFetcher.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include -#include "GFWPowerArray.h" -#include "GFW.h" -#include "GFWCumulant.h" -#include "GFWWeights.h" -#include "FlowContainer.h" #include "TList.h" +#include +#include #include #include -#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -53,9 +57,11 @@ using namespace o2::framework::expressions; struct FlowTask { + // Basic event&track selections O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") - O2_DEFINE_CONFIGURABLE(cfgCentMin, float, 0.0f, "Minimum centrality") - O2_DEFINE_CONFIGURABLE(cfgCentMax, float, 100.0f, "Maximum centrality") + O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FT0A") + O2_DEFINE_CONFIGURABLE(cfgCentFT0CMin, float, 0.0f, "Minimum centrality (FT0C) to cut events in filter") + O2_DEFINE_CONFIGURABLE(cfgCentFT0CMax, float, 100.0f, "Maximum centrality (FT0C) to cut events in filter") O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") O2_DEFINE_CONFIGURABLE(cfgCutPtRefMin, float, 0.2f, "Minimal pT for ref tracks") @@ -63,94 +69,135 @@ struct FlowTask { O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for all tracks") O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 10.0f, "Maximal pT for all tracks") O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgEtaPtPt, float, 0.4, "eta cut for pt-pt correlations"); O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5f, "max chi2 per TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 70.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 50.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCCrossedRows, float, 70.0f, "minimum TPC crossed rows") + O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters") O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "max DCA to vertex z") - O2_DEFINE_CONFIGURABLE(cfgCutDCAxyppPass3Enabled, bool, false, "switch of ppPass3 DCAxy pt dependent cut") - O2_DEFINE_CONFIGURABLE(cfgCutDCAzPtDepEnabled, bool, false, "switch of DCAz pt dependent cut") - O2_DEFINE_CONFIGURABLE(cfgTrkSelSwitch, bool, false, "switch for self-defined track selection") - O2_DEFINE_CONFIGURABLE(cfgTrkSelRun3ITSMatch, bool, false, "GlobalTrackRun3ITSMatching::Run3ITSall7Layers selection") - O2_DEFINE_CONFIGURABLE(cfgShowTPCsectorOverlap, bool, true, "Draw TPC sector overlap") - O2_DEFINE_CONFIGURABLE(cfgRejectionTPCsectorOverlap, bool, false, "rejection for TPC sector overlap") + // Additional events selection flags O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") - O2_DEFINE_CONFIGURABLE(cfgTriggerkTVXinTRD, bool, true, "TRD triggered") - O2_DEFINE_CONFIGURABLE(cfgEvSelkNoSameBunchPileup, bool, true, "rejects collisions which are associated with the same found-by-T0 bunch crossing") - O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodZvtxFT0vsPV, bool, true, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference, use this cut at low multiplicities with caution") - O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInTimeRangeStandard, bool, true, "no collisions in specified time range") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoSameBunchPileup, bool, false, "rejects collisions which are associated with the same found-by-T0 bunch crossing") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoITSROFrameBorder, bool, false, "reject events at ITS ROF border") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoTimeFrameBorder, bool, false, "reject events at TF border") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodZvtxFT0vsPV, bool, false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference, use this cut at low multiplicities with caution") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInTimeRangeStandard, bool, false, "no collisions in specified time range") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodITSLayersAll, bool, true, "cut time intervals with dead ITS staves") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInRofStandard, bool, false, "no other collisions in this Readout Frame with per-collision multiplicity above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoHighMultCollInPrevRof, bool, false, "veto an event if FT0C amplitude in previous ITS ROF is above threshold") O2_DEFINE_CONFIGURABLE(cfgEvSelMultCorrelation, bool, true, "Multiplicity correlation cut") O2_DEFINE_CONFIGURABLE(cfgEvSelV0AT0ACut, bool, true, "V0A T0A 5 sigma cut") O2_DEFINE_CONFIGURABLE(cfgGetInteractionRate, bool, false, "Get interaction rate from CCDB") O2_DEFINE_CONFIGURABLE(cfgUseInteractionRateCut, bool, false, "Use events with low interaction rate") - O2_DEFINE_CONFIGURABLE(cfgCutIR, float, 50.0, "maximum interaction rate (kHz)") + O2_DEFINE_CONFIGURABLE(cfgCutMaxIR, float, 50.0f, "maximum interaction rate (kHz)") + O2_DEFINE_CONFIGURABLE(cfgCutMinIR, float, 0.0f, "minimum interaction rate (kHz)") + O2_DEFINE_CONFIGURABLE(cfgEvSelOccupancy, bool, true, "Occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") + // User configuration for ananlysis O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables") - O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 30, "Number of subsamples") O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights") O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeightsRefPt, bool, false, "NUA weights are filled in ref pt bins") - O2_DEFINE_CONFIGURABLE(cfgOutputGroupNUAWeights, bool, false, "Fill and output group NUA weights") O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") - O2_DEFINE_CONFIGURABLE(cfgAcceptanceGroup, std::string, "", "CCDB path to group acceptance object") - O2_DEFINE_CONFIGURABLE(cfgAcceptanceGroupUse, bool, false, "Apply group acceptance, this option overrides cfgAcceptance") - O2_DEFINE_CONFIGURABLE(cfgMagnetField, std::string, "GLO/Config/GRPMagField", "CCDB path to Magnet field object") - O2_DEFINE_CONFIGURABLE(cfgEvSelOccupancy, bool, true, "Occupancy cut") - O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") - O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") O2_DEFINE_CONFIGURABLE(cfgUseSmallMemory, bool, false, "Use small memory mode") + O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrUse, bool, false, "Use track density efficiency correction") + O2_DEFINE_CONFIGURABLE(cfgUseCentralMoments, bool, true, "Use central moments in vn-pt calculations") + O2_DEFINE_CONFIGURABLE(cfgUsePtRef, bool, true, "Use refernce pt range for pt container (if you are checking the spectra, you need to extent it)") + O2_DEFINE_CONFIGURABLE(cfgMpar, int, 4, "Highest order of pt-pt correlations") Configurable> cfgUserDefineGFWCorr{"cfgUserDefineGFWCorr", std::vector{"refN02 {2} refP02 {-2}", "refN12 {2} refP12 {-2}"}, "User defined GFW CorrelatorConfig"}; Configurable> cfgUserDefineGFWName{"cfgUserDefineGFWName", std::vector{"Ch02Gap22", "Ch12Gap22"}, "User defined GFW Name"}; + Configurable cfgUserPtVnCorrConfig{"cfgUserPtVnCorrConfig", {{"refP {2} refN {-2}", "refP {3} refN {-3}"}, {"ChGap22", "ChGap32"}, {0, 0}, {3, 3}}, "Configurations for vn-pt correlations"}; Configurable> cfgRunRemoveList{"cfgRunRemoveList", std::vector{-1}, "excluded run numbers"}; - Configurable> cfgGroupSplitRunNumber{"cfgGroupSplitRunNumber", std::vector{544510, 544653}, "runnumbers for group splitting (suppose run numbers are increasing monotonically) "}; + struct : ConfigurableGroup { + Configurable> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector{0.7217476707, 0.7384792571, 0.7542625668, 0.7640680200, 0.7701951667, 0.7755299053, 0.7805901710, 0.7849446786, 0.7957356586, 0.8113039262, 0.8211968966, 0.8280558878, 0.8329342135}, "parameter 0 for track density efficiency correction"}; + Configurable> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector{-2.169488e-05, -2.191913e-05, -2.295484e-05, -2.556538e-05, -2.754463e-05, -2.816832e-05, -2.846502e-05, -2.843857e-05, -2.705974e-05, -2.477018e-05, -2.321730e-05, -2.203315e-05, -2.109474e-05}, "parameter 1 for track density efficiency correction"}; + O2_DEFINE_CONFIGURABLE(cfgMultCentHighCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + 10.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultCentLowCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x - 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultT0CCutEnabled, bool, false, "Enable Global multiplicity vs T0C centrality cut") + Configurable> cfgMultT0CCutPars{"cfgMultT0CCutPars", std::vector{143.04, -4.58368, 0.0766055, -0.000727796, 2.86153e-06, 23.3108, -0.36304, 0.00437706, -4.717e-05, 1.98332e-07}, "Global multiplicity vs T0C centrality cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultPVT0CCutEnabled, bool, false, "Enable PV multiplicity vs T0C centrality cut") + Configurable> cfgMultPVT0CCutPars{"cfgMultPVT0CCutPars", std::vector{195.357, -6.15194, 0.101313, -0.000955828, 3.74793e-06, 30.0326, -0.43322, 0.00476265, -5.11206e-05, 2.13613e-07}, "PV multiplicity vs T0C centrality cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultMultPVHighCutFunction, std::string, "[0]+[1]*x + 5.*([2]+[3]*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultMultPVLowCutFunction, std::string, "[0]+[1]*x - 5.*([2]+[3]*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultGlobalPVCutEnabled, bool, false, "Enable global multiplicity vs PV multiplicity cut") + Configurable> cfgMultGlobalPVCutPars{"cfgMultGlobalPVCutPars", std::vector{-0.140809, 0.734344, 2.77495, 0.0165935}, "PV multiplicity vs T0C centrality cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultMultV0AHighCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + 4.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultMultV0ALowCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x - 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultMultV0ACutEnabled, bool, false, "Enable global multiplicity vs V0A multiplicity cut") + Configurable> cfgMultMultV0ACutPars{"cfgMultMultV0ACutPars", std::vector{534.893, 184.344, 0.423539, -0.00331436, 5.34622e-06, 871.239, 53.3735, -0.203528, 0.000122758, 5.41027e-07}, "Global multiplicity vs V0A multiplicity cut parameter values"}; + std::vector multT0CCutPars; + std::vector multPVT0CCutPars; + std::vector multGlobalPVCutPars; + std::vector multMultV0ACutPars; + TF1* fMultPVT0CCutLow = nullptr; + TF1* fMultPVT0CCutHigh = nullptr; + TF1* fMultT0CCutLow = nullptr; + TF1* fMultT0CCutHigh = nullptr; + TF1* fMultGlobalPVCutLow = nullptr; + TF1* fMultGlobalPVCutHigh = nullptr; + TF1* fMultMultV0ACutLow = nullptr; + TF1* fMultMultV0ACutHigh = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + } cfgFuncParas; - ConfigurableAxis axisVertex{"axisVertex", {40, -20, 20}, "vertex axis for histograms"}; - ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; - ConfigurableAxis axisPhiMod{"axisPhiMod", {100, 0, constants::math::PI / 9}, "fmod(#varphi,#pi/9)"}; - ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; ConfigurableAxis axisPtHist{"axisPtHist", {100, 0., 10.}, "pt axis for histograms"}; ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}, "pt axis for histograms"}; ConfigurableAxis axisIndependent{"axisIndependent", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "X axis for histograms"}; - ConfigurableAxis axisCentForQA{"axisCentForQA", {100, 0, 100}, "centrality for QA"}; ConfigurableAxis axisNch{"axisNch", {4000, 0, 4000}, "N_{ch}"}; - ConfigurableAxis axisT0C{"axisT0C", {70, 0, 70000}, "N_{ch} (T0C)"}; - ConfigurableAxis axisT0A{"axisT0A", {200, 0, 200000}, "N_{ch} (T0A)"}; - ConfigurableAxis axisNchPV{"axisNchPV", {4000, 0, 4000}, "N_{ch} (PV)"}; ConfigurableAxis axisDCAz{"axisDCAz", {200, -2, 2}, "DCA_{z} (cm)"}; ConfigurableAxis axisDCAxy{"axisDCAxy", {200, -1, 1}, "DCA_{xy} (cm)"}; - Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVertex) && (aod::cent::centFT0C > cfgCentMin) && (aod::cent::centFT0C < cfgCentMax); + Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVertex) && (aod::cent::centFT0C > cfgCentFT0CMin) && (aod::cent::centFT0C < cfgCentFT0CMax); Filter trackFilter = ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + using FilteredCollisions = soa::Filtered>; + using FilteredTracks = soa::Filtered>; + // Filter for MCcollisions + Filter mccollisionFilter = nabs(aod::mccollision::posZ) < cfgCutVertex; + using FilteredMcCollisions = soa::Filtered; + // Filter for MCParticle + Filter particleFilter = (nabs(aod::mcparticle::eta) < cfgCutEta) && (aod::mcparticle::pt > cfgCutPtMin) && (aod::mcparticle::pt < cfgCutPtMax); + using FilteredMcParticles = soa::Filtered; + + using FilteredSmallGroupMcCollisions = soa::SmallGroups>; // Corrections TH1D* mEfficiency = nullptr; GFWWeights* mAcceptance = nullptr; - TList* mGroupAcceptanceList = nullptr; bool correctionsLoaded = false; // Connect to ccdb Service ccdb; - Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; // Define output OutputObj fFC{FlowContainer("FlowContainer")}; + OutputObj fFCgen{FlowContainer("FlowContainer_gen")}; + OutputObj fFCpt{FlowPtContainer("FlowPtContainer")}; + OutputObj fFCptgen{FlowPtContainer("FlowPtContainer_gen")}; OutputObj fWeights{GFWWeights("weights")}; HistogramRegistry registry{"registry"}; - OutputObj fGroupNUAList{"GroupNUAList", OutputObjHandlingPolicy::AnalysisObject, OutputObjSourceType::OutputObjSource}; // define global variables GFW* fGFW = new GFW(); std::vector corrconfigs; + GFWCorrConfigs gfwConfigs; + std::vector corrconfigsPtVn; TAxis* fPtAxis; TRandom3* fRndm = new TRandom3(0); - std::vector>> bootstrapArray; - enum ExtraProfile { - // here are TProfiles for vn-pt correlations that are not implemented in GFW - kMeanPt_InGap08 = 0, - kC22_Gap08_Weff, - kC22_Gap08_MeanPt, - kPtVarParA_InGap08, - kPtVarParB_InGap08, + enum CentEstimators { + kCentFT0C = 0, + kCentFT0CVariant1, + kCentFT0M, + kCentFV0A, // Count the total number of enum - kCount_ExtraProfile + kCount_CentEstimators + }; + enum DataType { + kReco, + kGen }; int mRunNumber{-1}; uint64_t mSOR{0}; @@ -158,29 +205,27 @@ struct FlowTask { std::unordered_map gHadronicRate; ctpRateFetcher mRateFetcher; TH2* gCurrentHadronicRate; - std::vector> groupNUAWeightPtr; - - using AodCollisions = soa::Filtered>; - using AodTracks = soa::Filtered>; - - // Track selection - TrackSelection myTrackSel; - TF1* fPhiCutLow = nullptr; - TF1* fPhiCutHigh = nullptr; - // Additional Event selection cuts - Copy from flowGenericFramework.cxx - TF1* fMultPVCutLow = nullptr; - TF1* fMultPVCutHigh = nullptr; - TF1* fMultCutLow = nullptr; - TF1* fMultCutHigh = nullptr; - TF1* fMultMultPVCut = nullptr; - TF1* fT0AV0AMean = nullptr; - TF1* fT0AV0ASigma = nullptr; + + // phi-EP correction + std::vector funcEff; + TH1D* hFindPtBin; + TF1* funcV2; + TF1* funcV3; + TF1* funcV4; void init(InitContext const&) { + const AxisSpec axisVertex{40, -20, 20, "Vtxz (cm)"}; + const AxisSpec axisPhi{60, 0.0, constants::math::TwoPI, "#varphi"}; + const AxisSpec axisEta{40, -1., 1., "#eta"}; + const AxisSpec axisCentForQA{100, 0, 100, "centrality (%)"}; + const AxisSpec axisT0C{70, 0, 70000, "N_{ch} (T0C)"}; + const AxisSpec axisT0A{200, 0, 200000, "N_{ch} (T0A)"}; + ccdb->setURL(ccdbUrl.value); ccdb->setCaching(true); - ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + auto now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); // Add some output objects to the histogram registry // Event QA @@ -190,24 +235,47 @@ struct FlowTask { registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(3, "after supicious Runs removal"); registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(4, "after additional event cut"); registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(5, "after correction loads"); + registry.add("hEventCountSpecific", "Number of Event;; Count", {HistType::kTH1D, {{12, 0, 12}}}); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(1, "after sel8"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(2, "kNoSameBunchPileup"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(3, "kNoITSROFrameBorder"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(4, "kNoTimeFrameBorder"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(5, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(6, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(7, "kIsGoodITSLayersAll"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(8, "kNoCollInRofStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(9, "kNoHighMultCollInPrevRof"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(10, "occupancy"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(11, "MultCorrelation"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(12, "cfgEvSelV0AT0ACut"); registry.add("hVtxZ", "Vexter Z distribution", {HistType::kTH1D, {axisVertex}}); registry.add("hMult", "Multiplicity distribution", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); - registry.add("hCent", "Centrality distribution", {HistType::kTH1D, {{90, 0, 90}}}); + std::string hCentTitle = "Centrality distribution, Estimator " + std::to_string(cfgCentEstimator); + registry.add("hCent", hCentTitle.c_str(), {HistType::kTH1D, {{100, 0, 100}}}); + if (doprocessMCGen) { + registry.add("MCGen/MChVtxZ", "Vexter Z distribution", {HistType::kTH1D, {axisVertex}}); + registry.add("MCGen/MChMult", "Multiplicity distribution", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); + registry.add("MCGen/MChCent", hCentTitle.c_str(), {HistType::kTH1D, {{100, 0, 100}}}); + } if (!cfgUseSmallMemory) { + registry.add("BeforeSel8_globalTracks_centT0C", "before sel8;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); registry.add("BeforeCut_globalTracks_centT0C", "before cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); - registry.add("BeforeCut_PVTracks_centT0C", "before cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNchPV}}); - registry.add("BeforeCut_globalTracks_PVTracks", "before cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNchPV, axisNch}}); + registry.add("BeforeCut_PVTracks_centT0C", "before cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("BeforeCut_globalTracks_PVTracks", "before cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNch, axisNch}}); registry.add("BeforeCut_globalTracks_multT0A", "before cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); registry.add("BeforeCut_globalTracks_multV0A", "before cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); registry.add("BeforeCut_multV0A_multT0A", "before cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); registry.add("BeforeCut_multT0C_centT0C", "before cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); registry.add("globalTracks_centT0C", "after cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); - registry.add("PVTracks_centT0C", "after cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNchPV}}); - registry.add("globalTracks_PVTracks", "after cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNchPV, axisNch}}); + registry.add("PVTracks_centT0C", "after cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("globalTracks_PVTracks", "after cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNch, axisNch}}); registry.add("globalTracks_multT0A", "after cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); registry.add("globalTracks_multV0A", "after cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); registry.add("multV0A_multT0A", "after cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); registry.add("multT0C_centT0C", "after cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); + registry.add("centFT0CVar_centFT0C", "after cut;Centrality T0C;Centrality T0C Var", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); + registry.add("centFT0M_centFT0C", "after cut;Centrality T0C;Centrality T0M", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); + registry.add("centFV0A_centFT0C", "after cut;Centrality T0C;Centrality V0A", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); } // Track QA registry.add("hPhi", "#phi distribution", {HistType::kTH1D, {axisPhi}}); @@ -215,36 +283,18 @@ struct FlowTask { registry.add("hEta", "#eta distribution", {HistType::kTH1D, {axisEta}}); registry.add("hPt", "p_{T} distribution before cut", {HistType::kTH1D, {axisPtHist}}); registry.add("hPtRef", "p_{T} distribution after cut", {HistType::kTH1D, {axisPtHist}}); - registry.add("pt_phi_bef", "before cut;p_{T};#phi_{modn}", {HistType::kTH2D, {axisPt, axisPhiMod}}); - registry.add("pt_phi_aft", "after cut;p_{T};#phi_{modn}", {HistType::kTH2D, {axisPt, axisPhiMod}}); registry.add("hChi2prTPCcls", "#chi^{2}/cluster for the TPC track segment", {HistType::kTH1D, {{100, 0., 5.}}}); registry.add("hChi2prITScls", "#chi^{2}/cluster for the ITS track", {HistType::kTH1D, {{100, 0., 50.}}}); registry.add("hnTPCClu", "Number of found TPC clusters", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("hnITSClu", "Number of found ITS clusters", {HistType::kTH1D, {{100, 0, 20}}}); registry.add("hnTPCCrossedRow", "Number of crossed TPC Rows", {HistType::kTH1D, {{100, 40, 180}}}); - registry.add("hDCAz", "DCAz after cuts", {HistType::kTH1D, {{100, -3, 3}}}); - registry.add("hDCAxy", "DCAxy after cuts; DCAxy (cm); Pt", {HistType::kTH2D, {{50, -1, 1}, {50, 0, 10}}}); + registry.add("hDCAz", "DCAz after cuts; DCAz (cm); Pt", {HistType::kTH2D, {{200, -0.5, 0.5}, {200, 0, 5}}}); + registry.add("hDCAxy", "DCAxy after cuts; DCAxy (cm); Pt", {HistType::kTH2D, {{200, -0.5, 0.5}, {200, 0, 5}}}); registry.add("hTrackCorrection2d", "Correlation table for number of tracks table; uncorrected track; corrected track", {HistType::kTH2D, {axisNch, axisNch}}); - if (!cfgUseSmallMemory) { - // additional Output histograms - registry.add("hMeanPt", "", {HistType::kTProfile, {axisIndependent}}); - registry.add("hMeanPtWithinGap08", "", {HistType::kTProfile, {axisIndependent}}); - registry.add("c22_gap08_Weff", "", {HistType::kTProfile, {axisIndependent}}); - registry.add("c22_gap08_trackMeanPt", "", {HistType::kTProfile, {axisIndependent}}); - registry.add("PtVariance_partA_WithinGap08", "", {HistType::kTProfile, {axisIndependent}}); - registry.add("PtVariance_partB_WithinGap08", "", {HistType::kTProfile, {axisIndependent}}); - - // initial array - bootstrapArray.resize(cfgNbootstrap); - for (int i = 0; i < cfgNbootstrap; i++) { - bootstrapArray[i].resize(kCount_ExtraProfile); - } - for (int i = 0; i < cfgNbootstrap; i++) { - bootstrapArray[i][kMeanPt_InGap08] = registry.add(Form("BootstrapContainer_%d/hMeanPtWithinGap08", i), "", {HistType::kTProfile, {axisIndependent}}); - bootstrapArray[i][kC22_Gap08_Weff] = registry.add(Form("BootstrapContainer_%d/c22_gap08_Weff", i), "", {HistType::kTProfile, {axisIndependent}}); - bootstrapArray[i][kC22_Gap08_MeanPt] = registry.add(Form("BootstrapContainer_%d/c22_gap08_trackMeanPt", i), "", {HistType::kTProfile, {axisIndependent}}); - bootstrapArray[i][kPtVarParA_InGap08] = registry.add(Form("BootstrapContainer_%d/PtVariance_partA_WithinGap08", i), "", {HistType::kTProfile, {axisIndependent}}); - bootstrapArray[i][kPtVarParB_InGap08] = registry.add(Form("BootstrapContainer_%d/PtVariance_partB_WithinGap08", i), "", {HistType::kTProfile, {axisIndependent}}); - } + if (doprocessMCGen) { + registry.add("MCGen/MChPhi", "#phi distribution", {HistType::kTH1D, {axisPhi}}); + registry.add("MCGen/MChEta", "#eta distribution", {HistType::kTH1D, {axisEta}}); + registry.add("MCGen/MChPtRef", "p_{T} distribution after cut", {HistType::kTH1D, {axisPtHist}}); } o2::framework::AxisSpec axis = axisPt; @@ -253,29 +303,8 @@ struct FlowTask { fPtAxis = new TAxis(nPtBins, ptBins); if (cfgOutputNUAWeights) { - fWeights->SetPtBins(nPtBins, ptBins); - fWeights->Init(true, false); - } - - TList* groupNUAWeightlist = new TList(); - groupNUAWeightlist->SetOwner(true); - fGroupNUAList.setObject(groupNUAWeightlist); - - if (cfgOutputGroupNUAWeights) { - groupNUAWeightPtr.resize(cfgGroupSplitRunNumber.value.size() + 1); - for (uint i = 0; i < cfgGroupSplitRunNumber.value.size() + 1; i++) { - GFWWeights* groupweight = nullptr; - if (i < cfgGroupSplitRunNumber.value.size()) - groupweight = new GFWWeights(Form("groupweight_%d", cfgGroupSplitRunNumber.value[i])); - else - groupweight = new GFWWeights(Form("groupweight_last")); - - groupweight->SetPtBins(nPtBins, ptBins); - groupweight->Init(true, false); - groupNUAWeightlist->Add(groupweight); - std::shared_ptr sharePtrGroupWeight(groupweight); - groupNUAWeightPtr[i] = sharePtrGroupWeight; - } + fWeights->setPtBins(nPtBins, ptBins); + fWeights->init(true, false); } // add in FlowContainer to Get boostrap sample automatically @@ -290,6 +319,8 @@ struct FlowTask { oba->Add(new TNamed(Form("ChFull22_pt_%i", i + 1), "ChFull22_pTDiff")); for (auto i = 0; i < fPtAxis->GetNbins(); i++) oba->Add(new TNamed(Form("ChFull24_pt_%i", i + 1), "ChFull24_pTDiff")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull26_pt_%i", i + 1), "ChFull26_pTDiff")); oba->Add(new TNamed("Ch04Gap22", "Ch04Gap22")); oba->Add(new TNamed("Ch06Gap22", "Ch06Gap22")); oba->Add(new TNamed("Ch08Gap22", "Ch08Gap22")); @@ -324,6 +355,8 @@ struct FlowTask { oba->Add(new TNamed("Ch10Gap3232", "Ch10Gap3232")); oba->Add(new TNamed("Ch10Gap4242", "Ch10Gap4242")); oba->Add(new TNamed("Ch10Gap24", "Ch10Gap24")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap24_pt_%i", i + 1), "Ch10Gap24_pTDiff")); std::vector userDefineGFWCorr = cfgUserDefineGFWCorr; std::vector userDefineGFWName = cfgUserDefineGFWName; if (!userDefineGFWCorr.empty() && !userDefineGFWName.empty()) { @@ -334,6 +367,11 @@ struct FlowTask { fFC->SetName("FlowContainer"); fFC->SetXAxis(fPtAxis); fFC->Initialize(oba, axisIndependent, cfgNbootstrap); + if (doprocessMCGen) { + fFCgen->SetName("FlowContainer_gen"); + fFCgen->SetXAxis(fPtAxis); + fFCgen->Initialize(oba, axisIndependent, cfgNbootstrap); + } delete oba; // eta region @@ -360,9 +398,9 @@ struct FlowTask { fGFW->AddRegion("poiN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 2); fGFW->AddRegion("poiN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 2); fGFW->AddRegion("poifull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 2); - fGFW->AddRegion("olN", -0.8, -0.4, 1, 4); - fGFW->AddRegion("olN10", -0.8, -0.5, 1, 4); - fGFW->AddRegion("olfull", -0.8, 0.8, 1, 4); + fGFW->AddRegion("olN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 4); + fGFW->AddRegion("olN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 4); + fGFW->AddRegion("olfull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 4); corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {3 -3}", "ChFull32", kFALSE)); @@ -387,6 +425,7 @@ struct FlowTask { corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN {2} refP {-2}", "ChGap22", kFALSE)); corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifull full | olfull {2 -2}", "ChFull22", kTRUE)); corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifull full | olfull {2 2 -2 -2}", "ChFull24", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifull full | olfull {2 2 2 -2 -2 -2}", "ChFull26", kTRUE)); corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {2} refP10 {-2}", "Ch10Gap22", kTRUE)); corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {3} refP10 {-3}", "Ch10Gap32", kTRUE)); corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {4} refP10 {-4}", "Ch10Gap42", kTRUE)); @@ -403,6 +442,7 @@ struct FlowTask { corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {3 2} refP10 {-3 -2}", "Ch10Gap3232", kFALSE)); corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {4 2} refP10 {-4 -2}", "Ch10Gap4242", kFALSE)); corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {2 2} refP10 {-2 -2}", "Ch10Gap24", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {2 2} refP10 {-2 -2}", "Ch10Gap24", kTRUE)); if (!userDefineGFWCorr.empty() && !userDefineGFWName.empty()) { LOGF(info, "User adding GFW CorrelatorConfig:"); // attentaion: here we follow the index of cfgUserDefineGFWCorr @@ -415,38 +455,70 @@ struct FlowTask { corrconfigs.push_back(fGFW->GetCorrelatorConfig(userDefineGFWCorr.at(i).c_str(), userDefineGFWName.at(i).c_str(), kFALSE)); } } - fGFW->CreateRegions(); - - if (cfgUseAdditionalEventCut) { - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - - fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); - fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); - fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); - fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); - } - - if (cfgShowTPCsectorOverlap) { - fPhiCutLow = new TF1("fPhiCutLow", "0.06/x+pi/18.0-0.06", 0, 100); - fPhiCutHigh = new TF1("fPhiCutHigh", "0.1/x+pi/18.0+0.06", 0, 100); + gfwConfigs.SetCorrs(cfgUserPtVnCorrConfig->GetCorrs()); + gfwConfigs.SetHeads(cfgUserPtVnCorrConfig->GetHeads()); + gfwConfigs.SetpTDifs(cfgUserPtVnCorrConfig->GetpTDifs()); + // Mask 1: vn-[pT], 2: vn-[pT^2], 4: vn-[pT^3] + gfwConfigs.SetpTCorrMasks(cfgUserPtVnCorrConfig->GetpTCorrMasks()); + gfwConfigs.Print(); + fFCpt->setUseCentralMoments(cfgUseCentralMoments); + fFCpt->setUseGapMethod(true); + fFCpt->initialise(axisIndependent, cfgMpar, gfwConfigs, cfgNbootstrap); + for (auto i = 0; i < gfwConfigs.GetSize(); ++i) { + corrconfigsPtVn.push_back(fGFW->GetCorrelatorConfig(gfwConfigs.GetCorrs()[i], gfwConfigs.GetHeads()[i], gfwConfigs.GetpTDifs()[i])); } + fGFW->CreateRegions(); - if (cfgTrkSelRun3ITSMatch) { - myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default); - } else { - myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + if (cfgEvSelMultCorrelation) { + cfgFuncParas.multT0CCutPars = cfgFuncParas.cfgMultT0CCutPars; + cfgFuncParas.multPVT0CCutPars = cfgFuncParas.cfgMultPVT0CCutPars; + cfgFuncParas.multGlobalPVCutPars = cfgFuncParas.cfgMultGlobalPVCutPars; + cfgFuncParas.multMultV0ACutPars = cfgFuncParas.cfgMultMultV0ACutPars; + cfgFuncParas.fMultPVT0CCutLow = new TF1("fMultPVT0CCutLow", cfgFuncParas.cfgMultCentLowCutFunction->c_str(), 0, 100); + cfgFuncParas.fMultPVT0CCutLow->SetParameters(&(cfgFuncParas.multPVT0CCutPars[0])); + cfgFuncParas.fMultPVT0CCutHigh = new TF1("fMultPVT0CCutHigh", cfgFuncParas.cfgMultCentHighCutFunction->c_str(), 0, 100); + cfgFuncParas.fMultPVT0CCutHigh->SetParameters(&(cfgFuncParas.multPVT0CCutPars[0])); + + cfgFuncParas.fMultT0CCutLow = new TF1("fMultT0CCutLow", cfgFuncParas.cfgMultCentLowCutFunction->c_str(), 0, 100); + cfgFuncParas.fMultT0CCutLow->SetParameters(&(cfgFuncParas.multT0CCutPars[0])); + cfgFuncParas.fMultT0CCutHigh = new TF1("fMultT0CCutHigh", cfgFuncParas.cfgMultCentHighCutFunction->c_str(), 0, 100); + cfgFuncParas.fMultT0CCutHigh->SetParameters(&(cfgFuncParas.multT0CCutPars[0])); + + cfgFuncParas.fMultGlobalPVCutLow = new TF1("fMultGlobalPVCutLow", cfgFuncParas.cfgMultMultPVLowCutFunction->c_str(), 0, 4000); + cfgFuncParas.fMultGlobalPVCutLow->SetParameters(&(cfgFuncParas.multGlobalPVCutPars[0])); + cfgFuncParas.fMultGlobalPVCutHigh = new TF1("fMultGlobalPVCutHigh", cfgFuncParas.cfgMultMultPVHighCutFunction->c_str(), 0, 4000); + cfgFuncParas.fMultGlobalPVCutHigh->SetParameters(&(cfgFuncParas.multGlobalPVCutPars[0])); + + cfgFuncParas.fMultMultV0ACutLow = new TF1("fMultMultV0ACutLow", cfgFuncParas.cfgMultMultV0ALowCutFunction->c_str(), 0, 4000); + cfgFuncParas.fMultMultV0ACutLow->SetParameters(&(cfgFuncParas.multMultV0ACutPars[0])); + cfgFuncParas.fMultMultV0ACutHigh = new TF1("fMultMultV0ACutHigh", cfgFuncParas.cfgMultMultV0AHighCutFunction->c_str(), 0, 4000); + cfgFuncParas.fMultMultV0ACutHigh->SetParameters(&(cfgFuncParas.multMultV0ACutPars[0])); + + cfgFuncParas.fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + cfgFuncParas.fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + cfgFuncParas.fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + cfgFuncParas.fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } + + if (cfgTrackDensityCorrUse) { + std::vector pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0}; + hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]); + funcEff.resize(pTEffBins.size() - 1); + // LHC24g3 Eff + std::vector f1p0 = cfgFuncParas.cfgTrackDensityP0; + std::vector f1p1 = cfgFuncParas.cfgTrackDensityP1; + for (uint ifunc = 0; ifunc < pTEffBins.size() - 1; ifunc++) { + funcEff[ifunc] = new TF1(Form("funcEff%i", ifunc), "[0]+[1]*x", 0, 3000); + funcEff[ifunc]->SetParameters(f1p0[ifunc], f1p1[ifunc]); + } + funcV2 = new TF1("funcV2", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV2->SetParameters(0.0186111, 0.00351907, -4.38264e-05, 1.35383e-07, -3.96266e-10); + funcV3 = new TF1("funcV3", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV3->SetParameters(0.0174056, 0.000703329, -1.45044e-05, 1.91991e-07, -1.62137e-09); + funcV4 = new TF1("funcV4", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV4->SetParameters(0.008845, 0.000259668, -3.24435e-06, 4.54837e-08, -6.01825e-10); } - myTrackSel.SetMinNClustersTPC(cfgCutTPCclu); - if (cfgCutDCAxyppPass3Enabled) - myTrackSel.SetMaxDcaXYPtDep([](float pt) { return 0.004f + 0.013f / pt; }); // Tuned on the LHC22f anchored MC LHC23d1d on primary pions. 7 Sigmas of the resolution } template @@ -465,62 +537,57 @@ struct FlowTask { return; } - template - void fillpTvnProfile(const GFW::CorrConfig& corrconf, const double& sum_pt, const double& WeffEvent, const ConstStr& vnWeff, const ConstStr& vnpT, const double& cent) + template + void fillFC(const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) { - double meanPt = sum_pt / WeffEvent; double dnx, val; dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; if (!corrconf.pTDif) { + if (dnx == 0) + return; val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; if (std::fabs(val) < 1) { - registry.fill(vnWeff, cent, val, dnx * WeffEvent); - registry.fill(vnpT, cent, val * meanPt, dnx * WeffEvent); + (dt == kGen) ? fFCgen->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm) : fFC->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); } return; } - return; - } - - void fillpTvnProfile(const GFW::CorrConfig& corrconf, const double& sum_pt, const double& WeffEvent, std::shared_ptr vnWeff, std::shared_ptr vnpT, const double& cent) - { - double meanPt = sum_pt / WeffEvent; - double dnx, val; - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; - if (!corrconf.pTDif) { - val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + for (auto i = 1; i <= fPtAxis->GetNbins(); i++) { + dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); + if (dnx == 0) + continue; + val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; if (std::fabs(val) < 1) { - vnWeff->Fill(cent, val, dnx * WeffEvent); - vnpT->Fill(cent, val * meanPt, dnx * WeffEvent); + (dt == kGen) ? fFCgen->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm) : fFC->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); } - return; } return; } - void fillFC(const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) + template + inline void fillPtSums(TTrack track, float weff) { - double dnx, val; - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; - if (!corrconf.pTDif) { - val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; - if (std::fabs(val) < 1) - fFC->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); - return; + if (std::abs(track.eta()) < cfgEtaPtPt) { + (dt == kGen) ? fFCptgen->fill(1., track.pt()) : fFCpt->fill(weff, track.pt()); } - for (auto i = 1; i <= fPtAxis->GetNbins(); i++) { - dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); - if (dnx == 0) + } + + template + void fillPtContainers(const float& centmult, const double& rndm) + { + (dt == kGen) ? fFCptgen->calculateCorrelations() : fFCpt->calculateCorrelations(); + (dt == kGen) ? fFCptgen->fillPtProfiles(centmult, rndm) : fFCpt->fillPtProfiles(centmult, rndm); + (dt == kGen) ? fFCptgen->fillCMProfiles(centmult, rndm) : fFCpt->fillCMProfiles(centmult, rndm); + for (uint l_ind = 0; l_ind < corrconfigsPtVn.size(); ++l_ind) { + if (!corrconfigsPtVn.at(l_ind).pTDif) { + auto dnx = fGFW->Calculate(corrconfigsPtVn.at(l_ind), 0, kTRUE).real(); + if (dnx == 0) + continue; + auto val = fGFW->Calculate(corrconfigsPtVn.at(l_ind), 0, kFALSE).real() / dnx; + if (std::abs(val) < 1) { + (dt == kGen) ? fFCptgen->fillVnPtProfiles(centmult, val, dnx, rndm, gfwConfigs.GetpTCorrMasks()[l_ind]) : fFCpt->fillVnPtProfiles(centmult, val, dnx, rndm, gfwConfigs.GetpTCorrMasks()[l_ind]); + } continue; - val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; - if (std::fabs(val) < 1) - fFC->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); + } } return; } @@ -536,13 +603,6 @@ struct FlowTask { else LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); } - if (cfgAcceptanceGroup.value.empty() == false) { - mGroupAcceptanceList = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - if (mGroupAcceptanceList == nullptr) { - LOGF(fatal, "Could not load grouped acceptance weights from %s", cfgAcceptanceGroup.value.c_str()); - } - LOGF(info, "Loaded grouped acceptance weights from %s (%p)", cfgAcceptanceGroup.value.c_str(), (void*)mGroupAcceptanceList); - } if (cfgEfficiency.value.empty() == false) { mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); if (mEfficiency == nullptr) { @@ -553,7 +613,7 @@ struct FlowTask { correctionsLoaded = true; } - bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz, int groupNUAIndex = 0) + bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz) { float eff = 1.; if (mEfficiency) @@ -563,16 +623,9 @@ struct FlowTask { if (eff == 0) return false; weight_nue = 1. / eff; - if (cfgAcceptanceGroupUse) { - if (mGroupAcceptanceList && mGroupAcceptanceList->At(groupNUAIndex)) { - weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->GetNUA(phi, eta, vtxz); - } else { - weight_nua = 1; - } - return true; - } + if (mAcceptance) - weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -581,95 +634,106 @@ struct FlowTask { template bool eventSelected(TCollision collision, const int multTrk, const float centrality) { - if (cfgTriggerkTVXinTRD && collision.alias_bit(kTVXinTRD)) { - // TRD triggered - return 0; - } + registry.fill(HIST("hEventCountSpecific"), 0.5); if (cfgEvSelkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { // rejects collisions which are associated with the same "found-by-T0" bunch crossing // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof return 0; } + if (cfgEvSelkNoSameBunchPileup) + registry.fill(HIST("hEventCountSpecific"), 1.5); + if (cfgEvSelkNoITSROFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return 0; + } + if (cfgEvSelkNoITSROFrameBorder) + registry.fill(HIST("hEventCountSpecific"), 2.5); + if (cfgEvSelkNoTimeFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return 0; + } + if (cfgEvSelkNoTimeFrameBorder) + registry.fill(HIST("hEventCountSpecific"), 3.5); if (cfgEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference // use this cut at low multiplicities with caution return 0; } + if (cfgEvSelkIsGoodZvtxFT0vsPV) + registry.fill(HIST("hEventCountSpecific"), 4.5); if (cfgEvSelkNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { // no collisions in specified time range return 0; } + if (cfgEvSelkNoCollInTimeRangeStandard) + registry.fill(HIST("hEventCountSpecific"), 5.5); + if (cfgEvSelkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // from Jan 9 2025 AOT meeting + // cut time intervals with dead ITS staves + return 0; + } + if (cfgEvSelkIsGoodITSLayersAll) + registry.fill(HIST("hEventCountSpecific"), 6.5); + if (cfgEvSelkNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + // no other collisions in this Readout Frame with per-collision multiplicity above threshold + return 0; + } + if (cfgEvSelkNoCollInRofStandard) + registry.fill(HIST("hEventCountSpecific"), 7.5); + if (cfgEvSelkNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + // veto an event if FT0C amplitude in previous ITS ROF is above threshold + return 0; + } + if (cfgEvSelkNoHighMultCollInPrevRof) + registry.fill(HIST("hEventCountSpecific"), 8.5); auto multNTracksPV = collision.multNTracksPV(); auto occupancy = collision.trackOccupancyInTimeRange(); if (cfgEvSelOccupancy && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) return 0; + if (cfgEvSelOccupancy) + registry.fill(HIST("hEventCountSpecific"), 9.5); if (cfgEvSelMultCorrelation) { - if (multNTracksPV < fMultPVCutLow->Eval(centrality)) - return 0; - if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) - return 0; - if (multTrk < fMultCutLow->Eval(centrality)) - return 0; - if (multTrk > fMultCutHigh->Eval(centrality)) - return 0; + if (cfgFuncParas.cfgMultPVT0CCutEnabled) { + if (multNTracksPV < cfgFuncParas.fMultPVT0CCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > cfgFuncParas.fMultPVT0CCutHigh->Eval(centrality)) + return 0; + } + if (cfgFuncParas.cfgMultT0CCutEnabled) { + if (multTrk < cfgFuncParas.fMultT0CCutLow->Eval(centrality)) + return 0; + if (multTrk > cfgFuncParas.fMultT0CCutHigh->Eval(centrality)) + return 0; + } + if (cfgFuncParas.cfgMultGlobalPVCutEnabled) { + if (multTrk < cfgFuncParas.fMultGlobalPVCutLow->Eval(multNTracksPV)) + return 0; + if (multTrk > cfgFuncParas.fMultGlobalPVCutHigh->Eval(multNTracksPV)) + return 0; + } + if (cfgFuncParas.cfgMultMultV0ACutEnabled) { + if (collision.multFV0A() < cfgFuncParas.fMultMultV0ACutLow->Eval(multTrk)) + return 0; + if (collision.multFV0A() > cfgFuncParas.fMultMultV0ACutHigh->Eval(multTrk)) + return 0; + } } + if (cfgEvSelMultCorrelation) + registry.fill(HIST("hEventCountSpecific"), 10.5); // V0A T0A 5 sigma cut - if (cfgEvSelV0AT0ACut && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > 5 * fT0AV0ASigma->Eval(collision.multFT0A()))) + float sigma = 5.0; + if (cfgEvSelV0AT0ACut && (std::fabs(collision.multFV0A() - cfgFuncParas.fT0AV0AMean->Eval(collision.multFT0A())) > sigma * cfgFuncParas.fT0AV0ASigma->Eval(collision.multFT0A()))) return 0; + if (cfgEvSelV0AT0ACut) + registry.fill(HIST("hEventCountSpecific"), 11.5); return 1; } - int getMagneticField(uint64_t timestamp) - { - static o2::parameters::GRPMagField* grpo = nullptr; - if (grpo == nullptr) { - grpo = ccdb->getForTimeStamp(cfgMagnetField, timestamp); - if (grpo == nullptr) { - LOGF(fatal, "GRP object not found in %s for timestamp %llu", cfgMagnetField.value.c_str(), timestamp); - return 0; - } - LOGF(info, "Retrieved GRP from %s for timestamp %llu with magnetic field of %d kG", cfgMagnetField.value.c_str(), timestamp, grpo->getNominalL3Field()); - } - return grpo->getNominalL3Field(); - } - template bool trackSelected(TTrack track) { - if (cfgCutDCAzPtDepEnabled && (std::fabs(track.dcaZ()) > (0.004f + 0.013f / track.pt()))) - return false; - - if (cfgTrkSelSwitch) { - return myTrackSel.IsSelected(track); - } else { - return (track.tpcNClsFound() >= cfgCutTPCclu); - } - } - - template - bool rejectionTPCoverlap(TTrack track, const int field) - { - double phimodn = track.phi(); - if (field < 0) // for negative polarity field - phimodn = o2::constants::math::TwoPI - phimodn; - if (track.sign() < 0) // for negative charge - phimodn = o2::constants::math::TwoPI - phimodn; - if (phimodn < 0) - LOGF(warning, "phi < 0: %g", phimodn); - - float middle = o2::constants::math::TwoPI / 18.0; - phimodn += middle; // to center gap in the middle - phimodn = fmod(phimodn, o2::constants::math::TwoPI / 9.0); - registry.fill(HIST("pt_phi_bef"), track.pt(), phimodn); - if (cfgRejectionTPCsectorOverlap) { - if (phimodn < fPhiCutHigh->Eval(track.pt()) && phimodn > fPhiCutLow->Eval(track.pt())) - return false; // reject track - } - registry.fill(HIST("pt_phi_aft"), track.pt(), phimodn); - return true; + return ((track.tpcNClsFound() >= cfgCutTPCclu) && (track.tpcNClsCrossedRows() >= cfgCutTPCCrossedRows) && (track.itsNCls() >= cfgCutITSclu)); } void initHadronicRate(aod::BCsWithTimestamps::iterator const& bc) @@ -689,9 +753,35 @@ struct FlowTask { gCurrentHadronicRate = gHadronicRate[mRunNumber]; } - void process(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracks const& tracks) + template + float getCentrality(TCollision const& collision) + { + float cent; + switch (cfgCentEstimator) { + case kCentFT0C: + cent = collision.centFT0C(); + break; + case kCentFT0CVariant1: + cent = collision.centFT0CVariant1(); + break; + case kCentFT0M: + cent = collision.centFT0M(); + break; + case kCentFV0A: + cent = collision.centFV0A(); + break; + default: + cent = collision.centFT0C(); + } + return cent; + } + + void processData(FilteredCollisions::iterator const& collision, aod::BCsWithTimestamps const&, FilteredTracks const& tracks) { registry.fill(HIST("hEventCount"), 0.5); + if (!cfgUseSmallMemory && tracks.size() >= 1) { + registry.fill(HIST("BeforeSel8_globalTracks_centT0C"), collision.centFT0C(), tracks.size()); + } if (!collision.sel8()) return; if (tracks.size() < 1) @@ -714,7 +804,8 @@ struct FlowTask { registry.fill(HIST("BeforeCut_multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); registry.fill(HIST("BeforeCut_multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); } - const auto cent = collision.centFT0C(); + float cent = getCentrality(collision); + if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), cent)) return; registry.fill(HIST("hEventCount"), 3.5); @@ -722,13 +813,14 @@ struct FlowTask { float vtxz = collision.posZ(); registry.fill(HIST("hVtxZ"), vtxz); registry.fill(HIST("hMult"), tracks.size()); - registry.fill(HIST("hCent"), collision.centFT0C()); + registry.fill(HIST("hCent"), cent); fGFW->Clear(); + fFCpt->clearVector(); if (cfgGetInteractionRate) { initHadronicRate(bc); double hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, "ZNC hadronic") * 1.e-3; // double seconds = bc.timestamp() * 1.e-3 - mMinSeconds; - if (cfgUseInteractionRateCut && hadronicRate > cfgCutIR) // cut on hadronic rate + if (cfgUseInteractionRateCut && (hadronicRate < cfgCutMinIR || hadronicRate > cfgCutMaxIR)) // cut on hadronic rate return; gCurrentHadronicRate->Fill(seconds, hadronicRate); } @@ -744,62 +836,73 @@ struct FlowTask { registry.fill(HIST("globalTracks_multV0A"), collision.multFV0A(), tracks.size()); registry.fill(HIST("multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); registry.fill(HIST("multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); + registry.fill(HIST("centFT0CVar_centFT0C"), collision.centFT0C(), collision.centFT0CVariant1()); + registry.fill(HIST("centFT0M_centFT0C"), collision.centFT0C(), collision.centFT0M()); + registry.fill(HIST("centFV0A_centFT0C"), collision.centFT0C(), collision.centFV0A()); } // track weights float weff = 1, wacc = 1; - double weffEvent = 0; - double ptSum = 0., ptSum_Gap08 = 0.; - double weffEventWithinGap08 = 0., weffEventSquareWithinGap08 = 0.; - double sumptSquarewSquareWithinGap08 = 0., sumptwSquareWithinGap08 = 0.; - int magnetfield = 0; double nTracksCorrected = 0; - if (cfgShowTPCsectorOverlap) { - // magnet field dependence cut - magnetfield = getMagneticField(bc.timestamp()); - } float independent = cent; if (cfgUseNch) independent = static_cast(tracks.size()); - int groupNUAIndex = 0; - if (cfgOutputGroupNUAWeights || cfgAcceptanceGroupUse) { - for (uint i = 0; i < cfgGroupSplitRunNumber.value.size(); i++) { - if (currentRunNumber < cfgGroupSplitRunNumber.value.at(i)) { - break; - } else { - groupNUAIndex++; + double psi2Est = 0, psi3Est = 0, psi4Est = 0; + float wEPeff = 1; + double v2 = 0, v3 = 0, v4 = 0; + // be cautious, this only works for Pb-Pb + // esimate the Event plane and vn for this event + if (cfgTrackDensityCorrUse) { + double q2x = 0, q2y = 0; + double q3x = 0, q3y = 0; + double q4x = 0, q4y = 0; + for (const auto& track : tracks) { + bool withinPtRef = (cfgCutPtRefMin < track.pt()) && (track.pt() < cfgCutPtRefMax); // within RF pT rang + if (withinPtRef) { + q2x += std::cos(2 * track.phi()); + q2y += std::sin(2 * track.phi()); + q3x += std::cos(3 * track.phi()); + q3y += std::sin(3 * track.phi()); + q4x += std::cos(4 * track.phi()); + q4y += std::sin(4 * track.phi()); } } + psi2Est = std::atan2(q2y, q2x) / 2.; + psi3Est = std::atan2(q3y, q3x) / 3.; + psi4Est = std::atan2(q4y, q4x) / 4.; + v2 = funcV2->Eval(cent); + v3 = funcV3->Eval(cent); + v4 = funcV4->Eval(cent); } for (const auto& track : tracks) { if (!trackSelected(track)) continue; - if (cfgShowTPCsectorOverlap && !rejectionTPCoverlap(track, magnetfield)) - continue; bool withinPtPOI = (cfgCutPtPOIMin < track.pt()) && (track.pt() < cfgCutPtPOIMax); // within POI pT range bool withinPtRef = (cfgCutPtRefMin < track.pt()) && (track.pt() < cfgCutPtRefMax); // within RF pT range - bool withinEtaGap08 = (track.eta() >= -0.4) && (track.eta() <= 0.4); if (cfgOutputNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } else { - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } - if (cfgOutputGroupNUAWeights) { - if (cfgOutputNUAWeightsRefPt) { - if (withinPtRef) { - groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) + continue; + if (cfgTrackDensityCorrUse && withinPtRef) { + double fphi = v2 * std::cos(2 * (track.phi() - psi2Est)) + v3 * std::cos(3 * (track.phi() - psi3Est)) + v4 * std::cos(4 * (track.phi() - psi4Est)); + fphi = (1 + 2 * fphi); + int pTBinForEff = hFindPtBin->FindBin(track.pt()); + if (pTBinForEff >= 1 && pTBinForEff <= hFindPtBin->GetNbinsX()) { + wEPeff = funcEff[pTBinForEff - 1]->Eval(fphi * tracks.size()); + if (wEPeff > 0.) { + wEPeff = 1. / wEPeff; + weff *= wEPeff; } - } else { - groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } - if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz, groupNUAIndex)) - continue; registry.fill(HIST("hPt"), track.pt()); if (withinPtRef) { registry.fill(HIST("hPhi"), track.phi()); @@ -809,19 +912,11 @@ struct FlowTask { registry.fill(HIST("hChi2prTPCcls"), track.tpcChi2NCl()); registry.fill(HIST("hChi2prITScls"), track.itsChi2NCl()); registry.fill(HIST("hnTPCClu"), track.tpcNClsFound()); + registry.fill(HIST("hnITSClu"), track.itsNCls()); registry.fill(HIST("hnTPCCrossedRow"), track.tpcNClsCrossedRows()); - registry.fill(HIST("hDCAz"), track.dcaZ()); + registry.fill(HIST("hDCAz"), track.dcaZ(), track.pt()); registry.fill(HIST("hDCAxy"), track.dcaXY(), track.pt()); - weffEvent += weff; - ptSum += weff * track.pt(); nTracksCorrected += weff; - if (withinEtaGap08) { - ptSum_Gap08 += weff * track.pt(); - sumptwSquareWithinGap08 += weff * weff * track.pt(); - sumptSquarewSquareWithinGap08 += weff * weff * track.pt() * track.pt(); - weffEventWithinGap08 += weff; - weffEventSquareWithinGap08 += weff * weff; - } } if (withinPtRef) fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 1); @@ -829,52 +924,75 @@ struct FlowTask { fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 2); if (withinPtPOI && withinPtRef) fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 4); + if (cfgUsePtRef && withinPtRef) + fillPtSums(track, weff); + if (!cfgUsePtRef && withinPtPOI) + fillPtSums(track, weff); } registry.fill(HIST("hTrackCorrection2d"), tracks.size(), nTracksCorrected); - if (!cfgUseSmallMemory) { - double weffEventDiffWithGap08 = weffEventWithinGap08 * weffEventWithinGap08 - weffEventSquareWithinGap08; - // Filling TProfile - // MeanPt - if (weffEvent > 1e-6) - registry.fill(HIST("hMeanPt"), independent, ptSum / weffEvent, weffEvent); - if (weffEventWithinGap08 > 1e-6) - registry.fill(HIST("hMeanPtWithinGap08"), independent, ptSum_Gap08 / weffEventWithinGap08, weffEventWithinGap08); - // v22-Pt - // c22_gap8 * pt_withGap8 - if (weffEventWithinGap08 > 1e-6) - fillpTvnProfile(corrconfigs.at(7), ptSum_Gap08, weffEventWithinGap08, HIST("c22_gap08_Weff"), HIST("c22_gap08_trackMeanPt"), independent); - // PtVariance - if (weffEventDiffWithGap08 > 1e-6) { - registry.fill(HIST("PtVariance_partA_WithinGap08"), independent, - (ptSum_Gap08 * ptSum_Gap08 - sumptSquarewSquareWithinGap08) / weffEventDiffWithGap08, - weffEventDiffWithGap08); - registry.fill(HIST("PtVariance_partB_WithinGap08"), independent, - (weffEventWithinGap08 * ptSum_Gap08 - sumptwSquareWithinGap08) / weffEventDiffWithGap08, - weffEventDiffWithGap08); - } + // Filling Flow Container + for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { + fillFC(corrconfigs.at(l_ind), independent, lRandom); + } + // Filling pt Container + fillPtContainers(independent, lRandom); + } + PROCESS_SWITCH(FlowTask, processData, "Process analysis for non-derived data", true); + + void processMCGen(FilteredMcCollisions::iterator const& mcCollision, FilteredSmallGroupMcCollisions const& collisions, FilteredMcParticles const& mcParticles) + { + if (collisions.size() != 1) + return; + + float cent = -1.; + for (const auto& collision : collisions) { + cent = getCentrality(collision); + } + + float lRandom = fRndm->Rndm(); + float vtxz = mcCollision.posZ(); + registry.fill(HIST("MCGen/MChVtxZ"), vtxz); + registry.fill(HIST("MCGen/MChMult"), mcParticles.size()); + registry.fill(HIST("MCGen/MChCent"), cent); + float independent = cent; + if (cfgUseNch) + independent = static_cast(mcParticles.size()); - // Filling Bootstrap Samples - int sampleIndex = static_cast(cfgNbootstrap * lRandom); - if (weffEventWithinGap08 > 1e-6) - bootstrapArray[sampleIndex][kMeanPt_InGap08]->Fill(independent, ptSum_Gap08 / weffEventWithinGap08, weffEventWithinGap08); - if (weffEventWithinGap08 > 1e-6) - fillpTvnProfile(corrconfigs.at(7), ptSum_Gap08, weffEventWithinGap08, bootstrapArray[sampleIndex][kC22_Gap08_Weff], bootstrapArray[sampleIndex][kC22_Gap08_MeanPt], independent); - if (weffEventDiffWithGap08 > 1e-6) { - bootstrapArray[sampleIndex][kPtVarParA_InGap08]->Fill(independent, - (ptSum_Gap08 * ptSum_Gap08 - sumptSquarewSquareWithinGap08) / weffEventDiffWithGap08, - weffEventDiffWithGap08); - bootstrapArray[sampleIndex][kPtVarParB_InGap08]->Fill(independent, - (weffEventWithinGap08 * ptSum_Gap08 - sumptwSquareWithinGap08) / weffEventDiffWithGap08, - weffEventDiffWithGap08); + fGFW->Clear(); + fFCptgen->clearVector(); + + for (const auto& mcParticle : mcParticles) { + if (!mcParticle.isPhysicalPrimary()) + continue; + bool withinPtPOI = (cfgCutPtPOIMin < mcParticle.pt()) && (mcParticle.pt() < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtRefMin < mcParticle.pt()) && (mcParticle.pt() < cfgCutPtRefMax); // within RF pT range + + if (withinPtRef) { + registry.fill(HIST("MCGen/MChPhi"), mcParticle.phi()); + registry.fill(HIST("MCGen/MChEta"), mcParticle.eta()); + registry.fill(HIST("MCGen/MChPtRef"), mcParticle.pt()); } + if (withinPtRef) + fGFW->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), 1., 1); + if (withinPtPOI) + fGFW->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), 1., 2); + if (withinPtPOI && withinPtRef) + fGFW->Fill(mcParticle.eta(), fPtAxis->FindBin(mcParticle.pt()) - 1, mcParticle.phi(), 1., 4); + if (cfgUsePtRef && withinPtRef) + fillPtSums(mcParticle, 1.); + if (!cfgUsePtRef && withinPtPOI) + fillPtSums(mcParticle, 1.); } // Filling Flow Container for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { - fillFC(corrconfigs.at(l_ind), independent, lRandom); + fillFC(corrconfigs.at(l_ind), independent, lRandom); } + // Filling pt Container + fillPtContainers(independent, lRandom); } + PROCESS_SWITCH(FlowTask, processMCGen, "Process analysis for MC generated events", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/Flow/Tasks/flowZdcTask.cxx b/PWGCF/Flow/Tasks/flowZdcTask.cxx new file mode 100644 index 00000000000..478a21ee4fc --- /dev/null +++ b/PWGCF/Flow/Tasks/flowZdcTask.cxx @@ -0,0 +1,832 @@ +// 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. + +/// \file flowZdcTask.cxx +/// \author Sabrina Hernandez +/// \since 10/01/2024 +/// \brief task to evaluate flow and neutron skin with information from ZDC + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/MathConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include + +#include "TList.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::mult; +using namespace o2::constants::math; +using namespace o2::aod::evsel; + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +struct FlowZdcTask { + SliceCache cache; + + O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") + + Configurable eventSelection{"eventSelection", 1, "event selection"}; + Configurable maxZp{"maxZp", 125.5, "Max ZP signal"}; + Configurable maxZem{"maxZem", 3099.5, "Max ZEM signal"}; + // for ZDC info and analysis + Configurable nBinsAmp{"nBinsAmp", 1025, "nbinsAmp"}; + Configurable nBinsCent{"nBinsCent", 90, "nBinsCent"}; + Configurable maxZn{"maxZn", 125.5, "Max ZN signal"}; + Configurable vtxRange{"vtxRange", 10.0f, "Vertex Z range to consider"}; + Configurable etaRange{"etaRange", 1.0f, "Eta range to consider"}; + // configs for process QA + Configurable nBinsNch{"nBinsNch", 2501, "N bins Nch (|eta|<0.8)"}; + Configurable nBinsAmpFT0{"nBinsAmpFT0", 100, "N bins FT0 amp"}; + Configurable maxAmpFT0{"maxAmpFT0", 2500, "Max FT0 amp"}; + Configurable nBinsAmpFV0{"nBinsAmpFV0", 100, "N bins FV0 amp"}; + Configurable maxAmpFV0{"maxAmpFV0", 2000, "Max FV0 amp"}; + Configurable nBinsZDC{"nBinsZDC", 400, "nBinsZDC"}; + Configurable nBinsZN{"nBinsZN", 400, "N bins ZN"}; + Configurable nBinsZP{"nBinsZP", 160, "N bins ZP"}; + Configurable minNch{"minNch", 0, "Min Nch (|eta|<0.8)"}; + Configurable maxNch{"maxNch", 2500, "Max Nch (|eta|<0.8)"}; + Configurable oneNeutron{"oneNeutron", 1.0, "one neutron, energy or integer"}; + Configurable nBinsTDC{"nBinsTDC", 150, "nbinsTDC"}; + Configurable minTdc{"minTdc", -15.0, "minimum TDC"}; + Configurable maxTdc{"maxTdc", 15.0, "maximum TDC"}; + Configurable cfgCollisionEnergy{"cfgCollisionEnergy", 2.68, "cfgCollisionEnergy"}; + // event selection + Configurable isNoCollInTimeRangeStrict{"isNoCollInTimeRangeStrict", true, "isNoCollInTimeRangeStrict?"}; + Configurable isNoCollInTimeRangeStandard{"isNoCollInTimeRangeStandard", false, "isNoCollInTimeRangeStandard?"}; + Configurable isNoCollInRofStrict{"isNoCollInRofStrict", true, "isNoCollInRofStrict?"}; + Configurable isNoCollInRofStandard{"isNoCollInRofStandard", false, "isNoCollInRofStandard?"}; + Configurable isNoHighMultCollInPrevRof{"isNoHighMultCollInPrevRof", true, "isNoHighMultCollInPrevRof?"}; + Configurable isNoCollInTimeRangeNarrow{"isNoCollInTimeRangeNarrow", false, "isNoCollInTimeRangeNarrow?"}; + Configurable isOccupancyCut{"isOccupancyCut", true, "Occupancy cut?"}; + Configurable isApplyFT0CbasedOccupancy{"isApplyFT0CbasedOccupancy", false, "T0C Occu cut?"}; + Configurable isTDCcut{"isTDCcut", false, "Use TDC cut?"}; + Configurable isZEMcut{"isZEMcut", false, "Use ZEM cut?"}; + Configurable useMidRapNchSel{"useMidRapNchSel", false, "Use mid-rapidity Nch selection"}; + Configurable applyEff{"applyEff", true, "Apply track-by-track efficiency correction"}; + Configurable applyFD{"applyFD", false, "Apply track-by-track feed down correction"}; + Configurable correctNch{"correctNch", true, "Correct also Nch"}; + Configurable isOneNeutronFound{"isOneNeutronFound", true, "Require at least 1 neutron in ZNA/ZNC to fill ZPA/ZPC"}; + + Configurable nSigmaNchCut{"nSigmaNchCut", 1., "nSigma Nch selection"}; + Configurable minNchSel{"minNchSel", 5., "min Nch Selection"}; + Configurable znBasedCut{"znBasedCut", 100, "ZN-based cut"}; + Configurable zemCut{"zemCut", 1000., "ZEM cut"}; + Configurable tdcCut{"tdcCut", 1., "TDC cut"}; + Configurable minOccCut{"minOccCut", 0, "min Occu cut"}; + Configurable maxOccCut{"maxOccCut", 500, "max Occu cut"}; + Configurable minPt{"minPt", 0.1, "minimum pt of the tracks"}; + Configurable maxPt{"maxPt", 3., "maximum pt of the tracks"}; + Configurable maxPtSpectra{"maxPtSpectra", 50., "maximum pt of the tracks"}; + // axis configs + ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {3500, 0, 3500}, "centrality axis for histograms"}; + ConfigurableAxis axisZN{"axisZN", {5000, 0, 500}, "axisZN"}; + ConfigurableAxis axisZP{"axisZP", {5000, 0, 500}, "axisZP"}; + ConfigurableAxis axisFT0CAmp{"axisFT0CAmp", {5000, 0, 5000}, "axisFT0CAmp"}; + ConfigurableAxis axisFT0AAmp{"axisFT0AAmp", {5000, 0, 5000}, "axisFT0AAmp"}; + ConfigurableAxis axisFT0MAmp{"axisFT0MAmp", {10000, 0, 10000}, "axisFT0MAmp"}; + ConfigurableAxis multHistBin{"multHistBin", {501, -0.5, 500.5}, ""}; + ConfigurableAxis axisCent{"axisCent", {10, 0, 100}, "axisCent"}; + ConfigurableAxis ft0cMultHistBin{"ft0cMultHistBin", {501, -0.5, 500.5}, ""}; + ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 0.0, 0.1, 0.12}, "pT binning"}; + Configurable posZcut{"posZcut", +10.0, "z-vertex position cut"}; + Configurable minEta{"minEta", -0.8, "minimum eta"}; + Configurable maxEta{"maxEta", +0.8, "maximum eta"}; + Configurable minT0CcentCut{"minT0CcentCut", 0.0, "Min T0C Cent. cut"}; + Configurable maxT0CcentCut{"maxT0CcentCut", 90.0, "Max T0C Cent. cut"}; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter trackFilter = ((aod::track::eta > minEta) && (aod::track::eta < maxEta)); + using ColEvSels = soa::Join; + using AodCollisions = soa::Filtered>; + using AodTracks = soa::Filtered>; + Partition tracksIUWithTPC = (aod::track::tpcNClsFindable > (uint8_t)0); + using TracksSel = soa::Join; + using BCsRun3 = soa::Join; + using AodZDCs = soa::Join; + using CollisionDataTable = soa::Join; + using TrackDataTable = soa::Join; + using FilTrackDataTable = soa::Filtered; + using TheFilteredTracks = soa::Filtered; + + // CCDB paths + Configurable paTH{"paTH", "Users/s/sahernan/test", "base path to the ccdb object"}; + Configurable paTHmeanNch{"paTHmeanNch", "Users/s/shernan/test", "base path to the ccdb object"}; + Configurable paTHsigmaNch{"paTHsigmaNch", "Users/s/shernan/testSigma", "base path to the ccdb object"}; + Configurable paTHEff{"paTHEff", "Users/s/shernan/TrackingEff", "base path to the ccdb object"}; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + + enum EvCutLabel { + All = 1, + SelEigth, + NoSameBunchPileup, + IsGoodZvtxFT0vsPV, + NoCollInTimeRangeStrict, + NoCollInTimeRangeStandard, + NoCollInRofStrict, + NoCollInRofStandard, + NoHighMultCollInPrevRof, + NoCollInTimeRangeNarrow, + OccuCut, + Centrality, + VtxZ, + Zdc, + TZero, + Tdc, + Zem + }; + // Begin Histogram Registry + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Service ccdb; + OutputObj pZNvsFT0Ccent{TProfile("pZNvsFT0Ccent", "ZN Energy vs FT0C Centrality", 100, 0, 100, 0, 500)}; + OutputObj pZPvsFT0Ccent{TProfile("pZPvsFT0Ccent", "ZP Energy vs FT0C Centrality", 100, 0, 100, 0, 500)}; + OutputObj pZNratiovscent{TProfile("pZNratiovscent", "Ratio ZNC/ZNA vs FT0C Centrality", 100, 0, 100, 0, 5)}; + OutputObj pZPratiovscent{TProfile("pZPratiovscent", "Ratio ZPC/ZPA vs FT0C Centrality", 100, 0, 100, 0, 5)}; + + void init(InitContext const&) + { + // define axes + const AxisSpec axisCounter{1, 0, +1, ""}; + const AxisSpec axisEvent{18, 0.5, 18.5, ""}; + const AxisSpec axisZpos{48, -12., 12., "Vtx_{z} (cm)"}; + const AxisSpec axisEta{40, -1., +1., "#eta"}; + const AxisSpec axisPt{binsPt, "#it{p}_{T} (GeV/#it{c})"}; + + AxisSpec axisVtxZ{40, -20, 20, "Vertex Z", "VzAxis"}; + AxisSpec axisMult = {multHistBin, "Mult", "MultAxis"}; + AxisSpec axisFT0CMult = {ft0cMultHistBin, "ft0c", "FT0CMultAxis"}; + + // create histograms + histos.add("hEventCounter", "Event counter", kTH1F, {axisEvent}); + histos.add("zPos", ";;Entries;", kTH1F, {axisZpos}); + + histos.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); + histos.add("hZNvsFT0Ccent", + "ZN Energy vs FT0C Centrality", + kTH2F, + {axisCent, axisZN}); + histos.add("hZPvsFT0Ccent", + "ZP Energy vs FT0C Centrality;Centrality [%];ZP Energy", + kTH2F, + {axisCent, axisZP}); + histos.add("hNchvsNPV", ";NPVTracks (|#eta|<1);N_{ch} (|#eta|<0.8);", + kTH2F, + {{{nBinsNch, -0.5, maxNch}, {nBinsNch, -0.5, maxNch}}}); + histos.add("T0Ccent", ";;Entries", kTH1F, {axisCent}); + histos.add("NchUncorrected", ";#it{N}_{ch} (|#eta| < 0.8);Entries;", kTH1F, {{300, 0., 3000.}}); + histos.add("ZNamp", ";ZNA+ZNC;Entries;", kTH1F, {{nBinsZN, -0.5, maxZn}}); + histos.add("ExcludedEvtVsFT0M", ";T0A+T0C (#times 1/100, -3.3 < #eta < -2.1 and 3.5 < #eta < 4.9);Entries;", kTH1F, {{nBinsAmpFT0, 0., maxAmpFT0}}); + histos.add("ExcludedEvtVsNch", ";#it{N}_{ch} (|#eta|<0.8);Entries;", kTH1F, {{300, 0, 3000}}); + histos.add("Nch", ";#it{N}_{ch} (|#eta| < 0.8, Corrected);", kTH1F, {{nBinsNch, minNch, maxNch}}); + histos.add("NchVsOneParCorr", ";#it{N}_{ch} (|#eta| < 0.8, Corrected);#LT[#it{p}_{T}^{(1)}]#GT (GeV/#it{c})", kTProfile, {{nBinsNch, minNch, maxNch}}); + histos.add("EtaVsPhi", ";#eta;#varphi", kTH2F, {{{axisEta}, {100, -0.1 * PI, +2.1 * PI}}}); + histos.add("ZposVsEta", "", kTProfile, {axisZpos}); + histos.add("sigma1Pt", ";;#sigma(p_{T})/p_{T};", kTProfile, {axisPt}); + histos.add("dcaXYvspT", ";DCA_{xy} (cm);;", kTH2F, {{{50, -1., 1.}, {axisPt}}}); + histos.add("GlobalMult_vs_FT0C", "GlobalMult_vs_FT0C", kTH2F, {axisMult, axisFT0CMult}); + histos.add("VtxZHist", "VtxZHist", kTH1D, {axisVtxZ}); + + // event selection steps + histos.add("eventSelectionSteps", "eventSelectionSteps", kTH1D, {axisEvent}); + auto hstat = histos.get(HIST("eventSelectionSteps")); + auto* xAxis = hstat->GetXaxis(); + xAxis->SetBinLabel(1, "All events"); + xAxis->SetBinLabel(2, "SelEigth"); + xAxis->SetBinLabel(3, "NoSameBunchPileup"); // reject collisions in case of pileup with another collision in the same foundBC + xAxis->SetBinLabel(4, "GoodZvtxFT0vsPV"); // small difference between z-vertex from PV and from FT0 + xAxis->SetBinLabel(5, "NoCollInTimeRangeStrict"); + xAxis->SetBinLabel(6, "NoCollInTimeRangeStandard"); + xAxis->SetBinLabel(7, "NoCollInRofStrict"); + xAxis->SetBinLabel(8, "NoCollInRofStandard"); + xAxis->SetBinLabel(9, "NoHighMultCollInPrevRof"); + xAxis->SetBinLabel(10, "NoCollInTimeRangeNarrow"); + xAxis->SetBinLabel(11, "Occupancy Cut"); + xAxis->SetBinLabel(12, "Cent. Sel."); + xAxis->SetBinLabel(13, "VtxZ cut"); + xAxis->SetBinLabel(14, "has ZDC?"); + xAxis->SetBinLabel(15, "has T0?"); + xAxis->SetBinLabel(16, "Within TDC cut?"); + xAxis->SetBinLabel(17, "Within ZEM cut?"); + + if (doprocessZdcCollAssoc) { // Check if the process function for ZDCCollAssoc is enabled + histos.add("ZNAcoll", "ZNAcoll; ZNA amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZn}}}); + histos.add("ZNCcoll", "ZNCcoll; ZNC amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZn}}}); + histos.add("ZPCcoll", "ZPCcoll; ZPC amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZn}}}); + histos.add("ZPAcoll", "ZPAcoll; ZPA amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZn}}}); + histos.add("ZEM1coll", "ZEM1coll; ZEM1 amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZem}}}); + histos.add("ZEM2coll", "ZEM2coll; ZEM2 amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, maxZem}}}); + histos.add("ZNvsZEMcoll", "ZNvsZEMcoll; ZEM; ZNA+ZNC", {HistType::kTH2F, {{{nBinsAmp, -0.5, maxZem}, {nBinsAmp, -0.5, 2. * maxZn}}}}); + histos.add("ZNAvsZNCcoll", "ZNAvsZNCcoll; ZNC; ZNA", {HistType::kTH2F, {{{nBinsAmp, -0.5, maxZn}, {nBinsAmp, -0.5, maxZn}}}}); + histos.add("ZDC_energy_vs_ZEM", "ZDCvsZEM; ZEM; ZNA+ZNC+ZPA+ZPC", {HistType::kTH2F, {{{nBinsAmp, -0.5, maxZem}, {nBinsAmp, -0.5, 2. * maxZn}}}}); + // common energies information for ZDC + histos.add("ZNCenergy", "common sum ZN energy side c", kTH1F, {axisZN}); + histos.add("ZNAenergy", "common sum ZN energy side a", kTH1F, {axisZN}); + histos.add("ZPCenergy", "common sum ZP energy side c", kTH1F, {axisZP}); + histos.add("ZPAenergy", "common sum ZP energy side a", kTH1F, {axisZP}); + histos.add("ZNenergy", "common sum zn (a + c sides) energy", kTH1F, {axisZN}); + histos.add("ZPenergy", "common sum zp energy (a + c sides)", kTH1F, {axisZP}); + histos.add("hZNvsFT0CAmp", "ZN Energy vs FT0C Amplitude", kTH2F, {axisFT0CAmp, axisZN}); + histos.add("hZPvsFT0CAmp", "ZP Energy vs FT0C Amplitude", kTH2F, {axisFT0CAmp, axisZP}); + histos.add("hZNvsMult", "ZN Energy vs Multiplicity", kTH2F, {axisMultiplicity, axisZN}); + histos.add("hZPvsMult", "ZP Energy vs Multiplicity", kTH2F, {axisMultiplicity, axisZP}); + } + + if (doprocessQA) { + histos.add("ZNVsFT0A", ";T0A (#times 1/100);ZNA+ZNC;", kTH2F, {{{nBinsAmpFT0, 0., maxAmpFT0}, {nBinsZDC, -0.5, maxZn}}}); + histos.add("ZNVsFT0C", ";T0C (#times 1/100);ZNA+ZNC;", kTH2F, {{{nBinsAmpFT0, 0., maxAmpFT0}, {nBinsZDC, -0.5, maxZn}}}); + histos.add("ZNVsFT0M", ";T0A+T0C (#times 1/100);ZNA+ZNC;", kTH2F, {{{nBinsAmpFT0, 0., 3000.}, {nBinsZDC, -0.5, maxZn}}}); + histos.add("ZN", ";ZNA+ZNC;Entries;", kTH1F, {{nBinsZDC, -0.5, maxZn}}); + histos.add("ZNA", ";ZNA;Entries;", kTH1F, {{nBinsZDC, -0.5, maxZn}}); + histos.add("ZPA", ";ZPA;Entries;", kTH1F, {{nBinsZDC, -0.5, maxZp}}); + histos.add("ZNC", ";ZNC;Entries;", kTH1F, {{nBinsZDC, -0.5, maxZn}}); + histos.add("ZPC", ";ZPC;Entries;", kTH1F, {{nBinsZDC, -0.5, maxZp}}); + histos.add("ZNAVsZNC", ";ZNC;ZNA", kTH2F, {{{30, -0.5, maxZn}, {30, -0.5, maxZn}}}); + histos.add("ZPAVsZPC", ";ZPC;ZPA;", kTH2F, {{{100, -0.5, maxZp}, {100, -0.5, maxZp}}}); + histos.add("ZNAVsZPA", ";ZPA;ZNA;", kTH2F, {{{20, -0.5, maxZp}, {30, -0.5, maxZn}}}); + histos.add("ZNCVsZPC", ";ZPC;ZNC;", kTH2F, {{{20, -0.5, maxZp}, {30, -0.5, maxZn}}}); + histos.add("ZNASector", ";ZNA;Entries;", kTH1F, {{nBinsZDC, -0.5, maxZn}}); + histos.add("ZPASector", ";ZPA;Entries;", kTH1F, {{nBinsZDC, -0.5, maxZp}}); + histos.add("ZNCSector", ";ZNC;Entries;", kTH1F, {{nBinsZDC, -0.5, maxZn}}); + histos.add("ZPCSector", ";ZPC;Entries;", kTH1F, {{nBinsZDC, -0.5, maxZp}}); + histos.add("ZNCcvsZNCsum", ";ZNC common;ZNC sum towers;", kTH2F, {{{30, -0.5, maxZn}, {30, -0.5, maxZn}}}); + histos.add("ZNAcvsZNAsum", ";ZNA common;ZNA sum towers;", kTH2F, {{{30, -0.5, maxZn}, {30, -0.5, maxZn}}}); + histos.add("ZPCcvsZPCsum", ";ZPC common;ZPC sum towers;", kTH2F, {{{30, -0.5, maxZp}, {30, -0.5, maxZp}}}); + histos.add("ZPAcvsZPAsum", ";ZPA common;ZPA sum towers;", kTH2F, {{{30, -0.5, maxZp}, {30, -0.5, maxZp}}}); + histos.add("ZNVsZEM", ";ZEM;ZNA+ZNC;", kTH2F, {{{60, -0.5, maxZem}, {60, -0.5, maxZn}}}); + histos.add("ZNCVstdc", ";t_{ZNC};ZNC;", kTH2F, {{{30, -15., 15.}, {nBinsZDC, -0.5, maxZn}}}); + histos.add("ZNAVstdc", ";t_{ZNA};ZNA;", kTH2F, {{{30, -15., 15.}, {30, -0.5, maxZn}}}); + histos.add("ZPCVstdc", ";t_{ZPC};ZPC;", kTH2F, {{{30, -15., 15}, {20, -0.5, maxZp}}}); + histos.add("ZPAVstdc", ";t_{ZPA};ZPA;", kTH2F, {{{30, -15., 15.}, {20, -0.5, maxZp}}}); + histos.add("ZEM1Vstdc", ";t_{ZEM1};ZEM1;", kTH2F, {{{30, -15., 15.}, {30, -0.5, 2000.5}}}); + histos.add("ZEM2Vstdc", ";t_{ZEM2};ZEM2;", kTH2F, {{{30, -15., 15.}, {30, -0.5, 2000.5}}}); + histos.add("debunch", ";t_{ZDC}-t_{ZDA};t_{ZDC}+t_{ZDA}", kTH2F, {{{nBinsTDC, minTdc, maxTdc}, {nBinsTDC, minTdc, maxTdc}}}); + + histos.add("GlbTracks", "Nch", kTH1F, {{nBinsNch, minNch, maxNch}}); + histos.add("NchVsFT0C", ";T0C (#times 1/100, -3.3 < #eta < -2.1);#it{N}_{ch} (|#eta|<0.8);", kTH2F, {{{nBinsAmpFT0, 0., 950.}, {nBinsNch, minNch, maxNch}}}); + histos.add("NchVsFT0M", ";T0A+T0C (#times 1/100, -3.3 < #eta < -2.1 and 3.5 < #eta < 4.9);#it{N}_{ch} (|#eta|<0.8);", kTH2F, {{{nBinsAmpFT0, 0., 3000.}, {nBinsNch, minNch, maxNch}}}); + histos.add("NchVsFT0A", ";T0A (#times 1/100, 3.5 < #eta < 4.9);#it{N}_{ch} (|#eta|<0.8);", kTH2F, {{{nBinsAmpFT0, 0., maxAmpFT0}, {nBinsNch, minNch, maxNch}}}); + histos.add("NchVsFV0A", ";V0A (#times 1/100, 2.2 < #eta < 5);#it{N}_{ch} (|#eta|<0.8);", kTH2F, {{{nBinsAmpFV0, 0., maxAmpFV0}, {nBinsNch, minNch, maxNch}}}); + + histos.add("NchVsEt", ";#it{E}_{T} (|#eta|<0.8);#LTITS+TPC tracks#GT (|#eta|<0.8);", kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsNch, minNch, maxNch}}}); + histos.add("NchVsMeanPt", ";#it{N}_{ch} (|#eta|<0.8);#LT[#it{p}_{T}]#GT (|#eta|<0.8);", kTProfile, {{nBinsNch, minNch, maxNch}}); + histos.add("NchVsNPV", ";#it{N}_{PV} (|#eta|<1);ITS+TPC tracks (|#eta|<0.8);", kTH2F, {{{300, -0.5, 5999.5}, {nBinsNch, minNch, maxNch}}}); + histos.add("NchVsITStracks", ";ITS tracks nCls >= 5;TITS+TPC tracks (|#eta|<0.8);", kTH2F, {{{300, -0.5, 5999.5}, {nBinsNch, minNch, maxNch}}}); + histos.add("ZNCVsNch", ";#it{N}_{ch} (|#eta|<0.8);ZNC;", kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsZDC, minNch, maxZn}}}); + histos.add("ZNAVsNch", ";#it{N}_{ch} (|#eta|<0.8);ZNA;", kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsZDC, minNch, maxZn}}}); + histos.add("ZNVsNch", ";#it{N}_{ch} (|#eta|<0.8);ZNA+ZNC;", kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsZDC, minNch, maxZn}}}); + histos.add("ZNDifVsNch", ";#it{N}_{ch} (|#eta|<0.8);ZNA-ZNC;", kTH2F, {{{nBinsNch, minNch, maxNch}, {100, -50., 50.}}}); + histos.add("ZPAvsCent", ";centFT0C;ZPA", kTH2F, {{{axisCent}, {nBinsZDC, -0.5, maxZp}}}); + histos.add("ZPCvsCent", ";centFT0C;ZPC", kTH2F, {{{axisCent}, {nBinsZDC, -0.5, maxZp}}}); + histos.add("pZPAvsFT0Ccent", ";FT0C centrality;ZPA Amplitude", kTProfile, {{nBinsCent, minT0CcentCut, maxT0CcentCut}}); + histos.add("pZPCvsFT0Ccent", ";FT0C centrality;ZPC Amplitude", kTProfile, {{nBinsCent, minT0CcentCut, maxT0CcentCut}}); + } + + ccdb->setURL("http://alice-ccdb.cern.ch"); + // Enabling object caching, otherwise each call goes to the CCDB server + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + // Not later than now, will be replaced by the value of the train creation + // This avoids that users can replace objects **while** a train is running + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + } + template + bool isEventSelected(EventCuts const& col) + { + histos.fill(HIST("hEventCounter"), EvCutLabel::All); + if (!col.sel8()) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::SelEigth); + + if (!col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::NoSameBunchPileup); + + if (!col.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::IsGoodZvtxFT0vsPV); + + if (isNoCollInTimeRangeStrict) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::NoCollInTimeRangeStrict); + } + + if (isNoCollInTimeRangeStandard) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::NoCollInTimeRangeStandard); + } + + if (isNoCollInRofStrict) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::NoCollInRofStrict); + } + + if (isNoCollInRofStandard) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::NoCollInRofStandard); + } + + if (isNoHighMultCollInPrevRof) { + if (!col.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::NoHighMultCollInPrevRof); + } + + // To be used in combination with FT0C-based occupancy + if (isNoCollInTimeRangeNarrow) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::NoCollInTimeRangeNarrow); + } + + if (isOccupancyCut) { + auto occuValue{isApplyFT0CbasedOccupancy ? col.ft0cOccupancyInTimeRange() : col.trackOccupancyInTimeRange()}; + if (occuValue < minOccCut || occuValue > maxOccCut) { + return false; + } + } + histos.fill(HIST("hEventCounter"), EvCutLabel::OccuCut); + + if (col.centFT0C() < minT0CcentCut || col.centFT0C() > maxT0CcentCut) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::Centrality); + + // Z-vertex position cut + if (std::fabs(col.posZ()) > posZcut) { + return false; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::VtxZ); + + return true; + } + + void processQA(ColEvSels::iterator const& collision, BCsRun3 const& /*bcs*/, aod::Zdcs const& /*zdcsData*/, aod::FV0As const& /*fv0as*/, aod::FT0s const& /*ft0s*/, TheFilteredTracks const& tracks) + { + const auto& foundBC = collision.foundBC_as(); + const auto cent = collision.centFT0C(); + if (!isEventSelected(collision)) { + return; + } + if (!foundBC.has_zdc()) { + return; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::Zdc); + auto zdc = foundBC.zdc(); + + float aT0A = 0., aT0C = 0., aV0A = 0.; + if (foundBC.has_ft0()) { + for (const auto& amplitude : foundBC.ft0().amplitudeA()) { + aT0A += amplitude; + } + for (const auto& amplitude : foundBC.ft0().amplitudeC()) { + aT0C += amplitude; + } + } else { + return; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::TZero); + if (foundBC.has_fv0a()) { + for (const auto& amplitude : foundBC.fv0a().amplitude()) { + aV0A += amplitude; + } + } else { + aV0A = -999.; + } + float tZNA{zdc.timeZNA()}; + float tZNC{zdc.timeZNC()}; + float tZPA{zdc.timeZPA()}; + float tZPC{zdc.timeZPC()}; + float tZDCdif{tZNC + tZPC - tZNA - tZPA}; + float tZDCsum{tZNC + tZPC + tZNA + tZPA}; + const double normT0M{(aT0A + aT0C) / 100.}; + float znA = zdc.amplitudeZNA() / cfgCollisionEnergy; + float znC = zdc.amplitudeZNC() / cfgCollisionEnergy; + float zpA = zdc.amplitudeZPA() / cfgCollisionEnergy; + float zpC = zdc.amplitudeZPC() / cfgCollisionEnergy; + float aZEM1{zdc.amplitudeZEM1()}; + float aZEM2{zdc.amplitudeZEM2()}; + float sumZEMs{aZEM1 + aZEM2}; + float tZEM1{zdc.timeZEM1()}; + float tZEM2{zdc.timeZEM2()}; + float sumZNs{znA + znC}; + + // TDC cut + if (isTDCcut) { + if (std::sqrt(std::pow(tZDCdif, 2.) + std::pow(tZDCsum, 2.)) > tdcCut) { + return; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::Tdc); + } + + // ZEM cut + if (isZEMcut) { + if (sumZEMs < zemCut) { + return; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::Zem); + } + + float sumZNC = (zdc.energySectorZNC())[0] + (zdc.energySectorZNC())[1] + (zdc.energySectorZNC())[2] + (zdc.energySectorZNC())[3]; + float sumZNA = (zdc.energySectorZNA())[0] + (zdc.energySectorZNA())[1] + (zdc.energySectorZNA())[2] + (zdc.energySectorZNA())[3]; + float sumZPC = (zdc.energySectorZPC())[0] + (zdc.energySectorZPC())[1] + (zdc.energySectorZPC())[2] + (zdc.energySectorZPC())[3]; + float sumZPA = (zdc.energySectorZPA())[0] + (zdc.energySectorZPA())[1] + (zdc.energySectorZPA())[2] + (zdc.energySectorZPA())[3]; + + float et = 0., meanpt = 0.; + int itsTracks = 0, glbTracks = 0; + for (const auto& track : tracks) { + if (track.hasITS()) { + itsTracks++; + } + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + glbTracks++; + } + bool skipEvent{false}; + if (useMidRapNchSel) { + auto hMeanNch = ccdb->getForTimeStamp(paTHmeanNch.value, foundBC.timestamp()); + auto hSigmaNch = ccdb->getForTimeStamp(paTHsigmaNch.value, foundBC.timestamp()); + if (!hMeanNch) { + LOGF(info, "hMeanNch NOT LOADED!"); + return; + } + if (!hSigmaNch) { + LOGF(info, "hSigmaNch NOT LOADED!"); + return; + } + + const int binT0M{hMeanNch->FindBin(normT0M)}; + const double meanNch{hMeanNch->GetBinContent(binT0M)}; + const double sigmaNch{hSigmaNch->GetBinContent(binT0M)}; + const double nSigmaSelection{nSigmaNchCut * sigmaNch}; + const double diffMeanNch{meanNch - glbTracks}; + + if (!(std::abs(diffMeanNch) < nSigmaSelection)) { + histos.fill(HIST("ExcludedEvtVsNch"), glbTracks); + } else { + skipEvent = true; + } + } else { + skipEvent = true; + } + if (!skipEvent) { + return; + } + + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPtSpectra)) { + continue; + } + + histos.fill(HIST("ZposVsEta"), collision.posZ(), track.eta()); + histos.fill(HIST("EtaVsPhi"), track.eta(), track.phi()); + histos.fill(HIST("dcaXYvspT"), track.dcaXY(), track.pt()); + et += std::sqrt(std::pow(track.pt(), 2.) + std::pow(o2::constants::physics::MassPionCharged, 2.)); + meanpt += track.pt(); + } + histos.fill(HIST("zPos"), collision.posZ()); + histos.fill(HIST("T0Ccent"), collision.centFT0C()); + histos.fill(HIST("ZNCcvsZNCsum"), sumZNC / cfgCollisionEnergy, zdc.energyCommonZNC() / cfgCollisionEnergy); + histos.fill(HIST("ZNAcvsZNAsum"), sumZNA / cfgCollisionEnergy, zdc.energyCommonZNA() / cfgCollisionEnergy); + histos.fill(HIST("ZPCcvsZPCsum"), sumZPC / cfgCollisionEnergy, zdc.energyCommonZPC() / cfgCollisionEnergy); + histos.fill(HIST("ZPAcvsZPAsum"), sumZPA / cfgCollisionEnergy, zdc.energyCommonZPA() / cfgCollisionEnergy); + histos.fill(HIST("GlbTracks"), glbTracks); + + // Neutron ZDC + histos.fill(HIST("ZNA"), znA); + histos.fill(HIST("ZNC"), znC); + histos.fill(HIST("ZNASector"), sumZNA / cfgCollisionEnergy); + histos.fill(HIST("ZNCSector"), sumZNC / cfgCollisionEnergy); + histos.fill(HIST("ZN"), znA + znC); + histos.fill(HIST("ZNVsZEM"), sumZEMs, sumZNs); + histos.fill(HIST("ZNCVstdc"), tZNC, znC); + histos.fill(HIST("ZNAVstdc"), tZNA, znA); + histos.fill(HIST("ZPCVstdc"), tZPC, zpC); + histos.fill(HIST("ZNVsFT0A"), aT0A / 100., sumZNs); + histos.fill(HIST("ZNVsFT0C"), aT0C / 100., sumZNs); + histos.fill(HIST("ZNVsFT0M"), (aT0A + aT0C) / 100., sumZNs); + + // Proton ZDC + if (!isOneNeutronFound || znA >= oneNeutron) { + histos.fill(HIST("ZPA"), zpA); + histos.fill(HIST("ZPASector"), sumZPA / cfgCollisionEnergy); + histos.fill(HIST("ZPAVstdc"), tZPA, zpA); + histos.fill(HIST("ZPAvsCent"), cent, zpA); + if (std::isfinite(zpA) && !std::isnan(zpA) && + cent >= minT0CcentCut && cent < maxT0CcentCut) { + histos.fill(HIST("pZPAvsFT0Ccent"), cent, zpA); + } + } + if (!isOneNeutronFound || znC >= oneNeutron) { + histos.fill(HIST("ZPC"), zpC); + histos.fill(HIST("ZPCSector"), sumZPC / cfgCollisionEnergy); + histos.fill(HIST("ZPCvsCent"), cent, zpC); + if (std::isfinite(zpC) && !std::isnan(zpC) && + cent >= minT0CcentCut && cent < maxT0CcentCut) { + histos.fill(HIST("pZPCvsFT0Ccent"), cent, zpC); + } + } + + // ZDC Correlations + histos.fill(HIST("ZNAVsZNC"), znC, znA); + histos.fill(HIST("ZNAVsZPA"), zpA, znA); + histos.fill(HIST("ZNCVsZPC"), zpC, znC); + histos.fill(HIST("ZPAVsZPC"), zpC, zpA); + histos.fill(HIST("ZEM1Vstdc"), tZEM1, aZEM1); + histos.fill(HIST("ZEM2Vstdc"), tZEM2, aZEM2); + histos.fill(HIST("debunch"), tZDCdif, tZDCsum); + + if (sumZNs > znBasedCut) { + return; + } + histos.fill(HIST("NchVsFV0A"), aV0A / 100., glbTracks); + histos.fill(HIST("NchVsFT0A"), aT0A / 100., glbTracks); + histos.fill(HIST("NchVsFT0C"), aT0C / 100., glbTracks); + histos.fill(HIST("NchVsFT0M"), (aT0A + aT0C) / 100., glbTracks); + + histos.fill(HIST("NchVsEt"), et, glbTracks); + histos.fill(HIST("NchVsITStracks"), itsTracks, glbTracks); + histos.fill(HIST("ZNAVsNch"), glbTracks, znA); + histos.fill(HIST("ZNCVsNch"), glbTracks, znC); + histos.fill(HIST("ZNVsNch"), glbTracks, sumZNs); + histos.fill(HIST("ZNDifVsNch"), glbTracks, znA - znC); + if (glbTracks >= minNchSel) { + histos.fill(HIST("NchVsMeanPt"), glbTracks, meanpt / glbTracks); + } + } + + void processZdcCollAssoc( + AodCollisions::iterator const& collision, + AodTracks const& tracks, + BCsRun3 const& /*bcs*/, + aod::Zdcs const& /*zdcs*/, + aod::FT0s const& /*ft0s*/) + { + if (!isEventSelected(collision)) { + return; + } + const auto& foundBC = collision.foundBC_as(); + if (!foundBC.has_zdc()) { + return; + } + int nTot = tracks.size(); + double ft0aAmp = 0; + double ft0cAmp = 0; + if (collision.has_foundFT0()) { + auto ft0 = collision.foundFT0(); + for (const auto& amplitude : ft0.amplitudeA()) { + ft0aAmp += amplitude; + } + for (const auto& amplitude : ft0.amplitudeC()) { + ft0cAmp += amplitude; + } + } + const double normT0M{(ft0aAmp + ft0aAmp) / 100.}; + + const auto& zdcread = foundBC.zdc(); + const auto cent = collision.centFT0C(); + + // ZDC data and histogram filling + float znA = zdcread.amplitudeZNA(); + float znC = zdcread.amplitudeZNC(); + float zpA = zdcread.amplitudeZPA(); + float zpC = zdcread.amplitudeZPC(); + float tZNA{zdcread.timeZNA()}; + float tZNC{zdcread.timeZNC()}; + float tZPA{zdcread.timeZPA()}; + float tZPC{zdcread.timeZPC()}; + float tZDCdif{tZNC + tZPC - tZNA - tZPA}; + float tZDCsum{tZNC + tZPC + tZNA + tZPA}; + float sumZNC = (zdcread.energySectorZNC())[0] + (zdcread.energySectorZNC())[1] + (zdcread.energySectorZNC())[2] + (zdcread.energySectorZNC())[3]; + float sumZNA = (zdcread.energySectorZNA())[0] + (zdcread.energySectorZNA())[1] + (zdcread.energySectorZNA())[2] + (zdcread.energySectorZNA())[3]; + float sumZPC = (zdcread.energySectorZPC())[0] + (zdcread.energySectorZPC())[1] + (zdcread.energySectorZPC())[2] + (zdcread.energySectorZPC())[3]; + float sumZPA = (zdcread.energySectorZPA())[0] + (zdcread.energySectorZPA())[1] + (zdcread.energySectorZPA())[2] + (zdcread.energySectorZPA())[3]; + float sumZDC = sumZPA + sumZPC + sumZNA + sumZNC; + float sumZEM = zdcread.amplitudeZEM1() + zdcread.amplitudeZEM2(); + znA /= cfgCollisionEnergy; + znC /= cfgCollisionEnergy; + zpA /= cfgCollisionEnergy; + zpC /= cfgCollisionEnergy; + float sumZNs{znA + znC}; + float sumZPs{zpA + zpC}; + // TDC cut + if (isTDCcut) { + if (std::sqrt(std::pow(tZDCdif, 2.) + std::pow(tZDCsum, 2.)) > tdcCut) { + return; + } + histos.fill(HIST("hEventCounter"), EvCutLabel::Tdc); + } + // ZEM cut + if (isZEMcut) { + if (sumZEM < zemCut) { + return; + } + } + // common energies + float commonSumZnc = (zdcread.energyCommonZNC()); + float commonSumZna = (zdcread.energyCommonZNA()); + float commonSumZpc = (zdcread.energyCommonZPC()); + float commonSumZpa = (zdcread.energyCommonZPA()); + float sumZN = (sumZNC) + (sumZNA); + float sumZP = (sumZPC) + (sumZPA); + + int itsTracks = 0, glbTracks = 0; + for (const auto& track : tracks) { + // Track Selection + if (track.hasITS()) { + itsTracks++; + } + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + histos.fill(HIST("ZposVsEta"), collision.posZ(), track.eta()); + histos.fill(HIST("EtaVsPhi"), track.eta(), track.phi()); + histos.fill(HIST("dcaXYvspT"), track.dcaXY(), track.pt()); + glbTracks++; + } + bool skipEvent{false}; + if (useMidRapNchSel) { + auto hMeanNch = ccdb->getForTimeStamp(paTHmeanNch.value, foundBC.timestamp()); + auto hSigmaNch = ccdb->getForTimeStamp(paTHsigmaNch.value, foundBC.timestamp()); + if (!hMeanNch) { + LOGF(info, "hMeanNch NOT LOADED!"); + return; + } + if (!hSigmaNch) { + LOGF(info, "hSigmaNch NOT LOADED!"); + return; + } + const int binT0M{hMeanNch->FindBin(normT0M)}; + const double meanNch{hMeanNch->GetBinContent(binT0M)}; + const double sigmaNch{hSigmaNch->GetBinContent(binT0M)}; + const double nSigmaSelection{nSigmaNchCut * sigmaNch}; + const double diffMeanNch{meanNch - glbTracks}; + if (!(std::abs(diffMeanNch) < nSigmaSelection)) { + histos.fill(HIST("ExcludedEvtVsFT0M"), normT0M); + histos.fill(HIST("ExcludedEvtVsNch"), glbTracks); + } else { + skipEvent = true; + } + } + // Skip event based on number of Nch sigmas + if (!skipEvent) { + return; + } + std::vector vecOneOverEff; + auto efficiency = ccdb->getForTimeStamp(paTHEff.value, foundBC.timestamp()); + if (!efficiency) { + return; + } + // Calculates the Nch multiplicity + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + + float pt{track.pt()}; + float effValue{1.0}; + if (applyEff) { + effValue = efficiency->GetBinContent(efficiency->FindBin(pt)); + } + if (effValue > 0.) { + vecOneOverEff.emplace_back(1. / effValue); + } + } + + double nchMult{0.}; + nchMult = std::accumulate(vecOneOverEff.begin(), vecOneOverEff.end(), 0); + if (!applyEff) + nchMult = static_cast(glbTracks); + if (applyEff && !correctNch) + nchMult = static_cast(glbTracks); + if (nchMult < minNchSel) { + return; + } + histos.get(HIST("ZNvsZEMcoll"))->Fill(zdcread.amplitudeZEM1() + zdcread.amplitudeZEM2(), zdcread.amplitudeZNA() + zdcread.amplitudeZNC()); + histos.get(HIST("ZNAvsZNCcoll"))->Fill(zdcread.amplitudeZNC(), zdcread.amplitudeZNA()); + histos.get(HIST("ZEM1coll"))->Fill(zdcread.amplitudeZEM1()); + histos.get(HIST("ZEM2coll"))->Fill(zdcread.amplitudeZEM2()); + histos.fill(HIST("ZNenergy"), sumZN); + histos.fill(HIST("ZPenergy"), sumZP); + histos.fill(HIST("ZNCenergy"), commonSumZnc); + histos.fill(HIST("ZNAenergy"), commonSumZna); + histos.fill(HIST("ZPAenergy"), commonSumZpa); + histos.fill(HIST("ZPCenergy"), commonSumZpc); + histos.fill(HIST("hZNvsFT0Ccent"), cent, sumZN); + histos.fill(HIST("hZPvsFT0Ccent"), cent, sumZP); + histos.fill(HIST("hZNvsFT0CAmp"), ft0cAmp, sumZN); + histos.fill(HIST("hZPvsFT0CAmp"), ft0cAmp, sumZP); + histos.fill(HIST("hZNvsMult"), nTot, sumZN); + histos.fill(HIST("hZPvsMult"), nTot, sumZP); + histos.fill(HIST("hNchvsNPV"), collision.multNTracksPVeta1(), nTot); + histos.fill(HIST("Nch"), nchMult); + histos.fill(HIST("ZNamp"), sumZNs); + histos.fill(HIST("NchVsZN"), nchMult, sumZNs); + histos.fill(HIST("NchVsZP"), nchMult, sumZPs); + histos.fill(HIST("NITSTacksVsZN"), itsTracks, sumZNs); + histos.fill(HIST("NITSTacksVsZP"), itsTracks, sumZPs); + histos.fill(HIST("T0MVsZN"), normT0M, sumZNs); + histos.fill(HIST("T0MVsZP"), normT0M, sumZPs); + histos.fill(HIST("NchUncorrected"), glbTracks); + + float ratioZN = sumZNC / sumZNA; + float ratioZP = sumZPC / sumZPA; + pZNratiovscent->Fill(cent, ratioZN); + pZPratiovscent->Fill(cent, ratioZP); + pZNvsFT0Ccent->Fill(cent, sumZN); + pZPvsFT0Ccent->Fill(cent, sumZP); + histos.get(HIST("ZDC_energy_vs_ZEM"))->Fill(sumZEM, sumZDC); + } + + void processCorrelation(CollisionDataTable::iterator const& collision, FilTrackDataTable const& tracks) + { + if (!isEventSelected(collision)) { + return; + } + if (std::abs(collision.posZ()) >= vtxRange) { + return; + } + histos.fill(HIST("VtxZHist"), collision.posZ()); + auto nchTracks = 0; + for (const auto& track : tracks) { + if (std::abs(track.eta()) >= etaRange) { + continue; + } + nchTracks++; + } + histos.fill(HIST("GlobalMult_vs_FT0C"), nchTracks, collision.multFT0C()); + } + + PROCESS_SWITCH(FlowZdcTask, processZdcCollAssoc, "Processing ZDC w. collision association", false); + PROCESS_SWITCH(FlowZdcTask, processQA, "Process QA", true); + PROCESS_SWITCH(FlowZdcTask, processCorrelation, "Process correlations", true); + +}; // end of struct function + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/pidcme.cxx b/PWGCF/Flow/Tasks/pidcme.cxx deleted file mode 100644 index 8b4dda3f271..00000000000 --- a/PWGCF/Flow/Tasks/pidcme.cxx +++ /dev/null @@ -1,1029 +0,0 @@ -// 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 ZhengqingWang(zhengqing.wang@cern.ch) -/// \file pidcme.cxx -/// \brief task to calculate the pikp cme signal and bacground. -// C++/ROOT includes. -// o2-linter: disable=name/workflow-file -#include -#include -#include -#include -#include -#include -#include -#include - -// o2Physics includes. -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/StaticFor.h" - -#include "Common/DataModel/Qvectors.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "Common/Core/EventPlaneHelper.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/PIDResponseITS.h" - -#include "CommonConstants/PhysicsConstants.h" - -// o2 includes. - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -namespace o2::aod -{ -namespace cme_track_pid_columns -{ -DECLARE_SOA_COLUMN(NPidFlag, nPidFlag, int8_t); // Flag tracks without proper binning as -1, and indicate type of particle 0->un-Id, 1->pion, 2->kaon, 3->proton -} // namespace cme_track_pid_columns -DECLARE_SOA_TABLE(Flags, "AOD", "Flags", cme_track_pid_columns::NPidFlag); -} // namespace o2::aod - -using TracksPID = soa::Join; -struct FillPIDcolums { - Configurable cfgnSigmaCutTPCPi{"cfgnSigmaCutTPCPi", 3.0, "Value of the TPC Nsigma cut for pions"}; - Configurable cfgnSigmaCutTPCKa{"cfgnSigmaCutTPCKa", 3.0, "Value of the TPC Nsigma cut for kaons"}; - Configurable cfgnSigmaCutTPCPr{"cfgnSigmaCutTPCPr", 3.0, "Value of the TPC Nsigma cut for protons"}; - Configurable cfgnSigmaCutTOFPi{"cfgnSigmaCutTOFPi", 3.0, "Value of the TOF Nsigma cut for pions"}; - Configurable cfgnSigmaCutTOFKa{"cfgnSigmaCutTOFKa", 3.0, "Value of the TOF Nsigma cut for kaons"}; - Configurable cfgnSigmaCutTOFPr{"cfgnSigmaCutTOFPr", 3.0, "Value of the TOF Nsigma cut for protons"}; - Configurable cfgnSigmaCutCombine{"cfgnSigmaCutCombine", 3.0, "Value of the Combined Nsigma cut"}; - Configurable cfgPtMaxforTPCOnlyPID{"cfgPtMaxforTPCOnlyPID", 0.4, "Maxmium track pt for TPC only PID,only when onlyTOF and onlyTOFHIT closed"}; - Configurable cfgMinPtPID{"cfgMinPtPID", 0.15, "Minimum track #P_{t} for PID"}; - Configurable cfgMaxEtaPID{"cfgMaxEtaPID", 0.8, "Maximum track #eta for PID"}; - Configurable cfgnSigmaCutITSPi{"cfgnSigmaCutITSPi", 3.0, "Value of the ITS Nsigma cut for Pions"}; - Configurable cfgnSigmaCutITSKa{"cfgnSigmaCutITSKa", 2.5, "Value of the ITS Nsigma cut for Kaons"}; - Configurable cfgnSigmaCutITSPr{"cfgnSigmaCutITSPr", 2.0, "Value of the ITS Nsigma cut for Protons"}; - Configurable cfgAveClusSizeCoslMinPi{"cfgAveClusSizeCoslMinPi", 0, "Base line for minmum ITS cluster size x cos(#lambda) for Pions"}; - Configurable cfgAveClusSizeCoslMaxPi{"cfgAveClusSizeCoslMaxPi", 1e9, "Base line for maxmum ITS cluster size x cos(#lambda) for Pions"}; - Configurable cfgAveClusSizeCoslMinKa{"cfgAveClusSizeCoslMinKa", 0, "Base line for minmum ITS cluster size x cos(#lambda) for Kaons"}; - Configurable cfgAveClusSizeCoslMaxKa{"cfgAveClusSizeCoslMaxKa", 1e9, "Base line for maxmum ITS cluster size x cos(#lambda) for Kaons"}; - Configurable cfgAveClusSizeCoslMinPr{"cfgAveClusSizeCoslMinPr", 0, "Base line for minmum ITS cluster size x cos(#lambda) for Protons"}; - Configurable cfgAveClusSizeCoslMaxPr{"cfgAveClusSizeCoslMaxPr", 1e9, "Base line for maxmum ITS cluster size x cos(#lambda) for Protons"}; - - ConfigurableAxis cfgrigidityBins{"cfgrigidityBins", {200, -10.f, 10.f}, "Binning for rigidity #it{p}^{TPC}/#it{z}"}; - ConfigurableAxis cfgdedxBins{"cfgdedxBins", {1000, 0.f, 1000.f}, "Binning for dE/dx"}; - ConfigurableAxis cfgnSigmaBins{"cfgnSigmaBins", {200, -5.f, 5.f}, "Binning for n sigma"}; - ConfigurableAxis cfgnSigmaBinsCom{"cfgnSigmaBinsCom", {100, 0.f, 10.f}, "Combination Binning for TPC&TOF nsigma"}; - ConfigurableAxis cfgaxisptPID{"cfgaxisptPID", {24, 0, 12}, "Binning for P_{t} PID"}; - ConfigurableAxis cfgaxispPID{"cfgaxispPID", {50, 0, 5}, "Binning for P PID"}; - ConfigurableAxis cfgaxisAverClusterCosl{"cfgaxisAverClusterCosl", {50, 0, 10}, "Binning for average cluster size x cos(#lambda)"}; - - Configurable onlyTOF{"onlyTOF", false, "only TOF tracks"}; - Configurable onlyTOFHIT{"onlyTOFHIT", false, "accept only TOF hit tracks at high pt"}; - Configurable openITSCut{"openITSCut", true, "open ITSnsigma cut"}; - bool onlyTPC = true; - - static float averageClusterSizeCosl(uint32_t itsClusterSizes, float eta) - { - float average = 0; - int nclusters = 0; - const float cosl = 1. / std::cosh(eta); - - for (int layer = 0; layer < 7; layer++) { - if ((itsClusterSizes >> (layer * 4)) & 0xf) { - nclusters++; - average += (itsClusterSizes >> (layer * 4)) & 0xf; - } - } - if (nclusters == 0) { - return 0; - } - return average * cosl / nclusters; - }; - - template - bool selTrackPid(const TrackType track) - { - if (!(track.pt() > cfgMinPtPID)) - return false; - if (!(std::abs(track.eta()) < cfgMaxEtaPID)) - return false; - if (!track.passedITSNCls()) - return false; - if (!track.passedITSChi2NDF()) - return false; - if (!track.passedITSHits()) - return false; - if (!track.passedTPCCrossedRowsOverNCls()) - return false; - if (!track.passedTPCChi2NDF()) - return false; - if (!track.passedDCAxy()) - return false; - if (!track.passedDCAz()) - return false; - return true; - } - - template - bool selectionPid(const T& candidate, int8_t PID, float clustersize) - { - if (candidate.pt() > cfgPtMaxforTPCOnlyPID) { - onlyTPC = false; - } - - if (PID == 0) { - if (onlyTOF) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOFPi) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPi()) < cfgnSigmaCutITSPi && clustersize > cfgAveClusSizeCoslMinPi && clustersize < cfgAveClusSizeCoslMaxPi) - return true; - } else { - return true; - } - } - } else if (onlyTOFHIT) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOFPi) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPi()) < cfgnSigmaCutITSPi && clustersize > cfgAveClusSizeCoslMinPi && clustersize < cfgAveClusSizeCoslMaxPi) - return true; - } else { - return true; - } - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPCPi) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPi()) < cfgnSigmaCutITSPi && clustersize > cfgAveClusSizeCoslMinPi && clustersize < cfgAveClusSizeCoslMaxPi) - return true; - } else { - return true; - } - } - } else if (onlyTPC) { - if (std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPCPi) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPi()) < cfgnSigmaCutITSPi && clustersize > cfgAveClusSizeCoslMinPi && clustersize < cfgAveClusSizeCoslMaxPi) - return true; - } else { - return true; - } - } - } else { - if (candidate.hasTOF() && (candidate.tofNSigmaPi() * candidate.tofNSigmaPi() + candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi()) < (cfgnSigmaCutCombine * cfgnSigmaCutCombine)) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPi()) < cfgnSigmaCutITSPi && clustersize > cfgAveClusSizeCoslMinPi && clustersize < cfgAveClusSizeCoslMaxPi) - return true; - } else { - return true; - } - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPCPi) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPi()) < cfgnSigmaCutITSPi && clustersize > cfgAveClusSizeCoslMinPi && clustersize < cfgAveClusSizeCoslMaxPi) - return true; - } else { - return true; - } - } - } - } else if (PID == 1) { - if (onlyTOF) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOFKa) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaKa()) < cfgnSigmaCutITSKa && clustersize > cfgAveClusSizeCoslMinKa && clustersize < cfgAveClusSizeCoslMaxKa) - return true; - } else { - return true; - } - } - } else if (onlyTOFHIT) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOFKa) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaKa()) < cfgnSigmaCutITSKa && clustersize > cfgAveClusSizeCoslMinKa && clustersize < cfgAveClusSizeCoslMaxKa) - return true; - } else { - return true; - } - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPCPi) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaKa()) < cfgnSigmaCutITSKa && clustersize > cfgAveClusSizeCoslMinKa && clustersize < cfgAveClusSizeCoslMaxKa) - return true; - } else { - return true; - } - } - } else if (onlyTPC) { - if (std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPCPi) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaKa()) < cfgnSigmaCutITSKa && clustersize > cfgAveClusSizeCoslMinKa && clustersize < cfgAveClusSizeCoslMaxKa) - return true; - } else { - return true; - } - } - } else { - if (candidate.hasTOF() && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < (cfgnSigmaCutCombine * cfgnSigmaCutCombine)) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaKa()) < cfgnSigmaCutITSKa && clustersize > cfgAveClusSizeCoslMinKa && clustersize < cfgAveClusSizeCoslMaxKa) - return true; - } else { - return true; - } - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPCPi) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaKa()) < cfgnSigmaCutITSKa && clustersize > cfgAveClusSizeCoslMinKa && clustersize < cfgAveClusSizeCoslMaxKa) - return true; - } else { - return true; - } - } - } - } else if (PID == 2) { - if (onlyTOF) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOFPr) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPr()) < cfgnSigmaCutITSPr && clustersize > cfgAveClusSizeCoslMinPr && clustersize < cfgAveClusSizeCoslMaxPr) - return true; - } else { - return true; - } - } - } else if (onlyTOFHIT) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOFPr) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPr()) < cfgnSigmaCutITSPr && clustersize > cfgAveClusSizeCoslMinPr && clustersize < cfgAveClusSizeCoslMaxPr) - return true; - } else { - return true; - } - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPCPr) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPr()) < cfgnSigmaCutITSPr && clustersize > cfgAveClusSizeCoslMinPr && clustersize < cfgAveClusSizeCoslMaxPr) - return true; - } else { - return true; - } - } - } else if (onlyTPC) { - if (std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPCPr) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPr()) < cfgnSigmaCutITSPr && clustersize > cfgAveClusSizeCoslMinPr && clustersize < cfgAveClusSizeCoslMaxPr) - return true; - } else { - return true; - } - } - } else { - if (candidate.hasTOF() && (candidate.tofNSigmaPr() * candidate.tofNSigmaPr() + candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr()) < (cfgnSigmaCutCombine * cfgnSigmaCutCombine)) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPr()) < cfgnSigmaCutITSPr && clustersize > cfgAveClusSizeCoslMinPr && clustersize < cfgAveClusSizeCoslMaxPr) - return true; - } else { - return true; - } - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPCPr) { - if (openITSCut) { - if (std::abs(candidate.itsNSigmaPr()) < cfgnSigmaCutITSPr && clustersize > cfgAveClusSizeCoslMinPr && clustersize < cfgAveClusSizeCoslMaxPr) - return true; - } else { - return true; - } - } - } - } - return false; - } - - HistogramRegistry histosQA{"histosQAPID", {}, OutputObjHandlingPolicy::AnalysisObject}; - - void init(InitContext const&) - { - AxisSpec axisRigidity{cfgrigidityBins, "#it{p}^{TPC}/#it{z}"}; - AxisSpec axisdEdx{cfgdedxBins, "d#it{E}/d#it{x}"}; - AxisSpec axisnSigmaTPC{cfgnSigmaBins, "n_{#sigma}TPC"}; - AxisSpec axisnSigmaTOF{cfgnSigmaBins, "n_{#sigma}TOF"}; - AxisSpec axisnSigmaITS{cfgnSigmaBins, "n_{#sigma}TOF"}; - AxisSpec axisnSigmaCom{cfgnSigmaBinsCom, "hypot(n_{#sigma}TPC,TOF)"}; - AxisSpec axisPtPID{cfgaxisptPID, "#it{p}_{T}"}; - AxisSpec axisPPID{cfgaxispPID, "#it{p}"}; - AxisSpec axisClusterSize{cfgaxisAverClusterCosl, " x "}; - AxisSpec axisPhi = {100, 0, 2.1 * constants::math::PI, "#phi"}; - // TH3D NSigmaTPC,NSigmaTOF,pt - histosQA.add(Form("QA/PID/histnSigma_TPC_TOF_Pi"), "", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaTOF, axisPtPID}}); - histosQA.add(Form("QA/PID/histnSigma_TPC_TOF_Ka"), "", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaTOF, axisPtPID}}); - histosQA.add(Form("QA/PID/histnSigma_TPC_TOF_Pr"), "", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaTOF, axisPtPID}}); - histosQA.add(Form("QA/PID/histnSigma_TPC_TOF_cross_Pi"), "", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaTOF, axisPtPID}}); - histosQA.add(Form("QA/PID/histnSigma_TPC_TOF_cross_Ka"), "", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaTOF, axisPtPID}}); - histosQA.add(Form("QA/PID/histnSigma_TPC_TOF_cross_Pr"), "", {HistType::kTH3F, {axisnSigmaTPC, axisnSigmaTOF, axisPtPID}}); - // Hist for PID Averge Cluster Size - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_Pi"), "", {HistType::kTH1F, {axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_Ka"), "", {HistType::kTH1F, {axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_Pr"), "", {HistType::kTH1F, {axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_cross_Pi"), "", {HistType::kTH1F, {axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_cross_Ka"), "", {HistType::kTH1F, {axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_cross_Pr"), "", {HistType::kTH1F, {axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_Pi"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_Ka"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_Pr"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_cross_Pi"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_cross_Ka"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_P_cross_Pr"), "", {HistType::kTH2F, {axisPPID, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pi"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Ka"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pr"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Pi"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Ka"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSize}}); - histosQA.add(Form("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Pr"), "", {HistType::kTH2F, {axisnSigmaTPC, axisClusterSize}}); - // Hist for Nsigma TPC TOF - histosQA.add(Form("QA/PID/histdEdxTPC_All"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); - histosQA.add(Form("QA/PID/histdEdxTPC_Pi"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); - histosQA.add(Form("QA/PID/histnSigma_Pi"), "", {HistType::kTH1F, {axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histnSigma_Pt_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histdEdxTPC_Ka"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); - histosQA.add(Form("QA/PID/histnSigma_Ka"), "", {HistType::kTH1F, {axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histnSigma_Pt_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histdEdxTPC_Pr"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); - histosQA.add(Form("QA/PID/histnSigma_Pr"), "", {HistType::kTH1F, {axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histnSigma_Pt_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histnSigma_com_Pi"), "", {HistType::kTH1F, {axisnSigmaCom}}); - histosQA.add(Form("QA/PID/histnSigma_com_Ka"), "", {HistType::kTH1F, {axisnSigmaCom}}); - histosQA.add(Form("QA/PID/histnSigma_com_Pr"), "", {HistType::kTH1F, {axisnSigmaCom}}); - histosQA.add(Form("QA/PID/histnSigma_TOF_Pi"), "", {HistType::kTH1F, {axisnSigmaTOF}}); - histosQA.add(Form("QA/PID/histnSigma_TOF_Ka"), "", {HistType::kTH1F, {axisnSigmaTOF}}); - histosQA.add(Form("QA/PID/histnSigma_TOF_Pr"), "", {HistType::kTH1F, {axisnSigmaTOF}}); - histosQA.add(Form("QA/PID/histdEdxTPC_cross_Pi"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); - histosQA.add(Form("QA/PID/histnSigma_cross_Pi"), "", {HistType::kTH1F, {axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histnSigma_Pt_cross_Pi"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histdEdxTPC_cross_Ka"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); - histosQA.add(Form("QA/PID/histnSigma_cross_Ka"), "", {HistType::kTH1F, {axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histnSigma_Pt_cross_Ka"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histdEdxTPC_cross_Pr"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); - histosQA.add(Form("QA/PID/histnSigma_cross_Pr"), "", {HistType::kTH1F, {axisnSigmaTPC}}); - histosQA.add(Form("QA/PID/histnSigma_Pt_cross_Pr"), "", {HistType::kTH2F, {axisPtPID, axisnSigmaTPC}}); - // Hist for nSigma ITS - histosQA.add(Form("QA/PID/histnSigma_ITS_Pi"), "", {HistType::kTH1F, {axisnSigmaITS}}); - histosQA.add(Form("QA/PID/histnSigma_ITS_Ka"), "", {HistType::kTH1F, {axisnSigmaITS}}); - histosQA.add(Form("QA/PID/histnSigma_ITS_Pr"), "", {HistType::kTH1F, {axisnSigmaITS}}); - histosQA.add(Form("QA/PID/histnSigma_ITS_cross_Pi"), "", {HistType::kTH1F, {axisnSigmaITS}}); - histosQA.add(Form("QA/PID/histnSigma_ITS_cross_Ka"), "", {HistType::kTH1F, {axisnSigmaITS}}); - histosQA.add(Form("QA/PID/histnSigma_ITS_cross_Pr"), "", {HistType::kTH1F, {axisnSigmaITS}}); - // Hist for checking the PID phi distribution - histosQA.add(Form("QA/PID/histPhi_Dis_Pi"), "", {HistType::kTH1F, {axisPhi}}); - histosQA.add(Form("QA/PID/histPhi_Dis_Ka"), "", {HistType::kTH1F, {axisPhi}}); - histosQA.add(Form("QA/PID/histPhi_Dis_Pr"), "", {HistType::kTH1F, {axisPhi}}); - histosQA.add(Form("QA/PID/histPhi_Dis_cross_Pi"), "", {HistType::kTH1F, {axisPhi}}); - histosQA.add(Form("QA/PID/histPhi_Dis_cross_Ka"), "", {HistType::kTH1F, {axisPhi}}); - histosQA.add(Form("QA/PID/histPhi_Dis_cross_Pr"), "", {HistType::kTH1F, {axisPhi}}); - } - Produces pidCmeTable; - void process(TracksPID const& tracks) - { - auto tracksWithITSPid = soa::Attach(tracks); - int8_t pidFlag; - for (const auto& track : tracksWithITSPid) { - float averClusSizeCosl = averageClusterSizeCosl(track.itsClusterSizes(), track.eta()); - if (!selTrackPid(track)) { - pidFlag = -1; - } else { - if (selectionPid(track, 0, averClusSizeCosl)) { - histosQA.fill(HIST("QA/PID/histnSigma_TPC_TOF_cross_Pi"), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt()); - histosQA.fill(HIST("QA/PID/histdEdxTPC_cross_Pi"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); - histosQA.fill(HIST("QA/PID/histnSigma_cross_Pi"), track.tpcNSigmaPi()); - histosQA.fill(HIST("QA/PID/histnSigma_Pt_cross_Pi"), track.pt(), track.tpcNSigmaPi()); - histosQA.fill(HIST("QA/PID/histnSigma_ITS_cross_Pi"), track.itsNSigmaPi()); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_cross_Pi"), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_cross_Pi"), track.p(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Pi"), track.tpcNSigmaPi(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histPhi_Dis_cross_Pi"), track.phi()); - } - if (selectionPid(track, 1, averClusSizeCosl)) { - histosQA.fill(HIST("QA/PID/histnSigma_TPC_TOF_cross_Ka"), track.tpcNSigmaKa(), track.tofNSigmaKa(), track.pt()); - histosQA.fill(HIST("QA/PID/histdEdxTPC_cross_Ka"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); - histosQA.fill(HIST("QA/PID/histnSigma_cross_Ka"), track.tpcNSigmaKa()); - histosQA.fill(HIST("QA/PID/histnSigma_Pt_cross_Ka"), track.pt(), track.tpcNSigmaKa()); - histosQA.fill(HIST("QA/PID/histnSigma_ITS_cross_Ka"), track.itsNSigmaKa()); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_cross_Ka"), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_cross_Ka"), track.p(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Ka"), track.tpcNSigmaKa(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histPhi_Dis_cross_Ka"), track.phi()); - } - if (selectionPid(track, 2, averClusSizeCosl)) { - histosQA.fill(HIST("QA/PID/histnSigma_TPC_TOF_cross_Pr"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); - histosQA.fill(HIST("QA/PID/histdEdxTPC_cross_Pr"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); - histosQA.fill(HIST("QA/PID/histnSigma_cross_Pr"), track.tpcNSigmaPr()); - histosQA.fill(HIST("QA/PID/histnSigma_Pt_cross_Pr"), track.pt(), track.tpcNSigmaPr()); - histosQA.fill(HIST("QA/PID/histnSigma_ITS_cross_Pr"), track.itsNSigmaPr()); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_cross_Pr"), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_cross_Pr"), track.p(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_cross_Pr"), track.tpcNSigmaKa(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histPhi_Dis_cross_Pr"), track.phi()); - } - histosQA.fill(HIST("QA/PID/histdEdxTPC_All"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); - float nSigmaArray[3] = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; - pidFlag = 0; - for (int8_t i = 0; i < 3; i++) { - if (selectionPid(track, i, averClusSizeCosl)) - pidFlag = pidFlag * 10 + i + 1; - if (pidFlag > 10) { // If a track is identified as two different tracks. - if (std::abs(nSigmaArray[(pidFlag / 10) - 1]) < std::abs(nSigmaArray[(pidFlag % 10) - 1])) // The track is identified as the particle whose |nsigma| is the least. - pidFlag /= 10; - else - pidFlag %= 10; - } - } - - switch (pidFlag) { - case 1: - histosQA.fill(HIST("QA/PID/histnSigma_TPC_TOF_Pi"), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt()); - histosQA.fill(HIST("QA/PID/histdEdxTPC_Pi"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); - histosQA.fill(HIST("QA/PID/histnSigma_Pi"), track.tpcNSigmaPi()); - histosQA.fill(HIST("QA/PID/histnSigma_Pt_Pi"), track.pt(), track.tpcNSigmaPi()); - histosQA.fill(HIST("QA/PID/histnSigma_com_Pi"), (track.tpcNSigmaPi() * track.tpcNSigmaPi() + track.tofNSigmaPi() * track.tofNSigmaPi())); - histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pi"), track.tofNSigmaPi()); - histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pi"), track.itsNSigmaPi()); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_Pi"), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_Pi"), track.p(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pi"), track.tpcNSigmaPi(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histPhi_Dis_Pi"), track.phi()); - break; - case 2: - histosQA.fill(HIST("QA/PID/histnSigma_TPC_TOF_Ka"), track.tpcNSigmaKa(), track.tofNSigmaKa(), track.pt()); - histosQA.fill(HIST("QA/PID/histdEdxTPC_Ka"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); - histosQA.fill(HIST("QA/PID/histnSigma_Ka"), track.tpcNSigmaKa()); - histosQA.fill(HIST("QA/PID/histnSigma_Pt_Ka"), track.pt(), track.tpcNSigmaKa()); - histosQA.fill(HIST("QA/PID/histnSigma_com_Ka"), (track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa())); - histosQA.fill(HIST("QA/PID/histnSigma_TOF_Ka"), track.tofNSigmaKa()); - histosQA.fill(HIST("QA/PID/histnSigma_ITS_Ka"), track.itsNSigmaKa()); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_Ka"), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_Ka"), track.p(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Ka"), track.tpcNSigmaKa(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histPhi_Dis_Ka"), track.phi()); - break; - case 3: - histosQA.fill(HIST("QA/PID/histnSigma_TPC_TOF_Pr"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); - histosQA.fill(HIST("QA/PID/histdEdxTPC_Pr"), track.sign() * track.tpcInnerParam(), track.tpcSignal()); - histosQA.fill(HIST("QA/PID/histnSigma_Pr"), track.tpcNSigmaPr()); - histosQA.fill(HIST("QA/PID/histnSigma_Pt_Pr"), track.pt(), track.tpcNSigmaPr()); - histosQA.fill(HIST("QA/PID/histnSigma_com_Pr"), (track.tpcNSigmaPr() * track.tpcNSigmaPr() + track.tofNSigmaPr() * track.tofNSigmaPr())); - histosQA.fill(HIST("QA/PID/histnSigma_TOF_Pr"), track.tofNSigmaPr()); - histosQA.fill(HIST("QA/PID/histnSigma_ITS_Pr"), track.itsNSigmaPr()); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_Pr"), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_P_Pr"), track.p(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histAverClusterSizeCosl_nSigmaTPC_Pr"), track.tpcNSigmaPr(), averClusSizeCosl); - histosQA.fill(HIST("QA/PID/histPhi_Dis_Pr"), track.phi()); - break; - } - } - pidCmeTable(pidFlag); - } - } -}; - -struct pidcme { // o2-linter: disable=name/struct - HistogramRegistry histosQA{"histosmain", {}, OutputObjHandlingPolicy::AnalysisObject}; - - Configurable> cfgnMods{"cfgnMods", {2}, "Modulation of interest"}; - Configurable cfgDetName{"cfgDetName", "FT0C", "The name of detector to be analyzed"}; - Configurable cfgRefAName{"cfgRefAName", "TPCpos", "The name of detector for reference A"}; - Configurable cfgRefBName{"cfgRefBName", "TPCneg", "The name of detector for reference B"}; - - Configurable cfgnTotalSystem{"cfgnTotalSystem", 7, "total qvector number"}; - - Configurable cfgMinPt{"cfgMinPt", 0.15, "Minimum transverse momentum for charged track"}; - Configurable cfgMaxEta{"cfgMaxEta", 0.8, "Maximum pseudorapidiy for charged track"}; - Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.1, "Maximum transverse DCA"}; - Configurable cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 1.0, "Maximum longitudinal DCA"}; - - ConfigurableAxis cfgaxisQvecF{"cfgaxisQvecF", {300, -1, 1}, ""}; - ConfigurableAxis cfgaxisQvec{"cfgaxisQvec", {100, -3, 3}, ""}; - ConfigurableAxis cfgaxisCent{"cfgaxisCent", {100, 0, 100}, ""}; - - ConfigurableAxis cfgaxiscos{"cfgaxiscos", {102, -1.02, 1.02}, ""}; - ConfigurableAxis cfgaxispt{"cfgaxispt", {100, 0, 10}, ""}; - ConfigurableAxis cfgaxisCentMerged{"cfgaxisCentMerged", {20, 0, 100}, ""}; - - ConfigurableAxis cfgaxissumpt{"cfgaxissumpt", {7, 1, 8}, "Binning for #gamma and #delta pt(particle1 + particle2)"}; - ConfigurableAxis cfgaxisdeltaeta{"cfgaxisdeltaeta", {5, 0, 1}, "Binning for #gamma and #delta |#eta(particle1 - particle2)|"}; - - Configurable cfgkOpeanCME{"cfgkOpeanCME", true, "open PID CME"}; - Configurable cfgkOpeanPiPi{"cfgkOpeanPiPi", true, "open Pi-Pi"}; - Configurable cfgkOpeanKaKa{"cfgkOpeanKaKa", false, "open Ka-Ka"}; - Configurable cfgkOpeanPrPr{"cfgkOpeanPrPr", false, "open Pr-Pr"}; - Configurable cfgkOpeanPiKa{"cfgkOpeanPiKa", true, "open Pi-Ka"}; - Configurable cfgkOpeanPiPr{"cfgkOpeanPiPr", true, "open Pi-Pr"}; - Configurable cfgkOpeanKaPr{"cfgkOpeanKaPr", true, "open Ka-Pr"}; - Configurable cfgkOpeanHaHa{"cfgkOpeanHaHa", false, "open Ha-Ha"}; - - EventPlaneHelper helperEP; - SliceCache cache; - - unsigned int mult1, mult2, mult3; - int detId; - int refAId; - int refBId; - - template - int getDetId(const T& name) - { - if (name.value == "BPos" || name.value == "BNeg" || name.value == "BTot") { - LOGF(warning, "Using deprecated label: %s. Please use TPCpos, TPCneg, TPCall instead.", name.value); - } - if (name.value == "FT0C") { - return 0; - } else if (name.value == "FT0A") { - return 1; - } else if (name.value == "FT0M") { - return 2; - } else if (name.value == "FV0A") { - return 3; - } else if (name.value == "TPCpos" || name.value == "BPos") { - return 4; - } else if (name.value == "TPCneg" || name.value == "BNeg") { - return 5; - } else if (name.value == "TPCall" || name.value == "BTot") { - return 6; - } else { - return 0; - } - } - - Filter col = aod::evsel::sel8 == true; - Filter collisionFilter = (nabs(aod::collision::posZ) < 10.f); - Filter ptfilter = aod::track::pt > cfgMinPt; - Filter etafilter = aod::track::eta < cfgMaxEta; - Filter properPIDfilter = aod::cme_track_pid_columns::nPidFlag != -1; - - Partition>> tracksSet1 = aod::cme_track_pid_columns::nPidFlag == 1; - Partition>> tracksSet2 = aod::cme_track_pid_columns::nPidFlag == 2; - Partition>> tracksSet3 = aod::cme_track_pid_columns::nPidFlag == 3; - void init(InitContext const&) - { - - detId = getDetId(cfgDetName); - refAId = getDetId(cfgRefAName); - refBId = getDetId(cfgRefBName); - - if (detId == refAId || detId == refBId || refAId == refBId) { - LOGF(info, "Wrong detector configuration \n The FT0C will be used to get Q-Vector \n The TPCpos and TPCneg will be used as reference systems"); - detId = 0; - refAId = 4; - refBId = 5; - } - - AxisSpec axisCent{cfgaxisCent, "centrality"}; - AxisSpec axisQvec{cfgaxisQvec, "Q"}; - AxisSpec axisQvecF{cfgaxisQvecF, "Q"}; - AxisSpec axisEvtPl = {100, -1.0 * constants::math::PI, constants::math::PI}; - - AxisSpec axisCos{cfgaxiscos, "angle function"}; - AxisSpec axisPt{cfgaxispt, "trasverse momentum"}; - AxisSpec axisCentMerged{cfgaxisCentMerged, "merged centrality"}; - - AxisSpec axissumpt{cfgaxissumpt, "#it{p}_{T}^{sum}}"}; - AxisSpec axisdeltaeta{cfgaxisdeltaeta, "#Delta#eta"}; - AxisSpec axisvertexz = {100, -15., 15., "vrtx_{Z} [cm]"}; - - histosQA.add(Form("QA/histEventCount"), "", {HistType::kTH1F, {{2, 0.0, 2.0}}}); - histosQA.get(HIST("QA/histEventCount"))->GetXaxis()->SetBinLabel(1, "Not selected events"); - histosQA.get(HIST("QA/histEventCount"))->GetXaxis()->SetBinLabel(2, "Selected events"); - histosQA.add(Form("QA/histVertexZRec"), "", {HistType::kTH1F, {axisvertexz}}); - histosQA.add(Form("QA/histCentrality"), "", {HistType::kTH1F, {axisCent}}); - histosQA.add(Form("QA/histQvec_CorrL0_V2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); - histosQA.add(Form("QA/histQvec_CorrL1_V2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); - histosQA.add(Form("QA/histQvec_CorrL2_V2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); - histosQA.add(Form("QA/histQvec_CorrL3_V2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); - histosQA.add(Form("QA/histEvtPl_CorrL0_V2"), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); - histosQA.add(Form("QA/histEvtPl_CorrL1_V2"), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); - histosQA.add(Form("QA/histEvtPl_CorrL2_V2"), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); - histosQA.add(Form("QA/histEvtPl_CorrL3_V2"), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); - histosQA.add(Form("QA/histQvecRes_SigRefAV2"), "", {HistType::kTH2F, {axisQvecF, axisCent}}); - histosQA.add(Form("QA/histQvecRes_SigRefBV2"), "", {HistType::kTH2F, {axisQvecF, axisCent}}); - histosQA.add(Form("QA/histQvecRes_RefARefBV2"), "", {HistType::kTH2F, {axisQvecF, axisCent}}); - - histosQA.add(Form("V2/histCosDetV2"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); - histosQA.add(Form("V2/histSinDetV2"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); - - histosQA.add(Form("V2/PID/histCosDetV2_Pi"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); - histosQA.add(Form("V2/PID/histCosDetV2_Ka"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); - histosQA.add(Form("V2/PID/histCosDetV2_Pr"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); - histosQA.add(Form("V2/PID/histCosDetV2_Pi_Neg"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); - histosQA.add(Form("V2/PID/histCosDetV2_Ka_Neg"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); - histosQA.add(Form("V2/PID/histCosDetV2_Pr_Neg"), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); - - if (cfgkOpeanCME) { - if (cfgkOpeanPiPi) { - histosQA.add(Form("PIDCME/histgamama_PiPi_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histgamama_PiPi_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_PiPi_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_PiPi_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/Differential/histgamama_PiPi_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histgamama_PiPi_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_PiPi_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_PiPi_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - } - if (cfgkOpeanKaKa) { - histosQA.add(Form("PIDCME/histgamama_KaKa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histgamama_KaKa_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_KaKa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_KaKa_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/Differential/histgamama_KaKa_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histgamama_KaKa_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_KaKa_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_KaKa_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - } - if (cfgkOpeanPrPr) { - histosQA.add(Form("PIDCME/histgamama_PrPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histgamama_PrPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_PrPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_PrPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/Differential/histgamama_PrPr_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histgamama_PrPr_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_PrPr_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_PrPr_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - } - if (cfgkOpeanPiKa) { - histosQA.add(Form("PIDCME/histgamama_PiKa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histgamama_PiKa_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_PiKa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_PiKa_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/Differential/histgamama_PiKa_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histgamama_PiKa_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_PiKa_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_PiKa_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - } - if (cfgkOpeanPiPr) { - histosQA.add(Form("PIDCME/histgamama_PiPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histgamama_PiPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_PiPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_PiPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/Differential/histgamama_PiPr_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histgamama_PiPr_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_PiPr_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_PiPr_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - } - if (cfgkOpeanKaPr) { - histosQA.add(Form("PIDCME/histgamama_KaPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histgamama_KaPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_KaPr_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_KaPr_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/Differential/histgamama_KaPr_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histgamama_KaPr_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_KaPr_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_KaPr_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - } - if (cfgkOpeanHaHa) { - histosQA.add(Form("PIDCME/histgamama_HaHa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histgamama_HaHa_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_HaHa_ss"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/histdelta_HaHa_os"), "", {HistType::kTProfile, {axisCentMerged}}); - histosQA.add(Form("PIDCME/Differential/histgamama_HaHa_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histgamama_HaHa_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_HaHa_ss_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - histosQA.add(Form("PIDCME/Differential/histdelta_HaHa_os_Dif"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); - } - } - } - - template - bool selEvent(const CollType& collision) - { - if (!collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { - return 0; - } - if (!collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { - return 0; - } - if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - return 0; - } - return 1; - } - - template - bool selTrack(const TrackType track) - { - if (!track.passedITSNCls()) - return false; - if (!track.passedITSChi2NDF()) - return false; - if (!track.passedITSHits()) - return false; - if (!track.passedTPCCrossedRowsOverNCls()) - return false; - if (!track.passedTPCChi2NDF()) - return false; - if (!track.passedDCAxy()) - return false; - if (!track.passedDCAz()) - return false; - return true; - } - - template - void fillHistosQvec(const CollType& collision, int nmode) - { - int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); - int refAInd = refAId * 4 + cfgnTotalSystem * 4 * (nmode - 2); - int refBInd = refBId * 4 + cfgnTotalSystem * 4 * (nmode - 2); - if (nmode == 2) { - if (collision.qvecAmp()[detId] > 1e-8) { - histosQA.fill(HIST("QA/histQvec_CorrL0_V2"), collision.qvecRe()[detInd], collision.qvecIm()[detInd], collision.centFT0C()); - histosQA.fill(HIST("QA/histQvec_CorrL1_V2"), collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], collision.centFT0C()); - histosQA.fill(HIST("QA/histQvec_CorrL2_V2"), collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], collision.centFT0C()); - histosQA.fill(HIST("QA/histQvec_CorrL3_V2"), collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], collision.centFT0C()); - histosQA.fill(HIST("QA/histEvtPl_CorrL0_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode), collision.centFT0C()); - histosQA.fill(HIST("QA/histEvtPl_CorrL1_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], nmode), collision.centFT0C()); - histosQA.fill(HIST("QA/histEvtPl_CorrL2_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], nmode), collision.centFT0C()); - histosQA.fill(HIST("QA/histEvtPl_CorrL3_V2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), collision.centFT0C()); - } - if (collision.qvecAmp()[detId] > 1e-8 && collision.qvecAmp()[refAId] > 1e-8 && collision.qvecAmp()[refBId] > 1e-8) { - histosQA.fill(HIST("QA/histQvecRes_SigRefAV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), nmode), collision.centFT0C()); - histosQA.fill(HIST("QA/histQvecRes_SigRefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.centFT0C()); - histosQA.fill(HIST("QA/histQvecRes_RefARefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.centFT0C()); - } - } - } - - template - void fillHistosFlowGammaDelta(const CollType& collision, const TrackType& track1, const TrackType& track2, const TrackType& track3, int nmode) - { - if (collision.qvecAmp()[detId] < 1e-8) { - return; - } - int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); - float psiN = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); - for (const auto& trk : track1) { - if (!selTrack(trk)) - continue; - if (nmode == 2) { - if (trk.sign() > 0) { - histosQA.fill(HIST("V2/PID/histCosDetV2_Pi"), collision.centFT0C(), trk.pt(), - std::cos(static_cast(nmode) * (trk.phi() - psiN))); - } else if (trk.sign() < 0) { - histosQA.fill(HIST("V2/PID/histCosDetV2_Pi_Neg"), collision.centFT0C(), trk.pt(), - std::cos(static_cast(nmode) * (trk.phi() - psiN))); - } - } - } - for (const auto& trk : track2) { - if (!selTrack(trk)) - continue; - if (nmode == 2) { - if (trk.sign() > 0) { - histosQA.fill(HIST("V2/PID/histCosDetV2_Ka"), collision.centFT0C(), trk.pt(), - std::cos(static_cast(nmode) * (trk.phi() - psiN))); - } else if (trk.sign() < 0) { - histosQA.fill(HIST("V2/PID/histCosDetV2_Ka_Neg"), collision.centFT0C(), trk.pt(), - std::cos(static_cast(nmode) * (trk.phi() - psiN))); - } - } - } - for (const auto& trk : track3) { - if (!selTrack(trk)) - continue; - if (nmode == 2) { - if (trk.sign() > 0) { - histosQA.fill(HIST("V2/PID/histCosDetV2_Pr"), collision.centFT0C(), trk.pt(), - std::cos(static_cast(nmode) * (trk.phi() - psiN))); - } else if (trk.sign() < 0) { - histosQA.fill(HIST("V2/PID/histCosDetV2_Pr_Neg"), collision.centFT0C(), trk.pt(), - std::cos(static_cast(nmode) * (trk.phi() - psiN))); - } - } - } - if (cfgkOpeanCME) { - if (cfgkOpeanPiPi) { - for (const auto& trk1 : track1) { - for (const auto& trk2 : track1) { - if (trk1.globalIndex() == trk2.globalIndex()) - continue; - if (nmode == 2) { - if (trk1.sign() == trk2.sign()) { - histosQA.fill(HIST("PIDCME/histgamama_PiPi_ss"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_PiPi_ss"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_PiPi_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPi_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } else { - histosQA.fill(HIST("PIDCME/histgamama_PiPi_os"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_PiPi_os"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_PiPi_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPi_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } - } - } - } - } - if (cfgkOpeanKaKa) { - for (const auto& trk1 : track2) { - for (const auto& trk2 : track2) { - if (trk1.globalIndex() == trk2.globalIndex()) - continue; - if (nmode == 2) { - if (trk1.sign() == trk2.sign()) { - histosQA.fill(HIST("PIDCME/histgamama_KaKa_ss"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_KaKa_ss"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_KaKa_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_KaKa_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } else { - histosQA.fill(HIST("PIDCME/histgamama_KaKa_os"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_KaKa_os"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_KaKa_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_KaKa_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } - } - } - } - } - if (cfgkOpeanPrPr) { - for (const auto& trk1 : track3) { - for (const auto& trk2 : track3) { - if (trk1.globalIndex() == trk2.globalIndex()) - continue; - if (nmode == 2) { - if (trk1.sign() == trk2.sign()) { - histosQA.fill(HIST("PIDCME/histgamama_PrPr_ss"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_PrPr_ss"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_PrPr_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_PrPr_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } else { - histosQA.fill(HIST("PIDCME/histgamama_PrPr_os"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_PrPr_os"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_PrPr_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_PrPr_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } - } - } - } - } - if (cfgkOpeanPiKa) { - for (const auto& trk1 : track1) { - for (const auto& trk2 : track2) { - if (trk1.globalIndex() == trk2.globalIndex()) - continue; - if (nmode == 2) { - if (trk1.sign() == trk2.sign()) { - histosQA.fill(HIST("PIDCME/histgamama_PiKa_ss"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_PiKa_ss"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_PiKa_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_PiKa_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } else { - histosQA.fill(HIST("PIDCME/histgamama_PiKa_os"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_PiKa_os"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_PiKa_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_PiKa_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } - } - } - } - } - if (cfgkOpeanPiPr) { - for (const auto& trk1 : track1) { - for (const auto& trk3 : track3) { - if (trk1.globalIndex() == trk3.globalIndex()) - continue; - if (nmode == 2) { - if (trk1.sign() == trk3.sign()) { - histosQA.fill(HIST("PIDCME/histgamama_PiPr_ss"), collision.centFT0C(), std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_PiPr_ss"), collision.centFT0C(), std::cos((trk1.phi() - trk3.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_PiPr_ss_Dif"), collision.centFT0C(), trk1.pt() + trk3.pt(), std::abs(trk1.eta() - trk3.eta()), - std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPr_ss_Dif"), collision.centFT0C(), trk1.pt() + trk3.pt(), std::abs(trk1.eta() - trk3.eta()), - std::cos((trk1.phi() - trk3.phi()))); - } else { - histosQA.fill(HIST("PIDCME/histgamama_PiPr_os"), collision.centFT0C(), std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_PiPr_os"), collision.centFT0C(), std::cos((trk1.phi() - trk3.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_PiPr_os_Dif"), collision.centFT0C(), trk1.pt() + trk3.pt(), std::abs(trk1.eta() - trk3.eta()), - std::cos((trk1.phi() + trk3.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_PiPr_os_Dif"), collision.centFT0C(), trk1.pt() + trk3.pt(), std::abs(trk1.eta() - trk3.eta()), - std::cos((trk1.phi() - trk3.phi()))); - } - } - } - } - } - if (cfgkOpeanKaPr) { - for (const auto& trk2 : track2) { - for (const auto& trk3 : track3) { - if (trk2.globalIndex() == trk3.globalIndex()) - continue; - if (nmode == 2) { - if (trk2.sign() == trk3.sign()) { - histosQA.fill(HIST("PIDCME/histgamama_KaPr_ss"), collision.centFT0C(), std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_KaPr_ss"), collision.centFT0C(), std::cos((trk2.phi() - trk3.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_KaPr_ss_Dif"), collision.centFT0C(), trk2.pt() + trk3.pt(), std::abs(trk2.eta() - trk3.eta()), - std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_KaPr_ss_Dif"), collision.centFT0C(), trk2.pt() + trk3.pt(), std::abs(trk2.eta() - trk3.eta()), - std::cos((trk2.phi() - trk3.phi()))); - } else { - histosQA.fill(HIST("PIDCME/histgamama_KaPr_os"), collision.centFT0C(), std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/histdelta_KaPr_os"), collision.centFT0C(), std::cos((trk2.phi() - trk3.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_KaPr_os_Dif"), collision.centFT0C(), trk2.pt() + trk3.pt(), std::abs(trk2.eta() - trk3.eta()), - std::cos((trk2.phi() + trk3.phi() - static_cast(nmode) * psiN))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_KaPr_os_Dif"), collision.centFT0C(), trk2.pt() + trk3.pt(), std::abs(trk2.eta() - trk3.eta()), - std::cos((trk2.phi() - trk3.phi()))); - } - } - } - } - } - } - } - - void process(soa::Filtered>::iterator const& collision, soa::Filtered> const& tracks) - { - histosQA.fill(HIST("QA/histEventCount"), 0.5); - if (!selEvent(collision)) { - return; - } - histosQA.fill(HIST("QA/histEventCount"), 1.5); - histosQA.fill(HIST("QA/histCentrality"), collision.centFT0C()); - histosQA.fill(HIST("QA/histVertexZRec"), collision.posZ()); - auto tracks1 = tracksSet1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto tracks2 = tracksSet2->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto tracks3 = tracksSet3->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - mult1 = tracks1.size(); - mult2 = tracks2.size(); - mult3 = tracks3.size(); - if (mult1 < 1 || mult2 < 1 || mult3 < 1) // Reject Collisions without sufficient particles - return; - for (auto i = 0; i < static_cast(cfgnMods->size()); i++) { - int detIndGlobal = detId * 4 + cfgnTotalSystem * 4 * (cfgnMods->at(i) - 2); - float psiNGlobal = helperEP.GetEventPlane(collision.qvecRe()[detIndGlobal + 3], collision.qvecIm()[detIndGlobal + 3], cfgnMods->at(i)); - for (const auto& trk : tracks) { - if (!selTrack(trk)) - continue; - histosQA.fill(HIST("V2/histSinDetV2"), collision.centFT0C(), trk.pt(), - std::sin(static_cast(cfgnMods->at(i)) * (trk.phi() - psiNGlobal))); - histosQA.fill(HIST("V2/histCosDetV2"), collision.centFT0C(), trk.pt(), - std::cos(static_cast(cfgnMods->at(i)) * (trk.phi() - psiNGlobal))); - } - if (cfgkOpeanCME && cfgkOpeanHaHa && cfgnMods->at(i) == 2) { - for (const auto& trk1 : tracks) { - for (const auto& trk2 : tracks) { - if (trk1.globalIndex() == trk2.globalIndex()) - continue; - if (trk1.sign() == trk2.sign()) { - histosQA.fill(HIST("PIDCME/histgamama_HaHa_ss"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); - histosQA.fill(HIST("PIDCME/histdelta_HaHa_ss"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_HaHa_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_HaHa_ss_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } else { - histosQA.fill(HIST("PIDCME/histgamama_HaHa_os"), collision.centFT0C(), std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); - histosQA.fill(HIST("PIDCME/histdelta_HaHa_os"), collision.centFT0C(), std::cos((trk1.phi() - trk2.phi()))); - histosQA.fill(HIST("PIDCME/Differential/histgamama_HaHa_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() + trk2.phi() - static_cast(cfgnMods->at(i)) * psiNGlobal))); - histosQA.fill(HIST("PIDCME/Differential/histdelta_HaHa_os_Dif"), collision.centFT0C(), trk1.pt() + trk2.pt(), std::abs(trk1.eta() - trk2.eta()), - std::cos((trk1.phi() - trk2.phi()))); - } - } - } - } - fillHistosQvec(collision, cfgnMods->at(i)); - fillHistosFlowGammaDelta(collision, tracks1, tracks2, tracks3, cfgnMods->at(i)); - } - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - }; -} diff --git a/PWGCF/Flow/Tasks/resonancesGfwFlow.cxx b/PWGCF/Flow/Tasks/resonancesGfwFlow.cxx new file mode 100644 index 00000000000..de9c43aeb88 --- /dev/null +++ b/PWGCF/Flow/Tasks/resonancesGfwFlow.cxx @@ -0,0 +1,1468 @@ +// 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. + +/// \file resonancesGfwFlow.cxx +/// \brief PID flow for resonances using the generic framework +/// \author Preet Bhanjan Pati + +#include "PWGCF/GenericFramework/Core/FlowContainer.h" +#include "PWGCF/GenericFramework/Core/GFW.h" +#include "PWGCF/GenericFramework/Core/GFWConfig.h" +#include "PWGCF/GenericFramework/Core/GFWCumulant.h" +#include "PWGCF/GenericFramework/Core/GFWPowerArray.h" +#include "PWGCF/GenericFramework/Core/GFWWeights.h" +#include "PWGCF/GenericFramework/Core/GFWWeightsList.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/PID.h" +#include "ReconstructionDataFormats/Track.h" +#include + +#include "Math/Vector4D.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace std; + +namespace +{ +std::vector> refV2; +std::vector> phiV2; +std::vector> lsPhiV2; +std::vector> k0V2; +std::vector> lambdaV2; + +std::vector>> refBoot; +std::vector>> phiBoot; +std::vector>> lsPhiBoot; +std::vector>> k0Boot; +std::vector>> lambdaBoot; +} // namespace + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +namespace o2::analysis::genericframework +{ +GFWRegions regions; +GFWCorrConfigs configs; +} // namespace o2::analysis::genericframework + +template +auto projectMatrix(Array2D const& mat, std::array& array1, std::array& array2, std::array& array3) +{ + for (auto j = 0; j < static_cast(mat.cols); ++j) { + array1[j] = mat(0, j); + array2[j] = mat(1, j); + array3[j] = mat(2, j); + } + return; +} +template +auto readMatrix(Array2D const& mat, P& array) +{ + for (auto i = 0; i < static_cast(mat.rows); ++i) { + for (auto j = 0; j < static_cast(mat.cols); ++j) { + array[i][j] = mat(i, j); + } + } + + return; +} + +using namespace o2::analysis::genericframework; + +static constexpr float LongArrayFloat[3][20] = {{1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2}, {2.1, 2.2, 2.3, -2.1, -2.2, -2.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2}, {3.1, 3.2, 3.3, -3.1, -3.2, -3.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2}}; +static constexpr int LongArrayInt[3][20] = {{1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1}, {2, 2, 2, -2, -2, -2, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1}, {3, 3, 3, -3, -3, -3, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1}}; + +struct ResonancesGfwFlow { + o2::aod::ITSResponse itsResponse; + Service ccdb; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + enum OutputSpecies { + K0 = 0, + LAMBDA = 1, + PHI = 2, + ANLAMBDA = 3, + REF = 4, + kCount_OutputSpecies + }; + enum Particles { + PIONS, + KAONS, + PROTONS + }; + enum ParticleCuts { + kCosPA = 0, + kMassMin, + kMassMax, + kPosTrackPt, + kNegTrackPt, + kDCAPosToPVMin, + kDCANegToPVMin, + kLifeTime, + kRadiusMin, + kRadiusMax, + kRapidity + }; + enum ParticleSwitches { + kUseParticle = 0, + kUseCosPA, + kMassBins, + kDCABetDaug, + kUseProperLifetime, + kUseV0Radius + }; + enum EventCutTypes { + kFilteredEvents = 0, + kAfterSel8, + kUseNoTimeFrameBorder, + kUseNoITSROFrameBorder, + kUseNoSameBunchPileup, + kUseGoodZvtxFT0vsPV, + kUseNoCollInTimeRangeStandard, + kUseGoodITSLayersAll, + kUseNoCollInRofStandard, + kUseNoHighMultCollInPrevRof, + kUseOccupancy, + kUseMultCorrCut, + kUseT0AV0ACut, + kUseVertexITSTPC, + kUseTVXinTRD + }; + enum TrackCutTypes { + kFilteredTracks = 0, + kUseGlobalTracks, + kUsePvContributor, + kItsClustersCut, + kHasTpcSignal, + kTpcClustersCut, + kTpcCrossedRowsCut + }; + + O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 3.0f, "Maximal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgTpcCluster, int, 50, "Number of TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgTpcCrossRows, int, 70, "Number of TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgTpcCut, float, 3.0f, "TPC N-sigma cut for pions, kaons, protons") + O2_DEFINE_CONFIGURABLE(cfgTofPtCut, float, 0.5f, "Minimum pt to use TOF N-sigma") + O2_DEFINE_CONFIGURABLE(cfgITScluster, int, 5, "Number of ITS cluster") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyMin, int, 0, "Minimum occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyMax, int, 2000, "Maximum occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgUseGlobalTrack, bool, true, "use Global track") + O2_DEFINE_CONFIGURABLE(cfgFakeKaonCut, float, 0.1f, "Maximum difference in measured momentum and TPC inner ring momentum of particle") + O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 2.0f, "DCAxy range for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "DCAz range for tracks") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, true, "Fill and output NUA weights") + O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiEtaVtxz, bool, true, "Use Phi, Eta, VertexZ dependent NUA weights") + O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiPtCent, bool, false, "Use Phi, Pt, Centrality dependent NUA weights") + O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiEtaPt, bool, false, "Use Phi, Eta, Pt dependent NUA weights") + O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgUseBootStrap, bool, true, "Use bootstrap for error estimation") + O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrUse, bool, true, "Use track density efficiency correction") + O2_DEFINE_CONFIGURABLE(cfgV0AT0Acut, int, 5, "V0AT0A cut") + O2_DEFINE_CONFIGURABLE(cfgUseLsPhi, bool, true, "Use LikeSign for Phi v2") + O2_DEFINE_CONFIGURABLE(cfgUseOnlyTPC, bool, true, "Use only TPC PID for daughter selection") + O2_DEFINE_CONFIGURABLE(cfgUseStrictPID, bool, true, "Use strict PID cuts for TPC") + O2_DEFINE_CONFIGURABLE(cfgUseAsymmetricPID, bool, false, "Use asymmetric PID cuts") + O2_DEFINE_CONFIGURABLE(cfgUseItsPID, bool, true, "Use ITS PID for particle identification") + + Configurable> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector{0.7217476707, 0.7384792571, 0.7542625668, 0.7640680200, 0.7701951667, 0.7755299053, 0.7805901710, 0.7849446786, 0.7957356586, 0.8113039262, 0.8211968966, 0.8280558878, 0.8329342135}, "parameter 0 for track density efficiency correction"}; + Configurable> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector{-2.169488e-05, -2.191913e-05, -2.295484e-05, -2.556538e-05, -2.754463e-05, -2.816832e-05, -2.846502e-05, -2.843857e-05, -2.705974e-05, -2.477018e-05, -2.321730e-05, -2.203315e-05, -2.109474e-05}, "parameter 1 for track density efficiency correction"}; + Configurable> cfgUseEventCuts{"cfgUseEventCuts", std::vector{1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0}, "Switch for various event cuts [Filtered Events, Sel8, kNoTimeFrameBorder, kNoITSROFrameBorder, kNoSameBunchPileup, kIsGoodZvtxFT0vsPV, kNoCollInTimeRangeStandard, kIsGoodITSLayersAll, kNoCollInRofStandard, kNoHighMultCollInPrevRof, Occupancy, Multiplicity correlation, T0AV0A 3 sigma cut, kIsVertexITSTPC, kTVXinTRD]"}; + Configurable> nSigmas{"nSigmas", {LongArrayFloat[0], 3, 6, {"TPC", "TOF", "ITS"}, {"pos_pi", "pos_ka", "pos_pr", "neg_pi", "neg_ka", "neg_pr"}}, "Labeled array for n-sigma values for TPC, TOF, ITS for pions, kaons, protons (positive and negative)"}; + Configurable> resonanceCuts{"resonanceCuts", {LongArrayFloat[0], 3, 11, {"K0", "Lambda", "Phi"}, {"cos_PAs", "massMin", "massMax", "PosTrackPt", "NegTrackPt", "DCAPosToPVMin", "DCANegToPVMin", "Lifetime", "RadiusMin", "RadiusMax", "Rapidity"}}, "Labeled array (float) for various cuts on resonances"}; + Configurable> resonanceSwitches{"resonanceSwitches", {LongArrayInt[0], 3, 6, {"K0", "Lambda", "Phi"}, {"UseParticle", "UseCosPA", "NMassBins", "DCABetDaug", "UseProperLifetime", "UseV0Radius"}}, "Labeled array (int) for various cuts on resonances"}; + + Configurable cfgRegions{"cfgRegions", {{"refN08", "refP08", "refFull", "poiNphi", "poiPphi", "poifullphi", "olNphi", "olPphi", "olfullphi", "poiNk0", "poiPk0", "poifullk0", "olNk0", "olPk0", "olfullk0", "poiNlam", "poiPlam", "poifulllam", "olNlam", "olPlam", "olfulllam", "poiNantilam", "poiPantilam", "poifullantilam", "olNantilam", "olPantilam", "olfullantilam"}, {-0.8, 0.4, -0.8, -0.8, 0.4, -0.8, -0.8, 0.4, -0.8, -0.8, 0.4, -0.8, -0.8, 0.4, -0.8, -0.8, 0.4, -0.8, -0.8, 0.4, -0.8, -0.8, 0.4, -0.8, -0.8, 0.4, -0.8}, {-0.4, 0.8, 0.8, -0.4, 0.8, 0.8, -0.4, 0.8, 0.8, -0.4, 0.8, 0.8, -0.4, 0.8, 0.8, -0.4, 0.8, 0.8, -0.4, 0.8, 0.8, -0.4, 0.8, 0.8, -0.4, 0.8, 0.8}, {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 2, 2, 2, 32, 32, 32, 4, 4, 4, 64, 64, 64, 8, 8, 8, 128, 128, 128, 16, 16, 16, 256, 256, 256}}, "Configurations for GFW regions"}; + Configurable cfgCorrConfig{"cfgCorrConfig", {{"refN08 {2} refP08 {-2}", "refN08 {2 2} refP08 {-2 -2}", "poiNphi refN08 | olNphi {2} refP08 {-2}", "poiNphi refN08 | olNphi {2 2} refP08 {-2 -2}", "poiPphi refP08 | olPphi {2} refN08 {-2}", "poiPphi refP08 | olPphi {2 2} refN08 {-2 -2}", "poiNk0 refN08 | olNk0 {2} refP08 {-2}", "poiNk0 refN08 | olNk0 {2 2} refP08 {-2 -2}", "poiPk0 refP08 | olPk0 {2} refN08 {-2}", "poiPk0 refP08 | olPk0 {2 2} refN08 {-2 -2}", "poiNlam refN08 | olNlam {2} refP08 {-2}", "poiNlam refN08 | olNlam {2 2} refP08 {-2 -2}", "poiPlam refP08 | olPlam {2} refN08 {-2}", "poiPlam refP08 | olPlam {2 2} refN08 {-2 -2}", "poiNantilam refN08 | olNantilam {2} refP08 {-2}", "poiNantilam refN08 | olNantilam {2 2} refP08 {-2 -2}", "poiPantilam refP08 | olPantilam {2} refN08 {-2}", "poiPantilam refP08 | olPantilam {2 2} refN08 {-2 -2}"}, {"Ref08Gap22", "Ref08Gap24", "PhiF08Gap22", "PhiF08Gap24", "PhiB08Gap22", "PhiB08Gap24", "K0F08Gap22", "K0F08Gap24", "K0B08Gap22", "K0B08Gap24", "LamF08Gap22", "LamF08Gap24", "LamB08Gap22", "LamB08Gap24", "AnLamF08Gap22", "AnLamF08Gap24", "AnLamB08Gap22", "AnLamB08Gap24"}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, "Configurations for each correlation to calculate"}; + + // Defining configurable axis + ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for histograms"}; + ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; + ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.20, 1.40, 1.60, 1.80, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00, 3.50, 4.00, 5.00, 6.00, 8.00, 10.00}, "pt axis for histograms"}; + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "centrality axis for histograms"}; + ConfigurableAxis axisNsigmaTPC{"axisNsigmaTPC", {80, -5, 5}, "nsigmaTPC axis"}; + ConfigurableAxis axisNsigmaTOF{"axisNsigmaTOF", {80, -5, 5}, "nsigmaTOF axis"}; + ConfigurableAxis axisParticles{"axisParticles", {3, 0, 3}, "axis for different hadrons"}; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter trackFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtPOIMin) && (aod::track::pt < cfgCutPtPOIMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); + + using AodCollisions = soa::Filtered>; + using AodTracksWithoutBayes = soa::Filtered>; + using V0TrackCandidate = aod::V0Datas; + + SliceCache cache; + Partition posTracks = aod::track::signed1Pt > 0.0f; + Partition negTracks = aod::track::signed1Pt < 0.0f; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + std::array, 3> resoCutVals; + std::array, 3> resoSwitchVals; + std::array tofNsigmaCut; + std::array itsNsigmaCut; + std::array tpcNsigmaCut; + std::vector eventCuts; + + GFW* fGFW = new GFW(); + std::vector corrconfigs; + TAxis* fPtAxis; + TAxis* fPhiMassAxis; + TAxis* fK0MassAxis; + TAxis* fLambdaMassAxis; + TRandom3* fRndm = new TRandom3(0); + + std::vector mAcceptance; + bool correctionsLoaded = false; + + // local track density correction + std::vector funcEff; + TH1D* hFindPtBin; + TF1* funcV2; + TF1* funcV3; + TF1* funcV4; + + // Additional Event selection cuts - Copy from flowGenericFramework.cxx + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fMultMultPVCut = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + + void init(InitContext const&) + { + int64_t noLaterThan = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + + // Initilizing ccdb + ccdb->setURL(ccdbUrl.value); + ccdb->setCaching(true); + ccdb->setCreatedNotAfter(noLaterThan); + + LOGF(info, "flowGenericFramework::init()"); + regions.SetNames(cfgRegions->GetNames()); + regions.SetEtaMin(cfgRegions->GetEtaMin()); + regions.SetEtaMax(cfgRegions->GetEtaMax()); + regions.SetpTDifs(cfgRegions->GetpTDifs()); + regions.SetBitmasks(cfgRegions->GetBitmasks()); + configs.SetCorrs(cfgCorrConfig->GetCorrs()); + configs.SetHeads(cfgCorrConfig->GetHeads()); + configs.SetpTDifs(cfgCorrConfig->GetpTDifs()); + configs.SetpTCorrMasks(cfgCorrConfig->GetpTCorrMasks()); + regions.Print(); + configs.Print(); + + projectMatrix(nSigmas->getData(), tpcNsigmaCut, tofNsigmaCut, itsNsigmaCut); + readMatrix(resonanceCuts->getData(), resoCutVals); + readMatrix(resonanceSwitches->getData(), resoSwitchVals); + eventCuts = cfgUseEventCuts; + + AxisSpec singleCount = {1, 0, 1}; + AxisSpec axisK0Mass = {resoSwitchVals[K0][kMassBins], resoCutVals[K0][kMassMin], resoCutVals[K0][kMassMax]}; + AxisSpec axisLambdaMass = {resoSwitchVals[LAMBDA][kMassBins], resoCutVals[LAMBDA][kMassMin], resoCutVals[LAMBDA][kMassMax]}; + AxisSpec axisPhiMass = {resoSwitchVals[PHI][kMassBins], resoCutVals[PHI][kMassMin], resoCutVals[PHI][kMassMax]}; + + histos.add("hVtxZ", "", {HistType::kTH1D, {axisVertex}}); + histos.add("hMult", "", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); + histos.add("hCent", "", {HistType::kTH1D, {{90, 0, 90}}}); + + refBoot.resize(cfgNbootstrap); + phiBoot.resize(cfgNbootstrap); + lsPhiBoot.resize(cfgNbootstrap); + k0Boot.resize(cfgNbootstrap); + lambdaBoot.resize(cfgNbootstrap); + + // Defining histograms to store correlations + for (auto i = 0; i < configs.GetSize(); ++i) { + if (resoSwitchVals[PHI][kUseParticle] && configs.GetHeads()[i].starts_with("Phi")) { + phiV2.push_back(histos.add(Form("h%spt", configs.GetHeads()[i].c_str()), "", {HistType::kTProfile3D, {axisPt, axisPhiMass, axisMultiplicity}})); + if (cfgUseBootStrap) { + for (int j = 0; j < cfgNbootstrap; ++j) { + phiBoot[j].push_back(histos.add(Form("BootStrap/h%spt_boot_%d", configs.GetHeads()[i].c_str(), j), "", {HistType::kTProfile3D, {axisPt, axisPhiMass, axisMultiplicity}})); + } + } // end of bootstrap condition + } // end of phi loop + + if (cfgUseLsPhi && configs.GetHeads()[i].starts_with("LsPhi")) { + lsPhiV2.push_back(histos.add(Form("h%spt", configs.GetHeads()[i].c_str()), "", {HistType::kTProfile3D, {axisPt, axisPhiMass, axisMultiplicity}})); + if (cfgUseBootStrap) { + for (int j = 0; j < cfgNbootstrap; ++j) { + phiBoot[j].push_back(histos.add(Form("BootStrap/h%spt_boot_%d", configs.GetHeads()[i].c_str(), j), "", {HistType::kTProfile3D, {axisPt, axisPhiMass, axisMultiplicity}})); + } + } // end of bootstrap condition + } + if (resoSwitchVals[K0][kUseParticle] && configs.GetHeads()[i].starts_with("K0")) { + k0V2.push_back(histos.add(Form("h%spt", configs.GetHeads()[i].c_str()), "", {HistType::kTProfile3D, {axisPt, axisK0Mass, axisMultiplicity}})); + if (cfgUseBootStrap) { + for (int j = 0; j < cfgNbootstrap; ++j) { + k0Boot[j].push_back(histos.add(Form("BootStrap/h%spt_boot_%d", configs.GetHeads()[i].c_str(), j), "", {HistType::kTProfile3D, {axisPt, axisK0Mass, axisMultiplicity}})); + } + } // end of bootstrap condition + } // end of K0 loop + + if (resoSwitchVals[LAMBDA][kUseParticle] && (configs.GetHeads()[i].starts_with("Lam") || configs.GetHeads()[i].starts_with("AnLam"))) { + lambdaV2.push_back(histos.add(Form("h%spt", configs.GetHeads()[i].c_str()), "", {HistType::kTProfile3D, {axisPt, axisLambdaMass, axisMultiplicity}})); + if (cfgUseBootStrap) { + for (int j = 0; j < cfgNbootstrap; ++j) { + lambdaBoot[j].push_back(histos.add(Form("BootStrap/h%spt_boot_%d", configs.GetHeads()[i].c_str(), j), "", {HistType::kTProfile3D, {axisPt, axisLambdaMass, axisMultiplicity}})); + } + } // end of bootstrap condition + } // end of lambda loop + + if (configs.GetHeads()[i].starts_with("Ref")) { + refV2.push_back(histos.add(Form("h%s", configs.GetHeads()[i].c_str()), "", {HistType::kTProfile, {axisMultiplicity}})); + if (cfgUseBootStrap) { + for (int j = 0; j < cfgNbootstrap; ++j) { + refBoot[j].push_back(histos.add(Form("BootStrap/h%s_boot_%d", configs.GetHeads()[i].c_str(), j), "", {HistType::kTProfile, {axisMultiplicity}})); + } + } // end of bootstrap condition + } // end of ref loop + + } // end of configs loop + + if (cfgUseLsPhi) { + histos.add("hLsPhiMass_sparse", "", {HistType::kTHnSparseD, {{axisPhiMass, axisPt, axisMultiplicity}}}); + } + + if (resoSwitchVals[PHI][kUseParticle]) { + histos.add("KaPlusTPC", "", {HistType::kTH2D, {{axisPt, axisNsigmaTPC}}}); + histos.add("KaMinusTPC", "", {HistType::kTH2D, {{axisPt, axisNsigmaTPC}}}); + histos.add("KaPlusTOF", "", {HistType::kTH2D, {{axisPt, axisNsigmaTOF}}}); + histos.add("KaMinusTOF", "", {HistType::kTH2D, {{axisPt, axisNsigmaTOF}}}); + histos.add("hPhiPhi", "", {HistType::kTH1D, {axisPhi}}); + histos.add("hPhiEta", "", {HistType::kTH1D, {axisEta}}); + histos.add("hPhiMass_sparse", "", {HistType::kTHnSparseD, {{axisPhiMass, axisPt, axisMultiplicity}}}); + + histos.add("hPhiCount", "Number of Phi;; Count", {HistType::kTH1D, {{5, 0, 5}}}); + histos.get(HIST("hPhiCount"))->GetXaxis()->SetBinLabel(1, "Phi candidates"); + histos.get(HIST("hPhiCount"))->GetXaxis()->SetBinLabel(2, "Daughter track selection"); + histos.get(HIST("hPhiCount"))->GetXaxis()->SetBinLabel(3, "Fake Kaon"); + histos.get(HIST("hPhiCount"))->GetXaxis()->SetBinLabel(4, "CosPA"); + histos.get(HIST("hPhiCount"))->GetXaxis()->SetBinLabel(5, "Rapidity cut"); + } + if (resoSwitchVals[K0][kUseParticle]) { + histos.add("PiPlusTPC_K0", "", {HistType::kTH2D, {{axisPt, axisNsigmaTPC}}}); + histos.add("PiMinusTPC_K0", "", {HistType::kTH2D, {{axisPt, axisNsigmaTPC}}}); + histos.add("PiPlusTOF_K0", "", {HistType::kTH2D, {{axisPt, axisNsigmaTOF}}}); + histos.add("PiMinusTOF_K0", "", {HistType::kTH2D, {{axisPt, axisNsigmaTOF}}}); + histos.add("hK0Phi", "", {HistType::kTH1D, {axisPhi}}); + histos.add("hK0Eta", "", {HistType::kTH1D, {axisEta}}); + histos.add("hK0Mass_sparse", "", {HistType::kTHnSparseF, {{axisK0Mass, axisPt, axisMultiplicity}}}); + histos.add("hK0s", "", {HistType::kTH1D, {singleCount}}); + + histos.add("hK0Count", "Number of K0;; Count", {HistType::kTH1D, {{10, 0, 10}}}); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(1, "K0 candidates"); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(2, "Daughter pt"); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(3, "Mass cut"); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(4, "Rapidity cut"); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(5, "DCA to PV"); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(6, "DCA between daughters"); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(7, "V0radius"); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(8, "CosPA"); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(9, "Proper lifetime"); + histos.get(HIST("hK0Count"))->GetXaxis()->SetBinLabel(10, "Daughter track selection"); + } + if (resoSwitchVals[LAMBDA][kUseParticle]) { + histos.add("PrPlusTPC_L", "", {HistType::kTH2D, {{axisPt, axisNsigmaTPC}}}); + histos.add("PiMinusTPC_L", "", {HistType::kTH2D, {{axisPt, axisNsigmaTPC}}}); + histos.add("PrPlusTOF_L", "", {HistType::kTH2D, {{axisPt, axisNsigmaTOF}}}); + histos.add("PiMinusTOF_L", "", {HistType::kTH2D, {{axisPt, axisNsigmaTOF}}}); + histos.add("hLambdaPhi", "", {HistType::kTH1D, {axisPhi}}); + histos.add("hLambdaEta", "", {HistType::kTH1D, {axisEta}}); + histos.add("hLambdaMass_sparse", "", {HistType::kTHnSparseF, {{axisLambdaMass, axisPt, axisMultiplicity}}}); + histos.add("PiPlusTPC_AL", "", {HistType::kTH2D, {{axisPt, axisNsigmaTPC}}}); + histos.add("PrMinusTPC_AL", "", {HistType::kTH2D, {{axisPt, axisNsigmaTPC}}}); + histos.add("PiPlusTOF_AL", "", {HistType::kTH2D, {{axisPt, axisNsigmaTOF}}}); + histos.add("PrMinusTOF_AL", "", {HistType::kTH2D, {{axisPt, axisNsigmaTOF}}}); + histos.add("hAntiLambdaPhi", "", {HistType::kTH1D, {axisPhi}}); + histos.add("hAntiLambdaEta", "", {HistType::kTH1D, {axisEta}}); + histos.add("hAntiLambdaMass_sparse", "", {HistType::kTHnSparseF, {{axisLambdaMass, axisPt, axisMultiplicity}}}); + histos.add("hLambdas", "", {HistType::kTH1D, {singleCount}}); + + histos.add("hLambdaCount", "Number of Lambda;; Count", {HistType::kTH1D, {{10, 0, 10}}}); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(1, "Lambda candidates"); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(2, "Daughter pt"); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(3, "Mass cut"); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(4, "Rapidity cut"); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(5, "DCA to PV"); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(6, "DCA between daughters"); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(7, "V0radius"); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(8, "CosPA"); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(9, "Proper lifetime"); + histos.get(HIST("hLambdaCount"))->GetXaxis()->SetBinLabel(10, "Daughter track selection"); + } + + histos.add("hEventCount", "Number of Events;; Count", {HistType::kTH1D, {{15, -0.5, 14.5}}}); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kFilteredEvents + 1, "Filtered event"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kAfterSel8 + 1, "After sel8"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoTimeFrameBorder + 1, "kNoTimeFrameBorder"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoITSROFrameBorder + 1, "kNoITSROFrameBorder"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoSameBunchPileup + 1, "kNoSameBunchPileup"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoCollInRofStandard + 1, "kNoCollInTimeRangeStandard"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseGoodITSLayersAll + 1, "kIsGoodITSLayersAll"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoCollInRofStandard + 1, "kNoCollInRofStandard"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoHighMultCollInPrevRof + 1, "kNoHighMultCollInPrevRof"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseOccupancy + 1, "Occupancy Cut"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseMultCorrCut + 1, "Multiplicity correlation Cut"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseT0AV0ACut + 1, "T0AV0A cut"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseVertexITSTPC + 1, "kIsVertexITSTPC"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseTVXinTRD + 1, "kTVXinTRD"); + + histos.add("hTrackCount", "Number of Tracks;; Count", {HistType::kTH1D, {{7, -0.5, 6.5}}}); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kFilteredTracks + 1, "Filtered track"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kUseGlobalTracks + 1, "Global tracks"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kUsePvContributor + 1, "PV contributor"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kItsClustersCut + 1, "ITS clusters"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kHasTpcSignal + 1, "TPC signal"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kTpcClustersCut + 1, "TPC clusters"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kTpcCrossedRowsCut + 1, "TPC crossed rows"); + + if (cfgOutputNUAWeights) { + histos.add("NUA/hPhiEtaVtxz_ref", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, {40, -10, 10}}}); + histos.add("NUA/hPhiEtaVtxz_k0", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, {40, -10, 10}}}); + histos.add("NUA/hPhiEtaVtxz_lambda", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, {40, -10, 10}}}); + histos.add("NUA/hPhiEtaVtxz_anlambda", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, {40, -10, 10}}}); + histos.add("NUA/hPhiEtaVtxz_phi", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, {40, -10, 10}}}); + + histos.add("NUA/hPhiPtCent_ref", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, {20, 0, 100}}}); + histos.add("NUA/hPhiPtCent_k0", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, {20, 0, 100}}}); + histos.add("NUA/hPhiPtCent_lambda", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, {20, 0, 100}}}); + histos.add("NUA/hPhiPtCent_anlambda", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, {20, 0, 100}}}); + histos.add("NUA/hPhiPtCent_phi", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, {20, 0, 100}}}); + + histos.add("NUA/hPhiEtaPt_ref", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, axisPt}}); + histos.add("NUA/hPhiEtaPt_k0", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, axisPt}}); + histos.add("NUA/hPhiEtaPt_lambda", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, axisPt}}); + histos.add("NUA/hPhiEtaPt_anlambda", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, axisPt}}); + histos.add("NUA/hPhiEtaPt_phi", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, {64, -1.6, 1.6}, axisPt}}); + } + + o2::framework::AxisSpec axis = axisPt; + int nPtBins = axis.binEdges.size() - 1; + double* ptBins = &(axis.binEdges)[0]; + fPtAxis = new TAxis(nPtBins, ptBins); + + fPhiMassAxis = new TAxis(resoSwitchVals[PHI][kMassBins], resoCutVals[PHI][kMassMin], resoCutVals[PHI][kMassMax]); + fK0MassAxis = new TAxis(resoSwitchVals[K0][kMassBins], resoCutVals[K0][kMassMin], resoCutVals[K0][kMassMax]); + fLambdaMassAxis = new TAxis(resoSwitchVals[LAMBDA][kMassBins], resoCutVals[LAMBDA][kMassMin], resoCutVals[LAMBDA][kMassMax]); + + int nPhisPtMassBins = nPtBins * resoSwitchVals[PHI][kMassBins]; + int nK0sPtMassBins = nPtBins * resoSwitchVals[K0][kMassBins]; + int nLambdasPtMassBins = nPtBins * resoSwitchVals[LAMBDA][kMassBins]; + int nPtMassBins; + + //********** Defining the regions ********** + for (auto i(0); i < regions.GetSize(); ++i) { + if (regions.GetNames()[i].ends_with("phi")) { + nPtMassBins = nPhisPtMassBins; + } else if (regions.GetNames()[i].ends_with("k0")) { + nPtMassBins = nK0sPtMassBins; + } else if (regions.GetNames()[i].ends_with("lam") || regions.GetNames()[i].ends_with("antilam")) { + nPtMassBins = nLambdasPtMassBins; + } else { + nPtMassBins = nPtBins; + } + fGFW->AddRegion(regions.GetNames()[i], regions.GetEtaMin()[i], regions.GetEtaMax()[i], (regions.GetpTDifs()[i]) ? nPtMassBins + 1 : 1, regions.GetBitmasks()[i]); + } + + //********** Defining the correlations ************ + for (auto i = 0; i < configs.GetSize(); ++i) { + corrconfigs.push_back(fGFW->GetCorrelatorConfig(configs.GetCorrs()[i], configs.GetHeads()[i], configs.GetpTDifs()[i])); + } + if (corrconfigs.empty()) + LOGF(error, "Configuration contains vectors of different size - check the GFWCorrConfig configurable"); + fGFW->CreateRegions(); + + // Multiplicity correlation cuts + if (eventCuts[kUseMultCorrCut]) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + + fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + } + if (eventCuts[kUseT0AV0ACut]) { + fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } + + // Track density correction + if (cfgTrackDensityCorrUse) { + std::vector pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0}; + hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]); + funcEff.resize(pTEffBins.size() - 1); + // LHC24g3 Eff + std::vector f1p0 = cfgTrackDensityP0; + std::vector f1p1 = cfgTrackDensityP1; + for (uint ifunc = 0; ifunc < pTEffBins.size() - 1; ifunc++) { + funcEff[ifunc] = new TF1(Form("funcEff%i", ifunc), "[0]+[1]*x", 0, 3000); + funcEff[ifunc]->SetParameters(f1p0[ifunc], f1p1[ifunc]); + } + funcV2 = new TF1("funcV2", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV2->SetParameters(0.0186111, 0.00351907, -4.38264e-05, 1.35383e-07, -3.96266e-10); + funcV3 = new TF1("funcV3", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV3->SetParameters(0.0174056, 0.000703329, -1.45044e-05, 1.91991e-07, -1.62137e-09); + funcV4 = new TF1("funcV4", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV4->SetParameters(0.008845, 0.000259668, -3.24435e-06, 4.54837e-08, -6.01825e-10); + } + } + + template + int findComponent(std::vector>& ptr, const std::string& name) + { + int nIndex = -1; + for (int i = 0; i < static_cast(ptr.size()); i++) { + if (ptr[i]->GetName() == name) { + nIndex = i; + } + } + + return nIndex; + } + + void fillProfileBoot(const GFW::CorrConfig& corrconf, std::shared_ptr profile, const double& cent) + { + double dnx, val; + if (!corrconf.pTDif) { + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) + return; + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) + profile->Fill(cent, val, dnx); + return; + } + return; + } + + void fillProfileBoot3D(const GFW::CorrConfig& corrconf, std::shared_ptr profile, const double& cent, TAxis* partaxis) + { + double dnx, val; + for (int i = 1; i <= fPtAxis->GetNbins(); i++) { + for (int j = 1; j <= partaxis->GetNbins(); j++) { + dnx = fGFW->Calculate(corrconf, ((i - 1) * partaxis->GetNbins()) + (j - 1), kTRUE).real(); + if (dnx == 0) + continue; + val = fGFW->Calculate(corrconf, ((i - 1) * partaxis->GetNbins()) + (j - 1), kFALSE).real() / dnx; + if (std::fabs(val) < 1) + profile->Fill(fPtAxis->GetBinCenter(i), partaxis->GetBinCenter(j), cent, val, dnx); + } + } + return; + } + + // Cosine pointing angle cut + template + double cosinePointingAngle(const TTrack1& track1, const TTrack2& track2) + { + double pt1, pt2, pz1, pz2, p1, p2, angle; + pt1 = track1.pt(); + pt2 = track2.pt(); + pz1 = track1.pz(); + pz2 = track2.pz(); + p1 = track1.p(); + p2 = track2.p(); + angle = std::acos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); + + return angle; + } + + template + bool isFakeKaon(TTrack const& track) + { + const auto pglobal = track.p(); + const auto ptpc = track.tpcInnerParam(); + if (std::abs(pglobal - ptpc) > cfgFakeKaonCut) { + return true; + } + return false; + } + + template + bool isGoodTrack(const TTrack& track) + { + histos.fill(HIST("hTrackCount"), kFilteredTracks); // Filtered tracks + + if (cfgUseGlobalTrack && !(track.isGlobalTrack())) { + return 0; + } + histos.fill(HIST("hTrackCount"), kUseGlobalTracks); // After global track selection + + if (!(track.isPVContributor())) { + return 0; + } + histos.fill(HIST("hTrackCount"), kUsePvContributor); // After PV contributor selection + + if (!(track.itsNCls() > cfgITScluster)) { + return 0; + } + histos.fill(HIST("hTrackCount"), kItsClustersCut); // After ITS cluster selection + + if (!(track.hasTPC())) { + return 0; + } + histos.fill(HIST("hTrackCount"), kHasTpcSignal); // If track has TPC signal + + if (!(track.tpcNClsFound() > cfgTpcCluster)) { + return 0; + } + histos.fill(HIST("hTrackCount"), kTpcClustersCut); // After TPC cluster selection + + if (!(track.tpcNClsCrossedRows() > cfgTpcCrossRows)) { + return 0; + } + histos.fill(HIST("hTrackCount"), kTpcCrossedRowsCut); // After TPC crossed rows selection + + return 1; + } + + template + int getNsigmaPIDTpcTof(TTrack track) + { + // Computing Nsigma arrays for pion, kaon, and protons + std::array nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; + std::array nSigmaCombined = {std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi()), std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa()), std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr())}; + int pid = -1; + float nsigma = cfgTpcCut; + + // Choose which nSigma to use + std::array nSigmaToUse = (track.pt() > cfgTofPtCut && track.hasTOF()) ? nSigmaCombined : nSigmaTPC; + if (track.pt() > cfgTofPtCut && !track.hasTOF()) + return 0; + + const int numSpecies = 3; + int pidCount = 0; + // Select particle with the lowest nsigma + for (int i = 0; i < numSpecies; ++i) { + if (std::abs(nSigmaToUse[i]) < nsigma) { + if (pidCount > 0 && cfgUseStrictPID) + return 0; // more than one particle with low nsigma + + pidCount++; + pid = i; + if (!cfgUseStrictPID) + nsigma = std::abs(nSigmaToUse[i]); + } + } + return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton + } + + template + int getNsigmaPIDAssymmetric(TTrack track) + { + // Computing Nsigma arrays for pion, kaon, and protons + std::array nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; + std::array nSigmaTOF = {track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()}; + std::array nSigmaITS = {itsResponse.nSigmaITS(track), itsResponse.nSigmaITS(track), itsResponse.nSigmaITS(track)}; + int pid = -1; + + std::array nSigmaToUse = cfgUseItsPID ? nSigmaITS : nSigmaTPC; // Choose which nSigma to use: TPC or ITS + std::array detectorNsigmaCut = cfgUseItsPID ? itsNsigmaCut : tpcNsigmaCut; // Choose which nSigma to use: TPC or ITS + + bool isPion, isKaon, isProton; + bool isDetectedPion = nSigmaToUse[0] < detectorNsigmaCut[0] && nSigmaToUse[0] > detectorNsigmaCut[0 + 3]; + bool isDetectedKaon = nSigmaToUse[1] < detectorNsigmaCut[1] && nSigmaToUse[1] > detectorNsigmaCut[1 + 3]; + bool isDetectedProton = nSigmaToUse[2] < detectorNsigmaCut[2] && nSigmaToUse[2] > detectorNsigmaCut[2 + 3]; + + bool isTofPion = nSigmaTOF[0] < tofNsigmaCut[0] && nSigmaTOF[0] > tofNsigmaCut[0 + 3]; + bool isTofKaon = nSigmaTOF[1] < tofNsigmaCut[1] && nSigmaTOF[1] > tofNsigmaCut[1 + 3]; + bool isTofProton = nSigmaTOF[2] < tofNsigmaCut[2] && nSigmaTOF[2] > tofNsigmaCut[2 + 3]; + + if (track.pt() > cfgTofPtCut && !track.hasTOF()) { + return 0; + } else if (track.pt() > cfgTofPtCut && track.hasTOF()) { + isPion = isTofPion && isDetectedPion; + isKaon = isTofKaon && isDetectedKaon; + isProton = isTofProton && isDetectedProton; + } else { + isPion = isDetectedPion; + isKaon = isDetectedKaon; + isProton = isDetectedProton; + } + + if ((isPion && isKaon) || (isPion && isProton) || (isKaon && isProton)) { + return 0; // more than one particle satisfy the criteria + } + + if (isPion) { + pid = PIONS; + } else if (isKaon) { + pid = KAONS; + } else if (isProton) { + pid = PROTONS; + } else { + return 0; // no particle satisfies the criteria + } + + return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton + } + + void loadCorrections(aod::BCsWithTimestamps::iterator const& bc) + { + if (correctionsLoaded) + return; + if (!cfgAcceptance.value.empty()) { + uint64_t timestamp = bc.timestamp(); + mAcceptance.clear(); + mAcceptance.resize(kCount_OutputSpecies); + + mAcceptance[K0] = ccdb->getForTimeStamp(cfgAcceptance.value + "_k0", timestamp); + if (mAcceptance[K0]) + LOGF(info, "Loaded acceptance weights from %s_k0 (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[K0]); + else + LOGF(fatal, "Could not load acceptance weights from %s_k0 (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[K0]); + + mAcceptance[LAMBDA] = ccdb->getForTimeStamp(cfgAcceptance.value + "_lambda", timestamp); + if (mAcceptance[LAMBDA]) + LOGF(info, "Loaded acceptance weights from %s_lambda (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[LAMBDA]); + else + LOGF(fatal, "Could not load acceptance weights from %s_lambda (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[LAMBDA]); + + mAcceptance[PHI] = ccdb->getForTimeStamp(cfgAcceptance.value + "_phi", timestamp); + if (mAcceptance[PHI]) + LOGF(info, "Loaded acceptance weights from %s_phi (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[PHI]); + else + LOGF(fatal, "Could not load acceptance weights from %s_phi (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[PHI]); + + mAcceptance[ANLAMBDA] = ccdb->getForTimeStamp(cfgAcceptance.value + "_anlambda", timestamp); + if (mAcceptance[ANLAMBDA]) + LOGF(info, "Loaded acceptance weights from %s_anlambda (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[ANLAMBDA]); + else + LOGF(fatal, "Could not load acceptance weights from %s_anlambda (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[ANLAMBDA]); + + mAcceptance[REF] = ccdb->getForTimeStamp(cfgAcceptance.value + "_ref", timestamp); + if (mAcceptance[REF]) + LOGF(info, "Loaded acceptance weights from %s_ref (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[REF]); + else + LOGF(fatal, "Could not load acceptance weights from %s_ref (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[REF]); + } + + correctionsLoaded = true; + } + + template + double getAcceptance(TTrack track, const TCollision collision, int pid_index_reso) + { // 0 = k0, 1 = lambda, 2 = phi, 3 = anti-lambda, 4 = ref + if (pid_index_reso < 0 || pid_index_reso >= kCount_OutputSpecies) { + return 1; + } + + double wacc = 1; + double cent = collision.centFT0C(); + double vtxz = collision.posZ(); + + if ((cfgUseWeightPhiEtaVtxz && cfgUseWeightPhiPtCent) || (cfgUseWeightPhiEtaPt && cfgUseWeightPhiPtCent) || (cfgUseWeightPhiEtaVtxz && cfgUseWeightPhiEtaPt)) { + LOGF(fatal, "Only one of the three weight options can be used at a time"); + } + if (!mAcceptance.empty() && correctionsLoaded) { + if (!mAcceptance[pid_index_reso]) { + LOGF(fatal, "Acceptance weights not loaded for pidIndex %d", pid_index_reso); + return 1; + } + if (cfgUseWeightPhiEtaVtxz) + wacc = mAcceptance[pid_index_reso]->getNUA(track.phi(), track.eta(), vtxz); + if (cfgUseWeightPhiPtCent) + wacc = mAcceptance[pid_index_reso]->getNUA(track.phi(), track.pt(), cent); + if (cfgUseWeightPhiEtaPt) + wacc = mAcceptance[pid_index_reso]->getNUA(track.phi(), track.eta(), track.pt()); + } + return wacc; + } + + template + double getAcceptancePhi(vector mom, const TCollision collision, int pid_index_reso) + { // 0 = k0, 1 = lambda, 2 = phi, 3 = anti-lambda, 4 = ref + if (pid_index_reso < 0 || pid_index_reso >= kCount_OutputSpecies) { + return 1; + } + + double wacc = 1; + double cent = collision.centFT0C(); + double vtxz = collision.posZ(); + double phi = mom.Phi(); + phi = RecoDecay::constrainAngle(phi, 0.0, 1); // constrain azimuthal angle to [0,2pi] + + if ((cfgUseWeightPhiEtaVtxz && cfgUseWeightPhiPtCent) || (cfgUseWeightPhiEtaPt && cfgUseWeightPhiPtCent) || (cfgUseWeightPhiEtaVtxz && cfgUseWeightPhiEtaPt)) { + LOGF(fatal, "Only one of the three weight options can be used at a time"); + } + if (!mAcceptance.empty() && correctionsLoaded) { + if (!mAcceptance[pid_index_reso]) { + LOGF(fatal, "Acceptance weights not loaded for pidIndex %d", pid_index_reso); + return 1; + } + if (cfgUseWeightPhiEtaVtxz) + wacc = mAcceptance[pid_index_reso]->getNUA(phi, mom.Eta(), vtxz); + if (cfgUseWeightPhiPtCent) + wacc = mAcceptance[pid_index_reso]->getNUA(phi, mom.Pt(), cent); + if (cfgUseWeightPhiEtaPt) + wacc = mAcceptance[pid_index_reso]->getNUA(phi, mom.Eta(), mom.Pt()); + } + return wacc; + } + + template + void fillWeights(const TTrack track, const TCollision collision, const int& pid_index_reso) + { + double cent = collision.centFT0C(); + double vtxz = collision.posZ(); + double pt = track.pt(); + bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtMin < pt) && (pt < cfgCutPtMax); // within RF pT range + + if (withinPtRef && pid_index_reso == REF) { + histos.fill(HIST("NUA/hPhiEtaVtxz_ref"), track.phi(), track.eta(), vtxz); // pt-subset of charged particles for ref flow + histos.fill(HIST("NUA/hPhiPtCent_ref"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_ref"), track.phi(), track.eta(), track.pt()); + } + + if (withinPtPOI) { + switch (pid_index_reso) { + case K0: + histos.fill(HIST("NUA/hPhiEtaVtxz_k0"), track.phi(), track.eta(), vtxz); // K0 weights + histos.fill(HIST("NUA/hPhiPtCent_k0"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_k0"), track.phi(), track.eta(), track.pt()); + break; + case LAMBDA: + histos.fill(HIST("NUA/hPhiEtaVtxz_lambda"), track.phi(), track.eta(), vtxz); // Lambda weights + histos.fill(HIST("NUA/hPhiPtCent_lambda"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_lambda"), track.phi(), track.eta(), track.pt()); + break; + case ANLAMBDA: + histos.fill(HIST("NUA/hPhiEtaVtxz_anlambda"), track.phi(), track.eta(), vtxz); // Anti-Lambda weights + histos.fill(HIST("NUA/hPhiPtCent_anlambda"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_anlambda"), track.phi(), track.eta(), track.pt()); + break; + // Phi weights are filled in the resurrectPhi function + } + } + } + + template + bool selectionV0Daughter(TTrack const& track, int pid) + { + if (!(track.itsNCls() > cfgITScluster)) + return 0; + if (!track.hasTPC()) + return false; + if (track.tpcNClsFound() < cfgTpcCluster) + return false; + if (!(track.tpcNClsCrossedRows() > cfgTpcCrossRows)) + return 0; + + if (cfgUseOnlyTPC) { + if (pid == PIONS && std::abs(track.tpcNSigmaPi()) > cfgTpcCut) + return false; + if (pid == KAONS && std::abs(track.tpcNSigmaKa()) > cfgTpcCut) + return false; + if (pid == PROTONS && std::abs(track.tpcNSigmaPr()) > cfgTpcCut) + return false; + } else { + int partIndex = cfgUseAsymmetricPID ? getNsigmaPIDAssymmetric(track) : getNsigmaPIDTpcTof(track); + int pidIndex = partIndex - 1; // 0 = pion, 1 = kaon, 2 = proton + if (pidIndex != pid) + return false; + } + + return true; + } + + template + void resurrectPhi(TTrack trackplus, TTrack trackminus, const TCollision collision, vector plusdaug, vector minusdaug, vector mom, double plusmass, const ConstStr& hist) + { + for (auto const& [partplus, partminus] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(trackplus, trackminus))) { + histos.fill(HIST("hPhiCount"), 0.5); + if (!selectionV0Daughter(partplus, KAONS) || !selectionV0Daughter(partminus, KAONS)) // 0 = pion, 1 = kaon, 2 = proton + continue; + histos.fill(HIST("hPhiCount"), 1.5); + + if (isFakeKaon(partplus) || isFakeKaon(partminus)) + continue; + histos.fill(HIST("hPhiCount"), 2.5); + + if (resoSwitchVals[PHI][kUseCosPA] && cosinePointingAngle(partplus, partminus) < resoCutVals[PHI][kCosPA]) + continue; + histos.fill(HIST("hPhiCount"), 3.5); + + histos.fill(HIST("KaPlusTPC"), partplus.pt(), partplus.tpcNSigmaKa()); + histos.fill(HIST("KaPlusTOF"), partplus.pt(), partplus.tofNSigmaKa()); + histos.fill(HIST("KaMinusTPC"), partminus.pt(), partminus.tpcNSigmaKa()); + histos.fill(HIST("KaMinusTOF"), partminus.pt(), partminus.tofNSigmaKa()); + + // Calculation using ROOT vectors + plusdaug = ROOT::Math::PxPyPzMVector(partplus.px(), partplus.py(), partplus.pz(), plusmass); + minusdaug = ROOT::Math::PxPyPzMVector(partminus.px(), partminus.py(), partminus.pz(), plusmass); + mom = plusdaug + minusdaug; + + double pt = mom.Pt(); + double invMass = mom.M(); + double phi = mom.Phi(); + bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtMin < pt) && (pt < cfgCutPtMax); + + phi = RecoDecay::constrainAngle(phi, 0.0, 1); // constrain azimuthal angle to [0,2pi] + + if (std::abs(mom.Rapidity()) < resoCutVals[PHI][kRapidity]) { + histos.fill(HIST("hPhiCount"), 4.5); + + histos.fill(hist, invMass, pt, collision.centFT0C()); + histos.fill(HIST("hPhiPhi"), phi); + histos.fill(HIST("hPhiEta"), mom.Eta()); + + // Fill Phi weights + if (cfgOutputNUAWeights && withinPtPOI) { + histos.fill(HIST("NUA/hPhiEtaVtxz_phi"), phi, mom.Eta(), collision.posZ()); + histos.fill(HIST("NUA/hPhiPtCent_phi"), phi, pt, collision.centFT0C()); + histos.fill(HIST("NUA/hPhiEtaPt_phi"), phi, mom.Eta(), pt); + } + double weff = 1; + double waccPOI = getAcceptancePhi(mom, collision, PHI); + + if (withinPtPOI) + fGFW->Fill(mom.Eta(), ((fPtAxis->FindBin(pt) - 1) * fPhiMassAxis->GetNbins()) + (fPhiMassAxis->FindBin(invMass) - 1), phi, weff * waccPOI, 2); + if (withinPtPOI && withinPtRef) + fGFW->Fill(mom.Eta(), ((fPtAxis->FindBin(pt) - 1) * fPhiMassAxis->GetNbins()) + (fPhiMassAxis->FindBin(invMass) - 1), phi, weff * waccPOI, 32); + } + } // end of combinations loop + return; + } + + template + void likeSignPhi(TTrack track, const TCollision collision, double plusmass, const ConstStr& hist) + { + ROOT::Math::PxPyPzMVector daug1, daug2, mom; + for (auto const& [part1, part2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(track, track))) { + + if (!selectionV0Daughter(part1, KAONS) || !selectionV0Daughter(part2, KAONS)) // 0 = pion, 1 = kaon, 2 = proton + continue; + if (isFakeKaon(part1) || isFakeKaon(part2)) + continue; + + // Calculation using ROOT vectors + daug1 = ROOT::Math::PxPyPzMVector(part1.px(), part1.py(), part1.pz(), plusmass); + daug2 = ROOT::Math::PxPyPzMVector(part2.px(), part2.py(), part2.pz(), plusmass); + mom = daug1 + daug2; + + double pt = mom.Pt(); + double invMass = mom.M(); + double phi = mom.Phi(); + bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtMin < pt) && (pt < cfgCutPtMax); + + phi = RecoDecay::constrainAngle(phi, 0.0, 1); // constrain azimuthal angle to [0,2pi] + + if (std::abs(mom.Rapidity()) < resoCutVals[PHI][kRapidity]) { + histos.fill(hist, invMass, pt, collision.centFT0C()); + double weff = 1; + double waccPOI = 1; + + if (withinPtPOI) + fGFW->Fill(mom.Eta(), ((fPtAxis->FindBin(pt) - 1) * fPhiMassAxis->GetNbins()) + (fPhiMassAxis->FindBin(invMass) - 1), phi, weff * waccPOI, 512); + if (withinPtPOI && withinPtRef) + fGFW->Fill(mom.Eta(), ((fPtAxis->FindBin(pt) - 1) * fPhiMassAxis->GetNbins()) + (fPhiMassAxis->FindBin(invMass) - 1), phi, weff * waccPOI, 1024); + } + } // end of positive combinations loop + return; + } + + template + bool selectionLambda(TCollision const& collision, V0 const& candidate) + { + bool isL = false; // Is lambda candidate + bool isAL = false; // Is anti-lambda candidate + + double mlambda = candidate.mLambda(); + double mantilambda = candidate.mAntiLambda(); + + // separate the positive and negative V0 daughters + auto postrack = candidate.template posTrack_as(); + auto negtrack = candidate.template negTrack_as(); + + histos.fill(HIST("hLambdaCount"), 0.5); + if (postrack.pt() < resoCutVals[LAMBDA][kPosTrackPt] || negtrack.pt() < resoCutVals[LAMBDA][kNegTrackPt]) + return false; + + histos.fill(HIST("hLambdaCount"), 1.5); + if (mlambda > resoCutVals[LAMBDA][kMassMin] && mlambda < resoCutVals[LAMBDA][kMassMax]) + isL = true; + if (mantilambda > resoCutVals[LAMBDA][kMassMin] && mantilambda < resoCutVals[LAMBDA][kMassMax]) + isAL = true; + + if (!isL && !isAL) { + return false; + } + histos.fill(HIST("hLambdaCount"), 2.5); + + // Rapidity correction + if (candidate.yLambda() > resoCutVals[LAMBDA][kRapidity]) + return false; + histos.fill(HIST("hLambdaCount"), 3.5); + // DCA cuts for lambda and antilambda + if (isL) { + if (std::abs(candidate.dcapostopv()) < resoCutVals[LAMBDA][kDCAPosToPVMin] || std::abs(candidate.dcanegtopv()) < resoCutVals[LAMBDA][kDCANegToPVMin]) + return false; + } + if (isAL) { + if (std::abs(candidate.dcapostopv()) < resoCutVals[LAMBDA][kDCANegToPVMin] || std::abs(candidate.dcanegtopv()) < resoCutVals[LAMBDA][kDCAPosToPVMin]) + return false; + } + histos.fill(HIST("hLambdaCount"), 4.5); + if (std::abs(candidate.dcaV0daughters()) > resoSwitchVals[LAMBDA][kDCABetDaug]) + return false; + histos.fill(HIST("hLambdaCount"), 5.5); + // v0 radius cuts + if (resoSwitchVals[LAMBDA][kUseV0Radius] && (candidate.v0radius() < resoCutVals[LAMBDA][kRadiusMin] || candidate.v0radius() > resoCutVals[LAMBDA][kRadiusMax])) + return false; + histos.fill(HIST("hLambdaCount"), 6.5); + // cosine pointing angle cuts + if (candidate.v0cosPA() < resoCutVals[LAMBDA][kCosPA]) + return false; + histos.fill(HIST("hLambdaCount"), 7.5); + // Proper lifetime + if (resoSwitchVals[LAMBDA][kUseProperLifetime] && candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massLambda > resoCutVals[LAMBDA][kLifeTime]) + return false; + histos.fill(HIST("hLambdaCount"), 8.5); + if (isL) { + if (!selectionV0Daughter(postrack, PROTONS) || !selectionV0Daughter(negtrack, PIONS)) + return false; + } + if (isAL) { + if (!selectionV0Daughter(postrack, PIONS) || !selectionV0Daughter(negtrack, PROTONS)) + return false; + } + histos.fill(HIST("hLambdaCount"), 9.5); + bool withinPtPOI = (cfgCutPtPOIMin < candidate.pt()) && (candidate.pt() < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtMin < candidate.pt()) && (candidate.pt() < cfgCutPtMax); + + float weff = 1; + + if (isL) { + if (cfgOutputNUAWeights) + fillWeights(candidate, collision, LAMBDA); + + double waccPOI = getAcceptance(candidate, collision, LAMBDA); + if (withinPtPOI) + fGFW->Fill(candidate.eta(), ((fPtAxis->FindBin(candidate.pt()) - 1) * fLambdaMassAxis->GetNbins()) + (fLambdaMassAxis->FindBin(mlambda) - 1), candidate.phi(), waccPOI * weff, 8); + if (withinPtPOI && withinPtRef) + fGFW->Fill(candidate.eta(), ((fPtAxis->FindBin(candidate.pt()) - 1) * fLambdaMassAxis->GetNbins()) + (fLambdaMassAxis->FindBin(mlambda) - 1), candidate.phi(), waccPOI * weff, 128); + + histos.fill(HIST("hLambdaMass_sparse"), mlambda, candidate.pt(), collision.centFT0C()); + histos.fill(HIST("hLambdaPhi"), candidate.phi()); + histos.fill(HIST("hLambdaEta"), candidate.eta()); + histos.fill(HIST("PrPlusTPC_L"), postrack.pt(), postrack.tpcNSigmaKa()); + histos.fill(HIST("PrPlusTOF_L"), postrack.pt(), postrack.tofNSigmaKa()); + histos.fill(HIST("PiMinusTPC_L"), negtrack.pt(), negtrack.tpcNSigmaKa()); + histos.fill(HIST("PiMinusTOF_L"), negtrack.pt(), negtrack.tofNSigmaKa()); + } + if (isAL) { + if (cfgOutputNUAWeights) + fillWeights(candidate, collision, ANLAMBDA); + + double waccPOI = getAcceptance(candidate, collision, ANLAMBDA); + if (withinPtPOI) + fGFW->Fill(candidate.eta(), ((fPtAxis->FindBin(candidate.pt()) - 1) * fLambdaMassAxis->GetNbins()) + (fLambdaMassAxis->FindBin(mantilambda) - 1), candidate.phi(), waccPOI * weff, 16); + if (withinPtPOI && withinPtRef) + fGFW->Fill(candidate.eta(), ((fPtAxis->FindBin(candidate.pt()) - 1) * fLambdaMassAxis->GetNbins()) + (fLambdaMassAxis->FindBin(mantilambda) - 1), candidate.phi(), waccPOI * weff, 256); + + histos.fill(HIST("hAntiLambdaMass_sparse"), mantilambda, candidate.pt(), collision.centFT0C()); + histos.fill(HIST("hAntiLambdaPhi"), candidate.phi()); + histos.fill(HIST("hAntiLambdaEta"), candidate.eta()); + histos.fill(HIST("PiPlusTPC_AL"), postrack.pt(), postrack.tpcNSigmaKa()); + histos.fill(HIST("PiPlusTOF_AL"), postrack.pt(), postrack.tofNSigmaKa()); + histos.fill(HIST("PrMinusTPC_AL"), negtrack.pt(), negtrack.tpcNSigmaKa()); + histos.fill(HIST("PrMinusTOF_AL"), negtrack.pt(), negtrack.tofNSigmaKa()); + } + return true; + } + + template + bool selectionK0(TCollision const& collision, V0 const& candidate) + { + double mk0 = candidate.mK0Short(); + + // separate the positive and negative V0 daughters + auto postrack = candidate.template posTrack_as(); + auto negtrack = candidate.template negTrack_as(); + + histos.fill(HIST("hK0Count"), 0.5); + if (postrack.pt() < resoCutVals[K0][kPosTrackPt] || negtrack.pt() < resoCutVals[K0][kNegTrackPt]) + return false; + histos.fill(HIST("hK0Count"), 1.5); + if (mk0 < resoCutVals[K0][kMassMin] && mk0 > resoCutVals[K0][kMassMax]) + return false; + histos.fill(HIST("hK0Count"), 2.5); + // Rapidity correction + if (candidate.yK0Short() > resoCutVals[K0][kRapidity]) + return false; + histos.fill(HIST("hK0Count"), 3.5); + // DCA cuts for K0short + if (std::abs(candidate.dcapostopv()) < resoCutVals[K0][kDCAPosToPVMin] || std::abs(candidate.dcanegtopv()) < resoCutVals[K0][kDCANegToPVMin]) + return false; + histos.fill(HIST("hK0Count"), 4.5); + if (std::abs(candidate.dcaV0daughters()) > resoSwitchVals[K0][kDCABetDaug]) + return false; + histos.fill(HIST("hK0Count"), 5.5); + // v0 radius cuts + if (resoSwitchVals[K0][kUseV0Radius] && (candidate.v0radius() < resoCutVals[K0][kRadiusMin] || candidate.v0radius() > resoCutVals[K0][kRadiusMax])) + return false; + histos.fill(HIST("hK0Count"), 6.5); + // cosine pointing angle cuts + if (candidate.v0cosPA() < resoCutVals[K0][kCosPA]) + return false; + histos.fill(HIST("hK0Count"), 7.5); + // Proper lifetime + if (resoSwitchVals[K0][kUseProperLifetime] && candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massK0Short > resoCutVals[K0][kLifeTime]) + return false; + histos.fill(HIST("hK0Count"), 8.5); + if (!selectionV0Daughter(postrack, PIONS) || !selectionV0Daughter(negtrack, PIONS)) + return false; + histos.fill(HIST("hK0Count"), 9.5); + bool withinPtPOI = (cfgCutPtPOIMin < candidate.pt()) && (candidate.pt() < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtMin < candidate.pt()) && (candidate.pt() < cfgCutPtMax); + + if (cfgOutputNUAWeights) + fillWeights(candidate, collision, K0); + + float weff = 1; + double waccPOI = getAcceptance(candidate, collision, K0); + + if (withinPtPOI) + fGFW->Fill(candidate.eta(), ((fPtAxis->FindBin(candidate.pt()) - 1) * fK0MassAxis->GetNbins()) + (fK0MassAxis->FindBin(mk0) - 1), candidate.phi(), waccPOI * weff, 4); + if (withinPtPOI && withinPtRef) + fGFW->Fill(candidate.eta(), ((fPtAxis->FindBin(candidate.pt()) - 1) * fK0MassAxis->GetNbins()) + (fK0MassAxis->FindBin(mk0) - 1), candidate.phi(), waccPOI * weff, 64); + + histos.fill(HIST("hK0Mass_sparse"), mk0, candidate.pt(), collision.centFT0C()); + histos.fill(HIST("hK0Phi"), candidate.phi()); + histos.fill(HIST("hK0Eta"), candidate.eta()); + histos.fill(HIST("PiPlusTPC_K0"), postrack.pt(), postrack.tpcNSigmaKa()); + histos.fill(HIST("PiPlusTOF_K0"), postrack.pt(), postrack.tofNSigmaKa()); + histos.fill(HIST("PiMinusTPC_K0"), negtrack.pt(), negtrack.tpcNSigmaKa()); + histos.fill(HIST("PiMinusTOF_K0"), negtrack.pt(), negtrack.tofNSigmaKa()); + + return true; + } + + template + bool selectionEvent(TCollision collision, const int mult, const float cent) + { + histos.fill(HIST("hEventCount"), kFilteredEvents); + if (!collision.sel8()) { + return 0; + } + histos.fill(HIST("hEventCount"), kAfterSel8); + + if (eventCuts[kUseNoTimeFrameBorder] && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return 0; + } + if (eventCuts[kUseNoTimeFrameBorder]) + histos.fill(HIST("hEventCount"), kUseNoTimeFrameBorder); + + if (eventCuts[kUseNoITSROFrameBorder] && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return 0; + } + if (eventCuts[kUseNoITSROFrameBorder]) + histos.fill(HIST("hEventCount"), kUseNoITSROFrameBorder); + + if (eventCuts[kUseNoSameBunchPileup] && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return 0; + } + if (eventCuts[kUseNoSameBunchPileup]) + histos.fill(HIST("hEventCount"), kUseNoSameBunchPileup); + + if (eventCuts[kUseGoodZvtxFT0vsPV] && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return 0; + } + if (eventCuts[kUseGoodZvtxFT0vsPV]) + histos.fill(HIST("hEventCount"), kUseGoodZvtxFT0vsPV); + + if (eventCuts[kUseNoCollInTimeRangeStandard] && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return 0; + } + if (eventCuts[kUseNoCollInTimeRangeStandard]) + histos.fill(HIST("hEventCount"), kUseNoCollInTimeRangeStandard); + + if (eventCuts[kUseGoodITSLayersAll] && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return 0; + } + if (eventCuts[kUseGoodITSLayersAll]) + histos.fill(HIST("hEventCount"), kUseGoodITSLayersAll); + + if (eventCuts[kUseNoCollInRofStandard] && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return 0; + } + if (eventCuts[kUseNoCollInRofStandard]) + histos.fill(HIST("hEventCount"), kUseNoCollInRofStandard); + + if (eventCuts[kUseNoHighMultCollInPrevRof] && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return 0; + } + if (eventCuts[kUseNoHighMultCollInPrevRof]) + histos.fill(HIST("hEventCount"), kUseNoHighMultCollInPrevRof); + + auto multNTracksPV = collision.multNTracksPV(); + auto occupancy = collision.trackOccupancyInTimeRange(); + + if (eventCuts[kUseOccupancy] && (occupancy < cfgCutOccupancyMin || occupancy > cfgCutOccupancyMax)) { + return 0; + } + if (eventCuts[kUseOccupancy]) + histos.fill(HIST("hEventCount"), kUseOccupancy); + + if (eventCuts[kUseMultCorrCut]) { + if (multNTracksPV < fMultPVCutLow->Eval(cent)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(cent)) + return 0; + if (mult < fMultCutLow->Eval(cent)) + return 0; + if (mult > fMultCutHigh->Eval(cent)) + return 0; + } + if (eventCuts[kUseMultCorrCut]) + histos.fill(HIST("hEventCount"), kUseMultCorrCut); + + // V0A T0A 5 sigma cut + if (eventCuts[kUseT0AV0ACut] && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > cfgV0AT0Acut * fT0AV0ASigma->Eval(collision.multFT0A()))) + return 0; + if (eventCuts[kUseT0AV0ACut]) + histos.fill(HIST("hEventCount"), kUseT0AV0ACut); + + if (eventCuts[kUseVertexITSTPC] && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) + return 0; + if (eventCuts[kUseVertexITSTPC]) + histos.fill(HIST("hEventCount"), kUseVertexITSTPC); + + if (eventCuts[kUseTVXinTRD] && collision.alias_bit(kTVXinTRD)) { + return 0; + } + if (eventCuts[kUseTVXinTRD]) + histos.fill(HIST("hEventCount"), kUseTVXinTRD); + + return 1; + } + + // using BinningTypeVertexContributor = ColumnBinningPolicy; + ROOT::Math::PxPyPzMVector phiMom, kaonPlus, kaonMinus; + double massKaPlus = o2::constants::physics::MassKPlus; + double massLambda = o2::constants::physics::MassLambda; + double massK0Short = o2::constants::physics::MassK0Short; + + void process(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracksWithoutBayes const& tracks, aod::V0Datas const& V0s) + { + int nTot = tracks.size(); + if (nTot < 1) + return; + + float vtxz = collision.posZ(); + const auto cent = collision.centFT0C(); + + if (!selectionEvent(collision, nTot, cent)) + return; + + auto bc = collision.bc_as(); + + histos.fill(HIST("hVtxZ"), vtxz); + histos.fill(HIST("hMult"), nTot); + histos.fill(HIST("hCent"), cent); + fGFW->Clear(); + + float weff = 1; + + loadCorrections(bc); // load corrections for the each event + + // Track loop for calculating the Qn angles + double psi2Est = 0, psi3Est = 0, psi4Est = 0; + float wEPeff = 1; + double v2 = 0, v3 = 0, v4 = 0; + // be cautious, this only works for Pb-Pb + // esimate the Qn angles and vn for this event + if (cfgTrackDensityCorrUse) { + double q2x = 0, q2y = 0; + double q3x = 0, q3y = 0; + double q4x = 0, q4y = 0; + for (const auto& track : tracks) { + bool withinPtRef = (cfgCutPtMin < track.pt()) && (track.pt() < cfgCutPtMax); // within RF pT rang + if (withinPtRef) { + q2x += std::cos(2 * track.phi()); + q2y += std::sin(2 * track.phi()); + q3x += std::cos(3 * track.phi()); + q3y += std::sin(3 * track.phi()); + q4x += std::cos(4 * track.phi()); + q4y += std::sin(4 * track.phi()); + } + } + psi2Est = std::atan2(q2y, q2x) / 2.; + psi3Est = std::atan2(q3y, q3x) / 3.; + psi4Est = std::atan2(q4y, q4x) / 4.; + v2 = funcV2->Eval(cent); + v3 = funcV3->Eval(cent); + v4 = funcV4->Eval(cent); + } + + // Actual track loop + for (auto const& track : tracks) { + if (!isGoodTrack(track)) + continue; + + double pt = track.pt(); + bool withinPtRef = (cfgCutPtMin < pt) && (pt < cfgCutPtMax); + + weff = 1; // Initializing weff for each track + + if (withinPtRef) + if (cfgOutputNUAWeights) + fillWeights(track, collision, REF); + + double waccRef = getAcceptance(track, collision, REF); + + if (cfgTrackDensityCorrUse && withinPtRef) { + double fphi = v2 * std::cos(2 * (track.phi() - psi2Est)) + v3 * std::cos(3 * (track.phi() - psi3Est)) + v4 * std::cos(4 * (track.phi() - psi4Est)); + fphi = (1 + 2 * fphi); + int pTBinForEff = hFindPtBin->FindBin(track.pt()); + if (pTBinForEff >= 1 && pTBinForEff <= hFindPtBin->GetNbinsX()) { + wEPeff = funcEff[pTBinForEff - 1]->Eval(fphi * tracks.size()); + if (wEPeff > 0.) { + wEPeff = 1. / wEPeff; + weff *= wEPeff; + } + } + } + + fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccRef * weff, 1); + } + + auto posSlicedTracks = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto negSlicedTracks = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + if (resoSwitchVals[PHI][kUseParticle]) { + resurrectPhi(posSlicedTracks, negSlicedTracks, collision, kaonPlus, kaonMinus, phiMom, massKaPlus, HIST("hPhiMass_sparse")); + } + + if (cfgUseLsPhi) { + likeSignPhi(posSlicedTracks, collision, massKaPlus, HIST("hLsPhiMass_sparse")); + likeSignPhi(negSlicedTracks, collision, massKaPlus, HIST("hLsPhiMass_sparse")); + } + + // ---------------------- Analyzing the V0s + for (auto const& v0s : V0s) { + if (resoSwitchVals[K0][kUseParticle]) { + if (selectionK0(collision, v0s) == true) + histos.fill(HIST("hK0s"), 1); + } + if (resoSwitchVals[LAMBDA][kUseParticle]) { + if (selectionLambda(collision, v0s) == true) + histos.fill(HIST("hLambdas"), 1); + } + } // End of v0 loop + + // Filling the cumulant profiles + double r = fRndm->Rndm(); + int bootId = static_cast(r * 10); + + for (auto i = 0; i < static_cast(corrconfigs.size()); ++i) { + if (resoSwitchVals[PHI][kUseParticle] && corrconfigs.at(i).Head.starts_with("Phi")) { + int pIndex = findComponent(phiV2, Form("h%spt", corrconfigs.at(i).Head.c_str())); + fillProfileBoot3D(corrconfigs.at(i), phiV2[pIndex], cent, fPhiMassAxis); + + if (cfgUseBootStrap) { + fillProfileBoot3D(corrconfigs.at(i), phiBoot[bootId][pIndex], cent, fPhiMassAxis); + } + } // end of phi condition + + if (cfgUseLsPhi && corrconfigs.at(i).Head.starts_with("LsPhi")) { + int pIndex = findComponent(lsPhiV2, Form("h%spt", corrconfigs.at(i).Head.c_str())); + fillProfileBoot3D(corrconfigs.at(i), lsPhiV2[pIndex], cent, fPhiMassAxis); + + if (cfgUseBootStrap) { + fillProfileBoot3D(corrconfigs.at(i), phiBoot[bootId][pIndex], cent, fPhiMassAxis); + } + } // end of LikeSign phi condition + + if (resoSwitchVals[K0][kUseParticle] && corrconfigs.at(i).Head.starts_with("K0")) { + int pIndex = findComponent(k0V2, Form("h%spt", corrconfigs.at(i).Head.c_str())); + fillProfileBoot3D(corrconfigs.at(i), k0V2[pIndex], cent, fK0MassAxis); + + if (cfgUseBootStrap) { + fillProfileBoot3D(corrconfigs.at(i), k0Boot[bootId][pIndex], cent, fK0MassAxis); + } + } // end of K0 condition + + if (resoSwitchVals[LAMBDA][kUseParticle] && (corrconfigs.at(i).Head.starts_with("Lam") || corrconfigs.at(i).Head.starts_with("AnLam"))) { + int pIndex = findComponent(lambdaV2, Form("h%spt", corrconfigs.at(i).Head.c_str())); + fillProfileBoot3D(corrconfigs.at(i), lambdaV2[pIndex], cent, fLambdaMassAxis); + + if (cfgUseBootStrap) { + fillProfileBoot3D(corrconfigs.at(i), lambdaBoot[bootId][pIndex], cent, fLambdaMassAxis); + } + } // end of lambda condition + + if (configs.GetHeads()[i].starts_with("Ref")) { + int pIndex = findComponent(refV2, Form("h%s", corrconfigs.at(i).Head.c_str())); + fillProfileBoot(corrconfigs.at(i), refV2[pIndex], cent); + + if (cfgUseBootStrap) { + fillProfileBoot(corrconfigs.at(i), refBoot[bootId][pIndex], cent); + } + } // end of ref condition + } // end of loop over correlation configurations + } // end of processReso +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/GenericFramework/Core/BootstrapProfile.h b/PWGCF/GenericFramework/Core/BootstrapProfile.h index a0dfde08509..829c58cc11a 100644 --- a/PWGCF/GenericFramework/Core/BootstrapProfile.h +++ b/PWGCF/GenericFramework/Core/BootstrapProfile.h @@ -9,6 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file BootstrapProfile.h/.cxx +/// \brief Derived class from TProfile that stores extra TProfiles for bootstrap samples +/// \author Emil Gorm Nielsen (ack. V. Vislavicius), NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_BOOTSTRAPPROFILE_H_ #define PWGCF_GENERICFRAMEWORK_CORE_BOOTSTRAPPROFILE_H_ diff --git a/PWGCF/GenericFramework/Core/FlowContainer.h b/PWGCF/GenericFramework/Core/FlowContainer.h index 40a379e01a8..bb330c049b6 100644 --- a/PWGCF/GenericFramework/Core/FlowContainer.h +++ b/PWGCF/GenericFramework/Core/FlowContainer.h @@ -9,6 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file GFW.h/.cxx +/// \brief Container to store correlations and compute common cumulants +/// \author Emil Gorm Nielsen, NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_FLOWCONTAINER_H_ #define PWGCF_GENERICFRAMEWORK_CORE_FLOWCONTAINER_H_ #include diff --git a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx index d538d88affe..33f2e303711 100644 --- a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx +++ b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx @@ -140,6 +140,17 @@ void FlowPtContainer::initialise(const o2::framework::AxisSpec axis, const int& fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt0", "ChFull22pt1_Mpt0", nMultiBins, &multiBins[0])); fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt1", "ChFull22pt1_Mpt1", nMultiBins, &multiBins[0])); + + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt0", "ChFull22pt3_Mpt0", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt1", "ChFull22pt3_Mpt1", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt2", "ChFull22pt3_Mpt2", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt3", "ChFull22pt3_Mpt3", nMultiBins, &multiBins[0])); + + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt0", "ChFull22pt4_Mpt0", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt1", "ChFull22pt4_Mpt1", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt2", "ChFull22pt4_Mpt2", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt3", "ChFull22pt4_Mpt3", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt4", "ChFull22pt4_Mpt4", nMultiBins, &multiBins[0])); } else { fCovList->Add(new BootstrapProfile("ChFull24pt2", "ChFull24pt2", nMultiBins, &multiBins[0])); fCovList->Add(new BootstrapProfile("ChFull24pt1", "ChFull24pt1", nMultiBins, &multiBins[0])); @@ -161,8 +172,8 @@ void FlowPtContainer::initialise(const o2::framework::AxisSpec axis, const int& }; void FlowPtContainer::initialise(int nbinsx, double* xbins, const int& m, const GFWCorrConfigs& configs, const int& nsub) { - arr.resize(3 * 3 * 3 * 3); - warr.resize(3 * 3 * 3 * 3); + arr.resize(3 * 3 * 5 * 5); + warr.resize(3 * 3 * 5 * 5); if (!mpar) mpar = m; if (fCMTermList) @@ -214,6 +225,17 @@ void FlowPtContainer::initialise(int nbinsx, double* xbins, const int& m, const fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt0", "ChFull22pt1_Mpt0", nbinsx, xbins)); fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt1", "ChFull22pt1_Mpt1", nbinsx, xbins)); + + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt0", "ChFull22pt3_Mpt0", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt1", "ChFull22pt3_Mpt1", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt2", "ChFull22pt3_Mpt2", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt3", "ChFull22pt3_Mpt3", nbinsx, xbins)); + + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt0", "ChFull22pt4_Mpt0", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt1", "ChFull22pt4_Mpt1", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt2", "ChFull22pt4_Mpt2", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt3", "ChFull22pt4_Mpt3", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt4", "ChFull22pt4_Mpt4", nbinsx, xbins)); } else { fCovList->Add(new BootstrapProfile("ChFull24pt2", "ChFull24pt2", nbinsx, xbins)); fCovList->Add(new BootstrapProfile("ChFull24pt1", "ChFull24pt1", nbinsx, xbins)); @@ -233,8 +255,8 @@ void FlowPtContainer::initialise(int nbinsx, double* xbins, const int& m, const }; void FlowPtContainer::initialise(int nbinsx, double xlow, double xhigh, const int& m, const GFWCorrConfigs& configs, const int& nsub) { - arr.resize(3 * 3 * 3 * 3); - warr.resize(3 * 3 * 3 * 3); + arr.resize(3 * 3 * 5 * 5); + warr.resize(3 * 3 * 5 * 5); if (!mpar) mpar = m; if (fCMTermList) @@ -286,6 +308,17 @@ void FlowPtContainer::initialise(int nbinsx, double xlow, double xhigh, const in fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt0", "ChFull22pt1_Mpt0", nbinsx, xlow, xhigh)); fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt1", "ChFull22pt1_Mpt1", nbinsx, xlow, xhigh)); + + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt0", "ChFull22pt3_Mpt0", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt1", "ChFull22pt3_Mpt1", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt2", "ChFull22pt3_Mpt2", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt3_Mpt3", "ChFull22pt3_Mpt3", nbinsx, xlow, xhigh)); + + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt0", "ChFull22pt4_Mpt0", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt1", "ChFull22pt4_Mpt1", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt2", "ChFull22pt4_Mpt2", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt3", "ChFull22pt4_Mpt3", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt4_Mpt4", "ChFull22pt4_Mpt4", nbinsx, xlow, xhigh)); } else { fCovList->Add(new BootstrapProfile("ChFull24pt2", "ChFull24pt2", nbinsx, xlow, xhigh)); fCovList->Add(new BootstrapProfile("ChFull24pt1", "ChFull24pt1", nbinsx, xlow, xhigh)); @@ -372,7 +405,7 @@ void FlowPtContainer::fillVnDeltaPtProfiles(const double& centmult, const double continue; for (auto i = 0; i <= m; ++i) { if (cmDen[m] != 0) { - dynamic_cast(fCovList->At(fillCounter))->FillProfile(centmult, flowval * ((i == m) ? cmVal[0] : cmVal[m * (m - 1) / 2 + (m - i)]), (fEventWeight == UnityWeight) ? 1.0 : flowtuples * cmDen[m], rn); + dynamic_cast(fCovList->At(fillCounter))->FillProfile(centmult, flowval * ((i == m) ? cmVal[0] : cmVal[m * (m - 1) / 2 + i + 1]), (fEventWeight == UnityWeight) ? 1.0 : flowtuples * cmDen[m], rn); } ++fillCounter; } @@ -430,6 +463,33 @@ void FlowPtContainer::fillVnDeltaPtStdProfiles(const double& centmult, const dou double wABD = getStdABD(warr); if (wABD != 0) dynamic_cast(fCovList->At(9))->FillProfile(centmult, getStdABD(arr) / wABD, (fEventWeight == UnityWeight) ? 1.0 : wABD, rn); + double wABCCCC = getStdABCCCC(warr); + if (wABCCCC != 0.) + dynamic_cast(fCovList->At(14))->FillProfile(centmult, getStdABCCCC(arr) / wABCCCC, (fEventWeight == UnityWeight) ? 1. : wABCCCC, rn); + double wABCCCD = getStdABCCCD(warr); + if (wABCCCD != 0.) + dynamic_cast(fCovList->At(15))->FillProfile(centmult, getStdABCCCD(arr) / wABCCCD, (fEventWeight == UnityWeight) ? 1. : wABCCCD, rn); + double wABCCDD = getStdABCCDD(warr); + if (wABCCDD != 0.) + dynamic_cast(fCovList->At(16))->FillProfile(centmult, getStdABCCDD(arr) / wABCCDD, (fEventWeight == UnityWeight) ? 1. : wABCCDD, rn); + double wABCDDD = getStdABCDDD(warr); + if (wABCDDD != 0.) + dynamic_cast(fCovList->At(17))->FillProfile(centmult, getStdABCDDD(arr) / wABCDDD, (fEventWeight == UnityWeight) ? 1. : wABCDDD, rn); + double wABDDDD = getStdABDDDD(warr); + if (wABDDDD != 0.) + dynamic_cast(fCovList->At(18))->FillProfile(centmult, getStdABDDDD(arr) / wABDDDD, (fEventWeight == UnityWeight) ? 1. : wABDDDD, rn); + double wABCCC = getStdABCCC(warr); + if (wABCCC != 0.) + dynamic_cast(fCovList->At(10))->FillProfile(centmult, getStdABCCC(arr) / wABCCC, (fEventWeight == UnityWeight) ? 1. : wABCCC, rn); + double wABCCD = getStdABCCD(warr); + if (wABCCD != 0.) + dynamic_cast(fCovList->At(11))->FillProfile(centmult, getStdABCCD(arr) / wABCCD, (fEventWeight == UnityWeight) ? 1. : wABCCD, rn); + double wABCDD = getStdABCDD(warr); + if (wABCDD != 0.) + dynamic_cast(fCovList->At(12))->FillProfile(centmult, getStdABCDD(arr) / wABCDD, (fEventWeight == UnityWeight) ? 1. : wABCDD, rn); + double wABDDD = getStdABDDD(warr); + if (wABDDD != 0.) + dynamic_cast(fCovList->At(13))->FillProfile(centmult, getStdABDDD(arr) / wABDDD, (fEventWeight == UnityWeight) ? 1. : wABDDD, rn); return; } void FlowPtContainer::fillCMProfiles(const double& centmult, const double& rn) @@ -447,40 +507,40 @@ void FlowPtContainer::fillCMProfiles(const double& centmult, const double& rn) if (mpar < 1 || cmDen[1] == 0) return; cmVal.push_back(sumP[getVectorIndex(1, 1)] / cmDen[1]); - dynamic_cast(fCMTermList->At(0))->FillProfile(centmult, cmVal[1], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[0], rn); + dynamic_cast(fCMTermList->At(0))->FillProfile(centmult, cmVal[1], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[1], rn); if (mpar < 2 || sumP[getVectorIndex(2, 0)] == 0 || cmDen[2] == 0) return; cmVal.push_back(1 / cmDen[2] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] - sumP[getVectorIndex(2, 2)])); - dynamic_cast(fCMTermList->At(1))->FillProfile(centmult, cmVal[2], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[1], rn); + dynamic_cast(fCMTermList->At(1))->FillProfile(centmult, cmVal[2], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[2], rn); cmVal.push_back(-2 * 1 / cmDen[2] * (sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 1)] - sumP[getVectorIndex(2, 1)])); - dynamic_cast(fCMTermList->At(2))->FillProfile(centmult, cmVal[3], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[1], rn); + dynamic_cast(fCMTermList->At(2))->FillProfile(centmult, cmVal[3], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[2], rn); if (mpar < 3 || sumP[getVectorIndex(3, 0)] == 0 || cmDen[3] == 0) return; cmVal.push_back(1 / cmDen[3] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] - 3 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(1, 1)] + 2 * sumP[getVectorIndex(3, 3)])); - dynamic_cast(fCMTermList->At(3))->FillProfile(centmult, cmVal[4], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[2], rn); + dynamic_cast(fCMTermList->At(3))->FillProfile(centmult, cmVal[4], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); cmVal.push_back(-3 * 1 / cmDen[3] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] - 2 * sumP[getVectorIndex(2, 1)] * sumP[getVectorIndex(1, 1)] + 2 * sumP[getVectorIndex(3, 2)] - sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(1, 0)])); - dynamic_cast(fCMTermList->At(4))->FillProfile(centmult, cmVal[5], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[2], rn); + dynamic_cast(fCMTermList->At(4))->FillProfile(centmult, cmVal[5], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); cmVal.push_back(3 * 1 / cmDen[3] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 0)] - 2 * sumP[getVectorIndex(2, 1)] * sumP[getVectorIndex(1, 0)] + 2 * sumP[getVectorIndex(3, 1)] - sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(2, 0)])); - dynamic_cast(fCMTermList->At(5))->FillProfile(centmult, cmVal[6], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[2], rn); + dynamic_cast(fCMTermList->At(5))->FillProfile(centmult, cmVal[6], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); if (mpar < 4 || sumP[getVectorIndex(4, 0)] == 0 || cmDen[4] == 0) return; cmVal.push_back(1 / cmDen[4] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] - 6 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] + 3 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(2, 2)] + 8 * sumP[getVectorIndex(3, 3)] * sumP[getVectorIndex(1, 1)] - 6 * sumP[getVectorIndex(4, 4)])); - dynamic_cast(fCMTermList->At(6))->FillProfile(centmult, cmVal[7], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); - cmVal.push_back(-4 * 1 / cmDen[4] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] - 3 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] - 3 * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(2, 1)] + 3 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(2, 1)] + 6 * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(3, 2)] - 6 * sumP[getVectorIndex(4, 3)])); - dynamic_cast(fCMTermList->At(7))->FillProfile(centmult, cmVal[8], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); + dynamic_cast(fCMTermList->At(6))->FillProfile(centmult, cmVal[7], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[4], rn); + cmVal.push_back(-4 * 1 / cmDen[4] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] - 3 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] - 3 * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(2, 1)] + 3 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(2, 1)] + 2 * sumP[getVectorIndex(3, 3)] * sumP[getVectorIndex(1, 0)] + 6 * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(3, 2)] - 6 * sumP[getVectorIndex(4, 3)])); + dynamic_cast(fCMTermList->At(7))->FillProfile(centmult, cmVal[8], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[4], rn); cmVal.push_back(6 * 1 / cmDen[4] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 0)] - sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 0)] - sumP[getVectorIndex(2, 0)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] + sumP[getVectorIndex(2, 0)] * sumP[getVectorIndex(2, 2)] - 4 * sumP[getVectorIndex(2, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] + 4 * sumP[getVectorIndex(3, 2)] * sumP[getVectorIndex(1, 0)] + 4 * sumP[getVectorIndex(3, 1)] * sumP[getVectorIndex(1, 1)] + 2 * sumP[getVectorIndex(2, 1)] * sumP[getVectorIndex(2, 1)] - 6 * sumP[getVectorIndex(4, 2)])); - dynamic_cast(fCMTermList->At(8))->FillProfile(centmult, cmVal[9], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); + dynamic_cast(fCMTermList->At(8))->FillProfile(centmult, cmVal[9], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[4], rn); cmVal.push_back(-4 * 1 / cmDen[4] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 0)] - 3 * sumP[getVectorIndex(2, 1)] * sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 0)] - 3 * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(2, 0)] * sumP[getVectorIndex(1, 0)] + 3 * sumP[getVectorIndex(2, 1)] * sumP[getVectorIndex(2, 0)] + 2 * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(3, 0)] + 6 * sumP[getVectorIndex(3, 1)] * sumP[getVectorIndex(1, 0)] - 6 * sumP[getVectorIndex(4, 1)])); - dynamic_cast(fCMTermList->At(9))->FillProfile(centmult, cmVal[10], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); + dynamic_cast(fCMTermList->At(9))->FillProfile(centmult, cmVal[10], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[4], rn); return; } void FlowPtContainer::fillArray(FillType a, FillType b, double c, double d) { - for (int idx = 0; idx < 81; ++idx) { + for (int idx = 0; idx < 225; ++idx) { int i = idx % 3; int j = ((idx - i) / 3) % 3; - int k = ((idx - j * 3 - i) / 9) % 3; - int l = ((idx - k * 9 - j * 3 - i) / 27) % 3; + int k = ((idx - j * 3 - i) / 9) % 5; + int l = ((idx - k * 9 - j * 3 - i) / 45) % 5; if (std::holds_alternative>(a) && std::holds_alternative>(b)) { arr[idx] += std::pow(std::get<0>(a), i) * std::pow(std::get<0>(b), j) * std::pow(c, k) * std::pow(d, l); } else if (std::holds_alternative(a) && std::holds_alternative(b)) { @@ -518,7 +578,7 @@ double FlowPtContainer::getStdAABBCC(T& inarr) std::complex bbcc = inarr[getVectorIndex(0, 2, 2, 0)]; std::complex aabbc = inarr[getVectorIndex(2, 2, 1, 0)]; std::complex aabcc = inarr[getVectorIndex(2, 1, 2, 0)]; - std::complex abbcc = inarr[getVectorIndex(0, 0, 0, 0)]; + std::complex abbcc = inarr[getVectorIndex(1, 2, 2, 0)]; std::complex aabbcc = inarr[getVectorIndex(2, 2, 2, 0)]; return (a * a * b * b * c * c - aa * b * b * c * c - a * a * bb * c * c - a * a * b * b * cc - 4. * a * ab * b * c * c - 4. * a * ac * b * b * c - 4. * a * a * b * bc * c + 4. * aab * b * c * c + 4. * aac * b * b * c + @@ -567,7 +627,7 @@ double FlowPtContainer::getStdAABBCD(T& inarr) std::complex aacd = inarr[getVectorIndex(2, 0, 1, 1)]; std::complex abbc = inarr[getVectorIndex(1, 2, 1, 0)]; std::complex abbd = inarr[getVectorIndex(1, 2, 0, 1)]; - std::complex abcd = inarr[getVectorIndex(0, 1, 1, 1)]; + std::complex abcd = inarr[getVectorIndex(1, 1, 1, 1)]; std::complex bbcd = inarr[getVectorIndex(0, 2, 1, 1)]; std::complex aabbc = inarr[getVectorIndex(2, 2, 1, 0)]; std::complex aabbd = inarr[getVectorIndex(2, 2, 0, 1)]; @@ -600,7 +660,7 @@ double FlowPtContainer::getStdAABBDD(T& inarr) { std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; - std::complex d = inarr[getVectorIndex(0, 0, 1, 1)]; + std::complex d = inarr[getVectorIndex(0, 0, 0, 1)]; std::complex aa = inarr[getVectorIndex(2, 0, 0, 0)]; std::complex bb = inarr[getVectorIndex(0, 2, 0, 0)]; std::complex dd = inarr[getVectorIndex(0, 0, 0, 2)]; @@ -622,7 +682,7 @@ double FlowPtContainer::getStdAABBDD(T& inarr) std::complex bbdd = inarr[getVectorIndex(0, 2, 0, 2)]; std::complex aabbd = inarr[getVectorIndex(2, 2, 0, 1)]; std::complex aabdd = inarr[getVectorIndex(2, 1, 0, 2)]; - std::complex abbdd = inarr[getVectorIndex(0, 0, 0, 2)]; + std::complex abbdd = inarr[getVectorIndex(1, 2, 0, 2)]; std::complex aabbdd = inarr[getVectorIndex(2, 2, 0, 2)]; return (-120. * aabbdd + 48. * a * abbdd + 16. * abd * abd + 24. * ab * abdd + 24. * abbd * ad + 8. * abb * add + 48. * aabdd * b - 24. * a * abdd * b - 16. * abd * ad * b - 8. * ab * add * b - @@ -667,21 +727,21 @@ double FlowPtContainer::getStdAABBD(T& inarr) { std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; - std::complex d = inarr[getVectorIndex(0, 0, 1, 0)]; + std::complex d = inarr[getVectorIndex(0, 0, 0, 1)]; std::complex aa = inarr[getVectorIndex(2, 0, 0, 0)]; std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; - std::complex ad = inarr[getVectorIndex(1, 0, 1, 0)]; + std::complex ad = inarr[getVectorIndex(1, 0, 0, 1)]; std::complex bb = inarr[getVectorIndex(0, 2, 0, 0)]; - std::complex bd = inarr[getVectorIndex(0, 1, 1, 0)]; + std::complex bd = inarr[getVectorIndex(0, 1, 0, 1)]; std::complex aab = inarr[getVectorIndex(2, 1, 0, 0)]; - std::complex aad = inarr[getVectorIndex(2, 0, 1, 0)]; + std::complex aad = inarr[getVectorIndex(2, 0, 0, 1)]; std::complex abb = inarr[getVectorIndex(1, 2, 0, 0)]; - std::complex abd = inarr[getVectorIndex(1, 1, 1, 0)]; - std::complex bbd = inarr[getVectorIndex(0, 2, 1, 0)]; + std::complex abd = inarr[getVectorIndex(1, 1, 0, 1)]; + std::complex bbd = inarr[getVectorIndex(0, 2, 0, 1)]; std::complex aabb = inarr[getVectorIndex(2, 2, 0, 0)]; - std::complex aabd = inarr[getVectorIndex(2, 1, 1, 0)]; - std::complex abbd = inarr[getVectorIndex(1, 2, 1, 0)]; - std::complex aabbd = inarr[getVectorIndex(2, 2, 1, 0)]; + std::complex aabd = inarr[getVectorIndex(2, 1, 0, 1)]; + std::complex abbd = inarr[getVectorIndex(1, 2, 0, 1)]; + std::complex aabbd = inarr[getVectorIndex(2, 2, 0, 1)]; return (a * a * b * b * d - aa * b * b * d - a * a * bb * d - 4. * ab * a * b * d - 2. * a * ad * b * b - 2. * a * a * bd * b + 2. * ab * ab * d + 4. * ab * ad * b + 4. * ab * bd * a + 8. * abd * a * b + 4. * aab * b * d + 2. * aad * b * b + 4. * abb * a * d + 2. * bbd * a * a + aa * bb * d + 2. * aa * b * bd + 2. * bb * a * ad - 12. * aabd * b - 12. * abbd * a - 6. * aabb * d - 8. * abd * ab - 2. * bbd * aa - 2. * aad * bb - 4. * aab * bd - 4. * abb * ad + 24. * aabbd).real(); } template @@ -763,6 +823,347 @@ double FlowPtContainer::getStdABD(T& inarr) std::complex abd = inarr[getVectorIndex(1, 1, 0, 1)]; return (a * b * d - ab * d - ad * b - a * bd + 2. * abd).real(); } +template +double FlowPtContainer::getStdABCCCC(T& inarr) +{ + std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; + std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; + std::complex c = inarr[getVectorIndex(0, 0, 1, 0)]; + std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; + std::complex ac = inarr[getVectorIndex(1, 0, 1, 0)]; + std::complex bc = inarr[getVectorIndex(0, 1, 1, 0)]; + std::complex cc = inarr[getVectorIndex(0, 0, 2, 0)]; + std::complex abc = inarr[getVectorIndex(1, 1, 1, 0)]; + std::complex acc = inarr[getVectorIndex(1, 0, 2, 0)]; + std::complex bcc = inarr[getVectorIndex(0, 1, 2, 0)]; + std::complex ccc = inarr[getVectorIndex(0, 0, 3, 0)]; + std::complex abcc = inarr[getVectorIndex(1, 1, 2, 0)]; + std::complex accc = inarr[getVectorIndex(1, 0, 3, 0)]; + std::complex bccc = inarr[getVectorIndex(0, 1, 3, 0)]; + std::complex cccc = inarr[getVectorIndex(0, 0, 4, 0)]; + std::complex abccc = inarr[getVectorIndex(1, 1, 3, 0)]; + std::complex acccc = inarr[getVectorIndex(1, 0, 4, 0)]; + std::complex bcccc = inarr[getVectorIndex(0, 1, 4, 0)]; + std::complex abcccc = inarr[getVectorIndex(1, 1, 4, 0)]; + return (-120. * abcccc + 24. * acccc * b + 24. * accc * bc + 24. * acc * bcc + + 24. * ac * bccc + 24. * a * bcccc + 96. * abccc * c - 24. * accc * b * c - 24. * acc * bc * c - + 24. * ac * bcc * c - 24. * a * bccc * c - 36. * abcc * c * c + 12. * acc * b * c * c + + 12. * ac * bc * c * c + 12. * a * bcc * c * c + 8. * abc * c * c * c - 4. * ac * b * c * c * c - 4. * a * bc * c * c * c - + ab * c * c * c * c + a * b * c * c * c * c + 36. * abcc * cc - 12. * acc * b * cc - 12. * ac * bc * cc - 12. * a * bcc * cc - 24. * abc * c * cc + 12. * ac * b * c * cc + 12. * a * bc * c * cc + 6. * ab * c * c * cc - 6. * a * b * c * c * cc - 3. * ab * cc * cc + 3. * a * b * cc * cc + 16. * abc * ccc - 8. * ac * b * ccc - 8. * a * bc * ccc - 8. * ab * c * ccc + 8. * a * b * c * ccc + 6. * ab * cccc - 6. * a * b * cccc) + .real(); +} +template +double FlowPtContainer::getStdABCCCD(T& inarr) +{ + std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; + std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; + std::complex c = inarr[getVectorIndex(0, 0, 1, 0)]; + std::complex d = inarr[getVectorIndex(0, 0, 0, 1)]; + std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; + std::complex ac = inarr[getVectorIndex(1, 0, 1, 0)]; + std::complex ad = inarr[getVectorIndex(1, 0, 0, 1)]; + std::complex bc = inarr[getVectorIndex(0, 1, 1, 0)]; + std::complex bd = inarr[getVectorIndex(0, 1, 0, 1)]; + std::complex cc = inarr[getVectorIndex(0, 0, 2, 0)]; + std::complex cd = inarr[getVectorIndex(0, 0, 1, 1)]; + std::complex abc = inarr[getVectorIndex(1, 1, 1, 0)]; + std::complex abd = inarr[getVectorIndex(1, 1, 0, 1)]; + std::complex acc = inarr[getVectorIndex(1, 0, 2, 0)]; + std::complex acd = inarr[getVectorIndex(1, 0, 1, 1)]; + std::complex bcc = inarr[getVectorIndex(0, 1, 2, 0)]; + std::complex bcd = inarr[getVectorIndex(0, 1, 1, 1)]; + std::complex ccc = inarr[getVectorIndex(0, 0, 3, 0)]; + std::complex ccd = inarr[getVectorIndex(0, 0, 2, 1)]; + std::complex abcc = inarr[getVectorIndex(1, 1, 2, 0)]; + std::complex abcd = inarr[getVectorIndex(1, 1, 1, 1)]; + std::complex accc = inarr[getVectorIndex(1, 0, 3, 0)]; + std::complex accd = inarr[getVectorIndex(1, 0, 2, 1)]; + std::complex bccc = inarr[getVectorIndex(0, 1, 3, 0)]; + std::complex bccd = inarr[getVectorIndex(0, 1, 2, 1)]; + std::complex cccd = inarr[getVectorIndex(0, 0, 3, 1)]; + std::complex abccc = inarr[getVectorIndex(1, 1, 3, 0)]; + std::complex abccd = inarr[getVectorIndex(1, 1, 2, 1)]; + std::complex acccd = inarr[getVectorIndex(1, 0, 3, 1)]; + std::complex bcccd = inarr[getVectorIndex(0, 1, 3, 1)]; + std::complex abcccd = inarr[getVectorIndex(1, 1, 3, 1)]; + return (-120. * abcccd + 24. * acccd * b + 18. * accd * bc + 12. * acd * bcc + 6. * ad * bccc + + 24. * a * bcccd + 18. * ac * bccd + 12. * acc * bcd + 6. * accc * bd + 72. * abccd * c - + 18. * accd * b * c - 12. * acd * bc * c - 6. * ad * bcc * c - 18. * a * bccd * c - 12. * ac * bcd * c - + 6. * acc * bd * c - 18. * abcd * c * c + 6. * acd * b * c * c + 3. * ad * bc * c * c + 6. * a * bcd * c * c + + 3. * ac * bd * c * c + 2. * abd * c * c * c - ad * b * c * c * c - a * bd * c * c * c + 18. * abcd * cc - + 6. * acd * b * cc - 3. * ad * bc * cc - 6. * a * bcd * cc - 3. * ac * bd * cc - 6. * abd * c * cc + + 3. * ad * b * c * cc + 3. * a * bd * c * cc + 4. * abd * ccc - 2. * ad * b * ccc - 2. * a * bd * ccc + + 6. * ab * cccd - 6. * a * b * cccd + 12. * abc * ccd - 6. * ac * b * ccd - 6. * a * bc * ccd - + 6. * ab * c * ccd + 6. * a * b * c * ccd + 18. * abcc * cd - 6. * acc * b * cd - 6. * ac * bc * cd - + 6. * a * bcc * cd - 12. * abc * c * cd + 6. * ac * b * c * cd + 6. * a * bc * c * cd + 3. * ab * c * c * cd - + 3. * a * b * c * c * cd - 3. * ab * cc * cd + 3. * a * b * cc * cd + 24. * abccc * d - 6. * accc * b * d - + 6. * acc * bc * d - 6. * ac * bcc * d - 6. * a * bccc * d - 18. * abcc * c * d + 6. * acc * b * c * d + + 6. * ac * bc * c * d + 6. * a * bcc * c * d + 6. * abc * c * c * d - 3. * ac * b * c * c * d - + 3. * a * bc * c * c * d - ab * c * c * c * d + a * b * c * c * c * d - 6. * abc * cc * d + 3. * ac * b * cc * d + + 3. * a * bc * cc * d + 3. * ab * c * cc * d - 3. * a * b * c * cc * d - 2. * ab * ccc * d + 2. * a * b * ccc * d) + .real(); +} +template +double FlowPtContainer::getStdABCCDD(T& inarr) +{ + std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; + std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; + std::complex c = inarr[getVectorIndex(0, 0, 1, 0)]; + std::complex d = inarr[getVectorIndex(0, 0, 0, 1)]; + std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; + std::complex ac = inarr[getVectorIndex(1, 0, 1, 0)]; + std::complex ad = inarr[getVectorIndex(1, 0, 0, 1)]; + std::complex bc = inarr[getVectorIndex(0, 1, 1, 0)]; + std::complex bd = inarr[getVectorIndex(0, 1, 0, 1)]; + std::complex cc = inarr[getVectorIndex(0, 0, 2, 0)]; + std::complex cd = inarr[getVectorIndex(0, 0, 1, 1)]; + std::complex dd = inarr[getVectorIndex(0, 0, 0, 2)]; + std::complex abc = inarr[getVectorIndex(1, 1, 1, 0)]; + std::complex abd = inarr[getVectorIndex(1, 1, 0, 1)]; + std::complex acc = inarr[getVectorIndex(1, 0, 2, 0)]; + std::complex acd = inarr[getVectorIndex(1, 0, 1, 1)]; + std::complex add = inarr[getVectorIndex(1, 0, 0, 2)]; + std::complex bcc = inarr[getVectorIndex(0, 1, 2, 0)]; + std::complex bcd = inarr[getVectorIndex(0, 1, 1, 1)]; + std::complex bdd = inarr[getVectorIndex(0, 1, 0, 2)]; + std::complex ccd = inarr[getVectorIndex(0, 0, 2, 1)]; + std::complex cdd = inarr[getVectorIndex(0, 0, 1, 2)]; + std::complex abcc = inarr[getVectorIndex(1, 1, 2, 0)]; + std::complex abcd = inarr[getVectorIndex(1, 1, 1, 1)]; + std::complex abdd = inarr[getVectorIndex(1, 1, 0, 2)]; + std::complex accd = inarr[getVectorIndex(1, 0, 2, 1)]; + std::complex acdd = inarr[getVectorIndex(1, 0, 1, 2)]; + std::complex bccd = inarr[getVectorIndex(0, 1, 2, 1)]; + std::complex bcdd = inarr[getVectorIndex(0, 1, 1, 2)]; + std::complex ccdd = inarr[getVectorIndex(0, 0, 2, 2)]; + std::complex abccd = inarr[getVectorIndex(1, 1, 2, 1)]; + std::complex abcdd = inarr[getVectorIndex(1, 1, 1, 2)]; + std::complex accdd = inarr[getVectorIndex(1, 0, 2, 2)]; + std::complex bccdd = inarr[getVectorIndex(0, 1, 2, 2)]; + std::complex abccdd = inarr[getVectorIndex(1, 1, 2, 2)]; + return (-120. * abccdd + 24. * accdd * b + 12. * acdd * bc + 4. * add * bcc + 12. * ad * bccd + + 24. * a * bccdd + 16. * acd * bcd + 12. * ac * bcdd + 12. * accd * bd + 4. * acc * bdd + + 48. * abcdd * c - 12. * acdd * b * c - 4. * add * bc * c - 8. * ad * bcd * c - 12. * a * bcdd * c - + 8. * acd * bd * c - 4. * ac * bdd * c - 6. * abdd * c * c + 2. * add * b * c * c + 2. * ad * bd * c * c + + 2. * a * bdd * c * c + 6. * abdd * cc - 2. * add * b * cc - 2. * ad * bd * cc - 2. * a * bdd * cc + + 8. * abd * ccd - 4. * ad * b * ccd - 4. * a * bd * ccd + 6. * ab * ccdd - 6. * a * b * ccdd + + 24. * abcd * cd - 8. * acd * b * cd - 4. * ad * bc * cd - 8. * a * bcd * cd - 4. * ac * bd * cd - + 8. * abd * c * cd + 4. * ad * b * c * cd + 4. * a * bd * c * cd - 2. * ab * cd * d + 2. * a * b * cd * d + + 8. * abc * cdd - 4. * ac * b * cdd - 4. * a * bc * cdd - 4. * ab * c * cdd + 4. * a * b * c * cdd + + 48. * abccd * d - 12. * accd * b * d - 8. * acd * bc * d - 4. * ad * bcc * d - 12. * a * bccd * d - + 8. * ac * bcd * d - 4. * acc * bd * d - 24. * abcd * c * d + 8. * acd * b * c * d + 4. * ad * bc * c * d + + 8. * a * bcd * c * d + 4. * ac * bd * c * d + 4. * abd * c * c * d - 2. * ad * b * c * c * d - + 2. * a * bd * c * c * d - 4. * abd * cc * d + 2. * ad * b * cc * d + 2. * a * bd * cc * d - 4. * ab * ccd * d + + 4. * a * b * ccd * d - 8. * abc * cd * d + 4. * ac * b * cd * d + 4. * a * bc * cd * d + 4. * ab * c * cd * d - + 4. * a * b * c * cd * d - 6. * abcc * d * d + 2. * acc * b * d * d + 2. * ac * bc * d * d + + 2. * a * bcc * d * d + 4. * abc * c * d * d - 2. * ac * b * c * d * d - 2. * a * bc * c * d * d - + ab * c * c * d * d + a * b * c * c * d * d + ab * cc * d * d - a * b * cc * d * d + 6. * abcc * dd - + 2. * acc * b * dd - 2. * ac * bc * dd - 2. * a * bcc * dd - 4. * abc * c * dd + 2. * ac * b * c * dd + + 2. * a * bc * c * dd + ab * c * c * dd - a * b * c * c * dd - ab * cc * dd + a * b * cc * dd) + .real(); +} +template +double FlowPtContainer::getStdABCDDD(T& inarr) +{ + std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; + std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; + std::complex c = inarr[getVectorIndex(0, 0, 1, 0)]; + std::complex d = inarr[getVectorIndex(0, 0, 0, 1)]; + std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; + std::complex ac = inarr[getVectorIndex(1, 0, 1, 0)]; + std::complex ad = inarr[getVectorIndex(1, 0, 0, 1)]; + std::complex bc = inarr[getVectorIndex(0, 1, 1, 0)]; + std::complex bd = inarr[getVectorIndex(0, 1, 0, 1)]; + std::complex cd = inarr[getVectorIndex(0, 0, 1, 1)]; + std::complex dd = inarr[getVectorIndex(0, 0, 0, 2)]; + std::complex abc = inarr[getVectorIndex(1, 1, 1, 0)]; + std::complex abd = inarr[getVectorIndex(1, 1, 0, 1)]; + std::complex acd = inarr[getVectorIndex(1, 0, 1, 1)]; + std::complex add = inarr[getVectorIndex(1, 0, 0, 2)]; + std::complex bcd = inarr[getVectorIndex(0, 1, 1, 1)]; + std::complex bdd = inarr[getVectorIndex(0, 1, 0, 2)]; + std::complex cdd = inarr[getVectorIndex(0, 0, 1, 2)]; + std::complex ddd = inarr[getVectorIndex(0, 0, 0, 3)]; + std::complex abcd = inarr[getVectorIndex(1, 1, 1, 1)]; + std::complex abdd = inarr[getVectorIndex(1, 1, 0, 2)]; + std::complex acdd = inarr[getVectorIndex(1, 0, 1, 2)]; + std::complex addd = inarr[getVectorIndex(1, 0, 0, 3)]; + std::complex bcdd = inarr[getVectorIndex(0, 1, 1, 2)]; + std::complex bddd = inarr[getVectorIndex(0, 1, 0, 3)]; + std::complex cddd = inarr[getVectorIndex(0, 0, 1, 3)]; + std::complex abcdd = inarr[getVectorIndex(1, 1, 1, 2)]; + std::complex abddd = inarr[getVectorIndex(1, 1, 0, 3)]; + std::complex acddd = inarr[getVectorIndex(1, 0, 1, 3)]; + std::complex bcddd = inarr[getVectorIndex(0, 1, 1, 3)]; + std::complex abcddd = inarr[getVectorIndex(1, 1, 1, 3)]; + return (-120. * abcddd + 24. * acddd * b + 6. * addd * bc + 12. * add * bcd + 18. * ad * bcdd + + 24. * a * bcddd + 18. * acdd * bd + 12. * acd * bdd + 6. * ac * bddd + 24. * abddd * c - + 6. * addd * b * c - 6. * add * bd * c - 6. * ad * bdd * c - 6. * a * bddd * c + 18. * abdd * cd - + 6. * add * b * cd - 6. * ad * bd * cd - 6. * a * bdd * cd + 12. * abd * cdd - 6. * ad * b * cdd - + 6. * a * bd * cdd + 6. * ab * cddd - 6. * a * b * cddd + 72. * abcdd * d - 18. * acdd * b * d - + 6. * add * bc * d - 12. * ad * bcd * d - 18. * a * bcdd * d - 12. * acd * bd * d - 6. * ac * bdd * d - + 18. * abdd * c * d + 6. * add * b * c * d + 6. * ad * bd * c * d + 6. * a * bdd * c * d - + 12. * abd * cd * d + 6. * ad * b * cd * d + 6. * a * bd * cd * d - 6. * ab * cdd * d + 6. * a * b * cdd * d - + 18. * abcd * d * d + 6. * acd * b * d * d + 3. * ad * bc * d * d + 6. * a * bcd * d * d + + 3. * ac * bd * d * d + 6. * abd * c * d * d - 3. * ad * b * c * d * d - 3. * a * bd * c * d * d + + 3. * ab * cd * d * d - 3. * a * b * cd * d * d + 2. * abc * d * d * d - ac * b * d * d * d - a * bc * d * d * d - + ab * c * d * d * d + a * b * c * d * d * d + 18. * abcd * dd - 6. * acd * b * dd - 3. * ad * bc * dd - + 6. * a * bcd * dd - 3. * ac * bd * dd - 6. * abd * c * dd + 3. * ad * b * c * dd + 3. * a * bd * c * dd - + 3. * ab * cd * dd + 3. * a * b * cd * dd - 6. * abc * d * dd + 3. * ac * b * d * dd + 3. * a * bc * d * dd + + 3. * ab * c * d * dd - 3. * a * b * c * d * dd + 4. * abc * ddd - 2. * ac * b * ddd - 2. * a * bc * ddd - + 2. * ab * c * ddd + 2. * a * b * c * ddd) + .real(); +} +template +double FlowPtContainer::getStdABDDDD(T& inarr) +{ + std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; + std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; + std::complex d = inarr[getVectorIndex(0, 0, 0, 1)]; + std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; + std::complex ad = inarr[getVectorIndex(1, 0, 0, 1)]; + std::complex bd = inarr[getVectorIndex(0, 1, 0, 1)]; + std::complex dd = inarr[getVectorIndex(0, 0, 0, 2)]; + std::complex abd = inarr[getVectorIndex(1, 1, 0, 1)]; + std::complex add = inarr[getVectorIndex(1, 0, 0, 2)]; + std::complex bdd = inarr[getVectorIndex(0, 1, 0, 2)]; + std::complex ddd = inarr[getVectorIndex(0, 0, 0, 3)]; + std::complex abdd = inarr[getVectorIndex(1, 1, 0, 2)]; + std::complex addd = inarr[getVectorIndex(1, 0, 0, 3)]; + std::complex bddd = inarr[getVectorIndex(0, 1, 0, 3)]; + std::complex dddd = inarr[getVectorIndex(0, 0, 0, 4)]; + std::complex abddd = inarr[getVectorIndex(1, 1, 0, 3)]; + std::complex adddd = inarr[getVectorIndex(1, 0, 0, 4)]; + std::complex bdddd = inarr[getVectorIndex(0, 1, 0, 4)]; + std::complex abdddd = inarr[getVectorIndex(1, 1, 0, 4)]; + return (-120. * abdddd + 24. * adddd * b + 24. * addd * bd + 24. * add * bdd + 24. * ad * bddd + + 24. * a * bdddd + 96. * abddd * d - 24. * addd * b * d - 24. * add * bd * d - 24. * ad * bdd * d - + 24. * a * bddd * d - 36. * abdd * d * d + 12. * add * b * d * d + 12. * ad * bd * d * d + + 12. * a * bdd * d * d + 8. * abd * d * d * d - 4. * ad * b * d * d * d - 4. * a * bd * d * d * d - ab * d * d * d * d + + a * b * d * d * d * d + 36. * abdd * dd - 12. * add * b * dd - 12. * ad * bd * dd - 12. * a * bdd * dd - + 24. * abd * d * dd + 12. * ad * b * d * dd + 12. * a * bd * d * dd + 6. * ab * d * d * dd - + 6. * a * b * d * d * dd - 3. * ab * dd * d + 3. * a * b * dd * d + 16. * abd * ddd - 8. * ad * b * ddd - + 8. * a * bd * ddd - 8. * ab * d * ddd + 8. * a * b * d * ddd + 6. * ab * dddd - 6. * a * b * dddd) + .real(); +} +template +double FlowPtContainer::getStdABCCC(T& inarr) +{ + std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; + std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; + std::complex c = inarr[getVectorIndex(0, 0, 1, 0)]; + std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; + std::complex ac = inarr[getVectorIndex(1, 0, 1, 0)]; + std::complex bc = inarr[getVectorIndex(0, 1, 1, 0)]; + std::complex cc = inarr[getVectorIndex(0, 0, 2, 0)]; + std::complex abc = inarr[getVectorIndex(1, 1, 1, 0)]; + std::complex acc = inarr[getVectorIndex(1, 0, 2, 0)]; + std::complex bcc = inarr[getVectorIndex(0, 1, 2, 0)]; + std::complex ccc = inarr[getVectorIndex(0, 0, 3, 0)]; + std::complex abcc = inarr[getVectorIndex(1, 1, 2, 0)]; + std::complex accc = inarr[getVectorIndex(1, 0, 3, 0)]; + std::complex bccc = inarr[getVectorIndex(0, 1, 3, 0)]; + std::complex abccc = inarr[getVectorIndex(1, 1, 3, 0)]; + return (24. * abccc - 6. * accc * b - 6. * acc * bc - 6. * ac * bcc - 6. * a * bccc - 18. * abcc * c + + 6. * acc * b * c + 6. * ac * bc * c + 6. * a * bcc * c + 6. * abc * c * c - 3. * ac * b * c * c - + 3. * a * bc * c * c - ab * c * c * c + a * b * c * c * c - 6. * abc * cc + 3. * ac * b * cc + 3. * a * bc * cc + + 3. * ab * c * cc - 3. * a * b * c * cc - 2. * ab * ccc + 2. * a * b * ccc) + .real(); +} +template +double FlowPtContainer::getStdABCCD(T& inarr) +{ + std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; + std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; + std::complex c = inarr[getVectorIndex(0, 0, 1, 0)]; + std::complex d = inarr[getVectorIndex(0, 0, 0, 1)]; + std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; + std::complex ac = inarr[getVectorIndex(1, 0, 1, 0)]; + std::complex ad = inarr[getVectorIndex(1, 0, 0, 1)]; + std::complex bc = inarr[getVectorIndex(0, 1, 1, 0)]; + std::complex bd = inarr[getVectorIndex(0, 1, 0, 1)]; + std::complex cc = inarr[getVectorIndex(0, 0, 2, 0)]; + std::complex cd = inarr[getVectorIndex(0, 0, 1, 1)]; + std::complex abc = inarr[getVectorIndex(1, 1, 1, 0)]; + std::complex abd = inarr[getVectorIndex(1, 1, 0, 1)]; + std::complex acc = inarr[getVectorIndex(1, 0, 2, 0)]; + std::complex bcc = inarr[getVectorIndex(0, 1, 2, 0)]; + std::complex ccd = inarr[getVectorIndex(0, 0, 2, 1)]; + std::complex acd = inarr[getVectorIndex(1, 0, 1, 1)]; + std::complex bcd = inarr[getVectorIndex(0, 1, 1, 1)]; + std::complex abcc = inarr[getVectorIndex(1, 1, 2, 0)]; + std::complex abcd = inarr[getVectorIndex(1, 1, 1, 1)]; + std::complex accd = inarr[getVectorIndex(1, 0, 2, 1)]; + std::complex bccd = inarr[getVectorIndex(0, 1, 2, 1)]; + std::complex abccd = inarr[getVectorIndex(1, 1, 2, 1)]; + return (24. * abccd - 6. * accd * b - 4. * acd * bc - 2. * ad * bcc - 6. * a * bccd - 4. * ac * bcd - + 2. * acc * bd - 12. * abcd * c + 4. * acd * b * c + 2. * ad * bc * c + 4. * a * bcd * c + + 2. * ac * bd * c + 2. * abd * c * c - ad * b * c * c - a * bd * c * c - 2. * abd * cc + ad * b * cc + + a * bd * cc - 2. * ab * ccd + 2. * a * b * ccd - 4. * abc * cd + 2. * ac * b * cd + 2. * a * bc * cd + + 2. * ab * c * cd - 2. * a * b * c * cd - 6. * abcc * d + 2. * acc * b * d + 2. * ac * bc * d + + 2. * a * bcc * d + 4. * abc * c * d - 2. * ac * b * c * d - 2. * a * bc * c * d - ab * c * c * d + + a * b * c * c * d + ab * cc * d - a * b * cc * d) + .real(); +} +template +double FlowPtContainer::getStdABCDD(T& inarr) +{ + std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; + std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; + std::complex c = inarr[getVectorIndex(0, 0, 1, 0)]; + std::complex d = inarr[getVectorIndex(0, 0, 0, 1)]; + std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; + std::complex ac = inarr[getVectorIndex(1, 0, 1, 0)]; + std::complex ad = inarr[getVectorIndex(1, 0, 0, 1)]; + std::complex bc = inarr[getVectorIndex(0, 1, 1, 0)]; + std::complex bd = inarr[getVectorIndex(0, 1, 0, 1)]; + std::complex cd = inarr[getVectorIndex(0, 0, 1, 1)]; + std::complex dd = inarr[getVectorIndex(0, 0, 0, 2)]; + std::complex abc = inarr[getVectorIndex(1, 1, 1, 0)]; + std::complex abd = inarr[getVectorIndex(1, 1, 0, 1)]; + std::complex add = inarr[getVectorIndex(1, 0, 0, 2)]; + std::complex bdd = inarr[getVectorIndex(0, 1, 0, 2)]; + std::complex cdd = inarr[getVectorIndex(0, 0, 1, 2)]; + std::complex acd = inarr[getVectorIndex(1, 0, 1, 1)]; + std::complex bcd = inarr[getVectorIndex(0, 1, 1, 1)]; + std::complex abdd = inarr[getVectorIndex(1, 1, 0, 2)]; + std::complex abcd = inarr[getVectorIndex(1, 1, 1, 1)]; + std::complex acdd = inarr[getVectorIndex(1, 0, 1, 2)]; + std::complex bcdd = inarr[getVectorIndex(0, 1, 1, 2)]; + std::complex abcdd = inarr[getVectorIndex(1, 1, 1, 2)]; + return (24. * abcdd - 6. * acdd * b - 2. * add * bc - 4. * ad * bcd - 6. * a * bcdd - 4. * acd * bd - + 2. * ac * bdd - 6. * abdd * c + 2. * add * b * c + 2. * ad * bd * c + 2. * a * bdd * c - 4. * abd * cd + + 2. * ad * b * cd + 2. * a * bd * cd - 2. * ab * cdd + 2. * a * b * cdd - 12. * abcd * d + + 4. * acd * b * d + 2. * ad * bc * d + 4. * a * bcd * d + 2. * ac * bd * d + 4. * abd * c * d - + 2. * ad * b * c * d - 2. * a * bd * c * d + 2. * ab * cd * d - 2. * a * b * cd * d + 2. * abc * d * d - + ac * b * d * d - a * bc * d * d - ab * c * d * d + a * b * c * d * d - 2. * abc * dd + ac * b * dd + + a * bc * dd + ab * c * dd - a * b * c * dd) + .real(); +} +template +double FlowPtContainer::getStdABDDD(T& inarr) +{ + std::complex a = inarr[getVectorIndex(1, 0, 0, 0)]; + std::complex b = inarr[getVectorIndex(0, 1, 0, 0)]; + std::complex d = inarr[getVectorIndex(0, 0, 0, 1)]; + std::complex ab = inarr[getVectorIndex(1, 1, 0, 0)]; + std::complex ad = inarr[getVectorIndex(1, 0, 0, 1)]; + std::complex bd = inarr[getVectorIndex(0, 1, 0, 1)]; + std::complex dd = inarr[getVectorIndex(0, 0, 0, 2)]; + std::complex abd = inarr[getVectorIndex(1, 1, 0, 1)]; + std::complex add = inarr[getVectorIndex(1, 0, 0, 2)]; + std::complex bdd = inarr[getVectorIndex(0, 1, 0, 2)]; + std::complex ddd = inarr[getVectorIndex(0, 0, 0, 3)]; + std::complex abdd = inarr[getVectorIndex(1, 1, 0, 2)]; + std::complex addd = inarr[getVectorIndex(1, 0, 0, 3)]; + std::complex bddd = inarr[getVectorIndex(0, 1, 0, 3)]; + std::complex abddd = inarr[getVectorIndex(1, 1, 0, 3)]; + return (24. * abddd - 6. * addd * b - 6. * add * bd - 6. * ad * bdd - 6. * a * bddd - 18. * abdd * d + + 6. * add * b * d + 6. * ad * bd * d + 6. * a * bdd * d + 6. * abd * d * d - 3. * ad * b * d * d - + 3. * a * bd * d * d - ab * d * d * d + a * b * d * d * d - 6. * abd * dd + 3. * ad * b * dd + 3. * a * bd * dd + + 3. * ab * d * dd - 3. * a * b * d * dd - 2. * ab * ddd + 2. * a * b * ddd) + .real(); +} double FlowPtContainer::orderedAddition(std::vector vec) { double sum = 0; diff --git a/PWGCF/GenericFramework/Core/FlowPtContainer.h b/PWGCF/GenericFramework/Core/FlowPtContainer.h index be68a564d84..207e1a36fe7 100644 --- a/PWGCF/GenericFramework/Core/FlowPtContainer.h +++ b/PWGCF/GenericFramework/Core/FlowPtContainer.h @@ -53,7 +53,7 @@ class FlowPtContainer : public TNamed void fill(const double& w, const double& pt); void fillArray(FillType a, FillType b, double c, double d); int getVectorIndex(const int i, const int j) { return j * (mpar + 1) + i; } // index for 2d array for storing pt correlations - int getVectorIndex(const int i, const int j, const int k, const int l) { return i + j * 3 + k * 3 * 3 + l * 3 * 3 * 3; } // index for 4d array for std vnpt correlation - size 3x3x3x3 + int getVectorIndex(const int i, const int j, const int k, const int l) { return i + j * 3 + k * 3 * 3 + l * 3 * 3 * 5; } // index for 4d array for std vnpt correlation - size 3x3x3x3 void calculateCorrelations(); void calculateCMTerms(); void fillPtProfiles(const double& lMult, const double& rn); @@ -104,9 +104,9 @@ class FlowPtContainer : public TNamed cmDen.clear(); fillCounter = 0; arr.clear(); - arr.resize(3 * 3 * 3 * 3, {0.0, 0.0}); + arr.resize(3 * 3 * 5 * 5, {0.0, 0.0}); warr.clear(); - warr.resize(3 * 3 * 3 * 3, 0.0); + warr.resize(3 * 3 * 5 * 5, 0.0); }; TList* fCMTermList; @@ -115,18 +115,18 @@ class FlowPtContainer : public TNamed TList* fCumulantList; TList* fCentralMomentList; - int mpar; //! + int mpar; int fillCounter; //! unsigned int fEventWeight; //! - bool fUseCentralMoments; //! - bool fUseGap; //! + bool fUseCentralMoments; + bool fUseGap; void mergeBSLists(TList* source, TList* target); TH1* raiseHistToPower(TH1* inh, double p); - std::vector sumP; //! - std::vector corrNum; //! - std::vector corrDen; //! - std::vector cmVal; //! - std::vector cmDen; //! + std::vector sumP; //! + std::vector corrNum; //! + std::vector corrDen; //! + std::vector cmVal; //! + std::vector cmDen; //! std::vector> arr; //! std::vector warr; //! template @@ -149,6 +149,24 @@ class FlowPtContainer : public TNamed double getStdABC(T& inarr); template double getStdABD(T& inarr); + template + double getStdABCCCC(T& inarr); + template + double getStdABCCCD(T& inarr); + template + double getStdABCCDD(T& inarr); + template + double getStdABCDDD(T& inarr); + template + double getStdABDDDD(T& inarr); + template + double getStdABCCC(T& inarr); + template + double getStdABCCD(T& inarr); + template + double getStdABCDD(T& inarr); + template + double getStdABDDD(T& inarr); private: static constexpr float FactorialArray[9] = {1., 1., 2., 6., 24., 120., 720., 5040., 40320.}; diff --git a/PWGCF/GenericFramework/Core/GFW.cxx b/PWGCF/GenericFramework/Core/GFW.cxx index 1541aaf8993..350fe752156 100644 --- a/PWGCF/GenericFramework/Core/GFW.cxx +++ b/PWGCF/GenericFramework/Core/GFW.cxx @@ -9,16 +9,13 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/* -Author: Vytautas Vislavicius -Extention of Generic Flow (https://arxiv.org/abs/1312.3572 by A. Bilandzic et al.) -Class steers the initialization and calculation of n-particle correlations. Uses recursive function, all terms are calculated only once. -Latest version includes the calculation of any number of gaps and any combination of harmonics (including eg symmetric cumulants, etc.) -If used, modified, or distributed, please aknowledge the author of this code. -*/ - #include "GFW.h" +#include +#include +#include +#include + using std::complex; using std::pair; using std::string; diff --git a/PWGCF/GenericFramework/Core/GFW.h b/PWGCF/GenericFramework/Core/GFW.h index 629731bea85..8ec2b78d095 100644 --- a/PWGCF/GenericFramework/Core/GFW.h +++ b/PWGCF/GenericFramework/Core/GFW.h @@ -9,23 +9,22 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/* -Author: Vytautas Vislavicius -Extention of Generic Flow (https://arxiv.org/abs/1312.3572 by A. Bilandzic et al.) -Class steers the initialization and calculation of n-particle correlations. Uses recursive function, all terms are calculated only once. -Latest version includes the calculation of any number of gaps and any combination of harmonics (including eg symmetric cumulants, etc.) -If used, modified, or distributed, please aknowledge the author of this code. -*/ +/// \file GFW.h/.cxx +/// \brief Class steers the initialization and calculation of n-particle correlations. Uses recursive function, all terms are calculated only once. +/// \author Emil Gorm Nielsen (ack. V. Vislavicius), NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFW_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFW_H_ #include "GFWCumulant.h" #include "GFWPowerArray.h" -#include -#include -#include + #include #include +#include +#include +#include +#include class GFW { diff --git a/PWGCF/GenericFramework/Core/GFWCumulant.cxx b/PWGCF/GenericFramework/Core/GFWCumulant.cxx index a82e3bcd08b..f27da24bd27 100644 --- a/PWGCF/GenericFramework/Core/GFWCumulant.cxx +++ b/PWGCF/GenericFramework/Core/GFWCumulant.cxx @@ -9,16 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/* -Author: Vytautas Vislavicius -Extention of Generic Flow (https://arxiv.org/abs/1312.3572 by A. Bilandzic et al.) -A part of -A container to store Q vectors for one subevent with an extra layer to recursively calculate particle correlations. -If used, modified, or distributed, please aknowledge the author of this code. -*/ - #include "GFWCumulant.h" +#include + using std::complex; using std::vector; diff --git a/PWGCF/GenericFramework/Core/GFWCumulant.h b/PWGCF/GenericFramework/Core/GFWCumulant.h index f8cf6624542..2567a2e9c4a 100644 --- a/PWGCF/GenericFramework/Core/GFWCumulant.h +++ b/PWGCF/GenericFramework/Core/GFWCumulant.h @@ -9,13 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/* -Author: Vytautas Vislavicius -Extention of Generic Flow (https://arxiv.org/abs/1312.3572 by A. Bilandzic et al.) -A part of -A container to store Q vectors for one subevent with an extra layer to recursively calculate particle correlations. -If used, modified, or distributed, please aknowledge the author of this code. -*/ +/// \file GFWCumulant.h/.cxx +/// \brief A container to store Q vectors for one subevent with an extra layer to recursively calculate particle correlations. +/// \author Emil Gorm Nielsen (ack. V. Vislavicius), NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWCUMULANT_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWCUMULANT_H_ diff --git a/PWGCF/GenericFramework/Core/GFWPowerArray.h b/PWGCF/GenericFramework/Core/GFWPowerArray.h index 82314374e00..ba38f2fcc54 100644 --- a/PWGCF/GenericFramework/Core/GFWPowerArray.h +++ b/PWGCF/GenericFramework/Core/GFWPowerArray.h @@ -9,6 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file GFWPowerArray.h/.cxx +/// \brief Class to compute necessary powers of Q-vectors based on input correlations +/// \author Emil Gorm Nielsen, NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWPOWERARRAY_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWPOWERARRAY_H_ diff --git a/PWGCF/GenericFramework/Core/GFWWeights.cxx b/PWGCF/GenericFramework/Core/GFWWeights.cxx index 8ff60183f99..4d2d41cd85d 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeights.cxx @@ -11,6 +11,8 @@ #include "GFWWeights.h" #include "TMath.h" +#include + GFWWeights::GFWWeights() : TNamed("", ""), fDataFilled(kFALSE), fMCFilled(kFALSE), @@ -44,7 +46,7 @@ GFWWeights::~GFWWeights() if (fbinsPt) delete[] fbinsPt; }; -void GFWWeights::SetPtBins(int Nbins, double* bins) +void GFWWeights::setPtBins(int Nbins, double* bins) { if (fbinsPt) delete[] fbinsPt; @@ -53,7 +55,7 @@ void GFWWeights::SetPtBins(int Nbins, double* bins) for (int i = 0; i <= fNbinsPt; ++i) fbinsPt[i] = bins[i]; }; -void GFWWeights::Init(bool AddData, bool AddMC) +void GFWWeights::init(bool AddData, bool AddMC) { if (!fbinsPt) { // If pT bins not initialized, set to default (-1 to 1e6) to accept everything fNbinsPt = 1; @@ -65,7 +67,7 @@ void GFWWeights::Init(bool AddData, bool AddMC) fW_data = new TObjArray(); fW_data->SetName("GFWWeights_Data"); fW_data->SetOwner(kTRUE); - const char* tnd = GetBinName(0, 0, Form("data_%s", this->GetName())); + const char* tnd = getBinName(0, 0, Form("data_%s", this->GetName())); fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); fDataFilled = kTRUE; } @@ -76,8 +78,8 @@ void GFWWeights::Init(bool AddData, bool AddMC) fW_mcgen->SetName("GFWWeights_MCGen"); fW_mcrec->SetOwner(kTRUE); fW_mcgen->SetOwner(kTRUE); - const char* tnr = GetBinName(0, 0, "mcrec"); // all integrated over cent. anyway - const char* tng = GetBinName(0, 0, "mcgen"); // all integrated over cent. anyway + const char* tnr = getBinName(0, 0, "mcrec"); // all integrated over cent. anyway + const char* tng = getBinName(0, 0, "mcgen"); // all integrated over cent. anyway fW_mcrec->Add(new TH3D(tnr, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); fW_mcgen->Add(new TH3D(tng, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); reinterpret_cast(fW_mcrec->At(fW_mcrec->GetEntries() - 1))->GetXaxis()->Set(fNbinsPt, fbinsPt); @@ -86,7 +88,7 @@ void GFWWeights::Init(bool AddData, bool AddMC) } }; -void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) +void GFWWeights::fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) { TObjArray* tar = 0; const char* pf = ""; @@ -104,15 +106,15 @@ void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cen } if (!tar) return; - TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated + TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated if (!th3) { if (!htype) - tar->Add(new TH3D(GetBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated + tar->Add(new TH3D(getBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated th3 = reinterpret_cast(tar->At(tar->GetEntries() - 1)); } th3->Fill(htype ? pt : phi, eta, vz, weight); }; -double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) +double GFWWeights::getWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) { TObjArray* tar = 0; const char* pf = ""; @@ -130,7 +132,7 @@ double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, doubl } if (!tar) return 1; - TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); + TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); if (!th3) return 1; //-1; int xind = th3->GetXaxis()->FindBin(htype ? pt : phi); @@ -141,10 +143,10 @@ double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, doubl return 1. / weight; return 1; }; -double GFWWeights::GetNUA(double phi, double eta, double vz) +double GFWWeights::getNUA(double phi, double eta, double vz) { if (!fAccInt) - CreateNUA(); + createNUA(); int xind = fAccInt->GetXaxis()->FindBin(phi); int etaind = fAccInt->GetYaxis()->FindBin(eta); int vzind = fAccInt->GetZaxis()->FindBin(vz); @@ -153,10 +155,10 @@ double GFWWeights::GetNUA(double phi, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::GetNUE(double pt, double eta, double vz) +double GFWWeights::getNUE(double pt, double eta, double vz) { if (!fEffInt) - CreateNUE(); + createNUE(); int xind = fEffInt->GetXaxis()->FindBin(pt); int etaind = fEffInt->GetYaxis()->FindBin(eta); int vzind = fEffInt->GetZaxis()->FindBin(vz); @@ -165,7 +167,7 @@ double GFWWeights::GetNUE(double pt, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) +double GFWWeights::findMax(TH3D* inh, int& ix, int& iy, int& iz) { double maxv = inh->GetBinContent(1, 1, 1); for (int i = 1; i <= inh->GetNbinsX(); i++) @@ -179,10 +181,10 @@ double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) } return maxv; }; -void GFWWeights::MCToEfficiency() +void GFWWeights::mcToEfficiency() { if (fW_mcgen->GetEntries() < 1) { - printf("MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); + LOGF(info, "MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); return; } for (int i = 0; i < fW_mcrec->GetEntries(); i++) { @@ -194,7 +196,7 @@ void GFWWeights::MCToEfficiency() } fW_mcgen->Clear(); }; -void GFWWeights::RebinNUA(int nX, int nY, int nZ) +void GFWWeights::rebinNUA(int nX, int nY, int nZ) { if (fW_data->GetEntries() < 1) return; @@ -204,10 +206,10 @@ void GFWWeights::RebinNUA(int nX, int nY, int nZ) reinterpret_cast(fW_data->At(i))->RebinZ(nZ); } }; -void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) +void GFWWeights::createNUA(bool IntegrateOverCentAndPt) { if (!IntegrateOverCentAndPt) { - printf("Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); + LOGF(info, "Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); return; } TH1D* h1; @@ -240,7 +242,7 @@ void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) return; } }; -TH1D* GFWWeights::GetdNdPhi() +TH1D* GFWWeights::getdNdPhi() { TH3D* temph = reinterpret_cast(fW_data->At(0)->Clone("tempH3")); TH1D* reth = reinterpret_cast(temph->Project3D("x")); @@ -257,10 +259,10 @@ TH1D* GFWWeights::GetdNdPhi() } return reth; } -void GFWWeights::CreateNUE(bool IntegrateOverCentrality) +void GFWWeights::createNUE(bool IntegrateOverCentrality) { if (!IntegrateOverCentrality) { - printf("Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); + LOGF(info, "Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); return; } TH3D* num = 0; @@ -281,7 +283,7 @@ void GFWWeights::CreateNUE(bool IntegrateOverCentrality) return; } }; -void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) +void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) { FILE* flist = fopen(filelinks.Data(), "r"); char str[150]; @@ -290,7 +292,7 @@ void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, nFiles++; rewind(flist); if (nFiles == 0) { - printf("No files to read!\n"); + LOGF(info, "No files to read!\n"); return; } if (!fW_data && addData) { @@ -314,31 +316,31 @@ void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, (void)retVal; tf = new TFile(str, "READ"); if (tf->IsZombie()) { - printf("Could not open file %s!\n", str); + LOGF(warning, "Could not open file %s!\n", str); tf->Close(); continue; } TList* tl = reinterpret_cast(tf->Get(listName.Data())); GFWWeights* tw = reinterpret_cast(tl->FindObject(this->GetName())); if (!tw) { - printf("Could not fetch weights object from %s\n", str); + LOGF(warning, "Could not fetch weights object from %s\n", str); tf->Close(); continue; } if (addData) - AddArray(fW_data, tw->GetDataArray()); + addArray(fW_data, tw->getDataArray()); if (addRec) - AddArray(fW_mcrec, tw->GetRecArray()); + addArray(fW_mcrec, tw->getRecArray()); if (addGen) - AddArray(fW_mcgen, tw->GetGenArray()); + addArray(fW_mcgen, tw->getGenArray()); tf->Close(); delete tw; } }; -void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) +void GFWWeights::addArray(TObjArray* targ, TObjArray* sour) { if (!sour) { - printf("Source array does not exist!\n"); + LOGF(info, "Source array does not exist!\n"); return; } for (int i = 0; i < sour->GetEntries(); i++) { @@ -353,10 +355,10 @@ void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) } } }; -void GFWWeights::OverwriteNUA() +void GFWWeights::overwriteNUA() { if (!fAccInt) - CreateNUA(); + createNUA(); TString ts(fW_data->At(0)->GetName()); TH3D* trash = reinterpret_cast(fW_data->RemoveAt(0)); delete trash; @@ -384,29 +386,29 @@ Long64_t GFWWeights::Merge(TCollection* collist) GFWWeights* l_w = 0; TIter all_w(collist); while ((l_w = (reinterpret_cast(all_w())))) { - AddArray(fW_data, l_w->GetDataArray()); - AddArray(fW_mcrec, l_w->GetRecArray()); - AddArray(fW_mcgen, l_w->GetGenArray()); + addArray(fW_data, l_w->getDataArray()); + addArray(fW_mcrec, l_w->getRecArray()); + addArray(fW_mcgen, l_w->getGenArray()); nmerged++; } return nmerged; }; -TH1D* GFWWeights::GetIntegratedEfficiencyHist() +TH1D* GFWWeights::getIntegratedEfficiencyHist() { if (!fW_mcgen) { - printf("MCGen array does not exist!\n"); + LOGF(warning, "MCGen array does not exist!\n"); return 0; } if (!fW_mcrec) { - printf("MCRec array does not exist!\n"); + LOGF(warning, "MCRec array does not exist!\n"); return 0; } if (!fW_mcgen->GetEntries()) { - printf("MCGen array is empty!\n"); + LOGF(warning, "MCGen array is empty!\n"); return 0; } if (!fW_mcrec->GetEntries()) { - printf("MCRec array is empty!\n"); + LOGF(warning, "MCRec array is empty!\n"); return 0; } TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); @@ -426,25 +428,25 @@ TH1D* GFWWeights::GetIntegratedEfficiencyHist() delete den1d; return num1d; } -bool GFWWeights::CalculateIntegratedEff() +bool GFWWeights::calculateIntegratedEff() { if (fIntEff) delete fIntEff; - fIntEff = GetIntegratedEfficiencyHist(); + fIntEff = getIntegratedEfficiencyHist(); if (!fIntEff) { return kFALSE; } fIntEff->SetName("IntegratedEfficiency"); return kTRUE; } -double GFWWeights::GetIntegratedEfficiency(double pt) +double GFWWeights::getIntegratedEfficiency(double pt) { if (!fIntEff) - if (!CalculateIntegratedEff()) + if (!calculateIntegratedEff()) return 0; return fIntEff->GetBinContent(fIntEff->FindBin(pt)); } -TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, double vzmax) +TH1D* GFWWeights::getEfficiency(double etamin, double etamax, double vzmin, double vzmax) { TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); for (int i = 1; i < fW_mcrec->GetEntries(); i++) @@ -470,3 +472,27 @@ TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, doub delete den1d; return num1d; } +void GFWWeights::mergeWeights(GFWWeights* other) +{ + if (!fW_data) { + fW_data = new TObjArray(); + fW_data->SetName("Weights_Data"); + fW_data->SetOwner(kTRUE); + } + addArray(fW_data, other->getDataArray()); + return; +} +void GFWWeights::setTH3D(TH3D* th3d) +{ + if (!fW_data) { + fW_data = new TObjArray(); + fW_data->SetName("GFWWeights_Data"); + fW_data->SetOwner(kTRUE); + fW_data->Add(th3d); + return; + } + TString ts(fW_data->At(0)->GetName()); + TH3D* trash = reinterpret_cast(fW_data->RemoveAt(0)); + delete trash; + fW_data->Add(reinterpret_cast(th3d->Clone(ts.Data()))); +} diff --git a/PWGCF/GenericFramework/Core/GFWWeights.h b/PWGCF/GenericFramework/Core/GFWWeights.h index e88904f14e8..f60783ccec8 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.h +++ b/PWGCF/GenericFramework/Core/GFWWeights.h @@ -9,8 +9,15 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file GFWWeights.h +/// \brief Class to store corrections for the Generic Framework +/// \author Emil Gorm Nielsen, NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ + +#include "Framework/Logger.h" + #include "TObjArray.h" #include "TNamed.h" #include "TH3D.h" @@ -26,32 +33,34 @@ class GFWWeights : public TNamed GFWWeights(); explicit GFWWeights(const char* name); ~GFWWeights(); - void Init(bool AddData = kTRUE, bool AddM = kTRUE); - void Fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double GetWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double GetNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up - double GetNUE(double pt, double eta, double vz); // fetches weight from fEffInt - bool IsDataFilled() { return fDataFilled; } - bool IsMCFilled() { return fMCFilled; } - double FindMax(TH3D* inh, int& ix, int& iy, int& iz); - void MCToEfficiency(); - TObjArray* GetRecArray() { return fW_mcrec; } - TObjArray* GetGenArray() { return fW_mcgen; } - TObjArray* GetDataArray() { return fW_data; } - void CreateNUA(bool IntegrateOverCentAndPt = kTRUE); - void CreateNUE(bool IntegrateOverCentrality = kTRUE); - TH1D* GetIntegratedEfficiencyHist(); - bool CalculateIntegratedEff(); - double GetIntegratedEfficiency(double pt); - void SetDataFilled(bool newval) { fDataFilled = newval; } - void SetMCFilled(bool newval) { fMCFilled = newval; } - void ReadAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); - void SetPtBins(int Nbins, double* bins); + void init(bool AddData = kTRUE, bool AddM = kTRUE); + void fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double getWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double getNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up + double getNUE(double pt, double eta, double vz); // fetches weight from fEffInt + bool isDataFilled() { return fDataFilled; } + bool isMCFilled() { return fMCFilled; } + double findMax(TH3D* inh, int& ix, int& iy, int& iz); + void mcToEfficiency(); + TObjArray* getRecArray() { return fW_mcrec; } + TObjArray* getGenArray() { return fW_mcgen; } + TObjArray* getDataArray() { return fW_data; } + void createNUA(bool IntegrateOverCentAndPt = kTRUE); + void createNUE(bool IntegrateOverCentrality = kTRUE); + TH1D* getIntegratedEfficiencyHist(); + bool calculateIntegratedEff(); + double getIntegratedEfficiency(double pt); + void setDataFilled(bool newval) { fDataFilled = newval; } + void setMCFilled(bool newval) { fMCFilled = newval; } + void readAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); + void setPtBins(int Nbins, double* bins); Long64_t Merge(TCollection* collist); - void RebinNUA(int nX = 1, int nY = 2, int nZ = 5); - void OverwriteNUA(); - TH1D* GetdNdPhi(); - TH1D* GetEfficiency(double etamin, double etamax, double vzmin, double vzmax); + void rebinNUA(int nX = 1, int nY = 2, int nZ = 5); + void overwriteNUA(); + TH1D* getdNdPhi(); + TH1D* getEfficiency(double etamin, double etamax, double vzmin, double vzmax); + void mergeWeights(GFWWeights* other); + void setTH3D(TH3D* th3d); private: bool fDataFilled; @@ -64,8 +73,8 @@ class GFWWeights : public TNamed TH3D* fAccInt; //! int fNbinsPt; //! do not store double* fbinsPt; //! do not store - void AddArray(TObjArray* targ, TObjArray* sour); - const char* GetBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") + void addArray(TObjArray* targ, TObjArray* sour); + const char* getBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") { int ptind = 0; // GetPtBin(ptv); int v0mind = 0; // GetV0MBin(v0mv); diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx index 90ac95d0f0d..11a6ffe3159 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx @@ -15,23 +15,25 @@ /// \brief one object to hold a list of GFWWeights objects, #include -#include #include "GFWWeightsList.h" GFWWeightsList::GFWWeightsList() : TNamed("", ""), list(0) { - runNumerMap.clear(); + runNumberMap.clear(); + runNumberPIDMap.clear(); } GFWWeightsList::GFWWeightsList(const char* name) : TNamed(name, name), list(0) { - runNumerMap.clear(); + runNumberMap.clear(); + runNumberPIDMap.clear(); } GFWWeightsList::~GFWWeightsList() { delete list; - runNumerMap.clear(); + runNumberMap.clear(); + runNumberPIDMap.clear(); } void GFWWeightsList::init(const char* listName) @@ -46,16 +48,19 @@ void GFWWeightsList::addGFWWeightsByName(const char* weightName, int nPtBins, do if (!list) { init("weightList"); } + if (reinterpret_cast(list->FindObject(weightName))) { + return; + } GFWWeights* weight = new GFWWeights(weightName); - weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); } GFWWeights* GFWWeightsList::getGFWWeightsByName(const char* weightName) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } return reinterpret_cast(list->FindObject(weightName)); @@ -66,22 +71,131 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi if (!list) { init("weightList"); } + if (runNumberMap.contains(runNumber)) { + return; + } GFWWeights* weight = new GFWWeights(Form("weight_%d", runNumber)); - weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); - runNumerMap.insert(std::make_pair(runNumber, weight)); + runNumberMap.insert(std::make_pair(runNumber, weight)); } GFWWeights* GFWWeightsList::getGFWWeightsByRun(int runNumber) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } - if (!runNumerMap.contains(runNumber)) { - printf("Error: weight for run %d is not found\n", runNumber); + if (!runNumberMap.contains(runNumber)) { + LOGF(error, "weight for run %d is not found\n", runNumber); return nullptr; } - return runNumerMap.at(runNumber); + return runNumberMap.at(runNumber); +} + +void GFWWeightsList::addPIDGFWWeightsByName(const char* weightName, int nPtBins, double* ptBins, double ptrefup, bool addData, bool addMC) +{ + if (!list) { + init("weightList"); + } + + std::vector ptbins(ptBins, ptBins + nPtBins + 1); + auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); + std::vector refpt(ptbins.begin(), it + 1); + + for (auto& type : species) { + if (reinterpret_cast(list->FindObject((static_cast(weightName) + type).c_str()))) { + continue; + } + GFWWeights* weight = new GFWWeights(Form("%s", (static_cast(weightName) + type).c_str())); + if (!type.compare("_ref")) + weight->setPtBins(refpt.size() - 1, &(refpt[0])); + else + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); + list->Add(weight); + } } +GFWWeights* GFWWeightsList::getPIDGFWWeightsByName(const char* weightName, int pidIndex) +{ + if (static_cast(pidIndex) >= species.size()) + return nullptr; + if (!list) { + LOGF(error, "weight list is not initialized\n"); + return nullptr; + } + return reinterpret_cast(list->FindObject((static_cast(weightName) + species[pidIndex]).c_str())); +} +void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData, bool addMC) +{ + if (!list) { + init("weightList"); + } + + if (runNumberPIDMap.contains(runNumber)) + return; + std::vector ptbins(ptBins, ptBins + nPtBins + 1); + auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); + std::vector refpt(ptbins.begin(), it + 1); + + std::vector weights; + for (auto& type : species) { + GFWWeights* weight = new GFWWeights(Form("weight_%d%s", runNumber, type.c_str())); + if (!type.compare("_ref")) + weight->setPtBins(refpt.size() - 1, &(refpt[0])); + else + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); + list->Add(weight); + weights.push_back(weight); + } + LOGF(info, "Adding weights for run %d\n", runNumber); + runNumberPIDMap.insert(std::make_pair(runNumber, weights)); + return; +} + +GFWWeights* GFWWeightsList::getPIDGFWWeightsByRun(int runNumber, int pidIndex) +{ + if (!list) { + LOGF(error, "weight list is not initialized\n"); + return nullptr; + } + if (!runNumberPIDMap.contains(runNumber)) { + LOGF(error, "PID weights for run %d is not found\n", runNumber); + return nullptr; + } + return runNumberPIDMap.at(runNumber)[pidIndex]; +} +Long64_t GFWWeightsList::Merge(TCollection* collist) +{ + Long64_t nmerged = 0; + if (!list) { + list = new TObjArray(); + list->SetName("weightList"); + list->SetOwner(kTRUE); + } + TIter allWeights(collist); + GFWWeightsList* lWeight = 0; + while ((lWeight = (reinterpret_cast(allWeights())))) { + addArray(list, lWeight->getList()); + nmerged++; + } + return nmerged; +} +void GFWWeightsList::addArray(TObjArray* target, TObjArray* source) +{ + if (!source) { + return; + } + for (int i = 0; i < source->GetEntries(); i++) { + GFWWeights* sourw = reinterpret_cast(source->At(i)); + GFWWeights* targw = reinterpret_cast(target->FindObject(sourw->GetName())); + if (!targw) { + targw = reinterpret_cast(sourw->Clone(sourw->GetName())); + target->Add(targw); + } else { + targw->mergeWeights(sourw); + } + } +}; diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.h b/PWGCF/GenericFramework/Core/GFWWeightsList.h index 278a6e4edc6..c0f208a7088 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.h +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.h @@ -17,6 +17,12 @@ #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTSLIST_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTSLIST_H_ #include +#include +#include +#include + +#include "Framework/Logger.h" + #include "TObjArray.h" #include "GFWWeights.h" @@ -31,11 +37,25 @@ class GFWWeightsList : public TNamed GFWWeights* getGFWWeightsByName(const char* weightName); void addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, bool addData = kTRUE, bool addMC = kTRUE); GFWWeights* getGFWWeightsByRun(int runNumber); + void addPIDGFWWeightsByName(const char* weightName, int nPtBins, double* ptBins, double ptrefup, bool addData = kTRUE, bool addMC = kTRUE); + GFWWeights* getPIDGFWWeightsByName(const char* weightName, int pidIndex); + void addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData = kTRUE, bool addMC = kTRUE); + GFWWeights* getPIDGFWWeightsByRun(int runNumber, int pidIndex); + void printRuns() + { + for (auto& el : runNumberPIDMap) + printf("%i\n", el.first); + } + TObjArray* getList() const { return list; } + Long64_t Merge(TCollection* collist); private: TObjArray* list; - std::map runNumerMap; + std::vector species = {"_ref", "_ch", "_pi", "_ka", "_pr"}; //! + std::map runNumberMap; + std::map> runNumberPIDMap; + void addArray(TObjArray* target, TObjArray* source); ClassDef(GFWWeightsList, 1); }; diff --git a/PWGCF/GenericFramework/Core/ProfileSubset.h b/PWGCF/GenericFramework/Core/ProfileSubset.h index 3d749e06b0e..fc920b898c4 100644 --- a/PWGCF/GenericFramework/Core/ProfileSubset.h +++ b/PWGCF/GenericFramework/Core/ProfileSubset.h @@ -9,9 +9,13 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file ProfileSubset.h/.cxx +/// \brief // Helper class to select a subrange of a TProfile +/// \author Emil Gorm Nielsen (ack. V. Vislavicius), NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_PROFILESUBSET_H_ #define PWGCF_GENERICFRAMEWORK_CORE_PROFILESUBSET_H_ -// Helper function to select a subrange of a TProfile + #include "TProfile.h" #include "TProfile2D.h" #include "TError.h" diff --git a/PWGCF/GenericFramework/Tasks/CMakeLists.txt b/PWGCF/GenericFramework/Tasks/CMakeLists.txt index ee71394c4cb..338f173aa73 100644 --- a/PWGCF/GenericFramework/Tasks/CMakeLists.txt +++ b/PWGCF/GenericFramework/Tasks/CMakeLists.txt @@ -13,3 +13,8 @@ o2physics_add_dpl_workflow(flow-generic-framework SOURCES flowGenericFramework.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-gfw-light-ions + SOURCES flowGfwLightIons.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore + COMPONENT_NAME Analysis) diff --git a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx index 712ab11b3da..79e56fbcff6 100644 --- a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -42,19 +44,18 @@ #include "FlowPtContainer.h" #include "GFWConfig.h" #include "GFWWeights.h" +#include "GFWWeightsList.h" #include #include #include +#include using namespace o2; using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::analysis; -using namespace o2::constants::math; #define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; -namespace o2::analysis::genericframework +namespace o2::analysis::gfw { std::vector ptbinning = {0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}; float ptpoilow = 0.2, ptpoiup = 10.0; @@ -66,7 +67,7 @@ int vtxZbins = 40; float vtxZlow = -10.0, vtxZup = 10.0; int phibins = 72; float philow = 0.0; -float phiup = TwoPI; +float phiup = o2::constants::math::TwoPI; int nchbins = 300; float nchlow = 0; float nchup = 3000; @@ -74,44 +75,57 @@ std::vector centbinning(90); int nBootstrap = 10; GFWRegions regions; GFWCorrConfigs configs; -} // namespace o2::analysis::genericframework +std::vector multGlobalCorrCutPars; +std::vector multPVCorrCutPars; +} // namespace o2::analysis::gfw -using namespace o2::analysis::genericframework; - -struct GenericFramework { +struct FlowGenericFramework { O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") O2_DEFINE_CONFIGURABLE(cfgMpar, int, 8, "Highest order of pt-pt correlations") + O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FT0A") O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Do correlations as function of Nch") O2_DEFINE_CONFIGURABLE(cfgFillWeights, bool, false, "Fill NUA weights") - O2_DEFINE_CONFIGURABLE(cfgRunByRunWeights, bool, false, "Use run by run NUA corrections") + O2_DEFINE_CONFIGURABLE(cfgRunByRun, bool, false, "Fill histograms on a run-by-run basis") O2_DEFINE_CONFIGURABLE(cfgFillQA, bool, false, "Fill QA histograms") O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") - O2_DEFINE_CONFIGURABLE(cfgUseAdditionalTrackCut, bool, false, "Use additional track cut on phi") O2_DEFINE_CONFIGURABLE(cfgUseCentralMoments, bool, true, "Use central moments in vn-pt calculations") O2_DEFINE_CONFIGURABLE(cfgUsePID, bool, true, "Enable PID information") O2_DEFINE_CONFIGURABLE(cfgUseGapMethod, bool, false, "Use gap method in vn-pt calculations") O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") - O2_DEFINE_CONFIGURABLE(cfgDCAxy, float, 0.2, "Cut on DCA in the transverse direction (cm)"); + O2_DEFINE_CONFIGURABLE(cfgDCAxyNSigma, float, 7, "Cut on number of sigma deviations from expected DCA in the transverse direction"); O2_DEFINE_CONFIGURABLE(cfgDCAz, float, 2, "Cut on DCA in the longitudinal direction (cm)"); - O2_DEFINE_CONFIGURABLE(cfgNcls, float, 70, "Cut on number of TPC clusters found"); + O2_DEFINE_CONFIGURABLE(cfgNTPCCls, float, 70, "Cut on number of TPC clusters found"); + O2_DEFINE_CONFIGURABLE(cfgNTPCXrows, float, 70, "Cut on number of TPC crossed rows"); + O2_DEFINE_CONFIGURABLE(cfgMinNITSCls, float, 5, "Cut on minimum number of ITS clusters found"); + O2_DEFINE_CONFIGURABLE(cfgChi2PrITSCls, float, 36, "Cut on chi^2 per ITS clusters found"); + O2_DEFINE_CONFIGURABLE(cfgChi2PrTPCCls, float, 2.5, "Cut on chi^2 per TPC clusters found"); O2_DEFINE_CONFIGURABLE(cfgPtmin, float, 0.2, "minimum pt (GeV/c)"); O2_DEFINE_CONFIGURABLE(cfgPtmax, float, 10, "maximum pt (GeV/c)"); O2_DEFINE_CONFIGURABLE(cfgEta, float, 0.8, "eta cut"); O2_DEFINE_CONFIGURABLE(cfgEtaPtPt, float, 0.4, "eta cut for pt-pt correlations"); O2_DEFINE_CONFIGURABLE(cfgVtxZ, float, 10, "vertex cut (cm)"); - O2_DEFINE_CONFIGURABLE(cfgOccupancySelection, int, -999, "Max occupancy selection, -999 to disable"); + O2_DEFINE_CONFIGURABLE(cfgOccupancySelection, int, 2000, "Max occupancy selection, -999 to disable"); O2_DEFINE_CONFIGURABLE(cfgNoSameBunchPileupCut, bool, true, "kNoSameBunchPileupCut"); O2_DEFINE_CONFIGURABLE(cfgIsGoodZvtxFT0vsPV, bool, true, "kIsGoodZvtxFT0vsPV"); + O2_DEFINE_CONFIGURABLE(cfgIsGoodITSLayersAll, bool, true, "kIsGoodITSLayersAll"); O2_DEFINE_CONFIGURABLE(cfgNoCollInTimeRangeStandard, bool, true, "kNoCollInTimeRangeStandard"); O2_DEFINE_CONFIGURABLE(cfgDoOccupancySel, bool, true, "Bool for event selection on detector occupancy"); - O2_DEFINE_CONFIGURABLE(cfgMultCut, bool, true, "Use additional evenr cut on mult correlations"); + O2_DEFINE_CONFIGURABLE(cfgMultCut, bool, true, "Use additional event cut on mult correlations"); O2_DEFINE_CONFIGURABLE(cfgTVXinTRD, bool, true, "Use kTVXinTRD (reject TRD triggered events)"); O2_DEFINE_CONFIGURABLE(cfgIsVertexITSTPC, bool, true, "Selects collisions with at least one ITS-TPC track"); O2_DEFINE_CONFIGURABLE(cfgMagField, float, 99999, "Configurable magnetic field; default CCDB will be queried"); - - Configurable cfgGFWBinning{"cfgGFWBinning", {40, 16, 72, 300, 0, 3000, 0.2, 10.0, 0.2, 3.0, {0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}, {0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}}, "Configuration for binning"}; + O2_DEFINE_CONFIGURABLE(cfgTofPtCut, float, 0.5, "pt cut on TOF for PID"); + O2_DEFINE_CONFIGURABLE(cfgUseDensityDependentCorrection, bool, false, "Use density dependent efficiency correction based on Run 2 measurements"); + Configurable> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector{0.7217476707, 0.7384792571, 0.7542625668, 0.7640680200, 0.7701951667, 0.7755299053, 0.7805901710, 0.7849446786, 0.7957356586, 0.8113039262, 0.8211968966, 0.8280558878, 0.8329342135}, "parameter 0 for track density efficiency correction"}; + Configurable> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector{-2.169488e-05, -2.191913e-05, -2.295484e-05, -2.556538e-05, -2.754463e-05, -2.816832e-05, -2.846502e-05, -2.843857e-05, -2.705974e-05, -2.477018e-05, -2.321730e-05, -2.203315e-05, -2.109474e-05}, "parameter 1 for track density efficiency correction"}; + Configurable> cfgMultGlobalCutPars{"cfgMultGlobalCutPars", std::vector{2272.16, -76.6932, 1.01204, -0.00631545, 1.59868e-05, 136.336, -4.97006, 0.121199, -0.0015921, 7.66197e-06}, "Global multiplicity cut parameter values"}; + Configurable> cfgMultPVCutPars{"cfgMultPVCutPars", std::vector{3074.43, -106.192, 1.46176, -0.00968364, 2.61923e-05, 182.128, -7.43492, 0.193901, -0.00256715, 1.22594e-05}, "PV multiplicity cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultCorrHighCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultCorrLowCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x - 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + + Configurable cfgGFWBinning{"cfgGFWBinning", {40, 16, 72, 300, 0, 3000, 0.2, 10.0, 0.2, 3.0, {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4, 4.5, 5, 5.5, 6, 7, 8, 9, 10}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90}}, "Configuration for binning"}; Configurable cfgRegions{"cfgRegions", {{"refN", "refP", "refFull"}, {-0.8, 0.4, -0.8}, {-0.4, 0.8, 0.8}, {0, 0, 0}, {1, 1, 1}}, "Configurations for GFW regions"}; Configurable cfgCorrConfig{"cfgCorrConfig", {{"refP {2} refN {-2}", "refP {3} refN {-3}", "refP {4} refN {-4}", "refFull {2 -2}", "refFull {2 2 -2 -2}"}, {"ChGap22", "ChGap32", "ChGap42", "ChFull22", "ChFull24"}, {0, 0, 0, 0, 0}, {15, 1, 1, 0, 0}}, "Configurations for each correlation to calculate"}; @@ -130,15 +144,63 @@ struct GenericFramework { OutputObj fFC{FlowContainer("FlowContainer")}; OutputObj fFCpt{FlowPtContainer("FlowPtContainer")}; OutputObj fFCgen{FlowContainer("FlowContainer_gen")}; - OutputObj fWeightList{"WeightList", OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry registry{"registry"}; - // define global variables + // QA outputs + std::map>> th1sList; + std::map>> th3sList; + enum OutputTH1Names { + hPhi = 0, + hEta, + hVtxZ, + hMult, + hCent, + hEventSel, + kCount_TH1Names + }; + // NUA outputs + enum OutputTH3Names { + hNUAref = 0, + hNUAch, + hNUApi, + hNUAka, + hNUApr, + kCount_TH3Names + }; + enum CentEstimators { + kCentFT0C = 0, + kCentFT0CVariant1, + kCentFT0M, + kCentFV0A, + kCentNTPV + }; + + // Define global variables + // Generic Framework GFW* fGFW = new GFW(); std::vector corrconfigs; + TRandom3* fRndm = new TRandom3(0); TAxis* fPtAxis; - int lastRun = 0; + int lastRun = -1; + std::vector runNumbers; + + // Density dependent eff correction + std::vector funcEff; + TH1D* hFindPtBin; + TF1* funcV2; + TF1* funcV3; + TF1* funcV4; + struct DensityCorr { + double psi2Est; + double psi3Est; + double psi4Est; + double v2; + double v3; + double v4; + int density; + DensityCorr() : psi2Est(0.), psi3Est(0.), psi4Est(0.), v2(0.), v3(0.), v4(0.), density(0) {} + }; // Event selection cuts - Alex TF1* fPhiCutLow = nullptr; @@ -152,51 +214,75 @@ struct GenericFramework { void init(InitContext const&) { LOGF(info, "flowGenericFramework::init()"); - regions.SetNames(cfgRegions->GetNames()); - regions.SetEtaMin(cfgRegions->GetEtaMin()); - regions.SetEtaMax(cfgRegions->GetEtaMax()); - regions.SetpTDifs(cfgRegions->GetpTDifs()); - regions.SetBitmasks(cfgRegions->GetBitmasks()); - configs.SetCorrs(cfgCorrConfig->GetCorrs()); - configs.SetHeads(cfgCorrConfig->GetHeads()); - configs.SetpTDifs(cfgCorrConfig->GetpTDifs()); - configs.SetpTCorrMasks(cfgCorrConfig->GetpTCorrMasks()); - regions.Print(); - configs.Print(); - ptbinning = cfgGFWBinning->GetPtBinning(); - ptpoilow = cfgGFWBinning->GetPtPOImin(); - ptpoiup = cfgGFWBinning->GetPtPOImax(); - ptreflow = cfgGFWBinning->GetPtRefMin(); - ptrefup = cfgGFWBinning->GetPtRefMax(); - ptlow = cfgPtmin; - ptup = cfgPtmax; - etabins = cfgGFWBinning->GetEtaBins(); - vtxZbins = cfgGFWBinning->GetVtxZbins(); - phibins = cfgGFWBinning->GetPhiBins(); - philow = 0.0f; - phiup = TwoPI; - nchbins = cfgGFWBinning->GetNchBins(); - nchlow = cfgGFWBinning->GetNchMin(); - nchup = cfgGFWBinning->GetNchMax(); - centbinning = cfgGFWBinning->GetCentBinning(); + o2::analysis::gfw::regions.SetNames(cfgRegions->GetNames()); + o2::analysis::gfw::regions.SetEtaMin(cfgRegions->GetEtaMin()); + o2::analysis::gfw::regions.SetEtaMax(cfgRegions->GetEtaMax()); + o2::analysis::gfw::regions.SetpTDifs(cfgRegions->GetpTDifs()); + o2::analysis::gfw::regions.SetBitmasks(cfgRegions->GetBitmasks()); + o2::analysis::gfw::configs.SetCorrs(cfgCorrConfig->GetCorrs()); + o2::analysis::gfw::configs.SetHeads(cfgCorrConfig->GetHeads()); + o2::analysis::gfw::configs.SetpTDifs(cfgCorrConfig->GetpTDifs()); + o2::analysis::gfw::configs.SetpTCorrMasks(cfgCorrConfig->GetpTCorrMasks()); + o2::analysis::gfw::regions.Print(); + o2::analysis::gfw::configs.Print(); + o2::analysis::gfw::ptbinning = cfgGFWBinning->GetPtBinning(); + o2::analysis::gfw::ptpoilow = cfgGFWBinning->GetPtPOImin(); + o2::analysis::gfw::ptpoiup = cfgGFWBinning->GetPtPOImax(); + o2::analysis::gfw::ptreflow = cfgGFWBinning->GetPtRefMin(); + o2::analysis::gfw::ptrefup = cfgGFWBinning->GetPtRefMax(); + o2::analysis::gfw::ptlow = cfgPtmin; + o2::analysis::gfw::ptup = cfgPtmax; + o2::analysis::gfw::etabins = cfgGFWBinning->GetEtaBins(); + o2::analysis::gfw::vtxZbins = cfgGFWBinning->GetVtxZbins(); + o2::analysis::gfw::phibins = cfgGFWBinning->GetPhiBins(); + o2::analysis::gfw::philow = 0.0f; + o2::analysis::gfw::phiup = o2::constants::math::TwoPI; + o2::analysis::gfw::nchbins = cfgGFWBinning->GetNchBins(); + o2::analysis::gfw::nchlow = cfgGFWBinning->GetNchMin(); + o2::analysis::gfw::nchup = cfgGFWBinning->GetNchMax(); + o2::analysis::gfw::centbinning = cfgGFWBinning->GetCentBinning(); cfgGFWBinning->Print(); - - AxisSpec phiAxis = {phibins, philow, phiup, "#phi"}; - AxisSpec phiModAxis = {100, 0, constants::math::PI / 9, "fmod(#varphi,#pi/9)"}; - AxisSpec etaAxis = {etabins, -cfgEta, cfgEta, "#eta"}; - AxisSpec vtxAxis = {vtxZbins, -cfgVtxZ, cfgVtxZ, "Vtx_{z} (cm)"}; - AxisSpec ptAxis = {ptbinning, "#it{p}_{T} GeV/#it{c}"}; - AxisSpec centAxis = {centbinning, "Centrality (%)"}; + o2::analysis::gfw::multGlobalCorrCutPars = cfgMultGlobalCutPars; + o2::analysis::gfw::multPVCorrCutPars = cfgMultPVCutPars; + + AxisSpec phiAxis = {o2::analysis::gfw::phibins, o2::analysis::gfw::philow, o2::analysis::gfw::phiup, "#phi"}; + AxisSpec etaAxis = {o2::analysis::gfw::etabins, -cfgEta, cfgEta, "#eta"}; + AxisSpec vtxAxis = {o2::analysis::gfw::vtxZbins, -cfgVtxZ, cfgVtxZ, "Vtx_{z} (cm)"}; + AxisSpec ptAxis = {o2::analysis::gfw::ptbinning, "#it{p}_{T} GeV/#it{c}"}; + std::string sCentralityEstimator; + switch (cfgCentEstimator) { + case kCentFT0C: + sCentralityEstimator = "FT0C"; + break; + case kCentFT0CVariant1: + sCentralityEstimator = "FT0C variant 1"; + break; + case kCentFT0M: + sCentralityEstimator = "FT0M"; + break; + case kCentFV0A: + sCentralityEstimator = "FV0A"; + break; + case kCentNTPV: + sCentralityEstimator = "NTPV"; + break; + default: + sCentralityEstimator = "FT0C"; + } + sCentralityEstimator += " centrality (%)"; + AxisSpec centAxis = {o2::analysis::gfw::centbinning, sCentralityEstimator.c_str()}; std::vector nchbinning; - int nchskip = (nchup - nchlow) / nchbins; - for (int i = 0; i <= nchbins; ++i) { - nchbinning.push_back(nchskip * i + nchlow + 0.5); + int nchskip = (o2::analysis::gfw::nchup - o2::analysis::gfw::nchlow) / o2::analysis::gfw::nchbins; + for (int i = 0; i <= o2::analysis::gfw::nchbins; ++i) { + nchbinning.push_back(nchskip * i + o2::analysis::gfw::nchlow + 0.5); } AxisSpec nchAxis = {nchbinning, "N_{ch}"}; + AxisSpec bAxis = {200, 0, 20, "#it{b}"}; AxisSpec t0cAxis = {70, 0, 70000, "N_{ch} (T0C)"}; AxisSpec t0aAxis = {200, 0, 200, "N_{ch}"}; AxisSpec multpvAxis = {4000, 0, 4000, "N_{ch} (PV)"}; - AxisSpec multAxis = (cfgUseNch) ? nchAxis : centAxis; + AxisSpec multAxis = (doprocessOnTheFly && !cfgUseNch) ? bAxis : (cfgUseNch) ? nchAxis + : centAxis; AxisSpec dcaZAXis = {200, -2, 2, "DCA_{z} (cm)"}; AxisSpec dcaXYAXis = {200, -1, 1, "DCA_{xy} (cm)"}; ccdb->setURL("http://alice-ccdb.cern.ch"); @@ -206,50 +292,31 @@ struct GenericFramework { int64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); ccdb->setCreatedNotAfter(now); - int ptbins = ptbinning.size() - 1; - fPtAxis = new TAxis(ptbins, &ptbinning[0]); - - TList* weightlist = new TList(); - weightlist->SetOwner(true); - fWeightList.setObject(weightlist); - - if (!cfgRunByRunWeights && cfgFillWeights) { - if (cfgUsePID) { - std::vector weights; - std::vector species = {"ref", "ch", "pi", "ka", "pr"}; - for (size_t i = 0; i < species.size(); ++i) { - weights.push_back(new GFWWeights(Form("w_%s", species[i].c_str()))); - if (i == 0) { - auto it = std::find(ptbinning.begin(), ptbinning.end(), ptrefup); - std::vector refpt(ptbinning.begin(), it + 1); - weights[i]->SetPtBins(refpt.size() - 1, &refpt[0]); - } else { - weights[i]->SetPtBins(fPtAxis->GetNbins(), &ptbinning[0]); - } - weights[i]->Init(true, false); - fWeightList->Add(weights[i]); - } - } else { - GFWWeights* weight = new GFWWeights("w_ch"); - weight->SetPtBins(fPtAxis->GetNbins(), &ptbinning[0]); - weight->Init(true, false); - fWeightList->Add(weight); - } - } + int ptbins = o2::analysis::gfw::ptbinning.size() - 1; + fPtAxis = new TAxis(ptbins, &o2::analysis::gfw::ptbinning[0]); - if (doprocessMCGen) { + if (doprocessMCGen || doprocessOnTheFly) { registry.add("MCGen/before/pt_gen", "", {HistType::kTH1D, {ptAxis}}); registry.add("MCGen/before/phi_eta_vtxZ_gen", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); registry.addClone("MCGen/before/", "MCGen/after/"); + if (doprocessOnTheFly) + registry.add("MCGen/impactParameter", "", {HistType::kTH2D, {{bAxis, nchAxis}}}); } if (doprocessMCReco || doprocessData || doprocessRun2) { registry.add("trackQA/before/phi_eta_vtxZ", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); registry.add("trackQA/before/pt_dcaXY_dcaZ", "", {HistType::kTH3D, {ptAxis, dcaXYAXis, dcaZAXis}}); - registry.add("trackQA/before/pt_phi", "", {HistType::kTH2D, {ptAxis, phiModAxis}}); + registry.add("trackQA/before/chi2prTPCcls", "#chi^{2}/cluster for the TPC track segment", {HistType::kTH1D, {{100, 0., 5.}}}); + registry.add("trackQA/before/chi2prITScls", "#chi^{2}/cluster for the ITS track", {HistType::kTH1D, {{100, 0., 50.}}}); + registry.add("trackQA/before/nTPCClusters", "Number of found TPC clusters", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("trackQA/before/nITSClusters", "Number of found ITS clusters", {HistType::kTH1D, {{100, 0, 20}}}); + registry.add("trackQA/before/nTPCCrossedRows", "Number of crossed TPC Rows", {HistType::kTH1D, {{100, 40, 180}}}); + registry.addClone("trackQA/before/", "trackQA/after/"); - registry.add("trackQA/after/pt_ref", "", {HistType::kTH1D, {{100, ptreflow, ptrefup}}}); - registry.add("trackQA/after/pt_poi", "", {HistType::kTH1D, {{100, ptpoilow, ptpoiup}}}); + registry.add("trackQA/after/pt_ref", "", {HistType::kTH1D, {{100, o2::analysis::gfw::ptreflow, o2::analysis::gfw::ptrefup}}}); + registry.add("trackQA/after/pt_poi", "", {HistType::kTH1D, {{100, o2::analysis::gfw::ptpoilow, o2::analysis::gfw::ptpoiup}}}); + registry.add("eventQA/before/centrality", "", {HistType::kTH1D, {centAxis}}); + registry.add("eventQA/before/multiplicity", "", {HistType::kTH1D, {nchAxis}}); registry.add("eventQA/before/globalTracks_centT0C", "", {HistType::kTH2D, {centAxis, nchAxis}}); registry.add("eventQA/before/PVTracks_centT0C", "", {HistType::kTH2D, {centAxis, multpvAxis}}); registry.add("eventQA/before/globalTracks_PVTracks", "", {HistType::kTH2D, {multpvAxis, nchAxis}}); @@ -258,7 +325,7 @@ struct GenericFramework { registry.add("eventQA/before/multV0A_multT0A", "", {HistType::kTH2D, {t0aAxis, t0aAxis}}); registry.add("eventQA/before/multT0C_centT0C", "", {HistType::kTH2D, {centAxis, t0cAxis}}); registry.addClone("eventQA/before/", "eventQA/after/"); - registry.add("eventQA/eventSel", "Number of Events;; Counts", {HistType::kTH1D, {{10, 0, 10}}}); + registry.add("eventQA/eventSel", "Number of Events;; Counts", {HistType::kTH1D, {{11, 0, 11}}}); registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(1, "Filtered event"); registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(2, "sel8"); registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(3, "occupancy"); @@ -267,17 +334,30 @@ struct GenericFramework { registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(6, "kIsGoodZvtxFT0vsPV"); registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(7, "kNoCollInTimeRangeStandard"); registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(8, "kIsVertexITSTPC"); - registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(9, "after Mult cuts"); - registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(10, "has track + within cent"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(9, "kIsGoodITSLayersAll"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(10, "after Mult cuts"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(11, "has track + within cent"); + + if (!cfgRunByRun) { + if (cfgUsePID) { + registry.add("phi_eta_vtxz_ref", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + registry.add("phi_eta_vtxz_ch", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + registry.add("phi_eta_vtxz_pi", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + registry.add("phi_eta_vtxz_ka", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + registry.add("phi_eta_vtxz_pr", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + } else { + registry.add("phi_eta_vtxz_ref", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + } + } } - if (regions.GetSize() < 0) + if (o2::analysis::gfw::regions.GetSize() < 0) LOGF(error, "Configuration contains vectors of different size - check the GFWRegions configurable"); - for (auto i(0); i < regions.GetSize(); ++i) { - fGFW->AddRegion(regions.GetNames()[i], regions.GetEtaMin()[i], regions.GetEtaMax()[i], (regions.GetpTDifs()[i]) ? ptbins + 1 : 1, regions.GetBitmasks()[i]); + for (auto i(0); i < o2::analysis::gfw::regions.GetSize(); ++i) { + fGFW->AddRegion(o2::analysis::gfw::regions.GetNames()[i], o2::analysis::gfw::regions.GetEtaMin()[i], o2::analysis::gfw::regions.GetEtaMax()[i], (o2::analysis::gfw::regions.GetpTDifs()[i]) ? ptbins + 1 : 1, o2::analysis::gfw::regions.GetBitmasks()[i]); } - for (auto i = 0; i < configs.GetSize(); ++i) { - corrconfigs.push_back(fGFW->GetCorrelatorConfig(configs.GetCorrs()[i], configs.GetHeads()[i], configs.GetpTDifs()[i])); + for (auto i = 0; i < o2::analysis::gfw::configs.GetSize(); ++i) { + corrconfigs.push_back(fGFW->GetCorrelatorConfig(o2::analysis::gfw::configs.GetCorrs()[i], o2::analysis::gfw::configs.GetHeads()[i], o2::analysis::gfw::configs.GetpTDifs()[i])); } if (corrconfigs.empty()) LOGF(error, "Configuration contains vectors of different size - check the GFWCorrConfig configurable"); @@ -289,7 +369,7 @@ struct GenericFramework { fFC->SetXAxis(fPtAxis); fFC->Initialize(oba, multAxis, cfgNbootstrap); } - if (doprocessMCGen) { + if (doprocessMCGen || doprocessOnTheFly) { fFCgen->SetName("FlowContainer_gen"); fFCgen->SetXAxis(fPtAxis); fFCgen->Initialize(oba, multAxis, cfgNbootstrap); @@ -297,37 +377,35 @@ struct GenericFramework { delete oba; fFCpt->setUseCentralMoments(cfgUseCentralMoments); fFCpt->setUseGapMethod(cfgUseGapMethod); - fFCpt->initialise(multAxis, cfgMpar, configs, cfgNbootstrap); + fFCpt->initialise(multAxis, cfgMpar, o2::analysis::gfw::configs, cfgNbootstrap); // Event selection - Alex if (cfgUseAdditionalEventCut) { - /* - //22s cuts - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); - - fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x)", 0, 100); - fMultCutLow->SetParameters(1893.94, -53.86, 0.502913, -0.0015122, 109.625, -1.19253); - fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x)", 0, 100); - fMultCutHigh->SetParameters(1893.94, -53.86, 0.502913, -0.0015122, 109.625, -1.19253); - fMultMultPVCut = new TF1("fMultMultPVCut", "[0]+[1]*x+[2]*x*x", 0, 5000); - fMultMultPVCut->SetParameters(-0.1, 0.785, -4.7e-05); - */ - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - - fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - } - - if (cfgUseAdditionalTrackCut) { - fPhiCutLow = new TF1("fPhiCutLow", "0.06/x+pi/18.0-0.06", 0, 100); - fPhiCutHigh = new TF1("fPhiCutHigh", "0.1/x+pi/18.0+0.06", 0, 100); + fMultPVCutLow = new TF1("fMultPVCutLow", cfgMultCorrLowCutFunction->c_str(), 0, 100); + fMultPVCutLow->SetParameters(&(o2::analysis::gfw::multPVCorrCutPars[0])); + fMultPVCutHigh = new TF1("fMultPVCutHigh", cfgMultCorrHighCutFunction->c_str(), 0, 100); + fMultPVCutHigh->SetParameters(&(o2::analysis::gfw::multPVCorrCutPars[0])); + fMultCutLow = new TF1("fMultCutLow", cfgMultCorrLowCutFunction->c_str(), 0, 100); + fMultCutLow->SetParameters(&(o2::analysis::gfw::multGlobalCorrCutPars[0])); + fMultCutHigh = new TF1("fMultCutHigh", cfgMultCorrHighCutFunction->c_str(), 0, 100); + fMultCutHigh->SetParameters(&(o2::analysis::gfw::multGlobalCorrCutPars[0])); + } + if (cfgUseDensityDependentCorrection) { + std::vector pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0}; + hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]); + funcEff.resize(pTEffBins.size() - 1); + // LHC24g3 Eff + std::vector f1p0 = cfgTrackDensityP0; + std::vector f1p1 = cfgTrackDensityP1; + for (uint ifunc = 0; ifunc < pTEffBins.size() - 1; ifunc++) { + funcEff[ifunc] = new TF1(Form("funcEff%i", ifunc), "[0]+[1]*x", 0, 3000); + funcEff[ifunc]->SetParameters(f1p0[ifunc], f1p1[ifunc]); + } + funcV2 = new TF1("funcV2", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV2->SetParameters(0.0186111, 0.00351907, -4.38264e-05, 1.35383e-07, -3.96266e-10); + funcV3 = new TF1("funcV3", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV3->SetParameters(0.0174056, 0.000703329, -1.45044e-05, 1.91991e-07, -1.62137e-09); + funcV4 = new TF1("funcV4", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV4->SetParameters(0.008845, 0.000259668, -3.24435e-06, 4.54837e-08, -6.01825e-10); } } @@ -373,52 +451,22 @@ struct GenericFramework { void loadCorrections(aod::BCsWithTimestamps::iterator const& bc) { uint64_t timestamp = bc.timestamp(); - int run = bc.runNumber(); - if (cfg.correctionsLoaded) { - if (!cfgRunByRunWeights) - return; - if (run == lastRun) - return; - } - if (cfgUsePID) { - if (cfgAcceptance.value.empty() == false) { - if (cfgRunByRunWeights) { // run-by-run NUA weights from ccdb, stored in TList to hold PID weights - TList* weightlist = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_ref", run)))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_ch", run)))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_pi", run)))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_ka", run)))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_pr", run)))); - } else { // run-averaged weights, stored in TList to hold PID weights - TList* weightlist = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - weightlist->ls(); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_ref"))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_ch"))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_pi"))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_ka"))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_pr"))); - } - if (!cfg.mAcceptance.empty()) - LOGF(info, "Loaded acceptance weights from %s", cfgAcceptance.value.c_str()); - else - LOGF(warning, "Could not load acceptance weights from %s", cfgAcceptance.value.c_str()); - } - } else { - if (cfgAcceptance.value.empty() == false) { - if (cfgRunByRunWeights) { // run-by-run NUA weights from ccdb, stored in TList - TList* weightlist = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_ch", run)))); - } else { // run-averaged weights, stored in TList - TList* weightlist = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("w_ch"))); - } - if (!cfg.mAcceptance.empty()) - LOGF(info, "Loaded acceptance weights from %s", cfgAcceptance.value.c_str()); - else - LOGF(warning, "Could not load acceptance weights from %s", cfgAcceptance.value.c_str()); + if (!cfgRunByRun && cfg.correctionsLoaded) + return; + if (!cfgAcceptance.value.empty()) { + std::string runstr = (cfgRunByRun) ? "RunByRun/" : ""; + cfg.mAcceptance.clear(); + if (cfgUsePID) { + cfg.mAcceptance.push_back(ccdb->getForTimeStamp(cfgAcceptance.value + runstr + "ref/", timestamp)); + cfg.mAcceptance.push_back(ccdb->getForTimeStamp(cfgAcceptance.value + runstr + "ch/", timestamp)); + cfg.mAcceptance.push_back(ccdb->getForTimeStamp(cfgAcceptance.value + runstr + "pi/", timestamp)); + cfg.mAcceptance.push_back(ccdb->getForTimeStamp(cfgAcceptance.value + runstr + "ka/", timestamp)); + cfg.mAcceptance.push_back(ccdb->getForTimeStamp(cfgAcceptance.value + runstr + "pr/", timestamp)); + } else { + cfg.mAcceptance.push_back(ccdb->getForTimeStamp(cfgAcceptance.value + runstr, timestamp)); } } - if (cfgEfficiency.value.empty() == false) { + if (!cfgEfficiency.value.empty()) { cfg.mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); if (cfg.mEfficiency == nullptr) { LOGF(fatal, "Could not load efficiency histogram from %s", cfgEfficiency.value.c_str()); @@ -430,16 +478,10 @@ struct GenericFramework { template double getAcceptance(TTrack track, const double& vtxz, int index) - { //-1 ref, 0 ch, 1 pi, 2 ka, 3 pr + { // 0 ref, 1 ch, 2 pi, 3 ka, 4 pr double wacc = 1; - index += 1; - if (!cfg.mAcceptance.empty()) { - if (cfgUsePID) { - wacc = cfg.mAcceptance[index]->GetNUA(track.phi(), track.eta(), vtxz); - } else { - wacc = cfg.mAcceptance[0]->GetNUA(track.phi(), track.eta(), vtxz); - } - } + if (!cfg.mAcceptance.empty()) + wacc = cfg.mAcceptance[index]->getNUA(track.phi(), track.eta(), vtxz); return wacc; } @@ -454,24 +496,6 @@ struct GenericFramework { else return 1. / eff; } - // Obsolete for now untill service wagons get added - /* template - int getBayesPIDIndex(TTrack track) { - float maxProb[3] = {0.95,0.85,0.85}; - int pidID = 0; - if(track.bayesID()==o2::track::PID::Pion || track.bayesID()==o2::track::PID::Kaon || track.bayesID()==o2::track::PID::Proton){ - pidID = track.bayesID()-1; //Realign - float nsigmaTPC[3] = {track.tpcNSigmaPi(),track.tpcNSigmaKa(),track.tpcNSigmaPr()}; - float nsigmaTOF[3] = {track.tofNSigmaPi(),track.tofNSigmaKa(),track.tofNSigmaPr()}; - if(track.bayesProb() > maxProb[pidID-1]) { - if(std::abs(nsigmaTPC[pidID-1]) > 3) return 0; - if(std::abs(nsigmaTOF[pidID-1]) > 3) return 0; - return pidID; - } - else return 0; - } - return 0; - } */ template int getNsigmaPID(TTrack track) @@ -483,10 +507,13 @@ struct GenericFramework { float nsigma = 3.0; // Choose which nSigma to use - std::array nSigmaToUse = (track.pt() > 0.4 && track.hasTOF()) ? nSigmaCombined : nSigmaTPC; + std::array nSigmaToUse = (track.pt() > cfgTofPtCut && track.hasTOF()) ? nSigmaCombined : nSigmaTPC; + if (track.pt() >= cfgTofPtCut && !track.hasTOF()) + return -1; // Select particle with the lowest nsigma - for (int i = 0; i < 3; ++i) { + const int nspecies = 3; + for (int i = 0; i < nspecies; ++i) { if (std::abs(nSigmaToUse[i]) < nsigma) { pid = i; nsigma = std::abs(nSigmaToUse[i]); @@ -496,7 +523,7 @@ struct GenericFramework { } template - bool eventSelected(TCollision collision, const int& multTrk, const float& centrality) + bool eventSelected(TCollision collision, const int& multTrk, const float& centrality, const int& run) { if (cfgTVXinTRD) { if (collision.alias_bit(kTVXinTRD)) { @@ -505,6 +532,8 @@ struct GenericFramework { return 0; } registry.fill(HIST("eventQA/eventSel"), 3.5); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(3.5); } if (cfgNoSameBunchPileupCut) { @@ -514,6 +543,8 @@ struct GenericFramework { return 0; } registry.fill(HIST("eventQA/eventSel"), 4.5); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(4.5); } if (cfgIsGoodZvtxFT0vsPV) { if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { @@ -522,6 +553,8 @@ struct GenericFramework { return 0; } registry.fill(HIST("eventQA/eventSel"), 5.5); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(5.5); } if (cfgNoCollInTimeRangeStandard) { if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { @@ -529,6 +562,8 @@ struct GenericFramework { return 0; } registry.fill(HIST("eventQA/eventSel"), 6.5); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(6.5); } if (cfgIsVertexITSTPC) { @@ -537,12 +572,25 @@ struct GenericFramework { return 0; } registry.fill(HIST("eventQA/eventSel"), 7.5); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(7.5); + } + + if (cfgIsGoodITSLayersAll) { + if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return 0; + } + registry.fill(HIST("eventQA/eventSel"), 8.5); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(8.5); } float vtxz = -999; if (collision.numContrib() > 1) { vtxz = collision.posZ(); float zRes = std::sqrt(collision.covZZ()); - if (zRes > 0.25 && collision.numContrib() < 20) + float minZRes = 0.25; + int minNContrib = 20; + if (zRes > minZRes && collision.numContrib() < minNContrib) vtxz = -999; } // auto multV0A = collision.multFV0A(); @@ -550,112 +598,116 @@ struct GenericFramework { // auto multT0C = collision.multFT0C(); auto multNTracksPV = collision.multNTracksPV(); - if (vtxz > vtxZup || vtxz < vtxZlow) - return 0; - if (multNTracksPV < fMultPVCutLow->Eval(centrality)) - return 0; - if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) - return 0; - if (multTrk < fMultCutLow->Eval(centrality)) - return 0; - if (multTrk > fMultCutHigh->Eval(centrality)) + if (vtxz > o2::analysis::gfw::vtxZup || vtxz < o2::analysis::gfw::vtxZlow) return 0; - registry.fill(HIST("eventQA/eventSel"), 8.5); - /* 22s - if (multNTracksPV < fMultPVCutLow->Eval(centrality)) - return 0; - if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) - return 0; - if (multTrk < fMultCutLow->Eval(centrality)) - return 0; - if (multTrk > fMultCutHigh->Eval(centrality)) - return 0; - if (multTrk > fMultMultPVCut->Eval(multNTracksPV)) - return 0; - */ + + if (cfgMultCut) { + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return 0; + if (multTrk < fMultCutLow->Eval(centrality)) + return 0; + if (multTrk > fMultCutHigh->Eval(centrality)) + return 0; + registry.fill(HIST("eventQA/eventSel"), 9.5); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(9.5); + } return 1; } template - bool trackSelected(TTrack track, const int& field) + bool trackSelected(TTrack track) { - double phimodn = track.phi(); - if (field < 0) // for negative polarity field - phimodn = TwoPI - phimodn; - if (track.sign() < 0) // for negative charge - phimodn = TwoPI - phimodn; - if (phimodn < 0) - LOGF(warning, "phi < 0: %g", phimodn); - - phimodn += PI / 18.0; // to center gap in the middle - phimodn = fmod(phimodn, PI / 9.0); - if (cfgFillQA) - registry.fill(HIST("trackQA/before/pt_phi"), track.pt(), phimodn); - if (phimodn < fPhiCutHigh->Eval(track.pt()) && phimodn > fPhiCutLow->Eval(track.pt())) - return false; // reject track - if (cfgFillQA) - registry.fill(HIST("trackQA/after/pt_phi"), track.pt(), phimodn); - return true; + if (cfgDCAxyNSigma && (std::fabs(track.dcaXY()) > cfgDCAxyNSigma / 7. * (0.0105f + 0.0035f / track.pt()))) + return false; + return ((track.tpcNClsCrossedRows() >= cfgNTPCXrows) && (track.tpcNClsFound() >= cfgNTPCCls) && (track.itsNCls() >= cfgMinNITSCls)); } - enum DataType { kReco, kGen }; template - void fillWeights(const TTrack track, const double vtxz, const double multcent, int pid_index) + void fillWeights(const TTrack track, const double vtxz, const int& pid_index, const int& run) { if (cfgUsePID) { - std::vector species = {"ref", "ch", "pi", "ka", "pr"}; - double ptpidmins[] = {ptpoilow, ptpoilow, 0.3, 0.5}; // min pt for ch, pi, ka, pr - double ptpidmaxs[] = {ptpoiup, ptpoiup, 6.0, 6.0}; // max pt for ch, pi, ka, pr - bool withinPtPOI = (ptpidmins[pid_index] < track.pt()) && (track.pt() < ptpidmaxs[pid_index]); // within POI pT range - bool withinPtRef = (ptreflow < track.pt()) && (track.pt() < ptrefup); // within RF pT range - if (cfgRunByRunWeights) { + double ptpidmins[] = {o2::analysis::gfw::ptpoilow, o2::analysis::gfw::ptpoilow, 0.3, 0.5}; // min pt for ch, pi, ka, pr + double ptpidmaxs[] = {o2::analysis::gfw::ptpoiup, o2::analysis::gfw::ptpoiup, 6.0, 6.0}; // max pt for ch, pi, ka, pr + bool withinPtPOI = (ptpidmins[pid_index] < track.pt()) && (track.pt() < ptpidmaxs[pid_index]); // within POI pT range + bool withinPtRef = (o2::analysis::gfw::ptreflow < track.pt()) && (track.pt() < o2::analysis::gfw::ptrefup); // within RF pT range + if (cfgRunByRun) { if (withinPtRef && !pid_index) - dynamic_cast(fWeightList->FindObject(Form("w%i_%s", lastRun, species[pid_index].c_str())))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + th3sList[run][hNUAref]->Fill(track.phi(), track.eta(), vtxz); // pt-subset of charged particles for ref flow if (withinPtPOI) - dynamic_cast(fWeightList->FindObject(Form("w%i_%s", lastRun, species[pid_index + 1].c_str())))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + th3sList[run][hNUAch + pid_index]->Fill(track.phi(), track.eta(), vtxz); // charged and id'ed particle weights } else { if (withinPtRef && !pid_index) - dynamic_cast(fWeightList->FindObject(Form("w_%s", species[pid_index].c_str())))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow - if (withinPtPOI) - dynamic_cast(fWeightList->FindObject(Form("w_%s", species[pid_index + 1].c_str())))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + registry.fill(HIST("phi_eta_vtxz_ref"), track.phi(), track.eta(), vtxz); // pt-subset of charged particles for ref flow + if (withinPtPOI) { + switch (pid_index) { + case 0: + registry.fill(HIST("phi_eta_vtxz_ch"), track.phi(), track.eta(), vtxz); // charged particle weights + break; + case 1: + registry.fill(HIST("phi_eta_vtxz_pi"), track.phi(), track.eta(), vtxz); // pion weights + break; + case 2: + registry.fill(HIST("phi_eta_vtxz_ka"), track.phi(), track.eta(), vtxz); // kaon weights + break; + case 3: + registry.fill(HIST("phi_eta_vtxz_pr"), track.phi(), track.eta(), vtxz); // proton weights + break; + } + } } } else { - if (cfgRunByRunWeights) - dynamic_cast(fWeightList->FindObject(Form("w%i_ch", lastRun)))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + if (cfgRunByRun) + th3sList[run][hNUAref]->Fill(track.phi(), track.eta(), vtxz); else - dynamic_cast(fWeightList->FindObject("w_ch"))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + registry.fill(HIST("phi_eta_vtxz_ref"), track.phi(), track.eta(), vtxz); } return; } - void createRunByRunWeights() + void createRunByRunHistograms(const int& run) { + AxisSpec phiAxis = {o2::analysis::gfw::phibins, o2::analysis::gfw::philow, o2::analysis::gfw::phiup, "#phi"}; + AxisSpec etaAxis = {o2::analysis::gfw::etabins, -cfgEta, cfgEta, "#eta"}; + AxisSpec vtxAxis = {o2::analysis::gfw::vtxZbins, -cfgVtxZ, cfgVtxZ, "Vtx_{z} (cm)"}; + AxisSpec nchAxis = {o2::analysis::gfw::nchbins, o2::analysis::gfw::nchlow, o2::analysis::gfw::nchup, "N_{ch}"}; + AxisSpec centAxis = {o2::analysis::gfw::centbinning, "Centrality (%)"}; + std::vector> histos(kCount_TH1Names); + histos[hPhi] = registry.add(Form("%d/phi", run), "", {HistType::kTH1D, {phiAxis}}); + histos[hEta] = registry.add(Form("%d/eta", run), "", {HistType::kTH1D, {etaAxis}}); + histos[hVtxZ] = registry.add(Form("%d/vtxz", run), "", {HistType::kTH1D, {vtxAxis}}); + histos[hMult] = registry.add(Form("%d/mult", run), "", {HistType::kTH1D, {nchAxis}}); + histos[hCent] = registry.add(Form("%d/cent", run), "", {HistType::kTH1D, {centAxis}}); + histos[hEventSel] = registry.add(Form("%d/eventSel", run), "Number of Events;; Counts", {HistType::kTH1D, {{11, 0, 11}}}); + histos[hEventSel]->GetXaxis()->SetBinLabel(1, "Filtered event"); + histos[hEventSel]->GetXaxis()->SetBinLabel(2, "sel8"); + histos[hEventSel]->GetXaxis()->SetBinLabel(3, "occupancy"); + histos[hEventSel]->GetXaxis()->SetBinLabel(4, "kTVXinTRD"); + histos[hEventSel]->GetXaxis()->SetBinLabel(5, "kNoSameBunchPileup"); + histos[hEventSel]->GetXaxis()->SetBinLabel(6, "kIsGoodZvtxFT0vsPV"); + histos[hEventSel]->GetXaxis()->SetBinLabel(7, "kNoCollInTimeRangeStandard"); + histos[hEventSel]->GetXaxis()->SetBinLabel(8, "kIsVertexITSTPC"); + histos[hEventSel]->GetXaxis()->SetBinLabel(9, "kIsGoodITSLayersAll"); + histos[hEventSel]->GetXaxis()->SetBinLabel(10, "after Mult cuts"); + histos[hEventSel]->GetXaxis()->SetBinLabel(11, "has track + within cent"); + th1sList.insert(std::make_pair(run, histos)); + std::vector> histos3d(kCount_TH3Names); if (cfgUsePID) { - std::vector weights; - std::vector species = {"ref", "ch", "pi", "ka", "pr"}; - for (size_t i = 0; i < species.size(); ++i) { - weights.push_back(new GFWWeights(Form("w%i_%s", lastRun, species[i].c_str()))); - if (i == 0) { - auto it = std::find(ptbinning.begin(), ptbinning.end(), ptrefup); - std::vector refpt(ptbinning.begin(), it + 1); - weights[i]->SetPtBins(refpt.size() - 1, &refpt[0]); - } else { - weights[i]->SetPtBins(fPtAxis->GetNbins(), &ptbinning[0]); - } - weights[i]->Init(true, false); - fWeightList->Add(weights[i]); - } + histos3d[hNUAref] = registry.add(Form("%d/phi_eta_vtxz_ref", run), "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + histos3d[hNUAch] = registry.add(Form("%d/phi_eta_vtxz_ch", run), "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + histos3d[hNUApi] = registry.add(Form("%d/phi_eta_vtxz_pi", run), "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + histos3d[hNUAka] = registry.add(Form("%d/phi_eta_vtxz_ka", run), "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + histos3d[hNUApr] = registry.add(Form("%d/phi_eta_vtxz_pr", run), "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); } else { - GFWWeights* weight = new GFWWeights(Form("w%i_ch", lastRun)); - weight->SetPtBins(fPtAxis->GetNbins(), &ptbinning[0]); - weight->Init(true, false); - fWeightList->Add(weight); + histos3d[hNUAref] = registry.add(Form("%d/phi_eta_vtxz_ref", run), "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); } - + th3sList.insert(std::make_pair(run, histos3d)); return; } @@ -676,7 +728,7 @@ struct GenericFramework { if (std::abs(val) < 1) { (dt == kGen) ? fFCgen->FillProfile(corrconfigs.at(l_ind).Head.c_str(), centmult, val, dnx, rndm) : fFC->FillProfile(corrconfigs.at(l_ind).Head.c_str(), centmult, val, dnx, rndm); if (cfgUseGapMethod) - fFCpt->fillVnPtProfiles(centmult, val, dnx, rndm, configs.GetpTCorrMasks()[l_ind]); + fFCpt->fillVnPtProfiles(centmult, val, dnx, rndm, o2::analysis::gfw::configs.GetpTCorrMasks()[l_ind]); } continue; } @@ -693,26 +745,71 @@ struct GenericFramework { } template - void processCollision(TCollision collision, TTracks tracks, const float& centrality, const int& field) + void processCollision(TCollision collision, TTracks tracks, const float& centrality, const int& run) { if (tracks.size() < 1) return; - if (centrality < centbinning.front() || centrality > centbinning.back()) + if (dt != kGen && (centrality < o2::analysis::gfw::centbinning.front() || centrality > o2::analysis::gfw::centbinning.back())) return; - registry.fill(HIST("eventQA/eventSel"), 9.5); + if (dt != kGen) { + registry.fill(HIST("eventQA/eventSel"), 10.5); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(10.5); + } float vtxz = collision.posZ(); + if (dt != kGen && cfgRunByRun) { + th1sList[run][hVtxZ]->Fill(vtxz); + th1sList[run][hMult]->Fill(tracks.size()); + th1sList[run][hCent]->Fill(centrality); + } fGFW->Clear(); fFCpt->clearVector(); float lRandom = fRndm->Rndm(); + + // be cautious, this only works for Pb-Pb + // esimate the Event plane and vn for this event + DensityCorr densitycorrections; + if (cfgUseDensityDependentCorrection) { + double psi2Est = 0, psi3Est = 0, psi4Est = 0; + double v2 = 0, v3 = 0, v4 = 0; + double q2x = 0, q2y = 0; + double q3x = 0, q3y = 0; + double q4x = 0, q4y = 0; + for (const auto& track : tracks) { + bool withinPtRef = (o2::analysis::gfw::ptreflow < track.pt()) && (track.pt() < o2::analysis::gfw::ptrefup); // within RF pT rang + if (withinPtRef) { + q2x += std::cos(2 * track.phi()); + q2y += std::sin(2 * track.phi()); + q3x += std::cos(3 * track.phi()); + q3y += std::sin(3 * track.phi()); + q4x += std::cos(4 * track.phi()); + q4y += std::sin(4 * track.phi()); + } + } + psi2Est = std::atan2(q2y, q2x) / 2.; + psi3Est = std::atan2(q3y, q3x) / 3.; + psi4Est = std::atan2(q4y, q4x) / 4.; + v2 = funcV2->Eval(centrality); + v3 = funcV3->Eval(centrality); + v4 = funcV4->Eval(centrality); + densitycorrections.psi2Est = psi2Est; + densitycorrections.psi3Est = psi3Est; + densitycorrections.psi4Est = psi4Est; + densitycorrections.v2 = v2; + densitycorrections.v3 = v3; + densitycorrections.v4 = v4; + densitycorrections.density = tracks.size(); + } + for (const auto& track : tracks) { - processTrack(track, centrality, vtxz, field); + processTrack(track, vtxz, run, densitycorrections); } if (!cfgFillWeights) fillOutputContainers
((cfgUseNch) ? tracks.size() : centrality, lRandom); } template - inline void processTrack(TTrack const& track, const float& centrality, const float& vtxz, const int& field) + inline void processTrack(TTrack const& track, const float& vtxz, const int& run, DensityCorr densitycorrections) { if constexpr (framework::has_type_v) { if (track.mcParticleId() < 0 || !(track.has_mcParticle())) @@ -724,31 +821,36 @@ struct GenericFramework { if (cfgFillQA) fillTrackQA(track, vtxz); - if (mcParticle.eta() < etalow || mcParticle.eta() > etaup || mcParticle.pt() < ptlow || mcParticle.pt() > ptup || track.tpcNClsFound() < cfgNcls) + if (mcParticle.eta() < o2::analysis::gfw::etalow || mcParticle.eta() > o2::analysis::gfw::etaup || mcParticle.pt() < o2::analysis::gfw::ptlow || mcParticle.pt() > o2::analysis::gfw::ptup) return; - if (cfgUseAdditionalTrackCut && !trackSelected(track, field)) + if (!trackSelected(track)) return; int pidIndex = 0; if (cfgUsePID) { - if (mcParticle.pdgCode() == 211) + if (std::abs(mcParticle.pdgCode()) == kPiPlus) pidIndex = 1; - if (mcParticle.pdgCode() == 321) + if (std::abs(mcParticle.pdgCode()) == kKPlus) pidIndex = 2; - if (mcParticle.pdgCode() == 2212) + if (std::abs(mcParticle.pdgCode()) == kProton) pidIndex = 3; } if (cfgFillWeights) { - fillWeights(mcParticle, vtxz, centrality, 0); + fillWeights(mcParticle, vtxz, 0, run); } else { fillPtSums(track, vtxz); - fillGFW(mcParticle, vtxz, pidIndex); + fillGFW(mcParticle, vtxz, pidIndex, densitycorrections); } - if (cfgFillQA) + if (cfgFillQA) { fillTrackQA(track, vtxz); + if (cfgRunByRun) { + th1sList[run][hPhi]->Fill(track.phi()); + th1sList[run][hEta]->Fill(track.eta()); + } + } } else if constexpr (framework::has_type_v) { if (!track.isPhysicalPrimary()) @@ -756,31 +858,29 @@ struct GenericFramework { if (cfgFillQA) fillTrackQA(track, vtxz); - if (track.eta() < etalow || track.eta() > etaup || track.pt() < ptlow || track.pt() > ptup) + if (track.eta() < o2::analysis::gfw::etalow || track.eta() > o2::analysis::gfw::etaup || track.pt() < o2::analysis::gfw::ptlow || track.pt() > o2::analysis::gfw::ptup) return; int pidIndex = 0; if (cfgUsePID) { - if (track.pdgCode() == 211) + if (std::abs(track.pdgCode()) == kPiPlus) pidIndex = 1; - if (track.pdgCode() == 321) + if (std::abs(track.pdgCode()) == kKPlus) pidIndex = 2; - if (track.pdgCode() == 2212) + if (std::abs(track.pdgCode()) == kProton) pidIndex = 3; } fillPtSums(track, vtxz); - fillGFW(track, vtxz, pidIndex); + fillGFW(track, vtxz, pidIndex, densitycorrections); if (cfgFillQA) fillTrackQA(track, vtxz); } else { if (cfgFillQA) fillTrackQA(track, vtxz); - if (track.tpcNClsFound() < cfgNcls) - return; - if (cfgUseAdditionalTrackCut && !trackSelected(track, field)) + if (!trackSelected(track)) return; int pidIndex = 0; @@ -789,20 +889,25 @@ struct GenericFramework { pidIndex = getNsigmaPID(track); } if (cfgFillWeights) { - fillWeights(track, vtxz, centrality, pidIndex); + fillWeights(track, vtxz, pidIndex, run); } else { fillPtSums(track, vtxz); - fillGFW(track, vtxz, pidIndex); + fillGFW(track, vtxz, pidIndex, densitycorrections); } - if (cfgFillQA) + if (cfgFillQA) { fillTrackQA(track, vtxz); + if (cfgRunByRun) { + th1sList[run][hPhi]->Fill(track.phi()); + th1sList[run][hEta]->Fill(track.eta()); + } + } } } template inline void fillPtSums(TTrack track, const double& vtxz) { - double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz, -1); + double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); double weff = (dt == kGen) ? 1. : getEfficiency(track); if (weff < 0) return; @@ -818,18 +923,18 @@ struct GenericFramework { } template - inline void fillGFW(TTrack track, const double& vtxz, int pid_index) + inline void fillGFW(TTrack track, const double& vtxz, int pid_index, DensityCorr densitycorrections) { if (cfgUsePID) { // Analysing POI flow with id'ed particles - double ptmins[] = {ptpoilow, ptpoilow, 0.3, 0.5}; - double ptmaxs[] = {ptpoiup, ptpoiup, 6.0, 6.0}; - bool withinPtRef = (track.pt() > ptreflow && track.pt() < ptrefup); + double ptmins[] = {o2::analysis::gfw::ptpoilow, o2::analysis::gfw::ptpoilow, 0.3, 0.5}; + double ptmaxs[] = {o2::analysis::gfw::ptpoiup, o2::analysis::gfw::ptpoiup, 6.0, 6.0}; + bool withinPtRef = (track.pt() > o2::analysis::gfw::ptreflow && track.pt() < o2::analysis::gfw::ptrefup); bool withinPtPOI = (track.pt() > ptmins[pid_index] && track.pt() < ptmaxs[pid_index]); bool withinPtNch = (track.pt() > ptmins[0] && track.pt() < ptmaxs[0]); if (!withinPtPOI && !withinPtRef) return; - double waccRef = (dt == kGen) ? 1. : getAcceptance(track, vtxz, -1); - double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index) + double waccRef = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); + double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index + 1) : getAcceptance(track, vtxz, 0); // if (withinPtRef && withinPtPOI && pid_index) waccRef = waccPOI; // if particle is both (then it's overlap), override ref with POI @@ -844,11 +949,32 @@ struct GenericFramework { if (withinPtNch && withinPtRef) fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), waccPOI, 32); } else { // Analysing only integrated flow + bool withinPtRef = (track.pt() > o2::analysis::gfw::ptreflow && track.pt() < o2::analysis::gfw::ptrefup); + bool withinPtPOI = (track.pt() > o2::analysis::gfw::ptpoilow && track.pt() < o2::analysis::gfw::ptpoiup); + if (!withinPtPOI && !withinPtRef) + return; double weff = (dt == kGen) ? 1. : getEfficiency(track); if (weff < 0) return; - double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz, -1); - fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), weff * wacc, 1); + if (cfgUseDensityDependentCorrection && withinPtRef && dt != kGen) { + double fphi = densitycorrections.v2 * std::cos(2 * (track.phi() - densitycorrections.psi2Est)) + densitycorrections.v3 * std::cos(3 * (track.phi() - densitycorrections.psi3Est)) + densitycorrections.v4 * std::cos(4 * (track.phi() - densitycorrections.psi4Est)); + fphi = (1 + 2 * fphi); + int pTBinForEff = hFindPtBin->FindBin(track.pt()); + if (pTBinForEff >= 1 && pTBinForEff <= hFindPtBin->GetNbinsX()) { + float wEPeff = funcEff[pTBinForEff - 1]->Eval(fphi * densitycorrections.density); + if (wEPeff > 0.) { + wEPeff = 1. / wEPeff; + weff *= wEPeff; + } + } + } + double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); + if (withinPtRef) + fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), weff * wacc, 1); + if (withinPtPOI) + fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), weff * wacc, 2); + if (withinPtRef && withinPtPOI) + fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), weff * wacc, 4); } return; } @@ -860,9 +986,16 @@ struct GenericFramework { registry.fill(HIST("MCGen/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ_gen"), track.phi(), track.eta(), vtxz); registry.fill(HIST("MCGen/") + HIST(FillTimeName[ft]) + HIST("pt_gen"), track.pt()); } else { - double wacc = getAcceptance(track, vtxz, -1); - registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, wacc); + double wacc = getAcceptance(track, vtxz, 0); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter) ? wacc : 1.0); registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_dcaXY_dcaZ"), track.pt(), track.dcaXY(), track.dcaZ()); + + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("chi2prTPCcls"), track.tpcChi2NCl()); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("chi2prITScls"), track.itsChi2NCl()); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("nTPCClusters"), track.tpcNClsFound()); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("nITSClusters"), track.itsNCls()); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("nTPCCrossedRows"), track.tpcNClsCrossedRows()); + if (ft == kAfter) { registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_ref"), track.pt()); registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_poi"), track.pt()); @@ -883,72 +1016,108 @@ struct GenericFramework { return; } - Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZ; - Filter trackFilter = nabs(aod::track::eta) < cfgEta && aod::track::pt > cfgPtmin&& aod::track::pt < cfgPtmax && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && nabs(aod::track::dcaXY) < cfgDCAxy&& nabs(aod::track::dcaZ) < cfgDCAz; + o2::framework::expressions::Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZ; + o2::framework::expressions::Filter trackFilter = nabs(aod::track::eta) < cfgEta && aod::track::pt > cfgPtmin&& aod::track::pt < cfgPtmax && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::itsChi2NCl < cfgChi2PrITSCls) && (aod::track::tpcChi2NCl < cfgChi2PrTPCCls) && nabs(aod::track::dcaZ) < cfgDCAz; + using GFWTracks = soa::Filtered>; - void processData(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) + void processData(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) { auto bc = collision.bc_as(); int run = bc.runNumber(); if (run != lastRun) { lastRun = run; - if (cfgFillWeights && cfgRunByRunWeights) - createRunByRunWeights(); + LOGF(info, "run = %d", run); + if (cfgRunByRun) { + if (std::find(runNumbers.begin(), runNumbers.end(), run) == runNumbers.end()) { + LOGF(info, "Creating histograms for run %d", run); + createRunByRunHistograms(run); + runNumbers.push_back(run); + } else { + LOGF(info, "run %d already in runNumbers", run); + } + if (!cfgFillWeights) + loadCorrections(bc); + } } + if (!cfgFillWeights && !cfgRunByRun) + loadCorrections(bc); registry.fill(HIST("eventQA/eventSel"), 0.5); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(0.5); if (!collision.sel8()) return; registry.fill(HIST("eventQA/eventSel"), 1.5); - - if (cfgOccupancySelection != -999) { + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(1.5); + if (cfgDoOccupancySel) { int occupancy = collision.trackOccupancyInTimeRange(); if (occupancy < 0 || occupancy > cfgOccupancySelection) return; } registry.fill(HIST("eventQA/eventSel"), 2.5); - const auto centrality = collision.centFT0C(); - + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(2.5); + float centrality; + switch (cfgCentEstimator) { + case kCentFT0C: + centrality = collision.centFT0C(); + break; + case kCentFT0CVariant1: + centrality = collision.centFT0CVariant1(); + break; + case kCentFT0M: + centrality = collision.centFT0M(); + break; + case kCentFV0A: + centrality = collision.centFV0A(); + break; + case kCentNTPV: + centrality = collision.centNTPV(); + break; + default: + centrality = collision.centFT0C(); + } if (cfgFillQA) fillEventQA(collision, tracks); - if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), centrality)) + registry.fill(HIST("eventQA/before/centrality"), centrality); + registry.fill(HIST("eventQA/before/multiplicity"), tracks.size()); + if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), centrality, run)) return; if (cfgFillQA) fillEventQA(collision, tracks); - if (!cfgFillWeights) - loadCorrections(bc); - auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; - processCollision(collision, tracks, centrality, field); + registry.fill(HIST("eventQA/after/centrality"), centrality); + registry.fill(HIST("eventQA/after/multiplicity"), tracks.size()); + processCollision(collision, tracks, centrality, run); } - PROCESS_SWITCH(GenericFramework, processData, "Process analysis for non-derived data", true); + PROCESS_SWITCH(FlowGenericFramework, processData, "Process analysis for non-derived data", true); - void processMCReco(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks, aod::McParticles const&) + void processMCReco(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks, aod::McParticles const&) { auto bc = collision.bc_as(); int run = bc.runNumber(); if (run != lastRun) { lastRun = run; - if (cfgFillWeights && cfgRunByRunWeights) - createRunByRunWeights(); + if (cfgRunByRun) + createRunByRunHistograms(run); } if (!collision.sel8()) return; const auto centrality = collision.centFT0C(); if (cfgFillQA) fillEventQA(collision, tracks); - if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), centrality)) + if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), centrality, run)) return; if (cfgFillQA) fillEventQA(collision, tracks); if (!cfgFillWeights) loadCorrections(bc); - auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; - processCollision(collision, tracks, centrality, field); + processCollision(collision, tracks, centrality, run); } - PROCESS_SWITCH(GenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); + PROCESS_SWITCH(FlowGenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); - Filter mcCollFilter = nabs(aod::mccollision::posZ) < cfgVtxZ; + o2::framework::expressions::Filter mcCollFilter = nabs(aod::mccollision::posZ) < cfgVtxZ; void processMCGen(soa::Filtered::iterator const& mcCollision, soa::SmallGroups> const& collisions, aod::McParticles const& particles) { if (collisions.size() != 1) @@ -957,26 +1126,41 @@ struct GenericFramework { for (const auto& collision : collisions) { centrality = collision.centFT0C(); } - processCollision(mcCollision, particles, centrality, -999); + int run = 0; + processCollision(mcCollision, particles, centrality, run); } - PROCESS_SWITCH(GenericFramework, processMCGen, "Process analysis for MC generated events", false); + PROCESS_SWITCH(FlowGenericFramework, processMCGen, "Process analysis for MC generated events", false); + + void processOnTheFly(soa::Filtered::iterator const& mcCollision, aod::McParticles const& mcParticles) + { + int run = 0; + registry.fill(HIST("MCGen/impactParameter"), mcCollision.impactParameter(), mcParticles.size()); + processCollision(mcCollision, mcParticles, mcCollision.impactParameter(), run); + } + PROCESS_SWITCH(FlowGenericFramework, processOnTheFly, "Process analysis for MC on-the-fly generated events", false); void processRun2(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) { + auto bc = collision.bc_as(); + int run = bc.runNumber(); + if (run != lastRun) { + lastRun = run; + if (cfgRunByRun) + createRunByRunHistograms(run); + } if (!collision.sel7()) return; const auto centrality = collision.centRun2V0M(); - auto bc = collision.bc_as(); - loadCorrections(bc); - auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; - processCollision(collision, tracks, centrality, field); + if (!cfgFillWeights) + loadCorrections(bc); + processCollision(collision, tracks, centrality, run); } - PROCESS_SWITCH(GenericFramework, processRun2, "Process analysis for Run 2 converted data", false); + PROCESS_SWITCH(FlowGenericFramework, processRun2, "Process analysis for Run 2 converted data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/PWGCF/GenericFramework/Tasks/flowGfwLightIons.cxx b/PWGCF/GenericFramework/Tasks/flowGfwLightIons.cxx new file mode 100644 index 00000000000..7a74223e5ac --- /dev/null +++ b/PWGCF/GenericFramework/Tasks/flowGfwLightIons.cxx @@ -0,0 +1,1295 @@ +// 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. + +/// \file flowGfwLightIons.cxx +/// \brief Dedicated GFW task to analyse angular correlations in light-ion collision systems +/// \author Emil Gorm Nielsen, NBI, emil.gorm.nielsen@cern.ch + +#include "FlowContainer.h" +#include "FlowPtContainer.h" +#include "GFW.h" +#include "GFWConfig.h" +#include "GFWCumulant.h" +#include "GFWPowerArray.h" +#include "GFWWeights.h" +#include "GFWWeightsList.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +namespace o2::analysis::gfw +{ +std::vector ptbinning = {0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}; +float ptpoilow = 0.2, ptpoiup = 10.0; +float ptreflow = 0.2, ptrefup = 3.0; +float ptlow = 0.2, ptup = 10.0; +int etabins = 16; +float etalow = -0.8, etaup = 0.8; +int vtxZbins = 40; +float vtxZlow = -10.0, vtxZup = 10.0; +int phibins = 72; +float philow = 0.0; +float phiup = o2::constants::math::TwoPI; +int nchbins = 300; +float nchlow = 0; +float nchup = 3000; +std::vector centbinning(90); +int nBootstrap = 10; +GFWRegions regions; +GFWCorrConfigs configs; +std::vector multGlobalCorrCutPars; +std::vector multPVCorrCutPars; +std::vector multGlobalPVCorrCutPars; +std::vector multGlobalV0ACutPars; +std::vector multGlobalT0ACutPars; +std::vector firstRunsOfFill; +} // namespace o2::analysis::gfw + +struct FlowGfwLightIons { + + O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgMpar, int, 4, "Highest order of pt-pt correlations") + O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FT0A") + O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Do correlations as function of Nch") + O2_DEFINE_CONFIGURABLE(cfgFillWeights, bool, false, "Fill NUA weights") + O2_DEFINE_CONFIGURABLE(cfgRunByRun, bool, false, "Fill histograms on a run-by-run basis") + O2_DEFINE_CONFIGURABLE(cfgFillFlowRunByRun, bool, false, "Fill flow profile run-by-run (only for v22)") + O2_DEFINE_CONFIGURABLE(cfgTimeDependent, bool, false, "Fill output as function of time (for contamination studies)") + O2_DEFINE_CONFIGURABLE(cfgFirstRunsOfFill, std::vector, {}, "First runs of a fill for time dependent analysis") + O2_DEFINE_CONFIGURABLE(cfgFillQA, bool, false, "Fill QA histograms") + O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") + O2_DEFINE_CONFIGURABLE(cfgUseCentralMoments, bool, true, "Use central moments in vn-pt calculations") + O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgDCAxyNSigma, float, 7, "Cut on number of sigma deviations from expected DCA in the transverse direction"); + O2_DEFINE_CONFIGURABLE(cfgDCAxy, std::string, "(0.0026+0.005/(x^1.01))", "Functional form of pt-dependent DCAxy cut"); + O2_DEFINE_CONFIGURABLE(cfgDCAz, float, 2, "Cut on DCA in the longitudinal direction (cm)"); + O2_DEFINE_CONFIGURABLE(cfgNTPCCls, float, 50, "Cut on number of TPC clusters found"); + O2_DEFINE_CONFIGURABLE(cfgNTPCXrows, float, 70, "Cut on number of TPC crossed rows"); + O2_DEFINE_CONFIGURABLE(cfgMinNITSCls, float, 5, "Cut on minimum number of ITS clusters found"); + O2_DEFINE_CONFIGURABLE(cfgChi2PrITSCls, float, 36, "Cut on chi^2 per ITS clusters found"); + O2_DEFINE_CONFIGURABLE(cfgChi2PrTPCCls, float, 2.5, "Cut on chi^2 per TPC clusters found"); + O2_DEFINE_CONFIGURABLE(cfgPtmin, float, 0.2, "minimum pt (GeV/c)"); + O2_DEFINE_CONFIGURABLE(cfgPtmax, float, 10, "maximum pt (GeV/c)"); + O2_DEFINE_CONFIGURABLE(cfgEta, float, 0.8, "eta cut"); + O2_DEFINE_CONFIGURABLE(cfgEtaPtPt, float, 0.4, "eta cut for pt-pt correlations"); + O2_DEFINE_CONFIGURABLE(cfgVtxZ, float, 10, "vertex cut (cm)"); + O2_DEFINE_CONFIGURABLE(cfgOccupancySelection, int, 2000, "Max occupancy selection, -999 to disable"); + O2_DEFINE_CONFIGURABLE(cfgNoSameBunchPileupCut, bool, true, "kNoSameBunchPileupCut"); + O2_DEFINE_CONFIGURABLE(cfgIsGoodZvtxFT0vsPV, bool, true, "kIsGoodZvtxFT0vsPV"); + O2_DEFINE_CONFIGURABLE(cfgIsGoodITSLayersAll, bool, true, "kIsGoodITSLayersAll"); + O2_DEFINE_CONFIGURABLE(cfgNoCollInTimeRangeStandard, bool, true, "kNoCollInTimeRangeStandard"); + O2_DEFINE_CONFIGURABLE(cfgDoOccupancySel, bool, true, "Bool for event selection on detector occupancy"); + O2_DEFINE_CONFIGURABLE(cfgMultCut, bool, true, "Use additional event cut on mult correlations"); + O2_DEFINE_CONFIGURABLE(cfgTVXinTRD, bool, true, "Use kTVXinTRD (reject TRD triggered events)"); + O2_DEFINE_CONFIGURABLE(cfgIsVertexITSTPC, bool, true, "Selects collisions with at least one ITS-TPC track"); + O2_DEFINE_CONFIGURABLE(cfgMagField, float, 99999, "Configurable magnetic field; default CCDB will be queried"); + O2_DEFINE_CONFIGURABLE(cfgFixedMultMin, int, 1, "Minimum for fixed nch range"); + O2_DEFINE_CONFIGURABLE(cfgFixedMultMax, int, 3000, "Maximum for fixed nch range"); + O2_DEFINE_CONFIGURABLE(cfgUseMultiplicityFlowWeights, bool, true, "Enable or disable the use of multiplicity-based event weighting"); + O2_DEFINE_CONFIGURABLE(cfgConsistentEventFlag, int, 0, "Flag to select consistent events - 0: off, 1: v2{2} gap calculable, 2: v2{4} full calculable, 4: v2{4} gap calculable, 8: v2{4} 3sub calculable"); + O2_DEFINE_CONFIGURABLE(cfgUseDensityDependentCorrection, bool, false, "Use density dependent efficiency correction based on Run 2 measurements"); + Configurable> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector{0.7217476707, 0.7384792571, 0.7542625668, 0.7640680200, 0.7701951667, 0.7755299053, 0.7805901710, 0.7849446786, 0.7957356586, 0.8113039262, 0.8211968966, 0.8280558878, 0.8329342135}, "parameter 0 for track density efficiency correction"}; + Configurable> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector{-2.169488e-05, -2.191913e-05, -2.295484e-05, -2.556538e-05, -2.754463e-05, -2.816832e-05, -2.846502e-05, -2.843857e-05, -2.705974e-05, -2.477018e-05, -2.321730e-05, -2.203315e-05, -2.109474e-05}, "parameter 1 for track density efficiency correction"}; + Configurable> cfgMultGlobalCutPars{"cfgMultGlobalCutPars", std::vector{2272.16, -76.6932, 1.01204, -0.00631545, 1.59868e-05, 136.336, -4.97006, 0.121199, -0.0015921, 7.66197e-06}, "Global vs FT0C multiplicity cut parameter values"}; + Configurable> cfgMultPVCutPars{"cfgMultPVCutPars", std::vector{3074.43, -106.192, 1.46176, -0.00968364, 2.61923e-05, 182.128, -7.43492, 0.193901, -0.00256715, 1.22594e-05}, "PV vs FT0C multiplicity cut parameter values"}; + Configurable> cfgMultGlobalPVCutPars{"cfgMultGlobalPVCutPars", std::vector{-0.223013, 0.715849, 0.664242, 0.0829653, -0.000503733, 1.21185e-06}, "Global vs PV multiplicity cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultCorrHighCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultCorrLowCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x - 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultGlobalPVCorrCutFunction, std::string, "[0] + [1]*x + 3*([2] + [3]*x + [4]*x*x + [5]*x*x*x)", "Functional for global vs pv multiplicity correlation cut"); + struct : ConfigurableGroup { + O2_DEFINE_CONFIGURABLE(cfgMultGlobalASideCorrCutFunction, std::string, "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + [10]*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", "Functional for global vs V0A multiplicity low correlation cut"); + Configurable> cfgMultGlobalV0ACutPars{"cfgMultGlobalV0ACutPars", std::vector{567.785, 172.715, 0.77888, -0.00693466, 1.40564e-05, 679.853, 66.8068, -0.444332, 0.00115002, -4.92064e-07}, "Global vs FV0A multiplicity cut parameter values"}; + Configurable> cfgMultGlobalT0ACutPars{"cfgMultGlobalT0ACutPars", std::vector{241.618, 61.8402, 0.348049, -0.00306078, 6.20357e-06, 315.235, 29.1491, -0.188639, 0.00044528, -9.08912e-08}, "Global vs FT0A multiplicity cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgGlobalV0ALowSigma, float, -3, "Number of sigma deviations below expected value in global vs V0A correlation"); + O2_DEFINE_CONFIGURABLE(cfgGlobalV0AHighSigma, float, 4, "Number of sigma deviations above expected value in global vs V0A correlation"); + O2_DEFINE_CONFIGURABLE(cfgGlobalT0ALowSigma, float, -3., "Number of sigma deviations below expected value in global vs T0A correlation"); + O2_DEFINE_CONFIGURABLE(cfgGlobalT0AHighSigma, float, 4, "Number of sigma deviations above expected value in global vs T0A correlation"); + } cfgGlobalAsideCorrCuts; + + Configurable cfgGFWBinning{"cfgGFWBinning", {40, 16, 72, 300, 0, 3000, 0.2, 10.0, 0.2, 3.0, {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4, 4.5, 5, 5.5, 6, 7, 8, 9, 10}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90}}, "Configuration for binning"}; + Configurable cfgRegions{"cfgRegions", {{"refN", "refP", "refFull"}, {-0.8, 0.4, -0.8}, {-0.4, 0.8, 0.8}, {0, 0, 0}, {1, 1, 1}}, "Configurations for GFW regions"}; + + Configurable cfgCorrConfig{"cfgCorrConfig", {{"refP {2} refN {-2}", "refP {3} refN {-3}", "refP {4} refN {-4}", "refFull {2 -2}", "refFull {2 2 -2 -2}"}, {"ChGap22", "ChGap32", "ChGap42", "ChFull22", "ChFull24"}, {0, 0, 0, 0, 0}, {15, 1, 1, 0, 0}}, "Configurations for each correlation to calculate"}; + + // Connect to ccdb + Service ccdb; + + struct Config { + TH1D* mEfficiency = nullptr; + GFWWeights* mAcceptance; + bool correctionsLoaded = false; + } cfg; + + // Define output + OutputObj fFC{FlowContainer("FlowContainer")}; + OutputObj fFCpt{FlowPtContainer("FlowPtContainer")}; + OutputObj fFCgen{FlowContainer("FlowContainer_gen")}; + OutputObj fFCptgen{FlowPtContainer("FlowPtContainer_gen")}; + HistogramRegistry registry{"registry"}; + + // QA outputs + std::map>> th1sList; + std::map>> tpfsList; + std::map>> th3sList; + enum OutputTH1Names { + hPhi = 0, + hEta, + hVtxZ, + hMult, + hCent, + hEventSel, + kCount_TH1Names + }; + enum OutputTProfileNames { + pfCorr22 = 0, + kCount_TProfileNames + }; + // NUA outputs + enum OutputTH3Names { + hNUAref = 0, + kCount_TH3Names + }; + enum CentEstimators { + kCentFT0C = 0, + kCentFT0CVariant1, + kCentFT0M, + kCentFV0A, + kCentNTPV, + kCentNGlobal, + kCentMFT + }; + enum EventSelFlags { + kFilteredEvent = 1, + kSel8, + kOccupancy, + kTVXTRD, + kNoSamebunchPU, + kZVtxFT0PV, + kNoCollTRStd, + kVtxITSTPC, + kGoodITSLayers, + kMultCuts, + kTrackCent + }; + + // Define global variables + // Generic Framework + GFW* fGFW = new GFW(); + std::vector corrconfigs; + + TRandom3* fRndm = new TRandom3(0); + TAxis* fSecondAxis; + int lastRun = -1; + std::vector::iterator firstRunOfCurrentFill; + std::vector runNumbers; + + // Density dependent eff correction + std::vector funcEff; + TH1D* hFindPtBin; + TF1* funcV2; + TF1* funcV3; + TF1* funcV4; + struct DensityCorr { + double psi2Est; + double psi3Est; + double psi4Est; + double v2; + double v3; + double v4; + int density; + DensityCorr() : psi2Est(0.), psi3Est(0.), psi4Est(0.), v2(0.), v3(0.), v4(0.), density(0) {} + }; + + // region indices for consistency flag + int posRegionIndex = -1; + int negRegionIndex = -1; + int fullRegionIndex = -1; + int midRegionIndex = -1; + + // Event selection cuts - Alex + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fMultPVGlobalCutHigh = nullptr; + TF1* fMultGlobalV0ACutLow = nullptr; + TF1* fMultGlobalV0ACutHigh = nullptr; + TF1* fMultGlobalT0ACutLow = nullptr; + TF1* fMultGlobalT0ACutHigh = nullptr; + + TF1* fPtDepDCAxy = nullptr; + + o2::framework::expressions::Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZ; + o2::framework::expressions::Filter trackFilter = nabs(aod::track::eta) < cfgEta && aod::track::pt > cfgPtmin&& aod::track::pt < cfgPtmax && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::itsChi2NCl < cfgChi2PrITSCls) && (aod::track::tpcChi2NCl < cfgChi2PrTPCCls) && nabs(aod::track::dcaZ) < cfgDCAz; + + Preslice perCollision = aod::track::collisionId; + o2::framework::expressions::Filter mcCollFilter = nabs(aod::mccollision::posZ) < cfgVtxZ; + o2::framework::expressions::Filter mcParticlesFilter = (aod::mcparticle::eta > o2::analysis::gfw::etalow && aod::mcparticle::eta < o2::analysis::gfw::etaup && aod::mcparticle::pt > o2::analysis::gfw::ptlow && aod::mcparticle::pt < o2::analysis::gfw::ptup); + + using GFWTracks = soa::Filtered>; + + void init(InitContext const&) + { + LOGF(info, "flowGfwLightIons::init()"); + o2::analysis::gfw::regions.SetNames(cfgRegions->GetNames()); + o2::analysis::gfw::regions.SetEtaMin(cfgRegions->GetEtaMin()); + o2::analysis::gfw::regions.SetEtaMax(cfgRegions->GetEtaMax()); + o2::analysis::gfw::regions.SetpTDifs(cfgRegions->GetpTDifs()); + o2::analysis::gfw::regions.SetBitmasks(cfgRegions->GetBitmasks()); + o2::analysis::gfw::configs.SetCorrs(cfgCorrConfig->GetCorrs()); + o2::analysis::gfw::configs.SetHeads(cfgCorrConfig->GetHeads()); + o2::analysis::gfw::configs.SetpTDifs(cfgCorrConfig->GetpTDifs()); + o2::analysis::gfw::configs.SetpTCorrMasks(cfgCorrConfig->GetpTCorrMasks()); + o2::analysis::gfw::regions.Print(); + o2::analysis::gfw::configs.Print(); + o2::analysis::gfw::ptbinning = cfgGFWBinning->GetPtBinning(); + o2::analysis::gfw::ptpoilow = cfgGFWBinning->GetPtPOImin(); + o2::analysis::gfw::ptpoiup = cfgGFWBinning->GetPtPOImax(); + o2::analysis::gfw::ptreflow = cfgGFWBinning->GetPtRefMin(); + o2::analysis::gfw::ptrefup = cfgGFWBinning->GetPtRefMax(); + o2::analysis::gfw::ptlow = cfgPtmin; + o2::analysis::gfw::ptup = cfgPtmax; + o2::analysis::gfw::etabins = cfgGFWBinning->GetEtaBins(); + o2::analysis::gfw::vtxZbins = cfgGFWBinning->GetVtxZbins(); + o2::analysis::gfw::phibins = cfgGFWBinning->GetPhiBins(); + o2::analysis::gfw::philow = 0.0f; + o2::analysis::gfw::phiup = o2::constants::math::TwoPI; + o2::analysis::gfw::nchbins = cfgGFWBinning->GetNchBins(); + o2::analysis::gfw::nchlow = cfgGFWBinning->GetNchMin(); + o2::analysis::gfw::nchup = cfgGFWBinning->GetNchMax(); + o2::analysis::gfw::centbinning = cfgGFWBinning->GetCentBinning(); + cfgGFWBinning->Print(); + o2::analysis::gfw::multGlobalCorrCutPars = cfgMultGlobalCutPars; + o2::analysis::gfw::multPVCorrCutPars = cfgMultPVCutPars; + o2::analysis::gfw::multGlobalPVCorrCutPars = cfgMultGlobalPVCutPars; + o2::analysis::gfw::multGlobalV0ACutPars = cfgGlobalAsideCorrCuts.cfgMultGlobalV0ACutPars; + o2::analysis::gfw::multGlobalT0ACutPars = cfgGlobalAsideCorrCuts.cfgMultGlobalT0ACutPars; + o2::analysis::gfw::firstRunsOfFill = cfgFirstRunsOfFill; + if (cfgTimeDependent && !std::is_sorted(o2::analysis::gfw::firstRunsOfFill.begin(), o2::analysis::gfw::firstRunsOfFill.end())) { + std::sort(o2::analysis::gfw::firstRunsOfFill.begin(), o2::analysis::gfw::firstRunsOfFill.end()); + } + firstRunOfCurrentFill = o2::analysis::gfw::firstRunsOfFill.begin(); + + AxisSpec phiAxis = {o2::analysis::gfw::phibins, o2::analysis::gfw::philow, o2::analysis::gfw::phiup, "#phi"}; + AxisSpec etaAxis = {o2::analysis::gfw::etabins, -cfgEta, cfgEta, "#eta"}; + AxisSpec vtxAxis = {o2::analysis::gfw::vtxZbins, -cfgVtxZ, cfgVtxZ, "Vtx_{z} (cm)"}; + AxisSpec ptAxis = {o2::analysis::gfw::ptbinning, "#it{p}_{T} GeV/#it{c}"}; + std::string sCentralityEstimator; + switch (cfgCentEstimator) { + case kCentFT0C: + sCentralityEstimator = "FT0C"; + break; + case kCentFT0CVariant1: + sCentralityEstimator = "FT0C variant 1"; + break; + case kCentFT0M: + sCentralityEstimator = "FT0M"; + break; + case kCentFV0A: + sCentralityEstimator = "FV0A"; + break; + case kCentNTPV: + sCentralityEstimator = "NTPV"; + break; + case kCentNGlobal: + sCentralityEstimator = "NGlobals"; + break; + case kCentMFT: + sCentralityEstimator = "MFT"; + break; + default: + sCentralityEstimator = "FT0C"; + break; + } + sCentralityEstimator += " centrality (%)"; + AxisSpec centAxis = {o2::analysis::gfw::centbinning, sCentralityEstimator.c_str()}; + std::vector nchbinning; + int nchskip = (o2::analysis::gfw::nchup - o2::analysis::gfw::nchlow) / o2::analysis::gfw::nchbins; + for (int i = 0; i <= o2::analysis::gfw::nchbins; ++i) { + nchbinning.push_back(nchskip * i + o2::analysis::gfw::nchlow + 0.5); + } + AxisSpec nchAxis = {nchbinning, "N_{ch}"}; + std::vector bbinning(201); + std::generate(bbinning.begin(), bbinning.end(), [n = -0.1, step = 0.1]() mutable { + n += step; + return n; + }); + AxisSpec bAxis = {bbinning, "#it{b}"}; + AxisSpec t0cAxis = {1000, 0, 10000, "N_{ch} (T0C)"}; + AxisSpec t0aAxis = {300, 0, 30000, "N_{ch} (T0A)"}; + AxisSpec v0aAxis = {800, 0, 80000, "N_{ch} (V0A)"}; + AxisSpec multpvAxis = {600, 0, 600, "N_{ch} (PV)"}; + AxisSpec dcaZAXis = {200, -2, 2, "DCA_{z} (cm)"}; + AxisSpec dcaXYAXis = {200, -0.5, 0.5, "DCA_{xy} (cm)"}; + std::vector timebinning(289); + std::generate(timebinning.begin(), timebinning.end(), [n = -24 / 288., step = 24 / 288.]() mutable { + n += step; + return n; + }); + AxisSpec timeAxis = {timebinning, "time (hrs)"}; + + AxisSpec multAxis = (cfgTimeDependent) ? timeAxis : (doprocessOnTheFly && !cfgUseNch) ? bAxis + : (cfgUseNch) ? nchAxis + : centAxis; + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + int64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); + + int ptbins = o2::analysis::gfw::ptbinning.size() - 1; + fSecondAxis = (cfgTimeDependent) ? new TAxis(timeAxis.binEdges.size() - 1, &(timeAxis.binEdges[0])) : new TAxis(ptbins, &o2::analysis::gfw::ptbinning[0]); + + if (doprocessMCGen || doprocessOnTheFly) { + registry.add("MCGen/trackQA/nch_pt", "#it{p}_{T} vs multiplicity; N_{ch}; #it{p}_{T}", {HistType::kTH2D, {nchAxis, ptAxis}}); + registry.add("MCGen/trackQA/phi_eta_vtxZ", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + registry.add("MCGen/trackQA/pt_ref", "Reference #it{p}_{T}; #it{p}_{T}; Counts", {HistType::kTH1D, {{100, o2::analysis::gfw::ptreflow, o2::analysis::gfw::ptrefup}}}); + registry.add("MCGen/trackQA/pt_poi", "POI #it{p}_{T}; #it{p}_{T}; Counts", {HistType::kTH1D, {{100, o2::analysis::gfw::ptpoilow, o2::analysis::gfw::ptpoiup}}}); + if (doprocessOnTheFly) + registry.add("MCGen/impactParameter", "", {HistType::kTH2D, {{bAxis, nchAxis}}}); + + registry.add("MCGen/eventQA/multiplicity", "", {HistType::kTH1D, {nchAxis}}); + if (doprocessMCGen) + registry.add("MCGen/eventQA/centrality", "", {HistType::kTH1D, {centAxis}}); + } + if (doprocessMCReco || doprocessData) { + registry.add("trackQA/before/phi_eta_vtxZ", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + registry.add("trackQA/before/pt_dcaXY_dcaZ", "", {HistType::kTH3D, {ptAxis, dcaXYAXis, dcaZAXis}}); + registry.add("trackQA/before/nch_pt", "#it{p}_{T} vs multiplicity; N_{ch}; #it{p}_{T}", {HistType::kTH2D, {nchAxis, ptAxis}}); + registry.add("trackQA/before/chi2prTPCcls", "#chi^{2}/cluster for the TPC track segment; #chi^{2}/TPC cluster", {HistType::kTH1D, {{100, 0., 5.}}}); + registry.add("trackQA/before/chi2prITScls", "#chi^{2}/cluster for the ITS track; #chi^{2}/ITS cluster", {HistType::kTH1D, {{100, 0., 50.}}}); + registry.add("trackQA/before/nTPCClusters", "Number of found TPC clusters; TPC N_{cls}; Counts", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("trackQA/before/nITSClusters", "Number of found ITS clusters; ITS N_{cls}; Counts", {HistType::kTH1D, {{100, 0, 20}}}); + registry.add("trackQA/before/nTPCCrossedRows", "Number of crossed TPC Rows; TPC X-rows; Counts", {HistType::kTH1D, {{100, 40, 180}}}); + + registry.addClone("trackQA/before/", "trackQA/after/"); + registry.add("trackQA/after/pt_ref", "", {HistType::kTH1D, {{100, o2::analysis::gfw::ptreflow, o2::analysis::gfw::ptrefup}}}); + registry.add("trackQA/after/pt_poi", "", {HistType::kTH1D, {{100, o2::analysis::gfw::ptpoilow, o2::analysis::gfw::ptpoiup}}}); + + registry.add("eventQA/before/multiplicity", "", {HistType::kTH1D, {nchAxis}}); + if (cfgTimeDependent) { + registry.add("eventQA/before/multiplicity_time", "Multiplicity vs time; time (hrs); N_{ch}", {HistType::kTH2D, {timeAxis, nchAxis}}); + registry.add("eventQA/before/multT0C_time", "T0C Multiplicity vs time; time (hrs); N_{ch} (T0C)", {HistType::kTH2D, {timeAxis, t0cAxis}}); + registry.add("eventQA/before/multT0A_time", "T0A Multiplicity vs time; time (hrs); N_{ch} (T0A)", {HistType::kTH2D, {timeAxis, t0aAxis}}); + registry.add("eventQA/before/multV0A_time", "V0A Multiplicity vs time; time (hrs); N_{ch} (V0A)", {HistType::kTH2D, {timeAxis, v0aAxis}}); + registry.add("eventQA/before/multPV_time", "PV Multiplicity vs time; time (hrs); N_{ch} (PV)", {HistType::kTH2D, {timeAxis, multpvAxis}}); + } + registry.add("eventQA/before/globalTracks_PVTracks", "", {HistType::kTH2D, {multpvAxis, nchAxis}}); + registry.add("eventQA/before/globalTracks_multT0A", "", {HistType::kTH2D, {t0aAxis, nchAxis}}); + registry.add("eventQA/before/globalTracks_multV0A", "", {HistType::kTH2D, {v0aAxis, nchAxis}}); + registry.add("eventQA/before/multV0A_multT0A", "", {HistType::kTH2D, {t0aAxis, v0aAxis}}); + + if (doprocessData || doprocessMCReco) { + registry.add("eventQA/before/centrality", "", {HistType::kTH1D, {centAxis}}); + registry.add("eventQA/before/globalTracks_centT0C", "", {HistType::kTH2D, {centAxis, nchAxis}}); + registry.add("eventQA/before/PVTracks_centT0C", "", {HistType::kTH2D, {centAxis, multpvAxis}}); + registry.add("eventQA/before/multT0C_centT0C", "", {HistType::kTH2D, {centAxis, t0cAxis}}); + + registry.add("eventQA/before/centT0M_centT0C", "", {HistType::kTH2D, {centAxis, centAxis}}); + registry.add("eventQA/before/centV0A_centT0C", "", {HistType::kTH2D, {centAxis, centAxis}}); + registry.add("eventQA/before/centGlobal_centT0C", "", {HistType::kTH2D, {centAxis, centAxis}}); + registry.add("eventQA/before/centNTPV_centT0C", "", {HistType::kTH2D, {centAxis, centAxis}}); + registry.add("eventQA/before/centMFT_centT0C", "", {HistType::kTH2D, {centAxis, centAxis}}); + } + + registry.addClone("eventQA/before/", "eventQA/after/"); + registry.add("eventQA/eventSel", "Number of Events;; Counts", {HistType::kTH1D, {{11, 0.5, 11.5}}}); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kFilteredEvent, "Filtered event"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kSel8, "sel8"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kOccupancy, "occupancy"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kTVXTRD, "kTVXinTRD"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kNoSamebunchPU, "kNoSameBunchPileup"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kZVtxFT0PV, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kNoCollTRStd, "kNoCollInTimeRangeStandard"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kVtxITSTPC, "kIsVertexITSTPC"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kGoodITSLayers, "kIsGoodITSLayersAll"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kMultCuts, "after Mult cuts"); + registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(kTrackCent, "has track + within cent"); + if (!cfgRunByRun && cfgFillWeights) { + registry.add("phi_eta_vtxz_ref", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + } + } + + if (o2::analysis::gfw::regions.GetSize() < 0) + LOGF(error, "Configuration contains vectors of different size - check the GFWRegions configurable"); + for (auto i(0); i < o2::analysis::gfw::regions.GetSize(); ++i) { + fGFW->AddRegion(o2::analysis::gfw::regions.GetNames()[i], o2::analysis::gfw::regions.GetEtaMin()[i], o2::analysis::gfw::regions.GetEtaMax()[i], (o2::analysis::gfw::regions.GetpTDifs()[i]) ? ptbins + 1 : 1, o2::analysis::gfw::regions.GetBitmasks()[i]); + } + for (auto i = 0; i < o2::analysis::gfw::configs.GetSize(); ++i) { + corrconfigs.push_back(fGFW->GetCorrelatorConfig(o2::analysis::gfw::configs.GetCorrs()[i], o2::analysis::gfw::configs.GetHeads()[i], o2::analysis::gfw::configs.GetpTDifs()[i])); + } + if (corrconfigs.empty()) + LOGF(error, "Configuration contains vectors of different size - check the GFWCorrConfig configurable"); + fGFW->CreateRegions(); + TObjArray* oba = new TObjArray(); + addConfigObjectsToObjArray(oba, corrconfigs); + if (doprocessData || doprocessMCReco) { + fFC->SetName("FlowContainer"); + fFC->SetXAxis(fSecondAxis); + fFC->Initialize(oba, multAxis, cfgNbootstrap); + } + if (doprocessMCGen || doprocessOnTheFly) { + fFCgen->SetName("FlowContainer_gen"); + fFCgen->SetXAxis(fSecondAxis); + fFCgen->Initialize(oba, multAxis, cfgNbootstrap); + } + delete oba; + fFCpt->setUseCentralMoments(cfgUseCentralMoments); + fFCpt->setUseGapMethod(true); + fFCpt->initialise(multAxis, cfgMpar, o2::analysis::gfw::configs, cfgNbootstrap); + fFCptgen->setUseCentralMoments(cfgUseCentralMoments); + fFCptgen->setUseGapMethod(true); + fFCptgen->initialise(multAxis, cfgMpar, o2::analysis::gfw::configs, cfgNbootstrap); + + fPtDepDCAxy = new TF1("ptDepDCAxy", Form("[0]*%s", cfgDCAxy->c_str()), 0.001, 100); + fPtDepDCAxy->SetParameter(0, cfgDCAxyNSigma); + LOGF(info, "DCAxy pt-dependence function: %s", Form("[0]*%s", cfgDCAxy->c_str())); + if (cfgUseAdditionalEventCut) { + fMultPVCutLow = new TF1("fMultPVCutLow", cfgMultCorrLowCutFunction->c_str(), 0, 100); + fMultPVCutLow->SetParameters(&(o2::analysis::gfw::multPVCorrCutPars[0])); + fMultPVCutHigh = new TF1("fMultPVCutHigh", cfgMultCorrHighCutFunction->c_str(), 0, 100); + fMultPVCutHigh->SetParameters(&(o2::analysis::gfw::multPVCorrCutPars[0])); + fMultCutLow = new TF1("fMultCutLow", cfgMultCorrLowCutFunction->c_str(), 0, 100); + fMultCutLow->SetParameters(&(o2::analysis::gfw::multGlobalCorrCutPars[0])); + fMultCutHigh = new TF1("fMultCutHigh", cfgMultCorrHighCutFunction->c_str(), 0, 100); + fMultCutHigh->SetParameters(&(o2::analysis::gfw::multGlobalCorrCutPars[0])); + fMultPVGlobalCutHigh = new TF1("fMultPVGlobalCutHigh", cfgMultGlobalPVCorrCutFunction->c_str(), 0, nchbinning.back()); + fMultPVGlobalCutHigh->SetParameters(&(o2::analysis::gfw::multGlobalPVCorrCutPars[0])); + + LOGF(info, "Global V0A function: %s in range 0-%g", cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->c_str(), v0aAxis.binEdges.back()); + fMultGlobalV0ACutLow = new TF1("fMultGlobalV0ACutLow", cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->c_str(), 0, v0aAxis.binEdges.back()); + for (std::size_t i = 0; i < o2::analysis::gfw::multGlobalV0ACutPars.size(); ++i) + fMultGlobalV0ACutLow->SetParameter(i, o2::analysis::gfw::multGlobalV0ACutPars[i]); + fMultGlobalV0ACutLow->SetParameter(o2::analysis::gfw::multGlobalV0ACutPars.size(), cfgGlobalAsideCorrCuts.cfgGlobalV0ALowSigma); + for (int i = 0; i < fMultGlobalV0ACutLow->GetNpar(); ++i) + LOGF(info, "fMultGlobalV0ACutLow par %d = %g", i, fMultGlobalV0ACutLow->GetParameter(i)); + + fMultGlobalV0ACutHigh = new TF1("fMultGlobalV0ACutHigh", cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->c_str(), 0, v0aAxis.binEdges.back()); + for (std::size_t i = 0; i < o2::analysis::gfw::multGlobalV0ACutPars.size(); ++i) + fMultGlobalV0ACutHigh->SetParameter(i, o2::analysis::gfw::multGlobalV0ACutPars[i]); + fMultGlobalV0ACutHigh->SetParameter(o2::analysis::gfw::multGlobalV0ACutPars.size(), cfgGlobalAsideCorrCuts.cfgGlobalV0AHighSigma); + for (int i = 0; i < fMultGlobalV0ACutHigh->GetNpar(); ++i) + LOGF(info, "fMultGlobalV0ACutHigh par %d = %g", i, fMultGlobalV0ACutHigh->GetParameter(i)); + + LOGF(info, "Global T0A function: %s", cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->c_str()); + fMultGlobalT0ACutLow = new TF1("fMultGlobalT0ACutLow", cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->c_str(), 0, t0aAxis.binEdges.back()); + for (std::size_t i = 0; i < o2::analysis::gfw::multGlobalT0ACutPars.size(); ++i) + fMultGlobalT0ACutLow->SetParameter(i, o2::analysis::gfw::multGlobalT0ACutPars[i]); + fMultGlobalT0ACutLow->SetParameter(o2::analysis::gfw::multGlobalT0ACutPars.size(), cfgGlobalAsideCorrCuts.cfgGlobalT0ALowSigma); + for (int i = 0; i < fMultGlobalT0ACutLow->GetNpar(); ++i) + LOGF(info, "fMultGlobalT0ACutLow par %d = %g", i, fMultGlobalT0ACutLow->GetParameter(i)); + + fMultGlobalT0ACutHigh = new TF1("fMultGlobalT0ACutHigh", cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->c_str(), 0, t0aAxis.binEdges.back()); + for (std::size_t i = 0; i < o2::analysis::gfw::multGlobalT0ACutPars.size(); ++i) + fMultGlobalT0ACutHigh->SetParameter(i, o2::analysis::gfw::multGlobalT0ACutPars[i]); + fMultGlobalT0ACutHigh->SetParameter(o2::analysis::gfw::multGlobalT0ACutPars.size(), cfgGlobalAsideCorrCuts.cfgGlobalT0AHighSigma); + for (int i = 0; i < fMultGlobalT0ACutHigh->GetNpar(); ++i) + LOGF(info, "fMultGlobalT0ACutHigh par %d = %g", i, fMultGlobalT0ACutHigh->GetParameter(i)); + } + if (cfgUseDensityDependentCorrection) { + std::vector pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0}; + hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]); + funcEff.resize(pTEffBins.size() - 1); + // LHC24g3 Eff + std::vector f1p0 = cfgTrackDensityP0; + std::vector f1p1 = cfgTrackDensityP1; + for (uint ifunc = 0; ifunc < pTEffBins.size() - 1; ifunc++) { + funcEff[ifunc] = new TF1(Form("funcEff%i", ifunc), "[0]+[1]*x", 0, 3000); + funcEff[ifunc]->SetParameters(f1p0[ifunc], f1p1[ifunc]); + } + funcV2 = new TF1("funcV2", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV2->SetParameters(0.0186111, 0.00351907, -4.38264e-05, 1.35383e-07, -3.96266e-10); + funcV3 = new TF1("funcV3", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV3->SetParameters(0.0174056, 0.000703329, -1.45044e-05, 1.91991e-07, -1.62137e-09); + funcV4 = new TF1("funcV4", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 100); + funcV4->SetParameters(0.008845, 0.000259668, -3.24435e-06, 4.54837e-08, -6.01825e-10); + } + if (cfgConsistentEventFlag) { + posRegionIndex = [&]() { + auto begin = cfgRegions->GetNames().begin(); + auto end = cfgRegions->GetNames().end(); + auto it = std::find(begin, end, "refP"); + return (it != end) ? std::distance(begin, it) : -1; + }(); + negRegionIndex = [&]() { + auto begin = cfgRegions->GetNames().begin(); + auto end = cfgRegions->GetNames().end(); + auto it = std::find(begin, end, "refN"); + return (it != end) ? std::distance(begin, it) : -1; + }(); + fullRegionIndex = [&]() { + auto begin = cfgRegions->GetNames().begin(); + auto end = cfgRegions->GetNames().end(); + auto it = std::find(begin, end, "refFull"); + return (it != end) ? std::distance(begin, it) : -1; + }(); + midRegionIndex = [&]() { + auto begin = cfgRegions->GetNames().begin(); + auto end = cfgRegions->GetNames().end(); + auto it = std::find(begin, end, "refMid"); + return (it != end) ? std::distance(begin, it) : -1; + }(); + } + } + + static constexpr std::string_view FillTimeName[] = {"before/", "after/"}; + + enum QAFillTime { + kBefore, + kAfter + }; + + void addConfigObjectsToObjArray(TObjArray* oba, const std::vector& configs) + { + for (auto it = configs.begin(); it != configs.end(); ++it) { + if (it->pTDif) { + std::string suffix = "_ptDiff"; + for (auto i = 0; i < fSecondAxis->GetNbins(); ++i) { + std::string index = Form("_pt_%i", i + 1); + oba->Add(new TNamed(it->Head.c_str() + index, it->Head.c_str() + suffix)); + } + } else { + oba->Add(new TNamed(it->Head.c_str(), it->Head.c_str())); + } + } + } + + int getMagneticField(uint64_t timestamp) + { + static o2::parameters::GRPMagField* grpo = nullptr; + if (grpo == nullptr) { + // grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); + grpo = ccdb->getForTimeStamp("GLO/Config/GRPMagField", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + } + return grpo->getNominalL3Field(); + } + + void loadCorrections(aod::BCsWithTimestamps::iterator const& bc) + { + uint64_t timestamp = bc.timestamp(); + if (!cfgRunByRun && cfg.correctionsLoaded) + return; + if (!cfgAcceptance.value.empty()) { + std::string runstr = (cfgRunByRun) ? "RunByRun/" : ""; + cfg.mAcceptance = ccdb->getForTimeStamp(cfgAcceptance.value + runstr, timestamp); + } + if (!cfgEfficiency.value.empty()) { + cfg.mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); + if (cfg.mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram from %s", cfgEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)cfg.mEfficiency); + } + cfg.correctionsLoaded = true; + } + + template + double getAcceptance(TTrack track, const double& vtxz) + { + double wacc = 1; + if (cfg.mAcceptance) + wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), vtxz); + return wacc; + } + + template + double getEfficiency(TTrack track) + { + double eff = 1.; + if (cfg.mEfficiency) + eff = cfg.mEfficiency->GetBinContent(cfg.mEfficiency->FindBin(track.pt())); + if (eff == 0) + return -1.; + else + return 1. / eff; + } + + template + bool eventSelected(TCollision collision, const int& multTrk, const float& centrality, const int& run) + { + if (cfgTVXinTRD) { + if (collision.alias_bit(kTVXinTRD)) { + // TRD triggered + // "CMTVX-B-NOPF-TRD,minbias_TVX" + return 0; + } + registry.fill(HIST("eventQA/eventSel"), kTVXTRD); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kTVXTRD); + } + if (cfgNoSameBunchPileupCut) { + if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return 0; + } + registry.fill(HIST("eventQA/eventSel"), kNoSamebunchPU); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kNoSamebunchPU); + } + if (cfgIsGoodZvtxFT0vsPV) { + if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return 0; + } + registry.fill(HIST("eventQA/eventSel"), kZVtxFT0PV); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kZVtxFT0PV); + } + if (cfgNoCollInTimeRangeStandard) { + if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // Rejection of the collisions which have other events nearby + return 0; + } + registry.fill(HIST("eventQA/eventSel"), kNoCollTRStd); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kNoCollTRStd); + } + + if (cfgIsVertexITSTPC) { + if (!collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + // selects collisions with at least one ITS-TPC track, and thus rejects vertices built from ITS-only tracks + return 0; + } + registry.fill(HIST("eventQA/eventSel"), kVtxITSTPC); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kVtxITSTPC); + } + + if (cfgIsGoodITSLayersAll) { + if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return 0; + } + registry.fill(HIST("eventQA/eventSel"), kGoodITSLayers); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kGoodITSLayers); + } + + float vtxz = -999; + if (collision.numContrib() > 1) { + vtxz = collision.posZ(); + float zRes = std::sqrt(collision.covZZ()); + float minZRes = 0.25; + int minNContrib = 20; + if (zRes > minZRes && collision.numContrib() < minNContrib) + vtxz = -999; + } + auto multNTracksPV = collision.multNTracksPV(); + + if (vtxz > o2::analysis::gfw::vtxZup || vtxz < o2::analysis::gfw::vtxZlow) + return 0; + + if (cfgMultCut) { + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return 0; + if (multTrk < fMultCutLow->Eval(centrality)) + return 0; + if (multTrk > fMultCutHigh->Eval(centrality)) + return 0; + if (multTrk > fMultPVGlobalCutHigh->Eval(collision.multNTracksPV())) + return 0; + + if (!(cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->empty()) && static_cast(collision.multFV0A()) < fMultGlobalV0ACutLow->Eval(multTrk)) + return 0; + if (!(cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->empty()) && static_cast(collision.multFV0A()) > fMultGlobalV0ACutHigh->Eval(multTrk)) + return 0; + if (!(cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->empty()) && static_cast(collision.multFT0A()) < fMultGlobalT0ACutLow->Eval(multTrk)) + return 0; + if (!(cfgGlobalAsideCorrCuts.cfgMultGlobalASideCorrCutFunction->empty()) && static_cast(collision.multFT0A()) > fMultGlobalT0ACutHigh->Eval(multTrk)) + return 0; + registry.fill(HIST("eventQA/eventSel"), kMultCuts); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kMultCuts); + } + return 1; + } + + template + bool trackSelected(TTrack track) + { + if (cfgDCAxyNSigma && (std::fabs(track.dcaXY()) > fPtDepDCAxy->Eval(track.pt()))) + return false; + return ((track.tpcNClsCrossedRows() >= cfgNTPCXrows) && (track.tpcNClsFound() >= cfgNTPCCls) && (track.itsNCls() >= cfgMinNITSCls)); + } + + enum DataType { + kReco, + kGen + }; + + template + void fillWeights(const TTrack track, const double vtxz, const int& run) + { + if (cfgRunByRun) + th3sList[run][hNUAref]->Fill(track.phi(), track.eta(), vtxz); + else + registry.fill(HIST("phi_eta_vtxz_ref"), track.phi(), track.eta(), vtxz); + return; + } + + void createRunByRunHistograms(const int& run) + { + AxisSpec phiAxis = {o2::analysis::gfw::phibins, o2::analysis::gfw::philow, o2::analysis::gfw::phiup, "#phi"}; + AxisSpec etaAxis = {o2::analysis::gfw::etabins, -cfgEta, cfgEta, "#eta"}; + AxisSpec vtxAxis = {o2::analysis::gfw::vtxZbins, -cfgVtxZ, cfgVtxZ, "Vtx_{z} (cm)"}; + AxisSpec nchAxis = {o2::analysis::gfw::nchbins, o2::analysis::gfw::nchlow, o2::analysis::gfw::nchup, "N_{ch}"}; + AxisSpec centAxis = {o2::analysis::gfw::centbinning, "Centrality (%)"}; + std::vector> histos(kCount_TH1Names); + histos[hPhi] = registry.add(Form("%d/phi", run), "", {HistType::kTH1D, {phiAxis}}); + histos[hEta] = registry.add(Form("%d/eta", run), "", {HistType::kTH1D, {etaAxis}}); + histos[hVtxZ] = registry.add(Form("%d/vtxz", run), "", {HistType::kTH1D, {vtxAxis}}); + histos[hMult] = registry.add(Form("%d/mult", run), "", {HistType::kTH1D, {nchAxis}}); + histos[hCent] = registry.add(Form("%d/cent", run), "", {HistType::kTH1D, {centAxis}}); + if (cfgFillFlowRunByRun) { + std::vector> profiles(kCount_TProfileNames); + profiles[pfCorr22] = registry.add(Form("%d/corr22", run), "", {HistType::kTProfile, {(cfgUseNch) ? nchAxis : centAxis}}); + tpfsList.insert(std::make_pair(run, profiles)); + } + histos[hEventSel] = registry.add(Form("%d/eventSel", run), "Number of Events;; Counts", {HistType::kTH1D, {{11, 0.5, 11.5}}}); + histos[hEventSel]->GetXaxis()->SetBinLabel(kFilteredEvent, "Filtered event"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kSel8, "sel8"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kOccupancy, "occupancy"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kTVXTRD, "kTVXinTRD"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kNoSamebunchPU, "kNoSameBunchPileup"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kZVtxFT0PV, "kIsGoodZvtxFT0vsPV"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kNoCollTRStd, "kNoCollInTimeRangeStandard"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kVtxITSTPC, "kIsVertexITSTPC"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kGoodITSLayers, "kIsGoodITSLayersAll"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kMultCuts, "after Mult cuts"); + histos[hEventSel]->GetXaxis()->SetBinLabel(kTrackCent, "has track + within cent"); + th1sList.insert(std::make_pair(run, histos)); + std::vector> histos3d(kCount_TH3Names); + histos3d[hNUAref] = registry.add(Form("%d/phi_eta_vtxz_ref", run), "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + th3sList.insert(std::make_pair(run, histos3d)); + return; + } + + template + void fillOutputContainers(const float& centmult, const double& rndm, const int& run = 0) + { + (dt == kGen) ? fFCptgen->calculateCorrelations() : fFCpt->calculateCorrelations(); + (dt == kGen) ? fFCptgen->fillPtProfiles(centmult, rndm) : fFCpt->fillPtProfiles(centmult, rndm); + (dt == kGen) ? fFCptgen->fillCMProfiles(centmult, rndm) : fFCpt->fillCMProfiles(centmult, rndm); + for (uint l_ind = 0; l_ind < corrconfigs.size(); ++l_ind) { + if (!corrconfigs.at(l_ind).pTDif) { + auto dnx = fGFW->Calculate(corrconfigs.at(l_ind), 0, kTRUE).real(); + if (dnx == 0) + continue; + auto val = fGFW->Calculate(corrconfigs.at(l_ind), 0, kFALSE).real() / dnx; + if (std::abs(val) < 1) { + (dt == kGen) ? fFCgen->FillProfile(corrconfigs.at(l_ind).Head.c_str(), centmult, val, (cfgUseMultiplicityFlowWeights) ? dnx : 1.0, rndm) : fFC->FillProfile(corrconfigs.at(l_ind).Head.c_str(), centmult, val, (cfgUseMultiplicityFlowWeights) ? dnx : 1.0, rndm); + (dt == kGen) ? fFCptgen->fillVnPtProfiles(centmult, val, (cfgUseMultiplicityFlowWeights) ? dnx : 1.0, rndm, o2::analysis::gfw::configs.GetpTCorrMasks()[l_ind]) : fFCpt->fillVnPtProfiles(centmult, val, (cfgUseMultiplicityFlowWeights) ? dnx : 1.0, rndm, o2::analysis::gfw::configs.GetpTCorrMasks()[l_ind]); + if (cfgRunByRun && cfgFillFlowRunByRun && dt != kGen && l_ind == 0) { + tpfsList[run][pfCorr22]->Fill(centmult, val, (cfgUseMultiplicityFlowWeights) ? dnx : 1.0); + } + } + continue; + } + for (int i = 1; i <= fSecondAxis->GetNbins(); i++) { + auto dnx = fGFW->Calculate(corrconfigs.at(l_ind), i - 1, kTRUE).real(); + if (dnx == 0) + continue; + auto val = fGFW->Calculate(corrconfigs.at(l_ind), i - 1, kFALSE).real() / dnx; + if (std::abs(val) < 1) + (dt == kGen) ? fFCgen->FillProfile(Form("%s_pt_%i", corrconfigs.at(l_ind).Head.c_str(), i), centmult, val, (cfgUseMultiplicityFlowWeights) ? dnx : 1.0, rndm) : fFC->FillProfile(Form("%s_pt_%i", corrconfigs.at(l_ind).Head.c_str(), i), centmult, val, (cfgUseMultiplicityFlowWeights) ? dnx : 1.0, rndm); + } + } + return; + } + + struct XAxis { + float centrality; + int64_t multiplicity; + double time; + }; + + struct AcceptedTracks { + int nPos; + int nNeg; + int nFull; + int nMid; + }; + + template + void processCollision(TCollision collision, TTracks tracks, const XAxis& xaxis, const int& run) + { + if (tracks.size() < 1) + return; + if (dt != kGen && xaxis.centrality >= 0 && (xaxis.centrality < o2::analysis::gfw::centbinning.front() || xaxis.centrality > o2::analysis::gfw::centbinning.back())) + return; + if (xaxis.multiplicity < cfgFixedMultMin || xaxis.multiplicity > cfgFixedMultMax) + return; + if (dt != kGen) { + registry.fill(HIST("eventQA/eventSel"), kTrackCent); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kTrackCent); + } + if (xaxis.centrality >= 0) + registry.fill(HIST("eventQA/after/centrality"), xaxis.centrality); + registry.fill(HIST("eventQA/after/multiplicity"), xaxis.multiplicity); + float vtxz = collision.posZ(); + if (dt != kGen && cfgRunByRun) { + th1sList[run][hVtxZ]->Fill(vtxz); + th1sList[run][hMult]->Fill(xaxis.multiplicity); + th1sList[run][hCent]->Fill(xaxis.centrality); + } + fGFW->Clear(); + (dt == kGen) ? fFCptgen->clearVector() : fFCpt->clearVector(); + + float lRandom = fRndm->Rndm(); + + // be cautious, this only works for Pb-Pb + // esimate the Event plane and vn for this event + DensityCorr densitycorrections; + if (cfgUseDensityDependentCorrection) { + double psi2Est = 0, psi3Est = 0, psi4Est = 0; + double v2 = 0, v3 = 0, v4 = 0; + double q2x = 0, q2y = 0; + double q3x = 0, q3y = 0; + double q4x = 0, q4y = 0; + for (const auto& track : tracks) { + bool withinPtRef = (o2::analysis::gfw::ptreflow < track.pt()) && (track.pt() < o2::analysis::gfw::ptrefup); // within RF pT rang + if (withinPtRef) { + q2x += std::cos(2 * track.phi()); + q2y += std::sin(2 * track.phi()); + q3x += std::cos(3 * track.phi()); + q3y += std::sin(3 * track.phi()); + q4x += std::cos(4 * track.phi()); + q4y += std::sin(4 * track.phi()); + } + } + psi2Est = std::atan2(q2y, q2x) / 2.; + psi3Est = std::atan2(q3y, q3x) / 3.; + psi4Est = std::atan2(q4y, q4x) / 4.; + v2 = funcV2->Eval(xaxis.centrality); + v3 = funcV3->Eval(xaxis.centrality); + v4 = funcV4->Eval(xaxis.centrality); + densitycorrections.psi2Est = psi2Est; + densitycorrections.psi3Est = psi3Est; + densitycorrections.psi4Est = psi4Est; + densitycorrections.v2 = v2; + densitycorrections.v3 = v3; + densitycorrections.v4 = v4; + densitycorrections.density = tracks.size(); + } + AcceptedTracks acceptedTracks{0, 0, 0, 0}; + for (const auto& track : tracks) { + processTrack(track, vtxz, xaxis.multiplicity, run, densitycorrections, acceptedTracks); + if (cfgConsistentEventFlag & 1) + if (!acceptedTracks.nPos || !acceptedTracks.nNeg) + return; + if (cfgConsistentEventFlag & 2) + if (acceptedTracks.nFull < 4) // o2-linter: disable=magic-number (at least four tracks in full acceptance) + return; + if (cfgConsistentEventFlag & 4) + if (acceptedTracks.nPos < 2 || acceptedTracks.nNeg < 2) // o2-linter: disable=magic-number (at least two tracks in each subevent) + return; + if (cfgConsistentEventFlag & 8) + if (acceptedTracks.nPos < 2 || acceptedTracks.nMid < 2 || acceptedTracks.nNeg < 2) // o2-linter: disable=magic-number (at least two tracks in all three subevents) + return; + } + if (!cfgFillWeights) + fillOutputContainers
((cfgTimeDependent) ? xaxis.time : (cfgUseNch) ? xaxis.multiplicity + : xaxis.centrality, + lRandom, run); + } + + bool isStable(int pdg) + { + if (std::abs(pdg) == PDG_t::kPiPlus) + return true; + if (std::abs(pdg) == PDG_t::kKPlus) + return true; + if (std::abs(pdg) == PDG_t::kProton) + return true; + if (std::abs(pdg) == PDG_t::kElectron) + return true; + if (std::abs(pdg) == PDG_t::kMuonMinus) + return true; + return false; + } + + template + void fillAcceptedTracks(TTrack track, AcceptedTracks& acceptedTracks) + { + if (posRegionIndex >= 0 && track.eta() > o2::analysis::gfw::regions.GetEtaMin()[posRegionIndex] && track.eta() < o2::analysis::gfw::regions.GetEtaMax()[posRegionIndex]) + ++acceptedTracks.nPos; + if (negRegionIndex >= 0 && track.eta() > o2::analysis::gfw::regions.GetEtaMin()[negRegionIndex] && track.eta() < o2::analysis::gfw::regions.GetEtaMax()[negRegionIndex]) + ++acceptedTracks.nNeg; + if (fullRegionIndex >= 0 && track.eta() > o2::analysis::gfw::regions.GetEtaMin()[fullRegionIndex] && track.eta() < o2::analysis::gfw::regions.GetEtaMax()[fullRegionIndex]) + ++acceptedTracks.nFull; + if (midRegionIndex >= 0 && track.eta() > o2::analysis::gfw::regions.GetEtaMin()[midRegionIndex] && track.eta() < o2::analysis::gfw::regions.GetEtaMax()[midRegionIndex]) + ++acceptedTracks.nMid; + } + + template + inline void processTrack(TTrack const& track, const float& vtxz, const int& multiplicity, const int& run, DensityCorr densitycorrections, AcceptedTracks& acceptedTracks) + { + if constexpr (framework::has_type_v) { + if (track.mcParticleId() < 0 || !(track.has_mcParticle())) + return; + + auto mcParticle = track.mcParticle(); + if (!mcParticle.isPhysicalPrimary()) + return; + if (!isStable(mcParticle.pdgCode())) + return; + if (cfgFillQA) { + fillTrackQA(track, vtxz); + registry.fill(HIST("trackQA/before/nch_pt"), multiplicity, track.pt()); + } + if (!trackSelected(track)) + return; + + if (cfgFillWeights) { + fillWeights(track, vtxz, run); + } else { + fillPtSums(track); + fillGFW(track, vtxz, densitycorrections); + fillAcceptedTracks(track, acceptedTracks); + } + + if (cfgFillQA) { + fillTrackQA(track, vtxz); + registry.fill(HIST("trackQA/after/nch_pt"), multiplicity, track.pt()); + if (cfgRunByRun) { + th1sList[run][hPhi]->Fill(track.phi()); + th1sList[run][hEta]->Fill(track.eta()); + } + } + + } else if constexpr (framework::has_type_v) { + if (!track.isPhysicalPrimary() || !isStable(track.pdgCode())) + return; + + fillPtSums(track); + fillGFW(track, vtxz, densitycorrections); + fillAcceptedTracks(track, acceptedTracks); + if (cfgFillQA) { + fillTrackQA(track, vtxz); + registry.fill(HIST("MCGen/trackQA/nch_pt"), multiplicity, track.pt()); + } + } else { + if (cfgFillQA) { + fillTrackQA(track, vtxz); + registry.fill(HIST("trackQA/before/nch_pt"), multiplicity, track.pt()); + } + if (!trackSelected(track)) + return; + + if (cfgFillWeights) { + fillWeights(track, vtxz, run); + } else { + fillPtSums(track); + fillGFW(track, vtxz, densitycorrections); + fillAcceptedTracks(track, acceptedTracks); + } + if (cfgFillQA) { + fillTrackQA(track, vtxz); + registry.fill(HIST("trackQA/after/nch_pt"), multiplicity, track.pt()); + if (cfgRunByRun) { + th1sList[run][hPhi]->Fill(track.phi()); + th1sList[run][hEta]->Fill(track.eta()); + th3sList[run][hNUAref]->Fill(track.phi(), track.eta(), vtxz, getAcceptance(track, vtxz)); + } + } + } + return; + } + + template + inline void fillGFW(TTrack track, const double& vtxz, DensityCorr densitycorrections) + { + bool withinPtRef = (track.pt() > o2::analysis::gfw::ptreflow && track.pt() < o2::analysis::gfw::ptrefup); + bool withinPtPOI = (track.pt() > o2::analysis::gfw::ptpoilow && track.pt() < o2::analysis::gfw::ptpoiup); + if (!withinPtPOI && !withinPtRef) + return; + double weff = (dt == kGen) ? 1. : getEfficiency(track); + if (weff < 0) + return; + if (cfgUseDensityDependentCorrection && withinPtRef && dt != kGen) { + double fphi = densitycorrections.v2 * std::cos(2 * (track.phi() - densitycorrections.psi2Est)) + densitycorrections.v3 * std::cos(3 * (track.phi() - densitycorrections.psi3Est)) + densitycorrections.v4 * std::cos(4 * (track.phi() - densitycorrections.psi4Est)); + fphi = (1 + 2 * fphi); + int pTBinForEff = hFindPtBin->FindBin(track.pt()); + if (pTBinForEff >= 1 && pTBinForEff <= hFindPtBin->GetNbinsX()) { + float wEPeff = funcEff[pTBinForEff - 1]->Eval(fphi * densitycorrections.density); + if (wEPeff > 0.) { + wEPeff = 1. / wEPeff; + weff *= wEPeff; + } + } + } + double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz); + if (withinPtRef) + fGFW->Fill(track.eta(), fSecondAxis->FindBin(track.pt()) - 1, track.phi(), weff * wacc, 1); + if (withinPtPOI) + fGFW->Fill(track.eta(), fSecondAxis->FindBin(track.pt()) - 1, track.phi(), weff * wacc, 2); + if (withinPtRef && withinPtPOI) + fGFW->Fill(track.eta(), fSecondAxis->FindBin(track.pt()) - 1, track.phi(), weff * wacc, 4); + return; + } + + template + inline void fillPtSums(TTrack track) + { + double weff = (dt == kGen) ? 1. : getEfficiency(track); + if (weff < 0) + return; + if (std::abs(track.eta()) < cfgEtaPtPt && track.pt() > o2::analysis::gfw::ptreflow && track.pt() < o2::analysis::gfw::ptrefup) { + (dt == kGen) ? fFCptgen->fill(1., track.pt()) : fFCpt->fill(weff, track.pt()); + } + } + + template + inline void fillTrackQA(TTrack track, const float vtxz) + { + if constexpr (dt == kGen) { + registry.fill(HIST("MCGen/trackQA/phi_eta_vtxZ"), track.phi(), track.eta(), vtxz); + registry.fill(HIST("MCGen/trackQA/pt_ref"), track.pt()); + registry.fill(HIST("MCGen/trackQA/pt_poi"), track.pt()); + } else { + double wacc = getAcceptance(track, vtxz); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter) ? wacc : 1.0); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_dcaXY_dcaZ"), track.pt(), track.dcaXY(), track.dcaZ()); + + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("chi2prTPCcls"), track.tpcChi2NCl()); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("chi2prITScls"), track.itsChi2NCl()); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("nTPCClusters"), track.tpcNClsFound()); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("nITSClusters"), track.itsNCls()); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("nTPCCrossedRows"), track.tpcNClsCrossedRows()); + + if (ft == kAfter) { + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_ref"), track.pt()); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_poi"), track.pt()); + } + } + } + + template + float getCentrality(TCollision collision) + { + switch (cfgCentEstimator) { + case kCentFT0C: + return collision.centFT0C(); + case kCentFT0CVariant1: + return collision.centFT0CVariant1(); + case kCentFT0M: + return collision.centFT0M(); + case kCentFV0A: + return collision.centFV0A(); + case kCentNTPV: + return collision.centNTPV(); + case kCentNGlobal: + return collision.centNGlobal(); + case kCentMFT: + return collision.centMFT(); + default: + return collision.centFT0C(); + } + } + + template + inline void fillEventQA(TCollision collision, XAxis xaxis) + { + if constexpr (framework::has_type_v) { + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("globalTracks_centT0C"), collision.centFT0C(), xaxis.multiplicity); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV()); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("centT0M_centT0C"), collision.centFT0C(), collision.centFT0M()); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("centV0A_centT0C"), collision.centFT0C(), collision.centFV0A()); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("centGlobal_centT0C"), collision.centFT0C(), collision.centNGlobal()); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("centNTPV_centT0C"), collision.centFT0C(), collision.centNTPV()); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("centMFT_centT0C"), collision.centFT0C(), collision.centMFT()); + } + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("globalTracks_PVTracks"), collision.multNTracksPV(), xaxis.multiplicity); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("globalTracks_multT0A"), collision.multFT0A(), xaxis.multiplicity); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("globalTracks_multV0A"), collision.multFV0A(), xaxis.multiplicity); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); + if (cfgTimeDependent) { + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("multiplicity_time"), xaxis.time, xaxis.multiplicity); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("multT0C_time"), xaxis.time, collision.multFT0C()); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("multT0A_time"), xaxis.time, collision.multFT0A()); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("multV0A_time"), xaxis.time, collision.multFV0A()); + registry.fill(HIST("eventQA/") + HIST(FillTimeName[ft]) + HIST("multPV_time"), xaxis.time, collision.multNTracksPV()); + } + return; + } + + double getTimeSinceStartOfFill(uint64_t timestamp, int firstRun) + { + auto runDuration = ccdb->getRunDuration(firstRun); + uint64_t tsSOF = runDuration.first; + uint64_t diff = timestamp - tsSOF; + return static_cast(diff) / 3600000.0; + } + + void processData(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) + { + auto bc = collision.bc_as(); + int run = bc.runNumber(); + if (run != lastRun) { + lastRun = run; + LOGF(info, "run = %d", run); + if (cfgRunByRun) { + if (std::find(runNumbers.begin(), runNumbers.end(), run) == runNumbers.end()) { + LOGF(info, "Creating histograms for run %d", run); + createRunByRunHistograms(run); + runNumbers.push_back(run); + } else { + LOGF(info, "run %d already in runNumbers", run); + } + if (!cfgFillWeights) + loadCorrections(bc); + } + } + if (!cfgFillWeights && !cfgRunByRun) + loadCorrections(bc); + registry.fill(HIST("eventQA/eventSel"), kFilteredEvent); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kFilteredEvent); + if (!collision.sel8()) + return; + registry.fill(HIST("eventQA/eventSel"), kSel8); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kSel8); + if (cfgDoOccupancySel) { + int occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy < 0 || occupancy > cfgOccupancySelection) + return; + } + registry.fill(HIST("eventQA/eventSel"), kOccupancy); + if (cfgRunByRun) + th1sList[run][hEventSel]->Fill(kOccupancy); + + const XAxis xaxis{getCentrality(collision), tracks.size(), (cfgTimeDependent) ? getTimeSinceStartOfFill(bc.timestamp(), *firstRunOfCurrentFill) : -1.0}; + if (cfgTimeDependent && run == *firstRunOfCurrentFill && firstRunOfCurrentFill != o2::analysis::gfw::firstRunsOfFill.end() - 1) + ++firstRunOfCurrentFill; + + if (cfgFillQA) + fillEventQA(collision, xaxis); + registry.fill(HIST("eventQA/before/centrality"), xaxis.centrality); + registry.fill(HIST("eventQA/before/multiplicity"), xaxis.multiplicity); + if (cfgUseAdditionalEventCut && !eventSelected(collision, xaxis.multiplicity, xaxis.centrality, run)) + return; + if (cfgFillQA) + fillEventQA(collision, xaxis); + processCollision(collision, tracks, xaxis, run); + } + PROCESS_SWITCH(FlowGfwLightIons, processData, "Process analysis for non-derived data", true); + + void processMCReco(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks, aod::McParticles const&) + { + auto bc = collision.bc_as(); + int run = bc.runNumber(); + if (run != lastRun) { + lastRun = run; + if (cfgRunByRun) + createRunByRunHistograms(run); + } + if (!collision.sel8()) + return; + + const XAxis xaxis{getCentrality(collision), tracks.size(), (cfgTimeDependent) ? getTimeSinceStartOfFill(bc.timestamp(), *firstRunOfCurrentFill) : -1.0}; + if (cfgTimeDependent && run == *firstRunOfCurrentFill && firstRunOfCurrentFill != o2::analysis::gfw::firstRunsOfFill.end() - 1) + ++firstRunOfCurrentFill; + + if (cfgFillQA) + fillEventQA(collision, xaxis); + registry.fill(HIST("eventQA/before/centrality"), xaxis.centrality); + registry.fill(HIST("eventQA/before/multiplicity"), xaxis.multiplicity); + if (cfgUseAdditionalEventCut && !eventSelected(collision, xaxis.multiplicity, xaxis.centrality, run)) + return; + if (cfgFillQA) + fillEventQA(collision, xaxis); + if (!cfgFillWeights) + loadCorrections(bc); + processCollision(collision, tracks, xaxis, run); + } + PROCESS_SWITCH(FlowGfwLightIons, processMCReco, "Process analysis for MC reconstructed events", false); + + void processMCGen(soa::Filtered::iterator const& mcCollision, soa::SmallGroups> const& collisions, aod::McParticles const& particles, GFWTracks const& tracks) + { + if (collisions.size() != 1) + return; + float centrality = -1; + for (const auto& collision : collisions) { + centrality = getCentrality(collision); + } + + std::vector numberOfTracks; + for (auto const& collision : collisions) { + auto groupedTracks = tracks.sliceBy(perCollision, collision.globalIndex()); + numberOfTracks.emplace_back(groupedTracks.size()); + } + + const XAxis xaxis{centrality, numberOfTracks[0], -1.0}; + int run = 0; + processCollision(mcCollision, particles, xaxis, run); + } + PROCESS_SWITCH(FlowGfwLightIons, processMCGen, "Process analysis for MC generated events", false); + + void processOnTheFly(soa::Filtered::iterator const& mcCollision, aod::McParticles const& mcParticles) + { + int run = 0; + registry.fill(HIST("MCGen/impactParameter"), mcCollision.impactParameter(), mcParticles.size()); + const XAxis xaxis{mcCollision.impactParameter(), mcParticles.size(), -1.0}; + processCollision(mcCollision, mcParticles, xaxis, run); + } + PROCESS_SWITCH(FlowGfwLightIons, processOnTheFly, "Process analysis for MC on-the-fly generated events", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGCF/JCorran/Core/FlowJHistManager.cxx b/PWGCF/JCorran/Core/FlowJHistManager.cxx index c78dbc4af3b..880ec409dbd 100644 --- a/PWGCF/JCorran/Core/FlowJHistManager.cxx +++ b/PWGCF/JCorran/Core/FlowJHistManager.cxx @@ -10,18 +10,20 @@ // or submit itself to any jurisdiction. // Header files. +#include // O2 headers. // O2 Physics headers. #include "PWGCF/JCorran/Core/FlowJHistManager.h" +#include "CommonConstants/MathConstants.h" // Namespaces. using namespace o2; using namespace o2::framework; /// \brief Create the histograms in the QA registry. -void FlowJHistManager::CreateHistQA() +void FlowJHistManager::createHistQA() { // Security checks for proper use of the method. if (!mHistRegistryQA) { @@ -60,7 +62,7 @@ void FlowJHistManager::CreateHistQA() mHistRegistryQA->add("Centrality_00-01/After/histEta", "Pseudorapidity", HistType::kTH1F, {axisEta}, true); - const AxisSpec axisPhi = {100, 0., 2. * M_PI, "#varphi"}; + const AxisSpec axisPhi = {100, 0., o2::constants::math::TwoPI, "#varphi"}; mHistRegistryQA->add("Centrality_00-01/After/histPhi", "Azimuthal angles (no NUA)", HistType::kTH1F, {axisPhi}, true); @@ -145,7 +147,7 @@ void FlowJHistManager::CreateHistQA() // Clone the first centrality class into the other classes. for (int iBin = 1; iBin < mNcentBins; iBin++) { - mHistRegistryQA->addClone("Centrality_00-01/", mCentClasses[iBin].data()); + mHistRegistryQA->addClone("Centrality_00-01/", MCentClasses[iBin].data()); } LOGF(info, "QA histograms created."); @@ -154,9 +156,9 @@ void FlowJHistManager::CreateHistQA() /// \brief Get the centrality bin value corresponding to the percentile. /// \param Centrality percentile of the collision. /// \return Bin for the histograms,... -int FlowJHistManager::GetCentBin(float cValue) +int FlowJHistManager::getCentBin(float cValue) { - const float centClasses[] = {0., 1., 2., 5., 10., 20., 30., 40., 50., 60., 70.}; + const float centClasses[] = {0., 5., 10., 20., 30., 40., 50., 60., 70., 100.}; for (int i = 0; i < mNcentBins + 1; i++) { if (cValue >= centClasses[i]) { diff --git a/PWGCF/JCorran/Core/FlowJHistManager.h b/PWGCF/JCorran/Core/FlowJHistManager.h index cbb212ff917..e067a9f00b5 100644 --- a/PWGCF/JCorran/Core/FlowJHistManager.h +++ b/PWGCF/JCorran/Core/FlowJHistManager.h @@ -16,7 +16,6 @@ #define PWGCF_JCORRAN_CORE_FLOWJHISTMANAGER_H_ /* Header files. */ -#include #include #include #include @@ -33,8 +32,6 @@ // O2 Physics headers. /* Namespaces. */ -using namespace o2; -using namespace o2::framework; // ---------------------------------------------------------------------------- // Histogram manager to fill the general QA common to all flow tasks. @@ -45,52 +42,52 @@ class FlowJHistManager FlowJHistManager() = default; // Setters and getters, in the same order as the data members. - void SetHistRegistryQA(HistogramRegistry* myRegistry) + void setHistRegistryQA(o2::framework::HistogramRegistry* myRegistry) { mHistRegistryQA = myRegistry; LOGF(info, "QA histogram registry successfully set."); } - HistogramRegistry* GetHistRegistryQA() const { return mHistRegistryQA; } + o2::framework::HistogramRegistry* getHistRegistryQA() const { return mHistRegistryQA; } - void SetDebugLog(bool debug) + void setDebugLog(bool debug) { mDebugLog = debug; LOGF(info, "Debug level: %d", mDebugLog); } - bool GetDebugLog() const { return mDebugLog; } + bool getDebugLog() const { return mDebugLog; } - void SetObtainNUA(bool nua) + void setObtainNUA(bool nua) { mObtainNUA = nua; LOGF(info, "Obtain 3D Zvtx-eta-phi distribution: %d", mObtainNUA); } - bool GetObtainNUA() const { return mObtainNUA; } + bool getObtainNUA() const { return mObtainNUA; } - void SetSaveAllQA(bool saveQA) + void setSaveAllQA(bool saveQA) { mSaveAllQA = saveQA; LOGF(info, "Save the additional QA : %d.", mSaveAllQA); } - bool GetSaveAllQA() const { return mSaveAllQA; } + bool getSaveAllQA() const { return mSaveAllQA; } - void SetSaveQABefore(bool saveQA) + void setSaveQABefore(bool saveQA) { mSaveQABefore = saveQA; LOGF(info, "Save the QA before the selection : %d.", mSaveQABefore); } - bool GetSaveQABefore() const { return mSaveQABefore; } + bool getSaveQABefore() const { return mSaveQABefore; } - void SetUseVariablePtBins(bool myAxis) + void setUseVariablePtBins(bool myAxis) { mUseVariablePtBins = myAxis; LOGF(info, "Use variable pT binning: %d.", mUseVariablePtBins); } - bool GetUseVariablePtBins() const { return mUseVariablePtBins; } + bool getUseVariablePtBins() const { return mUseVariablePtBins; } /* Methods specific to this class. */ // The template functions are defined down here to prevent compilation errors. - void CreateHistQA(); - int GetCentBin(float cValue); + void createHistQA(); + int getCentBin(float cValue); /// \brief Fill the event QA histograms. /// \tparam T Type of collision. @@ -100,71 +97,72 @@ class FlowJHistManager /// \param cent Centrality percentile of the collision. /// \param multi Collision multiplicity at this step. template - void FillEventQA(T const& coll, int cBin, float cent, int multi) + void fillEventQA(T const& coll, int cBin, float cent, int multi) { if (!mHistRegistryQA) { LOGF(fatal, "QA histogram registry missing. Quitting..."); return; } - static constexpr std::string_view subDir[] = {"Before/", "After/"}; + static constexpr std::string_view SubDir[] = {"Before/", "After/"}; switch (cBin) { case 0: - mHistRegistryQA->fill(HIST(mCentClasses[0]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[0]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[0]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[0]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[0]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[0]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; case 1: - mHistRegistryQA->fill(HIST(mCentClasses[1]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[1]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[1]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[1]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[1]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[1]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; case 2: - mHistRegistryQA->fill(HIST(mCentClasses[2]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[2]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[2]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[2]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[2]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[2]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; case 3: - mHistRegistryQA->fill(HIST(mCentClasses[3]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[3]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[3]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[3]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[3]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[3]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; case 4: - mHistRegistryQA->fill(HIST(mCentClasses[4]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[4]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[4]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[4]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[4]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[4]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; case 5: - mHistRegistryQA->fill(HIST(mCentClasses[5]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[5]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[5]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[5]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[5]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[5]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; case 6: - mHistRegistryQA->fill(HIST(mCentClasses[6]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[6]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[6]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[6]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[6]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[6]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; case 7: - mHistRegistryQA->fill(HIST(mCentClasses[7]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[7]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[7]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[7]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[7]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[7]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; case 8: - mHistRegistryQA->fill(HIST(mCentClasses[8]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[8]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[8]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[8]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[8]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[8]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; case 9: - mHistRegistryQA->fill(HIST(mCentClasses[9]) + HIST(subDir[mode]) + HIST("histCent"), cent); - mHistRegistryQA->fill(HIST(mCentClasses[9]) + HIST(subDir[mode]) + HIST("histMulti"), multi); - mHistRegistryQA->fill(HIST(mCentClasses[9]) + HIST(subDir[mode]) + HIST("histZvtx"), coll.posZ()); + mHistRegistryQA->fill(HIST(MCentClasses[9]) + HIST(SubDir[mode]) + HIST("histCent"), cent); + mHistRegistryQA->fill(HIST(MCentClasses[9]) + HIST(SubDir[mode]) + HIST("histMulti"), multi); + mHistRegistryQA->fill(HIST(MCentClasses[9]) + HIST(SubDir[mode]) + HIST("histZvtx"), coll.posZ()); break; } - LOGF(info, "The EventQA has been filled."); + if (mDebugLog) + LOGF(info, "The EventQA has been filled."); } - /// \brief Hardcode the cBin for FillThisTrackQA if not constant. + /// \brief Hardcode the cBin for fillThisTrackQA if not constant. /// \tparam T Type of track. /// \tparam mode Set if we fill Before/ or After/ objects. /// \param track Track entry. @@ -172,7 +170,7 @@ class FlowJHistManager /// \param weightNUE Value of the NUE weight to apply to pT. /// \param weightNUA Value of the NUA weight to apply to phi. template - void FillTrackQA(T const& track, int cBin, + void fillTrackQA(T const& track, int cBin, float weightNUE = 1., float weightNUA = 1., float zVtx = 0.) { if (!mHistRegistryQA) { @@ -182,34 +180,34 @@ class FlowJHistManager switch (cBin) { case 0: - FillThisTrackQA<0, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<0, mode>(track, zVtx, weightNUE, weightNUA); break; case 1: - FillThisTrackQA<1, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<1, mode>(track, zVtx, weightNUE, weightNUA); break; case 2: - FillThisTrackQA<2, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<2, mode>(track, zVtx, weightNUE, weightNUA); break; case 3: - FillThisTrackQA<3, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<3, mode>(track, zVtx, weightNUE, weightNUA); break; case 4: - FillThisTrackQA<4, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<4, mode>(track, zVtx, weightNUE, weightNUA); break; case 5: - FillThisTrackQA<5, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<5, mode>(track, zVtx, weightNUE, weightNUA); break; case 6: - FillThisTrackQA<6, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<6, mode>(track, zVtx, weightNUE, weightNUA); break; case 7: - FillThisTrackQA<7, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<7, mode>(track, zVtx, weightNUE, weightNUA); break; case 8: - FillThisTrackQA<8, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<8, mode>(track, zVtx, weightNUE, weightNUA); break; case 9: - FillThisTrackQA<9, mode>(track, zVtx, weightNUE, weightNUA); + fillThisTrackQA<9, mode>(track, zVtx, weightNUE, weightNUA); break; } @@ -229,61 +227,61 @@ class FlowJHistManager /// \note This method can be directly used if no switch is previously needed. // TODO: Add filling of the weight histograms. template - void FillThisTrackQA(T const& track, float zVtx = 0., + void fillThisTrackQA(T const& track, float zVtx = 0., float weightNUE = 1., float weightNUA = 1.) { - static constexpr std::string_view subDir[] = {"Before/", "After/"}; + static constexpr std::string_view SubDir[] = {"Before/", "After/"}; - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histPt"), track.pt()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histEta"), track.eta()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histPhi"), track.phi()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histCharge"), track.sign()); + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histPt"), track.pt()); + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histEta"), track.eta()); + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histPhi"), track.phi()); + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histCharge"), track.sign()); if (mode == 1) { // 'Weight' distributions are defined only for After/. - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST("After/histPtCorrected"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST("After/histPtCorrected"), track.pt(), 1. / weightNUE); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST("After/histPhiCorrected"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST("After/histPhiCorrected"), track.phi(), 1. / weightNUA); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST("After/histNUEWeights"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST("After/histNUEWeights"), track.pt(), weightNUE); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST("After/histNUAWeights"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST("After/histNUAWeights"), track.phi(), weightNUA); // 3D distribution Zvtx-eta-phi. if (mObtainNUA) { - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST("After/histZvtxEtaPhi"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST("After/histZvtxEtaPhi"), zVtx, track.eta(), track.phi()); } } if (mSaveAllQA) { // TPC information. - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histTPCNClsFound"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histTPCNClsFound"), track.tpcNClsFound()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histTPCNClsCrossedRows"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histTPCNClsCrossedRows"), track.tpcNClsCrossedRows()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histTPCCrossedRowsOverFindableCls"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histTPCCrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histTPCFoundOverFindableCls"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histTPCFoundOverFindableCls"), track.tpcFoundOverFindableCls()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histTPCFractionSharedCls"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histTPCFractionSharedCls"), track.tpcFractionSharedCls()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histTPCChi2NCl"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histTPCChi2NCl"), track.tpcChi2NCl()); // ITS information. - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histITSNCls"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histITSNCls"), track.itsNCls()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histITSNClsInnerBarrel"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histITSNClsInnerBarrel"), track.itsNClsInnerBarrel()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histITSChi2NCl"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histITSChi2NCl"), track.itsChi2NCl()); // DCA information. - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histDCAxy"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histDCAxy"), track.pt(), track.dcaXY()); - mHistRegistryQA->fill(HIST(mCentClasses[cBin]) + HIST(subDir[mode]) + HIST("histDCAz"), + mHistRegistryQA->fill(HIST(MCentClasses[cBin]) + HIST(SubDir[mode]) + HIST("histDCAz"), track.dcaZ()); } @@ -293,7 +291,7 @@ class FlowJHistManager } private: - HistogramRegistry* mHistRegistryQA = nullptr; ///< For the QA output. + o2::framework::HistogramRegistry* mHistRegistryQA = nullptr; ///< For the QA output. bool mDebugLog = false; ///< Enable to print additional log for debug. bool mObtainNUA = false; ///< Enable to get the 3D Zvtx-eta-phi distribution for NUA. @@ -302,7 +300,7 @@ class FlowJHistManager bool mUseVariablePtBins = false; ///< Enable the use of a variable width pT binning. static const int mNcentBins = 10; ///< Number of centrality classes. - static constexpr std::string_view mCentClasses[] = { ///< Centrality classes. + static constexpr std::string_view MCentClasses[] = { ///< Centrality classes. "Centrality_00-01/", "Centrality_01-02/", "Centrality_02-05/", "Centrality_05-10/", "Centrality_10-20/", "Centrality_20-30/", "Centrality_30-40/", "Centrality_40-50/", "Centrality_50-60/", diff --git a/PWGCF/JCorran/Core/FlowJSPCAnalysis.cxx b/PWGCF/JCorran/Core/FlowJSPCAnalysis.cxx index b1221432aa4..40585b3abec 100644 --- a/PWGCF/JCorran/Core/FlowJSPCAnalysis.cxx +++ b/PWGCF/JCorran/Core/FlowJSPCAnalysis.cxx @@ -21,7 +21,7 @@ using namespace o2; using namespace o2::framework; using namespace std; -TComplex FlowJSPCAnalysis::Q(const Int_t harmN, const Int_t p) +TComplex FlowJSPCAnalysis::q(const int harmN, const int p) { if (harmN >= 0) return qvecs->QvectorQC[harmN][p]; @@ -34,24 +34,24 @@ TComplex FlowJSPCAnalysis::Q(const Int_t harmN, const Int_t p) /// \return Complex value of the multiparticle correlator. /// \note Improved faster version) originally developed by Kristjan Gulbrandsen /// (gulbrand@nbi.dk). -TComplex FlowJSPCAnalysis::Recursion(int n, int* harmonic, int mult = 1, int skip = 0) +TComplex FlowJSPCAnalysis::recursion(int n, int* harmonic, int mult = 1, int skip = 0) { - Int_t nm1 = n - 1; - TComplex c(Q(harmonic[nm1], mult)); + int nm1 = n - 1; + TComplex c(q(harmonic[nm1], mult)); if (nm1 == 0) return c; - c *= Recursion(nm1, harmonic); + c *= recursion(nm1, harmonic); if (nm1 == skip) return c; - Int_t multp1 = mult + 1; - Int_t nm2 = n - 2; - Int_t counter1 = 0; - Int_t hhold = harmonic[counter1]; + int multp1 = mult + 1; + int nm2 = n - 2; + int counter1 = 0; + int hhold = harmonic[counter1]; harmonic[counter1] = harmonic[nm2]; harmonic[nm2] = hhold + harmonic[nm1]; - TComplex c2(Recursion(nm1, harmonic, multp1, nm2)); - Int_t counter2 = n - 3; + TComplex c2(recursion(nm1, harmonic, multp1, nm2)); + int counter2 = n - 3; while (counter2 >= skip) { harmonic[nm2] = harmonic[counter1]; @@ -60,7 +60,7 @@ TComplex FlowJSPCAnalysis::Recursion(int n, int* harmonic, int mult = 1, int ski hhold = harmonic[counter1]; harmonic[counter1] = harmonic[nm2]; harmonic[nm2] = hhold + harmonic[nm1]; - c2 += Recursion(nm1, harmonic, multp1, counter2); + c2 += recursion(nm1, harmonic, multp1, counter2); --counter2; } harmonic[nm2] = harmonic[counter1]; @@ -68,298 +68,356 @@ TComplex FlowJSPCAnalysis::Recursion(int n, int* harmonic, int mult = 1, int ski if (mult == 1) return c - c2; - return c - Double_t(mult) * c2; + return c - static_cast(mult) * c2; } // End of recursion -void FlowJSPCAnalysis::CalculateCorrelators(const Int_t fCentBin) +void FlowJSPCAnalysis::calculateCorrelators(const int fCentBin) { // Loop over the combinations of harmonics and calculate the corresponding SPC num and den. // Declare the arrays to later fill all the needed bins for the correlators // and the error terms. - Double_t* dataCorrelation = new Double_t[3]; // cosine, weight, sine. - Double_t correlationNum; - Double_t weightCorrelationNum; - Double_t correlationDenom; - Double_t weightCorrelationDenom; + double* dataCorrelation = new double[3]; // cosine, weight, sine. + double correlationNum; + double weightCorrelationNum; + double correlationDenom; + double weightCorrelationDenom; - for (Int_t j = 0; j < 12; j++) { + for (int i = 0; i < 14; ++i) + fCorrelDenoms[i] = 0; + + for (int j = 0; j < 12; j++) { if (fHarmosArray[j][0] == 0) { continue; } // Skip null correlator list. // Calculate the numerator. - Int_t hArrayNum[7] = {0}; + int hArrayNum[7] = {0}; for (int iH = 0; iH < 7; iH++) { hArrayNum[iH] = fHarmosArray[j][iH + 1]; } - Correlation(fHarmosArray[j][0], 7, hArrayNum, dataCorrelation); + correlation(fHarmosArray[j][0], 7, hArrayNum, dataCorrelation); correlationNum = dataCorrelation[0]; weightCorrelationNum = dataCorrelation[1]; // Calculate the denominator. - Int_t nPartDen = 2 * fHarmosArray[j][0]; - Int_t hArrayDen[14] = {0}; + int nPartDen = 2 * fHarmosArray[j][0]; + int hArrayDen[14] = {0}; for (int iH = 0; iH < 7; iH++) { hArrayDen[2 * iH] = hArrayNum[iH]; hArrayDen[2 * iH + 1] = -1 * hArrayNum[iH]; } - Correlation(nPartDen, 14, hArrayDen, dataCorrelation); + correlation(nPartDen, 14, hArrayDen, dataCorrelation); correlationDenom = dataCorrelation[0]; weightCorrelationDenom = dataCorrelation[1]; + // Check if the values are real numbers before filling. + if (std::isnan(correlationNum) || std::isnan(correlationDenom) || std::isnan(weightCorrelationNum) || std::isnan(weightCorrelationDenom)) + continue; + // Histogram filling + fillHistograms(fCentBin, j, correlationNum, correlationDenom, weightCorrelationNum, weightCorrelationDenom); - FillHistograms(fCentBin, j, correlationNum, correlationDenom, weightCorrelationNum, weightCorrelationDenom); + correlationNum = 0.; + weightCorrelationNum = 0.; + correlationDenom = 0.; + weightCorrelationDenom = 0.; + } +} - correlationNum = 0; - weightCorrelationNum = 0; - correlationDenom = 0; - weightCorrelationDenom = 0; +void FlowJSPCAnalysis::fillHistograms(const int fCentBin, int ind, double cNum, double cDenom, double wNum, double wDenom) +{ + switch (fCentBin) { + case 0: { + mHistRegistry->fill(HIST(MCentClasses[0]) + HIST("fResults"), 2. * static_cast(ind) + 0.5, cNum, wNum); + mHistRegistry->fill(HIST(MCentClasses[0]) + HIST("fResults"), 2. * static_cast(ind) + 1.5, cDenom, wDenom); + mHistRegistry->fill(HIST(MCentClasses[0]) + HIST("fCovResults"), 4. * static_cast(ind) + 0.5, cNum * cDenom, wNum * wDenom); + mHistRegistry->fill(HIST(MCentClasses[0]) + HIST("fCovResults"), 4. * static_cast(ind) + 1.5, wNum * wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[0]) + HIST("fCovResults"), 4. * static_cast(ind) + 2.5, wNum, 1.); + mHistRegistry->fill(HIST(MCentClasses[0]) + HIST("fCovResults"), 4. * static_cast(ind) + 3.5, wDenom, 1.); + } break; + case 1: { + mHistRegistry->fill(HIST(MCentClasses[1]) + HIST("fResults"), 2. * static_cast(ind) + 0.5, cNum, wNum); + mHistRegistry->fill(HIST(MCentClasses[1]) + HIST("fResults"), 2. * static_cast(ind) + 1.5, cDenom, wDenom); + mHistRegistry->fill(HIST(MCentClasses[1]) + HIST("fCovResults"), 4. * static_cast(ind) + 0.5, cNum * cDenom, wNum * wDenom); + mHistRegistry->fill(HIST(MCentClasses[1]) + HIST("fCovResults"), 4. * static_cast(ind) + 1.5, wNum * wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[1]) + HIST("fCovResults"), 4. * static_cast(ind) + 2.5, wNum, 1.); + mHistRegistry->fill(HIST(MCentClasses[1]) + HIST("fCovResults"), 4. * static_cast(ind) + 3.5, wDenom, 1.); + } break; + case 2: { + mHistRegistry->fill(HIST(MCentClasses[2]) + HIST("fResults"), 2. * static_cast(ind) + 0.5, cNum, wNum); + mHistRegistry->fill(HIST(MCentClasses[2]) + HIST("fResults"), 2. * static_cast(ind) + 1.5, cDenom, wDenom); + mHistRegistry->fill(HIST(MCentClasses[2]) + HIST("fCovResults"), 4. * static_cast(ind) + 0.5, cNum * cDenom, wNum * wDenom); + mHistRegistry->fill(HIST(MCentClasses[2]) + HIST("fCovResults"), 4. * static_cast(ind) + 1.5, wNum * wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[2]) + HIST("fCovResults"), 4. * static_cast(ind) + 2.5, wNum, 1.); + mHistRegistry->fill(HIST(MCentClasses[2]) + HIST("fCovResults"), 4. * static_cast(ind) + 3.5, wDenom, 1.); + } break; + case 3: { + mHistRegistry->fill(HIST(MCentClasses[3]) + HIST("fResults"), 2. * static_cast(ind) + 0.5, cNum, wNum); + mHistRegistry->fill(HIST(MCentClasses[3]) + HIST("fResults"), 2. * static_cast(ind) + 1.5, cDenom, wDenom); + mHistRegistry->fill(HIST(MCentClasses[3]) + HIST("fCovResults"), 4. * static_cast(ind) + 0.5, cNum * cDenom, wNum * wDenom); + mHistRegistry->fill(HIST(MCentClasses[3]) + HIST("fCovResults"), 4. * static_cast(ind) + 1.5, wNum * wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[3]) + HIST("fCovResults"), 4. * static_cast(ind) + 2.5, wNum, 1.); + mHistRegistry->fill(HIST(MCentClasses[3]) + HIST("fCovResults"), 4. * static_cast(ind) + 3.5, wDenom, 1.); + } break; + case 4: { + mHistRegistry->fill(HIST(MCentClasses[4]) + HIST("fResults"), 2. * static_cast(ind) + 0.5, cNum, wNum); + mHistRegistry->fill(HIST(MCentClasses[4]) + HIST("fResults"), 2. * static_cast(ind) + 1.5, cDenom, wDenom); + mHistRegistry->fill(HIST(MCentClasses[4]) + HIST("fCovResults"), 4. * static_cast(ind) + 0.5, cNum * cDenom, wNum * wDenom); + mHistRegistry->fill(HIST(MCentClasses[4]) + HIST("fCovResults"), 4. * static_cast(ind) + 1.5, wNum * wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[4]) + HIST("fCovResults"), 4. * static_cast(ind) + 2.5, wNum, 1.); + mHistRegistry->fill(HIST(MCentClasses[4]) + HIST("fCovResults"), 4. * static_cast(ind) + 3.5, wDenom, 1.); + } break; + case 5: { + mHistRegistry->fill(HIST(MCentClasses[5]) + HIST("fResults"), 2. * static_cast(ind) + 0.5, cNum, wNum); + mHistRegistry->fill(HIST(MCentClasses[5]) + HIST("fResults"), 2. * static_cast(ind) + 1.5, cDenom, wDenom); + mHistRegistry->fill(HIST(MCentClasses[5]) + HIST("fCovResults"), 4. * static_cast(ind) + 0.5, cNum * cDenom, wNum * wDenom); + mHistRegistry->fill(HIST(MCentClasses[5]) + HIST("fCovResults"), 4. * static_cast(ind) + 1.5, wNum * wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[5]) + HIST("fCovResults"), 4. * static_cast(ind) + 2.5, wNum, 1.); + mHistRegistry->fill(HIST(MCentClasses[5]) + HIST("fCovResults"), 4. * static_cast(ind) + 3.5, wDenom, 1.); + } break; + case 6: { + mHistRegistry->fill(HIST(MCentClasses[6]) + HIST("fResults"), 2. * static_cast(ind) + 0.5, cNum, wNum); + mHistRegistry->fill(HIST(MCentClasses[6]) + HIST("fResults"), 2. * static_cast(ind) + 1.5, cDenom, wDenom); + mHistRegistry->fill(HIST(MCentClasses[6]) + HIST("fCovResults"), 4. * static_cast(ind) + 0.5, cNum * cDenom, wNum * wDenom); + mHistRegistry->fill(HIST(MCentClasses[6]) + HIST("fCovResults"), 4. * static_cast(ind) + 1.5, wNum * wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[6]) + HIST("fCovResults"), 4. * static_cast(ind) + 2.5, wNum, 1.); + mHistRegistry->fill(HIST(MCentClasses[6]) + HIST("fCovResults"), 4. * static_cast(ind) + 3.5, wDenom, 1.); + } break; + case 7: { + mHistRegistry->fill(HIST(MCentClasses[7]) + HIST("fResults"), 2. * static_cast(ind) + 0.5, cNum, wNum); + mHistRegistry->fill(HIST(MCentClasses[7]) + HIST("fResults"), 2. * static_cast(ind) + 1.5, cDenom, wDenom); + mHistRegistry->fill(HIST(MCentClasses[7]) + HIST("fCovResults"), 4. * static_cast(ind) + 0.5, cNum * cDenom, wNum * wDenom); + mHistRegistry->fill(HIST(MCentClasses[7]) + HIST("fCovResults"), 4. * static_cast(ind) + 1.5, wNum * wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[7]) + HIST("fCovResults"), 4. * static_cast(ind) + 2.5, wNum, 1.); + mHistRegistry->fill(HIST(MCentClasses[7]) + HIST("fCovResults"), 4. * static_cast(ind) + 3.5, wDenom, 1.); + } break; + case 8: { + mHistRegistry->fill(HIST(MCentClasses[8]) + HIST("fResults"), 2. * static_cast(ind) + 0.5, cNum, wNum); + mHistRegistry->fill(HIST(MCentClasses[8]) + HIST("fResults"), 2. * static_cast(ind) + 1.5, cDenom, wDenom); + mHistRegistry->fill(HIST(MCentClasses[8]) + HIST("fCovResults"), 4. * static_cast(ind) + 0.5, cNum * cDenom, wNum * wDenom); + mHistRegistry->fill(HIST(MCentClasses[8]) + HIST("fCovResults"), 4. * static_cast(ind) + 1.5, wNum * wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[8]) + HIST("fCovResults"), 4. * static_cast(ind) + 2.5, wNum, 1.); + mHistRegistry->fill(HIST(MCentClasses[8]) + HIST("fCovResults"), 4. * static_cast(ind) + 3.5, wDenom, 1.); + } break; + default: + return; } } -void FlowJSPCAnalysis::FillHistograms(const Int_t fCentBin, Int_t ind, Double_t cNum, Double_t cDenom, Double_t wNum, Double_t wDenom) +void FlowJSPCAnalysis::fillQAHistograms(const int fCentBin, double phi, double phiWeight) { switch (fCentBin) { case 0: { - mHistRegistry->fill(HIST(mCentClasses[0]) + HIST("fResults"), 2. * (Float_t)(ind) + 0.5, cNum, wNum); - mHistRegistry->fill(HIST(mCentClasses[0]) + HIST("fResults"), 2. * (Float_t)(ind) + 1.5, cDenom, wDenom); - mHistRegistry->fill(HIST(mCentClasses[0]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 0.5, cNum * cDenom, wNum * wDenom); - mHistRegistry->fill(HIST(mCentClasses[0]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 1.5, wNum * wDenom, 1.); - mHistRegistry->fill(HIST(mCentClasses[0]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 2.5, wNum, 1.); - mHistRegistry->fill(HIST(mCentClasses[0]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 3.5, wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[0]) + HIST("phiBefore"), phi); + mHistRegistry->fill(HIST(MCentClasses[0]) + HIST("phiAfter"), phi, phiWeight); } break; case 1: { - mHistRegistry->fill(HIST(mCentClasses[1]) + HIST("fResults"), 2. * (Float_t)(ind) + 0.5, cNum, wNum); - mHistRegistry->fill(HIST(mCentClasses[1]) + HIST("fResults"), 2. * (Float_t)(ind) + 1.5, cDenom, wDenom); - mHistRegistry->fill(HIST(mCentClasses[1]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 0.5, cNum * cDenom, wNum * wDenom); - mHistRegistry->fill(HIST(mCentClasses[1]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 1.5, wNum * wDenom, 1.); - mHistRegistry->fill(HIST(mCentClasses[1]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 2.5, wNum, 1.); - mHistRegistry->fill(HIST(mCentClasses[1]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 3.5, wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[1]) + HIST("phiBefore"), phi); + mHistRegistry->fill(HIST(MCentClasses[1]) + HIST("phiAfter"), phi, phiWeight); } break; case 2: { - mHistRegistry->fill(HIST(mCentClasses[2]) + HIST("fResults"), 2. * (Float_t)(ind) + 0.5, cNum, wNum); - mHistRegistry->fill(HIST(mCentClasses[2]) + HIST("fResults"), 2. * (Float_t)(ind) + 1.5, cDenom, wDenom); - mHistRegistry->fill(HIST(mCentClasses[2]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 0.5, cNum * cDenom, wNum * wDenom); - mHistRegistry->fill(HIST(mCentClasses[2]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 1.5, wNum * wDenom, 1.); - mHistRegistry->fill(HIST(mCentClasses[2]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 2.5, wNum, 1.); - mHistRegistry->fill(HIST(mCentClasses[2]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 3.5, wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[2]) + HIST("phiBefore"), phi); + mHistRegistry->fill(HIST(MCentClasses[2]) + HIST("phiAfter"), phi, phiWeight); } break; case 3: { - mHistRegistry->fill(HIST(mCentClasses[3]) + HIST("fResults"), 2. * (Float_t)(ind) + 0.5, cNum, wNum); - mHistRegistry->fill(HIST(mCentClasses[3]) + HIST("fResults"), 2. * (Float_t)(ind) + 1.5, cDenom, wDenom); - mHistRegistry->fill(HIST(mCentClasses[3]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 0.5, cNum * cDenom, wNum * wDenom); - mHistRegistry->fill(HIST(mCentClasses[3]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 1.5, wNum * wDenom, 1.); - mHistRegistry->fill(HIST(mCentClasses[3]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 2.5, wNum, 1.); - mHistRegistry->fill(HIST(mCentClasses[3]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 3.5, wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[3]) + HIST("phiBefore"), phi); + mHistRegistry->fill(HIST(MCentClasses[3]) + HIST("phiAfter"), phi, phiWeight); } break; case 4: { - mHistRegistry->fill(HIST(mCentClasses[4]) + HIST("fResults"), 2. * (Float_t)(ind) + 0.5, cNum, wNum); - mHistRegistry->fill(HIST(mCentClasses[4]) + HIST("fResults"), 2. * (Float_t)(ind) + 1.5, cDenom, wDenom); - mHistRegistry->fill(HIST(mCentClasses[4]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 0.5, cNum * cDenom, wNum * wDenom); - mHistRegistry->fill(HIST(mCentClasses[4]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 1.5, wNum * wDenom, 1.); - mHistRegistry->fill(HIST(mCentClasses[4]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 2.5, wNum, 1.); - mHistRegistry->fill(HIST(mCentClasses[4]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 3.5, wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[4]) + HIST("phiBefore"), phi); + mHistRegistry->fill(HIST(MCentClasses[4]) + HIST("phiAfter"), phi, phiWeight); } break; case 5: { - mHistRegistry->fill(HIST(mCentClasses[5]) + HIST("fResults"), 2. * (Float_t)(ind) + 0.5, cNum, wNum); - mHistRegistry->fill(HIST(mCentClasses[5]) + HIST("fResults"), 2. * (Float_t)(ind) + 1.5, cDenom, wDenom); - mHistRegistry->fill(HIST(mCentClasses[5]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 0.5, cNum * cDenom, wNum * wDenom); - mHistRegistry->fill(HIST(mCentClasses[5]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 1.5, wNum * wDenom, 1.); - mHistRegistry->fill(HIST(mCentClasses[5]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 2.5, wNum, 1.); - mHistRegistry->fill(HIST(mCentClasses[5]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 3.5, wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[5]) + HIST("phiBefore"), phi); + mHistRegistry->fill(HIST(MCentClasses[5]) + HIST("phiAfter"), phi, phiWeight); } break; case 6: { - mHistRegistry->fill(HIST(mCentClasses[6]) + HIST("fResults"), 2. * (Float_t)(ind) + 0.5, cNum, wNum); - mHistRegistry->fill(HIST(mCentClasses[6]) + HIST("fResults"), 2. * (Float_t)(ind) + 1.5, cDenom, wDenom); - mHistRegistry->fill(HIST(mCentClasses[6]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 0.5, cNum * cDenom, wNum * wDenom); - mHistRegistry->fill(HIST(mCentClasses[6]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 1.5, wNum * wDenom, 1.); - mHistRegistry->fill(HIST(mCentClasses[6]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 2.5, wNum, 1.); - mHistRegistry->fill(HIST(mCentClasses[6]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 3.5, wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[6]) + HIST("phiBefore"), phi); + mHistRegistry->fill(HIST(MCentClasses[6]) + HIST("phiAfter"), phi, phiWeight); } break; case 7: { - mHistRegistry->fill(HIST(mCentClasses[7]) + HIST("fResults"), 2. * (Float_t)(ind) + 0.5, cNum, wNum); - mHistRegistry->fill(HIST(mCentClasses[7]) + HIST("fResults"), 2. * (Float_t)(ind) + 1.5, cDenom, wDenom); - mHistRegistry->fill(HIST(mCentClasses[7]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 0.5, cNum * cDenom, wNum * wDenom); - mHistRegistry->fill(HIST(mCentClasses[7]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 1.5, wNum * wDenom, 1.); - mHistRegistry->fill(HIST(mCentClasses[7]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 2.5, wNum, 1.); - mHistRegistry->fill(HIST(mCentClasses[7]) + HIST("fCovResults"), 2. * (Float_t)(ind) + 3.5, wDenom, 1.); + mHistRegistry->fill(HIST(MCentClasses[7]) + HIST("phiBefore"), phi); + mHistRegistry->fill(HIST(MCentClasses[7]) + HIST("phiAfter"), phi, phiWeight); + } break; + case 8: { + mHistRegistry->fill(HIST(MCentClasses[8]) + HIST("phiBefore"), phi); + mHistRegistry->fill(HIST(MCentClasses[8]) + HIST("phiAfter"), phi, phiWeight); } break; default: return; } } -void FlowJSPCAnalysis::Correlation(Int_t c_nPart, Int_t c_nHarmo, Int_t* harmo, Double_t* correlData) +void FlowJSPCAnalysis::correlation(int c_nPart, int c_nHarmo, int* harmo, double* correlData) { // Calculate the correlators for the provided set of harmonics using Q-vectors. // Protection against anisotropic correlators. - Int_t sumHarmo = 0; - for (Int_t i = 0; i < c_nHarmo; i++) { + int sumHarmo = 0; + for (int i = 0; i < c_nHarmo; i++) { sumHarmo += harmo[i]; } if (sumHarmo != 0) { - printf("\nOups, this correlator is not isotropic(sum = %d). Bye\n", sumHarmo); + LOGF(error, "\nOups, this correlator is not isotropic(sum = %d). Bye\n", sumHarmo); return; } switch (c_nPart) { case 2: { - Int_t harmonicsTwoNum[2] = {harmo[0], harmo[1]}; - Int_t harmonicsTwoDen[2] = {0, 0}; + int harmonicsTwoNum[2] = {harmo[0], harmo[1]}; + int harmonicsTwoDen[2] = {0, 0}; if (!fCorrelDenoms[1]) { - fCorrelDenoms[1] = Recursion(2, harmonicsTwoDen).Re(); + fCorrelDenoms[1] = recursion(2, harmonicsTwoDen).Re(); } - TComplex twoRecursion = Recursion(2, harmonicsTwoNum) / fCorrelDenoms[1]; + TComplex twoRecursion = recursion(2, harmonicsTwoNum) / fCorrelDenoms[1]; correlData[0] = twoRecursion.Re(); // correlData[1] = fCorrelDenoms[1]; // weight correlData[2] = twoRecursion.Im(); // } break; case 3: { - Int_t harmonicsThreeNum[3] = {harmo[0], harmo[1], harmo[2]}; - Int_t harmonicsThreeDen[3] = {0, 0, 0}; + int harmonicsThreeNum[3] = {harmo[0], harmo[1], harmo[2]}; + int harmonicsThreeDen[3] = {0, 0, 0}; if (!fCorrelDenoms[2]) { - fCorrelDenoms[2] = Recursion(3, harmonicsThreeDen).Re(); + fCorrelDenoms[2] = recursion(3, harmonicsThreeDen).Re(); } - TComplex threeRecursion = Recursion(3, harmonicsThreeNum) / fCorrelDenoms[2]; + TComplex threeRecursion = recursion(3, harmonicsThreeNum) / fCorrelDenoms[2]; correlData[0] = threeRecursion.Re(); // correlData[1] = fCorrelDenoms[2]; // weight correlData[2] = threeRecursion.Im(); // } break; case 4: { - Int_t harmonicsFourNum[4] = {harmo[0], harmo[1], harmo[2], harmo[3]}; - Int_t harmonicsFourDen[4] = {0, 0, 0, 0}; + int harmonicsFourNum[4] = {harmo[0], harmo[1], harmo[2], harmo[3]}; + int harmonicsFourDen[4] = {0, 0, 0, 0}; if (!fCorrelDenoms[3]) { - fCorrelDenoms[3] = Recursion(4, harmonicsFourDen).Re(); + fCorrelDenoms[3] = recursion(4, harmonicsFourDen).Re(); } - TComplex fourRecursion = Recursion(4, harmonicsFourNum) / fCorrelDenoms[3]; + TComplex fourRecursion = recursion(4, harmonicsFourNum) / fCorrelDenoms[3]; correlData[0] = fourRecursion.Re(); // correlData[1] = fCorrelDenoms[3]; // weight correlData[2] = fourRecursion.Im(); // } break; case 5: { - Int_t harmonicsFiveNum[5] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4]}; - Int_t harmonicsFiveDen[5] = {0, 0, 0, 0, 0}; + int harmonicsFiveNum[5] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4]}; + int harmonicsFiveDen[5] = {0, 0, 0, 0, 0}; if (!fCorrelDenoms[4]) { - fCorrelDenoms[4] = Recursion(5, harmonicsFiveDen).Re(); + fCorrelDenoms[4] = recursion(5, harmonicsFiveDen).Re(); } - TComplex fiveRecursion = Recursion(5, harmonicsFiveNum) / fCorrelDenoms[4]; + TComplex fiveRecursion = recursion(5, harmonicsFiveNum) / fCorrelDenoms[4]; correlData[0] = fiveRecursion.Re(); // correlData[1] = fCorrelDenoms[4]; // weight correlData[2] = fiveRecursion.Im(); // } break; case 6: { - Int_t harmonicsSixNum[6] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], harmo[5]}; - Int_t harmonicsSixDen[6] = {0, 0, 0, 0, 0, 0}; + int harmonicsSixNum[6] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], harmo[5]}; + int harmonicsSixDen[6] = {0, 0, 0, 0, 0, 0}; if (!fCorrelDenoms[5]) { - fCorrelDenoms[5] = Recursion(6, harmonicsSixDen).Re(); + fCorrelDenoms[5] = recursion(6, harmonicsSixDen).Re(); } - TComplex sixRecursion = Recursion(6, harmonicsSixNum) / fCorrelDenoms[5]; + TComplex sixRecursion = recursion(6, harmonicsSixNum) / fCorrelDenoms[5]; correlData[0] = sixRecursion.Re(); // correlData[1] = fCorrelDenoms[5]; // weight correlData[2] = sixRecursion.Im(); // } break; case 7: { - Int_t harmonicsSevenNum[7] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], harmo[5], harmo[6]}; - Int_t harmonicsSevenDen[7] = {0, 0, 0, 0, 0, 0, 0}; + int harmonicsSevenNum[7] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], harmo[5], harmo[6]}; + int harmonicsSevenDen[7] = {0, 0, 0, 0, 0, 0, 0}; if (!fCorrelDenoms[6]) { - fCorrelDenoms[6] = Recursion(7, harmonicsSevenDen).Re(); + fCorrelDenoms[6] = recursion(7, harmonicsSevenDen).Re(); } - TComplex sevenRecursion = Recursion(7, harmonicsSevenNum) / fCorrelDenoms[6]; + TComplex sevenRecursion = recursion(7, harmonicsSevenNum) / fCorrelDenoms[6]; correlData[0] = sevenRecursion.Re(); // correlData[1] = fCorrelDenoms[6]; // weight correlData[2] = sevenRecursion.Im(); // } break; case 8: { - Int_t harmonicsEightNum[8] = {harmo[0], harmo[1], harmo[2], harmo[3], - harmo[4], harmo[5], harmo[6], harmo[7]}; - Int_t harmonicsEightDen[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + int harmonicsEightNum[8] = {harmo[0], harmo[1], harmo[2], harmo[3], + harmo[4], harmo[5], harmo[6], harmo[7]}; + int harmonicsEightDen[8] = {0, 0, 0, 0, 0, 0, 0, 0}; if (!fCorrelDenoms[7]) { - fCorrelDenoms[7] = Recursion(8, harmonicsEightDen).Re(); + fCorrelDenoms[7] = recursion(8, harmonicsEightDen).Re(); } - TComplex eightRecursion = Recursion(8, harmonicsEightNum) / fCorrelDenoms[7]; + TComplex eightRecursion = recursion(8, harmonicsEightNum) / fCorrelDenoms[7]; correlData[0] = eightRecursion.Re(); // correlData[1] = fCorrelDenoms[7]; // weight correlData[2] = eightRecursion.Im(); // } break; case 9: { - Int_t harmonicsNineNum[9] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], - harmo[5], harmo[6], harmo[7], harmo[8]}; - Int_t harmonicsNineDen[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + int harmonicsNineNum[9] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], + harmo[5], harmo[6], harmo[7], harmo[8]}; + int harmonicsNineDen[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; if (!fCorrelDenoms[8]) { - fCorrelDenoms[8] = Recursion(9, harmonicsNineDen).Re(); + fCorrelDenoms[8] = recursion(9, harmonicsNineDen).Re(); } - TComplex nineRecursion = Recursion(9, harmonicsNineNum) / fCorrelDenoms[8]; + TComplex nineRecursion = recursion(9, harmonicsNineNum) / fCorrelDenoms[8]; correlData[0] = nineRecursion.Re(); correlData[1] = fCorrelDenoms[8]; correlData[2] = nineRecursion.Im(); } break; case 10: { - Int_t harmonicsTenNum[10] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], - harmo[5], harmo[6], harmo[7], harmo[8], harmo[9]}; - Int_t harmonicsTenDen[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int harmonicsTenNum[10] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], + harmo[5], harmo[6], harmo[7], harmo[8], harmo[9]}; + int harmonicsTenDen[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; if (!fCorrelDenoms[9]) { - fCorrelDenoms[9] = Recursion(10, harmonicsTenDen).Re(); + fCorrelDenoms[9] = recursion(10, harmonicsTenDen).Re(); } - TComplex tenRecursion = Recursion(10, harmonicsTenNum) / fCorrelDenoms[9]; + TComplex tenRecursion = recursion(10, harmonicsTenNum) / fCorrelDenoms[9]; correlData[0] = tenRecursion.Re(); correlData[1] = fCorrelDenoms[9]; correlData[2] = tenRecursion.Im(); } break; case 12: { - Int_t harmonicsTwelveNum[12] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], harmo[5], - harmo[6], harmo[7], harmo[8], harmo[9], harmo[10], harmo[11]}; - Int_t harmonicsTwelveDen[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int harmonicsTwelveNum[12] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], harmo[5], + harmo[6], harmo[7], harmo[8], harmo[9], harmo[10], harmo[11]}; + int harmonicsTwelveDen[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; if (!fCorrelDenoms[11]) { - fCorrelDenoms[11] = Recursion(12, harmonicsTwelveDen).Re(); + fCorrelDenoms[11] = recursion(12, harmonicsTwelveDen).Re(); } - TComplex twelveRecursion = Recursion(12, harmonicsTwelveNum) / fCorrelDenoms[11]; + TComplex twelveRecursion = recursion(12, harmonicsTwelveNum) / fCorrelDenoms[11]; correlData[0] = twelveRecursion.Re(); correlData[1] = fCorrelDenoms[11]; correlData[2] = twelveRecursion.Im(); } break; case 14: { - Int_t harmonicsFourteenNum[14] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], harmo[5], harmo[6], - harmo[7], harmo[8], harmo[9], harmo[10], harmo[11], harmo[12], harmo[13]}; - Int_t harmonicsFourteenDen[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int harmonicsFourteenNum[14] = {harmo[0], harmo[1], harmo[2], harmo[3], harmo[4], harmo[5], harmo[6], + harmo[7], harmo[8], harmo[9], harmo[10], harmo[11], harmo[12], harmo[13]}; + int harmonicsFourteenDen[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; if (!fCorrelDenoms[13]) { - fCorrelDenoms[13] = Recursion(14, harmonicsFourteenDen).Re(); + fCorrelDenoms[13] = recursion(14, harmonicsFourteenDen).Re(); } - TComplex fourteenRecursion = Recursion(14, harmonicsFourteenNum) / fCorrelDenoms[13]; + TComplex fourteenRecursion = recursion(14, harmonicsFourteenNum) / fCorrelDenoms[13]; correlData[0] = fourteenRecursion.Re(); correlData[1] = fCorrelDenoms[13]; @@ -367,7 +425,7 @@ void FlowJSPCAnalysis::Correlation(Int_t c_nPart, Int_t c_nHarmo, Int_t* harmo, } break; } } -int FlowJSPCAnalysis::GetCentBin(float cValue) +int FlowJSPCAnalysis::getCentBin(float cValue) { const float centClasses[] = {0., 1., 2., 5., 10., 20., 30., 40., 50., 60., 70.}; for (int i = 0; i < 8; i++) { diff --git a/PWGCF/JCorran/Core/FlowJSPCAnalysis.h b/PWGCF/JCorran/Core/FlowJSPCAnalysis.h index 656e54c8453..ba584d1e1eb 100644 --- a/PWGCF/JCorran/Core/FlowJSPCAnalysis.h +++ b/PWGCF/JCorran/Core/FlowJSPCAnalysis.h @@ -16,7 +16,6 @@ #define PWGCF_JCORRAN_CORE_FLOWJSPCANALYSIS_H_ /* Header files. */ -#include #include #include #include @@ -25,64 +24,54 @@ // O2 headers. // #include "Framework/HistogramRegistry.h" #include "PWGCF/JCorran/Core/JQVectors.h" - -using namespace o2; -using namespace o2::framework; -using namespace std; +#include "CommonConstants/MathConstants.h" class FlowJSPCAnalysis { public: FlowJSPCAnalysis() = default; - void SetHistRegistry(HistogramRegistry* histReg) { mHistRegistry = histReg; } - Int_t GetCentBin(float cValue); + void setHistRegistry(o2::framework::HistogramRegistry* histReg) { mHistRegistry = histReg; } + int getCentBin(float cValue); using JQVectorsT = JQVectors; - inline void SetQvectors(const JQVectorsT* _qvecs) { qvecs = _qvecs; } - void Correlation(Int_t c_nPart, Int_t c_nHarmo, Int_t* harmo, Double_t* correlData); - void CalculateCorrelators(const Int_t fCentBin); - void FillHistograms(const Int_t fCentBin, Int_t ind, Double_t cNum, Double_t cDenom, Double_t wNum, Double_t wDenom); - TComplex Recursion(int n, int* harmonic, int mult, int skip); - TComplex Q(const Int_t harmN, const Int_t p); - - void CreateHistos() + inline void setQvectors(const JQVectorsT* _qvecs) { qvecs = _qvecs; } + void correlation(int c_nPart, int c_nHarmo, int* harmo, double* correlData); + void calculateCorrelators(const int fCentBin); + void fillHistograms(const int fCentBin, int ind, double cNum, double cDenom, double wNum, double wDenom); + void fillQAHistograms(const int fCentBin, double phi, double phiWeight); + TComplex recursion(int n, int* harmonic, int mult, int skip); + TComplex q(const int harmN, const int p); + + void createHistos() { if (!mHistRegistry) { LOGF(error, "QA histogram registry missing. Quitting..."); return; } - mHistRegistry->add("FullCentrality", "FullCentrality", HistType::kTH1D, {{100, 0., 100.}}, true); - mHistRegistry->add("Centrality_0/fResults", "Numerators and denominators", {HistType::kTProfile, {{24, 0., 24.}}}, true); - mHistRegistry->add("Centrality_0/fCovResults", "Covariance N*D", {HistType::kTProfile, {{48, 0., 48.}}}, true); + mHistRegistry->add("FullCentrality", "FullCentrality", o2::framework::HistType::kTH1D, {{100, 0., 100.}}, true); + mHistRegistry->add("Centrality_0/fResults", "Numerators and denominators", {o2::framework::HistType::kTProfile, {{24, 0., 24.}}}, true); + mHistRegistry->add("Centrality_0/fCovResults", "Covariance N*D", {o2::framework::HistType::kTProfile, {{48, 0., 48.}}}, true); + mHistRegistry->add("Centrality_0/phiBefore", "Phi before", {o2::framework::HistType::kTH1D, {{100, 0., o2::constants::math::TwoPI}}}, true); + mHistRegistry->add("Centrality_0/phiAfter", "Phi after", {o2::framework::HistType::kTH1D, {{100, 0., o2::constants::math::TwoPI}}}, true); - for (UInt_t i = 1; i < 8; i++) { + for (uint i = 1; i < 9; i++) { mHistRegistry->addClone("Centrality_0/", Form("Centrality_%u/", i)); } } - void SetCorrSet(Int_t obsInd, Int_t harmo[8]) + void setCorrSet(int obsInd, int harmo[8]) { for (int i = 0; i < 8; i++) { fHarmosArray[obsInd][i] = harmo[i]; } } - void SetFullCorrSet(Int_t harmo[12][8]) + void setFullCorrSet(int harmo[12][8]) { - memcpy(fHarmosArray, harmo, sizeof(Int_t) * 12 * 8); + memcpy(fHarmosArray, harmo, sizeof(int) * 12 * 8); } - private: - const Int_t mNqHarmos = 113; ///< Highest harmo for Q(n,p): (v8*14part)+1. - const Int_t mNqPowers = 15; ///< Max power for Q(n,p): 14part+1. - const JQVectorsT* qvecs; - - HistogramRegistry* mHistRegistry = nullptr; - - Int_t fHarmosArray[12][8]; - - Double_t fCorrelDenoms[14]; - static constexpr std::string_view mCentClasses[] = { + static constexpr std::string_view MCentClasses[] = { "Centrality_0/", "Centrality_1/", "Centrality_2/", @@ -91,8 +80,18 @@ class FlowJSPCAnalysis "Centrality_5/", "Centrality_6/", "Centrality_7/", - "Centrality_8/", - "Centrality_9/"}; + "Centrality_8/"}; + + private: + const int mNqHarmos = 113; ///< Highest harmo for Q(n,p): (v8*14part)+1. + const int mNqPowers = 15; ///< Max power for Q(n,p): 14part+1. + const JQVectorsT* qvecs; + + o2::framework::HistogramRegistry* mHistRegistry = nullptr; + + int fHarmosArray[12][8]; + + double fCorrelDenoms[14]; ClassDefNV(FlowJSPCAnalysis, 1); }; diff --git a/PWGCF/JCorran/Core/FlowJSPCObservables.h b/PWGCF/JCorran/Core/FlowJSPCObservables.h index 5bf46f8aec2..bc504fe31fe 100644 --- a/PWGCF/JCorran/Core/FlowJSPCObservables.h +++ b/PWGCF/JCorran/Core/FlowJSPCObservables.h @@ -18,27 +18,23 @@ // O2 headers. // #include "Framework/HistogramRegistry.h" -using namespace o2; -using namespace o2::framework; -using namespace std; - const int maxNrComb = 12; class FlowJSPCObservables { public: FlowJSPCObservables() = default; - Int_t harmonicArray[maxNrComb][8] = {{0}}; + int harmonicArray[maxNrComb][8] = {{0}}; - void SetSPCObservables(Int_t index) + void setSPCObservables(int index) { - // Int_t *harmonicArray = (Int_t*)malloc(sizeof(Int_t)*maxNrComb*8); + // int *harmonicArray = (int*)malloc(sizeof(int)*maxNrComb*8); // Switch to set up correct symmetry plane combinations switch (index) { case 0: { LOGF(info, "Computing three harmonic SPC"); - Int_t harmonicArray01[maxNrComb][8] = { + int harmonicArray01[maxNrComb][8] = { {3, 6, -3, -3, 0, 0, 0, 0}, {3, 4, -2, -2, 0, 0, 0, 0}, {3, 8, -4, -4, 0, 0, 0, 0}, @@ -52,11 +48,11 @@ class FlowJSPCObservables {0, 2, -3, -3, 4, 0, 0, 0}, {0, 3, 3, -2, -2, -2, 0, 0}}; - memcpy(harmonicArray, harmonicArray01, sizeof(Int_t) * maxNrComb * 8); + memcpy(harmonicArray, harmonicArray01, sizeof(int) * maxNrComb * 8); } break; case 1: { LOGF(info, "Computing four harmonic SPC"); - Int_t harmonicArray02[maxNrComb][8] = { + int harmonicArray02[maxNrComb][8] = { {4, 6, -2, -2, -2, 0, 0, 0}, {4, 2, -3, -4, 5, 0, 0, 0}, {4, 2, -3, -3, 4, 0, 0, 0}, @@ -69,11 +65,11 @@ class FlowJSPCObservables {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}}; - memcpy(harmonicArray, harmonicArray02, sizeof(Int_t) * maxNrComb * 8); + memcpy(harmonicArray, harmonicArray02, sizeof(int) * maxNrComb * 8); } break; case 3: { LOGF(info, "Computing five and six harmonic SPC"); - Int_t harmonicArray03[maxNrComb][8] = { + int harmonicArray03[maxNrComb][8] = { {5, 3, 3, -2, -2, -2, 0, 0}, {5, 2, 2, -3, 4, -5, 0, 0}, {5, 2, 3, 3, -4, -4, 0, 0}, @@ -86,11 +82,10 @@ class FlowJSPCObservables {6, 2, 2, 2, 3, -4, -5, 0}, {6, 2, 2, 3, 3, -4, -6, 0}, {0, 0, 0, 0, 0, 0, 0, 0}}; - memcpy(harmonicArray, harmonicArray03, sizeof(Int_t) * maxNrComb * 8); + memcpy(harmonicArray, harmonicArray03, sizeof(int) * maxNrComb * 8); } break; default: - std::cout << "ERROR: Invalid configuration index. Skipping this element." - << std::endl; + LOGF(error, "ERROR: Invalid configuration index. Skipping this element."); } } diff --git a/PWGCF/JCorran/Core/JFFlucAnalysis.cxx b/PWGCF/JCorran/Core/JFFlucAnalysis.cxx index c3ca3595718..9dc4189a810 100644 --- a/PWGCF/JCorran/Core/JFFlucAnalysis.cxx +++ b/PWGCF/JCorran/Core/JFFlucAnalysis.cxx @@ -19,6 +19,7 @@ JFFlucAnalysis::JFFlucAnalysis() : TNamed(), fVertex(0), + fAvgInvariantMass(0.0f), fCent(0), fImpactParameter(-1), subeventMask(kSubEvent_A | kSubEvent_B), @@ -32,6 +33,7 @@ JFFlucAnalysis::JFFlucAnalysis() : TNamed(), //________________________________________________________________________ JFFlucAnalysis::JFFlucAnalysis(const char* /*name*/) : TNamed(), fVertex(0), + fAvgInvariantMass(0.0f), fCent(0), fImpactParameter(-1), subeventMask(kSubEvent_A | kSubEvent_B), @@ -45,6 +47,7 @@ JFFlucAnalysis::JFFlucAnalysis(const char* /*name*/) : TNamed(), //________________________________________________________________________ JFFlucAnalysis::JFFlucAnalysis(const JFFlucAnalysis& a) : TNamed(a), fVertex(a.fVertex), + fAvgInvariantMass(a.fAvgInvariantMass), fCent(a.fCent), fImpactParameter(a.fImpactParameter), subeventMask(a.subeventMask), @@ -113,6 +116,13 @@ TComplex JFFlucAnalysis::Q(int n, int p) return n >= 0 ? pqvecs->QvectorQC[n][p] : C(pqvecs->QvectorQC[-n][p]); } +TComplex JFFlucAnalysis::Q(const JQVectorsT& qvecs, int n, int p) +{ + // Return QvectorQC + // Q{-n, p} = Q{n, p}* + return n >= 0 ? qvecs.QvectorQC[n][p] : C(qvecs.QvectorQC[-n][p]); +} + TComplex JFFlucAnalysis::Two(int n1, int n2) { // two-particle correlation @@ -121,9 +131,26 @@ TComplex JFFlucAnalysis::Two(int n1, int n2) TComplex JFFlucAnalysis::Four(int n1, int n2, int n3, int n4) { - return Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) - Q(n1 + n2, 2) * Q(n3, 1) * Q(n4, 1) - Q(n2, 1) * Q(n1 + n3, 2) * Q(n4, 1) - Q(n1, 1) * Q(n2 + n3, 2) * Q(n4, 1) + 2. * Q(n1 + n2 + n3, 3) * Q(n4, 1) - Q(n2, 1) * Q(n3, 1) * Q(n1 + n4, 2) + Q(n2 + n3, 2) * Q(n1 + n4, 2) - Q(n1, 1) * Q(n3, 1) * Q(n2 + n4, 2) + Q(n1 + n3, 2) * Q(n2 + n4, 2) + 2. * Q(n3, 1) * Q(n1 + n2 + n4, 3) - Q(n1, 1) * Q(n2, 1) * Q(n3 + n4, 2) + Q(n1 + n2, 2) * Q(n3 + n4, 2) + 2. * Q(n2, 1) * Q(n1 + n3 + n4, 3) + 2. * Q(n1, 1) * Q(n2 + n3 + n4, 3) - 6. * Q(n1 + n2 + n3 + n4, 4); } + +TComplex JFFlucAnalysis::TwoDiff(int n1, int n2) +{ +#define dp(n, p) Q(*pqvecs, n, p) // POI +#define dQ(n, p) Q(*pqvecsRef, n, p) // REF +#define dq(n, p) dp(n, p) //(dp(n,p)+dQ(n,p)) //POI+REF in narrow bin. Since there is no mass for ref, q = POI + // #define dq(n,p) (dp(n,p)+dQ(n,p)) //POI+REF in narrow bin. Since there is no mass for ref, q = POI + return dp(n1, 1) * dQ(n2, 1) - dq(n1 + n2, 2); +} + +TComplex JFFlucAnalysis::FourDiff(int n1, int n2, int n3, int n4) +{ + return dp(n1, 1) * dQ(n2, 1) * dQ(n3, 1) * dQ(n4, 1) - dq(n1 + n2, 2) * dQ(n3, 1) * dQ(n4, 1) - dq(n1 + n3, 2) * dQ(n2, 1) * dQ(n4, 1) - dp(n1, 1) * dQ(n2 + n3, 2) * dQ(n4, 1) + 2. * dq(n1 + n2 + n3, 3) * dQ(n4, 1) - dQ(n2, 1) * dQ(n3, 1) * dq(n1 + n4, 2) + dQ(n2 + n3, 2) * dq(n1 + n4, 2) - dp(n1, 1) * dQ(n3, 1) * dQ(n2 + n4, 2) + dq(n1 + n3, 2) * dQ(n2 + n4, 2) + 2. * dQ(n3, 1) * dq(n1 + n2 + n4, 3) - dp(n1, 1) * dQ(n2, 1) * dQ(n3 + n4, 2) + dq(n1 + n2, 2) * dQ(n3 + n4, 2) + 2. * dQ(n2, 1) * dq(n1 + n3 + n4, 3) + 2. * dp(n1, 1) * dQ(n2 + n3 + n4, 3) - 6. * dq(n1 + n2 + n3 + n4, 4); +} + +#undef dp +#undef dQ +#undef dq #undef C //________________________________________________________________________ @@ -136,7 +163,7 @@ void JFFlucAnalysis::UserExec(Option_t* /*popt*/) // NOLINT(readability/casting) for (UInt_t i = 0; i < 2; ++i) { if ((subeventMask & (1 << i)) == 0) continue; - decltype(pqvecs->QvectorQCgap[i])& Qa = pqvecs->QvectorQCgap[i]; + decltype(pqvecs->QvectorQCgap[i])& Qa = pqvecs->QvectorQCgap[i]; // this is for one differential bin only. decltype(pqvecs->QvectorQCgap[1 - i])& Qb = (pqvecsRef ? pqvecsRef : pqvecs)->QvectorQCgap[1 - i]; // A & B subevents from POI and REF, when given Double_t ref_2p = TwoGap(Qa, Qb, 0, 0).Re(); Double_t ref_3p = ThreeGap(Qa, Qb, 0, 0, 0).Re(); @@ -203,11 +230,11 @@ void JFFlucAnalysis::UserExec(Option_t* /*popt*/) // NOLINT(readability/casting) // vn2[ih][ik] = corr[ih][ik].Re() / ref_2Np[ik - 1]; // fh_vn[ih][ik][fCBin]->Fill(vn2[ih][ik], ebe_2Np_weight[ik - 1]); // fh_vna[ih][ik][fCBin]->Fill(ncorr[ih][ik].Re() / ref_2Np[ik - 1], ebe_2Np_weight[ik - 1]); - phs[HIST_THN_SPARSE_VN]->Fill(fCent, ih, ik, ncorr[ih][ik].Re() / ref_2Np[ik - 1], ebe_2Np_weight[ik - 1]); + phs[HIST_THN_SPARSE_VN]->Fill(fCent, fAvgInvariantMass, ih, ik, ncorr[ih][ik].Re() / ref_2Np[ik - 1], ebe_2Np_weight[ik - 1]); for (UInt_t ihh = 2; ihh < kcNH; ihh++) { for (UInt_t ikk = 1; ikk < nKL; ikk++) { Double_t vn2_vn2 = ncorr2[ih][ik][ihh][ikk] / ref_2Np[ik + ikk - 1]; - phs[HIST_THN_SPARSE_VN_VN]->Fill(fCent, ih, ik, ihh, ikk, vn2_vn2, ebe_2Np_weight[ik + ikk - 1]); + phs[HIST_THN_SPARSE_VN_VN]->Fill(fCent, fAvgInvariantMass, ih, ik, ihh, ikk, vn2_vn2, ebe_2Np_weight[ik + ikk - 1]); } } } @@ -246,41 +273,41 @@ void JFFlucAnalysis::UserExec(Option_t* /*popt*/) // NOLINT(readability/casting) TComplex nV5V5V3V3 = FourGap22(Qa, Qb, 5, 3, 5, 3) / ref_4p; TComplex nV4V4V3V3 = FourGap22(Qa, Qb, 4, 3, 4, 3) / ref_4p; - pht[HIST_THN_V4V2starv2_2]->Fill(fCent, V4V2starv2_2.Re()); - pht[HIST_THN_V4V2starv2_4]->Fill(fCent, V4V2starv2_4.Re()); - pht[HIST_THN_V4V2star_2]->Fill(fCent, V4V2star_2.Re(), ebe_3p_weight); // added 2015.3.18 - pht[HIST_THN_V5V2starV3starv2_2]->Fill(fCent, V5V2starV3starv2_2.Re()); - pht[HIST_THN_V5V2starV3star]->Fill(fCent, V5V2starV3star.Re(), ebe_3p_weight); - pht[HIST_THN_V5V2starV3startv3_2]->Fill(fCent, V5V2starV3startv3_2.Re()); - pht[HIST_THN_V6V2star_3]->Fill(fCent, V6V2star_3.Re(), ebe_4p_weightB); - pht[HIST_THN_V6V3star_2]->Fill(fCent, V6V3star_2.Re(), ebe_3p_weight); - pht[HIST_THN_V7V2star_2V3star]->Fill(fCent, V7V2star_2V3star.Re(), ebe_4p_weightB); + pht[HIST_THN_V4V2starv2_2]->Fill(fCent, fAvgInvariantMass, V4V2starv2_2.Re()); + pht[HIST_THN_V4V2starv2_4]->Fill(fCent, fAvgInvariantMass, V4V2starv2_4.Re()); + pht[HIST_THN_V4V2star_2]->Fill(fCent, fAvgInvariantMass, V4V2star_2.Re(), ebe_3p_weight); // added 2015.3.18 + pht[HIST_THN_V5V2starV3starv2_2]->Fill(fCent, fAvgInvariantMass, V5V2starV3starv2_2.Re()); + pht[HIST_THN_V5V2starV3star]->Fill(fCent, fAvgInvariantMass, V5V2starV3star.Re(), ebe_3p_weight); + pht[HIST_THN_V5V2starV3startv3_2]->Fill(fCent, fAvgInvariantMass, V5V2starV3startv3_2.Re()); + pht[HIST_THN_V6V2star_3]->Fill(fCent, fAvgInvariantMass, V6V2star_3.Re(), ebe_4p_weightB); + pht[HIST_THN_V6V3star_2]->Fill(fCent, fAvgInvariantMass, V6V3star_2.Re(), ebe_3p_weight); + pht[HIST_THN_V7V2star_2V3star]->Fill(fCent, fAvgInvariantMass, V7V2star_2V3star.Re(), ebe_4p_weightB); - pht[HIST_THN_V4V2star_2]->Fill(fCent, nV4V2star_2.Re(), ebe_3p_weight); // added 2015.6.10 - pht[HIST_THN_V5V2starV3star]->Fill(fCent, nV5V2starV3star.Re(), ebe_3p_weight); - pht[HIST_THN_V6V3star_2]->Fill(fCent, nV6V3star_2.Re(), ebe_3p_weight); + pht[HIST_THN_V4V2star_2]->Fill(fCent, fAvgInvariantMass, nV4V2star_2.Re(), ebe_3p_weight); // added 2015.6.10 + pht[HIST_THN_V5V2starV3star]->Fill(fCent, fAvgInvariantMass, nV5V2starV3star.Re(), ebe_3p_weight); + pht[HIST_THN_V6V3star_2]->Fill(fCent, fAvgInvariantMass, nV6V3star_2.Re(), ebe_3p_weight); // use this to avoid self-correlation 4p correlation (2 particles from A, 2 particles from B) -> MA(MA-1)MB(MB-1) : evt weight.. - pht[HIST_THN_nV4V4V2V2]->Fill(fCent, nV4V4V2V2.Re(), ebe_2Np_weight[1]); - pht[HIST_THN_nV3V3V2V2]->Fill(fCent, nV3V3V2V2.Re(), ebe_2Np_weight[1]); + pht[HIST_THN_nV4V4V2V2]->Fill(fCent, fAvgInvariantMass, nV4V4V2V2.Re(), ebe_2Np_weight[1]); + pht[HIST_THN_nV3V3V2V2]->Fill(fCent, fAvgInvariantMass, nV3V3V2V2.Re(), ebe_2Np_weight[1]); - pht[HIST_THN_nV5V5V2V2]->Fill(fCent, nV5V5V2V2.Re(), ebe_2Np_weight[1]); - pht[HIST_THN_nV5V5V3V3]->Fill(fCent, nV5V5V3V3.Re(), ebe_2Np_weight[1]); - pht[HIST_THN_nV4V4V3V3]->Fill(fCent, nV4V4V3V3.Re(), ebe_2Np_weight[1]); + pht[HIST_THN_nV5V5V2V2]->Fill(fCent, fAvgInvariantMass, nV5V5V2V2.Re(), ebe_2Np_weight[1]); + pht[HIST_THN_nV5V5V3V3]->Fill(fCent, fAvgInvariantMass, nV5V5V3V3.Re(), ebe_2Np_weight[1]); + pht[HIST_THN_nV4V4V3V3]->Fill(fCent, fAvgInvariantMass, nV4V4V3V3.Re(), ebe_2Np_weight[1]); // higher order correlators, added 2017.8.10 - pht[HIST_THN_V8V2starV3star_2]->Fill(fCent, V8V2starV3star_2.Re(), ebe_4p_weightB); - pht[HIST_THN_V8V2star_4]->Fill(fCent, V8V2star_4.Re()); // 5p weight - pht[HIST_THN_V6V2star_3]->Fill(fCent, nV6V2star_3.Re(), ebe_4p_weightB); - pht[HIST_THN_V7V2star_2V3star]->Fill(fCent, nV7V2star_2V3star.Re(), ebe_4p_weightB); - pht[HIST_THN_V8V2starV3star_2]->Fill(fCent, nV8V2starV3star_2.Re(), ebe_4p_weightB); - - pht[HIST_THN_V6V2starV4star]->Fill(fCent, V6V2starV4star.Re(), ebe_3p_weight); - pht[HIST_THN_V7V2starV5star]->Fill(fCent, V7V2starV5star.Re(), ebe_3p_weight); - pht[HIST_THN_V7V3starV4star]->Fill(fCent, V7V3starV4star.Re(), ebe_3p_weight); - pht[HIST_THN_V6V2starV4star]->Fill(fCent, nV6V2starV4star.Re(), ebe_3p_weight); - pht[HIST_THN_V7V2starV5star]->Fill(fCent, nV7V2starV5star.Re(), ebe_3p_weight); - pht[HIST_THN_V7V3starV4star]->Fill(fCent, nV7V3starV4star.Re(), ebe_3p_weight); + pht[HIST_THN_V8V2starV3star_2]->Fill(fCent, fAvgInvariantMass, V8V2starV3star_2.Re(), ebe_4p_weightB); + pht[HIST_THN_V8V2star_4]->Fill(fCent, fAvgInvariantMass, V8V2star_4.Re()); // 5p weight + pht[HIST_THN_V6V2star_3]->Fill(fCent, fAvgInvariantMass, nV6V2star_3.Re(), ebe_4p_weightB); + pht[HIST_THN_V7V2star_2V3star]->Fill(fCent, fAvgInvariantMass, nV7V2star_2V3star.Re(), ebe_4p_weightB); + pht[HIST_THN_V8V2starV3star_2]->Fill(fCent, fAvgInvariantMass, nV8V2starV3star_2.Re(), ebe_4p_weightB); + + pht[HIST_THN_V6V2starV4star]->Fill(fCent, fAvgInvariantMass, V6V2starV4star.Re(), ebe_3p_weight); + pht[HIST_THN_V7V2starV5star]->Fill(fCent, fAvgInvariantMass, V7V2starV5star.Re(), ebe_3p_weight); + pht[HIST_THN_V7V3starV4star]->Fill(fCent, fAvgInvariantMass, V7V3starV4star.Re(), ebe_3p_weight); + pht[HIST_THN_V6V2starV4star]->Fill(fCent, fAvgInvariantMass, nV6V2starV4star.Re(), ebe_3p_weight); + pht[HIST_THN_V7V2starV5star]->Fill(fCent, fAvgInvariantMass, nV7V2starV5star.Re(), ebe_3p_weight); + pht[HIST_THN_V7V3starV4star]->Fill(fCent, fAvgInvariantMass, nV7V3starV4star.Re(), ebe_3p_weight); Double_t event_weight_two_gap = 1.0; if (flags & kFlucEbEWeighting) { @@ -289,24 +316,26 @@ void JFFlucAnalysis::UserExec(Option_t* /*popt*/) // NOLINT(readability/casting) for (UInt_t ih = 2; ih < kNH; ih++) { TComplex sctwoGap = (Qa[ih][1] * TComplex::Conjugate(Qb[ih][1])) / (Qa[0][1] * Qb[0][1]).Re(); - pht[HIST_THN_SC_with_QC_2corr_gap]->Fill(fCent, ih, sctwoGap.Re(), event_weight_two_gap); + pht[HIST_THN_SC_with_QC_2corr_gap]->Fill(fCent, fAvgInvariantMass, ih, sctwoGap.Re(), event_weight_two_gap); } } + auto four = [&](int a, int b, int c, int d) -> TComplex { return pqvecsRef ? FourDiff(a, b, c, d) : Four(a, b, c, d); }; + auto two = [&](int a, int b) -> TComplex { return pqvecsRef ? TwoDiff(a, b) : Two(a, b); }; Double_t event_weight_four = 1.0; Double_t event_weight_two = 1.0; if (flags & kFlucEbEWeighting) { - event_weight_four = Four(0, 0, 0, 0).Re(); - event_weight_two = Two(0, 0).Re(); + event_weight_four = four(0, 0, 0, 0).Re(); + event_weight_two = two(0, 0).Re(); } for (UInt_t ih = 2; ih < kNH; ih++) { for (UInt_t ihh = 2, mm = (ih < kcNH ? ih : static_cast(kcNH)); ihh < mm; ihh++) { - TComplex scfour = Four(ih, ihh, -ih, -ihh) / Four(0, 0, 0, 0).Re(); - pht[HIST_THN_SC_with_QC_4corr]->Fill(fCent, ih, ihh, scfour.Re(), event_weight_four); + TComplex scfour = four(ih, ihh, -ih, -ihh) / four(0, 0, 0, 0).Re(); + pht[HIST_THN_SC_with_QC_4corr]->Fill(fCent, fAvgInvariantMass, ih, ihh, scfour.Re(), event_weight_four); } - TComplex sctwo = Two(ih, -ih) / Two(0, 0).Re(); - pht[HIST_THN_SC_with_QC_2corr]->Fill(fCent, ih, sctwo.Re(), event_weight_two); + TComplex sctwo = two(ih, -ih) / two(0, 0).Re(); + pht[HIST_THN_SC_with_QC_2corr]->Fill(fCent, fAvgInvariantMass, ih, sctwo.Re(), event_weight_two); } } diff --git a/PWGCF/JCorran/Core/JFFlucAnalysis.h b/PWGCF/JCorran/Core/JFFlucAnalysis.h index cd5fdf5e515..4900e5c5b62 100644 --- a/PWGCF/JCorran/Core/JFFlucAnalysis.h +++ b/PWGCF/JCorran/Core/JFFlucAnalysis.h @@ -37,6 +37,8 @@ class JFFlucAnalysis : public TNamed TComplex Q(int n, int p); TComplex Two(int n1, int n2); TComplex Four(int n1, int n2, int n3, int n4); + TComplex TwoDiff(int n1, int n2); + TComplex FourDiff(int n1, int n2, int n3, int n4); void UserExec(Option_t* option); void Terminate(Option_t*); @@ -44,6 +46,7 @@ class JFFlucAnalysis : public TNamed inline float GetEventCentrality() const { return fCent; } inline void SetEventImpactParameter(float ip) { fImpactParameter = ip; } inline void SetEventVertex(float zvertex) { fVertex = zvertex; } + inline void SetAverageInvariantMass(float mass) { fAvgInvariantMass = mass; } enum SubEvent { kSubEvent_A = 0x1, kSubEvent_B = 0x2 @@ -123,6 +126,7 @@ class JFFlucAnalysis : public TNamed kK4, nKL }; // order using JQVectorsT = JQVectors; + TComplex Q(const JQVectorsT& qvecs, int n, int p); inline void SetJQVectors(const JQVectorsT* _pqvecs) { pqvecs = _pqvecs; @@ -139,10 +143,10 @@ class JFFlucAnalysis : public TNamed template using hasWeightEff = decltype(std::declval().weightEff()); template - using hasType = decltype(std::declval().particleType()); + using hasSign = decltype(std::declval().sign()); template - inline void FillQA(JInputClass& inputInst, UInt_t type = 0) + inline void FillQA(JInputClass& inputInst, UInt_t type = 0u) { ph1[HIST_TH1_CENTRALITY]->Fill(fCent); ph1[HIST_TH1_IMPACTPARAM]->Fill(fImpactParameter); @@ -151,32 +155,34 @@ class JFFlucAnalysis : public TNamed Double_t corrInv = 1.0; using JInputClassIter = typename JInputClass::iterator; if constexpr (std::experimental::is_detected::value) - corrInv /= track.weightEff(); - pht[HIST_THN_PTETA]->Fill(fCent, track.pt(), track.eta(), corrInv); + corrInv *= track.weightEff(); + if constexpr (std::experimental::is_detected::value) + pht[HIST_THN_PTETA]->Fill(fCent, track.pt(), track.eta(), track.sign(), corrInv); + else + pht[HIST_THN_PTETA]->Fill(fCent, track.pt(), track.eta(), 0.0, corrInv); if constexpr (std::experimental::is_detected::value) corrInv /= track.weightNUA(); pht[HIST_THN_PHIETA]->Fill(fCent, track.phi(), track.eta(), corrInv); - if constexpr (std::experimental::is_detected::value) - type = track.particleType(); pht[HIST_THN_PHIETAZ]->Fill(fCent, static_cast(type), track.phi(), track.eta(), fVertex, corrInv); } ph1[HIST_TH1_ZVERTEX]->Fill(fVertex); } -#define kcNH kH6 // max second dimension + 1 +#define kcNH kH4 // max second dimension + 1 protected: - Float_t fVertex; //! - Float_t fCent; //! - Float_t fImpactParameter; //! - UInt_t subeventMask; //! - UInt_t flags; //! + Float_t fVertex; //! + Float_t fAvgInvariantMass; //! + Float_t fCent; //! + Float_t fImpactParameter; //! + UInt_t subeventMask; //! + UInt_t flags; //! const JQVectorsT* pqvecs; //! const JQVectorsT* pqvecsRef; //! TH1* ph1[HIST_TH1_COUNT]; //! - THn* pht[HIST_THN_COUNT]; //! + THnSparse* pht[HIST_THN_COUNT]; //! THnSparse* phs[HIST_THN_SPARSE_COUNT]; //! ClassDef(JFFlucAnalysis, 1) diff --git a/PWGCF/JCorran/Core/JFFlucAnalysisO2Hist.cxx b/PWGCF/JCorran/Core/JFFlucAnalysisO2Hist.cxx index 181dbe6a05f..b3419ff7dc8 100644 --- a/PWGCF/JCorran/Core/JFFlucAnalysisO2Hist.cxx +++ b/PWGCF/JCorran/Core/JFFlucAnalysisO2Hist.cxx @@ -18,33 +18,31 @@ using namespace o2; -JFFlucAnalysisO2Hist::JFFlucAnalysisO2Hist(HistogramRegistry& registry, AxisSpec& axisMultiplicity, AxisSpec& phiAxis, AxisSpec& etaAxis, AxisSpec& zvtAxis, const TString& folder) : JFFlucAnalysis() +JFFlucAnalysisO2Hist::JFFlucAnalysisO2Hist(HistogramRegistry& registry, AxisSpec& axisMultiplicity, AxisSpec& phiAxis, AxisSpec& etaAxis, AxisSpec& zvtAxis, AxisSpec& ptAxis, AxisSpec& massAxis, const TString& folder) : JFFlucAnalysis() { ph1[HIST_TH1_CENTRALITY] = std::get>(registry.add(Form("%s/h_cent", folder.Data()), "multiplicity/centrality", {HistType::kTH1F, {axisMultiplicity}})).get(); ph1[HIST_TH1_IMPACTPARAM] = std::get>(registry.add(Form("%s/h_IP", folder.Data()), "impact parameter", {HistType::kTH1F, {{400, -2.0, 20.0}}})).get(); ph1[HIST_TH1_ZVERTEX] = std::get>(registry.add(Form("%s/h_vertex", folder.Data()), "z vertex", {HistType::kTH1F, {{100, -20.0, 20.0}}})).get(); - // - // TODO: these shall be configurable - std::vector ptBinning = {0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}; - AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/c)"}; + + AxisSpec chgAxis = {3, -1.5, 1.5, "charge"}; AxisSpec typeAxis = {2, -0.5, 1.5, "type"}; - pht[HIST_THN_PHIETAZ] = std::get>(registry.add(Form("%s/h_phietaz", folder.Data()), "multiplicity/centrality, type, phi, eta, z", {HistType::kTHnF, {axisMultiplicity, typeAxis, phiAxis, etaAxis, zvtAxis}})).get(); - pht[HIST_THN_PTETA] = std::get>(registry.add(Form("%s/h_pteta", folder.Data()), "(corrected) multiplicity/centrality, pT, eta", {HistType::kTHnF, {axisMultiplicity, ptAxis, etaAxis}})).get(); - pht[HIST_THN_PHIETA] = std::get>(registry.add(Form("%s/h_phieta", folder.Data()), "(corrected) multiplicity/centrality, phi, eta", {HistType::kTHnF, {axisMultiplicity, phiAxis, etaAxis}})).get(); + pht[HIST_THN_PHIETAZ] = std::get>(registry.add(Form("%s/h_phietaz", folder.Data()), "multiplicity/centrality, type, phi, eta, z", {HistType::kTHnSparseF, {axisMultiplicity, typeAxis, phiAxis, etaAxis, zvtAxis}})).get(); + pht[HIST_THN_PTETA] = std::get>(registry.add(Form("%s/h_pteta", folder.Data()), "(corrected) multiplicity/centrality, pT, eta, charge", {HistType::kTHnSparseF, {axisMultiplicity, ptAxis, etaAxis, chgAxis}})).get(); + pht[HIST_THN_PHIETA] = std::get>(registry.add(Form("%s/h_phieta", folder.Data()), "(corrected) multiplicity/centrality, phi, eta", {HistType::kTHnSparseF, {axisMultiplicity, phiAxis, etaAxis}})).get(); AxisSpec hAxis = {kNH, -0.5, static_cast(kNH - 1) + 0.5, "#it{n}"}; AxisSpec kAxis = {nKL, -0.5, static_cast(nKL - 1) + 0.5, "#it{k}"}; AxisSpec vnAxis = {2048, -0.1, 0.1, "#it{V}_#it{n}"}; - pht[HIST_THN_SC_with_QC_4corr] = std::get>(registry.add(Form("%s/h_SC_with_QC_4corr", folder.Data()), "SC_with_QC_4corr", {HistType::kTHnF, {axisMultiplicity, hAxis, hAxis, {2048, -0.001, 0.001, "correlation"}}})).get(); - pht[HIST_THN_SC_with_QC_2corr] = std::get>(registry.add(Form("%s/h_SC_with_QC_2corr", folder.Data()), "SC_with_QC_2corr", {HistType::kTHnF, {axisMultiplicity, hAxis, {2048, -0.1, 0.1, "correlation"}}})).get(); - pht[HIST_THN_SC_with_QC_2corr_gap] = std::get>(registry.add(Form("%s/h_SC_with_QC_2corr_gap", folder.Data()), "SC_with_QC_2corr_gap", {HistType::kTHnF, {axisMultiplicity, hAxis, {2048, -0.1, 0.1, "correlation"}}})).get(); + pht[HIST_THN_SC_with_QC_4corr] = std::get>(registry.add(Form("%s/h_SC_with_QC_4corr", folder.Data()), "SC_with_QC_4corr", {HistType::kTHnSparseF, {axisMultiplicity, massAxis, hAxis, hAxis, {2048, -0.001, 0.001, "correlation"}}})).get(); + pht[HIST_THN_SC_with_QC_2corr] = std::get>(registry.add(Form("%s/h_SC_with_QC_2corr", folder.Data()), "SC_with_QC_2corr", {HistType::kTHnSparseF, {axisMultiplicity, massAxis, hAxis, {2048, -0.1, 0.1, "correlation"}}})).get(); + pht[HIST_THN_SC_with_QC_2corr_gap] = std::get>(registry.add(Form("%s/h_SC_with_QC_2corr_gap", folder.Data()), "SC_with_QC_2corr_gap", {HistType::kTHnSparseF, {axisMultiplicity, massAxis, hAxis, {2048, -0.1, 0.1, "correlation"}}})).get(); for (UInt_t i = HIST_THN_V4V2star_2; i < HIST_THN_COUNT; ++i) - pht[i] = std::get>(registry.add(Form("%s/h_corrC%02u", folder.Data(), i - HIST_THN_V4V2star_2), "correlator", {HistType::kTHnF, {axisMultiplicity, {2048, -3.0, 3.0, "correlation"}}})).get(); + pht[i] = std::get>(registry.add(Form("%s/h_corrC%02u", folder.Data(), i - HIST_THN_V4V2star_2), "correlator", {HistType::kTHnSparseF, {axisMultiplicity, massAxis, {2048, -3.0, 3.0, "correlation"}}})).get(); for (UInt_t i = 0; i < HIST_THN_COUNT; ++i) pht[i]->Sumw2(); - phs[HIST_THN_SPARSE_VN] = std::get>(registry.add(Form("%s/hvna", folder.Data()), "#it{V}_#it{n}^#it{k}", {HistType::kTHnSparseF, {axisMultiplicity, hAxis, kAxis, vnAxis}})).get(); - phs[HIST_THN_SPARSE_VN_VN] = std::get>(registry.add(Form("%s/hvn_vn", folder.Data()), "#it{V}_#it{n_1}^#it{k_1}#it{V}_#it{n_2}^#it{k_2}", {HistType::kTHnSparseF, {axisMultiplicity, hAxis, kAxis, hAxis, kAxis, vnAxis}})).get(); + phs[HIST_THN_SPARSE_VN] = std::get>(registry.add(Form("%s/hvna", folder.Data()), "#it{V}_#it{n}^#it{k}", {HistType::kTHnSparseF, {axisMultiplicity, massAxis, hAxis, kAxis, vnAxis}})).get(); + phs[HIST_THN_SPARSE_VN_VN] = std::get>(registry.add(Form("%s/hvn_vn", folder.Data()), "#it{V}_#it{n_1}^#it{k_1}#it{V}_#it{n_2}^#it{k_2}", {HistType::kTHnSparseF, {axisMultiplicity, massAxis, hAxis, kAxis, hAxis, kAxis, vnAxis}})).get(); for (UInt_t i = 0; i < HIST_THN_SPARSE_COUNT; ++i) phs[i]->Sumw2(); } diff --git a/PWGCF/JCorran/Core/JFFlucAnalysisO2Hist.h b/PWGCF/JCorran/Core/JFFlucAnalysisO2Hist.h index 2e6a593a062..a9de2fd7864 100644 --- a/PWGCF/JCorran/Core/JFFlucAnalysisO2Hist.h +++ b/PWGCF/JCorran/Core/JFFlucAnalysisO2Hist.h @@ -23,7 +23,7 @@ using namespace o2::framework; class JFFlucAnalysisO2Hist : public JFFlucAnalysis { public: - JFFlucAnalysisO2Hist(HistogramRegistry&, AxisSpec&, AxisSpec&, AxisSpec&, AxisSpec&, const TString&); + JFFlucAnalysisO2Hist(HistogramRegistry&, AxisSpec&, AxisSpec&, AxisSpec&, AxisSpec&, AxisSpec&, AxisSpec&, const TString&); ~JFFlucAnalysisO2Hist(); }; diff --git a/PWGCF/JCorran/Core/JQVectors.h b/PWGCF/JCorran/Core/JQVectors.h index 884840010bf..01693ae6073 100644 --- a/PWGCF/JCorran/Core/JQVectors.h +++ b/PWGCF/JCorran/Core/JQVectors.h @@ -44,9 +44,11 @@ class JQVectors : public std::conditional_t, JQ using hasWeightNUA = decltype(std::declval().weightNUA()); template using hasWeightEff = decltype(std::declval().weightEff()); + template + using hasInvMass = decltype(std::declval().invMass()); template - inline void Calculate(JInputClass& inputInst, float etamin, float etamax) + inline void Calculate(JInputClass& inputInst, float etamin, float etamax, float massMin = 0.0f, float massMax = 999.9f) { // calculate Q-vector for QC method ( no subgroup ) for (UInt_t ih = 0; ih < nh; ++ih) { @@ -61,6 +63,11 @@ class JQVectors : public std::conditional_t, JQ for (auto& track : inputInst) { if (track.eta() < -etamax || track.eta() > etamax) continue; + using JInputClassIter = typename JInputClass::iterator; + if constexpr (std::experimental::is_detected::value) { + if (track.invMass() < massMin || track.invMass() >= massMax) + continue; + } UInt_t isub = (UInt_t)(track.eta() > 0.0); for (UInt_t ih = 0; ih < nh; ++ih) { @@ -74,11 +81,10 @@ class JQVectors : public std::conditional_t, JQ this->QvectorQCgap[isub][ih][ik] += q; } - using JInputClassIter = typename JInputClass::iterator; if constexpr (std::experimental::is_detected::value) tf /= track.weightNUA(); if constexpr (std::experimental::is_detected::value) - tf /= track.weightEff(); + tf *= track.weightEff(); } } } diff --git a/PWGCF/JCorran/Tasks/CMakeLists.txt b/PWGCF/JCorran/Tasks/CMakeLists.txt index 31fc41e4c6d..465083509d0 100644 --- a/PWGCF/JCorran/Tasks/CMakeLists.txt +++ b/PWGCF/JCorran/Tasks/CMakeLists.txt @@ -38,3 +38,8 @@ o2physics_add_dpl_workflow(epdzeroflow-analysis SOURCES jEPDzeroFlowAnalysis.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(j-fluc-efficiency-task + SOURCES jFlucEfficiencyTask.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::JCorran + COMPONENT_NAME Analysis) diff --git a/PWGCF/JCorran/Tasks/flowJNUACreation.cxx b/PWGCF/JCorran/Tasks/flowJNUACreation.cxx index 914dc37b4ab..31edc2a7c3d 100644 --- a/PWGCF/JCorran/Tasks/flowJNUACreation.cxx +++ b/PWGCF/JCorran/Tasks/flowJNUACreation.cxx @@ -93,10 +93,10 @@ struct flowJNUACreation { void init(InitContext const&) { // Add histomanager here - histManager.SetHistRegistryQA(&qaHistRegistry); - histManager.SetDebugLog(false); - histManager.SetObtainNUA(true); - histManager.CreateHistQA(); + histManager.setHistRegistryQA(&qaHistRegistry); + histManager.setDebugLog(false); + histManager.setObtainNUA(true); + histManager.createHistQA(); // Add CCDB access here ccdb->setURL(cfgCCDB.cfgURL); @@ -131,13 +131,13 @@ struct flowJNUACreation { if (cent < 0. || cent > 70.) { return; } - Int_t cBin = histManager.GetCentBin(cent); + Int_t cBin = histManager.getCentBin(cent); int nTracks = tracks.size(); for (auto& track : tracks) { - histManager.FillTrackQA<1>(track, cBin, 1., 1., coll.posZ()); + histManager.fillTrackQA<1>(track, cBin, 1., 1., coll.posZ()); } - histManager.FillEventQA<1>(coll, cBin, cent, nTracks); + histManager.fillEventQA<1>(coll, cBin, cent, nTracks); LOGF(info, "Collision analysed. Next..."); } diff --git a/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx b/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx index 3a533674f14..2ce4568348f 100644 --- a/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx +++ b/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx @@ -25,7 +25,6 @@ #include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" -#include "CCDB/BasicCCDBManager.h" #include "Framework/HistogramRegistry.h" // O2 Physics headers. // @@ -36,6 +35,8 @@ #include "Common/Core/TrackSelection.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "PWGCF/DataModel/CorrelationsDerived.h" +#include "PWGCF/JCorran/DataModel/JCatalyst.h" #include "PWGCF/JCorran/Core/FlowJSPCAnalysis.h" #include "PWGCF/JCorran/Core/FlowJSPCObservables.h" #include "PWGCF/JCorran/Core/FlowJHistManager.h" @@ -50,24 +51,24 @@ using MyCollisions = soa::Join; -using MyTracks = soa::Join; +using MyTracks = soa::Join; struct flowJSPCAnalysis { - HistogramRegistry SPCHistograms{"SPCResults", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry spcHistograms{"SPCResults", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; FlowJSPCAnalysis spcAnalysis; FlowJSPCAnalysis::JQVectorsT jqvecs; + template + using HasWeightNUA = decltype(std::declval().weightNUA()); HistogramRegistry qaHistRegistry{"qaHistRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; FlowJHistManager histManager; - FlowJSPCObservables SPCobservables; + FlowJSPCObservables spcObservables; // Set Configurables here - Configurable cfgUseNUA{"cfgUseNUA", false, "Use NUA correction"}; - Configurable cfgUseNUE{"cfgUseNUE", false, "Use NUE correction"}; Configurable cfgFillQA{"cfgFillQA", true, "Fill QA plots"}; - Configurable cfgWhichSPC{"cfgWhichSPC", 0, "Which SPC observables to compute."}; + Configurable cfgWhichSPC{"cfgWhichSPC", 0, "Which SPC observables to compute."}; struct : ConfigurableGroup { Configurable cfgPtMin{"cfgPtMin", 0.2f, "Minimum pT used for track selection."}; @@ -75,107 +76,89 @@ struct flowJSPCAnalysis { Configurable cfgEtaMax{"cfgEtaMax", 0.8f, "Maximum eta used for track selection."}; } cfgTrackCuts; - // The centrality estimators are the ones available for Run 3. - enum centEstimators { FT0M, - FT0A, - FT0C, - FDDM, - NTPV }; struct : ConfigurableGroup { Configurable cfgCentEst{"cfgCentEst", 2, "Centrality estimator."}; Configurable cfgZvtxMax{"cfgZvtxMax", 10.0f, "Maximum primary vertex cut applied for the events."}; Configurable cfgMultMin{"cfgMultMin", 10, "Minimum number of particles required for the event to have."}; } cfgEventCuts; - // Set the access to the CCDB for the NUA/NUE weights. - struct : ConfigurableGroup { - Configurable cfgUseCCDB{"cfgUseCCDB", true, "Use CCDB for NUA/NUE corrections."}; - Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", - "Address of the CCDB to get the NUA/NUE."}; - Configurable cfgTime{"ccdb-no-later-than", - std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), - "Latest acceptable timestamp of creation for the object."}; - } cfgCCDB; - Service ccdb; - // // Filters to be applied to the received data. // // The analysis assumes the data has been subjected to a QA of its selection, // // and thus only the final distributions of the data for analysis are saved. Filter collFilter = (nabs(aod::collision::posZ) < cfgEventCuts.cfgZvtxMax); Filter trackFilter = (aod::track::pt > cfgTrackCuts.cfgPtMin) && (aod::track::pt < cfgTrackCuts.cfgPtMax) && (nabs(aod::track::eta) < cfgTrackCuts.cfgEtaMax); + Filter cftrackFilter = (aod::cftrack::pt > cfgTrackCuts.cfgPtMin) && (aod::cftrack::pt < cfgTrackCuts.cfgPtMax); // eta cuts done by jfluc void init(InitContext const&) { // Add histomanager here - spcAnalysis.SetHistRegistry(&SPCHistograms); - spcAnalysis.CreateHistos(); - - SPCobservables.SetSPCObservables(cfgWhichSPC); - spcAnalysis.SetFullCorrSet(SPCobservables.harmonicArray); + spcAnalysis.setHistRegistry(&spcHistograms); + spcAnalysis.createHistos(); - histManager.SetHistRegistryQA(&qaHistRegistry); - histManager.SetDebugLog(false); - histManager.CreateHistQA(); + spcObservables.setSPCObservables(cfgWhichSPC); + spcAnalysis.setFullCorrSet(spcObservables.harmonicArray); - ///////////////////// - - ccdb->setURL(cfgCCDB.cfgURL); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setCreatedNotAfter(cfgCCDB.cfgTime.value); + histManager.setHistRegistryQA(&qaHistRegistry); + histManager.setDebugLog(false); + histManager.createHistQA(); } - void process(soa::Filtered::iterator const& coll, soa::Filtered const& tracks) + template + void analyze(CollisionT const& collision, TrackT const& tracks) + // void process(soa::Filtered::iterator const& coll, soa::Filtered> const& tracks) { if (tracks.size() < cfgEventCuts.cfgMultMin) return; - float cent = -1.; - switch (cfgEventCuts.cfgCentEst) { - case FT0M: - cent = coll.centFT0M(); - break; - case FT0A: - cent = coll.centFT0A(); - break; - case FT0C: - cent = coll.centFT0C(); - break; - case FDDM: - cent = coll.centFDDM(); - break; - case NTPV: - cent = coll.centNTPV(); - break; - } - if (cent < 0. || cent > 70.) { + float cent = collision.multiplicity(); + if (cent < 0. || cent > 100.) { return; } - Int_t cBin = histManager.GetCentBin(cent); - SPCHistograms.fill(HIST("FullCentrality"), cent); + int cBin = histManager.getCentBin(cent); + spcHistograms.fill(HIST("FullCentrality"), cent); int nTracks = tracks.size(); - - for (auto& track : tracks) { - if (cfgFillQA) - histManager.FillTrackQA<1>(track, cBin, coll.posZ()); - - if (cfgUseNUE) { - ; - } - if (cfgUseNUA) { - ; + for (const auto& track : tracks) { + if (cfgFillQA) { + // histManager.FillTrackQA<0>(track, cBin, collision.posZ()); + + using JInputClassIter = typename TrackT::iterator; + if constexpr (std::experimental::is_detected::value) { + spcAnalysis.fillQAHistograms(cBin, track.phi(), 1. / track.weightNUA()); + } } } if (cfgFillQA) - histManager.FillEventQA<1>(coll, cBin, cent, nTracks); + histManager.fillEventQA<1>(collision, cBin, cent, nTracks); jqvecs.Calculate(tracks, 0.0, cfgTrackCuts.cfgEtaMax); - spcAnalysis.SetQvectors(&jqvecs); - spcAnalysis.CalculateCorrelators(cBin); + spcAnalysis.setQvectors(&jqvecs); + spcAnalysis.calculateCorrelators(cBin); + } - LOGF(info, "Collision analysed. Next..."); + void processJDerived(aod::JCollision const& collision, soa::Filtered const& tracks) + { + analyze(collision, tracks); + } + PROCESS_SWITCH(flowJSPCAnalysis, processJDerived, "Process derived data", false); + + void processJDerivedCorrected(aod::JCollision const& collision, soa::Filtered> const& tracks) + { + analyze(collision, tracks); + } + PROCESS_SWITCH(flowJSPCAnalysis, processJDerivedCorrected, "Process derived data with corrections", false); + + void processCFDerived(aod::CFCollision const& collision, soa::Filtered const& tracks) + { + analyze(collision, tracks); + } + PROCESS_SWITCH(flowJSPCAnalysis, processCFDerived, "Process CF derived data", false); + + void processCFDerivedCorrected(aod::CFCollision const& collision, soa::Filtered> const& tracks) + { + analyze(collision, tracks); } + PROCESS_SWITCH(flowJSPCAnalysis, processCFDerivedCorrected, "Process CF derived data with corrections", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/JCorran/Tasks/jFlucEfficiencyTask.cxx b/PWGCF/JCorran/Tasks/jFlucEfficiencyTask.cxx new file mode 100644 index 00000000000..59ca8b18903 --- /dev/null +++ b/PWGCF/JCorran/Tasks/jFlucEfficiencyTask.cxx @@ -0,0 +1,659 @@ +// 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. +/// +/// \file jFlucEfficiencyTask.cxx +/// \brief Task to calculate the efficiency of the cf-derived tracks/particles +/// \author DongJo Kim, Jasper Parkkila, Bong-Hwi Lim (djkim@cern.ch, jparkkil@cern.ch, bong-hwi.lim@cern.ch) +/// \since March 2024 + +#include +#include +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "PWGCF/DataModel/CorrelationsDerived.h" +#include "PWGLF/Utils/collisionCuts.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::rctsel; + +struct JFlucEfficiencyTask { + Service pdg; + // Add the pT binning array as a static member + static constexpr std::array PttJacek = { + 0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, + 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, + 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, + 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, + 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, + 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 20.0, 22.0, 24.0, + 26.0, 28.0, 30.0, 32.0, 34.0, 36.0, 40.0, 45.0, 50.0, 60.0, + 70.0, 80.0, 90.0, 100.0, 110.0, 120.0, 130.0, 140.0, 150.0, 160.0, + 170.0, 180.0, 190.0, 200.0, 210.0, 220.0, 230.0, 240.0, 250.0, 260.0, + 270.0, 280.0, 290.0, 300.0}; + + // Update the axisPt configuration with proper vector initialization + ConfigurableAxis axisPt{"axisPt", std::vector(PttJacek.begin(), PttJacek.end()), "pT axis"}; + + // Event cuts + Configurable cfgAcceptSplitCollisions{"cfgAcceptSplitCollisions", 0, "0: only look at mcCollisions that are not split; 1: accept split mcCollisions, 2: accept split mcCollisions but only look at the first reco collision associated with it"}; + o2::analysis::CollisonCuts colCuts; + struct : ConfigurableGroup { + Configurable cfgEvtZvtx{"cfgEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable cfgCentMin{"cfgCentMin", 0.0f, "Min centrality"}; + Configurable cfgCentMax{"cfgCentMax", 100.0f, "Max centrality"}; + Configurable cfgEvtOccupancyInTimeRangeMax{"cfgEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; + Configurable cfgEvtOccupancyInTimeRangeMin{"cfgEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; + Configurable cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"}; + Configurable cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"}; + Configurable cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; + Configurable cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; + Configurable cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; + Configurable cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", true, "Evt sel: apply Z-vertex time difference"}; + Configurable cfgEvtPileupRejection{"cfgEvtPileupRejection", true, "Evt sel: apply pileup rejection"}; + Configurable cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + Configurable cfgEvtCollInTimeRangeStandard{"cfgEvtCollInTimeRangeStandard", true, "Evt sel: apply NoCollInTimeRangeStandard"}; + Configurable cfgEvtRun2AliEventCuts{"cfgEvtRun2AliEventCuts", true, "Evt sel: apply Run2 Ali event cuts"}; + Configurable cfgEvtRun2INELgtZERO{"cfgEvtRun2INELgtZERO", false, "Evt sel: apply Run2 INEL>0 event cuts"}; + Configurable cfgEvtUseRCTFlagChecker{"cfgEvtUseRCTFlagChecker", false, "Evt sel: use RCT flag checker"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", false, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } EventCuts; + RCTFlagsChecker rctChecker; + + // Track selections + struct : ConfigurableGroup { + Configurable cfgMinPt{"cfgMinPt", 0.6, "Track minium pt cut"}; + Configurable cfgMaxPt{"cfgMaxPt", 300.0f, "Maximum transverse momentum"}; + Configurable cfgEtaMin{"cfgEtaMin", -1.0f, "Minimum pseudorapidity"}; + Configurable cfgEtaMax{"cfgEtaMax", 1.0f, "Maximum pseudorapidity"}; + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", false, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", false, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + Configurable cfgGlobalTrack{"cfgGlobalTrack", true, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor + Configurable cfgpTdepDCAxyCut{"cfgpTdepDCAxyCut", false, "pT-dependent DCAxy cut"}; + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; + Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; + Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; + Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; + Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; + Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; + Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; + Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; + Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + // DCA to PV + Configurable cfgMaxbDCArToPVcut{"cfgMaxbDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; + Configurable cfgMaxbDCAzToPVcut{"cfgMaxbDCAzToPVcut", 1.0, "Track DCAz cut to PV Maximum"}; + } TrackCuts; + + // Configurable for track selection + Configurable trackSelection{"trackSelection", 0, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; + + // Configurable axes + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, "multiplicity / centrality axis"}; + + // Filter declarations + Filter cfCollisionFilter = (nabs(aod::collision::posZ) < EventCuts.cfgEvtZvtx); + Filter cfTrackFilter = (aod::cftrack::pt >= TrackCuts.cfgMinPt) && + (aod::cftrack::pt <= TrackCuts.cfgMaxPt) && + (aod::cftrack::eta >= TrackCuts.cfgEtaMin) && + (aod::cftrack::eta <= TrackCuts.cfgEtaMax); + // Filter collisionFilter = (nabs(aod::collision::posZ) < EventCuts.cfgEvtZvtx); + Filter trackFilter = (aod::track::pt >= TrackCuts.cfgMinPt) && + (aod::track::pt <= TrackCuts.cfgMaxPt) && + (aod::track::eta >= TrackCuts.cfgEtaMin) && + (aod::track::eta <= TrackCuts.cfgEtaMax); + + Configurable cfgCentBinsForMC{"cfgCentBinsForMC", 1, "Centrality bins for MC, 0: off, 1: on"}; + using CollisionCandidates = soa::Join; + using CollisionRun2Candidates = soa::Join; + using TrackCandidates = soa::Join; + using MCCollisionCandidates = soa::Join; + using MCRun2CollisionCandidates = soa::Join; + using MCTrackCandidates = soa::Join; + using BCsWithRun2Info = soa::Join; + + // Histogram Registry + HistogramRegistry registry{ + "registry", + {{"hEventCounterMC", "Event counter MC;Counter;Counts", {HistType::kTH1F, {{3, -0.5, 2.5}}}}, + {"hEventCounterReco", "Event counter Reco;Counter;Counts", {HistType::kTH1F, {{3, -0.5, 2.5}}}}, + {"hZVertexMC", "MC Z vertex distribution;Z vertex (cm);Centrality (%)", {HistType::kTH2F, {{200, -20, 20}, {axisMultiplicity}}}}, + {"hZVertexReco", "Reconstructed Z vertex distribution;Z vertex (cm);Centrality (%)", {HistType::kTH2F, {{200, -20, 20}, {axisMultiplicity}}}}, + {"hZVertexCorrelation", "Z vertex correlation;MC Z vertex (cm);Reco Z vertex (cm)", {HistType::kTH2F, {{200, -20, 20}, {200, -20, 20}}}}}}; + + // Configurable for debugging + Configurable debugMode{"debugMode", false, "Debug mode"}; + + void init(InitContext const&) + { + if (debugMode) { + LOGF(info, "Initializing JFlucEfficiencyTask"); + } + if (!doprocessMCRun2 && !doprocessDataRun2) { + colCuts.setCuts(EventCuts.cfgEvtZvtx, EventCuts.cfgEvtTriggerCheck, EventCuts.cfgEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, EventCuts.cfgEvtOccupancyInTimeRangeMax, EventCuts.cfgEvtOccupancyInTimeRangeMin); + } else { + colCuts.setCuts(EventCuts.cfgEvtZvtx, EventCuts.cfgEvtTriggerCheck, EventCuts.cfgEvtOfflineCheck, false); + } + colCuts.init(®istry); + colCuts.setTriggerTVX(EventCuts.cfgEvtTriggerTVXSel); + colCuts.setApplyTFBorderCut(EventCuts.cfgEvtTFBorderCut); + colCuts.setApplyITSTPCvertex(EventCuts.cfgEvtUseITSTPCvertex); + colCuts.setApplyZvertexTimedifference(EventCuts.cfgEvtZvertexTimedifference); + colCuts.setApplyPileupRejection(EventCuts.cfgEvtPileupRejection); + colCuts.setApplyNoITSROBorderCut(EventCuts.cfgEvtNoITSROBorderCut); + colCuts.setApplyCollInTimeRangeStandard(EventCuts.cfgEvtCollInTimeRangeStandard); + colCuts.setApplyRun2AliEventCuts(EventCuts.cfgEvtRun2AliEventCuts); + colCuts.setApplyRun2INELgtZERO(EventCuts.cfgEvtRun2INELgtZERO); + colCuts.printCuts(); + + rctChecker.init(EventCuts.cfgEvtRCTFlagCheckerLabel, EventCuts.cfgEvtRCTFlagCheckerZDCCheck, EventCuts.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + + if (doprocessDerivedMC || doprocessMC || doprocessMCRun2) { + registry.add("hPtGen", "Generated p_{T} (all);p_{T} (GeV/c);Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(axisPt), AxisSpec(axisMultiplicity)}); + registry.add("hEtaGen", "Generated #eta (all);#eta;Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(100, -1, 1), AxisSpec(axisMultiplicity)}); + registry.add("hPtGenPos", "Generated p_{T} (positive);p_{T} (GeV/c);Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(axisPt), AxisSpec(axisMultiplicity)}); + registry.add("hPtGenNeg", "Generated p_{T} (negative);p_{T} (GeV/c);Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(axisPt), AxisSpec(axisMultiplicity)}); + } + registry.add("hPtRec", "Reconstructed p_{T} (all);p_{T} (GeV/c);Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(axisPt), AxisSpec(axisMultiplicity)}); + registry.add("hEtaRec", "Reconstructed #eta (all);#eta;Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(100, -1, 1), AxisSpec(axisMultiplicity)}); + registry.add("hPtRecPos", "Reconstructed p_{T} (positive);p_{T} (GeV/c);Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(axisPt), AxisSpec(axisMultiplicity)}); + registry.add("hPtRecNeg", "Reconstructed p_{T} (negative);p_{T} (GeV/c);Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(axisPt), AxisSpec(axisMultiplicity)}); + + if (doprocessEfficiency) { + registry.add("hPtGenData", "Generated p_{T} from data events (all);p_{T} (GeV/c);Centrality (%);Counts", + {HistType::kTH2F, {axisPt, axisMultiplicity}}); + registry.add("hEtaGenData", "Generated #eta from data events (all);#eta;Centrality (%);Counts", + {HistType::kTH2F, {AxisSpec(100, -1, 1), axisMultiplicity}}); + registry.add("hPtGenDataPos", "Generated p_{T} from data events (positive);p_{T} (GeV/c);Centrality (%);Counts", + {HistType::kTH2F, {axisPt, axisMultiplicity}}); + registry.add("hPtGenDataNeg", "Generated p_{T} from data events (negative);p_{T} (GeV/c);Centrality (%);Counts", + {HistType::kTH2F, {axisPt, axisMultiplicity}}); + registry.add("hPtRecData", "Reconstructed p_{T} (all);p_{T} (GeV/c);Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(axisPt), AxisSpec(axisMultiplicity)}); + registry.add("hEtaRecData", "Reconstructed #eta (all);#eta;Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(100, -1, 1), AxisSpec(axisMultiplicity)}); + registry.add("hPtRecDataPos", "Reconstructed p_{T} (positive);p_{T} (GeV/c);Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(axisPt), AxisSpec(axisMultiplicity)}); + registry.add("hPtRecDataNeg", "Reconstructed p_{T} (negative);p_{T} (GeV/c);Centrality (%);Counts", + o2::framework::HistType::kTH2F, {AxisSpec(axisPt), AxisSpec(axisMultiplicity)}); + } + + // Initialize histogram labels + auto h1 = registry.get(HIST("hEventCounterMC")); + auto h2 = registry.get(HIST("hEventCounterReco")); + + if (h1 && h2) { + h1->GetXaxis()->SetBinLabel(1, "All MC Events"); + h1->GetXaxis()->SetBinLabel(2, "Selected MC Events"); + h1->GetXaxis()->SetBinLabel(3, "Analyzed MC Events"); + + h2->GetXaxis()->SetBinLabel(1, "All Reco Events"); + h2->GetXaxis()->SetBinLabel(2, "Selected Reco Events"); + h2->GetXaxis()->SetBinLabel(3, "Analyzed Reco Events"); + } else { + LOGF(error, "Failed to get histograms from registry"); + } + } + + template + double getCharge(ParticleType const& particle) + { + auto pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (!pdgParticle) { + return 10.f; + } + return pdgParticle->Charge(); + } + bool isChargedParticle(int code) + { + auto p = pdg->GetParticle(code); + auto charge = 0.; + if (p != nullptr) { + charge = p->Charge(); + } + return std::abs(charge) >= 3.; + } + // Track selection + template + bool trackCut(TrackType const& track) + { + // basic track cuts + if (std::abs(track.pt()) < TrackCuts.cfgMinPt) + return false; + if (std::abs(track.pt()) > TrackCuts.cfgMaxPt) + return false; + if (track.eta() < TrackCuts.cfgEtaMin) + return false; + if (track.eta() > TrackCuts.cfgEtaMax) + return false; + if (track.itsNCls() < TrackCuts.cfgITScluster) + return false; + if (track.tpcNClsFound() < TrackCuts.cfgTPCcluster) + return false; + if (track.tpcCrossedRowsOverFindableCls() < TrackCuts.cfgRatioTPCRowsOverFindableCls) + return false; + if (track.itsChi2NCl() >= TrackCuts.cfgITSChi2NCl) + return false; + if (track.tpcChi2NCl() >= TrackCuts.cfgTPCChi2NCl) + return false; + if (TrackCuts.cfgHasITS && !track.hasITS()) + return false; + if (TrackCuts.cfgHasTPC && !track.hasTPC()) + return false; + if (TrackCuts.cfgHasTOF && !track.hasTOF()) + return false; + if (TrackCuts.cfgUseITSRefit && !track.passedITSRefit()) + return false; + if (TrackCuts.cfgUseTPCRefit && !track.passedTPCRefit()) + return false; + if (TrackCuts.cfgPVContributor && !track.isPVContributor()) + return false; + if (TrackCuts.cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (TrackCuts.cfgGlobalTrack && !track.isGlobalTrack()) + return false; + if (TrackCuts.cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (TrackCuts.cfgpTdepDCAxyCut) { + // Tuned on the LHC22f anchored MC LHC23d1d on primary pions. 7 Sigmas of the resolution + if (std::abs(track.dcaXY()) > (0.004 + (0.013 / track.pt()))) + return false; + } else { + if (std::abs(track.dcaXY()) > TrackCuts.cfgMaxbDCArToPVcut) + return false; + } + if (std::abs(track.dcaZ()) > TrackCuts.cfgMaxbDCAzToPVcut) + return false; + return true; + } + + void processDerivedMC(soa::Filtered::iterator const& mcCollision, soa::Filtered const& mcParticles) + { + float centrality = mcCollision.multiplicity(); // multiplicity: number of primary particles TODO: apply percentiles + registry.fill(HIST("hEventCounterMC"), 0); + registry.fill(HIST("hZVertexMC"), mcCollision.posZ(), centrality); + + for (const auto& particle : mcParticles) { + if (!particle.isPhysicalPrimary()) { + continue; + } + + registry.fill(HIST("hPtGen"), particle.pt(), centrality); + registry.fill(HIST("hEtaGen"), particle.eta(), centrality); + + if (particle.sign() > 0) { // Positive particles + registry.fill(HIST("hPtGenPos"), particle.pt(), centrality); + } else if (particle.sign() < 0) { // Negative particles + registry.fill(HIST("hPtGenNeg"), particle.pt(), centrality); + } + } + } + + void processDerivedData(soa::Filtered::iterator const& cfCollision, soa::Filtered const& cfTracks) + { + float centrality = cfCollision.multiplicity(); + + if (centrality < EventCuts.cfgCentMin || centrality > EventCuts.cfgCentMax) { + return; + } + registry.fill(HIST("hZVertexReco"), cfCollision.posZ(), centrality); + + for (const auto& track : cfTracks) { + registry.fill(HIST("hPtRec"), track.pt(), centrality); + registry.fill(HIST("hEtaRec"), track.eta(), centrality); + + if (track.sign() > 0) { // Positive tracks + registry.fill(HIST("hPtRecPos"), track.pt(), centrality); + } else if (track.sign() < 0) { // Negative tracks + registry.fill(HIST("hPtRecNeg"), track.pt(), centrality); + } + } + } + + Preslice perCollision = aod::track::collisionId; + void processMC(aod::McCollisions::iterator const& mcCollision, + soa::SmallGroups const& collisions, + soa::Filtered const& mcTracks, + aod::McParticles const& mcParticles) + { + registry.fill(HIST("hEventCounterMC"), 0); + if (!(std::abs(mcCollision.posZ()) < EventCuts.cfgEvtZvtx)) { + return; + } + if (collisions.size() < 1) { + return; + } + if (cfgAcceptSplitCollisions == 0 && collisions.size() > 1) { + return; + } + float centrality = -999; + for (const auto& collision : collisions) { // Anayway only 1 collision per mcCollision will be selected + if (!colCuts.isSelected(collision)) // Default event selection + return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) { + return; + } + colCuts.fillQA(collision); + centrality = collision.centFT0C(); + } + registry.fill(HIST("hEventCounterMC"), 1); + registry.fill(HIST("hZVertexMC"), mcCollision.posZ(), centrality); + if (centrality < EventCuts.cfgCentMin || centrality > EventCuts.cfgCentMax) { + return; + } + for (const auto& particle : mcParticles) { + auto charge = getCharge(particle); + if ((!particle.isPhysicalPrimary()) || !isChargedParticle(particle.pdgCode())) { + continue; + } + // pT and eta selections + if (particle.pt() < TrackCuts.cfgMinPt || particle.pt() > TrackCuts.cfgMaxPt || particle.eta() < TrackCuts.cfgEtaMin || particle.eta() > TrackCuts.cfgEtaMax) { + continue; + } + registry.fill(HIST("hPtGen"), particle.pt(), centrality); + registry.fill(HIST("hEtaGen"), particle.eta(), centrality); + if (charge > 0) { // Positive particles + registry.fill(HIST("hPtGenPos"), particle.pt(), centrality); + } else if (charge < 0) { // Negative particles + registry.fill(HIST("hPtGenNeg"), particle.pt(), centrality); + } + } + // Reconstruct tracks from MC particles + for (const auto& collision : collisions) { + registry.fill(HIST("hZVertexReco"), collision.posZ(), centrality); + registry.fill(HIST("hZVertexCorrelation"), mcCollision.posZ(), collision.posZ()); + auto tracks = mcTracks.sliceBy(perCollision, collision.globalIndex()); + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + if (!trackCut(track)) { + continue; + } + auto mcPart = track.mcParticle(); + if (!mcPart.isPhysicalPrimary() || !isChargedParticle(mcPart.pdgCode())) { + continue; + } + registry.fill(HIST("hPtRec"), track.pt(), centrality); + registry.fill(HIST("hEtaRec"), track.eta(), centrality); + if (track.sign() > 0) { // Positive tracks + registry.fill(HIST("hPtRecPos"), track.pt(), centrality); + } else if (track.sign() < 0) { // Negative tracks + registry.fill(HIST("hPtRecNeg"), track.pt(), centrality); + } + } + } + } + + void processMCRun2(aod::McCollisions::iterator const& mcCollision, + soa::SmallGroups const& collisions, + soa::Filtered const& mcTracks, + aod::McParticles const& mcParticles, + BCsWithRun2Info const&) + { + registry.fill(HIST("hEventCounterMC"), 0); + if (!(std::abs(mcCollision.posZ()) < EventCuts.cfgEvtZvtx)) { + return; + } + if (collisions.size() < 1) { + return; + } + if (cfgAcceptSplitCollisions == 0 && collisions.size() > 1) { + return; + } + float centrality = -999; + for (const auto& collision : collisions) { // Anayway only 1 collision per mcCollision will be selected + if (!colCuts.isSelected(collision)) // Default event selection + return; + colCuts.fillQARun2(collision); + centrality = collision.centRun2V0M(); + } + registry.fill(HIST("hEventCounterMC"), 1); + registry.fill(HIST("hZVertexMC"), mcCollision.posZ(), centrality); + if (centrality < EventCuts.cfgCentMin || centrality > EventCuts.cfgCentMax) { + return; + } + for (const auto& particle : mcParticles) { + auto charge = getCharge(particle); + if ((!particle.isPhysicalPrimary()) || !isChargedParticle(particle.pdgCode())) { + continue; + } + // pT and eta selections + if (particle.pt() < TrackCuts.cfgMinPt || particle.pt() > TrackCuts.cfgMaxPt || particle.eta() < TrackCuts.cfgEtaMin || particle.eta() > TrackCuts.cfgEtaMax) { + continue; + } + registry.fill(HIST("hPtGen"), particle.pt(), centrality); + registry.fill(HIST("hEtaGen"), particle.eta(), centrality); + if (charge > 0) { // Positive particles + registry.fill(HIST("hPtGenPos"), particle.pt(), centrality); + } else if (charge < 0) { // Negative particles + registry.fill(HIST("hPtGenNeg"), particle.pt(), centrality); + } + } + // Reconstruct tracks from MC particles + for (const auto& collision : collisions) { + registry.fill(HIST("hZVertexReco"), collision.posZ(), centrality); + registry.fill(HIST("hZVertexCorrelation"), mcCollision.posZ(), collision.posZ()); + auto tracks = mcTracks.sliceBy(perCollision, collision.globalIndex()); + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + auto mcPart = track.mcParticle(); + if (!mcPart.isPhysicalPrimary() || !isChargedParticle(mcPart.pdgCode())) { + continue; + } + // pT and eta selections + if (!trackCut(track)) { + continue; + } + registry.fill(HIST("hPtRec"), track.pt(), centrality); + registry.fill(HIST("hEtaRec"), track.eta(), centrality); + if (track.sign() > 0) { // Positive tracks + registry.fill(HIST("hPtRecPos"), track.pt(), centrality); + } else if (track.sign() < 0) { // Negative tracks + registry.fill(HIST("hPtRecNeg"), track.pt(), centrality); + } + } + } + } + + void processData(CollisionCandidates::iterator const& collision, soa::Filtered const& tracks) + { + if (!colCuts.isSelected(collision)) // Default event selection + return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) { + return; + } + colCuts.fillQA(collision); + auto centrality = collision.centFT0C(); + if (centrality < EventCuts.cfgCentMin || centrality > EventCuts.cfgCentMax) { + return; + } + registry.fill(HIST("hZVertexReco"), collision.posZ(), centrality); + for (const auto& track : tracks) { + // pT and eta selections + if (!trackCut(track)) { + continue; + } + registry.fill(HIST("hPtRec"), track.pt(), centrality); + registry.fill(HIST("hEtaRec"), track.eta(), centrality); + if (track.sign() > 0) { // Positive tracks + registry.fill(HIST("hPtRecPos"), track.pt(), centrality); + } else if (track.sign() < 0) { // Negative tracks + registry.fill(HIST("hPtRecNeg"), track.pt(), centrality); + } + } + } + + void processDataRun2(CollisionRun2Candidates::iterator const& collision, soa::Filtered const& tracks, BCsWithRun2Info const&) + { + if (!colCuts.isSelected(collision)) // Default event selection + return; + colCuts.fillQARun2(collision); + auto centrality = collision.centRun2V0M(); + if (centrality < EventCuts.cfgCentMin || centrality > EventCuts.cfgCentMax) { + return; + } + registry.fill(HIST("hZVertexReco"), collision.posZ(), centrality); + for (const auto& track : tracks) { + // pT and eta selections + if (!trackCut(track)) { + continue; + } + registry.fill(HIST("hPtRec"), track.pt(), centrality); + registry.fill(HIST("hEtaRec"), track.eta(), centrality); + if (track.sign() > 0) { // Positive tracks + registry.fill(HIST("hPtRecPos"), track.pt(), centrality); + } else if (track.sign() < 0) { // Negative tracks + registry.fill(HIST("hPtRecNeg"), track.pt(), centrality); + } + } + } + + // NOTE SmallGroups includes soa::Filtered always + Preslice perCFCollision = aod::cftrack::cfCollisionId; + void processEfficiency(soa::Filtered::iterator const& mcCollision, + aod::CFMcParticles const& mcParticles, + soa::SmallGroups const& collisions, + soa::Filtered const& tracks) + { + try { + // Count MC events and fill MC z-vertex with centrality + if (debugMode) { + LOGF(info, "MC collision at vtx-z = %f with %d mc particles and %d reconstructed collisions", mcCollision.posZ(), mcParticles.size(), collisions.size()); + } + auto multiplicity = mcCollision.multiplicity(); + if (cfgCentBinsForMC > 0) { + if (collisions.size() == 0) { + return; + } + for (const auto& collision : collisions) { + multiplicity = collision.multiplicity(); + } + } + if (debugMode) { + LOGF(info, "MC collision multiplicity: %f", multiplicity); + } + registry.fill(HIST("hEventCounterMC"), 0); + registry.fill(HIST("hZVertexMC"), mcCollision.posZ(), multiplicity); + if (debugMode) { + LOGF(info, "Processing MC collision %d at z = %.3f", mcCollision.globalIndex(), mcCollision.posZ()); + } + + // Fill MC particle histograms + for (const auto& mcParticle : mcParticles) { + if (!mcParticle.isPhysicalPrimary() || mcParticle.sign() == 0) { + continue; + } + registry.fill(HIST("hPtGenData"), mcParticle.pt(), multiplicity); + registry.fill(HIST("hEtaGenData"), mcParticle.eta(), multiplicity); + if (mcParticle.sign() > 0) { + registry.fill(HIST("hPtGenDataPos"), mcParticle.pt(), multiplicity); + } else if (mcParticle.sign() < 0) { + registry.fill(HIST("hPtGenDataNeg"), mcParticle.pt(), multiplicity); + } + } + registry.fill(HIST("hEventCounterMC"), 1); + + // Check reconstructed collisions + if (collisions.size() == 0) { + if (debugMode) { + LOGF(info, "No reconstructed collisions found for MC collision %d", mcCollision.globalIndex()); + } + return; + } + + // Process reconstructed events + for (const auto& collision : collisions) { + registry.fill(HIST("hEventCounterReco"), 0); + registry.fill(HIST("hZVertexReco"), collision.posZ(), collision.multiplicity()); + registry.fill(HIST("hZVertexCorrelation"), mcCollision.posZ(), collision.posZ()); + + if (debugMode) { + LOGF(info, "Processing reconstructed collision %d at z = %.3f", + collision.globalIndex(), collision.posZ()); + } + registry.fill(HIST("hEventCounterReco"), 1); + + // Fill track histograms + auto groupedTracks = tracks.sliceBy(perCFCollision, collision.globalIndex()); + if (debugMode) { + LOGF(info, "Reconstructed collision %d has %d tracks", collision.globalIndex(), groupedTracks.size()); + } + for (const auto& track : groupedTracks) { + if (!track.has_cfMCParticle()) { + if (debugMode) { + LOGF(debug, "Track without MC particle found"); + } + continue; + } + // primary particles only + const auto& mcParticle = track.cfMCParticle(); + if (!mcParticle.isPhysicalPrimary()) { + continue; + } + registry.fill(HIST("hPtRecData"), track.pt(), collision.multiplicity()); + registry.fill(HIST("hEtaRecData"), track.eta(), collision.multiplicity()); + if (track.sign() > 0) { + registry.fill(HIST("hPtRecDataPos"), track.pt(), collision.multiplicity()); + } else if (track.sign() < 0) { + registry.fill(HIST("hPtRecDataNeg"), track.pt(), collision.multiplicity()); + } + } + + // Count selected and analyzed events + registry.fill(HIST("hEventCounterReco"), 2); + } + + registry.fill(HIST("hEventCounterMC"), 2); + + } catch (const std::exception& e) { + LOGF(error, "Exception caught in processEfficiency: %s", e.what()); + } catch (...) { + LOGF(error, "Unknown exception caught in processEfficiency"); + } + } + + PROCESS_SWITCH(JFlucEfficiencyTask, processMC, "Process MC only", false); + PROCESS_SWITCH(JFlucEfficiencyTask, processMCRun2, "Process Run2 MC only", false); + PROCESS_SWITCH(JFlucEfficiencyTask, processData, "Process data only", false); + PROCESS_SWITCH(JFlucEfficiencyTask, processDataRun2, "Process Run2 data only", false); + PROCESS_SWITCH(JFlucEfficiencyTask, processDerivedMC, "Process derived MC only", false); + PROCESS_SWITCH(JFlucEfficiencyTask, processDerivedData, "Process derived data only", false); + PROCESS_SWITCH(JFlucEfficiencyTask, processEfficiency, "Process efficiency task", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/JCorran/Tasks/jflucAnalysisTask.cxx b/PWGCF/JCorran/Tasks/jflucAnalysisTask.cxx index 16ff1b6c25b..0072f2c2a51 100644 --- a/PWGCF/JCorran/Tasks/jflucAnalysisTask.cxx +++ b/PWGCF/JCorran/Tasks/jflucAnalysisTask.cxx @@ -12,25 +12,27 @@ /// \author Dong Jo Kim (djkim@jyu.fi) /// \since Sep 2022 -#include +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "Framework/AnalysisTask.h" #include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" - -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" +#include "Framework/RunningWorkflowInfo.h" #include "ReconstructionDataFormats/V0.h" +#include + // #include "CCDB/BasicCCDBManager.h" -#include "PWGCF/JCorran/DataModel/JCatalyst.h" -#include "PWGCF/DataModel/CorrelationsDerived.h" #include "JFFlucAnalysis.h" #include "JFFlucAnalysisO2Hist.h" + +#include "PWGCF/DataModel/CorrelationsDerived.h" +#include "PWGCF/JCorran/DataModel/JCatalyst.h" + #include "Framework/runDataProcessing.h" using namespace o2; @@ -51,15 +53,19 @@ struct jflucAnalysisTask { O2_DEFINE_CONFIGURABLE(etamin, float, 0.4, "Minimum eta for tracks"); O2_DEFINE_CONFIGURABLE(etamax, float, 0.8, "Maximum eta for tracks"); O2_DEFINE_CONFIGURABLE(ptmin, float, 0.2, "Minimum pt for tracks"); - O2_DEFINE_CONFIGURABLE(ptmax, float, 0.5, "Maximum pt for tracks"); + O2_DEFINE_CONFIGURABLE(ptmax, float, 5.0, "Maximum pt for tracks"); + O2_DEFINE_CONFIGURABLE(cfgCentBinsForMC, int, 0, "0 = OFF and 1 = ON for data like multiplicity/centrality bins for MC process"); ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 100.1}, "multiplicity / centrality axis for histograms"}; ConfigurableAxis phiAxis{"axisPhi", {50, 0.0, o2::constants::math::TwoPI}, "phi axis for histograms"}; ConfigurableAxis etaAxis{"axisEta", {40, -2.0, 2.0}, "eta axis for histograms"}; ConfigurableAxis zvtAxis{"axisZvt", {20, -10.0, 10.0}, "zvertex axis for histograms"}; + ConfigurableAxis ptAxis{"axisPt", {60, 0.0, 300.0}, "pt axis for histograms"}; + ConfigurableAxis massAxis{"axisMass", {1, 0.0, 10.0}, "mass axis for histograms"}; - Filter jtrackFilter = (aod::jtrack::pt > ptmin) && (aod::jtrack::pt < ptmax); // eta cuts done by jfluc - Filter cftrackFilter = (aod::cftrack::pt > ptmin) && (aod::cftrack::pt < ptmax); // eta cuts done by jfluc + Filter jtrackFilter = (aod::jtrack::pt > ptmin) && (aod::jtrack::pt < ptmax); // eta cuts done by jfluc + Filter cftrackFilter = (aod::cftrack::pt > ptmin) && (aod::cftrack::pt < ptmax); // eta cuts done by jfluc + Filter cfmcparticleFilter = (aod::cfmcparticle::pt > ptmin) && (aod::cfmcparticle::pt < ptmax) && (aod::cfmcparticle::sign != 0); // eta cuts done by jfluc Filter cf2pFilter = (aod::cf2prongtrack::pt > ptmin) && (aod::cf2prongtrack::pt < ptmax); HistogramRegistry registry{"registry"}; @@ -70,20 +76,22 @@ struct jflucAnalysisTask { auto axisSpecPhi = AxisSpec(phiAxis); auto axisSpecEta = AxisSpec(etaAxis); auto axisSpecZvt = AxisSpec(zvtAxis); - if (doprocessJDerived || doprocessJDerivedCorrected || doprocessCFDerived || doprocessCFDerivedCorrected) { - pcf = new JFFlucAnalysisO2Hist(registry, axisSpecMult, axisSpecPhi, axisSpecEta, axisSpecZvt, "jfluc"); + auto axisSpecPt = AxisSpec(ptAxis); + auto axisSpecMass = AxisSpec(massAxis); + if (doprocessJDerived || doprocessJDerivedCorrected || doprocessCFDerived || doprocessCFDerivedCorrected || doprocessMCCFDerived) { + pcf = new JFFlucAnalysisO2Hist(registry, axisSpecMult, axisSpecPhi, axisSpecEta, axisSpecZvt, axisSpecPt, axisSpecMass, "jfluc"); pcf->AddFlags(JFFlucAnalysis::kFlucEbEWeighting); pcf->UserCreateOutputObjects(); } else { pcf = 0; } if (doprocessCF2ProngDerived || doprocessCF2ProngDerivedCorrected) { - pcf2Prong = new JFFlucAnalysisO2Hist(registry, axisSpecMult, axisSpecPhi, axisSpecEta, axisSpecZvt, "jfluc2prong"); + pcf2Prong = new JFFlucAnalysisO2Hist(registry, axisSpecMult, axisSpecPhi, axisSpecEta, axisSpecZvt, axisSpecPt, axisSpecMass, "jfluc2prong"); pcf2Prong->AddFlags(JFFlucAnalysis::kFlucEbEWeighting); pcf2Prong->UserCreateOutputObjects(); ConfigurableAxis axisInvMassHistogram{"axisInvMassHistogram", {1000, 1.0, 3.0}, "invariant mass histogram binning"}; - registry.add("invMass", "2-prong invariant mass (GeV/c^2)", {HistType::kTH2F, {axisInvMassHistogram, axisMultiplicity}}); + registry.add("invMass", "2-prong invariant mass (GeV/c^2)", {HistType::kTH3F, {axisInvMassHistogram, {8, 0.0, 8.0, "p_{T}"}, axisMultiplicity}}); } else { pcf2Prong = 0; } @@ -109,16 +117,21 @@ struct jflucAnalysisTask { { if constexpr (std::experimental::is_detected::value) { for (auto& track : poiTracks) - registry.fill(HIST("invMass"), track.invMass(), collision.multiplicity()); + registry.fill(HIST("invMass"), track.invMass(), track.pt(), collision.multiplicity()); } pcf2Prong->Init(); pcf2Prong->SetEventCentrality(collision.multiplicity()); pcf2Prong->SetEventVertex(collision.posZ()); + pcf2Prong->FillQA(refTracks, 0u); pcf2Prong->FillQA(poiTracks, 1u); // type = 1, all POI tracks in this list are of the same type - qvecs.Calculate(poiTracks, etamin, etamax); qvecsRef.Calculate(refTracks, etamin, etamax); pcf2Prong->SetJQVectors(&qvecs, &qvecsRef); - pcf2Prong->UserExec(""); + const AxisSpec& a = AxisSpec(massAxis); + for (uint i = 0; i < a.getNbins(); ++i) { + qvecs.Calculate(poiTracks, etamin, etamax, a.binEdges[i], a.binEdges[i + 1]); + pcf2Prong->SetAverageInvariantMass(0.5f * (a.binEdges[i] + a.binEdges[i + 1])); + pcf2Prong->UserExec(""); // The analysis needs to be called many times, once for each mass bin. For each of the bins, SetInvariantMass is used + } } void processJDerived(aod::JCollision const& collision, soa::Filtered const& tracks) @@ -137,13 +150,13 @@ struct jflucAnalysisTask { { analyze(collision, tracks); } - PROCESS_SWITCH(jflucAnalysisTask, processCFDerived, "Process CF derived data", true); + PROCESS_SWITCH(jflucAnalysisTask, processCFDerived, "Process CF derived data", false); void processCFDerivedCorrected(aod::CFCollision const& collision, soa::Filtered> const& tracks) { analyze(collision, tracks); } - PROCESS_SWITCH(jflucAnalysisTask, processCFDerivedCorrected, "Process CF derived data with corrections", false); + PROCESS_SWITCH(jflucAnalysisTask, processCFDerivedCorrected, "Process CF derived data with corrections", true); void processCF2ProngDerived(aod::CFCollision const& collision, soa::Filtered const& tracks, soa::Filtered const& p2tracks) { @@ -157,6 +170,27 @@ struct jflucAnalysisTask { } PROCESS_SWITCH(jflucAnalysisTask, processCF2ProngDerivedCorrected, "Process CF derived data with 2-prongs as POI and charged particles as REF with corrections.", false); + void processMCCFDerived(aod::CFMcCollision const& mcCollision, soa::Filtered const& particles, soa::SmallGroups const& collisions) + { + auto multiplicity = mcCollision.multiplicity(); + if (cfgCentBinsForMC > 0) { + if (collisions.size() == 0) { + return; + } + for (const auto& collision : collisions) { + multiplicity = collision.multiplicity(); + } + } + pcf->Init(); + pcf->SetEventCentrality(multiplicity); + pcf->SetEventVertex(mcCollision.posZ()); + pcf->FillQA(particles); + qvecs.Calculate(particles, etamin, etamax); + pcf->SetJQVectors(&qvecs); + pcf->UserExec(""); + } + PROCESS_SWITCH(jflucAnalysisTask, processMCCFDerived, "Process CF derived MC data", false); + JFFlucAnalysis::JQVectorsT qvecs; JFFlucAnalysis::JQVectorsT qvecsRef; JFFlucAnalysisO2Hist* pcf; diff --git a/PWGCF/JCorran/Tasks/jflucWeightsLoader.cxx b/PWGCF/JCorran/Tasks/jflucWeightsLoader.cxx index a7717b6c2f5..244035fd310 100644 --- a/PWGCF/JCorran/Tasks/jflucWeightsLoader.cxx +++ b/PWGCF/JCorran/Tasks/jflucWeightsLoader.cxx @@ -10,8 +10,10 @@ // or submit itself to any jurisdiction. /// \author Jasper Parkkila (jparkkil@cern.ch) /// \since May 2024 +// o2-linter: disable='doc/file' #include +#include #include #include @@ -26,7 +28,7 @@ #include "Common/DataModel/Centrality.h" #include "ReconstructionDataFormats/V0.h" -// #include "CCDB/BasicCCDBManager.h" +#include "CCDB/BasicCCDBManager.h" #include "PWGCF/JCorran/DataModel/JCatalyst.h" #include "PWGCF/DataModel/CorrelationsDerived.h" @@ -40,14 +42,22 @@ using namespace o2::framework::expressions; // The standalone jfluc code expects the entire list of tracks for an event. At the same time, it expects weights together with other track attributes. // This workflow creates a table of weights that can be joined with track tables. -struct jflucWeightsLoader { - O2_DEFINE_CONFIGURABLE(pathPhiWeights, std::string, "", "Local (local://) or CCDB path for the phi acceptance correction histogram"); +struct JflucWeightsLoader { + O2_DEFINE_CONFIGURABLE(cfgPathPhiWeights, std::string, "http://alice-ccdb.cern.ch", "Local (local://) or CCDB path for the phi acceptance correction histogram"); + O2_DEFINE_CONFIGURABLE(cfgPathEffWeights, std::string, "", "Local (local://) or CCDB path for the efficiency correction histogram"); + O2_DEFINE_CONFIGURABLE(cfgForRunNumber, bool, false, "Get CCDB object by run"); + O2_DEFINE_CONFIGURABLE(cfgCCDBPath, std::string, "Users/m/mavirta/corrections/NUA/LHC23zzh", "Internal path in CCDB"); THnF* ph = 0; TFile* pf = 0; + THnD* pheff = 0; + TFile* pfeff = 0; int runNumber = 0; + int timestamp = 0; + bool useCCDB = false; + Service ccdb; - ~jflucWeightsLoader() + ~JflucWeightsLoader() { if (ph) delete ph; @@ -55,46 +65,101 @@ struct jflucWeightsLoader { pf->Close(); delete pf; } + if (pheff) + delete pheff; + if (pfeff) { + pfeff->Close(); + delete pfeff; + } + } + + void initCCDB(int runNum, int ts) + { + if (cfgForRunNumber) { + ph = ccdb->getForRun(cfgCCDBPath, runNum); + } else { + ph = ccdb->getForTimeStamp(cfgCCDBPath, ts); + } } void init(InitContext const&) { - if (!doprocessLoadWeights && !doprocessLoadWeightsCF) + if (!doprocessLoadWeights && !doprocessLoadWeightsCF) { return; + } + if (doprocessLoadWeights && doprocessLoadWeightsCF) LOGF(fatal, "Only one of JTracks or CFTracks processing can be enabled at a time."); - if (pathPhiWeights.value.substr(0, 8) == "local://") { - pf = new TFile(pathPhiWeights.value.substr(8).c_str(), "read"); + if (cfgPathPhiWeights.value.find("ccdb") != std::string::npos) { + LOGF(info, "Using corrections from: ccdb"); + useCCDB = true; + ccdb->setURL(cfgPathPhiWeights); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + } else if (cfgPathPhiWeights.value.substr(0, 8) == "local://") { + LOGF(info, "Using non-uniform acceptance corrections from: %s", cfgPathPhiWeights.value.substr(8).c_str()); + pf = new TFile(cfgPathPhiWeights.value.substr(8).c_str(), "read"); if (!pf->IsOpen()) { delete pf; pf = 0; - LOGF(fatal, "NUA correction weights file not found: %s", pathPhiWeights.value.substr(8).c_str()); + LOGF(fatal, "NUA correction weights file not found: %s", cfgPathPhiWeights.value.substr(8).c_str()); } + useCCDB = false; + } else { + LOGF(info, "Didn't find \"local://\" or \"ccdb\" for non-uniform acceptance corrections."); + return; + } + + if (cfgPathEffWeights.value.substr(0, 8) == "local://") { + LOGF(info, "Using efficiency corrections from: %s", cfgPathEffWeights.value.substr(8).c_str()); + pfeff = new TFile(cfgPathEffWeights.value.substr(8).c_str(), "read"); + if (!pfeff->IsOpen()) { + delete pfeff; + pfeff = 0; + LOGF(fatal, "Efficiency correction weights file not found: %s", cfgPathEffWeights.value.substr(8).c_str()); + } + // + if (!(pheff = pfeff->Get("ccdb_object"))) { + LOGF(warning, "Efficiency correction histogram not found."); + } else { + LOGF(info, "Loaded efficiency correction histogram locally."); + } + } else { + LOGF(info, "Didn't find \"local://\" or \"ccdb\" for efficiency corrections."); + return; } } template - using hasDecay = decltype(std::declval().decay()); + using HasDecay = decltype(std::declval().decay()); template void loadWeights(Produces& outputT, CollisionT const& collision, TrackT const& tracks) { - if (!pf) - LOGF(fatal, "NUA correction weights file has not been opened."); - if (collision.runNumber() != runNumber) { - if (ph) - delete ph; - if (!(ph = static_cast(pf->Get(Form("NUAWeights_%d", collision.runNumber()))))) - LOGF(warning, "NUA correction histogram not found for run %d.", collision.runNumber()); - else - LOGF(info, "Loaded NUA correction histogram for run %d.", collision.runNumber()); - runNumber = collision.runNumber(); + if (pf || useCCDB) { + if (collision.runNumber() != runNumber) { + if (ph) + delete ph; + if (!useCCDB) { + // Check if NUA correction can be found from a local file and load it + if (!(ph = pf->Get(Form("NUAWeights_%d", collision.runNumber())))) + LOGF(warning, "NUA correction histogram not found for run %d.", collision.runNumber()); + else + LOGF(info, "Loaded NUA correction histogram locally for run %d.", collision.runNumber()); + } else { + initCCDB(collision.runNumber(), timestamp); + LOGF(info, "Loaded NUA correction histogram from CCDB for run %d.", collision.runNumber()); + } + runNumber = collision.runNumber(); + } } - for (auto& track : tracks) { + for (const auto& track : tracks) { float phiWeight, effWeight; if (ph) { - UInt_t partType = 0; // partType 0 = all charged hadrons - if constexpr (std::experimental::is_detected::value) { + uint partType = 0; // partType 0 = all charged hadrons + // TODO: code below to be enabled + /*if constexpr (std::experimental::is_detected::value) { switch (track.decay()) { case aod::cf2prongtrack::D0ToPiK: case aod::cf2prongtrack::D0barToKPi: @@ -103,14 +168,23 @@ struct jflucWeightsLoader { default: break; } - } - const Double_t coords[] = {collision.multiplicity(), static_cast(partType), track.phi(), track.eta(), collision.posZ()}; + }*/ + const double coords[] = {collision.multiplicity(), static_cast(partType), track.phi(), track.eta(), collision.posZ()}; phiWeight = ph->GetBinContent(ph->GetBin(coords)); } else { phiWeight = 1.0f; } - effWeight = 1.0f; //<--- todo + if (pheff) { + const int effVars[] = { + pheff->GetAxis(0)->FindBin(track.eta()), + pheff->GetAxis(1)->FindBin(track.pt()), + pheff->GetAxis(2)->FindBin(collision.multiplicity()), + pheff->GetAxis(3)->FindBin(collision.posZ())}; + effWeight = pheff->GetBinContent(effVars); + } else { + effWeight = 1.0f; + } outputT(phiWeight, effWeight); } @@ -121,23 +195,23 @@ struct jflucWeightsLoader { { loadWeights(output, collision, tracks); } - PROCESS_SWITCH(jflucWeightsLoader, processLoadWeights, "Load weights histograms for derived data table", false); + PROCESS_SWITCH(JflucWeightsLoader, processLoadWeights, "Load weights histograms for derived data table", false); void processLoadWeightsCF(aod::CFCollision const& collision, aod::CFTracks const& tracks) { loadWeights(output, collision, tracks); } - PROCESS_SWITCH(jflucWeightsLoader, processLoadWeightsCF, "Load weights histograms for CF derived data table", true); + PROCESS_SWITCH(JflucWeightsLoader, processLoadWeightsCF, "Load weights histograms for CF derived data table", true); Produces output2p; void processLoadWeightsCF2Prong(aod::CFCollision const& collision, aod::CF2ProngTracks const& tracks2p) { loadWeights(output2p, collision, tracks2p); } - PROCESS_SWITCH(jflucWeightsLoader, processLoadWeightsCF2Prong, "Load weights histograms for CF derived 2-prong tracks data table", false); + PROCESS_SWITCH(JflucWeightsLoader, processLoadWeightsCF2Prong, "Load weights histograms for CF derived 2-prong tracks data table", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGCF/MultiparticleCorrelations/Core/MuPa-Configurables.h b/PWGCF/MultiparticleCorrelations/Core/MuPa-Configurables.h index 78adc891cf3..c1274b6788c 100644 --- a/PWGCF/MultiparticleCorrelations/Core/MuPa-Configurables.h +++ b/PWGCF/MultiparticleCorrelations/Core/MuPa-Configurables.h @@ -9,18 +9,22 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file MuPa-Configurables.h +/// \brief ... TBI 20250425 +/// \author Ante.Bilandzic@cern.ch + #ifndef PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_CONFIGURABLES_H_ #define PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_CONFIGURABLES_H_ // ... -#include #include +#include // *) Task configuration: struct : ConfigurableGroup { // std::string prefix = "Task configuration"; // AA: now these configurables also appear grouped on hyperloop => TBI 20240522 check if this work, and if further modifications in init are needed - Configurable cfTaskIsConfiguredFromJson{"cfTaskIsConfiguredFromJson", "no", "always set manaully to \"yes\" via JSON, merely to ensure that settings are not ignored silently"}; - Configurable cfTaskName{"cfTaskName", "Default task name", "set task name - use eventually to determine weights for this task"}; + Configurable cfTaskIsConfiguredFromJson{"cfTaskIsConfiguredFromJson", "no", "always set manaully to \"yes\" via JSON, merely to ensure that settings are not ignored silently"}; + Configurable cfTaskName{"cfTaskName", "Default task name", "set task name - use eventually to determine weights for this task"}; Configurable cfDryRun{"cfDryRun", false, "book all histos and run without storing and calculating anything"}; Configurable cfVerbose{"cfVerbose", false, "run or not in verbose mode (but not for simple utility functions or function calls per particle)"}; Configurable cfVerboseUtility{"cfVerboseUtility", false, "run or not in verbose mode, also for simple utility functions (but not for function calls per particle)"}; @@ -34,64 +38,75 @@ struct : ConfigurableGroup { Configurable cfUseFisherYates{"cfUseFisherYates", false, "use or not Fisher-Yates algorithm to randomize particle indices"}; Configurable cfFixedNumberOfRandomlySelectedTracks{"cfFixedNumberOfRandomlySelectedTracks", -1, "set to some integer > 0, to apply and use. Set to <=0, to ignore."}; Configurable cfUseStopwatch{"cfUseStopwatch", false, "if true, some basic info on time execution is printed, here and there. Very loosely, this can be used for execution time profiling."}; - Configurable cfFloatingPointPrecision{"cfFloatingPointPrecision", 0.000001, "two floats are the same if TMath::Abs(f1 - f2) < fFloatingPointPrecision"}; + Configurable cfFloatingPointPrecision{"cfFloatingPointPrecision", 0.000001, "two floats are the same if abs(f1 - f2) < fFloatingPointPrecision"}; Configurable cfSequentialBailout{"cfSequentialBailout", 0, "if fSequentialBailout > 0, then each fSequentialBailout events the function BailOut() is called. Can be used for real analysis and for IV"}; Configurable cfUseSpecificCuts{"cfUseSpecificCuts", false, "if true, analysis-specific cuts set via configurable cfWhichSpecificCuts are applied after DefaultCuts(). "}; - Configurable cfWhichSpecificCuts{"cfWhichSpecificCuts", "some supported set of analysis-specific cuts (e.g. LHC23zzh, ...)", "determine which set of analysis-specific cuts will be applied after DefaultCuts(). Use in combination with tc.fUseSpecificCuts"}; - + Configurable cfWhichSpecificCuts{"cfWhichSpecificCuts", "some supported set of analysis-specific cuts (e.g. LHC23zzh, ...)", "determine which set of analysis-specific cuts will be applied after DefaultCuts(). Use in combination with tc.fUseSpecificCuts"}; + Configurable cfSkipTheseRuns{"cfSkipTheseRuns", "", "Set here via comma-separated list which runs will be skipped during hl analysis (a.k.a. \"bad runs\"). Leave empty to ignore. Example format and list for LHC23zzh: \"544116,544091\""}; + Configurable cfUseSetBinLabel{"cfUseSetBinLabel", false, "until hist->SetBinLabel(...) large memory consumption is resolved, for each histogram dump all that info in the y-axis title. See also local executable PostprocessLabels.C, where I do the final bin labeling offline"}; + Configurable cfUseClone{"cfUseClone", false, "until hist->Clone(...) large memory consumption is resolved, do not use cloning. See ROOT Forum thread."}; + Configurable cfUseFormula{"cfUseFormula", false, "until TFormula large memory consumption is resolved, do not use this class. See ROOT Forum thread."}; + Configurable cfUseDatabasePDG{"cfUseDatabasePDG", false, "When enabled, there is a standard memory blow-up."}; } cf_tc; // *) QA: struct : ConfigurableGroup { Configurable cfCheckUnderflowAndOverflow{"cfCheckUnderflowAndOverflow", false, "check and bail out if in event and particle histograms there are entries which went to underflow or overflow bins (use only locally)"}; - Configurable cfRebin{"cfRebin", 1, "number of bins of selected heavy 2D histograms are devided with this number"}; + Configurable cfRebin{"cfRebin", 10, "number of bins of selected heavy 2D histograms are devided with this number"}; Configurable cfFillQAEventHistograms2D{"cfFillQAEventHistograms2D", false, "if false, all QA 2D event histograms are not filled. if true, only the ones for which fBookQAEventHistograms2D[...] is true, are filled"}; - Configurable> cfBookQAEventHistograms2D{"cfBookQAEventHistograms2D", {"1-Multiplicity_vs_ReferenceMultiplicity", "1-Multiplicity_vs_NContributors", "1-Multiplicity_vs_Centrality", "1-Multiplicity_vs_Vertex_z", "1-Multiplicity_vs_Occupancy", "1-ReferenceMultiplicity_vs_NContributors", "1-ReferenceMultiplicity_vs_Centrality", "1-ReferenceMultiplicity_vs_Vertex_z", "1-ReferenceMultiplicity_vs_Occupancy", "1-NContributors_vs_Centrality", "1-NContributors_vs_Vertex_z", "1-NContributors_vs_Occupancy", "1-Centrality_vs_Vertex_z", "1-Centrality_vs_Occupancy", "0-Centrality_vs_ImpactParameter", "1-Vertex_z_vs_Occupancy", "0-MultNTracksPV_vs_MultNTracksGlobal", "0-CentFT0C_vs_CentNTPV", "0-CentFT0M_vs_CentNTPV", "0-CentRun2V0M_vs_CentRun2SPDTracklets", "1-TrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange", "1-CurrentRunDuration_vs_InteractionRate"}, "book (1) or do not book (0) this QA 2D event histogram"}; + Configurable> cfBookQAEventHistograms2D{"cfBookQAEventHistograms2D", {"1-Multiplicity_vs_ReferenceMultiplicity", "1-Multiplicity_vs_NContributors", "1-Multiplicity_vs_Centrality", "1-Multiplicity_vs_VertexZ", "1-Multiplicity_vs_Occupancy", "1-Multiplicity_vs_InteractionRate", "1-ReferenceMultiplicity_vs_NContributors", "1-ReferenceMultiplicity_vs_Centrality", "1-ReferenceMultiplicity_vs_VertexZ", "1-ReferenceMultiplicity_vs_Occupancy", "1-ReferenceMultiplicity_vs_InteractionRate", "1-NContributors_vs_Centrality", "1-NContributors_vs_VertexZ", "1-NContributors_vs_Occupancy", "1-NContributors_vs_InteractionRate", "1-Centrality_vs_VertexZ", "1-Centrality_vs_Occupancy", "0-Centrality_vs_ImpactParameter", "1-Centrality_vs_InteractionRate", "1-VertexZ_vs_Occupancy", "1-VertexZ_vs_InteractionRate", "0-MultNTracksPV_vs_MultNTracksGlobal", "1-CentFT0C_vs_CentFT0CVariant1", "1-CentFT0C_vs_CentFT0M", "1-CentFT0C_vs_CentFV0A", "0-CentFT0C_vs_CentNTPV", "0-CentFT0C_vs_CentNGlobal", "0-CentFT0M_vs_CentNTPV", "0-CentRun2V0M_vs_CentRun2SPDTracklets", "1-TrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange", "1-CurrentRunDuration_vs_InteractionRate", "1-Multiplicity_vs_FT0CAmplitudeOnFoundBC", "1-CentFT0C_vs_FT0CAmplitudeOnFoundBC", "1-Centrality_vs_CentralitySim"}, "book (1) or do not book (0) this QA 2D event histogram"}; Configurable cfFillQAParticleHistograms2D{"cfFillQAParticleHistograms2D", false, "if false, all QA 2D particle histograms are not filled. if true, only the ones for which fBookQAParticleHistograms2D[...] is true, are filled"}; - Configurable> cfBookQAParticleHistograms2D{"cfBookQAParticleHistograms2D", {"1-Pt_vs_dcaXY"}, "book (1) or do not book (0) this QA 2D particle histogram"}; + Configurable> cfBookQAParticleHistograms2D{"cfBookQAParticleHistograms2D", {"1-Pt_vs_dcaXY"}, "book (1) or do not book (0) this QA 2D particle histogram"}; Configurable cfFillQAParticleEventHistograms2D{"cfFillQAParticleEventHistograms2D", false, "if false, all QA 2D particle event histograms are not filled. if true, only the ones for which fBookQAParticleEventHistograms2D[...] is true, are filled"}; - Configurable> cfBookQAParticleEventHistograms2D{"cfBookQAParticleEventHistograms2D", {"1-CurrentRunDuration_vs_itsNCls", "1-CurrentRunDuration_vs_itsNClsNegEtaEbyE", "1-CurrentRunDuration_vs_itsNClsPosEtaEbyE", "1-CurrentRunDuration_vs_Eta0804EbyE", "1-CurrentRunDuration_vs_Eta0400EbyE", "1-CurrentRunDuration_vs_Eta0004EbyE", "1-CurrentRunDuration_vs_Eta0408EbyE", "1-CurrentRunDuration_vs_Pt0005EbyE", "1-CurrentRunDuration_vs_Pt0510EbyE", "1-CurrentRunDuration_vs_Pt1050EbyE"}, "book (1) or do not book (0) this QA 2D particle event histogram"}; + Configurable> cfBookQAParticleEventHistograms2D{"cfBookQAParticleEventHistograms2D", {"1-CurrentRunDuration_vs_itsNCls", "1-CurrentRunDuration_vs_itsNClsNegEtaEbyE", "1-CurrentRunDuration_vs_itsNClsPosEtaEbyE", "1-CurrentRunDuration_vs_Eta0804EbyE", "1-CurrentRunDuration_vs_Eta0400EbyE", "1-CurrentRunDuration_vs_Eta0004EbyE", "1-CurrentRunDuration_vs_Eta0408EbyE", "1-CurrentRunDuration_vs_Pt0005EbyE", "1-CurrentRunDuration_vs_Pt0510EbyE", "1-CurrentRunDuration_vs_Pt1050EbyE"}, "book (1) or do not book (0) this QA 2D particle event histogram"}; + + Configurable cfFillQACorrelationsVsHistograms2D{"cfFillQACorrelationsVsHistograms2D", false, "if false, all QA 2D histograms of this category are not filled. if true, only the ones for which fBookQACorrelationsVsHistograms2D[...] is true, are filled"}; + Configurable> cfBookQACorrelationsVsHistograms2D{"cfBookQACorrelationsVsHistograms2D", {"1-Correlations_vs_Multiplicity", "1-Correlations_vs_ReferenceMultiplicity", "1-Correlations_vs_Centrality", "1-Correlations_vs_Phi", "1-Correlations_vs_Pt", "1-Correlations_vs_Eta", "1-Correlations_vs_Charge", "1-Correlations_vs_tpcNClsFindable", "1-Correlations_vs_tpcNClsShared", "1-Correlations_vs_itsChi2NCl", "1-Correlations_vs_tpcNClsFound", "1-Correlations_vs_tpcNClsCrossedRows", "1-Correlations_vs_itsNCls", "1-Correlations_vs_itsNClsInnerBarrel", "1-Correlations_vs_tpcCrossedRowsOverFindableCls", "1-Correlations_vs_tpcFoundOverFindableCls", "1-Correlations_vs_tpcFractionSharedCls", "1-Correlations_vs_tpcChi2NCl", "1-Correlations_vs_dcaXY", "1-Correlations_vs_dcaZ"}, "book (1) or do not book (0) this QA 2D histogram"}; + Configurable> cfQACorrelationsVsHistogramsMinMaxHarmonic{"cfQACorrelationsVsHistogramsMinMaxHarmonic", {1, 5}, "harmonics are filled for min <= harmonic < max"}; + + Configurable cfFillQACorrelationsVsInteractionRateVsProfiles2D{"cfFillQACorrelationsVsInteractionRateVsProfiles2D", false, "if false, all QA 2D profiles of this category are not filled. if true, only the ones for which fBookQACorrelationsVsInteractionRateVsProfiles2D[...] is true, are filled"}; + Configurable> cfBookQACorrelationsVsInteractionRateVsProfiles2D{"cfBookQACorrelationsVsInteractionRateVsProfiles2D", {"1-CorrVsIR_vs_CurrentRunDuration", "1-CorrVsIR_vs_Multiplicity", "1-CorrVsIR_vs_ReferenceMultiplicity", "1-CorrVsIR_vs_Centrality", "1-CorrVsIR_vs_MeanPhi", "1-CorrVsIR_vs_SigmaMeanPhi", "1-CorrVsIR_vs_MeanPt", "1-CorrVsIR_vs_SigmaMeanPt", "1-CorrVsIR_vs_MeanEta", "1-CorrVsIR_vs_SigmaMeanEta"}, "book (1) or do not book (0) this QA 2D profile"}; + Configurable> cfQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic{"cfQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic", {1, 5}, "harmonics are filled for min <= harmonic < max"}; } cf_qa; // *) Event histograms: struct : ConfigurableGroup { Configurable cfFillEventHistograms{"cfFillEventHistograms", true, "if false, all event histograms are not filled. if true, only the ones for which fBookEventHistograms[...] is true, are filled"}; - Configurable> cfBookEventHistograms{"cfBookEventHistograms", {"1-NumberOfEvents", "1-TotalMultiplicity", "1-Multiplicity", "1-ReferenceMultiplicity", "1-Centrality", "1-Vertex_x", "1-Vertex_y", "1-Vertex_z", "1-NContributors", "0-ImpactParameter", "0-EventPlaneAngle", "1-Occupancy", "1-InteractionRate", "1-CurrentRunDuration", "0-MultMCNParticlesEta08"}, "Book (1) or do not book (0) event histogram"}; + Configurable> cfBookEventHistograms{"cfBookEventHistograms", {"1-NumberOfEvents", "1-TotalMultiplicity", "1-Multiplicity", "1-ReferenceMultiplicity", "1-Centrality", "1-VertexX", "1-VertexY", "1-VertexZ", "1-NContributors", "0-ImpactParameter", "0-EventPlaneAngle", "1-Occupancy", "1-InteractionRate", "1-CurrentRunDuration", "0-MultMCNParticlesEta08"}, "Book (1) or do not book (0) event histogram"}; } cf_eh; // *) Event cuts: struct : ConfigurableGroup { - Configurable> cfUseEventCuts{"cfUseEventCuts", {"1-NumberOfEvents", "1-TotalMultiplicity", "1-Multiplicity", "1-ReferenceMultiplicity", "1-Centrality", "1-Vertex_x", "1-Vertex_y", "1-Vertex_z", "1-NContributors", "1-ImpactParameter", "0-EventPlaneAngle", "1-Occupancy", "1-InteractionRate", "1-CurrentRunDuration", "0-MultMCNParticlesEta08", "0-Trigger", "0-Sel7", "1-Sel8", "1-MultiplicityEstimator", "1-ReferenceMultiplicityEstimator", "1-CentralityEstimator", "1-SelectedEvents", "1-NoSameBunchPileup", "1-IsGoodZvtxFT0vsPV", "1-IsVertexITSTPC", "1-IsVertexTOFmatched", "1-IsVertexTRDmatched", "0-NoCollInTimeRangeStrict", "0-NoCollInTimeRangeStandard", "0-NoCollInRofStrict", "0-NoCollInRofStandard", "0-NoHighMultCollInPrevRof", "0-IsGoodITSLayer3", "0-IsGoodITSLayer0123", "0-IsGoodITSLayersAll", "1-OccupancyEstimator", "1-MinVertexDistanceFromIP"}, "use (1) or do not use (0) event cuts"}; + Configurable> cfUseEventCuts{"cfUseEventCuts", {"1-NumberOfEvents", "1-TotalMultiplicity", "1-Multiplicity", "1-ReferenceMultiplicity", "1-Centrality", "1-VertexX", "1-VertexY", "1-VertexZ", "1-NContributors", "1-ImpactParameter", "0-EventPlaneAngle", "1-Occupancy", "1-InteractionRate", "1-CurrentRunDuration", "0-MultMCNParticlesEta08", "0-Trigger", "0-Sel7", "1-Sel8", "1-MultiplicityEstimator", "1-ReferenceMultiplicityEstimator", "1-CentralityEstimator", "1-SelectedEvents", "1-NoSameBunchPileup", "1-IsGoodZvtxFT0vsPV", "1-IsVertexITSTPC", "1-IsVertexTOFmatched", "1-IsVertexTRDmatched", "0-NoCollInTimeRangeStrict", "0-NoCollInTimeRangeStandard", "0-NoCollInRofStrict", "0-NoCollInRofStandard", "0-NoHighMultCollInPrevRof", "0-IsGoodITSLayer3", "0-IsGoodITSLayer0123", "0-IsGoodITSLayersAll", "1-OccupancyEstimator", "1-MinVertexDistanceFromIP", "0-NoPileupTPC", "0-NoPileupFromSPD", "0-NoSPDOnVsOfPileup", "1-RefMultVsNContrUp", "1-RefMultVsNContrLow", "1-CentralityCorrelationsCut", "0-FT0Bad", "0-ITSBad", "0-ITSLimAccMCRepr", "0-TPCBadTracking", "0-TPCLimAccMCRepr", "0-TPCBadPID", "1-CentralityWeights"}, "use (1) or do not use (0) event cuts"}; Configurable cfUseEventCutCounterAbsolute{"cfUseEventCutCounterAbsolute", false, "profile and save how many times each event cut counter triggered (absolute). Use with care, as this is computationally heavy"}; Configurable cfUseEventCutCounterSequential{"cfUseEventCutCounterSequential", false, "profile and save how many times each event cut counter triggered (sequential). Use with care, as this is computationally heavy"}; Configurable cfPrintCutCounterContent{"cfPrintCutCounterContent", false, "if true, prints on the screen after each event the content of fEventCutCounterHist[*][*] (all which were booked)"}; // Remark: Preserve below the same ordering as in enum's eEventHistograms + eEventCuts. In hyperloop, in any case this ordering is lost, because there it's alphabetical TBI 20240521 check this, after I added now std::string prefix thingie - Configurable> cfNumberOfEvents{"cfNumberOfEvents", {-1, 1000000000}, "total number of events to process (whether or not they survive event cuts): {min, max}, with convention: min <= N < max"}; - Configurable> cfTotalMultiplicity{"cfTotalMultiplicity", {-1, 1000000000}, "total multiplicity range: {min, max}, with convention: min <= M < max"}; - Configurable> cfMultiplicity{"cfMultiplicity", {-1., 1000000000.}, "multiplicity (defined via cfMultiplicityEstimator) range {min, max}, with convention: min <= M < max"}; - Configurable> cfReferenceMultiplicity{"cfReferenceMultiplicity", {-1., 1000000000.}, "reference multiplicity (defined via cfReferenceMultiplicityEstimator) range {min, max}, with convention: min <= M < max"}; - Configurable> cfCentrality{"cfCentrality", {-10., 110.}, "centrality range: {min, max}, with convention: min <= cent < max"}; - Configurable> cfVertex_x{"cfVertex_x", {-10., 10.}, "vertex x position range: {min, max}[cm], with convention: min <= Vx < max"}; - Configurable> cfVertex_y{"cfVertex_y", {-10., 10.}, "vertex y position range: {min, max}[cm], with convention: min <= Vy < max"}; - Configurable> cfVertex_z{"cfVertex_z", {-10, 10.}, "vertex z position range: {min, max}[cm], with convention: min <= Vz < max"}; + Configurable> cfNumberOfEvents{"cfNumberOfEvents", {-1, 1000000000}, "total number of events to process (whether or not they survive event cuts): {min, max}, with convention: min <= N < max"}; + Configurable> cfTotalMultiplicity{"cfTotalMultiplicity", {-1, 1000000000}, "total multiplicity range: {min, max}, with convention: min <= M < max"}; + Configurable> cfMultiplicity{"cfMultiplicity", {-1., 1000000000.}, "multiplicity (defined via cfMultiplicityEstimator) range {min, max}, with convention: min <= M < max"}; + Configurable> cfReferenceMultiplicity{"cfReferenceMultiplicity", {-1., 1000000000.}, "reference multiplicity (defined via cfReferenceMultiplicityEstimator) range {min, max}, with convention: min <= M < max"}; + Configurable> cfCentrality{"cfCentrality", {-10., 110.}, "centrality range: {min, max}, with convention: min <= cent < max"}; + Configurable> cfVertexX{"cfVertexX", {-10., 10.}, "vertex x position range: {min, max}[cm], with convention: min <= Vx < max"}; + Configurable> cfVertexY{"cfVertexY", {-10., 10.}, "vertex y position range: {min, max}[cm], with convention: min <= Vy < max"}; + Configurable> cfVertexZ{"cfVertexZ", {-10, 10.}, "vertex z position range: {min, max}[cm], with convention: min <= Vz < max"}; Configurable cfMinVertexDistanceFromIP{"cfMinVertexDistanceFromIP", {0.000001}, "if sqrt(vx^2+vy^2+vz^2) < cfMinVertexDistanceFromIP [cm], the event is reject. IP = nominal Interaction Point."}; - Configurable> cfNContributors{"cfNContributors", {2, 1000000000}, "Number of vertex contributors: {min, max}, with convention: min <= N < max"}; - Configurable> cfImpactParameter{"cfImpactParameter", {-1, 1000000000}, "Impact parameter range (can be used only for sim): {min, max}, with convention: min <= IP < max"}; - Configurable> cfEventPlaneAngle{"cfEventPlaneAngle", {-o2::constants::math::PI, o2::constants::math::TwoPI}, "Event Plane Angle range (can be used only for sim): {min, max}, with convention: min <= EP < max"}; - Configurable> cfOccupancy{"cfOccupancy", {-2, 1000000000}, "Range for occupancy (use cfOccupancyEstimator to set specific estimator): {min, max}, with convention: min <= X < max"}; - Configurable> cfInteractionRate{"cfInteractionRate", {-2, 1000000000}, "Range for interaction rate: {min, max}, with convention: min <= X < max"}; - Configurable> cfCurrentRunDuration{"cfCurrentRunDuration", {-2, 1000000000}, "Range for current run duration (i.e. seconds since start of run) in seconds: {min, max}, with convention: min <= X < max. Only collisions taken in this range (measured from SOR) are taken for analysis"}; - Configurable> cfMultMCNParticlesEta08{"cfMultMCNParticlesEta08", {-1, 1000000000}, "Range for MultMCNParticlesEta08 : {min, max}, with convention: min <= X < max"}; - Configurable cfTrigger{"cfTrigger", "some supported trigger (e.g. INT7 for Run 2, TVXinTRD for Run 3, etc...)", "set here some supported trigger"}; + Configurable> cfNContributors{"cfNContributors", {2, 1000000000}, "Number of vertex contributors: {min, max}, with convention: min <= N < max"}; + Configurable> cfImpactParameter{"cfImpactParameter", {-1, 1000000000}, "Impact parameter range (can be used only for sim): {min, max}, with convention: min <= IP < max"}; + Configurable> cfEventPlaneAngle{"cfEventPlaneAngle", {-o2::constants::math::PI, o2::constants::math::TwoPI}, "Event Plane Angle range (can be used only for sim): {min, max}, with convention: min <= EP < max"}; + Configurable> cfOccupancy{"cfOccupancy", {-0.0001, 1000000000}, "Range for occupancy (use cfOccupancyEstimator to set specific estimator): {min, max}, with convention: min <= X < max. Important: remember that 0. has to be included, therefore I set -0.0001 by default for low edge"}; + Configurable> cfInteractionRate{"cfInteractionRate", {0.1, 1000000000.}, "Range for interaction rate (in kHz): {min, max}, with convention: min <= X < max"}; + Configurable> cfCurrentRunDuration{"cfCurrentRunDuration", {-2, 1000000000}, "Range for current run duration (i.e. seconds since start of run) in seconds: {min, max}, with convention: min <= X < max. Only collisions taken in this range (measured from SOR) are taken for analysis"}; + Configurable> cfMultMCNParticlesEta08{"cfMultMCNParticlesEta08", {-1, 1000000000}, "Range for MultMCNParticlesEta08 : {min, max}, with convention: min <= X < max"}; + Configurable cfTrigger{"cfTrigger", "some supported trigger (e.g. \"kINT7\" for Run 2, \"kTVXinTRD\" for Run 3, etc...)", "set here some supported trigger"}; Configurable cfUseSel7{"cfUseSel7", false, "use for Run 1 and 2 data and MC (see official doc)"}; Configurable cfUseSel8{"cfUseSel8", false, "use for Run 3 data and MC (see official doc)"}; - Configurable cfMultiplicityEstimator{"cfMultiplicityEstimator", "SelectedTracks", "all results vs. mult are calculated against this multiplicity. Can be set to SelectedTracks (calculated internally), ReferenceMultiplicity (calculated outside of my code), etc."}; - // Configurable cfReferenceMultiplicityEstimator{"cfReferenceMultiplicityEstimator", "some supported option for ref. mult. (MultFT0C, MultFV0M, MultTPC, etc.)", "Reference multiplicity, calculated outside of my code. Can be MultFT0C, MultFV0M, MultTPC, etc."}; - Configurable cfReferenceMultiplicityEstimator{"cfReferenceMultiplicityEstimator", "MultFT0C", "Reference multiplicity, calculated outside of my code. Can be MultFT0C, MultFV0M, MultTPC, etc."}; - // Configurable cfCentralityEstimator{"cfCentralityEstimator", "some supported centrality estimator (e.g. CentFT0C, ...)", "set here some supported centrality estimator (CentFT0C, CentFT0M, CentFV0A, CentNTPV, ... for Run 3, and CentRun2V0M, CentRun2SPDTracklets, ..., for Run 2 and 1) "}; - Configurable cfCentralityEstimator{"cfCentralityEstimator", "CentFT0C", "set here some supported centrality estimator (CentFT0C, CentFT0M, CentFV0A, CentNTPV, ... for Run 3, and CentRun2V0M, CentRun2SPDTracklets, ..., for Run 2 and 1) "}; - Configurable> cfSelectedEvents{"cfSelectedEvents", {-1, 1000000000}, "Selected number of events to process (i.e. only events which survive event cuts): {min, max}, with convention: min <= N < max"}; + Configurable cfMultiplicityEstimator{"cfMultiplicityEstimator", "SelectedTracks", "all results vs. mult are calculated against this multiplicity. Can be set to SelectedTracks (calculated internally), ReferenceMultiplicity (calculated outside of my code), etc."}; + Configurable cfReferenceMultiplicityEstimator{"cfReferenceMultiplicityEstimator", "MultFT0C", "Reference multiplicity, calculated outside of my code. Can be MultFT0C, MultFV0M, MultTPC, etc."}; + // Configurable cfCentralityEstimator{"cfCentralityEstimator", "some supported centrality estimator (e.g. CentFT0C, ...)", "set here some supported centrality estimator (CentFT0C, CentFT0M, CentFV0A, CentNTPV, ... for Run 3, and CentRun2V0M, CentRun2SPDTracklets, ..., for Run 2 and 1) "}; + Configurable cfCentralityEstimator{"cfCentralityEstimator", "CentFT0C", "set here some supported centrality estimator (CentFT0C, CentFT0M, CentFV0A, CentNTPV, ... for Run 3, and CentRun2V0M, CentRun2SPDTracklets, ..., for Run 2 and 1) "}; + Configurable> cfSelectedEvents{"cfSelectedEvents", {-1, 1000000000}, "Selected number of events to process (i.e. only events which survive event cuts): {min, max}, with convention: min <= N < max"}; Configurable cfUseNoSameBunchPileup{"cfUseNoSameBunchPileup", false, "TBI 20240521 explanation"}; Configurable cfUseIsGoodZvtxFT0vsPV{"cfUseIsGoodZvtxFT0vsPV", false, "TBI 20240521 explanation"}; Configurable cfUseIsVertexITSTPC{"cfUseIsVertexITSTPC", false, "TBI 20240521 explanation"}; @@ -105,45 +120,66 @@ struct : ConfigurableGroup { Configurable cfUseIsGoodITSLayer3{"cfUseIsGoodITSLayer3", false, "TBI 20241220 explanation (or see enum)"}; Configurable cfUseIsGoodITSLayer0123{"cfUseIsGoodITSLayer0123", false, "TBI 20241220 explanation (or see enum)"}; Configurable cfUseIsGoodITSLayersAll{"cfUseIsGoodITSLayersAll", false, "TBI 20241220 explanation (or see enum)"}; - Configurable cfOccupancyEstimator{"cfOccupancyEstimator", "FT0COccupancyInTimeRange", "set here some supported occupancy estimator (TrackOccupancyInTimeRange, FT0COccupancyInTimeRange, ..."}; + Configurable cfUseNoPileupTPC{"cfUseNoPileupTPC", false, "TBI 20250318 explanation"}; + Configurable cfUseNoPileupFromSPD{"cfUseNoPileupFromSPD", false, "TBI 20250318 explanation"}; + Configurable cfUseNoSPDOnVsOfPileup{"cfUseNoSPDOnVsOfPileup", false, "TBI 20250318 explanation"}; + Configurable cfOccupancyEstimator{"cfOccupancyEstimator", "FT0COccupancyInTimeRange", "set here some supported occupancy estimator (TrackOccupancyInTimeRange, FT0COccupancyInTimeRange, ..."}; + Configurable cfRefMultVsNContrUp{"cfRefMultVsNContrUp", "1200. + 0.20*x", "set here some formula in the mandatory format \"p0 + p1*x\" for the upper boundary cut in RefMult_vs_NContr correlation"}; + Configurable cfRefMultVsNContrLow{"cfRefMultVsNContrLow", "-650. + 0.08*x", "set here some in the mandatory format \"p0 + p1*x\" for the lower boundary cut in RefMult_vs_NContr correlation"}; + Configurable cfCentralityCorrelationsCut{"cfCentralityCorrelationsCut", "CentFT0C_CentFT0M", "Indicate two centrality estimators for the calculation of centrality correlation cut"}; + Configurable cfCentralityCorrelationsCutTreshold{"cfCentralityCorrelationsCutTreshold", 10.0, "set the treshold for centrality correlation cut"}; + Configurable cfCentralityCorrelationsCutVersion{"cfCentralityCorrelationsCutVersion", "Absolute", "set the version of centrality correlation cut. Supported: \"Relative\" and \"Absolute\""}; + Configurable cfUseFT0Bad{"cfUseFT0Bad", false, "TBI 20250516 explanation (or see enum)"}; + Configurable cfUseITSBad{"cfUseITSBad", false, "TBI 20250516 explanation (or see enum)"}; + Configurable cfUseITSLimAccMCRepr{"cfUseITSLimAccMCRepr", false, "TBI 20250516 explanation (or see enum)"}; + Configurable cfUseTPCBadTracking{"cfUseTPCBadTracking", false, "TBI 20250516 explanation (or see enum)"}; + Configurable cfUseTPCLimAccMCRepr{"cfUseTPCLimAccMCRepr", false, "TBI 20250516 explanation (or see enum)"}; + Configurable cfUseTPCBadPID{"cfUseTPCBadPID", false, "TBI 20250516 explanation (or see enum)"}; } cf_ec; // *) Particle histograms: struct : ConfigurableGroup { Configurable cfFillParticleHistograms{"cfFillParticleHistograms", true, "if false, all 1D particle histograms are not filled. if kTRUE, the ones for which fBookParticleHistograms[...] is kTRUE, are filled"}; - Configurable> cfBookParticleHistograms{"cfBookParticleHistograms", {"1-Phi", "1-Pt", "1-Eta", "1-Charge", "1-tpcNClsFindable", "1-tpcNClsShared", "1-tpcNClsFound", "1-tpcNClsCrossedRows", "1-itsNCls", "1-itsNClsInnerBarrel", "1-tpcCrossedRowsOverFindableCls", "1-tpcFoundOverFindableCls", "1-tpcFractionSharedCls", "1-dcaXY", "1-dcaZ", "0-PDG"}, "Book (1) or do not book (0) particle histogram"}; + Configurable> cfBookParticleHistograms{"cfBookParticleHistograms", {"1-Phi", "1-Pt", "1-Eta", "1-Charge", "1-tpcNClsFindable", "1-tpcNClsShared", "1-itsChi2NCl", "1-tpcNClsFound", "1-tpcNClsCrossedRows", "1-itsNCls", "1-itsNClsInnerBarrel", "1-tpcCrossedRowsOverFindableCls", "1-tpcFoundOverFindableCls", "1-tpcFractionSharedCls", "1-tpcChi2NCl", "1-dcaXY", "1-dcaZ", "0-PDG"}, "Book (1) or do not book (0) particle histogram"}; Configurable cfFillParticleHistograms2D{"cfFillParticleHistograms2D", false, "if false, all 2D particle histograms are not filled. if kTRUE, the ones for which fBookParticleHistograms2D[...] is kTRUE, are filled"}; - Configurable> cfBookParticleHistograms2D{"cfBookParticleHistograms2D", {"1-Phi_vs_Pt", "1-Phi_vs_Eta"}, "Book (1) or do not book (0) 2D particle histograms"}; + Configurable> cfBookParticleHistograms2D{"cfBookParticleHistograms2D", {"1-Phi_vs_Pt", "1-Phi_vs_Eta"}, "Book (1) or do not book (0) 2D particle histograms"}; + Configurable cfRebinSparse{"cfRebinSparse", 1, "used only for all fixed-length bins which are implemented directly for sparse histograms (i.e. not inherited from results histograms)"}; + Configurable> cfBookParticleSparseHistograms{"cfBookParticleSparseHistograms", {"0-DWPhi", "0-DWPt", "0-DWEta"}, "Book (1) or do not book (0) particular category of sparse histograms"}; + // TBI 20250223 add eventually configurable for FillParticleSparseHistogramsDimension } cf_ph; // *) Particle cuts: struct : ConfigurableGroup { - Configurable> cfUseParticleCuts{"cfUseParticleCuts", {"1-Phi", "1-Pt", "1-Eta", "1-Charge", "1-tpcNClsFindable", "1-tpcNClsShared", "1-tpcNClsFound", "1-tpcNClsCrossedRows", "1-itsNCls", "1-itsNClsInnerBarrel", "1-tpcCrossedRowsOverFindableCls", "1-tpcFoundOverFindableCls", "1-tpcFractionSharedCls", "1-dcaXY", "1-dcaZ", "1-PDG", "0-trackCutFlagFb1", "0-trackCutFlagFb2", "0-isQualityTrack", "0-isPrimaryTrack", "0-isInAcceptanceTrack", "0-isGlobalTrack", "0-PtDependentDCAxyParameterization"}, "Use (1) or do not use (0) particle cuts"}; + Configurable> cfUseParticleCuts{"cfUseParticleCuts", {"1-Phi", "1-Pt", "1-Eta", "1-Charge", "1-tpcNClsFindable", "1-tpcNClsShared", "1-itsChi2NCl", "1-tpcNClsFound", "1-tpcNClsCrossedRows", "1-itsNCls", "1-itsNClsInnerBarrel", "1-tpcCrossedRowsOverFindableCls", "1-tpcFoundOverFindableCls", "1-tpcFractionSharedCls", "1-tpcChi2NCl", "1-dcaXY", "1-dcaZ", "1-PDG", "0-trackCutFlag", "0-trackCutFlagFb1", "0-trackCutFlagFb2", "0-isQualityTrack", "1-isPrimaryTrack", "0-isInAcceptanceTrack", "0-isGlobalTrack", "1-isPVContributor", "0-PtDependentDCAxyParameterization"}, "Use (1) or do not use (0) particle cuts"}; Configurable cfUseParticleCutCounterAbsolute{"cfUseParticleCutCounterAbsolute", false, "profile and save how many times each particle cut counter triggered (absolute). Use with care, as this is computationally heavy"}; Configurable cfUseParticleCutCounterSequential{"cfUseParticleCutCounterSequential", false, "profile and save how many times each particle cut counter triggered (sequential). Use with care, as this is computationally heavy"}; - Configurable> cfPhi{"cfPhi", {0.0, o2::constants::math::TwoPI}, "phi range: {min, max}[rad], with convention: min <= phi < max"}; - Configurable> cfPt{"cfPt", {0.2, 5.0}, "pt range: {min, max}[GeV], with convention: min <= pt < max"}; - Configurable> cfEta{"cfEta", {-0.8, 0.8}, "eta range: {min, max}, with convention: min <= eta < max"}; - Configurable> cfCharge{"cfCharge", {-1.5, 1.5}, "particle charge. {-1.5,0} = only negative, {0,1.5} = only positive"}; - Configurable> cftpcNClsFindable{"cftpcNClsFindable", {-1000., 1000.}, "tpcNClsFindable range: {min, max}, with convention: min <= cftpcNClsFindable < max"}; - Configurable> cftpcNClsShared{"cftpcNClsShared", {-1000., 1000.}, "tpcNClsShared range: {min, max}, with convention: min <= cftpcNClsShared < max"}; - Configurable> cftpcNClsFound{"cftpcNClsFound", {70., 1000.}, "tpcNClsFound range: {min, max}, with convention: min <= cftpcNClsFound < max"}; - Configurable> cftpcNClsCrossedRows{"cftpcNClsCrossedRows", {70., 1000.}, "tpcNClsCrossedRows range: {min, max}, with convention: min <= tpcNClsCrossedRows < max"}; - Configurable> cfitsNCls{"cfitsNCls", {5., 1000.}, "itsNCls range: {min, max}, with convention: min <= itsNCls < max"}; - Configurable> cfitsNClsInnerBarrel{"cfitsNClsInnerBarrel", {-1000., 1000.}, "itsNClsInnerBarrel range: {min, max}, with convention: min <= cfitsNClsInnerBarrel < max"}; - Configurable> cftpcCrossedRowsOverFindableCls{"cftpcCrossedRowsOverFindableCls", {0.8, 1000.}, "tpcCrossedRowsOverFindableCls range: {min, max}, with convention: min <= cftpcCrossedRowsOverFindableCls < max"}; - Configurable> cftpcFoundOverFindableCls{"cftpcFoundOverFindableCls", {-1000., 1000.}, "tpcFoundOverFindableCls range: {min, max}, with convention: min <= cftpcFoundOverFindableCls < max"}; - Configurable> cftpcFractionSharedCls{"cftpcFractionSharedCls", {-1000., 0.4}, "tpcFractionSharedCls range: {min, max}, with convention: min <= cftpcFractionSharedCls < max"}; - Configurable> cfdcaXY{"cfdcaXY", {-2.4, 2.4}, "dcaXY range: {min, max}, with convention: min <= dcaXY < max (yes, DCA can be negative!)"}; - Configurable> cfdcaZ{"cfdcaZ", {-3.2, 3.2}, "dcaZ range: {min, max}, with convention: min <= dcaZ < max (yes, DCA can be negative!)"}; - Configurable> cfPDG{"cfPDG", {-5000., 5000.}, "PDG code"}; - Configurable cftrackCutFlagFb1{"cftrackCutFlagFb1", false, "TBI 20240510 add description"}; - Configurable cftrackCutFlagFb2{"cftrackCutFlagFb2", false, "TBI 20240510 add description"}; + Configurable> cfPhi{"cfPhi", {0.0, o2::constants::math::TwoPI}, "phi range: {min, max}[rad], with convention: min <= phi < max"}; + Configurable> cfPt{"cfPt", {0.2, 5.0}, "pt range: {min, max}[GeV], with convention: min <= pt < max"}; + Configurable> cfEta{"cfEta", {-0.8, 0.8}, "eta range: {min, max}, with convention: min <= eta < max"}; + Configurable> cfCharge{"cfCharge", {-1.5, 1.5}, "particle charge. {-1.5,0} = only negative, {0,1.5} = only positive"}; + Configurable> cftpcNClsFindable{"cftpcNClsFindable", {-1000., 1000.}, "tpcNClsFindable range: {min, max}, with convention: min <= cftpcNClsFindable < max"}; + Configurable> cftpcNClsShared{"cftpcNClsShared", {-1000., 1000.}, "tpcNClsShared range: {min, max}, with convention: min <= cftpcNClsShared < max"}; + Configurable> cfitsChi2NCl{"cfitsChi2NCl", {-1000., 36.}, "itsChi2NCl range: {min, max}, with convention: min <= cfitsChi2NCl < max"}; + Configurable> cftpcNClsFound{"cftpcNClsFound", {70., 1000.}, "tpcNClsFound range: {min, max}, with convention: min <= cftpcNClsFound < max"}; + Configurable> cftpcNClsCrossedRows{"cftpcNClsCrossedRows", {70., 1000.}, "tpcNClsCrossedRows range: {min, max}, with convention: min <= tpcNClsCrossedRows < max"}; + Configurable> cfitsNCls{"cfitsNCls", {5., 1000.}, "itsNCls range: {min, max}, with convention: min <= itsNCls < max"}; + Configurable> cfitsNClsInnerBarrel{"cfitsNClsInnerBarrel", {-1000., 1000.}, "itsNClsInnerBarrel range: {min, max}, with convention: min <= cfitsNClsInnerBarrel < max"}; + Configurable> cftpcCrossedRowsOverFindableCls{"cftpcCrossedRowsOverFindableCls", {0.8, 1000.}, "tpcCrossedRowsOverFindableCls range: {min, max}, with convention: min <= cftpcCrossedRowsOverFindableCls < max"}; + Configurable> cftpcFoundOverFindableCls{"cftpcFoundOverFindableCls", {0.8, 1000.}, "tpcFoundOverFindableCls range: {min, max}, with convention: min <= cftpcFoundOverFindableCls < max"}; + Configurable> cftpcFractionSharedCls{"cftpcFractionSharedCls", {-1000., 0.4}, "tpcFractionSharedCls range: {min, max}, with convention: min <= cftpcFractionSharedCls < max"}; + Configurable> cftpcChi2NCl{"cftpcChi2NCl", {-1000., 4.}, "tpcChi2NCl range: {min, max}, with convention: min <= cftpcChi2NCl < max"}; + Configurable> cfdcaXY{"cfdcaXY", {-2.4, 2.4}, "dcaXY range: {min, max}, with convention: min <= dcaXY < max (yes, DCA can be negative!)"}; + Configurable> cfdcaZ{"cfdcaZ", {-3.2, 3.2}, "dcaZ range: {min, max}, with convention: min <= dcaZ < max (yes, DCA can be negative!)"}; + Configurable> cfPDG{"cfPDG", {-5000., 5000.}, "PDG code"}; + Configurable cftrackCutFlag{"cftrackCutFlag", false, "general selection, particle cuts are tuned centrally. Use only in Run 3."}; + Configurable cftrackCutFlagFb1{"cftrackCutFlagFb1", false, "general selection + 1 point in ITS IB. Use only in Run 3."}; + Configurable cftrackCutFlagFb2{"cftrackCutFlagFb2", false, "general selection + 2 point in ITS IB. Use only in Run 3."}; Configurable cfisQualityTrack{"cfisQualityTrack", false, "TBI 20240510 add description"}; - Configurable cfisPrimaryTrack{"cfisPrimaryTrack", false, "TBI 20240510 add description"}; - Configurable cfisInAcceptanceTrack{"cfisInAcceptanceTrack", false, "TBI 20240510 add description"}; + Configurable cfisPrimaryTrack{"cfisPrimaryTrack", true, "Set to true by default both in Run 3 and Run 2 TBI 20250319 validate still for Run 1"}; + Configurable cfisInAcceptanceTrack{"cfisInAcceptanceTrack", false, "TBI 20250113 obsolete - see enum, to be removed"}; Configurable cfisGlobalTrack{"cfisGlobalTrack", false, "TBI 20240510 add description"}; - Configurable cfPtDependentDCAxyParameterization{"cfPtDependentDCAxyParameterization", "some formula TBI add some default formula, e.g. 0.0105+0.0350/x^1.1", "set here formula for pt-dependence DCAxy cut, in the following example format 0.0105+0.0350/x^1.1"}; + Configurable cfisPVContributor{"cfisPVContributor", false, "Has this track contributed to the collision vertex fit"}; + Configurable cfPtDependentDCAxyParameterization{"cfPtDependentDCAxyParameterization", "some formula TBI add some default formula, e.g. 0.0105+0.0350/x^1.1", "set here formula for pt-dependence DCAxy cut, in the following example format 0.0105+0.0350/x^1.1"}; // TBI 20240426 do I need to add separate support for booleans to use each specific cut? } cf_pc; @@ -155,45 +191,35 @@ struct : ConfigurableGroup { // *) Multiparticle correlations: struct : ConfigurableGroup { Configurable cfCalculateCorrelations{"cfCalculateCorrelations", false, "calculate or not multiparticle correlations"}; - Configurable cfCalculateCorrelationsAsFunctionOfIntegrated{"cfCalculateCorrelationsAsFunctionOfIntegrated", true, "calculate or not correlations as a function of integrated"}; - Configurable cfCalculateCorrelationsAsFunctionOfMultiplicity{"cfCalculateCorrelationsAsFunctionOfMultiplicity", true, "calculate or not correlations as a function of multiplicity"}; - Configurable cfCalculateCorrelationsAsFunctionOfCentrality{"cfCalculateCorrelationsAsFunctionOfCentrality", true, "calculate or not correlations as a function of centrality"}; - Configurable cfCalculateCorrelationsAsFunctionOfPt{"cfCalculateCorrelationsAsFunctionOfPt", false, "calculate or not correlations as a function of pt"}; - Configurable cfCalculateCorrelationsAsFunctionOfEta{"cfCalculateCorrelationsAsFunctionOfEta", false, "calculate or not correlations as a function of eta"}; - Configurable cfCalculateCorrelationsAsFunctionOfOccupancy{"cfCalculateCorrelationsAsFunctionOfOccupancy", true, "calculate or not correlations as a function of occupancy"}; - Configurable cfCalculateCorrelationsAsFunctionOfInteractionRate{"cfCalculateCorrelationsAsFunctionOfInteractionRate", true, "calculate or not correlations as a function of interaction rate"}; - Configurable cfCalculateCorrelationsAsFunctionOfCurrentRunDuration{"cfCalculateCorrelationsAsFunctionOfCurrentRunDuration", true, "calculate or not correlations as a function of current run duration (i.e. vs. seconds since start of run)"}; + Configurable> cfCalculateCorrelationsAsFunctionOf{"cfCalculateCorrelationsAsFunctionOf", {"1-Integrated", "1-Multiplicity", "1-Centrality", "0-Pt", "0-Eta", "1-Occupancy", "1-InteractionRate", "1-CurrentRunDuration", "1-Vz", "0-Charge"}, "calculate or not correlations as a function of specified variable"}; } cf_mupa; // *) Test0: struct : ConfigurableGroup { + + // 1D: Configurable cfCalculateTest0{"cfCalculateTest0", false, "calculate or not Test0"}; - Configurable cfCalculateTest0AsFunctionOfIntegrated{"cfCalculateTest0AsFunctionOfIntegrated", false, "calculate or not Test0 as a function of integrated"}; - Configurable cfCalculateTest0AsFunctionOfMultiplicity{"cfCalculateTest0AsFunctionOfMultiplicity", false, "calculate or not Test0 as a function of multiplicity"}; - Configurable cfCalculateTest0AsFunctionOfCentrality{"cfCalculateTest0AsFunctionOfCentrality", false, "calculate or not Test0 as a function of centrality"}; - Configurable cfCalculateTest0AsFunctionOfPt{"cfCalculateTest0AsFunctionOfPt", false, "calculate or not Test0 as a function of pt"}; - Configurable cfCalculateTest0AsFunctionOfEta{"cfCalculateTest0AsFunctionOfEta", false, "calculate or not Test0 as a function of eta"}; - Configurable cfCalculateTest0AsFunctionOfOccupancy{"cfCalculateTest0AsFunctionOfOccupancy", false, "calculate or not Test0 as a function of occupancy"}; - Configurable cfCalculateTest0AsFunctionOfInteractionRate{"cfCalculateTest0AsFunctionOfInteractionRate", false, "calculate or not Test0 as a function of interaction rate"}; - Configurable cfCalculateTest0AsFunctionOfCurrentRunDuration{"cfCalculateTest0AsFunctionOfCurrentRunDuration", false, "calculate or not Test0 as a function of current run duration (i.e. vs. seconds since start of run)"}; - Configurable cfFileWithLabels{"cfFileWithLabels", "/home/abilandz/DatasetsO2/labels.root", "path to external ROOT file which specifies all labels"}; // for AliEn file prepend "/alice/cern.ch/", for CCDB prepend "/alice-ccdb.cern.ch" + Configurable> cfCalculateTest0AsFunctionOf{"cfCalculateTest0AsFunctionOf", {"1-Integrated", "1-Multiplicity", "1-Centrality", "1-Pt", "1-Eta", "1-Occupancy", "1-InteractionRate", "1-CurrentRunDuration", "1-Vz", "1-Charge"}, "calculate or not correlations as a function of specified variable"}; + + // 2D: + Configurable cfCalculate2DTest0{"cfCalculate2DTest0", false, "calculate or not 2D Test0 using TProfile2D"}; + Configurable> cfCalculate2DTest0AsFunctionOf{"cfCalculate2DTest0AsFunctionOf", {"1-Centrality_Pt", "1-Centrality_Eta", "1-Centrality_Charge", "1-Centrality_Vz", "1-Pt_Eta", "1-Pt_Charge", "1-Eta_Charge"}, "calculate or not correlations in 2D as a function of two specified variables."}; + + // 3D: + Configurable cfCalculate3DTest0{"cfCalculate3DTest0", false, "calculate or not 3D Test0 using TProfile3D"}; + Configurable> cfCalculate3DTest0AsFunctionOf{"cfCalculate3DTest0AsFunctionOf", {"1-Centrality_Pt_Eta", "1-Centrality_Pt_Charge", "1-Centrality_Pt_Vz", "1-Centrality_Eta_Vz", "1-Centrality_Eta_Charge", "1-Centrality_Vz_Charge", "1-Pt_Eta_Charge"}, "calculate or not correlations in 3D as a function of three specified variables."}; + + Configurable cfFileWithLabels{"cfFileWithLabels", "/home/abilandz/DatasetsO2/labels.root", "path to external ROOT file which specifies all labels"}; // for AliEn file prepend "/alice/cern.ch/", for CCDB prepend "/alice-ccdb.cern.ch" Configurable cfUseDefaultLabels{"cfUseDefaultLabels", false, "use default internally hardwired labels, only for testing purposes"}; - Configurable cfWhichDefaultLabels{"cfWhichDefaultLabels", "standard", "only for testing purposes, select one set of default labels, see GetDefaultObjArrayWithLabels for supported options"}; + Configurable cfWhichDefaultLabels{"cfWhichDefaultLabels", "standard", "only for testing purposes, select one set of default labels, see GetDefaultObjArrayWithLabels for supported options"}; } cf_t0; // *) Eta separation: struct : ConfigurableGroup { Configurable cfCalculateEtaSeparations{"cfCalculateEtaSeparations", false, "calculate or not 2p corr. vs. eta separations"}; - Configurable cfCalculateEtaSeparationsAsFunctionOfIntegrated{"cfCalculateEtaSeparationsAsFunctionOfIntegrated", false, "calculate or not 2p corr. vs. eta separations ..."}; - Configurable cfCalculateEtaSeparationsAsFunctionOfMultiplicity{"cfCalculateEtaSeparationsAsFunctionOfMultiplicity", false, "calculate or not 2p corr. vs. eta separations as a function of multiplicity"}; - Configurable cfCalculateEtaSeparationsAsFunctionOfCentrality{"cfCalculateEtaSeparationsAsFunctionOfCentrality", false, "calculate or not 2p corr. vs. eta separations as a function of centrality"}; - Configurable cfCalculateEtaSeparationsAsFunctionOfPt{"cfCalculateEtaSeparationsAsFunctionOfPt", false, "calculate or not 2p corr. vs. eta separations as a function of pt"}; - // Configurable cfCalculateEtaSeparationsAsFunctionOfEta{"cfCalculateEtaSeparationsAsFunctionOfEta", false, "this one doesn't make sense in this context"}; - Configurable cfCalculateEtaSeparationsAsFunctionOfOccupancy{"cfCalculateEtaSeparationsAsFunctionOfOccupancy", false, "calculate or not 2p corr. vs. eta separations as a function of occupancy"}; - Configurable cfCalculateEtaSeparationsAsFunctionOfInteractionRate{"cfCalculateEtaSeparationsAsFunctionOfInteractionRate", false, "calculate or not 2p corr. vs. eta separations as a function of interaction rate"}; - Configurable cfCalculateEtaSeparationsAsFunctionOfCurrentRunDuration{"cfCalculateEtaSeparationsAsFunctionOfCurrentRunDuration", false, "calculate or not E2p corr. vs. eta separations as a function of current run duration (i.e. vs. seconds since start of run)"}; - Configurable> cfEtaSeparationsValues{"cfEtaSeparationsValues", {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}, "Eta separation between interval A (-eta) and B (+eta)"}; - Configurable> cfEtaSeparationsSkipHarmonics{"cfEtaSeparationsSkipHarmonics", {"0-v1", "0-v2", "0-v3", "0-v4", "1-v5", "1-v6", "1-v7", "1-v8", "1-v9"}, "For calculation of 2p correlation with eta separation these harmonics will be skipped (if first flag = \"0-v1\", v1 will be NOT be skipped in the calculus of 2p correlations with eta separations, etc.)"}; + Configurable> cfCalculateEtaSeparationsAsFunctionOf{"cfCalculateEtaSeparationsAsFunctionOf", {"1-Integrated", "1-Multiplicity", "1-Centrality", "1-Pt", "0-Eta", "1-Occupancy", "1-InteractionRate", "1-CurrentRunDuration", "1-Vz", "1-Charge"}, "calculate or not correlations as a function of specified variable"}; + Configurable> cfEtaSeparationsValues{"cfEtaSeparationsValues", {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}, "Eta separation between interval A (-eta) and B (+eta)"}; + Configurable> cfEtaSeparationsSkipHarmonics{"cfEtaSeparationsSkipHarmonics", {"0-v1", "0-v2", "0-v3", "0-v4", "1-v5", "1-v6", "1-v7", "1-v8", "1-v9"}, "For calculation of 2p correlation with eta separation these harmonics will be skipped (if first flag = \"0-v1\", v1 will be NOT be skipped in the calculus of 2p correlations with eta separations, etc.)"}; } cf_es; // *) Particle weights: @@ -203,13 +229,16 @@ struct : ConfigurableGroup { Configurable cfUseEtaWeights{"cfUseEtaWeights", false, "use or not eta weights"}; Configurable cfUseDiffPhiPtWeights{"cfUseDiffPhiPtWeights", false, "use or not differential phi(pt) weights"}; Configurable cfUseDiffPhiEtaWeights{"cfUseDiffPhiEtaWeights", false, "use or not differential phi(eta) weights"}; - Configurable cfFileWithWeights{"cfFileWithWeights", "/home/abilandz/DatasetsO2/weights.root", "path to external ROOT file which holds all particle weights in O2 format"}; // for AliEn file prepend "/alice/cern.ch/", for CCDB prepend "/alice-ccdb.cern.ch" + Configurable> cfWhichDiffPhiWeights{"cfWhichDiffPhiWeights", {"1-wPhi", "1-wPt", "1-wEta", "1-wCharge", "1-wCentrality", "1-wVertexZ"}, "use (1) or do not use (0) differential phi weight for particular dimension. If only phi is set to 1, integrated phi weights are used. If phi is set to 0, ALL dimensions are switched off (yes!)"}; + Configurable> cfWhichDiffPtWeights{"cfWhichDiffPtWeights", {"0-wPt", "0-wCharge", "0-wCentrality"}, "use (1) or do not use (0) differential pt weight for particular dimension. If only pt is set to 1, integrated pt weights are used. If pt is set to 0, ALL dimensions are switched off (yes!)"}; + Configurable> cfWhichDiffEtaWeights{"cfWhichDiffEtaWeights", {"0-wEta", "0-wCharge", "0-wCentrality"}, "use (1) or do not use (0) differential eta weight for particular dimension. If only eta is set to 1, integrated eta weights are used. If eta is set to 0, ALL dimensions are switched off (yes!)"}; + Configurable cfFileWithWeights{"cfFileWithWeights", "/home/abilandz/DatasetsO2/weights.root", "path to external ROOT file which holds all particle weights in O2 format"}; // for AliEn file prepend "/alice/cern.ch/", for CCDB prepend "/alice-ccdb.cern.ch" } cf_pw; // *) Centrality weights: struct : ConfigurableGroup { Configurable cfUseCentralityWeights{"cfUseCentralityWeights", false, "use or not centrality weights"}; - Configurable cfFileWithCentralityWeights{"cfFileWithCentralityWeights", "/home/abilandz/DatasetsO2/centralityWeights.root", "path to external ROOT file which holds centrality weights in O2 format"}; // for AliEn file prepend "/alice/cern.ch/", for CCDB prepend "/alice-ccdb.cern.ch" + Configurable cfFileWithCentralityWeights{"cfFileWithCentralityWeights", "/home/abilandz/DatasetsO2/centralityWeights.root", "path to external ROOT file which holds centrality weights in O2 format"}; // for AliEn file prepend "/alice/cern.ch/", for CCDB prepend "/alice-ccdb.cern.ch" } cf_cw; // *) Nested loops: @@ -222,10 +251,10 @@ struct : ConfigurableGroup { // *) Toy NUA: struct : ConfigurableGroup { - Configurable> cfApplyNUAPDF{"cfApplyNUAPDF", {0, 0, 0}, "Apply (1) or do not apply (0) NUA on variable, ordering is the same as in enum eNUAPDF (phi, pt, eta)"}; - Configurable> cfUseDefaultNUAPDF{"cfUseDefaultNUAPDF", {1, 1, 1}, "Use (1) or do not use (0) default NUA profile, ordering is the same as in enum eNUAPDF (phi, pt, eta)"}; - Configurable> cfCustomNUAPDFHistNames{"cfCustomNUAPDFHistNames", {"a", "bb", "ccc"}, "the names of histograms holding custom NUA in an external file."}; - Configurable cfFileWithCustomNUA{"cfFileWithCustomNUA", "/home/abilandz/DatasetsO2/customNUA.root", "path to external ROOT file which holds all histograms with custom NUA"}; // for AliEn file prepend "/alice/cern.ch/", for CCDB prepend "/alice-ccdb.cern.ch" + Configurable> cfApplyNUAPDF{"cfApplyNUAPDF", {0, 0, 0}, "Apply (1) or do not apply (0) NUA on variable, ordering is the same as in enum eNUAPDF (phi, pt, eta)"}; + Configurable> cfUseDefaultNUAPDF{"cfUseDefaultNUAPDF", {1, 1, 1}, "Use (1) or do not use (0) default NUA profile, ordering is the same as in enum eNUAPDF (phi, pt, eta)"}; + Configurable> cfCustomNUAPDFHistNames{"cfCustomNUAPDFHistNames", {"a", "bb", "ccc"}, "the names of histograms holding custom NUA in an external file."}; + Configurable cfFileWithCustomNUA{"cfFileWithCustomNUA", "/home/abilandz/DatasetsO2/customNUA.root", "path to external ROOT file which holds all histograms with custom NUA"}; // for AliEn file prepend "/alice/cern.ch/", for CCDB prepend "/alice-ccdb.cern.ch" } cf_nua; // *) Internal validation: @@ -233,11 +262,12 @@ struct : ConfigurableGroup { Configurable cfUseInternalValidation{"cfUseInternalValidation", false, "perform internal validation using flow analysis on-the-fly"}; Configurable cfInternalValidationForceBailout{"cfInternalValidationForceBailout", false, "force bailout (use only locally, since there is no graceful exit (yet))"}; Configurable cfnEventsInternalValidation{"cfnEventsInternalValidation", 0, "number of events simulated on-the-fly for internal validation"}; - Configurable cfHarmonicsOptionInternalValidation{"cfHarmonicsOptionInternalValidation", "constant", "for internal validation, set whether flow amplitudes are \"constant\" or \"correlated\""}; + Configurable cfHarmonicsOptionInternalValidation{"cfHarmonicsOptionInternalValidation", "constant", "for internal validation, supported options are \"constant\", \"correlated\" and \"persistent\""}; Configurable cfRescaleWithTheoreticalInput{"cfRescaleWithTheoreticalInput", false, "if kTRUE, all correlators are rescaled with theoretical input, so that all results in profiles are 1"}; - Configurable> cfInternalValidationAmplitudes{"cfInternalValidationAmplitudes", {0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09}, "{v1, v2, v3, v4, ...} + has an effect only in combination with cfHarmonicsOptionInternalValidation = \"constant\". Max number of vn's is gMaxHarmonic."}; - Configurable> cfInternalValidationPlanes{"cfInternalValidationPlanes", {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, "{Psi1, Psi2, Psi3, Psi4, ...} + has an effect only in combination with cfHarmonicsOptionInternalValidation = \"constant\". Max number of Psin's is gMaxHarmonic."}; - Configurable> cfMultRangeInternalValidation{"cfMultRangeInternalValidation", {1000, 1001}, "{min, max}, with convention: min <= M < max"}; + Configurable cfRandomizeReactionPlane{"cfRandomizeReactionPlane", true, "set to false only when validating against theoretical value the non-isotropic correlators"}; + Configurable> cfInternalValidationAmplitudes{"cfInternalValidationAmplitudes", {0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09}, "{v1, v2, v3, v4, ...} + has an effect only in combination with cfHarmonicsOptionInternalValidation = \"constant\". Max number of vn's is gMaxHarmonic."}; + Configurable> cfInternalValidationPlanes{"cfInternalValidationPlanes", {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, "{Psi1, Psi2, Psi3, Psi4, ...} + has an effect only in combination with cfHarmonicsOptionInternalValidation = \"constant\". Max number of Psin's is gMaxHarmonic."}; + Configurable> cfMultRangeInternalValidation{"cfMultRangeInternalValidation", {1000, 1001}, "{min, max}, with convention: min <= M < max"}; } cf_iv; // *) Results histograms: @@ -245,29 +275,32 @@ struct : ConfigurableGroup { Configurable cfSaveResultsHistograms{"cfSaveResultsHistograms", false, "save or not results histograms"}; // Fixed-length binning (default): - Configurable> cfFixedLength_mult_bins{"cfFixedLength_mult_bins", {2000, 0., 20000.}, "nMultBins, multMin, multMax (only for results histograms)"}; - Configurable> cfFixedLength_cent_bins{"cfFixedLength_cent_bins", {110, 0., 110.}, "nCentBins, centMin, centMax (only for results histograms)"}; - Configurable> cfFixedLength_pt_bins{"cfFixedLength_pt_bins", {1000, 0., 10.}, "nPtBins, ptMin, ptMax (only for results histograms)"}; - Configurable> cfFixedLength_eta_bins{"cfFixedLength_eta_bins", {80, -2., 2.}, "nEtaBins, etaMin, etaMax (only for results histograms)"}; - Configurable> cfFixedLength_occu_bins{"cfFixedLength_occu_bins", {200, 0., 60000.}, "nOccuBins, occuMin, occuMax (only for results histograms)"}; - Configurable> cfFixedLength_ir_bins{"cfFixedLength_ir_bins", {1000, 0., 100.}, "nirBins, irMin, irMax (only for results histograms)"}; - Configurable> cfFixedLength_crd_bins{"cfFixedLength_crd_bins", {1000, 0., 10000.}, "nrdBins, rdMin, rdMax (only for results histograms)"}; + Configurable> cfFixedLengthMultBins{"cfFixedLengthMultBins", {2000, 0., 20000.}, "nMultBins, multMin, multMax (only for results histograms)"}; + Configurable> cfFixedLengthCentBins{"cfFixedLengthCentBins", {110, 0., 110.}, "nCentBins, centMin, centMax (only for results histograms)"}; + Configurable> cfFixedLengthPtBins{"cfFixedLengthPtBins", {1000, 0., 10.}, "nPtBins, ptMin, ptMax (only for results histograms)"}; + Configurable> cfFixedLengthEtaBins{"cfFixedLengthEtaBins", {80, -2., 2.}, "nEtaBins, etaMin, etaMax (only for results histograms)"}; + Configurable> cfFixedLengthOccuBins{"cfFixedLengthOccuBins", {200, 0., 60000.}, "nOccuBins, occuMin, occuMax (only for results histograms)"}; + Configurable> cfFixedLengthIRBins{"cfFixedLengthIRBins", {1000, 0., 100.}, "nirBins, irMin, irMax (only for results histograms)"}; + Configurable> cfFixedLengthCRDBins{"cfFixedLengthCRDBins", {100000, 0., 100000.}, "ncrdBins, crdMin, crdMax (only for results histograms)"}; + Configurable> cfFixedLengthVzBins{"cfFixedLengthVzBins", {400, -20., 20.}, "nvzBins, vzMin, vzMax (only for results histograms)"}; // Variable-length binning (per request): - Configurable cfUseVariableLength_mult_bins{"cfUseVariableLength_mult_bins", false, "use or not variable-length multiplicity bins"}; - Configurable> cfVariableLength_mult_bins{"cfVariableLength_mult_bins", {0., 5., 6., 7., 8., 9., 100., 200., 500., 1000., 10000.}, "variable-length multiplicity bins"}; - Configurable cfUseVariableLength_cent_bins{"cfUseVariableLength_cent_bins", false, "use or not variable-length centrality bins"}; - Configurable> cfVariableLength_cent_bins{"cfVariableLength_cent_bins", {0., 10., 50., 100.}, "variable-length centrality bins"}; - Configurable cfUseVariableLength_pt_bins{"cfUseVariableLength_pt_bins", true, "use or not variable-length pt bins"}; - Configurable> cfVariableLength_pt_bins{"cfVariableLength_pt_bins", {0.20, 0.25, 0.30, 0.35, 0.40, 0.50, 0.60, 0.80, 1.00, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00, 4.00, 5.00}, "variable-length pt bins"}; - Configurable cfUseVariableLength_eta_bins{"cfUseVariableLength_eta_bins", true, "use or not variable-length eta bins"}; - Configurable> cfVariableLength_eta_bins{"cfVariableLength_eta_bins", {-0.8, -0.6, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.6, 0.8}, "variable-length eta bins"}; - Configurable cfUseVariableLength_occu_bins{"cfUseVariableLength_occu_bins", false, "use or not variable-length occupancy bins"}; - Configurable> cfVariableLength_occu_bins{"cfVariableLength_occu_bins", {0., 5., 6., 7., 8., 9., 100., 200., 500., 1000., 10000.}, "variable-length occupancy bins"}; - Configurable cfUseVariableLength_ir_bins{"cfUseVariableLength_ir_bins", false, "use or not variable-length interaction rate bins"}; - Configurable> cfVariableLength_ir_bins{"cfVariableLength_ir_bins", {0., 5., 10., 50., 100., 200.}, "variable-length ineraction rate bins"}; - Configurable cfUseVariableLength_crd_bins{"cfUseVariableLength_crd_bins", false, "use or not variable-length current run duration bins"}; - Configurable> cfVariableLength_crd_bins{"cfVariableLength_crd_bins", {0., 5., 10., 50., 100., 500.}, "variable-length current run duration bins"}; + Configurable cfUseVariableLengthMultBins{"cfUseVariableLengthMultBins", false, "use or not variable-length multiplicity bins"}; + Configurable> cfVariableLengthMultBins{"cfVariableLengthMultBins", {0., 5., 6., 7., 8., 9., 100., 200., 500., 1000., 10000.}, "variable-length multiplicity bins"}; + Configurable cfUseVariableLengthCentBins{"cfUseVariableLengthCentBins", false, "use or not variable-length centrality bins"}; + Configurable> cfVariableLengthCentBins{"cfVariableLengthCentBins", {0., 10., 50., 100.}, "variable-length centrality bins"}; + Configurable cfUseVariableLengthPtBins{"cfUseVariableLengthPtBins", true, "use or not variable-length pt bins"}; + Configurable> cfVariableLengthPtBins{"cfVariableLengthPtBins", {0.20, 0.25, 0.30, 0.35, 0.40, 0.50, 0.60, 0.80, 1.00, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00, 4.00, 5.00}, "variable-length pt bins"}; + Configurable cfUseVariableLengthEtaBins{"cfUseVariableLengthEtaBins", true, "use or not variable-length eta bins"}; + Configurable> cfVariableLengthEtaBins{"cfVariableLengthEtaBins", {-0.8, -0.6, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.6, 0.8}, "variable-length eta bins"}; + Configurable cfUseVariableLengthOccuBins{"cfUseVariableLengthOccuBins", false, "use or not variable-length occupancy bins"}; + Configurable> cfVariableLengthOccuBins{"cfVariableLengthOccuBins", {0., 5., 6., 7., 8., 9., 100., 200., 500., 1000., 10000.}, "variable-length occupancy bins"}; + Configurable cfUseVariableLengthIRBins{"cfUseVariableLengthIRBins", false, "use or not variable-length interaction rate bins"}; + Configurable> cfVariableLengthIRBins{"cfVariableLengthIRBins", {0., 5., 10., 50., 100., 200.}, "variable-length ineraction rate bins"}; + Configurable cfUseVariableLengthCRDBins{"cfUseVariableLengthCRDBins", false, "use or not variable-length current run duration bins"}; + Configurable> cfVariableLengthCRDBins{"cfVariableLengthCRDBins", {0., 5., 10., 50., 100., 500.}, "variable-length current run duration bins"}; + Configurable cfUseVariableLengthVzBins{"cfUseVariableLengthVzBins", false, "use or not variable-length vertex z bins"}; + Configurable> cfVariableLengthVzBins{"cfVariableLengthVzBins", {-10., -8., -6., -4, -2., -1., 0., 1., 2., 4., 6., 8., 10.}, "variable-length vertex z bins"}; } cf_res; diff --git a/PWGCF/MultiparticleCorrelations/Core/MuPa-DataMembers.h b/PWGCF/MultiparticleCorrelations/Core/MuPa-DataMembers.h index b09eb50a02d..fff7cd5fdee 100644 --- a/PWGCF/MultiparticleCorrelations/Core/MuPa-DataMembers.h +++ b/PWGCF/MultiparticleCorrelations/Core/MuPa-DataMembers.h @@ -9,9 +9,15 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file MuPa-DataMembers.h +/// \brief ... TBI 20250425 +/// \author Ante.Bilandzic@cern.ch + #ifndef PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_DATAMEMBERS_H_ #define PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_DATAMEMBERS_H_ +#include + // General remarks: // 0. Starting with C++11, it's possible to initialize data members at declaration, so I do it here // 1. Use //! fBaseList{sBaseListName.Data(), OutputObjHandlingPolicy::AnalysisObject, OutputObjSourceType::OutputObjSource}; -TProfile* fBasePro = NULL; //! 0. Set to <=0 to ignore. - Bool_t fUseStopwatch = kFALSE; // do some basing profiling with TStopwatch for where the execution time is going - TStopwatch* fTimer[eTimer_N] = {NULL}; // stopwatch, global (overal execution time) and local - Float_t fFloatingPointPrecision = 1.e-6; // two floats are the same if TMath::Abs(f1 - f2) < fFloatingPointPrecision (there is configurable for it) - Int_t fSequentialBailout = 0; // if fSequentialBailout > 0, then each fSequentialBailout events the function BailOut() is called. Can be used for real analysis and for IV. - bool fUseSpecificCuts = kFALSE; // apply after DefaultCuts() also hardwired analysis-specific cuts, determined via tc.fWhichSpecificCuts - TString fWhichSpecificCuts = ""; // determine which set of analysis-specific cuts will be applied after DefaultCuts(). Use in combination with tc.fUseSpecificCuts -} tc; // "tc" labels an instance of this group of variables. + TString fTaskIsConfiguredFromJson = "no"; // the trick to ensure that settings from JSON are taken into account, even if only one configurable is misconfigured, when everything dies silently + TString fTaskName = ""; // task name - this one is used to get the right weights programatically for this analysis. + // If not set, weights are fetched from TDirectoryFile whose name ends with "multiparticle-correlations-a-b" (default) + // If set to "someName", weights are fetched from TDirectoryFile whose name ends with "multiparticle-correlations-a-b_someName" + // TBI 20250122 Therefore, when running in HL, it's important to configure manually cfTaskName to be exactly the same as subwagon name. + // Can I automate this? + TString fRunNumber = ""; // over which run number this task is executed + bool fRunNumberIsDetermined = false; // ensures that run number is determined in process() and propagated to already booked objects only once + int64_t fRunTime[eRunTime_N] = {0}; // stores permanently start of run, end of run, and run duration + bool fDryRun = false; // book all histos and run without storing and calculating anything + bool fVerbose = false; // print additional info during debugging, but not for simply utility function or function calls per particle (see next) + bool fVerboseUtility = false; // print additional info during debugging also for simply utility function, but not for function calls per particle (see next) + bool fVerboseForEachParticle = false; // print additional info during debugging, also for function calls per particle + bool fVerboseEventCounter = true; // print or not only event counter + bool fVerboseEventCut = true; // print or not only which event cut didn't survive + bool fPlainPrintout = false; // print in color or in plain (use the latter in HL) + bool fDoAdditionalInsanityChecks = false; // do additional insanity checks at run time, at the expense of losing a bit of performance + // (for instance, check if the run number in the current 'collision' is the same as run number in the first 'collision', etc.) + bool fInsanityCheckForEachParticle = false; // do additional insanity checks at run time for each particle, at the expense of losing a lot of performance. Use only during debugging. + bool fProcess[eProcess_N] = {false}; // set what to process. See enum eProcess for full description. Set via implicit variables within a PROCESS_SWITCH clause. + TString fWhichProcess = "ProcessRec"; // dump in this variable which process was used + unsigned int fRandomSeed = 0; // argument for TRandom3 constructor. By default it is 0 (seed is guaranteed to be unique in time and space) + bool fUseFisherYates = false; // algorithm used to randomize particle indices, set via configurable + TArrayI* fRandomIndices = NULL; // array to store random indices obtained from Fisher-Yates algorithm + int fFixedNumberOfRandomlySelectedTracks = -1; // use a fixed number of randomly selected particles in each event, applies to all centralities. It is set and applied if > 0. Set to <=0 to ignore. + + bool fUseStopwatch = false; // do some basing profiling with TStopwatch for where the execution time is going + TStopwatch* fTimer[eTimer_N] = {NULL}; // stopwatch, global (overal execution time) and local + float fFloatingPointPrecision = 1.e-6; // two floats are the same if abs(f1 - f2) < fFloatingPointPrecision (there is configurable for it) + int fSequentialBailout = 0; // if fSequentialBailout > 0, then each fSequentialBailout events the function BailOut() is called. Can be used for real analysis and for IV. + bool fUseSpecificCuts = false; // apply after DefaultCuts() also hardwired analysis-specific cuts, determined via tc.fWhichSpecificCuts + TString fWhichSpecificCuts = ""; // determine which set of analysis-specific cuts will be applied after DefaultCuts(). Use in combination with tc.fUseSpecificCuts + TString fSkipTheseRuns = ""; // comma-separated list of runs which will be skipped during analysis in hl (a.k.a. "bad runs") + bool fSkipRun = false; // based on the content of fWhichSpecificCuts, skip or not the current run + TDatabasePDG* fDatabasePDG = NULL; // booked only when MC info is available. There is a standard memory blow-up when booked, therefore I need to request also fUseDatabasePDG = true + // TBI 20250625 replace eventually with the service O2DatabasePDG, when memory consumption problem is resolved + bool fUseSetBinLabel = false; // until SetBinLabel(...) large memory consumption is resolved, do not use hist->SetBinLabel(...), see ROOT Forum + // See also local executable PostprocessLabels.C + bool fUseClone = false; // until Clone(...) large memory consumption is resolved, do not use hist->Clone(...), see ROOT Forum + bool fUseFormula = false; // until TFormula large memory consumption is resolved, do not use, see ROOT Forum + bool fUseDatabasePDG = false; // I use it at the moment only to retreive charge for MC particle from its PDG code, because there is no direct getter mcParticle.sign() + // But most likely I will use it to retrieve other particle proprties from PDG table. There is a standard memory blow-up when used. +} tc; // "tc" labels an instance of this group of variables. // *) Event-by-event quantities: struct EventByEventQuantities { - Int_t fSelectedTracks = 0; // integer counter of tracks used to calculate Q-vectors, after all particle cuts have been applied - Float_t fMultiplicity = 0.; // my internal multiplicity, can be set to fSelectedTracks (calculated internally), fReferenceMultiplicity (calculated outside of my code), etc. - // Results "vs. mult" are plotted against fMultiplicity, whatever it is set to. - // Use configurable cfMultiplicityEstimator[eMultiplicityEstimator] to define what is this multiplicity, by default it is "SelectedTracks" - Float_t fReferenceMultiplicity = 0.; // reference multiplicity, calculated outside of my code. Can be "MultTPC", "MultFV0M", etc. - // Use configurable cfReferenceMultiplicityEstimator[eReferenceMultiplicityEstimator]" to define what is this multiplicity, by default it is "TBI 20241123 I do not know yet which estimator is best for ref. mult." - Float_t fCentrality = 0.; // event-by-event centrality. Value of the default centrality estimator, set via configurable cfCentralityEstimator - Float_t fOccupancy = 0.; // event-by-event occupancy. Value of the default occupancy estimator, set via configurable cfOccupancyEstimator - Float_t fInteractionRate = 0.; // event-by-event interaction rate - Float_t fCurrentRunDuration = 0.; // how many seconds after start of run this collision was taken, i.e. seconds after start of run (SOR) -} ebye; // "ebye" is a common label for objects in this struct + int fSelectedTracks = 0; // integer counter of tracks used to calculate Q-vectors, after all particle cuts have been applied + float fMultiplicity = 0.; // my internal multiplicity, can be set to fSelectedTracks (calculated internally), fReferenceMultiplicity (calculated outside of my code), etc. + // Results "vs. mult" are plotted against fMultiplicity, whatever it is set to. + // Use configurable cfMultiplicityEstimator[eMultiplicityEstimator] to define what is this multiplicity, by default it is "SelectedTracks" + float fReferenceMultiplicity = 0.; // reference multiplicity, calculated outside of my code. Can be "MultTPC", "MultFV0M", etc. + // Use configurable cfReferenceMultiplicityEstimator[eReferenceMultiplicityEstimator]" to define what is this multiplicity, by default it is "TBI 20241123 I do not know yet which estimator is best for ref. mult." + float fCentrality = 0.; // event-by-event centrality, in reconstructed data. Value of the default centrality estimator, set via configurable cfCentralityEstimator + float fCentralitySim = 0.; // event-by-event centrality, in simulated data. Calculated directly from IP at the moment, eventually I will access it from o2::aod::hepmcheavyion::Centrality + float fOccupancy = 0.; // event-by-event occupancy. Value of the default occupancy estimator, set via configurable cfOccupancyEstimator. + // Remebmer that collision with occupanct 0. shall NOT be rejected, therefore in configurable I set -0.0001 for low edge by default. + float fInteractionRate = 0.; // event-by-event interaction rate + float fCurrentRunDuration = 0.; // how many seconds after start of run this collision was taken, i.e. seconds after start of run (SOR) + float fVz = 0.; // vertex z position + float fFT0CAmplitudeOnFoundBC = 0.; // TBI20250331 finalize the comment here + float fImpactParameter = 0.; // calculated only for simulated/generated data +} ebye; // "ebye" is a common label for objects in this struct // *) QA: // Remark 1: I keep new histograms in this group, until I need them permanently in the analysis. Then, they are moved to EventHistograms or ParticleHistograms (yes, even if they are 2D). // Remark 2: All 2D histograms book as TH2F, due to "stmem error" in terminate (see .cxx for further details) struct QualityAssurance { - TList* fQAList = NULL; //! event-by-event - // [reco, sim][before, after]. Type dimension is bin. - - Float_t fReferenceMultiplicity[eReferenceMultiplicityEstimators_N] = {0.}; // used mostly in QA correlation plots + TList* fQAEventList = NULL; //! event-by-event + // [reco, sim][before, after]. Type dimension is bin. + + TList* fQACorrelationsVsList = NULL; //!>>>> fqvector; // dynamically allocated differential q-vector => it has to be done this way, to optimize memory usage + // dimensions: [eqvectorKine_N][gMaxNoBinsKine][gMaxHarmonic * gMaxCorrelator + 1][gMaxCorrelator + 1] + std::vector fNumberOfKineBins = {0}; // for each kine vector which was requested in this analysis, here I calculate and store the corresponding number of kine bins + std::vector> fqvectorEntries; // dynamically allocated number of entries for differential q-vector => it has to be done this way, to optimize memory usage + + // q-vectors for eta separations: + TComplex fQabVector[2][gMaxHarmonic][gMaxNumberEtaSeparations] = {{{TComplex(0., 0.)}}}; //! integrated [-eta or +eta][harmonic][eta separation] + float fMab[2][gMaxNumberEtaSeparations] = {{0.}}; //! multiplicities in 2 eta separated intervals + TH1F* fMabDist[2][2][2][gMaxNumberEtaSeparations] = {{{{NULL}}}}; // multiplicity distributions in A and B, for each eta separation [ A or B ] [rec or sim] [ before or after cuts ] [ eta separation value ] + std::vector>>>>> fqabVector; // dynamically allocated differential q-vector. + // dimensions: [-eta or +eta][eqvectorKine_N][global binNo][harmonic][eta separation] + // Remark: Unlike fqvector above, here I support only 2-p correlations, + // therefore no need for "[gMaxHarmonic * gMaxCorrelator + 1][gMaxCorrelator + 1]", etc. + std::vector>>> fmab; //! multiplicities vs kine in 2 eta separated intervals + // [-eta or +eta][eqvectorKine_N][global binNo][eta separation] +} qv; // "qv" is a common label for objects in this struct // *) Multiparticle correlations (standard, isotropic, same harmonic): struct MultiparticleCorrelations { @@ -219,8 +296,8 @@ struct MultiparticleCorrelations { bool fCalculateCorrelations = false; // calculate and store integrated correlations TProfile* fCorrelationsPro[4][gMaxHarmonic][eAsFunctionOf_N] = {{{NULL}}}; //! multiparticle correlations // [2p=0,4p=1,6p=2,8p=3][n=1,n=2,...,n=gMaxHarmonic] - // [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta,5=vs. occupancy] - Bool_t fCalculateCorrelationsAsFunctionOf[eAsFunctionOf_N] = {false}; //! [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta,5=vs. occupancy, ...] + // [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta,5=vs. occupancy, ...] + bool fCalculateCorrelationsAsFunctionOf[eAsFunctionOf_N] = {false}; //! [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta,5=vs. occupancy, ...] // As of 20241111, 3=pT and 4=eta are not implemented, see void CalculateKineCorrelations(...) } mupa; // "mupa" is a common label for objects in this struct @@ -228,81 +305,98 @@ struct MultiparticleCorrelations { struct ParticleWeights { TList* fWeightsList = NULL; //! TBI 20250215 this is obsolete and superseeded with fUseDiffPhiWeights, etc. + TH1D* fDiffWeightsHist[eDiffWeights_N][gMaxBinsDiffWeights] = {{NULL}}; // histograms holding differential weights [phipt,phieta][bin number] => TBI 20250222 obsolete + + // ** sparse histograms: + THnSparse* fDiffWeightsSparse[eDiffWeightCategory_N] = {NULL}; // multidimensional sparse histogram to hold all differential phi-weights (as a function of pt, eta, etc.). + // each dimension has its own enum category, e.g. 0 = eDWPhi => eDiffPhiWeights, 1 = eDWPt => eDiffPtWeights, etc. + bool fUseDiffPhiWeights[eDiffPhiWeights_N] = {false}; // use differential phi weights, see enum eDiffPhiWeights for supported dimensions + bool fUseDiffPtWeights[eDiffPtWeights_N] = {false}; // use differential pt weights, see enum eDiffPtWeights for supported dimensions + bool fUseDiffEtaWeights[eDiffEtaWeights_N] = {false}; // use differential eta weights, see enum eDiffEtaWeights for supported dimensions + // ... + int fDWdimension[eDiffWeightCategory_N] = {0}; // dimension of differential weight for each category in current analysis + TArrayD* fFindBinVector[eDiffWeightCategory_N] = {NULL}; // this is the vector I use to find bin TBI 20250224 finalie description + + TString fFileWithWeights = ""; // path to external ROOT file which holds all particle weights + bool fParticleWeightsAreFetched = false; // ensures that particle weights are fetched only once +} pw; // "pw" labels an instance of this group of histograms // *) Centrality weights: struct CentralityWeights { - TList* fCentralityWeightsList = NULL; // list to hold all Q-vector objects - TProfile* fCentralityWeightsFlagsPro = NULL; // profile to hold all flags for CentralityWeights - Bool_t fUseCentralityWeights = false; // use centrality weights - TH1D* fCentralityWeightsHist = NULL; // histograms holding centrality weights - TString fFileWithCentralityWeights = ""; // path to external ROOT file which holds all centrality weights - Bool_t fCentralityWeightsAreFetched = kFALSE; // ensures that centrality weights are fetched only once + TList* fCentralityWeightsList = NULL; // list to hold all Q-vector objects + TProfile* fCentralityWeightsFlagsPro = NULL; // profile to hold all flags for CentralityWeights + bool fUseCentralityWeights = false; // use centrality weights + TH1D* fCentralityWeightsHist = NULL; // histograms holding centrality weights + TString fFileWithCentralityWeights = ""; // path to external ROOT file which holds all centrality weights + bool fCentralityWeightsAreFetched = false; // ensures that centrality weights are fetched only once } cw; // *) Nested loops: struct NestedLoops { TList* fNestedLoopsList = NULL; // list to hold all nested loops objects TProfile* fNestedLoopsFlagsPro = NULL; // profile to hold all flags for nested loops - Bool_t fCalculateNestedLoops = kFALSE; // calculate and store correlations with nested loops, as a cross-check - Bool_t fCalculateCustomNestedLoops = kFALSE; // validate e-b-e all correlations with custom nested loop - Bool_t fCalculateKineCustomNestedLoops = kFALSE; // validate e-b-e all differential (vs pt, eta, etc.) correlations with custom nested loop - Int_t fMaxNestedLoop = -1; // if set to e.g. 4, all nested loops beyond that, e.g. 6-p and 8-p, are NOT calculated + bool fCalculateNestedLoops = false; // calculate and store correlations with nested loops, as a cross-check + bool fCalculateCustomNestedLoops = false; // validate e-b-e all correlations with custom nested loop + bool fCalculateKineCustomNestedLoops = false; // validate e-b-e all differential (vs pt, eta, etc.) correlations with custom nested loop + int fMaxNestedLoop = -1; // if set to e.g. 4, all nested loops beyond that, e.g. 6-p and 8-p, are NOT calculated TProfile* fNestedLoopsPro[4][gMaxHarmonic][eAsFunctionOf_N] = {{{NULL}}}; //! multiparticle correlations from nested loops //! [2p=0,4p=1,6p=2,8p=3][n=1,n=2,...,n=gMaxHarmonic][0=integrated,1=vs. //! multiplicity,2=vs. centrality,3=pT,4=eta] TArrayD* ftaNestedLoops[2] = {NULL}; //! e-b-e container for nested loops [0=angles;1=product of all weights] - TArrayD* ftaNestedLoopsKine[eqvectorKine_N][gMaxNoBinsKine][2] = {{{NULL}}}; //! e-b-e container for nested loops // [0=pT,1=eta][kine bin][0=angles;1=product of all weights] + TArrayD* ftaNestedLoopsKine[eqvectorKine_N][gMaxNoBinsKine][2] = {{{NULL}}}; //! e-b-e container for nested loops // [0=pT,1=eta,2=...][kine bin][0=angles;1=product of all weights] } nl; // "nl" labels an instance of this group of histograms -// *) Toy NUA (can be applied both in real data analysis and in analysis 'on-the-fly'): +// *) Toy NUA (can be applied both in real data analysis and in analysis 'on-the-fly', e.g. when running internal validation): struct NUA { - TList* fNUAList = NULL; // list to hold all NUA objects - TProfile* fNUAFlagsPro = NULL; // profile to hold all flags for NUA objects - Bool_t fApplyNUAPDF[eNUAPDF_N] = {kFALSE}; // apply NUA to particular kine variable (see the corresponding enum eNUAPDF) - Bool_t fUseDefaultNUAPDF[eNUAPDF_N] = {kTRUE}; // by default, use simple hardcoded expressions for NUA acceptance profile - TF1* fDefaultNUAPDF[eNUAPDF_N] = {NULL}; // default distributions used as pdfs to simulate events on-the-fly - TH1D* fCustomNUAPDF[eNUAPDF_N] = {NULL}; // custom, user-supplied distributions used to simulate NUA - TString* fCustomNUAPDFHistNames[eNUAPDF_N] = {NULL}; // these are the names of histograms holding custom NUA in an external file. There is a configurable for this one. - TString fFileWithCustomNUA = ""; // path to external ROOT file which holds all histograms with custom NUA - Double_t fMaxValuePDF[eNUAPDF_N] = {0.}; // see algorithm used in Accept(...). I implemented it as a data member, so that it is not calculated again and again at each particle call + TList* fNUAList = NULL; // list to hold all NUA objects + TProfile* fNUAFlagsPro = NULL; // profile to hold all flags for NUA objects + bool fApplyNUAPDF[eNUAPDF_N] = {false}; // apply NUA to particular kine variable (see the corresponding enum eNUAPDF) + bool fUseDefaultNUAPDF[eNUAPDF_N] = {true, true, true}; // by default, use simple hardcoded expressions for NUA acceptance profile + TF1* fDefaultNUAPDF[eNUAPDF_N] = {NULL}; // default distributions used as pdfs to simulate NUA on-the-fly + TH1D* fCustomNUAPDF[eNUAPDF_N] = {NULL}; // custom, user-supplied distributions used to simulate NUA + TString* fCustomNUAPDFHistNames[eNUAPDF_N] = {NULL}; // these are the names of histograms holding custom NUA in an external file. There is a configurable for this one. + TString fFileWithCustomNUA = ""; // path to external ROOT file which holds all histograms with custom NUA + float fMaxValuePDF[eNUAPDF_N] = {0.}; // see algorithm used in Accept(...). I implemented it as a data member, so that it is not calculated again and again at each particle call } nua; // *) Internal validation: struct InternalValidation { TList* fInternalValidationList = NULL; // list to hold all objects for internal validation TProfile* fInternalValidationFlagsPro = NULL; // profile to hold all flags for internal validation - Bool_t fUseInternalValidation = kFALSE; // use internal validation - Bool_t fInternalValidationForceBailout = kFALSE; // force bailout in internal validation after either eNumberOfEvents or eSelectedEvents is reached. + bool fUseInternalValidation = false; // use internal validation + bool fInternalValidationForceBailout = false; // force bailout in internal validation after either eNumberOfEvents or eSelectedEvents is reached. // This is OK as long as I do not apply any event cuts in InternalValidation(). // Remember that for each real event, I do fnEventsInternalValidation events on-the-fly. // Can be used in combination with setting fSequentialBailout > 0. - UInt_t fnEventsInternalValidation = 0; // how many on-the-fly events will be sampled for each real event, for internal validation - TString* fHarmonicsOptionInternalValidation = NULL; // "constant" or "correlated", see .cxx for full documentation - Bool_t fRescaleWithTheoreticalInput = kFALSE; // if kTRUE, all measured correlators are rescaled with theoretical input, so that in profiles everything is at 1 + unsigned int fnEventsInternalValidation = 0; // how many on-the-fly events will be sampled for each real event, for internal validation + TString* fHarmonicsOptionInternalValidation = NULL; // "constant", "correlated" or "persistent", see .cxx for full documentation + bool fRescaleWithTheoreticalInput = false; // if true, all measured correlators are rescaled with theoretical input, so that in profiles everything is at 1 + bool fRandomizeReactionPlane = true; // if true, RP is randomized e-by-e. I need false basically only when validating against theoretical input non-isotropic correlators TArrayD* fInternalValidationVnPsin[2] = {NULL}; // 0 = { v1, v2, ... }, 1 = { Psi1, Psi2, ... } - Int_t fMultRangeInternalValidation[2] = {0, 0}; // min and max values for uniform multiplicity distribution in on-the-fly analysis (convention: min <= M < max) + int fMultRangeInternalValidation[2] = {0, 0}; // min and max values for uniform multiplicity distribution in on-the-fly analysis (convention: min <= M < max) } iv; // *) Test0: struct Test0 { - TList* fTest0List = NULL; // list to hold all objects for Test0 - TProfile* fTest0FlagsPro = NULL; // store all flags for Test0 - Bool_t fCalculateTest0 = kFALSE; // calculate or not Test0 - TProfile* fTest0Pro[gMaxCorrelator][gMaxIndex][eAsFunctionOf_N] = {{{NULL}}}; //! [order][index][0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta] - TString* fTest0Labels[gMaxCorrelator][gMaxIndex] = {{NULL}}; // all labels: k-p'th order is stored in k-1'th index. So yes, I also store 1-p - Bool_t fCalculateTest0AsFunctionOf[eAsFunctionOf_N] = {false}; //! [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta,5=vs. occupancy, ...] - TString fFileWithLabels = ""; // path to external ROOT file which specifies all labels of interest - Bool_t fUseDefaultLabels = kFALSE; // use default labels hardwired in GetDefaultObjArrayWithLabels(), the choice is made with cfWhichDefaultLabels - TString fWhichDefaultLabels = ""; // only for testing purposes, select one set of default labels, see GetDefaultObjArrayWithLabels for supported options - TH1I* fTest0LabelsPlaceholder = NULL; // store all Test0 labels in this histogram -} t0; // "t0" labels an instance of this group of histograms + TList* fTest0List = NULL; // list to hold all objects for Test0 + TProfile* fTest0FlagsPro = NULL; // store all flags for Test0 + bool fCalculateTest0 = false; // calculate or not Test0 + TProfile* fTest0Pro[gMaxCorrelator][gMaxIndex][eAsFunctionOf_N] = {{{NULL}}}; //! [order][index][0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta] + bool fCalculate2DTest0 = false; // calculate or not 2D Test0 + TProfile2D* fTest0Pro2D[gMaxCorrelator][gMaxIndex][eAsFunctionOf2D_N] = {{{NULL}}}; //! [order][index][0=cent vs pt, ..., see enum eAsFunctionOf2D] + bool fCalculate3DTest0 = false; // calculate or not 2D Test0 + TProfile3D* fTest0Pro3D[gMaxCorrelator][gMaxIndex][eAsFunctionOf3D_N] = {{{NULL}}}; //! [order][index][0=cent vs pt vs eta, ..., see enum eAsFunctionOf3D] + TString* fTest0Labels[gMaxCorrelator][gMaxIndex] = {{NULL}}; // all labels: k-p'th order is stored in k-1'th index. So yes, I also store 1-p + bool fCalculateTest0AsFunctionOf[eAsFunctionOf_N] = {false}; //! [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta,5=vs. occupancy, ...] + bool fCalculate2DTest0AsFunctionOf[eAsFunctionOf2D_N] = {false}; //! [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta,5=vs. occupancy, ...] + bool fCalculate3DTest0AsFunctionOf[eAsFunctionOf3D_N] = {false}; //! [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta,5=vs. occupancy, ...] + TString fFileWithLabels = ""; // path to external ROOT file which specifies all labels of interest + bool fUseDefaultLabels = false; // use default labels hardwired in GetDefaultObjArrayWithLabels(), the choice is made with cfWhichDefaultLabels + TString fWhichDefaultLabels = ""; // only for testing purposes, select one set of default labels, see GetDefaultObjArrayWithLabels for supported options +} t0; // "t0" labels an instance of this group of histograms // *) Eta separations: struct EtaSeparations { @@ -318,28 +412,31 @@ struct EtaSeparations { // *) Global cosmetics: struct GlobalCosmetics { - TString srs[2] = {"rec", "sim"}; // used in the histogram name as index when saved to the file - TString srs_long[2] = {"reconstructed", "simulated"}; // used in the histogram title - TString sba[2] = {"before", "after"}; // used in the histogram name as index when saved to the file - TString sba_long[2] = {"before cuts", "after cuts"}; // used in the histogram title - TString scc[eCutCounter_N] = {"abs", "seq"}; // used in the histogram name as index when saved to the file - TString scc_long[eCutCounter_N] = {"absolute", "sequential"}; // used in the histogram title + TString srs[2] = {"rec", "sim"}; // used in the histogram name as index when saved to the file + TString srsLong[2] = {"reconstructed", "simulated"}; // used in the histogram title + TString sba[2] = {"before", "after"}; // used in the histogram name as index when saved to the file + TString sbaLong[2] = {"before cuts", "after cuts"}; // used in the histogram title + TString scc[eCutCounter_N] = {"abs", "seq"}; // used in the histogram name as index when saved to the file + TString sccLong[eCutCounter_N] = {"absolute", "sequential"}; // used in the histogram title } gc; // *) Results: -struct Results { // This is in addition also sort of "abstract" interface, which defines common binning, etc., for other groups of histograms. - TList* fResultsList = NULL; //!Clone() + eUseFormula, // Use or not class TFormula + eUseDatabasePDG, // Use or not class TDatabasePDG eConfiguration_N }; @@ -47,8 +56,10 @@ enum eProcess { eProcessRecSim_Run1, // Run 1, both reconstructed and simulated eProcessSim_Run1, // Run 1, only simulated eProcessTest, // minimum subscription to the tables, for testing purposes + eProcessQA, // maximum subscription to the tables, for QA purposes. Basically: eProcessRec + otherwise unnecessary tables + eProcessHepMChi, // special subscription when I extract info from the table HepMCHeavyIons TBI 20250429 merge this case eventualyl with RecSim cases // Generic flags, calculated and set from individual flags above in DefaultConfiguration(), AFTER process switch was taken into account: - eGenericRec, // generic "Rec" case, eTest is treated for the time being as "Rec" + eGenericRec, // generic "Rec" case, eTest is treated for the time being as "Rec". eQA is also in this category eGenericRecSim, // generic "RecSim" case eGenericSim, // generic "Sim" case eProcess_N @@ -63,7 +74,8 @@ enum eRecSim { eRec = 0, eRec_Run1, // converted Run 1 data eSim_Run1, eRecAndSim_Run1, - eTest }; + eTest, // remember that as of 20250315 I can use "cfWhichSpecificCuts": "Test" in JSON, to configure quickly all cuts for this case + eQA }; enum eBeforeAfter { eBefore = 0, // use this one for cuts eAfter = 1 }; @@ -81,14 +93,48 @@ enum eDefaultColors { eColor = kBlack, enum eWeights { wPHI = 0, wPT = 1, wETA = 2, + wCHARGE = 3, eWeights_N }; -enum eDiffWeights { +enum eDiffWeights { // TBI 20250215 this is now obsolete, superseeded with more general implementation, see enums eDiffWeightCategory, eDiffPhiWeights, etc. wPHIPT = 0, wPHIETA, + wPHICHARGE, eDiffWeights_N }; +enum eDiffWeightCategory { + eDWPhi = 0, // corresponds to eDiffPhiWeights structure, here the fundamental 0-th axis never to be projected out is "phi" + eDWPt, // corresponds to eDiffPtWeights structure, here the fundamental 0-th axis never to be projected out is "pt" + eDWEta, // corresponds to eDiffEtaWeights structure, here the fundamental 0-th axis never to be projected out is "eta" + // ... + eDiffWeightCategory_N +}; + +enum eDiffPhiWeights { + wPhiPhiAxis = 0, // this is the main axis in this category, the only axis which shall never be projected out. If I project out all remaining axes, I shall recover the standard integrated phi weights + wPhiPtAxis, + wPhiEtaAxis, + wPhiChargeAxis, + wPhiCentralityAxis, + wPhiVertexZAxis, + eDiffPhiWeights_N +}; + +enum eDiffPtWeights { + wPtPtAxis = 0, + wPtChargeAxis, + wPtCentralityAxis, + eDiffPtWeights_N +}; + +enum eDiffEtaWeights { + wEtaEtaAxis = 0, + wEtaChargeAxis, + wEtaCentralityAxis, + eDiffEtaWeights_N +}; + enum eVnPsin { eVn = 0, ePsin = 1 }; @@ -98,29 +144,29 @@ enum eEventHistograms { eMultiplicity, // see documentation for ebye.fMultiplicity eReferenceMultiplicity, // see documentation for ebye.fReferenceMultiplicity eCentrality, // default centrality estimator - eVertex_x, - eVertex_y, - eVertex_z, + eVertexX, + eVertexY, + eVertexZ, eNContributors, // number of tracks used for the vertex eImpactParameter, eEventPlaneAngle, eOccupancy, // from helper task o2-analysis-event-selection, see also IA's presentation in https://indico.cern.ch/event/1464946, slide 38. Use specific occupancy estimator via eOccupancyEstimator - eInteractionRate, // from utility ctpRateFetcher + eInteractionRate, // from utility ctpRateFetcher . eCurrentRunDuration, // calculated with utility ctpRateFetcher eMultMCNParticlesEta08, // from helper task table o2::aod::MultMCExtras eEventHistograms_N }; enum eEventCuts { - // a) For available event selection bits, check https://github.com/AliceO2Group/O2Physics/blob/master/Common/CCDB/EventSelectionParams.cxx + // a) For available event selection bits, check https://github.com/AliceO2Group/O2Physics/blob/master/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) // b) Some settings are configurable, check: https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/eventSelection.cxx eTrigger = eEventHistograms_N, // Implemented and validated so far: // a) Run 3: "kTVXinTRD" (use optionally for systematics, and only in real data) - // b) Run 2: "kINT7" (at the moment the usage of this one is enfored in fact) + // b) Run 2: "kINT7" (at the moment there is a warning if not used in real data.). Not validated in Monte Carlo. // c) Run 1: TBI 20241209 check if I can use kINT7 also for Run 1 eSel7, // See def. of sel7 in Ref. b) above. Event selection decision based on V0A & V0C => use only in Run 2 and Run 1. - // TBI 20240522 I stil need to validate this one over MC - eSel8, // See def. of sel7 in Ref. b) above. Event selection decision based on TVX => use only in Run 3, both for data and MC + // TBI 20250115 it removes 99% of events in MC LHC21i6a, check this further + eSel8, // See def. of sel8 in Ref. b) above. Event selection decision based on TVX => use only in Run 3, both for data and MC // *) As of 20240410, kNoITSROFrameBorder (only in MC) and kNoTimeFrameBorder event selection cuts are part of Sel8 // See also email from EK from 2024041 eMultiplicityEstimator, // see documentation for ebye.fMultiplicity @@ -129,23 +175,57 @@ enum eEventCuts { eSelectedEvents, // selected events = eNumberOfEvents + eAfter => therefore I do not need a special histogram for it eNoSameBunchPileup, // reject collisions in case of pileup with another collision in the same foundBC (emails from IA on 20240404 and EK on 20240410) eIsGoodZvtxFT0vsPV, // small difference between z-vertex from PV and from FT0 (emails from IA on 20240404 and EK on 20240410) + // Avoid using kIsGoodZvtxFT0vsPV selection bit for Pb-Pb 2024 apass1, see IA email from 20250115. + // Therefore, until further notice, use this one in LHC23zzh, but not in LHC24ar and LHC24as eIsVertexITSTPC, // at least one ITS-TPC track (reject vertices built from ITS-only tracks) (emails from IA on 20240404 and EK on 20240410 eIsVertexTOFmatched, // at least one of vertex contributors is matched to TOF eIsVertexTRDmatched, // at least one of vertex contributors is matched to TRD eNoCollInTimeRangeStrict, // rejects a collision if there are other events in dtime +/- 10 μs, see IA Slide 39 in https://indico.cern.ch/event/1462154/ + // 20250122 Per feedback from IA, use this one only as a part of systematic check, and use eNoCollInTimeRangeStandard by default eNoCollInTimeRangeStandard, // rejects a collision if there are other events in dtime +/- 2 μs + additional cuts on multiplicity, see IA Slide 39 in https://indico.cern.ch/event/1462154/ eNoCollInRofStrict, // rejects a collision if there are other events within the same ROF (in-ROF pileup), ROF = "ITS Readout Frames", // see IA Slide 39 in https://indico.cern.ch/event/1462154/ + // 20250122 Per feedback from IA, use this one only as a part of systematic check, and use eNoCollInRofStandard by default eNoCollInRofStandard, // same as previous + additional cuts on multiplicity, see IA Slide 39 in https://indico.cern.ch/event/1462154/ eNoHighMultCollInPrevRof, // veto an event if FT0C amplitude in previous ITS ROF is above threshold (default is >5000 a.e. by FT0C), see IA Slide 39 in https://indico.cern.ch/event/1462154/ + // 20250122 Per feedback from IA, use it only in 2023 PbPb data (e.g. eLHC23zzh), in 2024 PbPb data this one has no effect (do not use in eLHC24ar and eLHC24as) eIsGoodITSLayer3, // number of inactive chips on ITS layer 3 is below maximum allowed value eIsGoodITSLayer0123, // numbers of inactive chips on ITS layers 0-3 are below maximum allowed values eIsGoodITSLayersAll, // numbers of inactive chips on all ITS layers are below maximum allowed values eOccupancyEstimator, // the default Occupancy estimator, set via configurable. All supported centrality estimators, for QA, etc, are in enum eOccupancyEstimators eMinVertexDistanceFromIP, // if sqrt(vx^2+vy^2+vz^2) < MinVertexDistanceFromIP, the event is rejected. This way, I remove suspicious events with |vertex| = 0. + eNoPileupTPC, // no pileup in TPC + eNoPileupFromSPD, // no pileup according to SPD vertexer + eNoSPDOnVsOfPileup, // no out-of-bunch pileup according to online-vs-offline SPD correlation + eRefMultVsNContrUp, // formula for upper boundary cut in eReferenceMultiplicity_vs_NContributors (remember that I use naming convention "x_vs_y") + eRefMultVsNContrLow, // formula for lower boundary cut in eReferenceMultiplicity_vs_NContributors (remember that I use naming convention "x_vs_y") + eCentralityCorrelationsCut, // port of void SetCentralityCorrelationsCuts(...) from MuPa class. Example format: "CentFT0C_CentFT0M", so IFS is "_", until proven otherwise + + // RCT flags, see https://indico.cern.ch/event/1545907/ + up-to-date code in Common/CCDB/RCTSelectionFlags.h + // Remark 1: For the time being, I support here differentially 6 flags used to define the combined "CBT" flag, see if (label == "CBT") in Common/CCDB/RCTSelectionFlags.h + // Remark 2: If I want to use directly the combined "CBT" flag, see how it can be done using RCTFlagsChecker in + // https://github.com/AliceO2Group/O2Physics/blob/master/DPG/Tasks/AOTEvent/timeDependentQa.cxx#L115 + // But check before the memory status after RCTFlagsChecker is used. + eFT0Bad, + eITSBad, + eITSLimAccMCRepr, + eTPCBadTracking, + eTPCLimAccMCRepr, + eTPCBadPID, + // ... + eCentralityWeights, // used for centrality flattening. Remember that this event cut must be implemented very last, + // therefore I have it separately implemented for Run 3,2,1 in EventCuts() at the very end in each case. + // Use only for small non-uniformity in centrality distribution (e.g. of the biggest dip in distribution is up to 20% compared to uniform part of cent. distribution), + // otherwise this flattening is too costly in terms of statistics. eEventCuts_N }; +enum eEventCutsFormulas { // special treatment for all event cuts defined via mathematical formula, because for them I have to do one additional layer of booking using TFormula + eRefMultVsNContrUp_Formula = 0, + eRefMultVsNContrLow_Formula, + eEventCutsFormulas_N +}; + enum eParticleHistograms { // from o2::aod::Tracks (Track parameters at their point closest to the collision vertex) @@ -154,17 +234,22 @@ enum eParticleHistograms { eEta, eCharge, // Charge: positive: 1, negative: -1 - // from o2::aod::TracksExtra_001 + // from o2::aod::TracksExtra_001 - I keep the ordering here the same as in the TracksExtra_001 table etpcNClsFindable, etpcNClsShared, + eitsChi2NCl, // TBI 20250110 I see for this one [478682:track-selection]: [15:35:00][INFO] Track selection, set max chi2 per cluster ITS: 36 + // But even with open particle cuts, this distribution doesn't cross 30... There is a sudden drop round 22, but when I apply other cuts + // that tail is gone already. etpcNClsFound, etpcNClsCrossedRows, eitsNCls, eitsNClsInnerBarrel, etpcCrossedRowsOverFindableCls, - etpcFoundOverFindableCls, + etpcFoundOverFindableCls, // TBI 20250110 I keep this one in sync with values for etpcCrossedRowsOverFindableCls etpcFractionSharedCls, - + etpcChi2NCl, // TBI 20250110 this one shall resemble aodTrack->GetTPCchi2()/aodTrack->GetTPCNcls(), but cross-check with the experts. Particles with tpcChi2NCl > 4. I reject now by default. + // See what I documented in AliPhysics below // task->SetParticleCuts("TPCChi2perNDF",4.,-44); // VAL + // 20250123 in some Run 2 analysis, 2.5 was used as a default. Check that value as a part of systematics // from o2::aod::TracksDCA edcaXY, edcaZ, @@ -184,21 +269,52 @@ enum eParticleHistograms2D { // All 2D histograms are first implemented in eQAPa enum eParticleCuts { - // from o2::aod::TrackSelection - etrackCutFlagFb1 = eParticleHistograms_N, // do not use in Run 2 and 1 - etrackCutFlagFb2, // do not use in Run 2 and 1 - eisQualityTrack, // not validated in Run 3, but it can be used in Run 2 and Run 1 (for the latter, it yields to large NUA) - eisPrimaryTrack, - eisInAcceptanceTrack, // TBI 20240516 check and document how acceptance window is defined - eisGlobalTrack, // not validated in Run 3, but it can be used in Run 2 and Run 1 (for the latter, it yields to real holes in NUA) - + // from o2::aod::TrackSelection (https://aliceo2group.github.io/analysis-framework/docs/datamodel/helperTaskTables.html#o2-analysis-trackselection) + // See also O2Physics/Common/DataModel/TrackSelectionTables.h + etrackCutFlag = eParticleHistograms_N, // General selection, with centrally tuned particle cuts for tpcNClsFound, itsNCls, etc. + // As of 20250113, this cut still has not effect, neither in Run 3 nor in converted Run 2. Use instead trackCutFlagFb1 and/or trackCutFlagFb2 below. + etrackCutFlagFb1, // Global tracks in Run 3. Closest possible match to global track definition in Run 2, which are selected with eisGlobalTrack. + // For the definition, see: + // a) "filtbit1" in https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/trackselection.cxx#L128 + // b) "getGlobalTrackSelectionRun3ITSMatch" in https://github.com/AliceO2Group/O2Physics/blob/master/Common/Core/TrackSelectionDefaults.cxx#L43 + // When I use this flag, make sure I do NOT cut on something on which this cut is already cutting by default (e.g. pt-dependent DCA xy cut) + etrackCutFlagFb2, // Global tracks in Run 3, similar as etrackCutFlagFb1, but more stringent (since 2 points in ITS are required in inner barrel (IB)). + // Unlike etrackCutFlagFb1 (1 ITS point is required), it produces a 20% dip in azimuthal acceptance for 1.2 < phi < 1.6, in LHC24ar/559545 + // DCAxy and z are significantly further depleted, when compared to etrackCutFlagFb1 + eisQualityTrack, // Do not use in Run 3, but it can be used in Run 2 and Run 1 + // In Run 2, it is already requested in isGlobalTrack, through definition kGlobalTrack = kQualityTracks | kPrimaryTracks | kInAcceptanceTracks + // See O2Physics/Common/DataModel/TrackSelectionTables.h for further details. + // Therefore, vary in Run 2 only is isGlobalTrack is NOT requested by default. + eisPrimaryTrack, // Validated in Run 3. See also isPVContributor + // In Run 2, it is already requested in isGlobalTrack, through definition kGlobalTrack = kQualityTracks | kPrimaryTracks | kInAcceptanceTracks + // See O2Physics/Common/DataModel/TrackSelectionTables.h for further details. + // Therefore, vary in Run 2 only is isGlobalTrack is NOT requested by default. + eisInAcceptanceTrack, // kInAcceptanceTracks = kPtRange | kEtaRange . Pt is open, and |eta| < 0.8. + // But after I already cut directly on 0.2 < pt < 5.0 and |eta| < 0.8, it has no effect. + // Can be used both in Run 3 and Run 2. + // TBI 20250113 remove this cut eventually from the code, because I cut direcly on 0.2 < pt < 5.0 and |eta| < 0.8 in any case. + eisGlobalTrack, // Do not use in Run 3, it can be used directly only in Run 2 and Run 1, see definition in: + // https://github.com/AliceO2Group/O2Physics/blob/master/Common/Core/TrackSelectionDefaults.cxx#L23 + // For Run 3 global tracks, I need to use TrackSelection getGlobalTrackSelectionRun3ITSMatch(int matching, int passFlag) from + // https://github.com/AliceO2Group/O2Physics/blob/master/Common/Core/TrackSelectionDefaults.cxx#L43 + // That is precisely definition of filtBit1 in https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/trackselection.cxx + // So: etrackCutFlagFb1 in Run 3 is a closest match to eisGlobalTrack in Run 2 + eisPVContributor, // Run 3: Has this track contributed to the collision vertex fit + // Tracks used in vertex fit are flagged as "contributors" (-> track.isPVContributor() for AO2D tracks). Such a track is + // allowed to contribute to only one PV. => See further details in RS presentation https://indico.cern.ch/event/1453901/timetable/#12-track-reconstruction + // This cut affects significantly distributions of other tracking parameters. Most notably, after using this cut, DCAz distribution is reduced to ~ 1mm range. + // But for global tracks in any case we request very stringent DCA cut. + // pt and eta distributions are only mildly affected. + // Do not use in Run 2 and Run 1. + // It's not the same as isPrimaryTrack cut, albeit there is an overlap. // special treatment: ePtDependentDCAxyParameterization, eParticleCuts_N }; -enum eAsFunctionOf { +enum eAsFunctionOf { // this is a specific enum only for 1D dependence + // 1D: AFO_INTEGRATED = 0, AFO_MULTIPLICITY, // vs. default multiplicity, which is (at the moment) fSelectedTracks, i.e. number of tracks in Q-vector AFO_CENTRALITY, // vs. default centrality estimator, see how it's calculated in DetermineCentrality(...) @@ -207,9 +323,38 @@ enum eAsFunctionOf { AFO_OCCUPANCY, // vs. default "occupancy" variable which is (at the moment) "FT0COccupancyInTimeRange" (alternative is "TrackOccupancyInTimeRange") AFO_INTERACTIONRATE, // vs. "interation rate" AFO_CURRENTRUNDURATION, // vs. "current run duration", i.e. vs "seconds since start of run" + AFO_VZ, // vs. "vertex z position" + AFO_CHARGE, // vs. "particle charge" + // ... eAsFunctionOf_N }; // prefix is needed, to avoid conflict with enum eKinematics +enum eAsFunctionOf2D { // this is a specific enum only for 2D dependence + // 2D: + AFO_CENTRALITY_PT = 0, + AFO_CENTRALITY_ETA, + AFO_CENTRALITY_CHARGE, + AFO_CENTRALITY_VZ, + AFO_PT_ETA, + AFO_PT_CHARGE, + AFO_ETA_CHARGE, + // ... + eAsFunctionOf2D_N +}; + +enum eAsFunctionOf3D { // this is a specific enum only for 3D dependence + // 3D: + AFO_CENTRALITY_PT_ETA = 0, + AFO_CENTRALITY_PT_CHARGE, + AFO_CENTRALITY_PT_VZ, + AFO_CENTRALITY_ETA_VZ, + AFO_CENTRALITY_ETA_CHARGE, + AFO_CENTRALITY_VZ_CHARGE, + AFO_PT_ETA_CHARGE, + // ... + eAsFunctionOf3D_N +}; + enum eNUAPDF { ePhiNUAPDF = 0, ePtNUAPDF, @@ -218,8 +363,21 @@ enum eNUAPDF { }; enum eqvectorKine { // Here "kine" originally meant "kinematic", i.e. vs. pt or vs. eta, now it's general. + // 1D: PTq = 0, ETAq, + CHARGEq, + // ... + + // 2D: // Yes, I linearize 2D case, in an analogy with "global bin" structure for multidimensional histograms. + PT_ETAq, + PT_CHARGEq, + ETA_CHARGEq, + // ... + + // 3D: // Yes, I linearize 3D case, in an analogy with "global bin" structure for multidimensional histograms. + PT_ETA_CHARGEq, + // ... eqvectorKine_N }; @@ -252,27 +410,42 @@ enum eQAEventHistograms2D { eMultiplicity_vs_ReferenceMultiplicity = 0, // multiplicity is x, reference multiplicity is y. I can swap offline if needed: histOriginal->GetBinContent(x,y); histSwapped->Fill(y,x); eMultiplicity_vs_NContributors, eMultiplicity_vs_Centrality, - eMultiplicity_vs_Vertex_z, + eMultiplicity_vs_VertexZ, eMultiplicity_vs_Occupancy, + eMultiplicity_vs_InteractionRate, // TBI 20250331 I ctd. below with more histos in category eMultiplicity_vs_... - re-organize at some point bookkeping here eReferenceMultiplicity_vs_NContributors, eReferenceMultiplicity_vs_Centrality, - eReferenceMultiplicity_vs_Vertex_z, + eReferenceMultiplicity_vs_VertexZ, eReferenceMultiplicity_vs_Occupancy, + eReferenceMultiplicity_vs_InteractionRate, eNContributors_vs_Centrality, - eNContributors_vs_Vertex_z, + eNContributors_vs_VertexZ, eNContributors_vs_Occupancy, - eCentrality_vs_Vertex_z, + eNContributors_vs_InteractionRate, + eCentrality_vs_VertexZ, eCentrality_vs_Occupancy, eCentrality_vs_ImpactParameter, // [sim] = reconstructed centrality vs. simulated impact parameter. [rec] = ... TBI 20241210 - eVertex_z_vs_Occupancy, + eCentrality_vs_InteractionRate, + eVertexZ_vs_Occupancy, + eVertexZ_vs_InteractionRate, // ... // Specific (everything is hardwired): eMultNTracksPV_vs_MultNTracksGlobal, // Run 3 multiplicity + eCentFT0C_vs_CentFT0CVariant1, // Run 3 centrality + eCentFT0C_vs_CentFT0M, // Run 3 centrality + eCentFT0C_vs_CentFV0A, // Run 3 centrality eCentFT0C_vs_CentNTPV, // Run 3 centrality + eCentFT0C_vs_CentNGlobal, // Run 3 centrality eCentFT0M_vs_CentNTPV, // Run 3 centrality eCentRun2V0M_vs_CentRun2SPDTracklets, // Run 2 centrality (do not use in Run 1 converted, because there is no centrality information) eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange, eCurrentRunDuration_vs_InteractionRate, // ... + // ... + // Unsorted category: TBI 20250331 not sure if I will keep these ones permanently: + eMultiplicity_vs_FT0CAmplitudeOnFoundBC, + eCentFT0C_vs_FT0CAmplitudeOnFoundBC, + eCentrality_vs_CentralitySim, // correlation between centrality determined from reconstructed data, and centrality determined at generated level (from IP). I save it as [eSim], not as [eRec] + // ... eQAEventHistograms2D_N }; @@ -284,7 +457,7 @@ enum eQAParticleHistograms2D { enum eQAParticleEventHistograms2D { // In this category I do correlation vs. some-event-property. // The < ... > goes over all particles in that event. - // All < ... > over particles are calculated with helper TProfile + // All < ... > over particles are calculated with helper TProfile fQAParticleEventProEbyE // For instance: vs. current run duration eCurrentRunDuration_vs_itsNClsEbyE, eCurrentRunDuration_vs_itsNClsNegEtaEbyE, @@ -300,19 +473,88 @@ enum eQAParticleEventHistograms2D { }; enum eQAParticleEventProEbyE { - eitsNClsEbyE = 1, // Labels average in a given event (therefore "EbyE" is appended). Yes, from one, because it runs over bin content and entries in TProfile for most of the time. - eitsNClsNegEtaEbyE, // in a given event for eta < 0 - eitsNClsPosEtaEbyE, // in a given event for eta > 0 - eEta0804EbyE, // in a given event for -0.8 < eta < -0.4 - eEta0400EbyE, // in a given event for -0.4 < eta < 0.0 - eEta0004EbyE, // in a given event for 0.0 < eta < 0.4 - eEta0408EbyE, // in a given event for 0.4 < eta < 0.8 - ePt0005EbyE, // in a given event for 0.0 < pt < 0.5 - ePt0510EbyE, // in a given event for 0.5 < pt < 1.0 - ePt1050EbyE, // in a given event for 1.0 < pt < 5.0 + eitsNClsEbyE = 1, // Labels average in a given event (therefore "EbyE" is appended). Yes, from one, because it runs over bin content and entries in TProfile for most of the time. + eitsNClsNegEtaEbyE, // in a given event for eta < 0 + eitsNClsPosEtaEbyE, // in a given event for eta > 0 + eEta0804EbyE, // in a given event for -0.8 < eta < -0.4 + eEta0400EbyE, // in a given event for -0.4 < eta < 0.0 + eEta0004EbyE, // in a given event for 0.0 < eta < 0.4 + eEta0408EbyE, // in a given event for 0.4 < eta < 0.8 + ePt0005EbyE, // in a given event for 0.0 < pt < 0.5 + ePt0510EbyE, // in a given event for 0.5 < pt < 1.0 + ePt1050EbyE, // in a given event for 1.0 < pt < 5.0 + eMeanPhi, // in an event TBI 20250214 I need to unify naming convention for <> with previous enums in above in the series, but okay... + eMeanPt, // in an event + eMeanEta, // in an event + eMeanCharge, // in an event + eMeantpcNClsFindable, // in an event + eMeantpcNClsShared, // in an event + eMeanitsChi2NCl, // in an event + eMeantpcNClsFound, // in an event + eMeantpcNClsCrossedRows, // in an event + eMeanitsNCls, // in an event + eMeanitsNClsInnerBarrel, // in an event + eMeantpcCrossedRowsOverFindableCls, // in an event + eMeantpcFoundOverFindableCls, // in an event + eMeantpcFractionSharedCls, // in an event + eMeantpcChi2NCl, // in an event + eMeandcaXY, // in an event + eMeandcaZ, // in an event eQAParticleEventProEbyE_N }; +enum eQACorrelationsVsHistograms2D { + // In this category I correlate <2> vs. some-event-property. + // For instance: <2> vs. ref. mult + // <2> vs. , where is calculated from all particles in that event (so in this sense, it's an event property as well) + // Remark 1: If I would ever need the same thingie for <4>, <6>, etc., just introduce new dimension in 2D histogram + // Remark 2: All < ... > over particles are calculated with helper TProfile fQAParticleEventProEbyE + eCorrelations_vs_Multiplicity = 0, + eCorrelations_vs_ReferenceMultiplicity, + eCorrelations_vs_Centrality, + // ... + eCorrelations_vs_MeanPhi, + eCorrelations_vs_MeanPt, + eCorrelations_vs_MeanEta, + eCorrelations_vs_MeanCharge, + eCorrelations_vs_MeantpcNClsFindable, + eCorrelations_vs_MeantpcNClsShared, + eCorrelations_vs_MeanitsChi2NCl, + eCorrelations_vs_MeantpcNClsFound, + eCorrelations_vs_MeantpcNClsCrossedRows, + eCorrelations_vs_MeanitsNCls, + eCorrelations_vs_MeanitsNClsInnerBarrel, + eCorrelations_vs_MeantpcCrossedRowsOverFindableCls, + eCorrelations_vs_MeantpcFoundOverFindableCls, + eCorrelations_vs_MeantpcFractionSharedCls, + eCorrelations_vs_MeantpcChi2NCl, + eCorrelations_vs_MeandcaXY, + eCorrelations_vs_MeandcaZ, + // ... + eQACorrelationsVsHistograms2D_N +}; + +enum eQACorrelationsVsInteractionRateVsProfiles2D_N { + // In this category I fill <2> in 2D profile spanned by IR vs. some-other-observable (IR is always x axis) + // For instance: <2> is filled in TProfile2D spanned by IR vs. CurrentRunDuration (crd) + // <2> is filled in TProfile2D spanned by IR vs. , where is calculated from all particles in that event + // Remark 1: If I would ever need the same thingie for <4>, <6>, etc., just introduce new dimension in 2D profile + // Remark 2: All < ... > over particles are calculated with helper TProfile fQAParticleEventProEbyE + eCorrelationsVsInteractionRate_vs_CurrentRunDuration = 0, + eCorrelationsVsInteractionRate_vs_Multiplicity, + eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity, + eCorrelationsVsInteractionRate_vs_Centrality, + // ... + eCorrelationsVsInteractionRate_vs_MeanPhi, + eCorrelationsVsInteractionRate_vs_SigmaMeanPhi, + eCorrelationsVsInteractionRate_vs_MeanPt, + eCorrelationsVsInteractionRate_vs_SigmaMeanPt, + eCorrelationsVsInteractionRate_vs_MeanEta, + eCorrelationsVsInteractionRate_vs_SigmaMeanEta, + // ... + eQACorrelationsVsInteractionRateVsProfiles2D_N +}; + enum eReferenceMultiplicityEstimators { // Run 3: eMultTPC = 0, @@ -329,9 +571,11 @@ enum eReferenceMultiplicityEstimators { enum eCentralityEstimators { // Run 3: eCentFT0C = 0, + eCentFT0CVariant1, eCentFT0M, eCentFV0A, eCentNTPV, + eCentNGlobal, // Run 2: eCentRun2V0M, eCentRun2SPDTracklets, @@ -351,7 +595,16 @@ enum eEventCounter { }; enum eSpecificCuts { + // Run 3: eLHC23zzh, + eLHC24ar, + eLHC24as, + // Run 2: + eLHC15o, + // Run 1: + // ... + // Cuts for minimal subscription, "processTest": "true in JSON + eTestCuts, eSpecificCuts_N }; diff --git a/PWGCF/MultiparticleCorrelations/Core/MuPa-GlobalConstants.h b/PWGCF/MultiparticleCorrelations/Core/MuPa-GlobalConstants.h index c62ffeaf6c8..adacaf76282 100644 --- a/PWGCF/MultiparticleCorrelations/Core/MuPa-GlobalConstants.h +++ b/PWGCF/MultiparticleCorrelations/Core/MuPa-GlobalConstants.h @@ -9,14 +9,19 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file MuPa-GlobalConstants.h +/// \brief ... TBI 20250425 +/// \author Ante.Bilandzic@cern.ch + #ifndef PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_GLOBALCONSTANTS_H_ #define PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_GLOBALCONSTANTS_H_ -const Int_t gMaxCorrelator = 12; -const Int_t gMaxHarmonic = 9; -const Int_t gMaxIndex = 300; // per order, used only in Test0 -const Int_t gMaxNoBinsKine = 1000; // max number of bins for differential q-vector -const Int_t gMaxBinsDiffWeights = 100; // max number of bins for differential weights, see MakeWeights.C -const Int_t gMaxNumberEtaSeparations = 9; // max number of different eta separations used to calculated 2p corr. with eta separations +const int gMaxCorrelator = 12; +const int gMaxHarmonic = 9; +const int gMaxIndex = 300; // per order, used only in Test0 +const int gMaxNoBinsKine = 1000; // max number of bins for differential q-vector +const int gMaxBinsDiffWeights = 100; // max number of bins for differential weights, see MakeWeights.C +const int gMaxNumberEtaSeparations = 9; // max number of different eta separations used to calculated 2p corr. with eta separations +const int gMaxNumberSparseDimensions = 10; // max number of dimensions in sparse histograms #endif // PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_GLOBALCONSTANTS_H_ diff --git a/PWGCF/MultiparticleCorrelations/Core/MuPa-MemberFunctions.h b/PWGCF/MultiparticleCorrelations/Core/MuPa-MemberFunctions.h index 1715085e10f..bd4bca81735 100644 --- a/PWGCF/MultiparticleCorrelations/Core/MuPa-MemberFunctions.h +++ b/PWGCF/MultiparticleCorrelations/Core/MuPa-MemberFunctions.h @@ -9,21 +9,31 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file MuPa-MemberFunctions.h +/// \brief ... TBI 20250425 +/// \author Ante.Bilandzic@cern.ch + #ifndef PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_MEMBERFUNCTIONS_H_ #define PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_MEMBERFUNCTIONS_H_ // ... -#include #include +#include //============================================================ -void BookBaseList() +void bookBaseList() { // Book base TList and store task configuration. // a) Book base TList; - // b) Store task configuration. + // b) Book base profile fBasePro to hold task configuration; + // c) Define bin labels directly via SetBinLabel(...); + // d) Define bin labels indirectly by storing them in y-axis title + local executable PostprocessLabels.C. + // Algorithm: y-axis title is formatted with respect to 2 IFS, ":" and ";" as follows "1:first-bin-label; 2:second-bin-label; ..." + // Then, I tokenize with respect to ";" to get bin number and corresponding bin label. + // In the final step, I tokenize with respect to ":" to disentangle bin number and its bin label; + // e) Add configured base TProfile to the list. if (tc.fVerbose) { StartFunction(__FUNCTION__); @@ -31,86 +41,199 @@ void BookBaseList() // a) Book base TList: TList* temp = new TList(); - temp->SetOwner(kTRUE); + temp->SetOwner(true); fBaseList.setObject(temp); - // b) Store task configuration: + // b) Book base profile to hold task configuration: fBasePro = new TProfile("fBasePro", "flags for the whole analysis", eConfiguration_N - 1, 0.5, static_cast(eConfiguration_N) - 0.5); // yes, eConfiguration_N - 1 and -0.5, because eConfiguration kicks off from 1 - fBasePro->SetStats(kFALSE); + fBasePro->SetStats(false); fBasePro->SetLineColor(eColor); fBasePro->SetFillColor(eFillColor); // Remark: If I want to change the ordering of bin labels, simply change the // ordering in enum eConfiguration { ... }, nothing needs to be changed here. - fBasePro->GetXaxis()->SetBinLabel(eTaskIsConfiguredFromJson, Form("fTaskIsConfiguredFromJson = %s", tc.fTaskIsConfiguredFromJson.Data())); - fBasePro->GetXaxis()->SetBinLabel(eTaskName, Form("fTaskName = %s", tc.fTaskName.Data())); + if (tc.fUseSetBinLabel) { + + // c) Define bin labels directly via SetBinLabel(...): + fBasePro->GetXaxis()->SetBinLabel(eTaskIsConfiguredFromJson, TString::Format("fTaskIsConfiguredFromJson = %s", tc.fTaskIsConfiguredFromJson.Data())); + + fBasePro->GetXaxis()->SetBinLabel(eTaskName, Form("fTaskName = %s", tc.fTaskName.Data())); + + fBasePro->GetXaxis()->SetBinLabel(eRunNumber, Form("fRunNumber = %s", "__RUN_NUMBER__")); + // I have to do it this way via placeholder, because run number is available only when i start to process data. + // Then, I replace placeholder with run number in PropagateRunNumber(...) + + fBasePro->GetXaxis()->SetBinLabel(eDryRun, "fDryRun"); + fBasePro->Fill(eDryRun, static_cast(tc.fDryRun)); + + fBasePro->GetXaxis()->SetBinLabel(eVerbose, "fVerbose"); + fBasePro->Fill(eVerbose, static_cast(tc.fVerbose)); + + fBasePro->GetXaxis()->SetBinLabel(eVerboseUtility, "fVerboseUtility"); + fBasePro->Fill(eVerboseUtility, static_cast(tc.fVerboseUtility)); + + fBasePro->GetXaxis()->SetBinLabel(eVerboseForEachParticle, "fVerboseForEachParticle"); + fBasePro->Fill(eVerboseForEachParticle, static_cast(tc.fVerboseForEachParticle)); + + fBasePro->GetXaxis()->SetBinLabel(eVerboseEventCounter, "fVerboseEventCounter"); + fBasePro->Fill(eVerboseEventCounter, static_cast(tc.fVerboseEventCounter)); + + fBasePro->GetXaxis()->SetBinLabel(ePlainPrintout, "fPlainPrintout"); + fBasePro->Fill(ePlainPrintout, static_cast(tc.fPlainPrintout)); + + fBasePro->GetXaxis()->SetBinLabel(eDoAdditionalInsanityChecks, "fDoAdditionalInsanityChecks"); + fBasePro->Fill(eDoAdditionalInsanityChecks, static_cast(tc.fDoAdditionalInsanityChecks)); + + fBasePro->GetXaxis()->SetBinLabel(eInsanityCheckForEachParticle, "fInsanityCheckForEachParticle"); + fBasePro->Fill(eInsanityCheckForEachParticle, static_cast(tc.fInsanityCheckForEachParticle)); + + fBasePro->GetXaxis()->SetBinLabel(eWhichProcess, Form("WhichProcess = %s", tc.fWhichProcess.Data())); + + fBasePro->GetXaxis()->SetBinLabel(eRandomSeed, "fRandomSeed"); + fBasePro->Fill(eRandomSeed, static_cast(tc.fRandomSeed)); + + fBasePro->GetXaxis()->SetBinLabel(eUseFisherYates, "fUseFisherYates"); + fBasePro->Fill(eUseFisherYates, static_cast(tc.fUseFisherYates)); + + fBasePro->GetXaxis()->SetBinLabel(eFixedNumberOfRandomlySelectedTracks, "fFixedNumberOfRandomlySelectedTracks"); + fBasePro->Fill(eFixedNumberOfRandomlySelectedTracks, static_cast(tc.fFixedNumberOfRandomlySelectedTracks)); + + fBasePro->GetXaxis()->SetBinLabel(eUseStopwatch, "fUseStopwatch"); + fBasePro->Fill(eUseStopwatch, static_cast(tc.fUseStopwatch)); + + fBasePro->GetXaxis()->SetBinLabel(eFloatingPointPrecision, "fFloatingPointPrecision"); + fBasePro->Fill(eFloatingPointPrecision, tc.fFloatingPointPrecision); + + fBasePro->GetXaxis()->SetBinLabel(eSequentialBailout, "fSequentialBailout"); + fBasePro->Fill(eSequentialBailout, static_cast(tc.fSequentialBailout)); + + fBasePro->GetXaxis()->SetBinLabel(eUseSpecificCuts, "fUseSpecificCuts"); + fBasePro->Fill(eUseSpecificCuts, static_cast(tc.fUseSpecificCuts)); + + fBasePro->GetXaxis()->SetBinLabel(eWhichSpecificCuts, Form("WhichSpecificCuts = %s", tc.fWhichSpecificCuts.Data())); + + fBasePro->GetXaxis()->SetBinLabel(eSkipTheseRuns, Form("SkipTheseRuns = %s", tc.fSkipTheseRuns.Data())); + + fBasePro->GetXaxis()->SetBinLabel(eUseSetBinLabel, "fUseSetBinLabel"); + fBasePro->Fill(eUseSetBinLabel, static_cast(tc.fUseSetBinLabel)); + + fBasePro->GetXaxis()->SetBinLabel(eUseClone, "fUseClone"); + fBasePro->Fill(eUseClone, static_cast(tc.fUseClone)); + + fBasePro->GetXaxis()->SetBinLabel(eUseFormula, "fUseFormula"); + fBasePro->Fill(eUseFormula, static_cast(tc.fUseFormula)); + + fBasePro->GetXaxis()->SetBinLabel(eUseDatabasePDG, "fUseDatabasePDG"); + fBasePro->Fill(eUseDatabasePDG, static_cast(tc.fUseDatabasePDG)); + + } else { + + // d) Define bin labels indirectly by storing them in y-axis title + local executable PostprocessLabels.C. + // Algorithm is documented in the function preamble above. + + TString yAxisTitle = ""; + yAxisTitle += TString::Format("%d:fTaskIsConfiguredFromJson = %s; ", static_cast(eTaskIsConfiguredFromJson), tc.fTaskIsConfiguredFromJson.Data()); - fBasePro->GetXaxis()->SetBinLabel(eRunNumber, Form("fRunNumber = %s", "__RUN_NUMBER__")); - // I have to do it this way via placeholder, because run number is available only when i start to process data. - // Then, I replace placeholder with run number in PropagateRunNumber(...) + yAxisTitle += TString::Format("%d:fTaskName = %s; ", static_cast(eTaskName), tc.fTaskName.Data()); - fBasePro->GetXaxis()->SetBinLabel(eDryRun, "fDryRun"); - fBasePro->Fill(eDryRun, static_cast(tc.fDryRun)); + yAxisTitle += TString::Format("%d:fRunNumber = %s; ", static_cast(eRunNumber), "__RUN_NUMBER__"); + // I have to do it this way via placeholder, because run number is available only when i start to process data. + // Then, I replace placeholder with run number in PropagateRunNumber(...) - fBasePro->GetXaxis()->SetBinLabel(eVerbose, "fVerbose"); - fBasePro->Fill(eVerbose, static_cast(tc.fVerbose)); + yAxisTitle += TString::Format("%d:fDryRun; ", static_cast(eDryRun)); + fBasePro->Fill(eDryRun, static_cast(tc.fDryRun)); - fBasePro->GetXaxis()->SetBinLabel(eVerboseUtility, "fVerboseUtility"); - fBasePro->Fill(eVerboseUtility, static_cast(tc.fVerboseUtility)); + yAxisTitle += TString::Format("%d:fVerbose; ", static_cast(eVerbose)); + fBasePro->Fill(eVerbose, static_cast(tc.fVerbose)); - fBasePro->GetXaxis()->SetBinLabel(eVerboseForEachParticle, "fVerboseForEachParticle"); - fBasePro->Fill(eVerboseForEachParticle, static_cast(tc.fVerboseForEachParticle)); + yAxisTitle += TString::Format("%d:fVerboseUtility; ", static_cast(eVerboseUtility)); + fBasePro->Fill(eVerboseUtility, static_cast(tc.fVerboseUtility)); - fBasePro->GetXaxis()->SetBinLabel(eVerboseEventCounter, "fVerboseEventCounter"); - fBasePro->Fill(eVerboseEventCounter, static_cast(tc.fVerboseEventCounter)); + yAxisTitle += TString::Format("%d:fVerboseForEachParticle; ", static_cast(eVerboseForEachParticle)); + fBasePro->Fill(eVerboseForEachParticle, static_cast(tc.fVerboseForEachParticle)); - fBasePro->GetXaxis()->SetBinLabel(ePlainPrintout, "fPlainPrintout"); - fBasePro->Fill(ePlainPrintout, static_cast(tc.fPlainPrintout)); + yAxisTitle += TString::Format("%d:fVerboseEventCounter; ", static_cast(eVerboseEventCounter)); + fBasePro->Fill(eVerboseEventCounter, static_cast(tc.fVerboseEventCounter)); - fBasePro->GetXaxis()->SetBinLabel(eDoAdditionalInsanityChecks, "fDoAdditionalInsanityChecks"); - fBasePro->Fill(eDoAdditionalInsanityChecks, static_cast(tc.fDoAdditionalInsanityChecks)); + yAxisTitle += TString::Format("%d:fPlainPrintout; ", static_cast(ePlainPrintout)); + fBasePro->Fill(ePlainPrintout, static_cast(tc.fPlainPrintout)); - fBasePro->GetXaxis()->SetBinLabel(eInsanityCheckForEachParticle, "fInsanityCheckForEachParticle"); - fBasePro->Fill(eInsanityCheckForEachParticle, static_cast(tc.fInsanityCheckForEachParticle)); + yAxisTitle += TString::Format("%d:fDoAdditionalInsanityChecks; ", static_cast(eDoAdditionalInsanityChecks)); + fBasePro->Fill(eDoAdditionalInsanityChecks, static_cast(tc.fDoAdditionalInsanityChecks)); - fBasePro->GetXaxis()->SetBinLabel(eWhichProcess, Form("WhichProcess = %s", tc.fWhichProcess.Data())); + yAxisTitle += TString::Format("%d:fInsanityCheckForEachParticle; ", static_cast(eInsanityCheckForEachParticle)); + fBasePro->Fill(eInsanityCheckForEachParticle, static_cast(tc.fInsanityCheckForEachParticle)); - fBasePro->GetXaxis()->SetBinLabel(eRandomSeed, "fRandomSeed"); - fBasePro->Fill(eRandomSeed, static_cast(tc.fRandomSeed)); + yAxisTitle += TString::Format("%d:fWhichProcess = %s; ", static_cast(eWhichProcess), tc.fWhichProcess.Data()); - fBasePro->GetXaxis()->SetBinLabel(eUseFisherYates, "fUseFisherYates"); - fBasePro->Fill(eUseFisherYates, static_cast(tc.fUseFisherYates)); + yAxisTitle += TString::Format("%d:fRandomSeed; ", static_cast(eRandomSeed)); + fBasePro->Fill(eRandomSeed, static_cast(tc.fRandomSeed)); - fBasePro->GetXaxis()->SetBinLabel(eFixedNumberOfRandomlySelectedTracks, "fFixedNumberOfRandomlySelectedTracks"); - fBasePro->Fill(eFixedNumberOfRandomlySelectedTracks, static_cast(tc.fFixedNumberOfRandomlySelectedTracks)); + yAxisTitle += TString::Format("%d:fUseFisherYates; ", static_cast(eUseFisherYates)); + fBasePro->Fill(eUseFisherYates, static_cast(tc.fUseFisherYates)); - fBasePro->GetXaxis()->SetBinLabel(eUseStopwatch, "fUseStopwatch"); - fBasePro->Fill(eUseStopwatch, static_cast(tc.fUseStopwatch)); + yAxisTitle += TString::Format("%d:fFixedNumberOfRandomlySelectedTracks; ", static_cast(eFixedNumberOfRandomlySelectedTracks)); + fBasePro->Fill(eFixedNumberOfRandomlySelectedTracks, static_cast(tc.fFixedNumberOfRandomlySelectedTracks)); - fBasePro->GetXaxis()->SetBinLabel(eFloatingPointPrecision, "fFloatingPointPrecision"); - fBasePro->Fill(eFloatingPointPrecision, tc.fFloatingPointPrecision); + yAxisTitle += TString::Format("%d:fUseStopwatch; ", static_cast(eUseStopwatch)); + fBasePro->Fill(eUseStopwatch, static_cast(tc.fUseStopwatch)); - fBasePro->GetXaxis()->SetBinLabel(eSequentialBailout, "fSequentialBailout"); - fBasePro->Fill(eSequentialBailout, static_cast(tc.fSequentialBailout)); + yAxisTitle += TString::Format("%d:fFloatingPointPrecision; ", static_cast(eFloatingPointPrecision)); + fBasePro->Fill(eFloatingPointPrecision, static_cast(tc.fFloatingPointPrecision)); - fBasePro->GetXaxis()->SetBinLabel(eUseSpecificCuts, "fUseSpecificCuts"); - fBasePro->Fill(eUseSpecificCuts, static_cast(tc.fUseSpecificCuts)); + yAxisTitle += TString::Format("%d:fSequentialBailout; ", static_cast(eSequentialBailout)); + fBasePro->Fill(eSequentialBailout, static_cast(tc.fSequentialBailout)); - fBasePro->GetXaxis()->SetBinLabel(eWhichSpecificCuts, Form("WhichSpecificCuts = %s", tc.fWhichSpecificCuts.Data())); + yAxisTitle += TString::Format("%d:fUseSpecificCuts; ", static_cast(eUseSpecificCuts)); + fBasePro->Fill(eUseSpecificCuts, static_cast(tc.fUseSpecificCuts)); + yAxisTitle += TString::Format("%d:fWhichSpecificCuts = %s; ", static_cast(eWhichSpecificCuts), tc.fWhichSpecificCuts.Data()); + + yAxisTitle += TString::Format("%d:fSkipTheseRuns = %s; ", static_cast(eSkipTheseRuns), tc.fSkipTheseRuns.Data()); + + yAxisTitle += TString::Format("%d:fUseSetBinLabel; ", static_cast(eUseSetBinLabel)); + fBasePro->Fill(eUseSetBinLabel, static_cast(tc.fUseSetBinLabel)); + + yAxisTitle += TString::Format("%d:fUseClone; ", static_cast(eUseClone)); + fBasePro->Fill(eUseClone, static_cast(tc.fUseClone)); + + yAxisTitle += TString::Format("%d:fUseFormula; ", static_cast(eUseFormula)); + fBasePro->Fill(eUseFormula, static_cast(tc.fUseFormula)); + + yAxisTitle += TString::Format("%d:fUseDatabasePDG; ", static_cast(eUseDatabasePDG)); + fBasePro->Fill(eUseDatabasePDG, static_cast(tc.fUseDatabasePDG)); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() != static_cast(eConfiguration_N)) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() = %d != eConfiguration_N = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), static_cast(eConfiguration_N)); + } + delete oa; + + // *) Okay, set the title: + fBasePro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else + + // e) Add configured base TProfile to the list: fBaseList->Add(fBasePro); if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void BookBaseList() +} // void bookBaseList() //============================================================ -void DefaultConfiguration() +void defaultConfiguration() { // Default task configuration. // a) Default values are hardcoded as Configurables in the file MuPa-Configurables.h @@ -144,12 +267,14 @@ void DefaultConfiguration() tc.fTaskName = TString(cf_tc.cfTaskName); tc.fDryRun = cf_tc.cfDryRun; tc.fVerbose = cf_tc.cfVerbose; + if (tc.fVerbose) { StartFunction(__FUNCTION__); // yes, here } tc.fVerboseUtility = cf_tc.cfVerboseUtility; tc.fVerboseForEachParticle = cf_tc.cfVerboseForEachParticle; tc.fVerboseEventCounter = cf_tc.cfVerboseEventCounter; + tc.fVerboseEventCut = cf_tc.cfVerboseEventCut; tc.fPlainPrintout = cf_tc.cfPlainPrintout; tc.fDoAdditionalInsanityChecks = cf_tc.cfDoAdditionalInsanityChecks; // Set automatically what to process, from an implicit variable "doprocessSomeProcessName" within a PROCESS_SWITCH clause: @@ -163,6 +288,8 @@ void DefaultConfiguration() tc.fProcess[eProcessRecSim_Run1] = doprocessRecSim_Run1; tc.fProcess[eProcessSim_Run1] = doprocessSim_Run1; tc.fProcess[eProcessTest] = doprocessTest; + tc.fProcess[eProcessQA] = doprocessQA; + tc.fProcess[eProcessHepMChi] = doprocessHepMChi; // Temporarary bailout protection against cases which are not implemented/validated yet: if (tc.fProcess[eProcessSim]) { @@ -186,7 +313,7 @@ void DefaultConfiguration() } // Set automatically generic flags, from above individual flags: - tc.fProcess[eGenericRec] = tc.fProcess[eProcessRec] || tc.fProcess[eProcessRec_Run2] || tc.fProcess[eProcessRec_Run1] || tc.fProcess[eProcessTest]; + tc.fProcess[eGenericRec] = tc.fProcess[eProcessRec] || tc.fProcess[eProcessRec_Run2] || tc.fProcess[eProcessRec_Run1] || tc.fProcess[eProcessTest] || tc.fProcess[eProcessQA]; tc.fProcess[eGenericRecSim] = tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessRecSim_Run2] || tc.fProcess[eProcessRecSim_Run1]; tc.fProcess[eGenericSim] = tc.fProcess[eProcessSim] || tc.fProcess[eProcessSim_Run2] || tc.fProcess[eProcessSim_Run1]; @@ -211,6 +338,10 @@ void DefaultConfiguration() tc.fWhichProcess = "ProcessSim_Run1"; } else if (tc.fProcess[eProcessTest]) { tc.fWhichProcess = "ProcessTest"; + } else if (tc.fProcess[eProcessQA]) { + tc.fWhichProcess = "ProcessQA"; + } else if (tc.fProcess[eProcessHepMChi]) { + tc.fWhichProcess = "ProcessHepMChi"; } tc.fRandomSeed = cf_tc.cfRandomSeed; @@ -221,6 +352,11 @@ void DefaultConfiguration() tc.fSequentialBailout = cf_tc.cfSequentialBailout; tc.fUseSpecificCuts = cf_tc.cfUseSpecificCuts; tc.fWhichSpecificCuts = cf_tc.cfWhichSpecificCuts; + tc.fSkipTheseRuns = cf_tc.cfSkipTheseRuns; + tc.fUseSetBinLabel = cf_tc.cfUseSetBinLabel; + tc.fUseClone = cf_tc.cfUseClone; + tc.fUseFormula = cf_tc.cfUseFormula; + tc.fUseDatabasePDG = cf_tc.cfUseDatabasePDG; // *) Event histograms (for QA see below): eh.fEventHistogramsName[eNumberOfEvents] = "NumberOfEvents"; @@ -228,9 +364,9 @@ void DefaultConfiguration() eh.fEventHistogramsName[eMultiplicity] = "Multiplicity"; eh.fEventHistogramsName[eReferenceMultiplicity] = "ReferenceMultiplicity"; eh.fEventHistogramsName[eCentrality] = "Centrality"; - eh.fEventHistogramsName[eVertex_x] = "Vertex_x"; - eh.fEventHistogramsName[eVertex_y] = "Vertex_y"; - eh.fEventHistogramsName[eVertex_z] = "Vertex_z"; + eh.fEventHistogramsName[eVertexX] = "VertexX"; + eh.fEventHistogramsName[eVertexY] = "VertexY"; + eh.fEventHistogramsName[eVertexZ] = "VertexZ"; eh.fEventHistogramsName[eNContributors] = "NContributors"; eh.fEventHistogramsName[eImpactParameter] = "ImpactParameter"; eh.fEventHistogramsName[eEventPlaneAngle] = "EventPlaneAngle"; @@ -239,7 +375,7 @@ void DefaultConfiguration() eh.fEventHistogramsName[eCurrentRunDuration] = "CurrentRunDuration"; eh.fEventHistogramsName[eMultMCNParticlesEta08] = "MultMCNParticlesEta08"; - for (Int_t t = 0; t < eEventHistograms_N; t++) { + for (int t = 0; t < eEventHistograms_N; t++) { if (eh.fEventHistogramsName[t].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : name of fEventHistogramsName[%d] is not set \033[0m", __FUNCTION__, __LINE__, static_cast(t)); } @@ -256,9 +392,9 @@ void DefaultConfiguration() ec.fEventCutName[eMultiplicity] = "Multiplicity"; ec.fEventCutName[eReferenceMultiplicity] = "ReferenceMultiplicity"; ec.fEventCutName[eCentrality] = "Centrality"; - ec.fEventCutName[eVertex_x] = "Vertex_x"; - ec.fEventCutName[eVertex_y] = "Vertex_y"; - ec.fEventCutName[eVertex_z] = "Vertex_z"; + ec.fEventCutName[eVertexX] = "VertexX"; + ec.fEventCutName[eVertexY] = "VertexY"; + ec.fEventCutName[eVertexZ] = "VertexZ"; ec.fEventCutName[eNContributors] = "NContributors"; ec.fEventCutName[eImpactParameter] = "ImpactParameter"; ec.fEventCutName[eEventPlaneAngle] = "EventPlaneAngle"; @@ -288,7 +424,20 @@ void DefaultConfiguration() ec.fEventCutName[eIsGoodITSLayersAll] = "IsGoodITSLayersAll"; ec.fEventCutName[eOccupancyEstimator] = "OccupancyEstimator"; ec.fEventCutName[eMinVertexDistanceFromIP] = "MinVertexDistanceFromIP"; - for (Int_t t = 0; t < eEventCuts_N; t++) { + ec.fEventCutName[eNoPileupTPC] = "NoPileupTPC"; + ec.fEventCutName[eNoPileupFromSPD] = "NoPileupFromSPD"; + ec.fEventCutName[eNoSPDOnVsOfPileup] = "NoSPDOnVsOfPileup"; + ec.fEventCutName[eRefMultVsNContrUp] = "RefMultVsNContrUp"; + ec.fEventCutName[eRefMultVsNContrLow] = "RefMultVsNContrLow"; + ec.fEventCutName[eCentralityCorrelationsCut] = "CentralityCorrelationsCut"; + ec.fEventCutName[eFT0Bad] = "FT0Bad"; + ec.fEventCutName[eITSBad] = "ITSBad"; + ec.fEventCutName[eITSLimAccMCRepr] = "ITSLimAccMCRepr"; + ec.fEventCutName[eTPCBadTracking] = "TPCBadTracking"; + ec.fEventCutName[eTPCLimAccMCRepr] = "TPCLimAccMCRepr"; + ec.fEventCutName[eTPCBadPID] = "TPCBadPID"; + ec.fEventCutName[eCentralityWeights] = "CentralityWeights"; + for (int t = 0; t < eEventCuts_N; t++) { if (ec.fEventCutName[t].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : event cut name is not set for ec.fEventCutName[%d]. The last cut name which was set is \"%s\" \033[0m", __FUNCTION__, __LINE__, t, ec.fEventCutName[t - 1].Data()); } @@ -301,6 +450,7 @@ void DefaultConfiguration() ph.fParticleHistogramsName[eCharge] = "Charge"; ph.fParticleHistogramsName[etpcNClsFindable] = "tpcNClsFindable"; ph.fParticleHistogramsName[etpcNClsShared] = "tpcNClsShared"; + ph.fParticleHistogramsName[eitsChi2NCl] = "itsChi2NCl"; ph.fParticleHistogramsName[etpcNClsFound] = "tpcNClsFound"; ph.fParticleHistogramsName[etpcNClsCrossedRows] = "tpcNClsCrossedRows"; ph.fParticleHistogramsName[eitsNCls] = "itsNCls"; @@ -308,10 +458,11 @@ void DefaultConfiguration() ph.fParticleHistogramsName[etpcCrossedRowsOverFindableCls] = "tpcCrossedRowsOverFindableCls"; ph.fParticleHistogramsName[etpcFoundOverFindableCls] = "tpcFoundOverFindableCls"; ph.fParticleHistogramsName[etpcFractionSharedCls] = "tpcFractionSharedCls"; + ph.fParticleHistogramsName[etpcChi2NCl] = "tpcChi2NCl"; ph.fParticleHistogramsName[edcaXY] = "dcaXY"; ph.fParticleHistogramsName[edcaZ] = "dcaZ"; ph.fParticleHistogramsName[ePDG] = "PDG"; - for (Int_t t = 0; t < eParticleHistograms_N; t++) { + for (int t = 0; t < eParticleHistograms_N; t++) { if (ph.fParticleHistogramsName[t].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : name of fParticleHistogramsName[%d] is not set \033[0m", __FUNCTION__, __LINE__, t); } @@ -320,7 +471,7 @@ void DefaultConfiguration() // *) Particle histograms 2D (for QA see below): ph.fParticleHistogramsName2D[ePhiPt] = Form("%s_vs_%s", ph.fParticleHistogramsName[ePhi].Data(), ph.fParticleHistogramsName[ePt].Data()), ph.fParticleHistogramsName2D[ePhiEta] = Form("%s_vs_%s", ph.fParticleHistogramsName[ePhi].Data(), ph.fParticleHistogramsName[eEta].Data()); - for (Int_t t = 0; t < eParticleHistograms2D_N; t++) { + for (int t = 0; t < eParticleHistograms2D_N; t++) { if (ph.fParticleHistogramsName2D[t].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : name of fParticleHistogramsName2D[%d] is not set \033[0m", __FUNCTION__, __LINE__, t); } @@ -337,6 +488,7 @@ void DefaultConfiguration() pc.fParticleCutName[eCharge] = "Charge"; pc.fParticleCutName[etpcNClsFindable] = "tpcNClsFindable"; pc.fParticleCutName[etpcNClsShared] = "tpcNClsShared"; + pc.fParticleCutName[eitsChi2NCl] = "itsChi2NCl"; pc.fParticleCutName[etpcNClsFound] = "tpcNClsFound"; pc.fParticleCutName[etpcNClsCrossedRows] = "tpcNClsCrossedRows"; pc.fParticleCutName[eitsNCls] = "itsNCls"; @@ -344,17 +496,20 @@ void DefaultConfiguration() pc.fParticleCutName[etpcCrossedRowsOverFindableCls] = "tpcCrossedRowsOverFindableCls"; pc.fParticleCutName[etpcFoundOverFindableCls] = "tpcFoundOverFindableCls"; pc.fParticleCutName[etpcFractionSharedCls] = "tpcFractionSharedCls"; + pc.fParticleCutName[etpcChi2NCl] = "tpcChi2NCl"; pc.fParticleCutName[edcaXY] = "dcaXY"; pc.fParticleCutName[edcaZ] = "dcaZ"; pc.fParticleCutName[ePDG] = "PDG"; + pc.fParticleCutName[etrackCutFlag] = "trackCutFlag"; pc.fParticleCutName[etrackCutFlagFb1] = "trackCutFlagFb1"; pc.fParticleCutName[etrackCutFlagFb2] = "trackCutFlagFb2"; pc.fParticleCutName[eisQualityTrack] = "isQualityTrack"; pc.fParticleCutName[eisPrimaryTrack] = "isPrimaryTrack"; pc.fParticleCutName[eisInAcceptanceTrack] = "isInAcceptanceTrack"; pc.fParticleCutName[eisGlobalTrack] = "isGlobalTrack"; + pc.fParticleCutName[eisPVContributor] = "isPVContributor"; pc.fParticleCutName[ePtDependentDCAxyParameterization] = "PtDependentDCAxyParameterization"; - for (Int_t t = 0; t < eParticleCuts_N; t++) { + for (int t = 0; t < eParticleCuts_N; t++) { if (pc.fParticleCutName[t].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : particle cut name is not set for pc.fParticleCutName[%d] \033[0m", __FUNCTION__, __LINE__, t); } @@ -365,26 +520,106 @@ void DefaultConfiguration() // *) Multiparticle correlations: mupa.fCalculateCorrelations = cf_mupa.cfCalculateCorrelations; - mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTEGRATED] = cf_mupa.cfCalculateCorrelationsAsFunctionOfIntegrated && mupa.fCalculateCorrelations; - mupa.fCalculateCorrelationsAsFunctionOf[AFO_MULTIPLICITY] = cf_mupa.cfCalculateCorrelationsAsFunctionOfMultiplicity && mupa.fCalculateCorrelations; - mupa.fCalculateCorrelationsAsFunctionOf[AFO_CENTRALITY] = cf_mupa.cfCalculateCorrelationsAsFunctionOfCentrality && mupa.fCalculateCorrelations; - mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] = cf_mupa.cfCalculateCorrelationsAsFunctionOfPt && mupa.fCalculateCorrelations; - mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] = cf_mupa.cfCalculateCorrelationsAsFunctionOfEta && mupa.fCalculateCorrelations; - mupa.fCalculateCorrelationsAsFunctionOf[AFO_OCCUPANCY] = cf_mupa.cfCalculateCorrelationsAsFunctionOfOccupancy && mupa.fCalculateCorrelations; - mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTERACTIONRATE] = cf_mupa.cfCalculateCorrelationsAsFunctionOfInteractionRate && mupa.fCalculateCorrelations; - mupa.fCalculateCorrelationsAsFunctionOf[AFO_CURRENTRUNDURATION] = cf_mupa.cfCalculateCorrelationsAsFunctionOfCurrentRunDuration && mupa.fCalculateCorrelations; + + // *) Use configurable array cfCalculateCorrelationsAsFunctionOf, to specify vs which observable correlations will be calculated (flags 1 or 0). + // Supported format: "0-someName" and "1-someName", where "-" is a field separator. + // Ordering of the flags in that array is interpreted through ordering of enums in enum eAsFunctionOf. + auto lCalculateCorrelationsAsFunctionOf = cf_mupa.cfCalculateCorrelationsAsFunctionOf.value; // this is now the local version of that string array from configurable. + if (lCalculateCorrelationsAsFunctionOf.size() != eAsFunctionOf_N) { + LOGF(info, "\033[1;31m lCalculateCorrelationsAsFunctionOf.size() = %d\033[0m", lCalculateCorrelationsAsFunctionOf.size()); + LOGF(info, "\033[1;31m eAsFunctionOf_N) = %d\033[0m", static_cast(eAsFunctionOf_N)); + LOGF(fatal, "\033[1;31m%s at line %d : Mismatch in the number of flags in configurable cfCalculateCorrelationsAsFunctionOf, and number of entries in enum eAsFunctionOf_N \n \033[0m", __FUNCTION__, __LINE__); + } + + // I append "&& mupa.fCalculateCorrelations" below, to switch off calculation of all correlations with one common flag: + mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTEGRATED] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_INTEGRATED]) && mupa.fCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_MULTIPLICITY] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_MULTIPLICITY]) && mupa.fCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_CENTRALITY] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_CENTRALITY]) && mupa.fCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_PT]) && mupa.fCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_ETA]) && mupa.fCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_OCCUPANCY] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_OCCUPANCY]) && mupa.fCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTERACTIONRATE] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_INTERACTIONRATE]) && mupa.fCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_CURRENTRUNDURATION] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_CURRENTRUNDURATION]) && mupa.fCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_VZ] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_VZ]) && mupa.fCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_CHARGE] = Alright(lCalculateCorrelationsAsFunctionOf[AFO_CHARGE]) && mupa.fCalculateCorrelations; + // ... // *) Test0: + // 1D: t0.fCalculateTest0 = cf_t0.cfCalculateTest0; - t0.fCalculateTest0AsFunctionOf[AFO_INTEGRATED] = cf_t0.cfCalculateTest0AsFunctionOfIntegrated && t0.fCalculateTest0; - t0.fCalculateTest0AsFunctionOf[AFO_MULTIPLICITY] = cf_t0.cfCalculateTest0AsFunctionOfMultiplicity && t0.fCalculateTest0; - t0.fCalculateTest0AsFunctionOf[AFO_CENTRALITY] = cf_t0.cfCalculateTest0AsFunctionOfCentrality && t0.fCalculateTest0; - t0.fCalculateTest0AsFunctionOf[AFO_PT] = cf_t0.cfCalculateTest0AsFunctionOfPt && t0.fCalculateTest0; - t0.fCalculateTest0AsFunctionOf[AFO_ETA] = cf_t0.cfCalculateTest0AsFunctionOfEta && t0.fCalculateTest0; - t0.fCalculateTest0AsFunctionOf[AFO_OCCUPANCY] = cf_t0.cfCalculateTest0AsFunctionOfOccupancy && t0.fCalculateTest0; - t0.fCalculateTest0AsFunctionOf[AFO_INTERACTIONRATE] = cf_t0.cfCalculateTest0AsFunctionOfInteractionRate && t0.fCalculateTest0; - t0.fCalculateTest0AsFunctionOf[AFO_CURRENTRUNDURATION] = cf_t0.cfCalculateTest0AsFunctionOfCurrentRunDuration && t0.fCalculateTest0; - if (t0.fCalculateTest0) { + + // *) Use configurable array cfCalculateTest0AsFunctionOf, to specify vs which observable Test0 will be calculated (flags 1 or 0). + // Supported format: "0-someName" and "1-someName", where "-" is a field separator. + // Ordering of the flags in that array is interpreted through ordering of enums in enum eAsFunctionOf. + auto lCalculateTest0AsFunctionOf = cf_t0.cfCalculateTest0AsFunctionOf.value; // this is now the local version of that string array from configurable. + if (lCalculateTest0AsFunctionOf.size() != eAsFunctionOf_N) { + LOGF(info, "\033[1;31m lCalculateTest0AsFunctionOf.size() = %d\033[0m", lCalculateTest0AsFunctionOf.size()); + LOGF(info, "\033[1;31m eAsFunctionOf_N) = %d\033[0m", static_cast(eAsFunctionOf_N)); + LOGF(fatal, "\033[1;31m%s at line %d : Mismatch in the number of flags in configurable cfCalculateTest0AsFunctionOf, and number of entries in enum eAsFunctionOf_N \n \033[0m", __FUNCTION__, __LINE__); + } + + // I append "&& t0.fCalculateTest0" below, to switch off calculation of all Test0 with one common flag: + t0.fCalculateTest0AsFunctionOf[AFO_INTEGRATED] = Alright(lCalculateTest0AsFunctionOf[AFO_INTEGRATED]) && t0.fCalculateTest0; + t0.fCalculateTest0AsFunctionOf[AFO_MULTIPLICITY] = Alright(lCalculateTest0AsFunctionOf[AFO_MULTIPLICITY]) && t0.fCalculateTest0; + t0.fCalculateTest0AsFunctionOf[AFO_CENTRALITY] = Alright(lCalculateTest0AsFunctionOf[AFO_CENTRALITY]) && t0.fCalculateTest0; + t0.fCalculateTest0AsFunctionOf[AFO_PT] = Alright(lCalculateTest0AsFunctionOf[AFO_PT]) && t0.fCalculateTest0; + t0.fCalculateTest0AsFunctionOf[AFO_ETA] = Alright(lCalculateTest0AsFunctionOf[AFO_ETA]) && t0.fCalculateTest0; + t0.fCalculateTest0AsFunctionOf[AFO_OCCUPANCY] = Alright(lCalculateTest0AsFunctionOf[AFO_OCCUPANCY]) && t0.fCalculateTest0; + t0.fCalculateTest0AsFunctionOf[AFO_INTERACTIONRATE] = Alright(lCalculateTest0AsFunctionOf[AFO_INTERACTIONRATE]) && t0.fCalculateTest0; + t0.fCalculateTest0AsFunctionOf[AFO_CURRENTRUNDURATION] = Alright(lCalculateTest0AsFunctionOf[AFO_CURRENTRUNDURATION]) && t0.fCalculateTest0; + t0.fCalculateTest0AsFunctionOf[AFO_VZ] = Alright(lCalculateTest0AsFunctionOf[AFO_VZ]) && t0.fCalculateTest0; + t0.fCalculateTest0AsFunctionOf[AFO_CHARGE] = Alright(lCalculateTest0AsFunctionOf[AFO_CHARGE]) && t0.fCalculateTest0; + // ... + + // 2D: + t0.fCalculate2DTest0 = cf_t0.cfCalculate2DTest0; + + // *) Use configurable array cfCalculate2DTest0AsFunctionOf, to specify vs which two observables Test0 will be calculated (flags 1 or 0). + // Supported format: "0-someName1_someName_2" and "1-someName1_someName_2", where both "-" and "_" are IFS, but with different meaning. + // Ordering of the flags in that array is interpreted through ordering of enums in enum eAsFunctionOf2D_N. + auto lCalculate2DTest0AsFunctionOf = cf_t0.cfCalculate2DTest0AsFunctionOf.value; // this is now the local version of that string array from configurable. + if (lCalculate2DTest0AsFunctionOf.size() != eAsFunctionOf2D_N) { + LOGF(info, "\033[1;31m lCalculate2DTest0AsFunctionOf.size() = %d\033[0m", lCalculate2DTest0AsFunctionOf.size()); + LOGF(info, "\033[1;31m eAsFunctionOf2D_N) = %d\033[0m", static_cast(eAsFunctionOf2D_N)); + LOGF(fatal, "\033[1;31m%s at line %d : Mismatch in the number of flags in configurable cfCalculate2DTest0AsFunctionOf, and number of entries in enum eAsFunctionOf2D_N \n \033[0m", __FUNCTION__, __LINE__); + } + + // I append "&& t0.fCalculate2DTest0" below, to switch off calculation of all Test0 with one common flag: + t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_PT] = Alright(lCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_PT]) && t0.fCalculate2DTest0; + t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_ETA] = Alright(lCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_ETA]) && t0.fCalculate2DTest0; + t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_CHARGE] = Alright(lCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_CHARGE]) && t0.fCalculate2DTest0; + t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_VZ] = Alright(lCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_VZ]) && t0.fCalculate2DTest0; + t0.fCalculate2DTest0AsFunctionOf[AFO_PT_ETA] = Alright(lCalculate2DTest0AsFunctionOf[AFO_PT_ETA]) && t0.fCalculate2DTest0; + t0.fCalculate2DTest0AsFunctionOf[AFO_PT_CHARGE] = Alright(lCalculate2DTest0AsFunctionOf[AFO_PT_CHARGE]) && t0.fCalculate2DTest0; + t0.fCalculate2DTest0AsFunctionOf[AFO_ETA_CHARGE] = Alright(lCalculate2DTest0AsFunctionOf[AFO_ETA_CHARGE]) && t0.fCalculate2DTest0; + + // ... + + // 3D: + t0.fCalculate3DTest0 = cf_t0.cfCalculate3DTest0; + + // *) Use configurable array cfCalculate3DTest0AsFunctionOf, to specify vs which two observables Test0 will be calculated (flags 1 or 0). + // Supported format: "0-someName1_someName_2" and "1-someName1_someName_2", where both "-" and "_" are IFS, but with different meaning. + // Ordering of the flags in that array is interpreted through ordering of enums in enum eAsFunctionOf3D_N. + auto lCalculate3DTest0AsFunctionOf = cf_t0.cfCalculate3DTest0AsFunctionOf.value; // this is now the local version of that string array from configurable. + if (lCalculate3DTest0AsFunctionOf.size() != eAsFunctionOf3D_N) { + LOGF(info, "\033[1;31m lCalculate3DTest0AsFunctionOf.size() = %d\033[0m", lCalculate3DTest0AsFunctionOf.size()); + LOGF(info, "\033[1;31m eAsFunctionOf3D_N) = %d\033[0m", static_cast(eAsFunctionOf3D_N)); + LOGF(fatal, "\033[1;31m%s at line %d : Mismatch in the number of flags in configurable cfCalculate3DTest0AsFunctionOf, and number of entries in enum eAsFunctionOf3D_N \n \033[0m", __FUNCTION__, __LINE__); + } + + // I append "&& t0.fCalculate3DTest0" below, to switch off calculation of all Test0 with one common flag: + t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_ETA] = Alright(lCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_ETA]) && t0.fCalculate3DTest0; + t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_CHARGE] = Alright(lCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_CHARGE]) && t0.fCalculate3DTest0; + t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_VZ] = Alright(lCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_VZ]) && t0.fCalculate3DTest0; + t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_VZ] = Alright(lCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_VZ]) && t0.fCalculate3DTest0; + t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_CHARGE] = Alright(lCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_CHARGE]) && t0.fCalculate3DTest0; + t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_VZ_CHARGE] = Alright(lCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_VZ_CHARGE]) && t0.fCalculate3DTest0; + t0.fCalculate3DTest0AsFunctionOf[AFO_PT_ETA_CHARGE] = Alright(lCalculate3DTest0AsFunctionOf[AFO_PT_ETA_CHARGE]) && t0.fCalculate3DTest0; + + // ... + + if (t0.fCalculateTest0 || t0.fCalculate2DTest0 || t0.fCalculate3DTest0) { t0.fFileWithLabels = TString(cf_t0.cfFileWithLabels); t0.fUseDefaultLabels = cf_t0.cfUseDefaultLabels; t0.fWhichDefaultLabels = TString(cf_t0.cfWhichDefaultLabels); @@ -394,8 +629,73 @@ void DefaultConfiguration() pw.fUseWeights[wPHI] = cf_pw.cfUsePhiWeights; pw.fUseWeights[wPT] = cf_pw.cfUsePtWeights; pw.fUseWeights[wETA] = cf_pw.cfUseEtaWeights; - pw.fUseDiffWeights[wPHIPT] = cf_pw.cfUseDiffPhiPtWeights; - pw.fUseDiffWeights[wPHIETA] = cf_pw.cfUseDiffPhiEtaWeights; + pw.fUseDiffWeights[wPHIPT] = cf_pw.cfUseDiffPhiPtWeights; // TBI 20250222 obsolete + pw.fUseDiffWeights[wPHIETA] = cf_pw.cfUseDiffPhiEtaWeights; // TBI 20250222 obsolete + + // **) Differential phi weights: + auto lWhichDiffPhiWeights = cf_pw.cfWhichDiffPhiWeights.value; + if (lWhichDiffPhiWeights.size() != eDiffPhiWeights_N) { + LOGF(info, "\033[1;31m lWhichDiffPhiWeights.size() = %d\033[0m", lWhichDiffPhiWeights.size()); + LOGF(info, "\033[1;31m eDiffPhiWeights_N = %d\033[0m", static_cast(eDiffPhiWeights_N)); + LOGF(fatal, "\033[1;31m%s at line %d : Mismatch in the number of flags in configurable cfWhichDiffPhiWeights, and number of entries in enum eDiffPhiWeights_N \n \033[0m", __FUNCTION__, __LINE__); + } + for (int dpw = 0; dpw < eDiffPhiWeights_N; dpw++) { // "differential phi weight" + if (TString(lWhichDiffPhiWeights[dpw]).Contains("wPhi")) { + pw.fUseDiffPhiWeights[wPhiPhiAxis] = Alright(lWhichDiffPhiWeights[dpw]); // if I pass "1-Phi" => true, "0-Phi" => false + } else if (TString(lWhichDiffPhiWeights[dpw]).Contains("wPt")) { + pw.fUseDiffPhiWeights[wPhiPtAxis] = Alright(lWhichDiffPhiWeights[dpw]) && pw.fUseDiffPhiWeights[wPhiPhiAxis]; // I chain here with wPhiPhiAxis , so that I can switch off all differential phi weights, if phi itself is not set to true + } else if (TString(lWhichDiffPhiWeights[dpw]).Contains("wEta")) { + pw.fUseDiffPhiWeights[wPhiEtaAxis] = Alright(lWhichDiffPhiWeights[dpw]) && pw.fUseDiffPhiWeights[wPhiPhiAxis]; + } else if (TString(lWhichDiffPhiWeights[dpw]).Contains("wCharge")) { + pw.fUseDiffPhiWeights[wPhiChargeAxis] = Alright(lWhichDiffPhiWeights[dpw]) && pw.fUseDiffPhiWeights[wPhiPhiAxis]; + } else if (TString(lWhichDiffPhiWeights[dpw]).Contains("wCentrality")) { + pw.fUseDiffPhiWeights[wPhiCentralityAxis] = Alright(lWhichDiffPhiWeights[dpw]) && pw.fUseDiffPhiWeights[wPhiPhiAxis]; + } else if (TString(lWhichDiffPhiWeights[dpw]).Contains("wVertexZ") || TString(lWhichDiffPhiWeights[dpw]).Contains("wVertex_z")) { // TBI 20250402 I keep "wVertex_z" here just in case I still have somewhere dependency on it, remove eventually + pw.fUseDiffPhiWeights[wPhiVertexZAxis] = Alright(lWhichDiffPhiWeights[dpw]) && pw.fUseDiffPhiWeights[wPhiPhiAxis]; + } else { + LOGF(fatal, "\033[1;31m%s at line %d : The setting %s in configurable cfWhichDiffPhiWeights is not supported yet. See enum eDiffPhiWeights . \n \033[0m", __FUNCTION__, __LINE__, TString(lWhichDiffPhiWeights[dpw]).Data()); + } + } + + // **) Differential pt weights: + auto lWhichDiffPtWeights = cf_pw.cfWhichDiffPtWeights.value; + if (lWhichDiffPtWeights.size() != eDiffPtWeights_N) { + LOGF(info, "\033[1;31m lWhichDiffPtWeights.size() = %d\033[0m", lWhichDiffPtWeights.size()); + LOGF(info, "\033[1;31m eDiffPtWeights_N = %d\033[0m", static_cast(eDiffPtWeights_N)); + LOGF(fatal, "\033[1;31m%s at line %d : Mismatch in the number of flags in configurable cfWhichDiffPtWeights, and number of entries in enum eDiffPtWeights_N \n \033[0m", __FUNCTION__, __LINE__); + } + for (int dpw = 0; dpw < eDiffPtWeights_N; dpw++) { // "differential pt weight" + if (TString(lWhichDiffPtWeights[dpw]).Contains("wPt")) { + pw.fUseDiffPtWeights[wPtPtAxis] = Alright(lWhichDiffPtWeights[dpw]); // if I pass "1-Pt" => true, "0-Pt" => false + } else if (TString(lWhichDiffPtWeights[dpw]).Contains("wCharge")) { + pw.fUseDiffPtWeights[wPtChargeAxis] = Alright(lWhichDiffPtWeights[dpw]) && pw.fUseDiffPtWeights[wPtPtAxis]; + } else if (TString(lWhichDiffPtWeights[dpw]).Contains("wCentrality")) { + pw.fUseDiffPtWeights[wPtCentralityAxis] = Alright(lWhichDiffPtWeights[dpw]) && pw.fUseDiffPtWeights[wPtPtAxis]; + } else { + LOGF(fatal, "\033[1;31m%s at line %d : The setting %s in configurable cfWhichDiffPtWeights is not supported yet. See enum eDiffPtWeights . \n \033[0m", __FUNCTION__, __LINE__, TString(lWhichDiffPtWeights[dpw]).Data()); + } + } + + // **) Differential eta weights: + auto lWhichDiffEtaWeights = cf_pw.cfWhichDiffEtaWeights.value; + if (lWhichDiffEtaWeights.size() != eDiffEtaWeights_N) { + LOGF(info, "\033[1;31m lWhichDiffEtaWeights.size() = %d\033[0m", lWhichDiffEtaWeights.size()); + LOGF(info, "\033[1;31m eDiffEtaWeights_N = %d\033[0m", static_cast(eDiffEtaWeights_N)); + LOGF(fatal, "\033[1;31m%s at line %d : Mismatch in the number of flags in configurable cfWhichDiffEtaWeights, and number of entries in enum eDiffEtaWeights_N \n \033[0m", __FUNCTION__, __LINE__); + } + for (int dpw = 0; dpw < eDiffEtaWeights_N; dpw++) { // "differential eta weight" + if (TString(lWhichDiffEtaWeights[dpw]).Contains("wEta")) { + pw.fUseDiffEtaWeights[wEtaEtaAxis] = Alright(lWhichDiffEtaWeights[dpw]); // if I pass "1-Eta" => true, "0-Eta" => false + } else if (TString(lWhichDiffEtaWeights[dpw]).Contains("wCharge")) { + pw.fUseDiffEtaWeights[wEtaChargeAxis] = Alright(lWhichDiffEtaWeights[dpw]) && pw.fUseDiffEtaWeights[wEtaEtaAxis]; + } else if (TString(lWhichDiffEtaWeights[dpw]).Contains("wCentrality")) { + pw.fUseDiffEtaWeights[wEtaCentralityAxis] = Alright(lWhichDiffEtaWeights[dpw]) && pw.fUseDiffEtaWeights[wEtaEtaAxis]; + } else { + LOGF(fatal, "\033[1;31m%s at line %d : The setting %s in configurable cfWhichDiffEtaWeights is not supported yet. See enum eDiffEtaWeights . \n \033[0m", __FUNCTION__, __LINE__, TString(lWhichDiffEtaWeights[dpw]).Data()); + } + } + + // **) File holding all particle weights: pw.fFileWithWeights = cf_pw.cfFileWithWeights; // *) Centrality weights: @@ -413,7 +713,7 @@ void DefaultConfiguration() // ... // *) Toy NUA: - auto lApplyNUAPDF = (vector)cf_nua.cfApplyNUAPDF; + auto lApplyNUAPDF = (std::vector)cf_nua.cfApplyNUAPDF; if (lApplyNUAPDF.size() != eNUAPDF_N) { LOGF(info, "\033[1;31m lApplyNUAPDF.size() = %d\033[0m", lApplyNUAPDF.size()); LOGF(info, "\033[1;31m eNUAPDF_N = %d\033[0m", static_cast(eNUAPDF_N)); @@ -426,7 +726,7 @@ void DefaultConfiguration() // **) Execute the lines below, only if toy NUA (either default or custom) is requested for at least one kine variable: if (nua.fApplyNUAPDF[ePhiNUAPDF] || nua.fApplyNUAPDF[ePtNUAPDF] || nua.fApplyNUAPDF[eEtaNUAPDF]) { - auto lUseDefaultNUAPDF = (vector)cf_nua.cfUseDefaultNUAPDF; + auto lUseDefaultNUAPDF = (std::vector)cf_nua.cfUseDefaultNUAPDF; if (lUseDefaultNUAPDF.size() != eNUAPDF_N) { LOGF(info, "\033[1;31m lUseDefaultNUAPDF.size() = %d\033[0m", lUseDefaultNUAPDF.size()); LOGF(info, "\033[1;31m eNUAPDF_N = %d\033[0m", static_cast(eNUAPDF_N)); @@ -447,7 +747,7 @@ void DefaultConfiguration() nua.fFileWithCustomNUA = TString(cf_nua.cfFileWithCustomNUA); // *) histogram names with custom NUA distributions in that file + get those histograms immediately here: - auto lCustomNUAPDFHistNames = (vector)cf_nua.cfCustomNUAPDFHistNames; + auto lCustomNUAPDFHistNames = (std::vector)cf_nua.cfCustomNUAPDFHistNames; // TBI 20241115 For some reason, the default values of configurable "cfCustomNUAPDFHistNames" are not correctly propagated in the local variables, but I can circumvent that with JSON settings for the time being if (lCustomNUAPDFHistNames.size() != eNUAPDF_N) { LOGF(info, "\033[1;31m lCustomNUAPDFHistNames.size() = %d\033[0m", lCustomNUAPDFHistNames.size()); @@ -486,10 +786,23 @@ void DefaultConfiguration() iv.fInternalValidationForceBailout = cf_iv.cfInternalValidationForceBailout; iv.fnEventsInternalValidation = cf_iv.cfnEventsInternalValidation; iv.fRescaleWithTheoreticalInput = cf_iv.cfRescaleWithTheoreticalInput; + iv.fRandomizeReactionPlane = cf_iv.cfRandomizeReactionPlane; + iv.fHarmonicsOptionInternalValidation = new TString(cf_iv.cfHarmonicsOptionInternalValidation); // *) Results histograms: - // Define axis titles: - // Remark: keep ordering in sync with enum eAsFunctionOf + // **) Fixed-length or variable-length binning: + // Remark: keep ordering in sync with enum eAsFunctionOf: + cf_res.cfUseVariableLengthMultBins ? res.fUseResultsProVariableLengthBins[AFO_MULTIPLICITY] = true : res.fUseResultsProVariableLengthBins[AFO_MULTIPLICITY] = false; + cf_res.cfUseVariableLengthCentBins ? res.fUseResultsProVariableLengthBins[AFO_CENTRALITY] = true : res.fUseResultsProVariableLengthBins[AFO_CENTRALITY] = false; + cf_res.cfUseVariableLengthPtBins ? res.fUseResultsProVariableLengthBins[AFO_PT] = true : res.fUseResultsProVariableLengthBins[AFO_PT] = false; + cf_res.cfUseVariableLengthEtaBins ? res.fUseResultsProVariableLengthBins[AFO_ETA] = true : res.fUseResultsProVariableLengthBins[AFO_ETA] = false; + cf_res.cfUseVariableLengthOccuBins ? res.fUseResultsProVariableLengthBins[AFO_OCCUPANCY] = true : res.fUseResultsProVariableLengthBins[AFO_OCCUPANCY] = false; + cf_res.cfUseVariableLengthCRDBins ? res.fUseResultsProVariableLengthBins[AFO_CURRENTRUNDURATION] = true : res.fUseResultsProVariableLengthBins[AFO_CURRENTRUNDURATION] = false; + cf_res.cfUseVariableLengthVzBins ? res.fUseResultsProVariableLengthBins[AFO_VZ] = true : res.fUseResultsProVariableLengthBins[AFO_VZ] = false; + + // **) Define axis titles: + // Remark: keep ordering in sync with enum eAsFunctionOf + // 1D: res.fResultsProXaxisTitle[AFO_INTEGRATED] = "integrated"; res.fResultsProRawName[AFO_INTEGRATED] = "int"; // this is how it appears simplified in the hist name when saved to the file res.fResultsProXaxisTitle[AFO_MULTIPLICITY] = "multiplicity"; @@ -506,6 +819,17 @@ void DefaultConfiguration() res.fResultsProRawName[AFO_INTERACTIONRATE] = "ir"; res.fResultsProXaxisTitle[AFO_CURRENTRUNDURATION] = "current run duration"; res.fResultsProRawName[AFO_CURRENTRUNDURATION] = "crd"; + res.fResultsProXaxisTitle[AFO_VZ] = "vertex z position"; + res.fResultsProRawName[AFO_VZ] = "vz"; + res.fResultsProXaxisTitle[AFO_CHARGE] = "particle charge"; + res.fResultsProRawName[AFO_CHARGE] = "charge"; + // ... + + // 2D: + // Remark: I re-use the above definitions for 1D. + + // 3D: + // Remark: I re-use the above definitions for 1D. res.fSaveResultsHistograms = cf_res.cfSaveResultsHistograms; @@ -525,9 +849,11 @@ void DefaultConfiguration() // **) Centrality estimators: qa.fCentralityEstimatorName[eCentFT0C] = "CentFT0C"; + qa.fCentralityEstimatorName[eCentFT0CVariant1] = "CentFT0CVariant1"; qa.fCentralityEstimatorName[eCentFT0M] = "CentFT0M"; qa.fCentralityEstimatorName[eCentFV0A] = "CentFV0A"; qa.fCentralityEstimatorName[eCentNTPV] = "CentNTPV"; + qa.fCentralityEstimatorName[eCentNGlobal] = "CentNGlobal"; qa.fCentralityEstimatorName[eCentRun2V0M] = "CentRun2V0M"; qa.fCentralityEstimatorName[eCentRun2SPDTracklets] = "CentRun2SPDTracklets"; @@ -536,32 +862,44 @@ void DefaultConfiguration() qa.fOccupancyEstimatorName[eFT0COccupancyInTimeRange] = "FT0COccupancyInTimeRange"; // **) Names of QA 2D event histograms: - // Remark: Do NOT use FancyFormatting here, only later in BookQAHistograms() for axis titles! + // Remark: Do NOT use FancyFormatting here, only later in bookQAHistograms() for axis titles! qa.fEventHistogramsName2D[eMultiplicity_vs_ReferenceMultiplicity] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultiplicity].Data(), eh.fEventHistogramsName[eReferenceMultiplicity].Data()); qa.fEventHistogramsName2D[eMultiplicity_vs_NContributors] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultiplicity].Data(), eh.fEventHistogramsName[eNContributors].Data()); qa.fEventHistogramsName2D[eMultiplicity_vs_Centrality] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultiplicity].Data(), eh.fEventHistogramsName[eCentrality].Data()); - qa.fEventHistogramsName2D[eMultiplicity_vs_Vertex_z] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultiplicity].Data(), eh.fEventHistogramsName[eVertex_z].Data()); + qa.fEventHistogramsName2D[eMultiplicity_vs_VertexZ] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultiplicity].Data(), eh.fEventHistogramsName[eVertexZ].Data()); qa.fEventHistogramsName2D[eMultiplicity_vs_Occupancy] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultiplicity].Data(), eh.fEventHistogramsName[eOccupancy].Data()); + qa.fEventHistogramsName2D[eMultiplicity_vs_InteractionRate] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultiplicity].Data(), eh.fEventHistogramsName[eInteractionRate].Data()); qa.fEventHistogramsName2D[eReferenceMultiplicity_vs_NContributors] = Form("%s_vs_%s", eh.fEventHistogramsName[eReferenceMultiplicity].Data(), eh.fEventHistogramsName[eNContributors].Data()); qa.fEventHistogramsName2D[eReferenceMultiplicity_vs_Centrality] = Form("%s_vs_%s", eh.fEventHistogramsName[eReferenceMultiplicity].Data(), eh.fEventHistogramsName[eCentrality].Data()); - qa.fEventHistogramsName2D[eReferenceMultiplicity_vs_Vertex_z] = Form("%s_vs_%s", eh.fEventHistogramsName[eReferenceMultiplicity].Data(), eh.fEventHistogramsName[eVertex_z].Data()); + qa.fEventHistogramsName2D[eReferenceMultiplicity_vs_VertexZ] = Form("%s_vs_%s", eh.fEventHistogramsName[eReferenceMultiplicity].Data(), eh.fEventHistogramsName[eVertexZ].Data()); qa.fEventHistogramsName2D[eReferenceMultiplicity_vs_Occupancy] = Form("%s_vs_%s", eh.fEventHistogramsName[eReferenceMultiplicity].Data(), eh.fEventHistogramsName[eOccupancy].Data()); + qa.fEventHistogramsName2D[eReferenceMultiplicity_vs_InteractionRate] = Form("%s_vs_%s", eh.fEventHistogramsName[eReferenceMultiplicity].Data(), eh.fEventHistogramsName[eInteractionRate].Data()); qa.fEventHistogramsName2D[eNContributors_vs_Centrality] = Form("%s_vs_%s", eh.fEventHistogramsName[eNContributors].Data(), eh.fEventHistogramsName[eCentrality].Data()); - qa.fEventHistogramsName2D[eNContributors_vs_Vertex_z] = Form("%s_vs_%s", eh.fEventHistogramsName[eNContributors].Data(), eh.fEventHistogramsName[eVertex_z].Data()); + qa.fEventHistogramsName2D[eNContributors_vs_VertexZ] = Form("%s_vs_%s", eh.fEventHistogramsName[eNContributors].Data(), eh.fEventHistogramsName[eVertexZ].Data()); qa.fEventHistogramsName2D[eNContributors_vs_Occupancy] = Form("%s_vs_%s", eh.fEventHistogramsName[eNContributors].Data(), eh.fEventHistogramsName[eOccupancy].Data()); - qa.fEventHistogramsName2D[eCentrality_vs_Vertex_z] = Form("%s_vs_%s", eh.fEventHistogramsName[eCentrality].Data(), eh.fEventHistogramsName[eVertex_z].Data()); + qa.fEventHistogramsName2D[eNContributors_vs_InteractionRate] = Form("%s_vs_%s", eh.fEventHistogramsName[eNContributors].Data(), eh.fEventHistogramsName[eInteractionRate].Data()); + qa.fEventHistogramsName2D[eCentrality_vs_VertexZ] = Form("%s_vs_%s", eh.fEventHistogramsName[eCentrality].Data(), eh.fEventHistogramsName[eVertexZ].Data()); qa.fEventHistogramsName2D[eCentrality_vs_Occupancy] = Form("%s_vs_%s", eh.fEventHistogramsName[eCentrality].Data(), eh.fEventHistogramsName[eOccupancy].Data()); qa.fEventHistogramsName2D[eCentrality_vs_ImpactParameter] = Form("%s_vs_%s", eh.fEventHistogramsName[eCentrality].Data(), eh.fEventHistogramsName[eImpactParameter].Data()); - qa.fEventHistogramsName2D[eVertex_z_vs_Occupancy] = Form("%s_vs_%s", eh.fEventHistogramsName[eVertex_z].Data(), eh.fEventHistogramsName[eOccupancy].Data()); + qa.fEventHistogramsName2D[eCentrality_vs_InteractionRate] = Form("%s_vs_%s", eh.fEventHistogramsName[eCentrality].Data(), eh.fEventHistogramsName[eInteractionRate].Data()); + qa.fEventHistogramsName2D[eVertexZ_vs_Occupancy] = Form("%s_vs_%s", eh.fEventHistogramsName[eVertexZ].Data(), eh.fEventHistogramsName[eOccupancy].Data()); + qa.fEventHistogramsName2D[eVertexZ_vs_InteractionRate] = Form("%s_vs_%s", eh.fEventHistogramsName[eVertexZ].Data(), eh.fEventHistogramsName[eInteractionRate].Data()); + qa.fEventHistogramsName2D[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultiplicity].Data(), "FT0CAmplitudeOnFoundBC"); // TBI 20250331 hardwired string + qa.fEventHistogramsName2D[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentFT0C].Data(), "FT0CAmplitudeOnFoundBC"); // TBI 20250331 hardwired string + qa.fEventHistogramsName2D[eCentrality_vs_CentralitySim] = Form("%s_vs_%s", eh.fEventHistogramsName[eCentrality].Data(), "CentralitySim"); // TBI 20250331 hardwired string qa.fEventHistogramsName2D[eMultNTracksPV_vs_MultNTracksGlobal] = Form("%s_vs_%s", qa.fReferenceMultiplicityEstimatorName[eMultNTracksPV].Data(), qa.fReferenceMultiplicityEstimatorName[eMultNTracksGlobal].Data()); + qa.fEventHistogramsName2D[eCentFT0C_vs_CentFT0CVariant1] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentFT0C].Data(), qa.fCentralityEstimatorName[eCentFT0CVariant1].Data()); + qa.fEventHistogramsName2D[eCentFT0C_vs_CentFT0M] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentFT0C].Data(), qa.fCentralityEstimatorName[eCentFT0M].Data()); + qa.fEventHistogramsName2D[eCentFT0C_vs_CentFV0A] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentFT0C].Data(), qa.fCentralityEstimatorName[eCentFV0A].Data()); qa.fEventHistogramsName2D[eCentFT0C_vs_CentNTPV] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentFT0C].Data(), qa.fCentralityEstimatorName[eCentNTPV].Data()); + qa.fEventHistogramsName2D[eCentFT0C_vs_CentNGlobal] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentFT0C].Data(), qa.fCentralityEstimatorName[eCentNGlobal].Data()); qa.fEventHistogramsName2D[eCentFT0M_vs_CentNTPV] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentFT0M].Data(), qa.fCentralityEstimatorName[eCentNTPV].Data()); qa.fEventHistogramsName2D[eCentRun2V0M_vs_CentRun2SPDTracklets] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentRun2V0M].Data(), qa.fCentralityEstimatorName[eCentRun2SPDTracklets].Data()); qa.fEventHistogramsName2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = Form("%s_vs_%s", qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange].Data(), qa.fOccupancyEstimatorName[eFT0COccupancyInTimeRange].Data()); qa.fEventHistogramsName2D[eCurrentRunDuration_vs_InteractionRate] = Form("%s_vs_%s", ec.fEventCutName[eCurrentRunDuration].Data(), ec.fEventCutName[eInteractionRate].Data()); // ***) Quick insanity check that all names are set: - for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) { + for (int t = 0; t < eQAEventHistograms2D_N; t++) { if (qa.fEventHistogramsName2D[t].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : qa.fEventHistogramsName2D[%d] is not set, check corresponding enum eQAEventHistograms2D \033[0m", __FUNCTION__, __LINE__, t); } @@ -571,7 +909,7 @@ void DefaultConfiguration() qa.fParticleHistogramsName2D[ePt_vs_dcaXY] = Form("%s_vs_%s", ph.fParticleHistogramsName[ePt].Data(), ph.fParticleHistogramsName[edcaXY].Data()); // ***) Quick insanity check that all names are set: - for (Int_t t = 0; t < eQAParticleHistograms2D_N; t++) { + for (int t = 0; t < eQAParticleHistograms2D_N; t++) { if (qa.fParticleHistogramsName2D[t].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : qa.fParticleHistogramsName2D[%d] is not set, check corresponding enum eQAParticleHistograms2D \033[0m", __FUNCTION__, __LINE__, t); } @@ -589,25 +927,104 @@ void DefaultConfiguration() qa.fQAParticleEventHistogramsName2D[eCurrentRunDuration_vs_Pt0510EbyE] = TString::Format("%s_vs_%s", eh.fEventHistogramsName[eCurrentRunDuration].Data(), TString(ph.fParticleHistogramsName[ePt].Data()).Append("0510EbyE").Data()).Data(); // TBI 20241214 time will tell if this Append() is safe enough... Remember that Append works in-place qa.fQAParticleEventHistogramsName2D[eCurrentRunDuration_vs_Pt1050EbyE] = TString::Format("%s_vs_%s", eh.fEventHistogramsName[eCurrentRunDuration].Data(), TString(ph.fParticleHistogramsName[ePt].Data()).Append("1050EbyE").Data()).Data(); // TBI 20241214 time will tell if this Append() is safe enough... Remember that Append works in-place - // ... - // ***) Quick insanity check that all names are set: - for (Int_t t = 0; t < eQAParticleEventHistograms2D_N; t++) { + for (int t = 0; t < eQAParticleEventHistograms2D_N; t++) { if (qa.fQAParticleEventHistogramsName2D[t].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : qa.fQAParticleEventHistogramsName2D[%d] is not set, check corresponding enum eQAParticleEventHistograms2D \033[0m", __FUNCTION__, __LINE__, t); } } + // **) Names of QA 2D "correlations vs." histograms: + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_Multiplicity] = TString::Format("%s_vs_%s", "Correlations", eh.fEventHistogramsName[eMultiplicity].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_ReferenceMultiplicity] = TString::Format("%s_vs_%s", "Correlations", eh.fEventHistogramsName[eReferenceMultiplicity].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_Centrality] = TString::Format("%s_vs_%s", "Correlations", eh.fEventHistogramsName[eCentrality].Data()).Data(); + // ... + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeanPhi] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[ePhi].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeanPt] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[ePt].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeanEta] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[eEta].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeanCharge] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[eCharge].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeantpcNClsFindable] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[etpcNClsFindable].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeantpcNClsShared] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[etpcNClsShared].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeanitsChi2NCl] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[eitsChi2NCl].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeantpcNClsFound] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[etpcNClsFound].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeantpcNClsCrossedRows] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[etpcNClsCrossedRows].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeanitsNCls] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[eitsNCls].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeanitsNClsInnerBarrel] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[eitsNClsInnerBarrel].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeantpcCrossedRowsOverFindableCls] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[etpcCrossedRowsOverFindableCls].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeantpcFoundOverFindableCls] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[etpcFoundOverFindableCls].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeantpcFractionSharedCls] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[etpcFractionSharedCls].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeantpcChi2NCl] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[etpcChi2NCl].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeandcaXY] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[edcaXY].Data()).Data(); + qa.fQACorrelationsVsHistogramsName2D[eCorrelations_vs_MeandcaZ] = TString::Format("%s_vs_%s", "Correlations", ph.fParticleHistogramsName[edcaZ].Data()).Data(); + + // ... + + // ***) Quick insanity check that all names are set: + for (int t = 0; t < eQACorrelationsVsHistograms2D_N; t++) { + if (qa.fQACorrelationsVsHistogramsName2D[t].EqualTo("")) { + LOGF(fatal, "\033[1;31m%s at line %d : qa.fQACorrelationsVsHistogramsName2D[%d] is not set, check corresponding enum eQACorrelationsVsHistograms2D \033[0m", __FUNCTION__, __LINE__, t); + } + } + + // **) Names of QA 2D "correlations vs. IR vs. " profiles: + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_CurrentRunDuration] = TString::Format("%s_vs_%s", "CorrVsIR", eh.fEventHistogramsName[eCurrentRunDuration].Data()).Data(); + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_Multiplicity] = TString::Format("%s_vs_%s", "CorrVsIR", eh.fEventHistogramsName[eMultiplicity].Data()).Data(); + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity] = TString::Format("%s_vs_%s", "CorrVsIR", eh.fEventHistogramsName[eReferenceMultiplicity].Data()).Data(); + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_Centrality] = TString::Format("%s_vs_%s", "CorrVsIR", eh.fEventHistogramsName[eCentrality].Data()).Data(); + // ... + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_MeanPhi] = TString::Format("%s_vs_Mean%s", "CorrVsIR", ph.fParticleHistogramsName[ePhi].Data()).Data(); + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPhi] = TString::Format("%s_vs_SigmaMean%s", "CorrVsIR", ph.fParticleHistogramsName[ePhi].Data()).Data(); + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_MeanPt] = TString::Format("%s_vs_Mean%s", "CorrVsIR", ph.fParticleHistogramsName[ePt].Data()).Data(); + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPt] = TString::Format("%s_vs_SigmaMean%s", "CorrVsIR", ph.fParticleHistogramsName[ePt].Data()).Data(); + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_MeanEta] = TString::Format("%s_vs_Mean%s", "CorrVsIR", ph.fParticleHistogramsName[eEta].Data()).Data(); + qa.fQACorrelationsVsInteractionRateVsProfilesName2D[eCorrelationsVsInteractionRate_vs_SigmaMeanEta] = TString::Format("%s_vs_SigmaMean%s", "CorrVsIR", ph.fParticleHistogramsName[eEta].Data()).Data(); + + // ... + + // ***) Quick insanity check that all names are set: + for (int t = 0; t < eQACorrelationsVsInteractionRateVsProfiles2D_N; t++) { + if (qa.fQACorrelationsVsInteractionRateVsProfilesName2D[t].EqualTo("")) { + LOGF(fatal, "\033[1;31m%s at line %d : qa.fQACorrelationsVsInteractionRateVsProfilesName2D[%d] is not set, check corresponding enum eQACorrelationsVsInteractionRateVsProfiles2D \033[0m", __FUNCTION__, __LINE__, t); + } + } + + // **) Names and titles of all categories of sparse histograms: + ph.fParticleSparseHistogramsName[eDWPhi] = "fParticleSparseHistograms_DWPhi"; + ph.fParticleSparseHistogramsTitle[eDWPhi] = "sparse histogram for differential #phi weights,"; + + ph.fParticleSparseHistogramsName[eDWPt] = "fParticleSparseHistograms_DWPt"; + ph.fParticleSparseHistogramsTitle[eDWPt] = "sparse histogram for differential p_{T} weights,"; + + ph.fParticleSparseHistogramsName[eDWEta] = "fParticleSparseHistograms_DWEta"; + ph.fParticleSparseHistogramsTitle[eDWEta] = "sparse histogram for differential #eta weights,"; + + // ... + // ** Eta separations: es.fCalculateEtaSeparations = cf_es.cfCalculateEtaSeparations; - es.fCalculateEtaSeparationsAsFunctionOf[AFO_INTEGRATED] = cf_es.cfCalculateEtaSeparationsAsFunctionOfIntegrated && es.fCalculateEtaSeparations; - es.fCalculateEtaSeparationsAsFunctionOf[AFO_MULTIPLICITY] = cf_es.cfCalculateEtaSeparationsAsFunctionOfMultiplicity && es.fCalculateEtaSeparations; - es.fCalculateEtaSeparationsAsFunctionOf[AFO_CENTRALITY] = cf_es.cfCalculateEtaSeparationsAsFunctionOfCentrality && es.fCalculateEtaSeparations; - es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT] = cf_es.cfCalculateEtaSeparationsAsFunctionOfPt && es.fCalculateEtaSeparations; - es.fCalculateEtaSeparationsAsFunctionOf[AFO_ETA] = false; // this one doesn't make sense in this context, obviously - es.fCalculateEtaSeparationsAsFunctionOf[AFO_OCCUPANCY] = cf_es.cfCalculateEtaSeparationsAsFunctionOfOccupancy && es.fCalculateEtaSeparations; - es.fCalculateEtaSeparationsAsFunctionOf[AFO_INTERACTIONRATE] = cf_es.cfCalculateEtaSeparationsAsFunctionOfInteractionRate && es.fCalculateEtaSeparations; - es.fCalculateEtaSeparationsAsFunctionOf[AFO_CURRENTRUNDURATION] = cf_es.cfCalculateEtaSeparationsAsFunctionOfCurrentRunDuration && es.fCalculateEtaSeparations; + + // *) Use configurable array cfCalculateEtaSeparationsAsFunctionOf, to specify vs which observable EtaSeparations will be calculated (flags 1 or 0). + // Supported format: "0-someName" and "1-someName", where "-" is a field separator. + // Ordering of the flags in that array is interpreted through ordering of enums in enum eAsFunctionOf. + auto lCalculateEtaSeparationsAsFunctionOf = cf_es.cfCalculateEtaSeparationsAsFunctionOf.value; // this is now the local version of that string array from configurable. + if (lCalculateEtaSeparationsAsFunctionOf.size() != eAsFunctionOf_N) { + LOGF(info, "\033[1;31m lCalculateEtaSeparationsAsFunctionOf.size() = %d\033[0m", lCalculateEtaSeparationsAsFunctionOf.size()); + LOGF(info, "\033[1;31m eAsFunctionOf_N) = %d\033[0m", static_cast(eAsFunctionOf_N)); + LOGF(fatal, "\033[1;31m%s at line %d : Mismatch in the number of flags in configurable cfCalculateEtaSeparationsAsFunctionOf, and number of entries in enum eAsFunctionOf_N \n \033[0m", __FUNCTION__, __LINE__); + } + + // I append "&& es.fCalculateEtaSeparations" below, to switch off calculation of all correlations with one common flag: + es.fCalculateEtaSeparationsAsFunctionOf[AFO_INTEGRATED] = Alright(lCalculateEtaSeparationsAsFunctionOf[AFO_INTEGRATED]) && es.fCalculateEtaSeparations; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_MULTIPLICITY] = Alright(lCalculateEtaSeparationsAsFunctionOf[AFO_MULTIPLICITY]) && es.fCalculateEtaSeparations; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_CENTRALITY] = Alright(lCalculateEtaSeparationsAsFunctionOf[AFO_CENTRALITY]) && es.fCalculateEtaSeparations; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT] = Alright(lCalculateEtaSeparationsAsFunctionOf[AFO_PT]) && es.fCalculateEtaSeparations; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_ETA] = false; // yes, in this context this one doesn't make sense + es.fCalculateEtaSeparationsAsFunctionOf[AFO_OCCUPANCY] = Alright(lCalculateEtaSeparationsAsFunctionOf[AFO_OCCUPANCY]) && es.fCalculateEtaSeparations; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_INTERACTIONRATE] = Alright(lCalculateEtaSeparationsAsFunctionOf[AFO_INTERACTIONRATE]) && es.fCalculateEtaSeparations; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_CURRENTRUNDURATION] = Alright(lCalculateEtaSeparationsAsFunctionOf[AFO_CURRENTRUNDURATION]) && es.fCalculateEtaSeparations; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_VZ] = Alright(lCalculateEtaSeparationsAsFunctionOf[AFO_VZ]) && es.fCalculateEtaSeparations; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_CHARGE] = Alright(lCalculateEtaSeparationsAsFunctionOf[AFO_CHARGE]) && es.fCalculateEtaSeparations; + // ... if (es.fCalculateEtaSeparations) { auto lEtaSeparationsValues = cf_es.cfEtaSeparationsValues.value; @@ -615,7 +1032,7 @@ void DefaultConfiguration() LOGF(info, "\033[1;31m%s at line %d : lEtaSeparationsValues.size() = %d\n \033[0m", __FUNCTION__, __LINE__, lEtaSeparationsValues.size()); LOGF(fatal, "\033[1;31m%s at line %d : Provide in configurable cfEtaSeparationsValues precisely %d entries\n \033[0m", __FUNCTION__, __LINE__, static_cast(gMaxNumberEtaSeparations)); } - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { if (lEtaSeparationsValues[e] < 0.) { LOGF(fatal, "\033[1;31m%s at line %d : lEtaSeparationsValues[%d] = %f is not >= 0. \n \033[0m", __FUNCTION__, __LINE__, e, static_cast(lEtaSeparationsValues[e])); } @@ -629,21 +1046,72 @@ void DefaultConfiguration() LOGF(fatal, "\033[1;31m%s at line %d : Mismatch in the number of flags in configurable cfEtaSeparationsSkipHarmonics, and max number of supported harmonics \n \033[0m", __FUNCTION__, __LINE__); } - for (Int_t h = 0; h < static_cast(lEtaSeparationsSkipHarmonics.size()); h++) { + for (int h = 0; h < static_cast(lEtaSeparationsSkipHarmonics.size()); h++) { es.fEtaSeparationsSkipHarmonics[h] = Alright(lEtaSeparationsSkipHarmonics[h]); } } // if(es.fCalculateEtaSeparations) { + // Set the flags qv.fCalculateqvectorsKineAny, fCalculateqvectorsKine[eqvectorKine_N] and fCalculateqvectorsKineEtaSeparations[eqvectorKine_N]: + // TBI 20250601 I have to do it without loop, until I provide support for 2D and 3D to Correlations and EtaSeparations + + // Test0 and Correlations: + if (mupa.fCalculateCorrelationsAsFunctionOf[AfoKineMap1D(PTq)] || t0.fCalculateTest0AsFunctionOf[AfoKineMap1D(PTq)]) { + qv.fCalculateqvectorsKine[PTq] = true; + } + if (mupa.fCalculateCorrelationsAsFunctionOf[AfoKineMap1D(ETAq)] || t0.fCalculateTest0AsFunctionOf[AfoKineMap1D(ETAq)]) { + qv.fCalculateqvectorsKine[ETAq] = true; + } + if (mupa.fCalculateCorrelationsAsFunctionOf[AfoKineMap1D(CHARGEq)] || t0.fCalculateTest0AsFunctionOf[AfoKineMap1D(CHARGEq)]) { + qv.fCalculateqvectorsKine[CHARGEq] = true; + } + if (t0.fCalculate2DTest0AsFunctionOf[AfoKineMap2D(PT_ETAq)]) { + qv.fCalculateqvectorsKine[PT_ETAq] = true; + } + if (t0.fCalculate2DTest0AsFunctionOf[AfoKineMap2D(PT_CHARGEq)]) { + qv.fCalculateqvectorsKine[PT_CHARGEq] = true; + } + if (t0.fCalculate2DTest0AsFunctionOf[AfoKineMap2D(ETA_CHARGEq)]) { + qv.fCalculateqvectorsKine[ETA_CHARGEq] = true; + } + if (t0.fCalculate3DTest0AsFunctionOf[AfoKineMap3D(PT_ETA_CHARGEq)]) { + qv.fCalculateqvectorsKine[PT_ETA_CHARGEq] = true; + } + + // Eta separations: + if (es.fCalculateEtaSeparationsAsFunctionOf[AfoKineMap1D(PTq)]) { + qv.fCalculateqvectorsKineEtaSeparations[PTq] = true; + } + qv.fCalculateqvectorsKineEtaSeparations[ETAq] = false; // yes, this one is alwas set explicitly to false + if (es.fCalculateEtaSeparationsAsFunctionOf[AfoKineMap1D(CHARGEq)]) { + qv.fCalculateqvectorsKineEtaSeparations[CHARGEq] = true; + } + qv.fCalculateqvectorsKineEtaSeparations[PT_ETAq] = false; // yes, this one is alwas set explicitly to false + + // TBI 20250617 comment in this branch, when i implement support for 2D eta separations. + // if (es.fCalculate2DEtaSeparationsAsFunctionOf[AfoKineMap2D(PT_CHARGEq)]) { + // qv.fCalculateqvectorsKineEtaSeparations[PT_CHARGEq] = true; + // } + + qv.fCalculateqvectorsKineEtaSeparations[ETA_CHARGEq] = false; // yes, this one is alwas set explicitly to false + qv.fCalculateqvectorsKineEtaSeparations[PT_ETA_CHARGEq] = false; // yes, this one is alwas set explicitly to false + + for (int qKine = 0; qKine < eqvectorKine_N; qKine++) { + if (qv.fCalculateqvectorsKine[qKine] || qv.fCalculateqvectorsKineEtaSeparations[qKine]) { + qv.fCalculateqvectorsKineAny = true; + break; // yes, I need at least one kine calculus, to set this flag to true + } + } + if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void DefaultConfiguration() +} // void defaultConfiguration() //============================================================ -Bool_t Alright(TString s) +bool Alright(TString s) { // Simple utility function, which for a string formatted "0-someName" returns false, and for "1-someName" returns true. @@ -655,26 +1123,26 @@ Bool_t Alright(TString s) LOGF(info, "\033[1;32m TString s = %s\033[0m", s.Data()); } - Bool_t returnValue = kFALSE; + bool returnValue = false; // a) Insanity check on the format: TObjArray* oa = s.Tokenize("-"); if (!oa) { LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL , s = %s\033[0m", __FUNCTION__, __LINE__, s.Data()); } - Int_t nEntries = oa->GetEntries(); + int nEntries = oa->GetEntries(); if (2 != nEntries) { - LOGF(fatal, "\033[1;31m%s at line %d : string expected in this function must be formatted as \"someName-0\" or \"someName-1\" => s = %s\033[0m", __FUNCTION__, __LINE__, s.Data()); + LOGF(fatal, "\033[1;31m%s at line %d : string expected in this function must be formatted as \"0-someName\" or \"1-someName\" => s = %s\033[0m", __FUNCTION__, __LINE__, s.Data()); } // b) Do the thing: // Algorithm: I split "0-someName" or "1-someName" with respect to "-" as a field separator, and check what is in the 1st field. if (TString(oa->At(0)->GetName()).EqualTo("0")) { delete oa; - returnValue = kFALSE; + returnValue = false; } else if (TString(oa->At(0)->GetName()).EqualTo("1")) { delete oa; - returnValue = kTRUE; + returnValue = true; } else { LOGF(fatal, "\033[1;31m%s at line %d : string expected in this function must be formatted as \"0-someName\" or \"1-someName\" => s = %s\033[0m", __FUNCTION__, __LINE__, s.Data()); } @@ -685,11 +1153,11 @@ Bool_t Alright(TString s) return returnValue; -} // Bool_t Alright(const char* name) +} // bool Alright(const char* name) //============================================================ -void DefaultBooking() +void defaultBooking() { // Set here which histograms are booked by default. @@ -697,19 +1165,20 @@ void DefaultBooking() // b) Event histograms 2D; // c) Particle histograms 1D; // d) Particle histograms 2D; - // e) QA; + // e) Particle sparse histograms; + // f) QA. if (tc.fVerbose) { StartFunction(__FUNCTION__); } // a) Event histograms 1D: - // By default all event histograms are booked. Set this flag to kFALSE to switch off booking of all event histograms: + // By default all event histograms are booked. Set this flag to false to switch off booking of all event histograms: eh.fFillEventHistograms = cf_eh.cfFillEventHistograms; // *) By default all event histograms are booked. If you do not want particular event histogram to be booked, // use configurable array cfBookEventHistograms, where you can specify name of the histogram accompanied with flags 1 (book) or 0 (do not book). - // Supported format: "someName-0" and "someName-1", where "-" is a field separator. + // Supported format: "0-someName" and "1-someName", where "-" is a field separator. // Ordering of the flags in that array is interpreted through ordering of enums in enum eEventHistograms. auto lBookEventHistograms = cf_eh.cfBookEventHistograms.value; // this is now the local version of that string array from configurable. if (lBookEventHistograms.size() != eEventHistograms_N) { @@ -720,7 +1189,7 @@ void DefaultBooking() // *) Insanity check on the content and ordering of histogram names in the initialization in configurable cfBookEventHistograms: // TBI 20240518 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. - for (Int_t name = 0; name < eEventHistograms_N; name++) { + for (int name = 0; name < eEventHistograms_N; name++) { // TBI 20240518 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. if (!TString(lBookEventHistograms[name]).EndsWith(eh.fEventHistogramsName[name].Data())) { LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfBookEventHistograms => name = %d, lBookEventHistograms[%d] = \"%s\", eh.fEventHistogramsName[%d] = \"%s\" \n Check if you are using an up to date tag. \033[0m", __FUNCTION__, __LINE__, name, name, TString(lBookEventHistograms[name]).Data(), name, eh.fEventHistogramsName[name].Data()); @@ -733,9 +1202,9 @@ void DefaultBooking() eh.fBookEventHistograms[eMultiplicity] = Alright(lBookEventHistograms[eMultiplicity]) && eh.fFillEventHistograms; eh.fBookEventHistograms[eReferenceMultiplicity] = Alright(lBookEventHistograms[eReferenceMultiplicity]) && eh.fFillEventHistograms; eh.fBookEventHistograms[eCentrality] = Alright(lBookEventHistograms[eCentrality]) && eh.fFillEventHistograms; - eh.fBookEventHistograms[eVertex_x] = Alright(lBookEventHistograms[eVertex_x]) && eh.fFillEventHistograms; - eh.fBookEventHistograms[eVertex_y] = Alright(lBookEventHistograms[eVertex_y]) && eh.fFillEventHistograms; - eh.fBookEventHistograms[eVertex_z] = Alright(lBookEventHistograms[eVertex_z]) && eh.fFillEventHistograms; + eh.fBookEventHistograms[eVertexX] = Alright(lBookEventHistograms[eVertexX]) && eh.fFillEventHistograms; + eh.fBookEventHistograms[eVertexY] = Alright(lBookEventHistograms[eVertexY]) && eh.fFillEventHistograms; + eh.fBookEventHistograms[eVertexZ] = Alright(lBookEventHistograms[eVertexZ]) && eh.fFillEventHistograms; eh.fBookEventHistograms[eNContributors] = Alright(lBookEventHistograms[eNContributors]) && eh.fFillEventHistograms; eh.fBookEventHistograms[eImpactParameter] = Alright(lBookEventHistograms[eImpactParameter]) && eh.fFillEventHistograms; eh.fBookEventHistograms[eEventPlaneAngle] = Alright(lBookEventHistograms[eEventPlaneAngle]) && eh.fFillEventHistograms; @@ -749,7 +1218,7 @@ void DefaultBooking() // ... // c) Particle histograms 1D: - // By default all 1D particle histograms are booked. Set this flag to kFALSE to switch off booking of all 1D particle histograms: + // By default all 1D particle histograms are booked. Set this flag to false to switch off booking of all 1D particle histograms: ph.fFillParticleHistograms = cf_ph.cfFillParticleHistograms; // *) If you do not want particular particle histogram to be booked, use configurable array cfBookParticleHistograms, where you can specify flags 1 (book) or 0 (do not book). @@ -763,7 +1232,7 @@ void DefaultBooking() // *) Insanity check on the content and ordering of particle histograms in the initialization in configurable cfBookParticleHistograms: // TBI 20240518 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. - for (Int_t name = 0; name < eParticleHistograms_N; name++) { + for (int name = 0; name < eParticleHistograms_N; name++) { // TBI 20240518 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. if (!TString(lBookParticleHistograms[name]).EndsWith(ph.fParticleHistogramsName[name].Data())) { LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfBookParticleHistograms => name = %d, lBookParticleHistograms[name] = \"%s\", ph.fParticleHistogramsName[name] = \"%s\" \n Check if you are using an up to date tag. \033[0m", __FUNCTION__, __LINE__, name, TString(lBookParticleHistograms[name]).Data(), ph.fParticleHistogramsName[name].Data()); @@ -777,6 +1246,7 @@ void DefaultBooking() ph.fBookParticleHistograms[eCharge] = Alright(lBookParticleHistograms[eCharge]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[etpcNClsFindable] = Alright(lBookParticleHistograms[etpcNClsFindable]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[etpcNClsShared] = Alright(lBookParticleHistograms[etpcNClsShared]) && ph.fFillParticleHistograms; + ph.fBookParticleHistograms[eitsChi2NCl] = Alright(lBookParticleHistograms[eitsChi2NCl]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[etpcNClsFound] = Alright(lBookParticleHistograms[etpcNClsFound]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[etpcNClsCrossedRows] = Alright(lBookParticleHistograms[etpcNClsCrossedRows]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[eitsNCls] = Alright(lBookParticleHistograms[eitsNCls]) && ph.fFillParticleHistograms; @@ -784,6 +1254,7 @@ void DefaultBooking() ph.fBookParticleHistograms[etpcCrossedRowsOverFindableCls] = Alright(lBookParticleHistograms[etpcCrossedRowsOverFindableCls]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[etpcFoundOverFindableCls] = Alright(lBookParticleHistograms[etpcFoundOverFindableCls]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[etpcFractionSharedCls] = Alright(lBookParticleHistograms[etpcFractionSharedCls]) && ph.fFillParticleHistograms; + ph.fBookParticleHistograms[etpcChi2NCl] = Alright(lBookParticleHistograms[etpcChi2NCl]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[edcaXY] = Alright(lBookParticleHistograms[edcaXY]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[edcaZ] = Alright(lBookParticleHistograms[edcaZ]) && ph.fFillParticleHistograms; ph.fBookParticleHistograms[ePDG] = Alright(lBookParticleHistograms[ePDG]) && ph.fFillParticleHistograms; @@ -791,7 +1262,7 @@ void DefaultBooking() // Remark #2: Nothing special here for ePtDependentDCAxyParameterization, because that is a string. // d) Particle histograms 2D: - // By default all 2D particle histograms are booked. Set this flag to kFALSE to switch off booking of all 2D particle histograms: + // By default all 2D particle histograms are booked. Set this flag to false to switch off booking of all 2D particle histograms: ph.fFillParticleHistograms2D = cf_ph.cfFillParticleHistograms2D; // If you do not want particular 2D particle histogram to be booked, use configurable array cfBookParticleHistograms2D, where you can specify flags 1 (book) or 0 (do not book). @@ -806,7 +1277,7 @@ void DefaultBooking() // *) Insanity check on the content and ordering of 2D particle histograms in the initialization in configurable cfBookParticleHistograms2D: // TBI 20241109 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. - for (Int_t name = 0; name < eParticleHistograms2D_N; name++) { + for (int name = 0; name < eParticleHistograms2D_N; name++) { // TBI 20241109 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. if (!TString(lBookParticleHistograms2D[name]).EndsWith(ph.fParticleHistogramsName2D[name].Data())) { LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfBookParticleHistograms2D => name = %d, lBookParticleHistograms2D[name] = \"%s\", ph.fParticleHistogramsName2D[name] = \"%s\" \n Check if you are using an up to date tag. \033[0m", __FUNCTION__, __LINE__, name, TString(lBookParticleHistograms2D[name]).Data(), ph.fParticleHistogramsName2D[name].Data()); @@ -817,7 +1288,36 @@ void DefaultBooking() ph.fBookParticleHistograms2D[ePhiPt] = Alright(lBookParticleHistograms2D[ePhiPt]) && ph.fFillParticleHistograms2D; ph.fBookParticleHistograms2D[ePhiEta] = Alright(lBookParticleHistograms2D[ePhiEta]) && ph.fFillParticleHistograms2D; - // e) QA: + // e) Particle sparse histograms: + ph.fRebinSparse = cf_ph.cfRebinSparse; + + // *) Categories of sparse histograms: + auto lBookParticleSparseHistograms = cf_ph.cfBookParticleSparseHistograms.value; // fill or not particulat category of sparse histograms + if (lBookParticleSparseHistograms.size() != eDiffWeightCategory_N) { + LOGF(info, "\033[1;31m lBookParticleSparseHistograms.size() = %d\033[0m", lBookParticleSparseHistograms.size()); + LOGF(info, "\033[1;31m eDiffWeightCategory_N) = %d\033[0m", static_cast(eDiffWeightCategory_N)); + LOGF(fatal, "in function \033[1;31m%s at line %d Mismatch in the number of flags in configurable cfBookParticleSparseHistograms, and number of entries in enum eDiffWeightCategory_N \n \033[0m", __FUNCTION__, __LINE__); + } + + // *) Insanity check on the content and ordering in the initialization in configurable cfBookParticleSparseHistograms: + // TBI 20241109 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. + // Algorithm: From [01]-DWPhi I tokenize with respect to "-" the 2nd field, and check if e.g. fParticleSparseHistogramsName_DWPhi ends with it. + for (int name = 0; name < eDiffWeightCategory_N; name++) { + TObjArray* oa = TString(lBookParticleSparseHistograms[name]).Tokenize("-"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : name = %s\033[0m", __FUNCTION__, __LINE__, TString(lBookParticleSparseHistograms[name]).Data()); + } + if (!ph.fParticleSparseHistogramsName[name].EndsWith(oa->At(1)->GetName())) { + LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfBookParticleSparseHistograms => name = %d, lBookParticleSparseHistograms[name] = \"%s\", ph.fParticleSparseHistogramsName[name] = \"%s\" \n Check if you are using an up to date tag. \033[0m", __FUNCTION__, __LINE__, name, TString(lBookParticleSparseHistograms[name]).Data(), ph.fParticleSparseHistogramsName[name].Data()); + } + delete oa; + } + // Remark: below exceptionally I do not append the common flag with &&, since each of these flags already stands for one category + ph.fBookParticleSparseHistograms[eDWPhi] = Alright(lBookParticleSparseHistograms[eDWPhi]); + ph.fBookParticleSparseHistograms[eDWPt] = Alright(lBookParticleSparseHistograms[eDWPt]); + ph.fBookParticleSparseHistograms[eDWEta] = Alright(lBookParticleSparseHistograms[eDWEta]); + + // f) QA: // **) QA 2D event histograms: qa.fFillQAEventHistograms2D = cf_qa.cfFillQAEventHistograms2D; @@ -834,7 +1334,7 @@ void DefaultBooking() // *) Insanity check on the content and ordering of QA 2D event histograms in the initialization in configurable cfBookQAEventHistograms2D: // TBI 20240518 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. - for (Int_t name = 0; name < eQAEventHistograms2D_N; name++) { + for (int name = 0; name < eQAEventHistograms2D_N; name++) { // TBI 20240518 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. if (!TString(lBookQAEventHistograms2D[name]).EndsWith(qa.fEventHistogramsName2D[name].Data())) { LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfBookQAEventHistograms2D => name = %d, lBookQAEventHistograms2D[name] = \"%s\", qa.fEventHistogramsName2D[name] = \"%s\" \n Check if you are using an up to date tag. \033[0m", __FUNCTION__, __LINE__, name, TString(lBookQAEventHistograms2D[name]).Data(), qa.fEventHistogramsName2D[name].Data()); @@ -845,21 +1345,33 @@ void DefaultBooking() qa.fBookQAEventHistograms2D[eMultiplicity_vs_ReferenceMultiplicity] = Alright(lBookQAEventHistograms2D[eMultiplicity_vs_ReferenceMultiplicity]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eMultiplicity_vs_NContributors] = Alright(lBookQAEventHistograms2D[eMultiplicity_vs_NContributors]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eMultiplicity_vs_Centrality] = Alright(lBookQAEventHistograms2D[eMultiplicity_vs_Centrality]) && qa.fFillQAEventHistograms2D; - qa.fBookQAEventHistograms2D[eMultiplicity_vs_Vertex_z] = Alright(lBookQAEventHistograms2D[eMultiplicity_vs_Vertex_z]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eMultiplicity_vs_VertexZ] = Alright(lBookQAEventHistograms2D[eMultiplicity_vs_VertexZ]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eMultiplicity_vs_Occupancy] = Alright(lBookQAEventHistograms2D[eMultiplicity_vs_Occupancy]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eMultiplicity_vs_InteractionRate] = Alright(lBookQAEventHistograms2D[eMultiplicity_vs_InteractionRate]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eReferenceMultiplicity_vs_NContributors] = Alright(lBookQAEventHistograms2D[eReferenceMultiplicity_vs_NContributors]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eReferenceMultiplicity_vs_Centrality] = Alright(lBookQAEventHistograms2D[eReferenceMultiplicity_vs_Centrality]) && qa.fFillQAEventHistograms2D; - qa.fBookQAEventHistograms2D[eReferenceMultiplicity_vs_Vertex_z] = Alright(lBookQAEventHistograms2D[eReferenceMultiplicity_vs_Vertex_z]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eReferenceMultiplicity_vs_VertexZ] = Alright(lBookQAEventHistograms2D[eReferenceMultiplicity_vs_VertexZ]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eReferenceMultiplicity_vs_Occupancy] = Alright(lBookQAEventHistograms2D[eReferenceMultiplicity_vs_Occupancy]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eReferenceMultiplicity_vs_InteractionRate] = Alright(lBookQAEventHistograms2D[eReferenceMultiplicity_vs_InteractionRate]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eNContributors_vs_Centrality] = Alright(lBookQAEventHistograms2D[eNContributors_vs_Centrality]) && qa.fFillQAEventHistograms2D; - qa.fBookQAEventHistograms2D[eNContributors_vs_Vertex_z] = Alright(lBookQAEventHistograms2D[eNContributors_vs_Vertex_z]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eNContributors_vs_VertexZ] = Alright(lBookQAEventHistograms2D[eNContributors_vs_VertexZ]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eNContributors_vs_Occupancy] = Alright(lBookQAEventHistograms2D[eNContributors_vs_Occupancy]) && qa.fFillQAEventHistograms2D; - qa.fBookQAEventHistograms2D[eCentrality_vs_Vertex_z] = Alright(lBookQAEventHistograms2D[eCentrality_vs_Vertex_z]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eNContributors_vs_InteractionRate] = Alright(lBookQAEventHistograms2D[eNContributors_vs_InteractionRate]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eCentrality_vs_VertexZ] = Alright(lBookQAEventHistograms2D[eCentrality_vs_VertexZ]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eCentrality_vs_Occupancy] = Alright(lBookQAEventHistograms2D[eCentrality_vs_Occupancy]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eCentrality_vs_ImpactParameter] = Alright(lBookQAEventHistograms2D[eCentrality_vs_ImpactParameter]) && qa.fFillQAEventHistograms2D; - qa.fBookQAEventHistograms2D[eVertex_z_vs_Occupancy] = Alright(lBookQAEventHistograms2D[eVertex_z_vs_Occupancy]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eCentrality_vs_InteractionRate] = Alright(lBookQAEventHistograms2D[eCentrality_vs_InteractionRate]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eVertexZ_vs_Occupancy] = Alright(lBookQAEventHistograms2D[eVertexZ_vs_Occupancy]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eVertexZ_vs_InteractionRate] = Alright(lBookQAEventHistograms2D[eVertexZ_vs_InteractionRate]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = Alright(lBookQAEventHistograms2D[eMultiplicity_vs_FT0CAmplitudeOnFoundBC]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = Alright(lBookQAEventHistograms2D[eCentFT0C_vs_FT0CAmplitudeOnFoundBC]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eCentrality_vs_CentralitySim] = Alright(lBookQAEventHistograms2D[eCentrality_vs_CentralitySim]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eMultNTracksPV_vs_MultNTracksGlobal] = Alright(lBookQAEventHistograms2D[eMultNTracksPV_vs_MultNTracksGlobal]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentFT0CVariant1] = Alright(lBookQAEventHistograms2D[eCentFT0C_vs_CentFT0CVariant1]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentFT0M] = Alright(lBookQAEventHistograms2D[eCentFT0C_vs_CentFT0M]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentFV0A] = Alright(lBookQAEventHistograms2D[eCentFT0C_vs_CentFV0A]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentNTPV] = Alright(lBookQAEventHistograms2D[eCentFT0C_vs_CentNTPV]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentNGlobal] = Alright(lBookQAEventHistograms2D[eCentFT0C_vs_CentNGlobal]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eCentFT0M_vs_CentNTPV] = Alright(lBookQAEventHistograms2D[eCentFT0M_vs_CentNTPV]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eCentRun2V0M_vs_CentRun2SPDTracklets] = Alright(lBookQAEventHistograms2D[eCentRun2V0M_vs_CentRun2SPDTracklets]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = Alright(lBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange]) && qa.fFillQAEventHistograms2D; @@ -879,7 +1391,7 @@ void DefaultBooking() // *) Insanity check on the content and ordering of QA 2D particle histograms in the initialization in configurable cfBookQAParticleHistograms2D: // TBI 20240518 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. - for (Int_t name = 0; name < eQAParticleHistograms2D_N; name++) { + for (int name = 0; name < eQAParticleHistograms2D_N; name++) { // TBI 20240518 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. if (!TString(lBookQAParticleHistograms2D[name]).EndsWith(qa.fParticleHistogramsName2D[name].Data())) { LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfBookQAParticleHistograms2D => name = %d, lBookQAParticleHistograms2D[name] = \"%s\", qa.fParticleHistogramsName2D[name] = \"%s\" \n Check if you are using an up to date tag. \033[0m", __FUNCTION__, __LINE__, name, TString(lBookQAParticleHistograms2D[name]).Data(), qa.fParticleHistogramsName2D[name].Data()); @@ -903,7 +1415,7 @@ void DefaultBooking() // *) Insanity check on the content and ordering of QA 2D particle event histograms in the initialization in configurable cfBookQAParticleEventHistograms2D: // TBI 20240518 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. - for (Int_t name = 0; name < eQAParticleEventHistograms2D_N; name++) { + for (int name = 0; name < eQAParticleEventHistograms2D_N; name++) { // TBI 20240518 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. if (!TString(lBookQAParticleEventHistograms2D[name]).EndsWith(qa.fQAParticleEventHistogramsName2D[name].Data())) { LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfBookQAParticleEventHistograms2D => name = %d, lBookQAParticleEventHistograms2D[name] = \"%s\", qa.fParticleEventHistogramsName2D[name] = \"%s\" \n Check if you are using an up to date tag. \033[0m", __FUNCTION__, __LINE__, name, TString(lBookQAParticleEventHistograms2D[name]).Data(), qa.fQAParticleEventHistogramsName2D[name].Data()); @@ -922,29 +1434,128 @@ void DefaultBooking() qa.fBookQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt0510EbyE] = Alright(lBookQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt0510EbyE]) && qa.fFillQAParticleEventHistograms2D; qa.fBookQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt1050EbyE] = Alright(lBookQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt1050EbyE]) && qa.fFillQAParticleEventHistograms2D; + // **) QA 2D "correlations vs." histograms: + qa.fFillQACorrelationsVsHistograms2D = cf_qa.cfFillQACorrelationsVsHistograms2D; + + // *) If you do not want particular 2D "correlations vs." histogram to be booked, use configurable array cfBookQACorrelationsVsHistograms2D, where you can specify flags 1 (book) or 0 (do not book). + // Ordering of the flags in that array is interpreted through ordering of enums in enum eQACorrelationsVsHistograms2D. + auto lBookQACorrelationsVsHistograms2D = cf_qa.cfBookQACorrelationsVsHistograms2D.value; // this is now the local version of that string array from configurable + if (lBookQACorrelationsVsHistograms2D.size() != eQACorrelationsVsHistograms2D_N) { + LOGF(info, "\033[1;31m lBookQACorrelationsVsHistograms2D.size() = %d\033[0m", lBookQACorrelationsVsHistograms2D.size()); + LOGF(info, "\033[1;31m eQACorrelationsVsHistograms2D_N = %d\033[0m", static_cast(eQACorrelationsVsHistograms2D_N)); + LOGF(fatal, "in function \033[1;31m%s at line %d Mismatch in the number of flags in configurable cfBookQACorrelationsVsHistograms2D, and number of entries in enum eCorrelationsVsHistograms2D \n \033[0m", __FUNCTION__, __LINE__); + } + + // *) Insanity check on the content and ordering of QA 2D "correlations vs." histograms in the initialization in configurable cfBookQACorrelationsVsHistograms2D: + // TBI 20240518 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. + for (int name = 0; name < eQACorrelationsVsHistograms2D_N; name++) { + // TBI 20240518 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. + if (!TString(lBookQACorrelationsVsHistograms2D[name]).EndsWith(qa.fQACorrelationsVsHistogramsName2D[name].Data())) { + LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfBookQACorrelationsVsHistograms2D => name = %d, lBookQACorrelationsVsHistograms2D[name] = \"%s\", qa.fCorrelationsVsHistogramsName2D[name] = \"%s\" \n Check if you are using an up to date tag. \033[0m", __FUNCTION__, __LINE__, name, TString(lBookQACorrelationsVsHistograms2D[name]).Data(), qa.fQACorrelationsVsHistogramsName2D[name].Data()); + } + } + + // I append "&& qa.fFillQACorrelationsVsHistograms2D" below, to switch off booking of all 2D "correlations vs." histograms with one common flag: + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_Multiplicity] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_Multiplicity]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_ReferenceMultiplicity] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_ReferenceMultiplicity]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_Centrality] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_Centrality]) && qa.fFillQACorrelationsVsHistograms2D; + // ..... + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanPhi] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanPhi]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanPt] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanPt]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanEta] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanEta]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanCharge] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanCharge]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsFindable] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsFindable]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsShared] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsShared]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsChi2NCl] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsChi2NCl]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsFound] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsFound]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsCrossedRows] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsCrossedRows]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsNCls] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsNCls]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsNClsInnerBarrel] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsNClsInnerBarrel]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcCrossedRowsOverFindableCls] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcCrossedRowsOverFindableCls]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcFoundOverFindableCls] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcFoundOverFindableCls]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcFractionSharedCls] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcFractionSharedCls]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcChi2NCl] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcChi2NCl]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeandcaXY] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeandcaXY]) && qa.fFillQACorrelationsVsHistograms2D; + qa.fBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeandcaZ] = Alright(lBookQACorrelationsVsHistograms2D[eCorrelations_vs_MeandcaZ]) && qa.fFillQACorrelationsVsHistograms2D; + // ..... + + // *) min and max harmonics for which this series of histograms will be booked: + auto lQACorrelationsVsHistogramsMinMaxHarmonic = cf_qa.cfQACorrelationsVsHistogramsMinMaxHarmonic.value; + qa.fQACorrelationsVsHistogramsMinMaxHarmonic[eMin] = lQACorrelationsVsHistogramsMinMaxHarmonic[eMin]; + qa.fQACorrelationsVsHistogramsMinMaxHarmonic[eMax] = lQACorrelationsVsHistogramsMinMaxHarmonic[eMax]; + // **) insanity check: + if (!(qa.fQACorrelationsVsHistogramsMinMaxHarmonic[eMin] <= qa.fQACorrelationsVsHistogramsMinMaxHarmonic[eMax])) { + LOGF(fatal, "\033[1;31m%s at line %d : wrong setting for min and max harmonics: min = %d, max = %d \033[0m", __FUNCTION__, __LINE__, qa.fQACorrelationsVsHistogramsMinMaxHarmonic[eMin], qa.fQACorrelationsVsHistogramsMinMaxHarmonic[eMax]); + } + + // **) QA 2D "correlations vs. IR vs. " profiles: + qa.fFillQACorrelationsVsInteractionRateVsProfiles2D = cf_qa.cfFillQACorrelationsVsInteractionRateVsProfiles2D; + + // *) If you do not want particular 2D correlations vs. IR vs. " profile to be booked, use configurable array cfBookQACorrelationsVsInteractionRateVsProfiles2D, where you can specify flags 1 (book) or 0 (do not book). + // Ordering of the flags in that array is interpreted through ordering of enums in enum eQACorrelationsVsInteractionRateVsProfiles2D. + auto lBookQACorrelationsVsInteractionRateVsProfiles2D = cf_qa.cfBookQACorrelationsVsInteractionRateVsProfiles2D.value; // this is now the local version of that string array from configurable + if (lBookQACorrelationsVsInteractionRateVsProfiles2D.size() != eQACorrelationsVsInteractionRateVsProfiles2D_N) { + LOGF(info, "\033[1;31m lBookQACorrelationsVsInteractionRateVsProfiles2D.size() = %d\033[0m", lBookQACorrelationsVsInteractionRateVsProfiles2D.size()); + LOGF(info, "\033[1;31m eQACorrelationsVsInteractionRateVsProfiles2D_N = %d\033[0m", static_cast(eQACorrelationsVsInteractionRateVsProfiles2D_N)); + LOGF(fatal, "in function \033[1;31m%s at line %d Mismatch in the number of flags in configurable cfBookQACorrelationsVsInteractionRateVsProfiles2D, and number of entries in enum eCorrelationsVsInteractionRateVsProfiles2D \n \033[0m", __FUNCTION__, __LINE__); + } + + // *) Insanity check on the content and ordering of QA 2D "correlations vs. IR vs. " profiles in the initialization in configurable cfBookQACorrelationsVsInteractionRateVsProfiles2D: + // TBI 20240518 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. + for (int name = 0; name < eQACorrelationsVsInteractionRateVsProfiles2D_N; name++) { + // TBI 20240518 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. + if (!TString(lBookQACorrelationsVsInteractionRateVsProfiles2D[name]).EndsWith(qa.fQACorrelationsVsInteractionRateVsProfilesName2D[name].Data())) { + LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfBookQACorrelationsVsInteractionRateVsProfiles2D => name = %d, lBookQACorrelationsVsInteractionRateVsProfiles2D[name] = \"%s\", qa.fCorrelationsVsInteractionRateVsProfilesName2D[name] = \"%s\" \n Check if you are using an up to date tag. \033[0m", __FUNCTION__, __LINE__, name, TString(lBookQACorrelationsVsInteractionRateVsProfiles2D[name]).Data(), qa.fQACorrelationsVsInteractionRateVsProfilesName2D[name].Data()); + } + } + + // I append "&& qa.fFillQACorrelationsVsInteractionRateVsProfiles2D" below, to switch off booking of all 2D "correlations vs. IR vs. " profiles with one common flag: + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_CurrentRunDuration] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_CurrentRunDuration]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_Multiplicity] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_Multiplicity]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_Centrality] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_Centrality]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + // ..... + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanPhi] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanPhi]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPhi] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPhi]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanPt] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanPt]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPt] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPt]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanEta] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanEta]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanEta] = Alright(lBookQACorrelationsVsInteractionRateVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanEta]) && qa.fFillQACorrelationsVsInteractionRateVsProfiles2D; + + // ..... + + // *) min and max harmonics for which this series of histograms will be booked: + auto lQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic = cf_qa.cfQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic.value; + qa.fQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMin] = lQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMin]; + qa.fQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMax] = lQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMax]; + // **) insanity check: + if (!(qa.fQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMin] < qa.fQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMax])) { + LOGF(fatal, "\033[1;31m%s at line %d : wrong setting for min and max harmonics: min = %d, max = %d \033[0m", __FUNCTION__, __LINE__, qa.fQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMin], qa.fQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMax]); + } + // ... if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void DefaultBooking() +} // void defaultBooking() //============================================================ -void DefaultBinning() +void defaultBinning() { // Default binning for all histograms. // TBI 20240114 If some of these values are going to change frequently, add support for them in MuPa-Configurables.h, - // in the same way I did it for DefaultCuts(). - // Remark: If + // in the same way I did it for defaultCuts(). + // At the moment, I added to configurables support only for binning of sparse histograms, because there memory managment is critical. // a) Default binning for event histograms; // b) Default binning for particle histograms 1D; // c) Default binning for particle histograms 2D; // d) Default binning for results histograms; - // e) Variable-length binning set via MuPa-Configurables.h. + // e) Variable-length binning for results histograms set via MuPa-Configurables.h. if (tc.fVerbose) { StartFunction(__FUNCTION__); @@ -959,33 +1570,33 @@ void DefaultBinning() eh.fEventHistogramsBins[eTotalMultiplicity][1] = 0.; eh.fEventHistogramsBins[eTotalMultiplicity][2] = 100000.; - eh.fEventHistogramsBins[eMultiplicity][0] = 2000.; + eh.fEventHistogramsBins[eMultiplicity][0] = 500.; eh.fEventHistogramsBins[eMultiplicity][1] = 0.; - eh.fEventHistogramsBins[eMultiplicity][2] = 20000.; + eh.fEventHistogramsBins[eMultiplicity][2] = 5000.; - eh.fEventHistogramsBins[eReferenceMultiplicity][0] = 6000.; + eh.fEventHistogramsBins[eReferenceMultiplicity][0] = 700.; // bin width is 100 eh.fEventHistogramsBins[eReferenceMultiplicity][1] = 0.; - eh.fEventHistogramsBins[eReferenceMultiplicity][2] = 60000.; + eh.fEventHistogramsBins[eReferenceMultiplicity][2] = 70000.; eh.fEventHistogramsBins[eCentrality][0] = 110; // intentionally, because if centrality is not determined, it's set to 105.0 at the moment eh.fEventHistogramsBins[eCentrality][1] = 0.; eh.fEventHistogramsBins[eCentrality][2] = 110.; - eh.fEventHistogramsBins[eVertex_x][0] = 800; - eh.fEventHistogramsBins[eVertex_x][1] = -0.4; - eh.fEventHistogramsBins[eVertex_x][2] = 0.4; + eh.fEventHistogramsBins[eVertexX][0] = 1600; + eh.fEventHistogramsBins[eVertexX][1] = -0.8; + eh.fEventHistogramsBins[eVertexX][2] = 0.8; - eh.fEventHistogramsBins[eVertex_y][0] = 800; - eh.fEventHistogramsBins[eVertex_y][1] = -0.4; - eh.fEventHistogramsBins[eVertex_y][2] = 0.4; + eh.fEventHistogramsBins[eVertexY][0] = 1600; + eh.fEventHistogramsBins[eVertexY][1] = -0.8; + eh.fEventHistogramsBins[eVertexY][2] = 0.8; - eh.fEventHistogramsBins[eVertex_z][0] = 800; - eh.fEventHistogramsBins[eVertex_z][1] = -40.; - eh.fEventHistogramsBins[eVertex_z][2] = 40.; + eh.fEventHistogramsBins[eVertexZ][0] = 800; + eh.fEventHistogramsBins[eVertexZ][1] = -40.; + eh.fEventHistogramsBins[eVertexZ][2] = 40.; - eh.fEventHistogramsBins[eNContributors][0] = 1000.; + eh.fEventHistogramsBins[eNContributors][0] = 600.; // bin width is 20 eh.fEventHistogramsBins[eNContributors][1] = 0.; - eh.fEventHistogramsBins[eNContributors][2] = 10000.; + eh.fEventHistogramsBins[eNContributors][2] = 12000.; eh.fEventHistogramsBins[eImpactParameter][0] = 1000; eh.fEventHistogramsBins[eImpactParameter][1] = 0.; @@ -1010,7 +1621,7 @@ void DefaultBinning() // b) Default binning for particle histograms 1D: ph.fParticleHistogramsBins[ePhi][0] = 360; ph.fParticleHistogramsBins[ePhi][1] = 0.; - ph.fParticleHistogramsBins[ePhi][2] = TMath::TwoPi(); + ph.fParticleHistogramsBins[ePhi][2] = o2::constants::math::TwoPI; ph.fParticleHistogramsBins[ePt][0] = 2000; ph.fParticleHistogramsBins[ePt][1] = 0.; @@ -1021,7 +1632,7 @@ void DefaultBinning() ph.fParticleHistogramsBins[eEta][2] = 5.; ph.fParticleHistogramsBins[eCharge][0] = 7; - ph.fParticleHistogramsBins[eCharge][1] = -3.5; // anticipating I might be storing charge of Delta++. etc. + ph.fParticleHistogramsBins[eCharge][1] = -3.5; // anticipating I might be storing charge of Delta++, etc. ph.fParticleHistogramsBins[eCharge][2] = 3.5; ph.fParticleHistogramsBins[etpcNClsFindable][0] = 300; @@ -1032,6 +1643,10 @@ void DefaultBinning() ph.fParticleHistogramsBins[etpcNClsShared][1] = 0.; ph.fParticleHistogramsBins[etpcNClsShared][2] = 200.; + ph.fParticleHistogramsBins[eitsChi2NCl][0] = 200; + ph.fParticleHistogramsBins[eitsChi2NCl][1] = 0.; + ph.fParticleHistogramsBins[eitsChi2NCl][2] = 200.; + ph.fParticleHistogramsBins[etpcNClsFound][0] = 200; ph.fParticleHistogramsBins[etpcNClsFound][1] = 0.; ph.fParticleHistogramsBins[etpcNClsFound][2] = 200.; @@ -1060,6 +1675,10 @@ void DefaultBinning() ph.fParticleHistogramsBins[etpcFractionSharedCls][1] = -1.; // yes, I saw here entries with negative values TBI 20240507 check what are these values ph.fParticleHistogramsBins[etpcFractionSharedCls][2] = 10.; + ph.fParticleHistogramsBins[etpcChi2NCl][0] = 2500; + ph.fParticleHistogramsBins[etpcChi2NCl][1] = 0.; + ph.fParticleHistogramsBins[etpcChi2NCl][2] = 250.; + ph.fParticleHistogramsBins[edcaXY][0] = 2000; ph.fParticleHistogramsBins[edcaXY][1] = -10.; ph.fParticleHistogramsBins[edcaXY][2] = 10.; @@ -1090,117 +1709,147 @@ void DefaultBinning() ph.fParticleHistogramsBins2D[ePhiEta][eY][2] = ph.fParticleHistogramsBins[eEta][2]; // d) Default binning for results histograms: - // Remark: These bins apply to following categories fCorrelationsPro, fNestedLoopsPro, fTest0Pro, and fResultsPro. - // *) For integrated resullts, binning is always the same: - res.fResultsProFixedLengthBins[AFO_INTEGRATED][0] = 1; - res.fResultsProFixedLengthBins[AFO_INTEGRATED][1] = 0.; - res.fResultsProFixedLengthBins[AFO_INTEGRATED][2] = 1.; - // *) Fixed-length binning vs. multiplicity: - this->InitializeFixedLengthBins(AFO_MULTIPLICITY); - // *) Fixed-length binning vs. centrality: - this->InitializeFixedLengthBins(AFO_CENTRALITY); - // *) Fixed-length binning vs. pt: - this->InitializeFixedLengthBins(AFO_PT); - // *) Fixed-length binning vs. eta: - this->InitializeFixedLengthBins(AFO_ETA); - // *) Fixed-length binning vs. occupancy: - this->InitializeFixedLengthBins(AFO_OCCUPANCY); - // *) Fixed-length binning vs. interaction rate: - this->InitializeFixedLengthBins(AFO_INTERACTIONRATE); - // *) Fixed-length binning vs. run duration: - this->InitializeFixedLengthBins(AFO_CURRENTRUNDURATION); - - // e) Variable-length binning set via MuPa-Configurables.h: - // *) Variable-length binning vs. multiplicity: - if (cf_res.cfUseVariableLength_mult_bins) { + // Remark: These bins apply to following categories fCorrelationsPro, fNestedLoopsPro, fTest0Pro, fResultsPro, and all 2D and 3D variants. + // 1D: + // *) For integrated results, binning is always the same nBins = 1 in (0.,1.): + res.fResultsProBinEdges[AFO_INTEGRATED] = new TArrayD(2); + res.fResultsProBinEdges[AFO_INTEGRATED]->AddAt(0., 0); + res.fResultsProBinEdges[AFO_INTEGRATED]->AddAt(1., 1); + + // *) Binning vs. multiplicity: + if (res.fUseResultsProVariableLengthBins[AFO_MULTIPLICITY]) { this->InitializeVariableLengthBins(AFO_MULTIPLICITY); + } else { + this->InitializeFixedLengthBins(AFO_MULTIPLICITY); } - // *) Variable-length binning vs. centrality: - if (cf_res.cfUseVariableLength_cent_bins) { + + // *) Binning vs. centrality: + if (res.fUseResultsProVariableLengthBins[AFO_CENTRALITY]) { this->InitializeVariableLengthBins(AFO_CENTRALITY); + } else { + this->InitializeFixedLengthBins(AFO_CENTRALITY); } - // *) Variable-length binning vs. pt: - if (cf_res.cfUseVariableLength_pt_bins) { + + // *) Binning vs. pt: + if (res.fUseResultsProVariableLengthBins[AFO_PT]) { this->InitializeVariableLengthBins(AFO_PT); + } else { + this->InitializeFixedLengthBins(AFO_PT); } - // *) Variable-length binning vs. eta: - if (cf_res.cfUseVariableLength_eta_bins) { + + // *) Binning vs. eta: + if (res.fUseResultsProVariableLengthBins[AFO_ETA]) { this->InitializeVariableLengthBins(AFO_ETA); + } else { + this->InitializeFixedLengthBins(AFO_ETA); } - // *) Variable-length binning vs. occupancy: - if (cf_res.cfUseVariableLength_occu_bins) { + + // *) Binning vs. occupancy: + if (res.fUseResultsProVariableLengthBins[AFO_OCCUPANCY]) { this->InitializeVariableLengthBins(AFO_OCCUPANCY); + } else { + this->InitializeFixedLengthBins(AFO_OCCUPANCY); } - // *) Variable-length binning vs. interaction rate: - if (cf_res.cfUseVariableLength_ir_bins) { + + // *) Binning vs. interaction rate: + if (res.fUseResultsProVariableLengthBins[AFO_INTERACTIONRATE]) { this->InitializeVariableLengthBins(AFO_INTERACTIONRATE); + } else { + this->InitializeFixedLengthBins(AFO_INTERACTIONRATE); } - // *) Variable-length binning vs. run duration: - if (cf_res.cfUseVariableLength_crd_bins) { + + // *) Binning vs. current run duration: + if (res.fUseResultsProVariableLengthBins[AFO_CURRENTRUNDURATION]) { this->InitializeVariableLengthBins(AFO_CURRENTRUNDURATION); + } else { + this->InitializeFixedLengthBins(AFO_CURRENTRUNDURATION); } + // *) Binning vs. vertex z position: + if (res.fUseResultsProVariableLengthBins[AFO_VZ]) { + this->InitializeVariableLengthBins(AFO_VZ); + } else { + this->InitializeFixedLengthBins(AFO_VZ); + } + + // *) Binning vs. particle charge => binning is always the same nBins = 2 in (-2.,2), so that the center of bins is at +/- 1: + // Therefore, I shall never initialize or set for ill-defined cases the charge to 0., because when filling, that one will go to bin for +1 charge ("lower boundary included"). + res.fResultsProBinEdges[AFO_CHARGE] = new TArrayD(3); + res.fResultsProBinEdges[AFO_CHARGE]->AddAt(-2., 0); + res.fResultsProBinEdges[AFO_CHARGE]->AddAt(0., 1); + res.fResultsProBinEdges[AFO_CHARGE]->AddAt(2., 2); + + // ... + if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void DefaultBinning() +} // void defaultBinning() //============================================================ void InitializeFixedLengthBins(eAsFunctionOf AFO) { - // This is a helper function to suppress code bloat in DefaultBinning(). + // This is a helper function to suppress code bloat in defaultBinning(). // It merely initalizes res.fResultsProFixedLengthBins[...] from corresponding configurables + a few other minor thingies. + // I do not have here AFO_INTEGRATED and AFO_CHARGE, because for them binning is always the same, i.e. no need for configurable. if (tc.fVerbose) { StartFunction(__FUNCTION__); } // Common local vector for all fixed-length bins: - vector lFixedLength_bins; + std::vector lFixedLength_bins; switch (AFO) { - case AFO_MULTIPLICITY: - lFixedLength_bins = cf_res.cfFixedLength_mult_bins.value; + case AFO_MULTIPLICITY: { + lFixedLength_bins = cf_res.cfFixedLengthMultBins.value; + break; + } + case AFO_CENTRALITY: { + lFixedLength_bins = cf_res.cfFixedLengthCentBins.value; break; - case AFO_CENTRALITY: - lFixedLength_bins = cf_res.cfFixedLength_cent_bins.value; + } + case AFO_PT: { + lFixedLength_bins = cf_res.cfFixedLengthPtBins.value; break; - case AFO_PT: - lFixedLength_bins = cf_res.cfFixedLength_pt_bins.value; + } + case AFO_ETA: { + lFixedLength_bins = cf_res.cfFixedLengthEtaBins.value; break; - case AFO_ETA: - lFixedLength_bins = cf_res.cfFixedLength_eta_bins.value; + } + case AFO_OCCUPANCY: { + lFixedLength_bins = cf_res.cfFixedLengthOccuBins.value; break; - case AFO_OCCUPANCY: - lFixedLength_bins = cf_res.cfFixedLength_occu_bins.value; + } + case AFO_INTERACTIONRATE: { + lFixedLength_bins = cf_res.cfFixedLengthIRBins.value; break; - case AFO_INTERACTIONRATE: - lFixedLength_bins = cf_res.cfFixedLength_ir_bins.value; + } + case AFO_CURRENTRUNDURATION: { + lFixedLength_bins = cf_res.cfFixedLengthCRDBins.value; break; - case AFO_CURRENTRUNDURATION: - lFixedLength_bins = cf_res.cfFixedLength_crd_bins.value; + } + case AFO_VZ: { + lFixedLength_bins = cf_res.cfFixedLengthVzBins.value; break; + } // ... - default: + default: { LOGF(fatal, "\033[1;31m%s at line %d : This enum AFO = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(AFO)); break; + } } // switch(AFO) // From this point onward, the code is the same for any AFO variable: if (lFixedLength_bins.size() != 3) { LOGF(fatal, "in function \033[1;31m%s at line %d => The array cfFixedLength_bins must have have 3 entries: {nBins, min, max} \n \033[0m", __FUNCTION__, __LINE__); } - res.fResultsProFixedLengthBins[AFO][0] = lFixedLength_bins[0]; - res.fResultsProFixedLengthBins[AFO][1] = lFixedLength_bins[1]; - res.fResultsProFixedLengthBins[AFO][2] = lFixedLength_bins[2]; + + res.fResultsProBinEdges[AFO] = ArrayWithBinEdges(lFixedLength_bins[0], lFixedLength_bins[1], lFixedLength_bins[2]); if (tc.fVerbose) { - LOGF(info, "\033[1;32m %s : fixed-length %s bins \033[0m", __FUNCTION__, res.fResultsProXaxisTitle[AFO].Data()); - LOGF(info, "\033[1;32m [0] : %f \033[0m", res.fResultsProFixedLengthBins[AFO][0]); - LOGF(info, "\033[1;32m [1] : %f \033[0m", res.fResultsProFixedLengthBins[AFO][1]); - LOGF(info, "\033[1;32m [2] : %f \033[0m", res.fResultsProFixedLengthBins[AFO][2]); ExitFunction(__FUNCTION__); } @@ -1210,7 +1859,7 @@ void InitializeFixedLengthBins(eAsFunctionOf AFO) void InitializeVariableLengthBins(eAsFunctionOf AFO) { - // This is a helper function to suppress code bloat in DefaultBinning(). + // This is a helper function to suppress code bloat in defaultBinning(). // It merely initalizes res.fResultsProVariableLengthBins[...] from corresponding configurables + a few other minor thingies. if (tc.fVerbose) { @@ -1218,46 +1867,57 @@ void InitializeVariableLengthBins(eAsFunctionOf AFO) } // Common local vector for all variable-length bins: - vector lVariableLength_bins; + std::vector lVariableLength_bins; switch (AFO) { - case AFO_MULTIPLICITY: - lVariableLength_bins = cf_res.cfVariableLength_mult_bins.value; + case AFO_MULTIPLICITY: { + lVariableLength_bins = cf_res.cfVariableLengthMultBins.value; + break; + } + case AFO_CENTRALITY: { + lVariableLength_bins = cf_res.cfVariableLengthCentBins.value; break; - case AFO_CENTRALITY: - lVariableLength_bins = cf_res.cfVariableLength_cent_bins.value; + } + case AFO_PT: { + lVariableLength_bins = cf_res.cfVariableLengthPtBins.value; break; - case AFO_PT: - lVariableLength_bins = cf_res.cfVariableLength_pt_bins.value; + } + case AFO_ETA: { + lVariableLength_bins = cf_res.cfVariableLengthEtaBins.value; break; - case AFO_ETA: - lVariableLength_bins = cf_res.cfVariableLength_eta_bins.value; + } + case AFO_OCCUPANCY: { + lVariableLength_bins = cf_res.cfVariableLengthOccuBins.value; break; - case AFO_OCCUPANCY: - lVariableLength_bins = cf_res.cfVariableLength_occu_bins.value; + } + case AFO_INTERACTIONRATE: { + lVariableLength_bins = cf_res.cfVariableLengthIRBins.value; break; - case AFO_INTERACTIONRATE: - lVariableLength_bins = cf_res.cfVariableLength_ir_bins.value; + } + case AFO_CURRENTRUNDURATION: { + lVariableLength_bins = cf_res.cfVariableLengthCRDBins.value; break; - case AFO_CURRENTRUNDURATION: - lVariableLength_bins = cf_res.cfVariableLength_crd_bins.value; + } + case AFO_VZ: { + lVariableLength_bins = cf_res.cfVariableLengthVzBins.value; break; + } // ... - default: + default: { LOGF(fatal, "\033[1;31m%s at line %d : This enum AFO = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(AFO)); break; + } } // switch(AFO) // From this point onward, the code is the same for any AFO variable: - res.fUseResultsProVariableLengthBins[AFO] = kTRUE; if (lVariableLength_bins.size() < 2) { LOGF(fatal, "in function \033[1;31m%s at line %d => The array cfVariableLength_bins must have at least 2 entries \n \033[0m", __FUNCTION__, __LINE__); } - res.fResultsProVariableLengthBins[AFO] = new TArrayF(lVariableLength_bins.size(), lVariableLength_bins.data()); + res.fResultsProBinEdges[AFO] = new TArrayD(lVariableLength_bins.size(), lVariableLength_bins.data()); if (tc.fVerbose) { LOGF(info, "\033[1;32m %s : variable-length %s bins \033[0m", __FUNCTION__, res.fResultsProXaxisTitle[AFO].Data()); - for (Int_t i = 0; i < res.fResultsProVariableLengthBins[AFO]->GetSize(); i++) { - LOGF(info, "\033[1;32m [%d] : %f \033[0m", i, res.fResultsProVariableLengthBins[AFO]->GetAt(i)); + for (int i = 0; i < res.fResultsProBinEdges[AFO]->GetSize(); i++) { + LOGF(info, "\033[1;32m [%d] : %f \033[0m", i, res.fResultsProBinEdges[AFO]->GetAt(i)); } } @@ -1269,7 +1929,7 @@ void InitializeVariableLengthBins(eAsFunctionOf AFO) //============================================================ -void CastStringIntoArray(Int_t AFO) +void CastStringIntoArray(int AFO) { // Temporary function, to be removed eventually. Here temporarily I am casting e.g. a string "1.0,2.0,5.0" into corresponding TArrayD. @@ -1287,15 +1947,15 @@ void CastStringIntoArray(Int_t AFO) if (!oa) { LOGF(fatal, "in function \033[1;31m%s at line %d \n fResultsProVariableLengthBinsString[AFO] = %s\033[0m", __FUNCTION__, __LINE__, res.fResultsProVariableLengthBinsString[AFO].Data()); } - Int_t nEntries = oa->GetEntries(); + int nEntries = oa->GetEntries(); res.fResultsProVariableLengthBins[AFO] = new TArrayF(nEntries); - for (Int_t i = 0; i < nEntries; i++) { + for (int i = 0; i < nEntries; i++) { res.fResultsProVariableLengthBins[AFO]->AddAt(TString(oa->At(i)->GetName()).Atof(), i); } delete oa; // yes, otherwise it's a memory leak if (tc.fVerbose) { - for (Int_t i = 0; i < res.fResultsProVariableLengthBins[AFO]->GetSize(); i++) { + for (int i = 0; i < res.fResultsProVariableLengthBins[AFO]->GetSize(); i++) { LOGF(info, "\033[1;32m [%d] : %f \033[0m", i, res.fResultsProVariableLengthBins[AFO]->At(i)); } } @@ -1304,11 +1964,11 @@ void CastStringIntoArray(Int_t AFO) LOGF(info, "\033[1;32m Done! \033[0m"); } -} // void CastStringIntoArray(Int_t AFO) +} // void CastStringIntoArray(int AFO) //============================================================ -void DefaultCuts() +void defaultCuts() { // Define default cuts. Default cuts are hardwired in MuPa-Configurables.h. @@ -1323,7 +1983,7 @@ void DefaultCuts() // *) Use or do not use a cut enumerated in eEventHistograms + eEventCuts. // Default cuts are set in configurable cfUseEventCuts - auto lUseEventCuts = (vector)cf_ec.cfUseEventCuts; + auto lUseEventCuts = (std::vector)cf_ec.cfUseEventCuts; if (lUseEventCuts.size() != eEventCuts_N) { LOGF(info, "\033[1;31m lUseEventCuts.size() = %d\033[0m", lUseEventCuts.size()); LOGF(info, "\033[1;31m eEventCuts_N = %d\033[0m", static_cast(eEventCuts_N)); @@ -1332,7 +1992,7 @@ void DefaultCuts() // *) Insanity check on the content and ordering of event cuts in the initialization in configurable cfUseEventCuts: // TBI 20240518 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. - for (Int_t name = 0; name < eEventCuts_N; name++) { + for (int name = 0; name < eEventCuts_N; name++) { // TBI 20240518 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. if (!TString(lUseEventCuts[name]).EndsWith(ec.fEventCutName[name].Data())) { LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfUseEventCuts => name = %d, lUseEventCuts[name] = \"%s\", ec.fEventCutName[name] = \"%s\" \033[0m", __FUNCTION__, __LINE__, name, TString(lUseEventCuts[name]).Data(), ec.fEventCutName[name].Data()); @@ -1345,9 +2005,9 @@ void DefaultCuts() ec.fUseEventCuts[eMultiplicity] = Alright(lUseEventCuts[eMultiplicity]); ec.fUseEventCuts[eReferenceMultiplicity] = Alright(lUseEventCuts[eReferenceMultiplicity]); ec.fUseEventCuts[eCentrality] = Alright(lUseEventCuts[eCentrality]); - ec.fUseEventCuts[eVertex_x] = Alright(lUseEventCuts[eVertex_x]); - ec.fUseEventCuts[eVertex_y] = Alright(lUseEventCuts[eVertex_y]); - ec.fUseEventCuts[eVertex_z] = Alright(lUseEventCuts[eVertex_z]); + ec.fUseEventCuts[eVertexX] = Alright(lUseEventCuts[eVertexX]); + ec.fUseEventCuts[eVertexY] = Alright(lUseEventCuts[eVertexY]); + ec.fUseEventCuts[eVertexZ] = Alright(lUseEventCuts[eVertexZ]); ec.fUseEventCuts[eNContributors] = Alright(lUseEventCuts[eNContributors]); ec.fUseEventCuts[eImpactParameter] = Alright(lUseEventCuts[eImpactParameter]); ec.fUseEventCuts[eEventPlaneAngle] = Alright(lUseEventCuts[eEventPlaneAngle]); @@ -1379,6 +2039,19 @@ void DefaultCuts() ec.fUseEventCuts[eIsGoodITSLayersAll] = Alright(lUseEventCuts[eIsGoodITSLayersAll]); ec.fUseEventCuts[eOccupancyEstimator] = Alright(lUseEventCuts[eOccupancyEstimator]); ec.fUseEventCuts[eMinVertexDistanceFromIP] = Alright(lUseEventCuts[eMinVertexDistanceFromIP]); + ec.fUseEventCuts[eNoPileupTPC] = Alright(lUseEventCuts[eNoPileupTPC]); + ec.fUseEventCuts[eNoPileupFromSPD] = Alright(lUseEventCuts[eNoPileupFromSPD]); + ec.fUseEventCuts[eNoSPDOnVsOfPileup] = Alright(lUseEventCuts[eNoSPDOnVsOfPileup]); + ec.fUseEventCuts[eRefMultVsNContrUp] = Alright(lUseEventCuts[eRefMultVsNContrUp]); + ec.fUseEventCuts[eRefMultVsNContrLow] = Alright(lUseEventCuts[eRefMultVsNContrLow]); + ec.fUseEventCuts[eCentralityCorrelationsCut] = Alright(lUseEventCuts[eCentralityCorrelationsCut]); + ec.fUseEventCuts[eFT0Bad] = Alright(lUseEventCuts[eFT0Bad]); + ec.fUseEventCuts[eITSBad] = Alright(lUseEventCuts[eITSBad]); + ec.fUseEventCuts[eITSLimAccMCRepr] = Alright(lUseEventCuts[eITSLimAccMCRepr]); + ec.fUseEventCuts[eTPCBadTracking] = Alright(lUseEventCuts[eTPCBadTracking]); + ec.fUseEventCuts[eTPCLimAccMCRepr] = Alright(lUseEventCuts[eTPCLimAccMCRepr]); + ec.fUseEventCuts[eTPCBadPID] = Alright(lUseEventCuts[eTPCBadPID]); + ec.fUseEventCuts[eCentralityWeights] = Alright(lUseEventCuts[eCentralityWeights]); // **) event cuts defined via booleans: ec.fUseEventCuts[eSel7] = ec.fUseEventCuts[eSel7] && cf_ec.cfUseSel7; @@ -1396,6 +2069,16 @@ void DefaultCuts() ec.fUseEventCuts[eIsGoodITSLayer3] = ec.fUseEventCuts[eIsGoodITSLayer3] && cf_ec.cfUseIsGoodITSLayer3; ec.fUseEventCuts[eIsGoodITSLayer0123] = ec.fUseEventCuts[eIsGoodITSLayer0123] && cf_ec.cfUseIsGoodITSLayer0123; ec.fUseEventCuts[eIsGoodITSLayersAll] = ec.fUseEventCuts[eIsGoodITSLayersAll] && cf_ec.cfUseIsGoodITSLayersAll; + ec.fUseEventCuts[eNoPileupTPC] = ec.fUseEventCuts[eNoPileupTPC] && cf_ec.cfUseNoPileupTPC; + ec.fUseEventCuts[eNoPileupFromSPD] = ec.fUseEventCuts[eNoPileupFromSPD] && cf_ec.cfUseNoPileupFromSPD; + ec.fUseEventCuts[eNoSPDOnVsOfPileup] = ec.fUseEventCuts[eNoSPDOnVsOfPileup] && cf_ec.cfUseNoSPDOnVsOfPileup; + ec.fUseEventCuts[eFT0Bad] = ec.fUseEventCuts[eFT0Bad] && cf_ec.cfUseFT0Bad; + ec.fUseEventCuts[eITSBad] = ec.fUseEventCuts[eITSBad] && cf_ec.cfUseITSBad; + ec.fUseEventCuts[eITSLimAccMCRepr] = ec.fUseEventCuts[eITSLimAccMCRepr] && cf_ec.cfUseITSLimAccMCRepr; + ec.fUseEventCuts[eTPCBadTracking] = ec.fUseEventCuts[eTPCBadTracking] && cf_ec.cfUseTPCBadTracking; + ec.fUseEventCuts[eTPCLimAccMCRepr] = ec.fUseEventCuts[eTPCLimAccMCRepr] && cf_ec.cfUseTPCLimAccMCRepr; + ec.fUseEventCuts[eTPCBadPID] = ec.fUseEventCuts[eTPCBadPID] && cf_ec.cfUseTPCBadPID; + ec.fUseEventCuts[eCentralityWeights] = ec.fUseEventCuts[eCentralityWeights] && cf_cw.cfUseCentralityWeights; // **) event cuts defined via [min, max): // Remark: I use this one also for events cuts set only via min or via max. @@ -1411,6 +2094,10 @@ void DefaultCuts() auto lMultiplicity = (std::vector)cf_ec.cfMultiplicity; ec.fdEventCuts[eMultiplicity][eMin] = lMultiplicity[eMin]; ec.fdEventCuts[eMultiplicity][eMax] = lMultiplicity[eMax]; + // If I have requested fFixedNumberOfRandomlySelectedTracks, then I do not care about events with smaller number of particles: + if (tc.fFixedNumberOfRandomlySelectedTracks > 0) { + ec.fdEventCuts[eMultiplicity][eMin] = tc.fFixedNumberOfRandomlySelectedTracks; + } auto lReferenceMultiplicity = (std::vector)cf_ec.cfReferenceMultiplicity; ec.fdEventCuts[eReferenceMultiplicity][eMin] = lReferenceMultiplicity[eMin]; @@ -1420,17 +2107,17 @@ void DefaultCuts() ec.fdEventCuts[eCentrality][eMin] = lCentrality[eMin]; ec.fdEventCuts[eCentrality][eMax] = lCentrality[eMax]; - auto lVertex_x = (std::vector)cf_ec.cfVertex_x; - ec.fdEventCuts[eVertex_x][eMin] = lVertex_x[eMin]; - ec.fdEventCuts[eVertex_x][eMax] = lVertex_x[eMax]; + auto lVertexX = (std::vector)cf_ec.cfVertexX; + ec.fdEventCuts[eVertexX][eMin] = lVertexX[eMin]; + ec.fdEventCuts[eVertexX][eMax] = lVertexX[eMax]; - auto lVertex_y = (std::vector)cf_ec.cfVertex_y; - ec.fdEventCuts[eVertex_y][eMin] = lVertex_y[eMin]; - ec.fdEventCuts[eVertex_y][eMax] = lVertex_y[eMax]; + auto lVertexY = (std::vector)cf_ec.cfVertexY; + ec.fdEventCuts[eVertexY][eMin] = lVertexY[eMin]; + ec.fdEventCuts[eVertexY][eMax] = lVertexY[eMax]; - auto lVertex_z = (std::vector)cf_ec.cfVertex_z; - ec.fdEventCuts[eVertex_z][eMin] = lVertex_z[eMin]; - ec.fdEventCuts[eVertex_z][eMax] = lVertex_z[eMax]; + auto lVertexZ = (std::vector)cf_ec.cfVertexZ; + ec.fdEventCuts[eVertexZ][eMin] = lVertexZ[eMin]; + ec.fdEventCuts[eVertexZ][eMax] = lVertexZ[eMax]; auto lNContributors = (std::vector)cf_ec.cfNContributors; ec.fdEventCuts[eNContributors][eMin] = lNContributors[eMin]; @@ -1465,7 +2152,7 @@ void DefaultCuts() ec.fdEventCuts[eSelectedEvents][eMax] = lSelectedEvents[eMax]; ec.fdEventCuts[eMinVertexDistanceFromIP][eMin] = cf_ec.cfMinVertexDistanceFromIP; // if vertex is closer to IP than this value, the event is rejected - ec.fdEventCuts[eMinVertexDistanceFromIP][eMax] = -1; // // this value is never checked in any case + ec.fdEventCuts[eMinVertexDistanceFromIP][eMax] = -1; // this value is never checked in any case // **) event cuts defined via string: ec.fsEventCuts[eMultiplicityEstimator] = cf_ec.cfMultiplicityEstimator; @@ -1473,6 +2160,13 @@ void DefaultCuts() ec.fsEventCuts[eCentralityEstimator] = cf_ec.cfCentralityEstimator; ec.fsEventCuts[eTrigger] = cf_ec.cfTrigger; ec.fsEventCuts[eOccupancyEstimator] = cf_ec.cfOccupancyEstimator; + ec.fsEventCuts[eRefMultVsNContrUp] = cf_ec.cfRefMultVsNContrUp; + ec.fsEventCuts[eRefMultVsNContrLow] = cf_ec.cfRefMultVsNContrLow; + ec.fsEventCuts[eCentralityCorrelationsCut] = cf_ec.cfCentralityCorrelationsCut; + + // **) additional info for some specific event cuts, which I didn't enumerate in enum eEventCuts, to trim down bookeeping: + ec.fCentralityCorrelationsCutTreshold = cf_ec.cfCentralityCorrelationsCutTreshold; + ec.fCentralityCorrelationsCutVersion = cf_ec.cfCentralityCorrelationsCutVersion; // ---------------------------------------------------------------------- @@ -1480,7 +2174,7 @@ void DefaultCuts() // *) Use or do not use a cut enumerated in eParticleHistograms + eParticleCuts. // Default cuts are set in configurable cfUseParticleCuts - auto lUseParticleCuts = (std::vector)cf_pc.cfUseParticleCuts; + auto lUseParticleCuts = (std::vector)cf_pc.cfUseParticleCuts; if (lUseParticleCuts.size() != eParticleCuts_N) { LOGF(info, "\033[1;31m lUseParticleCuts.size() = %d\033[0m", lUseParticleCuts.size()); LOGF(info, "\033[1;31m eParticleCuts_N = %d\033[0m", static_cast(eParticleCuts_N)); @@ -1489,7 +2183,7 @@ void DefaultCuts() // *) Insanity check on the content and ordering of particle cuts in the initialization in configurable cfUseParticleCuts: // TBI 20240518 I do not need this in fact, I can automate initialization even without ordering in configurable, but it feels with the ordering enforced, it's much safer. - for (Int_t name = 0; name < eParticleCuts_N; name++) { + for (int name = 0; name < eParticleCuts_N; name++) { // TBI 20240518 I could implement even a strickter EqualTo instead of EndsWith, but then I need to tokenize, etc., etc. This shall be safe enough. if (!TString(lUseParticleCuts[name]).EndsWith(pc.fParticleCutName[name].Data())) { LOGF(fatal, "\033[1;31m%s at line %d : Wrong content or ordering of contents in configurable cfUseParticleCuts => name = %d, lUseParticleCuts[name] = \"%s\", pc.fParticleCutName[name] = \"%s\" \033[0m", __FUNCTION__, __LINE__, name, TString(lUseParticleCuts[name]).Data(), pc.fParticleCutName[name].Data()); @@ -1503,6 +2197,7 @@ void DefaultCuts() pc.fUseParticleCuts[eCharge] = Alright(lUseParticleCuts[eCharge]); pc.fUseParticleCuts[etpcNClsFindable] = Alright(lUseParticleCuts[etpcNClsFindable]); pc.fUseParticleCuts[etpcNClsShared] = Alright(lUseParticleCuts[etpcNClsShared]); + pc.fUseParticleCuts[eitsChi2NCl] = Alright(lUseParticleCuts[eitsChi2NCl]); pc.fUseParticleCuts[etpcNClsFound] = Alright(lUseParticleCuts[etpcNClsFound]); pc.fUseParticleCuts[etpcNClsCrossedRows] = Alright(lUseParticleCuts[etpcNClsCrossedRows]); pc.fUseParticleCuts[eitsNCls] = Alright(lUseParticleCuts[eitsNCls]); @@ -1510,24 +2205,29 @@ void DefaultCuts() pc.fUseParticleCuts[etpcCrossedRowsOverFindableCls] = Alright(lUseParticleCuts[etpcCrossedRowsOverFindableCls]); pc.fUseParticleCuts[etpcFoundOverFindableCls] = Alright(lUseParticleCuts[etpcFoundOverFindableCls]); pc.fUseParticleCuts[etpcFractionSharedCls] = Alright(lUseParticleCuts[etpcFractionSharedCls]); + pc.fUseParticleCuts[etpcChi2NCl] = Alright(lUseParticleCuts[etpcChi2NCl]); pc.fUseParticleCuts[edcaXY] = Alright(lUseParticleCuts[edcaXY]); pc.fUseParticleCuts[edcaZ] = Alright(lUseParticleCuts[edcaZ]); pc.fUseParticleCuts[ePDG] = Alright(lUseParticleCuts[ePDG]); + pc.fUseParticleCuts[etrackCutFlag] = Alright(lUseParticleCuts[etrackCutFlag]); pc.fUseParticleCuts[etrackCutFlagFb1] = Alright(lUseParticleCuts[etrackCutFlagFb1]); pc.fUseParticleCuts[etrackCutFlagFb2] = Alright(lUseParticleCuts[etrackCutFlagFb2]); pc.fUseParticleCuts[eisQualityTrack] = Alright(lUseParticleCuts[eisQualityTrack]); pc.fUseParticleCuts[eisPrimaryTrack] = Alright(lUseParticleCuts[eisPrimaryTrack]); pc.fUseParticleCuts[eisInAcceptanceTrack] = Alright(lUseParticleCuts[eisInAcceptanceTrack]); pc.fUseParticleCuts[eisGlobalTrack] = Alright(lUseParticleCuts[eisGlobalTrack]); + pc.fUseParticleCuts[eisPVContributor] = Alright(lUseParticleCuts[eisPVContributor]); pc.fUseParticleCuts[ePtDependentDCAxyParameterization] = Alright(lUseParticleCuts[ePtDependentDCAxyParameterization]); // **) particles cuts defined via booleans: + pc.fUseParticleCuts[etrackCutFlag] = pc.fUseParticleCuts[etrackCutFlag] && cf_pc.cftrackCutFlag; pc.fUseParticleCuts[etrackCutFlagFb1] = pc.fUseParticleCuts[etrackCutFlagFb1] && cf_pc.cftrackCutFlagFb1; pc.fUseParticleCuts[etrackCutFlagFb2] = pc.fUseParticleCuts[etrackCutFlagFb2] && cf_pc.cftrackCutFlagFb2; pc.fUseParticleCuts[eisQualityTrack] = pc.fUseParticleCuts[eisQualityTrack] && cf_pc.cfisQualityTrack; pc.fUseParticleCuts[eisPrimaryTrack] = pc.fUseParticleCuts[eisPrimaryTrack] && cf_pc.cfisPrimaryTrack; pc.fUseParticleCuts[eisInAcceptanceTrack] = pc.fUseParticleCuts[eisInAcceptanceTrack] && cf_pc.cfisInAcceptanceTrack; pc.fUseParticleCuts[eisGlobalTrack] = pc.fUseParticleCuts[eisGlobalTrack] && cf_pc.cfisGlobalTrack; + pc.fUseParticleCuts[eisPVContributor] = pc.fUseParticleCuts[eisPVContributor] && cf_pc.cfisPVContributor; // **) particles cuts defined via [min, max): auto lPhi = (std::vector)cf_pc.cfPhi; @@ -1554,6 +2254,10 @@ void DefaultCuts() pc.fdParticleCuts[etpcNClsShared][eMin] = ltpcNClsShared[eMin]; pc.fdParticleCuts[etpcNClsShared][eMax] = ltpcNClsShared[eMax]; + auto litsChi2NCl = (std::vector)cf_pc.cfitsChi2NCl; + pc.fdParticleCuts[eitsChi2NCl][eMin] = litsChi2NCl[eMin]; + pc.fdParticleCuts[eitsChi2NCl][eMax] = litsChi2NCl[eMax]; + auto ltpcNClsFound = (std::vector)cf_pc.cftpcNClsFound; pc.fdParticleCuts[etpcNClsFound][eMin] = ltpcNClsFound[eMin]; pc.fdParticleCuts[etpcNClsFound][eMax] = ltpcNClsFound[eMax]; @@ -1582,6 +2286,10 @@ void DefaultCuts() pc.fdParticleCuts[etpcFractionSharedCls][eMin] = ltpcFractionSharedCls[eMin]; pc.fdParticleCuts[etpcFractionSharedCls][eMax] = ltpcFractionSharedCls[eMax]; + auto ltpcChi2NCl = (std::vector)cf_pc.cftpcChi2NCl; + pc.fdParticleCuts[etpcChi2NCl][eMin] = ltpcChi2NCl[eMin]; + pc.fdParticleCuts[etpcChi2NCl][eMax] = ltpcChi2NCl[eMax]; + auto ldcaXY = (std::vector)cf_pc.cfdcaXY; pc.fdParticleCuts[edcaXY][eMin] = ldcaXY[eMin]; pc.fdParticleCuts[edcaXY][eMax] = ldcaXY[eMax]; @@ -1601,16 +2309,16 @@ void DefaultCuts() ExitFunction(__FUNCTION__); } -} // void DefaultCuts() +} // void defaultCuts() //============================================================ -void SpecificCuts(TString whichSpecificCuts) +void specificCuts(TString whichSpecificCuts) { - // After default cuts are applied, on top of them apply analysis-specific cuts. Has to be called after DefaultBinning() and DefaultCuts(). - // Typically, analysis-specific cuts are determined through period tag, see below the case statement. - // Both event and particle cuts are hardwired here. - // All expert suggestions about the cuts to be used for specific period are hardwired here. + // After default cuts are applied, on top of them apply analysis-specific cuts. Has to be called after defaultBinning() and defaultCuts(). + // Here I hardwire defalt cuts and settings for a given period which will overwrite whatever is set in configurables. + // When I do systematic checks, this option shall NOT be used, because values for some cuts which I plan to vary, are also hardwired here. + // Both event and particle cuts are hardwired here. As well as some other settings. // For the time being, all specific cuts are defaulted and tuned for the latest reconstruction pass. // a) Mapping; @@ -1625,108 +2333,408 @@ void SpecificCuts(TString whichSpecificCuts) eSpecificCuts specificCuts = eSpecificCuts_N; if (whichSpecificCuts.EqualTo("LHC23zzh")) { specificCuts = eLHC23zzh; - } else if (whichSpecificCuts.EqualTo("...")) { - // ... + } else if (whichSpecificCuts.EqualTo("LHC24ar")) { + specificCuts = eLHC24ar; + } else if (whichSpecificCuts.EqualTo("LHC24as")) { + specificCuts = eLHC24as; + } else if (whichSpecificCuts.EqualTo("LHC15o")) { + specificCuts = eLHC15o; + } else if (whichSpecificCuts.EqualTo("Test")) { + specificCuts = eTestCuts; } else { LOGF(fatal, "\033[1;31m%s at line %d : whichSpecificCuts = %s is not supported \033[0m", __FUNCTION__, __LINE__, whichSpecificCuts.Data()); } // b) Implementation of analysis-specific cuts: - // Remark #1: Whichever cuts start to repeat below across different case statements, promote them into DefaultCuts(). - // The idea is to keep here cuts only which are specific for particular analysis, and which are unlikely ever to change for that particular analysis. + // Remark #1: Whichever cuts start to repeat below across different case statements, promote them into defaultCuts(), i.e. hardwire those values in configurables. + // The idea is to keep here cuts only which are specific for particular analysis, and which are unlikely ever to change as a default cut for that particular analysis. // Remark #2: Remember that the values for the cuts hardwired here overwrite the ones set as default values in configurables. - // If you want to reconfigure all cuts below manually via configurables, simply do not call SpecificCuts, i.e. set in JSON "cfUseSpecificCuts": "false" + // If you want to reconfigure all cuts below manually via configurables, simply do not call specificCuts, i.e. set in JSON "cfUseSpecificCuts": "false" + // Therefore, if I want to vary some of these cuts via configurables as a part of systematics, I must set in JSON "cfUseSpecificCuts": "false" // Remark #3: Most up-to-date documentation of each cut is in enum file. switch (specificCuts) { - case eLHC23zzh: + case eLHC23zzh: { + + // In this branch I implement default cuts and settings for PbPb Run 3 datasets collected in 2023. + // If I change some cut here, keep in sync. with other branches (e.g. for 2024 data). // Event cuts: - ec.fUseEventCuts[eSel8] = kTRUE; - ec.fUseEventCuts[eNoSameBunchPileup] = kTRUE; - ec.fUseEventCuts[eIsGoodZvtxFT0vsPV] = kTRUE; - ec.fUseEventCuts[eIsVertexITSTPC] = kTRUE; - ec.fUseEventCuts[eNoCollInTimeRangeStrict] = kTRUE; - ec.fUseEventCuts[eNoCollInRofStrict] = kTRUE; - ec.fUseEventCuts[eNoHighMultCollInPrevRof] = kTRUE; + ec.fUseEventCuts[eSel7] = false; + ec.fUseEventCuts[eSel8] = true; + ec.fUseEventCuts[eNoSameBunchPileup] = true; + ec.fUseEventCuts[eIsVertexITSTPC] = true; + ec.fUseEventCuts[eNoCollInTimeRangeStandard] = true; + ec.fUseEventCuts[eNoCollInTimeRangeStrict] = false; + ec.fUseEventCuts[eNoCollInRofStandard] = true; + ec.fUseEventCuts[eNoCollInRofStrict] = false; + ec.fUseEventCuts[eNoPileupTPC] = false; // Run 2 + ec.fUseEventCuts[eNoPileupFromSPD] = false; // Run 2 + ec.fUseEventCuts[eNoSPDOnVsOfPileup] = false; // Run 2 + + ec.fUseEventCuts[eInteractionRate] = false; // I set it to false by default, to prevent having the standard memory blow-up by default + ec.fdEventCuts[eInteractionRate][eMin] = 0.1; // there are some pathological non-physical events with IR = 0. See eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity + ec.fdEventCuts[eInteractionRate][eMax] = 1000000000.; + + ec.fUseEventCuts[eRefMultVsNContrUp] = true; + ec.fUseEventCuts[eRefMultVsNContrLow] = true; + if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("MultFT0C")) { + ec.fsEventCuts[eRefMultVsNContrUp] = "1200. + 0.20*x"; // TBI 20250401 not fine-tune, just an example + ec.fsEventCuts[eRefMultVsNContrLow] = "-650. + 0.08*x"; // TBI 20250401 not fine-tune, just an example + // TBI 20250331 fine-tune this cut in the same spirit for other ref. mult. estimators + } + + ec.fUseEventCuts[eCentralityCorrelationsCut] = true; + ec.fsEventCuts[eCentralityCorrelationsCut] = "CentFT0C_CentFT0M"; + ec.fCentralityCorrelationsCutTreshold = 10.0; + ec.fCentralityCorrelationsCutVersion = "Absolute"; // Particle cuts: - pc.fUseParticleCuts[eitsNCls] = kTRUE; + pc.fUseParticleCuts[eitsNCls] = true; pc.fdParticleCuts[eitsNCls][eMin] = 5.; pc.fdParticleCuts[eitsNCls][eMax] = 1000.; - pc.fUseParticleCuts[etpcNClsFound] = kTRUE; + pc.fUseParticleCuts[etpcNClsFound] = true; pc.fdParticleCuts[etpcNClsFound][eMin] = 70.; pc.fdParticleCuts[etpcNClsFound][eMax] = 1000.; - pc.fUseParticleCuts[etpcNClsCrossedRows] = kTRUE; + pc.fUseParticleCuts[etpcNClsCrossedRows] = true; pc.fdParticleCuts[etpcNClsCrossedRows][eMin] = 70.; pc.fdParticleCuts[etpcNClsCrossedRows][eMax] = 1000.; - pc.fUseParticleCuts[etpcCrossedRowsOverFindableCls] = kTRUE; + pc.fUseParticleCuts[etpcCrossedRowsOverFindableCls] = true; pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMin] = 0.8; pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMax] = 1000.; - break; + pc.fUseParticleCuts[etpcFoundOverFindableCls] = true; + pc.fdParticleCuts[etpcFoundOverFindableCls][eMin] = 0.8; + pc.fdParticleCuts[etpcFoundOverFindableCls][eMax] = 1000.; - // ... + pc.fUseParticleCuts[etpcFractionSharedCls] = true; + pc.fdParticleCuts[etpcFractionSharedCls][eMin] = -1000.; + pc.fdParticleCuts[etpcFractionSharedCls][eMax] = 0.4; - default: - LOGF(fatal, "\033[1;31m%s at line %d : specificCuts = %d is not supported yet \033[0m", __FUNCTION__, __LINE__, static_cast(specificCuts)); - break; - } // switch((specificCuts)) + pc.fUseParticleCuts[etpcChi2NCl] = true; + pc.fdParticleCuts[etpcChi2NCl][eMin] = -1000.; + pc.fdParticleCuts[etpcChi2NCl][eMax] = 4.0; - if (tc.fVerbose) { - ExitFunction(__FUNCTION__); - } + pc.fUseParticleCuts[edcaXY] = true; + pc.fdParticleCuts[edcaXY][eMin] = -2.4; // TBI 20250401 check further + pc.fdParticleCuts[edcaXY][eMax] = 2.4; // TBI 20250401 check further -} // void SpecificCuts(const char* specificCutsName) + pc.fUseParticleCuts[edcaZ] = true; + pc.fdParticleCuts[edcaZ][eMin] = -3.2; // TBI 20250401 check further + pc.fdParticleCuts[edcaZ][eMax] = 3.2; // TBI 20250401 check further -//============================================================ + pc.fUseParticleCuts[eisInAcceptanceTrack] = false; // see enum + pc.fUseParticleCuts[eisGlobalTrack] = false; // only for Run 2 + pc.fUseParticleCuts[eisPVContributor] = true; -void InsanityChecksOnDefinitionsOfConfigurables() -{ - // Do insanity checks on values obtained from configurables before using them in the remaining function. - // This is really important, because one misconfigured configurable (e.g. boolean set to string), causes the whole json config to die silently, and - // only default values from MuPa-Configurables.h are used. - // Here I only check if configurables are correctly defined, I do NOT here initialize local variables with configurables, that is done later. - // Example misconfiguration in JSON: - // "var": "true", => var = 1 + other configurables are processed correctly - // "var": "truee", => var = 0 + all settings in JSON for configurables are ingored silently + break; + } - // TBI 20241127 finalize this function eventually. This is not urgent, though, as only a check below on cfTaskIsConfiguredFromJson covers most cases already. + case eLHC24ar: + case eLHC24as: { - // Remark: Ordering below reflects the ordering in Configurables.h, not in DataMembers.h - // a) Task configuration; - // b) QA; - // c) Event histograms; - // d) Event cuts; - // e) Particle histograms; - // f) Particle cuts; - // g) Q-vectors; - // h) Multiparticle correlations; - // i) Test0; - // j) Particle weights; - // k) Centrality weights; - // l) Nested loops; - // m) Toy NUA; - // n) Internal validation; - // o) Results histograms. + // In this branch I implement default cuts and settings for PbPb Run 3 datasets collected in 2024: + // If I change some cut here, keep in sync. with other branches (e.g. for 2023 data). + // As of 20250207, all cuts are the same as for 2023, expect that here I do NOT use eIsGoodZvtxFT0vsPV and eNoHighMultCollInPrevRof - if (tc.fVerbose) { - StartFunction(__FUNCTION__); - } + // Event cuts: + ec.fUseEventCuts[eSel7] = false; + ec.fUseEventCuts[eSel8] = true; + ec.fUseEventCuts[eNoSameBunchPileup] = true; + ec.fUseEventCuts[eIsVertexITSTPC] = true; + ec.fUseEventCuts[eNoCollInTimeRangeStandard] = true; + ec.fUseEventCuts[eNoCollInTimeRangeStrict] = false; + ec.fUseEventCuts[eNoCollInRofStandard] = true; + ec.fUseEventCuts[eNoCollInRofStrict] = false; + ec.fUseEventCuts[eIsGoodZvtxFT0vsPV] = false; // diff commpared to 2023 + ec.fUseEventCuts[eNoHighMultCollInPrevRof] = false; // diff commpared to 2023 + ec.fUseEventCuts[eNoPileupTPC] = false; // Run 2 + ec.fUseEventCuts[eNoPileupFromSPD] = false; // Run 2 + ec.fUseEventCuts[eNoSPDOnVsOfPileup] = false; // Run 2 + + ec.fUseEventCuts[eInteractionRate] = false; // I set it to false by default, to prevent having the standard memory blow-up by default + ec.fdEventCuts[eInteractionRate][eMin] = 0.1; // there are some pathological non-physical events with IR = 0. See eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity + ec.fdEventCuts[eInteractionRate][eMax] = 1000000000.; + + ec.fUseEventCuts[eRefMultVsNContrUp] = false; // TBI 20250331 set to true only when I fine-tune + ec.fUseEventCuts[eRefMultVsNContrLow] = false; // TBI 20250331 set to true only when I fine-tune + if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("MultFT0C")) { + ec.fsEventCuts[eRefMultVsNContrUp] = "..."; // TBI 20250329 I need to tune and validate for this dataset, and estimator + ec.fsEventCuts[eRefMultVsNContrLow] = "..."; // TBI 20250329 I need to tune and validate for this dataset, and estimator + // TBI 20250331 fine-tune this cut in the same spirit for other ref. mult. estimators + } - // a) Task configuration: - if (!TString(cf_tc.cfTaskIsConfiguredFromJson).EqualTo("yes")) { - LOGF(fatal, "\033[1;31m%s at line %d : configurable cfTaskIsConfiguredFromJson = \"%s\", but it has to be set to \"yes\" in JSON => most likely some other configurable is misconfigured and all remaining settings in JSON are ignored silently\033[0m", __FUNCTION__, __LINE__, TString(cf_tc.cfTaskIsConfiguredFromJson).Data()); - } + ec.fUseEventCuts[eCentralityCorrelationsCut] = false; // TBI 20250104 yes, because in 2024 I can use only FT0C at the moment + ec.fsEventCuts[eCentralityCorrelationsCut] = "CentFT0C_CentFT0M"; + ec.fCentralityCorrelationsCutTreshold = 10.0; + ec.fCentralityCorrelationsCutVersion = "Absolute"; - // b) QA: - // ... + // Particle cuts: + pc.fUseParticleCuts[eitsNCls] = true; + pc.fdParticleCuts[eitsNCls][eMin] = 5.; + pc.fdParticleCuts[eitsNCls][eMax] = 1000.; - // c) Event histograms: - // ... + pc.fUseParticleCuts[etpcNClsFound] = true; + pc.fdParticleCuts[etpcNClsFound][eMin] = 70.; + pc.fdParticleCuts[etpcNClsFound][eMax] = 1000.; + + pc.fUseParticleCuts[etpcNClsCrossedRows] = true; + pc.fdParticleCuts[etpcNClsCrossedRows][eMin] = 70.; + pc.fdParticleCuts[etpcNClsCrossedRows][eMax] = 1000.; + + pc.fUseParticleCuts[etpcCrossedRowsOverFindableCls] = true; + pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMin] = 0.8; + pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMax] = 1000.; + + pc.fUseParticleCuts[etpcFoundOverFindableCls] = true; + pc.fdParticleCuts[etpcFoundOverFindableCls][eMin] = 0.8; + pc.fdParticleCuts[etpcFoundOverFindableCls][eMax] = 1000.; + + pc.fUseParticleCuts[etpcFractionSharedCls] = true; + pc.fdParticleCuts[etpcFractionSharedCls][eMin] = -1000.; + pc.fdParticleCuts[etpcFractionSharedCls][eMax] = 0.4; + + pc.fUseParticleCuts[etpcChi2NCl] = true; + pc.fdParticleCuts[etpcChi2NCl][eMin] = -1000.; + pc.fdParticleCuts[etpcChi2NCl][eMax] = 4.0; + + pc.fUseParticleCuts[edcaXY] = true; + pc.fdParticleCuts[edcaXY][eMin] = -2.4; // TBI 20250401 check further + pc.fdParticleCuts[edcaXY][eMax] = 2.4; // TBI 20250401 check further + + pc.fUseParticleCuts[edcaZ] = true; + pc.fdParticleCuts[edcaZ][eMin] = -3.2; // TBI 20250401 check further + pc.fdParticleCuts[edcaZ][eMax] = 3.2; // TBI 20250401 check further + + pc.fUseParticleCuts[eisInAcceptanceTrack] = false; // see enum + pc.fUseParticleCuts[eisGlobalTrack] = false; // only for Run 2 + pc.fUseParticleCuts[eisPVContributor] = true; + + break; + } + + case eLHC15o: { + + // In this branch I implement default cuts and settings for Run 2 datasets: + + // Event cuts: + ec.fUseEventCuts[eOccupancy] = false; + ec.fUseEventCuts[eInteractionRate] = false; + ec.fUseEventCuts[eCurrentRunDuration] = false; + // ec.fUseEventCuts[eSel7] = true; // TBI 20250115 ehen i procees in "Rec" some converted Run 2 MC, it removes 99% of events, see enum + ec.fUseEventCuts[eSel8] = false; + ec.fUseEventCuts[eNoSameBunchPileup] = false; + ec.fUseEventCuts[eIsGoodZvtxFT0vsPV] = false; + ec.fUseEventCuts[eIsVertexITSTPC] = false; + ec.fUseEventCuts[eNoCollInTimeRangeStrict] = false; + ec.fUseEventCuts[eNoCollInRofStrict] = false; + ec.fUseEventCuts[eNoHighMultCollInPrevRof] = false; + ec.fUseEventCuts[eNoCollInTimeRangeStandard] = false; + ec.fUseEventCuts[eNoCollInRofStrict] = false; + ec.fUseEventCuts[eNoCollInRofStandard] = false; + ec.fUseEventCuts[eNoCollInRofStandard] = false; + ec.fUseEventCuts[eIsGoodITSLayer3] = false; + ec.fUseEventCuts[eIsGoodITSLayer0123] = false; + ec.fUseEventCuts[eIsGoodITSLayersAll] = false; + ec.fUseEventCuts[eFT0Bad] = false; + ec.fUseEventCuts[eITSBad] = false; + ec.fUseEventCuts[eITSLimAccMCRepr] = false; + ec.fUseEventCuts[eTPCBadTracking] = false; + ec.fUseEventCuts[eTPCLimAccMCRepr] = false; + ec.fUseEventCuts[eTPCBadPID] = false; + ec.fUseEventCuts[eTrigger] = true; + ec.fsEventCuts[eTrigger] = "kINT7"; // TBI 20250115 remember that it cannot be used when i procees in "Rec" some converted Run 2 MC, see enum + + ec.fsEventCuts[eReferenceMultiplicityEstimator] = "MultTracklets"; // default ref. mult. estimator in Run 2 + ec.fsEventCuts[eCentralityEstimator] = "CentRun2V0M"; // default centrality estimator in Run 2 + + ec.fUseEventCuts[eRefMultVsNContrUp] = true; + ec.fUseEventCuts[eRefMultVsNContrLow] = true; + if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("MultTracklets")) { + ec.fsEventCuts[eRefMultVsNContrUp] = "700. + 0.95*x"; // TBI 20250401 not fine-tune, just an example + ec.fsEventCuts[eRefMultVsNContrLow] = "-400. + 0.5*x"; // TBI 20250401 not fine-tune, just an example + // TBI 20250331 fine-tune this cut in the same spirit for other ref. mult. estimators + } + + ec.fUseEventCuts[eCentralityCorrelationsCut] = false; + ec.fsEventCuts[eCentralityCorrelationsCut] = "CentRun2V0M_CentRun2SPDTracklets"; + ec.fCentralityCorrelationsCutTreshold = 10.0; + ec.fCentralityCorrelationsCutVersion = "Absolute"; + + // ... + + // Particle cuts: + pc.fUseParticleCuts[eisInAcceptanceTrack] = false; // see enum + pc.fUseParticleCuts[etrackCutFlagFb1] = false; // only for Run 3 + pc.fUseParticleCuts[etrackCutFlagFb2] = false; // only for Run 3 + pc.fUseParticleCuts[eisPVContributor] = false; // only for Run 3 + + // The rest: + mupa.fCalculateCorrelationsAsFunctionOf[AFO_OCCUPANCY] = false; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTERACTIONRATE] = false; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_CURRENTRUNDURATION] = false; + + t0.fCalculateTest0AsFunctionOf[AFO_OCCUPANCY] = false; + t0.fCalculateTest0AsFunctionOf[AFO_INTERACTIONRATE] = false; + t0.fCalculateTest0AsFunctionOf[AFO_CURRENTRUNDURATION] = false; + + es.fCalculateEtaSeparationsAsFunctionOf[AFO_OCCUPANCY] = false; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_INTERACTIONRATE] = false; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_CURRENTRUNDURATION] = false; + + eh.fBookEventHistograms[eOccupancy] = false; + eh.fBookEventHistograms[eInteractionRate] = false; + eh.fBookEventHistograms[eCurrentRunDuration] = false; + + qa.fBookQAEventHistograms2D[eMultiplicity_vs_Occupancy] = false; + qa.fBookQAEventHistograms2D[eMultiplicity_vs_InteractionRate] = false; + qa.fBookQAEventHistograms2D[eReferenceMultiplicity_vs_Occupancy] = false; + qa.fBookQAEventHistograms2D[eReferenceMultiplicity_vs_InteractionRate] = false; + qa.fBookQAEventHistograms2D[eNContributors_vs_Occupancy] = false; + qa.fBookQAEventHistograms2D[eNContributors_vs_InteractionRate] = false; + qa.fBookQAEventHistograms2D[eCentrality_vs_Occupancy] = false; + qa.fBookQAEventHistograms2D[eCentrality_vs_InteractionRate] = false; + qa.fBookQAEventHistograms2D[eVertexZ_vs_Occupancy] = false; + qa.fBookQAEventHistograms2D[eVertexZ_vs_InteractionRate] = false; + qa.fBookQAEventHistograms2D[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = false; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = false; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentFT0CVariant1] = false; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentFT0M] = false; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentFV0A] = false; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentNTPV] = false; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentNGlobal] = false; + qa.fBookQAEventHistograms2D[eCentFT0M_vs_CentNTPV] = false; + qa.fBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = false; + + // ... + + break; + } + + // ... + + case eTestCuts: { + + // In this branch I implement default cuts and settings for minimal subscription, "processTest": "true in JSON + + // Event cuts: + // ec.fUseEventCuts[eSel7] = true; // TBI 20250115 ehen i procees in "Rec" some converted Run 2 MC, it removes 99% of events, see enum + ec.fUseEventCuts[eSel8] = false; + ec.fUseEventCuts[eNoSameBunchPileup] = false; + ec.fUseEventCuts[eIsGoodZvtxFT0vsPV] = false; + ec.fUseEventCuts[eIsVertexITSTPC] = false; + ec.fUseEventCuts[eNoCollInTimeRangeStrict] = false; + ec.fUseEventCuts[eNoCollInRofStrict] = false; + ec.fUseEventCuts[eNoHighMultCollInPrevRof] = false; + ec.fUseEventCuts[eNoCollInTimeRangeStandard] = false; + ec.fUseEventCuts[eNoCollInRofStrict] = false; + ec.fUseEventCuts[eNoCollInRofStandard] = false; + ec.fUseEventCuts[eNoCollInRofStandard] = false; + ec.fUseEventCuts[eIsGoodITSLayer3] = false; + ec.fUseEventCuts[eIsGoodITSLayer0123] = false; + ec.fUseEventCuts[eIsGoodITSLayersAll] = false; + ec.fUseEventCuts[eFT0Bad] = false; + ec.fUseEventCuts[eITSBad] = false; + ec.fUseEventCuts[eITSLimAccMCRepr] = false; + ec.fUseEventCuts[eTPCBadTracking] = false; + ec.fUseEventCuts[eTPCLimAccMCRepr] = false; + ec.fUseEventCuts[eTPCBadPID] = false; + + // ec.fUseEventCuts[eTrigger] = true; + // ec.fsEventCuts[eTrigger] = "kINT7"; // TBI 20250115 cannot be used when i procees in "Rec" some converted Run 2 MC, see enum + + // ... + + // Particle cuts: + pc.fUseParticleCuts[eisInAcceptanceTrack] = false; // see enum + pc.fUseParticleCuts[etrackCutFlagFb1] = false; // only for Run 3 + pc.fUseParticleCuts[etrackCutFlagFb2] = false; // only for Run 3 + pc.fUseParticleCuts[eisPVContributor] = false; // only for Run 3 + + // ... + + // The rest: + mupa.fCalculateCorrelationsAsFunctionOf[AFO_OCCUPANCY] = false; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTERACTIONRATE] = false; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_CURRENTRUNDURATION] = false; + + t0.fCalculateTest0AsFunctionOf[AFO_OCCUPANCY] = false; + t0.fCalculateTest0AsFunctionOf[AFO_INTERACTIONRATE] = false; + t0.fCalculateTest0AsFunctionOf[AFO_CURRENTRUNDURATION] = false; + + es.fCalculateEtaSeparationsAsFunctionOf[AFO_OCCUPANCY] = false; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_INTERACTIONRATE] = false; + es.fCalculateEtaSeparationsAsFunctionOf[AFO_CURRENTRUNDURATION] = false; + + // ... + + break; + } + + default: { + LOGF(fatal, "\033[1;31m%s at line %d : specificCuts = %d is not supported yet \033[0m", __FUNCTION__, __LINE__, static_cast(specificCuts)); + break; + } + } // switch (specificCuts) + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void specificCuts(const char* specificCutsName) + +//============================================================ + +void insanityChecksOnDefinitionsOfConfigurables() +{ + // Do insanity checks on values obtained from configurables before using them in the remaining function. + // This is really important, because one misconfigured configurable (e.g. boolean set to string), causes the whole json config to die silently, and + // only default values from MuPa-Configurables.h are used. + // Here I only check if configurables are correctly defined, I do NOT here initialize local variables with configurables, that is done later. + // Example misconfiguration in JSON: + // "var": "true", => var = 1 + other configurables are processed correctly + // "var": "truee", => var = 0 + all settings in JSON for configurables are ingored silently + + // TBI 20241127 finalize this function eventually. This is not urgent, though, as only a check below on cfTaskIsConfiguredFromJson covers most cases already. + + // Remark: Ordering below reflects the ordering in Configurables.h, not in DataMembers.h + // a) Task configuration; + // b) QA; + // c) Event histograms; + // d) Event cuts; + // e) Particle histograms; + // f) Particle cuts; + // g) Q-vectors; + // h) Multiparticle correlations; + // i) Test0; + // j) Particle weights; + // k) Centrality weights; + // l) Nested loops; + // m) Toy NUA; + // n) Internal validation; + // o) Results histograms. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // a) Task configuration: + if (!TString(cf_tc.cfTaskIsConfiguredFromJson).EqualTo("yes")) { + LOGF(fatal, "\033[1;31m%s at line %d : configurable cfTaskIsConfiguredFromJson = \"%s\", but it has to be set to \"yes\" in JSON => most likely some other configurable is misconfigured and all remaining settings in JSON are ignored silently\033[0m", __FUNCTION__, __LINE__, TString(cf_tc.cfTaskIsConfiguredFromJson).Data()); + } + + if (cf_tc.cfUseSpecificCuts) { + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! cfUseSpecificCuts = true, all settings in the current config are ignored !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); + } + + // b) QA: + // ... + + // c) Event histograms: + // ... // d) Event cuts: // ... @@ -1768,15 +2776,15 @@ void InsanityChecksOnDefinitionsOfConfigurables() ExitFunction(__FUNCTION__); } -} // InsanityChecksOnDefinitionsOfConfigurables() +} // insanityChecksOnDefinitionsOfConfigurables() //============================================================ -void InsanityChecksBeforeBooking() +void insanityChecksBeforeBooking() { - // Do insanity checks on configuration, binning and cuts. Values obtained from configurables are checked before being used in InsanityChecksOnDefinitionsOfConfigurables(). + // Do insanity checks on configuration, binning and cuts. Values obtained from configurables are checked before being used in insanityChecksOnDefinitionsOfConfigurables(). // Remember that here I cannot do insanity checks on local histograms, etc., because they are not booked yet. - // For those additional checks, use InsanityChecksAfterBooking(). + // For those additional checks, use insanityChecksAfterBooking(). // a) Insanity checks on configuration; // b) Ensure that Run 1/2 specific cuts and flags are used only in Run 1/2 (both data and sim); @@ -1805,7 +2813,7 @@ void InsanityChecksBeforeBooking() // **) If some differential "correlations" flag is set to true, but the main fCalculateCorrelations is false, only print the warning that that differential correlations won't be calculated. // This is not fatal, because this way I can turn off all differential "correlations" flags, just by setting fCalculateCorrelations to false, e.g. when I want to fill only control histograms. - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { + for (int v = 0; v < eAsFunctionOf_N; v++) { if (mupa.fCalculateCorrelationsAsFunctionOf[v] && !mupa.fCalculateCorrelations) { LOGF(warning, "\033[1;33m%s at line %d : mupa.fCalculateCorrelationsAsFunctionOf[%d] is true, but mupa.fCalculateCorrelations is false. This differential correlations won't be calculated.\033[0m", __FUNCTION__, __LINE__, v); } @@ -1818,15 +2826,20 @@ void InsanityChecksBeforeBooking() // **) If some differential Test0 flag is set to true, but the main fCalculateTest0 is false, only print the warning that that differential Test0 won't be calculated. // This is not fatal, because this way I can turn off all differential Test0 flags, just by setting fCalculateTest0 to false, e.g. when I want to fill only control histograms. - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { + for (int v = 0; v < eAsFunctionOf_N; v++) { if (t0.fCalculateTest0AsFunctionOf[v] && !t0.fCalculateTest0) { LOGF(warning, "\033[1;33m%s at line %d : t0.fCalculateTest0AsFunctionOf[%d] is true, but t0.fCalculateTest0 is false. This differential Test0 won't be calculated.\033[0m", __FUNCTION__, __LINE__, v); } } - // **) Enforce that if fixed number of randomly selected tracks is used in the analysis, that Fisher-Yates algorithm is enabled: + // **) Enforce that if the fixed number of randomly selected tracks is used in the analysis, that Fisher-Yates algorithm is enabled: if (tc.fFixedNumberOfRandomlySelectedTracks > 0 && !tc.fUseFisherYates) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m : Did you forget to enable Fisher-Yates algorithm?", __FUNCTION__, __LINE__); + } + + // **) Enforce that if the fixed number of randomly selected tracks is used that Toy NUA is disabled: + if (tc.fFixedNumberOfRandomlySelectedTracks > 0 && (nua.fApplyNUAPDF[ePhiNUAPDF] || nua.fApplyNUAPDF[ePtNUAPDF] || nua.fApplyNUAPDF[eEtaNUAPDF])) { + LOGF(fatal, "\033[1;31m%s at line %d : Not supported at the moment: use FixedNumberOfRandomlySelectedTracks + Toy NUA enabled.\nI cannot in an easy way ensure that ParticleCuts behave exactly the same in the Main and Banishment loops, because e.g. I call consequtively for same partcile gRandom->Uniform(...) in ParticleCuts, and that can't work.\033[0m", __FUNCTION__, __LINE__); } // **) When it comes to DCAxy cut, ensure that either flat or pt-dependent cut is used, but not both: @@ -1834,11 +2847,11 @@ void InsanityChecksBeforeBooking() LOGF(fatal, "\033[1;31m%s at line %d : use either flat or pt-dependent DCAxy cut, but not both \033[0m", __FUNCTION__, __LINE__); } - // **) Insanity check on individual flags: Make sure that only one process is set to kTRUE. - // If 2 or more are kTRUE, then corresponding process function is executed over ALL data, then another process(...) function, etc. + // **) Insanity check on individual flags: Make sure that only one process is set to true. + // If 2 or more are true, then corresponding process function is executed over ALL data, then another process(...) function, etc. // Re-think this if it's possible to run different process(...)'s concurently over the same data. if (static_cast(tc.fProcess[eProcessRec]) + static_cast(tc.fProcess[eProcessRecSim]) + static_cast(tc.fProcess[eProcessSim]) + static_cast(tc.fProcess[eProcessRec_Run2]) + static_cast(tc.fProcess[eProcessRecSim_Run2]) + static_cast(tc.fProcess[eProcessSim_Run2]) + static_cast(tc.fProcess[eProcessRec_Run1]) + static_cast(tc.fProcess[eProcessRecSim_Run1]) + static_cast(tc.fProcess[eProcessSim_Run1]) > 1) { - LOGF(info, "\033[1;31m Only one flag can be kTRUE: tc.fProcess[eProcessRec] = %d, tc.fProcess[eProcessRecSim] = %d, tc.fProcess[eProcessSim] = %d, tc.fProcess[eProcessRec_Run2] = %d, tc.fProcess[eProcessRecSim_Run2] = %d, tc.fProcess[eProcessSim_Run2] = %d, tc.fProcess[eProcessRec_Run1] = %d, tc.fProcess[eProcessRecSim_Run1] = %d, tc.fProcess[eProcessSim_Run1] = %d \033[0m", static_cast(tc.fProcess[eProcessRec]), static_cast(tc.fProcess[eProcessRecSim]), static_cast(tc.fProcess[eProcessSim]), static_cast(tc.fProcess[eProcessRec_Run2]), static_cast(tc.fProcess[eProcessRecSim_Run2]), static_cast(tc.fProcess[eProcessSim_Run2]), static_cast(tc.fProcess[eProcessRec_Run1]), static_cast(tc.fProcess[eProcessRecSim_Run1]), static_cast(tc.fProcess[eProcessSim_Run1])); + LOGF(info, "\033[1;31m Only one flag can be true: tc.fProcess[eProcessRec] = %d, tc.fProcess[eProcessRecSim] = %d, tc.fProcess[eProcessSim] = %d, tc.fProcess[eProcessRec_Run2] = %d, tc.fProcess[eProcessRecSim_Run2] = %d, tc.fProcess[eProcessSim_Run2] = %d, tc.fProcess[eProcessRec_Run1] = %d, tc.fProcess[eProcessRecSim_Run1] = %d, tc.fProcess[eProcessSim_Run1] = %d \033[0m", static_cast(tc.fProcess[eProcessRec]), static_cast(tc.fProcess[eProcessRecSim]), static_cast(tc.fProcess[eProcessSim]), static_cast(tc.fProcess[eProcessRec_Run2]), static_cast(tc.fProcess[eProcessRecSim_Run2]), static_cast(tc.fProcess[eProcessSim_Run2]), static_cast(tc.fProcess[eProcessRec_Run1]), static_cast(tc.fProcess[eProcessRecSim_Run1]), static_cast(tc.fProcess[eProcessSim_Run1])); LOGF(fatal, "in function \033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } @@ -1850,7 +2863,7 @@ void InsanityChecksBeforeBooking() // So if the upper limit is set to some number < 1e6, I want to bail out for that number of events. // TBI 20241011 this is a bit shaky, but nevermind now... if (!eh.fBookEventHistograms[eNumberOfEvents]) { - LOGF(fatal, "\033[1;31m%s at line %d : Bailout for max number of events cannot be done, unless eh.fBookEventHistograms[eNumberOfEvents] is kTRUE.\033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d : Bailout for max number of events cannot be done, unless eh.fBookEventHistograms[eNumberOfEvents] is true.\033[0m", __FUNCTION__, __LINE__); } } @@ -1884,16 +2897,20 @@ void InsanityChecksBeforeBooking() } // **) Enforce the usage of particular trigger for this dataset: - if (tc.fProcess[eProcessRec_Run2]) { - // TBI 20240517 for the time being, here I am enforcing that "kINT7" is mandatory for Run 2 - // TBI 20241209 I still have to validate it for Run 1 converted real data => then expand if(...) statemebt above - if (!(ec.fUseEventCuts[eTrigger] && ec.fsEventCuts[eTrigger].EqualTo("kINT7"))) { - LOGF(fatal, "\033[1;31m%s at line %d : trigger \"%s\" is not internally validated/supported yet. Add it to the list of supported triggers, if you really want to use that one.\033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eTrigger].Data()); - } else { - LOGF(info, "\033[1;32m%s at line %d : WARNING => trigger \"%s\" can be used only on real converted Run 2 and Run 1 data. For MC converted Run 2 and Run 1 data, this trigger shouldn't be used.\033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eTrigger].Data()); - // TBI 20240517 I need here programmatic access to "event-selection-task" flags "isMC and "isRunMC" . Then I can directly bail out. - } - } + // if (tc.fProcess[eProcessRec_Run2]) { + // TBI 20250115 Not really sure I need this - if I want to run only "Rec" over Monte Carlo, then obviously the condition below is pointless. + // Also here I need to be able automaticaly to determine whether I am processing real data or Monte Carlo, from the dataset itself. + // TBI 20240517 for the time being, here I am enforcing that "kINT7" is mandatory for Run 2 + // TBI 20241209 I still have to validate it for Run 1 converted real data => then expand if(...) statement above + + // commented out temporariy, see TBI 20250115 above + // if (!(ec.fUseEventCuts[eTrigger] && ec.fsEventCuts[eTrigger].EqualTo("kINT7"))) { + // LOGF(fatal, "\033[1;31m%s at line %d : trigger \"%s\" is not internally validated/supported yet. Add it to the list of supported triggers, if you really want to use that one.\033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eTrigger].Data()); + // } else { + // LOGF(info, "\033[1;32m%s at line %d : WARNING => trigger \"%s\" can be used only on real converted Run 2 and Run 1 data. For MC converted Run 2 and Run 1 data, this trigger shouldn't be used.\033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eTrigger].Data()); + // // TBI 20240517 I need here programmatic access to "event-selection-task" flags "isMC and "isRunMC" . Then I can directly bail out. + // } + // } // **) Ensure that fFloatingPointPrecision makes sense: if (!(tc.fFloatingPointPrecision > 0.)) { @@ -1905,6 +2922,26 @@ void InsanityChecksBeforeBooking() LOGF(fatal, "\033[1;31m%s at line %d : set fSequentialBailout = %d either to 0 (not used), or to positive integer.\033[0m", __FUNCTION__, __LINE__, tc.fSequentialBailout); } + // **) Ensure that I do not spill over with number of dimensions in sparse histograms: + if (eDiffPhiWeights_N > gMaxNumberSparseDimensions) { + LOGF(fatal, "\033[1;31m%s at line %d : set eDiffPhiWeights_N = %d is bigger than gMaxNumberSparseDimensions = %d\033[0m", __FUNCTION__, __LINE__, static_cast(eDiffPhiWeights_N), gMaxNumberSparseDimensions); + } + if (eDiffPtWeights_N > gMaxNumberSparseDimensions) { + LOGF(fatal, "\033[1;31m%s at line %d : set eDiffPtWeights_N = %d is bigger than gMaxNumberSparseDimensions = %d\033[0m", __FUNCTION__, __LINE__, static_cast(eDiffPtWeights_N), gMaxNumberSparseDimensions); + } + if (eDiffEtaWeights_N > gMaxNumberSparseDimensions) { + LOGF(fatal, "\033[1;31m%s at line %d : set eDiffEtaWeights_N = %d is bigger than gMaxNumberSparseDimensions = %d\033[0m", __FUNCTION__, __LINE__, static_cast(eDiffEtaWeights_N), gMaxNumberSparseDimensions); + } + + // ** For simulated data when fDatabasePDG is NOT used, I have to disable cut on charge, since that info is not available: + if ((tc.fProcess[eGenericRecSim] || tc.fProcess[eGenericSim]) && pc.fUseParticleCuts[eCharge] && !tc.fUseDatabasePDG) { + LOGF(fatal, "\033[1;31m%s at line %d : For simulated data when fDatabasePDG is NOT used, I have to disable cut on charge, since that info is not available.\033[0m", __FUNCTION__, __LINE__); + } + // ** Make sure I am using fDatabasePDG only over Monte Carlo data: + if (tc.fUseDatabasePDG && !(tc.fProcess[eGenericRecSim] || tc.fProcess[eGenericSim])) { + LOGF(fatal, "\033[1;31m%s at line %d : Use fDatabasePDG only over Monte Carlo datasets.\033[0m", __FUNCTION__, __LINE__); + } + // b) Ensure that Run 1/2 specific cuts and flags are used only in Run 1/2 (both data and sim): // **) Ensure that eSel7 is used only for converted Run 2 and Run 1 (both data and sim): if (ec.fUseEventCuts[eSel7]) { @@ -1916,7 +2953,7 @@ void InsanityChecksBeforeBooking() // **) Supported reference multiplicity estimators for Run 1 and 2 are enlisted here: if (tc.fProcess[eProcessRec_Run2] || tc.fProcess[eProcessRecSim_Run2] || tc.fProcess[eProcessRec_Run1] || tc.fProcess[eProcessRecSim_Run1]) { if (!(ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("MultTracklets", TString::kIgnoreCase))) { - LOGF(fatal, "\033[1;31m%s at line %d : reference multiplicity estimator = %s is not supported yet for Run 1 and 2 analysis.\nUse \"MultTracklets\"\033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eReferenceMultiplicityEstimator].Data()); + LOGF(fatal, "\033[1;31m%s at line %d : reference multiplicity estimator = %s is not supported for Run 1 and 2 analysis.\nUse \"MultTracklets\"\033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eReferenceMultiplicityEstimator].Data()); } } else if (tc.fProcess[eProcessSim_Run2] || tc.fProcess[eProcessSim_Run1]) { LOGF(fatal, "\033[1;31m%s at line %d : eProcessSim is not validated yet \033[0m", __FUNCTION__, __LINE__); @@ -1924,19 +2961,57 @@ void InsanityChecksBeforeBooking() // **) Supported centrality estimators for Run 1 and 2 are enlisted here: if (tc.fProcess[eProcessRec_Run2] || tc.fProcess[eProcessRecSim_Run2] || tc.fProcess[eProcessSim_Run2] || tc.fProcess[eProcessRec_Run1] || tc.fProcess[eProcessRecSim_Run1] || tc.fProcess[eProcessSim_Run1]) { - if (!(ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2V0M") || - ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2SPDTracklets"))) { - LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %s is not supported yet for converted Run 2 and Run 1 analysis.\nUse either \"centRun2V0M\" or \"centRun2SPDTracklets\" (case sensitive!) \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); + if (!(ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2V0M", TString::kIgnoreCase) || + ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2SPDTracklets", TString::kIgnoreCase))) { + LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %s is not supported for converted Run 2 and Run 1 analysis.\nUse either \"centRun2V0M\" or \"centRun2SPDTracklets\" (case sensitive!) \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); } } // **) Protection against particle cuts which are available, but not yet validated, or are meaningless, in Run 2 and 1: if (tc.fProcess[eProcessRec_Run2] || tc.fProcess[eProcessRecSim_Run2] || tc.fProcess[eProcessSim_Run2] || tc.fProcess[eProcessRec_Run1] || tc.fProcess[eProcessRecSim_Run1] || tc.fProcess[eProcessSim_Run1]) { + if (pc.fUseParticleCuts[etrackCutFlag]) { + LOGF(fatal, "\033[1;31m%s at line %d : particle cut etrackCutFlag is not validated, as of 20250113 it has no effect in Run 2 and Run 1 \033[0m", __FUNCTION__, __LINE__); + } if (pc.fUseParticleCuts[etrackCutFlagFb1]) { - LOGF(fatal, "\033[1;31m%s at line %d : particle cut etrackCutFlagFb1 is not validated, as of 20240511 it kills all reconstructed tracks \033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d : particle cut etrackCutFlagFb1 is not validated, as of 20250113 it kills all reconstructed tracks in Run 2 and Run 1 \033[0m", __FUNCTION__, __LINE__); } if (pc.fUseParticleCuts[etrackCutFlagFb2]) { - LOGF(fatal, "\033[1;31m%s at line %d : particle cut etrackCutFlagFb2 is not validated, as of 20240511 it kills all reconstructed tracks \033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d : particle cut etrackCutFlagFb2 is not validated, as of 20250113 it kills all reconstructed tracks in Run 2 and Run 1 \033[0m", __FUNCTION__, __LINE__); + } + } + + // **) Print a warning if kINT7 trigger is not used in reconstructed Run 2: + // TBI 20250318 shall I expand the check also to Run 1? In 2011 there were dedicated kCentral and kSemiCentral triggers only... + // TBI 20250318 shall I make it fatal instead? Without this trigger, a lot of histos are just meaningles (e.g. nContributores vs centrality, etc.) + if (tc.fProcess[eProcessRec_Run2]) { + if (!(ec.fUseEventCuts[eTrigger] && ec.fsEventCuts[eTrigger].EqualTo("kINT7"))) { + LOGF(warning, "\033[1;31m%s at line %d : kINT7 trigger in Run 2 is not selected - by default it should be used.\033[0m", __FUNCTION__, __LINE__); + } + } + + // **) Bail out if kINT7 trigger is used in Run 2 Monte Carlo: + // TBI 20250318 shall I expand the check also to Run 1? In 2011 there were dedicated kCentral and kSemiCentral triggers only... + if (tc.fProcess[eProcessRecSim_Run2] || tc.fProcess[eProcessSim_Run2]) { + if (ec.fUseEventCuts[eTrigger] && ec.fsEventCuts[eTrigger].EqualTo("kINT7")) { + LOGF(fatal, "\033[1;31m%s at line %d : kINT7 trigger in Run 2 Monte Carlo is not validated - use it at your own peril.\033[0m", __FUNCTION__, __LINE__); + } + } + + if (ec.fUseEventCuts[eNoPileupTPC]) { + if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim]) { + LOGF(fatal, "\033[1;31m%s at line %d : cannot use NoPileupTPC in Run 3\033[0m", __FUNCTION__, __LINE__); + } + } + + if (ec.fUseEventCuts[eNoPileupFromSPD]) { + if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim]) { + LOGF(fatal, "\033[1;31m%s at line %d : cannot use NoPileupFromSPD in Run 3\033[0m", __FUNCTION__, __LINE__); + } + } + + if (ec.fUseEventCuts[eNoSPDOnVsOfPileup]) { + if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim]) { + LOGF(fatal, "\033[1;31m%s at line %d : cannot use NoSPDOnVsOfPileup in Run 3\033[0m", __FUNCTION__, __LINE__); } } @@ -1945,91 +3020,97 @@ void InsanityChecksBeforeBooking() // c) Ensure that Run 3 specific cuts and flags are used only in Run 3 (both data and sim): // **) Ensure that eSel8 is used only in Run 3 (both data and sim): if (ec.fUseEventCuts[eSel8]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eSel8 only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eNoSameBunchPileup]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eNoSameBunchPileup only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eIsGoodZvtxFT0vsPV]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eIsGoodZvtxFT0vsPV only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eIsVertexITSTPC]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eIsVertexITSTPC only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eIsVertexTOFmatched]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eIsVertexTOFmatched only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eIsVertexTRDmatched]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eIsVertexTRDmatched only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eNoCollInTimeRangeStrict]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eNoCollInTimeRangeStrict only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eNoCollInTimeRangeStandard]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eNoCollInTimeRangeStandard only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eNoCollInRofStrict]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eNoCollInRofStrict only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eNoCollInRofStandard]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eNoCollInRofStandard only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eNoHighMultCollInPrevRof]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eNoHighMultCollInPrevRof only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eIsGoodITSLayer3]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eIsGoodITSLayer3 only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eIsGoodITSLayer0123]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eIsGoodITSLayer0123 only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } if (ec.fUseEventCuts[eIsGoodITSLayersAll]) { - if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { LOGF(fatal, "\033[1;31m%s at line %d : use eIsGoodITSLayersAll only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } } + if (ec.fUseEventCuts[eFT0Bad] || ec.fUseEventCuts[eITSBad] || ec.fUseEventCuts[eITSLimAccMCRepr] || ec.fUseEventCuts[eTPCBadTracking] || ec.fUseEventCuts[eTPCLimAccMCRepr] || ec.fUseEventCuts[eTPCBadPID]) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { + LOGF(fatal, "\033[1;31m%s at line %d : use eFT0Bad, eITSBad, eITSLimAccMCRepr, eTPCBadTracking, eTPCLimAccMCRepr, eTPCBadPID only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); + } + } + // **) Supported reference multiplicity estimators for Run 3 are enlisted here: - if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim]) { + if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessQA]) { if (!(ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("MultTPC", TString::kIgnoreCase) || ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("MultFV0M", TString::kIgnoreCase) || ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("MultFT0C", TString::kIgnoreCase) || @@ -2042,19 +3123,21 @@ void InsanityChecksBeforeBooking() } // **) Supported centrality estimators for Run 3 are enlisted here: - if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim]) { + if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessQA]) { if (!(ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0C", TString::kIgnoreCase) || + ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0CVariant1", TString::kIgnoreCase) || ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0M", TString::kIgnoreCase) || ec.fsEventCuts[eCentralityEstimator].EqualTo("centFV0A", TString::kIgnoreCase) || - ec.fsEventCuts[eCentralityEstimator].EqualTo("centNTPV", TString::kIgnoreCase))) { - LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %s is not supported yet for Run 3 analysis.\nUse \"centFT0C\", \"centFT0M\", \"centFV0A\", or \"centNTPV\"\033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); + ec.fsEventCuts[eCentralityEstimator].EqualTo("centNTPV", TString::kIgnoreCase) || + ec.fsEventCuts[eCentralityEstimator].EqualTo("centNGlobal", TString::kIgnoreCase))) { + LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %s is not supported yet for Run 3 analysis.\nUse \"centFT0C\", \"centFT0CVariant1\", \"centFT0M\", \"centFV0A\", \"centNTPV\", pr , \"centNGlobal\"\033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); } } else if (tc.fProcess[eProcessSim]) { LOGF(fatal, "\033[1;31m%s at line %d : eProcessSim is not validated yet \033[0m", __FUNCTION__, __LINE__); } // **) Supported occupancy estimators for Run 3 are enlisted here: - if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim]) { + if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessQA]) { if (!(ec.fsEventCuts[eOccupancyEstimator].EqualTo("TrackOccupancyInTimeRange", TString::kIgnoreCase) || ec.fsEventCuts[eOccupancyEstimator].EqualTo("FT0COccupancyInTimeRange", TString::kIgnoreCase))) { LOGF(fatal, "\033[1;31m%s at line %d : occupancy estimator = %s is not supported yet for Run 3 analysis. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eOccupancyEstimator].Data()); @@ -2062,15 +3145,43 @@ void InsanityChecksBeforeBooking() } // **) Protection against particle cuts which are available, but not yet validated, or are meaningless, in Run 3: - if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim]) { + if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA]) { + if (pc.fUseParticleCuts[etrackCutFlag]) { + LOGF(fatal, "\033[1;31m%s at line %d : particle cut trackCutFlag is not validated in Run 3 as of 20250113 => it has no effect\033[0m", __FUNCTION__, __LINE__); + } if (pc.fUseParticleCuts[eisQualityTrack]) { - LOGF(fatal, "\033[1;31m%s at line %d : particle cut isQualityTrack is not validated in Run 3 as of 20240516 => it kills all reconstructed tracks \033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d : particle cut isQualityTrack is not validated in Run 3 as of 20250113 => it kills all reconstructed tracks \033[0m", __FUNCTION__, __LINE__); } if (pc.fUseParticleCuts[eisGlobalTrack]) { - LOGF(fatal, "\033[1;31m%s at line %d : particle cut isGlobalTrack is not validated in Run 3 as of 20240516 => it kills all reconstructed tracks \033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d : particle cut isGlobalTrack cannot be used in Run 3 => it kills all reconstructed tracks.\n To select global track in Run 3, use etrackCutFlagFb1 or etrackCutFlagFb2, see documentation in enum\033[0m", __FUNCTION__, __LINE__); + } + } + + // **) Protection on particle cuts which can be used only in Run 3: + // trackCutFlag, trackCutFlagFb1, trackCutFlagFb2 => use only one at the time + if (static_cast(pc.fUseParticleCuts[etrackCutFlag]) + static_cast(pc.fUseParticleCuts[etrackCutFlagFb1]) + static_cast(pc.fUseParticleCuts[etrackCutFlagFb2]) >= 2) { + LOGF(fatal, "\033[1;31m%s at line %d : use only one of trackCutFlag, trackCutFlagFb1, trackCutFlagFb2 at time. \033[0m", __FUNCTION__, __LINE__); + } + + // isPVContributor: + if (pc.fUseParticleCuts[eisPVContributor]) { + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { + LOGF(fatal, "\033[1;31m%s at line %d : particle cut isPVContributor can be used only in Run 3\033[0m", __FUNCTION__, __LINE__); } } + // **) Protection for histograms which are meaningfull only in Run 3: + // ***) interaction rate is available only in Run 3: + if (!(tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim] || tc.fProcess[eProcessQA])) { + if (qa.fFillQACorrelationsVsInteractionRateVsProfiles2D) { + LOGF(fatal, "\033[1;31m%s at line %d : fFillQACorrelationsVsInteractionRateVsProfiles2D can be used only in Run 3, because only there ir is available.\033[0m", __FUNCTION__, __LINE__); + } + if (qa.fFillQAParticleEventHistograms2D) { + LOGF(fatal, "\033[1;31m%s at line %d : qa.fFillQAParticleEventHistograms2D can be used only in Run 3, because only there crd is available.\033[0m", __FUNCTION__, __LINE__); + } + // ... + } // if (! (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim])) { + // ... // d) Insanity checks on binning: @@ -2086,13 +3197,19 @@ void InsanityChecksBeforeBooking() // ... // g) Insanity checks on internal validation: - // Remark: I check here only in the settings I could define in DefaultConfiguration(). - // The other insanity checks are in BookInternalValidationHistograms() or in InsanityChecksAfterBooking() + // Remark: I check here only in the settings I could define in defaultConfiguration(). + // The other insanity checks are in bookInternalValidationHistograms() or in insanityChecksAfterBooking() if (iv.fUseInternalValidation) { if (iv.fnEventsInternalValidation <= 0) { LOGF(fatal, "\033[1;31m%s at line %d : iv.fnEventsInternalValidation <= 0 => Set number of events to positive integer\033[0m", __FUNCTION__, __LINE__); } + if (!(iv.fHarmonicsOptionInternalValidation->EqualTo("constant", TString::kIgnoreCase) || + iv.fHarmonicsOptionInternalValidation->EqualTo("correlated", TString::kIgnoreCase) || + iv.fHarmonicsOptionInternalValidation->EqualTo("persistent", TString::kIgnoreCase))) { + LOGF(fatal, "\033[1;31m%s at line %d : fHarmonicsOptionInternalValidation = %s is not supported. \033[0m", __FUNCTION__, __LINE__, iv.fHarmonicsOptionInternalValidation->Data()); + } + if (iv.fRescaleWithTheoreticalInput && (nl.fCalculateNestedLoops || nl.fCalculateCustomNestedLoops || nl.fCalculateKineCustomNestedLoops)) { LOGF(fatal, "\033[1;31m%s at line %d : rescaling with theoretical input is not supported when cross-check is done with nested loops. \033[0m", __FUNCTION__, __LINE__); } @@ -2105,7 +3222,7 @@ void InsanityChecksBeforeBooking() // h) Insanity checks on results histograms: // **) Check if all arrays are initialized until the end: - for (Int_t afo = 0; afo < eAsFunctionOf_N; afo++) { + for (int afo = 0; afo < eAsFunctionOf_N; afo++) { if (res.fResultsProXaxisTitle[afo].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsProXaxisTitle[%d] is empty.\033[0m", __FUNCTION__, __LINE__, afo); } @@ -2113,7 +3230,7 @@ void InsanityChecksBeforeBooking() if (res.fResultsProRawName[afo].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsProRawName[%d] is empty.\033[0m", __FUNCTION__, __LINE__, afo); } - } // for(Int_t afo = 0; afo < eAsFunctionOf_N; afo++) { + } // for(int afo = 0; afo < eAsFunctionOf_N; afo++) { // ... @@ -2121,14 +3238,14 @@ void InsanityChecksBeforeBooking() ExitFunction(__FUNCTION__); } -} // void InsanityChecksBeforeBooking() +} // void insanityChecksBeforeBooking() //============================================================ -void InsanityChecksAfterBooking() +void insanityChecksAfterBooking() { // Do insanity checks on all booked histograms, etc., - // Configuration, binning and cuts are checked already before booking in InsanityChecksBeforeBooking(). + // Configuration, binning and cuts are checked already before booking in insanityChecksBeforeBooking(). // a) Insanity checks on booking; // b) Insanity checks on internal validation; @@ -2141,26 +3258,25 @@ void InsanityChecksAfterBooking() // a) Insanity checks on booking: // **) Check that the last bin is not empty in fBasePro, and that there is no underflow or overflow bins: - if (TString(fBasePro->GetXaxis()->GetBinLabel(eConfiguration_N - 1)).EqualTo("")) { - LOGF(fatal, "\033[1;31m%s at line %d : The very last bin of \"fBasePro\" doesn't have the title, check the booking of this hostogram. \033[0m", __FUNCTION__, __LINE__); - } - if (TMath::Abs(fBasePro->GetBinContent(0)) > 0.) { + if (std::abs(fBasePro->GetBinContent(0)) > 0.) { LOGF(fatal, "\033[1;31m%s at line %d : In \"fBasePro\" something was filled in the underflow, check the booking of this hostogram. \033[0m", __FUNCTION__, __LINE__); } - if (TMath::Abs(fBasePro->GetBinContent(eConfiguration_N)) > 0.) { + if (std::abs(fBasePro->GetBinContent(eConfiguration_N)) > 0.) { LOGF(fatal, "\033[1;31m%s at line %d : In \"fBasePro\" something was filled in the overflow, check the booking of this hostogram. \033[0m", __FUNCTION__, __LINE__); } // ... // b) Insanity checks on internal validation: - if (iv.fUseInternalValidation) { // **) Check that rescaling is used only when it makes sense: if (iv.fRescaleWithTheoreticalInput && iv.fHarmonicsOptionInternalValidation->EqualTo("correlated")) { LOGF(fatal, "\033[1;31m%s at line %d : rescaling with theoretical input doesn't make sanse for fHarmonicsOptionInternalValidation = \"correlated\". \033[0m", __FUNCTION__, __LINE__); } + if (iv.fRescaleWithTheoreticalInput && iv.fHarmonicsOptionInternalValidation->EqualTo("persistent")) { + LOGF(fatal, "\033[1;31m%s at line %d : rescaling with theoretical input doesn't make sanse for fHarmonicsOptionInternalValidation = \"persistent\". \033[0m", __FUNCTION__, __LINE__); + } // **) Print a warning if this histogram is not booked: if (!eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]) { @@ -2175,11 +3291,51 @@ void InsanityChecksAfterBooking() ExitFunction(__FUNCTION__); } -} // void InsanityChecksAfterBooking() +} // void insanityChecksAfterBooking() + +//============================================================ + +void purgeAfterBooking() +{ + // I can purge a few objects used for common consistent booking across different group of histograms. + + // TBI 20250518 I now automatically purge only 2D and 3D objects, I can refine further an purge also the lighte objects, if necessary + + // a) Purge results histograms and related objects; + // ... + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + return; // TBI 20250625 the code below is not ready yet, because I still use these 2D and 3D histos in in FillqvectorNdim(...) + + // a) Purge results histograms and related objects: + if (!res.fSaveResultsHistograms) { + for (int v = 0; v < eAsFunctionOf2D_N; v++) { + if (res.fResultsPro2D[v]) { + delete res.fResultsPro2D[v]; + res.fResultsPro2D[v] = NULL; + } + } + + for (int v = 0; v < eAsFunctionOf3D_N; v++) { + if (res.fResultsPro3D[v]) { + delete res.fResultsPro3D[v]; + res.fResultsPro3D[v] = NULL; + } + } + } // if(!res.fSaveResultsHistograms) + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void purgeAfterBooking() //============================================================ -Bool_t Skip(Int_t recOrSim) +bool Skip(int recOrSim) { // Decide here whether a certain histogram, etc., will be booked and used both for eRec and eSim. // Same for cuts. @@ -2196,30 +3352,32 @@ Bool_t Skip(Int_t recOrSim) // *) If I am doing internal validation, I book and fill only eSim: if (iv.fUseInternalValidation) { if (recOrSim == eRec) { - return kTRUE; // yes, skip + return true; // yes, skip } else { - return kFALSE; // this is eSim, do not skip + return false; // this is eSim, do not skip } } // *) If I am analyzing only reconstructed data, do not book histos for simulated, and vice versa. // TBI 20240223 tc.fProcess[eProcessTest] is treated as tc.fProcess[eProcessRec], for the time being if ((tc.fProcess[eGenericRec] && recOrSim == eSim) || (tc.fProcess[eGenericSim] && recOrSim == eRec)) { - return kTRUE; // yes, skip + return true; // yes, skip } - return kFALSE; // by default, I do not skip anything + return false; // by default, I do not skip anything -} // Bool_t Skip(Int_t recOrSim) +} // bool Skip(int recOrSim) //============================================================ -void BookAndNestAllLists() +void bookAndNestAllLists() { // *) QA; // **) QA event histograms; // **) QA particle histograms; // **) QA particle event histograms; + // **) QA "correlations vs." histograms: + // **) QA "correlations vs. IR vs. " profiles; // *) Control event histograms; // *) Control particle histograms; // *) Correlations; @@ -2240,126 +3398,142 @@ void BookAndNestAllLists() // *) QA: qa.fQAList = new TList(); qa.fQAList->SetName("QA"); - qa.fQAList->SetOwner(kTRUE); + qa.fQAList->SetOwner(true); fBaseList->Add(qa.fQAList); - // **) QA event histograms; + // **) QA event histograms: if (qa.fFillQAEventHistograms2D) { qa.fQAEventList = new TList(); qa.fQAEventList->SetName("QAEvent"); - qa.fQAEventList->SetOwner(kTRUE); + qa.fQAEventList->SetOwner(true); qa.fQAList->Add(qa.fQAEventList); // yes, this one is nested within base QA TList } - // **) QA particle histograms; + // **) QA particle histograms: if (qa.fFillQAParticleHistograms2D) { qa.fQAParticleList = new TList(); qa.fQAParticleList->SetName("QAParticle"); - qa.fQAParticleList->SetOwner(kTRUE); + qa.fQAParticleList->SetOwner(true); qa.fQAList->Add(qa.fQAParticleList); // yes, this one is nested within base QA TList } - // **) QA particle event histograms; + // **) QA particle event histograms: if (qa.fFillQAParticleEventHistograms2D) { qa.fQAParticleEventList = new TList(); qa.fQAParticleEventList->SetName("QAParticleEvent"); - qa.fQAParticleEventList->SetOwner(kTRUE); + qa.fQAParticleEventList->SetOwner(true); qa.fQAList->Add(qa.fQAParticleEventList); // yes, this one is nested within base QA TList } + // **) QA "correlations vs." histograms: + if (qa.fFillQACorrelationsVsHistograms2D) { + qa.fQACorrelationsVsList = new TList(); + qa.fQACorrelationsVsList->SetName("QACorrelationsVs"); + qa.fQACorrelationsVsList->SetOwner(true); + qa.fQAList->Add(qa.fQACorrelationsVsList); // yes, this one is nested within base QA TList + } + + // **) QA "correlations vs. IR vs. " profiles: + if (qa.fFillQACorrelationsVsInteractionRateVsProfiles2D) { + qa.fQACorrelationsVsInteractionRateVsList = new TList(); + qa.fQACorrelationsVsInteractionRateVsList->SetName("QACorrelationsVsInteractionRateVsList"); + qa.fQACorrelationsVsInteractionRateVsList->SetOwner(true); + qa.fQAList->Add(qa.fQACorrelationsVsInteractionRateVsList); // yes, this one is nested within base QA TList + } + // *) Event cuts: ec.fEventCutsList = new TList(); ec.fEventCutsList->SetName("EventCuts"); - ec.fEventCutsList->SetOwner(kTRUE); + ec.fEventCutsList->SetOwner(true); fBaseList->Add(ec.fEventCutsList); // *) Control event histograms: eh.fEventHistogramsList = new TList(); eh.fEventHistogramsList->SetName("EventHistograms"); - eh.fEventHistogramsList->SetOwner(kTRUE); + eh.fEventHistogramsList->SetOwner(true); fBaseList->Add(eh.fEventHistogramsList); // *) Particle cuts: pc.fParticleCutsList = new TList(); pc.fParticleCutsList->SetName("ParticleCuts"); - pc.fParticleCutsList->SetOwner(kTRUE); + pc.fParticleCutsList->SetOwner(true); fBaseList->Add(pc.fParticleCutsList); // *) Control particle histograms: ph.fParticleHistogramsList = new TList(); ph.fParticleHistogramsList->SetName("ParticleHistograms"); - ph.fParticleHistogramsList->SetOwner(kTRUE); + ph.fParticleHistogramsList->SetOwner(true); fBaseList->Add(ph.fParticleHistogramsList); // *) Q-vectors: qv.fQvectorList = new TList(); qv.fQvectorList->SetName("Q-vectors"); - qv.fQvectorList->SetOwner(kTRUE); + qv.fQvectorList->SetOwner(true); fBaseList->Add(qv.fQvectorList); // *) Correlations: mupa.fCorrelationsList = new TList(); mupa.fCorrelationsList->SetName("Correlations"); - mupa.fCorrelationsList->SetOwner(kTRUE); + mupa.fCorrelationsList->SetOwner(true); fBaseList->Add(mupa.fCorrelationsList); // *) Particle weights: pw.fWeightsList = new TList(); pw.fWeightsList->SetName("Weights"); - pw.fWeightsList->SetOwner(kTRUE); + pw.fWeightsList->SetOwner(true); fBaseList->Add(pw.fWeightsList); // *) Centrality weights: cw.fCentralityWeightsList = new TList(); cw.fCentralityWeightsList->SetName("CentralityWeights"); - cw.fCentralityWeightsList->SetOwner(kTRUE); + cw.fCentralityWeightsList->SetOwner(true); fBaseList->Add(cw.fCentralityWeightsList); // *) Nested loops: nl.fNestedLoopsList = new TList(); nl.fNestedLoopsList->SetName("NestedLoops"); - nl.fNestedLoopsList->SetOwner(kTRUE); + nl.fNestedLoopsList->SetOwner(true); fBaseList->Add(nl.fNestedLoopsList); // *) Toy NUA: nua.fNUAList = new TList(); nua.fNUAList->SetName("ToyNUA"); - nua.fNUAList->SetOwner(kTRUE); + nua.fNUAList->SetOwner(true); fBaseList->Add(nua.fNUAList); // *) Internal validation: iv.fInternalValidationList = new TList(); iv.fInternalValidationList->SetName("InternalValidation"); - iv.fInternalValidationList->SetOwner(kTRUE); + iv.fInternalValidationList->SetOwner(true); fBaseList->Add(iv.fInternalValidationList); // *) Test0: t0.fTest0List = new TList(); t0.fTest0List->SetName("Test0"); - t0.fTest0List->SetOwner(kTRUE); + t0.fTest0List->SetOwner(true); fBaseList->Add(t0.fTest0List); // *) Eta separations: es.fEtaSeparationsList = new TList(); es.fEtaSeparationsList->SetName("EtaSeparations"); - es.fEtaSeparationsList->SetOwner(kTRUE); + es.fEtaSeparationsList->SetOwner(true); fBaseList->Add(es.fEtaSeparationsList); // *) Results: res.fResultsList = new TList(); res.fResultsList->SetName("Results"); - res.fResultsList->SetOwner(kTRUE); + res.fResultsList->SetOwner(true); fBaseList->Add(res.fResultsList); if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void BookAndNestAllLists() +} // void bookAndNestAllLists() -//============================================================ +//========================================================== -void BookQAHistograms() +void bookQAHistograms() { // Book all QA histograms and other related objects. @@ -2369,41 +3543,92 @@ void BookQAHistograms() // b) Common local variables; // c) Book specific QA 2D event histograms; // d) Book specific QA 2D particle histograms; - // e) Book specific QA 2D particle event histograms. + // e) Book specific QA 2D particle event histograms; + // f) Book specific QA 2D "correlations vs." histograms; + // g) Book specific QA 2D "correlations vs. IR vs. " profiles. if (tc.fVerbose) { StartFunction(__FUNCTION__); } // *) Print the warning message, because with too many 2D histograms with double precision, the code crashes in terminate, due to: - /* - [1450742:multiparticle-correlations-a-b]: [13:30:27][STATE] Exiting FairMQ state machine - [1450742:multiparticle-correlations-a-b]: [13:30:27][FATAL] error while setting up workflow in o2-analysis-cf-multiparticle-correlations-ab: shmem: could not create a message of size 1282720912, alignment: 64, free memory: 1358639296 - [1450742:multiparticle-correlations-a-b]: terminate called after throwing an instance of 'o2::framework::RuntimeErrorRef' - [1450742:multiparticle-correlations-a-b]: *** Program crashed (Aborted) - [1450742:multiparticle-correlations-a-b]: Backtrace by DPL: - */ + // + // [1450742:multiparticle-correlations-a-b]: [13:30:27][STATE] Exiting FairMQ state machine + // [1450742:multiparticle-correlations-a-b]: [13:30:27][FATAL] error while setting up workflow in o2-analysis-cf-multiparticle-correlations-ab: shmem: could not create a message of size 1282720912, alignment: 64, free memory: 1358639296 + // [1450742:multiparticle-correlations-a-b]: terminate called after throwing an instance of 'o2::framework::RuntimeErrorRef' + // [1450742:multiparticle-correlations-a-b]: *** Program crashed (Aborted) + // [1450742:multiparticle-correlations-a-b]: Backtrace by DPL: + // + if (tc.fVerbose) { LOGF(info, "\033[1;33m%s: !!!! WARNING !!!! With too many 2D histograms with double precision, the code will crash in terminate (\"... shmem: could not create a message of size ...\") . Locally, you can circumvent this while testing by calling Bailout() explicitly. !!!! WARNING !!!! \033[0m", __FUNCTION__); } // a) Book the profile holding flags: - qa.fQAHistogramsPro = new TProfile("fQAHistogramsPro", "flags for QA histograms", 5, 0., 5.); - qa.fQAHistogramsPro->SetStats(kFALSE); + qa.fQAHistogramsPro = new TProfile("fQAHistogramsPro", "flags for QA histograms", 7, 0., 7.); + qa.fQAHistogramsPro->SetStats(false); qa.fQAHistogramsPro->SetLineColor(eColor); qa.fQAHistogramsPro->SetFillColor(eFillColor); - qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(1, "fCheckUnderflowAndOverflow"); - qa.fQAHistogramsPro->Fill(0.5, static_cast(qa.fCheckUnderflowAndOverflow)); - qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(2, "fFillQAEventHistograms2D"); - qa.fQAHistogramsPro->Fill(1.5, static_cast(qa.fFillQAEventHistograms2D)); - qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(3, "fFillQAParticleHistograms2D"); - qa.fQAHistogramsPro->Fill(2.5, static_cast(qa.fFillQAParticleHistograms2D)); - qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(4, "fFillQAParticleEventHistograms2D"); - qa.fQAHistogramsPro->Fill(3.5, static_cast(qa.fFillQAParticleEventHistograms2D)); - qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(5, "fRebin"); - qa.fQAHistogramsPro->Fill(4.5, static_cast(qa.fRebin)); - // ... + if (tc.fUseSetBinLabel) { + qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(1, "fCheckUnderflowAndOverflow"); + qa.fQAHistogramsPro->Fill(0.5, static_cast(qa.fCheckUnderflowAndOverflow)); + qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(2, "fFillQAEventHistograms2D"); + qa.fQAHistogramsPro->Fill(1.5, static_cast(qa.fFillQAEventHistograms2D)); + qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(3, "fFillQAParticleHistograms2D"); + qa.fQAHistogramsPro->Fill(2.5, static_cast(qa.fFillQAParticleHistograms2D)); + qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(4, "fFillQAParticleEventHistograms2D"); + qa.fQAHistogramsPro->Fill(3.5, static_cast(qa.fFillQAParticleEventHistograms2D)); + qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(5, "fFillQACorrelationsVsHistograms2D"); + qa.fQAHistogramsPro->Fill(4.5, static_cast(qa.fFillQACorrelationsVsHistograms2D)); + qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(6, "fFillQACorrelationsVsInteractionRateVsProfiles2D"); + qa.fQAHistogramsPro->Fill(5.5, static_cast(qa.fFillQACorrelationsVsInteractionRateVsProfiles2D)); + qa.fQAHistogramsPro->GetXaxis()->SetBinLabel(7, "fRebin"); + qa.fQAHistogramsPro->Fill(6.5, static_cast(qa.fRebin)); + + // ... + + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fCheckUnderflowAndOverflow; ", 1); + qa.fQAHistogramsPro->Fill(0.5, static_cast(qa.fCheckUnderflowAndOverflow)); + + yAxisTitle += TString::Format("%d:fFillQAEventHistograms2D; ", 2); + qa.fQAHistogramsPro->Fill(1.5, static_cast(qa.fFillQAEventHistograms2D)); + + yAxisTitle += TString::Format("%d:fFillQAParticleHistograms2D; ", 3); + qa.fQAHistogramsPro->Fill(2.5, static_cast(qa.fFillQAParticleHistograms2D)); + + yAxisTitle += TString::Format("%d:fFillQAParticleEventHistograms2D; ", 4); + qa.fQAHistogramsPro->Fill(3.5, static_cast(qa.fFillQAParticleEventHistograms2D)); + + yAxisTitle += TString::Format("%d:fFillQACorrelationsVsHistograms2D; ", 5); + qa.fQAHistogramsPro->Fill(4.5, static_cast(qa.fFillQACorrelationsVsHistograms2D)); + + yAxisTitle += TString::Format("%d:fFillQACorrelationsVsInteractionRateVsProfiles2D; ", 6); + qa.fQAHistogramsPro->Fill(5.5, static_cast(qa.fFillQACorrelationsVsInteractionRateVsProfiles2D)); + + yAxisTitle += TString::Format("%d:fRebin; ", 7); + qa.fQAHistogramsPro->Fill(6.5, static_cast(qa.fRebin)); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != qa.fQAHistogramsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != qa.fQAHistogramsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), qa.fQAHistogramsPro->GetNbinsX()); + } + delete oa; + + // *) Okay, set the title: + qa.fQAHistogramsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else qa.fQAList->Add(qa.fQAHistogramsPro); @@ -2412,13 +3637,13 @@ void BookQAHistograms() // c) Book specific QA 2D event histograms: // Binning of 2D event histos: TBI 20240503 see if you can automate all this - Int_t nBins_x_Event[eQAEventHistograms2D_N] = {0}; - Double_t min_x_Event[eQAEventHistograms2D_N] = {0.}; - Double_t max_x_Event[eQAEventHistograms2D_N] = {0.}; + int nBins_x_Event[eQAEventHistograms2D_N] = {0}; + double min_x_Event[eQAEventHistograms2D_N] = {0.}; + double max_x_Event[eQAEventHistograms2D_N] = {0.}; TString title_x_Event[eQAEventHistograms2D_N] = {""}; - Int_t nBins_y_Event[eQAEventHistograms2D_N] = {0}; - Double_t min_y_Event[eQAEventHistograms2D_N] = {0.}; - Double_t max_y_Event[eQAEventHistograms2D_N] = {0.}; + int nBins_y_Event[eQAEventHistograms2D_N] = {0}; + double min_y_Event[eQAEventHistograms2D_N] = {0.}; + double max_y_Event[eQAEventHistograms2D_N] = {0.}; TString title_y_Event[eQAEventHistograms2D_N] = {""}; // *) "Multiplicity_vs_ReferenceMultiplicity": @@ -2451,15 +3676,15 @@ void BookQAHistograms() max_y_Event[eMultiplicity_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][2]; title_y_Event[eMultiplicity_vs_Centrality] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); - // *) "Multiplicity_vs_Vertex_z": - nBins_x_Event[eMultiplicity_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eMultiplicity][0] / qa.fRebin); - min_x_Event[eMultiplicity_vs_Vertex_z] = eh.fEventHistogramsBins[eMultiplicity][1]; - max_x_Event[eMultiplicity_vs_Vertex_z] = eh.fEventHistogramsBins[eMultiplicity][2]; - title_x_Event[eMultiplicity_vs_Vertex_z] = FancyFormatting(eh.fEventHistogramsName[eMultiplicity].Data()); - nBins_y_Event[eMultiplicity_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]); - min_y_Event[eMultiplicity_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][1]; - max_y_Event[eMultiplicity_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][2]; - title_y_Event[eMultiplicity_vs_Vertex_z] = FancyFormatting(eh.fEventHistogramsName[eVertex_z].Data()); + // *) "Multiplicity_vs_VertexZ": + nBins_x_Event[eMultiplicity_vs_VertexZ] = static_cast(eh.fEventHistogramsBins[eMultiplicity][0] / qa.fRebin); + min_x_Event[eMultiplicity_vs_VertexZ] = eh.fEventHistogramsBins[eMultiplicity][1]; + max_x_Event[eMultiplicity_vs_VertexZ] = eh.fEventHistogramsBins[eMultiplicity][2]; + title_x_Event[eMultiplicity_vs_VertexZ] = FancyFormatting(eh.fEventHistogramsName[eMultiplicity].Data()); + nBins_y_Event[eMultiplicity_vs_VertexZ] = static_cast(eh.fEventHistogramsBins[eVertexZ][0]); + min_y_Event[eMultiplicity_vs_VertexZ] = eh.fEventHistogramsBins[eVertexZ][1]; + max_y_Event[eMultiplicity_vs_VertexZ] = eh.fEventHistogramsBins[eVertexZ][2]; + title_y_Event[eMultiplicity_vs_VertexZ] = FancyFormatting(eh.fEventHistogramsName[eVertexZ].Data()); // *) "Multiplicity_vs_Occupancy": nBins_x_Event[eMultiplicity_vs_Occupancy] = static_cast(eh.fEventHistogramsBins[eMultiplicity][0] / qa.fRebin); @@ -2471,12 +3696,22 @@ void BookQAHistograms() max_y_Event[eMultiplicity_vs_Occupancy] = eh.fEventHistogramsBins[eOccupancy][2]; title_y_Event[eMultiplicity_vs_Occupancy] = FancyFormatting(eh.fEventHistogramsName[eOccupancy].Data()); - // *) "ReferenceMultiplicity_vs_NContributors": - nBins_x_Event[eReferenceMultiplicity_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eReferenceMultiplicity][0] / qa.fRebin); + // *) "Multiplicity_vs_InteractionRate": + nBins_x_Event[eMultiplicity_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eMultiplicity][0] / qa.fRebin); + min_x_Event[eMultiplicity_vs_InteractionRate] = eh.fEventHistogramsBins[eMultiplicity][1]; + max_x_Event[eMultiplicity_vs_InteractionRate] = eh.fEventHistogramsBins[eMultiplicity][2]; + title_x_Event[eMultiplicity_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eMultiplicity].Data()); + nBins_y_Event[eMultiplicity_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eInteractionRate][0] / qa.fRebin); + min_y_Event[eMultiplicity_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][1]; + max_y_Event[eMultiplicity_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][2]; + title_y_Event[eMultiplicity_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eInteractionRate].Data()); + + // *) "ReferenceMultiplicity_vs_NContributors": // TBI 20250401 I use this one to calculate quantiles for HMO cut, therefore I keep it refined for the time being + nBins_x_Event[eReferenceMultiplicity_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eReferenceMultiplicity][0]); min_x_Event[eReferenceMultiplicity_vs_NContributors] = eh.fEventHistogramsBins[eReferenceMultiplicity][1]; max_x_Event[eReferenceMultiplicity_vs_NContributors] = eh.fEventHistogramsBins[eReferenceMultiplicity][2]; title_x_Event[eReferenceMultiplicity_vs_NContributors] = FancyFormatting(eh.fEventHistogramsName[eReferenceMultiplicity].Data()); - nBins_y_Event[eReferenceMultiplicity_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eNContributors][0] / qa.fRebin); + nBins_y_Event[eReferenceMultiplicity_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eNContributors][0]); min_y_Event[eReferenceMultiplicity_vs_NContributors] = eh.fEventHistogramsBins[eNContributors][1]; max_y_Event[eReferenceMultiplicity_vs_NContributors] = eh.fEventHistogramsBins[eNContributors][2]; title_y_Event[eReferenceMultiplicity_vs_NContributors] = FancyFormatting(eh.fEventHistogramsName[eNContributors].Data()); @@ -2491,15 +3726,15 @@ void BookQAHistograms() max_y_Event[eReferenceMultiplicity_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][2]; title_y_Event[eReferenceMultiplicity_vs_Centrality] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); - // *) "ReferenceMultiplicity_vs_Vertex_z": - nBins_x_Event[eReferenceMultiplicity_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eReferenceMultiplicity][0] / qa.fRebin); - min_x_Event[eReferenceMultiplicity_vs_Vertex_z] = eh.fEventHistogramsBins[eReferenceMultiplicity][1]; - max_x_Event[eReferenceMultiplicity_vs_Vertex_z] = eh.fEventHistogramsBins[eReferenceMultiplicity][2]; - title_x_Event[eReferenceMultiplicity_vs_Vertex_z] = FancyFormatting(eh.fEventHistogramsName[eReferenceMultiplicity].Data()); - nBins_y_Event[eReferenceMultiplicity_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]); - min_y_Event[eReferenceMultiplicity_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][1]; - max_y_Event[eReferenceMultiplicity_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][2]; - title_y_Event[eReferenceMultiplicity_vs_Vertex_z] = FancyFormatting(eh.fEventHistogramsName[eVertex_z].Data()); + // *) "ReferenceMultiplicity_vs_VertexZ": + nBins_x_Event[eReferenceMultiplicity_vs_VertexZ] = static_cast(eh.fEventHistogramsBins[eReferenceMultiplicity][0] / qa.fRebin); + min_x_Event[eReferenceMultiplicity_vs_VertexZ] = eh.fEventHistogramsBins[eReferenceMultiplicity][1]; + max_x_Event[eReferenceMultiplicity_vs_VertexZ] = eh.fEventHistogramsBins[eReferenceMultiplicity][2]; + title_x_Event[eReferenceMultiplicity_vs_VertexZ] = FancyFormatting(eh.fEventHistogramsName[eReferenceMultiplicity].Data()); + nBins_y_Event[eReferenceMultiplicity_vs_VertexZ] = static_cast(eh.fEventHistogramsBins[eVertexZ][0]); + min_y_Event[eReferenceMultiplicity_vs_VertexZ] = eh.fEventHistogramsBins[eVertexZ][1]; + max_y_Event[eReferenceMultiplicity_vs_VertexZ] = eh.fEventHistogramsBins[eVertexZ][2]; + title_y_Event[eReferenceMultiplicity_vs_VertexZ] = FancyFormatting(eh.fEventHistogramsName[eVertexZ].Data()); // *) "ReferenceMultiplicity_vs_Occupancy": nBins_x_Event[eReferenceMultiplicity_vs_Occupancy] = static_cast(eh.fEventHistogramsBins[eReferenceMultiplicity][0] / qa.fRebin); @@ -2511,6 +3746,16 @@ void BookQAHistograms() max_y_Event[eReferenceMultiplicity_vs_Occupancy] = eh.fEventHistogramsBins[eOccupancy][2]; title_y_Event[eReferenceMultiplicity_vs_Occupancy] = FancyFormatting(eh.fEventHistogramsName[eOccupancy].Data()); + // *) "ReferenceMultiplicity_vs_InteractionRate": + nBins_x_Event[eReferenceMultiplicity_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eReferenceMultiplicity][0] / qa.fRebin); + min_x_Event[eReferenceMultiplicity_vs_InteractionRate] = eh.fEventHistogramsBins[eReferenceMultiplicity][1]; + max_x_Event[eReferenceMultiplicity_vs_InteractionRate] = eh.fEventHistogramsBins[eReferenceMultiplicity][2]; + title_x_Event[eReferenceMultiplicity_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eReferenceMultiplicity].Data()); + nBins_y_Event[eReferenceMultiplicity_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eInteractionRate][0] / qa.fRebin); + min_y_Event[eReferenceMultiplicity_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][1]; + max_y_Event[eReferenceMultiplicity_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][2]; + title_y_Event[eReferenceMultiplicity_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eInteractionRate].Data()); + // *) "NContributors_vs_Centrality": nBins_x_Event[eNContributors_vs_Centrality] = static_cast(eh.fEventHistogramsBins[eNContributors][0] / qa.fRebin); min_x_Event[eNContributors_vs_Centrality] = eh.fEventHistogramsBins[eNContributors][1]; @@ -2521,15 +3766,15 @@ void BookQAHistograms() max_y_Event[eNContributors_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][2]; title_y_Event[eNContributors_vs_Centrality] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); - // *) "NContributors_vs_Vertex_z": - nBins_x_Event[eNContributors_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eNContributors][0] / qa.fRebin); - min_x_Event[eNContributors_vs_Vertex_z] = eh.fEventHistogramsBins[eNContributors][1]; - max_x_Event[eNContributors_vs_Vertex_z] = eh.fEventHistogramsBins[eNContributors][2]; - title_x_Event[eNContributors_vs_Vertex_z] = FancyFormatting(eh.fEventHistogramsName[eNContributors].Data()); - nBins_y_Event[eNContributors_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]); - min_y_Event[eNContributors_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][1]; - max_y_Event[eNContributors_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][2]; - title_y_Event[eNContributors_vs_Vertex_z] = FancyFormatting(eh.fEventHistogramsName[eVertex_z].Data()); + // *) "NContributors_vs_VertexZ": + nBins_x_Event[eNContributors_vs_VertexZ] = static_cast(eh.fEventHistogramsBins[eNContributors][0] / qa.fRebin); + min_x_Event[eNContributors_vs_VertexZ] = eh.fEventHistogramsBins[eNContributors][1]; + max_x_Event[eNContributors_vs_VertexZ] = eh.fEventHistogramsBins[eNContributors][2]; + title_x_Event[eNContributors_vs_VertexZ] = FancyFormatting(eh.fEventHistogramsName[eNContributors].Data()); + nBins_y_Event[eNContributors_vs_VertexZ] = static_cast(eh.fEventHistogramsBins[eVertexZ][0]); + min_y_Event[eNContributors_vs_VertexZ] = eh.fEventHistogramsBins[eVertexZ][1]; + max_y_Event[eNContributors_vs_VertexZ] = eh.fEventHistogramsBins[eVertexZ][2]; + title_y_Event[eNContributors_vs_VertexZ] = FancyFormatting(eh.fEventHistogramsName[eVertexZ].Data()); // *) "NContributors_vs_Occupancy": nBins_x_Event[eNContributors_vs_Occupancy] = static_cast(eh.fEventHistogramsBins[eNContributors][0] / qa.fRebin); @@ -2541,15 +3786,25 @@ void BookQAHistograms() max_y_Event[eNContributors_vs_Occupancy] = eh.fEventHistogramsBins[eOccupancy][2]; title_y_Event[eNContributors_vs_Occupancy] = FancyFormatting(eh.fEventHistogramsName[eOccupancy].Data()); - // *) "Centrality_vs_Vertex_z": - nBins_x_Event[eCentrality_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); - min_x_Event[eCentrality_vs_Vertex_z] = eh.fEventHistogramsBins[eCentrality][1]; - max_x_Event[eCentrality_vs_Vertex_z] = eh.fEventHistogramsBins[eCentrality][2]; - title_x_Event[eCentrality_vs_Vertex_z] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); - nBins_y_Event[eCentrality_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]); - min_y_Event[eCentrality_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][1]; - max_y_Event[eCentrality_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][2]; - title_y_Event[eCentrality_vs_Vertex_z] = FancyFormatting(eh.fEventHistogramsName[eVertex_z].Data()); + // *) "NContributors_vs_InteractionRate": + nBins_x_Event[eNContributors_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eNContributors][0] / qa.fRebin); + min_x_Event[eNContributors_vs_InteractionRate] = eh.fEventHistogramsBins[eNContributors][1]; + max_x_Event[eNContributors_vs_InteractionRate] = eh.fEventHistogramsBins[eNContributors][2]; + title_x_Event[eNContributors_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eNContributors].Data()); + nBins_y_Event[eNContributors_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eInteractionRate][0] / qa.fRebin); + min_y_Event[eNContributors_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][1]; + max_y_Event[eNContributors_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][2]; + title_y_Event[eNContributors_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eInteractionRate].Data()); + + // *) "Centrality_vs_VertexZ": + nBins_x_Event[eCentrality_vs_VertexZ] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_x_Event[eCentrality_vs_VertexZ] = eh.fEventHistogramsBins[eCentrality][1]; + max_x_Event[eCentrality_vs_VertexZ] = eh.fEventHistogramsBins[eCentrality][2]; + title_x_Event[eCentrality_vs_VertexZ] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); + nBins_y_Event[eCentrality_vs_VertexZ] = static_cast(eh.fEventHistogramsBins[eVertexZ][0]); + min_y_Event[eCentrality_vs_VertexZ] = eh.fEventHistogramsBins[eVertexZ][1]; + max_y_Event[eCentrality_vs_VertexZ] = eh.fEventHistogramsBins[eVertexZ][2]; + title_y_Event[eCentrality_vs_VertexZ] = FancyFormatting(eh.fEventHistogramsName[eVertexZ].Data()); // *) "Centrality_vs_Occupancy": nBins_x_Event[eCentrality_vs_Occupancy] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); @@ -2571,17 +3826,68 @@ void BookQAHistograms() max_y_Event[eCentrality_vs_ImpactParameter] = eh.fEventHistogramsBins[eImpactParameter][2]; title_y_Event[eCentrality_vs_ImpactParameter] = FancyFormatting(eh.fEventHistogramsName[eImpactParameter].Data()); - // *) "Vertex_z_vs_Occupancy": - nBins_x_Event[eVertex_z_vs_Occupancy] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]); - min_x_Event[eVertex_z_vs_Occupancy] = eh.fEventHistogramsBins[eVertex_z][1]; - max_x_Event[eVertex_z_vs_Occupancy] = eh.fEventHistogramsBins[eVertex_z][2]; - title_x_Event[eVertex_z_vs_Occupancy] = FancyFormatting(eh.fEventHistogramsName[eVertex_z].Data()); - nBins_y_Event[eVertex_z_vs_Occupancy] = static_cast(eh.fEventHistogramsBins[eOccupancy][0] / qa.fRebin); - min_y_Event[eVertex_z_vs_Occupancy] = eh.fEventHistogramsBins[eOccupancy][1]; - max_y_Event[eVertex_z_vs_Occupancy] = eh.fEventHistogramsBins[eOccupancy][2]; - title_y_Event[eVertex_z_vs_Occupancy] = FancyFormatting(eh.fEventHistogramsName[eOccupancy].Data()); - - // *) "eMultNTracksPV_vs_MultNTracksGlobal": + // *) "Centrality_vs_InteractionRate": + nBins_x_Event[eCentrality_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_x_Event[eCentrality_vs_InteractionRate] = eh.fEventHistogramsBins[eCentrality][1]; + max_x_Event[eCentrality_vs_InteractionRate] = eh.fEventHistogramsBins[eCentrality][2]; + title_x_Event[eCentrality_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); + nBins_y_Event[eCentrality_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eInteractionRate][0] / qa.fRebin); + min_y_Event[eCentrality_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][1]; + max_y_Event[eCentrality_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][2]; + title_y_Event[eCentrality_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eInteractionRate].Data()); + + // *) "VertexZ_vs_Occupancy": + nBins_x_Event[eVertexZ_vs_Occupancy] = static_cast(eh.fEventHistogramsBins[eVertexZ][0]); + min_x_Event[eVertexZ_vs_Occupancy] = eh.fEventHistogramsBins[eVertexZ][1]; + max_x_Event[eVertexZ_vs_Occupancy] = eh.fEventHistogramsBins[eVertexZ][2]; + title_x_Event[eVertexZ_vs_Occupancy] = FancyFormatting(eh.fEventHistogramsName[eVertexZ].Data()); + nBins_y_Event[eVertexZ_vs_Occupancy] = static_cast(eh.fEventHistogramsBins[eOccupancy][0] / qa.fRebin); + min_y_Event[eVertexZ_vs_Occupancy] = eh.fEventHistogramsBins[eOccupancy][1]; + max_y_Event[eVertexZ_vs_Occupancy] = eh.fEventHistogramsBins[eOccupancy][2]; + title_y_Event[eVertexZ_vs_Occupancy] = FancyFormatting(eh.fEventHistogramsName[eOccupancy].Data()); + + // *) "VertexZ_vs_InteractionRate": + nBins_x_Event[eVertexZ_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eVertexZ][0]); + min_x_Event[eVertexZ_vs_InteractionRate] = eh.fEventHistogramsBins[eVertexZ][1]; + max_x_Event[eVertexZ_vs_InteractionRate] = eh.fEventHistogramsBins[eVertexZ][2]; + title_x_Event[eVertexZ_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eVertexZ].Data()); + nBins_y_Event[eVertexZ_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eInteractionRate][0] / qa.fRebin); + min_y_Event[eVertexZ_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][1]; + max_y_Event[eVertexZ_vs_InteractionRate] = eh.fEventHistogramsBins[eInteractionRate][2]; + title_y_Event[eVertexZ_vs_InteractionRate] = FancyFormatting(eh.fEventHistogramsName[eInteractionRate].Data()); + + // *) "Multiplicity_vs_FT0CAmplitudeOnFoundBC": + // nBins_x_Event[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = static_cast(eh.fEventHistogramsBins[eMultiplicity][0]); + nBins_x_Event[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = 2000.; // TBI 20250331 hardwired value + min_x_Event[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = eh.fEventHistogramsBins[eMultiplicity][1]; + max_x_Event[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = eh.fEventHistogramsBins[eMultiplicity][2]; + title_x_Event[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = FancyFormatting(eh.fEventHistogramsName[eMultiplicity].Data()); + nBins_y_Event[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = 1000; // TBI 20250331 hardwired value + min_y_Event[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = 0.; // TBI 20250331 hardwired value + max_y_Event[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = 100000.; // TBI 20250331 hardwired value + title_y_Event[eMultiplicity_vs_FT0CAmplitudeOnFoundBC] = "FT0CAmplitudeOnFoundBC"; // TBI 20250331 hardwired string + + // *) "CentFT0C_vs_FT0CAmplitudeOnFoundBC": + nBins_x_Event[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = eh.fEventHistogramsBins[eCentrality][0]; // yes, eCentrality, not eCentFT0C, just think of it ! + min_x_Event[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = eh.fEventHistogramsBins[eCentrality][1]; + max_x_Event[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = eh.fEventHistogramsBins[eCentrality][2]; + title_x_Event[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = FancyFormatting(qa.fCentralityEstimatorName[eCentFT0C].Data()); + nBins_y_Event[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = 1000; // TBI 20250331 hardwired value + min_y_Event[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = 0.; // TBI 20250331 hardwired value + max_y_Event[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = 100000.; // TBI 20250331 hardwired value + title_y_Event[eCentFT0C_vs_FT0CAmplitudeOnFoundBC] = "FT0CAmplitudeOnFoundBC"; // TBI 20250331 hardwired string + + // *) "Centrality_vs_CentralitySim": + nBins_x_Event[eCentrality_vs_CentralitySim] = eh.fEventHistogramsBins[eCentrality][0]; + min_x_Event[eCentrality_vs_CentralitySim] = eh.fEventHistogramsBins[eCentrality][1]; + max_x_Event[eCentrality_vs_CentralitySim] = eh.fEventHistogramsBins[eCentrality][2]; + title_x_Event[eCentrality_vs_CentralitySim] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); + nBins_y_Event[eCentrality_vs_CentralitySim] = eh.fEventHistogramsBins[eCentrality][0]; + min_y_Event[eCentrality_vs_CentralitySim] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_Event[eCentrality_vs_CentralitySim] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_Event[eCentrality_vs_CentralitySim] = "simulated centrality (calculated from IP)"; // TBI 20250331 hardwired string + + // *) "MultNTracksPV_vs_MultNTracksGlobal": nBins_x_Event[eMultNTracksPV_vs_MultNTracksGlobal] = static_cast(eh.fEventHistogramsBins[eMultiplicity][0] / qa.fRebin); min_x_Event[eMultNTracksPV_vs_MultNTracksGlobal] = eh.fEventHistogramsBins[eMultiplicity][1]; max_x_Event[eMultNTracksPV_vs_MultNTracksGlobal] = eh.fEventHistogramsBins[eMultiplicity][2]; @@ -2591,7 +3897,37 @@ void BookQAHistograms() max_y_Event[eMultNTracksPV_vs_MultNTracksGlobal] = eh.fEventHistogramsBins[eMultiplicity][2]; title_y_Event[eMultNTracksPV_vs_MultNTracksGlobal] = FancyFormatting(qa.fReferenceMultiplicityEstimatorName[eMultNTracksGlobal].Data()); - // *) "eCentFT0C_vs_CentNTPV": + // *) "CentFT0C_vs_CentFT0CVariant1": + nBins_x_Event[eCentFT0C_vs_CentFT0CVariant1] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_x_Event[eCentFT0C_vs_CentFT0CVariant1] = eh.fEventHistogramsBins[eCentrality][1]; + max_x_Event[eCentFT0C_vs_CentFT0CVariant1] = eh.fEventHistogramsBins[eCentrality][2]; + title_x_Event[eCentFT0C_vs_CentFT0CVariant1] = FancyFormatting(qa.fCentralityEstimatorName[eCentFT0C].Data()); + nBins_y_Event[eCentFT0C_vs_CentFT0CVariant1] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_y_Event[eCentFT0C_vs_CentFT0CVariant1] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_Event[eCentFT0C_vs_CentFT0CVariant1] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_Event[eCentFT0C_vs_CentFT0CVariant1] = FancyFormatting(qa.fCentralityEstimatorName[eCentFT0CVariant1].Data()); + + // *) "CentFT0C_vs_CentFT0M": + nBins_x_Event[eCentFT0C_vs_CentFT0M] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_x_Event[eCentFT0C_vs_CentFT0M] = eh.fEventHistogramsBins[eCentrality][1]; + max_x_Event[eCentFT0C_vs_CentFT0M] = eh.fEventHistogramsBins[eCentrality][2]; + title_x_Event[eCentFT0C_vs_CentFT0M] = FancyFormatting(qa.fCentralityEstimatorName[eCentFT0C].Data()); + nBins_y_Event[eCentFT0C_vs_CentFT0M] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_y_Event[eCentFT0C_vs_CentFT0M] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_Event[eCentFT0C_vs_CentFT0M] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_Event[eCentFT0C_vs_CentFT0M] = FancyFormatting(qa.fCentralityEstimatorName[eCentFT0M].Data()); + + // *) "CentFT0C_vs_CentFV0A": + nBins_x_Event[eCentFT0C_vs_CentFV0A] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_x_Event[eCentFT0C_vs_CentFV0A] = eh.fEventHistogramsBins[eCentrality][1]; + max_x_Event[eCentFT0C_vs_CentFV0A] = eh.fEventHistogramsBins[eCentrality][2]; + title_x_Event[eCentFT0C_vs_CentFV0A] = FancyFormatting(qa.fCentralityEstimatorName[eCentFT0C].Data()); + nBins_y_Event[eCentFT0C_vs_CentFV0A] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_y_Event[eCentFT0C_vs_CentFV0A] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_Event[eCentFT0C_vs_CentFV0A] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_Event[eCentFT0C_vs_CentFV0A] = FancyFormatting(qa.fCentralityEstimatorName[eCentFV0A].Data()); + + // *) "CentFT0C_vs_CentNTPV": nBins_x_Event[eCentFT0C_vs_CentNTPV] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); min_x_Event[eCentFT0C_vs_CentNTPV] = eh.fEventHistogramsBins[eCentrality][1]; max_x_Event[eCentFT0C_vs_CentNTPV] = eh.fEventHistogramsBins[eCentrality][2]; @@ -2601,7 +3937,17 @@ void BookQAHistograms() max_y_Event[eCentFT0C_vs_CentNTPV] = eh.fEventHistogramsBins[eCentrality][2]; title_y_Event[eCentFT0C_vs_CentNTPV] = FancyFormatting(qa.fCentralityEstimatorName[eCentNTPV].Data()); - // *) "eCentFT0M_vs_CentNTPV": + // *) "CentFT0C_vs_CentNGlobal": + nBins_x_Event[eCentFT0C_vs_CentNGlobal] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_x_Event[eCentFT0C_vs_CentNGlobal] = eh.fEventHistogramsBins[eCentrality][1]; + max_x_Event[eCentFT0C_vs_CentNGlobal] = eh.fEventHistogramsBins[eCentrality][2]; + title_x_Event[eCentFT0C_vs_CentNGlobal] = FancyFormatting(qa.fCentralityEstimatorName[eCentFT0C].Data()); + nBins_y_Event[eCentFT0C_vs_CentNGlobal] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_y_Event[eCentFT0C_vs_CentNGlobal] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_Event[eCentFT0C_vs_CentNGlobal] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_Event[eCentFT0C_vs_CentNGlobal] = FancyFormatting(qa.fCentralityEstimatorName[eCentNGlobal].Data()); + + // *) "CentFT0M_vs_CentNTPV": nBins_x_Event[eCentFT0M_vs_CentNTPV] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); min_x_Event[eCentFT0M_vs_CentNTPV] = eh.fEventHistogramsBins[eCentrality][1]; max_x_Event[eCentFT0M_vs_CentNTPV] = eh.fEventHistogramsBins[eCentrality][2]; @@ -2611,7 +3957,7 @@ void BookQAHistograms() max_y_Event[eCentFT0M_vs_CentNTPV] = eh.fEventHistogramsBins[eCentrality][2]; title_y_Event[eCentFT0M_vs_CentNTPV] = FancyFormatting(qa.fCentralityEstimatorName[eCentNTPV].Data()); - // *) "eCentRun2V0M_vs_CentRun2SPDTracklets": + // *) "CentRun2V0M_vs_CentRun2SPDTracklets": nBins_x_Event[eCentRun2V0M_vs_CentRun2SPDTracklets] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); min_x_Event[eCentRun2V0M_vs_CentRun2SPDTracklets] = eh.fEventHistogramsBins[eCentrality][1]; max_x_Event[eCentRun2V0M_vs_CentRun2SPDTracklets] = eh.fEventHistogramsBins[eCentrality][2]; @@ -2621,7 +3967,7 @@ void BookQAHistograms() max_y_Event[eCentRun2V0M_vs_CentRun2SPDTracklets] = eh.fEventHistogramsBins[eCentrality][2]; title_y_Event[eCentRun2V0M_vs_CentRun2SPDTracklets] = FancyFormatting(qa.fCentralityEstimatorName[eCentRun2SPDTracklets].Data()); - // *) "eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange": + // *) "TrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange": nBins_x_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = static_cast(eh.fEventHistogramsBins[eOccupancy][0] / qa.fRebin); min_x_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = eh.fEventHistogramsBins[eOccupancy][1]; max_x_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = eh.fEventHistogramsBins[eOccupancy][2]; @@ -2631,7 +3977,7 @@ void BookQAHistograms() max_y_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = eh.fEventHistogramsBins[eOccupancy][2]; title_y_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = FancyFormatting(qa.fOccupancyEstimatorName[eFT0COccupancyInTimeRange].Data()); - // *) "eCurrentRunDuration_vs_InteractionRate": + // *) "CurrentRunDuration_vs_InteractionRate": nBins_x_Event[eCurrentRunDuration_vs_InteractionRate] = static_cast(eh.fEventHistogramsBins[eCurrentRunDuration][0] / qa.fRebin); min_x_Event[eCurrentRunDuration_vs_InteractionRate] = eh.fEventHistogramsBins[eCurrentRunDuration][1]; max_x_Event[eCurrentRunDuration_vs_InteractionRate] = eh.fEventHistogramsBins[eCurrentRunDuration][2]; @@ -2644,7 +3990,7 @@ void BookQAHistograms() // ... // *) Quick insanity check on title_x_Event and title_y_Event: - for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) { + for (int t = 0; t < eQAEventHistograms2D_N; t++) { // **) title_x_Event: if (tc.fVerbose) { @@ -2662,22 +4008,22 @@ void BookQAHistograms() LOGF(fatal, "\033[1;31m%s at line %d : title_y_Event[%d] is not set, check corresponding enum \033[0m", __FUNCTION__, __LINE__, t); } - } // for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) { + } // for (int t = 0; t < eQAEventHistograms2D_N; t++) { // Okay, let's book 'em all: - for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eQAEventHistograms2D + for (int t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eQAEventHistograms2D { if (!qa.fBookQAEventHistograms2D[t]) { continue; } - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { if (Skip(rs)) { continue; } - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { // Special treatment for eMultiplicity => I will never fill this one before the cuts, if Multiplicity = SelectedTracks, obviously: @@ -2690,9 +4036,10 @@ void BookQAHistograms() continue; } + // valgrind --tool=massif => ~9.8 MiB (Last check: 20250315) qa.fQAEventHistograms2D[t][rs][ba] = new TH2F( - Form("fQAEventHistograms2D[%s][%s][%s]", qa.fEventHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), - Form("%s, %s, %s", "__RUN_NUMBER__", gc.srs_long[rs].Data(), gc.sba_long[ba].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) + TString::Format("fQAEventHistograms2D[%s][%s][%s]", qa.fEventHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), + TString::Format("%s, %s, %s", "__RUN_NUMBER__", gc.srsLong[rs].Data(), gc.sbaLong[ba].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) nBins_x_Event[t], min_x_Event[t], max_x_Event[t], nBins_y_Event[t], min_y_Event[t], max_y_Event[t]); qa.fQAEventHistograms2D[t][rs][ba]->GetXaxis()->SetTitle(title_x_Event[t].Data()); qa.fQAEventHistograms2D[t][rs][ba]->GetYaxis()->SetTitle(title_y_Event[t].Data()); @@ -2700,21 +4047,21 @@ void BookQAHistograms() qa.fQAEventHistograms2D[t][rs][ba]->SetFillColor(ec.fBeforeAfterColor[ba] - 10); qa.fQAEventHistograms2D[t][rs][ba]->SetOption("col"); qa.fQAEventList->Add(qa.fQAEventHistograms2D[t][rs][ba]); - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for(Int_t t=0;t ~30.6 MiB (Last check: 20250315) qa.fQAParticleHistograms2D[t][rs][ba] = new TH2F( - Form("fQAParticleHistograms2D[%s][%s][%s]", qa.fParticleHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), - Form("%s, %s, %s", "__RUN_NUMBER__", gc.srs_long[rs].Data(), gc.sba_long[ba].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) + TString::Format("fQAParticleHistograms2D[%s][%s][%s]", qa.fParticleHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), + TString::Format("%s, %s, %s", "__RUN_NUMBER__", gc.srsLong[rs].Data(), gc.sbaLong[ba].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) nBins_x_Particle[t], min_x_Particle[t], max_x_Particle[t], nBins_y_Particle[t], min_y_Particle[t], max_y_Particle[t]); qa.fQAParticleHistograms2D[t][rs][ba]->GetXaxis()->SetTitle(title_x_Particle[t].Data()); @@ -2765,20 +4113,20 @@ void BookQAHistograms() qa.fQAParticleHistograms2D[t][rs][ba]->SetFillColor(ec.fBeforeAfterColor[ba] - 10); qa.fQAParticleHistograms2D[t][rs][ba]->SetOption("col"); qa.fQAParticleList->Add(qa.fQAParticleHistograms2D[t][rs][ba]); - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for(Int_t t=0;t ~70.2 MiB (Last check: 20250315) qa.fQAParticleEventHistograms2D[t][rs][ba] = new TH2F( - Form("fQAParticleEventHistograms2D[%s][%s][%s]", qa.fQAParticleEventHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), - Form("%s, %s, %s", "__RUN_NUMBER__", gc.srs_long[rs].Data(), gc.sba_long[ba].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) + TString::Format("fQAParticleEventHistograms2D[%s][%s][%s]", qa.fQAParticleEventHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), + TString::Format("%s, %s, %s", "__RUN_NUMBER__", gc.srsLong[rs].Data(), gc.sbaLong[ba].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) nBins_x_ParticleEvent[t], min_x_ParticleEvent[t], max_x_ParticleEvent[t], nBins_y_ParticleEvent[t], min_y_ParticleEvent[t], max_y_ParticleEvent[t]); qa.fQAParticleEventHistograms2D[t][rs][ba]->GetXaxis()->SetTitle(title_x_ParticleEvent[t].Data()); @@ -2925,19 +4274,19 @@ void BookQAHistograms() qa.fQAParticleEventHistograms2D[t][rs][ba]->SetFillColor(ec.fBeforeAfterColor[ba] - 10); qa.fQAParticleEventHistograms2D[t][rs][ba]->SetOption("col"); qa.fQAParticleEventList->Add(qa.fQAParticleEventHistograms2D[t][rs][ba]); - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for(Int_t t=0;tGetXaxis()->SetBinLabel(eitsNClsEbyE, "#LTitsNCls#GT"); // TBI 20241214 this bin labeling is not really needed, as I never save this TProfile persistently - qa.fQAParticleEventProEbyE[rs][ba]->GetXaxis()->SetBinLabel(eitsNClsNegEtaEbyE, "#LTitsNClsNegEta#GT"); - qa.fQAParticleEventProEbyE[rs][ba]->GetXaxis()->SetBinLabel(eitsNClsPosEtaEbyE, "#LTitsNClsPosEta#GT"); - qa.fQAParticleEventProEbyE[rs][ba]->GetXaxis()->SetBinLabel(eEta0804EbyE, "#LTEta0804EbyE#GT"); - qa.fQAParticleEventProEbyE[rs][ba]->GetXaxis()->SetBinLabel(eEta0400EbyE, "#LTEta0400EbyE#GT"); - qa.fQAParticleEventProEbyE[rs][ba]->GetXaxis()->SetBinLabel(eEta0004EbyE, "#LTEta0004EbyE#GT"); - qa.fQAParticleEventProEbyE[rs][ba]->GetXaxis()->SetBinLabel(eEta0408EbyE, "#LTEta0408EbyE#GT"); - qa.fQAParticleEventProEbyE[rs][ba]->GetXaxis()->SetBinLabel(ePt0005EbyE, "#LTPt0005EbyE#GT"); - qa.fQAParticleEventProEbyE[rs][ba]->GetXaxis()->SetBinLabel(ePt0510EbyE, "#LTPt0510EbyE#GT"); - qa.fQAParticleEventProEbyE[rs][ba]->GetXaxis()->SetBinLabel(ePt1050EbyE, "#LTPt1050EbyE#GT"); + } // for (int ba = 0; ba < 2; ba++) // before/after cuts + } // for (int rs = 0; rs < 2; rs++) // reco/sim + + // f) Book specific QA 2D "correlations vs." histograms: + + // Binning of 2D "correlations vs." histos: + // Remark: I use the same binning for x axis for all 2D QA histos in this category, therefore here implementation in shorter. + int nBins_x_CorrelationsVs = 2000; + double min_x_CorrelationsVs = -1.; + double max_x_CorrelationsVs = 1.; + TString title_x_CorrelationsVs = "#LT2#GT"; // harmonic I store elsewhere TBI-today document here where + int nBins_y_CorrelationsVs[eQACorrelationsVsHistograms2D_N] = {0}; + double min_y_CorrelationsVs[eQACorrelationsVsHistograms2D_N] = {0.}; + double max_y_CorrelationsVs[eQACorrelationsVsHistograms2D_N] = {0.}; + TString title_y_CorrelationsVs[eQACorrelationsVsHistograms2D_N] = {""}; + + // *) "eCorrelations_vs_Multiplicity": + nBins_y_CorrelationsVs[eCorrelations_vs_Multiplicity] = static_cast(eh.fEventHistogramsBins[eMultiplicity][0] / 10); // TBI 20250331 here I have temporarily hardwired rebin value + min_y_CorrelationsVs[eCorrelations_vs_Multiplicity] = eh.fEventHistogramsBins[eMultiplicity][1]; + max_y_CorrelationsVs[eCorrelations_vs_Multiplicity] = eh.fEventHistogramsBins[eMultiplicity][2]; + title_y_CorrelationsVs[eCorrelations_vs_Multiplicity] = FancyFormatting(eh.fEventHistogramsName[eMultiplicity].Data()); + + // *) "eCorrelations_vs_ReferenceMultiplicity": + nBins_y_CorrelationsVs[eCorrelations_vs_ReferenceMultiplicity] = static_cast(eh.fEventHistogramsBins[eReferenceMultiplicity][0] / 10); // TBI 20250331 here I have temporarily hardwired rebin value + min_y_CorrelationsVs[eCorrelations_vs_ReferenceMultiplicity] = eh.fEventHistogramsBins[eReferenceMultiplicity][1]; + max_y_CorrelationsVs[eCorrelations_vs_ReferenceMultiplicity] = eh.fEventHistogramsBins[eReferenceMultiplicity][2]; + title_y_CorrelationsVs[eCorrelations_vs_ReferenceMultiplicity] = FancyFormatting(eh.fEventHistogramsName[eReferenceMultiplicity].Data()); + + // *) "eCorrelations_vs_Centrality": + nBins_y_CorrelationsVs[eCorrelations_vs_Centrality] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_y_CorrelationsVs[eCorrelations_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_CorrelationsVs[eCorrelations_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_CorrelationsVs[eCorrelations_vs_Centrality] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); + + // ..... + + // *) "eCorrelations_vs_MeanPhi": + nBins_y_CorrelationsVs[eCorrelations_vs_MeanPhi] = 200; + min_y_CorrelationsVs[eCorrelations_vs_MeanPhi] = 2.; + max_y_CorrelationsVs[eCorrelations_vs_MeanPhi] = 4.; + title_y_CorrelationsVs[eCorrelations_vs_MeanPhi] = FancyFormatting(ph.fParticleHistogramsName[ePhi].Data()); + + // *) "eCorrelations_vs_MeanPt": + nBins_y_CorrelationsVs[eCorrelations_vs_MeanPt] = 100; + min_y_CorrelationsVs[eCorrelations_vs_MeanPt] = 0.0; + max_y_CorrelationsVs[eCorrelations_vs_MeanPt] = 2.0; + title_y_CorrelationsVs[eCorrelations_vs_MeanPt] = FancyFormatting(ph.fParticleHistogramsName[ePt].Data()); + + // *) "eCorrelations_vs_MeanEta": + nBins_y_CorrelationsVs[eCorrelations_vs_MeanEta] = 200; + min_y_CorrelationsVs[eCorrelations_vs_MeanEta] = -0.3; + max_y_CorrelationsVs[eCorrelations_vs_MeanEta] = 0.3; + title_y_CorrelationsVs[eCorrelations_vs_MeanEta] = FancyFormatting(ph.fParticleHistogramsName[eEta].Data()); + + // *) "eCorrelations_vs_MeanCharge": + nBins_y_CorrelationsVs[eCorrelations_vs_MeanCharge] = 200; + min_y_CorrelationsVs[eCorrelations_vs_MeanCharge] = -1.; + max_y_CorrelationsVs[eCorrelations_vs_MeanCharge] = 1.; + title_y_CorrelationsVs[eCorrelations_vs_MeanCharge] = FancyFormatting(ph.fParticleHistogramsName[eCharge].Data()); + + // *) "eCorrelations_vs_MeantpcNClsFindable": + nBins_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsFindable] = 400; + min_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsFindable] = 50.; + max_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsFindable] = 250.; + title_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsFindable] = FancyFormatting(ph.fParticleHistogramsName[etpcNClsFindable].Data()); + + // *) "eCorrelations_vs_MeantpcNClsShared": + nBins_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsShared] = 500; + min_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsShared] = 0.; + max_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsShared] = 100.; + title_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsShared] = FancyFormatting(ph.fParticleHistogramsName[etpcNClsShared].Data()); + + // *) "eCorrelations_vs_MeanitsChi2NCl": + nBins_y_CorrelationsVs[eCorrelations_vs_MeanitsChi2NCl] = 200; + min_y_CorrelationsVs[eCorrelations_vs_MeanitsChi2NCl] = 0.; + max_y_CorrelationsVs[eCorrelations_vs_MeanitsChi2NCl] = 4.; + title_y_CorrelationsVs[eCorrelations_vs_MeanitsChi2NCl] = FancyFormatting(ph.fParticleHistogramsName[eitsChi2NCl].Data()); + + // *) "eCorrelations_vs_MeantpcNClsFound": + nBins_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsFound] = 400; + min_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsFound] = 50.; + max_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsFound] = 250.; + title_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsFound] = FancyFormatting(ph.fParticleHistogramsName[etpcNClsFound].Data()); + + // *) "eCorrelations_vs_MeantpcNClsCrossedRows": + nBins_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsCrossedRows] = 400; + min_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsCrossedRows] = 50.; + max_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsCrossedRows] = 250.; + title_y_CorrelationsVs[eCorrelations_vs_MeantpcNClsCrossedRows] = FancyFormatting(ph.fParticleHistogramsName[etpcNClsCrossedRows].Data()); + + // *) "eCorrelations_vs_MeanitsNCls": + nBins_y_CorrelationsVs[eCorrelations_vs_MeanitsNCls] = 500; + min_y_CorrelationsVs[eCorrelations_vs_MeanitsNCls] = 0.; + max_y_CorrelationsVs[eCorrelations_vs_MeanitsNCls] = 10.; + title_y_CorrelationsVs[eCorrelations_vs_MeanitsNCls] = FancyFormatting(ph.fParticleHistogramsName[eitsNCls].Data()); + + // *) "eCorrelations_vs_MeanitsNClsInnerBarrel": + nBins_y_CorrelationsVs[eCorrelations_vs_MeanitsNClsInnerBarrel] = 400; + min_y_CorrelationsVs[eCorrelations_vs_MeanitsNClsInnerBarrel] = 0.; + max_y_CorrelationsVs[eCorrelations_vs_MeanitsNClsInnerBarrel] = 4.; + title_y_CorrelationsVs[eCorrelations_vs_MeanitsNClsInnerBarrel] = FancyFormatting(ph.fParticleHistogramsName[eitsNClsInnerBarrel].Data()); + + // *) "eCorrelations_vs_MeantpcCrossedRowsOverFindableCls": + nBins_y_CorrelationsVs[eCorrelations_vs_MeantpcCrossedRowsOverFindableCls] = 200; + min_y_CorrelationsVs[eCorrelations_vs_MeantpcCrossedRowsOverFindableCls] = 0.; + max_y_CorrelationsVs[eCorrelations_vs_MeantpcCrossedRowsOverFindableCls] = 2.; + title_y_CorrelationsVs[eCorrelations_vs_MeantpcCrossedRowsOverFindableCls] = FancyFormatting(ph.fParticleHistogramsName[etpcCrossedRowsOverFindableCls].Data()); + + // *) "eCorrelations_vs_MeantpcFoundOverFindableCls": + nBins_y_CorrelationsVs[eCorrelations_vs_MeantpcFoundOverFindableCls] = 200; + min_y_CorrelationsVs[eCorrelations_vs_MeantpcFoundOverFindableCls] = 0.8; + max_y_CorrelationsVs[eCorrelations_vs_MeantpcFoundOverFindableCls] = 1.2; + title_y_CorrelationsVs[eCorrelations_vs_MeantpcFoundOverFindableCls] = FancyFormatting(ph.fParticleHistogramsName[etpcFoundOverFindableCls].Data()); + + // *) "eCorrelations_vs_MeantpcFractionSharedCls": + nBins_y_CorrelationsVs[eCorrelations_vs_MeantpcFractionSharedCls] = 500; + min_y_CorrelationsVs[eCorrelations_vs_MeantpcFractionSharedCls] = 0.; + max_y_CorrelationsVs[eCorrelations_vs_MeantpcFractionSharedCls] = 1.; + title_y_CorrelationsVs[eCorrelations_vs_MeantpcFractionSharedCls] = FancyFormatting(ph.fParticleHistogramsName[etpcFractionSharedCls].Data()); + + // *) "eCorrelations_vs_MeantpcChi2NCl": + nBins_y_CorrelationsVs[eCorrelations_vs_MeantpcChi2NCl] = 200; + min_y_CorrelationsVs[eCorrelations_vs_MeantpcChi2NCl] = 0.; + max_y_CorrelationsVs[eCorrelations_vs_MeantpcChi2NCl] = 2.; + title_y_CorrelationsVs[eCorrelations_vs_MeantpcChi2NCl] = FancyFormatting(ph.fParticleHistogramsName[etpcChi2NCl].Data()); + + // *) "eCorrelations_vs_MeandcaXY": + nBins_y_CorrelationsVs[eCorrelations_vs_MeandcaXY] = 200; + min_y_CorrelationsVs[eCorrelations_vs_MeandcaXY] = -0.2; + max_y_CorrelationsVs[eCorrelations_vs_MeandcaXY] = 0.2; + title_y_CorrelationsVs[eCorrelations_vs_MeandcaXY] = FancyFormatting(ph.fParticleHistogramsName[edcaXY].Data()); + + // *) "eCorrelations_vs_MeandcaZ": + nBins_y_CorrelationsVs[eCorrelations_vs_MeandcaZ] = 200; + min_y_CorrelationsVs[eCorrelations_vs_MeandcaZ] = -0.2; + max_y_CorrelationsVs[eCorrelations_vs_MeandcaZ] = 0.2; + title_y_CorrelationsVs[eCorrelations_vs_MeandcaZ] = FancyFormatting(ph.fParticleHistogramsName[edcaZ].Data()); + + // ..... + + // *) Quick insanity check on title_x_CorrelationsVs and title_y_CorrelationsVs: + if (title_x_CorrelationsVs.EqualTo("")) { + LOGF(fatal, "\033[1;31m%s at line %d : title_x_CorrelationsVs is not set, check corresponding enum \033[0m", __FUNCTION__, __LINE__); + } + for (int t = 0; t < eQACorrelationsVsHistograms2D_N; t++) { + if (title_y_CorrelationsVs[t].EqualTo("")) { + LOGF(fatal, "\033[1;31m%s at line %d : title_y_CorrelationsVs[%d] is not set, check corresponding enum \033[0m", __FUNCTION__, __LINE__, t); + } + } + + // Okay, let's book 'em all: + for (int t = 0; t < eQACorrelationsVsHistograms2D_N; t++) // type, see enum eQACorrelationsVsHistograms2D + { + if (!qa.fBookQACorrelationsVsHistograms2D[t]) { + continue; + } + + for (int h = 0; h < gMaxHarmonic; h++) { + + if (h + 1 < qa.fQACorrelationsVsHistogramsMinMaxHarmonic[eMin] || h + 1 >= qa.fQACorrelationsVsHistogramsMinMaxHarmonic[eMax]) { + continue; + } + + for (int rs = 0; rs < 2; rs++) // reco/sim + { + + if (Skip(rs)) { + continue; + } + + // valgrind --tool=massif => ~58.7 MiB (Last check: 20250315) + qa.fQACorrelationsVsHistograms2D[t][h][rs] = new TH2F( + TString::Format("fQACorrelationsVsHistograms2D[%s][%d][%s]", qa.fQACorrelationsVsHistogramsName2D[t].Data(), h, gc.srs[rs].Data()), + TString::Format("%s, %s", "__RUN_NUMBER__", gc.srsLong[rs].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) + nBins_x_CorrelationsVs, min_x_CorrelationsVs, max_x_CorrelationsVs, nBins_y_CorrelationsVs[t], min_y_CorrelationsVs[t], max_y_CorrelationsVs[t]); + + qa.fQACorrelationsVsHistograms2D[t][h][rs]->GetXaxis()->SetTitle(TString::Format("%s (harmonic = %d)", title_x_CorrelationsVs.Data(), h + 1)); + qa.fQACorrelationsVsHistograms2D[t][h][rs]->GetYaxis()->SetTitle(title_y_CorrelationsVs[t].Data()); + qa.fQACorrelationsVsHistograms2D[t][h][rs]->SetLineColor(ec.fBeforeAfterColor[eAfter]); + qa.fQACorrelationsVsHistograms2D[t][h][rs]->SetFillColor(ec.fBeforeAfterColor[eAfter] - 10); + qa.fQACorrelationsVsHistograms2D[t][h][rs]->SetOption("col"); + qa.fQACorrelationsVsList->Add(qa.fQACorrelationsVsHistograms2D[t][h][rs]); + } // for(int rs=0;rs<2;rs++) // reco/sim + + } // for (int h = 0; h < gMaxHarmonic; h++) { + + } // for(int t=0;t(eh.fEventHistogramsBins[eInteractionRate][0] / qa.fRebin); + double min_x_CorrelationsVsInteractionRateVs = eh.fEventHistogramsBins[eInteractionRate][1]; + double max_x_CorrelationsVsInteractionRateVs = eh.fEventHistogramsBins[eInteractionRate][2]; + TString title_x_CorrelationsVsInteractionRateVs = "interaction rate"; + int nBins_y_CorrelationsVsInteractionRateVs[eQACorrelationsVsInteractionRateVsProfiles2D_N] = {0}; + double min_y_CorrelationsVsInteractionRateVs[eQACorrelationsVsInteractionRateVsProfiles2D_N] = {0.}; + double max_y_CorrelationsVsInteractionRateVs[eQACorrelationsVsInteractionRateVsProfiles2D_N] = {0.}; + TString title_y_CorrelationsVsInteractionRateVs[eQACorrelationsVsInteractionRateVsProfiles2D_N] = {""}; + + // *) "eCorrelationsVsInteractionRate_vs_CurrentRunDuration": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_CurrentRunDuration] = static_cast(eh.fEventHistogramsBins[eCurrentRunDuration][0] / qa.fRebin); + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_CurrentRunDuration] = eh.fEventHistogramsBins[eCurrentRunDuration][1]; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_CurrentRunDuration] = eh.fEventHistogramsBins[eCurrentRunDuration][2]; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_CurrentRunDuration] = FancyFormatting(eh.fEventHistogramsName[eCurrentRunDuration].Data()); + + // *) "eCorrelationsVsInteractionRate_vs_Multiplicity": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_Multiplicity] = static_cast(eh.fEventHistogramsBins[eMultiplicity][0] / qa.fRebin); + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_Multiplicity] = eh.fEventHistogramsBins[eMultiplicity][1]; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_Multiplicity] = eh.fEventHistogramsBins[eMultiplicity][2]; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_Multiplicity] = FancyFormatting(eh.fEventHistogramsName[eMultiplicity].Data()); + + // *) "eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity] = static_cast(eh.fEventHistogramsBins[eReferenceMultiplicity][0] / qa.fRebin); + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity] = eh.fEventHistogramsBins[eReferenceMultiplicity][1]; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity] = eh.fEventHistogramsBins[eReferenceMultiplicity][2]; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity] = FancyFormatting(eh.fEventHistogramsName[eReferenceMultiplicity].Data()); + + // *) "eCorrelationsVsInteractionRate_vs_Centrality": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_Centrality] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_Centrality] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); + + // ..... + + // *) "eCorrelationsVsInteractionRate_vs_MeanPhi": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanPhi] = 200; + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanPhi] = 0.; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanPhi] = o2::constants::math::TwoPI; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanPhi] = FancyFormatting(ph.fParticleHistogramsName[ePhi].Data()); + + // *) "eCorrelationsVsInteractionRate_vs_SigmaMeanPhi": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanPhi] = 200; + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanPhi] = 0.; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanPhi] = 1.0; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanPhi] = TString::Format("#sigma_{%s}", FancyFormatting(ph.fParticleHistogramsName[ePhi].Data())); + + // *) "eCorrelationsVsInteractionRate_vs_MeanPt": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanPt] = 200; + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanPt] = 0.0; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanPt] = 2.0; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanPt] = FancyFormatting(ph.fParticleHistogramsName[ePt].Data()); + + // *) "eCorrelationsVsInteractionRate_vs_SigmaMeanPt": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanPt] = 200; + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanPt] = 0.; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanPt] = 1.0; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanPt] = TString::Format("#sigma_{%s}", FancyFormatting(ph.fParticleHistogramsName[ePt].Data())); + + // *) "eCorrelationsVsInteractionRate_vs_MeanEta": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanEta] = 600; + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanEta] = -0.5; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanEta] = 0.5; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_MeanEta] = FancyFormatting(ph.fParticleHistogramsName[eEta].Data()); + + // *) "eCorrelationsVsInteractionRate_vs_SigmaMeanEta": + nBins_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanEta] = 200; + min_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanEta] = 0.; + max_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanEta] = 1.0; + title_y_CorrelationsVsInteractionRateVs[eCorrelationsVsInteractionRate_vs_SigmaMeanEta] = TString::Format("#sigma_{%s}", FancyFormatting(ph.fParticleHistogramsName[eEta].Data())); + + // ..... + + // *) Quick insanity check on title_x_CorrelationsVsInteractionRateVs and title_y_CorrelationsVsInteractionRateVs: + if (title_x_CorrelationsVsInteractionRateVs.EqualTo("")) { + LOGF(fatal, "\033[1;31m%s at line %d : title_x_CorrelationsVsInteractionRateVs is not set, check corresponding enum \033[0m", __FUNCTION__, __LINE__); + } + for (int t = 0; t < eQACorrelationsVsInteractionRateVsProfiles2D_N; t++) { + if (title_y_CorrelationsVsInteractionRateVs[t].EqualTo("")) { + LOGF(fatal, "\033[1;31m%s at line %d : title_y_CorrelationsVsInteractionRateVs[%d] is not set, check corresponding enum \033[0m", __FUNCTION__, __LINE__, t); } } + // Okay, let's book 'em all: + for (int t = 0; t < eQACorrelationsVsInteractionRateVsProfiles2D_N; t++) // type, see enum eQACorrelationsVsInteractionRateVsProfiles2D + { + if (!qa.fBookQACorrelationsVsInteractionRateVsProfiles2D[t]) { + continue; + } + + for (int h = 0; h < gMaxHarmonic; h++) { + + if (h + 1 < qa.fQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMin] || h + 1 >= qa.fQACorrelationsVsInteractionRateVsProfilesMinMaxHarmonic[eMax]) { + continue; + } + + for (int rs = 0; rs < 2; rs++) // reco/sim + { + + if (Skip(rs)) { + continue; + } + + // TBI 20250317 documet here the output of profiling using valgrind --tool=massif + qa.fQACorrVsIRVsProfiles2D[t][h][rs] = new TProfile2D( + TString::Format("fQACorrVsIRVsProfiles2D[%s][%d][%s]", qa.fQACorrelationsVsInteractionRateVsProfilesName2D[t].Data(), h, gc.srs[rs].Data()), + TString::Format("%s, %s", "__RUN_NUMBER__", gc.srsLong[rs].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) + nBins_x_CorrelationsVsInteractionRateVs, min_x_CorrelationsVsInteractionRateVs, max_x_CorrelationsVsInteractionRateVs, nBins_y_CorrelationsVsInteractionRateVs[t], min_y_CorrelationsVsInteractionRateVs[t], max_y_CorrelationsVsInteractionRateVs[t]); + + TString tmp = qa.fQACorrVsIRVsProfiles2D[t][h][rs]->GetTitle(); // translating e.g. "544114, reconstructed" into "<<2>> (harmonic = 2), 544114, reconstructed" + qa.fQACorrVsIRVsProfiles2D[t][h][rs]->SetTitle(TString::Format("#LT#LT2#GT#GT (harmonic = %d), %s", h + 1, tmp.Data())); + qa.fQACorrVsIRVsProfiles2D[t][h][rs]->GetXaxis()->SetTitle(title_x_CorrelationsVsInteractionRateVs.Data()); + qa.fQACorrVsIRVsProfiles2D[t][h][rs]->GetYaxis()->SetTitle(title_y_CorrelationsVsInteractionRateVs[t].Data()); + qa.fQACorrVsIRVsProfiles2D[t][h][rs]->SetLineColor(ec.fBeforeAfterColor[eAfter]); + qa.fQACorrVsIRVsProfiles2D[t][h][rs]->SetFillColor(ec.fBeforeAfterColor[eAfter] - 10); + qa.fQACorrVsIRVsProfiles2D[t][h][rs]->SetOption("col"); + qa.fQACorrelationsVsInteractionRateVsList->Add(qa.fQACorrVsIRVsProfiles2D[t][h][rs]); + } // for(int rs=0;rs<2;rs++) // reco/sim + + } // for (int h = 0; h < gMaxHarmonic; h++) { + + } // for(int t=0;tSetStats(kFALSE); + eh.fEventHistogramsPro->SetStats(false); eh.fEventHistogramsPro->SetLineColor(eColor); eh.fEventHistogramsPro->SetFillColor(eFillColor); - eh.fEventHistogramsPro->GetXaxis()->SetBinLabel(1, "fFillEventHistograms"); - eh.fEventHistogramsPro->Fill(0.5, static_cast(eh.fFillEventHistograms)); - // ... - eh.fEventHistogramsList->Add(eh.fEventHistogramsPro); - // b) Book specific control event histograms 1D: - // ... + if (tc.fUseSetBinLabel) { + eh.fEventHistogramsPro->GetXaxis()->SetBinLabel(1, "fFillEventHistograms"); + eh.fEventHistogramsPro->Fill(0.5, static_cast(eh.fFillEventHistograms)); - for (Int_t t = 0; t < eEventHistograms_N; t++) // type, see enum eEventHistograms - { + // ... + + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fFillEventHistograms; ", 1); // TBI 20250411 hardwired 1 + eh.fEventHistogramsPro->Fill(0.5, static_cast(eh.fFillEventHistograms)); // TBI 20250411 hardwired 0.5 + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != eh.fEventHistogramsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != eh.fEventHistogramsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), eh.fEventHistogramsPro->GetNbinsX()); + } + delete oa; + + // *) Okay, set the title: + eh.fEventHistogramsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else + + eh.fEventHistogramsList->Add(eh.fEventHistogramsPro); + + // b) Book specific control event histograms 1D: + // ... + + for (int t = 0; t < eEventHistograms_N; t++) // type, see enum eEventHistograms + { if (!eh.fBookEventHistograms[t]) { continue; } - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { if (Skip(rs)) { continue; } - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { // Special treatment for eMultiplicity => I will never fill this one before the cuts, if Multiplicity = SelectedTracks, obviously: @@ -3015,33 +4696,34 @@ void BookEventHistograms() continue; } eh.fEventHistograms[t][rs][ba] = new TH1F( - Form("fEventHistograms[%s][%s][%s]", eh.fEventHistogramsName[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), - Form("%s, %s, %s", "__RUN_NUMBER__", gc.srs_long[rs].Data(), gc.sba_long[ba].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) + TString::Format("fEventHistograms[%s][%s][%s]", eh.fEventHistogramsName[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), + TString::Format("%s, %s, %s", "__RUN_NUMBER__", gc.srsLong[rs].Data(), gc.sbaLong[ba].Data()), // __RUN_NUMBER__ is handled in PropagateRunNumber(...) static_cast(eh.fEventHistogramsBins[t][0]), eh.fEventHistogramsBins[t][1], eh.fEventHistogramsBins[t][2]); eh.fEventHistograms[t][rs][ba]->GetXaxis()->SetTitle(FancyFormatting(eh.fEventHistogramsName[t].Data())); eh.fEventHistograms[t][rs][ba]->SetLineColor(ec.fBeforeAfterColor[ba]); eh.fEventHistograms[t][rs][ba]->SetFillColor(ec.fBeforeAfterColor[ba] - 10); eh.fEventHistogramsList->Add(eh.fEventHistograms[t][rs][ba]); - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for(Int_t t=0;tSetTitle(TString::Format("%s (hardwired analysis-specific cuts not used)", ec.fEventCutsPro->GetTitle()).Data()); } - ec.fEventCutsPro->SetStats(kFALSE); + ec.fEventCutsPro->SetStats(false); ec.fEventCutsPro->SetLineColor(eColor); ec.fEventCutsPro->SetFillColor(eFillColor); - for (Int_t cut = 0; cut < eEventCuts_N; cut++) { - ec.fEventCutsPro->GetXaxis()->SetBinLabel(1 + cut, ec.fEventCutName[cut].Data()); // Remark: check always if bin labels here correspond to ordering in enum eEventCuts + ec.fEventCutsPro->GetXaxis()->SetLabelSize(0.020); + + TString yAxisTitle = ""; // TBI 20250413 when I fall back on using SetBinLabel(...), this variable is declared but will be unused + for (int cut = 0; cut < eEventCuts_N; cut++) { + + if (tc.fUseSetBinLabel) { + ec.fEventCutsPro->GetXaxis()->SetBinLabel(1 + cut, ec.fEventCutName[cut].Data()); // Remark: check always if bin labels here correspond to ordering in enum eEventCuts + } else { + // Workaround for SetBinLabel() large memory consumption: + yAxisTitle += TString::Format("%d:%s; ", 1 + cut, ec.fEventCutName[cut].Data()); + } + ec.fEventCutsPro->Fill(cut, static_cast(ec.fUseEventCuts[cut])); - } + + } // for (int cut = 0; cut < eEventCuts_N; cut++) { + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + if (!tc.fUseSetBinLabel) { + + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != ec.fEventCutsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() = %d != ec.fEventCutsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), ec.fEventCutsPro->GetNbinsX()); + } + delete oa; + + // *) Okay, set the title: + ec.fEventCutsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + } // if(!tc.fUseSetBinLabel) + ec.fEventCutsList->Add(ec.fEventCutsPro); // b) Book event cut counter maps: - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { // If I am analyzing only reconstructed data, do not book maps for simulated, and vice versa. if ((tc.fProcess[eGenericRec] && rs == eSim) || (tc.fProcess[eGenericSim] && rs == eRec)) { @@ -3076,47 +4786,169 @@ void BookEventCutsHistograms() // c) Book event cut counter histograms: // ... - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { if (Skip(rs)) { continue; } - for (Int_t cc = 0; cc < eCutCounter_N; cc++) // cut counter + for (int cc = 0; cc < eCutCounter_N; cc++) // cut counter { if ((!ec.fUseEventCutCounterAbsolute && cc == eAbsolute) || (!ec.fUseEventCutCounterSequential && cc == eSequential)) { continue; } - ec.fEventCutCounterHist[rs][cc] = new TH1I(Form("fEventCutCounterHist[%s][%s]", gc.srs[rs].Data(), gc.scc[cc].Data()), Form("%s, %s, event cut counter (%s)", "__RUN_NUMBER__", gc.srs_long[rs].Data(), gc.scc_long[cc].Data()), eEventCuts_N, 0.5, static_cast(eEventCuts_N) + 0.5); // I cast in double the last argument, because that's what this particular TH1I constructor expects - // Yes, +0.5, because eEventCuts kicks off from 0 - ec.fEventCutCounterHist[rs][cc]->SetStats(kFALSE); + ec.fEventCutCounterHist[rs][cc] = new TH1F(TString::Format("fEventCutCounterHist[%s][%s]", gc.srs[rs].Data(), gc.scc[cc].Data()), TString::Format("%s, %s, event cut counter (%s)", "__RUN_NUMBER__", gc.srsLong[rs].Data(), gc.sccLong[cc].Data()), eEventCuts_N, 0.5, static_cast(eEventCuts_N) + 0.5); // I cast in double the last argument, because that's what this particular TH1I constructor expects. And yes, +0.5, because eEventCuts kicks off from 0 + ec.fEventCutCounterHist[rs][cc]->SetStats(false); ec.fEventCutCounterHist[rs][cc]->SetLineColor(eColor); ec.fEventCutCounterHist[rs][cc]->SetFillColor(eFillColor); + ec.fEventCutCounterHist[rs][cc]->GetXaxis()->SetLabelSize(0.025); + // Remark: Bin labels are set later in a dry call to EventCuts, to accomodate sequential event cut counting ec.fEventCutsList->Add(ec.fEventCutCounterHist[rs][cc]); - } // for (Int_t cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter + } // for (int cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter + + } // for (int rs = 0; rs < 2; rs++) // reco/sim + + // d) Book the formulas for all event cuts defined via mathematical expressions: + + // **) eRefMultVsNContrUp: + if (ec.fUseEventCuts[eRefMultVsNContrUp]) { + if (tc.fUseFormula) { + ec.fEventCutsFormulas[eRefMultVsNContrUp_Formula] = new TFormula("RefMultVsNContrUp_Formula", ec.fsEventCuts[eRefMultVsNContrUp].Data()); + + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! There is a large memory blow-up when using TFormula() !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); + + // As a quick insanity check, try immediately to evaluate something from this formula: + if (std::isnan(ec.fEventCutsFormulas[eRefMultVsNContrUp_Formula]->Eval(1.44))) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } else { + // This is a workaround to evaluate upper boundary of HMO cut, until large-memory consumption with TFormula is resolved. + + // Algorithm: 1. ec.fsEventCuts[eRefMultVsNContrUp].Data() is linear expression in the mandatory format "p0 + p1*x". + // 2. Then I extract p0 and p1, and store them in float fdEventCutsFormulas[eEventCutsFormulas_N][2] = {{0.}} + // 3. Those values are then used in temporary function float RefMultVsNContr(const float &refMult, ...) + + this->GetP0P1(ec.fsEventCuts[eRefMultVsNContrUp].ReplaceAll(" ", ""), eRefMultVsNContrUp_Formula); + + } // else + + } // if (ec.fUseEventCuts[eRefMultVsNContrUp]) + + // **) eRefMultVsNContrLow: + if (ec.fUseEventCuts[eRefMultVsNContrLow]) { + if (tc.fUseFormula) { + ec.fEventCutsFormulas[eRefMultVsNContrLow_Formula] = new TFormula("RefMultVsNContrLow_Formula", ec.fsEventCuts[eRefMultVsNContrLow].Data()); + + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! There is a large memory blow-up when using TFormula() !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); + + // As a quick insanity check, try immediately to evaluate something from this formula: + if (std::isnan(ec.fEventCutsFormulas[eRefMultVsNContrLow_Formula]->Eval(1.44))) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } else { + // This is a workaround to evaluate upper boundary of HMO cut, until large-memory consumption with TFormula is resolved. + + // Algorithm: See above for eRefMultVsNContrUp + this->GetP0P1(ec.fsEventCuts[eRefMultVsNContrLow].ReplaceAll(" ", ""), eRefMultVsNContrLow_Formula); + } + + } // if (ec.fUseEventCuts[eRefMultVsNContrLow]) + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void bookEventCutsHistograms() + +//============================================================ + +void GetP0P1(const char* formula, eEventCutsFormulas whichCutFormula) +{ + // This is a sort of temporary parser, which extracts from linear expression p0 + p1*x coefficients p0 and p1, and stores them into float fdEventCutsFormulas[eEventCutsFormulas_N][2] = {{0.}} + // Remark #0: I need all this gym until large memory consumption with TFormula is resolved; + // Remark #1: Remove all blanks in 'formula' before calling this function; + // Remark #2: If I need to go beyond p1, use recursion instead. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + TString signP0 = ""; + TString signP1 = ""; + TString P0 = ""; + TString P1 = ""; + + // P0 signature parser: + int offset = 0; + if (TString(formula[0]).EqualTo("-")) { + signP0 = "-"; + offset = 1; + } + + // P0 parser + P1 signature parser: + int c1 = 0; + for (int c = 0 + offset; c < static_cast(strlen(formula)); c++) { + if (!(TString(formula[c]).EqualTo("-") || TString(formula[c]).EqualTo("+") || TString(formula[c]).EqualTo("*"))) { + P0 += formula[c]; + continue; + } else { + signP1 = formula[c]; + c1 = c; + break; + } + } + // P1 parser: + for (int c = c1 + 1; c < static_cast(strlen(formula)); c++) { + if (TString(formula[c]).EqualTo("-") || TString(formula[c]).EqualTo("+") || TString(formula[c]).EqualTo("*")) { + break; + } + P1 += formula[c]; + } + + // Okay, finally merge signature and value, cast into floats and store: + signP0 += P0; + ec.fdEventCutsFormulas[whichCutFormula][0] = signP0.Atof(); - } // for (Int_t rs = 0; rs < 2; rs++) // reco/sim + signP1 += P1; + ec.fdEventCutsFormulas[whichCutFormula][1] = signP1.Atof(); if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void BookEventCutsHistograms() +} // void GetP0P1(const char *formula, eEventCutsFormulas whichCutFormula) + +//============================================================ + +float RefMultVsNContr(const float& refMult, eEventCutsFormulas whichCutFormula) +{ + // Temporary workaround for p0 + p1 * x formula until large memory consumption with TFormula is resolved. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // Evaluate p0 + p1 * x: + return ec.fdEventCutsFormulas[whichCutFormula][0] + (ec.fdEventCutsFormulas[whichCutFormula][1]) * refMult; + +} // float RefMultVsNContr(const float &refMult, eEventCutsFormulas whichCutFormula) //============================================================ -void BookParticleHistograms() +void bookParticleHistograms() { // Book all particle histograms. // a) Book the profile holding flags; // b) Book specific particle histograms 1D; - // c) Book specific particle histograms 2D. + // c) Book specific particle histograms 2D; + // e) Default binning for particle sparse histograms (yes, here, see comments below); + // d) Book specific particle sparse histograms (n-dimensions). if (tc.fVerbose) { StartFunction(__FUNCTION__); @@ -3125,22 +4957,50 @@ void BookParticleHistograms() // a) Book the profile holding flags: ph.fParticleHistogramsPro = new TProfile( "fParticleHistogramsPro", "flags for particle histograms", 1, 0., 1.); - ph.fParticleHistogramsPro->SetStats(kFALSE); + ph.fParticleHistogramsPro->SetStats(false); ph.fParticleHistogramsPro->SetLineColor(eColor); ph.fParticleHistogramsPro->SetFillColor(eFillColor); - ph.fParticleHistogramsPro->GetXaxis()->SetBinLabel(1, "fFillParticleHistograms"); - ph.fParticleHistogramsPro->Fill(0.5, static_cast(ph.fFillParticleHistograms)); - // ... + ph.fParticleHistogramsPro->GetXaxis()->SetLabelSize(0.025); + + if (tc.fUseSetBinLabel) { + ph.fParticleHistogramsPro->GetXaxis()->SetBinLabel(1, "fFillParticleHistograms"); + ph.fParticleHistogramsPro->Fill(0.5, static_cast(ph.fFillParticleHistograms)); + + // ... + + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fFillParticleHistograms; ", 1); // TBI 20250411 hardwired 1 + ph.fParticleHistogramsPro->Fill(0.5, static_cast(ph.fFillParticleHistograms)); // TBI 20250411 hardwired 0.5 + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != ph.fParticleHistogramsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != ph.fParticleHistogramsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), ph.fParticleHistogramsPro->GetNbinsX()); + } + + // *) Okay, set the title: + ph.fParticleHistogramsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else + ph.fParticleHistogramsList->Add(ph.fParticleHistogramsPro); // b) Book specific particle histograms 1D: // ... - for (Int_t t = 0; t < eParticleHistograms_N; t++) // type, see enum eParticleHistograms + for (int t = 0; t < eParticleHistograms_N; t++) // type, see enum eParticleHistograms { if (!ph.fBookParticleHistograms[t]) { continue; } - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { if (Skip(rs)) { @@ -3154,10 +5014,10 @@ void BookParticleHistograms() } } - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { - ph.fParticleHistograms[t][rs][ba] = new TH1F(Form("fParticleHistograms[%s][%s][%s]", ph.fParticleHistogramsName[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), - Form("%s, %s, %s", "__RUN_NUMBER__", gc.srs_long[rs].Data(), gc.sba_long[ba].Data()), + ph.fParticleHistograms[t][rs][ba] = new TH1F(TString::Format("fParticleHistograms[%s][%s][%s]", ph.fParticleHistogramsName[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), + TString::Format("%s, %s, %s", "__RUN_NUMBER__", gc.srsLong[rs].Data(), gc.sbaLong[ba].Data()), static_cast(ph.fParticleHistogramsBins[t][0]), ph.fParticleHistogramsBins[t][1], ph.fParticleHistogramsBins[t][2]); ph.fParticleHistograms[t][rs][ba]->SetLineColor(ec.fBeforeAfterColor[ba]); ph.fParticleHistograms[t][rs][ba]->SetFillColor(ec.fBeforeAfterColor[ba] - 10); @@ -3168,9 +5028,9 @@ void BookParticleHistograms() // But it's harmless, because in any case I do not care about the content of empty histogram... ph.fParticleHistograms[t][rs][ba]->SetOption("hist"); // do not plot marker and error (see BanishmentLoopOverParticles why errors are not reliable) for each bin, only content + filled area. ph.fParticleHistogramsList->Add(ph.fParticleHistograms[t][rs][ba]); - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for(Int_t t=0;t(ph.fParticleHistogramsBins2D[t][eX][0]), ph.fParticleHistogramsBins2D[t][eX][1], ph.fParticleHistogramsBins2D[t][eX][2], res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetArray()); // yes, x-axis of "results vs pt" hist is y-axis here for 2D. } else if (ph.fParticleHistogramsName2D[t].EqualTo("Phi_vs_Eta") && res.fUseResultsProVariableLengthBins[AFO_ETA]) { // *) variable-length binning for phi vs eta, but only in eta axis: - ph.fParticleHistograms2D[t][rs][ba] = new TH2D(Form("fParticleHistograms2D[%s][%s][%s]", ph.fParticleHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), - Form("%s, %s, %s", "__RUN_NUMBER__", gc.srs_long[rs].Data(), gc.sba_long[ba].Data()), + ph.fParticleHistograms2D[t][rs][ba] = new TH2D(TString::Format("fParticleHistograms2D[%s][%s][%s]", ph.fParticleHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), + TString::Format("%s, %s, %s", "__RUN_NUMBER__", gc.srsLong[rs].Data(), gc.sbaLong[ba].Data()), static_cast(ph.fParticleHistogramsBins2D[t][eX][0]), ph.fParticleHistogramsBins2D[t][eX][1], ph.fParticleHistogramsBins2D[t][eX][2], res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetArray()); // yes, x-axis of "results vs pt" hist is y-axis here for 2D } else { // default fixed-length binning: - ph.fParticleHistograms2D[t][rs][ba] = new TH2D(Form("fParticleHistograms2D[%s][%s][%s]", ph.fParticleHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), - Form("%s, %s, %s", "__RUN_NUMBER__", gc.srs_long[rs].Data(), gc.sba_long[ba].Data()), + // Remark: Remember that I cannot use here GetXaxis()->GetXbins()->GetArray() as for variable-width case, because for fixed-width case, this is always 0 + // See https://root-forum.cern.ch/t/get-bin-array/7276/9 + ph.fParticleHistograms2D[t][rs][ba] = new TH2D(TString::Format("fParticleHistograms2D[%s][%s][%s]", ph.fParticleHistogramsName2D[t].Data(), gc.srs[rs].Data(), gc.sba[ba].Data()), + TString::Format("%s, %s, %s", "__RUN_NUMBER__", gc.srsLong[rs].Data(), gc.sbaLong[ba].Data()), static_cast(ph.fParticleHistogramsBins2D[t][eX][0]), ph.fParticleHistogramsBins2D[t][eX][1], ph.fParticleHistogramsBins2D[t][eX][2], static_cast(ph.fParticleHistogramsBins2D[t][eY][0]), ph.fParticleHistogramsBins2D[t][eY][1], ph.fParticleHistogramsBins2D[t][eY][2]); } @@ -3234,20 +5096,288 @@ void BookParticleHistograms() ph.fParticleHistograms2D[t][rs][ba]->GetXaxis()->SetTitle(stitleX2D[t].Data()); ph.fParticleHistograms2D[t][rs][ba]->GetYaxis()->SetTitle(stitleY2D[t].Data()); ph.fParticleHistogramsList->Add(ph.fParticleHistograms2D[t][rs][ba]); - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for(Int_t t=0;t(180. / ph.fRebinSparse); + lAxis = new TAxis(ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiPhiAxis], 0., o2::constants::math::TwoPI); + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiPhiAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiPhiAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiPhiAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiPhiAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + delete lAxis; + ph.fParticleSparseHistogramsAxisTitle[eDWPhi][wPhiPhiAxis] = FancyFormatting("Phi"); + + // ***) pt-axis for diff phi weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_PT]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_PT] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiPtAxis] = res.fResultsPro[AFO_PT]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_PT]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiPtAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiPtAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiPtAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiPtAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWPhi][wPhiPtAxis] = FancyFormatting("Pt"); + + // ***) eta-axis for diff phi weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_ETA]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_ETA] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiEtaAxis] = res.fResultsPro[AFO_ETA]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_ETA]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiEtaAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiEtaAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiEtaAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiEtaAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWPhi][wPhiEtaAxis] = FancyFormatting("Eta"); + + // ***) charge-axis for diff phi weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_CHARGE]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_CHARGE] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiChargeAxis] = res.fResultsPro[AFO_CHARGE]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_CHARGE]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiChargeAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiChargeAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiChargeAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiChargeAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWPhi][wPhiChargeAxis] = FancyFormatting("Charge"); + + // ***) centrality-axis for diff phi weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_CENTRALITY]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_CENTRALITY] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiCentralityAxis] = res.fResultsPro[AFO_CENTRALITY]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_CENTRALITY]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiCentralityAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiCentralityAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiCentralityAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiCentralityAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWPhi][wPhiCentralityAxis] = "Centrality"; // TBI 20250222 I cannot call here FancyFormatting for "Centrality", because ec.fsEventCuts[eCentralityEstimator] is still not fetched and set from configurable. Re-think how to proceed for this specific case. + + // ***) VertexZ-axis for diff phi weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_VZ]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_VZ] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiVertexZAxis] = res.fResultsPro[AFO_VZ]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_VZ]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiVertexZAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWPhi][wPhiVertexZAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiVertexZAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWPhi][wPhiVertexZAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWPhi][wPhiVertexZAxis] = "VertexZ"; // TBI 20250222 I cannot call here FancyFormatting for "Centrality", because ec.fsEventCuts[eCentralityEstimator] + + // ... + + // **) eDiffWeightCategory = eDWPt: + + // ***) pt-axis for diff pt weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_PT]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_PT] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWPt][wPtPtAxis] = res.fResultsPro[AFO_PT]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_PT]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWPt][wPtPtAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWPt][wPtPtAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWPt][wPtPtAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWPt][wPtPtAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWPt][wPtPtAxis] = FancyFormatting("Pt"); + + // ***) charge-axis for diff pt weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_CHARGE]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_CHARGE] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWPt][wPtChargeAxis] = res.fResultsPro[AFO_CHARGE]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_CHARGE]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWPt][wPtChargeAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWPt][wPtChargeAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWPt][wPtChargeAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWPt][wPtChargeAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWPt][wPtChargeAxis] = FancyFormatting("Charge"); + + // ***) centrality-axis for diff pt weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_CENTRALITY]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_CENTRALITY] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWPt][wPtCentralityAxis] = res.fResultsPro[AFO_CENTRALITY]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_CENTRALITY]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWPt][wPtCentralityAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWPt][wPtCentralityAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWPt][wPtCentralityAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWPt][wPtCentralityAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWPt][wPtCentralityAxis] = "Centrality"; // TBI 20250222 I cannot call here FancyFormatting for "Centrality", because ec.fsEventCuts[eCentralityEstimator] is still not fetched and set from configurable. Re-think how to proceed for this specific case. + + // ... + + // **) eDiffWeightCategory = eDWEta: + + // ***) eta-axis for diff eta weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_ETA]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_ETA] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWEta][wEtaEtaAxis] = res.fResultsPro[AFO_ETA]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_ETA]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWEta][wEtaEtaAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWEta][wEtaEtaAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWEta][wEtaEtaAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWEta][wEtaEtaAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWEta][wEtaEtaAxis] = FancyFormatting("Eta"); + + // ***) charge-axis for diff eta weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_CHARGE]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_CHARGE] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWEta][wEtaChargeAxis] = res.fResultsPro[AFO_CHARGE]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_CHARGE]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWEta][wEtaChargeAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWEta][wEtaChargeAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWEta][wEtaChargeAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWEta][wEtaChargeAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWEta][wEtaChargeAxis] = FancyFormatting("Charge"); + + // ***) centrality-axis for diff eta weights - I re-use binning from results histograms: + if (!res.fResultsPro[AFO_CENTRALITY]) { + LOGF(fatal, "\033[1;31m%s at line %d : res.fResultsPro[AFO_CENTRALITY] is NULL \033[0m", __FUNCTION__, __LINE__); + } + ph.fParticleSparseHistogramsNBins[eDWEta][wEtaCentralityAxis] = res.fResultsPro[AFO_CENTRALITY]->GetNbinsX(); + lAxis = res.fResultsPro[AFO_CENTRALITY]->GetXaxis(); + ph.fParticleSparseHistogramsBinEdges[eDWEta][wEtaCentralityAxis] = new TArrayD(1 + ph.fParticleSparseHistogramsNBins[eDWEta][wEtaCentralityAxis]); + for (int bin = 1; bin <= lAxis->GetNbins(); bin++) { + ph.fParticleSparseHistogramsBinEdges[eDWEta][wEtaCentralityAxis]->AddAt(lAxis->GetBinLowEdge(bin), bin - 1); + } + ph.fParticleSparseHistogramsBinEdges[eDWEta][wEtaCentralityAxis]->AddAt(lAxis->GetBinLowEdge(1 + lAxis->GetNbins()), lAxis->GetNbins()); // special treatment for last bin + // delete lAxis; // I do not need to delete here, only when new TAxis(...) + ph.fParticleSparseHistogramsAxisTitle[eDWEta][wEtaCentralityAxis] = "Centrality"; // TBI 20250222 I cannot call here FancyFormatting for "Centrality", because ec.fsEventCuts[eCentralityEstimator] is still not fetched and set from configurable. Re-think how to proceed for this specific case. + + // ... + + // e) Book specific particle sparse histograms (n-dimensions): + if (ph.fBookParticleSparseHistograms[eDWPhi]) { + BookParticleSparseHistograms(eDWPhi); + } + + if (ph.fBookParticleSparseHistograms[eDWPt]) { + BookParticleSparseHistograms(eDWPt); + } + + if (ph.fBookParticleSparseHistograms[eDWEta]) { + BookParticleSparseHistograms(eDWEta); + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void bookParticleHistograms() + +//============================================================ + +void BookParticleSparseHistograms(eDiffWeightCategory dwc) +{ + // This is a helper function for bookParticleHistograms(), merely to reduce code bloat. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // *) Determine number of dimensions for sparse histogram for this differential weight category: + int nDimensions = -1; + switch (dwc) { + case eDWPhi: { + nDimensions = static_cast(eDiffPhiWeights_N); + break; + } + case eDWPt: { + nDimensions = static_cast(eDiffPtWeights_N); + break; + } + case eDWEta: { + nDimensions = static_cast(eDiffEtaWeights_N); + break; + } + default: { + LOGF(fatal, "\033[1;31m%s at line %d : This differential weight category, dwc = %d, is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(dwc)); + break; + } + } // switch(dwc) + + // *) Determine binning for all dimensions: + TArrayI* nBins = new TArrayI(nDimensions); + for (int d = 0; d < nDimensions; d++) { + nBins->AddAt(static_cast(ph.fParticleSparseHistogramsNBins[dwc][d]), d); + } + + // *) Book THnSparse with correct number of bins for each dimension, but void bin edges: + for (int rs = 0; rs < 2; rs++) // reco/sim + { + if (Skip(rs)) { + continue; + } + // Remark: Here I have a bit unusual convention for the name and title, but okay... + ph.fParticleSparseHistograms[dwc][rs] = new THnSparseF(TString::Format("%s[%s]", ph.fParticleSparseHistogramsName[dwc].Data(), gc.srs[rs].Data()), TString::Format("__RUN_NUMBER__, %s, %s", gc.srsLong[rs].Data(), ph.fParticleSparseHistogramsTitle[dwc].Data()), nDimensions, nBins->GetArray(), NULL, NULL); + + // *) For each dimension set bin edges, axis title, etc.: + for (int d = 0; d < nDimensions; d++) { + ph.fParticleSparseHistograms[dwc][rs]->SetBinEdges(d, ph.fParticleSparseHistogramsBinEdges[dwc][d]->GetArray()); + ph.fParticleSparseHistograms[dwc][rs]->GetAxis(d)->SetTitle(ph.fParticleSparseHistogramsAxisTitle[dwc][d].Data()); + } + + // *) Finally, add the fully configured THnSparse to its TList: + ph.fParticleHistogramsList->Add(ph.fParticleSparseHistograms[dwc][rs]); + } // for (int rs = 0; rs < 2; rs++) // reco/sim + + // *) Clean up: + delete nBins; + if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void BookParticleHistograms() +} // void BookParticleSparseHistograms() //============================================================ -void BookParticleCutsHistograms() +void bookParticleCutsHistograms() { // Book all particle cuts objects. @@ -3267,17 +5397,43 @@ void BookParticleCutsHistograms() } else { pc.fParticleCutsPro->SetTitle(TString::Format("%s (hardwired analysis-specific cuts not used)", pc.fParticleCutsPro->GetTitle()).Data()); } - pc.fParticleCutsPro->SetStats(kFALSE); + pc.fParticleCutsPro->SetStats(false); pc.fParticleCutsPro->SetLineColor(eColor); pc.fParticleCutsPro->SetFillColor(eFillColor); - for (Int_t cut = 0; cut < eParticleCuts_N; cut++) { - pc.fParticleCutsPro->GetXaxis()->SetBinLabel(1 + cut, pc.fParticleCutName[cut].Data()); // Remark: check always if bin labels here correspond to ordering in enum eParticleCuts + + TString yAxisTitle = ""; // TBI 20250413 when I fall back on using SetBinLabel(...), this variable is declared but will be unused + for (int cut = 0; cut < eParticleCuts_N; cut++) { + if (tc.fUseSetBinLabel) { + pc.fParticleCutsPro->GetXaxis()->SetBinLabel(1 + cut, pc.fParticleCutName[cut].Data()); // Remark: check always if bin labels here correspond to ordering in enum eParticleCuts + } else { + // Workaround for SetBinLabel() large memory consumption: + yAxisTitle += TString::Format("%d:%s; ", 1 + cut, pc.fParticleCutName[cut].Data()); + } + pc.fParticleCutsPro->Fill(cut, static_cast(pc.fUseParticleCuts[cut])); - } + + } // for (int cut = 0; cut < eParticleCuts_N; cut++)s + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + if (!tc.fUseSetBinLabel) { + + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != pc.fParticleCutsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() = %d != pc.fParticleCutsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), pc.fParticleCutsPro->GetNbinsX()); + } + delete oa; + + // *) Okay, set the title: + pc.fParticleCutsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + } // if(!tc.fUseSetBinLabel) + pc.fParticleCutsList->Add(pc.fParticleCutsPro); // b) Book particle cut counter maps: - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { // If I am analyzing only reconstructed data, do not book maps for simulated, and vice versa. if ((tc.fProcess[eGenericRec] && rs == eSim) || (tc.fProcess[eGenericSim] && rs == eRec)) { @@ -3289,36 +5445,40 @@ void BookParticleCutsHistograms() // c) Book the particle cut counter (absolute): // ... - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { if (Skip(rs)) { continue; } - for (Int_t cc = 0; cc < eCutCounter_N; cc++) // cut counter + for (int cc = 0; cc < eCutCounter_N; cc++) // cut counter { if ((!pc.fUseParticleCutCounterAbsolute && cc == eAbsolute) || (!pc.fUseParticleCutCounterSequential && cc == eSequential)) { continue; } - pc.fParticleCutCounterHist[rs][cc] = new TH1I(Form("fParticleCutCounterHist[%s][%s]", gc.srs[rs].Data(), gc.scc[cc].Data()), Form("%s, %s, particle cut counter (%s)", "__RUN_NUMBER__", gc.srs_long[rs].Data(), gc.scc_long[cc].Data()), eParticleCuts_N, 0.5, static_cast(eParticleCuts_N) + 0.5); + pc.fParticleCutCounterHist[rs][cc] = new TH1F(TString::Format("fParticleCutCounterHist[%s][%s]", gc.srs[rs].Data(), gc.scc[cc].Data()), TString::Format("%s, %s, particle cut counter (%s)", "__RUN_NUMBER__", gc.srsLong[rs].Data(), gc.sccLong[cc].Data()), eParticleCuts_N, 0.5, static_cast(eParticleCuts_N) + 0.5); // I cast in double the last argument, because that's what this particular TH1I constructor expects // Yes, +0.5, because eParticleCuts kicks off from 0 - pc.fParticleCutCounterHist[rs][cc]->SetStats(kFALSE); + pc.fParticleCutCounterHist[rs][cc]->SetStats(false); pc.fParticleCutCounterHist[rs][cc]->SetLineColor(eColor); pc.fParticleCutCounterHist[rs][cc]->SetFillColor(eFillColor); + pc.fParticleCutCounterHist[rs][cc]->GetXaxis()->SetLabelSize(0.025); // Remark: Bin labels are set later in a dry call to ParticleCuts, to accomodate sequential particle cut counting pc.fParticleCutsList->Add(pc.fParticleCutCounterHist[rs][cc]); - } // for (Int_t cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter + } // for (int cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter - } // for (Int_t rs = 0; rs < 2; rs++) // reco/sim + } // for (int rs = 0; rs < 2; rs++) // reco/sim // d) Book the formula for pt-dependent DCAxy cut: if (pc.fUseParticleCuts[ePtDependentDCAxyParameterization]) { pc.fPtDependentDCAxyFormula = new TFormula("fPtDependentDCAxyFormula", pc.fsParticleCuts[ePtDependentDCAxyParameterization].Data()); + + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! There is a large memory blow-up when using TFormula() !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); + // As a quick insanity check, try immediately to evaluate something from this formula: if (std::isnan(pc.fPtDependentDCAxyFormula->Eval(1.44))) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); @@ -3329,17 +5489,18 @@ void BookParticleCutsHistograms() ExitFunction(__FUNCTION__); } -} // void BookParticleCutsHistograms() +} // void bookParticleCutsHistograms() //============================================================ -void BookQvectorHistograms() +void bookQvectorHistograms() { // Book all Q-vector histograms. // a) Book the profile holding flags; - // b) Book multiplicity distributions in A and B, for each eta separation; - // c) ... + // b) Differential q-vectors booked dynamically: + // c) Book multiplicity distributions in A and B, for each eta separation; + // d) ... if (tc.fVerbose) { StartFunction(__FUNCTION__); @@ -3348,50 +5509,192 @@ void BookQvectorHistograms() // a) Book the profile holding flags: qv.fQvectorFlagsPro = new TProfile("fQvectorFlagsPro", "flags for Q-vector objects", 3, 0., 3.); - qv.fQvectorFlagsPro->SetStats(kFALSE); + qv.fQvectorFlagsPro->SetStats(false); qv.fQvectorFlagsPro->SetLineColor(eColor); qv.fQvectorFlagsPro->SetFillColor(eFillColor); qv.fQvectorFlagsPro->GetXaxis()->SetLabelSize(0.05); - qv.fQvectorFlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateQvectors"); - qv.fQvectorFlagsPro->Fill(0.5, qv.fCalculateQvectors); - qv.fQvectorFlagsPro->GetXaxis()->SetBinLabel(2, "gMaxHarmonic"); - qv.fQvectorFlagsPro->Fill(1.5, gMaxHarmonic); - qv.fQvectorFlagsPro->GetXaxis()->SetBinLabel(3, "gMaxCorrelator"); - qv.fQvectorFlagsPro->Fill(2.5, gMaxCorrelator); + + if (tc.fUseSetBinLabel) { + + qv.fQvectorFlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateQvectors"); + qv.fQvectorFlagsPro->Fill(0.5, qv.fCalculateQvectors); + qv.fQvectorFlagsPro->GetXaxis()->SetBinLabel(2, "gMaxHarmonic"); + qv.fQvectorFlagsPro->Fill(1.5, gMaxHarmonic); + qv.fQvectorFlagsPro->GetXaxis()->SetBinLabel(3, "gMaxCorrelator"); + qv.fQvectorFlagsPro->Fill(2.5, gMaxCorrelator); + + // ... + + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fCalculateQvectors; ", 1); + qv.fQvectorFlagsPro->Fill(0.5, static_cast(qv.fCalculateQvectors)); + + yAxisTitle += TString::Format("%d:gMaxHarmonic; ", 2); + qv.fQvectorFlagsPro->Fill(1.5, static_cast(gMaxHarmonic)); + + yAxisTitle += TString::Format("%d:gMaxCorrelator; ", 3); + qv.fQvectorFlagsPro->Fill(2.5, static_cast(gMaxCorrelator)); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != qv.fQvectorFlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != qv.fQvectorFlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), qv.fQvectorFlagsPro->GetNbinsX()); + } + + // *) Okay, set the title: + qv.fQvectorFlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else + qv.fQvectorList->Add(qv.fQvectorFlagsPro); - // b) Book multiplicity distributions in A and B, for each eta separation: - TString sEtaSep[2] = {"A", "B"}; // A <=> -eta , B <=> + eta - TString sEtaSep_long[2] = {Form("%.2f < #eta <", pc.fdParticleCuts[eEta][eMin]), Form("< #eta < %.2f", pc.fdParticleCuts[eEta][eMax])}; - // yes, here I define first the part of intervals as etaCutMin < eta < "subevent boundary", and "subevent" boundary < eta < etaCutMax - // Then below in the loop, I inject for "subevent boundary" the corresponding fEtaSeparationsValues (devided by 2, becaus it's symmetric round 0) - for (Int_t ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta - for (Int_t rs = 0; rs < 2; rs++) { // reco/sim - if (Skip(rs)) { - continue; + // b) Differential q-vectors booked dynamically: + // Remark: Here I am slighthly generalizing the great example provided at https://cplusplus.com/forum/articles/7459/ + + // b1) book qv.fqvector and qv.fqvectorEntries : + // dimensions: [eqvectorKine_N][gMaxNoBinsKine][gMaxHarmonic * gMaxCorrelator + 1][gMaxCorrelator + 1] => keep in sync with the documentation in the header + // here I am calculating for each dimensions how many entries I need in a given analysis + if (qv.fCalculateqvectorsKineAny) { + qv.fNumberOfKineBins.resize(eqvectorKine_N); // this is the light object, so I can hardwire here eqvectorKine_N + // then, in NumberOfKineVectors() i will store bins ONLY for qvectorKine which were requested. + // Therefore, final ordering in will correspond to the ordering in enum eqvectorKine ONLY if all kine vectors were requested. + // Otherwise, I fill here bins only for kine vectors which were requested, in consequtive order, starting from 0. + + int dim1 = eqvectorKine_N; + // int dim2 = number of kine bins => I calculate this one dynamically for each qVectorKine, see the loop below + NumberOfKineBins(); // here I calculate and fill qv.fNumberOfKineBins[ ... ] + int dim3 = gMaxHarmonic * gMaxCorrelator + 1; // TBI 20250601 I could dinamically allocate this one as well, but this will trigger another major re-design, and it's not rally a big deal + int dim4 = gMaxCorrelator + 1; // TBI 20250601 I could dinamically allocate this one as well, but this will trigger another major re-design, and it's not really a big deal + + qv.fqvector.resize(dim1); + qv.fqvectorEntries.resize(dim1); + + for (int i = 0; i < dim1; ++i) { // here I am looping over entries in enum eqvectorKine + if (qv.fCalculateqvectorsKine[i]) { + qv.fqvector[i].resize(qv.fNumberOfKineBins[i]); // yes, qv.fNumberOfKineBins[i] => for each qvectorkine I calculate and dynamically allocate only necessary bins + qv.fqvectorEntries[i].resize(qv.fNumberOfKineBins[i]); + } else { + // calculus for this kine variable is not needed, I am ironing out this dimension + qv.fqvector[i].resize(0); + qv.fqvectorEntries[i].resize(0); + } + + for (int j = 0; j < qv.fNumberOfKineBins[i]; ++j) { + if (qv.fCalculateqvectorsKine[i]) { + qv.fqvector[i][j].resize(dim3); + } else { + // calculus for this kine variable is not needed, I am ironing out this dimension + qv.fqvector[i][j].resize(0); + } + + for (int k = 0; k < dim3; ++k) { + if (qv.fCalculateqvectorsKine[i]) { + qv.fqvector[i][j][k].resize(dim4); + } else { + // calculus for this kine variable is not needed, I am ironing out this dimension + qv.fqvector[i][j][k].resize(0); + } + } } - for (Int_t ba = 0; ba < 2; ba++) { // before/after cuts - if (eBefore == ba) { - continue; // it make sense to fill these histos only for "eAfter", because Q-vectors are not filled for "eBefore" + } // for (int i = 0; i < dim1; ++i) + + // b2) book qv.fqabVector and qv.fmab (differential q-vectors with eta separations): + // dimensions: [-eta or +eta][eqvectorKine_N][global binNo][harmonic][eta separation] => keep in sync with the documentation in the header + // here I am calculating for each dimensions how many entries I need in a given analysis + + if (es.fCalculateEtaSeparations) { + int dim1 = 2; // -eta or eta + int dim2 = eqvectorKine_N; + // int dim3 = number of kine bins => I calculated this one dynamically for each qVectorKine, see the loop below + // NumberOfKineBins(); // here I calculate and fill qv.fNumberOfKineBins[ ... ] => I did it already above for qv.fqvector + int dim4 = gMaxHarmonic; + int dim5 = gMaxNumberEtaSeparations; + qv.fqabVector.resize(dim1); + qv.fmab.resize(dim1); + + for (int i = 0; i < dim1; ++i) { // here I am looping over -eta or eta + qv.fqabVector[i].resize(dim2); + qv.fmab[i].resize(dim2); + + for (int j = 0; j < dim2; ++j) { // here I am looping over entries in enum eqvectorKine + + if (qv.fCalculateqvectorsKineEtaSeparations[j]) { + qv.fqabVector[i][j].resize(qv.fNumberOfKineBins[j]); // yes, qv.fNumberOfKineBins[j] => for each qvectorkine I calculate and dynamically allocate only necessary bins + qv.fmab[i][j].resize(qv.fNumberOfKineBins[j]); + } else { + // calculus for this kine variable is not needed, I am ironing out this dimension + qv.fqabVector[i][j].resize(0); + qv.fmab[i][j].resize(0); + } + + for (int k = 0; k < qv.fNumberOfKineBins[j]; ++k) { + if (qv.fCalculateqvectorsKineEtaSeparations[j]) { + qv.fqabVector[i][j][k].resize(dim4); + qv.fmab[i][j][k].resize(dim5); // yes, directly dim5, because this one doesn't depend on harmonics + } else { + // calculus for this kine variable is not needed, I am ironing out this dimension + // I have already in the previous loop ironed out for qv.fCalculateqvectorsKineEtaSeparations[j] = false, so no need to do it here again + // TBI 20250620 validate what happens here + } + + for (int l = 0; l < dim4; ++l) { // loop over harmonics + if (qv.fCalculateqvectorsKineEtaSeparations[j] && !es.fEtaSeparationsSkipHarmonics[l]) { + qv.fqabVector[i][j][k][l].resize(dim5); + // no need to resize qv.fmab here, because this one doesn't depend on harmonics + } else { + // calculus for this kine variable is not needed, I am ironing out this dimension + // I have already in the previous loop ironed out for qv.fCalculateqvectorsKineEtaSeparations[j] = false, so no need to do it here again + // TBI 20250620 validate what happens here + } + } // for (int l = 0; l < dim4; ++l) + } // for (int k = 0; k < qv.fNumberOfKineBins[j]; ++k) + } // for (int j = 0; j < dim2; ++j) + } // for (int i = 0; i < dim1; ++i) + } // if(es.fCalculateEtaSeparations) + } // if(qv.fCalculateqvectorsKineAny) + + // c) Book multiplicity distributions in A and B, for each eta separation: + if (es.fCalculateEtaSeparations) { + TString sEtaSep[2] = {"A", "B"}; // A <=> -eta , B <=> + eta + TString sEtaSepLong[2] = {TString::Format("%.2f < #eta <", pc.fdParticleCuts[eEta][eMin]), TString::Format("< #eta < %.2f", pc.fdParticleCuts[eEta][eMax])}; + // yes, here I define first the part of intervals as etaCutMin < eta < "subevent boundary", and "subevent" boundary < eta < etaCutMax + // Then below in the loop, I inject for "subevent boundary" the corresponding fEtaSeparationsValues (divided by 2, becaus it's symmetric round 0) + for (int ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta + for (int rs = 0; rs < 2; rs++) { // reco/sim + if (Skip(rs)) { + continue; } - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation - qv.fMabDist[ab][rs][ba][e] = new TH1F(Form("fMabDist[%s][%s][%s][%d]", sEtaSep[ab].Data(), gc.srs[rs].Data(), gc.sba[ba].Data(), e), - Form("%s, %s, %s, %s", "__RUN_NUMBER__", - 0 == ab ? Form("%s -%.2f", sEtaSep_long[ab].Data(), es.fEtaSeparationsValues[e] / 2.) : Form("%.2f %s", es.fEtaSeparationsValues[e] / 2., sEtaSep_long[ab].Data()), gc.srs_long[rs].Data(), gc.sba_long[ba].Data()), - static_cast(eh.fEventHistogramsBins[eMultiplicity][0]), eh.fEventHistogramsBins[eMultiplicity][1], eh.fEventHistogramsBins[eMultiplicity][2]); // TBI 20241207 I have hardwired in this constructor "0 == ab", this can backfire... - qv.fMabDist[ab][rs][ba][e]->SetLineColor(ec.fBeforeAfterColor[ba]); - qv.fMabDist[ab][rs][ba][e]->SetFillColor(ec.fBeforeAfterColor[ba] - 10); - qv.fMabDist[ab][rs][ba][e]->GetXaxis()->SetTitle("subevent multiplicity (sum of particle weights)"); - qv.fMabDist[ab][rs][ba][e]->SetMinimum(1.e-4); // so that I can switch to log scale, even if some bins are empty - // Remark: For empty histograms, when plotting interactively, because of this line, I will get - // E-TCanvas::Range: illegal world coordinates range .... - // But it's harmless, because in any case I do not care about the content of empty histogram... - qv.fMabDist[ab][rs][ba][e]->SetOption("hist"); // do not plot marker and error (see BanishmentLoopOverParticles why errors are not reliable) for each bin, only content + filled area. - qv.fQvectorList->Add(qv.fMabDist[ab][rs][ba][e]); + for (int ba = 0; ba < 2; ba++) { // before/after cuts + if (eBefore == ba) { + continue; // it make sense to fill these histos only for "eAfter", because Q-vectors are not filled for "eBefore" + } + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + qv.fMabDist[ab][rs][ba][e] = new TH1F(Form("fMabDist[%s][%s][%s][%d]", sEtaSep[ab].Data(), gc.srs[rs].Data(), gc.sba[ba].Data(), e), + Form("%s, %s, %s, %s", "__RUN_NUMBER__", + 0 == ab ? Form("%s -%.2f", sEtaSepLong[ab].Data(), es.fEtaSeparationsValues[e] / 2.) : Form("%.2f %s", es.fEtaSeparationsValues[e] / 2., sEtaSepLong[ab].Data()), gc.srsLong[rs].Data(), gc.sbaLong[ba].Data()), + static_cast(eh.fEventHistogramsBins[eMultiplicity][0]), eh.fEventHistogramsBins[eMultiplicity][1], eh.fEventHistogramsBins[eMultiplicity][2]); // TBI 20241207 I have hardwired in this constructor "0 == ab", this can backfire... + qv.fMabDist[ab][rs][ba][e]->SetLineColor(ec.fBeforeAfterColor[ba]); + qv.fMabDist[ab][rs][ba][e]->SetFillColor(ec.fBeforeAfterColor[ba] - 10); + qv.fMabDist[ab][rs][ba][e]->GetXaxis()->SetTitle("subevent multiplicity (sum of particle weights)"); + qv.fMabDist[ab][rs][ba][e]->SetMinimum(1.e-4); // so that I can switch to log scale, even if some bins are empty + // Remark: For empty histograms, when plotting interactively, because of this line, I will get + // E-TCanvas::Range: illegal world coordinates range .... + // But it's harmless, because in any case I do not care about the content of empty histogram... + qv.fMabDist[ab][rs][ba][e]->SetOption("hist"); // do not plot marker and error (see BanishmentLoopOverParticles why errors are not reliable) for each bin, only content + filled area. + qv.fQvectorList->Add(qv.fMabDist[ab][rs][ba][e]); + } } } } - } + } // if (es.fCalculateEtaSeparations) { // c) ... @@ -3399,36 +5702,110 @@ void BookQvectorHistograms() ExitFunction(__FUNCTION__); } -} // void BookQvectorHistograms() +} // void bookQvectorHistograms() //============================================================ -void BookCorrelationsHistograms() +void NumberOfKineBins() { - // Book all correlations histograms. - - // a) Book the profile holding flags; - // b) Common local labels; - // c) Histograms; - // d) Few quick insanity checks on booking. + // Helper function called only in void bookQvectorHistograms(), if kine analysis was requested. + // I calculate for each requested kine vector the number of kine bins => this is stored in dynamically allocated array qv.fNumberOfKineBins. if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // a) Book the profile holding flags: - mupa.fCorrelationsFlagsPro = new TProfile("fCorrelationsFlagsPro", - "flags for correlations", 1, 0., 1.); - mupa.fCorrelationsFlagsPro->SetStats(kFALSE); - mupa.fCorrelationsFlagsPro->SetLineColor(eColor); - mupa.fCorrelationsFlagsPro->SetFillColor(eFillColor); - mupa.fCorrelationsFlagsPro->GetXaxis()->SetLabelSize(0.05); - mupa.fCorrelationsFlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateCorrelations"); - mupa.fCorrelationsFlagsPro->Fill(0.5, mupa.fCalculateCorrelations); + // 1D kine: + if (qv.fCalculateqvectorsKine[PTq]) { + qv.fNumberOfKineBins[PTq] = res.fResultsPro[AFO_PT]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it in the loop below + } + if (qv.fCalculateqvectorsKine[ETAq]) { + qv.fNumberOfKineBins[ETAq] = res.fResultsPro[AFO_ETA]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it in the loop below + } + if (qv.fCalculateqvectorsKine[CHARGEq]) { + qv.fNumberOfKineBins[CHARGEq] = res.fResultsPro[AFO_CHARGE]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it in the loop below + } // ... - mupa.fCorrelationsList->Add(mupa.fCorrelationsFlagsPro); - if (!mupa.fCalculateCorrelations) { + // 2D kine: + if (qv.fCalculateqvectorsKine[PT_ETAq]) { + qv.fNumberOfKineBins[PT_ETAq] = (res.fResultsPro2D[AfoKineMap2D(PT_ETAq)]->GetNbinsX() + 2) * (res.fResultsPro2D[AfoKineMap2D(PT_ETAq)]->GetNbinsY() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + } + if (qv.fCalculateqvectorsKine[PT_CHARGEq]) { + qv.fNumberOfKineBins[PT_CHARGEq] = (res.fResultsPro2D[AfoKineMap2D(PT_CHARGEq)]->GetNbinsX() + 2) * (res.fResultsPro2D[AfoKineMap2D(PT_CHARGEq)]->GetNbinsY() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + } + if (qv.fCalculateqvectorsKine[ETA_CHARGEq]) { + qv.fNumberOfKineBins[ETA_CHARGEq] = (res.fResultsPro2D[AfoKineMap2D(ETA_CHARGEq)]->GetNbinsX() + 2) * (res.fResultsPro2D[AfoKineMap2D(ETA_CHARGEq)]->GetNbinsY() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + } + // ... + + // 3D kine: + if (qv.fCalculateqvectorsKine[PT_ETA_CHARGEq]) { + qv.fNumberOfKineBins[PT_ETA_CHARGEq] = (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]->GetNbinsX() + 2) * (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]->GetNbinsY() + 2) * (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]->GetNbinsZ() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + } + // ... + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void NumberOfKineBins() + +//============================================================ + +void bookCorrelationsHistograms() +{ + // Book all correlations histograms. + + // a) Book the profile holding flags; + // b) Common local labels; + // c) Histograms; + // d) Few quick insanity checks on booking. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // a) Book the profile holding flags: + mupa.fCorrelationsFlagsPro = new TProfile("fCorrelationsFlagsPro", + "flags for correlations", 1, 0., 1.); + mupa.fCorrelationsFlagsPro->SetStats(false); + mupa.fCorrelationsFlagsPro->SetLineColor(eColor); + mupa.fCorrelationsFlagsPro->SetFillColor(eFillColor); + mupa.fCorrelationsFlagsPro->GetXaxis()->SetLabelSize(0.05); + + if (tc.fUseSetBinLabel) { + mupa.fCorrelationsFlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateCorrelations"); + mupa.fCorrelationsFlagsPro->Fill(0.5, mupa.fCalculateCorrelations); + + // ... + + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fCalculateCorrelations; ", 1); + mupa.fCorrelationsFlagsPro->Fill(0.5, static_cast(mupa.fCalculateCorrelations)); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != mupa.fCorrelationsFlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != mupa.fCorrelationsFlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), mupa.fCorrelationsFlagsPro->GetNbinsX()); + } + + // *) Okay, set the title: + mupa.fCorrelationsFlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else + + mupa.fCorrelationsList->Add(mupa.fCorrelationsFlagsPro); + + if (!mupa.fCalculateCorrelations) { return; } @@ -3441,50 +5818,35 @@ void BookCorrelationsHistograms() "#varphi_{7}-#varphi_{8}"}; // c) Histograms: - for (Int_t k = 0; k < 4; k++) // order [2p=0,4p=1,6p=2,8p=3] + for (int k = 0; k < 4; k++) // order [2p=0,4p=1,6p=2,8p=3] { - for (Int_t n = 0; n < gMaxHarmonic; n++) // harmonic + for (int n = 0; n < gMaxHarmonic; n++) // harmonic { - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { + for (int v = 0; v < eAsFunctionOf_N; v++) { // decide what is booked, then later valid pointer to fCorrelationsPro[k][n][v] is used as a boolean, in the standard way: - if (AFO_INTEGRATED == v && !mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTEGRATED]) { - continue; - } - if (AFO_MULTIPLICITY == v && !mupa.fCalculateCorrelationsAsFunctionOf[AFO_MULTIPLICITY]) { - continue; - } - if (AFO_CENTRALITY == v && !mupa.fCalculateCorrelationsAsFunctionOf[AFO_CENTRALITY]) { - continue; - } - if (AFO_PT == v && !mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT]) { - continue; - } - if (AFO_ETA == v && !mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA]) { - continue; - } - if (AFO_OCCUPANCY == v && !mupa.fCalculateCorrelationsAsFunctionOf[AFO_OCCUPANCY]) { - continue; - } - if (AFO_INTERACTIONRATE == v && !mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTERACTIONRATE]) { - continue; - } - if (AFO_CURRENTRUNDURATION == v && !mupa.fCalculateCorrelationsAsFunctionOf[AFO_CURRENTRUNDURATION]) { + if (!mupa.fCalculateCorrelationsAsFunctionOf[v]) { continue; } if (!res.fResultsPro[v]) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d : fResultsPro[%d] is NULL, this shall never happen, but apparently it happened... \033[0m", __FUNCTION__, __LINE__, v); + } + + if (tc.fUseClone) { + mupa.fCorrelationsPro[k][n][v] = reinterpret_cast(res.fResultsPro[v]->Clone(Form("fCorrelationsPro[%d][%d][%s]", k, n, res.fResultsProRawName[v].Data()))); // yes + } else { + mupa.fCorrelationsPro[k][n][v] = new TProfile(Form("fCorrelationsPro[%d][%d][%s]", k, n, res.fResultsProRawName[v].Data()), "", res.fResultsPro[v]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[v]->GetXaxis()->GetXbins()->GetArray()); } - mupa.fCorrelationsPro[k][n][v] = reinterpret_cast(res.fResultsPro[v]->Clone(Form("fCorrelationsPro[%d][%d][%s]", k, n, res.fResultsProRawName[v].Data()))); // yes - mupa.fCorrelationsPro[k][n][v]->SetStats(kFALSE); + + mupa.fCorrelationsPro[k][n][v]->SetStats(false); mupa.fCorrelationsPro[k][n][v]->Sumw2(); mupa.fCorrelationsPro[k][n][v]->GetXaxis()->SetTitle(FancyFormatting(res.fResultsProXaxisTitle[v].Data())); mupa.fCorrelationsPro[k][n][v]->GetYaxis()->SetTitle(Form("#LT#LTcos[%s(%s)]#GT#GT", 1 == n + 1 ? "" : Form("%d", n + 1), oVariable[k].Data())); mupa.fCorrelationsList->Add(mupa.fCorrelationsPro[k][n][v]); } - } // for (Int_t n = 0; n < gMaxHarmonic; n++) // harmonic - } // for (Int_t k = 0; k < 4; k++) // order [2p=0,4p=1,6p=2,8p=3] + } // for (int n = 0; n < gMaxHarmonic; n++) // harmonic + } // for (int k = 0; k < 4; k++) // order [2p=0,4p=1,6p=2,8p=3] // d) Few quick insanity checks on booking: if (mupa.fCorrelationsPro[0][0][AFO_INTEGRATED] && !TString(mupa.fCorrelationsPro[0][0][AFO_INTEGRATED]->GetXaxis()->GetTitle()).EqualTo("integrated")) { @@ -3498,47 +5860,150 @@ void BookCorrelationsHistograms() ExitFunction(__FUNCTION__); } -} // BookCorrelationsHistograms() +} // bookCorrelationsHistograms() //============================================================ -void BookWeightsHistograms() +void bookWeightsHistograms() { // Book all objects for particle weights. // a) Book the profile holding flags; // b) Histograms for integrated weights; - // c) Histograms for differential weights. + // c) Histograms for differential weights; + // d) Sparse histograms for differential phi weights. if (tc.fVerbose) { StartFunction(__FUNCTION__); } // a) Book the profile holding flags: - pw.fWeightsFlagsPro = - new TProfile("fWeightsFlagsPro", "flags for particle weights", 5, 0., 5.); - pw.fWeightsFlagsPro->SetStats(kFALSE); + pw.fWeightsFlagsPro = new TProfile("fWeightsFlagsPro", "flags for particle weights", 13, 0., 13.); + pw.fWeightsFlagsPro->SetStats(false); pw.fWeightsFlagsPro->SetLineColor(eColor); pw.fWeightsFlagsPro->SetFillColor(eFillColor); - pw.fWeightsFlagsPro->GetXaxis()->SetLabelSize(0.05); - pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(1, "w_{#varphi}"); - pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(2, "w_{p_{t}}"); - pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(3, "w_{#eta}"); - pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(4, "(w_{#varphi})_{| p_{T}}"); // TBI 20241019 not sure if this is the final notation, keep in sync with void SetDiffWeightsHist(...) - pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(5, "(w_{#varphi})_{| #eta}"); // TBI 20241019 not sure if this is the final notation, keep in sync with void SetDiffWeightsHist(...) - - for (Int_t w = 0; w < eWeights_N; w++) // use weights [phi,pt,eta] + pw.fWeightsFlagsPro->GetXaxis()->SetLabelSize(0.035); + + if (tc.fUseSetBinLabel) { + + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(1, "w_{#varphi}"); + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(2, "w_{p_{t}}"); + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(3, "w_{#eta}"); + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(4, "(w_{#varphi})_{| p_{T}}"); // TBI 20241019 not sure if this is the final notation, keep in sync with void SetDiffWeightsHist(...) + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(5, "(w_{#varphi})_{| #eta}"); // TBI 20241019 not sure if this is the final notation, keep in sync with void SetDiffWeightsHist(...) + + // **) differential phi weights using sparse: + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(6, "(w_{#varphi})_{phi axis (sparse)}"); + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(7, "(w_{#varphi})_{p_{T} axis (sparse)}"); + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(8, "(w_{#varphi})_{#eta axis (sparse)}"); + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(9, "(w_{#varphi})_{charge axis (sparse)}"); + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(10, "(w_{#varphi})_{centrality axis (sparse)}"); + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(11, "(w_{#varphi})_{VertexZ axis (sparse)}"); + + // **) differential pt weights using sparse: + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(12, "(w_{p_{T}})_{pt axis (sparse)}"); + + // **) differential eta weights using sparse: + pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(13, "(w_{#eta})_{eta axis (sparse)}"); + + } else { + + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:w_{#varphi}; ", 1); + yAxisTitle += TString::Format("%d:w_{p_{t}}; ", 2); + yAxisTitle += TString::Format("%d:w_{#eta}; ", 3); + yAxisTitle += TString::Format("%d:(w_{#varphi})_{| p_{T}}; ", 4); + yAxisTitle += TString::Format("%d:(w_{#varphi})_{| #eta}; ", 5); + + // **) differential phi weights using sparse: + yAxisTitle += TString::Format("%d:(w_{#varphi})_{phi axis (sparse)}; ", 6); + yAxisTitle += TString::Format("%d:(w_{#varphi})_{p_{T} axis (sparse)}; ", 7); + yAxisTitle += TString::Format("%d:(w_{#varphi})_{#eta axis (sparse)}; ", 8); + yAxisTitle += TString::Format("%d:(w_{#varphi})_{charge axis (sparse)}; ", 9); + yAxisTitle += TString::Format("%d:(w_{#varphi})_{centrality axis (sparse)}; ", 10); + yAxisTitle += TString::Format("%d:(w_{#varphi})_{VertexZ axis (sparse)}; ", 11); + + // **) differential pt weights using sparse: + yAxisTitle += TString::Format("%d:(w_{p_{T}})_{pt axis (sparse)}; ", 12); + + // **) differential eta weights using sparse: + yAxisTitle += TString::Format("%d:(w_{#eta})_{eta axis (sparse)}; ", 13); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != pw.fWeightsFlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != pw.fWeightsFlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), pw.fWeightsFlagsPro->GetNbinsX()); + } + + // *) Okay, set the title: + pw.fWeightsFlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else + + for (int w = 0; w < eWeights_N; w++) // use weights [phi,pt,eta] { if (pw.fUseWeights[w]) { pw.fWeightsFlagsPro->Fill(w + 0.5, 1.); } } - for (Int_t w = 0; w < eDiffWeights_N; w++) // use differential weights [phipt,phieta,...] - { - if (pw.fUseDiffWeights[w]) { - pw.fWeightsFlagsPro->Fill(w + 3.5, 1.); // TBI 20231026 This hadrwired offset of +3.5 will bite me sooner or later, but nevermind now... - } + + // **) use differential weights [phipt,phieta,...] TBI 20250514 obsolete + if (pw.fUseDiffWeights[wPHIPT]) { + pw.fWeightsFlagsPro->Fill(3.5, 1.); + } + if (pw.fUseDiffWeights[wPHIETA]) { + pw.fWeightsFlagsPro->Fill(4.5, 1.); + } + + // **) differential phi weights using sparse: + if (pw.fUseDiffPhiWeights[wPhiPhiAxis]) { + pw.fWeightsFlagsPro->Fill(5.5, 1.); + } + if (pw.fUseDiffPhiWeights[wPhiPtAxis]) { + pw.fWeightsFlagsPro->Fill(6.5, 1.); + } + if (pw.fUseDiffPhiWeights[wPhiEtaAxis]) { + pw.fWeightsFlagsPro->Fill(7.5, 1.); + } + if (pw.fUseDiffPhiWeights[wPhiChargeAxis]) { + pw.fWeightsFlagsPro->Fill(8.5, 1.); + } + if (pw.fUseDiffPhiWeights[wPhiCentralityAxis]) { + pw.fWeightsFlagsPro->Fill(9.5, 1.); + } + if (pw.fUseDiffPhiWeights[wPhiVertexZAxis]) { + pw.fWeightsFlagsPro->Fill(10.5, 1.); + } + + // **) differential pt weights using sparse: + if (pw.fUseDiffPtWeights[wPtPtAxis]) { + pw.fWeightsFlagsPro->Fill(11.5, 1.); + } + if (pw.fUseDiffPhiWeights[wPtChargeAxis]) { + pw.fWeightsFlagsPro->Fill(12.5, 1.); + } + if (pw.fUseDiffPhiWeights[wPtCentralityAxis]) { + pw.fWeightsFlagsPro->Fill(13.5, 1.); + } + + // **) differential eta weights using sparse: + if (pw.fUseDiffEtaWeights[wEtaEtaAxis]) { + pw.fWeightsFlagsPro->Fill(14.5, 1.); } + if (pw.fUseDiffPhiWeights[wEtaChargeAxis]) { + pw.fWeightsFlagsPro->Fill(15.5, 1.); + } + if (pw.fUseDiffPhiWeights[wEtaCentralityAxis]) { + pw.fWeightsFlagsPro->Fill(16.5, 1.); + } + pw.fWeightsList->Add(pw.fWeightsFlagsPro); // b) Histograms for integrated weights: @@ -3549,15 +6014,18 @@ void BookWeightsHistograms() // c) Histograms for differential weights: // Same comment applies as for b) => add histograms to the list, only after they are cloned from external files. + // d) Sparse histograms for differential phi weights: + // Same comment applies as for b) => add sparse histograms to the list, only after they are cloned from external files. + if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void BookWeightsHistograms() +} // void bookWeightsHistograms() //============================================================ -void BookCentralityWeightsHistograms() +void bookCentralityWeightsHistograms() { // Book all objects for centrality weights. @@ -3570,12 +6038,38 @@ void BookCentralityWeightsHistograms() // a) Book the profile holding flags: cw.fCentralityWeightsFlagsPro = - new TProfile("fWeightsFlagsPro", "flags for centrality weights", 1, 0., 1.); - cw.fCentralityWeightsFlagsPro->SetStats(kFALSE); + new TProfile("fCentralityWeightsFlagsPro", "flags for centrality weights", 1, 0., 1.); + cw.fCentralityWeightsFlagsPro->SetStats(false); cw.fCentralityWeightsFlagsPro->SetLineColor(eColor); cw.fCentralityWeightsFlagsPro->SetFillColor(eFillColor); cw.fCentralityWeightsFlagsPro->GetXaxis()->SetLabelSize(0.05); - cw.fCentralityWeightsFlagsPro->GetXaxis()->SetBinLabel(1, "TBI 20241118 I need to store here name of centrality esimator for which centrality weights were calculated"); + + if (tc.fUseSetBinLabel) { + cw.fCentralityWeightsFlagsPro->GetXaxis()->SetBinLabel(1, TString::Format("Use centrality weights for estimator %s", ec.fsEventCuts[eCentralityEstimator].Data())); + + // ... + + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:Use centrality weights for estimator %s; ", 1, ec.fsEventCuts[eCentralityEstimator].Data()); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != cw.fCentralityWeightsFlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != cw.fCentralityWeightsFlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), cw.fCentralityWeightsFlagsPro->GetNbinsX()); + } + + // *) Okay, set the title: + cw.fCentralityWeightsFlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + } + if (cw.fUseCentralityWeights) { cw.fCentralityWeightsFlagsPro->Fill(0.5, 1.); // TBI 20241118 shall I automate this? } @@ -3590,16 +6084,16 @@ void BookCentralityWeightsHistograms() ExitFunction(__FUNCTION__); } -} // void BookCentralityWeightsHistograms() +} // void bookCentralityWeightsHistograms() //============================================================ -void BookNestedLoopsHistograms() +void bookNestedLoopsHistograms() { // Book all nested loops histograms. // a) Book the profile holding flags; - // b) Common local labels (keep 'em in sync with BookCorrelationsHistograms()); + // b) Common local labels (keep 'em in sync with bookCorrelationsHistograms()); // c) Book what needs to be booked; // d) Few quick insanity checks on booking. @@ -3610,18 +6104,54 @@ void BookNestedLoopsHistograms() // a) Book the profile holding flags: nl.fNestedLoopsFlagsPro = new TProfile("fNestedLoopsFlagsPro", "flags for nested loops", 4, 0., 4.); - nl.fNestedLoopsFlagsPro->SetStats(kFALSE); + nl.fNestedLoopsFlagsPro->SetStats(false); nl.fNestedLoopsFlagsPro->SetLineColor(eColor); nl.fNestedLoopsFlagsPro->SetFillColor(eFillColor); nl.fNestedLoopsFlagsPro->GetXaxis()->SetLabelSize(0.03); - nl.fNestedLoopsFlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateNestedLoops"); - nl.fNestedLoopsFlagsPro->Fill(0.5, nl.fCalculateNestedLoops); - nl.fNestedLoopsFlagsPro->GetXaxis()->SetBinLabel(2, "fCalculateCustomNestedLoops"); - nl.fNestedLoopsFlagsPro->Fill(1.5, nl.fCalculateCustomNestedLoops); - nl.fNestedLoopsFlagsPro->GetXaxis()->SetBinLabel(3, "fCalculateKineCustomNestedLoops"); - nl.fNestedLoopsFlagsPro->Fill(2.5, nl.fCalculateKineCustomNestedLoops); - nl.fNestedLoopsFlagsPro->GetXaxis()->SetBinLabel(4, "fMaxNestedLoop"); - nl.fNestedLoopsFlagsPro->Fill(3.5, nl.fMaxNestedLoop); + + if (tc.fUseSetBinLabel) { + nl.fNestedLoopsFlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateNestedLoops"); + nl.fNestedLoopsFlagsPro->Fill(0.5, nl.fCalculateNestedLoops); + nl.fNestedLoopsFlagsPro->GetXaxis()->SetBinLabel(2, "fCalculateCustomNestedLoops"); + nl.fNestedLoopsFlagsPro->Fill(1.5, nl.fCalculateCustomNestedLoops); + nl.fNestedLoopsFlagsPro->GetXaxis()->SetBinLabel(3, "fCalculateKineCustomNestedLoops"); + nl.fNestedLoopsFlagsPro->Fill(2.5, nl.fCalculateKineCustomNestedLoops); + nl.fNestedLoopsFlagsPro->GetXaxis()->SetBinLabel(4, "fMaxNestedLoop"); + nl.fNestedLoopsFlagsPro->Fill(3.5, nl.fMaxNestedLoop); + + // ... + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fCalculateNestedLoops; ", 1); + nl.fNestedLoopsFlagsPro->Fill(0.5, nl.fCalculateNestedLoops); + + yAxisTitle += TString::Format("%d:fCalculateCustomNestedLoops; ", 2); + nl.fNestedLoopsFlagsPro->Fill(1.5, nl.fCalculateCustomNestedLoops); + + yAxisTitle += TString::Format("%d:fCalculateKineCustomNestedLoops; ", 3); + nl.fNestedLoopsFlagsPro->Fill(2.5, nl.fCalculateKineCustomNestedLoops); + + yAxisTitle += TString::Format("%d:fMaxNestedLoop; ", 4); + nl.fNestedLoopsFlagsPro->Fill(3.5, nl.fMaxNestedLoop); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != nl.fNestedLoopsFlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != nl.fNestedLoopsFlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), nl.fNestedLoopsFlagsPro->GetNbinsX()); + } + + // *) Okay, set the title: + nl.fNestedLoopsFlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else + nl.fNestedLoopsList->Add(nl.fNestedLoopsFlagsPro); if (!(nl.fCalculateNestedLoops || nl.fCalculateCustomNestedLoops || nl.fCalculateKineCustomNestedLoops)) { @@ -3631,25 +6161,94 @@ void BookNestedLoopsHistograms() // *) Book containers for integrated nested loops: if (nl.fCalculateNestedLoops || nl.fCalculateCustomNestedLoops) { - const Int_t iMaxSize = 2e4; + const int iMaxSize = 2e4; nl.ftaNestedLoops[0] = new TArrayD(iMaxSize); // ebe container for azimuthal angles nl.ftaNestedLoops[1] = new TArrayD(iMaxSize); // ebe container for particle weights (product of all) } // *) Book containers for differential nested loops: if (nl.fCalculateKineCustomNestedLoops) { - const Int_t iMaxSize = 2e4; - for (Int_t b = 0; b < res.fResultsPro[AFO_PT]->GetNbinsX(); b++) { + + const int iMaxSize = 2e4; // this is roughly number of particles per bin, it shouldn't exceed this threshold + int nBins = -1; + + // 1D kine: + // **) vs. pt: + nBins = res.fResultsPro[AFO_PT]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip later + for (int b = 0; b < nBins; b++) { nl.ftaNestedLoopsKine[PTq][b][0] = new TArrayD(iMaxSize); nl.ftaNestedLoopsKine[PTq][b][1] = new TArrayD(iMaxSize); } - for (Int_t b = 0; b < res.fResultsPro[AFO_ETA]->GetNbinsX(); b++) { + + // **) vs. eta: + nBins = res.fResultsPro[AFO_ETA]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it later + for (int b = 0; b < nBins; b++) { nl.ftaNestedLoopsKine[ETAq][b][0] = new TArrayD(iMaxSize); nl.ftaNestedLoopsKine[ETAq][b][1] = new TArrayD(iMaxSize); } - } - // b) Common local labels (keep 'em in sync with BookCorrelationsHistograms()) + // **) vs. charge: + nBins = res.fResultsPro[AFO_CHARGE]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it later + for (int b = 0; b < nBins; b++) { + nl.ftaNestedLoopsKine[CHARGEq][b][0] = new TArrayD(iMaxSize); + nl.ftaNestedLoopsKine[CHARGEq][b][1] = new TArrayD(iMaxSize); + } + + // ... + + // 2D kine: + // **) vs. (pt,eta): + if (res.fResultsPro2D[AfoKineMap2D(PT_ETAq)]) { + // this is safe, because this one shall be booked if any of Correlations, Test0, EtaSeparations, etc., was requested + nBins = (res.fResultsPro2D[AfoKineMap2D(PT_ETAq)]->GetNbinsX() + 2) * (res.fResultsPro2D[AfoKineMap2D(PT_ETAq)]->GetNbinsY() + 2); + // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { // loop over lineralized global bins + nl.ftaNestedLoopsKine[PT_ETAq][b][0] = new TArrayD(iMaxSize); + nl.ftaNestedLoopsKine[PT_ETAq][b][1] = new TArrayD(iMaxSize); + } + } + + // **) vs. (pt,charge): + if (res.fResultsPro2D[AfoKineMap2D(PT_CHARGEq)]) { + // this is safe, because this one shall be booked if any of Correlations, Test0, EtaSeparations, etc., was requested + nBins = (res.fResultsPro2D[AfoKineMap2D(PT_CHARGEq)]->GetNbinsX() + 2) * (res.fResultsPro2D[AfoKineMap2D(PT_CHARGEq)]->GetNbinsY() + 2); + // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { // loop over lineralized global bins + nl.ftaNestedLoopsKine[PT_CHARGEq][b][0] = new TArrayD(iMaxSize); + nl.ftaNestedLoopsKine[PT_CHARGEq][b][1] = new TArrayD(iMaxSize); + } + } + + // **) vs. (eta,charge): + if (res.fResultsPro2D[AfoKineMap2D(ETA_CHARGEq)]) { + // this is safe, because this one shall be booked if any of Correlations, Test0, EtaSeparations, etc., was requested + nBins = (res.fResultsPro2D[AfoKineMap2D(ETA_CHARGEq)]->GetNbinsX() + 2) * (res.fResultsPro2D[AfoKineMap2D(ETA_CHARGEq)]->GetNbinsY() + 2); + // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { // loop over lineralized global bins + nl.ftaNestedLoopsKine[ETA_CHARGEq][b][0] = new TArrayD(iMaxSize); + nl.ftaNestedLoopsKine[ETA_CHARGEq][b][1] = new TArrayD(iMaxSize); + } + } + + // ... + + // 3D kine: + // **) vs. (pt,eta,charge): + if (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]) { + // this is safe, because this one shall be booked if any of Correlations, Test0, EtaSeparations, etc., was requested + nBins = (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]->GetNbinsX() + 2) * (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]->GetNbinsY() + 2) * (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]->GetNbinsZ() + 2); + // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { // loop over lineralized global bins + nl.ftaNestedLoopsKine[PT_ETA_CHARGEq][b][0] = new TArrayD(iMaxSize); + nl.ftaNestedLoopsKine[PT_ETA_CHARGEq][b][1] = new TArrayD(iMaxSize); + } + } + + // ... + + } // if (nl.fCalculateKineCustomNestedLoops) + + // b) Common local labels (keep 'em in sync with bookCorrelationsHistograms()) TString oVariable[4] = { "#varphi_{1}-#varphi_{2}", "#varphi_{1}+#varphi_{2}-#varphi_{3}-#varphi_{4}", @@ -3661,47 +6260,46 @@ void BookNestedLoopsHistograms() if (!(nl.fCalculateNestedLoops)) { // TBI 20240404 for the time being, I can keep it here, but eventualy it will have to go elsewhere return; } - for (Int_t k = 0; k < 4; k++) // order [2p=0,4p=1,6p=2,8p=3] + for (int k = 0; k < 4; k++) // order [2p=0,4p=1,6p=2,8p=3] { // TBI 20240405 I could break here, with respect to what nl.fMaxNestedLoop was set to - for (Int_t n = 0; n < gMaxHarmonic; n++) // harmonic + for (int n = 0; n < gMaxHarmonic; n++) // harmonic { - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { - - // if(PTKINE == v && !fCalculatePtCorrelations){continue;} - // if(ETAKINE == v && !fCalculateEtaCorrelations){continue;} + for (int v = 0; v < eAsFunctionOf_N; v++) { if (!res.fResultsPro[v]) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - nl.fNestedLoopsPro[k][n][v] = reinterpret_cast(res.fResultsPro[v]->Clone(Form("fNestedLoopsPro[%d][%d][%d]", k, n, v))); // yes + + if (tc.fUseClone) { + nl.fNestedLoopsPro[k][n][v] = reinterpret_cast(res.fResultsPro[v]->Clone(Form("fNestedLoopsPro[%d][%d][%d]", k, n, v))); // yes + } else { + nl.fNestedLoopsPro[k][n][v] = new TProfile(Form("fNestedLoopsPro[%d][%d][%s]", k, n, res.fResultsProRawName[v].Data()), "", res.fResultsPro[v]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[v]->GetXaxis()->GetXbins()->GetArray()); + } + nl.fNestedLoopsPro[k][n][v]->SetTitle(Form("#LT#LTcos[%s(%s)]#GT#GT", 1 == n + 1 ? "" : Form("%d", n + 1), oVariable[k].Data())); - nl.fNestedLoopsPro[k][n][v]->SetStats(kFALSE); + nl.fNestedLoopsPro[k][n][v]->SetStats(false); nl.fNestedLoopsPro[k][n][v]->Sumw2(); nl.fNestedLoopsPro[k][n][v]->GetXaxis()->SetTitle(res.fResultsProXaxisTitle[v].Data()); - /* - if(fUseFixedNumberOfRandomlySelectedTracks && 1==v) // just a warning - for the meaning of multiplicity in this special case - { - nl.fNestedLoopsPro[k][n][1]->GetXaxis()->SetTitle("WARNING: for each - multiplicity, fFixedNumberOfRandomlySelectedTracks is selected randomly - in Q-vector"); + if (tc.fFixedNumberOfRandomlySelectedTracks > 0 && AFO_MULTIPLICITY == v) { // just a warning for the meaning of multiplicity in this special case + nl.fNestedLoopsPro[k][n][v]->GetXaxis()->SetTitle("WARNING: for each multiplicity, fFixedNumberOfRandomlySelectedTracks is selected randomly in Q-vector"); } - */ nl.fNestedLoopsList->Add(nl.fNestedLoopsPro[k][n][v]); - } // for(Int_t v=0;v<5;v++) // variable [0=integrated,1=vs. + } // for(int v=0;v<5;v++) // variable [0=integrated,1=vs. // multiplicity,2=vs. centrality] - } // for (Int_t n = 0; n < gMaxHarmonic; n++) // harmonic - } // for (Int_t k = 0; k < 4; k++) // order [2p=0,4p=1,6p=2,8p=3] + } // for (int n = 0; n < gMaxHarmonic; n++) // harmonic + } // for (int k = 0; k < 4; k++) // order [2p=0,4p=1,6p=2,8p=3] // d) Few quick insanity checks on booking: if (nl.fNestedLoopsPro[0][0][AFO_INTEGRATED] && !TString(nl.fNestedLoopsPro[0][0][AFO_INTEGRATED]->GetXaxis()->GetTitle()).EqualTo("integrated")) { + LOGF(info, "\033[1;33mnl.fNestedLoopsPro[0][0][AFO_INTEGRATED]->GetXaxis()->GetTitle() = %s \033[0m", nl.fNestedLoopsPro[0][0][AFO_INTEGRATED]->GetXaxis()->GetTitle()); LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); // ordering in enum eAsFunctionOf is not the same as in TString fResultsProXaxisTitle[eAsFunctionOf_N] } - if (nl.fNestedLoopsPro[0][0][AFO_PT] && !TString(nl.fNestedLoopsPro[0][0][AFO_PT]->GetXaxis()->GetTitle()).EqualTo("p_{T}")) { + if (nl.fNestedLoopsPro[0][0][AFO_PT] && !TString(nl.fNestedLoopsPro[0][0][AFO_PT]->GetXaxis()->GetTitle()).EqualTo("pt")) { // I do not need here fancy formatting + LOGF(info, "\033[1;33mnl.fNestedLoopsPro[0][0][AFO_PT]->GetXaxis()->GetTitle() = %s \033[0m", nl.fNestedLoopsPro[0][0][AFO_PT]->GetXaxis()->GetTitle()); LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); // ordering in enum eAsFunctionOf is not the same as in TString fResultsProXaxisTitle[eAsFunctionOf_N] } @@ -3709,11 +6307,11 @@ void BookNestedLoopsHistograms() ExitFunction(__FUNCTION__); } -} // void BookNestedLoopsHistograms() +} // void bookNestedLoopsHistograms() //============================================================ -void BookNUAHistograms() +void bookNUAHistograms() { // Book all objects for Toy NUA. @@ -3727,14 +6325,50 @@ void BookNUAHistograms() // a) Book the profile holding flags: nua.fNUAFlagsPro = new TProfile("fNUAFlagsPro", "flags for Toy NUA", 6, 0.5, 6.5); - nua.fNUAFlagsPro->SetStats(kFALSE); + nua.fNUAFlagsPro->SetStats(false); nua.fNUAFlagsPro->SetLineColor(eColor); nua.fNUAFlagsPro->SetFillColor(eFillColor); nua.fNUAFlagsPro->GetXaxis()->SetLabelSize(0.03); + // TBI 20240429 the binning below is a bit fragile, but ok... - nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(1 + ePhiNUAPDF), "fApplyNUAPDF[phi]"); - nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(1 + ePtNUAPDF), "fApplyNUAPDF[pt]"); - nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(1 + eEtaNUAPDF), "fApplyNUAPDF[eta]"); + if (tc.fUseSetBinLabel) { + nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(1 + ePhiNUAPDF), "fApplyNUAPDF[phi]"); + nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(1 + ePtNUAPDF), "fApplyNUAPDF[pt]"); + nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(1 + eEtaNUAPDF), "fApplyNUAPDF[eta]"); + nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(4 + ePhiNUAPDF), "fUseDefaultNUAPDF[phi]"); + nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(4 + ePtNUAPDF), "fUseDefaultNUAPDF[pt]"); + nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(4 + eEtaNUAPDF), "fUseDefaultNUAPDF[eta]"); + + // ... + + } else { + + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fApplyNUAPDF[phi]; ", static_cast(1 + ePhiNUAPDF)); + yAxisTitle += TString::Format("%d:fApplyNUAPDF[pt]; ", static_cast(1 + ePtNUAPDF)); + yAxisTitle += TString::Format("%d:fApplyNUAPDF[eta]; ", static_cast(1 + eEtaNUAPDF)); + yAxisTitle += TString::Format("%d:fUseDefaultNUAPDF[phi]; ", static_cast(4 + ePhiNUAPDF)); + yAxisTitle += TString::Format("%d:fUseDefaultNUAPDF[pt]; ", static_cast(4 + ePtNUAPDF)); + yAxisTitle += TString::Format("%d:fUseDefaultNUAPDF[eta]; ", static_cast(4 + eEtaNUAPDF)); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != nua.fNUAFlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != nua.fNUAFlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), nua.fNUAFlagsPro->GetNbinsX()); + } + + // *) Okay, set the title: + nua.fNUAFlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else + if (nua.fApplyNUAPDF[ePhiNUAPDF]) { nua.fNUAFlagsPro->Fill(static_cast(1 + ePhiNUAPDF), 1.); } @@ -3744,9 +6378,6 @@ void BookNUAHistograms() if (nua.fApplyNUAPDF[eEtaNUAPDF]) { nua.fNUAFlagsPro->Fill(static_cast(1 + eEtaNUAPDF), 1.); } - nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(4 + ePhiNUAPDF), "fUseDefaultNUAPDF[phi]"); - nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(4 + ePtNUAPDF), "fUseDefaultNUAPDF[pt]"); - nua.fNUAFlagsPro->GetXaxis()->SetBinLabel(static_cast(4 + eEtaNUAPDF), "fUseDefaultNUAPDF[eta]"); if (nua.fUseDefaultNUAPDF[ePhiNUAPDF]) { nua.fNUAFlagsPro->Fill(static_cast(4 + ePhiNUAPDF), 1.); } @@ -3766,7 +6397,7 @@ void BookNUAHistograms() TString sVariable[eNUAPDF_N] = {"#varphi", "p_{t}", "#eta"}; // has to be in sync with the ordering of enum eNUAPDF // c) Histograms: - for (Int_t pdf = 0; pdf < eNUAPDF_N; pdf++) // use pdfs for NUA in (phi, pt, eta, ...) + for (int pdf = 0; pdf < eNUAPDF_N; pdf++) // use pdfs for NUA in (phi, pt, eta, ...) { if (!nua.fCustomNUAPDF[pdf]) // yes, because these histos are cloned from the external ones, see void SetNUAPDF(TH1D* const hist, const char* variable); { @@ -3778,10 +6409,10 @@ void BookNUAHistograms() continue; } // Define default detector acceptance in azimuthal angle: Two sectors, with different probabilities. - Double_t dFirstSector[2] = {-(3. / 4.) * TMath::Pi(), -(1. / 4.) * TMath::Pi()}; // first sector is defined as [-3Pi/4,Pi/4] - Double_t dSecondSector[2] = {(1. / 3.) * TMath::Pi(), (2. / 3.) * TMath::Pi()}; // second sector is defined as [Pi/3,2Pi/3] - Double_t dProbability[2] = {0.3, 0.5}; // probabilities - nua.fDefaultNUAPDF[ePhiNUAPDF] = new TF1(Form("fDefaultNUAPDF[%d]", ePhiNUAPDF), "1.-(x>=[0])*(1.-[4]) + (x>=[1])*(1.-[4]) - (x>=[2])*(1.-[5]) + (x>=[3])*(1.-[5]) ", + double dFirstSector[2] = {-(3. / 4.) * o2::constants::math::PI, -(1. / 4.) * o2::constants::math::PI}; // first sector is defined as [-3Pi/4,Pi/4] + double dSecondSector[2] = {(1. / 3.) * o2::constants::math::PI, (2. / 3.) * o2::constants::math::PI}; // second sector is defined as [Pi/3,2Pi/3] + double dProbability[2] = {0.3, 0.5}; // probabilities + nua.fDefaultNUAPDF[ePhiNUAPDF] = new TF1(TString::Format("fDefaultNUAPDF[%d]", ePhiNUAPDF), "1.-(x>=[0])*(1.-[4]) + (x>=[1])*(1.-[4]) - (x>=[2])*(1.-[5]) + (x>=[3])*(1.-[5]) ", ph.fParticleHistogramsBins[ePhi][1], ph.fParticleHistogramsBins[ePhi][2]); nua.fDefaultNUAPDF[ePhiNUAPDF]->SetParameter(0, dFirstSector[0]); nua.fDefaultNUAPDF[ePhiNUAPDF]->SetParameter(1, dFirstSector[1]); @@ -3798,9 +6429,9 @@ void BookNUAHistograms() continue; } // Define default detector acceptance in transverse momentum: One sectors, with probability < 1. - Double_t dSector[2] = {0.4, 0.8}; // sector is defined as 0.8 < pT < 1.2 - Double_t dProbability = 0.3; // probability, so after being set this way, only 30% of particles in that sector are reconstructed - nua.fDefaultNUAPDF[ePtNUAPDF] = new TF1(Form("fDefaultNUAPDF[%d]", ePtNUAPDF), "1.-(x>=[0])*(1.-[2]) + (x>=[1])*(1.-[2])", + double dSector[2] = {0.4, 0.8}; // sector is defined as 0.8 < pT < 1.2 + double dProbability = 0.3; // probability, so after being set this way, only 30% of particles in that sector are reconstructed + nua.fDefaultNUAPDF[ePtNUAPDF] = new TF1(TString::Format("fDefaultNUAPDF[%d]", ePtNUAPDF), "1.-(x>=[0])*(1.-[2]) + (x>=[1])*(1.-[2])", ph.fParticleHistogramsBins[ePt][1], ph.fParticleHistogramsBins[ePt][2]); nua.fDefaultNUAPDF[ePtNUAPDF]->SetParameter(0, dSector[0]); nua.fDefaultNUAPDF[ePtNUAPDF]->SetParameter(1, dSector[1]); @@ -3814,9 +6445,9 @@ void BookNUAHistograms() continue; } // Define default detector acceptance in pseudorapidity: One sectors, with probability < 1. - Double_t dSector[2] = {2.0, 2.5}; // sector is defined as 0.5 < eta < 1.0 - Double_t dProbability = 0.5; // probability, so after being set this way, only 50% of particles in that sector are reconstructed - nua.fDefaultNUAPDF[eEtaNUAPDF] = new TF1(Form("fDefaultNUAPDF[%d]", eEtaNUAPDF), "1.-(x>=[0])*(1.-[2]) + (x>=[1])*(1.-[2])", + double dSector[2] = {2.0, 2.5}; // sector is defined as 0.5 < eta < 1.0 + double dProbability = 0.5; // probability, so after being set this way, only 50% of particles in that sector are reconstructed + nua.fDefaultNUAPDF[eEtaNUAPDF] = new TF1(TString::Format("fDefaultNUAPDF[%d]", eEtaNUAPDF), "1.-(x>=[0])*(1.-[2]) + (x>=[1])*(1.-[2])", ph.fParticleHistogramsBins[eEta][1], ph.fParticleHistogramsBins[eEta][2]); nua.fDefaultNUAPDF[eEtaNUAPDF]->SetParameter(0, dSector[0]); nua.fDefaultNUAPDF[eEtaNUAPDF]->SetParameter(1, dSector[1]); @@ -3828,8 +6459,8 @@ void BookNUAHistograms() } else { // if(!nua.fCustomNUAPDF[pdf]) // generic cosmetics for custom user-supplied pdfs via histograms: - nua.fCustomNUAPDF[pdf]->SetTitle(Form("Custom user-provided NUA for %s", sVariable[pdf].Data())); - nua.fCustomNUAPDF[pdf]->SetStats(kFALSE); + nua.fCustomNUAPDF[pdf]->SetTitle(TString::Format("Custom user-provided NUA for %s", sVariable[pdf].Data())); + nua.fCustomNUAPDF[pdf]->SetStats(false); nua.fCustomNUAPDF[pdf]->GetXaxis()->SetTitle(sVariable[pdf].Data()); nua.fCustomNUAPDF[pdf]->SetFillColor(eFillColor); nua.fCustomNUAPDF[pdf]->SetLineColor(eColor); @@ -3845,17 +6476,17 @@ void BookNUAHistograms() nua.fMaxValuePDF[pdf] = nua.fDefaultNUAPDF[pdf]->GetMaximum(ph.fParticleHistogramsBins[pdf][1], ph.fParticleHistogramsBins[pdf][2]); } - } // for(Int_t pdf=0;pdfSetStats(kFALSE); + iv.fInternalValidationFlagsPro = new TProfile("fInternalValidationFlagsPro", "flags for internal validation", 5, 0., 5.); + iv.fInternalValidationFlagsPro->SetStats(false); iv.fInternalValidationFlagsPro->SetLineColor(eColor); iv.fInternalValidationFlagsPro->SetFillColor(eFillColor); iv.fInternalValidationFlagsPro->GetXaxis()->SetLabelSize(0.04); iv.fInternalValidationList->Add(iv.fInternalValidationFlagsPro); - iv.fInternalValidationFlagsPro->GetXaxis()->SetBinLabel(1, "fUseInternalValidation"); - iv.fInternalValidationFlagsPro->Fill(0.5, iv.fUseInternalValidation); - iv.fInternalValidationFlagsPro->GetXaxis()->SetBinLabel(2, "fnEventsInternalValidation"); - iv.fInternalValidationFlagsPro->Fill(1.5, iv.fnEventsInternalValidation); - iv.fInternalValidationFlagsPro->GetXaxis()->SetBinLabel(3, "fRescaleWithTheoreticalInput"); - iv.fInternalValidationFlagsPro->Fill(2.5, iv.fRescaleWithTheoreticalInput); - - /* TBI 20240423 I have to re-think where to fill the remaining bins of this profile. It feels now I have to fill it on the bottom, after all objects for internal validation are booked. - The problem here is that I do not book all objects below, unless I really do internal validation. - iv.fInternalValidationFlagsPro->GetXaxis()->SetBinLabel(4, Form("fHarmonicsOptionInternalValidation = %s", iv.fHarmonicsOptionInternalValidation->Data())); - iv.fInternalValidationFlagsPro->Fill(3.5, 1); - */ + if (tc.fUseSetBinLabel) { + iv.fInternalValidationFlagsPro->GetXaxis()->SetBinLabel(1, "fUseInternalValidation"); + iv.fInternalValidationFlagsPro->Fill(0.5, iv.fUseInternalValidation); + iv.fInternalValidationFlagsPro->GetXaxis()->SetBinLabel(2, "fnEventsInternalValidation"); + iv.fInternalValidationFlagsPro->Fill(1.5, iv.fnEventsInternalValidation); + iv.fInternalValidationFlagsPro->GetXaxis()->SetBinLabel(3, "fRescaleWithTheoreticalInput"); + iv.fInternalValidationFlagsPro->Fill(2.5, iv.fRescaleWithTheoreticalInput); + iv.fInternalValidationFlagsPro->GetXaxis()->SetBinLabel(4, "fRandomizeReactionPlane"); + iv.fInternalValidationFlagsPro->Fill(3.5, iv.fRandomizeReactionPlane); + iv.fInternalValidationFlagsPro->GetXaxis()->SetBinLabel(5, TString::Format("option = %s", iv.fHarmonicsOptionInternalValidation->Data())); + + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fUseInternalValidation; ", 1); + iv.fInternalValidationFlagsPro->Fill(0.5, static_cast(iv.fUseInternalValidation)); + + yAxisTitle += TString::Format("%d:fnEventsInternalValidation; ", 2); + iv.fInternalValidationFlagsPro->Fill(1.5, static_cast(iv.fnEventsInternalValidation)); + + yAxisTitle += TString::Format("%d:fRescaleWithTheoreticalInput; ", 3); + iv.fInternalValidationFlagsPro->Fill(2.5, static_cast(iv.fRescaleWithTheoreticalInput)); + + yAxisTitle += TString::Format("%d:fRandomizeReactionPlane; ", 4); + iv.fInternalValidationFlagsPro->Fill(3.5, static_cast(iv.fRandomizeReactionPlane)); + + yAxisTitle += TString::Format("%d:option = %s; ", 5, iv.fHarmonicsOptionInternalValidation->Data()); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != iv.fInternalValidationFlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != iv.fInternalValidationFlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), iv.fInternalValidationFlagsPro->GetNbinsX()); + } + + // *) Okay, set the title: + iv.fInternalValidationFlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else // *) Book object beyond this line only if internal validation was requested: if (!iv.fUseInternalValidation) { return; } - // *) TBI - iv.fHarmonicsOptionInternalValidation = new TString(cf_iv.cfHarmonicsOptionInternalValidation); - if (!(iv.fHarmonicsOptionInternalValidation->EqualTo("constant", TString::kIgnoreCase) || - iv.fHarmonicsOptionInternalValidation->EqualTo("correlated", TString::kIgnoreCase))) { - LOGF(fatal, "\033[1;31m%s at line %d : fHarmonicsOptionInternalValidation = %s is not supported. \033[0m", __FUNCTION__, __LINE__, iv.fHarmonicsOptionInternalValidation->Data()); - } - // b) Book and fill container vn amplitudes: iv.fInternalValidationVnPsin[eVn] = new TArrayD(gMaxHarmonic); - auto lInternalValidationAmplitudes = (vector)cf_iv.cfInternalValidationAmplitudes; // this is now the local version of that array from configurable + auto lInternalValidationAmplitudes = (std::vector)cf_iv.cfInternalValidationAmplitudes; // this is now the local version of that array from configurable if (lInternalValidationAmplitudes.size() < 1) { LOGF(fatal, "\033[1;31m%s at line %d : set at least one vn amplitude in array cfInternalValidationAmplitudes\n \033[0m", __FUNCTION__, __LINE__); } if (lInternalValidationAmplitudes.size() > gMaxHarmonic) { LOGF(fatal, "\033[1;31m%s at line %d : lInternalValidationAmplitudes.size() > gMaxHarmonic \n \033[0m", __FUNCTION__, __LINE__); } - for (Int_t i = 0; i < static_cast(lInternalValidationAmplitudes.size()); i++) { + for (int i = 0; i < static_cast(lInternalValidationAmplitudes.size()); i++) { iv.fInternalValidationVnPsin[eVn]->SetAt(lInternalValidationAmplitudes[i], i); } // c) Book and fill container for Psin planes: iv.fInternalValidationVnPsin[ePsin] = new TArrayD(gMaxHarmonic); - auto lInternalValidationPlanes = (vector)cf_iv.cfInternalValidationPlanes; + auto lInternalValidationPlanes = (std::vector)cf_iv.cfInternalValidationPlanes; if (lInternalValidationPlanes.size() < 1) { LOGF(fatal, "\033[1;31m%s at line : %d set at least one Psi plane in array cfInternalValidationPlanes\n \033[0m", __FUNCTION__, __LINE__); } @@ -3926,12 +6582,12 @@ void BookInternalValidationHistograms() if (lInternalValidationAmplitudes.size() != lInternalValidationPlanes.size()) { LOGF(fatal, "\033[1;31m%s at line %d : lInternalValidationAmplitudes.size() != lInternalValidationPlanes.size() \n \033[0m", __FUNCTION__, __LINE__); } - for (Int_t i = 0; i < static_cast(lInternalValidationPlanes.size()); i++) { + for (int i = 0; i < static_cast(lInternalValidationPlanes.size()); i++) { iv.fInternalValidationVnPsin[ePsin]->SetAt(lInternalValidationPlanes[i], i); } // d) Handle multiplicity for internal validation: - auto lMultRangeInternalValidation = (vector)cf_iv.cfMultRangeInternalValidation; + auto lMultRangeInternalValidation = (std::vector)cf_iv.cfMultRangeInternalValidation; iv.fMultRangeInternalValidation[eMin] = lMultRangeInternalValidation[eMin]; iv.fMultRangeInternalValidation[eMax] = lMultRangeInternalValidation[eMax]; if (iv.fMultRangeInternalValidation[eMin] >= iv.fMultRangeInternalValidation[eMax]) { @@ -3942,7 +6598,7 @@ void BookInternalValidationHistograms() ExitFunction(__FUNCTION__); } -} // BookInternalValidationHistograms() +} // bookInternalValidationHistograms() //============================================================ @@ -3974,11 +6630,11 @@ TComplex TheoreticalValue(TArrayI* harmonics, TArrayD* amplitudes, TArrayD* plan } // b) Main calculus: - TComplex value = TComplex(1., 0., kTRUE); // yes, polar representation - for (Int_t h = 0; h < harmonics->GetSize(); h++) { - // Using polar form of TComplex (Double_t re, Double_t im=0, Bool_t polar=kFALSE): - value *= TComplex(amplitudes->GetAt(TMath::Abs(harmonics->GetAt(h)) - 1), 1. * harmonics->GetAt(h) * planes->GetAt(TMath::Abs(harmonics->GetAt(h)) - 1), kTRUE); - } // for(Int_t h=0;hGetSize();h++) + TComplex value = TComplex(1., 0., true); // yes, polar representation + for (int h = 0; h < harmonics->GetSize(); h++) { + // Using polar form of TComplex (double re, double im=0, bool polar=false): + value *= TComplex(amplitudes->GetAt(std::abs(harmonics->GetAt(h)) - 1), 1. * harmonics->GetAt(h) * planes->GetAt(std::abs(harmonics->GetAt(h)) - 1), true); + } // for(int h=0;hGetSize();h++) // c) Return value: if (tc.fVerbose) { @@ -3994,10 +6650,11 @@ void InternalValidation() { // Internal validation against theoretical values in on-the-fly study for all implemented correlators. - // Last update: 20241111 + // Last update: 20250121 // To do: - // 20231114 Do I need to add support for diff. weights also here? + // 20250121 At the moment, I do not support here differential phi weights. If I decide to add that feature, basically I need to generalize Accept() for 2D case, + // where e.g. phi(pt) weights will be given with some toy 2D pdf. // *) Set and propagate some fake run number; // *) Fetch the weights for this particular run number. Do it only once; @@ -4024,9 +6681,34 @@ void InternalValidation() if (!pw.fParticleWeightsAreFetched) { if (pw.fUseWeights[wPHI] || pw.fUseWeights[wPT] || pw.fUseWeights[wETA] || pw.fUseDiffWeights[wPHIPT] || pw.fUseDiffWeights[wPHIETA]) { GetParticleWeights(); - pw.fParticleWeightsAreFetched = kTRUE; + pw.fParticleWeightsAreFetched = true; + } + + // differential phi weights: + if (pw.fUseDiffPhiWeights[wPhiPhiAxis]) { // Yes, I check only the first flag. This way, I can switch off all differential phi weights by setting 0-wPhi in config. + // On the other hand, it doesn't make sense to calculate differential phi weights without having phi axis. + // At any point I shall be able to fall back to integrated phi weights, that corresponds to the case wheh "1-wPhi" and all others are "0-w..." + GetParticleWeights(); + pw.fParticleWeightsAreFetched = true; + } + + // differential pt weights: + if (pw.fUseDiffPhiWeights[wPtPtAxis]) { // Yes, I check only the first flag. This way, I can switch off all differential pt weights by setting 0-wPt in config. + // On the other hand, it doesn't make sense to calculate differential pt weights without having pt axis. + // At any point I shall be able to fall back to integrated pt weights, that corresponds to the case wheh "1-wPt" and all others are "0-w..." + GetParticleWeights(); + pw.fParticleWeightsAreFetched = true; } - } + + // differential eta weights: + if (pw.fUseDiffPhiWeights[wEtaEtaAxis]) { // Yes, I check only the first flag. This way, I can switch off all differential eta weights by setting 0-wEta in config. + // On the other hand, it doesn't make sense to calculate differential eta weights without having eta axis. + // At any point I shall be able to fall back to integrated eta weights, that corresponds to the case wheh "1-wEta" and all others are "0-w..." + GetParticleWeights(); + pw.fParticleWeightsAreFetched = true; + } + + } // if (!pw.fParticleWeightsAreFetched) { // a) Fourier like p.d.f. for azimuthal angles and flow amplitudes: TF1* fPhiPDF = NULL; @@ -4035,11 +6717,11 @@ void InternalValidation() if (iv.fHarmonicsOptionInternalValidation->EqualTo("constant")) { // For this option, vn's and psin's are constant for all simulated events, therefore I can configure fPhiPDF outside of loop over events. // Remark: The last parameter [18] is a random reaction plane, keep in sync with fPhiPDF->SetParameter(18,fReactionPlane); below - // Keep also in sync with const Int_t gMaxHarmonic = 9; in *GlobalConstants.h - fPhiPDF = new TF1("fPhiPDF", "1 + 2.*[0]*TMath::Cos(x-[1]-[18]) + 2.*[2]*TMath::Cos(2.*(x-[3]-[18])) + 2.*[4]*TMath::Cos(3.*(x-[5]-[18])) + 2.*[6]*TMath::Cos(4.*(x-[7]-[18])) + 2.*[8]*TMath::Cos(5.*(x-[9]-[18])) + 2.*[10]*TMath::Cos(6.*(x-[11]-[18])) + 2.*[12]*TMath::Cos(7.*(x-[13]-[18])) + 2.*[14]*TMath::Cos(8.*(x-[15]-[18])) + 2.*[16]*TMath::Cos(9.*(x-[17]-[18]))", 0., TMath::TwoPi()); - for (Int_t h = 0; h < gMaxHarmonic; h++) { - fPhiPDF->SetParName(2 * h, Form("v_{%d}", h + 1)); // set name v_n - fPhiPDF->SetParName(2 * h + 1, Form("Psi_{%d}", h + 1)); // set name psi_n + // Keep also in sync with const int gMaxHarmonic = 9; in *GlobalConstants.h + fPhiPDF = new TF1("fPhiPDF", "1 + 2.*[0]*std::cos(x-[1]-[18]) + 2.*[2]*std::cos(2.*(x-[3]-[18])) + 2.*[4]*std::cos(3.*(x-[5]-[18])) + 2.*[6]*std::cos(4.*(x-[7]-[18])) + 2.*[8]*std::cos(5.*(x-[9]-[18])) + 2.*[10]*std::cos(6.*(x-[11]-[18])) + 2.*[12]*std::cos(7.*(x-[13]-[18])) + 2.*[14]*std::cos(8.*(x-[15]-[18])) + 2.*[16]*std::cos(9.*(x-[17]-[18]))", 0., o2::constants::math::TwoPI); + for (int h = 0; h < gMaxHarmonic; h++) { + fPhiPDF->SetParName(2 * h, TString::Format("v_{%d}", h + 1)); // set name v_n + fPhiPDF->SetParName(2 * h + 1, TString::Format("Psi_{%d}", h + 1)); // set name psi_n // initialize v_n: if (iv.fInternalValidationVnPsin[eVn] && h + 1 <= iv.fInternalValidationVnPsin[eVn]->GetSize()) { fPhiPDF->SetParameter(2 * h, iv.fInternalValidationVnPsin[eVn]->GetAt(h)); @@ -4052,59 +6734,100 @@ void InternalValidation() } else { fPhiPDF->SetParameter(2 * h + 1, 0.); } - } // for(Int_t h=0;h This is initial configuration for p.d.f. used in internal validation:"); - for (Int_t h = 0; h < 2 * gMaxHarmonic; h++) { + for (int h = 0; h < 2 * gMaxHarmonic; h++) { LOGF(info, Form("%d %s = %f", h, fPhiPDF->GetParName(h), fPhiPDF->GetParameter(h))); } LOGF(info, "Remark: Parameter [18] at the moment is reaction plane.\n"); } // if (tc.fVerbose) { + } else if (iv.fHarmonicsOptionInternalValidation->EqualTo("correlated")) { // if(iv.fHarmonicsOptionInternalValidation->EqualTo("constant")) // For this option, three selected vn's (v1,v2,v3) are correlated, and all psin's are set to zero, for simplicity. // Remark: The last parameter [3] is a random reaction plane, keep in sync with fPhiPDF->SetParameter(3,fReactionPlane); below - // Keep also in sync with const Int_t gMaxHarmonic = 9; in *GlobalConstants.h - fPhiPDF = new TF1("fPhiPDF", "1 + 2.*[0]*TMath::Cos(x-[3]) + 2.*[1]*TMath::Cos(2.*(x-[3])) + 2.*[2]*TMath::Cos(3.*(x-[3]))", 0., TMath::TwoPi()); + // Keep also in sync with const int gMaxHarmonic = 9; in *GlobalConstants.h + + // Azimuthal angles are sampled from this pdf: + fPhiPDF = new TF1("fPhiPDF", "1 + 2.*[0]*std::cos(x-[3]) + 2.*[1]*std::cos(2.*(x-[3])) + 2.*[2]*std::cos(3.*(x-[3]))", 0., o2::constants::math::TwoPI); // With this parameterization, I have: // [0] => v1 // [1] => v2 // [2] => v3 // [3] => RP + fPhiPDF->SetParName(0, "v_{1}"); + fPhiPDF->SetParName(1, "v_{2}"); + fPhiPDF->SetParName(2, "v_{3}"); + fPhiPDF->SetParName(3, "RP"); + + // vn amplitudes are sampled e-b-e from this pdf: + fvnPDF = new TF3("fvnPDF", "x + 2.*y - 3.*z", 0.07, 0.08, 0.06, 0.07, 0.05, 0.06); // v1 \in [0.07,0.08], v2 \in [0.06,0.07], v3 \in [0.05,0.06] + // check for example message 'W-TF3::GetRandom3: function:fvnPDF has 27000 negative values: abs assumed' in the log file + // All the amplitudes v1, v2 and v3, and RP are determined e-b-e, and then set in fPhiPDF below + + } else if (iv.fHarmonicsOptionInternalValidation->EqualTo("persistent")) { // if(iv.fHarmonicsOptionInternalValidation->EqualTo("persistent")) + // For this option, three selected vn's (v1,v2,v3) are correlated in the same way as in "correlated" case, but in addition, the persistent + // non-vanishing correlation among SPCs Psi1, Psi2 and Psi3 is introduced, in the same way as in arXiv:1901.06968, Sec. II D. + // Remark: In this example, there is no Reaction Plane, instead Psi1 and Psi2 are sampled uniformly, and the equation for Psi3 is hardwired, + // to introduce strong and persistent SPC correlation, see arXiv:1901.06968, Sec. II D. + // Keep also in sync with const int gMaxHarmonic = 9; in *GlobalConstants.h + + // Azimuthal angles are sampled from this pdf: + fPhiPDF = new TF1("fPhiPDF", "1 + 2.*[0]*std::cos(x-[3]) + 2.*[1]*std::cos(2.*(x-[4])) + 2.*[2]*std::cos(3.*(x-[5]))", 0., o2::constants::math::TwoPI); + // With this parameterization, I have: + // [0] => v1 + // [1] => v2 + // [2] => v3 + // [3] => Psi1 + // [4] => Psi2 + // [5] => Psi3 + fPhiPDF->SetParName(0, "v_{1}"); + fPhiPDF->SetParName(1, "v_{2}"); + fPhiPDF->SetParName(2, "v_{3}"); + fPhiPDF->SetParName(3, "Psi_{1}"); + fPhiPDF->SetParName(4, "Psi_{2}"); + fPhiPDF->SetParName(5, "Psi_{3}"); + + // vn amplitudes are sampled e-b-e from this pdf (yes, for simplicity, I keep it the same as in "correlated" case): fvnPDF = new TF3("fvnPDF", "x + 2.*y - 3.*z", 0.07, 0.08, 0.06, 0.07, 0.05, 0.06); // v1 \in [0.07,0.08], v2 \in [0.06,0.07], v3 \in [0.05,0.06] // check for example message 'W-TF3::GetRandom3: function:fvnPDF has 27000 negative values: abs assumed' in the log file - fvnPDF->SetParName(0, "v_{1}"); - fvnPDF->SetParName(1, "v_{2}"); - fvnPDF->SetParName(2, "v_{3}"); - fvnPDF->SetParName(3, "RP"); - // Both amplitudes v1-v3 and RP are sampled e-b-e, and then set in fPhiPDF below - } // else if(fHarmonicsOptionInternalValidation->EqualTo("correlated")) + // All the amplitudes v1, v2 and v3, and symmetry planes Psi_{1}, Psi_{2} and Psi_{3} are determined e-b-e, and then set in fPhiPDF below + } // else if(fHarmonicsOptionInternalValidation->EqualTo("persistent")) // b) Loop over on-the-fly events: - Double_t v1 = 0., v2 = 0., v3 = 0.; - for (Int_t e = 0; e < static_cast(iv.fnEventsInternalValidation); e++) { + double v1 = 0., v2 = 0., v3 = 0.; + for (int e = 0; e < static_cast(iv.fnEventsInternalValidation); e++) { // b0) Reset ebye quantities: ResetEventByEventQuantities(); // b1) Determine multiplicity, centrality, reaction plane and configure p.d.f. for azimuthal angles if harmonics are not constant e-by-e: - Int_t nMult = static_cast(gRandom->Uniform(iv.fMultRangeInternalValidation[eMin], iv.fMultRangeInternalValidation[eMax])); + int nMult = static_cast(gRandom->Uniform(iv.fMultRangeInternalValidation[eMin], iv.fMultRangeInternalValidation[eMax])); - Double_t fReactionPlane = gRandom->Uniform(0., TMath::TwoPi()); // no cast is needed, since Uniform(...) returns double + double fReactionPlane = 0.; + if (iv.fRandomizeReactionPlane) { + fReactionPlane = gRandom->Uniform(0., o2::constants::math::TwoPI); // no cast is needed, since Uniform(...) returns double + } else { + LOGF(info, "\033[1;33m%s at line %d : Reaction plane was not randomized for this collision.\033[0m", __FUNCTION__, __LINE__); + } if (iv.fHarmonicsOptionInternalValidation->EqualTo("constant")) { fPhiPDF->SetParameter(18, fReactionPlane); } else if (iv.fHarmonicsOptionInternalValidation->EqualTo("correlated")) { fPhiPDF->SetParameter(3, fReactionPlane); - } + } // Remark: I do not need here anything for option "persistent", because RP is not used for that case. See below how 3 symmetry planes are introduced with persistent correlation - ebye.fCentrality = static_cast(gRandom->Uniform(0., 100.)); // this is perfectly fine for this exercise - ebye.fOccupancy = static_cast(gRandom->Uniform(0., 10000.)); // this is perfectly fine for this exercise - ebye.fInteractionRate = static_cast(gRandom->Uniform(0., 10000.)); // this is perfectly fine for this exercise - ebye.fCurrentRunDuration = static_cast(gRandom->Uniform(0., 86400.)); // this is perfectly fine for this exercise + ebye.fCentrality = static_cast(gRandom->Uniform(0., 100.)); // this is perfectly fine for this exercise + ebye.fOccupancy = static_cast(gRandom->Uniform(0., 10000.)); // this is perfectly fine for this exercise + ebye.fInteractionRate = static_cast(gRandom->Uniform(0., 1000.)); // this is perfectly fine for this exercise + ebye.fCurrentRunDuration = static_cast(gRandom->Uniform(0., 86400.)); // this is perfectly fine for this exercise + ebye.fVz = static_cast(gRandom->Uniform(-20., 20.)); // this is perfectly fine for this exercise + ebye.fFT0CAmplitudeOnFoundBC = static_cast(gRandom->Uniform(0., 100000.)); // this is perfectly fine for this exercise + ebye.fImpactParameter = static_cast(gRandom->Uniform(0., 20.)); // this is perfectly fine for this exercise - // b2) Fill event histograms before cuts: + // b2) Fill event histograms before cuts: if (eh.fFillEventHistograms) { !eh.fEventHistograms[eNumberOfEvents][eSim][eBefore] ? true : eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]->Fill(0.5); !eh.fEventHistograms[eTotalMultiplicity][eSim][eBefore] ? true : eh.fEventHistograms[eTotalMultiplicity][eSim][eBefore]->Fill(nMult); @@ -4112,46 +6835,86 @@ void InternalValidation() !eh.fEventHistograms[eOccupancy][eSim][eBefore] ? true : eh.fEventHistograms[eOccupancy][eSim][eBefore]->Fill(ebye.fOccupancy); !eh.fEventHistograms[eInteractionRate][eSim][eBefore] ? true : eh.fEventHistograms[eInteractionRate][eSim][eBefore]->Fill(ebye.fInteractionRate); !eh.fEventHistograms[eCurrentRunDuration][eSim][eBefore] ? true : eh.fEventHistograms[eCurrentRunDuration][eSim][eBefore]->Fill(ebye.fCurrentRunDuration); + !eh.fEventHistograms[eVertexZ][eSim][eBefore] ? true : eh.fEventHistograms[eVertexZ][eSim][eBefore]->Fill(ebye.fVz); !eh.fEventHistograms[eEventPlaneAngle][eSim][eBefore] ? true : eh.fEventHistograms[eEventPlaneAngle][eSim][eBefore]->Fill(fReactionPlane); } // ... here I could implement some event cuts, if necessary ... - // configure p.d.f. for azimuthal angles if harmonics are not constant e-by-e: + // configure p.d.f. for azimuthal angles if harmonics are not constant e-by-e, for option "correlated": if (iv.fHarmonicsOptionInternalValidation->EqualTo("correlated")) { // Sample 3 correlated vn's from TF3 fvnPDF, and with them initialize fPhiPDF: fvnPDF->GetRandom3(v1, v2, v3); fPhiPDF->SetParameter(0, v1); fPhiPDF->SetParameter(1, v2); fPhiPDF->SetParameter(2, v3); - // reaction plane is set above + // reaction plane is set above already } // if(fHarmonicsOptionInternalValidation->EqualTo("correlated")) + // configure p.d.f. for azimuthal angles if harmonics are not constant e-by-e, for option "persistent": + if (iv.fHarmonicsOptionInternalValidation->EqualTo("persistent")) { + + // Sample 3 correlated vn's from TF3 fvnPDF, and with them initialize fPhiPDF: + fvnPDF->GetRandom3(v1, v2, v3); + fPhiPDF->SetParameter(0, v1); + fPhiPDF->SetParameter(1, v2); + fPhiPDF->SetParameter(2, v3); + + // Persistent symmetry plane correlation: + double Psi1 = gRandom->Uniform(0., o2::constants::math::TwoPI); + double Psi2 = gRandom->Uniform(0., o2::constants::math::TwoPI); + double Psi3 = (1. / 3.) * (o2::constants::math::PIQuarter + 2. * Psi2 + Psi1); // see arXiv:1901.06968, Sec. II D. + // o2::constants::math::PIQuarter = 0.25f * PI + fPhiPDF->SetParameter(3, Psi1); + fPhiPDF->SetParameter(4, Psi2); + fPhiPDF->SetParameter(5, Psi3); + + // Remark: reaction plane is not needed for case "persistent" + + } // if(fHarmonicsOptionInternalValidation->EqualTo("persistent")) + // b3) Loop over particles: - Double_t dPhi = 0.; - Double_t dPt = 0.; - Double_t dEta = 0.; + double dPhi = 0.; + double dPt = 0.; + double dEta = 0.; + double dCharge = -44.; // it has to be double, because below I use e.g. double kineArr[2] = {dPt, dCharge}; // *) Define min and max ranges for sampling: - Double_t dPt_min = res.fResultsPro[AFO_PT]->GetXaxis()->GetBinLowEdge(1); // yes, low edge of first bin is pt min - Double_t dPt_max = res.fResultsPro[AFO_PT]->GetXaxis()->GetBinLowEdge(1 + res.fResultsPro[AFO_PT]->GetNbinsX()); // yes, low edge of overflow bin is max pt - Double_t dEta_min = res.fResultsPro[AFO_ETA]->GetXaxis()->GetBinLowEdge(1); // yes, low edge of first bin is eta min - Double_t dEta_max = res.fResultsPro[AFO_ETA]->GetXaxis()->GetBinLowEdge(1 + res.fResultsPro[AFO_ETA]->GetNbinsX()); // yes, low edge of overflow bin is max eta + double dPt_min = res.fResultsPro[AFO_PT]->GetXaxis()->GetBinLowEdge(1); // yes, low edge of first bin is pt min + double dPt_max = res.fResultsPro[AFO_PT]->GetXaxis()->GetBinLowEdge(1 + res.fResultsPro[AFO_PT]->GetNbinsX()); // yes, low edge of overflow bin is max pt + double dEta_min = res.fResultsPro[AFO_ETA]->GetXaxis()->GetBinLowEdge(1); // yes, low edge of first bin is eta min + double dEta_max = res.fResultsPro[AFO_ETA]->GetXaxis()->GetBinLowEdge(1 + res.fResultsPro[AFO_ETA]->GetNbinsX()); // yes, low edge of overflow bin is max eta - for (Int_t p = 0; p < nMult; p++) { + for (int p = 0; p < nMult; p++) { // Particle angle: dPhi = fPhiPDF->GetRandom(); - // *) To increase performance, sample pt or eta only if requested: - if (mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] || t0.fCalculateTest0AsFunctionOf[AFO_PT] || es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT]) { + // *) To increase performance, sample pt, eta or charge only if requested: + if (mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] || t0.fCalculateTest0AsFunctionOf[AFO_PT] || es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT] || + t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_PT] || t0.fCalculate2DTest0AsFunctionOf[AFO_PT_ETA] || t0.fCalculate2DTest0AsFunctionOf[AFO_PT_CHARGE] || + t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_ETA] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_CHARGE] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_VZ] || + t0.fCalculate3DTest0AsFunctionOf[AFO_PT_ETA_CHARGE]) { dPt = gRandom->Uniform(dPt_min, dPt_max); } - if (mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] || t0.fCalculateTest0AsFunctionOf[AFO_ETA] || es.fCalculateEtaSeparations) { + if (mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] || t0.fCalculateTest0AsFunctionOf[AFO_ETA] || es.fCalculateEtaSeparations || + t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_ETA] || t0.fCalculate2DTest0AsFunctionOf[AFO_PT_ETA] || t0.fCalculate2DTest0AsFunctionOf[AFO_ETA_CHARGE] || + t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_ETA] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_CHARGE] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_VZ] || + t0.fCalculate3DTest0AsFunctionOf[AFO_PT_ETA_CHARGE]) { // Yes, I have to use here es.fCalculateEtaSeparations , and not some differential flag, like for pt case above dEta = gRandom->Uniform(dEta_min, dEta_max); } + if (mupa.fCalculateCorrelationsAsFunctionOf[AFO_CHARGE] || t0.fCalculateTest0AsFunctionOf[AFO_CHARGE] || es.fCalculateEtaSeparationsAsFunctionOf[AFO_CHARGE] || + t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_CHARGE] || t0.fCalculate2DTest0AsFunctionOf[AFO_PT_CHARGE] || t0.fCalculate2DTest0AsFunctionOf[AFO_ETA_CHARGE] || + t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_CHARGE] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_CHARGE] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_VZ_CHARGE] || + t0.fCalculate3DTest0AsFunctionOf[AFO_PT_ETA_CHARGE]) { + dCharge = (1 == gRandom->Integer(2) ? 1 : -1); // gRandom->Integer(2) samples either 0 or 1, then I cast 0 into -1 + if (tc.fInsanityCheckForEachParticle && std::abs(dCharge) != 1) { + LOGF(fatal, "\033[1;31m%s at line %d : dCharge = %d\033[0m", __FUNCTION__, __LINE__, dCharge); + } + } + // *) Fill few selected particle histograms before cuts here directly: // Remark: I do not call FillParticleHistograms(track, eBefore), as I do not want to bother to make here full 'track' object, etc., just to fill simple kine info: if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D) { @@ -4159,6 +6922,7 @@ void InternalValidation() !ph.fParticleHistograms[ePhi][eSim][eBefore] ? true : ph.fParticleHistograms[ePhi][eSim][eBefore]->Fill(dPhi); !ph.fParticleHistograms[ePt][eSim][eBefore] ? true : ph.fParticleHistograms[ePt][eSim][eBefore]->Fill(dPt); !ph.fParticleHistograms[eEta][eSim][eBefore] ? true : ph.fParticleHistograms[eEta][eSim][eBefore]->Fill(dEta); + !ph.fParticleHistograms[eCharge][eSim][eBefore] ? true : ph.fParticleHistograms[eCharge][eSim][eBefore]->Fill(dCharge); // 2D: !ph.fParticleHistograms2D[ePhiPt][eSim][eBefore] ? true : ph.fParticleHistograms2D[ePhiPt][eSim][eBefore]->Fill(dPhi, dPt); !ph.fParticleHistograms2D[ePhiEta][eSim][eBefore] ? true : ph.fParticleHistograms2D[ePhiEta][eSim][eBefore]->Fill(dPhi, dEta); @@ -4183,6 +6947,7 @@ void InternalValidation() !ph.fParticleHistograms[ePhi][eSim][eAfter] ? true : ph.fParticleHistograms[ePhi][eSim][eAfter]->Fill(dPhi); !ph.fParticleHistograms[ePt][eSim][eAfter] ? true : ph.fParticleHistograms[ePt][eSim][eAfter]->Fill(dPt); !ph.fParticleHistograms[eEta][eSim][eAfter] ? true : ph.fParticleHistograms[eEta][eSim][eAfter]->Fill(dEta); + !ph.fParticleHistograms[eCharge][eSim][eAfter] ? true : ph.fParticleHistograms[eCharge][eSim][eAfter]->Fill(dCharge); // 2D: !ph.fParticleHistograms2D[ePhiPt][eSim][eAfter] ? true : ph.fParticleHistograms2D[ePhiPt][eSim][eAfter]->Fill(dPhi, dPt); !ph.fParticleHistograms2D[ePhiEta][eSim][eAfter] ? true : ph.fParticleHistograms2D[ePhiEta][eSim][eAfter]->Fill(dPhi, dEta); @@ -4194,20 +6959,74 @@ void InternalValidation() this->FillQvector(dPhi, dPt, dEta); // all 3 arguments are passed by reference } - // *) Differential q-vectors: - // **) pt-dependence: + // *) Differential q-vectors (keep in sync with the code in MainLoopOverParticles(...)): + + // ** 1D: + // ***) pt dependence: if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] || t0.fCalculateTest0AsFunctionOf[AFO_PT]) && !es.fCalculateEtaSeparations) { - // In this branch I do not need eta separation, so the ligher call can be executed: - this->Fillqvector(dPhi, dPt, PTq); // first 2 arguments are passed by reference, 3rd argument is enum + // In this branch I do not need eta separation, so the lighter call can be executed: + double kineArr[1] = {dPt}; + this->FillqvectorNdim(dPhi, kineArr, 1, PTq); } else if (es.fCalculateEtaSeparations && es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT]) { // In this branch I do need eta separation, so the heavier call must be executed: - // Remark: Within Fillqvector() I check again all the relevant flags. - this->Fillqvector(dPhi, dPt, PTq, dEta); // first 2 arguments and the last one are passed by reference, 3rd argument is enum. "kine" variable is the 2nd argument + double kineArr[1] = {dPt}; + this->FillqvectorNdim(dPhi, kineArr, 1, PTq, dEta); } - // **) eta-dependence: + + // ***) eta dependence: if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] || t0.fCalculateTest0AsFunctionOf[AFO_ETA])) { // Remark: For eta dependence I do not consider es.fCalculateEtaSeparations, because in this context that calculation is meaningless. - this->Fillqvector(dPhi, dEta, ETAq); // first 2 arguments are passed by reference, 3rd argument is enum + double kineArr[1] = {dEta}; + this->FillqvectorNdim(dPhi, kineArr, 1, ETAq); + } + + // ***) charge dependence: + if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_CHARGE] || t0.fCalculateTest0AsFunctionOf[AFO_CHARGE]) && !es.fCalculateEtaSeparations) { + // In this branch I do not need eta separation, so the lighter call can be executed: + double kineArr[1] = {dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 1, CHARGEq); + } else if (es.fCalculateEtaSeparations && es.fCalculateEtaSeparationsAsFunctionOf[AFO_CHARGE]) { + // In this branch I do need eta separation, so the heavier call must be executed: + double kineArr[1] = {dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 1, CHARGEq, dEta); + } + + // ... + + // ** 2D: + // ***) pt-eta dependence: + if (qv.fCalculateQvectors && (t0.fCalculate2DTest0AsFunctionOf[AFO_PT_ETA] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_ETA])) { + // Remark: For eta dependence I do not consider es.fCalculateEtaSeparations, because in this context that calculation is meaningless. + double kineArr[2] = {dPt, dEta}; + this->FillqvectorNdim(dPhi, kineArr, 2, PT_ETAq); + } + + // ***) pt-charge dependence: + if (qv.fCalculateQvectors && (t0.fCalculate2DTest0AsFunctionOf[AFO_PT_CHARGE] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_CHARGE]) && !es.fCalculateEtaSeparations) { + // In this branch I do not need eta separation, so the lighter call can be executed: + double kineArr[2] = {dPt, dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 2, PT_CHARGEq); + } else if (es.fCalculateEtaSeparations && false) { // && TBI 20250623 finalize, replace "false" with 2D flag for (pt,charge) with eta separation case + // In this branch I do need eta separation, so the heavier call must be executed: + double kineArr[2] = {dPt, dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 2, PT_CHARGEq, dEta); + } + + // ***) eta-charge dependence: + if (qv.fCalculateQvectors && (t0.fCalculate2DTest0AsFunctionOf[AFO_ETA_CHARGE] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_CHARGE])) { + // Remark: For eta dependence I do not consider es.fCalculateEtaSeparations, because in this context that calculation is meaningless. + double kineArr[2] = {dEta, dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 2, ETA_CHARGEq); + } + + // ... + + // ** 3D: + // ***) pt-eta-charge dependence: + if (qv.fCalculateQvectors && (t0.fCalculate3DTest0AsFunctionOf[AFO_PT_ETA_CHARGE])) { + // Remark: For eta dependence I do not consider es.fCalculateEtaSeparations, because in this context that calculation is meaningless. + double kineArr[3] = {dPt, dEta, dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 3, PT_ETA_CHARGEq); } // *) Fill nested loops containers: @@ -4222,7 +7041,7 @@ void InternalValidation() break; } - } // for(Int_t p=0;pFill(ebye.fOccupancy); !eh.fEventHistograms[eInteractionRate][eSim][eAfter] ? true : eh.fEventHistograms[eCentrality][eSim][eAfter]->Fill(ebye.fInteractionRate); !eh.fEventHistograms[eCurrentRunDuration][eSim][eAfter] ? true : eh.fEventHistograms[eCurrentRunDuration][eSim][eAfter]->Fill(ebye.fCurrentRunDuration); + !eh.fEventHistograms[eVertexZ][eSim][eAfter] ? true : eh.fEventHistograms[eVertexZ][eSim][eAfter]->Fill(ebye.fVz); !eh.fEventHistograms[eEventPlaneAngle][eSim][eAfter] ? true : eh.fEventHistograms[eEventPlaneAngle][eSim][eAfter]->Fill(fReactionPlane); } @@ -4252,7 +7072,7 @@ void InternalValidation() ResetEventByEventQuantities(); // *) Print info on the current event number (within current real event): - LOGF(info, " Event # %d/%d (within current real event) ....", e + 1, static_cast(iv.fnEventsInternalValidation)); + LOGF(info, " Event # %d/%d (within current real event, running internal validation) ....", e + 1, static_cast(iv.fnEventsInternalValidation)); // *) Determine all event counters: DetermineEventCounters(); @@ -4265,11 +7085,11 @@ void InternalValidation() // *) If I reached max number of events, ignore the remaining collisions: if (MaxNumberOfEvents(eAfter)) { if (iv.fInternalValidationForceBailout) { - BailOut(kTRUE); + BailOut(true); } } - } // for(Int_t e=0;e(iv.fnEventsInternalValidation);e++) + } // for(int e=0;e(iv.fnEventsInternalValidation);e++) // *) Print info on the current event number (total): if (tc.fVerboseEventCounter) { @@ -4292,7 +7112,7 @@ void InternalValidation() //============================================================ -Bool_t Accept(const Double_t& value, Int_t var) +bool Accept(const double& value, int var) { // Given the acceptance profile for this observable, accept or not that observable for the analysis. // Use in Toy NUA studies. @@ -4313,10 +7133,10 @@ Bool_t Accept(const Double_t& value, Int_t var) LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - Bool_t bAccept = kTRUE; // return value + bool bAccept = true; // return value - Double_t acceptanceProbability = 1.; - Double_t correspondingAcceptance = -44.; + double acceptanceProbability = 1.; + double correspondingAcceptance = -44.; if (!nua.fUseDefaultNUAPDF[var]) { correspondingAcceptance = nua.fCustomNUAPDF[var]->GetBinContent(nua.fCustomNUAPDF[var]->FindBin(value)); } else { @@ -4327,123 +7147,243 @@ Bool_t Accept(const Double_t& value, Int_t var) acceptanceProbability = 1. - (nua.fMaxValuePDF[var] - correspondingAcceptance) / nua.fMaxValuePDF[var]; // Accept or not: - (gRandom->Uniform(0, 1) < acceptanceProbability) ? bAccept = kTRUE : bAccept = kFALSE; + (gRandom->Uniform(0, 1) < acceptanceProbability) ? bAccept = true : bAccept = false; return bAccept; -} // Bool_t Accept(const Double_t &value, Int_t var) +} // bool Accept(const double &value, int var) //============================================================ -void BookTest0Histograms() +void bookTest0Histograms() { // Book all Test0 histograms. // a) Book the profile holding flags; // b) Book placeholder and make sure all labels are stored in the placeholder; - // c) Retrieve labels from placeholder; - // d) Book what needs to be booked; - // e) Few quick insanity checks on booking. + // c) Book what needs to be booked for 1D; + // d) Book what needs to be booked for 2D; + // e) Book what needs to be booked for 3D; + // f) Few quick insanity checks on booking (cherry-picking). if (tc.fVerbose) { StartFunction(__FUNCTION__); } // a) Book the profile holding flags: - t0.fTest0FlagsPro = new TProfile("fTest0FlagsPro", "flags for Test0", 1, 0., 1.); - t0.fTest0FlagsPro->SetStats(kFALSE); + t0.fTest0FlagsPro = new TProfile("fTest0FlagsPro", "flags for Test0", 3, 0., 3.); + t0.fTest0FlagsPro->SetStats(false); t0.fTest0FlagsPro->GetXaxis()->SetLabelSize(0.04); - t0.fTest0FlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateTest0"); - t0.fTest0FlagsPro->Fill(0.5, t0.fCalculateTest0); + + if (tc.fUseSetBinLabel) { + t0.fTest0FlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateTest0"); + t0.fTest0FlagsPro->GetXaxis()->SetBinLabel(2, "fCalculate2DTest0"); + t0.fTest0FlagsPro->GetXaxis()->SetBinLabel(3, "fCalculate3DTest0"); + + // ... + + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fCalculateTest0; ", 1); + yAxisTitle += TString::Format("%d:fCalculate2DTest0; ", 2); + yAxisTitle += TString::Format("%d:fCalculate3DTest0; ", 3); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != t0.fTest0FlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != t0.fTest0FlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), t0.fTest0FlagsPro->GetNbinsX()); + } + + // *) Okay, set the title: + t0.fTest0FlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + // ... + + } // else + + t0.fTest0FlagsPro->Fill(0.5, static_cast(t0.fCalculateTest0)); + t0.fTest0FlagsPro->Fill(1.5, static_cast(t0.fCalculate2DTest0)); + t0.fTest0FlagsPro->Fill(2.5, static_cast(t0.fCalculate3DTest0)); + // ... t0.fTest0List->Add(t0.fTest0FlagsPro); - if (!t0.fCalculateTest0) { + if (!(t0.fCalculateTest0 || t0.fCalculate2DTest0 || t0.fCalculate3DTest0)) { return; } // b) Book placeholder and make sure all labels are stored in the placeholder: this->StoreLabelsInPlaceholder(); - if (t0.fTest0LabelsPlaceholder) { - t0.fTest0List->Add(t0.fTest0LabelsPlaceholder); - } - // c) Retrieve labels from placeholder: - if (!(this->RetrieveCorrelationsLabels())) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } + // c) Book what needs to be booked for 1D: + if (t0.fCalculateTest0) { + for (int mo = 0; mo < gMaxCorrelator; mo++) { + for (int mi = 0; mi < gMaxIndex; mi++) { + if (!t0.fTest0Labels[mo][mi]) { + continue; + } + for (int v = 0; v < eAsFunctionOf_N; v++) { - // d) Book what needs to be booked: - for (Int_t mo = 0; mo < gMaxCorrelator; mo++) { - for (Int_t mi = 0; mi < gMaxIndex; mi++) { - if (!t0.fTest0Labels[mo][mi]) { - continue; - } - { - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { - // decide what is booked, then later valid pointer to fCorrelationsPro[k][n][v] is used as a boolean, in the standard way: - if (AFO_INTEGRATED == v && !t0.fCalculateTest0AsFunctionOf[AFO_INTEGRATED]) { - continue; - } - if (AFO_MULTIPLICITY == v && !t0.fCalculateTest0AsFunctionOf[AFO_MULTIPLICITY]) { - continue; - } - if (AFO_CENTRALITY == v && !t0.fCalculateTest0AsFunctionOf[AFO_CENTRALITY]) { - continue; - } - if (AFO_PT == v && !t0.fCalculateTest0AsFunctionOf[AFO_PT]) { - continue; - } - if (AFO_ETA == v && !t0.fCalculateTest0AsFunctionOf[AFO_ETA]) { - continue; - } - if (AFO_OCCUPANCY == v && !t0.fCalculateTest0AsFunctionOf[AFO_OCCUPANCY]) { - continue; - } - if (AFO_INTERACTIONRATE == v && !t0.fCalculateTest0AsFunctionOf[AFO_INTERACTIONRATE]) { - continue; - } - if (AFO_CURRENTRUNDURATION == v && !t0.fCalculateTest0AsFunctionOf[AFO_CURRENTRUNDURATION]) { + // decide what is booked, then later valid pointer to fTest0Pro[k][n][v] is used as a boolean, in the standard way: + if (!t0.fCalculateTest0AsFunctionOf[v]) { continue; } if (!res.fResultsPro[v]) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d : fResultsPro[%d] is NULL, this shall never happen, but apparently it happened... \033[0m", __FUNCTION__, __LINE__, v); + } + + if (tc.fUseClone) { + t0.fTest0Pro[mo][mi][v] = reinterpret_cast(res.fResultsPro[v]->Clone(Form("fTest0Pro[%d][%d][%s]", mo, mi, res.fResultsProRawName[v].Data()))); // yes + } else { + t0.fTest0Pro[mo][mi][v] = new TProfile(Form("fTest0Pro[%d][%d][%s]", mo, mi, res.fResultsProRawName[v].Data()), "", res.fResultsPro[v]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[v]->GetXaxis()->GetXbins()->GetArray()); } - t0.fTest0Pro[mo][mi][v] = reinterpret_cast(res.fResultsPro[v]->Clone(Form("fTest0Pro[%d][%d][%s]", mo, mi, res.fResultsProRawName[v].Data()))); // yes - t0.fTest0Pro[mo][mi][v]->SetStats(kFALSE); + t0.fTest0Pro[mo][mi][v]->SetStats(false); t0.fTest0Pro[mo][mi][v]->Sumw2(); t0.fTest0Pro[mo][mi][v]->SetTitle(t0.fTest0Labels[mo][mi]->Data()); t0.fTest0Pro[mo][mi][v]->GetXaxis()->SetTitle(FancyFormatting(res.fResultsProXaxisTitle[v].Data())); - /* - if(fUseFixedNumberOfRandomlySelectedParticles && 1==v) // just a warning for the meaning of multiplicity in this special case - { - fTest0Pro[mo][mi][1]->GetXaxis()->SetTitle("WARNING: for each multiplicity, fFixedNumberOfRandomlySelectedParticles is selected randomly in Q-vector"); - } - */ t0.fTest0List->Add(t0.fTest0Pro[mo][mi][v]); // yes, this has to be here - } // for(Int_t v=0;vGetName(); + TObjArray* oa = rawName.Tokenize("[]"); + if (oa->GetEntries() != 2) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() = %d \033[0m", __FUNCTION__, __LINE__, oa->GetEntries()); + } + rawName = oa->At(1)->GetName(); // basically: fResultsPro2D[cent_pt] => cent_pt + delete oa; + if (rawName.EqualTo("")) { + LOGF(fatal, "\033[1;31m%s at line %d : rawName is empty string \033[0m", __FUNCTION__, __LINE__); + } + + if (tc.fUseClone) { + t0.fTest0Pro2D[mo][mi][v] = reinterpret_cast(res.fResultsPro2D[v]->Clone(Form("fTest0Pro2D[%d][%d][%s]", mo, mi, rawName.Data()))); + } else { + // TBI 20250412 this branch is temporary workaround until hist->Clone(...) large memory consumption is resolved + t0.fTest0Pro2D[mo][mi][v] = new TProfile2D(Form("fTest0Pro2D[%d][%d][%s]", mo, mi, rawName.Data()), "", + res.fResultsPro2D[v]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro2D[v]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro2D[v]->GetYaxis()->GetXbins()->GetSize() - 1, res.fResultsPro2D[v]->GetYaxis()->GetXbins()->GetArray()); // yes, GetYaxis()->GetXbins() + } // else + + t0.fTest0Pro2D[mo][mi][v]->SetStats(false); + t0.fTest0Pro2D[mo][mi][v]->Sumw2(); + t0.fTest0Pro2D[mo][mi][v]->SetTitle(t0.fTest0Labels[mo][mi]->Data()); + t0.fTest0Pro2D[mo][mi][v]->GetXaxis()->SetTitle(FancyFormatting(res.fResultsPro2D[v]->GetXaxis()->GetTitle())); + t0.fTest0Pro2D[mo][mi][v]->GetYaxis()->SetTitle(FancyFormatting(res.fResultsPro2D[v]->GetYaxis()->GetTitle())); + t0.fTest0List->Add(t0.fTest0Pro2D[mo][mi][v]); // yes, this has to be here + + } // for(int v=0;vGetName(); + TObjArray* oa = rawName.Tokenize("[]"); + if (oa->GetEntries() != 2) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() = %d \033[0m", __FUNCTION__, __LINE__, oa->GetEntries()); + } + rawName = oa->At(1)->GetName(); // basically: fResultsPro2D[cent_pt_eta] => cent_pt_eta + delete oa; + if (rawName.EqualTo("")) { + LOGF(fatal, "\033[1;31m%s at line %d : rawName is empty string \033[0m", __FUNCTION__, __LINE__); + } + + if (tc.fUseClone) { + t0.fTest0Pro3D[mo][mi][v] = reinterpret_cast(res.fResultsPro3D[v]->Clone(Form("fTest0Pro3D[%d][%d][%s]", mo, mi, rawName.Data()))); + } else { + // TBI 20250412 this branch is temporary workaround until hist->Clone(...) large memory consumption is resolved + t0.fTest0Pro3D[mo][mi][v] = new TProfile3D(Form("fTest0Pro3D[%d][%d][%s]", mo, mi, rawName.Data()), "", + res.fResultsPro3D[v]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro3D[v]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro3D[v]->GetYaxis()->GetXbins()->GetSize() - 1, res.fResultsPro3D[v]->GetYaxis()->GetXbins()->GetArray(), // yes, GetYaxis()->GetXbins() + res.fResultsPro3D[v]->GetZaxis()->GetXbins()->GetSize() - 1, res.fResultsPro3D[v]->GetZaxis()->GetXbins()->GetArray()); // yes, GetZaxis()->GetXbins() + } // else + + t0.fTest0Pro3D[mo][mi][v]->SetStats(false); + t0.fTest0Pro3D[mo][mi][v]->Sumw2(); + t0.fTest0Pro3D[mo][mi][v]->SetTitle(t0.fTest0Labels[mo][mi]->Data()); + t0.fTest0Pro3D[mo][mi][v]->GetXaxis()->SetTitle(FancyFormatting(res.fResultsPro3D[v]->GetXaxis()->GetTitle())); + t0.fTest0Pro3D[mo][mi][v]->GetYaxis()->SetTitle(FancyFormatting(res.fResultsPro3D[v]->GetYaxis()->GetTitle())); + t0.fTest0Pro3D[mo][mi][v]->GetZaxis()->SetTitle(FancyFormatting(res.fResultsPro3D[v]->GetZaxis()->GetTitle())); + t0.fTest0List->Add(t0.fTest0Pro3D[mo][mi][v]); // yes, this has to be here + + } // for(int v=0;vGetXaxis()->GetTitle()).EqualTo("integrated")) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); // ordering in enum eAsFunctionOf is not the same as in TString fResultsProXaxisTitle[eAsFunctionOf_N] } if (t0.fTest0Pro[0][0][AFO_PT] && !TString(t0.fTest0Pro[0][0][AFO_PT]->GetXaxis()->GetTitle()).EqualTo("p_{T}")) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); // ordering in enum eAsFunctionOf is not the same as in TString fResultsProXaxisTitle[eAsFunctionOf_N] + LOGF(fatal, "\033[1;31m%s at line %d : x-axis title = %s\033[0m", __FUNCTION__, __LINE__, t0.fTest0Pro[0][0][AFO_PT]->GetXaxis()->GetTitle()); // ordering in enum eAsFunctionOf is not the same as in TString fResultsProXaxisTitle[eAsFunctionOf_N] + } + + // 2D: + if (t0.fTest0Pro2D[0][0][AFO_CENTRALITY_PT] && !(TString(t0.fTest0Pro2D[0][0][AFO_CENTRALITY_PT]->GetXaxis()->GetTitle()).Contains("centrality", TString::kIgnoreCase) && TString(t0.fTest0Pro2D[0][0][AFO_CENTRALITY_PT]->GetYaxis()->GetTitle()).EqualTo("p_{T}"))) { + LOGF(fatal, "\033[1;31m%s at line %d : x-axis title = %s, y-axis title = %s\033[0m", __FUNCTION__, __LINE__, t0.fTest0Pro2D[0][0][AFO_CENTRALITY_PT]->GetXaxis()->GetTitle(), t0.fTest0Pro2D[0][0][AFO_CENTRALITY_PT]->GetYaxis()->GetTitle()); // ordering in enum eAsFunctionOf is not the same as in TString fResultsProXaxisTitle[eAsFunctionOf_N] + } + + // 3D: + if (t0.fTest0Pro3D[0][0][AFO_CENTRALITY_PT_ETA] && !(TString(t0.fTest0Pro3D[0][0][AFO_CENTRALITY_PT_ETA]->GetXaxis()->GetTitle()).Contains("centrality", TString::kIgnoreCase) && TString(t0.fTest0Pro3D[0][0][AFO_CENTRALITY_PT_ETA]->GetYaxis()->GetTitle()).EqualTo("p_{T}") && TString(t0.fTest0Pro3D[0][0][AFO_CENTRALITY_PT_ETA]->GetZaxis()->GetTitle()).EqualTo("#eta"))) { + LOGF(fatal, "\033[1;31m%s at line %d : x-axis title = %s, y-axis title = %s, z-axis title = %s\033[0m", __FUNCTION__, __LINE__, t0.fTest0Pro3D[0][0][AFO_CENTRALITY_PT_ETA]->GetXaxis()->GetTitle(), t0.fTest0Pro3D[0][0][AFO_CENTRALITY_PT_ETA]->GetYaxis()->GetTitle(), t0.fTest0Pro3D[0][0][AFO_CENTRALITY_PT_ETA]->GetZaxis()->GetTitle()); // ordering in enum eAsFunctionOf is not the same as in TString fResultsProXaxisTitle[eAsFunctionOf_N] } if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void BookTest0Histograms() +} // void bookTest0Histograms() //============================================================ -void BookEtaSeparationsHistograms() +void bookEtaSeparationsHistograms() { // Book all eta separations histograms. @@ -4457,11 +7397,40 @@ void BookEtaSeparationsHistograms() // a) Book the profile holding flags: es.fEtaSeparationsFlagsPro = new TProfile("fEtaSeparationsFlagsPro", "flags for eta separations", 1, 0., 1.); - es.fEtaSeparationsFlagsPro->SetStats(kFALSE); + es.fEtaSeparationsFlagsPro->SetStats(false); es.fEtaSeparationsFlagsPro->SetLineColor(eColor); es.fEtaSeparationsFlagsPro->SetFillColor(eFillColor); es.fEtaSeparationsFlagsPro->GetXaxis()->SetLabelSize(0.04); - es.fEtaSeparationsFlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateEtaSeparations"); + + if (tc.fUseSetBinLabel) { + es.fEtaSeparationsFlagsPro->GetXaxis()->SetBinLabel(1, "fCalculateEtaSeparations"); + + // ... + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fCalculateEtaSeparations; ", 1); + es.fEtaSeparationsFlagsPro->Fill(0.5, static_cast(es.fCalculateEtaSeparations)); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != es.fEtaSeparationsFlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() - 1 = %d != es.fEtaSeparationsFlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), es.fEtaSeparationsFlagsPro->GetNbinsX()); + } + + // *) Okay, set the title: + es.fEtaSeparationsFlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + + // ... + + } // else + es.fEtaSeparationsFlagsPro->Fill(0.5, es.fCalculateEtaSeparations); es.fEtaSeparationsList->Add(es.fEtaSeparationsFlagsPro); @@ -4470,51 +7439,36 @@ void BookEtaSeparationsHistograms() } // b) Book what needs to be booked: - for (Int_t h = 0; h < gMaxHarmonic; h++) { + for (int h = 0; h < gMaxHarmonic; h++) { if (es.fEtaSeparationsSkipHarmonics[h]) { continue; } - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { - // decide what is booked, then later valid pointer to fCorrelationsPro[k][n][v] is used as a boolean, in the standard way: - if (AFO_INTEGRATED == v && !es.fCalculateEtaSeparationsAsFunctionOf[AFO_INTEGRATED]) { - continue; - } - if (AFO_MULTIPLICITY == v && !es.fCalculateEtaSeparationsAsFunctionOf[AFO_MULTIPLICITY]) { - continue; - } - if (AFO_CENTRALITY == v && !es.fCalculateEtaSeparationsAsFunctionOf[AFO_CENTRALITY]) { - continue; - } - if (AFO_PT == v && !es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT]) { - continue; - } - if (AFO_ETA == v && !es.fCalculateEtaSeparationsAsFunctionOf[AFO_ETA]) { - continue; - } - if (AFO_OCCUPANCY == v && !es.fCalculateEtaSeparationsAsFunctionOf[AFO_OCCUPANCY]) { - continue; - } - if (AFO_INTERACTIONRATE == v && !es.fCalculateEtaSeparationsAsFunctionOf[AFO_INTERACTIONRATE]) { - continue; - } - if (AFO_CURRENTRUNDURATION == v && !es.fCalculateEtaSeparationsAsFunctionOf[AFO_CURRENTRUNDURATION]) { + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + for (int v = 0; v < eAsFunctionOf_N; v++) { + + // decide what is booked, then later valid pointer to es.fEtaSeparationsPro[h][e][v] is used as a boolean, in the standard way: + if (!es.fCalculateEtaSeparationsAsFunctionOf[v]) { continue; } if (!res.fResultsPro[v]) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d : fResultsPro[%d] is NULL, this shall never happen, but apparently it happened... \033[0m", __FUNCTION__, __LINE__, v); + } + + if (tc.fUseClone) { + es.fEtaSeparationsPro[h][e][v] = reinterpret_cast(res.fResultsPro[v]->Clone(Form("fEtaSeparationsPro[%d][%d][%s]", h, e, res.fResultsProRawName[v].Data()))); // yes + } else { + es.fEtaSeparationsPro[h][e][v] = new TProfile(Form("fEtaSeparationsPro[%d][%d][%s]", h, e, res.fResultsProRawName[v].Data()), "", res.fResultsPro[v]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[v]->GetXaxis()->GetXbins()->GetArray()); } - es.fEtaSeparationsPro[h][e][v] = reinterpret_cast(res.fResultsPro[v]->Clone(Form("fEtaSeparationsPro[%d][%d][%s]", h, e, res.fResultsProRawName[v].Data()))); // yes - es.fEtaSeparationsPro[h][e][v]->SetStats(kFALSE); + es.fEtaSeparationsPro[h][e][v]->SetStats(false); es.fEtaSeparationsPro[h][e][v]->Sumw2(); es.fEtaSeparationsPro[h][e][v]->SetTitle(Form("%d -%d, |#Delta#eta| > %.2f", h + 1, h + 1, es.fEtaSeparationsValues[e])); es.fEtaSeparationsPro[h][e][v]->GetXaxis()->SetTitle(FancyFormatting(res.fResultsProXaxisTitle[v].Data())); es.fEtaSeparationsList->Add(es.fEtaSeparationsPro[h][e][v]); // yes, this has to be here - } // for(Int_t v=0;vGetXaxis()->GetTitle()).EqualTo("integrated")) { @@ -4528,16 +7482,19 @@ void BookEtaSeparationsHistograms() ExitFunction(__FUNCTION__); } -} // void BookEtaSeparationsHistograms() +} // void bookEtaSeparationsHistograms() //============================================================ -void BookResultsHistograms() +void bookResultsHistograms() { // Book all results histograms. + // These results histograms in addition act as a sort of "abstract" interface, which defines common binning, etc., for other groups of histograms. // a) Book the profile holding flags; - // b) Book results histograms, which in addition act as a sort of "abstract" interface, which defines common binning, etc., for other groups of histograms. + // b) Book (and optionaly save) results histograms 1D; + // c) Book (and optionaly save) results histograms 2D; + // d) Book (and optionaly save) results histograms 3D. if (tc.fVerbose) { StartFunction(__FUNCTION__); @@ -4545,43 +7502,289 @@ void BookResultsHistograms() // a) Book the profile holding flags: res.fResultsFlagsPro = new TProfile("fResultsFlagsPro", "flags for results histograms", 1, 0., 1.); - res.fResultsFlagsPro->SetStats(kFALSE); + res.fResultsFlagsPro->SetStats(false); res.fResultsFlagsPro->SetLineColor(eColor); res.fResultsFlagsPro->SetFillColor(eFillColor); - res.fResultsFlagsPro->GetXaxis()->SetBinLabel(1, "fSaveResultsHistograms"); - res.fResultsFlagsPro->Fill(0.5, res.fSaveResultsHistograms); - // ... - res.fResultsList->Add(res.fResultsFlagsPro); - // b) Book results histograms, which in addition act as a sort of "abstract" interface, which defines common binning, etc., for other groups of histograms: - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { - if (res.fUseResultsProVariableLengthBins[v]) { - // per demand, variable-length binning: - res.fResultsPro[v] = new TProfile(Form("fResultsPro[%s]", res.fResultsProRawName[v].Data()), "...", res.fResultsProVariableLengthBins[v]->GetSize() - 1, res.fResultsProVariableLengthBins[v]->GetArray()); - } else { - // the default fixed-length binning: - res.fResultsPro[v] = new TProfile(Form("fResultsPro[%s]", res.fResultsProRawName[v].Data()), "...", static_cast(res.fResultsProFixedLengthBins[v][0]), res.fResultsProFixedLengthBins[v][1], res.fResultsProFixedLengthBins[v][2]); + if (tc.fUseSetBinLabel) { + res.fResultsFlagsPro->GetXaxis()->SetBinLabel(1, "fSaveResultsHistograms"); + res.fResultsFlagsPro->Fill(0.5, res.fSaveResultsHistograms); + + // ... + + } else { + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + + yAxisTitle += TString::Format("%d:fSaveResultsHistograms; ", 1); + res.fResultsFlagsPro->Fill(0.5, static_cast(res.fSaveResultsHistograms)); + + // ... + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); } + if (oa->GetEntries() - 1 != res.fResultsFlagsPro->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() = %d != res.fResultsFlagsPro->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), res.fResultsFlagsPro->GetNbinsX()); + } + delete oa; + + // *) Okay, set the title: + res.fResultsFlagsPro->GetYaxis()->SetTitle(yAxisTitle.Data()); + } + res.fResultsList->Add(res.fResultsFlagsPro); + + // b) Book (and optionaly save) results histograms 1D: + for (int v = 0; v < eAsFunctionOf_N; v++) { + + // TBI 20250518 I book 1D case always for the time being, because I also use their binning to book particle sparse histograms. + // There should not be any big memory penalty for 1D case + // if (!(t0.fCalculateTest0AsFunctionOf[v] || mupa.fCalculateCorrelationsAsFunctionOf[v] || es.fCalculateEtaSeparationsAsFunctionOf[v])) { + // // TBI 20250518 do I need here also some check for the nested loops? + // continue; + // } - // Optionally, save these histograms. Or just use them as an "abstract" interface for the booking of other group of histograms: + res.fResultsPro[v] = new TProfile(Form("fResultsPro[%s]", res.fResultsProRawName[v].Data()), "...", res.fResultsProBinEdges[v]->GetSize() - 1, res.fResultsProBinEdges[v]->GetArray()); + res.fResultsPro[v]->GetXaxis()->SetTitle(res.fResultsProXaxisTitle[v].Data()); + res.fResultsPro[v]->SetStats(false); + + delete res.fResultsProBinEdges[v]; // yes, it served the purpose. Now this info is carried permanently with res.fResultsPro[v], and I can always retrieve it later with e.g. + // res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins() (which gives pointer to TArrayD, yes I need double, because TProfile ctor takes double) + + // Optionally, save these histograms - I need this mostly to check/validate the binning. if (res.fSaveResultsHistograms) { res.fResultsList->Add(res.fResultsPro[v]); } - } // for (Int_t v = 0; v < eAsFunctionOf_N; v++) { + } // for (int v = 0; v < eAsFunctionOf_N; v++) + + // c) Book (and optionaly save) results histograms 2D: + // Remark 1: Here I cannot loop, because for each axis I re-use binning from 1D cases. + // Remark 2: I have deleted above res.fResultsProBinEdges[...], that info is now only in the axis of res.fResultsPro[...] + if (t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_PT]) { + TString rawName = TString::Format("%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_PT].Data()); // raw name is e.g. "[cent_pt]" in the file + res.fResultsPro2D[AFO_CENTRALITY_PT] = new TProfile2D(Form("fResultsPro2D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro2D[AFO_CENTRALITY_PT]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_CENTRALITY_PT]->GetYaxis()->SetTitle(res.fResultsPro[AFO_PT]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_CENTRALITY_PT]->SetStats(false); + } + + if (t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_ETA]) { + TString rawName = TString::Format("%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_ETA].Data()); + res.fResultsPro2D[AFO_CENTRALITY_ETA] = new TProfile2D(Form("fResultsPro2D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro2D[AFO_CENTRALITY_ETA]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_CENTRALITY_ETA]->GetYaxis()->SetTitle(res.fResultsPro[AFO_ETA]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_CENTRALITY_ETA]->SetStats(false); + } + + if (t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_CHARGE]) { + TString rawName = TString::Format("%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_CHARGE].Data()); + res.fResultsPro2D[AFO_CENTRALITY_CHARGE] = new TProfile2D(Form("fResultsPro2D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetArray()); + + res.fResultsPro2D[AFO_CENTRALITY_CHARGE]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_CENTRALITY_CHARGE]->GetYaxis()->SetTitle(res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_CENTRALITY_CHARGE]->SetStats(false); + } + + if (t0.fCalculate2DTest0AsFunctionOf[AFO_CENTRALITY_VZ]) { + TString rawName = TString::Format("%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_VZ].Data()); + res.fResultsPro2D[AFO_CENTRALITY_VZ] = new TProfile2D(Form("fResultsPro2D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_VZ]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_VZ]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro2D[AFO_CENTRALITY_VZ]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_CENTRALITY_VZ]->GetYaxis()->SetTitle(res.fResultsPro[AFO_VZ]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_CENTRALITY_VZ]->SetStats(false); + } + + if (t0.fCalculate2DTest0AsFunctionOf[AFO_PT_ETA]) { + TString rawName = TString::Format("%s_%s", res.fResultsProRawName[AFO_PT].Data(), res.fResultsProRawName[AFO_ETA].Data()); + res.fResultsPro2D[AFO_PT_ETA] = new TProfile2D(Form("fResultsPro2D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro2D[AFO_PT_ETA]->GetXaxis()->SetTitle(res.fResultsPro[AFO_PT]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_PT_ETA]->GetYaxis()->SetTitle(res.fResultsPro[AFO_ETA]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_PT_ETA]->SetStats(false); + } + + if (t0.fCalculate2DTest0AsFunctionOf[AFO_PT_CHARGE]) { + TString rawName = TString::Format("%s_%s", res.fResultsProRawName[AFO_PT].Data(), res.fResultsProRawName[AFO_CHARGE].Data()); + res.fResultsPro2D[AFO_PT_CHARGE] = new TProfile2D(Form("fResultsPro2D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro2D[AFO_PT_CHARGE]->GetXaxis()->SetTitle(res.fResultsPro[AFO_PT]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_PT_CHARGE]->GetYaxis()->SetTitle(res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_PT_CHARGE]->SetStats(false); + } + + if (t0.fCalculate2DTest0AsFunctionOf[AFO_ETA_CHARGE]) { + TString rawName = TString::Format("%s_%s", res.fResultsProRawName[AFO_ETA].Data(), res.fResultsProRawName[AFO_CHARGE].Data()); + res.fResultsPro2D[AFO_ETA_CHARGE] = new TProfile2D(Form("fResultsPro2D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro2D[AFO_ETA_CHARGE]->GetXaxis()->SetTitle(res.fResultsPro[AFO_ETA]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_ETA_CHARGE]->GetYaxis()->SetTitle(res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetTitle()); + res.fResultsPro2D[AFO_ETA_CHARGE]->SetStats(false); + } + + // ... + + // Optionally, save 2D results histograms - I need this mostly to check/validate the binning: + for (int v = 0; v < eAsFunctionOf2D_N; v++) { + if (res.fSaveResultsHistograms && res.fResultsPro2D[v]) { + res.fResultsList->Add(res.fResultsPro2D[v]); + } + } + + // d) Book (and optionaly save) results histograms 3D: + // Remark 1: Here I cannot loop, because for each axis I re-use binning from 1D cases. + // Remark 2: I have deleted above res.fResultsProBinEdges[...], that info is now only in the axis of res.fResultsPro[...] + if (t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_ETA]) { + TString rawName = TString::Format("%s_%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_PT].Data(), res.fResultsProRawName[AFO_ETA].Data()); + res.fResultsPro3D[AFO_CENTRALITY_PT_ETA] = new TProfile3D(Form("fResultsPro3D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro3D[AFO_CENTRALITY_PT_ETA]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_PT_ETA]->GetYaxis()->SetTitle(res.fResultsPro[AFO_PT]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_PT_ETA]->GetZaxis()->SetTitle(res.fResultsPro[AFO_ETA]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_PT_ETA]->SetStats(false); + } + + if (t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_CHARGE]) { + TString rawName = TString::Format("%s_%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_PT].Data(), res.fResultsProRawName[AFO_CHARGE].Data()); + res.fResultsPro3D[AFO_CENTRALITY_PT_CHARGE] = new TProfile3D(Form("fResultsPro3D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro3D[AFO_CENTRALITY_PT_CHARGE]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_PT_CHARGE]->GetYaxis()->SetTitle(res.fResultsPro[AFO_PT]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_PT_CHARGE]->GetZaxis()->SetTitle(res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_PT_CHARGE]->SetStats(false); + } + + if (t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_VZ]) { + TString rawName = TString::Format("%s_%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_PT].Data(), res.fResultsProRawName[AFO_VZ].Data()); + res.fResultsPro3D[AFO_CENTRALITY_PT_VZ] = new TProfile3D(Form("fResultsPro3D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_VZ]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_VZ]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro3D[AFO_CENTRALITY_PT_VZ]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_PT_VZ]->GetYaxis()->SetTitle(res.fResultsPro[AFO_PT]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_PT_VZ]->GetZaxis()->SetTitle(res.fResultsPro[AFO_VZ]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_PT_VZ]->SetStats(false); + } + + if (t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_VZ]) { + TString rawName = TString::Format("%s_%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_ETA].Data(), res.fResultsProRawName[AFO_VZ].Data()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_VZ] = new TProfile3D(Form("fResultsPro3D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_VZ]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_VZ]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_VZ]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_VZ]->GetYaxis()->SetTitle(res.fResultsPro[AFO_ETA]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_VZ]->GetZaxis()->SetTitle(res.fResultsPro[AFO_VZ]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_VZ]->SetStats(false); + } + + if (t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_CHARGE]) { + TString rawName = TString::Format("%s_%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_ETA].Data(), res.fResultsProRawName[AFO_CHARGE].Data()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_CHARGE] = new TProfile3D(Form("fResultsPro3D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_CHARGE]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_CHARGE]->GetYaxis()->SetTitle(res.fResultsPro[AFO_ETA]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_CHARGE]->GetZaxis()->SetTitle(res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_ETA_CHARGE]->SetStats(false); + } + + if (t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_VZ_CHARGE]) { + TString rawName = TString::Format("%s_%s_%s", res.fResultsProRawName[AFO_CENTRALITY].Data(), res.fResultsProRawName[AFO_VZ].Data(), res.fResultsProRawName[AFO_CHARGE].Data()); + res.fResultsPro3D[AFO_CENTRALITY_VZ_CHARGE] = new TProfile3D(Form("fResultsPro3D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_VZ]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_VZ]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro3D[AFO_CENTRALITY_VZ_CHARGE]->GetXaxis()->SetTitle(res.fResultsPro[AFO_CENTRALITY]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_VZ_CHARGE]->GetYaxis()->SetTitle(res.fResultsPro[AFO_VZ]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_VZ_CHARGE]->GetZaxis()->SetTitle(res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_CENTRALITY_VZ_CHARGE]->SetStats(false); + } + + if (t0.fCalculate3DTest0AsFunctionOf[AFO_PT_ETA_CHARGE]) { + TString rawName = TString::Format("%s_%s_%s", res.fResultsProRawName[AFO_PT].Data(), res.fResultsProRawName[AFO_ETA].Data(), res.fResultsProRawName[AFO_CHARGE].Data()); + res.fResultsPro3D[AFO_PT_ETA_CHARGE] = new TProfile3D(Form("fResultsPro3D[%s]", rawName.Data()), "...", + res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_PT]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_ETA]->GetXaxis()->GetXbins()->GetArray(), + res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetSize() - 1, res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetXbins()->GetArray()); + res.fResultsPro3D[AFO_PT_ETA_CHARGE]->GetXaxis()->SetTitle(res.fResultsPro[AFO_PT]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_PT_ETA_CHARGE]->GetYaxis()->SetTitle(res.fResultsPro[AFO_ETA]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_PT_ETA_CHARGE]->GetZaxis()->SetTitle(res.fResultsPro[AFO_CHARGE]->GetXaxis()->GetTitle()); + res.fResultsPro3D[AFO_PT_ETA_CHARGE]->SetStats(false); + } + + // Optionally, save 3D results histograms - I need this mostly to check/validate the binning: + for (int v = 0; v < eAsFunctionOf3D_N; v++) { + + if (res.fSaveResultsHistograms && res.fResultsPro3D[v]) { + res.fResultsList->Add(res.fResultsPro3D[v]); + } + } if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void BookResultsHistograms() +} // void bookResultsHistograms() //============================================================ -void BookTheRest() +TArrayD* ArrayWithBinEdges(int nBins, float min, float max) +{ + // Helper function to determine concrete bin edges, when the fixed-size binning was specified with nBins in (min, max). + + // a) Insanity checks on arguments; + // b) Okay, do the thing. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // a) Insanity check on arguments: + if (nBins <= 0 || max < min || std::abs(max - min) < tc.fFloatingPointPrecision) { + LOGF(fatal, "\033[1;31m%s at line %d : Insane arguments for fixed-length binning: nBins = %d , min = %f, max = %f \033[0m", __FUNCTION__, __LINE__, nBins, min, max); + } + + // b) Okay, do the thing: + float binWidth = (max - min) / (1. * nBins); + + TArrayD* binEdges = new TArrayD(nBins + 1); + for (int b = 1; b <= nBins + 1; b++) { + binEdges->AddAt(min + (b - 1) * binWidth, b - 1); + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + + return binEdges; + +} // TArrayD *ArrayWithBinEdges(int nBins, float min, float max) + +//============================================================ + +void bookTheRest() { // Here I book everything not sorted (yes) in specific functions above. // a) Book the timer; + // b) Book TDatabasePDG; // *) ... if (tc.fVerbose) { @@ -4595,11 +7798,16 @@ void BookTheRest() tc.fTimer[eLocal] = new TStopwatch(); } + // b) Book TDatabasePDG: + if (tc.fUseDatabasePDG) { + tc.fDatabasePDG = new TDatabasePDG(); // there is a standard memory blow-up here + } + if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void BookTheRest() +} // void bookTheRest() //============================================================ @@ -4622,7 +7830,7 @@ void Preprocess(T1 const& collision, T2 const& bcs) // *) If I reached max number of events, ignore the remaining collisions: if (MaxNumberOfEvents(eAfter) || MaxNumberOfEvents(eBefore)) { // TBI 20240510 this is a bit confusing, implemented this way. Shall I split off? - BailOut(kTRUE); + BailOut(true); } // *) Determine and propagate run number info to already booked objects: @@ -4630,25 +7838,50 @@ void Preprocess(T1 const& collision, T2 const& bcs) DetermineRunNumber(collision, bcs); PropagateRunNumber(); } + if (tc.fDoAdditionalInsanityChecks && tc.fRunNumberIsDetermined) { CheckCurrentRunNumber(collision, bcs); } + // *) Check whether this run shall be skipped later from further processing in Steer(): + if (!tc.fSkipTheseRuns.EqualTo("")) { + // If tc.fSkipTheseRuns is not empty, that means it holds comma-separated list of runs to be skipped. Let's check it out... + SkipThisRun(); // I set inside the data member tc.fSkipRun , which serves then as a switch later all over the place + if (tc.fSkipRun) { + return; // yes, I bail out immediately from Preprocess, so that I do not waste time on fetching weights for this run + } + // TBI 20250316 Same comment here: At the moment I can access run number info only in process(...), but not in init(...) + // Once I can access run number info in init(...), this function shall be called in init(...), not in process(...) + } // if (!tc.fSkipTheseRuns.EqualTo("")) + // *) Fetch the weights for this particular run number. Do it only once. // TBI 20231012 If eventualy I can access programatically run number in init(...) at run time, this shall go there. if (!pw.fParticleWeightsAreFetched) { + + // integrated weights and differentials weights without sparse histograms (the latter is becoming obsolete): if (pw.fUseWeights[wPHI] || pw.fUseWeights[wPT] || pw.fUseWeights[wETA] || pw.fUseDiffWeights[wPHIPT] || pw.fUseDiffWeights[wPHIETA]) { GetParticleWeights(); - pw.fParticleWeightsAreFetched = kTRUE; + pw.fParticleWeightsAreFetched = true; + } + + // differential particle weights using sparse histogreams: + if (pw.fUseDiffPhiWeights[wPhiPhiAxis] || pw.fUseDiffPtWeights[wPtPtAxis] || pw.fUseDiffPtWeights[wEtaEtaAxis]) { + // Yes, I check only the first flag. This way, I can e.g. switch off all differential phi weights by setting 0-wPhi in config. + // On the other hand, it doesn't make sense to calculate differential phi weights without having phi axis. + // At any point I shall be able to fall back e.g. to integrated phi weights, that corresponds to the case wheh "1-wPhi" and all others are "0-w..." + // Same for differential pt or eta weights. + GetParticleWeights(); + pw.fParticleWeightsAreFetched = true; } - } + + } // if (!pw.fParticleWeightsAreFetched) { // *) Fetch the centrality weights for this particular run number. Do it only once. // TBI 20231012 If eventualy I can access programatically run number in init(...) at run time, this shall go there. if (!cw.fCentralityWeightsAreFetched) { if (cw.fUseCentralityWeights) { GetCentralityWeights(); - cw.fCentralityWeightsAreFetched = kTRUE; + cw.fCentralityWeightsAreFetched = true; } } @@ -4669,15 +7902,15 @@ void DetermineRunNumber(T1 const& collision, T2 const&) // TBI 20231018 At the moment I can access run number info only in process(...), but not in init(...) // Once I can access run number info in init(...), this function shall be called in init(...), not in process(...) - // a) Determine run number for Run 3 real data; - // b) Determine run number for the rest. TBI 20241126 differentiate this support as well, e.g. for eRecSim and eSim. But Run 2 and Run 1 most likely will stay as before + // a) Determine run number for Run 3 and Run 2 real data; + // b) Determine run number for the rest. TBI 20241126 differentiate this support as well, e.g. for eRecSim and eSim. if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // a) Determine run number for Run 3 real data: - if constexpr (rs == eRec || rs == eRecAndSim) { + // a) Determine run number for Run 3 and Run 2 real data; + if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eQA) { // **) Determine run number: // Get start timestamp and end timemstamp for this run in miliseconds, and convert both of them in seconds: @@ -4706,11 +7939,15 @@ void DetermineRunNumber(T1 const& collision, T2 const&) LOGF(fatal, "\033[1;31m%s at line %d : tc.fRunTime[eDurationInSec] = %d is not positive\033[0m", __FUNCTION__, __LINE__, tc.fRunTime[eDurationInSec]); } + } else if constexpr (rs == eTest) { + LOGF(warning, "\033[1;33m%s at line %d : RunNumber cannot be determined for eTest mode, due to minimal subscription. Setting run number manually to some dummy value. If you do not like this, extend subscription to more tables.\033[0m", __FUNCTION__, __LINE__); + tc.fRunNumber = "123456"; } else { - // b) Determine run number for the rest. TBI 20241126 differentiate this support as well, e.g. for eRecSim and eSim. But Run 2 and Run 1 most likely will stay as before + // b) Determine run number for the rest. + // TBI 20241126 differentiate this support as well, e.g. for eRecSim and eSim. LOGF(fatal, "\033[1;31m%s at line %d : bc.runNumber() is not validated yet for this case\033[0m", __FUNCTION__, __LINE__); } - tc.fRunNumberIsDetermined = kTRUE; + tc.fRunNumberIsDetermined = true; if (tc.fVerbose) { ExitFunction(__FUNCTION__); @@ -4734,15 +7971,21 @@ void PropagateRunNumber() } // *) base: - fBasePro->GetXaxis()->SetBinLabel(eRunNumber, Form("fRunNumber = %s", tc.fRunNumber.Data())); + if (tc.fUseSetBinLabel) { + fBasePro->GetXaxis()->SetBinLabel(eRunNumber, Form("fRunNumber = %s", tc.fRunNumber.Data())); + } else { + // Workaround for SetBinLabel() large memory consumption: + TString tmp = fBasePro->GetYaxis()->GetTitle(); + fBasePro->GetYaxis()->SetTitle(tmp.ReplaceAll("__RUN_NUMBER__", tc.fRunNumber.Data())); + } // else // *) common title var: TString histTitle = ""; // *) event cuts: - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter + for (int cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter { if (!ec.fEventCutCounterHist[rs][cc]) { continue; @@ -4756,11 +7999,11 @@ void PropagateRunNumber() } // *) event histograms 1D: - for (Int_t t = 0; t < eEventHistograms_N; t++) // type, see enum eEventHistograms + for (int t = 0; t < eEventHistograms_N; t++) // type, see enum eEventHistograms { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!eh.fEventHistograms[t][rs][ba]) { continue; @@ -4770,16 +8013,16 @@ void PropagateRunNumber() histTitle.ReplaceAll("__RUN_NUMBER__", tc.fRunNumber.Data()); // it replaces in-place eh.fEventHistograms[t][rs][ba]->SetTitle(histTitle.Data()); } - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for(Int_t t=0;tSetTitle(histTitle.Data()); } - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eEventHistograms2D + } // for(int ba=0;ba<2;ba++) + } // for(int rs=0;rs<2;rs++) // reco/sim + } // for (int t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eEventHistograms2D // *) particle histograms 2D: - for (Int_t t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D + for (int t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!qa.fQAParticleHistograms2D[t][rs][ba]) { continue; @@ -4808,16 +8051,16 @@ void PropagateRunNumber() histTitle.ReplaceAll("__RUN_NUMBER__", tc.fRunNumber.Data()); // it replaces in-place qa.fQAParticleHistograms2D[t][rs][ba]->SetTitle(histTitle.Data()); } - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for (Int_t t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D + } // for(int ba=0;ba<2;ba++) + } // for(int rs=0;rs<2;rs++) // reco/sim + } // for (int t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D // *) particle event histograms 2D: - for (Int_t t = 0; t < eQAParticleEventHistograms2D_N; t++) // type, see enum eParticleEventHistograms2D + for (int t = 0; t < eQAParticleEventHistograms2D_N; t++) // type, see enum eParticleEventHistograms2D { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!qa.fQAParticleEventHistograms2D[t][rs][ba]) { continue; @@ -4827,14 +8070,66 @@ void PropagateRunNumber() histTitle.ReplaceAll("__RUN_NUMBER__", tc.fRunNumber.Data()); // it replaces in-place qa.fQAParticleEventHistograms2D[t][rs][ba]->SetTitle(histTitle.Data()); } - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for (Int_t t = 0; t < eQAParticleEventHistograms2D_N; t++) // type, see enum eParticleEventHistograms2D + } // for(int ba=0;ba<2;ba++) + } // for(int rs=0;rs<2;rs++) // reco/sim + } // for (int t = 0; t < eQAParticleEventHistograms2D_N; t++) // type, see enum eParticleEventHistograms2D + + // *) particle sparse histograms: + for (int t = 0; t < eDiffWeightCategory_N; t++) // category, see enum eDiffWeightCategory + { + for (int rs = 0; rs < 2; rs++) // reco/sim + { + if (!ph.fParticleSparseHistograms[t][rs]) { + continue; + } + histTitle = ph.fParticleSparseHistograms[t][rs]->GetTitle(); + if (histTitle.Contains("__RUN_NUMBER__")) { + histTitle.ReplaceAll("__RUN_NUMBER__", tc.fRunNumber.Data()); // it replaces in-place + ph.fParticleSparseHistograms[t][rs]->SetTitle(histTitle.Data()); + } + } // for(int rs=0;rs<2;rs++) // reco/sim + } // for (int t = 0; t < eDiffWeightCategory; t++) // category, see enum eDiffWeightCategory + + // *) "correlations vs." histograms 2D: + for (int t = 0; t < eQACorrelationsVsHistograms2D_N; t++) // type, see enum eCorrelationsVsHistograms2D + { + for (int h = 0; h < gMaxHarmonic; h++) { + for (int rs = 0; rs < 2; rs++) // reco/sim + { + if (!qa.fQACorrelationsVsHistograms2D[t][h][rs]) { + continue; + } + histTitle = qa.fQACorrelationsVsHistograms2D[t][h][rs]->GetTitle(); + if (histTitle.Contains("__RUN_NUMBER__")) { + histTitle.ReplaceAll("__RUN_NUMBER__", tc.fRunNumber.Data()); // it replaces in-place + qa.fQACorrelationsVsHistograms2D[t][h][rs]->SetTitle(histTitle.Data()); + } + } // for(int rs=0;rs<2;rs++) // reco/sim + } // for (int h = 0; h < gMaxHarmonic; h++) + } // for (int t = 0; t < eQACorrelationsVsHistograms2D_N; t++) // type, see enum eCorrelationsVsHistograms2D + + // *) "correlations vs. IR vs. " profiles 2D: + for (int t = 0; t < eQACorrelationsVsInteractionRateVsProfiles2D_N; t++) // type, see enum eCorrelationsVsInteractionRateVsProfiles2D + { + for (int h = 0; h < gMaxHarmonic; h++) { + for (int rs = 0; rs < 2; rs++) // reco/sim + { + if (!qa.fQACorrVsIRVsProfiles2D[t][h][rs]) { + continue; + } + histTitle = qa.fQACorrVsIRVsProfiles2D[t][h][rs]->GetTitle(); + if (histTitle.Contains("__RUN_NUMBER__")) { + histTitle.ReplaceAll("__RUN_NUMBER__", tc.fRunNumber.Data()); // it replaces in-place + qa.fQACorrVsIRVsProfiles2D[t][h][rs]->SetTitle(histTitle.Data()); + } + } // for(int rs=0;rs<2;rs++) // reco/sim + } // for (int h = 0; h < gMaxHarmonic; h++) + } // for (int t = 0; t < eQACorrelationsVsInteractionRateVsProfiles2D_N; t++) // type, see enum eCorrelationsVsInteractionRateVsProfiles2D // *) particle cuts: - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter + for (int cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter { if (!pc.fParticleCutCounterHist[rs][cc]) { continue; @@ -4848,11 +8143,11 @@ void PropagateRunNumber() } // *) particle histograms 1D: - for (Int_t t = 0; t < eParticleHistograms_N; t++) // type, see enum eParticleHistograms + for (int t = 0; t < eParticleHistograms_N; t++) // type, see enum eParticleHistograms { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!ph.fParticleHistograms[t][rs][ba]) { continue; @@ -4862,16 +8157,16 @@ void PropagateRunNumber() histTitle.ReplaceAll("__RUN_NUMBER__", tc.fRunNumber.Data()); // it replaces in-place ph.fParticleHistograms[t][rs][ba]->SetTitle(histTitle.Data()); } - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for(Int_t t=0;tSetTitle(histTitle.Data()); } - } // for(Int_t ba=0;ba<2;ba++) - } // for(Int_t rs=0;rs<2;rs++) // reco/sim - } // for(Int_t t=0;t -eta , ab = 1 <=> + eta - for (Int_t rs = 0; rs < 2; rs++) { // reco/sim - for (Int_t ba = 0; ba < 2; ba++) { // before/after cuts - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + for (int ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta + for (int rs = 0; rs < 2; rs++) { // reco/sim + for (int ba = 0; ba < 2; ba++) { // before/after cuts + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation if (!qv.fMabDist[ab][rs][ba][e]) { continue; } @@ -4917,17 +8212,20 @@ void CheckCurrentRunNumber(T1 const& collision, T2 const&) // Insanity check for the current run number and related thingies. // Used only during validation. - // a) Support for Run 3 real data; + // a) Support for Run 3 and Run 2 real data; // b) The rest. TBI 20241126 differentiate this support as well, e.g. for eRecSim and eSim. But Run 2 and Run 1 most likely will stay as before if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // a) Support for Run 3 real data: - if constexpr (rs == eRec) { + // a) Support for Run 3 and Run 2 real data: + // TBI 20250112 enable other cases, after validating them + // TBI 20250112 Remember that I can get total run duration in converted data, but not current run duration. + if constexpr (rs == eRec || rs == eRec_Run2 || rs == eQA) { // **) Check run number: + auto bc = collision.template foundBC_as(); // I have the same code snippet at other places, keep in sync. if (!tc.fRunNumber.EqualTo(Form("%d", bc.runNumber()))) { LOGF(error, "\033[1;33m%s Run number changed within process(). This most likely indicates that a given masterjob is processing 2 or more different runs in one go.\033[0m", __FUNCTION__); @@ -4958,6 +8256,8 @@ void CheckCurrentRunNumber(T1 const& collision, T2 const&) LOGF(fatal, "tc.fRunTime[eDurationInSec] = %d, durationInSec = %d", tc.fRunTime[eDurationInSec], durationInSec); } + } else if constexpr (rs == eTest) { + LOGF(warning, "\033[1;33m%s at line %d : RunNumber cannot be checked in eTest mode, due to minimal subscription. Simply skipping this check. If you do not like this, extend subscription to more tables.\033[0m", __FUNCTION__, __LINE__); } else { // b) The rest: @@ -4995,9 +8295,14 @@ void ResetEventByEventQuantities() ebye.fMultiplicity = 0.; ebye.fReferenceMultiplicity = 0.; ebye.fCentrality = 0.; + // ebye.fCentralitySim = 0.; // TBI 20250429 special treatment, because I access this one before Steer(...) is called in .cxx . Re-think how to handle this one + // But if I do not access it in .cxx, in any case I skip that collision, so I think it is just fine not to reset it here ebye.fOccupancy = 0.; ebye.fInteractionRate = 0.; ebye.fCurrentRunDuration = 0.; + ebye.fVz = 0.; + ebye.fFT0CAmplitudeOnFoundBC = 0.; + ebye.fImpactParameter = 0.; // I can reset it here to 0., as long as I am calculating it from collision.mcCollision().impactParameter() . If I calculate it from hep.impactParameter(), i need to re-think // b) Q-vectors: if (qv.fCalculateQvectors) { @@ -5005,68 +8310,79 @@ void ResetEventByEventQuantities() // b0) generic Q-vector: ResetQ(); // b1) integrated Q-vector: - for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { - for (Int_t wp = 0; wp < gMaxCorrelator + 1; wp++) // weight power + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) // weight power { qv.fQvector[h][wp] = TComplex(0., 0.); } } + } // if (qv.fCalculateQvectors) + + if (qv.fCalculateqvectorsKineAny) { + ResetQ(); // TBI 20250601 do I really need this one here. It doesn't hurt, though... + // Remark: It's important to validate this reset with nested loops e-by-e and for all events. + for (int i = 0; i < static_cast(qv.fqvector.size()); ++i) { + for (int j = 0; j < static_cast(qv.fqvector[i].size()); ++j) { + qv.fqvectorEntries[i][j] = 0; + for (int k = 0; k < static_cast(qv.fqvector[i][j].size()); ++k) { + for (int l = 0; l < static_cast(qv.fqvector[i][j][k].size()); ++l) { + qv.fqvector[i][j][k][l] = {0., 0.}; // yes, this is the right notation for complex numbers + } + } + } + } - // b2) diff. Q-vector: - for (Int_t bin = 1; bin <= gMaxNoBinsKine; bin++) { - qv.fqVectorEntries[PTq][bin - 1] = 0; // TBI 20240214 shall I loop also over enum's PTq and ETAq? If yes, fix it also below for qv.fqvector[PTq][bin - 1][... - qv.fqVectorEntries[ETAq][bin - 1] = 0; - for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { - for (Int_t wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power - qv.fqvector[PTq][bin - 1][h][wp] = TComplex(0., 0.); - qv.fqvector[ETAq][bin - 1][h][wp] = TComplex(0., 0.); - } // for (Int_t wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power - } // for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { - } // for (Int_t b = 0; b < gMaxNoBinsKine; b++ ) { - } // if(qv.fCalculateQvectors) + } // if (qv.fCalculateqvectorsKineAny) // b3) integrated Q-vector needed for calculations with eta separations: if (es.fCalculateEtaSeparations) { - for (Int_t ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta - for (Int_t h = 0; h < gMaxHarmonic; h++) { + for (int ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta + for (int h = 0; h < gMaxHarmonic; h++) { if (es.fEtaSeparationsSkipHarmonics[h]) { continue; } - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation qv.fQabVector[ab][h][e] = TComplex(0., 0.); } } } - for (Int_t ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + for (int ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation qv.fMab[ab][e] = 0.; } } } - // b4) diff. q-vector in pt needed for calculations with eta separations: - if (es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT]) { // yes, for the time being, only as a function of pt makes sense if eta separation is used - for (Int_t ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta - for (Int_t bin = 1; bin <= gMaxNoBinsKine; bin++) { - for (Int_t h = 0; h < gMaxHarmonic; h++) { - if (es.fEtaSeparationsSkipHarmonics[h]) { - continue; - } - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { - qv.fqabVector[ab][bin - 1][h][e] = TComplex(0., 0.); // yes, bin - 1 here + // b4) diff. q-vector needed for calculations with eta separations: + if (es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT]) { // _444 check this conditions + // [-eta or +eta][eqvectorKine_N][global binNo][harmonic][eta separation] + for (int i = 0; i < static_cast(qv.fqabVector.size()); ++i) { + for (int j = 0; j < static_cast(qv.fqabVector[i].size()); ++j) { + for (int k = 0; k < static_cast(qv.fqabVector[i][j].size()); ++k) { + for (int l = 0; l < static_cast(qv.fqabVector[i][j][k].size()); ++l) { // yes, this dimension is for harmonics at the moment + if (es.fEtaSeparationsSkipHarmonics[l]) { + continue; + } + for (int m = 0; m < static_cast(qv.fqabVector[i][j][k][l].size()); ++m) { + qv.fqabVector[i][j][k][l][m] = {0., 0.}; // yes, this is the right notation for complex numbers + } } } } } - for (Int_t ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta - for (Int_t bin = 1; bin <= gMaxNoBinsKine; bin++) { - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { - qv.fmab[ab][bin - 1][e] = 0.; // yes, bin - 1 here + // [-eta or +eta][eqvectorKine_N][global binNo][eta separation] + for (int i = 0; i < static_cast(qv.fmab.size()); ++i) { + for (int j = 0; j < static_cast(qv.fmab[i].size()); ++j) { + for (int k = 0; k < static_cast(qv.fmab[i][j].size()); ++k) { + for (int l = 0; l < static_cast(qv.fmab[i][j][k].size()); ++l) { + qv.fmab[i][j][k][l] = 0.; + } } } } - } + + } // if (es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT]) // c) Reset ebe containers for nested loops: if (nl.fCalculateNestedLoops || nl.fCalculateCustomNestedLoops) { @@ -5080,14 +8396,74 @@ void ResetEventByEventQuantities() } // if(nl.fCalculateNestedLoops || nl.fCalculateCustomNestedLoops) if (nl.fCalculateKineCustomNestedLoops) { - for (Int_t b = 0; b < res.fResultsPro[AFO_PT]->GetNbinsX(); b++) { + int nBins = -1; + + // 1D kine: + // **) vs. pt: + nBins = res.fResultsPro[AFO_PT]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { nl.ftaNestedLoopsKine[PTq][b][0]->Reset(); nl.ftaNestedLoopsKine[PTq][b][1]->Reset(); } - for (Int_t b = 0; b < res.fResultsPro[AFO_ETA]->GetNbinsX(); b++) { + + // **) vs. eta: + nBins = res.fResultsPro[AFO_ETA]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { nl.ftaNestedLoopsKine[ETAq][b][0]->Reset(); nl.ftaNestedLoopsKine[ETAq][b][1]->Reset(); } + + // **) vs. charge: + nBins = res.fResultsPro[AFO_CHARGE]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { + nl.ftaNestedLoopsKine[CHARGEq][b][0]->Reset(); + nl.ftaNestedLoopsKine[CHARGEq][b][1]->Reset(); + } + + // ... + + // 2D kine: + // **) vs. (pt,eta): + if (res.fResultsPro2D[AfoKineMap2D(PT_ETAq)]) { // this is safe, because this one shall be booked if any of Correlations, Test0, EtaSeparations, etc., was requested + nBins = (res.fResultsPro2D[AfoKineMap2D(PT_ETAq)]->GetNbinsX() + 2) * (res.fResultsPro2D[AfoKineMap2D(PT_ETAq)]->GetNbinsY() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { // loop over lineralized global bins + nl.ftaNestedLoopsKine[PT_ETAq][b][0]->Reset(); + nl.ftaNestedLoopsKine[PT_ETAq][b][1]->Reset(); + } + } + + // **) vs. (pt,charge): + if (res.fResultsPro2D[AfoKineMap2D(PT_CHARGEq)]) { // this is safe, because this one shall be booked if any of Correlations, Test0, EtaSeparations, etc., was requested + nBins = (res.fResultsPro2D[AfoKineMap2D(PT_CHARGEq)]->GetNbinsX() + 2) * (res.fResultsPro2D[AfoKineMap2D(PT_CHARGEq)]->GetNbinsY() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { // loop over lineralized global bins + nl.ftaNestedLoopsKine[PT_CHARGEq][b][0]->Reset(); + nl.ftaNestedLoopsKine[PT_CHARGEq][b][1]->Reset(); + } + } + + // **) vs. (eta,charge): + if (res.fResultsPro2D[AfoKineMap2D(ETA_CHARGEq)]) { // this is safe, because this one shall be booked if any of Correlations, Test0, EtaSeparations, etc., was requested + nBins = (res.fResultsPro2D[AfoKineMap2D(ETA_CHARGEq)]->GetNbinsX() + 2) * (res.fResultsPro2D[AfoKineMap2D(ETA_CHARGEq)]->GetNbinsY() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { // loop over lineralized global bins + nl.ftaNestedLoopsKine[ETA_CHARGEq][b][0]->Reset(); + nl.ftaNestedLoopsKine[ETA_CHARGEq][b][1]->Reset(); + } + } + + // ... + + // 3D kine: + // **) vs. (pt,eta,charge): + if (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]) { // this is safe, because this one shall be booked if any of Correlations, Test0, EtaSeparations, etc., was requested + nBins = (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]->GetNbinsX() + 2) * (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]->GetNbinsY() + 2) * (res.fResultsPro3D[AfoKineMap3D(PT_ETA_CHARGEq)]->GetNbinsZ() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + for (int b = 0; b < nBins; b++) { // loop over lineralized global bins + nl.ftaNestedLoopsKine[PT_ETA_CHARGEq][b][0]->Reset(); + nl.ftaNestedLoopsKine[PT_ETA_CHARGEq][b][1]->Reset(); + } + } + + // ... + } // if(nl.fCalculateKineCustomNestedLoops) { // d) Fisher-Yates algorithm: @@ -5097,9 +8473,9 @@ void ResetEventByEventQuantities() } // e) QA: - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (qa.fQAParticleEventProEbyE[rs][ba]) { qa.fQAParticleEventProEbyE[rs][ba]->Reset(); @@ -5147,31 +8523,61 @@ void EventCutsCounters(T1 const& collision, T2 const& tracks) } // **) Map this ordering into bin labels of actual histograms for event cut counters: - for (Int_t rec_sim = 0; rec_sim < 2; rec_sim++) // reco/sim => I use here exceptionally different var 'rec_sim', not the shadow 'rs' in the template parameter + for (int rec_sim = 0; rec_sim < 2; rec_sim++) // reco/sim => I use here exceptionally different var 'rec_sim', not the shadow 'rs' in the template parameter { - for (Int_t cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter + for (int cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter { if (!ec.fEventCutCounterHist[rec_sim][cc]) { continue; } - for (Int_t bin = 1; bin < ec.fEventCutCounterBinNumber[rec_sim]; bin++) // implemented and used cuts in this analysis - { - ec.fEventCutCounterHist[rec_sim][cc]->GetXaxis()->SetBinLabel(bin, FancyFormatting(ec.fEventCutName[ec.fEventCutCounterMap[rec_sim]->GetValue(bin)].Data())); - } - for (Int_t bin = ec.fEventCutCounterBinNumber[rec_sim]; bin <= eEventCuts_N; bin++) // implemented, but unused cuts in this analysis - { - ec.fEventCutCounterHist[rec_sim][cc]->GetXaxis()->SetBinLabel(bin, Form("binNo = %d (unused cut)", bin)); - // Remark: I have to write here something concrete as a bin label, if I leave "TBI" for all bin labels here for cuts which were not used, - // I get this harmless but annoying warning during merging: - // Warning in : Histogram fEventCutCounterHist[rec][seq] has duplicate labels in the x axis. Bin contents will be merged in a single bin - // TBI 20241130 as a better solution, I shall re-define this histogram with the narower range on x-axis... - } + + if (tc.fUseSetBinLabel) { + for (int bin = 1; bin < ec.fEventCutCounterBinNumber[rec_sim]; bin++) // implemented and used cuts in this analysis + { + ec.fEventCutCounterHist[rec_sim][cc]->GetXaxis()->SetBinLabel(bin, FancyFormatting(ec.fEventCutName[ec.fEventCutCounterMap[rec_sim]->GetValue(bin)].Data())); + } + for (int bin = ec.fEventCutCounterBinNumber[rec_sim]; bin <= eEventCuts_N; bin++) // implemented, but unused cuts in this analysis + { + ec.fEventCutCounterHist[rec_sim][cc]->GetXaxis()->SetBinLabel(bin, TString::Format("binNo = %d (unused cut)", bin)); + // Remark: I have to write here something concrete as a bin label, if I leave "TBI" for all bin labels here for cuts which were not used, + // I get this harmless but annoying warning during merging: + // Warning in : Histogram fEventCutCounterHist[rec][seq] has duplicate labels in the x axis. Bin contents will be merged in a single bin + // TBI 20241130 as a better solution, I shall re-define this histogram with the narower range on x-axis... + } + } else { + + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + for (int bin = 1; bin < ec.fEventCutCounterBinNumber[rec_sim]; bin++) // implemented and used cuts in this analysis + { + yAxisTitle += TString::Format("%d:%s; ", bin, FancyFormatting(ec.fEventCutName[ec.fEventCutCounterMap[rec_sim]->GetValue(bin)].Data())); + } + for (int bin = ec.fEventCutCounterBinNumber[rec_sim]; bin <= eEventCuts_N; bin++) // implemented, but unused cuts in this analysis + { + yAxisTitle += TString::Format("%d:%s; ", bin, TString::Format("binNo = %d (unused cut)", bin).Data()); + } + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != ec.fEventCutCounterHist[rec_sim][cc]->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() = %d != ec.fEventCutCounterHist[rec_sim][cc]->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), ec.fEventCutCounterHist[rec_sim][cc]->GetNbinsX()); + } + delete oa; + + // *) Okay, set the title: + ec.fEventCutCounterHist[rec_sim][cc]->GetYaxis()->SetTitle(yAxisTitle.Data()); + + } // else + // All cuts which were implemeted, but not used I simply do not show (i can always UnZoom x-axis in TBrowser, if I want to see 'em): ec.fEventCutCounterHist[rec_sim][cc]->GetXaxis()->SetRangeUser(ec.fEventCutCounterHist[rec_sim][cc]->GetBinLowEdge(1), ec.fEventCutCounterHist[rec_sim][cc]->GetBinLowEdge(ec.fEventCutCounterBinNumber[rec_sim])); } } - ec.fEventCutCounterBinLabelingIsDone = kTRUE; // this flag ensures that this specific binning is performed only once, for the first processed event + ec.fEventCutCounterBinLabelingIsDone = true; // this flag ensures that this specific binning is performed only once, for the first processed event // delete ec.fEventCutCounterMap[eRec]; // TBI 20240508 if i do not need them later, I could delete here // delete ec.fEventCutCounterMap[eSim]; // delete ec.fEventCutCounterMapInverse[eRec]; @@ -5209,11 +8615,11 @@ void EventCutsCounters(T1 const& collision, T2 const& tracks) //============================================================ template -Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) +bool EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) { // Event cuts on reconstructed and simulated data. Supports event cut counters, both absolute and sequential. // There is also a related enum eEventCuts. - // Remark: I have added to all if statemets below which deals with floats, e.g. TMath::Abs(ebye.fCentrality - ec.fdEventCuts[eCentrality][eMax]) < tc.fFloatingPointPrecision , + // Remark: I have added to all if statemets below which deals with floats, e.g. std::abs(ebye.fCentrality - ec.fdEventCuts[eCentrality][eMax]) < tc.fFloatingPointPrecision , // to enforce the ROOT convention: "lower boundary included, upper boundary excluded" // a) Event cuts on reconstructed, and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1); @@ -5222,14 +8628,16 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) // d) Event cuts on simulated (Run 3 specific); // e) Event cuts on reconstructed, and corresponding MC truth simulated (Run 1 and 2 specific); // In case there is some corner case between Run 1 and Run 2, simply branch further this one // f) Event cuts on simulated (Run 1 and 2 specific); // In case there is some corner case between Run 1 and Run 2, simply branch further this one - // *) Event cuts on Test case. + // *) Event cuts for Test case. + + // 44:EventCuts if (tc.fVerbose) { StartFunction(__FUNCTION__); } // a) Event cuts on reconstructed, and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1) ... - if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { + if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1 || rs == eQA) { // *) NumberOfEvents: => this event cut is implemented directly in Steer(...) @@ -5247,11 +8655,11 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) EventCut(eRec, eTrigger, eCutCounterBinning); } else if (ec.fsEventCuts[eTrigger].EqualTo("kINT7") && !collision.alias_bit(kINT7)) { // Validated only for Run 2 if (!EventCut(eRec, eTrigger, cutModus)) { - return kFALSE; + return false; } } else if (ec.fsEventCuts[eTrigger].EqualTo("kTVXinTRD") && !collision.alias_bit(kTVXinTRD)) { // Validated only for Run 3 if (!EventCut(eRec, eTrigger, cutModus)) { - return kFALSE; + return false; } } // ... @@ -5265,7 +8673,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) EventCut(eRec, eSel8, eCutCounterBinning); } else if (!collision.sel8()) { if (!EventCut(eRec, eSel8, cutModus)) { - return kFALSE; + return false; } } } @@ -5274,9 +8682,9 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eTotalMultiplicity]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eTotalMultiplicity, eCutCounterBinning); - } else if (tracks.size() < ec.fdEventCuts[eTotalMultiplicity][eMin] || tracks.size() > ec.fdEventCuts[eTotalMultiplicity][eMax] || TMath::Abs(tracks.size() - ec.fdEventCuts[eTotalMultiplicity][eMax]) < tc.fFloatingPointPrecision) { + } else if (tracks.size() < ec.fdEventCuts[eTotalMultiplicity][eMin] || tracks.size() > ec.fdEventCuts[eTotalMultiplicity][eMax] || std::abs(tracks.size() - ec.fdEventCuts[eTotalMultiplicity][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eTotalMultiplicity, cutModus)) { - return kFALSE; + return false; } } } @@ -5290,9 +8698,9 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eReferenceMultiplicity]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eReferenceMultiplicity, eCutCounterBinning); - } else if (ebye.fReferenceMultiplicity < ec.fdEventCuts[eReferenceMultiplicity][eMin] || ebye.fReferenceMultiplicity > ec.fdEventCuts[eReferenceMultiplicity][eMax] || TMath::Abs(ebye.fReferenceMultiplicity - ec.fdEventCuts[eReferenceMultiplicity][eMax]) < tc.fFloatingPointPrecision) { + } else if (ebye.fReferenceMultiplicity < ec.fdEventCuts[eReferenceMultiplicity][eMin] || ebye.fReferenceMultiplicity > ec.fdEventCuts[eReferenceMultiplicity][eMax] || std::abs(ebye.fReferenceMultiplicity - ec.fdEventCuts[eReferenceMultiplicity][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eReferenceMultiplicity, cutModus)) { - return kFALSE; + return false; } } } @@ -5302,42 +8710,42 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eCentrality]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eCentrality, eCutCounterBinning); - } else if (ebye.fCentrality < ec.fdEventCuts[eCentrality][eMin] || ebye.fCentrality > ec.fdEventCuts[eCentrality][eMax] || TMath::Abs(ebye.fCentrality - ec.fdEventCuts[eCentrality][eMax]) < tc.fFloatingPointPrecision) { + } else if (ebye.fCentrality < ec.fdEventCuts[eCentrality][eMin] || ebye.fCentrality > ec.fdEventCuts[eCentrality][eMax] || std::abs(ebye.fCentrality - ec.fdEventCuts[eCentrality][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eCentrality, cutModus)) { - return kFALSE; + return false; } } } - // *) Vertex_x: - if (ec.fUseEventCuts[eVertex_x]) { + // *) VertexX: + if (ec.fUseEventCuts[eVertexX]) { if (cutModus == eCutCounterBinning) { - EventCut(eRec, eVertex_x, eCutCounterBinning); - } else if (collision.posX() < ec.fdEventCuts[eVertex_x][eMin] || collision.posX() > ec.fdEventCuts[eVertex_x][eMax] || TMath::Abs(collision.posX() - ec.fdEventCuts[eVertex_x][eMax]) < tc.fFloatingPointPrecision) { - if (!EventCut(eRec, eVertex_x, cutModus)) { - return kFALSE; + EventCut(eRec, eVertexX, eCutCounterBinning); + } else if (collision.posX() < ec.fdEventCuts[eVertexX][eMin] || collision.posX() > ec.fdEventCuts[eVertexX][eMax] || std::abs(collision.posX() - ec.fdEventCuts[eVertexX][eMax]) < tc.fFloatingPointPrecision) { + if (!EventCut(eRec, eVertexX, cutModus)) { + return false; } } } - // *) Vertex_y: - if (ec.fUseEventCuts[eVertex_y]) { + // *) VertexY: + if (ec.fUseEventCuts[eVertexY]) { if (cutModus == eCutCounterBinning) { - EventCut(eRec, eVertex_y, eCutCounterBinning); - } else if (collision.posY() < ec.fdEventCuts[eVertex_y][eMin] || collision.posY() > ec.fdEventCuts[eVertex_y][eMax] || TMath::Abs(collision.posY() - ec.fdEventCuts[eVertex_y][eMax]) < tc.fFloatingPointPrecision) { - if (!EventCut(eRec, eVertex_y, cutModus)) { - return kFALSE; + EventCut(eRec, eVertexY, eCutCounterBinning); + } else if (collision.posY() < ec.fdEventCuts[eVertexY][eMin] || collision.posY() > ec.fdEventCuts[eVertexY][eMax] || std::abs(collision.posY() - ec.fdEventCuts[eVertexY][eMax]) < tc.fFloatingPointPrecision) { + if (!EventCut(eRec, eVertexY, cutModus)) { + return false; } } } - // *) Vertex_z: - if (ec.fUseEventCuts[eVertex_z]) { + // *) VertexZ: + if (ec.fUseEventCuts[eVertexZ]) { if (cutModus == eCutCounterBinning) { - EventCut(eRec, eVertex_z, eCutCounterBinning); - } else if (collision.posZ() < ec.fdEventCuts[eVertex_z][eMin] || collision.posZ() > ec.fdEventCuts[eVertex_z][eMax] || TMath::Abs(collision.posZ() - ec.fdEventCuts[eVertex_z][eMax]) < tc.fFloatingPointPrecision) { - if (!EventCut(eRec, eVertex_z, cutModus)) { - return kFALSE; + EventCut(eRec, eVertexZ, eCutCounterBinning); + } else if (collision.posZ() < ec.fdEventCuts[eVertexZ][eMin] || collision.posZ() > ec.fdEventCuts[eVertexZ][eMax] || std::abs(collision.posZ() - ec.fdEventCuts[eVertexZ][eMax]) < tc.fFloatingPointPrecision) { + if (!EventCut(eRec, eVertexZ, cutModus)) { + return false; } } } @@ -5346,9 +8754,9 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eMinVertexDistanceFromIP]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eMinVertexDistanceFromIP, eCutCounterBinning); - } else if (sqrt(pow(collision.posX(), 2.) + pow(collision.posY(), 2.) + pow(collision.posZ(), 2.)) < ec.fdEventCuts[eMinVertexDistanceFromIP][eMin]) { + } else if (std::sqrt(std::pow(collision.posX(), 2.) + std::pow(collision.posY(), 2.) + std::pow(collision.posZ(), 2.)) < ec.fdEventCuts[eMinVertexDistanceFromIP][eMin]) { if (!EventCut(eRec, eMinVertexDistanceFromIP, cutModus)) { - return kFALSE; + return false; } } } @@ -5357,9 +8765,42 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eNContributors]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eNContributors, eCutCounterBinning); - } else if (collision.numContrib() < ec.fdEventCuts[eNContributors][eMin] || collision.numContrib() > ec.fdEventCuts[eNContributors][eMax] || TMath::Abs(collision.numContrib() - ec.fdEventCuts[eNContributors][eMax]) < tc.fFloatingPointPrecision) { + } else if (collision.numContrib() < ec.fdEventCuts[eNContributors][eMin] || collision.numContrib() > ec.fdEventCuts[eNContributors][eMax] || std::abs(collision.numContrib() - ec.fdEventCuts[eNContributors][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eNContributors, cutModus)) { - return kFALSE; + return false; + } + } + } + + // *) RefMultVsNContrUp: + if (ec.fUseEventCuts[eRefMultVsNContrUp]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eRefMultVsNContrUp, eCutCounterBinning); + } else if (collision.numContrib() > (tc.fUseFormula ? ec.fEventCutsFormulas[eRefMultVsNContrUp_Formula]->Eval(ebye.fReferenceMultiplicity) : RefMultVsNContr(ebye.fReferenceMultiplicity, eRefMultVsNContrUp_Formula))) { + if (!EventCut(eRec, eRefMultVsNContrUp, cutModus)) { + return false; + } + } + } + + // *) RefMultVsNContrLow: + if (ec.fUseEventCuts[eRefMultVsNContrLow]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eRefMultVsNContrLow, eCutCounterBinning); + } else if (collision.numContrib() < (tc.fUseFormula ? ec.fEventCutsFormulas[eRefMultVsNContrLow_Formula]->Eval(ebye.fReferenceMultiplicity) : RefMultVsNContr(ebye.fReferenceMultiplicity, eRefMultVsNContrLow_Formula))) { + if (!EventCut(eRec, eRefMultVsNContrLow, cutModus)) { + return false; + } + } + } + + // *) CentralityCorrelationsCut: + if (ec.fUseEventCuts[eCentralityCorrelationsCut]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eCentralityCorrelationsCut, eCutCounterBinning); + } else if (!CentralityCorrelationCut()) { + if (!EventCut(eRec, eCentralityCorrelationsCut, cutModus)) { + return false; } } } @@ -5371,8 +8812,8 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) // See https://aliceo2group.github.io/analysis-framework/docs/datamodel/ao2dTables.html#montecarlo if constexpr (rs == eRecAndSim || rs == eRecAndSim_Run2 || rs == eRecAndSim_Run1) { if (!collision.has_mcCollision()) { - LOGF(warning, "No MC collision for this collision, skip..."); // TBI 20231106 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this collision - return kFALSE; + LOGF(warning, "\033[1;31m%s at line %d : No MC collision for this collision, skip... \033[0m", __FUNCTION__, __LINE__); // TBI 20231106 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this collision + return false; } // In this branch I can cut additionally and directly on corresponding MC truth simulated, e.g. on collision.mcCollision().posZ(). @@ -5397,9 +8838,9 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eImpactParameter]) { if (cutModus == eCutCounterBinning) { EventCut(eSim, eImpactParameter, eCutCounterBinning); - } else if (collision.impactParameter() < ec.fdEventCuts[eImpactParameter][eMin] || collision.impactParameter() > ec.fdEventCuts[eImpactParameter][eMax] || TMath::Abs(collision.impactParameter() - ec.fdEventCuts[eImpactParameter][eMax]) < tc.fFloatingPointPrecision) { + } else if (collision.impactParameter() < ec.fdEventCuts[eImpactParameter][eMin] || collision.impactParameter() > ec.fdEventCuts[eImpactParameter][eMax] || std::abs(collision.impactParameter() - ec.fdEventCuts[eImpactParameter][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eSim, eImpactParameter, cutModus)) { - return kFALSE; + return false; } } } @@ -5408,9 +8849,9 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eEventPlaneAngle]) { if (cutModus == eCutCounterBinning) { EventCut(eSim, eEventPlaneAngle, eCutCounterBinning); - } else if (collision.eventPlaneAngle() < ec.fdEventCuts[eEventPlaneAngle][eMin] || collision.eventPlaneAngle() > ec.fdEventCuts[eEventPlaneAngle][eMax] || TMath::Abs(collision.eventPlaneAngle() - ec.fdEventCuts[eEventPlaneAngle][eMax]) < tc.fFloatingPointPrecision) { + } else if (collision.eventPlaneAngle() < ec.fdEventCuts[eEventPlaneAngle][eMin] || collision.eventPlaneAngle() > ec.fdEventCuts[eEventPlaneAngle][eMax] || std::abs(collision.eventPlaneAngle() - ec.fdEventCuts[eEventPlaneAngle][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eSim, eEventPlaneAngle, cutModus)) { - return kFALSE; + return false; } } } @@ -5421,37 +8862,46 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) // *) Multiplicity: // Remark: This cut is implemented directly in Steer(...) TBI 20240508 check how to implement this one with the current re-write - // *) Centrality: this is related to eImpactParameter. TBI 20240509 How do I proceed here? Shall i calculate it in void DetermineCentrality( ... ), from IP, and store it in ebye.fCentrality? + // *) Centrality: this centrality is calculated directly from impact parameter, i.e. this is centrality at simulated level, see DetermineCentrality(...) what I do for thre "eSim*" cases. + if (ec.fUseEventCuts[eCentrality]) { + if (cutModus == eCutCounterBinning) { + EventCut(eSim, eCentrality, eCutCounterBinning); + } else if (ebye.fCentrality < ec.fdEventCuts[eCentrality][eMin] || ebye.fCentrality > ec.fdEventCuts[eCentrality][eMax] || std::abs(ebye.fCentrality - ec.fdEventCuts[eCentrality][eMax]) < tc.fFloatingPointPrecision) { + if (!EventCut(eSim, eCentrality, cutModus)) { + return false; + } + } + } - // *) Vertex_x: - if (ec.fUseEventCuts[eVertex_x]) { + // *) VertexX: + if (ec.fUseEventCuts[eVertexX]) { if (cutModus == eCutCounterBinning) { - EventCut(eSim, eVertex_x, eCutCounterBinning); - } else if (collision.posX() < ec.fdEventCuts[eVertex_x][eMin] || collision.posX() > ec.fdEventCuts[eVertex_x][eMax] || TMath::Abs(collision.posX() - ec.fdEventCuts[eVertex_x][eMax]) < tc.fFloatingPointPrecision) { - if (!EventCut(eSim, eVertex_x, cutModus)) { - return kFALSE; + EventCut(eSim, eVertexX, eCutCounterBinning); + } else if (collision.posX() < ec.fdEventCuts[eVertexX][eMin] || collision.posX() > ec.fdEventCuts[eVertexX][eMax] || std::abs(collision.posX() - ec.fdEventCuts[eVertexX][eMax]) < tc.fFloatingPointPrecision) { + if (!EventCut(eSim, eVertexX, cutModus)) { + return false; } } } - // *) Vertex_y: - if (ec.fUseEventCuts[eVertex_y]) { + // *) VertexY: + if (ec.fUseEventCuts[eVertexY]) { if (cutModus == eCutCounterBinning) { - EventCut(eSim, eVertex_y, eCutCounterBinning); - } else if (collision.posY() < ec.fdEventCuts[eVertex_y][eMin] || collision.posY() > ec.fdEventCuts[eVertex_y][eMax] || TMath::Abs(collision.posY() - ec.fdEventCuts[eVertex_y][eMax]) < tc.fFloatingPointPrecision) { - if (!EventCut(eSim, eVertex_y, cutModus)) { - return kFALSE; + EventCut(eSim, eVertexY, eCutCounterBinning); + } else if (collision.posY() < ec.fdEventCuts[eVertexY][eMin] || collision.posY() > ec.fdEventCuts[eVertexY][eMax] || std::abs(collision.posY() - ec.fdEventCuts[eVertexY][eMax]) < tc.fFloatingPointPrecision) { + if (!EventCut(eSim, eVertexY, cutModus)) { + return false; } } } - // *) Vertex_z: - if (ec.fUseEventCuts[eVertex_z]) { + // *) VertexZ: + if (ec.fUseEventCuts[eVertexZ]) { if (cutModus == eCutCounterBinning) { - EventCut(eSim, eVertex_z, eCutCounterBinning); - } else if (collision.posZ() < ec.fdEventCuts[eVertex_z][eMin] || collision.posZ() > ec.fdEventCuts[eVertex_z][eMax] || TMath::Abs(collision.posZ() - ec.fdEventCuts[eVertex_z][eMax]) < tc.fFloatingPointPrecision) { - if (!EventCut(eSim, eVertex_z, cutModus)) { - return kFALSE; + EventCut(eSim, eVertexZ, eCutCounterBinning); + } else if (collision.posZ() < ec.fdEventCuts[eVertexZ][eMin] || collision.posZ() > ec.fdEventCuts[eVertexZ][eMax] || std::abs(collision.posZ() - ec.fdEventCuts[eVertexZ][eMax]) < tc.fFloatingPointPrecision) { + if (!EventCut(eSim, eVertexZ, cutModus)) { + return false; } } } @@ -5460,9 +8910,9 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eMinVertexDistanceFromIP]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eMinVertexDistanceFromIP, eCutCounterBinning); - } else if (sqrt(pow(collision.posX(), 2.) + pow(collision.posY(), 2.) + pow(collision.posZ(), 2.)) < ec.fdEventCuts[eMinVertexDistanceFromIP][eMin]) { + } else if (std::sqrt(std::pow(collision.posX(), 2.) + std::pow(collision.posY(), 2.) + std::pow(collision.posZ(), 2.)) < ec.fdEventCuts[eMinVertexDistanceFromIP][eMin]) { if (!EventCut(eRec, eMinVertexDistanceFromIP, cutModus)) { - return kFALSE; + return false; } } } @@ -5479,7 +8929,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) // c) Event cuts on reconstructed, and corresponding MC truth simulated (Run 3 specific): // Remark: I implement here only the event cuts which are not already in group a) above, and which make sense only for Run 3 data. - if constexpr (rs == eRec || rs == eRecAndSim) { + if constexpr (rs == eRec || rs == eRecAndSim || rs == eQA) { // For Run 3 multiplicities, I subscribe to o2::aod::Mults // See how it is defined as Joined table at https://aliceo2group.github.io/analysis-framework/docs/datamodel/helperTaskTables.html#o2-analysis-multiplicity-table @@ -5490,9 +8940,9 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eOccupancy]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eOccupancy, eCutCounterBinning); - } else if (ebye.fOccupancy < ec.fdEventCuts[eOccupancy][eMin] || ebye.fOccupancy > ec.fdEventCuts[eOccupancy][eMax] || TMath::Abs(ebye.fOccupancy - ec.fdEventCuts[eOccupancy][eMax]) < tc.fFloatingPointPrecision) { + } else if (ebye.fOccupancy < ec.fdEventCuts[eOccupancy][eMin] || ebye.fOccupancy > ec.fdEventCuts[eOccupancy][eMax] || std::abs(ebye.fOccupancy - ec.fdEventCuts[eOccupancy][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eOccupancy, cutModus)) { - return kFALSE; + return false; } } } @@ -5501,9 +8951,9 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eInteractionRate]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eInteractionRate, eCutCounterBinning); - } else if (ebye.fInteractionRate < ec.fdEventCuts[eInteractionRate][eMin] || ebye.fInteractionRate > ec.fdEventCuts[eInteractionRate][eMax] || TMath::Abs(ebye.fInteractionRate - ec.fdEventCuts[eInteractionRate][eMax]) < tc.fFloatingPointPrecision) { + } else if (ebye.fInteractionRate < ec.fdEventCuts[eInteractionRate][eMin] || ebye.fInteractionRate > ec.fdEventCuts[eInteractionRate][eMax] || std::abs(ebye.fInteractionRate - ec.fdEventCuts[eInteractionRate][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eInteractionRate, cutModus)) { - return kFALSE; + return false; } } } @@ -5512,165 +8962,247 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eCurrentRunDuration]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eCurrentRunDuration, eCutCounterBinning); - } else if (ebye.fCurrentRunDuration < ec.fdEventCuts[eCurrentRunDuration][eMin] || ebye.fCurrentRunDuration > ec.fdEventCuts[eCurrentRunDuration][eMax] || TMath::Abs(ebye.fCurrentRunDuration - ec.fdEventCuts[eCurrentRunDuration][eMax]) < tc.fFloatingPointPrecision) { + } else if (ebye.fCurrentRunDuration < ec.fdEventCuts[eCurrentRunDuration][eMin] || ebye.fCurrentRunDuration > ec.fdEventCuts[eCurrentRunDuration][eMax] || std::abs(ebye.fCurrentRunDuration - ec.fdEventCuts[eCurrentRunDuration][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eCurrentRunDuration, cutModus)) { - return kFALSE; + return false; } } } - // *) NoSameBunchPileup: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) NoSameBunchPileup: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eNoSameBunchPileup]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eNoSameBunchPileup, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { if (!EventCut(eRec, eNoSameBunchPileup, cutModus)) { - return kFALSE; + return false; } } } - // *) IsGoodZvtxFT0vsPV: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) IsGoodZvtxFT0vsPV: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eIsGoodZvtxFT0vsPV]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eIsGoodZvtxFT0vsPV, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { if (!EventCut(eRec, eIsGoodZvtxFT0vsPV, cutModus)) { - return kFALSE; + return false; } } } - // *) IsVertexITSTPC: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) IsVertexITSTPC: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eIsVertexITSTPC]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eIsVertexITSTPC, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { if (!EventCut(eRec, eIsVertexITSTPC, cutModus)) { - return kFALSE; + return false; } } } - // *) IsVertexTOFmatched: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) IsVertexTOFmatched: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eIsVertexTOFmatched]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eIsVertexTOFmatched, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { if (!EventCut(eRec, eIsVertexTOFmatched, cutModus)) { - return kFALSE; + return false; } } } - // *) IsVertexTRDmatched: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) IsVertexTRDmatched: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eIsVertexTRDmatched]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eIsVertexTRDmatched, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { if (!EventCut(eRec, eIsVertexTRDmatched, cutModus)) { - return kFALSE; + return false; } } } - // *) NoCollInTimeRangeStrict: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) NoCollInTimeRangeStrict: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eNoCollInTimeRangeStrict]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eNoCollInTimeRangeStrict, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { if (!EventCut(eRec, eNoCollInTimeRangeStrict, cutModus)) { - return kFALSE; + return false; } } } - // *) NoCollInTimeRangeStandard: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) NoCollInTimeRangeStandard: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eNoCollInTimeRangeStandard]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eNoCollInTimeRangeStandard, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { if (!EventCut(eRec, eNoCollInTimeRangeStandard, cutModus)) { - return kFALSE; + return false; } } } - // *) NoCollInRofStrict: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) NoCollInRofStrict: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eNoCollInRofStrict]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eNoCollInRofStrict, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { if (!EventCut(eRec, eNoCollInRofStrict, cutModus)) { - return kFALSE; + return false; } } } - // *) NoCollInRofStandard: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) NoCollInRofStandard: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eNoCollInRofStandard]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eNoCollInRofStandard, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { if (!EventCut(eRec, eNoCollInRofStandard, cutModus)) { - return kFALSE; + return false; } } } - // *) NoHighMultCollInPrevRof: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) NoHighMultCollInPrevRof: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eNoHighMultCollInPrevRof]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eNoHighMultCollInPrevRof, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { if (!EventCut(eRec, eNoHighMultCollInPrevRof, cutModus)) { - return kFALSE; + return false; } } } - // *) IsGoodITSLayer3: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) IsGoodITSLayer3: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eIsGoodITSLayer3]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eIsGoodITSLayer3, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { if (!EventCut(eRec, eIsGoodITSLayer3, cutModus)) { - return kFALSE; + return false; } } } - // *) IsGoodITSLayer0123: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) IsGoodITSLayer0123: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eIsGoodITSLayer0123]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eIsGoodITSLayer0123, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { if (!EventCut(eRec, eIsGoodITSLayer0123, cutModus)) { - return kFALSE; + return false; } } } - // *) IsGoodITSLayersAll: // see O2Physics/Common/CCDB/EventSelectionParams.cxx + // *) IsGoodITSLayersAll: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) if (ec.fUseEventCuts[eIsGoodITSLayersAll]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eIsGoodITSLayersAll, eCutCounterBinning); } else if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { if (!EventCut(eRec, eIsGoodITSLayersAll, cutModus)) { - return kFALSE; + return false; + } + } + } + + // *) FT0Bad: // see O2Physics/Common/CCDB/RCTSelectionFlags.h + if (ec.fUseEventCuts[eFT0Bad]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eFT0Bad, eCutCounterBinning); + } else if (collision.rct_bit(o2::aod::rctsel::kFT0Bad)) { + if (!EventCut(eRec, eFT0Bad, cutModus)) { + return false; + } + } + } + + // *) ITSBad: // see O2Physics/Common/CCDB/RCTSelectionFlags.h + if (ec.fUseEventCuts[eITSBad]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eITSBad, eCutCounterBinning); + } else if (collision.rct_bit(o2::aod::rctsel::kITSBad)) { + if (!EventCut(eRec, eITSBad, cutModus)) { + return false; + } + } + } + + // *) ITSLimAccMCRepr: // see O2Physics/Common/CCDB/RCTSelectionFlags.h + if (ec.fUseEventCuts[eITSLimAccMCRepr]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eITSLimAccMCRepr, eCutCounterBinning); + } else if (collision.rct_bit(o2::aod::rctsel::kITSLimAccMCRepr)) { + if (!EventCut(eRec, eITSLimAccMCRepr, cutModus)) { + return false; + } + } + } + + // *) TPCBadTracking: // see O2Physics/Common/CCDB/RCTSelectionFlags.h + if (ec.fUseEventCuts[eTPCBadTracking]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eTPCBadTracking, eCutCounterBinning); + } else if (collision.rct_bit(o2::aod::rctsel::kTPCBadTracking)) { + if (!EventCut(eRec, eTPCBadTracking, cutModus)) { + return false; + } + } + } + + // *) TPCLimAccMCRepr: // see O2Physics/Common/CCDB/RCTSelectionFlags.h + if (ec.fUseEventCuts[eTPCLimAccMCRepr]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eTPCLimAccMCRepr, eCutCounterBinning); + } else if (collision.rct_bit(o2::aod::rctsel::kTPCLimAccMCRepr)) { + if (!EventCut(eRec, eTPCLimAccMCRepr, cutModus)) { + return false; + } + } + } + + // *) TPCBadPID: // see O2Physics/Common/CCDB/RCTSelectionFlags.h + if (ec.fUseEventCuts[eTPCBadPID]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eTPCBadPID, eCutCounterBinning); + } else if (collision.rct_bit(o2::aod::rctsel::kTPCBadPID)) { + if (!EventCut(eRec, eTPCBadPID, cutModus)) { + return false; } } } // ... + // *) Centrality weights (flattening): + // Remark 1: Since I am getting centrality weights from centrality distribution AFTER all the events cuts, flattening must be applied here after all other event cuts: + // Remark 2: Whatever I change here, change also in the corresponding branch for Run 2 and Run 1. + // Yes, I have to replicate for this special event cut the same code, since in each case it has to be applied at the very end. + if (ec.fUseEventCuts[eCentralityWeights]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eCentralityWeights, eCutCounterBinning); + } else if (gRandom->Uniform(0, 1) > CentralityWeight(ebye.fCentrality)) { // yes, since centralityWeight is normalized probability (see CentralityWeight(...)) + if (!EventCut(eRec, eCentralityWeights, cutModus)) { + return false; + } + } + } + + // Remark: If I need any further event cut, implement it BEFORE event cut "Centrality weights (flattening)", which must be implemented last. + // ... and corresponding MC truth simulated (Run 3 specific): // See https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/mcHistograms.cxx // See https://aliceo2group.github.io/analysis-framework/docs/datamodel/ao2dTables.html#montecarlo if constexpr (rs == eRecAndSim) { if (!collision.has_mcCollision()) { - LOGF(warning, "No MC collision for this collision, skip..."); // TBI 20231106 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this collision - return kFALSE; + LOGF(warning, "\033[1;31m%s at line %d : No MC collision for this collision, skip... \033[0m", __FUNCTION__, __LINE__); // TBI 20231106 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this collision + return false; } // In this branch I can cut additionally and directly on corresponding MC truth simulated. @@ -5707,31 +9239,69 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) EventCut(eRec, eSel7, eCutCounterBinning); } else if (!collision.sel7()) { if (!EventCut(eRec, eSel7, cutModus)) { - return kFALSE; + return false; + } + } + } + + // *) NoPileupTPC: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) + if (ec.fUseEventCuts[eNoPileupTPC]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eNoPileupTPC, eCutCounterBinning); + } else if (!collision.selection_bit(o2::aod::evsel::kNoPileupTPC)) { + if (!EventCut(eRec, eNoPileupTPC, cutModus)) { + return false; + } + } + } + + // *) NoPileupFromSPD: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) + if (ec.fUseEventCuts[eNoPileupFromSPD]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eNoPileupFromSPD, eCutCounterBinning); + } else if (!collision.selection_bit(o2::aod::evsel::kNoPileupFromSPD)) { + if (!EventCut(eRec, eNoPileupFromSPD, cutModus)) { + return false; } } } - // *) MultTracklets: - if (ec.fUseEventCuts[eMultTracklets]) { + // *) NoSPDOnVsOfPileup: // see O2Physics/Common/CCDB/EventSelectionParams.cxx (and .h for better documentation) + if (ec.fUseEventCuts[eNoSPDOnVsOfPileup]) { if (cutModus == eCutCounterBinning) { - EventCut(eRec, eMultTracklets, eCutCounterBinning); - } else if (collision.multTracklets() < ec.fdEventCuts[eMultTracklets][eMin] || collision.multTracklets() > ec.fdEventCuts[eMultTracklets][eMax] || TMath::Abs(collision.multTracklets() - ec.fdEventCuts[eMultTracklets][eMax]) < tc.fFloatingPointPrecision) { - if (!EventCut(eRec, eMultTracklets, cutModus)) { - return kFALSE; + EventCut(eRec, eNoSPDOnVsOfPileup, eCutCounterBinning); + } else if (!collision.selection_bit(o2::aod::evsel::kNoSPDOnVsOfPileup)) { + if (!EventCut(eRec, eNoSPDOnVsOfPileup, cutModus)) { + return false; } } } // ... + // *) Centrality weights (flattening): + // Remark 1: Since I am getting centrality weights from centrality distribution AFTER all the events cuts, flattening must be applied here after all other event cuts: + // Remark 2: Whatever I change here, change also in the corresponding branch for Run 3. + // Yes, I have to replicate for this special event cut the same code, since in each case it has to be applied at the very end. + if (ec.fUseEventCuts[eCentralityWeights]) { + if (cutModus == eCutCounterBinning) { + EventCut(eRec, eCentralityWeights, eCutCounterBinning); + } else if (gRandom->Uniform(0, 1) > CentralityWeight(ebye.fCentrality)) { // yes, since centralityWeight is normalized probability (see CentralityWeight(...)) + if (!EventCut(eRec, eCentralityWeights, cutModus)) { + return false; + } + } + } + + // Remark: If I need any further event cut, implement it BEFORE event cut "Centrality weights (flattening)", which must be implemented last. + // ... and corresponding MC truth simulated: // See https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/mcHistograms.cxx // See https://aliceo2group.github.io/analysis-framework/docs/datamodel/ao2dTables.html#montecarlo if constexpr (rs == eRecAndSim_Run2 || rs == eRecAndSim_Run1) { if (!collision.has_mcCollision()) { - LOGF(warning, "No MC collision for this collision, skip..."); // TBI 20231106 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this collision - return kFALSE; + LOGF(warning, "\033[1;31m%s at line %d : No MC collision for this collision, skip... \033[0m", __FUNCTION__, __LINE__); // TBI 20231106 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this collision + return false; } // In this branch I can cut additionally and directly on corresponding MC truth simulated. @@ -5767,20 +9337,20 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eTotalMultiplicity]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eTotalMultiplicity, eCutCounterBinning); - } else if (tracks.size() < ec.fdEventCuts[eTotalMultiplicity][eMin] || tracks.size() > ec.fdEventCuts[eTotalMultiplicity][eMax] || TMath::Abs(tracks.size() - ec.fdEventCuts[eTotalMultiplicity][eMax]) < tc.fFloatingPointPrecision) { + } else if (tracks.size() < ec.fdEventCuts[eTotalMultiplicity][eMin] || tracks.size() > ec.fdEventCuts[eTotalMultiplicity][eMax] || std::abs(tracks.size() - ec.fdEventCuts[eTotalMultiplicity][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eTotalMultiplicity, cutModus)) { - return kFALSE; + return false; } } } - // *) Vertex_z: - if (ec.fUseEventCuts[eVertex_z]) { + // *) VertexZ: + if (ec.fUseEventCuts[eVertexZ]) { if (cutModus == eCutCounterBinning) { - EventCut(eSim, eVertex_z, eCutCounterBinning); - } else if (collision.posZ() < ec.fdEventCuts[eVertex_z][eMin] || collision.posZ() > ec.fdEventCuts[eVertex_z][eMax] || TMath::Abs(collision.posZ() - ec.fdEventCuts[eVertex_z][eMax]) < tc.fFloatingPointPrecision) { - if (!EventCut(eSim, eVertex_z, cutModus)) { - return kFALSE; + EventCut(eRec, eVertexZ, eCutCounterBinning); + } else if (collision.posZ() < ec.fdEventCuts[eVertexZ][eMin] || collision.posZ() > ec.fdEventCuts[eVertexZ][eMax] || std::abs(collision.posZ() - ec.fdEventCuts[eVertexZ][eMax]) < tc.fFloatingPointPrecision) { + if (!EventCut(eRec, eVertexZ, cutModus)) { + return false; } } } @@ -5789,9 +9359,9 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eCentrality]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eCentrality, eCutCounterBinning); - } else if (ebye.fCentrality < ec.fdEventCuts[eCentrality][eMin] || ebye.fCentrality > ec.fdEventCuts[eCentrality][eMax] || TMath::Abs(ebye.fCentrality - ec.fdEventCuts[eCentrality][eMax]) < tc.fFloatingPointPrecision) { + } else if (ebye.fCentrality < ec.fdEventCuts[eCentrality][eMin] || ebye.fCentrality > ec.fdEventCuts[eCentrality][eMax] || std::abs(ebye.fCentrality - ec.fdEventCuts[eCentrality][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eCentrality, cutModus)) { - return kFALSE; + return false; } } } @@ -5800,16 +9370,18 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) } // if constexpr (rs == eTest) { - return kTRUE; + return true; -} // template Bool_t EventCuts(T1 const& collision, T2 const& tracks) +} // template bool EventCuts(T1 const& collision, T2 const& tracks) //============================================================ -Bool_t EventCut(Int_t rs, Int_t eventCut, eCutModus cutModus) +bool EventCut(int rs, int eventCut, eCutModus cutModus) { // Helper function to reduce code bloat in EventCuts(). It's meant to be used only in EventCuts(). // It can be used also in exceptional cases outside of EventCuts(), like for eMultiplicity, but use with care. + // For instance, I can call EventCut(eRec, eCentrality, eCutCounterSequential) directly, only if I have checked that + // fUseEventCutCounterSequential is true, etc. // Remark: Remember that as a second argument I cannot use enum eEventCuts, because here in one go I take both enum eEventCuts and enum eEventHistograms . @@ -5823,34 +9395,39 @@ Bool_t EventCut(Int_t rs, Int_t eventCut, eCutModus cutModus) // *) Do the thing: switch (cutModus) { - case eCut: + case eCut: { if (tc.fVerboseEventCut) { LOGF(info, "\033[1;31mEvent didn't survive the cut: %s\033[0m", ec.fEventCutName[eventCut].Data()); } - return kFALSE; + return false; break; - case eCutCounterBinning: + } + case eCutCounterBinning: { ec.fEventCutCounterMap[rs]->Add(ec.fEventCutCounterBinNumber[rs], eventCut); ec.fEventCutCounterMapInverse[rs]->Add(eventCut, ec.fEventCutCounterBinNumber[rs]); ec.fEventCutCounterBinNumber[rs]++; // yes - return kTRUE; + return true; break; - case eCutCounterAbsolute: + } + case eCutCounterAbsolute: { ec.fEventCutCounterHist[rs][eAbsolute]->Fill(ec.fEventCutCounterMapInverse[rs]->GetValue(eventCut)); - return kTRUE; // yes, so that I can proceed with another cut in EventCuts + return true; // yes, so that I can proceed with another cut in EventCuts break; - case eCutCounterSequential: + } + case eCutCounterSequential: { ec.fEventCutCounterHist[rs][eSequential]->Fill(ec.fEventCutCounterMapInverse[rs]->GetValue(eventCut)); - return kFALSE; // yes, so that I bail out from EventCuts + return false; // yes, so that I bail out from EventCuts break; - default: + } + default: { LOGF(fatal, "\033[1;31m%s at line %d : This cutModus = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(cutModus)); break; + } } // switch(cutModus) - return kFALSE; // obsolete, but it suppresses the warning... + return false; // obsolete, but it suppresses the warning... -} // Bool_t EventCut(Int_t rs, Int_t eventCut, eCutModus cutModus) +} // bool EventCut(int rs, int eventCut, eCutModus cutModus) //============================================================ @@ -5881,15 +9458,17 @@ bool RemainingEventCuts() // *) Multiplicity: (see documentation for ebye.fMultiplicity for its definition) if (ec.fUseEventCuts[eMultiplicity]) { - if (ebye.fMultiplicity < ec.fdEventCuts[eMultiplicity][eMin] || ebye.fMultiplicity > ec.fdEventCuts[eMultiplicity][eMax] || TMath::Abs(ebye.fMultiplicity - ec.fdEventCuts[eMultiplicity][eMax]) < tc.fFloatingPointPrecision) { + if (ebye.fMultiplicity < ec.fdEventCuts[eMultiplicity][eMin] || ebye.fMultiplicity > ec.fdEventCuts[eMultiplicity][eMax] || std::abs(ebye.fMultiplicity - ec.fdEventCuts[eMultiplicity][eMax]) < tc.fFloatingPointPrecision) { // Remark: I have to implement RemainingEventCuts() in a slightly different way as EventCuts() - EventCut(rs, eMultiplicity, eCut); // just a printout that this event didn't survive this cut - EventCut(rs, eMultiplicity, eCutCounterSequential); - return kFALSE; + EventCut(rs, eMultiplicity, eCut); // just a printout that this event didn't survive this cut + if (ec.fUseEventCutCounterSequential) { // yes, this is important. Otherwise fEventCutCounterHist can be used in EventCut(...), even though it's NULL + EventCut(rs, eMultiplicity, eCutCounterSequential); + } + return false; } } - return kTRUE; + return true; } // bool RemainingEventCuts() @@ -5911,9 +9490,9 @@ void FillSubeventMultiplicities() } // a) Fill reconstructed (common to Run 3, Run 2 and Run 1 + Test mode): - if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1 || rs == eTest) { - for (Int_t ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1 || rs == eTest || rs == eQA) { + for (int ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation !qv.fMabDist[ab][eRec][eAfter][e] ? true : qv.fMabDist[ab][eRec][eAfter][e]->Fill(qv.fMab[ab][e]); } } @@ -5921,8 +9500,8 @@ void FillSubeventMultiplicities() // b) Fill only simulated (common to Run 3, Run 2 and Run 1): if constexpr (rs == eSim || rs == eSim_Run2 || rs == eSim_Run1) { - for (Int_t ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + for (int ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation !qv.fMabDist[ab][eSim][eAfter][e] ? true : qv.fMabDist[ab][eSim][eAfter][e]->Fill(qv.fMab[ab][e]); } } @@ -5956,12 +9535,12 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) } // a) Fill reconstructed ... (common to Run 3, Run 2 and Run 1): - if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { + if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1 || rs == eQA) { if (eh.fFillEventHistograms) { !eh.fEventHistograms[eNumberOfEvents][eRec][ba] ? true : eh.fEventHistograms[eNumberOfEvents][eRec][ba]->Fill(0.5); // basically, if histogram is not booked, do nothing. 'true' is a placeholder, for the time being - !eh.fEventHistograms[eVertex_x][eRec][ba] ? true : eh.fEventHistograms[eVertex_x][eRec][ba]->Fill(collision.posX()); - !eh.fEventHistograms[eVertex_y][eRec][ba] ? true : eh.fEventHistograms[eVertex_y][eRec][ba]->Fill(collision.posY()); - !eh.fEventHistograms[eVertex_z][eRec][ba] ? true : eh.fEventHistograms[eVertex_z][eRec][ba]->Fill(collision.posZ()); + !eh.fEventHistograms[eVertexX][eRec][ba] ? true : eh.fEventHistograms[eVertexX][eRec][ba]->Fill(collision.posX()); + !eh.fEventHistograms[eVertexY][eRec][ba] ? true : eh.fEventHistograms[eVertexY][eRec][ba]->Fill(collision.posY()); + !eh.fEventHistograms[eVertexZ][eRec][ba] ? true : eh.fEventHistograms[eVertexZ][eRec][ba]->Fill(collision.posZ()); !eh.fEventHistograms[eNContributors][eRec][ba] ? true : eh.fEventHistograms[eNContributors][eRec][ba]->Fill(collision.numContrib()); !eh.fEventHistograms[eTotalMultiplicity][eRec][ba] ? true : eh.fEventHistograms[eTotalMultiplicity][eRec][ba]->Fill(tracks.size()); // TBI 20231106 check and validate further !eh.fEventHistograms[eMultiplicity][eRec][ba] ? true : eh.fEventHistograms[eMultiplicity][eRec][ba]->Fill(ebye.fMultiplicity); @@ -5974,37 +9553,92 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) !qa.fQAEventHistograms2D[eMultiplicity_vs_ReferenceMultiplicity][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultiplicity_vs_ReferenceMultiplicity][eRec][ba]->Fill(ebye.fMultiplicity, ebye.fReferenceMultiplicity); !qa.fQAEventHistograms2D[eMultiplicity_vs_NContributors][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultiplicity_vs_NContributors][eRec][ba]->Fill(ebye.fMultiplicity, collision.numContrib()); !qa.fQAEventHistograms2D[eMultiplicity_vs_Centrality][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultiplicity_vs_Centrality][eRec][ba]->Fill(ebye.fMultiplicity, ebye.fCentrality); - !qa.fQAEventHistograms2D[eMultiplicity_vs_Vertex_z][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultiplicity_vs_Vertex_z][eRec][ba]->Fill(ebye.fMultiplicity, collision.posZ()); + !qa.fQAEventHistograms2D[eMultiplicity_vs_VertexZ][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultiplicity_vs_VertexZ][eRec][ba]->Fill(ebye.fMultiplicity, collision.posZ()); !qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_NContributors][eRec][ba] ? true : qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_NContributors][eRec][ba]->Fill(ebye.fReferenceMultiplicity, collision.numContrib()); !qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_Centrality][eRec][ba] ? true : qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_Centrality][eRec][ba]->Fill(ebye.fReferenceMultiplicity, ebye.fCentrality); - !qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_Vertex_z][eRec][ba] ? true : qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_Vertex_z][eRec][ba]->Fill(ebye.fReferenceMultiplicity, collision.posZ()); + !qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_VertexZ][eRec][ba] ? true : qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_VertexZ][eRec][ba]->Fill(ebye.fReferenceMultiplicity, collision.posZ()); !qa.fQAEventHistograms2D[eNContributors_vs_Centrality][eRec][ba] ? true : qa.fQAEventHistograms2D[eNContributors_vs_Centrality][eRec][ba]->Fill(collision.numContrib(), ebye.fCentrality); - !qa.fQAEventHistograms2D[eNContributors_vs_Vertex_z][eRec][ba] ? true : qa.fQAEventHistograms2D[eNContributors_vs_Vertex_z][eRec][ba]->Fill(collision.numContrib(), collision.posZ()); - !qa.fQAEventHistograms2D[eCentrality_vs_Vertex_z][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentrality_vs_Vertex_z][eRec][ba]->Fill(ebye.fCentrality, collision.posZ()); + !qa.fQAEventHistograms2D[eNContributors_vs_VertexZ][eRec][ba] ? true : qa.fQAEventHistograms2D[eNContributors_vs_VertexZ][eRec][ba]->Fill(collision.numContrib(), collision.posZ()); + !qa.fQAEventHistograms2D[eCentrality_vs_VertexZ][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentrality_vs_VertexZ][eRec][ba]->Fill(ebye.fCentrality, collision.posZ()); } + if (qa.fFillQACorrelationsVsHistograms2D && qa.fQAParticleEventProEbyE[eRec][ba] && ba == eAfter) { // fill only for eAfter, because I do not calculate Q-vectors before cuts + + // Calculate quickly 2-p correlation in harmonic h for this event: TBI 20250114 shall I add this also to some EbyE variable? There is no really much of a code bloat for the time being... + + // Flush 'n' fill the generic Q-vectors: + ResetQ(); + int lMaxCorrelator = 2; // used only here locally + for (int h = 0; h < gMaxHarmonic * lMaxCorrelator + 1; h++) { + for (int wp = 0; wp < lMaxCorrelator + 1; wp++) // weight power + { + qv.fQ[h][wp] = qv.fQvector[h][wp]; + } + } + + for (int h = 1; h <= gMaxHarmonic; h++) { + TComplex two = Two(h, -h); + double twoC = two.Re(); // cos + // double twoS = two.Im(); // sin + double wTwo = Two(0, 0).Re(); // Weight is 'number of combinations' by default TBI + // 20220809 add support for other weights + if (!(wTwo > 0.0)) { + LOGF(fatal, "In function \033[1;31m%s at line %d : wTwo = %f <=0. ebye.fSelectedTracks = %d.\nDid you forget to enable fCalculateQvectors = true?\033[0m", __FUNCTION__, __LINE__, wTwo, ebye.fSelectedTracks); + } + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_Multiplicity][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_Multiplicity][h - 1][eRec]->Fill(twoC / wTwo, ebye.fMultiplicity, wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_ReferenceMultiplicity][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_ReferenceMultiplicity][h - 1][eRec]->Fill(twoC / wTwo, ebye.fReferenceMultiplicity, wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_Centrality][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_Centrality][h - 1][eRec]->Fill(twoC / wTwo, ebye.fCentrality, wTwo); + // ..... + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanPhi][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanPhi][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanPhi), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanPt][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanPt][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanPt), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanEta][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanEta][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanEta), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanCharge][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanCharge][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanCharge), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsFindable][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsFindable][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeantpcNClsFindable), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsShared][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsShared][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeantpcNClsShared), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsChi2NCl][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsChi2NCl][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanitsChi2NCl), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsFound][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsFound][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeantpcNClsFound), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsCrossedRows][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcNClsCrossedRows][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeantpcNClsCrossedRows), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsNCls][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsNCls][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanitsNCls), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsNClsInnerBarrel][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeanitsNClsInnerBarrel][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanitsNClsInnerBarrel), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcCrossedRowsOverFindableCls][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcCrossedRowsOverFindableCls][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeantpcCrossedRowsOverFindableCls), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcFoundOverFindableCls][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcFoundOverFindableCls][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeantpcFoundOverFindableCls), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcFractionSharedCls][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcFractionSharedCls][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeantpcFractionSharedCls), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcChi2NCl][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeantpcChi2NCl][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeantpcChi2NCl), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeandcaXY][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeandcaXY][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeandcaXY), wTwo); + !qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeandcaZ][h - 1][eRec] ? true : qa.fQACorrelationsVsHistograms2D[eCorrelations_vs_MeandcaZ][h - 1][eRec]->Fill(twoC / wTwo, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeandcaZ), wTwo); + // ..... + } + + // Flush the generic Q-vectors: + ResetQ(); + + } // if (qa.fFillQACorrelationsVsHistograms2D && qa.fQAParticleEventProEbyE[eRec][ba] && ba == eAfter) + + // ... + // ... and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1) ( see https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/mcHistograms.cxx ): if constexpr (rs == eRecAndSim || rs == eRecAndSim_Run2 || rs == eRecAndSim_Run1) { if (!collision.has_mcCollision()) { - LOGF(warning, "No MC collision for this collision, skip..."); + LOGF(warning, "\033[1;31m%s at line %d : No MC collision for this collision, skip... \033[0m", __FUNCTION__, __LINE__); return; } if (eh.fFillEventHistograms) { !eh.fEventHistograms[eNumberOfEvents][eSim][ba] ? true : eh.fEventHistograms[eNumberOfEvents][eSim][ba]->Fill(0.5); - !eh.fEventHistograms[eVertex_x][eSim][ba] ? true : eh.fEventHistograms[eVertex_x][eSim][ba]->Fill(collision.mcCollision().posX()); - !eh.fEventHistograms[eVertex_y][eSim][ba] ? true : eh.fEventHistograms[eVertex_y][eSim][ba]->Fill(collision.mcCollision().posY()); - !eh.fEventHistograms[eVertex_z][eSim][ba] ? true : eh.fEventHistograms[eVertex_z][eSim][ba]->Fill(collision.mcCollision().posZ()); + !eh.fEventHistograms[eVertexX][eSim][ba] ? true : eh.fEventHistograms[eVertexX][eSim][ba]->Fill(collision.mcCollision().posX()); + !eh.fEventHistograms[eVertexY][eSim][ba] ? true : eh.fEventHistograms[eVertexY][eSim][ba]->Fill(collision.mcCollision().posY()); + !eh.fEventHistograms[eVertexZ][eSim][ba] ? true : eh.fEventHistograms[eVertexZ][eSim][ba]->Fill(collision.mcCollision().posZ()); !eh.fEventHistograms[eImpactParameter][eSim][ba] ? true : eh.fEventHistograms[eImpactParameter][eSim][ba]->Fill(collision.mcCollision().impactParameter()); !eh.fEventHistograms[eEventPlaneAngle][eSim][ba] ? true : eh.fEventHistograms[eEventPlaneAngle][eSim][ba]->Fill(collision.mcCollision().eventPlaneAngle()); // eh.fEventHistograms[eTotalMultiplicity][eSim][ba]->Fill(tracks.size()); // TBI 20231106 check how to get corresponding MC truth info, and validate further // eh.fEventHistograms[eMultiplicity][eSim][ba]->Fill(ebye.fMultiplicity); // TBI 20241123 re-think if I really need it here. If yes, most likely I will have to // generalize fSelectedTracks to an array, to counter separately selected sim particles - // eh.fEventHistograms[eCentrality][eSim][ba]->Fill(ebye.fCentrality); // TBI 20240120 this case is still not supported in DetermineCentrality() + !eh.fEventHistograms[eCentrality][eSim][ba] ? true : eh.fEventHistograms[eCentrality][eSim][ba]->Fill(ebye.fCentralitySim); } // QA: if (qa.fFillQAEventHistograms2D) { !qa.fQAEventHistograms2D[eCentrality_vs_ImpactParameter][eSim][ba] ? true : qa.fQAEventHistograms2D[eCentrality_vs_ImpactParameter][eSim][ba]->Fill(ebye.fCentrality, collision.mcCollision().impactParameter()); + !qa.fQAEventHistograms2D[eCentrality_vs_CentralitySim][eSim][ba] ? true : qa.fQAEventHistograms2D[eCentrality_vs_CentralitySim][eSim][ba]->Fill(ebye.fCentrality, ebye.fCentralitySim); // ... } } // if constexpr (rs == eRecAndSim) { @@ -6018,15 +9652,15 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) !eh.fEventHistograms[eImpactParameter][eSim][ba] ? true : eh.fEventHistograms[eImpactParameter][eSim][ba]->Fill(collision.impactParameter()); // yes, because in this branch 'collision' is always aod::McCollision !eh.fEventHistograms[eEventPlaneAngle][eSim][ba] ? true : eh.fEventHistograms[eEventPlaneAngle][eSim][ba]->Fill(collision.eventPlaneAngle()); // yes, because in this branch 'collision' is always aod::McCollision !eh.fEventHistograms[eMultiplicity][eSim][ba] ? true : eh.fEventHistograms[eMultiplicity][eSim][ba]->Fill(ebye.fMultiplicity); - // eh.fEventHistograms[eCentrality][eSim][ba]->Fill(ebye.fCentrality); // TBI 20240120 this case is still not supported in DetermineCentrality() + !eh.fEventHistograms[eCentrality][eSim][ba] ? true : eh.fEventHistograms[eCentrality][eSim][ba]->Fill(ebye.fCentrality); // ebye.fCentrality = ebye.fCentralitySim in any case in this branch // eh.fEventHistograms[eReferenceMultiplicity][eSim][ba]->Fill(ebye.fReferenceMultiplicity); // TBI 20241123 this case is still not supported in DetermineReferenceMultiplicity() // eh.fEventHistograms[eTotalMultiplicity][eSim][ba]->Fill(tracks.size()); // TBI 20231030 check further how to use the same thing for 'sim' } // Eta separations: if (es.fCalculateEtaSeparations) { - for (Int_t ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + for (int ab = 0; ab < 2; ab++) { // ab = 0 <=> -eta , ab = 1 <=> + eta + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation !qv.fMabDist[ab][eSim][ba][e] ? true : qv.fMabDist[ab][eSim][ba][e]->Fill(qv.fMab[ab][e]); } } @@ -6036,25 +9670,43 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) // ----------------------------------------------------------------------------- // c) Fill reconstructed (Run 3 specific): - if constexpr (rs == eRec || rs == eRecAndSim) { + if constexpr (rs == eRec || rs == eRecAndSim || rs == eQA) { if (eh.fFillEventHistograms) { !eh.fEventHistograms[eOccupancy][eRec][ba] ? true : eh.fEventHistograms[eOccupancy][eRec][ba]->Fill(ebye.fOccupancy); !eh.fEventHistograms[eInteractionRate][eRec][ba] ? true : eh.fEventHistograms[eInteractionRate][eRec][ba]->Fill(ebye.fInteractionRate); - !eh.fEventHistograms[eCurrentRunDuration][eRec][ba] ? true : eh.fEventHistograms[eCurrentRunDuration][eRec][ba]->Fill(ebye.fCurrentRunDuration); // TBI 20241128 check if this one can be used for Run 2 and Run 1 converted, most likely not + !eh.fEventHistograms[eCurrentRunDuration][eRec][ba] ? true : eh.fEventHistograms[eCurrentRunDuration][eRec][ba]->Fill(ebye.fCurrentRunDuration); } // QA: if (qa.fFillQAEventHistograms2D) { // General (estimators can be chosen via configurables): + + // **) vs occupancy: !qa.fQAEventHistograms2D[eMultiplicity_vs_Occupancy][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultiplicity_vs_Occupancy][eRec][ba]->Fill(ebye.fMultiplicity, ebye.fOccupancy); !qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_Occupancy][eRec][ba] ? true : qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_Occupancy][eRec][ba]->Fill(ebye.fReferenceMultiplicity, ebye.fOccupancy); !qa.fQAEventHistograms2D[eNContributors_vs_Occupancy][eRec][ba] ? true : qa.fQAEventHistograms2D[eNContributors_vs_Occupancy][eRec][ba]->Fill(collision.numContrib(), ebye.fOccupancy); !qa.fQAEventHistograms2D[eCentrality_vs_Occupancy][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentrality_vs_Occupancy][eRec][ba]->Fill(ebye.fCentrality, ebye.fOccupancy); - !qa.fQAEventHistograms2D[eVertex_z_vs_Occupancy][eRec][ba] ? true : qa.fQAEventHistograms2D[eVertex_z_vs_Occupancy][eRec][ba]->Fill(collision.posZ(), ebye.fOccupancy); + !qa.fQAEventHistograms2D[eVertexZ_vs_Occupancy][eRec][ba] ? true : qa.fQAEventHistograms2D[eVertexZ_vs_Occupancy][eRec][ba]->Fill(collision.posZ(), ebye.fOccupancy); + + // **) vs interaction rate: + !qa.fQAEventHistograms2D[eMultiplicity_vs_InteractionRate][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultiplicity_vs_InteractionRate][eRec][ba]->Fill(ebye.fMultiplicity, ebye.fInteractionRate); + !qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_InteractionRate][eRec][ba] ? true : qa.fQAEventHistograms2D[eReferenceMultiplicity_vs_InteractionRate][eRec][ba]->Fill(ebye.fReferenceMultiplicity, ebye.fInteractionRate); + !qa.fQAEventHistograms2D[eNContributors_vs_InteractionRate][eRec][ba] ? true : qa.fQAEventHistograms2D[eNContributors_vs_InteractionRate][eRec][ba]->Fill(collision.numContrib(), ebye.fInteractionRate); + !qa.fQAEventHistograms2D[eCentrality_vs_InteractionRate][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentrality_vs_InteractionRate][eRec][ba]->Fill(ebye.fCentrality, ebye.fInteractionRate); + !qa.fQAEventHistograms2D[eVertexZ_vs_InteractionRate][eRec][ba] ? true : qa.fQAEventHistograms2D[eVertexZ_vs_InteractionRate][eRec][ba]->Fill(collision.posZ(), ebye.fInteractionRate); + + // **) unsorted TBI 20250331 sort at some point + !qa.fQAEventHistograms2D[eMultiplicity_vs_FT0CAmplitudeOnFoundBC][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultiplicity_vs_FT0CAmplitudeOnFoundBC][eRec][ba]->Fill(ebye.fMultiplicity, ebye.fFT0CAmplitudeOnFoundBC); + !qa.fQAEventHistograms2D[eCentFT0C_vs_FT0CAmplitudeOnFoundBC][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentFT0C_vs_FT0CAmplitudeOnFoundBC][eRec][ba]->Fill(qa.fCentrality[eCentFT0C], ebye.fFT0CAmplitudeOnFoundBC); + // ... // Specific (estimators are hardwired): !qa.fQAEventHistograms2D[eMultNTracksPV_vs_MultNTracksGlobal][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultNTracksPV_vs_MultNTracksGlobal][eRec][ba]->Fill(qa.fReferenceMultiplicity[eMultNTracksPV], qa.fReferenceMultiplicity[eMultNTracksGlobal]); // TBI 20241209 check if I can use this one for Run 2 and 1 + !qa.fQAEventHistograms2D[eCentFT0C_vs_CentFT0CVariant1][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentFT0C_vs_CentFT0CVariant1][eRec][ba]->Fill(qa.fCentrality[eCentFT0C], qa.fCentrality[eCentFT0CVariant1]); + !qa.fQAEventHistograms2D[eCentFT0C_vs_CentFT0M][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentFT0C_vs_CentFT0M][eRec][ba]->Fill(qa.fCentrality[eCentFT0C], qa.fCentrality[eCentFT0M]); + !qa.fQAEventHistograms2D[eCentFT0C_vs_CentFV0A][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentFT0C_vs_CentFV0A][eRec][ba]->Fill(qa.fCentrality[eCentFT0C], qa.fCentrality[eCentFV0A]); !qa.fQAEventHistograms2D[eCentFT0C_vs_CentNTPV][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentFT0C_vs_CentNTPV][eRec][ba]->Fill(qa.fCentrality[eCentFT0C], qa.fCentrality[eCentNTPV]); + !qa.fQAEventHistograms2D[eCentFT0C_vs_CentNGlobal][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentFT0C_vs_CentNGlobal][eRec][ba]->Fill(qa.fCentrality[eCentFT0C], qa.fCentrality[eCentNGlobal]); !qa.fQAEventHistograms2D[eCentFT0M_vs_CentNTPV][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentFT0M_vs_CentNTPV][eRec][ba]->Fill(qa.fCentrality[eCentFT0M], qa.fCentrality[eCentNTPV]); !qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange][eRec][ba] ? true : qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange][eRec][ba]->Fill(collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); !qa.fQAEventHistograms2D[eCurrentRunDuration_vs_InteractionRate][eRec][ba] ? true : qa.fQAEventHistograms2D[eCurrentRunDuration_vs_InteractionRate][eRec][ba]->Fill(ebye.fCurrentRunDuration, ebye.fInteractionRate); @@ -6073,16 +9725,58 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) !qa.fQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt0005EbyE][eRec][ba] ? true : qa.fQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt0005EbyE][eRec][ba]->Fill(ebye.fCurrentRunDuration, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(ePt0005EbyE), qa.fQAParticleEventProEbyE[eRec][ba]->GetBinEntries(ePt0005EbyE)); !qa.fQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt0510EbyE][eRec][ba] ? true : qa.fQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt0510EbyE][eRec][ba]->Fill(ebye.fCurrentRunDuration, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(ePt0510EbyE), qa.fQAParticleEventProEbyE[eRec][ba]->GetBinEntries(ePt0510EbyE)); !qa.fQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt1050EbyE][eRec][ba] ? true : qa.fQAParticleEventHistograms2D[eCurrentRunDuration_vs_Pt1050EbyE][eRec][ba]->Fill(ebye.fCurrentRunDuration, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(ePt1050EbyE), qa.fQAParticleEventProEbyE[eRec][ba]->GetBinEntries(ePt1050EbyE)); + } // if (qa.fFillQAParticleEventHistograms2D && qa.fQAParticleEventProEbyE[eRec][ba]) { - // ... + if (qa.fFillQACorrelationsVsInteractionRateVsProfiles2D && qa.fQAParticleEventProEbyE[eRec][ba] && ba == eAfter) { // fill only for eAfter, because I do not calculate Q-vectors before cuts - } // if (qa.fFillQAParticleEventHistograms2D && qa.fQAParticleEventProEbyE[eRec][ba]) { + // Calculate quickly 2-p correlation in harmonic h for this event: TBI 20250114 shall I add this also to some EbyE variable? There is no really much of a code bloat for the time being... + + // Flush 'n' fill the generic Q-vectors: + ResetQ(); + int lMaxCorrelator = 2; // used only here locally + for (int h = 0; h < gMaxHarmonic * lMaxCorrelator + 1; h++) { + for (int wp = 0; wp < lMaxCorrelator + 1; wp++) // weight power + { + qv.fQ[h][wp] = qv.fQvector[h][wp]; + } + } + + for (int h = 1; h <= gMaxHarmonic; h++) { + TComplex two = Two(h, -h); + double twoC = two.Re(); // cos + // double twoS = two.Im(); // sin + double wTwo = Two(0, 0).Re(); // Weight is 'number of combinations' by default TBI + // 20220809 add support for other weights + if (!(wTwo > 0.0)) { + LOGF(fatal, "In function \033[1;31m%s at line %d : wTwo = %f <=0. ebye.fSelectedTracks = %d.\nDid you forget to enable fCalculateQvectors = true?\033[0m", __FUNCTION__, __LINE__, wTwo, ebye.fSelectedTracks); + } + + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_CurrentRunDuration][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_CurrentRunDuration][h - 1][eRec]->Fill(ebye.fInteractionRate, ebye.fCurrentRunDuration, twoC / wTwo, wTwo); + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_Multiplicity][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_Multiplicity][h - 1][eRec]->Fill(ebye.fInteractionRate, ebye.fMultiplicity, twoC / wTwo, wTwo); + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_ReferenceMultiplicity][h - 1][eRec]->Fill(ebye.fInteractionRate, ebye.fReferenceMultiplicity, twoC / wTwo, wTwo); + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_Centrality][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_Centrality][h - 1][eRec]->Fill(ebye.fInteractionRate, ebye.fCentrality, twoC / wTwo, wTwo); + // ..... + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanPhi][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanPhi][h - 1][eRec]->Fill(ebye.fInteractionRate, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanPhi), twoC / wTwo, wTwo); + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPhi][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPhi][h - 1][eRec]->Fill(ebye.fInteractionRate, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinError(eMeanPhi), twoC / wTwo, wTwo); + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanPt][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanPt][h - 1][eRec]->Fill(ebye.fInteractionRate, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanPt), twoC / wTwo, wTwo); + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPt][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanPt][h - 1][eRec]->Fill(ebye.fInteractionRate, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinError(eMeanPt), twoC / wTwo, wTwo); + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanEta][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_MeanEta][h - 1][eRec]->Fill(ebye.fInteractionRate, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinContent(eMeanEta), twoC / wTwo, wTwo); + !qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanEta][h - 1][eRec] ? true : qa.fQACorrVsIRVsProfiles2D[eCorrelationsVsInteractionRate_vs_SigmaMeanEta][h - 1][eRec]->Fill(ebye.fInteractionRate, qa.fQAParticleEventProEbyE[eRec][ba]->GetBinError(eMeanEta), twoC / wTwo, wTwo); + // ..... + } + + // Flush the generic Q-vectors: + ResetQ(); + + } // if (qa.fFillQACorrelationsVsInteractionRateVsProfiles2D && qa.fQAParticleEventProEbyE[eRec][ba] && ba == eAfter) { + + // ... // ... and corresponding MC truth simulated (Run 3 specific) // See https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/mcHistograms.cxx if constexpr (rs == eRecAndSim) { if (!collision.has_mcCollision()) { - LOGF(warning, "No MC collision for this collision, skip..."); + LOGF(warning, "\033[1;31m%s at line %d : No MC collision for this collision, skip... \033[0m", __FUNCTION__, __LINE__); return; } @@ -6105,7 +9799,7 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) // e) Fill reconstructed (Run 1 and 2 specific): // In case there is some corner case between Run 1 and Run 2, simply branch further this one if constexpr (rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { if (eh.fFillEventHistograms) { - !eh.fEventHistograms[eMultTracklets][eRec][ba] ? true : eh.fEventHistograms[eMultTracklets][eRec][ba]->Fill(collision.multTracklets()); + // ... } // QA: if (qa.fFillQAEventHistograms2D) { @@ -6116,7 +9810,7 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) // See https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/mcHistograms.cxx if constexpr (rs == eRecAndSim_Run2 || rs == eRecAndSim_Run1) { if (!collision.has_mcCollision()) { - LOGF(warning, "No MC collision for this collision, skip..."); + LOGF(warning, "\033[1;31m%s at line %d : No MC collision for this collision, skip... \033[0m", __FUNCTION__, __LINE__); return; } // !eh.fEventHistograms[eNumberOfEvents][eSim][ba] ? true : eh.fEventHistograms[eNumberOfEvents][eSim][ba]->Fill(0.5); @@ -6139,7 +9833,8 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) // TBI 20240223 for the time being, eTest fills only eRec histos: // A few example histograms, just to check if I access corresponding tables: if (eh.fFillEventHistograms) { - !eh.fEventHistograms[eVertex_z][eRec][ba] ? true : eh.fEventHistograms[eVertex_z][eRec][ba]->Fill(collision.posZ()); + !eh.fEventHistograms[eNumberOfEvents][eRec][ba] ? true : eh.fEventHistograms[eNumberOfEvents][eRec][ba]->Fill(0.5); + !eh.fEventHistograms[eVertexZ][eRec][ba] ? true : eh.fEventHistograms[eVertexZ][eRec][ba]->Fill(collision.posZ()); !eh.fEventHistograms[eTotalMultiplicity][eRec][ba] ? true : eh.fEventHistograms[eTotalMultiplicity][eRec][ba]->Fill(tracks.size()); !eh.fEventHistograms[eCentrality][eRec][ba] ? true : eh.fEventHistograms[eCentrality][eRec][ba]->Fill(ebye.fCentrality); } @@ -6157,6 +9852,10 @@ void CheckUnderflowAndOverflow() { // Check and bail out if in event and particle histograms there are entries which went to underflow or overflow bins. + // TBI 20250527 I have reinvented the wheel here, there are already member functions TH1::IsBinUnderflow() and TH1::IsBinOverflow(), + // which I have use also for 2D and 3D cases with "global bin". + // Reimplemented this function using those member functions eventually. + // a) Event histograms 1D; // b) Event histograms 2D; // c) Particle histograms 1D; @@ -6170,11 +9869,11 @@ void CheckUnderflowAndOverflow() } // a) Event histograms 1D: - for (Int_t t = 0; t < eEventHistograms_N; t++) // type, see enum eEventHistograms + for (int t = 0; t < eEventHistograms_N; t++) // type, see enum eEventHistograms { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!eh.fEventHistograms[t][rs][ba]) { continue; @@ -6191,11 +9890,11 @@ void CheckUnderflowAndOverflow() // ... // c) Particle histograms 1D: - for (Int_t t = 0; t < eParticleHistograms_N; t++) // type, see enum eParticleHistograms + for (int t = 0; t < eParticleHistograms_N; t++) // type, see enum eParticleHistograms { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!ph.fParticleHistograms[t][rs][ba]) { continue; @@ -6209,28 +9908,28 @@ void CheckUnderflowAndOverflow() } // d) Particle histograms 2D: - for (Int_t t = 0; t < eParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D + for (int t = 0; t < eParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!ph.fParticleHistograms2D[t][rs][ba]) { continue; } // Underflow and overflow in x: - for (Int_t binY = 0; binY <= ph.fParticleHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { + for (int binY = 0; binY <= ph.fParticleHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { if (ph.fParticleHistograms2D[t][rs][ba]->GetBinContent(ph.fParticleHistograms2D[t][rs][ba]->GetBin(0, binY)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : underflow in x variable in fParticleHistograms2D[%d][%d][%d], for binY = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binY); } if (ph.fParticleHistograms2D[t][rs][ba]->GetBinContent(ph.fParticleHistograms2D[t][rs][ba]->GetBin(ph.fParticleHistograms2D[t][rs][ba]->GetNbinsX() + 1, binY)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : overflow in x variable in fParticleHistograms2D[%d][%d][%d], for binY = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binY); } - } // for (Int_t binY = 0; binY <= ph.fParticleHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { + } // for (int binY = 0; binY <= ph.fParticleHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { // Underflow and overflow in y: - for (Int_t binX = 0; binX <= ph.fParticleHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { + for (int binX = 0; binX <= ph.fParticleHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { if (ph.fParticleHistograms2D[t][rs][ba]->GetBinContent(ph.fParticleHistograms2D[t][rs][ba]->GetBin(binX, 0)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : underflow in y variable in fParticleHistograms2D[%d][%d][%d], for binX = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binX); } @@ -6238,34 +9937,34 @@ void CheckUnderflowAndOverflow() if (ph.fParticleHistograms2D[t][rs][ba]->GetBinContent(ph.fParticleHistograms2D[t][rs][ba]->GetBin(binX, ph.fParticleHistograms2D[t][rs][ba]->GetNbinsY() + 1)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : overflow in y variable in fParticleHistograms2D[%d][%d][%d], for binX = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binX); } - } // for (Int_t binX = 0; binX <= ph.fParticleHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { - } // for (Int_t ba = 0; ba < 2; ba++) // before/after cuts - } // for (Int_t rs = 0; rs < 2; rs++) // reco/sim - } // for (Int_t t = 0; t < eParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D + } // for (int binX = 0; binX <= ph.fParticleHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { + } // for (int ba = 0; ba < 2; ba++) // before/after cuts + } // for (int rs = 0; rs < 2; rs++) // reco/sim + } // for (int t = 0; t < eParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D // e) QA Event histograms 2D: - for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eQAEventHistograms2D + for (int t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eQAEventHistograms2D { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!qa.fQAEventHistograms2D[t][rs][ba]) { continue; } // Underflow and overflow in x: - for (Int_t binY = 0; binY <= qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { + for (int binY = 0; binY <= qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { if (qa.fQAEventHistograms2D[t][rs][ba]->GetBinContent(qa.fQAEventHistograms2D[t][rs][ba]->GetBin(0, binY)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : underflow in x variable in fEventHistograms2D[%d][%d][%d], for binY = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binY); } if (qa.fQAEventHistograms2D[t][rs][ba]->GetBinContent(qa.fQAEventHistograms2D[t][rs][ba]->GetBin(qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsX() + 1, binY)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : overflow in x variable in fEventHistograms2D[%d][%d][%d], for binY = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binY); } - } // for (Int_t binY = 0; binY <= qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { + } // for (int binY = 0; binY <= qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { // Underflow and overflow in y: - for (Int_t binX = 0; binX <= qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { + for (int binX = 0; binX <= qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { if (qa.fQAEventHistograms2D[t][rs][ba]->GetBinContent(qa.fQAEventHistograms2D[t][rs][ba]->GetBin(binX, 0)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : underflow in y variable in fEventHistograms2D[%d][%d][%d], for binX = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binX); } @@ -6273,34 +9972,34 @@ void CheckUnderflowAndOverflow() if (qa.fQAEventHistograms2D[t][rs][ba]->GetBinContent(qa.fQAEventHistograms2D[t][rs][ba]->GetBin(binX, qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsY() + 1)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : overflow in y variable in fEventHistograms2D[%d][%d][%d], for binX = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binX); } - } // for (Int_t binX = 0; binX <= qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { - } // for (Int_t ba = 0; ba < 2; ba++) // before/after cuts - } // for (Int_t rs = 0; rs < 2; rs++) // reco/sim - } // for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eQAEventHistograms2D + } // for (int binX = 0; binX <= qa.fQAEventHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { + } // for (int ba = 0; ba < 2; ba++) // before/after cuts + } // for (int rs = 0; rs < 2; rs++) // reco/sim + } // for (int t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eQAEventHistograms2D // f) QA Particle histograms 2D: - for (Int_t t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eQAParticleHistograms2D + for (int t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eQAParticleHistograms2D { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!qa.fQAParticleHistograms2D[t][rs][ba]) { continue; } // Underflow and overflow in x: - for (Int_t binY = 0; binY <= qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { + for (int binY = 0; binY <= qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { if (qa.fQAParticleHistograms2D[t][rs][ba]->GetBinContent(qa.fQAParticleHistograms2D[t][rs][ba]->GetBin(0, binY)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : underflow in x variable in fParticleHistograms2D[%d][%d][%d], for binY = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binY); } if (qa.fQAParticleHistograms2D[t][rs][ba]->GetBinContent(qa.fQAParticleHistograms2D[t][rs][ba]->GetBin(qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsX() + 1, binY)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : overflow in x variable in fParticleHistograms2D[%d][%d][%d], for binY = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binY); } - } // for (Int_t binY = 0; binY <= qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { + } // for (int binY = 0; binY <= qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { // Underflow and overflow in y: - for (Int_t binX = 0; binX <= qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { + for (int binX = 0; binX <= qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { if (qa.fQAParticleHistograms2D[t][rs][ba]->GetBinContent(qa.fQAParticleHistograms2D[t][rs][ba]->GetBin(binX, 0)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : underflow in y variable in fParticleHistograms2D[%d][%d][%d], for binX = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binX); } @@ -6308,35 +10007,35 @@ void CheckUnderflowAndOverflow() if (qa.fQAParticleHistograms2D[t][rs][ba]->GetBinContent(qa.fQAParticleHistograms2D[t][rs][ba]->GetBin(binX, qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsY() + 1)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : overflow in y variable in fParticleHistograms2D[%d][%d][%d], for binX = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binX); } - } // for (Int_t binX = 0; binX <= qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { - } // for (Int_t ba = 0; ba < 2; ba++) // before/after cuts - } // for (Int_t rs = 0; rs < 2; rs++) // reco/sim - } // for (Int_t t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D + } // for (int binX = 0; binX <= qa.fQAParticleHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { + } // for (int ba = 0; ba < 2; ba++) // before/after cuts + } // for (int rs = 0; rs < 2; rs++) // reco/sim + } // for (int t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D // g) QA Particle event histograms 2D: // TBI 20241212 I never validated this code block - for (Int_t t = 0; t < eQAParticleEventHistograms2D_N; t++) // type, see enum eQAParticleEventHistograms2D + for (int t = 0; t < eQAParticleEventHistograms2D_N; t++) // type, see enum eQAParticleEventHistograms2D { - for (Int_t rs = 0; rs < 2; rs++) // reco/sim + for (int rs = 0; rs < 2; rs++) // reco/sim { - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts + for (int ba = 0; ba < 2; ba++) // before/after cuts { if (!qa.fQAParticleEventHistograms2D[t][rs][ba]) { continue; } // Underflow and overflow in x: - for (Int_t binY = 0; binY <= qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { + for (int binY = 0; binY <= qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { if (qa.fQAParticleEventHistograms2D[t][rs][ba]->GetBinContent(qa.fQAParticleEventHistograms2D[t][rs][ba]->GetBin(0, binY)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : underflow in x variable in fParticleEventHistograms2D[%d][%d][%d], for binY = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binY); } if (qa.fQAParticleEventHistograms2D[t][rs][ba]->GetBinContent(qa.fQAParticleEventHistograms2D[t][rs][ba]->GetBin(qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsX() + 1, binY)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : overflow in x variable in fParticleEventHistograms2D[%d][%d][%d], for binY = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binY); } - } // for (Int_t binY = 0; binY <= qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { + } // for (int binY = 0; binY <= qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsY(); binY++) { // Underflow and overflow in y: - for (Int_t binX = 0; binX <= qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { + for (int binX = 0; binX <= qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { if (qa.fQAParticleEventHistograms2D[t][rs][ba]->GetBinContent(qa.fQAParticleEventHistograms2D[t][rs][ba]->GetBin(binX, 0)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : underflow in y variable in fParticleEventHistograms2D[%d][%d][%d], for binX = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binX); } @@ -6344,10 +10043,10 @@ void CheckUnderflowAndOverflow() if (qa.fQAParticleEventHistograms2D[t][rs][ba]->GetBinContent(qa.fQAParticleEventHistograms2D[t][rs][ba]->GetBin(binX, qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsY() + 1)) > 0) { LOGF(fatal, "\033[1;31m%s at line %d : overflow in y variable in fParticleEventHistograms2D[%d][%d][%d], for binX = %d => optimize default binning for this histogram\033[0m", __FUNCTION__, __LINE__, t, rs, ba, binX); } - } // for (Int_t binX = 0; binX <= qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { - } // for (Int_t ba = 0; ba < 2; ba++) // before/after cuts - } // for (Int_t rs = 0; rs < 2; rs++) // reco/sim - } // for (Int_t t = 0; t < eQAParticleEventHistograms2D_N; t++) // type, see enum eParticleEventHistograms2D + } // for (int binX = 0; binX <= qa.fQAParticleEventHistograms2D[t][rs][ba]->GetNbinsX(); binX++) { + } // for (int ba = 0; ba < 2; ba++) // before/after cuts + } // for (int rs = 0; rs < 2; rs++) // reco/sim + } // for (int t = 0; t < eQAParticleEventHistograms2D_N; t++) // type, see enum eParticleEventHistograms2D if (tc.fVerboseForEachParticle) { ExitFunction(__FUNCTION__); @@ -6379,12 +10078,12 @@ bool ValidTrack(T const& track) // a) Validity checks for tracks in Run 3: // *) Ensure that I am taking into account propagated tracks (and not e.g. track evaluated at innermost update): - if constexpr (rs == eRec || rs == eRecAndSim) { + if constexpr (rs == eRec || rs == eRecAndSim || rs == eQA) { if (!(track.trackType() == o2::aod::track::TrackTypeEnum::Track)) { if (tc.fVerboseForEachParticle) { LOGF(info, "\033[1;31m%s track.trackType() == o2::aod::track::TrackTypeEnum::Trac\033[0m", __FUNCTION__); } - return kFALSE; + return false; } } @@ -6395,7 +10094,7 @@ bool ValidTrack(T const& track) if (tc.fVerboseForEachParticle) { LOGF(info, "\033[1;31m%s track.trackType() == o2::aod::track::TrackTypeEnum::Run2Track\033[0m", __FUNCTION__); } - return kFALSE; + return false; } } @@ -6413,7 +10112,7 @@ bool ValidTrack(T const& track) LOGF(info, "\033[1;31m%s std::isnan(track.phi()) || std::isnan(track.pt()) || std::isnan(track.eta())\033[0m", __FUNCTION__); LOGF(error, "track.phi() = %f\ntrack.pt() = %f\ntrack.eta() = %f", track.phi(), track.pt(), track.eta()); } - return kFALSE; + return false; } // *) ... @@ -6422,12 +10121,126 @@ bool ValidTrack(T const& track) } // if(tc.fInsanityCheckForEachParticle) { // *) All checks above survived, then it's a valid track: - return kTRUE; + return true; } // template bool ValidTrack(T const& track) //============================================================ +float GetCentralityPercentile(TString ce) +{ + // Helper function for CentralityCorrelationCut(), to reduce the code bloat there. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // TBI 20250331 shall I add some insanity check on centrality estimator "ce" + + float centralityPercentile = -1.; + + // Run 3: + if (ce.EqualTo("centFT0C", TString::kIgnoreCase)) { + centralityPercentile = qa.fCentrality[eCentFT0C]; + } else if (ce.EqualTo("centFT0CVariant1", TString::kIgnoreCase)) { + centralityPercentile = qa.fCentrality[eCentFT0CVariant1]; + } else if (ce.EqualTo("centFT0M", TString::kIgnoreCase)) { + centralityPercentile = qa.fCentrality[eCentFT0M]; + } else if (ce.EqualTo("centFV0A", TString::kIgnoreCase)) { + centralityPercentile = qa.fCentrality[eCentFV0A]; + } else if (ce.EqualTo("centNTPV", TString::kIgnoreCase)) { + centralityPercentile = qa.fCentrality[eCentNTPV]; + } else if (ce.EqualTo("centNGlobal", TString::kIgnoreCase)) { + // centralityPercentile = qa.fCentrality[eCentNGlobal]; // TBI 20250331 enable eventually + + // ... ctd. here with Run 3 estimators ... + + // Run 1 and Run 2: + } else if (ce.EqualTo("centRun2V0M", TString::kIgnoreCase)) { + centralityPercentile = qa.fCentrality[eCentRun2V0M]; + } else if (ce.EqualTo("centRun2SPDTracklets", TString::kIgnoreCase)) { + centralityPercentile = qa.fCentrality[eCentRun2SPDTracklets]; + + // ... ctd. here with Run 1 and Run 2 estimators ... + + } else { + LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %s is not supported yet. \033[0m", __FUNCTION__, __LINE__, ce.Data()); + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + + return centralityPercentile; + +} // float GetCentralityPercentile(TString ce) + +//============================================================ + +bool CentralityCorrelationCut() +{ + // If centrality correlation cut was requested, in this function i decide whether the current event survives it or not. + // This function is called only in EventCuts(...). I implemented it here separately merely to keep code in EventCuts(...) as clean as possible. + // If makes sense to call this function, only if in DetermineCentrality(...) I have filled in qa.Centrality . + + // TBI 20250331 There is a bit of performance loss, because I need 2 centrality estimators to calculate correlation cut, and I fill in qa.Centrality values + // for all centrality estimators. But this way I can chain several centrality correlation cuts in the future with AND condition, if necessary. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + LOGF(info, "\033[1;33m%s at line %d : ec.fsEventCuts[eCentralityCorrelationsCut] = %s \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityCorrelationsCut].Data()); + } + + bool alright = true; // this local variable holds the return value for this function + + // Algorithm: I extract e.g. from "CentFT0C_CentFT0M" that the first estimator is "CentFT0C" and second "CentFT0M", and for each estimator I fetch the corresponding centrality percentile: + if (!ec.fsEventCuts[eCentralityCorrelationsCut].Contains("_")) { + LOGF(fatal, "\033[1;31m%s at line %d : ec.fsEventCuts[eCentralityCorrelationsCut] = %s \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityCorrelationsCut].Data()); + } + + TObjArray* oa = ec.fsEventCuts[eCentralityCorrelationsCut].Tokenize("_"); // TBI 20250331 let's see for how long I can use "_" safely as IFS ... + if (!oa || 2 != oa->GetEntries()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL , s = %s. Example format is e.g. \"CentFT0C_CentFT0M\"\033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityCorrelationsCut].Data()); + } + + if (tc.fVerbose) { + LOGF(info, "\033[1;33m%s at line %d : oa->At(0)->GetName() = %s \033[0m", __FUNCTION__, __LINE__, oa->At(0)->GetName()); + LOGF(info, "\033[1;33m%s at line %d : oa->At(1)->GetName() = %s \033[0m", __FUNCTION__, __LINE__, oa->At(1)->GetName()); + } + + ec.fCentralityValues[0] = GetCentralityPercentile(oa->At(0)->GetName()); + ec.fCentralityValues[1] = GetCentralityPercentile(oa->At(1)->GetName()); + delete oa; // yes + + // Okay, do the thing: + // *) "Relative" <=> |(firstEstimator-secondEstimator)/(firstEstimator+secondEstimator)| > treshold => reject the event => alright = false + // *) "Absolute" <=> |firstEstimator-secondEstimator| > treshold => reject the event => alright = false + // *) ... + if (ec.fCentralityValues[0] > 0. && ec.fCentralityValues[1] > 0.) { + if (ec.fCentralityCorrelationsCutVersion.EqualTo("Relative")) { + if (std::abs((ec.fCentralityValues[0] - ec.fCentralityValues[1]) / (ec.fCentralityValues[0] + ec.fCentralityValues[1])) > ec.fCentralityCorrelationsCutTreshold) { + alright = false; + } + } else if (ec.fCentralityCorrelationsCutVersion.EqualTo("Absolute")) { + if (std::abs((ec.fCentralityValues[0] - ec.fCentralityValues[1])) > ec.fCentralityCorrelationsCutTreshold) { + alright = false; + } + } else { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } // if(ec.fCentralityValues[0] > 0. && ec.fCentralityValues[1] > 0.) + + if (tc.fVerbose) { + LOGF(info, "\033[1;33m%s at line %d : %f, %f, %f, %d \033[0m", __FUNCTION__, __LINE__, ec.fCentralityValues[0], ec.fCentralityValues[1], ec.fCentralityCorrelationsCutTreshold, static_cast(alright)); + ExitFunction(__FUNCTION__); + } + + return alright; + +} // bool CentralityCorrelationCut() + +//============================================================ + template void ParticleCutsCounters(T const& track) { @@ -6444,30 +10257,60 @@ void ParticleCutsCounters(T const& track) ParticleCuts(track, eCutCounterBinning); // dry call, to establish the map fParticleCutCounterMap and its inverse // **) Map this ordering into bin labels of actual histograms for particle cut counters: - for (Int_t rec_sim = 0; rec_sim < 2; rec_sim++) // reco/sim => I use here exceptionally different var 'rec_sim', not the shadow 'rs' in the template parameter + for (int rec_sim = 0; rec_sim < 2; rec_sim++) // reco/sim => I use here exceptionally different var 'rec_sim', not the shadow 'rs' in the template parameter { - for (Int_t cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter + for (int cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter { if (!pc.fParticleCutCounterHist[rec_sim][cc]) { continue; } - for (Int_t bin = 1; bin < pc.fParticleCutCounterBinNumber[rec_sim]; bin++) // implemented and used particle cuts in this analysis - { - pc.fParticleCutCounterHist[rec_sim][cc]->GetXaxis()->SetBinLabel(bin, FancyFormatting(pc.fParticleCutName[pc.fParticleCutCounterMap[rec_sim]->GetValue(bin)].Data())); - } - for (Int_t bin = pc.fParticleCutCounterBinNumber[rec_sim]; bin <= eParticleCuts_N; bin++) // implemented, but unused particle cuts in this analysis - { - pc.fParticleCutCounterHist[rec_sim][cc]->GetXaxis()->SetBinLabel(bin, Form("binNo = %d (unused cut)", bin)); - // Remark: I have to write here something concrete as a bin label, if I leave "TBI" for all bin labels here for cuts which were not used, - // I get this harmless but annoying warning during merging: - // Warning in : Histogram fParticleCutCounterHist[rec][seq] has duplicate labels in the x axis. Bin contents will be merged in a single bin - // TBI 20241130 as a better solution, I shall re-define this histogram with the narower range on x-axis... + + if (tc.fUseSetBinLabel) { + + for (int bin = 1; bin < pc.fParticleCutCounterBinNumber[rec_sim]; bin++) // implemented and used particle cuts in this analysis + { + pc.fParticleCutCounterHist[rec_sim][cc]->GetXaxis()->SetBinLabel(bin, FancyFormatting(pc.fParticleCutName[pc.fParticleCutCounterMap[rec_sim]->GetValue(bin)].Data())); + } + for (int bin = pc.fParticleCutCounterBinNumber[rec_sim]; bin <= eParticleCuts_N; bin++) // implemented, but unused particle cuts in this analysis + { + pc.fParticleCutCounterHist[rec_sim][cc]->GetXaxis()->SetBinLabel(bin, Form("binNo = %d (unused cut)", bin)); + // Remark: I have to write here something concrete as a bin label, if I leave "TBI" for all bin labels here for cuts which were not used, + // I get this harmless but annoying warning during merging: + // Warning in : Histogram fParticleCutCounterHist[rec][seq] has duplicate labels in the x axis. Bin contents will be merged in a single bin + // TBI 20241130 as a better solution, I shall re-define this histogram with the narower range on x-axis... + } + + } else { + + // Workaround for SetBinLabel() large memory consumption: + TString yAxisTitle = ""; + for (int bin = 1; bin < pc.fParticleCutCounterBinNumber[rec_sim]; bin++) // implemented and used cuts in this analysis + { + yAxisTitle += TString::Format("%d:%s; ", bin, FancyFormatting(pc.fParticleCutName[pc.fParticleCutCounterMap[rec_sim]->GetValue(bin)].Data())); + } + for (int bin = pc.fParticleCutCounterBinNumber[rec_sim]; bin <= eParticleCuts_N; bin++) // implemented, but unused cuts in this analysis + { + yAxisTitle += TString::Format("%d:%s; ", bin, TString::Format("binNo = %d (unused cut)", bin).Data()); + } + + // *) Insanity check on the number of fields in this specially crafted y-axis title: + TObjArray* oa = yAxisTitle.Tokenize(";"); + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d : oa is NULL\033[0m", __FUNCTION__, __LINE__); + } + if (oa->GetEntries() - 1 != pc.fParticleCutCounterHist[rec_sim][cc]->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d : oa->GetEntries() = %d != pc.fParticleCutCounterHist[rec_sim][cc]->GetNbinsX() = %d\033[0m", __FUNCTION__, __LINE__, oa->GetEntries(), pc.fParticleCutCounterHist[rec_sim][cc]->GetNbinsX()); + } + delete oa; + + // *) Okay, set the title: + pc.fParticleCutCounterHist[rec_sim][cc]->GetYaxis()->SetTitle(yAxisTitle.Data()); } // All cuts which were implemeted, but not used I simply do not show (i can always UnZoom x-axis in TBrowser, if I want to see 'em). pc.fParticleCutCounterHist[rec_sim][cc]->GetXaxis()->SetRangeUser(pc.fParticleCutCounterHist[rec_sim][cc]->GetBinLowEdge(1), pc.fParticleCutCounterHist[rec_sim][cc]->GetBinLowEdge(pc.fParticleCutCounterBinNumber[rec_sim])); } } - pc.fParticleCutCounterBinLabelingIsDone = kTRUE; // this flag ensures that this specific binning is performed only once, for the first processed particle + pc.fParticleCutCounterBinLabelingIsDone = true; // this flag ensures that this specific binning is performed only once, for the first processed particle // delete pc.fParticleCutCounterMap[eRec]; // TBI 20240508 if i do not need them later, I could delete here // delete pc.fParticleCutCounterMap[eSim]; // delete pc.fParticleCutCounterMapInverse[eRec]; @@ -6493,11 +10336,11 @@ void ParticleCutsCounters(T const& track) //============================================================ template -Bool_t ParticleCuts(T const& track, eCutModus cutModus) +bool ParticleCuts(T const& track, eCutModus cutModus) { // Particle cuts on reconstructed and simulated data. Supports particle cut counters, both absolute and sequential. // There is also a related enum eParticleCuts. - // Remark: I have added to all if statemets below which deals with floats, e.g. TMath::Abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision , + // Remark: I have added to all if statemets below which deals with floats, e.g. std::abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision , // to enforce the ROOT convention: "lower boundary included, upper boundary excluded" // a) Particle cuts on reconstructed, and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1); @@ -6509,20 +10352,22 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) // *) Particle cuts on Test case; // *) Toy NUA. + // 44:ParticleCuts + if (tc.fVerboseForEachParticle) { StartFunction(__FUNCTION__); } // a) Particle cuts on reconstructed, and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1) ... - if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { + if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1 || rs == eQA) { // *) Phi: if (pc.fUseParticleCuts[ePhi]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, ePhi, eCutCounterBinning); - } else if (track.phi() < pc.fdParticleCuts[ePhi][eMin] || track.phi() > pc.fdParticleCuts[ePhi][eMax] || TMath::Abs(track.phi() - pc.fdParticleCuts[ePhi][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.phi() < pc.fdParticleCuts[ePhi][eMin] || track.phi() > pc.fdParticleCuts[ePhi][eMax] || std::abs(track.phi() - pc.fdParticleCuts[ePhi][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, ePhi, cutModus)) { - return kFALSE; + return false; } } } @@ -6531,9 +10376,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[ePt]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, ePt, eCutCounterBinning); - } else if (track.pt() < pc.fdParticleCuts[ePt][eMin] || track.pt() > pc.fdParticleCuts[ePt][eMax] || TMath::Abs(track.pt() - pc.fdParticleCuts[ePt][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.pt() < pc.fdParticleCuts[ePt][eMin] || track.pt() > pc.fdParticleCuts[ePt][eMax] || std::abs(track.pt() - pc.fdParticleCuts[ePt][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, ePt, cutModus)) { - return kFALSE; + return false; } } } @@ -6542,9 +10387,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[eEta]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, eEta, eCutCounterBinning); - } else if (track.eta() < pc.fdParticleCuts[eEta][eMin] || track.eta() > pc.fdParticleCuts[eEta][eMax] || TMath::Abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.eta() < pc.fdParticleCuts[eEta][eMin] || track.eta() > pc.fdParticleCuts[eEta][eMax] || std::abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, eEta, cutModus)) { - return kFALSE; + return false; } } } @@ -6557,7 +10402,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) // With first condition, I always throw away neutral particles. // I can use safely == here, because track.sign() returns short int. if (!ParticleCut(eRec, eCharge, cutModus)) { - return kFALSE; + return false; } } } @@ -6568,7 +10413,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, etpcNClsFindable, eCutCounterBinning); } else if (track.tpcNClsFindable() < pc.fdParticleCuts[etpcNClsFindable][eMin] || track.tpcNClsFindable() > pc.fdParticleCuts[etpcNClsFindable][eMax]) { if (!ParticleCut(eRec, etpcNClsFindable, cutModus)) { - return kFALSE; + return false; } } } @@ -6579,7 +10424,18 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, etpcNClsShared, eCutCounterBinning); } else if (track.tpcNClsShared() < pc.fdParticleCuts[etpcNClsShared][eMin] || track.tpcNClsShared() > pc.fdParticleCuts[etpcNClsShared][eMax]) { if (!ParticleCut(eRec, etpcNClsShared, cutModus)) { - return kFALSE; + return false; + } + } + } + + // *) itsChi2NCl + if (pc.fUseParticleCuts[eitsChi2NCl]) { + if (cutModus == eCutCounterBinning) { + ParticleCut(eRec, eitsChi2NCl, eCutCounterBinning); + } else if (track.itsChi2NCl() < pc.fdParticleCuts[eitsChi2NCl][eMin] || track.itsChi2NCl() > pc.fdParticleCuts[eitsChi2NCl][eMax]) { + if (!ParticleCut(eRec, eitsChi2NCl, cutModus)) { + return false; } } } @@ -6590,7 +10446,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, etpcNClsFound, eCutCounterBinning); } else if (track.tpcNClsFound() < pc.fdParticleCuts[etpcNClsFound][eMin] || track.tpcNClsFound() > pc.fdParticleCuts[etpcNClsFound][eMax]) { if (!ParticleCut(eRec, etpcNClsFound, cutModus)) { - return kFALSE; + return false; } } } @@ -6601,7 +10457,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, etpcNClsCrossedRows, eCutCounterBinning); } else if (track.tpcNClsCrossedRows() < pc.fdParticleCuts[etpcNClsCrossedRows][eMin] || track.tpcNClsCrossedRows() > pc.fdParticleCuts[etpcNClsCrossedRows][eMax]) { if (!ParticleCut(eRec, etpcNClsCrossedRows, cutModus)) { - return kFALSE; + return false; } } } @@ -6612,7 +10468,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, eitsNCls, eCutCounterBinning); } else if (track.itsNCls() < pc.fdParticleCuts[eitsNCls][eMin] || track.itsNCls() > pc.fdParticleCuts[eitsNCls][eMax]) { if (!ParticleCut(eRec, eitsNCls, cutModus)) { - return kFALSE; + return false; } } } @@ -6623,7 +10479,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, eitsNClsInnerBarrel, eCutCounterBinning); } else if (track.itsNClsInnerBarrel() < pc.fdParticleCuts[eitsNClsInnerBarrel][eMin] || track.itsNClsInnerBarrel() > pc.fdParticleCuts[eitsNClsInnerBarrel][eMax]) { if (!ParticleCut(eRec, eitsNClsInnerBarrel, cutModus)) { - return kFALSE; + return false; } } } @@ -6632,9 +10488,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[etpcCrossedRowsOverFindableCls]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, etpcCrossedRowsOverFindableCls, eCutCounterBinning); - } else if (track.tpcCrossedRowsOverFindableCls() < pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMin] || track.tpcCrossedRowsOverFindableCls() > pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMax] || TMath::Abs(track.tpcCrossedRowsOverFindableCls() - pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.tpcCrossedRowsOverFindableCls() < pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMin] || track.tpcCrossedRowsOverFindableCls() > pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMax] || std::abs(track.tpcCrossedRowsOverFindableCls() - pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, etpcCrossedRowsOverFindableCls, cutModus)) { - return kFALSE; + return false; } } } @@ -6643,9 +10499,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[etpcFoundOverFindableCls]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, etpcFoundOverFindableCls, eCutCounterBinning); - } else if (track.tpcFoundOverFindableCls() < pc.fdParticleCuts[etpcFoundOverFindableCls][eMin] || track.tpcFoundOverFindableCls() > pc.fdParticleCuts[etpcFoundOverFindableCls][eMax] || TMath::Abs(track.tpcFoundOverFindableCls() - pc.fdParticleCuts[etpcFoundOverFindableCls][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.tpcFoundOverFindableCls() < pc.fdParticleCuts[etpcFoundOverFindableCls][eMin] || track.tpcFoundOverFindableCls() > pc.fdParticleCuts[etpcFoundOverFindableCls][eMax] || std::abs(track.tpcFoundOverFindableCls() - pc.fdParticleCuts[etpcFoundOverFindableCls][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, etpcFoundOverFindableCls, cutModus)) { - return kFALSE; + return false; } } } @@ -6654,9 +10510,20 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[etpcFractionSharedCls]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, etpcFractionSharedCls, eCutCounterBinning); - } else if (track.tpcFractionSharedCls() < pc.fdParticleCuts[etpcFractionSharedCls][eMin] || track.tpcFractionSharedCls() > pc.fdParticleCuts[etpcFractionSharedCls][eMax] || TMath::Abs(track.tpcFractionSharedCls() - pc.fdParticleCuts[etpcFractionSharedCls][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.tpcFractionSharedCls() < pc.fdParticleCuts[etpcFractionSharedCls][eMin] || track.tpcFractionSharedCls() > pc.fdParticleCuts[etpcFractionSharedCls][eMax] || std::abs(track.tpcFractionSharedCls() - pc.fdParticleCuts[etpcFractionSharedCls][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, etpcFractionSharedCls, cutModus)) { - return kFALSE; + return false; + } + } + } + + // *) tpcChi2NCl: + if (pc.fUseParticleCuts[etpcChi2NCl]) { + if (cutModus == eCutCounterBinning) { + ParticleCut(eRec, etpcChi2NCl, eCutCounterBinning); + } else if (track.tpcChi2NCl() < pc.fdParticleCuts[etpcChi2NCl][eMin] || track.tpcChi2NCl() > pc.fdParticleCuts[etpcChi2NCl][eMax] || std::abs(track.tpcChi2NCl() - pc.fdParticleCuts[etpcChi2NCl][eMax]) < tc.fFloatingPointPrecision) { + if (!ParticleCut(eRec, etpcChi2NCl, cutModus)) { + return false; } } } @@ -6665,9 +10532,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[edcaXY]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, edcaXY, eCutCounterBinning); - } else if (track.dcaXY() < pc.fdParticleCuts[edcaXY][eMin] || track.dcaXY() > pc.fdParticleCuts[edcaXY][eMax] || TMath::Abs(track.dcaXY() - pc.fdParticleCuts[edcaXY][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.dcaXY() < pc.fdParticleCuts[edcaXY][eMin] || track.dcaXY() > pc.fdParticleCuts[edcaXY][eMax] || std::abs(track.dcaXY() - pc.fdParticleCuts[edcaXY][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, edcaXY, cutModus)) { - return kFALSE; + return false; } } } @@ -6676,9 +10543,20 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[edcaZ]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, edcaZ, eCutCounterBinning); - } else if (track.dcaZ() < pc.fdParticleCuts[edcaZ][eMin] || track.dcaZ() > pc.fdParticleCuts[edcaZ][eMax] || TMath::Abs(track.dcaZ() - pc.fdParticleCuts[edcaZ][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.dcaZ() < pc.fdParticleCuts[edcaZ][eMin] || track.dcaZ() > pc.fdParticleCuts[edcaZ][eMax] || std::abs(track.dcaZ() - pc.fdParticleCuts[edcaZ][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, edcaZ, cutModus)) { - return kFALSE; + return false; + } + } + } + + // *) trackCutFlag: + if (pc.fUseParticleCuts[etrackCutFlag]) { + if (cutModus == eCutCounterBinning) { + ParticleCut(eRec, etrackCutFlag, eCutCounterBinning); + } else if (!track.trackCutFlag()) { + if (!ParticleCut(eRec, etrackCutFlag, cutModus)) { + return false; } } } @@ -6689,7 +10567,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, etrackCutFlagFb1, eCutCounterBinning); } else if (!track.trackCutFlagFb1()) { if (!ParticleCut(eRec, etrackCutFlagFb1, cutModus)) { - return kFALSE; + return false; } } } @@ -6700,7 +10578,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, etrackCutFlagFb2, eCutCounterBinning); } else if (!track.trackCutFlagFb2()) { if (!ParticleCut(eRec, etrackCutFlagFb2, cutModus)) { - return kFALSE; + return false; } } } @@ -6711,7 +10589,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, eisQualityTrack, eCutCounterBinning); } else if (!track.isQualityTrack()) { if (!ParticleCut(eRec, eisQualityTrack, cutModus)) { - return kFALSE; + return false; } } } @@ -6722,7 +10600,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, eisPrimaryTrack, eCutCounterBinning); } else if (!track.isPrimaryTrack()) { if (!ParticleCut(eRec, eisPrimaryTrack, cutModus)) { - return kFALSE; + return false; } } } @@ -6733,7 +10611,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, eisInAcceptanceTrack, eCutCounterBinning); } else if (!track.isInAcceptanceTrack()) { if (!ParticleCut(eRec, eisInAcceptanceTrack, cutModus)) { - return kFALSE; + return false; } } } @@ -6744,7 +10622,18 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) ParticleCut(eRec, eisGlobalTrack, eCutCounterBinning); } else if (!track.isGlobalTrack()) { if (!ParticleCut(eRec, eisGlobalTrack, cutModus)) { - return kFALSE; + return false; + } + } + } + + // *) isPVContributor: + if (pc.fUseParticleCuts[eisPVContributor]) { + if (cutModus == eCutCounterBinning) { + ParticleCut(eRec, eisPVContributor, eCutCounterBinning); + } else if (!track.isPVContributor()) { + if (!ParticleCut(eRec, eisPVContributor, cutModus)) { + return false; } } } @@ -6753,9 +10642,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[ePtDependentDCAxyParameterization]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, ePtDependentDCAxyParameterization, eCutCounterBinning); - } else if (TMath::Abs(track.dcaXY()) > pc.fPtDependentDCAxyFormula->Eval(track.pt())) { + } else if (std::abs(track.dcaXY()) > pc.fPtDependentDCAxyFormula->Eval(track.pt())) { if (!ParticleCut(eRec, ePtDependentDCAxyParameterization, cutModus)) { - return kFALSE; + return false; } } } @@ -6769,38 +10658,37 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (!track.has_mcParticle()) { LOGF(warning, "No MC particle for this track, skip..."); - return kFALSE; // TBI 20231107 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this track + return false; // TBI 20231107 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this track } - // auto mcparticle = track.mcParticle(); // corresponding MC truth simulated particle + // auto mcParticle = track.mcParticle(); // corresponding MC truth simulated particle - // In this branch I can cut additionally and directly on corresponding MC truth simulated, e.g. on mcparticle.pt() + // In this branch I can cut additionally and directly on corresponding MC truth simulated, e.g. on mcParticle.pt() // In case I implement something here, remember to switch from eRec to eSim when calling e.g. ParticleCut(...) - /* - // *) Phi: TBI 2024-511 re-think if i really cut directly on MC truth kine and other info and keep it in sync with what I did in AliPhysics - if (pc.fUseParticleCuts[ePhi]) { - if (cutModus == eCutCounterBinning) { - ParticleCut(eSim, ePhi, eCutCounterBinning); - } else if (mcparticle.phi() < pc.fdParticleCuts[ePhi][eMin] || mcparticle.phi() > pc.fdParticleCuts[ePhi][eMax]) { - if (!ParticleCut(eSim, ePhi, cutModus)) { - return kFALSE; - } - } - } - */ - // *) Charge: TBI 20240511 mcparticle.sign() doesn't exist, here most likely i need to cut on the signature of mcparticle.pdg() but check further, because e is negative charge, but PDG is 11, etc. - /* - if (pc.fUseParticleCuts[eCharge]) { - if (cutModus == eCutCounterBinning) { - ParticleCut(eSim, eCharge, eCutCounterBinning); - } else if (0 == mcparticle.sign() || mcparticle.sign() < pc.fdParticleCuts[eCharge][eMin] || mcparticle.sign() > pc.fdParticleCuts[eCharge][eMax]) { - // TBI 20240511 with first condition, I always throw away neutral particles, so for the time being that is hardcoded - if (!ParticleCut(eSim, eCharge, cutModus)) { - return kFALSE; - } - } - } - */ + // // *) Phi: TBI 2024-511 re-think if i really cut directly on MC truth kine and other info and keep it in sync with what I did in AliPhysics + // if (pc.fUseParticleCuts[ePhi]) { + // if (cutModus == eCutCounterBinning) { + // ParticleCut(eSim, ePhi, eCutCounterBinning); + // } else if (mcParticle.phi() < pc.fdParticleCuts[ePhi][eMin] || mcParticle.phi() > pc.fdParticleCuts[ePhi][eMax]) { + // if (!ParticleCut(eSim, ePhi, cutModus)) { + // return false; + // } + // } + // } + + // *) Charge: TBI 20240511 mcParticle.sign() doesn't exist, get charge from tc.fDatabasePDG instead using PDG code , as I did it below + + // if (pc.fUseParticleCuts[eCharge]) { + // if (cutModus == eCutCounterBinning) { + // ParticleCut(eSim, eCharge, eCutCounterBinning); + // } else if (0 == mcParticle.sign() || mcParticle.sign() < pc.fdParticleCuts[eCharge][eMin] || mcParticle.sign() > pc.fdParticleCuts[eCharge][eMax]) { + // // TBI 20240511 with first condition, I always throw away neutral particles, so for the time being that is hardcoded + // if (!ParticleCut(eSim, eCharge, cutModus)) { + // return false; + // } + // } + // } + // TBI 20240511 add cut on PDG // ... @@ -6820,9 +10708,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[ePhi]) { if (cutModus == eCutCounterBinning) { ParticleCut(eSim, ePhi, eCutCounterBinning); - } else if (track.phi() < pc.fdParticleCuts[ePhi][eMin] || track.phi() > pc.fdParticleCuts[ePhi][eMax] || TMath::Abs(track.phi() - pc.fdParticleCuts[ePhi][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.phi() < pc.fdParticleCuts[ePhi][eMin] || track.phi() > pc.fdParticleCuts[ePhi][eMax] || std::abs(track.phi() - pc.fdParticleCuts[ePhi][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eSim, ePhi, cutModus)) { - return kFALSE; + return false; } } } @@ -6831,9 +10719,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[ePt]) { if (cutModus == eCutCounterBinning) { ParticleCut(eSim, ePt, eCutCounterBinning); - } else if (track.pt() < pc.fdParticleCuts[ePt][eMin] || track.pt() > pc.fdParticleCuts[ePt][eMax] || TMath::Abs(track.pt() - pc.fdParticleCuts[ePt][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.pt() < pc.fdParticleCuts[ePt][eMin] || track.pt() > pc.fdParticleCuts[ePt][eMax] || std::abs(track.pt() - pc.fdParticleCuts[ePt][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eSim, ePt, cutModus)) { - return kFALSE; + return false; } } } @@ -6842,9 +10730,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[eEta]) { if (cutModus == eCutCounterBinning) { ParticleCut(eSim, eEta, eCutCounterBinning); - } else if (track.eta() < pc.fdParticleCuts[eEta][eMin] || track.eta() > pc.fdParticleCuts[eEta][eMax] || TMath::Abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.eta() < pc.fdParticleCuts[eEta][eMin] || track.eta() > pc.fdParticleCuts[eEta][eMax] || std::abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eSim, eEta, cutModus)) { - return kFALSE; + return false; } } } @@ -6852,17 +10740,39 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) /* // *) Charge: if (pc.fUseParticleCuts[eCharge]) { + double charge = -44.; // yes, never initialize charge to 0. + if (tc.fDatabasePDG && tc.fDatabasePDG->GetParticle(track.pdgCode())) { + // Yes, I have to check the 2nd condition, because e.g. for PDG code 1000010020 (deuteron), GetParticle(...) returns NULL + charge = tc.fDatabasePDG->GetParticle(track.pdgCode())->Charge() / 3.; // yes, divided by 3. Fundamental unit of charge is associated with quarks + if (tc.fVerboseForEachParticle) { + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! There is a large memory blow-up when using TDatabasePDG !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); + } + } if (cutModus == eCutCounterBinning) { ParticleCut(eSim, eCharge, eCutCounterBinning); - } else if (0 == track.sign() || track.sign() < pc.fdParticleCuts[eCharge][eMin] || track.sign() > pc.fdParticleCuts[eCharge][eMax]) { - // TBI 20240511 with first condition, I always throw away neutral particles, so for the time being that is hardcoded + } else if (0 == static_cast(charge) || charge < pc.fdParticleCuts[eCharge][eMin] || charge > pc.fdParticleCuts[eCharge][eMax]) { + // TBI 20250611 with first condition, I always throw away neutral particles when O2DatabasePDG is used. + // However due to initialization charge = 0. that way I throw all particles when O2DatabasePDG is NOT used. + // Therefore, when O2DatabasePDG is NOT used, I have to disable cut on charge, since that info is not available. if (!ParticleCut(eSim, eCharge, cutModus)) { - return kFALSE; + return false; } } } + */ - // TBI 20240511 add cut on PDG + + // *) PDG code: + if (pc.fUseParticleCuts[ePDG]) { + if (cutModus == eCutCounterBinning) { + ParticleCut(eSim, ePDG, eCutCounterBinning); + } else if (track.pdgCode() < pc.fdParticleCuts[ePDG][eMin] || track.pdgCode() > pc.fdParticleCuts[ePDG][eMax]) { + // TBI 20250611 I need to generalize this, e.g. add support to process more that one PDG code (e.g. 2212 and -2212, etc.) + if (!ParticleCut(eSim, ePDG, cutModus)) { + return false; + } + } + } // ... @@ -6872,7 +10782,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) // c) Particle cuts on reconstructed, and corresponding MC truth simulated (Run 3 specific): // Remark: I implement here only the particle cuts which are not already in group a) above, and which make sense only for Run 3 data. - if constexpr (rs == eRec || rs == eRecAndSim) { + if constexpr (rs == eRec || rs == eRecAndSim || rs == eQA) { // ... @@ -6881,9 +10791,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (!track.has_mcParticle()) { LOGF(warning, "No MC particle for this track, skip..."); - return kFALSE; // TBI 20231107 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this track + return false; // TBI 20231107 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this track } - // auto mcparticle = track.mcParticle(); // corresponding MC truth simulated particle + // auto mcParticle = track.mcParticle(); // corresponding MC truth simulated particle // ... @@ -6918,9 +10828,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (!track.has_mcParticle()) { LOGF(warning, "No MC particle for this track, skip..."); - return kFALSE; // TBI 20231107 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this track + return false; // TBI 20231107 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this track } - // auto mcparticle = track.mcParticle(); // corresponding MC truth simulated particle + // auto mcParticle = track.mcParticle(); // corresponding MC truth simulated particle // ... @@ -6951,9 +10861,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[ePhi]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, ePhi, eCutCounterBinning); - } else if (track.phi() < pc.fdParticleCuts[ePhi][eMin] || track.phi() > pc.fdParticleCuts[ePhi][eMax] || TMath::Abs(track.phi() - pc.fdParticleCuts[ePhi][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.phi() < pc.fdParticleCuts[ePhi][eMin] || track.phi() > pc.fdParticleCuts[ePhi][eMax] || std::abs(track.phi() - pc.fdParticleCuts[ePhi][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, ePhi, cutModus)) { - return kFALSE; + return false; } } } @@ -6962,9 +10872,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[ePt]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, ePt, eCutCounterBinning); - } else if (track.pt() < pc.fdParticleCuts[ePt][eMin] || track.pt() > pc.fdParticleCuts[ePt][eMax] || TMath::Abs(track.pt() - pc.fdParticleCuts[ePt][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.pt() < pc.fdParticleCuts[ePt][eMin] || track.pt() > pc.fdParticleCuts[ePt][eMax] || std::abs(track.pt() - pc.fdParticleCuts[ePt][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, ePt, cutModus)) { - return kFALSE; + return false; } } } @@ -6973,9 +10883,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (pc.fUseParticleCuts[eEta]) { if (cutModus == eCutCounterBinning) { ParticleCut(eRec, eEta, eCutCounterBinning); - } else if (track.eta() < pc.fdParticleCuts[eEta][eMin] || track.eta() > pc.fdParticleCuts[eEta][eMax] || TMath::Abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision) { + } else if (track.eta() < pc.fdParticleCuts[eEta][eMin] || track.eta() > pc.fdParticleCuts[eEta][eMax] || std::abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, eEta, cutModus)) { - return kFALSE; + return false; } } } @@ -6992,9 +10902,9 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) // Remark: I do not for the time being add Toy NUA cuts to particle cut counters, since in this case I can inspect direcly from phi, pt and eta distributions. // Local kine variables on which support for Toy NUA is implemented and applied: - Double_t dPhi = 0.; - Double_t dPt = 0.; - Double_t dEta = 0.; + double dPhi = 0.; + double dPt = 0.; + double dEta = 0.; // *) Apply Toy NUA on info available in reconstructed (and the corresponding MC truth simulated track); if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { @@ -7004,35 +10914,35 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) // Apply NUA on these kine variables: if (nua.fApplyNUAPDF[ePhiNUAPDF] && !Accept(dPhi, ePhiNUAPDF)) { - return kFALSE; + return false; } if (nua.fApplyNUAPDF[ePtNUAPDF] && !Accept(dPt, ePtNUAPDF)) { - return kFALSE; + return false; } if (nua.fApplyNUAPDF[eEtaNUAPDF] && !Accept(dEta, eEtaNUAPDF)) { - return kFALSE; + return false; } // ... and corresponding MC truth simulated ( see https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/mcHistograms.cxx ): if constexpr (rs == eRecAndSim || rs == eRecAndSim_Run2 || rs == eRecAndSim_Run1) { if (!track.has_mcParticle()) { LOGF(warning, "No MC particle for this track, skip..."); - return kFALSE; // TBI 20231107 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this particle + return false; // TBI 20231107 re-think. I shouldn't probably get to this point, if MC truth info doesn't exist for this particle } - auto mcparticle = track.mcParticle(); // corresponding MC truth simulated particle - dPhi = mcparticle.phi(); - dPt = mcparticle.pt(); - dEta = mcparticle.eta(); + auto mcParticle = track.mcParticle(); // corresponding MC truth simulated particle + dPhi = mcParticle.phi(); + dPt = mcParticle.pt(); + dEta = mcParticle.eta(); // Apply NUA on these kine variables: if (nua.fApplyNUAPDF[ePhiNUAPDF] && !Accept(dPhi, ePhiNUAPDF)) { - return kFALSE; + return false; } if (nua.fApplyNUAPDF[ePtNUAPDF] && !Accept(dPt, ePtNUAPDF)) { - return kFALSE; + return false; } if (nua.fApplyNUAPDF[eEtaNUAPDF] && !Accept(dEta, eEtaNUAPDF)) { - return kFALSE; + return false; } } // if constexpr (rs == eRecAndSim || rs == eRecAndSim_Run2 || rs == eRecAndSim_Run1) { @@ -7047,64 +10957,69 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) // Apply NUA on these kine variables: if (nua.fApplyNUAPDF[ePhiNUAPDF] && !Accept(dPhi, ePhiNUAPDF)) { - return kFALSE; + return false; } if (nua.fApplyNUAPDF[ePtNUAPDF] && !Accept(dPt, ePtNUAPDF)) { - return kFALSE; + return false; } if (nua.fApplyNUAPDF[eEtaNUAPDF] && !Accept(dEta, eEtaNUAPDF)) { - return kFALSE; + return false; } } // if constexpr (rs == eSim || rs == eSim_Run2 || rs == eSim_Run1) { } // if(nua.fApplyNUAPDF[ePhiNUAPDF] || nua.fApplyNUAPDF[ePtNUAPDF] || nua.fApplyNUAPDF[eEtaNUAPDF]) { - return kTRUE; + return true; -} // template Bool_t ParticleCuts(T const& track, eCutModus cutModus) +} // template bool ParticleCuts(T const& track, eCutModus cutModus) //============================================================ -Bool_t ParticleCut(Int_t rs, Int_t particleCut, eCutModus cutModus) +bool ParticleCut(int rs, int particleCut, eCutModus cutModus) { // Helper function to reduce code bloat in ParticleCuts(). It's meant to be used only in ParticleCuts(). // Remark: Remember that as a second argument I cannot use enum eParticleCuts, because here in one go I take both enum eParticleCuts and enum eParticleHistograms . switch (cutModus) { - case eCut: + case eCut: { if (tc.fVerboseForEachParticle) { LOGF(info, "\033[1;31mParticle didn't pass the cut: %s\033[0m", pc.fParticleCutName[particleCut].Data()); } - return kFALSE; + return false; break; - case eCutCounterBinning: + } + case eCutCounterBinning: { pc.fParticleCutCounterMap[rs]->Add(pc.fParticleCutCounterBinNumber[rs], particleCut); pc.fParticleCutCounterMapInverse[rs]->Add(particleCut, pc.fParticleCutCounterBinNumber[rs]); pc.fParticleCutCounterBinNumber[rs]++; // yes - return kTRUE; + return true; break; - case eCutCounterAbsolute: + } + case eCutCounterAbsolute: { pc.fParticleCutCounterHist[rs][eAbsolute]->Fill(pc.fParticleCutCounterMapInverse[rs]->GetValue(particleCut)); - return kTRUE; // yes, so that I can proceed with another cut in ParticleCuts + return true; // yes, so that I can proceed with another cut in ParticleCuts break; - case eCutCounterSequential: + } + case eCutCounterSequential: { pc.fParticleCutCounterHist[rs][eSequential]->Fill(pc.fParticleCutCounterMapInverse[rs]->GetValue(particleCut)); - return kFALSE; // yes, so that I bail out from ParticleCuts + return false; // yes, so that I bail out from ParticleCuts break; - default: + } + default: { LOGF(fatal, "\033[1;31m%s at line %d : This cutModus = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(cutModus)); break; + } } // switch(cutModus) - return kFALSE; // obsolete, but it suppresses the warning... + return false; // obsolete, but it suppresses the warning... -} // Bool_t ParticleCut(Int_t rs, Int_t particleCut, eCutModus cutModus) +} // bool ParticleCut(int rs, int particleCut, eCutModus cutModus) //============================================================ template -void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) +void FillParticleHistograms(T const& track, eBeforeAfter ba, int weight = 1) { // Fill all particle histograms for reconstructed and simulated data. @@ -7130,19 +11045,20 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) } if (tc.fInsanityCheckForEachParticle) { - if (1 != TMath::Abs(weight)) { + if (1 != std::abs(weight)) { LOGF(fatal, "\033[1;31m%s at line %d : in the current implementation, weight for particle histograms can be only +1 or -1, weight = %d\033[0m", __FUNCTION__, __LINE__, weight); } } // a) Fill reconstructed ... (common to Run 3, Run 2 and Run 1): - if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { + if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1 || rs == eQA) { // Remark: Remember to use only eRec and eSim as array indices in histos, also for rs == eRecAndSim, etc. TBI 20240504 shall I introduce generic enum egRec and egSim for this sake? // TBI 20240414 also here have to hardcode 'eRec', because 'rs' spans over all enums in eRecSim => I definitely need 'generic Rec' case, perhaps via TExMap ? // But I have already tc.fProcess[eGenericRec] and tc.fProcess[eGenericRecSim], available, shall I simply re-use them? // 1D: if (ph.fFillParticleHistograms) { + // From o2::aod::Tracks !ph.fParticleHistograms[ePhi][eRec][ba] ? true : ph.fParticleHistograms[ePhi][eRec][ba]->Fill(track.phi(), weight); !ph.fParticleHistograms[ePt][eRec][ba] ? true : ph.fParticleHistograms[ePt][eRec][ba]->Fill(track.pt(), weight); @@ -7152,6 +11068,7 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) // From o2::aod::TracksExtra_001 !ph.fParticleHistograms[etpcNClsFindable][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsFindable][eRec][ba]->Fill(track.tpcNClsFindable(), weight); !ph.fParticleHistograms[etpcNClsShared][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsShared][eRec][ba]->Fill(track.tpcNClsShared(), weight); + !ph.fParticleHistograms[eitsChi2NCl][eRec][ba] ? true : ph.fParticleHistograms[eitsChi2NCl][eRec][ba]->Fill(track.itsChi2NCl(), weight); !ph.fParticleHistograms[etpcNClsFound][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsFound][eRec][ba]->Fill(track.tpcNClsFound(), weight); !ph.fParticleHistograms[etpcNClsCrossedRows][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsCrossedRows][eRec][ba]->Fill(track.tpcNClsCrossedRows(), weight); !ph.fParticleHistograms[eitsNCls][eRec][ba] ? true : ph.fParticleHistograms[eitsNCls][eRec][ba]->Fill(track.itsNCls(), weight); @@ -7159,6 +11076,7 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) !ph.fParticleHistograms[etpcCrossedRowsOverFindableCls][eRec][ba] ? true : ph.fParticleHistograms[etpcCrossedRowsOverFindableCls][eRec][ba]->Fill(track.tpcCrossedRowsOverFindableCls(), weight); !ph.fParticleHistograms[etpcFoundOverFindableCls][eRec][ba] ? true : ph.fParticleHistograms[etpcFoundOverFindableCls][eRec][ba]->Fill(track.tpcFoundOverFindableCls(), weight); !ph.fParticleHistograms[etpcFractionSharedCls][eRec][ba] ? true : ph.fParticleHistograms[etpcFractionSharedCls][eRec][ba]->Fill(track.tpcFractionSharedCls(), weight); + !ph.fParticleHistograms[etpcChi2NCl][eRec][ba] ? true : ph.fParticleHistograms[etpcChi2NCl][eRec][ba]->Fill(track.tpcChi2NCl(), weight); // From o2::aod::TracksDCA // Remark: For this one, in Run 3 workflow I need helper task o2-analysis-track-propagation, while in Run 2 and 1 I need o2-analysis-trackextension . @@ -7172,11 +11090,33 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) !ph.fParticleHistograms2D[ePhiEta][eRec][ba] ? true : ph.fParticleHistograms2D[ePhiEta][eRec][ba]->Fill(track.phi(), track.eta(), weight); } // if (ph.fFillParticleHistograms2D) { + // nD (THnSparse): + if (ba == eAfter) { // yes, I feel sparse histograms only AFTER cuts for the time being + // **) eDWPhi : here the fundamental 0-th axis never to be projected out is "phi" + if (ph.fBookParticleSparseHistograms[eDWPhi]) { + // Remark: It is mandatory that ordering in initialization here resembles the ordering in enum eDiffPhiWeights + double vector[eDiffPhiWeights_N] = {track.phi(), track.pt(), track.eta(), static_cast(track.sign()), ebye.fCentrality, ebye.fVz}; + ph.fParticleSparseHistograms[eDWPhi][eRec]->Fill(vector, weight); + } + // **) eDWPt : here the fundamental 0-th axis never to be projected out is "pt" + if (ph.fBookParticleSparseHistograms[eDWPt]) { + // Remark: It is mandatory that ordering in initialization here resembles the ordering in enum eDiffPtWeights + double vector[eDiffPtWeights_N] = {track.pt(), static_cast(track.sign()), ebye.fCentrality}; + ph.fParticleSparseHistograms[eDWPt][eRec]->Fill(vector, weight); + } + // **) eDWEta : here the fundamental 0-th axis never to be projected out is "eta" + if (ph.fBookParticleSparseHistograms[eDWEta]) { + // Remark: It is mandatory that ordering in initialization here resembles the ordering in enum eDiffEtaWeights + double vector[eDiffEtaWeights_N] = {track.eta(), static_cast(track.sign()), ebye.fCentrality}; + ph.fParticleSparseHistograms[eDWEta][eRec]->Fill(vector, weight); + } + } // if (ba == eAfter) { + // QA: if (qa.fFillQAParticleHistograms2D) { !qa.fQAParticleHistograms2D[ePt_vs_dcaXY][eRec][ba] ? true : qa.fQAParticleHistograms2D[ePt_vs_dcaXY][eRec][ba]->Fill(track.pt(), track.dcaXY(), weight); } - if (qa.fFillQAParticleEventHistograms2D && qa.fQAParticleEventProEbyE[eRec][ba]) { + if ((qa.fFillQAParticleEventHistograms2D || qa.fFillQACorrelationsVsHistograms2D || qa.fFillQACorrelationsVsInteractionRateVsProfiles2D) && qa.fQAParticleEventProEbyE[eRec][ba]) { // Here I only fill the helper profile to get average of requested particle variable for current event: qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eitsNClsEbyE) - 0.5, track.itsNCls(), weight); @@ -7204,9 +11144,60 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(ePt1050EbyE) - 0.5, track.pt(), weight); } - // ... + // eMeanPhi: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeanPhi) - 0.5, track.phi(), weight); - } // if (qa.fFillQAParticleEventHistograms2D && qa.fQAParticleEventProEbyE[eRec][ba]) { + // eMeanPt: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeanPt) - 0.5, track.pt(), weight); + + // eMeanEta: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeanEta) - 0.5, track.eta(), weight); + + // eMeanCharge: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeanCharge) - 0.5, track.sign(), weight); + + // eMeantpcNClsFindable: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeantpcNClsFindable) - 0.5, track.tpcNClsFindable(), weight); + + // eMeantpcNClsShared: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeantpcNClsShared) - 0.5, track.tpcNClsShared(), weight); + + // eMeanitsChi2NCl: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeanitsChi2NCl) - 0.5, track.itsChi2NCl(), weight); + + // eMeantpcNClsFound: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeantpcNClsFound) - 0.5, track.tpcNClsFound(), weight); + + // eMeantpcNClsCrossedRow: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeantpcNClsCrossedRows) - 0.5, track.tpcNClsCrossedRows(), weight); + + // eMeanitsNCls: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeanitsNCls) - 0.5, track.itsNCls(), weight); + + // eMeanitsNClsInnerBarrel: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeanitsNClsInnerBarrel) - 0.5, track.itsNClsInnerBarrel(), weight); + + // eMeantpcCrossedRowsOverFindableCl: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeantpcCrossedRowsOverFindableCls) - 0.5, track.tpcCrossedRowsOverFindableCls(), weight); + + // eMeantpcFoundOverFindableCl: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeantpcFoundOverFindableCls) - 0.5, track.tpcFoundOverFindableCls(), weight); + + // eMeantpcFractionSharedCls: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeantpcFractionSharedCls) - 0.5, track.tpcFractionSharedCls(), weight); + + // eMeantpcChi2NCl: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeantpcChi2NCl) - 0.5, track.tpcChi2NCl(), weight); + + // eMeandcaXY: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeandcaXY) - 0.5, track.dcaXY(), weight); + + // eMeandcaZ: + qa.fQAParticleEventProEbyE[eRec][ba]->Fill(static_cast(eMeandcaZ) - 0.5, track.dcaZ(), weight); + + // ... + + } // if ... // ... and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1) // See https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/mcHistograms.cxx @@ -7217,23 +11208,74 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) LOGF(warning, " No MC particle for this track, skip..."); return; } - auto mcparticle = track.mcParticle(); // corresponding MC truth simulated particle + auto mcParticle = track.mcParticle(); // corresponding MC truth simulated particle // 1D: if (ph.fFillParticleHistograms) { - !ph.fParticleHistograms[ePhi][eSim][ba] ? true : ph.fParticleHistograms[ePhi][eSim][ba]->Fill(mcparticle.phi(), weight); - !ph.fParticleHistograms[ePt][eSim][ba] ? true : ph.fParticleHistograms[ePt][eSim][ba]->Fill(mcparticle.pt(), weight); - !ph.fParticleHistograms[eEta][eSim][ba] ? true : ph.fParticleHistograms[eEta][eSim][ba]->Fill(mcparticle.eta(), weight); - // !ph.fParticleHistograms[eCharge][eSim][ba] ? true : ph.fParticleHistograms[eCharge][eSim][ba]->Fill( ... ); // TBI 20240511 there is no mcparticle.sign()) - !ph.fParticleHistograms[ePDG][eSim][ba] ? true : ph.fParticleHistograms[ePDG][eSim][ba]->Fill(mcparticle.pdgCode(), weight); // TBI 20240512 this one gets filles correctly, deduce from it charge signature + !ph.fParticleHistograms[ePhi][eSim][ba] ? true : ph.fParticleHistograms[ePhi][eSim][ba]->Fill(mcParticle.phi(), weight); + !ph.fParticleHistograms[ePt][eSim][ba] ? true : ph.fParticleHistograms[ePt][eSim][ba]->Fill(mcParticle.pt(), weight); + !ph.fParticleHistograms[eEta][eSim][ba] ? true : ph.fParticleHistograms[eEta][eSim][ba]->Fill(mcParticle.eta(), weight); + + // special treatment for charge, because there is no getter mcParticle.sign() + double charge = -44.; // yes, never initialize charge to 0. + if (tc.fDatabasePDG && tc.fDatabasePDG->GetParticle(mcParticle.pdgCode())) { + // Yes, I have to check the 2nd condition, because e.g. for PDG code 1000010020 (deuteron), GetParticle(...) returns NULL + charge = tc.fDatabasePDG->GetParticle(mcParticle.pdgCode())->Charge() / 3.; // yes, divided by 3. Fundamental unit of charge is associated with quarks + } + !ph.fParticleHistograms[eCharge][eSim][ba] ? true : ph.fParticleHistograms[eCharge][eSim][ba]->Fill(charge); + !ph.fParticleHistograms[ePDG][eSim][ba] ? true : ph.fParticleHistograms[ePDG][eSim][ba]->Fill(mcParticle.pdgCode(), weight); } // 2D: if (ph.fFillParticleHistograms2D) { - !ph.fParticleHistograms2D[ePhiPt][eSim][ba] ? true : ph.fParticleHistograms2D[ePhiPt][eSim][ba]->Fill(mcparticle.phi(), mcparticle.pt(), weight); - !ph.fParticleHistograms2D[ePhiEta][eSim][ba] ? true : ph.fParticleHistograms2D[ePhiEta][eSim][ba]->Fill(mcparticle.phi(), mcparticle.eta(), weight); + !ph.fParticleHistograms2D[ePhiPt][eSim][ba] ? true : ph.fParticleHistograms2D[ePhiPt][eSim][ba]->Fill(mcParticle.phi(), mcParticle.pt(), weight); + !ph.fParticleHistograms2D[ePhiEta][eSim][ba] ? true : ph.fParticleHistograms2D[ePhiEta][eSim][ba]->Fill(mcParticle.phi(), mcParticle.eta(), weight); } // if(ph.fFillParticleHistograms2D) { + // nD (THnSparse): + if (ba == eAfter) { // yes, I feel sparse histograms only AFTER cuts for the time being + // **) eDWPhi : here the fundamental 0-th axis never to be projected out is "phi" + if (ph.fBookParticleSparseHistograms[eDWPhi]) { + // Remark: It is mandatory that ordering in initialization here resembles the ordering in enum eDiffPhiWeights + + // special treatment for charge, because there is no getter mcParticle.sign() + double charge = -44.; // yes, never initialize charge to 0. + if (tc.fDatabasePDG && tc.fDatabasePDG->GetParticle(mcParticle.pdgCode())) { + // Yes, I have to check the 2nd condition, because e.g. for PDG code 1000010020 (deuteron), GetParticle(...) returns NULL + charge = tc.fDatabasePDG->GetParticle(mcParticle.pdgCode())->Charge() / 3.; // yes, divided by 3. Fundamental unit of charge is associated with quarks + } + double vector[eDiffPhiWeights_N] = {mcParticle.phi(), mcParticle.pt(), mcParticle.eta(), charge, ebye.fCentralitySim, 0.}; + // TBI 20250611 I do nothing for vertex z, I could trivially extend ebye.fVz also for "sim" dimension => I set it to 0 temporarily here, until that's done. + ph.fParticleSparseHistograms[eDWPhi][eSim]->Fill(vector, weight); + } + // **) eDWPt : here the fundamental 0-th axis never to be projected out is "pt" + if (ph.fBookParticleSparseHistograms[eDWPt]) { + // Remark: It is mandatory that ordering in initialization here resembles the ordering in enum eDiffPtWeights + + // special treatment for charge, because there is no getter mcParticle.sign() + double charge = -44.; // yes, never initialize charge to 0. + if (tc.fDatabasePDG && tc.fDatabasePDG->GetParticle(mcParticle.pdgCode())) { + // Yes, I have to check the 2nd condition, because e.g. for PDG code 1000010020 (deuteron), GetParticle(...) returns NULL + charge = tc.fDatabasePDG->GetParticle(mcParticle.pdgCode())->Charge() / 3.; // yes, divided by 3. Fundamental unit of charge is associated with quarks + } + double vector[eDiffPtWeights_N] = {mcParticle.pt(), charge, ebye.fCentralitySim}; + ph.fParticleSparseHistograms[eDWPt][eSim]->Fill(vector, weight); + } + // **) eDWEta : here the fundamental 0-th axis never to be projected out is "eta" + if (ph.fBookParticleSparseHistograms[eDWEta]) { + // Remark: It is mandatory that ordering in initialization here resembles the ordering in enum eDiffEtaWeights + + // special treatment for charge, because there is no getter mcParticle.sign() + double charge = -44.; // yes, never initialize charge to 0. + if (tc.fDatabasePDG && tc.fDatabasePDG->GetParticle(mcParticle.pdgCode())) { + // Yes, I have to check the 2nd condition, because e.g. for PDG code 1000010020 (deuteron), GetParticle(...) returns NULL + charge = tc.fDatabasePDG->GetParticle(mcParticle.pdgCode())->Charge() / 3.; // yes, divided by 3. Fundamental unit of charge is associated with quarks + } + double vector[eDiffEtaWeights_N] = {mcParticle.eta(), charge, ebye.fCentralitySim}; + ph.fParticleSparseHistograms[eDWEta][eSim]->Fill(vector, weight); + } + } // if (ba == eAfter) { + } // if constexpr (rs == eRecAndSim || rs == eRecAndSim_Run2 || rs == eRecAndSim_Run1) { } // if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { @@ -7248,7 +11290,14 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) !ph.fParticleHistograms[ePhi][eSim][ba] ? true : ph.fParticleHistograms[ePhi][eSim][ba]->Fill(track.phi(), weight); !ph.fParticleHistograms[ePt][eSim][ba] ? true : ph.fParticleHistograms[ePt][eSim][ba]->Fill(track.pt(), weight); !ph.fParticleHistograms[eEta][eSim][ba] ? true : ph.fParticleHistograms[eEta][eSim][ba]->Fill(track.eta(), weight); - // !ph.fParticleHistograms[eCharge][eSim][ba] ? true : ph.fParticleHistograms[eCharge][eSim][ba]->Fill( ... ); // TBI 20240511 there is no mcparticle.sign()) + + // special treatment for charge, because there is no getter mcParticle.sign() + double charge = -44.; // yes, never initialize charge to 0. + if (tc.fDatabasePDG && tc.fDatabasePDG->GetParticle(track.pdgCode())) { + // Yes, I have to check the 2nd condition, because e.g. for PDG code 1000010020 (deuteron), GetParticle(...) returns NULL + charge = tc.fDatabasePDG->GetParticle(track.pdgCode())->Charge() / 3.; // yes, divided by 3. Fundamental unit of charge is associated with quarks + } + !ph.fParticleHistograms[eCharge][eSim][ba] ? true : ph.fParticleHistograms[eCharge][eSim][ba]->Fill(charge); !ph.fParticleHistograms[ePDG][eSim][ba] ? true : ph.fParticleHistograms[ePDG][eSim][ba]->Fill(track.pdgCode(), weight); } // if(ph.fFillParticleHistograms) { @@ -7262,7 +11311,7 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) // ----------------------------------------------------------------------------- // c) Fill reconstructed ... (Run 3 specific): - if constexpr (rs == eRec || rs == eRecAndSim) { + if constexpr (rs == eRec || rs == eRecAndSim || rs == eQA) { // TBI 20240511 check If I can use them for Run 2 and Run 1, but extending TracksRecSim_Run2 to Tracks_extra, etc. // Remark: Remember to use only eRec and eSim as array indices in histos, also for rs == eRecAndSim, etc. TBI 20240504 shall I introduce generic enum egRec and egSim for this sake? @@ -7276,7 +11325,7 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) return; } - // auto mcparticle = track.mcParticle(); // corresponding MC truth simulated particle + // auto mcParticle = track.mcParticle(); // corresponding MC truth simulated particle // ... @@ -7311,7 +11360,7 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) return; } - // auto mcparticle = track.mcParticle(); // corresponding MC truth simulated particle + // auto mcParticle = track.mcParticle(); // corresponding MC truth simulated particle // ... @@ -7356,8 +11405,7 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) void CalculateCorrelations() { // Calculate analytically multiparticle correlations from Q-vectors. - // In this method, only isotropic correlations for which all harmonics are the - // same are evaluated. + // In this method, only isotropic correlations for which all harmonics are the same are evaluated. // a) Flush 'n' fill the generic Q-vectors; // b) Calculate correlations; @@ -7369,15 +11417,15 @@ void CalculateCorrelations() // a) Flush 'n' fill the generic Q-vectors: ResetQ(); - for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { - for (Int_t wp = 0; wp < gMaxCorrelator + 1; wp++) // weight power + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) // weight power { qv.fQ[h][wp] = qv.fQvector[h][wp]; } } // b) Calculate correlations: - for (Int_t h = 1; h <= gMaxHarmonic; h++) // harmonic + for (int h = 1; h <= gMaxHarmonic; h++) // harmonic { // 2p: if (ebye.fSelectedTracks < 2) { @@ -7387,10 +11435,10 @@ void CalculateCorrelations() LOGF(info, " calculating 2-particle correlations ...."); } TComplex two = Two(h, -h); - Double_t twoC = two.Re(); // cos - // Double_t twoS = two.Im(); // sin - Double_t wTwo = Two(0, 0).Re(); // Weight is 'number of combinations' by default TBI - // 20220809 add support for other weights + double twoC = two.Re(); // cos + // double twoS = two.Im(); // sin + double wTwo = Two(0, 0).Re(); // Weight is 'number of combinations' by default TBI + // 20220809 add support for other weights if (wTwo > 0.0) { twoC /= wTwo; } else { @@ -7402,19 +11450,19 @@ void CalculateCorrelations() TArrayI* harmonics = new TArrayI(2); harmonics->SetAt(h, 0); harmonics->SetAt(-h, 1); - Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); - if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(twoC - nestedLoopValue) > tc.fFloatingPointPrecision) { + double nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); + if (std::abs(nestedLoopValue) > 0. && std::abs(twoC - nestedLoopValue) > tc.fFloatingPointPrecision) { LOGF(fatal, "\033[1;31m%s at line %d : nestedLoopValue = %f is not the same as twoC = %f\033[0m", __FUNCTION__, __LINE__, nestedLoopValue, twoC); } else { - LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for isotropic 2-p, harmonic %d\033[0m", h); + LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for isotropic 2-p, harmonic %d\033[0m", h); } delete harmonics; harmonics = NULL; } // if(nl.fCalculateCustomNestedLoops) // for on-the-fly and internal validation, rescale results with theoretical value: - if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && TMath::Abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1)) > 0.) { - twoC /= pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1), 2.); + if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && std::abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1)) > 0.) { + twoC /= std::pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1), 2.); } // integrated: @@ -7441,6 +11489,10 @@ void CalculateCorrelations() if (mupa.fCorrelationsPro[0][h - 1][AFO_CURRENTRUNDURATION]) { mupa.fCorrelationsPro[0][h - 1][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, twoC, wTwo); } + // vs. vertex z position: + if (mupa.fCorrelationsPro[0][h - 1][AFO_VZ]) { + mupa.fCorrelationsPro[0][h - 1][AFO_VZ]->Fill(ebye.fVz, twoC, wTwo); + } // 4p: if (ebye.fSelectedTracks < 4) { @@ -7450,9 +11502,9 @@ void CalculateCorrelations() LOGF(info, " calculating 4-particle correlations ...."); } TComplex four = Four(h, h, -h, -h); - Double_t fourC = four.Re(); // cos - // Double_t fourS = four.Im(); // sin - Double_t wFour = Four(0, 0, 0, 0).Re(); // Weight is 'number of combinations' by default TBI_20210515 add support for other weights + double fourC = four.Re(); // cos + // double fourS = four.Im(); // sin + double wFour = Four(0, 0, 0, 0).Re(); // Weight is 'number of combinations' by default TBI_20210515 add support for other weights if (wFour > 0.0) { fourC /= wFour; } else { @@ -7467,19 +11519,19 @@ void CalculateCorrelations() harmonics->SetAt(h, 1); harmonics->SetAt(-h, 2); harmonics->SetAt(-h, 3); - Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); - if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(fourC - nestedLoopValue) > tc.fFloatingPointPrecision) { + double nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); + if (std::abs(nestedLoopValue) > 0. && std::abs(fourC - nestedLoopValue) > tc.fFloatingPointPrecision) { LOGF(fatal, "\033[1;31m%s at line %d : nestedLoopValue = %f is not the same as fourC = %f\033[0m", __FUNCTION__, __LINE__, nestedLoopValue, fourC); } else { - LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for isotropic 4-p, harmonic %d\033[0m", h); + LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for isotropic 4-p, harmonic %d\033[0m", h); } delete harmonics; harmonics = NULL; } // if(nl.fCalculateCustomNestedLoops) // for on-the-fly and internal validation, rescale results with theoretical value: - if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && TMath::Abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1)) > 0.) { - fourC /= pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1), 4.); + if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && std::abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1)) > 0.) { + fourC /= std::pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1), 4.); } // integrated: @@ -7506,6 +11558,10 @@ void CalculateCorrelations() if (mupa.fCorrelationsPro[1][h - 1][AFO_CURRENTRUNDURATION]) { mupa.fCorrelationsPro[1][h - 1][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, fourC, wFour); } + // vs. vertex z position: + if (mupa.fCorrelationsPro[1][h - 1][AFO_VZ]) { + mupa.fCorrelationsPro[1][h - 1][AFO_VZ]->Fill(ebye.fVz, fourC, wFour); + } // 6p: if (ebye.fSelectedTracks < 6) { @@ -7515,9 +11571,9 @@ void CalculateCorrelations() LOGF(info, " calculating 6-particle correlations ...."); } TComplex six = Six(h, h, h, -h, -h, -h); - Double_t sixC = six.Re(); // cos - // Double_t sixS = six.Im(); // sin - Double_t wSix = Six(0, 0, 0, 0, 0, 0).Re(); // Weight is 'number of combinations' by default TBI_20210515 add support for other weights + double sixC = six.Re(); // cos + // double sixS = six.Im(); // sin + double wSix = Six(0, 0, 0, 0, 0, 0).Re(); // Weight is 'number of combinations' by default TBI_20210515 add support for other weights if (wSix > 0.0) { sixC /= wSix; } else { @@ -7534,19 +11590,19 @@ void CalculateCorrelations() harmonics->SetAt(-h, 3); harmonics->SetAt(-h, 4); harmonics->SetAt(-h, 5); - Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); - if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(sixC - nestedLoopValue) > tc.fFloatingPointPrecision) { + double nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); + if (std::abs(nestedLoopValue) > 0. && std::abs(sixC - nestedLoopValue) > tc.fFloatingPointPrecision) { LOGF(fatal, "\033[1;31m%s at line %d : nestedLoopValue = %f is not the same as sixC = %f\033[0m", __FUNCTION__, __LINE__, nestedLoopValue, sixC); } else { - LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for isotropic 6-p, harmonic %d\033[0m", h); + LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for isotropic 6-p, harmonic %d\033[0m", h); } delete harmonics; harmonics = NULL; } // if(nl.fCalculateCustomNestedLoops) // for on-the-fly and internal validation, rescale results with theoretical value: - if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && TMath::Abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1)) > 0.) { - sixC /= pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1), 6.); + if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && std::abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1)) > 0.) { + sixC /= std::pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1), 6.); } // integrated: @@ -7573,6 +11629,10 @@ void CalculateCorrelations() if (mupa.fCorrelationsPro[2][h - 1][AFO_CURRENTRUNDURATION]) { mupa.fCorrelationsPro[2][h - 1][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, sixC, wSix); } + // vs. vertex z position: + if (mupa.fCorrelationsPro[2][h - 1][AFO_VZ]) { + mupa.fCorrelationsPro[2][h - 1][AFO_VZ]->Fill(ebye.fVz, sixC, wSix); + } // 8p: if (ebye.fSelectedTracks < 8) { @@ -7582,9 +11642,9 @@ void CalculateCorrelations() LOGF(info, " calculating 8-particle correlations ...."); } TComplex eight = Eight(h, h, h, h, -h, -h, -h, -h); - Double_t eightC = eight.Re(); // cos - // Double_t eightS = eight.Im(); // sin - Double_t wEight = Eight(0, 0, 0, 0, 0, 0, 0, 0).Re(); // Weight is 'number of combinations' by default TBI_20210515 add support for other weights + double eightC = eight.Re(); // cos + // double eightS = eight.Im(); // sin + double wEight = Eight(0, 0, 0, 0, 0, 0, 0, 0).Re(); // Weight is 'number of combinations' by default TBI_20210515 add support for other weights if (wEight > 0.0) { eightC /= wEight; } else { @@ -7603,19 +11663,19 @@ void CalculateCorrelations() harmonics->SetAt(-h, 5); harmonics->SetAt(-h, 6); harmonics->SetAt(-h, 7); - Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); - if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(eightC - nestedLoopValue) > tc.fFloatingPointPrecision) { + double nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); + if (std::abs(nestedLoopValue) > 0. && std::abs(eightC - nestedLoopValue) > tc.fFloatingPointPrecision) { LOGF(fatal, "\033[1;31m%s at line %d : nestedLoopValue = %f is not the same as eightC = %f\033[0m", __FUNCTION__, __LINE__, nestedLoopValue, eightC); } else { - LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for isotropic 8-p, harmonic %d\033[0m", h); + LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for isotropic 8-p, harmonic %d\033[0m", h); } delete harmonics; harmonics = NULL; } // if(nl.fCalculateCustomNestedLoops) // for on-the-fly and internal validation, rescale results with theoretical value: - if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && TMath::Abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1)) > 0.) { - eightC /= pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1), 8.); + if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && std::abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1)) > 0.) { + eightC /= std::pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h - 1), 8.); } // integrated: @@ -7642,8 +11702,11 @@ void CalculateCorrelations() if (mupa.fCorrelationsPro[3][h - 1][AFO_CURRENTRUNDURATION]) { mupa.fCorrelationsPro[3][h - 1][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, eightC, wEight); } - - } // for(Int_t h=1;h<=gMaxHarmonic;h++) // harmonic + // vs. vertex z position: + if (mupa.fCorrelationsPro[3][h - 1][AFO_VZ]) { + mupa.fCorrelationsPro[3][h - 1][AFO_VZ]->Fill(ebye.fVz, eightC, wEight); + } + } // for(int h=1;h<=gMaxHarmonic;h++) // harmonic // c) Flush the generic Q-vectors: ResetQ(); @@ -7666,20 +11729,28 @@ void CalculateKineCorrelations(eAsFunctionOf AFO_variable) // *) ... eqvectorKine qvKine = eqvectorKine_N; // which eqvectorKine enum - // Int_t nBins = -1; // TBI 20241111 temporarily commented out just to suppress warnings + // int nBins = -1; // TBI 20241111 temporarily commented out just to suppress warnings switch (AFO_variable) { - case AFO_PT: + case AFO_PT: { qvKine = PTq; // nBins = res.fResultsPro[AFO_PT]->GetNbinsX(); // TBI 20241111 temporarily commented out just to suppress warnings break; - case AFO_ETA: + } + case AFO_ETA: { qvKine = ETAq; // nBins = res.fResultsPro[AFO_ETA]->GetNbinsX(); // TBI 20241111 temporarily commented out just to suppress warnings break; - default: + } + case AFO_CHARGE: { + qvKine = CHARGEq; + // nBins = res.fResultsPro[AFO_ETA]->GetNbinsX(); // TBI 20241111 temporarily commented out just to suppress warnings + break; + } + default: { LOGF(fatal, "\033[1;31m%s at line %d : This AFO_variable = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable)); break; + } } // switch(AFO_variable) // *) Insanity checks on above settings: @@ -7715,26 +11786,26 @@ void CalculateTest0() // a) Flush 'n' fill the generic Q-vectors: ResetQ(); - for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { - for (Int_t wp = 0; wp < gMaxCorrelator + 1; wp++) // weight power + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) // weight power { qv.fQ[h][wp] = qv.fQvector[h][wp]; } } // b) Calculate correlations: - Double_t correlation = 0.; // still has to be divided with 'weight' later, to get average correlation - Double_t weight = 0.; - Int_t n[gMaxCorrelator] = {0}; // array holding harmonics + double correlation = 0.; // still has to be divided with 'weight' later, to get average correlation + double weight = 0.; + int n[gMaxCorrelator] = {0}; // array holding harmonics - for (Int_t mo = 0; mo < gMaxCorrelator; mo++) { - for (Int_t mi = 0; mi < gMaxIndex; mi++) { + for (int mo = 0; mo < gMaxCorrelator; mo++) { + for (int mi = 0; mi < gMaxIndex; mi++) { // TBI 20210913 I do not have to loop each time all the way up to gMaxCorrelator and gMaxIndex, but nevermind now, it's not a big efficiency loss. // Sanitize the labels (If necessary. Locally this is irrelevant): if (!t0.fTest0Labels[mo][mi]) // I do not stream them. { - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { + for (int v = 0; v < eAsFunctionOf_N; v++) { if (t0.fTest0Pro[mo][mi][v]) { t0.fTest0Labels[mo][mi] = new TString(t0.fTest0Pro[mo][mi][v]->GetTitle()); // there is no memory leak here, since this is executed only once due to if(!fTest0Labels[mo][mi]) break; // yes, since for all v they are the same, so I just need to fetch it from one @@ -7744,7 +11815,7 @@ void CalculateTest0() if (t0.fTest0Labels[mo][mi]) { // Extract harmonics from TString, FS is " ": - for (Int_t h = 0; h <= mo; h++) { + for (int h = 0; h <= mo; h++) { TObjArray* oa = t0.fTest0Labels[mo][mi]->Tokenize(" "); if (!oa) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); @@ -7863,16 +11934,16 @@ void CalculateTest0() // e-b-e sanity check: if (nl.fCalculateCustomNestedLoops) { TArrayI* harmonics = new TArrayI(mo + 1); - for (Int_t i = 0; i < mo + 1; i++) { + for (int i = 0; i < mo + 1; i++) { harmonics->SetAt(n[i], i); } - Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); - if (!(TMath::Abs(nestedLoopValue) > 0.)) { + double nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); + if (!(std::abs(nestedLoopValue) > 0.)) { LOGF(info, " ebye check (integrated) with CustomNestedLoops was NOT calculated for %d-p Test0 corr. %s", mo + 1, t0.fTest0Labels[mo][mi]->Data()); - } else if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(correlation / weight - nestedLoopValue) > tc.fFloatingPointPrecision) { + } else if (std::abs(nestedLoopValue) > 0. && std::abs(correlation / weight - nestedLoopValue) > tc.fFloatingPointPrecision) { LOGF(fatal, "\033[1;31m%s at line %d : nestedLoopValue = %f is not the same as correlation/weight = %f, for correlator %s\033[0m", __FUNCTION__, __LINE__, nestedLoopValue, correlation / weight, t0.fTest0Labels[mo][mi]->Data()); } else { - LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for %d-p Test0 corr. %s\033[0m", mo + 1, t0.fTest0Labels[mo][mi]->Data()); + LOGF(info, "\033[1;32m ebye check (integrated) with CustomNestedLoops is OK for %d-p Test0 corr. %s\033[0m", mo + 1, t0.fTest0Labels[mo][mi]->Data()); } delete harmonics; harmonics = NULL; @@ -7881,11 +11952,11 @@ void CalculateTest0() // To ease comparison, rescale with theoretical value. Now all Test0 results shall be at 1. Remember that contribution from symmetry planes is here also relevant (in general): if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && iv.fInternalValidationVnPsin[ePsin]) { TArrayI* harmonics = new TArrayI(mo + 1); - for (Int_t i = 0; i < mo + 1; i++) { + for (int i = 0; i < mo + 1; i++) { harmonics->SetAt(n[i], i); } TComplex theoreticalValue = this->TheoreticalValue(harmonics, iv.fInternalValidationVnPsin[eVn], iv.fInternalValidationVnPsin[ePsin]); - if (TMath::Abs(theoreticalValue.Re()) > 0.) { + if (std::abs(theoreticalValue.Re()) > 0.) { correlation /= theoreticalValue.Re(); } // TBI 20240424 for the time being, I do not do anything with imaginary part, but I could eventually... @@ -7894,6 +11965,8 @@ void CalculateTest0() } // if(fUseInternalValidation && fRescaleWithTheoreticalInput) // Finally, fill: + + // 1D: // integrated: if (t0.fTest0Pro[mo][mi][AFO_INTEGRATED]) { t0.fTest0Pro[mo][mi][AFO_INTEGRATED]->Fill(0.5, correlation / weight, weight); @@ -7918,9 +11991,28 @@ void CalculateTest0() if (t0.fTest0Pro[mo][mi][AFO_CURRENTRUNDURATION]) { t0.fTest0Pro[mo][mi][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, correlation / weight, weight); } + // vs. vertex z position: + if (t0.fTest0Pro[mo][mi][AFO_VZ]) { + t0.fTest0Pro[mo][mi][AFO_VZ]->Fill(ebye.fVz, correlation / weight, weight); + } + + // ... + + // 2D: + // vs. centrality vs. vertex z position: + if (t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_VZ]) { + t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_VZ]->Fill(ebye.fCentrality, ebye.fVz, correlation / weight, weight); + } + + // ... + + // 3D: + + // ... + } // if(t0.fTest0Labels[mo][mi]) - } // for(Int_t mi=0;miGetNbinsX(); break; - case AFO_ETA: + } + case AFO_ETA: { qvKine = ETAq; nBins = res.fResultsPro[AFO_ETA]->GetNbinsX(); break; - default: + } + case AFO_CHARGE: { + qvKine = CHARGEq; + nBins = res.fResultsPro[AFO_CHARGE]->GetNbinsX(); + break; + } + default: { LOGF(fatal, "\033[1;31m%s at line %d : This AFO_variable = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable)); break; + } } // switch(AFO_variable) // *) Insanity checks on above settings: @@ -7964,11 +12068,11 @@ void CalculateKineTest0(eAsFunctionOf AFO_variable) LOGF(fatal, "\033[1;31m%s at line %d : qvKine == eqvectorKine_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); } - // *) Uniform loop over bin for all kine variables: - for (Int_t b = 0; b < nBins; b++) { + // *) Uniform loop over bins for all kine variables: + for (int b = 0; b < nBins; b++) { // *) Ensures that in each bin of interest, I have the same cut on number of particles, like in integrated analysis: - if ((qv.fqVectorEntries[qvKine][b] < ec.fdEventCuts[eMultiplicity][eMin]) || (qv.fqVectorEntries[qvKine][b] > ec.fdEventCuts[eMultiplicity][eMax] || TMath::Abs(qv.fqVectorEntries[qvKine][b] - ec.fdEventCuts[eMultiplicity][eMax]) < tc.fFloatingPointPrecision)) { + if ((qv.fqvectorEntries[qvKine][b] < ec.fdEventCuts[eMultiplicity][eMin]) || (qv.fqvectorEntries[qvKine][b] > ec.fdEventCuts[eMultiplicity][eMax] || std::abs(qv.fqvectorEntries[qvKine][b] - ec.fdEventCuts[eMultiplicity][eMax]) < tc.fFloatingPointPrecision)) { if (tc.fVerbose) { LOGF(info, "\033[1;31m%s eMultiplicity cut in bin = %d, for qvKine = %d\033[0m", __FUNCTION__, b, static_cast(qvKine)); } @@ -7976,23 +12080,23 @@ void CalculateKineTest0(eAsFunctionOf AFO_variable) // *) Re-initialize Q-vector to be q-vector in this bin: // After that, I can call all standard Q-vector functions again: - for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { - for (Int_t wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power - qv.fQ[h][wp] = qv.fqvector[qvKine][b][h][wp]; + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power + // qv.fQ[h][wp] = qv.fqvector[qvKine][b][h][wp]; TBI 20250616 I cannot use this any longer, after I added one more dimension to qv.fqvector } } // *) Okay, let's do the differential calculus: - Double_t correlation = 0.; - Double_t weight = 0.; - Int_t n[gMaxCorrelator] = {0}; // array holding harmonics + double correlation = 0.; + double weight = 0.; + int n[gMaxCorrelator] = {0}; // array holding harmonics - for (Int_t mo = 0; mo < gMaxCorrelator; mo++) { - for (Int_t mi = 0; mi < gMaxIndex; mi++) { + for (int mo = 0; mo < gMaxCorrelator; mo++) { + for (int mi = 0; mi < gMaxIndex; mi++) { // TBI 20240221 I do not have to loop each time all the way up to gMaxCorrelator and gMaxIndex, but nevermind now, it's not a big efficiency loss. if (t0.fTest0Labels[mo][mi]) { // Extract harmonics from TString, FS is " ": - for (Int_t h = 0; h <= mo; h++) { + for (int h = 0; h <= mo; h++) { // cout<SetAt(n[i], i); } if (!(weight > 0.)) { LOGF(fatal, "\033[1;31m%s at line %d : is perhaps order of some requested correlator bigger than the number of particles? Correlator = %s \033[0m", __FUNCTION__, __LINE__, t0.fTest0Labels[mo][mi]->Data()); } - Double_t nestedLoopValue = this->CalculateKineCustomNestedLoops(harmonics, AFO_variable, b); - if (!(TMath::Abs(nestedLoopValue) > 0.)) { + double nestedLoopValue = this->CalculateKineCustomNestedLoops(harmonics, AFO_variable, b); + if (!(std::abs(nestedLoopValue) > 0.)) { LOGF(info, " e-b-e check with CalculateKineCustomNestedLoops was NOT calculated for %d-p Test0 corr. %s, bin = %d", mo + 1, t0.fTest0Labels[mo][mi]->Data(), b + 1); - } else if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(correlation / weight - nestedLoopValue) > tc.fFloatingPointPrecision) { + } else if (std::abs(nestedLoopValue) > 0. && std::abs(correlation / weight - nestedLoopValue) > tc.fFloatingPointPrecision) { LOGF(fatal, "\033[1;31m%s at line %d : correlator: %s \n correlation: %f \n custom loop: %f \033[0m", __FUNCTION__, __LINE__, t0.fTest0Labels[mo][mi]->Data(), correlation / weight, nestedLoopValue); } else { LOGF(info, "\033[1;32m ebye check (differential) with CalculateKineCustomNestedLoops is OK for %d-p Test0 corr. %s, bin = %d\033[0m", mo + 1, t0.fTest0Labels[mo][mi]->Data(), b + 1); @@ -8096,11 +12200,11 @@ void CalculateKineTest0(eAsFunctionOf AFO_variable) // To ease comparison, rescale with theoretical value. Now all Test0 results shall be at 1: if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && iv.fInternalValidationVnPsin[ePsin]) { TArrayI* harmonics = new TArrayI(mo + 1); - for (Int_t i = 0; i < mo + 1; i++) { + for (int i = 0; i < mo + 1; i++) { harmonics->SetAt(n[i], i); } TComplex theoreticalValue = TheoreticalValue(harmonics, iv.fInternalValidationVnPsin[eVn], iv.fInternalValidationVnPsin[ePsin]); - if (TMath::Abs(theoreticalValue.Re()) > 0.) { + if (std::abs(theoreticalValue.Re()) > 0.) { correlation /= theoreticalValue.Re(); } // TBI 20240424 for the time being, I do not do anything with imaginary part, but I could eventually... @@ -8120,20 +12224,44 @@ void CalculateKineTest0(eAsFunctionOf AFO_variable) LOGF(info, "\n\033[1;33m t0.fTest0Pro[mo][mi][AFO_variable]->GetTitle() = %s \033[0m\n", t0.fTest0Pro[mo][mi][AFO_variable]->GetTitle()); LOGF(info, "\n\033[1;33m [mo][mi][AFO_variable] = [%d][%d][%d] \033[0m\n", mo, mi, static_cast(AFO_variable)); LOGF(info, "\n\033[1;33m ebye.fSelectedTracks = %d \033[0m\n", ebye.fSelectedTracks); - LOGF(info, "\n\033[1;33m qv.fqVectorEntries[qvKine][b] = %d \033[0m\n", qv.fqVectorEntries[qvKine][b]); + LOGF(info, "\n\033[1;33m qv.fqvectorEntries[qvKine][b] = %d \033[0m\n", qv.fqvectorEntries[qvKine][b]); LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } // Finally, fill: + + // 1D: if (t0.fTest0Pro[mo][mi][AFO_variable]) { t0.fTest0Pro[mo][mi][AFO_variable]->Fill(t0.fTest0Pro[mo][mi][AFO_variable]->GetXaxis()->GetBinCenter(b + 1), correlation / weight, weight); } // fill in the bin center + // 2D: + if (t0.fCalculate2DTest0) { + + // vs. centrality vs. pt: + if (t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_PT] && AFO_variable == AFO_PT) { + t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_PT]->Fill(ebye.fCentrality, t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_PT]->GetYaxis()->GetBinCenter(b + 1), correlation / weight, weight); + } + + // vs. centrality vs. eta: + if (t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_ETA] && AFO_variable == AFO_ETA) { + t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_ETA]->Fill(ebye.fCentrality, t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_ETA]->GetYaxis()->GetBinCenter(b + 1), correlation / weight, weight); + } + + // vs. centrality vs. charge: + if (t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_CHARGE] && AFO_variable == AFO_CHARGE) { + t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_CHARGE]->Fill(ebye.fCentrality, t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_CHARGE]->GetYaxis()->GetBinCenter(b + 1), correlation / weight, weight); + } + + // ... + + } // if(t0.fCalculate2DTest0) + } // if(fTest0Labels[mo][mi]) - } // for(Int_t mi=0;mi(kineVarChoice), StringKineMap(kineVarChoice).Data(), Ndim); } - // Calculate 2-p correlations with eta separations from Qa (-eta, index [0]) and Qb (+eta, index [1]) vectors: - Double_t correlation = 0.; - Double_t weight = 0.; - for (Int_t h = 0; h < gMaxHarmonic; h++) { - if (es.fEtaSeparationsSkipHarmonics[h]) { - continue; - } - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { - if (!(qv.fQabVector[0][h][e].Rho() > 0. && qv.fQabVector[1][h][e].Rho() > 0.)) { - continue; - } - if (!(qv.fMab[0][e] > 0. && qv.fMab[1][e] > 0.)) { - continue; - } - - // calculate correlation and weights with particular eta separation: - correlation = TComplex(qv.fQabVector[0][h][e] * TComplex::Conjugate(qv.fQabVector[1][h][e])).Re(); - weight = qv.fMab[0][e] * qv.fMab[1][e]; - - // for on-the-fly and internal validation, rescale results with theoretical value: - if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && TMath::Abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h)) > 0.) { - correlation /= pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h), 2.); - } + int nBins = -1; - // integrated: - if (es.fEtaSeparationsPro[h][e][AFO_INTEGRATED]) { - es.fEtaSeparationsPro[h][e][AFO_INTEGRATED]->Fill(0.5, correlation / weight, weight); - } + switch (Ndim) { - // vs. multiplicity: - if (es.fEtaSeparationsPro[h][e][AFO_MULTIPLICITY]) { - es.fEtaSeparationsPro[h][e][AFO_MULTIPLICITY]->Fill(ebye.fMultiplicity + 0.5, correlation / weight, weight); + case 1: { + eAsFunctionOf AFO_var = AfoKineMap1D(kineVarChoice); + if (res.fResultsPro[AFO_var]) { + nBins = res.fResultsPro[AFO_var]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it in the loop below. + if (tc.fVerbose) { + LOGF(info, "\033[1;31m%s nBins = %d, kineVarChoice = %d (%s), Ndim = %d \033[0m", __FUNCTION__, nBins, static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), Ndim); + } } - // vs. centrality: - if (es.fEtaSeparationsPro[h][e][AFO_CENTRALITY]) { - es.fEtaSeparationsPro[h][e][AFO_CENTRALITY]->Fill(ebye.fCentrality, correlation / weight, weight); - } + break; + } - // vs. occupancy: - if (es.fEtaSeparationsPro[h][e][AFO_OCCUPANCY]) { - es.fEtaSeparationsPro[h][e][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, correlation / weight, weight); + case 2: { + eAsFunctionOf2D AFO_var = AfoKineMap2D(kineVarChoice); + if (res.fResultsPro2D[AFO_var]) { + nBins = (res.fResultsPro2D[AFO_var]->GetNbinsX() + 2) * (res.fResultsPro2D[AFO_var]->GetNbinsY() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + if (tc.fVerbose) { + LOGF(info, "\033[1;31m%s nBins = %d, kineVarChoice = %d (%s), Ndim = %d \033[0m", __FUNCTION__, nBins, static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), Ndim); + } } - // vs. interaction rate: - if (es.fEtaSeparationsPro[h][e][AFO_INTERACTIONRATE]) { - es.fEtaSeparationsPro[h][e][AFO_INTERACTIONRATE]->Fill(ebye.fInteractionRate, correlation / weight, weight); - } + break; + } - // vs. current run duration: - if (es.fEtaSeparationsPro[h][e][AFO_CURRENTRUNDURATION]) { - es.fEtaSeparationsPro[h][e][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, correlation / weight, weight); + case 3: { + eAsFunctionOf3D AFO_var = AfoKineMap3D(kineVarChoice); + if (res.fResultsPro3D[AFO_var]) { + nBins = (res.fResultsPro3D[AFO_var]->GetNbinsX() + 2) * (res.fResultsPro3D[AFO_var]->GetNbinsY() + 2) * (res.fResultsPro3D[AFO_var]->GetNbinsZ() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + if (tc.fVerbose) { + LOGF(info, "\033[1;31m%s nBins = %d, kineVarChoice = %d (%s), Ndim = %d \033[0m", __FUNCTION__, nBins, static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), Ndim); + } } + break; + } - } // for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { - } // for (Int_t h = 0; h < gMaxHarmonic; h++) { + // ... - if (tc.fVerbose) { - ExitFunction(__FUNCTION__); - } + default: { + LOGF(fatal, "\033[1;31m%s at line %d : Ndim = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, Ndim); + break; + } -} // void CalculateEtaSeparations() + } // switch (Ndim) -//============================================================ + // *) Uniform loop over linearized global bins for all kine variables: + for (int b = 0; b < nBins; b++) { // yes, "< nBins", not "<= nBins", because b runs over all regular bins + 2 (therefore, including underflow and overflow already) -void CalculateKineEtaSeparations(eAsFunctionOf AFO_variable) -{ - // Calculate differential correlations with pseudorapidity separations. + if (tc.fVerbose) { // TBI 20250701 temporary check, remove eventually + LOGF(info, "\033[1;31m%s b = %d \033[0m", __FUNCTION__, b); + Trace(__FUNCTION__, __LINE__); + } - if (tc.fVerbose) { - StartFunction(__FUNCTION__); - } + // *) Check if this bin is overflow or underflow: + // Well, I already checked that when filling fqvector, if this global bin is overflow or underflow, qvector and number of entries shall be empty for that bin, so I am checking for that: + if (0 == qv.fqvectorEntries[kineVarChoice][b]) { + if (tc.fVerbose) { + LOGF(info, "\033[1;31m%s no entries in bin = %d, for kineVarChoice = %d (%s). Just skipping this bin (this is most likely underflow or overflow global bin)\033[0m", __FUNCTION__, b, static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data()); + } + continue; + } - // *) ... - eqvectorKine qvKine = eqvectorKine_N; // which eqvectorKine enum - Int_t nBins = -1; + // *) Ensures that in each bin of interest, I have the same cut on number of particles, like in integrated analysis: + /* TBI 20250603 not sure any longer if I can use this code: + // 1. if i do not use it, I allow possibility that correlations are calculated even when that makes no sense (two few particles for that correlators) + // 2. if I use it, I will not be able to get exactly the same result after rebinning (or ironing out some dimensions) as in integrated analysis + // => re-think + if ((qv.fqvectorEntries[kineVarChoice][b] < ec.fdEventCuts[eMultiplicity][eMin]) || (qv.fqvectorEntries[kineVarChoice][b] > ec.fdEventCuts[eMultiplicity][eMax] || std::abs(qv.fqvectorEntries[kineVarChoice][b] - ec.fdEventCuts[eMultiplicity][eMax]) < tc.fFloatingPointPrecision)) { + if (tc.fVerbose) { + LOGF(info, "\033[1;31m%s eMultiplicity cut in global bin = %d, for kineVarChoice = %d (%s), there are only %d selected particles in this bin\033[0m", __FUNCTION__, b, static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), qv.fqvectorEntries[kineVarChoice][b]); + } + } + */ - switch (AFO_variable) { - case AFO_PT: - qvKine = PTq; - nBins = res.fResultsPro[AFO_PT]->GetNbinsX(); - break; - case AFO_ETA: - LOGF(fatal, "\033[1;31m%s at line %d : It doesn't make sense (i.e. AFO_ETA cannot be used here). \033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable)); - break; // obsolete, but it supresses the warning - default: - LOGF(fatal, "\033[1;31m%s at line %d : This AFO_variable = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable)); - break; - } // switch(AFO_variable) + // *) Re-initialize Q-vector to be q-vector in this bin: + // After that, I can call all standard Q-vector functions again: + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) { + qv.fQ[h][wp] = TComplex(qv.fqvector[kineVarChoice][b][h][wp].real(), qv.fqvector[kineVarChoice][b][h][wp].imag()); // TBI 20250601 check if there is a simpler way to initialize ROOT TComplex with C++ type 'complex' + } + } - // *) Insanity checks on above settings: - if (qvKine == eqvectorKine_N) { - LOGF(fatal, "\033[1;31m%s at line %d : qvKine == eqvectorKine_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); - } + if (tc.fVerbose) { // TBI 20250701 temporary check, remove eventually + Trace(__FUNCTION__, __LINE__); + } - // *) Uniform loop over bin for all kine variables: - for (Int_t b = 0; b < nBins; b++) { + // *) Okay, let's do transparently the differential calculus, whether it's 1D, 2D, 3D, ...: + double correlation = 0.; + double weight = 0.; + int n[gMaxCorrelator] = {0}; // array holding harmonics - /* TBI 20241206 Do I need to adapt and apply this cut, also for Qa and Qb? If so, most likely I would need to apply it on sum, i.e. on entries in Qa + Qb + for (int mo = 0; mo < gMaxCorrelator; mo++) { + for (int mi = 0; mi < gMaxIndex; mi++) { + // TBI 20240221 I do not have to loop each time all the way up to gMaxCorrelator and gMaxIndex, but nevermind now, it's not a big efficiency loss. + if (t0.fTest0Labels[mo][mi]) { + // Extract harmonics from TString, FS is " ": + for (int h = 0; h <= mo; h++) { + // cout<At(h)->GetName()).Atoi(); + delete oa; // yes, otherwise it's a memory leak + } - // *) Ensures that in each bin of interest, I have the same cut on number of particles, like in integrated analysis: - if ((qv.fqVectorEntries[qvKine][b] < ec.fdEventCuts[eMultiplicity][eMin]) || (qv.fqVectorEntries[qvKine][b] > ec.fdEventCuts[eMultiplicity][eMax] || TMath::Abs(qv.fqVectorEntries[qvKine][b] - ec.fdEventCuts[eMultiplicity][eMax]) < tc.fFloatingPointPrecision)) { - if (tc.fVerbose) { - LOGF(info, "\033[1;31m%s eMultiplicity cut in bin = %d, for qvKine = %d\033[0m", __FUNCTION__, b, static_cast(qvKine)); + if (qv.fqvectorEntries[kineVarChoice][b] < mo + 1) { + continue; } - } - */ - // Calculate differential 2-p correlations with eta separations from Qa (-eta, index [0]) and Qb (+eta, index [1]) vectors: - Double_t correlation = 0.; - Double_t weight = 0.; - for (Int_t h = 0; h < gMaxHarmonic; h++) { - if (es.fEtaSeparationsSkipHarmonics[h]) { - continue; - } + switch (mo + 1) // which order? yes, mo+1 + { + case 1: + correlation = One(n[0]).Re(); + weight = One(0).Re(); + break; - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { - if (!(qv.fqabVector[0][b][h][e].Rho() > 0. && qv.fqabVector[1][b][h][e].Rho() > 0.)) { - continue; - } - if (!(qv.fmab[0][b][e] > 0. && qv.fmab[1][b][e] > 0.)) { - continue; - } + case 2: + correlation = Two(n[0], n[1]).Re(); + weight = Two(0, 0).Re(); + break; - // calculate correlation and weights with particular eta separation: - correlation = TComplex(qv.fqabVector[0][b][h][e] * TComplex::Conjugate(qv.fqabVector[1][b][h][e])).Re(); - weight = qv.fmab[0][b][e] * qv.fmab[1][b][e]; + case 3: + correlation = Three(n[0], n[1], n[2]).Re(); + weight = Three(0, 0, 0).Re(); + break; - // for on-the-fly and internal validation, rescale results with theoretical value: - if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && TMath::Abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h)) > 0.) { - correlation /= pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h), 2.); - } + case 4: + correlation = Four(n[0], n[1], n[2], n[3]).Re(); + weight = Four(0, 0, 0, 0).Re(); + break; - // finally, fill: - if (es.fEtaSeparationsPro[h][e][AFO_variable]) { - es.fEtaSeparationsPro[h][e][AFO_variable]->Fill(es.fEtaSeparationsPro[h][e][AFO_variable]->GetXaxis()->GetBinCenter(b + 1), correlation / weight, weight); - } - } - } - } // for (Int_t b = 0; b < nBins; b++) { + case 5: + correlation = Five(n[0], n[1], n[2], n[3], n[4]).Re(); + weight = Five(0, 0, 0, 0, 0).Re(); + break; - if (tc.fVerbose) { - ExitFunction(__FUNCTION__); - } + case 6: + correlation = Six(n[0], n[1], n[2], n[3], n[4], n[5]).Re(); + weight = Six(0, 0, 0, 0, 0, 0).Re(); + break; -} // void CalculateKineEtaSeparations() + case 7: + correlation = Seven(n[0], n[1], n[2], n[3], n[4], n[5], n[6]).Re(); + weight = Seven(0, 0, 0, 0, 0, 0, 0).Re(); + break; -//============================================================ + case 8: + correlation = Eight(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7]).Re(); + weight = Eight(0, 0, 0, 0, 0, 0, 0, 0).Re(); + break; -void FillNestedLoopsContainers(const Int_t& particleIndex, const Double_t& dPhi, const Double_t& dPt, const Double_t& dEta) -{ - // Fill into the nested loop containers the current particle. + case 9: + correlation = Nine(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8]).Re(); + weight = Nine(0, 0, 0, 0, 0, 0, 0, 0, 0).Re(); + break; - if (tc.fVerbose) { - StartFunction(__FUNCTION__); - } + case 10: + correlation = Ten(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8], n[9]).Re(); + weight = Ten(0, 0, 0, 0, 0, 0, 0, 0, 0, 0).Re(); + break; - if (tc.fInsanityCheckForEachParticle) { - if (particleIndex < 0) { - LOGF(fatal, "\033[1;31m%s at line %d : particleIndex = %d\033[0m", __FUNCTION__, __LINE__, particleIndex); - } - if (!(TMath::Abs(nl.ftaNestedLoops[0]->GetAt(particleIndex - 1)) > 0.)) { - LOGF(fatal, "\033[1;31m%s at line %d : there are empty elements in nl.ftaNestedLoops[0] \033[0m", __FUNCTION__, __LINE__); - // I need this protection, to ensure that all array entries are filled. If not, most likely a particle passed all - // selection criteria, and it wasn't added to the nested loops containers - } - } + case 11: + correlation = Eleven(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8], n[9], n[10]).Re(); + weight = Eleven(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).Re(); + break; - // *) Fill container for angles: - if (nl.ftaNestedLoops[0]) { - nl.ftaNestedLoops[0]->AddAt(dPhi, particleIndex); // remember that the 2nd argument here must start from 0 + case 12: + correlation = Twelve(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8], n[9], n[10], n[11]).Re(); + weight = Twelve(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).Re(); + break; + + default: + LOGF(fatal, "\033[1;31m%s at line %d : not supported yet: %s \n\n\033[0m", __FUNCTION__, __LINE__, t0.fTest0Labels[mo][mi]->Data()); + } // switch(mo+1) + + // *) e-b-e sanity check: + if (nl.fCalculateKineCustomNestedLoops) { + TArrayI* harmonics = new TArrayI(mo + 1); + for (int i = 0; i < mo + 1; i++) { + harmonics->SetAt(n[i], i); + } + if (!(weight > 0.)) { + LOGF(fatal, "\033[1;31m%s at line %d : is perhaps order of some requested correlator bigger than the number of particles? Correlator = %s \033[0m", __FUNCTION__, __LINE__, t0.fTest0Labels[mo][mi]->Data()); + } + double nestedLoopValue = this->CalculateKineCustomNestedLoops(harmonics, kineVarChoice, b); + PrintBinEdgesKine(kineVarChoice, b); + if (!(std::abs(nestedLoopValue) > 0.)) { + LOGF(info, " e-b-e check with CalculateKineCustomNestedLoops was NOT calculated for %d-p Test0 corr. %s, kineVarChoice (eqvectorKine) = %d (%s), bin = %d", mo + 1, t0.fTest0Labels[mo][mi]->Data(), static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), b); + } else if (std::abs(nestedLoopValue) > 0. && std::abs(correlation / weight - nestedLoopValue) > tc.fFloatingPointPrecision) { + LOGF(fatal, "\033[1;31m%s at line %d : correlator: %s \n correlation: %f \n custom loop: %f \033[0m", __FUNCTION__, __LINE__, t0.fTest0Labels[mo][mi]->Data(), correlation / weight, nestedLoopValue); + } else { + LOGF(info, "\033[1;32m ebye check (differential) with CalculateKineCustomNestedLoops is OK for %d-p Test0 corr. %s, kineVarChoice (eqvectorKine) = %d (%s), bin = %d, nParticles in this bin = %d\033[0m", mo + 1, t0.fTest0Labels[mo][mi]->Data(), static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), b, qv.fqvectorEntries[kineVarChoice][b]); + } + delete harmonics; + harmonics = NULL; + } // if(nl.fCalculateKineCustomNestedLoops) + + if (tc.fVerbose) { // TBI 20250701 temporary check, remove eventually + Trace(__FUNCTION__, __LINE__); + } + + // To ease comparison, rescale with theoretical value. Now all Test0 results shall be at 1: + if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && iv.fInternalValidationVnPsin[ePsin]) { + TArrayI* harmonics = new TArrayI(mo + 1); + for (int i = 0; i < mo + 1; i++) { + harmonics->SetAt(n[i], i); + } + TComplex theoreticalValue = TheoreticalValue(harmonics, iv.fInternalValidationVnPsin[eVn], iv.fInternalValidationVnPsin[ePsin]); + if (std::abs(theoreticalValue.Re()) > 0.) { + correlation /= theoreticalValue.Re(); + } + // TBI 20240424 for the time being, I do not do anything with imaginary part, but I could eventually... + delete harmonics; + harmonics = NULL; + } // if(fUseInternalValidation && fRescaleWithTheoreticalInput) + + if (tc.fVerbose) { // TBI 20250701 temporary check, remove eventually + Trace(__FUNCTION__, __LINE__); + } + + // Insanity check for the event weight: + if (!(weight > 0.)) { + // If it's negative, that means that sum of particle weights is smaller than "number of particles - 1" + // In that case, you can simply rescale all particle weights, so that each of them is > 1, basically recalculate weights.root files with such a rescaling. + LOGF(info, "\n\033[1;33m b = %d \033[0m\n", b); + LOGF(info, "\n\033[1;33m kineVarChoice = %d \033[0m\n", static_cast(kineVarChoice)); + LOGF(info, "\n\033[1;33m event weight = %e \033[0m\n", weight); + LOGF(info, "\n\033[1;33m sum of particle weights = %e \033[0m\n", One(0).Re()); + LOGF(info, "\n\033[1;33m correlation = %f \033[0m\n", correlation); + + switch (Ndim) { + + case 1: { + eAsFunctionOf AFO_var = AfoKineMap1D(kineVarChoice); + LOGF(info, "\n\033[1;33m t0.fTest0Pro[mo][mi][AFO_variable]->GetTitle() = %s \033[0m\n", t0.fTest0Pro[mo][mi][AFO_var]->GetTitle()); + LOGF(info, "\n\033[1;33m [mo][mi][AFO_variable] = [%d][%d][%d] \033[0m\n", mo, mi, static_cast(AFO_var)); + break; + } + + case 2: { + eAsFunctionOf2D AFO_var = AfoKineMap2D(kineVarChoice); + LOGF(info, "\n\033[1;33m t0.fTest0Pro2D[mo][mi][AFO_variable]->GetTitle() = %s \033[0m\n", t0.fTest0Pro2D[mo][mi][AFO_var]->GetTitle()); + LOGF(info, "\n\033[1;33m [mo][mi][AFO_variable] = [%d][%d][%d] \033[0m\n", mo, mi, static_cast(AFO_var)); + break; + } + + case 3: { + eAsFunctionOf3D AFO_var = AfoKineMap3D(kineVarChoice); + LOGF(info, "\n\033[1;33m t0.fTest0Pro3D[mo][mi][AFO_variable]->GetTitle() = %s \033[0m\n", t0.fTest0Pro3D[mo][mi][AFO_var]->GetTitle()); + LOGF(info, "\n\033[1;33m [mo][mi][AFO_variable] = [%d][%d][%d] \033[0m\n", mo, mi, static_cast(AFO_var)); + break; + } + + // ... + + default: { + LOGF(fatal, "\033[1;31m%s at line %d : Ndim = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, Ndim); + break; + } + + } // switch (Ndim) + + LOGF(info, "\n\033[1;33m ebye.fSelectedTracks = %d \033[0m\n", ebye.fSelectedTracks); + LOGF(info, "\n\033[1;33m qv.fqvectorEntries[kineVarChoice][b] = %d \033[0m\n", qv.fqvectorEntries[kineVarChoice][b]); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + // Finally, fill: + switch (Ndim) { + + case 1: { + + // *) cases for which 1D vs. pt calculus is needed: + if (kineVarChoice == PTq) { + // **) vs. pt: + if (t0.fTest0Pro[mo][mi][AFO_PT]) { + t0.fTest0Pro[mo][mi][AFO_PT]->Fill(t0.fTest0Pro[mo][mi][AFO_PT]->GetXaxis()->GetBinCenter(b), correlation / weight, weight); // only for 1D kine case, I can use direcly b, because "linearized global bin" is the same as ordinary bin + } + // **) vs. centrality vs. pt: + if (t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_PT]) { + t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_PT]->Fill(ebye.fCentrality, t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_PT]->GetYaxis()->GetBinCenter(b), correlation / weight, weight); // only for 1D kine case, I can use direcly b, because "linearized global bin" is the same as ordinary bin + } + // **) vs. centrality vs. pt vs. vz: + if (t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_VZ]) { + t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_VZ]->Fill(ebye.fCentrality, t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_VZ]->GetYaxis()->GetBinCenter(b), ebye.fVz, correlation / weight, weight); // only for 1D kine case, I can use direcly b, because "linearized global bin" is the same as ordinary bin + } + + // ... + + } // if (kineVarChoice == PTq) { + + // *) cases for which 1D vs. eta calculus is needed: + if (kineVarChoice == ETAq) { + // **) vs. eta: + if (t0.fTest0Pro[mo][mi][AFO_ETA]) { + t0.fTest0Pro[mo][mi][AFO_ETA]->Fill(t0.fTest0Pro[mo][mi][AFO_ETA]->GetXaxis()->GetBinCenter(b), correlation / weight, weight); // only for 1D kine case, I can use direcly b, because "linearized global bin" is the same as ordinary bin + } + // **) vs. centrality vs. eta: + if (t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_ETA]) { + t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_ETA]->Fill(ebye.fCentrality, t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_ETA]->GetYaxis()->GetBinCenter(b), correlation / weight, weight); // only for 1D kine case, I can use direcly b, because "linearized global bin" is the same as ordinary bin + } + // **) vs. centrality vs. eta vs. vz: + if (t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_ETA_VZ]) { + t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_ETA_VZ]->Fill(ebye.fCentrality, t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_ETA_VZ]->GetYaxis()->GetBinCenter(b), ebye.fVz, correlation / weight, weight); // only for 1D kine case, I can use direcly b, because "linearized global bin" is the same as ordinary bin + } + + // ... + + } // if (kineVarChoice == ETAq) { + + // *) cases for which 1D vs. charge calculus is needed: + if (kineVarChoice == CHARGEq) { + // **) vs. charge: + if (t0.fTest0Pro[mo][mi][AFO_CHARGE]) { + t0.fTest0Pro[mo][mi][AFO_CHARGE]->Fill(t0.fTest0Pro[mo][mi][AFO_CHARGE]->GetXaxis()->GetBinCenter(b), correlation / weight, weight); // only for 1D kine case, I can use direcly b, because "linearized global bin" is the same as ordinary bin + } + // **) vs. centrality vs. charge: + if (t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_CHARGE]) { + t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_CHARGE]->Fill(ebye.fCentrality, t0.fTest0Pro2D[mo][mi][AFO_CENTRALITY_CHARGE]->GetYaxis()->GetBinCenter(b), correlation / weight, weight); // only for 1D kine case, I can use direcly b, because "linearized global bin" is the same as ordinary bin + } + + // **) vs. centrality vs. vz vs. charge: + if (t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_VZ_CHARGE]) { + t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_VZ_CHARGE]->Fill(ebye.fCentrality, ebye.fVz, t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_VZ_CHARGE]->GetZaxis()->GetBinCenter(b), correlation / weight, weight); // only for 1D kine case, I can use direcly b, because "linearized global bin" is the same as ordinary bin + } + + // ... + + } // if (kineVarChoice == CHARGEq) { + + // ... + + break; + } + + case 2: { + + // *) cases for which 2D vs. (pt,eta) calculus is needed: + if (kineVarChoice == PT_ETAq) { + + // transfer global bin b into (binX, binY, binZ): + int binX = -1; + int binY = -1; + int binZ = -1; // dummy for 2D case + t0.fTest0Pro2D[mo][mi][AFO_PT_ETA]->GetBinXYZ(b, binX, binY, binZ); + + // **) vs. pt vs. eta: + if (t0.fTest0Pro2D[mo][mi][AFO_PT_ETA]) { + t0.fTest0Pro2D[mo][mi][AFO_PT_ETA]->Fill(t0.fTest0Pro2D[mo][mi][AFO_PT_ETA]->GetXaxis()->GetBinCenter(binX), t0.fTest0Pro2D[mo][mi][AFO_PT_ETA]->GetYaxis()->GetBinCenter(binY), correlation / weight, weight); + } + + // **) vs. centrality vs. pt vs. eta: + if (t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_ETA]) { + // Remark: I have to re-use binX, binY, binZ obtained from t0.fTest0Pro2D[mo][mi][AFO_PT_ETA] above, because I am looping for "case 2:" here over global bin number of + // t0.fTest0Pro2D[mo][mi][AFO_PT_ETA], not of t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_ETA] + t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_ETA]->Fill(ebye.fCentrality, t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_ETA]->GetYaxis()->GetBinCenter(binX), t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_ETA]->GetZaxis()->GetBinCenter(binY), correlation / weight, weight); // yes, y-axis of this histogram is x-axis of t0.fTest0Pro2D[mo][mi][AFO_PT_ETA], and similarly z-axis here is y-axis of t0.fTest0Pro2D[mo][mi][AFO_PT_ETA] + } + + // ... + + } // if (kineVarChoice == PT_ETAq) + + // *) cases for which 2D vs. (pt,charge) calculus is needed: + if (kineVarChoice == PT_CHARGEq) { + + // transfer global bin b into (binX, binY, binZ): + int binX = -1; + int binY = -1; + int binZ = -1; // dummy for 2D case + t0.fTest0Pro2D[mo][mi][AFO_PT_CHARGE]->GetBinXYZ(b, binX, binY, binZ); + + // **) vs. pt vs. charge: + if (t0.fTest0Pro2D[mo][mi][AFO_PT_CHARGE]) { + t0.fTest0Pro2D[mo][mi][AFO_PT_CHARGE]->Fill(t0.fTest0Pro2D[mo][mi][AFO_PT_CHARGE]->GetXaxis()->GetBinCenter(binX), t0.fTest0Pro2D[mo][mi][AFO_PT_CHARGE]->GetYaxis()->GetBinCenter(binY), correlation / weight, weight); + } + // **) vs. centrality vs. pt vs. charge: + if (t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_CHARGE]) { + // Remark: I have to re-use binX, binY, binZ obtained from t0.fTest0Pro2D[mo][mi][AFO_PT_CHARGE] above, because I am looping for "case 2:" here over global bin number of + // t0.fTest0Pro2D[mo][mi][AFO_PT_CHARGE], not of t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_CHARGE] + t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_CHARGE]->Fill(ebye.fCentrality, t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_CHARGE]->GetYaxis()->GetBinCenter(binX), t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_PT_CHARGE]->GetZaxis()->GetBinCenter(binY), correlation / weight, weight); // yes, y-axis of this histogram is x-axis of t0.fTest0Pro2D[mo][mi][AFO_PT_CHARGE], and similarly z-axis here is y-axis of t0.fTest0Pro2D[mo][mi][AFO_PT_CHARGE] + } + + // ... + + } // if (kineVarChoice == PT_CHARGEq) + + // *) cases for which 2D vs. (eta,charge) calculus is needed: + if (kineVarChoice == ETA_CHARGEq) { + + // transfer global bin b into (binX, binY, binZ): + int binX = -1; + int binY = -1; + int binZ = -1; // dummy for 2D case + t0.fTest0Pro2D[mo][mi][AFO_ETA_CHARGE]->GetBinXYZ(b, binX, binY, binZ); + + // **) vs. eta vs. charge: + if (t0.fTest0Pro2D[mo][mi][AFO_ETA_CHARGE]) { + t0.fTest0Pro2D[mo][mi][AFO_ETA_CHARGE]->Fill(t0.fTest0Pro2D[mo][mi][AFO_ETA_CHARGE]->GetXaxis()->GetBinCenter(binX), t0.fTest0Pro2D[mo][mi][AFO_ETA_CHARGE]->GetYaxis()->GetBinCenter(binY), correlation / weight, weight); + } + // **) vs. centrality vs. eta vs. charge: + if (t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_ETA_CHARGE]) { + // Remark: I have to re-use binX, binY, binZ obtained from t0.fTest0Pro2D[mo][mi][AFO_ETA_CHARGE] above, because I am looping for "case 2:" here over global bin number of + // t0.fTest0Pro2D[mo][mi][AFO_ETA_CHARGE], not of t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_ETA_CHARGE] + t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_ETA_CHARGE]->Fill(ebye.fCentrality, t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_ETA_CHARGE]->GetYaxis()->GetBinCenter(binX), t0.fTest0Pro3D[mo][mi][AFO_CENTRALITY_ETA_CHARGE]->GetZaxis()->GetBinCenter(binY), correlation / weight, weight); // yes, y-axis of this histogram is x-axis of t0.fTest0Pro2D[mo][mi][AFO_ETA_CHARGE], and similarly z-axis here is y-axis of t0.fTest0Pro2D[mo][mi][AFO_ETA_CHARGE] + } + + // ... + + } // if (kineVarChoice == ETA_CHARGEq) + + // ... + + break; + } + + case 3: { + + // *) cases for which 3D vs. (pt,eta,charge) calculus is needed: + if (kineVarChoice == PT_ETA_CHARGEq) { + + // transfer global bin b into (binX, binY, binZ): + int binX = -1; + int binY = -1; + int binZ = -1; + t0.fTest0Pro3D[mo][mi][AFO_PT_ETA_CHARGE]->GetBinXYZ(b, binX, binY, binZ); + + // **) vs. pt vs. eta vs. charge: + if (t0.fTest0Pro3D[mo][mi][AFO_PT_ETA_CHARGE]) { + t0.fTest0Pro3D[mo][mi][AFO_PT_ETA_CHARGE]->Fill(t0.fTest0Pro3D[mo][mi][AFO_PT_ETA_CHARGE]->GetXaxis()->GetBinCenter(binX), + t0.fTest0Pro3D[mo][mi][AFO_PT_ETA_CHARGE]->GetYaxis()->GetBinCenter(binY), + t0.fTest0Pro3D[mo][mi][AFO_PT_ETA_CHARGE]->GetZaxis()->GetBinCenter(binZ), + correlation / weight, weight); + } + } + + // ... + + break; + } + + // ... + + default: { + LOGF(fatal, "\033[1;31m%s at line %d : Ndim = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, Ndim); + break; + } + + } // switch (Ndim) + + } // if(fTest0Labels[mo][mi]) + } // for(int mi=0;mi kineVarChoice (eqvectorKine) = %d, global (ordinary) bin %d <=> (%f, %f)", static_cast(kineVarChoice), bin, res.fResultsPro[AfoKineMap1D(kineVarChoice)]->GetBinLowEdge(bin), res.fResultsPro[AfoKineMap1D(kineVarChoice)]->GetBinLowEdge(bin + 1)); + + break; } - if (pw.fUseWeights[wPT]) { - wPt = Weight(dPt, wPT); + + // 2D: + case PT_ETAq: + case PT_CHARGEq: + case ETA_CHARGEq: { + + // transfer global bin b into (binX, binY, binZ): + int binX = -1; + int binY = -1; + int binZ = -1; // dummy for 2D case + res.fResultsPro2D[AfoKineMap2D(kineVarChoice)]->GetBinXYZ(bin, binX, binY, binZ); + + LOGF(info, " => kineVarChoice (eqvectorKine) = %d, global bin %d = (%d, %d) <=> (%f, %f) x (%f, %f)", static_cast(kineVarChoice), bin, binX, binY, res.fResultsPro2D[AfoKineMap2D(kineVarChoice)]->GetXaxis()->GetBinLowEdge(binX), res.fResultsPro2D[AfoKineMap2D(kineVarChoice)]->GetXaxis()->GetBinLowEdge(binX + 1), res.fResultsPro2D[AfoKineMap2D(kineVarChoice)]->GetYaxis()->GetBinLowEdge(binY), res.fResultsPro2D[AfoKineMap2D(kineVarChoice)]->GetYaxis()->GetBinLowEdge(binY + 1)); + + break; } - if (pw.fUseWeights[wETA]) { - wEta = Weight(dEta, wETA); + + // 3D: + case PT_ETA_CHARGEq: { + + // transfer global bin b into (binX, binY, binZ): + int binX = -1; + int binY = -1; + int binZ = -1; + res.fResultsPro3D[AfoKineMap3D(kineVarChoice)]->GetBinXYZ(bin, binX, binY, binZ); + + LOGF(info, " => kineVarChoice (eqvectorKine) = %d, global bin %d = (%d, %d, %d) <=> (%f, %f) x (%f, %f) x (%f, %f)", static_cast(kineVarChoice), bin, binX, binY, binZ, res.fResultsPro3D[AfoKineMap3D(kineVarChoice)]->GetXaxis()->GetBinLowEdge(binX), res.fResultsPro3D[AfoKineMap3D(kineVarChoice)]->GetXaxis()->GetBinLowEdge(binX + 1), res.fResultsPro3D[AfoKineMap3D(kineVarChoice)]->GetYaxis()->GetBinLowEdge(binY), res.fResultsPro3D[AfoKineMap3D(kineVarChoice)]->GetYaxis()->GetBinLowEdge(binY + 1), res.fResultsPro3D[AfoKineMap3D(kineVarChoice)]->GetZaxis()->GetBinLowEdge(binZ), res.fResultsPro3D[AfoKineMap3D(kineVarChoice)]->GetZaxis()->GetBinLowEdge(binZ + 1)); + + break; } - nl.ftaNestedLoops[1]->AddAt(wPhi * wPt * wEta, particleIndex); // remember that the 2nd argument here must start from 0 - } + + default: { + LOGF(fatal, "\033[1;31m%s at line %d : This kineVarChoice = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice)); + break; + } + + } // switch(AFO_variable) if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void FillNestedLoopsContainers(const Int_t& particleIndex, const Double_t& dPhi, const Double_t& dPt, const Double_t& dEta) +} // void PrintBinEdgesKine() //============================================================ -void CalculateNestedLoops() +void CalculateEtaSeparations() { - // Calculate correlations with nested loops. + // Calculate correlations with pseudorapidity separations. - // a) 2-particle nested loops; - // b) 4-particle nested loops; - // c) 6-particle nested loops; - // d) 8-particle nested loops. + // Remark: this is a port and generalization of void AliFlowAnalysisWithMultiparticleCorrelations::CalculateEtaGaps(AliFlowEventSimple *anEvent) if (tc.fVerbose) { StartFunction(__FUNCTION__); } - LOGF(info, " ebye.fSelectedTracks = %d", ebye.fSelectedTracks); - Int_t nParticles = ebye.fSelectedTracks; + // Calculate 2-p correlations with eta separations from Qa (-eta, index [0]) and Qb (+eta, index [1]) vectors: + double correlation = 0.; + double weight = 0.; + for (int h = 0; h < gMaxHarmonic; h++) { + if (es.fEtaSeparationsSkipHarmonics[h]) { + continue; + } + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + if (!(qv.fQabVector[0][h][e].Rho() > 0. && qv.fQabVector[1][h][e].Rho() > 0.)) { + continue; + } + if (!(qv.fMab[0][e] > 0. && qv.fMab[1][e] > 0.)) { + continue; + } - /* TBI 20220823 enable the lines below eventually - if(fUseFixedNumberOfRandomlySelectedTracks) - { - nParticles = 0; - for(Int_t i=0;iGetSize();i++) - { - if(TMath::Abs(ftaNestedLoops[0]->GetAt(i)) > 0. && - TMath::Abs(ftaNestedLoops[1]->GetAt(i)) > 0.){nParticles++;} - } - } - cout<<"nParticles = "< 0 && nl.fMaxNestedLoop < 2) { - return; - } - LOGF(info, " Calculating 2-p correlations with nested loops .... "); - for (int i1 = 0; i1 < nParticles; i1++) { - Double_t dPhi1 = nl.ftaNestedLoops[0]->GetAt(i1); - Double_t dW1 = nl.ftaNestedLoops[1]->GetAt(i1); - for (int i2 = 0; i2 < nParticles; i2++) { - if (i2 == i1) { - continue; + // for on-the-fly and internal validation, rescale results with theoretical value: + if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && std::abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h)) > 0.) { + correlation /= std::pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h), 2.); } - Double_t dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); - Double_t dW2 = nl.ftaNestedLoops[1]->GetAt(i2); - for (int h = 0; h < gMaxHarmonic; h++) { - // fill cos, 2p, integreated: - if (nl.fNestedLoopsPro[0][h][AFO_INTEGRATED]) { - nl.fNestedLoopsPro[0][h][AFO_INTEGRATED]->Fill( - 0.5, TMath::Cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); - } - // fill cos, 2p, vs. multiplicity: - if (nl.fNestedLoopsPro[0][h][AFO_MULTIPLICITY]) { - nl.fNestedLoopsPro[0][h][AFO_MULTIPLICITY]->Fill( - ebye.fMultiplicity + 0.5, TMath::Cos((h + 1.) * (dPhi1 - dPhi2)), - dW1 * dW2); - } - // fill cos, 2p, vs. centrality: - if (nl.fNestedLoopsPro[0][h][AFO_CENTRALITY]) { - nl.fNestedLoopsPro[0][h][AFO_CENTRALITY]->Fill( - ebye.fCentrality, TMath::Cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); - } - // fill cos, 2p, vs. occupancy: - if (nl.fNestedLoopsPro[0][h][AFO_OCCUPANCY]) { - nl.fNestedLoopsPro[0][h][AFO_OCCUPANCY]->Fill( - ebye.fOccupancy, TMath::Cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); - } - // fill cos, 2p, vs. interaction rate: - if (nl.fNestedLoopsPro[0][h][AFO_INTERACTIONRATE]) { - nl.fNestedLoopsPro[0][h][AFO_INTERACTIONRATE]->Fill( - ebye.fInteractionRate, TMath::Cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); - } - // fill cos, 2p, vs. current run duration: - if (nl.fNestedLoopsPro[0][h][AFO_CURRENTRUNDURATION]) { - nl.fNestedLoopsPro[0][h][AFO_CURRENTRUNDURATION]->Fill( - ebye.fCurrentRunDuration, TMath::Cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); - } - } // for(int h=1; h<=6; h++) - } // for(int i2=0; i2Fill(0.5, correlation / weight, weight); + } + + // vs. multiplicity: + if (es.fEtaSeparationsPro[h][e][AFO_MULTIPLICITY]) { + es.fEtaSeparationsPro[h][e][AFO_MULTIPLICITY]->Fill(ebye.fMultiplicity + 0.5, correlation / weight, weight); + } + + // vs. centrality: + if (es.fEtaSeparationsPro[h][e][AFO_CENTRALITY]) { + es.fEtaSeparationsPro[h][e][AFO_CENTRALITY]->Fill(ebye.fCentrality, correlation / weight, weight); + } + + // vs. occupancy: + if (es.fEtaSeparationsPro[h][e][AFO_OCCUPANCY]) { + es.fEtaSeparationsPro[h][e][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, correlation / weight, weight); + } + + // vs. interaction rate: + if (es.fEtaSeparationsPro[h][e][AFO_INTERACTIONRATE]) { + es.fEtaSeparationsPro[h][e][AFO_INTERACTIONRATE]->Fill(ebye.fInteractionRate, correlation / weight, weight); + } + + // vs. current run duration: + if (es.fEtaSeparationsPro[h][e][AFO_CURRENTRUNDURATION]) { + es.fEtaSeparationsPro[h][e][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, correlation / weight, weight); + } + + // vs. vertex z position: + if (es.fEtaSeparationsPro[h][e][AFO_VZ]) { + es.fEtaSeparationsPro[h][e][AFO_VZ]->Fill(ebye.fVz, correlation / weight, weight); + } + + } // for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + } // for (int h = 0; h < gMaxHarmonic; h++) { + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void CalculateEtaSeparations() + +//============================================================ + +void CalculateKineEtaSeparationsNdim(eqvectorKine kineVarChoice, int Ndim) +{ + // Calculate analytically N-dimensional kine eta separations from differential q-vectors. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // This is a replacement for the legacy function CalculateKineEtaSeparations(...), which is as of 20250620 deemed obsolete. + // Remember that here I changed design, and pass enum eqvectorKine as an argument, not any longer enum eAsFunctionOf. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + int nBins = -1; + + switch (Ndim) { + + case 1: { + eAsFunctionOf AFO_var = AfoKineMap1D(kineVarChoice); + if (res.fResultsPro[AFO_var]) { + nBins = res.fResultsPro[AFO_var]->GetNbinsX() + 2; // + 2 means that I take into account overflow and underflow, then skip it in the loop below. + } + + break; + } + + case 2: { + eAsFunctionOf2D AFO_var = AfoKineMap2D(kineVarChoice); + if (res.fResultsPro2D[AFO_var]) { + nBins = (res.fResultsPro2D[AFO_var]->GetNbinsX() + 2) * (res.fResultsPro2D[AFO_var]->GetNbinsY() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + } + + break; + } + + case 3: { + eAsFunctionOf3D AFO_var = AfoKineMap3D(kineVarChoice); + if (res.fResultsPro3D[AFO_var]) { + nBins = (res.fResultsPro3D[AFO_var]->GetNbinsX() + 2) * (res.fResultsPro3D[AFO_var]->GetNbinsY() + 2) * (res.fResultsPro3D[AFO_var]->GetNbinsZ() + 2); // + 2 means that I take into account overflow and underflow, then skip it in the loop below + } + break; + } + + // ... + + default: { + LOGF(fatal, "\033[1;31m%s at line %d : Ndim = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, Ndim); + break; + } + + } // switch (Ndim) + + // *) Uniform loop over linearized global bins for all kine variables: + for (int b = 0; b < nBins; b++) { // yes, "< nBins", not "<= nBins", because b runs over all regular bins + 2 (therefore, including underflow and overflow already) + + // TBI 20241206 Do I need to adapt and apply this cut, also for Qa and Qb? If so, most likely I would need to apply it on sum, i.e. on entries in Qa + Qb + // + // // *) Ensures that in each bin of interest, I have the same cut on number of particles, like in integrated analysis: + // if ((qv.fqvectorEntries[qvKine][b] < ec.fdEventCuts[eMultiplicity][eMin]) || (qv.fqvectorEntries[qvKine][b] > ec.fdEventCuts[eMultiplicity][eMax] || std::abs(qv.fqvectorEntries[qvKine][b] - ec.fdEventCuts[eMultiplicity][eMax]) < tc.fFloatingPointPrecision)) { + // if (tc.fVerbose) { + // LOGF(info, "\033[1;31m%s eMultiplicity cut in bin = %d, for qvKine = %d\033[0m", __FUNCTION__, b, static_cast(qvKine)); + // } + // } + + // Calculate differential 2-p correlations with eta separations from Qa (-eta, index [0]) and Qb (+eta, index [1]) vectors: + double correlation = 0.; + double weight = 0.; + for (int h = 0; h < gMaxHarmonic; h++) { + if (es.fEtaSeparationsSkipHarmonics[h]) { + continue; + } + + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + if (!(std::abs(qv.fqabVector[0][kineVarChoice][b][h][e]) > 0. && std::abs(qv.fqabVector[1][kineVarChoice][b][h][e]) > 0.)) { + continue; + } + if (!(qv.fmab[0][kineVarChoice][b][e] > 0. && qv.fmab[1][kineVarChoice][b][e] > 0.)) { + continue; + } + + // calculate correlation and weights with particular eta separation: + correlation = (qv.fqabVector[0][kineVarChoice][b][h][e] * std::conj(qv.fqabVector[1][kineVarChoice][b][h][e])).real(); + // Remark: this was the legacy code, just in case I would still need it: + // correlation = TComplex(qv.fqabVector[0][kineVarChoice][b][h][e] * TComplex::Conjugate(qv.fqabVector[1][kineVarChoice][b][h][e])).Re(); + weight = qv.fmab[0][kineVarChoice][b][e] * qv.fmab[1][kineVarChoice][b][e]; + + // for on-the-fly and internal validation, rescale results with theoretical value: + if (iv.fUseInternalValidation && iv.fRescaleWithTheoreticalInput && iv.fInternalValidationVnPsin[eVn] && std::abs(iv.fInternalValidationVnPsin[eVn]->GetAt(h)) > 0.) { + correlation /= std::pow(iv.fInternalValidationVnPsin[eVn]->GetAt(h), 2.); + } + + // finally, fill 1D case: + if (es.fEtaSeparationsPro[h][e][AfoKineMap1D(kineVarChoice)]) { + es.fEtaSeparationsPro[h][e][AfoKineMap1D(kineVarChoice)]->Fill(es.fEtaSeparationsPro[h][e][AfoKineMap1D(kineVarChoice)]->GetXaxis()->GetBinCenter(b), correlation / weight, weight); + } + + // TBI 20250620 I need to add support eventually also for 2D and 3D cases. + } + } + } // for (int b = 0; b < nBins; b++) + + // *) Quick insanity check: I shall never have any entry in underflow (bin = 0) or overflow (bin = nBins -1) in es.fEtaSeparationsPro, otherwise some cuts were bypassed: + if (tc.fDoAdditionalInsanityChecks) { + for (int h = 0; h < gMaxHarmonic; h++) { + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + if (es.fEtaSeparationsPro[h][e][AfoKineMap1D(kineVarChoice)] && std::abs(es.fEtaSeparationsPro[h][e][AfoKineMap1D(kineVarChoice)]->GetBinContent(0)) > 0.) { + LOGF(fatal, "\033[1;31m%s at line %d : underflow is not empty \033[0m", __FUNCTION__, __LINE__); + } + if (es.fEtaSeparationsPro[h][e][AfoKineMap1D(kineVarChoice)] && std::abs(es.fEtaSeparationsPro[h][e][AfoKineMap1D(kineVarChoice)]->GetBinContent(nBins - 1)) > 0.) { + LOGF(fatal, "\033[1;31m%s at line %d : overflow is not empty \033[0m", __FUNCTION__, __LINE__); + } + } + } + } // if (tc.fDoAdditionalInsanityChecks) + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void CalculateKineEtaSeparationsNdim(eqvectorKine kineVarChoice, int Ndim) + +//============================================================ + +void FillNestedLoopsContainers(const int& particleIndex, const double& dPhi, const double& dPt, const double& dEta) +{ + // Fill into the nested loop containers the current particle. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + if (tc.fInsanityCheckForEachParticle) { + if (particleIndex < 0) { + LOGF(fatal, "\033[1;31m%s at line %d : particleIndex = %d\033[0m", __FUNCTION__, __LINE__, particleIndex); + } + if (!(std::abs(nl.ftaNestedLoops[0]->GetAt(particleIndex - 1)) > 0.)) { + LOGF(fatal, "\033[1;31m%s at line %d : there are empty elements in nl.ftaNestedLoops[0] \033[0m", __FUNCTION__, __LINE__); + // I need this protection, to ensure that all array entries are filled. If not, most likely a particle passed all + // selection criteria, and it wasn't added to the nested loops containers + } + } + + // *) Fill container for angles: + if (nl.ftaNestedLoops[0]) { + nl.ftaNestedLoops[0]->AddAt(dPhi, particleIndex); // remember that the 2nd argument here must start from 0 + } + + // *) Fill container for weights: + if (nl.ftaNestedLoops[1]) { + // TBI 20240501 there is a bit of efficiency loss here, because I access Weight() again here. + // But it doesn't matter really, in any case I evaluate nested loops only for small M during debugging. + // Otherwise, just promote weights to data members, and initialize them only once for a given particle. + double wPhi = 1.; + double wPt = 1.; + double wEta = 1.; + if (pw.fUseWeights[wPHI]) { + wPhi = Weight(dPhi, wPHI); + } + if (pw.fUseWeights[wPT]) { + wPt = Weight(dPt, wPT); + } + if (pw.fUseWeights[wETA]) { + wEta = Weight(dEta, wETA); + } + nl.ftaNestedLoops[1]->AddAt(wPhi * wPt * wEta, particleIndex); // remember that the 2nd argument here must start from 0 + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void FillNestedLoopsContainers(const int& particleIndex, const double& dPhi, const double& dPt, const double& dEta) + +//============================================================ + +void CalculateNestedLoops() +{ + // Calculate correlations with nested loops. + + // a) 2-particle nested loops; + // b) 4-particle nested loops; + // c) 6-particle nested loops; + // d) 8-particle nested loops. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + LOGF(info, " ebye.fSelectedTracks = %d", ebye.fSelectedTracks); + int nParticles = ebye.fSelectedTracks; + + // a) 2-particle nested loops: + if (nParticles < 2) { + return; + } + if (nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < 2) { + return; + } + LOGF(info, " Calculating 2-p correlations with nested loops .... "); + for (int i1 = 0; i1 < nParticles; i1++) { + double dPhi1 = nl.ftaNestedLoops[0]->GetAt(i1); + double dW1 = nl.ftaNestedLoops[1]->GetAt(i1); + for (int i2 = 0; i2 < nParticles; i2++) { + if (i2 == i1) { + continue; + } + double dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); + double dW2 = nl.ftaNestedLoops[1]->GetAt(i2); + for (int h = 0; h < gMaxHarmonic; h++) { + // fill cos, 2p, integreated: + if (nl.fNestedLoopsPro[0][h][AFO_INTEGRATED]) { + nl.fNestedLoopsPro[0][h][AFO_INTEGRATED]->Fill( + 0.5, std::cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); + } + // fill cos, 2p, vs. multiplicity: + if (nl.fNestedLoopsPro[0][h][AFO_MULTIPLICITY]) { + nl.fNestedLoopsPro[0][h][AFO_MULTIPLICITY]->Fill( + ebye.fMultiplicity + 0.5, std::cos((h + 1.) * (dPhi1 - dPhi2)), + dW1 * dW2); + } + // fill cos, 2p, vs. centrality: + if (nl.fNestedLoopsPro[0][h][AFO_CENTRALITY]) { + nl.fNestedLoopsPro[0][h][AFO_CENTRALITY]->Fill( + ebye.fCentrality, std::cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); + } + // fill cos, 2p, vs. occupancy: + if (nl.fNestedLoopsPro[0][h][AFO_OCCUPANCY]) { + nl.fNestedLoopsPro[0][h][AFO_OCCUPANCY]->Fill( + ebye.fOccupancy, std::cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); + } + // fill cos, 2p, vs. interaction rate: + if (nl.fNestedLoopsPro[0][h][AFO_INTERACTIONRATE]) { + nl.fNestedLoopsPro[0][h][AFO_INTERACTIONRATE]->Fill( + ebye.fInteractionRate, std::cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); + } + // fill cos, 2p, vs. current run duration: + if (nl.fNestedLoopsPro[0][h][AFO_CURRENTRUNDURATION]) { + nl.fNestedLoopsPro[0][h][AFO_CURRENTRUNDURATION]->Fill( + ebye.fCurrentRunDuration, std::cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); + } + // fill cos, 2p, vs. vertex z position: + if (nl.fNestedLoopsPro[0][h][AFO_VZ]) { + nl.fNestedLoopsPro[0][h][AFO_VZ]->Fill( + ebye.fVz, std::cos((h + 1.) * (dPhi1 - dPhi2)), dW1 * dW2); + } + + } // for(int h=1; h<=6; h++) + } // for(int i2=0; i2 0 && nl.fMaxNestedLoop < 4) { return; } LOGF(info, " Calculating 4-p correlations with nested loops .... "); for (int i1 = 0; i1 < nParticles; i1++) { - Double_t dPhi1 = nl.ftaNestedLoops[0]->GetAt(i1); - Double_t dW1 = nl.ftaNestedLoops[1]->GetAt(i1); + double dPhi1 = nl.ftaNestedLoops[0]->GetAt(i1); + double dW1 = nl.ftaNestedLoops[1]->GetAt(i1); for (int i2 = 0; i2 < nParticles; i2++) { if (i2 == i1) { continue; } - Double_t dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); - Double_t dW2 = nl.ftaNestedLoops[1]->GetAt(i2); + double dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); + double dW2 = nl.ftaNestedLoops[1]->GetAt(i2); for (int i3 = 0; i3 < nParticles; i3++) { if (i3 == i1 || i3 == i2) { continue; } - Double_t dPhi3 = nl.ftaNestedLoops[0]->GetAt(i3); - Double_t dW3 = nl.ftaNestedLoops[1]->GetAt(i3); + double dPhi3 = nl.ftaNestedLoops[0]->GetAt(i3); + double dW3 = nl.ftaNestedLoops[1]->GetAt(i3); for (int i4 = 0; i4 < nParticles; i4++) { if (i4 == i1 || i4 == i2 || i4 == i3) { continue; } - Double_t dPhi4 = nl.ftaNestedLoops[0]->GetAt(i4); - Double_t dW4 = nl.ftaNestedLoops[1]->GetAt(i4); + double dPhi4 = nl.ftaNestedLoops[0]->GetAt(i4); + double dW4 = nl.ftaNestedLoops[1]->GetAt(i4); for (int h = 0; h < gMaxHarmonic; h++) { // fill cos, 4p, integreated: if (nl.fNestedLoopsPro[1][h][AFO_INTEGRATED]) { - nl.fNestedLoopsPro[1][h][AFO_INTEGRATED]->Fill(0.5, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); + nl.fNestedLoopsPro[1][h][AFO_INTEGRATED]->Fill(0.5, std::cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); } // fill cos, 4p, all harmonics, vs. M: if (nl.fNestedLoopsPro[1][h][AFO_MULTIPLICITY]) { - nl.fNestedLoopsPro[1][h][AFO_MULTIPLICITY]->Fill(ebye.fMultiplicity + 0.5, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); + nl.fNestedLoopsPro[1][h][AFO_MULTIPLICITY]->Fill(ebye.fMultiplicity + 0.5, std::cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); } // fill cos, 4p, all harmonics, vs. centrality: if (nl.fNestedLoopsPro[1][h][AFO_CENTRALITY]) { - nl.fNestedLoopsPro[1][h][AFO_CENTRALITY]->Fill(ebye.fCentrality, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); + nl.fNestedLoopsPro[1][h][AFO_CENTRALITY]->Fill(ebye.fCentrality, std::cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); } // fill cos, 4p, all harmonics, vs. occupancy: if (nl.fNestedLoopsPro[1][h][AFO_OCCUPANCY]) { - nl.fNestedLoopsPro[1][h][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); + nl.fNestedLoopsPro[1][h][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, std::cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); } // fill cos, 4p, all harmonics, vs. interaction rate: if (nl.fNestedLoopsPro[1][h][AFO_INTERACTIONRATE]) { - nl.fNestedLoopsPro[1][h][AFO_INTERACTIONRATE]->Fill(ebye.fInteractionRate, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); + nl.fNestedLoopsPro[1][h][AFO_INTERACTIONRATE]->Fill(ebye.fInteractionRate, std::cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); } // fill cos, 4p, all harmonics, vs. current run duratione: if (nl.fNestedLoopsPro[1][h][AFO_CURRENTRUNDURATION]) { - nl.fNestedLoopsPro[1][h][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); + nl.fNestedLoopsPro[1][h][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, std::cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); + } + // fill cos, 4p, all harmonics, vs. vertex z position: + if (nl.fNestedLoopsPro[1][h][AFO_VZ]) { + nl.fNestedLoopsPro[1][h][AFO_VZ]->Fill(ebye.fVz, std::cos((h + 1.) * (dPhi1 + dPhi2 - dPhi3 - dPhi4)), dW1 * dW2 * dW3 * dW4); } } // for(int h=0; hGetAt(i1); - Double_t dW1 = nl.ftaNestedLoops[1]->GetAt(i1); + double dPhi1 = nl.ftaNestedLoops[0]->GetAt(i1); + double dW1 = nl.ftaNestedLoops[1]->GetAt(i1); for (int i2 = 0; i2 < nParticles; i2++) { if (i2 == i1) { continue; } - Double_t dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); - Double_t dW2 = nl.ftaNestedLoops[1]->GetAt(i2); + double dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); + double dW2 = nl.ftaNestedLoops[1]->GetAt(i2); for (int i3 = 0; i3 < nParticles; i3++) { if (i3 == i1 || i3 == i2) { continue; } - Double_t dPhi3 = nl.ftaNestedLoops[0]->GetAt(i3); - Double_t dW3 = nl.ftaNestedLoops[1]->GetAt(i3); + double dPhi3 = nl.ftaNestedLoops[0]->GetAt(i3); + double dW3 = nl.ftaNestedLoops[1]->GetAt(i3); for (int i4 = 0; i4 < nParticles; i4++) { if (i4 == i1 || i4 == i2 || i4 == i3) { continue; } - Double_t dPhi4 = nl.ftaNestedLoops[0]->GetAt(i4); - Double_t dW4 = nl.ftaNestedLoops[1]->GetAt(i4); + double dPhi4 = nl.ftaNestedLoops[0]->GetAt(i4); + double dW4 = nl.ftaNestedLoops[1]->GetAt(i4); for (int i5 = 0; i5 < nParticles; i5++) { if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) { continue; } - Double_t dPhi5 = nl.ftaNestedLoops[0]->GetAt(i5); - Double_t dW5 = nl.ftaNestedLoops[1]->GetAt(i5); + double dPhi5 = nl.ftaNestedLoops[0]->GetAt(i5); + double dW5 = nl.ftaNestedLoops[1]->GetAt(i5); for (int i6 = 0; i6 < nParticles; i6++) { if (i6 == i1 || i6 == i2 || i6 == i3 || i6 == i4 || i6 == i5) { continue; } - Double_t dPhi6 = nl.ftaNestedLoops[0]->GetAt(i6); - Double_t dW6 = nl.ftaNestedLoops[1]->GetAt(i6); + double dPhi6 = nl.ftaNestedLoops[0]->GetAt(i6); + double dW6 = nl.ftaNestedLoops[1]->GetAt(i6); for (int h = 0; h < gMaxHarmonic; h++) { // fill cos, 6p, integreated: if (nl.fNestedLoopsPro[2][h][AFO_INTEGRATED]) { - nl.fNestedLoopsPro[2][h][AFO_INTEGRATED]->Fill(0.5, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); + nl.fNestedLoopsPro[2][h][AFO_INTEGRATED]->Fill(0.5, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); } // fill cos, 6p, all harmonics, vs. M: if (nl.fNestedLoopsPro[2][h][AFO_MULTIPLICITY]) { - nl.fNestedLoopsPro[2][h][AFO_MULTIPLICITY]->Fill(ebye.fMultiplicity + 0.5, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); + nl.fNestedLoopsPro[2][h][AFO_MULTIPLICITY]->Fill(ebye.fMultiplicity + 0.5, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); } // fill cos, 6p, all harmonics, vs. centrality: if (nl.fNestedLoopsPro[2][h][AFO_CENTRALITY]) { - nl.fNestedLoopsPro[2][h][AFO_CENTRALITY]->Fill(ebye.fCentrality, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); + nl.fNestedLoopsPro[2][h][AFO_CENTRALITY]->Fill(ebye.fCentrality, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); } // fill cos, 6p, all harmonics, vs. occupancy: if (nl.fNestedLoopsPro[2][h][AFO_OCCUPANCY]) { - nl.fNestedLoopsPro[2][h][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); + nl.fNestedLoopsPro[2][h][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); } // fill cos, 6p, all harmonics, vs. interaction rate: if (nl.fNestedLoopsPro[2][h][AFO_INTERACTIONRATE]) { - nl.fNestedLoopsPro[2][h][AFO_INTERACTIONRATE]->Fill(ebye.fInteractionRate, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); + nl.fNestedLoopsPro[2][h][AFO_INTERACTIONRATE]->Fill(ebye.fInteractionRate, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); } // fill cos, 6p, all harmonics, vs. current run duration: if (nl.fNestedLoopsPro[2][h][AFO_CURRENTRUNDURATION]) { - nl.fNestedLoopsPro[2][h][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); + nl.fNestedLoopsPro[2][h][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); + } + // fill cos, 6p, all harmonics, vs. vertex z position: + if (nl.fNestedLoopsPro[2][h][AFO_VZ]) { + nl.fNestedLoopsPro[2][h][AFO_VZ]->Fill(ebye.fVz, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); } } // for(int h=0; h 0 && nl.fMaxNestedLoop < 8) { - return; - } - LOGF(info, " Calculating 8-p correlations with nested loops .... "); - for (int i1 = 0; i1 < nParticles; i1++) { - Double_t dPhi1 = nl.ftaNestedLoops[0]->GetAt(i1); - Double_t dW1 = nl.ftaNestedLoops[1]->GetAt(i1); - for (int i2 = 0; i2 < nParticles; i2++) { - if (i2 == i1) { - continue; - } - Double_t dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); - Double_t dW2 = nl.ftaNestedLoops[1]->GetAt(i2); - for (int i3 = 0; i3 < nParticles; i3++) { - if (i3 == i1 || i3 == i2) { - continue; - } - Double_t dPhi3 = nl.ftaNestedLoops[0]->GetAt(i3); - Double_t dW3 = nl.ftaNestedLoops[1]->GetAt(i3); - for (int i4 = 0; i4 < nParticles; i4++) { - if (i4 == i1 || i4 == i2 || i4 == i3) { - continue; - } - Double_t dPhi4 = nl.ftaNestedLoops[0]->GetAt(i4); - Double_t dW4 = nl.ftaNestedLoops[1]->GetAt(i4); - for (int i5 = 0; i5 < nParticles; i5++) { - if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) { - continue; - } - Double_t dPhi5 = nl.ftaNestedLoops[0]->GetAt(i5); - Double_t dW5 = nl.ftaNestedLoops[1]->GetAt(i5); - for (int i6 = 0; i6 < nParticles; i6++) { - if (i6 == i1 || i6 == i2 || i6 == i3 || i6 == i4 || i6 == i5) { - continue; - } - Double_t dPhi6 = nl.ftaNestedLoops[0]->GetAt(i6); - Double_t dW6 = nl.ftaNestedLoops[1]->GetAt(i6); - for (int i7 = 0; i7 < nParticles; i7++) { - if (i7 == i1 || i7 == i2 || i7 == i3 || i7 == i4 || i7 == i5 || i7 == i6) { - continue; - } - Double_t dPhi7 = nl.ftaNestedLoops[0]->GetAt(i7); - Double_t dW7 = nl.ftaNestedLoops[1]->GetAt(i7); - for (int i8 = 0; i8 < nParticles; i8++) { - if (i8 == i1 || i8 == i2 || i8 == i3 || i8 == i4 || i8 == i5 || i8 == i6 || i8 == i7) { - continue; - } - Double_t dPhi8 = nl.ftaNestedLoops[0]->GetAt(i8); - Double_t dW8 = nl.ftaNestedLoops[1]->GetAt(i8); - for (int h = 0; h < gMaxHarmonic; h++) { - // fill cos, 8p, integreated: - if (nl.fNestedLoopsPro[3][h][AFO_INTEGRATED]) { - nl.fNestedLoopsPro[3][h][AFO_INTEGRATED]->Fill(0.5, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); - } - // fill cos, 8p, all harmonics, vs. M: - if (nl.fNestedLoopsPro[3][h][AFO_MULTIPLICITY]) { - nl.fNestedLoopsPro[3][h][AFO_MULTIPLICITY]->Fill(ebye.fMultiplicity + 0.5, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); - } - // fill cos, 8p, all harmonics, vs. centrality: - if (nl.fNestedLoopsPro[3][h][AFO_CENTRALITY]) { - nl.fNestedLoopsPro[3][h][AFO_CENTRALITY]->Fill(ebye.fCentrality, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); - } - // fill cos, 8p, all harmonics, vs. occupancy: - if (nl.fNestedLoopsPro[3][h][AFO_OCCUPANCY]) { - nl.fNestedLoopsPro[3][h][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); - } - // fill cos, 8p, all harmonics, vs. interaction rate: - if (nl.fNestedLoopsPro[3][h][AFO_INTERACTIONRATE]) { - nl.fNestedLoopsPro[3][h][AFO_INTERACTIONRATE]->Fill(ebye.fInteractionRate, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); - } - // fill cos, 8p, all harmonics, vs. current run duration: - if (nl.fNestedLoopsPro[3][h][AFO_CURRENTRUNDURATION]) { - nl.fNestedLoopsPro[3][h][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); - } - } // for(int h=0; h 0 && nl.fMaxNestedLoop < 8) { + return; + } + LOGF(info, " Calculating 8-p correlations with nested loops .... "); + for (int i1 = 0; i1 < nParticles; i1++) { + double dPhi1 = nl.ftaNestedLoops[0]->GetAt(i1); + double dW1 = nl.ftaNestedLoops[1]->GetAt(i1); + for (int i2 = 0; i2 < nParticles; i2++) { + if (i2 == i1) { + continue; + } + double dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); + double dW2 = nl.ftaNestedLoops[1]->GetAt(i2); + for (int i3 = 0; i3 < nParticles; i3++) { + if (i3 == i1 || i3 == i2) { + continue; + } + double dPhi3 = nl.ftaNestedLoops[0]->GetAt(i3); + double dW3 = nl.ftaNestedLoops[1]->GetAt(i3); + for (int i4 = 0; i4 < nParticles; i4++) { + if (i4 == i1 || i4 == i2 || i4 == i3) { + continue; + } + double dPhi4 = nl.ftaNestedLoops[0]->GetAt(i4); + double dW4 = nl.ftaNestedLoops[1]->GetAt(i4); + for (int i5 = 0; i5 < nParticles; i5++) { + if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) { + continue; + } + double dPhi5 = nl.ftaNestedLoops[0]->GetAt(i5); + double dW5 = nl.ftaNestedLoops[1]->GetAt(i5); + for (int i6 = 0; i6 < nParticles; i6++) { + if (i6 == i1 || i6 == i2 || i6 == i3 || i6 == i4 || i6 == i5) { + continue; + } + double dPhi6 = nl.ftaNestedLoops[0]->GetAt(i6); + double dW6 = nl.ftaNestedLoops[1]->GetAt(i6); + for (int i7 = 0; i7 < nParticles; i7++) { + if (i7 == i1 || i7 == i2 || i7 == i3 || i7 == i4 || i7 == i5 || i7 == i6) { + continue; + } + double dPhi7 = nl.ftaNestedLoops[0]->GetAt(i7); + double dW7 = nl.ftaNestedLoops[1]->GetAt(i7); + for (int i8 = 0; i8 < nParticles; i8++) { + if (i8 == i1 || i8 == i2 || i8 == i3 || i8 == i4 || i8 == i5 || i8 == i6 || i8 == i7) { + continue; + } + double dPhi8 = nl.ftaNestedLoops[0]->GetAt(i8); + double dW8 = nl.ftaNestedLoops[1]->GetAt(i8); + for (int h = 0; h < gMaxHarmonic; h++) { + // fill cos, 8p, integreated: + if (nl.fNestedLoopsPro[3][h][AFO_INTEGRATED]) { + nl.fNestedLoopsPro[3][h][AFO_INTEGRATED]->Fill(0.5, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); + } + // fill cos, 8p, all harmonics, vs. M: + if (nl.fNestedLoopsPro[3][h][AFO_MULTIPLICITY]) { + nl.fNestedLoopsPro[3][h][AFO_MULTIPLICITY]->Fill(ebye.fMultiplicity + 0.5, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); + } + // fill cos, 8p, all harmonics, vs. centrality: + if (nl.fNestedLoopsPro[3][h][AFO_CENTRALITY]) { + nl.fNestedLoopsPro[3][h][AFO_CENTRALITY]->Fill(ebye.fCentrality, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); + } + // fill cos, 8p, all harmonics, vs. occupancy: + if (nl.fNestedLoopsPro[3][h][AFO_OCCUPANCY]) { + nl.fNestedLoopsPro[3][h][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); + } + // fill cos, 8p, all harmonics, vs. interaction rate: + if (nl.fNestedLoopsPro[3][h][AFO_INTERACTIONRATE]) { + nl.fNestedLoopsPro[3][h][AFO_INTERACTIONRATE]->Fill(ebye.fInteractionRate, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); + } + // fill cos, 8p, all harmonics, vs. current run duration: + if (nl.fNestedLoopsPro[3][h][AFO_CURRENTRUNDURATION]) { + nl.fNestedLoopsPro[3][h][AFO_CURRENTRUNDURATION]->Fill(ebye.fCurrentRunDuration, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); + } + // fill cos, 8p, all harmonics, vs. vertex z position: + if (nl.fNestedLoopsPro[3][h][AFO_VZ]) { + nl.fNestedLoopsPro[3][h][AFO_VZ]->Fill(ebye.fVz, std::cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 + dPhi4 - dPhi5 - dPhi6 - dPhi7 - dPhi8)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8); + } + } // for(int h=0; hGetNbinsX(); + nBinsNL = nl.fNestedLoopsPro[0][0][v]->GetNbinsX(); + if (nBinsQV != nBinsNL) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + LOGF(info, "\033[1;32m [%d] : %s\033[0m", v, res.fResultsProXaxisTitle[v].Data()); + for (int o = 0; o < 4; o++) { + LOGF(info, "\033[1;32m ==== <<%d>>-particle correlations ====\033[0m", 2 * (o + 1)); + for (int h = 0; h < gMaxHarmonic; h++) { + for (int b = 1; b <= nBinsQV; b++) { + if (mupa.fCorrelationsPro[o][h][v]) { + valueQV = mupa.fCorrelationsPro[o][h][v]->GetBinContent(b); + } + if (nl.fNestedLoopsPro[o][h][v]) { + valueNL = nl.fNestedLoopsPro[o][h][v]->GetBinContent(b); + } + if (std::abs(valueQV) > 0. && std::abs(valueNL) > 0.) { + LOGF(info, " bin=%d, h=%d, Q-vectors: %f", b, h + 1, valueQV); + LOGF(info, " bin=%d, h=%d, Nested loops: %f", b, h + 1, valueNL); + if (std::abs(valueQV - valueNL) > tc.fFloatingPointPrecision) { + LOGF(info, "\n\033[1;33m[%d][%d][%d] \033[0m\n", o, h, v); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } // if(std::abs(valueQV)>0. && std::abs(valueNL)>0.) + } // for(int b=1;b<=nBinsQV;b++) + } // for (int h = 0; h < gMaxHarmonic; h++) { + LOGF(info, ""); // new line + } // for(int o=0;o<4;o++) + } // for (int v = 0; v < 3; v++) + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void ComparisonNestedLoopsVsCorrelations() + +//============================================================ + +TComplex Q(int n, int wp) +{ + // Using the fact that Q{-n,p} = Q{n,p}^*. + + if (n >= 0) { + return qv.fQ[n][wp]; + } + return TComplex::Conjugate(qv.fQ[-n][wp]); + +} // TComplex FlowWithMultiparticleCorrelationsTask::Q(int n, int wp) + +//============================================================ + +TComplex One(int n1) +{ + // Generic expression . + + TComplex one = Q(n1, 1); + + return one; + +} // TComplex FlowWithMultiparticleCorrelationsTask::One(int n1) + +//============================================================ + +TComplex Two(int n1, int n2) +{ + // Generic two-particle correlation . + + TComplex two = Q(n1, 1) * Q(n2, 1) - Q(n1 + n2, 2); + + return two; + +} // TComplex FlowWithMultiparticleCorrelationsTask::Two(int n1, int n2) + +//============================================================ + +TComplex Three(int n1, int n2, int n3) +{ + // Generic three-particle correlation . + + TComplex three = Q(n1, 1) * Q(n2, 1) * Q(n3, 1) - Q(n1 + n2, 2) * Q(n3, 1) - + Q(n2, 1) * Q(n1 + n3, 2) - Q(n1, 1) * Q(n2 + n3, 2) + + 2. * Q(n1 + n2 + n3, 3); + + return three; + +} // TComplex Three(int n1, int n2, int n3) + +//============================================================ + +TComplex Four(int n1, int n2, int n3, int n4) +{ + // Generic four-particle correlation + // . + + TComplex four = + Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) - + Q(n1 + n2, 2) * Q(n3, 1) * Q(n4, 1) - + Q(n2, 1) * Q(n1 + n3, 2) * Q(n4, 1) - + Q(n1, 1) * Q(n2 + n3, 2) * Q(n4, 1) + 2. * Q(n1 + n2 + n3, 3) * Q(n4, 1) - + Q(n2, 1) * Q(n3, 1) * Q(n1 + n4, 2) + Q(n2 + n3, 2) * Q(n1 + n4, 2) - + Q(n1, 1) * Q(n3, 1) * Q(n2 + n4, 2) + Q(n1 + n3, 2) * Q(n2 + n4, 2) + + 2. * Q(n3, 1) * Q(n1 + n2 + n4, 3) - Q(n1, 1) * Q(n2, 1) * Q(n3 + n4, 2) + + Q(n1 + n2, 2) * Q(n3 + n4, 2) + 2. * Q(n2, 1) * Q(n1 + n3 + n4, 3) + + 2. * Q(n1, 1) * Q(n2 + n3 + n4, 3) - 6. * Q(n1 + n2 + n3 + n4, 4); + + return four; + +} // TComplex Four(int n1, int n2, int n3, int n4) + +//============================================================ + +TComplex Five(int n1, int n2, int n3, int n4, int n5) +{ + // Generic five-particle correlation . + + TComplex five = Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) - Q(n1 + n2, 2) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) - Q(n2, 1) * Q(n1 + n3, 2) * Q(n4, 1) * Q(n5, 1) - Q(n1, 1) * Q(n2 + n3, 2) * Q(n4, 1) * Q(n5, 1) + 2. * Q(n1 + n2 + n3, 3) * Q(n4, 1) * Q(n5, 1) - Q(n2, 1) * Q(n3, 1) * Q(n1 + n4, 2) * Q(n5, 1) + Q(n2 + n3, 2) * Q(n1 + n4, 2) * Q(n5, 1) - Q(n1, 1) * Q(n3, 1) * Q(n2 + n4, 2) * Q(n5, 1) + Q(n1 + n3, 2) * Q(n2 + n4, 2) * Q(n5, 1) + 2. * Q(n3, 1) * Q(n1 + n2 + n4, 3) * Q(n5, 1) - Q(n1, 1) * Q(n2, 1) * Q(n3 + n4, 2) * Q(n5, 1) + Q(n1 + n2, 2) * Q(n3 + n4, 2) * Q(n5, 1) + 2. * Q(n2, 1) * Q(n1 + n3 + n4, 3) * Q(n5, 1) + 2. * Q(n1, 1) * Q(n2 + n3 + n4, 3) * Q(n5, 1) - 6. * Q(n1 + n2 + n3 + n4, 4) * Q(n5, 1) - Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n1 + n5, 2) + Q(n2 + n3, 2) * Q(n4, 1) * Q(n1 + n5, 2) + Q(n3, 1) * Q(n2 + n4, 2) * Q(n1 + n5, 2) + Q(n2, 1) * Q(n3 + n4, 2) * Q(n1 + n5, 2) - 2. * Q(n2 + n3 + n4, 3) * Q(n1 + n5, 2) - Q(n1, 1) * Q(n3, 1) * Q(n4, 1) * Q(n2 + n5, 2) + Q(n1 + n3, 2) * Q(n4, 1) * Q(n2 + n5, 2) + Q(n3, 1) * Q(n1 + n4, 2) * Q(n2 + n5, 2) + Q(n1, 1) * Q(n3 + n4, 2) * Q(n2 + n5, 2) - 2. * Q(n1 + n3 + n4, 3) * Q(n2 + n5, 2) + 2. * Q(n3, 1) * Q(n4, 1) * Q(n1 + n2 + n5, 3) - 2. * Q(n3 + n4, 2) * Q(n1 + n2 + n5, 3) - Q(n1, 1) * Q(n2, 1) * Q(n4, 1) * Q(n3 + n5, 2) + Q(n1 + n2, 2) * Q(n4, 1) * Q(n3 + n5, 2) + Q(n2, 1) * Q(n1 + n4, 2) * Q(n3 + n5, 2) + Q(n1, 1) * Q(n2 + n4, 2) * Q(n3 + n5, 2) - 2. * Q(n1 + n2 + n4, 3) * Q(n3 + n5, 2) + 2. * Q(n2, 1) * Q(n4, 1) * Q(n1 + n3 + n5, 3) - 2. * Q(n2 + n4, 2) * Q(n1 + n3 + n5, 3) + 2. * Q(n1, 1) * Q(n4, 1) * Q(n2 + n3 + n5, 3) - 2. * Q(n1 + n4, 2) * Q(n2 + n3 + n5, 3) - 6. * Q(n4, 1) * Q(n1 + n2 + n3 + n5, 4) - Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4 + n5, 2) + Q(n1 + n2, 2) * Q(n3, 1) * Q(n4 + n5, 2) + Q(n2, 1) * Q(n1 + n3, 2) * Q(n4 + n5, 2) + Q(n1, 1) * Q(n2 + n3, 2) * Q(n4 + n5, 2) - 2. * Q(n1 + n2 + n3, 3) * Q(n4 + n5, 2) + 2. * Q(n2, 1) * Q(n3, 1) * Q(n1 + n4 + n5, 3) - 2. * Q(n2 + n3, 2) * Q(n1 + n4 + n5, 3) + 2. * Q(n1, 1) * Q(n3, 1) * Q(n2 + n4 + n5, 3) - 2. * Q(n1 + n3, 2) * Q(n2 + n4 + n5, 3) - 6. * Q(n3, 1) * Q(n1 + n2 + n4 + n5, 4) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n3 + n4 + n5, 3) - 2. * Q(n1 + n2, 2) * Q(n3 + n4 + n5, 3) - 6. * Q(n2, 1) * Q(n1 + n3 + n4 + n5, 4) - 6. * Q(n1, 1) * Q(n2 + n3 + n4 + n5, 4) + 24. * Q(n1 + n2 + n3 + n4 + n5, 5); + + return five; + +} // TComplex Five(int n1, int n2, int n3, int n4, int n5) + +//============================================================ + +TComplex Six(int n1, int n2, int n3, int n4, int n5, int n6) +{ + // Generic six-particle correlation . + + TComplex six = Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) - Q(n1 + n2, 2) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) - Q(n2, 1) * Q(n1 + n3, 2) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) - Q(n1, 1) * Q(n2 + n3, 2) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) + 2. * Q(n1 + n2 + n3, 3) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) - Q(n2, 1) * Q(n3, 1) * Q(n1 + n4, 2) * Q(n5, 1) * Q(n6, 1) + Q(n2 + n3, 2) * Q(n1 + n4, 2) * Q(n5, 1) * Q(n6, 1) - Q(n1, 1) * Q(n3, 1) * Q(n2 + n4, 2) * Q(n5, 1) * Q(n6, 1) + Q(n1 + n3, 2) * Q(n2 + n4, 2) * Q(n5, 1) * Q(n6, 1) + 2. * Q(n3, 1) * Q(n1 + n2 + n4, 3) * Q(n5, 1) * Q(n6, 1) - Q(n1, 1) * Q(n2, 1) * Q(n3 + n4, 2) * Q(n5, 1) * Q(n6, 1) + Q(n1 + n2, 2) * Q(n3 + n4, 2) * Q(n5, 1) * Q(n6, 1) + 2. * Q(n2, 1) * Q(n1 + n3 + n4, 3) * Q(n5, 1) * Q(n6, 1) + 2. * Q(n1, 1) * Q(n2 + n3 + n4, 3) * Q(n5, 1) * Q(n6, 1) - 6. * Q(n1 + n2 + n3 + n4, 4) * Q(n5, 1) * Q(n6, 1) - Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n1 + n5, 2) * Q(n6, 1) + Q(n2 + n3, 2) * Q(n4, 1) * Q(n1 + n5, 2) * Q(n6, 1) + Q(n3, 1) * Q(n2 + n4, 2) * Q(n1 + n5, 2) * Q(n6, 1) + Q(n2, 1) * Q(n3 + n4, 2) * Q(n1 + n5, 2) * Q(n6, 1) - 2. * Q(n2 + n3 + n4, 3) * Q(n1 + n5, 2) * Q(n6, 1) - Q(n1, 1) * Q(n3, 1) * Q(n4, 1) * Q(n2 + n5, 2) * Q(n6, 1) + Q(n1 + n3, 2) * Q(n4, 1) * Q(n2 + n5, 2) * Q(n6, 1) + Q(n3, 1) * Q(n1 + n4, 2) * Q(n2 + n5, 2) * Q(n6, 1) + Q(n1, 1) * Q(n3 + n4, 2) * Q(n2 + n5, 2) * Q(n6, 1) - 2. * Q(n1 + n3 + n4, 3) * Q(n2 + n5, 2) * Q(n6, 1) + 2. * Q(n3, 1) * Q(n4, 1) * Q(n1 + n2 + n5, 3) * Q(n6, 1) - 2. * Q(n3 + n4, 2) * Q(n1 + n2 + n5, 3) * Q(n6, 1) - Q(n1, 1) * Q(n2, 1) * Q(n4, 1) * Q(n3 + n5, 2) * Q(n6, 1) + Q(n1 + n2, 2) * Q(n4, 1) * Q(n3 + n5, 2) * Q(n6, 1) + Q(n2, 1) * Q(n1 + n4, 2) * Q(n3 + n5, 2) * Q(n6, 1) + Q(n1, 1) * Q(n2 + n4, 2) * Q(n3 + n5, 2) * Q(n6, 1) - 2. * Q(n1 + n2 + n4, 3) * Q(n3 + n5, 2) * Q(n6, 1) + 2. * Q(n2, 1) * Q(n4, 1) * Q(n1 + n3 + n5, 3) * Q(n6, 1) - 2. * Q(n2 + n4, 2) * Q(n1 + n3 + n5, 3) * Q(n6, 1) + 2. * Q(n1, 1) * Q(n4, 1) * Q(n2 + n3 + n5, 3) * Q(n6, 1) - 2. * Q(n1 + n4, 2) * Q(n2 + n3 + n5, 3) * Q(n6, 1) - 6. * Q(n4, 1) * Q(n1 + n2 + n3 + n5, 4) * Q(n6, 1) - Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4 + n5, 2) * Q(n6, 1) + Q(n1 + n2, 2) * Q(n3, 1) * Q(n4 + n5, 2) * Q(n6, 1) + Q(n2, 1) * Q(n1 + n3, 2) * Q(n4 + n5, 2) * Q(n6, 1) + Q(n1, 1) * Q(n2 + n3, 2) * Q(n4 + n5, 2) * Q(n6, 1) - 2. * Q(n1 + n2 + n3, 3) * Q(n4 + n5, 2) * Q(n6, 1) + 2. * Q(n2, 1) * Q(n3, 1) * Q(n1 + n4 + n5, 3) * Q(n6, 1) - 2. * Q(n2 + n3, 2) * Q(n1 + n4 + n5, 3) * Q(n6, 1) + 2. * Q(n1, 1) * Q(n3, 1) * Q(n2 + n4 + n5, 3) * Q(n6, 1) - 2. * Q(n1 + n3, 2) * Q(n2 + n4 + n5, 3) * Q(n6, 1) - 6. * Q(n3, 1) * Q(n1 + n2 + n4 + n5, 4) * Q(n6, 1) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n3 + n4 + n5, 3) * Q(n6, 1) - 2. * Q(n1 + n2, 2) * Q(n3 + n4 + n5, 3) * Q(n6, 1) - 6. * Q(n2, 1) * Q(n1 + n3 + n4 + n5, 4) * Q(n6, 1) - 6. * Q(n1, 1) * Q(n2 + n3 + n4 + n5, 4) * Q(n6, 1) + 24. * Q(n1 + n2 + n3 + n4 + n5, 5) * Q(n6, 1) - Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n1 + n6, 2) + Q(n2 + n3, 2) * Q(n4, 1) * Q(n5, 1) * Q(n1 + n6, 2) + Q(n3, 1) * Q(n2 + n4, 2) * Q(n5, 1) * Q(n1 + n6, 2) + Q(n2, 1) * Q(n3 + n4, 2) * Q(n5, 1) * Q(n1 + n6, 2) - 2. * Q(n2 + n3 + n4, 3) * Q(n5, 1) * Q(n1 + n6, 2) + Q(n3, 1) * Q(n4, 1) * Q(n2 + n5, 2) * Q(n1 + n6, 2) - Q(n3 + n4, 2) * Q(n2 + n5, 2) * Q(n1 + n6, 2) + Q(n2, 1) * Q(n4, 1) * Q(n3 + n5, 2) * Q(n1 + n6, 2) - Q(n2 + n4, 2) * Q(n3 + n5, 2) * Q(n1 + n6, 2) - 2. * Q(n4, 1) * Q(n2 + n3 + n5, 3) * Q(n1 + n6, 2) + Q(n2, 1) * Q(n3, 1) * Q(n4 + n5, 2) * Q(n1 + n6, 2) - Q(n2 + n3, 2) * Q(n4 + n5, 2) * Q(n1 + n6, 2) - 2. * Q(n3, 1) * Q(n2 + n4 + n5, 3) * Q(n1 + n6, 2) - 2. * Q(n2, 1) * Q(n3 + n4 + n5, 3) * Q(n1 + n6, 2) + 6. * Q(n2 + n3 + n4 + n5, 4) * Q(n1 + n6, 2) - Q(n1, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n2 + n6, 2) + Q(n1 + n3, 2) * Q(n4, 1) * Q(n5, 1) * Q(n2 + n6, 2) + Q(n3, 1) * Q(n1 + n4, 2) * Q(n5, 1) * Q(n2 + n6, 2) + Q(n1, 1) * Q(n3 + n4, 2) * Q(n5, 1) * Q(n2 + n6, 2) - 2. * Q(n1 + n3 + n4, 3) * Q(n5, 1) * Q(n2 + n6, 2) + Q(n3, 1) * Q(n4, 1) * Q(n1 + n5, 2) * Q(n2 + n6, 2) - Q(n3 + n4, 2) * Q(n1 + n5, 2) * Q(n2 + n6, 2) + Q(n1, 1) * Q(n4, 1) * Q(n3 + n5, 2) * Q(n2 + n6, 2) - Q(n1 + n4, 2) * Q(n3 + n5, 2) * Q(n2 + n6, 2) - 2. * Q(n4, 1) * Q(n1 + n3 + n5, 3) * Q(n2 + n6, 2) + Q(n1, 1) * Q(n3, 1) * Q(n4 + n5, 2) * Q(n2 + n6, 2) - Q(n1 + n3, 2) * Q(n4 + n5, 2) * Q(n2 + n6, 2) - 2. * Q(n3, 1) * Q(n1 + n4 + n5, 3) * Q(n2 + n6, 2) - 2. * Q(n1, 1) * Q(n3 + n4 + n5, 3) * Q(n2 + n6, 2) + 6. * Q(n1 + n3 + n4 + n5, 4) * Q(n2 + n6, 2) + 2. * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n1 + n2 + n6, 3) - 2. * Q(n3 + n4, 2) * Q(n5, 1) * Q(n1 + n2 + n6, 3) - 2. * Q(n4, 1) * Q(n3 + n5, 2) * Q(n1 + n2 + n6, 3) - 2. * Q(n3, 1) * Q(n4 + n5, 2) * Q(n1 + n2 + n6, 3) + 4. * Q(n3 + n4 + n5, 3) * Q(n1 + n2 + n6, 3) - Q(n1, 1) * Q(n2, 1) * Q(n4, 1) * Q(n5, 1) * Q(n3 + n6, 2) + Q(n1 + n2, 2) * Q(n4, 1) * Q(n5, 1) * Q(n3 + n6, 2) + Q(n2, 1) * Q(n1 + n4, 2) * Q(n5, 1) * Q(n3 + n6, 2) + Q(n1, 1) * Q(n2 + n4, 2) * Q(n5, 1) * Q(n3 + n6, 2) - 2. * Q(n1 + n2 + n4, 3) * Q(n5, 1) * Q(n3 + n6, 2) + Q(n2, 1) * Q(n4, 1) * Q(n1 + n5, 2) * Q(n3 + n6, 2) - Q(n2 + n4, 2) * Q(n1 + n5, 2) * Q(n3 + n6, 2) + Q(n1, 1) * Q(n4, 1) * Q(n2 + n5, 2) * Q(n3 + n6, 2) - Q(n1 + n4, 2) * Q(n2 + n5, 2) * Q(n3 + n6, 2) - 2. * Q(n4, 1) * Q(n1 + n2 + n5, 3) * Q(n3 + n6, 2) + Q(n1, 1) * Q(n2, 1) * Q(n4 + n5, 2) * Q(n3 + n6, 2) - Q(n1 + n2, 2) * Q(n4 + n5, 2) * Q(n3 + n6, 2) - 2. * Q(n2, 1) * Q(n1 + n4 + n5, 3) * Q(n3 + n6, 2) - 2. * Q(n1, 1) * Q(n2 + n4 + n5, 3) * Q(n3 + n6, 2) + 6. * Q(n1 + n2 + n4 + n5, 4) * Q(n3 + n6, 2) + 2. * Q(n2, 1) * Q(n4, 1) * Q(n5, 1) * Q(n1 + n3 + n6, 3) - 2. * Q(n2 + n4, 2) * Q(n5, 1) * Q(n1 + n3 + n6, 3) - 2. * Q(n4, 1) * Q(n2 + n5, 2) * Q(n1 + n3 + n6, 3) - 2. * Q(n2, 1) * Q(n4 + n5, 2) * Q(n1 + n3 + n6, 3) + 4. * Q(n2 + n4 + n5, 3) * Q(n1 + n3 + n6, 3) + 2. * Q(n1, 1) * Q(n4, 1) * Q(n5, 1) * Q(n2 + n3 + n6, 3) - 2. * Q(n1 + n4, 2) * Q(n5, 1) * Q(n2 + n3 + n6, 3) - 2. * Q(n4, 1) * Q(n1 + n5, 2) * Q(n2 + n3 + n6, 3) - 2. * Q(n1, 1) * Q(n4 + n5, 2) * Q(n2 + n3 + n6, 3) + 4. * Q(n1 + n4 + n5, 3) * Q(n2 + n3 + n6, 3) - 6. * Q(n4, 1) * Q(n5, 1) * Q(n1 + n2 + n3 + n6, 4) + 6. * Q(n4 + n5, 2) * Q(n1 + n2 + n3 + n6, 4) - Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n5, 1) * Q(n4 + n6, 2) + Q(n1 + n2, 2) * Q(n3, 1) * Q(n5, 1) * Q(n4 + n6, 2) + Q(n2, 1) * Q(n1 + n3, 2) * Q(n5, 1) * Q(n4 + n6, 2) + Q(n1, 1) * Q(n2 + n3, 2) * Q(n5, 1) * Q(n4 + n6, 2) - 2. * Q(n1 + n2 + n3, 3) * Q(n5, 1) * Q(n4 + n6, 2) + Q(n2, 1) * Q(n3, 1) * Q(n1 + n5, 2) * Q(n4 + n6, 2) - Q(n2 + n3, 2) * Q(n1 + n5, 2) * Q(n4 + n6, 2) + Q(n1, 1) * Q(n3, 1) * Q(n2 + n5, 2) * Q(n4 + n6, 2) - Q(n1 + n3, 2) * Q(n2 + n5, 2) * Q(n4 + n6, 2) - 2. * Q(n3, 1) * Q(n1 + n2 + n5, 3) * Q(n4 + n6, 2) + Q(n1, 1) * Q(n2, 1) * Q(n3 + n5, 2) * Q(n4 + n6, 2) - Q(n1 + n2, 2) * Q(n3 + n5, 2) * Q(n4 + n6, 2) - 2. * Q(n2, 1) * Q(n1 + n3 + n5, 3) * Q(n4 + n6, 2) - 2. * Q(n1, 1) * Q(n2 + n3 + n5, 3) * Q(n4 + n6, 2) + 6. * Q(n1 + n2 + n3 + n5, 4) * Q(n4 + n6, 2) + 2. * Q(n2, 1) * Q(n3, 1) * Q(n5, 1) * Q(n1 + n4 + n6, 3) - 2. * Q(n2 + n3, 2) * Q(n5, 1) * Q(n1 + n4 + n6, 3) - 2. * Q(n3, 1) * Q(n2 + n5, 2) * Q(n1 + n4 + n6, 3) - 2. * Q(n2, 1) * Q(n3 + n5, 2) * Q(n1 + n4 + n6, 3) + 4. * Q(n2 + n3 + n5, 3) * Q(n1 + n4 + n6, 3) + 2. * Q(n1, 1) * Q(n3, 1) * Q(n5, 1) * Q(n2 + n4 + n6, 3) - 2. * Q(n1 + n3, 2) * Q(n5, 1) * Q(n2 + n4 + n6, 3) - 2. * Q(n3, 1) * Q(n1 + n5, 2) * Q(n2 + n4 + n6, 3) - 2. * Q(n1, 1) * Q(n3 + n5, 2) * Q(n2 + n4 + n6, 3) + 4. * Q(n1 + n3 + n5, 3) * Q(n2 + n4 + n6, 3) - 6. * Q(n3, 1) * Q(n5, 1) * Q(n1 + n2 + n4 + n6, 4) + 6. * Q(n3 + n5, 2) * Q(n1 + n2 + n4 + n6, 4) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n5, 1) * Q(n3 + n4 + n6, 3) - 2. * Q(n1 + n2, 2) * Q(n5, 1) * Q(n3 + n4 + n6, 3) - 2. * Q(n2, 1) * Q(n1 + n5, 2) * Q(n3 + n4 + n6, 3) - 2. * Q(n1, 1) * Q(n2 + n5, 2) * Q(n3 + n4 + n6, 3) + 4. * Q(n1 + n2 + n5, 3) * Q(n3 + n4 + n6, 3) - 6. * Q(n2, 1) * Q(n5, 1) * Q(n1 + n3 + n4 + n6, 4) + 6. * Q(n2 + n5, 2) * Q(n1 + n3 + n4 + n6, 4) - 6. * Q(n1, 1) * Q(n5, 1) * Q(n2 + n3 + n4 + n6, 4) + 6. * Q(n1 + n5, 2) * Q(n2 + n3 + n4 + n6, 4) + 24. * Q(n5, 1) * Q(n1 + n2 + n3 + n4 + n6, 5) - Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5 + n6, 2) + Q(n1 + n2, 2) * Q(n3, 1) * Q(n4, 1) * Q(n5 + n6, 2) + Q(n2, 1) * Q(n1 + n3, 2) * Q(n4, 1) * Q(n5 + n6, 2) + Q(n1, 1) * Q(n2 + n3, 2) * Q(n4, 1) * Q(n5 + n6, 2) - 2. * Q(n1 + n2 + n3, 3) * Q(n4, 1) * Q(n5 + n6, 2) + Q(n2, 1) * Q(n3, 1) * Q(n1 + n4, 2) * Q(n5 + n6, 2) - Q(n2 + n3, 2) * Q(n1 + n4, 2) * Q(n5 + n6, 2) + Q(n1, 1) * Q(n3, 1) * Q(n2 + n4, 2) * Q(n5 + n6, 2) - Q(n1 + n3, 2) * Q(n2 + n4, 2) * Q(n5 + n6, 2) - 2. * Q(n3, 1) * Q(n1 + n2 + n4, 3) * Q(n5 + n6, 2) + Q(n1, 1) * Q(n2, 1) * Q(n3 + n4, 2) * Q(n5 + n6, 2) - Q(n1 + n2, 2) * Q(n3 + n4, 2) * Q(n5 + n6, 2) - 2. * Q(n2, 1) * Q(n1 + n3 + n4, 3) * Q(n5 + n6, 2) - 2. * Q(n1, 1) * Q(n2 + n3 + n4, 3) * Q(n5 + n6, 2) + 6. * Q(n1 + n2 + n3 + n4, 4) * Q(n5 + n6, 2) + 2. * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n1 + n5 + n6, 3) - 2. * Q(n2 + n3, 2) * Q(n4, 1) * Q(n1 + n5 + n6, 3) - 2. * Q(n3, 1) * Q(n2 + n4, 2) * Q(n1 + n5 + n6, 3) - 2. * Q(n2, 1) * Q(n3 + n4, 2) * Q(n1 + n5 + n6, 3) + 4. * Q(n2 + n3 + n4, 3) * Q(n1 + n5 + n6, 3) + 2. * Q(n1, 1) * Q(n3, 1) * Q(n4, 1) * Q(n2 + n5 + n6, 3) - 2. * Q(n1 + n3, 2) * Q(n4, 1) * Q(n2 + n5 + n6, 3) - 2. * Q(n3, 1) * Q(n1 + n4, 2) * Q(n2 + n5 + n6, 3) - 2. * Q(n1, 1) * Q(n3 + n4, 2) * Q(n2 + n5 + n6, 3) + 4. * Q(n1 + n3 + n4, 3) * Q(n2 + n5 + n6, 3) - 6. * Q(n3, 1) * Q(n4, 1) * Q(n1 + n2 + n5 + n6, 4) + 6. * Q(n3 + n4, 2) * Q(n1 + n2 + n5 + n6, 4) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n4, 1) * Q(n3 + n5 + n6, 3) - 2. * Q(n1 + n2, 2) * Q(n4, 1) * Q(n3 + n5 + n6, 3) - 2. * Q(n2, 1) * Q(n1 + n4, 2) * Q(n3 + n5 + n6, 3) - 2. * Q(n1, 1) * Q(n2 + n4, 2) * Q(n3 + n5 + n6, 3) + 4. * Q(n1 + n2 + n4, 3) * Q(n3 + n5 + n6, 3) - 6. * Q(n2, 1) * Q(n4, 1) * Q(n1 + n3 + n5 + n6, 4) + 6. * Q(n2 + n4, 2) * Q(n1 + n3 + n5 + n6, 4) - 6. * Q(n1, 1) * Q(n4, 1) * Q(n2 + n3 + n5 + n6, 4) + 6. * Q(n1 + n4, 2) * Q(n2 + n3 + n5 + n6, 4) + 24. * Q(n4, 1) * Q(n1 + n2 + n3 + n5 + n6, 5) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4 + n5 + n6, 3) - 2. * Q(n1 + n2, 2) * Q(n3, 1) * Q(n4 + n5 + n6, 3) - 2. * Q(n2, 1) * Q(n1 + n3, 2) * Q(n4 + n5 + n6, 3) - 2. * Q(n1, 1) * Q(n2 + n3, 2) * Q(n4 + n5 + n6, 3) + 4. * Q(n1 + n2 + n3, 3) * Q(n4 + n5 + n6, 3) - 6. * Q(n2, 1) * Q(n3, 1) * Q(n1 + n4 + n5 + n6, 4) + 6. * Q(n2 + n3, 2) * Q(n1 + n4 + n5 + n6, 4) - 6. * Q(n1, 1) * Q(n3, 1) * Q(n2 + n4 + n5 + n6, 4) + 6. * Q(n1 + n3, 2) * Q(n2 + n4 + n5 + n6, 4) + 24. * Q(n3, 1) * Q(n1 + n2 + n4 + n5 + n6, 5) - 6. * Q(n1, 1) * Q(n2, 1) * Q(n3 + n4 + n5 + n6, 4) + 6. * Q(n1 + n2, 2) * Q(n3 + n4 + n5 + n6, 4) + 24. * Q(n2, 1) * Q(n1 + n3 + n4 + n5 + n6, 5) + 24. * Q(n1, 1) * Q(n2 + n3 + n4 + n5 + n6, 5) - 120. * Q(n1 + n2 + n3 + n4 + n5 + n6, 6); + + return six; + +} // TComplex Six(int n1, int n2, int n3, int n4, int n5, int n6) + +//============================================================ + +TComplex Seven(int n1, int n2, int n3, int n4, int n5, int n6, int n7) +{ + // Generic seven-particle correlation . + + int harmonic[7] = {n1, n2, n3, n4, n5, n6, n7}; + + TComplex seven = Recursion(7, harmonic); + + return seven; + +} // end of TComplex Seven(int n1, int n2, int n3, int n4, int n5, int n6, int n7) + +//============================================================ + +TComplex Eight(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8) +{ + // Generic eight-particle correlation . + + int harmonic[8] = {n1, n2, n3, n4, n5, n6, n7, n8}; + + TComplex eight = Recursion(8, harmonic); + + return eight; + +} // end of Eight(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8) + +//============================================================ + +TComplex Nine(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9) +{ + // Generic nine-particle correlation . + + int harmonic[9] = {n1, n2, n3, n4, n5, n6, n7, n8, n9}; + + TComplex nine = Recursion(9, harmonic); + + return nine; + +} // end of TComplex Nine(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9) + +//============================================================ + +TComplex Ten(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10) +{ + // Generic ten-particle correlation . + + int harmonic[10] = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10}; + + TComplex ten = Recursion(10, harmonic); + + return ten; + +} // end of TComplex Ten(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10) + +//============================================================ + +TComplex Eleven(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11) +{ + // Generic eleven-particle correlation . + + int harmonic[11] = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11}; + + TComplex eleven = Recursion(11, harmonic); + + return eleven; + +} // end of TComplex Eleven(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11) + +//============================================================ + +TComplex Twelve(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11, int n12) +{ + // Generic twelve-particle correlation . + + int harmonic[12] = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12}; + + TComplex twelve = Recursion(12, harmonic); + + return twelve; + +} // end of TComplex Twelve(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int n11, int n12) + +//============================================================ + +TComplex Recursion(int n, int* harmonic, int mult = 1, int skip = 0) +{ + // Calculate multi-particle correlators by using recursion (an improved faster version) originally developed by + // Kristjan Gulbrandsen (gulbrand@nbi.dk). + + int nm1 = n - 1; + TComplex c(Q(harmonic[nm1], mult)); + if (nm1 == 0) + return c; + c *= Recursion(nm1, harmonic); + if (nm1 == skip) + return c; + + int multp1 = mult + 1; + int nm2 = n - 2; + int counter1 = 0; + int hhold = harmonic[counter1]; + harmonic[counter1] = harmonic[nm2]; + harmonic[nm2] = hhold + harmonic[nm1]; + TComplex c2(Recursion(nm1, harmonic, multp1, nm2)); + int counter2 = n - 3; + while (counter2 >= skip) { + harmonic[nm2] = harmonic[counter1]; + harmonic[counter1] = hhold; + ++counter1; + hhold = harmonic[counter1]; + harmonic[counter1] = harmonic[nm2]; + harmonic[nm2] = hhold + harmonic[nm1]; + c2 += Recursion(nm1, harmonic, multp1, counter2); + --counter2; + } + harmonic[nm2] = harmonic[counter1]; + harmonic[counter1] = hhold; + + if (mult == 1) + return c - c2; + return c - static_cast(mult) * c2; + +} // TComplex Recursion(int n, int* harmonic, int mult = 1, int skip = 0) + +//============================================================ + +void ResetQ() +{ + // Reset the components of generic Q-vectors. Use it whenever you call the + // standard functions for correlations, for some custom Q-vectors. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) // weight power + { + qv.fQ[h][wp] = TComplex(0., 0.); + } + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void ResetQ() + +//============================================================ + +void SetWeightsHist(TH1D* const hist, eWeights whichWeight) +{ + // Copy histogram holding weights from an external file to the corresponding data member. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // Finally: + hist->SetDirectory(0); + pw.fWeightsHist[whichWeight] = reinterpret_cast(hist); + + if (!pw.fWeightsHist[whichWeight]) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + // Cosmetics: TBI 20240216 do I really want to overwrite initial cosmetics, perhaps this shall go better into MakeWeights.C ? + // Or I could move all this to GetHistogramWithWeights, where in any case I am setting e.g. histogram title, etc. + TString sVariable[eWeights_N] = {"#varphi", "p_{t}", "#eta"}; // [phi,pt,eta] + TString sWeights[eWeights_N] = {"w_{#varphi}", "w_{p_{t}}", "w_{#eta}"}; + pw.fWeightsHist[whichWeight]->SetStats(false); + pw.fWeightsHist[whichWeight]->GetXaxis()->SetTitle(sVariable[whichWeight].Data()); + pw.fWeightsHist[whichWeight]->GetYaxis()->SetTitle(sWeights[whichWeight].Data()); + pw.fWeightsHist[whichWeight]->SetFillColor(eFillColor); + pw.fWeightsHist[whichWeight]->SetLineColor(eColor); + if (!pw.fWeightsList) { + LOGF(fatal, "\033[1;31m%s at line %d: fWeightsList is NULL. That means that you have called SetWeightsHist(...) in init(), before this TList was booked.\033[0m", __FUNCTION__, __LINE__); + } + pw.fWeightsList->Add(pw.fWeightsHist[whichWeight]); // This is working at the moment, because I am fetching all weights in Preprocess(), which is called after init() + // But if eventually it will be possible to fetch run number programatically in init(), I will have to re-think this line. + + // Flag: + pw.fUseWeights[whichWeight] = true; + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void SetWeightsHist(TH1D* const hist, eWeights whichWeight) + +//============================================================ + +void SetDiffWeightsHist(TH1D* const hist, eDiffWeights whichDiffWeight, int bin) +{ + // Copy histogram holding differential weights from an external file to the corresponding data member. + + // Remark: Do not edit histogram title here, because that's done in GetHistogramWithWeights(), because I have "filePath" info there locally. + // Only if I promote "filePath" to data members, re-think the design of this function, and what goes where. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // Finally: + hist->SetDirectory(0); + pw.fDiffWeightsHist[whichDiffWeight][bin] = reinterpret_cast(hist); + + if (!pw.fDiffWeightsHist[whichDiffWeight][bin]) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + // Cosmetics: TBI 20240216 do I really want to overwrite initial cosmetics, perhaps this shall go better into MakeWeights.C ? + // Or I could move all this to GetHistogramWithWeights, where in any case I am setting e.g. histogram title, etc. + TString sVariable[eDiffWeights_N] = {"#varphi", "#varphi"}; // yes, for the time being, x-axis is always phi + TString sWeights[eDiffWeights_N] = {"(w_{#varphi})_{| p_{T}}", "(w_{#varphi})_{| #eta}"}; + pw.fDiffWeightsHist[whichDiffWeight][bin]->SetStats(false); + pw.fDiffWeightsHist[whichDiffWeight][bin]->GetXaxis()->SetTitle(sVariable[whichDiffWeight].Data()); + pw.fDiffWeightsHist[whichDiffWeight][bin]->GetYaxis()->SetTitle(sWeights[whichDiffWeight].Data()); + pw.fDiffWeightsHist[whichDiffWeight][bin]->SetFillColor(eFillColor); + pw.fDiffWeightsHist[whichDiffWeight][bin]->SetLineColor(eColor); + pw.fWeightsList->Add(pw.fDiffWeightsHist[whichDiffWeight][bin]); // This is working at the moment, because I am fetching all weights in Preprocess(), which is called after init() + // But if eventually it will be possible to fetch run number programatically in init(), I will have to re-think this line. + + // Flag: + if (!pw.fUseDiffWeights[whichDiffWeight]) // yes, set it only once to true, for all bins + { + pw.fUseDiffWeights[whichDiffWeight] = true; + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // SetDiffWeightsHist(TH1D* const hist, const char *variable, int bin) + +//============================================================ + +void SetDiffWeightsSparse(THnSparseF* const sparse, eDiffWeightCategory dwc) +{ + // Copy sparse histogram holding differential phi, pt, eta, etc., weights from an external file to the corresponding data member. + + // Remark: Do not edit sparse histogram title here, because that's done in GetHistogramWithWeights(), because I have "filePath" info there locally. + // Only if I promote "filePath" to data members, re-think the design of this function, and what goes where. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // Finally: + // sparse->SetDirectory(0); I cannot use this for sparse + pw.fDiffWeightsSparse[dwc] = reinterpret_cast(sparse); + + if (!pw.fDiffWeightsSparse[dwc]) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + // Within current analysis the dimension of weight for each category won't change, therefore I store it permanently: + pw.fDWdimension[dwc] = pw.fDiffWeightsSparse[dwc]->GetNdimensions(); + + // I book here immediately vectors needed to fetch the weight from the right bin of THnSparse: + pw.fFindBinVector[dwc] = new TArrayD(pw.fDWdimension[dwc]); + + // Finally, add to corresponding TList: + pw.fWeightsList->Add(pw.fDiffWeightsSparse[dwc]); + + // TBI 20250530 check this code snippet - do I need it? + // // Cosmetics: TBI 20240216 do I really want to overwrite initial cosmetics, perhaps this shall go better into MakeWeights.C ? + // // Or I could move all this to GetHistogramWithWeights, where in any case I am setting e.g. histogram title, etc. + // TString sVariable[eDiffWeights_N] = {"#varphi", "#varphi"}; // yes, for the time being, x-axis is always phi + // TString sWeights[eDiffWeights_N] = {"(w_{#varphi})_{| p_{T}}", "(w_{#varphi})_{| #eta}"}; + // pw.fDiffWeightsSparse[whichDiffWeight][bin]->SetStats(false); + // pw.fDiffWeightsSparse[whichDiffWeight][bin]->GetXaxis()->SetTitle(sVariable[whichDiffWeight].Data()); + // pw.fDiffWeightsSparse[whichDiffWeight][bin]->GetYaxis()->SetTitle(sWeights[whichDiffWeight].Data()); + // pw.fDiffWeightsSparse[whichDiffWeight][bin]->SetFillColor(eFillColor); + // pw.fDiffWeightsSparse[whichDiffWeight][bin]->SetLineColor(eColor); + // pw.fWeightsList->Add(pw.fDiffWeightsSparse[whichDiffWeight][bin]); // This is working at the moment, because I am fetching all weights in Preprocess(), which is called after init() + // // But if eventually it will be possible to fetch run number programatically in init(), I will have to re-think this line. + + // // Flag: + // if (!pw.fUseDiffWeights[whichDiffWeight]) // yes, set it only once to true, for all bins + // { + // pw.fUseDiffWeights[whichDiffWeight] = true; + // } + + // if (tc.fVerbose) { + // ExitFunction(__FUNCTION__); + // } + +} // void SetDiffWeightsSparse(THnSparseF* const sparse) + +//============================================================ + +void SetCentralityWeightsHist(TH1D* const hist) +{ + // Copy histogram holding weights from an external file to the corresponding data member. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // Finally: + hist->SetDirectory(0); + cw.fCentralityWeightsHist = reinterpret_cast(hist); + + if (!cw.fCentralityWeightsHist) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + // Cosmetics: TBI 20240216 do I really want to overwrite initial cosmetics, perhaps this shall go better into MakeCentralityWeights.C ? + // Or I could move all this to GetHistogramWithCentralityWeights, where in any case I am setting e.g. histogram title, etc. + cw.fCentralityWeightsHist->SetStats(false); + cw.fCentralityWeightsHist->GetXaxis()->SetTitle("Centrality percentile"); + cw.fCentralityWeightsHist->GetYaxis()->SetTitle(Form("Centrality weight (%s)", ec.fsEventCuts[eCentralityEstimator].Data())); + cw.fCentralityWeightsHist->SetFillColor(eFillColor); + cw.fCentralityWeightsHist->SetLineColor(eColor); + if (!cw.fCentralityWeightsList) { + LOGF(fatal, "\033[1;31m%s at line %d: fCentralityWeightsList is NULL. That means that you have called SetCentralityWeightsHist(...) in init(), before this TList was booked.\033[0m", __FUNCTION__, __LINE__); + } + cw.fCentralityWeightsList->Add(cw.fCentralityWeightsHist); // This is working at the moment, because I am fetching all centrality weights in Preprocess(), which is called after init() + // But if eventually it will be possible to fetch run number programatically in init(), I will have to re-think this line. + + // Flag: + cw.fUseCentralityWeights = true; + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void SetCentralityWeightsHist(TH1D* const hist) + +//============================================================ + +TH1D* GetWeightsHist(eWeights whichWeight) +{ + // The standard getter. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // ... + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + + // Finally: + return pw.fWeightsHist[whichWeight]; + +} // TH1D* GetWeightsHist(eWeights whichWeigh) + +//============================================================ + +TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const char* variable, int bin = -1) +{ + // Get and return histogram with weights from an external file. + // If bin > 0, differential weights for that bin are searched for. + // If bin = -1, integrated weights are searched for, i.e. in this case "bin" variable has no effect. + // I do it this way, so as to condense GetHistogramWithWeights(...) and GetHistogramWithDiffWeights(...) from MuPa class in + // one routine here, so that I do not duplicate code related to CCDB access, etc. + + // TBI 20240504: Here I can keep const char* variable , i.e. no need to switch to enums, because this function is called only once, at init. + // Nevertheless, I could switch to enums and make it more general, i.e. I could introduce additional data members and configurables, + // for the names of histograms with weights. Like I did it in void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) + + // TBI 20241021 Strictly speaking, I do not need to pass here first 2 arguments, "filePath" and "runNumber", because they are initialized at call from data members. + // But since this function is called only once, it's not an important performance loss. But re-think the design here eventually. + // If I decide to promote filePath to data member, implement it as an array, to allow possibility that different catagories of weights are fetched from different external files. + + // a) Return value; + // b) Basic protection for arguments; + // c) Determine from filePath if the file in on a local machine, or in AliEn, or in CCDB; + // d) Handle the AliEn case; + // e) Handle the CCDB case; + // f) Handle the local case; + // g) The final touch on histogram with weights; + // h) Clone histogram and delete baseList (realising back the memory). + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + LOGF(info, "\033[1;33m filePath = %s\033[0m", filePath); + LOGF(info, "\033[1;33m runNumber = %s\033[0m", runNumber); + LOGF(info, "\033[1;33m variable = %s\033[0m", variable); + LOGF(info, "\033[1;33m bin = %d (if bin = -1, integrated weights are searched for)\033[0m", bin); + LOGF(info, "\033[1;33m fTaskName = %s\033[0m", tc.fTaskName.Data()); + } + + // a) Return value: + TH1D* hist = NULL; + TList* baseList = NULL; // base top-level list in the TFile, e.g. named "ccdb_object" + TList* listWithRuns = NULL; // nested list with run-wise TList's holding run-specific weights + + // b) Basic protection for arguments: + // Remark: below I do one more specific check. + if (!(TString(variable).EqualTo("phi") || TString(variable).EqualTo("pt") || TString(variable).EqualTo("eta") || + TString(variable).EqualTo("phipt") || TString(variable).EqualTo("phieta"))) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + // c) Determine from filePath if the file in on a local machine, or in home + // dir AliEn, or in CCDB: + // Algorithm: If filePath begins with "/alice/cern.ch/" then it's in home + // dir AliEn. If filePath begins with "/alice-ccdb.cern.ch/" then it's in + // CCDB. Therefore, files in AliEn and CCDB must be specified with abs path, + // for local files both abs and relative paths are just fine. + bool bFileIsInAliEn = false; + bool bFileIsInCCDB = false; + if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + bFileIsInAliEn = true; + } else { + if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { + bFileIsInCCDB = true; + } // else { + } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + + if (bFileIsInAliEn) { + // d) Handle the AliEn case: + TGrid* alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", ""); + if (!alien) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + TFile* weightsFile = TFile::Open(Form("alien://%s", filePath), "READ"); + if (!weightsFile) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + weightsFile->GetObject( + "ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name + // of base TList is "ccdb_object" also for + // AliEn case, see if I need to change this + if (!baseList) { + // weightsFile->ls(); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); + if (!listWithRuns) { + TString runNumberWithLeadingZeroes = "000"; + runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); + if (!listWithRuns) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } + + } else if (bFileIsInCCDB) { + + // e) Handle the CCDB case: Remember that here I do not access the file, + // instead directly object in that file. + // My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ + // Inspired by: + // 1. Discussion at: + // https://alice-talk.web.cern.ch/t/access-to-lhc-filling-scheme/1073/17 + // 2. See also: + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyGlobal.cxx + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyPerRun.cxx + // 3. O2 Analysis Tutorial 2.0: + // https://indico.cern.ch/event/1267433/timetable/#20230417.detailed + + ccdb->setURL("http://alice-ccdb.cern.ch"); + if (tc.fVerbose) { + LOGF(info, "\033[1;32mAccessing in CCDB %s\033[0m", TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data()); + } + + baseList = reinterpret_cast(ccdb->get(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data())); + + if (!baseList) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); + if (!listWithRuns) { + TString runNumberWithLeadingZeroes = "000"; + runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); + if (!listWithRuns) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } + + } else { + + // f) Handle the local case: + // TBI 20231008 In principle, also for the local case in O2, I could + // maintain the same local structure of weights as it was in AliPhysics. + // But for simplicity, in O2 I organize local weights in the + // same way as in AliEn or CCDB. + + // Check if the external ROOT file exists at specified path: + if (gSystem->AccessPathName(filePath, kFileExists)) { + LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + TFile* weightsFile = TFile::Open(filePath, "READ"); + if (!weightsFile) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + weightsFile->GetObject("ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name + // of base TList is "ccdb_object" also for + // local case, see if I need to change this + if (!baseList) { + // weightsFile->ls(); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); + if (!listWithRuns) { + TString runNumberWithLeadingZeroes = "000"; + runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); + if (!listWithRuns) { + // baseList->ls(); + LOGF(fatal, "\033[1;31m%s at line %d : this crash can happen if in the output file there is no list with weights for the current run number = %s\033[0m", __FUNCTION__, __LINE__, tc.fRunNumber.Data()); + } + } + + } // else { + + // g) The final touch on histogram with weights: + TString histName = ""; + if (-1 == bin) { + // Integrated weights: + if (!(TString(variable).EqualTo("phi") || TString(variable).EqualTo("pt") || TString(variable).EqualTo("eta"))) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + // fetch histogram directly from this list: + histName = TString::Format("%s_%s", variable, tc.fTaskName.Data()); + LOGF(info, "\033[1;33m%s at line %d : fetching directly hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + hist = reinterpret_cast(listWithRuns->FindObject(histName.Data())); + // if the previous search failed, descend recursively also into the nested lists: + if (!hist) { + LOGF(info, "\033[1;33m%s at line %d : previous attempt failed, fetching instead recursively hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + hist = reinterpret_cast(GetObjectFromList(listWithRuns, histName.Data())); + } + if (!hist) { + histName = TString::Format("%s", variable); // yes, for some simple tests I can have only histogram named e.g. 'phi' + LOGF(info, "\033[1;33m%s at line %d : last attempt, fetching instead hist with trivial name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + hist = reinterpret_cast(GetObjectFromList(listWithRuns, histName.Data())); + } + if (!hist) { + listWithRuns->ls(); + LOGF(fatal, "\033[1;31m%s at line %d : couldn't fetch hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + } + hist->SetDirectory(0); + hist->SetTitle(Form("%s, %s", filePath, runNumber)); // I have to do it here, because only here I have "filePath" av + + } else { + // Differential weights: + if (!(TString(variable).EqualTo("phipt") || TString(variable).EqualTo("phieta"))) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + // fetch histogram directly from this list: + histName = TString::Format("%s[%d]_%s", variable, bin, tc.fTaskName.Data()); + LOGF(info, "\033[1;33m%s at line %d : fetching directly hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + hist = reinterpret_cast(listWithRuns->FindObject(histName.Data())); + // if the previous search failed, descend recursively also into the nested lists: + if (!hist) { + LOGF(info, "\033[1;33m%s at line %d : previous attempt failed, fetching instead recursively hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + hist = reinterpret_cast(GetObjectFromList(listWithRuns, Form("%s[%d]_%s", variable, bin, tc.fTaskName.Data()))); + } + if (!hist) { + histName = TString::Format("%s[%d]", variable, bin); // yes, for some simple tests I can have only histogram named e.g. 'phipt[0]' + LOGF(info, "\033[1;33m%s at line %d : last attempt, fetching instead hist with trivial name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + hist = reinterpret_cast(GetObjectFromList(listWithRuns, histName.Data())); + } + if (!hist) { + listWithRuns->ls(); + LOGF(fatal, "\033[1;31m%s at line %d : couldn't fetch hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + } + + // *) insanity check for differential weights => check if boundaries of current bin are the same as bin boundaries for which these weights were calculated. + // This way I ensure that weights correspond to same kinematic cuts and binning as in current analysis. + // Current example format which was set in MakeWeights.C: someString(s), min < kinematic-variable-name < max + // Algorithm: IFS is " " and I take (N-1)th and (N-5)th entry: + TObjArray* oa = TString(hist->GetTitle()).Tokenize(" "); + if (!oa) { + LOGF(fatal, "in function \033[1;31m%s at line %d \n hist->GetTitle() = %s\033[0m", __FUNCTION__, __LINE__, hist->GetTitle()); + } + int nEntries = oa->GetEntries(); + + // I need to figure out corresponding variable from results histograms and its formatting: + eAsFunctionOf AFO = eAsFunctionOf_N; + const char* lVariableName = ""; + if (TString(variable).EqualTo("phipt")) { + AFO = AFO_PT; + lVariableName = FancyFormatting("Pt"); + } else if (TString(variable).EqualTo("phieta")) { + AFO = AFO_ETA; + lVariableName = FancyFormatting("Eta"); + } else { + LOGF(fatal, "\033[1;31m%s at line %d : name = %s is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(variable)); + } + + // Get min and max value for bin, stored locally: + float min = res.fResultsPro[AFO]->GetBinLowEdge(bin + 1); + float max = res.fResultsPro[AFO]->GetBinLowEdge(bin + 2); + if (min > max) { + LOGF(fatal, "\033[1;33m min = %f, max = %f, res.fResultsPro[AFO]->GetName() = %s\033[0m", min, max, res.fResultsPro[AFO]->GetName()); + } + + // Compare with min and max value stored in external weights.root file using MakeWeights.C: + if (!(std::abs(TString(oa->At(nEntries - 1)->GetName()).Atof() - max) < tc.fFloatingPointPrecision)) { + LOGF(info, "\033[1;33m hist->GetTitle() = %s, res.fResultsPro[AFO]->GetName() = %s\033[0m", hist->GetTitle(), res.fResultsPro[AFO]->GetName()); + LOGF(fatal, "in function \033[1;31m%s at line %d : mismatch in upper bin boundaries \n from title = %f , local = %f\033[0m", __FUNCTION__, __LINE__, TString(oa->At(nEntries - 1)->GetName()).Atof(), max); + } + if (!(std::abs(TString(oa->At(nEntries - 5)->GetName()).Atof() - min) < tc.fFloatingPointPrecision)) { + LOGF(info, "\033[1;33m hist->GetTitle() = %s, res.fResultsPro[AFO]->GetName() = %s\033[0m", hist->GetTitle(), res.fResultsPro[AFO]->GetName()); + LOGF(fatal, "in function \033[1;31m%s at line %d : mismatch in lower bin boundaries \n from title = %f , local = %f\033[0m", __FUNCTION__, __LINE__, TString(oa->At(nEntries - 5)->GetName()).Atof(), min); + } + delete oa; // yes, otherwise it's a memory leak + + // *) final settings and cosmetics: + hist->SetDirectory(0); + hist->SetTitle(Form("%s, %.2f < %s < %.2f", filePath, min, lVariableName, max)); + + } // else + + // TBI 20241021 if I need to split hist title across two lines, use this technique: + // hist->SetTitle(Form("#splitline{#scale[0.6]{%s}}{#scale[0.4]{%s}}",hist->GetTitle(),filePath)); + + // h) Clone histogram and delete baseList (realising back the memory): + // Remark: Yes, I have to clone here. + TH1D* histClone = reinterpret_cast(hist->Clone()); + delete baseList; // release back the memory if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void CalculateNestedLoops() + return histClone; + +} // TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const char* variable, int bin = -1) //============================================================ -void ComparisonNestedLoopsVsCorrelations() +THnSparseF* GetSparseHistogramWithWeights(const char* filePath, const char* runNumber, const char* whichCategory, const char* whichDimensions) { - // Compare analytic results from Q-vectors and brute force results from nested loops. - // Use only for small multiplicities, when nested loops are still feasible. - // Results have to be exactly the same in each case. + // Get and return sparse histogram with weights from an external file. + + // Remark 1: "whichCategory" always indicates the default x-axis (0th dimension), for instance for "differential phi weights" it's "phi" + + // Remark 2: "whichDimensions" is formatted as follows: __..., for instance "pt_cent", if weights are calculated differentially as a function of pt and centrality + // If empty, that is also fine, I am fetching integrated weights, for instance integrated phi-weights. + + // Remark 3: The nameing convention for sparse histogram in the output file is: __multiparticle-correlations-a-b_ + // a) I allow possibility that "multiparticle-correlations-a-b_" is not present in the name + // b) In HL, fTaskName is typically subwagon name. Therefoere, it's mandatory that for a given subwagon in HL, BOTH subwagon name and fTaskName are set to the same name + // TBI 20250215 If I can get within my task at run time subwagon name, I can automate this step. Check if that is possible + + // TBI 20240504: Here I can keep const char* variable , i.e. no need to switch to enums, because this function is called only once, at init. + // Nevertheless, I could switch to enums and make it more general, i.e. I could introduce additional data members and configurables, + // for the names of histograms with weights. Like I did it in void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) + + // TBI 20241021 Strictly speaking, I do not need to pass here first 2 arguments, "filePath" and "runNumber", because they are initialized at call from data members. + // But since this function is called only once, it's not an important performance loss. But re-think the design here eventually. + // If I decide to promote filePath to data member, implement it as an array, to allow possibility that different catagories of weights are fetched from different external files. + + // a) Return value; + // b) Basic protection for arguments; + // c) Determine from filePath if the file in on a local machine, or in AliEn, or in CCDB; + // d) Handle the AliEn case; + // e) Handle the CCDB case; + // f) Handle the local case; + // g) The final touch on sparse histogram with weights; + // h) Clone histogram and delete baseList (realising back the memory). if (tc.fVerbose) { StartFunction(__FUNCTION__); + LOGF(info, "\033[1;33m filePath = %s\033[0m", filePath); + LOGF(info, "\033[1;33m runNumber = %s\033[0m", runNumber); + LOGF(info, "\033[1;33m whichDimensions = %s\033[0m", whichDimensions); + } + + // a) Return value: + THnSparseF* sparseHist = NULL; + TList* baseList = NULL; // base top-level list in the TFile, e.g. named "ccdb_object" + TList* listWithRuns = NULL; // nested list with run-wise TList's holding run-specific weights + + // b) Basic protection for arguments: + // Remark: below I do one more specific check. + if (!(TString(whichCategory).EqualTo("phi"))) { // TBI 20250215 I could in the future extend support to differential pT weights, etc. + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + if (TString(whichDimensions).EqualTo("")) { + LOGF(warning, "\033[1;33m%s at line %d : whichDimensions is empty, accessing only integrated %s weights\033[0m", __FUNCTION__, __LINE__, whichCategory); } - Int_t nBinsQV = -44; - Int_t nBinsNL = -44; - Double_t valueQV = 0.; - Double_t valueNL = 0.; + // c) Determine from filePath if the file in on a local machine, or in home + // dir AliEn, or in CCDB: + // Algorithm: If filePath begins with "/alice/cern.ch/" then it's in home + // dir AliEn. If filePath begins with "/alice-ccdb.cern.ch/" then it's in + // CCDB. Therefore, files in AliEn and CCDB must be specified with abs path, + // for local files both abs and relative paths are just fine. + bool bFileIsInAliEn = false; + bool bFileIsInCCDB = false; + if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + bFileIsInAliEn = true; + } else { + if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { + bFileIsInCCDB = true; + } // else { + } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { // This corresponds to the ordering of variables in enum eAsFunctionOf . Here (for the time being) I compare only int, mult, cent and occu. - if (v == AFO_PT || v == AFO_ETA) { - continue; // TBI 20241112 correlations vs pt and vs eta are not implemented yet + if (bFileIsInAliEn) { + // d) Handle the AliEn case: + TGrid* alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", ""); + if (!alien) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - nBinsQV = mupa.fCorrelationsPro[0][0][v]->GetNbinsX(); - nBinsNL = nl.fNestedLoopsPro[0][0][v]->GetNbinsX(); - if (nBinsQV != nBinsNL) { + TFile* weightsFile = TFile::Open(Form("alien://%s", filePath), "READ"); + if (!weightsFile) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - LOGF(info, "\033[1;32m [%d] : %s\033[0m", v, res.fResultsProXaxisTitle[v].Data()); - for (Int_t o = 0; o < 4; o++) { - LOGF(info, "\033[1;32m ==== <<%d>>-particle correlations ====\033[0m", 2 * (o + 1)); - for (Int_t h = 0; h < gMaxHarmonic; h++) { - for (Int_t b = 1; b <= nBinsQV; b++) { - if (mupa.fCorrelationsPro[o][h][v]) { - valueQV = mupa.fCorrelationsPro[o][h][v]->GetBinContent(b); - } - if (nl.fNestedLoopsPro[o][h][v]) { - valueNL = nl.fNestedLoopsPro[o][h][v]->GetBinContent(b); - } - if (TMath::Abs(valueQV) > 0. && TMath::Abs(valueNL) > 0.) { - LOGF(info, " bin=%d, h=%d, Q-vectors: %f", b, h + 1, valueQV); - LOGF(info, " bin=%d, h=%d, Nested loops: %f", b, h + 1, valueNL); - if (TMath::Abs(valueQV - valueNL) > tc.fFloatingPointPrecision) { - LOGF(info, "\n\033[1;33m[%d][%d][%d] \033[0m\n", o, h, v); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - } // if(TMath::Abs(valueQV)>0. && TMath::Abs(valueNL)>0.) - } // for(Int_t b=1;b<=nBinsQV;b++) - } // for (Int_t h = 0; h < gMaxHarmonic; h++) { - LOGF(info, ""); // new line - } // for(Int_t o=0;o<4;o++) - } // for (Int_t v = 0; v < 3; v++) + + weightsFile->GetObject("ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name + // of base TList is "ccdb_object" also for + // AliEn case, see if I need to change this + if (!baseList) { + // weightsFile->ls(); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); + if (!listWithRuns) { + TString runNumberWithLeadingZeroes = "000"; + runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); + if (!listWithRuns) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } + + } else if (bFileIsInCCDB) { + + // e) Handle the CCDB case: Remember that here I do not access the file, + // instead directly object in that file. + // My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ + // Inspired by: + // 1. Discussion at: + // https://alice-talk.web.cern.ch/t/access-to-lhc-filling-scheme/1073/17 + // 2. See also: + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyGlobal.cxx + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyPerRun.cxx + // 3. O2 Analysis Tutorial 2.0: + // https://indico.cern.ch/event/1267433/timetable/#20230417.detailed + + ccdb->setURL("http://alice-ccdb.cern.ch"); + if (tc.fVerbose) { + LOGF(info, "\033[1;32mAccessing in CCDB %s\033[0m", TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data()); + } + + baseList = reinterpret_cast(ccdb->get(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data())); + + if (!baseList) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); + if (!listWithRuns) { + TString runNumberWithLeadingZeroes = "000"; + runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); + if (!listWithRuns) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } + + } else { + + // f) Handle the local case: + // TBI 20231008 In principle, also for the local case in O2, I could + // maintain the same local structure of weights as it was in AliPhysics. + // But for simplicity, in O2 I organize local weights in the + // same way as in AliEn or CCDB. + + // Check if the external ROOT file exists at specified path: + if (gSystem->AccessPathName(filePath, kFileExists)) { + LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + TFile* weightsFile = TFile::Open(filePath, "READ"); + if (!weightsFile) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + weightsFile->GetObject("ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name + // of base TList is "ccdb_object" also for + // local case, see if I need to change this + if (!baseList) { + // weightsFile->ls(); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); + if (!listWithRuns) { + TString runNumberWithLeadingZeroes = "000"; + runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); + if (!listWithRuns) { + // baseList->ls(); + LOGF(fatal, "\033[1;31m%s at line %d : this crash can happen if in the output file there is no list with weights for the current run number = %s\033[0m", __FUNCTION__, __LINE__, tc.fRunNumber.Data()); + } + } + + } // else { + + // g) The final touch on sparse histogram with weights: + TString sparseHistName = ""; + if (TString(whichDimensions).EqualTo("")) { + sparseHistName = TString::Format("%s_multiparticle-correlations-a-b", whichCategory); + } else if (TString(whichDimensions).BeginsWith("_")) { // TBI 20250215 alternativelly, I can remove leading "_" before calling this function + sparseHistName = TString::Format("%s%s_multiparticle-correlations-a-b", whichCategory, whichDimensions); + } else { + sparseHistName = TString::Format("%s_%s_multiparticle-correlations-a-b", whichCategory, whichDimensions); + } + // *) If not empty, I still need to appent TaskName (i.e. the cut name): + if (!TString(tc.fTaskName).EqualTo("")) { + sparseHistName += tc.fTaskName.Data(); + } + + // 1. fetch histogram directly from this list: const char* whichCategory, const char* whichDimensions + LOGF(info, "\033[1;33m%s at line %d : fetching directly from the list sparse histogram with name = %s\033[0m", __FUNCTION__, __LINE__, sparseHistName.Data()); + sparseHist = reinterpret_cast(listWithRuns->FindObject(sparseHistName.Data())); + if (!sparseHist) { + // try once again by chopping off "multiparticle-correlations-a-b_" from name: + TString tmp = sparseHistName; // yes, because "ReplaceAll" below replaces in-place, and I will need sparseHistName unmodified still later + sparseHist = reinterpret_cast(listWithRuns->FindObject(tmp.ReplaceAll("multiparticle-correlations-a-b_", ""))); + } + + // 2. if the previous search failed, descend recursively into the nested lists: + if (!sparseHist) { + LOGF(info, "\033[1;33m%s at line %d : previous attempt failed, fetching instead recursively sparse histogram with name = %s\033[0m", __FUNCTION__, __LINE__, sparseHistName.Data()); + sparseHist = reinterpret_cast(GetObjectFromList(listWithRuns, sparseHistName.Data())); + if (!sparseHist) { + // try once again by chopping off "multiparticle-correlations-a-b_" from name: + TString tmp = sparseHistName; // yes, because "ReplaceAll" below replaces in-place, and I will need sparseHistName unmodified still later + sparseHist = reinterpret_cast(GetObjectFromList(listWithRuns, tmp.ReplaceAll("multiparticle-correlations-a-b_", ""))); + } + } + + if (!sparseHist) { + listWithRuns->ls(); + LOGF(fatal, "\033[1;31m%s at line %d : couldn't fetch sparse histogram with name = %s from this list\033[0m", __FUNCTION__, __LINE__, sparseHistName.Data()); + } + + sparseHist->SetTitle(Form("%s, %s", filePath, runNumber)); // I have to do it here, because only here I have "filePath" available + + // hist->SetTitle(Form("%s, %.2f < %s < %.2f", filePath, min, lVariableName, max)); + + // TBI 20250530 check this code snippet - do I need it? + // // *) insanity check for differential weights => check if boundaries of current bin are the same as bin boundaries for which these weights were calculated. + // // This way I ensure that weights correspond to same kinematic cuts and binning as in current analysis. + // // Current example format which was set in MakeWeights.C: someString(s), min < kinematic-variable-name < max + // // Algorithm: IFS is " " and I take (N-1)th and (N-5)th entry: + // TObjArray* oa = TString(hist->GetTitle()).Tokenize(" "); + // if (!oa) { + // LOGF(fatal, "in function \033[1;31m%s at line %d \n hist->GetTitle() = %s\033[0m", __FUNCTION__, __LINE__, hist->GetTitle()); + // } + // int nEntries = oa->GetEntries(); + // + // // I need to figure out corresponding variable from results histograms and its formatting: + // eAsFunctionOf AFO = eAsFunctionOf_N; + // const char* lVariableName = ""; + // if (TString(variable).EqualTo("phipt")) { + // AFO = AFO_PT; + // lVariableName = FancyFormatting("Pt"); + // } else if (TString(variable).EqualTo("phieta")) { + // AFO = AFO_ETA; + // lVariableName = FancyFormatting("Eta"); + // } else { + // LOGF(fatal, "\033[1;31m%s at line %d : name = %s is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(variable)); + // } + // + // // Get min and max value for bin, stored locally: + // float min = res.fResultsPro[AFO]->GetBinLowEdge(bin + 1); + // float max = res.fResultsPro[AFO]->GetBinLowEdge(bin + 2); + // if (min > max) { + // LOGF(fatal, "\033[1;33m min = %f, max = %f, res.fResultsPro[AFO]->GetName() = %s\033[0m", min, max, res.fResultsPro[AFO]->GetName()); + // } + // + // // Compare with min and max value stored in external weights.root file using MakeWeights.C: + // if (!(std::abs(TString(oa->At(nEntries - 1)->GetName()).Atof() - max) < tc.fFloatingPointPrecision)) { + // LOGF(info, "\033[1;33m hist->GetTitle() = %s, res.fResultsPro[AFO]->GetName() = %s\033[0m", hist->GetTitle(), res.fResultsPro[AFO]->GetName()); + // LOGF(fatal, "in function \033[1;31m%s at line %d : mismatch in upper bin boundaries \n from title = %f , local = %f\033[0m", __FUNCTION__, __LINE__, TString(oa->At(nEntries - 1)->GetName()).Atof(), max); + // } + // if (!(std::abs(TString(oa->At(nEntries - 5)->GetName()).Atof() - min) < tc.fFloatingPointPrecision)) { + // LOGF(info, "\033[1;33m hist->GetTitle() = %s, res.fResultsPro[AFO]->GetName() = %s\033[0m", hist->GetTitle(), res.fResultsPro[AFO]->GetName()); + // LOGF(fatal, "in function \033[1;31m%s at line %d : mismatch in lower bin boundaries \n from title = %f , local = %f\033[0m", __FUNCTION__, __LINE__, TString(oa->At(nEntries - 5)->GetName()).Atof(), min); + // } + // delete oa; // yes, otherwise it's a memory leak + // + // // *) final settings and cosmetics: + // hist->SetDirectory(0); + + // TBI 20241021 if I need to split hist title across two lines, use this technique: + // hist->SetTitle(Form("#splitline{#scale[0.6]{%s}}{#scale[0.4]{%s}}",hist->GetTitle(),filePath)); + + // h) Clone histogram and delete baseList (realising back the memory): + // Remark: Yes, I have to clone here. + THnSparseF* sparseHistClone = reinterpret_cast(sparseHist->Clone()); + delete baseList; // release back the memory if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void ComparisonNestedLoopsVsCorrelations() + return sparseHistClone; + +} // THnSparseF* GetSparseHistogramWithWeights(const char* filePath, const char* runNumber, const char* whichCategory, const char* whichDimensions) //============================================================ -TComplex Q(Int_t n, Int_t wp) +TH1D* GetHistogramWithCentralityWeights(const char* filePath, const char* runNumber) { - // Using the fact that Q{-n,p} = Q{n,p}^*. + // Get and return histogram with centrality weights from an external file. - if (n >= 0) { - return qv.fQ[n][wp]; - } - return TComplex::Conjugate(qv.fQ[-n][wp]); + // TBI 20241118 Shall I merge this function with GetHistogramWithWeights(...) as there is a bit of code bloat? -} // TComplex FlowWithMultiparticleCorrelationsTask::Q(Int_t n, Int_t wp) + // TBI 20241021 Strictly speaking, I do not need to pass here 2 arguments, "filePath" and "runNumber", because they are initialized at call from data members. + // But since this function is called only once, it's not an important performance loss. But re-think the design here eventually. -//============================================================ + // a) Return value; + // b) Basic protection for arguments; + // c) Determine from filePath if the file in on a local machine, or in AliEn, or in CCDB; + // d) Handle the AliEn case; + // e) Handle the CCDB case; + // f) Handle the local case; + // g) The final touch on histogram with centrality weights; + // h) Clone histogram and delete baseList (realising back the memory). -TComplex One(Int_t n1) -{ - // Generic expression . + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + LOGF(info, "\033[1;33m filePath = %s\033[0m", filePath); + LOGF(info, "\033[1;33m runNumber = %s\033[0m", runNumber); + LOGF(info, "\033[1;33m fTaskName = %s\033[0m", tc.fTaskName.Data()); + } - TComplex one = Q(n1, 1); + // a) Return value: + TH1D* hist = NULL; + TList* baseList = NULL; // base top-level list in the TFile, e.g. named "ccdb_object" + TList* listWithRuns = NULL; // nested list with run-wise TList's holding run-specific weights - return one; + // b) Basic protection for arguments: + // ... -} // TComplex FlowWithMultiparticleCorrelationsTask::One(Int_t n1) + // c) Determine from filePath if the file in on a local machine, or in home dir AliEn, or in CCDB: + // Algorithm: If filePath begins with "/alice/cern.ch/" then it's in home + // dir AliEn. If filePath begins with "/alice-ccdb.cern.ch/" then it's in + // CCDB. Therefore, files in AliEn and CCDB must be specified with abs path, + // for local files both abs and relative paths are just fine. + bool bFileIsInAliEn = false; + bool bFileIsInCCDB = false; + if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + bFileIsInAliEn = true; + } else { + if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { + bFileIsInCCDB = true; + } // else { + } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { -//============================================================ + if (bFileIsInAliEn) { + // d) Handle the AliEn case: + TGrid* alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", ""); + if (!alien) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + TFile* centralityWeightsFile = TFile::Open(Form("alien://%s", filePath), "READ"); + if (!centralityWeightsFile) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } -TComplex Two(Int_t n1, Int_t n2) -{ - // Generic two-particle correlation . + centralityWeightsFile->GetObject("ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name + // of base TList is "ccdb_object" also for + // AliEn case, see if I need to change this + if (!baseList) { + // centralityWeightsFile->ls(); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } - TComplex two = Q(n1, 1) * Q(n2, 1) - Q(n1 + n2, 2); + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); + if (!listWithRuns) { + TString runNumberWithLeadingZeroes = "000"; + runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); + if (!listWithRuns) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } - return two; + } else if (bFileIsInCCDB) { -} // TComplex FlowWithMultiparticleCorrelationsTask::Two(Int_t n1, Int_t n2) + // e) Handle the CCDB case: Remember that here I do not access the file, + // instead directly object in that file. + // My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ + // Inspired by: + // 1. Discussion at: + // https://alice-talk.web.cern.ch/t/access-to-lhc-filling-scheme/1073/17 + // 2. See also: + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyGlobal.cxx + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyPerRun.cxx + // 3. O2 Analysis Tutorial 2.0: + // https://indico.cern.ch/event/1267433/timetable/#20230417.detailed -//============================================================ + ccdb->setURL("http://alice-ccdb.cern.ch"); + if (tc.fVerbose) { + LOGF(info, "\033[1;32mAccessing in CCDB %s\033[0m", TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data()); + } -TComplex Three(Int_t n1, Int_t n2, Int_t n3) -{ - // Generic three-particle correlation . + baseList = reinterpret_cast(ccdb->get(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data())); - TComplex three = Q(n1, 1) * Q(n2, 1) * Q(n3, 1) - Q(n1 + n2, 2) * Q(n3, 1) - - Q(n2, 1) * Q(n1 + n3, 2) - Q(n1, 1) * Q(n2 + n3, 2) + - 2. * Q(n1 + n2 + n3, 3); + if (!baseList) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } - return three; + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); + if (!listWithRuns) { + TString runNumberWithLeadingZeroes = "000"; + runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); + if (!listWithRuns) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } -} // TComplex Three(Int_t n1, Int_t n2, Int_t n3) + } else { -//============================================================ + // f) Handle the local case: + // TBI 20231008 In principle, also for the local case in O2, I could + // maintain the same local structure of weights as it was in AliPhysics. + // But for simplicity, in O2 I organize local weights in the same way as in AliEn or CCDB. -TComplex Four(Int_t n1, Int_t n2, Int_t n3, Int_t n4) -{ - // Generic four-particle correlation - // . + // Check if the external ROOT file exists at specified path: + if (gSystem->AccessPathName(filePath, kFileExists)) { + LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } - TComplex four = - Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) - - Q(n1 + n2, 2) * Q(n3, 1) * Q(n4, 1) - - Q(n2, 1) * Q(n1 + n3, 2) * Q(n4, 1) - - Q(n1, 1) * Q(n2 + n3, 2) * Q(n4, 1) + 2. * Q(n1 + n2 + n3, 3) * Q(n4, 1) - - Q(n2, 1) * Q(n3, 1) * Q(n1 + n4, 2) + Q(n2 + n3, 2) * Q(n1 + n4, 2) - - Q(n1, 1) * Q(n3, 1) * Q(n2 + n4, 2) + Q(n1 + n3, 2) * Q(n2 + n4, 2) + - 2. * Q(n3, 1) * Q(n1 + n2 + n4, 3) - Q(n1, 1) * Q(n2, 1) * Q(n3 + n4, 2) + - Q(n1 + n2, 2) * Q(n3 + n4, 2) + 2. * Q(n2, 1) * Q(n1 + n3 + n4, 3) + - 2. * Q(n1, 1) * Q(n2 + n3 + n4, 3) - 6. * Q(n1 + n2 + n3 + n4, 4); + TFile* centralityWeightsFile = TFile::Open(filePath, "READ"); + if (!centralityWeightsFile) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } - return four; + centralityWeightsFile->GetObject("ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name + // of base TList is "ccdb_object" also for + // local case, see if I need to change this -} // TComplex Four(Int_t n1, Int_t n2, Int_t n3, Int_t n4) + if (!baseList) { + // centralityWeightsFile->ls(); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } -//============================================================ + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); + if (!listWithRuns) { + TString runNumberWithLeadingZeroes = "000"; + runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); + if (!listWithRuns) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } -TComplex Five(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5) -{ - // Generic five-particle correlation . + } // else { - TComplex five = Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) - Q(n1 + n2, 2) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) - Q(n2, 1) * Q(n1 + n3, 2) * Q(n4, 1) * Q(n5, 1) - Q(n1, 1) * Q(n2 + n3, 2) * Q(n4, 1) * Q(n5, 1) + 2. * Q(n1 + n2 + n3, 3) * Q(n4, 1) * Q(n5, 1) - Q(n2, 1) * Q(n3, 1) * Q(n1 + n4, 2) * Q(n5, 1) + Q(n2 + n3, 2) * Q(n1 + n4, 2) * Q(n5, 1) - Q(n1, 1) * Q(n3, 1) * Q(n2 + n4, 2) * Q(n5, 1) + Q(n1 + n3, 2) * Q(n2 + n4, 2) * Q(n5, 1) + 2. * Q(n3, 1) * Q(n1 + n2 + n4, 3) * Q(n5, 1) - Q(n1, 1) * Q(n2, 1) * Q(n3 + n4, 2) * Q(n5, 1) + Q(n1 + n2, 2) * Q(n3 + n4, 2) * Q(n5, 1) + 2. * Q(n2, 1) * Q(n1 + n3 + n4, 3) * Q(n5, 1) + 2. * Q(n1, 1) * Q(n2 + n3 + n4, 3) * Q(n5, 1) - 6. * Q(n1 + n2 + n3 + n4, 4) * Q(n5, 1) - Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n1 + n5, 2) + Q(n2 + n3, 2) * Q(n4, 1) * Q(n1 + n5, 2) + Q(n3, 1) * Q(n2 + n4, 2) * Q(n1 + n5, 2) + Q(n2, 1) * Q(n3 + n4, 2) * Q(n1 + n5, 2) - 2. * Q(n2 + n3 + n4, 3) * Q(n1 + n5, 2) - Q(n1, 1) * Q(n3, 1) * Q(n4, 1) * Q(n2 + n5, 2) + Q(n1 + n3, 2) * Q(n4, 1) * Q(n2 + n5, 2) + Q(n3, 1) * Q(n1 + n4, 2) * Q(n2 + n5, 2) + Q(n1, 1) * Q(n3 + n4, 2) * Q(n2 + n5, 2) - 2. * Q(n1 + n3 + n4, 3) * Q(n2 + n5, 2) + 2. * Q(n3, 1) * Q(n4, 1) * Q(n1 + n2 + n5, 3) - 2. * Q(n3 + n4, 2) * Q(n1 + n2 + n5, 3) - Q(n1, 1) * Q(n2, 1) * Q(n4, 1) * Q(n3 + n5, 2) + Q(n1 + n2, 2) * Q(n4, 1) * Q(n3 + n5, 2) + Q(n2, 1) * Q(n1 + n4, 2) * Q(n3 + n5, 2) + Q(n1, 1) * Q(n2 + n4, 2) * Q(n3 + n5, 2) - 2. * Q(n1 + n2 + n4, 3) * Q(n3 + n5, 2) + 2. * Q(n2, 1) * Q(n4, 1) * Q(n1 + n3 + n5, 3) - 2. * Q(n2 + n4, 2) * Q(n1 + n3 + n5, 3) + 2. * Q(n1, 1) * Q(n4, 1) * Q(n2 + n3 + n5, 3) - 2. * Q(n1 + n4, 2) * Q(n2 + n3 + n5, 3) - 6. * Q(n4, 1) * Q(n1 + n2 + n3 + n5, 4) - Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4 + n5, 2) + Q(n1 + n2, 2) * Q(n3, 1) * Q(n4 + n5, 2) + Q(n2, 1) * Q(n1 + n3, 2) * Q(n4 + n5, 2) + Q(n1, 1) * Q(n2 + n3, 2) * Q(n4 + n5, 2) - 2. * Q(n1 + n2 + n3, 3) * Q(n4 + n5, 2) + 2. * Q(n2, 1) * Q(n3, 1) * Q(n1 + n4 + n5, 3) - 2. * Q(n2 + n3, 2) * Q(n1 + n4 + n5, 3) + 2. * Q(n1, 1) * Q(n3, 1) * Q(n2 + n4 + n5, 3) - 2. * Q(n1 + n3, 2) * Q(n2 + n4 + n5, 3) - 6. * Q(n3, 1) * Q(n1 + n2 + n4 + n5, 4) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n3 + n4 + n5, 3) - 2. * Q(n1 + n2, 2) * Q(n3 + n4 + n5, 3) - 6. * Q(n2, 1) * Q(n1 + n3 + n4 + n5, 4) - 6. * Q(n1, 1) * Q(n2 + n3 + n4 + n5, 4) + 24. * Q(n1 + n2 + n3 + n4 + n5, 5); + // g) The final touch on histogram with centrality weights: + TString histName = ""; - return five; + // fetch histogram directly from this list: + // Remark: histName must be formated as e.g. "FT0C_multiparticle-correlations-a-b" for default analysis, or "FT0C_multiparticle-correlations-a-b_someCut" + + // Isolate short centrality estimator name, e.g. "FT0C" or "V0M" TBI 20250122 move this to utility function, because I have the same code in FancyFormatting() + TString tmp = ec.fsEventCuts[eCentralityEstimator]; // I have to introduce local TString tmp, because ReplaceAll replaces in-place + if (tmp.BeginsWith("CentRun2")) { + tmp.ReplaceAll("CentRun2", ""); // "CentRun2V0M" => "V0M" + } else if (tmp.BeginsWith("Cent")) { + tmp.ReplaceAll("Cent", ""); // "CentFT0C" => FT0C" + } else { + LOGF(fatal, "\033[1;31m%s at line %d : the case tmp = %s is not supported yet\033[0m", __FUNCTION__, __LINE__, tmp.Data()); + } -} // TComplex Five(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5) + histName = TString::Format("%s_multiparticle-correlations-a-b", tmp.Data()); // I can hardwire here the name, as long as my main task name is struct MultiparticleCorrelationsAB + if (!tc.fTaskName.EqualTo("")) { + // for non-default analysis (e.g. in subwagon), append still "_someName", where "someName" is subwagon = taskname + histName += "_"; + histName += tc.fTaskName; + } -//============================================================ + LOGF(info, "\033[1;33m%s at line %d : fetching directly hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + hist = reinterpret_cast(listWithRuns->FindObject(histName.Data())); + // if the previous search failed, descend recursively also into the nested lists: + if (!hist) { + LOGF(info, "\033[1;33m%s at line %d : previous attempt failed, fetching instead recursively hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + hist = reinterpret_cast(GetObjectFromList(listWithRuns, histName.Data())); + } + if (!hist) { + histName = tmp; // yes, for some simple tests I can have only histogram named e.g. 'FT0C' + LOGF(info, "\033[1;33m%s at line %d : last attempt, fetching instead hist with trivial name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + hist = reinterpret_cast(GetObjectFromList(listWithRuns, histName.Data())); + } + if (!hist) { + listWithRuns->ls(); + LOGF(fatal, "\033[1;31m%s at line %d : couldn't fetch hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); + } + hist->SetDirectory(0); + hist->SetTitle(Form("%s, %s", filePath, runNumber)); // I have to do it here, because only here I have "filePath" av -TComplex Six(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6) -{ - // Generic six-particle correlation . + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } - TComplex six = Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) - Q(n1 + n2, 2) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) - Q(n2, 1) * Q(n1 + n3, 2) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) - Q(n1, 1) * Q(n2 + n3, 2) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) + 2. * Q(n1 + n2 + n3, 3) * Q(n4, 1) * Q(n5, 1) * Q(n6, 1) - Q(n2, 1) * Q(n3, 1) * Q(n1 + n4, 2) * Q(n5, 1) * Q(n6, 1) + Q(n2 + n3, 2) * Q(n1 + n4, 2) * Q(n5, 1) * Q(n6, 1) - Q(n1, 1) * Q(n3, 1) * Q(n2 + n4, 2) * Q(n5, 1) * Q(n6, 1) + Q(n1 + n3, 2) * Q(n2 + n4, 2) * Q(n5, 1) * Q(n6, 1) + 2. * Q(n3, 1) * Q(n1 + n2 + n4, 3) * Q(n5, 1) * Q(n6, 1) - Q(n1, 1) * Q(n2, 1) * Q(n3 + n4, 2) * Q(n5, 1) * Q(n6, 1) + Q(n1 + n2, 2) * Q(n3 + n4, 2) * Q(n5, 1) * Q(n6, 1) + 2. * Q(n2, 1) * Q(n1 + n3 + n4, 3) * Q(n5, 1) * Q(n6, 1) + 2. * Q(n1, 1) * Q(n2 + n3 + n4, 3) * Q(n5, 1) * Q(n6, 1) - 6. * Q(n1 + n2 + n3 + n4, 4) * Q(n5, 1) * Q(n6, 1) - Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n1 + n5, 2) * Q(n6, 1) + Q(n2 + n3, 2) * Q(n4, 1) * Q(n1 + n5, 2) * Q(n6, 1) + Q(n3, 1) * Q(n2 + n4, 2) * Q(n1 + n5, 2) * Q(n6, 1) + Q(n2, 1) * Q(n3 + n4, 2) * Q(n1 + n5, 2) * Q(n6, 1) - 2. * Q(n2 + n3 + n4, 3) * Q(n1 + n5, 2) * Q(n6, 1) - Q(n1, 1) * Q(n3, 1) * Q(n4, 1) * Q(n2 + n5, 2) * Q(n6, 1) + Q(n1 + n3, 2) * Q(n4, 1) * Q(n2 + n5, 2) * Q(n6, 1) + Q(n3, 1) * Q(n1 + n4, 2) * Q(n2 + n5, 2) * Q(n6, 1) + Q(n1, 1) * Q(n3 + n4, 2) * Q(n2 + n5, 2) * Q(n6, 1) - 2. * Q(n1 + n3 + n4, 3) * Q(n2 + n5, 2) * Q(n6, 1) + 2. * Q(n3, 1) * Q(n4, 1) * Q(n1 + n2 + n5, 3) * Q(n6, 1) - 2. * Q(n3 + n4, 2) * Q(n1 + n2 + n5, 3) * Q(n6, 1) - Q(n1, 1) * Q(n2, 1) * Q(n4, 1) * Q(n3 + n5, 2) * Q(n6, 1) + Q(n1 + n2, 2) * Q(n4, 1) * Q(n3 + n5, 2) * Q(n6, 1) + Q(n2, 1) * Q(n1 + n4, 2) * Q(n3 + n5, 2) * Q(n6, 1) + Q(n1, 1) * Q(n2 + n4, 2) * Q(n3 + n5, 2) * Q(n6, 1) - 2. * Q(n1 + n2 + n4, 3) * Q(n3 + n5, 2) * Q(n6, 1) + 2. * Q(n2, 1) * Q(n4, 1) * Q(n1 + n3 + n5, 3) * Q(n6, 1) - 2. * Q(n2 + n4, 2) * Q(n1 + n3 + n5, 3) * Q(n6, 1) + 2. * Q(n1, 1) * Q(n4, 1) * Q(n2 + n3 + n5, 3) * Q(n6, 1) - 2. * Q(n1 + n4, 2) * Q(n2 + n3 + n5, 3) * Q(n6, 1) - 6. * Q(n4, 1) * Q(n1 + n2 + n3 + n5, 4) * Q(n6, 1) - Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4 + n5, 2) * Q(n6, 1) + Q(n1 + n2, 2) * Q(n3, 1) * Q(n4 + n5, 2) * Q(n6, 1) + Q(n2, 1) * Q(n1 + n3, 2) * Q(n4 + n5, 2) * Q(n6, 1) + Q(n1, 1) * Q(n2 + n3, 2) * Q(n4 + n5, 2) * Q(n6, 1) - 2. * Q(n1 + n2 + n3, 3) * Q(n4 + n5, 2) * Q(n6, 1) + 2. * Q(n2, 1) * Q(n3, 1) * Q(n1 + n4 + n5, 3) * Q(n6, 1) - 2. * Q(n2 + n3, 2) * Q(n1 + n4 + n5, 3) * Q(n6, 1) + 2. * Q(n1, 1) * Q(n3, 1) * Q(n2 + n4 + n5, 3) * Q(n6, 1) - 2. * Q(n1 + n3, 2) * Q(n2 + n4 + n5, 3) * Q(n6, 1) - 6. * Q(n3, 1) * Q(n1 + n2 + n4 + n5, 4) * Q(n6, 1) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n3 + n4 + n5, 3) * Q(n6, 1) - 2. * Q(n1 + n2, 2) * Q(n3 + n4 + n5, 3) * Q(n6, 1) - 6. * Q(n2, 1) * Q(n1 + n3 + n4 + n5, 4) * Q(n6, 1) - 6. * Q(n1, 1) * Q(n2 + n3 + n4 + n5, 4) * Q(n6, 1) + 24. * Q(n1 + n2 + n3 + n4 + n5, 5) * Q(n6, 1) - Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n1 + n6, 2) + Q(n2 + n3, 2) * Q(n4, 1) * Q(n5, 1) * Q(n1 + n6, 2) + Q(n3, 1) * Q(n2 + n4, 2) * Q(n5, 1) * Q(n1 + n6, 2) + Q(n2, 1) * Q(n3 + n4, 2) * Q(n5, 1) * Q(n1 + n6, 2) - 2. * Q(n2 + n3 + n4, 3) * Q(n5, 1) * Q(n1 + n6, 2) + Q(n3, 1) * Q(n4, 1) * Q(n2 + n5, 2) * Q(n1 + n6, 2) - Q(n3 + n4, 2) * Q(n2 + n5, 2) * Q(n1 + n6, 2) + Q(n2, 1) * Q(n4, 1) * Q(n3 + n5, 2) * Q(n1 + n6, 2) - Q(n2 + n4, 2) * Q(n3 + n5, 2) * Q(n1 + n6, 2) - 2. * Q(n4, 1) * Q(n2 + n3 + n5, 3) * Q(n1 + n6, 2) + Q(n2, 1) * Q(n3, 1) * Q(n4 + n5, 2) * Q(n1 + n6, 2) - Q(n2 + n3, 2) * Q(n4 + n5, 2) * Q(n1 + n6, 2) - 2. * Q(n3, 1) * Q(n2 + n4 + n5, 3) * Q(n1 + n6, 2) - 2. * Q(n2, 1) * Q(n3 + n4 + n5, 3) * Q(n1 + n6, 2) + 6. * Q(n2 + n3 + n4 + n5, 4) * Q(n1 + n6, 2) - Q(n1, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n2 + n6, 2) + Q(n1 + n3, 2) * Q(n4, 1) * Q(n5, 1) * Q(n2 + n6, 2) + Q(n3, 1) * Q(n1 + n4, 2) * Q(n5, 1) * Q(n2 + n6, 2) + Q(n1, 1) * Q(n3 + n4, 2) * Q(n5, 1) * Q(n2 + n6, 2) - 2. * Q(n1 + n3 + n4, 3) * Q(n5, 1) * Q(n2 + n6, 2) + Q(n3, 1) * Q(n4, 1) * Q(n1 + n5, 2) * Q(n2 + n6, 2) - Q(n3 + n4, 2) * Q(n1 + n5, 2) * Q(n2 + n6, 2) + Q(n1, 1) * Q(n4, 1) * Q(n3 + n5, 2) * Q(n2 + n6, 2) - Q(n1 + n4, 2) * Q(n3 + n5, 2) * Q(n2 + n6, 2) - 2. * Q(n4, 1) * Q(n1 + n3 + n5, 3) * Q(n2 + n6, 2) + Q(n1, 1) * Q(n3, 1) * Q(n4 + n5, 2) * Q(n2 + n6, 2) - Q(n1 + n3, 2) * Q(n4 + n5, 2) * Q(n2 + n6, 2) - 2. * Q(n3, 1) * Q(n1 + n4 + n5, 3) * Q(n2 + n6, 2) - 2. * Q(n1, 1) * Q(n3 + n4 + n5, 3) * Q(n2 + n6, 2) + 6. * Q(n1 + n3 + n4 + n5, 4) * Q(n2 + n6, 2) + 2. * Q(n3, 1) * Q(n4, 1) * Q(n5, 1) * Q(n1 + n2 + n6, 3) - 2. * Q(n3 + n4, 2) * Q(n5, 1) * Q(n1 + n2 + n6, 3) - 2. * Q(n4, 1) * Q(n3 + n5, 2) * Q(n1 + n2 + n6, 3) - 2. * Q(n3, 1) * Q(n4 + n5, 2) * Q(n1 + n2 + n6, 3) + 4. * Q(n3 + n4 + n5, 3) * Q(n1 + n2 + n6, 3) - Q(n1, 1) * Q(n2, 1) * Q(n4, 1) * Q(n5, 1) * Q(n3 + n6, 2) + Q(n1 + n2, 2) * Q(n4, 1) * Q(n5, 1) * Q(n3 + n6, 2) + Q(n2, 1) * Q(n1 + n4, 2) * Q(n5, 1) * Q(n3 + n6, 2) + Q(n1, 1) * Q(n2 + n4, 2) * Q(n5, 1) * Q(n3 + n6, 2) - 2. * Q(n1 + n2 + n4, 3) * Q(n5, 1) * Q(n3 + n6, 2) + Q(n2, 1) * Q(n4, 1) * Q(n1 + n5, 2) * Q(n3 + n6, 2) - Q(n2 + n4, 2) * Q(n1 + n5, 2) * Q(n3 + n6, 2) + Q(n1, 1) * Q(n4, 1) * Q(n2 + n5, 2) * Q(n3 + n6, 2) - Q(n1 + n4, 2) * Q(n2 + n5, 2) * Q(n3 + n6, 2) - 2. * Q(n4, 1) * Q(n1 + n2 + n5, 3) * Q(n3 + n6, 2) + Q(n1, 1) * Q(n2, 1) * Q(n4 + n5, 2) * Q(n3 + n6, 2) - Q(n1 + n2, 2) * Q(n4 + n5, 2) * Q(n3 + n6, 2) - 2. * Q(n2, 1) * Q(n1 + n4 + n5, 3) * Q(n3 + n6, 2) - 2. * Q(n1, 1) * Q(n2 + n4 + n5, 3) * Q(n3 + n6, 2) + 6. * Q(n1 + n2 + n4 + n5, 4) * Q(n3 + n6, 2) + 2. * Q(n2, 1) * Q(n4, 1) * Q(n5, 1) * Q(n1 + n3 + n6, 3) - 2. * Q(n2 + n4, 2) * Q(n5, 1) * Q(n1 + n3 + n6, 3) - 2. * Q(n4, 1) * Q(n2 + n5, 2) * Q(n1 + n3 + n6, 3) - 2. * Q(n2, 1) * Q(n4 + n5, 2) * Q(n1 + n3 + n6, 3) + 4. * Q(n2 + n4 + n5, 3) * Q(n1 + n3 + n6, 3) + 2. * Q(n1, 1) * Q(n4, 1) * Q(n5, 1) * Q(n2 + n3 + n6, 3) - 2. * Q(n1 + n4, 2) * Q(n5, 1) * Q(n2 + n3 + n6, 3) - 2. * Q(n4, 1) * Q(n1 + n5, 2) * Q(n2 + n3 + n6, 3) - 2. * Q(n1, 1) * Q(n4 + n5, 2) * Q(n2 + n3 + n6, 3) + 4. * Q(n1 + n4 + n5, 3) * Q(n2 + n3 + n6, 3) - 6. * Q(n4, 1) * Q(n5, 1) * Q(n1 + n2 + n3 + n6, 4) + 6. * Q(n4 + n5, 2) * Q(n1 + n2 + n3 + n6, 4) - Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n5, 1) * Q(n4 + n6, 2) + Q(n1 + n2, 2) * Q(n3, 1) * Q(n5, 1) * Q(n4 + n6, 2) + Q(n2, 1) * Q(n1 + n3, 2) * Q(n5, 1) * Q(n4 + n6, 2) + Q(n1, 1) * Q(n2 + n3, 2) * Q(n5, 1) * Q(n4 + n6, 2) - 2. * Q(n1 + n2 + n3, 3) * Q(n5, 1) * Q(n4 + n6, 2) + Q(n2, 1) * Q(n3, 1) * Q(n1 + n5, 2) * Q(n4 + n6, 2) - Q(n2 + n3, 2) * Q(n1 + n5, 2) * Q(n4 + n6, 2) + Q(n1, 1) * Q(n3, 1) * Q(n2 + n5, 2) * Q(n4 + n6, 2) - Q(n1 + n3, 2) * Q(n2 + n5, 2) * Q(n4 + n6, 2) - 2. * Q(n3, 1) * Q(n1 + n2 + n5, 3) * Q(n4 + n6, 2) + Q(n1, 1) * Q(n2, 1) * Q(n3 + n5, 2) * Q(n4 + n6, 2) - Q(n1 + n2, 2) * Q(n3 + n5, 2) * Q(n4 + n6, 2) - 2. * Q(n2, 1) * Q(n1 + n3 + n5, 3) * Q(n4 + n6, 2) - 2. * Q(n1, 1) * Q(n2 + n3 + n5, 3) * Q(n4 + n6, 2) + 6. * Q(n1 + n2 + n3 + n5, 4) * Q(n4 + n6, 2) + 2. * Q(n2, 1) * Q(n3, 1) * Q(n5, 1) * Q(n1 + n4 + n6, 3) - 2. * Q(n2 + n3, 2) * Q(n5, 1) * Q(n1 + n4 + n6, 3) - 2. * Q(n3, 1) * Q(n2 + n5, 2) * Q(n1 + n4 + n6, 3) - 2. * Q(n2, 1) * Q(n3 + n5, 2) * Q(n1 + n4 + n6, 3) + 4. * Q(n2 + n3 + n5, 3) * Q(n1 + n4 + n6, 3) + 2. * Q(n1, 1) * Q(n3, 1) * Q(n5, 1) * Q(n2 + n4 + n6, 3) - 2. * Q(n1 + n3, 2) * Q(n5, 1) * Q(n2 + n4 + n6, 3) - 2. * Q(n3, 1) * Q(n1 + n5, 2) * Q(n2 + n4 + n6, 3) - 2. * Q(n1, 1) * Q(n3 + n5, 2) * Q(n2 + n4 + n6, 3) + 4. * Q(n1 + n3 + n5, 3) * Q(n2 + n4 + n6, 3) - 6. * Q(n3, 1) * Q(n5, 1) * Q(n1 + n2 + n4 + n6, 4) + 6. * Q(n3 + n5, 2) * Q(n1 + n2 + n4 + n6, 4) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n5, 1) * Q(n3 + n4 + n6, 3) - 2. * Q(n1 + n2, 2) * Q(n5, 1) * Q(n3 + n4 + n6, 3) - 2. * Q(n2, 1) * Q(n1 + n5, 2) * Q(n3 + n4 + n6, 3) - 2. * Q(n1, 1) * Q(n2 + n5, 2) * Q(n3 + n4 + n6, 3) + 4. * Q(n1 + n2 + n5, 3) * Q(n3 + n4 + n6, 3) - 6. * Q(n2, 1) * Q(n5, 1) * Q(n1 + n3 + n4 + n6, 4) + 6. * Q(n2 + n5, 2) * Q(n1 + n3 + n4 + n6, 4) - 6. * Q(n1, 1) * Q(n5, 1) * Q(n2 + n3 + n4 + n6, 4) + 6. * Q(n1 + n5, 2) * Q(n2 + n3 + n4 + n6, 4) + 24. * Q(n5, 1) * Q(n1 + n2 + n3 + n4 + n6, 5) - Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n5 + n6, 2) + Q(n1 + n2, 2) * Q(n3, 1) * Q(n4, 1) * Q(n5 + n6, 2) + Q(n2, 1) * Q(n1 + n3, 2) * Q(n4, 1) * Q(n5 + n6, 2) + Q(n1, 1) * Q(n2 + n3, 2) * Q(n4, 1) * Q(n5 + n6, 2) - 2. * Q(n1 + n2 + n3, 3) * Q(n4, 1) * Q(n5 + n6, 2) + Q(n2, 1) * Q(n3, 1) * Q(n1 + n4, 2) * Q(n5 + n6, 2) - Q(n2 + n3, 2) * Q(n1 + n4, 2) * Q(n5 + n6, 2) + Q(n1, 1) * Q(n3, 1) * Q(n2 + n4, 2) * Q(n5 + n6, 2) - Q(n1 + n3, 2) * Q(n2 + n4, 2) * Q(n5 + n6, 2) - 2. * Q(n3, 1) * Q(n1 + n2 + n4, 3) * Q(n5 + n6, 2) + Q(n1, 1) * Q(n2, 1) * Q(n3 + n4, 2) * Q(n5 + n6, 2) - Q(n1 + n2, 2) * Q(n3 + n4, 2) * Q(n5 + n6, 2) - 2. * Q(n2, 1) * Q(n1 + n3 + n4, 3) * Q(n5 + n6, 2) - 2. * Q(n1, 1) * Q(n2 + n3 + n4, 3) * Q(n5 + n6, 2) + 6. * Q(n1 + n2 + n3 + n4, 4) * Q(n5 + n6, 2) + 2. * Q(n2, 1) * Q(n3, 1) * Q(n4, 1) * Q(n1 + n5 + n6, 3) - 2. * Q(n2 + n3, 2) * Q(n4, 1) * Q(n1 + n5 + n6, 3) - 2. * Q(n3, 1) * Q(n2 + n4, 2) * Q(n1 + n5 + n6, 3) - 2. * Q(n2, 1) * Q(n3 + n4, 2) * Q(n1 + n5 + n6, 3) + 4. * Q(n2 + n3 + n4, 3) * Q(n1 + n5 + n6, 3) + 2. * Q(n1, 1) * Q(n3, 1) * Q(n4, 1) * Q(n2 + n5 + n6, 3) - 2. * Q(n1 + n3, 2) * Q(n4, 1) * Q(n2 + n5 + n6, 3) - 2. * Q(n3, 1) * Q(n1 + n4, 2) * Q(n2 + n5 + n6, 3) - 2. * Q(n1, 1) * Q(n3 + n4, 2) * Q(n2 + n5 + n6, 3) + 4. * Q(n1 + n3 + n4, 3) * Q(n2 + n5 + n6, 3) - 6. * Q(n3, 1) * Q(n4, 1) * Q(n1 + n2 + n5 + n6, 4) + 6. * Q(n3 + n4, 2) * Q(n1 + n2 + n5 + n6, 4) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n4, 1) * Q(n3 + n5 + n6, 3) - 2. * Q(n1 + n2, 2) * Q(n4, 1) * Q(n3 + n5 + n6, 3) - 2. * Q(n2, 1) * Q(n1 + n4, 2) * Q(n3 + n5 + n6, 3) - 2. * Q(n1, 1) * Q(n2 + n4, 2) * Q(n3 + n5 + n6, 3) + 4. * Q(n1 + n2 + n4, 3) * Q(n3 + n5 + n6, 3) - 6. * Q(n2, 1) * Q(n4, 1) * Q(n1 + n3 + n5 + n6, 4) + 6. * Q(n2 + n4, 2) * Q(n1 + n3 + n5 + n6, 4) - 6. * Q(n1, 1) * Q(n4, 1) * Q(n2 + n3 + n5 + n6, 4) + 6. * Q(n1 + n4, 2) * Q(n2 + n3 + n5 + n6, 4) + 24. * Q(n4, 1) * Q(n1 + n2 + n3 + n5 + n6, 5) + 2. * Q(n1, 1) * Q(n2, 1) * Q(n3, 1) * Q(n4 + n5 + n6, 3) - 2. * Q(n1 + n2, 2) * Q(n3, 1) * Q(n4 + n5 + n6, 3) - 2. * Q(n2, 1) * Q(n1 + n3, 2) * Q(n4 + n5 + n6, 3) - 2. * Q(n1, 1) * Q(n2 + n3, 2) * Q(n4 + n5 + n6, 3) + 4. * Q(n1 + n2 + n3, 3) * Q(n4 + n5 + n6, 3) - 6. * Q(n2, 1) * Q(n3, 1) * Q(n1 + n4 + n5 + n6, 4) + 6. * Q(n2 + n3, 2) * Q(n1 + n4 + n5 + n6, 4) - 6. * Q(n1, 1) * Q(n3, 1) * Q(n2 + n4 + n5 + n6, 4) + 6. * Q(n1 + n3, 2) * Q(n2 + n4 + n5 + n6, 4) + 24. * Q(n3, 1) * Q(n1 + n2 + n4 + n5 + n6, 5) - 6. * Q(n1, 1) * Q(n2, 1) * Q(n3 + n4 + n5 + n6, 4) + 6. * Q(n1 + n2, 2) * Q(n3 + n4 + n5 + n6, 4) + 24. * Q(n2, 1) * Q(n1 + n3 + n4 + n5 + n6, 5) + 24. * Q(n1, 1) * Q(n2 + n3 + n4 + n5 + n6, 5) - 120. * Q(n1 + n2 + n3 + n4 + n5 + n6, 6); + // h) Clone histogram and delete baseList (realising back the memory): + // Remark: Yes, I have to clone here. + TH1D* histClone = reinterpret_cast(hist->Clone()); + delete baseList; // release back the memory - return six; + return histClone; -} // TComplex Six(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6) +} // TH1D* GetHistogramWithCentralityWeights(const char* filePath, const char* runNumber) //============================================================ -TComplex Seven(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7) +TObjArray* GetDefaultObjArrayWithLabels(const char* whichDefaultLabels) { - // Generic seven-particle correlation . + // To speed up testing, I hardwire here some labels and use them directly as they are. - Int_t harmonic[7] = {n1, n2, n3, n4, n5, n6, n7}; + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } - TComplex seven = Recursion(7, harmonic); + // Define TObjArray: + TObjArray* arr = new TObjArray(); + arr->SetOwner(); - return seven; + // Define some labels, depending on the chosen option for whichDefaultLabels: + if (TString(whichDefaultLabels).EqualTo("trivial")) { + const int nLabels = 1; + TString labels[nLabels] = {"2 -2"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("mixedEventsStudy")) { + const int nLabels = 3; + TString labels[nLabels] = {"2", "-2", "2 -2"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("scan2p")) { + const int nLabels = 6; + TString labels[nLabels] = {"1 -1", "2 -2", "3 -3", "4 -4", "5 -5", "6 -6"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("projections")) { // use this set to test projections when calculating multi-dimensional weights + const int nLabels = 10; + TString labels[nLabels] = {"1", "2", "3", "1 -1", "2 -2", "3 -3", "3 -1 -2", "1 1 -1 -1", "2 2 -2 -2", "3 3 -3 -3"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("standard")) { + const int nLabels = 7; + TString labels[nLabels] = {"1 -1", "2 -2", "3 -3", "2 1 -1 -2", "3 1 -1 -3", "3 2 -2 -3", "3 2 1 -1 -2 -3"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("isotropic")) { + const int nLabels = 8; + TString labels[nLabels] = {"1 -1", "2 -2", "3 -3", "4 -4", "1 1 -1 -1", "2 2 -2 -2", "3 3 -3 -3", "4 4 -4 -4"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("upto8th")) { + const int nLabels = 7; // yes, because I do not care about 1-p + TString labels[nLabels] = {"1 -1", "1 1 -1", "1 1 -1 -1", "1 1 -1 -1 -1", "1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("upto10th")) { + const int nLabels = 9; // yes, because I do not care about 1-p + TString labels[nLabels] = {"1 -1", "1 1 -1", "1 1 -1 -1", "1 1 -1 -1 -1", "1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1 -1", "1 1 1 1 1 -1 -1 -1 -1 -1"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("upto12th")) { + const int nLabels = 11; // yes, because I do not care about 1-p + TString labels[nLabels] = {"1 -1", "1 1 -1", "1 1 -1 -1", "1 1 -1 -1 -1", "1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1 -1", "1 1 1 1 1 -1 -1 -1 -1 -1", "1 1 1 1 1 1 -1 -1 -1 -1 -1", "1 1 1 1 1 1 -1 -1 -1 -1 -1 -1"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("Set_0")) { + // From ~/scratch/O2/master/Labels/Set_0/labels_Set_0.root + const int nLabels = 57; // yes, because I do not care about 1-p + TString labels[nLabels] = { + "1 -1 ", + "2 -2 ", + "3 -3 ", + "4 -4 ", + "5 -5 ", + "6 -6 ", + "2 1 -1 -2 ", + "3 1 -1 -3 ", + "3 2 -2 -3 ", + "4 1 -1 -4 ", + "4 2 -2 -4 ", + "4 3 -3 -4 ", + "5 1 -1 -5 ", + "5 2 -2 -5 ", + "5 3 -3 -5 ", + "5 4 -4 -5 ", + "6 1 -1 -6 ", + "6 2 -2 -6 ", + "6 3 -3 -6 ", + "6 4 -4 -6 ", + "6 5 -5 -6 ", + "3 2 1 -1 -2 -3 ", + "4 2 1 -1 -2 -4 ", + "4 3 1 -1 -3 -4 ", + "4 3 2 -2 -3 -4 ", + "5 2 1 -1 -2 -5 ", + "5 3 1 -1 -3 -5 ", + "5 3 2 -2 -3 -5 ", + "5 4 1 -1 -4 -5 ", + "5 4 2 -2 -4 -5 ", + "5 4 3 -3 -4 -5 ", + "6 2 1 -1 -2 -6 ", + "6 3 1 -1 -3 -6 ", + "6 3 2 -2 -3 -6 ", + "6 4 1 -1 -4 -6 ", + "6 4 2 -2 -4 -6 ", + "6 4 3 -3 -4 -6 ", + "6 5 1 -1 -5 -6 ", + "6 5 2 -2 -5 -6 ", + "6 5 3 -3 -5 -6 ", + "6 5 4 -4 -5 -6 ", + "2 2 -2 -2", + "3 3 -3 -3", + "4 4 -4 -4", + "2 2 2 -2 -2 -2", + "3 3 2 -2 -3 -3", + "3 2 2 -2 -2 -3 ", + "3 3 3 -3 -3 -3", + "4 4 2 -2 -4 -4", + "4 2 2 -2 -2 -4", + "4 4 3 -3 -4 -4", + "4 3 3 -3 -3 -4", + "4 4 3 2 -2 -3 -4 -4", + "4 3 3 2 -2 -3 -3 -4", + "4 3 2 2 -2 -2 -3 -4", + "3 3 3 2 -2 -3 -3 -3", + "3 2 2 2 -2 -2 -2 -3"}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("Set_1")) { + // From ~/scratch/O2/master/Labels/Set_1/labels_Set_1.root + const int nLabels = 56; // yes, because I do not care about 1-p + TString labels[nLabels] = { + "1 -1 ", + "2 -2 ", + "3 -3 ", + "4 -4 ", + "5 -5 ", + "6 -6 ", + "2 1 -1 -2 ", + "3 1 -1 -3 ", + "3 2 -2 -3 ", + "4 1 -1 -4 ", + "4 2 -2 -4 ", + "4 3 -3 -4 ", + "5 1 -1 -5 ", + "5 2 -2 -5 ", + "5 3 -3 -5 ", + "5 4 -4 -5 ", + "6 1 -1 -6 ", + "6 2 -2 -6 ", + "6 3 -3 -6 ", + "6 4 -4 -6 ", + "6 5 -5 -6 ", + "3 2 1 -1 -2 -3 ", + "4 2 1 -1 -2 -4 ", + "4 3 1 -1 -3 -4 ", + "4 3 2 -2 -3 -4 ", + "5 2 1 -1 -2 -5 ", + "5 3 1 -1 -3 -5 ", + "5 3 2 -2 -3 -5 ", + "5 4 1 -1 -4 -5 ", + "5 4 2 -2 -4 -5 ", + "5 4 3 -3 -4 -5 ", + "6 2 1 -1 -2 -6 ", + "6 3 1 -1 -3 -6 ", + "6 3 2 -2 -3 -6 ", + "6 4 1 -1 -4 -6 ", + "6 4 2 -2 -4 -6 ", + "6 4 3 -3 -4 -6 ", + "6 5 1 -1 -5 -6 ", + "6 5 2 -2 -5 -6 ", + "6 5 3 -3 -5 -6 ", + "6 5 4 -4 -5 -6 ", + "4 3 2 1 -1 -2 -3 -4 ", + "5 3 2 1 -1 -2 -3 -5 ", + "5 4 2 1 -1 -2 -4 -5 ", + "5 4 3 1 -1 -3 -4 -5 ", + "5 4 3 2 -2 -3 -4 -5 ", + "6 3 2 1 -1 -2 -3 -6 ", + "6 4 2 1 -1 -2 -4 -6 ", + "6 4 3 1 -1 -3 -4 -6 ", + "6 4 3 2 -2 -3 -4 -6 ", + "6 5 2 1 -1 -2 -5 -6 ", + "6 5 3 1 -1 -3 -5 -6 ", + "6 5 3 2 -2 -3 -5 -6 ", + "6 5 4 1 -1 -4 -5 -6 ", + "6 5 4 2 -2 -4 -5 -6 ", + "6 5 4 3 -3 -4 -5 -6 "}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else if (TString(whichDefaultLabels).EqualTo("Set_2")) { + // From ~/scratch/O2/master/Labels/Set_2/labels_Set_2.root + const int nLabels = 62; // yes, because I do not care about 1-p + TString labels[nLabels] = { + "1 -1 ", + "2 -2 ", + "3 -3 ", + "4 -4 ", + "5 -5 ", + "6 -6 ", + "2 1 -1 -2 ", + "3 1 -1 -3 ", + "3 2 -2 -3 ", + "4 1 -1 -4 ", + "4 2 -2 -4 ", + "4 3 -3 -4 ", + "5 1 -1 -5 ", + "5 2 -2 -5 ", + "5 3 -3 -5 ", + "5 4 -4 -5 ", + "6 1 -1 -6 ", + "6 2 -2 -6 ", + "6 3 -3 -6 ", + "6 4 -4 -6 ", + "6 5 -5 -6 ", + "3 2 1 -1 -2 -3 ", + "4 2 1 -1 -2 -4 ", + "4 3 1 -1 -3 -4 ", + "4 3 2 -2 -3 -4 ", + "5 2 1 -1 -2 -5 ", + "5 3 1 -1 -3 -5 ", + "5 3 2 -2 -3 -5 ", + "5 4 1 -1 -4 -5 ", + "5 4 2 -2 -4 -5 ", + "5 4 3 -3 -4 -5 ", + "6 2 1 -1 -2 -6 ", + "6 3 1 -1 -3 -6 ", + "6 3 2 -2 -3 -6 ", + "6 4 1 -1 -4 -6 ", + "6 4 2 -2 -4 -6 ", + "6 4 3 -3 -4 -6 ", + "6 5 1 -1 -5 -6 ", + "6 5 2 -2 -5 -6 ", + "6 5 3 -3 -5 -6 ", + "6 5 4 -4 -5 -6 ", + "4 3 2 1 -1 -2 -3 -4 ", + "5 3 2 1 -1 -2 -3 -5 ", + "5 4 2 1 -1 -2 -4 -5 ", + "5 4 3 1 -1 -3 -4 -5 ", + "5 4 3 2 -2 -3 -4 -5 ", + "6 3 2 1 -1 -2 -3 -6 ", + "6 4 2 1 -1 -2 -4 -6 ", + "6 4 3 1 -1 -3 -4 -6 ", + "6 4 3 2 -2 -3 -4 -6 ", + "6 5 2 1 -1 -2 -5 -6 ", + "6 5 3 1 -1 -3 -5 -6 ", + "6 5 3 2 -2 -3 -5 -6 ", + "6 5 4 1 -1 -4 -5 -6 ", + "6 5 4 2 -2 -4 -5 -6 ", + "6 5 4 3 -3 -4 -5 -6 ", + "5 4 3 2 1 -1 -2 -3 -4 -5 ", + "6 4 3 2 1 -1 -2 -3 -4 -6 ", + "6 5 3 2 1 -1 -2 -3 -5 -6 ", + "6 5 4 2 1 -1 -2 -4 -5 -6 ", + "6 5 4 3 1 -1 -3 -4 -5 -6 ", + "6 5 4 3 2 -2 -3 -4 -5 -6 "}; + for (int l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + } else { + LOGF(fatal, "\033[1;31m%s at line %d : whichDefaultLabels = %s is not supported yet \033[0m", __FUNCTION__, __LINE__, whichDefaultLabels); + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + + return arr; -} // end of TComplex Seven(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7) +} // TObjArray* GetDefaultObjArrayWithLabels(const char* whichDefaultLabels) //============================================================ -TComplex Eight(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8) +TObjArray* GetObjArrayWithLabels(const char* filePath) { - // Generic eight-particle correlation . + // This function extracts from an external file TObjArray named "labels", and + // returns it. External file can be: + // 1) on a local computer; + // 2) in home directory AliEn => configurable "cfFileWithLabels" must begin with "/alice/cern.ch/" + // 3) in CCDB => configurable "cfFileWithLabels" must begin with "/alice-ccdb.cern.ch/" + // For all CCDB wisdom, see toggle "CCDB" in page "O2" - Int_t harmonic[8] = {n1, n2, n3, n4, n5, n6, n7, n8}; + // a) Return value; + // b) Determine from filePath if the file in on a local machine, or in AliEn; + // c) Handle the AliEn case; + // d) Handle the CCDB case; + // e) Handle the local case; + // f) Clean up. - TComplex eight = Recursion(8, harmonic); + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } - return eight; + // a) Return value: + TObjArray* oa = NULL; -} // end of Eight(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8) + // b) Determine from filePath if the file in on a local machine, or in home + // dir AliEn, or in CCDB: + // Algorithm: If filePath begins with "/alice/cern.ch/" then it's in home + // dir AliEn. + // If filePath begins with "/alice-ccdb.cern.ch/" then it's in + // CCDB. Therefore, files in AliEn and CCDB must be specified + // with abs path, for local files both abs and relative paths + // are just fine. + bool bFileIsInAliEn = false; + bool bFileIsInCCDB = false; + if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + bFileIsInAliEn = true; + } else { + if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { + bFileIsInCCDB = true; + } // else { + } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { -//============================================================ + TFile* oaFile = NULL; // file holding TObjArray with all labels + if (bFileIsInAliEn) { + // c) Handle the AliEn case: + TGrid* alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", ""); + if (!alien) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + oaFile = TFile::Open(Form("alien://%s", filePath), "READ"); + if (!oaFile) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } -TComplex Nine(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9) -{ - // Generic nine-particle correlation . + // Fetch TObjArray from external file (keep in sync with local file case below): + TList* lok = oaFile->GetListOfKeys(); + if (!lok) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + for (int l = 0; l < lok->GetEntries(); l++) { + oaFile->GetObject(lok->At(l)->GetName(), oa); + if (oa && TString(oa->ClassName()).EqualTo("TObjArray")) { + break; // TBI 20231107 the working assumption is that in an external file there is only one TObjArray object, + // and here I fetch it, whatever its name is. The advantage is that I do not have to do + // any additional work for TObjArray's name. Since I do not anticipate ever having more than 1 + // TObjArray in an external file, this shall be alright. With the current implementation, + // if there are multiple TObjArray objects in the same ROOT file, the first one will be fetched. + } + } // for(int l=0;lGetEntries();l++) - Int_t harmonic[9] = {n1, n2, n3, n4, n5, n6, n7, n8, n9}; + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } else if (bFileIsInCCDB) { - TComplex nine = Recursion(9, harmonic); + // d) Handle the CCDB case: Remember that here I do not access the file, + // instead directly object in that file. + // My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ + // Inspired by: + // 1. Discussion at: + // https://alice-talk.web.cern.ch/t/access-to-lhc-filling-scheme/1073/17 + // 2. See also: + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyGlobal.cxx + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyPerRun.cxx + // 3. O2 Analysis Tutorial 2.0: + // https://indico.cern.ch/event/1267433/timetable/#20230417.detailed - return nine; + ccdb->setURL("http://alice-ccdb.cern.ch"); + oa = reinterpret_cast(ccdb->get(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data())); // TBI 20250414 memory blow-up + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } else { -} // end of TComplex Nine(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9) + // e) Handle the local case: + // Check if the external ROOT file exists at specified path: + if (gSystem->AccessPathName(filePath, kFileExists)) { + LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + oaFile = TFile::Open(filePath, "READ"); + if (!oaFile) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } -//============================================================ + // Fetch TObjArray from external file (keep in sync with AliEn file case above): + TList* lok = oaFile->GetListOfKeys(); + if (!lok) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + for (int l = 0; l < lok->GetEntries(); l++) { + oaFile->GetObject(lok->At(l)->GetName(), oa); + if (oa && TString(oa->ClassName()).EqualTo("TObjArray")) { + break; // TBI 20231107 the working assumption is that in an external file there is only one TObjArray object, + // and here I fetch it, whatever its name is. The advantage is that I do not have to do + // any additional work for TObjArray's name. Since I do not anticipate ever having more than 1 + // TObjArray in an external file, this shall be alright. With the current implementation, + // if there are multiple TObjArray objects in the same ROOT file, the first one will be fetched. + } + } // for(int l=0;lGetEntries();l++) + if (!oa) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } -TComplex Ten(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9, Int_t n10) -{ - // Generic ten-particle correlation . + } // else { - Int_t harmonic[10] = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10}; + if (tc.fVerbose) { + LOGF(info, "\033[1;32m%s => Fetched TObjArray named \"%s\" from file %s\033[0m", __FUNCTION__, oa->GetName(), filePath); + ExitFunction(__FUNCTION__); + } - TComplex ten = Recursion(10, harmonic); + // f) Clean up: + if (oaFile) { + oaFile->Close(); + delete oaFile; + oaFile = nullptr; + } - return ten; + return oa; // "292535" (local) + 294291 (ccdb) -} // end of TComplex Ten(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9, Int_t n10) +} // TObjArray* GetObjArrayWithLabels(const char *filePath) //============================================================ -TComplex Eleven(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9, Int_t n10, Int_t n11) +void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) { - // Generic eleven-particle correlation . + // Get and set immediately histogram with custom NUA for specified variable, from an external file. + // This structure of an external file is mandatory at the moment: + // *) There is a TList named "ccdb_object", which holds all histograms for custom NUA; + // *) These histograms are TH1D objects. + // This is a port of void FlowWithMultiparticleCorrelationsTask::SetNUAPDF(TH1D* const hist, const char* variable) - Int_t harmonic[11] = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11}; + // Remark: Unlike for weights and labels, here I am trying to do everythign in the same function, that's why here return type is void, instead of TH1D*. - TComplex eleven = Recursion(11, harmonic); + // TBI 20240501 there is a bit of code repetition below, add with analogous functions GetHistogramWithWeights(...) and GetObjArrayWithLabels(...) - return eleven; + // a) Local objects; + // b) Basic protection for arguments; + // c) Determine from filePath if the file in on a local machine, or in AliEn, or in CCDB; + // d) Handle the AliEn case; + // e) Handle the CCDB case; + // f) Handle the local case; + // g) The final touch; + // h) Clone histogram and delete baseList (realising back the memory). + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + LOGF(info, "\033[1;32m filePath = %s\033[0m", filePath); + LOGF(info, "\033[1;32m variable = %d\033[0m", static_cast(variable)); + LOGF(info, "\033[1;32m nua.fCustomNUAPDFHistNames[variable]->Data() = %s\033[0m", nua.fCustomNUAPDFHistNames[variable]->Data()); + LOGF(info, "\033[1;32m fTaskName = %s\033[0m", tc.fTaskName.Data()); + } -} // end of TComplex Eleven(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9, Int_t n10, Int_t n11) + // *) Basic protection: + if (nua.fCustomNUAPDFHistNames[variable] && nua.fCustomNUAPDFHistNames[variable]->EqualTo("")) { + LOGF(info, "\033[1;32m empty TString, variable = %d\033[0m", static_cast(variable)); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } -//============================================================ + // a) Local objects: + TH1D* hist = NULL; + TList* baseList = NULL; // base top-level list in the TFile, always named "ccdb_object" -TComplex Twelve(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9, Int_t n10, Int_t n11, Int_t n12) -{ - // Generic twelve-particle correlation . + // b) Basic protection for arguments: + // ... - Int_t harmonic[12] = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12}; + // c) Determine from filePath if the file in on a local machine, or in home dir AliEn, or in CCDB: + // Algorithm: + // *) If filePath begins with "/alice/cern.ch/" then it's in home dir AliEn. + // *) If filePath begins with "/alice-ccdb.cern.ch/" then it's in CCDB. + // *) It's a local file otherwise. + // Therefore, files in AliEn and CCDB must be specified with abs path, for local files both abs and relative paths are just fine. + bool bFileIsInAliEn = false; + bool bFileIsInCCDB = false; + if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + bFileIsInAliEn = true; + } else { + if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { + bFileIsInCCDB = true; + } // else { + } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { - TComplex twelve = Recursion(12, harmonic); + if (bFileIsInAliEn) { + // d) Handle the AliEn case: + TGrid* alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", ""); + if (!alien) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + TFile* customNUAFile = TFile::Open(Form("alien://%s", filePath), "READ"); + if (!customNUAFile) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + customNUAFile->GetObject("ccdb_object", baseList); + if (!baseList) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } - return twelve; + } else if (bFileIsInCCDB) { -} // end of TComplex Twelve(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9, Int_t n10, Int_t n11, Int_t n12) + // e) Handle the CCDB case: Remember that here I do not access the file, instead directly object in that file. + // My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ + // Inspired by: + // 1. Discussion at: + // https://alice-talk.web.cern.ch/t/access-to-lhc-filling-scheme/1073/17 + // 2. See also: + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyGlobal.cxx + // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyPerRun.cxx + // 3. O2 Analysis Tutorial 2.0: + // https://indico.cern.ch/event/1267433/timetable/#20230417.detailed -//============================================================ + ccdb->setURL("http://alice-ccdb.cern.ch"); + if (tc.fVerbose) { + LOGF(info, "\033[1;32mAccessing in CCDB %s\033[0m", TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data()); + } -TComplex Recursion(Int_t n, Int_t* harmonic, Int_t mult = 1, Int_t skip = 0) -{ - // Calculate multi-particle correlators by using recursion (an improved faster version) originally developed by - // Kristjan Gulbrandsen (gulbrand@nbi.dk). + baseList = reinterpret_cast(ccdb->get(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data())); - Int_t nm1 = n - 1; - TComplex c(Q(harmonic[nm1], mult)); - if (nm1 == 0) - return c; - c *= Recursion(nm1, harmonic); - if (nm1 == skip) - return c; + if (!baseList) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } - Int_t multp1 = mult + 1; - Int_t nm2 = n - 2; - Int_t counter1 = 0; - Int_t hhold = harmonic[counter1]; - harmonic[counter1] = harmonic[nm2]; - harmonic[nm2] = hhold + harmonic[nm1]; - TComplex c2(Recursion(nm1, harmonic, multp1, nm2)); - Int_t counter2 = n - 3; - while (counter2 >= skip) { - harmonic[nm2] = harmonic[counter1]; - harmonic[counter1] = hhold; - ++counter1; - hhold = harmonic[counter1]; - harmonic[counter1] = harmonic[nm2]; - harmonic[nm2] = hhold + harmonic[nm1]; - c2 += Recursion(nm1, harmonic, multp1, counter2); - --counter2; - } - harmonic[nm2] = harmonic[counter1]; - harmonic[counter1] = hhold; + } else { - if (mult == 1) - return c - c2; - return c - Double_t(mult) * c2; + // f) Handle the local case: + + // Check if the external ROOT file exists at specified path: + if (gSystem->AccessPathName(filePath, kFileExists)) { + LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } -} // TComplex Recursion(Int_t n, Int_t* harmonic, Int_t mult = 1, Int_t skip = 0) + TFile* customNUAFile = TFile::Open(filePath, "READ"); + if (!customNUAFile) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + customNUAFile->GetObject("ccdb_object", baseList); + if (!baseList) { + // customNUAFile->ls(); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } -//============================================================ + // hist = reinterpret_cast(GetObjectFromList(baseList, nua.fCustomNUAPDFHistNames[variable]->Data())); -void ResetQ() -{ - // Reset the components of generic Q-vectors. Use it whenever you call the - // standard functions for correlations, for some custom Q-vectors. + } // else { - if (tc.fVerbose) { - StartFunction(__FUNCTION__); + // g) The final touch: + hist = reinterpret_cast(GetObjectFromList(baseList, nua.fCustomNUAPDFHistNames[variable]->Data())); + if (!hist) { + LOGF(info, "\033[1;31m hist is NULL \033[0m"); + LOGF(info, "\033[1;31m variable = %d\033[0m", static_cast(variable)); + LOGF(info, "\033[1;31m nua.fCustomNUAPDFHistNames[variable]->Data() = %s\033[0m", nua.fCustomNUAPDFHistNames[variable]->Data()); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { - for (Int_t wp = 0; wp < gMaxCorrelator + 1; wp++) // weight power - { - qv.fQ[h][wp] = TComplex(0., 0.); - } - } + // h) Clone histogram and delete baseList (realising back the memory). + // TBI 20250315 here I did it a bit differently than e.g. in GetHistogramWithWeights or in GetSparseHistogramWithWeights . + // If it's failing here, redo it in exactly the same way as I did it there. + hist->SetDirectory(0); + nua.fCustomNUAPDF[variable] = reinterpret_cast(hist->Clone()); + nua.fCustomNUAPDF[variable]->SetTitle(Form("%s", filePath)); + delete baseList; + + // TBI 20240501 if additional cosmetics is needed, it can be implemented here if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void ResetQ() +} // void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) //============================================================ -void SetWeightsHist(TH1D* const hist, eWeights whichWeight) +void StoreLabelsInPlaceholder() { - // Copy histogram holding weights from an external file to the corresponding data member. + // Storal all Test0 labels in the placeholder. + + // a) Initialize all counters; + // b) Fetch TObjArray with labels from an external file or from local hardwired values; + // c) Insanity check on labels; + // d) Finally, store the labels from external source into the placeholder. if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // Finally: - hist->SetDirectory(0); - pw.fWeightsHist[whichWeight] = reinterpret_cast(hist->Clone()); + // a) Initialize all counters; + int counter[gMaxCorrelator] = {0}; // is this safe? + for (int o = 0; o < gMaxCorrelator; o++) { + counter[o] = 0; + } // now it's safe :-) - if (!pw.fWeightsHist[whichWeight]) { + // b) Fetch TObjArray with labels from an external file or from local hardwired values: + TObjArray* oa = NULL; + if (t0.fUseDefaultLabels) { + oa = GetDefaultObjArrayWithLabels(t0.fWhichDefaultLabels.Data()); + } else { + + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! There is a large memory blow-up when calling function GetObjArrayWithLabels(...) !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); + + oa = GetObjArrayWithLabels(t0.fFileWithLabels.Data()); + // TBI 20250412 There is a large memory penalty in this call, confirmed for "local" and "ccdb" cases (most likely also for "alien", but I didn't test it yet) + // a) For the "local" case, it's related to the following minimal reproducer: + // TFile *f = new TFile("tmp.root", "read"); // memory blows up by > 50 MB + // f->Close(); delete f; f = nullptr; // memory stays > 50 MB + // b) Not clear why there is a blow-up for "ccdb" case, but it can be reproduced with this line: + // Service ccdb; + // ccdb->get("somePath"); + // c) TBI 20250412 document eventually also the "alien" case here + // ... + } + if (!oa) { + LOGF(info, "\033[1;33m fFileWithLabels = %s \033[0m", + t0.fFileWithLabels.Data()); LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - // Cosmetics: TBI 20240216 do I really want to overwrite initial cosmetics, perhaps this shall go better into MakeWeights.C ? - // Or I could move all this to GetHistogramWithWeights, where in any case I am setting e.g. histogram title, etc. - TString sVariable[eWeights_N] = {"#varphi", "p_{t}", "#eta"}; // [phi,pt,eta] - TString sWeights[eWeights_N] = {"w_{#varphi}", "w_{p_{t}}", "w_{#eta}"}; - pw.fWeightsHist[whichWeight]->SetStats(kFALSE); - pw.fWeightsHist[whichWeight]->GetXaxis()->SetTitle(sVariable[whichWeight].Data()); - pw.fWeightsHist[whichWeight]->GetYaxis()->SetTitle(sWeights[whichWeight].Data()); - pw.fWeightsHist[whichWeight]->SetFillColor(eFillColor); - pw.fWeightsHist[whichWeight]->SetLineColor(eColor); - if (!pw.fWeightsList) { - LOGF(fatal, "\033[1;31m%s at line %d: fWeightsList is NULL. That means that you have called SetWeightsHist(...) in init(), before this TList was booked.\033[0m", __FUNCTION__, __LINE__); + // c) Insanity check on labels: + int nLabels = oa->GetEntries(); + // c1) Insanity check on number of labels: + if (nLabels <= 0) { + LOGF(fatal, "\033[1;31m%s at line %d : nLabels = %d \033[0m", __FUNCTION__, __LINE__, nLabels); } - pw.fWeightsList->Add(pw.fWeightsHist[whichWeight]); // This is working at the moment, because I am fetching all weights in Preprocess(), which is called after init() - // But if eventually it will be possible to fetch run number programatically in init(), I will have to re-think this line. + // c2) Here I am merely checking that harmonic larger than gMaxHarmonic was not requested: + for (int e = 0; e < nLabels; e++) { + TObjArray* temp = TString(oa->At(e)->GetName()).Tokenize(" "); + for (int h = 0; h < temp->GetEntries(); h++) { + if (std::abs(TString(temp->At(h)->GetName()).Atoi()) > gMaxHarmonic) { + LOGF(info, "\033[1;31m e = %d, label = %s, gMaxHarmonic = %d\033[0m", e, temp->At(h)->GetName(), static_cast(gMaxHarmonic)); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } // if(TString(temp->At(h)->GetName()).Atoi() > gMaxHarmonic) { + } // for(int h = 0; h < temp->GetEntries(); h++) { + delete temp; // yes, otherwise it's a memory leak + } // for (int e = 0; e < nLabels; e++) { + // ... - // Flag: - pw.fUseWeights[whichWeight] = kTRUE; + // d) Finally, store the labels from external source into the placeholder: + int order = -44; + for (int e = 0; e < nLabels; e++) { + TObjArray* temp = TString(oa->At(e)->GetName()).Tokenize(" "); + if (!temp) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + order = temp->GetEntries(); + delete temp; // yes, otherwise it's a memory leak + if (0 == order) { + continue; + } // empty lines, or the label format which is not supported + // 1-p => 0, 2-p => 1, etc.: + t0.fTest0Labels[order - 1][counter[order - 1]] = new TString(oa->At(e)->GetName()); // okay... + counter[order - 1]++; + } // for(int e=0; eGet("hist-name"). - // Remark: Do not edit histogram title here, because that's done in GetHistogramWithWeights(), because I have "filePath" info there locally. - // Only if I promote "filePath" to data members, re-think the design of this function, and what goes where. + // Usage: TH1D *hist = (TH1D*) + // GetObjectFromList("some-valid-TList-pointer","some-object-name"); + + // Example 1: + // GetObjectFromList("some-valid-TList-pointer","some-object-name")->Draw(); + // // yes, for histograms and profiles this is just fine, at least in + // interpreted code + + // To do: + // a) Check if I can make it working in compiled mode. + // b) If I have objects with same name, nested in different TLists, what then? if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // Finally: - hist->SetDirectory(0); - pw.fDiffWeightsHist[whichDiffWeight][bin] = reinterpret_cast(hist->Clone()); - - if (!pw.fDiffWeightsHist[whichDiffWeight][bin]) { + // Insanity checks: + if (!list) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + if (!objectName) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } + if (0 == list->GetEntries()) { + return NULL; + } - // Cosmetics: TBI 20240216 do I really want to overwrite initial cosmetics, perhaps this shall go better into MakeWeights.C ? - // Or I could move all this to GetHistogramWithWeights, where in any case I am setting e.g. histogram title, etc. - TString sVariable[eDiffWeights_N] = {"#varphi", "#varphi"}; // yes, for the time being, x-axis is always phi - TString sWeights[eDiffWeights_N] = {"(w_{#varphi})_{| p_{T}}", "(w_{#varphi})_{| #eta}"}; - pw.fDiffWeightsHist[whichDiffWeight][bin]->SetStats(kFALSE); - pw.fDiffWeightsHist[whichDiffWeight][bin]->GetXaxis()->SetTitle(sVariable[whichDiffWeight].Data()); - pw.fDiffWeightsHist[whichDiffWeight][bin]->GetYaxis()->SetTitle(sWeights[whichDiffWeight].Data()); - pw.fDiffWeightsHist[whichDiffWeight][bin]->SetFillColor(eFillColor); - pw.fDiffWeightsHist[whichDiffWeight][bin]->SetLineColor(eColor); - pw.fWeightsList->Add(pw.fDiffWeightsHist[whichDiffWeight][bin]); // This is working at the moment, because I am fetching all weights in Preprocess(), which is called after init() - // But if eventually it will be possible to fetch run number programatically in init(), I will have to re-think this line. + // The object is in the current base list: + TObject* objectFinal = + list->FindObject(objectName); // final object I am after + if (objectFinal) + return objectFinal; - // Flag: - if (!pw.fUseDiffWeights[whichDiffWeight]) // yes, set it only once to kTRUE, for all bins + // Search for object recursively in the nested lists: + TObject* objectIter; // iterator object in the loop below + TIter next(list); + while ( + (objectIter = next())) // double round braces are to silent the warnings { - pw.fUseDiffWeights[whichDiffWeight] = kTRUE; - } + if (TString(objectIter->ClassName()).EqualTo("TList")) { + objectFinal = GetObjectFromList(reinterpret_cast(objectIter), objectName); + if (objectFinal) + return objectFinal; + } + } // while(objectIter = next()) if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // SetDiffWeightsHist(TH1D* const hist, const char *variable, Int_t bin) + return NULL; + +} // TObject* GetObjectFromList(TList *list, char *objectName) //============================================================ -void SetCentralityWeightsHist(TH1D* const hist) +double Weight(const double& value, eWeights whichWeight) // value, integrated [phi,pt,eta] weight { - // Copy histogram holding weights from an external file to the corresponding data member. + // Determine particle weight. if (tc.fVerbose) { StartFunction(__FUNCTION__); + LOGF(info, "\033[1;32m value = %f\033[0m", value); + LOGF(info, "\033[1;32m variable = %d\033[0m", static_cast(whichWeight)); } - // Finally: - hist->SetDirectory(0); - cw.fCentralityWeightsHist = reinterpret_cast(hist->Clone()); - - if (!cw.fCentralityWeightsHist) { + if (!pw.fWeightsHist[whichWeight]) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - // Cosmetics: TBI 20240216 do I really want to overwrite initial cosmetics, perhaps this shall go better into MakeCentralityWeights.C ? - // Or I could move all this to GetHistogramWithCentralityWeights, where in any case I am setting e.g. histogram title, etc. - cw.fCentralityWeightsHist->SetStats(kFALSE); - cw.fCentralityWeightsHist->GetXaxis()->SetTitle("Centrality percentile"); - cw.fCentralityWeightsHist->GetYaxis()->SetTitle(Form("Centrality weight (%s)", ec.fsEventCuts[eCentralityEstimator].Data())); - cw.fCentralityWeightsHist->SetFillColor(eFillColor); - cw.fCentralityWeightsHist->SetLineColor(eColor); - if (!cw.fCentralityWeightsList) { - LOGF(fatal, "\033[1;31m%s at line %d: fCentralityWeightsList is NULL. That means that you have called SetCentralityWeightsHist(...) in init(), before this TList was booked.\033[0m", __FUNCTION__, __LINE__); + int bin = pw.fWeightsHist[whichWeight]->FindBin(value); + double weight = 0.; + if (bin > pw.fWeightsHist[whichWeight]->GetNbinsX()) { + weight = 0.; // we are in the overflow, ignore this particle TBI_20210524 is + // this really the correct procedure? + } else { + weight = pw.fWeightsHist[whichWeight]->GetBinContent(bin); } - cw.fCentralityWeightsList->Add(cw.fCentralityWeightsHist); // This is working at the moment, because I am fetching all centrality weights in Preprocess(), which is called after init() - // But if eventually it will be possible to fetch run number programatically in init(), I will have to re-think this line. - - // Flag: - cw.fUseCentralityWeights = kTRUE; if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void SetCentralityWeightsHist(TH1D* const hist) + return weight; + +} // Weight(const double &value, eWeights whichWeight) // value, integrated [phi,pt,eta] weight //============================================================ -TH1D* GetWeightsHist(eWeights whichWeight) +double WeightFromSparse(const double& dPhi, const double& dPt, const double& dEta, const double& dCharge, eDiffWeightCategory dwc) { - // The standard getter. + // Determine differential multidimensional particle weight using sparse histograms. if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // ... + // *) Reduce dimensionality is possible, i.e. look up only the dimensions in THnSparse which were requested in this analysis: + int dim = 1; // yes, because dimension 0 is always reserved for each category + switch (dwc) { + case eDWPhi: { + // Remember that ordering here has to resemble ordering in eDiffPhiWeights + pw.fFindBinVector[dwc]->AddAt(dPhi, 0); // special treatment for phi in eDWPhi category + if (pw.fUseDiffPhiWeights[wPhiPtAxis]) { + pw.fFindBinVector[dwc]->AddAt(dPt, dim++); + } + if (pw.fUseDiffPhiWeights[wPhiEtaAxis]) { + pw.fFindBinVector[dwc]->AddAt(dEta, dim++); + } + if (pw.fUseDiffPhiWeights[wPhiChargeAxis]) { + pw.fFindBinVector[dwc]->AddAt(dCharge, dim++); + } + if (pw.fUseDiffPhiWeights[wPhiCentralityAxis]) { + pw.fFindBinVector[dwc]->AddAt(ebye.fCentrality, dim++); + } + if (pw.fUseDiffPhiWeights[wPhiVertexZAxis]) { + pw.fFindBinVector[dwc]->AddAt(ebye.fVz, dim++); + } + // ... + break; + } + case eDWPt: { + pw.fFindBinVector[dwc]->AddAt(dPt, 0); // special treatment for pt in eDWPt category + // Remember that ordering here has to resemble ordering in eDiffPtWeights + // if(pw.fUseDiffPtWeights[...]) { + // pw.fFindBinVector[dwc]->AddAt(..., dim++); // skeleton for next dimension + // } + // ... + break; + } + case eDWEta: { + pw.fFindBinVector[dwc]->AddAt(dEta, 0); // special treatment for eta in eDWEta category + // Remember that ordering here has to resemble ordering in eDiffEtaWeights + // if(pw.fUseDiffEtaWeights[...]) { + // pw.fFindBinVector[dwc]->AddAt(..., dim++); // skeleton for next dimension + // } + // ... + break; + } + default: { + LOGF(fatal, "\033[1;31m%s at line %d : This differential weight category, dwc = %d, is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(dwc)); + break; + } + } // switch(dwc) + + // *) Insanity check: + // **) ... + if (!pw.fDiffWeightsSparse[dwc]) { + LOGF(fatal, "\033[1;31m dwc = %d\033[0m", static_cast(dwc)); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + // **) Check that dimensions of vector I will use to fetch the right bin content and sparse histogram with weights do match: + if (tc.fInsanityCheckForEachParticle) { + if (pw.fFindBinVector[dwc]->GetSize() != pw.fDiffWeightsSparse[dwc]->GetNdimensions()) { + LOGF(fatal, "\033[1;31m dwc = %d\033[0m", static_cast(dwc)); + LOGF(fatal, "\033[1;31m pw.fFindBinVector[dwc]->GetSize() = %d\033[0m", pw.fFindBinVector[dwc]->GetSize()); + LOGF(fatal, "\033[1;31m pw.fDiffWeightsSparse[dwc]->GetNdimensions() = %d\033[0m", pw.fDiffWeightsSparse[dwc]->GetNdimensions()); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + } // if(tc.fInsanityCheckForEachParticle) + + // *) okay, let's fetch the weight: + int bin = pw.fDiffWeightsSparse[dwc]->GetBin(pw.fFindBinVector[dwc]->GetArray()); // this is the general bin, corresponding to the actual multidimensional bin + // TBI 20250224 do I need some insanity check here, e.g. that bin is neither in overflow nor in underflow? + // If I decide to implement this, remember e.g. for 2D case that all bins of type (0,1), (0,2) ... are underflow of first variable, + // and all bins of type (1,0), (2,0), ... are underflow of second variable. Analogously for overflow. + // Each of these cases, however, have different global bin! + // Total number of linearized global bins for N-dimensional sparse = (N_1 + 2) * (N_2 + 2) * ... (N_N + 2), + // where N_1 is number of bins in first dimension, etc. The offset + 2 in each case counts underflow and overflow. + // Mapping between 2D bins and linearized global bins goes as follows (for an example 2 x 3 histogram): + // 0,0 => 0 + // 1,0 => 1 + // 2,0 => 2 + // 3,0 => 3 + // 0,1 => 4 + // 1,1 => 5 + // ... + // 2,4 => 18 + // 3,4 => 19 + // So, for 2 x 3 histogram, there are (2+2) * (3+2) = 20 linearized global bins. + // Remember that I need to loop first over y dimensions, then nest inside the loop over x dimension, to achieve loop over global bins in consequtive order. + + double weight = pw.fDiffWeightsSparse[dwc]->GetBinContent(bin); if (tc.fVerbose) { ExitFunction(__FUNCTION__); } - // Finally: - return pw.fWeightsHist[whichWeight]; + return weight; -} // TH1D* GetWeightsHist(eWeights whichWeigh) +} // double WeightFromSparse(...) //============================================================ -TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const char* variable, Int_t bin = -1) +double DiffWeight(const double& valueY, const double& valueX, eqvectorKine variableX) { - // Get and return histogram with weights from an external file. - // If bin > 0, differential weights for that bin are searched for. - // If bin = -1, integrated weights are searched for, i.e. in this case "bin" variable has no effect. - // I do it this way, so as to condense GetHistogramWithWeights(...) and GetHistogramWithDiffWeights(...) from MuPa class in - // one routine here, so that I do not duplicate code related to CCDB access, etc. - - // TBI 20240504: Here I can keep const char* variable , i.e. no need to switch to enums, because this function is called only once, at init. - // Nevertheless, I could switch to enums and make it more general, i.e. I could introduce additional data members and configurables, - // for the names of histograms with weights. Like I did it in void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) - - // TBI 20241021 Strictly speaking, I do not need to pass here first 2 arguments, "filePath" and "runNumber", because they are initialized at call from data members. - // But since this function is called only once, it's not an important performance loss. But re-think the design here eventually. - // If I decide to promote filePath to data member, implement it as an array, to allow possibility that different catagories of weights are fetched from different external files. + // Determine differential particle weight y(x). For the time being, "y = phi" always, but this can be generalized. - // a) Return value; - // b) Basic protection for arguments; - // c) Determine from filePath if the file in on a local machine, or in AliEn, or in CCDB; - // d) Handle the AliEn case; - // e) Handle the CCDB case; - // f) Handle the local case; - // g) The final touch on histogram with weights. + // TBI 20250520 This function is now obsolete, use WeightFromSparse(...) instead. if (tc.fVerbose) { StartFunction(__FUNCTION__); - LOGF(info, "\033[1;33m filePath = %s\033[0m", filePath); - LOGF(info, "\033[1;33m runNumber = %s\033[0m", runNumber); - LOGF(info, "\033[1;33m variable = %s\033[0m", variable); - LOGF(info, "\033[1;33m bin = %d (if bin = -1, integrated weights are searched for)\033[0m", bin); - LOGF(info, "\033[1;33m fTaskName = %s\033[0m", tc.fTaskName.Data()); } - // a) Return value: - TH1D* hist = NULL; - TList* baseList = NULL; // base top-level list in the TFile, e.g. named "ccdb_object" - TList* listWithRuns = NULL; // nested list with run-wise TList's holding run-specific weights + // *) Determine first to which bin the 'valueX' corresponds to. + // Based on that, I decide from which histogram I fetch weight for y. See MakeWeights.C - // b) Basic protection for arguments: - // Remark: below I do one more specific check. - if (!(TString(variable).EqualTo("phi") || TString(variable).EqualTo("pt") || TString(variable).EqualTo("eta") || - TString(variable).EqualTo("phipt") || TString(variable).EqualTo("phieta"))) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // *) Mapping between enums "eqvectorKine" on one side, and enums "eAsFunctionOf" and "eDiffWeights" on the other: + eAsFunctionOf AFO_var = eAsFunctionOf_N; // this local variable determines the enum "eAsFunctionOf" which corresponds to enum "eqvectorKine" + eDiffWeights AFO_diffWeight = eDiffWeights_N; // this local variable determines the enum "eDiffWeights" which corresponds to enum "eqvectorKine" + if (variableX == PTq) { + AFO_var = AFO_PT; + AFO_diffWeight = wPHIPT; + } else if (variableX == ETAq) { + AFO_var = AFO_ETA; + AFO_diffWeight = wPHIETA; } - // c) Determine from filePath if the file in on a local machine, or in home - // dir AliEn, or in CCDB: - // Algorithm: If filePath begins with "/alice/cern.ch/" then it's in home - // dir AliEn. If filePath begins with "/alice-ccdb.cern.ch/" then it's in - // CCDB. Therefore, files in AliEn and CCDB must be specified with abs path, - // for local files both abs and relative paths are just fine. - Bool_t bFileIsInAliEn = kFALSE; - Bool_t bFileIsInCCDB = kFALSE; - if (TString(filePath).BeginsWith("/alice/cern.ch/")) { - bFileIsInAliEn = kTRUE; - } else { - if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { - bFileIsInCCDB = kTRUE; - } // else { - } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + // *) Insanity checks on above settings: + if (AFO_var == eAsFunctionOf_N) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_var == eAsFunctionOf_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); + } + if (AFO_diffWeight == eDiffWeights_N) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_diffWeight == eDiffWeights_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); + } - if (bFileIsInAliEn) { - // d) Handle the AliEn case: - TGrid* alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", ""); - if (!alien) { + // *) Determine first to which bin the 'valueX' corresponds to. + // Based on that, I decide from which histogram I fetch weight for y. See MakeWeights.C + int binX = res.fResultsPro[AFO_var]->FindBin(valueX); + if (tc.fInsanityCheckForEachParticle) // enable only during debugging, as this check is computationally heavy. + { + if (binX < 1) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // underflow. this means that I didn't use the same cuts now, and I was using when making the particle weights. Adjust the cuts. } - TFile* weightsFile = TFile::Open(Form("alien://%s", filePath), "READ"); - if (!weightsFile) { + if (binX > res.fResultsPro[AFO_var]->GetNbinsX()) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // overflow. this means that I didn't use the same cuts now, and I was using when making the particle weights. Adjust the cuts. } + } // if(tc.fInsanityCheckForEachParticle) - weightsFile->GetObject( - "ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name - // of base TList is "ccdb_object" also for - // AliEn case, see if I need to change this - if (!baseList) { - // weightsFile->ls(); + // *) Finally, determine weight for y(x): + if (!pw.fDiffWeightsHist[AFO_diffWeight][binX - 1]) { + LOGF(info, "\033[1;32mvalueY = %f\033[0m", valueY); + LOGF(info, "\033[1;32mvalueX = %f\033[0m", valueX); + LOGF(info, "\033[1;32mvariableX = %d\033[0m", static_cast(variableX)); + LOGF(info, "\033[1;32mAFO_diffWeight = %d\033[0m", static_cast(AFO_diffWeight)); + LOGF(info, "\033[1;32mbinX = %d\033[0m", binX); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + int bin = pw.fDiffWeightsHist[AFO_diffWeight][binX - 1]->FindBin(valueY); // binX - 1, because I histogram for first bin in X is labeled with "[0]", etc. + if (tc.fInsanityCheckForEachParticle) // enable only during debugging, as this check is computationally heavy. + { + if (bin < 1) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // underflow. this means that I didn't use the same cuts now, and I was using when making the particle weights. Adjust the cuts. + } + if (bin > pw.fDiffWeightsHist[AFO_diffWeight][binX - 1]->GetNbinsX()) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // overflow. this means that I didn't use the same cuts now, and I was using when making the particle weights. Adjust the cuts. } + } // if(tc.fInsanityCheckForEachParticle) - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); - if (!listWithRuns) { - TString runNumberWithLeadingZeroes = "000"; - runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); - if (!listWithRuns) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } + double diffWeight = pw.fDiffWeightsHist[AFO_diffWeight][binX - 1]->GetBinContent(bin); + if (tc.fInsanityCheckForEachParticle) // enable only during debugging, as this check is computationally heavy. + { + if (diffWeight < 0.) { // or <= 0 ? TBI 20240324 rethink + LOGF(fatal, "\033[1;31m%s at line %d : diffWeight < 0\033[0m", __FUNCTION__, __LINE__); } + } - } else if (bFileIsInCCDB) { + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } - // e) Handle the CCDB case: Remember that here I do not access the file, - // instead directly object in that file. - // My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ - // Inspired by: - // 1. Discussion at: - // https://alice-talk.web.cern.ch/t/access-to-lhc-filling-scheme/1073/17 - // 2. See also: - // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyGlobal.cxx - // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyPerRun.cxx - // 3. O2 Analysis Tutorial 2.0: - // https://indico.cern.ch/event/1267433/timetable/#20230417.detailed + return diffWeight; - ccdb->setURL("http://alice-ccdb.cern.ch"); - if (tc.fVerbose) { - LOGF(info, "\033[1;32mAccessing in CCDB %s\033[0m", TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data()); - } +} // DiffWeight(const double &valueY, const double &valueX, eqvectorKine variableX) - baseList = reinterpret_cast(ccdb->get(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data())); +//============================================================ - if (!baseList) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } +void GetParticleWeights() +{ + // Get the particle weights. Call this function only once. - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); - if (!listWithRuns) { - TString runNumberWithLeadingZeroes = "000"; - runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); - if (!listWithRuns) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - } + // TBI 20231012 Here the current working assumption is that: + // 1) Corrections do not change within a given run; + // 2) Hyperloop proceeses the dataset one masterjob per run number. + // If any of these 2 assumptions are violated, this code will have to be modified. - } else { + // a) Integrated weights; + // b) Differential weights; => TBI 20250225 this is now obsolete and superseeded with c), where I use more general approach with sparse histograms + // c) Differential phi weights using sparse histograms; + // d) Differential pt weights using sparse histograms; + // e) Differential eta weights using sparse histograms. - // f) Handle the local case: - // TBI 20231008 In principle, also for the local case in O2, I could - // maintain the same local structure of weights as it was in AliPhysics. - // But for simplicity, in O2 I organize local weights in the - // same way as in AliEn or CCDB. + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } - // Check if the external ROOT file exists at specified path: - if (gSystem->AccessPathName(filePath, kFileExists)) { - LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // a) Integrated weights: + // integrated phi weights: + if (pw.fUseWeights[wPHI]) { + TH1D* phiWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "phi"); + if (!phiWeights) { + LOGF(fatal, "in function \033[1;31m%s at line %d, phiWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); } + SetWeightsHist(phiWeights, wPHI); + } - TFile* weightsFile = TFile::Open(filePath, "READ"); - if (!weightsFile) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // integrated pt weights: + if (pw.fUseWeights[wPT]) { + TH1D* ptWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "pt"); + if (!ptWeights) { + LOGF(fatal, "\033[1;31m%s at line %d : ptWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); } + SetWeightsHist(ptWeights, wPT); + } - weightsFile->GetObject("ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name - // of base TList is "ccdb_object" also for - // local case, see if I need to change this - if (!baseList) { - // weightsFile->ls(); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // integrated eta weights: + if (pw.fUseWeights[wETA]) { + TH1D* etaWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "eta"); + if (!etaWeights) { + LOGF(fatal, "\033[1;31m%s at line %d : etaWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); } + SetWeightsHist(etaWeights, wETA); + } - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); - if (!listWithRuns) { - TString runNumberWithLeadingZeroes = "000"; - runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); - if (!listWithRuns) { - // baseList->ls(); - LOGF(fatal, "\033[1;31m%s at line %d : this crash can happen if in the output file there is no list with weights for the current run number = %s\033[0m", __FUNCTION__, __LINE__, tc.fRunNumber.Data()); + // b) Differential weights: + // differential phi(pt) weights: + if (pw.fUseDiffWeights[wPHIPT]) { + TH1D* phiptWeights = NULL; + int nPtBins = res.fResultsPro[AFO_PT]->GetXaxis()->GetNbins(); + for (int b = 0; b < nPtBins; b++) { + + // *) check if particles in this pt bin survive particle cuts in pt. If not, skip this bin, because for that pt bin weights are simply not available: + if (!(res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 2) > pc.fdParticleCuts[ePt][eMin])) { + // this branch protects against the case when I am e.g. in pt bin [0.0,0.2], and pt cut is 0.2 < pt < 5.0 + LOGF(info, "\033[1;33m%s at line %d : you are requesting phi(pt) weight for pt bin = %d from (%f,%f), which is outside (below) pt phase space = (%f,%f). Skipping this bin. \033[0m", __FUNCTION__, __LINE__, b, res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 1), res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 2), pc.fdParticleCuts[ePt][eMin], pc.fdParticleCuts[ePt][eMax]); + continue; + } + if (!(res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 1) < pc.fdParticleCuts[ePt][eMax])) { + // this branch protects against the case when I am e.g. in pt bin [5.0,10.0], and pt cut is 0.2 < pt < 5.0 + LOGF(info, "\033[1;33m%s at line %d : you are requesting phi(pt) weight for pt bin = %d from (%f,%f), which is outside (above) pt phase space = (%f,%f). Skipping this bin. \033[0m", __FUNCTION__, __LINE__, b, res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 1), res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 2), pc.fdParticleCuts[ePt][eMin], pc.fdParticleCuts[ePt][eMax]); + continue; } - } - } // else { + // *) okay, this pt bin is within pt phase-space window, defined by pt cut: + phiptWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "phipt", b); + if (!phiptWeights) { + LOGF(fatal, "\033[1;31m%s at line %d : phiptWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); + } - // g) The final touch on histogram with weights: - TString histName = ""; - if (-1 == bin) { - // Integrated weights: - if (!(TString(variable).EqualTo("phi") || TString(variable).EqualTo("pt") || TString(variable).EqualTo("eta"))) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // *) okay, just use this histogram with weights: + SetDiffWeightsHist(phiptWeights, wPHIPT, b); } + } // if (pw.fUseDiffWeights[wPHIPT]) { - // fetch histogram directly from this list: - histName = TString::Format("%s_%s", variable, tc.fTaskName.Data()); - LOGF(info, "\033[1;33m%s at line %d : fetching directly hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); - hist = reinterpret_cast(listWithRuns->FindObject(histName.Data())); - // if the previous search failed, descend recursively also into the nested lists: - if (!hist) { - LOGF(info, "\033[1;33m%s at line %d : previous attempt failed, fetching instead recursively hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); - hist = reinterpret_cast(GetObjectFromList(listWithRuns, histName.Data())); - } - if (!hist) { - histName = TString::Format("%s", variable); // yes, for some simple tests I can have only histogram named e.g. 'phi' - LOGF(info, "\033[1;33m%s at line %d : last attempt, fetching instead hist with trivial name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); - hist = reinterpret_cast(GetObjectFromList(listWithRuns, histName.Data())); - } - if (!hist) { - listWithRuns->ls(); - LOGF(fatal, "\033[1;31m%s at line %d : couldn't fetch hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); - } - hist->SetDirectory(0); - hist->SetTitle(Form("%s, %s", filePath, runNumber)); // I have to do it here, because only here I have "filePath" av + // differential phi(eta) weights: + if (pw.fUseDiffWeights[wPHIETA]) { + TH1D* phietaWeights = NULL; + int nEtaBins = res.fResultsPro[AFO_ETA]->GetXaxis()->GetNbins(); + for (int b = 0; b < nEtaBins; b++) { - } else { - // Differential weights: - if (!(TString(variable).EqualTo("phipt") || TString(variable).EqualTo("phieta"))) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - // fetch histogram directly from this list: - histName = TString::Format("%s[%d]_%s", variable, bin, tc.fTaskName.Data()); - LOGF(info, "\033[1;33m%s at line %d : fetching directly hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); - hist = reinterpret_cast(listWithRuns->FindObject(histName.Data())); - // if the previous search failed, descend recursively also into the nested lists: - if (!hist) { - LOGF(info, "\033[1;33m%s at line %d : previous attempt failed, fetching instead recursively hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); - hist = reinterpret_cast(GetObjectFromList(listWithRuns, Form("%s[%d]_%s", variable, bin, tc.fTaskName.Data()))); - } - if (!hist) { - histName = TString::Format("%s[%d]", variable, bin); // yes, for some simple tests I can have only histogram named e.g. 'phipt[0]' - LOGF(info, "\033[1;33m%s at line %d : last attempt, fetching instead hist with trivial name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); - hist = reinterpret_cast(GetObjectFromList(listWithRuns, histName.Data())); - } - if (!hist) { - listWithRuns->ls(); - LOGF(fatal, "\033[1;31m%s at line %d : couldn't fetch hist with name = %s\033[0m", __FUNCTION__, __LINE__, histName.Data()); - } + // *) check if particles in this eta bin survive particle cuts in eta. If not, skip this bin, because for that eta bin weights are simply not available: + if (!(res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 2) > pc.fdParticleCuts[eEta][eMin])) { + // this branch protects against the case when I am e.g. in eta bin [-1.0,-0.8], and eta cut is -0.8 < eta < 0.8 + LOGF(info, "\033[1;33m%s at line %d : you are requesting phi(eta) weight for eta bin = %d from (%f,%f), which is outside (below) eta phase space = (%f,%f). Skipping this bin. \033[0m", __FUNCTION__, __LINE__, b, res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 1), res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 2), pc.fdParticleCuts[eEta][eMin], pc.fdParticleCuts[eEta][eMax]); + continue; + } + if (!(res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 1) < pc.fdParticleCuts[eEta][eMax])) { + // this branch protects against the case when I am e.g. in eta bin [0.8,1.0], and eta cut is 0.8 < eta < 1.0 + LOGF(info, "\033[1;33m%s at line %d : you are requesting phi(eta) weight for eta bin = %d from (%f,%f), which is outside (above) eta phase space = (%f,%f). Skipping this bin. \033[0m", __FUNCTION__, __LINE__, b, res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 1), res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 2), pc.fdParticleCuts[eEta][eMin], pc.fdParticleCuts[eEta][eMax]); + continue; + } - // *) insanity check for differential weights => check if boundaries of current bin are the same as bin boundaries for which these weights were calculated. - // This way I ensure that weights correspond to same kinematic cuts and binning as in current analysis. - // Current example format which was set in MakeWeights.C: someString(s), min < kinematic-variable-name < max - // Algorithm: IFS is " " and I take (N-1)th and (N-5)th entry: - TObjArray* oa = TString(hist->GetTitle()).Tokenize(" "); - if (!oa) { - LOGF(fatal, "in function \033[1;31m%s at line %d \n hist->GetTitle() = %s\033[0m", __FUNCTION__, __LINE__, hist->GetTitle()); - } - Int_t nEntries = oa->GetEntries(); + // *) okay, this eta bin is within eta phase-space window, defined by eta cut: + phietaWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "phieta", b); + if (!phietaWeights) { + LOGF(fatal, "\033[1;31m%s at line %d : phietaWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); + } - // I need to figure out corresponding variable from results histograms and its formatting: - eAsFunctionOf AFO = eAsFunctionOf_N; - const char* lVariableName = ""; - if (TString(variable).EqualTo("phipt")) { - AFO = AFO_PT; - lVariableName = FancyFormatting("Pt"); - } else if (TString(variable).EqualTo("phieta")) { - AFO = AFO_ETA; - lVariableName = FancyFormatting("Eta"); - } else { - LOGF(fatal, "\033[1;31m%s at line %d : name = %s is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(variable)); + // *) okay, just use this histogram with weights: + SetDiffWeightsHist(phietaWeights, wPHIETA, b); + } // for(int b=0; bGetBinLowEdge(bin + 1); - Float_t max = res.fResultsPro[AFO]->GetBinLowEdge(bin + 2); - if (min > max) { - LOGF(fatal, "\033[1;33m min = %f, max = %f, res.fResultsPro[AFO]->GetName() = %s\033[0m", min, max, res.fResultsPro[AFO]->GetName()); + if (pw.fUseDiffPhiWeights[wPhiCentralityAxis]) { + whichDimensions += "_centrality"; } + if (pw.fUseDiffPhiWeights[wPhiVertexZAxis]) { + whichDimensions += "_vertexZ"; + } + // ... - // Compare with min and max value stored in external weights.root file using MakeWeights.C: - if (!(TMath::Abs(TString(oa->At(nEntries - 1)->GetName()).Atof() - max) < tc.fFloatingPointPrecision)) { - LOGF(info, "\033[1;33m hist->GetTitle() = %s, res.fResultsPro[AFO]->GetName() = %s\033[0m", hist->GetTitle(), res.fResultsPro[AFO]->GetName()); - LOGF(fatal, "in function \033[1;31m%s at line %d : mismatch in upper bin boundaries \n from title = %f , local = %f\033[0m", __FUNCTION__, __LINE__, TString(oa->At(nEntries - 1)->GetName()).Atof(), max); + // TBI-today ... check if particles weights are avaiable for the phase window I have selected for each dimension with cuts + + THnSparseF* diffWeightsSparse = GetSparseHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), whichCategory.Data(), whichDimensions.Data()); + if (!diffWeightsSparse) { + LOGF(fatal, "\033[1;31m%s at line %d : diffWeightsSparse for category \"phi\" is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); } - if (!(TMath::Abs(TString(oa->At(nEntries - 5)->GetName()).Atof() - min) < tc.fFloatingPointPrecision)) { - LOGF(info, "\033[1;33m hist->GetTitle() = %s, res.fResultsPro[AFO]->GetName() = %s\033[0m", hist->GetTitle(), res.fResultsPro[AFO]->GetName()); - LOGF(fatal, "in function \033[1;31m%s at line %d : mismatch in lower bin boundaries \n from title = %f , local = %f\033[0m", __FUNCTION__, __LINE__, TString(oa->At(nEntries - 5)->GetName()).Atof(), min); + + // okay, just use this sparse histogram with weights: + SetDiffWeightsSparse(diffWeightsSparse, eDWPhi); + + } // if (pw.fUseDiffPhiWeights[wPhiPhiAxis]) { + + // d) Differential pt weights using sparse histograms: + if (pw.fUseDiffPtWeights[wPtPtAxis]) { // yes, remember that flag for pt axis serves also as a common boolean to switch off all differential pt weights + + TString whichCategory = "pt"; // differential pt weights + + TString whichDimensions = ""; // differential pt weights as a function of particular dimension + // Remark: the naming convention hardwired here for axes dimensions have to be in sync with what I have in the macro to make these weights + // ... TBI 20250222 proceed here in the same way as above for phi weights + + // TBI-today ... check if particles weights are avaiable for the phase window I have selected for each dimension with cuts + + THnSparseF* diffWeightsSparse = GetSparseHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), whichCategory.Data(), whichDimensions.Data()); + if (!diffWeightsSparse) { + LOGF(fatal, "\033[1;31m%s at line %d : diffWeightsSparse for category \"pt\" is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); } - delete oa; // yes, otherwise it's a memory leak - // *) final settings and cosmetics: - hist->SetDirectory(0); - hist->SetTitle(Form("%s, %.2f < %s < %.2f", filePath, min, lVariableName, max)); + // okay, just use this sparse histogram with weights: + SetDiffWeightsSparse(diffWeightsSparse, eDWPt); - } // else + } // if (pw.fUseDiffPtWeights[wPtPtAxis]) { - // TBI 20241021 if I need to split hist title across two lines, use this technique: - // hist->SetTitle(Form("#splitline{#scale[0.6]{%s}}{#scale[0.4]{%s}}",hist->GetTitle(),filePath)); + // e) Differential eta weights using sparse histograms: + if (pw.fUseDiffEtaWeights[wEtaEtaAxis]) { // yes, remember that flag for eta axis serves also as a common boolean to switch off all differential eta weights + + TString whichCategory = "eta"; // differential eta weights + + TString whichDimensions = ""; // differential eta weights as a function of particular dimension + // Remark: the naming convention hardwired here for axes dimensions have to be in sync with what I have in the macro to make these weights + // ... TBI 20250222 proceed here in the same way as above for phi weights + + // TBI-today ... check if particles weights are avaiable for the phase window I have selected for each dimension with cuts + + THnSparseF* diffWeightsSparse = GetSparseHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), whichCategory.Data(), whichDimensions.Data()); + if (!diffWeightsSparse) { + LOGF(fatal, "\033[1;31m%s at line %d : diffWeightsSparse for category \"pt\" is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); + } + + // okay, just use this sparse histogram with weights: + SetDiffWeightsSparse(diffWeightsSparse, eDWEta); + + } // if (pw.fUseDiffEtaWeights[wEtaEtaAxis]) { if (tc.fVerbose) { ExitFunction(__FUNCTION__); } - return hist; - -} // TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const char* variable, Int_t bin = -1) +} // void GetParticleWeights() //============================================================ -TH1D* GetHistogramWithCentralityWeights(const char* filePath, const char* runNumber) +void GetCentralityWeights() { - // Get and return histogram with centrality weights from an external file. - - // TBI 20241118 Shall I merge this function with GetHistogramWithWeights(...) as there is a bit of code bloat? + // Get the centrality weights. Call this function only once. - // TBI 20241021 Strictly speaking, I do not need to pass here first 2 arguments, "filePath" and "runNumber", because they are initialized at call from data members. - // But since this function is called only once, it's not an important performance loss. But re-think the design here eventually. + // TBI 20231012 Here the current working assumption is that: + // 1) Corrections do not change within a given run; + // 2) Hyperloop proceeses the dataset one masterjob per run number. + // If any of these 2 assumptions are violated, this code will have to be modified. - // a) Return value; - // b) Basic protection for arguments; - // c) Determine from filePath if the file in on a local machine, or in AliEn, or in CCDB; - // d) Handle the AliEn case; - // e) Handle the CCDB case; - // f) Handle the local case; - // g) The final touch on histogram with centrality weights. + // a) Centrality weights; + // b) ... if (tc.fVerbose) { StartFunction(__FUNCTION__); - LOGF(info, "\033[1;33m filePath = %s\033[0m", filePath); - LOGF(info, "\033[1;33m runNumber = %s\033[0m", runNumber); - LOGF(info, "\033[1;33m fTaskName = %s\033[0m", tc.fTaskName.Data()); } - // a) Return value: - TH1D* hist = NULL; - TList* baseList = NULL; // base top-level list in the TFile, e.g. named "ccdb_object" - TList* listWithRuns = NULL; // nested list with run-wise TList's holding run-specific weights + // a) Centrality weights: + if (cw.fUseCentralityWeights) { + TH1D* centralityWeights = GetHistogramWithCentralityWeights(cw.fFileWithCentralityWeights.Data(), tc.fRunNumber.Data()); + if (!centralityWeights) { + LOGF(fatal, "in function \033[1;31m%s at line %d : centralityWeights is NULL. Check the external file %s with centrality weights\033[0m", __FUNCTION__, __LINE__, cw.fFileWithCentralityWeights.Data()); + } + SetCentralityWeightsHist(centralityWeights); + } - // b) Basic protection for arguments: - // ... + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } - // c) Determine from filePath if the file in on a local machine, or in home - // dir AliEn, or in CCDB: - // Algorithm: If filePath begins with "/alice/cern.ch/" then it's in home - // dir AliEn. If filePath begins with "/alice-ccdb.cern.ch/" then it's in - // CCDB. Therefore, files in AliEn and CCDB must be specified with abs path, - // for local files both abs and relative paths are just fine. - Bool_t bFileIsInAliEn = kFALSE; - Bool_t bFileIsInCCDB = kFALSE; - if (TString(filePath).BeginsWith("/alice/cern.ch/")) { - bFileIsInAliEn = kTRUE; - } else { - if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { - bFileIsInCCDB = kTRUE; - } // else { - } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { +} // void GetCentralityWeights() - if (bFileIsInAliEn) { - // d) Handle the AliEn case: - TGrid* alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", ""); - if (!alien) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - TFile* centralityWeightsFile = TFile::Open(Form("alien://%s", filePath), "READ"); - if (!centralityWeightsFile) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } +//============================================================ - centralityWeightsFile->GetObject("ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name - // of base TList is "ccdb_object" also for - // AliEn case, see if I need to change this - if (!baseList) { - // centralityWeightsFile->ls(); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } +double CentralityWeight(const double& value) // centrality value +{ + // Determine centrality weight. - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); - if (!listWithRuns) { - TString runNumberWithLeadingZeroes = "000"; - runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); - if (!listWithRuns) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - } + // Ported directly from double AliAnalysisTaskMuPa::CentralityWeight(const double &value) - } else if (bFileIsInCCDB) { + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } - // e) Handle the CCDB case: Remember that here I do not access the file, - // instead directly object in that file. - // My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ - // Inspired by: - // 1. Discussion at: - // https://alice-talk.web.cern.ch/t/access-to-lhc-filling-scheme/1073/17 - // 2. See also: - // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyGlobal.cxx - // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyPerRun.cxx - // 3. O2 Analysis Tutorial 2.0: - // https://indico.cern.ch/event/1267433/timetable/#20230417.detailed + if (!cw.fCentralityWeightsHist) { + LOGF(fatal, "\033[1;31m%s at line %d : cw.fCentralityWeightsHist is NULL. \033[0m", __FUNCTION__, __LINE__); + } - ccdb->setURL("http://alice-ccdb.cern.ch"); - if (tc.fVerbose) { - LOGF(info, "\033[1;32mAccessing in CCDB %s\033[0m", TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data()); - } + int bin = cw.fCentralityWeightsHist->FindBin(value); + double weight = 0.; + if (bin > cw.fCentralityWeightsHist->GetNbinsX()) { + weight = 0.; // we are in the overflow, ignore this case + } else { + weight = cw.fCentralityWeightsHist->GetBinContent(bin) * cw.fCentralityWeightsHist->GetBinWidth(bin); // yes, since fCentralityWeightsHist is normalized p.d.f. + // (I ensure that with the macro which makes centrality weights) + } - baseList = reinterpret_cast(ccdb->get(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data())); + // In this context, it is assumed that centrality weight is a normalized probability (I ensure that with the macro which makes centrality weights): + if (weight < 0. || weight > 1.) { + LOGF(fatal, "\033[1;31m%s at line %d : weight = %f \033[0m", __FUNCTION__, __LINE__, weight); + } - if (!baseList) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); - if (!listWithRuns) { - TString runNumberWithLeadingZeroes = "000"; - runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); - if (!listWithRuns) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - } + return weight; - } else { +} // double CentralityWeight(const double& value) - // f) Handle the local case: - // TBI 20231008 In principle, also for the local case in O2, I could - // maintain the same local structure of weights as it was in AliPhysics. - // But for simplicity, in O2 I organize local weights in the - // same way as in AliEn or CCDB. +//============================================================ - // Check if the external ROOT file exists at specified path: - if (gSystem->AccessPathName(filePath, kFileExists)) { - LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } +bool MaxNumberOfEvents(eBeforeAfter ba) +{ + // Check if max number of events was reached. Can be used for cut eNumberOfEvents (= total events, with ba = eBefore), and eSelectedEvents (ba = eAfter). - TFile* centralityWeightsFile = TFile::Open(filePath, "READ"); - if (!centralityWeightsFile) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } - // xxxxxxxxxxxx TBI 20241124 remove this code + // *) Return value: + bool reachedMaxNumberOfEvents = false; - hist = reinterpret_cast(centralityWeightsFile->Get("FT0C_Default list name")); // TBI 20241122 temporary workaround - if (!hist) { - Exit(); + // *) Internal validation case (special treatment): + if (iv.fUseInternalValidation) { + if (eh.fEventHistograms[eNumberOfEvents][eSim][eAfter] && (eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1) == ec.fdEventCuts[eNumberOfEvents][eMax] || eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1) == ec.fdEventCuts[eSelectedEvents][eMax])) { + return true; + } else { + return false; } - hist->SetDirectory(0); - hist->SetTitle(Form("%s, %s", filePath, runNumber)); // I have to do it here, because only here I have "filePath" available - return hist; - - // xxxxxxxxxxxx + } - /* - centralityWeightsFile->GetObject("ccdb_object", baseList); // TBI 20231008 for simplicity, hardwired name - // of base TList is "ccdb_object" also for - // local case, see if I need to change this + // *) Determine from which histogram the relevant info will be taken: + int rs = -44; // reconstructed or simulated + if (tc.fProcess[eGenericRec] || tc.fProcess[eGenericRecSim]) { // yes, for tc.fProcess[eGenericRecSim] I take info from Rec part + rs = eRec; + } else if (tc.fProcess[eGenericSim]) { + rs = eSim; + } else { + LOGF(fatal, "\033[1;31m%s at line %d : not a single flag gProcess* is true \033[0m", __FUNCTION__, __LINE__); + } - if (!baseList) { - // centralityWeightsFile->ls(); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } + // *) Okay, do the thing: + switch (ba) { + case eBefore: { + if (eh.fEventHistograms[eNumberOfEvents][rs][eBefore] && eh.fEventHistograms[eNumberOfEvents][rs][eBefore]->GetBinContent(1) == ec.fdEventCuts[eNumberOfEvents][eMax]) { + reachedMaxNumberOfEvents = true; + } + break; + } + case eAfter: { + if (eh.fEventHistograms[eNumberOfEvents][rs][eAfter] && eh.fEventHistograms[eNumberOfEvents][rs][eAfter]->GetBinContent(1) == ec.fdEventCuts[eSelectedEvents][eMax]) { + reachedMaxNumberOfEvents = true; + } + break; + } + default: { + LOGF(fatal, "\033[1;31m%s at line %d : enum ba = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(ba)); + break; + } + } // switch (ba) - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); - if (!listWithRuns) { - TString runNumberWithLeadingZeroes = "000"; - runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number - listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumberWithLeadingZeroes.Data())); - if (!listWithRuns) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - } - */ + // *) Hasta la vista: + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + return reachedMaxNumberOfEvents; - } // else { +} // void MaxNumberOfEvents(eBeforeAfter ba) - // g) The final touch on histogram with centrality weights: +//============================================================ - // TBI 20241211 unify code below with how I implemented below for particle weights +void PrintEventCounter(eBeforeAfter ba) +{ + // Print how many events were processed by now. + // Remark: If I am processing RecSim, the counter is corresponding to Rec. - // fetch histogram directly from this list: - hist = reinterpret_cast(listWithRuns->FindObject(Form("%s_%s", ec.fsEventCuts[eCentralityEstimator].Data(), tc.fTaskName.Data()))); - // if the previous search failed, descend recursively also into the nested lists: - if (!hist) { - hist = reinterpret_cast(GetObjectFromList(listWithRuns, Form("%s_%s", ec.fsEventCuts[eCentralityEstimator].Data(), tc.fTaskName.Data()))); - } - if (!hist) { - hist = reinterpret_cast(GetObjectFromList(listWithRuns, Form("%s", ec.fsEventCuts[eCentralityEstimator].Data()))); // yes, for some simple tests I can have only histogram named e.g. 'CentFT0C' - } - if (!hist) { - listWithRuns->ls(); - LOGF(fatal, "\033[1;31m%s at line %d : \033[0m", __FUNCTION__, __LINE__); + if (tc.fVerbose) { + StartFunction(__FUNCTION__); } - hist->SetDirectory(0); - hist->SetTitle(Form("%s, %s", filePath, runNumber)); // I have to do it here, because only here I have "filePath" available + + // *) Print or die: + switch (ba) { + case eBefore: { + if (!tc.fPlainPrintout) { + LOGF(info, "\033[1;32m%s : processing event %d ....\033[0m", __FUNCTION__, eh.fEventCounter[eTotal]); + } else { + LOGF(info, "%s : processing event %d ....", __FUNCTION__, eh.fEventCounter[eTotal]); + } + break; + } + case eAfter: { + if (!tc.fPlainPrintout) { + LOGF(info, "\033[1;32m%s : event passed all cuts %d/%d\033[0m", __FUNCTION__, eh.fEventCounter[eProcessed], eh.fEventCounter[eTotal]); + } else { + LOGF(info, "%s : event passed all cuts %d/%d", __FUNCTION__, eh.fEventCounter[eProcessed], eh.fEventCounter[eTotal]); + } + break; + } + default: { + LOGF(fatal, "\033[1;31m%s at line %d : enum ba = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(ba)); + break; + } + } // switch (ba) if (tc.fVerbose) { ExitFunction(__FUNCTION__); } - return hist; - -} // TH1D* GetHistogramWithCentralityWeights(const char* filePath, const char* runNumber) +} // void PrintEventCounter(eBeforeAfter ba) //============================================================ -TObjArray* GetDefaultObjArrayWithLabels(const char* whichDefaultLabels) +void EventCounterForDryRun(eEventCounterForDryRun eVar) { - // To speed up testing, I hardwire here some labels and use them directly as they are. + // Simple utility function which either fills histogram with event count, or prints its current content. + // Remark: Use only in combination with tc.fDryRun = true, otherwise I might be filling the same histogram in different member functions, there is a protection below. + // It fills or prints per call, therefore I do not have to pass 'collision' objects, etc. if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // Define TObjArray: - TObjArray* arr = new TObjArray(); - arr->SetOwner(); + if (!tc.fDryRun) { + LOGF(fatal, "\033[1;31m%s at line %d : for the time being, function EventCounterForDryRun(...) can be safely used only for tc.fDryRun = true \033[0m", __FUNCTION__, __LINE__); + } - // Define some labels, depending on the chosen option for whichDefaultLabels: - if (TString(whichDefaultLabels).EqualTo("trivial")) { - const Int_t nLabels = 1; - TString labels[nLabels] = {"2 -2"}; - for (Int_t l = 0; l < nLabels; l++) { - TObjString* objstr = new TObjString(labels[l].Data()); - arr->Add(objstr); - } - } else if (TString(whichDefaultLabels).EqualTo("standard")) { - const Int_t nLabels = 7; - TString labels[nLabels] = {"1 -1", "2 -2", "3 -3", "2 1 -1 -2", "3 1 -1 -3", "3 2 -2 -3", "3 2 1 -1 -2 -3"}; - for (Int_t l = 0; l < nLabels; l++) { - TObjString* objstr = new TObjString(labels[l].Data()); - arr->Add(objstr); - } - } else if (TString(whichDefaultLabels).EqualTo("isotropic")) { - const Int_t nLabels = 8; - TString labels[nLabels] = {"1 -1", "2 -2", "3 -3", "4 -4", "1 1 -1 -1", "2 2 -2 -2", "3 3 -3 -3", "4 4 -4 -4"}; - for (Int_t l = 0; l < nLabels; l++) { - TObjString* objstr = new TObjString(labels[l].Data()); - arr->Add(objstr); - } - } else if (TString(whichDefaultLabels).EqualTo("upto8th")) { - const Int_t nLabels = 7; // yes, because I do not care about 1-p - TString labels[nLabels] = {"1 -1", "1 1 -1", "1 1 -1 -1", "1 1 -1 -1 -1", "1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1"}; - for (Int_t l = 0; l < nLabels; l++) { - TObjString* objstr = new TObjString(labels[l].Data()); - arr->Add(objstr); + switch (eVar) { + case eFill: { + // Fill event counter: + !eh.fEventHistograms[eNumberOfEvents][eRec][eAfter] ? true : eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->Fill(0.5); + !eh.fEventHistograms[eNumberOfEvents][eSim][eAfter] ? true : eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->Fill(0.5); + break; } - } else if (TString(whichDefaultLabels).EqualTo("upto10th")) { - const Int_t nLabels = 9; // yes, because I do not care about 1-p - TString labels[nLabels] = {"1 -1", "1 1 -1", "1 1 -1 -1", "1 1 -1 -1 -1", "1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1 -1", "1 1 1 1 1 -1 -1 -1 -1 -1"}; - for (Int_t l = 0; l < nLabels; l++) { - TObjString* objstr = new TObjString(labels[l].Data()); - arr->Add(objstr); + case ePrint: { + // Print current status of event counter: + // Remark: if I am processing RecSim, the counter is corresponding to Rec. + if (eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]) { + LOGF(info, "Processing event %d (dry run) ....", static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->GetBinContent(1))); + } else if (eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]) { + LOGF(info, "Processing event %d (dry run) ....", static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1))); + } + break; } - } else if (TString(whichDefaultLabels).EqualTo("upto12th")) { - const Int_t nLabels = 11; // yes, because I do not care about 1-p - TString labels[nLabels] = {"1 -1", "1 1 -1", "1 1 -1 -1", "1 1 -1 -1 -1", "1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1", "1 1 1 1 -1 -1 -1 -1 -1", "1 1 1 1 1 -1 -1 -1 -1 -1", "1 1 1 1 1 1 -1 -1 -1 -1 -1", "1 1 1 1 1 1 -1 -1 -1 -1 -1 -1"}; - for (Int_t l = 0; l < nLabels; l++) { - TObjString* objstr = new TObjString(labels[l].Data()); - arr->Add(objstr); + default: { + LOGF(fatal, "\033[1;31m%s at line %d : enum eVar = %d is not supported yet in eEventCounter. \033[0m", __FUNCTION__, __LINE__, static_cast(eVar)); + break; } - } else { - LOGF(fatal, "\033[1;31m%s at line %d : whichDefaultLabels = %s is not supported yet \033[0m", __FUNCTION__, __LINE__, whichDefaultLabels); - } + } // switch(eVar) if (tc.fVerbose) { ExitFunction(__FUNCTION__); } - return arr; - -} // TObjArray* GetDefaultObjArrayWithLabels(const char* whichDefaultLabels) +} // void EventCounterForDryRun(eEventCounterForDryRun eVar) //============================================================ -TObjArray* GetObjArrayWithLabels(const char* filePath) +const char* FancyFormatting(const char* name) { - // This function extracts from an external file TObjArray named "labels", and - // returns it. External file can be: - // 1) on a local computer; - // 2) in home directory AliEn => configurable "cfFileWithLabels" must begin with "/alice/cern.ch/" - // 3) in CCDB => configurable "cfFileWithLabels" must begin with "/alice-ccdb.cern.ch/" - // For all CCDB wisdom, see toggle "CCDB" in page "O2" + // Simple utility function to convert ordinary name into fancier formatting. - // a) Return value; - // b) Determine from filePath if the file in on a local machine, or in AliEn; - // c) Handle the AliEn case; - // d) Handle the CCDB case; - // e) Handle the local case. + // Examples: + // 1. use LaTeX syntax (as supported by ROOT!), for the case when it's possible (e.g. "Phi" => "#{varphi}"); + // 2. add additional information to defalt name (e.g. "Centrality" => "Centrality (V0M)" + // 3. ... - if (tc.fVerbose) { + if (tc.fVerboseUtility) { StartFunction(__FUNCTION__); + LOGF(info, "\033[1;32m const char* name = %s\033[0m", name); } - // a) Return value: - TObjArray* oa = NULL; - - // b) Determine from filePath if the file in on a local machine, or in home - // dir AliEn, or in CCDB: - // Algorithm: If filePath begins with "/alice/cern.ch/" then it's in home - // dir AliEn. - // If filePath begins with "/alice-ccdb.cern.ch/" then it's in - // CCDB. Therefore, files in AliEn and CCDB must be specified - // with abs path, for local files both abs and relative paths - // are just fine. - Bool_t bFileIsInAliEn = kFALSE; - Bool_t bFileIsInCCDB = kFALSE; - if (TString(filePath).BeginsWith("/alice/cern.ch/")) { - bFileIsInAliEn = kTRUE; - } else { - if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { - bFileIsInCCDB = kTRUE; - } // else { - } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + // By default, do nothing and return the same thing: + const char* fancyFormatting = name; - TFile* oaFile = NULL; // file holding TObjArray with all labels - if (bFileIsInAliEn) { - // c) Handle the AliEn case: - TGrid* alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", ""); - if (!alien) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - oaFile = TFile::Open(Form("alien://%s", filePath), "READ"); - if (!oaFile) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // Special cases supported by now: + if (TString(name).EqualTo("Phi", TString::kIgnoreCase)) { + fancyFormatting = "#varphi"; + } else if (TString(name).EqualTo("Pt", TString::kIgnoreCase)) { + fancyFormatting = "p_{T}"; + } else if (TString(name).EqualTo("Eta", TString::kIgnoreCase)) { + fancyFormatting = "#eta"; + } else if (TString(name).EqualTo("VertexX")) { + fancyFormatting = "V_{x}"; + } else if (TString(name).EqualTo("VertexY")) { + fancyFormatting = "V_{y}"; + } else if (TString(name).EqualTo("VertexZ")) { + fancyFormatting = "V_{z}"; + } else if (TString(name).EqualTo("TotalMultiplicity")) { + fancyFormatting = "TotalMultiplicity (tracks.size())"; + } else if (TString(name).EqualTo("Multiplicity", TString::kIgnoreCase)) { + fancyFormatting = Form("Multiplicity (%s)", ec.fsEventCuts[eMultiplicityEstimator].Data()); + } else if (TString(name).EqualTo("ReferenceMultiplicity")) { + fancyFormatting = Form("ReferenceMultiplicity (%s)", ec.fsEventCuts[eReferenceMultiplicityEstimator].Data()); + } else if (TString(name).EqualTo("Centrality", TString::kIgnoreCase)) { + TString tmp = ec.fsEventCuts[eCentralityEstimator]; // I have to introduce local TString tmp, because ReplaceAll replaces in-place + if (tmp.BeginsWith("CentRun2")) { + fancyFormatting = Form("Centrality (%s)", tmp.ReplaceAll("CentRun2", "").Data()); // "CentRun2V0M" => "Centrality (V0M)" + } else if (tmp.BeginsWith("Cent")) { + fancyFormatting = Form("Centrality (%s)", tmp.ReplaceAll("Cent", "").Data()); // "CentFT0C" => "Centrality (FT0C)" + } else { + LOGF(fatal, "\033[1;31m%s at line %d : the case tmp = \"%s\" is not supported yet\033[0m", __FUNCTION__, __LINE__, tmp.Data()); } + } else if (TString(name).EqualTo("Trigger")) { + fancyFormatting = Form("Trigger (%s)", ec.fsEventCuts[eTrigger].Data()); + } else if (TString(name).EqualTo("TrackOccupancyInTimeRange")) { + fancyFormatting = "trackOccupancyInTimeRange()"; + } else if (TString(name).EqualTo("FT0COccupancyInTimeRange")) { + fancyFormatting = "ft0cOccupancyInTimeRange()"; + } else if (TString(name).EqualTo("Occupancy", TString::kIgnoreCase)) { + fancyFormatting = Form("Occupancy (%s)", ec.fsEventCuts[eOccupancyEstimator].Data()); + } else if (TString(name).EqualTo("InteractionRate", TString::kIgnoreCase) || TString(name).EqualTo("Interaction Rate", TString::kIgnoreCase)) { + fancyFormatting = "Interaction Rate [kHz]"; // TBI 20241127 do I leave kHz hardwired here? + } else if (TString(name).EqualTo("CurrentRunDuration", TString::kIgnoreCase) || TString(name).EqualTo("Current Run Duration", TString::kIgnoreCase)) { + fancyFormatting = "Current run duration [s] (i.e. time in seconds since start of run)"; + } - // Fetch TObjArray from external file (keep in sync with local file case below): - TList* lok = oaFile->GetListOfKeys(); - if (!lok) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - for (Int_t l = 0; l < lok->GetEntries(); l++) { - oaFile->GetObject(lok->At(l)->GetName(), oa); - if (oa && TString(oa->ClassName()).EqualTo("TObjArray")) { - break; // TBI 20231107 the working assumption is that in an external file there is only one TObjArray object, - // and here I fetch it, whatever its name is. The advantage is that I do not have to do - // any additional work for TObjArray's name. Since I do not anticipate ever having more than 1 - // TObjArray in an external file, this shall be alright. With the current implementation, - // if there are multiple TObjArray objects in the same ROOT file, the first one will be fetched. - } - } // for(Int_t l=0;lGetEntries();l++) + if (tc.fVerboseUtility) { + ExitFunction(__FUNCTION__); + } - if (!oa) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - } else if (bFileIsInCCDB) { + return fancyFormatting; - // d) Handle the CCDB case: Remember that here I do not access the file, - // instead directly object in that file. - // My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ - // Inspired by: - // 1. Discussion at: - // https://alice-talk.web.cern.ch/t/access-to-lhc-filling-scheme/1073/17 - // 2. See also: - // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyGlobal.cxx - // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyPerRun.cxx - // 3. O2 Analysis Tutorial 2.0: - // https://indico.cern.ch/event/1267433/timetable/#20230417.detailed +} // const char* FancyFormatting(const char *name) - ccdb->setURL("http://alice-ccdb.cern.ch"); - oa = reinterpret_cast(ccdb->get( - TString(filePath) - .ReplaceAll("/alice-ccdb.cern.ch/", "") - .Data())); +//============================================================ - if (!oa) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - } else { +double CalculateCustomNestedLoops(TArrayI* harmonics) +{ + // For the specified harmonics, get the correlation from nested loops. + // Order of correlator is the number of harmonics, i.e. the number of elements in an array. - // e) Handle the local case: - // Check if the external ROOT file exists at specified path: - if (gSystem->AccessPathName(filePath, kFileExists)) { - LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - oaFile = TFile::Open(filePath, "READ"); - if (!oaFile) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // a) Determine the order of correlator; + // b) Custom nested loop; + // c) Return value. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + if (!harmonics) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + int nParticles = ebye.fSelectedTracks; + + // a) Determine the order of correlator; + int order = harmonics->GetSize(); + if (0 == order || order > gMaxCorrelator) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + if (nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order) { + LOGF(info, " nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order, where nl.fMaxNestedLoop = %d, order = %d", nl.fMaxNestedLoop, order); + return 0.; // TBI 20240405 Is this really safe here? Re-think... + } + + // b) Custom nested loop: + TProfile* profile = new TProfile("profile", "", 1, 0., 1.); // helper profile to get all averages automatically + // profile->Sumw2(); + double value = 0.; // cos of current multiplet + double weight = 1.; // weight of current multiplet + for (int i1 = 0; i1 < nParticles; i1++) { + double dPhi1 = nl.ftaNestedLoops[0]->GetAt(i1); + double dW1 = nl.ftaNestedLoops[1]->GetAt(i1); + if (1 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1); + weight = dW1; + profile->Fill(0.5, value, weight); + continue; } + for (int i2 = 0; i2 < nParticles; i2++) { + if (i2 == i1) { + continue; + } + double dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); + double dW2 = nl.ftaNestedLoops[1]->GetAt(i2); + if (2 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2); + weight = dW1 * dW2; + profile->Fill(0.5, value, weight); + continue; + } + for (int i3 = 0; i3 < nParticles; i3++) { + if (i3 == i1 || i3 == i2) { + continue; + } + double dPhi3 = nl.ftaNestedLoops[0]->GetAt(i3); + double dW3 = nl.ftaNestedLoops[1]->GetAt(i3); + if (3 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3); + weight = dW1 * dW2 * dW3; + profile->Fill(0.5, value, weight); + continue; + } + for (int i4 = 0; i4 < nParticles; i4++) { + if (i4 == i1 || i4 == i2 || i4 == i3) { + continue; + } + double dPhi4 = nl.ftaNestedLoops[0]->GetAt(i4); + double dW4 = nl.ftaNestedLoops[1]->GetAt(i4); + if (4 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4); + weight = dW1 * dW2 * dW3 * dW4; + profile->Fill(0.5, value, weight); + continue; + } + for (int i5 = 0; i5 < nParticles; i5++) { + if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) { + continue; + } + double dPhi5 = nl.ftaNestedLoops[0]->GetAt(i5); + double dW5 = nl.ftaNestedLoops[1]->GetAt(i5); + if (5 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5); + weight = dW1 * dW2 * dW3 * dW4 * dW5; + profile->Fill(0.5, value, weight); + continue; + } + for (int i6 = 0; i6 < nParticles; i6++) { + if (i6 == i1 || i6 == i2 || i6 == i3 || i6 == i4 || i6 == i5) { + continue; + } + double dPhi6 = nl.ftaNestedLoops[0]->GetAt(i6); + double dW6 = nl.ftaNestedLoops[1]->GetAt(i6); + if (6 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6; + profile->Fill(0.5, value, weight); + continue; + } + for (int i7 = 0; i7 < nParticles; i7++) { + if (i7 == i1 || i7 == i2 || i7 == i3 || i7 == i4 || i7 == i5 || i7 == i6) { + continue; + } + double dPhi7 = nl.ftaNestedLoops[0]->GetAt(i7); + double dW7 = nl.ftaNestedLoops[1]->GetAt(i7); + if (7 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7; + profile->Fill(0.5, value, weight); + continue; + } + for (int i8 = 0; i8 < nParticles; i8++) { + if (i8 == i1 || i8 == i2 || i8 == i3 || i8 == i4 || i8 == i5 || i8 == i6 || i8 == i7) { + continue; + } + double dPhi8 = nl.ftaNestedLoops[0]->GetAt(i8); + double dW8 = nl.ftaNestedLoops[1]->GetAt(i8); + if (8 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8; + profile->Fill(0.5, value, weight); + continue; + } + for (int i9 = 0; i9 < nParticles; i9++) { + if (i9 == i1 || i9 == i2 || i9 == i3 || i9 == i4 || i9 == i5 || i9 == i6 || i9 == i7 || i9 == i8) { + continue; + } + double dPhi9 = nl.ftaNestedLoops[0]->GetAt(i9); + double dW9 = nl.ftaNestedLoops[1]->GetAt(i9); + if (9 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9; + profile->Fill(0.5, value, weight); + continue; + } + for (int i10 = 0; i10 < nParticles; i10++) { + if (i10 == i1 || i10 == i2 || i10 == i3 || i10 == i4 || i10 == i5 || i10 == i6 || i10 == i7 || i10 == i8 || i10 == i9) { + continue; + } + double dPhi10 = nl.ftaNestedLoops[0]->GetAt(i10); + double dW10 = nl.ftaNestedLoops[1]->GetAt(i10); + if (10 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10; + profile->Fill(0.5, value, weight); + continue; + } + for (int i11 = 0; i11 < nParticles; i11++) { + if (i11 == i1 || i11 == i2 || i11 == i3 || i11 == i4 || i11 == i5 || i11 == i6 || i11 == i7 || i11 == i8 || i11 == i9 || i11 == i10) { + continue; + } + double dPhi11 = nl.ftaNestedLoops[0]->GetAt(i11); + double dW11 = nl.ftaNestedLoops[1]->GetAt(i11); + if (11 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11; + profile->Fill(0.5, value, weight); + continue; + } + for (int i12 = 0; i12 < nParticles; i12++) { + if (i12 == i1 || i12 == i2 || i12 == i3 || i12 == i4 || i12 == i5 || i12 == i6 || i12 == i7 || i12 == i8 || i12 == i9 || i12 == i10 || i12 == i11) { + continue; + } + double dPhi12 = nl.ftaNestedLoops[0]->GetAt(i12); + double dW12 = nl.ftaNestedLoops[1]->GetAt(i12); + if (12 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11 + harmonics->GetAt(11) * dPhi12); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11 * dW12; + profile->Fill(0.5, value, weight); + continue; + } - // Fetch TObjArray from external file (keep in sync with AliEn file case above): - TList* lok = oaFile->GetListOfKeys(); - if (!lok) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - for (Int_t l = 0; l < lok->GetEntries(); l++) { - oaFile->GetObject(lok->At(l)->GetName(), oa); - if (oa && TString(oa->ClassName()).EqualTo("TObjArray")) { - break; // TBI 20231107 the working assumption is that in an external file there is only one TObjArray object, - // and here I fetch it, whatever its name is. The advantage is that I do not have to do - // any additional work for TObjArray's name. Since I do not anticipate ever having more than 1 - // TObjArray in an external file, this shall be alright. With the current implementation, - // if there are multiple TObjArray objects in the same ROOT file, the first one will be fetched. - } - } // for(Int_t l=0;lGetEntries();l++) - if (!oa) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } + // ... it's easy to continue the above pattern here - } // else { + } // for(int i12=0; i12GetBinContent(1); + delete profile; + profile = NULL; if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s => Fetched TObjArray named \"%s\" from file %s\033[0m", __FUNCTION__, oa->GetName(), filePath); ExitFunction(__FUNCTION__); } + return finalValue; - return oa; - -} // TObjArray* GetObjArrayWithLabels(const char *filePath) +} // double CalculateCustomNestedLoops(TArrayI *harmonics) //============================================================ -void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) +double CalculateKineCustomNestedLoops(TArrayI* harmonics, eAsFunctionOf AFO_variable, int bin) { - // Get and set immediately histogram with custom NUA for specified variable, from an external file. - // This structure of an external file is mandatory at the moment: - // *) There is a TList named "ccdb_object", which holds all histograms for custom NUA; - // *) These histograms are TH1D objects. - // This is a port of void FlowWithMultiparticleCorrelationsTask::SetNUAPDF(TH1D* const hist, const char* variable) + // !!! OBSOLETE FUNCTION !!! - // Remark: Unlike for weights and labels, here I am trying to do everythign in the same function, that's why here return type is void, instead of TH1D*. + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! As of 20250529, this is an obsolete function, use double CalculateKineCustomNestedLoops(TArrayI* harmonics, eqvectorKine kineVarChoice, int bin) instead !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); - // TBI 20240501 there is a bit of code repetition below, add with analogous functions GetHistogramWithWeights(...) and GetObjArrayWithLabels(...) + // For the specified harmonics, kine variable, and bin, get the correlation from nested loops. + // Order of correlator is the number of harmonics, i.e. the number of elements in an array. - // a) Local objects; - // b) Basic protection for arguments; - // c) Determine from filePath if the file in on a local machine, or in AliEn, or in CCDB; - // d) Handle the AliEn case; - // e) Handle the CCDB case; - // f) Handle the local case; - // g) The final touch. + // a) Determine the order of correlator; + // b) Custom nested loop; + // c) Return value. if (tc.fVerbose) { StartFunction(__FUNCTION__); - LOGF(info, "\033[1;32m filePath = %s\033[0m", filePath); - LOGF(info, "\033[1;32m variable = %d\033[0m", static_cast(variable)); - LOGF(info, "\033[1;32m nua.fCustomNUAPDFHistNames[variable]->Data() = %s\033[0m", nua.fCustomNUAPDFHistNames[variable]->Data()); - LOGF(info, "\033[1;32m fTaskName = %s\033[0m", tc.fTaskName.Data()); } - // *) Basic protection: - if (nua.fCustomNUAPDFHistNames[variable] && nua.fCustomNUAPDFHistNames[variable]->EqualTo("")) { - LOGF(info, "\033[1;32m empty TString, variable = %d\033[0m", static_cast(variable)); + if (!harmonics) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - // a) Local objects: - TH1D* hist = NULL; - TList* baseList = NULL; // base top-level list in the TFile, always named "ccdb_object" - - // b) Basic protection for arguments: - // ... - - // c) Determine from filePath if the file in on a local machine, or in home dir AliEn, or in CCDB: - // Algorithm: - // *) If filePath begins with "/alice/cern.ch/" then it's in home dir AliEn. - // *) If filePath begins with "/alice-ccdb.cern.ch/" then it's in CCDB. - // *) It's a local file otherwise. - // Therefore, files in AliEn and CCDB must be specified with abs path, for local files both abs and relative paths are just fine. - Bool_t bFileIsInAliEn = kFALSE; - Bool_t bFileIsInCCDB = kFALSE; - if (TString(filePath).BeginsWith("/alice/cern.ch/")) { - bFileIsInAliEn = kTRUE; - } else { - if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { - bFileIsInCCDB = kTRUE; - } // else { - } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { - - if (bFileIsInAliEn) { - // d) Handle the AliEn case: - TGrid* alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", ""); - if (!alien) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - TFile* customNUAFile = TFile::Open(Form("alien://%s", filePath), "READ"); - if (!customNUAFile) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - customNUAFile->GetObject("ccdb_object", baseList); - if (!baseList) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - - } else if (bFileIsInCCDB) { - - // e) Handle the CCDB case: Remember that here I do not access the file, instead directly object in that file. - // My home dir in CCDB: https://alice-ccdb.cern.ch/browse/Users/a/abilandz/ - // Inspired by: - // 1. Discussion at: - // https://alice-talk.web.cern.ch/t/access-to-lhc-filling-scheme/1073/17 - // 2. See also: - // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyGlobal.cxx - // https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/efficiencyPerRun.cxx - // 3. O2 Analysis Tutorial 2.0: - // https://indico.cern.ch/event/1267433/timetable/#20230417.detailed - - ccdb->setURL("http://alice-ccdb.cern.ch"); - if (tc.fVerbose) { - LOGF(info, "\033[1;32mAccessing in CCDB %s\033[0m", TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data()); - } - - baseList = reinterpret_cast(ccdb->get(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data())); - - if (!baseList) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // *) ... + eqvectorKine qvKine = eqvectorKine_N; // which component of q-vector + TString kineVarName = ""; + switch (AFO_variable) { + case AFO_PT: { + qvKine = PTq; + kineVarName = "pt"; + break; } - - } else { - - // f) Handle the local case: - - // Check if the external ROOT file exists at specified path: - if (gSystem->AccessPathName(filePath, kFileExists)) { - LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + case AFO_ETA: { + qvKine = ETAq; + kineVarName = "eta"; + break; } - - TFile* customNUAFile = TFile::Open(filePath, "READ"); - if (!customNUAFile) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + case AFO_CHARGE: { + qvKine = CHARGEq; + kineVarName = "charge"; + break; } - customNUAFile->GetObject("ccdb_object", baseList); - if (!baseList) { - // customNUAFile->ls(); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + default: { + LOGF(fatal, "\033[1;31m%s at line %d : This AFO_variable = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable)); + break; } + } // switch(AFO_variable) - // hist = reinterpret_cast(GetObjectFromList(baseList, nua.fCustomNUAPDFHistNames[variable]->Data())); - - } // else { - - // g) The final touch: - hist = reinterpret_cast(GetObjectFromList(baseList, nua.fCustomNUAPDFHistNames[variable]->Data())); - if (!hist) { - LOGF(info, "\033[1;31m hist is NULL \033[0m"); - LOGF(info, "\033[1;31m variable = %d\033[0m", static_cast(variable)); - LOGF(info, "\033[1;31m nua.fCustomNUAPDFHistNames[variable]->Data() = %s\033[0m", nua.fCustomNUAPDFHistNames[variable]->Data()); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // *) Insanity checks on above settings: + if (qvKine == eqvectorKine_N) { + LOGF(fatal, "\033[1;31m%s at line %d : qvKine == eqvectorKine_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); } - hist->SetDirectory(0); - nua.fCustomNUAPDF[variable] = reinterpret_cast(hist->Clone()); - nua.fCustomNUAPDF[variable]->SetTitle(Form("%s", filePath)); - - // TBI 20240501 if additional cosmetics is needed, it can be implemented here - if (tc.fVerbose) { - ExitFunction(__FUNCTION__); + if (0 > bin || res.fResultsPro[AFO_variable]->GetNbinsX() < bin) { // this 'bin' starts from 0, i.e. this is an array bin + // either underflow or overflow is hit, meaning that histogram is booked in narrower range than cuts + LOGF(fatal, "\033[1;31m%s at line %d => AFO_variable = %d, bin = %d\033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable), bin); } -} // void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) - -//============================================================ - -void StoreLabelsInPlaceholder() -{ - // Storal all Test0 labels in the temporary placeholder. - - // a) Initialize all counters; - // b) Fetch TObjArray with labels from an external file; - // c) Book the placeholder fTest0LabelsPlaceholder for all labels; - // d) Finally, store the labels from external source into placeholder; - // e) Insantity check on labels. + // Get the number of particles in this kine bin: + int nParticles = 0; + for (int i = 0; i < nl.ftaNestedLoopsKine[qvKine][bin][0]->GetSize(); i++) { + if (std::abs(nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i)) > 0.) { + nParticles++; + } + } - if (tc.fVerbose) { - StartFunction(__FUNCTION__); + // 'qvKine' is enum eqvectorKine: + if (!res.fResultsPro[AFO_variable]) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_variable = %d, bin = %d \033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable), bin); } - // a) Initialize all counters; - Int_t counter[gMaxCorrelator] = {0}; // is this safe? - for (Int_t o = 0; o < gMaxCorrelator; o++) { - counter[o] = 0; - } // now it's safe :-) + LOGF(info, " Processing qvKine = %d (vs. %s), nParticles in this kine bin = %d, bin range = [%f,%f) ....", static_cast(qvKine), kineVarName.Data(), nParticles, res.fResultsPro[AFO_variable]->GetBinLowEdge(bin + 1), res.fResultsPro[AFO_variable]->GetBinLowEdge(bin + 2)); - // b) Fetch TObjArray with labels from an external file: - TObjArray* oa = NULL; - if (t0.fUseDefaultLabels) { - oa = GetDefaultObjArrayWithLabels(t0.fWhichDefaultLabels.Data()); - } else { - oa = GetObjArrayWithLabels(t0.fFileWithLabels.Data()); - } - if (!oa) { - LOGF(info, "\033[1;33m fFileWithLabels = %s \033[0m", - t0.fFileWithLabels.Data()); + // a) Determine the order of correlator; + int order = harmonics->GetSize(); + if (0 == order || order > gMaxCorrelator) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } + if (order > nParticles) { + LOGF(info, " There is no enough particles in this bin to calculate the requested correlator"); + return 0.; // TBI 20240405 Is this really safe here? Re-think... + } + if (nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order) { + LOGF(info, " nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order, where nl.fMaxNestedLoop = %d, order = %d", nl.fMaxNestedLoop, order); + return 0.; // TBI 20240405 Is this really safe here? Re-think... + } - // c) Book the placeholder fTest0LabelsPlaceholder for all labels: - Int_t nLabels = oa->GetEntries(); - t0.fTest0LabelsPlaceholder = - new TH1I("fTest0LabelsPlaceholder", - Form("placeholder for all labels, %d in total", nLabels), - nLabels, 0, nLabels); - t0.fTest0LabelsPlaceholder->SetStats(kFALSE); - - // d) Finally, store the labels from external source into placeholder: - Int_t bin = 1; // used only for fTest0LabelsPlaceholder - Int_t order = -44; - for (Int_t e = 0; e < nLabels; e++) { - TObjArray* temp = TString(oa->At(e)->GetName()).Tokenize(" "); - if (!temp) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - order = temp->GetEntries(); - delete temp; // yes, otherwise it's a memory leak - if (0 == order) { + // b) Custom nested loop: + TProfile* profile = new TProfile("profile", "", 1, 0., 1.); // helper profile to get all averages automatically + // profile->Sumw2(); + double value = 0.; // cos of current multiplet + double weight = 1.; // weight of current multiplet + for (int i1 = 0; i1 < nParticles; i1++) { + double dPhi1 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i1); + double dW1 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i1); + if (1 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1); + weight = dW1; + profile->Fill(0.5, value, weight); continue; - } // empty lines, or the label format which is not supported - // 1-p => 0, 2-p => 1, etc.: - t0.fTest0Labels[order - 1][counter[order - 1]] = - new TString(oa->At(e)->GetName()); // okay... - t0.fTest0LabelsPlaceholder->GetXaxis()->SetBinLabel( - bin++, t0.fTest0Labels[order - 1][counter[order - 1]]->Data()); - // cout<<__LINE__<<": - // "<Data()<GetEntries()<GetXaxis()->GetNbins(); b++) { - TObjArray* temp = TString(t0.fTest0LabelsPlaceholder->GetXaxis()->GetBinLabel(b)).Tokenize(" "); - for (Int_t h = 0; h < temp->GetEntries(); h++) { - if (TMath::Abs(TString(temp->At(h)->GetName()).Atoi()) > gMaxHarmonic) { - LOGF(info, "\033[1;31m bin = %d, label = %s, gMaxHarmonic = %d\033[0m", b, t0.fTest0LabelsPlaceholder->GetXaxis()->GetBinLabel(b), static_cast(gMaxHarmonic)); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } // if(TString(temp->At(h)->GetName()).Atoi() > gMaxHarmonic) { - } // for(Int_t h = 0; h < temp->GetEntries(); h++) { - delete temp; // yes, otherwise it's a memory leak - } // for(Int_t b = 1; b <= t0.fTest0LabelsPlaceholder->GetXaxis()->GetNbins(); b++) { + } + for (int i2 = 0; i2 < nParticles; i2++) { + if (i2 == i1) { + continue; + } + double dPhi2 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i2); + double dW2 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i2); + if (2 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2); + weight = dW1 * dW2; + profile->Fill(0.5, value, weight); + continue; + } + for (int i3 = 0; i3 < nParticles; i3++) { + if (i3 == i1 || i3 == i2) { + continue; + } + double dPhi3 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i3); + double dW3 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i3); + if (3 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3); + weight = dW1 * dW2 * dW3; + profile->Fill(0.5, value, weight); + continue; + } + for (int i4 = 0; i4 < nParticles; i4++) { + if (i4 == i1 || i4 == i2 || i4 == i3) { + continue; + } + double dPhi4 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i4); + double dW4 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i4); + if (4 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4); + weight = dW1 * dW2 * dW3 * dW4; + profile->Fill(0.5, value, weight); + continue; + } + for (int i5 = 0; i5 < nParticles; i5++) { + if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) { + continue; + } + double dPhi5 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i5); + double dW5 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i5); + if (5 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5); + weight = dW1 * dW2 * dW3 * dW4 * dW5; + profile->Fill(0.5, value, weight); + continue; + } + for (int i6 = 0; i6 < nParticles; i6++) { + if (i6 == i1 || i6 == i2 || i6 == i3 || i6 == i4 || i6 == i5) { + continue; + } + double dPhi6 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i6); + double dW6 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i6); + if (6 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6; + profile->Fill(0.5, value, weight); + continue; + } + for (int i7 = 0; i7 < nParticles; i7++) { + if (i7 == i1 || i7 == i2 || i7 == i3 || i7 == i4 || i7 == i5 || i7 == i6) { + continue; + } + double dPhi7 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i7); + double dW7 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i7); + if (7 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7; + profile->Fill(0.5, value, weight); + continue; + } + for (int i8 = 0; i8 < nParticles; i8++) { + if (i8 == i1 || i8 == i2 || i8 == i3 || i8 == i4 || i8 == i5 || i8 == i6 || i8 == i7) { + continue; + } + double dPhi8 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i8); + double dW8 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i8); + if (8 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8; + profile->Fill(0.5, value, weight); + continue; + } + for (int i9 = 0; i9 < nParticles; i9++) { + if (i9 == i1 || i9 == i2 || i9 == i3 || i9 == i4 || i9 == i5 || i9 == i6 || i9 == i7 || i9 == i8) { + continue; + } + double dPhi9 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i9); + double dW9 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i9); + if (9 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9; + profile->Fill(0.5, value, weight); + continue; + } + for (int i10 = 0; i10 < nParticles; i10++) { + if (i10 == i1 || i10 == i2 || i10 == i3 || i10 == i4 || i10 == i5 || i10 == i6 || i10 == i7 || i10 == i8 || i10 == i9) { + continue; + } + double dPhi10 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i10); + double dW10 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i10); + if (10 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10; + profile->Fill(0.5, value, weight); + continue; + } + for (int i11 = 0; i11 < nParticles; i11++) { + if (i11 == i1 || i11 == i2 || i11 == i3 || i11 == i4 || i11 == i5 || i11 == i6 || i11 == i7 || i11 == i8 || i11 == i9 || i11 == i10) { + continue; + } + double dPhi11 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i11); + double dW11 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i11); + if (11 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11; + profile->Fill(0.5, value, weight); + continue; + } + for (int i12 = 0; i12 < nParticles; i12++) { + if (i12 == i1 || i12 == i2 || i12 == i3 || i12 == i4 || i12 == i5 || i12 == i6 || i12 == i7 || i12 == i8 || i12 == i9 || i12 == i10 || i12 == i11) { + continue; + } + double dPhi12 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i12); + double dW12 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i12); + if (12 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11 + harmonics->GetAt(11) * dPhi12); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11 * dW12; + profile->Fill(0.5, value, weight); + continue; + } + + // ... it's easy to continue the above pattern here + + } // for(int i12=0; i12GetBinContent(1); + delete profile; + profile = NULL; if (tc.fVerbose) { ExitFunction(__FUNCTION__); } + return finalValue; -} // void StoreLabelsInPlaceholder() +} // double CalculateKineCustomNestedLoops(TArrayI *harmonics, eAsFunctionOf AFO_variable, int bin) //============================================================ -Bool_t RetrieveCorrelationsLabels() +double CalculateKineCustomNestedLoops(TArrayI* harmonics, eqvectorKine kineVarChoice, int bin) { - // Generate the labels of all correlations of interest, i.e. retrieve them - // from TH1I *t0.fTest0LabelsPlaceholder + // For the specified harmonics, kine variable, and bin, get the correlation from nested loops. + // Order of correlator is the number of harmonics, i.e. the number of elements in an array. + + // a) Determine the order of correlator; + // b) Custom nested loop; + // c) Return value. if (tc.fVerbose) { StartFunction(__FUNCTION__); } - Int_t counter[gMaxCorrelator] = {0}; // is this safe? - for (Int_t o = 0; o < gMaxCorrelator; o++) { - counter[o] = 0; - } // now it's safe :-) + if (!harmonics) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } - Int_t nBins = t0.fTest0LabelsPlaceholder->GetXaxis()->GetNbins(); + // TBI 20250529 add protection for b in underflow or overflow - Int_t order = -44; - for (Int_t b = 1; b <= nBins; b++) { - TObjArray* oa = TString(t0.fTest0LabelsPlaceholder->GetXaxis()->GetBinLabel(b)) - .Tokenize(" "); - if (!oa) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // Get the number of particles in this kine bin: + int nParticles = 0; + for (int i = 0; i < nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetSize(); i++) { + if (std::abs(nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i)) > 0.) { + nParticles++; } - order = oa->GetEntries(); - delete oa; // yes, otherwise it's a memory leak - if (0 == order) { - continue; - } // empty lines, or the label format which is not supported - // 1-p => 0, 2-p => 1, etc.: - t0.fTest0Labels[order - 1][counter[order - 1]] = new TString(t0.fTest0LabelsPlaceholder->GetXaxis()->GetBinLabel(b)); // okay... - counter[order - 1]++; - } // for(Int_t b=1;b<=nBins;b++) - - if (tc.fVerbose) { - ExitFunction(__FUNCTION__); } - return kTRUE; - -} // Bool_t RetrieveCorrelationsLabels() - -//============================================================ - -TObject* GetObjectFromList(TList* list, const Char_t* objectName) // Last update: 20210918 -{ - // Get TObject pointer from TList, even if it's in some nested TList. Foreseen - // to be used to fetch histograms or profiles from files directly. Some ideas - // taken from TCollection::ls() If you have added histograms directly to files - // (without TList's), then you can fetch them directly with - // file->Get("hist-name"). - - // Usage: TH1D *hist = (TH1D*) - // GetObjectFromList("some-valid-TList-pointer","some-object-name"); - - // Example 1: - // GetObjectFromList("some-valid-TList-pointer","some-object-name")->Draw(); - // // yes, for histograms and profiles this is just fine, at least in - // interpreted code - - // To do: - // a) Check if I can make it working in compiled mode. - // b) If I have objects with same name, nested in different TLists, what then? - - if (tc.fVerbose) { - StartFunction(__FUNCTION__); + // It doesn't hurt to do here insanity check on the number of particles, in case I have already calculated it independently when calculating diff. q-vectors: + if (qv.fCalculateqvectorsKineAny && qv.fqvectorEntries[kineVarChoice][bin] > 0) { // TBI 20250602 I think this chained condition is ok, but re-think nevertheless + if (!(nParticles == qv.fqvectorEntries[kineVarChoice][bin])) { + LOGF(fatal, "\033[1;31m%s at line %d : nParticles = %d, qv.fqvectorEntries[kineVarChoice][bin] = %d, kineVarChoices = %d (%s), bin = %d\033[0m", __FUNCTION__, __LINE__, nParticles, qv.fqvectorEntries[kineVarChoice][bin], static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), bin); + } } - // Insanity checks: - if (!list) { + // a) Determine the order of correlator; + int order = harmonics->GetSize(); + if (0 == order || order > gMaxCorrelator) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - if (!objectName) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + if (order > nParticles) { + LOGF(info, " There is no enough particles in this bin to calculate the requested correlator"); + return 0.; // TBI 20240405 Is this really safe here? Re-think... } - if (0 == list->GetEntries()) { - return NULL; + if (nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order) { + LOGF(info, " nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order, where nl.fMaxNestedLoop = %d, order = %d", nl.fMaxNestedLoop, order); + return 0.; // TBI 20240405 Is this really safe here? Re-think... } - // The object is in the current base list: - TObject* objectFinal = - list->FindObject(objectName); // final object I am after - if (objectFinal) - return objectFinal; + // b) Custom nested loop: + TProfile* profile = new TProfile("profile", "", 1, 0., 1.); // helper profile to get all averages automatically + // profile->Sumw2(); + double value = 0.; // cos of current multiplet + double weight = 1.; // weight of current multiplet + for (int i1 = 0; i1 < nParticles; i1++) { + double dPhi1 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i1); + double dW1 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i1); + if (1 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1); + weight = dW1; + profile->Fill(0.5, value, weight); + continue; + } + for (int i2 = 0; i2 < nParticles; i2++) { + if (i2 == i1) { + continue; + } + double dPhi2 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i2); + double dW2 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i2); + if (2 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2); + weight = dW1 * dW2; + profile->Fill(0.5, value, weight); + continue; + } + for (int i3 = 0; i3 < nParticles; i3++) { + if (i3 == i1 || i3 == i2) { + continue; + } + double dPhi3 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i3); + double dW3 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i3); + if (3 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3); + weight = dW1 * dW2 * dW3; + profile->Fill(0.5, value, weight); + continue; + } + for (int i4 = 0; i4 < nParticles; i4++) { + if (i4 == i1 || i4 == i2 || i4 == i3) { + continue; + } + double dPhi4 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i4); + double dW4 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i4); + if (4 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4); + weight = dW1 * dW2 * dW3 * dW4; + profile->Fill(0.5, value, weight); + continue; + } + for (int i5 = 0; i5 < nParticles; i5++) { + if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) { + continue; + } + double dPhi5 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i5); + double dW5 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i5); + if (5 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5); + weight = dW1 * dW2 * dW3 * dW4 * dW5; + profile->Fill(0.5, value, weight); + continue; + } + for (int i6 = 0; i6 < nParticles; i6++) { + if (i6 == i1 || i6 == i2 || i6 == i3 || i6 == i4 || i6 == i5) { + continue; + } + double dPhi6 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i6); + double dW6 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i6); + if (6 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6; + profile->Fill(0.5, value, weight); + continue; + } + for (int i7 = 0; i7 < nParticles; i7++) { + if (i7 == i1 || i7 == i2 || i7 == i3 || i7 == i4 || i7 == i5 || i7 == i6) { + continue; + } + double dPhi7 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i7); + double dW7 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i7); + if (7 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7; + profile->Fill(0.5, value, weight); + continue; + } + for (int i8 = 0; i8 < nParticles; i8++) { + if (i8 == i1 || i8 == i2 || i8 == i3 || i8 == i4 || i8 == i5 || i8 == i6 || i8 == i7) { + continue; + } + double dPhi8 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i8); + double dW8 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i8); + if (8 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8; + profile->Fill(0.5, value, weight); + continue; + } + for (int i9 = 0; i9 < nParticles; i9++) { + if (i9 == i1 || i9 == i2 || i9 == i3 || i9 == i4 || i9 == i5 || i9 == i6 || i9 == i7 || i9 == i8) { + continue; + } + double dPhi9 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i9); + double dW9 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i9); + if (9 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9; + profile->Fill(0.5, value, weight); + continue; + } + for (int i10 = 0; i10 < nParticles; i10++) { + if (i10 == i1 || i10 == i2 || i10 == i3 || i10 == i4 || i10 == i5 || i10 == i6 || i10 == i7 || i10 == i8 || i10 == i9) { + continue; + } + double dPhi10 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i10); + double dW10 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i10); + if (10 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10; + profile->Fill(0.5, value, weight); + continue; + } + for (int i11 = 0; i11 < nParticles; i11++) { + if (i11 == i1 || i11 == i2 || i11 == i3 || i11 == i4 || i11 == i5 || i11 == i6 || i11 == i7 || i11 == i8 || i11 == i9 || i11 == i10) { + continue; + } + double dPhi11 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i11); + double dW11 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i11); + if (11 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11; + profile->Fill(0.5, value, weight); + continue; + } + for (int i12 = 0; i12 < nParticles; i12++) { + if (i12 == i1 || i12 == i2 || i12 == i3 || i12 == i4 || i12 == i5 || i12 == i6 || i12 == i7 || i12 == i8 || i12 == i9 || i12 == i10 || i12 == i11) { + continue; + } + double dPhi12 = nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->GetAt(i12); + double dW12 = nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->GetAt(i12); + if (12 == order) { + value = std::cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11 + harmonics->GetAt(11) * dPhi12); + weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11 * dW12; + profile->Fill(0.5, value, weight); + continue; + } + + // ... it's easy to continue the above pattern here - // Search for object recursively in the nested lists: - TObject* objectIter; // iterator object in the loop below - TIter next(list); - while ( - (objectIter = next())) // double round braces are to silent the warnings - { - if (TString(objectIter->ClassName()).EqualTo("TList")) { - objectFinal = GetObjectFromList(reinterpret_cast(objectIter), objectName); - if (objectFinal) - return objectFinal; - } - } // while(objectIter = next()) + } // for(int i12=0; i12GetBinContent(1); + delete profile; + profile = NULL; if (tc.fVerbose) { ExitFunction(__FUNCTION__); } + return finalValue; - return NULL; - -} // TObject* GetObjectFromList(TList *list, Char_t *objectName) +} // double CalculateKineCustomNestedLoops(TArrayI *harmonics, eAsFunctionOf AFO_variable, int bin) //============================================================ -Double_t Weight(const Double_t& value, eWeights whichWeight) // value, integrated [phi,pt,eta] weight +void DetermineMultiplicity() { - // Determine particle weight. + // Determine multiplicity for "vs. mult" results. if (tc.fVerbose) { StartFunction(__FUNCTION__); - LOGF(info, "\033[1;32m value = %f\033[0m", value); - LOGF(info, "\033[1;32m variable = %d\033[0m", static_cast(whichWeight)); - } - - if (!pw.fWeightsHist[whichWeight]) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - Int_t bin = pw.fWeightsHist[whichWeight]->FindBin(value); - Double_t weight = 0.; - if (bin > pw.fWeightsHist[whichWeight]->GetNbinsX()) { - weight = 0.; // we are in the overflow, ignore this particle TBI_20210524 is - // this really the correct procedure? + if (ec.fsEventCuts[eMultiplicityEstimator].EqualTo("SelectedTracks", TString::kIgnoreCase)) { + ebye.fMultiplicity = static_cast(ebye.fSelectedTracks); + } else if (ec.fsEventCuts[eMultiplicityEstimator].EqualTo("ReferenceMultiplicity", TString::kIgnoreCase)) { + ebye.fMultiplicity = ebye.fReferenceMultiplicity; } else { - weight = pw.fWeightsHist[whichWeight]->GetBinContent(bin); + LOGF(fatal, "\033[1;31m%s at line %d : multiplicity estimator = %s is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eMultiplicityEstimator].Data()); } if (tc.fVerbose) { ExitFunction(__FUNCTION__); } - return weight; - -} // Weight(const Double_t &value, eWeights whichWeight) // value, integrated [phi,pt,eta] weight +} // void DetermineMultiplicity() //============================================================ -Double_t DiffWeight(const Double_t& valueY, const Double_t& valueX, eqvectorKine variableX) +template +void DetermineReferenceMultiplicity(T const& collision) { - // Determine differential particle weight y(x). For the time being, "y = phi" always, but this can be generalized. + // Determine collision reference multiplicity. + + // a) Determine reference multiplicity for real Run 3 data; + // b) Determine reference multiplicity for simulated Run 3 data; + // c) Same as a), just for converted Run 2 and Run 1 data; + // d) Same as b), just for converted Run 2 and Run 1 data; + // e) Test case; + // f) Print reference multiplicity for the audience... if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // *) Determine first to which bin the 'valueX' corresponds to. - // Based on that, I decide from which histogram I fetch weight for y. See MakeWeights.C + // a) Determine reference multiplicity for real Run 3 data: + if constexpr (rs == eRec || rs == eRecAndSim || rs == eQA) { + // Local convention for name of reference multiplicity estimator: use the same name as the getter, case insensitive. + if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multTPC", TString::kIgnoreCase)) { + ebye.fReferenceMultiplicity = collision.multTPC(); + } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multFV0M", TString::kIgnoreCase)) { + ebye.fReferenceMultiplicity = collision.multFV0M(); + } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multFT0C", TString::kIgnoreCase)) { + ebye.fReferenceMultiplicity = collision.multFT0C(); + } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multFT0M", TString::kIgnoreCase)) { + ebye.fReferenceMultiplicity = collision.multFT0M(); + } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multNTracksPV", TString::kIgnoreCase)) { + ebye.fReferenceMultiplicity = collision.multNTracksPV(); + } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multNTracksGlobal", TString::kIgnoreCase)) { + // ebye.fReferenceMultiplicity = collision.multNTracksGlobal(); // TBI 20241209 not validated yet + } else { + LOGF(fatal, "\033[1;31m%s at line %d : reference multiplicity estimator = %d is not supported yet for Run 3. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eReferenceMultiplicityEstimator].Data()); + } + // QA: + if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific + qa.fReferenceMultiplicity[eMultTPC] = collision.multTPC(); + qa.fReferenceMultiplicity[eMultFV0M] = collision.multFV0M(); + qa.fReferenceMultiplicity[eMultFT0C] = collision.multFT0C(); + qa.fReferenceMultiplicity[eMultFT0M] = collision.multFT0M(); + qa.fReferenceMultiplicity[eMultNTracksPV] = collision.multNTracksPV(); + // qa.fReferenceMultiplicity[eMultNTracksGlobal] = collision.multNTracksGlobal(); // TBI 20241209 not validated yet + } - // *) Mapping between enums "eqvectorKine" on one side, and enums "eAsFunctionOf" and "eDiffWeights" on the other: - eAsFunctionOf AFO_var = eAsFunctionOf_N; // this local variable determines the enum "eAsFunctionOf" which corresponds to enum "eqvectorKine" - eDiffWeights AFO_diffWeight = eDiffWeights_N; // this local variable determines the enum "eDiffWeights" which corresponds to enum "eqvectorKine" - if (variableX == PTq) { - AFO_var = AFO_PT; - AFO_diffWeight = wPHIPT; - } else if (variableX == ETAq) { - AFO_var = AFO_ETA; - AFO_diffWeight = wPHIETA; + // TBI 20241123 check if corresponding simulated ref. mult. is available through collision.has_mcCollision() + // ... } - // *) Insanity checks on above settings: - if (AFO_var == eAsFunctionOf_N) { - LOGF(fatal, "\033[1;31m%s at line %d : AFO_var == eAsFunctionOf_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); - } - if (AFO_diffWeight == eDiffWeights_N) { - LOGF(fatal, "\033[1;31m%s at line %d : AFO_diffWeight == eDiffWeights_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); + // b) Determine reference multiplicity for simulated Run 3 data: + if constexpr (rs == eSim) { + ebye.fReferenceMultiplicity = -44.; // TBI 20241123 check what to use here and add support eventualy } - // *) Determine first to which bin the 'valueX' corresponds to. - // Based on that, I decide from which histogram I fetch weight for y. See MakeWeights.C - Int_t binX = res.fResultsPro[AFO_var]->FindBin(valueX); - if (tc.fInsanityCheckForEachParticle) // enable only during debugging, as this check is computationally heavy. - { - if (binX < 1) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - // underflow. this means that I didn't use the same cuts now, and I was using when making the particle weights. Adjust the cuts. + // c) Same as a), just for converted Run 2 and Run 1 data: + if constexpr (rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { + if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multTracklets", TString::kIgnoreCase)) { + ebye.fReferenceMultiplicity = collision.multTracklets(); + } else { + LOGF(fatal, "\033[1;31m%s at line %d : reference multiplicity estimator = %d is not supported yet for Run 2. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eReferenceMultiplicityEstimator].Data()); } - if (binX > res.fResultsPro[AFO_var]->GetNbinsX()) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - // overflow. this means that I didn't use the same cuts now, and I was using when making the particle weights. Adjust the cuts. + // QA: + if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific + // ... } - } // if(tc.fInsanityCheckForEachParticle) - // *) Finally, determine weight for y(x): - if (!pw.fDiffWeightsHist[AFO_diffWeight][binX - 1]) { - LOGF(info, "\033[1;32mvalueY = %f\033[0m", valueY); - LOGF(info, "\033[1;32mvalueX = %f\033[0m", valueX); - LOGF(info, "\033[1;32mvariableX = %d\033[0m", static_cast(variableX)); - LOGF(info, "\033[1;32mAFO_diffWeight = %d\033[0m", static_cast(AFO_diffWeight)); - LOGF(info, "\033[1;32mbinX = %d\033[0m", binX); - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + // TBI 20241123 check if corresponding simulated ref. mult. is available through collision.has_mcCollision() + // ... } - Int_t bin = pw.fDiffWeightsHist[AFO_diffWeight][binX - 1]->FindBin(valueY); // binX - 1, because I histogram for first bin in X is labeled with "[0]", etc. - if (tc.fInsanityCheckForEachParticle) // enable only during debugging, as this check is computationally heavy. - { - if (bin < 1) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - // underflow. this means that I didn't use the same cuts now, and I was using when making the particle weights. Adjust the cuts. - } - if (bin > pw.fDiffWeightsHist[AFO_diffWeight][binX - 1]->GetNbinsX()) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - // overflow. this means that I didn't use the same cuts now, and I was using when making the particle weights. Adjust the cuts. - } - } // if(tc.fInsanityCheckForEachParticle) + // d) Same as b), just for converted Run 2 and Run 1 data: + if constexpr (rs == eSim_Run2 || rs == eSim_Run1) { + ebye.fReferenceMultiplicity = -44.; // TBI 20241123 check what to use here and add support eventualy + } - Double_t diffWeight = pw.fDiffWeightsHist[AFO_diffWeight][binX - 1]->GetBinContent(bin); - if (tc.fInsanityCheckForEachParticle) // enable only during debugging, as this check is computationally heavy. - { - if (diffWeight < 0.) { // or <= 0 ? TBI 20240324 rethink - LOGF(fatal, "\033[1;31m%s at line %d : diffWeight < 0\033[0m", __FUNCTION__, __LINE__); - } + // e) Test case: + if constexpr (rs == eTest) { + ebye.fReferenceMultiplicity = static_cast(gRandom->Uniform(0., 5000.)); // TBI 20241123 I could implement here a getter, if there is one available both for Run 3 and Run 2/1 } + // f) Print centrality for the audience...: if (tc.fVerbose) { + LOGF(info, "\033[1;32m ebye.fReferenceMultiplicity = %f\033[0m", ebye.fReferenceMultiplicity); ExitFunction(__FUNCTION__); } - return diffWeight; - -} // DiffWeight(const Double_t &valueY, const Double_t &valueX, eqvectorKine variableX) +} // template void DetermineReferenceMultiplicity(T const& collision) //============================================================ -void GetParticleWeights() +template +void DetermineCentrality(T const& collision) { - // Get the particle weights. Call this function only once. + // Determine collision centrality. + // For simulated data, I determine ebye.ImpactParameter here as well. - // TBI 20231012 Here the current working assumption is that: - // 1) Corrections do not change within a given run; - // 2) Hyperloop proceeses the dataset one masterjob per run number. - // If any of these 2 assumptions are violated, this code will have to be modified. + // TBI 20250429 there it a bit of code bloat here in this function - // a) Integrated weights; - // b) Differential weights. + // a) For real data, determine centrality from default centrality estimator; + // b) For simulated data, determine centrality directly from impact parameter + store impact parameter; + // c) Same as a), just for converted Run 2 data; + // d) Same as b), just for converted Run 2 data; + // e) Same as a), just for converted Run 1 data; + // f) Same as b), just for converted Run 1 data; + // g) Test case; + // h) Print centrality for the audience... if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // a) Integrated weights: - // integrated phi weights: - if (pw.fUseWeights[wPHI]) { - TH1D* phiWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "phi"); - if (!phiWeights) { - LOGF(fatal, "in function \033[1;31m%s at line %d, phiWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); + // a) For real data, determine centrality from default centrality estimator: + if constexpr (rs == eRec || rs == eRecAndSim || rs == eQA) { + // Local convention for name of centrality estimator: use the same name as the getter, case insensitive. + if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0C", TString::kIgnoreCase)) { + ebye.fCentrality = collision.centFT0C(); + } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0CVariant1", TString::kIgnoreCase)) { + ebye.fCentrality = collision.centFT0CVariant1(); + } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0M", TString::kIgnoreCase)) { + ebye.fCentrality = collision.centFT0M(); + } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centFV0A", TString::kIgnoreCase)) { + ebye.fCentrality = collision.centFV0A(); + } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centNTPV", TString::kIgnoreCase)) { + ebye.fCentrality = collision.centNTPV(); + } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centNGlobal", TString::kIgnoreCase)) { + // ebye.fCentrality = collision.centNGlobal(); // TBI 20250128 enable eventually + } else { + LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); } - SetWeightsHist(phiWeights, wPHI); + // QA: + if (qa.fFillQAEventHistograms2D || ec.fUseEventCuts[eCentralityCorrelationsCut]) { // TBI 20250331 I re-use here qa.fCentrality for CentralityCorrelationsCut, why not... + qa.fCentrality[eCentFT0C] = collision.centFT0C(); + qa.fCentrality[eCentFT0CVariant1] = collision.centFT0CVariant1(); + qa.fCentrality[eCentFT0M] = collision.centFT0M(); + qa.fCentrality[eCentFV0A] = collision.centFV0A(); + qa.fCentrality[eCentNTPV] = collision.centNTPV(); + // qa.fCentrality[eCentNGlobal] = collision.centNGlobal(); // TBI 20250128 enable eventually + } + + // ... + + // ... and corresponding MC truth simulated: + if constexpr (rs == eRecAndSim) { + + // *) Impact parameter: + ebye.fImpactParameter = collision.mcCollision().impactParameter(); // has to be called before DetermineSimulatedCentrality(); + + // *) Centrality for simulated data in Run 3: + ebye.fCentralitySim = DetermineSimulatedCentrality(); + + // ... + + } // if constexpr (rs == eRecAndSim) + + } // if constexpr (rs == eRec || rs == eRecAndSim || rs == eQA) + + // b) For simulated data, determine centrality directly from impact parameter + store impact parameter: + if constexpr (rs == eSim) { + ebye.fImpactParameter = collision.mcCollision().impactParameter(); // has to be called before DetermineSimulatedCentrality(); + ebye.fCentrality = DetermineSimulatedCentrality(); // yes, I use here ebye.fCentrality, not ebye.fCentralitySim } - // integrated pt weights: - if (pw.fUseWeights[wPT]) { - TH1D* ptWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "pt"); - if (!ptWeights) { - LOGF(fatal, "\033[1;31m%s at line %d : ptWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); + // c) Same as a), just for converted Run 2 data: + if constexpr (rs == eRec_Run2 || rs == eRecAndSim_Run2) { + if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2V0M", TString::kIgnoreCase)) { + ebye.fCentrality = collision.centRun2V0M(); + } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2SPDTracklets", TString::kIgnoreCase)) { + ebye.fCentrality = collision.centRun2SPDTracklets(); + } else { + LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); } - SetWeightsHist(ptWeights, wPT); + // QA: + if (qa.fFillQAEventHistograms2D || ec.fUseEventCuts[eCentralityCorrelationsCut]) { // TBI 20250331 I re-use here qa.fCentrality for CentralityCorrelationsCut, why not... + qa.fCentrality[eCentRun2V0M] = collision.centRun2V0M(); + qa.fCentrality[eCentRun2SPDTracklets] = collision.centRun2SPDTracklets(); + } + + // ... + + // ... and corresponding MC truth simulated: + + if constexpr (rs == eRecAndSim_Run2) { + + // *) Impact parameter: + ebye.fImpactParameter = collision.mcCollision().impactParameter(); // has to be called before DetermineSimulatedCentrality(); + + // *) Centrality for simulated data in Run 3: + ebye.fCentralitySim = DetermineSimulatedCentrality(); + + // ... + + } // if constexpr (rs == eRecAndSim_Run2) } - // integrated eta weights: - if (pw.fUseWeights[wETA]) { - TH1D* etaWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "eta"); - if (!etaWeights) { - LOGF(fatal, "\033[1;31m%s at line %d : etaWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); - } - SetWeightsHist(etaWeights, wETA); + // d) Same as b), just for converted Run 2 data: + if constexpr (rs == eSim_Run2) { + ebye.fImpactParameter = collision.mcCollision().impactParameter(); // has to be called before DetermineSimulatedCentrality(); + ebye.fCentrality = DetermineSimulatedCentrality(); // yes, I use here ebye.fCentrality, not ebye.fCentralitySim } - // b) Differential weights: - // differential phi(pt) weights: - if (pw.fUseDiffWeights[wPHIPT]) { - TH1D* phiptWeights = NULL; - Int_t nPtBins = res.fResultsPro[AFO_PT]->GetXaxis()->GetNbins(); - for (Int_t b = 0; b < nPtBins; b++) { + // e) Same as a), just for converted Run 1 data: + if constexpr (rs == eRec_Run1 || rs == eRecAndSim_Run1) { + if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2V0M", TString::kIgnoreCase)) { + // ebye.fCentrality = collision.centRun2V0M(); // TBI 20240224 enable when I add support for RecAndSim_Run1 + } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("CentRun2SPDTracklets", TString::kIgnoreCase)) { + // ebye.fCentrality = collision.centRun2SPDTracklets(); // TBI 20240224 enable when I add support for RecAndSim_Run1 + } else { + LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); + } - // *) check if particles in this pt bin survive particle cuts in pt. If not, skip this bin, because for that pt bin weights are simply not available: - if (!(res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 2) > pc.fdParticleCuts[ePt][eMin])) { - // this branch protects against the case when I am e.g. in pt bin [0.0,0.2], and pt cut is 0.2 < pt < 5.0 - LOGF(info, "\033[1;33m%s at line %d : you are requesting phi(pt) weight for pt bin = %d from (%f,%f), which is outside (below) pt phase space = (%f,%f). Skipping this bin. \033[0m", __FUNCTION__, __LINE__, b, res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 1), res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 2), pc.fdParticleCuts[ePt][eMin], pc.fdParticleCuts[ePt][eMax]); - continue; - } - if (!(res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 1) < pc.fdParticleCuts[ePt][eMax])) { - // this branch protects against the case when I am e.g. in pt bin [5.0,10.0], and pt cut is 0.2 < pt < 5.0 - LOGF(info, "\033[1;33m%s at line %d : you are requesting phi(pt) weight for pt bin = %d from (%f,%f), which is outside (above) pt phase space = (%f,%f). Skipping this bin. \033[0m", __FUNCTION__, __LINE__, b, res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 1), res.fResultsPro[AFO_PT]->GetBinLowEdge(b + 2), pc.fdParticleCuts[ePt][eMin], pc.fdParticleCuts[ePt][eMax]); - continue; - } + // ... and corresponding MC truth simulated: - // *) okay, this pt bin is within pt phase-space window, defined by pt cut: - phiptWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "phipt", b); - if (!phiptWeights) { - LOGF(fatal, "\033[1;31m%s at line %d : phiptWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); - } + if constexpr (rs == eRecAndSim_Run1) { - // *) okay, just use this histogram with weights: - SetDiffWeightsHist(phiptWeights, wPHIPT, b); - } - } // if (pw.fUseDiffWeights[wPHIPT]) { + // *) Impact parameter: + ebye.fImpactParameter = collision.mcCollision().impactParameter(); // has to be called before DetermineSimulatedCentrality(); - // differential phi(eta) weights: - if (pw.fUseDiffWeights[wPHIETA]) { - TH1D* phietaWeights = NULL; - Int_t nEtaBins = res.fResultsPro[AFO_ETA]->GetXaxis()->GetNbins(); - for (Int_t b = 0; b < nEtaBins; b++) { + // *) Centrality for simulated data in Run 3: + ebye.fCentralitySim = DetermineSimulatedCentrality(); - // *) check if particles in this eta bin survive particle cuts in eta. If not, skip this bin, because for that eta bin weights are simply not available: - if (!(res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 2) > pc.fdParticleCuts[eEta][eMin])) { - // this branch protects against the case when I am e.g. in eta bin [-1.0,-0.8], and eta cut is -0.8 < eta < 0.8 - LOGF(info, "\033[1;33m%s at line %d : you are requesting phi(eta) weight for eta bin = %d from (%f,%f), which is outside (below) eta phase space = (%f,%f). Skipping this bin. \033[0m", __FUNCTION__, __LINE__, b, res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 1), res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 2), pc.fdParticleCuts[eEta][eMin], pc.fdParticleCuts[eEta][eMax]); - continue; - } - if (!(res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 1) < pc.fdParticleCuts[eEta][eMax])) { - // this branch protects against the case when I am e.g. in eta bin [0.8,1.0], and eta cut is 0.8 < eta < 1.0 - LOGF(info, "\033[1;33m%s at line %d : you are requesting phi(eta) weight for eta bin = %d from (%f,%f), which is outside (above) eta phase space = (%f,%f). Skipping this bin. \033[0m", __FUNCTION__, __LINE__, b, res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 1), res.fResultsPro[AFO_ETA]->GetBinLowEdge(b + 2), pc.fdParticleCuts[eEta][eMin], pc.fdParticleCuts[eEta][eMax]); - continue; - } + // ... - // *) okay, this eta bin is within eta phase-space window, defined by eta cut: - phietaWeights = GetHistogramWithWeights(pw.fFileWithWeights.Data(), tc.fRunNumber.Data(), "phieta", b); - if (!phietaWeights) { - LOGF(fatal, "\033[1;31m%s at line %d : phietaWeights is NULL. Check the external file %s with particle weights\033[0m", __FUNCTION__, __LINE__, pw.fFileWithWeights.Data()); - } + } // if constexpr (rs == eRecAndSim_Run1) + } - // *) okay, just use this histogram with weights: - SetDiffWeightsHist(phietaWeights, wPHIETA, b); - } // for(Int_t b=0; b(gRandom->Uniform(0., 100.)); + } + // h) Print centrality for the audience...: if (tc.fVerbose) { + LOGF(info, "\033[1;32m ebye.fCentrality = %f\033[0m", ebye.fCentrality); + LOGF(info, "\033[1;32m ebye.fCentralitySim = %f\033[0m", ebye.fCentralitySim); ExitFunction(__FUNCTION__); } -} // void GetParticleWeights() +} // template void DetermineCentrality(T const& collision) //============================================================ -void GetCentralityWeights() +float DetermineSimulatedCentrality() { - // Get the centrality weights. Call this function only once. + // Determine centrality at generated/simulated level, just using impact parameter. + // This is a helper function for DetermineCentrality(), to reduce the code bloat there. I do not anticipate calling this function anywhere alse at the moment. - // TBI 20231012 Here the current working assumption is that: - // 1) Corrections do not change within a given run; - // 2) Hyperloop proceeses the dataset one masterjob per run number. - // If any of these 2 assumptions are violated, this code will have to be modified. - - // a) Centrality weights; - // b) ... + // Algorithm: + // 1. Ideally, I simply fetch this centrality from the table HepMCHeavyIons via getter .centrality(); + // 2. If that info is not available, I calculate the simulated centrality here temporarily manually from impact parameter + sigma_inel; + // 3. From process switches I can see whether I am processing Run 3, Run 2 or Run 1 data, for collision system I support at the moment only Pb+Pb. if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // a) Centrality weights: - if (cw.fUseCentralityWeights) { - TH1D* centralityWeights = GetHistogramWithCentralityWeights(cw.fFileWithCentralityWeights.Data(), tc.fRunNumber.Data()); - if (!centralityWeights) { - LOGF(fatal, "in function \033[1;31m%s at line %d : centralityWeights is NULL. Check the external file %s with centrality weights\033[0m", __FUNCTION__, __LINE__, cw.fFileWithCentralityWeights.Data()); + float lSimulatedCentrality = -1.; + float lSigmaInel = -1.; + + if (tc.fProcess[eProcessHepMChi]) { + // I have extracted already by this point simulated centrality from HepMCHeavyIons and stored it in ebye.fCentralitySim: + + // TBI 20250429 when I merge eProcessHepMChi with other RecSim process switches, I will have to refurbish the code here + + lSimulatedCentrality = ebye.fCentralitySim; + + } else if (tc.fProcess[eGenericRecSim] || tc.fProcess[eGenericSim]) { + + LOGF(warning, "\033[1;33m%s at line %d : Simulated centrality is calculated manually for the time being from impact parameter. Results make sense only for Pb+Pb at Run 3, Run 2 and Run 1 energies, other cases are not supported here (yet)\033[0m\n", __FUNCTION__, __LINE__); + + // Algorithm: Temporarily, I calculate centrality manually for simulated data directly from impact parameter as follows: + + // centrality(b) = Pi * b^2 / sigma_inel , where e.g. I take sigma_inel = 7.67 for Pb+Pb at 5.02 TeV, and analogously for other collision systems and energies + + if (tc.fProcess[eProcessRecSim] || tc.fProcess[eSim]) { + // Pb+Pb in Run 3: + lSigmaInel = 7.71; // interpolation, see Slide 3 in DDC presentation https://indico.cern.ch/event/1326916/ + } else if (tc.fProcess[eProcessRecSim_Run2] || tc.fProcess[eSim_Run2]) { + // Pb+Pb in Run 2: + lSigmaInel = 7.67; // for 5.02 TeV, see Slide 3 in DDC presentation https://indico.cern.ch/event/1326916/ + Run 2 paper https://arxiv.org/abs/2204.10148 + } else if (tc.fProcess[eProcessRecSim_Run1] || tc.fProcess[eSim_Run1]) { + // Pb+Pb in Run 1: + lSigmaInel = 7.55; // see Slide 3 in DDC presentation https://indico.cern.ch/event/1326916/ + Run 1 multiplicity paper https://arxiv.org/abs/1301.4361 + } else { + LOGF(fatal, "\033[1;31m%s at line %d : this branch is not supported/validated yet\033[0m", __FUNCTION__, __LINE__); } - SetCentralityWeightsHist(centralityWeights); + + // okay, I have SigmaInel for this collision system and energy, calculate centrality: + float b = ebye.fImpactParameter; + if (b < 0.) { + LOGF(warning, "\033[1;31m%s at line %d : b < 0. => did you forget to calculate ebye.fImpactParameter before calling DetermineSimulatedCentrality() ? Or you are processing Monte Carlo dataset where IP was not stored, i.e. it's set to -999 (e.g. in LHC21i6a) ? Setting lSimulatedCentrality = -1. and simply continuing... \033[0m", __FUNCTION__, __LINE__); + lSimulatedCentrality = -1.; + } else { + lSimulatedCentrality = o2::constants::math::PI * std::pow(b, 2.) / lSigmaInel; // finally, calculate true simulated centrality directly from impact parameter + } + } else { + LOGF(fatal, "\033[1;31m%s at line %d : this branch is not supported/validated yet\033[0m", __FUNCTION__, __LINE__); } if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void GetCentralityWeights() + return lSimulatedCentrality; + +} // float DetermineSimulatedCentrality() //============================================================ -Bool_t MaxNumberOfEvents(eBeforeAfter ba) +template +void DetermineOccupancy(T const& collision) { - // Check if max number of events was reached. Can be used for cut eNumberOfEvents (= total events, with ba = eBefore), and eSelectedEvents (ba = eAfter). + // Determine collision occupancy. + + // a) Determine occupancy from default occupancy estimator, only for eRec and eRecAndSim; + // b) For all other cases, set occupancy to -1 (not defined). + // c) Print occupancy for the audience... if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // *) Return value: - Bool_t reachedMaxNumberOfEvents = kFALSE; - - // *) Internal validation case (special treatment): - if (iv.fUseInternalValidation) { - if (eh.fEventHistograms[eNumberOfEvents][eSim][eAfter] && (eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1) == ec.fdEventCuts[eNumberOfEvents][eMax] || eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1) == ec.fdEventCuts[eSelectedEvents][eMax])) { - return kTRUE; + // a) Determine occupancy from default occupancy estimator, only for eRec and eRecAndSim: + if constexpr (rs == eRec || rs == eRecAndSim || rs == eQA) { + if (ec.fsEventCuts[eOccupancyEstimator].EqualTo("TrackOccupancyInTimeRange", TString::kIgnoreCase)) { + ebye.fOccupancy = collision.trackOccupancyInTimeRange(); + } else if (ec.fsEventCuts[eOccupancyEstimator].EqualTo("FT0COccupancyInTimeRange", TString::kIgnoreCase)) { + ebye.fOccupancy = collision.ft0cOccupancyInTimeRange(); } else { - return kFALSE; + LOGF(fatal, "\033[1;31m%s at line %d : occupancy estimator = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eOccupancyEstimator].Data()); + } + // QA: + if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific + qa.fOccupancy[eTrackOccupancyInTimeRange] = collision.trackOccupancyInTimeRange(); + qa.fOccupancy[eFT0COccupancyInTimeRange] = collision.ft0cOccupancyInTimeRange(); } - } - - // *) Determine from which histogram the relevant info will be taken: - Int_t rs = -44; // reconstructed or simulated - if (tc.fProcess[eGenericRec] || tc.fProcess[eGenericRecSim]) { // yes, for tc.fProcess[eGenericRecSim] I take info from Rec part - rs = eRec; - } else if (tc.fProcess[eGenericSim]) { - rs = eSim; } else { - LOGF(fatal, "\033[1;31m%s at line %d : not a single flag gProcess* is true \033[0m", __FUNCTION__, __LINE__); - } - - // *) Okay, do the thing: - switch (ba) { - case eBefore: - if (eh.fEventHistograms[eNumberOfEvents][rs][eBefore] && eh.fEventHistograms[eNumberOfEvents][rs][eBefore]->GetBinContent(1) == ec.fdEventCuts[eNumberOfEvents][eMax]) { - reachedMaxNumberOfEvents = kTRUE; - } - break; - case eAfter: - if (eh.fEventHistograms[eNumberOfEvents][rs][eAfter] && eh.fEventHistograms[eNumberOfEvents][rs][eAfter]->GetBinContent(1) == ec.fdEventCuts[eSelectedEvents][eMax]) { - reachedMaxNumberOfEvents = kTRUE; + // b) For all other cases, set occupancy to -1 (not defined): + ebye.fOccupancy = -1.; + // QA: + if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific + for (int oe = 0; oe < eOccupancyEstimators_N; oe++) { + qa.fOccupancy[oe] = -1.; } - break; - default: - LOGF(fatal, "\033[1;31m%s at line %d : enum ba = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(ba)); - break; + } } - // *) Hasta la vista: + // c) Print occupancy for the audience...: if (tc.fVerbose) { + LOGF(info, "\033[1;32m ebye.fOccupancy = %f\033[0m", ebye.fOccupancy); ExitFunction(__FUNCTION__); } - return reachedMaxNumberOfEvents; -} // void MaxNumberOfEvents(eBeforeAfter ba) +} // template void DetermineOccupancy(T const& collision) //============================================================ -void PrintEventCounter(eBeforeAfter ba) +template +void DetermineInteractionRateAndCurrentRunDuration(T1 const& collision, T2 const&) { - // Print how many events were processed by now. - // Remark: If I am processing RecSim, the counter is corresponding to Rec. + // Determine interaction rate and current run duration in Run 3. + + // Cannot be used in converted Run 2 and Run 1, because mRateFetcher.fetch... line below crashes with example line: + // [228607:multiparticle-correlations-a-b]: [10:02:38][ERROR] Requested resource does not exist: http://alice-ccdb.cern.ch//GLO/Config/GRPLHCIF/1449947476529/ + // [228607:multiparticle-correlations-a-b]: [10:02:38][FATAL] Got nullptr from CCDB for path GLO/Config/GRPLHCIF and timestamp 1449947476529 + + // a) Determine interaction rate and current run duration only for eRec; + // b) For all other cases, set interaction rate to -1 for the time being; + // c) Print interaction rate and current run duration for the audience... if (tc.fVerbose) { StartFunction(__FUNCTION__); } - // *) Print or die: - switch (ba) { - case eBefore: - if (!tc.fPlainPrintout) { - LOGF(info, "\033[1;32m%s : processing event %d ....\033[0m", __FUNCTION__, eh.fEventCounter[eTotal]); - } else { - LOGF(info, "%s : processing event %d ....", __FUNCTION__, eh.fEventCounter[eTotal]); - } - break; - case eAfter: - if (!tc.fPlainPrintout) { - LOGF(info, "\033[1;32m%s : event passed all cuts %d/%d\033[0m", __FUNCTION__, eh.fEventCounter[eProcessed], eh.fEventCounter[eTotal]); + if constexpr (rs == eRec || rs == eQA) { // TBI 20250112 check still eRecSim mode here + auto bc = collision.template foundBC_as(); // I have the same code snippet at other places, keep in sync. + + // a1) Determine interaction rate only for eRec: + if (ec.fUseEventCuts[eInteractionRate] || qa.fFillQAEventHistograms2D || qa.fFillQACorrelationsVsInteractionRateVsProfiles2D || (mupa.fCalculateCorrelations && mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTERACTIONRATE]) || (t0.fCalculateTest0 && t0.fCalculateTest0AsFunctionOf[AFO_INTERACTIONRATE]) || (es.fCalculateEtaSeparations && es.fCalculateEtaSeparationsAsFunctionOf[AFO_INTERACTIONRATE])) { + + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! There is a large memory blow-up of ~130 MB when calling mRateFetcher.fetch(...) !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); + + double hadronicRate = mRateFetcher.fetch(ccdb.service, static_cast(bc.timestamp()), static_cast(bc.runNumber()), "ZNC hadronic") * 1.e-3; // TBI 20250414 memory blow-up + if (hadronicRate > 0.) { + ebye.fInteractionRate = static_cast(hadronicRate); } else { - LOGF(info, "%s : event passed all cuts %d/%d", __FUNCTION__, eh.fEventCounter[eProcessed], eh.fEventCounter[eTotal]); + LOGF(warning, "\033[1;31m%s at line %d : hadronicRate = %f is meaningless \033[0m", __FUNCTION__, __LINE__, hadronicRate); + // I hit indeed at negative hadronic rate in LHC24ar/559545/apass1 dataset. But I do not really need to bail out here, because that collision in + // any case will not pass a cut in configurable cfInteractionRate . Therefore, I print a warning, and then can grep it from the log, if necessary. } - break; - default: - LOGF(fatal, "\033[1;31m%s at line %d : enum ba = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(ba)); - break; + } // if(...) + + // a2) Determine the current run duration: + // TBI 20250107 I could move this to a separate function? + // TBI 20250415 I do not see any memory penalty here, so I keep it + ebye.fCurrentRunDuration = std::floor(bc.timestamp() * 0.001) - tc.fRunTime[eStartOfRun]; + if (ebye.fCurrentRunDuration > tc.fRunTime[eDurationInSec]) { + LOGF(fatal, "\033[1;31m%s at line %d : ebye.fCurrentRunDuration = %d is bigger than tc.fRunTime[eDurationInSec] = %d, which is meaningless \033[0m", __FUNCTION__, __LINE__, static_cast(ebye.fCurrentRunDuration), static_cast(tc.fRunTime[eDurationInSec])); + } + + } else { + // b) For all other cases, set interaction rate to -1: + ebye.fInteractionRate = -1.; + ebye.fCurrentRunDuration = -1.; + ebye.fFT0CAmplitudeOnFoundBC = -1.; } + // c) Print interaction rate and run duration for the audience...: if (tc.fVerbose) { + LOGF(info, "\033[1;32m ebye.fInteractionRate = %f kHz\033[0m", ebye.fInteractionRate); + if (qa.fBookQAEventHistograms2D[eCurrentRunDuration_vs_InteractionRate]) { // TBI 20241127 do I check this flag, or pointer, like in FillEventHistograms(...) ? + LOGF(info, "\033[1;32m ebye.fCurrentRunDuration = %f s (in seconds after SOR)\033[0m", ebye.fCurrentRunDuration); + } ExitFunction(__FUNCTION__); } -} // void PrintEventCounter(eBeforeAfter ba) +} // template void DetermineInteractionRateAndCurrentRunDuration(T1 const& collision, T2 const&) //============================================================ -void EventCounterForDryRun(eEventCounterForDryRun eVar) +template +void DetermineVertexZ(T const& collision) { - // Simple utility function which either fills histogram with event count, or prints its current content. - // Remark: Use only in combination with tc.fDryRun = kTRUE, otherwise I might be filling the same histogram in different member functions, there is a protection below. - // It fills or prints per call, therefore I do not have to pass 'collision' objects, etc. + // Determine vetex z position. + + // TBI 20250108 I could use ebye.fVz determined here to fill event histograms, but it's not a big deal to fetch it there also via collision.posZ() if (tc.fVerbose) { StartFunction(__FUNCTION__); } - if (!tc.fDryRun) { - LOGF(fatal, "\033[1;31m%s at line %d : for the time being, function EventCounterForDryRun(...) can be safely used only for tc.fDryRun = kTRUE \033[0m", __FUNCTION__, __LINE__); - } - - switch (eVar) { - case eFill: - // Fill event counter: - !eh.fEventHistograms[eNumberOfEvents][eRec][eAfter] ? true : eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->Fill(0.5); - !eh.fEventHistograms[eNumberOfEvents][eSim][eAfter] ? true : eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->Fill(0.5); - break; - case ePrint: - // Print current status of event counter: - // Remark: if I am processing RecSim, the counter is corresponding to Rec. - if (eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]) { - LOGF(info, "Processing event %d (dry run) ....", static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->GetBinContent(1))); - } else if (eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]) { - LOGF(info, "Processing event %d (dry run) ....", static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1))); - } - break; - default: - LOGF(fatal, "\033[1;31m%s at line %d : enum eVar = %d is not supported yet in eEventCounter. \033[0m", __FUNCTION__, __LINE__, static_cast(eVar)); - break; - } // switch(eVar) + ebye.fVz = collision.posZ(); if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void EventCounterForDryRun(eEventCounterForDryRun eVar) +} // void DetermineVertexZ(T const& collision) //============================================================ -const char* FancyFormatting(const char* name) +template +void DetermineQAThingies(T1 const& collision, T2 const&) { - // Simple utility function to convert ordinary name into fancier formatting. + // Remark: I implement ideally here only the getters for which the subscription to additional non-standard tables was needed for QA purposes. + // Support only for Run 3 data is provided, because in the "processQA" switch the starting point are tables used in "processRec", and I join to them + // some non-standard tables only for QA purposes. - // Examples: - // 1. use LaTeX syntax (as supported by ROOT!), for the case when it's possible (e.g. "Phi" => "#{varphi}"); - // 2. add additional information to defalt name (e.g. "Centrality" => "Centrality (V0M)" - // 3. ... + // a) Determine FT0CAmplitudeOnFoundBC; + // ... + // *) Print something for the audience... . - if (tc.fVerboseUtility) { + if (tc.fVerbose) { StartFunction(__FUNCTION__); - LOGF(info, "\033[1;32m const char* name = %s\033[0m", name); } - // By default, do nothing and return the same thing: - const char* fancyFormatting = name; + if constexpr (rs == eQA) { + auto bc = collision.template foundBC_as(); // I have the same code snippet at other places, keep in sync. - // Special cases supported by now: - if (TString(name).EqualTo("Phi", TString::kIgnoreCase)) { - fancyFormatting = "#varphi"; - } else if (TString(name).EqualTo("Pt", TString::kIgnoreCase)) { - fancyFormatting = "p_{T}"; - } else if (TString(name).EqualTo("Eta", TString::kIgnoreCase)) { - fancyFormatting = "#eta"; - } else if (TString(name).EqualTo("Vertex_x")) { - fancyFormatting = "V_{x}"; - } else if (TString(name).EqualTo("Vertex_y")) { - fancyFormatting = "V_{y}"; - } else if (TString(name).EqualTo("Vertex_z")) { - fancyFormatting = "V_{z}"; - } else if (TString(name).EqualTo("TotalMultiplicity")) { - fancyFormatting = "TotalMultiplicity (tracks.size())"; - } else if (TString(name).EqualTo("Multiplicity", TString::kIgnoreCase)) { - fancyFormatting = Form("Multiplicity (%s)", ec.fsEventCuts[eMultiplicityEstimator].Data()); - } else if (TString(name).EqualTo("ReferenceMultiplicity")) { - fancyFormatting = Form("ReferenceMultiplicity (%s)", ec.fsEventCuts[eReferenceMultiplicityEstimator].Data()); - } else if (TString(name).EqualTo("Centrality", TString::kIgnoreCase)) { - TString tmp = ec.fsEventCuts[eCentralityEstimator]; // I have to introduce local TString tmp, because ReplaceAll replaces in-place - if (tmp.BeginsWith("CentRun2")) { - fancyFormatting = Form("Centrality (%s)", tmp.ReplaceAll("CentRun2", "").Data()); // "CentRun2V0M" => "Centrality (V0M)" - } else if (tmp.BeginsWith("Cent")) { - fancyFormatting = Form("Centrality (%s)", tmp.ReplaceAll("Cent", "").Data()); // "CentFT0C" => "Centrality (FT0C)" - } else { - LOGF(fatal, "\033[1;31m%s at line %d : the case tmp = %s is not supported yet\033[0m", __FUNCTION__, __LINE__, tmp.Data()); + // a) Determine FT0CAmplitudeOnFoundBC; + if (bc.has_foundFT0()) { + ebye.fFT0CAmplitudeOnFoundBC = bc.foundFT0().sumAmpC(); // see more details in rofOccupancyQa.cxx } - } else if (TString(name).EqualTo("Trigger")) { - fancyFormatting = Form("Trigger (%s)", ec.fsEventCuts[eTrigger].Data()); - } else if (TString(name).EqualTo("TrackOccupancyInTimeRange")) { - fancyFormatting = "trackOccupancyInTimeRange()"; - } else if (TString(name).EqualTo("FT0COccupancyInTimeRange")) { - fancyFormatting = "ft0cOccupancyInTimeRange()"; - } else if (TString(name).EqualTo("Occupancy", TString::kIgnoreCase)) { - fancyFormatting = Form("Occupancy (%s)", ec.fsEventCuts[eOccupancyEstimator].Data()); - } else if (TString(name).EqualTo("InteractionRate", TString::kIgnoreCase) || TString(name).EqualTo("Interaction Rate", TString::kIgnoreCase)) { - fancyFormatting = "Interaction Rate [kHz]"; // TBI 20241127 do I leave kHz hardwired here? - } else if (TString(name).EqualTo("CurrentRunDuration", TString::kIgnoreCase) || TString(name).EqualTo("Current Run Duration", TString::kIgnoreCase)) { - fancyFormatting = "Current run duration [s] (i.e. time in seconds since start of run)"; - } - if (tc.fVerboseUtility) { - ExitFunction(__FUNCTION__); + // ... + + // *) Print something for the audience...: + if (tc.fVerbose) { + LOGF(info, "\033[1;32m ebye.fFT0CAmplitudeOnFoundBC = %f\033[0m", ebye.fFT0CAmplitudeOnFoundBC); + } // if (tc.fVerbose) { + + } else { + // For all other cases, set all QA-specific variables calculated here to -1. TBI 20250401 shall I really do it this way, in a sense that for all other cases, this function should never be called? + ebye.fFT0CAmplitudeOnFoundBC = -1.; } - return fancyFormatting; + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } // if (tc.fVerbose) { -} // const char* FancyFormatting(const char *name) +} // template void DetermineQAThingies(T1 const& collision, T2 const&) //============================================================ -Double_t CalculateCustomNestedLoops(TArrayI* harmonics) +void ProcessHepMCHeavyIons(aod::HepMCHeavyIon const& hep) { - // For the specified harmonics, get the correlation from nested loops. - // Order of correlator is the number of harmonics, i.e. the number of elements in an array. + // Process extra MC info from HepMCHeavyIons only in this function. + // See documentation at https://aliceo2group.github.io/analysis-framework/docs/datamodel/ao2dTables.html#montecarlo - // a) Determine the order of correlator; - // b) Custom nested loop; - // c) Return value. + LOGF(info, "\033[1;32m hep.mcCollisionId() = %d\033[0m", hep.mcCollisionId()); + LOGF(info, "\033[1;32m hep.centrality() = %f\033[0m", hep.centrality()); // TBI 20250428 set to -1 in LHC24g3 + LOGF(info, "\033[1;32m hep.eccentricity() = %f\033[0m", hep.eccentricity()); // TBI 20250428 set to 0 in LHC24g3 + LOGF(info, "\033[1;32m hep.sigmaInelNN() = %f\033[0m", hep.sigmaInelNN()); // TBI 20250428 set to 0 in LHC24g3 + LOGF(info, "\033[1;32m hep.eventPlaneAngle() = %f\033[0m", hep.eventPlaneAngle()); // TBI 20250428 set to 0 in LHC24g3, but stored correctly in McCollisions + LOGF(info, "\033[1;32m hep.impactParameter() = %f\033[0m\n", hep.impactParameter()); // stored correctly both in HepMCHeavyIons and McCollisions - if (tc.fVerbose) { - StartFunction(__FUNCTION__); + // *) Centrality at generated level: + ebye.fCentralitySim = hep.centrality(); + if (ebye.fCentralitySim < 0. || ebye.fCentralitySim > 100.) { + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! ebye.fCentralitySim = %f, this info is still not stored in the table HepMCHeavyIons !!!! WARNING !!!! \033[0m\n", __FUNCTION__, __LINE__, ebye.fCentralitySim); } - if (!harmonics) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } + // ... TBI 20240429 as soon as HepMCHeavyIons data is stored filled in Monte Carlo datasets, ctd. here - Int_t nParticles = ebye.fSelectedTracks; - /* TBI 20231108 enable eventually - if(fUseFixedNumberOfRandomlySelectedParticles) - { - nParticles = 0; - for(Int_t i=0;iGetSize();i++) - { - if(TMath::Abs(nl.ftaNestedLoops[0]->GetAt(i)) > 0. && TMath::Abs(nl.ftaNestedLoops[1]->GetAt(i)) > 0.){nParticles++;} - } - } - */ +} // void ProcessHepMCHeavyIons(aod::HepMCHeavyIon const& hep) - // a) Determine the order of correlator; - Int_t order = harmonics->GetSize(); - if (0 == order || order > gMaxCorrelator) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - if (nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order) { - LOGF(info, " nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order, where nl.fMaxNestedLoop = %d, order = %d", nl.fMaxNestedLoop, order); - return 0.; // TBI 20240405 Is this really safe here? Re-think... - } +//============================================================ - // b) Custom nested loop: - TProfile* profile = new TProfile("profile", "", 1, 0., 1.); // helper profile to get all averages automatically - // profile->Sumw2(); - Double_t value = 0.; // cos of current multiplet - Double_t weight = 1.; // weight of current multiplet - for (int i1 = 0; i1 < nParticles; i1++) { - Double_t dPhi1 = nl.ftaNestedLoops[0]->GetAt(i1); - Double_t dW1 = nl.ftaNestedLoops[1]->GetAt(i1); - if (1 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1); - weight = dW1; - profile->Fill(0.5, value, weight); - continue; - } - for (int i2 = 0; i2 < nParticles; i2++) { - if (i2 == i1) { - continue; - } - Double_t dPhi2 = nl.ftaNestedLoops[0]->GetAt(i2); - Double_t dW2 = nl.ftaNestedLoops[1]->GetAt(i2); - if (2 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2); - weight = dW1 * dW2; - profile->Fill(0.5, value, weight); - continue; - } - for (int i3 = 0; i3 < nParticles; i3++) { - if (i3 == i1 || i3 == i2) { - continue; - } - Double_t dPhi3 = nl.ftaNestedLoops[0]->GetAt(i3); - Double_t dW3 = nl.ftaNestedLoops[1]->GetAt(i3); - if (3 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3); - weight = dW1 * dW2 * dW3; - profile->Fill(0.5, value, weight); - continue; - } - for (int i4 = 0; i4 < nParticles; i4++) { - if (i4 == i1 || i4 == i2 || i4 == i3) { - continue; - } - Double_t dPhi4 = nl.ftaNestedLoops[0]->GetAt(i4); - Double_t dW4 = nl.ftaNestedLoops[1]->GetAt(i4); - if (4 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4); - weight = dW1 * dW2 * dW3 * dW4; - profile->Fill(0.5, value, weight); - continue; - } - for (int i5 = 0; i5 < nParticles; i5++) { - if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) { - continue; - } - Double_t dPhi5 = nl.ftaNestedLoops[0]->GetAt(i5); - Double_t dW5 = nl.ftaNestedLoops[1]->GetAt(i5); - if (5 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5); - weight = dW1 * dW2 * dW3 * dW4 * dW5; - profile->Fill(0.5, value, weight); - continue; - } - for (int i6 = 0; i6 < nParticles; i6++) { - if (i6 == i1 || i6 == i2 || i6 == i3 || i6 == i4 || i6 == i5) { - continue; - } - Double_t dPhi6 = nl.ftaNestedLoops[0]->GetAt(i6); - Double_t dW6 = nl.ftaNestedLoops[1]->GetAt(i6); - if (6 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6; - profile->Fill(0.5, value, weight); - continue; - } - for (int i7 = 0; i7 < nParticles; i7++) { - if (i7 == i1 || i7 == i2 || i7 == i3 || i7 == i4 || i7 == i5 || i7 == i6) { - continue; - } - Double_t dPhi7 = nl.ftaNestedLoops[0]->GetAt(i7); - Double_t dW7 = nl.ftaNestedLoops[1]->GetAt(i7); - if (7 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7; - profile->Fill(0.5, value, weight); - continue; - } - for (int i8 = 0; i8 < nParticles; i8++) { - if (i8 == i1 || i8 == i2 || i8 == i3 || i8 == i4 || i8 == i5 || i8 == i6 || i8 == i7) { - continue; - } - Double_t dPhi8 = nl.ftaNestedLoops[0]->GetAt(i8); - Double_t dW8 = nl.ftaNestedLoops[1]->GetAt(i8); - if (8 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8; - profile->Fill(0.5, value, weight); - continue; - } - for (int i9 = 0; i9 < nParticles; i9++) { - if (i9 == i1 || i9 == i2 || i9 == i3 || i9 == i4 || i9 == i5 || i9 == i6 || i9 == i7 || i9 == i8) { - continue; - } - Double_t dPhi9 = nl.ftaNestedLoops[0]->GetAt(i9); - Double_t dW9 = nl.ftaNestedLoops[1]->GetAt(i9); - if (9 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9; - profile->Fill(0.5, value, weight); - continue; - } - for (int i10 = 0; i10 < nParticles; i10++) { - if (i10 == i1 || i10 == i2 || i10 == i3 || i10 == i4 || i10 == i5 || i10 == i6 || i10 == i7 || i10 == i8 || i10 == i9) { - continue; - } - Double_t dPhi10 = nl.ftaNestedLoops[0]->GetAt(i10); - Double_t dW10 = nl.ftaNestedLoops[1]->GetAt(i10); - if (10 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10; - profile->Fill(0.5, value, weight); - continue; - } - for (int i11 = 0; i11 < nParticles; i11++) { - if (i11 == i1 || i11 == i2 || i11 == i3 || i11 == i4 || i11 == i5 || i11 == i6 || i11 == i7 || i11 == i8 || i11 == i9 || i11 == i10) { - continue; - } - Double_t dPhi11 = nl.ftaNestedLoops[0]->GetAt(i11); - Double_t dW11 = nl.ftaNestedLoops[1]->GetAt(i11); - if (11 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11; - profile->Fill(0.5, value, weight); - continue; - } - for (int i12 = 0; i12 < nParticles; i12++) { - if (i12 == i1 || i12 == i2 || i12 == i3 || i12 == i4 || i12 == i5 || i12 == i6 || i12 == i7 || i12 == i8 || i12 == i9 || i12 == i10 || i12 == i11) { - continue; - } - Double_t dPhi12 = nl.ftaNestedLoops[0]->GetAt(i12); - Double_t dW12 = nl.ftaNestedLoops[1]->GetAt(i12); - if (12 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11 + harmonics->GetAt(11) * dPhi12); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11 * dW12; - profile->Fill(0.5, value, weight); - continue; - } +void DetermineEventCounters() +{ + // Determine all event counters. - // ... it's easy to continue the above pattern here + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } - } // for(int i12=0; i12(eh.fEventHistograms[eNumberOfEvents][eRec][eBefore]->GetBinContent(1)); + eh.fEventCounter[eProcessed] = static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->GetBinContent(1)); + } else if (eh.fEventHistograms[eNumberOfEvents][eSim][eBefore] && eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]) { + // Remark: This branch covers automatically also internal validation, because I book and fill there only eSim. + eh.fEventCounter[eTotal] = static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]->GetBinContent(1)); + eh.fEventCounter[eProcessed] = static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1)); + } - // c) Return value: - Double_t finalValue = profile->GetBinContent(1); - delete profile; - profile = NULL; if (tc.fVerbose) { ExitFunction(__FUNCTION__); } - return finalValue; -} // Double_t CalculateCustomNestedLoops(TArrayI *harmonics) +} // void DetermineEventCounters() //============================================================ -Double_t CalculateKineCustomNestedLoops(TArrayI* harmonics, eAsFunctionOf AFO_variable, Int_t bin) +void RandomIndices(int nTracks) { - // For the specified harmonics, kine variable, and bin, get the correlation from nested loops. - // Order of correlator is the number of harmonics, i.e. the number of elements in an array. - - // a) Determine the order of correlator; - // b) Custom nested loop; - // c) Return value. + // Randomize indices using Fisher-Yates algorithm. if (tc.fVerbose) { StartFunction(__FUNCTION__); } - if (!harmonics) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + if (nTracks < 1) { + return; } - // *) ... - eqvectorKine qvKine = eqvectorKine_N; // which component of q-vector - TString kineVarName = ""; - switch (AFO_variable) { - case AFO_PT: - qvKine = PTq; - kineVarName = "pt"; - break; - case AFO_ETA: - qvKine = ETAq; - kineVarName = "eta"; - break; - default: - LOGF(fatal, "\033[1;31m%s at line %d : This AFO_variable = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable)); - break; - } // switch(AFO_variable) + // Fisher-Yates algorithm: + tc.fRandomIndices = new TArrayI(nTracks); + tc.fRandomIndices->Reset(); // just in case there is some random garbage in memory at init + for (int i = 0; i < nTracks; i++) { + tc.fRandomIndices->AddAt(i, i); + } + for (int i = nTracks - 1; i >= 1; i--) { + int j = gRandom->Integer(i + 1); + int temp = tc.fRandomIndices->GetAt(j); + tc.fRandomIndices->AddAt(tc.fRandomIndices->GetAt(i), j); + tc.fRandomIndices->AddAt(temp, i); + } // end of for(int i=nTracks-1;i>=1;i--) - // *) Insanity checks on above settings: - if (qvKine == eqvectorKine_N) { - LOGF(fatal, "\033[1;31m%s at line %d : qvKine == eqvectorKine_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); } - if (0 > bin || res.fResultsPro[AFO_variable]->GetNbinsX() < bin) { // this 'bin' starts from 0, i.e. this is an array bin - // either underflow or overflow is hit, meaning that histogram is booked in narrower range than cuts - LOGF(fatal, "\033[1;31m%s at line %d => AFO_variable = %d, bin = %d\033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable), bin); +} // void RandomIndices(int nTracks) + +//============================================================ + +template +void BanishmentLoopOverParticles(T const& tracks) +{ + // This is the quick banishment loop over particles, as a support for eSelectedTracks cut (used through eMultiplicity, see comments for ebye.fMultiplicity). + // This is particularly relevant to get all efficiency corrections right. + // The underlying problem is that particle histograms got filled before eSelectedTracks could be applied in Steer. + // Therefore, particle histograms got filled even for events which were rejected by eSelectedTracks cut. + // In this loop, for those few specific events (typically low-multiplicity outliers), particle histograms are re-filled again with weight -1, + // which in effect cancels the previos fill in the MainLoopOverParticles. + + // Remark: I have to use here all additional checks, like ValidTrack, as in the MainLoopOverParticles. + // Therefore, it's important to have local variable lSelectedTracks, so that I can cross-compare + // at the end with central data member ebye.fSelectedTracks + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); } - // Get the number of particles in this kine bin: - Int_t nParticles = 0; - for (Int_t i = 0; i < nl.ftaNestedLoopsKine[qvKine][bin][0]->GetSize(); i++) { - if (TMath::Abs(nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i)) > 0.) { - nParticles++; + // *) If random access of tracks from collection is requested, use Fisher-Yates algorithm to generate random indices: + // Remark: It is very important that I use exactly the same random sequence from FY already generated in the MainLoop + if (tc.fUseFisherYates) { + if (!tc.fRandomIndices) { + LOGF(fatal, "\033[1;31m%s at line %d : I have to use here exactly the same random sequence from FY already generated in the MainLoopOverParticles, but it's not available \033[0m", __FUNCTION__, __LINE__); } } - // 'qvKine' is enum eqvectorKine: - if (!res.fResultsPro[AFO_variable]) { - LOGF(fatal, "\033[1;31m%s at line %d : AFO_variable = %d, bin = %d \033[0m", __FUNCTION__, __LINE__, static_cast(AFO_variable), bin); - } + // *) Counter of selected tracks in the current event: + int lSelectedTracks = 0; // I could reset and reuse here ebye.fSelectedTracks, but it's safer to use separate local variable, as I can do additional insanity checks here - LOGF(info, " Processing qvKine = %d (vs. %s), nParticles in this kine bin = %d, bin range = [%f,%f) ....", static_cast(qvKine), kineVarName.Data(), nParticles, res.fResultsPro[AFO_variable]->GetBinLowEdge(bin + 1), res.fResultsPro[AFO_variable]->GetBinLowEdge(bin + 2)); + // *) Banishment loop over particles: + // for (auto& track : tracks) { // default standard way of looping of tracks + auto track = tracks.iteratorAt(0); // set the type and scope from one instance + for (int64_t i = 0; i < tracks.size(); i++) { - // a) Determine the order of correlator; - Int_t order = harmonics->GetSize(); - if (0 == order || order > gMaxCorrelator) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - if (order > nParticles) { - LOGF(info, " There is no enough particles in this bin to calculate the requested correlator"); - return 0.; // TBI 20240405 Is this really safe here? Re-think... - } - if (nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order) { - LOGF(info, " nl.fMaxNestedLoop > 0 && nl.fMaxNestedLoop < order, where nl.fMaxNestedLoop = %d, order = %d", nl.fMaxNestedLoop, order); - return 0.; // TBI 20240405 Is this really safe here? Re-think... - } + // *) Access track sequentially from collection of tracks (default), or randomly using Fisher-Yates algorithm: + if (!tc.fUseFisherYates) { + track = tracks.iteratorAt(i); + } else { + track = tracks.iteratorAt(static_cast(tc.fRandomIndices->GetAt(i))); + } - // b) Custom nested loop: - TProfile* profile = new TProfile("profile", "", 1, 0., 1.); // helper profile to get all averages automatically - // profile->Sumw2(); - Double_t value = 0.; // cos of current multiplet - Double_t weight = 1.; // weight of current multiplet - for (int i1 = 0; i1 < nParticles; i1++) { - Double_t dPhi1 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i1); - Double_t dW1 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i1); - if (1 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1); - weight = dW1; - profile->Fill(0.5, value, weight); + // *) Skip track objects which are not valid tracks (e.g. Run 2 and 1 tracklets, etc.): + if (!ValidTrack(track)) { continue; } - for (int i2 = 0; i2 < nParticles; i2++) { - if (i2 == i1) { - continue; - } - Double_t dPhi2 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i2); - Double_t dW2 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i2); - if (2 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2); - weight = dW1 * dW2; - profile->Fill(0.5, value, weight); - continue; - } - for (int i3 = 0; i3 < nParticles; i3++) { - if (i3 == i1 || i3 == i2) { - continue; - } - Double_t dPhi3 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i3); - Double_t dW3 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i3); - if (3 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3); - weight = dW1 * dW2 * dW3; - profile->Fill(0.5, value, weight); - continue; - } - for (int i4 = 0; i4 < nParticles; i4++) { - if (i4 == i1 || i4 == i2 || i4 == i3) { - continue; - } - Double_t dPhi4 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i4); - Double_t dW4 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i4); - if (4 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4); - weight = dW1 * dW2 * dW3 * dW4; - profile->Fill(0.5, value, weight); - continue; - } - for (int i5 = 0; i5 < nParticles; i5++) { - if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) { - continue; - } - Double_t dPhi5 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i5); - Double_t dW5 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i5); - if (5 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5); - weight = dW1 * dW2 * dW3 * dW4 * dW5; - profile->Fill(0.5, value, weight); - continue; - } - for (int i6 = 0; i6 < nParticles; i6++) { - if (i6 == i1 || i6 == i2 || i6 == i3 || i6 == i4 || i6 == i5) { - continue; - } - Double_t dPhi6 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i6); - Double_t dW6 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i6); - if (6 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6; - profile->Fill(0.5, value, weight); - continue; - } - for (int i7 = 0; i7 < nParticles; i7++) { - if (i7 == i1 || i7 == i2 || i7 == i3 || i7 == i4 || i7 == i5 || i7 == i6) { - continue; - } - Double_t dPhi7 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i7); - Double_t dW7 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i7); - if (7 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7; - profile->Fill(0.5, value, weight); - continue; - } - for (int i8 = 0; i8 < nParticles; i8++) { - if (i8 == i1 || i8 == i2 || i8 == i3 || i8 == i4 || i8 == i5 || i8 == i6 || i8 == i7) { - continue; - } - Double_t dPhi8 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i8); - Double_t dW8 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i8); - if (8 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8; - profile->Fill(0.5, value, weight); - continue; - } - for (int i9 = 0; i9 < nParticles; i9++) { - if (i9 == i1 || i9 == i2 || i9 == i3 || i9 == i4 || i9 == i5 || i9 == i6 || i9 == i7 || i9 == i8) { - continue; - } - Double_t dPhi9 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i9); - Double_t dW9 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i9); - if (9 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9; - profile->Fill(0.5, value, weight); - continue; - } - for (int i10 = 0; i10 < nParticles; i10++) { - if (i10 == i1 || i10 == i2 || i10 == i3 || i10 == i4 || i10 == i5 || i10 == i6 || i10 == i7 || i10 == i8 || i10 == i9) { - continue; - } - Double_t dPhi10 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i10); - Double_t dW10 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i10); - if (10 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10; - profile->Fill(0.5, value, weight); - continue; - } - for (int i11 = 0; i11 < nParticles; i11++) { - if (i11 == i1 || i11 == i2 || i11 == i3 || i11 == i4 || i11 == i5 || i11 == i6 || i11 == i7 || i11 == i8 || i11 == i9 || i11 == i10) { - continue; - } - Double_t dPhi11 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i11); - Double_t dW11 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i11); - if (11 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11; - profile->Fill(0.5, value, weight); - continue; - } - for (int i12 = 0; i12 < nParticles; i12++) { - if (i12 == i1 || i12 == i2 || i12 == i3 || i12 == i4 || i12 == i5 || i12 == i6 || i12 == i7 || i12 == i8 || i12 == i9 || i12 == i10 || i12 == i11) { - continue; - } - Double_t dPhi12 = nl.ftaNestedLoopsKine[qvKine][bin][0]->GetAt(i12); - Double_t dW12 = nl.ftaNestedLoopsKine[qvKine][bin][1]->GetAt(i12); - if (12 == order) { - value = TMath::Cos(harmonics->GetAt(0) * dPhi1 + harmonics->GetAt(1) * dPhi2 + harmonics->GetAt(2) * dPhi3 + harmonics->GetAt(3) * dPhi4 + harmonics->GetAt(4) * dPhi5 + harmonics->GetAt(5) * dPhi6 + harmonics->GetAt(6) * dPhi7 + harmonics->GetAt(7) * dPhi8 + harmonics->GetAt(8) * dPhi9 + harmonics->GetAt(9) * dPhi10 + harmonics->GetAt(10) * dPhi11 + harmonics->GetAt(11) * dPhi12); - weight = dW1 * dW2 * dW3 * dW4 * dW5 * dW6 * dW7 * dW8 * dW9 * dW10 * dW11 * dW12; - profile->Fill(0.5, value, weight); - continue; - } - // ... it's easy to continue the above pattern here + // *) Banish particle histograms before particle cuts: + // TBI 20240515 I banish for the time being only particle histograms AFTER particle cuts. + // If I start to banish here also particle histograms BEFORE particle cuts, then see if I have to do it also for event histograms BEFORE cuts. + // Event histograms AFTER cuts are not affected. + // if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D) { + // FillParticleHistograms(track, eBefore, -1); + // } + + // *) Particle cuts: + if (!ParticleCuts(track, eCut)) { // Main call for particle cuts. + continue; // not return!! + } + + // *) Banish particle histograms after particle cuts: + if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D || qa.fFillQAParticleHistograms2D) { + FillParticleHistograms(track, eAfter, -1); // with negative weight -1, I effectively remove the previous fill for this track + } + + // *) Increase the local selected particle counter: + lSelectedTracks++; + if (lSelectedTracks >= ec.fdEventCuts[eMultiplicity][eMax]) { + break; + } + + // *) Break the loop if fixed number of particles is taken randomly from each event (use always in combination with tc.fUseFisherYates = true): + if (tc.fFixedNumberOfRandomlySelectedTracks > 0 && tc.fFixedNumberOfRandomlySelectedTracks == lSelectedTracks) { + LOGF(info, "%s : Breaking the loop over particles, since requested fixed number of %d particles was reached", __FUNCTION__, tc.fFixedNumberOfRandomlySelectedTracks); + break; + } + + } // for (auto& track : tracks) - } // for(int i12=0; i12GetBinContent(1); - delete profile; - profile = NULL; if (tc.fVerbose) { ExitFunction(__FUNCTION__); } - return finalValue; -} // Double_t CalculateKineCustomNestedLoops(TArrayI *harmonics, eAsFunctionOf AFO_variable, Int_t bin) +} // template void BanishmentLoopOverParticles(T const& tracks) { //============================================================ -void DetermineMultiplicity() +void PrintCutCounterContent() { - // Determine multiplicity for "vs. mult" results. + // Prints on the screen content of fEventCutCounterHist[][] (all which were booked). + + // a) Insanity checks; + // b) Print or die. if (tc.fVerbose) { StartFunction(__FUNCTION__); } - if (ec.fsEventCuts[eMultiplicityEstimator].EqualTo("SelectedTracks", TString::kIgnoreCase)) { - ebye.fMultiplicity = static_cast(ebye.fSelectedTracks); - } else if (ec.fsEventCuts[eMultiplicityEstimator].EqualTo("ReferenceMultiplicity", TString::kIgnoreCase)) { - ebye.fMultiplicity = ebye.fReferenceMultiplicity; - } else { - LOGF(fatal, "\033[1;31m%s at line %d : multiplicity estimator = %s is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eMultiplicityEstimator].Data()); + // a) Insanity checks: + if (!(ec.fUseEventCutCounterAbsolute || ec.fUseEventCutCounterSequential)) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } + // b) Print or die: + for (int rs = 0; rs < 2; rs++) // reco/sim + { + for (int cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter + { + if (!(ec.fEventCutCounterHist[rs][cc])) { + continue; + } + LOGF(info, "\033[1;32m\nPrinting the content of event cut counter histogram %s\033[0m", ec.fEventCutCounterHist[rs][cc]->GetName()); + for (int bin = 1; bin <= ec.fEventCutCounterHist[rs][cc]->GetNbinsX(); bin++) { + if (TString(ec.fEventCutCounterHist[rs][cc]->GetXaxis()->GetBinLabel(bin)).EqualTo("TBI")) { // TBI 20240514 temporary workaround, "TBI" can't persist here + continue; + } + LOGF(info, "bin = %d => %s : %d", bin, ec.fEventCutCounterHist[rs][cc]->GetXaxis()->GetBinLabel(bin), static_cast(ec.fEventCutCounterHist[rs][cc]->GetBinContent(bin))); + } + } // for (int cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter + } // for (int rs = 0; rs < 2; rs++) // reco/sim + if (tc.fVerbose) { ExitFunction(__FUNCTION__); } -} // void DetermineMultiplicity() +} // void PrintCutCounterContent() //============================================================ -template -void DetermineReferenceMultiplicity(T const& collision) +void Trace(const char* functionName, int lineNumber) { - // Determine collision reference multiplicity. - - // a) Determine reference multiplicity for real Run 3 data; - // b) Determine reference multiplicity for simulated Run 3 data; - // c) Same as a), just for converted Run 2 and Run 1 data; - // d) Same as b), just for converted Run 2 and Run 1 data; - // e) Test case; - // f) Print reference multiplicity for the audience... + // A simple utility wrapper. Use only during debugging, sprinkle calls to this function here and there, as follows + // Trace(__FUNCTION__, __LINE__); - if (tc.fVerbose) { - StartFunction(__FUNCTION__); - } + LOGF(info, "\033[1;32m%s .... line %d\033[0m", functionName, lineNumber); - // a) Determine reference multiplicity for real Run 3 data: - if constexpr (rs == eRec || rs == eRecAndSim) { - // Local convention for name of reference multiplicity estimator: use the same name as the getter, case insensitive. - if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multTPC", TString::kIgnoreCase)) { - ebye.fReferenceMultiplicity = collision.multTPC(); - } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multFV0M", TString::kIgnoreCase)) { - ebye.fReferenceMultiplicity = collision.multFV0M(); - } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multFT0C", TString::kIgnoreCase)) { - ebye.fReferenceMultiplicity = collision.multFT0C(); - } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multFT0M", TString::kIgnoreCase)) { - ebye.fReferenceMultiplicity = collision.multFT0M(); - } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multNTracksPV", TString::kIgnoreCase)) { - ebye.fReferenceMultiplicity = collision.multNTracksPV(); - } else if (ec.fsEventCuts[eReferenceMultiplicityEstimator].EqualTo("multNTracksGlobal", TString::kIgnoreCase)) { - // ebye.fReferenceMultiplicity = collision.multNTracksGlobal(); // TBI 20241209 not validated yet - } else { - LOGF(fatal, "\033[1;31m%s at line %d : reference multiplicity estimator = %d is not supported yet for Run 3. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eReferenceMultiplicityEstimator].Data()); - } - // QA: - if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific - qa.fReferenceMultiplicity[eMultTPC] = collision.multTPC(); - qa.fReferenceMultiplicity[eMultFV0M] = collision.multFV0M(); - qa.fReferenceMultiplicity[eMultFT0C] = collision.multFT0C(); - qa.fReferenceMultiplicity[eMultFT0M] = collision.multFT0M(); - qa.fReferenceMultiplicity[eMultNTracksPV] = collision.multNTracksPV(); - // qa.fReferenceMultiplicity[eMultNTracksGlobal] = collision.multNTracksGlobal(); // TBI 20241209 not validated yet - } +} // void Trace(const char* functionName, int lineNumber) - // TBI 20241123 check if corresponding simulated ref. mult. is available through collision.has_mcCollision() - // ... - } +//============================================================ - // b) Determine reference multiplicity for simulated Run 3 data: - if constexpr (rs == eSim) { - ebye.fReferenceMultiplicity = -44.; // TBI 20241123 check what to use here and add support eventualy - } +void Exit() +{ + // A simple utility wrapper. Used only during debugging. + // Use directly as: Exit(); + // Line number, function name, formatting, etc, are determinad automatically. - // c) Same as a), just for converted Run 2 and Run 1 data: - if constexpr (rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { - if (ec.fsEventCuts[eReferenceMultiplicity].EqualTo("multTracklets", TString::kIgnoreCase)) { - ebye.fReferenceMultiplicity = collision.multTracklets(); - } else { - LOGF(fatal, "\033[1;31m%s at line %d : reference multiplicity estimator = %d is not supported yet for Run 2. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eReferenceMultiplicityEstimator].Data()); - } - // QA: - if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific - // ... - } + LOGF(info, "\n\n\n\n\n\n\n\n\n\n"); + exit(1); - // TBI 20241123 check if corresponding simulated ref. mult. is available through collision.has_mcCollision() - // ... - } +} // void Exit() - // d) Same as b), just for converted Run 2 and Run 1 data: - if constexpr (rs == eSim_Run2 || rs == eSim_Run1) { - ebye.fReferenceMultiplicity = -44.; // TBI 20241123 check what to use here and add support eventualy - } +//============================================================ - // e) Test case: - if constexpr (rs == eTest) { - ebye.fReferenceMultiplicity = static_cast(gRandom->Uniform(0., 5000.)); // TBI 20241123 I could implement here a getter, if there is one available both for Run 3 and Run 2/1 - } +void StartFunction(const char* functionName) +{ + // A simple utility wrapper, used when tc.fVerbose = true. It merely ensures uniform formatting of notification when the function starts. - // f) Print centrality for the audience...: - if (tc.fVerbose) { - LOGF(info, "\033[1;32m ebye.fReferenceMultiplicity = %f\033[0m", ebye.fReferenceMultiplicity); - ExitFunction(__FUNCTION__); - } + LOGF(info, "\033[1;32mStart %s\033[0m", functionName); // prints in green -} // template void DetermineReferenceMultiplicity(T const& collision) +} // void StartFunction(const char* functionName) //============================================================ -template -void DetermineCentrality(T const& collision) +void ExitFunction(const char* functionName) { - // Determine collision centrality. + // A simple utility wrapper, used when tc.fVerbose = true. It merely ensures uniform formatting of notification when the function exits. - // a) For real data, determine centrality from default centrality estimator; - // b) For simulated data, determine centrality directly from impact parameter; - // c) Same as a), just for converted Run 2 data; - // d) Same as b), just for converted Run 2 data; - // e) Same as a), just for converted Run 1 data; - // f) Same as b), just for converted Run 1 data; - // g) Test case; - // h) Print centrality for the audience... + LOGF(info, "\033[1;32mExit %s\033[0m", functionName); // prints in green - if (tc.fVerbose) { - StartFunction(__FUNCTION__); - } +} // void ExitFunction(const char* functionName) - // a) For real data, determine centrality from default centrality estimator: - if constexpr (rs == eRec || rs == eRecAndSim) { - // Local convention for name of centrality estimator: use the same name as the getter, case insensitive. - if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0C", TString::kIgnoreCase)) { - ebye.fCentrality = collision.centFT0C(); - } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0M", TString::kIgnoreCase)) { - ebye.fCentrality = collision.centFT0M(); - } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centFV0A", TString::kIgnoreCase)) { - ebye.fCentrality = collision.centFV0A(); - } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centNTPV", TString::kIgnoreCase)) { - ebye.fCentrality = collision.centNTPV(); - } else { - LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); - } - // QA: - if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific - qa.fCentrality[eCentFT0C] = collision.centFT0C(); - qa.fCentrality[eCentFT0M] = collision.centFT0M(); - qa.fCentrality[eCentFV0A] = collision.centFV0A(); - qa.fCentrality[eCentNTPV] = collision.centNTPV(); - } +//============================================================ - // TBI 20240120 I could also here access also corresponding simulated centrality from impact parameter, if available through collision.has_mcCollision() - } +void BailOut(bool finalBailout = false) +{ + // Use only locally - bail out if maximum number of events was reached, and dump all results by that point in a local ROOT file. + // If fSequentialBailout > 0, bail out is performed each fSequentialBailout events, each time in a new local ROOT file. + // For sequential bailout, the naming scheme of ROOT files is AnalysisResultsBailOut_eh.fEventCounter[eProcessed].root . + // If ROOT file with the same name already exists, BailOut is not performed, since the argument is that + // it's pointless to perform Bailout for same eh.fEventCounter[eProcessed], even if eh.fEventCounter[eTotal] changed. + // Only if finalBailout = true, I will overwrite the existing file with the same name. - // b) For simulated data, determine centrality directly from impact parameter: - if constexpr (rs == eSim) { - ebye.fCentrality = -44.; // TBI 20240120 add support eventualy + if (tc.fVerbose) { + StartFunction(__FUNCTION__); } - // c) Same as a), just for converted Run 2 data: - if constexpr (rs == eRec_Run2 || rs == eRecAndSim_Run2) { - if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2V0M", TString::kIgnoreCase)) { - ebye.fCentrality = collision.centRun2V0M(); - } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2SPDTracklets", TString::kIgnoreCase)) { - ebye.fCentrality = collision.centRun2SPDTracklets(); - } else { - LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); - } - // QA: - if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific - qa.fCentrality[eCentRun2V0M] = collision.centRun2V0M(); - qa.fCentrality[eCentRun2SPDTracklets] = collision.centRun2SPDTracklets(); - } + // *) Local variables: TBI 20240130 shall I promote 'em to data members + add support for configurables? + TString sBailOutFile = "AnalysisResultsBailOut.root"; + TString sDirectoryFile = "multiparticle-correlations-a-b"; - // TBI 20240120 I could also here access also corresponding simulated centrality from impact parameter, if available through collision.has_mcCollision() + // *) For sequential bailout, I need to adapt the ROOT file name each time this function is called: + if (tc.fSequentialBailout > 0) { + sBailOutFile.ReplaceAll(".root", Form("_%d.root", eh.fEventCounter[eProcessed])); // replaces in-place + // basically, at 1st call "AnalysisResultsBailOut.root" => "AnalysisResultsBailOut_1*eh.fEventCounter[eProcessed].root", + // at 2nd call "AnalysisResultsBailOut.root" => "AnalysisResultsBailOut_2*eh.fEventCounter[eProcessed].root", etc. + if (!finalBailout && !gSystem->AccessPathName(sBailOutFile.Data(), kFileExists)) { // only for finalBailout = true, I will overwrite the existing file with the same name. + LOGF(info, "\033[1;33m\nsBailOutFile = %s already exits, that means that eh.fEventCounter[eProcessed] is the same as in the previous call of BailOut.\nJust skipping and waiting more events to pass selection criteria... \033[0m", sBailOutFile.Data()); + return; + } } - // d) Same as b), just for converted Run 2 data: - if constexpr (rs == eSim_Run2) { - ebye.fCentrality = -44.; // TBI 20240120 add support eventualy + // *) Info message: + if (eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]) { + LOGF(info, "\033[1;32m=> Per request, bailing out after %d selected events in the local file %s .\n\033[0m", static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->GetBinContent(1)), sBailOutFile.Data()); } - // e) Same as a), just for converted Run 1 data: - if constexpr (rs == eRec_Run1 || rs == eRecAndSim_Run1) { - if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centRun2V0M", TString::kIgnoreCase)) { - // ebye.fCentrality = collision.centRun2V0M(); // TBI 20240224 enable when I add support for RecAndSim_Run1 - } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("CentRun2SPDTracklets", TString::kIgnoreCase)) { - // ebye.fCentrality = collision.centRun2SPDTracklets(); // TBI 20240224 enable when I add support for RecAndSim_Run1 - } else { - LOGF(fatal, "\033[1;31m%s at line %d : centrality estimator = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); - } - // TBI 20240120 I could also here access also corresponding simulated centrality from impact parameter, if available through collision.has_mcCollision() - } + // *) Okay, let's bail out intentionally: + TFile* f = new TFile(sBailOutFile.Data(), "recreate"); + TDirectoryFile* dirFile = new TDirectoryFile(sDirectoryFile.Data(), sDirectoryFile.Data()); + // TBI 20240130 I cannot add here fBaseList directly, since that one is declared as OutputObj + // Therefore, adding one-by-one nested TList's I want to bail out. + // Keep in sync with bookAndNestAllLists(). + TList* bailOutList = new TList(); // this is sort of 'fake' fBaseList + bailOutList->SetOwner(false); // yes, beacause for sequential bailout, with SetOwner(true) the code is crashing after 1st sequential bailout is done + bailOutList->SetName(sBaseListName.Data()); + bailOutList->Add(fBasePro); // yes, this one needs a special treatment + bailOutList->Add(qa.fQAList); + bailOutList->Add(ec.fEventCutsList); + bailOutList->Add(eh.fEventHistogramsList); + bailOutList->Add(pc.fParticleCutsList); + bailOutList->Add(ph.fParticleHistogramsList); + bailOutList->Add(qv.fQvectorList); + bailOutList->Add(mupa.fCorrelationsList); + bailOutList->Add(pw.fWeightsList); + bailOutList->Add(cw.fCentralityWeightsList); + bailOutList->Add(nl.fNestedLoopsList); + bailOutList->Add(nua.fNUAList); + bailOutList->Add(iv.fInternalValidationList); + bailOutList->Add(t0.fTest0List); + bailOutList->Add(es.fEtaSeparationsList); + bailOutList->Add(res.fResultsList); + + // *) Add list with nested list to TDirectoryFile: + dirFile->Add(bailOutList, true); + dirFile->Write(dirFile->GetName(), TObject::kSingleKey + TObject::kOverwrite); - // f) Same as b), just for converted Run 1 data: - if constexpr (rs == eSim_Run1) { - ebye.fCentrality = -44.; // TBI 20240515 add support eventualy, or merge with Run 2 branch. It seems that in converted Run 1 there is no centrality. - } + delete dirFile; + dirFile = NULL; + f->Close(); - // g) Test case: - if constexpr (rs == eTest) { - ebye.fCentrality = static_cast(gRandom->Uniform(0., 100.)); + if (tc.fVerbose && !(tc.fSequentialBailout > 0)) { // then it will be called only once, for the only and permanent bailout + ExitFunction(__FUNCTION__); } - // h) Print centrality for the audience...: - if (tc.fVerbose) { - LOGF(info, "\033[1;32m ebye.fCentrality = %f\033[0m", ebye.fCentrality); - ExitFunction(__FUNCTION__); + // *) Hasta la vista: + if (finalBailout) { + LOGF(fatal, "\033[1;31mHasta la vista - bailed out permanently in function %s at line %d\n The output file is: %s\n\n\033[0m", __FUNCTION__, __LINE__, sBailOutFile.Data()); + } else { + LOGF(info, "\033[1;32mBailed out sequentially in function %s at line %d\n The output file is: %s\n\n\033[0m", __FUNCTION__, __LINE__, sBailOutFile.Data()); + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } } -} // template void DetermineCentrality(T const& collision) +} // void BailOut(bool finalBailout = false) //============================================================ -template -void DetermineOccupancy(T const& collision) +void FillQvector(const double& dPhi, const double& dPt, const double& dEta) { - // Determine collision occupancy. + // Fill integrated Q-vector. + // Example usage: this->FillQvector(dPhi, dPt, dEta); - // a) Determine occupancy from default occupancy estimator, only for eRec and eRecAndSim; - // b) For all other cases, set occupancy to -1 (not defined). - // c) Print occupancy for the audience... + // TBI 20240430 I could optimize further, and have a bare version of this function when weights are NOT used. + // But since usage of weights amounts to checking a few simple booleans here, I do not anticipate any big gain in efficiency... - if (tc.fVerbose) { + if (tc.fVerboseForEachParticle) { StartFunction(__FUNCTION__); + LOGF(info, "\033[1;32m dPhi = %f\033[0m", dPhi); + LOGF(info, "\033[1;32m dPt = %f\033[0m", dPt); + LOGF(info, "\033[1;32m dEta = %f\033[0m", dEta); } - // a) Determine occupancy from default occupancy estimator, only for eRec and eRecAndSim: - if constexpr (rs == eRec || rs == eRecAndSim) { - if (ec.fsEventCuts[eOccupancyEstimator].EqualTo("TrackOccupancyInTimeRange", TString::kIgnoreCase)) { - ebye.fOccupancy = collision.trackOccupancyInTimeRange(); - } else if (ec.fsEventCuts[eOccupancyEstimator].EqualTo("FT0COccupancyInTimeRange", TString::kIgnoreCase)) { - ebye.fOccupancy = collision.ft0cOccupancyInTimeRange(); - } else { - LOGF(fatal, "\033[1;31m%s at line %d : occupancy estimator = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eOccupancyEstimator].Data()); + // Particle weights: + double wPhi = 1.; // integrated phi weight + double wPt = 1.; // integrated pt weight + double wEta = 1.; // integrated eta weight + double wToPowerP = 1.; // weight raised to power p + + if (pw.fUseWeights[wPHI]) { + wPhi = Weight(dPhi, wPHI); + if (!(wPhi > 0.)) { + LOGF(error, "\033[1;33m%s wPhi is not positive\033[0m", __FUNCTION__); + LOGF(fatal, "dPhi = %f\nwPhi = %f", dPhi, wPhi); } - // QA: - if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific - qa.fOccupancy[eTrackOccupancyInTimeRange] = collision.trackOccupancyInTimeRange(); - qa.fOccupancy[eFT0COccupancyInTimeRange] = collision.ft0cOccupancyInTimeRange(); + } // if(pw.fUseWeights[wPHI]) + + if (pw.fUseWeights[wPT]) { + wPt = Weight(dPt, wPT); // corresponding pt weight + if (!(wPt > 0.)) { + LOGF(error, "\033[1;33m%s wPt is not positive\033[0m", __FUNCTION__); + LOGF(fatal, "dPt = %f\nwPt = %f", dPt, wPt); } - } else { - // b) For all other cases, set occupancy to -1 (not defined): - ebye.fOccupancy = -1.; - // QA: - if (qa.fFillQAEventHistograms2D) { // TBI 20240515 this flag is too general here, I need to make it more specific - for (Int_t oe = 0; oe < eOccupancyEstimators_N; oe++) { - qa.fOccupancy[oe] = -1.; + } // if(pw.fUseWeights[wPT]) + + if (pw.fUseWeights[wETA]) { + wEta = Weight(dEta, wETA); // corresponding eta weight + if (!(wEta > 0.)) { + LOGF(error, "\033[1;33m%s wEta is not positive\033[0m", __FUNCTION__); + LOGF(fatal, "dEta = %f\nwEta = %f", dEta, wEta); + } + } // if(pw.fUseWeights[wETA]) + + if (qv.fCalculateQvectors) { + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power + if (pw.fUseWeights[wPHI] || pw.fUseWeights[wPT] || pw.fUseWeights[wETA]) { + wToPowerP = std::pow(wPhi * wPt * wEta, wp); + qv.fQvector[h][wp] += TComplex(wToPowerP * std::cos(h * dPhi), wToPowerP * std::sin(h * dPhi)); // Q-vector with weights + } else { + qv.fQvector[h][wp] += TComplex(std::cos(h * dPhi), std::sin(h * dPhi)); // bare Q-vector without weights + } + } // for(int wp=0;wp 0.) { + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + if (dEta > es.fEtaSeparationsValues[e] / 2.) { // yes, if eta separation is 0.2, then separation interval runs from -0.1 to 0.1 + qv.fMab[1][e] += wPhi * wPt * wEta; + for (int h = 0; h < gMaxHarmonic; h++) { + { + if (es.fEtaSeparationsSkipHarmonics[h]) { + continue; + } + qv.fQabVector[1][h][e] += TComplex(wPhi * wPt * wEta * std::cos((h + 1) * dPhi), wPhi * wPt * wEta * std::sin((h + 1) * dPhi)); + } + } // for (int h = 0; h < gMaxHarmonic; h++) { + } // for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation } } - } + } // if(es.fCalculateEtaSeparations) { - // c) Print occupancy for the audience...: - if (tc.fVerbose) { - LOGF(info, "\033[1;32m ebye.fOccupancy = %f\033[0m", ebye.fOccupancy); + if (tc.fVerboseForEachParticle) { ExitFunction(__FUNCTION__); } -} // template void DetermineOccupancy(T const& collision) +} // void FillQvector(const double& dPhi, const double& dPt, const double& dEta) //============================================================ -template -void DetermineInteractionRate(T1 const& collision, T2 const&) +void FillQvectorFromSparse(const double& dPhi, const double& dPt, const double& dEta, const double& dCharge) { - // Determine interaction rate. + // Fill integrated Q-vector using sparse histograms. - // a) Determine interaction rate only for eRec; - // b) For all other cases, set interaction rate to -1 for the time being; - // c) Print interaction rate and run duration for the audience... + // Remark: I pass by reference particle quantities, while event quantities (centrality, vertex z, ...) I fetch from data members (or from global variables in a macro). - if (tc.fVerbose) { + // To do: + // 20250224 do I need to switch to this function also in InternalValidation()? I still use simple FillQvector() there. + // That would really make sense only after I add support for usage of particle weights in InternalValidation() + + if (tc.fVerboseForEachParticle) { StartFunction(__FUNCTION__); - } + LOGF(info, "\033[1;32m dPhi = %f\033[0m", dPhi); + LOGF(info, "\033[1;32m dPt = %f\033[0m", dPt); + LOGF(info, "\033[1;32m dEta = %f\033[0m", dEta); + LOGF(info, "\033[1;32m dCharge = %f\033[0m", dCharge); + } + + // Particle weights from sparse histograms: + double wPhi = 1.; // differential multidimensional phi weight, its dimensions are defined via enum eDiffPhiWeights + double wPt = 1.; // differential multidimensional pt weight, its dimensions are defined via enum eDiffPtWeights + double wEta = 1.; // differential multidimensional eta weight, its dimensions are defined via enum eDiffEtaWeights + double wToPowerP = 1.; // weight raised to power p + + // *) Multidimensional phi weights: + if (pw.fUseDiffPhiWeights[wPhiPhiAxis]) { // yes, 0th axis serves as a comon boolean for this category + wPhi = WeightFromSparse(dPhi, dPt, dEta, dCharge, eDWPhi); + // last argument is enum eDiffWeightCategory. Event quantities, e.g. centraliy and vz, I do not need to pass, because + // for them I have ebye data members + if (!(wPhi > 0.)) { + LOGF(error, "\033[1;33m%s wPhi is not positive\033[0m", __FUNCTION__); + LOGF(error, "dPhi = %f", dPhi); + if (pw.fUseDiffPhiWeights[wPhiPtAxis]) { + LOGF(fatal, "dPt = %f", dPt); + } + if (pw.fUseDiffPhiWeights[wPhiEtaAxis]) { + LOGF(fatal, "dEta = %f", dEta); + } + if (pw.fUseDiffPhiWeights[wPhiChargeAxis]) { + LOGF(fatal, "dCharge = %f", dCharge); + } + if (pw.fUseDiffPhiWeights[wPhiCentralityAxis]) { + LOGF(fatal, "ebye.Centrality = %f", ebye.fCentrality); + } + if (pw.fUseDiffPhiWeights[wPhiVertexZAxis]) { + LOGF(fatal, "ebye.Vz = %f", ebye.fVz); + } + LOGF(fatal, "Multidimensional weight for enabled dimensions is wPhi = %f", wPhi); + } + } // if(pw.fUseDiffPhiWeights[wPhiPhiAxis]) - // a) Determine interaction rate only for eRec: - if constexpr (rs == eRec) { - auto bc = collision.template foundBC_as(); // I have the same code snippet at other places, keep in sync. - double hadronicRate = mRateFetcher.fetch(ccdb.service, static_cast(bc.timestamp()), static_cast(bc.runNumber()), "ZNC hadronic") * 1.e-3; - if (hadronicRate > 0.) { - ebye.fInteractionRate = static_cast(hadronicRate); - } else { - LOGF(fatal, "\033[1;31m%s at line %d : hadronicRate = %f is meaningless \033[0m", __FUNCTION__, __LINE__, hadronicRate); + // *) Multidimensional pt weights: + if (pw.fUseDiffPtWeights[wPtPtAxis]) { // yes, 0th axis serves as a comon boolean for this category + wPt = WeightFromSparse(dPhi, dPt, dEta, dCharge, eDWPt); // TBI 20250224 not sure if this is the right/best approach + // last argument is enum eDiffWeightCategory. Event quantities, e.g. centraliy and vz, I do not need to pass, because + // for them I have ebye data members + if (!(wPt > 0.)) { + LOGF(error, "\033[1;33m%s wPt is not positive\033[0m", __FUNCTION__); + LOGF(error, "dPt = %f", dPt); + if (pw.fUseDiffPtWeights[wPtPtAxis]) { + LOGF(fatal, "dPt = %f", dPt); + } + LOGF(fatal, "Multidimensional weight for enabled dimensions is wPt = %f", wPt); } + } // if(pw.fUseDiffPtWeights[wPtPtAxis]) - // If I fill 2D QA histogram eCurrentRunDuration_vs_InteractionRate , extract still the current run duration: - if (qa.fBookQAEventHistograms2D[eCurrentRunDuration_vs_InteractionRate]) { // TBI 20241127 do I check this flag, or pointer, like in FillEventHistograms(...) ? - ebye.fCurrentRunDuration = std::floor(bc.timestamp() * 0.001) - tc.fRunTime[eStartOfRun]; - if (ebye.fCurrentRunDuration > tc.fRunTime[eDurationInSec]) { - LOGF(fatal, "\033[1;31m%s at line %d : ebye.fCurrentRunDuration = %d is bigger than tc.fRunTime[eDurationInSec] = %d, which is meaningless \033[0m", __FUNCTION__, __LINE__, static_cast(ebye.fCurrentRunDuration), static_cast(tc.fRunTime[eDurationInSec])); + // *) Multidimensional eta weights: + if (pw.fUseDiffEtaWeights[wEtaEtaAxis]) { // yes, 0th axis serves as a comon boolean for this category + wEta = WeightFromSparse(dPhi, dPt, dEta, dCharge, eDWEta); // TBI 20250224 not sure if this is the right/best approach + // last argument is enum eDiffWeightCategory. Event quantities, e.g. centraliy and vz, I do not need to pass, because + // for them I have ebye data members + if (!(wEta > 0.)) { + LOGF(error, "\033[1;33m%s wEta is not positive\033[0m", __FUNCTION__); + LOGF(error, "dEta = %f", dEta); + if (pw.fUseDiffEtaWeights[wEtaEtaAxis]) { + LOGF(fatal, "dEta = %f", dEta); } + LOGF(fatal, "Multidimensional weight for enabled dimensions is wEta = %f", wEta); } - } else { - ebye.fInteractionRate = -1.; - ebye.fCurrentRunDuration = -1.; - } + } // if(pw.fUseDiffEtaWeights[wEtaEtaAxis]) - // c) Print interaction rate and run duration for the audience...: - if (tc.fVerbose) { - LOGF(info, "\033[1;32m ebye.fInteractionRate = %f kHz\033[0m", ebye.fInteractionRate); - if (qa.fBookQAEventHistograms2D[eCurrentRunDuration_vs_InteractionRate]) { // TBI 20241127 do I check this flag, or pointer, like in FillEventHistograms(...) ? - LOGF(info, "\033[1;32m ebye.fCurrentRunDuration = %f s (in seconds after SOR)\033[0m", ebye.fCurrentRunDuration); + if (qv.fCalculateQvectors) { + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power + if (pw.fUseDiffPhiWeights[wPhiPhiAxis] || pw.fUseDiffPtWeights[wPtPtAxis] || pw.fUseDiffEtaWeights[wEtaEtaAxis]) { + wToPowerP = std::pow(wPhi * wPt * wEta, wp); + qv.fQvector[h][wp] += TComplex(wToPowerP * std::cos(h * dPhi), wToPowerP * std::sin(h * dPhi)); // Q-vector with weights + } else { + qv.fQvector[h][wp] += TComplex(std::cos(h * dPhi), std::sin(h * dPhi)); // bare Q-vector without weights + } + } // for(int wp=0;wp 0.) { + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + if (dEta > es.fEtaSeparationsValues[e] / 2.) { // yes, if eta separation is 0.2, then separation interval runs from -0.1 to 0.1 + qv.fMab[1][e] += wPhi * wPt * wEta; + for (int h = 0; h < gMaxHarmonic; h++) { + { + if (es.fEtaSeparationsSkipHarmonics[h]) { + continue; + } + qv.fQabVector[1][h][e] += TComplex(wPhi * wPt * wEta * std::cos((h + 1) * dPhi), wPhi * wPt * wEta * std::sin((h + 1) * dPhi)); + } + } // for (int h = 0; h < gMaxHarmonic; h++) { + } // for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + } } + } // if(es.fCalculateEtaSeparations) { + + if (tc.fVerboseForEachParticle) { ExitFunction(__FUNCTION__); } -} // template void DetermineInteractionRate(T1 const& collision, T2 const& bcs) +} // void FillQvectorFromSparse(const double& dPhi, const double& dPt, const double& dEta, const double& dCharge) //============================================================ -void DetermineEventCounters() +void Fillqvector(const double& dPhi, const double& kineVarValue, eqvectorKine kineVarChoice, const double& dEta = 0.) { - // Determine all event counters. + // !!! OBSOLETE FUNCTION (as of 20250527) !!! - if (tc.fVerbose) { + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! As of 20250527, this is an obsolete function, use FillqvectorNdim(...) and FillqvectorNdimFromSparse(...) instead !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); + + // Fill differential q-vector, in generic kinematic variable. Here "kine" originally meant vs. pt or vs. eta, now it's general. + // Example usage #1: this->Fillqvector(dPhi, dPt, PTq); // differential q-vectors without using eta separations + // Example usage #2: this->Fillqvector(dPhi, dPt, PTq, dEta); // differential q-vectors with using eta separations (I need dEta of particle to decide whether particle is added to qa or qb) + + // Remark: As of 20250527, this function is obsolete, and it's superseeded by more general functions: + // a) void FillqvectorNdim(...) (without particle weights) + // b) void FillqvectorNdimFromSparse(...) (with particle weights) + + if (tc.fVerboseForEachParticle) { StartFunction(__FUNCTION__); } - // Remark: For "RecSim", the total number of events is taken from eRec. - if (eh.fEventHistograms[eNumberOfEvents][eRec][eBefore] && eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]) { - eh.fEventCounter[eTotal] = static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eBefore]->GetBinContent(1)); - eh.fEventCounter[eProcessed] = static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->GetBinContent(1)); - } else if (eh.fEventHistograms[eNumberOfEvents][eSim][eBefore] && eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]) { - // Remark: This branch covers automatically also internal validation, because I book and fill there only eSim. - eh.fEventCounter[eTotal] = static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]->GetBinContent(1)); - eh.fEventCounter[eProcessed] = static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1)); + // *) Mapping between enum's "eqvectorKine" on one side, and "eAsFunctionOf", "eWeights" and "eDiffWeights" on the other: + // TBI 20240212 I could promote this also to a member function, if I need it elsewhere. Or I could use TExMap? + eAsFunctionOf AFO_var = eAsFunctionOf_N; // this local variable determines the enum "eAsFunctionOf" which corresponds to enum "eqvectorKine" + eWeights AFO_weight = eWeights_N; // this local variable determines the enum "eWeights" which corresponds to enum "eqvectorKine" + eDiffWeights AFO_diffWeight = eDiffWeights_N; // this local variable determines the enum "eDiffWeights" which corresponds to enum "eqvectorKine" + switch (kineVarChoice) { + case PTq: { + AFO_var = AFO_PT; + AFO_weight = wPT; + AFO_diffWeight = wPHIPT; // TBI 20250215 this is now obsolete, see the comment in enum + break; + } + case ETAq: { + AFO_var = AFO_ETA; + AFO_weight = wETA; + AFO_diffWeight = wPHIETA; // TBI 20250215 this is now obsolete, see the comment in enum + break; + } + case CHARGEq: { + AFO_var = AFO_CHARGE; + AFO_weight = wCHARGE; + AFO_diffWeight = wPHICHARGE; // TBI 20250215 this is now obsolete, see the comment in enum + break; + } + default: { + LOGF(fatal, "\033[1;31m%s at line %d : this kineVarChoice = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice)); + break; + } + } // switch(kineVarChoice) + + // *) Insanity checks on above settings: + if (AFO_var == eAsFunctionOf_N) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_var == eAsFunctionOf_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); + } + if (AFO_weight == eWeights_N) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_weight == eWeights_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); + } + if (AFO_diffWeight == eDiffWeights_N) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_diffWeight == eDiffWeights_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); } - if (tc.fVerbose) { - ExitFunction(__FUNCTION__); + // *) Get the desired bin number: + int bin = -1; + if (res.fResultsPro[AFO_var]) { + bin = res.fResultsPro[AFO_var]->FindBin(kineVarValue); // this 'bin' starts from 1, i.e. this is genuine histogram bin + if (0 >= bin || res.fResultsPro[AFO_var]->GetNbinsX() < bin) { // either underflow or overflow is hit, meaning that histogram is booked in narrower range than cuts + LOGF(fatal, "\033[1;31m%s at line %d : kineVarChoice = %d, bin = %d, kineVarValue = %f \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice), bin, kineVarValue); + } } -} // void DetermineEventCounters() + // *) Get all integrated kinematic weights: + double wToPowerP = 1.; // weight raised to power p + double kineVarWeight = 1.; // e.g. this can be integrated pT or eta weight + if (pw.fUseWeights[AFO_weight]) { + kineVarWeight = Weight(kineVarValue, AFO_weight); // corresponding e.g. pt or eta weight + if (!(kineVarWeight > 0.)) { + LOGF(fatal, "\033[1;31m%s at line %d : kineVarWeight is not positive \033[0m", __FUNCTION__, __LINE__); + // TBI 20240212 or could I just skip this particle? + } + } // if(fUseWeights[AFO_weight]) { -//============================================================ + // *) Get all differential phi-weights for this kinematic variable: + // Remark: special treatment is justified for phi-weights, because q-vector is defined in terms of phi-weights. + double diffPhiWeightsForThisKineVar = 1.; + if (pw.fUseDiffWeights[AFO_diffWeight]) { + diffPhiWeightsForThisKineVar = DiffWeight(dPhi, kineVarValue, kineVarChoice); // corresponding differential phi weight as a function of e.g. pt or eta + if (!(diffPhiWeightsForThisKineVar > 0.)) { + LOGF(fatal, "\033[1;31m%s at line %d : diffPhiWeightsForThisKineVar is not positive \033[0m", __FUNCTION__, __LINE__); + // TBI 20240212 or could I just skip this particle? + } + } // if(pw.fUseDiffWeights[AFO_diffWeight]) { -void RandomIndices(Int_t nTracks) -{ - // Randomize indices using Fisher-Yates algorithm. + // *) Finally, fill differential q-vector in that bin: + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power + if (pw.fUseWeights[AFO_weight] || pw.fUseDiffWeights[AFO_diffWeight]) { + // TBI 20240212 supported at the moment: e.g. q-vector vs pt can be weighted only with diff. phi(pt) and integrated pt weights. + // It cannot be weighted in addition with eta weights, since in any case I anticipate I will do always 1-D analysis, by integrating out all other dependencies + wToPowerP = std::pow(diffPhiWeightsForThisKineVar * kineVarWeight, wp); + qv.fqvector[kineVarChoice][bin - 1][h][wp] += TComplex(wToPowerP * std::cos(h * dPhi), wToPowerP * std::sin(h * dPhi)); // q-vector with weights + } else { + qv.fqvector[kineVarChoice][bin - 1][h][wp] += TComplex(std::cos(h * dPhi), std::sin(h * dPhi)); // bare q-vector without weights + } + } // for(int wp=0;wpAddAt(dPhi, qv.fqvectorEntries[kineVarChoice][bin - 1]); + nl.ftaNestedLoopsKine[kineVarChoice][bin - 1][1]->AddAt(diffPhiWeightsForThisKineVar * kineVarWeight, qv.fqvectorEntries[kineVarChoice][bin - 1]); } - if (nTracks < 1) { - return; - } + // *) Multiplicity counter in this bin: + qv.fqvectorEntries[kineVarChoice][bin - 1]++; // count number of particles in this pt bin in this event - // Fisher-Yates algorithm: - tc.fRandomIndices = new TArrayI(nTracks); - tc.fRandomIndices->Reset(); // just in case there is some random garbage in memory at init - for (Int_t i = 0; i < nTracks; i++) { - tc.fRandomIndices->AddAt(i, i); - } - for (Int_t i = nTracks - 1; i >= 1; i--) { - Int_t j = gRandom->Integer(i + 1); - Int_t temp = tc.fRandomIndices->GetAt(j); - tc.fRandomIndices->AddAt(tc.fRandomIndices->GetAt(i), j); - tc.fRandomIndices->AddAt(temp, i); - } // end of for(Int_t i=nTracks-1;i>=1;i--) + // *) Usage of eta separations in differential correlations: + if (es.fCalculateEtaSeparations && es.fCalculateEtaSeparationsAsFunctionOf[AFO_var]) { // yes, I can decouple this one from if (qv.fCalculateQvectors) - if (tc.fVerbose) { + if (AFO_var == AFO_ETA) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_var == AFO_ETA . This doesn't make any sense in this context. \033[0m", __FUNCTION__, __LINE__); + } + + if (dEta < 0.) { + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + if (dEta < -1. * es.fEtaSeparationsValues[e] / 2.) { // yes, if eta separation is 0.2, then separation interval runs from -0.1 to 0.1 + // qv.fmab[0][bin - 1][e] += diffPhiWeightsForThisKineVar * kineVarWeight; // Remark: I can hardwire linear weight like this only for 2-p correlation + // TBI 20250616 I cannot use this any longer, after i added one more dimension + for (int h = 0; h < gMaxHarmonic; h++) { + if (es.fEtaSeparationsSkipHarmonics[h]) { + continue; + } + // qv.fqabVector[0][bin - 1][h][e] += TComplex(diffPhiWeightsForThisKineVar * kineVarWeight * std::cos((h + 1) * dPhi), diffPhiWeightsForThisKineVar * kineVarWeight * std::sin((h + 1) * dPhi)); // TBI 20250616 I cannot use this any longer, after I added one more dimension to qv.fqabVector + } + } // for (int h = 0; h < gMaxHarmonic; h++) { + } // for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + } else if (dEta > 0.) { + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + if (dEta > es.fEtaSeparationsValues[e] / 2.) { // yes, if eta separation is 0.2, then separation interval runs from -0.1 to 0.1 + // qv.fmab[1][bin - 1][e] += diffPhiWeightsForThisKineVar * kineVarWeight; // Remark: I can hardwire linear weight like this only for 2-p correlation + // TBI 20250616 I cannot use this any longer, after i added one more dimension + for (int h = 0; h < gMaxHarmonic; h++) { + { + if (es.fEtaSeparationsSkipHarmonics[h]) { + continue; + } + // qv.fqabVector[1][bin - 1][h][e] += TComplex(diffPhiWeightsForThisKineVar * kineVarWeight * std::cos((h + 1) * dPhi), diffPhiWeightsForThisKineVar * kineVarWeight * std::sin((h + 1) * dPhi)); // Remark: I can hardwire linear weight like this only for 2-p correlation // TBI 20250616 I cannot use this any longer, after I added one more dimension to qv.fqabVector + } + } // for (int h = 0; h < gMaxHarmonic; h++) { + } // for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + } + } + } // if(es.fCalculateEtaSeparations) { + + if (tc.fVerboseForEachParticle) { ExitFunction(__FUNCTION__); } -} // void RandomIndices(Int_t nTracks) +} // void Fillqvector(const double& dPhi, const double& kineVarValue, eqvectorKine kineVarChoice) //============================================================ -template -void BanishmentLoopOverParticles(T const& tracks) +eAsFunctionOf AfoKineMap1D(eqvectorKine kineVarChoice) { - // This is the quick banishment loop over particles, as a support for eSelectedTracks cut (used through eMultiplicity, see comments for ebye.fMultiplicity). - // This is particularly relevant to get all efficiency corrections right. - // The underlying problem is that particle histograms got filled before eSelectedTracks could be applied in Steer. - // Therefore, particle histograms got filled even for events which were rejected by eSelectedTracks cut. - // In this loop, for those few specific events (typically low-multiplicity outliers), particle histograms are re-filled again with weight -1, - // which in effect cancels the previos fill in the MainLoopOverParticles. - - // Remark: I have to use here all additional checks, like ValidTrack, as in the MainLoopOverParticles. - // Therefore, it's important to have local variable lSelectedTracks, so that I can cross-compare - // at the end with central data member ebye.fSelectedTracks + // Simple utility function to map for the 1-dimensional case eqvectorKine into eAsFunctionOf. - if (tc.fVerbose) { + if (tc.fVerboseForEachParticle) { StartFunction(__FUNCTION__); } - // *) If random access of tracks from collection is requested, use Fisher-Yates algorithm to generate random indices: - // Remark: It is very important that I use exactly the same random sequence from FY already generated in the MainLoop - if (tc.fUseFisherYates) { - if (!tc.fRandomIndices) { - LOGF(fatal, "\033[1;31m%s at line %d : I have to use here exactly the same random sequence from FY already generated in the MainLoopOverParticles, but it's not available \033[0m", __FUNCTION__, __LINE__); - } - } - - // *) Counter of selected tracks in the current event: - Int_t lSelectedTracks = 0; // I could reset and reuse here ebye.fSelectedTracks, but it's safer to use separate local variable, as I can do additional insanity checks here - - // *) Banishment loop over particles: - // for (auto& track : tracks) { // default standard way of looping of tracks - auto track = tracks.iteratorAt(0); // set the type and scope from one instance - for (int64_t i = 0; i < tracks.size(); i++) { - - // *) Access track sequentially from collection of tracks (default), or randomly using Fisher-Yates algorithm: - if (!tc.fUseFisherYates) { - track = tracks.iteratorAt(i); - } else { - track = tracks.iteratorAt(static_cast(tc.fRandomIndices->GetAt(i))); - } - - // *) Skip track objects which are not valid tracks (e.g. Run 2 and 1 tracklets, etc.): - if (!ValidTrack(track)) { - continue; - } + eAsFunctionOf AFO_var = eAsFunctionOf_N; - // *) Banish particle histograms before particle cuts: - // TBI 20240515 I banish for the time being only particle histograms AFTER particle cuts. - // If I start to banish here also particle histograms BEFORE particle cuts, then see if I have to do it also for event histograms BEFORE cuts. - // Event histograms AFTER cuts are not affected. - // if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D) { - // FillParticleHistograms(track, eBefore, -1); - // } + switch (kineVarChoice) { - // *) Particle cuts: - if (!ParticleCuts(track, eCut)) { // Main call for particle cuts. - continue; // not return!! + case PTq: { + AFO_var = AFO_PT; + break; } - // *) Banish particle histograms after particle cuts: - if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D || qa.fFillQAParticleHistograms2D) { - FillParticleHistograms(track, eAfter, -1); // with negative weight -1, I effectively remove the previous fill for this track + case ETAq: { + AFO_var = AFO_ETA; + break; } - // *) Increase the local selected particle counter: - lSelectedTracks++; - if (lSelectedTracks >= ec.fdEventCuts[eMultiplicity][eMax]) { + case CHARGEq: { + AFO_var = AFO_CHARGE; break; } - // *) Break the loop if fixed number of particles is taken randomly from each event (use always in combination with tc.fUseFisherYates = kTRUE): - if (tc.fFixedNumberOfRandomlySelectedTracks > 0 && tc.fFixedNumberOfRandomlySelectedTracks == lSelectedTracks) { - LOGF(info, "%s : Breaking the loop over particles, since requested fixed number of %d particles was reached", __FUNCTION__, tc.fFixedNumberOfRandomlySelectedTracks); + // ... + + default: { + LOGF(fatal, "\033[1;31m%s at line %d : this kineVarChoice = %d is not supported yet for 1D case. \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice)); break; } - } // for (auto& track : tracks) - - // *) Quick insanity checks (mandatory!): - if (lSelectedTracks != ebye.fSelectedTracks) { - LOGF(fatal, "\033[1;31m%s at line %d : lSelectedTracks != ebye.fSelectedTracks , lSelectedTracks = %d, ebye.fSelectedTracks = %d \033[0m", __FUNCTION__, __LINE__, lSelectedTracks, ebye.fSelectedTracks); - } + } // switch(kineVarChoice) - if (tc.fVerbose) { + if (tc.fVerboseForEachParticle) { ExitFunction(__FUNCTION__); } -} // template void BanishmentLoopOverParticles(T const& tracks) { + return AFO_var; + +} // eAsFunctionOf AfoKineMap1D(eqvectorKine kineVarChoice) //============================================================ -void PrintCutCounterContent() +eAsFunctionOf2D AfoKineMap2D(eqvectorKine kineVarChoice) { - // Prints on the screen content of fEventCutCounterHist[][] (all which were booked). + // Simple utility function to map for the 2-dimensional case eqvectorKine into eAsFunctionOf2D. - // a) Insanity checks; - // b) Print or die. - - if (tc.fVerbose) { + if (tc.fVerboseForEachParticle) { StartFunction(__FUNCTION__); } - // a) Insanity checks: - if (!(ec.fUseEventCutCounterAbsolute || ec.fUseEventCutCounterSequential)) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - - // b) Print or die: - for (Int_t rs = 0; rs < 2; rs++) // reco/sim - { - for (Int_t cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter - { - if (!(ec.fEventCutCounterHist[rs][cc])) { - continue; - } - LOGF(info, "\033[1;32m\nPrinting the content of event cut counter histogram %s\033[0m", ec.fEventCutCounterHist[rs][cc]->GetName()); - for (Int_t bin = 1; bin <= ec.fEventCutCounterHist[rs][cc]->GetNbinsX(); bin++) { - if (TString(ec.fEventCutCounterHist[rs][cc]->GetXaxis()->GetBinLabel(bin)).EqualTo("TBI")) { // TBI 20240514 temporary workaround, "TBI" can't persist here - continue; - } - LOGF(info, "bin = %d => %s : %d", bin, ec.fEventCutCounterHist[rs][cc]->GetXaxis()->GetBinLabel(bin), static_cast(ec.fEventCutCounterHist[rs][cc]->GetBinContent(bin))); - } - } // for (Int_t cc = 0; cc < eCutCounter_N; cc++) // enum eCutCounter - } // for (Int_t rs = 0; rs < 2; rs++) // reco/sim - - if (tc.fVerbose) { - ExitFunction(__FUNCTION__); - } - -} // void PrintCutCounterContent() - -//============================================================ - -void Trace(const char* functionName, Int_t lineNumber) -{ - // A simple utility wrapper. Use only during debugging, sprinkle calls to this function here and there, as follows - // Trace(__FUNCTION__, __LINE__); - - LOGF(info, "\033[1;32m%s .... line %d\033[0m", functionName, lineNumber); - -} // void Trace(const char* functionName, Int_t lineNumber) - -//============================================================ - -void Exit() -{ - // A simple utility wrapper. Used only during debugging. - // Use directly as: Exit(); - // Line number, function name, formatting, etc, are determinad automatically. + eAsFunctionOf2D AFO_var = eAsFunctionOf2D_N; - LOGF(info, "\n\n\n\n\n\n\n\n\n\n"); - exit(1); + switch (kineVarChoice) { -} // void Exit() + case PT_ETAq: { + AFO_var = AFO_PT_ETA; + break; + } -//============================================================ + case PT_CHARGEq: { + AFO_var = AFO_PT_CHARGE; + break; + } -void StartFunction(const char* functionName) -{ - // A simple utility wrapper, used when tc.fVerbose = kTRUE. It merely ensures uniform formatting of notification when the function starts. + case ETA_CHARGEq: { + AFO_var = AFO_ETA_CHARGE; + break; + } - LOGF(info, "\033[1;32mStart %s\033[0m", functionName); // prints in green + // ... -} // void StartFunction(const char* functionName) + default: { + LOGF(fatal, "\033[1;31m%s at line %d : this kineVarChoice = %d is not supported yet for 2D case. \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice)); + break; + } -//============================================================ + } // switch(kineVarChoice) -void ExitFunction(const char* functionName) -{ - // A simple utility wrapper, used when tc.fVerbose = kTRUE. It merely ensures uniform formatting of notification when the function exits. + if (tc.fVerboseForEachParticle) { + ExitFunction(__FUNCTION__); + } - LOGF(info, "\033[1;32mExit %s\033[0m", functionName); // prints in green + return AFO_var; -} // void ExitFunction(const char* functionName) +} // eAsFunctionOf2D AfoKineMap2D(eqvectorKine kineVarChoice) //============================================================ -void BailOut(Bool_t finalBailout = kFALSE) +eAsFunctionOf3D AfoKineMap3D(eqvectorKine kineVarChoice) { - // Use only locally - bail out if maximum number of events was reached, and dump all results by that point in a local ROOT file. - // If fSequentialBailout > 0, bail out is performed each fSequentialBailout events, each time in a new local ROOT file. - // For sequential bailout, the naming scheme of ROOT files is AnalysisResultsBailOut_eh.fEventCounter[eProcessed].root . - // If ROOT file with the same name already exists, BailOut is not performed, since the argument is that - // it's pointless to perform Bailout for same eh.fEventCounter[eProcessed], even if eh.fEventCounter[eTotal] changed. - // Only if finalBailout = kTRUE, I will overwrite the existing file with the same name. + // Simple utility function to map for the 3-dimensional case eqvectorKine into eAsFunctionOf3D. - if (tc.fVerbose) { + if (tc.fVerboseForEachParticle) { StartFunction(__FUNCTION__); } - // *) Local variables: TBI 20240130 shall I promote 'em to data members + add support for configurables? - TString sBailOutFile = "AnalysisResultsBailOut.root"; - TString sDirectoryFile = "multiparticle-correlations-a-b"; + eAsFunctionOf3D AFO_var = eAsFunctionOf3D_N; - // *) For sequential bailout, I need to adapt the ROOT file name each time this function is called: - if (tc.fSequentialBailout > 0) { - sBailOutFile.ReplaceAll(".root", Form("_%d.root", eh.fEventCounter[eProcessed])); // replaces in-place - // basically, at 1st call "AnalysisResultsBailOut.root" => "AnalysisResultsBailOut_1*eh.fEventCounter[eProcessed].root", - // at 2nd call "AnalysisResultsBailOut.root" => "AnalysisResultsBailOut_2*eh.fEventCounter[eProcessed].root", etc. - if (!finalBailout && !gSystem->AccessPathName(sBailOutFile.Data(), kFileExists)) { // only for finalBailout = kTRUE, I will overwrite the existing file with the same name. - LOGF(info, "\033[1;33m\nsBailOutFile = %s already exits, that means that eh.fEventCounter[eProcessed] is the same as in the previous call of BailOut.\nJust skipping and waiting more events to pass selection criteria... \033[0m", sBailOutFile.Data()); - return; + switch (kineVarChoice) { + + case PT_ETA_CHARGEq: { + AFO_var = AFO_PT_ETA_CHARGE; + break; } - } - // *) Info message: - if (eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]) { - LOGF(info, "\033[1;32m=> Per request, bailing out after %d selected events in the local file %s .\n\033[0m", static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->GetBinContent(1)), sBailOutFile.Data()); - } + // ... - // *) Okay, let's bail out intentionally: - TFile* f = new TFile(sBailOutFile.Data(), "recreate"); - TDirectoryFile* dirFile = new TDirectoryFile(sDirectoryFile.Data(), sDirectoryFile.Data()); - // TBI 20240130 I cannot add here fBaseList directly, since that one is declared as OutputObj - // Therefore, adding one-by-one nested TList's I want to bail out. - // Keep in sync with BookAndNestAllLists(). - TList* bailOutList = new TList(); // this is sort of 'fake' fBaseList - bailOutList->SetOwner(kFALSE); // yes, beacause for sequential bailout, with SetOwner(kTRUE) the code is crashing after 1st sequential bailout is done - bailOutList->SetName(sBaseListName.Data()); - bailOutList->Add(fBasePro); // yes, this one needs a special treatment - bailOutList->Add(qa.fQAList); - bailOutList->Add(ec.fEventCutsList); - bailOutList->Add(eh.fEventHistogramsList); - bailOutList->Add(pc.fParticleCutsList); - bailOutList->Add(ph.fParticleHistogramsList); - bailOutList->Add(qv.fQvectorList); - bailOutList->Add(mupa.fCorrelationsList); - bailOutList->Add(pw.fWeightsList); - bailOutList->Add(cw.fCentralityWeightsList); - bailOutList->Add(nl.fNestedLoopsList); - bailOutList->Add(nua.fNUAList); - bailOutList->Add(iv.fInternalValidationList); - bailOutList->Add(t0.fTest0List); - bailOutList->Add(es.fEtaSeparationsList); - bailOutList->Add(res.fResultsList); + default: { + LOGF(fatal, "\033[1;31m%s at line %d : this kineVarChoice = %d is not supported yet for 3D case. \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice)); + break; + } - // *) Add list with nested list to TDirectoryFile: - dirFile->Add(bailOutList, kTRUE); - dirFile->Write(dirFile->GetName(), TObject::kSingleKey + TObject::kOverwrite); - delete dirFile; - dirFile = NULL; - f->Close(); + } // switch(kineVarChoice) - if (tc.fVerbose && !(tc.fSequentialBailout > 0)) { // then it will be called only once, for the only and permanent bailout + if (tc.fVerboseForEachParticle) { ExitFunction(__FUNCTION__); } - // *) Hasta la vista: - if (finalBailout) { - LOGF(fatal, "\033[1;31mHasta la vista - bailed out permanently in function %s at line %d\n The output file is: %s\n\n\033[0m", __FUNCTION__, __LINE__, sBailOutFile.Data()); - } else { - LOGF(info, "\033[1;32mBailed out sequentially in function %s at line %d\n The output file is: %s\n\n\033[0m", __FUNCTION__, __LINE__, sBailOutFile.Data()); - if (tc.fVerbose) { - ExitFunction(__FUNCTION__); - } - } + return AFO_var; -} // void BailOut(Bool_t finalBailout = kFALSE) +} // eAsFunctionOf3D AfoKineMap3D(eqvectorKine kineVarChoice) //============================================================ -void FillQvector(const Double_t& dPhi, const Double_t& dPt, const Double_t& dEta) +TString StringKineMap(eqvectorKine kineVarChoice) { - // Fill integrated Q-vector. - // Example usage: this->FillQvector(dPhi, dPt, dEta); + // Simple utility function to map eqvectorKine into string. - // TBI 20240430 I could optimize further, and have a bare version of this function when weights are NOT used. - // But since usage of weights amounts to checking a few simple booleans here, I do not anticipate any big gain in efficiency... + // Example: StringKineMap(PTq).Data() => prints "vs. pt" if (tc.fVerboseForEachParticle) { StartFunction(__FUNCTION__); - LOGF(info, "\033[1;32m dPhi = %f\033[0m", dPhi); - LOGF(info, "\033[1;32m dPt = %f\033[0m", dPt); - LOGF(info, "\033[1;32m dEta = %f\033[0m", dEta); } - // Particle weights: - Double_t wPhi = 1.; // integrated phi weight - Double_t wPt = 1.; // integrated pt weight - Double_t wEta = 1.; // integrated eta weight - Double_t wToPowerP = 1.; // weight raised to power p + TString s = ""; - if (pw.fUseWeights[wPHI]) { - wPhi = Weight(dPhi, wPHI); - if (!(wPhi > 0.)) { - LOGF(error, "\033[1;33m%s wPhi is not positive\033[0m", __FUNCTION__); - LOGF(fatal, "dPhi = %f\nwPhi = %f", dPhi, wPhi); + switch (kineVarChoice) { + + case PTq: { + s = "vs. pt"; + break; } - } // if(pw.fUseWeights[wPHI]) - if (pw.fUseWeights[wPT]) { - wPt = Weight(dPt, wPT); // corresponding pt weight - if (!(wPt > 0.)) { - LOGF(error, "\033[1;33m%s wPt is not positive\033[0m", __FUNCTION__); - LOGF(fatal, "dPt = %f\nwPt = %f", dPt, wPt); + case ETAq: { + s = "vs. eta"; + break; } - } // if(pw.fUseWeights[wPT]) - if (pw.fUseWeights[wETA]) { - wEta = Weight(dEta, wETA); // corresponding eta weight - if (!(wEta > 0.)) { - LOGF(error, "\033[1;33m%s wEta is not positive\033[0m", __FUNCTION__); - LOGF(fatal, "dEta = %f\nwEta = %f", dEta, wEta); + case CHARGEq: { + s = "vs. charge"; + break; } - } // if(pw.fUseWeights[wETA]) - if (qv.fCalculateQvectors) { - for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { - for (Int_t wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power - if (pw.fUseWeights[wPHI] || pw.fUseWeights[wPT] || pw.fUseWeights[wETA]) { - wToPowerP = pow(wPhi * wPt * wEta, wp); - qv.fQvector[h][wp] += TComplex(wToPowerP * TMath::Cos(h * dPhi), wToPowerP * TMath::Sin(h * dPhi)); // Q-vector with weights - } else { - qv.fQvector[h][wp] += TComplex(TMath::Cos(h * dPhi), TMath::Sin(h * dPhi)); // bare Q-vector without weights - } - } // for(Int_t wp=0;wp 0.) { - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { - if (dEta > es.fEtaSeparationsValues[e] / 2.) { // yes, if eta separation is 0.2, then separation interval runs from -0.1 to 0.1 - qv.fMab[1][e] += wPhi * wPt * wEta; - for (Int_t h = 0; h < gMaxHarmonic; h++) { - { - if (es.fEtaSeparationsSkipHarmonics[h]) { - continue; - } - qv.fQabVector[1][h][e] += TComplex(wPhi * wPt * wEta * TMath::Cos((h + 1) * dPhi), wPhi * wPt * wEta * TMath::Sin((h + 1) * dPhi)); - } - } // for (Int_t h = 0; h < gMaxHarmonic; h++) { - } // for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation - } + case PT_CHARGEq: { + s = "vs. pt vs. charge"; + break; } - } // if(es.fCalculateEtaSeparations) { + + case ETA_CHARGEq: { + s = "vs. eta vs. charge"; + break; + } + + case PT_ETA_CHARGEq: { + s = "vs. pt vs. eta vs. charge"; + break; + } + + // ... + + default: { + LOGF(fatal, "\033[1;31m%s at line %d : this kineVarChoice = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice)); + break; + } + + } // switch(kineVarChoice) if (tc.fVerboseForEachParticle) { ExitFunction(__FUNCTION__); } -} // void FillQvector(const Double_t& dPhi, const Double_t& dPt, const Double_t& dEta) + return s; + +} // TString StringKineMap(eqvectorKine kineVarChoice) //============================================================ -void Fillqvector(const Double_t& dPhi, const Double_t& kineVarValue, eqvectorKine kineVarChoice, const Double_t& dEta = 0.) +void FillqvectorNdim(const double& dPhi, double* kineVarValues, int Ndim, eqvectorKine kineVarChoice, const double& dEta = 0.) { - // Fill differential q-vector, in generic kinematic variable. Here "kine" originally meant vs. pt or vs. eta, now it's general. - // Example usage #1: this->Fillqvector(dPhi, dPt, PTq); // differential q-vectors without using eta separations - // Example usage #2: this->Fillqvector(dPhi, dPt, PTq, dEta); // differential q-vectors with using eta separations (I need dEta of particle to decide whether particle is added to qa or qb) + // Fill differential q-vector in N dimensions, calculated vs. N generic kinematic variables, + // and using only the unit particle weights (for non-unit weights, there is FillqvectorNdimFromSparse(...)). + // Here "kine" originally meant vs. pt or vs. eta, now it's general. + // For more than 1 dimension, e.g. vs. (pt, eta), "kineVarChoice" corresponds to linearized 2D case, in an analogy with "global bin" structure for multidimensional histograms. + + // Remark 0: "kineVarValues" is now an array, e.g. for qvector vs. (pt, eta), it holds pt and eta of a particle. Ndim is dimensionality of that array. + // Remark 1: The last argument "dEta" is meant to be used only for fqabVector (I need dEta of particle to decide whether particle is added to qa or qb) + // Remark 2: "bin" is always mean to be "linearized global bin", therefore I changed indexing here from "bin-1" to "bin" + + // Example - the standard 1D case: + // double kineArr[1] = {dPt}; + // this->FillqvectorNdim(dPhi, kineArr, 1, PTq); // differential q-vector vs. pt + + // Example - the 2D case: + // double kineArr[2] = {dPt, dEta}; + // this->FillqvectorNdim(dPhi, kineArr, 2, PT_ETAq); // differential q-vector vs. (pt, eta) + + // Example - the 3D case: + // double kineArr[3] = {dPt, dEta, dCharge}; + // this->FillqvectorNdim(dPhi, kineArr, 3, PT_ETA_CHARGEq); // differential q-vector vs. (pt, eta, charge) + + // Example - the 1D case, pt dependence with eta separations: + // double kineArr[1] = {dPt}; + // this->FillqvectorNdim(dPhi, kineArr, 1, PTq, dEta); // differential q-vectors with using eta separations (I need dEta of particle to decide whether particle is added to qa or qb) if (tc.fVerboseForEachParticle) { StartFunction(__FUNCTION__); } - // *) Mapping between enum's "eqvectorKine" on one side, and "eAsFunctionOf", "eWeights" and "eDiffWeights" on the other: - // TBI 20240212 I could promote this also to a member function, if I need it elsewhere. Or I could use TExMap? - eAsFunctionOf AFO_var = eAsFunctionOf_N; // this local variable determines the enum "eAsFunctionOf" which corresponds to enum "eqvectorKine" - eWeights AFO_weight = eWeights_N; // this local variable determines the enum "eWeights" which corresponds to enum "eqvectorKine" - eDiffWeights AFO_diffWeight = eDiffWeights_N; // this local variable determines the enum "eDiffWeights" which corresponds to enum "eqvectorKine" - switch (kineVarChoice) { - case PTq: - AFO_var = AFO_PT; - AFO_weight = wPT; - AFO_diffWeight = wPHIPT; + // This is the linearized global bin, the 2nd index of fqvector[...][gMaxNoBinsKine][...][...], it shall work transparently for 1D, 2D, 3D, etc... + // Yes, it is also the 3rd index of fqabVector[...][...][gMaxNoBinsKine][...][...] + int bin = -1; + + switch (Ndim) { + + case 1: { + eAsFunctionOf AFO_var = AfoKineMap1D(kineVarChoice); + if (res.fResultsPro[AFO_var]) { + bin = res.fResultsPro[AFO_var]->FindBin(kineVarValues[0]); // this is linearized 'global bin', for 1D it's the same as ordinary bin + + // TBI 20250528 check if the check below is computationally heavy. If so, add the flag tc.fInsanityCheckForEachParticle here. + if (res.fResultsPro[AFO_var]->IsBinUnderflow(bin) || res.fResultsPro[AFO_var]->IsBinOverflow(bin)) { + LOGF(fatal, "\033[1;31m%s at line %d : kineVarChoice = %d (%s), kineVarValues[0] = %f is in bin = %d, which is either underflow or overflow.\033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), kineVarValues[0], bin); + } + } break; - case ETAq: - AFO_var = AFO_ETA; - AFO_weight = wETA; - AFO_diffWeight = wPHIETA; + } + + case 2: { + eAsFunctionOf2D AFO_var = AfoKineMap2D(kineVarChoice); + if (res.fResultsPro2D[AFO_var]) { + bin = res.fResultsPro2D[AFO_var]->FindBin(kineVarValues[0], kineVarValues[1]); // this is linearized 'global bin' + + // TBI 20250528 check if the check below is computationally heavy. If so, add the flag tc.fInsanityCheckForEachParticle here. + if (res.fResultsPro2D[AFO_var]->IsBinUnderflow(bin) || res.fResultsPro2D[AFO_var]->IsBinOverflow(bin)) { + LOGF(fatal, "\033[1;31m%s at line %d : kineVarChoice = %d (%s), kineVarValues[0] = %f, kineVarValues[1] = %f is in global bin = %d, which is either underflow or overflow.\033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), kineVarValues[0], kineVarValues[1], bin); + } + } break; - default: - LOGF(fatal, "\033[1;31m%s at line %d : this kineVarChoice = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice)); + } + + case 3: { + eAsFunctionOf3D AFO_var = AfoKineMap3D(kineVarChoice); + if (res.fResultsPro3D[AFO_var]) { + bin = res.fResultsPro3D[AFO_var]->FindBin(kineVarValues[0], kineVarValues[1], kineVarValues[2]); // this is linearized 'global bin' + + // TBI 20250528 check if the check below is computationally heavy. If so, add the flag tc.fInsanityCheckForEachParticle here. + if (res.fResultsPro3D[AFO_var]->IsBinUnderflow(bin) || res.fResultsPro3D[AFO_var]->IsBinOverflow(bin)) { + LOGF(fatal, "\033[1;31m%s at line %d : kineVarChoice = %d (%s), kineVarValues[0] = %f, kineVarValues[1] = %f, kineVarValues[2] = %f is in global bin = %d, which is either underflow or overflow.\033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice), StringKineMap(kineVarChoice).Data(), kineVarValues[0], kineVarValues[1], kineVarValues[2], bin); + } + } break; - } // switch(kineVarChoice) + } - // *) Insanity checks on above settings: - if (AFO_var == eAsFunctionOf_N) { - LOGF(fatal, "\033[1;31m%s at line %d : AFO_var == eAsFunctionOf_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); - } - if (AFO_weight == eWeights_N) { - LOGF(fatal, "\033[1;31m%s at line %d : AFO_weight == eWeights_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); - } - if (AFO_diffWeight == eDiffWeights_N) { - LOGF(fatal, "\033[1;31m%s at line %d : AFO_diffWeight == eDiffWeights_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); - } + // ... - // *) Get the desired bin number: - Int_t bin = -1; - if (res.fResultsPro[AFO_var]) { - bin = res.fResultsPro[AFO_var]->FindBin(kineVarValue); // this 'bin' starts from 1, i.e. this is genuine histogram bin - if (0 >= bin || res.fResultsPro[AFO_var]->GetNbinsX() < bin) { // either underflow or overflow is hit, meaning that histogram is booked in narrower range than cuts - LOGF(fatal, "\033[1;31m%s at line %d : kineVarChoice = %d, bin = %d, kineVarValue = %f \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice), bin, kineVarValue); + default: { + LOGF(fatal, "\033[1;31m%s at line %d : Ndim = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, Ndim); + break; } - } - // *) Get all integrated kinematic weights: - Double_t wToPowerP = 1.; // weight raised to power p - Double_t kineVarWeight = 1.; // e.g. this can be integrated pT or eta weight - if (pw.fUseWeights[AFO_weight]) { - kineVarWeight = Weight(kineVarValue, AFO_weight); // corresponding e.g. pt or eta weight - if (!(kineVarWeight > 0.)) { - LOGF(fatal, "\033[1;31m%s at line %d : kineVarWeight is not positive \033[0m", __FUNCTION__, __LINE__); - // TBI 20240212 or could I just skip this particle? + } // switch (Ndim) + + // zzzzzzzzzzzzzzzzzzzzzz + + /* + + // *) Mapping between enum's "eqvectorKine" on one side, and "eAsFunctionOf", "eWeights" and "eDiffWeights" on the other: + // TBI 20240212 I could promote this also to a member function, if I need it elsewhere. Or I could use TExMap? + eAsFunctionOf AFO_var = eAsFunctionOf_N; // this local variable determines the enum "eAsFunctionOf" which corresponds to enum "eqvectorKine" + eWeights AFO_weight = eWeights_N; // this local variable determines the enum "eWeights" which corresponds to enum "eqvectorKine" + eDiffWeights AFO_diffWeight = eDiffWeights_N; // this local variable determines the enum "eDiffWeights" which corresponds to enum "eqvectorKine" + switch (kineVarChoice) { + case PTq: { + AFO_var = AFO_PT; + AFO_weight = wPT; + AFO_diffWeight = wPHIPT; // TBI 20250215 this is now obsolete, see the comment in enum + break; + } + case ETAq: { + AFO_var = AFO_ETA; + AFO_weight = wETA; + AFO_diffWeight = wPHIETA; // TBI 20250215 this is now obsolete, see the comment in enum + break; + } + case CHARGEq: { + AFO_var = AFO_CHARGE; + AFO_weight = wCHARGE; + AFO_diffWeight = wPHICHARGE; // TBI 20250215 this is now obsolete, see the comment in enum + break; + } + default: { + LOGF(fatal, "\033[1;31m%s at line %d : this kineVarChoice = %d is not supported yet. \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice)); + break; + } + } // switch(kineVarChoice) + + // *) Insanity checks on above settings: + if (AFO_var == eAsFunctionOf_N) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_var == eAsFunctionOf_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); + } + if (AFO_weight == eWeights_N) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_weight == eWeights_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); + } + if (AFO_diffWeight == eDiffWeights_N) { + LOGF(fatal, "\033[1;31m%s at line %d : AFO_diffWeight == eDiffWeights_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); } - } // if(fUseWeights[AFO_weight]) { - // *) Get all differential phi-weights for this kinematic variable: - // Remark: special treatment is justified for phi-weights, because q-vector is defined in terms of phi-weights. - Double_t diffPhiWeightsForThisKineVar = 1.; - if (pw.fUseDiffWeights[AFO_diffWeight]) { - diffPhiWeightsForThisKineVar = DiffWeight(dPhi, kineVarValue, kineVarChoice); // corresponding differential phi weight as a function of e.g. pt or eta - if (!(diffPhiWeightsForThisKineVar > 0.)) { - LOGF(fatal, "\033[1;31m%s at line %d : diffPhiWeightsForThisKineVar is not positive \033[0m", __FUNCTION__, __LINE__); - // TBI 20240212 or could I just skip this particle? + // *) Get the desired bin number: + int bin = -1; + if (res.fResultsPro[AFO_var]) { + bin = res.fResultsPro[AFO_var]->FindBin(kineVarValue); // this 'bin' starts from 1, i.e. this is genuine histogram bin + if (0 >= bin || res.fResultsPro[AFO_var]->GetNbinsX() < bin) { // either underflow or overflow is hit, meaning that histogram is booked in narrower range than cuts + LOGF(fatal, "\033[1;31m%s at line %d : kineVarChoice = %d, bin = %d, kineVarValue = %f \033[0m", __FUNCTION__, __LINE__, static_cast(kineVarChoice), bin, kineVarValue); + } } - } // if(pw.fUseDiffWeights[AFO_diffWeight]) { + */ - // *) Finally, fill differential q-vector in that bin: - for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { - for (Int_t wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power - if (pw.fUseWeights[AFO_weight] || pw.fUseDiffWeights[AFO_diffWeight]) { - // TBI 20240212 supported at the moment: e.g. q-vector vs pt can be weighted only with diff. phi(pt) and integrated pt weights. - // It cannot be weighted in addition with eta weights, since in any case I anticipate I will do always 1-D analysis, by integrating out all other dependencies - wToPowerP = pow(diffPhiWeightsForThisKineVar * kineVarWeight, wp); - qv.fqvector[kineVarChoice][bin - 1][h][wp] += TComplex(wToPowerP * TMath::Cos(h * dPhi), wToPowerP * TMath::Sin(h * dPhi)); // q-vector with weights - } else { - qv.fqvector[kineVarChoice][bin - 1][h][wp] += TComplex(TMath::Cos(h * dPhi), TMath::Sin(h * dPhi)); // bare q-vector without weights + /* + // *) Get all integrated kinematic weights: + double wToPowerP = 1.; // weight raised to power p + double kineVarWeight = 1.; // e.g. this can be integrated pT or eta weight + if (pw.fUseWeights[AFO_weight]) { + kineVarWeight = Weight(kineVarValue, AFO_weight); // corresponding e.g. pt or eta weight + if (!(kineVarWeight > 0.)) { + LOGF(fatal, "\033[1;31m%s at line %d : kineVarWeight is not positive \033[0m", __FUNCTION__, __LINE__); + // TBI 20240212 or could I just skip this particle? } - } // for(Int_t wp=0;wp 0.)) { + LOGF(fatal, "\033[1;31m%s at line %d : diffPhiWeightsForThisKineVar is not positive \033[0m", __FUNCTION__, __LINE__); + // TBI 20240212 or could I just skip this particle? + } + } // if(pw.fUseDiffWeights[AFO_diffWeight]) { + + */ + + // *) Finally, fill differential q-vector in that linearized "global bin": + for (int h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + for (int wp = 0; wp < gMaxCorrelator + 1; wp++) { // weight power + qv.fqvector[kineVarChoice][bin][h][wp] += std::complex(std::cos(h * dPhi), std::sin(h * dPhi)); // bare q-vector without weights + } // for(int wp=0;wpAddAt(dPhi, qv.fqVectorEntries[kineVarChoice][bin - 1]); - nl.ftaNestedLoopsKine[kineVarChoice][bin - 1][1]->AddAt(diffPhiWeightsForThisKineVar * kineVarWeight, qv.fqVectorEntries[kineVarChoice][bin - 1]); + nl.ftaNestedLoopsKine[kineVarChoice][bin][0]->AddAt(dPhi, qv.fqvectorEntries[kineVarChoice][bin]); + nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->AddAt(1, qv.fqvectorEntries[kineVarChoice][bin]); // TBI 20250529 bare, without weights. Otherwise, adapt and use the line below + // nl.ftaNestedLoopsKine[kineVarChoice][bin][1]->AddAt(diffPhiWeightsForThisKineVar * kineVarWeight, qv.fqvectorEntries[kineVarChoice][bin]); // TBI 20250527 temporarily commented out } // *) Multiplicity counter in this bin: - qv.fqVectorEntries[kineVarChoice][bin - 1]++; // count number of particles in this pt bin in this event + qv.fqvectorEntries[kineVarChoice][bin]++; // count number of particles in this differential bin in this event // *) Usage of eta separations in differential correlations: - if (es.fCalculateEtaSeparations && es.fCalculateEtaSeparationsAsFunctionOf[AFO_var]) { // yes, I can decouple this one from if (qv.fCalculateQvectors) + if (es.fCalculateEtaSeparations && qv.fCalculateqvectorsKineEtaSeparations[kineVarChoice]) { // yes, I have decoupled this one from if (qv.fCalculateQvectors) - if (AFO_var == AFO_ETA) { - LOGF(fatal, "\033[1;31m%s at line %d : AFO_var == AFO_ETA . This doesn't make any sense in this context. \033[0m", __FUNCTION__, __LINE__); + if (kineVarChoice == ETAq || kineVarChoice == PT_ETAq || kineVarChoice == ETA_CHARGEq || kineVarChoice == PT_ETA_CHARGEq) { + LOGF(fatal, "\033[1;31m%s at line %d : kineVarChoice == %s . This doesn't make any sense in this context => eta separations cannot be used for differential vectors vs. eta (either 1D or 2D or 3D case). \033[0m", __FUNCTION__, __LINE__, StringKineMap(kineVarChoice).Data()); // _22 } if (dEta < 0.) { - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { - if (dEta < -1. * es.fEtaSeparationsValues[e] / 2.) { // yes, if eta separation is 0.2, then separation interval runs from -0.1 to 0.1 - qv.fmab[0][bin - 1][e] += diffPhiWeightsForThisKineVar * kineVarWeight; // Remark: I can hardwire linear weight like this only for 2-p correlation - for (Int_t h = 0; h < gMaxHarmonic; h++) { + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + if (dEta < -1. * es.fEtaSeparationsValues[e] / 2.) { // yes, if eta separation is 0.2, then separation interval runs from -0.1 to 0.1 + qv.fmab[0][kineVarChoice][bin][e] += 1.; // diffPhiWeightsForThisKineVar * kineVarWeight; // Remark: I can hardwire linear weight like this only for 2-p correlation + for (int h = 0; h < gMaxHarmonic; h++) { if (es.fEtaSeparationsSkipHarmonics[h]) { continue; } - qv.fqabVector[0][bin - 1][h][e] += TComplex(diffPhiWeightsForThisKineVar * kineVarWeight * TMath::Cos((h + 1) * dPhi), diffPhiWeightsForThisKineVar * kineVarWeight * TMath::Sin((h + 1) * dPhi)); // Remark: I can hardwire linear weight like this only for 2-p correlation + qv.fqabVector[0][kineVarChoice][bin][h][e] += std::complex(std::cos((h + 1) * dPhi), std::sin((h + 1) * dPhi)); // bare q_ab-vector without weights } - } // for (Int_t h = 0; h < gMaxHarmonic; h++) { - } // for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + } // for (int h = 0; h < gMaxHarmonic; h++) { + } // for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation } else if (dEta > 0.) { - for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { - if (dEta > es.fEtaSeparationsValues[e] / 2.) { // yes, if eta separation is 0.2, then separation interval runs from -0.1 to 0.1 - qv.fmab[1][bin - 1][e] += diffPhiWeightsForThisKineVar * kineVarWeight; // Remark: I can hardwire linear weight like this only for 2-p correlation - for (Int_t h = 0; h < gMaxHarmonic; h++) { + for (int e = 0; e < gMaxNumberEtaSeparations; e++) { + if (dEta > es.fEtaSeparationsValues[e] / 2.) { // yes, if eta separation is 0.2, then separation interval runs from -0.1 to 0.1 + qv.fmab[1][kineVarChoice][bin][e] += 1.; // diffPhiWeightsForThisKineVar * kineVarWeight; // Remark: I can hardwire linear weight like this only for 2-p correlation + for (int h = 0; h < gMaxHarmonic; h++) { { if (es.fEtaSeparationsSkipHarmonics[h]) { continue; } - qv.fqabVector[1][bin - 1][h][e] += TComplex(diffPhiWeightsForThisKineVar * kineVarWeight * TMath::Cos((h + 1) * dPhi), diffPhiWeightsForThisKineVar * kineVarWeight * TMath::Sin((h + 1) * dPhi)); // Remark: I can hardwire linear weight like this only for 2-p correlation + qv.fqabVector[1][kineVarChoice][bin][h][e] += std::complex(std::cos((h + 1) * dPhi), std::sin((h + 1) * dPhi)); // bare q_ab-vector without weights } - } // for (Int_t h = 0; h < gMaxHarmonic; h++) { - } // for (Int_t e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation + } // for (int h = 0; h < gMaxHarmonic; h++) { + } // for (int e = 0; e < gMaxNumberEtaSeparations; e++) { // eta separation } } - } // if(es.fCalculateEtaSeparations) { + } // if(es.fCalculateEtaSeparations) if (tc.fVerboseForEachParticle) { ExitFunction(__FUNCTION__); } -} // void Fillqvector(const Double_t& dPhi, const Double_t& kineVarValue, eqvectorKine kineVarChoice) +} // void FillqvectorNdim(const double& dPhi, double* kineVarValues, int Ndim, eqvectorKine kineVarChoice, const double& dEta = 0.) //============================================================ void CalculateEverything() { // Calculate everything for selected events and particles. - // Remark: Data members for Q-vectors, containers for nested loops, etc., must all be filled when this function is called. + // Remark: Data members for Q-vectors (both integrated and differential), containers for nested loops, etc., must all be filled when this function is called. if (tc.fVerbose) { StartFunction(__FUNCTION__); @@ -11968,21 +18496,52 @@ void CalculateEverything() this->CalculateTest0(); } - // *) Calculate kine Test0: TBI 20240110 name convention - // Remark: vs. pt, vs. eta, etc., are all calculated here - if (qv.fCalculateQvectors && t0.fCalculateTest0AsFunctionOf[AFO_PT]) { - this->CalculateKineTest0(AFO_PT); + // *) Calculate kine Test0: + + // **) 1D kine: + // ***) cases for which 1D vs. pt calculus is needed: + if (qv.fCalculateQvectors && qv.fCalculateqvectorsKine[PTq]) { // TBI 20250601 do I really need here qv.fCalculateQvectors + this->CalculateKineTest0Ndim(PTq, 1); + } + + // ***) cases for which 1D vs. eta calculus is needed: + if (qv.fCalculateQvectors && qv.fCalculateqvectorsKine[ETAq]) { // TBI 20250601 do I really need here qv.fCalculateQvectors + this->CalculateKineTest0Ndim(ETAq, 1); + } + // ***) cases for which 1D vs. charge calculus is needed: + if (qv.fCalculateQvectors && qv.fCalculateqvectorsKine[CHARGEq]) { // TBI 20250601 do I really need here qv.fCalculateQvectors + this->CalculateKineTest0Ndim(CHARGEq, 1); + } + // ... + + // **) 2D kine: + // ***) cases for which 2D vs. (pt,eta) calculus is needed: + if (qv.fCalculateQvectors && qv.fCalculateqvectorsKine[PT_ETAq]) { // TBI 20250601 do I really need here qv.fCalculateQvectors + this->CalculateKineTest0Ndim(PT_ETAq, 2); + } + // ***) cases for which 2D vs. (pt,charge) calculus is needed: + if (qv.fCalculateQvectors && qv.fCalculateqvectorsKine[PT_CHARGEq]) { // TBI 20250601 do I really need here qv.fCalculateQvectors + this->CalculateKineTest0Ndim(PT_CHARGEq, 2); + } + // ***) cases for which 2D vs. (eta,charge) calculus is needed: + if (qv.fCalculateQvectors && qv.fCalculateqvectorsKine[ETA_CHARGEq]) { // TBI 20250601 do I really need here qv.fCalculateQvectors + this->CalculateKineTest0Ndim(ETA_CHARGEq, 2); } - if (qv.fCalculateQvectors && t0.fCalculateTest0AsFunctionOf[AFO_ETA]) { - this->CalculateKineTest0(AFO_ETA); + // ... + + // **) 3D kine: + // ***) cases for which 3D vs. (pt,eta,charge) calculus is needed: + if (qv.fCalculateQvectors && qv.fCalculateqvectorsKine[PT_ETA_CHARGEq]) { // TBI 20250601 do I really need here qv.fCalculateQvectors + this->CalculateKineTest0Ndim(PT_ETA_CHARGEq, 3); } + // ... // *) Calculate nested loops: if (nl.fCalculateNestedLoops) { this->CalculateNestedLoops(); if (mupa.fCalculateCorrelations) { // I do not have option here for Test0, because in Test0 I cross-check either e-by-e with CustomNestedLoops or - // for all events with IV + fRescaleWithTheoreticalInput = kTRUE + // for all events with IV + fRescaleWithTheoreticalInput = true this->ComparisonNestedLoopsVsCorrelations(); // I call it here, so comparison is performed cumulatively after each event. The final printout corresponds to all events. } } @@ -11991,7 +18550,10 @@ void CalculateEverything() if (es.fCalculateEtaSeparations) { this->CalculateEtaSeparations(); if (es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT]) { - this->CalculateKineEtaSeparations(AFO_PT); // The implementation of CalculateKineEtaSeparations( ... ) is generic and can be used for any other "kine" variable, for which it makes sense + this->CalculateKineEtaSeparationsNdim(PTq, 1); + } + if (es.fCalculateEtaSeparationsAsFunctionOf[AFO_CHARGE]) { + this->CalculateKineEtaSeparationsNdim(CHARGEq, 1); } } @@ -12003,6 +18565,40 @@ void CalculateEverything() //============================================================ +void SkipThisRun() +{ + // Skip or not the current run from furher processing. + + // a) Insanity checks; + // b) Do the check. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + // a) Insanity checks: + if (tc.fRunNumber.EqualTo("")) { + LOGF(fatal, "\033[1;31m%s at line %d : tc.fRunNumber is empty. In case you are running something on-the-fly, empty the string fSkipTheseRuns .\033[0m", __FUNCTION__, __LINE__); + } + + // TBI 20250516 Shall I implement some insanity check on fSkipTheseRuns? I commented in configurable that the format is comma-separated list of runs, + // but I am nowhere really enforcing that... + + // b) Do the check: + if (tc.fSkipTheseRuns.Contains(tc.fRunNumber.Data())) { + // TBI 20250316 I think this check is safe enough. If not, tokenize fSkipTheseRuns with respect to "," etc. + tc.fSkipRun = true; + } else { + tc.fSkipRun = false; + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void SkipThisRun() + +//============================================================ + template void MainLoopOverParticles(T const& tracks) { @@ -12019,14 +18615,21 @@ void MainLoopOverParticles(T const& tracks) // Remark #3: // *) There is also processTest(...), to process data with minimum subscription to the tables. To use it, set field "processTest": "true" in json config + // Remark #4: + // *) There is also processQA(...), to process data with maximum subscription to the tables (use for Run 3 only). To use it, set field "processQA: "true" in json config + + // Remark #5: + // *) Switch ProcessHepMChi(...) amounts at the moment to calling one dedicated function + calling Steer for "RecSim", so no special care is needed here for that switch. + if (tc.fVerbose) { StartFunction(__FUNCTION__); } // *) Declare local kinematic variables: - Double_t dPhi = 0.; // azimuthal angle - Double_t dPt = 0.; // transverse momentum - Double_t dEta = 0.; // pseudorapidity + double dPhi = 0.; // azimuthal angle + double dPt = 0.; // transverse momentum + double dEta = 0.; // pseudorapidity + double dCharge = -44.; // particle charge. Yes, never initialize charge to 0. // *) If random access of tracks from collection is requested, use Fisher-Yates algorithm to generate random indices: if (tc.fUseFisherYates) { @@ -12067,7 +18670,6 @@ void MainLoopOverParticles(T const& tracks) if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D || qa.fFillQAParticleHistograms2D) { FillParticleHistograms(track, eBefore); } - // *) Particle cuts counters (use only during QA, as this is computationally heavy): if (pc.fUseParticleCutCounterAbsolute || pc.fUseParticleCutCounterSequential) { ParticleCutsCounters(track); @@ -12088,30 +18690,97 @@ void MainLoopOverParticles(T const& tracks) dPhi = track.phi(); dPt = track.pt(); dEta = track.eta(); + dCharge = track.sign(); // Remark: Keep in sync all calls and flags below with the ones in InternalValidation(). // *) Integrated Q-vectors: if (qv.fCalculateQvectors || es.fCalculateEtaSeparations) { - this->FillQvector(dPhi, dPt, dEta); // all 3 arguments are passed by reference + if (!(pw.fUseDiffPhiWeights[wPhiPhiAxis] || pw.fUseDiffPtWeights[wPtPtAxis] || pw.fUseDiffPtWeights[wEtaEtaAxis])) { + // legacy integrated weights: + this->FillQvector(dPhi, dPt, dEta); // all 3 arguments are passed by reference + } else { + // this is now the new approach, with sparse histograms: + this->FillQvectorFromSparse(dPhi, dPt, dEta, dCharge); // particle arguments are passed by reference. + // Event observables (centrality, vertex z, ...), I do not need to pass as arguments, + // as I have data members for them (ebye.fCentrality, ebye.Vz, ...) + } } - // *) Differential q-vectors: - // **) pt-dependence: + // *) Differential q-vectors (keep in sync with the code in InternalValidation()): + + // ** 1D: + // ***) pt dependence: if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] || t0.fCalculateTest0AsFunctionOf[AFO_PT]) && !es.fCalculateEtaSeparations) { - // In this branch I do not need eta separation, so the ligher call can be executed: - this->Fillqvector(dPhi, dPt, PTq); // first 2 arguments are passed by reference, 3rd argument is enum + // In this branch I do not need eta separation, so the lighter call can be executed: + double kineArr[1] = {dPt}; + this->FillqvectorNdim(dPhi, kineArr, 1, PTq); } else if (es.fCalculateEtaSeparations && es.fCalculateEtaSeparationsAsFunctionOf[AFO_PT]) { // In this branch I do need eta separation, so the heavier call must be executed: - // Remark: Within Fillqvector() I check again all the relevant flags. - this->Fillqvector(dPhi, dPt, PTq, dEta); // first 2 arguments and the last one are passed by reference, 3rd argument is enum. "kine" variable is the 2nd argument + double kineArr[1] = {dPt}; + this->FillqvectorNdim(dPhi, kineArr, 1, PTq, dEta); } - // **) eta-dependence: + + // ***) eta dependence: if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] || t0.fCalculateTest0AsFunctionOf[AFO_ETA])) { // Remark: For eta dependence I do not consider es.fCalculateEtaSeparations, because in this context that calculation is meaningless. - this->Fillqvector(dPhi, dEta, ETAq); // first 2 arguments are passed by reference, 3rd argument is enum + double kineArr[1] = {dEta}; + this->FillqvectorNdim(dPhi, kineArr, 1, ETAq); + } + + // ***) charge dependence: + if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_CHARGE] || t0.fCalculateTest0AsFunctionOf[AFO_CHARGE]) && !es.fCalculateEtaSeparations) { + // In this branch I do not need eta separation, so the lighter call can be executed: + double kineArr[1] = {dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 1, CHARGEq); + } else if (es.fCalculateEtaSeparations && es.fCalculateEtaSeparationsAsFunctionOf[AFO_CHARGE]) { + // In this branch I do need eta separation, so the heavier call must be executed: + double kineArr[1] = {dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 1, CHARGEq, dEta); + } + + // ... + + // ** 2D: + // ***) pt-eta dependence: + if (qv.fCalculateQvectors && (t0.fCalculate2DTest0AsFunctionOf[AFO_PT_ETA] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_ETA])) { + // Remark: For eta dependence I do not consider es.fCalculateEtaSeparations, because in this context that calculation is meaningless. + double kineArr[2] = {dPt, dEta}; + this->FillqvectorNdim(dPhi, kineArr, 2, PT_ETAq); + } + + // ***) pt-charge dependence: + if (qv.fCalculateQvectors && (t0.fCalculate2DTest0AsFunctionOf[AFO_PT_CHARGE] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_PT_CHARGE]) && !es.fCalculateEtaSeparations) { + // In this branch I do not need eta separation, so the lighter call can be executed: + double kineArr[2] = {dPt, dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 2, PT_CHARGEq); + } else if (es.fCalculateEtaSeparations) { // && TBI 20250527 finalize by checking if 2D pt_charge with eta separations was requested + // In this branch I do need eta separation, so the heavier call must be executed: + // double kineArr[2] = {dPt, dCharge}; + // this->FillqvectorNdim(dPhi, kineArr, 2, PT_CHARGEq, dEta); // TBI 20250620 enable when I finalize else if above + + if (tc.fVerboseForEachParticle) { // TBI 20250627 temporary here I use this switch, otherwise logs in HL are too heavy + LOGF(info, "\033[1;33m%s at line %d: !!!! WARNING !!!! This branch is not finalized yet, i need to implement 2D objects also for eta separations, but it's unlikely I will ever need that in pracice. If I ever add it, just finalize the if statement above, and comment in two lines above !!!! WARNING !!!! \033[0m", __FUNCTION__, __LINE__); + } + } + + // ***) eta-charge dependence: + if (qv.fCalculateQvectors && (t0.fCalculate2DTest0AsFunctionOf[AFO_ETA_CHARGE] || t0.fCalculate3DTest0AsFunctionOf[AFO_CENTRALITY_ETA_CHARGE])) { + // Remark: For eta dependence I do not consider es.fCalculateEtaSeparations, because in this context that calculation is meaningless. + double kineArr[2] = {dEta, dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 2, ETA_CHARGEq); + } + + // ... + + // ** 3D: + // ***) pt-eta-charge dependence: + if (qv.fCalculateQvectors && (t0.fCalculate3DTest0AsFunctionOf[AFO_PT_ETA_CHARGE])) { + // Remark: For eta dependence I do not consider es.fCalculateEtaSeparations, because in this context that calculation is meaningless. + double kineArr[3] = {dPt, dEta, dCharge}; + this->FillqvectorNdim(dPhi, kineArr, 3, PT_ETA_CHARGEq); } - // *) Fill nested loops containers: + // *) Fill nested loops containers (integrated => I fill kine containers for nested loops in FillqvectorNdim(...)): if (nl.fCalculateNestedLoops || nl.fCalculateCustomNestedLoops) { this->FillNestedLoopsContainers(ebye.fSelectedTracks, dPhi, dPt, dEta); // all 4 arguments are passed by reference } @@ -12122,7 +18791,7 @@ void MainLoopOverParticles(T const& tracks) break; } - // *) Break the loop if fixed number of particles is taken randomly from each event (use always in combination with tc.fUseFisherYates = kTRUE): + // *) Break the loop if fixed number of particles is taken randomly from each event (use always in combination with tc.fUseFisherYates = true): if (tc.fFixedNumberOfRandomlySelectedTracks > 0 && tc.fFixedNumberOfRandomlySelectedTracks == ebye.fSelectedTracks) { LOGF(info, "%s : Breaking the loop over particles, since requested fixed number of %d particles was reached", __FUNCTION__, tc.fFixedNumberOfRandomlySelectedTracks); break; @@ -12159,6 +18828,8 @@ void Steer(T1 const& collision, T2 const& bcs, T3 const& tracks) StartFunction(__FUNCTION__); } + // memStatus: ~50K (without differential q-vectors and eta separations) + // *) Dry run: if (tc.fDryRun) { EventCounterForDryRun(eFill); @@ -12167,6 +18838,8 @@ void Steer(T1 const& collision, T2 const& bcs, T3 const& tracks) return; } + // memStatus: ~50K (without differential q-vectors and eta separations) + // *) Reset event-by-event quantities: TBI 20240430 I do not need this call also here really, but it doesn't hurt either... ResetEventByEventQuantities(); @@ -12185,20 +18858,39 @@ void Steer(T1 const& collision, T2 const& bcs, T3 const& tracks) // *) Do all thingies before starting to process data from this collision (e.g. cut on number of events (both total and selected), fetch the run number, etc.): Preprocess(collision, bcs); + // *) It was explicitly requested, skip this particular run: + if (tc.fSkipRun) { + LOGF(info, "\033[1;33mPer exlicit request via configurable cfSkipTheseRuns, skipping run %s from further processing.\033[0m", tc.fRunNumber.Data()); + return; + } + // *) Determine collision reference multiplicity: DetermineReferenceMultiplicity(collision); // *) Determine collision centrality: + // Remark: I determine also IP here. DetermineCentrality(collision); // *) Determine collision occupancy: DetermineOccupancy(collision); - // *) Determine collision interaction rate: - DetermineInteractionRate(collision, bcs); + // *) Determine collision interaction rate and current run duration: + DetermineInteractionRateAndCurrentRunDuration(collision, bcs); // TBI 20250414 temporary commented out, because of memory blow-up + + // *) Determine vertex z position: + DetermineVertexZ(collision); + + // memStatus: ~50K (without differential q-vectors and eta separations) + + // *) Determine additional QA thingies: + if (qa.fFillQAEventHistograms2D || qa.fFillQAParticleHistograms2D || qa.fFillQAParticleEventHistograms2D || qa.fFillQACorrelationsVsHistograms2D || qa.fFillQACorrelationsVsInteractionRateVsProfiles2D) { + // Remark: I implement ideally here only the getters for which the subscription to additional non-standard tables was needed for QA purposes. + DetermineQAThingies(collision, bcs); + } // *) Fill event histograms before event cuts: - if (eh.fFillEventHistograms || qa.fFillQAEventHistograms2D) { + if (eh.fFillEventHistograms || qa.fFillQAEventHistograms2D || qa.fFillQAParticleEventHistograms2D) { + // Remark: I do not above the flag fFillQACorrelationsVsHistograms2D, because as a part of QA I calculate <2> only after cuts in any case FillEventHistograms(collision, tracks, eBefore); } @@ -12217,8 +18909,12 @@ void Steer(T1 const& collision, T2 const& bcs, T3 const& tracks) return; } + // memStatus: ~50K (without differential q-vectors and eta separations) + // *) Main loop over particles: - MainLoopOverParticles(tracks); + MainLoopOverParticles(tracks); // memStatus: so here I invest ~20K, as of 20250530 + + // memStatus: ~70K (without differential q-vectors and eta separations) // *) Determine multiplicity of this event, for all "vs. mult" results: DetermineMultiplicity(); @@ -12232,7 +18928,7 @@ void Steer(T1 const& collision, T2 const& bcs, T3 const& tracks) } // *) Fill event histograms after event AND particle cuts: - if (eh.fFillEventHistograms || qa.fFillQAEventHistograms2D) { + if (eh.fFillEventHistograms || qa.fFillQAEventHistograms2D || qa.fFillQAParticleEventHistograms2D || qa.fFillQACorrelationsVsHistograms2D) { FillEventHistograms(collision, tracks, eAfter); } @@ -12245,6 +18941,8 @@ void Steer(T1 const& collision, T2 const& bcs, T3 const& tracks) // *) Calculate everything for selected events and particles: CalculateEverything(); + // memStatus: ~72K (without differential q-vectors and eta separations) + // *) Reset event-by-event quantities: ResetEventByEventQuantities(); @@ -12273,6 +18971,16 @@ void Steer(T1 const& collision, T2 const& bcs, T3 const& tracks) ExitFunction(__FUNCTION__); } + // memStatus (summary): Last update: 20250602 + // Remark: disable sequential bailout before doing this test (yes!) + all of UseSetBinLabel, ... UseDatabasetPDG + // ~46K (skeleton - literally) + // ~50K (dry run with 1D objects booked) + // ~70K (all object declaration besides kine objects (diff. q-vectors and eta separations) + all calculus and 1D histograms filled, trivial labels) + // ~70K (all object declaration + 1D kine objects (diff. q-vectors in coarse kine bins) + all calculus and 1D histograms filled, standard labels) + // ~80K (all object declaration + 1D + 2D kine objects (diff. q-vectors in fine kine bins) + all calculus and 1D histograms filled, standard labels) + // ~110K (all object declaration + 1D + 2D + 3D kine objects (diff. q-vectors in fine kine bins) + all calculus and 1D histograms filled, standard labels) + // ~125K (all object declaration + 1D + 2D + 3D kine objects (diff. q-vectors in fine kine bins) + all calculus and 1D histograms filled, Set_0 labels) + } // template void Steer(T1 const* collision, T2 const* tracks) #endif // PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_MEMBERFUNCTIONS_H_ diff --git a/PWGCF/MultiparticleCorrelations/Tasks/CMakeLists.txt b/PWGCF/MultiparticleCorrelations/Tasks/CMakeLists.txt index bc0ad886d5c..05bb4edb850 100644 --- a/PWGCF/MultiparticleCorrelations/Tasks/CMakeLists.txt +++ b/PWGCF/MultiparticleCorrelations/Tasks/CMakeLists.txt @@ -19,7 +19,7 @@ o2physics_add_dpl_workflow(multiparticle-correlations-ar PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(threeparticle-correlations - SOURCES ThreeParticleCorrelations.cxx +o2physics_add_dpl_workflow(three-particle-correlations + SOURCES threeParticleCorrelations.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) diff --git a/PWGCF/MultiparticleCorrelations/Tasks/ThreeParticleCorrelations.cxx b/PWGCF/MultiparticleCorrelations/Tasks/ThreeParticleCorrelations.cxx deleted file mode 100644 index 1203d90e47a..00000000000 --- a/PWGCF/MultiparticleCorrelations/Tasks/ThreeParticleCorrelations.cxx +++ /dev/null @@ -1,664 +0,0 @@ -// 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. - -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "CCDB/BasicCCDBManager.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" - -#include "TPDGCode.h" -#include "RecoDecay.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct ThreePartCorr { - Service CCDB; - - // Histogram registry - HistogramRegistry MECorrRegistry{"MECorrRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; - HistogramRegistry SECorrRegistry{"SECorrRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; - HistogramRegistry MCRegistry{"MCRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; - HistogramRegistry QARegistry{"QARegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; - - // Collision & Event filters - Filter CollCent = aod::cent::centFT0C > 0.0f && aod::cent::centFT0C < 90.0f; - Filter CollZvtx = nabs(aod::collision::posZ) < 7.0f; - Filter MCCollZvtx = nabs(aod::mccollision::posZ) < 7.0f; - Filter EvSelect = aod::evsel::sel8 == true; - - // V0 filters - Filter V0Pt = aod::v0data::pt > 0.6f && aod::v0data::pt < 12.0f; - Filter V0Eta = nabs(aod::v0data::eta) < 0.72f; - - // Track filters - Filter TrackPt = aod::track::pt > 0.2f && aod::track::pt < 3.0f; - Filter TrackEta = nabs(aod::track::eta) < 0.8f; - Filter GlobalTracks = requireGlobalTrackInFilter(); - - // Particle filters - Filter ParticlePt = aod::mcparticle::pt > 0.2f && aod::mcparticle::pt < 3.0f; - Filter ParticleEta = nabs(aod::mcparticle::eta) < 0.8f; - - // Table aliases - Data - using MyFilteredCollisions = soa::Filtered>; - using MyFilteredCollision = MyFilteredCollisions::iterator; - using MyFilteredV0s = soa::Filtered; - using MyFilteredTracks = soa::Filtered>; - - // Table aliases - MC - using MyFilteredMCGenCollision = soa::Filtered::iterator; - using MyFilteredMCParticles = soa::Filtered; - using MyFilteredMCRecCollision = soa::Filtered>::iterator; - using MyFilteredMCTracks = soa::Filtered>; - - // Mixed-events binning policy - SliceCache cache; - ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f}, "ME Centrality binning"}; - ConfigurableAxis ConfZvtxBins{"ConfZvtxBins", {VARIABLE_WIDTH, -7.0f, -5.0f, -3.0f, -1.0f, 0.0f, 1.0f, 3.0f, 5.0f, 7.0f}, "ME Zvtx binning"}; - using BinningType = ColumnBinningPolicy; - - BinningType CollBinning{{ConfCentBins, ConfZvtxBins}, true}; - Pair pair{CollBinning, 5, -1, &cache}; - - // Process configurables - Configurable ConfFilterSwitch{"ConfFilterSwitch", false, "Switch for the FakeV0Filter function"}; - - // Particle masses - Double_t massLambda = o2::constants::physics::MassLambda0; - Double_t DGaussSigma = 0.0021; - - // Efficiency histograms - TH1D** hEffPions = new TH1D*[2]; - TH1D** hEffKaons = new TH1D*[2]; - TH1D** hEffProtons = new TH1D*[2]; - - // Correlation variables - Int_t T_Sign; - Double_t CandMass; - Double_t* A_PID; - - Double_t DeltaPhi, DeltaEta; - - //================================================================================================================================================================================================================ - - void init(InitContext const&) - { - - // Histograms axes - const AxisSpec CentralityAxis{ConfCentBins}; - const AxisSpec ZvtxAxis{ConfZvtxBins}; - const AxisSpec PhiAxis{36, (-1. / 2) * M_PI, (3. / 2) * M_PI}; - const AxisSpec EtaAxis{32, -1.52, 1.52}; - const AxisSpec V0PtAxis{114, 0.6, 12}; - const AxisSpec TrackPtAxis{28, 0.2, 3}; - const AxisSpec LambdaInvMassAxis{100, 1.08, 1.16}; - - // QA & PID - QARegistry.add("hTrackPt", "hTrackPt", {HistType::kTH1D, {{100, 0, 4}}}); - QARegistry.add("hTrackEta", "hTrackEta", {HistType::kTH1D, {{100, -1, 1}}}); - QARegistry.add("hTrackPhi", "hTrackPhi", {HistType::kTH1D, {{100, (-1. / 2) * M_PI, (5. / 2) * M_PI}}}); - QARegistry.add("hEventCentrality", "hEventCentrality", {HistType::kTH1D, {{CentralityAxis}}}); - QARegistry.add("hEventZvtx", "hEventZvtx", {HistType::kTH1D, {{ZvtxAxis}}}); - - QARegistry.add("hdEdx", "hdEdx", {HistType::kTH2D, {{56, 0.2, 3.0}, {180, 20, 200}}}); - QARegistry.add("hdEdxPion", "hdEdxPion", {HistType::kTH2D, {{56, 0.2, 3.0}, {180, 20, 200}}}); - QARegistry.add("hdEdxKaon", "hdEdxKaon", {HistType::kTH2D, {{56, 0.2, 3.0}, {180, 20, 200}}}); - QARegistry.add("hdEdxProton", "hdEdxProton", {HistType::kTH2D, {{56, 0.2, 3.0}, {180, 20, 200}}}); - QARegistry.add("hBeta", "hBeta", {HistType::kTH2D, {{56, 0.2, 3.0}, {70, 0.4, 1.1}}}); - QARegistry.add("hBetaPion", "hBetaPion", {HistType::kTH2D, {{56, 0.2, 3.0}, {70, 0.4, 1.1}}}); - QARegistry.add("hBetaKaon", "hBetaKaon", {HistType::kTH2D, {{56, 0.2, 3.0}, {70, 0.4, 1.1}}}); - QARegistry.add("hBetaProton", "hBetaProton", {HistType::kTH2D, {{56, 0.2, 3.0}, {70, 0.4, 1.1}}}); - QARegistry.add("hNSigmaPion", "hNSigmaPion", {HistType::kTH2D, {{201, -5.025, 5.025}, {201, -5.025, 5.025}}}); - QARegistry.add("hNSigmaKaon", "hNSigmaKaon", {HistType::kTH2D, {{201, -5.025, 5.025}, {201, -5.025, 5.025}}}); - QARegistry.add("hNSigmaProton", "hNSigmaProton", {HistType::kTH2D, {{201, -5.025, 5.025}, {201, -5.025, 5.025}}}); - - QARegistry.add("hTOFPion", "hTOFPion", {HistType::kTH2D, {{TrackPtAxis}, {1000, -50, 50}}}); - QARegistry.add("hTOFKaon", "hTOFKaon", {HistType::kTH2D, {{TrackPtAxis}, {1000, -50, 50}}}); - QARegistry.add("hTOFProton", "hTOFProton", {HistType::kTH2D, {{TrackPtAxis}, {1000, -50, 50}}}); - - QARegistry.add("hInvMassLambda", "hInvMassLambda", {HistType::kTH3D, {{LambdaInvMassAxis}, {V0PtAxis}, {CentralityAxis}}}); - QARegistry.add("hInvMassAntiLambda", "hInvMassAntiLambda", {HistType::kTH3D, {{LambdaInvMassAxis}, {V0PtAxis}, {CentralityAxis}}}); - - // Efficiency - MCRegistry.add("hGenerated", "hGenerated", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hGenPionP", "hGenPionP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hGenPionN", "hGenPionN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hGenKaonP", "hGenKaonP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hGenKaonN", "hGenKaonN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hGenProtonP", "hGenProtonP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hGenProtonN", "hGenProtonN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hReconstructed", "hReconstructed", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hRecPionP", "hRecPionP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hRecPionN", "hRecPionN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hRecKaonP", "hRecKaonP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hRecKaonN", "hRecKaonN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hRecProtonP", "hRecProtonP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hRecProtonN", "hRecProtonN", {HistType::kTH1D, {TrackPtAxis}}); - - // Purity - MCRegistry.add("hSelectPionP", "hSelectPionP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hSelectPionN", "hSelectPionN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hSelectKaonP", "hSelectKaonP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hSelectKaonN", "hSelectKaonN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hSelectProtonP", "hSelectProtonP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hSelectProtonN", "hSelectProtonN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hTrueSelectPionP", "hTrueSelectPionP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hTrueSelectPionN", "hTrueSelectPionN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hTrueSelectKaonP", "hTrueSelectKaonP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hTrueSelectKaonN", "hTrueSelectKaonN", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hTrueSelectProtonP", "hTrueSelectProtonP", {HistType::kTH1D, {TrackPtAxis}}); - MCRegistry.add("hTrueSelectProtonN", "hTrueSelectProtonN", {HistType::kTH1D, {TrackPtAxis}}); - - // Correlations - SECorrRegistry.add("hSameLambdaPion_SGNL", "Same-event #Lambda - #pi correlator (SGNL region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - SECorrRegistry.add("hSameLambdaPion_SB", "Same-event #Lambda - #pi correlator (SB region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - SECorrRegistry.add("hSameLambdaKaon_SGNL", "Same-event #Lambda - K correlator (SGNL region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - SECorrRegistry.add("hSameLambdaKaon_SB", "Same-event #Lambda - K correlator (SB region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - SECorrRegistry.add("hSameLambdaProton_SGNL", "Same-event #Lambda - p correlator (SGNL region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - SECorrRegistry.add("hSameLambdaProton_SB", "Same-event #Lambda - p correlator (SB region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - - MECorrRegistry.add("hMixLambdaPion_SGNL", "Mixed-event #Lambda - #pi correlator (SGNL region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - MECorrRegistry.add("hMixLambdaPion_SB", "Mixed-event #Lambda - #pi correlator (SB region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - MECorrRegistry.add("hMixLambdaKaon_SGNL", "Mixed-event #Lambda - K correlator (SGNL region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - MECorrRegistry.add("hMixLambdaKaon_SB", "Mixed-event #Lambda - K correlator (SB region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - MECorrRegistry.add("hMixLambdaProton_SGNL", "Mixed-event #Lambda - p correlator (SGNL region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - MECorrRegistry.add("hMixLambdaProton_SB", "Mixed-event #Lambda - p correlator (SB region)", {HistType::kTHnSparseD, {{PhiAxis}, {EtaAxis}, {CentralityAxis}, {ZvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); - - CCDB->setURL("http://alice-ccdb.cern.ch"); - CCDB->setCaching(true); - TList* EfficiencyList = CCDB->getForTimeStamp("Users/j/jstaa/Efficiency/ChargedParticles", 1); - hEffPions[0] = static_cast(EfficiencyList->FindObject("hEfficiencyPionP")); - hEffPions[1] = static_cast(EfficiencyList->FindObject("hEfficiencyPionN")); - hEffKaons[0] = static_cast(EfficiencyList->FindObject("hEfficiencyKaonP")); - hEffKaons[1] = static_cast(EfficiencyList->FindObject("hEfficiencyKaonN")); - hEffProtons[0] = static_cast(EfficiencyList->FindObject("hEfficiencyProtonP")); - hEffProtons[1] = static_cast(EfficiencyList->FindObject("hEfficiencyProtonN")); - } - - //================================================================================================================================================================================================================ - - void processSame(MyFilteredCollision const& collision, MyFilteredV0s const& v0s, MyFilteredTracks const& tracks) - { - - QARegistry.fill(HIST("hEventCentrality"), collision.centFT0C()); - QARegistry.fill(HIST("hEventZvtx"), collision.posZ()); - - // Start of the Track QA - for (const auto& track : tracks) { - if (track.hasTOF()) { - QARegistry.fill(HIST("hTOFPion"), track.pt(), track.tofNSigmaPi()); - QARegistry.fill(HIST("hTOFKaon"), track.pt(), track.tofNSigmaKa()); - QARegistry.fill(HIST("hTOFProton"), track.pt(), track.tofNSigmaPr()); - } - - if (TrackFilters(track)) { - A_PID = TrackPID(track); - QARegistry.fill(HIST("hTrackPt"), track.pt()); - QARegistry.fill(HIST("hTrackEta"), track.eta()); - QARegistry.fill(HIST("hTrackPhi"), track.phi()); - QARegistry.fill(HIST("hdEdx"), track.pt(), track.tpcSignal()); - QARegistry.fill(HIST("hBeta"), track.pt(), track.beta()); - if (A_PID[0] == 0.0) { // Pions - QARegistry.fill(HIST("hdEdxPion"), track.pt(), track.tpcSignal()); - QARegistry.fill(HIST("hBetaPion"), track.pt(), track.beta()); - QARegistry.fill(HIST("hNSigmaPion"), track.tpcNSigmaPi(), track.tofNSigmaPi()); - } else if (A_PID[0] == 1.0) { // Kaons - QARegistry.fill(HIST("hdEdxKaon"), track.pt(), track.tpcSignal()); - QARegistry.fill(HIST("hBetaKaon"), track.pt(), track.beta()); - QARegistry.fill(HIST("hNSigmaKaon"), track.tpcNSigmaKa(), track.tofNSigmaKa()); - } else if (A_PID[0] == 2.0) { // Protons - QARegistry.fill(HIST("hdEdxProton"), track.pt(), track.tpcSignal()); - QARegistry.fill(HIST("hBetaProton"), track.pt(), track.beta()); - QARegistry.fill(HIST("hNSigmaProton"), track.tpcNSigmaPr(), track.tofNSigmaPr()); - } - } - } - // End of the Track QA - - // Start of the V0-Track Correlations - for (const auto& trigger : v0s) { - if (V0Filters(trigger)) { - - T_Sign = V0Sign(trigger); - if (T_Sign == 1) { - CandMass = trigger.mLambda(); - QARegistry.fill(HIST("hInvMassLambda"), trigger.mLambda(), trigger.pt(), collision.centFT0C()); - } else if (T_Sign == -1) { - CandMass = trigger.mAntiLambda(); - QARegistry.fill(HIST("hInvMassAntiLambda"), trigger.mAntiLambda(), trigger.pt(), collision.centFT0C()); - } - - for (const auto& associate : tracks) { - if (TrackFilters(associate)) { - if (CorrelationFilters(trigger, associate) && FakeV0Filter(trigger, associate)) { - - A_PID = TrackPID(associate); - DeltaPhi = DeltaPhiShift(trigger.phi(), associate.phi()); - DeltaEta = trigger.eta() - associate.eta(); - - if (CandMass >= massLambda - 4 * DGaussSigma && CandMass <= massLambda + 4 * DGaussSigma) { - if (A_PID[0] == 0.0) { // Pions - SECorrRegistry.fill(HIST("hSameLambdaPion_SGNL"), DeltaPhi, DeltaEta, collision.centFT0C(), collision.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffPions, associate.sign(), associate.pt())); - } else if (A_PID[0] == 1.0) { // Kaons - SECorrRegistry.fill(HIST("hSameLambdaKaon_SGNL"), DeltaPhi, DeltaEta, collision.centFT0C(), collision.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffKaons, associate.sign(), associate.pt())); - } else if (A_PID[0] == 2.0) { // Protons - SECorrRegistry.fill(HIST("hSameLambdaProton_SGNL"), DeltaPhi, DeltaEta, collision.centFT0C(), collision.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffProtons, associate.sign(), associate.pt())); - } - } else if (CandMass >= massLambda - 8 * DGaussSigma && CandMass <= massLambda + 8 * DGaussSigma) { - if (A_PID[0] == 0.0) { // Pions - SECorrRegistry.fill(HIST("hSameLambdaPion_SB"), DeltaPhi, DeltaEta, collision.centFT0C(), collision.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffPions, associate.sign(), associate.pt())); - } else if (A_PID[0] == 1.0) { // Kaons - SECorrRegistry.fill(HIST("hSameLambdaKaon_SB"), DeltaPhi, DeltaEta, collision.centFT0C(), collision.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffKaons, associate.sign(), associate.pt())); - } else if (A_PID[0] == 2.0) { // Protons - SECorrRegistry.fill(HIST("hSameLambdaProton_SB"), DeltaPhi, DeltaEta, collision.centFT0C(), collision.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffProtons, associate.sign(), associate.pt())); - } - } - } - } - } - } - } - // End of the V0-Track Correlations - } - - void processMixed(MyFilteredCollisions const&, MyFilteredV0s const&, MyFilteredTracks const&) - { - - // Start of the Mixed-events Correlations - for (const auto& [coll_1, v0_1, coll_2, track_2] : pair) { - for (const auto& [trigger, associate] : soa::combinations(soa::CombinationsFullIndexPolicy(v0_1, track_2))) { - if (V0Filters(trigger) && TrackFilters(associate)) { - if (CorrelationFilters(trigger, associate) && FakeV0Filter(trigger, associate)) { - - T_Sign = V0Sign(trigger); - if (T_Sign == 1) { - CandMass = trigger.mLambda(); - } else if (T_Sign == -1) { - CandMass = trigger.mAntiLambda(); - } - - A_PID = TrackPID(associate); - DeltaPhi = DeltaPhiShift(trigger.phi(), associate.phi()); - DeltaEta = trigger.eta() - associate.eta(); - - if (CandMass >= massLambda - 4 * DGaussSigma && CandMass <= massLambda + 4 * DGaussSigma) { - if (A_PID[0] == 0.0) { // Pions - MECorrRegistry.fill(HIST("hMixLambdaPion_SGNL"), DeltaPhi, DeltaEta, coll_1.centFT0C(), coll_1.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffPions, associate.sign(), associate.pt())); - } else if (A_PID[0] == 1.0) { // Kaons - MECorrRegistry.fill(HIST("hMixLambdaKaon_SGNL"), DeltaPhi, DeltaEta, coll_1.centFT0C(), coll_1.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffKaons, associate.sign(), associate.pt())); - } else if (A_PID[0] == 2.0) { // Protons - MECorrRegistry.fill(HIST("hMixLambdaProton_SGNL"), DeltaPhi, DeltaEta, coll_1.centFT0C(), coll_1.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffProtons, associate.sign(), associate.pt())); - } - } else if (CandMass >= massLambda - 8 * DGaussSigma && CandMass <= massLambda + 8 * DGaussSigma) { - if (A_PID[0] == 0.0) { // Pions - MECorrRegistry.fill(HIST("hMixLambdaPion_SB"), DeltaPhi, DeltaEta, coll_1.centFT0C(), coll_1.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffPions, associate.sign(), associate.pt())); - } else if (A_PID[0] == 1.0) { // Kaons - MECorrRegistry.fill(HIST("hMixLambdaKaon_SB"), DeltaPhi, DeltaEta, coll_1.centFT0C(), coll_1.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffKaons, associate.sign(), associate.pt())); - } else if (A_PID[0] == 2.0) { // Protons - MECorrRegistry.fill(HIST("hMixLambdaProton_SB"), DeltaPhi, DeltaEta, coll_1.centFT0C(), coll_1.posZ(), T_Sign, associate.sign(), 1. / TrackEff(hEffProtons, associate.sign(), associate.pt())); - } - } - } - } - } - } - // End of the Mixed-events Correlations - } - - void processMCGen(MyFilteredMCGenCollision const&, MyFilteredMCParticles const& particles) - { - - // Start of the Monte-Carlo generated QA - for (const auto& particle : particles) { - if (particle.isPhysicalPrimary()) { - - // Efficiency - Generated - MCRegistry.fill(HIST("hGenerated"), particle.pt()); - if (particle.pdgCode() == kPiPlus) { // Pos pions - MCRegistry.fill(HIST("hGenPionP"), particle.pt()); - } else if (particle.pdgCode() == kPiMinus) { // Neg pions - MCRegistry.fill(HIST("hGenPionN"), particle.pt()); - } else if (particle.pdgCode() == kKPlus) { // Pos kaons - MCRegistry.fill(HIST("hGenKaonP"), particle.pt()); - } else if (particle.pdgCode() == kKMinus) { // Neg kaons - MCRegistry.fill(HIST("hGenKaonN"), particle.pt()); - } else if (particle.pdgCode() == kProton) { // Pos protons - MCRegistry.fill(HIST("hGenProtonP"), particle.pt()); - } else if (particle.pdgCode() == kProtonBar) { // Neg protons - MCRegistry.fill(HIST("hGenProtonN"), particle.pt()); - } - } - } - // End of the Monte-Carlo generated QA - } - - void processMCRec(MyFilteredMCRecCollision const& collision, MyFilteredMCTracks const& tracks, aod::McCollisions const&, aod::McParticles const&) - { - - if (!collision.has_mcCollision()) { - return; - } - - // Start of the Monte-Carlo reconstructed QA - for (const auto& track : tracks) { - if (!track.has_mcParticle()) { - continue; - } - - if (TrackFilters(track)) { - auto particle = track.mcParticle(); - if (particle.isPhysicalPrimary()) { - - // Efficiency - Reconstructed - MCRegistry.fill(HIST("hReconstructed"), track.pt()); - if (particle.pdgCode() == kPiPlus) { // Pos pions - MCRegistry.fill(HIST("hRecPionP"), track.pt()); - } else if (particle.pdgCode() == kPiMinus) { // Neg pions - MCRegistry.fill(HIST("hRecPionN"), track.pt()); - } else if (particle.pdgCode() == kKPlus) { // Pos kaons - MCRegistry.fill(HIST("hRecKaonP"), track.pt()); - } else if (particle.pdgCode() == kKMinus) { // Neg kaons - MCRegistry.fill(HIST("hRecKaonN"), track.pt()); - } else if (particle.pdgCode() == kProton) { // Pos protons - MCRegistry.fill(HIST("hRecProtonP"), track.pt()); - } else if (particle.pdgCode() == kProtonBar) { // Neg protons - MCRegistry.fill(HIST("hRecProtonN"), track.pt()); - } - - // Purity (PID) - A_PID = TrackPID(track); - - if (track.sign() > 0) { // Positive tracks - if (A_PID[0] == 0.0) { // Pions - MCRegistry.fill(HIST("hSelectPionP"), track.pt()); - if (particle.pdgCode() == kPiPlus) { - MCRegistry.fill(HIST("hTrueSelectPionP"), track.pt()); - } - } else if (A_PID[0] == 1.0) { // Kaons - MCRegistry.fill(HIST("hSelectKaonP"), track.pt()); - if (particle.pdgCode() == kKPlus) { - MCRegistry.fill(HIST("hTrueSelectKaonP"), track.pt()); - } - } else if (A_PID[0] == 2.0) { // Protons - MCRegistry.fill(HIST("hSelectProtonP"), track.pt()); - if (particle.pdgCode() == kProton) { - MCRegistry.fill(HIST("hTrueSelectProtonP"), track.pt()); - } - } - } else if (track.sign() < 0) { // Negative tracks - if (A_PID[0] == 0.0) { // Pions - MCRegistry.fill(HIST("hSelectPionN"), track.pt()); - if (particle.pdgCode() == kPiMinus) { - MCRegistry.fill(HIST("hTrueSelectPionN"), track.pt()); - } - } else if (A_PID[0] == 1.0) { // Kaons - MCRegistry.fill(HIST("hSelectKaonN"), track.pt()); - if (particle.pdgCode() == kKMinus) { - MCRegistry.fill(HIST("hTrueSelectKaonN"), track.pt()); - } - } else if (A_PID[0] == 2.0) { // Protons - MCRegistry.fill(HIST("hSelectProtonN"), track.pt()); - if (particle.pdgCode() == kProtonBar) { - MCRegistry.fill(HIST("hTrueSelectProtonN"), track.pt()); - } - } - } - } - } - } - // End of the Monte-Carlo reconstructed QA - } - - PROCESS_SWITCH(ThreePartCorr, processSame, "Process same-event correlations", true); - PROCESS_SWITCH(ThreePartCorr, processMixed, "Process mixed-event correlations", true); - PROCESS_SWITCH(ThreePartCorr, processMCGen, "Process Monte-Carlo, generator level", false); - PROCESS_SWITCH(ThreePartCorr, processMCRec, "Process Monte-Carlo, reconstructed level", false); - - //================================================================================================================================================================================================================ - - Double_t DeltaPhiShift(Double_t TriggerPhi, Double_t AssociatePhi) - { - - Double_t dPhi = TriggerPhi - AssociatePhi; - - if (dPhi < (-1. / 2) * M_PI) { - dPhi = dPhi + 2 * M_PI; - } else if (dPhi > (3. / 2) * M_PI) { - dPhi = dPhi - 2 * M_PI; - } - - return dPhi; - } - - Double_t TrackEff(TH1D** Efficiencies, Int_t Sign, Double_t pT) - { - - Int_t Index = -999; - if (Sign > 0) { - Index = 0; - } else if (Sign < 0) { - Index = 1; - } - - return Efficiencies[Index]->GetBinContent(Efficiencies[Index]->FindBin(pT)); - } - - template - Int_t V0Sign(const V0Cand& V0) - { - - if (TMath::Abs(V0.mLambda() - massLambda) <= TMath::Abs(V0.mAntiLambda() - massLambda)) { - return 1; - } else if (TMath::Abs(V0.mLambda() - massLambda) > TMath::Abs(V0.mAntiLambda() - massLambda)) { - return -1; - } - - return 0; - } - - template - Double_t* TrackPID(const TrackCand& Track) - { - - static Double_t ID[2]; // {PID, NSigma} - - Double_t NSigma[3]; - Double_t NSigmaTOF[3]; - NSigmaTOF[0] = Track.tofNSigmaPi(); - NSigmaTOF[1] = Track.tofNSigmaKa(); - NSigmaTOF[2] = Track.tofNSigmaPr(); - - NSigma[0] = TMath::Abs(NSigmaTOF[0]); - NSigma[1] = TMath::Abs(NSigmaTOF[1]); - NSigma[2] = TMath::Abs(NSigmaTOF[2]); - - if (NSigma[0] <= std::min(NSigma[1], NSigma[2])) { // Pions - ID[0] = 0.0; - ID[1] = NSigmaTOF[0]; - } else if (NSigma[1] <= std::min(NSigma[0], NSigma[2])) { // Kaons - ID[0] = 1.0; - ID[1] = NSigmaTOF[1]; - } else if (NSigma[2] < std::min(NSigma[0], NSigma[1])) { // Protons - ID[0] = 2.0; - ID[1] = NSigmaTOF[2]; - } - - return ID; - } - - //================================================================================================================================================================================================================ - - template - Bool_t V0Filters(const V0Cand& V0) - { - - if (V0Sign(V0) == 1) { - const auto& posDaughter = V0.template posTrack_as(); - if (TMath::Abs(posDaughter.tpcNSigmaPr()) > 4.0) { - return kFALSE; - } - } else if (V0Sign(V0) == -1) { - const auto& negDaughter = V0.template negTrack_as(); - if (TMath::Abs(negDaughter.tpcNSigmaPr()) > 4.0) { - return kFALSE; - } - } - - return kTRUE; - } - - template - Bool_t TrackFilters(const TrackCand& Track) - { - - if (!Track.hasTOF()) { - return kFALSE; - } - - if (TrackPID(Track)[0] == 0.0) { // Pions - if (TMath::Abs(Track.tpcNSigmaPi()) > 4.0) { - return kFALSE; - } - if (Track.pt() < 0.3) { - return kFALSE; - } else if (Track.pt() > 0.3 && Track.pt() < 1.5) { - if (TMath::Abs(TrackPID(Track)[1]) > 4.0) { - return kFALSE; - } - } else if (Track.pt() > 1.5 && Track.pt() < 2.3) { - if (TrackPID(Track)[1] < -4.0 || TrackPID(Track)[1] > 0.0) { - return kFALSE; - } - } else if (Track.pt() > 2.3) { - return kFALSE; - } - - } else if (TrackPID(Track)[0] == 1.0) { // Kaons - if (TMath::Abs(Track.tpcNSigmaKa()) > 4.0) { - return kFALSE; - } - if (Track.pt() < 0.5) { - return kFALSE; - } else if (Track.pt() > 0.5 && Track.pt() < 1.5) { - if (TMath::Abs(TrackPID(Track)[1]) > 4.0) { - return kFALSE; - } - } else if (Track.pt() > 1.5 && Track.pt() < 2.0) { - if (TrackPID(Track)[1] < -2.0 || TrackPID(Track)[1] > 4.0) { - return kFALSE; - } - } else if (Track.pt() > 2.0 && Track.pt() < 2.5) { - if (TrackPID(Track)[1] < 0.0 || TrackPID(Track)[1] > 4.0) { - return kFALSE; - } - } else if (Track.pt() > 2.5) { - return kFALSE; - } - - } else if (TrackPID(Track)[0] == 2.0) { // Protons - if (TMath::Abs(Track.tpcNSigmaPr()) > 4.0) { - return kFALSE; - } - if (Track.pt() < 0.5) { - return kFALSE; - } else if (Track.pt() > 0.5 && Track.pt() < 0.7) { - if (TrackPID(Track)[1] < -2.0 || TrackPID(Track)[1] > 4.0) { - return kFALSE; - } - } else if (Track.pt() > 0.7 && Track.pt() < 2.5) { - if (TMath::Abs(TrackPID(Track)[1]) > 4.0) { - return kFALSE; - } - } else if (Track.pt() > 2.5) { - if (TrackPID(Track)[1] < -2.0 || TrackPID(Track)[1] > 4.0) { - return kFALSE; - } - } - } - - return kTRUE; - } - - template - Bool_t CorrelationFilters(const V0Cand& V0, const TrackCand& Track) - { - - if (Track.globalIndex() == V0.posTrackId() || Track.globalIndex() == V0.negTrackId()) { - return kFALSE; - } - - return kTRUE; - } - - template - Bool_t FakeV0Filter(const V0Cand& V0, const TrackCand& Track) - { - - if (ConfFilterSwitch) { - - if (TrackPID(Track)[0] == 1.0) { // Kaons - return kTRUE; - } - - std::array MassArray; - std::array DMomArray; - std::array AMomArray = Track.pVector(); - if (TrackPID(Track)[0] == 0.0) { - MassArray = {o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}; - - if (V0Sign(V0) == 1 && Track.sign() == -1) { // Lambda - Pi_min - const auto& dTrack = V0.template posTrack_as(); - DMomArray = dTrack.pVector(); - } else if (V0Sign(V0) == -1 && Track.sign() == 1) { // Antilambda - Pi_plus - const auto& dTrack = V0.template negTrack_as(); - DMomArray = dTrack.pVector(); - } - } else if (TrackPID(Track)[0] == 2.0) { - MassArray = {o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton}; - - if (V0Sign(V0) == 1 && Track.sign() == 1) { // Lambda - Proton - const auto& dTrack = V0.template negTrack_as(); - DMomArray = dTrack.pVector(); - } else if (V0Sign(V0) == -1 && Track.sign() == -1) { // Antilambda - Antiproton - const auto& dTrack = V0.template posTrack_as(); - DMomArray = dTrack.pVector(); - } - } - - Double_t M = RecoDecay::m(std::array{DMomArray, AMomArray}, MassArray); - if (M >= massLambda - 4 * DGaussSigma && M <= massLambda + 4 * DGaussSigma) { - return kFALSE; - } - } - - return kTRUE; - } -}; - -//================================================================================================================================================================================================================== - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; - return workflow; -} - -//================================================================================================================================================================================================================== diff --git a/PWGCF/MultiparticleCorrelations/Tasks/multiparticle-correlations-ab.cxx b/PWGCF/MultiparticleCorrelations/Tasks/multiparticle-correlations-ab.cxx index 13652b66836..3f7953f5f11 100644 --- a/PWGCF/MultiparticleCorrelations/Tasks/multiparticle-correlations-ab.cxx +++ b/PWGCF/MultiparticleCorrelations/Tasks/multiparticle-correlations-ab.cxx @@ -9,29 +9,37 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file multiparticle-correlations-ab.cxx +/// \brief ... TBI 20250425 +/// \author Ante.Bilandzic@cern.ch + // O2: -#include #include "Common/CCDB/ctpRateFetcher.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/DataTypes.h" -#include "Common/DataModel/TrackSelectionTables.h" // needed for aod::TracksDCA table +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/TrackSelectionTables.h" // needed for aod::TracksDCA table + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/DataTypes.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" +#include using namespace o2; using namespace o2::framework; // *) Run 3: -using BCs_Run3 = soa::Join; // TBI 20241126 under testing -// Remark 1: I have already timestamp in workflow, due to track-propagation. With Run3MatchedToBCSparse, I can use bc.has_zdc() -// Remark 2: For consistency with notation below, drop _Run3 and instead use _Run2 and _Run1 +using BCs_Run3 = soa::Join; // TBI 20241126 under testing +// Remark 1: I have already timestamp in workflow, due to track-propagation. +// Remark 2: For consistency with notation below, drop _Run3 and instead use _Run2 and _Run1 TBI 20250401 not sure any longer what I wanted to say here... // using EventSelection = soa::Join; // TBI 20241209 validating "MultsGlobal" -// for using collision.multNTracksGlobal() -using EventSelection = soa::Join; +// for using collision.multNTracksGlobal() TBI 20250128 do i still need this? +using EventSelection = soa::Join; +// TBI 20250128 I can't join here directly aod::CentNGlobals, see email from DDC from 20250127 if this one requires a special treatment +// See in https://github.com/AliceO2Group/O2Physics/blob/master/Common/DataModel/Centrality.h how centrality tables are named exactly using CollisionRec = soa::Join::iterator; // use in json "isMC": "true" for "event-selection-task" using CollisionRecSim = soa::Join::iterator; // using CollisionRecSim = soa::Join::iterator; // TBI 20241210 validating "MultsExtraMC" for multMCNParticlesEta08 @@ -57,20 +65,37 @@ using CollisionRec_Run1 = soa::Join::itera using CollisionRecSim_Run1 = soa::Join::iterator; // Remark: For tracks, I can use everything same as in Run 3 +// *) QA: +// Remark: This is Run 3 "Rec" + subscription to additional few tables (otherwise unnecessary in my analysis, e.g. some specific detector tables), used only for QA purposes. +// Therefore, I start all definitions from what I have defined for Run 3 "Rec", and on top of it join these additional tables for QA. +using BCs_QA = soa::Join; +// *) BcSels => bc.has_foundFT0(), etc. +// *) Run3MatchedToBCSparse => bc.has_zdc(), etc. TBI 20250401 at the moment, I do not use this one +using Collision_QA = CollisionRec; // if I would need additional tables for QA, just join 'em here with CollisionRec +using TracksRec_QA = TracksRec; // if I would need additional tables for QA, just join 'em here with TracksRec + // *) ROOT: -#include -#include -#include -#include -#include -#include -#include #include -#include +#include #include #include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include + +#include + +#include using namespace std; // *) Enums: @@ -87,6 +112,12 @@ struct MultiparticleCorrelationsAB // this name is used in lower-case format to Service ccdb; ctpRateFetcher mRateFetcher; // see email from MP on 20240508 and example usage in O2Physics/PWGLF/TableProducer/Common/zdcSP.cxx + // *) O2DatabsePDG service shared service between different tasks (do not use TDatabasePDG directly, because it's not shared) + // See also Tutorials/src/usingPDGCervice.cxx + // TBI 20250625 enable the line below and switch to O2DatabsePDG when memory consumption with O2DatabsePDG is resolved, and then replace in all functions + // tc.fDatabasePDG->GetParticle(track.pdgCode()) with pdg->GetParticle(track.pdgCode()) + same for mcParticle + remove TDatabasePDG.h + // Service pdg; + // *) Configurables (cuts): #include "PWGCF/MultiparticleCorrelations/Core/MuPa-Configurables.h" @@ -111,53 +142,58 @@ struct MultiparticleCorrelationsAB // this name is used in lower-case format to // *) Trick to avoid name clashes, part 2; // *) Trick to avoid name clashes, part 1: - Bool_t oldHistAddStatus = TH1::AddDirectoryStatus(); + bool oldHistAddStatus = TH1::AddDirectoryStatus(); TH1::AddDirectory(kFALSE); // *) Default configuration, booking, binning and cuts: - InsanityChecksOnDefinitionsOfConfigurables(); // values passed via configurables are insanitized here. Nothing is initialized yet via configurables in this method - DefaultConfiguration(); // here default values from configurables are taken into account - DefaultBooking(); // here I decide only which histograms are booked, not details like binning, etc. - DefaultBinning(); // here default values for bins are either hardwired, or values for bins provided via configurables are taken into account - DefaultCuts(); // here default values for cuts are either hardwired, or defined through default binning to ease bookeeping, + insanityChecksOnDefinitionsOfConfigurables(); // values passed via configurables are insanitized here. Nothing is initialized yet via configurables in this method + defaultConfiguration(); // here default values from configurables are taken into account + defaultBooking(); // here I decide only which histograms are booked, not details like binning, etc. + defaultBinning(); // here default values for bins are either hardwired, or values for bins provided via configurables are taken into account + defaultCuts(); // here default values for cuts are either hardwired, or defined through default binning to ease bookeeping, // or values for cuts provided via configurables are taken into account - // Remark: DefaultCuts() has to be called after DefaultBinning() + // Remark: defaultCuts() has to be called after defaultBinning() + // *) Specific cuts: if (tc.fUseSpecificCuts) { - SpecificCuts(tc.fWhichSpecificCuts); // after default cuts are applied, on top of them apply analysis-specific cuts. Has to be called after DefaultBinning() and DefaultCuts() + specificCuts(tc.fWhichSpecificCuts); // after default cuts are applied, on top of them apply analysis-specific cuts. Has to be called after defaultBinning() and defaultCuts() } // *) Insanity checks before booking: - InsanityChecksBeforeBooking(); // check only hardwired values and the ones obtained from configurables + insanityChecksBeforeBooking(); // check only hardwired values and the ones obtained from configurables // *) Book random generator: delete gRandom; gRandom = new TRandom3(tc.fRandomSeed); // if uiSeed is 0, the seed is determined uniquely in space and time via TUUID // *) Book base list: - BookBaseList(); + bookBaseList(); // *) Book all remaining objects; - BookAndNestAllLists(); - BookResultsHistograms(); // yes, this one has to be booked first, because it defines the commong binning for other groups of histograms - BookQAHistograms(); - BookEventHistograms(); - BookEventCutsHistograms(); - BookParticleHistograms(); - BookParticleCutsHistograms(); - BookQvectorHistograms(); - BookCorrelationsHistograms(); - BookWeightsHistograms(); - BookCentralityWeightsHistograms(); - BookNestedLoopsHistograms(); - BookNUAHistograms(); - BookInternalValidationHistograms(); - BookTest0Histograms(); - BookEtaSeparationsHistograms(); - BookTheRest(); // here I book everything that was not sorted (yet) in the specific functions above + bookAndNestAllLists(); + bookResultsHistograms(); // yes, this one has to be booked first, because it defines the common binning for other groups of histograms, w/ or w/o clonning + bookQAHistograms(); + bookEventHistograms(); + bookEventCutsHistograms(); + bookParticleHistograms(); + bookParticleCutsHistograms(); // memStatus: 50913 + bookQvectorHistograms(); // memStatus: 50913 (without differential q-vectors and eta separations) + bookCorrelationsHistograms(); + bookWeightsHistograms(); + bookCentralityWeightsHistograms(); + bookNestedLoopsHistograms(); + bookNUAHistograms(); + bookInternalValidationHistograms(); + bookTest0Histograms(); + bookEtaSeparationsHistograms(); + bookTheRest(); // I book everything that was not sorted (yet) in the specific functions above + // memStatus: 50913 (without differential q-vectors and eta separations) + + // *) I can purge a few objects used for common consistent booking across different groups of histograms: + purgeAfterBooking(); // *) Insanity checks after booking: - InsanityChecksAfterBooking(); // pointers of all local histograms, etc., are available, so I can do insanity checks directly on all booked objects + insanityChecksAfterBooking(); // pointers of all local histograms, etc., are available, so I can do insanity checks directly on all booked objects // *) Trick to avoid name clashes, part 2: TH1::AddDirectory(oldHistAddStatus); @@ -187,7 +223,6 @@ struct MultiparticleCorrelationsAB // this name is used in lower-case format to // ------------------------------------------- // A) Process only reconstructed data: - // void processRec(CollisionRec const& collision, aod::BCs const&, TracksRec const& tracks) void processRec(CollisionRec const& collision, BCs_Run3 const& bcs, TracksRec const& tracks) { // Remark: Do not use here LOGF(fatal, ...) or LOGF(info, ...), because their stdout/stderr is suppressed. Use them in regular member functions instead. @@ -272,12 +307,74 @@ struct MultiparticleCorrelationsAB // this name is used in lower-case format to // ------------------------------------------- // J) Process data with minimum subscription to the tables, for testing purposes: + // Remark: To keep this branch as simple as possible, I do not subscribe to centrality table. Therefore, when running with "processTest": "true" in JSON, + // I have to remove "| o2-analysis-centrality-table $JsonFile \" from workflow (yes, remove, not comment out!) void processTest(aod::Collision const& collision, aod::BCs const& bcs, aod::Tracks const& tracks) { Steer(collision, bcs, tracks); } PROCESS_SWITCH(MultiparticleCorrelationsAB, processTest, "test processing", false); + // ------------------------------------------- + + // K) Process data with more than necessary subscriptions to the tables, only for QA purposes: + // Remark 1: This is basically the main "processRec" switch, merely enhanced with subscription to few more tables (e.g. detector specific), only for QA purposes. + // Remark 2: Ideally, i use the same workflow for "processRec" and "processQA", but most likely at some point I will have to establish separate workflow for "processQA" + void processQA(Collision_QA const& collision, BCs_QA const& bcs, TracksRec_QA const& tracks, aod::FT0s const&) + { + // Summary for additional tables subscribed to directly here: + // *) FT0s => bc.foundFT0().sumAmpC(), etc. + Steer(collision, bcs, tracks); + } + PROCESS_SWITCH(MultiparticleCorrelationsAB, processQA, "QA processing", false); + + // ------------------------------------------- + + // L) Process extra Monte Carlo info the from table HepMCHeavyIons: + // Remark 1: Under testing, merge eventually this process switch with processRecSim, processRecSim_Run2, and processRecSim_Run1 above; + // This switch does everything the same as processRecSim (so it works only for Run 3 at the moment), except extra info is processed from table HepMCHeavyIons with dedicated function call + // ProcessHepMCHeavyIons(hepMChi). I use this dedicated function, in order not to modify call to Steer(...) by adding the fourth argument. + // TBI 20250429 see if I can circumvent this with templates (i can NOT join HepMCHeavyIons and McParticles), in order to keep call to Steer(...) as simple as it is now + // Remark 2: In MC LHC24g3 and LHC24e2c, for HepMCHeavyIons only impact parameter is filled; + // As soon as HepMCHeavyIons is correctly filled in MC productions, merge this switch with processRecSim, processRecSim_Run2, and processRecSim_Run1 above. + // Most notably, I will need hep.centrality() (centrality at generated level), and hep.sigmaInelNN() + void processHepMChi(CollisionRecSim const& collision, aod::BCs const& bcs, TracksRecSim const& tracks, aod::HepMCHeavyIons const& hepMChi, aod::McParticles const&, aod::McCollisions const&) + { + // Comment the weather here... + + // *) Check if this collision has the corresponding MC collision: + if (!collision.has_mcCollision()) { + LOGF(warning, "\033[1;31m%s at line %d : No MC collision for this collision, skip... \033[0m", __FUNCTION__, __LINE__); + return; + } + + // *) For this collision, get the corresponding mcCollision, and then profit from the fact that HepMCHeavyIons have index to mcCollision by default (no need to join with McCollisionLabels): + auto hep = hepMChi.iteratorAt(collision.mcCollision().globalIndex()); + + // *) Quick insanity check that HepMCHeavyIons and McCollisions refer to the same MC collision: + // Since both of them provide getter impactParameter(), i simply check if it gives the same value in both cases: + if (std::abs(hep.impactParameter() - collision.mcCollision().impactParameter()) > tc.fFloatingPointPrecision) { + LOGF(fatal, "\033[1;31m%s at line %d : impactParameter accessed from HepMCHeavyIons and McCollisions is not the same, they do not correspond to the same MC event \033[0m", __FUNCTION__, __LINE__); + } + + // *) Okay, extract all extra info from HepMCHeavyIons: + ProcessHepMCHeavyIons(hep); + + // *) Call the Steer(...) + // TBI 20250429 For the time being, only Run 3 call for Steer(...) is supported. When generalizing to Run 2 and Run 1 process switches, perhaps the better strategy is + // just to inject ProcessHepMCHeavyIons(hep); , and keep call to Steer(...) as it is now? + Steer(collision, bcs, tracks); // TBI 20250429 remember that I have hardwired here eRecAndSim, so this now works only for Run 3 + + } // void processHepMChi( ... ) + + PROCESS_SWITCH(MultiparticleCorrelationsAB, processHepMChi, "HepMCHeavyIons processing", false); + + // ------------------------------------------- + + // ... ctd. here with further process switches ... + + // ------------------------------------------- + }; // struct MultiparticleCorrelationsAB // ------------------------------------------- diff --git a/PWGCF/MultiparticleCorrelations/Tasks/threeParticleCorrelations.cxx b/PWGCF/MultiparticleCorrelations/Tasks/threeParticleCorrelations.cxx new file mode 100644 index 00000000000..5f856d409ca --- /dev/null +++ b/PWGCF/MultiparticleCorrelations/Tasks/threeParticleCorrelations.cxx @@ -0,0 +1,1219 @@ +// 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. +// +/// \file threeParticleCorrelations.cxx +/// \brief Task for producing particle correlations +/// \author Joey Staa + +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "CCDB/BasicCCDBManager.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/McCollisionExtra.h" +#include "Common/DataModel/PIDResponse.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "RecoDecay.h" +#include "TPDGCode.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace constants::physics; + +struct ThreeParticleCorrelations { + Service ccdb; + + // Analysis parameters + float centMin = 0.0, centMax = 90.0; + float zvtxMax = 10.0; + float v0PtMin = 0.6, v0PtMax = 12.0; + float v0EtaMax = 0.72; + float trackPtMin = 0.2, trackPtMax = 3.0; + float trackEtaMax = 0.8; + + // Track PID parameters + double pionID = 0.0, kaonID = 1.0, protonID = 2.0; + float nSigma0 = 0.0, nSigma2 = 2.0, nSigma4 = 4.0, nSigma5 = 5.0; + + // V0 filter parameters + float tpcNCrossedRowsMin = 70.0; + float decayRMin = 1.2, ctauMax = 30.0; + float cosPAMin = 0.995; + float dcaProtonMin = 0.05, dcaPionMin = 0.2; + int dcaV0DauMax = 1; + + // Track filter parameters + float pionPtMin = 0.3, pionPtMax = 2.3, kaonPtMin = 0.5, kaonPtMax = 2.5, protonPtMin = 0.5, protonPtMax = 2.5; + float pionPtMid = 1.5, kaonPtMid1 = 1.5, kaonPtMid2 = 2.0, protonPtMid = 0.7; + + // RD filter parameters + float dEtaMax = 0.05, dEtaMin = 0.023; + float dPhiStarMinOS = 0.09, dPhiStarMinSS = 0.095; + float rMin = 0.8, rMax = 2.5; + + // Lambda invariant mass fit + double dGaussSigma = 0.0021; + + // Histogram registry + HistogramRegistry rMECorrRegistry{"MECorrRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry rSECorrRegistry{"SECorrRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry rMCRegistry{"MCRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry rPhiStarRegistry{"PhiStarRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry rQARegistry{"QARegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + + // Collision & Event filters + Filter collCent = aod::cent::centFT0C > centMin&& aod::cent::centFT0C < centMax; + Filter collZvtx = nabs(aod::collision::posZ) < zvtxMax; + Filter mcCollZvtx = nabs(aod::mccollision::posZ) < zvtxMax; + Filter evSelect = aod::evsel::sel8 == true; + + // Track filters + Filter trackPt = aod::track::pt > trackPtMin&& aod::track::pt < trackPtMax; + Filter trackEta = nabs(aod::track::eta) < trackEtaMax; + Filter globalTracks = requireGlobalTrackInFilter(); + + // Particle filters + Filter particleEta = nabs(aod::mcparticle::eta) < trackEtaMax; + + // Table aliases - Data + using MyFilteredCollisions = soa::Filtered>; + using MyFilteredCollision = MyFilteredCollisions::iterator; + using MyFilteredTracks = soa::Filtered>; + + // Table aliases - MC Gen + using MyFilteredMCGenCollisions = soa::Filtered>; + using MyFilteredMCGenCollision = MyFilteredMCGenCollisions::iterator; + using MyFilteredMCParticles = soa::Filtered; + + // Table aliases - MC Rec + using MCRecCollisions = soa::Join; + using MyFilteredMCRecCollisions = soa::Filtered; + using MyMCV0s = soa::Join; + using MyFilteredMCTracks = soa::Filtered>; + + // Partitions + Partition mcTracks = aod::mcparticle::pt > trackPtMin&& aod::mcparticle::pt < trackPtMax; + Partition mcV0s = aod::mcparticle::pt > v0PtMin&& aod::mcparticle::pt < v0PtMax&& nabs(aod::mcparticle::eta) < v0EtaMax; + Partition mcTriggers = ((aod::mcparticle::pdgCode == static_cast(kLambda0) || aod::mcparticle::pdgCode == static_cast(kLambda0Bar)) && + aod::mcparticle::pt > v0PtMin && aod::mcparticle::pt < v0PtMax && nabs(aod::mcparticle::eta) < v0EtaMax); + Partition mcAssociates = (((aod::mcparticle::pdgCode == static_cast(kPiPlus) || aod::mcparticle::pdgCode == static_cast(kPiMinus)) && aod::mcparticle::pt > pionPtMin && aod::mcparticle::pt < pionPtMax) || + ((aod::mcparticle::pdgCode == static_cast(kKPlus) || aod::mcparticle::pdgCode == static_cast(kKMinus)) && aod::mcparticle::pt > kaonPtMin && aod::mcparticle::pt < kaonPtMax) || + ((aod::mcparticle::pdgCode == static_cast(kProton) || aod::mcparticle::pdgCode == static_cast(kProtonBar)) && aod::mcparticle::pt > protonPtMin)); + + // Mixed-events binning policy + SliceCache cache; + Preslice perCol = aod::mcparticle::mcCollisionId; + PresliceUnsorted perMCCol = aod::mccollisionlabel::mcCollisionId; + + ConfigurableAxis confCentBins{"confCentBins", {VARIABLE_WIDTH, 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f}, "ME Centrality binning"}; + ConfigurableAxis confZvtxBins{"confZvtxBins", {VARIABLE_WIDTH, -10.0f, -8.0f, -6.0f, -4.0f, -2.0, 0.0f, 2.0f, 4.0f, 6.0f, 8.0f, 10.0f}, "ME Zvtx binning"}; + using BinningType = ColumnBinningPolicy; + using BinningTypeMC = ColumnBinningPolicy; + + BinningType collBinning{{confCentBins, confZvtxBins}, true}; + BinningTypeMC collBinningMC{{confCentBins, confZvtxBins}, true}; + Pair pairData{collBinning, 5, -1, &cache}; + SameKindPair pairMC{collBinningMC, 5, -1, &cache}; + + // Process configurables + Configurable confFakeV0Switch{"confFakeV0Switch", false, "Switch for the fakeV0Filter function"}; + Configurable confRDSwitch{"confRDSwitch", true, "Switch for the radialDistanceFilter function"}; + + // Efficiency histograms + TH3D** hEffPions = new TH3D*[2]; + TH3D** hEffKaons = new TH3D*[2]; + TH3D** hEffProtons = new TH3D*[2]; + TH3D** hEffLambdas = new TH3D*[2]; + + // Correlation variables + int triggSign, assocSign; + double v0Efficiency; + double candMass; + double* assocPID; + + double deltaPhi, deltaEta; + + //========================================================================================================================================================================================================================================================================== + + void init(InitContext const&) + { + + // Histograms axes + const AxisSpec centralityAxis{confCentBins}; + const AxisSpec zvtxAxis{confZvtxBins}; + const AxisSpec dPhiAxis{36, (-1. / 2) * constants::math::PI, (3. / 2) * constants::math::PI}; + const AxisSpec dEtaAxis{32, -1.52, 1.52}; + const AxisSpec v0PtAxis{114, 0.6, 12}; + const AxisSpec v0EtaAxis{36, -0.72, 0.72}; + const AxisSpec trackPtAxis{28, 0.2, 3}; + const AxisSpec trackEtaAxis{32, -0.8, 0.8}; + const AxisSpec lambdaInvMassAxis{100, 1.08, 1.16}; + + // QA & PID + rQARegistry.add("hNEvents", "hNEvents", {HistType::kTH1D, {{3, 0, 3}}}); + rQARegistry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "All"); + rQARegistry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "kIsGoodZvtxFT0vsPV"); + rQARegistry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "kNoSameBunchPileup"); + + rQARegistry.add("hEventCentrality", "hEventCentrality", {HistType::kTH1D, {{centralityAxis}}}); + rQARegistry.add("hEventCentrality_MC", "hEventCentrality_MC", {HistType::kTH1D, {{centralityAxis}}}); + rQARegistry.add("hEventZvtx", "hEventZvtx", {HistType::kTH1D, {{zvtxAxis}}}); + rQARegistry.add("hTrackPt", "hTrackPt", {HistType::kTH1D, {{100, 0, 4}}}); + rQARegistry.add("hTrackEta", "hTrackEta", {HistType::kTH1D, {{100, -1, 1}}}); + rQARegistry.add("hTrackPhi", "hTrackPhi", {HistType::kTH1D, {{100, (-1. / 2) * constants::math::PI, (5. / 2) * constants::math::PI}}}); + rQARegistry.add("hTrackNSharedClusters", "hTrackNSharedClusters", {HistType::kTH1D, {{200, 0, 200}}}); + + rQARegistry.add("hPtPion", "hPtPion", {HistType::kTH3D, {{trackPtAxis}, {centralityAxis}, {2, -2, 2}}}); + rQARegistry.add("hPtKaon", "hPtKaon", {HistType::kTH3D, {{trackPtAxis}, {centralityAxis}, {2, -2, 2}}}); + rQARegistry.add("hPtProton", "hPtProton", {HistType::kTH3D, {{trackPtAxis}, {centralityAxis}, {2, -2, 2}}}); + rQARegistry.add("hPtV0", "hPtV0", {HistType::kTH3D, {{v0PtAxis}, {centralityAxis}, {2, -2, 2}}}); + rQARegistry.add("hPtPion_MC", "hPtPion_MC", {HistType::kTH3D, {{trackPtAxis}, {centralityAxis}, {2, -2, 2}}}); + rQARegistry.add("hPtKaon_MC", "hPtKaon_MC", {HistType::kTH3D, {{trackPtAxis}, {centralityAxis}, {2, -2, 2}}}); + rQARegistry.add("hPtProton_MC", "hPtProton_MC", {HistType::kTH3D, {{trackPtAxis}, {centralityAxis}, {2, -2, 2}}}); + rQARegistry.add("hPtV0_MC", "hPtV0_MC", {HistType::kTH3D, {{v0PtAxis}, {centralityAxis}, {2, -2, 2}}}); + + rQARegistry.add("hdEdx", "hdEdx", {HistType::kTH2D, {{56, 0.2, 3.0}, {180, 20, 200}}}); + rQARegistry.add("hdEdxPion", "hdEdxPion", {HistType::kTH2D, {{56, 0.2, 3.0}, {180, 20, 200}}}); + rQARegistry.add("hdEdxKaon", "hdEdxKaon", {HistType::kTH2D, {{56, 0.2, 3.0}, {180, 20, 200}}}); + rQARegistry.add("hdEdxProton", "hdEdxProton", {HistType::kTH2D, {{56, 0.2, 3.0}, {180, 20, 200}}}); + rQARegistry.add("hBeta", "hBeta", {HistType::kTH2D, {{56, 0.2, 3.0}, {70, 0.4, 1.1}}}); + rQARegistry.add("hBetaPion", "hBetaPion", {HistType::kTH2D, {{56, 0.2, 3.0}, {70, 0.4, 1.1}}}); + rQARegistry.add("hBetaKaon", "hBetaKaon", {HistType::kTH2D, {{56, 0.2, 3.0}, {70, 0.4, 1.1}}}); + rQARegistry.add("hBetaProton", "hBetaProton", {HistType::kTH2D, {{56, 0.2, 3.0}, {70, 0.4, 1.1}}}); + + rQARegistry.add("hTPCPion", "hTPCPion", {HistType::kTH2D, {{trackPtAxis}, {241, -6, 6}}}); + rQARegistry.add("hTPCKaon", "hTPCKaon", {HistType::kTH2D, {{trackPtAxis}, {241, -6, 6}}}); + rQARegistry.add("hTPCProton", "hTPCProton", {HistType::kTH2D, {{trackPtAxis}, {241, -6, 6}}}); + rQARegistry.add("hTOFPion", "hTOFPion", {HistType::kTH2D, {{trackPtAxis}, {1000, -50, 50}}}); + rQARegistry.add("hTOFKaon", "hTOFKaon", {HistType::kTH2D, {{trackPtAxis}, {1000, -50, 50}}}); + rQARegistry.add("hTOFProton", "hTOFProton", {HistType::kTH2D, {{trackPtAxis}, {1000, -50, 50}}}); + + rQARegistry.add("hInvMassLambda", "hInvMassLambda", {HistType::kTH3D, {{lambdaInvMassAxis}, {v0PtAxis}, {centralityAxis}}}); + rQARegistry.add("hInvMassAntiLambda", "hInvMassAntiLambda", {HistType::kTH3D, {{lambdaInvMassAxis}, {v0PtAxis}, {centralityAxis}}}); + rQARegistry.add("hNLambdas", "hNLambdas", {HistType::kTH3D, {{2, -2, 2}, {v0PtAxis}, {centralityAxis}}}); + rQARegistry.add("hInvMassLambda_MC", "hInvMassLambda_MC", {HistType::kTH3D, {{lambdaInvMassAxis}, {v0PtAxis}, {centralityAxis}}}); + rQARegistry.add("hInvMassAntiLambda_MC", "hInvMassAntiLambda_MC", {HistType::kTH3D, {{lambdaInvMassAxis}, {v0PtAxis}, {centralityAxis}}}); + + // PhiStar + rPhiStarRegistry.add("hSEPhiStarIR_OS", "hSEPhiStarIR_OS", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hSEPhiStarIR_SS", "hSEPhiStarIR_SS", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hSEPhiStarIR_SSP", "hSEPhiStarIR_SSP", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hSEPhiStarIR_SSN", "hSEPhiStarIR_SSN", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hSEPhiStarMean_OS", "hSEPhiStarMean_OS", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hSEPhiStarMean_SS", "hSEPhiStarMean_SS", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hSEPhiStarMean_SSP", "hSEPhiStarMean_SSP", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hSEPhiStarMean_SSN", "hSEPhiStarMean_SSN", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + + rPhiStarRegistry.add("hMEPhiStarIR_OS", "hMEPhiStarIR_OS", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hMEPhiStarIR_SS", "hMEPhiStarIR_SS", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hMEPhiStarIR_SSP", "hMEPhiStarIR_SSP", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hMEPhiStarIR_SSN", "hMEPhiStarIR_SSN", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hMEPhiStarMean_OS", "hMEPhiStarMean_OS", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hMEPhiStarMean_SS", "hMEPhiStarMean_SS", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hMEPhiStarMean_SSP", "hMEPhiStarMean_SSP", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + rPhiStarRegistry.add("hMEPhiStarMean_SSN", "hMEPhiStarMean_SSN", {HistType::kTH2D, {{121, -0.3025, 0.3025}, {101, -0.0505, 0.0505}}}); + + // Efficiency + rMCRegistry.add("hGenerated", "hGenerated", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hGenPionP", "hGenPionP", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hGenPionN", "hGenPionN", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hGenKaonP", "hGenKaonP", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hGenKaonN", "hGenKaonN", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hGenProtonP", "hGenProtonP", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hGenProtonN", "hGenProtonN", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hGenLambdaP", "hGenLambdaP", {HistType::kTH3D, {{v0PtAxis}, {v0EtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hGenLambdaN", "hGenLambdaN", {HistType::kTH3D, {{v0PtAxis}, {v0EtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hReconstructed", "hReconstructed", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hRecPionP", "hRecPionP", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hRecPionN", "hRecPionN", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hRecKaonP", "hRecKaonP", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hRecKaonN", "hRecKaonN", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hRecProtonP", "hRecProtonP", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hRecProtonN", "hRecProtonN", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hRecLambdaP", "hRecLambdaP", {HistType::kTH3D, {{v0PtAxis}, {v0EtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hRecLambdaN", "hRecLambdaN", {HistType::kTH3D, {{v0PtAxis}, {v0EtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hIdentified", "hIdentified", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hPIDPionP", "hPIDPionP", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hPIDPionN", "hPIDPionN", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hPIDKaonP", "hPIDKaonP", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hPIDKaonN", "hPIDKaonN", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hPIDProtonP", "hPIDProtonP", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + rMCRegistry.add("hPIDProtonN", "hPIDProtonN", {HistType::kTH3D, {{trackPtAxis}, {trackEtaAxis}, {centralityAxis}}}); + + // Purity + rMCRegistry.add("hSelectPionP", "hSelectPionP", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hSelectPionN", "hSelectPionN", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hSelectKaonP", "hSelectKaonP", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hSelectKaonN", "hSelectKaonN", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hSelectProtonP", "hSelectProtonP", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hSelectProtonN", "hSelectProtonN", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hTrueSelectPionP", "hTrueSelectPionP", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hTrueSelectPionN", "hTrueSelectPionN", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hTrueSelectKaonP", "hTrueSelectKaonP", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hTrueSelectKaonN", "hTrueSelectKaonN", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hTrueSelectProtonP", "hTrueSelectProtonP", {HistType::kTH1D, {trackPtAxis}}); + rMCRegistry.add("hTrueSelectProtonN", "hTrueSelectProtonN", {HistType::kTH1D, {trackPtAxis}}); + + // Correlations + rSECorrRegistry.add("hSameLambdaPion_SGNL", "Same-event #Lambda - #pi correlator (SGNL region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaPion_SB", "Same-event #Lambda - #pi correlator (SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaKaon_SGNL", "Same-event #Lambda - K correlator (SGNL region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaKaon_SB", "Same-event #Lambda - K correlator (SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaProton_SGNL", "Same-event #Lambda - p correlator (SGNL region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaProton_SB", "Same-event #Lambda - p correlator (SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaPion_MC", "Same-event #Lambda - #pi correlator (MC)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaKaon_MC", "Same-event #Lambda - K correlator (MC)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaProton_MC", "Same-event #Lambda - p correlator (MC)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + + rSECorrRegistry.add("hSameLambdaPion_leftSB", "Same-event #Lambda - #pi correlator (Left SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaPion_rightSB", "Same-event #Lambda - #pi correlator (Right SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaKaon_leftSB", "Same-event #Lambda - K correlator (Left SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaKaon_rightSB", "Same-event #Lambda - K correlator (Right SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaProton_leftSB", "Same-event #Lambda - p correlator (Left SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rSECorrRegistry.add("hSameLambdaProton_rightSB", "Same-event #Lambda - p correlator (Right SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + + rMECorrRegistry.add("hMixLambdaPion_SGNL", "Mixed-event #Lambda - #pi correlator (SGNL region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaPion_SB", "Mixed-event #Lambda - #pi correlator (SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaKaon_SGNL", "Mixed-event #Lambda - K correlator (SGNL region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaKaon_SB", "Mixed-event #Lambda - K correlator (SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaProton_SGNL", "Mixed-event #Lambda - p correlator (SGNL region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaProton_SB", "Mixed-event #Lambda - p correlator (SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaPion_MC", "Mixed-event #Lambda - #pi correlator (MC)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaKaon_MC", "Mixed-event #Lambda - K correlator (MC)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaProton_MC", "Mixed-event #Lambda - p correlator (MC)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + + rMECorrRegistry.add("hMixLambdaPion_leftSB", "Mixed-event #Lambda - #pi correlator (Left SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaPion_rightSB", "Mixed-event #Lambda - #pi correlator (Right SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaKaon_leftSB", "Mixed-event #Lambda - K correlator (Left SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaKaon_rightSB", "Mixed-event #Lambda - K correlator (Right SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaProton_leftSB", "Mixed-event #Lambda - p correlator (Left SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + rMECorrRegistry.add("hMixLambdaProton_rightSB", "Mixed-event #Lambda - p correlator (Right SB region)", {HistType::kTHnSparseF, {{dPhiAxis}, {dEtaAxis}, {centralityAxis}, {zvtxAxis}, {2, -2, 2}, {2, -2, 2}}}); + + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + TList* effListChargedParticles = ccdb->getForTimeStamp("Users/j/jstaa/Efficiency/ChargedParticles", 1); + TList* effListLambdas = ccdb->getForTimeStamp("Users/j/jstaa/Efficiency/Lambdas", 1); + hEffPions[0] = static_cast(effListChargedParticles->FindObject("hEfficiencyPionP")); + hEffPions[1] = static_cast(effListChargedParticles->FindObject("hEfficiencyPionN")); + hEffKaons[0] = static_cast(effListChargedParticles->FindObject("hEfficiencyKaonP")); + hEffKaons[1] = static_cast(effListChargedParticles->FindObject("hEfficiencyKaonN")); + hEffProtons[0] = static_cast(effListChargedParticles->FindObject("hEfficiencyProtonP")); + hEffProtons[1] = static_cast(effListChargedParticles->FindObject("hEfficiencyProtonN")); + hEffLambdas[0] = static_cast(effListLambdas->FindObject("hEfficiencyLambdaP")); + hEffLambdas[1] = static_cast(effListLambdas->FindObject("hEfficiencyLambdaN")); + } + + //========================================================================================================================================================================================================================================================================== + + void processSame(MyFilteredCollision const& collision, aod::V0Datas const& v0s, MyFilteredTracks const& tracks, aod::BCsWithTimestamps const&) + { + + if (!acceptEvent(collision, true)) { + return; + } + + auto bc = collision.bc_as(); + auto bField = getMagneticField(bc.timestamp()); + rQARegistry.fill(HIST("hEventCentrality"), collision.centFT0C()); + rQARegistry.fill(HIST("hEventZvtx"), collision.posZ()); + + // Start of the Track QA + for (const auto& track : tracks) { + rQARegistry.fill(HIST("hTPCPion"), track.pt(), track.tpcNSigmaPi()); + rQARegistry.fill(HIST("hTPCKaon"), track.pt(), track.tpcNSigmaKa()); + rQARegistry.fill(HIST("hTPCProton"), track.pt(), track.tpcNSigmaPr()); + if (track.hasTOF()) { + rQARegistry.fill(HIST("hTOFPion"), track.pt(), track.tofNSigmaPi()); + rQARegistry.fill(HIST("hTOFKaon"), track.pt(), track.tofNSigmaKa()); + rQARegistry.fill(HIST("hTOFProton"), track.pt(), track.tofNSigmaPr()); + } + + if (trackFilters(track)) { + assocPID = trackPID(track); + rQARegistry.fill(HIST("hTrackPt"), track.pt()); + rQARegistry.fill(HIST("hTrackEta"), track.eta()); + rQARegistry.fill(HIST("hTrackPhi"), track.phi()); + rQARegistry.fill(HIST("hTrackNSharedClusters"), track.tpcNClsShared()); + rQARegistry.fill(HIST("hdEdx"), track.pt(), track.tpcSignal()); + rQARegistry.fill(HIST("hBeta"), track.pt(), track.beta()); + if (assocPID[0] == pionID) { // Pions + rQARegistry.fill(HIST("hPtPion"), track.pt(), collision.centFT0C(), track.sign(), 1. / trackEff(hEffPions, track, collision.centFT0C())); + rQARegistry.fill(HIST("hdEdxPion"), track.pt(), track.tpcSignal()); + rQARegistry.fill(HIST("hBetaPion"), track.pt(), track.beta()); + } else if (assocPID[0] == kaonID) { // Kaons + rQARegistry.fill(HIST("hPtKaon"), track.pt(), collision.centFT0C(), track.sign(), 1. / trackEff(hEffKaons, track, collision.centFT0C())); + rQARegistry.fill(HIST("hdEdxKaon"), track.pt(), track.tpcSignal()); + rQARegistry.fill(HIST("hBetaKaon"), track.pt(), track.beta()); + } else if (assocPID[0] == protonID) { // Protons + rQARegistry.fill(HIST("hPtProton"), track.pt(), collision.centFT0C(), track.sign(), 1. / trackEff(hEffProtons, track, collision.centFT0C())); + rQARegistry.fill(HIST("hdEdxProton"), track.pt(), track.tpcSignal()); + rQARegistry.fill(HIST("hBetaProton"), track.pt(), track.beta()); + } + } + } + // End of the Track QA + + // Start of the Same-Event correlations + for (const auto& trigger : v0s) { + if (v0Filters(collision, trigger, tracks)) { + + triggSign = v0Sign(trigger); + v0Efficiency = v0Eff(hEffLambdas, trigger, collision.centFT0C()); + + rQARegistry.fill(HIST("hPtV0"), trigger.pt(), collision.centFT0C(), triggSign, 1. / v0Efficiency); + if (triggSign == 1) { + candMass = trigger.mLambda(); + rQARegistry.fill(HIST("hInvMassLambda"), trigger.mLambda(), trigger.pt(), collision.centFT0C(), 1. / v0Efficiency); + } else if (triggSign == -1) { + candMass = trigger.mAntiLambda(); + rQARegistry.fill(HIST("hInvMassAntiLambda"), trigger.mAntiLambda(), trigger.pt(), collision.centFT0C(), 1. / v0Efficiency); + } + + for (const auto& associate : tracks) { + if (trackFilters(associate)) { + if (correlationFilters(trigger, associate) && radialDistanceFilter(trigger, associate, bField, false) && fakeV0Filter(trigger, associate)) { + + assocPID = trackPID(associate); + deltaPhi = RecoDecay::constrainAngle(trigger.phi() - associate.phi(), -constants::math::PIHalf); + deltaEta = trigger.eta() - associate.eta(); + + if (candMass >= MassLambda0 - 4 * dGaussSigma && candMass <= MassLambda0 + 4 * dGaussSigma) { + if (assocPID[0] == pionID) { // Pions + rSECorrRegistry.fill(HIST("hSameLambdaPion_SGNL"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffPions, associate, collision.centFT0C()) * v0Efficiency)); + } else if (assocPID[0] == kaonID) { // Kaons + rSECorrRegistry.fill(HIST("hSameLambdaKaon_SGNL"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffKaons, associate, collision.centFT0C()) * v0Efficiency)); + } else if (assocPID[0] == protonID) { // Protons + rSECorrRegistry.fill(HIST("hSameLambdaProton_SGNL"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffProtons, associate, collision.centFT0C()) * v0Efficiency)); + } + + } else if (candMass >= MassLambda0 - 8 * dGaussSigma && candMass <= MassLambda0 + 8 * dGaussSigma) { + if (assocPID[0] == pionID) { // Pions + rSECorrRegistry.fill(HIST("hSameLambdaPion_SB"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffPions, associate, collision.centFT0C()) * v0Efficiency)); + if (candMass >= MassLambda0 - 8 * dGaussSigma && candMass < MassLambda0 - 4 * dGaussSigma) { + rSECorrRegistry.fill(HIST("hSameLambdaPion_leftSB"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffPions, associate, collision.centFT0C()) * v0Efficiency)); + } else if (candMass > MassLambda0 + 4 * dGaussSigma && candMass <= MassLambda0 + 8 * dGaussSigma) { + rSECorrRegistry.fill(HIST("hSameLambdaPion_rightSB"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffPions, associate, collision.centFT0C()) * v0Efficiency)); + } + + } else if (assocPID[0] == kaonID) { // Kaons + rSECorrRegistry.fill(HIST("hSameLambdaKaon_SB"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffKaons, associate, collision.centFT0C()) * v0Efficiency)); + if (candMass >= MassLambda0 - 8 * dGaussSigma && candMass < MassLambda0 - 4 * dGaussSigma) { + rSECorrRegistry.fill(HIST("hSameLambdaKaon_leftSB"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffKaons, associate, collision.centFT0C()) * v0Efficiency)); + } else if (candMass > MassLambda0 + 4 * dGaussSigma && candMass <= MassLambda0 + 8 * dGaussSigma) { + rSECorrRegistry.fill(HIST("hSameLambdaKaon_rightSB"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffKaons, associate, collision.centFT0C()) * v0Efficiency)); + } + + } else if (assocPID[0] == protonID) { // Protons + rSECorrRegistry.fill(HIST("hSameLambdaProton_SB"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffProtons, associate, collision.centFT0C()) * v0Efficiency)); + if (candMass >= MassLambda0 - 8 * dGaussSigma && candMass < MassLambda0 - 4 * dGaussSigma) { + rSECorrRegistry.fill(HIST("hSameLambdaProton_leftSB"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffProtons, associate, collision.centFT0C()) * v0Efficiency)); + } else if (candMass > MassLambda0 + 4 * dGaussSigma && candMass <= MassLambda0 + 8 * dGaussSigma) { + rSECorrRegistry.fill(HIST("hSameLambdaProton_rightSB"), deltaPhi, deltaEta, collision.centFT0C(), collision.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffProtons, associate, collision.centFT0C()) * v0Efficiency)); + } + } + } + } + } + } + } + } + // End of the Same-Event correlations + } + + void processMixed(MyFilteredCollisions const&, aod::V0Datas const&, MyFilteredTracks const& tracks, aod::BCsWithTimestamps const&) + { + + // Start of the Mixed-Event correlations + for (const auto& [coll_1, v0_1, coll_2, track_2] : pairData) { + if (!acceptEvent(coll_1, false) || !acceptEvent(coll_2, false)) { + return; + } + + auto bc = coll_1.bc_as(); + auto bField = getMagneticField(bc.timestamp()); + for (const auto& [trigger, associate] : soa::combinations(soa::CombinationsFullIndexPolicy(v0_1, track_2))) { + if (v0Filters(coll_1, trigger, tracks) && trackFilters(associate)) { + if (radialDistanceFilter(trigger, associate, bField, true) && fakeV0Filter(trigger, associate)) { + + triggSign = v0Sign(trigger); + v0Efficiency = v0Eff(hEffLambdas, trigger, coll_1.centFT0C()); + + if (triggSign == 1) { + candMass = trigger.mLambda(); + } else if (triggSign == -1) { + candMass = trigger.mAntiLambda(); + } + + assocPID = trackPID(associate); + deltaPhi = RecoDecay::constrainAngle(trigger.phi() - associate.phi(), -constants::math::PIHalf); + deltaEta = trigger.eta() - associate.eta(); + + if (candMass >= MassLambda0 - 4 * dGaussSigma && candMass <= MassLambda0 + 4 * dGaussSigma) { + if (assocPID[0] == pionID) { // Pions + rMECorrRegistry.fill(HIST("hMixLambdaPion_SGNL"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffPions, associate, coll_1.centFT0C()) * v0Efficiency)); + } else if (assocPID[0] == kaonID) { // Kaons + rMECorrRegistry.fill(HIST("hMixLambdaKaon_SGNL"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffKaons, associate, coll_1.centFT0C()) * v0Efficiency)); + } else if (assocPID[0] == protonID) { // Protons + rMECorrRegistry.fill(HIST("hMixLambdaProton_SGNL"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffProtons, associate, coll_1.centFT0C()) * v0Efficiency)); + } + + } else if (candMass >= MassLambda0 - 8 * dGaussSigma && candMass <= MassLambda0 + 8 * dGaussSigma) { + if (assocPID[0] == pionID) { // Pions + rMECorrRegistry.fill(HIST("hMixLambdaPion_SB"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffPions, associate, coll_1.centFT0C()) * v0Efficiency)); + if (candMass >= MassLambda0 - 8 * dGaussSigma && candMass < MassLambda0 - 4 * dGaussSigma) { + rMECorrRegistry.fill(HIST("hMixLambdaPion_leftSB"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffPions, associate, coll_1.centFT0C()) * v0Efficiency)); + } else if (candMass > MassLambda0 + 4 * dGaussSigma && candMass <= MassLambda0 + 8 * dGaussSigma) { + rMECorrRegistry.fill(HIST("hMixLambdaPion_rightSB"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffPions, associate, coll_1.centFT0C()) * v0Efficiency)); + } + + } else if (assocPID[0] == kaonID) { // Kaons + rMECorrRegistry.fill(HIST("hMixLambdaKaon_SB"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffKaons, associate, coll_1.centFT0C()) * v0Efficiency)); + if (candMass >= MassLambda0 - 8 * dGaussSigma && candMass < MassLambda0 - 4 * dGaussSigma) { + rMECorrRegistry.fill(HIST("hMixLambdaKaon_leftSB"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffKaons, associate, coll_1.centFT0C()) * v0Efficiency)); + } else if (candMass > MassLambda0 + 4 * dGaussSigma && candMass <= MassLambda0 + 8 * dGaussSigma) { + rMECorrRegistry.fill(HIST("hMixLambdaKaon_rightSB"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffKaons, associate, coll_1.centFT0C()) * v0Efficiency)); + } + + } else if (assocPID[0] == protonID) { // Protons + rMECorrRegistry.fill(HIST("hMixLambdaProton_SB"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffProtons, associate, coll_1.centFT0C()) * v0Efficiency)); + if (candMass >= MassLambda0 - 8 * dGaussSigma && candMass < MassLambda0 - 4 * dGaussSigma) { + rMECorrRegistry.fill(HIST("hMixLambdaProton_leftSB"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffProtons, associate, coll_1.centFT0C()) * v0Efficiency)); + } else if (candMass > MassLambda0 + 4 * dGaussSigma && candMass <= MassLambda0 + 8 * dGaussSigma) { + rMECorrRegistry.fill(HIST("hMixLambdaProton_rightSB"), deltaPhi, deltaEta, coll_1.centFT0C(), coll_1.posZ(), triggSign, associate.sign(), 1. / (trackEff(hEffProtons, associate, coll_1.centFT0C()) * v0Efficiency)); + } + } + } + } + } + } + } + // End of the Mixed-Event Correlations + } + + void processMCSame(MyFilteredMCGenCollision const& collision, MyFilteredMCParticles const&, soa::SmallGroups const& recCollisions) + { + + if (recCollisions.size() == 1) { + for (const auto& recCollision : recCollisions) { + if (!acceptEvent(recCollision, false)) { + return; + } + } + } + + rQARegistry.fill(HIST("hEventCentrality_MC"), collision.bestCollisionCentFT0C()); + auto groupMCTriggers = mcTriggers->sliceByCached(aod::mcparticle::mcCollisionId, collision.globalIndex(), cache); + auto groupMCAssociates = mcAssociates->sliceByCached(aod::mcparticle::mcCollisionId, collision.globalIndex(), cache); + + // Start of the MC Track QA + for (const auto& track : groupMCAssociates) { + if (track.isPhysicalPrimary()) { + + if (track.pdgCode() > 0) { + assocSign = 1; + } else if (track.pdgCode() < 0) { + assocSign = -1; + } + + if (std::abs(track.pdgCode()) == kPiPlus) { // Pions + rQARegistry.fill(HIST("hPtPion_MC"), track.pt(), collision.bestCollisionCentFT0C(), assocSign); + } else if (std::abs(track.pdgCode()) == kKPlus) { // Kaons + rQARegistry.fill(HIST("hPtKaon_MC"), track.pt(), collision.bestCollisionCentFT0C(), assocSign); + } else if (std::abs(track.pdgCode()) == kProton) { // Protons + rQARegistry.fill(HIST("hPtProton_MC"), track.pt(), collision.bestCollisionCentFT0C(), assocSign); + } + } + } + // End of the MC Track QA + + // Start of the MC Same-Event correlations + for (const auto& trigger : groupMCTriggers) { + if (trigger.isPhysicalPrimary()) { + + if (trigger.pdgCode() > 0) { + triggSign = 1; + } else if (trigger.pdgCode() < 0) { + triggSign = -1; + } + rQARegistry.fill(HIST("hPtV0_MC"), trigger.pt(), collision.bestCollisionCentFT0C(), triggSign); + rQARegistry.fill(HIST("hNLambdas"), triggSign, trigger.pt(), collision.bestCollisionCentFT0C()); + + for (const auto& associate : groupMCAssociates) { + if (associate.isPhysicalPrimary()) { + + if (associate.pdgCode() > 0) { + assocSign = 1; + } else if (associate.pdgCode() < 0) { + assocSign = -1; + } + + deltaPhi = RecoDecay::constrainAngle(trigger.phi() - associate.phi(), -constants::math::PIHalf); + deltaEta = trigger.eta() - associate.eta(); + + if (std::abs(associate.pdgCode()) == kPiPlus) { + rSECorrRegistry.fill(HIST("hSameLambdaPion_MC"), deltaPhi, deltaEta, collision.bestCollisionCentFT0C(), collision.posZ(), triggSign, assocSign); + } else if (std::abs(associate.pdgCode()) == kKPlus) { + rSECorrRegistry.fill(HIST("hSameLambdaKaon_MC"), deltaPhi, deltaEta, collision.bestCollisionCentFT0C(), collision.posZ(), triggSign, assocSign); + } else if (std::abs(associate.pdgCode()) == kProton) { + rSECorrRegistry.fill(HIST("hSameLambdaProton_MC"), deltaPhi, deltaEta, collision.bestCollisionCentFT0C(), collision.posZ(), triggSign, assocSign); + } + } + } + } + } + // End of the MC Same-Event Correlations + } + + void processMCMixed(MyFilteredMCGenCollisions const&, MyFilteredMCParticles const&, MyFilteredMCRecCollisions const& recCollisions) + { + + // Start of the MC Mixed-events Correlations + for (const auto& [coll_1, v0_1, coll_2, particle_2] : pairMC) { + auto recCollsA1 = recCollisions.sliceBy(perMCCol, coll_1.globalIndex()); + auto recCollsA2 = recCollisions.sliceBy(perMCCol, coll_2.globalIndex()); + if (recCollsA1.size() == 1 && recCollsA2.size() == 1) { + for (const auto& recColl_1 : recCollsA1) { + if (!acceptEvent(recColl_1, false)) { + return; + } + } + for (const auto& recColl_2 : recCollsA2) { + if (!acceptEvent(recColl_2, false)) { + return; + } + } + } + + auto groupMCTriggers = mcTriggers->sliceByCached(aod::mcparticle::mcCollisionId, coll_1.globalIndex(), cache); + auto groupMCAssociates = mcAssociates->sliceByCached(aod::mcparticle::mcCollisionId, coll_2.globalIndex(), cache); + for (const auto& [trigger, associate] : soa::combinations(soa::CombinationsFullIndexPolicy(groupMCTriggers, groupMCAssociates))) { + if (trigger.isPhysicalPrimary() && associate.isPhysicalPrimary()) { + + if (trigger.pdgCode() > 0) { + triggSign = 1; + } else if (trigger.pdgCode() < 0) { + triggSign = -1; + } + if (associate.pdgCode() > 0) { + assocSign = 1; + } else if (associate.pdgCode() < 0) { + assocSign = -1; + } + + deltaPhi = RecoDecay::constrainAngle(trigger.phi() - associate.phi(), -constants::math::PIHalf); + deltaEta = trigger.eta() - associate.eta(); + + if (std::abs(associate.pdgCode()) == kPiPlus) { + rMECorrRegistry.fill(HIST("hMixLambdaPion_MC"), deltaPhi, deltaEta, coll_1.bestCollisionCentFT0C(), coll_1.posZ(), triggSign, assocSign); + } else if (std::abs(associate.pdgCode()) == kKPlus) { + rMECorrRegistry.fill(HIST("hMixLambdaKaon_MC"), deltaPhi, deltaEta, coll_1.bestCollisionCentFT0C(), coll_1.posZ(), triggSign, assocSign); + } else if (std::abs(associate.pdgCode()) == kProton) { + rMECorrRegistry.fill(HIST("hMixLambdaProton_MC"), deltaPhi, deltaEta, coll_1.bestCollisionCentFT0C(), coll_1.posZ(), triggSign, assocSign); + } + } + } + } + // End of the MC Mixed-events Correlations + } + + void processMCGen(MyFilteredMCGenCollision const& collision, MyFilteredMCParticles const&, soa::SmallGroups const& recCollisions) + { + + if (recCollisions.size() == 1) { + for (const auto& recCollision : recCollisions) { + if (!acceptEvent(recCollision, false)) { + return; + } + } + } + + auto groupMCTracks = mcTracks->sliceByCached(aod::mcparticle::mcCollisionId, collision.globalIndex(), cache); + auto groupMCV0s = mcV0s->sliceByCached(aod::mcparticle::mcCollisionId, collision.globalIndex(), cache); + + // Start of the Monte-Carlo generated QA + for (const auto& particle : groupMCTracks) { + if (particle.isPhysicalPrimary()) { + + // Track efficiency - Generated + rMCRegistry.fill(HIST("hGenerated"), particle.pt(), particle.eta(), collision.bestCollisionCentFT0C()); + if (particle.pdgCode() == kPiPlus) { // Pos pions + rMCRegistry.fill(HIST("hGenPionP"), particle.pt(), particle.eta(), collision.bestCollisionCentFT0C()); + } else if (particle.pdgCode() == kPiMinus) { // Neg pions + rMCRegistry.fill(HIST("hGenPionN"), particle.pt(), particle.eta(), collision.bestCollisionCentFT0C()); + } else if (particle.pdgCode() == kKPlus) { // Pos kaons + rMCRegistry.fill(HIST("hGenKaonP"), particle.pt(), particle.eta(), collision.bestCollisionCentFT0C()); + } else if (particle.pdgCode() == kKMinus) { // Neg kaons + rMCRegistry.fill(HIST("hGenKaonN"), particle.pt(), particle.eta(), collision.bestCollisionCentFT0C()); + } else if (particle.pdgCode() == kProton) { // Pos protons + rMCRegistry.fill(HIST("hGenProtonP"), particle.pt(), particle.eta(), collision.bestCollisionCentFT0C()); + } else if (particle.pdgCode() == kProtonBar) { // Neg protons + rMCRegistry.fill(HIST("hGenProtonN"), particle.pt(), particle.eta(), collision.bestCollisionCentFT0C()); + } + } + } + + for (const auto& particle : groupMCV0s) { + if (particle.isPhysicalPrimary()) { + + // V0 efficiency - Generated + if (particle.pdgCode() == kLambda0) { // Lambdas + rMCRegistry.fill(HIST("hGenLambdaP"), particle.pt(), particle.eta(), collision.bestCollisionCentFT0C()); + } else if (particle.pdgCode() == kLambda0Bar) { // AntiLambdas + rMCRegistry.fill(HIST("hGenLambdaN"), particle.pt(), particle.eta(), collision.bestCollisionCentFT0C()); + } + } + } + // End of the Monte-Carlo generated QA + } + + void processMCRec(MyFilteredMCRecCollisions::iterator const& collision, MyMCV0s const& v0s, MyFilteredMCTracks const& tracks, aod::McCollisions const&, aod::McParticles const&) + { + + if (!acceptEvent(collision, false) || !collision.has_mcCollision()) { + return; + } + + // Start of the Monte-Carlo reconstructed QA + for (const auto& track : tracks) { + + if (!track.has_mcParticle()) { + continue; + } + auto particle = track.mcParticle(); + + // Track efficiency - Reconstructed + rMCRegistry.fill(HIST("hReconstructed"), track.pt(), track.eta(), collision.centFT0C()); + if (particle.pdgCode() == kPiPlus) { // Pos pions + rMCRegistry.fill(HIST("hRecPionP"), track.pt(), track.eta(), collision.centFT0C()); + } else if (particle.pdgCode() == kPiMinus) { // Neg pions + rMCRegistry.fill(HIST("hRecPionN"), track.pt(), track.eta(), collision.centFT0C()); + } else if (particle.pdgCode() == kKPlus) { // Pos kaons + rMCRegistry.fill(HIST("hRecKaonP"), track.pt(), track.eta(), collision.centFT0C()); + } else if (particle.pdgCode() == kKMinus) { // Neg kaons + rMCRegistry.fill(HIST("hRecKaonN"), track.pt(), track.eta(), collision.centFT0C()); + } else if (particle.pdgCode() == kProton) { // Pos protons + rMCRegistry.fill(HIST("hRecProtonP"), track.pt(), track.eta(), collision.centFT0C()); + } else if (particle.pdgCode() == kProtonBar) { // Neg protons + rMCRegistry.fill(HIST("hRecProtonN"), track.pt(), track.eta(), collision.centFT0C()); + } + + if (trackFilters(track)) { + + // Track efficiency - Reconstructed & PID filters applied + assocPID = trackPID(track); + rMCRegistry.fill(HIST("hIdentified"), track.pt(), track.eta(), collision.centFT0C()); + if (assocPID[0] == pionID && track.sign() > 0) { // Pos pions + rMCRegistry.fill(HIST("hPIDPionP"), track.pt(), track.eta(), collision.centFT0C()); + } else if (assocPID[0] == pionID && track.sign() < 0) { // Neg pions + rMCRegistry.fill(HIST("hPIDPionN"), track.pt(), track.eta(), collision.centFT0C()); + } else if (assocPID[0] == kaonID && track.sign() > 0) { // Pos kaons + rMCRegistry.fill(HIST("hPIDKaonP"), track.pt(), track.eta(), collision.centFT0C()); + } else if (assocPID[0] == kaonID && track.sign() < 0) { // Neg kaons + rMCRegistry.fill(HIST("hPIDKaonN"), track.pt(), track.eta(), collision.centFT0C()); + } else if (assocPID[0] == protonID && track.sign() > 0) { // Pos protons + rMCRegistry.fill(HIST("hPIDProtonP"), track.pt(), track.eta(), collision.centFT0C()); + } else if (assocPID[0] == protonID && track.sign() < 0) { // Neg protons + rMCRegistry.fill(HIST("hPIDProtonN"), track.pt(), track.eta(), collision.centFT0C()); + } + + // Purity (PID) + if (track.sign() > 0) { // Positive tracks + if (assocPID[0] == pionID) { // Pions + rMCRegistry.fill(HIST("hSelectPionP"), track.pt()); + if (particle.pdgCode() == kPiPlus) { + rMCRegistry.fill(HIST("hTrueSelectPionP"), track.pt()); + } + } else if (assocPID[0] == kaonID) { // Kaons + rMCRegistry.fill(HIST("hSelectKaonP"), track.pt()); + if (particle.pdgCode() == kKPlus) { + rMCRegistry.fill(HIST("hTrueSelectKaonP"), track.pt()); + } + } else if (assocPID[0] == protonID) { // Protons + rMCRegistry.fill(HIST("hSelectProtonP"), track.pt()); + if (particle.pdgCode() == kProton) { + rMCRegistry.fill(HIST("hTrueSelectProtonP"), track.pt()); + } + } + } else if (track.sign() < 0) { // Negative tracks + if (assocPID[0] == pionID) { // Pions + rMCRegistry.fill(HIST("hSelectPionN"), track.pt()); + if (particle.pdgCode() == kPiMinus) { + rMCRegistry.fill(HIST("hTrueSelectPionN"), track.pt()); + } + } else if (assocPID[0] == kaonID) { // Kaons + rMCRegistry.fill(HIST("hSelectKaonN"), track.pt()); + if (particle.pdgCode() == kKMinus) { + rMCRegistry.fill(HIST("hTrueSelectKaonN"), track.pt()); + } + } else if (assocPID[0] == protonID) { // Protons + rMCRegistry.fill(HIST("hSelectProtonN"), track.pt()); + if (particle.pdgCode() == kProtonBar) { + rMCRegistry.fill(HIST("hTrueSelectProtonN"), track.pt()); + } + } + } + } + } + + for (const auto& v0 : v0s) { + + if (!v0.has_mcParticle()) { + continue; + } + + if (v0Filters(collision, v0, tracks)) { + + v0Efficiency = v0Eff(hEffLambdas, v0, collision.centFT0C()); + + // V0 efficiency - Reconstructed + if (v0Sign(v0) == 1) { // Lambdas + candMass = v0.mLambda(); + rQARegistry.fill(HIST("hInvMassLambda_MC"), v0.mLambda(), v0.pt(), collision.centFT0C(), 1. / v0Efficiency); + rMCRegistry.fill(HIST("hRecLambdaP"), v0.pt(), v0.eta(), collision.centFT0C()); + } else if (v0Sign(v0) == -1) { // AntiLambdas + candMass = v0.mAntiLambda(); + rQARegistry.fill(HIST("hInvMassAntiLambda_MC"), v0.mAntiLambda(), v0.pt(), collision.centFT0C(), 1. / v0Efficiency); + rMCRegistry.fill(HIST("hRecLambdaN"), v0.pt(), v0.eta(), collision.centFT0C()); + } + } + } + // End of the Monte-Carlo reconstructed QA + } + + PROCESS_SWITCH(ThreeParticleCorrelations, processSame, "Process same-event correlations", true); + PROCESS_SWITCH(ThreeParticleCorrelations, processMixed, "Process mixed-event correlations", true); + PROCESS_SWITCH(ThreeParticleCorrelations, processMCSame, "Process MC same-event correlations", false); + PROCESS_SWITCH(ThreeParticleCorrelations, processMCMixed, "Process MC mixed-event correlations", false); + PROCESS_SWITCH(ThreeParticleCorrelations, processMCGen, "Process Monte-Carlo, generator level", false); + PROCESS_SWITCH(ThreeParticleCorrelations, processMCRec, "Process Monte-Carlo, reconstructed level", false); + + //========================================================================================================================================================================================================================================================================== + + double getMagneticField(uint64_t timestamp) + { + static parameters::GRPMagField* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp("GLO/Config/GRPMagField", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + } + + return 0.1 * (grpo->getNominalL3Field()); // 1 T = 10 kG + } + + template + double v0Eff(TH3D** efficiencies, const V0Cand& v0, double centrality) + { + + int index = -999; + if (v0Sign(v0) > 0) { + index = 0; + } else if (v0Sign(v0) < 0) { + index = 1; + } + + double efficiency = efficiencies[index]->GetBinContent(efficiencies[index]->FindBin(v0.pt(), v0.eta(), centrality)); + if (efficiency > 0) { + return efficiency; + } else { + return 1.0; + } + } + + template + double trackEff(TH3D** efficiencies, const TrackCand& track, double centrality) + { + + int index = -999; + if (track.sign() > 0) { + index = 0; + } else if (track.sign() < 0) { + index = 1; + } + + double efficiency = efficiencies[index]->GetBinContent(efficiencies[index]->FindBin(track.pt(), track.eta(), centrality)); + if (efficiency > 0) { + return efficiency; + } else { + return 1.0; + } + } + + template + int v0Sign(const V0Cand& v0) + { + + if (std::abs(v0.mLambda() - MassLambda0) <= std::abs(v0.mAntiLambda() - MassLambda0)) { + return 1; + } else if (std::abs(v0.mLambda() - MassLambda0) > std::abs(v0.mAntiLambda() - MassLambda0)) { + return -1; + } + + return 0; + } + + template + double* trackPID(const TrackCand& track) + { + + static double pid[2]; // {PID, NSigma} + + double nSigma[3]; + double nSigmaTOF[3]; + nSigmaTOF[0] = track.tofNSigmaPi(); + nSigmaTOF[1] = track.tofNSigmaKa(); + nSigmaTOF[2] = track.tofNSigmaPr(); + + nSigma[0] = std::abs(nSigmaTOF[0]); + nSigma[1] = std::abs(nSigmaTOF[1]); + nSigma[2] = std::abs(nSigmaTOF[2]); + + if (nSigma[0] <= std::min(nSigma[1], nSigma[2])) { // Pions + pid[0] = pionID; + pid[1] = nSigmaTOF[0]; + } else if (nSigma[1] <= std::min(nSigma[0], nSigma[2])) { // Kaons + pid[0] = kaonID; + pid[1] = nSigmaTOF[1]; + } else if (nSigma[2] < std::min(nSigma[0], nSigma[1])) { // Protons + pid[0] = protonID; + pid[1] = nSigmaTOF[2]; + } + + return pid; + } + + //========================================================================================================================================================================================================================================================================== + + template + bool acceptEvent(const Col& col, bool FillHist) // Event filter + { + + if (FillHist) { + rQARegistry.fill(HIST("hNEvents"), 0.5); + } + + if (!col.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { // kIsGoodZvtxFT0vsPV + return false; + } + if (FillHist) { + rQARegistry.fill(HIST("hNEvents"), 1.5); + } + + if (!col.selection_bit(aod::evsel::kNoSameBunchPileup)) { // kNoSameBunchPileup + return false; + } + if (FillHist) { + rQARegistry.fill(HIST("hNEvents"), 2.5); + } + + return true; + } + + template + bool v0Filters(const Col& col, const V0Cand& v0, T const&) // V0 filter + { + + // Kinematic cuts + if (v0.pt() <= v0PtMin || v0.pt() >= v0PtMax || std::abs(v0.eta()) >= v0EtaMax) { + return false; + } + + // Daughter cuts + auto posDaughter = v0.template posTrack_as(); + auto negDaughter = v0.template negTrack_as(); + if (std::abs(posDaughter.eta()) >= trackEtaMax || std::abs(negDaughter.eta()) >= trackEtaMax) { + return false; + } + if (posDaughter.tpcNClsCrossedRows() <= tpcNCrossedRowsMin || negDaughter.tpcNClsCrossedRows() <= tpcNCrossedRowsMin) { + return false; + } + if (v0Sign(v0) == 1) { + if (std::abs(posDaughter.tpcNSigmaPr()) >= nSigma5 || std::abs(negDaughter.tpcNSigmaPi()) >= nSigma5) { + return false; + } + if (std::abs(v0.dcapostopv()) <= dcaProtonMin || std::abs(v0.dcanegtopv()) <= dcaPionMin) { + return false; + } + } else if (v0Sign(v0) == -1) { + if (std::abs(posDaughter.tpcNSigmaPi()) >= nSigma5 || std::abs(negDaughter.tpcNSigmaPr()) >= nSigma5) { + return false; + } + if (std::abs(v0.dcapostopv()) <= dcaPionMin || std::abs(v0.dcanegtopv()) <= dcaProtonMin) { + return false; + } + } + + // Topological cuts + float ctau = v0.distovertotmom(col.posX(), col.posY(), col.posZ()) * MassLambda0; + if (v0.v0radius() <= decayRMin) { + return false; + } + if (ctau >= ctauMax) { + return false; + } + if (v0.v0cosPA() <= cosPAMin) { + return false; + } + if (v0.dcaV0daughters() >= dcaV0DauMax) { + return false; + } + + return true; + } + + template + bool trackFilters(const TrackCand& track) // Track filter + { + + if (!track.hasTOF()) { + return false; + } + + if (trackPID(track)[0] == pionID) { // Pions + if (std::abs(track.tpcNSigmaPi()) >= nSigma4) { + return false; + } + if (track.pt() < pionPtMin) { + return false; + } else if (track.pt() > pionPtMin && track.pt() < pionPtMid) { + if (std::abs(track.tofNSigmaPi()) >= nSigma4) { + return false; + } + } else if (track.pt() > pionPtMid && track.pt() < pionPtMax) { + if (track.tofNSigmaPi() <= -nSigma4 || track.tofNSigmaPi() >= nSigma0) { + return false; + } + } else if (track.pt() > pionPtMax) { + return false; + } + + } else if (trackPID(track)[0] == kaonID) { // Kaons + if (std::abs(track.tpcNSigmaKa()) >= nSigma4) { + return false; + } + if (track.pt() < kaonPtMin) { + return false; + } else if (track.pt() > kaonPtMin && track.pt() < kaonPtMid1) { + if (std::abs(track.tofNSigmaKa()) >= nSigma4) { + return false; + } + } else if (track.pt() > kaonPtMid1 && track.pt() < kaonPtMid2) { + if (track.tofNSigmaKa() <= -nSigma2 || track.tofNSigmaKa() >= nSigma4) { + return false; + } + } else if (track.pt() > kaonPtMid2 && track.pt() < kaonPtMax) { + if (track.tofNSigmaKa() <= nSigma0 || track.tofNSigmaKa() >= nSigma4) { + return false; + } + } else if (track.pt() > kaonPtMax) { + return false; + } + + } else if (trackPID(track)[0] == protonID) { // Protons + if (std::abs(track.tpcNSigmaPr()) >= nSigma4) { + return false; + } + if (track.pt() < protonPtMin) { + return false; + } else if (track.pt() > protonPtMin && track.pt() < protonPtMid) { + if (track.tofNSigmaPr() <= -nSigma2 || track.tofNSigmaPr() >= nSigma4) { + return false; + } + } else if (track.pt() > protonPtMid && track.pt() < protonPtMax) { + if (std::abs(track.tofNSigmaPr()) >= nSigma4) { + return false; + } + } else if (track.pt() > protonPtMax) { + if (track.tofNSigmaPr() <= -nSigma2 || track.tofNSigmaPr() >= nSigma4) { + return false; + } + } + } + + return true; + } + + template + bool correlationFilters(const V0Cand& v0, const TrackCand& track) // Correlation filter + { + + if (track.globalIndex() == v0.posTrackId() || track.globalIndex() == v0.negTrackId()) { + return false; + } + + return true; + } + + template + bool fakeV0Filter(const V0Cand& v0, const TrackCand& track) + { + + if (confFakeV0Switch) { + + if (trackPID(track)[0] == kaonID) { // Kaons + return true; + } + + std::array massArray; + std::array dMomArray; + std::array aMomArray = track.pVector(); + if (trackPID(track)[0] == pionID) { + massArray = {MassProton, MassPionCharged}; + + if (v0Sign(v0) == 1 && track.sign() == -1) { // Lambda - Pi_min + const auto& dTrack = v0.template posTrack_as(); + dMomArray = dTrack.pVector(); + } else if (v0Sign(v0) == -1 && track.sign() == 1) { // Antilambda - Pi_plus + const auto& dTrack = v0.template negTrack_as(); + dMomArray = dTrack.pVector(); + } + } else if (trackPID(track)[0] == protonID) { + massArray = {MassPionCharged, MassProton}; + + if (v0Sign(v0) == 1 && track.sign() == 1) { // Lambda - Proton + const auto& dTrack = v0.template negTrack_as(); + dMomArray = dTrack.pVector(); + } else if (v0Sign(v0) == -1 && track.sign() == -1) { // Antilambda - Antiproton + const auto& dTrack = v0.template posTrack_as(); + dMomArray = dTrack.pVector(); + } + } + + double invMass = RecoDecay::m(std::array{dMomArray, aMomArray}, massArray); + if (invMass >= MassLambda0 - 4 * dGaussSigma && invMass <= MassLambda0 + 4 * dGaussSigma) { + return false; + } + } + + return true; + } + + template + bool radialDistanceFilter(const V0Cand& v0, const TrackCand& track, double B, bool Mix) + { + + bool pass = true; + if (confRDSwitch) { + + auto proton = v0.template posTrack_as(); + if (v0Sign(v0) == -1) { + proton = v0.template negTrack_as(); + } + + double dEta = proton.eta() - track.eta(); + if (std::abs(dEta) > dEtaMax) { + return pass; + } + + double dPhiStar; + double dPhi = proton.phi() - track.phi(); + double phaseProton = (-0.3 * B * proton.sign()) / (2 * proton.pt()); + double phaseTrack = (-0.3 * B * track.sign()) / (2 * track.pt()); + + double dPhiStarMean = 0; + + // Start of the TPC radius loop + for (double r = rMin; r <= rMax; r += 0.01) { + dPhiStar = RecoDecay::constrainAngle(dPhi + std::asin(phaseProton * r) - std::asin(phaseTrack * r), -constants::math::PIHalf); + + if (r == rMin) { + if (!Mix) { // Same-event + if (proton.sign() * track.sign() == -1) { // OS (Electric charge) + rPhiStarRegistry.fill(HIST("hSEPhiStarIR_OS"), dPhiStar, dEta); + } else if (proton.sign() * track.sign() == 1) { // SS (Electric charge) + rPhiStarRegistry.fill(HIST("hSEPhiStarIR_SS"), dPhiStar, dEta); + if (proton.sign() == 1) { // Positive + rPhiStarRegistry.fill(HIST("hSEPhiStarIR_SSP"), dPhiStar, dEta); + } else if (proton.sign() == -1) { // Negative + rPhiStarRegistry.fill(HIST("hSEPhiStarIR_SSN"), dPhiStar, dEta); + } + } + + } else { // Mixed-event + if (proton.sign() * track.sign() == -1) { // OS (Electric charge) + rPhiStarRegistry.fill(HIST("hMEPhiStarIR_OS"), dPhiStar, dEta); + } else if (proton.sign() * track.sign() == 1) { // SS (Electric charge) + rPhiStarRegistry.fill(HIST("hMEPhiStarIR_SS"), dPhiStar, dEta); + if (proton.sign() == 1) { // Positive + rPhiStarRegistry.fill(HIST("hMEPhiStarIR_SSP"), dPhiStar, dEta); + } else if (proton.sign() == -1) { // Negative + rPhiStarRegistry.fill(HIST("hMEPhiStarIR_SSN"), dPhiStar, dEta); + } + } + } + + if (proton.sign() * track.sign() == -1) { // OS (Electric charge) + if (std::abs(dEta) < dEtaMin && std::abs(dPhiStar) < dPhiStarMinOS) { + pass = false; + } + } + } + + dPhiStarMean += (dPhiStar / 170); + } + // End of the TPC radius loop + + if (!Mix) { // Same-event + if (proton.sign() * track.sign() == -1) { // OS (Electric charge) + rPhiStarRegistry.fill(HIST("hSEPhiStarMean_OS"), dPhiStarMean, dEta); + } else if (proton.sign() * track.sign() == 1) { // SS (Electric charge) + rPhiStarRegistry.fill(HIST("hSEPhiStarMean_SS"), dPhiStarMean, dEta); + if (proton.sign() == 1) { // Positive + rPhiStarRegistry.fill(HIST("hSEPhiStarMean_SSP"), dPhiStarMean, dEta); + } else if (proton.sign() == -1) { // Negative + rPhiStarRegistry.fill(HIST("hSEPhiStarMean_SSN"), dPhiStarMean, dEta); + } + } + + } else { // Mixed-event + if (proton.sign() * track.sign() == -1) { // OS (Electric charge) + rPhiStarRegistry.fill(HIST("hMEPhiStarMean_OS"), dPhiStarMean, dEta); + } else if (proton.sign() * track.sign() == 1) { // SS (Electric charge) + rPhiStarRegistry.fill(HIST("hMEPhiStarMean_SS"), dPhiStarMean, dEta); + if (proton.sign() == 1) { // Positive + rPhiStarRegistry.fill(HIST("hMEPhiStarMean_SSP"), dPhiStarMean, dEta); + } else if (proton.sign() == -1) { // Negative + rPhiStarRegistry.fill(HIST("hMEPhiStarMean_SSN"), dPhiStarMean, dEta); + } + } + } + + if (proton.sign() * track.sign() == 1) { // SS (Electric charge) + if (std::abs(dEta) < dEtaMin && std::abs(dPhiStarMean) < dPhiStarMinSS) { + pass = false; + } + } + } + + return pass; + } +}; + +//============================================================================================================================================================================================================================================================================ + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} + +//============================================================================================================================================================================================================================================================================ diff --git a/PWGCF/TableProducer/CMakeLists.txt b/PWGCF/TableProducer/CMakeLists.txt index 1bfef915ff3..6438d45a5fe 100644 --- a/PWGCF/TableProducer/CMakeLists.txt +++ b/PWGCF/TableProducer/CMakeLists.txt @@ -19,7 +19,7 @@ o2physics_add_dpl_workflow(filter-correlations-2prong PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(dptdpt-filter - SOURCES dptdptfilter.cxx +o2physics_add_dpl_workflow(dpt-dpt-filter + SOURCES dptDptFilter.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) diff --git a/PWGCF/TableProducer/dptdptfilter.cxx b/PWGCF/TableProducer/dptDptFilter.cxx similarity index 83% rename from PWGCF/TableProducer/dptdptfilter.cxx rename to PWGCF/TableProducer/dptDptFilter.cxx index 316415ef479..30f55cf3c3f 100644 --- a/PWGCF/TableProducer/dptdptfilter.cxx +++ b/PWGCF/TableProducer/dptDptFilter.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file dptdptfilter.cxx +/// \file dptDptFilter.cxx /// \brief Filters collisions and tracks according to selection criteria /// \author victor.gonzalez.sebastian@gmail.com @@ -46,7 +46,7 @@ #include #include -#include "PWGCF/TableProducer/dptdptfilter.h" +#include "PWGCF/TableProducer/dptDptFilter.h" using namespace o2; using namespace o2::framework; @@ -105,6 +105,8 @@ const char* eventSelectionSteps[knCollisionSelectionFlags] = { "ISVERTEXITSTPC", "ISVERTEXTOFMATCHED", "ISVERTEXTRDMATCHED", + "NOCOLLINTIMERANGE", + "NOCOLLINROF", "OCCUPANCY", "ISGOODITSLAYER3", "ISGOODITSLAYER0123", @@ -208,6 +210,8 @@ struct Multiplicity { MultEst classestimator = kV0M; + static constexpr float kForMultiplicityPtLowLimit = 0.001f; + static constexpr float kForMultiplicityPtHighLimit = 50.0f; float multiplicityClass = -1.0; float multiplicity = 0.0; bool inelgth0 = false; @@ -275,16 +279,16 @@ struct Multiplicity { case kProton: /* not clear if we should use IsPhysicalPrimary here */ /* TODO: adapt to FT0M Run 3 and other estimators */ - if (0.001 < p.pt() && p.pt() < 50.0) { - if (p.eta() < 1.0 && -1.0 < p.eta()) { + if (kForMultiplicityPtLowLimit < p.pt() && p.pt() < kForMultiplicityPtHighLimit) { + if (p.eta() < 1.0f && -1.0f < p.eta()) { inelgth0 = true; } - addTo(p, v0am, 2.8, 5.1); - addTo(p, v0cm, -3.7, -1.7); - addTo(p, cl1m, -1.4, 1.4); - addTo(p, cl1EtaGapM, -1.4, -0.8); - addTo(p, cl1EtaGapM, 0.8, 1.4); - addTo(p, dNchdEta, -0.5, 0.5); + addTo(p, v0am, 2.8f, 5.1f); + addTo(p, v0cm, -3.7f, -1.7f); + addTo(p, cl1m, -1.4f, 1.4f); + addTo(p, cl1EtaGapM, -1.4f, -0.8f); + addTo(p, cl1EtaGapM, 0.8f, 1.4f); + addTo(p, dNchdEta, -0.5f, 0.5f); nPart++; } break; @@ -357,24 +361,31 @@ struct Multiplicity { struct DptDptFilter { struct : ConfigurableGroup { - Configurable cfgCCDBUrl{"input_ccdburl", "http://ccdb-test.cern.ch:8080", "The CCDB url for the input file"}; - Configurable cfgCCDBPathName{"input_ccdbpath", "", "The CCDB path for the input file. Default \"\", i.e. don't load from CCDB"}; - Configurable cfgCCDBDate{"input_ccdbdate", "20220307", "The CCDB date for the input file"}; - Configurable cfgCCDBPeriod{"input_ccdbperiod", "LHC22o", "The CCDB dataset period for the input file"}; + Configurable cfgCCDBUrl{"cfgCCDBUrl", "http://ccdb-test.cern.ch:8080", "The CCDB url for the input file"}; + Configurable cfgCCDBPathName{"cfgCCDBPathName", "", "The CCDB path for the input file. Default \"\", i.e. don't load from CCDB"}; + Configurable cfgCCDBDate{"cfgCCDBDate", "20220307", "The CCDB date for the input file"}; + Configurable cfgCCDBPeriod{"cfgCCDBPeriod", "LHC22o", "The CCDB dataset period for the input file"}; } cfginputfile; - Configurable cfgFullDerivedData{"fullderiveddata", false, "Produce the full derived data for external storage. Default false"}; - Configurable cfgCentMultEstimator{"centmultestimator", "V0M", "Centrality/multiplicity estimator detector: V0M,CL0,CL1,FV0A,FT0M,FT0A,FT0C,NTPV,NOCM: none. Default V0M"}; - Configurable cfgOccupancyEstimation{"occestimation", "None", "Occupancy estimation: None, Tracks, FT0C. Default None"}; - Configurable cfgMaxOccupancy{"occmax", 1e6f, "Maximum allowed occupancy. Depends on the occupancy estimation"}; + Configurable cfgFullDerivedData{"cfgFullDerivedData", false, "Produce the full derived data for external storage. Default false"}; + Configurable cfgCentMultEstimator{"cfgCentMultEstimator", "V0M", "Centrality/multiplicity estimator detector: V0M,CL0,CL1,FV0A,FT0M,FT0A,FT0C,NTPV,NOCM: none. Default V0M"}; + struct : ConfigurableGroup { std::string prefix = "cfgEventSelection"; Configurable itsDeadMaps{"itsDeadMaps", "", "Level of inactive chips: nocheck(empty), goodIts3, goodIts0123, goodItsAll. Default empty"}; + Configurable minOrbit{"minOrbit", -1, "Lowest orbit to track"}; + Configurable maxOrbit{"maxOrbit", INT64_MAX, "Highest orbit to track"}; + struct : ConfigurableGroup { + std::string prefix = "cfgOccupancySelection"; + Configurable cfgOccupancyEstimation{"cfgOccupancyEstimation", "None", "Occupancy estimation: None, Tracks, FT0C. Default None"}; + Configurable cfgMinOccupancy{"cfgMinOccupancy", 0.0f, "Minimum allowed occupancy. Depends on the occupancy estimation"}; + Configurable cfgMaxOccupancy{"cfgMaxOccupancy", 1e6f, "Maximum allowed occupancy. Depends on the occupancy estimation"}; + } cfgOccupancySelection; } cfgEventSelection; - Configurable cfgSystem{"syst", "PbPb", "System: pp, PbPb, Pbp, pPb, XeXe, ppRun3, PbPbRun3. Default PbPb"}; - Configurable cfgDataType{"datatype", "data", "Data type: data, datanoevsel, MC, FastMC, OnTheFlyMC. Default data"}; - Configurable cfgTriggSel{"triggsel", "MB", "Trigger selection: MB,VTXTOFMATCHED,VTXTRDMATCHED,VTXTRDTOFMATCHED,None. Default MB"}; - Configurable cfgCentSpec{"centralities", "00-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80", "Centrality/multiplicity ranges in min-max separated by commas"}; - Configurable cfgOverallMinP{"overallminp", 0.0f, "The overall minimum momentum for the analysis. Default: 0.0"}; + Configurable cfgSystem{"cfgSystem", "PbPb", "System: pp, PbPb, Pbp, pPb, XeXe, ppRun3, PbPbRun3. Default PbPb"}; + Configurable cfgDataType{"cfgDataType", "data", "Data type: data, datanoevsel, MC, FastMC, OnTheFlyMC. Default data"}; + Configurable cfgTriggSel{"cfgTriggSel", "MB", "Trigger selection: MB,VTXTOFMATCHED,VTXTRDMATCHED,VTXTRDTOFMATCHED,None. Default MB"}; + Configurable cfgCentSpec{"cfgCentSpec", "00-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80", "Centrality/multiplicity ranges in min-max separated by commas"}; + Configurable cfgOverallMinP{"cfgOverallMinP", 0.0f, "The overall minimum momentum for the analysis. Default: 0.0"}; struct : ConfigurableGroup { std::string prefix = "cfgTpcExclusion"; Configurable method{"method", 0, "The method for excluding tracks within the TPC. 0: no exclusion; 1: static; 2: dynamic. Default: 0"}; @@ -383,10 +394,10 @@ struct DptDptFilter { Configurable negativeLowCut{"negativeLowCut", "pi/9.0 - (0.0892/x + 0.0251)", "The lower cut function for negative tracks"}; Configurable negativeUpCut{"negativeUpCut", "pi/9 - (0.0787/x - 0.0236)", "The upper cut function for negative tracks"}; } cfgTpcExclusion; - Configurable cfgBinning{"binning", + Configurable cfgBinning{"cfgBinning", {28, -7.0, 7.0, 18, 0.2, 2.0, 16, -0.8, 0.8, 72, 0.5}, "triplets - nbins, min, max - for z_vtx, pT, eta and phi, binning plus bin fraction of phi origin shift"}; - Configurable cfgTraceCollId0{"tracecollid0", false, "Trace particles in collisions id 0. Default false"}; + Configurable cfgTraceCollId0{"cfgTraceCollId0", false, "Trace particles in collisions id 0. Default false"}; OutputObj fOutput{"DptDptFilterCollisionsInfo", OutputObjHandlingPolicy::AnalysisObject}; @@ -426,8 +437,9 @@ struct DptDptFilter { fCentMultEstimator = getCentMultEstimator(cfgCentMultEstimator); } /* the occupancy selection */ - fOccupancyEstimation = getOccupancyEstimator(cfgOccupancyEstimation); - fMaxOccupancy = cfgMaxOccupancy; + fOccupancyEstimation = getOccupancyEstimator(cfgEventSelection.cfgOccupancySelection.cfgOccupancyEstimation); + fMinOccupancy = cfgEventSelection.cfgOccupancySelection.cfgMinOccupancy; + fMaxOccupancy = cfgEventSelection.cfgOccupancySelection.cfgMaxOccupancy; /* the ITS dead map check */ fItsDeadMapCheck = getItsDeadMapCheck(cfgEventSelection.itsDeadMaps); @@ -512,24 +524,27 @@ struct DptDptFilter { template void processReconstructed(CollisionObject const& collision, TracksObject const& ftracks, float centormult); - void processWithCent(aod::CollisionEvSelCent const& collision, DptDptFullTracks const& ftracks); + void processWithCent(aod::CollisionEvSelCent const& collision, DptDptFullTracks const& ftracks, const aod::BCsWithTimestamps&); PROCESS_SWITCH(DptDptFilter, processWithCent, "Process reco with centrality", false); - void processWithRun2Cent(aod::CollisionEvSelRun2Cent const& collision, DptDptFullTracks const& ftracks); + void processWithRun2Cent(aod::CollisionEvSelRun2Cent const& collision, DptDptFullTracks const& ftracks, const aod::BCsWithTimestamps&); PROCESS_SWITCH(DptDptFilter, processWithRun2Cent, "Process reco with Run !/2 centrality", false); - void processWithoutCent(aod::CollisionEvSel const& collision, DptDptFullTracks const& ftracks); + void processWithoutCent(aod::CollisionEvSel const& collision, DptDptFullTracks const& ftracks, const aod::BCsWithTimestamps&); PROCESS_SWITCH(DptDptFilter, processWithoutCent, "Process reco without centrality", false); - void processWithCentDetectorLevel(aod::CollisionEvSelCent const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&); + void processWithCentDetectorLevel(aod::CollisionEvSelCent const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&, const aod::BCsWithTimestamps&); PROCESS_SWITCH(DptDptFilter, processWithCentDetectorLevel, "Process MC detector level with centrality", false); - void processWithRun2CentDetectorLevel(aod::CollisionEvSelRun2Cent const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&); + void processWithRun2CentDetectorLevel(aod::CollisionEvSelRun2Cent const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&, const aod::BCsWithTimestamps&); PROCESS_SWITCH(DptDptFilter, processWithRun2CentDetectorLevel, "Process MC detector level with centrality", false); - void processWithoutCentDetectorLevel(aod::CollisionEvSel const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&); + void processWithoutCentDetectorLevel(aod::CollisionEvSel const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&, const aod::BCsWithTimestamps&); PROCESS_SWITCH(DptDptFilter, processWithoutCentDetectorLevel, "Process MC detector level without centrality", false); + void processWithoutCentWithoutEvSelDetectorLevel(soa::Join::iterator const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&, const aod::BCsWithTimestamps&); + PROCESS_SWITCH(DptDptFilter, processWithoutCentWithoutEvSelDetectorLevel, "Process MC detector level without centrality nor event selections", false); + template bool processGenerated(CollisionObject const& mccollision, ParticlesList const& mcparticles, float centormult); @@ -574,13 +589,16 @@ void DptDptFilter::processReconstructed(CollisionObject const& collision, Tracks LOGF(DPTDPTFILTERLOGCOLLISIONS, "DptDptFilterTask::processReconstructed(). New collision with %d tracks", ftracks.size()); float mult = extractMultiplicity(collision, fCentMultEstimator); + static const int32_t nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; fhCentMultB->Fill(tentativecentmult); fhMultB->Fill(mult); fhVertexZB->Fill(collision.posZ()); uint8_t acceptedevent = uint8_t(false); float centormult = tentativecentmult; - if (isEventSelected(collision, centormult)) { + int64_t orbit = collision.template bc_as().globalBC() / nBCsPerOrbit; + bool withinOrbitOfInterest = (cfgEventSelection.minOrbit <= orbit) && (orbit < cfgEventSelection.maxOrbit); + if (withinOrbitOfInterest && isEventSelected(collision, centormult)) { acceptedevent = true; fhCentMultA->Fill(centormult); fhMultA->Fill(mult); @@ -604,32 +622,37 @@ void DptDptFilter::processReconstructed(CollisionObject const& collision, Tracks } } -void DptDptFilter::processWithCent(aod::CollisionEvSelCent const& collision, DptDptFullTracks const& ftracks) +void DptDptFilter::processWithCent(aod::CollisionEvSelCent const& collision, DptDptFullTracks const& ftracks, aod::BCsWithTimestamps const&) { processReconstructed(collision, ftracks, getCentMultPercentile(collision)); } -void DptDptFilter::processWithRun2Cent(aod::CollisionEvSelRun2Cent const& collision, DptDptFullTracks const& ftracks) +void DptDptFilter::processWithRun2Cent(aod::CollisionEvSelRun2Cent const& collision, DptDptFullTracks const& ftracks, aod::BCsWithTimestamps const&) { processReconstructed(collision, ftracks, getCentMultPercentile(collision)); } -void DptDptFilter::processWithoutCent(aod::CollisionEvSel const& collision, DptDptFullTracks const& ftracks) +void DptDptFilter::processWithoutCent(aod::CollisionEvSel const& collision, DptDptFullTracks const& ftracks, aod::BCsWithTimestamps const&) { processReconstructed(collision, ftracks, 50.0); } -void DptDptFilter::processWithCentDetectorLevel(aod::CollisionEvSelCent const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&) +void DptDptFilter::processWithCentDetectorLevel(aod::CollisionEvSelCent const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&, aod::BCsWithTimestamps const&) { processReconstructed(collision, ftracks, getCentMultPercentile(collision)); } -void DptDptFilter::processWithRun2CentDetectorLevel(aod::CollisionEvSelRun2Cent const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&) +void DptDptFilter::processWithRun2CentDetectorLevel(aod::CollisionEvSelRun2Cent const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&, aod::BCsWithTimestamps const&) { processReconstructed(collision, ftracks, getCentMultPercentile(collision)); } -void DptDptFilter::processWithoutCentDetectorLevel(aod::CollisionEvSel const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&) +void DptDptFilter::processWithoutCentDetectorLevel(aod::CollisionEvSel const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&, aod::BCsWithTimestamps const&) +{ + processReconstructed(collision, ftracks, 50.0); +} + +void DptDptFilter::processWithoutCentWithoutEvSelDetectorLevel(soa::Join::iterator const& collision, DptDptFullTracksDetLevel const& ftracks, aod::McParticles const&, aod::BCsWithTimestamps const&) { processReconstructed(collision, ftracks, 50.0); } @@ -672,8 +695,9 @@ void DptDptFilter::processGeneratorLevel(aod::McCollision const& mccollision, if (tmpcollision.mcCollisionId() == mccollision.globalIndex()) { typename AllCollisions::iterator const& collision = allcollisions.iteratorAt(tmpcollision.globalIndex()); if (isEventSelected(collision, defaultcent)) { - fhTrueVertexZAA->Fill((mccollision.posZ())); - processGenerated(mccollision, mcparticles, defaultcent); + if (processGenerated(mccollision, mcparticles, defaultcent)) { + fhTrueVertexZAA->Fill((mccollision.posZ())); + } processed = true; break; /* TODO: only processing the first reconstructed accepted collision */ } @@ -772,27 +796,27 @@ struct DptDptFilterTracks { std::string cfgCCDBDate{"20220307"}; std::string cfgCCDBPeriod{"LHC22o"}; - Configurable cfgOutDebugInfo{"outdebuginfo", false, "Out detailed debug information per track into a text file. Default false"}; - Configurable cfgFullDerivedData{"fullderiveddata", false, "Produce the full derived data for external storage. Default false"}; - Configurable cfgTrackType{"trktype", 4, "Type of selected tracks: 0 = no selection;1 = Run2 global tracks FB96;3 = Run3 tracks;4 = Run3 tracks MM sel;5 = Run2 TPC only tracks;7 = Run 3 TPC only tracks;30-33 = any/two on 3 ITS,any/all in 7 ITS;40-43 same as 30-33 w tighter DCAxy;50-53 w tighter pT DCAz. Default 4"}; - Configurable cfgOnlyInOneSide{"onlyinoneside", false, "select tracks that don't cross the TPC central membrane. Default false"}; - Configurable cfgTraceDCAOutliers{"trackdcaoutliers", {false, 0.0, 0.0}, "Track the generator level DCAxy outliers: false/true, low dcaxy, up dcaxy. Default {false,0.0,0.0}"}; - Configurable cfgTraceOutOfSpeciesParticles{"trackoutparticles", false, "Track the particles which are not e,mu,pi,K,p: false/true. Default false"}; - Configurable cfgRecoIdMethod{"recoidmethod", 0, "Method for identifying reconstructed tracks: 0 No PID, 1 PID, 2 mcparticle, 3 mcparticle only primaries, 4 mcparticle only sec, 5 mcparicle only sec from decays, 6 mcparticle only sec from material. Default 0"}; - Configurable cfgTuneTrackSelection{"tunetracksel", {}, "Track selection: {useit: true/false, tpccls-useit, tpcxrws-useit, tpcxrfc-useit, tpcshcls-useit, dcaxy-useit, dcaz-useit}. Default {false,0.70,false,0.8,false,0.4,false,2.4,false,3.2,false}"}; - Configurable cfgPionPIDSelection{"pipidsel", + Configurable cfgOutDebugInfo{"cfgOutDebugInfo", false, "Out detailed debug information per track into a text file. Default false"}; + Configurable cfgFullDerivedData{"cfgFullDerivedData", false, "Produce the full derived data for external storage. Default false"}; + Configurable cfgTrackType{"cfgTrackType", 4, "Type of selected tracks: 0 = no selection;1 = Run2 global tracks FB96;3 = Run3 tracks;4 = Run3 tracks MM sel;5 = Run2 TPC only tracks;7 = Run 3 TPC only tracks;30-33 = any/two on 3 ITS,any/all in 7 ITS;40-43 same as 30-33 w tighter DCAxy;50-53 w tighter pT DCAz. Default 4"}; + Configurable cfgOnlyInOneSide{"cfgOnlyInOneSide", false, "select tracks that don't cross the TPC central membrane. Default false"}; + Configurable cfgTraceDCAOutliers{"cfgTraceDCAOutliers", {false, 0.0, 0.0}, "Track the generator level DCAxy outliers: false/true, low dcaxy, up dcaxy. Default {false,0.0,0.0}"}; + Configurable cfgTraceOutOfSpeciesParticles{"cfgTraceOutOfSpeciesParticles", false, "Track the particles which are not e,mu,pi,K,p: false/true. Default false"}; + Configurable cfgRecoIdMethod{"cfgRecoIdMethod", 0, "Method for identifying reconstructed tracks: 0 No PID, 1 PID, 2 mcparticle, 3 mcparticle only primaries, 4 mcparticle only sec, 5 mcparicle only sec from decays, 6 mcparticle only sec from material. Default 0"}; + Configurable cfgTuneTrackSelection{"cfgTuneTrackSelection", {}, "Track selection: {useit: true/false, tpccls-useit, tpcxrws-useit, tpcxrfc-useit, tpcshcls-useit, dcaxy-useit, dcaz-useit}. Default {false,0.70,false,0.8,false,0.4,false,2.4,false,3.2,false}"}; + Configurable cfgPionPIDSelection{"cfgPionPIDSelection", {}, "PID criteria for pions"}; - Configurable cfgKaonPIDSelection{"kapidsel", + Configurable cfgKaonPIDSelection{"cfgKaonPIDSelection", {}, "PID criteria for kaons"}; - Configurable cfgProtonPIDSelection{"prpidsel", + Configurable cfgProtonPIDSelection{"cfgProtonPIDSelection", {}, "PID criteria for protons"}; - Configurable cfgElectronPIDSelection{"elpidsel", + Configurable cfgElectronPIDSelection{"cfgElectronPIDSelection", {}, "PID criteria for electrons"}; - Configurable cfgMuonPIDSelection{"mupidsel", + Configurable cfgMuonPIDSelection{"cfgMuonPIDSelection", {}, "PID criteria for muons"}; @@ -801,6 +825,8 @@ struct DptDptFilterTracks { PIDSpeciesSelection pidselector; bool checkAmbiguousTracks = false; + std::vector particleReconstructed; + void init(InitContext& initContext) { LOGF(info, "DptDptFilterTracks::init()"); @@ -809,18 +835,18 @@ struct DptDptFilterTracks { /* update with the configurable values */ /* self configure the binning */ - getTaskOptionValue(initContext, "dpt-dpt-filter", "overallminp", overallminp, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mZVtxbins", zvtxbins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mZVtxmin", zvtxlow, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mZVtxmax", zvtxup, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPTbins", ptbins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPTmin", ptlow, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPTmax", ptup, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mEtabins", etabins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mEtamin", etalow, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mEtamax", etaup, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPhibins", phibins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPhibinshift", phibinshift, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgOverallMinP", overallminp, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mZVtxbins", zvtxbins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mZVtxmin", zvtxlow, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mZVtxmax", zvtxup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPTbins", ptbins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPTmin", ptlow, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPTmax", ptup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mEtabins", etabins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mEtamin", etalow, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mEtamax", etaup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPhibins", phibins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPhibinshift", phibinshift, false); TpcExclusionMethod tpcExclude = kNOEXCLUSION; ///< exclude tracks within the TPC according to this method std::string pLowCut; @@ -837,14 +863,25 @@ struct DptDptFilterTracks { tpcExclude = static_cast(tmpTpcExclude); } /* self configure the CCDB access to the input file */ - getTaskOptionValue(initContext, "dpt-dpt-filter", "input_ccdburl", cfgCCDBUrl, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "input_ccdbpath", cfgCCDBPathName, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "input_ccdbdate", cfgCCDBDate, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "input_ccdbperiod", cfgCCDBPeriod, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDBUrl", cfgCCDBUrl, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDBPathName", cfgCCDBPathName, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDBDate", cfgCCDBDate, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDBPeriod", cfgCCDBPeriod, false); + + /* create the output list which will own the task histograms */ + TList* fOutputList = new TList(); + fOutputList->SetOwner(true); + fOutput.setObject(fOutputList); /* the track types and combinations */ tracktype = cfgTrackType.value; - initializeTrackSelection(cfgTuneTrackSelection.value); + + /* incorporate configuration parameters to the output */ + fOutputList->Add(new TParameter("TrackType", cfgTrackType, 'f')); + fOutputList->Add(new TParameter("TrackOneCharge", 1, 'f')); + fOutputList->Add(new TParameter("TrackTwoCharge", -1, 'f')); + + DptDptTrackSelection::initializeTrackSelection(cfgTuneTrackSelection.value, fOutputList); traceDCAOutliers = cfgTraceDCAOutliers; traceOutOfSpeciesParticles = cfgTraceOutOfSpeciesParticles; recoIdMethod = cfgRecoIdMethod; @@ -857,9 +894,9 @@ struct DptDptFilterTracks { /* self configure system type and data type */ /* if the system type is not known at this time, we have to put the initialization somewhere else */ std::string tmpstr; - getTaskOptionValue(initContext, "dpt-dpt-filter", "syst", tmpstr, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgSystem", tmpstr, false); fSystem = getSystemType(tmpstr); - getTaskOptionValue(initContext, "dpt-dpt-filter", "datatype", tmpstr, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgDataType", tmpstr, false); fDataType = getDataType(tmpstr); /* required ambiguous tracks checks? */ @@ -886,16 +923,6 @@ struct DptDptFilterTracks { insertInPIDselector(cfgKaonPIDSelection, 3); insertInPIDselector(cfgProtonPIDSelection, 4); - /* create the output list which will own the task histograms */ - TList* fOutputList = new TList(); - fOutputList->SetOwner(true); - fOutput.setObject(fOutputList); - - /* incorporate configuration parameters to the output */ - fOutputList->Add(new TParameter("TrackType", cfgTrackType, 'f')); - fOutputList->Add(new TParameter("TrackOneCharge", 1, 'f')); - fOutputList->Add(new TParameter("TrackTwoCharge", -1, 'f')); - if ((fDataType == kData) || (fDataType == kDataNoEvtSel) || (fDataType == kMC)) { /* create the reconstructed data histograms */ fhPB = new TH1F("fHistPB", "p distribution for reconstructed before;p (GeV/c);dN/dp (c/GeV)", 100, 0.0, 15.0); @@ -1201,6 +1228,26 @@ struct DptDptFilterTracks { tracks.size()); } + /* filter the tracks but not creating the filtered tracks table */ + /* the aim is to fill the structure of the generated particles */ + /* that were reconstructed */ + template + void filterTracksSpecial(soa::Join const&, passedtracks const& tracks) + { + /* do check for special adjustments */ + getCCDBInformation(); + + for (auto const& track : tracks) { + int8_t pid = -1; + if (track.has_collision() && (track.template collision_as>()).collisionaccepted()) { + pid = selectTrack>(track); + if (!(pid < 0)) { + particleReconstructed[track.mcParticleId()] = true; + } + } + } + } + /* TODO: for the time being the full derived data is still not supported */ /* for doing that we need to get the index of the associated mc collision */ void filterParticles(soa::Join const& gencollisions, aod::McParticles const& particles) @@ -1250,6 +1297,59 @@ struct DptDptFilterTracks { particles.size()); } + /* we produce the derived particle table incoporating only the particles that were accepted but not were reconstructed */ + void filterParticlesSpecial(soa::Join const& gencollisions, aod::McParticles const& particles) + { + using namespace dptdptfilter; + + int acceptedparticles = 0; + int acceptedcollisions = 0; + if (!fullDerivedData) { + gentracksinfo.reserve(particles.size()); + } + + for (auto const& gencoll : gencollisions) { + if (gencoll.collisionaccepted()) { + acceptedcollisions++; + } + } + + for (auto const& particle : particles) { + int8_t pid = -1; + auto pdgpart = fPDG->GetParticle(particle.pdgCode()); + float charge = pdgpart != nullptr ? getCharge(pdgpart->Charge()) : 0; + + if (charge != 0) { + if (particle.has_mcCollision() && (particle.template mcCollision_as>()).collisionaccepted()) { + auto mccollision = particle.template mcCollision_as>(); + pid = selectParticle(particle, mccollision); + if (!(pid < 0)) { + if (particleReconstructed[particle.globalIndex()]) { + /* the particle was reconstructed and accepted, reject it */ + pid = -1; + } else { + acceptedparticles++; + } + } + } + } else { + if ((particle.mcCollisionId() == 0) && traceCollId0) { + LOGF(DPTDPTFILTERLOGTRACKS, "Particle %d with fractional charge or equal to zero", particle.globalIndex()); + } + } + if (!fullDerivedData) { + gentracksinfo(pid); + } + } + LOGF(DPTDPTFILTERLOGCOLLISIONS, + "Processed %d accepted generated collisions out of a total of %d with %d accepted particles out of a " + "total of %d", + acceptedcollisions, + gencollisions.size(), + acceptedparticles, + particles.size()); + } + template void doFilterTracks(soa::Join const& collisions, passedtracks const& tracks) { @@ -1339,6 +1439,26 @@ struct DptDptFilterTracks { filterParticles(gencollisions, particles); } PROCESS_SWITCH(DptDptFilterTracks, filterGenerated, "Generated particles filtering", true) + + void filterGeneratedNotReconstructed(soa::Join const& gencollisions, aod::McParticles const& particles, + soa::Join& collisions, DptDptFullTracksPIDDetLevel const& tracks) + { + particleReconstructed.resize(particles.size()); + filterTracksSpecial(collisions, tracks); + filterParticlesSpecial(gencollisions, particles); + particleReconstructed.clear(); + } + PROCESS_SWITCH(DptDptFilterTracks, filterGeneratedNotReconstructed, "Generated particles filtering selecting not reconstructed using PID", false) + + void filterGeneratedNotReconstructedWithoutPID(soa::Join const& gencollisions, aod::McParticles const& particles, + soa::Join& collisions, DptDptFullTracksDetLevel const& tracks) + { + particleReconstructed.resize(particles.size()); + filterTracksSpecial(collisions, tracks); + filterParticlesSpecial(gencollisions, particles); + particleReconstructed.clear(); + } + PROCESS_SWITCH(DptDptFilterTracks, filterGeneratedNotReconstructedWithoutPID, "Generated particles filtering selecting not reconstructed inclusive", false) }; template @@ -1418,8 +1538,14 @@ int8_t DptDptFilterTracks::selectTrack(TrackObject const& track) template int8_t DptDptFilterTracks::selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track) { + enum AmbiguityTypes { + kNoAmbiguous = 0, /* no ambiguous track */ + kOnePossibilitySame = 1, /* the track is present in the collision association table but has the same associated collision so the track is not ambiguous */ + kOnePossibilityDifferent = 2, /* the track is present in the collision association table and has a diffetent collision associeted so the track is ambiguous */ + kMoreThanOnePossibility = 3 /* the track is associated to more than one collision in the collision association table so the track is ambiguous */ + }; bool ambiguoustrack = false; - int ambtracktype = 0; /* no ambiguous */ + AmbiguityTypes ambtracktype = kNoAmbiguous; std::vector zvertexes{}; /* ambiguous tracks checks if required */ if constexpr (has_type_v) { @@ -1429,17 +1555,17 @@ int8_t DptDptFilterTracks::selectTrackAmbiguousCheck(CollisionObjects const& col /* ambiguous track! */ ambiguoustrack = true; /* in principle we should not be here because the track is associated to two collisions at least */ - ambtracktype = 2; + ambtracktype = kOnePossibilityDifferent; zvertexes.push_back(collisions.iteratorAt(track.collisionId()).posZ()); zvertexes.push_back(collisions.iteratorAt(track.compatibleCollIds()[0]).posZ()); } else { /* we consider the track as no ambiguous */ - ambtracktype = 1; + ambtracktype = kOnePossibilitySame; } } else { /* ambiguous track! */ ambiguoustrack = true; - ambtracktype = 3; + ambtracktype = kMoreThanOnePossibility; /* the track is associated to more than one collision */ for (const auto& collIdx : track.compatibleCollIds()) { zvertexes.push_back(collisions.iteratorAt(collIdx).posZ()); @@ -1454,7 +1580,7 @@ int8_t DptDptFilterTracks::selectTrackAmbiguousCheck(CollisionObjects const& col fhAmbiguousTrackType->Fill(ambtracktype, multiplicityClass); fhAmbiguousTrackPt->Fill(track.pt(), multiplicityClass); fhAmbiguityDegree->Fill(zvertexes.size(), multiplicityClass); - if (ambtracktype == 2) { + if (ambtracktype == kOnePossibilityDifferent) { fhCompatibleCollisionsZVtxRms->Fill(-computeRMS(zvertexes), multiplicityClass); } else { fhCompatibleCollisionsZVtxRms->Fill(computeRMS(zvertexes), multiplicityClass); diff --git a/PWGCF/TableProducer/dptdptfilter.h b/PWGCF/TableProducer/dptDptFilter.h similarity index 75% rename from PWGCF/TableProducer/dptdptfilter.h rename to PWGCF/TableProducer/dptDptFilter.h index 9ade7e92c00..18076266f1a 100644 --- a/PWGCF/TableProducer/dptdptfilter.h +++ b/PWGCF/TableProducer/dptDptFilter.h @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file dptdptfilter.h +/// \file dptDptFilter.h /// \brief Filters collisions and tracks according to selection criteria /// \author victor.gonzalez.sebastian@gmail.com @@ -17,6 +17,8 @@ #define PWGCF_TABLEPRODUCER_DPTDPTFILTER_H_ #include +#include +#include #include #include #include @@ -26,6 +28,7 @@ #include #include #include +#include #include #include @@ -134,6 +137,8 @@ enum CollisionSelectionFlags { kISVERTEXITSTPCBIT, ///< is vertex TPC and ITS kISVERTEXTOFMATCHEDBIT, ///< vertex contributor with TOF matched kISVERTEXTRDMATCHEDBIT, ///< vertex contributor with TRD matche + kNOCOLLINTIMERANGEBIT, ///< no collision in time range + kNOCOLLINROFBIT, ///< no collision in readout kOCCUPANCYBIT, ///< occupancy within limits kISGOODITSLAYER3BIT, ///< right level of inactive chips for ITS layer 3 kISGOODITSLAYER0123BIT, ///< right level of inactive chips for ITS layers 0,1,2, and 3 @@ -205,6 +210,7 @@ bool onlyInOneSide = false; ///< select only tracks that don't cross the extern TpcExcludeTrack tpcExcluder; ///< the TPC excluder object instance /* selection criteria from PWGMM */ +static constexpr int kTrackTypePWGMM = 4; // default quality criteria for tracks with ITS contribution static constexpr o2::aod::track::TrackSelectionFlags::flagtype TrackSelectionITS = o2::aod::track::TrackSelectionFlags::kITSNCls | o2::aod::track::TrackSelectionFlags::kITSChi2NDF | @@ -220,14 +226,270 @@ static constexpr o2::aod::track::TrackSelectionFlags::flagtype TrackSelectionTPC static constexpr o2::aod::track::TrackSelectionFlags::flagtype TrackSelectionDCA = o2::aod::track::TrackSelectionFlags::kDCAz | o2::aod::track::TrackSelectionFlags::kDCAxy; +struct DptDptTrackSelection; // forward struct declaration int tracktype = 1; -std::function maxDcaZPtDep{}; // max dca in z axis as function of pT +std::vector trackFilters = {}; // the vector of track selectors -std::vector trackFilters = {}; -bool dca2Dcut = false; -float sharedTpcClusters = 1.0; ///< max fraction of shared TPC clusters -float maxDCAz = 1e6f; -float maxDCAxy = 1e6f; +struct DptDptTrackSelection { + DptDptTrackSelection(TrackSelection* stdTs, TList* outputList, const char* name) : stdTrackSelection(stdTs) + { + passedHistogram = new TH1F(name, name, ptbins, ptlow, ptup); + outputList->Add(passedHistogram); + } + DptDptTrackSelection(TrackSelection* stdTs, std::function ptDepCut, TList* outputList, const char* name) + : stdTrackSelection(stdTs), + maxDcazPtDep(ptDepCut) + { + passedHistogram = new TH1F(name, name, ptbins, ptlow, ptup); + outputList->Add(passedHistogram); + } + void setMaxDcaXY(float max) + { + maxDCAxy = max; + stdTrackSelection->SetMaxDcaXY(max); + } + void setMaxDcaZ(float max) + { + maxDCAz = max; + stdTrackSelection->SetMaxDcaZ(max); + } + void setMaxDcazPtDep(std::function ptDepCut) + { + maxDcazPtDep = ptDepCut; + } + void setRequirePvContributor(bool pvc = true) + { + requirePvContributor = pvc; + } + + template + bool isSelected(TrackObject const& track) const + { + if (stdTrackSelection->IsSelected(track)) { + auto checkDca2Dcut = [&](auto const& track) { + if (dca2Dcut) { + if (track.dcaXY() * track.dcaXY() / maxDCAxy / maxDCAxy + track.dcaZ() * track.dcaZ() / maxDCAz / maxDCAz > 1) { + return false; + } else { + return true; + } + } else { + return true; + } + }; + auto checkDcaZcut = [&](auto const& track) { + return ((maxDcazPtDep) ? std::fabs(track.dcaZ()) <= maxDcazPtDep(track.pt()) : true); + }; + + /* tight pT dependent DCAz cut */ + if (!checkDcaZcut(track)) { + return false; + } + /* 2D DCA xy-o-z cut */ + if (!checkDca2Dcut(track)) { + return false; + } + /* primary vertex contributor */ + if (requirePvContributor) { + if (!track.isPVContributor()) { + return false; + } + } + passedHistogram->Fill(track.pt()); + return true; + } else { + return false; + } + } + + static void initializeTrackSelection(TrackSelectionTuneCfg& tune, TList* outputList) + { + auto addTrackFilter = [](auto filter) { + trackFilters.push_back(filter); + }; + auto highQualityTpcTrack = [](TList* outList, const char* name) { + DptDptTrackSelection* tpcTrack = new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelection()), outList, name); + tpcTrack->stdTrackSelection->ResetITSRequirements(); + tpcTrack->stdTrackSelection->SetRequireITSRefit(false); + tpcTrack->stdTrackSelection->SetMinNClustersTPC(120); + tpcTrack->stdTrackSelection->SetMaxTPCFractionSharedCls(0.2f); + return tpcTrack; + }; + auto highQualityItsOnlyTrack = [](TList* outList, const char* name) { + DptDptTrackSelection* itsTrack = new DptDptTrackSelection(new TrackSelection(), [](float pt) { return 0.004f + 0.013f / pt; }, outList, name); + itsTrack->stdTrackSelection->SetTrackType(o2::aod::track::TrackTypeEnum::Track); + itsTrack->stdTrackSelection->SetRequireITSRefit(true); + itsTrack->stdTrackSelection->SetRequireHitsInITSLayers(2, {0, 1, 2}); + itsTrack->stdTrackSelection->SetMaxChi2PerClusterITS(36.0f); + itsTrack->stdTrackSelection->SetMaxDcaXYPtDep([](float pt) { return 0.004f + 0.013f / pt; }); + return itsTrack; + }; + switch (tracktype) { + case 1: { /* Run2 global track */ + DptDptTrackSelection* globalRun2 = new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelection()), outputList, "TType1Global"); + globalRun2->stdTrackSelection->SetTrackType(o2::aod::track::Run2Track); // Run 2 track asked by default + globalRun2->stdTrackSelection->SetMaxChi2PerClusterTPC(2.5f); + DptDptTrackSelection* globalSDDRun2 = new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionSDD()), outputList, "TType1Sdd"); + globalSDDRun2->stdTrackSelection->SetTrackType(o2::aod::track::Run2Track); // Run 2 track asked by default + globalSDDRun2->stdTrackSelection->SetMaxChi2PerClusterTPC(2.5f); + addTrackFilter(globalRun2); + addTrackFilter(globalSDDRun2); + } break; + case 3: { /* Run3 track */ + DptDptTrackSelection* globalRun3 = new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelection()), outputList, "TType3Global"); + globalRun3->stdTrackSelection->SetTrackType(o2::aod::track::TrackTypeEnum::Track); + globalRun3->stdTrackSelection->ResetITSRequirements(); + globalRun3->stdTrackSelection->SetRequireHitsInITSLayers(1, {0, 1, 2}); + DptDptTrackSelection* globalSDDRun3 = new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelection()), outputList, "TType3Sdd"); + globalSDDRun3->stdTrackSelection->SetTrackType(o2::aod::track::TrackTypeEnum::Track); + globalSDDRun3->stdTrackSelection->ResetITSRequirements(); + globalSDDRun3->stdTrackSelection->SetRequireNoHitsInITSLayers({0, 1, 2}); + globalSDDRun3->stdTrackSelection->SetRequireHitsInITSLayers(1, {3}); + addTrackFilter(globalRun3); + addTrackFilter(globalSDDRun3); + } break; + case 5: { /* Run2 TPC only track */ + DptDptTrackSelection* tpcOnly = new DptDptTrackSelection(new TrackSelection, outputList, "TType5"); + tpcOnly->stdTrackSelection->SetTrackType(o2::aod::track::Run2Track); // Run 2 track asked by default + tpcOnly->stdTrackSelection->SetMinNClustersTPC(50); + tpcOnly->stdTrackSelection->SetMaxChi2PerClusterTPC(4); + tpcOnly->setMaxDcaZ(3.2f); + tpcOnly->setMaxDcaXY(2.4f); + tpcOnly->dca2Dcut = true; + addTrackFilter(tpcOnly); + } break; + case 7: { /* Run3 TPC only track */ + DptDptTrackSelection* tpcOnly = new DptDptTrackSelection(new TrackSelection, outputList, "TType7"); + tpcOnly->stdTrackSelection->SetTrackType(o2::aod::track::TrackTypeEnum::Track); + tpcOnly->stdTrackSelection->SetMinNClustersTPC(50); + tpcOnly->stdTrackSelection->SetMaxChi2PerClusterTPC(4); + tpcOnly->setMaxDcaZ(3.2f); + tpcOnly->setMaxDcaXY(2.4f); + tpcOnly->dca2Dcut = true; + addTrackFilter(tpcOnly); + } break; + case 10: { /* Run3 track primary vertex contributor */ + DptDptTrackSelection* globalRun3 = new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelection()), outputList, "TType10Global"); + globalRun3->stdTrackSelection->SetTrackType(o2::aod::track::TrackTypeEnum::Track); + globalRun3->stdTrackSelection->ResetITSRequirements(); + globalRun3->stdTrackSelection->SetRequireHitsInITSLayers(1, {0, 1, 2}); + globalRun3->setRequirePvContributor(true); + DptDptTrackSelection* globalSDDRun3 = new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelection()), outputList, "TType10Sdd"); + globalSDDRun3->stdTrackSelection->SetTrackType(o2::aod::track::TrackTypeEnum::Track); + globalSDDRun3->stdTrackSelection->ResetITSRequirements(); + globalSDDRun3->stdTrackSelection->SetRequireNoHitsInITSLayers({0, 1, 2}); + globalSDDRun3->stdTrackSelection->SetRequireHitsInITSLayers(1, {3}); + globalSDDRun3->setRequirePvContributor(true); + addTrackFilter(globalRun3); + addTrackFilter(globalSDDRun3); + } break; + case 30: { /* Run 3 default global track: kAny on 3 IB layers of ITS */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default)), outputList, "TType30")); + } break; + case 31: { /* Run 3 global track: kTwo on 3 IB layers of ITS */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::Default)), outputList, "TType31")); + } break; + case 32: { /* Run 3 global track: kAny on all 7 layers of ITS */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default)), outputList, "TType32")); + } break; + case 33: { /* Run 3 global track: kAll on all 7 layers of ITS */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default)), outputList, "TType33")); + } break; + case 40: { /* Run 3 global track: kAny on 3 IB layers of ITS, tighter DCAxy */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), outputList, "TType40")); + } break; + case 41: { /* Run 3 global track: kTwo on 3 IB layers of ITS, tighter DCAxy */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), outputList, "TType41")); + } break; + case 42: { /* Run 3 global track: kAny on all 7 layers of ITS, tighter DCAxy */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), outputList, "TType42")); + } break; + case 43: { /* Run 3 global track: kAll on all 7 layers of ITS, tighter DCAxy */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), outputList, "TType43")); + } break; + case 50: { /* Run 3 global track: kAny on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType50")); + } break; + case 51: { /* Run 3 global track: kTwo on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType51")); + } break; + case 52: { /* Run 3 global track: kAny on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType52")); + } break; + case 53: { /* Run 3 global track: kAll on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType53")); + } break; + case 60: { /* Run 3 global track: kAny on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus TPC+TOF only tracks */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType60Global")); + addTrackFilter(highQualityTpcTrack(outputList, "TType60Tpc")); + } break; + case 61: { /* Run 3 global track: kTwo on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus TPC+TOF only tracks */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType61Global")); + addTrackFilter(highQualityTpcTrack(outputList, "TType61Tpc")); + } break; + case 62: { /* Run 3 global track: kAny on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus TPC+TOF only tracks */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType62Global")); + addTrackFilter(highQualityTpcTrack(outputList, "TType62Tpc")); + } break; + case 63: { /* Run 3 global track: kAll on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus TPC+TOF only tracks */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType63Global")); + addTrackFilter(highQualityTpcTrack(outputList, "TType63Tpc")); + } break; + case 70: { /* Run 3 global track: kAny on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus ITS only tracks */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType70Global")); + addTrackFilter(highQualityItsOnlyTrack(outputList, "TType70Its")); + } break; + case 71: { /* Run 3 global track: kTwo on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus ITS only tracks */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType71Global")); + addTrackFilter(highQualityItsOnlyTrack(outputList, "TType71Its")); + } break; + case 72: { /* Run 3 global track: kAny on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus ITS only tracks */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType72Global")); + addTrackFilter(highQualityItsOnlyTrack(outputList, "TType72Its")); + } break; + case 73: { /* Run 3 global track: kAll on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus ITS only tracks */ + addTrackFilter(new DptDptTrackSelection(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0.004f + 0.013f / pt; }, outputList, "TType73Global")); + addTrackFilter(highQualityItsOnlyTrack(outputList, "TType73Its")); + } break; + default: + break; + } + if (tune.mUseIt) { + for (auto const& filter : trackFilters) { + if (tune.mUseTPCclusters) { + filter->stdTrackSelection->SetMinNClustersTPC(tune.mTPCclusters); + } + if (tune.mUseTPCxRows) { + filter->stdTrackSelection->SetMinNCrossedRowsTPC(tune.mTPCxRows); + } + if (tune.mUseTPCXRoFClusters) { + filter->stdTrackSelection->SetMinNCrossedRowsOverFindableClustersTPC(tune.mTPCXRoFClusters); + } + if (tune.mUseDCAxy) { + /* DCAxy is tricky due to how the pT dependence is implemented */ + filter->stdTrackSelection->SetMaxDcaXYPtDep([&tune](float) { return tune.mDCAxy; }); + filter->setMaxDcaXY(tune.mDCAxy); + } + if (tune.mUseDCAz) { + /* DCAz is tricky due to how the pT dependence is implemented */ + filter->setMaxDcazPtDep([&tune](float) { return tune.mDCAz; }); + filter->setMaxDcaZ(tune.mDCAz); + } + if (tune.mUseFractionTpcSharedClusters) { + filter->stdTrackSelection->SetMaxTPCFractionSharedCls(tune.mFractionTpcSharedClusters); + } + } + } + } + + float maxDCAxy = 1e6; + float maxDCAz = 1e6; + TrackSelection* stdTrackSelection = nullptr; + std::function maxDcazPtDep = {}; + TH1* passedHistogram = nullptr; + bool dca2Dcut = false; + bool requirePvContributor = false; +}; inline TList* getCCDBInput(auto& ccdb, const char* ccdbpath, const char* ccdbdate, const char* period = "") { @@ -252,128 +514,6 @@ inline TList* getCCDBInput(auto& ccdb, const char* ccdbpath, const char* ccdbdat return lst; } -inline void initializeTrackSelection(TrackSelectionTuneCfg& tune) -{ - switch (tracktype) { - case 1: { /* Run2 global track */ - TrackSelection* globalRun2 = new TrackSelection(getGlobalTrackSelection()); - globalRun2->SetTrackType(o2::aod::track::Run2Track); // Run 2 track asked by default - globalRun2->SetMaxChi2PerClusterTPC(2.5f); - TrackSelection* globalSDDRun2 = new TrackSelection(getGlobalTrackSelectionSDD()); - globalSDDRun2->SetTrackType(o2::aod::track::Run2Track); // Run 2 track asked by default - globalSDDRun2->SetMaxChi2PerClusterTPC(2.5f); - trackFilters.push_back(globalRun2); - trackFilters.push_back(globalSDDRun2); - } break; - case 3: { /* Run3 track */ - TrackSelection* globalRun3 = new TrackSelection(getGlobalTrackSelection()); - globalRun3->SetTrackType(o2::aod::track::TrackTypeEnum::Track); - globalRun3->ResetITSRequirements(); - globalRun3->SetRequireHitsInITSLayers(1, {0, 1, 2}); - TrackSelection* globalSDDRun3 = new TrackSelection(getGlobalTrackSelection()); - globalSDDRun3->SetTrackType(o2::aod::track::TrackTypeEnum::Track); - globalSDDRun3->ResetITSRequirements(); - globalSDDRun3->SetRequireNoHitsInITSLayers({0, 1, 2}); - globalSDDRun3->SetRequireHitsInITSLayers(1, {3}); - trackFilters.push_back(globalRun3); - trackFilters.push_back(globalSDDRun3); - } break; - case 5: { /* Run2 TPC only track */ - TrackSelection* tpcOnly = new TrackSelection; - tpcOnly->SetTrackType(o2::aod::track::Run2Track); // Run 2 track asked by default - tpcOnly->SetMinNClustersTPC(50); - tpcOnly->SetMaxChi2PerClusterTPC(4); - tpcOnly->SetMaxDcaZ(3.2f); - maxDCAz = 3.2; - tpcOnly->SetMaxDcaXY(2.4f); - maxDCAxy = 2.4; - dca2Dcut = true; - trackFilters.push_back(tpcOnly); - } break; - case 7: { /* Run3 TPC only track */ - TrackSelection* tpcOnly = new TrackSelection; - tpcOnly->SetTrackType(o2::aod::track::TrackTypeEnum::Track); - tpcOnly->SetMinNClustersTPC(50); - tpcOnly->SetMaxChi2PerClusterTPC(4); - tpcOnly->SetMaxDcaZ(3.2f); - maxDCAz = 3.2; - tpcOnly->SetMaxDcaXY(2.4f); - maxDCAxy = 2.4; - dca2Dcut = true; - trackFilters.push_back(tpcOnly); - } break; - case 30: { /* Run 3 default global track: kAny on 3 IB layers of ITS */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default))); - } break; - case 31: { /* Run 3 global track: kTwo on 3 IB layers of ITS */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::Default))); - } break; - case 32: { /* Run 3 global track: kAny on all 7 layers of ITS */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default))); - } break; - case 33: { /* Run 3 global track: kAll on all 7 layers of ITS */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default))); - } break; - case 40: { /* Run 3 global track: kAny on 3 IB layers of ITS, tighter DCAxy */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3))); - } break; - case 41: { /* Run 3 global track: kTwo on 3 IB layers of ITS, tighter DCAxy */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3))); - } break; - case 42: { /* Run 3 global track: kAny on all 7 layers of ITS, tighter DCAxy */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3))); - } break; - case 43: { /* Run 3 global track: kAll on all 7 layers of ITS, tighter DCAxy */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3))); - } break; - case 50: { /* Run 3 global track: kAny on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3))); - maxDcaZPtDep = [](float pt) { return 0.004f + 0.013f / pt; }; - } break; - case 51: { /* Run 3 global track: kTwo on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3))); - maxDcaZPtDep = [](float pt) { return 0.004f + 0.013f / pt; }; - } break; - case 52: { /* Run 3 global track: kAny on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3))); - maxDcaZPtDep = [](float pt) { return 0.004f + 0.013f / pt; }; - } break; - case 53: { /* Run 3 global track: kAll on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz */ - trackFilters.push_back(new TrackSelection(getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3))); - maxDcaZPtDep = [](float pt) { return 0.004f + 0.013f / pt; }; - } break; - default: - break; - } - if (tune.mUseIt) { - for (auto const& filter : trackFilters) { - if (tune.mUseTPCclusters) { - filter->SetMinNClustersTPC(tune.mTPCclusters); - } - if (tune.mUseTPCxRows) { - filter->SetMinNCrossedRowsTPC(tune.mTPCxRows); - } - if (tune.mUseTPCXRoFClusters) { - filter->SetMinNCrossedRowsOverFindableClustersTPC(tune.mTPCXRoFClusters); - } - if (tune.mUseDCAxy) { - /* DCAxy is tricky due to how the pT dependence is implemented */ - filter->SetMaxDcaXYPtDep([&tune](float) { return tune.mDCAxy; }); - filter->SetMaxDcaXY(tune.mDCAxy); - } - if (tune.mUseDCAz) { - filter->SetMaxDcaZ(tune.mDCAz); - } - } - if (tune.mUseDCAz) { - maxDcaZPtDep = [&tune](float) { return tune.mDCAz; }; - } - if (tune.mUseFractionTpcSharedClusters) { - sharedTpcClusters = tune.mFractionTpcSharedClusters; - } - } -} - SystemType fSystem = kNoSystem; DataType fDataType = kData; CentMultEstimatorType fCentMultEstimator = kV0M; @@ -381,6 +521,7 @@ TriggerSelectionType fTriggerSelection = kMB; OccupancyEstimationType fOccupancyEstimation = kNOOCC; /* the occupancy estimator to use */ ItsDeadMapsCheckType fItsDeadMapCheck = kNOCHECK; /* the check of the ITS dead maps to use */ +float fMinOccupancy = 0.0f; /* the minimum allowed occupancy */ float fMaxOccupancy = 1e6f; /* the maximum allowed occupancy */ /* adaptations for the pp nightly checks */ @@ -612,7 +753,9 @@ inline bool triggerSelectionReco(CollisionObject const& collision) case kppRun3: case kPbPbRun3: { auto run3Accepted = [](auto const& coll) { - return coll.sel8(); + return coll.sel8() && + coll.selection_bit(aod::evsel::kNoCollInTimeRangeStandard) && + coll.selection_bit(aod::evsel::kNoCollInRofStandard); }; auto run3ExtraAccepted = [](auto const& coll) { return coll.sel8() && @@ -627,6 +770,8 @@ inline bool triggerSelectionReco(CollisionObject const& collision) flags.set(kISVERTEXITSTPCBIT, coll.selection_bit(aod::evsel::kIsVertexITSTPC)); flags.set(kISVERTEXTOFMATCHEDBIT, coll.selection_bit(aod::evsel::kIsVertexTOFmatched)); flags.set(kISVERTEXTRDMATCHEDBIT, coll.selection_bit(aod::evsel::kIsVertexTRDmatched)); + flags.set(kNOCOLLINTIMERANGEBIT, coll.selection_bit(aod::evsel::kNoCollInTimeRangeStandard)); + flags.set(kNOCOLLINROFBIT, coll.selection_bit(aod::evsel::kNoCollInRofStandard)); flags.set(kISGOODITSLAYER3BIT, coll.selection_bit(aod::evsel::kIsGoodITSLayer3)); flags.set(kISGOODITSLAYER0123BIT, coll.selection_bit(aod::evsel::kIsGoodITSLayer0123)); flags.set(kISGOODITSLAYERALLBIT, coll.selection_bit(aod::evsel::kIsGoodITSLayersAll)); @@ -746,6 +891,8 @@ inline bool triggerSelection(aod::McCollision const&) ////////////////////////////////////////////////////////////////////////////////// /// Multiplicity extraction ////////////////////////////////////////////////////////////////////////////////// +static constexpr float kValidPercentileLowLimit = 0.0f; +static constexpr float kValidPercentileUpLimit = 100.0f; /// \brief Extract the collision multiplicity from the event selection information template @@ -832,7 +979,7 @@ template inline bool centralitySelectionMult(CollisionObject collision, float& centmult) { float mult = getCentMultPercentile(collision); - if (mult < 100 && 0 < mult) { + if (mult < kValidPercentileUpLimit && kValidPercentileLowLimit < mult) { centmult = mult; collisionFlags.set(kCENTRALITYBIT); return true; @@ -911,7 +1058,7 @@ inline bool centralitySelection inline bool centralitySelection(aod::McCollision const&, float& centmult) { - if (centmult < 100 && 0 < centmult) { + if (centmult < kValidPercentileUpLimit && kValidPercentileLowLimit < centmult) { return true; } else { return false; @@ -932,14 +1079,14 @@ inline bool selectOnOccupancy(CollisionObject collision) collisionFlags.set(kOCCUPANCYBIT); return true; case kTRACKSOCC: - if (collision.trackOccupancyInTimeRange() < fMaxOccupancy) { + if ((fMinOccupancy <= collision.trackOccupancyInTimeRange()) && (collision.trackOccupancyInTimeRange() < fMaxOccupancy)) { collisionFlags.set(kOCCUPANCYBIT); return true; } else { return false; } case kFT0COCC: - if (collision.ft0cOccupancyInTimeRange() < fMaxOccupancy) { + if ((fMinOccupancy <= collision.ft0cOccupancyInTimeRange()) && (collision.ft0cOccupancyInTimeRange() < fMaxOccupancy)) { collisionFlags.set(kOCCUPANCYBIT); return true; } else { @@ -1017,7 +1164,7 @@ template inline bool selectOnItsDeadMaps(CollisionObject coll) { auto checkFlag = [](auto flag, bool invert = false) { - return flag && !invert; + return invert ? !flag : flag; }; switch (fItsDeadMapCheck) { case kNOCHECK: @@ -1149,12 +1296,14 @@ struct TpcExcludeTrack { } explicit TpcExcludeTrack(TpcExclusionMethod m) { + static constexpr float kDefaultPhiBinShift = 0.5f; + static constexpr int kDefaultNoOfPhiBins = 72; switch (m) { case kNOEXCLUSION: method = m; break; case kSTATIC: - if (phibinshift == 0.5f && phibins == 72) { + if (phibinshift == kDefaultPhiBinShift && phibins == kDefaultNoOfPhiBins) { method = m; } else { LOGF(fatal, "Static TPC exclusion method with bin shift: %.2f and number of bins %d. Please fix it", phibinshift, phibins); @@ -1234,7 +1383,7 @@ inline bool matchTrackType(TrackObject const& track) { using namespace o2::aod::track; - if (tracktype == 4) { + if (tracktype == kTrackTypePWGMM) { // under tests MM track selection // see: https://indico.cern.ch/event/1383788/contributions/5816953/attachments/2805905/4896281/TrackSel_GlobalTracks_vs_MMTrackSel.pdf // it should be equivalent to this @@ -1246,35 +1395,7 @@ inline bool matchTrackType(TrackObject const& track) ((track.trackCutFlag() & TrackSelectionDCA) == TrackSelectionDCA); } else { for (auto const& filter : trackFilters) { - if (filter->IsSelected(track)) { - /* additional track cuts if needed */ - auto checkDca2Dcut = [&](auto const& track) { - if (dca2Dcut) { - if (track.dcaXY() * track.dcaXY() / maxDCAxy / maxDCAxy + track.dcaZ() * track.dcaZ() / maxDCAz / maxDCAz > 1) { - return false; - } else { - return true; - } - } else { - return true; - } - }; - auto checkDcaZcut = [&](auto const& track) { - return ((maxDcaZPtDep) ? std::fabs(track.dcaZ()) <= maxDcaZPtDep(track.pt()) : true); - }; - - /* tight pT dependent DCAz cut */ - if (!checkDcaZcut(track)) { - return false; - } - /* 2D DCA xy-o-z cut */ - if (!checkDca2Dcut(track)) { - return false; - } - /* shared fraction of TPC clusters */ - if (!(track.tpcFractionSharedCls() < sharedTpcClusters)) { - return false; - } + if (filter->isSelected(track)) { return true; } } @@ -1354,7 +1475,8 @@ void exploreMothers(ParticleObject& particle, MCCollisionObject& collision) inline float getCharge(float pdgCharge) { - float charge = (pdgCharge / 3 >= 1) ? 1.0 : ((pdgCharge / 3 <= -1) ? -1.0 : 0); + static constexpr int kNoOfBasicChargesPerUnitCharge = 3; + float charge = (pdgCharge / kNoOfBasicChargesPerUnitCharge >= 1) ? 1.0 : ((pdgCharge / kNoOfBasicChargesPerUnitCharge <= -1) ? -1.0 : 0); return charge; } @@ -1390,7 +1512,7 @@ inline bool acceptParticle(ParticleObject& particle, MCCollisionObject const&) ////////////////////////////////////////////////////////////////////////////////// struct PIDSpeciesSelection { - const std::vector pdgcodes = {11, 13, 211, 321, 2212}; + const std::vector pdgcodes = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; const std::vector spnames = {"e", "mu", "pi", "ka", "p"}; const std::vector sptitles = {"e", "#mu", "#pi", "K", "p"}; const std::vector spfnames = {"E", "Mu", "Pi", "Ka", "Pr"}; @@ -1500,8 +1622,8 @@ struct PIDSpeciesSelection { return false; } }; - auto awayFrom = [](auto& values, auto& mindet, auto& maxdet, uint8_t sp) { - for (int ix = 0; ix < 5; ix++) { + auto awayFrom = [&](auto& values, auto& mindet, auto& maxdet, uint8_t sp) { + for (size_t ix = 0; ix < pdgcodes.size(); ix++) { if (ix != sp) { if (mindet[ix] <= values[ix] && values[ix] < maxdet[ix]) { return false; @@ -1535,7 +1657,7 @@ struct PIDSpeciesSelection { } }; auto awayFromTPCTOF = [&](auto& config, uint8_t sp) { - for (uint8_t ix = 0; ix < 5; ++ix) { + for (uint8_t ix = 0; ix < pdgcodes.size(); ++ix) { if (ix != sp) { if (closeToTPCTOF(config, ix)) { return false; @@ -1713,7 +1835,7 @@ struct PIDSpeciesSelection { template int8_t whichTruthSecFromDecaySpecies(ParticleObject part) { - if (!(part.isPhysicalPrimary()) && (part.getProcess() == 4)) { + if (!(part.isPhysicalPrimary()) && (part.getProcess() == TMCProcess::kPDecay)) { return whichTruthSpecies(part); } else { return -127; @@ -1723,7 +1845,7 @@ struct PIDSpeciesSelection { template int8_t whichTruthSecFromMaterialSpecies(ParticleObject part) { - if (!(part.isPhysicalPrimary()) && (part.getProcess() != 4)) { + if (!(part.isPhysicalPrimary()) && (part.getProcess() != TMCProcess::kPDecay)) { return whichTruthSpecies(part); } else { return -127; diff --git a/PWGCF/TableProducer/filter2Prong.cxx b/PWGCF/TableProducer/filter2Prong.cxx index d4353ca9150..00f7bb58827 100644 --- a/PWGCF/TableProducer/filter2Prong.cxx +++ b/PWGCF/TableProducer/filter2Prong.cxx @@ -8,50 +8,161 @@ // 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/ASoAHelpers.h" -#include "MathUtils/detail/TypeTruncation.h" +/// \author Jasper Parkkila #include "PWGCF/DataModel/CorrelationsDerived.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/DataModel/PIDResponseITS.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "MathUtils/detail/TypeTruncation.h" + +#include + +#include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::math_utils::detail; +enum LambdaPid { kLambda = 0, + kAntiLambda +}; + // #define FLOAT_PRECISION 0xFFFFFFF0 #define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; struct Filter2Prong { O2_DEFINE_CONFIGURABLE(cfgVerbosity, int, 0, "Verbosity level (0 = major, 1 = per collision)") O2_DEFINE_CONFIGURABLE(cfgYMax, float, -1.0f, "Maximum candidate rapidity") + O2_DEFINE_CONFIGURABLE(cfgImPart1Mass, float, o2::constants::physics::MassKPlus, "Daughter particle 1 mass in GeV") + O2_DEFINE_CONFIGURABLE(cfgImPart2Mass, float, o2::constants::physics::MassKMinus, "Daughter particle 2 mass in GeV") + O2_DEFINE_CONFIGURABLE(cfgImPart1PID, int, o2::track::PID::Kaon, "PID of daughter particle 1 (O2 PID ID)") + O2_DEFINE_CONFIGURABLE(cfgImPart2PID, int, o2::track::PID::Kaon, "PID of daughter particle 2 (O2 PID ID)") + O2_DEFINE_CONFIGURABLE(cfgMomDepPID, bool, 1, "Use mommentum dependent PID for Phi meson") + O2_DEFINE_CONFIGURABLE(cfgImCutPt, float, 0.2f, "Minimal pT for candidates") + O2_DEFINE_CONFIGURABLE(cfgImMinInvMass, float, 0.95f, "Minimum invariant mass for generic 2 prong") + O2_DEFINE_CONFIGURABLE(cfgImMaxInvMass, float, 1.07f, "Maximum invariant mass for generic 2 prong") + O2_DEFINE_CONFIGURABLE(cfgImSigmaFormula, std::string, "(([p] < 0.5 || [hasTOF] <= 0.0) && abs([sTPC]) < 3.0) || ([p] >= 0.5 && abs([sTPC]) < 2.5 && abs([sTOF]) < 3.0)", "pT dependent daughter track sigma pass condition. Parameters: [p] momentum, [sTPC] sigma TPC, [sTOF] sigma TOF, [hasTOF] has TOF.") + + struct : ConfigurableGroup { + O2_DEFINE_CONFIGURABLE(tpcNClsCrossedRowsTrackMin, float, 70, "Minimum number of crossed rows in TPC"); + O2_DEFINE_CONFIGURABLE(etaTrackMax, float, 0.8, "Maximum pseudorapidity"); + O2_DEFINE_CONFIGURABLE(ptTrackMin, float, 0.1, "Minimum transverse momentum"); + O2_DEFINE_CONFIGURABLE(minV0DCAPr, float, 0.1, "Min V0 proton DCA"); + O2_DEFINE_CONFIGURABLE(minV0DCAPiLambda, float, 0.1, "Min V0 pion DCA for lambda"); + O2_DEFINE_CONFIGURABLE(minV0DCAPiK0s, float, 0.1, "Min V0 pion DCA for K0s"); + O2_DEFINE_CONFIGURABLE(daughPIDCuts, float, 4.0, "PID nsigma for V0s"); + O2_DEFINE_CONFIGURABLE(massK0Min, float, 0.4, "Minimum mass for K0"); + O2_DEFINE_CONFIGURABLE(massK0Max, float, 0.6, "Maximum mass for K0"); + O2_DEFINE_CONFIGURABLE(massLambdaMin, float, 1.0, "Minimum mass for lambda"); + O2_DEFINE_CONFIGURABLE(massLambdaMax, float, 1.3, "Maximum mass for lambda"); + O2_DEFINE_CONFIGURABLE(radiusMaxLambda, float, 2.3, "Maximum decay radius (cm) for lambda"); + O2_DEFINE_CONFIGURABLE(radiusMinLambda, float, 0.0, "Minimum decay radius (cm) for lambda"); + O2_DEFINE_CONFIGURABLE(radiusMaxK0s, float, 2.3, "Maximum decay radius (cm) for K0s"); + O2_DEFINE_CONFIGURABLE(radiusMinK0s, float, 0.0, "Minimum decay radius (cm) for K0s"); + O2_DEFINE_CONFIGURABLE(cosPaMinLambda, float, 0.98, "Minimum cosine of pointing angle for lambda"); + O2_DEFINE_CONFIGURABLE(cosPaMinK0s, float, 0.98, "Minimum cosine of pointing angle for K0s"); + O2_DEFINE_CONFIGURABLE(dcaV0DaughtersMaxLambda, float, 0.2, "Maximum DCA among the V0 daughters (cm) for lambda"); + O2_DEFINE_CONFIGURABLE(dcaV0DaughtersMaxK0s, float, 0.2, "Maximum DCA among the V0 daughters (cm) for K0s"); + O2_DEFINE_CONFIGURABLE(qtArmenterosMinForK0s, float, 0.12, "Minimum Armenteros' qt for K0s"); + O2_DEFINE_CONFIGURABLE(maxLambdaLifeTime, float, 30, "Maximum lambda lifetime (in cm)"); + O2_DEFINE_CONFIGURABLE(maxK0sLifeTime, float, 30, "Maximum K0s lifetime (in cm)"); + } grpV0; + + struct : ConfigurableGroup { + O2_DEFINE_CONFIGURABLE(ImMinInvMassPhiMeson, float, 0.98f, "Minimum invariant mass Phi meson (GeV)"); + O2_DEFINE_CONFIGURABLE(ImMaxInvMassPhiMeson, float, 1.07f, "Maximum invariant mass Phi meson (GeV)"); + O2_DEFINE_CONFIGURABLE(ITSPIDSelection, bool, true, "PID ITS"); + O2_DEFINE_CONFIGURABLE(ITSPIDPthreshold, float, 1.0, "Momentum threshold for ITS PID (GeV/c) (only used if ITSPIDSelection is true)"); + O2_DEFINE_CONFIGURABLE(lowITSPIDNsigma, float, 3.0, "lower cut on PID nsigma for ITS"); + O2_DEFINE_CONFIGURABLE(highITSPIDNsigma, float, 3.0, "higher cut on PID nsigma for ITS"); + O2_DEFINE_CONFIGURABLE(ITSclusterPhiMeson, int, 5, "Minimum number of ITS cluster for phi meson track"); + O2_DEFINE_CONFIGURABLE(TPCCrossedRowsPhiMeson, int, 80, "Minimum number of TPC Crossed Rows for phi meson track"); + O2_DEFINE_CONFIGURABLE(cutDCAxyPhiMeson, float, 0.1, "Maximum DCAxy for phi meson track"); + O2_DEFINE_CONFIGURABLE(cutDCAzPhiMeson, float, 0.1, "Maximum DCAz for phi meson track"); + O2_DEFINE_CONFIGURABLE(cutEtaPhiMeson, float, 0.8, "Maximum eta for phi meson track"); + O2_DEFINE_CONFIGURABLE(cutPTPhiMeson, float, 0.15, "Maximum pt for phi meson track"); + O2_DEFINE_CONFIGURABLE(isDeepAngle, bool, true, "Flag for applying deep angle"); + O2_DEFINE_CONFIGURABLE(deepAngle, float, 0.04, "Deep angle cut"); + O2_DEFINE_CONFIGURABLE(nsigmaCutTPC, float, 2.5, "nsigma tpc"); + O2_DEFINE_CONFIGURABLE(nsigmaCutTOF, float, 2.5, "nsigma tof"); + O2_DEFINE_CONFIGURABLE(cutTOFBeta, float, 0.5, "TOF beta"); + O2_DEFINE_CONFIGURABLE(confFakeKaonCut, float, 0.15, "Cut based on track from momentum difference"); + O2_DEFINE_CONFIGURABLE(removefaketrack, bool, true, "Flag to remove fake kaon"); + } grpPhi; HfHelper hfHelper; Produces output2ProngTracks; + Produces output2ProngTrackmls; + + Produces output2ProngMcParts; + + std::vector mlvecd{}; + std::vector mlvecdbar{}; using HFCandidates = soa::Join; - void processData(aod::Collisions::iterator const&, aod::BCsWithTimestamps const&, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, HFCandidates const& candidates) + using HFCandidatesML = soa::Join; + using HFCandidatesMCRecoML = soa::Join; + + template + using HasMLProb = decltype(std::declval().mlProbD0()); + template + using HasFlagMcMatchRec = decltype(std::declval().flagMcMatchRec()); + + using PIDTrack = soa::Join; + using ResoV0s = aod::V0Datas; + + std::unique_ptr sigmaFormula; + std::array sigmaFormulaParamIndex; + + void init(InitContext&) + { + if (doprocessDataInvMass) { + sigmaFormula = std::make_unique("sigmaFormula", cfgImSigmaFormula.value.c_str()); + if (static_cast(sigmaFormula->GetNpar()) > std::size(sigmaFormulaParamIndex)) + LOGF(fatal, "Number of parameters in cfgImSigmaFormula can not be larger than %d.", std::size(sigmaFormulaParamIndex)); + // could do SetParameter(name,value) directly, but pre-lookup of the names will result in faster process + std::array pars = {"p", "sTPC", "sTOF", "hasTOF"}; + std::fill_n(sigmaFormulaParamIndex.begin(), std::size(sigmaFormulaParamIndex), ~0u); + for (uint i = 0, n = sigmaFormula->GetNpar(); i < n; ++i) { + auto m = std::find(pars.begin(), pars.end(), sigmaFormula->GetParName(i)); + if (m != pars.end()) + sigmaFormulaParamIndex[std::distance(pars.begin(), m)] = i; + else + LOGF(warning, "Unrecognized cfgImSigmaFormula parameter %s.", sigmaFormula->GetParName(i)); + } + } + } + + template + void processDataT(aod::Collisions::iterator const&, aod::BCsWithTimestamps const&, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, HFCandidatesType const& candidates) { if (cfcollisions.size() <= 0 || cftracks.size() <= 0) return; // rejected collision if (cfgVerbosity > 0 && candidates.size() > 0) LOGF(info, "Candidates for collision: %lu, cfcollisions: %lu, CFTracks: %lu", candidates.size(), cfcollisions.size(), cftracks.size()); - for (auto& c : candidates) { + for (const auto& c : candidates) { int prongCFId[2] = {-1, -1}; - for (auto& cftrack : cftracks) { + for (const auto& cftrack : cftracks) { if (c.prong0Id() == cftrack.trackId()) { prongCFId[0] = cftrack.globalIndex(); break; } } - for (auto& cftrack : cftracks) { + for (const auto& cftrack : cftracks) { if (c.prong1Id() == cftrack.trackId()) { prongCFId[1] = cftrack.globalIndex(); break; @@ -62,15 +173,513 @@ struct Filter2Prong { continue; if (cfgYMax >= 0.0f && std::abs(hfHelper.yD0(c)) > cfgYMax) continue; - if (c.isSelD0() > 0) + if constexpr (std::experimental::is_detected::value) { + if (std::abs(c.flagMcMatchRec()) != o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) + continue; + } + + if (c.isSelD0() > 0) { output2ProngTracks(cfcollisions.begin().globalIndex(), prongCFId[0], prongCFId[1], c.pt(), c.eta(), c.phi(), hfHelper.invMassD0ToPiK(c), aod::cf2prongtrack::D0ToPiK); - if (c.isSelD0bar() > 0) + if constexpr (std::experimental::is_detected::value) { + mlvecd.clear(); + for (const float val : c.mlProbD0()) + mlvecd.push_back(val); + mlvecdbar.clear(); + for (const float val : c.mlProbD0bar()) + mlvecdbar.push_back(val); + output2ProngTrackmls(cfcollisions.begin().globalIndex(), mlvecd, mlvecdbar); + } + } + + if (c.isSelD0bar() > 0) { output2ProngTracks(cfcollisions.begin().globalIndex(), prongCFId[0], prongCFId[1], c.pt(), c.eta(), c.phi(), hfHelper.invMassD0barToKPi(c), aod::cf2prongtrack::D0barToKPi); + if constexpr (std::experimental::is_detected::value) { + mlvecd.clear(); + for (const float val : c.mlProbD0()) + mlvecd.push_back(val); + mlvecdbar.clear(); + for (const float val : c.mlProbD0bar()) + mlvecdbar.push_back(val); + output2ProngTrackmls(cfcollisions.begin().globalIndex(), mlvecd, mlvecdbar); + } + } } } + + void processDataML(aod::Collisions::iterator const& col, aod::BCsWithTimestamps const& bcs, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, HFCandidatesML const& candidates) + { + processDataT(col, bcs, cfcollisions, cftracks, candidates); + } + PROCESS_SWITCH(Filter2Prong, processDataML, "Process data D0 candidates with ML", false); + + void processData(aod::Collisions::iterator const& col, aod::BCsWithTimestamps const& bcs, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, HFCandidates const& candidates) + { + processDataT(col, bcs, cfcollisions, cftracks, candidates); + } PROCESS_SWITCH(Filter2Prong, processData, "Process data D0 candidates", true); + + void processMCRecoML(aod::Collisions::iterator const& col, aod::BCsWithTimestamps const& bcs, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, HFCandidatesMCRecoML const& candidates) + { + processDataT(col, bcs, cfcollisions, cftracks, candidates); + } + PROCESS_SWITCH(Filter2Prong, processMCRecoML, "Process data D0 candidates together with reco information and ML", false); + + using HFMCTrack = soa::Join; + void processMC(aod::McCollisions::iterator const&, aod::CFMcParticleRefs const& cfmcparticles, [[maybe_unused]] HFMCTrack const& mcparticles) + { + // The main filter outputs the primary MC particles. Here we just resolve the daughter indices that are needed for the efficiency matching. + for (const auto& r : cfmcparticles) { + const auto& mcParticle = r.mcParticle_as(); + if ((std::abs(mcParticle.flagMcMatchGen()) != o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || mcParticle.daughtersIds().size() != 2) { + output2ProngMcParts(-1, -1, aod::cf2prongtrack::Generic2Prong); + continue; + } + int prongCFId[2] = {-1, -1}; + for (uint i = 0; i < 2; ++i) { + for (const auto& cfmcpart : cfmcparticles) { + if (mcParticle.daughtersIds()[i] == cfmcpart.mcParticleId()) { + prongCFId[i] = cfmcpart.globalIndex(); + break; + } + } + } + output2ProngMcParts(prongCFId[0], prongCFId[1], + (mcParticle.pdgCode() >= 0 ? aod::cf2prongtrack::D0ToPiK : aod::cf2prongtrack::D0barToKPi) | ((mcParticle.originMcGen() == RecoDecay::OriginType::Prompt) ? aod::cf2prongmcpart::Prompt : 0)); + } + } + PROCESS_SWITCH(Filter2Prong, processMC, "Process MC 2-prong daughters", false); + + void processMCGeneric(aod::McCollisions::iterator const&, aod::CFMcParticleRefs const& cfmcparticles, [[maybe_unused]] aod::McParticles const& mcparticles) + { + // The main filter outputs the primary MC particles. Here we just resolve the daughter indices that are needed for the efficiency matching. + for (const auto& r : cfmcparticles) { + const auto& mcParticle = r.mcParticle(); + if (mcParticle.daughtersIds().size() != 2) { + output2ProngMcParts(-1, -1, aod::cf2prongtrack::Generic2Prong); // not a 2-prong + continue; + } + int prongCFId[2] = {-1, -1}; + for (uint i = 0; i < 2; ++i) { + for (const auto& cfmcpart : cfmcparticles) { + if (mcParticle.daughtersIds()[i] == cfmcpart.mcParticleId()) { + prongCFId[i] = cfmcpart.globalIndex(); + break; + } + } + } + output2ProngMcParts(prongCFId[0], prongCFId[1], aod::cf2prongtrack::Generic2Prong); // the 2-prong Phi, for example, can be checked through its daughters + } + } + PROCESS_SWITCH(Filter2Prong, processMCGeneric, "Process generic MC 2-prong daughters", false); + + template + bool selectionTrack(const T& candidate) + { + if (candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() >= grpPhi.ITSclusterPhiMeson && candidate.tpcNClsCrossedRows() > grpPhi.TPCCrossedRowsPhiMeson && std::abs(candidate.dcaXY()) <= grpPhi.cutDCAxyPhiMeson && std::abs(candidate.dcaZ()) <= grpPhi.cutDCAzPhiMeson && std::abs(candidate.eta()) <= grpPhi.cutEtaPhiMeson && candidate.pt() >= grpPhi.cutPTPhiMeson) { + return true; + } + return false; + } + + template + bool selectionPair(const T1& candidate1, const T2& candidate2) + { + double pt1, pt2, pz1, pz2, p1, p2, angle; + pt1 = candidate1.pt(); + pt2 = candidate2.pt(); + pz1 = candidate1.pz(); + pz2 = candidate2.pz(); + p1 = candidate1.p(); + p2 = candidate2.p(); + angle = TMath::ACos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); + if (grpPhi.isDeepAngle && angle < grpPhi.deepAngle) { + return false; + } + return true; + } + + template + bool isFakeTrack(T const& track) + { + const auto pglobal = track.p(); + const auto ptpc = track.tpcInnerParam(); + if (TMath::Abs(pglobal - ptpc) > grpPhi.confFakeKaonCut) { + return true; + } + return false; + } + + template + bool isSelectedV0AsK0s(Collision const& collision, const V0Cand& v0) + { + const auto& posTrack = v0.template posTrack_as(); + const auto& negTrack = v0.template negTrack_as(); + + float CtauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0; + + if (v0.mK0Short() < grpV0.massK0Min || v0.mK0Short() > grpV0.massK0Max) { + return false; + } + if ((v0.qtarm() / std::abs(v0.alpha())) < grpV0.qtArmenterosMinForK0s) { + return false; + } + if (v0.v0radius() > grpV0.radiusMaxK0s || v0.v0radius() < grpV0.radiusMinK0s) { + return false; + } + if (v0.v0cosPA() < grpV0.cosPaMinK0s) { + return false; + } + if (v0.dcaV0daughters() > grpV0.dcaV0DaughtersMaxK0s) { + return false; + } + if (std::abs(CtauK0s) > grpV0.maxK0sLifeTime) { + return false; + } + if (((std::abs(posTrack.tpcNSigmaPi()) > grpV0.daughPIDCuts) || (std::abs(negTrack.tpcNSigmaPi()) > grpV0.daughPIDCuts))) { + return false; + } + if ((TMath::Abs(v0.dcapostopv()) < grpV0.minV0DCAPiK0s || TMath::Abs(v0.dcanegtopv()) < grpV0.minV0DCAPiK0s)) { + return false; + } + return true; + } + + template + bool isSelectedV0AsLambda(Collision const& collision, const V0Cand& v0) + { + const auto& posTrack = v0.template posTrack_as(); + const auto& negTrack = v0.template negTrack_as(); + + float CtauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda; + + if ((v0.mLambda() < grpV0.massLambdaMin || v0.mLambda() > grpV0.massLambdaMax) && + (v0.mAntiLambda() < grpV0.massLambdaMin || v0.mAntiLambda() > grpV0.massLambdaMax)) { + return false; + } + if (v0.v0radius() > grpV0.radiusMaxLambda || v0.v0radius() < grpV0.radiusMinLambda) { + return false; + } + if (v0.v0cosPA() < grpV0.cosPaMinLambda) { + return false; + } + if (v0.dcaV0daughters() > grpV0.dcaV0DaughtersMaxLambda) { + return false; + } + if (pid == LambdaPid::kLambda && (TMath::Abs(v0.dcapostopv()) < grpV0.minV0DCAPr || TMath::Abs(v0.dcanegtopv()) < grpV0.minV0DCAPiLambda)) { + return false; + } + if (pid == LambdaPid::kAntiLambda && (TMath::Abs(v0.dcapostopv()) < grpV0.minV0DCAPiLambda || TMath::Abs(v0.dcanegtopv()) < grpV0.minV0DCAPr)) { + return false; + } + if (pid == LambdaPid::kLambda && ((std::abs(posTrack.tpcNSigmaPr()) > grpV0.daughPIDCuts) || (std::abs(negTrack.tpcNSigmaPi()) > grpV0.daughPIDCuts))) { + return false; + } + if (pid == LambdaPid::kAntiLambda && ((std::abs(posTrack.tpcNSigmaPi()) > grpV0.daughPIDCuts) || (std::abs(negTrack.tpcNSigmaPr()) > grpV0.daughPIDCuts))) { + return false; + } + if (std::abs(CtauLambda) > grpV0.maxLambdaLifeTime) { + return false; + } + return true; + } + + template + bool isV0TrackSelected(const T1& v0) + { + const auto& posTrack = v0.template posTrack_as(); + const auto& negTrack = v0.template negTrack_as(); + + if (!posTrack.hasTPC() || !negTrack.hasTPC()) { + return false; + } + if (posTrack.tpcNClsCrossedRows() < grpV0.tpcNClsCrossedRowsTrackMin || negTrack.tpcNClsCrossedRows() < grpV0.tpcNClsCrossedRowsTrackMin) { + return false; + } + if (posTrack.tpcCrossedRowsOverFindableCls() < 0.8 || negTrack.tpcCrossedRowsOverFindableCls() < 0.8) { + return false; + } + if (std::abs(v0.positiveeta()) > grpV0.etaTrackMax || std::abs(v0.negativeeta()) > grpV0.etaTrackMax) { + return false; + } + if (v0.positivept() < grpV0.ptTrackMin || v0.negativept() < grpV0.ptTrackMin) { + return false; + } + return true; + } + + template + bool selectionPID(const T& candidate) + { + if (cfgMomDepPID) { + if (candidate.p() < 0.5) { + if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < grpPhi.nsigmaCutTPC) { + return true; + } else if (candidate.hasTOF() && TMath::Sqrt(candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) < grpPhi.nsigmaCutTOF && candidate.beta() > grpPhi.cutTOFBeta) { + return true; + } + } else if (candidate.hasTOF() && TMath::Sqrt(candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) < grpPhi.nsigmaCutTOF && candidate.beta() > grpPhi.cutTOFBeta) { + return true; + } + } else { + if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < grpPhi.nsigmaCutTPC) { + return true; + } else if (candidate.hasTOF() && TMath::Sqrt(candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) < grpPhi.nsigmaCutTOF && candidate.beta() > grpPhi.cutTOFBeta) { + return true; + } + } + return false; + } + + // Generic 2-prong invariant mass method candidate finder. Only works for non-identical daughters of opposite charge for now. + void processDataInvMass(aod::Collisions::iterator const&, aod::BCsWithTimestamps const&, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, Filter2Prong::PIDTrack const& tracks) + { + if (cfcollisions.size() <= 0 || cftracks.size() <= 0) + return; // rejected collision + for (const auto& cftrack1 : cftracks) { + const auto& p1 = tracks.iteratorAt(cftrack1.trackId() - tracks.begin().globalIndex()); + if (p1.sign() != 1) + continue; + sigmaFormula->SetParameter(sigmaFormulaParamIndex[0], p1.p()); + sigmaFormula->SetParameter(sigmaFormulaParamIndex[1], o2::aod::pidutils::tpcNSigma(cfgImPart1PID, p1)); + sigmaFormula->SetParameter(sigmaFormulaParamIndex[2], o2::aod::pidutils::tofNSigma(cfgImPart1PID, p1)); + sigmaFormula->SetParameter(sigmaFormulaParamIndex[3], static_cast(p1.hasTOF())); + if (sigmaFormula->Eval() <= 0.0f) + continue; + for (const auto& cftrack2 : cftracks) { + if (cftrack2.globalIndex() == cftrack1.globalIndex()) + continue; + const auto& p2 = tracks.iteratorAt(cftrack2.trackId() - tracks.begin().globalIndex()); + if (p2.sign() != -1) + continue; + sigmaFormula->SetParameter(sigmaFormulaParamIndex[0], p2.p()); + sigmaFormula->SetParameter(sigmaFormulaParamIndex[1], o2::aod::pidutils::tpcNSigma(cfgImPart1PID, p2)); + sigmaFormula->SetParameter(sigmaFormulaParamIndex[2], o2::aod::pidutils::tofNSigma(cfgImPart1PID, p2)); + sigmaFormula->SetParameter(sigmaFormulaParamIndex[3], static_cast(p2.hasTOF())); + if (sigmaFormula->Eval() <= 0.0f) + continue; + ROOT::Math::PtEtaPhiMVector vec1(p1.pt(), p1.eta(), p1.phi(), cfgImPart1Mass); + ROOT::Math::PtEtaPhiMVector vec2(p2.pt(), p2.eta(), p2.phi(), cfgImPart2Mass); + ROOT::Math::PtEtaPhiMVector s = vec1 + vec2; + if (s.pt() < cfgImCutPt || s.M() < cfgImMinInvMass || s.M() > cfgImMaxInvMass) + continue; + + float phi = RecoDecay::constrainAngle(s.Phi(), 0.0f); + output2ProngTracks(cfcollisions.begin().globalIndex(), + cftrack1.globalIndex(), cftrack2.globalIndex(), s.pt(), s.eta(), phi, s.M(), aod::cf2prongtrack::Generic2Prong); + } + } + } + PROCESS_SWITCH(Filter2Prong, processDataInvMass, "Process data generic 2-prong candidates with invariant mass method", false); + + // Phi and V0s invariant mass method candidate finder. Only works for non-identical daughters of opposite charge for now. + void processDataPhiV0(aod::Collisions::iterator const& collision, aod::BCsWithTimestamps const&, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, Filter2Prong::PIDTrack const& tracks, aod::V0Datas const& V0s) + { + if (cfcollisions.size() <= 0) + return; // rejected collision + + // V0 + for (const auto& v0 : V0s) { // Loop over V0 candidates + if (!isV0TrackSelected(v0)) { // Quality selection for V0 prongs + continue; + } + + const auto& posTrack = v0.template posTrack_as(); + const auto& negTrack = v0.template negTrack_as(); + double massV0 = 0.0; + + // K0s + if (isSelectedV0AsK0s(collision, v0)) { // candidate is K0s + output2ProngTracks(cfcollisions.begin().globalIndex(), + posTrack.globalIndex(), negTrack.globalIndex(), + v0.pt(), v0.eta(), v0.phi(), v0.mK0Short(), aod::cf2prongtrack::K0stoPiPi); + } + + // Lambda and Anti-Lambda + bool LambdaTag = isSelectedV0AsLambda(collision, v0); + bool aLambdaTag = isSelectedV0AsLambda(collision, v0); + + // Note: candidate compatible with Lambda and Anti-Lambda hypothesis are counted twice (once for each hypothesis) + if (LambdaTag) { // candidate is Lambda + massV0 = v0.mLambda(); + output2ProngTracks(cfcollisions.begin().globalIndex(), posTrack.globalIndex(), negTrack.globalIndex(), + v0.pt(), v0.eta(), v0.phi(), massV0, aod::cf2prongtrack::LambdatoPPi); + } + if (aLambdaTag) { // candidate is Anti-lambda + massV0 = v0.mAntiLambda(); + output2ProngTracks(cfcollisions.begin().globalIndex(), posTrack.globalIndex(), negTrack.globalIndex(), + v0.pt(), v0.eta(), v0.phi(), massV0, aod::cf2prongtrack::AntiLambdatoPiP); + } // end of Lambda and Anti-Lambda processing + } // end of loop over V0 candidates + + // Phi + if (cftracks.size() <= 0) + return; // rejected collision + + o2::aod::ITSResponse itsResponse; + + for (const auto& cftrack1 : cftracks) { // Loop over first track + const auto& p1 = tracks.iteratorAt(cftrack1.trackId() - tracks.begin().globalIndex()); + if (p1.sign() != 1) { + continue; + } + if (!selectionTrack(p1)) { + continue; + } + if (grpPhi.ITSPIDSelection && p1.p() < grpPhi.ITSPIDPthreshold.value && !(itsResponse.nSigmaITS(p1) > grpPhi.lowITSPIDNsigma.value && itsResponse.nSigmaITS(p1) < grpPhi.highITSPIDNsigma.value)) { // Check ITS PID condition + continue; + } + if (!selectionPID(p1)) { + continue; + } + if (grpPhi.removefaketrack && isFakeTrack(p1)) { // Check if the track is a fake kaon + continue; + } + + for (const auto& cftrack2 : cftracks) { // Loop over second track + if (cftrack2.globalIndex() == cftrack1.globalIndex()) // Skip if it's the same track as the first one + continue; + + const auto& p2 = tracks.iteratorAt(cftrack2.trackId() - tracks.begin().globalIndex()); + if (p2.sign() != -1) { + continue; + } + if (!selectionTrack(p2)) { + continue; + } + if (!selectionPID(p2)) { + continue; + } + if (grpPhi.ITSPIDSelection && p2.p() < grpPhi.ITSPIDPthreshold.value && !(itsResponse.nSigmaITS(p2) > grpPhi.lowITSPIDNsigma.value && itsResponse.nSigmaITS(p2) < grpPhi.highITSPIDNsigma.value)) { // Check ITS PID condition + continue; + } + if (grpPhi.removefaketrack && isFakeTrack(p2)) { // Check if the track is a fake kaon + continue; + } + if (!selectionPair(p1, p2)) { + continue; + } + + ROOT::Math::PtEtaPhiMVector vec1(p1.pt(), p1.eta(), p1.phi(), cfgImPart1Mass); + ROOT::Math::PtEtaPhiMVector vec2(p2.pt(), p2.eta(), p2.phi(), cfgImPart2Mass); + ROOT::Math::PtEtaPhiMVector s = vec1 + vec2; + if (s.M() < grpPhi.ImMinInvMassPhiMeson || s.M() > grpPhi.ImMaxInvMassPhiMeson) { + continue; + } + float phi = RecoDecay::constrainAngle(s.Phi(), 0.0f); + output2ProngTracks(cfcollisions.begin().globalIndex(), + cftrack1.globalIndex(), cftrack2.globalIndex(), s.pt(), s.eta(), phi, s.M(), aod::cf2prongtrack::PhiToKK); + } // end of loop over second track + } // end of loop over first track + } + PROCESS_SWITCH(Filter2Prong, processDataPhiV0, "Process data Phi and V0 candidates with invariant mass method", false); + + // Phi and V0s invariant mass method candidate finder. Only works for non-identical daughters of opposite charge for now. + void processDataV0(aod::Collisions::iterator const& collision, aod::BCsWithTimestamps const&, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, Filter2Prong::PIDTrack const&, aod::V0Datas const& V0s) + { + if (cfcollisions.size() <= 0 || cftracks.size() <= 0) + return; // rejected collision + + for (const auto& v0 : V0s) { // Loop over V0 candidates + if (!isV0TrackSelected(v0)) { // Quality selection for V0 prongs + continue; + } + + const auto& posTrack = v0.template posTrack_as(); + const auto& negTrack = v0.template negTrack_as(); + double massV0 = 0.0; + + // K0s + if (isSelectedV0AsK0s(collision, v0)) { // candidate is K0s + output2ProngTracks(cfcollisions.begin().globalIndex(), + posTrack.globalIndex(), negTrack.globalIndex(), + v0.pt(), v0.eta(), v0.phi(), v0.mK0Short(), aod::cf2prongtrack::K0stoPiPi); + } + + // Lambda and Anti-Lambda + bool LambdaTag = isSelectedV0AsLambda(collision, v0); + bool aLambdaTag = isSelectedV0AsLambda(collision, v0); + + // Note: candidate compatible with Lambda and Anti-Lambda hypothesis are counted twice (once for each hypothesis) + if (LambdaTag) { // candidate is Lambda + massV0 = v0.mLambda(); + output2ProngTracks(cfcollisions.begin().globalIndex(), posTrack.globalIndex(), negTrack.globalIndex(), + v0.pt(), v0.eta(), v0.phi(), massV0, aod::cf2prongtrack::LambdatoPPi); + } + if (aLambdaTag) { // candidate is Anti-lambda + massV0 = v0.mAntiLambda(); + output2ProngTracks(cfcollisions.begin().globalIndex(), posTrack.globalIndex(), negTrack.globalIndex(), + v0.pt(), v0.eta(), v0.phi(), massV0, aod::cf2prongtrack::AntiLambdatoPiP); + } // end of Lambda and Anti-Lambda processing + } // end of loop over V0 candidates + } + PROCESS_SWITCH(Filter2Prong, processDataV0, "Process data V0 candidates with invariant mass method", false); + + // Phi and V0s invariant mass method candidate finder. Only works for non-identical daughters of opposite charge for now. + void processDataPhi(aod::Collisions::iterator const&, aod::BCsWithTimestamps const&, aod::CFCollRefs const& cfcollisions, aod::CFTrackRefs const& cftracks, Filter2Prong::PIDTrack const& tracks) + { + if (cfcollisions.size() <= 0 || cftracks.size() <= 0) + return; // rejected collision + + o2::aod::ITSResponse itsResponse; + + for (const auto& cftrack1 : cftracks) { // Loop over first track + const auto& p1 = tracks.iteratorAt(cftrack1.trackId() - tracks.begin().globalIndex()); + if (p1.sign() != 1) { + continue; + } + if (!selectionTrack(p1)) { + continue; + } + if (grpPhi.ITSPIDSelection && p1.p() < grpPhi.ITSPIDPthreshold.value && !(itsResponse.nSigmaITS(p1) > grpPhi.lowITSPIDNsigma.value && itsResponse.nSigmaITS(p1) < grpPhi.highITSPIDNsigma.value)) { // Check ITS PID condition + continue; + } + if (!selectionPID(p1)) { + continue; + } + if (grpPhi.removefaketrack && isFakeTrack(p1)) { // Check if the track is a fake kaon + continue; + } + + for (const auto& cftrack2 : cftracks) { // Loop over second track + if (cftrack2.globalIndex() == cftrack1.globalIndex()) // Skip if it's the same track as the first one + continue; + + const auto& p2 = tracks.iteratorAt(cftrack2.trackId() - tracks.begin().globalIndex()); + if (p2.sign() != -1) { + continue; + } + if (!selectionTrack(p2)) { + continue; + } + if (!selectionPID(p2)) { + continue; + } + if (grpPhi.ITSPIDSelection && p2.p() < grpPhi.ITSPIDPthreshold.value && !(itsResponse.nSigmaITS(p2) > grpPhi.lowITSPIDNsigma.value && itsResponse.nSigmaITS(p2) < grpPhi.highITSPIDNsigma.value)) { // Check ITS PID condition + continue; + } + if (grpPhi.removefaketrack && isFakeTrack(p2)) { // Check if the track is a fake kaon + continue; + } + if (!selectionPair(p1, p2)) { + continue; + } + + ROOT::Math::PtEtaPhiMVector vec1(p1.pt(), p1.eta(), p1.phi(), cfgImPart1Mass); + ROOT::Math::PtEtaPhiMVector vec2(p2.pt(), p2.eta(), p2.phi(), cfgImPart2Mass); + ROOT::Math::PtEtaPhiMVector s = vec1 + vec2; + if (s.M() < grpPhi.ImMinInvMassPhiMeson || s.M() > grpPhi.ImMaxInvMassPhiMeson) { + continue; + } + float phi = RecoDecay::constrainAngle(s.Phi(), 0.0f); + output2ProngTracks(cfcollisions.begin().globalIndex(), + cftrack1.globalIndex(), cftrack2.globalIndex(), s.pt(), s.eta(), phi, s.M(), aod::cf2prongtrack::PhiToKK); + } // end of loop over second track + } // end of loop over first track + } + PROCESS_SWITCH(Filter2Prong, processDataPhi, "Process data Phi candidates with invariant mass method", false); + }; // struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/TableProducer/filterCorrelations.cxx b/PWGCF/TableProducer/filterCorrelations.cxx index 5ae37e93384..95fd3ae951f 100644 --- a/PWGCF/TableProducer/filterCorrelations.cxx +++ b/PWGCF/TableProducer/filterCorrelations.cxx @@ -8,21 +8,26 @@ // 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/ASoAHelpers.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include "MathUtils/detail/TypeTruncation.h" - #include "PWGCF/DataModel/CorrelationsDerived.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" + +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseITS.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" +#include "MathUtils/detail/TypeTruncation.h" #include -#include + +#include // required for is_detected +#include using namespace o2; using namespace o2::framework; @@ -46,10 +51,17 @@ using CFMultiplicity = CFMultiplicities::iterator; struct FilterCF { Service pdg; - enum TrackSelectionCuts : uint8_t { + enum TrackSelectionCuts1 : uint8_t { kTrackSelected = BIT(0), kITS5Clusters = BIT(1), - kTPC90CrossedRows = BIT(2) + kTPCCrossedRows = BIT(2), + kTPCClusters = BIT(3), + kchi2perTPC = BIT(4), + kchi2perITS = BIT(5), + }; + + enum TrackSelectionCuts2 : uint8_t { + kPIDProton = BIT(1) }; // Configuration @@ -59,13 +71,25 @@ struct FilterCF { O2_DEFINE_CONFIGURABLE(cfgCutMCPt, float, 0.5f, "Minimal pT for particles") O2_DEFINE_CONFIGURABLE(cfgCutMCEta, float, 0.8f, "Eta range for particles") O2_DEFINE_CONFIGURABLE(cfgVerbosity, int, 1, "Verbosity level (0 = major, 1 = per collision)") - O2_DEFINE_CONFIGURABLE(cfgTrigger, int, 7, "Trigger choice: (0 = none, 7 = sel7, 8 = sel8, 9 = sel8 + kNoSameBunchPileup + kIsGoodZvtxFT0vsPV, 10 = sel8 before April, 2024, 11 = sel8 for MC, 12 = sel8 with low occupancy cut)") + O2_DEFINE_CONFIGURABLE(cfgTrigger, int, 7, "Trigger choice: (0 = none, 7 = sel7, 8 = sel8, 9 = sel8 + kNoSameBunchPileup + kIsGoodZvtxFT0vsPV, 10 = sel8 before April, 2024, 11 = sel8 for MC, 12 = sel8 with low occupancy cut, 13 = sel8 + kNoSameBunchPileup + kIsGoodITSLayersAll -- for OO/NeNe) ") O2_DEFINE_CONFIGURABLE(cfgMinOcc, int, 0, "minimum occupancy selection") O2_DEFINE_CONFIGURABLE(cfgMaxOcc, int, 3000, "maximum occupancy selection") O2_DEFINE_CONFIGURABLE(cfgCollisionFlags, uint16_t, aod::collision::CollisionFlagsRun2::Run2VertexerTracks, "Request collision flags if non-zero (0 = off, 1 = Run2VertexerTracks)") - O2_DEFINE_CONFIGURABLE(cfgTransientTables, bool, false, "Output transient tables for collision and track IDs") - O2_DEFINE_CONFIGURABLE(cfgTrackSelection, int, 0, "Type of track selection (0 = Run 2/3 without systematics | 1 = Run 3 with systematics)") + O2_DEFINE_CONFIGURABLE(cfgTransientTables, bool, false, "Output transient tables for collision and track IDs to enable successive filtering tasks") + O2_DEFINE_CONFIGURABLE(cfgTrackSelection, int, 0, "Type of track selection (0 = Run 2/3 without systematics | 1 = Run 3 with systematics | 2 = Run 3 with proton pid selection)") O2_DEFINE_CONFIGURABLE(cfgMinMultiplicity, float, -1, "Minimum multiplicity considered for filtering (if value positive)") + O2_DEFINE_CONFIGURABLE(cfgMcSpecialPDGs, std::vector, {}, "Special MC PDG codes to include in the MC primary particle output (additional to charged particles). Empty = charged particles only.") // needed for some neutral particles + O2_DEFINE_CONFIGURABLE(nsigmaCutTPCProton, float, 3, "proton nsigma TPC") + O2_DEFINE_CONFIGURABLE(nsigmaCutTOFProton, float, 3, "proton nsigma TOF") + O2_DEFINE_CONFIGURABLE(ITSProtonselection, bool, false, "flag for ITS proton nsigma selection") + O2_DEFINE_CONFIGURABLE(nsigmaCutITSProton, float, 3, "proton nsigma ITS") + O2_DEFINE_CONFIGURABLE(dcaxymax, float, 999.f, "maximum dcaxy of tracks") + O2_DEFINE_CONFIGURABLE(dcazmax, float, 999.f, "maximum dcaz of tracks") + O2_DEFINE_CONFIGURABLE(itsnclusters, int, 5, "minimum number of ITS clusters for tracks") + O2_DEFINE_CONFIGURABLE(tpcncrossedrows, int, 80, "minimum number of TPC crossed rows for tracks") + O2_DEFINE_CONFIGURABLE(tpcnclusters, int, 50, "minimum number of TPC clusters found") + O2_DEFINE_CONFIGURABLE(chi2pertpccluster, float, 2.5, "maximum Chi2 / cluster for the TPC track segment") + O2_DEFINE_CONFIGURABLE(chi2peritscluster, float, 36, "maximum Chi2 / cluster for the ITS track segment") // Filters and input definitions Filter collisionZVtxFilter = nabs(aod::collision::posZ) < cfgCutVertex; @@ -91,6 +115,11 @@ struct FilterCF { Produces outputCollRefs; Produces outputTrackRefs; + Produces outputMcParticleRefs; + + // persistent caches + std::vector mcReconstructedCache; + std::vector mcParticleLabelsCache; template bool keepCollision(TCollision& collision) @@ -106,7 +135,7 @@ struct FilterCF { } else if (cfgTrigger == 8) { return isMultSelected && collision.sel8(); } else if (cfgTrigger == 9) { // relevant only for Pb-Pb - return isMultSelected && collision.sel8() && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV); + return isMultSelected && collision.sel8() && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && collision.selection_bit(aod::evsel::kIsGoodITSLayersAll); } else if (cfgTrigger == 10) { // TVX trigger only (sel8 selection before April, 2024) return isMultSelected && collision.selection_bit(aod::evsel::kIsTriggerTVX); } else if (cfgTrigger == 11) { // sel8 selection for MC @@ -114,15 +143,58 @@ struct FilterCF { } else if (cfgTrigger == 12) { // relevant only for Pb-Pb with occupancy cuts and rejection of the collisions which have other events nearby int occupancy = collision.trackOccupancyInTimeRange(); if (occupancy >= cfgMinOcc && occupancy < cfgMaxOcc) - return isMultSelected && collision.sel8() && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && collision.selection_bit(aod::evsel::kNoCollInTimeRangeStandard); + return isMultSelected && collision.sel8() && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && collision.selection_bit(aod::evsel::kNoCollInTimeRangeStandard) && collision.selection_bit(aod::evsel::kIsGoodITSLayersAll); else return false; + } else if (cfgTrigger == 13) { // relevant for OO/NeNe + return isMultSelected && collision.sel8() && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodITSLayersAll); } return false; } - template - uint8_t getTrackType(TTrack& track) + using TrackType = soa::Filtered>; + + template + bool selectionPIDProton(const T& candidate) + { + o2::aod::ITSResponse itsResponse; + + if (ITSProtonselection && candidate.pt() <= 0.6 && !(itsResponse.nSigmaITS(candidate) > nsigmaCutITSProton)) { + return false; + } + if (ITSProtonselection && candidate.pt() > 0.6 && candidate.pt() <= 0.8 && !(itsResponse.nSigmaITS(candidate) > nsigmaCutITSProton)) { + return false; + } + + if (candidate.hasTOF()) { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPCProton) { + return true; + } + if (candidate.p() >= 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPCProton && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOFProton) { + return true; + } + } else { + if (std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPCProton) { + return true; + } + } + return false; + } + + template + struct HasProtonPID : std::false_type { + }; + + template + struct HasProtonPID().tpcNSigmaPr()), + decltype(std::declval().tofNSigmaPr()), + decltype(std::declval().hasTOF())>> + : std::true_type { + }; + + template + uint8_t getTrackType(const TTrack& track) { if (cfgTrackSelection == 0) { if (track.isGlobalTrack()) { @@ -135,20 +207,42 @@ struct FilterCF { uint8_t trackType = 0; if (track.isGlobalTrack()) { trackType |= kTrackSelected; - if (track.itsNCls() >= 5) { + if (track.itsNCls() >= itsnclusters) { trackType |= kITS5Clusters; } - if (track.tpcNClsCrossedRows() >= 90) { - trackType |= kTPC90CrossedRows; + if (track.tpcNClsCrossedRows() >= tpcncrossedrows) { + trackType |= kTPCCrossedRows; + } + if (track.tpcNClsFound() >= tpcnclusters) { + trackType |= kTPCClusters; + } + if (track.tpcChi2NCl() <= chi2pertpccluster) { + trackType |= kchi2perTPC; + } + if (track.itsChi2NCl() <= chi2peritscluster) { + trackType |= kchi2perITS; + } + } + return trackType; + } else if (cfgTrackSelection == 2) { + uint8_t trackType = 0; + if constexpr (HasProtonPID::value) { + if (track.isGlobalTrack() && (track.itsNCls() >= itsnclusters) && (track.tpcNClsCrossedRows() >= tpcncrossedrows) && selectionPIDProton(track)) { + trackType |= kPIDProton; } } return trackType; } + LOGF(fatal, "Invalid setting for cfgTrackSelection: %d", cfgTrackSelection.value); return 0; } - void processData(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks) + /// \brief Templetized process data for a given collision and its associated tracks + /// \param collision The collision object containing information about the collision + /// \param tracks The collection of tracks associated with the collision + template + void processDataT(const C1& collision, const T1& tracks) { if (cfgVerbosity > 0) { LOGF(info, "processData: Tracks for collision: %d | Vertex: %.1f (%d) | INT7: %d | Multiplicity: %.1f", tracks.size(), collision.posZ(), collision.flags(), collision.sel7(), collision.multiplicity()); @@ -158,13 +252,16 @@ struct FilterCF { return; } - auto bc = collision.bc_as(); + auto bc = collision.template bc_as(); outputCollisions(bc.runNumber(), collision.posZ(), collision.multiplicity(), bc.timestamp()); if (cfgTransientTables) outputCollRefs(collision.globalIndex()); - for (auto& track : tracks) { + if ((std::abs(track.dcaXY()) > dcaxymax) || (std::abs(track.dcaZ()) > dcazmax)) { + continue; + } + outputTracks(outputCollisions.lastIndex(), track.pt(), track.eta(), track.phi(), track.sign(), getTrackType(track)); if (cfgTransientTables) outputTrackRefs(collision.globalIndex(), track.globalIndex()); @@ -173,21 +270,39 @@ struct FilterCF { etaphi->Fill(collision.multiplicity(), track.eta(), track.phi()); } } + + void processData(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks) + { + processDataT(collision, tracks); + } PROCESS_SWITCH(FilterCF, processData, "Process data", true); - // NOTE not filtering collisions here because in that case there can be tracks referring to MC particles which are not part of the selected MC collisions - Preslice perMcCollision = aod::mcparticle::mcCollisionId; - Preslice perCollision = aod::track::collisionId; - void processMC(aod::McCollisions const& mcCollisions, aod::McParticles const& allParticles, - soa::Join const& allCollisions, - soa::Filtered> const& tracks, - aod::BCsWithTimestamps const&) + void processDataPid(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks) { - bool* reconstructed = new bool[allParticles.size()]; - int* mcParticleLabels = new int[allParticles.size()]; + processDataT(collision, tracks); + } + PROCESS_SWITCH(FilterCF, processDataPid, "Process data with PID", false); + + /// \brief Process MC data for a given set of MC collisions and associated particles and tracks + /// \param mcCollisions The collection of MC collisions + /// \param allParticles The collection of all MC particles + /// \param allCollisions The collection of all collisions, joined with MC collision labels and + /// event selections + /// \param tracks The collection of tracks, filtered by selection criteria + /// \param bcs The collection of bunch crossings with timestamps + template + void processMCT(aod::McCollisions const& mcCollisions, aod::McParticles const& allParticles, + soa::Join const& allCollisions, + T1 const& tracks, + aod::BCsWithTimestamps const&) + { + mcReconstructedCache.reserve(allParticles.size()); + mcParticleLabelsCache.reserve(allParticles.size()); + mcReconstructedCache.clear(); + mcParticleLabelsCache.clear(); for (int i = 0; i < allParticles.size(); i++) { - reconstructed[i] = false; - mcParticleLabels[i] = -1; + mcReconstructedCache.push_back(false); + mcParticleLabelsCache.push_back(-1); } // PASS 1 on collisions: check which particles are kept @@ -203,7 +318,7 @@ struct FilterCF { for (auto& track : groupedTracks) { if (track.has_mcParticle()) { - reconstructed[track.mcParticleId()] = true; + mcReconstructedCache[track.mcParticleId()] = true; } } } @@ -223,25 +338,29 @@ struct FilterCF { if (pdgparticle != nullptr) { sign = (pdgparticle->Charge() > 0) ? 1.0 : ((pdgparticle->Charge() < 0) ? -1.0 : 0.0); } + + bool special = !cfgMcSpecialPDGs->empty() && std::find(cfgMcSpecialPDGs->begin(), cfgMcSpecialPDGs->end(), particle.pdgCode()) != cfgMcSpecialPDGs->end(); bool primary = particle.isPhysicalPrimary() && sign != 0 && std::abs(particle.eta()) < cfgCutMCEta && particle.pt() > cfgCutMCPt; if (primary) { multiplicity++; } - if (reconstructed[particle.globalIndex()] || primary) { + if (mcReconstructedCache[particle.globalIndex()] || primary || special) { // keep particle // use highest bit to flag if it is reconstructed uint8_t flags = particle.flags() & ~aod::cfmcparticle::kReconstructed; // clear bit in case of clashes in the future - if (reconstructed[particle.globalIndex()]) { + if (mcReconstructedCache[particle.globalIndex()]) { flags |= aod::cfmcparticle::kReconstructed; } // NOTE using "outputMcCollisions.lastIndex()+1" here to allow filling of outputMcCollisions *after* the loop outputMcParticles(outputMcCollisions.lastIndex() + 1, truncateFloatFraction(particle.pt(), FLOAT_PRECISION), truncateFloatFraction(particle.eta(), FLOAT_PRECISION), truncateFloatFraction(particle.phi(), FLOAT_PRECISION), sign, particle.pdgCode(), flags); + if (cfgTransientTables) + outputMcParticleRefs(outputMcCollisions.lastIndex() + 1, particle.globalIndex()); // relabeling array - mcParticleLabels[particle.globalIndex()] = outputMcParticles.lastIndex(); + mcParticleLabelsCache[particle.globalIndex()] = outputMcParticles.lastIndex(); } } outputMcCollisions(mcCollision.posZ(), multiplicity); @@ -262,29 +381,50 @@ struct FilterCF { // NOTE works only when we store all MC collisions (as we do here) outputCollisions(bc.runNumber(), collision.posZ(), collision.multiplicity(), bc.timestamp()); outputMcCollisionLabels(collision.mcCollisionId()); + if (cfgTransientTables) + outputCollRefs(collision.globalIndex()); for (auto& track : groupedTracks) { int mcParticleId = track.mcParticleId(); if (mcParticleId >= 0) { - mcParticleId = mcParticleLabels[track.mcParticleId()]; + mcParticleId = mcParticleLabelsCache[track.mcParticleId()]; if (mcParticleId < 0) { - LOGP(fatal, "processMC: Track {} is referring to a MC particle which we do not store {} {} (reco flag {})", track.index(), track.mcParticleId(), mcParticleId, reconstructed[track.mcParticleId()]); + LOGP(fatal, "processMC: Track {} is referring to a MC particle which we do not store {} {} (reco flag {})", track.index(), track.mcParticleId(), mcParticleId, static_cast(mcReconstructedCache[track.mcParticleId()])); } } - outputTracks(outputCollisions.lastIndex(), - truncateFloatFraction(track.pt()), truncateFloatFraction(track.eta()), truncateFloatFraction(track.phi()), track.sign(), getTrackType(track)); + outputTracks(outputCollisions.lastIndex(), truncateFloatFraction(track.pt()), truncateFloatFraction(track.eta()), truncateFloatFraction(track.phi()), track.sign(), getTrackType(track)); outputTrackLabels(mcParticleId); + if (cfgTransientTables) + outputTrackRefs(collision.globalIndex(), track.globalIndex()); yields->Fill(collision.multiplicity(), track.pt(), track.eta()); etaphi->Fill(collision.multiplicity(), track.eta(), track.phi()); } } + } - delete[] reconstructed; - delete[] mcParticleLabels; + // NOTE not filtering collisions here because in that case there can be tracks referring to MC particles which are not part of the selected MC collisions + Preslice perMcCollision = aod::mcparticle::mcCollisionId; + Preslice perCollision = aod::track::collisionId; + void processMC(aod::McCollisions const& mcCollisions, aod::McParticles const& allParticles, + soa::Join const& allCollisions, + soa::Filtered> const& tracks, + aod::BCsWithTimestamps const& bcs) + { + processMCT(mcCollisions, allParticles, allCollisions, tracks, bcs); } PROCESS_SWITCH(FilterCF, processMC, "Process MC", false); + // NOTE not filtering collisions here because in that case there can be tracks referring to MC particles which are not part of the selected MC collisions + void processMCPid(aod::McCollisions const& mcCollisions, aod::McParticles const& allParticles, + soa::Join const& allCollisions, + soa::Filtered> const& tracks, + aod::BCsWithTimestamps const& bcs) + { + processMCT(mcCollisions, allParticles, allCollisions, tracks, bcs); + } + PROCESS_SWITCH(FilterCF, processMCPid, "Process MC with PID", false); + void processMCGen(aod::McCollisions::iterator const& mcCollision, aod::McParticles const& particles) { float multiplicity = 0.0f; @@ -329,9 +469,15 @@ struct MultiplicitySelector { if (doprocessFT0C) { enabledFunctions++; } + if (doprocessFT0CVariant1) { + enabledFunctions++; + } if (doprocessFT0A) { enabledFunctions++; } + if (doprocessCentNGlobal) { + enabledFunctions++; + } if (doprocessMCGen) { enabledFunctions++; } @@ -363,6 +509,14 @@ struct MultiplicitySelector { } PROCESS_SWITCH(MultiplicitySelector, processFT0C, "Select FT0C centrality as multiplicity", false); + void processFT0CVariant1(aod::CentFT0CVariant1s const& centralities) + { + for (auto& c : centralities) { + output(c.centFT0CVariant1()); + } + } + PROCESS_SWITCH(MultiplicitySelector, processFT0CVariant1, "Select FT0CVariant1 centrality as multiplicity", false); + void processFT0A(aod::CentFT0As const& centralities) { for (auto& c : centralities) { @@ -371,6 +525,14 @@ struct MultiplicitySelector { } PROCESS_SWITCH(MultiplicitySelector, processFT0A, "Select FT0A centrality as multiplicity", false); + void processCentNGlobal(aod::CentNGlobals const& centralities) + { + for (auto& c : centralities) { + output(c.centNGlobal()); + } + } + PROCESS_SWITCH(MultiplicitySelector, processCentNGlobal, "Select CentNGlobal centrality as multiplicity", false); + void processRun2V0M(aod::CentRun2V0Ms const& centralities) { for (auto& c : centralities) { diff --git a/PWGCF/Tasks/CMakeLists.txt b/PWGCF/Tasks/CMakeLists.txt index 233cb351d13..22e2b0f9f21 100644 --- a/PWGCF/Tasks/CMakeLists.txt +++ b/PWGCF/Tasks/CMakeLists.txt @@ -9,8 +9,8 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2physics_add_dpl_workflow(dptdptcorrelations - SOURCES dptdptcorrelations.cxx +o2physics_add_dpl_workflow(dpt-dpt-correlations + SOURCES dptDptCorrelations.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) diff --git a/PWGCF/Tasks/correlations.cxx b/PWGCF/Tasks/correlations.cxx index 25bd72aff28..941f9541612 100644 --- a/PWGCF/Tasks/correlations.cxx +++ b/PWGCF/Tasks/correlations.cxx @@ -13,35 +13,38 @@ /// \brief task for the correlation calculations with CF-filtered tracks for O2 analysis /// \author Jan Fiete Grosse-Oetringhaus , Jasper Parkkila -#include -#include -#include +#include "PWGCF/Core/CorrelationContainer.h" +#include "PWGCF/Core/PairCuts.h" +#include "PWGCF/DataModel/CorrelationsDerived.h" -#include -#include -#include -#include -#include +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" #include "CCDB/BasicCCDBManager.h" -#include "Framework/StepTHn.h" +#include "CommonConstants/MathConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/RunningWorkflowInfo.h" -#include "CommonConstants/MathConstants.h" -#include "Common/Core/RecoDecay.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "PWGCF/DataModel/CorrelationsDerived.h" -#include "PWGCF/Core/CorrelationContainer.h" -#include "PWGCF/Core/PairCuts.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -73,9 +76,9 @@ struct CorrelationTask { O2_DEFINE_CONFIGURABLE(cfgPtOrder, int, 1, "Only consider pairs for which pT,1 < pT,2 (0 = OFF, 1 = ON)"); O2_DEFINE_CONFIGURABLE(cfgTriggerCharge, int, 0, "Select on charge of trigger particle: 0 = all; 1 = positive; -1 = negative"); - O2_DEFINE_CONFIGURABLE(cfgAssociatedCharge, int, 0, "Select on charge of associated particle: 0 = all; 1 = positive; -1 = negative"); + O2_DEFINE_CONFIGURABLE(cfgAssociatedCharge, int, 0, "Select on charge of associated particle: 0 = all charged; 1 = positive; -1 = negative"); O2_DEFINE_CONFIGURABLE(cfgPairCharge, int, 0, "Select on charge of particle pair: 0 = all; 1 = like sign; -1 = unlike sign"); - O2_DEFINE_CONFIGURABLE(cfgCorrelateTheSame, int, 0, "Correlate the d0 with d0 or d0bar with d0bar, 0 = no, 1 = yes"); + O2_DEFINE_CONFIGURABLE(cfgCorrelationMethod, int, 0, "Correlation method, 0 = all, 1 = dd, 2 = ddbar"); O2_DEFINE_CONFIGURABLE(cfgTwoTrackCut, float, -1, "Two track cut: -1 = off; >0 otherwise distance value (suggested: 0.02)"); O2_DEFINE_CONFIGURABLE(cfgTwoTrackCutMinRadius, float, 0.8f, "Two track cut: radius in m from which two track cuts are applied"); @@ -93,9 +96,13 @@ struct CorrelationTask { O2_DEFINE_CONFIGURABLE(cfgVerbosity, int, 1, "Verbosity level (0 = major, 1 = per collision)") O2_DEFINE_CONFIGURABLE(cfgDecayParticleMask, int, 0, "Selection bitmask for the decay particles: 0 = no selection") + O2_DEFINE_CONFIGURABLE(cfgV0RapidityMax, float, 0.8, "Maximum rapidity for the decay particles (0 = no selection)") O2_DEFINE_CONFIGURABLE(cfgMassAxis, int, 0, "Use invariant mass axis (0 = OFF, 1 = ON)") O2_DEFINE_CONFIGURABLE(cfgMcTriggerPDGs, std::vector, {}, "MC PDG codes to use exclusively as trigger particles and exclude from associated particles. Empty = no selection.") + O2_DEFINE_CONFIGURABLE(cfgPtDepMLbkg, std::vector, {}, "pT interval for ML training") + O2_DEFINE_CONFIGURABLE(cfgPtCentDepMLbkgSel, std::vector, {}, "Bkg ML selection") + ConfigurableAxis axisVertex{"axisVertex", {7, -7, 7}, "vertex axis for histograms"}; ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"}; ConfigurableAxis axisDeltaEta{"axisDeltaEta", {40, -2, 2}, "delta eta axis for histograms"}; @@ -107,8 +114,7 @@ struct CorrelationTask { ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"}; ConfigurableAxis axisPtEfficiency{"axisPtEfficiency", {VARIABLE_WIDTH, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0}, "pt axis for efficiency histograms"}; - ConfigurableAxis axisInvMass{"axisInvMass", {VARIABLE_WIDTH, 0, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2.0, 5.0}, "invariant mass axis for histograms"}; - ConfigurableAxis axisInvMassHistogram{"axisInvMassHistogram", {1000, 1.0, 3.0}, "invariant mass histogram binning"}; + ConfigurableAxis axisInvMass{"axisInvMass", {VARIABLE_WIDTH, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2.0, 5.0}, "invariant mass axis for histograms"}; // This filter is applied to AOD and derived data (column names are identical) Filter collisionZVtxFilter = nabs(aod::collision::posZ) < cfgCutVertex; @@ -121,7 +127,7 @@ struct CorrelationTask { // MC filters Filter cfMCCollisionFilter = nabs(aod::mccollision::posZ) < cfgCutVertex; - Filter cfMCParticleFilter = (nabs(aod::cfmcparticle::eta) < cfgCutEta) && (aod::cfmcparticle::pt > cfgCutPt) && (aod::cfmcparticle::sign != 0); + Filter cfMCParticleFilter = (nabs(aod::cfmcparticle::eta) < cfgCutEta) && (aod::cfmcparticle::pt > cfgCutPt); // && (aod::cfmcparticle::sign != 0); //check the sign manually, some specials may be neutral // HF filters Filter track2pFilter = (nabs(aod::cf2prongtrack::eta) < cfgCutEta) && (aod::cf2prongtrack::pt > cfgCutPt); @@ -130,7 +136,9 @@ struct CorrelationTask { OutputObj same{"sameEvent"}; OutputObj mixed{"mixedEvent"}; + // persistent caches std::vector efficiencyAssociatedCache; + std::vector p2indexCache; struct Config { bool mPairCuts = false; @@ -152,21 +160,30 @@ struct CorrelationTask { void init(o2::framework::InitContext&) { + if ((doprocessSame2ProngDerivedML || doprocessSame2Prong2ProngML || doprocessMixed2ProngDerivedML || doprocessMixed2Prong2ProngML) && (cfgPtDepMLbkg->empty() || cfgPtCentDepMLbkgSel->empty())) + LOGF(fatal, "cfgPtDepMLbkg or cfgPtCentDepMLbkgSel can not be empty when ML 2-prong selections are used."); registry.add("yields", "multiplicity/centrality vs pT vs eta", {HistType::kTH3F, {{100, 0, 100, "/multiplicity/centrality"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); registry.add("etaphi", "multiplicity/centrality vs eta vs phi", {HistType::kTH3F, {{100, 0, 100, "multiplicity/centrality"}, {100, -2, 2, "#eta"}, {200, 0, o2::constants::math::TwoPI, "#varphi"}}}); - if (doprocessSame2ProngDerived || doprocessMixed2ProngDerived || doprocessSame2Prong2Prong) { + if (doprocessSame2ProngDerived || doprocessSame2ProngDerivedML || doprocessSame2Prong2Prong || doprocessSame2Prong2ProngML || doprocessMCSameDerived2Prong) { registry.add("yieldsTrigger", "multiplicity/centrality vs pT vs eta (triggers)", {HistType::kTH3F, {{100, 0, 100, "/multiplicity/centrality"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); registry.add("etaphiTrigger", "multiplicity/centrality vs eta vs phi (triggers)", {HistType::kTH3F, {{100, 0, 100, "multiplicity/centrality"}, {100, -2, 2, "#eta"}, {200, 0, o2::constants::math::TwoPI, "#varphi"}}}); - registry.add("invMass", "2-prong invariant mass (GeV/c^2)", {HistType::kTH3F, {axisInvMassHistogram, axisPtTrigger, axisMultiplicity}}); - if (doprocessSame2Prong2Prong) { - registry.add("invMassTwoPart", "2D 2-prong invariant mass (GeV/c^2)", {HistType::kTHnSparseF, {axisInvMassHistogram, axisInvMassHistogram, axisPtTrigger, axisPtAssoc, axisMultiplicity}}); + const AxisSpec& a = AxisSpec(axisInvMass); + AxisSpec axisSpecMass = {1000, a.binEdges[0], a.binEdges[a.getNbins()]}; + registry.add("invMass", "2-prong invariant mass (GeV/c^2)", {HistType::kTH3F, {axisSpecMass, axisPtTrigger, axisMultiplicity}}); + if (doprocessSame2Prong2Prong || doprocessSame2Prong2ProngML) { + registry.add("invMassTwoPart", "2D 2-prong invariant mass (GeV/c^2)", {HistType::kTHnSparseF, {axisSpecMass, axisSpecMass, axisPtTrigger, axisPtAssoc, axisMultiplicity}}); + registry.add("invMassTwoPartDPhi", "2D 2-prong invariant mass (GeV/c^2)", {HistType::kTHnSparseF, {axisSpecMass, axisSpecMass, axisPtTrigger, axisPtAssoc, axisDeltaPhi}}); } } registry.add("multiplicity", "event multiplicity", {HistType::kTH1F, {{1000, 0, 100, "/multiplicity/centrality"}}}); + registry.add("yvspt", "y vs pT", {HistType::kTH2F, {{100, -1, 1, "y"}, {100, 0, 20, "p_{T}"}}}); // y vs pT for all tracks (control histogram) const int maxMixBin = AxisSpec(axisMultiplicity).getNbins() * AxisSpec(axisVertex).getNbins(); + // The bin numbers for the control histograms (eventcount_*) come from getBin(...) and are the following: #mult_bin * #number_of_z_bins + #zbin registry.add("eventcount_same", "bin", {HistType::kTH1F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}}}); registry.add("eventcount_mixed", "bin", {HistType::kTH1F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}}}); + registry.add("trackcount_same", "bin", {HistType::kTH2F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}, {10, -0.5, 9.5}}}); + registry.add("trackcount_mixed", "bin", {HistType::kTH3F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}, {10, -0.5, 9.5}, {10, -0.5, 9.5}}}); mPairCuts.SetHistogramRegistry(®istry); @@ -201,9 +218,9 @@ struct CorrelationTask { userAxis.emplace_back(axisInvMass, "m (GeV/c^2)"); userMixingAxis.emplace_back(axisInvMass, "m (GeV/c^2)"); } - if (doprocessSame2Prong2Prong) + if (doprocessSame2Prong2Prong || doprocessSame2Prong2ProngML) userAxis.emplace_back(axisInvMass, "m (GeV/c^2)"); - if (doprocessMixed2Prong2Prong) + if (doprocessMixed2Prong2Prong || doprocessMixed2Prong2ProngML) userMixingAxis.emplace_back(axisInvMass, "m (GeV/c^2)"); same.setObject(new CorrelationContainer("sameEvent", "sameEvent", corrAxis, effAxis, userAxis)); @@ -212,7 +229,13 @@ struct CorrelationTask { same->setTrackEtaCut(cfgCutEta); mixed->setTrackEtaCut(cfgCutEta); - efficiencyAssociatedCache.reserve(512); + if (!cfgEfficiencyAssociated.value.empty()) + efficiencyAssociatedCache.reserve(512); + if (doprocessMCEfficiency2Prong || doprocessMCEfficiency2ProngML) { + p2indexCache.reserve(16); + if (cfgMcTriggerPDGs->empty()) + LOGF(fatal, "At least one PDG code in {} is to be selected to process 2-prong efficiency.", cfgMcTriggerPDGs.name); + } // o2-ccdb-upload -p Users/jgrosseo/correlations/LHC15o -f /tmp/correction_2011_global.root -k correction @@ -241,6 +264,14 @@ struct CorrelationTask { return grpo->getNominalL3Field(); } + template + bool passMLScore(const p2typeIterator& track) + { + auto it = std::lower_bound(cfgPtDepMLbkg->begin(), cfgPtDepMLbkg->end(), track.pt()); + int idx = std::distance(cfgPtDepMLbkg->begin(), it) - 1; + return !((track.decay() == 0 && track.mlProbD0()[0] > cfgPtCentDepMLbkgSel->at(idx)) || (track.decay() == 1 && track.mlProbD0bar()[0] > cfgPtCentDepMLbkgSel->at(idx))); + } + template void fillQA(const TCollision& /*collision*/, float multiplicity, const TTracks& tracks) { @@ -260,26 +291,62 @@ struct CorrelationTask { void fillQA(const TCollision& collision, float multiplicity, const TTracks1& tracks1, const TTracks2& tracks2) { for (const auto& track1 : tracks1) { - if constexpr (std::experimental::is_detected::value) { - if constexpr (std::experimental::is_detected::value) { - if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast(track1.decay()))) == 0u) + if constexpr (std::experimental::is_detected::value && std::experimental::is_detected::value) { + if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast(track1.decay()))) == 0u) + continue; + if constexpr (std::experimental::is_detected::value) { + if (!passMLScore(track1)) continue; } registry.fill(HIST("invMass"), track1.invMass(), track1.pt(), multiplicity); for (const auto& track2 : tracks2) { if constexpr (std::experimental::is_detected::value && std::experimental::is_detected::value) { - if (doprocessSame2Prong2Prong || doprocessMixed2Prong2Prong) { + if (doprocessSame2Prong2Prong || doprocessMixed2Prong2Prong || doprocessSame2Prong2ProngML || doprocessMixed2Prong2ProngML) { if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast(track1.decay()))) == 0u) continue; - if ((track1.decay() != 0) || (track2.decay() != 1)) // D0 in trk1, D0bar in trk2 + if constexpr (std::experimental::is_detected::value) { + if (!passMLScore(track2)) + continue; + } + + if constexpr (std::experimental::is_detected::value) { + if constexpr (std::experimental::is_detected::value) { + if (track1.cfTrackProng0Id() == track2.cfTrackProng0Id()) { + continue; + } + } + if constexpr (std::experimental::is_detected::value) { + if (track1.cfTrackProng0Id() == track2.cfTrackProng1Id()) { + continue; + } + } + } + + if constexpr (std::experimental::is_detected::value) { + if constexpr (std::experimental::is_detected::value) { + if (track1.cfTrackProng1Id() == track2.cfTrackProng0Id()) { + continue; + } + } + if constexpr (std::experimental::is_detected::value) { + if (track1.cfTrackProng1Id() == track2.cfTrackProng1Id()) { + continue; + } + } + } // no shared prong for two mothers + + if (cfgCorrelationMethod == 1 && track1.decay() != track2.decay()) + continue; + if (cfgCorrelationMethod == 2 && track1.decay() == track2.decay()) continue; registry.fill(HIST("invMassTwoPart"), track1.invMass(), track2.invMass(), track1.pt(), track2.pt(), multiplicity); + registry.fill(HIST("invMassTwoPartDPhi"), track1.invMass(), track2.invMass(), track1.pt(), track2.pt(), TVector2::Phi_0_2pi(track1.phi() - track2.phi() + TMath::Pi() / 2.0) - TMath::Pi() / 2.0); } } } } if constexpr (std::experimental::is_detected::value) { - if (!cfgMcTriggerPDGs->empty() && std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), track1->pdgCode()) == cfgMcTriggerPDGs->end()) + if (!cfgMcTriggerPDGs->empty() && std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), track1.pdgCode()) == cfgMcTriggerPDGs->end()) continue; } registry.fill(HIST("yieldsTrigger"), multiplicity, track1.pt(), track1.eta()); @@ -321,9 +388,51 @@ struct CorrelationTask { template using HasDecay = decltype(std::declval().decay()); template + using HasMcDecay = decltype(std::declval().mcDecay()); + template using HasProng0Id = decltype(std::declval().cfTrackProng0Id()); template using HasProng1Id = decltype(std::declval().cfTrackProng1Id()); + template + using HasMlProbD0 = decltype(std::declval().mlProbD0()); + template + using HasPartDaugh0Id = decltype(std::declval().cfParticleDaugh0Id()); + template + using HasPartDaugh1Id = decltype(std::declval().cfParticleDaugh1Id()); + + template + float getV0Rapidity(const T& track) + { + const float pt = track.pt(); + const float eta = track.eta(); + const float phi = track.phi(); + + const float px = pt * std::cos(phi); + const float py = pt * std::sin(phi); + const float pz = pt * std::sinh(eta); + + const float p2 = px * px + py * py + pz * pz; + + if constexpr (std::experimental::is_detected::value) { + const auto decayType = track.decay(); + float mass = 0.f; + + if (decayType == aod::cf2prongtrack::K0stoPiPi) { + mass = o2::constants::physics::MassK0Short; + } else if (decayType == aod::cf2prongtrack::LambdatoPPi || decayType == aod::cf2prongtrack::AntiLambdatoPiP) { + mass = o2::constants::physics::MassLambda; + } else if (decayType == aod::cf2prongtrack::PhiToKK) { + mass = o2::constants::physics::MassPhi; + } else { + return -999.f; // unsupported decay type, return dummy rapidity + } + + const float E = std::sqrt(p2 + mass * mass); + return 0.5f * std::log((E + pz) / (E - pz)); + } + + return -999.f; // no decay type, return dummy rapidity + } template void fillCorrelations(TTarget target, TTracks1& tracks1, TTracks2& tracks2, float multiplicity, float posZ, int magField, float eventWeight) @@ -342,28 +451,55 @@ struct CorrelationTask { for (const auto& track1 : tracks1) { // LOGF(info, "Track %f | %f | %f %d %d", track1.eta(), track1.phi(), track1.pt(), track1.isGlobalTrack(), track1.isGlobalTrackSDD()); - if constexpr (step <= CorrelationContainer::kCFStepTracked) { + if constexpr (step <= CorrelationContainer::kCFStepTracked && !std::experimental::is_detected::value) { if (!checkObject(track1)) { continue; } } - if constexpr (std::experimental::is_detected::value) { - if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast(track1.decay()))) == 0u) - continue; - } - + // sign check and PDG code special cases if constexpr (std::experimental::is_detected::value) { - if (!cfgMcTriggerPDGs->empty() && std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), track1.pdgCode()) == cfgMcTriggerPDGs->end()) + // If the MC trigger particle is on the trigger PDG code list, we will accept them regardless of their charge. + if (!cfgMcTriggerPDGs->empty()) { + if (std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), track1.pdgCode()) == cfgMcTriggerPDGs->end()) + continue; + } else { // otherwise check the sign against the configuration + if (cfgTriggerCharge != 0) { + if (cfgTriggerCharge * track1.sign() < 0) + continue; + } else if (track1.sign() == 0) { + continue; // reject neutral MC particles + } + } + } else if constexpr (std::experimental::is_detected::value) { + // Check reco objects that have the sign attribute. There are no neutrals to deal with. + if (cfgTriggerCharge != 0 && cfgTriggerCharge * track1.sign() < 0) continue; } - if constexpr (std::experimental::is_detected::value) { - if (cfgTriggerCharge != 0 && cfgTriggerCharge * track1.sign() < 0) { + if constexpr (std::experimental::is_detected::value) { + if (((track1.mcDecay() != aod::cf2prongtrack::D0ToPiK) && (track1.mcDecay() != aod::cf2prongtrack::D0barToKPi)) || (track1.decay() & aod::cf2prongmcpart::Prompt) == 0) continue; + } else if constexpr (std::experimental::is_detected::value) { + if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast(track1.decay()))) == 0u) { + continue; // skip particles that do not match the decay mask } + if (cfgV0RapidityMax > 0 && std::abs(getV0Rapidity(track1)) > cfgV0RapidityMax) { + continue; // V0s are not allowed to be outside the rapidity range + } + registry.fill(HIST("yvspt"), getV0Rapidity(track1), track1.pt()); } + if constexpr (std::experimental::is_detected::value) { + if (track1.cfParticleDaugh0Id() < 0 && track1.cfParticleDaugh1Id() < 0) + continue; // these we could not match + } + + if constexpr (std::experimental::is_detected::value) { + if (!passMLScore(track1)) + continue; + } // ML selection + float triggerWeight = eventWeight; if constexpr (step == CorrelationContainer::kCFStepCorrected) { if (cfg.mEfficiencyTrigger) { @@ -374,8 +510,13 @@ struct CorrelationTask { if (cfgMassAxis) { if constexpr (std::experimental::is_detected::value) target->getTriggerHist()->Fill(step, track1.pt(), multiplicity, posZ, track1.invMass(), triggerWeight); - else + else if constexpr (std::experimental::is_detected::value) { + // TParticlePDG *p = pdg->GetParticle(track1.pdgCode()); + // target->getTriggerHist()->Fill(step, track1.pt(), multiplicity, posZ, p->Mass(), triggerWeight); + target->getTriggerHist()->Fill(step, track1.pt(), multiplicity, posZ, 1.8, triggerWeight); + } else { LOGF(fatal, "Can not fill mass axis without invMass column. Disable cfgMassAxis."); + } } else { target->getTriggerHist()->Fill(step, track1.pt(), multiplicity, posZ, triggerWeight); } @@ -387,11 +528,12 @@ struct CorrelationTask { continue; } } - if constexpr (std::experimental::is_detected::value) { + if constexpr (std::experimental::is_detected::value) { // skip those that are specifically chosen to be triggers if (!cfgMcTriggerPDGs->empty() && std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), track2.pdgCode()) != cfgMcTriggerPDGs->end()) - continue; + continue; // TODO: fix cases like MC D0-D0 } + // Daughter track and particle checks if constexpr (std::experimental::is_detected::value) { if (track2.globalIndex() == track1.cfTrackProng0Id()) // do not correlate daughter tracks of the same event continue; @@ -400,24 +542,39 @@ struct CorrelationTask { if (track2.globalIndex() == track1.cfTrackProng1Id()) // do not correlate daughter tracks of the same event continue; } + if constexpr (std::experimental::is_detected::value) { + if (track2.globalIndex() == track1.cfParticleDaugh0Id()) // do not correlate daughter particles of the same event + continue; + } + if constexpr (std::experimental::is_detected::value) { + if (track2.globalIndex() == track1.cfParticleDaugh1Id()) // do not correlate daughter particles of the same event + continue; + } - if constexpr (step <= CorrelationContainer::kCFStepTracked) { + if constexpr (step <= CorrelationContainer::kCFStepTracked && !std::experimental::is_detected::value) { if (!checkObject(track2)) { continue; } } - if constexpr (std::experimental::is_detected::value) { - if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast(track2.decay()))) == 0u) + // If decay attributes are found for the second track/particle, we assume 2p-2p correlation + if constexpr (std::experimental::is_detected::value) { + if ((((track2.mcDecay()) != aod::cf2prongtrack::D0ToPiK) && ((track2.mcDecay()) != aod::cf2prongtrack::D0barToKPi)) || (track2.decay() & aod::cf2prongmcpart::Prompt) == 0) continue; + } else if constexpr (std::experimental::is_detected::value) { + if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast(track2.decay()))) == 0u) { + continue; // skip particles that do not match the decay mask + } + if (cfgV0RapidityMax > 0 && std::abs(getV0Rapidity(track1)) > cfgV0RapidityMax) { + continue; // V0s are not allowed to be outside the rapidity range + } } if constexpr (std::experimental::is_detected::value && std::experimental::is_detected::value) { - if (cfgCorrelateTheSame == 0 && (doprocessSame2Prong2Prong || doprocessMixed2Prong2Prong) && (track1.decay() == track2.decay() || track1.decay() > 1 || track2.decay() > 1)) { - continue; // D0 and anti-D0 selection - } else if (cfgCorrelateTheSame == 1 && (doprocessSame2Prong2Prong || doprocessMixed2Prong2Prong) && (track1.decay() != track2.decay() || track1.decay() > 1 || track2.decay() > 1)) { - continue; // the same particle selection - } + if (cfgCorrelationMethod == 1 && track1.decay() != track2.decay()) + continue; + if (cfgCorrelationMethod == 2 && track1.decay() == track2.decay()) + continue; } if constexpr (std::experimental::is_detected::value) { @@ -445,13 +602,18 @@ struct CorrelationTask { } } } // no shared prong for two mothers + // TODO MC daughters check ^^ if (cfgPtOrder != 0 && track2.pt() >= track1.pt()) { continue; } if constexpr (std::experimental::is_detected::value) { - if (cfgAssociatedCharge != 0 && cfgAssociatedCharge * track2.sign() < 0) { + // TODO: support for MC D0-D0 case + if (cfgAssociatedCharge != 0) { + if (cfgAssociatedCharge * track2.sign() < 0) + continue; + } else if (track2.sign() == 0) { // mc particles come in neutrals, need to check explicitly continue; } } @@ -484,8 +646,13 @@ struct CorrelationTask { float deltaPhi = RecoDecay::constrainAngle(track1.phi() - track2.phi(), -o2::constants::math::PIHalf); + if constexpr (std::experimental::is_detected::value) { + if (!passMLScore(track2)) + continue; + } // ML selection + // last param is the weight - if (cfgMassAxis && (doprocessSame2Prong2Prong || doprocessMixed2Prong2Prong) && !(doprocessSame2ProngDerived || doprocessMixed2ProngDerived)) { + if (cfgMassAxis && (doprocessSame2Prong2Prong || doprocessMixed2Prong2Prong || doprocessSame2Prong2ProngML || doprocessMixed2Prong2ProngML) && !(doprocessSame2ProngDerived || doprocessSame2ProngDerivedML || doprocessMixed2ProngDerived || doprocessMixed2ProngDerivedML)) { if constexpr (std::experimental::is_detected::value && std::experimental::is_detected::value) target->getPairHist()->Fill(step, track1.eta() - track2.eta(), track2.pt(), track1.pt(), multiplicity, deltaPhi, posZ, track2.invMass(), track1.invMass(), associatedWeight); else @@ -493,8 +660,12 @@ struct CorrelationTask { } else if (cfgMassAxis) { if constexpr (std::experimental::is_detected::value) target->getPairHist()->Fill(step, track1.eta() - track2.eta(), track2.pt(), track1.pt(), multiplicity, deltaPhi, posZ, track1.invMass(), associatedWeight); - else + else if constexpr (std::experimental::is_detected::value) { + // TParticlePDG *p = pdg->GetParticle(track1.pdgCode()); //TODO: get the mass for the PDG properly + target->getPairHist()->Fill(step, track1.eta() - track2.eta(), track2.pt(), track1.pt(), multiplicity, deltaPhi, posZ, 1.8, associatedWeight); // p->Mass() + } else { LOGF(fatal, "Can not fill mass axis without invMass column. Disable cfgMassAxis."); + } } else { target->getPairHist()->Fill(step, track1.eta() - track2.eta(), track2.pt(), track1.pt(), multiplicity, deltaPhi, posZ, associatedWeight); } @@ -568,11 +739,12 @@ struct CorrelationTask { } PROCESS_SWITCH(CorrelationTask, processSameAOD, "Process same event on AOD", true); - void processSameDerived(DerivedCollisions::iterator const& collision, soa::Filtered const& tracks) + template + void processSameDerivedT(DerivedCollisions::iterator const& collision, TTracks1 const& tracks1, TTracks2 const& tracks2) { BinningTypeDerived configurableBinningDerived{{axisVertex, axisMultiplicity}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. if (cfgVerbosity > 0) { - LOGF(info, "processSameDerived: Tracks for collision: %d | Vertex: %.1f | Multiplicity/Centrality: %.1f", tracks.size(), collision.posZ(), collision.multiplicity()); + LOGF(info, "processSameDerivedT: Tracks for collision: %d/%d | Vertex: %.1f | Multiplicity/Centrality: %.1f", tracks1.size(), tracks2.size(), collision.posZ(), collision.multiplicity()); } loadEfficiency(collision.timestamp()); @@ -584,66 +756,51 @@ struct CorrelationTask { int bin = configurableBinningDerived.getBin({collision.posZ(), collision.multiplicity()}); registry.fill(HIST("eventcount_same"), bin); - fillQA(collision, multiplicity, tracks); + registry.fill(HIST("trackcount_same"), bin, tracks1.size()); + if constexpr (std::experimental::is_detected::value) + fillQA(collision, multiplicity, tracks1, tracks2); + else + fillQA(collision, multiplicity, tracks1); same->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCorrelations(same, tracks, tracks, multiplicity, collision.posZ(), field, 1.0f); + fillCorrelations(same, tracks1, tracks2, multiplicity, collision.posZ(), field, 1.0f); if (cfg.mEfficiencyAssociated || cfg.mEfficiencyTrigger) { same->fillEvent(multiplicity, CorrelationContainer::kCFStepCorrected); - fillCorrelations(same, tracks, tracks, multiplicity, collision.posZ(), field, 1.0f); + fillCorrelations(same, tracks1, tracks2, multiplicity, collision.posZ(), field, 1.0f); } } + + void processSameDerived(DerivedCollisions::iterator const& collision, soa::Filtered const& tracks) + { + processSameDerivedT(collision, tracks, tracks); + } PROCESS_SWITCH(CorrelationTask, processSameDerived, "Process same event on derived data", false); void processSame2ProngDerived(DerivedCollisions::iterator const& collision, soa::Filtered const& tracks, soa::Filtered const& p2tracks) { - BinningTypeDerived configurableBinningDerived{{axisVertex, axisMultiplicity}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. - if (cfgVerbosity > 0) { - LOGF(info, "processSame2ProngDerived: Tracks for collision: %d | 2-prong candidates: %d | Vertex: %.1f | Multiplicity/Centrality: %.1f", tracks.size(), p2tracks.size(), collision.posZ(), collision.multiplicity()); - } - loadEfficiency(collision.timestamp()); - - const auto multiplicity = collision.multiplicity(); - - int bin = configurableBinningDerived.getBin({collision.posZ(), collision.multiplicity()}); - registry.fill(HIST("eventcount_same"), bin); - fillQA(collision, multiplicity, p2tracks, tracks); - - same->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCorrelations(same, p2tracks, tracks, multiplicity, collision.posZ(), 0, 1.0f); - - if (cfg.mEfficiencyAssociated || cfg.mEfficiencyTrigger) { - same->fillEvent(multiplicity, CorrelationContainer::kCFStepCorrected); - fillCorrelations(same, p2tracks, tracks, multiplicity, collision.posZ(), 0, 1.0f); - } + processSameDerivedT(collision, p2tracks, tracks); } PROCESS_SWITCH(CorrelationTask, processSame2ProngDerived, "Process same event on derived data", false); - void processSame2Prong2Prong(DerivedCollisions::iterator const& collision, soa::Filtered const& p2tracks) + void processSame2ProngDerivedML(DerivedCollisions::iterator const& collision, soa::Filtered const& tracks, soa::Filtered> const& p2tracks) { - BinningTypeDerived configurableBinningDerived{{axisVertex, axisMultiplicity}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. - if (cfgVerbosity > 0) { - LOGF(info, "processSame2ProngDerived: 2-prong candidates: %d | Vertex: %.1f | Multiplicity/Centrality: %.1f", p2tracks.size(), collision.posZ(), collision.multiplicity()); - } - loadEfficiency(collision.timestamp()); - - const auto multiplicity = collision.multiplicity(); - - int bin = configurableBinningDerived.getBin({collision.posZ(), collision.multiplicity()}); - registry.fill(HIST("eventcount_same"), bin); - fillQA(collision, multiplicity, p2tracks, p2tracks); - - same->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCorrelations(same, p2tracks, p2tracks, multiplicity, collision.posZ(), 0, 1.0f); + processSameDerivedT(collision, p2tracks, tracks); + } + PROCESS_SWITCH(CorrelationTask, processSame2ProngDerivedML, "Process same event on derived data with ML scores", false); - if (cfg.mEfficiencyAssociated || cfg.mEfficiencyTrigger) { - same->fillEvent(multiplicity, CorrelationContainer::kCFStepCorrected); - fillCorrelations(same, p2tracks, p2tracks, multiplicity, collision.posZ(), 0, 1.0f); - } + void processSame2Prong2Prong(DerivedCollisions::iterator const& collision, soa::Filtered const& p2tracks) + { + processSameDerivedT(collision, p2tracks, p2tracks); } PROCESS_SWITCH(CorrelationTask, processSame2Prong2Prong, "Process same event on derived data", false); + void processSame2Prong2ProngML(DerivedCollisions::iterator const& collision, soa::Filtered> const& p2tracks) + { + processSameDerivedT(collision, p2tracks, p2tracks); + } + PROCESS_SWITCH(CorrelationTask, processSame2Prong2ProngML, "Process same event on derived data with ML scores", false); + using BinningTypeAOD = ColumnBinningPolicy; void processMixedAOD(AodCollisions const& collisions, AodTracks const& tracks, aod::BCsWithTimestamps const&) { @@ -688,12 +845,16 @@ struct CorrelationTask { PROCESS_SWITCH(CorrelationTask, processMixedAOD, "Process mixed events on AOD", false); using BinningTypeDerived = ColumnBinningPolicy; - void processMixedDerived(DerivedCollisions const& collisions, DerivedTracks const& tracks) + + template + void processMixedDerivedT(DerivedCollisions const& collisions, TrackTypes&&... tracks) { BinningTypeDerived configurableBinningDerived{{axisVertex, axisMultiplicity}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. // Strictly upper categorised collisions, for cfgNoMixedEvents combinations per bin, skipping those in entry -1 - auto tracksTuple = std::make_tuple(tracks); - SameKindPair pairs{configurableBinningDerived, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + auto tracksTuple = std::make_tuple(std::forward(tracks)...); + using TA = std::tuple_element<0, decltype(tracksTuple)>::type; + using TB = std::tuple_element - 1, decltype(tracksTuple)>::type; + Pair pairs{configurableBinningDerived, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip for (auto it = pairs.begin(); it != pairs.end(); it++) { auto& [collision1, tracks1, collision2, tracks2] = *it; @@ -717,6 +878,7 @@ struct CorrelationTask { // LOGF(info, "Tracks: %d and %d entries", tracks1.size(), tracks2.size()); registry.fill(HIST("eventcount_mixed"), bin); + registry.fill(HIST("trackcount_mixed"), bin, tracks1.size(), tracks2.size()); fillCorrelations(mixed, tracks1, tracks2, collision1.multiplicity(), collision1.posZ(), field, eventWeight); if (cfg.mEfficiencyAssociated || cfg.mEfficiencyTrigger) { @@ -727,86 +889,37 @@ struct CorrelationTask { } } } + + void processMixedDerived(DerivedCollisions const& collisions, DerivedTracks const& tracks) + { + processMixedDerivedT(collisions, tracks); + } PROCESS_SWITCH(CorrelationTask, processMixedDerived, "Process mixed events on derived data", false); void processMixed2ProngDerived(DerivedCollisions const& collisions, DerivedTracks const& tracks, soa::Filtered const& p2tracks) { - BinningTypeDerived configurableBinningDerived{{axisVertex, axisMultiplicity}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. - // Strictly upper categorised collisions, for cfgNoMixedEvents combinations per bin, skipping those in entry -1 - auto tracksTuple = std::make_tuple(p2tracks, tracks); - Pair, DerivedTracks, BinningTypeDerived> pairs{configurableBinningDerived, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip - - for (auto it = pairs.begin(); it != pairs.end(); it++) { - auto& [collision1, tracks1, collision2, tracks2] = *it; - int bin = configurableBinningDerived.getBin({collision1.posZ(), collision1.multiplicity()}); - float eventWeight = 1.0f / it.currentWindowNeighbours(); - int field = 0; - if (cfgTwoTrackCut > 0) { - field = getMagneticField(collision1.timestamp()); - } - - if (cfgVerbosity > 0) { - LOGF(info, "processMixed2ProngDerived: Mixed collisions bin: %d pair: [%d, %d] %d (%.3f, %.3f), %d (%.3f, %.3f)", bin, it.isNewWindow(), it.currentWindowNeighbours(), collision1.globalIndex(), collision1.posZ(), collision1.multiplicity(), collision2.globalIndex(), collision2.posZ(), collision2.multiplicity()); - } - - if (it.isNewWindow()) { - loadEfficiency(collision1.timestamp()); - - mixed->fillEvent(collision1.multiplicity(), CorrelationContainer::kCFStepReconstructed); - } - - registry.fill(HIST("eventcount_mixed"), bin); - fillCorrelations(mixed, tracks1, tracks2, collision1.multiplicity(), collision1.posZ(), field, eventWeight); - - if (cfg.mEfficiencyAssociated || cfg.mEfficiencyTrigger) { - if (it.isNewWindow()) { - mixed->fillEvent(collision1.multiplicity(), CorrelationContainer::kCFStepCorrected); - } - fillCorrelations(mixed, tracks1, tracks2, collision1.multiplicity(), collision1.posZ(), field, eventWeight); - } - } + processMixedDerivedT(collisions, p2tracks, tracks); } PROCESS_SWITCH(CorrelationTask, processMixed2ProngDerived, "Process mixed events on derived data", false); - void processMixed2Prong2Prong(DerivedCollisions const& collisions, soa::Filtered const& p2tracks) + void processMixed2ProngDerivedML(DerivedCollisions const& collisions, DerivedTracks const& tracks, soa::Filtered> const& p2tracks) { - BinningTypeDerived configurableBinningDerived{{axisVertex, axisMultiplicity}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. - // Strictly upper categorised collisions, for cfgNoMixedEvents combinations per bin, skipping those in entry -1 - auto tracksTuple = std::make_tuple(p2tracks); - SameKindPair, BinningTypeDerived> pairs{configurableBinningDerived, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip - - for (auto it = pairs.begin(); it != pairs.end(); it++) { - auto& [collision1, tracks1, collision2, tracks2] = *it; - int bin = configurableBinningDerived.getBin({collision1.posZ(), collision1.multiplicity()}); - float eventWeight = 1.0f / it.currentWindowNeighbours(); - int field = 0; - if (cfgTwoTrackCut > 0) { - field = getMagneticField(collision1.timestamp()); - } - - if (cfgVerbosity > 0) { - LOGF(info, "processMixedDerived: Mixed collisions bin: %d pair: [%d, %d] %d (%.3f, %.3f), %d (%.3f, %.3f)", bin, it.isNewWindow(), it.currentWindowNeighbours(), collision1.globalIndex(), collision1.posZ(), collision1.multiplicity(), collision2.globalIndex(), collision2.posZ(), collision2.multiplicity()); - } - - if (it.isNewWindow()) { - loadEfficiency(collision1.timestamp()); - mixed->fillEvent(collision1.multiplicity(), CorrelationContainer::kCFStepReconstructed); - } - - // LOGF(info, "Tracks: %d and %d entries", tracks1.size(), tracks2.size()); + processMixedDerivedT(collisions, p2tracks, tracks); + } + PROCESS_SWITCH(CorrelationTask, processMixed2ProngDerivedML, "Process mixed events on derived data with ML scores", false); - registry.fill(HIST("eventcount_mixed"), bin); - fillCorrelations(mixed, tracks1, tracks2, collision1.multiplicity(), collision1.posZ(), field, eventWeight); - if (cfg.mEfficiencyAssociated || cfg.mEfficiencyTrigger) { - if (it.isNewWindow()) { - mixed->fillEvent(collision1.multiplicity(), CorrelationContainer::kCFStepCorrected); - } - fillCorrelations(mixed, tracks1, tracks2, collision1.multiplicity(), collision1.posZ(), field, eventWeight); - } - } + void processMixed2Prong2Prong(DerivedCollisions const& collisions, soa::Filtered const& p2tracks) + { + processMixedDerivedT(collisions, p2tracks); } PROCESS_SWITCH(CorrelationTask, processMixed2Prong2Prong, "Process mixed events on derived data", false); + void processMixed2Prong2ProngML(DerivedCollisions const& collisions, soa::Filtered> const& p2tracks) + { + processMixedDerivedT(collisions, p2tracks); + } + PROCESS_SWITCH(CorrelationTask, processMixed2Prong2ProngML, "Process mixed events on derived data with ML scores", false); + // Version with combinations /*void processWithCombinations(soa::Join::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered const& tracks) { @@ -870,12 +983,11 @@ struct CorrelationTask { case 2212: // proton case -2212: return 2; - case 421: // D0 - case -421: - return 3; - default: - return 4; } + if (std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), pdgCode) != cfgMcTriggerPDGs->end()) + return 4; // NOTE - if changed, the number in processMCEfficiency2Prong needs to be changed too since we skip the getSpecies call + else // The efficiency histogram is hardcoded to contain 5 species. Anything special will have the 4th slot. + return 3; } // NOTE SmallGroups includes soa::Filtered always @@ -897,7 +1009,7 @@ struct CorrelationTask { } // Primaries for (const auto& mcParticle : mcParticles) { - if (mcParticle.isPhysicalPrimary() && mcParticle.sign() != 0) { + if (mcParticle.isPhysicalPrimary() && mcParticle.sign() != 0 && !((doprocessMCEfficiency2Prong || doprocessMCEfficiency2ProngML) && std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), mcParticle.pdgCode()) != cfgMcTriggerPDGs->end())) { same->getTrackHistEfficiency()->Fill(CorrelationContainer::MC, mcParticle.eta(), mcParticle.pt(), getSpecies(mcParticle.pdgCode()), multiplicity, mcCollision.posZ()); } } @@ -911,6 +1023,8 @@ struct CorrelationTask { for (const auto& track : groupedTracks) { if (track.has_cfMCParticle()) { const auto& mcParticle = track.cfMCParticle(); + if ((doprocessMCEfficiency2Prong || doprocessMCEfficiency2ProngML) && std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), mcParticle.pdgCode()) != cfgMcTriggerPDGs->end()) + continue; // properly booked by the 2Prong efficiency function, ignore here if (mcParticle.isPhysicalPrimary()) { same->getTrackHistEfficiency()->Fill(CorrelationContainer::RecoPrimaries, mcParticle.eta(), mcParticle.pt(), getSpecies(mcParticle.pdgCode()), multiplicity, mcCollision.posZ()); } @@ -925,11 +1039,95 @@ struct CorrelationTask { } PROCESS_SWITCH(CorrelationTask, processMCEfficiency, "MC: Extract efficiencies", false); - // NOTE SmallGroups includes soa::Filtered always - void processMCSameDerived(soa::Filtered::iterator const& mcCollision, soa::Filtered const& mcParticles, soa::SmallGroups const& collisions) + template + void processMCEfficiency2ProngT(soa::Filtered::iterator const& mcCollision, soa::Join const& mcParticles, soa::SmallGroups const& collisions, aod::CFTracksWithLabel const&, p2type const& p2tracks, Preslice& perCollision2Prong) + { + auto multiplicity = mcCollision.multiplicity(); + if (cfgCentBinsForMC > 0) { + if (collisions.size() == 0) { + return; + } + for (const auto& collision : collisions) { + multiplicity = collision.multiplicity(); + } + } + // Primaries + p2indexCache.clear(); + for (const auto& mcParticle : mcParticles) { + if (std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), mcParticle.pdgCode()) != cfgMcTriggerPDGs->end()) { + if (((mcParticle.mcDecay() != aod::cf2prongtrack::D0ToPiK) && (mcParticle.mcDecay() != aod::cf2prongtrack::D0barToKPi)) || (mcParticle.decay() & aod::cf2prongmcpart::Prompt) == 0) + continue; // wrong decay channel + if (mcParticle.cfParticleDaugh0Id() < 0 && mcParticle.cfParticleDaugh1Id() < 0) + continue; // daughters not found + same->getTrackHistEfficiency()->Fill(CorrelationContainer::MC, mcParticle.eta(), mcParticle.pt(), 4, multiplicity, mcCollision.posZ()); + p2indexCache.push_back(mcParticle.globalIndex()); + } + } + for (const auto& collision : collisions) { + auto grouped2ProngTracks = p2tracks.sliceBy(perCollision2Prong, collision.globalIndex()); + + for (const auto& p2track : grouped2ProngTracks) { + if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast(p2track.decay()))) == 0u) + continue; + // Check if the mc particles of the prongs are found. + if constexpr (std::experimental::is_detected::value) { + if (!passMLScore(p2track)) + continue; + } + auto fillMC2p = [&](const aod::CFTracksWithLabel::iterator& p) -> bool { + if (!p.has_cfMCParticle()) + return false; + auto m = std::find_if(p2indexCache.begin(), p2indexCache.end(), [&](const auto& t) -> bool { + const auto& mcParticle = mcParticles.iteratorAt(t - mcParticles.begin().globalIndex()); + return (p.cfMCParticleId() == mcParticle.cfParticleDaugh0Id() || p.cfMCParticleId() == mcParticle.cfParticleDaugh1Id()); + }); + if (m == p2indexCache.end()) + return false; + const auto& mcParticle = mcParticles.iteratorAt(*m - mcParticles.begin().globalIndex()); + same->getTrackHistEfficiency()->Fill(CorrelationContainer::RecoPrimaries, mcParticle.eta(), mcParticle.pt(), 4, multiplicity, mcCollision.posZ()); + same->getTrackHistEfficiency()->Fill(CorrelationContainer::RecoAll, mcParticle.eta(), mcParticle.pt(), 4, multiplicity, mcCollision.posZ()); + return true; + }; + if (p2track.has_cfTrackProng0()) { + // + if (const auto& p0 = p2track.template cfTrackProng0_as(); fillMC2p(p0)) + continue; + } + if (p2track.has_cfTrackProng1()) { + if (const auto& p1 = p2track.template cfTrackProng1_as(); fillMC2p(p1)) + continue; + } + + // alternatively, book the reco pTs directly + // same->getTrackHistEfficiency()->Fill(CorrelationContainer::RecoPrimaries, p2track.eta(), p2track.pt(), 4, multiplicity, mcCollision.posZ()); + // same->getTrackHistEfficiency()->Fill(CorrelationContainer::RecoAll, p2track.eta(), p2track.pt(), 4, multiplicity, mcCollision.posZ()); + // continue; + + // fake track + same->getTrackHistEfficiency()->Fill(CorrelationContainer::Fake, p2track.eta(), p2track.pt(), 4, multiplicity, mcCollision.posZ()); + } + } + } + + Preslice perCollision2Prong = aod::cftrack::cfCollisionId; + void processMCEfficiency2Prong(soa::Filtered::iterator const& mcCollision, soa::Join const& mcParticles, soa::SmallGroups const& collisions, aod::CFTracksWithLabel const& tracks, aod::CF2ProngTracks const& p2tracks) + { + processMCEfficiency2ProngT(mcCollision, mcParticles, collisions, tracks, p2tracks, perCollision2Prong); + } + PROCESS_SWITCH(CorrelationTask, processMCEfficiency2Prong, "MC: Extract efficiencies for 2-prong particles", false); + + Preslice> perCollision2ProngML = aod::cftrack::cfCollisionId; + void processMCEfficiency2ProngML(soa::Filtered::iterator const& mcCollision, soa::Join const& mcParticles, soa::SmallGroups const& collisions, aod::CFTracksWithLabel const& tracks, soa::Join const& p2tracks) + { + processMCEfficiency2ProngT(mcCollision, mcParticles, collisions, tracks, p2tracks, perCollision2ProngML); + } + PROCESS_SWITCH(CorrelationTask, processMCEfficiency2ProngML, "MC: Extract efficiencies for 2-prong particles with ML scores", false); + + template + void processMCSameDerivedT(soa::Filtered::iterator const& mcCollision, Particles1 const& mcParticles1, Particles2 const& mcParticles2, soa::SmallGroups const& collisions) { if (cfgVerbosity > 0) { - LOGF(info, "processMCSameDerived. MC collision: %d, particles: %d, collisions: %d", mcCollision.globalIndex(), mcParticles.size(), collisions.size()); + LOGF(info, "processMCSameDerivedT. MC collision: %d, particles1: %d, particles2: %d, collisions: %d", mcCollision.globalIndex(), mcParticles1.size(), mcParticles2.size(), collisions.size()); } auto multiplicity = mcCollision.multiplicity(); @@ -940,36 +1138,55 @@ struct CorrelationTask { for (const auto& collision : collisions) { multiplicity = collision.multiplicity(); } - if (cfgVerbosity > 0) { - LOGF(info, " Data multiplicity: %f", multiplicity); - } } - fillQA(mcCollision, multiplicity, mcParticles); + if (!(doprocessSameDerived || doprocessSame2ProngDerived || doprocessSame2ProngDerivedML || doprocessSame2Prong2Prong || doprocessSame2Prong2ProngML)) { + if constexpr (std::experimental::is_detected::value) + fillQA(mcCollision, multiplicity, mcParticles1, mcParticles2); + else + fillQA(mcCollision, multiplicity, mcParticles1); + } same->fillEvent(multiplicity, CorrelationContainer::kCFStepAll); - fillCorrelations(same, mcParticles, mcParticles, multiplicity, mcCollision.posZ(), 0, 1.0f); + fillCorrelations(same, mcParticles1, mcParticles2, multiplicity, mcCollision.posZ(), 0, 1.0f); if (collisions.size() == 0) { return; } same->fillEvent(multiplicity, CorrelationContainer::kCFStepVertex); - fillCorrelations(same, mcParticles, mcParticles, multiplicity, mcCollision.posZ(), 0, 1.0f); + fillCorrelations(same, mcParticles1, mcParticles2, multiplicity, mcCollision.posZ(), 0, 1.0f); same->fillEvent(multiplicity, CorrelationContainer::kCFStepTrackedOnlyPrim); - fillCorrelations(same, mcParticles, mcParticles, multiplicity, mcCollision.posZ(), 0, 1.0f); + fillCorrelations(same, mcParticles1, mcParticles2, multiplicity, mcCollision.posZ(), 0, 1.0f); same->fillEvent(multiplicity, CorrelationContainer::kCFStepTracked); - fillCorrelations(same, mcParticles, mcParticles, multiplicity, mcCollision.posZ(), 0, 1.0f); + fillCorrelations(same, mcParticles1, mcParticles2, multiplicity, mcCollision.posZ(), 0, 1.0f); // NOTE kCFStepReconstructed and kCFStepCorrected are filled in processSameDerived // This also means that if a MC collision had several reconstructed vertices (collisions), all of them are filled } + + // NOTE SmallGroups includes soa::Filtered always + void processMCSameDerived(soa::Filtered::iterator const& mcCollision, soa::Filtered const& mcParticles, soa::SmallGroups const& collisions) // TODO. For mixed no need to check the daughters since the events are different + { + processMCSameDerivedT(mcCollision, mcParticles, mcParticles, collisions); + } PROCESS_SWITCH(CorrelationTask, processMCSameDerived, "Process MC same event on derived data", false); + void processMCSameDerived2Prong(soa::Filtered::iterator const& mcCollision, soa::Filtered> const& mcParticles2Prong, soa::Filtered const& mcParticles, soa::SmallGroups const& collisions) + { + // Subscribe to the MC particles table twice, once joined with the 2prongs and another time without. + // This is to avoid triggering any 2p-2p specific cases in the templated fillCorrelations(). + processMCSameDerivedT(mcCollision, mcParticles2Prong, mcParticles, collisions); + } + PROCESS_SWITCH(CorrelationTask, processMCSameDerived2Prong, "Process MC same event on derived data", false); + + // TODO: add MC 2Prong2Prong functions when needed + PresliceUnsorted collisionPerMCCollision = aod::cfcollision::cfMcCollisionId; - void processMCMixedDerived(soa::Filtered const& mcCollisions, soa::Filtered const& mcParticles, soa::Filtered const& collisions) + template + void processMCMixedDerivedT(soa::Filtered const& mcCollisions, soa::Filtered const& collisions, ParticleTypes&&... particles) { bool useMCMultiplicity = (cfgCentBinsForMC == 0); auto getMultiplicity = @@ -986,8 +1203,10 @@ struct CorrelationTask { BinningTypeMCDerived configurableBinning{{getMultiplicity}, {axisVertex, axisMultiplicity}, true}; // Strictly upper categorised collisions, for cfgNoMixedEvents combinations per bin, skipping those in entry -1 - auto tuple = std::make_tuple(mcParticles); - SameKindPair, soa::Filtered, BinningTypeMCDerived> pairs{configurableBinning, cfgNoMixedEvents, -1, mcCollisions, tuple, &cache}; // -1 is the number of the bin to skip + auto tuple = std::make_tuple(std::forward(particles)...); + using TA = std::tuple_element<0, decltype(tuple)>::type; + using TB = std::tuple_element - 1, decltype(tuple)>::type; + Pair, TA, TB, BinningTypeMCDerived> pairs{configurableBinning, cfgNoMixedEvents, -1, mcCollisions, tuple, &cache}; // -1 is the number of the bin to skip for (auto it = pairs.begin(); it != pairs.end(); it++) { auto& [collision1, tracks1, collision2, tracks2] = *it; @@ -1027,7 +1246,20 @@ struct CorrelationTask { // This also means that if a MC collision had several reconstructed vertices (collisions), all of them are filled } } + + void processMCMixedDerived(soa::Filtered const& mcCollisions, soa::Filtered const& mcParticles, soa::Filtered const& collisions) + { + processMCMixedDerivedT(mcCollisions, collisions, mcParticles); + } PROCESS_SWITCH(CorrelationTask, processMCMixedDerived, "Process MC mixed events on derived data", false); + + void processMCMixedDerived2Prong(soa::Filtered const& mcCollisions, soa::Filtered> const& mcParticles2Prong, soa::Filtered const& mcParticles, soa::Filtered const& collisions) + { + // Subscribe to the MC particles table twice, once joined with the 2prongs and another time without. + // This is to avoid triggering any 2p-2p specific cases in the templated fillCorrelations(). + processMCMixedDerivedT(mcCollisions, collisions, mcParticles2Prong, mcParticles); + } + PROCESS_SWITCH(CorrelationTask, processMCMixedDerived2Prong, "Process MC mixed events on derived data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/Tasks/dptdptcorrelations.cxx b/PWGCF/Tasks/dptDptCorrelations.cxx similarity index 90% rename from PWGCF/Tasks/dptdptcorrelations.cxx rename to PWGCF/Tasks/dptDptCorrelations.cxx index 2ac77b4a2d3..065e4be286f 100644 --- a/PWGCF/Tasks/dptdptcorrelations.cxx +++ b/PWGCF/Tasks/dptDptCorrelations.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file dptdptcorrelations.cxx +/// \file dptDptCorrelations.cxx /// \brief implements two-particle correlations base data collection /// \author victor.gonzalez.sebastian@gmail.com @@ -32,6 +32,7 @@ #include "Common/Core/TrackSelection.h" #include "Common/Core/TableHelper.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -44,7 +45,7 @@ #include "PWGCF/Core/AnalysisConfigurableCuts.h" #include "PWGCF/Core/PairCuts.h" #include "PWGCF/DataModel/DptDptFiltered.h" -#include "PWGCF/TableProducer/dptdptfilter.h" +#include "PWGCF/TableProducer/dptDptFilter.h" using namespace o2; using namespace o2::framework; @@ -67,12 +68,19 @@ float deltaphibinwidth = constants::math::TwoPI / deltaphibins; float deltaphilow = 0.0 - deltaphibinwidth / 2.0; float deltaphiup = constants::math::TwoPI - deltaphibinwidth / 2.0; -int nNoOfDimensions = 1; // number of dimensions for the NUA & NUE corrections -bool processpairs = false; // process pairs analysis -bool processmixedevents = false; // process mixed events -bool ptorder = false; // consider pt ordering -bool invmass = false; // produce the invariant mass histograms -bool corrana = false; // produce the correlation analysis histograms +enum HistoDimensions { + kNONE = 0, + k1D, + k2D, + k3D, + k4D +}; +HistoDimensions nNoOfDimensions = k1D; // number of dimensions for the NUA & NUE corrections +bool processpairs = false; // process pairs analysis +bool processmixedevents = false; // process mixed events +bool ptorder = false; // consider pt ordering +bool invmass = false; // produce the invariant mass histograms +bool corrana = false; // produce the correlation analysis histograms PairCuts fPairCuts; // pair suppression engine bool fUseConversionCuts = false; // suppress resonances and conversions @@ -85,7 +93,7 @@ std::vector> trackPairsNames; ///< the track pairs name } // namespace correlationstask // Task for building correlations -struct DptDptCorrelationsTask { +struct DptDptCorrelations { /* the data collecting engine */ template @@ -98,6 +106,7 @@ struct DptDptCorrelationsTask { /* histograms */ TH1F* fhVertexZA; //! fhN1VsPt{nch, nullptr}; //! fhN1VsPtEta{nch, nullptr}; //! fhN1VsEtaPhi{nch, nullptr}; //! fhSum1PtVsEtaPhi{nch, nullptr}; //! fhN1VsZEtaPhiPt{nch, nullptr}; //!GetDimension()) { - LOGF(fatal, " Corrections received dimensions %d for track id %d different than expected %d", corrs[i]->GetDimension(), i, nNoOfDimensions); + LOGF(fatal, " Corrections received dimensions %d for track id %d different than expected %d", corrs[i]->GetDimension(), i, static_cast(nNoOfDimensions)); } else { LOGF(info, " Storing NUA&NUE corrections %s for track id %d with %d dimensions %s", - corrs[i] != nullptr ? corrs[i]->GetName() : "nullptr", i, nNoOfDimensions, corrs[i] != nullptr ? "yes" : "no"); + corrs[i] != nullptr ? corrs[i]->GetName() : "nullptr", i, static_cast(nNoOfDimensions), corrs[i] != nullptr ? "yes" : "no"); } } fhNuaNue[i] = corrs[i]; @@ -314,15 +319,15 @@ struct DptDptCorrelationsTask { int nbins = 0; double avg = 0.0; for (int ix = 0; ix < fhNuaNue[i]->GetNbinsX(); ++ix) { - if (nNoOfDimensions == 1) { + if (nNoOfDimensions == k1D) { nbins++; avg += fhNuaNue[i]->GetBinContent(ix + 1); } else { for (int iy = 0; iy < fhNuaNue[i]->GetNbinsY(); ++iy) { - if (nNoOfDimensions == 2) { + if (nNoOfDimensions == k2D) { nbins++; avg += fhNuaNue[i]->GetBinContent(ix + 1, iy + 1); - } else if (nNoOfDimensions == 3 || nNoOfDimensions == 4) { + } else if (nNoOfDimensions == k3D || nNoOfDimensions == k4D) { for (int iz = 0; iz < fhNuaNue[i]->GetNbinsZ(); ++iz) { nbins++; avg += fhNuaNue[i]->GetBinContent(ix + 1, iy + 1, iz + 1); @@ -347,18 +352,20 @@ struct DptDptCorrelationsTask { ccdbstored = true; } - template + template std::vector* getTrackCorrections(TrackListObject const& tracks, float zvtx) { + using namespace correlationstask; + std::vector* corr = new std::vector(tracks.size(), 1.0f); int index = 0; for (const auto& t : tracks) { if (fhNuaNue[t.trackacceptedid()] != nullptr) { - if constexpr (nDim == 1) { + if constexpr (nDim == k1D) { (*corr)[index] = fhNuaNue[t.trackacceptedid()]->GetBinContent(fhNuaNue[t.trackacceptedid()]->FindFixBin(t.pt())); - } else if constexpr (nDim == 2) { + } else if constexpr (nDim == k2D) { (*corr)[index] = fhNuaNue[t.trackacceptedid()]->GetBinContent(fhNuaNue[t.trackacceptedid()]->FindFixBin(t.eta(), t.pt())); - } else if constexpr (nDim == 3) { + } else if constexpr (nDim == k3D) { (*corr)[index] = fhNuaNue[t.trackacceptedid()]->GetBinContent(fhNuaNue[t.trackacceptedid()]->FindFixBin(zvtx, getEtaPhiIndex(t) + 0.5, t.pt())); } } @@ -372,14 +379,14 @@ struct DptDptCorrelationsTask { { using namespace correlationstask; - if (nNoOfDimensions == 1) { - return getTrackCorrections<1>(tracks, zvtx); - } else if (nNoOfDimensions == 2) { - return getTrackCorrections<2>(tracks, zvtx); - } else if (nNoOfDimensions == 3) { - return getTrackCorrections<3>(tracks, zvtx); + if (nNoOfDimensions == k1D) { + return getTrackCorrections(tracks, zvtx); + } else if (nNoOfDimensions == k2D) { + return getTrackCorrections(tracks, zvtx); + } else if (nNoOfDimensions == k3D) { + return getTrackCorrections(tracks, zvtx); } - return getTrackCorrections<4>(tracks, zvtx); + return getTrackCorrections(tracks, zvtx); } template @@ -407,6 +414,7 @@ struct DptDptCorrelationsTask { float corr = (*corrs)[index]; fhN1VsPt[track.trackacceptedid()]->Fill(track.pt(), corr); if constexpr (smallsingles) { + fhN1VsPtEta[track.trackacceptedid()]->Fill(track.eta(), track.pt(), corr); fhN1VsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), getShiftedPhi(track.phi()), corr); fhSum1PtVsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), getShiftedPhi(track.phi()), track.pt() * corr); } else { @@ -439,6 +447,7 @@ struct DptDptCorrelationsTask { n1nw[track.trackacceptedid()] += 1; sum1Ptnw[track.trackacceptedid()] += track.pt(); + fhN1VsPtEta[track.trackacceptedid()]->Fill(track.eta(), track.pt(), corr); fhN1VsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), getShiftedPhi(track.phi()), corr); fhSum1PtVsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), getShiftedPhi(track.phi()), track.pt() * corr); index++; @@ -504,12 +513,7 @@ struct DptDptCorrelationsTask { } float deltaeta = track1.eta() - track2.eta(); float deltaphi = track1.phi() - track2.phi(); - while (deltaphi >= deltaphiup) { - deltaphi -= constants::math::TwoPI; - } - while (deltaphi < deltaphilow) { - deltaphi += constants::math::TwoPI; - } + deltaphi = RecoDecay::constrainAngle(deltaphi, deltaphilow); if ((fUseConversionCuts && fPairCuts.conversionCuts(track1, track2)) || (fUseTwoTrackCut && fPairCuts.twoTrackCut(track1, track2, bfield))) { /* suppress the pair */ if constexpr (docorrelations) { @@ -672,6 +676,9 @@ struct DptDptCorrelationsTask { /* we don't want the Sumw2 structure being created here */ bool defSumw2 = TH1::GetDefaultSumw2(); if constexpr (smallsingles) { + fhN1VsPtEta[i] = new TH2F(TString::Format("n1_%s_vsPtEta", tnames[i].c_str()).Data(), + TString::Format("#LT n_{1_{%s}} #GT;#eta;#it{p}_{T}", tnames[i].c_str()).Data(), + etabins, etalow, etaup, ptbins, ptlow, ptup); fhN1VsEtaPhi[i] = new TH2F(TString::Format("n1_%s_vsEtaPhi", tnames[i].c_str()).Data(), TString::Format("#LT n_{1} #GT;#eta_{%s};#varphi_{%s} (radian);#LT n_{1} #GT", tnames[i].c_str(), tnames[i].c_str()).Data(), etabins, etalow, etaup, phibins, philow, phiup); @@ -722,6 +729,8 @@ struct DptDptCorrelationsTask { /* the statistical uncertainties will be estimated by the subsamples method so let's get rid of the error tracking */ if constexpr (smallsingles) { + fhN1VsPtEta[i]->SetBit(TH1::kIsNotW); + fhN1VsPtEta[i]->Sumw2(false); fhN1VsEtaPhi[i]->SetBit(TH1::kIsNotW); fhN1VsEtaPhi[i]->Sumw2(false); fhSum1PtVsEtaPhi[i]->SetBit(TH1::kIsNotW); @@ -737,6 +746,7 @@ struct DptDptCorrelationsTask { fOutputList->Add(fhN1VsPt[i]); if constexpr (smallsingles) { + fOutputList->Add(fhN1VsPtEta[i]); fOutputList->Add(fhN1VsEtaPhi[i]); fOutputList->Add(fhSum1PtVsEtaPhi[i]); } else { @@ -747,6 +757,9 @@ struct DptDptCorrelationsTask { } else { for (uint i = 0; i < nch; ++i) { /* histograms for each track species */ + fhN1VsPtEta[i] = new TH2F(TString::Format("n1_%s_vsPtEta", tnames[i].c_str()).Data(), + TString::Format("#LT n_{1_{%s}} #GT;#eta;#it{p}_{T}", tnames[i].c_str()).Data(), + etabins, etalow, etaup, ptbins, ptlow, ptup); fhN1VsEtaPhi[i] = new TH2F(TString::Format("n1_%s_vsEtaPhi", tnames[i].c_str()).Data(), TString::Format("#LT n_{1} #GT;#eta_{%s};#varphi_{%s} (radian);#LT n_{1} #GT", tnames[i].c_str(), tnames[i].c_str()).Data(), etabins, etalow, etaup, phibins, philow, phiup); @@ -768,6 +781,7 @@ struct DptDptCorrelationsTask { TString::Format("#LT #Sigma p_{t,%s} #GT;Centrality/Multiplicity (%%);#LT #Sigma p_{t,%s} #GT (GeV/c)", tnames[i].c_str(), tnames[i].c_str()).Data(), 100, 0.0, 100.0); fhNuaNue[i] = nullptr; fhPtAvgVsEtaPhi[i] = nullptr; + fOutputList->Add(fhN1VsPtEta[i]); fOutputList->Add(fhN1VsEtaPhi[i]); fOutputList->Add(fhSum1PtVsEtaPhi[i]); fOutputList->Add(fhN1VsC[i]); @@ -895,17 +909,17 @@ struct DptDptCorrelationsTask { /* pair conversion suppression defaults */ static constexpr float kCfgPairCutDefaults[1][5] = {{-1, -1, -1, -1, -1}}; - Configurable> cfgPairCut{"paircut", {kCfgPairCutDefaults[0], 5, {"Photon", "K0", "Lambda", "Phi", "Rho"}}, "Conversion suppressions"}; + Configurable> cfgPairCut{"cfgPairCut", {kCfgPairCutDefaults[0], 5, {"Photon", "K0", "Lambda", "Phi", "Rho"}}, "Conversion suppressions"}; /* two tracks cut */ - Configurable cfgTwoTrackCut{"twotrackcut", -1, "Two-tracks cut: -1 = off; >0 otherwise distance value (suggested: 0.02"}; - Configurable cfgTwoTrackCutMinRadius{"twotrackcutminradius", 0.8f, "Two-tracks cut: radius in m from which two-tracks cut is applied"}; - - Configurable cfgSmallDCE{"smalldce", true, "Use small data collecting engine for singles processing, true = yes. Default = true"}; - Configurable cfgDoInvMass{"doinvmass", false, "Do the invariant mass analyis, true = yes. Default = false"}; - Configurable cfgDoCorrelations{"docorrelations", true, "Do the correlations analysis, true = yes. Default = true"}; - Configurable cfgProcessPairs{"processpairs", false, "Process pairs: false = no, just singles, true = yes, process pairs"}; - Configurable cfgProcessME{"processmixedevents", false, "Process mixed events: false = no, just same event, true = yes, also process mixed events"}; - Configurable cfgPtOrder{"ptorder", false, "enforce pT_1 < pT_2. Defalut: false"}; + Configurable cfgTwoTrackCut{"cfgTwoTrackCut", -1, "Two-tracks cut: -1 = off; >0 otherwise distance value (suggested: 0.02"}; + Configurable cfgTwoTrackCutMinRadius{"cfgTwoTrackCutMinRadius", 0.8f, "Two-tracks cut: radius in m from which two-tracks cut is applied"}; + + Configurable cfgSmallDCE{"cfgSmallDCE", true, "Use small data collecting engine for singles processing, true = yes. Default = true"}; + Configurable cfgDoInvMass{"cfgDoInvMass", false, "Do the invariant mass analyis, true = yes. Default = false"}; + Configurable cfgDoCorrelations{"cfgDoCorrelations", true, "Do the correlations analysis, true = yes. Default = true"}; + Configurable cfgProcessPairs{"cfgProcessPairs", false, "Process pairs: false = no, just singles, true = yes, process pairs"}; + Configurable cfgProcessME{"cfgProcessME", false, "Process mixed events: false = no, just same event, true = yes, also process mixed events"}; + Configurable cfgPtOrder{"cfgPtOrder", false, "enforce pT_1 < pT_2. Defalut: false"}; Configurable cfgNoOfDimensions{"cfgNoOfDimensions", 1, "Number of dimensions for the NUA&NUE corrections. Default 1"}; OutputObj fOutput{"DptDptCorrelationsData", OutputObjHandlingPolicy::AnalysisObject, OutputObjSourceType::OutputObjSource}; @@ -931,17 +945,17 @@ struct DptDptCorrelationsTask { } /* self configure the binning */ - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mZVtxbins", zvtxbins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mZVtxmin", zvtxlow, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mZVtxmax", zvtxup, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPTbins", ptbins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPTmin", ptlow, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPTmax", ptup, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mEtabins", etabins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mEtamin", etalow, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mEtamax", etaup, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPhibins", phibins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPhibinshift", phibinshift, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mZVtxbins", zvtxbins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mZVtxmin", zvtxlow, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mZVtxmax", zvtxup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPTbins", ptbins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPTmin", ptlow, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPTmax", ptup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mEtabins", etabins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mEtamin", etalow, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mEtamax", etaup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPhibins", phibins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPhibinshift", phibinshift, false); philow = 0.0f; phiup = constants::math::TwoPI; processpairs = cfgProcessPairs.value; @@ -949,20 +963,20 @@ struct DptDptCorrelationsTask { ptorder = cfgPtOrder.value; invmass = cfgDoInvMass.value; corrana = cfgDoCorrelations.value; - nNoOfDimensions = cfgNoOfDimensions.value; + nNoOfDimensions = static_cast(cfgNoOfDimensions.value); /* self configure the CCDB access to the input file */ - getTaskOptionValue(initContext, "dpt-dpt-filter", "input_ccdburl", cfgCCDBUrl, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "input_ccdbpath", cfgCCDBPathName, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "input_ccdbdate", cfgCCDBDate, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "input_ccdbperiod", cfgCCDBPeriod, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDBUrl", cfgCCDBUrl, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDBPathName", cfgCCDBPathName, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDBDate", cfgCCDBDate, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCCDBPeriod", cfgCCDBPeriod, false); loadfromccdb = cfgCCDBPathName.length() > 0; /* update the potential binning change */ etabinwidth = (etaup - etalow) / static_cast(etabins); phibinwidth = (phiup - philow) / static_cast(phibins); - /* the differential bining */ + /* the differential binning */ deltaetabins = etabins * 2 - 1; deltaetalow = etalow - etaup, deltaetaup = etaup - etalow; deltaetabinwidth = (deltaetaup - deltaetalow) / static_cast(deltaetabins); @@ -996,7 +1010,7 @@ struct DptDptCorrelationsTask { { /* self configure the desired species */ o2::analysis::dptdptfilter::PIDSpeciesSelection pidselector; - std::vector cfgnames = {"elpidsel", "mupidsel", "pipidsel", "kapidsel", "prpidsel"}; + std::vector cfgnames = {"cfgElectronPIDSelection", "cfgMuonPIDSelection", "cfgPionPIDSelection", "cfgKaonPIDSelection", "cfgProtonPIDSelection"}; std::vector spids = {0, 1, 2, 3, 4}; for (uint i = 0; i < cfgnames.size(); ++i) { auto includeIt = [&pidselector, &initContext](int spid, auto name) { @@ -1041,7 +1055,7 @@ struct DptDptCorrelationsTask { /* self configure the centrality/multiplicity ranges */ std::string centspec; - if (getTaskOptionValue(initContext, "dpt-dpt-filter", "centralities", centspec, false)) { + if (getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCentSpec", centspec, false)) { LOGF(info, "Got the centralities specification: %s", centspec.c_str()); auto tokens = TString(centspec.c_str()).Tokenize(","); ncmranges = tokens->GetEntries(); @@ -1380,7 +1394,7 @@ struct DptDptCorrelationsTask { { processSame(collision, tracks, collision.bc_as().timestamp()); } - PROCESS_SWITCH(DptDptCorrelationsTask, processRecLevel, "Process reco level correlations", false); + PROCESS_SWITCH(DptDptCorrelations, processRecLevel, "Process reco level correlations", false); void processRecLevelCheck(aod::Collisions const& collisions, aod::Tracks const& tracks) { @@ -1407,7 +1421,7 @@ struct DptDptCorrelationsTask { LOGF(info, " First not assigned track index %d", firstNotAssignedIndex); LOGF(info, " Last not assigned track index %d", lastNotAssignedIndex); } - PROCESS_SWITCH(DptDptCorrelationsTask, processRecLevelCheck, "Process reco level checks", true); + PROCESS_SWITCH(DptDptCorrelations, processRecLevelCheck, "Process reco level checks", true); void processGenLevelCheck(aod::McCollisions const& mccollisions, aod::McParticles const& particles) { @@ -1434,7 +1448,7 @@ struct DptDptCorrelationsTask { LOGF(info, " First not assigned track index %d", firstNotAssignedIndex); LOGF(info, " Last not assigned track index %d", lastNotAssignedIndex); } - PROCESS_SWITCH(DptDptCorrelationsTask, processGenLevelCheck, "Process generator level checks", true); + PROCESS_SWITCH(DptDptCorrelations, processGenLevelCheck, "Process generator level checks", true); void processRecLevelNotStored( soa::Filtered>::iterator const& collision, @@ -1443,7 +1457,7 @@ struct DptDptCorrelationsTask { { processSame(collision, tracks, collision.bc_as().timestamp()); } - PROCESS_SWITCH(DptDptCorrelationsTask, processRecLevelNotStored, "Process reco level correlations for not stored derived data", true); + PROCESS_SWITCH(DptDptCorrelations, processRecLevelNotStored, "Process reco level correlations for not stored derived data", true); void processGenLevel( soa::Filtered::iterator const& collision, @@ -1451,7 +1465,7 @@ struct DptDptCorrelationsTask { { processSame(collision, tracks); } - PROCESS_SWITCH(DptDptCorrelationsTask, processGenLevel, "Process generator level correlations", false); + PROCESS_SWITCH(DptDptCorrelations, processGenLevel, "Process generator level correlations", false); void processGenLevelNotStored( soa::Filtered>::iterator const& collision, @@ -1459,7 +1473,7 @@ struct DptDptCorrelationsTask { { processSame(collision, particles); } - PROCESS_SWITCH(DptDptCorrelationsTask, processGenLevelNotStored, "Process generator level correlations for not stored derived data", false); + PROCESS_SWITCH(DptDptCorrelations, processGenLevelNotStored, "Process generator level correlations for not stored derived data", false); std::vector vtxBinsEdges{VARIABLE_WIDTH, -7.0f, -5.0f, -3.0f, -1.0f, 1.0f, 3.0f, 5.0f, 7.0f}; @@ -1467,6 +1481,7 @@ struct DptDptCorrelationsTask { SliceCache cache; using BinningZVtxMultRec = ColumnBinningPolicy; BinningZVtxMultRec bindingOnVtxAndMultRec{{vtxBinsEdges, multBinsEdges}, true}; // true is for 'ignore overflows' (true by default) + static constexpr int kNoOfLoggingCombinations = 10; void processRecLevelMixed(soa::Filtered const& collisions, aod::BCsWithTimestamps const&, soa::Filtered const& tracks) { @@ -1476,7 +1491,7 @@ struct DptDptCorrelationsTask { LOGF(DPTDPTLOGCOLLISIONS, "Received %d collisions", collisions.size()); int logcomb = 0; for (auto const& [collision1, tracks1, collision2, tracks2] : pairreco) { - if (logcomb < 10) { + if (logcomb < kNoOfLoggingCombinations) { LOGF(DPTDPTLOGCOLLISIONS, "Received collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s", collision1.globalIndex(), collision1.posZ(), collision1.centmult(), collision1.collisionaccepted() ? "accepted" : "not accepted", collision2.globalIndex(), collision2.posZ(), collision2.centmult(), collision2.collisionaccepted() ? "accepted" : "not accepted"); @@ -1490,7 +1505,7 @@ struct DptDptCorrelationsTask { processMixed(collision1, tracks1, tracks2, collision1.bc_as().timestamp()); } } - PROCESS_SWITCH(DptDptCorrelationsTask, processRecLevelMixed, "Process reco level mixed events correlations", false); + PROCESS_SWITCH(DptDptCorrelations, processRecLevelMixed, "Process reco level mixed events correlations", false); void processRecLevelMixedNotStored( soa::Filtered> const& collisions, @@ -1511,7 +1526,7 @@ struct DptDptCorrelationsTask { LOGF(DPTDPTLOGCOLLISIONS, "Received %d collisions", collisions.size()); int logcomb = 0; for (auto const& [collision1, tracks1, collision2, tracks2] : pairreco) { - if (logcomb < 10) { + if (logcomb < kNoOfLoggingCombinations) { LOGF(DPTDPTLOGCOLLISIONS, "Received collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s", collision1.globalIndex(), @@ -1542,7 +1557,7 @@ struct DptDptCorrelationsTask { collision1.bc_as().timestamp()); } } - PROCESS_SWITCH(DptDptCorrelationsTask, processRecLevelMixedNotStored, "Process reco level mixed events correlations for not stored derived data", false); + PROCESS_SWITCH(DptDptCorrelations, processRecLevelMixedNotStored, "Process reco level mixed events correlations for not stored derived data", false); using BinningZVtxMultGen = ColumnBinningPolicy; BinningZVtxMultGen bindingOnVtxAndMultGen{{vtxBinsEdges, multBinsEdges}, true}; // true is for 'ignore overflows' (true by default) @@ -1555,7 +1570,7 @@ struct DptDptCorrelationsTask { LOGF(DPTDPTLOGCOLLISIONS, "Received %d generated collisions", collisions.size()); int logcomb = 0; for (auto const& [collision1, tracks1, collision2, tracks2] : pairgen) { - if (logcomb < 10) { + if (logcomb < kNoOfLoggingCombinations) { LOGF(DPTDPTLOGCOLLISIONS, "Received generated collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s", collision1.globalIndex(), collision1.posZ(), collision1.centmult(), collision1.collisionaccepted() ? "accepted" : "not accepted", collision2.globalIndex(), collision2.posZ(), collision2.centmult(), collision2.collisionaccepted() ? "accepted" : "not accepted"); @@ -1568,7 +1583,7 @@ struct DptDptCorrelationsTask { processMixed(collision1, tracks1, tracks2); } } - PROCESS_SWITCH(DptDptCorrelationsTask, processGenLevelMixed, "Process generator level mixed events correlations", false); + PROCESS_SWITCH(DptDptCorrelations, processGenLevelMixed, "Process generator level mixed events correlations", false); void processGenLevelMixedNotStored(soa::Filtered> const& collisions, soa::Filtered> const& tracks) { @@ -1586,7 +1601,7 @@ struct DptDptCorrelationsTask { LOGF(DPTDPTLOGCOLLISIONS, "Received %d generated collisions", collisions.size()); int logcomb = 0; for (auto const& [collision1, tracks1, collision2, tracks2] : pairgen) { - if (logcomb < 10) { + if (logcomb < kNoOfLoggingCombinations) { LOGF(DPTDPTLOGCOLLISIONS, "Received generated collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s", collision1.globalIndex(), @@ -1613,7 +1628,7 @@ struct DptDptCorrelationsTask { processMixed(collision1, tracks1, tracks2); } } - PROCESS_SWITCH(DptDptCorrelationsTask, processGenLevelMixedNotStored, "Process generator level mixed events correlations for not stored derived data", false); + PROCESS_SWITCH(DptDptCorrelations, processGenLevelMixedNotStored, "Process generator level mixed events correlations for not stored derived data", false); /// cleans the output object when the task is not used void processCleaner(soa::Filtered const& colls) @@ -1621,13 +1636,13 @@ struct DptDptCorrelationsTask { LOGF(DPTDPTLOGCOLLISIONS, "Got %d new collisions", colls.size()); fOutput->Clear(); } - PROCESS_SWITCH(DptDptCorrelationsTask, processCleaner, "Cleaner process for not used output", false); + PROCESS_SWITCH(DptDptCorrelations, processCleaner, "Cleaner process for not used output", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{ - adaptAnalysisTask(cfgc, TaskName{"DptDptCorrelationsTaskRec"}, SetDefaultProcesses{{{"processRecLevel", true}, {"processRecLevelMixed", false}, {"processCleaner", false}}}), // o2-linter: disable=name/o2-task - adaptAnalysisTask(cfgc, TaskName{"DptDptCorrelationsTaskGen"}, SetDefaultProcesses{{{"processGenLevel", false}, {"processGenLevelMixed", false}, {"processCleaner", true}}})}; // o2-linter: disable=name/o2-task + adaptAnalysisTask(cfgc, TaskName{"DptDptCorrelationsRec"}, SetDefaultProcesses{{{"processRecLevel", true}, {"processRecLevelMixed", false}, {"processCleaner", false}}}), // o2-linter: disable=name/o2-task (It is adapted multiple times) + adaptAnalysisTask(cfgc, TaskName{"DptDptCorrelationsGen"}, SetDefaultProcesses{{{"processGenLevel", false}, {"processGenLevelMixed", false}, {"processCleaner", true}}})}; // o2-linter: disable=name/o2-task (It is adapted multiple times) return workflow; } diff --git a/PWGCF/Tasks/dptDptFilterQa.cxx b/PWGCF/Tasks/dptDptFilterQa.cxx index ebb50785a61..85dee751438 100644 --- a/PWGCF/Tasks/dptDptFilterQa.cxx +++ b/PWGCF/Tasks/dptDptFilterQa.cxx @@ -21,7 +21,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "PWGCF/DataModel/DptDptFiltered.h" -#include "PWGCF/TableProducer/dptdptfilter.h" +#include "PWGCF/TableProducer/dptDptFilter.h" using namespace o2; using namespace o2::framework; @@ -91,6 +91,7 @@ struct DptDptFilterQa { FilteredTracks const& tracks) { using namespace o2::analysis::dptdptfilterqa; + static constexpr int kNoOfIclusiveParticles = 2; /* number of inclusive charged particles, aka positive and negative */ if (collision.collisionaccepted() != uint8_t(true)) { histos.fill(HIST(Dirname[dir]) + HIST("SelectedEvents"), 0.5); @@ -103,7 +104,7 @@ struct DptDptFilterQa { int nTracksOneAndTwo = 0; int nTracksNone = 0; for (auto const& track : tracks) { - if (!(track.trackacceptedid() < 0) && !(track.trackacceptedid() < 2)) { + if (!(track.trackacceptedid() < 0) && !(track.trackacceptedid() < kNoOfIclusiveParticles)) { LOGF(fatal, "Task not prepared for identified particles"); } if (track.trackacceptedid() != 0 && track.trackacceptedid() != 1) { diff --git a/PWGCF/Tasks/matchRecoGen.cxx b/PWGCF/Tasks/matchRecoGen.cxx index 486eae85e37..57ab00301b7 100644 --- a/PWGCF/Tasks/matchRecoGen.cxx +++ b/PWGCF/Tasks/matchRecoGen.cxx @@ -31,7 +31,7 @@ #include "Framework/runDataProcessing.h" #include "PWGCF/Core/AnalysisConfigurableCuts.h" #include "PWGCF/DataModel/DptDptFiltered.h" -#include "PWGCF/TableProducer/dptdptfilter.h" +#include "PWGCF/TableProducer/dptDptFilter.h" #include #include #include @@ -69,7 +69,8 @@ struct MatchRecoGen { typedef enum { kBEFORE = 0, kAFTER } beforeafterselection; typedef enum { kPOSITIVE = 0, - kNEGATIVE } colllabelsign; + kNEGATIVE, + kNOOFCOLLSIGNS } colllabelsign; enum { kMATCH = 0, kDONTMATCH }; @@ -292,7 +293,7 @@ struct MatchRecoGen { using namespace o2::analysis::recogenmap; using namespace o2::analysis::dptdptfilter; - for (int i = 0; i < 2; ++i) { + for (int i = 0; i < kNOOFCOLLSIGNS; ++i) { mclabelpos[i].clear(); mclabelneg[i].clear(); mclabelpos[i].resize(mcParticles.size()); @@ -346,7 +347,7 @@ struct MatchRecoGen { using namespace o2::analysis::recogenmap; using namespace o2::analysis::dptdptfilter; - for (int i = 0; i < 2; ++i) { + for (int i = 0; i < kNOOFCOLLSIGNS; ++i) { mclabelpos[i].clear(); mclabelneg[i].clear(); mclabelpos[i].resize(mcParticles.size()); diff --git a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx index fee15c95f97..535dd77cce2 100644 --- a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx +++ b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx @@ -8,6 +8,11 @@ // 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. + +/// \file identifiedBfFilter.cxx +/// \brief Filters collisions and tracks according to selection criteria +/// \author bghanley1995@gmail.com + #include "PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h" #include @@ -28,9 +33,10 @@ #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/CollisionAssociationTables.h" #include "Framework/runDataProcessing.h" +#include "Framework/O2DatabasePDGPlugin.h" #include -#include #include +#include #include #include #include @@ -53,16 +59,17 @@ namespace o2::analysis::identifiedbffilter using IdBfFullTracks = soa::Join; using IdBfFullTracksAmbiguous = soa::Join; using IdBfTracksPID = soa::Join; +using IdBfTracksTOF = soa::Join; using IdBfTracksFullPID = soa::Join; -using IdBfFullTracksPID = soa::Join; +using IdBfFullTracksPID = soa::Join; using IdBfFullTracksFullPID = soa::Join; -using IdBfFullTracksPIDAmbiguous = soa::Join; +using IdBfFullTracksPIDAmbiguous = soa::Join; using IdBfFullTracksFullPIDAmbiguous = soa::Join; using IdBfFullTracksDetLevel = soa::Join; using IdBfFullTracksDetLevelAmbiguous = soa::Join; -using IdBfFullTracksPIDDetLevel = soa::Join; +using IdBfFullTracksPIDDetLevel = soa::Join; using IdBfFullTracksFullPIDDetLevel = soa::Join; -using IdBfFullTracksPIDDetLevelAmbiguous = soa::Join; +using IdBfFullTracksPIDDetLevelAmbiguous = soa::Join; using IdBfFullTracksFullPIDDetLevelAmbiguous = soa::Join; bool fullDerivedData = false; /* produce full derived data for its external storage */ @@ -70,6 +77,10 @@ bool fullDerivedData = false; /* produce full derived data for its external stor TList* ccdblst = nullptr; bool loadfromccdb = false; +std::vector recoIdMethods = {0, 1, 2}; // Reconstructed PID Methods, 0 is no PID, 1 is calculated PID, 2 is MC PID +std::vector trackTypes = {0, 1, 2, 3}; +const int twoDenom = 2; // Used to test if a value is even or odd + //============================================================================================ // The IdentifiedBfFilter histogram objects // TODO: consider registering in the histogram registry @@ -80,21 +91,40 @@ TH1F* fhVertexZB = nullptr; TH1F* fhVertexZA = nullptr; TH1F* fhMultB = nullptr; TH1F* fhMultA = nullptr; +TH2F* fhYZB = nullptr; +TH2F* fhXYB = nullptr; +TH2F* fhYZA = nullptr; +TH2F* fhXYA = nullptr; TH1F* fhPB = nullptr; -TH1F* fhPA[kIdBfNoOfSpecies] = {nullptr}; +TH1F* fhPA[kIdBfNoOfSpecies + 1] = {nullptr}; TH1F* fhPtB = nullptr; -TH1F* fhPtA[kIdBfNoOfSpecies] = {nullptr}; +TH1F* fhPtA[kIdBfNoOfSpecies + 1] = {nullptr}; TH1F* fhPtPosB = nullptr; -TH1F* fhPtPosA[kIdBfNoOfSpecies] = {nullptr}; +TH1F* fhPtPosA[kIdBfNoOfSpecies + 1] = {nullptr}; TH1F* fhPtNegB = nullptr; -TH1F* fhPtNegA[kIdBfNoOfSpecies] = {nullptr}; -TH2F* fhNPosNegA[kIdBfNoOfSpecies] = {nullptr}; -TH1F* fhDeltaNA[kIdBfNoOfSpecies] = {nullptr}; +TH1F* fhPtNegA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhNPosNegA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhDeltaNA[kIdBfNoOfSpecies + 1] = {nullptr}; + +TH2F* fhPtEtaPosA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPtEtaNegA[kIdBfNoOfSpecies + 1] = {nullptr}; + +TH1I* fhNClustersB = nullptr; +TH2F* fhPhiYB = nullptr; +TH2F* fhPtYB = nullptr; +TH1F* fhChi2B = nullptr; +TH1I* fhITSNclB = nullptr; + +TH1I* fhNClustersA = nullptr; +TH2F* fhPhiYA = nullptr; +TH2F* fhPtYA = nullptr; +TH1F* fhChi2A = nullptr; +TH1I* fhITSNclA = nullptr; TH2F* fhNSigmaTPC[kIdBfNoOfSpecies] = {nullptr}; TH2F* fhNSigmaTOF[kIdBfNoOfSpecies] = {nullptr}; TH2F* fhNSigmaCombo[kIdBfNoOfSpecies] = {nullptr}; -TH2F* fhNSigmaTPC_IdTrks[kIdBfNoOfSpecies] = {nullptr}; +TH2F* fhNSigmaTPCIdTrks[kIdBfNoOfSpecies] = {nullptr}; TH1F* fhNSigmaCorrection[kIdBfNoOfSpecies] = {nullptr}; @@ -104,10 +134,22 @@ TH1F* fhEtaA = nullptr; TH1F* fhPhiB = nullptr; TH1F* fhPhiA = nullptr; +TH1F* fhTrackLengthB = nullptr; +TH1F* fhTrackLengthTOFB = nullptr; +TH2F* fhTrackTimeB = nullptr; +TH2F* fhTrackBetaInvB = nullptr; +TH2F* fhTrackTimeIPB = nullptr; +TH2F* fhTrackBetaInvIPB = nullptr; TH2F* fhdEdxB = nullptr; TH2F* fhdEdxIPTPCB = nullptr; -TH2F* fhdEdxA[kIdBfNoOfSpecies + 1] = {nullptr}; -TH2F* fhdEdxIPTPCA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhTrackLengthA[kIdBfNoOfSpecies + 2] = {nullptr}; +TH1F* fhTrackLengthTOFA[kIdBfNoOfSpecies + 2] = {nullptr}; +TH2F* fhdEdxA[kIdBfNoOfSpecies + 2] = {nullptr}; +TH2F* fhdEdxIPTPCA[kIdBfNoOfSpecies + 2] = {nullptr}; +TH2F* fhTrackTimeA[kIdBfNoOfSpecies + 2] = {nullptr}; +TH2F* fhTrackBetaInvA[kIdBfNoOfSpecies + 2] = {nullptr}; +TH2F* fhTrackTimeIPA[kIdBfNoOfSpecies + 2] = {nullptr}; +TH2F* fhTrackBetaInvIPA[kIdBfNoOfSpecies + 2] = {nullptr}; TH1F* fhMassB = nullptr; TH1F* fhMassA[kIdBfNoOfSpecies + 1] = {nullptr}; @@ -118,8 +160,10 @@ TH1F* fhDCAxyB = nullptr; TH1F* fhDCAxyA = nullptr; TH1F* fhFineDCAxyA = nullptr; TH1F* fhDCAzB = nullptr; +TH2F* fhDCAxyzB = nullptr; TH1F* fhDCAzA = nullptr; TH1F* fhFineDCAzA = nullptr; +TH2F* fhDCAxyzA = nullptr; TH1F* fhWrongTrackID = nullptr; @@ -128,21 +172,71 @@ TH2F* fhAmbiguousTrackPt = nullptr; TH2F* fhAmbiguityDegree = nullptr; TH2F* fhCompatibleCollisionsZVtxRms = nullptr; +TH2S* fhTruePIDMismatch = nullptr; +TH1S* fhTruePIDCorrect = nullptr; + +std::vector> fhTrueNSigmaTPC = {o2::analysis::identifiedbffilter::kIdBfNoOfSpecies, {o2::analysis::identifiedbffilter::kIdBfNoOfSpecies, nullptr}}; +std::vector> fhTrueNSigmaTOF = {o2::analysis::identifiedbffilter::kIdBfNoOfSpecies, {o2::analysis::identifiedbffilter::kIdBfNoOfSpecies, nullptr}}; + +std::vector> fhPrimaryNSigmaTPC = {o2::analysis::identifiedbffilter::kIdBfNoOfSpecies, {o2::analysis::identifiedbffilter::kIdBfNoOfSpecies, nullptr}}; +std::vector> fhPrimaryNSigmaTOF = {o2::analysis::identifiedbffilter::kIdBfNoOfSpecies, {o2::analysis::identifiedbffilter::kIdBfNoOfSpecies, nullptr}}; + TH1F* fhTrueCentMultB = nullptr; TH1F* fhTrueCentMultA = nullptr; TH1F* fhTrueVertexZB = nullptr; TH1F* fhTrueVertexZA = nullptr; TH1F* fhTrueVertexZAA = nullptr; TH1F* fhTruePB = nullptr; -TH1F* fhTruePA[kIdBfNoOfSpecies] = {nullptr}; +TH1F* fhTrueCharge = nullptr; +TH1F* fhTruePA[kIdBfNoOfSpecies + 1] = {nullptr}; TH1F* fhTruePtB = nullptr; -TH1F* fhTruePtA[kIdBfNoOfSpecies] = {nullptr}; +TH1F* fhTruePtA[kIdBfNoOfSpecies + 1] = {nullptr}; TH1F* fhTruePtPosB = nullptr; -TH1F* fhTruePtPosA[kIdBfNoOfSpecies] = {nullptr}; +TH1F* fhTruePtPosA[kIdBfNoOfSpecies + 1] = {nullptr}; TH1F* fhTruePtNegB = nullptr; -TH1F* fhTruePtNegA[kIdBfNoOfSpecies] = {nullptr}; -TH2F* fhTrueNPosNegA[kIdBfNoOfSpecies] = {nullptr}; -TH1F* fhTrueDeltaNA[kIdBfNoOfSpecies] = {nullptr}; +TH1F* fhTruePtNegA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhTrueNPosNegA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhTrueDeltaNA[kIdBfNoOfSpecies + 1] = {nullptr}; + +TH2F* fhTruedEdxA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhTruedEdxIPTPCA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhTrueTrackLengthA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhTrueTrackLengthTOFA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhTrueTrackTimeA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhTrueTrackBetaInvA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhTrueTrackTimeIPA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhTrueTrackBetaInvIPA[kIdBfNoOfSpecies + 1] = {nullptr}; + +TH1F* fhPrimaryPA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhPrimaryPtA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPrimarydEdxA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPrimarydEdxIPTPCA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhPrimaryTrackLengthA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhPrimaryTrackLengthTOFA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPrimaryTrackTimeA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPrimaryTrackBetaInvA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPrimaryTrackTimeIPA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPrimaryTrackBetaInvIPA[kIdBfNoOfSpecies + 1] = {nullptr}; + +TH1F* fhPurePA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhPurePtA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPuredEdxA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPuredEdxIPTPCA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhPureTrackLengthA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH1F* fhPureTrackLengthTOFA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPureTrackTimeA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPureTrackBetaInvA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPureTrackTimeIPA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhPureTrackBetaInvIPA[kIdBfNoOfSpecies + 1] = {nullptr}; + +TH2F* fhTruePtEtaPosA[kIdBfNoOfSpecies + 1] = {nullptr}; +TH2F* fhTruePtEtaNegA[kIdBfNoOfSpecies + 1] = {nullptr}; + +TH2F* fhTruePhiYB = nullptr; +TH2F* fhTruePtYB = nullptr; + +TH2F* fhTruePhiYA = nullptr; +TH2F* fhTruePtYA = nullptr; TH1F* fhTrueEtaB = nullptr; TH1F* fhTrueEtaA = nullptr; @@ -155,6 +249,19 @@ TH1F* fhTrueDCAxyA = nullptr; TH1F* fhTrueDCAzB = nullptr; TH1F* fhTrueDCAxyBid = nullptr; TH1F* fhTrueDCAzA = nullptr; +TH2F* fhTrueDCAxyzB = nullptr; +TH2F* fhTrueDCAxyzA = nullptr; + +TH1F* fhPrimaryPB = nullptr; +TH1F* fhPrimaryPtB = nullptr; +TH2F* fhPrimarydEdxB = nullptr; +TH2F* fhPrimarydEdxIPTPCB = nullptr; +TH1F* fhPrimaryTrackLengthB = nullptr; +TH1F* fhPrimaryTrackLengthTOFB = nullptr; +TH2F* fhPrimaryTrackTimeB = nullptr; +TH2F* fhPrimaryTrackBetaInvB = nullptr; +TH2F* fhPrimaryTrackTimeIPB = nullptr; +TH2F* fhPrimaryTrackBetaInvIPB = nullptr; //============================================================================================ // The IdentifiedBfFilter multiplicity counters @@ -168,15 +275,15 @@ int partMultNeg[kIdBfNoOfSpecies + 1]; // multiplicity of negative particles using namespace identifiedbffilter; struct IdentifiedBfFilter { - Configurable cfgFullDerivedData{"fullderiveddata", false, "Produce the full derived data for external storage. Default false"}; - Configurable cfgCentMultEstimator{"centmultestimator", "V0M", "Centrality/multiplicity estimator detector: V0M,CL0,CL1,FV0A,FT0M,FT0A,FT0C,NTPV,NOCM: none. Default V0M"}; - Configurable cfgSystem{"syst", "PbPb", "System: pp, PbPb, Pbp, pPb, XeXe, ppRun3, PbPbRun3. Default PbPb"}; - Configurable cfgDataType{"datatype", "data", "Data type: data, datanoevsel, MC, FastMC, OnTheFlyMC. Default data"}; - Configurable cfgTriggSel{"triggsel", "MB", "Trigger selection: MB, None. Default MB"}; - Configurable cfgBinning{"binning", + Configurable cfgFullDerivedData{"cfgFullDerivedData", false, "Produce the full derived data for external storage. Default false"}; + Configurable cfgCentMultEstimator{"cfgCentMultEstimator", "V0M", "Centrality/multiplicity estimator detector: V0M,CL0,CL1,FV0A,FT0M,FT0A,FT0C,NTPV,NOCM: none. Default V0M"}; + Configurable cfgSystem{"cfgSystem", "PbPb", "System: pp, PbPb, Pbp, pPb, XeXe, ppRun3, PbPbRun3. Default PbPb"}; + Configurable cfgDataType{"cfgDataType", "data", "Data type: data, datanoevsel, MC, FastMC, OnTheFlyMC. Default data"}; + Configurable cfgTriggSel{"cfgTriggSel", "MB", "Trigger selection: MB, None. Default MB"}; + Configurable cfgBinning{"cfgBinning", {28, -7.0, 7.0, 18, 0.2, 2.0, 16, -0.8, 0.8, 72, 0.5}, "triplets - nbins, min, max - for z_vtx, pT, eta and phi, binning plus bin fraction of phi origin shift"}; - Configurable cfgTraceCollId0{"tracecollid0", false, "Trace particles in collisions id 0. Default false"}; + Configurable cfgTraceCollId0{"cfgTraceCollId0", false, "Trace particles in collisions id 0. Default false"}; OutputObj fOutput{"IdentifiedBfFilterCollisionsInfo", OutputObjHandlingPolicy::AnalysisObject}; @@ -377,7 +484,7 @@ void IdentifiedBfFilter::processReconstructed(CollisionObject const& collision, fhVertexZB->Fill(collision.posZ()); uint8_t acceptedevent = uint8_t(false); float centormult = tentativecentmult; - if (IsEvtSelected(collision, centormult)) { + if (isEvtSelected(collision, centormult)) { acceptedevent = true; fhCentMultA->Fill(centormult); fhMultA->Fill(mult); @@ -491,7 +598,7 @@ void IdentifiedBfFilter::processGenerated(CollisionObject const& mccollision, Pa using namespace identifiedbffilter; uint8_t acceptedevent = uint8_t(false); - if (IsEvtSelected(mccollision, centormult)) { + if (isEvtSelected(mccollision, centormult)) { acceptedevent = uint8_t(true); } if (fullDerivedData) { @@ -517,12 +624,12 @@ void IdentifiedBfFilter::processGeneratorLevel(aod::McCollision const& mccollisi } bool processed = false; - for (auto& tmpcollision : collisions) { + for (const auto& tmpcollision : collisions) { if (tmpcollision.has_mcCollision()) { if (tmpcollision.mcCollisionId() == mccollision.globalIndex()) { typename AllCollisions::iterator const& collision = allcollisions.iteratorAt(tmpcollision.globalIndex()); - if (IsEvtSelected(collision, defaultcent)) { - fhTrueVertexZAA->Fill((mccollision.posZ())); + if (isEvtSelected(collision, defaultcent)) { + fhTrueVertexZAA->Fill(mccollision.posZ()); processGenerated(mccollision, mcparticles, defaultcent); processed = true; break; /* TODO: only processing the first reconstructed accepted collision */ @@ -565,7 +672,7 @@ void IdentifiedBfFilter::processVertexGenerated(aod::McCollisions const& mccolli fhTrueVertexZB->Fill(mccollision.posZ()); /* we assign a default value */ float centmult = 50.0f; - if (IsEvtSelected(mccollision, centmult)) { + if (isEvtSelected(mccollision, centmult)) { fhTrueVertexZA->Fill((mccollision.posZ())); } } @@ -581,8 +688,8 @@ T computeRMS(std::vector& vec) std::vector diff(vec.size()); std::transform(vec.begin(), vec.end(), diff.begin(), [mean](T x) { return x - mean; }); - T sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0); - T stdev = std::sqrt(sq_sum / vec.size()); + T sqSum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0); + T stdev = std::sqrt(sqSum / vec.size()); return stdev; } @@ -590,9 +697,9 @@ T computeRMS(std::vector& vec) struct IdentifiedBfFilterTracks { struct : ConfigurableGroup { - Configurable cfgCCDBUrl{"input_ccdburl", "http://ccdb-test.cern.ch:8080", "The CCDB url for the input file"}; - Configurable cfgCCDBPathName{"input_ccdbpath", "", "The CCDB path for the input file. Default \"\", i.e. don't load from CCDB"}; - Configurable cfgCCDBDate{"input_ccdbdate", "20220307", "The CCDB date for the input file"}; + Configurable inputCCDBUrl{"inputCCDBUrl", "http://ccdb-test.cern.ch:8080", "The CCDB url for the input file"}; + Configurable inputCCDBPathName{"inputCCDBPathName", "", "The CCDB path for the input file. Default \"\", i.e. don't load from CCDB"}; + Configurable inputCCDBDate{"inputCCDBDate", "20220307", "The CCDB date for the input file"}; } cfgcentersinputfile; Service ccdb; @@ -614,37 +721,60 @@ struct IdentifiedBfFilterTracks { return lst; } + Service fPDG; Produces scannedtracks; Produces tracksinfo; Produces scannedgentracks; Produces gentracksinfo; - Configurable cfgFullDerivedData{"fullderiveddata", false, "Produce the full derived data for external storage. Default false"}; - Configurable cfgTrackType{"trktype", 1, "Type of selected tracks: 0 = no selection, 1 = Run2 global tracks FB96, 3 = Run3 tracks, 5 = Run2 TPC only tracks, 7 = Run 3 TPC only tracks. Default 1"}; - Configurable cfgSystem{"syst", "PbPb", "System: pp, PbPb, Pbp, pPb, XeXe, ppRun3, PbPbRun3. Default PbPb"}; - Configurable cfgDataType{"datatype", "data", "Data type: data, datanoevsel, MC, FastMC, OnTheFlyMC. Default data"}; - Configurable cfgBinning{"binning", + Configurable cfgFullDerivedData{"cfgFullDerivedData", false, "Produce the full derived data for external storage. Default false"}; + Configurable cfgTrackType{"cfgTrackType", 1, "Type of selected tracks: 0 = no selection, 1 = Run2 global tracks FB96, 3 = Run3 tracks, 5 = Run2 TPC only tracks, 7 = Run 3 TPC only tracks. Default 1"}; + Configurable cfgSystem{"cfgSystem", "PbPb", "System: pp, PbPb, Pbp, pPb, XeXe, ppRun3, PbPbRun3. Default PbPb"}; + Configurable cfgDataType{"cfgDataType", "data", "Data type: data, datanoevsel, MC, FastMC, OnTheFlyMC. Default data"}; + Configurable cfgBinning{"cfgBinning", {28, -7.0, 7.0, 18, 0.2, 2.0, 16, -0.8, 0.8, 72, 0.5}, "triplets - nbins, min, max - for z_vtx, pT, eta and phi, binning plus bin fraction of phi origin shift"}; - Configurable cfgTraceDCAOutliers{"trackdcaoutliers", {false, 0.0, 0.0}, "Track the generator level DCAxy outliers: false/true, low dcaxy, up dcaxy. Default {false,0.0,0.0}"}; - Configurable cfgTraceOutOfSpeciesParticles{"trackoutparticles", false, "Track the particles which are not e,mu,pi,K,p: false/true. Default false"}; - Configurable cfgRecoIdMethod{"recoidmethod", 0, "Method for identifying reconstructed tracks: 0 No PID, 1 PID, 2 mcparticle. Default 0"}; - Configurable cfgTrackSelection{"tracksel", {false, false, 0, 70, 0.8, 2.4, 3.2}, "Track selection: {useit: true/false, ongen: true/false, tpccls, tpcxrws, tpcxrfc, dcaxy, dcaz}. Default {false,0.70.0.8,2.4,3.2}"}; - Configurable reqTOF{"requireTOF", false, "Require TOF data for PID. Default false"}; + Configurable cfgTraceDCAOutliers{"cfgTraceDCAOutliers", {false, 0.0, 0.0}, "Track the generator level DCAxy outliers: false/true, low dcaxy, up dcaxy. Default {false,0.0,0.0}"}; + Configurable cfgTraceOutOfSpeciesParticles{"cfgTraceOutOfSpeciesParticles", false, "Track the particles which are not e,mu,pi,K,p: false/true. Default false"}; + Configurable cfgRecoIdMethod{"cfgRecoIdMethod", 0, "Method for identifying reconstructed tracks: 0 No PID, 1 PID, 2 mcparticle. Default 0"}; + Configurable cfgTrackSelection{"cfgTrackSelection", {false, false, 0, 70, 0.8, 2.4, 3.2}, "Track selection: {useit: true/false, ongen: true/false, tpccls, tpcxrws, tpcxrfc, dcaxy, dcaz}. Default {false,0.70.0.8,2.4,3.2}"}; + Configurable reqTOF{"reqTOF", false, "Require TOF data for PID. Default false"}; Configurable onlyTOF{"onlyTOF", false, "Only use TOF data for PID. Default false"}; - Configurable pidEl{"pidEl", -1, "Identify Electron Tracks"}; - Configurable pidPi{"pidPi", -1, "Identify Pion Tracks"}; - Configurable pidKa{"pidKa", -1, "Identify Kaon Tracks"}; - Configurable pidPr{"pidPr", -1, "Identify Proton Tracks"}; + // Configurable pidEl{"pidEl", -1, "Identify Electron Tracks"}; + // Configurable pidPi{"pidPi", -1, "Identify Pion Tracks"}; + // Configurable pidKa{"pidKa", -1, "Identify Kaon Tracks"}; + // Configurable pidPr{"pidPr", -1, "Identify Proton Tracks"}; + + // Configurable minPIDSigma{"minPIDSigma", -3.0, "Minimum required sigma for PID Acceptance"}; + // Configurable maxPIDSigma{"maxPIDSigma", 3.0, "Maximum required sigma for PID Acceptance"}; + + // Configurable> minPIDSigmas{"minPIDSigmas", {-3.,-3.,-3.,-3.},"Minimum required sigma for PID Acceptance, {e, pi, K, p}"}; + // Configurable>> acceptPIDSigmas{"acceptPIDSigmas", {{-3.,3.},{-3.,3.},{-3.,3.},{-3.,3.}},"Sigma range for PID Acceptance, {e, pi, K, p}"}; + // Configurable> minRejectSigmas{"minRejectSigmas", {-1.,-1.,-1.,-1.},"Minimum required sigma for PID double match rejection, {e, pi, K, p}"}; + + // Configurable minRejectSigma{"minRejectSigma", -1.0, "Minimum required sigma for PID double match rejection"}; + // Configurable maxRejectSigma{"maxRejectSigma", 1.0, "Maximum required sigma for PID double match rejection"}; - Configurable minPIDSigma{"minpidsigma", -3.0, "Minimum required sigma for PID Acceptance"}; - Configurable maxPIDSigma{"maxpidsigma", 3.0, "Maximum required sigma for PID Acceptance"}; + Configurable> cfgDoPID{"cfgDoPID", {-1, -1, -1, -1}, "Do PID for particle, {e, pi, K, p}"}; + Configurable> cfgTOFCut{"cfgTOFCut", {0.8, 0.8, 0.8, 0.8}, "Momentum under which we don't use TOF PID data, {e, pi, K, p}"}; + Configurable> cfgTPCCut{"cfgTPCCut", {1.2, 1.2, 1.2, 1.2}, "Momentum over which we don't use TPC PID data, {e, pi, K, p}"}; - Configurable minRejectSigma{"minrejectsigma", -1.0, "Minimum required sigma for PID double match rejection"}; - Configurable maxRejectSigma{"maxrejectsigma", 1.0, "Maximum required sigma for PID double match rejection"}; + Configurable makeNSigmaPlots{"makeNSigmaPlots", false, "Produce the N Sigma Plots for external storage. Default false"}; - Configurable tofCut{"TOFCutoff", 0.8, "Momentum under which we don't use TOF PID data"}; + struct : ConfigurableGroup { + Configurable> rejectPIDSigmasEl{"rejectPIDSigmasEl", {0., 1., 1., 1.}, "Required sigma for PID double match rejection of electrons for {e, pi, K, p}"}; + Configurable> rejectPIDSigmasPi{"rejectPIDSigmasPi", {1., 0., 1., 1.}, "Required sigma for PID double match rejection of pions for {e, pi, K, p}"}; + Configurable> rejectPIDSigmasKa{"rejectPIDSigmasKa", {1., 1., 0., 1.}, "Required sigma for PID double match rejection of kaons for {e, pi, K, p}"}; + Configurable> rejectPIDSigmasPr{"rejectPIDSigmasPr", {1., 1., 1., 0.}, "Required sigma for PID double match rejection of protons for {e, pi, K, p}"}; + } rejectPIDSigmas; + + struct : ConfigurableGroup { + Configurable> acceptPIDSigmasEl{"acceptPIDSigmasEl", {-3., 3.}, "Sigma range for PID Acceptance for electrons"}; + Configurable> acceptPIDSigmasPi{"acceptPIDSigmasPi", {-3., 3.}, "Sigma range for PID Acceptance for pions"}; + Configurable> acceptPIDSigmasKa{"acceptPIDSigmasKa", {-3., 3.}, "Sigma range for PID Acceptance for kaons"}; + Configurable> acceptPIDSigmasPr{"acceptPIDSigmasPr", {-3., 3.}, "Sigma range for PID Acceptance for protons"}; + } acceptPIDSigmas; OutputObj fOutput{"IdentifiedBfFilterTracksInfo", OutputObjHandlingPolicy::AnalysisObject}; bool checkAmbiguousTracks = false; @@ -654,18 +784,18 @@ struct IdentifiedBfFilterTracks { LOGF(info, "IdentifiedBfFilterTracks::init()"); // ccdb info - ccdb->setURL(cfgcentersinputfile.cfgCCDBUrl); + ccdb->setURL(cfgcentersinputfile.inputCCDBUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); LOGF(info, "Initizalized CCDB"); - loadfromccdb = cfgcentersinputfile.cfgCCDBPathName->length() > 0; + loadfromccdb = cfgcentersinputfile.inputCCDBPathName->length() > 0; if (ccdblst == nullptr) { if (loadfromccdb) { LOGF(info, "Loading CCDB Objects"); - ccdblst = getCCDBInput(cfgcentersinputfile.cfgCCDBPathName->c_str(), cfgcentersinputfile.cfgCCDBDate->c_str()); + ccdblst = getCCDBInput(cfgcentersinputfile.inputCCDBPathName->c_str(), cfgcentersinputfile.inputCCDBDate->c_str()); for (int i = 0; i < kIdBfNoOfSpecies; i++) { fhNSigmaCorrection[i] = reinterpret_cast(ccdblst->FindObject(Form("centerBin_%s", speciesName[i]))); } @@ -686,6 +816,21 @@ struct IdentifiedBfFilterTracks { zvtxbins = cfgBinning->mZVtxbins; zvtxlow = cfgBinning->mZVtxmin; zvtxup = cfgBinning->mZVtxmax; + + LOGF(info, "Initializing ranges"); + acceptRange.push_back(acceptPIDSigmas.acceptPIDSigmasEl); + acceptRange.push_back(acceptPIDSigmas.acceptPIDSigmasPi); + acceptRange.push_back(acceptPIDSigmas.acceptPIDSigmasKa); + acceptRange.push_back(acceptPIDSigmas.acceptPIDSigmasPr); + + rejectRange.push_back(rejectPIDSigmas.rejectPIDSigmasEl); + rejectRange.push_back(rejectPIDSigmas.rejectPIDSigmasPi); + rejectRange.push_back(rejectPIDSigmas.rejectPIDSigmasKa); + rejectRange.push_back(rejectPIDSigmas.rejectPIDSigmasPr); + + doPID = cfgDoPID; + tofCut = cfgTOFCut; + tpcCut = cfgTPCCut; /* the track types and combinations */ tracktype = cfgTrackType.value; initializeTrackSelection(); @@ -725,7 +870,6 @@ struct IdentifiedBfFilterTracks { /* if the system type is not known at this time, we have to put the initialization somewhere else */ fSystem = getSystemType(cfgSystem); fDataType = getDataType(cfgDataType); - fPDG = TDatabasePDG::Instance(); /* required ambiguous tracks checks? */ if (dofilterDetectorLevelWithoutPIDAmbiguous || dofilterDetectorLevelWithPIDAmbiguous || dofilterRecoWithoutPIDAmbiguous || dofilterRecoWithPIDAmbiguous) { @@ -738,12 +882,16 @@ struct IdentifiedBfFilterTracks { fOutput.setObject(fOutputList); /* incorporate configuration parameters to the output */ - fOutputList->Add(new TParameter("TrackType", cfgTrackType, 'f')); - fOutputList->Add(new TParameter("TrackOneCharge", 1, 'f')); - fOutputList->Add(new TParameter("TrackTwoCharge", -1, 'f')); + fOutputList->Add(new TParameter("TrackType", cfgTrackType, 'f')); + fOutputList->Add(new TParameter("TrackOneCharge", 1, 'f')); + fOutputList->Add(new TParameter("TrackTwoCharge", -1, 'f')); if ((fDataType == kData) || (fDataType == kDataNoEvtSel) || (fDataType == kMC)) { /* create the reconstructed data histograms */ + fhXYB = new TH2F("fHistXYB", "x and y distribution for reconstructed before", 1000, -10.0, 10.0, 1000, -10.0, 10.0); + fhYZB = new TH2F("fHistYZB", "y and z distribution for reconstructed before", 1000, -10.0, 10.0, 1000, -10.0, 10.0); + fhXYA = new TH2F("fHistXYA", "x and y distribution for reconstructed after", 1000, -10.0, 10.0, 1000, -10.0, 10.0); + fhYZA = new TH2F("fHistYZA", "y and z distribution for reconstructed after", 1000, -10.0, 10.0, 1000, -10.0, 10.0); fhPB = new TH1F("fHistPB", "p distribution for reconstructed before;p (GeV/c);dN/dp (c/GeV)", 100, 0.0, 15.0); fhPtB = new TH1F("fHistPtB", "p_{T} distribution for reconstructed before;p_{T} (GeV/c);dN/dP_{T} (c/GeV)", 100, 0.0, 15.0); fhPtPosB = new TH1F("fHistPtPosB", "P_{T} distribution for reconstructed (#plus) before;P_{T} (GeV/c);dN/dP_{T} (c/GeV)", 100, 0.0, 15.0); @@ -753,13 +901,45 @@ struct IdentifiedBfFilterTracks { fhPhiB = new TH1F("fHistPhiB", "#phi distribution for reconstructed before;#phi;counts", 360, 0.0, constants::math::TwoPI); fhdEdxB = new TH2F("fHistdEdxB", "dE/dx vs P before; P (GeV/c); dE/dx (a.u.)", ptbins, ptlow, ptup, 1000, 0.0, 1000.0); fhdEdxIPTPCB = new TH2F("fHistdEdxIPTPCB", "dE/dx vs P_{IP} before; P (GeV/c); dE/dx (a.u.)", ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhTrackLengthB = new TH1F(TString::Format("fhTrackLengthB").Data(), + TString::Format("Track Length; L (cm)").Data(), + 1000, 0., 1000.0); + fhTrackLengthTOFB = new TH1F(TString::Format("fhTrackLengthTOFB").Data(), + TString::Format("Track Length with TOF; L (cm)").Data(), + 1000, 0.0, 1000.0); + fhTrackTimeB = new TH2F(TString::Format("fhTrackTimeB").Data(), + TString::Format("Track Time vs P; P (GeV/c); Track Time(ns)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrackBetaInvB = new TH2F(TString::Format("fhTrackBetaInvB").Data(), + TString::Format("1/#Beta vs P; P (GeV/c); 1/#Beta(ns/m)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrackTimeIPB = new TH2F(TString::Format("fhTrackTimeIPB").Data(), + TString::Format("Track Time vs P_{IP}; P (GeV/c); Track Time(ns)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrackBetaInvIPB = new TH2F(TString::Format("fhTrackBetaInvIPB").Data(), + TString::Format("1/#Beta vs P_{IP}; P (GeV/c); 1/#Beta(ns/m)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); fhPhiA = new TH1F("fHistPhiA", "#phi distribution for reconstructed;#phi;counts", 360, 0.0, constants::math::TwoPI); fhDCAxyB = new TH1F("DCAxyB", "DCA_{xy} distribution for reconstructed before;DCA_{xy} (cm);counts", 1000, -4.0, 4.0); fhDCAxyA = new TH1F("DCAxyA", "DCA_{xy} distribution for reconstructed;DCA_{xy} (cm);counts", 1000, -4., 4.0); + fhDCAxyzB = new TH2F("DCAxyzB", "DCA_{xy} vs DCA_{z} distribution for reconstructed before;DCA_{xy} (cm); DCA_{z} (cm);counts", 1000, -4.0, 4.0, 1000, -4.0, 4.0); fhFineDCAxyA = new TH1F("FineDCAxyA", "DCA_{xy} distribution for reconstructed;DCA_{xy} (cm);counts", 4000, -1.0, 1.0); fhDCAzB = new TH1F("DCAzB", "DCA_{z} distribution for reconstructed before;DCA_{z} (cm);counts", 1000, -4.0, 4.0); fhDCAzA = new TH1F("DCAzA", "DCA_{z} distribution for reconstructed;DCA_{z} (cm);counts", 1000, -4.0, 4.0); fhFineDCAzA = new TH1F("FineDCAzA", "DCA_{z} distribution for reconstructed;DCA_{z} (cm);counts", 4000, -1.0, 1.0); + fhDCAxyzA = new TH2F("DCAxyzA", "DCA_{xy} vs DCA_{z} distribution for reconstructed;DCA_{xy} (cm); DCA_{z} (cm);counts", 1000, -4.0, 4.0, 1000, -4.0, 4.0); + + fhNClustersB = new TH1I("fHistNClB", "TPC NClusters distribution for reconstructed before;counts", 201, 0, 200); + fhPhiYB = new TH2F("fHistPhiYB", "#phi vs #eta distribution for reconstructed before;#phi;#eta;counts", 360, 0.0, constants::math::TwoPI, 40, -2.0, 2.0); + fhPtYB = new TH2F("fHistPtYB", "p_{T} vs #eta distribution for reconstructed before;p_{T} (GeV/c);#eta;counts", 100, 0.0, 15.0, 40, -2.0, 2.0); + fhChi2B = new TH1F("fHistChi2B", "#chi^{2}/Ncl TPC distribution for reconstructed before;", 100, 0.0, 20.0); + fhITSNclB = new TH1I("fHistITSNClB", "ITS NClusters distribution for reconstructed before;counts", 21, 0, 20); + + fhNClustersA = new TH1I("fHistNClA", "TPC NClusters distribution for reconstructed after;counts", 201, 0, 200); + fhPhiYA = new TH2F("fHistPhiYA", "#phi vs #eta distribution for reconstructed after;#phi;#eta;counts", 360, 0.0, constants::math::TwoPI, 40, -2.0, 2.0); + fhPtYA = new TH2F("fHistPtYA", "p_{T} vs #eta distribution for reconstructed after;p_{T} (GeV/c);#eta;counts", 100, 0.0, 15.0, 40, -2.0, 2.0); + fhChi2A = new TH1F("fHistChi2A", "#chi^{2}/Ncl TPC distribution for reconstructed after;", 100, 0.0, 20.0); + fhITSNclA = new TH1I("fHistITSNClA", "ITS NClusters distribution for reconstructed after;counts", 21, 0, 20); fhDoublePID = new TH2S("DoublePID", "PIDs for double match;Original Species;Secondary Species", kIdBfNoOfSpecies, 0, kIdBfNoOfSpecies, kIdBfNoOfSpecies, 0, kIdBfNoOfSpecies); @@ -773,6 +953,25 @@ struct IdentifiedBfFilterTracks { } for (int sp = 0; sp < kIdBfNoOfSpecies; ++sp) { + fhNSigmaTPC[sp] = new TH2F(TString::Format("fhNSigmaTPC_%s", speciesName[sp]).Data(), + TString::Format("N Sigma from TPC vs P for %s;N #sigma;p (GeV/c)", speciesTitle[sp]).Data(), + 48, -6, 6, + ptbins, ptlow, ptup); + fhNSigmaTOF[sp] = new TH2F(TString::Format("fhNSigmaTOF_%s", speciesName[sp]).Data(), + TString::Format("N Sigma from TOF vs P for %s;N #sigma;p (GeV/c)", speciesTitle[sp]).Data(), + 48, -6, 6, + ptbins, ptlow, ptup); + fhNSigmaCombo[sp] = new TH2F(TString::Format("fhNSigmaCombo_%s", speciesName[sp]).Data(), + TString::Format("N Sigma from Combo vs P for %s;N #sigma;p (GeV/c)", speciesTitle[sp]).Data(), + 48, -6, 6, + ptbins, ptlow, ptup); + fhNSigmaTPCIdTrks[sp] = new TH2F(TString::Format("fhNSigmaTPC_IdTrks_%s", speciesName[sp]).Data(), + TString::Format("N Sigma from TPC vs P for Identified %s;N #sigma;p (GeV/c)", speciesTitle[sp]).Data(), + 48, -6, 6, + ptbins, ptlow, ptup); + } + + for (int sp = 0; sp < kIdBfNoOfSpecies + 1; ++sp) { fhPA[sp] = new TH1F(TString::Format("fHistPA_%s", speciesName[sp]).Data(), TString::Format("p distribution for reconstructed %s;p (GeV/c);dN/dp (c/GeV)", speciesTitle[sp]).Data(), ptbins, ptlow, ptup); @@ -785,42 +984,85 @@ struct IdentifiedBfFilterTracks { fhPtNegA[sp] = new TH1F(TString::Format("fHistPtNegA_%s", speciesName[sp]), TString::Format("P_{T} distribution for reconstructed %s^{#minus};P_{T} (GeV/c);dN/dP_{T} (c/GeV)", speciesTitle[sp]).Data(), ptbins, ptlow, ptup); + fhPtEtaPosA[sp] = new TH2F(TString::Format("fHistPtEtaPosA_%s", speciesName[sp]), + TString::Format("P_{T} vs #eta distribution for reconstructed %s^{#plus};P_{T} (GeV/c);#eta;dN/dP_{T} (c/GeV)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, + etabins, etalow, etaup); + fhPtEtaNegA[sp] = new TH2F(TString::Format("fHistPtEtaNegA_%s", speciesName[sp]), + TString::Format("P_{T} vs #eta distribution for reconstructed %s^{#minus};P_{T} (GeV/c);#eta;dN/dP_{T} (c/GeV)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, + etabins, etalow, etaup); fhNPosNegA[sp] = new TH2F(TString::Format("fhNPosNegA_%s", speciesName[sp]).Data(), TString::Format("N(%s^{#plus}) N(%s^{#minus}) distribution for reconstructed;N(%s^{#plus});N(%s^{#minus})", speciesTitle[sp], speciesTitle[sp], speciesTitle[sp], speciesTitle[sp]).Data(), 40, -0.5, 39.5, 40, -0.5, 39.5); fhDeltaNA[sp] = new TH1F(TString::Format("fhDeltaNA_%s", speciesName[sp]).Data(), TString::Format("N(%s^{#plus}) #minus N(%s^{#minus}) distribution for reconstructed;N(%s^{#plus}) #minus N(%s^{#minus})", speciesTitle[sp], speciesTitle[sp], speciesTitle[sp], speciesTitle[sp]).Data(), 79, -39.5, 39.5); - fhNSigmaTPC[sp] = new TH2F(TString::Format("fhNSigmaTPC_%s", speciesName[sp]).Data(), - TString::Format("N Sigma from TPC vs P for %s;N #sigma;p (GeV/c)", speciesTitle[sp]).Data(), - 48, -6, 6, - ptbins, ptlow, ptup); - fhNSigmaTOF[sp] = new TH2F(TString::Format("fhNSigmaTOF_%s", speciesName[sp]).Data(), - TString::Format("N Sigma from TOF vs P for %s;N #sigma;p (GeV/c)", speciesTitle[sp]).Data(), - 48, -6, 6, - ptbins, ptlow, ptup); - fhNSigmaCombo[sp] = new TH2F(TString::Format("fhNSigmaCombo_%s", speciesName[sp]).Data(), - TString::Format("N Sigma from Combo vs P for %s;N #sigma;p (GeV/c)", speciesTitle[sp]).Data(), - 48, -6, 6, - ptbins, ptlow, ptup); - fhNSigmaTPC_IdTrks[sp] = new TH2F(TString::Format("fhNSigmaTPC_IdTrks_%s", speciesName[sp]).Data(), - TString::Format("N Sigma from TPC vs P for Identified %s;N #sigma;p (GeV/c)", speciesTitle[sp]).Data(), - 48, -6, 6, - ptbins, ptlow, ptup); fhdEdxA[sp] = new TH2F(TString::Format("fhdEdxA_%s", speciesName[sp]).Data(), TString::Format("dE/dx vs P reconstructed %s; P (GeV/c); dE/dx (a.u.)", speciesTitle[sp]).Data(), ptbins, ptlow, ptup, 1000, 0.0, 1000.0); fhdEdxIPTPCA[sp] = new TH2F(TString::Format("fhdEdxIPTPCA_%s", speciesName[sp]).Data(), TString::Format("dE/dx vs P_{IP} reconstructed %s; P (GeV/c); dE/dx (a.u.)", speciesTitle[sp]).Data(), ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhTrackLengthA[sp] = new TH1F(TString::Format("fhTrackLengthA_%s", speciesName[sp]).Data(), + TString::Format("Track Length of reconstructed %s; L (cm)", speciesTitle[sp]).Data(), + 1000, 0.0, 1000.0); + fhTrackLengthTOFA[sp] = new TH1F(TString::Format("fhTrackLengthTOFA_%s", speciesName[sp]).Data(), + TString::Format("Track Length of reconstructed %s with TOF; L (cm)", speciesTitle[sp]).Data(), + 1000, 0.0, 1000.0); + fhTrackTimeA[sp] = new TH2F(TString::Format("fhTrackTimeA_%s", speciesName[sp]).Data(), + TString::Format("Track Time vs P reconstructed %s; P (GeV/c); Track Time(ns)", speciesTitle[sp]).Data(), ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrackBetaInvA[sp] = new TH2F(TString::Format("fhTrackBetaInvA_%s", speciesName[sp]).Data(), + TString::Format("1/#Beta vs P reconstructed %s; P (GeV/c); 1/#Beta(ns/m)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrackTimeIPA[sp] = new TH2F(TString::Format("fhTrackTimeIPA_%s", speciesName[sp]).Data(), + TString::Format("Track Time vs P_{IP} reconstructed %s; P (GeV/c); Track Time(ns)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrackBetaInvIPA[sp] = new TH2F(TString::Format("fhTrackBetaInvIPA_%s", speciesName[sp]).Data(), + TString::Format("1/#Beta vs P_{IP} reconstructed %s; P (GeV/c); 1/#Beta(ns/m)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + LOGF(info, "Made Histos"); } - fhdEdxA[kIdBfNoOfSpecies] = new TH2F(TString::Format("fhdEdxA_WrongSpecies").Data(), - TString::Format("dE/dx vs P reconstructed Wrong Species; P (GeV/c); dE/dx (a.u.)").Data(), - ptbins, ptlow, ptup, 1000, 0.0, 1000.0); - fhdEdxIPTPCA[kIdBfNoOfSpecies] = new TH2F(TString::Format("fhdEdxIPTPCA_WrongSpecies").Data(), - TString::Format("dE/dx vs P_{IP} reconstructed Wrong Species; P (GeV/c); dE/dx (a.u.)").Data(), - ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhdEdxA[kIdBfNoOfSpecies + 1] = new TH2F(TString::Format("fhdEdxA_WrongSpecies").Data(), + TString::Format("dE/dx vs P reconstructed Wrong Species; P (GeV/c); dE/dx (a.u.)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhdEdxIPTPCA[kIdBfNoOfSpecies + 1] = new TH2F(TString::Format("fhdEdxIPTPCA_WrongSpecies").Data(), + TString::Format("dE/dx vs P_{IP} reconstructed Wrong Species; P (GeV/c); dE/dx (a.u.)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhTrackLengthA[kIdBfNoOfSpecies + 1] = new TH1F(TString::Format("fhTrackLengthA_WrongSpecies").Data(), + TString::Format("Track Length of reconstructed Wrong Species; L (cm)").Data(), + 1000, 0.0, 1000.0); + fhTrackLengthTOFA[kIdBfNoOfSpecies + 1] = new TH1F(TString::Format("fhTrackLengthTOFA_WrongSpecies").Data(), + TString::Format("Track Length of reconstructed Wrong Species with TOF; L (cm)").Data(), + 1000, 0.0, 1000.0); + fhTrackTimeA[kIdBfNoOfSpecies + 1] = new TH2F(TString::Format("fhTrackTimeA_WrongSpecies").Data(), + TString::Format("Track Time vs P reconstructed Wrong Species; P (GeV/c); Track Time(ns)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrackBetaInvA[kIdBfNoOfSpecies + 1] = new TH2F(TString::Format("fhTrackBetaInvA_WrongSpecies").Data(), + TString::Format("1/#Beta vs P reconstructed Wrong Species; P (GeV/c); 1/#Beta(ns/m)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrackTimeIPA[kIdBfNoOfSpecies + 1] = new TH2F(TString::Format("fhTrackTimeIPA_WrongSpecies").Data(), + TString::Format("Track Time vs P_{IP} reconstructed Wrong Species; P (GeV/c); Track Time(ns)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrackBetaInvIPA[kIdBfNoOfSpecies + 1] = new TH2F(TString::Format("fhTrackBetaInvIPA_WrongSpecies").Data(), + TString::Format("1/#Beta vs P_{IP} reconstructed Wrong Species; P (GeV/c); 1/#Beta(ns/m)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + /* add the hstograms to the output list */ + fOutputList->Add(fhXYB); + fOutputList->Add(fhYZB); + fOutputList->Add(fhXYA); + fOutputList->Add(fhYZA); + fOutputList->Add(fhNClustersB); + fOutputList->Add(fhNClustersA); + fOutputList->Add(fhPhiYB); + fOutputList->Add(fhPhiYA); + fOutputList->Add(fhPtYB); + fOutputList->Add(fhPtYA); + fOutputList->Add(fhChi2B); + fOutputList->Add(fhChi2A); + fOutputList->Add(fhITSNclB); + fOutputList->Add(fhITSNclA); fOutputList->Add(fhPB); fOutputList->Add(fhPtB); fOutputList->Add(fhPtPosB); @@ -831,14 +1073,23 @@ struct IdentifiedBfFilterTracks { fOutputList->Add(fhPhiA); fOutputList->Add(fhdEdxB); fOutputList->Add(fhdEdxIPTPCB); + fOutputList->Add(fhTrackLengthB); + fOutputList->Add(fhTrackLengthTOFB); + fOutputList->Add(fhTrackTimeB); + fOutputList->Add(fhTrackBetaInvB); + fOutputList->Add(fhTrackTimeIPB); + fOutputList->Add(fhTrackBetaInvIPB); fOutputList->Add(fhDCAxyB); fOutputList->Add(fhDCAxyA); + fOutputList->Add(fhDCAxyzB); + fOutputList->Add(fhDCAxyzA); fOutputList->Add(fhWrongTrackID); fOutputList->Add(fhDoublePID); fOutputList->Add(fhFineDCAxyA); fOutputList->Add(fhDCAzB); fOutputList->Add(fhDCAzA); fOutputList->Add(fhFineDCAzA); + if (checkAmbiguousTracks) { fOutputList->Add(fhAmbiguousTrackType); fOutputList->Add(fhAmbiguousTrackPt); @@ -847,26 +1098,56 @@ struct IdentifiedBfFilterTracks { } for (int sp = 0; sp < kIdBfNoOfSpecies; ++sp) { + fOutputList->Add(fhNSigmaTPC[sp]); + fOutputList->Add(fhNSigmaTOF[sp]); + fOutputList->Add(fhNSigmaCombo[sp]); + fOutputList->Add(fhNSigmaTPCIdTrks[sp]); + } + + for (int sp = 0; sp < kIdBfNoOfSpecies + 1; ++sp) { fOutputList->Add(fhPA[sp]); fOutputList->Add(fhPtA[sp]); fOutputList->Add(fhPtPosA[sp]); fOutputList->Add(fhPtNegA[sp]); + fOutputList->Add(fhPtEtaPosA[sp]); + fOutputList->Add(fhPtEtaNegA[sp]); fOutputList->Add(fhNPosNegA[sp]); fOutputList->Add(fhDeltaNA[sp]); - fOutputList->Add(fhNSigmaTPC[sp]); - fOutputList->Add(fhNSigmaTOF[sp]); - fOutputList->Add(fhNSigmaCombo[sp]); - fOutputList->Add(fhNSigmaTPC_IdTrks[sp]); fOutputList->Add(fhdEdxA[sp]); fOutputList->Add(fhdEdxIPTPCA[sp]); + fOutputList->Add(fhTrackLengthA[sp]); + fOutputList->Add(fhTrackLengthTOFA[sp]); + fOutputList->Add(fhTrackTimeA[sp]); + fOutputList->Add(fhTrackBetaInvA[sp]); + fOutputList->Add(fhTrackTimeIPA[sp]); + fOutputList->Add(fhTrackBetaInvIPA[sp]); + LOGF(info, "Added histos"); } - fOutputList->Add(fhdEdxA[kIdBfNoOfSpecies]); - fOutputList->Add(fhdEdxIPTPCA[kIdBfNoOfSpecies]); + fOutputList->Add(fhdEdxA[kIdBfNoOfSpecies + 1]); + fOutputList->Add(fhdEdxIPTPCA[kIdBfNoOfSpecies + 1]); + fOutputList->Add(fhTrackLengthA[kIdBfNoOfSpecies + 1]); + fOutputList->Add(fhTrackLengthTOFA[kIdBfNoOfSpecies + 1]); + fOutputList->Add(fhTrackTimeA[kIdBfNoOfSpecies + 1]); + fOutputList->Add(fhTrackBetaInvA[kIdBfNoOfSpecies + 1]); + fOutputList->Add(fhTrackTimeIPA[kIdBfNoOfSpecies + 1]); + fOutputList->Add(fhTrackBetaInvIPA[kIdBfNoOfSpecies + 1]); } if ((fDataType != kData) && (fDataType != kDataNoEvtSel)) { /* create the true data histograms */ + + fhTruePIDMismatch = new TH2S("fHistTruePIDMismatch", "Mismatched Generated and Reconstructed PID;Generated Species;Reconstructed Species", kIdBfNoOfSpecies, 0, kIdBfNoOfSpecies, kIdBfNoOfSpecies, 0, kIdBfNoOfSpecies); + fhTruePIDCorrect = new TH1S("fHistTruePIDCorrect", "Correct PID between Generated and Reconstructed PID;Species", kIdBfNoOfSpecies, 0, kIdBfNoOfSpecies); + fhTruePB = new TH1F("fTrueHistPB", "p distribution before (truth);p (GeV/c);dN/dp (c/GeV)", 100, 0.0, 15.0); + fhTrueCharge = new TH1F("fTrueHistCharge", "Charge distribution before (truth);charge;count", 3, -1.0, 1.0); + + fhTruePhiYB = new TH2F("fTrueHistPhiYB", "#phi vs #eta distribution before (truth);#phi;#eta;counts", 360, 0.0, constants::math::TwoPI, 40, -2.0, 2.0); + fhTruePtYB = new TH2F("fTrueHistPtYB", "p_{T} vs #eta distribution before (truth);p_{T} (GeV/c);#eta;counts", 100, 0.0, 15.0, 40, -2.0, 2.0); + + fhTruePhiYA = new TH2F("fTrueHistPhiYA", "#phi vs #eta distribution after (truth);#phi;#eta;counts", 360, 0.0, constants::math::TwoPI, 40, -2.0, 2.0); + fhTruePtYA = new TH2F("fTrueHistPtYA", "p_{T} vs #eta distribution after (truth);p_{T} (GeV/c);#eta;counts", 100, 0.0, 15.0, 40, -2.0, 2.0); + fhTruePtB = new TH1F("fTrueHistPtB", "p_{T} distribution before (truth);p_{T} (GeV/c);dN/dP_{T} (c/GeV)", 100, 0.0, 15.0); fhTruePtPosB = new TH1F("fTrueHistPtPosB", "P_{T} distribution (#plus) before (truth);P_{T} (GeV/c);dN/dP_{T} (c/GeV)", 100, 0.0, 15.0); fhTruePtNegB = new TH1F("fTrueHistPtNegB", "P_{T} distribution (#minus) before (truth);P_{T} (GeV/c);dN/dP_{T} (c/GeV)", 100, 0.0, 15.0); @@ -875,6 +1156,36 @@ struct IdentifiedBfFilterTracks { fhTruePhiB = new TH1F("fTrueHistPhiB", "#phi distribution before (truth);#phi;counts", 360, 0.0, constants::math::TwoPI); fhTruePhiA = new TH1F("fTrueHistPhiA", "#phi distribution (truth);#phi;counts", 360, 0.0, constants::math::TwoPI); fhTrueDCAxyB = new TH1F("TrueDCAxyB", "DCA_{xy} distribution for generated before;DCA_{xy} (cm);counts", 1000, -4.0, 4.0); + fhPrimaryPB = new TH1F(TString::Format("fhPrimaryPB").Data(), + TString::Format("p distribution Primary Before Selection;p (GeV/c);dN/dp (c/GeV)").Data(), + ptbins, ptlow, ptup); + fhPrimaryPtB = new TH1F(TString::Format("fhPrimaryPtB"), + TString::Format("p_{T} distribution Primary Before Selection ;p_{T} (GeV/c);dN/dP_{T} (c/GeV)").Data(), + ptbins, ptlow, ptup); + fhPrimarydEdxB = new TH2F(TString::Format("fhPrimarydEdxB").Data(), + TString::Format("dE/dx vs P Primary Before Selection; P (GeV/c); dE/dx (a.u.)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhPrimarydEdxIPTPCB = new TH2F(TString::Format("fhPrimarydEdxIPTPCB").Data(), + TString::Format("dE/dx vs P_{IP} Primary Before Selection; P (GeV/c); dE/dx (a.u.)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhPrimaryTrackLengthB = new TH1F(TString::Format("fhPrimaryTrackLengthB").Data(), + TString::Format("Track Length of Primary Before Selection; L (cm)").Data(), + 1000, 0.0, 1000.0); + fhPrimaryTrackLengthTOFB = new TH1F(TString::Format("fhPrimaryTrackLengthTOFB").Data(), + TString::Format("Track Length of Primary Before Selection with TOF; L (cm)").Data(), + 1000, 0.0, 1000.0); + fhPrimaryTrackTimeB = new TH2F(TString::Format("fhPrimaryTrackTimeB").Data(), + TString::Format("Track Time vs P Primary Before Selection; P (GeV/c); Track Time(ns)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhPrimaryTrackBetaInvB = new TH2F(TString::Format("fhPrimaryTrackBetaInvB").Data(), + TString::Format("1/#Beta vs P Primary Before Selection; P (GeV/c); 1/#Beta(ns/m)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhPrimaryTrackTimeIPB = new TH2F(TString::Format("fhPrimaryTrackTimeIPB").Data(), + TString::Format("Track Time vs P_{IP} Primary Before Selection; P (GeV/c); Track Time(ns)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhPrimaryTrackBetaInvIPB = new TH2F(TString::Format("fhPrimaryTrackBetaInvIPB").Data(), + TString::Format("1/#Beta vs P_{IP} Primary Before Selection; P (GeV/c); 1/#Beta(ns/m)").Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); if (traceDCAOutliers.mDoIt) { fhTrueDCAxyBid = new TH1F("PDGCodeDCAxyB", TString::Format("PDG code within %.2f<|DCA_{#it{xy}}|<%.2f; PDG code", traceDCAOutliers.mLowValue, traceDCAOutliers.mUpValue).Data(), @@ -883,8 +1194,10 @@ struct IdentifiedBfFilterTracks { fhTrueDCAxyA = new TH1F("TrueDCAxyA", "DCA_{xy} distribution for generated;DCA_{xy};counts (cm)", 1000, -4., 4.0); fhTrueDCAzB = new TH1F("TrueDCAzB", "DCA_{z} distribution for generated before;DCA_{z} (cm);counts", 1000, -4.0, 4.0); fhTrueDCAzA = new TH1F("TrueDCAzA", "DCA_{z} distribution for generated;DCA_{z} (cm);counts", 1000, -4.0, 4.0); + fhTrueDCAxyzB = new TH2F("TrueDCAxyzB", "DCA_{xy} vs DCA_{z} distribution for generated before;DCA_{xy} (cm);DCA_{z} (cm);counts", 1000, -4.0, 4.0, 1000, -4.0, 4.0); + fhTrueDCAxyzA = new TH2F("TrueDCAxyzA", "DCA_{xy} vs DCA_{z} distribution for generated after;DCA_{xy} (cm);DCA_{z} (cm);counts", 1000, -4.0, 4.0, 1000, -4.0, 4.0); - for (int sp = 0; sp < kIdBfNoOfSpecies; ++sp) { + for (int sp = 0; sp < kIdBfNoOfSpecies + 1; ++sp) { fhTruePA[sp] = new TH1F(TString::Format("fTrueHistPA_%s", speciesName[sp]).Data(), TString::Format("p distribution %s (truth);p (GeV/c);dN/dp (c/GeV)", speciesTitle[sp]).Data(), ptbins, ptlow, ptup); @@ -897,57 +1210,245 @@ struct IdentifiedBfFilterTracks { fhTruePtNegA[sp] = new TH1F(TString::Format("fTrueHistPtNegA_%s", speciesName[sp]), TString::Format("P_{T} distribution %s^{#minus} (truth);P_{T} (GeV/c);dN/dP_{T} (c/GeV)", speciesTitle[sp]).Data(), ptbins, ptlow, ptup); + fhTruePtEtaPosA[sp] = new TH2F(TString::Format("fTrueHistPtEtaPosA_%s", speciesName[sp]), + TString::Format("P_{T} vs #eta distribution %s^{#plus} (truth);P_{T} (GeV/c);#eta;dN/dP_{T} (c/GeV)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, + etabins, etalow, etaup); + fhTruePtEtaNegA[sp] = new TH2F(TString::Format("fTrueHistPtEtaNegA_%s", speciesName[sp]), + TString::Format("P_{T} vs #eta distribution %s^{#minus} (truth);P_{T} (GeV/c);#eta;dN/dP_{T} (c/GeV)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, + etabins, etalow, etaup); fhTrueNPosNegA[sp] = new TH2F(TString::Format("fhTrueNPosNegA_%s", speciesName[sp]).Data(), TString::Format("N(%s^{#plus}) N(%s^{#minus}) distribution (truth);N(%s^{#plus});N(%s^{#minus})", speciesTitle[sp], speciesTitle[sp], speciesTitle[sp], speciesTitle[sp]).Data(), 40, -0.5, 39.5, 40, -0.5, 39.5); fhTrueDeltaNA[sp] = new TH1F(TString::Format("fhTrueDeltaNA_%s", speciesName[sp]).Data(), TString::Format("N(%s^{#plus}) #minus N(%s^{#minus}) distribution (truth);N(%s^{#plus}) #minus N(%s^{#minus})", speciesTitle[sp], speciesTitle[sp], speciesTitle[sp], speciesTitle[sp]).Data(), 79, -39.5, 39.5); + fhTruedEdxA[sp] = new TH2F(TString::Format("fhTruedEdxA_%s", speciesName[sp]).Data(), + TString::Format("dE/dx vs P generated %s; P (GeV/c); dE/dx (a.u.)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhTruedEdxIPTPCA[sp] = new TH2F(TString::Format("fhTruedEdxIPTPCA_%s", speciesName[sp]).Data(), + TString::Format("dE/dx vs P_{IP} generated %s; P (GeV/c); dE/dx (a.u.)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhTrueTrackLengthA[sp] = new TH1F(TString::Format("fhTrueTrackLengthA_%s", speciesName[sp]).Data(), + TString::Format("Track Length of generated %s; L (cm)", speciesTitle[sp]).Data(), + 1000, 0.0, 1000.0); + fhTrueTrackLengthTOFA[sp] = new TH1F(TString::Format("fhTrueTrackLengthTOFA_%s", speciesName[sp]).Data(), + TString::Format("Track Length of generated %s with TOF; L (cm)", speciesTitle[sp]).Data(), + 1000, 0.0, 1000.0); + fhTrueTrackTimeA[sp] = new TH2F(TString::Format("fhTrueTrackTimeA_%s", speciesName[sp]).Data(), + TString::Format("Track Time vs P generated %s; P (GeV/c); Track Time(ns)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrueTrackBetaInvA[sp] = new TH2F(TString::Format("fhTrueTrackBetaInvA_%s", speciesName[sp]).Data(), + TString::Format("1/#Beta vs P generated %s; P (GeV/c); 1/#Beta(ns/m)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrueTrackTimeIPA[sp] = new TH2F(TString::Format("fhTrueTrackTimeIPA_%s", speciesName[sp]).Data(), + TString::Format("Track Time vs P_{IP} generated %s; P (GeV/c); Track Time(ns)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhTrueTrackBetaInvIPA[sp] = new TH2F(TString::Format("fhTrueTrackBetaInvIPA_%s", speciesName[sp]).Data(), + TString::Format("1/#Beta vs P_{IP} generated %s; P (GeV/c); 1/#Beta(ns/m)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + + fhPrimaryPA[sp] = new TH1F(TString::Format("fhPrimaryPA_%s", speciesName[sp]).Data(), + TString::Format("p distribution Primary %s;p (GeV/c);dN/dp (c/GeV)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup); + fhPrimaryPtA[sp] = new TH1F(TString::Format("fhPrimaryPtA_%s", speciesName[sp]), + TString::Format("p_{T} distribution Primary %s ;p_{T} (GeV/c);dN/dP_{T} (c/GeV)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup); + fhPrimarydEdxA[sp] = new TH2F(TString::Format("fhPrimarydEdxA_%s", speciesName[sp]).Data(), + TString::Format("dE/dx vs P Primary %s; P (GeV/c); dE/dx (a.u.)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhPrimarydEdxIPTPCA[sp] = new TH2F(TString::Format("fhPrimarydEdxIPTPCA_%s", speciesName[sp]).Data(), + TString::Format("dE/dx vs P_{IP} Primary %s; P (GeV/c); dE/dx (a.u.)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhPrimaryTrackLengthA[sp] = new TH1F(TString::Format("fhPrimaryTrackLengthA_%s", speciesName[sp]).Data(), + TString::Format("Track Length of Primary %s; L (cm)", speciesTitle[sp]).Data(), + 1000, 0.0, 1000.0); + fhPrimaryTrackLengthTOFA[sp] = new TH1F(TString::Format("fhPrimaryTrackLengthTOFA_%s", speciesName[sp]).Data(), + TString::Format("Track Length of Primary %s with TOF; L (cm)", speciesTitle[sp]).Data(), + 1000, 0.0, 1000.0); + fhPrimaryTrackTimeA[sp] = new TH2F(TString::Format("fhPrimaryTrackTimeA_%s", speciesName[sp]).Data(), + TString::Format("Track Time vs P Primary %s; P (GeV/c); Track Time(ns)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhPrimaryTrackBetaInvA[sp] = new TH2F(TString::Format("fhPrimaryTrackBetaInvA_%s", speciesName[sp]).Data(), + TString::Format("1/#Beta vs P Primary %s; P (GeV/c); 1/#Beta(ns/m)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhPrimaryTrackTimeIPA[sp] = new TH2F(TString::Format("fhPrimaryTrackTimeIPA_%s", speciesName[sp]).Data(), + TString::Format("Track Time vs P_{IP} Primary %s; P (GeV/c); Track Time(ns)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhPrimaryTrackBetaInvIPA[sp] = new TH2F(TString::Format("fhPrimaryTrackBetaInvIPA_%s", speciesName[sp]).Data(), + TString::Format("1/#Beta vs P_{IP} Primary %s; P (GeV/c); 1/#Beta(ns/m)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + + fhPurePA[sp] = new TH1F(TString::Format("fhPurePA_%s", speciesName[sp]).Data(), + TString::Format("p distribution Pure %s;p (GeV/c);dN/dp (c/GeV)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup); + fhPurePtA[sp] = new TH1F(TString::Format("fhPurePtA_%s", speciesName[sp]), + TString::Format("p_{T} distribution Pure %s ;p_{T} (GeV/c);dN/dP_{T} (c/GeV)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup); + fhPuredEdxA[sp] = new TH2F(TString::Format("fhPuredEdxA_%s", speciesName[sp]).Data(), + TString::Format("dE/dx vs P Pure %s; P (GeV/c); dE/dx (a.u.)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhPuredEdxIPTPCA[sp] = new TH2F(TString::Format("fhPuredEdxIPTPCA_%s", speciesName[sp]).Data(), + TString::Format("dE/dx vs P_{IP} Pure %s; P (GeV/c); dE/dx (a.u.)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 1000.0); + fhPureTrackLengthA[sp] = new TH1F(TString::Format("fhPureTrackLengthA_%s", speciesName[sp]).Data(), + TString::Format("Track Length of Pure %s; L (cm)", speciesTitle[sp]).Data(), + 1000, 0.0, 1000.0); + fhPureTrackLengthTOFA[sp] = new TH1F(TString::Format("fhPureTrackLengthTOFA_%s", speciesName[sp]).Data(), + TString::Format("Track Length of Pure %s with TOF; L (cm)", speciesTitle[sp]).Data(), + 1000, 0.0, 1000.0); + fhPureTrackTimeA[sp] = new TH2F(TString::Format("fhPureTrackTimeA_%s", speciesName[sp]).Data(), + TString::Format("Track Time vs P Pure %s; P (GeV/c); Track Time(ns)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhPureTrackBetaInvA[sp] = new TH2F(TString::Format("fhPureTrackBetaInvA_%s", speciesName[sp]).Data(), + TString::Format("1/#Beta vs P Pure %s; P (GeV/c); 1/#Beta(ns/m)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhPureTrackTimeIPA[sp] = new TH2F(TString::Format("fhPureTrackTimeIPA_%s", speciesName[sp]).Data(), + TString::Format("Track Time vs P_{IP} Pure %s; P (GeV/c); Track Time(ns)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + fhPureTrackBetaInvIPA[sp] = new TH2F(TString::Format("fhPureTrackBetaInvIPA_%s", speciesName[sp]).Data(), + TString::Format("1/#Beta vs P_{IP} Pure %s; P (GeV/c); 1/#Beta(ns/m)", speciesTitle[sp]).Data(), + ptbins, ptlow, ptup, 1000, 0.0, 10.0); + } + if (makeNSigmaPlots) { + for (int sp1 = 0; sp1 < kIdBfNoOfSpecies; ++sp1) { + for (int sp2 = 0; sp2 < kIdBfNoOfSpecies; ++sp2) { + fhTrueNSigmaTPC[sp1][sp2] = new TH2F(TString::Format("fhTrueNSigmaTPC%s_%s", speciesName[sp1], speciesName[sp2]).Data(), + TString::Format("N #sigma %s from TPC vs P for generated %s;N #sigma;p (GeV/c)", speciesTitle[sp1], speciesTitle[sp2]).Data(), + 48, -6, 6, + ptbins, ptlow, ptup); + + fhTrueNSigmaTOF[sp1][sp2] = new TH2F(TString::Format("fhTrueNSigmaTOF%s_%s", speciesName[sp1], speciesName[sp2]).Data(), + TString::Format("N #sigma %s from TOF vs P for generated %s;N #sigma;p (GeV/c)", speciesTitle[sp1], speciesTitle[sp2]).Data(), + 48, -6, 6, + ptbins, ptlow, ptup); + fhPrimaryNSigmaTPC[sp1][sp2] = new TH2F(TString::Format("fhPrimaryNSigmaTPC%s_%s", speciesName[sp1], speciesName[sp2]).Data(), + TString::Format("N #sigma %s from TPC vs P for primary %s;N #sigma;p (GeV/c)", speciesTitle[sp1], speciesTitle[sp2]).Data(), + 48, -6, 6, + ptbins, ptlow, ptup); + + fhPrimaryNSigmaTOF[sp1][sp2] = new TH2F(TString::Format("fhPrimaryNSigmaTOF%s_%s", speciesName[sp1], speciesName[sp2]).Data(), + TString::Format("N #sigma %s from TOF vs P for primary %s;N #sigma;p (GeV/c)", speciesTitle[sp1], speciesTitle[sp2]).Data(), + 48, -6, 6, + ptbins, ptlow, ptup); + } + } } /* add the hstograms to the output list */ + fOutputList->Add(fhTruePIDMismatch); + fOutputList->Add(fhTruePIDCorrect); + fOutputList->Add(fhTruePhiYB); + fOutputList->Add(fhTruePtYB); + fOutputList->Add(fhTruePhiYA); + fOutputList->Add(fhTruePtYA); fOutputList->Add(fhTruePB); fOutputList->Add(fhTruePtB); fOutputList->Add(fhTruePtPosB); fOutputList->Add(fhTruePtNegB); + fOutputList->Add(fhTrueCharge); fOutputList->Add(fhTrueEtaB); fOutputList->Add(fhTrueEtaA); fOutputList->Add(fhTruePhiB); fOutputList->Add(fhTruePhiA); fOutputList->Add(fhTrueDCAxyB); + fOutputList->Add(fhPrimaryPB); + fOutputList->Add(fhPrimaryPtB); + fOutputList->Add(fhPrimarydEdxB); + fOutputList->Add(fhPrimarydEdxIPTPCB); + fOutputList->Add(fhPrimaryTrackLengthB); + fOutputList->Add(fhPrimaryTrackLengthTOFB); + fOutputList->Add(fhPrimaryTrackTimeB); + fOutputList->Add(fhPrimaryTrackBetaInvB); + fOutputList->Add(fhPrimaryTrackTimeIPB); + fOutputList->Add(fhPrimaryTrackBetaInvIPB); if (traceDCAOutliers.mDoIt) { fOutputList->Add(fhTrueDCAxyBid); } fOutputList->Add(fhTrueDCAxyA); fOutputList->Add(fhTrueDCAzB); fOutputList->Add(fhTrueDCAzA); + fOutputList->Add(fhTrueDCAxyzB); + fOutputList->Add(fhTrueDCAxyzA); - for (int sp = 0; sp < kIdBfNoOfSpecies; ++sp) { + for (int sp = 0; sp < kIdBfNoOfSpecies + 1; ++sp) { fOutputList->Add(fhTruePA[sp]); fOutputList->Add(fhTruePtA[sp]); fOutputList->Add(fhTruePtPosA[sp]); fOutputList->Add(fhTruePtNegA[sp]); + fOutputList->Add(fhTruePtEtaPosA[sp]); + fOutputList->Add(fhTruePtEtaNegA[sp]); fOutputList->Add(fhTrueNPosNegA[sp]); fOutputList->Add(fhTrueDeltaNA[sp]); + + fOutputList->Add(fhTruedEdxA[sp]); + fOutputList->Add(fhTruedEdxIPTPCA[sp]); + fOutputList->Add(fhTrueTrackLengthA[sp]); + fOutputList->Add(fhTrueTrackLengthTOFA[sp]); + fOutputList->Add(fhTrueTrackTimeA[sp]); + fOutputList->Add(fhTrueTrackBetaInvA[sp]); + fOutputList->Add(fhTrueTrackTimeIPA[sp]); + fOutputList->Add(fhTrueTrackBetaInvIPA[sp]); + + fOutputList->Add(fhPrimaryPA[sp]); + fOutputList->Add(fhPrimaryPtA[sp]); + fOutputList->Add(fhPrimarydEdxA[sp]); + fOutputList->Add(fhPrimarydEdxIPTPCA[sp]); + fOutputList->Add(fhPrimaryTrackLengthA[sp]); + fOutputList->Add(fhPrimaryTrackLengthTOFA[sp]); + fOutputList->Add(fhPrimaryTrackTimeA[sp]); + fOutputList->Add(fhPrimaryTrackBetaInvA[sp]); + fOutputList->Add(fhPrimaryTrackTimeIPA[sp]); + fOutputList->Add(fhPrimaryTrackBetaInvIPA[sp]); + + fOutputList->Add(fhPurePA[sp]); + fOutputList->Add(fhPurePtA[sp]); + fOutputList->Add(fhPuredEdxA[sp]); + fOutputList->Add(fhPuredEdxIPTPCA[sp]); + fOutputList->Add(fhPureTrackLengthA[sp]); + fOutputList->Add(fhPureTrackLengthTOFA[sp]); + fOutputList->Add(fhPureTrackTimeA[sp]); + fOutputList->Add(fhPureTrackBetaInvA[sp]); + fOutputList->Add(fhPureTrackTimeIPA[sp]); + fOutputList->Add(fhPureTrackBetaInvIPA[sp]); + } + if (makeNSigmaPlots) { + for (int sp1 = 0; sp1 < kIdBfNoOfSpecies; ++sp1) { + for (int sp2 = 0; sp2 < kIdBfNoOfSpecies; ++sp2) { + fOutputList->Add(fhTrueNSigmaTPC[sp1][sp2]); + fOutputList->Add(fhTrueNSigmaTOF[sp1][sp2]); + fOutputList->Add(fhPrimaryNSigmaTPC[sp1][sp2]); + fOutputList->Add(fhPrimaryNSigmaTOF[sp1][sp2]); + } + } } } /* initialize access to the CCDB */ } template - inline MatchRecoGenSpecies IdentifyTrack(TrackObject const& track); + inline MatchRecoGenSpecies identifyTrack(TrackObject const& track); template - int8_t AcceptTrack(TrackObject const& track); + int8_t acceptTrack(TrackObject const& track); template - int8_t AcceptParticle(ParticleObject& particle, MCCollisionObject const& mccollision); + int8_t acceptParticle(ParticleObject& particle, MCCollisionObject const& mccollision); template int8_t selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track); template - inline MatchRecoGenSpecies IdentifyParticle(ParticleObject const& particle); + inline void identifyPIDMismatch(ParticleObject const& particle, MatchRecoGenSpecies const& trkId); + template + inline void identifyRealNSigma(ParticleObject const& particle, std::vector tpcNSigma, std::vector tofNSigma, float tpcInnerParam); + template + inline MatchRecoGenSpecies identifyParticle(ParticleObject const& particle); template void fillTrackHistosBeforeSelection(TrackObject const& track); template void fillTrackHistosAfterSelection(TrackObject const& track, MatchRecoGenSpecies sp); + template + bool isPrimary(ParticleObject const& particle); + template + void fillRealPIDTrackHistosAfter(TrackObject const& track, MatchRecoGenSpecies sp); template void fillParticleHistosBeforeSelection(ParticleObject const& particle, MCCollisionObject const& collision, @@ -964,27 +1465,28 @@ struct IdentifiedBfFilterTracks { void filterTracks(soa::Join const& collisions, passedtracks const& tracks) { + // LOGF(info, "Top of filterTracks"); int naccepted = 0; int ncollaccepted = 0; if (!fullDerivedData) { tracksinfo.reserve(tracks.size()); } - for (auto collision : collisions) { + for (const auto& collision : collisions) { if (collision.collisionaccepted()) { ncollaccepted++; } } - for (auto track : tracks) { + for (const auto& track : tracks) { int8_t pid = -1; if (track.has_collision() && (track.template collision_as>()).collisionaccepted()) { pid = selectTrackAmbiguousCheck(collisions, track); if (!(pid < 0)) { naccepted++; /* update charged multiplicities */ - if (pid % 2 == 0) { + if (pid % twoDenom == trackTypes[0]) { trkMultPos[kIdBfCharged]++; } - if (pid % 2 == 1) { + if (pid % twoDenom == trackTypes[1]) { trkMultNeg[kIdBfCharged]++; } if (fullDerivedData) { @@ -1026,43 +1528,50 @@ struct IdentifiedBfFilterTracks { gentracksinfo.reserve(particles.size()); } - for (auto gencoll : gencollisions) { + for (const auto& gencoll : gencollisions) { if (gencoll.collisionaccepted()) { acceptedcollisions++; } } - for (auto& particle : particles) { - float charge = 0.0; - TParticlePDG* pdgparticle = fPDG->GetParticle(particle.pdgCode()); - if (pdgparticle != nullptr) { - charge = (pdgparticle->Charge() / 3 >= 1) ? 1.0 : ((pdgparticle->Charge() / 3 <= -1) ? -1.0 : 0.0); - } - + for (const auto& particle : particles) { int8_t pid = -1; - - if (charge != 0) { - if (particle.has_mcCollision() && (particle.template mcCollision_as>()).collisionaccepted()) { - auto mccollision = particle.template mcCollision_as>(); - /* before particle selection */ - fillParticleHistosBeforeSelection(particle, mccollision, charge); - - /* track selection */ - pid = AcceptParticle(particle, mccollision); - if (!(pid < 0)) { // if PID isn't negative - acceptedparticles++; + if (particle.isPhysicalPrimary()) { + TParticlePDG* pdgpart = fPDG->GetParticle(particle.pdgCode()); + float charge = 0; + if (pdgpart != nullptr) { + charge = getCharge(pdgpart->Charge()); + // print charge + } + fhTrueCharge->Fill(charge); + if (charge != 0) { + if (particle.has_mcCollision() && (particle.template mcCollision_as>()).collisionaccepted()) { + auto mccollision = particle.template mcCollision_as>(); + /* before particle selection */ + fillParticleHistosBeforeSelection(particle, mccollision, charge); + + /* track selection */ + pid = acceptParticle(particle, mccollision); + if (!(pid < 0)) { // if PID isn't negative + acceptedparticles++; + } + } + } else { + if ((particle.mcCollisionId() == 0) && traceCollId0) { + LOGF(IDENTIFIEDBFFILTERLOGTRACKS, "Particle %d with fractional charge or equal to zero", particle.globalIndex()); } } + } else { if ((particle.mcCollisionId() == 0) && traceCollId0) { - LOGF(IDENTIFIEDBFFILTERLOGTRACKS, "Particle %d with fractional charge or equal to zero", particle.globalIndex()); + LOGF(IDENTIFIEDBFFILTERLOGTRACKS, "Particle %d not Physical Primary", particle.globalIndex()); } } if (!fullDerivedData) { gentracksinfo(pid); } } - LOGF(IDENTIFIEDBFFILTERLOGCOLLISIONS, + LOGF(info, "Processed %d accepted generated collisions out of a total of %d with %d accepted particles out of a " "total of %d", acceptedcollisions, @@ -1083,19 +1592,19 @@ struct IdentifiedBfFilterTracks { } PROCESS_SWITCH(IdentifiedBfFilterTracks, filterRecoWithPIDAmbiguous, "Not stored derived data track filtering with ambiguous tracks check", false) - void filterDetectorLevelWithPID(soa::Join& collisions, IdBfFullTracksPIDDetLevel const& tracks) + void filterDetectorLevelWithPID(soa::Join& collisions, IdBfFullTracksPIDDetLevel const& tracks, aod::McParticles const&) { filterTracks(collisions, tracks); } PROCESS_SWITCH(IdentifiedBfFilterTracks, filterDetectorLevelWithPID, "Not stored derived data detector level track filtering", false) - void filterDetectorLevelWithPIDAmbiguous(soa::Join& collisions, IdBfFullTracksPIDDetLevelAmbiguous const& tracks) + void filterDetectorLevelWithPIDAmbiguous(soa::Join& collisions, IdBfFullTracksPIDDetLevelAmbiguous const& tracks, aod::McParticles const&) { filterTracks(collisions, tracks); } PROCESS_SWITCH(IdentifiedBfFilterTracks, filterDetectorLevelWithPIDAmbiguous, "Not stored derived data detector level track filtering with ambiguous tracks check", false) - void filterRecoWithFullPID(soa::Join& collisions, IdBfFullTracksFullPID const& tracks) + void filterRecoWithFullPID(soa::Join& collisions, IdBfFullTracksFullPID const& tracks, aod::McParticles const&) { filterTracks(collisions, tracks); } @@ -1107,13 +1616,13 @@ struct IdentifiedBfFilterTracks { } PROCESS_SWITCH(IdentifiedBfFilterTracks, filterRecoWithFullPIDAmbiguous, "Not stored derived data track filtering with ambiguous tracks check", false) - void filterDetectorLevelWithFullPID(soa::Join& collisions, IdBfFullTracksFullPIDDetLevel const& tracks) + void filterDetectorLevelWithFullPID(soa::Join& collisions, IdBfFullTracksFullPIDDetLevel const& tracks, aod::McParticles const&) { filterTracks(collisions, tracks); } PROCESS_SWITCH(IdentifiedBfFilterTracks, filterDetectorLevelWithFullPID, "Not stored derived data detector level track filtering", false) - void filterDetectorLevelWithFullPIDAmbiguous(soa::Join& collisions, IdBfFullTracksFullPIDDetLevelAmbiguous const& tracks) + void filterDetectorLevelWithFullPIDAmbiguous(soa::Join& collisions, IdBfFullTracksFullPIDDetLevelAmbiguous const& tracks, aod::McParticles const&) { filterTracks(collisions, tracks); } @@ -1137,7 +1646,7 @@ struct IdentifiedBfFilterTracks { } PROCESS_SWITCH(IdentifiedBfFilterTracks, filterDetectorLevelWithoutPID, "Detector level track filtering without PID information", false) - void filterDetectorLevelWithoutPIDAmbiguous(soa::Join const& collisions, IdBfFullTracksDetLevelAmbiguous const& tracks) + void filterDetectorLevelWithoutPIDAmbiguous(soa::Join const& collisions, IdBfFullTracksDetLevelAmbiguous const& tracks, aod::McParticles const&) { filterTracks(collisions, tracks); } @@ -1147,32 +1656,29 @@ struct IdentifiedBfFilterTracks { { filterParticles(gencollisions, particles); } - PROCESS_SWITCH(IdentifiedBfFilterTracks, filterGenerated, "Generated particles filering", true) + PROCESS_SWITCH(IdentifiedBfFilterTracks, filterGenerated, "Generated particles filtering", true) }; template -inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyParticle(ParticleObject const& particle) +inline MatchRecoGenSpecies IdentifiedBfFilterTracks::identifyParticle(ParticleObject const& particle) { using namespace identifiedbffilter; - constexpr int pdgcodeEl = 11; - constexpr int pdgcodePi = 211; - constexpr int pdgcodeKa = 321; - constexpr int pdgcodePr = 2212; + // LOGF(info, "Top of identifyParticle"); - int pdgcode = abs(particle.pdgCode()); + int pdgcode = std::fabs(particle.pdgCode()); switch (pdgcode) { - case pdgcodeEl: + case kPositron: return kIdBfElectron; break; - case pdgcodePi: + case kPiPlus: return kIdBfPion; break; - case pdgcodeKa: + case kKPlus: return kIdBfKaon; break; - case pdgcodePr: + case kProton: return kIdBfProton; break; @@ -1185,117 +1691,159 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyParticle(ParticleOb } } +template +inline void IdentifiedBfFilterTracks::identifyPIDMismatch(ParticleObject const& particle, MatchRecoGenSpecies const& trkId) +{ + MatchRecoGenSpecies realPID = identifyParticle(particle); + if (!(realPID < 0)) { + if (realPID == trkId) { + fhTruePIDCorrect->Fill(realPID); + } else { + fhTruePIDMismatch->Fill(realPID, trkId); + } + } +} + +template +inline void IdentifiedBfFilterTracks::identifyRealNSigma(ParticleObject const& particle, std::vector tpcNSigma, std::vector tofNSigma, float tpcInnerParam) +{ + + MatchRecoGenSpecies realPID = identifyParticle(particle); + if (!(realPID < 0)) { + fhTrueNSigmaTPC[kIdBfElectron][realPID]->Fill(tpcNSigma[kIdBfElectron], tpcInnerParam); + fhTrueNSigmaTOF[kIdBfElectron][realPID]->Fill(tofNSigma[kIdBfElectron], tpcInnerParam); + fhTrueNSigmaTPC[kIdBfPion][realPID]->Fill(tpcNSigma[kIdBfPion], tpcInnerParam); + fhTrueNSigmaTOF[kIdBfPion][realPID]->Fill(tofNSigma[kIdBfPion], tpcInnerParam); + fhTrueNSigmaTPC[kIdBfKaon][realPID]->Fill(tpcNSigma[kIdBfKaon], tpcInnerParam); + fhTrueNSigmaTOF[kIdBfKaon][realPID]->Fill(tofNSigma[kIdBfKaon], tpcInnerParam); + fhTrueNSigmaTPC[kIdBfProton][realPID]->Fill(tpcNSigma[kIdBfProton], tpcInnerParam); + fhTrueNSigmaTOF[kIdBfProton][realPID]->Fill(tofNSigma[kIdBfProton], tpcInnerParam); + + if (particle.isPhysicalPrimary()) { + fhPrimaryNSigmaTPC[kIdBfElectron][realPID]->Fill(tpcNSigma[kIdBfElectron], tpcInnerParam); + fhPrimaryNSigmaTOF[kIdBfElectron][realPID]->Fill(tofNSigma[kIdBfElectron], tpcInnerParam); + fhPrimaryNSigmaTPC[kIdBfPion][realPID]->Fill(tpcNSigma[kIdBfPion], tpcInnerParam); + fhPrimaryNSigmaTOF[kIdBfPion][realPID]->Fill(tofNSigma[kIdBfPion], tpcInnerParam); + fhPrimaryNSigmaTPC[kIdBfKaon][realPID]->Fill(tpcNSigma[kIdBfKaon], tpcInnerParam); + fhPrimaryNSigmaTOF[kIdBfKaon][realPID]->Fill(tofNSigma[kIdBfKaon], tpcInnerParam); + fhPrimaryNSigmaTPC[kIdBfProton][realPID]->Fill(tpcNSigma[kIdBfProton], tpcInnerParam); + fhPrimaryNSigmaTOF[kIdBfProton][realPID]->Fill(tofNSigma[kIdBfProton], tpcInnerParam); + } + } +} + template void fillNSigmaHistos(TrackObject const& track) { - float actualTPCNSigmaEl = track.tpcNSigmaEl(); - float actualTPCNSigmaPi = track.tpcNSigmaPi(); - float actualTPCNSigmaKa = track.tpcNSigmaKa(); - float actualTPCNSigmaPr = track.tpcNSigmaPr(); + float actualTPCNSigma[kIdBfNoOfSpecies]; + + actualTPCNSigma[kIdBfElectron] = track.tpcNSigmaEl(); + actualTPCNSigma[kIdBfPion] = track.tpcNSigmaPi(); + actualTPCNSigma[kIdBfKaon] = track.tpcNSigmaKa(); + actualTPCNSigma[kIdBfProton] = track.tpcNSigmaPr(); + + float actualTOFNSigma[kIdBfNoOfSpecies]; + + actualTOFNSigma[kIdBfElectron] = track.tofNSigmaEl(); + actualTOFNSigma[kIdBfPion] = track.tofNSigmaPi(); + actualTOFNSigma[kIdBfKaon] = track.tofNSigmaKa(); + actualTOFNSigma[kIdBfProton] = track.tofNSigmaPr(); if (loadfromccdb) { - actualTPCNSigmaEl = actualTPCNSigmaEl - fhNSigmaCorrection[kIdBfElectron]->GetBinContent(fhNSigmaCorrection[kIdBfElectron]->FindBin(track.tpcInnerParam())); - actualTPCNSigmaPi = actualTPCNSigmaPi - fhNSigmaCorrection[kIdBfPion]->GetBinContent(fhNSigmaCorrection[kIdBfPion]->FindBin(track.tpcInnerParam())); - actualTPCNSigmaKa = actualTPCNSigmaKa - fhNSigmaCorrection[kIdBfKaon]->GetBinContent(fhNSigmaCorrection[kIdBfKaon]->FindBin(track.tpcInnerParam())); - actualTPCNSigmaPr = actualTPCNSigmaPr - fhNSigmaCorrection[kIdBfProton]->GetBinContent(fhNSigmaCorrection[kIdBfProton]->FindBin(track.tpcInnerParam())); + actualTPCNSigma[kIdBfElectron] = actualTPCNSigma[kIdBfElectron] - fhNSigmaCorrection[kIdBfElectron]->GetBinContent(fhNSigmaCorrection[kIdBfElectron]->FindBin(track.tpcInnerParam())); + actualTPCNSigma[kIdBfPion] = actualTPCNSigma[kIdBfPion] - fhNSigmaCorrection[kIdBfPion]->GetBinContent(fhNSigmaCorrection[kIdBfPion]->FindBin(track.tpcInnerParam())); + actualTPCNSigma[kIdBfKaon] = actualTPCNSigma[kIdBfKaon] - fhNSigmaCorrection[kIdBfKaon]->GetBinContent(fhNSigmaCorrection[kIdBfKaon]->FindBin(track.tpcInnerParam())); + actualTPCNSigma[kIdBfProton] = actualTPCNSigma[kIdBfProton] - fhNSigmaCorrection[kIdBfProton]->GetBinContent(fhNSigmaCorrection[kIdBfProton]->FindBin(track.tpcInnerParam())); } - fhNSigmaTPC[kIdBfElectron]->Fill(actualTPCNSigmaEl, track.tpcInnerParam()); - fhNSigmaTPC[kIdBfPion]->Fill(actualTPCNSigmaPi, track.tpcInnerParam()); - fhNSigmaTPC[kIdBfKaon]->Fill(actualTPCNSigmaKa, track.tpcInnerParam()); - fhNSigmaTPC[kIdBfProton]->Fill(actualTPCNSigmaPr, track.tpcInnerParam()); + fhNSigmaTPC[kIdBfElectron]->Fill(actualTPCNSigma[kIdBfElectron], track.tpcInnerParam()); + fhNSigmaTPC[kIdBfPion]->Fill(actualTPCNSigma[kIdBfPion], track.tpcInnerParam()); + fhNSigmaTPC[kIdBfKaon]->Fill(actualTPCNSigma[kIdBfKaon], track.tpcInnerParam()); + fhNSigmaTPC[kIdBfProton]->Fill(actualTPCNSigma[kIdBfProton], track.tpcInnerParam()); - fhNSigmaTOF[kIdBfElectron]->Fill(track.tofNSigmaEl(), track.tpcInnerParam()); - fhNSigmaTOF[kIdBfPion]->Fill(track.tofNSigmaPi(), track.tpcInnerParam()); - fhNSigmaTOF[kIdBfKaon]->Fill(track.tofNSigmaKa(), track.tpcInnerParam()); - fhNSigmaTOF[kIdBfProton]->Fill(track.tofNSigmaPr(), track.tpcInnerParam()); + fhNSigmaTOF[kIdBfElectron]->Fill(actualTOFNSigma[kIdBfElectron], track.tpcInnerParam()); + fhNSigmaTOF[kIdBfPion]->Fill(actualTOFNSigma[kIdBfPion], track.tpcInnerParam()); + fhNSigmaTOF[kIdBfKaon]->Fill(actualTOFNSigma[kIdBfKaon], track.tpcInnerParam()); + fhNSigmaTOF[kIdBfProton]->Fill(actualTOFNSigma[kIdBfProton], track.tpcInnerParam()); - fhNSigmaCombo[kIdBfElectron]->Fill(sqrtf(track.tofNSigmaEl() * track.tofNSigmaEl() + actualTPCNSigmaEl * actualTPCNSigmaEl), track.tpcInnerParam()); - fhNSigmaCombo[kIdBfPion]->Fill(sqrtf(track.tofNSigmaPi() * track.tofNSigmaPi() + actualTPCNSigmaPi * actualTPCNSigmaPi), track.tpcInnerParam()); - fhNSigmaCombo[kIdBfKaon]->Fill(sqrtf(track.tofNSigmaKa() * track.tofNSigmaKa() + actualTPCNSigmaKa * actualTPCNSigmaKa), track.tpcInnerParam()); - fhNSigmaCombo[kIdBfProton]->Fill(sqrtf(track.tofNSigmaPr() * track.tofNSigmaPr() + actualTPCNSigmaPr * actualTPCNSigmaPr), track.tpcInnerParam()); + fhNSigmaCombo[kIdBfElectron]->Fill(sqrtf(actualTOFNSigma[kIdBfElectron] * actualTOFNSigma[kIdBfElectron] + actualTPCNSigma[kIdBfElectron] * actualTPCNSigma[kIdBfElectron]), track.tpcInnerParam()); + fhNSigmaCombo[kIdBfPion]->Fill(sqrtf(actualTOFNSigma[kIdBfPion] * actualTOFNSigma[kIdBfPion] + actualTPCNSigma[kIdBfPion] * actualTPCNSigma[kIdBfPion]), track.tpcInnerParam()); + fhNSigmaCombo[kIdBfKaon]->Fill(sqrtf(actualTOFNSigma[kIdBfKaon] * actualTOFNSigma[kIdBfKaon] + actualTPCNSigma[kIdBfKaon] * actualTPCNSigma[kIdBfKaon]), track.tpcInnerParam()); + fhNSigmaCombo[kIdBfProton]->Fill(sqrtf(actualTOFNSigma[kIdBfProton] * actualTOFNSigma[kIdBfProton] + actualTPCNSigma[kIdBfProton] * actualTPCNSigma[kIdBfProton]), track.tpcInnerParam()); } +/// \brief Identifies the passed track with TPC and TOF data +/// \param track the track of interest +/// \return the internal track id, -1 if not accepted + template -inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyTrack(TrackObject const& track) +inline MatchRecoGenSpecies IdentifiedBfFilterTracks::identifyTrack(TrackObject const& track) { using namespace o2::analysis::identifiedbffilter; fillNSigmaHistos(track); - float actualTPCNSigmaEl = track.tpcNSigmaEl(); - float actualTPCNSigmaPi = track.tpcNSigmaPi(); - float actualTPCNSigmaKa = track.tpcNSigmaKa(); - float actualTPCNSigmaPr = track.tpcNSigmaPr(); + std::vector actualTPCNSigma(kIdBfNoOfSpecies, 0.); + + actualTPCNSigma[kIdBfElectron] = track.tpcNSigmaEl(); + actualTPCNSigma[kIdBfPion] = track.tpcNSigmaPi(); + actualTPCNSigma[kIdBfKaon] = track.tpcNSigmaKa(); + actualTPCNSigma[kIdBfProton] = track.tpcNSigmaPr(); + + std::vector actualTOFNSigma(kIdBfNoOfSpecies, 0.); + + actualTOFNSigma[kIdBfElectron] = track.tofNSigmaEl(); + actualTOFNSigma[kIdBfPion] = track.tofNSigmaPi(); + actualTOFNSigma[kIdBfKaon] = track.tofNSigmaKa(); + actualTOFNSigma[kIdBfProton] = track.tofNSigmaPr(); float nsigmas[kIdBfNoOfSpecies]; - if (loadfromccdb) { - actualTPCNSigmaEl = actualTPCNSigmaEl - fhNSigmaCorrection[kIdBfElectron]->GetBinContent(fhNSigmaCorrection[kIdBfElectron]->FindBin(track.tpcInnerParam())); - actualTPCNSigmaPi = actualTPCNSigmaPi - fhNSigmaCorrection[kIdBfPion]->GetBinContent(fhNSigmaCorrection[kIdBfPion]->FindBin(track.tpcInnerParam())); - actualTPCNSigmaKa = actualTPCNSigmaKa - fhNSigmaCorrection[kIdBfKaon]->GetBinContent(fhNSigmaCorrection[kIdBfKaon]->FindBin(track.tpcInnerParam())); - actualTPCNSigmaPr = actualTPCNSigmaPr - fhNSigmaCorrection[kIdBfProton]->GetBinContent(fhNSigmaCorrection[kIdBfProton]->FindBin(track.tpcInnerParam())); + if constexpr (framework::has_type_v) { + if (makeNSigmaPlots) { + identifyRealNSigma(track.template mcParticle_as(), actualTPCNSigma, actualTOFNSigma, track.tpcInnerParam()); + } } - if (track.tpcInnerParam() < tofCut && !reqTOF && !onlyTOF) { + if (loadfromccdb) { + for (int iSp = 0; iSp < kIdBfNoOfSpecies; iSp++) { + actualTPCNSigma[iSp] = actualTPCNSigma[iSp] - fhNSigmaCorrection[iSp]->GetBinContent(fhNSigmaCorrection[iSp]->FindBin(track.tpcInnerParam())); + } + } - nsigmas[kIdBfElectron] = actualTPCNSigmaEl; - nsigmas[kIdBfPion] = actualTPCNSigmaPi; - nsigmas[kIdBfKaon] = actualTPCNSigmaKa; - nsigmas[kIdBfProton] = actualTPCNSigmaPr; + for (int iSp = 0; iSp < kIdBfNoOfSpecies; iSp++) { - } else { - /* introduce require TOF flag */ - if (track.hasTOF() && !onlyTOF) { - nsigmas[kIdBfElectron] = sqrtf(actualTPCNSigmaEl * actualTPCNSigmaEl + track.tofNSigmaEl() * track.tofNSigmaEl()); - nsigmas[kIdBfPion] = sqrtf(actualTPCNSigmaPi * actualTPCNSigmaPi + track.tofNSigmaPi() * track.tofNSigmaPi()); - nsigmas[kIdBfKaon] = sqrtf(actualTPCNSigmaKa * actualTPCNSigmaKa + track.tofNSigmaKa() * track.tofNSigmaKa()); - nsigmas[kIdBfProton] = sqrtf(actualTPCNSigmaPr * actualTPCNSigmaPr + track.tofNSigmaPr() * track.tofNSigmaPr()); - - } else if (!reqTOF || !onlyTOF) { - nsigmas[kIdBfElectron] = actualTPCNSigmaEl; - nsigmas[kIdBfPion] = actualTPCNSigmaPi; - nsigmas[kIdBfKaon] = actualTPCNSigmaKa; - nsigmas[kIdBfProton] = actualTPCNSigmaPr; - - } else if (track.hasTOF() && onlyTOF) { - nsigmas[kIdBfElectron] = track.tofNSigmaEl(); - nsigmas[kIdBfPion] = track.tofNSigmaPi(); - nsigmas[kIdBfKaon] = track.tofNSigmaKa(); - nsigmas[kIdBfProton] = track.tofNSigmaPr(); + if (track.tpcInnerParam() < tofCut[iSp] && track.tpcInnerParam() < tpcCut[iSp] && !onlyTOF) { + nsigmas[iSp] = actualTPCNSigma[iSp]; + } else if (track.tpcInnerParam() > tofCut[iSp] && track.tpcInnerParam() < tpcCut[iSp] && !onlyTOF && track.hasTOF()) { + nsigmas[iSp] = sqrtf(actualTPCNSigma[iSp] * actualTPCNSigma[iSp] + actualTOFNSigma[iSp] * actualTOFNSigma[iSp]); + } else if (track.hasTOF() && ((track.tpcInnerParam() > tofCut[iSp] && track.tpcInnerParam() > tpcCut[iSp]) || onlyTOF)) { + nsigmas[iSp] = actualTOFNSigma[iSp]; } else { return kWrongSpecies; } } - if (!pidEl) { - nsigmas[kIdBfElectron] = 999.0f; - } - if (!pidPi) { - nsigmas[kIdBfPion] = 999.0f; - } - if (!pidKa) { - nsigmas[kIdBfKaon] = 999.0f; - } - if (!pidPr) { - nsigmas[kIdBfProton] = 999.0f; - } - - float min_nsigma = 999.0f; - MatchRecoGenSpecies sp_min_nsigma = kWrongSpecies; + float minNSigma = 999.0f; + MatchRecoGenSpecies spMinNSigma = kWrongSpecies; for (int sp = 0; sp < kIdBfNoOfSpecies; ++sp) { - if (abs(nsigmas[sp]) < abs(min_nsigma)) { // Check if species nsigma is less than current nsigma - min_nsigma = nsigmas[sp]; // If yes, set species nsigma to current nsigma - sp_min_nsigma = MatchRecoGenSpecies(sp); // set current species sp number to current sp + if (doPID[sp]) { // Check if we're IDing PID for this species + if (std::fabs(nsigmas[sp]) < std::fabs(minNSigma)) { // Check if species nsigma is less than current nsigma + minNSigma = nsigmas[sp]; // If yes, set species nsigma to current nsigma + spMinNSigma = MatchRecoGenSpecies(sp); // set current species sp number to current sp + } } } bool doublematch = false; MatchRecoGenSpecies spDouble = kWrongSpecies; - if (min_nsigma < maxPIDSigma && min_nsigma > minPIDSigma) { // Check that current nsigma is in accpetance range + // LOGF(info,"Looking at accept range"); + if (minNSigma < acceptRange[spMinNSigma][1] && minNSigma > acceptRange[spMinNSigma][0]) { // Check that current nsigma is in accpetance range + // LOGF(info,"In accept Range"); for (int sp = 0; (sp < kIdBfNoOfSpecies) && !doublematch; ++sp) { // iterate over all species while there's no double match and we're in the list - if (sp != sp_min_nsigma) { // for species not current minimum nsigma species - if (nsigmas[sp] < maxRejectSigma && nsigmas[sp] > minRejectSigma) { // If secondary species is in rejection range + if (sp != spMinNSigma) { // for species not current minimum nsigma species + // LOGF(info, "looking at Reject Range"); + if (std::fabs(nsigmas[sp]) < rejectRange[spMinNSigma][sp]) { // If secondary species is in rejection range doublematch = true; // Set double match true spDouble = MatchRecoGenSpecies(sp); } @@ -1305,23 +1853,23 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyTrack(TrackObject c fhWrongTrackID->Fill(track.p()); fhdEdxA[kIdBfNoOfSpecies]->Fill(track.p(), track.tpcSignal()); fhdEdxIPTPCA[kIdBfNoOfSpecies]->Fill(track.tpcInnerParam(), track.tpcSignal()); - fhDoublePID->Fill(sp_min_nsigma, spDouble); + fhTrackLengthA[kIdBfNoOfSpecies]->Fill(track.length()); + fhTrackTimeA[kIdBfNoOfSpecies]->Fill(track.p(), (track.trackTime())); + fhTrackTimeIPA[kIdBfNoOfSpecies]->Fill(track.tpcInnerParam(), (track.trackTime())); + + if constexpr (framework::has_type_v) { + fhTrackBetaInvA[kIdBfNoOfSpecies]->Fill(track.p(), 1 / track.beta()); + fhTrackBetaInvIPA[kIdBfNoOfSpecies]->Fill(track.tpcInnerParam(), 1 / track.beta()); + } + fhDoublePID->Fill(spMinNSigma, spDouble); return kWrongSpecies; // Return wrong species value } else { - if (sp_min_nsigma == 0) { - fhNSigmaTPC_IdTrks[sp_min_nsigma]->Fill(actualTPCNSigmaEl, track.tpcInnerParam()); - } - if (sp_min_nsigma == 1) { - fhNSigmaTPC_IdTrks[sp_min_nsigma]->Fill(actualTPCNSigmaPi, track.tpcInnerParam()); - } - if (sp_min_nsigma == 2) { - fhNSigmaTPC_IdTrks[sp_min_nsigma]->Fill(actualTPCNSigmaKa, track.tpcInnerParam()); - } - if (sp_min_nsigma == 3) { - fhNSigmaTPC_IdTrks[sp_min_nsigma]->Fill(actualTPCNSigmaPr, track.tpcInnerParam()); - } + fhNSigmaTPCIdTrks[spMinNSigma]->Fill(actualTPCNSigma[spMinNSigma], track.tpcInnerParam()); - return sp_min_nsigma; + if constexpr (framework::has_type_v) { + identifyPIDMismatch(track.template mcParticle_as(), spMinNSigma); + } + return spMinNSigma; } } else { return kWrongSpecies; @@ -1331,38 +1879,38 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyTrack(TrackObject c /// \brief Accepts or not the passed track /// \param track the track of interest /// \return the internal track id, -1 if not accepted -/// TODO: the PID implementation -/// For the time being we keep the convention -/// - positive track pid even -/// - negative track pid odd + template -inline int8_t IdentifiedBfFilterTracks::AcceptTrack(TrackObject const& track) +inline int8_t IdentifiedBfFilterTracks::acceptTrack(TrackObject const& track) { + // LOGF(info,"Top of acceptTrack"); fillTrackHistosBeforeSelection(track); // ) { if (track.mcParticleId() < 0) { + // LOGF(info,"No matching MC particle"); return -1; } } if (matchTrackType(track)) { + // LOGF(info, "Track type match"); if (ptlow < track.pt() && track.pt() < ptup && etalow < track.eta() && track.eta() < etaup) { + // LOGF(info, "Track Accepted"); fillTrackHistosAfterSelection(track, kIdBfCharged); MatchRecoGenSpecies sp = kWrongSpecies; - if (recoIdMethod == 0) { + if (recoIdMethod == recoIdMethods[0]) { sp = kIdBfCharged; - } else if (recoIdMethod == 1) { - + } else if (recoIdMethod == recoIdMethods[1]) { if constexpr (framework::has_type_v || framework::has_type_v) { - sp = IdentifyTrack(track); + sp = identifyTrack(track); } else { LOGF(fatal, "Track identification required but PID information not present"); } - } else if (recoIdMethod == 2) { + } else if (recoIdMethod == recoIdMethods[2]) { if constexpr (framework::has_type_v) { - sp = IdentifyParticle(track.template mcParticle_as()); + sp = identifyParticle(track.template mcParticle_as()); } else { LOGF(fatal, "Track identification required from MC particle but MC information not present"); } @@ -1390,52 +1938,67 @@ inline int8_t IdentifiedBfFilterTracks::AcceptTrack(TrackObject const& track) /// \param track the particle of interest /// \return `true` if the particle is accepted, `false` otherwise template -inline int8_t IdentifiedBfFilterTracks::AcceptParticle(ParticleObject& particle, MCCollisionObject const& mccollision) +inline int8_t IdentifiedBfFilterTracks::acceptParticle(ParticleObject& particle, MCCollisionObject const& mccollision) { /* overall momentum cut */ if (!(overallminp < particle.p())) { return kWrongSpecies; } + TParticlePDG* pdgpart = fPDG->GetParticle(particle.pdgCode()); + float charge = 0; + if (pdgpart != nullptr) { + charge = getCharge(pdgpart->Charge()); + } + if ((particle.flags() & 0x8) != 0x8) { + if (particle.isPhysicalPrimary() && std::fabs(charge) > 0.0) { + if ((particle.mcCollisionId() == 0) && traceCollId0) { + LOGF(info, "Particle %d passed isPhysicalPrimary", particle.globalIndex()); + } - float charge = getCharge(particle); - - if (particle.isPhysicalPrimary()) { - if ((particle.mcCollisionId() == 0) && traceCollId0) { - LOGF(info, "Particle %d passed isPhysicalPrimary", particle.globalIndex()); - } + if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) { + MatchRecoGenSpecies sp = kWrongSpecies; + if (recoIdMethod == recoIdMethods[0]) { + sp = kIdBfCharged; + } + if (recoIdMethod == recoIdMethods[1] || recoIdMethod == recoIdMethods[2]) { + sp = identifyParticle(particle); + } - if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) { - MatchRecoGenSpecies sp = IdentifyParticle(particle); - if (sp != kWrongSpecies) { - if (sp != kIdBfCharged) { - /* fill the charged particle histograms */ - fillParticleHistosAfterSelection(particle, mccollision, charge, kIdBfCharged); - /* update charged multiplicities */ + if (sp != kWrongSpecies) { + if (sp != kIdBfCharged) { + /* fill the charged particle histograms */ + fillParticleHistosAfterSelection(particle, mccollision, charge, kIdBfCharged); + /* update charged multiplicities */ + if (charge == 1) { + partMultPos[kIdBfCharged]++; + } else if (charge == -1) { + partMultNeg[kIdBfCharged]++; + } + } + /* fill the species histograms */ + fillParticleHistosAfterSelection(particle, mccollision, charge, sp); + /* update species multiplicities */ if (charge == 1) { - partMultPos[kIdBfCharged]++; + partMultPos[sp]++; } else if (charge == -1) { - partMultNeg[kIdBfCharged]++; + partMultNeg[sp]++; } } - /* fill the species histograms */ - fillParticleHistosAfterSelection(particle, mccollision, charge, sp); - /* update species multiplicities */ if (charge == 1) { - partMultPos[sp]++; + return speciesChargeValue1[sp]; + } else if (charge == -1) { - partMultNeg[sp]++; + return speciesChargeValue1[sp] + 1; } } - if (charge == 1) { - return speciesChargeValue1[sp]; - - } else if (charge == -1) { - return speciesChargeValue1[sp] + 1; + } else { + if ((particle.mcCollisionId() == 0) && traceCollId0) { + LOGF(info, "Particle %d NOT passed isPhysicalPrimary", particle.globalIndex()); } } } else { if ((particle.mcCollisionId() == 0) && traceCollId0) { - LOGF(info, "Particle %d NOT passed isPhysicalPrimary", particle.globalIndex()); + LOGF(info, "Particle %d Out of Bunch Pileup", particle.globalIndex()); } } return kWrongSpecies; @@ -1444,6 +2007,7 @@ inline int8_t IdentifiedBfFilterTracks::AcceptParticle(ParticleObject& particle, template int8_t IdentifiedBfFilterTracks::selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track) { + // LOGF(info,"Top of AmbiguousCheck"); bool ambiguoustrack = false; int tracktype = 0; /* no ambiguous */ std::vector zvertexes{}; @@ -1480,7 +2044,7 @@ int8_t IdentifiedBfFilterTracks::selectTrackAmbiguousCheck(CollisionObjects cons fhAmbiguousTrackType->Fill(tracktype, multiplicityclass); fhAmbiguousTrackPt->Fill(track.pt(), multiplicityclass); fhAmbiguityDegree->Fill(zvertexes.size(), multiplicityclass); - if (tracktype == 2) { + if (tracktype == trackTypes[2]) { fhCompatibleCollisionsZVtxRms->Fill(-computeRMS(zvertexes), multiplicityclass); } else { fhCompatibleCollisionsZVtxRms->Fill(computeRMS(zvertexes), multiplicityclass); @@ -1491,13 +2055,21 @@ int8_t IdentifiedBfFilterTracks::selectTrackAmbiguousCheck(CollisionObjects cons /* feedback of no ambiguous tracks only if checks required */ fhAmbiguousTrackType->Fill(tracktype, multiplicityclass); } - return AcceptTrack(track); + return acceptTrack(track); } } template void IdentifiedBfFilterTracks::fillTrackHistosBeforeSelection(TrackObject const& track) { + fhXYB->Fill(track.x(), track.y()); + fhYZB->Fill(track.y(), track.z()); + fhNClustersB->Fill(track.tpcNClsFound()); + fhPhiYB->Fill(track.phi(), track.eta()); + fhPtYB->Fill(track.pt(), track.eta()); + fhChi2B->Fill(track.tpcChi2NCl()); + fhITSNclB->Fill(track.itsNCls()); + fhPB->Fill(track.p()); fhPtB->Fill(track.pt()); fhEtaB->Fill(track.eta()); @@ -1511,17 +2083,110 @@ void IdentifiedBfFilterTracks::fillTrackHistosBeforeSelection(TrackObject const& } fhDCAxyB->Fill(track.dcaXY()); fhDCAzB->Fill(track.dcaZ()); + fhDCAxyzB->Fill(track.dcaXY(), track.dcaZ()); + + if constexpr (framework::has_type_v) { + + if (isPrimary(track.template mcParticle_as())) { + fhPrimaryPB->Fill(track.p()); + fhPrimaryPtB->Fill(track.pt()); + fhPrimarydEdxB->Fill(track.p(), track.tpcSignal()); + fhPrimarydEdxIPTPCB->Fill(track.tpcInnerParam(), track.tpcSignal()); + fhPrimaryTrackLengthB->Fill(track.length()); + if (track.hasTOF() && track.p() > tofCut[0]) { + fhPrimaryTrackLengthTOFB->Fill(track.length()); + fhPrimaryTrackTimeB->Fill(track.p(), (track.trackTime())); + fhPrimaryTrackTimeIPB->Fill(track.tpcInnerParam(), (track.trackTime())); + + if constexpr (framework::has_type_v) { + fhPrimaryTrackBetaInvB->Fill(track.p(), 1 / track.beta()); + fhPrimaryTrackBetaInvIPB->Fill(track.tpcInnerParam(), 1 / track.beta()); + } + } + } + } +} +template +bool IdentifiedBfFilterTracks::isPrimary(ParticleObject const& particle) +{ + return particle.isPhysicalPrimary(); } +template +void IdentifiedBfFilterTracks::fillRealPIDTrackHistosAfter(TrackObject const& track, MatchRecoGenSpecies sp) +{ + + if constexpr (framework::has_type_v) { + MatchRecoGenSpecies realPID = identifyParticle(track.template mcParticle_as()); + if (!(realPID < 0)) { + fhTruedEdxA[realPID]->Fill(track.p(), track.tpcSignal()); + fhTruedEdxIPTPCA[realPID]->Fill(track.tpcInnerParam(), track.tpcSignal()); + fhTrueTrackLengthA[realPID]->Fill(track.length()); + if (track.hasTOF() && track.p() > tofCut[realPID]) { + fhTrueTrackLengthTOFA[realPID]->Fill(track.length()); + fhTrueTrackTimeA[realPID]->Fill(track.p(), (track.trackTime())); + fhTrueTrackTimeIPA[realPID]->Fill(track.tpcInnerParam(), (track.trackTime())); + if constexpr (framework::has_type_v) { + fhTrueTrackBetaInvA[realPID]->Fill(track.p(), 1 / track.beta()); + fhTrueTrackBetaInvIPA[realPID]->Fill(track.tpcInnerParam(), 1 / track.beta()); + } + } + } + + if (isPrimary(track.template mcParticle_as())) { + fhPrimaryPA[sp]->Fill(track.p()); + fhPrimaryPtA[sp]->Fill(track.pt()); + fhPrimarydEdxA[sp]->Fill(track.p(), track.tpcSignal()); + fhPrimarydEdxIPTPCA[sp]->Fill(track.tpcInnerParam(), track.tpcSignal()); + fhPrimaryTrackLengthA[sp]->Fill(track.length()); + if (track.hasTOF() && track.p() > tofCut[sp]) { + fhPrimaryTrackLengthTOFA[sp]->Fill(track.length()); + fhPrimaryTrackTimeA[sp]->Fill(track.p(), (track.trackTime())); + fhPrimaryTrackTimeIPA[sp]->Fill(track.tpcInnerParam(), (track.trackTime())); + + if constexpr (framework::has_type_v) { + fhPrimaryTrackBetaInvA[sp]->Fill(track.p(), 1 / track.beta()); + fhPrimaryTrackBetaInvIPA[sp]->Fill(track.tpcInnerParam(), 1 / track.beta()); + } + } + if (sp == realPID) { + fhPurePA[realPID]->Fill(track.p()); + fhPurePtA[realPID]->Fill(track.pt()); + fhPuredEdxA[realPID]->Fill(track.p(), track.tpcSignal()); + fhPuredEdxIPTPCA[realPID]->Fill(track.tpcInnerParam(), track.tpcSignal()); + fhPureTrackLengthA[realPID]->Fill(track.length()); + if (track.hasTOF() && track.p() > tofCut[realPID]) { + fhPureTrackLengthTOFA[realPID]->Fill(track.length()); + fhPureTrackTimeA[realPID]->Fill(track.p(), (track.trackTime())); + fhPureTrackTimeIPA[realPID]->Fill(track.tpcInnerParam(), (track.trackTime())); + + if constexpr (framework::has_type_v) { + fhPureTrackBetaInvA[realPID]->Fill(track.p(), 1 / track.beta()); + fhPureTrackBetaInvIPA[realPID]->Fill(track.tpcInnerParam(), 1 / track.beta()); + } + } + } + } + } +} template void IdentifiedBfFilterTracks::fillTrackHistosAfterSelection(TrackObject const& track, MatchRecoGenSpecies sp) { /* the charged species should have been called first so avoid double counting */ + // LOGF(info,"Top of AfterSelection"); if (sp == kIdBfCharged) { fhEtaA->Fill(track.eta()); fhPhiA->Fill(track.phi()); + fhXYA->Fill(track.x(), track.y()); + fhYZA->Fill(track.y(), track.z()); + fhNClustersA->Fill(track.tpcNClsFound()); + fhPhiYA->Fill(track.phi(), track.eta()); + fhPtYA->Fill(track.pt(), track.eta()); + fhChi2A->Fill(track.tpcChi2NCl()); + fhITSNclA->Fill(track.itsNCls()); fhDCAxyA->Fill(track.dcaXY()); fhDCAzA->Fill(track.dcaZ()); + fhDCAxyzA->Fill(track.dcaXY(), track.dcaZ()); if (track.dcaXY() < 1.0) { fhFineDCAxyA->Fill(track.dcaXY()); @@ -1529,22 +2194,39 @@ void IdentifiedBfFilterTracks::fillTrackHistosAfterSelection(TrackObject const& if (track.dcaZ() < 1.0) { fhFineDCAzA->Fill(track.dcaZ()); } - } else { - fhPA[sp]->Fill(track.p()); - fhPtA[sp]->Fill(track.pt()); - fhdEdxA[sp]->Fill(track.p(), track.tpcSignal()); - fhdEdxIPTPCA[sp]->Fill(track.tpcInnerParam(), track.tpcSignal()); - if (track.sign() > 0) { - fhPtPosA[sp]->Fill(track.pt()); - } else { - fhPtNegA[sp]->Fill(track.pt()); + } + fhPA[sp]->Fill(track.p()); + fhPtA[sp]->Fill(track.pt()); + fhdEdxA[sp]->Fill(track.p(), track.tpcSignal()); + fhdEdxIPTPCA[sp]->Fill(track.tpcInnerParam(), track.tpcSignal()); + fhTrackLengthA[sp]->Fill(track.length()); + if (track.hasTOF() && track.p() > tofCut[sp]) { + fhTrackLengthTOFA[sp]->Fill(track.length()); + fhTrackTimeA[sp]->Fill(track.p(), (track.trackTime())); + fhTrackTimeIPA[sp]->Fill(track.tpcInnerParam(), (track.trackTime())); + + if constexpr (framework::has_type_v) { + fhTrackBetaInvA[sp]->Fill(track.p(), 1 / track.beta()); + fhTrackBetaInvIPA[sp]->Fill(track.tpcInnerParam(), 1 / track.beta()); } } + if (track.sign() > 0) { + fhPtPosA[sp]->Fill(track.pt()); + fhPtEtaPosA[sp]->Fill(track.pt(), track.eta()); + } else { + fhPtNegA[sp]->Fill(track.pt()); + fhPtEtaNegA[sp]->Fill(track.pt(), track.eta()); + } + if ((fDataType != kData) && (fDataType != kDataNoEvtSel)) { + fillRealPIDTrackHistosAfter(track, sp); + } } template void IdentifiedBfFilterTracks::fillParticleHistosBeforeSelection(ParticleObject const& particle, MCCollisionObject const& collision, float charge) { + fhTruePhiYB->Fill(particle.phi(), particle.eta()); + fhTruePtYB->Fill(particle.pt(), particle.eta()); fhTruePB->Fill(particle.p()); fhTruePtB->Fill(particle.pt()); fhTrueEtaB->Fill(particle.eta()); @@ -1555,14 +2237,17 @@ void IdentifiedBfFilterTracks::fillParticleHistosBeforeSelection(ParticleObject fhTruePtNegB->Fill(particle.pt()); } - float dcaxy = TMath::Sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + - (particle.vy() - collision.posY()) * (particle.vy() - collision.posY())); + float dcaxy = std::sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + + (particle.vy() - collision.posY()) * (particle.vy() - collision.posY())); if (traceDCAOutliers.mDoIt && (traceDCAOutliers.mLowValue < dcaxy) && (dcaxy < traceDCAOutliers.mUpValue)) { fhTrueDCAxyBid->Fill(TString::Format("%d", particle.pdgCode()).Data(), 1.0); } - fhTrueDCAxyB->Fill(TMath::Sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + - (particle.vy() - collision.posY()) * (particle.vy() - collision.posY()))); + fhTrueDCAxyB->Fill(std::sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + + (particle.vy() - collision.posY()) * (particle.vy() - collision.posY()))); + fhTrueDCAxyzB->Fill(std::sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + + (particle.vy() - collision.posY()) * (particle.vy() - collision.posY())), + (particle.vz() - collision.posZ())); fhTrueDCAzB->Fill((particle.vz() - collision.posZ())); } @@ -1571,36 +2256,41 @@ void IdentifiedBfFilterTracks::fillParticleHistosAfterSelection(ParticleObject c { /* the charged species should have been called first so avoid double counting */ if (sp == kIdBfCharged) { + fhTruePhiYA->Fill(particle.phi(), particle.eta()); + fhTruePtYA->Fill(particle.pt(), particle.eta()); fhTrueEtaA->Fill(particle.eta()); fhTruePhiA->Fill(particle.phi()); - float dcaxy = TMath::Sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + - (particle.vy() - collision.posY()) * (particle.vy() - collision.posY())); + float dcaxy = std::sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + + (particle.vy() - collision.posY()) * (particle.vy() - collision.posY())); if (traceDCAOutliers.mDoIt && (traceDCAOutliers.mLowValue < dcaxy) && (dcaxy < traceDCAOutliers.mUpValue)) { LOGF(info, "DCAxy outlier: Particle with index %d and pdg code %d assigned to MC collision %d, pT: %f, phi: %f, eta: %f", particle.globalIndex(), particle.pdgCode(), particle.mcCollisionId(), particle.pt(), particle.phi(), particle.eta()); LOGF(info, " With status %d and flags %0X", particle.statusCode(), particle.flags()); } - fhTrueDCAxyA->Fill(TMath::Sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + - (particle.vy() - collision.posY()) * (particle.vy() - collision.posY()))); + fhTrueDCAxyA->Fill(std::sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + + (particle.vy() - collision.posY()) * (particle.vy() - collision.posY()))); fhTrueDCAzA->Fill((particle.vz() - collision.posZ())); + fhTrueDCAxyzA->Fill(std::sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + + (particle.vy() - collision.posY()) * (particle.vy() - collision.posY())), + (particle.vz() - collision.posZ())); + } + fhTruePA[sp]->Fill(particle.p()); + fhTruePtA[sp]->Fill(particle.pt()); + if (charge > 0) { + fhTruePtPosA[sp]->Fill(particle.pt()); + fhTruePtEtaPosA[sp]->Fill(particle.pt(), particle.eta()); } else { - fhTruePA[sp]->Fill(particle.p()); - fhTruePtA[sp]->Fill(particle.pt()); - if (charge > 0) { - fhTruePtPosA[sp]->Fill(particle.pt()); - } else { - fhTruePtNegA[sp]->Fill(particle.pt()); - } + fhTruePtNegA[sp]->Fill(particle.pt()); + fhTruePtEtaNegA[sp]->Fill(particle.pt(), particle.eta()); } } - WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{adaptAnalysisTask(cfgc, SetDefaultProcesses{ {{"processWithoutCent", true}, - {"processWithoutCentMC", true}}}), + {"processWithoutCentGeneratorLevel", true}}}), adaptAnalysisTask(cfgc)}; return workflow; } diff --git a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h index 6897cac98b4..7335b36c421 100644 --- a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h +++ b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h @@ -9,6 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file identifiedBfFilter.h +/// \brief Filters collisions and tracks according to selection criteria +/// \author bghanley1995@gmail.com + #ifndef PWGCF_TWOPARTICLECORRELATIONS_TABLEPRODUCER_IDENTIFIEDBFFILTER_H_ #define PWGCF_TWOPARTICLECORRELATIONS_TABLEPRODUCER_IDENTIFIEDBFFILTER_H_ @@ -19,6 +23,8 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" +#include "Framework/runDataProcessing.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" @@ -26,9 +32,10 @@ #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" #include "PWGCF/Core/AnalysisConfigurableCuts.h" -#include +#include "MathUtils/Utils.h" namespace o2 + { namespace aod { @@ -79,9 +86,9 @@ enum SpeciesPairMatch { kIdBfProtonProton ///< Proton-Proton }; -const char* speciesName[kIdBfNoOfSpecies] = {"e", "pi", "ka", "p"}; +const char* speciesName[kIdBfNoOfSpecies + 1] = {"e", "pi", "ka", "p", "ha"}; -const char* speciesTitle[kIdBfNoOfSpecies] = {"e", "#pi", "K", "p"}; +const char* speciesTitle[kIdBfNoOfSpecies + 1] = {"e", "#pi", "K", "p", "ha"}; const int speciesChargeValue1[kIdBfNoOfSpecies] = { 0, //< electron @@ -153,6 +160,13 @@ int phibins = 72; float philow = 0.0; float phiup = constants::math::TwoPI; +std::vector> acceptRange; +std::vector> rejectRange; + +std::vector doPID; +std::vector tofCut; +std::vector tpcCut; + int tracktype = 1; std::vector trackFilters = {}; @@ -231,8 +245,6 @@ float particleMaxDCAxy = 999.9f; float particleMaxDCAZ = 999.9f; bool traceCollId0 = false; -TDatabasePDG* fPDG = nullptr; - inline TriggerSelectionType getTriggerSelection(std::string const& triggstr) { if (triggstr.empty() || triggstr == "MB") { @@ -585,7 +597,9 @@ template inline bool centralitySelectionMult(CollisionObject collision, float& centmult) { float mult = getCentMultPercentile(collision); - if (mult < 100 && 0 < mult) { + int maxMult = 100; + int minMult = 0; + if (mult < maxMult && minMult < mult) { centmult = mult; return true; } @@ -667,7 +681,9 @@ inline bool centralitySelection inline bool centralitySelection(aod::McCollision const&, float& centmult) { - if (centmult < 100 && 0 < centmult) { + int maxMult = 100; + int minMult = 0; + if (centmult < maxMult && minMult < centmult) { return true; } else { return false; @@ -679,7 +695,7 @@ inline bool centralitySelection(aod::McCollision const&, float ////////////////////////////////////////////////////////////////////////////////// template -inline bool IsEvtSelected(CollisionObject const& collision, float& centormult) +inline bool isEvtSelected(CollisionObject const& collision, float& centormult) { bool trigsel = triggerSelection(collision); @@ -690,6 +706,7 @@ inline bool IsEvtSelected(CollisionObject const& collision, float& centormult) } bool centmultsel = centralitySelection(collision, centormult); + return trigsel && zvtxsel && centmultsel; } @@ -703,7 +720,7 @@ inline bool matchTrackType(TrackObject const& track) if (useOwnTrackSelection) { return ownTrackSelection.IsSelected(track); } else { - for (auto filter : trackFilters) { + for (const auto& filter : trackFilters) { if (filter->IsSelected(track)) { if (dca2Dcut) { if (track.dcaXY() * track.dcaXY() / maxDCAxy / maxDCAxy + track.dcaZ() * track.dcaZ() / maxDCAz / maxDCAz > 1) { @@ -731,7 +748,7 @@ inline bool matchTrackType(TrackObject const& track) template void exploreMothers(ParticleObject& particle, MCCollisionObject& collision) { - for (auto& m : particle.template mothers_as()) { + for (const auto& m : particle.template mothers_as()) { LOGF(info, " mother index: %d", m.globalIndex()); LOGF(info, " Tracking back mother"); LOGF(info, " assigned collision Id: %d, looping on collision Id: %d", m.mcCollisionId(), collision.globalIndex()); @@ -742,14 +759,12 @@ void exploreMothers(ParticleObject& particle, MCCollisionObject& collision) } } -template -inline float getCharge(ParticleObject& particle) +inline float getCharge(float pdgCharge) { - float charge = 0.0; - TParticlePDG* pdgparticle = fPDG->GetParticle(particle.pdgCode()); - if (pdgparticle != nullptr) { - charge = (pdgparticle->Charge() / 3 >= 1) ? 1.0 : ((pdgparticle->Charge() / 3 <= -1) ? -1.0 : 0); - } + int posCharge = 1; + int negCharge = -1; + int denom = 3; + float charge = (pdgCharge / denom >= posCharge) ? 1.0 : ((pdgCharge / denom <= negCharge) ? -1.0 : 0); return charge; } diff --git a/PWGCF/TwoParticleCorrelations/Tasks/CMakeLists.txt b/PWGCF/TwoParticleCorrelations/Tasks/CMakeLists.txt index 547403be12d..0b61a13fbb5 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/CMakeLists.txt +++ b/PWGCF/TwoParticleCorrelations/Tasks/CMakeLists.txt @@ -38,13 +38,13 @@ o2physics_add_dpl_workflow(dpt-dpt-efficiency-and-qc PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(twopartcorr-per-run-qc - SOURCES perRunQc.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore O2Physics::AnalysisCCDB +o2physics_add_dpl_workflow(dpt-dpt-per-run-qc + SOURCES dptDptPerRunQc.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore O2Physics::AnalysisCCDB O2::DataFormatsITSMFT COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(twopartcorr-per-run-extraqc - SOURCES perRunExtraQc.cxx +o2physics_add_dpl_workflow(dpt-dpt-per-run-extra-qc + SOURCES dptDptPerRunExtraQc.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) @@ -58,6 +58,17 @@ o2physics_add_dpl_workflow(neutron-proton-corr-zdc PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(di-hadron-cor + SOURCES diHadronCor.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore O2Physics::AnalysisCCDB O2Physics::GFWCore + COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(pid-di-hadron + SOURCES pidDiHadron.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore O2Physics::AnalysisCCDB O2Physics::GFWCore + COMPONENT_NAME Analysis) - +o2physics_add_dpl_workflow(longrange-correlation + SOURCES longrangeCorrelation.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore + COMPONENT_NAME Analysis) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/corrSparse.cxx b/PWGCF/TwoParticleCorrelations/Tasks/corrSparse.cxx index e61155d2a48..489c99bdbff 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/corrSparse.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/corrSparse.cxx @@ -11,161 +11,371 @@ /// \file corrSparse.cxx /// \brief Provides a sparse with usefull two particle correlation info -/// \author Thor Jensen (djt288@alumni.ku.dk) +/// \author Thor Jensen (thor.kjaersgaard.jensen@cern.ch) +#include +#include "TRandom3.h" #include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" +#include "Framework/StepTHn.h" #include "Framework/HistogramRegistry.h" #include "Framework/RunningWorkflowInfo.h" #include "CommonConstants/MathConstants.h" +#include "Common/Core/RecoDecay.h" + #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/Centrality.h" +#include "PWGCF/DataModel/CorrelationsDerived.h" +#include "Common/DataModel/CollisionAssociationTables.h" #include "PWGCF/Core/CorrelationContainer.h" #include "PWGCF/Core/PairCuts.h" -#include "Common/Core/RecoDecay.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +namespace o2::aod +{ +namespace corrsparse +{ +DECLARE_SOA_COLUMN(Multiplicity, multiplicity, int); +} +DECLARE_SOA_TABLE(Multiplicity, "AOD", "MULTIPLICITY", + corrsparse::Multiplicity); + +} // namespace o2::aod + +// define the filtered collisions and tracks +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; struct CorrSparse { - Configurable cfgZVtxCut = {"cfgZVtxCut", 10.0, "Vertex z cut. Default 10 cm"}; - Configurable cfgPtCutMin = {"cfgPtCutMin", 0.2, "Minimum accepted track pT. Default 0.2 GeV"}; - Configurable cfgPtCutMax = {"cfgPtCutMax", 5.0, "Maximum accepted track pT. Default 5.0 GeV"}; - Configurable cfgEtaCut = {"cfgEtaCut", 0.8, "Eta cut. Default 0.8"}; - ConfigurableAxis axisVertex{"axisVertex", {7, -7, 7}, "vertex axis for histograms"}; + Service ccdb; + + O2_DEFINE_CONFIGURABLE(cfgZVtxCut, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgPtCutMin, float, 0.2f, "minimum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgPtCutMax, float, 10.0f, "maximum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgEtaCut, float, 0.8f, "Eta cut") + O2_DEFINE_CONFIGURABLE(cfgMinMixEventNum, int, 5, "Minimum number of events to mix") + O2_DEFINE_CONFIGURABLE(cfgMinMult, int, 0, "Minimum multiplicity for collision") + O2_DEFINE_CONFIGURABLE(cfgMaxMult, int, 10, "Maximum multiplicity for collision") + O2_DEFINE_CONFIGURABLE(cfgMergingCut, float, 0.02, "Merging cut on track merge") + O2_DEFINE_CONFIGURABLE(cfgApplyTwoTrackEfficiency, bool, true, "Apply two track efficiency for tpc tpc") + O2_DEFINE_CONFIGURABLE(cfgRadiusLow, float, 0.8, "Low radius for merging cut") + O2_DEFINE_CONFIGURABLE(cfgRadiusHigh, float, 2.5, "High radius for merging cut") + O2_DEFINE_CONFIGURABLE(etaMftTrackMin, float, -3.6, "Minimum eta for MFT track") + O2_DEFINE_CONFIGURABLE(etaMftTrackMax, float, -2.5, "Maximum eta for MFT track") + O2_DEFINE_CONFIGURABLE(nClustersMftTrack, int, 5, "Minimum number of clusters for MFT track") + O2_DEFINE_CONFIGURABLE(cfgSampleSize, double, 10, "Sample size for mixed event") + + Configurable processMFT{"processMFT", true, "Associate particle from MFT"}; + + SliceCache cache; + SliceCache cacheNch; + + ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for histograms"}; + ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; + ConfigurableAxis axisPhi{"axisPhi", {72, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt axis for histograms"}; ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"}; - ConfigurableAxis axisDeltaEta{"axisDeltaEta", {40, -2, 2}, "delta eta axis for histograms"}; + ConfigurableAxis axisDeltaEta{"axisDeltaEta", {48, -2.4, 2.4}, "delta eta axis for histograms"}; ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt trigger axis for histograms"}; ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt associated axis for histograms"}; ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100}, "multiplicity / centrality axis for histograms"}; + ConfigurableAxis vtxMix{"vtxMix", {VARIABLE_WIDTH, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, "vertex axis for mixed event histograms"}; + ConfigurableAxis multMix{"multMix", {VARIABLE_WIDTH, 0, 5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100}, "multiplicity / centrality axis for mixed event histograms"}; + ConfigurableAxis axisSample{"axisSample", {cfgSampleSize, 0, cfgSampleSize}, "sample axis for histograms"}; + + ConfigurableAxis axisVertexEfficiency{"axisVertexEfficiency", {10, -10, 10}, "vertex axis for efficiency histograms"}; + ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"}; + ConfigurableAxis axisPtEfficiency{"axisPtEfficiency", {VARIABLE_WIDTH, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0}, "pt axis for efficiency histograms"}; + + // make the filters and cuts. + Filter collisionFilter = (nabs(aod::collision::posZ) < cfgZVtxCut) && (aod::evsel::sel8) == true; + Filter trackFilter = (nabs(aod::track::eta) < cfgEtaCut) && (cfgPtCutMin < aod::track::pt) && (cfgPtCutMax > aod::track::pt) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)); + + // Define the outputs + OutputObj same{Form("sameEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj mixed{Form("mixedEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + HistogramRegistry registry{"registry"}; - int logcolls = 0; - int logcollpairs = 0; + + using AodCollisions = soa::Filtered>; // aod::CentFT0Cs + using AodTracks = soa::Filtered>; void init(InitContext&) { + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + auto now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); + LOGF(info, "Starting init"); - registry.add("Yield", "pT vs eta vs Nch", {HistType::kTH3F, {{40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}, {100, 0, 100, "Nch"}}}); // check to see total number of tracks - registry.add("etaphi_Trigger", "eta vs phi vs Nch", {HistType::kTH3F, {{100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}, {100, 0, 100, "Nch"}}}); // Make histograms to check the distributions after cuts registry.add("deltaEta_deltaPhi_same", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); // check to see the delta eta and delta phi distribution registry.add("deltaEta_deltaPhi_mixed", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); - registry.add("Phi", "Phi", {HistType::kTH1D, {{72, 0, TwoPI, "Phi"}}}); - registry.add("Eta", "Eta", {HistType::kTH1D, {{40, -2, 2, "Eta"}}}); + registry.add("Phi", "Phi", {HistType::kTH1D, {axisPhi}}); + registry.add("Eta", "Eta", {HistType::kTH1D, {axisEta}}); registry.add("pT", "pT", {HistType::kTH1D, {axisPtTrigger}}); registry.add("Nch", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}}); + registry.add("Nch_used", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}}); // histogram to see how many events are in the same and mixed event + registry.add("zVtx", "zVtx", {HistType::kTH1D, {axisVertex}}); + + registry.add("Trig_hist", "", {HistType::kTHnSparseF, {{axisSample, axisVertex, axisPtTrigger}}}); - registry.add("Sparse_mixed", "", {HistType::kTHnSparseF, {{axisVertex, axisPtTrigger, axisPtAssoc, axisMultiplicity, axisDeltaPhi, axisDeltaEta}}}); // Make the output sparse - registry.add("Sparse_same", "", {HistType::kTHnSparseF, {{axisVertex, axisPtTrigger, axisPtAssoc, axisMultiplicity, axisDeltaPhi, axisDeltaEta}}}); + registry.add("eventcount", "bin", {HistType::kTH1F, {{4, 0, 4, "bin"}}}); // histogram to see how many events are in the same and mixed event - const int maxMixBin = axisMultiplicity->size() * axisVertex->size(); - registry.add("eventcount", "bin", {HistType::kTH1F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}}}); // histogram to see how many events are in the same and mixed event + std::vector corrAxis = {{axisSample, "Sample"}, + {axisVertex, "z-vtx (cm)"}, + {axisPtTrigger, "p_{T} (GeV/c)"}, + {axisPtAssoc, "p_{T} (GeV/c)"}, + {axisDeltaPhi, "#Delta#varphi (rad)"}, + {axisDeltaEta, "#Delta#eta"}}; + std::vector effAxis = { + {axisVertexEfficiency, "z-vtx (cm)"}, + {axisPtEfficiency, "p_{T} (GeV/c)"}, + {axisEtaEfficiency, "#eta"}, + }; + std::vector userAxis; + + same.setObject(new CorrelationContainer(Form("sameEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("sameEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + mixed.setObject(new CorrelationContainer(Form("mixedEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("mixedEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + } + enum EventType { + SameEvent = 1, + MixedEvent = 3 + }; + + TRandom3* gRandom = new TRandom3(); + + template + bool isAcceptedMftTrack(TTrackAssoc const& mftTrack) + { + // cut on the eta of MFT tracks + if (mftTrack.eta() < etaMftTrackMin || mftTrack.eta() > etaMftTrackMax) { + return false; + } + + // cut on the number of clusters of the reconstructed MFT track + if (mftTrack.nClusters() < nClustersMftTrack) { + return false; + } + + return true; + } + + int getMagneticField(uint64_t timestamp) + { + // Get the magnetic field + static o2::parameters::GRPMagField* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp("/GLO/Config/GRPMagField", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + } + return grpo->getNominalL3Field(); } // fill multiple histograms template - void fillYield(TCollision /*collision*/, float /*centrality*/, TTracks tracks) // function to fill the yield and etaphi histograms. + void fillYield(TCollision collision, TTracks tracks) // function to fill the yield and etaphi histograms. { + registry.fill(HIST("Nch"), tracks.size()); + registry.fill(HIST("zVtx"), collision.posZ()); + for (auto const& track1 : tracks) { - registry.fill(HIST("Yield"), track1.pt(), track1.eta(), track1.size()); - registry.fill(HIST("etaphi_Trigger"), track1.eta(), track1.phi(), track1.size()); - registry.fill(HIST("Phi"), track1.phi()); + + if (processMFT) { + if constexpr (std::is_same_v) { + if (!isAcceptedMftTrack(track1)) { + continue; + } + } + } + + registry.fill(HIST("Phi"), RecoDecay::constrainAngle(track1.phi(), 0.0)); registry.fill(HIST("Eta"), track1.eta()); registry.fill(HIST("pT"), track1.pt()); } } - template - bool fillCollision(TCollision collision, float /*centrality*/) + template + float getDPhiStar(TTrack const& track1, TTrackAssoc const& track2, float radius, int magField) { + float charge1 = track1.sign(); + float charge2 = track2.sign(); - if (!collision.sel8()) { - return false; - } + float phi1 = track1.phi(); + float phi2 = track2.phi(); - return true; + float pt1 = track1.pt(); + float pt2 = track2.pt(); + + int fbSign = (magField > 0) ? 1 : -1; + + float dPhiStar = phi1 - phi2 - charge1 * fbSign * std::asin(0.075 * radius / pt1) + charge2 * fbSign * std::asin(0.075 * radius / pt2); + + if (dPhiStar > constants::math::PI) + dPhiStar = constants::math::TwoPI - dPhiStar; + if (dPhiStar < -constants::math::PI) + dPhiStar = -constants::math::TwoPI - dPhiStar; + + return dPhiStar; } - template - void fillCorrelations(TTracks tracks1, TTracks tracks2, float posZ, int system, float Nch) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms + // + template + void fillCorrelations(TTracks tracks1, TTracksAssoc tracks2, float posZ, int system, int magneticField) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms { + + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + // loop over all tracks for (auto const& track1 : tracks1) { + if (system == SameEvent) { + registry.fill(HIST("Nch_used"), tracks1.size()); + registry.fill(HIST("Trig_hist"), fSampleIndex, posZ, track1.pt()); + } + for (auto const& track2 : tracks2) { - if (track1 == track2) { - continue; + + if (processMFT) { + if constexpr (std::is_same_v) { + if (!isAcceptedMftTrack(track2)) { + continue; + } + } + } else { + if (track1.pt() <= track2.pt()) + continue; // skip if the trigger pt is less than the associate pt } float deltaPhi = RecoDecay::constrainAngle(track1.phi() - track2.phi(), -PIHalf); float deltaEta = track1.eta() - track2.eta(); + if (cfgApplyTwoTrackEfficiency && std::abs(deltaEta) < cfgMergingCut) { + + double dPhiStarHigh = getDPhiStar(track1, track2, cfgRadiusHigh, magneticField); + double dPhiStarLow = getDPhiStar(track1, track2, cfgRadiusLow, magneticField); + + const double kLimit = 3.0 * cfgMergingCut; + + bool bIsBelow = false; + + if (std::abs(dPhiStarLow) < kLimit || std::abs(dPhiStarHigh) < kLimit || dPhiStarLow * dPhiStarHigh < 0) { + for (double rad(cfgRadiusLow); rad < cfgRadiusHigh; rad += 0.01) { + double dPhiStar = getDPhiStar(track1, track2, rad, magneticField); + if (std::abs(dPhiStar) < kLimit) { + bIsBelow = true; + break; + } + } + if (bIsBelow) + continue; + } + } + // fill the right sparse and histograms - if (system == 1) { + if (system == SameEvent) { + + same->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta); registry.fill(HIST("deltaEta_deltaPhi_same"), deltaPhi, deltaEta); - registry.fill(HIST("Sparse_same"), posZ, track1.pt(), track2.pt(), Nch, deltaPhi, deltaEta); - } else if (system == 2) { + } else if (system == MixedEvent) { + + mixed->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta); registry.fill(HIST("deltaEta_deltaPhi_mixed"), deltaPhi, deltaEta); - registry.fill(HIST("Sparse_mixed"), posZ, track1.pt(), track2.pt(), Nch, deltaPhi, deltaEta); } } } } - // make the filters and cuts. + void processSame(AodCollisions::iterator const& collision, AodTracks const& tracks, aod::MFTTracks const& mfts, aod::BCsWithTimestamps const&) + { - Filter collisionFilter = nabs(aod::collision::posZ) < cfgZVtxCut; + auto bc = collision.bc_as(); - Filter trackFilter = (nabs(aod::track::eta) < cfgEtaCut) && (aod::track::pt > cfgPtCutMin) && (aod::track::pt < cfgPtCutMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)); + registry.fill(HIST("eventcount"), SameEvent); // because its same event i put it in the 1 bin - // define the filtered collisions and tracks + if (processMFT) { + fillYield(collision, mfts); - using AodCollisions = soa::Filtered>; - using AodTracks = soa::Filtered>; + if (tracks.size() < cfgMinMult || tracks.size() >= cfgMaxMult) { + return; + } - void processSame(AodCollisions::iterator const& collision, AodTracks const& tracks) - { - const auto centrality = collision.centFT0C(); + fillCorrelations(tracks, mfts, collision.posZ(), SameEvent, getMagneticField(bc.timestamp())); - registry.fill(HIST("eventcount"), -2); // because its same event i put it in the -2 bin - fillYield(collision, centrality, tracks); - fillCorrelations(tracks, tracks, collision.posZ(), 1, tracks.size()); // fill the SE histogram and Sparse - } - PROCESS_SWITCH(CorrSparse, processSame, "Process same event", true); + } else { + fillYield(collision, tracks); - // i do the event mixing (i have not changed this from the tutorial i got). - std::vector vtxBinsEdges{VARIABLE_WIDTH, -7.0f, -5.0f, -3.0f, -1.0f, 1.0f, 3.0f, 5.0f, 7.0f}; - std::vector multBinsEdges{VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0, 100.1f}; - SliceCache cache; + if (tracks.size() < cfgMinMult || tracks.size() >= cfgMaxMult) { + return; + } - ColumnBinningPolicy - bindingOnVtxAndMult{{vtxBinsEdges, multBinsEdges}, true}; // true is for 'ignore overflows' (true by default) - SameKindPair> - pair{bindingOnVtxAndMult, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored + fillCorrelations(tracks, tracks, collision.posZ(), SameEvent, getMagneticField(bc.timestamp())); + } + } + PROCESS_SWITCH(CorrSparse, processSame, "Process same event", true); // the process for filling the mixed events - void processMixed(AodCollisions const& /*collisions*/, AodTracks const& /*tracks*/) + void processMixed(AodCollisions const& collisions, AodTracks const& tracks, aod::MFTTracks const& MFTtracks, aod::BCsWithTimestamps const&) { - for (auto const& [collision1, tracks1, collision2, tracks2] : pair) { - if (fillCollision(collision1, collision1.centFT0C()) == false) { - continue; + auto getTracksSize = [&tracks, this](AodCollisions::iterator const& collision) { + auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), this->cache); + auto mult = associatedTracks.size(); + return mult; + }; + + using MixedBinning = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getTracksSize)>; + + MixedBinning binningOnVtxAndMult{{getTracksSize}, {vtxMix, multMix}, true}; + + if (processMFT) { + + auto tracksTuple = std::make_tuple(tracks, MFTtracks); + Pair pair{binningOnVtxAndMult, cfgMinMixEventNum, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + for (auto const& [collision1, tracks1, collision2, tracks2] : pair) { + registry.fill(HIST("eventcount"), MixedEvent); // fill the mixed event in the 3 bin + auto bc = collision1.bc_as(); + + if ((tracks1.size() < cfgMinMult || tracks1.size() >= cfgMaxMult)) + continue; + + fillCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent, getMagneticField(bc.timestamp())); } + } else { + auto tracksTuple = std::make_tuple(tracks, tracks); + Pair pair{binningOnVtxAndMult, cfgMinMixEventNum, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + for (auto const& [collision1, tracks1, collision2, tracks2] : pair) { + registry.fill(HIST("eventcount"), MixedEvent); // fill the mixed event in the 3 bin + auto bc = collision1.bc_as(); - registry.fill(HIST("eventcount"), 1); // fill the mixed event in the 1 bin + if ((tracks1.size() < cfgMinMult || tracks1.size() >= cfgMaxMult)) + continue; + + if ((tracks2.size() < cfgMinMult || tracks2.size() >= cfgMaxMult)) + continue; - fillCorrelations(tracks1, tracks2, collision1.posZ(), 2, tracks1.size()); + fillCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent, getMagneticField(bc.timestamp())); + } } } + PROCESS_SWITCH(CorrSparse, processMixed, "Process mixed events", true); }; diff --git a/PWGCF/TwoParticleCorrelations/Tasks/diHadronCor.cxx b/PWGCF/TwoParticleCorrelations/Tasks/diHadronCor.cxx new file mode 100644 index 00000000000..03d38b71db4 --- /dev/null +++ b/PWGCF/TwoParticleCorrelations/Tasks/diHadronCor.cxx @@ -0,0 +1,1053 @@ +// 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. + +/// \file diHadronCor.cxx +/// \brief di-hadron correlation for O-O, Pb-Pb collisions +/// \author Zhiyong Lu (zhiyong.lu@cern.ch) +/// \since May/03/2025 + +#include "PWGCF/Core/CorrelationContainer.h" +#include "PWGCF/Core/PairCuts.h" +#include "PWGCF/DataModel/CorrelationsDerived.h" +#include "PWGCF/GenericFramework/Core/GFW.h" +#include "PWGCF/GenericFramework/Core/GFWCumulant.h" +#include "PWGCF/GenericFramework/Core/GFWPowerArray.h" +#include "PWGCF/GenericFramework/Core/GFWWeights.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/MathConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include + +#include "TF1.h" +#include "TRandom3.h" +#include + +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// define the filtered collisions and tracks +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +struct DiHadronCor { + Service ccdb; + + O2_DEFINE_CONFIGURABLE(cfgCutVtxZ, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "minimum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 10.0f, "maximum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta cut") + O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5f, "max chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 50.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCCrossedRows, float, 70.0f, "minimum TPC crossed rows") + O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters") + O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "max DCA to vertex z") + O2_DEFINE_CONFIGURABLE(cfgCutMerging, float, 0.0, "Merging cut on track merge") + O2_DEFINE_CONFIGURABLE(cfgSelCollByNch, bool, true, "Select collisions by Nch or centrality") + O2_DEFINE_CONFIGURABLE(cfgCutMultMin, int, 0, "Minimum multiplicity for collision") + O2_DEFINE_CONFIGURABLE(cfgCutMultMax, int, 10, "Maximum multiplicity for collision") + O2_DEFINE_CONFIGURABLE(cfgCutCentMin, float, 60.0f, "Minimum centrality for collision") + O2_DEFINE_CONFIGURABLE(cfgCutCentMax, float, 80.0f, "Maximum centrality for collision") + O2_DEFINE_CONFIGURABLE(cfgMixEventNumMin, int, 5, "Minimum number of events to mix") + O2_DEFINE_CONFIGURABLE(cfgRadiusLow, float, 0.8, "Low radius for merging cut") + O2_DEFINE_CONFIGURABLE(cfgRadiusHigh, float, 2.5, "High radius for merging cut") + O2_DEFINE_CONFIGURABLE(cfgSampleSize, double, 10, "Sample size for mixed event") + O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FT0A") + O2_DEFINE_CONFIGURABLE(cfgCentTableUnavailable, bool, false, "if a dataset does not provide centrality information") + O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoSameBunchPileup, bool, false, "rejects collisions which are associated with the same found-by-T0 bunch crossing") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoITSROFrameBorder, bool, false, "reject events at ITS ROF border") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoTimeFrameBorder, bool, false, "reject events at TF border") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodZvtxFT0vsPV, bool, false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference, use this cut at low multiplicities with caution") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInTimeRangeStandard, bool, false, "no collisions in specified time range") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodITSLayersAll, bool, true, "cut time intervals with dead ITS staves") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInRofStandard, bool, false, "no other collisions in this Readout Frame with per-collision multiplicity above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoHighMultCollInPrevRof, bool, false, "veto an event if FT0C amplitude in previous ITS ROF is above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelMultCorrelation, bool, true, "Multiplicity correlation cut") + O2_DEFINE_CONFIGURABLE(cfgEvSelV0AT0ACut, bool, true, "V0A T0A 5 sigma cut") + O2_DEFINE_CONFIGURABLE(cfgEvSelOccupancy, bool, true, "Occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 2000, "High cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgCentralityWeight, std::string, "", "CCDB path to centrality weight object") + O2_DEFINE_CONFIGURABLE(cfgLocalEfficiency, bool, false, "Use local efficiency object") + O2_DEFINE_CONFIGURABLE(cfgVerbosity, bool, false, "Verbose output") + O2_DEFINE_CONFIGURABLE(cfgUseEventWeights, bool, false, "Use event weights for mixed event") + O2_DEFINE_CONFIGURABLE(cfgUsePtOrder, bool, true, "enable trigger pT < associated pT cut") + O2_DEFINE_CONFIGURABLE(cfgUsePtOrderInMixEvent, bool, true, "enable trigger pT < associated pT cut in mixed event") + struct : ConfigurableGroup { + O2_DEFINE_CONFIGURABLE(cfgMultCentHighCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + 10.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultCentLowCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x - 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultT0CCutEnabled, bool, false, "Enable Global multiplicity vs T0C centrality cut") + Configurable> cfgMultT0CCutPars{"cfgMultT0CCutPars", std::vector{143.04, -4.58368, 0.0766055, -0.000727796, 2.86153e-06, 23.3108, -0.36304, 0.00437706, -4.717e-05, 1.98332e-07}, "Global multiplicity vs T0C centrality cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultPVT0CCutEnabled, bool, false, "Enable PV multiplicity vs T0C centrality cut") + Configurable> cfgMultPVT0CCutPars{"cfgMultPVT0CCutPars", std::vector{195.357, -6.15194, 0.101313, -0.000955828, 3.74793e-06, 30.0326, -0.43322, 0.00476265, -5.11206e-05, 2.13613e-07}, "PV multiplicity vs T0C centrality cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultMultPVHighCutFunction, std::string, "[0]+[1]*x + 5.*([2]+[3]*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultMultPVLowCutFunction, std::string, "[0]+[1]*x - 5.*([2]+[3]*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultGlobalPVCutEnabled, bool, false, "Enable global multiplicity vs PV multiplicity cut") + Configurable> cfgMultGlobalPVCutPars{"cfgMultGlobalPVCutPars", std::vector{-0.140809, 0.734344, 2.77495, 0.0165935}, "PV multiplicity vs T0C centrality cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultMultV0AHighCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + 4.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultMultV0ALowCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x - 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultMultV0ACutEnabled, bool, false, "Enable global multiplicity vs V0A multiplicity cut") + Configurable> cfgMultMultV0ACutPars{"cfgMultMultV0ACutPars", std::vector{534.893, 184.344, 0.423539, -0.00331436, 5.34622e-06, 871.239, 53.3735, -0.203528, 0.000122758, 5.41027e-07}, "Global multiplicity vs V0A multiplicity cut parameter values"}; + std::vector multT0CCutPars; + std::vector multPVT0CCutPars; + std::vector multGlobalPVCutPars; + std::vector multMultV0ACutPars; + TF1* fMultPVT0CCutLow = nullptr; + TF1* fMultPVT0CCutHigh = nullptr; + TF1* fMultT0CCutLow = nullptr; + TF1* fMultT0CCutHigh = nullptr; + TF1* fMultGlobalPVCutLow = nullptr; + TF1* fMultGlobalPVCutHigh = nullptr; + TF1* fMultMultV0ACutLow = nullptr; + TF1* fMultMultV0ACutHigh = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + } cfgFuncParas; + + SliceCache cache; + + ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for histograms"}; + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 10, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260}, "multiplicity axis for histograms"}; + ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, "centrality axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt axis for histograms"}; + ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"}; + ConfigurableAxis axisDeltaEta{"axisDeltaEta", {48, -2.4, 2.4}, "delta eta axis for histograms"}; + ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt trigger axis for histograms"}; + ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt associated axis for histograms"}; + ConfigurableAxis axisVtxMix{"axisVtxMix", {VARIABLE_WIDTH, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, "vertex axis for mixed event histograms"}; + ConfigurableAxis axisMultMix{"axisMultMix", {VARIABLE_WIDTH, 0, 10, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260}, "multiplicity / centrality axis for mixed event histograms"}; + ConfigurableAxis axisSample{"axisSample", {cfgSampleSize, 0, cfgSampleSize}, "sample axis for histograms"}; + + ConfigurableAxis axisVertexEfficiency{"axisVertexEfficiency", {10, -10, 10}, "vertex axis for efficiency histograms"}; + ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"}; + ConfigurableAxis axisPtEfficiency{"axisPtEfficiency", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt axis for efficiency histograms"}; + + // make the filters and cuts. + Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVtxZ); + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + using FilteredCollisions = soa::Filtered>; + using FilteredTracks = soa::Filtered>; + using FilteredTracksWithMCLabels = soa::Filtered>; + + // Filter for MCParticle + Filter particleFilter = (nabs(aod::mcparticle::eta) < cfgCutEta) && (aod::mcparticle::pt > cfgCutPtMin) && (aod::mcparticle::pt < cfgCutPtMax); + using FilteredMcParticles = soa::Filtered; + + // Filter for MCcollisions + Filter mccollisionFilter = nabs(aod::mccollision::posZ) < cfgCutVtxZ; + using FilteredMcCollisions = soa::Filtered; + + using SmallGroupMcCollisions = soa::SmallGroups>; + + Preslice perCollision = aod::track::collisionId; + PresliceUnsorted collisionPerMCCollision = aod::mccollisionlabel::mcCollisionId; + + // Corrections + TH3D* mEfficiency = nullptr; + TH1D* mCentralityWeight = nullptr; + bool correctionsLoaded = false; + + // Define the outputs + OutputObj same{"sameEvent"}; + OutputObj mixed{"mixedEvent"}; + HistogramRegistry registry{"registry"}; + + // define global variables + TRandom3* gRandom = new TRandom3(); + enum CentEstimators { + kCentFT0C = 0, + kCentFT0CVariant1, + kCentFT0M, + kCentFV0A, + // Count the total number of enum + kCount_CentEstimators + }; + enum EventType { + SameEvent = 1, + MixedEvent = 3 + }; + + // persistent caches + std::vector efficiencyAssociatedCache; + + void init(InitContext&) + { + if (cfgCentTableUnavailable && !cfgSelCollByNch) { + LOGF(fatal, "Centrality table is unavailable, cannot select collisions by centrality"); + } + const AxisSpec axisPhi{72, 0.0, constants::math::TwoPI, "#varphi"}; + const AxisSpec axisEta{40, -1., 1., "#eta"}; + + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + auto now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); + + LOGF(info, "Starting init"); + + // Event Counter + if (doprocessSame && cfgUseAdditionalEventCut) { + registry.add("hEventCountSpecific", "Number of Event;; Count", {HistType::kTH1D, {{12, 0, 12}}}); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(1, "after sel8"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(2, "kNoSameBunchPileup"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(3, "kNoITSROFrameBorder"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(4, "kNoTimeFrameBorder"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(5, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(6, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(7, "kIsGoodITSLayersAll"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(8, "kNoCollInRofStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(9, "kNoHighMultCollInPrevRof"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(10, "occupancy"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(11, "MultCorrelation"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(12, "cfgEvSelV0AT0ACut"); + } + + if (cfgEvSelMultCorrelation) { + cfgFuncParas.multT0CCutPars = cfgFuncParas.cfgMultT0CCutPars; + cfgFuncParas.multPVT0CCutPars = cfgFuncParas.cfgMultPVT0CCutPars; + cfgFuncParas.multGlobalPVCutPars = cfgFuncParas.cfgMultGlobalPVCutPars; + cfgFuncParas.multMultV0ACutPars = cfgFuncParas.cfgMultMultV0ACutPars; + cfgFuncParas.fMultPVT0CCutLow = new TF1("fMultPVT0CCutLow", cfgFuncParas.cfgMultCentLowCutFunction->c_str(), 0, 100); + cfgFuncParas.fMultPVT0CCutLow->SetParameters(&(cfgFuncParas.multPVT0CCutPars[0])); + cfgFuncParas.fMultPVT0CCutHigh = new TF1("fMultPVT0CCutHigh", cfgFuncParas.cfgMultCentHighCutFunction->c_str(), 0, 100); + cfgFuncParas.fMultPVT0CCutHigh->SetParameters(&(cfgFuncParas.multPVT0CCutPars[0])); + + cfgFuncParas.fMultT0CCutLow = new TF1("fMultT0CCutLow", cfgFuncParas.cfgMultCentLowCutFunction->c_str(), 0, 100); + cfgFuncParas.fMultT0CCutLow->SetParameters(&(cfgFuncParas.multT0CCutPars[0])); + cfgFuncParas.fMultT0CCutHigh = new TF1("fMultT0CCutHigh", cfgFuncParas.cfgMultCentHighCutFunction->c_str(), 0, 100); + cfgFuncParas.fMultT0CCutHigh->SetParameters(&(cfgFuncParas.multT0CCutPars[0])); + + cfgFuncParas.fMultGlobalPVCutLow = new TF1("fMultGlobalPVCutLow", cfgFuncParas.cfgMultMultPVLowCutFunction->c_str(), 0, 4000); + cfgFuncParas.fMultGlobalPVCutLow->SetParameters(&(cfgFuncParas.multGlobalPVCutPars[0])); + cfgFuncParas.fMultGlobalPVCutHigh = new TF1("fMultGlobalPVCutHigh", cfgFuncParas.cfgMultMultPVHighCutFunction->c_str(), 0, 4000); + cfgFuncParas.fMultGlobalPVCutHigh->SetParameters(&(cfgFuncParas.multGlobalPVCutPars[0])); + + cfgFuncParas.fMultMultV0ACutLow = new TF1("fMultMultV0ACutLow", cfgFuncParas.cfgMultMultV0ALowCutFunction->c_str(), 0, 4000); + cfgFuncParas.fMultMultV0ACutLow->SetParameters(&(cfgFuncParas.multMultV0ACutPars[0])); + cfgFuncParas.fMultMultV0ACutHigh = new TF1("fMultMultV0ACutHigh", cfgFuncParas.cfgMultMultV0AHighCutFunction->c_str(), 0, 4000); + cfgFuncParas.fMultMultV0ACutHigh->SetParameters(&(cfgFuncParas.multMultV0ACutPars[0])); + + cfgFuncParas.fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + cfgFuncParas.fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + cfgFuncParas.fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + cfgFuncParas.fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } + + std::string hCentTitle = "Centrality distribution, Estimator " + std::to_string(cfgCentEstimator); + // Make histograms to check the distributions after cuts + if (doprocessSame) { + registry.add("deltaEta_deltaPhi_same", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); // check to see the delta eta and delta phi distribution + registry.add("deltaEta_deltaPhi_mixed", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); + registry.add("Phi", "Phi", {HistType::kTH1D, {axisPhi}}); + registry.add("Eta", "Eta", {HistType::kTH1D, {axisEta}}); + registry.add("EtaCorrected", "EtaCorrected", {HistType::kTH1D, {axisEta}}); + registry.add("pT", "pT", {HistType::kTH1D, {axisPtTrigger}}); + registry.add("pTCorrected", "pTCorrected", {HistType::kTH1D, {axisPtTrigger}}); + registry.add("Nch", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}}); + registry.add("Nch_used", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}}); // histogram to see how many events are in the same and mixed event + registry.add("Centrality", hCentTitle.c_str(), {HistType::kTH1D, {{100, 0, 100}}}); + registry.add("CentralityWeighted", hCentTitle.c_str(), {HistType::kTH1D, {{100, 0, 100}}}); + registry.add("Centrality_used", hCentTitle.c_str(), {HistType::kTH1D, {{100, 0, 100}}}); // histogram to see how many events are in the same and mixed event + registry.add("zVtx", "zVtx", {HistType::kTH1D, {axisVertex}}); + registry.add("zVtx_used", "zVtx_used", {HistType::kTH1D, {axisVertex}}); + registry.add("Trig_hist", "", {HistType::kTHnSparseF, {{axisSample, axisVertex, axisPtTrigger}}}); + } + + registry.add("eventcount", "bin", {HistType::kTH1F, {{4, 0, 4, "bin"}}}); // histogram to see how many events are in the same and mixed event + if (doprocessMCSame && doprocessOntheflySame) { + LOGF(fatal, "Full simulation and on-the-fly processing of same event not supported"); + } + if (doprocessMCMixed && doprocessOntheflyMixed) { + LOGF(fatal, "Full simulation and on-the-fly processing of mixed event not supported"); + } + if (doprocessMCSame || doprocessOntheflySame) { + registry.add("MCTrue/MCeventcount", "MCeventcount", {HistType::kTH1F, {{5, 0, 5, "bin"}}}); // histogram to see how many events are in the same and mixed event + registry.get(HIST("MCTrue/MCeventcount"))->GetXaxis()->SetBinLabel(2, "same all"); + registry.get(HIST("MCTrue/MCeventcount"))->GetXaxis()->SetBinLabel(3, "same reco"); + registry.get(HIST("MCTrue/MCeventcount"))->GetXaxis()->SetBinLabel(4, "mixed all"); + registry.get(HIST("MCTrue/MCeventcount"))->GetXaxis()->SetBinLabel(5, "mixed reco"); + registry.add("MCTrue/MCCentrality", hCentTitle.c_str(), {HistType::kTH1D, {axisCentrality}}); + registry.add("MCTrue/MCNch", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}}); + registry.add("MCTrue/MCzVtx", "MCzVtx", {HistType::kTH1D, {axisVertex}}); + registry.add("MCTrue/MCPhi", "MCPhi", {HistType::kTH1D, {axisPhi}}); + registry.add("MCTrue/MCEta", "MCEta", {HistType::kTH1D, {axisEta}}); + registry.add("MCTrue/MCpT", "MCpT", {HistType::kTH1D, {axisPtTrigger}}); + registry.add("MCTrue/MCTrig_hist", "", {HistType::kTHnSparseF, {{axisSample, axisVertex, axisPtTrigger}}}); + registry.add("MCTrue/MCdeltaEta_deltaPhi_same", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); // check to see the delta eta and delta phi distribution + registry.add("MCTrue/MCdeltaEta_deltaPhi_mixed", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); + } + if (doprocessMCEfficiency) { + registry.add("MCEffeventcount", "bin", {HistType::kTH1F, {{5, 0, 5, "bin"}}}); + registry.get(HIST("MCEffeventcount"))->GetXaxis()->SetBinLabel(1, "All"); + registry.get(HIST("MCEffeventcount"))->GetXaxis()->SetBinLabel(2, "MC"); + registry.get(HIST("MCEffeventcount"))->GetXaxis()->SetBinLabel(3, "Reco Primary"); + registry.get(HIST("MCEffeventcount"))->GetXaxis()->SetBinLabel(4, "Reco All"); + registry.get(HIST("MCEffeventcount"))->GetXaxis()->SetBinLabel(5, "Fake"); + } + + LOGF(info, "Initializing correlation container"); + std::vector corrAxis = {{axisSample, "Sample"}, + {axisVertex, "z-vtx (cm)"}, + {axisPtTrigger, "p_{T} (GeV/c)"}, + {axisPtAssoc, "p_{T} (GeV/c)"}, + {axisDeltaPhi, "#Delta#varphi (rad)"}, + {axisDeltaEta, "#Delta#eta"}}; + std::vector effAxis = { + {axisEtaEfficiency, "#eta"}, + {axisPtEfficiency, "p_{T} (GeV/c)"}, + {axisVertexEfficiency, "z-vtx (cm)"}, + }; + std::vector userAxis; + + same.setObject(new CorrelationContainer("sameEvent", "sameEvent", corrAxis, effAxis, userAxis)); + mixed.setObject(new CorrelationContainer("mixedEvent", "mixedEvent", corrAxis, effAxis, userAxis)); + + LOGF(info, "End of init"); + } + + int getMagneticField(uint64_t timestamp) + { + // Get the magnetic field + static o2::parameters::GRPMagField* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp("/GLO/Config/GRPMagField", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + } + return grpo->getNominalL3Field(); + } + + template + float getCentrality(TCollision const& collision) + { + float cent; + switch (cfgCentEstimator) { + case kCentFT0C: + cent = collision.centFT0C(); + break; + case kCentFT0CVariant1: + cent = collision.centFT0CVariant1(); + break; + case kCentFT0M: + cent = collision.centFT0M(); + break; + case kCentFV0A: + cent = collision.centFV0A(); + break; + default: + cent = collision.centFT0C(); + } + return cent; + } + + template + bool trackSelected(TTrack track) + { + return ((track.tpcNClsFound() >= cfgCutTPCclu) && (track.tpcNClsCrossedRows() >= cfgCutTPCCrossedRows) && (track.itsNCls() >= cfgCutITSclu)); + } + + template + bool genTrackSelected(TTrack track) + { + if (!track.isPhysicalPrimary()) { + return false; + } + if (!track.producedByGenerator()) { + return false; + } + if (std::abs(track.eta()) > cfgCutEta) { + return false; + } + if (std::abs(track.pt()) < cfgCutPtMin || std::abs(track.pt()) > cfgCutPtMax) { + return false; + } + return true; + } + + void loadCorrection(uint64_t timestamp) + { + if (correctionsLoaded) { + return; + } + if (cfgEfficiency.value.empty() == false) { + if (cfgLocalEfficiency > 0) { + TFile* fEfficiencyTrigger = TFile::Open(cfgEfficiency.value.c_str(), "READ"); + mEfficiency = reinterpret_cast(fEfficiencyTrigger->Get("ccdb_object")); + } else { + mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); + } + if (mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency); + } + if (cfgCentralityWeight.value.empty() == false) { + mCentralityWeight = ccdb->getForTimeStamp(cfgCentralityWeight, timestamp); + if (mCentralityWeight == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgCentralityWeight.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgCentralityWeight.value.c_str(), (void*)mCentralityWeight); + } + correctionsLoaded = true; + } + + bool getEfficiencyCorrection(float& weight_nue, float eta, float pt, float posZ) + { + float eff = 1.; + if (mEfficiency) { + int etaBin = mEfficiency->GetXaxis()->FindBin(eta); + int ptBin = mEfficiency->GetYaxis()->FindBin(pt); + int zBin = mEfficiency->GetZaxis()->FindBin(posZ); + eff = mEfficiency->GetBinContent(etaBin, ptBin, zBin); + } else { + eff = 1.0; + } + if (eff == 0) + return false; + weight_nue = 1. / eff; + return true; + } + + bool getCentralityWeight(float& weightCent, const float centrality) + { + float weight = 1.; + if (mCentralityWeight) + weight = mCentralityWeight->GetBinContent(mCentralityWeight->FindBin(centrality)); + else + weight = 1.0; + if (weight == 0) + return false; + weightCent = weight; + return true; + } + + // fill multiple histograms + template + void fillYield(TCollision collision, TTracks tracks) // function to fill the yield and etaphi histograms. + { + float weff1 = 1; + float vtxz = collision.posZ(); + for (auto const& track1 : tracks) { + if (!trackSelected(track1)) + continue; + if (!getEfficiencyCorrection(weff1, track1.eta(), track1.pt(), vtxz)) + continue; + registry.fill(HIST("Phi"), RecoDecay::constrainAngle(track1.phi(), 0.0)); + registry.fill(HIST("Eta"), track1.eta()); + registry.fill(HIST("EtaCorrected"), track1.eta(), weff1); + registry.fill(HIST("pT"), track1.pt()); + registry.fill(HIST("pTCorrected"), track1.pt(), weff1); + } + } + + template + float getDPhiStar(TTrack const& track1, TTrackAssoc const& track2, float radius, int magField) + { + float charge1 = track1.sign(); + float charge2 = track2.sign(); + + float phi1 = track1.phi(); + float phi2 = track2.phi(); + + float pt1 = track1.pt(); + float pt2 = track2.pt(); + + int fbSign = (magField > 0) ? 1 : -1; + + float dPhiStar = phi1 - phi2 - charge1 * fbSign * std::asin(0.075 * radius / pt1) + charge2 * fbSign * std::asin(0.075 * radius / pt2); + + if (dPhiStar > constants::math::PI) + dPhiStar = constants::math::TwoPI - dPhiStar; + if (dPhiStar < -constants::math::PI) + dPhiStar = -constants::math::TwoPI - dPhiStar; + + return dPhiStar; + } + + template + void fillCorrelations(TTracks tracks1, TTracksAssoc tracks2, float posZ, int system, int magneticField, float cent, float eventWeight) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms + { + // Cache efficiency for particles (too many FindBin lookups) + if (mEfficiency) { + efficiencyAssociatedCache.clear(); + efficiencyAssociatedCache.reserve(tracks2.size()); + for (const auto& track2 : tracks2) { + float weff = 1.; + getEfficiencyCorrection(weff, track2.eta(), track2.pt(), posZ); + efficiencyAssociatedCache.push_back(weff); + } + } + + if (system == SameEvent) { + if (!cfgCentTableUnavailable) + registry.fill(HIST("Centrality_used"), cent); + registry.fill(HIST("Nch_used"), tracks1.size()); + } + + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + + float triggerWeight = 1.0f; + float associatedWeight = 1.0f; + // loop over all tracks + for (auto const& track1 : tracks1) { + + if (!trackSelected(track1)) + continue; + if (!getEfficiencyCorrection(triggerWeight, track1.eta(), track1.pt(), posZ)) + continue; + if (system == SameEvent) { + registry.fill(HIST("Trig_hist"), fSampleIndex, posZ, track1.pt(), eventWeight * triggerWeight); + } + + for (auto const& track2 : tracks2) { + + if (!trackSelected(track2)) + continue; + if (mEfficiency) { + associatedWeight = efficiencyAssociatedCache[track2.filteredIndex()]; + } + + if (!cfgUsePtOrder && track1.globalIndex() == track2.globalIndex()) + continue; // For pt-differential correlations, skip if the trigger and associate are the same track + if (cfgUsePtOrder && system == SameEvent && track1.pt() <= track2.pt()) + continue; // Without pt-differential correlations, skip if the trigger pt is less than the associate pt + if (cfgUsePtOrder && system == MixedEvent && cfgUsePtOrderInMixEvent && track1.pt() <= track2.pt()) + continue; // For pt-differential correlations in mixed events, skip if the trigger pt is less than the associate pt + + float deltaPhi = RecoDecay::constrainAngle(track1.phi() - track2.phi(), -PIHalf); + float deltaEta = track1.eta() - track2.eta(); + + if (std::abs(deltaEta) < cfgCutMerging) { + + double dPhiStarHigh = getDPhiStar(track1, track2, cfgRadiusHigh, magneticField); + double dPhiStarLow = getDPhiStar(track1, track2, cfgRadiusLow, magneticField); + + const double kLimit = 3.0 * cfgCutMerging; + + bool bIsBelow = false; + + if (std::abs(dPhiStarLow) < kLimit || std::abs(dPhiStarHigh) < kLimit || dPhiStarLow * dPhiStarHigh < 0) { + for (double rad(cfgRadiusLow); rad < cfgRadiusHigh; rad += 0.01) { + double dPhiStar = getDPhiStar(track1, track2, rad, magneticField); + if (std::abs(dPhiStar) < kLimit) { + bIsBelow = true; + break; + } + } + if (bIsBelow) + continue; + } + } + + // fill the right sparse and histograms + if (system == SameEvent) { + + same->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + registry.fill(HIST("deltaEta_deltaPhi_same"), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + } else if (system == MixedEvent) { + + mixed->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + registry.fill(HIST("deltaEta_deltaPhi_mixed"), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + } + } + } + } + template + void fillMCCorrelations(TTracks tracks1, TTracksAssoc tracks2, float posZ, int system, float eventWeight) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms + { + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + + float triggerWeight = 1.0f; + float associatedWeight = 1.0f; + // loop over all tracks + for (auto const& track1 : tracks1) { + if (step >= CorrelationContainer::kCFStepTrackedOnlyPrim && !track1.isPhysicalPrimary()) + continue; + if (doprocessOntheflySame && !genTrackSelected(track1)) + continue; + + if (system == SameEvent && (doprocessMCSame || doprocessOntheflySame)) + registry.fill(HIST("MCTrue/MCTrig_hist"), fSampleIndex, posZ, track1.pt(), eventWeight * triggerWeight); + + for (auto const& track2 : tracks2) { + + if (step >= CorrelationContainer::kCFStepTrackedOnlyPrim && !track2.isPhysicalPrimary()) + continue; + if (doprocessOntheflyMixed && !genTrackSelected(track2)) + continue; + + if (!cfgUsePtOrder && track1.globalIndex() == track2.globalIndex()) + continue; // For pt-differential correlations, skip if the trigger and associate are the same track + if (cfgUsePtOrder && system == SameEvent && track1.pt() <= track2.pt()) + continue; // Without pt-differential correlations, skip if the trigger pt is less than the associate pt + if (cfgUsePtOrder && system == MixedEvent && cfgUsePtOrderInMixEvent && track1.pt() <= track2.pt()) + continue; // For pt-differential correlations in mixed events, skip if the trigger pt is less than the associate pt + + float deltaPhi = RecoDecay::constrainAngle(track1.phi() - track2.phi(), -PIHalf); + float deltaEta = track1.eta() - track2.eta(); + + // fill the right sparse and histograms + if (system == SameEvent) { + same->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + if (doprocessMCSame || doprocessOntheflySame) + registry.fill(HIST("MCTrue/MCdeltaEta_deltaPhi_same"), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + } else if (system == MixedEvent) { + mixed->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + if (doprocessMCMixed || doprocessOntheflyMixed) + registry.fill(HIST("MCTrue/MCdeltaEta_deltaPhi_mixed"), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + } + } + } + } + + template + bool eventSelected(TCollision collision, const int multTrk, const float centrality, const bool fillCounter) + { + registry.fill(HIST("hEventCountSpecific"), 0.5); + if (cfgEvSelkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return 0; + } + if (fillCounter && cfgEvSelkNoSameBunchPileup) + registry.fill(HIST("hEventCountSpecific"), 1.5); + if (cfgEvSelkNoITSROFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return 0; + } + if (fillCounter && cfgEvSelkNoITSROFrameBorder) + registry.fill(HIST("hEventCountSpecific"), 2.5); + if (cfgEvSelkNoTimeFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return 0; + } + if (fillCounter && cfgEvSelkNoTimeFrameBorder) + registry.fill(HIST("hEventCountSpecific"), 3.5); + if (cfgEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return 0; + } + if (fillCounter && cfgEvSelkIsGoodZvtxFT0vsPV) + registry.fill(HIST("hEventCountSpecific"), 4.5); + if (cfgEvSelkNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // no collisions in specified time range + return 0; + } + if (fillCounter && cfgEvSelkNoCollInTimeRangeStandard) + registry.fill(HIST("hEventCountSpecific"), 5.5); + if (cfgEvSelkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // from Jan 9 2025 AOT meeting + // cut time intervals with dead ITS staves + return 0; + } + if (fillCounter && cfgEvSelkIsGoodITSLayersAll) + registry.fill(HIST("hEventCountSpecific"), 6.5); + if (cfgEvSelkNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + // no other collisions in this Readout Frame with per-collision multiplicity above threshold + return 0; + } + if (fillCounter && cfgEvSelkNoCollInRofStandard) + registry.fill(HIST("hEventCountSpecific"), 7.5); + if (cfgEvSelkNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + // veto an event if FT0C amplitude in previous ITS ROF is above threshold + return 0; + } + if (fillCounter && cfgEvSelkNoHighMultCollInPrevRof) + registry.fill(HIST("hEventCountSpecific"), 8.5); + auto occupancy = collision.trackOccupancyInTimeRange(); + if (cfgEvSelOccupancy && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) + return 0; + if (fillCounter && cfgEvSelOccupancy) + registry.fill(HIST("hEventCountSpecific"), 9.5); + + auto multNTracksPV = collision.multNTracksPV(); + if (cfgEvSelMultCorrelation) { + if (cfgFuncParas.cfgMultPVT0CCutEnabled) { + if (multNTracksPV < cfgFuncParas.fMultPVT0CCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > cfgFuncParas.fMultPVT0CCutHigh->Eval(centrality)) + return 0; + } + if (cfgFuncParas.cfgMultT0CCutEnabled) { + if (multTrk < cfgFuncParas.fMultT0CCutLow->Eval(centrality)) + return 0; + if (multTrk > cfgFuncParas.fMultT0CCutHigh->Eval(centrality)) + return 0; + } + if (cfgFuncParas.cfgMultGlobalPVCutEnabled) { + if (multTrk < cfgFuncParas.fMultGlobalPVCutLow->Eval(multNTracksPV)) + return 0; + if (multTrk > cfgFuncParas.fMultGlobalPVCutHigh->Eval(multNTracksPV)) + return 0; + } + if (cfgFuncParas.cfgMultMultV0ACutEnabled) { + if (collision.multFV0A() < cfgFuncParas.fMultMultV0ACutLow->Eval(multTrk)) + return 0; + if (collision.multFV0A() > cfgFuncParas.fMultMultV0ACutHigh->Eval(multTrk)) + return 0; + } + } + if (fillCounter && cfgEvSelMultCorrelation) + registry.fill(HIST("hEventCountSpecific"), 10.5); + + // V0A T0A 5 sigma cut + float sigma = 5.0; + if (cfgEvSelV0AT0ACut && (std::fabs(collision.multFV0A() - cfgFuncParas.fT0AV0AMean->Eval(collision.multFT0A())) > sigma * cfgFuncParas.fT0AV0ASigma->Eval(collision.multFT0A()))) + return 0; + if (fillCounter && cfgEvSelV0AT0ACut) + registry.fill(HIST("hEventCountSpecific"), 11.5); + + return 1; + } + + void processSame(FilteredCollisions::iterator const& collision, FilteredTracks const& tracks, aod::BCsWithTimestamps const&) + { + if (!collision.sel8()) + return; + auto bc = collision.bc_as(); + float cent = -1.; + float weightCent = 1.0f; + if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), cent, true)) + return; + loadCorrection(bc.timestamp()); + if (!cfgCentTableUnavailable) { + cent = getCentrality(collision); + getCentralityWeight(weightCent, cent); + registry.fill(HIST("Centrality"), cent); + registry.fill(HIST("CentralityWeighted"), cent, weightCent); + } + registry.fill(HIST("Nch"), tracks.size()); + registry.fill(HIST("zVtx"), collision.posZ()); + + if (cfgSelCollByNch && (tracks.size() < cfgCutMultMin || tracks.size() >= cfgCutMultMax)) { + return; + } + if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent < cfgCutCentMin || cent >= cfgCutCentMax)) { + return; + } + + registry.fill(HIST("eventcount"), SameEvent); // because its same event i put it in the 1 bin + fillYield(collision, tracks); + + same->fillEvent(tracks.size(), CorrelationContainer::kCFStepReconstructed); + fillCorrelations(tracks, tracks, collision.posZ(), SameEvent, getMagneticField(bc.timestamp()), cent, weightCent); + } + PROCESS_SWITCH(DiHadronCor, processSame, "Process same event", true); + + // the process for filling the mixed events + void processMixed(FilteredCollisions const& collisions, FilteredTracks const& tracks, aod::BCsWithTimestamps const&) + { + + auto getTracksSize = [&tracks, this](FilteredCollisions::iterator const& collision) { + auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), this->cache); + auto mult = associatedTracks.size(); + return mult; + }; + + using MixedBinning = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getTracksSize)>; + + MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxMix, axisMultMix}, true}; + + auto tracksTuple = std::make_tuple(tracks, tracks); + Pair pairs{binningOnVtxAndMult, cfgMixEventNumMin, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + for (auto it = pairs.begin(); it != pairs.end(); it++) { + auto& [collision1, tracks1, collision2, tracks2] = *it; + if (!collision1.sel8() || !collision2.sel8()) + continue; + + if (cfgSelCollByNch && (tracks1.size() < cfgCutMultMin || tracks1.size() >= cfgCutMultMax)) + continue; + + if (cfgSelCollByNch && (tracks2.size() < cfgCutMultMin || tracks2.size() >= cfgCutMultMax)) + continue; + + float cent1 = -1; + float cent2 = -1; + if (!cfgCentTableUnavailable) { + cent1 = getCentrality(collision1); + cent2 = getCentrality(collision2); + } + if (cfgUseAdditionalEventCut && !eventSelected(collision1, tracks1.size(), cent1, false)) + continue; + if (cfgUseAdditionalEventCut && !eventSelected(collision2, tracks2.size(), cent2, false)) + continue; + + if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent1 < cfgCutCentMin || cent1 >= cfgCutCentMax)) + continue; + + if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent2 < cfgCutCentMin || cent2 >= cfgCutCentMax)) + continue; + + registry.fill(HIST("eventcount"), MixedEvent); // fill the mixed event in the 3 bin + auto bc = collision1.bc_as(); + loadCorrection(bc.timestamp()); + float eventWeight = 1.0f; + if (cfgUseEventWeights) { + eventWeight = 1.0f / it.currentWindowNeighbours(); + } + float weightCent = 1.0f; + if (!cfgCentTableUnavailable) + getCentralityWeight(weightCent, cent1); + + fillCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent, getMagneticField(bc.timestamp()), cent1, eventWeight * weightCent); + } + } + + PROCESS_SWITCH(DiHadronCor, processMixed, "Process mixed events", true); + + int getSpecies(int pdgCode) + { + switch (std::abs(pdgCode)) { + case PDG_t::kPiPlus: // pion + return 0; + case PDG_t::kKPlus: // Kaon + return 1; + case PDG_t::kProton: // proton + return 2; + default: // NOTE. The efficiency histogram is hardcoded to contain 4 species. Anything special will have the last slot. + return 3; + } + } + + void processMCEfficiency(FilteredMcCollisions::iterator const& mcCollision, soa::SmallGroups> const& collisions, FilteredMcParticles const& mcParticles, FilteredTracksWithMCLabels const& tracks) + { + registry.fill(HIST("MCEffeventcount"), 0.5); + if (cfgSelCollByNch && (mcParticles.size() < cfgCutMultMin || mcParticles.size() >= cfgCutMultMax)) { + return; + } + // Primaries + for (const auto& mcParticle : mcParticles) { + if (mcParticle.isPhysicalPrimary()) { + registry.fill(HIST("MCEffeventcount"), 1.5); + same->getTrackHistEfficiency()->Fill(CorrelationContainer::MC, mcParticle.eta(), mcParticle.pt(), getSpecies(mcParticle.pdgCode()), 0., mcCollision.posZ()); + } + } + for (const auto& collision : collisions) { + auto groupedTracks = tracks.sliceBy(perCollision, collision.globalIndex()); + if (cfgVerbosity) { + LOGF(info, " Reconstructed collision at vtx-z = %f", collision.posZ()); + LOGF(info, " which has %d tracks", groupedTracks.size()); + } + + for (const auto& track : groupedTracks) { + if (track.has_mcParticle()) { + auto mcParticle = track.mcParticle(); + if (mcParticle.isPhysicalPrimary()) { + registry.fill(HIST("MCEffeventcount"), 2.5); + same->getTrackHistEfficiency()->Fill(CorrelationContainer::RecoPrimaries, mcParticle.eta(), mcParticle.pt(), getSpecies(mcParticle.pdgCode()), 0., mcCollision.posZ()); + } + registry.fill(HIST("MCEffeventcount"), 3.5); + same->getTrackHistEfficiency()->Fill(CorrelationContainer::RecoAll, mcParticle.eta(), mcParticle.pt(), getSpecies(mcParticle.pdgCode()), 0., mcCollision.posZ()); + } else { + // fake track + registry.fill(HIST("MCEffeventcount"), 4.5); + same->getTrackHistEfficiency()->Fill(CorrelationContainer::Fake, track.eta(), track.pt(), 0, 0., mcCollision.posZ()); + } + } + } + } + PROCESS_SWITCH(DiHadronCor, processMCEfficiency, "MC: Extract efficiencies", false); + + void processMCSame(FilteredMcCollisions::iterator const& mcCollision, FilteredMcParticles const& mcParticles, SmallGroupMcCollisions const& collisions) + { + if (cfgVerbosity) { + LOGF(info, "processMCSame. MC collision: %d, particles: %d, collisions: %d", mcCollision.globalIndex(), mcParticles.size(), collisions.size()); + } + + float cent = -1; + if (!cfgCentTableUnavailable) { + for (const auto& collision : collisions) { + cent = getCentrality(collision); + } + } + + if (cfgSelCollByNch && (mcParticles.size() < cfgCutMultMin || mcParticles.size() >= cfgCutMultMax)) { + return; + } + if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent < cfgCutCentMin || cent >= cfgCutCentMax)) { + return; + } + + registry.fill(HIST("MCTrue/MCeventcount"), SameEvent); // because its same event i put it in the 1 bin + if (!cfgCentTableUnavailable) + registry.fill(HIST("MCTrue/MCCentrality"), cent); + registry.fill(HIST("MCTrue/MCNch"), mcParticles.size()); + registry.fill(HIST("MCTrue/MCzVtx"), mcCollision.posZ()); + for (const auto& mcParticle : mcParticles) { + if (mcParticle.isPhysicalPrimary()) { + registry.fill(HIST("MCTrue/MCPhi"), mcParticle.phi()); + registry.fill(HIST("MCTrue/MCEta"), mcParticle.eta()); + registry.fill(HIST("MCTrue/MCpT"), mcParticle.pt()); + } + } + + same->fillEvent(mcParticles.size(), CorrelationContainer::kCFStepAll); + fillMCCorrelations(mcParticles, mcParticles, mcCollision.posZ(), SameEvent, 1.0f); + + if (collisions.size() == 0) { + return; + } + + registry.fill(HIST("MCTrue/MCeventcount"), 2.5); + same->fillEvent(mcParticles.size(), CorrelationContainer::kCFStepTrackedOnlyPrim); + fillMCCorrelations(mcParticles, mcParticles, mcCollision.posZ(), SameEvent, 1.0f); + } + PROCESS_SWITCH(DiHadronCor, processMCSame, "Process MC same event", false); + + void processMCMixed(FilteredMcCollisions const& mcCollisions, FilteredMcParticles const& mcParticles, SmallGroupMcCollisions const& collisions) + { + auto getTracksSize = [&mcParticles, this](FilteredMcCollisions::iterator const& mcCollision) { + auto associatedTracks = mcParticles.sliceByCached(o2::aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), this->cache); + auto mult = associatedTracks.size(); + return mult; + }; + + using MixedBinning = FlexibleBinningPolicy, o2::aod::mccollision::PosZ, decltype(getTracksSize)>; + + MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxMix, axisMultMix}, true}; + + auto tracksTuple = std::make_tuple(mcParticles, mcParticles); + Pair pairs{binningOnVtxAndMult, cfgMixEventNumMin, -1, mcCollisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + for (auto it = pairs.begin(); it != pairs.end(); it++) { + auto& [collision1, tracks1, collision2, tracks2] = *it; + + if (cfgSelCollByNch && (tracks1.size() < cfgCutMultMin || tracks1.size() >= cfgCutMultMax)) + continue; + + if (cfgSelCollByNch && (tracks2.size() < cfgCutMultMin || tracks2.size() >= cfgCutMultMax)) + continue; + + auto groupedCollisions = collisions.sliceBy(collisionPerMCCollision, collision1.globalIndex()); + if (cfgVerbosity > 0) { + LOGF(info, "Found %d related collisions", groupedCollisions.size()); + } + float cent = -1; + if (!cfgCentTableUnavailable) { + for (const auto& collision : groupedCollisions) { + cent = getCentrality(collision); + } + } + + if (!cfgSelCollByNch && !cfgCentTableUnavailable && groupedCollisions.size() != 0 && (cent < cfgCutCentMin || cent >= cfgCutCentMax)) + continue; + + registry.fill(HIST("MCTrue/MCeventcount"), MixedEvent); // fill the mixed event in the 3 bin + float eventWeight = 1.0f; + if (cfgUseEventWeights) { + eventWeight = 1.0f / it.currentWindowNeighbours(); + } + + fillMCCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent, eventWeight); + + if (groupedCollisions.size() == 0) { + continue; + } + + registry.fill(HIST("MCTrue/MCeventcount"), 4.5); + fillMCCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent, eventWeight); + } + } + PROCESS_SWITCH(DiHadronCor, processMCMixed, "Process MC mixed events", false); + + void processOntheflySame(aod::McCollisions::iterator const& mcCollision, aod::McParticles const& mcParticles) + { + if (cfgVerbosity) { + LOGF(info, "processOntheflySame. MC collision: %d, particles: %d", mcCollision.globalIndex(), mcParticles.size()); + } + + if (cfgSelCollByNch && (mcParticles.size() < cfgCutMultMin || mcParticles.size() >= cfgCutMultMax)) { + return; + } + + registry.fill(HIST("MCTrue/MCeventcount"), SameEvent); // because its same event i put it in the 1 bin + registry.fill(HIST("MCTrue/MCNch"), mcParticles.size()); + registry.fill(HIST("MCTrue/MCzVtx"), mcCollision.posZ()); + for (const auto& mcParticle : mcParticles) { + if (mcParticle.isPhysicalPrimary()) { + registry.fill(HIST("MCTrue/MCPhi"), mcParticle.phi()); + registry.fill(HIST("MCTrue/MCEta"), mcParticle.eta()); + registry.fill(HIST("MCTrue/MCpT"), mcParticle.pt()); + } + } + + same->fillEvent(mcParticles.size(), CorrelationContainer::kCFStepAll); + fillMCCorrelations(mcParticles, mcParticles, mcCollision.posZ(), SameEvent, 1.0f); + + same->fillEvent(mcParticles.size(), CorrelationContainer::kCFStepTrackedOnlyPrim); + fillMCCorrelations(mcParticles, mcParticles, mcCollision.posZ(), SameEvent, 1.0f); + } + PROCESS_SWITCH(DiHadronCor, processOntheflySame, "Process on-the-fly same event", false); + + void processOntheflyMixed(aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) + { + auto getTracksSize = [&mcParticles, this](aod::McCollisions::iterator const& mcCollision) { + auto associatedTracks = mcParticles.sliceByCached(o2::aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), this->cache); + auto mult = associatedTracks.size(); + return mult; + }; + + using MixedBinning = FlexibleBinningPolicy, o2::aod::mccollision::PosZ, decltype(getTracksSize)>; + + MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxMix, axisMultMix}, true}; + + auto tracksTuple = std::make_tuple(mcParticles, mcParticles); + Pair pairs{binningOnVtxAndMult, cfgMixEventNumMin, -1, mcCollisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + for (auto it = pairs.begin(); it != pairs.end(); it++) { + auto& [collision1, tracks1, collision2, tracks2] = *it; + + if (cfgSelCollByNch && (tracks1.size() < cfgCutMultMin || tracks1.size() >= cfgCutMultMax)) + continue; + + if (cfgSelCollByNch && (tracks2.size() < cfgCutMultMin || tracks2.size() >= cfgCutMultMax)) + continue; + + registry.fill(HIST("MCTrue/MCeventcount"), MixedEvent); // fill the mixed event in the 3 bin + float eventWeight = 1.0f; + if (cfgUseEventWeights) { + eventWeight = 1.0f / it.currentWindowNeighbours(); + } + + fillMCCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent, eventWeight); + + fillMCCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent, eventWeight); + } + } + PROCESS_SWITCH(DiHadronCor, processOntheflyMixed, "Process on-the-fly mixed events", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGCF/TwoParticleCorrelations/Tasks/dptDptEfficiencyAndQc.cxx b/PWGCF/TwoParticleCorrelations/Tasks/dptDptEfficiencyAndQc.cxx index fe70e5dcfb5..0fdbca208bf 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/dptDptEfficiencyAndQc.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/dptDptEfficiencyAndQc.cxx @@ -15,9 +15,12 @@ #include #include +#include #include +#include #include #include +#include #include #include #include @@ -38,7 +41,7 @@ #include "PWGCF/Core/AnalysisConfigurableCuts.h" #include "PWGCF/DataModel/DptDptFiltered.h" -#include "PWGCF/TableProducer/dptdptfilter.h" +#include "PWGCF/TableProducer/dptDptFilter.h" using namespace o2; using namespace o2::framework; @@ -59,7 +62,7 @@ TpcExcludeTrack tpcExcluder; ///< the TPC excluder object instance namespace efficiencyandqatask { -/// \enum KindOfProcessQA +/// \enum KindOfData /// \brief The kind of data for templating the procedures enum KindOfData { kReco = 0, ///< processing over reconstructed particles/tracks @@ -70,6 +73,7 @@ enum KindOfData { /// \brief The kind of processing for templating the procedures and produce histograms enum KindOfProcess { kBASIC, ///< produce the basic histograms + kEXTRA, ///< produce the extra pair based histograms kPID, ///< produce the basic PID histograms kPIDEXTRA ///< produce the extra PID histograms }; @@ -91,6 +95,9 @@ float maxNSigma = 4.05f; float widthNSigmaBin = 0.1f; int noOfNSigmaBins = static_cast((maxNSigma - minNSigma) / widthNSigmaBin); +/* the pT bins of interest for the relative separation within TPC sectors data collection */ +std::vector ptBinsOfInterest{}; + /* the PID selector object to help with the configuration and the id of the selected particles */ o2::analysis::dptdptfilter::PIDSpeciesSelection pidselector; @@ -127,14 +134,26 @@ struct QADataCollectingEngine { std::vector> fhPtVsEtaB{2, nullptr}; std::vector> fhPtVsZvtxB{2, nullptr}; std::shared_ptr fhPhiVsPtPosB{nullptr}; + std::shared_ptr fhNchVsPhiVsPtPosB{nullptr}; + TH2* fhPerColNchVsPhiVsPtPosB{nullptr}; std::shared_ptr fhPhiVsInnerWallMomPosB{nullptr}; + std::shared_ptr fhNchVsPhiVsInnerWallMomPosB{nullptr}; + TH2* fhPerColNchVsPhiVsInnerWallMomPosB{nullptr}; std::shared_ptr fhPhiVsPtNegB{nullptr}; + std::shared_ptr fhNchVsPhiVsPtNegB{nullptr}; + TH2* fhPerColNchVsPhiVsPtNegB{nullptr}; std::shared_ptr fhPhiVsInnerWallMomNegB{nullptr}; + std::shared_ptr fhNchVsPhiVsInnerWallMomNegB{nullptr}; + TH2* fhPerColNchVsPhiVsInnerWallMomNegB{nullptr}; std::vector>> fhPtA{2, {nsp, nullptr}}; std::vector>> fhPtVsEtaA{2, {nsp, nullptr}}; std::vector>> fhPtVsZvtxA{2, {nsp, nullptr}}; std::vector> fhPhiVsPtA{nsp, nullptr}; + std::vector> fhNchVsPhiVsPtA{nsp, nullptr}; + std::vector fhPerColNchVsPhiVsPtA{nsp, nullptr}; std::vector> fhPhiVsInnerWallMomA{nsp, nullptr}; + std::vector> fhNchVsPhiVsInnerWallMomA{nsp, nullptr}; + std::vector fhPerColNchVsPhiVsInnerWallMomA{nsp, nullptr}; std::vector> fhPhiShiftedVsPtA{nsp, nullptr}; std::vector> fhPhiShiftedVsInnerWallMomA{nsp, nullptr}; std::shared_ptr fhPtVsEtaItsAcc{nullptr}; @@ -197,13 +216,17 @@ struct QADataCollectingEngine { using namespace analysis::dptdptfilter; AxisSpec pidPtAxis{150, 0.1, 5.0, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec pidPtAxisReduced{50, 0.1, 5.0, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec pidPAxis{150, 0.1, 5.0, "#it{p} (GeV/#it{c})"}; + AxisSpec pidPAxisReduced{50, 0.1, 5.0, "#it{p} (GeV/#it{c})"}; pidPtAxis.makeLogarithmic(); pidPAxis.makeLogarithmic(); const AxisSpec ptAxis{ptbins, ptlow, ptup, "#it{p}_{T} (GeV/c)"}; const AxisSpec etaAxis{etabins, etalow, etaup, "#eta"}; const AxisSpec phiAxis{360, 0.0f, constants::math::TwoPI, "#varphi (rad)"}; - const AxisSpec phiSectorAxis{144, 0.0f, 0.36, "#varphi (mod(2#pi/18) (rad))"}; + const AxisSpec phiSectorAxis{144, 0.0f, 0.36f, "#varphi (mod(2#pi/18) (rad))"}; + const AxisSpec phiSectorAxisReduced{36, 0.0f, 0.36f, "#varphi (mod(2#pi/18) (rad))"}; + const AxisSpec nChargeAxis{100, 0.0f, 100.0f, "#it{N}_{ch}"}; const AxisSpec phiShiftedSectorAxis{220, -55.0f, 55.0f, "% of the sector"}; const AxisSpec zvtxAxis{zvtxbins, zvtxlow, zvtxup, "#it{z}_{vtx}"}; const AxisSpec itsNClsAxis{8, -0.5, 7.5, "ITS n clusters"}; @@ -228,9 +251,13 @@ struct QADataCollectingEngine { if constexpr (kindOfData == kReco) { /* only the reconstructed level histograms*/ fhPhiVsPtPosB = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "PhiVsPtPos", "#varphi (mod(2#pi/18))", kTH2F, {pidPtAxis, phiSectorAxis}); + fhNchVsPhiVsPtPosB = ADDHISTOGRAM(TH3, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "NchVsPhiVsPtPos", "#it{N}_{ch}^{#plus} #varphi (mod(2#pi/18))", kTH3F, {pidPtAxisReduced, phiSectorAxisReduced, nChargeAxis}); fhPhiVsInnerWallMomPosB = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "PhiVsIwMomPos", "#varphi (mod(2#pi/18)) TPC_{iw} #it{p}", kTH2F, {pidPAxis, phiSectorAxis}); + fhNchVsPhiVsInnerWallMomPosB = ADDHISTOGRAM(TH3, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "NchVsPhiVsIwMomPos", "#it{N}_{ch}^{#plus} #varphi (mod(2#pi/18)) TPC_{iw} #it{p}", kTH3F, {pidPAxisReduced, phiSectorAxisReduced, nChargeAxis}); fhPhiVsPtNegB = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "PhiVsPtNeg", "#varphi (mod(2#pi/18))", kTH2F, {pidPtAxis, phiSectorAxis}); + fhNchVsPhiVsPtNegB = ADDHISTOGRAM(TH3, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "NchVsPhiVsPtNeg", "#it{N}_{ch}^{#minus} #varphi (mod(2#pi/18))", kTH3F, {pidPtAxisReduced, phiSectorAxisReduced, nChargeAxis}); fhPhiVsInnerWallMomNegB = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "PhiVsIwMomNeg", "#varphi (mod(2#pi/18)) TPC_{iw} #it{p}", kTH2F, {pidPAxis, phiSectorAxis}); + fhNchVsPhiVsInnerWallMomNegB = ADDHISTOGRAM(TH3, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "NchVsPhiVsIwMomNeg", "#it{N}_{ch}^{#minus} #varphi (mod(2#pi/18)) TPC_{iw} #it{p}", kTH3F, {pidPAxisReduced, phiSectorAxisReduced, nChargeAxis}); fhItsNClsVsPtB = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "ITSNCls", "ITS clusters", kTH2F, {ptAxis, itsNClsAxis}); fhItsChi2NClsVsPtB = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "ITSChi2NCls", "ITS #Chi^{2}", kTH2F, {ptAxis, itsCh2Axis}); fhTpcFindableNClsVsPtB = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "Before"), "TPCFindableNCls", "TPC findable clusters", kTH2F, {ptAxis, tpcNClsAxis}); @@ -248,9 +275,25 @@ struct QADataCollectingEngine { fhPtVsEtaItsTofAcc = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Efficiency", "Reco"), "ptItsTofAcc", "ITS&TOF tracks within the acceptance", kTH2F, {etaAxis, ptAxis}); fhPtVsEtaTpcTofAcc = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Efficiency", "Reco"), "ptTpcTofAcc", "TPC&TOF tracks within the acceptance", kTH2F, {etaAxis, ptAxis}); fhPtVsEtaItsTpcTofAcc = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Efficiency", "Reco"), "ptItsTpcTofAcc", "ITS&TPC&TOF tracks within the acceptance", kTH2F, {etaAxis, ptAxis}); + /* per collision histograms not going to the results file */ + int nPtBins = fhNchVsPhiVsPtPosB->GetNbinsX(); + float ptLow = fhNchVsPhiVsPtNegB->GetXaxis()->GetBinLowEdge(1); + float ptHigh = fhNchVsPhiVsPtNegB->GetXaxis()->GetBinUpEdge(nPtBins); + int nTpcIwMomBins = fhNchVsPhiVsInnerWallMomNegB->GetNbinsX(); + float tpcIwMomLow = fhNchVsPhiVsInnerWallMomNegB->GetXaxis()->GetBinLowEdge(1); + float tpcIwMomHigh = fhNchVsPhiVsInnerWallMomNegB->GetXaxis()->GetBinUpEdge(nTpcIwMomBins); + int nPhiSectorBins = fhNchVsPhiVsPtPosB->GetNbinsY(); + float phiSectorLow = fhNchVsPhiVsPtNegB->GetYaxis()->GetBinLowEdge(1); + float phiSectorHigh = fhNchVsPhiVsPtNegB->GetYaxis()->GetBinUpEdge(nPhiSectorBins); + fhPerColNchVsPhiVsPtPosB = new TH2F(TString::Format("%s_PerColNchVsPhiVsPtPosB", dirname), "", nPtBins, ptLow, ptHigh, nPhiSectorBins, phiSectorLow, phiSectorHigh); + fhPerColNchVsPhiVsInnerWallMomPosB = new TH2F(TString::Format("%s_PerColNchVsPhiVsInnerWallMomPosB", dirname), "", nTpcIwMomBins, tpcIwMomLow, tpcIwMomHigh, nPhiSectorBins, phiSectorLow, phiSectorHigh); + fhPerColNchVsPhiVsPtNegB = new TH2F(TString::Format("%s_PerColNchVsPhiVsPtNegB", dirname), "", nPtBins, ptLow, ptHigh, nPhiSectorBins, phiSectorLow, phiSectorHigh); + fhPerColNchVsPhiVsInnerWallMomNegB = new TH2F(TString::Format("%s_PerColNchVsPhiVsInnerWallMomNegB", dirname), "", nTpcIwMomBins, tpcIwMomLow, tpcIwMomHigh, nPhiSectorBins, phiSectorLow, phiSectorHigh); for (uint isp = 0; isp < nsp; ++isp) { fhPhiVsPtA[isp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "After"), HNAMESTRING("PhiVsPt_%s", tnames[isp].c_str()), HTITLESTRING("#varphi %s (mod(2#pi/18))", tnames[isp].c_str()), kTH2F, {pidPtAxis, phiSectorAxis}); + fhNchVsPhiVsPtA[isp] = ADDHISTOGRAM(TH3, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "After"), HNAMESTRING("NchVsPhiVsPt_%s", tnames[isp].c_str()), HTITLESTRING("#it{N}_{ch}^{%s} #varphi (mod(2#pi/18))", tnames[isp].c_str()), kTH3F, {pidPtAxisReduced, phiSectorAxisReduced, nChargeAxis}); fhPhiVsInnerWallMomA[isp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "After"), HNAMESTRING("PhiVsIwMom_%s", tnames[isp].c_str()), HTITLESTRING("#varphi %s (mod(2#pi/18)) TPC_{iw} #it{p}", tnames[isp].c_str()), kTH2F, {pidPAxis, phiSectorAxis}); + fhNchVsPhiVsInnerWallMomA[isp] = ADDHISTOGRAM(TH3, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "After"), HNAMESTRING("NchVsPhiVsIwMom_%s", tnames[isp].c_str()), HTITLESTRING("#it{N}_{ch}^{%s} #varphi (mod(2#pi/18)) TPC_{iw} #it{p}", tnames[isp].c_str()), kTH3F, {pidPAxisReduced, phiSectorAxisReduced, nChargeAxis}); fhPhiShiftedVsPtA[isp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "After"), HNAMESTRING("PhiShiftedVsPt_%s", tnames[isp].c_str()), HTITLESTRING("%s TPC sector %%", tnames[isp].c_str()), kTH2F, {pidPtAxis, phiShiftedSectorAxis}); fhPhiShiftedVsInnerWallMomA[isp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "After"), HNAMESTRING("PhiShiftedVsIwMom_%s", tnames[isp].c_str()), HTITLESTRING("%s TPC sector %% TPC_{iw} #it{p}", tnames[isp].c_str()), kTH2F, {pidPAxis, phiShiftedSectorAxis}); fhItsNClsVsPtA[isp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Reco", "After"), HNAMESTRING("ITSNCls_%s", tnames[isp].c_str()), HTITLESTRING("ITS clusters %s", tnames[isp].c_str()), kTH2F, {ptAxis, itsNClsAxis}); @@ -269,6 +312,9 @@ struct QADataCollectingEngine { fhPtVsEtaItsTofA[isp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Efficiency", "Reco"), HNAMESTRING("ptItsTof_%s", tnames[isp].c_str()), HTITLESTRING("ITS&TOF %s tracks", tnames[isp].c_str()), kTH2F, {etaAxis, ptAxis}); fhPtVsEtaTpcTofA[isp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Efficiency", "Reco"), HNAMESTRING("ptTpcTof_%s", tnames[isp].c_str()), HTITLESTRING("TPC&TOF %s tracks", tnames[isp].c_str()), kTH2F, {etaAxis, ptAxis}); fhPtVsEtaItsTpcTofA[isp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "Efficiency", "Reco"), HNAMESTRING("ptItsTpcTof_%s", tnames[isp].c_str()), HTITLESTRING("ITS&TPC&TOF %s tracks", tnames[isp].c_str()), kTH2F, {etaAxis, ptAxis}); + /* per collision histograms not going to the results file */ + fhPerColNchVsPhiVsPtA[isp] = new TH2F(HNAMESTRING("%s_PerColNchVsPhiVsPt_%s", dirname, tnames[isp].c_str()), "", nPtBins, ptLow, ptHigh, nPhiSectorBins, phiSectorLow, phiSectorHigh); + fhPerColNchVsPhiVsInnerWallMomA[isp] = new TH2F(HNAMESTRING("%s_PerColNchVsPhiVsInnerWallMom_%s", dirname, tnames[isp].c_str()), "", nTpcIwMomBins, tpcIwMomLow, tpcIwMomHigh, nPhiSectorBins, phiSectorLow, phiSectorHigh); } } else { AxisSpec recoSpecies{static_cast(nsp) + 1, -0.5, nsp - 0.5, "reco species"}; @@ -346,6 +392,9 @@ struct QADataCollectingEngine { using namespace analysis::dptdptfilter; using namespace o2::aod::track; + constexpr float kFiftyPerCent = 50.0f; + constexpr float kHundredPerCent = 100.0f; + fhPtB[kindOfData]->Fill(track.pt()); fhPtVsEtaB[kindOfData]->Fill(track.eta(), track.pt()); fhPtVsZvtxB[kindOfData]->Fill(zvtx, track.pt()); @@ -366,13 +415,17 @@ struct QADataCollectingEngine { float phiInTpcSector = std::fmod(track.phi(), kTpcPhiSectorWidth); float phiShiftedPercentInTpcSector = phiInTpcSector * 100 / kTpcPhiSectorWidth; - phiShiftedPercentInTpcSector = (phiShiftedPercentInTpcSector > 50.0f) ? (phiShiftedPercentInTpcSector - 100.0f) : phiShiftedPercentInTpcSector; + phiShiftedPercentInTpcSector = (phiShiftedPercentInTpcSector > kFiftyPerCent) ? (phiShiftedPercentInTpcSector - kHundredPerCent) : phiShiftedPercentInTpcSector; if (track.sign() > 0) { fhPhiVsPtPosB->Fill(track.pt(), phiInTpcSector); + fhPerColNchVsPhiVsPtPosB->Fill(track.pt(), phiInTpcSector); fhPhiVsInnerWallMomPosB->Fill(track.tpcInnerParam(), phiInTpcSector); + fhPerColNchVsPhiVsInnerWallMomPosB->Fill(track.tpcInnerParam(), phiInTpcSector); } else { fhPhiVsPtNegB->Fill(track.pt(), phiInTpcSector); + fhPerColNchVsPhiVsPtNegB->Fill(track.pt(), phiInTpcSector); fhPhiVsInnerWallMomNegB->Fill(track.tpcInnerParam(), phiInTpcSector); + fhPerColNchVsPhiVsInnerWallMomNegB->Fill(track.tpcInnerParam(), phiInTpcSector); } fhItsNClsVsPtB->Fill(track.pt(), track.itsNCls()); fhItsChi2NClsVsPtB->Fill(track.pt(), track.itsChi2NCl()); @@ -394,7 +447,9 @@ struct QADataCollectingEngine { } if (!(track.trackacceptedid() < 0)) { fhPhiVsPtA[track.trackacceptedid()]->Fill(track.pt(), phiInTpcSector); + fhPerColNchVsPhiVsPtA[track.trackacceptedid()]->Fill(track.pt(), phiInTpcSector); fhPhiVsInnerWallMomA[track.trackacceptedid()]->Fill(track.tpcInnerParam(), phiInTpcSector); + fhPerColNchVsPhiVsInnerWallMomA[track.trackacceptedid()]->Fill(track.tpcInnerParam(), phiInTpcSector); fhPhiShiftedVsPtA[track.trackacceptedid()]->Fill(track.pt(), phiShiftedPercentInTpcSector); fhPhiShiftedVsInnerWallMomA[track.trackacceptedid()]->Fill(track.tpcInnerParam(), phiShiftedPercentInTpcSector); fhItsNClsVsPtA[track.trackacceptedid()]->Fill(track.pt(), track.itsNCls()); @@ -439,7 +494,7 @@ struct QADataCollectingEngine { float genid = findgenid(mcparticle); bool isprimary = mcparticle.isPhysicalPrimary(); - bool issecdecay = !isprimary && (mcparticle.getProcess() == 4); + bool issecdecay = !isprimary && (mcparticle.getProcess() == TMCProcess::kPDecay); bool isfrommaterial = !isprimary && !issecdecay; fillpurityhistos(fhPtPurityPosPrimA, fhPtPurityNegPrimA, genid, track, isprimary); fillpurityhistos(fhPtPurityPosSecA, fhPtPurityNegSecA, genid, track, issecdecay); @@ -473,7 +528,7 @@ struct QADataCollectingEngine { /* pure generator level */ if (track.isPhysicalPrimary()) { fhPtVsEtaPrimA[track.trackacceptedid()]->Fill(track.eta(), track.pt()); - } else if (track.getProcess() == 4) { + } else if (track.getProcess() == TMCProcess::kPDecay) { fhPtVsEtaSecA[track.trackacceptedid()]->Fill(track.eta(), track.pt()); } else { fhPtVsEtaMatA[track.trackacceptedid()]->Fill(track.eta(), track.pt()); @@ -481,6 +536,178 @@ struct QADataCollectingEngine { } } } + + template + void newCollision() + { + using namespace efficiencyandqatask; + if constexpr (kindOfData == kReco) { + fhPerColNchVsPhiVsPtPosB->Reset(); + fhPerColNchVsPhiVsPtNegB->Reset(); + fhPerColNchVsPhiVsInnerWallMomPosB->Reset(); + fhPerColNchVsPhiVsInnerWallMomNegB->Reset(); + for (uint isp = 0; isp < nsp; ++isp) { + fhPerColNchVsPhiVsPtA[isp]->Reset(); + fhPerColNchVsPhiVsInnerWallMomA[isp]->Reset(); + } + } + } + + template + void finishedCollision() + { + using namespace efficiencyandqatask; + if constexpr (kindOfData == kReco) { + auto fillHistogram = [](auto& th, const TH2* sh) { + int nBinsX = sh->GetNbinsX(); + int nBinsY = sh->GetNbinsY(); + for (int ix = 0; ix < nBinsX; ++ix) { + for (int iy = 0; iy < nBinsY; ++iy) { + th->Fill(sh->GetXaxis()->GetBinCenter(ix + 1), sh->GetYaxis()->GetBinCenter(iy + 1), sh->GetBinContent(ix + 1, iy + 1)); + } + } + }; + fillHistogram(fhNchVsPhiVsPtPosB, fhPerColNchVsPhiVsPtPosB); + fillHistogram(fhNchVsPhiVsPtNegB, fhPerColNchVsPhiVsPtNegB); + fillHistogram(fhNchVsPhiVsInnerWallMomPosB, fhPerColNchVsPhiVsInnerWallMomPosB); + fillHistogram(fhNchVsPhiVsInnerWallMomNegB, fhPerColNchVsPhiVsInnerWallMomNegB); + for (uint isp = 0; isp < nsp; ++isp) { + fillHistogram(fhNchVsPhiVsPtA[isp], fhPerColNchVsPhiVsPtA[isp]); + fillHistogram(fhNchVsPhiVsInnerWallMomA[isp], fhPerColNchVsPhiVsInnerWallMomA[isp]); + } + } + } +}; + +/* the QA extra data, pairs, collecting engine */ +struct QAExtraDataCollectingEngine { + uint nsp = static_cast(efficiencyandqatask::tnames.size()); + uint nmainsp = static_cast(efficiencyandqatask::mainspnames.size()); + uint nallmainsp = static_cast(efficiencyandqatask::allmainspnames.size()); + + //=================================================== + // The QA output objects + //=================================================== + /* pairs histograms */ + constexpr static size_t kNoOfOverflowBins = 2; + constexpr static int kBinNotTracked = -1; + std::vector>>> fhPhiPhiA{2, {nsp, {nsp, nullptr}}}; + std::vector>>> fhEtaEtaA{2, {nsp, {nsp, nullptr}}}; + std::vector>>> fhN2VsDeltaEtaVsDeltaPhi{2, {nsp, {nsp, nullptr}}}; + TAxis ptAxis{analysis::dptdptfilter::ptbins, analysis::dptdptfilter::ptlow, analysis::dptdptfilter::ptup}; + std::vector ptOfInterestBinMap; + std::vector>>> fhInSectorDeltaPhiVsPhiPhiPerPtBinA{2, {nsp, {nsp, nullptr}}}; + std::vector>>> fhInSectorDeltaPhiVsEtaEtaPerPtBinA{2, {nsp, {nsp, nullptr}}}; + + QAExtraDataCollectingEngine() + { + using namespace efficiencyandqatask; + using namespace analysis::dptdptfilter; + + /* the mapping between pT bins of interest and internal representation, and histogram title to keep track of them offline */ + /* it is done once for both reco and gen */ + ptOfInterestBinMap = std::vector(static_cast(ptbins + kNoOfOverflowBins), kBinNotTracked); + LOGF(info, "Configuring the pT bins of interest on a map of length %d", ptOfInterestBinMap.size()); + for (size_t ix = 0; ix < ptBinsOfInterest.size(); ++ix) { + /* remember our internal axis starts in 0.5 value, i.e. its first central value is 1 */ + ptOfInterestBinMap[ptBinsOfInterest[ix]] = ix + 1; + LOGF(info, " Added pT bin %d as internal axis value %d", ptBinsOfInterest[ix], ptOfInterestBinMap[ptBinsOfInterest[ix]]); + } + } + + template + void init(HistogramRegistry& registry, const char* dirname) + { + using namespace efficiencyandqatask; + using namespace analysis::dptdptfilter; + + AxisSpec phiAxis = {phibins, 0.0f, constants::math::TwoPI, "#varphi"}; + AxisSpec phiSectorAxis = {72, 0.0f, kTpcPhiSectorWidth, "#varphi (mod(2#pi/18)) (rad)"}; + AxisSpec deltaPhiAxis = {phibins, 0.0f, constants::math::TwoPI, "#Delta#varphi (rad)"}; + AxisSpec deltaEtaAxis = {2 * etabins - 1, etalow - etaup, etaup - etalow, "#Delta#eta"}; + AxisSpec deltaPhiInSectorAxis = {144, -kTpcPhiSectorWidth, kTpcPhiSectorWidth, "#Delta#varphi (rad)"}; + AxisSpec etaAxis = {etabins, etalow, etaup, "#eta"}; + AxisSpec ptOfInterestAxis = {static_cast(ptBinsOfInterest.size()), 0.5f, static_cast(ptBinsOfInterest.size()) + 0.5f, "#it{p}_{T} (GeV/#it{c})"}; + + /* the reconstructed and generated levels histograms */ + std::string recogen = (kindOfData == kReco) ? "Reco" : "Gen"; + + /* the mapping between pT bins of interest and internal representation, and histogram title to keep track of them offline */ + LOGF(info, "Configured at %s level the pT bins of interest on a map of length %d", recogen.c_str(), ptOfInterestBinMap.size()); + std::string hPtRangesOfInterestTitle; + bool firstRange = true; + for (size_t ix = 0; ix < ptOfInterestBinMap.size(); ++ix) { + if (ptOfInterestBinMap[ix] != kBinNotTracked) { + TString ptRange = TString::Format("%s%.2f-%.2f", firstRange ? "" : ",", ptAxis.GetBinLowEdge(ix), ptAxis.GetBinUpEdge(ix)); + hPtRangesOfInterestTitle += ptRange.Data(); + LOGF(info, " Tracking pT bin %d as internal axis value %d", ix, ptOfInterestBinMap[ix]); + firstRange = false; + } + } + LOGF(info, " Final pT bins tilte: %s", hPtRangesOfInterestTitle.c_str()); + + for (uint isp = 0; isp < nsp; ++isp) { + for (uint jsp = 0; jsp < nsp; ++jsp) { + fhPhiPhiA[kindOfData][isp][jsp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, recogen.c_str(), "After"), HNAMESTRING("PhiPhi_%s%s", tnames[isp].c_str(), tnames[jsp].c_str()), + HTITLESTRING("%s%s pairs", tnames[isp].c_str(), tnames[jsp].c_str()), kTH2F, {phiAxis, phiAxis}); + fhEtaEtaA[kindOfData][isp][jsp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, recogen.c_str(), "After"), HNAMESTRING("EtaEta_%s%s", tnames[isp].c_str(), tnames[jsp].c_str()), + HTITLESTRING("%s%s pairs", tnames[isp].c_str(), tnames[jsp].c_str()), kTH2F, {etaAxis, etaAxis}); + fhN2VsDeltaEtaVsDeltaPhi[kindOfData][isp][jsp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, recogen.c_str(), "After"), HNAMESTRING("N2VsDeltaEtaDeltaPhi_%s%s", tnames[isp].c_str(), tnames[jsp].c_str()), + HTITLESTRING("%s%s pairs", tnames[isp].c_str(), tnames[jsp].c_str()), kTH2F, {deltaEtaAxis, deltaPhiAxis}); + fhInSectorDeltaPhiVsPhiPhiPerPtBinA[kindOfData][isp][jsp] = ADDHISTOGRAM(THnSparse, DIRECTORYSTRING("%s/%s/%s", dirname, recogen.c_str(), "After"), HNAMESTRING("DeltaPhiVsPhiPhiPt_%s%s", tnames[isp].c_str(), tnames[jsp].c_str()), + HTITLESTRING("%s%s pairs, #it{p}_{T}: %s", tnames[isp].c_str(), tnames[jsp].c_str(), hPtRangesOfInterestTitle.c_str()), + kTHnSparseF, {phiSectorAxis, phiSectorAxis, deltaPhiInSectorAxis, ptOfInterestAxis, ptOfInterestAxis}); + fhInSectorDeltaPhiVsEtaEtaPerPtBinA[kindOfData][isp][jsp] = ADDHISTOGRAM(THnSparse, DIRECTORYSTRING("%s/%s/%s", dirname, recogen.c_str(), "After"), HNAMESTRING("DeltaPhiVsEtaEtaPt_%s%s", tnames[isp].c_str(), tnames[jsp].c_str()), + HTITLESTRING("%s%s pairs, #it{p}_{T}: %s", tnames[isp].c_str(), tnames[jsp].c_str(), hPtRangesOfInterestTitle.c_str()), + kTHnSparseF, {etaAxis, etaAxis, deltaPhiInSectorAxis, ptOfInterestAxis, ptOfInterestAxis}); + } + } + } + + template + void processTrackPairs(TracksObject const& tracks1, TracksObject const& tracks2) + { + using namespace efficiencyandqatask; + using namespace analysis::dptdptfilter; + float deltaEtaSpan = etaup - etalow; + + /* we should only receive accepted tracks */ + for (auto const& track1 : tracks1) { + auto binForPt = [&](auto const& track) { + return ptOfInterestBinMap[ptAxis.FindFixBin(track.pt())]; + }; + int ptBin1 = binForPt(track1); + if (ptBin1 != kBinNotTracked) { + float inTpcSectorPhi1 = std::fmod(track1.phi(), kTpcPhiSectorWidth); + for (auto const& track2 : tracks2) { + /* checking the same track id condition */ + if (track1 == track2) { + /* exclude autocorrelations */ + continue; + } + int ptBin2 = binForPt(track2); + if (ptBin2 != kBinNotTracked) { + float deltaPhi = RecoDecay::constrainAngle(track1.phi() - track2.phi()); + float deltaEta = track1.eta() - track2.eta(); + float preWeight = 1 - std::abs(deltaEta) / deltaEtaSpan; + float weight = preWeight != 0 ? 1.0f / preWeight : 0.0f; + fhPhiPhiA[kindOfData][track1.trackacceptedid()][track2.trackacceptedid()]->Fill(track1.phi(), track2.phi(), weight); + fhEtaEtaA[kindOfData][track1.trackacceptedid()][track2.trackacceptedid()]->Fill(track1.eta(), track2.eta()); + fhN2VsDeltaEtaVsDeltaPhi[kindOfData][track1.trackacceptedid()][track2.trackacceptedid()]->Fill(deltaEta, deltaPhi, weight); + if (static_cast(track1.phi() / kTpcPhiSectorWidth) == static_cast(track2.phi() / kTpcPhiSectorWidth)) { + /* only if, for sure, both tracks are within the same sector */ + float inTpcSectorPhi2 = std::fmod(track2.phi(), kTpcPhiSectorWidth); + float inTpcSectorDeltaPhi = inTpcSectorPhi1 - inTpcSectorPhi2; + double values[] = {inTpcSectorPhi1, inTpcSectorPhi2, inTpcSectorDeltaPhi, static_cast(ptBin1), static_cast(ptBin2)}; + fhInSectorDeltaPhiVsPhiPhiPerPtBinA[kindOfData][track1.trackacceptedid()][track2.trackacceptedid()]->Fill(values, weight); + values[0] = track1.eta(), values[1] = track2.eta(); + fhInSectorDeltaPhiVsEtaEtaPerPtBinA[kindOfData][track1.trackacceptedid()][track2.trackacceptedid()]->Fill(values, weight); + } + } + } + } + } + } }; /* the PID data collecting engine */ @@ -489,16 +716,18 @@ struct PidDataCollectingEngine { uint nmainsp = static_cast(efficiencyandqatask::mainspnames.size()); uint nallmainsp = static_cast(efficiencyandqatask::allmainspnames.size()); + constexpr static uint kNoOfSteps = 2; /* Before and after track selection */ + /* PID histograms */ /* before and after */ - std::vector> fhTPCdEdxSignalVsP{2, nullptr}; - std::vector>> fhTPCdEdxSignalDiffVsP{2, {nmainsp, nullptr}}; - std::vector>> fhTPCnSigmasVsP{2, {nallmainsp, nullptr}}; - std::vector> fhTOFSignalVsP{2, nullptr}; - std::vector>> fhTOFSignalDiffVsP{2, {nmainsp, nullptr}}; - std::vector>> fhTOFnSigmasVsP{2, {nallmainsp, nullptr}}; - std::vector> fhPvsTOFSqMass{2, nullptr}; - std::vector>> fhTPCTOFSigmaVsP{2, {nmainsp, nullptr}}; + std::vector> fhTPCdEdxSignalVsP{kNoOfSteps, nullptr}; + std::vector>> fhTPCdEdxSignalDiffVsP{kNoOfSteps, {nmainsp, nullptr}}; + std::vector>> fhTPCnSigmasVsP{kNoOfSteps, {nallmainsp, nullptr}}; + std::vector> fhTOFSignalVsP{kNoOfSteps, nullptr}; + std::vector>> fhTOFSignalDiffVsP{kNoOfSteps, {nmainsp, nullptr}}; + std::vector>> fhTOFnSigmasVsP{kNoOfSteps, {nallmainsp, nullptr}}; + std::vector> fhPvsTOFSqMass{kNoOfSteps, nullptr}; + std::vector>> fhTPCTOFSigmaVsP{kNoOfSteps, {nmainsp, nullptr}}; template void init(HistogramRegistry& registry, const char* dirname) @@ -512,9 +741,9 @@ struct PidDataCollectingEngine { if constexpr (kindOfData == kReco) { /* PID histograms */ std::vector whenname{"Before", "After"}; - char whenprefix[2]{'B', 'A'}; + constexpr char whenprefix[kNoOfSteps]{'B', 'A'}; std::vector whentitle{"before", ""}; - for (uint ix = 0; ix < whenname.size(); ++ix) { + for (uint ix = 0; ix < kNoOfSteps; ++ix) { fhTPCdEdxSignalVsP[ix] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "PID", whenname[ix].c_str()), HNAMESTRING("tpcSignalVsP%c", whenprefix[ix]), HTITLESTRING("TPC dE/dx signal %s", whentitle[ix].c_str()), kTH2F, {pidPAxis, dEdxAxis}); @@ -562,7 +791,7 @@ struct PidDataCollectingEngine { } else { ix = 2 * ix; } - for (uint when = 0; when < 2; ++when) { + for (uint when = 0; when < kNoOfSteps; ++when) { fhTPCnSigmasVsP[when][ix]->Fill(tpcmom, o2::aod::pidutils::tpcNSigma(track)); fhTOFnSigmasVsP[when][ix]->Fill(tofmom, o2::aod::pidutils::tofNSigma(track)); if (track.trackacceptedid() < 0) { @@ -580,7 +809,7 @@ struct PidDataCollectingEngine { } else { ix = 2 * ix; } - for (uint when = 0; when < 2; ++when) { + for (uint when = 0; when < kNoOfSteps; ++when) { fhTPCdEdxSignalDiffVsP[when][ix]->Fill(tpcmom, o2::aod::pidutils::tpcExpSignalDiff(track)); fhTOFSignalDiffVsP[when][ix]->Fill(tofmom, o2::aod::pidutils::tofExpSignalDiff(track)); fhTPCTOFSigmaVsP[when][ix]->Fill(tpcmom, o2::aod::pidutils::tpcNSigma(track), o2::aod::pidutils::tofNSigma(track)); @@ -594,7 +823,7 @@ struct PidDataCollectingEngine { template void fillPID(TrackObject const& track, float tpcmom, float tofmom) { - for (uint when = 0; when < 2; ++when) { + for (uint when = 0; when < kNoOfSteps; ++when) { if constexpr (framework::has_type_v) { fhTPCdEdxSignalVsP[when]->Fill(tpcmom, track.mcTunedTPCSignal()); } else { @@ -654,6 +883,7 @@ struct PidExtraDataCollectingEngine { const AxisSpec dEdxAxis{200, 0.0, 200.0, "dE/dx (au)"}; AxisSpec pidPAxis{150, 0.1, 5.0, "#it{p} (GeV/#it{c})"}; pidPAxis.makeLogarithmic(); + constexpr int kEvenOddBase = 2; if constexpr (kindOfData == kReco) { /* PID histograms */ @@ -676,7 +906,7 @@ struct PidExtraDataCollectingEngine { kTProfile2D, {pidPAxis, {200, 0.0, 1.1, "#beta"}}); for (uint imainsp = 0; imainsp < nallmainsp; ++imainsp) { /* only the same charge makes any sense */ - if (isp % 2 == imainsp % 2) { + if (isp % kEvenOddBase == imainsp % kEvenOddBase) { fhIdTPCnSigmasVsP[isp][imainsp] = ADDHISTOGRAM(TH2, DIRECTORYSTRING("%s/%s/%s", dirname, "PID", "Selected"), HNAMESTRING("tpcNSigmasVsPSelected_%s_to%s", tnames[isp].c_str(), allmainspnames[imainsp].c_str()), HTITLESTRING("TPC n#sigma for selected %s to the %s line", tnames[isp].c_str(), allmainsptitles[imainsp].c_str()), @@ -764,6 +994,7 @@ struct DptDptEfficiencyAndQc { /* the data collecting engine instances */ QADataCollectingEngine** qaDataCE; + QAExtraDataCollectingEngine** qaExtraDataCE; PidDataCollectingEngine** pidDataCE; PidExtraDataCollectingEngine** pidExtraDataCE; @@ -778,6 +1009,16 @@ struct DptDptEfficiencyAndQc { HistogramRegistry registryEight{"registryEight", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry registryNine{"registryNine", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry registryTen{"registryTen", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraOne{"extraregistryOne", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraTwo{"extraregistryTwo", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraThree{"extraregistryThree", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraFour{"extraregistryFour", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraFive{"extraregistryFive", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraSix{"extraregistrySix", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraSeven{"extraregistrySeven", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraEight{"extraregistryEight", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraNine{"extraregistryNine", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryExtraTen{"extraregistryTen", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry registryPidOne{"pidregistryOne", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry registryPidTwo{"pidregistryTwo", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry registryPidThree{"pidregistryThree", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -788,9 +1029,11 @@ struct DptDptEfficiencyAndQc { HistogramRegistry registryPidEight{"pidregistryEight", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry registryPidNine{"pidregistryNine", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry registryPidTen{"pidregistryTen", {}, OutputObjHandlingPolicy::AnalysisObject}; - std::vector registrybank{®istryOne, ®istryTwo, ®istryThree, ®istryFour, ®istryFive, + std::vector registryBank{®istryOne, ®istryTwo, ®istryThree, ®istryFour, ®istryFive, ®istrySix, ®istrySeven, ®istryEight, ®istryNine, ®istryTen}; - std::vector pidregistrybank{®istryPidOne, ®istryPidTwo, ®istryPidThree, ®istryPidFour, ®istryPidFive, + std::vector extraRegistryBank{®istryExtraOne, ®istryExtraTwo, ®istryExtraThree, ®istryExtraFour, ®istryExtraFive, + ®istryExtraSix, ®istryExtraSeven, ®istryExtraEight, ®istryExtraNine, ®istryExtraTen}; + std::vector pidRegistryBank{®istryPidOne, ®istryPidTwo, ®istryPidThree, ®istryPidFour, ®istryPidFive, ®istryPidSix, ®istryPidSeven, ®istryPidEight, ®istryPidNine, ®istryPidTen}; Configurable useCentrality{"useCentrality", false, "Perform the task using centrality/multiplicity classes. Default value: false"}; @@ -798,6 +1041,7 @@ struct DptDptEfficiencyAndQc { Configurable cfgMinNSigma{"cfgMinNSigma", -4.05f, "nsigma axes lowest value. Default: -4.05"}; Configurable cfgMaxNSigma{"cfgMaxNSigma", 4.05f, "nsigma axes highest value. Default: 4.05"}; Configurable cfgWidthNSigmaBin{"cfgWidthNSigmaBin", 0.1, "nsigma axes bin width. Deafault: 0.1"}; + Configurable> cfgPtBinsOfInterest{"cfgPtBinsOfInterest", {1, 2, 3}, "The pt bins of interest"}; void init(o2::framework::InitContext& initContext) { @@ -806,10 +1050,15 @@ struct DptDptEfficiencyAndQc { /* do nothing if not active */ if (!doprocessDetectorLevelNotStored && + !doprocessExtraDetectorLevelNotStored && !doprocessDetectorLevelNotStoredPID && + !doprocessDetectorLevelNotStoredTunedOnDataPID && !doprocessDetectorLevelNotStoredPIDExtra && + !doprocessDetectorLevelNotStoredTunedOnDataPIDExtra && !doprocessGeneratorLevelNotStored && + !doprocessExtraGeneratorLevelNotStored && !doprocessReconstructedNotStored && + !doprocessExtraReconstructedNotStored && !doprocessReconstructedNotStoredPID && !doprocessReconstructedNotStoredPIDExtra) { return; @@ -818,19 +1067,20 @@ struct DptDptEfficiencyAndQc { /* Self configuration: requires dptdptfilter task in the workflow */ { /* the binning */ - getTaskOptionValue(initContext, "dpt-dpt-filter", "overallminp", overallminp, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mZVtxbins", zvtxbins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mZVtxmin", zvtxlow, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mZVtxmax", zvtxup, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPTbins", ptbins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPTmin", ptlow, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mPTmax", ptup, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mEtabins", etabins, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mEtamin", etalow, false); - getTaskOptionValue(initContext, "dpt-dpt-filter", "binning.mEtamax", etaup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgOverallMinP", overallminp, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mZVtxbins", zvtxbins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mZVtxmin", zvtxlow, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mZVtxmax", zvtxup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPTbins", ptbins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPTmin", ptlow, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPTmax", ptup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mEtabins", etabins, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mEtamin", etalow, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mEtamax", etaup, false); + getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgBinning.mPhibins", phibins, false); /* configuring the involved species */ - std::vector cfgnames = {"elpidsel", "mupidsel", "pipidsel", "kapidsel", "prpidsel"}; + std::vector cfgnames = {"cfgElectronPIDSelection", "cfgMuonPIDSelection", "cfgPionPIDSelection", "cfgKaonPIDSelection", "cfgProtonPIDSelection"}; std::vector spids = {0, 1, 2, 3, 4}; for (uint i = 0; i < cfgnames.size(); ++i) { auto includeIt = [&initContext](int spid, auto name) { @@ -866,7 +1116,7 @@ struct DptDptEfficiencyAndQc { /* create the data collecting engine instances according to the configured centrality/multiplicity ranges */ std::string centspec; - if (useCentrality.value && getTaskOptionValue(initContext, "dpt-dpt-filter", "centralities", centspec, false)) { + if (useCentrality.value && getTaskOptionValue(initContext, "dpt-dpt-filter", "cfgCentSpec", centspec, false)) { LOGF(info, "Got the centralities specification: %s", centspec.c_str()); auto tokens = TString(centspec.c_str()).Tokenize(","); ncmranges = tokens->GetEntries(); @@ -894,13 +1144,24 @@ struct DptDptEfficiencyAndQc { widthNSigmaBin = cfgWidthNSigmaBin.value; noOfNSigmaBins = static_cast((maxNSigma - minNSigma) / widthNSigmaBin); - bool doBasicAnalysis = doprocessDetectorLevelNotStored || doprocessReconstructedNotStored; - bool doPidAnalysis = doprocessDetectorLevelNotStoredPID || doprocessReconstructedNotStoredPID; - bool doPidExtraAnalysis = doprocessDetectorLevelNotStoredPIDExtra || doprocessReconstructedNotStoredPIDExtra; + /* configure the pT bins of interest */ + TAxis ptAxis{ptbins, ptlow, ptup}; + for (const int& bin : cfgPtBinsOfInterest.value) { + ptBinsOfInterest.push_back(bin); + LOGF(info, "Inserted pT bin %d: %.2f < pT < %.2f GeV/c", bin, ptAxis.GetBinLowEdge(bin), ptAxis.GetBinUpEdge(bin)); + } + + bool doBasicAnalysis = doprocessDetectorLevelNotStored || doprocessReconstructedNotStored || doprocessGeneratorLevelNotStored; + bool doExtraAnalysis = doprocessExtraDetectorLevelNotStored || doprocessExtraReconstructedNotStored || doprocessExtraGeneratorLevelNotStored; + bool doPidAnalysis = doprocessDetectorLevelNotStoredPID || doprocessDetectorLevelNotStoredTunedOnDataPID || doprocessReconstructedNotStoredPID; + bool doPidExtraAnalysis = doprocessDetectorLevelNotStoredPIDExtra || doprocessDetectorLevelNotStoredTunedOnDataPIDExtra || doprocessReconstructedNotStoredPIDExtra; if (doBasicAnalysis) { qaDataCE = new QADataCollectingEngine*[ncmranges]; } + if (doExtraAnalysis) { + qaExtraDataCE = new QAExtraDataCollectingEngine*[ncmranges]; + } if (doPidAnalysis) { pidDataCE = new PidDataCollectingEngine*[ncmranges]; } @@ -908,38 +1169,52 @@ struct DptDptEfficiencyAndQc { pidExtraDataCE = new PidExtraDataCollectingEngine*[ncmranges]; } std::string recogen; - if (ncmranges > registrybank.size()) { + if (ncmranges > registryBank.size()) { LOGF(fatal, "There are more centrality ranges configured than registries in the bank. Please fix it!"); } /* in reverse order for proper order in results file */ for (uint i = 0; i < ncmranges; ++i) { - auto initializeCEInstance = [&](auto dce, auto name, auto& registry) { + auto initializeCEInstance = [&](auto dce, auto name, auto& registry, bool reclevel, bool genlevel) { /* crete the output list for the passed centrality/multiplicity range */ /* init the data collection instance */ - dce->template init(registry, name.Data()); - if (doprocessGeneratorLevelNotStored) { + if (reclevel) { + dce->template init(registry, name.Data()); + } + if (genlevel) { dce->template init(registry, name.Data()); } }; auto buildQACEInstance = [&](float min, float max) { auto* dce = new QADataCollectingEngine(); - initializeCEInstance(dce, TString::Format("EfficiencyAndQaData-%d-%d", static_cast(min), static_cast(max)), *registrybank[i]); + initializeCEInstance(dce, TString::Format("EfficiencyAndQaData-%d-%d", static_cast(min), static_cast(max)), *registryBank[i], + doprocessReconstructedNotStored || doprocessDetectorLevelNotStored, doprocessGeneratorLevelNotStored); + return dce; + }; + auto buildQACEExtraInstance = [&](float min, float max) { + auto* dce = new QAExtraDataCollectingEngine(); + initializeCEInstance(dce, TString::Format("EfficiencyAndQaExtraData-%d-%d", static_cast(min), static_cast(max)), *extraRegistryBank[i], + doprocessExtraReconstructedNotStored || doprocessExtraDetectorLevelNotStored, doprocessExtraGeneratorLevelNotStored); return dce; }; auto buildPidCEInstance = [&](float min, float max) { auto* dce = new PidDataCollectingEngine(); - initializeCEInstance(dce, TString::Format("EfficiencyAndPidData-%d-%d", static_cast(min), static_cast(max)), *pidregistrybank[i]); + initializeCEInstance(dce, TString::Format("EfficiencyAndPidData-%d-%d", static_cast(min), static_cast(max)), *pidRegistryBank[i], + doprocessReconstructedNotStoredPID || doprocessDetectorLevelNotStoredPID || doprocessDetectorLevelNotStoredTunedOnDataPID, doprocessGeneratorLevelNotStored); return dce; }; auto buildPidExtraCEInstance = [&](float min, float max) { auto* dce = new PidExtraDataCollectingEngine(); - initializeCEInstance(dce, TString::Format("EfficiencyAndPidData-%d-%d", static_cast(min), static_cast(max)), *pidregistrybank[i]); + initializeCEInstance(dce, TString::Format("EfficiencyAndPidData-%d-%d", static_cast(min), static_cast(max)), *pidRegistryBank[i], + doprocessReconstructedNotStoredPIDExtra || doprocessDetectorLevelNotStoredPIDExtra || doprocessDetectorLevelNotStoredTunedOnDataPIDExtra, doprocessGeneratorLevelNotStored); return dce; }; /* in reverse order for proper order in results file */ if (doBasicAnalysis) { qaDataCE[ncmranges - i - 1] = buildQACEInstance(fCentMultMin[ncmranges - i - 1], fCentMultMax[ncmranges - i - 1]); } + if (doExtraAnalysis) { + qaExtraDataCE[ncmranges - i - 1] = buildQACEExtraInstance(fCentMultMin[ncmranges - i - 1], fCentMultMax[ncmranges - i - 1]); + } if (doPidAnalysis) { pidDataCE[ncmranges - i - 1] = buildPidCEInstance(fCentMultMin[ncmranges - i - 1], fCentMultMax[ncmranges - i - 1]); } @@ -984,24 +1259,35 @@ struct DptDptEfficiencyAndQc { int ixDCE = getDCEindex(collision); if (!(ixDCE < 0)) { - for (auto const& track : tracks) { - float tpcmom = track.p(); - float tofmom = track.p(); - if (useTPCInnerWallMomentum.value) { - if constexpr (!framework::has_type_v) { - tpcmom = track.tpcInnerParam(); + if constexpr (kindOfProcess == kBASIC) { + qaDataCE[ixDCE]->newCollision(); + } + if constexpr (kindOfProcess == kEXTRA) { + qaExtraDataCE[ixDCE]->processTrackPairs(tracks, tracks); + } + if constexpr (kindOfProcess == kBASIC || kindOfProcess == kPID || kindOfProcess == kPIDEXTRA) { + for (auto const& track : tracks) { + float tpcmom = track.p(); + float tofmom = track.p(); + if (useTPCInnerWallMomentum.value) { + if constexpr (!framework::has_type_v) { + tpcmom = track.tpcInnerParam(); + } + } + if constexpr (kindOfProcess == kBASIC) { + qaDataCE[ixDCE]->processTrack(collision.posZ(), track); + } + if constexpr (kindOfProcess == kPID) { + pidDataCE[ixDCE]->processTrack(track, tpcmom, tofmom); + } + if constexpr (kindOfProcess == kPIDEXTRA) { + pidExtraDataCE[ixDCE]->processTrack(track, tpcmom, tofmom); } - } - if constexpr (kindOfProcess == kBASIC) { - qaDataCE[ixDCE]->processTrack(collision.posZ(), track); - } - if constexpr (kindOfProcess == kPID) { - pidDataCE[ixDCE]->processTrack(track, tpcmom, tofmom); - } - if constexpr (kindOfProcess == kPIDEXTRA) { - pidExtraDataCE[ixDCE]->processTrack(track, tpcmom, tofmom); } } + if constexpr (kindOfProcess == kBASIC) { + qaDataCE[ixDCE]->finishedCollision(); + } } } @@ -1015,6 +1301,7 @@ struct DptDptEfficiencyAndQc { using TofPID = soa::Join; Filter onlyacceptedcollisions = (aod::dptdptfilter::collisionaccepted == uint8_t(true)); + Filter onlyacceptedtracks = (aod::dptdptfilter::trackacceptedid >= int8_t(0)); void processReconstructedNotStored(soa::Filtered>::iterator const& collision, soa::Join const& tracks) @@ -1044,6 +1331,34 @@ struct DptDptEfficiencyAndQc { } PROCESS_SWITCH(DptDptEfficiencyAndQc, processGeneratorLevelNotStored, "Process MC generator level efficiency and QA for not stored derived data", true); + void processExtraReconstructedNotStored(soa::Filtered>::iterator const& collision, + soa::Filtered> const& tracks) + { + using namespace efficiencyandqatask; + + processTracks>, kEXTRA, kReco>(collision, tracks); + } + PROCESS_SWITCH(DptDptEfficiencyAndQc, processExtraReconstructedNotStored, "Process reconstructed extra efficiency and QA for not stored derived data", false); + + void processExtraDetectorLevelNotStored(soa::Filtered>::iterator const& collision, + soa::Filtered> const& tracks, + soa::Join const&) + { + using namespace efficiencyandqatask; + + processTracks>, kEXTRA, kReco>(collision, tracks); + } + PROCESS_SWITCH(DptDptEfficiencyAndQc, processExtraDetectorLevelNotStored, "Process MC detector level extra efficiency and QA for not stored derived data", false); + + void processExtraGeneratorLevelNotStored(soa::Filtered>::iterator const& collision, + soa::Filtered> const& particles) + { + using namespace efficiencyandqatask; + + processTracks>, kEXTRA, kGen>(collision, particles); + } + PROCESS_SWITCH(DptDptEfficiencyAndQc, processExtraGeneratorLevelNotStored, "Process MC generator level extra efficiency and QA for not stored derived data", true); + void processReconstructedNotStoredPID(soa::Filtered>::iterator const& collision, soa::Join const& tracks) { @@ -1070,7 +1385,17 @@ struct DptDptEfficiencyAndQc { processTracks>, kPID, kReco>(collision, tracks); } - PROCESS_SWITCH(DptDptEfficiencyAndQc, processDetectorLevelNotStoredPID, "Process MC detector level PID QA for not stored derived data", true); + PROCESS_SWITCH(DptDptEfficiencyAndQc, processDetectorLevelNotStoredPID, "Process MC detector level PID QA for not stored derived data", false); + + void processDetectorLevelNotStoredTunedOnDataPID(soa::Filtered>::iterator const& collision, + soa::Join const& tracks, + soa::Join const&) + { + using namespace efficiencyandqatask; + + processTracks>, kPID, kReco>(collision, tracks); + } + PROCESS_SWITCH(DptDptEfficiencyAndQc, processDetectorLevelNotStoredTunedOnDataPID, "Process MC detector level tuned on data PID QA for not stored derived data", true); void processDetectorLevelNotStoredPIDExtra(soa::Filtered>::iterator const& collision, soa::Join const& tracks, @@ -1080,7 +1405,17 @@ struct DptDptEfficiencyAndQc { processTracks>, kPIDEXTRA, kReco>(collision, tracks); } - PROCESS_SWITCH(DptDptEfficiencyAndQc, processDetectorLevelNotStoredPIDExtra, "Process MC detector level PID extra QA for not stored derived data", true); + PROCESS_SWITCH(DptDptEfficiencyAndQc, processDetectorLevelNotStoredPIDExtra, "Process MC detector level PID extra QA for not stored derived data", false); + + void processDetectorLevelNotStoredTunedOnDataPIDExtra(soa::Filtered>::iterator const& collision, + soa::Join const& tracks, + soa::Join const&) + { + using namespace efficiencyandqatask; + + processTracks>, kPIDEXTRA, kReco>(collision, tracks); + } + PROCESS_SWITCH(DptDptEfficiencyAndQc, processDetectorLevelNotStoredTunedOnDataPIDExtra, "Process MC detector level tuned on data PID extra QA for not stored derived data", true); }; using BCsWithTimestamps = soa::Join; diff --git a/PWGCF/TwoParticleCorrelations/Tasks/perRunExtraQc.cxx b/PWGCF/TwoParticleCorrelations/Tasks/dptDptPerRunExtraQc.cxx similarity index 76% rename from PWGCF/TwoParticleCorrelations/Tasks/perRunExtraQc.cxx rename to PWGCF/TwoParticleCorrelations/Tasks/dptDptPerRunExtraQc.cxx index ce09b4fed46..8617a65de2f 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/perRunExtraQc.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/dptDptPerRunExtraQc.cxx @@ -8,12 +8,14 @@ // 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. -// -// Minimal example to run this task: -// o2-analysis-centrality-table -b --configuration json://configuration.json | o2-analysis-timestamp -b --configuration json://configuration.json | o2-analysis-event-selection -b --configuration json://configuration.json | o2-analysis-multiplicity-table -b --configuration json://configuration.json | o2-analysis-lf-zdcsp -b --configuration json://configuration.json --aod-file @input_data.txt --aod-writer-json OutputDirector.json + +/// \file dptDptPerRunExtraQc.cxx +/// \brief basic per run check of the per analyzed species p vs TPC IW momentum +/// \author victor.gonzalez.sebastian@gmail.com #include #include +#include #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" @@ -22,7 +24,7 @@ #include "Framework/runDataProcessing.h" #include "PWGCF/DataModel/DptDptFiltered.h" -#include "PWGCF/TableProducer/dptdptfilter.h" +#include "PWGCF/TableProducer/dptDptFilter.h" using namespace o2; using namespace o2::framework; @@ -31,21 +33,21 @@ using namespace o2::constants::physics; using BCsWithTimestamps = soa::Join; -namespace perrunextraqa +namespace perrunextraqc { std::unordered_map gRunMapPvsTpcIwP; TProfile3D* gCurrentRunPvsPtcIwP; -} // namespace perrunextraqa +} // namespace perrunextraqc -struct DptDptPerRunExtraQa { +struct DptDptPerRunExtraQc { int mRunNumber{-1}; AxisSpec qaPAxis{150, 0.1, 5.0}; - HistogramRegistry mHistos{"PerRunExtraQaHistograms", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry mHistos{"PerRunExtraQcHistograms", {}, OutputObjHandlingPolicy::AnalysisObject}; void initRunNumber(aod::BCsWithTimestamps::iterator const& bc) { - using namespace perrunextraqa; + using namespace perrunextraqc; if (mRunNumber == bc.runNumber()) { return; @@ -60,7 +62,7 @@ struct DptDptPerRunExtraQa { void init(InitContext&) { - using namespace perrunextraqa; + using namespace perrunextraqc; qaPAxis.makeLogarithmic(); } @@ -68,9 +70,9 @@ struct DptDptPerRunExtraQa { template void processTracks(PassedTracks const& tracks) { - using namespace perrunextraqa; + using namespace perrunextraqc; - for (auto& track : tracks) { + for (const auto& track : tracks) { gCurrentRunPvsPtcIwP->Fill(track.trackacceptedid(), track.p(), track.tpcInnerParam(), track.pt()); } } @@ -95,5 +97,5 @@ struct DptDptPerRunExtraQa { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGCF/TwoParticleCorrelations/Tasks/dptDptPerRunQc.cxx b/PWGCF/TwoParticleCorrelations/Tasks/dptDptPerRunQc.cxx new file mode 100644 index 00000000000..598d3305539 --- /dev/null +++ b/PWGCF/TwoParticleCorrelations/Tasks/dptDptPerRunQc.cxx @@ -0,0 +1,142 @@ +// 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. + +/// \file dptDptPerRunQc.cxx +/// \brief basic per run check of the ITS dead chips and of the hadronic interaction rate +/// \author victor.gonzalez.sebastian@gmail.com + +#include +#include +#include +#include +#include +#include + +#include "CCDB/BasicCCDBManager.h" +#include "Common/CCDB/ctpRateFetcher.h" + +#include "DataFormatsParameters/AggregatedRunInfo.h" +#include "DataFormatsITSMFT/NoiseMap.h" // missing include in TimeDeadMap.h +#include "DataFormatsITSMFT/TimeDeadMap.h" +#include "ITSMFTReconstruction/ChipMappingITS.h" + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "PWGCF/DataModel/DptDptFiltered.h" +#include "PWGCF/TableProducer/dptDptFilter.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using BCsWithTimestamps = soa::Join; + +namespace perrunqctask +{ +static const int32_t nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; +std::unordered_map gHadronicRate; +std::unordered_map> gCollisionOrbitBefore; +std::unordered_map> gCollisionOrbitAfter; + +TH2* gCurrentHadronicRate; +std::shared_ptr gCurrentCollisionOrbitBefore; +std::shared_ptr gCurrentCollisionOrbitAfter; +} // namespace perrunqctask + +struct DptDptPerRunQc { + + Service ccdb; + + int mRunNumber{-1}; + double mMinSeconds{-1.}; + + ctpRateFetcher mRateFetcher; + HistogramRegistry mHistos{"PerRunQaHistograms", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Configurable cfgInteractionRateSource{"cfgInteractionRateSource", "ZNC hadronic", "The shource for the interaction rate measure.PbPb:ZNC hadronic;pp:T0VTX.Default:ZNC hadronic"}; + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + using namespace perrunqctask; + using namespace analysis::dptdptfilter; + + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + if (gHadronicRate.find(mRunNumber) == gHadronicRate.end()) { + auto runDuration = ccdb->getRunDuration(mRunNumber); + uint64_t mSOR = runDuration.first; + mMinSeconds = std::floor(mSOR * 1.e-3); /// round tsSOR to the highest integer lower than tsSOR + double maxSec = std::ceil(runDuration.second * 1.e-3); /// round tsEOR to the lowest integer higher than tsEOR + const AxisSpec axisSeconds{static_cast(maxSec - mMinSeconds), 0, maxSec - mMinSeconds, "Seconds since SOR"}; + gHadronicRate[mRunNumber] = mHistos.add(Form("%i/hadronicRate", mRunNumber), ";Time since SOR (s);Hadronic rate (kHz)", kTH2D, {{static_cast((maxSec - mMinSeconds) / 20.f), 0, maxSec - mMinSeconds, "Seconds since SOR"}, {1010, 0., 1010.}}).get(); + + /* initializing the ITS chips dead map orbit axis*/ + /* inspired in DPG/Tasks/AOTEvent/eventSelectionQa.cxx */ + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), mRunNumber); + int64_t tsSOR = runInfo.sor; + int64_t tsEOR = runInfo.eor; + o2::itsmft::TimeDeadMap* itsDeadMap = ccdb->getForTimeStamp("ITS/Calib/TimeDeadMap", (tsSOR + tsEOR) / 2); + auto itsDeadMapOrbits = itsDeadMap->getEvolvingMapKeys(); // roughly every second, ~350 TFs = 350x32 orbits + if (itsDeadMapOrbits.size() > 0) { + std::vector itsDeadMapOrbitsDouble(itsDeadMapOrbits.begin(), itsDeadMapOrbits.end()); + const AxisSpec axisItsDeadMapOrbits{itsDeadMapOrbitsDouble}; + gCollisionOrbitBefore[mRunNumber] = mHistos.add(TString::Format("%d/Before/hCollisionOrbitB", mRunNumber), "Collision orbit before; orbit", kTH1I, {axisItsDeadMapOrbits}); + gCollisionOrbitAfter[mRunNumber] = mHistos.add(TString::Format("%d/After/hCollisionOrbitA", mRunNumber), "Collision orbit; orbit", kTH1I, {axisItsDeadMapOrbits}); + gCurrentCollisionOrbitBefore = gCollisionOrbitBefore[mRunNumber]; + gCurrentCollisionOrbitAfter = gCollisionOrbitAfter[mRunNumber]; + } else { + gCurrentCollisionOrbitBefore = nullptr; + gCurrentCollisionOrbitAfter = nullptr; + } + LOGF(info, "Run number: %d, SOR: %lld, EOR: %lld, prev SOR: %lld, prev EOR: %lld, SOR seconds: %f", mRunNumber, tsSOR, tsEOR, mSOR, runDuration.second, mMinSeconds); + } + gCurrentHadronicRate = gHadronicRate[mRunNumber]; + } + + void init(o2::framework::InitContext&) + { + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setFatalWhenNull(false); + } + + void process(soa::Join::iterator const& collision, aod::BCsWithTimestamps const&) + { + using namespace perrunqctask; + using namespace analysis::dptdptfilter; + + auto bc = collision.bc_as(); + initCCDB(bc); + int64_t orbit = bc.globalBC() / nBCsPerOrbit; + gCurrentCollisionOrbitBefore->Fill(orbit); + + if (!collision.collisionaccepted()) { + return; + } + + double hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, cfgInteractionRateSource) * 1.e-3; // + double seconds = bc.timestamp() * 1.e-3 - mMinSeconds; + gCurrentHadronicRate->Fill(seconds, hadronicRate); + gCurrentCollisionOrbitAfter->Fill(orbit); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/TwoParticleCorrelations/Tasks/identifiedbf.cxx b/PWGCF/TwoParticleCorrelations/Tasks/identifiedbf.cxx index 83bd0629020..b357272c17c 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/identifiedbf.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/identifiedbf.cxx @@ -9,8 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file identifiedbf.cxx +/// \brief Fills histograms with particles and tracks to calculate the Balance Function +/// \author bghanley1995@gmail.com #include -#include #include #include #include @@ -23,16 +25,21 @@ #include #include #include +#include +#include +#include #include "Common/Core/TrackSelection.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/RecoDecay.h" #include "DataFormatsParameters/GRPObject.h" #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "PWGCF/Core/AnalysisConfigurableCuts.h" #include "PWGCF/Core/PairCuts.h" #include "PWGCF/TwoParticleCorrelations/DataModel/IdentifiedBfFiltered.h" @@ -60,6 +67,8 @@ float deltaphibinwidth = constants::math::TwoPI / deltaphibins; float deltaphilow = 0.0 - deltaphibinwidth / 2.0; float deltaphiup = constants::math::TwoPI - deltaphibinwidth / 2.0; +int maxLogComb = 10; + bool processpairs = false; bool processmixedevents = false; bool ptorder = false; @@ -72,7 +81,7 @@ std::vector tname = {"e+", "e-", "pi+", "pi-", "K+", "K-", "p+", "p } // namespace correlationstask // Task for building correlations -struct IdentifiedBfCorrelationsTask { +struct IdentifiedbfTask { /* the data collecting engine */ template @@ -85,31 +94,34 @@ struct IdentifiedBfCorrelationsTask { //============================================================================================ /* histograms */ TH1F* fhVertexZA; //! fhN1_vsPt{nch, nullptr}; //! fhN1_vsEtaPhi{nch, nullptr}; //! fhSum1Pt_vsEtaPhi{nch, nullptr}; //! fhN1_vsZEtaPhiPt{nch, nullptr}; //! fhSum1Pt_vsZEtaPhiPt{nch, nullptr}; //! fhNuaNue_vsZEtaPhiPt{nch, nullptr}; //! fhPtAvg_vsEtaPhi{nch, nullptr}; //!> fhN2_vsPtPt{nch, {nch, nullptr}}; //!> fhN2_vsDEtaDPhi{nch, {nch, nullptr}}; //!> fhN2cont_vsDEtaDPhi{nch, {nch, nullptr}}; //!> fhSum2PtPt_vsDEtaDPhi{nch, {nch, nullptr}}; //!> fhSum2DptDpt_vsDEtaDPhi{nch, {nch, nullptr}}; //!) ({p_T}_2 - <{p_T}_2>) \f$ distribution vs \f$\Delta\eta,\;\Delta\phi\f$ for the different species combinations - std::vector> fhSupN1N1_vsDEtaDPhi{nch, {nch, nullptr}}; //!> fhSupPt1Pt1_vsDEtaDPhi{nch, {nch, nullptr}}; //! fhN1VsPt{nch, nullptr}; //! fhN1VsEtaPhi{nch, nullptr}; //! fhSum1PtVsEtaPhi{nch, nullptr}; //! fhN1VsZEtaPhiPt{nch + 1, nullptr}; //! fhN1VsZEtaPhiPtPrimary{nch, nullptr}; //! fhN1VsZEtaPhiPtSecondary{nch, nullptr}; //! fhN1VsZEtaPhiPtPure{nch + 1, nullptr}; //! fhSum1PtVsZEtaPhiPt{nch, nullptr}; //! fhNuaNueVsZEtaPhiPt{nch, nullptr}; //! fhPtAvgVsEtaPhi{nch, nullptr}; //!> fhN2VsPtPt{nch, {nch, nullptr}}; //!> fhN2VsDEtaDPhi{nch, {nch, nullptr}}; //!> fhN2ContVsDEtaDPhi{nch, {nch, nullptr}}; //!> fhSum2PtPtVsDEtaDPhi{nch, {nch, nullptr}}; //!> fhSum2DptDptVsDEtaDPhi{nch, {nch, nullptr}}; //!) ({p_T}_2 - <{p_T}_2>) \f$ distribution vs \f$\Delta\eta,\;\Delta\phi\f$ for the different species combinations + std::vector> fhSupN1N1VsDEtaDPhi{nch, {nch, nullptr}}; //!> fhSupPt1Pt1VsDEtaDPhi{nch, {nch, nullptr}}; //! fhN1_vsC{nch, nullptr}; //! fhSum1Pt_vsC{nch, nullptr}; //! fhN1nw_vsC{nch, nullptr}; //! fhSum1Ptnw_vsC{nch, nullptr}; //!> fhN2_vsC{nch, {nch, nullptr}}; //!> fhSum2PtPt_vsC{nch, {nch, nullptr}}; //!> fhSum2DptDpt_vsC{nch, {nch, nullptr}}; //!) ({p_T}_2 - <{p_T}_2>) \f$ distribution vs event centrality/multiplicity 1-1,1-2,2-1,2-2, combinations - std::vector> fhN2nw_vsC{nch, {nch, nullptr}}; //!> fhSum2PtPtnw_vsC{nch, {nch, nullptr}}; //!> fhSum2DptDptnw_vsC{nch, {nch, nullptr}}; //!) ({p_T}_2 - <{p_T}_2>) \f$ distribution vs \f$\Delta\eta,\;\Delta\phi\f$ distribution vs event centrality/multiplicity 1-1,1-2,2-1,2-2, combinations + std::vector fhN1VsC{nch, nullptr}; //! fhSum1PtVsC{nch, nullptr}; //! fhN1NWVsC{nch, nullptr}; //! fhSum1PtNWVsC{nch, nullptr}; //!> fhN2VsC{nch, {nch, nullptr}}; //!> fhSum2PtPtVsC{nch, {nch, nullptr}}; //!> fhSum2DptDptVsC{nch, {nch, nullptr}}; //!) ({p_T}_2 - <{p_T}_2>) \f$ distribution vs event centrality/multiplicity 1-1,1-2,2-1,2-2, combinations + std::vector> fhN2NWVsC{nch, {nch, nullptr}}; //!> fhSum2PtPtNWVsC{nch, {nch, nullptr}}; //!> fhSum2DptDptNWVsC{nch, {nch, nullptr}}; //!) ({p_T}_2 - <{p_T}_2>) \f$ distribution vs \f$\Delta\eta,\;\Delta\phi\f$ distribution vs event centrality/multiplicity 1-1,1-2,2-1,2-2, combinations std::vector> chargePairsNames = {{"OO", "OT"}, {"TO", "TT"}}; std::vector> speciesPairNames = {{"e+e+", "e+e-", "e+pi+", "e+pi-", "e+K+", "e+K-", "e+p+", "e+p-"}, @@ -130,15 +142,12 @@ struct IdentifiedBfCorrelationsTask { /// \brief Returns the potentially phi origin shifted phi /// \param phi the track azimuthal angle /// \return the track phi origin shifted azimuthal angle - float GetShiftedPhi(float phi) + float getShiftedPhi(float phi) { using namespace correlationstask; using namespace o2::analysis::identifiedbffilter; - if (!(phi < phiup)) { - return phi - constants::math::TwoPI; - } else { - return phi; - } + phi = RecoDecay::constrainAngle(phi, philow, 1U); + return phi; } /// \brief Returns the zero based bin index of the eta phi passed track @@ -154,14 +163,14 @@ struct IdentifiedBfCorrelationsTask { /// the track has been accepted and it is within that ranges /// IF THAT IS NOT THE CASE THE ROUTINE WILL PRODUCE NONSENSE RESULTS template - int GetEtaPhiIndex(TrackObject const& t) + int getEtaPhiIndex(TrackObject const& t) { using namespace correlationstask; using namespace o2::analysis::identifiedbffilter; int etaix = static_cast((t.eta() - etalow) / etabinwidth); /* consider a potential phi origin shift */ - float phi = GetShiftedPhi(t.phi()); + float phi = getShiftedPhi(t.phi()); int phiix = static_cast((phi - philow) / phibinwidth); return etaix * phibins + phiix; } @@ -176,28 +185,28 @@ struct IdentifiedBfCorrelationsTask { /// the tracks have been accepted and they are within that ranges /// IF THAT IS NOT THE CASE THE ROUTINE WILL PRODUCE NONSENSE RESULTS template - int GetDEtaDPhiGlobalIndex(TrackObject const& t1, TrackObject const& t2) + int getDEtaDPhiGlobalIndex(TrackObject const& t1, TrackObject const& t2) { using namespace correlationstask; using namespace o2::analysis::identifiedbffilter; /* rule: ix are always zero based while bins are always one based */ - int etaix_1 = static_cast((t1.eta() - etalow) / etabinwidth); + int etaix1 = static_cast((t1.eta() - etalow) / etabinwidth); /* consider a potential phi origin shift */ - float phi = GetShiftedPhi(t1.phi()); - int phiix_1 = static_cast((phi - philow) / phibinwidth); - int etaix_2 = static_cast((t2.eta() - etalow) / etabinwidth); + float phi = getShiftedPhi(t1.phi()); + int phiix1 = static_cast((phi - philow) / phibinwidth); + int etaix2 = static_cast((t2.eta() - etalow) / etabinwidth); /* consider a potential phi origin shift */ - phi = GetShiftedPhi(t2.phi()); - int phiix_2 = static_cast((phi - philow) / phibinwidth); + phi = getShiftedPhi(t2.phi()); + int phiix2 = static_cast((phi - philow) / phibinwidth); - int deltaeta_ix = etaix_1 - etaix_2 + etabins - 1; - int deltaphi_ix = phiix_1 - phiix_2; - if (deltaphi_ix < 0) { - deltaphi_ix += phibins; + int deltaetaix = etaix1 - etaix2 + etabins - 1; + int deltaphiix = phiix1 - phiix2; + if (deltaphiix < 0) { + deltaphiix += phibins; } - return fhN2_vsDEtaDPhi[0][0]->GetBin(deltaeta_ix + 1, deltaphi_ix + 1); + return fhN2VsDEtaDPhi[0][0]->GetBin(deltaetaix + 1, deltaphiix + 1); } void storeTrackCorrections(std::vector corrs) @@ -205,15 +214,15 @@ struct IdentifiedBfCorrelationsTask { LOGF(info, "Stored NUA&NUE corrections for %d track ids", corrs.size()); for (uint i = 0; i < corrs.size(); ++i) { LOGF(info, " Stored NUA&NUE corrections %s for track id %d %s", corrs[i] != nullptr ? corrs[i]->GetName() : "nullptr", i, corrs[i] != nullptr ? "yes" : "no"); - fhNuaNue_vsZEtaPhiPt[i] = corrs[i]; - if (fhNuaNue_vsZEtaPhiPt[i] != nullptr) { + fhNuaNueVsZEtaPhiPt[i] = corrs[i]; + if (fhNuaNueVsZEtaPhiPt[i] != nullptr) { int nbins = 0; double avg = 0.0; - for (int ix = 0; ix < fhNuaNue_vsZEtaPhiPt[i]->GetNbinsX(); ++ix) { - for (int iy = 0; iy < fhNuaNue_vsZEtaPhiPt[i]->GetNbinsY(); ++iy) { - for (int iz = 0; iz < fhNuaNue_vsZEtaPhiPt[i]->GetNbinsZ(); ++iz) { + for (int ix = 0; ix < fhNuaNueVsZEtaPhiPt[i]->GetNbinsX(); ++ix) { + for (int iy = 0; iy < fhNuaNueVsZEtaPhiPt[i]->GetNbinsY(); ++iy) { + for (int iz = 0; iz < fhNuaNueVsZEtaPhiPt[i]->GetNbinsZ(); ++iz) { nbins++; - avg += fhNuaNue_vsZEtaPhiPt[i]->GetBinContent(ix + 1, iy + 1, iz + 1); + avg += fhNuaNueVsZEtaPhiPt[i]->GetBinContent(ix + 1, iy + 1, iz + 1); } } } @@ -228,7 +237,7 @@ struct IdentifiedBfCorrelationsTask { LOGF(info, "Stored pT average for %d track ids", ptavgs.size()); for (uint i = 0; i < ptavgs.size(); ++i) { LOGF(info, " Stored pT average for track id %d %s", i, ptavgs[i] != nullptr ? "yes" : "no"); - fhPtAvg_vsEtaPhi[i] = ptavgs[i]; + fhPtAvgVsEtaPhi[i] = ptavgs[i]; } ccdbstored = true; } @@ -238,9 +247,9 @@ struct IdentifiedBfCorrelationsTask { { std::vector* corr = new std::vector(tracks.size(), 1.0f); int index = 0; - for (auto& t : tracks) { - if (fhNuaNue_vsZEtaPhiPt[t.trackacceptedid()] != nullptr) { - (*corr)[index] = fhNuaNue_vsZEtaPhiPt[t.trackacceptedid()]->GetBinContent(fhNuaNue_vsZEtaPhiPt[t.trackacceptedid()]->FindFixBin(zvtx, GetEtaPhiIndex(t) + 0.5, t.pt())); + for (const auto& t : tracks) { + if (fhNuaNueVsZEtaPhiPt[t.trackacceptedid()] != nullptr) { + (*corr)[index] = fhNuaNueVsZEtaPhiPt[t.trackacceptedid()]->GetBinContent(fhNuaNueVsZEtaPhiPt[t.trackacceptedid()]->FindFixBin(zvtx, getEtaPhiIndex(t) + 0.5, t.pt())); } index++; } @@ -252,15 +261,93 @@ struct IdentifiedBfCorrelationsTask { { std::vector* ptavg = new std::vector(tracks.size(), 0.0f); int index = 0; - for (auto& t : tracks) { - if (fhPtAvg_vsEtaPhi[t.trackacceptedid()] != nullptr) { - (*ptavg)[index] = fhPtAvg_vsEtaPhi[t.trackacceptedid()]->GetBinContent(fhPtAvg_vsEtaPhi[t.trackacceptedid()]->FindFixBin(t.eta(), t.phi())); + for (const auto& t : tracks) { + if (fhPtAvgVsEtaPhi[t.trackacceptedid()] != nullptr) { + (*ptavg)[index] = fhPtAvgVsEtaPhi[t.trackacceptedid()]->GetBinContent(fhPtAvgVsEtaPhi[t.trackacceptedid()]->FindFixBin(t.eta(), t.phi())); index++; } } return ptavg; } + /// \brief checks whether MC track is a physical primary or secondary + /// \param track passed MC track converted to MCParticle + template + void trackPrimaryCheck(TrackObject const& track, float zvtx, float corr) + { + if constexpr (framework::has_type_v) { + if (isPrimaryCheck(track.template mcParticle_as())) { + fhN1VsZEtaPhiPtPrimary[track.trackacceptedid()]->Fill(zvtx, getEtaPhiIndex(track) + 0.5, track.pt(), corr); + } else { + fhN1VsZEtaPhiPtSecondary[track.trackacceptedid()]->Fill(zvtx, getEtaPhiIndex(track) + 0.5, track.pt(), corr); + } + } else if constexpr (framework::has_type_v) { + if (isPrimaryCheck(track)) { + fhN1VsZEtaPhiPtPrimary[track.trackacceptedid()]->Fill(zvtx, getEtaPhiIndex(track) + 0.5, track.pt(), corr); + } else { + fhN1VsZEtaPhiPtSecondary[track.trackacceptedid()]->Fill(zvtx, getEtaPhiIndex(track) + 0.5, track.pt(), corr); + } + } + } + + /// \brief checks whether MC track is a physical primary or secondary + /// \param particle passed MC track converted to MCParticle + template + bool isPrimaryCheck(ParticleObject const& particle) + { + return particle.isPhysicalPrimary(); + } + + /// \brief checks whether MC track is a physical primary or secondary + /// \param particle passed MC track converted to MCParticle + template + bool isSpeciesCheck(ParticleObject const& particle, int trkId) + { + int pdgcode = particle.pdgCode(); + int realPID = -1; + switch (pdgcode) { + case kPositron: + realPID = 0; + break; + case kElectron: + realPID = 1; + break; + case kPiPlus: + realPID = 2; + break; + case kPiMinus: + realPID = 3; + break; + case kKPlus: + realPID = 4; + break; + case kKMinus: + realPID = 5; + break; + case kProton: + realPID = 6; + break; + case kProtonBar: + realPID = 7; + break; + default: + realPID = -1; + break; + } + return (realPID == trkId); + } + + /// \brief checks whether MC track is a physical primary or secondary + /// \param particle passed MC track converted to MCParticle + template + bool isPrimarySpeciesCheck(TrackObject const& track, int trkId) + { + if constexpr (framework::has_type_v) { + return (isPrimaryCheck(track.template mcParticle_as()) && isSpeciesCheck(track.template mcParticle_as(), trkId)); + } + return false; + } + /// \brief fills the singles histograms in singles execution mode /// \param passedtracks filtered table with the tracks associated to the passed index /// \param tix index, in the singles histogram bank, for the passed filetered track table @@ -268,15 +355,20 @@ struct IdentifiedBfCorrelationsTask { void processSingles(TrackListObject const& passedtracks, std::vector* corrs, float zvtx) { int index = 0; - for (auto& track : passedtracks) { + for (const auto& track : passedtracks) { float corr = (*corrs)[index]; - fhN1_vsPt[track.trackacceptedid()]->Fill(track.pt(), corr); + fhN1VsPt[track.trackacceptedid()]->Fill(track.pt(), corr); if constexpr (smallsingles) { - fhN1_vsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), GetShiftedPhi(track.phi()), corr); - fhSum1Pt_vsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), GetShiftedPhi(track.phi()), track.pt() * corr); + fhN1VsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), getShiftedPhi(track.phi()), corr); + fhSum1PtVsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), getShiftedPhi(track.phi()), track.pt() * corr); } else { - fhN1_vsZEtaPhiPt[track.trackacceptedid()]->Fill(zvtx, GetEtaPhiIndex(track) + 0.5, track.pt(), corr); - fhSum1Pt_vsZEtaPhiPt[track.trackacceptedid()]->Fill(zvtx, GetEtaPhiIndex(track) + 0.5, track.pt(), track.pt() * corr); + fhN1VsZEtaPhiPt[nch]->Fill(zvtx, getEtaPhiIndex(track) + 0.5, track.pt(), corr); + fhN1VsZEtaPhiPt[track.trackacceptedid()]->Fill(zvtx, getEtaPhiIndex(track) + 0.5, track.pt(), corr); + fhSum1PtVsZEtaPhiPt[track.trackacceptedid()]->Fill(zvtx, getEtaPhiIndex(track) + 0.5, track.pt(), track.pt() * corr); + trackPrimaryCheck(track, zvtx, corr); + if (isPrimarySpeciesCheck(track, track.trackacceptedid())) { + fhN1VsZEtaPhiPtPure[track.trackacceptedid()]->Fill(zvtx, getEtaPhiIndex(track) + 0.5, track.pt(), corr); + } } index++; } @@ -297,22 +389,22 @@ struct IdentifiedBfCorrelationsTask { std::vector n1nw(nch, 0.0); ///< not weighted number of single tracks for current collision std::vector sum1Ptnw(nch, 0.0); ///< accumulated sum of not weighted single \f$p_T\f$ for current collision int index = 0; - for (auto& track : passedtracks) { + for (const auto& track : passedtracks) { float corr = (*corrs)[index]; n1[track.trackacceptedid()] += corr; sum1Pt[track.trackacceptedid()] += track.pt() * corr; n1nw[track.trackacceptedid()] += 1; sum1Ptnw[track.trackacceptedid()] += track.pt(); - fhN1_vsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), GetShiftedPhi(track.phi()), corr); - fhSum1Pt_vsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), GetShiftedPhi(track.phi()), track.pt() * corr); + fhN1VsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), getShiftedPhi(track.phi()), corr); + fhSum1PtVsEtaPhi[track.trackacceptedid()]->Fill(track.eta(), getShiftedPhi(track.phi()), track.pt() * corr); index++; } for (uint tid = 0; tid < nch; ++tid) { - fhN1_vsC[tid]->Fill(cmul, n1[tid]); - fhSum1Pt_vsC[tid]->Fill(cmul, sum1Pt[tid]); - fhN1nw_vsC[tid]->Fill(cmul, n1nw[tid]); - fhSum1Ptnw_vsC[tid]->Fill(cmul, sum1Ptnw[tid]); + fhN1VsC[tid]->Fill(cmul, n1[tid]); + fhSum1PtVsC[tid]->Fill(cmul, sum1Pt[tid]); + fhN1NWVsC[tid]->Fill(cmul, n1nw[tid]); + fhSum1PtNWVsC[tid]->Fill(cmul, sum1Ptnw[tid]); } } @@ -336,11 +428,11 @@ struct IdentifiedBfCorrelationsTask { std::vector> sum2DptDptnw(nch, std::vector(nch, 0.0)); ///< accumulated sum of not weighted number of track 1 tracks times not weighted track 2 \f$p_T\f$ for current collision int index1 = 0; - for (auto& track1 : trks1) { - double ptavg_1 = (*ptavgs1)[index1]; + for (const auto& track1 : trks1) { + double ptavg1 = (*ptavgs1)[index1]; double corr1 = (*corrs1)[index1]; int index2 = 0; - for (auto& track2 : trks2) { + for (const auto& track2 : trks2) { /* checking the same track id condition */ if (track1 == track2) { /* exclude autocorrelations */ @@ -353,26 +445,21 @@ struct IdentifiedBfCorrelationsTask { } } /* process pair magnitudes */ - double ptavg_2 = (*ptavgs2)[index2]; + double ptavg2 = (*ptavgs2)[index2]; double corr2 = (*corrs2)[index2]; double corr = corr1 * corr2; - double dptdptnw = (track1.pt() - ptavg_1) * (track2.pt() - ptavg_2); - double dptdptw = (corr1 * track1.pt() - ptavg_1) * (corr2 * track2.pt() - ptavg_2); + double dptdptnw = (track1.pt() - ptavg1) * (track2.pt() - ptavg2); + double dptdptw = (corr1 * track1.pt() - ptavg1) * (corr2 * track2.pt() - ptavg2); /* get the global bin for filling the differential histograms */ - int globalbin = GetDEtaDPhiGlobalIndex(track1, track2); + int globalbin = getDEtaDPhiGlobalIndex(track1, track2); float deltaeta = track1.eta() - track2.eta(); float deltaphi = track1.phi() - track2.phi(); - while (deltaphi >= deltaphiup) { - deltaphi -= constants::math::TwoPI; - } - while (deltaphi < deltaphilow) { - deltaphi += constants::math::TwoPI; - } + deltaphi = RecoDecay::constrainAngle(deltaphi, deltaphilow, 1U); if ((fUseConversionCuts && fPairCuts.conversionCuts(track1, track2)) || (fUseTwoTrackCut && fPairCuts.twoTrackCut(track1, track2, bfield))) { /* suppress the pair */ - fhSupN1N1_vsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, corr); - fhSupPt1Pt1_vsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, track1.pt() * track2.pt() * corr); + fhSupN1N1VsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, corr); + fhSupPt1Pt1VsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, track1.pt() * track2.pt() * corr); n2sup[track1.trackacceptedid()][track2.trackacceptedid()] += corr; } else { /* count the pair */ @@ -383,30 +470,30 @@ struct IdentifiedBfCorrelationsTask { sum2PtPtnw[track1.trackacceptedid()][track2.trackacceptedid()] += track1.pt() * track2.pt(); sum2DptDptnw[track1.trackacceptedid()][track2.trackacceptedid()] += dptdptnw; - fhN2_vsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, corr); - fhN2cont_vsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->Fill(deltaeta, deltaphi, corr); - fhSum2DptDpt_vsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, dptdptw); - fhSum2PtPt_vsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, track1.pt() * track2.pt() * corr); + fhN2VsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, corr); + fhN2ContVsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->Fill(deltaeta, deltaphi, corr); + fhSum2DptDptVsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, dptdptw); + fhSum2PtPtVsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, track1.pt() * track2.pt() * corr); } - fhN2_vsPtPt[track1.trackacceptedid()][track2.trackacceptedid()]->Fill(track1.pt(), track2.pt(), corr); + fhN2VsPtPt[track1.trackacceptedid()][track2.trackacceptedid()]->Fill(track1.pt(), track2.pt(), corr); index2++; } index1++; } for (uint pid1 = 0; pid1 < nch; ++pid1) { for (uint pid2 = 0; pid2 < nch; ++pid2) { - fhN2_vsC[pid1][pid2]->Fill(cmul, n2[pid1][pid2]); - fhSum2PtPt_vsC[pid1][pid2]->Fill(cmul, sum2PtPt[pid1][pid2]); - fhSum2DptDpt_vsC[pid1][pid2]->Fill(cmul, sum2DptDpt[pid1][pid2]); - fhN2nw_vsC[pid1][pid2]->Fill(cmul, n2nw[pid1][pid2]); - fhSum2PtPtnw_vsC[pid1][pid2]->Fill(cmul, sum2PtPtnw[pid1][pid2]); - fhSum2DptDptnw_vsC[pid1][pid2]->Fill(cmul, sum2DptDptnw[pid1][pid2]); + fhN2VsC[pid1][pid2]->Fill(cmul, n2[pid1][pid2]); + fhSum2PtPtVsC[pid1][pid2]->Fill(cmul, sum2PtPt[pid1][pid2]); + fhSum2DptDptVsC[pid1][pid2]->Fill(cmul, sum2DptDpt[pid1][pid2]); + fhN2NWVsC[pid1][pid2]->Fill(cmul, n2nw[pid1][pid2]); + fhSum2PtPtNWVsC[pid1][pid2]->Fill(cmul, sum2PtPtnw[pid1][pid2]); + fhSum2DptDptNWVsC[pid1][pid2]->Fill(cmul, sum2DptDptnw[pid1][pid2]); /* let's also update the number of entries in the differential histograms */ - fhN2_vsDEtaDPhi[pid1][pid2]->SetEntries(fhN2_vsDEtaDPhi[pid1][pid2]->GetEntries() + n2[pid1][pid2]); - fhSum2DptDpt_vsDEtaDPhi[pid1][pid2]->SetEntries(fhSum2DptDpt_vsDEtaDPhi[pid1][pid2]->GetEntries() + n2[pid1][pid2]); - fhSum2PtPt_vsDEtaDPhi[pid1][pid2]->SetEntries(fhSum2PtPt_vsDEtaDPhi[pid1][pid2]->GetEntries() + n2[pid1][pid2]); - fhSupN1N1_vsDEtaDPhi[pid1][pid2]->SetEntries(fhSupN1N1_vsDEtaDPhi[pid1][pid2]->GetEntries() + n2sup[pid1][pid2]); - fhSupPt1Pt1_vsDEtaDPhi[pid1][pid2]->SetEntries(fhSupPt1Pt1_vsDEtaDPhi[pid1][pid2]->GetEntries() + n2sup[pid1][pid2]); + fhN2VsDEtaDPhi[pid1][pid2]->SetEntries(fhN2VsDEtaDPhi[pid1][pid2]->GetEntries() + n2[pid1][pid2]); + fhSum2DptDptVsDEtaDPhi[pid1][pid2]->SetEntries(fhSum2DptDptVsDEtaDPhi[pid1][pid2]->GetEntries() + n2[pid1][pid2]); + fhSum2PtPtVsDEtaDPhi[pid1][pid2]->SetEntries(fhSum2PtPtVsDEtaDPhi[pid1][pid2]->GetEntries() + n2[pid1][pid2]); + fhSupN1N1VsDEtaDPhi[pid1][pid2]->SetEntries(fhSupN1N1VsDEtaDPhi[pid1][pid2]->GetEntries() + n2sup[pid1][pid2]); + fhSupPt1Pt1VsDEtaDPhi[pid1][pid2]->SetEntries(fhSupPt1Pt1VsDEtaDPhi[pid1][pid2]->GetEntries() + n2sup[pid1][pid2]); } } } @@ -475,7 +562,7 @@ struct IdentifiedBfCorrelationsTask { using namespace o2::analysis::identifiedbffilter; /* create the histograms */ - Bool_t oldstatus = TH1::AddDirectoryStatus(); + bool oldstatus = TH1::AddDirectoryStatus(); TH1::AddDirectory(kFALSE); if (!processpairs) { @@ -483,23 +570,23 @@ struct IdentifiedBfCorrelationsTask { fOutputList->Add(fhVertexZA); for (uint i = 0; i < nch; ++i) { /* histograms for each track, one and two */ - fhN1_vsPt[i] = new TH1F(TString::Format("n1_%s_vsPt", tname[i].c_str()).Data(), - TString::Format("#LT n_{1} #GT;p_{t,%s} (GeV/c);#LT n_{1} #GT", tname[i].c_str()).Data(), - ptbins, ptlow, ptup); + fhN1VsPt[i] = new TH1F(TString::Format("n1_%s_vsPt", tname[i].c_str()).Data(), + TString::Format("#LT n_{1} #GT;p_{t,%s} (GeV/c);#LT n_{1} #GT", tname[i].c_str()).Data(), + ptbins, ptlow, ptup); /* we don't want the Sumw2 structure being created here */ bool defSumw2 = TH1::GetDefaultSumw2(); if constexpr (smallsingles) { - fhN1_vsEtaPhi[i] = new TH2F(TString::Format("n1_%s_vsEtaPhi", tname[i].c_str()).Data(), - TString::Format("#LT n_{1} #GT;#eta_{%s};#varphi_{%s} (radian);#LT n_{1} #GT", tname[i].c_str(), tname[i].c_str()).Data(), - etabins, etalow, etaup, phibins, philow, phiup); - fhSum1Pt_vsEtaPhi[i] = new TH2F(TString::Format("sumPt_%s_vsEtaPhi", tname[i].c_str()).Data(), - TString::Format("#LT #Sigma p_{t,%s} #GT;#eta_{%s};#varphi_{%s} (radian);#LT #Sigma p_{t,%s} #GT (GeV/c)", - tname[i].c_str(), tname[i].c_str(), tname[i].c_str(), tname[i].c_str()) - .Data(), - etabins, etalow, etaup, phibins, philow, phiup); + fhN1VsEtaPhi[i] = new TH2F(TString::Format("n1_%s_vsEtaPhi", tname[i].c_str()).Data(), + TString::Format("#LT n_{1} #GT;#eta_{%s};#varphi_{%s} (radian);#LT n_{1} #GT", tname[i].c_str(), tname[i].c_str()).Data(), + etabins, etalow, etaup, phibins, philow, phiup); + fhSum1PtVsEtaPhi[i] = new TH2F(TString::Format("sumPt_%s_vsEtaPhi", tname[i].c_str()).Data(), + TString::Format("#LT #Sigma p_{t,%s} #GT;#eta_{%s};#varphi_{%s} (radian);#LT #Sigma p_{t,%s} #GT (GeV/c)", + tname[i].c_str(), tname[i].c_str(), tname[i].c_str(), tname[i].c_str()) + .Data(), + etabins, etalow, etaup, phibins, philow, phiup); } else { TH1::SetDefaultSumw2(false); - fhN1_vsZEtaPhiPt[i] = new TH3F( + fhN1VsZEtaPhiPt[i] = new TH3F( TString::Format("n1_%s_vsZ_vsEtaPhi_vsPt", tname[i].c_str()).Data(), TString::Format("#LT n_{1} #GT;vtx_{z};#eta_{%s}#times#varphi_{%s};p_{t,%s} (GeV/c)", tname[i].c_str(), @@ -515,7 +602,59 @@ struct IdentifiedBfCorrelationsTask { ptbins, ptlow, ptup); - fhSum1Pt_vsZEtaPhiPt[i] = new TH3F( + + fhN1VsZEtaPhiPtPrimary[i] = new TH3F( + TString::Format("n1_%s_Primary_vsZ_vsEtaPhi_vsPt", tname[i].c_str()).Data(), + TString::Format("#LT n_{1} Primary #GT;vtx_{z};#eta_{%s}#times#varphi_{%s};p_{t,%s} (GeV/c)", + tname[i].c_str(), + tname[i].c_str(), + tname[i].c_str()) + .Data(), + zvtxbins, + zvtxlow, + zvtxup, + etabins * phibins, + 0.0, + static_cast(etabins * phibins), + ptbins, + ptlow, + ptup); + + fhN1VsZEtaPhiPtSecondary[i] = new TH3F( + TString::Format("n1_%s_Secondary_vsZ_vsEtaPhi_vsPt", tname[i].c_str()).Data(), + TString::Format("#LT n_{1} Secondary #GT;vtx_{z};#eta_{%s}#times#varphi_{%s};p_{t,%s} (GeV/c)", + tname[i].c_str(), + tname[i].c_str(), + tname[i].c_str()) + .Data(), + zvtxbins, + zvtxlow, + zvtxup, + etabins * phibins, + 0.0, + static_cast(etabins * phibins), + ptbins, + ptlow, + ptup); + + fhN1VsZEtaPhiPtPure[i] = new TH3F( + TString::Format("n1_%s_Pure_vsZ_vsEtaPhi_vsPt", tname[i].c_str()).Data(), + TString::Format("#LT n_{1} Pure #GT;vtx_{z};#eta_{%s}#times#varphi_{%s};p_{t,%s} (GeV/c)", + tname[i].c_str(), + tname[i].c_str(), + tname[i].c_str()) + .Data(), + zvtxbins, + zvtxlow, + zvtxup, + etabins * phibins, + 0.0, + static_cast(etabins * phibins), + ptbins, + ptlow, + ptup); + + fhSum1PtVsZEtaPhiPt[i] = new TH3F( TString::Format("sumPt1_%s_vsZ_vsEtaPhi_vsPt", tname[i].c_str()).Data(), TString::Format( "#LT #Sigma p_{t,%s}#GT;vtx_{z};#eta_{%s}#times#varphi_{%s};p_{t,%s} (GeV/c)", @@ -539,58 +678,88 @@ struct IdentifiedBfCorrelationsTask { /* the statistical uncertainties will be estimated by the subsamples method so let's get rid of the error tracking */ if constexpr (smallsingles) { - fhN1_vsEtaPhi[i]->SetBit(TH1::kIsNotW); - fhN1_vsEtaPhi[i]->Sumw2(false); - fhSum1Pt_vsEtaPhi[i]->SetBit(TH1::kIsNotW); - fhSum1Pt_vsEtaPhi[i]->Sumw2(false); + fhN1VsEtaPhi[i]->SetBit(TH1::kIsNotW); + fhN1VsEtaPhi[i]->Sumw2(false); + fhSum1PtVsEtaPhi[i]->SetBit(TH1::kIsNotW); + fhSum1PtVsEtaPhi[i]->Sumw2(false); } else { - fhN1_vsZEtaPhiPt[i]->SetBit(TH1::kIsNotW); - fhN1_vsZEtaPhiPt[i]->Sumw2(false); - fhSum1Pt_vsZEtaPhiPt[i]->SetBit(TH1::kIsNotW); - fhSum1Pt_vsZEtaPhiPt[i]->Sumw2(false); + fhN1VsZEtaPhiPt[i]->SetBit(TH1::kIsNotW); + fhN1VsZEtaPhiPt[i]->Sumw2(false); + fhN1VsZEtaPhiPtPrimary[i]->SetBit(TH1::kIsNotW); + fhN1VsZEtaPhiPtPrimary[i]->Sumw2(false); + fhN1VsZEtaPhiPtSecondary[i]->SetBit(TH1::kIsNotW); + fhN1VsZEtaPhiPtSecondary[i]->Sumw2(false); + fhN1VsZEtaPhiPtPure[i]->SetBit(TH1::kIsNotW); + fhN1VsZEtaPhiPtPure[i]->Sumw2(false); + fhSum1PtVsZEtaPhiPt[i]->SetBit(TH1::kIsNotW); + fhSum1PtVsZEtaPhiPt[i]->Sumw2(false); } - fhNuaNue_vsZEtaPhiPt[i] = nullptr; - fhPtAvg_vsEtaPhi[i] = nullptr; + fhNuaNueVsZEtaPhiPt[i] = nullptr; + fhPtAvgVsEtaPhi[i] = nullptr; - fOutputList->Add(fhN1_vsPt[i]); + fOutputList->Add(fhN1VsPt[i]); if constexpr (smallsingles) { - fOutputList->Add(fhN1_vsEtaPhi[i]); - fOutputList->Add(fhSum1Pt_vsEtaPhi[i]); + fOutputList->Add(fhN1VsEtaPhi[i]); + fOutputList->Add(fhSum1PtVsEtaPhi[i]); } else { - fOutputList->Add(fhN1_vsZEtaPhiPt[i]); - fOutputList->Add(fhSum1Pt_vsZEtaPhiPt[i]); + fOutputList->Add(fhN1VsZEtaPhiPt[i]); + fOutputList->Add(fhN1VsZEtaPhiPtPrimary[i]); + fOutputList->Add(fhN1VsZEtaPhiPtSecondary[i]); + fOutputList->Add(fhN1VsZEtaPhiPtPure[i]); + fOutputList->Add(fhSum1PtVsZEtaPhiPt[i]); } } + if (!smallsingles) { + TH1::SetDefaultSumw2(false); + fhN1VsZEtaPhiPt[nch] = new TH3F( + TString::Format("n1_%s_vsZ_vsEtaPhi_vsPt", "h"), + TString::Format("#LT n_{1} #GT;vtx_{z};#eta_{%s}#times#varphi_{%s};p_{t,%s} (GeV/c)", + "h", + "h", + "h") + .Data(), + zvtxbins, + zvtxlow, + zvtxup, + etabins * phibins, + 0.0, + static_cast(etabins * phibins), + ptbins, + ptlow, + ptup); + fOutputList->Add(fhN1VsZEtaPhiPt[nch]); + } + } else { for (uint i = 0; i < nch; ++i) { /* histograms for each track species */ - fhN1_vsEtaPhi[i] = new TH2F(TString::Format("n1_%s_vsEtaPhi", tname[i].c_str()).Data(), - TString::Format("#LT n_{1} #GT;#eta_{%s};#varphi_{%s} (radian);#LT n_{1} #GT", tname[i].c_str(), tname[i].c_str()).Data(), - etabins, etalow, etaup, phibins, philow, phiup); - fhSum1Pt_vsEtaPhi[i] = new TH2F(TString::Format("sumPt_%s_vsEtaPhi", tname[i].c_str()).Data(), - TString::Format("#LT #Sigma p_{t,%s} #GT;#eta_{%s};#varphi_{%s} (radian);#LT #Sigma p_{t,%s} #GT (GeV/c)", - tname[i].c_str(), tname[i].c_str(), tname[i].c_str(), tname[i].c_str()) - .Data(), - etabins, etalow, etaup, phibins, philow, phiup); - fhN1_vsC[i] = new TProfile(TString::Format("n1_%s_vsM", tname[i].c_str()).Data(), - TString::Format("#LT n_{1} #GT (weighted);Centrality/Multiplicity (%%);#LT n_{1} #GT").Data(), - 100, 0.0, 100.0); - fhSum1Pt_vsC[i] = new TProfile(TString::Format("sumPt_%s_vsM", tname[i].c_str()), - TString::Format("#LT #Sigma p_{t,%s} #GT (weighted);Centrality/Multiplicity (%%);#LT #Sigma p_{t,%s} #GT (GeV/c)", tname[i].c_str(), tname[i].c_str()).Data(), - 100, 0.0, 100.0); - fhN1nw_vsC[i] = new TProfile(TString::Format("n1Nw_%s_vsM", tname[i].c_str()).Data(), - TString::Format("#LT n_{1} #GT;Centrality/Multiplicity (%%);#LT n_{1} #GT").Data(), - 100, 0.0, 100.0); - fhSum1Ptnw_vsC[i] = new TProfile(TString::Format("sumPtNw_%s_vsM", tname[i].c_str()).Data(), - TString::Format("#LT #Sigma p_{t,%s} #GT;Centrality/Multiplicity (%%);#LT #Sigma p_{t,%s} #GT (GeV/c)", tname[i].c_str(), tname[i].c_str()).Data(), 100, 0.0, 100.0); - fhNuaNue_vsZEtaPhiPt[i] = nullptr; - fhPtAvg_vsEtaPhi[i] = nullptr; - fOutputList->Add(fhN1_vsEtaPhi[i]); - fOutputList->Add(fhSum1Pt_vsEtaPhi[i]); - fOutputList->Add(fhN1_vsC[i]); - fOutputList->Add(fhSum1Pt_vsC[i]); - fOutputList->Add(fhN1nw_vsC[i]); - fOutputList->Add(fhSum1Ptnw_vsC[i]); + fhN1VsEtaPhi[i] = new TH2F(TString::Format("n1_%s_vsEtaPhi", tname[i].c_str()).Data(), + TString::Format("#LT n_{1} #GT;#eta_{%s};#varphi_{%s} (radian);#LT n_{1} #GT", tname[i].c_str(), tname[i].c_str()).Data(), + etabins, etalow, etaup, phibins, philow, phiup); + fhSum1PtVsEtaPhi[i] = new TH2F(TString::Format("sumPt_%s_vsEtaPhi", tname[i].c_str()).Data(), + TString::Format("#LT #Sigma p_{t,%s} #GT;#eta_{%s};#varphi_{%s} (radian);#LT #Sigma p_{t,%s} #GT (GeV/c)", + tname[i].c_str(), tname[i].c_str(), tname[i].c_str(), tname[i].c_str()) + .Data(), + etabins, etalow, etaup, phibins, philow, phiup); + fhN1VsC[i] = new TProfile(TString::Format("n1_%s_vsM", tname[i].c_str()).Data(), + TString::Format("#LT n_{1} #GT (weighted);Centrality/Multiplicity (%%);#LT n_{1} #GT").Data(), + 100, 0.0, 100.0); + fhSum1PtVsC[i] = new TProfile(TString::Format("sumPt_%s_vsM", tname[i].c_str()), + TString::Format("#LT #Sigma p_{t,%s} #GT (weighted);Centrality/Multiplicity (%%);#LT #Sigma p_{t,%s} #GT (GeV/c)", tname[i].c_str(), tname[i].c_str()).Data(), + 100, 0.0, 100.0); + fhN1NWVsC[i] = new TProfile(TString::Format("n1Nw_%s_vsM", tname[i].c_str()).Data(), + TString::Format("#LT n_{1} #GT;Centrality/Multiplicity (%%);#LT n_{1} #GT").Data(), + 100, 0.0, 100.0); + fhSum1PtNWVsC[i] = new TProfile(TString::Format("sumPtNw_%s_vsM", tname[i].c_str()).Data(), + TString::Format("#LT #Sigma p_{t,%s} #GT;Centrality/Multiplicity (%%);#LT #Sigma p_{t,%s} #GT (GeV/c)", tname[i].c_str(), tname[i].c_str()).Data(), 100, 0.0, 100.0); + fhNuaNueVsZEtaPhiPt[i] = nullptr; + fhPtAvgVsEtaPhi[i] = nullptr; + fOutputList->Add(fhN1VsEtaPhi[i]); + fOutputList->Add(fhSum1PtVsEtaPhi[i]); + fOutputList->Add(fhN1VsC[i]); + fOutputList->Add(fhSum1PtVsC[i]); + fOutputList->Add(fhN1NWVsC[i]); + fOutputList->Add(fhSum1PtNWVsC[i]); } for (uint i = 0; i < nch; ++i) { for (uint j = 0; j < nch; ++j) { @@ -600,58 +769,58 @@ struct IdentifiedBfCorrelationsTask { TH1::SetDefaultSumw2(false); // const char* pname = chargePairsNames[i][j].c_str(); const char* pname = speciesPairNames[i][j].c_str(); - fhN2_vsDEtaDPhi[i][j] = new TH2F(TString::Format("n2_12_vsDEtaDPhi_%s", pname), TString::Format("#LT n_{2} #GT (%s);#Delta#eta;#Delta#varphi;#LT n_{2} #GT", pname), - deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); - fhN2cont_vsDEtaDPhi[i][j] = new TH2F(TString::Format("n2_12cont_vsDEtaDPhi_%s", pname), TString::Format("#LT n_{2} #GT (%s);#Delta#eta;#Delta#varphi;#LT n_{2} #GT", pname), - deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); - fhSum2PtPt_vsDEtaDPhi[i][j] = new TH2F(TString::Format("sumPtPt_12_vsDEtaDPhi_%s", pname), TString::Format("#LT #Sigma p_{t,1}p_{t,2} #GT (%s);#Delta#eta;#Delta#varphi;#LT #Sigma p_{t,1}p_{t,2} #GT (GeV^{2})", pname), - deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); - fhSum2DptDpt_vsDEtaDPhi[i][j] = new TH2F(TString::Format("sumDptDpt_12_vsDEtaDPhi_%s", pname), TString::Format("#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (%s);#Delta#eta;#Delta#varphi;#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (GeV^{2})", pname), - deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); - fhSupN1N1_vsDEtaDPhi[i][j] = new TH2F(TString::Format("suppn1n1_12_vsDEtaDPhi_%s", pname), TString::Format("Suppressed #LT n_{1} #GT#LT n_{1} #GT (%s);#Delta#eta;#Delta#varphi;#LT n_{1} #GT#LT n_{1} #GT", pname), + fhN2VsDEtaDPhi[i][j] = new TH2F(TString::Format("n2_12_vsDEtaDPhi_%s", pname), TString::Format("#LT n_{2} #GT (%s);#Delta#eta;#Delta#varphi;#LT n_{2} #GT", pname), + deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); + fhN2ContVsDEtaDPhi[i][j] = new TH2F(TString::Format("n2_12cont_vsDEtaDPhi_%s", pname), TString::Format("#LT n_{2} #GT (%s);#Delta#eta;#Delta#varphi;#LT n_{2} #GT", pname), + deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); + fhSum2PtPtVsDEtaDPhi[i][j] = new TH2F(TString::Format("sumPtPt_12_vsDEtaDPhi_%s", pname), TString::Format("#LT #Sigma p_{t,1}p_{t,2} #GT (%s);#Delta#eta;#Delta#varphi;#LT #Sigma p_{t,1}p_{t,2} #GT (GeV^{2})", pname), deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); - fhSupPt1Pt1_vsDEtaDPhi[i][j] = new TH2F(TString::Format("suppPtPt_12_vsDEtaDPhi_%s", pname), TString::Format("Suppressed #LT p_{t,1} #GT#LT p_{t,2} #GT (%s);#Delta#eta;#Delta#varphi;#LT p_{t,1} #GT#LT p_{t,2} #GT (GeV^{2})", pname), + fhSum2DptDptVsDEtaDPhi[i][j] = new TH2F(TString::Format("sumDptDpt_12_vsDEtaDPhi_%s", pname), TString::Format("#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (%s);#Delta#eta;#Delta#varphi;#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (GeV^{2})", pname), deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); + fhSupN1N1VsDEtaDPhi[i][j] = new TH2F(TString::Format("suppn1n1_12_vsDEtaDPhi_%s", pname), TString::Format("Suppressed #LT n_{1} #GT#LT n_{1} #GT (%s);#Delta#eta;#Delta#varphi;#LT n_{1} #GT#LT n_{1} #GT", pname), + deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); + fhSupPt1Pt1VsDEtaDPhi[i][j] = new TH2F(TString::Format("suppPtPt_12_vsDEtaDPhi_%s", pname), TString::Format("Suppressed #LT p_{t,1} #GT#LT p_{t,2} #GT (%s);#Delta#eta;#Delta#varphi;#LT p_{t,1} #GT#LT p_{t,2} #GT (GeV^{2})", pname), + deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); /* we return it back to previuos state */ TH1::SetDefaultSumw2(defSumw2); - fhN2_vsPtPt[i][j] = new TH2F(TString::Format("n2_12_vsPtVsPt_%s", pname), TString::Format("#LT n_{2} #GT (%s);p_{t,1} (GeV/c);p_{t,2} (GeV/c);#LT n_{2} #GT", pname), - ptbins, ptlow, ptup, ptbins, ptlow, ptup); + fhN2VsPtPt[i][j] = new TH2F(TString::Format("n2_12_vsPtVsPt_%s", pname), TString::Format("#LT n_{2} #GT (%s);p_{t,1} (GeV/c);p_{t,2} (GeV/c);#LT n_{2} #GT", pname), + ptbins, ptlow, ptup, ptbins, ptlow, ptup); - fhN2_vsC[i][j] = new TProfile(TString::Format("n2_12_vsM_%s", pname), TString::Format("#LT n_{2} #GT (%s) (weighted);Centrality/Multiplicity (%%);#LT n_{2} #GT", pname), 100, 0.0, 100.0); - fhSum2PtPt_vsC[i][j] = new TProfile(TString::Format("sumPtPt_12_vsM_%s", pname), TString::Format("#LT #Sigma p_{t,1}p_{t,2} #GT (%s) (weighted);Centrality/Multiplicity (%%);#LT #Sigma p_{t,1}p_{t,2} #GT (GeV^{2})", pname), 100, 0.0, 100.0); - fhSum2DptDpt_vsC[i][j] = new TProfile(TString::Format("sumDptDpt_12_vsM_%s", pname), TString::Format("#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (%s) (weighted);Centrality/Multiplicity (%%);#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (GeV^{2})", pname), 100, 0.0, 100.0); - fhN2nw_vsC[i][j] = new TProfile(TString::Format("n2Nw_12_vsM_%s", pname), TString::Format("#LT n_{2} #GT (%s);Centrality/Multiplicity (%%);#LT n_{2} #GT", pname), 100, 0.0, 100.0); - fhSum2PtPtnw_vsC[i][j] = new TProfile(TString::Format("sumPtPtNw_12_vsM_%s", pname), TString::Format("#LT #Sigma p_{t,1}p_{t,2} #GT (%s);Centrality/Multiplicity (%%);#LT #Sigma p_{t,1}p_{t,2} #GT (GeV^{2})", pname), 100, 0.0, 100.0); - fhSum2DptDptnw_vsC[i][j] = new TProfile(TString::Format("sumDptDptNw_12_vsM_%s", pname), TString::Format("#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (%s);Centrality/Multiplicity (%%);#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (GeV^{2})", pname), 100, 0.0, 100.0); + fhN2VsC[i][j] = new TProfile(TString::Format("n2_12_vsM_%s", pname), TString::Format("#LT n_{2} #GT (%s) (weighted);Centrality/Multiplicity (%%);#LT n_{2} #GT", pname), 100, 0.0, 100.0); + fhSum2PtPtVsC[i][j] = new TProfile(TString::Format("sumPtPt_12_vsM_%s", pname), TString::Format("#LT #Sigma p_{t,1}p_{t,2} #GT (%s) (weighted);Centrality/Multiplicity (%%);#LT #Sigma p_{t,1}p_{t,2} #GT (GeV^{2})", pname), 100, 0.0, 100.0); + fhSum2DptDptVsC[i][j] = new TProfile(TString::Format("sumDptDpt_12_vsM_%s", pname), TString::Format("#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (%s) (weighted);Centrality/Multiplicity (%%);#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (GeV^{2})", pname), 100, 0.0, 100.0); + fhN2NWVsC[i][j] = new TProfile(TString::Format("n2Nw_12_vsM_%s", pname), TString::Format("#LT n_{2} #GT (%s);Centrality/Multiplicity (%%);#LT n_{2} #GT", pname), 100, 0.0, 100.0); + fhSum2PtPtNWVsC[i][j] = new TProfile(TString::Format("sumPtPtNw_12_vsM_%s", pname), TString::Format("#LT #Sigma p_{t,1}p_{t,2} #GT (%s);Centrality/Multiplicity (%%);#LT #Sigma p_{t,1}p_{t,2} #GT (GeV^{2})", pname), 100, 0.0, 100.0); + fhSum2DptDptNWVsC[i][j] = new TProfile(TString::Format("sumDptDptNw_12_vsM_%s", pname), TString::Format("#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (%s);Centrality/Multiplicity (%%);#LT #Sigma (p_{t,1} - #LT p_{t,1} #GT)(p_{t,2} - #LT p_{t,2} #GT) #GT (GeV^{2})", pname), 100, 0.0, 100.0); /* the statistical uncertainties will be estimated by the subsamples method so let's get rid of the error tracking */ - fhN2_vsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); - fhN2_vsDEtaDPhi[i][j]->Sumw2(false); - fhN2cont_vsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); - fhN2cont_vsDEtaDPhi[i][j]->Sumw2(false); - fhSum2PtPt_vsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); - fhSum2PtPt_vsDEtaDPhi[i][j]->Sumw2(false); - fhSum2DptDpt_vsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); - fhSum2DptDpt_vsDEtaDPhi[i][j]->Sumw2(false); - fhSupN1N1_vsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); - fhSupN1N1_vsDEtaDPhi[i][j]->Sumw2(false); - fhSupPt1Pt1_vsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); - fhSupPt1Pt1_vsDEtaDPhi[i][j]->Sumw2(false); - - fOutputList->Add(fhN2_vsDEtaDPhi[i][j]); - fOutputList->Add(fhN2cont_vsDEtaDPhi[i][j]); - fOutputList->Add(fhSum2PtPt_vsDEtaDPhi[i][j]); - fOutputList->Add(fhSum2DptDpt_vsDEtaDPhi[i][j]); - fOutputList->Add(fhSupN1N1_vsDEtaDPhi[i][j]); - fOutputList->Add(fhSupPt1Pt1_vsDEtaDPhi[i][j]); - fOutputList->Add(fhN2_vsPtPt[i][j]); - fOutputList->Add(fhN2_vsC[i][j]); - fOutputList->Add(fhSum2PtPt_vsC[i][j]); - fOutputList->Add(fhSum2DptDpt_vsC[i][j]); - fOutputList->Add(fhN2nw_vsC[i][j]); - fOutputList->Add(fhSum2PtPtnw_vsC[i][j]); - fOutputList->Add(fhSum2DptDptnw_vsC[i][j]); + fhN2VsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); + fhN2VsDEtaDPhi[i][j]->Sumw2(false); + fhN2ContVsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); + fhN2ContVsDEtaDPhi[i][j]->Sumw2(false); + fhSum2PtPtVsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); + fhSum2PtPtVsDEtaDPhi[i][j]->Sumw2(false); + fhSum2DptDptVsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); + fhSum2DptDptVsDEtaDPhi[i][j]->Sumw2(false); + fhSupN1N1VsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); + fhSupN1N1VsDEtaDPhi[i][j]->Sumw2(false); + fhSupPt1Pt1VsDEtaDPhi[i][j]->SetBit(TH1::kIsNotW); + fhSupPt1Pt1VsDEtaDPhi[i][j]->Sumw2(false); + + fOutputList->Add(fhN2VsDEtaDPhi[i][j]); + fOutputList->Add(fhN2ContVsDEtaDPhi[i][j]); + fOutputList->Add(fhSum2PtPtVsDEtaDPhi[i][j]); + fOutputList->Add(fhSum2DptDptVsDEtaDPhi[i][j]); + fOutputList->Add(fhSupN1N1VsDEtaDPhi[i][j]); + fOutputList->Add(fhSupPt1Pt1VsDEtaDPhi[i][j]); + fOutputList->Add(fhN2VsPtPt[i][j]); + fOutputList->Add(fhN2VsC[i][j]); + fOutputList->Add(fhSum2PtPtVsC[i][j]); + fOutputList->Add(fhSum2DptDptVsC[i][j]); + fOutputList->Add(fhN2NWVsC[i][j]); + fOutputList->Add(fhSum2PtPtNWVsC[i][j]); + fOutputList->Add(fhSum2DptDptNWVsC[i][j]); } } } @@ -669,7 +838,7 @@ struct IdentifiedBfCorrelationsTask { /* the data collecting engine instances */ DataCollectingEngine** dataCE; - DataCollectingEngine** dataCE_small; + DataCollectingEngine** dataCESmall; DataCollectingEngine** dataCEME; /* the input file structure from CCDB */ @@ -677,25 +846,25 @@ struct IdentifiedBfCorrelationsTask { bool loadfromccdb = false; /* pair conversion suppression defaults */ - static constexpr float cfgPairCutDefaults[1][5] = {{-1, -1, -1, -1, -1}}; - Configurable> cfgPairCut{"paircut", {cfgPairCutDefaults[0], 5, {"Photon", "K0", "Lambda", "Phi", "Rho"}}, "Conversion suppressions"}; + static constexpr float PairCutDefaults[1][5] = {{-1, -1, -1, -1, -1}}; + Configurable> cfgPairCut{"cfgPairCut", {PairCutDefaults[0], 5, {"Photon", "K0", "Lambda", "Phi", "Rho"}}, "Conversion suppressions"}; /* two tracks cut */ - Configurable cfgTwoTrackCut{"twotrackcut", -1, "Two-tracks cut: -1 = off; >0 otherwise distance value (suggested: 0.02"}; - Configurable cfgTwoTrackCutMinRadius{"twotrackcutminradius", 0.8f, "Two-tracks cut: radius in m from which two-tracks cut is applied"}; + Configurable cfgTwoTrackCut{"cfgTwoTrackCut", -1, "Two-tracks cut: -1 = off; >0 otherwise distance value (suggested: 0.02"}; + Configurable cfgTwoTrackCutMinRadius{"cfgTwoTrackCutMinRadius", 0.8f, "Two-tracks cut: radius in m from which two-tracks cut is applied"}; - Configurable cfgSmallDCE{"smalldce", true, "Use small data collecting engine for singles processing, true = yes. Default = true"}; - Configurable cfgProcessPairs{"processpairs", false, "Process pairs: false = no, just singles, true = yes, process pairs"}; - Configurable cfgProcessME{"processmixedevents", false, "Process mixed events: false = no, just same event, true = yes, also process mixed events"}; - Configurable cfgCentSpec{"centralities", "00-05,05-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80", "Centrality/multiplicity ranges in min-max separated by commas"}; + Configurable cfgSmallDCE{"cfgSmallDCE", true, "Use small data collecting engine for singles processing, true = yes. Default = true"}; + Configurable cfgProcessPairs{"cfgProcessPairs", false, "Process pairs: false = no, just singles, true = yes, process pairs"}; + Configurable cfgProcessME{"cfgProcessME", false, "Process mixed events: false = no, just same event, true = yes, also process mixed events"}; + Configurable cfgCentSpec{"cfgCentSpec", "00-05,05-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80", "Centrality/multiplicity ranges in min-max separated by commas"}; - Configurable cfgBinning{"binning", + Configurable cfgBinning{"cfgBinning", {28, -7.0, 7.0, 18, 0.2, 2.0, 16, -0.8, 0.8, 72, 0.5}, "triplets - nbins, min, max - for z_vtx, pT, eta and phi, binning plus bin fraction of phi origin shift"}; - Configurable cfgPtOrder{"ptorder", false, "enforce pT_1 < pT_2. Defalut: false"}; + Configurable cfgPtOrder{"cfgPtOrder", false, "enforce pT_1 < pT_2. Defalut: false"}; struct : ConfigurableGroup { - Configurable cfgCCDBUrl{"input_ccdburl", "http://ccdb-test.cern.ch:8080", "The CCDB url for the input file"}; - Configurable cfgCCDBPathName{"input_ccdbpath", "", "The CCDB path for the input file. Default \"\", i.e. don't load from CCDB"}; - Configurable cfgCCDBDate{"input_ccdbdate", "20220307", "The CCDB date for the input file"}; + Configurable cfgCCDBUrl{"cfgCCDBUrl", "http://ccdb-test.cern.ch:8080", "The CCDB url for the input file"}; + Configurable cfgCCDBPathName{"cfgCCDBPathName", "", "The CCDB path for the input file. Default \"\", i.e. don't load from CCDB"}; + Configurable cfgCCDBDate{"cfgCCDBDate", "20220307", "The CCDB date for the input file"}; } cfginputfile; OutputObj fOutput{"IdentifiedBfCorrelationsData", OutputObjHandlingPolicy::AnalysisObject, OutputObjSourceType::OutputObjSource}; @@ -770,7 +939,7 @@ struct IdentifiedBfCorrelationsTask { fCentMultMax = new float[ncmranges]; dataCE = new DataCollectingEngine*[ncmranges]; if (cfgSmallDCE) { - dataCE_small = new DataCollectingEngine*[ncmranges]; + dataCESmall = new DataCollectingEngine*[ncmranges]; } else { dataCE = new DataCollectingEngine*[ncmranges]; } @@ -807,7 +976,7 @@ struct IdentifiedBfCorrelationsTask { if (processpairs) { LOGF(fatal, "Processing pairs cannot be used with the small DCE, please configure properly!!"); } - dataCE_small[i] = builSmallDCEInstance(tokens->At(i)->GetName()); + dataCESmall[i] = builSmallDCEInstance(tokens->At(i)->GetName()); } else { dataCE[i] = buildCEInstance(tokens->At(i)->GetName()); } @@ -922,7 +1091,7 @@ struct IdentifiedBfCorrelationsTask { .Data())); } if (cfgSmallDCE.value) { - dataCE_small[ixDCE]->storePtAverages(ptavgs); + dataCESmall[ixDCE]->storePtAverages(ptavgs); } else { dataCE[ixDCE]->storePtAverages(ptavgs); } @@ -937,7 +1106,7 @@ struct IdentifiedBfCorrelationsTask { .Data())); } if (cfgSmallDCE.value) { - dataCE_small[ixDCE]->storeTrackCorrections(corrs); + dataCESmall[ixDCE]->storeTrackCorrections(corrs); } else { dataCE[ixDCE]->storeTrackCorrections(corrs); } @@ -952,7 +1121,7 @@ struct IdentifiedBfCorrelationsTask { .Data())); } if (cfgSmallDCE.value) { - dataCE_small[ixDCE]->storePtAverages(ptavgs); + dataCESmall[ixDCE]->storePtAverages(ptavgs); } else { dataCE[ixDCE]->storePtAverages(ptavgs); } @@ -976,7 +1145,7 @@ struct IdentifiedBfCorrelationsTask { bfield = (fUseConversionCuts || fUseTwoTrackCut) ? getMagneticField(timestamp) : 0; } if (cfgSmallDCE.value) { - dataCE_small[ixDCE]->processCollision(tracks, tracks, collision.posZ(), collision.centmult(), bfield); + dataCESmall[ixDCE]->processCollision(tracks, tracks, collision.posZ(), collision.centmult(), bfield); } else { dataCE[ixDCE]->processCollision(tracks, tracks, collision.posZ(), collision.centmult(), bfield); } @@ -1059,20 +1228,20 @@ struct IdentifiedBfCorrelationsTask { Filter onlyacceptedcollisions = (aod::identifiedbffilter::collisionaccepted == uint8_t(true)); Filter onlyacceptedtracks = (aod::identifiedbffilter::trackacceptedid >= int8_t(0)); - void processRecLevel(soa::Filtered::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered& tracks) + void processRecLevel(soa::Filtered::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered const& tracks) { processSame(collision, tracks, collision.bc_as().timestamp()); } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, processRecLevel, "Process reco level correlations", false); + PROCESS_SWITCH(IdentifiedbfTask, processRecLevel, "Process reco level correlations", false); - void processRecLevelCheck(aod::Collisions const& collisions, aod::Tracks& tracks) + void processRecLevelCheck(aod::Collisions const& collisions, aod::Tracks const& tracks) { int nAssignedTracks = 0; int nNotAssignedTracks = 0; int64_t firstNotAssignedIndex = -1; int64_t lastNotAssignedIndex = -1; - for (auto track : tracks) { + for (const auto& track : tracks) { if (track.has_collision()) { nAssignedTracks++; } else { @@ -1090,16 +1259,16 @@ struct IdentifiedBfCorrelationsTask { LOGF(info, " First not assigned track index %d", firstNotAssignedIndex); LOGF(info, " Last not assigned track index %d", lastNotAssignedIndex); } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, processRecLevelCheck, "Process reco level checks", true); + PROCESS_SWITCH(IdentifiedbfTask, processRecLevelCheck, "Process reco level checks", true); - void processGenLevelCheck(aod::McCollisions const& mccollisions, aod::McParticles& particles) + void processGenLevelCheck(aod::McCollisions const& mccollisions, aod::McParticles const& particles) { int nAssignedParticles = 0; int nNotAssignedParticles = 0; int64_t firstNotAssignedIndex = -1; int64_t lastNotAssignedIndex = -1; - for (auto particle : particles) { + for (const auto& particle : particles) { if (particle.has_mcCollision()) { nAssignedParticles++; } else { @@ -1117,36 +1286,46 @@ struct IdentifiedBfCorrelationsTask { LOGF(info, " First not assigned track index %d", firstNotAssignedIndex); LOGF(info, " Last not assigned track index %d", lastNotAssignedIndex); } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, processGenLevelCheck, "Process generator level checks", true); + PROCESS_SWITCH(IdentifiedbfTask, processGenLevelCheck, "Process generator level checks", true); void processRecLevelNotStored( soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, - soa::Filtered>& tracks) + soa::Filtered> const& tracks) { processSame(collision, tracks, collision.bc_as().timestamp()); } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, - processRecLevelNotStored, + PROCESS_SWITCH(IdentifiedbfTask, processRecLevelNotStored, "Process reco level correlations for not stored derived data", true); + void processDetLevelNotStored( + soa::Filtered>::iterator const& collision, + aod::BCsWithTimestamps const&, + soa::Filtered> const& tracks, + aod::McParticles const&) + { + processSame(collision, tracks, collision.bc_as().timestamp()); + } + PROCESS_SWITCH(IdentifiedbfTask, processDetLevelNotStored, + "Process detecotr level correlations for not stored derived data", + true); + void processGenLevel( soa::Filtered::iterator const& collision, - soa::Filtered>& tracks) + soa::Filtered> const& tracks) { processSame(collision, tracks); } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, processGenLevel, "Process generator level correlations", false); + PROCESS_SWITCH(IdentifiedbfTask, processGenLevel, "Process generator level correlations", false); void processGenLevelNotStored( soa::Filtered>::iterator const& collision, - soa::Filtered>& particles) + soa::Filtered> const& particles) { processSame(collision, particles); } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, - processGenLevelNotStored, + PROCESS_SWITCH(IdentifiedbfTask, processGenLevelNotStored, "Process generator level correlations for not stored derived data", false); @@ -1157,15 +1336,15 @@ struct IdentifiedBfCorrelationsTask { using BinningZVtxMultRec = ColumnBinningPolicy; BinningZVtxMultRec bindingOnVtxAndMultRec{{vtxBinsEdges, multBinsEdges}, true}; // true is for 'ignore overflows' (true by default) - void processRecLevelMixed(soa::Filtered& collisions, aod::BCsWithTimestamps const&, soa::Filtered& tracks) + void processRecLevelMixed(soa::Filtered const& collisions, aod::BCsWithTimestamps const&, soa::Filtered const& tracks) { auto tracksTuple = std::make_tuple(tracks); SameKindPair, soa::Filtered, BinningZVtxMultRec> pairreco{bindingOnVtxAndMultRec, 5, -1, collisions, tracksTuple, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored LOGF(IDENTIFIEDBFLOGCOLLISIONS, "Received %d collisions", collisions.size()); int logcomb = 0; - for (auto& [collision1, tracks1, collision2, tracks2] : pairreco) { - if (logcomb < 10) { + for (const auto& [collision1, tracks1, collision2, tracks2] : pairreco) { + if (logcomb < correlationstask::maxLogComb) { LOGF(IDENTIFIEDBFLOGCOLLISIONS, "Received collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s", collision1.globalIndex(), collision1.posZ(), collision1.centmult(), collision1.collisionaccepted() ? "accepted" : "not accepted", collision2.globalIndex(), collision2.posZ(), collision2.centmult(), collision2.collisionaccepted() ? "accepted" : "not accepted"); @@ -1179,12 +1358,12 @@ struct IdentifiedBfCorrelationsTask { processMixed(collision1, tracks1, tracks2, collision1.bc_as().timestamp()); } } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, processRecLevelMixed, "Process reco level mixed events correlations", false); + PROCESS_SWITCH(IdentifiedbfTask, processRecLevelMixed, "Process reco level mixed events correlations", false); void processRecLevelMixedNotStored( - soa::Filtered>& collisions, + soa::Filtered> const& collisions, aod::BCsWithTimestamps const&, - soa::Filtered>& tracks) + soa::Filtered> const& tracks) { auto tracksTuple = std::make_tuple(tracks); SameKindPair>, @@ -1199,8 +1378,8 @@ struct IdentifiedBfCorrelationsTask { LOGF(IDENTIFIEDBFLOGCOLLISIONS, "Received %d collisions", collisions.size()); int logcomb = 0; - for (auto& [collision1, tracks1, collision2, tracks2] : pairreco) { - if (logcomb < 10) { + for (const auto& [collision1, tracks1, collision2, tracks2] : pairreco) { + if (logcomb < correlationstask::maxLogComb) { LOGF(IDENTIFIEDBFLOGCOLLISIONS, "Received collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s", collision1.globalIndex(), @@ -1231,23 +1410,22 @@ struct IdentifiedBfCorrelationsTask { collision1.bc_as().timestamp()); } } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, - processRecLevelMixedNotStored, + PROCESS_SWITCH(IdentifiedbfTask, processRecLevelMixedNotStored, "Process reco level mixed events correlations for not stored derived data", false); using BinningZVtxMultGen = ColumnBinningPolicy; BinningZVtxMultGen bindingOnVtxAndMultGen{{vtxBinsEdges, multBinsEdges}, true}; // true is for 'ignore overflows' (true by default) - void processGenLevelMixed(soa::Filtered& collisions, soa::Filtered& tracks) + void processGenLevelMixed(soa::Filtered const& collisions, soa::Filtered const& tracks) { auto tracksTuple = std::make_tuple(tracks); SameKindPair, soa::Filtered, BinningZVtxMultGen> pairgen{bindingOnVtxAndMultGen, 5, -1, collisions, tracksTuple, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored LOGF(IDENTIFIEDBFLOGCOLLISIONS, "Received %d generated collisions", collisions.size()); int logcomb = 0; - for (auto& [collision1, tracks1, collision2, tracks2] : pairgen) { - if (logcomb < 10) { + for (const auto& [collision1, tracks1, collision2, tracks2] : pairgen) { + if (logcomb < correlationstask::maxLogComb) { LOGF(IDENTIFIEDBFLOGCOLLISIONS, "Received generated collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s", collision1.globalIndex(), collision1.posZ(), collision1.centmult(), collision1.collisionaccepted() ? "accepted" : "not accepted", collision2.globalIndex(), collision2.posZ(), collision2.centmult(), collision2.collisionaccepted() ? "accepted" : "not accepted"); @@ -1260,11 +1438,11 @@ struct IdentifiedBfCorrelationsTask { processMixed(collision1, tracks1, tracks2); } } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, processGenLevelMixed, "Process generator level mixed events correlations", false); + PROCESS_SWITCH(IdentifiedbfTask, processGenLevelMixed, "Process generator level mixed events correlations", false); void processGenLevelMixedNotStored( - soa::Filtered>& collisions, - soa::Filtered>& tracks) + soa::Filtered> const& collisions, + soa::Filtered> const& tracks) { auto tracksTuple = std::make_tuple(tracks); SameKindPair>, @@ -1279,8 +1457,8 @@ struct IdentifiedBfCorrelationsTask { LOGF(IDENTIFIEDBFLOGCOLLISIONS, "Received %d generated collisions", collisions.size()); int logcomb = 0; - for (auto& [collision1, tracks1, collision2, tracks2] : pairgen) { - if (logcomb < 10) { + for (const auto& [collision1, tracks1, collision2, tracks2] : pairgen) { + if (logcomb < correlationstask::maxLogComb) { LOGF(IDENTIFIEDBFLOGCOLLISIONS, "Received generated collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s", collision1.globalIndex(), @@ -1307,8 +1485,7 @@ struct IdentifiedBfCorrelationsTask { processMixed(collision1, tracks1, tracks2); } } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, - processGenLevelMixedNotStored, + PROCESS_SWITCH(IdentifiedbfTask, processGenLevelMixedNotStored, "Process generator level mixed events correlations for not stored derived data", false); @@ -1318,13 +1495,13 @@ struct IdentifiedBfCorrelationsTask { LOGF(IDENTIFIEDBFLOGCOLLISIONS, "Got %d new collisions", colls.size()); fOutput->Clear(); } - PROCESS_SWITCH(IdentifiedBfCorrelationsTask, processCleaner, "Cleaner process for not used output", false); + PROCESS_SWITCH(IdentifiedbfTask, processCleaner, "Cleaner process for not used output", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{ - adaptAnalysisTask(cfgc, TaskName{"IdentifiedBfCorrelationsTaskRec"}, SetDefaultProcesses{{{"processRecLevel", true}, {"processRecLevelMixed", false}, {"processCleaner", false}}}), - adaptAnalysisTask(cfgc, TaskName{"IdentifiedBfCorrelationsTaskGen"}, SetDefaultProcesses{{{"processGenLevel", false}, {"processGenLevelMixed", false}, {"processCleaner", true}}})}; + adaptAnalysisTask(cfgc, TaskName{"IdentifiedbfTaskRec"}, SetDefaultProcesses{{{"processRecLevel", true}, {"processRecLevelMixed", false}, {"processCleaner", false}}}), // o2-linter: disable=name/o2-task (Task is adapted multiple times) + adaptAnalysisTask(cfgc, TaskName{"IdentifiedbfTaskGen"}, SetDefaultProcesses{{{"processGenLevel", false}, {"processGenLevelMixed", false}, {"processCleaner", true}}})}; // o2-linter: disable=name/o2-task (Task is adapted multiple times) return workflow; } diff --git a/PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx b/PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx index 3d217200ea5..3dd5ec474de 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx @@ -13,22 +13,25 @@ /// \brief R2 correlation of Lambda baryons. /// \author Yash Patley -#include -#include +#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" #include "Common/DataModel/EventSelection.h" -#include "Framework/AnalysisTask.h" +#include "Common/DataModel/PIDResponse.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" -#include "PWGLF/DataModel/LFResonanceTables.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/Core/RecoDecay.h" -#include "CCDB/BasicCCDBManager.h" + #include "TPDGCode.h" +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -52,6 +55,7 @@ namespace lambdamcgencollision { } DECLARE_SOA_TABLE(LambdaMcGenCollisions, "AOD", "LMCGENCOLS", o2::soa::Index<>, + lambdacollision::Cent, o2::aod::mccollision::PosX, o2::aod::mccollision::PosY, o2::aod::mccollision::PosZ); @@ -70,9 +74,10 @@ DECLARE_SOA_COLUMN(Rap, rap, float); DECLARE_SOA_COLUMN(Mass, mass, float); DECLARE_SOA_COLUMN(PosTrackId, posTrackId, int64_t); DECLARE_SOA_COLUMN(NegTrackId, negTrackId, int64_t); -DECLARE_SOA_COLUMN(V0Type, v0Type, int8_t); DECLARE_SOA_COLUMN(CosPA, cosPA, float); DECLARE_SOA_COLUMN(DcaDau, dcaDau, float); +DECLARE_SOA_COLUMN(V0Type, v0Type, int8_t); +DECLARE_SOA_COLUMN(V0PrmScd, v0PrmScd, int8_t); DECLARE_SOA_COLUMN(CorrFact, corrFact, float); } // namespace lambdatrack DECLARE_SOA_TABLE(LambdaTracks, "AOD", "LAMBDATRACKS", o2::soa::Index<>, @@ -87,9 +92,10 @@ DECLARE_SOA_TABLE(LambdaTracks, "AOD", "LAMBDATRACKS", o2::soa::Index<>, lambdatrack::Mass, lambdatrack::PosTrackId, lambdatrack::NegTrackId, - lambdatrack::V0Type, lambdatrack::CosPA, lambdatrack::DcaDau, + lambdatrack::V0Type, + lambdatrack::V0PrmScd, lambdatrack::CorrFact); using LambdaTrack = LambdaTracks::iterator; @@ -125,6 +131,7 @@ DECLARE_SOA_TABLE(LambdaMcGenTracks, "AOD", "LMCGENTRACKS", o2::soa::Index<>, lambdatrack::V0Type, lambdatrack::CosPA, lambdatrack::DcaDau, + lambdatrack::V0PrmScd, lambdatrack::CorrFact); using LambdaMcGenTrack = LambdaMcGenTracks::iterator; @@ -139,22 +146,27 @@ enum CollisionLabels { enum TrackLabels { kTracksBeforeHasMcParticle = 1, kAllV0Tracks, + kV0KShortMassRej, + kNotLambdaNotAntiLambda, + kV0IsBothLambdaAntiLambda, + kNotLambdaAfterSel, + kV0IsLambdaOrAntiLambda, kPassV0DauTrackSel, + kPassV0KinCuts, kPassV0TopoSel, - kPassV0TopoKinCuts, - kNotLambdaNotAntiLambda, - kV0AsLambdaAntiLambda, - kPassV0MassWinCuts, - kNotPrimaryLambda, - kNotSecondaryLambda, + kAllSelPassed, + kPrimaryLambda, + kSecondaryLambda, kLambdaDauNotMcParticle, kLambdaNotPrPiMinus, kAntiLambdaNotAntiPrPiPlus, kPassTrueLambdaSel, - kEffCorrPt, - kEffCorrPtRap, - kEffCorrPtRapVz, + kEffCorrPtCent, + kEffCorrPtRapCent, kNoEffCorr, + kPFCorrPtCent, + kPFCorrPtRapCent, + kNoPFCorr, kGenTotAccLambda, kGenLambdaNoDau, kGenLambdaToPrPi @@ -191,6 +203,24 @@ enum DMCType { kMC }; +enum CorrHistDim { + OneDimCorr = 1, + TwoDimCorr, + ThreeDimCorr +}; + +enum PrmScdType { + kPrimary = 0, + kSecondary +}; + +enum PrmScdPairType { + kPP = 0, + kPS, + kSP, + kSS +}; + struct LambdaTableProducer { Produces lambdaCollisionTable; @@ -199,8 +229,10 @@ struct LambdaTableProducer { Produces lambdaMCGenTrackTable; // Collisions - Configurable cMinZVtx{"cMinZVtx", -10.0, "z vertex cut"}; - Configurable cMaxZVtx{"cMaxZVtx", 10.0, "z vertex cut"}; + Configurable cMinZVtx{"cMinZVtx", -10.0, "Min VtxZ cut"}; + Configurable cMaxZVtx{"cMaxZVtx", 10.0, "Max VtxZ cut"}; + Configurable cMinMult{"cMinMult", 0., "Minumum Multiplicity"}; + Configurable cMaxMult{"cMaxMult", 100.0, "Maximum Multiplicity"}; Configurable cSel8Trig{"cSel8Trig", true, "Sel8 (T0A + T0C) Selection Run3"}; Configurable cInt7Trig{"cInt7Trig", false, "kINT7 MB Trigger"}; Configurable cSel7Trig{"cSel7Trig", false, "Sel7 (V0A + V0C) Selection Run2"}; @@ -210,53 +242,60 @@ struct LambdaTableProducer { Configurable cItsTpcVtx{"cItsTpcVtx", false, "ITS+TPC Vertex Selection"}; Configurable cPileupReject{"cPileupReject", false, "Pileup rejection"}; Configurable cZVtxTimeDiff{"cZVtxTimeDiff", false, "z-vtx time diff selection"}; + Configurable cIsGoodITSLayers{"cIsGoodITSLayers", false, "Good ITS Layers All"}; // Tracks - Configurable cTrackMinPt{"cTrackMinPt", 0.2, "p_{T} minimum"}; - Configurable cTrackMaxPt{"cTrackMaxPt", 999.0, "p_{T} minimum"}; + Configurable cTrackMinPt{"cTrackMinPt", 0.15, "p_{T} minimum"}; + Configurable cTrackMaxPt{"cTrackMaxPt", 999.0, "p_{T} maximum"}; Configurable cTrackEtaCut{"cTrackEtaCut", 0.8, "Pseudorapidity cut"}; - Configurable cMinTpcCrossedRows{"cMinTpcCrossedRows", 70, "min crossed rows"}; - Configurable cTpcNsigmaCut{"cTpcNsigmaCut", 2.0, "TPC NSigma Selection Cut"}; - Configurable cTrackMinDcaXY{"cTrackMinDcaXY", 0.05, "Minimum DcaXY of Daughter Tracks"}; - Configurable cIsGlobalTrackWoDca{"cIsGlobalTrackWoDca", true, "Check for Global Track"}; + Configurable cMinTpcCrossedRows{"cMinTpcCrossedRows", 70, "TPC Min Crossed Rows"}; + Configurable cMinTpcCROverCls{"cMinTpcCROverCls", 0.8, "Tpc Min Crossed Rows Over Findable Clusters"}; + Configurable cMaxTpcSharedClusters{"cMaxTpcSharedClusters", 0.4, "Tpc Max Shared Clusters"}; + Configurable cMaxChi2Tpc{"cMaxChi2Tpc", 4, "Max Chi2 Tpc"}; + Configurable cTpcNsigmaCut{"cTpcNsigmaCut", 3.0, "TPC NSigma Selection Cut"}; + Configurable cRemoveAmbiguousTracks{"cRemoveAmbiguousTracks", false, "Remove Ambiguous Tracks"}; // V0s + Configurable cMinDcaProtonToPV{"cMinDcaProtonToPV", 0.02, "Minimum Proton DCAr to PV"}; + Configurable cMinDcaPionToPV{"cMinDcaPionToPV", 0.06, "Minimum Pion DCAr to PV"}; Configurable cMinV0DcaDaughters{"cMinV0DcaDaughters", 0., "Minimum DCA between V0 daughters"}; - Configurable cMaxV0DcaDaughters{"cMaxV0DcaDaughters", 1.4, "Maximum DCA between V0 daughters"}; - Configurable cMinDcaPosToPV{"cMinDcaPosToPV", 0.06, "Minimum V0 Positive Track DCAr cut to PV"}; - Configurable cMinDcaNegToPV{"cMinDcaNegToPV", 0.06, "Minimum V0 Negative Track DCAr cut to PV"}; + Configurable cMaxV0DcaDaughters{"cMaxV0DcaDaughters", 1., "Maximum DCA between V0 daughters"}; Configurable cMinDcaV0ToPV{"cMinDcaV0ToPV", 0.0, "Minimum DCA V0 to PV"}; Configurable cMaxDcaV0ToPV{"cMaxDcaV0ToPV", 999.0, "Maximum DCA V0 to PV"}; - Configurable cMinV0TransRadius{"cMinV0TransRadius", 0.2, "Minimum V0 radius from PV"}; + Configurable cMinV0TransRadius{"cMinV0TransRadius", 0.5, "Minimum V0 radius from PV"}; Configurable cMaxV0TransRadius{"cMaxV0TransRadius", 999.0, "Maximum V0 radius from PV"}; Configurable cMinV0CTau{"cMinV0CTau", 0.0, "Minimum ctau"}; Configurable cMaxV0CTau{"cMaxV0CTau", 30.0, "Maximum ctau"}; - Configurable cMinV0CosPA{"cMinV0CosPA", 0.998, "Minimum V0 CosPA to PV"}; - Configurable cLambdaMassWindow{"cLambdaMassWindow", 0.005, "Mass Window to select Lambda"}; - Configurable cKshortRejMassWindow{"cKshortRejMassWindow", 0.017, "Reject K0Short Candidates"}; + Configurable cMinV0CosPA{"cMinV0CosPA", 0.995, "Minimum V0 CosPA to PV"}; + Configurable cKshortRejMassWindow{"cKshortRejMassWindow", 0.01, "Reject K0Short Candidates"}; Configurable cKshortRejFlag{"cKshortRejFlag", true, "K0short Mass Rej Flag"}; - Configurable cArmPodCutValue{"cArmPodCutValue", 0.5, "Armentros-Podolanski Slope Parameter"}; - Configurable cArmPodCutFlag{"cArmPodCutFlag", false, "Armentros-Podolanski Cut Flag"}; // V0s kinmatic acceptance + Configurable cMinV0Mass{"cMinV0Mass", 1.10, "V0 Mass Min"}; + Configurable cMaxV0Mass{"cMaxV0Mass", 1.12, "V0 Mass Min"}; Configurable cMinV0Pt{"cMinV0Pt", 0.8, "Minimum V0 pT"}; - Configurable cMaxV0Pt{"cMaxV0Pt", 2.8, "Minimum V0 pT"}; - Configurable cMaxV0Rap{"cMaxV0Rap", 0.6, "|rap| cut"}; + Configurable cMaxV0Pt{"cMaxV0Pt", 4.2, "Minimum V0 pT"}; + Configurable cMaxV0Rap{"cMaxV0Rap", 0.5, "|rap| cut"}; Configurable cDoEtaAnalysis{"cDoEtaAnalysis", false, "Do Eta Analysis"}; + Configurable cV0TypeSelFlag{"cV0TypeSelFlag", false, "V0 Type Selection Flag"}; + Configurable cV0TypeSelection{"cV0TypeSelection", 1, "V0 Type Selection"}; // V0s MC Configurable cHasMcFlag{"cHasMcFlag", true, "Has Mc Tag"}; - Configurable cSelectTrueLambda{"cSelectTrueLambda", false, "Select True Lambda"}; - Configurable cRecPrimaryLambda{"cRecPrimaryLambda", false, "Primary Reconstructed Lambda"}; - Configurable cRecSecondaryLambda{"cRecSecondaryLambda", false, "Secondary Reconstructed Lambda"}; + Configurable cSelectTrueLambda{"cSelectTrueLambda", true, "Select True Lambda"}; + Configurable cSelMCPSV0{"cSelMCPSV0", true, "Select Primary/Secondary V0"}; + Configurable cCheckRecoDauFlag{"cCheckRecoDauFlag", true, "Check for reco daughter PID"}; Configurable cGenPrimaryLambda{"cGenPrimaryLambda", true, "Primary Generated Lambda"}; + Configurable cGenSecondaryLambda{"cGenSecondaryLambda", false, "Secondary Generated Lambda"}; Configurable cGenDecayChannel{"cGenDecayChannel", true, "Gen Level Decay Channel Flag"}; - Configurable cLambdaToPiProtonBR{"cLambdaToPiProtonBR", 0.639, "#Lambda->p#pi B.R. (63.9%) (PDG)"}; + Configurable cRecoMomResoFlag{"cRecoMomResoFlag", false, "Check effect of momentum space smearing on balance function"}; // Efficiency Correction - Configurable cCorrectionFlag{"cCorrectionFlag", false, "Efficiency Correction Flag"}; - Configurable cCorrFactHist{"cCorrFactHist", 0, "Correction Factor Histogram"}; - Configurable cDoEtaCorr{"cDoEtaCorr", false, "Do Eta Corr"}; + Configurable cCorrectionFlag{"cCorrectionFlag", false, "Correction Flag"}; + Configurable cGetEffFact{"cGetEffFact", false, "Get Efficiency Factor Flag"}; + Configurable cGetPrimFrac{"cGetPrimFrac", false, "Get Primary Fraction Flag"}; + Configurable cCorrFactHist{"cCorrFactHist", 0, "Efficiency Factor Histogram"}; + Configurable cPrimFracHist{"cPrimFracHist", 0, "Primary Fraction Histogram"}; // CCDB Configurable cUrlCCDB{"cUrlCCDB", "http://ccdb-test.cern.ch:8080", "url of ccdb"}; @@ -269,11 +308,19 @@ struct LambdaTableProducer { HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; // initialize corr_factor objects - std::vector> vCorrFactStrings = {{"hEffVsPtLambda", "hEffVsPtAntiLambda"}, - {"hEffVsPtYLambda", "hEffVsPtYAntiLambda"}, - {"hEffVsPtEtaLambda", "hEffVsPtEtaAntiLambda"}, - {"hEffVsPtYVzLambda", "hEffVsPtYVzAntiLambda"}, - {"hEffVsPtEtaVzLambda", "hEffVsPtEtaVzAntiLambda"}}; + std::vector> vCorrFactStrings = {{"hEffVsPtCentLambda", "hEffVsPtCentAntiLambda"}, + {"hEffVsPtYCentLambda", "hEffVsPtYCentAntiLambda"}, + {"hEffVsPtEtaCentLambda", "hEffVsPtEtaCentAntiLambda"}}; + + // initialize corr_factor objects + std::vector> vPrimFracStrings = {{"hPrimFracVsPtCentLambda", "hPrimFracVsPtCentAntiLambda"}, + {"hPrimFracVsPtYCentLambda", "hPrimFracVsPtYCentAntiLambda"}, + {"hPrimFracVsPtEtaCentLambda", "hPrimFracVsPtEtaCentAntiLambda"}}; + + // Initialize Global Variables + float cent = 0.; + float pt = 0., eta = 0., rap = 0., phi = 0.; + bool bSecondaryLambdaFlag = false; void init(InitContext const&) { @@ -283,20 +330,20 @@ struct LambdaTableProducer { // initialize axis specifications const AxisSpec axisCols(5, 0.5, 5.5, ""); - const AxisSpec axisTrks(25, 0.5, 25.5, ""); - const AxisSpec axisCent(105, 0, 105, "FT0M (%)"); + const AxisSpec axisTrks(30, 0.5, 30.5, ""); + const AxisSpec axisCent(100, 0, 100, "FT0M (%)"); const AxisSpec axisMult(10, 0, 10, "N_{#Lambda}"); const AxisSpec axisVz(220, -11, 11, "V_{z} (cm)"); const AxisSpec axisPID(8000, -4000, 4000, "PdgCode"); - const AxisSpec axisV0Mass(200, 1.09, 1.14, "M_{p#pi} (GeV/#it{c}^{2})"); - const AxisSpec axisV0Pt(38, 0.2, 4.0, "p_{T} (GeV/#it{c})"); - const AxisSpec axisV0Rap(24, -1.2, 1.2, "y"); - const AxisSpec axisV0Eta(24, -1.2, 1.2, "#eta"); + const AxisSpec axisV0Mass(140, 1.08, 1.15, "M_{p#pi} (GeV/#it{c}^{2})"); + const AxisSpec axisV0Pt(100., 0., 10., "p_{T} (GeV/#it{c})"); + const AxisSpec axisV0Rap(48, -1.2, 1.2, "y"); + const AxisSpec axisV0Eta(48, -1.2, 1.2, "#eta"); const AxisSpec axisV0Phi(36, 0., TwoPI, "#phi (rad)"); const AxisSpec axisRadius(2000, 0, 200, "r(cm)"); - const AxisSpec axisCosPA(500, 0.995, 1.0, "cos(#theta_{PA})"); + const AxisSpec axisCosPA(300, 0.97, 1.0, "cos(#theta_{PA})"); const AxisSpec axisDcaV0PV(1000, 0., 10., "dca (cm)"); const AxisSpec axisDcaProngPV(5000, -50., 50., "dca (cm)"); const AxisSpec axisDcaDau(75, 0., 1.5, "Daug DCA (#sigma)"); @@ -350,11 +397,18 @@ struct LambdaTableProducer { histos.add("QA/Lambda/h2f_pos_prong_tpc_nsigma_pi_vs_p", "TPC n#sigma Pos Prong", kTH2F, {axisMomPID, axisNsigma}); histos.add("QA/Lambda/h2f_neg_prong_tpc_nsigma_pi_vs_p", "TPC n#sigma Neg Prong", kTH2F, {axisMomPID, axisNsigma}); + // Kinematic Histograms + histos.add("McRec/Lambda/hPt", "Transverse Momentum", kTH1F, {axisV0Pt}); + histos.add("McRec/Lambda/hEta", "Pseudorapidity", kTH1F, {axisV0Eta}); + histos.add("McRec/Lambda/hRap", "Rapidity", kTH1F, {axisV0Rap}); + histos.add("McRec/Lambda/hPhi", "Azimuthal Angle", kTH1F, {axisV0Phi}); + // QA Anti-Lambda histos.addClone("QA/Lambda/", "QA/AntiLambda/"); + histos.addClone("McRec/Lambda/", "McRec/AntiLambda/"); // MC Generated Histograms - if (doprocessMCGen) { + if (doprocessMCRun3 || doprocessMCRun2 || doprocessMCRecoRun3 || doprocessMCRecoRun2) { // McReco Histos histos.add("Tracks/h2f_tracks_pid_before_sel", "PIDs", kTH2F, {axisPID, axisV0Pt}); histos.add("Tracks/h2f_tracks_pid_after_sel", "PIDs", kTH2F, {axisPID, axisV0Pt}); @@ -363,16 +417,31 @@ struct LambdaTableProducer { histos.add("Tracks/h2f_lambda_from_omega", "PIDs", kTH2F, {axisPID, axisV0Pt}); // McGen Histos + histos.add("McGen/h1f_collision_recgen", "# of Reco Collision Associated to One Mc Generator Collision", kTH1F, {axisMult}); histos.add("McGen/h1f_collisions_info", "# of collisions", kTH1F, {axisCols}); - histos.add("McGen/h1f_collision_posZ", "V_{z}-distribution", kTH1F, {axisVz}); + histos.add("McGen/h2f_collision_posZ", "V_{z}-distribution", kTH2F, {axisVz, axisVz}); + histos.add("McGen/h2f_collision_cent", "FT0M Centrality", kTH2F, {axisCent, axisCent}); histos.add("McGen/h1f_lambda_daughter_PDG", "PDG Daughters", kTH1F, {axisPID}); histos.add("McGen/h1f_antilambda_daughter_PDG", "PDG Daughters", kTH1F, {axisPID}); + histos.addClone("McRec/", "McGen/"); + + histos.add("McGen/Lambda/Proton/hPt", "Proton p_{T}", kTH1F, {axisTrackPt}); + histos.add("McGen/Lambda/Proton/hEta", "Proton #eta", kTH1F, {axisV0Eta}); + histos.add("McGen/Lambda/Proton/hRap", "Proton y", kTH1F, {axisV0Rap}); + histos.add("McGen/Lambda/Proton/hPhi", "Proton #phi", kTH1F, {axisV0Phi}); + + histos.addClone("McGen/Lambda/Proton/", "McGen/Lambda/Pion/"); + histos.addClone("McGen/Lambda/Proton/", "McGen/AntiLambda/Proton/"); + histos.addClone("McGen/Lambda/Pion/", "McGen/AntiLambda/Pion/"); + // set bin lables specific to MC histos.get(HIST("Events/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kTotColBeforeHasMcCollision, "kTotColBeforeHasMcCollision"); + histos.get(HIST("McGen/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kTotCol, "kTotCol"); + histos.get(HIST("McGen/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kPassSelCol, "kPassSelCol"); histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kTracksBeforeHasMcParticle, "kTracksBeforeHasMcParticle"); - histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNotPrimaryLambda, "kNotPrimaryLambda"); - histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNotSecondaryLambda, "kNotSecondaryLambda"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kPrimaryLambda, "kPrimaryLambda"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kSecondaryLambda, "kSecondaryLambda"); histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kLambdaDauNotMcParticle, "kLambdaDauNotMcParticle"); histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kLambdaNotPrPiMinus, "kLambdaNotPrPiMinus"); histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kAntiLambdaNotAntiPrPiPlus, "kAntiLambdaNotAntiPrPiPlus"); @@ -386,39 +455,50 @@ struct LambdaTableProducer { histos.get(HIST("Events/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kTotCol, "kTotCol"); histos.get(HIST("Events/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kPassSelCol, "kPassSelCol"); histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kAllV0Tracks, "kAllV0Tracks"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kV0KShortMassRej, "kV0KShortMassRej"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNotLambdaNotAntiLambda, "kNotLambdaNotAntiLambda"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kV0IsBothLambdaAntiLambda, "kV0IsBothLambdaAntiLambda"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNotLambdaAfterSel, "kNotLambdaAfterSel"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kV0IsLambdaOrAntiLambda, "kV0IsLambdaOrAntiLambda"); histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kPassV0DauTrackSel, "kPassV0DauTrackSel"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kPassV0KinCuts, "kPassV0KinCuts"); histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kPassV0TopoSel, "kPassV0TopoSel"); - histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kPassV0TopoKinCuts, "kPassV0TopoKinCuts"); - histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNotLambdaNotAntiLambda, "kNotLambdaNotAntiLambda"); - histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kV0AsLambdaAntiLambda, "kV0AsLambdaAntiLambda"); - histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kPassV0MassWinCuts, "kPassV0MassWinCuts"); - histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kEffCorrPt, "kEffCorrPt"); - histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kEffCorrPtRap, "kEffCorrPtRap"); - histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kEffCorrPtRapVz, "kEffCorrPtRapVz"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kAllSelPassed, "kAllSelPassed"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kEffCorrPtCent, "kEffCorrPtCent"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kEffCorrPtRapCent, "kEffCorrPtRapCent"); histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNoEffCorr, "kNoEffCorr"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kPFCorrPtCent, "kPFCorrPtCent"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kPFCorrPtRapCent, "kPFCorrPtRapCent"); + histos.get(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNoPFCorr, "kNoPFCorr"); } template bool selCollision(C const& col) { + // VtxZ Selection if (col.posZ() <= cMinZVtx || col.posZ() >= cMaxZVtx) { return false; } - if constexpr (run == kRun3) { + if constexpr (run == kRun3) { // Run3 Min-Bias Trigger + cent = col.centFT0M(); if (cSel8Trig && !col.sel8()) { return false; } - } else { + } else { // Run2 Min-Bias Trigger + cent = col.centRun2V0M(); if (cInt7Trig && !col.alias_bit(kINT7)) { return false; } - if (cSel7Trig && !col.sel7()) { return false; } } + if (cent <= cMinMult || cent >= cMaxMult) { // select centrality + return false; + } + if (cTriggerTvxSel && !col.selection_bit(aod::evsel::kIsTriggerTVX)) { return false; } @@ -443,17 +523,28 @@ struct LambdaTableProducer { return false; } + if (cIsGoodITSLayers && !col.selection_bit(aod::evsel::kIsGoodITSLayersAll)) { + return false; + } + return true; } - template - bool selDaughterTracks(T const& track) + // Kinematic Selection + bool kinCutSelection(float const& pt, float const& rap, float const& ptMin, float const& ptMax, float const& rapMax) { - if (track.pt() <= cTrackMinPt || track.pt() >= cTrackMaxPt) { + if (pt <= ptMin || pt >= ptMax || rap >= rapMax) { return false; } - if (std::abs(track.eta()) >= cTrackEtaCut) { + return true; + } + + // Track Selection + template + bool selTrack(T const& track) + { + if (!kinCutSelection(track.pt(), std::abs(track.eta()), cTrackMinPt, cTrackMaxPt, cTrackEtaCut)) { return false; } @@ -461,38 +552,54 @@ struct LambdaTableProducer { return false; } - if (std::abs(track.dcaXY()) <= cTrackMinDcaXY) { + if (track.tpcCrossedRowsOverFindableCls() < cMinTpcCROverCls) { return false; } - if (cIsGlobalTrackWoDca && !track.isGlobalTrackWoDCA()) { + if (track.tpcNClsShared() > cMaxTpcSharedClusters) { + return false; + } + + if (track.tpcChi2NCl() > cMaxChi2Tpc) { return false; } return true; } - template - bool selLambdaWithTopoKinCuts(C const& col, V const& v0, T const&) + // Daughter Track Selection + template + bool selDaughterTracks(V const& v0, T const&, ParticleType const& v0Type) { - auto postrack = v0.template posTrack_as(); - auto negtrack = v0.template negTrack_as(); + auto posTrack = v0.template posTrack_as(); + auto negTrack = v0.template negTrack_as(); - if (!selDaughterTracks(postrack) || !selDaughterTracks(negtrack)) { + if (!selTrack(posTrack) || !selTrack(negTrack)) { return false; } - histos.fill(HIST("Tracks/h1f_tracks_info"), kPassV0DauTrackSel); - - if (v0.dcaV0daughters() <= cMinV0DcaDaughters || v0.dcaV0daughters() >= cMaxV0DcaDaughters) { - return false; + // Apply DCA Selection on Daughter Tracks Based on Lambda/AntiLambda daughters + float dcaProton = 0., dcaPion = 0.; + if (v0Type == kLambda) { + dcaProton = std::abs(v0.dcapostopv()); + dcaPion = std::abs(v0.dcanegtopv()); + } else if (v0Type == kAntiLambda) { + dcaPion = std::abs(v0.dcapostopv()); + dcaProton = std::abs(v0.dcanegtopv()); } - if (std::abs(v0.dcapostopv()) < cMinDcaPosToPV) { + if (dcaProton < cMinDcaProtonToPV || dcaPion < cMinDcaPionToPV) { return false; } - if (std::abs(v0.dcanegtopv()) < cMinDcaNegToPV) { + return true; + } + + template + bool topoCutSelection(C const& col, V const& v0, T const&) + { + // DCA + if (v0.dcaV0daughters() <= cMinV0DcaDaughters || v0.dcaV0daughters() >= cMaxV0DcaDaughters) { return false; } @@ -515,19 +622,6 @@ struct LambdaTableProducer { return false; } - histos.fill(HIST("Tracks/h1f_tracks_info"), kPassV0TopoSel); - - // pT cut - if (v0.pt() <= cMinV0Pt || v0.pt() >= cMaxV0Pt) { - return false; - } - - // rapidity | pseudo-rapidity cut - float rap = (cDoEtaAnalysis) ? v0.eta() : v0.yLambda(); - if (std::abs(rap) >= cMaxV0Rap) { - return false; - } - // all selection criterion passed (Return True) return true; } @@ -562,6 +656,12 @@ struct LambdaTableProducer { template bool selLambdaMassWindow(V const& v0, T const&, ParticleType& v0type) { + // Kshort mass rejection hypothesis + if (cKshortRejFlag && (std::abs(v0.mK0Short() - MassK0Short) <= cKshortRejMassWindow)) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kV0KShortMassRej); + return false; + } + // initialize daughter tracks auto postrack = v0.template posTrack_as(); auto negtrack = v0.template negTrack_as(); @@ -570,13 +670,13 @@ struct LambdaTableProducer { bool lambdaFlag = false, antiLambdaFlag = false; // get v0 track as lambda - if ((std::abs(v0.mLambda() - MassLambda0) < cLambdaMassWindow) && (selLambdaDauWithTpcPid(postrack, negtrack))) { + if ((v0.mLambda() > cMinV0Mass && v0.mLambda() < cMaxV0Mass) && (selLambdaDauWithTpcPid(postrack, negtrack))) { lambdaFlag = true; v0type = kLambda; } // get v0 track as anti-lambda - if ((std::abs(v0.mAntiLambda() - MassLambda0) < cLambdaMassWindow) && (selLambdaDauWithTpcPid(postrack, negtrack))) { + if ((v0.mAntiLambda() > cMinV0Mass && v0.mAntiLambda() < cMaxV0Mass) && (selLambdaDauWithTpcPid(postrack, negtrack))) { antiLambdaFlag = true; v0type = kAntiLambda; } @@ -585,79 +685,146 @@ struct LambdaTableProducer { histos.fill(HIST("Tracks/h1f_tracks_info"), kNotLambdaNotAntiLambda); return false; } else if (lambdaFlag && antiLambdaFlag) { // check if the track is identified as lambda and anti-lambda both (DISCARD THIS TRACK) - histos.fill(HIST("Tracks/h1f_tracks_info"), kV0AsLambdaAntiLambda); + histos.fill(HIST("Tracks/h1f_tracks_info"), kV0IsBothLambdaAntiLambda); return false; } - // Armentros-Podolanski Selection - if (cArmPodCutFlag && (std::abs(v0.alpha()) < v0.qtarm() / cArmPodCutValue)) { + if (lambdaFlag || antiLambdaFlag) { + return true; + } + + histos.fill(HIST("Tracks/h1f_tracks_info"), kNotLambdaAfterSel); + + return false; + } + + template + bool selV0Particle(C const& col, V const& v0, T const& tracks, ParticleType& v0Type) + { + // Apply Lambda Mass Hypothesis + if (!selLambdaMassWindow(v0, tracks, v0Type)) { return false; } - // Kshort mass rejection hypothesis - if (cKshortRejFlag && (std::abs(v0.mK0Short() - MassK0Short) <= cKshortRejMassWindow)) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kV0IsLambdaOrAntiLambda); + + // Apply Daughter Track Selection + if (!selDaughterTracks(v0, tracks, v0Type)) { return false; } - if (lambdaFlag || antiLambdaFlag) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kPassV0DauTrackSel); + + // Apply Kinematic Selection + float rap = 0.; + if (!cDoEtaAnalysis) { + rap = std::abs(v0.yLambda()); + } else { + rap = std::abs(v0.eta()); + } + + if (!kinCutSelection(v0.pt(), rap, cMinV0Pt, cMaxV0Pt, cMaxV0Rap)) { + return false; + } + + histos.fill(HIST("Tracks/h1f_tracks_info"), kPassV0KinCuts); + + // Apply Topological Selection + if (!topoCutSelection(col, v0, tracks)) { + return false; + } + + histos.fill(HIST("Tracks/h1f_tracks_info"), kPassV0TopoSel); + + // All Selection Criterion Passed + return true; + } + + template + bool hasAmbiguousDaughters(V const& v0, T const&) + { + auto posTrack = v0.template posTrack_as(); + auto negTrack = v0.template negTrack_as(); + + auto posTrackCompCols = posTrack.compatibleCollIds(); + auto negTrackCompCols = negTrack.compatibleCollIds(); + + // Check if daughter tracks belongs to more than one collision (Ambiguous Tracks) + if (posTrackCompCols.size() > 1 || negTrackCompCols.size() > 1) { return true; } - histos.fill(HIST("Tracks/h1f_tracks_info"), 23.5); + // Check if compatible collision index matches the track collision index + if (((posTrackCompCols.size() != 0) && (posTrackCompCols[0] != posTrack.collisionId())) || + ((negTrackCompCols.size() != 0) && (negTrackCompCols[0] != negTrack.collisionId()))) { + return true; + } + // Pass as not ambiguous return false; } - template - bool selTrueMcRecLambda(V const& v0, T const&) + template + PrmScdType isPrimaryV0(V const& v0) { auto mcpart = v0.template mcParticle_as(); - if (std::abs(mcpart.pdgCode()) != kLambda0) { - return false; + // check for secondary lambda + if (!mcpart.isPhysicalPrimary()) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kSecondaryLambda); + bSecondaryLambdaFlag = true; + return kSecondary; } - // check for primary/secondary lambda - if (cRecPrimaryLambda && !mcpart.isPhysicalPrimary()) { - histos.fill(HIST("Tracks/h1f_tracks_info"), kNotPrimaryLambda); - return false; - } else if (cRecSecondaryLambda && mcpart.isPhysicalPrimary()) { - histos.fill(HIST("Tracks/h1f_tracks_info"), kNotSecondaryLambda); - return false; - } + histos.fill(HIST("Tracks/h1f_tracks_info"), kPrimaryLambda); + return kPrimary; + } - auto postrack = v0.template posTrack_as(); - auto negtrack = v0.template negTrack_as(); + template + bool selTrueMcRecLambda(V const& v0, T const&) + { + auto mcpart = v0.template mcParticle_as(); - // check if the daughters have corresponding mcparticle - if (!postrack.has_mcParticle() || !negtrack.has_mcParticle()) { - histos.fill(HIST("Tracks/h1f_tracks_info"), kLambdaDauNotMcParticle); + // check if Lambda/AntiLambda + if (std::abs(mcpart.pdgCode()) != kLambda0) { return false; } - auto mcpostrack = postrack.template mcParticle_as(); - auto mcnegtrack = negtrack.template mcParticle_as(); + // Check for daughters + if (cCheckRecoDauFlag) { + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); - if (mcpart.pdgCode() == kLambda0) { - if (mcpostrack.pdgCode() != kProton || mcnegtrack.pdgCode() != kPiMinus) { - histos.fill(HIST("Tracks/h1f_tracks_info"), kLambdaNotPrPiMinus); + // check if the daughters have corresponding mcparticle + if (!postrack.has_mcParticle() || !negtrack.has_mcParticle()) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kLambdaDauNotMcParticle); return false; } - } else if (mcpart.pdgCode() == kLambda0Bar) { - if (mcpostrack.pdgCode() != kPiPlus || mcnegtrack.pdgCode() != kProtonBar) { - histos.fill(HIST("Tracks/h1f_tracks_info"), kAntiLambdaNotAntiPrPiPlus); - return false; + + auto mcpostrack = postrack.template mcParticle_as(); + auto mcnegtrack = negtrack.template mcParticle_as(); + + if (mcpart.pdgCode() == kLambda0) { + if (mcpostrack.pdgCode() != kProton || mcnegtrack.pdgCode() != kPiMinus) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kLambdaNotPrPiMinus); + return false; + } + } else if (mcpart.pdgCode() == kLambda0Bar) { + if (mcpostrack.pdgCode() != kPiPlus || mcnegtrack.pdgCode() != kProtonBar) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kAntiLambdaNotAntiPrPiPlus); + return false; + } } } // get information about secondary lambdas - if (cRecSecondaryLambda) { + if (bSecondaryLambdaFlag) { auto lambdaMothers = mcpart.template mothers_as(); - if (std::abs(lambdaMothers[0].pdgCode()) == 3112 || std::abs(lambdaMothers[0].pdgCode()) == 3212 || std::abs(lambdaMothers[0].pdgCode()) == 3222) { + if (std::abs(lambdaMothers[0].pdgCode()) == kSigmaMinus || std::abs(lambdaMothers[0].pdgCode()) == kSigma0 || std::abs(lambdaMothers[0].pdgCode()) == kSigmaPlus) { histos.fill(HIST("Tracks/h2f_lambda_from_sigma"), mcpart.pdgCode(), mcpart.pt()); - } else if (std::abs(lambdaMothers[0].pdgCode()) == 3312 || std::abs(lambdaMothers[0].pdgCode()) == 3322) { + } else if (std::abs(lambdaMothers[0].pdgCode()) == kXiMinus || std::abs(lambdaMothers[0].pdgCode()) == kXi0) { histos.fill(HIST("Tracks/h2f_lambda_from_cascade"), mcpart.pdgCode(), mcpart.pt()); - } else if (std::abs(lambdaMothers[0].pdgCode()) == 3334) { + } else if (std::abs(lambdaMothers[0].pdgCode()) == kOmegaMinus) { histos.fill(HIST("Tracks/h2f_lambda_from_omega"), mcpart.pdgCode(), mcpart.pt()); } } @@ -665,10 +832,10 @@ struct LambdaTableProducer { return true; } - template - float getCorrectionFactors(C const& col, V const& v0) + template + float getCorrectionFactors(V const& v0) { - // Check for efficiency correction flag and Rec/Gen Data + // Check for efficiency correction flag if (!cCorrectionFlag) { return 1.; } @@ -682,29 +849,48 @@ struct LambdaTableProducer { return 1.; } - // get ccdb object - TObject* obj = reinterpret_cast(ccdbObj->FindObject(Form("%s", vCorrFactStrings[cCorrFactHist][part].c_str()))); - TH1F* hist = reinterpret_cast(obj->Clone()); - float retVal = 0.; - float rap = (cDoEtaCorr) ? v0.eta() : v0.yLambda(); - - if (std::string(obj->ClassName()) == "TH1F") { - histos.fill(HIST("Tracks/h1f_tracks_info"), kEffCorrPt); - retVal = hist->GetBinContent(hist->FindBin(v0.pt())); - } else if (std::string(obj->ClassName()) == "TH2F") { - histos.fill(HIST("Tracks/h1f_tracks_info"), kEffCorrPtRap); - retVal = hist->GetBinContent(hist->FindBin(v0.pt(), rap)); - } else if (std::string(obj->ClassName()) == "TH3F") { - histos.fill(HIST("Tracks/h1f_tracks_info"), kEffCorrPtRapVz); - retVal = hist->GetBinContent(hist->FindBin(v0.pt(), rap, col.posZ())); - } else { - histos.fill(HIST("Tracks/h1f_tracks_info"), kNoEffCorr); - LOGF(warning, "CCDB OBJECT IS NOT A HISTOGRAM !!!"); - retVal = 1.; + // initialize efficiency factor and primary fraction values + float effCorrFact = 1., primFrac = 1.; + float rap = (cDoEtaAnalysis) ? v0.eta() : v0.yLambda(); + + // Get Efficiency Factor + if (cGetEffFact) { + TObject* objEff = reinterpret_cast(ccdbObj->FindObject(Form("%s", vCorrFactStrings[cCorrFactHist][part].c_str()))); + TH1F* histEff = reinterpret_cast(objEff->Clone()); + if (histEff->GetDimension() == TwoDimCorr) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kEffCorrPtCent); + effCorrFact = histEff->GetBinContent(histEff->FindBin(cent, v0.pt())); + } else if (histEff->GetDimension() == ThreeDimCorr) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kEffCorrPtRapCent); + effCorrFact = histEff->GetBinContent(histEff->FindBin(cent, v0.pt(), rap)); + } else { + histos.fill(HIST("Tracks/h1f_tracks_info"), kNoEffCorr); + LOGF(warning, "CCDB OBJECT IS NOT A HISTOGRAM !!!"); + effCorrFact = 1.; + } + delete histEff; + } + + // Get Primary Fraction + // (The dimension of this could be different than efficiency because of large errors !!!) + if (cGetPrimFrac) { + TObject* objPrm = reinterpret_cast(ccdbObj->FindObject(Form("%s", vPrimFracStrings[cPrimFracHist][part].c_str()))); + TH1F* histPrm = reinterpret_cast(objPrm->Clone()); + if (histPrm->GetDimension() == TwoDimCorr) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kPFCorrPtCent); + primFrac = histPrm->GetBinContent(histPrm->FindBin(cent, v0.pt())); + } else if (histPrm->GetDimension() == ThreeDimCorr) { + histos.fill(HIST("Tracks/h1f_tracks_info"), kPFCorrPtRapCent); + primFrac = histPrm->GetBinContent(histPrm->FindBin(cent, v0.pt(), rap)); + } else { + histos.fill(HIST("Tracks/h1f_tracks_info"), kNoPFCorr); + LOGF(warning, "CCDB OBJECT IS NOT A HISTOGRAM !!!"); + primFrac = 1.; + } + delete histPrm; } - delete hist; - return retVal; + return primFrac * effCorrFact; } template @@ -756,45 +942,49 @@ struct LambdaTableProducer { histos.fill(HIST(SubDir[part]) + HIST("h2f_neg_prong_tpc_nsigma_pi_vs_p"), negtrack.tpcInnerParam(), negtrack.tpcNSigmaPi()); } - template - void fillLambdaTables(C const& collision, V const& v0tracks, T const& tracks) + // Fill Lambda Kinematic Histograms + template + void fillKinematicHists(float const& pt, float const& eta, float const& y, float const& phi) { - if constexpr (dmc == kMC) { - histos.fill(HIST("Events/h1f_collisions_info"), kTotColBeforeHasMcCollision); - if (!collision.has_mcCollision()) { - return; - } - } + static constexpr std::string_view SubDirRG[] = {"McRec/", "McGen/"}; + static constexpr std::string_view SubDirPart[] = {"Lambda/", "AntiLambda/"}; + histos.fill(HIST(SubDirRG[rg]) + HIST(SubDirPart[part]) + HIST("hPt"), pt); + histos.fill(HIST(SubDirRG[rg]) + HIST(SubDirPart[part]) + HIST("hEta"), eta); + histos.fill(HIST(SubDirRG[rg]) + HIST(SubDirPart[part]) + HIST("hRap"), y); + histos.fill(HIST(SubDirRG[rg]) + HIST(SubDirPart[part]) + HIST("hPhi"), phi); + } + + // Reconstructed Level Tables + template + void fillLambdaRecoTables(C const& collision, V const& v0tracks, T const& tracks) + { + // Total Collisions histos.fill(HIST("Events/h1f_collisions_info"), kTotCol); - // select collision - if (!selCollision(collision)) { - return; + // Select Collision (Only for Data... McRec has been selected already !!!) + if constexpr (dmc == kData) { + if (!selCollision(collision)) { + return; + } } histos.fill(HIST("Events/h1f_collisions_info"), kPassSelCol); histos.fill(HIST("Events/h1f_collision_posZ"), collision.posZ()); - float cent = 0.; - - if constexpr (run == kRun3) { - cent = collision.centFT0M(); - } else { - cent = collision.centRun2V0M(); - } - + // Fill Collision Table lambdaCollisionTable(cent, collision.posX(), collision.posY(), collision.posZ()); // initialize v0track objects - ParticleType v0type = kLambda; + ParticleType v0Type = kLambda; + PrmScdType v0PrmScdType = kPrimary; float mass = 0., corr_fact = 1.; for (auto const& v0 : v0tracks) { // check for corresponding MCGen Particle if constexpr (dmc == kMC) { histos.fill(HIST("Tracks/h1f_tracks_info"), kTracksBeforeHasMcParticle); - if (!v0.has_mcParticle() || !v0.template posTrack_as().has_mcParticle() || !v0.template negTrack_as().has_mcParticle()) { + if (!v0.has_mcParticle()) { continue; } } @@ -802,125 +992,120 @@ struct LambdaTableProducer { histos.fill(HIST("Tracks/h1f_tracks_info"), kAllV0Tracks); histos.fill(HIST("Tracks/h2f_armpod_before_sel"), v0.alpha(), v0.qtarm()); - // topological and kinematic selection - if (!selLambdaWithTopoKinCuts(collision, v0, tracks)) { + // Select V0 Particle as Lambda/AntiLambda + if (!selV0Particle(collision, v0, tracks, v0Type)) { continue; } - histos.fill(HIST("Tracks/h1f_tracks_info"), kPassV0TopoKinCuts); + // Select V0 Type Selection + if (cV0TypeSelFlag && v0.v0Type() != cV0TypeSelection) { + continue; + } - // select v0 as lambda / anti-lambda - // armeteros-podolanski selection | kshort mass rejection hypothesis - if (!selLambdaMassWindow(v0, tracks, v0type)) { + // we have v0 as lambda + histos.fill(HIST("Tracks/h1f_tracks_info"), kAllSelPassed); + + // Remove lambda with ambiguous daughters + if (cRemoveAmbiguousTracks && hasAmbiguousDaughters(v0, tracks)) { continue; } - histos.fill(HIST("Tracks/h1f_tracks_info"), kPassV0MassWinCuts); + // Get Lambda mass and kinematic variables + mass = (v0Type == kLambda) ? v0.mLambda() : v0.mAntiLambda(); + pt = v0.pt(); + eta = v0.eta(); + rap = v0.yLambda(); + phi = v0.phi(); - // we have v0 as lambda // do MC analysis if constexpr (dmc == kMC) { histos.fill(HIST("Tracks/h2f_tracks_pid_before_sel"), v0.mcParticle().pdgCode(), v0.pt()); - if (cSelectTrueLambda && !selTrueMcRecLambda(v0, tracks)) { + + if (cSelMCPSV0) { // Get Primary/Secondary Lambda + v0PrmScdType = isPrimaryV0(v0); + } + if (cSelectTrueLambda && !selTrueMcRecLambda(v0, tracks)) { // check for true Lambda/Anti-Lambda continue; } + histos.fill(HIST("Tracks/h1f_tracks_info"), kPassTrueLambdaSel); histos.fill(HIST("Tracks/h2f_tracks_pid_after_sel"), v0.mcParticle().pdgCode(), v0.pt()); + + if (cRecoMomResoFlag) { + auto mc = v0.template mcParticle_as(); + pt = mc.pt(); + eta = mc.eta(); + rap = mc.y(); + phi = mc.phi(); + float y = (cDoEtaAnalysis) ? eta : rap; + // apply kinematic selection (On Truth) + if (!kinCutSelection(pt, std::abs(y), cMinV0Pt, cMaxV0Pt, cMaxV0Rap)) { + continue; + } + } } histos.fill(HIST("Tracks/h2f_armpod_after_sel"), v0.alpha(), v0.qtarm()); - // get correction factors and mass - corr_fact = (v0type == kLambda) ? getCorrectionFactors(collision, v0) : getCorrectionFactors(collision, v0); - mass = (v0type == kLambda) ? v0.mLambda() : v0.mAntiLambda(); + // get correction factors + corr_fact = (v0Type == kLambda) ? getCorrectionFactors(v0) : getCorrectionFactors(v0); // fill lambda qa - if (v0type == kLambda) { + if (v0Type == kLambda) { histos.fill(HIST("Tracks/h1f_lambda_pt_vs_invm"), mass, v0.pt()); fillLambdaQAHistos(collision, v0, tracks); + fillKinematicHists(v0.pt(), v0.eta(), v0.yLambda(), v0.phi()); } else { histos.fill(HIST("Tracks/h1f_antilambda_pt_vs_invm"), mass, v0.pt()); fillLambdaQAHistos(collision, v0, tracks); + fillKinematicHists(v0.pt(), v0.eta(), v0.yLambda(), v0.phi()); } // Fill Lambda/AntiLambda Table lambdaTrackTable(lambdaCollisionTable.lastIndex(), v0.px(), v0.py(), v0.pz(), - v0.pt(), v0.eta(), v0.phi(), v0.yLambda(), mass, - v0.template posTrack_as().index(), v0.template negTrack_as().index(), - (int8_t)v0type, v0.v0cosPA(), v0.dcaV0daughters(), corr_fact); + pt, eta, phi, rap, mass, v0.template posTrack_as().index(), v0.template negTrack_as().index(), + v0.v0cosPA(), v0.dcaV0daughters(), (int8_t)v0Type, v0PrmScdType, corr_fact); } } - using CollisionsRun3 = soa::Join; - using CollisionsRun2 = soa::Join; - using Tracks = soa::Join; - using McV0Tracks = soa::Join; - using TracksMC = soa::Join; - - void processDataRun3(CollisionsRun3::iterator const& collision, aod::V0Datas const& V0s, Tracks const& tracks) - { - fillLambdaTables(collision, V0s, tracks); - } - - PROCESS_SWITCH(LambdaTableProducer, processDataRun3, "Process for Run3 DATA", true); - - void processDataRun2(CollisionsRun2::iterator const& collision, aod::V0Datas const& V0s, Tracks const& tracks) + // MC Generater Level Tables + template + void fillLambdaMcGenTables(C const& mcCollision, M const& mcParticles) { - fillLambdaTables(collision, V0s, tracks); - } - - PROCESS_SWITCH(LambdaTableProducer, processDataRun2, "Process for Run2 DATA", false); - - void processMCRecoRun3(soa::Join::iterator const& collision, aod::McCollisions const&, - McV0Tracks const& V0s, aod::McParticles const&, TracksMC const& tracks) - { - fillLambdaTables(collision, V0s, tracks); - } - - PROCESS_SWITCH(LambdaTableProducer, processMCRecoRun3, "Process for Run3 MC Reconstructed", false); - - void processMCRecoRun2(soa::Join::iterator const& collision, aod::McCollisions const&, - McV0Tracks const& V0s, aod::McParticles const&, TracksMC const& tracks) - { - fillLambdaTables(collision, V0s, tracks); - } - - PROCESS_SWITCH(LambdaTableProducer, processMCRecoRun2, "Process for Run2 MC Reconstructed", false); - - void processMCGen(aod::McCollisions::iterator const& mcCollision, aod::McParticles const& mcParticles) - { - histos.fill(HIST("McGen/h1f_collisions_info"), 1.5); - - // apply collision cuts - if (mcCollision.posZ() <= cMinZVtx || mcCollision.posZ() >= cMaxZVtx) { - return; - } - - histos.fill(HIST("McGen/h1f_collisions_info"), 2.5); - histos.fill(HIST("McGen/h1f_collision_posZ"), mcCollision.posZ()); - lambdaMCGenCollisionTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()); + // Fill McGen Collision Table + lambdaMCGenCollisionTable(cent, mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()); // initialize track objects - ParticleType v0type = kLambda; + ParticleType v0Type = kLambda; + PrmScdType v0PrmScdType = kPrimary; + float rap = 0.; for (auto const& mcpart : mcParticles) { - // check for Lambda first if (mcpart.pdgCode() == kLambda0) { - v0type = kLambda; + v0Type = kLambda; } else if (mcpart.pdgCode() == kLambda0Bar) { - v0type = kAntiLambda; + v0Type = kAntiLambda; } else { continue; } - // check for Primary Lambdas/AntiLambdas - if (cGenPrimaryLambda && !mcpart.isPhysicalPrimary()) { - continue; + // check for Primary Lambda/AntiLambda + if (mcpart.isPhysicalPrimary()) { + v0PrmScdType = kPrimary; + } else { + v0PrmScdType = kSecondary; } - // apply kinematic acceptance - if (mcpart.pt() <= cMinV0Pt || mcpart.pt() >= cMaxV0Pt || std::abs(mcpart.y()) >= cMaxV0Rap) { + // Decide Eta/Rap + if (!cDoEtaAnalysis) { + rap = mcpart.y(); + } else { + rap = mcpart.eta(); + } + + // Apply Kinematic Acceptance + if (!kinCutSelection(mcpart.pt(), std::abs(rap), cMinV0Pt, cMaxV0Pt, cMaxV0Rap)) { continue; } @@ -933,33 +1118,154 @@ struct LambdaTableProducer { } auto dautracks = mcpart.template daughters_as(); std::vector daughterPDGs, daughterIDs; + std::vector vDauPt, vDauEta, vDauRap, vDauPhi; for (auto const& dautrack : dautracks) { daughterPDGs.push_back(dautrack.pdgCode()); daughterIDs.push_back(dautrack.globalIndex()); + vDauPt.push_back(dautrack.pt()); + vDauEta.push_back(dautrack.eta()); + vDauRap.push_back(dautrack.y()); + vDauPhi.push_back(dautrack.phi()); } - if (cGenDecayChannel && (std::abs(daughterPDGs[0]) != kProton || std::abs(daughterPDGs[1]) != kPiPlus)) { - continue; + if (cGenDecayChannel) { // check decay channel + if (v0Type == kLambda) { + if (daughterPDGs[0] != kProton || daughterPDGs[1] != kPiMinus) { + continue; + } + } else if (v0Type == kAntiLambda) { + if (daughterPDGs[0] != kProtonBar || daughterPDGs[1] != kPiPlus) { + continue; + } + } } histos.fill(HIST("Tracks/h1f_tracks_info"), kGenLambdaToPrPi); - if (v0type == kLambda) { + if (v0Type == kLambda) { histos.fill(HIST("McGen/h1f_lambda_daughter_PDG"), daughterPDGs[0]); histos.fill(HIST("McGen/h1f_lambda_daughter_PDG"), daughterPDGs[1]); histos.fill(HIST("McGen/h1f_lambda_daughter_PDG"), mcpart.pdgCode()); + histos.fill(HIST("McGen/Lambda/Proton/hPt"), vDauPt[0]); + histos.fill(HIST("McGen/Lambda/Proton/hEta"), vDauEta[0]); + histos.fill(HIST("McGen/Lambda/Proton/hRap"), vDauRap[0]); + histos.fill(HIST("McGen/Lambda/Proton/hPhi"), vDauPhi[0]); + histos.fill(HIST("McGen/Lambda/Pion/hPt"), vDauPt[1]); + histos.fill(HIST("McGen/Lambda/Pion/hEta"), vDauEta[1]); + histos.fill(HIST("McGen/Lambda/Pion/hRap"), vDauRap[1]); + histos.fill(HIST("McGen/Lambda/Pion/hPhi"), vDauPhi[1]); + fillKinematicHists(mcpart.pt(), mcpart.eta(), mcpart.y(), mcpart.phi()); } else { histos.fill(HIST("McGen/h1f_antilambda_daughter_PDG"), daughterPDGs[0]); histos.fill(HIST("McGen/h1f_antilambda_daughter_PDG"), daughterPDGs[1]); histos.fill(HIST("McGen/h1f_antilambda_daughter_PDG"), mcpart.pdgCode()); + histos.fill(HIST("McGen/AntiLambda/Pion/hPt"), vDauPt[0]); + histos.fill(HIST("McGen/AntiLambda/Pion/hEta"), vDauEta[0]); + histos.fill(HIST("McGen/AntiLambda/Pion/hRap"), vDauRap[0]); + histos.fill(HIST("McGen/AntiLambda/Pion/hPhi"), vDauPhi[0]); + histos.fill(HIST("McGen/AntiLambda/Proton/hPt"), vDauPt[1]); + histos.fill(HIST("McGen/AntiLambda/Proton/hEta"), vDauEta[1]); + histos.fill(HIST("McGen/AntiLambda/Proton/hRap"), vDauRap[1]); + histos.fill(HIST("McGen/AntiLambda/Proton/hPhi"), vDauPhi[1]); + fillKinematicHists(mcpart.pt(), mcpart.eta(), mcpart.y(), mcpart.phi()); } + // Fill Lambda McGen Table lambdaMCGenTrackTable(lambdaMCGenCollisionTable.lastIndex(), mcpart.px(), mcpart.py(), mcpart.pz(), mcpart.pt(), mcpart.eta(), mcpart.phi(), mcpart.y(), RecoDecay::m(mcpart.p(), mcpart.e()), - daughterIDs[0], daughterIDs[1], (int8_t)v0type, -999., -999., 1. / cLambdaToPiProtonBR); + daughterIDs[0], daughterIDs[1], (int8_t)v0Type, -999., -999., v0PrmScdType, 1.); + } + } + + template + void analyzeMcRecoGen(M const& mcCollision, C const& collisions, V const& V0s, T const& tracks, P const& mcParticles) + { + // Number of Rec Collisions Associated to the McGen Collision + int nRecCols = collisions.size(); + if (nRecCols != 0) { + histos.fill(HIST("McGen/h1f_collision_recgen"), nRecCols); + } + // Do not analyze if more than one reco collision is accociated to one mc gen collision + if (nRecCols != 1) { + return; + } + histos.fill(HIST("McGen/h1f_collisions_info"), kTotCol); + // Check the reco collision + if (!collisions.begin().has_mcCollision() || !selCollision(collisions.begin()) || collisions.begin().mcCollisionId() != mcCollision.globalIndex()) { + return; + } + histos.fill(HIST("McGen/h1f_collisions_info"), kPassSelCol); + histos.fill(HIST("McGen/h2f_collision_posZ"), mcCollision.posZ(), collisions.begin().posZ()); + auto v0Tracks = V0s.sliceBy(perCollision, collisions.begin().globalIndex()); + fillLambdaRecoTables(collisions.begin(), v0Tracks, tracks); + fillLambdaMcGenTables(mcCollision, mcParticles); + } + + SliceCache cache; + Preslice> perCollision = aod::v0data::collisionId; + + using CollisionsRun3 = soa::Join; + using CollisionsRun2 = soa::Join; + using Tracks = soa::Join; + using McV0Tracks = soa::Join; + using TracksMC = soa::Join; + + void processDataRun3(CollisionsRun3::iterator const& collision, aod::V0Datas const& V0s, Tracks const& tracks) + { + fillLambdaRecoTables(collision, V0s, tracks); + } + + PROCESS_SWITCH(LambdaTableProducer, processDataRun3, "Process for Run3 DATA", true); + + void processDataRun2(CollisionsRun2::iterator const& collision, aod::V0Datas const& V0s, Tracks const& tracks) + { + fillLambdaRecoTables(collision, V0s, tracks); + } + + PROCESS_SWITCH(LambdaTableProducer, processDataRun2, "Process for Run2 DATA", false); + + void processMCRecoRun3(soa::Join::iterator const& collision, aod::McCollisions const&, + McV0Tracks const& V0s, TracksMC const& tracks, aod::McParticles const&) + { + // check collision + if (!selCollision(collision)) { + return; + } + fillLambdaRecoTables(collision, V0s, tracks); + } + + PROCESS_SWITCH(LambdaTableProducer, processMCRecoRun3, "Process for Run3 McReco DATA", false); + + void processMCRecoRun2(soa::Join::iterator const& collision, aod::McCollisions const&, + McV0Tracks const& V0s, TracksMC const& tracks, aod::McParticles const&) + { + // check collision + if (!selCollision(collision)) { + return; } + fillLambdaRecoTables(collision, V0s, tracks); + } + + PROCESS_SWITCH(LambdaTableProducer, processMCRecoRun2, "Process for Run2 McReco DATA", false); + + void processMCRun3(aod::McCollisions::iterator const& mcCollision, + soa::SmallGroups> const& collisions, + McV0Tracks const& V0s, TracksMC const& tracks, + aod::McParticles const& mcParticles) + { + analyzeMcRecoGen(mcCollision, collisions, V0s, tracks, mcParticles); + } + + PROCESS_SWITCH(LambdaTableProducer, processMCRun3, "Process for Run3 MC RecoGen", false); + + void processMCRun2(aod::McCollisions::iterator const& mcCollision, + soa::SmallGroups> const& collisions, + McV0Tracks const& V0s, TracksMC const& tracks, + aod::McParticles const& mcParticles) + { + analyzeMcRecoGen(mcCollision, collisions, V0s, tracks, mcParticles); } - PROCESS_SWITCH(LambdaTableProducer, processMCGen, "Process for MC Generated", false); + PROCESS_SWITCH(LambdaTableProducer, processMCRun2, "Process for Run2 MC RecoGen", false); }; struct LambdaTracksExtProducer { @@ -985,12 +1291,17 @@ struct LambdaTracksExtProducer { const AxisSpec axisMass(100, 1.06, 1.16, "Inv Mass (GeV/#it{c}^{2})"); const AxisSpec axisCPA(100, 0.995, 1.0, "cos(#theta_{PA})"); const AxisSpec axisDcaDau(75, 0., 1.5, "Daug DCA (#sigma)"); + const AxisSpec axisDEta(320, -1.6, 1.6, "#Delta#eta"); + const AxisSpec axisDPhi(640, -PIHalf, 3. * PIHalf, "#Delta#varphi"); // Histograms Booking histos.add("h1i_totlambda_mult", "Multiplicity", kTH1I, {axisMult}); histos.add("h1i_totantilambda_mult", "Multiplicity", kTH1I, {axisMult}); histos.add("h1i_lambda_mult", "Multiplicity", kTH1I, {axisMult}); histos.add("h1i_antilambda_mult", "Multiplicity", kTH1I, {axisMult}); + histos.add("h2d_n2_etaphi_LaP_LaM", "#rho_{2}^{SharePair}", kTH2D, {axisDEta, axisDPhi}); + histos.add("h2d_n2_etaphi_LaP_LaP", "#rho_{2}^{SharePair}", kTH2D, {axisDEta, axisDPhi}); + histos.add("h2d_n2_etaphi_LaM_LaM", "#rho_{2}^{SharePair}", kTH2D, {axisDEta, axisDPhi}); // InvMass, DcaDau and CosPA histos.add("Reco/h1f_lambda_invmass", "M_{p#pi}", kTH1F, {axisMass}); @@ -1044,16 +1355,20 @@ struct LambdaTracksExtProducer { continue; } - // check only lambda-lambda || antilambda-antilambda - if (lambda.v0Type() != track.v0Type()) { - continue; - } - // check if lambda shares daughters with any other track if (lambda.posTrackId() == track.posTrackId() || lambda.negTrackId() == track.negTrackId()) { vSharedDauLambdaIndex.push_back(track.index()); lambdaSharingDauFlag = true; + // Fill DEta-DPhi Histogram + if ((lambda.v0Type() == kLambda && track.v0Type() == kAntiLambda) || (lambda.v0Type() == kAntiLambda && track.v0Type() == kLambda)) { + histos.fill(HIST("h2d_n2_etaphi_LaP_LaM"), lambda.eta() - track.eta(), RecoDecay::constrainAngle((lambda.phi() - track.phi()), -PIHalf)); + } else if (lambda.v0Type() == kLambda && track.v0Type() == kLambda) { + histos.fill(HIST("h2d_n2_etaphi_LaP_LaP"), lambda.eta() - track.eta(), RecoDecay::constrainAngle((lambda.phi() - track.phi()), -PIHalf)); + } else if (lambda.v0Type() == kAntiLambda && track.v0Type() == kAntiLambda) { + histos.fill(HIST("h2d_n2_etaphi_LaM_LaM"), lambda.eta() - track.eta(), RecoDecay::constrainAngle((lambda.phi() - track.phi()), -PIHalf)); + } + // decision based on mass closest to PdgMass of Lambda if (std::abs(lambda.mass() - MassLambda0) > std::abs(track.mass() - MassLambda0)) { lambdaMinDeltaMassFlag = false; @@ -1117,16 +1432,24 @@ struct LambdaTracksExtProducer { }; struct LambdaR2Correlation { - // Global Configurables - Configurable cNRapBins{"cNRapBins", 12, "N Rapidity Bins"}; - Configurable cMinRap{"cMinRap", -0.6, "Minimum Rapidity"}; - Configurable cMaxRap{"cMaxRap", 0.6, "Maximum Rapidity"}; - Configurable cNPhiBins{"cNPhiBins", 64, "N Phi Bins"}; + Configurable cNPtBins{"cNPtBins", 34, "N pT Bins"}; + Configurable cMinPt{"cMinPt", 0.8, "pT Min"}; + Configurable cMaxPt{"cMaxPt", 4.2, "pT Max"}; + Configurable cNRapBins{"cNRapBins", 20, "N Rapidity Bins"}; + Configurable cMinRap{"cMinRap", -0.5, "Minimum Rapidity"}; + Configurable cMaxRap{"cMaxRap", 0.5, "Maximum Rapidity"}; + Configurable cNPhiBins{"cNPhiBins", 36, "N Phi Bins"}; + Configurable cAnaSecondaries{"cAnaSecondaries", false, "Analysze Secondaries"}; + Configurable cAnaPairs{"cAnaPairs", false, "Analyze Pairs Flag"}; + Configurable cAnaSecondaryPairs{"cAnaSecondaryPairs", false, "Analyze Secondary Pairs Flag"}; // Eta/Rap Analysis Configurable cDoEtaAnalysis{"cDoEtaAnalysis", false, "Eta/Rap Analysis Flag"}; + // Centrality Axis + ConfigurableAxis cMultBins{"cMultBins", {VARIABLE_WIDTH, 0.0f, 10.0f, 30.0f, 50.f, 80.0f, 100.f}, "Variable Mult-Bins"}; + // Histogram Registry. HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -1140,6 +1463,7 @@ struct LambdaR2Correlation { float rapbinwidth = 0.; float phibinwidth = 0.; float q = 0., e = 0., qinv = 0.; + float cent = 0.; void init(InitContext const&) { @@ -1158,22 +1482,16 @@ struct LambdaR2Correlation { const AxisSpec axisCheck(1, 0, 1, ""); const AxisSpec axisPosZ(220, -11, 11, "V_{z} (cm)"); - const AxisSpec axisCent(105, 0, 105, "FT0M (%)"); + const AxisSpec axisCent(cMultBins, "FT0M (%)"); const AxisSpec axisMult(10, 0, 10, "N_{#Lambda}"); - const AxisSpec axisMass(100, 1.06, 1.16, "Inv Mass (GeV/#it{c}^{2})"); - const AxisSpec axisPt(40, 0, 4.0, "p_{T} (GeV/#it{c})"); - const AxisSpec axisEta(24, -1.2, 1.2, "#eta"); - const AxisSpec axisYRap(24, -1.2, 1.2, "y"); - const AxisSpec axisRap(cNRapBins, cMinRap, cMaxRap, "rap"); - const AxisSpec axisPhi(cNPhiBins, 0., TwoPI, "#phi (rad)"); - const AxisSpec axisRapPhi(knrapphibins, kminrapphi, kmaxrapphi, "y #phi"); + const AxisSpec axisMass(100, 1.06, 1.16, "M_{#Lambda} (GeV/#it{c}^{2})"); + const AxisSpec axisPt(cNPtBins, cMinPt, cMaxPt, "p_{T} (GeV/#it{c})"); + const AxisSpec axisEta(cNRapBins, cMinRap, cMaxRap, "#eta"); + const AxisSpec axisRap(cNRapBins, cMinRap, cMaxRap, "y"); + const AxisSpec axisPhi(cNPhiBins, 0., TwoPI, "#varphi (rad)"); + const AxisSpec axisRapPhi(knrapphibins, kminrapphi, kmaxrapphi, "y #varphi"); const AxisSpec axisQinv(100, 0, 10, "q_{inv} (GeV/#it{c})"); - const AxisSpec axisEfPt(20, 0, 4.0, "p_{T}"); - const AxisSpec axisEfEta(24, -1.2, 1.2, "#eta"); - const AxisSpec axisEfRap(24, -1.2, 1.2, "y"); - const AxisSpec axisEfPosZ(10, -10., 10., "V_{Z}"); - // Create Histograms. // Event histos.add("Event/Reco/h1f_collision_posz", "V_{Z} Distribution", kTH1F, {axisPosZ}); @@ -1182,49 +1500,64 @@ struct LambdaR2Correlation { histos.add("Event/Reco/h1i_antilambda_mult", "#bar{#Lambda} - Multiplicity", kTH1I, {axisMult}); // Efficiency Histograms - histos.add("Reco/Efficiency/h1f_n1_pt_LaP", "#rho_{1}^{#Lambda}", kTH1F, {axisEfPt}); - histos.add("Reco/Efficiency/h1f_n1_pt_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH1F, {axisEfPt}); - histos.add("Reco/Efficiency/h2f_n1_pteta_LaP", "#rho_{1}^{#Lambda}", kTH2F, {axisEfPt, axisEfEta}); - histos.add("Reco/Efficiency/h2f_n1_pteta_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2F, {axisEfPt, axisEfEta}); - histos.add("Reco/Efficiency/h2f_n1_ptrap_LaP", "#rho_{1}^{#Lambda}", kTH2F, {axisEfPt, axisEfRap}); - histos.add("Reco/Efficiency/h2f_n1_ptrap_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2F, {axisEfPt, axisEfRap}); - histos.add("Reco/Efficiency/h3f_n1_ptetaposz_LaP", "#rho_{1}^{#Lambda}", kTH3F, {axisEfPt, axisEfEta, axisEfPosZ}); - histos.add("Reco/Efficiency/h3f_n1_ptetaposz_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH3F, {axisEfPt, axisEfEta, axisEfPosZ}); - histos.add("Reco/Efficiency/h3f_n1_ptrapposz_LaP", "#rho_{1}^{#Lambda}", kTH3F, {axisEfPt, axisEfRap, axisEfPosZ}); - histos.add("Reco/Efficiency/h3f_n1_ptrapposz_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH3F, {axisEfPt, axisEfRap, axisEfPosZ}); - - // single and two particle densities + // Single Particle Efficiencies + histos.add("Reco/Primary/Efficiency/h2f_n1_centpt_LaP", "#rho_{1}^{#Lambda}", kTH2F, {axisCent, axisPt}); + histos.add("Reco/Primary/Efficiency/h2f_n1_centpt_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2F, {axisCent, axisPt}); + histos.add("Reco/Primary/Efficiency/h3f_n1_centpteta_LaP", "#rho_{1}^{#Lambda}", kTH3F, {axisCent, axisPt, axisEta}); + histos.add("Reco/Primary/Efficiency/h3f_n1_centpteta_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH3F, {axisCent, axisPt, axisEta}); + histos.add("Reco/Primary/Efficiency/h3f_n1_centptrap_LaP", "#rho_{1}^{#Lambda}", kTH3F, {axisCent, axisPt, axisRap}); + histos.add("Reco/Primary/Efficiency/h3f_n1_centptrap_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH3F, {axisCent, axisPt, axisRap}); + + // Single and Two Particle Densities // 1D Histograms - histos.add("Reco/h1d_n1_mass_LaP", "#rho_{1}^{#Lambda}", kTH1D, {axisMass}); - histos.add("Reco/h1d_n1_mass_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH1D, {axisMass}); - histos.add("Reco/h1d_n1_pt_LaP", "#rho_{1}^{#Lambda}", kTH1D, {axisPt}); - histos.add("Reco/h1d_n1_pt_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH1D, {axisPt}); - histos.add("Reco/h1d_n1_eta_LaP", "#rho_{1}^{#Lambda}", kTH1D, {axisEta}); - histos.add("Reco/h1d_n1_eta_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH1D, {axisEta}); - histos.add("Reco/h1d_n1_rap_LaP", "#rho_{1}^{#Lambda}", kTH1D, {axisYRap}); - histos.add("Reco/h1d_n1_rap_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH1D, {axisYRap}); - histos.add("Reco/h1d_n1_phi_LaP", "#rho_{1}^{#Lambda}", kTH1D, {axisPhi}); - histos.add("Reco/h1d_n1_phi_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH1D, {axisPhi}); - - // rho1 for R2 deta dphi histograms - histos.add("Reco/h2d_n1_rapphi_LaP", "#rho_{1}^{#Lambda}", kTH2D, {axisRap, axisPhi}); - histos.add("Reco/h2d_n1_rapphi_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2D, {axisRap, axisPhi}); - - // rho1 for R2 qinv histograms - histos.add("Reco/h2d_n1_ptrap_LaP", "#rho_{1}^{#Lambda}", kTH2D, {axisPt, axisYRap}); - histos.add("Reco/h2d_n1_ptrap_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2D, {axisPt, axisYRap}); - histos.add("Reco/h2d_n1_pteta_LaP", "#rho_{1}^{#Lambda}", kTH2D, {axisPt, axisEta}); - histos.add("Reco/h2d_n1_pteta_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2D, {axisPt, axisEta}); - - // rho2 for R2 deta dphi histograms - histos.add("Reco/h2d_n2_rapphi_LaP_LaM", "#rho_{2}^{#Lambda - #bar{#Lambda}}", kTH2D, {axisRapPhi, axisRapPhi}); - histos.add("Reco/h2d_n2_rapphi_LaP_LaP", "#rho_{2}^{#Lambda - #Lambda}", kTH2D, {axisRapPhi, axisRapPhi}); - histos.add("Reco/h2d_n2_rapphi_LaM_LaM", "#rho_{2}^{#bar{#Lambda} - #bar{#Lambda}}", kTH2D, {axisRapPhi, axisRapPhi}); - - // rho2 for R2 qinv histograms - histos.add("Reco/h1d_n2_qinv_LaP_LaM", "#rho_{2}^{#Lambda-#bar{#Lambda}}", kTH1D, {axisQinv}); - histos.add("Reco/h1d_n2_qinv_LaP_LaP", "#rho_{2}^{#Lambda-#Lambda}", kTH1D, {axisQinv}); - histos.add("Reco/h1d_n2_qinv_LaM_LaM", "#rho_{2}^{#bar{#Lambda}-#bar{#Lambda}}", kTH1D, {axisQinv}); + histos.add("Reco/Primary/h2f_n1_pt_LaP", "#rho_{1}^{#Lambda}", kTH2F, {axisCent, axisPt}); + histos.add("Reco/Primary/h2f_n1_pt_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2F, {axisCent, axisPt}); + histos.add("Reco/Primary/h2f_n1_eta_LaP", "#rho_{1}^{#Lambda}", kTH2F, {axisCent, axisEta}); + histos.add("Reco/Primary/h2f_n1_eta_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2F, {axisCent, axisEta}); + histos.add("Reco/Primary/h2f_n1_rap_LaP", "#rho_{1}^{#Lambda}", kTH2F, {axisCent, axisRap}); + histos.add("Reco/Primary/h2f_n1_rap_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2F, {axisCent, axisRap}); + histos.add("Reco/Primary/h2f_n1_phi_LaP", "#rho_{1}^{#Lambda}", kTH2F, {axisCent, axisPhi}); + histos.add("Reco/Primary/h2f_n1_phi_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2F, {axisCent, axisPhi}); + + // rho1 for R2 RapPhi + histos.add("Reco/Primary/h3f_n1_rapphi_LaP", "#rho_{1}^{#Lambda}", kTH3F, {axisCent, axisRap, axisPhi}); + histos.add("Reco/Primary/h3f_n1_rapphi_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH3F, {axisCent, axisRap, axisPhi}); + + // rho1 for Q_{inv} + histos.add("Reco/Primary/h3f_n1_pteta_LaP", "#rho_{1}^{#Lambda}", kTH3F, {axisCent, axisPt, axisEta}); + histos.add("Reco/Primary/h3f_n1_pteta_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH3F, {axisCent, axisPt, axisEta}); + + // Clone Singles Primary/Secondary Histogram + if (cAnaSecondaries) { + histos.addClone("Reco/Primary/", "Reco/Secondary/"); + } + + if (cAnaPairs) { + // rho2 for numerator of R2 + histos.add("Reco/PP/h3f_n2_raprap_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH3F, {axisCent, axisRap, axisRap}); + histos.add("Reco/PP/h3f_n2_raprap_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH3F, {axisCent, axisRap, axisRap}); + histos.add("Reco/PP/h3f_n2_raprap_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH3F, {axisCent, axisRap, axisRap}); + histos.add("Reco/PP/h3f_n2_phiphi_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH3F, {axisCent, axisPhi, axisPhi}); + histos.add("Reco/PP/h3f_n2_phiphi_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH3F, {axisCent, axisPhi, axisPhi}); + histos.add("Reco/PP/h3f_n2_phiphi_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH3F, {axisCent, axisPhi, axisPhi}); + + // rho2 for R2 Rap1Phi1Rap2Phi2 + histos.add("Reco/PP/h3f_n2_rapphi_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH3F, {axisCent, axisRapPhi, axisRapPhi}); + histos.add("Reco/PP/h3f_n2_rapphi_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH3F, {axisCent, axisRapPhi, axisRapPhi}); + histos.add("Reco/PP/h3f_n2_rapphi_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH3F, {axisCent, axisRapPhi, axisRapPhi}); + + // rho2 for R2 Qinv + histos.add("Reco/PP/h2f_n2_qinv_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH2F, {axisCent, axisQinv}); + histos.add("Reco/PP/h2f_n2_qinv_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH2F, {axisCent, axisQinv}); + histos.add("Reco/PP/h2f_n2_qinv_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH2F, {axisCent, axisQinv}); + + // Clone Pairs Histograms + if (cAnaSecondaryPairs) { + histos.addClone("Reco/PP/", "Reco/PS/"); + histos.addClone("Reco/PP/", "Reco/SP/"); + histos.addClone("Reco/PP/", "Reco/SS/"); + } + } // MCGen if (doprocessMCGen) { @@ -1233,10 +1566,11 @@ struct LambdaR2Correlation { } } - template + template void fillPairHistos(U& p1, U& p2) { static constexpr std::string_view SubDirRecGen[] = {"Reco/", "McGen/"}; + static constexpr std::string_view SubDirPrmScd[] = {"PP/", "PS/", "SP/", "SS/"}; static constexpr std::string_view SubDirHist[] = {"LaP_LaM", "LaP_LaP", "LaM_LaM"}; float rap1 = (cDoEtaAnalysis) ? p1.eta() : p1.rap(); @@ -1250,25 +1584,30 @@ struct LambdaR2Correlation { float corfac = p1.corrFact() * p2.corrFact(); + // fill rho2 histograms + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[psp]) + HIST("h3f_n2_raprap_") + HIST(SubDirHist[part_pair]), cent, rap1, rap2, corfac); + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[psp]) + HIST("h3f_n2_phiphi_") + HIST(SubDirHist[part_pair]), cent, p1.phi(), p2.phi(), corfac); + if (rapbin1 >= 0 && rapbin2 >= 0 && phibin1 >= 0 && phibin2 >= 0 && rapbin1 < nrapbins && rapbin2 < nrapbins && phibin1 < nphibins && phibin2 < nphibins) { int rapphix = rapbin1 * nphibins + phibin1; int rapphiy = rapbin2 * nphibins + phibin2; - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h2d_n2_rapphi_") + HIST(SubDirHist[part_pair]), rapphix + 0.5, rapphiy + 0.5, corfac); + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[psp]) + HIST("h3f_n2_rapphi_") + HIST(SubDirHist[part_pair]), cent, rapphix + 0.5, rapphiy + 0.5, corfac); } // qinv histograms q = RecoDecay::p((p1.px() - p2.px()), (p1.py() - p2.py()), (p1.pz() - p2.pz())); e = RecoDecay::e(p1.px(), p1.py(), p1.pz(), MassLambda0) - RecoDecay::e(p2.px(), p2.py(), p2.pz(), MassLambda0); qinv = std::sqrt(-RecoDecay::m2(q, e)); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h1d_n2_qinv_") + HIST(SubDirHist[part_pair]), qinv, corfac); + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[psp]) + HIST("h2f_n2_qinv_") + HIST(SubDirHist[part_pair]), cent, qinv, corfac); } - template - void analyzeSingles(C const& col, T const& tracks) + template + void analyzeSingles(T const& tracks) { static constexpr std::string_view SubDirRecGen[] = {"Reco/", "McGen/"}; + static constexpr std::string_view SubDirPrmScd[] = {"Primary/", "Secondary/"}; static constexpr std::string_view SubDirHist[] = {"LaP", "LaM"}; int ntrk = 0; @@ -1277,24 +1616,22 @@ struct LambdaR2Correlation { // count tracks ++ntrk; + // Efficiency Plots + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[pst]) + HIST("Efficiency/h2f_n1_centpt_") + HIST(SubDirHist[part]), cent, track.pt()); + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[pst]) + HIST("Efficiency/h3f_n1_centpteta_") + HIST(SubDirHist[part]), cent, track.pt(), track.eta()); + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[pst]) + HIST("Efficiency/h3f_n1_centptrap_") + HIST(SubDirHist[part]), cent, track.pt(), track.rap()); + // QA Plots - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h1d_n1_mass_") + HIST(SubDirHist[part]), track.mass()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h1d_n1_pt_") + HIST(SubDirHist[part]), track.pt(), track.corrFact()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h1d_n1_eta_") + HIST(SubDirHist[part]), track.eta(), track.corrFact()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h1d_n1_phi_") + HIST(SubDirHist[part]), track.phi(), track.corrFact()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h1d_n1_rap_") + HIST(SubDirHist[part]), track.rap(), track.corrFact()); + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[pst]) + HIST("h2f_n1_pt_") + HIST(SubDirHist[part]), cent, track.pt(), track.corrFact()); + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[pst]) + HIST("h2f_n1_eta_") + HIST(SubDirHist[part]), cent, track.eta(), track.corrFact()); + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[pst]) + HIST("h2f_n1_phi_") + HIST(SubDirHist[part]), cent, track.phi(), track.corrFact()); + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[pst]) + HIST("h2f_n1_rap_") + HIST(SubDirHist[part]), cent, track.rap(), track.corrFact()); - // Efficiency Calculation Plots - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("Efficiency/h1f_n1_pt_") + HIST(SubDirHist[part]), track.pt()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("Efficiency/h2f_n1_pteta_") + HIST(SubDirHist[part]), track.pt(), track.eta()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("Efficiency/h2f_n1_ptrap_") + HIST(SubDirHist[part]), track.pt(), track.rap()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("Efficiency/h3f_n1_ptetaposz_") + HIST(SubDirHist[part]), track.pt(), track.eta(), col.posZ()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("Efficiency/h3f_n1_ptrapposz_") + HIST(SubDirHist[part]), track.pt(), track.rap(), col.posZ()); + // Rho1 for N1RapPhi + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[pst]) + HIST("h3f_n1_rapphi_") + HIST(SubDirHist[part]), cent, track.rap(), track.phi(), track.corrFact()); - // Rho1 for R2 Calculation - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h2d_n1_ptrap_") + HIST(SubDirHist[part]), track.pt(), track.rap(), track.corrFact()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h2d_n1_pteta_") + HIST(SubDirHist[part]), track.pt(), track.eta(), track.corrFact()); - histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST("h2d_n1_rapphi_") + HIST(SubDirHist[part]), track.rap(), track.phi(), track.corrFact()); + // Rho1 for Q_{inv} Bkg Estimation + histos.fill(HIST(SubDirRecGen[rec_gen]) + HIST(SubDirPrmScd[pst]) + HIST("h3f_n1_pteta_") + HIST(SubDirHist[part]), cent, track.pt(), track.eta(), track.corrFact()); } // fill multiplicity histograms @@ -1307,7 +1644,7 @@ struct LambdaR2Correlation { } } - template + template void analyzePairs(T const& trks_1, T const& trks_2) { for (auto const& trk_1 : trks_1) { @@ -1316,7 +1653,7 @@ struct LambdaR2Correlation { if (samelambda && ((trk_1.index() == trk_2.index()))) { continue; } - fillPairHistos(trk_1, trk_2); + fillPairHistos(trk_1, trk_2); } } } @@ -1325,22 +1662,50 @@ struct LambdaR2Correlation { using LambdaTracks = soa::Join; SliceCache cache; - Partition partLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kLambda) && (aod::lambdatrackext::trueLambdaFlag == true); - Partition partAntiLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kAntiLambda) && (aod::lambdatrackext::trueLambdaFlag == true); + Partition partPrimLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kLambda) && (aod::lambdatrackext::trueLambdaFlag == true) && (aod::lambdatrack::v0PrmScd == (int8_t)kPrimary); + Partition partPrimAntiLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kAntiLambda) && (aod::lambdatrackext::trueLambdaFlag == true) && (aod::lambdatrack::v0PrmScd == (int8_t)kPrimary); + Partition partSecdLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kLambda) && (aod::lambdatrackext::trueLambdaFlag == true) && (aod::lambdatrack::v0PrmScd == (int8_t)kSecondary); + Partition partSecdAntiLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kAntiLambda) && (aod::lambdatrackext::trueLambdaFlag == true) && (aod::lambdatrack::v0PrmScd == (int8_t)kSecondary); void processDataReco(LambdaCollisions::iterator const& collision, LambdaTracks const&) { histos.fill(HIST("Event/Reco/h1f_collision_posz"), collision.posZ()); histos.fill(HIST("Event/Reco/h1f_ft0m_mult_percentile"), collision.cent()); - auto lambdaTracks = partLambdaTracks->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); - auto antiLambdaTracks = partAntiLambdaTracks->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); + cent = collision.cent(); + + auto lambdaPrimTracks = partPrimLambdaTracks->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); + auto antiLambdaPrimTracks = partPrimAntiLambdaTracks->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); + auto lambdaSecdTracks = partSecdLambdaTracks->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); + auto antiLambdaSecdTracks = partSecdAntiLambdaTracks->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); + + analyzeSingles(lambdaPrimTracks); + analyzeSingles(antiLambdaPrimTracks); + + if (cAnaSecondaries) { + analyzeSingles(lambdaSecdTracks); + analyzeSingles(antiLambdaSecdTracks); + } - analyzeSingles(collision, lambdaTracks); - analyzeSingles(collision, antiLambdaTracks); - analyzePairs(lambdaTracks, antiLambdaTracks); - analyzePairs(lambdaTracks, lambdaTracks); - analyzePairs(antiLambdaTracks, antiLambdaTracks); + if (cAnaPairs) { + // Primary Pairs Only + analyzePairs(lambdaPrimTracks, antiLambdaPrimTracks); + analyzePairs(lambdaPrimTracks, lambdaPrimTracks); + analyzePairs(antiLambdaPrimTracks, antiLambdaPrimTracks); + + // Secondary Pairs + if (cAnaSecondaryPairs) { + analyzePairs(lambdaPrimTracks, antiLambdaSecdTracks); + analyzePairs(lambdaPrimTracks, lambdaSecdTracks); + analyzePairs(antiLambdaPrimTracks, antiLambdaSecdTracks); + analyzePairs(lambdaSecdTracks, antiLambdaPrimTracks); + analyzePairs(lambdaSecdTracks, lambdaPrimTracks); + analyzePairs(antiLambdaSecdTracks, antiLambdaPrimTracks); + analyzePairs(lambdaSecdTracks, antiLambdaSecdTracks); + analyzePairs(lambdaSecdTracks, lambdaSecdTracks); + analyzePairs(antiLambdaSecdTracks, antiLambdaSecdTracks); + } + } } PROCESS_SWITCH(LambdaR2Correlation, processDataReco, "Process for Data and MCReco", true); @@ -1349,21 +1714,50 @@ struct LambdaR2Correlation { using LambdaMcGenTracks = aod::LambdaMcGenTracks; SliceCache cachemc; - Partition partLambdaMcGenTracks = aod::lambdatrack::v0Type == (int8_t)kLambda; - Partition partAntiLambdaMcGenTracks = aod::lambdatrack::v0Type == (int8_t)kAntiLambda; + Partition partMcPrimLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kLambda) && (aod::lambdatrack::v0PrmScd == (int8_t)kPrimary); + Partition partMcPrimAntiLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kAntiLambda) && (aod::lambdatrack::v0PrmScd == (int8_t)kPrimary); + Partition partMcSecdLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kLambda) && (aod::lambdatrack::v0PrmScd == (int8_t)kSecondary); + Partition partMcSecdAntiLambdaTracks = (aod::lambdatrack::v0Type == (int8_t)kAntiLambda) && (aod::lambdatrack::v0PrmScd == (int8_t)kSecondary); void processMCGen(LambdaMcGenCollisions::iterator const& mcgencol, LambdaMcGenTracks const&) { histos.fill(HIST("Event/McGen/h1f_collision_posz"), mcgencol.posZ()); + histos.fill(HIST("Event/McGen/h1f_ft0m_mult_percentile"), mcgencol.cent()); + + cent = mcgencol.cent(); + + auto lambdaPrimTracks = partMcPrimLambdaTracks->sliceByCached(aod::lambdamcgentrack::lambdaMcGenCollisionId, mcgencol.globalIndex(), cachemc); + auto antiLambdaPrimTracks = partMcPrimAntiLambdaTracks->sliceByCached(aod::lambdamcgentrack::lambdaMcGenCollisionId, mcgencol.globalIndex(), cachemc); + auto lambdaSecdTracks = partMcSecdLambdaTracks->sliceByCached(aod::lambdamcgentrack::lambdaMcGenCollisionId, mcgencol.globalIndex(), cachemc); + auto antiLambdaSecdTracks = partMcSecdAntiLambdaTracks->sliceByCached(aod::lambdamcgentrack::lambdaMcGenCollisionId, mcgencol.globalIndex(), cachemc); - auto lambdaMcGenTracks = partLambdaMcGenTracks->sliceByCached(aod::lambdamcgentrack::lambdaMcGenCollisionId, mcgencol.globalIndex(), cachemc); - auto antiLambdaMcGenTracks = partAntiLambdaMcGenTracks->sliceByCached(aod::lambdamcgentrack::lambdaMcGenCollisionId, mcgencol.globalIndex(), cachemc); + analyzeSingles(lambdaPrimTracks); + analyzeSingles(antiLambdaPrimTracks); - analyzeSingles(mcgencol, lambdaMcGenTracks); - analyzeSingles(mcgencol, antiLambdaMcGenTracks); - analyzePairs(lambdaMcGenTracks, antiLambdaMcGenTracks); - analyzePairs(lambdaMcGenTracks, lambdaMcGenTracks); - analyzePairs(antiLambdaMcGenTracks, antiLambdaMcGenTracks); + if (cAnaSecondaries) { + analyzeSingles(lambdaSecdTracks); + analyzeSingles(antiLambdaSecdTracks); + } + + if (cAnaPairs) { + // Primary Pairs Only + analyzePairs(lambdaPrimTracks, antiLambdaPrimTracks); + analyzePairs(lambdaPrimTracks, lambdaPrimTracks); + analyzePairs(antiLambdaPrimTracks, antiLambdaPrimTracks); + + // Secondary Pairs + if (cAnaSecondaryPairs) { + analyzePairs(lambdaPrimTracks, antiLambdaSecdTracks); + analyzePairs(lambdaPrimTracks, lambdaSecdTracks); + analyzePairs(antiLambdaPrimTracks, antiLambdaSecdTracks); + analyzePairs(lambdaSecdTracks, antiLambdaPrimTracks); + analyzePairs(lambdaSecdTracks, lambdaPrimTracks); + analyzePairs(antiLambdaSecdTracks, antiLambdaPrimTracks); + analyzePairs(lambdaSecdTracks, antiLambdaSecdTracks); + analyzePairs(lambdaSecdTracks, lambdaSecdTracks); + analyzePairs(antiLambdaSecdTracks, antiLambdaSecdTracks); + } + } } PROCESS_SWITCH(LambdaR2Correlation, processMCGen, "Process for MC Generated", false); diff --git a/PWGCF/TwoParticleCorrelations/Tasks/longrangeCorrelation.cxx b/PWGCF/TwoParticleCorrelations/Tasks/longrangeCorrelation.cxx new file mode 100644 index 00000000000..c2cf7781b53 --- /dev/null +++ b/PWGCF/TwoParticleCorrelations/Tasks/longrangeCorrelation.cxx @@ -0,0 +1,829 @@ +// 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. +/// +/// \file longrangeCorrelation.cxx +/// +/// \brief task for long range correlation analysis +/// \author Abhi Modak (abhi.modak@cern.ch) and Debojit Sarkar (debojit.sarkar@cern.ch) +/// \since April 22, 2025 + +#include "PWGCF/Core/CorrelationContainer.h" +#include "PWGCF/Core/PairCuts.h" +#include "PWGCF/DataModel/CorrelationsDerived.h" +#include "PWGMM/Mult/DataModel/bestCollisionTable.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DetectorsCommonDataFormats/AlignParam.h" +#include "FT0Base/Geometry.h" +#include "FV0Base/Geometry.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::track; +using namespace o2::aod::fwdtrack; +using namespace o2::aod::evsel; +using namespace o2::constants::math; + +static constexpr TrackSelectionFlags::flagtype TrackSelectionIts = + TrackSelectionFlags::kITSNCls | TrackSelectionFlags::kITSChi2NDF | + TrackSelectionFlags::kITSHits; +static constexpr TrackSelectionFlags::flagtype TrackSelectionTpc = + TrackSelectionFlags::kTPCNCls | + TrackSelectionFlags::kTPCCrossedRowsOverNCls | + TrackSelectionFlags::kTPCChi2NDF; +static constexpr TrackSelectionFlags::flagtype TrackSelectionDca = + TrackSelectionFlags::kDCAz | TrackSelectionFlags::kDCAxy; +static constexpr TrackSelectionFlags::flagtype TrackSelectionDcaxyOnly = + TrackSelectionFlags::kDCAxy; + +AxisSpec axisEvent{10, 0.5, 9.5, "#Event", "EventAxis"}; + +struct LongrangeCorrelation { + + struct : ConfigurableGroup { + Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + Configurable noLaterThan{"noLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; + } cfgCcdbParam; + + SliceCache cache; + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + std::vector* offsetFT0; + std::vector* offsetFV0; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable cfgVtxCut{"cfgVtxCut", 10.0f, "Vertex Z range to consider"}; + Configurable cfgEtaCut{"cfgEtaCut", 1.0f, "Eta range to consider"}; + Configurable dcaZ{"dcaZ", 0.2f, "Custom DCA Z cut (ignored if negative)"}; + Configurable cfgPtCutMin{"cfgPtCutMin", 0.2f, "minimum accepted track pT"}; + Configurable cfgPtCutMax{"cfgPtCutMax", 10.0f, "maximum accepted track pT"}; + Configurable mixingParameter{"mixingParameter", 5, "how many events are mixed"}; + Configurable cfgMinMult{"cfgMinMult", 0, "Minimum multiplicity for collision"}; + Configurable cfgMaxMult{"cfgMaxMult", 10, "Maximum multiplicity for collision"}; + Configurable cfigMftEtaMax{"cfigMftEtaMax", -2.5f, "Maximum MFT eta cut"}; + Configurable cfigMftEtaMin{"cfigMftEtaMin", -3.6f, "Minimum MFT eta cut"}; + Configurable cfigMftDcaxy{"cfigMftDcaxy", 2.0f, "cut on DCA xy for MFT tracks"}; + Configurable cfigMftCluster{"cfigMftCluster", 5, "cut on MFT Cluster"}; + Configurable cfgSampleSize{"cfgSampleSize", 10, "Sample size for mixed event"}; + Configurable isApplySameBunchPileup{"isApplySameBunchPileup", false, "Enable SameBunchPileup cut"}; + ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"}; + ConfigurableAxis axisDeltaEta{"axisDeltaEta", {40, -6, -2}, "delta eta axis for histograms"}; + ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt trigger axis for histograms"}; + ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt associated axis for histograms"}; + ConfigurableAxis axisMultME{"axisMultME", {VARIABLE_WIDTH, 0, 5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100}, "Mixing bins - multiplicity"}; + ConfigurableAxis axisVtxZME{"axisVtxZME", {VARIABLE_WIDTH, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, "Mixing bins - z-vertex"}; + ConfigurableAxis axisVertexEfficiency{"axisVertexEfficiency", {10, -10, 10}, "vertex axis for efficiency histograms"}; + ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"}; + ConfigurableAxis axisPtEfficiency{"axisPtEfficiency", {VARIABLE_WIDTH, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0}, "pt axis for efficiency histograms"}; + ConfigurableAxis axisVtxZ{"axisVtxZ", {40, -20, 20}, "vertex axis"}; + ConfigurableAxis axisPhi{"axisPhi", {96, 0, TwoPI}, "#phi axis"}; + ConfigurableAxis axisEtaTrig{"axisEtaTrig", {40, -1., 1.}, "#eta trig axis"}; + ConfigurableAxis axisEtaAssoc{"axisEtaAssoc", {96, 3.5, 4.9}, "#eta assoc axis"}; + ConfigurableAxis axisSample{"axisSample", {cfgSampleSize, 0, cfgSampleSize}, "sample axis for histograms"}; + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100}, "multiplicity / centrality axis for histograms"}; + ConfigurableAxis amplitudeFt0a{"amplitudeFt0a", {5000, 0, 10000}, "FT0A amplitude"}; + ConfigurableAxis channelFt0aAxis{"channelFt0aAxis", {96, 0.0, 96.0}, "FT0A channel"}; + + using CollTable = soa::Join; + using TrksTable = soa::Filtered>; + using MftTrkTable = soa::Filtered; + Preslice perColGlobal = aod::track::collisionId; + Preslice perColMft = aod::fwdtrack::collisionId; + + OutputObj sameFt0aGlobal{Form("sameEventFt0aGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj mixedFt0aGlobal{Form("mixedEventFt0aGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj sameFt0cGlobal{Form("sameEventFt0cGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj mixedFt0cGlobal{Form("mixedEventFt0cGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj sameMftGlobal{Form("sameEventMftGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj mixedMftGlobal{Form("mixedEventMftGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj sameFv0Global{Form("sameEventFv0Global_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj mixedFv0Global{Form("mixedEventFv0Global_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj sameFv0Mft{Form("sameEventFv0Mft_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj mixedFv0Mft{Form("mixedEventFv0Mft_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + + void init(InitContext const&) + { + ccdb->setURL(cfgCcdbParam.cfgURL); + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + LOGF(info, "Getting alignment offsets from the CCDB..."); + offsetFT0 = ccdb->getForTimeStamp>("FT0/Calib/Align", cfgCcdbParam.noLaterThan.value); + offsetFV0 = ccdb->getForTimeStamp>("FV0/Calib/Align", cfgCcdbParam.noLaterThan.value); + LOGF(info, "Offset for FT0A: x = %.3f y = %.3f z = %.3f\n", (*offsetFT0)[0].getX(), (*offsetFT0)[0].getY(), (*offsetFT0)[0].getZ()); + LOGF(info, "Offset for FT0C: x = %.3f y = %.3f z = %.3f\n", (*offsetFT0)[1].getX(), (*offsetFT0)[1].getY(), (*offsetFT0)[1].getZ()); + LOGF(info, "Offset for FV0-left: x = %.3f y = %.3f\n", (*offsetFV0)[0].getX(), (*offsetFV0)[0].getY()); + LOGF(info, "Offset for FV0-right: x = %.3f y = %.3f\n", (*offsetFV0)[1].getX(), (*offsetFV0)[1].getY()); + + std::vector corrAxis = {{axisSample, "Sample"}, + {axisVtxZ, "z-vtx (cm)"}, + {axisPtTrigger, "p_{T} (GeV/c)"}, + {axisPtAssoc, "p_{T} (GeV/c)"}, + {axisDeltaPhi, "#Delta#varphi (rad)"}, + {axisDeltaEta, "#Delta#eta"}}; + std::vector effAxis = {{axisVertexEfficiency, "z-vtx (cm)"}, + {axisPtEfficiency, "p_{T} (GeV/c)"}, + {axisEtaEfficiency, "#eta"}}; + + std::vector userAxis; + + if (doprocessEventStat) { + histos.add("QA/EventHist", "events", kTH1F, {axisEvent}, false); + histos.add("QA/VtxZHist", "v_{z} (cm)", kTH1F, {axisVtxZ}, false); + + auto hstat = histos.get(HIST("QA/EventHist")); + auto* x = hstat->GetXaxis(); + x->SetBinLabel(1, "All events"); + x->SetBinLabel(2, "sel8"); + x->SetBinLabel(3, "kNoSameBunchPileup"); // reject collisions in case of pileup with another collision in the same foundBC + x->SetBinLabel(4, "|vz|<10"); + } + + histos.add("Ft0aGlobal/SE/hMult", "", kTH1D, {axisMultiplicity}); + histos.add("Ft0aGlobal/SE/Trig_etavsphi", "", kTH2D, {axisPhi, axisEtaTrig}); + histos.add("Ft0aGlobal/SE/Trig_eta", "", kTH1D, {axisEtaTrig}); + histos.add("Ft0aGlobal/SE/Trig_phi", "", kTH1D, {axisPhi}); + histos.add("Ft0aGlobal/SE/Trig_pt", "", kTH1D, {axisPtTrigger}); + histos.add("Ft0aGlobal/SE/hMult_used", "", kTH1F, {axisMultiplicity}); + histos.add("Ft0aGlobal/SE/Trig_hist", "", kTHnSparseF, {axisSample, axisVtxZ, axisPtTrigger}); + histos.add("Ft0aGlobal/SE/Assoc_amp", "", kTH2D, {channelFt0aAxis, amplitudeFt0a}); + histos.add("Ft0aGlobal/SE/Assoc_eta", "", kTH1D, {axisEtaAssoc}); + histos.add("Ft0aGlobal/SE/Assoc_phi", "", kTH1D, {axisPhi}); + histos.add("Ft0aGlobal/SE/Assoc_etavsphi", "", kTH2D, {axisPhi, axisEtaAssoc}); + histos.add("Ft0aGlobal/SE/deltaEta_deltaPhi", "", kTH2D, {axisDeltaPhi, axisDeltaEta}); + + histos.add("Ft0aGlobal/ME/hMult", "", kTH1D, {axisMultiplicity}); + histos.add("Ft0aGlobal/ME/Trig_etavsphi", "", kTH2D, {axisPhi, axisEtaTrig}); + histos.add("Ft0aGlobal/ME/Trig_eta", "", kTH1D, {axisEtaTrig}); + histos.add("Ft0aGlobal/ME/Trig_phi", "", kTH1D, {axisPhi}); + histos.add("Ft0aGlobal/ME/Trig_pt", "", kTH1D, {axisPtTrigger}); + histos.add("Ft0aGlobal/ME/Assoc_amp", "", kTH2D, {channelFt0aAxis, amplitudeFt0a}); + histos.add("Ft0aGlobal/ME/Assoc_eta", "", kTH1D, {axisEtaAssoc}); + histos.add("Ft0aGlobal/ME/Assoc_phi", "", kTH1D, {axisPhi}); + histos.add("Ft0aGlobal/ME/Assoc_etavsphi", "", kTH2D, {axisPhi, axisEtaAssoc}); + histos.add("Ft0aGlobal/ME/deltaEta_deltaPhi", "", kTH2D, {axisDeltaPhi, axisDeltaEta}); + + if (doprocessFt0aGlobalSE || doprocessFt0aGlobalME) { + sameFt0aGlobal.setObject(new CorrelationContainer(Form("sameEventFt0aGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("sameEventFt0aGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + mixedFt0aGlobal.setObject(new CorrelationContainer(Form("mixedEventFt0aGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("mixedEventFt0aGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + } + + if (doprocessFt0cGlobalSE || doprocessFt0cGlobalME) { + histos.addClone("Ft0aGlobal/SE/", "Ft0cGlobal/SE/"); + histos.addClone("Ft0aGlobal/ME/", "Ft0cGlobal/ME/"); + sameFt0cGlobal.setObject(new CorrelationContainer(Form("sameEventFt0cGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("sameEventFt0cGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + mixedFt0cGlobal.setObject(new CorrelationContainer(Form("mixedEventFt0cGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("mixedEventFt0cGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + } + + if (doprocessMftGlobalSE || doprocessMftGlobalME) { + histos.addClone("Ft0aGlobal/SE/", "MftGlobal/SE/"); + histos.addClone("Ft0aGlobal/ME/", "MftGlobal/ME/"); + sameMftGlobal.setObject(new CorrelationContainer(Form("sameEventMftGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("sameEventMftGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + mixedMftGlobal.setObject(new CorrelationContainer(Form("mixedEventMftGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("mixedEventMftGlobal_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + } + + if (doprocessFv0GlobalSE || doprocessFv0GlobalME) { + histos.addClone("Ft0aGlobal/SE/", "Fv0Global/SE/"); + histos.addClone("Ft0aGlobal/ME/", "Fv0Global/ME/"); + sameFv0Global.setObject(new CorrelationContainer(Form("sameEventFv0Global_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("sameEventFv0Global_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + mixedFv0Global.setObject(new CorrelationContainer(Form("mixedEventFv0Global_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("mixedEventFv0Global_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + } + + if (doprocessFv0MftSE || doprocessFv0MftME) { + histos.addClone("Ft0aGlobal/SE/", "Fv0Mft/SE/"); + histos.addClone("Ft0aGlobal/ME/", "Fv0Mft/ME/"); + sameFv0Mft.setObject(new CorrelationContainer(Form("sameEventFv0Mft_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("sameEventFv0Mft_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + mixedFv0Mft.setObject(new CorrelationContainer(Form("mixedEventFv0Mft_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("mixedEventFv0Mft_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + } + } + + Filter fTrackSelectionITS = ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) && + ncheckbit(aod::track::trackCutFlag, TrackSelectionIts); + Filter fTrackSelectionTPC = ifnode(ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC), + ncheckbit(aod::track::trackCutFlag, TrackSelectionTpc), true); + Filter fTrackSelectionDCA = ifnode(dcaZ.node() > 0.f, nabs(aod::track::dcaZ) <= dcaZ && ncheckbit(aod::track::trackCutFlag, TrackSelectionDcaxyOnly), + ncheckbit(aod::track::trackCutFlag, TrackSelectionDca)); + Filter fTracksEta = nabs(aod::track::eta) < cfgEtaCut; + Filter fTracksPt = (aod::track::pt > cfgPtCutMin) && (aod::track::pt < cfgPtCutMax); + + Filter fMftTrackEta = (aod::fwdtrack::eta < cfigMftEtaMax) && (aod::fwdtrack::eta > cfigMftEtaMin); + Filter fMftTrackColID = (aod::fwdtrack::bestCollisionId >= 0); + Filter fMftTrackDca = (nabs(aod::fwdtrack::bestDCAXY) < cfigMftDcaxy); + + double getPhiFT0(int chno, double offsetX, double offsetY) + { + o2::ft0::Geometry ft0Det; + ft0Det.calculateChannelCenter(); + auto chPos = ft0Det.getChannelCenter(chno); + return RecoDecay::phi(chPos.X() + offsetX, chPos.Y() + offsetY); + } + + double getPhiFV0(int chno) + { + o2::fv0::Geometry fv0Det; + int cellsInLeft[] = {0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27, 32, 40, 33, 41, 34, 42, 35, 43}; + bool isChnoInLeft = std::find(std::begin(cellsInLeft), std::end(cellsInLeft), chno) != std::end(cellsInLeft); + float offsetX, offsetY; + if (isChnoInLeft) { + offsetX = (*offsetFV0)[0].getX(); + offsetY = (*offsetFV0)[0].getY(); + } else { + offsetX = (*offsetFV0)[1].getX(); + offsetY = (*offsetFV0)[1].getY(); + } + + auto chPos = fv0Det.getReadoutCenter(chno); + return RecoDecay::phi(chPos.x + offsetX, chPos.y + offsetY); + } + + double getEtaFT0(int chno, double offsetX, double offsetY, double offsetZ) + { + o2::ft0::Geometry ft0Det; + ft0Det.calculateChannelCenter(); + auto chPos = ft0Det.getChannelCenter(chno); + auto x = chPos.X() + offsetX; + auto y = chPos.Y() + offsetY; + auto z = chPos.Z() + offsetZ; + auto r = std::sqrt(x * x + y * y); + auto theta = std::atan2(r, z); + return -std::log(std::tan(0.5 * theta)); + } + + double getEtaFV0(int chno) + { + o2::fv0::Geometry fv0Det; + int cellsInLeft[] = {0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27, 32, 40, 33, 41, 34, 42, 35, 43}; + bool isChnoInLeft = std::find(std::begin(cellsInLeft), std::end(cellsInLeft), chno) != std::end(cellsInLeft); + float offsetX, offsetY, offsetZ; + if (isChnoInLeft) { + offsetX = (*offsetFV0)[0].getX(); + offsetY = (*offsetFV0)[0].getY(); + offsetZ = (*offsetFV0)[0].getZ(); + } else { + offsetX = (*offsetFV0)[1].getX(); + offsetY = (*offsetFV0)[1].getY(); + offsetZ = (*offsetFV0)[1].getZ(); + } + + auto chPos = fv0Det.getReadoutCenter(chno); + auto x = chPos.x + offsetX; + auto y = chPos.y + offsetY; + auto z = chPos.z + offsetZ; + auto r = std::sqrt(x * x + y * y); + auto theta = std::atan2(r, z); + return -std::log(std::tan(0.5 * theta)); + } + + template + bool isEventSelected(CheckCol const& col) + { + if (!col.sel8()) { + return false; + } + if (isApplySameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + if (std::abs(col.posZ()) >= cfgVtxCut) { + return false; + } + return true; + } + + template + bool isMftTrackSelected(CheckMftTrack const& track) + { + if (track.nClusters() < cfigMftCluster) { + return false; + } + return true; + } + + template + void fillYield(TTracks tracks, bool mixing) + { + static constexpr std::string_view SubDirSE[] = {"Ft0aGlobal/SE/", "Ft0cGlobal/SE/", "Fv0Global/SE/", + "MftGlobal/SE/", "Fv0Mft/SE/"}; + static constexpr std::string_view SubDirME[] = {"Ft0aGlobal/ME/", "Ft0cGlobal/ME/", "Fv0Global/ME/", + "MftGlobal/ME/", "Fv0Mft/ME/"}; + + if (mixing) { + histos.fill(HIST(SubDirME[mode]) + HIST("hMult"), tracks.size()); + for (auto const& triggerTrack : tracks) { + histos.fill(HIST(SubDirME[mode]) + HIST("Trig_etavsphi"), triggerTrack.phi(), triggerTrack.eta()); + histos.fill(HIST(SubDirME[mode]) + HIST("Trig_eta"), triggerTrack.eta()); + histos.fill(HIST(SubDirME[mode]) + HIST("Trig_phi"), triggerTrack.phi()); + histos.fill(HIST(SubDirME[mode]) + HIST("Trig_pt"), triggerTrack.pt()); + } + } else { + histos.fill(HIST(SubDirSE[mode]) + HIST("hMult"), tracks.size()); + for (auto const& triggerTrack : tracks) { + histos.fill(HIST(SubDirSE[mode]) + HIST("Trig_etavsphi"), triggerTrack.phi(), triggerTrack.eta()); + histos.fill(HIST(SubDirSE[mode]) + HIST("Trig_eta"), triggerTrack.eta()); + histos.fill(HIST(SubDirSE[mode]) + HIST("Trig_phi"), triggerTrack.phi()); + histos.fill(HIST(SubDirSE[mode]) + HIST("Trig_pt"), triggerTrack.pt()); + } + } + } + + template + void fillCorrFt0aGlobal(TTarget target, TTriggers const& triggers, TFT0s const& ft0, bool mixing, float vz) + { + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + if (!mixing) + histos.fill(HIST("Ft0aGlobal/SE/hMult_used"), triggers.size()); + for (auto const& triggerTrack : triggers) { + if (!mixing) + histos.fill(HIST("Ft0aGlobal/SE/Trig_hist"), fSampleIndex, vz, triggerTrack.pt()); + + auto offsetX = (*offsetFT0)[0].getX(); + auto offsetY = (*offsetFT0)[0].getY(); + auto offsetZ = (*offsetFT0)[0].getZ(); + for (std::size_t iCh = 0; iCh < ft0.channelA().size(); iCh++) { + auto chanelid = ft0.channelA()[iCh]; + float ampl = ft0.amplitudeA()[iCh]; + if (ampl <= 0) + continue; + if (mixing) + histos.fill(HIST("Ft0aGlobal/ME/Assoc_amp"), chanelid, ampl); + else + histos.fill(HIST("Ft0aGlobal/SE/Assoc_amp"), chanelid, ampl); + + auto phi = getPhiFT0(chanelid, offsetX, offsetY); + auto eta = getEtaFT0(chanelid, offsetX, offsetY, offsetZ); + + if (mixing) { + histos.fill(HIST("Ft0aGlobal/ME/Assoc_eta"), eta); + histos.fill(HIST("Ft0aGlobal/ME/Assoc_phi"), phi); + histos.fill(HIST("Ft0aGlobal/ME/Assoc_etavsphi"), phi, eta); + } else { + histos.fill(HIST("Ft0aGlobal/SE/Assoc_eta"), eta); + histos.fill(HIST("Ft0aGlobal/SE/Assoc_phi"), phi); + histos.fill(HIST("Ft0aGlobal/SE/Assoc_etavsphi"), phi, eta); + } + float deltaPhi = RecoDecay::constrainAngle(triggerTrack.phi() - phi, -PIHalf); + float deltaEta = triggerTrack.eta() - eta; + if (mixing) + histos.fill(HIST("Ft0aGlobal/ME/deltaEta_deltaPhi"), deltaPhi, deltaEta); + else + histos.fill(HIST("Ft0aGlobal/SE/deltaEta_deltaPhi"), deltaPhi, deltaEta); + target->getPairHist()->Fill(step, fSampleIndex, vz, triggerTrack.pt(), triggerTrack.pt(), deltaPhi, deltaEta); + } // associated ft0 tracks + } // trigger tracks + } // fillCorrFt0aGlobal + + template + void fillCorrFt0cGlobal(TTarget target, TTriggers const& triggers, TFT0s const& ft0, bool mixing, float vz) + { + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + if (!mixing) + histos.fill(HIST("Ft0cGlobal/SE/hMult_used"), triggers.size()); + for (auto const& triggerTrack : triggers) { + if (!mixing) + histos.fill(HIST("Ft0cGlobal/SE/Trig_hist"), fSampleIndex, vz, triggerTrack.pt()); + + auto offsetX = (*offsetFT0)[1].getX(); + auto offsetY = (*offsetFT0)[1].getY(); + auto offsetZ = (*offsetFT0)[1].getZ(); + for (std::size_t iCh = 0; iCh < ft0.channelC().size(); iCh++) { + auto chanelid = ft0.channelC()[iCh]; + float ampl = ft0.amplitudeC()[iCh]; + if (ampl <= 0) + continue; + if (mixing) + histos.fill(HIST("Ft0cGlobal/ME/Assoc_amp"), chanelid, ampl); + else + histos.fill(HIST("Ft0cGlobal/SE/Assoc_amp"), chanelid, ampl); + + auto phi = getPhiFT0(chanelid, offsetX, offsetY); + auto eta = getEtaFT0(chanelid, offsetX, offsetY, offsetZ); + + if (mixing) { + histos.fill(HIST("Ft0cGlobal/ME/Assoc_eta"), eta); + histos.fill(HIST("Ft0cGlobal/ME/Assoc_phi"), phi); + histos.fill(HIST("Ft0cGlobal/ME/Assoc_etavsphi"), phi, eta); + } else { + histos.fill(HIST("Ft0cGlobal/SE/Assoc_eta"), eta); + histos.fill(HIST("Ft0cGlobal/SE/Assoc_phi"), phi); + histos.fill(HIST("Ft0cGlobal/SE/Assoc_etavsphi"), phi, eta); + } + float deltaPhi = RecoDecay::constrainAngle(triggerTrack.phi() - phi, -PIHalf); + float deltaEta = triggerTrack.eta() - eta; + if (mixing) + histos.fill(HIST("Ft0cGlobal/ME/deltaEta_deltaPhi"), deltaPhi, deltaEta); + else + histos.fill(HIST("Ft0cGlobal/SE/deltaEta_deltaPhi"), deltaPhi, deltaEta); + target->getPairHist()->Fill(step, fSampleIndex, vz, triggerTrack.pt(), triggerTrack.pt(), deltaPhi, deltaEta); + } // associated ft0 tracks + } // trigger tracks + } // fillCorrFt0cGlobal + + template + void fillCorrMftGlobal(TTarget target, TTriggers const& triggers, TMFTs const& mft, bool mixing, float vz) + { + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + if (!mixing) + histos.fill(HIST("MftGlobal/SE/hMult_used"), triggers.size()); + for (auto const& triggerTrack : triggers) { + if (!mixing) + histos.fill(HIST("MftGlobal/SE/Trig_hist"), fSampleIndex, vz, triggerTrack.pt()); + + for (auto const& assoTrack : mft) { + if (!isMftTrackSelected(assoTrack)) { + continue; + } + auto phi = assoTrack.phi(); + o2::math_utils::bringTo02Pi(phi); + if (mixing) { + histos.fill(HIST("MftGlobal/ME/Assoc_eta"), assoTrack.eta()); + histos.fill(HIST("MftGlobal/ME/Assoc_phi"), phi); + histos.fill(HIST("MftGlobal/ME/Assoc_etavsphi"), phi, assoTrack.eta()); + } else { + histos.fill(HIST("MftGlobal/SE/Assoc_eta"), assoTrack.eta()); + histos.fill(HIST("MftGlobal/SE/Assoc_phi"), phi); + histos.fill(HIST("MftGlobal/SE/Assoc_etavsphi"), phi, assoTrack.eta()); + } + float deltaPhi = RecoDecay::constrainAngle(triggerTrack.phi() - phi, -PIHalf); + float deltaEta = triggerTrack.eta() - assoTrack.eta(); + if (mixing) + histos.fill(HIST("MftGlobal/ME/deltaEta_deltaPhi"), deltaPhi, deltaEta); + else + histos.fill(HIST("MftGlobal/SE/deltaEta_deltaPhi"), deltaPhi, deltaEta); + target->getPairHist()->Fill(step, fSampleIndex, vz, triggerTrack.pt(), assoTrack.pt(), deltaPhi, deltaEta); + } // associated mft tracks + } // trigger tracks + } // fillCorrMftGlobal + + template + void fillCorrFv0Global(TTarget target, TTriggers const& triggers, TFV0s const& fv0, bool mixing, float vz) + { + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + if (!mixing) + histos.fill(HIST("Fv0Global/SE/hMult_used"), triggers.size()); + for (auto const& triggerTrack : triggers) { + if (!mixing) + histos.fill(HIST("Fv0Global/SE/Trig_hist"), fSampleIndex, vz, triggerTrack.pt()); + + for (std::size_t iCh = 0; iCh < fv0.channel().size(); iCh++) { + auto chanelid = fv0.channel()[iCh]; + float ampl = fv0.amplitude()[iCh]; + if (ampl <= 0) + continue; + if (mixing) + histos.fill(HIST("Fv0Global/ME/Assoc_amp"), chanelid, ampl); + else + histos.fill(HIST("Fv0Global/SE/Assoc_amp"), chanelid, ampl); + + auto phi = getPhiFV0(chanelid); + auto eta = getEtaFV0(chanelid); + + if (mixing) { + histos.fill(HIST("Fv0Global/ME/Assoc_eta"), eta); + histos.fill(HIST("Fv0Global/ME/Assoc_phi"), phi); + histos.fill(HIST("Fv0Global/ME/Assoc_etavsphi"), phi, eta); + } else { + histos.fill(HIST("Fv0Global/SE/Assoc_eta"), eta); + histos.fill(HIST("Fv0Global/SE/Assoc_phi"), phi); + histos.fill(HIST("Fv0Global/SE/Assoc_etavsphi"), phi, eta); + } + float deltaPhi = RecoDecay::constrainAngle(triggerTrack.phi() - phi, -PIHalf); + float deltaEta = triggerTrack.eta() - eta; + if (mixing) + histos.fill(HIST("Fv0Global/ME/deltaEta_deltaPhi"), deltaPhi, deltaEta); + else + histos.fill(HIST("Fv0Global/SE/deltaEta_deltaPhi"), deltaPhi, deltaEta); + target->getPairHist()->Fill(step, fSampleIndex, vz, triggerTrack.pt(), triggerTrack.pt(), deltaPhi, deltaEta); + } // associated fv0 tracks + } // trigger tracks + } // fillCorrFv0Global + + template + void fillCorrFv0Mft(TTarget target, TTracks const& tracks, TTriggers const& triggers, TFV0s const& fv0, bool mixing, float vz) + { + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + if (!mixing) + histos.fill(HIST("Fv0Mft/SE/hMult_used"), tracks.size()); + for (auto const& triggerTrack : triggers) { + if (!isMftTrackSelected(triggerTrack)) { + continue; + } + if (!mixing) + histos.fill(HIST("Fv0Mft/SE/Trig_hist"), fSampleIndex, vz, triggerTrack.pt()); + + auto trigphi = triggerTrack.phi(); + o2::math_utils::bringTo02Pi(trigphi); + + for (std::size_t iCh = 0; iCh < fv0.channel().size(); iCh++) { + auto chanelid = fv0.channel()[iCh]; + float ampl = fv0.amplitude()[iCh]; + if (ampl <= 0) + continue; + if (mixing) + histos.fill(HIST("Fv0Mft/ME/Assoc_amp"), chanelid, ampl); + else + histos.fill(HIST("Fv0Mft/SE/Assoc_amp"), chanelid, ampl); + + auto phi = getPhiFV0(chanelid); + auto eta = getEtaFV0(chanelid); + + if (mixing) { + histos.fill(HIST("Fv0Mft/ME/Assoc_eta"), eta); + histos.fill(HIST("Fv0Mft/ME/Assoc_phi"), phi); + histos.fill(HIST("Fv0Mft/ME/Assoc_etavsphi"), phi, eta); + } else { + histos.fill(HIST("Fv0Mft/SE/Assoc_eta"), eta); + histos.fill(HIST("Fv0Mft/SE/Assoc_phi"), phi); + histos.fill(HIST("Fv0Mft/SE/Assoc_etavsphi"), phi, eta); + } + + float deltaPhi = RecoDecay::constrainAngle(trigphi - phi, -PIHalf); + float deltaEta = triggerTrack.eta() - eta; + if (mixing) + histos.fill(HIST("Fv0Mft/ME/deltaEta_deltaPhi"), deltaPhi, deltaEta); + else + histos.fill(HIST("Fv0Mft/SE/deltaEta_deltaPhi"), deltaPhi, deltaEta); + target->getPairHist()->Fill(step, fSampleIndex, vz, triggerTrack.pt(), triggerTrack.pt(), deltaPhi, deltaEta); + } // associated fv0 tracks + } // trigger tracks + } // fillCorrFv0Mft + + void processEventStat(CollTable::iterator const& col) + { + histos.fill(HIST("QA/EventHist"), 1); + if (!col.sel8()) { + return; + } + histos.fill(HIST("QA/EventHist"), 2); + if (isApplySameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return; + } + histos.fill(HIST("QA/EventHist"), 3); + if (std::abs(col.posZ()) >= cfgVtxCut) { + return; + } + histos.fill(HIST("QA/EventHist"), 4); + histos.fill(HIST("QA/VtxZHist"), col.posZ()); + } + + void processFt0aGlobalSE(CollTable::iterator const& col, aod::FT0s const&, TrksTable const& tracks) + { + if (!isEventSelected(col)) { + return; + } + if (col.has_foundFT0()) { + fillYield<0>(tracks, false); + const auto& ft0 = col.foundFT0(); + if (tracks.size() < cfgMinMult || tracks.size() >= cfgMaxMult) { + return; + } + fillCorrFt0aGlobal(sameFt0aGlobal, tracks, ft0, false, col.posZ()); + } + } // same event + + void processFt0cGlobalSE(CollTable::iterator const& col, aod::FT0s const&, TrksTable const& tracks) + { + if (!isEventSelected(col)) { + return; + } + if (col.has_foundFT0()) { + fillYield<1>(tracks, false); + const auto& ft0 = col.foundFT0(); + if (tracks.size() < cfgMinMult || tracks.size() >= cfgMaxMult) { + return; + } + fillCorrFt0cGlobal(sameFt0cGlobal, tracks, ft0, false, col.posZ()); + } + } // same event + + void processMftGlobalSE(CollTable::iterator const& col, MftTrkTable const& mfttracks, TrksTable const& tracks) + { + if (!isEventSelected(col)) { + return; + } + fillYield<3>(tracks, false); + if (tracks.size() < cfgMinMult || tracks.size() >= cfgMaxMult) { + return; + } + fillCorrMftGlobal(sameMftGlobal, tracks, mfttracks, false, col.posZ()); + } // same event + + void processFv0GlobalSE(CollTable::iterator const& col, aod::FV0As const&, TrksTable const& tracks) + { + if (!isEventSelected(col)) { + return; + } + if (col.has_foundFV0()) { + fillYield<2>(tracks, false); + const auto& fv0 = col.foundFV0(); + if (tracks.size() < cfgMinMult || tracks.size() >= cfgMaxMult) { + return; + } + fillCorrFv0Global(sameFv0Global, tracks, fv0, false, col.posZ()); + } + } // same event + + void processFv0MftSE(CollTable::iterator const& col, aod::FV0As const&, TrksTable const& tracks, MftTrkTable const& mfttracks) + { + if (!isEventSelected(col)) { + return; + } + if (col.has_foundFV0()) { + fillYield<4>(mfttracks, false); + const auto& fv0 = col.foundFV0(); + if (tracks.size() < cfgMinMult || tracks.size() >= cfgMaxMult) { + return; + } + fillCorrFv0Mft(sameFv0Mft, tracks, mfttracks, fv0, false, col.posZ()); + } + } // same event + + void processFt0aGlobalME(CollTable const& col, aod::FT0s const&, TrksTable const& tracks) + { + auto getTracksSize = [&tracks, this](CollTable::iterator const& collision) { + auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), this->cache); + return associatedTracks.size(); + }; + + using MixedBinning = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getTracksSize)>; + MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxZME, axisMultME}, true}; + for (auto const& [col1, col2] : soa::selfCombinations(binningOnVtxAndMult, mixingParameter, -1, col, col)) { + if (!isEventSelected(col1) || !isEventSelected(col2)) { + continue; + } + if (col1.globalIndex() == col2.globalIndex()) { + continue; + } + if (col1.has_foundFT0() && col2.has_foundFT0()) { + auto slicedTriggerTracks = tracks.sliceBy(perColGlobal, col1.globalIndex()); + fillYield<0>(slicedTriggerTracks, true); + const auto& ft0 = col2.foundFT0(); + if (slicedTriggerTracks.size() < cfgMinMult || slicedTriggerTracks.size() >= cfgMaxMult) { + continue; + } + fillCorrFt0aGlobal(mixedFt0aGlobal, slicedTriggerTracks, ft0, true, col1.posZ()); + } + } + } // mixed event + + void processFt0cGlobalME(CollTable const& col, aod::FT0s const&, TrksTable const& tracks) + { + auto getTracksSize = [&tracks, this](CollTable::iterator const& collision) { + auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), this->cache); + return associatedTracks.size(); + }; + + using MixedBinning = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getTracksSize)>; + MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxZME, axisMultME}, true}; + for (auto const& [col1, col2] : soa::selfCombinations(binningOnVtxAndMult, mixingParameter, -1, col, col)) { + if (!isEventSelected(col1) || !isEventSelected(col2)) { + continue; + } + if (col1.globalIndex() == col2.globalIndex()) { + continue; + } + if (col1.has_foundFT0() && col2.has_foundFT0()) { + auto slicedTriggerTracks = tracks.sliceBy(perColGlobal, col1.globalIndex()); + fillYield<1>(slicedTriggerTracks, true); + const auto& ft0 = col2.foundFT0(); + if (slicedTriggerTracks.size() < cfgMinMult || slicedTriggerTracks.size() >= cfgMaxMult) { + continue; + } + fillCorrFt0cGlobal(mixedFt0cGlobal, slicedTriggerTracks, ft0, true, col1.posZ()); + } + } + } // mixed event + + void processMftGlobalME(CollTable const& col, MftTrkTable const& mfttracks, TrksTable const& tracks) + { + auto getTracksSize = [&tracks, this](CollTable::iterator const& collision) { + auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), this->cache); + return associatedTracks.size(); + }; + + using MixedBinning = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getTracksSize)>; + MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxZME, axisMultME}, true}; + auto tracksTuple = std::make_tuple(tracks, mfttracks); + Pair pairs{binningOnVtxAndMult, mixingParameter, -1, col, tracksTuple, &cache}; + for (auto const& [col1, tracks1, col2, tracks2] : pairs) { + if (!isEventSelected(col1) || !isEventSelected(col2)) { + continue; + } + if ((tracks1.size() < cfgMinMult || tracks1.size() >= cfgMaxMult)) { + continue; + } + fillCorrMftGlobal(mixedMftGlobal, tracks1, tracks2, true, col1.posZ()); + } + } // mixed event + + void processFv0GlobalME(CollTable const& col, aod::FV0As const&, TrksTable const& tracks) + { + auto getTracksSize = [&tracks, this](CollTable::iterator const& collision) { + auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), this->cache); + return associatedTracks.size(); + }; + + using MixedBinning = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getTracksSize)>; + MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxZME, axisMultME}, true}; + for (auto const& [col1, col2] : soa::selfCombinations(binningOnVtxAndMult, mixingParameter, -1, col, col)) { + if (!isEventSelected(col1) || !isEventSelected(col2)) { + continue; + } + if (col1.globalIndex() == col2.globalIndex()) { + continue; + } + if (col1.has_foundFV0() && col2.has_foundFV0()) { + auto slicedTriggerTracks = tracks.sliceBy(perColGlobal, col1.globalIndex()); + fillYield<2>(slicedTriggerTracks, true); + const auto& fv0 = col2.foundFV0(); + if (slicedTriggerTracks.size() < cfgMinMult || slicedTriggerTracks.size() >= cfgMaxMult) { + continue; + } + fillCorrFv0Global(mixedFv0Global, slicedTriggerTracks, fv0, true, col1.posZ()); + } + } + } // mixed event + + void processFv0MftME(CollTable const& col, aod::FV0As const&, TrksTable const& tracks, MftTrkTable const& mfttracks) + { + auto getTracksSize = [&tracks, this](CollTable::iterator const& collision) { + auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), this->cache); + return associatedTracks.size(); + }; + + using MixedBinning = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getTracksSize)>; + MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxZME, axisMultME}, true}; + for (auto const& [col1, col2] : soa::selfCombinations(binningOnVtxAndMult, mixingParameter, -1, col, col)) { + if (!isEventSelected(col1) || !isEventSelected(col2)) { + continue; + } + if (col1.globalIndex() == col2.globalIndex()) { + continue; + } + if (col1.has_foundFV0() && col2.has_foundFV0()) { + auto slicedGlobalTracks = tracks.sliceBy(perColGlobal, col1.globalIndex()); + auto slicedTriggerMftTracks = mfttracks.sliceBy(perColMft, col1.globalIndex()); + fillYield<4>(slicedTriggerMftTracks, true); + const auto& fv0 = col2.foundFV0(); + if (slicedGlobalTracks.size() < cfgMinMult || slicedGlobalTracks.size() >= cfgMaxMult) { + continue; + } + fillCorrFv0Mft(mixedFv0Mft, slicedGlobalTracks, slicedTriggerMftTracks, fv0, true, col1.posZ()); + } + } + } // mixed event + + PROCESS_SWITCH(LongrangeCorrelation, processEventStat, "event stat", false); + PROCESS_SWITCH(LongrangeCorrelation, processFt0aGlobalSE, "same event FT0a vs global", false); + PROCESS_SWITCH(LongrangeCorrelation, processFt0aGlobalME, "mixed event FT0a vs global", false); + PROCESS_SWITCH(LongrangeCorrelation, processFt0cGlobalSE, "same event FT0c vs global", false); + PROCESS_SWITCH(LongrangeCorrelation, processFt0cGlobalME, "mixed event FT0c vs global", false); + PROCESS_SWITCH(LongrangeCorrelation, processMftGlobalSE, "same event MFT vs global", false); + PROCESS_SWITCH(LongrangeCorrelation, processMftGlobalME, "mixed event MFT vs global", false); + PROCESS_SWITCH(LongrangeCorrelation, processFv0GlobalSE, "same event FV0 vs global", false); + PROCESS_SWITCH(LongrangeCorrelation, processFv0GlobalME, "mixed event FV0 vs global", false); + PROCESS_SWITCH(LongrangeCorrelation, processFv0MftSE, "same event FV0 vs MFT", false); + PROCESS_SWITCH(LongrangeCorrelation, processFv0MftME, "mixed event FV0 vs MFT", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/TwoParticleCorrelations/Tasks/neutronProtonCorrZdc.cxx b/PWGCF/TwoParticleCorrelations/Tasks/neutronProtonCorrZdc.cxx index 1b51265f19e..1870c66da80 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/neutronProtonCorrZdc.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/neutronProtonCorrZdc.cxx @@ -19,7 +19,6 @@ #include "Framework/ASoAHelpers.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/Multiplicity.h" #include "Framework/StaticFor.h" @@ -29,14 +28,29 @@ using namespace o2::framework; using namespace o2::framework::expressions; enum EventCounter { kNoSelection = 0, - kQualitySelection = 1, - kMaxCentralitySelection = 2, - kZDCSelection = 3 }; + kSel8 = 1, + kNoSameBunchPileUp = 2, + kIsGoodZvtxFT0vsPV = 3, + kNoCollInTimeRangeStandard = 4, + kMaxCentralitySelection = 5, + kZDCSelection = 6, + kTimeDifferenceZDC = 7 }; struct NeutronProtonCorrZdc { // Histogram registry: an object to hold your histograms HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable cfgZVertexCut{"cfgZVertexCut", 10., "Cut on Z vertex position"}; + Configurable cfgNoSameBunchPileupCut{"cfgNoSameBunchPileupCut", true, "kNoSameBunchPileUp Cut"}; + Configurable cfgIsGoodZvtxFT0vsPV{"cfgIsGoodZvtxFT0vsPV", true, "kIsGoodZvtxFT0vsPV Cut"}; + Configurable cfgNoCollInTimeRangeStandard{"cfgNoCollInTimeRangeStandard", true, "kNoCollInTimeRangeStandard Cut"}; + Configurable cfgMaxCentrality{"cfgMaxCentrality", 80, "Maximum collision centrality"}; + Configurable cfgZDCTimingInformationCut{"cfgZDCTimingInformationCut", true, "Use timing information in ZDC event selection"}; + Configurable cfgTimingBins{"cfgTimingBins", 200, "N bins for timing histograms"}; + Configurable cfgTDCZNmincut{"cfgTDCZNmincut", -3.0, "Min ZN TDC cut"}; + Configurable cfgTDCZNmaxcut{"cfgTDCZNmaxcut", 3.0, "Max ZN TDC cut"}; + Configurable cfgTDCZPmincut{"cfgTDCZPmincut", -3.0, "Min ZP TDC cut"}; + Configurable cfgTDCZPmaxcut{"cfgTDCZPmaxcut", 3.0, "Max ZP TDC cut"}; Configurable cfgNBinsZN{"cfgNBinsZN", 100, "N bins for ZNA and ZNC"}; Configurable cfgNBinsZP{"cfgNBinsZP", 100, "N bins for ZPA and ZPC"}; Configurable cfgZNmin{"cfgZNmin", -10, "Minimum value for ZN signal"}; @@ -48,20 +62,23 @@ struct NeutronProtonCorrZdc { Configurable cfgNBinsAlpha{"cfgNBinsAlpha", 100, "Number of bins for ZDC asymmetry"}; Configurable cfgAlphaZmin{"cfgAlphaZmin", -1, "Minimum value for ZDC asymmetry"}; Configurable cfgAlphaZmax{"cfgAlphaZmax", 1, "Maximum value for ZDC asymmetry"}; - Configurable cfgMaxCentrality{"cfgMaxCentrality", 80, "Maximum collision centrality"}; + Configurable cfgCentralityEstimator{"cfgCentralityEstimator", 0, "Choice of centrality estimator"}; + Configurable cfgFillMultiplicityQAHistograms{"cfgFillMultiplicityQAHistograms", true, "Fill multiplicity QA plots"}; + Configurable cfgNBinsMultiplicity{"cfgNBinsMultiplicity", 500, "N bins for multiplicity histograms"}; ConfigurableAxis cfgAxisCent{"cfgAxisCent", {VARIABLE_WIDTH, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0, 71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0, 80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0, 90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0}, "Centrality [%]"}; - Filter collisionVtxZ = nabs(aod::collision::posZ) < 10.f; + Filter collisionVtxZ = nabs(aod::collision::posZ) < cfgZVertexCut; - using CentralitiesRun3 = aod::CentFT0Cs; + using CentralitiesRun3 = soa::Join; using CentralitiesRun2 = aod::CentRun2V0Ms; using BCsRun3 = soa::Join; void init(InitContext const&) { // define axes you want to use - const AxisSpec axisCounter{4, -0.5, 3.5, ""}; + const AxisSpec axisCounter{8, -0.5, 7.5, ""}; + const AxisSpec axisZDCTiming{cfgTimingBins, -10, 10}; const AxisSpec axisZNSectorSignal{cfgNBinsZN, cfgZNmin, cfgZNmax / 3.}; const AxisSpec axisZPSectorSignal{cfgNBinsZP, cfgZPmin, cfgZPmax / 3.}; const AxisSpec axisZNASignal{cfgNBinsZN, cfgZNmin, cfgZNmax, "ZNA (a.u.)"}; @@ -72,14 +89,33 @@ struct NeutronProtonCorrZdc { const AxisSpec axisZPSignal{2 * cfgNBinsZP, cfgZPmin, 1.5 * cfgZPmax, "ZP (a.u.)"}; const AxisSpec axisAlphaZ{cfgNBinsAlpha, cfgAlphaZmin, cfgAlphaZmax, "#alpha_{spec}"}; const AxisSpec axisZDiffSignal{cfgNBinsZN, cfgDiffZmin, cfgDiffZmax, "#Delta E"}; - + const AxisSpec axisMultiplicityF0A{cfgNBinsMultiplicity, 0, 200000, "F0A"}; + const AxisSpec axisMultiplicityF0C{cfgNBinsMultiplicity, 0, 100000, "F0C"}; + const AxisSpec axisMultiplicityF0M{cfgNBinsMultiplicity, 0, 300000, "F0M"}; + const AxisSpec axisMultiplicityFDD{cfgNBinsMultiplicity, 0, 50000, "FDD"}; + const AxisSpec axisMultiplicityTPC{cfgNBinsMultiplicity, 0, 100000, "TPC"}; + const AxisSpec axisMultiplicityMultNGlobal{cfgNBinsMultiplicity, 0, 3500, "MultsNGlobal"}; + + HistogramConfigSpec defaultTimingHistogram({HistType::kTH2F, {cfgAxisCent, axisZDCTiming}}); HistogramConfigSpec defaultZNSectorHist({HistType::kTH2F, {cfgAxisCent, axisZNSectorSignal}}); HistogramConfigSpec defaultZPSectorHist({HistType::kTH2F, {cfgAxisCent, axisZPSectorSignal}}); HistogramConfigSpec defaultZDCDiffHist({HistType::kTH2F, {cfgAxisCent, axisZDiffSignal}}); // create histograms histos.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); + histos.get(HIST("eventCounter"))->GetXaxis()->SetBinLabel(EventCounter::kSel8 + 1, "Sel8"); + histos.get(HIST("eventCounter"))->GetXaxis()->SetBinLabel(EventCounter::kNoSameBunchPileUp + 1, "kNoSameBunchPileup"); + histos.get(HIST("eventCounter"))->GetXaxis()->SetBinLabel(EventCounter::kIsGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("eventCounter"))->GetXaxis()->SetBinLabel(EventCounter::kNoCollInTimeRangeStandard + 1, "kNoCollInTimeRangeStandard"); + histos.get(HIST("eventCounter"))->GetXaxis()->SetBinLabel(EventCounter::kMaxCentralitySelection + 1, "Cenrality range"); + histos.get(HIST("eventCounter"))->GetXaxis()->SetBinLabel(EventCounter::kZDCSelection + 1, "isSelectedZDC"); + histos.get(HIST("eventCounter"))->GetXaxis()->SetBinLabel(EventCounter::kTimeDifferenceZDC + 1, "ZDC time difference"); + histos.add("CentralityPercentile", "CentralityPercentile", kTH1F, {cfgAxisCent}); + histos.add("TimingZNAvsCent", "TimingZNAvsCent", defaultTimingHistogram); + histos.add("TimingZNCvsCent", "TimingZNCvsCent", defaultTimingHistogram); + histos.add("TimingZPAvsCent", "TimingZPAvsCent", defaultTimingHistogram); + histos.add("TimingZPCvsCent", "TimingZPCvsCent", defaultTimingHistogram); histos.add("ASide/CentvsZNSector0Signal", "CentvsZNASector0Signal", defaultZNSectorHist); histos.add("ASide/CentvsZNSector1Signal", "CentvsZNASector1Signal", defaultZNSectorHist); @@ -105,11 +141,96 @@ struct NeutronProtonCorrZdc { histos.add("CentvsZPSignalSum", "CentvsZPSignalSum", kTH2F, {cfgAxisCent, axisZPSignal}); histos.add("CentvsAlphaZN", "CentvsAlphaZN", kTH2F, {cfgAxisCent, axisAlphaZ}); histos.add("CentvsAlphaZP", "CentvsAlphaZP", kTH2F, {cfgAxisCent, axisAlphaZ}); + histos.add("CentvsAlphaZNcommon", "CentvsAlphaZNcommon", kTH2F, {cfgAxisCent, axisAlphaZ}); + histos.add("CentvsAlphaZPcommon", "CentvsAlphaZPcommon", kTH2F, {cfgAxisCent, axisAlphaZ}); histos.add("CentvsDiffZNSignal", "CentvsDiffZNSignal", defaultZDCDiffHist); histos.add("CentvsDiffZPSignal", "CentvsDiffZPSignal", defaultZDCDiffHist); + histos.add("CentvsZNAvsZNC", "CentvsZNAvsZNC", kTH3F, {cfgAxisCent, axisZNASignal, axisZNCSignal}); + histos.add("CentvsZNAvsZPA", "CentvsZNAvsZPA", kTH3F, {cfgAxisCent, axisZNASignal, axisZPASignal}); + histos.add("CentvsZNAvsZPC", "CentvsZNAvsZPC", kTH3F, {cfgAxisCent, axisZNASignal, axisZPCSignal}); + histos.add("CentvsZPAvsZNC", "CentvsZPAvsZNC", kTH3F, {cfgAxisCent, axisZPASignal, axisZNCSignal}); + histos.add("CentvsZPAvsZPC", "CentvsZNAvsZPC", kTH3F, {cfgAxisCent, axisZPASignal, axisZPCSignal}); + histos.add("CentvsZNCvsZPC", "CentvsZNCvsZPC", kTH3F, {cfgAxisCent, axisZNCSignal, axisZPCSignal}); + histos.add("CentvsZNvsZP", "CentvsZNvsZP", kTH3F, {cfgAxisCent, axisZNSignal, axisZPSignal}); + + if (cfgFillMultiplicityQAHistograms) { + histos.add("MultiplicityHistograms/FV0A", "FV0A", kTH1F, {axisMultiplicityF0A}); + histos.add("MultiplicityHistograms/FT0A", "FT0A", kTH1F, {axisMultiplicityF0A}); + histos.add("MultiplicityHistograms/FT0C", "FT0C", kTH1F, {axisMultiplicityF0C}); + histos.add("MultiplicityHistograms/FDDA", "FDDA", kTH1F, {axisMultiplicityFDD}); + histos.add("MultiplicityHistograms/FDDC", "FDDC", kTH1F, {axisMultiplicityFDD}); + histos.add("MultiplicityHistograms/TPC", "TPC", kTH1F, {axisMultiplicityTPC}); + histos.add("MultiplicityHistograms/NGlobal", "NGlobal", kTH1F, {axisMultiplicityMultNGlobal}); + histos.add("MultiplicityHistograms/CentvsFT0C", "CentvsFT0C", kTH2F, {cfgAxisCent, axisMultiplicityF0C}); + histos.add("MultiplicityHistograms/CentvsFT0CVar1", "CentvsFT0CVar1", kTH2F, {cfgAxisCent, axisMultiplicityF0C}); + histos.add("MultiplicityHistograms/CentvsFT0M", "CentvsFT0M", kTH2F, {cfgAxisCent, axisMultiplicityF0M}); + histos.add("MultiplicityHistograms/CentvsFV0A", "CentvsFV0A", kTH2F, {cfgAxisCent, axisMultiplicityF0A}); + histos.add("MultiplicityHistograms/CentvsNGlobal", "CentvsNGlobal", kTH2F, {cfgAxisCent, axisMultiplicityMultNGlobal}); + } + } + + template + bool eventSelected(TCollision coll, const float centrality) + { + if (!coll.sel8()) + return 0; + histos.fill(HIST("eventCounter"), kSel8); + + if (cfgNoSameBunchPileupCut) { + if (!coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return 0; + } + histos.fill(HIST("eventCounter"), EventCounter::kNoSameBunchPileUp); + } + + if (cfgIsGoodZvtxFT0vsPV) { + if (!coll.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return 0; + } + histos.fill(HIST("eventCounter"), EventCounter::kIsGoodZvtxFT0vsPV); + } + + if (cfgNoCollInTimeRangeStandard) { + if (!coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // Rejection of the collisions which have other events nearby + return 0; + } + histos.fill(HIST("eventCounter"), EventCounter::kNoCollInTimeRangeStandard); + } + + if (centrality > cfgMaxCentrality) { + return 0; + } + histos.fill(HIST("eventCounter"), EventCounter::kMaxCentralitySelection); + + return 1; } + + template + void fillMultHistosRun3(const C& col) + { + static constexpr std::string_view MultLabels[] = {"FT0C", "FT0A", "FV0A", "FDDC", "FDDA", "TPC", "NGlobal"}; + std::array multarray = {col.multFT0C(), col.multFT0A(), col.multFV0A(), col.multFDDC(), col.multFDDA(), static_cast(col.multTPC()), static_cast(col.multNTracksGlobal())}; + + histos.fill(HIST("MultiplicityHistograms/") + HIST(MultLabels[mult]), multarray[mult]); + } + + template + void fillCentHistosRun3(const C& col) + { + static constexpr std::string_view CentLabels[] = {"CentvsFT0C", "CentvsFT0CVar1", "CentvsFT0M", "CentvsFV0A", "CentvsNGlobal"}; + std::array centarray = {col.centFT0C(), col.centFT0CVariant1(), col.centFT0M(), col.centFV0A(), col.centNGlobal()}; + std::array multarray = {col.multFT0C(), col.multFT0C(), col.multFT0C() + col.multFT0A(), col.multFV0A(), static_cast(col.multNTracksGlobal())}; + + histos.fill(HIST("MultiplicityHistograms/") + HIST(CentLabels[cent]), centarray[cent], multarray[cent]); + } + template - void fillZDCHistos(const float centr, const Z& zdc) + void fillZDCSideCommonHistos(const float centr, const Z& zdc) { static constexpr std::string_view SubDir[] = {"ASide/", "CSide/"}; @@ -118,52 +239,90 @@ struct NeutronProtonCorrZdc { std::array znEnergyResponseCommon = {zdc.energyCommonZNA(), zdc.energyCommonZNC()}; std::array zpEnergyResponseCommon = {zdc.energyCommonZPA(), zdc.energyCommonZPC()}; - // Fill Neutron ZDC historgrams - histos.fill(HIST(SubDir[side]) + HIST("CentvsZNSector0Signal"), centr, znEnergyResponse[side][0]); - histos.fill(HIST(SubDir[side]) + HIST("CentvsZNSector1Signal"), centr, znEnergyResponse[side][1]); - histos.fill(HIST(SubDir[side]) + HIST("CentvsZNSector2Signal"), centr, znEnergyResponse[side][2]); - histos.fill(HIST(SubDir[side]) + HIST("CentvsZNSector3Signal"), centr, znEnergyResponse[side][3]); - float sumZN = znEnergyResponse[side][0] + znEnergyResponse[side][1] + znEnergyResponse[side][2] + znEnergyResponse[side][3]; + float sumZP = zpEnergyResponse[side][0] + zpEnergyResponse[side][1] + zpEnergyResponse[side][2] + zpEnergyResponse[side][3]; histos.fill(HIST(SubDir[side]) + HIST("CentvsZNSignalSum"), centr, sumZN); histos.fill(HIST(SubDir[side]) + HIST("CentvsZNSignalCommon"), centr, znEnergyResponseCommon[side]); histos.fill(HIST(SubDir[side]) + HIST("CentvsdiffZNSignal"), centr, sumZN - znEnergyResponseCommon[side]); - - // Fill Proton ZDC histograms - histos.fill(HIST(SubDir[side]) + HIST("CentvsZPSector0Signal"), centr, zpEnergyResponse[side][0]); - histos.fill(HIST(SubDir[side]) + HIST("CentvsZPSector1Signal"), centr, zpEnergyResponse[side][1]); - histos.fill(HIST(SubDir[side]) + HIST("CentvsZPSector2Signal"), centr, zpEnergyResponse[side][2]); - histos.fill(HIST(SubDir[side]) + HIST("CentvsZPSector3Signal"), centr, zpEnergyResponse[side][3]); - - float sumZP = zpEnergyResponse[side][0] + zpEnergyResponse[side][1] + zpEnergyResponse[side][2] + zpEnergyResponse[side][3]; - histos.fill(HIST(SubDir[side]) + HIST("CentvsZPSignalSum"), centr, sumZP); histos.fill(HIST(SubDir[side]) + HIST("CentvsZPSignalCommon"), centr, zpEnergyResponseCommon[side]); histos.fill(HIST(SubDir[side]) + HIST("CentvsdiffZPSignal"), centr, sumZP - zpEnergyResponseCommon[side]); } - void processRun3(soa::Filtered>::iterator const& collision, BCsRun3 const&, aod::Zdcs const&) + template + void fillZDCSideSectorHistos(const float centr, const Z& zdc) + { + static constexpr std::string_view SubDir[] = {"ASide/", "CSide/"}; + static constexpr std::string_view ZNSector[] = {"CentvsZNSector0Signal", "CentvsZNSector1Signal", "CentvsZNSector2Signal", "CentvsZNSector3Signal"}; + static constexpr std::string_view ZPSector[] = {"CentvsZPSector0Signal", "CentvsZPSector1Signal", "CentvsZPSector2Signal", "CentvsZPSector3Signal"}; + + std::array, 2> znEnergyResponse = {zdc.energySectorZNA(), zdc.energySectorZNC()}; + std::array, 2> zpEnergyResponse = {zdc.energySectorZPA(), zdc.energySectorZPC()}; + + histos.fill(HIST(SubDir[side]) + HIST(ZNSector[sector]), centr, znEnergyResponse[side][sector]); + histos.fill(HIST(SubDir[side]) + HIST(ZPSector[sector]), centr, zpEnergyResponse[side][sector]); + } + + void processRun3(soa::Filtered>::iterator const& collision, BCsRun3 const&, aod::Zdcs const&) { histos.fill(HIST("eventCounter"), EventCounter::kNoSelection); - if (!collision.sel8()) { - return; - } - histos.fill(HIST("eventCounter"), EventCounter::kQualitySelection); - if (collision.centFT0C() > cfgMaxCentrality) { + + const float centArray[] = {collision.centFT0C(), collision.centFT0CVariant1(), collision.centFT0M(), collision.centFV0A(), collision.centNGlobal()}; + const auto cent = centArray[cfgCentralityEstimator]; + + if (!eventSelected(collision, cent)) return; - } - histos.fill(HIST("eventCounter"), EventCounter::kMaxCentralitySelection); + const auto& foundBC = collision.foundBC_as(); if (foundBC.has_zdc()) { const auto& zdcread = foundBC.zdc(); - const auto cent = collision.centFT0C(); - histos.fill(HIST("eventCounter"), EventCounter::kZDCSelection); + + auto tZNA = zdcread.timeZNA(); + auto tZNC = zdcread.timeZNC(); + auto tZPA = zdcread.timeZPA(); + auto tZPC = zdcread.timeZPC(); + + histos.fill(HIST("TimingZNAvsCent"), cent, tZNA); + histos.fill(HIST("TimingZNCvsCent"), cent, tZNC); + histos.fill(HIST("TimingZPAvsCent"), cent, tZPA); + histos.fill(HIST("TimingZPCvsCent"), cent, tZPC); + + // Selection on timing for the ZDC + if (cfgZDCTimingInformationCut) { + if (tZNA <= cfgTDCZNmincut || tZNA >= cfgTDCZNmaxcut) { + return; + } + if (tZNC <= cfgTDCZNmincut || tZNC >= cfgTDCZNmaxcut) { + return; + } + if (tZPA <= cfgTDCZPmincut || tZPA >= cfgTDCZPmaxcut) { + return; + } + if (tZPC <= cfgTDCZPmincut || tZPC >= cfgTDCZPmaxcut) { + return; + } + } + histos.fill(HIST("eventCounter"), EventCounter::kTimeDifferenceZDC); histos.fill(HIST("CentralityPercentile"), cent); - fillZDCHistos<0>(cent, zdcread); // Fill A-side - fillZDCHistos<1>(cent, zdcread); // Fill C-side + if (cfgFillMultiplicityQAHistograms) { + static_for<0, 6>([&](auto i) { + fillMultHistosRun3(collision); // Fill multiplicity histograms + }); + + static_for<0, 4>([&](auto i) { + fillCentHistosRun3(collision); // Fill centrality vs multiplicity histograms + }); + } + + static_for<0, 1>([&](auto i) { + fillZDCSideCommonHistos(cent, zdcread); // Fill i-side common histograms + static_for<0, 3>([&](auto j) { + fillZDCSideSectorHistos(cent, zdcread); // Fill i-side sector j histograms + }); + }); float sumZNC = (zdcread.energySectorZNC())[0] + (zdcread.energySectorZNC())[1] + (zdcread.energySectorZNC())[2] + (zdcread.energySectorZNC())[3]; float sumZNA = (zdcread.energySectorZNA())[0] + (zdcread.energySectorZNA())[1] + (zdcread.energySectorZNA())[2] + (zdcread.energySectorZNA())[3]; @@ -181,6 +340,16 @@ struct NeutronProtonCorrZdc { histos.fill(HIST("CentvsZPSignalCommon"), cent, (zdcread.energyCommonZPA() + zdcread.energyCommonZPC())); histos.fill(HIST("CentvsAlphaZN"), cent, alphaZN); histos.fill(HIST("CentvsAlphaZP"), cent, alphaZP); + histos.fill(HIST("CentvsAlphaZNcommon"), cent, (zdcread.energyCommonZNA() - zdcread.energyCommonZNC()) / (zdcread.energyCommonZNA() + zdcread.energyCommonZNC())); + histos.fill(HIST("CentvsAlphaZPcommon"), cent, (zdcread.energyCommonZPA() - zdcread.energyCommonZPC()) / (zdcread.energyCommonZPA() + zdcread.energyCommonZPC())); + + histos.fill(HIST("CentvsZNAvsZNC"), cent, sumZNA, sumZNC); + histos.fill(HIST("CentvsZNAvsZPA"), cent, sumZNA, sumZPA); + histos.fill(HIST("CentvsZNAvsZPC"), cent, sumZNA, sumZPC); + histos.fill(HIST("CentvsZPAvsZNC"), cent, sumZPA, sumZNC); + histos.fill(HIST("CentvsZPAvsZPC"), cent, sumZPA, sumZPC); + histos.fill(HIST("CentvsZNCvsZPC"), cent, sumZNC, sumZPC); + histos.fill(HIST("CentvsZNvsZP"), cent, sumZNA + sumZNC, sumZPA + sumZPC); } } PROCESS_SWITCH(NeutronProtonCorrZdc, processRun3, "Process analysis for Run 3 data", true); @@ -191,7 +360,7 @@ struct NeutronProtonCorrZdc { if (!collision.alias_bit(kINT7)) { return; } - histos.fill(HIST("eventCounter"), EventCounter::kQualitySelection); + histos.fill(HIST("eventCounter"), EventCounter::kSel8); if (collision.centRun2V0M() > cfgMaxCentrality) { return; } @@ -204,8 +373,12 @@ struct NeutronProtonCorrZdc { histos.fill(HIST("eventCounter"), EventCounter::kZDCSelection); histos.fill(HIST("CentralityPercentile"), cent); - fillZDCHistos<0>(cent, zdcread); // Fill A-side - fillZDCHistos<1>(cent, zdcread); // Fill C-side + static_for<0, 1>([&](auto i) { + fillZDCSideCommonHistos(cent, zdcread); // Fill i-side common channels + static_for<0, 3>([&](auto j) { + fillZDCSideSectorHistos(cent, zdcread); // Fill i-side sector j + }); + }); float sumZNC = (zdcread.energySectorZNC())[0] + (zdcread.energySectorZNC())[1] + (zdcread.energySectorZNC())[2] + (zdcread.energySectorZNC())[3]; float sumZNA = (zdcread.energySectorZNA())[0] + (zdcread.energySectorZNA())[1] + (zdcread.energySectorZNA())[2] + (zdcread.energySectorZNA())[3]; @@ -223,6 +396,16 @@ struct NeutronProtonCorrZdc { histos.fill(HIST("CentvsZPSignalCommon"), cent, (zdcread.energyCommonZPA() + zdcread.energyCommonZPC())); histos.fill(HIST("CentvsAlphaZN"), cent, alphaZN); histos.fill(HIST("CentvsAlphaZP"), cent, alphaZP); + histos.fill(HIST("CentvsAlphaZNcommon"), cent, (zdcread.energyCommonZNA() - zdcread.energyCommonZNC()) / (zdcread.energyCommonZNA() + zdcread.energyCommonZNC())); + histos.fill(HIST("CentvsAlphaZPcommon"), cent, (zdcread.energyCommonZPA() - zdcread.energyCommonZPC()) / (zdcread.energyCommonZPA() + zdcread.energyCommonZPC())); + + histos.fill(HIST("CentvsZNAvsZNC"), cent, sumZNA, sumZNC); + histos.fill(HIST("CentvsZNAvsZPA"), cent, sumZNA, sumZPA); + histos.fill(HIST("CentvsZNAvsZPC"), cent, sumZNA, sumZPC); + histos.fill(HIST("CentvsZPAvsZNC"), cent, sumZPA, sumZNC); + histos.fill(HIST("CentvsZPAvsZPC"), cent, sumZPA, sumZPC); + histos.fill(HIST("CentvsZNCvsZPC"), cent, sumZNC, sumZPC); + histos.fill(HIST("CentvsZNvsZP"), cent, sumZNA + sumZNC, sumZPA + sumZPC); } } PROCESS_SWITCH(NeutronProtonCorrZdc, processRun2, "Process analysis for Run 2 converted data", false); diff --git a/PWGCF/TwoParticleCorrelations/Tasks/perRunQc.cxx b/PWGCF/TwoParticleCorrelations/Tasks/perRunQc.cxx deleted file mode 100644 index 0faa24ab951..00000000000 --- a/PWGCF/TwoParticleCorrelations/Tasks/perRunQc.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// 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. -// -// Minimal example to run this task: -// o2-analysis-centrality-table -b --configuration json://configuration.json | o2-analysis-timestamp -b --configuration json://configuration.json | o2-analysis-event-selection -b --configuration json://configuration.json | o2-analysis-multiplicity-table -b --configuration json://configuration.json | o2-analysis-lf-zdcsp -b --configuration json://configuration.json --aod-file @input_data.txt --aod-writer-json OutputDirector.json - -#include -#include - -#include "CCDB/BasicCCDBManager.h" -#include "Common/CCDB/ctpRateFetcher.h" - -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "PWGCF/DataModel/DptDptFiltered.h" -#include "PWGCF/TableProducer/dptdptfilter.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -using BCsWithTimestamps = soa::Join; - -namespace perrunqatask -{ -std::unordered_map gHadronicRate; - -TH2* gCurrentHadronicRate; -} // namespace perrunqatask - -struct DptDptPerRunQa { - - Service ccdb; - - int mRunNumber{-1}; - uint64_t mSOR{0}; - double mMinSeconds{-1.}; - - ctpRateFetcher mRateFetcher; - HistogramRegistry mHistos{"PerRunQaHistograms", {}, OutputObjHandlingPolicy::AnalysisObject}; - - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) - { - using namespace perrunqatask; - using namespace analysis::dptdptfilter; - - if (mRunNumber == bc.runNumber()) { - return; - } - mRunNumber = bc.runNumber(); - if (gHadronicRate.find(mRunNumber) == gHadronicRate.end()) { - auto runDuration = ccdb->getRunDuration(mRunNumber); - mSOR = runDuration.first; - mMinSeconds = std::floor(mSOR * 1.e-3); /// round tsSOR to the highest integer lower than tsSOR - double maxSec = std::ceil(runDuration.second * 1.e-3); /// round tsEOR to the lowest integer higher than tsEOR - const AxisSpec axisSeconds{static_cast(maxSec - mMinSeconds), 0, maxSec - mMinSeconds, "Seconds since SOR"}; - gHadronicRate[mRunNumber] = mHistos.add(Form("%i/hadronicRate", mRunNumber), ";Time since SOR (s);Hadronic rate (kHz)", kTH2D, {{static_cast((maxSec - mMinSeconds) / 20.f), 0, maxSec - mMinSeconds, "Seconds since SOR"}, {1010, 0., 1010.}}).get(); - } - gCurrentHadronicRate = gHadronicRate[mRunNumber]; - } - - void init(o2::framework::InitContext&) - { - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setFatalWhenNull(false); - } - - void process(soa::Join::iterator const& collision, aod::BCsWithTimestamps const&) - { - using namespace perrunqatask; - using namespace analysis::dptdptfilter; - - if (!collision.collisionaccepted()) { - return; - } - - auto bc = collision.bc_as(); - initCCDB(bc); - double hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, "T0VTX") * 1.e-3; // - double seconds = bc.timestamp() * 1.e-3 - mMinSeconds; - gCurrentHadronicRate->Fill(seconds, hadronicRate); - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx b/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx new file mode 100644 index 00000000000..b5190b2927c --- /dev/null +++ b/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx @@ -0,0 +1,717 @@ +// 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. + +/// \file pidDiHadron.cxx +/// \brief di-hadron correlation of PID for O-O, Pb-Pb collisions +/// \author Preet Bhanjan Pati (preet.bhanjan.pati@cern.ch), Zhiyong Lu (zhiyong.lu@cern.ch) +/// \since July/29/2025 + +#include "PWGCF/Core/CorrelationContainer.h" +#include "PWGCF/Core/PairCuts.h" +#include "PWGCF/DataModel/CorrelationsDerived.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/MathConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/PID.h" +#include "ReconstructionDataFormats/Track.h" +#include + +#include "TF1.h" +#include "TRandom3.h" +#include + +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// define the filtered collisions and tracks +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +struct PidDiHadron { + Service ccdb; + + O2_DEFINE_CONFIGURABLE(cfgCutVtxZ, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "minimum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 10.0f, "maximum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta cut") + O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5f, "max chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 50.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCCrossedRows, float, 70.0f, "minimum TPC crossed rows") + O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters") + O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "max DCA to vertex z") + O2_DEFINE_CONFIGURABLE(cfgCutMerging, float, 0.0, "Merging cut on track merge") + O2_DEFINE_CONFIGURABLE(cfgSelCollByNch, bool, true, "Select collisions by Nch or centrality") + O2_DEFINE_CONFIGURABLE(cfgCutMultMin, int, 0, "Minimum multiplicity for collision") + O2_DEFINE_CONFIGURABLE(cfgCutMultMax, int, 10, "Maximum multiplicity for collision") + O2_DEFINE_CONFIGURABLE(cfgCutCentMin, float, 60.0f, "Minimum centrality for collision") + O2_DEFINE_CONFIGURABLE(cfgCutCentMax, float, 80.0f, "Maximum centrality for collision") + O2_DEFINE_CONFIGURABLE(cfgMixEventNumMin, int, 5, "Minimum number of events to mix") + O2_DEFINE_CONFIGURABLE(cfgRadiusLow, float, 0.8, "Low radius for merging cut") + O2_DEFINE_CONFIGURABLE(cfgRadiusHigh, float, 2.5, "High radius for merging cut") + O2_DEFINE_CONFIGURABLE(cfgSampleSize, double, 10, "Sample size for mixed event") + O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FT0A") + O2_DEFINE_CONFIGURABLE(cfgCentTableUnavailable, bool, false, "if a dataset does not provide centrality information") + O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoSameBunchPileup, bool, false, "rejects collisions which are associated with the same found-by-T0 bunch crossing") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoITSROFrameBorder, bool, false, "reject events at ITS ROF border") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoTimeFrameBorder, bool, false, "reject events at TF border") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodZvtxFT0vsPV, bool, false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference, use this cut at low multiplicities with caution") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInTimeRangeStandard, bool, false, "no collisions in specified time range") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodITSLayersAll, bool, true, "cut time intervals with dead ITS staves") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInRofStandard, bool, false, "no other collisions in this Readout Frame with per-collision multiplicity above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoHighMultCollInPrevRof, bool, false, "veto an event if FT0C amplitude in previous ITS ROF is above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelMultCorrelation, bool, true, "Multiplicity correlation cut") + O2_DEFINE_CONFIGURABLE(cfgEvSelV0AT0ACut, bool, true, "V0A T0A 5 sigma cut") + O2_DEFINE_CONFIGURABLE(cfgEvSelOccupancy, bool, true, "Occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 2000, "High cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgLocalEfficiency, bool, false, "Use local efficiency object") + O2_DEFINE_CONFIGURABLE(cfgVerbosity, bool, false, "Verbose output") + O2_DEFINE_CONFIGURABLE(cfgUseEventWeights, bool, false, "Use event weights for mixed event") + O2_DEFINE_CONFIGURABLE(cfgUsePtOrder, bool, false, "enable trigger pT < associated pT cut") + O2_DEFINE_CONFIGURABLE(cfgUsePtOrderInMixEvent, bool, false, "enable trigger pT < associated pT cut in mixed event") + O2_DEFINE_CONFIGURABLE(cfgPIDUseITSPID, bool, true, "Use ITS PID for particle identification") + O2_DEFINE_CONFIGURABLE(cfgPIDTofPtCut, float, 0.5f, "Minimum pt to use TOF N-sigma") + O2_DEFINE_CONFIGURABLE(cfgPIDParticle, int, 0, "1 = pion, 2 = kaon, 3 = proton, 0 for no PID") + + SliceCache cache; + + ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for histograms"}; + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 10, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260}, "multiplicity axis for histograms"}; + ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, "centrality axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt axis for histograms"}; + ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"}; + ConfigurableAxis axisDeltaEta{"axisDeltaEta", {48, -2.4, 2.4}, "delta eta axis for histograms"}; + ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt trigger axis for histograms"}; + ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt associated axis for histograms"}; + ConfigurableAxis axisVtxMix{"axisVtxMix", {VARIABLE_WIDTH, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, "vertex axis for mixed event histograms"}; + ConfigurableAxis axisMultMix{"axisMultMix", {VARIABLE_WIDTH, 0, 10, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260}, "multiplicity / centrality axis for mixed event histograms"}; + ConfigurableAxis axisSample{"axisSample", {cfgSampleSize, 0, cfgSampleSize}, "sample axis for histograms"}; + Configurable> pidTofNsigmaCut{"pidTofNsigmaCut", std::vector{1.5, 1.5, 1.5, -1.5, -1.5, -1.5}, "TOF n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"}; + Configurable> pidItsNsigmaCut{"pidItsNsigmaCut", std::vector{3, 3, 3, -3, -3, -3}, "ITS n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"}; + Configurable> pidTpcNsigmaCut{"pidTpcNsigmaCut", std::vector{10, 10, 10, -10, -10, -10}, "TOF n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"}; + + ConfigurableAxis axisVertexEfficiency{"axisVertexEfficiency", {10, -10, 10}, "vertex axis for efficiency histograms"}; + ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"}; + ConfigurableAxis axisPtEfficiency{"axisPtEfficiency", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt axis for efficiency histograms"}; + + // make the filters and cuts. + Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVtxZ); + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + using FilteredCollisions = soa::Filtered>; + using FilteredTracks = soa::Filtered>; + + Preslice perCollision = aod::track::collisionId; + + // Corrections + TH3D* mEfficiency = nullptr; + bool correctionsLoaded = false; + + // Define the outputs + OutputObj same{"sameEvent"}; + OutputObj mixed{"mixedEvent"}; + HistogramRegistry registry{"registry"}; + + // define global variables + TRandom3* gRandom = new TRandom3(); + enum CentEstimators { + kCentFT0C = 0, + kCentFT0CVariant1, + kCentFT0M, + kCentFV0A, + // Count the total number of enum + kCount_CentEstimators + }; + enum EventType { + SameEvent = 1, + MixedEvent = 3 + }; + std::vector tofNsigmaCut; + std::vector itsNsigmaCut; + std::vector tpcNsigmaCut; + o2::aod::ITSResponse itsResponse; + enum Particles { + PIONS, + KAONS, + PROTONS + }; + + // persistent caches + std::vector efficiencyAssociatedCache; + + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fMultMultPVCut = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + + void init(InitContext&) + { + if (cfgCentTableUnavailable && !cfgSelCollByNch) { + LOGF(fatal, "Centrality table is unavailable, cannot select collisions by centrality"); + } + const AxisSpec axisPhi{72, 0.0, constants::math::TwoPI, "#varphi"}; + const AxisSpec axisEta{40, -1., 1., "#eta"}; + + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + auto now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); + + LOGF(info, "Starting init"); + + // Event Counter + if (doprocessSame && cfgUseAdditionalEventCut) { + registry.add("hEventCountSpecific", "Number of Event;; Count", {HistType::kTH1D, {{12, 0, 12}}}); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(1, "after sel8"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(2, "kNoSameBunchPileup"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(3, "kNoITSROFrameBorder"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(4, "kNoTimeFrameBorder"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(5, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(6, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(7, "kIsGoodITSLayersAll"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(8, "kNoCollInRofStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(9, "kNoHighMultCollInPrevRof"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(10, "occupancy"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(11, "MultCorrelation"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(12, "cfgEvSelV0AT0ACut"); + } + + if (cfgUseAdditionalEventCut) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + + fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + + fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } + + std::string hCentTitle = "Centrality distribution, Estimator " + std::to_string(cfgCentEstimator); + // Make histograms to check the distributions after cuts + if (doprocessSame) { + registry.add("deltaEta_deltaPhi_same", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); // check to see the delta eta and delta phi distribution + registry.add("deltaEta_deltaPhi_mixed", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); + registry.add("Phi", "Phi", {HistType::kTH1D, {axisPhi}}); + registry.add("Eta", "Eta", {HistType::kTH1D, {axisEta}}); + registry.add("EtaCorrected", "EtaCorrected", {HistType::kTH1D, {axisEta}}); + registry.add("pT", "pT", {HistType::kTH1D, {axisPtTrigger}}); + registry.add("pTCorrected", "pTCorrected", {HistType::kTH1D, {axisPtTrigger}}); + registry.add("Nch", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}}); + registry.add("Nch_used", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}}); // histogram to see how many events are in the same and mixed event + registry.add("Centrality", hCentTitle.c_str(), {HistType::kTH1D, {axisCentrality}}); + registry.add("Centrality_used", hCentTitle.c_str(), {HistType::kTH1D, {axisCentrality}}); // histogram to see how many events are in the same and mixed event + registry.add("zVtx", "zVtx", {HistType::kTH1D, {axisVertex}}); + registry.add("zVtx_used", "zVtx_used", {HistType::kTH1D, {axisVertex}}); + registry.add("Trig_hist", "", {HistType::kTHnSparseF, {{axisSample, axisVertex, axisPtTrigger}}}); + } + + registry.add("eventcount", "bin", {HistType::kTH1F, {{4, 0, 4, "bin"}}}); // histogram to see how many events are in the same and mixed event + + LOGF(info, "Initializing correlation container"); + std::vector corrAxis = {{axisSample, "Sample"}, + {axisVertex, "z-vtx (cm)"}, + {axisPtTrigger, "p_{T} (GeV/c)"}, + {axisPtAssoc, "p_{T} (GeV/c)"}, + {axisDeltaPhi, "#Delta#varphi (rad)"}, + {axisDeltaEta, "#Delta#eta"}}; + std::vector effAxis = { + {axisEtaEfficiency, "#eta"}, + {axisPtEfficiency, "p_{T} (GeV/c)"}, + {axisVertexEfficiency, "z-vtx (cm)"}, + }; + std::vector userAxis; + + same.setObject(new CorrelationContainer("sameEvent", "sameEvent", corrAxis, effAxis, userAxis)); + mixed.setObject(new CorrelationContainer("mixedEvent", "mixedEvent", corrAxis, effAxis, userAxis)); + + tofNsigmaCut = pidTofNsigmaCut; + itsNsigmaCut = pidItsNsigmaCut; + tpcNsigmaCut = pidTpcNsigmaCut; + + LOGF(info, "End of init"); + } + + int getMagneticField(uint64_t timestamp) + { + // Get the magnetic field + static o2::parameters::GRPMagField* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp("/GLO/Config/GRPMagField", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + } + return grpo->getNominalL3Field(); + } + + template + float getCentrality(TCollision const& collision) + { + float cent; + switch (cfgCentEstimator) { + case kCentFT0C: + cent = collision.centFT0C(); + break; + case kCentFT0CVariant1: + cent = collision.centFT0CVariant1(); + break; + case kCentFT0M: + cent = collision.centFT0M(); + break; + case kCentFV0A: + cent = collision.centFV0A(); + break; + default: + cent = collision.centFT0C(); + } + return cent; + } + + template + bool trackSelected(TTrack track) + { + if (cfgPIDParticle && getNsigmaPID(track) != cfgPIDParticle) { + return false; + } + return ((track.tpcNClsFound() >= cfgCutTPCclu) && (track.tpcNClsCrossedRows() >= cfgCutTPCCrossedRows) && (track.itsNCls() >= cfgCutITSclu)); + } + + void loadEfficiency(uint64_t timestamp) + { + if (correctionsLoaded) { + return; + } + if (cfgEfficiency.value.empty() == false) { + if (cfgLocalEfficiency > 0) { + TFile* fEfficiencyTrigger = TFile::Open(cfgEfficiency.value.c_str(), "READ"); + mEfficiency = reinterpret_cast(fEfficiencyTrigger->Get("ccdb_object")); + } else { + mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); + } + if (mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency); + } + correctionsLoaded = true; + } + + bool getEfficiencyCorrection(float& weight_nue, float eta, float pt, float posZ) + { + float eff = 1.; + if (mEfficiency) { + int etaBin = mEfficiency->GetXaxis()->FindBin(eta); + int ptBin = mEfficiency->GetYaxis()->FindBin(pt); + int zBin = mEfficiency->GetZaxis()->FindBin(posZ); + eff = mEfficiency->GetBinContent(etaBin, ptBin, zBin); + } else { + eff = 1.0; + } + if (eff == 0) + return false; + weight_nue = 1. / eff; + return true; + } + + // fill multiple histograms + template + void fillYield(TCollision collision, TTracks tracks) // function to fill the yield and etaphi histograms. + { + float weff1 = 1; + float vtxz = collision.posZ(); + for (auto const& track1 : tracks) { + if (!trackSelected(track1)) + continue; + if (!getEfficiencyCorrection(weff1, track1.eta(), track1.pt(), vtxz)) + continue; + registry.fill(HIST("Phi"), RecoDecay::constrainAngle(track1.phi(), 0.0)); + registry.fill(HIST("Eta"), track1.eta()); + registry.fill(HIST("EtaCorrected"), track1.eta(), weff1); + registry.fill(HIST("pT"), track1.pt()); + registry.fill(HIST("pTCorrected"), track1.pt(), weff1); + } + } + + template + float getDPhiStar(TTrack const& track1, TTrackAssoc const& track2, float radius, int magField) + { + float charge1 = track1.sign(); + float charge2 = track2.sign(); + + float phi1 = track1.phi(); + float phi2 = track2.phi(); + + float pt1 = track1.pt(); + float pt2 = track2.pt(); + + int fbSign = (magField > 0) ? 1 : -1; + + float dPhiStar = phi1 - phi2 - charge1 * fbSign * std::asin(0.075 * radius / pt1) + charge2 * fbSign * std::asin(0.075 * radius / pt2); + + if (dPhiStar > constants::math::PI) + dPhiStar = constants::math::TwoPI - dPhiStar; + if (dPhiStar < -constants::math::PI) + dPhiStar = -constants::math::TwoPI - dPhiStar; + + return dPhiStar; + } + + template + void fillCorrelations(TTracks tracks1, TTracksAssoc tracks2, float posZ, int system, int magneticField, float cent, float eventWeight) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms + { + // Cache efficiency for particles (too many FindBin lookups) + if (mEfficiency) { + efficiencyAssociatedCache.clear(); + efficiencyAssociatedCache.reserve(tracks2.size()); + for (const auto& track2 : tracks2) { + float weff = 1.; + getEfficiencyCorrection(weff, track2.eta(), track2.pt(), posZ); + efficiencyAssociatedCache.push_back(weff); + } + } + + if (system == SameEvent) { + if (!cfgCentTableUnavailable) + registry.fill(HIST("Centrality_used"), cent); + registry.fill(HIST("Nch_used"), tracks1.size()); + } + + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + + float triggerWeight = 1.0f; + float associatedWeight = 1.0f; + // loop over all tracks + for (auto const& track1 : tracks1) { + + if (!trackSelected(track1)) + continue; + if (!getEfficiencyCorrection(triggerWeight, track1.eta(), track1.pt(), posZ)) + continue; + if (system == SameEvent) { + registry.fill(HIST("Trig_hist"), fSampleIndex, posZ, track1.pt(), eventWeight * triggerWeight); + } + + for (auto const& track2 : tracks2) { + + if (!trackSelected(track2)) + continue; + if (mEfficiency) { + associatedWeight = efficiencyAssociatedCache[track2.filteredIndex()]; + } + + if (!cfgUsePtOrder && track1.globalIndex() == track2.globalIndex()) + continue; // For pt-differential correlations, skip if the trigger and associate are the same track + if (cfgUsePtOrder && system == SameEvent && track1.pt() <= track2.pt()) + continue; // Without pt-differential correlations, skip if the trigger pt is less than the associate pt + if (cfgUsePtOrder && system == MixedEvent && cfgUsePtOrderInMixEvent && track1.pt() <= track2.pt()) + continue; // For pt-differential correlations in mixed events, skip if the trigger pt is less than the associate pt + + float deltaPhi = RecoDecay::constrainAngle(track1.phi() - track2.phi(), -PIHalf); + float deltaEta = track1.eta() - track2.eta(); + + if (std::abs(deltaEta) < cfgCutMerging) { + + double dPhiStarHigh = getDPhiStar(track1, track2, cfgRadiusHigh, magneticField); + double dPhiStarLow = getDPhiStar(track1, track2, cfgRadiusLow, magneticField); + + const double kLimit = 3.0 * cfgCutMerging; + + bool bIsBelow = false; + + if (std::abs(dPhiStarLow) < kLimit || std::abs(dPhiStarHigh) < kLimit || dPhiStarLow * dPhiStarHigh < 0) { + for (double rad(cfgRadiusLow); rad < cfgRadiusHigh; rad += 0.01) { + double dPhiStar = getDPhiStar(track1, track2, rad, magneticField); + if (std::abs(dPhiStar) < kLimit) { + bIsBelow = true; + break; + } + } + if (bIsBelow) + continue; + } + } + + // fill the right sparse and histograms + if (system == SameEvent) { + + same->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + registry.fill(HIST("deltaEta_deltaPhi_same"), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + } else if (system == MixedEvent) { + + mixed->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + registry.fill(HIST("deltaEta_deltaPhi_mixed"), deltaPhi, deltaEta, eventWeight * triggerWeight * associatedWeight); + } + } + } + } + + template + bool eventSelected(TCollision collision, const int multTrk, const float centrality, const bool fillCounter) + { + registry.fill(HIST("hEventCountSpecific"), 0.5); + if (cfgEvSelkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return 0; + } + if (fillCounter && cfgEvSelkNoSameBunchPileup) + registry.fill(HIST("hEventCountSpecific"), 1.5); + if (cfgEvSelkNoITSROFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return 0; + } + if (fillCounter && cfgEvSelkNoITSROFrameBorder) + registry.fill(HIST("hEventCountSpecific"), 2.5); + if (cfgEvSelkNoTimeFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return 0; + } + if (fillCounter && cfgEvSelkNoTimeFrameBorder) + registry.fill(HIST("hEventCountSpecific"), 3.5); + if (cfgEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return 0; + } + if (fillCounter && cfgEvSelkIsGoodZvtxFT0vsPV) + registry.fill(HIST("hEventCountSpecific"), 4.5); + if (cfgEvSelkNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // no collisions in specified time range + return 0; + } + if (fillCounter && cfgEvSelkNoCollInTimeRangeStandard) + registry.fill(HIST("hEventCountSpecific"), 5.5); + if (cfgEvSelkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // from Jan 9 2025 AOT meeting + // cut time intervals with dead ITS staves + return 0; + } + if (fillCounter && cfgEvSelkIsGoodITSLayersAll) + registry.fill(HIST("hEventCountSpecific"), 6.5); + if (cfgEvSelkNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + // no other collisions in this Readout Frame with per-collision multiplicity above threshold + return 0; + } + if (fillCounter && cfgEvSelkNoCollInRofStandard) + registry.fill(HIST("hEventCountSpecific"), 7.5); + if (cfgEvSelkNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + // veto an event if FT0C amplitude in previous ITS ROF is above threshold + return 0; + } + if (fillCounter && cfgEvSelkNoHighMultCollInPrevRof) + registry.fill(HIST("hEventCountSpecific"), 8.5); + auto occupancy = collision.trackOccupancyInTimeRange(); + if (cfgEvSelOccupancy && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) + return 0; + if (fillCounter && cfgEvSelOccupancy) + registry.fill(HIST("hEventCountSpecific"), 9.5); + + auto multNTracksPV = collision.multNTracksPV(); + if (cfgEvSelMultCorrelation) { + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return 0; + if (multTrk < fMultCutLow->Eval(centrality)) + return 0; + if (multTrk > fMultCutHigh->Eval(centrality)) + return 0; + } + if (fillCounter && cfgEvSelMultCorrelation) + registry.fill(HIST("hEventCountSpecific"), 10.5); + + // V0A T0A 5 sigma cut + float sigma = 5.0; + if (cfgEvSelV0AT0ACut && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > sigma * fT0AV0ASigma->Eval(collision.multFT0A()))) + return 0; + if (fillCounter && cfgEvSelV0AT0ACut) + registry.fill(HIST("hEventCountSpecific"), 11.5); + + return 1; + } + + void processSame(FilteredCollisions::iterator const& collision, FilteredTracks const& tracks, aod::BCsWithTimestamps const&) + { + if (!collision.sel8()) + return; + auto bc = collision.bc_as(); + float cent = -1.; + if (!cfgCentTableUnavailable) + cent = getCentrality(collision); + if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), cent, true)) + return; + + if (!cfgCentTableUnavailable) + registry.fill(HIST("Centrality"), cent); + registry.fill(HIST("Nch"), tracks.size()); + registry.fill(HIST("zVtx"), collision.posZ()); + + if (cfgSelCollByNch && (tracks.size() < cfgCutMultMin || tracks.size() >= cfgCutMultMax)) { + return; + } + if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent < cfgCutCentMin || cent >= cfgCutCentMax)) { + return; + } + + loadEfficiency(bc.timestamp()); + registry.fill(HIST("eventcount"), SameEvent); // because its same event i put it in the 1 bin + fillYield(collision, tracks); + + same->fillEvent(tracks.size(), CorrelationContainer::kCFStepReconstructed); + fillCorrelations(tracks, tracks, collision.posZ(), SameEvent, getMagneticField(bc.timestamp()), cent, 1.0f); + } + PROCESS_SWITCH(PidDiHadron, processSame, "Process same event", true); + + // the process for filling the mixed events + void processMixed(FilteredCollisions const& collisions, FilteredTracks const& tracks, aod::BCsWithTimestamps const&) + { + + auto getTracksSize = [&tracks, this](FilteredCollisions::iterator const& collision) { + auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), this->cache); + auto mult = associatedTracks.size(); + return mult; + }; + + using MixedBinning = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getTracksSize)>; + + MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxMix, axisMultMix}, true}; + + auto tracksTuple = std::make_tuple(tracks, tracks); + Pair pairs{binningOnVtxAndMult, cfgMixEventNumMin, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + for (auto it = pairs.begin(); it != pairs.end(); it++) { + auto& [collision1, tracks1, collision2, tracks2] = *it; + if (!collision1.sel8() || !collision2.sel8()) + continue; + + if (cfgSelCollByNch && (tracks1.size() < cfgCutMultMin || tracks1.size() >= cfgCutMultMax)) + continue; + + if (cfgSelCollByNch && (tracks2.size() < cfgCutMultMin || tracks2.size() >= cfgCutMultMax)) + continue; + + float cent1 = -1; + float cent2 = -1; + if (!cfgCentTableUnavailable) { + cent1 = getCentrality(collision1); + cent2 = getCentrality(collision2); + } + if (cfgUseAdditionalEventCut && !eventSelected(collision1, tracks1.size(), cent1, false)) + continue; + if (cfgUseAdditionalEventCut && !eventSelected(collision2, tracks2.size(), cent2, false)) + continue; + + if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent1 < cfgCutCentMin || cent1 >= cfgCutCentMax)) + continue; + + if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent2 < cfgCutCentMin || cent2 >= cfgCutCentMax)) + continue; + + registry.fill(HIST("eventcount"), MixedEvent); // fill the mixed event in the 3 bin + auto bc = collision1.bc_as(); + loadEfficiency(bc.timestamp()); + float eventWeight = 1.0f; + if (cfgUseEventWeights) { + eventWeight = 1.0f / it.currentWindowNeighbours(); + } + + fillCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent, getMagneticField(bc.timestamp()), cent1, eventWeight); + } + } + PROCESS_SWITCH(PidDiHadron, processMixed, "Process mixed events", true); + + template + int getNsigmaPID(TTrack track) + { + // Computing Nsigma arrays for pion, kaon, and protons + std::array nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; + std::array nSigmaTOF = {track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()}; + std::array nSigmaITS = {itsResponse.nSigmaITS(track), itsResponse.nSigmaITS(track), itsResponse.nSigmaITS(track)}; + int pid = -1; + + std::array nSigmaToUse = cfgPIDUseITSPID ? nSigmaITS : nSigmaTPC; // Choose which nSigma to use: TPC or ITS + std::vector detectorNsigmaCut = cfgPIDUseITSPID ? itsNsigmaCut : tpcNsigmaCut; // Choose which nSigma to use: TPC or ITS + + bool isPion, isKaon, isProton; + bool isDetectedPion = nSigmaToUse[0] < detectorNsigmaCut[0] && nSigmaToUse[0] > detectorNsigmaCut[0 + 3]; + bool isDetectedKaon = nSigmaToUse[1] < detectorNsigmaCut[1] && nSigmaToUse[1] > detectorNsigmaCut[1 + 3]; + bool isDetectedProton = nSigmaToUse[2] < detectorNsigmaCut[2] && nSigmaToUse[2] > detectorNsigmaCut[2 + 3]; + + bool isTofPion = nSigmaTOF[0] < tofNsigmaCut[0] && nSigmaTOF[0] > tofNsigmaCut[0 + 3]; + bool isTofKaon = nSigmaTOF[1] < tofNsigmaCut[1] && nSigmaTOF[1] > tofNsigmaCut[1 + 3]; + bool isTofProton = nSigmaTOF[2] < tofNsigmaCut[2] && nSigmaTOF[2] > tofNsigmaCut[2 + 3]; + + if (track.pt() > cfgPIDTofPtCut && !track.hasTOF()) { + return 0; + } else if (track.pt() > cfgPIDTofPtCut && track.hasTOF()) { + isPion = isTofPion && isDetectedPion; + isKaon = isTofKaon && isDetectedKaon; + isProton = isTofProton && isDetectedProton; + } else { + isPion = isDetectedPion; + isKaon = isDetectedKaon; + isProton = isDetectedProton; + } + + if ((isPion && isKaon) || (isPion && isProton) || (isKaon && isProton)) { + return 0; // more than one particle satisfy the criteria + } + + if (isPion) { + pid = PIONS; + } else if (isKaon) { + pid = KAONS; + } else if (isProton) { + pid = PROTONS; + } else { + return 0; // no particle satisfies the criteria + } + + return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGDQ/Core/AnalysisCompositeCut.cxx b/PWGDQ/Core/AnalysisCompositeCut.cxx index cb14bd7afad..5ab08001953 100644 --- a/PWGDQ/Core/AnalysisCompositeCut.cxx +++ b/PWGDQ/Core/AnalysisCompositeCut.cxx @@ -35,6 +35,34 @@ AnalysisCompositeCut::AnalysisCompositeCut(const char* name, const char* title, // } +//____________________________________________________________________________ +AnalysisCompositeCut::AnalysisCompositeCut(const AnalysisCompositeCut& c) : AnalysisCut(c) +{ + // + // copy constructor + // + if (this != &c) { + fOptionUseAND = c.fOptionUseAND; + fCutList = c.fCutList; + fCompositeCutList = c.fCompositeCutList; + } +} + +//____________________________________________________________________________ +AnalysisCompositeCut& AnalysisCompositeCut::operator=(const AnalysisCompositeCut& c) +{ + // + // assignment + // + if (this != &c) { + AnalysisCut::operator=(c); + fOptionUseAND = c.fOptionUseAND; + fCutList = c.fCutList; + fCompositeCutList = c.fCompositeCutList; + } + return (*this); +} + //____________________________________________________________________________ AnalysisCompositeCut::~AnalysisCompositeCut() = default; diff --git a/PWGDQ/Core/AnalysisCompositeCut.h b/PWGDQ/Core/AnalysisCompositeCut.h index f9b00a9ed2e..f3d603909c4 100644 --- a/PWGDQ/Core/AnalysisCompositeCut.h +++ b/PWGDQ/Core/AnalysisCompositeCut.h @@ -26,8 +26,8 @@ class AnalysisCompositeCut : public AnalysisCut public: AnalysisCompositeCut(bool useAND = kTRUE); AnalysisCompositeCut(const char* name, const char* title, bool useAND = kTRUE); - AnalysisCompositeCut(const AnalysisCompositeCut& c) = default; - AnalysisCompositeCut& operator=(const AnalysisCompositeCut& c) = default; + AnalysisCompositeCut(const AnalysisCompositeCut& c); + AnalysisCompositeCut& operator=(const AnalysisCompositeCut& c); ~AnalysisCompositeCut() override; void AddCut(AnalysisCut* cut) diff --git a/PWGDQ/Core/AnalysisCut.cxx b/PWGDQ/Core/AnalysisCut.cxx index f61e38db131..7b5718552ba 100644 --- a/PWGDQ/Core/AnalysisCut.cxx +++ b/PWGDQ/Core/AnalysisCut.cxx @@ -11,6 +11,10 @@ #include "PWGDQ/Core/AnalysisCut.h" +#include +using std::cout; +using std::endl; + ClassImp(AnalysisCut); std::vector AnalysisCut::fgUsedVars = {}; @@ -37,5 +41,22 @@ AnalysisCut& AnalysisCut::operator=(const AnalysisCut& c) return (*this); } +//____________________________________________________________________________ +AnalysisCut::AnalysisCut(const AnalysisCut& c) : TNamed(c) +{ + // + // copy constructor + // + if (this != &c) { + fCuts = c.fCuts; + } +} + //____________________________________________________________________________ AnalysisCut::~AnalysisCut() = default; + +//____________________________________________________________________________ +void AnalysisCut::PrintCuts() +{ + cout << "**************** AnalysisCut::PrintCuts" << endl; +} diff --git a/PWGDQ/Core/AnalysisCut.h b/PWGDQ/Core/AnalysisCut.h index a1a7dfe7461..6c7185b13ec 100644 --- a/PWGDQ/Core/AnalysisCut.h +++ b/PWGDQ/Core/AnalysisCut.h @@ -26,7 +26,7 @@ class AnalysisCut : public TNamed public: AnalysisCut() = default; AnalysisCut(const char* name, const char* title); - AnalysisCut(const AnalysisCut& c) = default; + AnalysisCut(const AnalysisCut& c); AnalysisCut& operator=(const AnalysisCut& c); ~AnalysisCut() override; @@ -42,6 +42,8 @@ class AnalysisCut : public TNamed static std::vector fgUsedVars; //! vector of used variables + void PrintCuts(); + struct CutContainer { short fVar; // variable to be cut upon float fLow; // lower limit for the var diff --git a/PWGDQ/Core/CMakeLists.txt b/PWGDQ/Core/CMakeLists.txt index 5ce05ab82d1..d19a66a68e6 100644 --- a/PWGDQ/Core/CMakeLists.txt +++ b/PWGDQ/Core/CMakeLists.txt @@ -21,7 +21,7 @@ o2physics_add_library(PWGDQCore AnalysisCompositeCut.cxx MCProng.cxx MCSignal.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DCAFitter O2::GlobalTracking O2Physics::AnalysisCore KFParticle::KFParticle) + PUBLIC_LINK_LIBRARIES O2::Framework O2::DCAFitter O2::GlobalTracking O2Physics::AnalysisCore KFParticle::KFParticle) o2physics_target_root_dictionary(PWGDQCore HEADERS AnalysisCut.h diff --git a/PWGDQ/Core/CutsLibrary.cxx b/PWGDQ/Core/CutsLibrary.cxx index 4f4b658bcce..5cf99d6f22f 100644 --- a/PWGDQ/Core/CutsLibrary.cxx +++ b/PWGDQ/Core/CutsLibrary.cxx @@ -16,9 +16,13 @@ #include #include #include +#include #include "AnalysisCompositeCut.h" #include "VarManager.h" +using std::cout; +using std::endl; + AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) { // @@ -48,6 +52,120 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) cut->AddCut(GetAnalysisCut("jpsi_TPCPID_debug5_noCorr")); return cut; } + if (!nameStr.compare("Electron2025_1")) { + AnalysisCut* kineCut = new AnalysisCut("kineCut", "kine cut"); + kineCut->AddCut(VarManager::kP, 1.0, 1000.0); + kineCut->AddCut(VarManager::kEta, -0.9, 0.9); + + AnalysisCut* qualityCuts = new AnalysisCut("qualityCuts", "quality cuts"); + qualityCuts->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + qualityCuts->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + qualityCuts->AddCut(VarManager::kTPCncls, 70, 161.); + qualityCuts->AddCut(VarManager::kTrackDCAz, -0.5, 0.5); + + AnalysisCut* pidCuts = new AnalysisCut("pidCuts", "pid cuts"); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -3.0, 4.0, false, VarManager::kPin, 0.0, 5.0); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -1.5, 4.0, false, VarManager::kPin, 5.0, 1000.0); + pidCuts->AddCut(VarManager::kTPCnSigmaPi, 2.5, 999, false, VarManager::kPin, 0.0, 5.0); + pidCuts->AddCut(VarManager::kTPCnSigmaPr, 2.5, 999, false, VarManager::kPin, 0.0, 5.0); + + cut->AddCut(kineCut); + cut->AddCut(qualityCuts); + cut->AddCut(pidCuts); + return cut; + } + + if (!nameStr.compare("Electron2025_2")) { + AnalysisCut* kineCut = new AnalysisCut("kineCut", "kine cut"); + kineCut->AddCut(VarManager::kP, 1.0, 1000.0); + kineCut->AddCut(VarManager::kEta, -0.9, 0.9); + + AnalysisCut* qualityCuts = new AnalysisCut("qualityCuts", "quality cuts"); + qualityCuts->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + qualityCuts->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + qualityCuts->AddCut(VarManager::kTPCncls, 70, 161.); + qualityCuts->AddCut(VarManager::kTrackDCAz, -0.5, 0.5); + + AnalysisCut* pidCuts = new AnalysisCut("pidCuts", "pid cuts"); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -3.0, 4.0, false, VarManager::kPin, 0.0, 5.0); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -2.0, 4.0, false, VarManager::kPin, 5.0, 1000.0); + pidCuts->AddCut(VarManager::kTPCnSigmaPi, 2.0, 999, false, VarManager::kPin, 0.0, 5.0); + pidCuts->AddCut(VarManager::kTPCnSigmaPr, 2.5, 999, false, VarManager::kPin, 0.0, 5.0); + + cut->AddCut(kineCut); + cut->AddCut(qualityCuts); + cut->AddCut(pidCuts); + return cut; + } + + if (!nameStr.compare("Electron2025_3")) { + AnalysisCut* kineCut = new AnalysisCut("kineCut", "kine cut"); + kineCut->AddCut(VarManager::kP, 1.0, 1000.0); + kineCut->AddCut(VarManager::kEta, -0.9, 0.9); + + AnalysisCut* qualityCuts = new AnalysisCut("qualityCuts", "quality cuts"); + qualityCuts->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + qualityCuts->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + qualityCuts->AddCut(VarManager::kTPCncls, 70, 161.); + qualityCuts->AddCut(VarManager::kTrackDCAz, -0.5, 0.5); + + AnalysisCut* pidCuts = new AnalysisCut("pidCuts", "pid cuts"); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -2.5, 4.0, false, VarManager::kPin, 0.0, 5.0); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -2.0, 4.0, false, VarManager::kPin, 5.0, 1000.0); + pidCuts->AddCut(VarManager::kTPCnSigmaPr, 2.5, 999, false, VarManager::kPin, 0.0, 5.0); + + cut->AddCut(kineCut); + cut->AddCut(qualityCuts); + cut->AddCut(pidCuts); + return cut; + } + + if (!nameStr.compare("Electron2025_4")) { + AnalysisCut* kineCut = new AnalysisCut("kineCut", "kine cut"); + kineCut->AddCut(VarManager::kP, 1.0, 1000.0); + kineCut->AddCut(VarManager::kEta, -0.9, 0.9); + + AnalysisCut* qualityCuts = new AnalysisCut("qualityCuts", "quality cuts"); + qualityCuts->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + qualityCuts->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + qualityCuts->AddCut(VarManager::kTPCncls, 70, 161.); + qualityCuts->AddCut(VarManager::kTrackDCAz, -0.5, 0.5); + + AnalysisCut* pidCuts = new AnalysisCut("pidCuts", "pid cuts"); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -2.5, 4.0, false, VarManager::kPin, 0.0, 5.0); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -1.5, 4.0, false, VarManager::kPin, 5.0, 1000.0); + pidCuts->AddCut(VarManager::kTPCnSigmaPi, 2.5, 999, false, VarManager::kPin, 0.0, 5.0); + pidCuts->AddCut(VarManager::kTPCnSigmaPr, 3.0, 999, false, VarManager::kPin, 0.0, 5.0); + + cut->AddCut(kineCut); + cut->AddCut(qualityCuts); + cut->AddCut(pidCuts); + return cut; + } + + if (!nameStr.compare("Electron2025_5")) { + AnalysisCut* kineCut = new AnalysisCut("kineCut", "kine cut"); + kineCut->AddCut(VarManager::kP, 1.0, 1000.0); + kineCut->AddCut(VarManager::kEta, -0.9, 0.9); + + AnalysisCut* qualityCuts = new AnalysisCut("qualityCuts", "quality cuts"); + qualityCuts->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + qualityCuts->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + qualityCuts->AddCut(VarManager::kTPCncls, 70, 161.); + qualityCuts->AddCut(VarManager::kTrackDCAz, -0.5, 0.5); + + AnalysisCut* pidCuts = new AnalysisCut("pidCuts", "pid cuts"); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -2.25, 4.0, false, VarManager::kPin, 0.0, 5.0); + pidCuts->AddCut(VarManager::kTPCnSigmaEl, -1.5, 4.0, false, VarManager::kPin, 5.0, 1000.0); + pidCuts->AddCut(VarManager::kTPCnSigmaPi, 2.5, 999, false, VarManager::kPin, 0.0, 5.0); + pidCuts->AddCut(VarManager::kTPCnSigmaPr, 3.0, 999, false, VarManager::kPin, 0.0, 5.0); + + cut->AddCut(kineCut); + cut->AddCut(qualityCuts); + cut->AddCut(pidCuts); + return cut; + } + if (!nameStr.compare("LowMassElectron2023")) { cut->AddCut(GetAnalysisCut("lmeeStandardKine")); cut->AddCut(GetAnalysisCut("LooseGlobalTrackRun3")); @@ -76,6 +194,18 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) cut->AddCut(GetAnalysisCut("MCHMID")); return cut; } + if (!nameStr.compare("ElectronForEMu")) { + cut->AddCut(GetAnalysisCut("jpsiKineSkimmed")); + cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); + cut->AddCut(GetAnalysisCut("electronPIDnsigmaLoose")); + return cut; + } + if (!nameStr.compare("MuonForEMu")) { + cut->AddCut(GetAnalysisCut("muonLowPt5")); + cut->AddCut(GetAnalysisCut("muonQualityCuts")); + cut->AddCut(GetAnalysisCut("MCHMID")); + return cut; + } // /////////////////////////////////////////////// // End of Cuts for CEFP // // /////////////////////////////////////////////// @@ -138,7 +268,13 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) cut->AddCut(GetAnalysisCut("electronPIDnsigmaMedium")); return cut; } - + if (!nameStr.compare("electronSelection1_ionut_withTOFPID")) { + cut->AddCut(GetAnalysisCut("jpsiStandardKine")); + cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("electronPIDnsigmaMedium_withLargeTOFPID")); + return cut; + } if (!nameStr.compare("electronSelection1_idstoreh")) { // same as electronSelection1_ionut, but with kIsSPDAny -> kIsITSibAny cut->AddCut(GetAnalysisCut("jpsiStandardKine")); cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); @@ -379,6 +515,12 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("JpsiPWGSkimmedCuts5")) { + cut->AddCut(GetAnalysisCut("electronTrackQualitySkimmed3")); + cut->AddCut(GetAnalysisCut("jpsi_TPCPID_debug8")); + return cut; + } + if (!nameStr.compare("pidElectron_ionut")) { cut->AddCut(GetAnalysisCut("pidcalib_ele")); cut->AddCut(GetAnalysisCut("jpsiStandardKine3")); @@ -493,6 +635,12 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("pionPIDCut2")) { + cut->AddCut(GetAnalysisCut("pionQualityCut2")); + cut->AddCut(GetAnalysisCut("pionPIDnsigma")); + return cut; + } + if (!nameStr.compare("PIDCalibElectron")) { cut->AddCut(GetAnalysisCut("pidcalib_ele")); return cut; @@ -818,6 +966,17 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("protonPIDPV")) { + cut->AddCut(GetAnalysisCut("protonPID_TPCnTOF2")); + cut->AddCut(GetAnalysisCut("protonPVcut")); + return cut; + } + + if (!nameStr.compare("protonPIDPV2")) { + cut->AddCut(GetAnalysisCut("protonPID_TPCnTOF2")); + return cut; + } + if (!nameStr.compare("PrimaryTrack_DCAz")) { cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); return cut; @@ -963,6 +1122,13 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("Jpsi_TPCPost_calib_debug10")) { + cut->AddCut(GetAnalysisCut("jpsiKineSkimmed")); + cut->AddCut(GetAnalysisCut("jpsi_trackCut_debug6")); + cut->AddCut(GetAnalysisCut("jpsi_TPCPID_debug10")); + return cut; + } + if (!nameStr.compare("LMee_TPCPost_calib_debug1")) { cut->AddCut(GetAnalysisCut("lmee_trackCut_debug")); cut->AddCut(GetAnalysisCut("lmee_TPCPID_debug1")); @@ -1016,6 +1182,153 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) } } + // Magnus composite cuts ----------------------------------------------------------------------------------------------------------------- + + AnalysisCompositeCut* magnus_PID111 = new AnalysisCompositeCut("magnus_PID111", ""); + magnus_PID111->AddCut(GetAnalysisCut("pidJpsi_magnus_ele1")); + magnus_PID111->AddCut(GetAnalysisCut("pidJpsi_magnus_pion1")); + magnus_PID111->AddCut(GetAnalysisCut("pidJpsi_magnus_prot1")); + if (!nameStr.compare("MagnussOptimization111")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID111); + return cut; + } + + AnalysisCompositeCut* magnus_PID211 = new AnalysisCompositeCut("magnus_PID211", ""); + magnus_PID211->AddCut(GetAnalysisCut("pidJpsi_magnus_ele2")); + magnus_PID211->AddCut(GetAnalysisCut("pidJpsi_magnus_pion1")); + magnus_PID211->AddCut(GetAnalysisCut("pidJpsi_magnus_prot1")); + if (!nameStr.compare("MagnussOptimization211")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID211); + return cut; + } + + AnalysisCompositeCut* magnus_PID311 = new AnalysisCompositeCut("magnus_PID311", ""); + magnus_PID311->AddCut(GetAnalysisCut("pidJpsi_magnus_ele3")); + magnus_PID311->AddCut(GetAnalysisCut("pidJpsi_magnus_pion1")); + magnus_PID311->AddCut(GetAnalysisCut("pidJpsi_magnus_prot1")); + if (!nameStr.compare("MagnussOptimization311")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID311); + return cut; + } + + AnalysisCompositeCut* magnus_PID121 = new AnalysisCompositeCut("magnus_PID121", ""); + magnus_PID121->AddCut(GetAnalysisCut("pidJpsi_magnus_ele1")); + magnus_PID121->AddCut(GetAnalysisCut("pidJpsi_magnus_pion2")); + magnus_PID121->AddCut(GetAnalysisCut("pidJpsi_magnus_prot1")); + if (!nameStr.compare("MagnussOptimization121")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID121); + return cut; + } + + AnalysisCompositeCut* magnus_PID112 = new AnalysisCompositeCut("magnus_PID112", ""); + magnus_PID112->AddCut(GetAnalysisCut("pidJpsi_magnus_ele1")); + magnus_PID112->AddCut(GetAnalysisCut("pidJpsi_magnus_pion1")); + magnus_PID112->AddCut(GetAnalysisCut("pidJpsi_magnus_prot2")); + if (!nameStr.compare("MagnussOptimization112")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID112); + return cut; + } + + AnalysisCompositeCut* magnus_PID122 = new AnalysisCompositeCut("magnus_PID122", ""); + magnus_PID122->AddCut(GetAnalysisCut("pidJpsi_magnus_ele1")); + magnus_PID122->AddCut(GetAnalysisCut("pidJpsi_magnus_pion2")); + magnus_PID122->AddCut(GetAnalysisCut("pidJpsi_magnus_prot2")); + if (!nameStr.compare("MagnussOptimization122")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID122); + return cut; + } + + AnalysisCompositeCut* magnus_PID222 = new AnalysisCompositeCut("magnus_PID222", ""); + magnus_PID222->AddCut(GetAnalysisCut("pidJpsi_magnus_ele2")); + magnus_PID222->AddCut(GetAnalysisCut("pidJpsi_magnus_pion2")); + magnus_PID222->AddCut(GetAnalysisCut("pidJpsi_magnus_prot2")); + if (!nameStr.compare("MagnussOptimization222")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID222); + return cut; + } + + AnalysisCompositeCut* magnus_PID212 = new AnalysisCompositeCut("magnus_PID212", ""); + magnus_PID212->AddCut(GetAnalysisCut("pidJpsi_magnus_ele2")); + magnus_PID212->AddCut(GetAnalysisCut("pidJpsi_magnus_pion1")); + magnus_PID212->AddCut(GetAnalysisCut("pidJpsi_magnus_prot2")); + if (!nameStr.compare("MagnussOptimization212")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID212); + return cut; + } + + AnalysisCompositeCut* magnus_PID221 = new AnalysisCompositeCut("magnus_PID221", ""); + magnus_PID221->AddCut(GetAnalysisCut("pidJpsi_magnus_ele2")); + magnus_PID221->AddCut(GetAnalysisCut("pidJpsi_magnus_pion2")); + magnus_PID221->AddCut(GetAnalysisCut("pidJpsi_magnus_prot1")); + if (!nameStr.compare("MagnussOptimization221")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID221); + return cut; + } + + AnalysisCompositeCut* magnus_PID321 = new AnalysisCompositeCut("magnus_PID321", ""); + magnus_PID321->AddCut(GetAnalysisCut("pidJpsi_magnus_ele3")); + magnus_PID321->AddCut(GetAnalysisCut("pidJpsi_magnus_pion2")); + magnus_PID321->AddCut(GetAnalysisCut("pidJpsi_magnus_prot1")); + if (!nameStr.compare("MagnussOptimization321")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID321); + return cut; + } + + AnalysisCompositeCut* magnus_PID312 = new AnalysisCompositeCut("magnus_PID312", ""); + magnus_PID312->AddCut(GetAnalysisCut("pidJpsi_magnus_ele3")); + magnus_PID312->AddCut(GetAnalysisCut("pidJpsi_magnus_pion1")); + magnus_PID312->AddCut(GetAnalysisCut("pidJpsi_magnus_prot2")); + if (!nameStr.compare("MagnussOptimization312")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID312); + return cut; + } + + AnalysisCompositeCut* magnus_PID322 = new AnalysisCompositeCut("magnus_PID322", ""); + magnus_PID322->AddCut(GetAnalysisCut("pidJpsi_magnus_ele1")); + magnus_PID322->AddCut(GetAnalysisCut("pidJpsi_magnus_pion2")); + magnus_PID322->AddCut(GetAnalysisCut("pidJpsi_magnus_prot2")); + if (!nameStr.compare("MagnussOptimization322")) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(magnus_PID322); + return cut; + } + //------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------- // Cuts for the selection of legs from dalitz decay // @@ -2652,6 +2965,11 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("muonMinimalCuts")) { + cut->AddCut(GetAnalysisCut("muonMinimalCuts")); + return cut; + } + if (!nameStr.compare("muonQualityCuts")) { cut->AddCut(GetAnalysisCut("muonQualityCuts")); return cut; @@ -2679,6 +2997,12 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("muonQualityCuts10SigmaPDCA_MCHMID")) { + cut->AddCut(GetAnalysisCut("muonQualityCuts10SigmaPDCA")); + cut->AddCut(GetAnalysisCut("MCHMID")); + return cut; + } + if (!nameStr.compare("muonLowPt10SigmaPDCA")) { cut->AddCut(GetAnalysisCut("muonLowPt")); cut->AddCut(GetAnalysisCut("muonQualityCuts10SigmaPDCA")); @@ -2872,6 +3196,17 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("muonQualityCutsMUONStandalone")) { + cut->AddCut(GetAnalysisCut("matchedMchMid")); + cut->AddCut(GetAnalysisCut("muonQualityCuts")); + return cut; + } + + if (!nameStr.compare("muonQualityCutsGlobal")) { + cut->AddCut(GetAnalysisCut("matchedGlobal")); + cut->AddCut(GetAnalysisCut("muonQualityCuts")); + return cut; + } // ----------------------------------------------------------- // Pair cuts if (!nameStr.compare("pairNoCut")) { @@ -3149,6 +3484,11 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("pairJpsi3")) { + cut->AddCut(GetAnalysisCut("pairJpsi3")); + return cut; + } + if (!nameStr.compare("pairPsi2S")) { cut->AddCut(GetAnalysisCut("pairPsi2S")); return cut; @@ -3164,11 +3504,26 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("pairX3872Cut2")) { + cut->AddCut(GetAnalysisCut("pairX3872_2")); + return cut; + } + + if (!nameStr.compare("pairX3872Cut3")) { + cut->AddCut(GetAnalysisCut("pairX3872_3")); + return cut; + } + if (!nameStr.compare("DipionPairCut1")) { cut->AddCut(GetAnalysisCut("DipionMassCut1")); return cut; } + if (!nameStr.compare("DipionPairCut2")) { + cut->AddCut(GetAnalysisCut("DipionMassCut2")); + return cut; + } + if (!nameStr.compare("pairRapidityForward")) { cut->AddCut(GetAnalysisCut("pairRapidityForward")); return cut; @@ -3318,66 +3673,10 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } - if (!nameStr.compare("emu_electron_test1")) { + if (!nameStr.compare("emu_electron_test")) { cut->AddCut(GetAnalysisCut("jpsiStandardKine")); - cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaOpen")); - return cut; - } - - if (!nameStr.compare("emu_electron_test2")) { - cut->AddCut(GetAnalysisCut("jpsiStandardKine2")); - cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaOpen")); - return cut; - } - - if (!nameStr.compare("emu_electron_test3")) { - cut->AddCut(GetAnalysisCut("jpsiKineSkimmed")); - cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaOpen")); - return cut; - } - - if (!nameStr.compare("emu_electron_test1_loosensigma")) { - cut->AddCut(GetAnalysisCut("jpsiStandardKine")); - cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaVeryVeryLoose2")); - return cut; - } - - if (!nameStr.compare("emu_electron_test2_loosensigma")) { - cut->AddCut(GetAnalysisCut("jpsiStandardKine2")); - cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaVeryVeryLoose2")); - return cut; - } - - if (!nameStr.compare("emu_electron_test3_loosensigma")) { - cut->AddCut(GetAnalysisCut("jpsiKineSkimmed")); - cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaVeryVeryLoose2")); - return cut; - } - - if (!nameStr.compare("emu_electron_test1_tightnsigma")) { - cut->AddCut(GetAnalysisCut("jpsiStandardKine")); - cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaLoose")); - return cut; - } - - if (!nameStr.compare("emu_electron_test2_tightnsigma")) { - cut->AddCut(GetAnalysisCut("jpsiStandardKine2")); - cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaLoose")); - return cut; - } - - if (!nameStr.compare("emu_electron_test3_tightnsigma")) { - cut->AddCut(GetAnalysisCut("jpsiKineSkimmed")); - cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); - cut->AddCut(GetAnalysisCut("electronPIDnsigmaLoose")); + cut->AddCut(GetAnalysisCut("electronTrackQuality_Maolin")); + cut->AddCut(GetAnalysisCut("electronPIDnsigmaEMu")); return cut; } @@ -3428,7 +3727,7 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) } delete cut; - LOGF(info, Form("Did not find cut %s", cutName)); + LOGF(fatal, Form("Did not find cut %s. Returning nullptr", cutName)); return nullptr; } @@ -3466,7 +3765,11 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } - if (!nameStr.compare("eventStandardSel8")) { + if (!nameStr.compare("eventSel8")) { // kIsSel8 = kIsTriggerTVX && kNoITSROFrameBorder && kNoTimeFrameBorder + cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); + return cut; + } + if (!nameStr.compare("eventStandardSel8")) { // kIsSel8 = kIsTriggerTVX && kNoITSROFrameBorder && kNoTimeFrameBorder cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); return cut; @@ -3479,14 +3782,14 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } - if (!nameStr.compare("eventStandardSel8NoTFBorder")) { + if (!nameStr.compare("eventStandardSel8NoTFBorder")) { // Redundant w.r.t. eventStandardSel8, to be removed cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); cut->AddCut(VarManager::kIsNoTFBorder, 0.5, 1.5); return cut; } - if (!nameStr.compare("eventStandardSel8NoTFBNoITSROFB")) { + if (!nameStr.compare("eventStandardSel8NoTFBNoITSROFB")) { // Redundant w.r.t. eventStandardSel8, to be removed cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); cut->AddCut(VarManager::kIsNoTFBorder, 0.5, 1.5); @@ -3512,6 +3815,17 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("eventStandardSel8PbPbQualityGoodITSLayersAll")) { // kIsSel8 = kIsTriggerTVX && kNoITSROFrameBorder && kNoTimeFrameBorder + cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); + cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoTFBorder, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoITSROFBorder, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoSameBunch, 0.5, 1.5); + cut->AddCut(VarManager::kIsGoodZvtxFT0vsPV, 0.5, 1.5); + cut->AddCut(VarManager::kIsGoodITSLayersAll, 0.5, 1.5); + return cut; + } + if (!nameStr.compare("eventStandardSel8PbPbQualityTightTrackOccupancy")) { cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); @@ -3521,9 +3835,9 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) cut->AddCut(VarManager::kIsGoodZvtxFT0vsPV, 0.5, 1.5); cut->AddCut(VarManager::kCentFT0C, 0.0, 90.0); cut->AddCut(VarManager::kTrackOccupancyInTimeRange, 0., 1000); - return cut; } + if (!nameStr.compare("eventStandardSel8PbPbQualityFirmTrackOccupancy")) { cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); @@ -3607,6 +3921,21 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) } } + for (size_t icase = 0; icase < vecOccupancies.size() - 1; icase++) { + if (!nameStr.compare(Form("eventStandardSel8PbPbQualityTrackOccupancySlice_0_%lu", icase))) { + cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); + cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoTFBorder, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoITSROFBorder, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoSameBunch, 0.5, 1.5); + cut->AddCut(VarManager::kIsGoodZvtxFT0vsPV, 0.5, 1.5); + cut->AddCut(VarManager::kCentFT0C, 0.0, 90.0); + cut->AddCut(VarManager::kTrackOccupancyInTimeRange, 0, vecOccupancies[icase]); + + return cut; + } + } + if (!nameStr.compare("eventStandardSel8ppQuality")) { cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); @@ -3619,6 +3948,44 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("eventStandardSel8multAnalysis")) { + cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); + cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoTFBorder, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoITSROFBorder, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoSameBunch, 0.5, 1.5); + cut->AddCut(VarManager::kIsVertexITSTPC, 0.5, 1.5); + return cut; + } + + if (!nameStr.compare("eventStandardSel8VtxQuality1")) { // kIsSel8 = kIsTriggerTVX && kNoITSROFrameBorder && kNoTimeFrameBorder + cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); + cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoSameBunch, 0.5, 1.5); + cut->AddCut(VarManager::kIsVertexITSTPC, 0.5, 1.5); + cut->AddCut(VarManager::kIsVertexTOFmatched, 0.5, 1.5); + return cut; + } + + if (!nameStr.compare("eventStandardSel8PbPbMultCorr")) { + TF1* fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + TF1* fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + + TF1* fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + TF1* fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + cut->AddCut(VarManager::kVtxNcontribReal, fMultPVCutLow, fMultPVCutHigh, false, VarManager::kCentFT0C, 0.0, 100.0, false); + cut->AddCut(VarManager::kMultA, fMultCutLow, fMultCutHigh, false, VarManager::kCentFT0C, 0.0, 100.0, false); + cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); + cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); + cut->AddCut(VarManager::kIsNoSameBunch, 0.5, 1.5); + cut->AddCut(VarManager::kIsGoodZvtxFT0vsPV, 0.5, 1.5); + return cut; + } + if (!nameStr.compare("eventDimuonStandard")) { cut->AddCut(VarManager::kIsMuonUnlikeLowPt7, 0.5, 1.5); return cut; @@ -4041,6 +4408,15 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("jpsi_trackCut_debug6")) { + cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + cut->AddCut(VarManager::kTPCncls, 120., 159); + cut->AddCut(VarManager::kTPCnclsCR, 140., 159); + cut->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + cut->AddCut(VarManager::kIsSPDfirst, 0.5, 1.5); + return cut; + } + if (!nameStr.compare("lmee_trackCut_debug")) { cut->AddCut(VarManager::kEta, -0.9, 0.9); cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); @@ -4301,6 +4677,26 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("electronTrackQualitySkimmed3")) { + cut->AddCut(VarManager::kPt, 1.0, 1000.0); + cut->AddCut(VarManager::kEta, -0.9, 0.9); + cut->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + cut->AddCut(VarManager::kTPCnclsCR, 70, 161); + cut->AddCut(VarManager::kTPCncls, 70, 161); + return cut; + } + + if (!nameStr.compare("electronTrackQuality_Maolin")) { + cut->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + cut->AddCut(VarManager::kITSchi2, 0.0, 15.0); + cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + cut->AddCut(VarManager::kTPCncls, 70, 161.); + cut->AddCut(VarManager::kTPCnclsCR, 70, 161); + cut->AddCut(VarManager::kTrackDCAxy, -2.0, 2.0); + cut->AddCut(VarManager::kTrackDCAz, -2.0, 2.0); + return cut; + } + if (!nameStr.compare("pionQualityCut1")) { cut->AddCut(VarManager::kPt, 0.15, 1000.0); cut->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); @@ -4308,6 +4704,26 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("pionQualityCut2")) { + cut->AddCut(VarManager::kPt, 0.15, 1000.0); + cut->AddCut(VarManager::kEta, -0.9, 0.9); + cut->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + cut->AddCut(VarManager::kTPCncls, 90, 161); + cut->AddCut(VarManager::kTPCnclsCR, 70, 161); + return cut; + } + + if (!nameStr.compare("protonPVcut")) { + cut->AddCut(VarManager::kTrackDCAxy, -0.1, 0.1); + cut->AddCut(VarManager::kTrackDCAz, -0.15, 0.15); + cut->AddCut(VarManager::kPt, 0.4, 3); + cut->AddCut(VarManager::kEta, -0.9, 0.9); + cut->AddCut(VarManager::kIsSPDany, 0.5, 1.5); + cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + cut->AddCut(VarManager::kTPCncls, 80, 161.); + return cut; + } + if (!nameStr.compare("pidbasic")) { cut->AddCut(VarManager::kEta, -0.9, 0.9); cut->AddCut(VarManager::kTPCncls, 60, 161.); @@ -4420,6 +4836,39 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + // Magnus cuts ---------------------------------------------------------- + + if (!nameStr.compare("pidJpsi_magnus_ele1")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -3.0, 4.0); + return cut; + } + if (!nameStr.compare("pidJpsi_magnus_ele2")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -2.0, 4.0); + return cut; + } + if (!nameStr.compare("pidJpsi_magnus_ele3")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -1.0, 4.0); + return cut; + } + if (!nameStr.compare("pidJpsi_magnus_prot1")) { + cut->AddCut(VarManager::kTPCnSigmaPr, 3.0, 1000.0); + return cut; + } + if (!nameStr.compare("pidJpsi_magnus_prot2")) { + cut->AddCut(VarManager::kTPCnSigmaPr, 3.5, 1000.0); + return cut; + } + if (!nameStr.compare("pidJpsi_magnus_pion1")) { + cut->AddCut(VarManager::kTPCnSigmaPi, 3.0, 1000.0); + return cut; + } + if (!nameStr.compare("pidJpsi_magnus_pion2")) { + cut->AddCut(VarManager::kTPCnSigmaPi, 3.5, 1000.0); + return cut; + } + + // ---------------------------------------------------------------------------------- + if (!nameStr.compare("standardPrimaryTrackDCAz")) { cut->AddCut(VarManager::kTrackDCAxy, -3.0, 3.0); cut->AddCut(VarManager::kTrackDCAz, -1.0, 1.0); @@ -4598,6 +5047,13 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("jpsi_TPCPID_debug10")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -1.5, 2.0); + cut->AddCut(VarManager::kTPCnSigmaPi, 4.0, 999); + cut->AddCut(VarManager::kTPCnSigmaPr, 3.5, 999); + return cut; + } + if (!nameStr.compare("pidCut_lowP_Corr")) { cut->AddCut(VarManager::kTPCnSigmaEl_Corr, -3.0, 3.0, false, VarManager::kP, 0.0, 5.0); cut->AddCut(VarManager::kTPCnSigmaPi_Corr, 3.0, 999, false, VarManager::kP, 0.0, 5.0); @@ -5056,13 +5512,6 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } - if (!nameStr.compare("electronPIDnsigmaVeryVeryLoose2")) { - cut->AddCut(VarManager::kTPCnSigmaEl, -4.0, 4.0); - cut->AddCut(VarManager::kTPCnSigmaPr, 2.5, 3000.0); - cut->AddCut(VarManager::kTPCnSigmaPi, 2.5, 3000.0); - return cut; - } - if (!nameStr.compare("electronPIDnsigmaVeryLoose")) { cut->AddCut(VarManager::kTPCnSigmaEl, -4.0, 4.0); cut->AddCut(VarManager::kTPCnSigmaPr, 2.5, 3000.0); @@ -5084,7 +5533,13 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) cut->AddCut(VarManager::kTPCnSigmaPi, 2.7, 3000.0); return cut; } - + if (!nameStr.compare("electronPIDnsigmaMedium_withLargeTOFPID")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -3.0, 3.0); + cut->AddCut(VarManager::kTPCnSigmaPr, 2.7, 3000.0); + cut->AddCut(VarManager::kTPCnSigmaPi, 2.7, 3000.0); + cut->AddCut(VarManager::kTOFnSigmaEl, -5.0, 5.0); + return cut; + } if (!nameStr.compare("electronPIDnsigmaSkewed")) { cut->AddCut(VarManager::kTPCnSigmaEl, -2.0, 3.0); cut->AddCut(VarManager::kTPCnSigmaPr, 3.5, 3000.0); @@ -5133,6 +5588,14 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("electronPIDnsigmaEMu")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -1.0, 3.0); + cut->AddCut(VarManager::kTPCnSigmaPr, 3.5, 3000.0); + cut->AddCut(VarManager::kTPCnSigmaPi, 3.5, 3000.0); + cut->AddCut(VarManager::kTPCnSigmaKa, 3.5, 3000.0); + return cut; + } + if (!nameStr.compare("kaonPIDnsigma")) { cut->AddCut(VarManager::kTPCnSigmaKa, -3.0, 3.0); return cut; @@ -5204,6 +5667,11 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("protonPID_TPCnTOF2")) { + cut->AddCut(VarManager::kTPCnSigmaPr, -2.5, 2.5); + return cut; + } + if (!nameStr.compare("tpc_pion_rejection")) { TF1* f1maxPi = new TF1("f1maxPi", "[0]+[1]*x", 0, 10); f1maxPi->SetParameters(85, -50); @@ -5557,6 +6025,14 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("muonMinimalCuts")) { + cut->AddCut(VarManager::kEta, -4.0, -2.5); + cut->AddCut(VarManager::kMuonRAtAbsorberEnd, 17.6, 89.5); + cut->AddCut(VarManager::kMuonPDca, 0.0, 594.0, false, VarManager::kMuonRAtAbsorberEnd, 17.6, 26.5); + cut->AddCut(VarManager::kMuonPDca, 0.0, 324.0, false, VarManager::kMuonRAtAbsorberEnd, 26.5, 89.5); + return cut; + } + if (!nameStr.compare("muonQualityCuts")) { cut->AddCut(VarManager::kEta, -4.0, -2.5); cut->AddCut(VarManager::kMuonRAtAbsorberEnd, 17.6, 89.5); @@ -5919,6 +6395,11 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("DipionMassCut2")) { + cut->AddCut(VarManager::kMass, 0.0, 1.0); + return cut; + } + if (!nameStr.compare("pairMassLow1")) { cut->AddCut(VarManager::kMass, 1.0, 1000.0); return cut; @@ -6019,6 +6500,11 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("pairJpsi3")) { + cut->AddCut(VarManager::kMass, 2.92, 3.14); + return cut; + } + if (!nameStr.compare("pairPsi2S")) { cut->AddCut(VarManager::kMass, 3.4, 3.9); return cut; @@ -6034,6 +6520,22 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("pairX3872_2")) { + cut->AddCut(VarManager::kQuadDefaultDileptonMass, 3.0, 5.0); + cut->AddCut(VarManager::kQ, 0.0, 0.5); + cut->AddCut(VarManager::kDeltaR, 0.0, 5.0); + cut->AddCut(VarManager::kQuadPt, 5.0, 40.0); + return cut; + } + + if (!nameStr.compare("pairX3872_3")) { + cut->AddCut(VarManager::kQuadDefaultDileptonMass, 3.0, 5.0); + cut->AddCut(VarManager::kQ, 0.0, 0.5); + cut->AddCut(VarManager::kDeltaR, 0.0, 5.0); + cut->AddCut(VarManager::kQuadPt, 0.0, 1000.0); + return cut; + } + if (!nameStr.compare("pairPtLow1")) { cut->AddCut(VarManager::kPt, 2.0, 1000.0); return cut; @@ -6205,6 +6707,396 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) } delete cut; - LOGF(info, Form("Did not find cut %s", cutName)); + LOGF(fatal, Form("Did not find cut %s", cutName)); return nullptr; } + +//________________________________________________________________________________________________ +std::vector o2::aod::dqcuts::GetCutsFromJSON(const char* json) +{ + // + // configure cuts using a json file + // + + std::vector cuts; + // AnalysisCut* cuts[100]; + LOG(info) << "========================================== interpreting JSON for analysis cuts"; + LOG(info) << "JSON string: " << json; + + // + // Create a vector of AnalysisCuts from a JSON formatted string + // The JSON is expected to contain a list of objects, with each object containing the fields needed + // to define either an AnalysisCut or an AnalysisCompositeCut + rapidjson::Document document; + + // Check that the json is parsed correctly + rapidjson::ParseResult ok = document.Parse(json); + if (!ok) { + LOG(fatal) << "JSON parse error: " << rapidjson::GetParseErrorFunc(ok.Code()) << " (" << ok.Offset() << ")"; + return cuts; + } + + // The json is expected to contain a list of objects, each of which should provide the configuration of a cut + for (rapidjson::Value::ConstMemberIterator it = document.MemberBegin(); it != document.MemberEnd(); it++) { + + const char* cutName = it->name.GetString(); + LOG(info) << "=================================================== Configuring cut " << cutName; + const auto& cut = it->value; + + // Detect if this is an AnalysisCut or a composite cut + bool isAnalysisCut = false; + bool isAnalysisCompositeCut = false; + if (cut.HasMember("type")) { + TString typeStr = cut.FindMember("type")->value.GetString(); + if (typeStr.CompareTo("AnalysisCut") == 0) { + LOG(debug) << "This is an AnalysisCut"; + isAnalysisCut = true; + } + if (typeStr.CompareTo("AnalysisCompositeCut") == 0) { + LOG(debug) << "This is an AnalysisCompositeCut"; + isAnalysisCompositeCut = true; + } + } + if (!(isAnalysisCut || isAnalysisCompositeCut)) { + LOG(fatal) << "Member is neither an AnalysisCut or AnalysisCompositeCut"; + return cuts; + } + + // Parse the object, construct the cut and add it to the return vector + if (isAnalysisCut) { + AnalysisCut* anaCut = ParseJSONAnalysisCut(&cut, cutName); + if (anaCut != nullptr) { + cuts.push_back(anaCut); + } else { + LOG(fatal) << "Something went wrong in creating the AnalysisCut " << cutName; + return cuts; + } + } + if (isAnalysisCompositeCut) { + AnalysisCompositeCut* anaCut = ParseJSONAnalysisCompositeCut(&cut, cutName); + if (anaCut != nullptr) { + cuts.push_back(anaCut); + } else { + LOG(fatal) << "Something went wrong in creating the AnalysisCompositeCut " << cutName; + return cuts; + } + } + } + + return cuts; +} + +//________________________________________________________________________________________________ +template +bool o2::aod::dqcuts::ValidateJSONAnalysisCut(T cut) +{ + // + // Validate cut definition in JSON file + // + // The type field is compulsory + if (!cut->HasMember("type")) { + LOG(fatal) << "Missing type information"; + return false; + } + TString typeStr = cut->FindMember("type")->value.GetString(); + if (typeStr.CompareTo("AnalysisCut") != 0) { + LOG(fatal) << "Type is not AnalysisCut"; + return false; + } + + return true; +} + +//________________________________________________________________________________________________ +template +bool o2::aod::dqcuts::ValidateJSONAddCut(T addcut, bool isSimple) +{ + // + // Validate AddCut definition in JSON file + // + + // Check if this AddCut is adding an analysis cut (if the mother is a composite cut) + bool isAnalysisCut = false; + if (addcut->HasMember("type")) { + isAnalysisCut = true; + } + // check if this is adding a basic variable range cut + bool isBasicCut = false; + if (addcut->HasMember("var") && addcut->HasMember("cutLow") && addcut->HasMember("cutHigh")) { + isBasicCut = true; + } + + // if neither of the two option is true, then something is wrong + if (!(isBasicCut || isAnalysisCut)) { + LOG(fatal) << "This is neither adding an AnalysisCut nor a basic variable range cut"; + return false; + } + if (isSimple && isAnalysisCut) { + LOG(fatal) << "One cannot call AddCut with an AnalysisCut in this case"; + return false; + } + if (!isSimple && isAnalysisCut) { + return true; + } + + // check that the variable to cut on is a valid one (implemented in the VarManager) + const char* var = addcut->FindMember("var")->value.GetString(); + if (VarManager::fgVarNamesMap.find(var) == VarManager::fgVarNamesMap.end()) { + LOG(fatal) << "Bad cut variable (" << var << ") specified for this AddCut"; + return false; + } + + // check whether the specified cut low and high are numbers or functions + bool cutLow_isNumber = addcut->FindMember("cutLow")->value.IsNumber(); + bool cutHigh_isNumber = addcut->FindMember("cutHigh")->value.IsNumber(); + if (!cutLow_isNumber) { + auto& cutLow = addcut->FindMember("cutLow")->value; + if (!cutLow.HasMember("funcName") || !cutLow.HasMember("funcBody") || + !cutLow.HasMember("xLow") || !cutLow.HasMember("xHigh")) { + LOG(fatal) << "Missing fields for the cutLow TF1 definition"; + return false; + } + } + if (!cutHigh_isNumber) { + auto& cutHigh = addcut->FindMember("cutHigh")->value; + if (!cutHigh.HasMember("funcName") || !cutHigh.HasMember("funcBody") || + !cutHigh.HasMember("xLow") || !cutHigh.HasMember("xHigh")) { + LOG(fatal) << "Missing fields for the cutLow TF1 definition"; + return false; + } + } + if (!cutHigh_isNumber || !cutLow_isNumber) { + if (!addcut->HasMember("dependentVar") || !addcut->HasMember("depCutLow") || !addcut->HasMember("depCutHigh")) { + LOG(fatal) << "For cutLow or cutHigh as a TF1, the definition of the dependentVar and range are also required"; + return false; + } + const char* depVar = addcut->FindMember("dependentVar")->value.GetString(); + if (VarManager::fgVarNamesMap.find(depVar) == VarManager::fgVarNamesMap.end()) { + LOG(fatal) << "Bad cut variable (" << depVar << ") specified for the dependentVar"; + return false; + } + } + if (addcut->HasMember("dependentVar1") && cutLow_isNumber && cutHigh_isNumber) { + const char* depVar1 = addcut->FindMember("dependentVar1")->value.GetString(); + if (VarManager::fgVarNamesMap.find(depVar1) == VarManager::fgVarNamesMap.end()) { + LOG(fatal) << "Bad cut variable (" << depVar1 << ") specified for the dependentVar"; + return false; + } + if (!addcut->HasMember("depCut2Low") || !addcut->HasMember("depCut2High")) { + LOG(fatal) << "dependentVar2 specified, but not its range"; + return false; + } + } + if (addcut->HasMember("dependentVar2")) { + const char* depVar2 = addcut->FindMember("dependentVar2")->value.GetString(); + if (VarManager::fgVarNamesMap.find(depVar2) == VarManager::fgVarNamesMap.end()) { + LOG(fatal) << "Bad cut variable (" << depVar2 << ") specified for the dependentVar2"; + return false; + } + if (!addcut->HasMember("depCut2Low") || !addcut->HasMember("depCut2High")) { + LOG(fatal) << "dependentVar2 specified, but not its range"; + return false; + } + } + + return true; +} + +//_______________________________________________________________________________________________ +template +AnalysisCut* o2::aod::dqcuts::ParseJSONAnalysisCut(T cut, const char* cutName) +{ + + // Parse the json object and build an AnalysisCut + if (!ValidateJSONAnalysisCut(cut)) { + LOG(fatal) << "AnalysisCut not properly defined in the JSON file. Skipping it"; + return nullptr; + } + + // If the analysis cut has the field "library", its just loaded from the preexisting cuts in the library and return + if (cut->HasMember("library")) { + return GetAnalysisCut(cut->FindMember("library")->value.GetString()); + } + + // construct the AnalysisCut object and add the AddCuts + AnalysisCut* retCut = new AnalysisCut(cutName, cut->HasMember("library") ? cut->FindMember("title")->value.GetString() : ""); + + // loop over all the members for this cut and configure the AddCut objects + for (rapidjson::Value::ConstMemberIterator it = cut->MemberBegin(); it != cut->MemberEnd(); it++) { + + TString itName = it->name.GetString(); + + if (itName.Contains("AddCut")) { + + LOG(debug) << "Parsing " << itName.Data(); + const auto& addcut = it->value; + if (!ValidateJSONAddCut(&addcut, true)) { + LOG(fatal) << "AddCut statement not properly defined"; + return nullptr; + } + + const char* var = addcut.FindMember("var")->value.GetString(); + LOG(info) << "var " << var; + bool cutLow_isNumber = addcut.FindMember("cutLow")->value.IsNumber(); + LOG(info) << "cutLow_isNumber " << cutLow_isNumber; + bool cutHigh_isNumber = addcut.FindMember("cutHigh")->value.IsNumber(); + LOG(info) << "cutHigh_isNumber " << cutHigh_isNumber; + + bool exclude = (addcut.HasMember("exclude") ? addcut.FindMember("exclude")->value.GetBool() : false); + LOG(info) << "exclude " << exclude; + const char* dependentVar = (addcut.HasMember("dependentVar") ? addcut.FindMember("dependentVar")->value.GetString() : "kNothing"); + LOG(info) << "dependentVar " << dependentVar; + double depCutLow = (addcut.HasMember("depCutLow") ? addcut.FindMember("depCutLow")->value.GetDouble() : 0.0); + LOG(info) << "depCutLow " << depCutLow; + double depCutHigh = (addcut.HasMember("depCutHigh") ? addcut.FindMember("depCutHigh")->value.GetDouble() : 10.0); + LOG(info) << "depCutHigh " << depCutHigh; + bool depCutExclude = (addcut.HasMember("depCutExclude") ? addcut.FindMember("depCutExclude")->value.GetBool() : false); + LOG(info) << "depCutExclude " << depCutExclude; + const char* dependentVar2 = (addcut.HasMember("dependentVar2") ? addcut.FindMember("dependentVar2")->value.GetString() : "kNothing"); + LOG(info) << "dependentVar2 " << dependentVar2; + double depCut2Low = (addcut.HasMember("depCut2Low") ? addcut.FindMember("depCut2Low")->value.GetDouble() : 0.0); + LOG(info) << "depCut2Low " << depCut2Low; + double depCut2High = (addcut.HasMember("depCut2High") ? addcut.FindMember("depCut2High")->value.GetDouble() : 10.0); + LOG(info) << "depCut2High " << depCut2High; + bool depCut2Exclude = (addcut.HasMember("depCut2Exclude") ? addcut.FindMember("depCut2Exclude")->value.GetBool() : false); + LOG(info) << "depCut2Exclude " << depCut2Exclude; + + TF1* cutLowFunc = nullptr; + TF1* cutHighFunc = nullptr; + double cutLowNumber = 0.0; + double cutHighNumber = 0.0; + if (cutLow_isNumber) { + cutLowNumber = addcut.FindMember("cutLow")->value.GetDouble(); + LOG(info) << "cutLowNumber " << cutLowNumber; + } else { + auto& cutLow = addcut.FindMember("cutLow")->value; + cutLowFunc = new TF1(cutLow.FindMember("funcName")->value.GetString(), cutLow.FindMember("funcBody")->value.GetString(), + cutLow.FindMember("xLow")->value.GetDouble(), cutLow.FindMember("xHigh")->value.GetDouble()); + LOG(info) << "cutLowFunc " << cutLow.FindMember("funcName")->value.GetString() << ", " << cutLow.FindMember("funcBody")->value.GetString() + << ", " << cutLow.FindMember("xLow")->value.GetDouble() << ", " << cutLow.FindMember("xHigh")->value.GetDouble(); + } + if (cutHigh_isNumber) { + cutHighNumber = addcut.FindMember("cutHigh")->value.GetDouble(); + LOG(info) << "cutHighNumber " << cutHighNumber; + } else { + auto& cutHigh = addcut.FindMember("cutHigh")->value; + cutHighFunc = new TF1(cutHigh.FindMember("funcName")->value.GetString(), cutHigh.FindMember("funcBody")->value.GetString(), + cutHigh.FindMember("xLow")->value.GetDouble(), cutHigh.FindMember("xHigh")->value.GetDouble()); + LOG(info) << "cutHighFunc " << cutHigh.FindMember("funcName")->value.GetString() << ", " << cutHigh.FindMember("funcBody")->value.GetString() + << ", " << cutHigh.FindMember("xLow")->value.GetDouble() << ", " << cutHigh.FindMember("xHigh")->value.GetDouble(); + } + if (cutLow_isNumber) { + if (cutHigh_isNumber) { + retCut->AddCut(VarManager::fgVarNamesMap[var], cutLowNumber, cutHighNumber, exclude, + VarManager::fgVarNamesMap[dependentVar], depCutLow, depCutHigh, depCutExclude, + VarManager::fgVarNamesMap[dependentVar2], depCut2Low, depCut2High, depCut2Exclude); + } else { + retCut->AddCut(VarManager::fgVarNamesMap[var], cutLowNumber, cutHighFunc, exclude, + VarManager::fgVarNamesMap[dependentVar], depCutLow, depCutHigh, depCutExclude, + VarManager::fgVarNamesMap[dependentVar2], depCut2Low, depCut2High, depCut2Exclude); + } + } else { + if (cutHigh_isNumber) { + retCut->AddCut(VarManager::fgVarNamesMap[var], cutLowFunc, cutHighNumber, exclude, + VarManager::fgVarNamesMap[dependentVar], depCutLow, depCutHigh, depCutExclude, + VarManager::fgVarNamesMap[dependentVar2], depCut2Low, depCut2High, depCut2Exclude); + } else { + retCut->AddCut(VarManager::fgVarNamesMap[var], cutLowFunc, cutHighFunc, exclude, + VarManager::fgVarNamesMap[dependentVar], depCutLow, depCutHigh, depCutExclude, + VarManager::fgVarNamesMap[dependentVar2], depCut2Low, depCut2High, depCut2Exclude); + } + } + } + } + + return retCut; +} + +//_______________________________________________________________________________________________ +template +bool o2::aod::dqcuts::ValidateJSONAnalysisCompositeCut(T cut) +{ + // + // Validate composite cut definition in JSON file + // + if (!cut->HasMember("type")) { + LOG(fatal) << "Missing type field"; + return false; + } + if (!(cut->HasMember("library") || cut->HasMember("useAND"))) { + LOG(fatal) << "Either library or useAND fields are required in an AnalysisCompositeCut definition"; + } + TString typeStr = cut->FindMember("type")->value.GetString(); + if (typeStr.CompareTo("AnalysisCompositeCut") != 0) { + LOG(fatal) << "Type is not AnalysisCompositeCut"; + return false; + } + + return true; +} + +//_______________________________________________________________________________________________ +template +AnalysisCompositeCut* o2::aod::dqcuts::ParseJSONAnalysisCompositeCut(T cut, const char* cutName) +{ + + // Configure an AnalysisCompositeCut + if (!ValidateJSONAnalysisCompositeCut(cut)) { + LOG(fatal) << "Composite Cut not properly defined in the JSON file. Skipping it"; + return nullptr; + } + + if (cut->HasMember("library")) { + return GetCompositeCut(cut->FindMember("library")->value.GetString()); + } + + AnalysisCompositeCut* retCut = new AnalysisCompositeCut(cutName, cut->HasMember("library") ? cut->FindMember("title")->value.GetString() : "", cut->FindMember("useAND")->value.GetBool()); + + // Loop to find AddCut objects + for (rapidjson::Value::ConstMemberIterator it = cut->MemberBegin(); it != cut->MemberEnd(); it++) { + + TString itName = it->name.GetString(); + + if (itName.Contains("AddCut")) { + + LOG(debug) << "Parsing " << itName.Data(); + const auto& addcut = it->value; + if (!ValidateJSONAddCut(&addcut, false)) { + LOG(fatal) << "AddCut statement not properly defined"; + return nullptr; + } + + // For an AnalysisCompositeCut, one can call AddCut with either an AnalysisCut or another AnalysisCompositeCut + bool isAnalysisCut = false; + bool isAnalysisCompositeCut = false; + TString typeStr = addcut.FindMember("type")->value.GetString(); + if (typeStr.CompareTo("AnalysisCut") == 0) { + isAnalysisCut = true; + } + if (typeStr.CompareTo("AnalysisCompositeCut") == 0) { + isAnalysisCompositeCut = true; + } + + // Add an AnalysisCut + if (isAnalysisCut) { + AnalysisCut* cutMember = ParseJSONAnalysisCut(&addcut, itName.Data()); + if (cutMember != nullptr) { + retCut->AddCut(cutMember); + } else { + return nullptr; + } + } + // Add an AnalysisCompositeCut + if (isAnalysisCompositeCut) { + AnalysisCompositeCut* cutMember = ParseJSONAnalysisCompositeCut(&addcut, itName.Data()); + if (cutMember != nullptr) { + retCut->AddCut(cutMember); + } else { + return nullptr; + } + } + } + } + + return retCut; +} diff --git a/PWGDQ/Core/CutsLibrary.h b/PWGDQ/Core/CutsLibrary.h index 1ce85510ab2..c6ad4caded2 100644 --- a/PWGDQ/Core/CutsLibrary.h +++ b/PWGDQ/Core/CutsLibrary.h @@ -97,12 +97,27 @@ // End of Cuts for CEFP // // /////////////////////////////////////////////// +#include "rapidjson/document.h" + namespace o2::aod { namespace dqcuts { AnalysisCompositeCut* GetCompositeCut(const char* cutName); AnalysisCut* GetAnalysisCut(const char* cutName); + +std::vector GetCutsFromJSON(const char* json); +// AnalysisCut** GetCutsFromJSON(const char* json); +template +bool ValidateJSONAnalysisCut(T cut); +template +bool ValidateJSONAddCut(T cut, bool isSimple); +template +AnalysisCut* ParseJSONAnalysisCut(T cut, const char* cutName); +template +bool ValidateJSONAnalysisCompositeCut(T cut); +template +AnalysisCompositeCut* ParseJSONAnalysisCompositeCut(T key, const char* cutName); } // namespace dqcuts } // namespace o2::aod diff --git a/PWGDQ/Core/HistogramManager.cxx b/PWGDQ/Core/HistogramManager.cxx index f66ced3ca8b..fb5ce5f8d65 100644 --- a/PWGDQ/Core/HistogramManager.cxx +++ b/PWGDQ/Core/HistogramManager.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include "Framework/Logger.h" using namespace std; @@ -563,6 +564,13 @@ void HistogramManager::AddHistogram(const char* histClass, const char* hname, co fUsedVars[varW] = kTRUE; } + for (int i = 0; i < nDimensions; i++) { + if (xmax[i] <= xmin[i]) { + LOG(warn) << "HistogramManager::AddHistogram(): Histogram " << hname << " has wrong axes ranges for dimension " << i + << ", (xmin/xmax): " << xmin[i] << " / " << xmax[i]; + } + } + // encode needed variable identifiers in a vector and push it to the std::list corresponding to the current histogram list std::vector varVector; varVector.push_back(0); // whether the histogram is a profile diff --git a/PWGDQ/Core/HistogramsLibrary.cxx b/PWGDQ/Core/HistogramsLibrary.cxx index 9e4e37fd463..b9618a4c64e 100644 --- a/PWGDQ/Core/HistogramsLibrary.cxx +++ b/PWGDQ/Core/HistogramsLibrary.cxx @@ -11,6 +11,8 @@ // // Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no // +#include +#include #include "PWGDQ/Core/HistogramsLibrary.h" #include "VarManager.h" #include "CommonConstants/MathConstants.h" @@ -82,14 +84,16 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h if (subGroupStr.Contains("mult")) { if (subGroupStr.Contains("pp")) { hm->AddHistogram(histClass, "MultTPC", "MultTPC", false, 250, 0.0, 500.0, VarManager::kMultTPC); - hm->AddHistogram(histClass, "MultFV0A", "MultFV0A", false, 250, 0.0, 500.0, VarManager::kMultFV0A); - hm->AddHistogram(histClass, "MultFT0A", "MultFT0A", false, 300, 0.0, 300.0, VarManager::kMultFT0A); - hm->AddHistogram(histClass, "MultFT0C", "MultFT0C", false, 300, 0.0, 300.0, VarManager::kMultFT0C); - hm->AddHistogram(histClass, "MultFDDA", "MultFDDA", false, 300, 0.0, 300.0, VarManager::kMultFDDA); - hm->AddHistogram(histClass, "MultFDDC", "MultFDDC", false, 50, 0.0, 50.0, VarManager::kMultFDDC); + hm->AddHistogram(histClass, "MultFV0A", "MultFV0A", false, 1000, 0.0, 25000.0, VarManager::kMultFV0A); + hm->AddHistogram(histClass, "MultFT0A", "MultFT0A", false, 1000, 0.0, 25000.0, VarManager::kMultFT0A); + hm->AddHistogram(histClass, "MultFT0C", "MultFT0C", false, 1000, 0.0, 25000.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "MultFDDA", "MultFDDA", false, 1000, 0.0, 25000.0, VarManager::kMultFDDA); + hm->AddHistogram(histClass, "MultFDDC", "MultFDDC", false, 1000, 0.0, 25000.0, VarManager::kMultFDDC); hm->AddHistogram(histClass, "MultTracklets", "MultTracklets", false, 250, 0.0, 250.0, VarManager::kMultTracklets); - hm->AddHistogram(histClass, "VtxNContribReal", "Vtx n contributors", false, 100, 0.0, 100.0, VarManager::kVtxNcontribReal); + hm->AddHistogram(histClass, "VtxNContribReal", "Vtx n contributors", false, 150, 0.0, 150.0, VarManager::kVtxNcontribReal); hm->AddHistogram(histClass, "VtxNContrib", "Vtx n contributors", false, 100, 0.0, 100.0, VarManager::kVtxNcontrib); + hm->AddHistogram(histClass, "MultNTracksPVeta1", "MultNTracksPVeta1", false, 150, 0, 150.0, VarManager::kMultNTracksPVeta1); + hm->AddHistogram(histClass, "MultNTracksPVetaHalf", "MultNTracksPVetaHalf", false, 150, 0, 150.0, VarManager::kMultNTracksPVetaHalf); hm->AddHistogram(histClass, "MultTPC_MultFV0A", "MultTPC vs MultFV0A", false, 100, 0, 500.0, VarManager::kMultTPC, 100, 0, 500.0, VarManager::kMultFV0A); hm->AddHistogram(histClass, "MultTPC_MultFT0A", "MultTPC vs MultFT0A", false, 100, 0, 500.0, VarManager::kMultTPC, 100, 0, 200.0, VarManager::kMultFT0A); hm->AddHistogram(histClass, "MultTPC_MultFT0C", "MultTPC vs MultFT0C", false, 100, 0, 500.0, VarManager::kMultTPC, 100, 0, 300.0, VarManager::kMultFT0C); @@ -104,6 +108,19 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "MultITSWithPV_MultFT0A", "MultITSWithPV_MultFT0A", false, 150, 0.0, 150.0, VarManager::kMultNTracksHasITS, 250, 0.0, 2500.0, VarManager::kMultFT0A); hm->AddHistogram(histClass, "MultITSTPCWithPV_MultFT0C", "MultITSTPCWithPV_MultFT0C", false, 150, 0.0, 150.0, VarManager::kMultNTracksITSTPC, 250, 0.0, 2500.0, VarManager::kMultFT0C); hm->AddHistogram(histClass, "MultITSTPCWithPV_MultFT0A", "MultITSTPCWithPV_MultFT0A", false, 150, 0.0, 150.0, VarManager::kMultNTracksITSTPC, 250, 0.0, 2500.0, VarManager::kMultFT0A); + hm->AddHistogram(histClass, "VtxZ_MultITSWithPV", "VtxZ vs MultITSWithPV", false, 240, -12.0, 12.0, VarManager::kVtxZ, 400, 0, 400.0, VarManager::kMultNTracksHasITS); + hm->AddHistogram(histClass, "VtxZ_MultTPCWithPV", "VtxZ vs MultTPCWithPV", false, 240, -12.0, 12.0, VarManager::kVtxZ, 400, 0, 400.0, VarManager::kMultNTracksHasTPC); + hm->AddHistogram(histClass, "VtxZ_MultITSTPCWithPV", "VtxZ vs MultITSTPCWithPV", false, 240, -12.0, 12.0, VarManager::kVtxZ, 400, 0, 400.0, VarManager::kMultNTracksITSTPC); + hm->AddHistogram(histClass, "VtxZ_MultITSOnly", "VtxZ vs MultITSOnly", false, 240, -12.0, 12.0, VarManager::kVtxZ, 400, 0, 400.0, VarManager::kMultNTracksITSOnly); + hm->AddHistogram(histClass, "VtxZ_VtxNcontribReal", "VtxZ vs VtxNcontribReal", false, 100, -10.0, 10.0, VarManager::kVtxZ, 150, 0, 150.0, VarManager::kVtxNcontribReal); + hm->AddHistogram(histClass, "VtxZ_MultNTracksPVeta1", "VtxZ vs MultNTracksPVeta1", false, 100, -10.0, 10.0, VarManager::kVtxZ, 150, 0, 150.0, VarManager::kMultNTracksPVeta1); + hm->AddHistogram(histClass, "VtxZ_MultNTracksPVetaHalf", "VtxZ vs MultNTracksPVetaHalf", false, 100, -10.0, 10.0, VarManager::kVtxZ, 150, 0, 150.0, VarManager::kMultNTracksPVetaHalf); + hm->AddHistogram(histClass, "VtxZ_MultFV0A", "VtxZ vs MultFV0A", false, 20, -10.0, 10.0, VarManager::kVtxZ, 200, 0, 25000.0, VarManager::kMultFV0A); + hm->AddHistogram(histClass, "VtxZ_MultFT0A", "VtxZ vs MultFT0A", false, 20, -10.0, 10.0, VarManager::kVtxZ, 200, 0, 25000.0, VarManager::kMultFT0A); + hm->AddHistogram(histClass, "VtxZ_MultFT0C", "VtxZ vs MultFT0C", false, 20, -10.0, 10.0, VarManager::kVtxZ, 200, 0, 25000.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "VtxZ_MultFDDA", "VtxZ vs MultFDDA", false, 20, -10.0, 10.0, VarManager::kVtxZ, 200, 0, 25000.0, VarManager::kMultFDDA); + hm->AddHistogram(histClass, "VtxZ_MultFDDC", "VtxZ vs MultFDDC", false, 20, -10.0, 10.0, VarManager::kVtxZ, 200, 0, 25000.0, VarManager::kMultFDDC); + } else { hm->AddHistogram(histClass, "MultTPC", "MultTPC", false, 200, 0.0, 50000.0, VarManager::kMultTPC); hm->AddHistogram(histClass, "MultTPC_vsTimeSOR", "MultTPC vs time from SOR", true, 10000, 0.0, 1000.0, VarManager::kTimeFromSOR, 10, 0.0, 50000.0, VarManager::kMultTPC); @@ -158,6 +175,10 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "TPCoccupMedianTimeShortA", "TPC occupancy from pileup, median time, A-side, short time range", false, 100, -20.0, 20.0, VarManager::kNTPCmedianTimeShortA); hm->AddHistogram(histClass, "TPCoccupMedianTimeShortC", "TPC occupancy from pileup, median time, C-side, short time range", false, 100, -20.0, 20.0, VarManager::kNTPCmedianTimeShortC); hm->AddHistogram(histClass, "TPCoccupMedianTimeShortAvsC", "TPC occupancy from pileup, median time, A-side vs C-side, short time range", false, 100, -20.0, 20.0, VarManager::kNTPCmedianTimeShortA, 100, -20.0, 20.0, VarManager::kNTPCmedianTimeShortC); + hm->AddHistogram(histClass, "TPCoccupContribLongA_TrackOccup", "TPC occupancy from pileup, n-contrib, A-side, long time range vs common track occup", false, 100, 0.0, 10000.0, VarManager::kNTPCcontribLongA, 100, 0.0, 10000.0, VarManager::kTrackOccupancyInTimeRange); + hm->AddHistogram(histClass, "NcontribReal_centT0C", "Ncontrib vs Cent", false, 100, 0, 100, VarManager::kCentFT0C, 4000, 0, 4000, VarManager::kVtxNcontribReal); + hm->AddHistogram(histClass, "globalTracks_centT0C", "globalTracks vs Cent", false, 100, 0, 100, VarManager::kCentFT0C, 4000, 0, 4000, VarManager::kMultA); + hm->AddHistogram(histClass, "ITSTPCTracks_centT0C", "ITSTPCTracks vs Cent", false, 100, 0, 100, VarManager::kCentFT0C, 4000, 0, 4000, VarManager::kMultAllTracksITSTPC); } } if (subGroupStr.Contains("ftmulpbpb")) { @@ -172,6 +193,19 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h } if (subGroupStr.Contains("occupancy")) { hm->AddHistogram(histClass, "ITStrackOccupancy", "ITStrackOccupancy", false, 200, 0.0, 20000.0, VarManager::kTrackOccupancyInTimeRange); + hm->AddHistogram(histClass, "Ft0cOccupancy", "Ft0cOccupancy", false, 200, 0.0, 20000.0, VarManager::kFT0COccupancyInTimeRange); + if (subGroupStr.Contains("qvector")) { + hm->AddHistogram(histClass, "Psi2A_ITStrackOccupancy", "", false, 200, 0.0, 20000.0, VarManager::kTrackOccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2A); + hm->AddHistogram(histClass, "Psi2B_ITStrackOccupancy", "", true, 200, 0.0, 20000.0, VarManager::kTrackOccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2B); + hm->AddHistogram(histClass, "Psi2C_ITStrackOccupancy", "", true, 200, 0.0, 20000.0, VarManager::kTrackOccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2C); + hm->AddHistogram(histClass, "Psi2APOS_ITStrackOccupancy", "", true, 200, 0.0, 20000.0, VarManager::kTrackOccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2APOS); + hm->AddHistogram(histClass, "Psi2ANEG_ITStrackOccupancy", "", true, 200, 0.0, 20000.0, VarManager::kTrackOccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2ANEG); + hm->AddHistogram(histClass, "Psi2A_Ft0cOccupancy", "", false, 200, 0.0, 20000.0, VarManager::kFT0COccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2A); + hm->AddHistogram(histClass, "Psi2B_Ft0cOccupancy", "", true, 200, 0.0, 20000.0, VarManager::kFT0COccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2B); + hm->AddHistogram(histClass, "Psi2C_Ft0cOccupancy", "", true, 200, 0.0, 20000.0, VarManager::kFT0COccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2C); + hm->AddHistogram(histClass, "Psi2APOS_Ft0cOccupancy", "", true, 200, 0.0, 20000.0, VarManager::kFT0COccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2APOS); + hm->AddHistogram(histClass, "Psi2ANEG_Ft0cOccupancy", "", true, 200, 0.0, 20000.0, VarManager::kFT0COccupancyInTimeRange, 100, -TMath::Pi() / 2, TMath::Pi() / 2, VarManager::kPsi2ANEG); + } } if (subGroupStr.Contains("mc")) { hm->AddHistogram(histClass, "MCVtxX_VtxX", "Vtx X (MC vs rec)", false, 100, -0.5, 0.5, VarManager::kVtxX, 100, -0.5, 0.5, VarManager::kMCVtxX); @@ -220,6 +254,10 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Q2X0A", "", false, 500, -10.0, 10.0, VarManager::kQ2X0A); hm->AddHistogram(histClass, "Q2Y0A", "", false, 500, -10.0, 10.0, VarManager::kQ2Y0A); + hm->AddHistogram(histClass, "Q2X0APOS", "", false, 500, -10.0, 10.0, VarManager::kQ2X0APOS); + hm->AddHistogram(histClass, "Q2Y0APOS", "", false, 500, -10.0, 10.0, VarManager::kQ2Y0APOS); + hm->AddHistogram(histClass, "Q2X0ANEG", "", false, 500, -10.0, 10.0, VarManager::kQ2X0ANEG); + hm->AddHistogram(histClass, "Q2Y0ANEG", "", false, 500, -10.0, 10.0, VarManager::kQ2Y0ANEG); hm->AddHistogram(histClass, "Q2X0B", "", false, 500, -10.0, 10.0, VarManager::kQ2X0B); hm->AddHistogram(histClass, "Q2Y0B", "", false, 500, -10.0, 10.0, VarManager::kQ2Y0B); hm->AddHistogram(histClass, "Q2X0C", "", false, 500, -10.0, 10.0, VarManager::kQ2X0C); @@ -236,6 +274,9 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Q2Y0B_Cent", "", true, 18, 0.0, 90.0, VarManager::kCentVZERO, 500, -10.0, 10.0, VarManager::kQ2Y0B); hm->AddHistogram(histClass, "Q2X0C_Cent", "", true, 18, 0.0, 90.0, VarManager::kCentVZERO, 500, -10.0, 10.0, VarManager::kQ2X0C); hm->AddHistogram(histClass, "Q2Y0C_Cent", "", true, 18, 0.0, 90.0, VarManager::kCentVZERO, 500, -10.0, 10.0, VarManager::kQ2Y0C); + hm->AddHistogram(histClass, "Q2X0A_Q2Y0A_CentFT0C", "", false, 18, 0.0, 90.0, VarManager::kCentFT0C, 500, -10.0, 10.0, VarManager::kQ2X0A, 500, -10.0, 10.0, VarManager::kQ2Y0A); + hm->AddHistogram(histClass, "Q2X0B_Q2Y0B_CentFT0C", "", false, 18, 0.0, 90.0, VarManager::kCentFT0C, 500, -10.0, 10.0, VarManager::kQ2X0B, 500, -10.0, 10.0, VarManager::kQ2Y0B); + hm->AddHistogram(histClass, "Q2X0C_Q2Y0C_CentFT0C", "", false, 18, 0.0, 90.0, VarManager::kCentFT0C, 500, -10.0, 10.0, VarManager::kQ2X0C, 500, -10.0, 10.0, VarManager::kQ2Y0C); hm->AddHistogram(histClass, "Q3X0A", "", false, 500, -10.0, 10.0, VarManager::kQ3X0A); hm->AddHistogram(histClass, "Q3Y0A", "", false, 500, -10.0, 10.0, VarManager::kQ3Y0A); hm->AddHistogram(histClass, "Q3X0B", "", false, 500, -10.0, 10.0, VarManager::kQ3X0B); @@ -263,6 +304,8 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Q3X0A_CentFT0C", "", false, 18, 0.0, 90.0, VarManager::kCentFT0C, 500, -10.0, 10.0, VarManager::kQ3X0A); hm->AddHistogram(histClass, "Q3Y0A_CentFT0C", "", false, 18, 0.0, 90.0, VarManager::kCentFT0C, 500, -10.0, 10.0, VarManager::kQ3Y0A); hm->AddHistogram(histClass, "Psi2A", "", false, 100, -2.0, 2.0, VarManager::kPsi2A); + hm->AddHistogram(histClass, "Psi2APOS", "", false, 100, -2.0, 2.0, VarManager::kPsi2APOS); + hm->AddHistogram(histClass, "Psi2ANEG", "", false, 100, -2.0, 2.0, VarManager::kPsi2ANEG); hm->AddHistogram(histClass, "Psi2B", "", false, 100, -2.0, 2.0, VarManager::kPsi2B); hm->AddHistogram(histClass, "Psi2C", "", false, 100, -2.0, 2.0, VarManager::kPsi2C); hm->AddHistogram(histClass, "Psi2A_CentFT0C", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 100, -2.0, 2.0, VarManager::kPsi2A); @@ -509,14 +552,14 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "TPCnSigPi_pIN", "TPC n-#sigma(#pi) vs pIN", false, nbins_pIN, pIN_bins, VarManager::kPin, nbins_nSigma, nSigma_bins, VarManager::kTPCnSigmaPi); hm->AddHistogram(histClass, "TPCnSigKa_pIN", "TPC n-#sigma(K) vs pIN", false, nbins_pIN, pIN_bins, VarManager::kPin, nbins_nSigma, nSigma_bins, VarManager::kTPCnSigmaKa); hm->AddHistogram(histClass, "TPCnSigPr_pIN", "TPC n-#sigma(p) vs pIN", false, nbins_pIN, pIN_bins, VarManager::kPin, nbins_nSigma, nSigma_bins, VarManager::kTPCnSigmaPr); - if (subGroupStr.Contains("tpcpid_fine_Corr")) { + if (subGroupStr.Contains("tpcpid_fine_corr")) { hm->AddHistogram(histClass, "TPCnSigEl_Corr_pIN", "TPC n-#sigma(e) Corr. vs pIN", false, nbins_pIN, pIN_bins, VarManager::kPin, nbins_nSigma, nSigma_bins, VarManager::kTPCnSigmaEl_Corr); hm->AddHistogram(histClass, "TPCnSigPi_Corr_pIN", "TPC n-#sigma(#pi) Corr. vs pIN", false, nbins_pIN, pIN_bins, VarManager::kPin, nbins_nSigma, nSigma_bins, VarManager::kTPCnSigmaPi_Corr); hm->AddHistogram(histClass, "TPCnSigPr_Corr_pIN", "TPC n-#sigma(p) Corr. vs pIN", false, nbins_pIN, pIN_bins, VarManager::kPin, nbins_nSigma, nSigma_bins, VarManager::kTPCnSigmaPr_Corr); } } else { - hm->AddHistogram(histClass, "TPCdedx_pIN", "TPC dE/dx vs pIN", false, 100, 0.0, 10.0, VarManager::kPin, 200, 0.0, 200., VarManager::kTPCsignal); - hm->AddHistogram(histClass, "TPCnSigEle_pIN", "TPC n-#sigma(e) vs pIN", false, 100, 0.0, 10.0, VarManager::kPin, 100, -5.0, 5.0, VarManager::kTPCnSigmaEl); + hm->AddHistogram(histClass, "TPCdedx_pIN", "TPC dE/dx vs pIN", false, 100, 0.0, 20.0, VarManager::kPin, 150, 0.0, 150., VarManager::kTPCsignal); + hm->AddHistogram(histClass, "TPCnSigEle_pIN", "TPC n-#sigma(e) vs pIN", false, 100, 0.0, 20.0, VarManager::kPin, 100, -5.0, 5.0, VarManager::kTPCnSigmaEl); hm->AddHistogram(histClass, "TPCnSigEle_occupancy", "TPC n-#sigma(e) vs occupancy", false, 200, 0., 20000., VarManager::kTrackOccupancyInTimeRange, 100, -5.0, 5.0, VarManager::kTPCnSigmaEl); hm->AddHistogram(histClass, "TPCnSigEle_timeFromSOR", "TPC n-#sigma(e) vs time from SOR", true, 10000, 0.0, 1000.0, VarManager::kTimeFromSOR, 10, -5.0, 5.0, VarManager::kTPCnSigmaEl); hm->AddHistogram(histClass, "TPCnSigEle_occupTPCcontribLongA", "TPC n-#sigma(e) vs pileup n-contrib, long time range A-side", false, 20, 0.0, 10000.0, VarManager::kNTPCcontribLongA, 200, -5.0, 5.0, VarManager::kTPCnSigmaEl); @@ -544,12 +587,18 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "TPCnSigPr_pIN", "TPC n-#sigma(p) vs pIN", false, 100, 0.0, 10.0, VarManager::kPin, 100, -5.0, 5.0, VarManager::kTPCnSigmaPr); hm->AddHistogram(histClass, "TPCnSigPr_timeFromSOR", "TPC n-#sigma(p) vs time from SOR", true, 10000, 0.0, 1000.0, VarManager::kTimeFromSOR, 10, -5.0, 5.0, VarManager::kTPCnSigmaPr); hm->AddHistogram(histClass, "TPCnSigPr_occupancy", "TPC n-#sigma(p) vs. occupancy", false, 200, 0., 20000., VarManager::kTrackOccupancyInTimeRange, 100, -5.0, 5.0, VarManager::kTPCnSigmaPr); - if (subGroupStr.Contains("tpcpid_Corr")) { + if (subGroupStr.Contains("tpcpid_corr")) { hm->AddHistogram(histClass, "TPCnSigEl_Corr_pIN", "TPC n-#sigma(e) Corr. vs pIN", false, 100, 0.0, 10.0, VarManager::kPin, 100, -5.0, 5.0, VarManager::kTPCnSigmaEl_Corr); hm->AddHistogram(histClass, "TPCnSigPi_Corr_pIN", "TPC n-#sigma(#pi) Corr. vs pIN", false, 100, 0.0, 10.0, VarManager::kPin, 100, -5.0, 5.0, VarManager::kTPCnSigmaPi_Corr); hm->AddHistogram(histClass, "TPCnSigKa_Corr_pIN", "TPC n-#sigma(K) Corr. vs pIN", false, 100, 0.0, 10.0, VarManager::kPin, 100, -5.0, 5.0, VarManager::kTPCnSigmaKa_Corr); hm->AddHistogram(histClass, "TPCnSigPr_Corr_pIN", "TPC n-#sigma(p) Corr. vs pIN", false, 100, 0.0, 10.0, VarManager::kPin, 100, -5.0, 5.0, VarManager::kTPCnSigmaPr_Corr); } + if (subGroupStr.Contains("tpcpidvspt")) { + hm->AddHistogram(histClass, "TPCnSigEl_Pt", "TPC n-#sigma(e). vs Pt", false, 200, 0.0, 20.0, VarManager::kPt, 100, -5.0, 5.0, VarManager::kTPCnSigmaEl); + hm->AddHistogram(histClass, "TPCnSigPi_Pt", "TPC n-#sigma(#pi). vs Pt", false, 200, 0.0, 20.0, VarManager::kPt, 100, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigKa_Pt", "TPC n-#sigma(K). vs Pt", false, 200, 0.0, 20.0, VarManager::kPt, 100, -5.0, 5.0, VarManager::kTPCnSigmaKa); + hm->AddHistogram(histClass, "TPCnSigPr_Pt", "TPC n-#sigma(p). vs Pt", false, 200, 0.0, 20.0, VarManager::kPt, 100, -5.0, 5.0, VarManager::kTPCnSigmaPr); + } } } if (subGroupStr.Contains("postcalib")) { @@ -824,6 +873,26 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "tpcNSigmaKa_tofNSigmaKa", "", false, 200, -10., 10., VarManager::kTPCnSigmaKa, 200, -10., 10., VarManager::kTOFnSigmaKa); hm->AddHistogram(histClass, "tpcNSigmaPi_tofNSigmaPi", "", false, 200, -10., 10., VarManager::kTPCnSigmaPi, 200, -10., 10., VarManager::kTOFnSigmaPi); } + if (subGroupStr.Contains("singlemucumulant")) { + double PtBinEdges[67]; // 0-30GeV/c + for (int i = 0; i < 67; i++) { + if (i <= 39) { + PtBinEdges[i] = i / 10.; + } else { + PtBinEdges[i] = (i - 40) * 1. + 4.; + } + } + + double CentBinEdges[19]; // 0-90% + for (int i = 0; i < 19; i++) { + CentBinEdges[i] = i * 5; + } + + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr2REFsingle", "", true, 66, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR2REFbysinglemu, "", "", "", VarManager::kNothing, VarManager::kM11REFoverMpsingle); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr4REFsingle", "", true, 66, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR4REFbysinglemu, "", "", "", VarManager::kNothing, VarManager::kM1111REFoverMpsingle); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr2POIsingle", "", true, 66, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR2POIsingle, "", "", "", VarManager::kNothing, VarManager::kM01POIoverMpsingle); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr4POIsingle", "", true, 66, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR4POIsingle, "", "", "", VarManager::kNothing, VarManager::kM0111POIoverMpsingle); + } } if (!groupStr.CompareTo("mctruth_triple")) { @@ -854,6 +923,15 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Mass", "", false, 500, 0.0, 5.0, VarManager::kMass); hm->AddHistogram(histClass, "Eta_Pt", "", false, 40, -2.0, 2.0, VarManager::kEta, 200, 0.0, 20.0, VarManager::kPt); hm->AddHistogram(histClass, "Phi_Eta", "#phi vs #eta distribution", false, 200, -5.0, 5.0, VarManager::kEta, 200, -2. * o2::constants::math::PI, 2. * o2::constants::math::PI, VarManager::kPhi); + int varspTHE[3] = {VarManager::kMCPt, VarManager::kMCCosThetaHE, VarManager::kMCPhiHE}; + int varspTCS[3] = {VarManager::kMCPt, VarManager::kMCCosThetaCS, VarManager::kMCPhiCS}; + int varspTPP[3] = {VarManager::kMCPt, VarManager::kMCCosThetaPP, VarManager::kMCPhiPP}; + int binspT[3] = {40, 20, 20}; + double xminpT[3] = {0., -1., -3.14}; + double xmaxpT[3] = {20., 1., +3.14}; + hm->AddHistogram(histClass, "Pt_cosThetaHE_phiHE", "", 3, varspTHE, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Pt_cosThetaCS_phiCS", "", 3, varspTCS, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Pt_cosThetaPP_phiPP", "", 3, varspTPP, binspT, xminpT, xmaxpT, 0, -1, kFALSE); } if (!groupStr.CompareTo("mctruth_quad")) { hm->AddHistogram(histClass, "hMass_defaultDileptonMass", "", false, 1000, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass); @@ -862,6 +940,7 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "hQ", "", false, 150, 0.0, 3.0, VarManager::kQ); hm->AddHistogram(histClass, "hDeltaR1", "", false, 100, 0.0, 10.0, VarManager::kDeltaR1); hm->AddHistogram(histClass, "hDeltaR2", "", false, 100, 0.0, 10.0, VarManager::kDeltaR2); + hm->AddHistogram(histClass, "hDeltaR", "", false, 100, 0.0, 10.0, VarManager::kDeltaR); hm->AddHistogram(histClass, "hDiTrackMass", "", false, 300, 0.0, 3.0, VarManager::kDitrackMass); hm->AddHistogram(histClass, "hMCPt_MCRap", "", false, 200, 0.0, 20.0, VarManager::kMCPt, 100, -2.0, 2.0, VarManager::kMCY); hm->AddHistogram(histClass, "hMCPhi", "", false, 100, -TMath::Pi(), TMath::Pi(), VarManager::kMCPhi); @@ -870,14 +949,35 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "PtMC", "MC pT", false, 200, 0.0, 20.0, VarManager::kMCPt); hm->AddHistogram(histClass, "EtaMC", "MC #eta", false, 50, -5.0, 5.0, VarManager::kMCEta); hm->AddHistogram(histClass, "PhiMC", "MC #phi", false, 50, -6.3, 6.3, VarManager::kMCPhi); - hm->AddHistogram(histClass, "MCY", "MC y", false, 50, -5.0, 5.0, VarManager::kMCY); + hm->AddHistogram(histClass, "YMC", "MC y", false, 50, -5.0, 5.0, VarManager::kMCY); + hm->AddHistogram(histClass, "CentFT0CMC", "MC Cent. FT0C", false, 18, 0., 90., VarManager::kCentFT0C); + hm->AddHistogram(histClass, "PtMC_YMC", "MC pT vs MC y", false, 120, 0.0, 30.0, VarManager::kMCPt, 1000, -5.0, 5.0, VarManager::kMCY); hm->AddHistogram(histClass, "EtaMC_PtMC", "", false, 40, -2.0, 2.0, VarManager::kMCEta, 200, 0.0, 20.0, VarManager::kMCPt); hm->AddHistogram(histClass, "VzMC", "MC vz", false, 100, -15.0, 15.0, VarManager::kMCVz); hm->AddHistogram(histClass, "VzMC_VtxZMC", "MC vz vs MC vtxZ", false, 50, -15.0, 15.0, VarManager::kMCVz, 50, -15.0, 15.0, VarManager::kMCVtxZ); hm->AddHistogram(histClass, "Weight", "", false, 50, 0.0, 5.0, VarManager::kMCParticleWeight); + hm->AddHistogram(histClass, "MCImpPar_CentFT0CMC", "MC impact param vs MC Cent. FT0C", false, 20, 0.0, 20.0, VarManager::kMCEventImpParam, 100, 0.0, 100.0, VarManager::kCentFT0C); } if (!groupStr.CompareTo("pair")) { + if (subGroupStr.Contains("cepf")) { + hm->AddHistogram(histClass, "Mass", "", false, 300, 0.0, 12.0, VarManager::kMass); + hm->AddHistogram(histClass, "Mass_Pt", "", false, 300, 0.0, 12.0, VarManager::kMass, 10, 0.0, 20.0, VarManager::kPt); + hm->AddHistogram(histClass, "Mass_Y", "", false, 300, 0.0, 12.0, VarManager::kMass, 100, -5.0, 5.0, VarManager::kRap); + hm->AddHistogram(histClass, "Y_Pt", "", false, 100, -5.0, 5.0, VarManager::kRap, 20, 0.0, 20.0, VarManager::kPt); + } + if (subGroupStr.Contains("mult_pvcontrib")) { + hm->AddHistogram(histClass, "Mass_VtxNcontribReal", "Mass vs VtxNcontribReal", false, 200, 2.0, 5.0, VarManager::kMass, 150, 0, 150.0, VarManager::kVtxNcontribReal); + hm->AddHistogram(histClass, "Mass_MultNTracksPVetaHalf", "Mass vs MultNTracksPVetaHalf", false, 200, 2.0, 5.0, VarManager::kMass, 150, 0, 150.0, VarManager::kMultNTracksPVetaHalf); + hm->AddHistogram(histClass, "Mass_MultNTracksPVeta1", "Mass vs MultNTracksPVeta1", false, 200, 2.0, 5.0, VarManager::kMass, 150, 0, 150.0, VarManager::kMultNTracksPVeta1); + } + if (subGroupStr.Contains("dimuon_fwdmult")) { + hm->AddHistogram(histClass, "Mass_MultFV0A", "Mass vs MultFV0A", false, 200, 2.0, 5.0, VarManager::kMass, 1000, 0, 25000.0, VarManager::kMultFV0A); + hm->AddHistogram(histClass, "Mass_MultFT0A", "Mass vs MultFT0A", false, 200, 2.0, 5.0, VarManager::kMass, 1000, 0, 25000.0, VarManager::kMultFT0A); + hm->AddHistogram(histClass, "Mass_MultFT0C", "Mass vs MultFT0C", false, 200, 2.0, 5.0, VarManager::kMass, 1000, 0, 25000.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "Mass_MultFDDA", "Mass vs MultFDDA", false, 200, 2.0, 5.0, VarManager::kMass, 1000, 0, 25000.0, VarManager::kMultFDDA); + hm->AddHistogram(histClass, "Mass_MultFDDC", "Mass vs MultFDDC", false, 200, 2.0, 5.0, VarManager::kMass, 1000, 0, 25000.0, VarManager::kMultFDDC); + } if (subGroupStr.Contains("barrel")) { hm->AddHistogram(histClass, "Mass", "", false, 500, 0.0, 5.0, VarManager::kMass); hm->AddHistogram(histClass, "Mass_HighRange", "", false, 375, 0.0, 15.0, VarManager::kMass); @@ -896,6 +996,7 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h } hm->AddHistogram(histClass, "Mass_PtFine", "", false, 75, massBins, VarManager::kMass, 69, ptBins, VarManager::kPt); hm->AddHistogram(histClass, "Eta_Pt", "", false, 40, -2.0, 2.0, VarManager::kEta, 40, 0.0, 20.0, VarManager::kPt); + hm->AddHistogram(histClass, "Y_Pt", "", false, 40, -2.0, 2.0, VarManager::kRap, 40, 0.0, 20.0, VarManager::kPt); hm->AddHistogram(histClass, "Mass_VtxZ", "", true, 30, -15.0, 15.0, VarManager::kVtxZ, 500, 0.0, 5.0, VarManager::kMass); if (subGroupStr.Contains("pbpb")) { hm->AddHistogram(histClass, "Mass_CentFT0C", "", false, 125, 0.0, 5.0, VarManager::kMass, 20, 0.0, 100.0, VarManager::kCentFT0C); @@ -905,16 +1006,43 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h if (subGroupStr.Contains("mult")) { hm->AddHistogram(histClass, "Mass_Pt_MultFV0A", "", false, 200, 0.0, 5.0, VarManager::kMass, 40, 0.0, 40.0, VarManager::kPt, 100, 0.0, 25000.0, VarManager::kMultFV0A); hm->AddHistogram(histClass, "Mass_VtxNcontribReal", "Mass vs VtxNcontribReal", false, 200, 0.0, 5.0, VarManager::kMass, 200, 0, 200.0, VarManager::kVtxNcontribReal); + hm->AddHistogram(histClass, "Mass_VtxNcontribReal_VtxZ", "Mass vs VtxNcontribReal vs VtxZ", false, 200, 2.0, 5.0, VarManager::kMass, 150, 0, 150.0, VarManager::kVtxNcontribReal, 20, -10.0, 10.0, VarManager::kVtxZ); + hm->AddHistogram(histClass, "VtxZ_VtxNcontribReal", "VtxZ vs VtxNcontribReal", false, 240, -12.0, 12.0, VarManager::kVtxZ, 200, 0, 200.0, VarManager::kVtxNcontribReal); } if (subGroupStr.Contains("polarization")) { - hm->AddHistogram(histClass, "cosThetaHE", "", false, 100, -1., 1., VarManager::kCosThetaHE); - hm->AddHistogram(histClass, "cosThetaCS", "", false, 100, -1., 1., VarManager::kCosThetaCS); - hm->AddHistogram(histClass, "PhiHE", "", false, 100, -o2::constants::math::PI, o2::constants::math::PI, VarManager::kPhiHE); - hm->AddHistogram(histClass, "PhiCS", "", false, 100, -o2::constants::math::PI, o2::constants::math::PI, VarManager::kPhiCS); - hm->AddHistogram(histClass, "Mass_Pt_cosThetaHE", "", false, 100, 1.0, 5.0, VarManager::kMass, 250, 0.0, 25.0, VarManager::kPt, 40, -1., 1., VarManager::kCosThetaHE); - hm->AddHistogram(histClass, "Mass_Pt_cosThetaCS", "", false, 100, 1.0, 5.0, VarManager::kMass, 250, 0.0, 25.0, VarManager::kPt, 40, -1., 1., VarManager::kCosThetaCS); - hm->AddHistogram(histClass, "Mass_Pt_PhiHE", "", false, 100, 1.0, 5.0, VarManager::kMass, 250, 0.0, 25.0, VarManager::kPt, 40, -o2::constants::math::PI, o2::constants::math::PI, VarManager::kPhiHE); - hm->AddHistogram(histClass, "Mass_Pt_PhiCS", "", false, 100, 1.0, 5.0, VarManager::kMass, 250, 0.0, 25.0, VarManager::kPt, 40, -o2::constants::math::PI, o2::constants::math::PI, VarManager::kPhiCS); + if (subGroupStr.Contains("helicity")) { + hm->AddHistogram(histClass, "cosThetaHE", "", false, 100, -1., 1., VarManager::kCosThetaHE); + hm->AddHistogram(histClass, "phiHE", "", false, 100, 0, 2 * o2::constants::math::PI, VarManager::kPhiHE); + hm->AddHistogram(histClass, "phitildeHE", "", false, 100, 0, 2 * o2::constants::math::PI, VarManager::kPhiTildeHE); + hm->AddHistogram(histClass, "Mass_Pt_CosThetaHE", "", false, 100, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, -1., 1., VarManager::kCosThetaHE); + hm->AddHistogram(histClass, "Mass_Pt_PhiHE", "", false, 100, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, 0., 2 * o2::constants::math::PI, VarManager::kPhiHE); + hm->AddHistogram(histClass, "Mass_Pt_PhiTildeHE", "", false, 100, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, 0., 2 * o2::constants::math::PI, VarManager::kPhiTildeHE); + } + if (subGroupStr.Contains("collins-soper")) { + hm->AddHistogram(histClass, "cosThetaCS", "", false, 100, -1., 1., VarManager::kCosThetaCS); + hm->AddHistogram(histClass, "phiCS", "", false, 100, 0, 2 * o2::constants::math::PI, VarManager::kPhiCS); + hm->AddHistogram(histClass, "phitildeCS", "", false, 100, 0, 2 * o2::constants::math::PI, VarManager::kPhiTildeCS); + hm->AddHistogram(histClass, "Mass_Pt_CosThetaCS", "", false, 100, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, -1., 1., VarManager::kCosThetaCS); + hm->AddHistogram(histClass, "Mass_Pt_PhiCS", "", false, 100, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, 0., 2 * o2::constants::math::PI, VarManager::kPhiCS); + hm->AddHistogram(histClass, "Mass_Pt_PhiTildeCS", "", false, 100, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, 0., 2 * o2::constants::math::PI, VarManager::kPhiTildeCS); + } + if (subGroupStr.Contains("production")) { + hm->AddHistogram(histClass, "cosThetaPP", "", false, 100, -1., 1., VarManager::kCosThetaPP); + hm->AddHistogram(histClass, "phiPP", "", false, 100, 0, 2 * o2::constants::math::PI, VarManager::kPhiPP); + hm->AddHistogram(histClass, "phitildePP", "", false, 100, 0, 2 * o2::constants::math::PI, VarManager::kPhiTildePP); + hm->AddHistogram(histClass, "Mass_Pt_CosThetaPP", "", false, 100, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, -1., 1., VarManager::kCosThetaPP); + hm->AddHistogram(histClass, "Mass_Pt_PhiPP", "", false, 100, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, 0., 2 * o2::constants::math::PI, VarManager::kPhiPP); + hm->AddHistogram(histClass, "Mass_Pt_PhiTildePP", "", false, 100, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, 0., 2 * o2::constants::math::PI, VarManager::kPhiTildePP); + } + if (subGroupStr.Contains("random")) { + hm->AddHistogram(histClass, "cosThetaRM", "", false, 100, -1., 1., VarManager::kCosThetaRM); + hm->AddHistogram(histClass, "Mass_Pt_CosThetaRM", "", false, 200, 1.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt, 20, -1., 1., VarManager::kCosThetaRM); + } + } + if (subGroupStr.Contains("globalpolarization")) { + hm->AddHistogram(histClass, "CosThetaStarTPC", "", false, 100, -1.0, 1.0, VarManager::kCosThetaStarTPC); + hm->AddHistogram(histClass, "CosThetaStarFT0A", "", false, 100, -1.0, 1.0, VarManager::kCosThetaStarFT0A); + hm->AddHistogram(histClass, "CosThetaStarFT0C", "", false, 100, -1.0, 1.0, VarManager::kCosThetaStarFT0C); } if (subGroupStr.Contains("upsilon")) { hm->AddHistogram(histClass, "MassUpsilon_Pt", "", false, 500, 7.0, 12.0, VarManager::kMass, 400, 0.0, 40.0, VarManager::kPt); @@ -938,11 +1066,30 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "LxyzProj", "", false, 1000, -1.0, 1.0, VarManager::kVertexingLxyzProjected); hm->AddHistogram(histClass, "TauzProj", "", false, 1000, -0.03, 0.03, VarManager::kVertexingTauzProjected); hm->AddHistogram(histClass, "TauxyProj", "", false, 1000, -0.03, 0.03, VarManager::kVertexingTauxyProjected); + hm->AddHistogram(histClass, "TauxyProj_Mass_Pt", "", false, 50, 2.0, 4.0, VarManager::kMass, 10, 0.0, 20.0, VarManager::kPt, 1000, -0.03, 0.03, VarManager::kVertexingTauxyProjected); + hm->AddHistogram(histClass, "TauzProj_Mass_Pt", "", false, 50, 2.0, 4.0, VarManager::kMass, 10, 0.0, 20.0, VarManager::kPt, 1000, -0.03, 0.03, VarManager::kVertexingTauzProjected); hm->AddHistogram(histClass, "TauxyzProj", "", false, 1000, -0.03, 0.03, VarManager::kVertexingTauxyzProjected); hm->AddHistogram(histClass, "LxyProj_Pt", "", false, 10, 0.0, 20.0, VarManager::kPt, 1000, -1.0, 1.0, VarManager::kVertexingLxyProjected); hm->AddHistogram(histClass, "LxyProj_Mass_Pt", "", false, 50, 2.0, 4.0, VarManager::kMass, 10, 0.0, 20.0, VarManager::kPt, 1000, -1.0, 1.0, VarManager::kVertexingLxyProjected); hm->AddHistogram(histClass, "LzProj_Mass_Pt", "", false, 50, 2.0, 4.0, VarManager::kMass, 10, 0.0, 20.0, VarManager::kPt, 1000, -1.0, 1.0, VarManager::kVertexingLzProjected); hm->AddHistogram(histClass, "CosPointingAngle", "", false, 200, -1.0, 1.0, VarManager::kCosPointingAngle); + hm->AddHistogram(histClass, "VtxingChi2PCA", "", false, 100, 0.0, 10.0, VarManager::kVertexingChi2PCA); + } + if (subGroupStr.Contains("tauxy-midy-pol-he")) { + int varspTHE[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaHE, VarManager::kVertexingTauxyProjectedPoleJPsiMass}; + int binspT[4] = {50, 10, 20, 1000}; + double xminpT[4] = {2., 0., -1., -0.03}; + double xmaxpT[4] = {4., 20., 1., 0.03}; + hm->AddHistogram(histClass, "Tauxy_Mass_Pt_CosthetaHE", "", 4, varspTHE, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + } + + if (subGroupStr.Contains("tauxy-midy-pol-rand")) { + int varspTRand[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaRM, VarManager::kVertexingTauxyProjectedPoleJPsiMass}; + + int binspT[4] = {50, 10, 20, 1000}; + double xminpT[4] = {2., 0., -1., -0.03}; + double xmaxpT[4] = {4., 20., 1., 0.03}; + hm->AddHistogram(histClass, "Tauxy_Mass_Pt_CosthetaRand", "", 4, varspTRand, binspT, xminpT, xmaxpT, 0, -1, kFALSE); } if (subGroupStr.Contains("kalman-filter")) { @@ -1026,6 +1173,11 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h } else if (subGroupStr.Contains("dimuon")) { hm->AddHistogram(histClass, "Mass_Pt", "", false, 750, 0.0, 15.0, VarManager::kMass, 120, 0.0, 30.0, VarManager::kPt); hm->AddHistogram(histClass, "Mass_Rapidity", "", false, 750, 0.0, 15.0, VarManager::kMass, 150, 2.5, 4.0, VarManager::kRap); + hm->AddHistogram(histClass, "Mass_Phi", "", false, 750, 0.0, 15.0, VarManager::kMass, 180, constants::math::PI, 2 * constants::math::PI, VarManager::kPhi); + if (subGroupStr.Contains("dimuon-tag-and-probe")) { + hm->AddHistogram(histClass, "Mass_PtProbe", "mass vs probe pT", false, 750, 0.0, 15.0, VarManager::kMass, 120, 0.0, 30.0, VarManager::kPt2); // Warning: in the tag-and-probe task t2 is always the probe + hm->AddHistogram(histClass, "Mass_EtaProbe", "mass vs probe eta", false, 750, 0.0, 15.0, VarManager::kMass, 120, 0.0, 30.0, VarManager::kEta2); // Warning: in the tag-and-probe task t2 is always the probe + } if (subGroupStr.Contains("dimuon-multi-diff")) { int varsKine[3] = {VarManager::kMass, VarManager::kPt, VarManager::kRap}; int binsKine[3] = {250, 120, 60}; @@ -1033,6 +1185,13 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h double xmaxKine[3] = {5.0, 30.0, 4.0}; hm->AddHistogram(histClass, "Mass_Pt_Rapidity", "", 3, varsKine, binsKine, xminKine, xmaxKine, 0, -1, kFALSE); } + if (subGroupStr.Contains("dimuon-high-mass-multi-diff")) { + int varsKine[3] = {VarManager::kMass, VarManager::kPt, VarManager::kRap}; + int binsKine[3] = {250, 120, 60}; + double xminKine[3] = {7.0, 0.0, 2.5}; + double xmaxKine[3] = {12.0, 30.0, 4.0}; + hm->AddHistogram(histClass, "Mass_Pt_Rapidity", "", 3, varsKine, binsKine, xminKine, xmaxKine, 0, -1, kFALSE); + } if (subGroupStr.Contains("dimuon-centr")) { hm->AddHistogram(histClass, "Mass_CentFT0C", "", false, 750, 0.0, 15.0, VarManager::kMass, 100, 0., 100., VarManager::kCentFT0C); } @@ -1052,50 +1211,146 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "U2Q2_CentFT0C_ev2", "mass vs. centrality vs. U2Q2_event2", false, 125, 0.0, 5.0, VarManager::kMass, 9, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kU2Q2Ev2); } if (subGroupStr.Contains("metest")) { - hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V2ME_SP", "Mass_Pt_CentFT0C_V2ME_SP", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 90, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kV2ME_SP, VarManager::kWV2ME_SP); - hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V2ME_EP", "Mass_Pt_CentFT0C_V2ME_EP", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 90, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kV2ME_EP, VarManager::kWV2ME_EP); + double MassBinEdges[251]; // 0-5GeV/c2 + for (int i = 0; i < 251; i++) { + MassBinEdges[i] = i * 0.02; + } + + double PtBinEdges[49]; // 0-20GeV/c + for (int i = 0; i < 49; i++) { + if (i <= 9) { + PtBinEdges[i] = i / 10.; + } else { + PtBinEdges[i] = (i - 10) * 0.5 + 1.; + } + } + + double CentBinEdges[19]; // 0-90% + for (int i = 0; i < 19; i++) { + CentBinEdges[i] = i * 5; + } + + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V2ME_SP", "Mass_Pt_CentFT0C_V2ME_SP", true, 250, MassBinEdges, VarManager::kMass, 48, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, "", "", "", VarManager::kV2ME_SP, VarManager::kWV2ME_SP); + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V2ME_EP", "Mass_Pt_CentFT0C_V2ME_EP", true, 250, MassBinEdges, VarManager::kMass, 48, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, "", "", "", VarManager::kV2ME_EP, VarManager::kWV2ME_EP); + } + if (subGroupStr.Contains("cumulantme")) { + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M11REFoverMpME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM11REFoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M1111REFoverMpME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM1111REFoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M01POIoverMpME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM01POIoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M0111POIoverMpME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM0111POIoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REFME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2REFbydimuonsME, VarManager::kM11REFoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4REFME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR4REFbydimuonsME, VarManager::kM1111REFoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2POIME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2POIME, VarManager::kM01POIoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4POIME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR4POIME, VarManager::kM0111POIoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V22ME", "Mass_Pt_CentFT0C_V22ME", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 90, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kV22ME, VarManager::kWV22ME); + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V24ME", "Mass_Pt_CentFT0C_V24ME", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 90, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kV24ME, VarManager::kWV24ME); + } + if (subGroupStr.Contains("cumulantme1")) { + double MassBinEdges[251]; // 0-5GeV/c2 + for (int i = 0; i < 251; i++) { + MassBinEdges[i] = i * 0.02; + } + + double PtBinEdges[67]; // 0-30GeV/c + for (int i = 0; i < 67; i++) { + if (i <= 39) { + PtBinEdges[i] = i / 10.; + } else { + PtBinEdges[i] = (i - 40) * 1. + 4.; + } + } + + double CentBinEdges[19]; // 0-90% + for (int i = 0; i < 19; i++) { + CentBinEdges[i] = i * 5; + } + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V22ME", "Mass_Pt_CentFT0C_V22ME", true, 250, MassBinEdges, VarManager::kMass, 66, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, "", "", "", VarManager::kV22ME, VarManager::kWV22ME); + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V24ME", "Mass_Pt_CentFT0C_V24ME", true, 250, MassBinEdges, VarManager::kMass, 66, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, "", "", "", VarManager::kV24ME, VarManager::kWV24ME); + } + if (subGroupStr.Contains("cumulantme2")) { + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M11REFoverMpME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM11REFoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M1111REFoverMpME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM1111REFoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M01POIoverMpME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM01POIoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M0111POIoverMpME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM0111POIoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REFME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2REFbydimuonsME, VarManager::kM11REFoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4REFME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR4REFbydimuonsME, VarManager::kM1111REFoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2POIME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2POIME, VarManager::kM01POIoverMpME); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4POIME", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 9, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR4POIME, VarManager::kM0111POIoverMpME); } if (subGroupStr.Contains("dimuon-polarization-he")) { + int varspTHE[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaHE, VarManager::kPhiHE}; + int binspT[4] = {100, 40, 20, 20}; + double xminpT[4] = {1., 0., -1., -3.14}; + double xmaxpT[4] = {5., 20., 1., +3.14}; + hm->AddHistogram(histClass, "Mass_Pt_cosThetaHE_phiHE", "", 4, varspTHE, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + } + if (subGroupStr.Contains("dimuon-polarization-cs")) { + int varspTCS[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaCS, VarManager::kPhiCS}; + int binspT[4] = {100, 40, 20, 20}; + double xminpT[4] = {1., 0., -1., -3.14}; + double xmaxpT[4] = {5., 20., 1., +3.14}; + hm->AddHistogram(histClass, "Mass_Pt_cosThetaCS_phiCS", "", 4, varspTCS, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + } + if (subGroupStr.Contains("dimuon-polarization-pp")) { + int varspTPP[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaPP, VarManager::kPhiPP}; + int binspT[4] = {100, 40, 20, 20}; + double xminpT[4] = {1., 0., -1., -3.14}; + double xmaxpT[4] = {5., 20., 1., +3.14}; + hm->AddHistogram(histClass, "Mass_Pt_cosThetaPP_phiPP", "", 4, varspTPP, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + } + if (subGroupStr.Contains("dimuon-polarization-lowmass-pp")) { + int varspTPP[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaPP, VarManager::kPhiPP}; + int varsrapPP[4] = {VarManager::kMass, VarManager::kRap, VarManager::kCosThetaPP, VarManager::kPhiPP}; + int binspT[4] = {100, 20, 20, 20}; + int binsy[4] = {100, 10, 20, 20}; + double xminpT[4] = {0.2, 0., -1., -3.14}; + double xmaxpT[4] = {1.5, 20., 1., +3.14}; + double xminy[4] = {0.2, 2.5, -1., -3.14}; + double xmaxy[4] = {1.5, 4.0, 1., +3.14}; + hm->AddHistogram(histClass, "Mass_Pt_cosThetaPP_phiPP", "", 4, varspTPP, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Mass_y_cosThetaPP_phiPP", "", 4, varsrapPP, binsy, xminy, xmaxy, 0, -1, kFALSE); + } + if (subGroupStr.Contains("upsilon-polarization-he")) { int varspTHE[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaHE, VarManager::kPhiHE}; int varsrapHE[4] = {VarManager::kMass, VarManager::kRap, VarManager::kCosThetaHE, VarManager::kPhiHE}; int binspT[4] = {100, 20, 20, 20}; int binsy[4] = {100, 10, 20, 20}; double xminpT[4] = {1., 0., -1., -3.14}; - double xmaxpT[4] = {5., 20., 1., +3.14}; + double xmaxpT[4] = {15., 20., 1., +3.14}; double xminy[4] = {1., 2.5, -1., -3.14}; - double xmaxy[4] = {5., 4.0, 1., +3.14}; + double xmaxy[4] = {15., 4.0, 1., +3.14}; hm->AddHistogram(histClass, "Mass_Pt_cosThetaHE_phiHE", "", 4, varspTHE, binspT, xminpT, xmaxpT, 0, -1, kFALSE); hm->AddHistogram(histClass, "Mass_y_cosThetaHE_phiHE", "", 4, varsrapHE, binsy, xminy, xmaxy, 0, -1, kFALSE); } - if (subGroupStr.Contains("dimuon-polarization-cs")) { + if (subGroupStr.Contains("upsilon-polarization-cs")) { int varspTCS[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaCS, VarManager::kPhiCS}; int varsrapCS[4] = {VarManager::kMass, VarManager::kRap, VarManager::kCosThetaCS, VarManager::kPhiCS}; int binspT[4] = {100, 20, 20, 20}; int binsy[4] = {100, 10, 20, 20}; double xminpT[4] = {1., 0., -1., -3.14}; - double xmaxpT[4] = {5., 20., 1., +3.14}; + double xmaxpT[4] = {15., 20., 1., +3.14}; double xminy[4] = {1., 2.5, -1., -3.14}; - double xmaxy[4] = {5., 4.0, 1., +3.14}; + double xmaxy[4] = {15., 4.0, 1., +3.14}; hm->AddHistogram(histClass, "Mass_Pt_cosThetaCS_phiCS", "", 4, varspTCS, binspT, xminpT, xmaxpT, 0, -1, kFALSE); hm->AddHistogram(histClass, "Mass_y_cosThetaCS_phiCS", "", 4, varsrapCS, binsy, xminy, xmaxy, 0, -1, kFALSE); } if (subGroupStr.Contains("dimuon-polarization-vp")) { - int varspTCS[3] = {VarManager::kMass, VarManager::kPt, VarManager::kPhiVP}; - int varsrapCS[3] = {VarManager::kMass, VarManager::kRap, VarManager::kPhiVP}; - int binspT[3] = {100, 20, 24}; - int binsy[3] = {100, 10, 24}; - double xminpT[3] = {1., 0., 0.}; - double xmaxpT[3] = {5., 20., +3.14}; - double xminy[3] = {1., 2.5, 0.}; - double xmaxy[3] = {5., 4.0, +3.14}; - hm->AddHistogram(histClass, "Mass_Pt_phiVP", "", 3, varspTCS, binspT, xminpT, xmaxpT, 0, -1, kFALSE); - hm->AddHistogram(histClass, "Mass_y_phiVP", "", 3, varsrapCS, binsy, xminy, xmaxy, 0, -1, kFALSE); + int varspTVP[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosPhiVP, VarManager::kPhiVP}; + int varsrapVP[4] = {VarManager::kMass, VarManager::kRap, VarManager::kCosPhiVP, VarManager::kPhiVP}; + int binspT[4] = {100, 20, 24, 24}; + int binsy[4] = {100, 10, 24, 24}; + double xminpT[4] = {1., 0., -1., 0.}; + double xmaxpT[4] = {5., 20., 1., +3.14}; + double xminy[4] = {1., 2.5, -1., 0.}; + double xmaxy[4] = {5., 4.0, 1., +3.14}; + hm->AddHistogram(histClass, "Mass_Pt_phiVP", "", 4, varspTVP, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Mass_y_phiVP", "", 4, varsrapVP, binsy, xminy, xmaxy, 0, -1, kFALSE); } if (subGroupStr.Contains("dimuon-rap")) { int vars[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kRap}; - int binspT[4] = {150, 200, 10, 6}; + int binspT[4] = {300, 200, 10, 6}; double xminpT[4] = {2., 0., 0, 2.5}; - double xmaxpT[4] = {5., 20., 100, 4.0}; + double xmaxpT[4] = {8., 20., 100, 4.0}; hm->AddHistogram(histClass, "Mass_Pt_Cent_Rap", "", 4, vars, binspT, xminpT, xmaxpT, 0, -1, kFALSE); } if (subGroupStr.Contains("dimuon-polarization-he-pbpb")) { @@ -1127,18 +1382,18 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Mass_Pt_Cent_cosThetaCS_lowmass", "", 5, varsCSpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); } if (subGroupStr.Contains("dimuon-polarization-vp-pbpb")) { - int varsHEpbpb[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kPhiVP}; - int binspT[4] = {150, 30, 10, 24}; - double xminpT[4] = {2., 0., 0, 0.}; - double xmaxpT[4] = {5., 3., 100, 3.14}; - hm->AddHistogram(histClass, "Mass_Pt_Cent_phiVP", "", 4, varsHEpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + int varsVPpbpb[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kCosPhiVP, VarManager::kPhiVP}; + int binspT[5] = {150, 30, 10, 24, 24}; + double xminpT[5] = {2., 0., 0, -1., 0.}; + double xmaxpT[5] = {5., 3., 100, 1., 3.14}; + hm->AddHistogram(histClass, "Mass_Pt_Cent_phiVP", "", 5, varsVPpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); } if (subGroupStr.Contains("dimuon-polarization-lowmass-vp-pbpb")) { - int varsHEpbpb[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kPhiVP}; - int binspT[4] = {200, 30, 10, 24}; - double xminpT[4] = {0.2, 0., 0, 0.}; - double xmaxpT[4] = {1.2, 3., 100, 3.14}; - hm->AddHistogram(histClass, "Mass_Pt_Cent_phiVP_lowmass", "", 4, varsHEpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + int varsVPpbpb[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kCosPhiVP, VarManager::kPhiVP}; + int binspT[5] = {200, 30, 10, 24, 24}; + double xminpT[5] = {0.2, 0., 0, -1., 0.}; + double xmaxpT[5] = {1.2, 3., 100, 1., 3.14}; + hm->AddHistogram(histClass, "Mass_Pt_Cent_phiVP_lowmass", "", 5, varsVPpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); } if (subGroupStr.Contains("dimuon-rap-polarization-he-pbpb")) { int varsHEpbpb[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kCosThetaHE, VarManager::kRap}; @@ -1219,19 +1474,46 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Mass_Lxyz", "", false, 250, 0.0, 5.0, VarManager::kMass, 1000, 0.0, 5, VarManager::kVertexingLxyz); hm->AddHistogram(histClass, "Mass_OpeningAngle", "", false, 250, 0.0, 5.0, VarManager::kMass, 800, 0, 0.8, VarManager::kOpeningAngle); } + if (subGroupStr.Contains("flow-dimuon-high-mass")) { + int varV2[6] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C, VarManager::kU2Q2, VarManager::kCos2DeltaPhi}; + + int bins[6] = {50, 30, 6, 18, 200, 40}; + double minBins[6] = {7.0, 0.0, 2.5, 0.0, -10.0, -2.0}; + double maxBins[6] = {12.0, 30.0, 4.0, 90.0, 10.0, 2.0}; + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_V2", "", 6, varV2, bins, minBins, maxBins, 0, -1, kTRUE); + } if (subGroupStr.Contains("flow-dimuon")) { int varV2[6] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C, VarManager::kU2Q2, VarManager::kCos2DeltaPhi}; - int varV3[6] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C, VarManager::kU3Q3, VarManager::kCos3DeltaPhi}; + // int varV3[6] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C, VarManager::kU3Q3, VarManager::kCos3DeltaPhi}; // removed temporarily int bins[6] = {250, 60, 6, 18, 200, 40}; double minBins[6] = {0.0, 0.0, 2.5, 0.0, -10.0, -2.0}; double maxBins[6] = {5.0, 30.0, 4.0, 90.0, 10.0, 2.0}; hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_V2", "", 6, varV2, bins, minBins, maxBins, 0, -1, kTRUE); - hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_V3", "", 6, varV3, bins, minBins, maxBins, 0, -1, kTRUE); + // hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_V3", "", 6, varV3, bins, minBins, maxBins, 0, -1, kTRUE); // removed temporarily } if (subGroupStr.Contains("flow-ccdb")) { - hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V2SPwR", "Mass_Pt_CentFT0C_V2SPwR", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 90, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kV2SP, VarManager::kWV2SP); - hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V2EPwR", "Mass_Pt_CentFT0C_V2EPwR", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 90, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kV2EP, VarManager::kWV2EP); + double MassBinEdges[251]; // 0-5GeV/c2 + for (int i = 0; i < 251; i++) { + MassBinEdges[i] = i * 0.02; + } + + double PtBinEdges[49]; // 0-20GeV/c + for (int i = 0; i < 49; i++) { + if (i <= 9) { + PtBinEdges[i] = i / 10.; + } else { + PtBinEdges[i] = (i - 10) * 0.5 + 1.; + } + } + + double CentBinEdges[19]; // 0-90% + for (int i = 0; i < 19; i++) { + CentBinEdges[i] = i * 5; + } + + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V2SPwR", "Mass_Pt_CentFT0C_V2SPwR", true, 250, MassBinEdges, VarManager::kMass, 48, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, "", "", "", VarManager::kV2SP, VarManager::kWV2SP); + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_V2EPwR", "Mass_Pt_CentFT0C_V2EPwR", true, 250, MassBinEdges, VarManager::kMass, 48, PtBinEdges, VarManager::kPt, 18, CentBinEdges, VarManager::kCentFT0C, "", "", "", VarManager::kV2EP, VarManager::kWV2EP); } if (subGroupStr.Contains("cumulant")) { int var[4] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C}; @@ -1246,8 +1528,8 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "centrFT0C_Corr2Corr4REF_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 250, -1.0, 1.0, VarManager::kCORR2CORR4REF, VarManager::kM11M1111REFoverMp); hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M11REFoverMp", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM11REFoverMp); hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M1111REFoverMp", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM1111REFoverMp); - hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M01POIoverMp", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM11REFoverMp); - hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M0111POIoverMp", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM1111REFoverMp); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M01POIoverMp", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM01POIoverMp); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M0111POIoverMp", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM0111POIoverMp); hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M11M1111REFoverMp", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM11M1111REFoverMp); hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M01M0111overMp", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM01M0111overMp); hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_M11M0111overMp", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kM11M0111overMp); @@ -1262,15 +1544,75 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REFCorr4POI", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2REFCORR4POI, VarManager::kM11M0111overMp); hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REFCorr2POI", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2REFCORR2POI, VarManager::kM11M01overMp); } + if (subGroupStr.Contains("cumulant1")) { + int var[4] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C}; + int bins[4] = {250, 60, 6, 18}; + double minBins[4] = {0.0, 0.0, 2.5, 0.0}; + double maxBins[4] = {5.0, 30.0, 4.0, 90.0}; + hm->AddHistogram(histClass, "Mass_Pt_Rapidity_CentFT0C", "", 4, var, bins, minBins, maxBins, 0, -1, kTRUE); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REF", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2REFbydimuons, VarManager::kM11REFoverMp); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4REF", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR4REFbydimuons, VarManager::kM1111REFoverMp); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2POI", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2POI, VarManager::kM01POIoverMp); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4POI", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR4POI, VarManager::kM0111POIoverMp); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REFCorr4REF", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2CORR4REF, VarManager::kM11M1111REFoverMp); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2POICorr4POI", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2POICORR4POI, VarManager::kM01M0111overMp); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REFCorr4POI", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2REFCORR4POI, VarManager::kM11M0111overMp); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REFCorr2POI", "", true, 250, 0.0, 5.0, VarManager::kMass, 60, 0.0, 30.0, VarManager::kPt, 18, 0.0, 90.0, VarManager::kCentFT0C, "", "", "", VarManager::kCORR2REFCORR2POI, VarManager::kM11M01overMp); + } + if (subGroupStr.Contains("cumulant2")) { + hm->AddHistogram(histClass, "centrFT0C_M11REFoverMp_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 1000, 0.0, 1000000.0, VarManager::kM11REFoverMp); + hm->AddHistogram(histClass, "centrFT0C_M1111REFoverMp_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 1000, 0.0, 100000000000000.0, VarManager::kM1111REFoverMp); + hm->AddHistogram(histClass, "centrFT0C_M11M1111REFoverMp_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 1000, 0.0, 10000000000000000.0, VarManager::kM11M1111REFoverMp); + hm->AddHistogram(histClass, "centrFT0C_Corr2REF_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 250, -1.0, 1.0, VarManager::kCORR2REFbydimuons, VarManager::kM11REFoverMp); + hm->AddHistogram(histClass, "centrFT0C_Corr4REF_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 250, -1.0, 1.0, VarManager::kCORR4REFbydimuons, VarManager::kM1111REFoverMp); + hm->AddHistogram(histClass, "centrFT0C_Corr2Corr4REF_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 250, -1.0, 1.0, VarManager::kCORR2CORR4REF, VarManager::kM11M1111REFoverMp); + } + if (subGroupStr.Contains("singlecumulant")) { + int var[4] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C}; + int bins[4] = {250, 60, 6, 18}; + double minBins[4] = {0.0, 0.0, 2.5, 0.0}; + double maxBins[4] = {5.0, 30.0, 4.0, 90.0}; + hm->AddHistogram(histClass, "Mass_Pt_Rapidity_CentFT0C", "", 4, var, bins, minBins, maxBins, 0, -1, kTRUE); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REFminus", "", true, 60, 0.0, 30.0, VarManager::kPt2, 18, 0.0, 90.0, VarManager::kCentFT0C, 0, 0.0, 1.0, VarManager::kCORR2REFbydimuons, "", "", "", VarManager::kNothing, VarManager::kM11REFoverMpminus); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4REFminus", "", true, 60, 0.0, 30.0, VarManager::kPt2, 18, 0.0, 90.0, VarManager::kCentFT0C, 0, 0.0, 1.0, VarManager::kCORR4REFbydimuons, "", "", "", VarManager::kNothing, VarManager::kM1111REFoverMpminus); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2REFplus", "", true, 60, 0.0, 30.0, VarManager::kPt1, 18, 0.0, 90.0, VarManager::kCentFT0C, 0, 0.0, 1.0, VarManager::kCORR2REFbydimuons, "", "", "", VarManager::kNothing, VarManager::kM11REFoverMpplus); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4REFplus", "", true, 60, 0.0, 30.0, VarManager::kPt1, 18, 0.0, 90.0, VarManager::kCentFT0C, 0, 0.0, 1.0, VarManager::kCORR4REFbydimuons, "", "", "", VarManager::kNothing, VarManager::kM1111REFoverMpplus); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2POIminus", "", true, 60, 0.0, 30.0, VarManager::kPt2, 18, 0.0, 90.0, VarManager::kCentFT0C, 0, 0.0, 1.0, VarManager::kCORR2POIminus, "", "", "", VarManager::kNothing, VarManager::kM01POIoverMpminus); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4POIminus", "", true, 60, 0.0, 30.0, VarManager::kPt2, 18, 0.0, 90.0, VarManager::kCentFT0C, 0, 0.0, 1.0, VarManager::kCORR4POIminus, "", "", "", VarManager::kNothing, VarManager::kM0111POIoverMpminus); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr2POIplus", "", true, 60, 0.0, 30.0, VarManager::kPt1, 18, 0.0, 90.0, VarManager::kCentFT0C, 0, 0.0, 1.0, VarManager::kCORR2POIplus, "", "", "", VarManager::kNothing, VarManager::kM01POIoverMpplus); + hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_Corr4POIplus", "", true, 60, 0.0, 30.0, VarManager::kPt1, 18, 0.0, 90.0, VarManager::kCentFT0C, 0, 0.0, 1.0, VarManager::kCORR4POIplus, "", "", "", VarManager::kNothing, VarManager::kM0111POIoverMpplus); + } + if (subGroupStr.Contains("singlecumulant2")) { + double PtBinEdges[67]; // 0-30GeV/c + for (int i = 0; i < 67; i++) { + if (i <= 39) { + PtBinEdges[i] = i / 10.; + } else { + PtBinEdges[i] = (i - 40) * 1. + 4.; + } + } + double CentBinEdges[19]; // 0-90% + for (int i = 0; i < 19; i++) { + CentBinEdges[i] = i * 5; + } + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr2REFminus", "", true, 66, PtBinEdges, VarManager::kPt2, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR2REFbydimuons, "", "", "", VarManager::kNothing, VarManager::kM11REFoverMpminus); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr4REFminus", "", true, 66, PtBinEdges, VarManager::kPt2, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR4REFbydimuons, "", "", "", VarManager::kNothing, VarManager::kM1111REFoverMpminus); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr2REFplus", "", true, 66, PtBinEdges, VarManager::kPt1, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR2REFbydimuons, "", "", "", VarManager::kNothing, VarManager::kM11REFoverMpplus); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr4REFplus", "", true, 66, PtBinEdges, VarManager::kPt1, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR4REFbydimuons, "", "", "", VarManager::kNothing, VarManager::kM1111REFoverMpplus); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr2POIminus", "", true, 66, PtBinEdges, VarManager::kPt2, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR2POIminus, "", "", "", VarManager::kNothing, VarManager::kM01POIoverMpminus); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr4POIminus", "", true, 66, PtBinEdges, VarManager::kPt2, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR4POIminus, "", "", "", VarManager::kNothing, VarManager::kM0111POIoverMpminus); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr2POIplus", "", true, 66, PtBinEdges, VarManager::kPt1, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR2POIplus, "", "", "", VarManager::kNothing, VarManager::kM01POIoverMpplus); + hm->AddHistogram(histClass, "Pt_centrFT0C_Corr4POIplus", "", true, 66, PtBinEdges, VarManager::kPt1, 18, CentBinEdges, VarManager::kCentFT0C, 0, nullptr, VarManager::kCORR4POIplus, "", "", "", VarManager::kNothing, VarManager::kM0111POIoverMpplus); + } if (subGroupStr.Contains("res-flow-dimuon")) { int varV2[6] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C, VarManager::kR2SP_AB, VarManager::kR2EP_AB}; - int varV3[6] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C, VarManager::kR3SP, VarManager::kR3EP}; + // int varV3[6] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C, VarManager::kR3SP, VarManager::kR3EP}; // removed temporarily int bins[6] = {125, 60, 6, 18, 200, 40}; double minBins[6] = {0.0, 0.0, 2.5, 0.0, -10.0, -2.0}; double maxBins[6] = {5.0, 30.0, 4.0, 90.0, 10.0, 2.0}; hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_R2", "", 6, varV2, bins, minBins, maxBins, 0, -1, kTRUE); - hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_R3", "", 6, varV3, bins, minBins, maxBins, 0, -1, kTRUE); + // hm->AddHistogram(histClass, "Mass_Pt_centrFT0C_R3", "", 6, varV3, bins, minBins, maxBins, 0, -1, kTRUE); // removed temporarily } if (subGroupStr.Contains("z-boson")) { hm->AddHistogram(histClass, "MassZboson", "", false, 240, 20.0, 140.0, VarManager::kMass); @@ -1286,7 +1628,8 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Mass_Pt", "", false, 750, 0.0, 30.0, VarManager::kMass, 120, 0.0, 30.0, VarManager::kPt); hm->AddHistogram(histClass, "Mass_Rapidity", "", false, 750, 0.0, 30.0, VarManager::kMass, 500, -1.0, 4.0, VarManager::kRap); hm->AddHistogram(histClass, "Mass_VtxZ", "", true, 30, -15.0, 15.0, VarManager::kVtxZ, 750, 0.0, 30.0, VarManager::kMass); - hm->AddHistogram(histClass, "DeltaPhiPair", "", false, 130, -6.5, 6.5, VarManager::kDeltaPhiPair); + hm->AddHistogram(histClass, "DeltaPhiPair2", "", false, 600, -o2::constants::math::PIHalf, 1.5 * o2::constants::math::PI, VarManager::kDeltaPhiPair2); + hm->AddHistogram(histClass, "DeltaEtaPair2", "", false, 350, 1.5, 5.0, VarManager::kDeltaEtaPair2); } if (subGroupStr.Contains("correlation-emu")) { hm->AddHistogram(histClass, "DeltaPhiPair2_DeltaEtaPair2", "", false, 600, -o2::constants::math::PIHalf, 1.5 * o2::constants::math::PI, VarManager::kDeltaPhiPair2, 350, 1.5, 5.0, VarManager::kDeltaEtaPair2); @@ -1400,9 +1743,15 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "MassD0region_TauxyProj", "", false, 140, 1.5, 2.2, VarManager::kMass, 200, -0.03, 0.03, VarManager::kVertexingTauxyProjected); hm->AddHistogram(histClass, "MassD0region_CosPointing", "", false, 140, 1.5, 2.2, VarManager::kMass, 200, -1.0, 1.0, VarManager::kCosPointingAngle); hm->AddHistogram(histClass, "MassD0region_VtxNContribReal", "", false, 140, 1.5, 2.2, VarManager::kMass, 50, 0, 50, VarManager::kVtxNcontribReal); + } + if (subGroupStr.Contains("3d-mass-histograms")) { + hm->AddHistogram(histClass, "MassD0region_Pt_TauxyzProj", "", false, 140, 1.5, 2.2, VarManager::kMass, 80, 0., 20., VarManager::kPt, 300, 0., 0.03, VarManager::kVertexingTauxyzProjected); + hm->AddHistogram(histClass, "MassD0region_Pt_CosPointing", "", false, 140, 1.5, 2.2, VarManager::kMass, 80, 0., 20., VarManager::kPt, 100, -1., 0., VarManager::kCosPointingAngle); hm->AddHistogram(histClass, "MassD0region_Rapidity_AveragePt", "", true, 140, 1.5, 2.2, VarManager::kMass, 10, -0.8, 0.8, VarManager::kRap, 150, 0.0, 30.0, VarManager::kPt); + hm->AddHistogram(histClass, "MassD0region_Pt_ITStrackOccupancy", "Pair mass vs pair Pt vs event ITS occupancy", false, 70, 1.5, 2.2, VarManager::kMass, 160, 0., 20., VarManager::kPt, 200, 0., 20000., VarManager::kTrackOccupancyInTimeRange); hm->AddHistogram(histClass, "MassD0region_TPCnSigKa_pIN", "Pair mass vs kaon cand. pIN vs kaon cand. TPC n-#sigma(K)", false, 140, 1.5, 2.2, VarManager::kMass, 100, 0.0, 10.0, VarManager::kPin_leg1, 20, -5.0, 5.0, VarManager::kTPCnSigmaKa_leg1); - hm->AddHistogram(histClass, "Mass_TPCnSigKa_pIN", "Pair mass vs kaon cand. pIN vs kaon cand. TPC n-#sigma(K)", false, 500, 0., 5., VarManager::kMass, 100, 0.0, 10.0, VarManager::kPin_leg1, 20, -5.0, 5.0, VarManager::kTPCnSigmaKa_leg1); + hm->AddHistogram(histClass, "Mass_Pt_Ft0cOccupancy", "", false, 150, 0.0, 5.0, VarManager::kMass, 10, 0., 10., VarManager::kPt, 20, 0., 20000., VarManager::kFT0COccupancyInTimeRange); + hm->AddHistogram(histClass, "Mass_Pt_ITStrackOccupancy", "", false, 150, 0.0, 5.0, VarManager::kMass, 10, 0., 10., VarManager::kPt, 20, 0., 20000., VarManager::kTrackOccupancyInTimeRange); } if (subGroupStr.Contains("lambdac")) { hm->AddHistogram(histClass, "MassLambdacRegion", "", false, 50, 2.15, 2.4, VarManager::kMass); @@ -1511,6 +1860,9 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "InvMass_DelEta_DelPhi", "", 4, varsJPsiHadCorr, nJPsiHadCorr); // Without efficiency // hm->AddHistogram(histClass, "InvMass_DelEta_DelPhi", "", 4, varsJPsiHadCorr, nJPsiHadCorr, nullptr, VarManager::kJpsiHadronEff); } + if (subGroupStr.Contains("dilepton-hadron-femto")) { + hm->AddHistogram(histClass, "DileptonHadronKstar_DileptonMass", "", false, 150, 0.0, 3.0, VarManager::kDileptonHadronKstar, 100, 1.5, 4.5, VarManager::kPairMassDau); + } if (subGroupStr.Contains("opencharm")) { hm->AddHistogram(histClass, "Delta_Mass_DstarD0region", "", false, 50, 0.14, 0.16, VarManager::kDeltaMass); } @@ -1546,7 +1898,7 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h } } if (!groupStr.CompareTo("dilepton-dihadron")) { - if (subGroupStr.EqualTo("xtojpsipipi")) { + if (subGroupStr.Contains("xtojpsipipi") || subGroupStr.Contains("psi2stojpsipipi")) { hm->AddHistogram(histClass, "hMass_X3872", "", false, 1000, 3.0, 5.0, VarManager::kQuadMass); hm->AddHistogram(histClass, "hMass_defaultDileptonMass_X3872", "", false, 1000, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass); hm->AddHistogram(histClass, "hPt_X3872", "", false, 150, 0.0, 15.0, VarManager::kQuadPt); @@ -1555,11 +1907,12 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "hCostheta_Jpsi_Dihadron", "", false, 100, -1.0, 1.0, VarManager::kCosthetaDileptonDitrack); hm->AddHistogram(histClass, "hPtDilepton_PtDihadron", "", false, 150, 0, 15.0, VarManager::kPairPt, 100, 0, 10, VarManager::kDitrackPt); hm->AddHistogram(histClass, "hPtDilepton_MassDihadron", "", false, 150, 0, 15.0, VarManager::kPairPt, 150, 0.0, 3.0, VarManager::kDitrackMass); - hm->AddHistogram(histClass, "hQ_X3872", "", false, 150, 0.0, 3.0, VarManager::kQ); + hm->AddHistogram(histClass, "hQ_X3872", "", false, 300, -3.0, 3.0, VarManager::kQ); hm->AddHistogram(histClass, "hDeltaR1_X3872", "", false, 100, 0.0, 10.0, VarManager::kDeltaR1); hm->AddHistogram(histClass, "hDeltaR2_X3872", "", false, 100, 0.0, 10.0, VarManager::kDeltaR2); - hm->AddHistogram(histClass, "hMass_Q_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 150, 0.0, 3.0, VarManager::kQ); - hm->AddHistogram(histClass, "hMass_defaultDileptonMass_Q_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 150, 0.0, 3.0, VarManager::kQ); + hm->AddHistogram(histClass, "hDeltaR_X3872", "", false, 100, 0.0, 10.0, VarManager::kDeltaR); + hm->AddHistogram(histClass, "hMass_Q_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 300, -3.0, 3.0, VarManager::kQ); + hm->AddHistogram(histClass, "hMass_defaultDileptonMass_Q_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 300, -3.0, 3.0, VarManager::kQ); hm->AddHistogram(histClass, "hMass_DeltaR1_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 100, 0.0, 10.0, VarManager::kDeltaR1); hm->AddHistogram(histClass, "hMass_defaultDileptonMass_DeltaR1_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 100, 0.0, 10.0, VarManager::kDeltaR1); hm->AddHistogram(histClass, "hMass_DeltaR2_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 100, 0.0, 10.0, VarManager::kDeltaR2); @@ -1579,6 +1932,30 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "hMass_defaultDileptonMass_PtTrack1", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 100, 0.0, 10.0, VarManager::kPt); hm->AddHistogram(histClass, "hMass_PtTrack1", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 100, 0.0, 10.0, VarManager::kPt); } + if (subGroupStr.Contains("vertexing")) { + hm->AddHistogram(histClass, "UsedKF", "", false, 2, -0.5, 1.5, VarManager::kUsedKF); + hm->AddHistogram(histClass, "KFMass", "", false, 750, 0.0, 30.0, VarManager::kKFMass); + hm->AddHistogram(histClass, "Lz", "", false, 1000, -0.2, 0.2, VarManager::kVertexingLz); + hm->AddHistogram(histClass, "Lxy", "", false, 1000, -0.2, 0.2, VarManager::kVertexingLxy); + hm->AddHistogram(histClass, "Lxyz", "", false, 1000, -0.2, 0.2, VarManager::kVertexingLxyz); + hm->AddHistogram(histClass, "Tauz", "", false, 4000, -0.01, 0.01, VarManager::kVertexingTauz); + hm->AddHistogram(histClass, "Tauxy", "", false, 4000, -0.01, 0.01, VarManager::kVertexingTauxy); + hm->AddHistogram(histClass, "LxyzErr", "", false, 100, 0.0, 0.2, VarManager::kVertexingLxyzErr); + hm->AddHistogram(histClass, "LzErr", "", false, 100, 0.0, 0.2, VarManager::kVertexingLzErr); + hm->AddHistogram(histClass, "TauzErr", "", false, 100, 0.0, 0.2, VarManager::kVertexingTauzErr); + hm->AddHistogram(histClass, "VtxingProcCode", "", false, 10, 0.0, 10.0, VarManager::kVertexingProcCode); + hm->AddHistogram(histClass, "VtxingChi2PCA", "", false, 100, 0.0, 10.0, VarManager::kVertexingChi2PCA); + hm->AddHistogram(histClass, "LzProj", "", false, 1000, -0.2, 0.2, VarManager::kVertexingLzProjected); + hm->AddHistogram(histClass, "LxyProj", "", false, 1000, -0.2, 0.2, VarManager::kVertexingLxyProjected); + hm->AddHistogram(histClass, "LxyzProj", "", false, 1000, -0.2, 0.2, VarManager::kVertexingLxyzProjected); + hm->AddHistogram(histClass, "TauzProj", "", false, 4000, -0.5, 0.5, VarManager::kVertexingTauzProjected); + hm->AddHistogram(histClass, "TauxyProj", "", false, 4000, -0.5, 0.5, VarManager::kVertexingTauxyProjected); + hm->AddHistogram(histClass, "CosPointingAngle", "", false, 100, 0.0, 1.0, VarManager::kCosPointingAngle); + hm->AddHistogram(histClass, "DCAxyzBetweenProngs", "", false, 100, 0.0, 1.0, VarManager::kKFDCAxyzBetweenProngs); + hm->AddHistogram(histClass, "KFChi2OverNDFGeo", "", false, 150, -5, 10, VarManager::kKFChi2OverNDFGeo); + hm->AddHistogram(histClass, "hMass_Chi2OverNDFGeo", "", false, 1000, 3.0, 5.0, VarManager::kQuadMass, 150, -5, 10., VarManager::kKFChi2OverNDFGeo); + hm->AddHistogram(histClass, "hMass_defaultDileptonMass_Chi2OverNDFGeo", "", false, 1000, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 150, -5, 10., VarManager::kKFChi2OverNDFGeo); + } } if (!groupStr.CompareTo("dilepton-photon-mass")) { hm->AddHistogram(histClass, "Mass_Dilepton", "", false, 500, 0.0, 5.0, VarManager::kPairMassDau); @@ -1609,4 +1986,441 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Mass_Pt", "", false, 500, 0.0, 5.0, VarManager::kMassDau, 200, 0.0, 20.0, VarManager::kPt); hm->AddHistogram(histClass, "Rapidity", "", false, 400, -4.0, 4.0, VarManager::kRap); } + + if (subGroupStr.Contains("DY-dimuon")) { + hm->AddHistogram(histClass, "DY_mass", "", false, 5000, 0.0, 50.0, VarManager::kMass); // 10 MeV mass res + hm->AddHistogram(histClass, "DY_pT", "", false, 2000, 0.0, 100.0, VarManager::kPt); // 50 MeV pT res + hm->AddHistogram(histClass, "DY_y", "", false, 20, 2.0, 4.0, VarManager::kRap); + hm->AddHistogram(histClass, "DY_phi", "", false, 180, constants::math::PI, 2 * constants::math::PI, VarManager::kPhi); + } +} + +//__________________________________________________________________ +template +bool o2::aod::dqhistograms::ValidateJSONHistogram(T hist) +{ + // + // Validate JSON entry for this histogram + // + + // The fields histClass, title and type are compulsory + if (!hist->HasMember("histClass") || !hist->HasMember("title") || !hist->HasMember("type")) { + LOG(fatal) << "Missing histClass, title or type fields"; + return false; + } + + TString histTypeStr = hist->FindMember("type")->value.GetString(); + bool isTH1 = (histTypeStr.CompareTo("TH1") == 0); + bool isTH2 = (histTypeStr.CompareTo("TH2") == 0); + bool isTH3 = (histTypeStr.CompareTo("TH3") == 0); + bool isTHn = (histTypeStr.CompareTo("THn") == 0); + if (!(isTH1 || isTH2 || isTH3 || isTHn)) { + LOG(fatal) << "The type field must be one of the TH1, TH2, TH3 or THn"; + return false; + } + // Check if the histogram uses constant binning + bool isConstantBinning = true; + if (!(hist->HasMember("xmin") && hist->HasMember("xmax"))) { + isConstantBinning = false; + } + + if (!isTHn && (!hist->HasMember("isProfile") || !hist->HasMember("nXbins") || !hist->HasMember("varX"))) { + LOG(fatal) << "Missing isProfile, nXbins or varX information for histogram"; + return false; + } + bool isProfile = (hist->HasMember("isProfile") ? hist->FindMember("isProfile")->value.GetBool() : false); + + if (isConstantBinning) { + if (!hist->HasMember("xmin") || !hist->HasMember("xmax")) { + LOG(fatal) << "Missing xmin or xmax information for histogram"; + return false; + } + if (isTHn) { + if (!hist->FindMember("xmin")->value.IsArray()) { + LOG(fatal) << "xmin field should be an array of arrays"; + return false; + } + if (!hist->FindMember("xmax")->value.IsArray()) { + LOG(fatal) << "xmax field should be an array of arrays"; + return false; + } + } + } else { + if (isTHn && !hist->HasMember("binLimits")) { + LOG(fatal) << "Missing binLimits information for histogram"; + return false; + } + if (!isTHn && !hist->HasMember("xbins")) { + LOG(fatal) << "Missing xbins information for histogram"; + return false; + } + if (isTHn && !hist->FindMember("binLimits")->value.IsArray()) { + LOG(fatal) << "binLimits field should be an array of arrays"; + return false; + } + if (!isTHn && !hist->FindMember("xbins")->value.IsArray()) { + LOG(fatal) << "xbins field should be an array"; + return false; + } + } + if (isProfile && !hist->HasMember("varY")) { + LOG(fatal) << "Missing varY information for histogram"; + return false; + } + + if (isTHn) { + if (!hist->HasMember("nDimensions") || !hist->HasMember("vars")) { + LOG(fatal) << "Missing nDimensions or vars fields for histogram"; + return false; + } + if (isConstantBinning) { + if (!hist->HasMember("nBins")) { + LOG(fatal) << "Missing nBins field for histogram"; + return false; + } else { + if (!hist->FindMember("nBins")->value.IsArray()) { + LOG(fatal) << "nBins field should be an array"; + return false; + } + } + } + if (hist->HasMember("axLabels") && !hist->FindMember("axLabels")->value.IsArray()) { + LOG(fatal) << "axLabels field should be an array of strings"; + return false; + } + } + + if (isTH2 || isTH3) { + if (!hist->HasMember("nYbins") || !hist->HasMember("varY")) { + LOG(fatal) << "Missing nYbins or varY information for histogram"; + return false; + } + if (isConstantBinning && (!hist->HasMember("ymin") || !hist->HasMember("ymax"))) { + LOG(fatal) << "Missing ymin or ymax information for histogram"; + return false; + } + if (!isConstantBinning && !hist->HasMember("ybins")) { + LOG(fatal) << "Missing ybins information for histogram"; + return false; + } + if (!isConstantBinning && !hist->FindMember("xbins")->value.IsArray()) { + LOG(fatal) << "ybins field should be an array"; + } + + if (isTH3) { + if (!hist->HasMember("nZbins") || !hist->HasMember("varZ")) { + LOG(fatal) << "Missing nZbins or varZ information for histogram"; + return false; + } + if (isConstantBinning && (!hist->HasMember("zmin") || !hist->HasMember("zmax"))) { + LOG(fatal) << "Missing zmin or zmax information for histogram"; + return false; + } + if (!isConstantBinning && !hist->HasMember("zbins")) { + LOG(fatal) << "Missing zbins information for histogram"; + return false; + } + if (!isConstantBinning && !hist->FindMember("zbins")->value.IsArray()) { + LOG(fatal) << "zbins field should be an array"; + } + } + } + if (isTH2 && isProfile && !hist->HasMember("varZ")) { + LOG(fatal) << "Missing varZ information for histogram"; + return false; + } + if (isTH3 && isProfile && !hist->HasMember("varT")) { + LOG(fatal) << "Missing varT information for histogram"; + return false; + } + + if (!isTHn) { + TString varX = hist->FindMember("varX")->value.GetString(); + if (VarManager::fgVarNamesMap.find(varX) == VarManager::fgVarNamesMap.end()) { + LOG(fatal) << "Bad varX variable (" << hist->FindMember("varX")->value.GetString() << ") specified for histogram"; + return false; + } + if (hist->HasMember("varY") && (VarManager::fgVarNamesMap.find(hist->FindMember("varY")->value.GetString()) == VarManager::fgVarNamesMap.end())) { + LOG(fatal) << "Bad varY variable (" << hist->FindMember("varY")->value.GetString() << ") specified for histogram"; + return false; + } + if (hist->HasMember("varZ") && (VarManager::fgVarNamesMap.find(hist->FindMember("varZ")->value.GetString()) == VarManager::fgVarNamesMap.end())) { + LOG(fatal) << "Bad varZ variable (" << hist->FindMember("varZ")->value.GetString() << ") specified for histogram"; + return false; + } + if (hist->HasMember("varT") && (VarManager::fgVarNamesMap.find(hist->FindMember("varT")->value.GetString()) == VarManager::fgVarNamesMap.end())) { + LOG(fatal) << "Bad varT variable (" << hist->FindMember("varT")->value.GetString() << ") specified for histogram"; + return false; + } + if (hist->HasMember("varW") && (VarManager::fgVarNamesMap.find(hist->FindMember("varW")->value.GetString()) == VarManager::fgVarNamesMap.end())) { + LOG(fatal) << "Bad varW variable (" << hist->FindMember("varW")->value.GetString() << ") specified for histogram"; + return false; + } + } + if (isTHn) { + for (auto& v : hist->FindMember("vars")->value.GetArray()) { + if (VarManager::fgVarNamesMap.find(v.GetString()) == VarManager::fgVarNamesMap.end()) { + LOG(fatal) << "Bad variable in vars (" << v.GetString() << ") specified for histogram"; + return false; + } + } + } + + return true; +} + +//__________________________________________________________________ +void o2::aod::dqhistograms::AddHistogramsFromJSON(HistogramManager* hm, const char* json) +{ + // + // Add histograms to already existing histogram classes from a JSON formatted string + // The JSON is expected to contain a list of objects, with each object containing the fields needed + // to define a histogram via the HistogramManager::AddHistogram() functions + + LOG(info) << "========================================== interpreting JSON for adding histograms"; + LOG(info) << " json string is: " << json; + + TString jsonStr = json; + if (jsonStr == "") { + // No histograms to add + return; + } + + rapidjson::Document document; + rapidjson::ParseResult ok = document.Parse(json); + if (!ok) { + LOG(fatal) << "JSON parse error: " << rapidjson::GetParseErrorFunc(ok.Code()) << " (" << ok.Offset() << ")"; + TString str = ""; + for (int i = ok.Offset() - 30; i < static_cast(ok.Offset()) + 50; i++) { + if ((i >= 0) && (i < static_cast(strlen(json)))) { + str += json[i]; + } + } + LOG(fatal) << "**** Parsing error is somewhere here: " << str.Data() << endl; + return; + } + + for (rapidjson::Value::ConstMemberIterator it = document.MemberBegin(); it != document.MemberEnd(); it++) { + + const char* histName = it->name.GetString(); + LOG(info) << "Configuring histogram " << histName; + const auto& hist = it->value; + if (!ValidateJSONHistogram(&hist)) { + LOG(fatal) << "Histogram not properly defined in the JSON file. Skipping it"; + continue; + } + + TString histTypeStr = hist.FindMember("type")->value.GetString(); + bool isTH2 = (histTypeStr.CompareTo("TH2") == 0); + bool isTH3 = (histTypeStr.CompareTo("TH3") == 0); + bool isTHn = (histTypeStr.CompareTo("THn") == 0); + bool isConstantBinning = true; + if (!(hist.HasMember("xmin") && hist.HasMember("xmax"))) { + isConstantBinning = false; + } + + const char* histClass = hist.FindMember("histClass")->value.GetString(); + const char* title = hist.FindMember("title")->value.GetString(); + + if (isTHn) { + int nDimensions = hist.FindMember("nDimensions")->value.GetInt(); + LOG(debug) << "nDimensions: " << nDimensions; + + int* vars = new int[nDimensions]; + int iDim = 0; + for (auto& v : hist.FindMember("vars")->value.GetArray()) { + LOG(debug) << "iDim " << iDim << ": " << v.GetString(); + vars[iDim++] = VarManager::fgVarNamesMap[v.GetString()]; + } + + int* nBins = nullptr; + double* xmin = nullptr; + double* xmax = nullptr; + TArrayD* binLimits = nullptr; + if (isConstantBinning) { + nBins = new int[nDimensions]; + xmin = new double[nDimensions]; + xmax = new double[nDimensions]; + int iDim = 0; + for (auto& v : hist.FindMember("nBins")->value.GetArray()) { + nBins[iDim++] = v.GetInt(); + LOG(debug) << "nBins " << iDim << ": " << nBins[iDim - 1]; + } + iDim = 0; + for (auto& v : hist.FindMember("xmin")->value.GetArray()) { + xmin[iDim++] = v.GetDouble(); + LOG(debug) << "xmin " << iDim << ": " << xmin[iDim - 1]; + } + iDim = 0; + for (auto& v : hist.FindMember("xmax")->value.GetArray()) { + xmax[iDim++] = v.GetDouble(); + LOG(debug) << "xmax " << iDim << ": " << xmax[iDim - 1]; + } + } else { + int iDim = 0; + binLimits = new TArrayD[nDimensions]; + for (auto& v : hist.FindMember("binLimits")->value.GetArray()) { + double* lims = new double[v.GetArray().Size()]; + int iElem = 0; + for (auto& lim : v.GetArray()) { + lims[iElem++] = lim.GetDouble(); + } + binLimits[iDim++] = TArrayD(v.GetArray().Size(), lims); + } + } + + TString* axLabels = nullptr; + if (hist.HasMember("axLabels")) { + axLabels = new TString[hist.FindMember("axLabels")->value.GetArray().Size()]; + int iDim = 0; + for (auto& v : hist.FindMember("axLabels")->value.GetArray()) { + axLabels[iDim++] = v.GetString(); + } + } + + int varW = (hist.HasMember("varW") ? VarManager::fgVarNamesMap[hist.FindMember("varW")->value.GetString()] : -1); + bool useSparse = (hist.HasMember("useSparse") ? hist.FindMember("useSparse")->value.GetBool() : false); + bool isDouble = (hist.HasMember("isDouble") ? hist.FindMember("isDouble")->value.GetBool() : false); + + if (isConstantBinning) { + hm->AddHistogram(histClass, histName, title, nDimensions, vars, nBins, xmin, xmax, axLabels, varW, useSparse, isDouble); + } else { + hm->AddHistogram(histClass, histName, title, nDimensions, vars, binLimits, axLabels, varW, useSparse, isDouble); + } + + } else { // TH1, TH2 or TH3 + + LOG(debug) << "is TH1, TH2 or TH3 "; + + bool isProfile = hist.FindMember("isProfile")->value.GetBool(); + LOG(debug) << "isProfile: " << isProfile; + + int nXbins = hist.FindMember("nXbins")->value.GetInt(); + LOG(debug) << "nXbins: " << nXbins; + + const char* varX = hist.FindMember("varX")->value.GetString(); + LOG(debug) << "varX: " << varX; + + double xmin = (hist.HasMember("xmin") ? hist.FindMember("xmin")->value.GetDouble() : 0.0); + LOG(debug) << "xmin: " << xmin; + + double xmax = (hist.HasMember("xmax") ? hist.FindMember("xmax")->value.GetDouble() : 0.0); + LOG(debug) << "xmax: " << xmax; + + std::vector xbinsVec; + if (hist.HasMember("xbins")) { + LOG(debug) << "xbins: "; + for (auto& v : hist.FindMember("xbins")->value.GetArray()) { + xbinsVec.push_back(v.GetDouble()); + LOG(debug) << v.GetDouble(); + } + } + + const char* varY = (hist.HasMember("varY") ? hist.FindMember("varY")->value.GetString() : "kNothing"); + LOG(debug) << "varY: " << varY; + + int nYbins = (hist.HasMember("nYbins") ? hist.FindMember("nYbins")->value.GetInt() : 0); + LOG(debug) << "nYbins: " << nYbins; + + double ymin = (hist.HasMember("ymin") ? hist.FindMember("ymin")->value.GetDouble() : 0.0); + LOG(debug) << "ymin: " << ymin; + + double ymax = (hist.HasMember("ymax") ? hist.FindMember("ymax")->value.GetDouble() : 0.0); + LOG(debug) << "ymax: " << ymax; + + std::vector ybinsVec; + if (hist.HasMember("ybins")) { + LOG(debug) << "ybins: "; + for (auto& v : hist.FindMember("ybins")->value.GetArray()) { + ybinsVec.push_back(v.GetDouble()); + LOG(debug) << v.GetDouble(); + } + } + + const char* varZ = (hist.HasMember("varZ") ? hist.FindMember("varZ")->value.GetString() : "kNothing"); + LOG(debug) << "varZ: " << varZ; + + int nZbins = (hist.HasMember("nZbins") ? hist.FindMember("nZbins")->value.GetInt() : 0); + LOG(debug) << "nZbins: " << nZbins; + + double zmin = (hist.HasMember("zmin") ? hist.FindMember("zmin")->value.GetDouble() : 0.0); + LOG(debug) << "zmin: " << zmin; + + double zmax = (hist.HasMember("zmax") ? hist.FindMember("zmax")->value.GetDouble() : 0.0); + LOG(debug) << "zmax: " << zmax; + + std::vector zbinsVec; + if (hist.HasMember("zbins")) { + LOG(debug) << "zbins: "; + for (auto& v : hist.FindMember("zbins")->value.GetArray()) { + zbinsVec.push_back(v.GetDouble()); + LOG(debug) << v.GetDouble(); + } + } + + const char* xLabels = (hist.HasMember("xLabels") ? hist.FindMember("xLabels")->value.GetString() : ""); + LOG(debug) << "xLabels: " << xLabels; + + const char* yLabels = (hist.HasMember("yLabels") ? hist.FindMember("yLabels")->value.GetString() : ""); + LOG(debug) << "yLabels: " << yLabels; + + const char* zLabels = (hist.HasMember("zLabels") ? hist.FindMember("zLabels")->value.GetString() : ""); + LOG(debug) << "zLabels: " << zLabels; + + const char* varT = (hist.HasMember("varT") ? hist.FindMember("varT")->value.GetString() : "kNothing"); + LOG(debug) << "varT: " << varT; + + const char* varW = (hist.HasMember("varW") ? hist.FindMember("varW")->value.GetString() : "kNothing"); + LOG(debug) << "varW: " << varW; + + bool isdouble = (hist.HasMember("isdouble") ? hist.FindMember("isdouble")->value.GetBool() : false); + LOG(debug) << "isdouble: " << isdouble; + + bool isFillLabelx = (hist.HasMember("isFillLabelx") ? hist.FindMember("isFillLabelx")->value.GetBool() : false); + LOG(debug) << "isFillLabelx: " << isFillLabelx; + + if (isConstantBinning) { + hm->AddHistogram(histClass, histName, title, isProfile, + nXbins, xmin, xmax, VarManager::fgVarNamesMap[varX], + nYbins, ymin, ymax, VarManager::fgVarNamesMap[varY], + nZbins, zmin, zmax, VarManager::fgVarNamesMap[varZ], + xLabels, yLabels, zLabels, + VarManager::fgVarNamesMap[varT], VarManager::fgVarNamesMap[varW], isdouble, isFillLabelx); + } else { + int xBinsSize = xbinsVec.size(); + if (xBinsSize != (nXbins + 1)) { + LOG(fatal) << "Histogram not properly defined in the JSON file. Wrong x binning for histogram"; + continue; + } + double* xbins = new double[xbinsVec.size()]; + std::copy(xbinsVec.begin(), xbinsVec.end(), xbins); + + double* ybins = nullptr; + if (isTH2 || isTH3) { + if (static_cast(ybinsVec.size()) != (nYbins + 1)) { + LOG(fatal) << "Histogram not properly defined in the JSON file. Wrong y binning for histogram"; + continue; + } + ybins = new double[ybinsVec.size()]; + std::copy(ybinsVec.begin(), ybinsVec.end(), ybins); + } + + double* zbins = nullptr; + if (isTH3) { + if (static_cast(zbinsVec.size()) != (nZbins + 1)) { + LOG(fatal) << "Histogram not properly defined in the JSON file. Wrong z binning for histogram"; + continue; + } + zbins = new double[zbinsVec.size()]; + std::copy(zbinsVec.begin(), zbinsVec.end(), zbins); + } + hm->AddHistogram(histClass, histName, title, isProfile, + nXbins, xbins, VarManager::fgVarNamesMap[varX], + nYbins, ybins, VarManager::fgVarNamesMap[varY], + nZbins, zbins, VarManager::fgVarNamesMap[varZ], + xLabels, yLabels, zLabels, + VarManager::fgVarNamesMap[varT], VarManager::fgVarNamesMap[varW], isdouble, isFillLabelx); + } // end if (!isTHn) + } + } } diff --git a/PWGDQ/Core/HistogramsLibrary.h b/PWGDQ/Core/HistogramsLibrary.h index aa53a2674cc..869fb3a85f3 100644 --- a/PWGDQ/Core/HistogramsLibrary.h +++ b/PWGDQ/Core/HistogramsLibrary.h @@ -19,12 +19,16 @@ #include "PWGDQ/Core/HistogramManager.h" #include "PWGDQ/Core/VarManager.h" #include "CommonConstants/MathConstants.h" +#include "rapidjson/document.h" namespace o2::aod { namespace dqhistograms { void DefineHistograms(HistogramManager* hm, const char* histClass, const char* groupName, const char* subGroupName = ""); +template +bool ValidateJSONHistogram(T hist); +void AddHistogramsFromJSON(HistogramManager* hm, const char* json); } } // namespace o2::aod diff --git a/PWGDQ/Core/MCProng.cxx b/PWGDQ/Core/MCProng.cxx index 975fee96681..48f2c52ae36 100644 --- a/PWGDQ/Core/MCProng.cxx +++ b/PWGDQ/Core/MCProng.cxx @@ -11,11 +11,22 @@ #include "PWGDQ/Core/MCProng.h" +#include +#include #include #include ClassImp(MCProng); +std::map MCProng::fgSourceNames = { + {"kNothing", MCProng::kNothing}, + {"kPhysicalPrimary", MCProng::kPhysicalPrimary}, + {"kProducedInTransport", MCProng::kProducedInTransport}, + {"kProducedByGenerator", MCProng::kProducedByGenerator}, + {"kFromBackgroundEvent", MCProng::kFromBackgroundEvent}, + {"kHEPMCFinalState", MCProng::kHEPMCFinalState}, + {"kIsPowhegDYMuon", MCProng::kIsPowhegDYMuon}}; + //________________________________________________________________________________________________________________ MCProng::MCProng() : fNGenerations(0), fPDGcodes({}), @@ -119,9 +130,9 @@ void MCProng::SetSourceBit(int generation, int sourceBit, bool exclude /*=false* if (generation < 0 || generation >= fNGenerations) { return; } - fSourceBits[generation] |= (uint64_t(1) << sourceBit); + fSourceBits[generation] |= (static_cast(1) << sourceBit); if (exclude) { - fExcludeSource[generation] |= (uint64_t(1) << sourceBit); + fExcludeSource[generation] |= (static_cast(1) << sourceBit); } } @@ -186,6 +197,13 @@ bool MCProng::ComparePDG(int pdg, int prongPDG, bool checkBothCharges, bool excl decision = (prongPDG > 0 ? pdg >= 100 && pdg <= 199 : pdg >= -199 && pdg <= -100); } break; + case 101: // all light flavoured and strange mesons + if (checkBothCharges) { + decision = absPDG >= 100 && absPDG <= 399; + } else { + decision = (prongPDG > 0 ? pdg >= 100 && pdg <= 399 : pdg >= -399 && pdg <= -100); + } + break; case 1000: // light flavoured baryons if (checkBothCharges) { decision = absPDG >= 1000 && absPDG <= 1999; diff --git a/PWGDQ/Core/MCProng.h b/PWGDQ/Core/MCProng.h index df36f1a316c..cd42965d271 100644 --- a/PWGDQ/Core/MCProng.h +++ b/PWGDQ/Core/MCProng.h @@ -23,6 +23,7 @@ A few non-existent PYTHIA codes are used to select more than one PYTHIA code. 0 - default, accepts all PYTHIA codes 100 - light unflavoured mesons in the code range 100-199 +101 - all light and strange mesons in the code range 100-399 200 - --"-- 200-299 300 - strange mesons in the code range 300-399 400 - charmed mesons in the code range 400-499 @@ -43,6 +44,7 @@ A few non-existent PYTHIA codes are used to select more than one PYTHIA code. 901 - LF mesons for LMEE 111, 221, 331, 113, 223, 333 902 - all open charm open beauty mesons+baryons 400-439, 500-549, 4000-4399, 5000-5499 903 - all hadrons in the code range 100-599, 1000-5999 +904 - chic0, chic1 and chic2 445, 100441, 200443 1000 - light unflavoured baryons in the code range 1000-1999 2000 - --"-- 2000-2999 3000 - strange baryons in the code range 3000-3999 @@ -56,28 +58,35 @@ A few non-existent PYTHIA codes are used to select more than one PYTHIA code. #define PWGDQ_CORE_MCPRONG_H_ #include "TNamed.h" +#include "TString.h" #include #include +#include class MCProng { public: enum Source { // TODO: add more sources, see Run-2 code + kNothing = -1, kPhysicalPrimary = 0, // Physical primary, ALICE definition kProducedInTransport, // Produced during transport through the detector (e.g. GEANT) kProducedByGenerator, // Produced by generator (if not, then produced by GEANT) kFromBackgroundEvent, // Produced in the underlying event + kHEPMCFinalState, // HEPMC code 11 + kIsPowhegDYMuon, // POWHEG muons based on Pythia Status Code (=23) -> Drell-Yan signal kNSources }; + static std::map fgSourceNames; + enum Constants { kPDGCodeNotAssigned = 0 }; MCProng(); - MCProng(int n); + explicit MCProng(int n); MCProng(int n, int m); MCProng(int n, std::vector pdgs, std::vector checkBothCharges, std::vector excludePDG, std::vector sourceBits, std::vector excludeSource, std::vector useANDonSourceBitMap, diff --git a/PWGDQ/Core/MCSignal.h b/PWGDQ/Core/MCSignal.h index 0e979aae8b2..42fe0a0a050 100644 --- a/PWGDQ/Core/MCSignal.h +++ b/PWGDQ/Core/MCSignal.h @@ -216,41 +216,56 @@ bool MCSignal::CheckProng(int i, bool checkSources, const T& track) currentMCParticle = track; for (int j = 0; j < fProngs[i].fNGenerations; j++) { // check whether sources are required for this generation - if (!fProngs[i].fSourceBits[j]) { - continue; + bool hasSources = false; + if (fProngs[i].fSourceBits[j]) { + hasSources = true; } // check each source uint64_t sourcesDecision = 0; - // Check kPhysicalPrimary - if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kPhysicalPrimary)) { - if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kPhysicalPrimary)) != currentMCParticle.isPhysicalPrimary()) { - sourcesDecision |= (static_cast(1) << MCProng::kPhysicalPrimary); + if (hasSources) { + // Check kPhysicalPrimary + if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kPhysicalPrimary)) { + if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kPhysicalPrimary)) != currentMCParticle.isPhysicalPrimary()) { + sourcesDecision |= (static_cast(1) << MCProng::kPhysicalPrimary); + } } - } - // Check kProducedInTransport - if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kProducedInTransport)) { - if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kProducedInTransport)) != (!currentMCParticle.producedByGenerator())) { - sourcesDecision |= (static_cast(1) << MCProng::kProducedInTransport); + // Check kProducedInTransport + if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kProducedInTransport)) { + if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kProducedInTransport)) != (!currentMCParticle.producedByGenerator())) { + sourcesDecision |= (static_cast(1) << MCProng::kProducedInTransport); + } } - } - // Check kProducedByGenerator - if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kProducedByGenerator)) { - if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kProducedByGenerator)) != currentMCParticle.producedByGenerator()) { - sourcesDecision |= (static_cast(1) << MCProng::kProducedByGenerator); + // Check kProducedByGenerator + if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kProducedByGenerator)) { + if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kProducedByGenerator)) != currentMCParticle.producedByGenerator()) { + sourcesDecision |= (static_cast(1) << MCProng::kProducedByGenerator); + } } - } - // Check kFromBackgroundEvent - if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kFromBackgroundEvent)) { - if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kFromBackgroundEvent)) != currentMCParticle.fromBackgroundEvent()) { - sourcesDecision |= (static_cast(1) << MCProng::kFromBackgroundEvent); + // Check kFromBackgroundEvent + if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kFromBackgroundEvent)) { + if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kFromBackgroundEvent)) != currentMCParticle.fromBackgroundEvent()) { + sourcesDecision |= (static_cast(1) << MCProng::kFromBackgroundEvent); + } } - } + // Check HEPMC code 11 (final state) + if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kHEPMCFinalState)) { + if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kHEPMCFinalState)) != (currentMCParticle.getHepMCStatusCode() == 11)) { + sourcesDecision |= (static_cast(1) << MCProng::kHEPMCFinalState); + } + } + // Check kIsPowhegDYMuon + if (fProngs[i].fSourceBits[j] & (static_cast(1) << MCProng::kIsPowhegDYMuon)) { + if ((fProngs[i].fExcludeSource[j] & (static_cast(1) << MCProng::kIsPowhegDYMuon)) != (currentMCParticle.getGenStatusCode() == 23)) { + sourcesDecision |= (static_cast(1) << MCProng::kIsPowhegDYMuon); + } + } + } // end if(hasSources) // no source bit is fulfilled - if (!sourcesDecision) { + if (hasSources && !sourcesDecision) { return false; } // if fUseANDonSourceBitMap is on, request all bits - if (fProngs[i].fUseANDonSourceBitMap[j] && (sourcesDecision != fProngs[i].fSourceBits[j])) { + if (hasSources && (fProngs[i].fUseANDonSourceBitMap[j] && (sourcesDecision != fProngs[i].fSourceBits[j]))) { return false; } @@ -280,8 +295,8 @@ bool MCSignal::CheckProng(int i, bool checkSources, const T& track) } } } - } - } + } // end loop over generations + } // end if(checkSources) if (fProngs[i].fPDGInHistory.size() == 0) { return true; @@ -299,43 +314,45 @@ bool MCSignal::CheckProng(int i, bool checkSources, const T& track) // Note: Currently no need to check generation InTime, so disable if case and always check BackInTime (direction of mothers) // The option to check for daughter in decay chain is still implemented but commented out. - // if (!fProngs[i].fCheckGenerationsInTime) { // check generation back in time - while (currentMCParticle.has_mothers()) { - auto mother = currentMCParticle.template mothers_first_as

(); - if (!fProngs[i].fExcludePDGInHistory[k] && fProngs[i].ComparePDG(mother.pdgCode(), fProngs[i].fPDGInHistory[k], true, fProngs[i].fExcludePDGInHistory[k])) { - pdgInHistory.emplace_back(mother.pdgCode()); - break; + if (!fProngs[i].fCheckGenerationsInTime) { // check generation back in time + while (currentMCParticle.has_mothers()) { + auto mother = currentMCParticle.template mothers_first_as

(); + if (!fProngs[i].fExcludePDGInHistory[k] && fProngs[i].ComparePDG(mother.pdgCode(), fProngs[i].fPDGInHistory[k], true, fProngs[i].fExcludePDGInHistory[k])) { + pdgInHistory.emplace_back(mother.pdgCode()); + break; + } + if (fProngs[i].fExcludePDGInHistory[k] && !fProngs[i].ComparePDG(mother.pdgCode(), fProngs[i].fPDGInHistory[k], true, fProngs[i].fExcludePDGInHistory[k])) { + return false; + } + ith++; + currentMCParticle = mother; + if (ith > 10) { // need error message. Given pdg code was not found within 10 generations of the particles decay chain. + break; + } } - if (fProngs[i].fExcludePDGInHistory[k] && !fProngs[i].ComparePDG(mother.pdgCode(), fProngs[i].fPDGInHistory[k], true, fProngs[i].fExcludePDGInHistory[k])) { + } /*else { // check generation in time + if (!currentMCParticle.has_daughters()) { return false; } - ith++; - currentMCParticle = mother; - if (ith > 10) { // need error message. Given pdg code was not found within 10 generations of the particles decay chain. - break; + const auto& daughtersSlice = currentMCParticle.template daughters_as

(); + for (auto& d : daughtersSlice) { + if (!fProngs[i].fExcludePDGInHistory[k] && fProngs[i].ComparePDG(d.pdgCode(), fProngs[i].fPDGInHistory[k], true, fProngs[i].fExcludePDGInHistory[k])) { + pdgInHistory.emplace_back(d.pdgCode()); + break; + } + if (fProngs[i].fExcludePDGInHistory[k] && !fProngs[i].ComparePDG(d.pdgCode(), fProngs[i].fPDGInHistory[k], true, fProngs[i].fExcludePDGInHistory[k])) { + return false; + } + ith++; + if (ith > 10) { // need error message. Given pdg code was not found within 10 generations of the particles decay chain. + break; + } } - } - // } else { // check generation in time - // if (!currentMCParticle.has_daughters()) - // return false; - // const auto& daughtersSlice = currentMCParticle.template daughters_as

(); - // for (auto& d : daughtersSlice) { - // if (!fProngs[i].fExcludePDGInHistory[k] && fProngs[i].ComparePDG(d.pdgCode(), fProngs[i].fPDGInHistory[k], true, fProngs[i].fExcludePDGInHistory[k])) { - // pdgInHistory.emplace_back(d.pdgCode()); - // break; - // } - // if (fProngs[i].fExcludePDGInHistory[k] && !fProngs[i].ComparePDG(d.pdgCode(), fProngs[i].fPDGInHistory[k], true, fProngs[i].fExcludePDGInHistory[k])) { - // return false; - // } - // ith++; - // if (ith > 10) { // need error message. Given pdg code was not found within 10 generations of the particles decay chain. - // break; - // } - // } - // } + }*/ } - if (pdgInHistory.size() != nIncludedPDG) // vector has as many entries as mothers (daughters) defined for prong + if (pdgInHistory.size() != nIncludedPDG) { // vector has as many entries as mothers (daughters) defined for prong return false; + } } return true; } diff --git a/PWGDQ/Core/MCSignalLibrary.cxx b/PWGDQ/Core/MCSignalLibrary.cxx index 98b907391b9..5e4f2ada1bb 100644 --- a/PWGDQ/Core/MCSignalLibrary.cxx +++ b/PWGDQ/Core/MCSignalLibrary.cxx @@ -12,12 +12,17 @@ // Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no // #include +#include +// #include #include #include "CommonConstants/PhysicsConstants.h" #include "PWGDQ/Core/MCSignalLibrary.h" +#include "Framework/Logger.h" using namespace o2::constants::physics; +// using std::cout; +// using std::endl; MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) { @@ -126,6 +131,18 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "Helium3", {prong}, {-1}); return signal; } + if (!nameStr.compare("Helium3Primary")) { + MCProng prong(1, {1000020030}, {true}, {false}, {0}, {0}, {false}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "Helium3Primary", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("Helium3FromTransport")) { + MCProng prong(1, {1000020030}, {true}, {false}, {0}, {0}, {false}); + prong.SetSourceBit(0, MCProng::kProducedInTransport); + signal = new MCSignal(name, "Helium3FromTransport", {prong}, {-1}); + return signal; + } if (!nameStr.compare("nonPromptJpsi")) { MCProng prong(2, {443, 503}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); signal = new MCSignal(name, "Non-prompt jpsi", {prong}, {-1}); @@ -157,7 +174,7 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) return signal; } if (!nameStr.compare("promptPsi2S")) { - MCProng prong(2, {100443, 503}, {true, true}, {false, true}, {0, 0}, {0, 0}, {false, false}); + MCProng prong(1, {100443}, {true}, {false}, {0}, {0}, {false}, false, {503}, {true}); signal = new MCSignal(name, "Prompt psi2s (not from beauty)", {prong}, {-1}); return signal; } @@ -201,11 +218,23 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "All beauty hadrons", {prong}, {-1}); return signal; } + if (!nameStr.compare("allBeautyHadronsFS")) { + MCProng prong(1, {503}, {true}, {false}, {0}, {0}, {false}); + prong.SetSourceBit(0, MCProng::kHEPMCFinalState); + signal = new MCSignal(name, "All beauty hadrons", {prong}, {-1}); + return signal; + } if (!nameStr.compare("allOpenBeautyHadrons")) { MCProng prong(1, {502}, {true}, {false}, {0}, {0}, {false}); signal = new MCSignal(name, "All open beauty hadrons", {prong}, {-1}); return signal; } + if (!nameStr.compare("allOpenBeautyHadronsFS")) { + MCProng prong(1, {502}, {true}, {false}, {0}, {0}, {false}); + prong.SetSourceBit(0, MCProng::kHEPMCFinalState); + signal = new MCSignal(name, "All open beauty hadrons", {prong}, {-1}); + return signal; + } if (!nameStr.compare("Bc")) { MCProng prong(1, {541}, {true}, {false}, {0}, {0}, {false}); signal = new MCSignal(name, "Bc", {prong}, {-1}); @@ -232,11 +261,23 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "Everything from beauty", {prong}, {-1}); return signal; } + if (!nameStr.compare("everythingFromBeautyFS")) { + MCProng prong(2, {0, 503}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + prong.SetSourceBit(1, MCProng::kHEPMCFinalState); + signal = new MCSignal(name, "Everything from beauty", {prong}, {-1}); + return signal; + } if (!nameStr.compare("everythingFromEverythingFromBeauty")) { MCProng prong(3, {0, 0, 503}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); signal = new MCSignal(name, "Everything from everything from beauty", {prong}, {-1}); return signal; } + if (!nameStr.compare("everythingFromEverythingFromBeautyFS")) { + MCProng prong(3, {0, 0, 503}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + prong.SetSourceBit(2, MCProng::kHEPMCFinalState); + signal = new MCSignal(name, "Everything from everything from beauty", {prong}, {-1}); + return signal; + } if (!nameStr.compare("allCharmHadrons")) { MCProng prong(1, {403}, {true}, {false}, {0}, {0}, {false}); signal = new MCSignal(name, "All charm hadrons", {prong}, {-1}); @@ -320,6 +361,12 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "electron from a photon conversion", {prong}, {-1}); return signal; } + if (!nameStr.compare("PowhegDYMuon1")) { + MCProng prong(1, {13}, {true}, {false}, {0}, {0}, {false}); // selecting muons + prong.SetSourceBit(0, MCProng::kIsPowhegDYMuon); // set source to be Muon from POWHEG + signal = new MCSignal(name, "POWHEG Muon singles", {prong}, {-1}); // define a signal with 1-prong + return signal; + } // 2-prong signals if (!nameStr.compare("dielectron")) { @@ -353,6 +400,12 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "dielectron from a photon conversion from a pi0", {prong, prong}, {1, 1}); return signal; } + if (!nameStr.compare("PowhegDYMuon2")) { + MCProng prong(1, {13}, {true}, {false}, {0}, {0}, {false}); // selecting muons + prong.SetSourceBit(0, MCProng::kIsPowhegDYMuon); // set source to be Muon from POWHEG + signal = new MCSignal(name, "POWHEG Muon pair", {prong, prong}, {-1, -1}); // define a signal with 2-prong + return signal; + } // LMEE single signals // electron signals with mother X: e from mother X @@ -555,6 +608,36 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "Electrons from open charmed hadron decays with b hadron in decay history", {prong}, {-1}); return signal; } + if (!nameStr.compare("eFromPromptLM")) { + MCProng prong(2, {11, 101}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502, 402}, {true, true}); + signal = new MCSignal(name, "Electrons from light mesons without B/D in decay history", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("eFromHbtoLM")) { + MCProng prong(2, {11, 101}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502}, {false}); + signal = new MCSignal(name, "Electrons from light mesons with B hadron in decay history", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("eFromHctoLM")) { + MCProng prong(2, {11, 101, 402}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}, false, {502}, {true}); + signal = new MCSignal(name, "Electrons from light mesons from D hadron decays and no B in decay history", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("eFromUpsilon1S")) { + MCProng prong(2, {11, 553}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Electrons from Upsilon1S decays", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("eFromUpsilon2S")) { + MCProng prong(2, {11, 100553}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Electrons from Upsilon2S decays", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("eFromUpsilon3S")) { + MCProng prong(2, {11, 200553}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Electrons from Upsilon3S decays", {prong}, {-1}); + return signal; + } // muon signals with mother X: mu from mother X if (!nameStr.compare("muFromJpsi")) { @@ -567,6 +650,57 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "muons from psi2s decays", {prong}, {-1}); return signal; } + if (!nameStr.compare("muFromHb")) { + MCProng prong(2, {13, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "muons from b->mu", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("muFromPromptHc")) { + MCProng prong(2, {13, 402}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502}, {true}); + signal = new MCSignal(name, "muons from c->mu, without beauty in decay history", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("muFromHbtoHc")) { + MCProng prong(3, {13, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + signal = new MCSignal(name, "muons from b->c->mu", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("secondaryMuon")) { + MCProng prong(1, {13}, {true}, {false}, {0}, {0}, {false}); + prong.SetSourceBit(0, MCProng::kProducedInTransport); + signal = new MCSignal(name, "muons produced during transport in detector", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("muFromPromptLM")) { + MCProng prong(2, {13, 101}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502, 402}, {true, true}); + signal = new MCSignal(name, "muons from light mesons without B/D in decay history", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("muFromHbtoLM")) { + MCProng prong(2, {13, 101}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502}, {false}); + signal = new MCSignal(name, "muons from light mesons with B hadron in decay history", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("muFromHctoLM")) { + MCProng prong(2, {13, 101, 402}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}, false, {502}, {true}); + signal = new MCSignal(name, "muons from light mesons from D hadron decays and no B in decay history", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("muFromUpsilon1S")) { + MCProng prong(2, {13, 553}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "muons from Upsilon1S decays", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("muFromUpsilon2S")) { + MCProng prong(2, {13, 100553}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "muons from Upsilon2S decays", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("muFromUpsilon3S")) { + MCProng prong(2, {13, 200553}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "muons from Upsilon3S decays", {prong}, {-1}); + return signal; + } // Decay signal: Mother to electron: X -> e if (!nameStr.compare("AnythingToE")) { @@ -734,11 +868,29 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "ee pairs from non-prompt j/psi decays", {prong, prong}, {1, 1}); // signal at pair level return signal; } + if (!nameStr.compare("mumuFromPhi")) { + MCProng prong(2, {13, 333}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "mumu pairs from phi decays", {prong, prong}, {1, 1}); // signal at pair level + return signal; + } if (!nameStr.compare("mumuFromJpsi")) { MCProng prong(2, {13, 443}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); signal = new MCSignal(name, "mumu pairs from j/psi decays", {prong, prong}, {1, 1}); // signal at pair level return signal; } + if (!nameStr.compare("mumuFromPromptJpsi")) { + MCProng prong(2, {13, 443}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {503}, {true}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "mumu pairs from prompt j/psi decays", {prong, prong}, {1, 1}); // signal at pair level + return signal; + } + if (!nameStr.compare("mumuFromNonPromptJpsi")) { + MCProng prong(2, {13, 443}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {503}, {false}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "mumu pairs from non-prompt j/psi decays", {prong, prong}, {1, 1}); // signal at pair level + return signal; + } if (!nameStr.compare("eeFromPsi2S")) { MCProng prong(2, {11, 100443}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); prong.SetSourceBit(0, MCProng::kPhysicalPrimary); @@ -750,6 +902,18 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "mumu pairs from psi2s decays", {prong, prong}, {1, 1}); // signal at pair level return signal; } + if (!nameStr.compare("mumuFromPromptPsi2S")) { + MCProng prong(2, {13, 100443}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {503}, {true}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "mumu pairs from prompt psi2s decays", {prong, prong}, {1, 1}); // signal at pair level + return signal; + } + if (!nameStr.compare("mumuFromNonPromptPsi2S")) { + MCProng prong(2, {13, 100443}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {503}, {false}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "mumu pairs from non-prompt psi2s decays", {prong, prong}, {1, 1}); // signal at pair level + return signal; + } if (!nameStr.compare("mumuFromUpsilon1S")) { MCProng prong(2, {13, 553}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); signal = new MCSignal(name, "mumu pairs from upsilon1s decays", {prong, prong}, {1, 1}); // signal at pair level @@ -1116,6 +1280,33 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) return signal; } + if (!nameStr.compare("kaonFromBplusHistory")) { + MCProng prong(1, {321}, {true}, {false}, {0}, {0}, {false}, false, {521}, {false}); + signal = new MCSignal(name, "Kaons from B+ decays", {prong}, {-1}); + return signal; + } + + if (!nameStr.compare("kaonPrimaryFromBplusHistory")) { + MCProng prong(1, {321}, {true}, {false}, {0}, {0}, {false}, false, {521}, {false}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "Kaons from B+ decays", {prong}, {-1}); + return signal; + } + + if (!nameStr.compare("kaonPrimaryFromBplusFS")) { + MCProng prong(2, {321, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + prong.SetSourceBit(1, MCProng::kHEPMCFinalState); + signal = new MCSignal(name, "Kaons from B+ decays", {prong}, {-1}); + return signal; + } + + if (!nameStr.compare("kaonFromAnyBHistory")) { + MCProng prong(1, {321}, {true}, {false}, {0}, {0}, {false}, false, {503}, {false}); + signal = new MCSignal(name, "Kaons from B+ decays", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("JpsiFromBplus")) { MCProng prong(2, {443, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); signal = new MCSignal(name, "Jpsi from B+ decays", {prong}, {1}); @@ -1128,6 +1319,18 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) return signal; } + if (!nameStr.compare("electronFromJpsiFromBplus")) { + MCProng prong(3, {11, 443, 521}, {false, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + signal = new MCSignal(name, "Electrons from Jpsi from B+ decays", {prong}, {1}); + return signal; + } + + if (!nameStr.compare("positronFromJpsiFromBplus")) { + MCProng prong(3, {-11, 443, 521}, {false, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + signal = new MCSignal(name, "Positrons from Jpsi from B+ decays", {prong}, {1}); + return signal; + } + if (!nameStr.compare("eeFromJpsiFromBplus")) { MCProng prong(3, {11, 443, 521}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); signal = new MCSignal(name, "Electron pair from Jpsi from B+ decays", {prong, prong}, {1, 1}); @@ -1141,6 +1344,13 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) return signal; } + if (!nameStr.compare("eeFromJpsiKaonAny")) { + MCProng pronge(2, {11, 443}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + MCProng prongKaon(1, {321}, {true}, {false}, {0}, {0}, {false}); + signal = new MCSignal(name, "Kaon and electron pair", {pronge, pronge, prongKaon}, {-1, -1, -1}); + return signal; + } + if (!nameStr.compare("eeKaonFromBplusExclusive")) { MCProng pronge(3, {11, 443, 521}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); MCProng prongKaon(2, {321, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); @@ -1172,24 +1382,70 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) return signal; } - if (!nameStr.compare("eeKaonFromBplusViaKstar")) { // specific K exited state decays + if (!nameStr.compare("eeKaonFromB0")) { + MCProng pronge(3, {11, 443, 511}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + MCProng prongKaon(2, {321, 511}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Kaon and electron pair from B0", {pronge, pronge, prongKaon}, {2, 2, 1}); + return signal; + } + + if (!nameStr.compare("eePionFromB0ViaEverything")) { // catching feed-down for B0 + MCProng pronge(3, {11, 443, 511}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + MCProng prongPion(3, {211, 0, 511}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + signal = new MCSignal(name, "Pion and electron pair from B0", {pronge, pronge, prongPion}, {2, 2, 1}); + return signal; + } + + if (!nameStr.compare("eeKaonFromOpenBeautyMesons")) { + MCProng pronge(3, {11, 443, 501}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + MCProng prongKaon(2, {321, 501}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Excited kaon and electron pair from B0", {pronge, pronge, prongKaon}, {2, 2, 2}); + return signal; + } + + if (!nameStr.compare("eeKaonFromOpenBeautyHadrons")) { + MCProng pronge(3, {11, 443, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + MCProng prongKaon(2, {321, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Kaon and electron pair from open beauty hadrons", {pronge, pronge, prongKaon}, {2, 2, 1}); + return signal; + } + + if (!nameStr.compare("eeKaonFromLambdaB")) { + MCProng pronge(3, {11, 443, 5122}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + MCProng prongKaon(2, {321, 5122}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Kaon and electron pair from lambda B", {pronge, pronge, prongKaon}, {2, 2, 1}); + return signal; + } + + if (!nameStr.compare("eeKaonPion0FromBplus")) { MCProng pronge(3, {11, 443, 521}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); - MCProng prongKaon(3, {321, 323, 521}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); - signal = new MCSignal(name, "Kaon and electron pair from B+ via Kstar", {pronge, pronge, prongKaon}, {2, 2, 2}); + MCProng prongKaon(2, {321, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + MCProng prongPion(2, {111, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Kaon, pi0 and electron pair from B+", {pronge, pronge, prongKaon, prongPion}, {2, 2, 1, 1}); return signal; } - if (!nameStr.compare("eeKaonFromBplusViaK1270")) { // specific K exited state decays + if (!nameStr.compare("eeKaonEtaFromBplus")) { MCProng pronge(3, {11, 443, 521}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); - MCProng prongKaon(3, {321, 10323, 521}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); - signal = new MCSignal(name, "Kaon and electron pair from B+ via K1270", {pronge, pronge, prongKaon}, {2, 2, 2}); + MCProng prongKaon(2, {321, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + MCProng prongEta(2, {221, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Kaon, eta and electron pair from B+", {pronge, pronge, prongKaon, prongEta}, {2, 2, 1, 1}); return signal; } - if (!nameStr.compare("eeKaonFromBplusViaK1400")) { // specific K exited state decays + if (!nameStr.compare("eeKaonOmegaFromBplus")) { MCProng pronge(3, {11, 443, 521}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); - MCProng prongKaon(3, {321, 20323, 521}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); - signal = new MCSignal(name, "Kaon and electron pair from B+ via K1400", {pronge, pronge, prongKaon}, {2, 2, 2}); + MCProng prongKaon(2, {321, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + MCProng prongOmega(2, {223, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Kaon, omega and electron pair from B+", {pronge, pronge, prongKaon, prongOmega}, {2, 2, 1, 1}); + return signal; + } + + if (!nameStr.compare("eeKaonPionFromBplus")) { + MCProng pronge(3, {11, 443, 521}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); + MCProng prongKaon(2, {321, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + MCProng prongPion(2, {211, 521}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Kaon, pion and electron pair from B+", {pronge, pronge, prongKaon, prongPion}, {2, 2, 1, 1}); return signal; } @@ -1199,6 +1455,13 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) return signal; } + if (!nameStr.compare("BplusFS")) { + MCProng prong(1, {521}, {true}, {false}, {0}, {0}, {false}); + prong.SetSourceBit(0, MCProng::kHEPMCFinalState); + signal = new MCSignal(name, "B+", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("beautyPairs")) { MCProng prong(1, {503}, {true}, {false}, {0}, {0}, {false}); signal = new MCSignal("beautyPairs", "Beauty hadron pair", {prong, prong}, {-1, -1}); @@ -1228,12 +1491,29 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "D0", {prong}, {-1}); return signal; } + if (!nameStr.compare("nonPromptD0")) { + MCProng prong(2, {Pdg::kD0, 503}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Non-prompt D0", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("D0FS")) { + MCProng prong(1, {Pdg::kD0}, {true}, {false}, {0}, {0}, {false}); + prong.SetSourceBit(0, MCProng::kHEPMCFinalState); + signal = new MCSignal(name, "D0", {prong}, {-1}); + return signal; + } if (!nameStr.compare("KPiFromD0")) { MCProng prongKaon(2, {321, Pdg::kD0}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); MCProng prongPion(2, {211, Pdg::kD0}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); signal = new MCSignal(name, "Kaon and pion pair from D0", {prongKaon, prongPion}, {1, 1}); return signal; } + if (!nameStr.compare("KPiFromD0Reflected")) { + MCProng prongFalseKaon(2, {211, Pdg::kD0}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + MCProng prongFalsePion(2, {321, Pdg::kD0}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "Kaon and pion pair from D0 with reflected mass assumption", {prongFalseKaon, prongFalsePion}, {1, 1}); + return signal; + } if (!nameStr.compare("Dcharged")) { MCProng prong(1, {Pdg::kDPlus}, {true}, {false}, {0}, {0}, {false}); signal = new MCSignal(name, "D+/-", {prong}, {-1}); @@ -1484,6 +1764,12 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) //-------------------------------------------------------------------------------- + if (!nameStr.compare("X3872")) { + MCProng prong(1, {9920443}, {true}, {false}, {0}, {0}, {false}); + signal = new MCSignal(name, "Inclusive X(3872)", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("JpsiFromX3872")) { MCProng prong(1, {443}, {true}, {false}, {0}, {0}, {false}, false, {9920443}, {false}); signal = new MCSignal(name, "Jpsi from X3872", {prong}, {-1}); @@ -1508,7 +1794,7 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) return signal; } - if (!nameStr.compare("eFromPsi2S")) { + if (!nameStr.compare("eFromJpsiFromPsi2S")) { MCProng prong(3, {11, 443, 100443}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}); signal = new MCSignal(name, "Electron from Jpsi from Psi2S", {prong}, {1}); return signal; @@ -1561,3 +1847,418 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) } return nullptr; } + +//_______________________________________________________________________________________________ +std::vector o2::aod::dqmcsignals::GetMCSignalsFromJSON(const char* json) +{ + // + // configure MC signals using a json file + // + std::vector signals; + LOG(info) << "========================================== interpreting JSON for MC signals"; + LOG(info) << "JSON string: " << json; + // + // Create a vector of MCSignal from a JSON formatted string + // The JSON is expected to contain a list of objects, with each object containing the fields needed + // to define an MCSignal + rapidjson::Document document; + + // Check that the json is parsed correctly + rapidjson::ParseResult ok = document.Parse(json); + if (!ok) { + TString str = ""; + for (int i = ok.Offset() - 30; i < static_cast(ok.Offset()) + 50; i++) { + if ((i >= 0) && (i < static_cast(strlen(json)))) { + str += json[i]; + } + } + LOG(fatal) << "JSON parse error: " << rapidjson::GetParseErrorFunc(ok.Code()) << " (" << ok.Offset() << ")" << " **** Parsing error is somewhere here: " << str.Data(); + return signals; + } + + // loop over the top level objects in the json + for (rapidjson::Value::ConstMemberIterator it = document.MemberBegin(); it != document.MemberEnd(); it++) { + + const char* sigName = it->name.GetString(); + LOG(info) << "=================================================== Configuring MC signal " << sigName; + const auto& signal = it->value; + + // Validate the entry for this MCSignal + if (!ValidateJSONMCSignal(&signal, sigName)) { + LOG(fatal) << "MCSignal JSON not properly defined for " << sigName << ". Skipping"; + continue; + } else { + LOG(debug) << "MCSignal validated"; + } + + // Get the signal title + const char* title = (signal.HasMember("title") ? signal.FindMember("title")->value.GetString() : ""); + LOG(info) << "Title is: " << title; + + // Get the exclude common ancestor + bool excludeCommonAncestor = false; + if (signal.HasMember("excludeCommonAncestor")) { + excludeCommonAncestor = signal.FindMember("excludeCommonAncestor")->value.GetBool(); + } + LOG(debug) << "exclude common ancestor " << excludeCommonAncestor; + + // Check for MCProng objects in the json + std::vector prongs; + for (rapidjson::Value::ConstMemberIterator prongIt = signal.MemberBegin(); prongIt != signal.MemberEnd(); prongIt++) { + + // If the name is not MCProng, continue + TString prongName = prongIt->name.GetString(); + if (!prongName.Contains("MCProng")) { + continue; + } + + // Call the function to parse the MCProng object and get the pointer to the created MCProng + MCProng* prong = ParseJSONMCProng(&prongIt->value, prongName.Data()); + if (prong == nullptr) { + LOG(fatal) << "MCProng not built! MCSignal not configured"; + return signals; + } + LOG(debug) << "MCProng defined"; + // Print the contents of the configured prong + prong->Print(); + // push the prong to the vector + prongs.push_back(*prong); + } + + // Get the common ancestors array + std::vector commonAncestors; + if (signal.HasMember("commonAncestors")) { + for (auto& v : signal.FindMember("commonAncestors")->value.GetArray()) { + commonAncestors.push_back(v.GetInt()); + LOG(debug) << "common ancestor " << v.GetInt(); + } + } else { + for (uint32_t i = 0; i < prongs.size(); i++) { + commonAncestors.push_back(-1); + } + } + + if (prongs.size() == 0) { + LOG(fatal) << "No prongs were defined for this MCSignal!"; + return signals; + } + + // Check that we have as many prongs defined as the size of the common ancestors array + if (prongs.size() != commonAncestors.size()) { + LOG(fatal) << "Number of defined prongs and size of commonAncestors array must coincide in MCSignal definition"; + return signals; + } + + // Create the signal and add it to the output vector + MCSignal* mcSignal = new MCSignal(sigName, title, prongs, commonAncestors, excludeCommonAncestor); + LOG(debug) << "MCSignal defined, adding to the output vector"; + mcSignal->PrintConfig(); + signals.push_back(mcSignal); + } + + return signals; +} + +//_______________________________________________________________________________________________ +template +bool o2::aod::dqmcsignals::ValidateJSONMCProng(T prongJSON, const char* prongName) +{ + + // Check that the json entry for this prong is correctly given + LOG(debug) << "Validating the prong " << prongName; + + // The fields for the number of generations, pdg codes and checkBothCharges are required + if (!prongJSON->HasMember("n") || !prongJSON->HasMember("pdgs") || !prongJSON->HasMember("checkBothCharges")) { + LOG(fatal) << "Missing either n, pdgs or checkBothCharges fields in MCProng JSON definition"; + return false; + } + // the size of the pdgs array must be equal to n + int n = prongJSON->FindMember("n")->value.GetInt(); + uint32_t nSigned = static_cast(n); + if (prongJSON->FindMember("pdgs")->value.GetArray().Size() != nSigned) { + LOG(fatal) << "Size of the pdgs array must be equal to n in MCProng JSON definition"; + return false; + } + // the size of the checkBothCharges array must be equal to n + if (prongJSON->FindMember("checkBothCharges")->value.GetArray().Size() != nSigned) { + LOG(fatal) << "Size of the checkBothCharges array must be equal to n in MCProng JSON definition"; + return false; + } + // the size of the exclude pdg array must be equal to n + if (prongJSON->HasMember("excludePDG")) { + if (prongJSON->FindMember("excludePDG")->value.GetArray().Size() != nSigned) { + LOG(fatal) << "Size of the excludePDG array must be equal to n in MCProng JSON definition"; + return false; + } + } + + // Check the corectness of the source bits fields, if these are specified + // The sourceBits field should be an array of size n, with each element being another array containing an array of sources specified as strings + // The source strings have to be the ones specified in MCProng::Source + // If the excludeSource is specified in addition, then this field should be an array of size n, with each element being another array of booleans + // corresponding to each source specified in sourceBits + if (prongJSON->HasMember("sourceBits")) { + if (prongJSON->FindMember("sourceBits")->value.GetArray().Size() != nSigned) { + LOG(fatal) << "Size of the sourceBits array must be equal to n in MCProng JSON definition"; + return false; + } + std::vector nSourceBits; + for (auto& ii : prongJSON->FindMember("sourceBits")->value.GetArray()) { + if (!ii.IsArray()) { + LOG(fatal) << "The sourceBits field should be an array of arrays of MCProng::Source"; + return false; + } + nSourceBits.push_back(ii.GetArray().Size()); + for (auto& iii : ii.GetArray()) { + if (MCProng::fgSourceNames.find(iii.GetString()) == MCProng::fgSourceNames.end()) { + LOG(fatal) << "Source " << iii.GetString() << " not implemented in MCProng"; + return false; + } + } + } + if (prongJSON->HasMember("excludeSource")) { + if (prongJSON->FindMember("excludeSource")->value.GetArray().Size() != nSigned) { + LOG(fatal) << "Size of the excludeSource array must be equal to n in MCProng JSON definition"; + return false; + } + int iElem = 0; + for (auto& ii : prongJSON->FindMember("excludeSource")->value.GetArray()) { + if (!ii.IsArray()) { + LOG(fatal) << "The excludeSource field should be an array of arrays of bool"; + return false; + } + if (ii.GetArray().Size() != nSourceBits[iElem]) { + LOG(fatal) << "The size of excludeSource arrays does not match the size of the arrays in sourceBits"; + return false; + } + iElem++; + } + } + // Check the useAND on source bit map + if (prongJSON->HasMember("useANDonSourceBitMap")) { + if (prongJSON->FindMember("useANDonSourceBitMap")->value.GetArray().Size() != nSigned) { + LOG(fatal) << "Size of the useANDonSourceBitMap array must be equal to n in MCProng JSON definition"; + return false; + } + } + } + + // sourceBits is needed in case the other source related fields are specified + if ((prongJSON->HasMember("excludeSource") || prongJSON->HasMember("useANDonSourceBitMap")) && !prongJSON->HasMember("sourceBits")) { + LOG(fatal) << "Field sourceBits is needed when specifying excludeSource or useANDonSourceBitMap"; + return false; + } + + // check checkGenerationsInTime + if (prongJSON->HasMember("checkGenerationsInTime")) { + if (!prongJSON->FindMember("checkGenerationsInTime")->value.IsBool()) { + LOG(fatal) << "Field checkGeneretionsInTime must be boolean"; + return false; + } + } + + if (prongJSON->HasMember("checkIfPDGInHistory")) { + if (!prongJSON->FindMember("checkIfPDGInHistory")->value.IsArray()) { + LOG(fatal) << "Field checkGeneretionsInTime must be an array of integers"; + return false; + } + uint32_t vecSize = prongJSON->FindMember("checkIfPDGInHistory")->value.GetArray().Size(); + if (prongJSON->HasMember("excludePDGInHistory")) { + if (!prongJSON->FindMember("excludePDGInHistory")->value.IsArray()) { + LOG(fatal) << "Field excludePDGInHistory must be an array of booleans"; + return false; + } + if (prongJSON->FindMember("excludePDGInHistory")->value.GetArray().Size() != vecSize) { + LOG(fatal) << "Field excludePDGInHistory must be an array of equal size with the array specified by checkIfPDGInHistory"; + return false; + } + } + } else { + if (prongJSON->HasMember("excludePDGInHistory")) { + LOG(fatal) << "Field checkIfPDGInHistory is required when excludePDGInHistory is specified"; + return false; + } + } + + return true; +} + +//_______________________________________________________________________________________________ +template +MCProng* o2::aod::dqmcsignals::ParseJSONMCProng(T prongJSON, const char* prongName) +{ + + // Check that the entry for this prong is validated + LOG(debug) << "Parsing the prong " << prongName; + if (!ValidateJSONMCProng(prongJSON, prongName)) { + LOG(fatal) << "MCProng not properly defined in the JSON file."; + return nullptr; + } + + // Get the number of generations + int n = prongJSON->FindMember("n")->value.GetInt(); + LOG(debug) << "n: " << n; + // Get the array of PDG codes + std::vector pdgs; + for (auto& pdg : prongJSON->FindMember("pdgs")->value.GetArray()) { + pdgs.push_back(pdg.GetInt()); + LOG(debug) << "pdgs: " << pdg.GetInt(); + } + // get the array of booleans for check both charges option + std::vector checkBothCharges; + for (auto& ii : prongJSON->FindMember("checkBothCharges")->value.GetArray()) { + checkBothCharges.push_back(ii.GetBool()); + LOG(debug) << "check both charges " << ii.GetBool(); + } + + // get the array of booleans for the excludePDG option, defaults to false + std::vector excludePDG; + if (prongJSON->HasMember("excludePDG")) { + for (auto& ii : prongJSON->FindMember("excludePDG")->value.GetArray()) { + excludePDG.push_back(ii.GetBool()); + LOG(debug) << "exclude pdg " << ii.GetBool(); + } + } else { + for (int i = 0; i < n; i++) { + excludePDG.push_back(false); + } + } + + // get the source bits, and transform from string to int + std::vector> sourceBitsVec; + if (prongJSON->HasMember("sourceBits")) { + for (auto& ii : prongJSON->FindMember("sourceBits")->value.GetArray()) { + std::vector sourceBits; + for (auto& iii : ii.GetArray()) { + sourceBits.push_back(MCProng::fgSourceNames[iii.GetString()]); + LOG(debug) << "source bit " << iii.GetString(); + } + sourceBitsVec.push_back(sourceBits); + } + } + // prepare the exclusion source options if specified + std::vector> excludeSourceVec; + if (prongJSON->HasMember("excludeSource")) { + for (auto& ii : prongJSON->FindMember("excludeSource")->value.GetArray()) { + std::vector excludeSource; + for (auto& iii : ii.GetArray()) { + excludeSource.push_back(iii.GetBool()); + LOG(debug) << "exclude source bit " << iii.GetBool(); + } + excludeSourceVec.push_back(excludeSource); + } + } + + // prepare the useANDonSourceBitMap vector, defaults to true for each generation + std::vector useANDonSourceBitMap; + if (prongJSON->HasMember("useANDonSourceBitMap")) { + for (auto& ii : prongJSON->FindMember("useANDonSourceBitMap")->value.GetArray()) { + useANDonSourceBitMap.push_back(ii.GetBool()); + LOG(debug) << "use AND on source map " << ii.GetBool(); + } + } else { + for (int i = 0; i < n; i++) { + useANDonSourceBitMap.push_back(true); + } + } + + // prepare the bit maps suitable for the MCProng constructor + bool hasExclude = prongJSON->HasMember("excludeSource"); + int igen = 0; + std::vector sBitsVec; + std::vector sBitsExcludeVec; + for (auto& itgen : sourceBitsVec) { + int is = 0; + uint64_t sBits = 0; + uint64_t sBitsExclude = 0; + auto excludeVec = (hasExclude ? excludeSourceVec[igen] : std::vector{}); + for (auto& s : itgen) { + bool exclude = (hasExclude ? excludeVec[is] : false); + if (s != MCProng::kNothing) { + sBits |= (static_cast(1) << s); + if (exclude) { + sBitsExclude |= (static_cast(1) << s); + } + } + is++; + } + sBitsVec.push_back(sBits); + sBitsExcludeVec.push_back(sBitsExclude); + LOG(debug) << "igen " << igen; + LOG(debug) << "igen sBits " << sBits; + LOG(debug) << "igen exclude " << sBitsExclude; + igen++; + } + + // check that the sourceBits has the size of n generations + if (prongJSON->HasMember("sourceBits")) { + if (sBitsVec.size() != static_cast(n)) { + LOG(fatal) << "sourceBits array should have a size equal to n"; + } + } else { + sBitsVec.clear(); + for (int i = 0; i < n; i++) { + sBitsVec.push_back(0); + } + } + // check that the sourceBits exclude has the size of n generations + if (prongJSON->HasMember("excludeSource")) { + if (sBitsExcludeVec.size() != static_cast(n)) { + LOG(fatal) << "sourceBits exclude array should have a size equal to n"; + } + } else { + sBitsExcludeVec.clear(); + for (int i = 0; i < n; i++) { + sBitsExcludeVec.push_back(0); + } + } + + bool checkGenerationsInTime = false; + if (prongJSON->HasMember("checkGenerationsInTime")) { + checkGenerationsInTime = prongJSON->FindMember("checkGenerationsInTime")->value.GetBool(); + } + LOG(debug) << "checkGenerationsInTime: " << checkGenerationsInTime; + + std::vector checkIfPDGInHistory = {}; + if (prongJSON->HasMember("checkIfPDGInHistory")) { + for (auto& ii : prongJSON->FindMember("checkIfPDGInHistory")->value.GetArray()) { + checkIfPDGInHistory.push_back(ii.GetInt()); + LOG(debug) << "checkIfPDGInHistory: " << ii.GetInt(); + } + } + + std::vector excludePDGInHistory = {}; + if (prongJSON->HasMember("excludePDGInHistory")) { + for (auto& ii : prongJSON->FindMember("excludePDGInHistory")->value.GetArray()) { + excludePDGInHistory.push_back(ii.GetBool()); + LOG(debug) << "excludePDGInHistory: " << ii.GetBool(); + } + } + + // Calling the MCProng constructor + MCProng* prong = new MCProng(n, pdgs, checkBothCharges, excludePDG, sBitsVec, sBitsExcludeVec, useANDonSourceBitMap, + checkGenerationsInTime, checkIfPDGInHistory, excludePDGInHistory); + // Print the configuration + prong->Print(); + return prong; +} + +//_______________________________________________________________________________________________ +template +bool o2::aod::dqmcsignals::ValidateJSONMCSignal(T sigJSON, const char* sigName) +{ + + LOG(info) << "Validating MC signal " << sigName; + if (sigJSON->HasMember("commonAncestors")) { + if (!sigJSON->FindMember("commonAncestors")->value.IsArray()) { + LOG(fatal) << "In MCSignal definition, commonAncestors must be an array"; + return false; + } + } + if (sigJSON->HasMember("excludeCommonAncestor") && !sigJSON->HasMember("commonAncestors")) { + LOG(fatal) << "In MCSignal definition, commonAncestors field is needed if excludeCommonAncestor is specified"; + return false; + } + + return true; +} diff --git a/PWGDQ/Core/MCSignalLibrary.h b/PWGDQ/Core/MCSignalLibrary.h index a35ec9f31c9..df01f60c978 100644 --- a/PWGDQ/Core/MCSignalLibrary.h +++ b/PWGDQ/Core/MCSignalLibrary.h @@ -16,6 +16,7 @@ #define PWGDQ_CORE_MCSIGNALLIBRARY_H_ #include +#include "rapidjson/document.h" #include "PWGDQ/Core/MCProng.h" #include "PWGDQ/Core/MCSignal.h" @@ -24,6 +25,17 @@ namespace o2::aod namespace dqmcsignals { MCSignal* GetMCSignal(const char* signalName); + +std::vector GetMCSignalsFromJSON(const char* json); + +template +bool ValidateJSONMCSignal(T sigJSON, const char* sigName); + +template +MCProng* ParseJSONMCProng(T prongJSON, const char* prongName); + +template +bool ValidateJSONMCProng(T prongJSON, const char* prongName); } } // namespace o2::aod diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index 59aa8990005..912dc06740a 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -23,15 +23,11 @@ ClassImp(VarManager); TString VarManager::fgVariableNames[VarManager::kNVars] = {""}; TString VarManager::fgVariableUnits[VarManager::kNVars] = {""}; +std::map VarManager::fgVarNamesMap; bool VarManager::fgUsedVars[VarManager::kNVars] = {false}; bool VarManager::fgUsedKF = false; float VarManager::fgMagField = 0.5; float VarManager::fgValues[VarManager::kNVars] = {0.0f}; -std::map VarManager::fgRunMap; -TString VarManager::fgRunStr = ""; -std::vector VarManager::fgRunList = {0}; -float VarManager::fgCenterOfMassEnergy = 13600; // GeV -float VarManager::fgMassofCollidingParticle = 9.382720; // GeV float VarManager::fgTPCInterSectorBoundary = 1.0; // cm int VarManager::fgITSROFbias = 0; int VarManager::fgITSROFlength = 100; @@ -39,8 +35,11 @@ int VarManager::fgITSROFBorderMarginLow = 0; int VarManager::fgITSROFBorderMarginHigh = 0; uint64_t VarManager::fgSOR = 0; uint64_t VarManager::fgEOR = 0; +ROOT::Math::PxPyPzEVector VarManager::fgBeamA(0, 0, 6799.99, 6800); // GeV, beam from A-side 4-momentum vector +ROOT::Math::PxPyPzEVector VarManager::fgBeamC(0, 0, -6799.99, 6800); // GeV, beam from C-side 4-momentum vector o2::vertexing::DCAFitterN<2> VarManager::fgFitterTwoProngBarrel; o2::vertexing::DCAFitterN<3> VarManager::fgFitterThreeProngBarrel; +o2::vertexing::DCAFitterN<4> VarManager::fgFitterFourProngBarrel; o2::vertexing::FwdDCAFitterN<2> VarManager::fgFitterTwoProngFwd; o2::vertexing::FwdDCAFitterN<3> VarManager::fgFitterThreeProngFwd; o2::globaltracking::MatchGlobalFwd VarManager::mMatching; @@ -109,97 +108,91 @@ void VarManager::ResetValues(int startValue, int endValue, float* values) } } -//__________________________________________________________________ -void VarManager::SetRunNumbers(int n, int* runs) -{ - // - // maps the list of runs such that one can plot the list of runs nicely in a histogram axis - // - for (int i = 0; i < n; ++i) { - fgRunMap[runs[i]] = i + 1; - fgRunStr += Form("%d;", runs[i]); - } -} - -//__________________________________________________________________ -void VarManager::SetRunNumbers(std::vector runs) -{ - // - // maps the list of runs such that one can plot the list of runs nicely in a histogram axis - // - int i = 0; - for (auto run = runs.begin(); run != runs.end(); run++, i++) { - fgRunMap[*run] = i + 1; - fgRunStr += Form("%d;", *run); - } - fgRunList = runs; -} - -//__________________________________________________________________ -void VarManager::SetDummyRunlist(int InitRunnumber) -{ - // - // runlist for the different periods - fgRunList.clear(); - fgRunList.push_back(InitRunnumber); - fgRunList.push_back(InitRunnumber + 100); -} - -//__________________________________________________________________ -int VarManager::GetDummyFirst() -{ - // - // Get the fist index of the vector of run numbers - // - return fgRunList[0]; -} -//__________________________________________________________________ -int VarManager::GetDummyLast() -{ - // - // Get the last index of the vector of run numbers - // - return fgRunList[fgRunList.size() - 1]; -} -//_________________________________________________________________ -float VarManager::GetRunIndex(double Runnumber) -{ - // - // Get the index of RunNumber in it's runlist - // - int runNumber = static_cast(Runnumber); - auto runIndex = std::find(fgRunList.begin(), fgRunList.end(), runNumber); - float index = std::distance(fgRunList.begin(), runIndex); - return index; -} //__________________________________________________________________ void VarManager::SetCollisionSystem(TString system, float energy) { // // Set the collision system and the center of mass energy // - fgCenterOfMassEnergy = energy; - - if (system.Contains("PbPb")) { - fgMassofCollidingParticle = MassProton * 208; - } - if (system.Contains("pp")) { - fgMassofCollidingParticle = MassProton; + int NumberOfNucleonsA = 1; // default value for pp collisions + int NumberOfNucleonsC = 1; // default value for pp collisions + int NumberOfProtonsA = 1; // default value for pp collisions + int NumberOfProtonsC = 1; // default value for pp collisions + if (system.EqualTo("PbPb")) { + NumberOfNucleonsA = 208; + NumberOfNucleonsC = 208; + NumberOfProtonsA = 82; // Pb has 82 protons + NumberOfProtonsC = 82; // Pb has 82 protons + } else if (system.EqualTo("pp")) { + NumberOfNucleonsA = 1; + NumberOfNucleonsC = 1; + NumberOfProtonsA = 1; // proton has 1 proton + NumberOfProtonsC = 1; // proton has 1 proton + } else if (system.EqualTo("XeXe")) { + NumberOfNucleonsA = 129; + NumberOfNucleonsC = 129; + NumberOfProtonsA = 54; // Xe has 54 protons + NumberOfProtonsC = 54; // Xe has 54 protons + } else if (system.EqualTo("pPb")) { + NumberOfNucleonsA = 1; + NumberOfNucleonsC = 208; + NumberOfProtonsA = 1; // proton has 1 proton + NumberOfProtonsC = 82; // Pb has 82 protons + } else if (system.EqualTo("Pbp")) { + NumberOfNucleonsA = 208; + NumberOfNucleonsC = 1; + NumberOfProtonsA = 82; // Pb has 82 protons + NumberOfProtonsC = 1; // proton has 1 proton + } else if (system.EqualTo("OO")) { + NumberOfNucleonsA = 16; + NumberOfNucleonsC = 16; + NumberOfProtonsA = 8; // O has 8 protons + NumberOfProtonsC = 8; // O has 8 protons + } else if (system.EqualTo("pO")) { + NumberOfNucleonsA = 1; + NumberOfNucleonsC = 16; + NumberOfProtonsA = 1; // proton has 1 proton + NumberOfProtonsC = 8; // O has 8 protons + } else if (system.EqualTo("NeNe")) { + NumberOfNucleonsA = 20; + NumberOfNucleonsC = 20; + NumberOfProtonsA = 10; // Ne has 5 protons + NumberOfProtonsC = 10; // Ne has 5 protons } // TO Do: add more systems + + // set the beam 4-momentum vectors + float beamAEnergy = energy / 2.0 * sqrt(NumberOfProtonsA * NumberOfProtonsC / NumberOfProtonsC / NumberOfProtonsA); // GeV + float beamCEnergy = energy / 2.0 * sqrt(NumberOfProtonsC * NumberOfProtonsA / NumberOfProtonsA / NumberOfProtonsC); // GeV + float beamAMomentum = std::sqrt(beamAEnergy * beamAEnergy - NumberOfNucleonsA * NumberOfNucleonsA * MassProton * MassProton); + float beamCMomentum = std::sqrt(beamCEnergy * beamCEnergy - NumberOfNucleonsC * NumberOfNucleonsC * MassProton * MassProton); + fgBeamA.SetPxPyPzE(0, 0, beamAMomentum, beamAEnergy); + fgBeamC.SetPxPyPzE(0, 0, -beamCMomentum, beamCEnergy); } //__________________________________________________________________ -void VarManager::FillEventDerived(float* values) +void VarManager::SetCollisionSystem(o2::parameters::GRPLHCIFData* grplhcif) { // - // Fill event-wise derived quantities (these are all quantities which can be computed just based on the values already filled in the FillEvent() function) - // - if (fgUsedVars[kRunId]) { - values[kRunId] = (fgRunMap.size() > 0 ? fgRunMap[static_cast(values[kRunNo])] : 0); - } + // Set the collision system and the center of mass energy from the GRP information + double beamAEnergy = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamDirection::BeamA); + double beamCEnergy = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamDirection::BeamC); + double beamANucleons = grplhcif->getBeamA(o2::constants::lhc::BeamDirection::BeamA); + double beamCNucleons = grplhcif->getBeamA(o2::constants::lhc::BeamDirection::BeamC); + double beamAMomentum = std::sqrt(beamAEnergy * beamAEnergy - beamANucleons * beamANucleons * MassProton * MassProton); + double beamCMomentum = std::sqrt(beamCEnergy * beamCEnergy - beamCNucleons * beamCNucleons * MassProton * MassProton); + fgBeamA.SetPxPyPzE(0, 0, beamAMomentum, beamAEnergy); + fgBeamC.SetPxPyPzE(0, 0, -beamCMomentum, beamCEnergy); } +//__________________________________________________________________ +// void VarManager::FillEventDerived(float* values) +// { +// // +// // Fill event-wise derived quantities (these are all quantities which can be computed just based on the values already filled in the FillEvent() function) +// // +// } + //__________________________________________________________________ void VarManager::FillTrackDerived(float* values) { @@ -229,8 +222,6 @@ void VarManager::SetDefaultVarNames() fgVariableNames[kRunNo] = "Run number"; fgVariableUnits[kRunNo] = ""; - fgVariableNames[kRunId] = "Run number"; - fgVariableUnits[kRunId] = ""; fgVariableNames[kBC] = "Bunch crossing"; fgVariableUnits[kBC] = ""; fgVariableNames[kTimeFromSOR] = "time since SOR"; @@ -271,6 +262,10 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kCentVZERO] = "%"; fgVariableNames[kCentFT0C] = "Centrality FT0C"; fgVariableUnits[kCentFT0C] = "%"; + fgVariableNames[kCentFT0A] = "Centrality FT0A"; + fgVariableUnits[kCentFT0A] = "%"; + fgVariableNames[kCentFT0M] = "Centrality FT0M"; + fgVariableUnits[kCentFT0M] = "%"; fgVariableNames[kMultTPC] = "Multiplicity TPC"; fgVariableUnits[kMultTPC] = ""; fgVariableNames[kMultFV0A] = "Multiplicity FV0A"; @@ -293,6 +288,8 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kMultTracklets] = ""; fgVariableNames[kMultDimuons] = "Multiplicity Dimuons Unlike Sign"; fgVariableUnits[kMultDimuons] = ""; + fgVariableNames[kMultDimuonsME] = "Multiplicity Dimuons Unlike Sign Mixed Events"; + fgVariableUnits[kMultDimuonsME] = ""; fgVariableNames[kCentFT0C] = "Centrality FT0C"; fgVariableUnits[kCentFT0C] = "%"; fgVariableNames[kMCEventGeneratorId] = "MC Generator ID"; @@ -361,8 +358,14 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kMultNTracksTPCOnly] = ""; fgVariableNames[kMultNTracksITSTPC] = "# ITS-TPC tracks in PV"; fgVariableUnits[kMultNTracksITSTPC] = ""; + fgVariableNames[kMultNTracksPVeta1] = "# Mult Tracks PV |#eta| < 1"; + fgVariableUnits[kMultNTracksPVeta1] = ""; + fgVariableNames[kMultNTracksPVetaHalf] = "# Mult Tracks PV |#eta| < 0.5"; + fgVariableUnits[kMultNTracksPVetaHalf] = ""; fgVariableNames[kTrackOccupancyInTimeRange] = "track occupancy in TPC drift time (PV tracks)"; fgVariableUnits[kTrackOccupancyInTimeRange] = ""; + fgVariableNames[kFT0COccupancyInTimeRange] = "FT0C occupancy"; + fgVariableUnits[kFT0COccupancyInTimeRange] = ""; fgVariableNames[kNoCollInTimeRangeStandard] = "track occupancy in TPC drift standart time"; fgVariableUnits[kNoCollInTimeRangeStandard] = ""; fgVariableNames[kMultAllTracksITSTPC] = "# ITS-TPC tracks"; @@ -407,6 +410,10 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kNTPCmedianTimeShortC] = "#mu s"; fgVariableNames[kPt] = "p_{T}"; fgVariableUnits[kPt] = "GeV/c"; + fgVariableNames[kPt1] = "p_{T1}"; + fgVariableUnits[kPt1] = "GeV/c"; + fgVariableNames[kPt2] = "p_{T2}"; + fgVariableUnits[kPt2] = "GeV/c"; fgVariableNames[kInvPt] = "1/p_{T}"; fgVariableUnits[kInvPt] = "1/(GeV/c)"; fgVariableNames[kP] = "p"; @@ -429,6 +436,10 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kDeltaPtotTracks] = "GeV/c"; fgVariableNames[kCharge] = "charge"; fgVariableUnits[kCharge] = ""; + fgVariableNames[kCharge1] = "charge track 1"; + fgVariableUnits[kCharge1] = ""; + fgVariableNames[kCharge2] = "charge track 2"; + fgVariableUnits[kCharge2] = ""; fgVariableNames[kPin] = "p_{IN}"; fgVariableUnits[kPin] = "GeV/c"; fgVariableNames[kPin_leg1] = "p_{IN}"; @@ -578,7 +589,7 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kMCPy] = "GeV/c"; fgVariableNames[kMCPz] = "MC pz"; fgVariableUnits[kMCPz] = "GeV/c"; - fgVariableNames[kMCPt] = "MC pt"; + fgVariableNames[kMCPt] = "MC p_{T}"; fgVariableUnits[kMCPt] = "GeV/c"; fgVariableNames[kMCPhi] = "#varphi"; fgVariableUnits[kMCPhi] = "rad"; @@ -588,12 +599,34 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kMCY] = ""; fgVariableNames[kMCE] = "MC Energy"; fgVariableUnits[kMCE] = "GeV"; + fgVariableNames[kMCMass] = "MC Mass"; + fgVariableUnits[kMCMass] = "GeV/c2"; fgVariableNames[kMCVx] = "MC vx"; fgVariableUnits[kMCVx] = "cm"; // TODO: check the unit fgVariableNames[kMCVy] = "MC vy"; fgVariableUnits[kMCVy] = "cm"; // TODO: check the unit fgVariableNames[kMCVz] = "MC vz"; fgVariableUnits[kMCVz] = "cm"; // TODO: check the unit + fgVariableNames[kMCCosThetaHE] = "MC cos(#theta_{HE})"; + fgVariableUnits[kMCCosThetaHE] = ""; + fgVariableNames[kMCPhiHE] = "MC #varphi_{HE}"; + fgVariableUnits[kMCPhiHE] = "rad"; + fgVariableNames[kMCPhiTildeHE] = "MC #tilde{#varphi}_{HE}"; + fgVariableUnits[kMCPhiTildeHE] = "rad"; + fgVariableNames[kMCCosThetaCS] = "MC cos(#theta_{CS})"; + fgVariableUnits[kMCCosThetaCS] = ""; + fgVariableNames[kMCPhiCS] = "MC #varphi_{CS}"; + fgVariableUnits[kMCPhiCS] = "rad"; + fgVariableNames[kMCPhiTildeCS] = "MC #tilde{#varphi}_{CS}"; + fgVariableUnits[kMCPhiTildeCS] = "rad"; + fgVariableNames[kMCCosThetaPP] = "MC cos(#theta_{PP})"; + fgVariableUnits[kMCCosThetaPP] = ""; + fgVariableNames[kMCPhiPP] = "MC #varphi_{PP}"; + fgVariableUnits[kMCPhiPP] = "rad"; + fgVariableNames[kMCPhiTildePP] = "MC #tilde{#varphi}_{PP}"; + fgVariableUnits[kMCPhiTildePP] = "rad"; + fgVariableNames[kMCCosThetaRM] = "MC cos(#theta_{RM})"; + fgVariableUnits[kMCCosThetaRM] = ""; fgVariableNames[kCandidateId] = ""; fgVariableUnits[kCandidateId] = ""; fgVariableNames[kPairType] = "Pair type"; @@ -626,6 +659,8 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kVertexingTauzProjected] = "ns"; fgVariableNames[kVertexingTauxyProjected] = "Pair pseudo-proper Tauxy"; fgVariableUnits[kVertexingTauxyProjected] = "ns"; + fgVariableNames[kVertexingTauxyProjectedPoleJPsiMass] = "Pair pseudo-proper Tauxy (with pole JPsi mass)"; + fgVariableUnits[kVertexingTauxyProjectedPoleJPsiMass] = "ns"; fgVariableNames[kVertexingTauxyzProjected] = "Pair pseudo-proper Tauxyz"; fgVariableUnits[kVertexingTauxyzProjected] = "ns"; fgVariableNames[kCosPointingAngle] = "cos(#theta_{pointing})"; @@ -844,6 +879,68 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kCORR2POIMp] = ""; fgVariableNames[kCORR4POIMp] = "<4'> M_{p} "; fgVariableUnits[kCORR4POIMp] = ""; + fgVariableNames[kMultMuons] = "Multiplicity muons"; + fgVariableUnits[kMultMuons] = ""; + fgVariableNames[kMultAntiMuons] = "Multiplicity anti-muons"; + fgVariableUnits[kMultAntiMuons] = ""; + fgVariableNames[kM01POIplus] = "M_{01}_{POI}^{+} "; + fgVariableUnits[kM01POIplus] = ""; + fgVariableNames[kM0111POIplus] = "M^{'}_{0111}^{POI+} "; + fgVariableUnits[kM0111POIplus] = ""; + fgVariableNames[kM01POIminus] = "M_{01}_{POI}^{-} "; + fgVariableUnits[kM01POIminus] = ""; + fgVariableNames[kM0111POIminus] = "M^{'}_{0111}^{POI-} "; + fgVariableUnits[kM0111POIminus] = ""; + fgVariableNames[kM01POIoverMpminus] = "M_{01}_{POI}^{-} / M_{p} "; + fgVariableUnits[kM01POIoverMpminus] = ""; + fgVariableNames[kM01POIoverMpplus] = "M_{01}_{POI}^{+} / M_{p} "; + fgVariableUnits[kM01POIoverMpplus] = ""; + fgVariableNames[kM01POIoverMpmoins] = "M_{01}_{POI}^{-} / M_{p} "; + fgVariableUnits[kM01POIoverMpmoins] = ""; + fgVariableNames[kM01POIoverMpplus] = "M_{01}_{POI}^{+} / M_{p} "; + fgVariableUnits[kM01POIoverMpplus] = ""; + fgVariableNames[kM01POIoverMpmoins] = "M_{01}_{POI}^{-} / M_{p} "; + fgVariableUnits[kM01POIoverMpmoins] = ""; + fgVariableNames[kM0111POIoverMpminus] = "M^{'}_{0111}^{POI-} / M_{p} "; + fgVariableUnits[kM0111POIoverMpminus] = ""; + fgVariableNames[kM0111POIoverMpplus] = "M^{'}_{0111}^{POI+} / M_{p} "; + fgVariableUnits[kM0111POIoverMpplus] = ""; + fgVariableNames[kCORR2POIplus] = "<2>_{POI}^{+} "; + fgVariableUnits[kCORR2POIplus] = ""; + fgVariableNames[kCORR2POIminus] = "<2>_{POI}^{-} "; + fgVariableUnits[kCORR2POIminus] = ""; + fgVariableNames[kCORR4POIplus] = "<4>_{POI}^{+} "; + fgVariableUnits[kCORR4POIplus] = ""; + fgVariableNames[kCORR4POIminus] = "<4>_{POI}^{-} "; + fgVariableUnits[kCORR4POIminus] = ""; + fgVariableNames[kM11REFoverMpminus] = "M^{-}_{11}^{REF}/M^{-}_{p} "; + fgVariableUnits[kM11REFoverMpminus] = ""; + fgVariableNames[kM11REFoverMpplus] = "M^{+}_{11}^{REF}/M^{+}_{p} "; + fgVariableUnits[kM11REFoverMpplus] = ""; + fgVariableNames[kM1111REFoverMpplus] = "M^{+}_{1111}^{REF}/M^{+}_{p} "; + fgVariableUnits[kM1111REFoverMpplus] = ""; + fgVariableNames[kM1111REFoverMpminus] = "M^{-}_{1111}^{REF}/M^{-}_{p} "; + fgVariableUnits[kM1111REFoverMpminus] = ""; + fgVariableNames[kM01POIME] = "M_{01}^{POI, ME}"; + fgVariableUnits[kM01POIME] = ""; + fgVariableNames[kM0111POIME] = "M_{0111}^{POI, ME}"; + fgVariableUnits[kM0111POIME] = ""; + fgVariableNames[kCORR2POIME] = "CORR2^{POI, ME}"; + fgVariableUnits[kCORR2POIME] = ""; + fgVariableNames[kCORR4POIME] = "CORR4^{POI, ME}"; + fgVariableUnits[kCORR4POIME] = ""; + fgVariableNames[kM01POIoverMpME] = "M_{01}^{POI, ME} / M_p"; + fgVariableUnits[kM01POIoverMpME] = ""; + fgVariableNames[kM0111POIoverMpME] = "M_{0111}^{POI, ME} / M_p"; + fgVariableUnits[kM0111POIoverMpME] = ""; + fgVariableNames[kM11REFoverMpME] = "M_{11}^{REF} / M_p"; + fgVariableUnits[kM11REFoverMpME] = ""; + fgVariableNames[kM1111REFoverMpME] = "M_{1111}^{REF} / M_p"; + fgVariableUnits[kM1111REFoverMpME] = ""; + fgVariableNames[kCORR2REFbydimuonsME] = "CORR2^{REF} / dimuons ME"; + fgVariableUnits[kCORR2REFbydimuonsME] = ""; + fgVariableNames[kCORR4REFbydimuonsME] = "CORR4^{REF} / dimuons ME"; + fgVariableUnits[kCORR4REFbydimuonsME] = ""; fgVariableNames[kCos2DeltaPhi] = "cos 2(#varphi-#Psi_{2}^{A}) "; fgVariableUnits[kCos2DeltaPhi] = ""; fgVariableNames[kCos3DeltaPhi] = "cos 3(#varphi-#Psi_{3}^{A}) "; @@ -902,6 +999,8 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kPairPhi] = "rad."; fgVariableNames[kPairPhiv] = "#varphi_{V}"; fgVariableUnits[kPairPhiv] = "rad."; + fgVariableNames[kDileptonHadronKstar] = "Dilepton-hadron k^{*}"; + fgVariableUnits[kDileptonHadronKstar] = "GeV/c^{2}"; fgVariableNames[kDeltaEta] = "#Delta#eta"; fgVariableUnits[kDeltaEta] = ""; fgVariableNames[kDeltaPhi] = "#Delta#phi"; @@ -912,10 +1011,30 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kCosThetaHE] = ""; fgVariableNames[kPhiHE] = "#varphi_{HE}"; fgVariableUnits[kPhiHE] = "rad."; + fgVariableNames[kPhiTildeHE] = "#tilde{#varphi}_{HE}"; + fgVariableUnits[kPhiTildeHE] = "rad."; fgVariableNames[kCosThetaCS] = "cos#it{#theta}_{CS}"; fgVariableUnits[kCosThetaCS] = ""; fgVariableNames[kPhiCS] = "#varphi_{CS}"; fgVariableUnits[kPhiCS] = "rad."; + fgVariableNames[kPhiTildeCS] = "#tilde{#varphi}_{CS}"; + fgVariableUnits[kPhiTildeCS] = "rad."; + fgVariableNames[kCosThetaPP] = "cos#it{#theta}_{PP}"; + fgVariableUnits[kCosThetaPP] = ""; + fgVariableNames[kPhiPP] = "#varphi_{PP}"; + fgVariableUnits[kPhiPP] = "rad."; + fgVariableNames[kPhiTildePP] = "#tilde{#varphi}_{PP}"; + fgVariableUnits[kPhiTildePP] = "rad."; + fgVariableNames[kCosThetaRM] = "cos#it{#theta}_{RM}"; + fgVariableUnits[kCosThetaRM] = ""; + fgVariableNames[kCosThetaStarTPC] = "cos#it{#theta}^{*}_{TPC}"; + fgVariableUnits[kCosThetaStarTPC] = ""; + fgVariableNames[kCosThetaStarFT0A] = "cos#it{#theta}^{*}_{FT0A}"; + fgVariableUnits[kCosThetaStarFT0A] = ""; + fgVariableNames[kCosThetaStarFT0C] = "cos#it{#theta}^{*}_{FT0C}"; + fgVariableUnits[kCosThetaStarFT0C] = ""; + fgVariableNames[kCosPhiVP] = "cos#it{#varphi}_{VP}"; + fgVariableUnits[kCosPhiVP] = ""; fgVariableNames[kPhiVP] = "#varphi_{VP} - #Psi_{2}"; fgVariableUnits[kPhiVP] = "rad."; fgVariableNames[kDeltaPhiPair2] = "#Delta#phi"; @@ -990,4 +1109,665 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kDeltaR1] = ""; fgVariableNames[kDeltaR2] = "angular distance prong 2"; fgVariableUnits[kDeltaR2] = ""; + fgVariableNames[kV22m] = "v_{2}(2)_{#mu^{-}}"; + fgVariableUnits[kV22m] = ""; + fgVariableNames[kV24m] = "v_{2}(4)_{#mu^{-}}"; + fgVariableUnits[kV24m] = ""; + fgVariableNames[kV22p] = "v_{2}(2)_{#mu^{+}}"; + fgVariableUnits[kV22p] = ""; + fgVariableNames[kV24p] = "v_{2}(4)_{#mu^{+}}"; + fgVariableUnits[kV24p] = ""; + fgVariableNames[kV22ME] = "v_{2}(2)_{ME}"; + fgVariableUnits[kV22ME] = ""; + fgVariableNames[kV24ME] = "v_{2}(4)_{ME}"; + fgVariableUnits[kV24ME] = ""; + fgVariableNames[kWV22ME] = "W_{2}(2)_{ME}"; + fgVariableUnits[kWV22ME] = ""; + fgVariableNames[kWV24ME] = "W_{2}(4)_{ME}"; + fgVariableUnits[kWV24ME] = ""; + fgVariableNames[kS12] = "m_{12}^{2}"; + fgVariableUnits[kS12] = "GeV^{2}/c^{4}"; + fgVariableNames[kS13] = "m_{13}^{2}"; + fgVariableUnits[kS13] = "GeV^{2}/c^{4}"; + fgVariableNames[kS23] = "m_{23}^{2}"; + fgVariableUnits[kS23] = "GeV^{2}/c^{4}"; + + // Set the variables short names map. This is needed for dynamic configuration via JSON files + fgVarNamesMap["kNothing"] = kNothing; + fgVarNamesMap["kRunNo"] = kRunNo; + fgVarNamesMap["kNRunWiseVariables"] = kNRunWiseVariables; + fgVarNamesMap["kTimestamp"] = kTimestamp; + fgVarNamesMap["kTimeFromSOR"] = kTimeFromSOR; + fgVarNamesMap["kCollisionTime"] = kCollisionTime; + fgVarNamesMap["kCollisionTimeRes"] = kCollisionTimeRes; + fgVarNamesMap["kBC"] = kBC; + fgVarNamesMap["kBCOrbit"] = kBCOrbit; + fgVarNamesMap["kIsPhysicsSelection"] = kIsPhysicsSelection; + fgVarNamesMap["kIsNoTFBorder"] = kIsNoTFBorder; + fgVarNamesMap["kIsNoITSROFBorder"] = kIsNoITSROFBorder; + fgVarNamesMap["kIsNoITSROFBorderRecomputed"] = kIsNoITSROFBorderRecomputed; + fgVarNamesMap["kIsNoSameBunch"] = kIsNoSameBunch; + fgVarNamesMap["kIsGoodZvtxFT0vsPV"] = kIsGoodZvtxFT0vsPV; + fgVarNamesMap["kIsVertexITSTPC"] = kIsVertexITSTPC; + fgVarNamesMap["kIsVertexTOFmatched"] = kIsVertexTOFmatched; + fgVarNamesMap["kIsSel8"] = kIsSel8; + fgVarNamesMap["kIsGoodITSLayer3"] = kIsGoodITSLayer3; + fgVarNamesMap["kIsGoodITSLayer0123"] = kIsGoodITSLayer0123; + fgVarNamesMap["kIsGoodITSLayersAll"] = kIsGoodITSLayersAll; + fgVarNamesMap["kIsINT7"] = kIsINT7; + fgVarNamesMap["kIsEMC7"] = kIsEMC7; + fgVarNamesMap["kIsINT7inMUON"] = kIsINT7inMUON; + fgVarNamesMap["kIsMuonSingleLowPt7"] = kIsMuonSingleLowPt7; + fgVarNamesMap["kIsMuonSingleHighPt7"] = kIsMuonSingleHighPt7; + fgVarNamesMap["kIsMuonUnlikeLowPt7"] = kIsMuonUnlikeLowPt7; + fgVarNamesMap["kIsMuonLikeLowPt7"] = kIsMuonLikeLowPt7; + fgVarNamesMap["kIsCUP8"] = kIsCUP8; + fgVarNamesMap["kIsCUP9"] = kIsCUP9; + fgVarNamesMap["kIsMUP10"] = kIsMUP10; + fgVarNamesMap["kIsMUP11"] = kIsMUP11; + fgVarNamesMap["kVtxX"] = kVtxX; + fgVarNamesMap["kVtxY"] = kVtxY; + fgVarNamesMap["kVtxZ"] = kVtxZ; + fgVarNamesMap["kVtxNcontrib"] = kVtxNcontrib; + fgVarNamesMap["kVtxNcontribReal"] = kVtxNcontribReal; + fgVarNamesMap["kVtxCovXX"] = kVtxCovXX; + fgVarNamesMap["kVtxCovXY"] = kVtxCovXY; + fgVarNamesMap["kVtxCovXZ"] = kVtxCovXZ; + fgVarNamesMap["kVtxCovYY"] = kVtxCovYY; + fgVarNamesMap["kVtxCovYZ"] = kVtxCovYZ; + fgVarNamesMap["kVtxCovZZ"] = kVtxCovZZ; + fgVarNamesMap["kVtxChi2"] = kVtxChi2; + fgVarNamesMap["kCentVZERO"] = kCentVZERO; + fgVarNamesMap["kCentFT0C"] = kCentFT0C; + fgVarNamesMap["kCentFT0A"] = kCentFT0A; + fgVarNamesMap["kCentFT0M"] = kCentFT0M; + fgVarNamesMap["kMultTPC"] = kMultTPC; + fgVarNamesMap["kMultFV0A"] = kMultFV0A; + fgVarNamesMap["kMultFV0C"] = kMultFV0C; + fgVarNamesMap["kMultFT0A"] = kMultFT0A; + fgVarNamesMap["kMultFT0C"] = kMultFT0C; + fgVarNamesMap["kMultFDDA"] = kMultFDDA; + fgVarNamesMap["kMultFDDC"] = kMultFDDC; + fgVarNamesMap["kMultZNA"] = kMultZNA; + fgVarNamesMap["kMultZNC"] = kMultZNC; + fgVarNamesMap["kMultTracklets"] = kMultTracklets; + fgVarNamesMap["kMultDimuons"] = kMultDimuons; + fgVarNamesMap["kMultDimuonsME"] = kMultDimuonsME; + fgVarNamesMap["kMultNTracksHasITS"] = kMultNTracksHasITS; + fgVarNamesMap["kMultNTracksHasTPC"] = kMultNTracksHasTPC; + fgVarNamesMap["kMultNTracksHasTOF"] = kMultNTracksHasTOF; + fgVarNamesMap["kMultNTracksHasTRD"] = kMultNTracksHasTRD; + fgVarNamesMap["kMultNTracksITSOnly"] = kMultNTracksITSOnly; + fgVarNamesMap["kMultNTracksTPCOnly"] = kMultNTracksTPCOnly; + fgVarNamesMap["kMultNTracksITSTPC"] = kMultNTracksITSTPC; + fgVarNamesMap["kMultNTracksPVeta1"] = kMultNTracksPVeta1; + fgVarNamesMap["kMultNTracksPVetaHalf"] = kMultNTracksPVetaHalf; + fgVarNamesMap["kTrackOccupancyInTimeRange"] = kTrackOccupancyInTimeRange; + fgVarNamesMap["kFT0COccupancyInTimeRange"] = kFT0COccupancyInTimeRange; + fgVarNamesMap["kNoCollInTimeRangeStandard"] = kNoCollInTimeRangeStandard; + fgVarNamesMap["kMultAllTracksTPCOnly"] = kMultAllTracksTPCOnly; + fgVarNamesMap["kMultAllTracksITSTPC"] = kMultAllTracksITSTPC; + fgVarNamesMap["kNTPCpileupContribA"] = kNTPCpileupContribA; + fgVarNamesMap["kNTPCpileupContribC"] = kNTPCpileupContribC; + fgVarNamesMap["kNTPCpileupZA"] = kNTPCpileupZA; + fgVarNamesMap["kNTPCpileupZC"] = kNTPCpileupZC; + fgVarNamesMap["kNTPCtracksInPast"] = kNTPCtracksInPast; + fgVarNamesMap["kNTPCtracksInFuture"] = kNTPCtracksInFuture; + fgVarNamesMap["kNTPCcontribLongA"] = kNTPCcontribLongA; + fgVarNamesMap["kNTPCcontribLongC"] = kNTPCcontribLongC; + fgVarNamesMap["kNTPCmeanTimeLongA"] = kNTPCmeanTimeLongA; + fgVarNamesMap["kNTPCmeanTimeLongC"] = kNTPCmeanTimeLongC; + fgVarNamesMap["kNTPCmedianTimeLongA"] = kNTPCmedianTimeLongA; + fgVarNamesMap["kNTPCmedianTimeLongC"] = kNTPCmedianTimeLongC; + fgVarNamesMap["kNTPCcontribShortA"] = kNTPCcontribShortA; + fgVarNamesMap["kNTPCcontribShortC"] = kNTPCcontribShortC; + fgVarNamesMap["kNTPCmeanTimeShortA"] = kNTPCmeanTimeShortA; + fgVarNamesMap["kNTPCmeanTimeShortC"] = kNTPCmeanTimeShortC; + fgVarNamesMap["kNTPCmedianTimeShortA"] = kNTPCmedianTimeShortA; + fgVarNamesMap["kNTPCmedianTimeShortC"] = kNTPCmedianTimeShortC; + fgVarNamesMap["kMCEventGeneratorId"] = kMCEventGeneratorId; + fgVarNamesMap["kMCEventSubGeneratorId"] = kMCEventSubGeneratorId; + fgVarNamesMap["kMCVtxX"] = kMCVtxX; + fgVarNamesMap["kMCVtxY"] = kMCVtxY; + fgVarNamesMap["kMCVtxZ"] = kMCVtxZ; + fgVarNamesMap["kMCEventTime"] = kMCEventTime; + fgVarNamesMap["kMCEventWeight"] = kMCEventWeight; + fgVarNamesMap["kMCEventImpParam"] = kMCEventImpParam; + fgVarNamesMap["kQ1ZNAX"] = kQ1ZNAX; + fgVarNamesMap["kQ1ZNAY"] = kQ1ZNAY; + fgVarNamesMap["kQ1ZNCX"] = kQ1ZNCX; + fgVarNamesMap["kQ1ZNCY"] = kQ1ZNCY; + fgVarNamesMap["KIntercalibZNA"] = KIntercalibZNA; + fgVarNamesMap["KIntercalibZNC"] = KIntercalibZNC; + fgVarNamesMap["kQ1ZNACXX"] = kQ1ZNACXX; + fgVarNamesMap["kQ1ZNACYY"] = kQ1ZNACYY; + fgVarNamesMap["kQ1ZNACYX"] = kQ1ZNACYX; + fgVarNamesMap["kQ1ZNACXY"] = kQ1ZNACXY; + fgVarNamesMap["kQ1X0A"] = kQ1X0A; + fgVarNamesMap["kQ1Y0A"] = kQ1Y0A; + fgVarNamesMap["kQ1X0B"] = kQ1X0B; + fgVarNamesMap["kQ1Y0B"] = kQ1Y0B; + fgVarNamesMap["kQ1X0C"] = kQ1X0C; + fgVarNamesMap["kQ1Y0C"] = kQ1Y0C; + fgVarNamesMap["kQ2X0A"] = kQ2X0A; + fgVarNamesMap["kQ2Y0A"] = kQ2Y0A; + fgVarNamesMap["kQ2X0APOS"] = kQ2X0APOS; + fgVarNamesMap["kQ2Y0APOS"] = kQ2Y0APOS; + fgVarNamesMap["kQ2X0ANEG"] = kQ2X0ANEG; + fgVarNamesMap["kQ2Y0ANEG"] = kQ2Y0ANEG; + fgVarNamesMap["kQ2X0B"] = kQ2X0B; + fgVarNamesMap["kQ2Y0B"] = kQ2Y0B; + fgVarNamesMap["kQ2X0C"] = kQ2X0C; + fgVarNamesMap["kQ2Y0C"] = kQ2Y0C; + fgVarNamesMap["kQ2YYAB"] = kQ2YYAB; + fgVarNamesMap["kQ2XXAB"] = kQ2XXAB; + fgVarNamesMap["kQ2XYAB"] = kQ2XYAB; + fgVarNamesMap["kQ2YXAB"] = kQ2YXAB; + fgVarNamesMap["kQ2YYAC"] = kQ2YYAC; + fgVarNamesMap["kQ2XXAC"] = kQ2XXAC; + fgVarNamesMap["kQ2XYAC"] = kQ2XYAC; + fgVarNamesMap["kQ2YXAC"] = kQ2YXAC; + fgVarNamesMap["kQ2YYBC"] = kQ2YYBC; + fgVarNamesMap["kQ2XXBC"] = kQ2XXBC; + fgVarNamesMap["kQ2XYBC"] = kQ2XYBC; + fgVarNamesMap["kQ2YXBC"] = kQ2YXBC; + fgVarNamesMap["kMultA"] = kMultA; + fgVarNamesMap["kMultAPOS"] = kMultAPOS; + fgVarNamesMap["kMultANEG"] = kMultANEG; + fgVarNamesMap["kMultB"] = kMultB; + fgVarNamesMap["kMultC"] = kMultC; + fgVarNamesMap["kQ3X0A"] = kQ3X0A; + fgVarNamesMap["kQ3Y0A"] = kQ3Y0A; + fgVarNamesMap["kQ3X0B"] = kQ3X0B; + fgVarNamesMap["kQ3Y0B"] = kQ3Y0B; + fgVarNamesMap["kQ3X0C"] = kQ3X0C; + fgVarNamesMap["kQ3Y0C"] = kQ3Y0C; + fgVarNamesMap["kQ4X0A"] = kQ4X0A; + fgVarNamesMap["kQ4Y0A"] = kQ4Y0A; + fgVarNamesMap["kQ4X0B"] = kQ4X0B; + fgVarNamesMap["kQ4Y0B"] = kQ4Y0B; + fgVarNamesMap["kQ4X0C"] = kQ4X0C; + fgVarNamesMap["kQ4Y0C"] = kQ4Y0C; + fgVarNamesMap["kR2SP_AB"] = kR2SP_AB; + fgVarNamesMap["kR2SP_AC"] = kR2SP_AC; + fgVarNamesMap["kR2SP_BC"] = kR2SP_BC; + fgVarNamesMap["kWR2SP_AB"] = kWR2SP_AB; + fgVarNamesMap["kWR2SP_AC"] = kWR2SP_AC; + fgVarNamesMap["kWR2SP_BC"] = kWR2SP_BC; + fgVarNamesMap["kR2SP_AB_Im"] = kR2SP_AB_Im; + fgVarNamesMap["kR2SP_AC_Im"] = kR2SP_AC_Im; + fgVarNamesMap["kR2SP_BC_Im"] = kR2SP_BC_Im; + fgVarNamesMap["kWR2SP_AB_Im"] = kWR2SP_AB_Im; + fgVarNamesMap["kWR2SP_AC_Im"] = kWR2SP_AC_Im; + fgVarNamesMap["kWR2SP_BC_Im"] = kWR2SP_BC_Im; + fgVarNamesMap["kR2SP_FT0CTPCPOS"] = kR2SP_FT0CTPCPOS; + fgVarNamesMap["kR2SP_FT0CTPCNEG"] = kR2SP_FT0CTPCNEG; + fgVarNamesMap["kR2SP_FT0ATPCPOS"] = kR2SP_FT0ATPCPOS; + fgVarNamesMap["kR2SP_FT0ATPCNEG"] = kR2SP_FT0ATPCNEG; + fgVarNamesMap["kR2SP_FT0MTPCPOS"] = kR2SP_FT0MTPCPOS; + fgVarNamesMap["kR2SP_FT0MTPCNEG"] = kR2SP_FT0MTPCNEG; + fgVarNamesMap["kR2SP_FV0ATPCPOS"] = kR2SP_FV0ATPCPOS; + fgVarNamesMap["kR2SP_FV0ATPCNEG"] = kR2SP_FV0ATPCNEG; + fgVarNamesMap["kR3SP"] = kR3SP; + fgVarNamesMap["kR2EP_AB"] = kR2EP_AB; + fgVarNamesMap["kR2EP_AC"] = kR2EP_AC; + fgVarNamesMap["kR2EP_BC"] = kR2EP_BC; + fgVarNamesMap["kWR2EP_AB"] = kWR2EP_AB; + fgVarNamesMap["kWR2EP_AC"] = kWR2EP_AC; + fgVarNamesMap["kWR2EP_BC"] = kWR2EP_BC; + fgVarNamesMap["kR2EP_AB_Im"] = kR2EP_AB_Im; + fgVarNamesMap["kR2EP_AC_Im"] = kR2EP_AC_Im; + fgVarNamesMap["kR2EP_BC_Im"] = kR2EP_BC_Im; + fgVarNamesMap["kWR2EP_AB_Im"] = kWR2EP_AB_Im; + fgVarNamesMap["kWR2EP_AC_Im"] = kWR2EP_AC_Im; + fgVarNamesMap["kWR2EP_BC_Im"] = kWR2EP_BC_Im; + fgVarNamesMap["kR2EP_FT0CTPCPOS"] = kR2EP_FT0CTPCPOS; + fgVarNamesMap["kR2EP_FT0CTPCNEG"] = kR2EP_FT0CTPCNEG; + fgVarNamesMap["kR2EP_FT0ATPCPOS"] = kR2EP_FT0ATPCPOS; + fgVarNamesMap["kR2EP_FT0ATPCNEG"] = kR2EP_FT0ATPCNEG; + fgVarNamesMap["kR2EP_FT0MTPCPOS"] = kR2EP_FT0MTPCPOS; + fgVarNamesMap["kR2EP_FT0MTPCNEG"] = kR2EP_FT0MTPCNEG; + fgVarNamesMap["kR2EP_FV0ATPCPOS"] = kR2EP_FV0ATPCPOS; + fgVarNamesMap["kR2EP_FV0ATPCNEG"] = kR2EP_FV0ATPCNEG; + fgVarNamesMap["kR3EP"] = kR3EP; + fgVarNamesMap["kIsDoubleGap"] = kIsDoubleGap; + fgVarNamesMap["kIsSingleGapA"] = kIsSingleGapA; + fgVarNamesMap["kIsSingleGapC"] = kIsSingleGapC; + fgVarNamesMap["kIsSingleGap"] = kIsSingleGap; + fgVarNamesMap["kIsITSUPCMode"] = kIsITSUPCMode; + fgVarNamesMap["kTwoEvPosZ1"] = kTwoEvPosZ1; + fgVarNamesMap["kTwoEvPosZ2"] = kTwoEvPosZ2; + fgVarNamesMap["kTwoEvPosR1"] = kTwoEvPosR1; + fgVarNamesMap["kTwoEvPosR2"] = kTwoEvPosR2; + fgVarNamesMap["kTwoEvCentFT0C1"] = kTwoEvCentFT0C1; + fgVarNamesMap["kTwoEvCentFT0C2"] = kTwoEvCentFT0C2; + fgVarNamesMap["kTwoEvPVcontrib1"] = kTwoEvPVcontrib1; + fgVarNamesMap["kTwoEvPVcontrib2"] = kTwoEvPVcontrib2; + fgVarNamesMap["kTwoEvDeltaZ"] = kTwoEvDeltaZ; + fgVarNamesMap["kTwoEvDeltaX"] = kTwoEvDeltaX; + fgVarNamesMap["kTwoEvDeltaY"] = kTwoEvDeltaY; + fgVarNamesMap["kTwoEvDeltaR"] = kTwoEvDeltaR; + fgVarNamesMap["kEnergyCommonZNA"] = kEnergyCommonZNA; + fgVarNamesMap["kEnergyCommonZNC"] = kEnergyCommonZNC; + fgVarNamesMap["kEnergyCommonZPA"] = kEnergyCommonZPA; + fgVarNamesMap["kEnergyCommonZPC"] = kEnergyCommonZPC; + fgVarNamesMap["kEnergyZNA1"] = kEnergyZNA1; + fgVarNamesMap["kEnergyZNA2"] = kEnergyZNA2; + fgVarNamesMap["kEnergyZNA3"] = kEnergyZNA3; + fgVarNamesMap["kEnergyZNA4"] = kEnergyZNA4; + fgVarNamesMap["kEnergyZNC1"] = kEnergyZNC1; + fgVarNamesMap["kEnergyZNC2"] = kEnergyZNC2; + fgVarNamesMap["kEnergyZNC3"] = kEnergyZNC3; + fgVarNamesMap["kEnergyZNC4"] = kEnergyZNC4; + fgVarNamesMap["kTimeZNA"] = kTimeZNA; + fgVarNamesMap["kTimeZNC"] = kTimeZNC; + fgVarNamesMap["kTimeZPA"] = kTimeZPA; + fgVarNamesMap["kTimeZPC"] = kTimeZPC; + fgVarNamesMap["kQ2X0A1"] = kQ2X0A1; + fgVarNamesMap["kQ2X0A2"] = kQ2X0A2; + fgVarNamesMap["kQ2Y0A1"] = kQ2Y0A1; + fgVarNamesMap["kQ2Y0A2"] = kQ2Y0A2; + fgVarNamesMap["kU2Q2Ev1"] = kU2Q2Ev1; + fgVarNamesMap["kU2Q2Ev2"] = kU2Q2Ev2; + fgVarNamesMap["kCos2DeltaPhiEv1"] = kCos2DeltaPhiEv1; + fgVarNamesMap["kCos2DeltaPhiEv2"] = kCos2DeltaPhiEv2; + fgVarNamesMap["kV2SP1"] = kV2SP1; + fgVarNamesMap["kV2SP2"] = kV2SP2; + fgVarNamesMap["kV2EP1"] = kV2EP1; + fgVarNamesMap["kV2EP2"] = kV2EP2; + fgVarNamesMap["kV2ME_SP"] = kV2ME_SP; + fgVarNamesMap["kV2ME_EP"] = kV2ME_EP; + fgVarNamesMap["kWV2ME_SP"] = kWV2ME_SP; + fgVarNamesMap["kWV2ME_EP"] = kWV2ME_EP; + fgVarNamesMap["kTwoR2SP1"] = kTwoR2SP1; + fgVarNamesMap["kTwoR2SP2"] = kTwoR2SP2; + fgVarNamesMap["kTwoR2EP1"] = kTwoR2EP1; + fgVarNamesMap["kTwoR2EP2"] = kTwoR2EP2; + fgVarNamesMap["kNEventWiseVariables"] = kNEventWiseVariables; + fgVarNamesMap["kX"] = kX; + fgVarNamesMap["kY"] = kY; + fgVarNamesMap["kZ"] = kZ; + fgVarNamesMap["kPt"] = kPt; + fgVarNamesMap["kSignedPt"] = kSignedPt; + fgVarNamesMap["kInvPt"] = kInvPt; + fgVarNamesMap["kEta"] = kEta; + fgVarNamesMap["kTgl"] = kTgl; + fgVarNamesMap["kPhi"] = kPhi; + fgVarNamesMap["kP"] = kP; + fgVarNamesMap["kPx"] = kPx; + fgVarNamesMap["kPy"] = kPy; + fgVarNamesMap["kPz"] = kPz; + fgVarNamesMap["kRap"] = kRap; + fgVarNamesMap["kMass"] = kMass; + fgVarNamesMap["kCharge"] = kCharge; + fgVarNamesMap["kNBasicTrackVariables"] = kNBasicTrackVariables; + fgVarNamesMap["kUsedKF"] = kUsedKF; + fgVarNamesMap["kKFMass"] = kKFMass; + fgVarNamesMap["kKFMassGeoTop"] = kKFMassGeoTop; + fgVarNamesMap["kPt1"] = kPt1; + fgVarNamesMap["kEta1"] = kEta1; + fgVarNamesMap["kPhi1"] = kPhi1; + fgVarNamesMap["kCharge1"] = kCharge1; + fgVarNamesMap["kPin_leg1"] = kPin_leg1; + fgVarNamesMap["kTPCnSigmaKa_leg1"] = kTPCnSigmaKa_leg1; + fgVarNamesMap["kPt2"] = kPt2; + fgVarNamesMap["kEta2"] = kEta2; + fgVarNamesMap["kPhi2"] = kPhi2; + fgVarNamesMap["kCharge2"] = kCharge2; + fgVarNamesMap["kPin"] = kPin; + fgVarNamesMap["kSignedPin"] = kSignedPin; + fgVarNamesMap["kTOFExpMom"] = kTOFExpMom; + fgVarNamesMap["kTrackTime"] = kTrackTime; + fgVarNamesMap["kTrackTimeRes"] = kTrackTimeRes; + fgVarNamesMap["kTrackTimeResRelative"] = kTrackTimeResRelative; + fgVarNamesMap["kDetectorMap"] = kDetectorMap; + fgVarNamesMap["kHasITS"] = kHasITS; + fgVarNamesMap["kHasTRD"] = kHasTRD; + fgVarNamesMap["kHasTOF"] = kHasTOF; + fgVarNamesMap["kHasTPC"] = kHasTPC; + fgVarNamesMap["kIsGlobalTrack"] = kIsGlobalTrack; + fgVarNamesMap["kIsGlobalTrackSDD"] = kIsGlobalTrackSDD; + fgVarNamesMap["kIsITSrefit"] = kIsITSrefit; + fgVarNamesMap["kIsSPDany"] = kIsSPDany; + fgVarNamesMap["kIsSPDfirst"] = kIsSPDfirst; + fgVarNamesMap["kIsSPDboth"] = kIsSPDboth; + fgVarNamesMap["kIsITSibAny"] = kIsITSibAny; + fgVarNamesMap["kIsITSibFirst"] = kIsITSibFirst; + fgVarNamesMap["kIsITSibAll"] = kIsITSibAll; + fgVarNamesMap["kITSncls"] = kITSncls; + fgVarNamesMap["kITSchi2"] = kITSchi2; + fgVarNamesMap["kITSlayerHit"] = kITSlayerHit; + fgVarNamesMap["kITSmeanClsSize"] = kITSmeanClsSize; + fgVarNamesMap["kIsTPCrefit"] = kIsTPCrefit; + fgVarNamesMap["kTPCncls"] = kTPCncls; + fgVarNamesMap["kITSClusterMap"] = kITSClusterMap; + fgVarNamesMap["kTPCnclsCR"] = kTPCnclsCR; + fgVarNamesMap["kTPCnCRoverFindCls"] = kTPCnCRoverFindCls; + fgVarNamesMap["kTPCchi2"] = kTPCchi2; + fgVarNamesMap["kTPCsignal"] = kTPCsignal; + fgVarNamesMap["kTPCsignalRandomized"] = kTPCsignalRandomized; + fgVarNamesMap["kTPCsignalRandomizedDelta"] = kTPCsignalRandomizedDelta; + fgVarNamesMap["kPhiTPCOuter"] = kPhiTPCOuter; + fgVarNamesMap["kTrackIsInsideTPCModule"] = kTrackIsInsideTPCModule; + fgVarNamesMap["kTRDsignal"] = kTRDsignal; + fgVarNamesMap["kTRDPattern"] = kTRDPattern; + fgVarNamesMap["kTOFbeta"] = kTOFbeta; + fgVarNamesMap["kTrackLength"] = kTrackLength; + fgVarNamesMap["kTrackDCAxy"] = kTrackDCAxy; + fgVarNamesMap["kTrackDCAxyProng1"] = kTrackDCAxyProng1; + fgVarNamesMap["kTrackDCAxyProng2"] = kTrackDCAxyProng2; + fgVarNamesMap["kTrackDCAz"] = kTrackDCAz; + fgVarNamesMap["kTrackDCAzProng1"] = kTrackDCAzProng1; + fgVarNamesMap["kTrackDCAzProng2"] = kTrackDCAzProng2; + fgVarNamesMap["kTrackDCAsigXY"] = kTrackDCAsigXY; + fgVarNamesMap["kTrackDCAsigZ"] = kTrackDCAsigZ; + fgVarNamesMap["kTrackDCAresXY"] = kTrackDCAresXY; + fgVarNamesMap["kTrackDCAresZ"] = kTrackDCAresZ; + fgVarNamesMap["kIsGoldenChi2"] = kIsGoldenChi2; + fgVarNamesMap["kTrackCYY"] = kTrackCYY; + fgVarNamesMap["kTrackCZZ"] = kTrackCZZ; + fgVarNamesMap["kTrackCSnpSnp"] = kTrackCSnpSnp; + fgVarNamesMap["kTrackCTglTgl"] = kTrackCTglTgl; + fgVarNamesMap["kTrackC1Pt21Pt2"] = kTrackC1Pt21Pt2; + fgVarNamesMap["kTPCnSigmaEl"] = kTPCnSigmaEl; + fgVarNamesMap["kTPCnSigmaElRandomized"] = kTPCnSigmaElRandomized; + fgVarNamesMap["kTPCnSigmaElRandomizedDelta"] = kTPCnSigmaElRandomizedDelta; + fgVarNamesMap["kTPCnSigmaMu"] = kTPCnSigmaMu; + fgVarNamesMap["kTPCnSigmaPi"] = kTPCnSigmaPi; + fgVarNamesMap["kTPCnSigmaPiRandomized"] = kTPCnSigmaPiRandomized; + fgVarNamesMap["kTPCnSigmaPiRandomizedDelta"] = kTPCnSigmaPiRandomizedDelta; + fgVarNamesMap["kTPCnSigmaKa"] = kTPCnSigmaKa; + fgVarNamesMap["kTPCnSigmaPr"] = kTPCnSigmaPr; + fgVarNamesMap["kTPCnSigmaEl_Corr"] = kTPCnSigmaEl_Corr; + fgVarNamesMap["kTPCnSigmaPi_Corr"] = kTPCnSigmaPi_Corr; + fgVarNamesMap["kTPCnSigmaKa_Corr"] = kTPCnSigmaKa_Corr; + fgVarNamesMap["kTPCnSigmaPr_Corr"] = kTPCnSigmaPr_Corr; + fgVarNamesMap["kTPCnSigmaPrRandomized"] = kTPCnSigmaPrRandomized; + fgVarNamesMap["kTPCnSigmaPrRandomizedDelta"] = kTPCnSigmaPrRandomizedDelta; + fgVarNamesMap["kTOFnSigmaEl"] = kTOFnSigmaEl; + fgVarNamesMap["kTOFnSigmaMu"] = kTOFnSigmaMu; + fgVarNamesMap["kTOFnSigmaPi"] = kTOFnSigmaPi; + fgVarNamesMap["kTOFnSigmaKa"] = kTOFnSigmaKa; + fgVarNamesMap["kTOFnSigmaPr"] = kTOFnSigmaPr; + fgVarNamesMap["kTrackTimeResIsRange"] = kTrackTimeResIsRange; + fgVarNamesMap["kPVContributor"] = kPVContributor; + fgVarNamesMap["kOrphanTrack"] = kOrphanTrack; + fgVarNamesMap["kIsAmbiguous"] = kIsAmbiguous; + fgVarNamesMap["kIsLegFromGamma"] = kIsLegFromGamma; + fgVarNamesMap["kIsLegFromK0S"] = kIsLegFromK0S; + fgVarNamesMap["kIsLegFromLambda"] = kIsLegFromLambda; + fgVarNamesMap["kIsLegFromAntiLambda"] = kIsLegFromAntiLambda; + fgVarNamesMap["kIsLegFromOmega"] = kIsLegFromOmega; + fgVarNamesMap["kIsProtonFromLambdaAndAntiLambda"] = kIsProtonFromLambdaAndAntiLambda; + fgVarNamesMap["kIsDalitzLeg"] = kIsDalitzLeg; + fgVarNamesMap["kBarrelNAssocsInBunch"] = kBarrelNAssocsInBunch; + fgVarNamesMap["kBarrelNAssocsOutOfBunch"] = kBarrelNAssocsOutOfBunch; + fgVarNamesMap["kNBarrelTrackVariables"] = kNBarrelTrackVariables; + fgVarNamesMap["kMuonNClusters"] = kMuonNClusters; + fgVarNamesMap["kMuonPDca"] = kMuonPDca; + fgVarNamesMap["kMuonRAtAbsorberEnd"] = kMuonRAtAbsorberEnd; + fgVarNamesMap["kMCHBitMap"] = kMCHBitMap; + fgVarNamesMap["kMuonChi2"] = kMuonChi2; + fgVarNamesMap["kMuonChi2MatchMCHMID"] = kMuonChi2MatchMCHMID; + fgVarNamesMap["kMuonChi2MatchMCHMFT"] = kMuonChi2MatchMCHMFT; + fgVarNamesMap["kMuonMatchScoreMCHMFT"] = kMuonMatchScoreMCHMFT; + fgVarNamesMap["kMuonCXX"] = kMuonCXX; + fgVarNamesMap["kMuonCXY"] = kMuonCXY; + fgVarNamesMap["kMuonCYY"] = kMuonCYY; + fgVarNamesMap["kMuonCPhiX"] = kMuonCPhiX; + fgVarNamesMap["kMuonCPhiY"] = kMuonCPhiY; + fgVarNamesMap["kMuonCPhiPhi"] = kMuonCPhiPhi; + fgVarNamesMap["kMuonCTglX"] = kMuonCTglX; + fgVarNamesMap["kMuonCTglY"] = kMuonCTglY; + fgVarNamesMap["kMuonCTglPhi"] = kMuonCTglPhi; + fgVarNamesMap["kMuonCTglTgl"] = kMuonCTglTgl; + fgVarNamesMap["kMuonC1Pt2X"] = kMuonC1Pt2X; + fgVarNamesMap["kMuonC1Pt2Y"] = kMuonC1Pt2Y; + fgVarNamesMap["kMuonC1Pt2Phi"] = kMuonC1Pt2Phi; + fgVarNamesMap["kMuonC1Pt2Tgl"] = kMuonC1Pt2Tgl; + fgVarNamesMap["kMuonC1Pt21Pt2"] = kMuonC1Pt21Pt2; + fgVarNamesMap["kMuonTrackType"] = kMuonTrackType; + fgVarNamesMap["kMuonDCAx"] = kMuonDCAx; + fgVarNamesMap["kMuonDCAy"] = kMuonDCAy; + fgVarNamesMap["kMuonTime"] = kMuonTime; + fgVarNamesMap["kMuonTimeRes"] = kMuonTimeRes; + fgVarNamesMap["kMftNClusters"] = kMftNClusters; + fgVarNamesMap["kMftClusterSize"] = kMftClusterSize; + fgVarNamesMap["kMftMeanClusterSize"] = kMftMeanClusterSize; + fgVarNamesMap["kMuonNAssocsInBunch"] = kMuonNAssocsInBunch; + fgVarNamesMap["kMuonNAssocsOutOfBunch"] = kMuonNAssocsOutOfBunch; + fgVarNamesMap["kNMuonTrackVariables"] = kNMuonTrackVariables; + fgVarNamesMap["kMCPdgCode"] = kMCPdgCode; + fgVarNamesMap["kMCParticleWeight"] = kMCParticleWeight; + fgVarNamesMap["kMCPx"] = kMCPx; + fgVarNamesMap["kMCPy"] = kMCPy; + fgVarNamesMap["kMCPz"] = kMCPz; + fgVarNamesMap["kMCE"] = kMCE; + fgVarNamesMap["kMCVx"] = kMCVx; + fgVarNamesMap["kMCVy"] = kMCVy; + fgVarNamesMap["kMCVz"] = kMCVz; + fgVarNamesMap["kMCPt"] = kMCPt; + fgVarNamesMap["kMCPhi"] = kMCPhi; + fgVarNamesMap["kMCEta"] = kMCEta; + fgVarNamesMap["kMCY"] = kMCY; + fgVarNamesMap["kMCCosThetaHE"] = kMCCosThetaHE; + fgVarNamesMap["kMCPhiHE"] = kMCPhiHE; + fgVarNamesMap["kMCPhiTildeHE"] = kMCPhiTildeHE; + fgVarNamesMap["kMCCosThetaCS"] = kMCCosThetaCS; + fgVarNamesMap["kMCPhiCS"] = kMCPhiCS; + fgVarNamesMap["kMCPhiTildeCS"] = kMCPhiTildeCS; + fgVarNamesMap["kMCCosThetaPP"] = kMCCosThetaPP; + fgVarNamesMap["kMCPhiPP"] = kMCPhiPP; + fgVarNamesMap["kMCPhiTildePP"] = kMCPhiTildePP; + fgVarNamesMap["kMCCosThetaRM"] = kMCCosThetaRM; + fgVarNamesMap["kMCParticleGeneratorId"] = kMCParticleGeneratorId; + fgVarNamesMap["kNMCParticleVariables"] = kNMCParticleVariables; + fgVarNamesMap["kMCMotherPdgCode"] = kMCMotherPdgCode; + fgVarNamesMap["kCandidateId"] = kCandidateId; + fgVarNamesMap["kPairType"] = kPairType; + fgVarNamesMap["kVertexingLxy"] = kVertexingLxy; + fgVarNamesMap["kVertexingLxyErr"] = kVertexingLxyErr; + fgVarNamesMap["kVertexingPseudoCTau"] = kVertexingPseudoCTau; + fgVarNamesMap["kVertexingLxyz"] = kVertexingLxyz; + fgVarNamesMap["kVertexingLxyzErr"] = kVertexingLxyzErr; + fgVarNamesMap["kVertexingLz"] = kVertexingLz; + fgVarNamesMap["kVertexingLzErr"] = kVertexingLzErr; + fgVarNamesMap["kVertexingTauxy"] = kVertexingTauxy; + fgVarNamesMap["kVertexingTauxyErr"] = kVertexingTauxyErr; + fgVarNamesMap["kVertexingLzProjected"] = kVertexingLzProjected; + fgVarNamesMap["kVertexingLxyProjected"] = kVertexingLxyProjected; + fgVarNamesMap["kVertexingLxyzProjected"] = kVertexingLxyzProjected; + fgVarNamesMap["kVertexingTauzProjected"] = kVertexingTauzProjected; + fgVarNamesMap["kVertexingTauxyProjected"] = kVertexingTauxyProjected; + fgVarNamesMap["kVertexingTauxyProjectedPoleJPsiMass"] = kVertexingTauxyProjectedPoleJPsiMass; + fgVarNamesMap["kVertexingTauxyProjectedNs"] = kVertexingTauxyProjectedNs; + fgVarNamesMap["kVertexingTauxyzProjected"] = kVertexingTauxyzProjected; + fgVarNamesMap["kVertexingTauz"] = kVertexingTauz; + fgVarNamesMap["kVertexingTauzErr"] = kVertexingTauzErr; + fgVarNamesMap["kVertexingPz"] = kVertexingPz; + fgVarNamesMap["kVertexingSV"] = kVertexingSV; + fgVarNamesMap["kVertexingProcCode"] = kVertexingProcCode; + fgVarNamesMap["kVertexingChi2PCA"] = kVertexingChi2PCA; + fgVarNamesMap["kCosThetaHE"] = kCosThetaHE; + fgVarNamesMap["kPhiHE"] = kPhiHE; + fgVarNamesMap["kPhiTildeHE"] = kPhiTildeHE; + fgVarNamesMap["kCosThetaCS"] = kCosThetaCS; + fgVarNamesMap["kPhiCS"] = kPhiCS; + fgVarNamesMap["kPhiTildeCS"] = kPhiTildeCS; + fgVarNamesMap["kCosThetaPP"] = kCosThetaPP; + fgVarNamesMap["kPhiPP"] = kPhiPP; + fgVarNamesMap["kPhiTildePP"] = kPhiTildePP; + fgVarNamesMap["kCosThetaRM"] = kCosThetaRM; + fgVarNamesMap["kCosThetaStarTPC"] = kCosThetaStarTPC; + fgVarNamesMap["kCosThetaStarFT0A"] = kCosThetaStarFT0A; + fgVarNamesMap["kCosThetaStarFT0C"] = kCosThetaStarFT0C; + fgVarNamesMap["kCosPhiVP"] = kCosPhiVP; + fgVarNamesMap["kPhiVP"] = kPhiVP; + fgVarNamesMap["kDeltaPhiPair2"] = kDeltaPhiPair2; + fgVarNamesMap["kDeltaEtaPair2"] = kDeltaEtaPair2; + fgVarNamesMap["kPsiPair"] = kPsiPair; + fgVarNamesMap["kDeltaPhiPair"] = kDeltaPhiPair; + fgVarNamesMap["kOpeningAngle"] = kOpeningAngle; + fgVarNamesMap["kQuadDCAabsXY"] = kQuadDCAabsXY; + fgVarNamesMap["kQuadDCAsigXY"] = kQuadDCAsigXY; + fgVarNamesMap["kQuadDCAabsZ"] = kQuadDCAabsZ; + fgVarNamesMap["kQuadDCAsigZ"] = kQuadDCAsigZ; + fgVarNamesMap["kQuadDCAsigXYZ"] = kQuadDCAsigXYZ; + fgVarNamesMap["kSignQuadDCAsigXY"] = kSignQuadDCAsigXY; + fgVarNamesMap["kCosPointingAngle"] = kCosPointingAngle; + fgVarNamesMap["kImpParXYJpsi"] = kImpParXYJpsi; + fgVarNamesMap["kImpParXYK"] = kImpParXYK; + fgVarNamesMap["kDCATrackProd"] = kDCATrackProd; + fgVarNamesMap["kDCATrackVtxProd"] = kDCATrackVtxProd; + fgVarNamesMap["kV2SP"] = kV2SP; + fgVarNamesMap["kV2EP"] = kV2EP; + fgVarNamesMap["kWV2SP"] = kWV2SP; + fgVarNamesMap["kWV2EP"] = kWV2EP; + fgVarNamesMap["kU2Q2"] = kU2Q2; + fgVarNamesMap["kU3Q3"] = kU3Q3; + fgVarNamesMap["kQ42XA"] = kQ42XA; + fgVarNamesMap["kQ42YA"] = kQ42YA; + fgVarNamesMap["kQ23XA"] = kQ23XA; + fgVarNamesMap["kQ23YA"] = kQ23YA; + fgVarNamesMap["kS11A"] = kS11A; + fgVarNamesMap["kS12A"] = kS12A; + fgVarNamesMap["kS13A"] = kS13A; + fgVarNamesMap["kS31A"] = kS31A; + fgVarNamesMap["kM11REF"] = kM11REF; + fgVarNamesMap["kM11REFetagap"] = kM11REFetagap; + fgVarNamesMap["kM01POI"] = kM01POI; + fgVarNamesMap["kM1111REF"] = kM1111REF; + fgVarNamesMap["kM11M1111REF"] = kM11M1111REF; + fgVarNamesMap["kM11M1111REFoverMp"] = kM11M1111REFoverMp; + fgVarNamesMap["kM01M0111POIoverMp"] = kM01M0111POIoverMp; + fgVarNamesMap["kM0111POI"] = kM0111POI; + fgVarNamesMap["kCORR2REF"] = kCORR2REF; + fgVarNamesMap["kCORR2REFbydimuons"] = kCORR2REFbydimuons; + fgVarNamesMap["kMultAntiMuons"] = kMultAntiMuons; + fgVarNamesMap["kMultMuons"] = kMultMuons; + fgVarNamesMap["kM01POIplus"] = kM01POIplus; + fgVarNamesMap["kM0111POIplus"] = kM0111POIplus; + fgVarNamesMap["kM01POIminus"] = kM01POIminus; + fgVarNamesMap["kM0111POIminus"] = kM0111POIminus; + fgVarNamesMap["kM01POIoverMpminus"] = kM01POIoverMpminus; + fgVarNamesMap["kM01POIoverMpplus"] = kM01POIoverMpplus; + fgVarNamesMap["kM01POIoverMpmoins"] = kM01POIoverMpmoins; + fgVarNamesMap["kM0111POIoverMpminus"] = kM0111POIoverMpminus; + fgVarNamesMap["kM0111POIoverMpplus"] = kM0111POIoverMpplus; + fgVarNamesMap["kCORR2POIplus"] = kCORR2POIplus; + fgVarNamesMap["kCORR2POIminus"] = kCORR2POIminus; + fgVarNamesMap["kCORR4POIplus"] = kCORR4POIplus; + fgVarNamesMap["kCORR4POIminus"] = kCORR4POIminus; + fgVarNamesMap["kM11REFoverMpminus"] = kM11REFoverMpminus; + fgVarNamesMap["kM11REFoverMpplus"] = kM11REFoverMpplus; + fgVarNamesMap["kM1111REFoverMpplus"] = kM1111REFoverMpplus; + fgVarNamesMap["kM1111REFoverMpminus"] = kM1111REFoverMpminus; + fgVarNamesMap["kCORR2REFetagap"] = kCORR2REFetagap; + fgVarNamesMap["kCORR2POI"] = kCORR2POI; + fgVarNamesMap["kCORR2POICORR4POI"] = kCORR2POICORR4POI; + fgVarNamesMap["kCORR2REFCORR4POI"] = kCORR2REFCORR4POI; + fgVarNamesMap["kCORR2REFCORR2POI"] = kCORR2REFCORR2POI; + fgVarNamesMap["kM01M0111overMp"] = kM01M0111overMp; + fgVarNamesMap["kM11M0111overMp"] = kM11M0111overMp; + fgVarNamesMap["kM11M01overMp"] = kM11M01overMp; + fgVarNamesMap["kCORR2CORR4REF"] = kCORR2CORR4REF; + fgVarNamesMap["kCORR4REF"] = kCORR4REF; + fgVarNamesMap["kCORR4REFbydimuons"] = kCORR4REFbydimuons; + fgVarNamesMap["kCORR4POI"] = kCORR4POI; + fgVarNamesMap["kM11REFoverMp"] = kM11REFoverMp; + fgVarNamesMap["kM01POIoverMp"] = kM01POIoverMp; + fgVarNamesMap["kM1111REFoverMp"] = kM1111REFoverMp; + fgVarNamesMap["kM0111POIoverMp"] = kM0111POIoverMp; + fgVarNamesMap["kCORR2POIMp"] = kCORR2POIMp; + fgVarNamesMap["kCORR4POIMp"] = kCORR4POIMp; + fgVarNamesMap["kM01POIME"] = kM01POIME; + fgVarNamesMap["kMultDimuonsME"] = kMultDimuonsME; + fgVarNamesMap["kM0111POIME"] = kM0111POIME; + fgVarNamesMap["kCORR2POIME"] = kCORR2POIME; + fgVarNamesMap["kCORR4POIME"] = kCORR4POIME; + fgVarNamesMap["kM01POIoverMpME"] = kM01POIoverMpME; + fgVarNamesMap["kM0111POIoverMpME"] = kM0111POIoverMpME; + fgVarNamesMap["kM11REFoverMpME"] = kM11REFoverMpME; + fgVarNamesMap["kM1111REFoverMpME"] = kM1111REFoverMpME; + fgVarNamesMap["kCORR2REFbydimuonsME"] = kCORR2REFbydimuonsME; + fgVarNamesMap["kCORR4REFbydimuonsME"] = kCORR4REFbydimuonsME; + fgVarNamesMap["kR2SP"] = kR2SP; + fgVarNamesMap["kR2EP"] = kR2EP; + fgVarNamesMap["kPsi2A"] = kPsi2A; + fgVarNamesMap["kPsi2APOS"] = kPsi2APOS; + fgVarNamesMap["kPsi2ANEG"] = kPsi2ANEG; + fgVarNamesMap["kPsi2B"] = kPsi2B; + fgVarNamesMap["kPsi2C"] = kPsi2C; + fgVarNamesMap["kCos2DeltaPhi"] = kCos2DeltaPhi; + fgVarNamesMap["kCos2DeltaPhiMu1"] = kCos2DeltaPhiMu1; + fgVarNamesMap["kCos2DeltaPhiMu2"] = kCos2DeltaPhiMu2; + fgVarNamesMap["kCos3DeltaPhi"] = kCos3DeltaPhi; + fgVarNamesMap["kDeltaPtotTracks"] = kDeltaPtotTracks; + fgVarNamesMap["kVertexingLxyOverErr"] = kVertexingLxyOverErr; + fgVarNamesMap["kVertexingLzOverErr"] = kVertexingLzOverErr; + fgVarNamesMap["kVertexingLxyzOverErr"] = kVertexingLxyzOverErr; + fgVarNamesMap["kKFTrack0DCAxyz"] = kKFTrack0DCAxyz; + fgVarNamesMap["kKFTrack1DCAxyz"] = kKFTrack1DCAxyz; + fgVarNamesMap["kKFTracksDCAxyzMax"] = kKFTracksDCAxyzMax; + fgVarNamesMap["kKFDCAxyzBetweenProngs"] = kKFDCAxyzBetweenProngs; + fgVarNamesMap["kKFTrack0DCAxy"] = kKFTrack0DCAxy; + fgVarNamesMap["kKFTrack1DCAxy"] = kKFTrack1DCAxy; + fgVarNamesMap["kKFTracksDCAxyMax"] = kKFTracksDCAxyMax; + fgVarNamesMap["kKFDCAxyBetweenProngs"] = kKFDCAxyBetweenProngs; + fgVarNamesMap["kKFTrack0DeviationFromPV"] = kKFTrack0DeviationFromPV; + fgVarNamesMap["kKFTrack1DeviationFromPV"] = kKFTrack1DeviationFromPV; + fgVarNamesMap["kKFTrack0DeviationxyFromPV"] = kKFTrack0DeviationxyFromPV; + fgVarNamesMap["kKFTrack1DeviationxyFromPV"] = kKFTrack1DeviationxyFromPV; + fgVarNamesMap["kKFChi2OverNDFGeo"] = kKFChi2OverNDFGeo; + fgVarNamesMap["kKFNContributorsPV"] = kKFNContributorsPV; + fgVarNamesMap["kKFCosPA"] = kKFCosPA; + fgVarNamesMap["kKFChi2OverNDFGeoTop"] = kKFChi2OverNDFGeoTop; + fgVarNamesMap["kKFJpsiDCAxyz"] = kKFJpsiDCAxyz; + fgVarNamesMap["kKFJpsiDCAxy"] = kKFJpsiDCAxy; + fgVarNamesMap["kKFPairDeviationFromPV"] = kKFPairDeviationFromPV; + fgVarNamesMap["kKFPairDeviationxyFromPV"] = kKFPairDeviationxyFromPV; + fgVarNamesMap["kS12"] = kS12, + fgVarNamesMap["kS13"] = kS13, + fgVarNamesMap["kS23"] = kS23, + fgVarNamesMap["kNPairVariables"] = kNPairVariables; + fgVarNamesMap["kPairMass"] = kPairMass; + fgVarNamesMap["kPairMassDau"] = kPairMassDau; + fgVarNamesMap["kMassDau"] = kMassDau; + fgVarNamesMap["kPairPt"] = kPairPt; + fgVarNamesMap["kPairPtDau"] = kPairPtDau; + fgVarNamesMap["kPairEta"] = kPairEta; + fgVarNamesMap["kPairPhi"] = kPairPhi; + fgVarNamesMap["kPairPhiv"] = kPairPhiv; + fgVarNamesMap["kDileptonHadronKstar"] = kDileptonHadronKstar; + fgVarNamesMap["kDeltaEta"] = kDeltaEta; + fgVarNamesMap["kDeltaPhi"] = kDeltaPhi; + fgVarNamesMap["kDeltaPhiSym"] = kDeltaPhiSym; + fgVarNamesMap["kNCorrelationVariables"] = kNCorrelationVariables; + fgVarNamesMap["kQuadMass"] = kQuadMass; + fgVarNamesMap["kQuadDefaultDileptonMass"] = kQuadDefaultDileptonMass; + fgVarNamesMap["kQuadPt"] = kQuadPt; + fgVarNamesMap["kQuadEta"] = kQuadEta; + fgVarNamesMap["kQuadPhi"] = kQuadPhi; + fgVarNamesMap["kCosthetaDileptonDitrack"] = kCosthetaDileptonDitrack; + fgVarNamesMap["kDitrackMass"] = kDitrackMass; + fgVarNamesMap["kDitrackPt"] = kDitrackPt; + fgVarNamesMap["kQ"] = kQ; + fgVarNamesMap["kDeltaR1"] = kDeltaR1; + fgVarNamesMap["kDeltaR2"] = kDeltaR2; + fgVarNamesMap["kMassCharmHadron"] = kMassCharmHadron; + fgVarNamesMap["kPtCharmHadron"] = kPtCharmHadron; + fgVarNamesMap["kRapCharmHadron"] = kRapCharmHadron; + fgVarNamesMap["kPhiCharmHadron"] = kPhiCharmHadron; + fgVarNamesMap["kBdtCharmHadron"] = kBdtCharmHadron; + fgVarNamesMap["kBitMapIndex"] = kBitMapIndex; + fgVarNamesMap["kDeltaMass"] = kDeltaMass; + fgVarNamesMap["kDeltaMass_jpsi"] = kDeltaMass_jpsi; + fgVarNamesMap["kV22m"] = kV22m; + fgVarNamesMap["kV24m"] = kV24m; + fgVarNamesMap["kV22p"] = kV22p; + fgVarNamesMap["kV24p"] = kV24p; + fgVarNamesMap["kV22ME"] = kV22ME; + fgVarNamesMap["kV24ME"] = kV24ME; + fgVarNamesMap["kWV22ME"] = kWV22ME; + fgVarNamesMap["kWV24ME"] = kWV24ME; } diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index d445baee722..ec2ec55b83b 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -17,54 +17,56 @@ #ifndef PWGDQ_CORE_VARMANAGER_H_ #define PWGDQ_CORE_VARMANAGER_H_ +#include #include #include #ifndef HomogeneousField #define HomogeneousField #endif -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "TRandom.h" -#include "TH3F.h" -#include "Math/Vector4D.h" -#include "Math/Vector3D.h" -#include "Math/GenVector/Boost.h" - -#include "Framework/DataTypes.h" -#include "TGeoGlobalMagField.h" -#include "Field/MagneticField.h" -#include "ReconstructionDataFormats/Track.h" -#include "ReconstructionDataFormats/Vertex.h" -#include "DCAFitter/DCAFitterN.h" #include "Common/CCDB/EventSelectionParams.h" #include "Common/CCDB/TriggerAliases.h" -#include "ReconstructionDataFormats/DCA.h" -#include "DetectorsBase/Propagator.h" +#include "Common/Core/CollisionTypeHelper.h" +#include "Common/Core/EventPlaneHelper.h" #include "Common/Core/trackUtilities.h" -#include "Math/SMatrix.h" -#include "ReconstructionDataFormats/TrackFwd.h" +#include "CommonConstants/LHCConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DCAFitter/DCAFitterN.h" #include "DCAFitter/FwdDCAFitterN.h" +#include "DetectorsBase/Propagator.h" +#include "Field/MagneticField.h" +#include "Framework/DataTypes.h" #include "GlobalTracking/MatchGlobalFwd.h" -#include "CommonConstants/PhysicsConstants.h" -#include "CommonConstants/LHCConstants.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/Track.h" +#include "ReconstructionDataFormats/TrackFwd.h" +#include "ReconstructionDataFormats/Vertex.h" + +#include "Math/GenVector/Boost.h" +#include "Math/SMatrix.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "Math/VectorUtil.h" +#include "TGeoGlobalMagField.h" +#include "TH3F.h" +#include "TRandom.h" +#include +#include -#include "KFParticle.h" #include "KFPTrack.h" #include "KFPVertex.h" +#include "KFParticle.h" #include "KFParticleBase.h" #include "KFVertex.h" -#include "Common/Core/EventPlaneHelper.h" +#include +#include +#include +#include +#include +#include +#include using std::complex; using std::cout; @@ -103,6 +105,7 @@ class VarManager : public TObject CollisionMultExtra = BIT(18), ReducedEventMultExtra = BIT(19), CollisionQvectCentr = BIT(20), + RapidityGapFilter = BIT(21), Track = BIT(0), TrackCov = BIT(1), TrackExtra = BIT(2), @@ -128,7 +131,9 @@ class VarManager : public TObject TrackTPCPID = BIT(22), TrackMFT = BIT(23), ReducedTrackCollInfo = BIT(24), // TODO: remove it once new reduced data tables are produced for dielectron with ReducedTracksBarrelInfo - ReducedMuonCollInfo = BIT(25) // TODO: remove it once new reduced data tables are produced for dielectron with ReducedTracksBarrelInfo + ReducedMuonCollInfo = BIT(25), // TODO: remove it once new reduced data tables are produced for dielectron with ReducedTracksBarrelInfo + MuonRealign = BIT(26), + MuonCovRealign = BIT(27) }; enum PairCandidateType { @@ -139,7 +144,9 @@ class VarManager : public TObject kElectronMuon, // e.g. Electron - muon correlations kBcToThreeMuons, // e.g. Bc -> mu+ mu- mu+ kBtoJpsiEEK, // e.g. B+ -> e+ e- K+ + kJpsiEEProton, // e.g. Jpsi-proton correlation, Jpsi to e+e- kXtoJpsiPiPi, // e.g. X(3872) -> J/psi pi+ pi- + kPsi2StoJpsiPiPi, // e.g. Psi(2S) -> J/psi pi+ pi- kChictoJpsiEE, // e.g. Chi_c1 -> J/psi e+ e- kDstarToD0KPiPi, // e.g. D*+ -> D0 pi+ -> K- pi+ pi+ kTripleCandidateToEEPhoton, // e.g. chi_c -> e+ e- photon or pi0 -> e+ e- photon @@ -170,8 +177,6 @@ class VarManager : public TObject kNothing = -1, // Run wise variables kRunNo = 0, - kRunId, - kRunIndex, kNRunWiseVariables, // Event wise variables @@ -189,7 +194,10 @@ class VarManager : public TObject kIsGoodZvtxFT0vsPV, // No collisions w/ difference between z_ {PV, tracks} and z_{PV FT0A-C} kIsVertexITSTPC, // At least one ITS-TPC track kIsVertexTOFmatched, // At least one TOF-matched track - kIsSel8, // TVX in Run3 + kIsSel8, // TVX in Run3 && No time frame border && No ITS read out frame border (from event selection) + kIsGoodITSLayer3, // number of inactive chips on ITS layer 3 is below maximum allowed value + kIsGoodITSLayer0123, // numbers of inactive chips on ITS layers 0-3 are below maximum allowed values + kIsGoodITSLayersAll, // numbers of inactive chips on all ITS layers are below maximum allowed values kIsINT7, kIsEMC7, kIsINT7inMUON, @@ -215,6 +223,8 @@ class VarManager : public TObject kVtxChi2, kCentVZERO, kCentFT0C, + kCentFT0A, + kCentFT0M, kMultTPC, kMultFV0A, kMultFV0C, @@ -226,6 +236,9 @@ class VarManager : public TObject kMultZNC, kMultTracklets, kMultDimuons, + kMultAntiMuons, + kMultMuons, + kMultSingleMuons, kMultNTracksHasITS, kMultNTracksHasTPC, kMultNTracksHasTOF, @@ -233,7 +246,10 @@ class VarManager : public TObject kMultNTracksITSOnly, kMultNTracksTPCOnly, kMultNTracksITSTPC, + kMultNTracksPVeta1, + kMultNTracksPVetaHalf, kTrackOccupancyInTimeRange, + kFT0COccupancyInTimeRange, kNoCollInTimeRangeStandard, kMultAllTracksTPCOnly, kMultAllTracksITSTPC, @@ -393,7 +409,6 @@ class VarManager : public TObject kTimeZNC, kTimeZPA, kTimeZPC, - kNEventWiseVariables, kQ2X0A1, kQ2X0A2, kQ2Y0A1, @@ -414,6 +429,17 @@ class VarManager : public TObject kTwoR2SP2, // Scalar product resolution of event2 for ME technique kTwoR2EP1, // Event plane resolution of event2 for ME technique kTwoR2EP2, // Event plane resolution of event2 for ME technique + kNEventWiseVariables, + + // Variables for event mixing with cumulant + kV22m, + kV24m, + kV22p, + kV24p, + kV22ME, + kV24ME, + kWV22ME, + kWV24ME, // Basic track/muon/pair wise variables kX, @@ -581,6 +607,7 @@ class VarManager : public TObject kMCPx, kMCPy, kMCPz, + kMCMass, kMCE, kMCVx, kMCVy, @@ -595,6 +622,18 @@ class VarManager : public TObject // MC mother particle variables kMCMotherPdgCode, + // MC pair variables + kMCCosThetaHE, + kMCPhiHE, + kMCPhiTildeHE, + kMCCosThetaCS, + kMCPhiCS, + kMCPhiTildeCS, + kMCCosThetaPP, + kMCPhiPP, + kMCPhiTildePP, + kMCCosThetaRM, + // Pair variables kCandidateId, kPairType, @@ -612,6 +651,7 @@ class VarManager : public TObject kVertexingLxyzProjected, kVertexingTauzProjected, kVertexingTauxyProjected, + kVertexingTauxyProjectedPoleJPsiMass, kVertexingTauxyProjectedNs, kVertexingTauxyzProjected, kVertexingTauz, @@ -621,9 +661,19 @@ class VarManager : public TObject kVertexingProcCode, kVertexingChi2PCA, kCosThetaHE, - kCosThetaCS, kPhiHE, + kPhiTildeHE, + kCosThetaCS, kPhiCS, + kPhiTildeCS, + kCosThetaPP, + kPhiPP, + kPhiTildePP, + kCosThetaRM, + kCosThetaStarTPC, + kCosThetaStarFT0A, + kCosThetaStarFT0C, + kCosPhiVP, kPhiVP, kDeltaPhiPair2, kDeltaEtaPair2, @@ -665,6 +715,7 @@ class VarManager : public TObject kM0111POI, kCORR2REF, kCORR2REFbydimuons, + kCORR2REFbysinglemu, kCORR2REFetagap, kCORR2POI, kCORR2POICORR4POI, @@ -676,6 +727,7 @@ class VarManager : public TObject kCORR2CORR4REF, kCORR4REF, kCORR4REFbydimuons, + kCORR4REFbysinglemu, kCORR4POI, kM11REFoverMp, kM01POIoverMp, @@ -683,6 +735,42 @@ class VarManager : public TObject kM0111POIoverMp, kCORR2POIMp, kCORR4POIMp, + kM01POIplus, + kM0111POIplus, + kM01POIminus, + kM0111POIminus, + kM01POIsingle, + kM0111POIsingle, + kM01POIoverMpminus, + kM01POIoverMpplus, + kM01POIoverMpsingle, + kM01POIoverMpmoins, + kM0111POIoverMpminus, + kM0111POIoverMpplus, + kM0111POIoverMpsingle, + kCORR2POIplus, + kCORR2POIminus, + kCORR2POIsingle, + kCORR4POIplus, + kCORR4POIminus, + kCORR4POIsingle, + kM11REFoverMpplus, + kM1111REFoverMpplus, + kM11REFoverMpminus, + kM1111REFoverMpminus, + kM11REFoverMpsingle, + kM1111REFoverMpsingle, + kM01POIME, + kMultDimuonsME, + kM0111POIME, + kCORR2POIME, + kCORR4POIME, + kM01POIoverMpME, + kM0111POIoverMpME, + kM11REFoverMpME, + kM1111REFoverMpME, + kCORR2REFbydimuonsME, + kCORR4REFbydimuonsME, kR2SP, kR2EP, kPsi2A, @@ -718,6 +806,9 @@ class VarManager : public TObject kKFJpsiDCAxy, kKFPairDeviationFromPV, kKFPairDeviationxyFromPV, + kS12, + kS13, + kS23, kNPairVariables, // Candidate-track correlation variables @@ -733,6 +824,7 @@ class VarManager : public TObject kDeltaPhi, kDeltaPhiSym, kNCorrelationVariables, + kDileptonHadronKstar, // Dilepton-track-track variables kQuadMass, @@ -746,6 +838,7 @@ class VarManager : public TObject kQ, kDeltaR1, kDeltaR2, + kDeltaR, // DQ-HF correlation variables kMassCharmHadron, @@ -797,8 +890,9 @@ class VarManager : public TObject kToRabs }; - static TString fgVariableNames[kNVars]; // variable names - static TString fgVariableUnits[kNVars]; // variable units + static TString fgVariableNames[kNVars]; // variable names + static TString fgVariableUnits[kNVars]; // variable units + static std::map fgVarNamesMap; // key: variables short name, value: order in the Variables enum static void SetDefaultVarNames(); static void SetUseVariable(int var) @@ -831,31 +925,9 @@ class VarManager : public TObject return false; } - static void SetRunNumbers(int n, int* runs); - static void SetRunNumbers(std::vector runs); - static float GetRunIndex(double); - static void SetDummyRunlist(int InitRunnumber); - static int GetDummyFirst(); - static int GetDummyLast(); - static int GetDummyNRuns() - { - if (fgRunMap.size() == 0) { - return 101; - } else { - return fgRunMap.size(); - } - } - static int GetNRuns() - { - return fgRunMap.size(); - } - static TString GetRunStr() - { - return fgRunStr; - } - // Setup the collision system static void SetCollisionSystem(TString system, float energy); + static void SetCollisionSystem(o2::parameters::GRPLHCIFData* grplhcif); static void SetMagneticField(float magField) { @@ -933,6 +1005,25 @@ class VarManager : public TObject fgUsedKF = false; } + // Setup the 4 prong KFParticle + static void SetupFourProngKFParticle(float magField) + { + KFParticle::SetField(magField); + fgUsedKF = true; + } + + // Setup the 4 prong DCAFitterN + static void SetupFourProngDCAFitter(float magField, bool propagateToPCA, float maxR, float /*maxDZIni*/, float minParamChange, float minRelChi2Change, bool useAbsDCA) + { + fgFitterFourProngBarrel.setBz(magField); + fgFitterFourProngBarrel.setPropagateToPCA(propagateToPCA); + fgFitterFourProngBarrel.setMaxR(maxR); + fgFitterFourProngBarrel.setMinParamChange(minParamChange); + fgFitterFourProngBarrel.setMinRelChi2Change(minRelChi2Change); + fgFitterFourProngBarrel.setUseAbsDCA(useAbsDCA); + fgUsedKF = false; + } + static auto getEventPlane(int harm, float qnxa, float qnya) { // Compute event plane angle from qn vector components for the sub-event A @@ -972,6 +1063,8 @@ class VarManager : public TObject static void FillTwoMixEvents(T1 const& event1, T1 const& event2, T2 const& tracks1, T2 const& tracks2, float* values = nullptr); template static void FillTwoMixEventsFlowResoFactor(T const& hs_sp, T const& hs_ep, float* values = nullptr); + template + static void FillTwoMixEventsCumulants(T const& h_v22m, T const& h_v24m, T const& h_v22p, T const& h_v24p, T1 const& t1, T2 const& t2, float* values = nullptr); template static void FillTrack(T const& track, float* values = nullptr); template @@ -996,12 +1089,12 @@ class VarManager : public TObject static void FillTriple(T1 const& t1, T2 const& t2, T3 const& t3, float* values = nullptr, PairCandidateType pairType = kTripleCandidateToEEPhoton); template static void FillPairME(T1 const& t1, T2 const& t2, float* values = nullptr); - template - static void FillPairMC(T1 const& t1, T2 const& t2, float* values = nullptr, PairCandidateType pairType = kDecayToEE); + template + static void FillPairMC(T1 const& t1, T2 const& t2, float* values = nullptr); template static void FillTripleMC(T1 const& t1, T2 const& t2, T3 const& t3, float* values = nullptr, PairCandidateType pairType = kTripleCandidateToEEPhoton); template - static void FillQaudMC(T1 const& t1, T2 const& t2, T2 const& t3, float* values = nullptr); + static void FillQuadMC(T1 const& t1, T2 const& t2, T2 const& t3, float* values = nullptr); template static void FillPairVertexing(C const& collision, T const& t1, T const& t2, bool propToSV = false, float* values = nullptr); template @@ -1030,6 +1123,8 @@ class VarManager : public TObject static void FillPairVn(T1 const& t1, T2 const& t2, float* values = nullptr); template static void FillDileptonTrackTrack(T1 const& dilepton, T2 const& hadron1, T3 const& hadron2, float* values = nullptr); + template + static void FillDileptonTrackTrackVertexing(C const& collision, T1 const& lepton1, T1 const& lepton2, T1 const& track1, T1 const& track2, float* values); template static void FillZDC(const T& zdc, float* values = nullptr); @@ -1039,15 +1134,19 @@ class VarManager : public TObject // Check whether all the needed objects for TPC postcalibration are available if (fgCalibs.find(kTPCElectronMean) != fgCalibs.end() && fgCalibs.find(kTPCElectronSigma) != fgCalibs.end()) { fgRunTPCPostCalibration[0] = true; + fgUsedVars[kTPCnSigmaEl_Corr] = true; } if (fgCalibs.find(kTPCPionMean) != fgCalibs.end() && fgCalibs.find(kTPCPionSigma) != fgCalibs.end()) { fgRunTPCPostCalibration[1] = true; + fgUsedVars[kTPCnSigmaPi_Corr] = true; } if (fgCalibs.find(kTPCKaonMean) != fgCalibs.end() && fgCalibs.find(kTPCKaonSigma) != fgCalibs.end()) { fgRunTPCPostCalibration[2] = true; + fgUsedVars[kTPCnSigmaKa_Corr] = true; } if (fgCalibs.find(kTPCProtonMean) != fgCalibs.end() && fgCalibs.find(kTPCProtonSigma) != fgCalibs.end()) { fgRunTPCPostCalibration[3] = true; + fgUsedVars[kTPCnSigmaPr_Corr] = true; } } static TObject* GetCalibrationObject(CalibObjects calib) @@ -1090,9 +1189,6 @@ class VarManager : public TObject static void SetVariableDependencies(); // toggle those variables on which other used variables might depend static float fgMagField; - static std::map fgRunMap; // map of runs to be used in histogram axes - static TString fgRunStr; // semi-colon separated list of runs, to be used for histogram axis labels - static std::vector fgRunList; // vector of runs, to be used for histogram axis static float fgCenterOfMassEnergy; // collision energy static float fgMassofCollidingParticle; // mass of the colliding particle static float fgTPCInterSectorBoundary; // TPC inter-sector border size at the TPC outer radius, in cm @@ -1102,8 +1198,10 @@ class VarManager : public TObject static int fgITSROFBorderMarginHigh; // ITS ROF border high margin static uint64_t fgSOR; // Timestamp for start of run static uint64_t fgEOR; // Timestamp for end of run + static ROOT::Math::PxPyPzEVector fgBeamA; // beam from A-side 4-momentum vector + static ROOT::Math::PxPyPzEVector fgBeamC; // beam from C-side 4-momentum vector - static void FillEventDerived(float* values = nullptr); + // static void FillEventDerived(float* values = nullptr); static void FillTrackDerived(float* values = nullptr); template static auto getRotatedCovMatrixXX(const T& matrix, U phi, V theta); @@ -1119,6 +1217,7 @@ class VarManager : public TObject static o2::vertexing::DCAFitterN<2> fgFitterTwoProngBarrel; static o2::vertexing::DCAFitterN<3> fgFitterThreeProngBarrel; + static o2::vertexing::DCAFitterN<4> fgFitterFourProngBarrel; static o2::vertexing::FwdDCAFitterN<2> fgFitterTwoProngFwd; static o2::vertexing::FwdDCAFitterN<3> fgFitterThreeProngFwd; static o2::globaltracking::MatchGlobalFwd mMatching; @@ -1296,7 +1395,7 @@ void VarManager::FillPropagateMuon(const T& muon, const C& collision, float* val } } - if constexpr ((fillMap & MuonCov) > 0 || (fillMap & ReducedMuonCov) > 0) { + if constexpr ((fillMap & MuonCov) > 0 || (fillMap & ReducedMuonCov) > 0 || (fillMap & MuonCovRealign) > 0) { o2::dataformats::GlobalFwdTrack propmuon = PropagateMuon(muon, collision); values[kPt] = propmuon.getPt(); values[kX] = propmuon.getX(); @@ -1373,7 +1472,6 @@ void VarManager::FillBC(T const& bc, float* values) values[kBCOrbit] = bc.globalBC() % o2::constants::lhc::LHCMaxBunches; values[kTimestamp] = bc.timestamp(); values[kTimeFromSOR] = (fgSOR > 0 ? (bc.timestamp() - fgSOR) / 60000. : -1.0); - values[kRunIndex] = GetRunIndex(bc.runNumber()); } template @@ -1397,6 +1495,9 @@ void VarManager::FillEvent(T const& event, float* values) if (fgUsedVars[kTrackOccupancyInTimeRange]) { values[kTrackOccupancyInTimeRange] = event.trackOccupancyInTimeRange(); } + if (fgUsedVars[kFT0COccupancyInTimeRange]) { + values[kFT0COccupancyInTimeRange] = event.ft0cOccupancyInTimeRange(); + } if (fgUsedVars[kNoCollInTimeRangeStandard]) { values[kNoCollInTimeRangeStandard] = event.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard); } @@ -1418,6 +1519,15 @@ void VarManager::FillEvent(T const& event, float* values) if (fgUsedVars[kIsSel8]) { values[kIsSel8] = event.selection_bit(o2::aod::evsel::kIsTriggerTVX) && event.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) && event.selection_bit(o2::aod::evsel::kNoTimeFrameBorder); } + if (fgUsedVars[kIsGoodITSLayer3]) { + values[kIsGoodITSLayer3] = event.selection_bit(o2::aod::evsel::kIsGoodITSLayer3); + } + if (fgUsedVars[kIsGoodITSLayer0123]) { + values[kIsGoodITSLayer0123] = event.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123); + } + if (fgUsedVars[kIsGoodITSLayersAll]) { + values[kIsGoodITSLayersAll] = event.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll); + } if (fgUsedVars[kIsINT7]) { values[kIsINT7] = (event.alias_bit(kINT7) > 0); } @@ -1472,16 +1582,27 @@ void VarManager::FillEvent(T const& event, float* values) if constexpr ((fillMap & CollisionCent) > 0 || (fillMap & ReducedEventExtended) > 0) { values[kCentFT0C] = event.centFT0C(); + values[kCentFT0A] = event.centFT0A(); + values[kCentFT0M] = event.centFT0M(); } if constexpr ((fillMap & CollisionMult) > 0 || (fillMap & ReducedEventExtended) > 0) { + if constexpr ((fillMap & RapidityGapFilter) > 0) { + // UPC: Use the FIT signals from the nearest BC with FIT amplitude above threshold + values[kMultFV0A] = event.newBcMultFV0A(); + values[kMultFT0A] = event.newBcMultFT0A(); + values[kMultFT0C] = event.newBcMultFT0C(); + values[kMultFDDA] = event.newBcMultFDDA(); + values[kMultFDDC] = event.newBcMultFDDC(); + } else { + values[kMultFV0A] = event.multFV0A(); + values[kMultFT0A] = event.multFT0A(); + values[kMultFT0C] = event.multFT0C(); + values[kMultFDDA] = event.multFDDA(); + values[kMultFDDC] = event.multFDDC(); + } values[kMultTPC] = event.multTPC(); - values[kMultFV0A] = event.multFV0A(); values[kMultFV0C] = event.multFV0C(); - values[kMultFT0A] = event.multFT0A(); - values[kMultFT0C] = event.multFT0C(); - values[kMultFDDA] = event.multFDDA(); - values[kMultFDDC] = event.multFDDC(); values[kMultZNA] = event.multZNA(); values[kMultZNC] = event.multZNC(); values[kMultTracklets] = event.multTracklets(); @@ -1496,8 +1617,12 @@ void VarManager::FillEvent(T const& event, float* values) values[kMultNTracksITSOnly] = event.multNTracksITSOnly(); values[kMultNTracksTPCOnly] = event.multNTracksTPCOnly(); values[kMultNTracksITSTPC] = event.multNTracksITSTPC(); + values[kMultNTracksPVeta1] = event.multNTracksPVeta1(); + values[kMultNTracksPVetaHalf] = event.multNTracksPVetaHalf(); values[kMultAllTracksTPCOnly] = event.multAllTracksTPCOnly(); values[kMultAllTracksITSTPC] = event.multAllTracksITSTPC(); + values[kTrackOccupancyInTimeRange] = event.trackOccupancyInTimeRange(); + values[kFT0COccupancyInTimeRange] = event.ft0cOccupancyInTimeRange(); if constexpr ((fillMap & ReducedEventMultExtra) > 0) { values[kNTPCcontribLongA] = event.nTPCoccupContribLongA(); values[kNTPCcontribLongC] = event.nTPCoccupContribLongC(); @@ -1517,7 +1642,6 @@ void VarManager::FillEvent(T const& event, float* values) if constexpr ((fillMap & ReducedEvent) > 0) { values[kRunNo] = event.runNumber(); - values[kRunIndex] = GetRunIndex(event.runNumber()); values[kVtxX] = event.posX(); values[kVtxY] = event.posY(); values[kVtxZ] = event.posZ(); @@ -1572,6 +1696,15 @@ void VarManager::FillEvent(T const& event, float* values) if (fgUsedVars[kIsSel8]) { values[kIsSel8] = event.selection_bit(o2::aod::evsel::kIsTriggerTVX) && event.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && event.selection_bit(o2::aod::evsel::kNoITSROFrameBorder); } + if (fgUsedVars[kIsGoodITSLayer3]) { + values[kIsGoodITSLayer3] = event.selection_bit(o2::aod::evsel::kIsGoodITSLayer3); + } + if (fgUsedVars[kIsGoodITSLayer0123]) { + values[kIsGoodITSLayer0123] = event.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123); + } + if (fgUsedVars[kIsGoodITSLayersAll]) { + values[kIsGoodITSLayersAll] = event.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll); + } if (fgUsedVars[kIsINT7]) { values[kIsINT7] = (event.alias_bit(kINT7) > 0); } @@ -1788,7 +1921,7 @@ void VarManager::FillEvent(T const& event, float* values) values[kMCEventImpParam] = event.impactParameter(); } - if constexpr ((fillMap & EventFilter) > 0) { + if constexpr ((fillMap & EventFilter) > 0 || (fillMap & RapidityGapFilter) > 0) { values[kIsDoubleGap] = (event.eventFilter() & (static_cast(1) << kDoubleGap)) > 0; values[kIsSingleGapA] = (event.eventFilter() & (static_cast(1) << kSingleGapA)) > 0; values[kIsSingleGapC] = (event.eventFilter() & (static_cast(1) << kSingleGapC)) > 0; @@ -1800,7 +1933,7 @@ void VarManager::FillEvent(T const& event, float* values) FillZDC(event, values); } - FillEventDerived(values); + // FillEventDerived(values); } template @@ -1893,6 +2026,52 @@ void VarManager::FillTwoMixEventsFlowResoFactor(T const& hs_sp, T const& hs_ep, } } +template +void VarManager::FillTwoMixEventsCumulants(T const& h_v22ev1, T const& h_v24ev1, T const& h_v22ev2, T const& h_v24ev2, T1 const& t1, T2 const& t2, float* values) +{ + if (!values) { + values = fgValues; + } + + int idx_v22ev1; + int idx_v24ev1; + int idx_v22ev2; + int idx_v24ev2; + + if (values[kTwoEvCentFT0C1] >= 0.) { + if (t1.sign() < 0) { + + idx_v22ev1 = h_v22ev1->FindBin(values[kTwoEvCentFT0C1], t1.pt()); + idx_v24ev1 = h_v24ev1->FindBin(values[kTwoEvCentFT0C1], t1.pt()); + values[kV22m] = h_v22ev1->GetBinContent(idx_v22ev1); + values[kV24m] = h_v24ev1->GetBinContent(idx_v24ev1); + + } else { + + idx_v22ev1 = h_v22ev2->FindBin(values[kTwoEvCentFT0C1], t1.pt()); + idx_v24ev1 = h_v24ev2->FindBin(values[kTwoEvCentFT0C1], t1.pt()); + values[kV22m] = h_v22ev2->GetBinContent(idx_v22ev1); + values[kV24m] = h_v24ev2->GetBinContent(idx_v24ev1); + } + } + if (values[kTwoEvCentFT0C2] >= 0.) { + if (t2.sign() < 0) { + + idx_v22ev2 = h_v22ev1->FindBin(values[kTwoEvCentFT0C2], t2.pt()); + idx_v24ev2 = h_v24ev1->FindBin(values[kTwoEvCentFT0C2], t2.pt()); + values[kV22p] = h_v22ev1->GetBinContent(idx_v22ev2); + values[kV24p] = h_v24ev1->GetBinContent(idx_v24ev2); + + } else { + + idx_v22ev2 = h_v22ev2->FindBin(values[kTwoEvCentFT0C2], t2.pt()); + idx_v24ev2 = h_v24ev2->FindBin(values[kTwoEvCentFT0C2], t2.pt()); + values[kV22p] = h_v22ev2->GetBinContent(idx_v22ev2); + values[kV24p] = h_v24ev2->GetBinContent(idx_v24ev2); + } + } +} + template void VarManager::FillTwoEvents(T const& ev1, T const& ev2, float* values) { @@ -1986,7 +2165,7 @@ void VarManager::FillTrack(T const& track, float* values) } // Quantities based on the basic table (contains just kine information and filter bits) - if constexpr ((fillMap & Track) > 0 || (fillMap & Muon) > 0 || (fillMap & ReducedTrack) > 0 || (fillMap & ReducedMuon) > 0) { + if constexpr ((fillMap & Track) > 0 || (fillMap & Muon) > 0 || (fillMap & MuonRealign) > 0 || (fillMap & ReducedTrack) > 0 || (fillMap & ReducedMuon) > 0) { values[kPt] = track.pt(); values[kSignedPt] = track.pt() * track.sign(); if (fgUsedVars[kP]) { @@ -2045,6 +2224,30 @@ void VarManager::FillTrack(T const& track, float* values) values[kIsDalitzLeg + i] = track.filteringFlags_bit(VarManager::kDalitzBits + i); } } + + if (fgUsedVars[kM11REFoverMpsingle]) { + float m = o2::constants::physics::MassMuon; + ROOT::Math::PtEtaPhiMVector v(track.pt(), track.eta(), track.phi(), m); + complex Q21(values[kQ2X0A] * values[kS11A], values[kQ2Y0A] * values[kS11A]); + complex Q42(values[kQ42XA], values[kQ42YA]); + complex Q23(values[kQ23XA], values[kQ23YA]); + complex P2(TMath::Cos(2 * v.Phi()), TMath::Sin(2 * v.Phi())); + values[kM11REFoverMpsingle] = values[kMultSingleMuons] > 0 && !(std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF])) ? values[kM11REF] / values[kMultSingleMuons] : 0; + values[kM1111REFoverMpsingle] = values[kMultSingleMuons] > 0 && !(std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF]) || std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF])) ? values[kM1111REF] / values[kMultSingleMuons] : 0; + values[kCORR2REFbysinglemu] = std::isnan(values[kM11REFoverMpsingle]) || std::isinf(values[kM11REFoverMpsingle]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kM1111REFoverMpsingle]) || std::isinf(values[kM1111REFoverMpsingle]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF]) ? 0 : values[kCORR2REF]; + values[kCORR4REFbysinglemu] = std::isnan(values[kM1111REFoverMpsingle]) || std::isinf(values[kM1111REFoverMpsingle]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF]) || std::isnan(values[kM11REFoverMpsingle]) || std::isinf(values[kM11REFoverMpsingle]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) ? 0 : values[kCORR4REF]; + values[kCORR2POIsingle] = (P2 * conj(Q21)).real() / values[kM01POI]; + values[kM01POIsingle] = values[kMultSingleMuons] * values[kS11A]; + values[kM0111POIsingle] = values[kMultSingleMuons] * (values[kS31A] - 3. * values[kS11A] * values[kS12A] + 2. * values[kS13A]); + values[kCORR2POIsingle] = (P2 * conj(Q21)).real() / values[kM01POIsingle]; + values[kCORR4POIsingle] = (P2 * Q21 * conj(Q21) * conj(Q21) - P2 * Q21 * conj(Q42) - 2. * values[kS12A] * P2 * conj(Q21) + 2. * P2 * conj(Q23)).real() / values[kM0111POIsingle]; + values[kM01POIsingle] = std::isnan(values[kM01POIsingle]) || std::isinf(values[kM01POIsingle]) || std::isnan(values[kM0111POIsingle]) || std::isinf(values[kM0111POIsingle]) || std::isnan(values[kCORR2POIsingle]) || std::isinf(values[kCORR2POIsingle]) || std::isnan(values[kCORR4POIsingle]) || std::isinf(values[kCORR4POIsingle]) ? 0 : values[kM01POIsingle]; + values[kM0111POIsingle] = std::isnan(values[kM0111POIsingle]) || std::isinf(values[kM0111POIsingle]) || std::isnan(values[kCORR2POIsingle]) || std::isinf(values[kCORR2POIsingle]) || std::isnan(values[kCORR4POIsingle]) || std::isinf(values[kCORR4POIsingle]) ? 0 : values[kM0111POIsingle]; + values[kCORR2POIsingle] = std::isnan(values[kM01POIsingle]) || std::isinf(values[kM01POIsingle]) || std::isnan(values[kM0111POIsingle]) || std::isinf(values[kM0111POIsingle]) || std::isnan(values[kCORR2POIsingle]) || std::isinf(values[kCORR2POIsingle]) || std::isnan(values[kCORR4POIsingle]) || std::isinf(values[kCORR4POIsingle]) ? 0 : values[kCORR2POIsingle]; + values[kCORR4POIsingle] = std::isnan(values[kM01POIsingle]) || std::isinf(values[kM01POIsingle]) || std::isnan(values[kM0111POIsingle]) || std::isinf(values[kM0111POIsingle]) || std::isnan(values[kCORR2POIsingle]) || std::isinf(values[kCORR2POIsingle]) || std::isnan(values[kCORR4POIsingle]) || std::isinf(values[kCORR4POIsingle]) ? 0 : values[kCORR4POIsingle]; + values[kM01POIoverMpsingle] = values[kMultSingleMuons] > 0 && !(std::isnan(values[kM0111POIsingle]) || std::isinf(values[kM0111POIsingle]) || std::isnan(values[kCORR4POIsingle]) || std::isinf(values[kCORR4POIsingle]) || std::isnan(values[kM01POIsingle]) || std::isinf(values[kM01POIsingle]) || std::isnan(values[kCORR2POIsingle]) || std::isinf(values[kCORR2POIsingle])) ? values[kM01POIsingle] / values[kMultSingleMuons] : 0; + values[kM0111POIoverMpsingle] = values[kMultSingleMuons] > 0 && !(std::isnan(values[kM0111POIsingle]) || std::isinf(values[kM0111POIsingle]) || std::isnan(values[kCORR4POIsingle]) || std::isinf(values[kCORR4POIsingle]) || std::isnan(values[kM01POIsingle]) || std::isinf(values[kM01POIsingle]) || std::isnan(values[kCORR2POIsingle]) || std::isinf(values[kCORR2POIsingle])) ? values[kM0111POIsingle] / values[kMultSingleMuons] : 0; + } } // Quantities based on the barrel tables @@ -2210,7 +2413,7 @@ void VarManager::FillTrack(T const& track, float* values) } // Quantities based on the barrel PID tables - if constexpr ((fillMap & TrackPID) > 0 || (fillMap & ReducedTrackBarrelPID) > 0) { + if constexpr ((fillMap & TrackPID) > 0 || (fillMap & TrackTPCPID) > 0 || (fillMap & ReducedTrackBarrelPID) > 0) { values[kTPCnSigmaEl] = track.tpcNSigmaEl(); values[kTPCnSigmaPi] = track.tpcNSigmaPi(); values[kTPCnSigmaKa] = track.tpcNSigmaKa(); @@ -2313,10 +2516,13 @@ void VarManager::FillTrack(T const& track, float* values) values[kTPCnSigmaPr_Corr] = track.tpcNSigmaPr(); } } - values[kTOFnSigmaEl] = track.tofNSigmaEl(); - values[kTOFnSigmaPi] = track.tofNSigmaPi(); - values[kTOFnSigmaKa] = track.tofNSigmaKa(); - values[kTOFnSigmaPr] = track.tofNSigmaPr(); + + if constexpr ((fillMap & TrackPID) > 0 || (fillMap & ReducedTrackBarrelPID) > 0) { + values[kTOFnSigmaEl] = track.tofNSigmaEl(); + values[kTOFnSigmaPi] = track.tofNSigmaPi(); + values[kTOFnSigmaKa] = track.tofNSigmaKa(); + values[kTOFnSigmaPr] = track.tofNSigmaPr(); + } if (fgUsedVars[kTPCsignalRandomized] || fgUsedVars[kTPCnSigmaElRandomized] || fgUsedVars[kTPCnSigmaPiRandomized] || fgUsedVars[kTPCnSigmaPrRandomized]) { // NOTE: this is needed temporarily for the study of the impact of TPC pid degradation on the quarkonium triggers in high lumi pp @@ -2355,7 +2561,7 @@ void VarManager::FillTrack(T const& track, float* values) } // Quantities based on the muon extra table - if constexpr ((fillMap & ReducedMuonExtra) > 0 || (fillMap & Muon) > 0) { + if constexpr ((fillMap & ReducedMuonExtra) > 0 || (fillMap & Muon) > 0 || (fillMap & MuonRealign) > 0) { values[kMuonNClusters] = track.nClusters(); values[kMuonPDca] = track.pDca(); values[kMCHBitMap] = track.mchBitMap(); @@ -2371,7 +2577,7 @@ void VarManager::FillTrack(T const& track, float* values) values[kMuonTimeRes] = track.trackTimeRes(); } // Quantities based on the muon covariance table - if constexpr ((fillMap & ReducedMuonCov) > 0 || (fillMap & MuonCov) > 0) { + if constexpr ((fillMap & ReducedMuonCov) > 0 || (fillMap & MuonCov) > 0 || (fillMap & MuonCovRealign) > 0) { values[kX] = track.x(); values[kY] = track.y(); values[kZ] = track.z(); @@ -2428,7 +2634,7 @@ void VarManager::FillTrackCollision(T const& track, C const& collision, float* v } } } - if constexpr ((fillMap & MuonCov) > 0 || (fillMap & ReducedMuonCov) > 0) { + if constexpr ((fillMap & MuonCov) > 0 || (fillMap & MuonCovRealign) > 0 || (fillMap & ReducedMuonCov) > 0) { o2::dataformats::GlobalFwdTrack propmuonAtDCA = PropagateMuon(track, collision, kToDCA); @@ -2588,6 +2794,9 @@ void VarManager::FillPair(T1 const& t1, T2 const& t2, float* values) m2 = o2::constants::physics::MassMuon; } + values[kCharge] = t1.sign() + t2.sign(); + values[kCharge1] = t1.sign(); + values[kCharge2] = t2.sign(); ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), m1); ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), m2); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; @@ -2601,6 +2810,13 @@ void VarManager::FillPair(T1 const& t1, T2 const& t2, float* values) double Ptot2 = TMath::Sqrt(v2.Px() * v2.Px() + v2.Py() * v2.Py() + v2.Pz() * v2.Pz()); values[kDeltaPtotTracks] = Ptot1 - Ptot2; + values[kPt1] = t1.pt(); + values[kEta1] = t1.eta(); + values[kPhi1] = t1.phi(); + values[kPt2] = t2.pt(); + values[kEta2] = t2.eta(); + values[kPhi2] = t2.phi(); + if (fgUsedVars[kDeltaPhiPair2]) { double phipair2 = v1.Phi() - v2.Phi(); if (phipair2 > 3 * TMath::Pi() / 2) { @@ -2637,42 +2853,123 @@ void VarManager::FillPair(T1 const& t1, T2 const& t2, float* values) } } - // TO DO: get the correct values from CCDB - double BeamMomentum = TMath::Sqrt(fgCenterOfMassEnergy * fgCenterOfMassEnergy / 4 - fgMassofCollidingParticle * fgMassofCollidingParticle); // GeV - ROOT::Math::PxPyPzEVector Beam1(0., 0., -BeamMomentum, fgCenterOfMassEnergy / 2); - ROOT::Math::PxPyPzEVector Beam2(0., 0., BeamMomentum, fgCenterOfMassEnergy / 2); - - // Boost to center of mass frame - ROOT::Math::Boost boostv12{v12.BoostToCM()}; - ROOT::Math::XYZVectorF v1_CM{(boostv12(v1).Vect()).Unit()}; - ROOT::Math::XYZVectorF v2_CM{(boostv12(v2).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam1_CM{(boostv12(Beam1).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam2_CM{(boostv12(Beam2).Vect()).Unit()}; - - // Helicity frame - ROOT::Math::XYZVectorF zaxis_HE{(v12.Vect()).Unit()}; - ROOT::Math::XYZVectorF yaxis_HE{(Beam1_CM.Cross(Beam2_CM)).Unit()}; - ROOT::Math::XYZVectorF xaxis_HE{(yaxis_HE.Cross(zaxis_HE)).Unit()}; - - // Collins-Soper frame - ROOT::Math::XYZVectorF zaxis_CS{((Beam1_CM.Unit() - Beam2_CM.Unit()).Unit())}; - ROOT::Math::XYZVectorF yaxis_CS{(Beam1_CM.Cross(Beam2_CM)).Unit()}; - ROOT::Math::XYZVectorF xaxis_CS{(yaxis_CS.Cross(zaxis_CS)).Unit()}; - - if (fgUsedVars[kCosThetaHE]) { - values[kCosThetaHE] = (t1.sign() > 0 ? zaxis_HE.Dot(v1_CM) : zaxis_HE.Dot(v2_CM)); - } + // polarization parameters + bool useHE = fgUsedVars[kCosThetaHE] || fgUsedVars[kPhiHE]; // helicity frame + bool useCS = fgUsedVars[kCosThetaCS] || fgUsedVars[kPhiCS]; // Collins-Soper frame + bool usePP = fgUsedVars[kCosThetaPP]; // production plane frame + bool useRM = fgUsedVars[kCosThetaRM]; // Random frame + + if (useHE || useCS || usePP || useRM) { + ROOT::Math::Boost boostv12{v12.BoostToCM()}; + ROOT::Math::XYZVectorF v1_CM{(boostv12(v1).Vect()).Unit()}; + ROOT::Math::XYZVectorF v2_CM{(boostv12(v2).Vect()).Unit()}; + ROOT::Math::XYZVectorF Beam1_CM{(boostv12(fgBeamA).Vect()).Unit()}; + ROOT::Math::XYZVectorF Beam2_CM{(boostv12(fgBeamC).Vect()).Unit()}; + + // using positive sign convention for the first track + ROOT::Math::XYZVectorF v_CM = (t1.sign() > 0 ? v1_CM : v2_CM); + + if (useHE) { + ROOT::Math::XYZVectorF zaxis_HE{(v12.Vect()).Unit()}; + ROOT::Math::XYZVectorF yaxis_HE{(Beam1_CM.Cross(Beam2_CM)).Unit()}; + ROOT::Math::XYZVectorF xaxis_HE{(yaxis_HE.Cross(zaxis_HE)).Unit()}; + if (fgUsedVars[kCosThetaHE]) + values[kCosThetaHE] = zaxis_HE.Dot(v_CM); + if (fgUsedVars[kPhiHE]) { + values[kPhiHE] = TMath::ATan2(yaxis_HE.Dot(v_CM), xaxis_HE.Dot(v_CM)); + if (values[kPhiHE] < 0) { + values[kPhiHE] += 2 * TMath::Pi(); // ensure phi is in [0, 2pi] + } + } + if (fgUsedVars[kPhiTildeHE]) { + if (fgUsedVars[kCosThetaHE] && fgUsedVars[kPhiHE]) { + if (values[kCosThetaHE] > 0) { + values[kPhiTildeHE] = values[kPhiHE] - 0.25 * TMath::Pi(); // phi_tilde = phi - pi/4 + if (values[kPhiTildeHE] < 0) { + values[kPhiTildeHE] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } else { + values[kPhiTildeHE] = values[kPhiHE] - 0.75 * TMath::Pi(); // phi_tilde = phi - 3pi/4 + if (values[kPhiTildeHE] < 0) { + values[kPhiTildeHE] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } + } else { + values[kPhiTildeHE] = -999; // not computable + } + } + } - if (fgUsedVars[kPhiHE]) { - values[kPhiHE] = (t1.sign() > 0 ? TMath::ATan2(yaxis_HE.Dot(v1_CM), xaxis_HE.Dot(v1_CM)) : TMath::ATan2(yaxis_HE.Dot(v2_CM), xaxis_HE.Dot(v2_CM))); - } + if (useCS) { + ROOT::Math::XYZVectorF zaxis_CS{(Beam1_CM - Beam2_CM).Unit()}; + ROOT::Math::XYZVectorF yaxis_CS{(Beam1_CM.Cross(Beam2_CM)).Unit()}; + ROOT::Math::XYZVectorF xaxis_CS{(yaxis_CS.Cross(zaxis_CS)).Unit()}; + if (fgUsedVars[kCosThetaCS]) + values[kCosThetaCS] = zaxis_CS.Dot(v_CM); + if (fgUsedVars[kPhiCS]) { + values[kPhiCS] = TMath::ATan2(yaxis_CS.Dot(v_CM), xaxis_CS.Dot(v_CM)); + if (values[kPhiCS] < 0) { + values[kPhiCS] += 2 * TMath::Pi(); // ensure phi is in [0, 2pi] + } + } + if (fgUsedVars[kPhiTildeCS]) { + if (fgUsedVars[kCosThetaCS] && fgUsedVars[kPhiCS]) { + if (values[kCosThetaCS] > 0) { + values[kPhiTildeCS] = values[kPhiCS] - 0.25 * TMath::Pi(); // phi_tilde = phi - pi/4 + if (values[kPhiTildeCS] < 0) { + values[kPhiTildeCS] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } else { + values[kPhiTildeCS] = values[kPhiCS] - 0.75 * TMath::Pi(); // phi_tilde = phi - 3pi/4 + if (values[kPhiTildeCS] < 0) { + values[kPhiTildeCS] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } + } else { + values[kPhiTildeCS] = -999; // not computable + } + } + } - if (fgUsedVars[kCosThetaCS]) { - values[kCosThetaCS] = (t1.sign() > 0 ? zaxis_CS.Dot(v1_CM) : zaxis_CS.Dot(v2_CM)); - } + if (usePP) { + ROOT::Math::XYZVector zaxis_PP = ROOT::Math::XYZVector(v12.Py(), -v12.Px(), 0.f); + ROOT::Math::XYZVector yaxis_PP{(v12.Vect()).Unit()}; + ROOT::Math::XYZVector xaxis_PP{(yaxis_PP.Cross(zaxis_PP)).Unit()}; + if (fgUsedVars[kCosThetaPP]) { + values[kCosThetaPP] = zaxis_PP.Dot(v_CM) / std::sqrt(zaxis_PP.Mag2()); + } + if (fgUsedVars[kPhiPP]) { + values[kPhiPP] = TMath::ATan2(yaxis_PP.Dot(v_CM), xaxis_PP.Dot(v_CM)); + if (values[kPhiPP] < 0) { + values[kPhiPP] += 2 * TMath::Pi(); // ensure phi is in [0, 2pi] + } + } + if (fgUsedVars[kPhiTildePP]) { + if (fgUsedVars[kCosThetaPP] && fgUsedVars[kPhiPP]) { + if (values[kCosThetaPP] > 0) { + values[kPhiTildePP] = values[kPhiPP] - 0.25 * TMath::Pi(); // phi_tilde = phi - pi/4 + if (values[kPhiTildePP] < 0) { + values[kPhiTildePP] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } else { + values[kPhiTildePP] = values[kPhiPP] - 0.75 * TMath::Pi(); // phi_tilde = phi - 3pi/4 + if (values[kPhiTildePP] < 0) { + values[kPhiTildePP] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } + } else { + values[kPhiTildePP] = -999; // not computable + } + } + } - if (fgUsedVars[kPhiCS]) { - values[kPhiCS] = (t1.sign() > 0 ? TMath::ATan2(yaxis_CS.Dot(v1_CM), xaxis_CS.Dot(v1_CM)) : TMath::ATan2(yaxis_CS.Dot(v2_CM), xaxis_CS.Dot(v2_CM))); + if (useRM) { + double randomCostheta = gRandom->Uniform(-1., 1.); + double randomPhi = gRandom->Uniform(0., 2. * TMath::Pi()); + ROOT::Math::XYZVectorF zaxis_RM(randomCostheta, std::sqrt(1 - randomCostheta * randomCostheta) * std::cos(randomPhi), std::sqrt(1 - randomCostheta * randomCostheta) * std::sin(randomPhi)); + if (fgUsedVars[kCosThetaRM]) + values[kCosThetaRM] = zaxis_RM.Dot(v_CM); + } } if constexpr ((pairType == kDecayToEE) && ((fillMap & TrackCov) > 0 || (fillMap & ReducedTrackBarrelCov) > 0)) { @@ -2884,6 +3181,10 @@ void VarManager::FillTriple(T1 const& t1, T2 const& t2, T3 const& t3, float* val values[kEta] = v123.Eta(); values[kPhi] = v123.Phi(); values[kRap] = -v123.Rapidity(); + values[kCharge] = t1.sign() + t2.sign() + t3.sign(); + values[kS12] = (v1 + v2).M2(); + values[kS13] = (v1 + v3).M2(); + values[kS23] = (v2 + v3).M2(); } if (pairType == kTripleCandidateToPKPi) { @@ -2959,8 +3260,10 @@ void VarManager::FillPairME(T1 const& t1, T2 const& t2, float* values) // Compute the scalar product UQ for two muon from different event using Q-vector from A, for second and third harmonic float Psi2A1 = getEventPlane(2, values[kQ2X0A1], values[kQ2Y0A1]); float Psi2A2 = getEventPlane(2, values[kQ2X0A2], values[kQ2Y0A2]); + values[kCos2DeltaPhi] = TMath::Cos(2 * (v12.Phi() - Psi2A1)); // WARNING: using the first event EP values[kCos2DeltaPhiEv1] = TMath::Cos(2 * (v1.Phi() - Psi2A1)); values[kCos2DeltaPhiEv2] = TMath::Cos(2 * (v2.Phi() - Psi2A2)); + values[kU2Q2] = values[kQ2X0A1] * TMath::Cos(2 * v12.Phi()) + values[kQ2Y0A1] * TMath::Sin(2 * v12.Phi()); // WARNING: using the first event EP values[kU2Q2Ev1] = values[kQ2X0A1] * TMath::Cos(2 * v1.Phi()) + values[kQ2Y0A1] * TMath::Sin(2 * v1.Phi()); values[kU2Q2Ev2] = values[kQ2X0A2] * TMath::Cos(2 * v2.Phi()) + values[kQ2Y0A2] * TMath::Sin(2 * v2.Phi()); @@ -2978,6 +3281,33 @@ void VarManager::FillPairME(T1 const& t1, T2 const& t2, float* values) values[kWV2ME_SP] = std::isnan(V2ME_SP) || std::isinf(V2ME_SP) ? 0. : 1.0; values[kV2ME_EP] = std::isnan(V2ME_EP) || std::isinf(V2ME_EP) ? 0. : V2ME_EP; values[kWV2ME_EP] = std::isnan(V2ME_EP) || std::isinf(V2ME_EP) ? 0. : 1.0; + + // Cumulant part + float V22ME = values[kV22m] * values[kCos2DeltaPhiMu1] + values[kV22p] * values[kCos2DeltaPhiMu2]; + float V24ME = values[kV24m] * values[kCos2DeltaPhiMu1] + values[kV24p] * values[kCos2DeltaPhiMu2]; + values[kV22ME] = (std::isnan(V22ME) || std::isinf(V22ME) || std::isnan(V24ME) || std::isinf(V24ME)) ? 0. : V22ME; + values[kWV22ME] = (std::isnan(V22ME) || std::isinf(V22ME) || std::isnan(V24ME) || std::isinf(V24ME)) ? 0. : 1.0; + values[kV24ME] = (std::isnan(V22ME) || std::isinf(V22ME) || std::isnan(V24ME) || std::isinf(V24ME)) ? 0. : V24ME; + values[kWV24ME] = (std::isnan(V22ME) || std::isinf(V22ME) || std::isnan(V24ME) || std::isinf(V24ME)) ? 0. : 1.0; + + if constexpr ((fillMap & ReducedEventQvectorExtra) > 0) { + complex Q21(values[kQ2X0A] * values[kS11A], values[kQ2Y0A] * values[kS11A]); + complex Q42(values[kQ42XA], values[kQ42YA]); + complex Q23(values[kQ23XA], values[kQ23YA]); + complex P2(TMath::Cos(2 * v12.Phi()), TMath::Sin(2 * v12.Phi())); + values[kM01POIME] = values[kMultDimuonsME] * values[kS11A]; + values[kM0111POIME] = values[kMultDimuonsME] * (values[kS31A] - 3. * values[kS11A] * values[kS12A] + 2. * values[kS13A]); + values[kCORR2POIME] = (P2 * conj(Q21)).real() / values[kM01POIME]; + values[kCORR4POIME] = (P2 * Q21 * conj(Q21) * conj(Q21) - P2 * Q21 * conj(Q42) - 2. * values[kS12A] * P2 * conj(Q21) + 2. * P2 * conj(Q23)).real() / values[kM0111POIME]; + values[kM01POIoverMpME] = values[kMultDimuonsME] > 0 && !(std::isnan(values[kM01POIME]) || std::isinf(values[kM01POIME]) || std::isnan(values[kCORR2POIME]) || std::isinf(values[kCORR2POIME]) || std::isnan(values[kM0111POIME]) || std::isinf(values[kM0111POIME]) || std::isnan(values[kCORR4POIME]) || std::isinf(values[kCORR4POIME])) ? values[kM01POIME] / values[kMultDimuonsME] : 0; + values[kM0111POIoverMpME] = values[kMultDimuonsME] > 0 && !(std::isnan(values[kM0111POIME]) || std::isinf(values[kM0111POIME]) || std::isnan(values[kCORR4POIME]) || std::isinf(values[kCORR4POIME]) || std::isnan(values[kM01POIME]) || std::isinf(values[kM01POIME]) || std::isnan(values[kCORR2POIME]) || std::isinf(values[kCORR2POIME])) ? values[kM0111POIME] / values[kMultDimuonsME] : 0; + values[kM11REFoverMpME] = values[kMultDimuonsME] > 0 && !(std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF])) ? values[kM11REF] / values[kMultDimuonsME] : 0; + values[kM1111REFoverMpME] = values[kMultDimuonsME] > 0 && !(std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF]) || std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF])) ? values[kM1111REF] / values[kMultDimuonsME] : 0; + values[kCORR2REFbydimuonsME] = std::isnan(values[kM11REFoverMpME]) || std::isinf(values[kM11REFoverMpME]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kM1111REFoverMpME]) || std::isinf(values[kM1111REFoverMpME]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF]) ? 0 : values[kCORR2REF]; + values[kCORR4REFbydimuonsME] = std::isnan(values[kM1111REFoverMpME]) || std::isinf(values[kM1111REFoverMpME]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF]) || std::isnan(values[kM11REFoverMpME]) || std::isinf(values[kM11REFoverMpME]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) ? 0 : values[kCORR4REF]; + values[kCORR2POIME] = std::isnan(values[kCORR2POIME]) || std::isinf(values[kCORR2POIME]) || std::isnan(values[kM01POIME]) || std::isinf(values[kM01POIME]) || std::isnan(values[kCORR4POIME]) || std::isinf(values[kCORR4POIME]) || std::isnan(values[kM0111POIME]) || std::isinf(values[kM0111POIME]) ? 0 : values[kCORR2POIME]; + values[kCORR4POIME] = std::isnan(values[kCORR4POIME]) || std::isinf(values[kCORR4POIME]) || std::isnan(values[kM0111POIME]) || std::isinf(values[kM0111POIME]) || std::isnan(values[kCORR2POIME]) || std::isinf(values[kCORR2POIME]) || std::isnan(values[kM01POIME]) || std::isinf(values[kM01POIME]) ? 0 : values[kCORR4POIME]; + } } if constexpr (pairType == kDecayToMuMu) { if (fgUsedVars[kQuadDCAabsXY]) { @@ -2995,8 +3325,8 @@ void VarManager::FillPairME(T1 const& t1, T2 const& t2, float* values) } } -template -void VarManager::FillPairMC(T1 const& t1, T2 const& t2, float* values, PairCandidateType pairType) +template +void VarManager::FillPairMC(T1 const& t1, T2 const& t2, float* values) { if (!values) { values = fgValues; @@ -3014,6 +3344,11 @@ void VarManager::FillPairMC(T1 const& t1, T2 const& t2, float* values, PairCandi m2 = o2::constants::physics::MassPionCharged; } + if (pairType == kDecayToKPi) { + m1 = o2::constants::physics::MassKaonCharged; + m2 = o2::constants::physics::MassPionCharged; + } + if (pairType == kElectronMuon) { m2 = o2::constants::physics::MassMuon; } @@ -3022,11 +3357,130 @@ void VarManager::FillPairMC(T1 const& t1, T2 const& t2, float* values, PairCandi ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), m1); ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), m2); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - values[kMass] = v12.M(); - values[kPt] = v12.Pt(); - values[kEta] = v12.Eta(); - values[kPhi] = v12.Phi(); - values[kRap] = -v12.Rapidity(); + values[kMCMass] = v12.M(); + values[kMCPt] = v12.Pt(); + values[kMCEta] = v12.Eta(); + values[kMCPhi] = v12.Phi(); + values[kMCY] = -v12.Rapidity(); + + // polarization parameters + bool useHE = fgUsedVars[kMCCosThetaHE] || fgUsedVars[kMCPhiHE]; // helicity frame + bool useCS = fgUsedVars[kMCCosThetaCS] || fgUsedVars[kMCPhiCS]; // Collins-Soper frame + bool usePP = fgUsedVars[kMCCosThetaPP]; // production plane frame + bool useRM = fgUsedVars[kMCCosThetaRM]; // Random frame + + if (useHE || useCS || usePP || useRM) { + ROOT::Math::Boost boostv12{v12.BoostToCM()}; + ROOT::Math::XYZVectorF v1_CM{(boostv12(v1).Vect()).Unit()}; + ROOT::Math::XYZVectorF v2_CM{(boostv12(v2).Vect()).Unit()}; + ROOT::Math::XYZVectorF Beam1_CM{(boostv12(fgBeamA).Vect()).Unit()}; + ROOT::Math::XYZVectorF Beam2_CM{(boostv12(fgBeamC).Vect()).Unit()}; + + // using positive sign convention for the first track + ROOT::Math::XYZVectorF v_CM = (t1.pdgCode() > 0 ? v1_CM : v2_CM); + + if (useHE) { + ROOT::Math::XYZVectorF zaxis_HE{(v12.Vect()).Unit()}; + ROOT::Math::XYZVectorF yaxis_HE{(Beam1_CM.Cross(Beam2_CM)).Unit()}; + ROOT::Math::XYZVectorF xaxis_HE{(yaxis_HE.Cross(zaxis_HE)).Unit()}; + if (fgUsedVars[kMCCosThetaHE]) + values[kMCCosThetaHE] = zaxis_HE.Dot(v_CM); + if (fgUsedVars[kMCPhiHE]) { + values[kMCPhiHE] = TMath::ATan2(yaxis_HE.Dot(v_CM), xaxis_HE.Dot(v_CM)); + if (values[kMCPhiHE] < 0) { + values[kMCPhiHE] += 2 * TMath::Pi(); // ensure phi is in [0, 2pi] + } + } + if (fgUsedVars[kMCPhiTildeHE]) { + if (fgUsedVars[kMCCosThetaHE] && fgUsedVars[kMCPhiHE]) { + if (values[kMCCosThetaHE] > 0) { + values[kMCPhiTildeHE] = values[kMCPhiHE] - 0.25 * TMath::Pi(); // phi_tilde = phi - pi/4 + if (values[kMCPhiTildeHE] < 0) { + values[kMCPhiTildeHE] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } else { + values[kMCPhiTildeHE] = values[kMCPhiHE] - 0.75 * TMath::Pi(); // phi_tilde = phi - 3pi/4 + if (values[kMCPhiTildeHE] < 0) { + values[kMCPhiTildeHE] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } + } else { + values[kMCPhiTildeHE] = -999; // not computable + } + } + } + + if (useCS) { + ROOT::Math::XYZVectorF zaxis_CS{(Beam1_CM - Beam2_CM).Unit()}; + ROOT::Math::XYZVectorF yaxis_CS{(Beam1_CM.Cross(Beam2_CM)).Unit()}; + ROOT::Math::XYZVectorF xaxis_CS{(yaxis_CS.Cross(zaxis_CS)).Unit()}; + if (fgUsedVars[kMCCosThetaCS]) + values[kMCCosThetaCS] = zaxis_CS.Dot(v_CM); + if (fgUsedVars[kMCPhiCS]) { + values[kMCPhiCS] = TMath::ATan2(yaxis_CS.Dot(v_CM), xaxis_CS.Dot(v_CM)); + if (values[kMCPhiCS] < 0) { + values[kMCPhiCS] += 2 * TMath::Pi(); // ensure phi is in [0, 2pi] + } + } + if (fgUsedVars[kMCPhiTildeCS]) { + if (fgUsedVars[kMCCosThetaCS] && fgUsedVars[kMCPhiCS]) { + if (values[kMCCosThetaCS] > 0) { + values[kMCPhiTildeCS] = values[kMCPhiCS] - 0.25 * TMath::Pi(); // phi_tilde = phi - pi/4 + if (values[kMCPhiTildeCS] < 0) { + values[kMCPhiTildeCS] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } else { + values[kMCPhiTildeCS] = values[kMCPhiCS] - 0.75 * TMath::Pi(); // phi_tilde = phi - 3pi/4 + if (values[kMCPhiTildeCS] < 0) { + values[kMCPhiTildeCS] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } + } else { + values[kMCPhiTildeCS] = -999; // not computable + } + } + } + + if (usePP) { + ROOT::Math::XYZVector zaxis_PP = ROOT::Math::XYZVector(v12.Py(), -v12.Px(), 0.f); + ROOT::Math::XYZVector yaxis_PP{v12.Vect().Unit()}; + ROOT::Math::XYZVector xaxis_PP{(yaxis_PP.Cross(zaxis_PP)).Unit()}; + if (fgUsedVars[kMCCosThetaPP]) { + values[kMCCosThetaPP] = zaxis_PP.Dot(v_CM); + } + if (fgUsedVars[kMCPhiPP]) { + values[kMCPhiPP] = TMath::ATan2(yaxis_PP.Dot(v_CM), xaxis_PP.Dot(v_CM)); + if (values[kMCPhiPP] < 0) { + values[kMCPhiPP] += 2 * TMath::Pi(); // ensure phi is in [0, 2pi] + } + } + if (fgUsedVars[kMCPhiTildePP]) { + if (fgUsedVars[kMCCosThetaPP] && fgUsedVars[kMCPhiPP]) { + if (values[kMCCosThetaPP] > 0) { + values[kMCPhiTildePP] = values[kMCPhiPP] - 0.25 * TMath::Pi(); // phi_tilde = phi - pi/4 + if (values[kMCPhiTildePP] < 0) { + values[kMCPhiTildePP] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } else { + values[kMCPhiTildePP] = values[kMCPhiPP] - 0.75 * TMath::Pi(); // phi_tilde = phi - 3pi/4 + if (values[kMCPhiTildePP] < 0) { + values[kMCPhiTildePP] += 2 * TMath::Pi(); // ensure phi_tilde is in [0, 2pi] + } + } + } else { + values[kMCPhiTildePP] = -999; // not computable + } + } + } + + if (useRM) { + double randomCostheta = gRandom->Uniform(-1., 1.); + double randomPhi = gRandom->Uniform(0., 2. * TMath::Pi()); + ROOT::Math::XYZVectorF zaxis_RM(randomCostheta, std::sqrt(1 - randomCostheta * randomCostheta) * std::cos(randomPhi), std::sqrt(1 - randomCostheta * randomCostheta) * std::sin(randomPhi)); + if (fgUsedVars[kMCCosThetaRM]) + values[kMCCosThetaRM] = zaxis_RM.Dot(v_CM); + } + } } template @@ -3078,6 +3532,10 @@ void VarManager::FillTripleMC(T1 const& t1, T2 const& t2, T3 const& t3, float* v values[kEta] = v123.Eta(); values[kPhi] = v123.Phi(); values[kRap] = -v123.Rapidity(); + values[kCharge] = t1.sign() + t2.sign() + t3.sign(); + values[kS12] = (v1 + v2).M2(); + values[kS13] = (v1 + v3).M2(); + values[kS23] = (v2 + v3).M2(); } } @@ -3248,6 +3706,7 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2, values[kVertexingLxyzProjected] = ((secondaryVertex[0] - collision.posX()) * v12.Px()) + ((secondaryVertex[1] - collision.posY()) * v12.Py()) + ((secondaryVertex[2] - collision.posZ()) * v12.Pz()); values[kVertexingLxyzProjected] = values[kVertexingLxyzProjected] / TMath::Sqrt((v12.Px() * v12.Px()) + (v12.Py() * v12.Py()) + (v12.Pz() * v12.Pz())); values[kVertexingTauxyProjected] = values[kVertexingLxyProjected] * v12.M() / (v12.Pt()); + values[kVertexingTauxyProjectedPoleJPsiMass] = values[kVertexingLxyProjected] * o2::constants::physics::MassJPsi / (v12.Pt()); values[kVertexingTauxyProjectedNs] = values[kVertexingTauxyProjected] / o2::constants::physics::LightSpeedCm2NS; values[kVertexingTauzProjected] = values[kVertexingLzProjected] * v12.M() / TMath::Abs(v12.Pz()); values[kVertexingTauxyzProjected] = values[kVertexingLxyzProjected] * v12.M() / (v12.P()); @@ -3336,6 +3795,7 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2, values[kVertexingLxyzProjected] = (dxPair2PV * KFGeoTwoProng.GetPx()) + (dyPair2PV * KFGeoTwoProng.GetPy()) + (dzPair2PV * KFGeoTwoProng.GetPz()); values[kVertexingLxyzProjected] = values[kVertexingLxyzProjected] / TMath::Sqrt((KFGeoTwoProng.GetPx() * KFGeoTwoProng.GetPx()) + (KFGeoTwoProng.GetPy() * KFGeoTwoProng.GetPy()) + (KFGeoTwoProng.GetPz() * KFGeoTwoProng.GetPz())); values[kVertexingTauxyProjected] = values[kVertexingLxyProjected] * KFGeoTwoProng.GetMass() / (KFGeoTwoProng.GetPt()); + values[kVertexingTauxyProjectedPoleJPsiMass] = values[kVertexingLxyProjected] * o2::constants::physics::MassJPsi / (KFGeoTwoProng.GetPt()); values[kVertexingTauxyProjectedNs] = values[kVertexingTauxyProjected] / o2::constants::physics::LightSpeedCm2NS; values[kVertexingTauzProjected] = values[kVertexingLzProjected] * KFGeoTwoProng.GetMass() / TMath::Abs(KFGeoTwoProng.GetPz()); } @@ -3533,6 +3993,7 @@ void VarManager::FillTripletVertexing(C const& collision, T const& t1, T const& values[VarManager::kVertexingProcCode] = procCode; if (procCode == 0) { // TODO: set the other variables to appropriate values and return + values[kVertexingChi2PCA] = -999.; values[kVertexingLxy] = -999.; values[kVertexingLxyz] = -999.; values[kVertexingLz] = -999.; @@ -3567,6 +4028,11 @@ void VarManager::FillTripletVertexing(C const& collision, T const& t1, T const& o2::dataformats::VertexBase primaryVertex = {std::move(vtxXYZ), std::move(vtxCov)}; auto covMatrixPV = primaryVertex.getCov(); + if (fgUsedVars[kVertexingChi2PCA]) { + auto chi2PCA = fgFitterThreeProngBarrel.getChi2AtPCACandidate(); + values[VarManager::kVertexingChi2PCA] = chi2PCA; + } + double phi = std::atan2(secondaryVertex[1] - collision.posY(), secondaryVertex[0] - collision.posX()); double theta = std::atan2(secondaryVertex[2] - collision.posZ(), std::sqrt((secondaryVertex[0] - collision.posX()) * (secondaryVertex[0] - collision.posX()) + @@ -3789,6 +4255,9 @@ void VarManager::FillDileptonTrackVertexing(C const& collision, T1 const& lepton values[VarManager::kPairPtDau] = v12.Pt(); } values[VarManager::kPt] = track.pt(); + values[kS12] = (v1 + v2).M2(); + values[kS13] = (v1 + v3).M2(); + values[kS23] = (v2 + v3).M2(); values[VarManager::kVertexingProcCode] = procCode; if (procCode == 0 || procCodeJpsi == 0) { @@ -3830,9 +4299,10 @@ void VarManager::FillDileptonTrackVertexing(C const& collision, T1 const& lepton covMatrixPCA = fgFitterThreeProngFwd.calcPCACovMatrixFlat(); } - auto chi2PCA = fgFitterThreeProngBarrel.getChi2AtPCACandidate(); - if (fgUsedVars[kVertexingChi2PCA]) + if (fgUsedVars[kVertexingChi2PCA]) { + auto chi2PCA = fgFitterThreeProngBarrel.getChi2AtPCACandidate(); values[VarManager::kVertexingChi2PCA] = chi2PCA; + } double phi = std::atan2(secondaryVertex[1] - collision.posY(), secondaryVertex[0] - collision.posX()); double theta = std::atan2(secondaryVertex[2] - collision.posZ(), @@ -4034,7 +4504,7 @@ void VarManager::FillQVectorFromGFW(C const& /*collision*/, A const& compA11, A values[kM11REF] = S21A - S12A; values[kM1111REF] = S41A - 6. * S12A * S21A + 8. * S13A * S11A + 3. * S22A - 6. * S14A; values[kCORR2REF] = (norm(compA21) - S12A) / values[kM11REF]; - values[kCORR4REF] = (pow(norm(compA21), 2) + norm(compA42) - 2. * (compA42 * conj(compA21) * conj(compA21)).real() + 8. * (compA23 * conj(compA21)).real() - 4. * S12A * norm(compA21) - 6. * S14A - 2. * S22A) / values[kM1111REF]; + values[kCORR4REF] = (pow(norm(compA21), 2) + norm(compA42) - 2. * (compA42 * conj(compA21) * conj(compA21)).real() + 8. * (compA23 * conj(compA21)).real() - 4. * S12A * norm(compA21) - 6. * S14A + 2. * S22A) / values[kM1111REF]; values[kCORR2REF] = std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) ? 0 : values[kCORR2REF]; values[kM11REF] = std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) ? 0 : values[kM11REF]; values[kCORR4REF] = std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF]) ? 0 : values[kCORR4REF]; @@ -4305,6 +4775,8 @@ void VarManager::FillPairVn(T1 const& t1, T2 const& t2, float* values) ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), m1); ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), m2); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + values[kPt1] = t1.pt(); + values[kPt2] = t2.pt(); // TODO: provide different computations for vn // Compute the scalar product UQ using Q-vector from A, for second and third harmonic @@ -4357,6 +4829,26 @@ void VarManager::FillPairVn(T1 const& t1, T2 const& t2, float* values) values[kR3EP] = -999.; } + // global polarization parameters + bool useGlobalPolarizatiobSpinOne = fgUsedVars[kCosThetaStarTPC] || fgUsedVars[kCosThetaStarFT0A] || fgUsedVars[kCosThetaStarFT0C]; + if (useGlobalPolarizatiobSpinOne) { + ROOT::Math::Boost boostv12{v12.BoostToCM()}; + ROOT::Math::XYZVectorF v1_CM{(boostv12(v1).Vect()).Unit()}; + ROOT::Math::XYZVectorF v2_CM{(boostv12(v2).Vect()).Unit()}; + + // using positive sign convention for the first track + ROOT::Math::XYZVectorF v_CM = (t1.sign() > 0 ? v1_CM : v2_CM); + + ROOT::Math::XYZVector zaxisTPC = ROOT::Math::XYZVector(TMath::Cos(Psi2A), TMath::Sin(Psi2A), 0).Unit(); + values[kCosThetaStarTPC] = v_CM.Dot(zaxisTPC); + + ROOT::Math::XYZVector zaxisFT0A = ROOT::Math::XYZVector(TMath::Cos(Psi2B), TMath::Sin(Psi2B), 0).Unit(); + values[kCosThetaStarFT0A] = v_CM.Dot(zaxisFT0A); + + ROOT::Math::XYZVector zaxisFT0C = ROOT::Math::XYZVector(TMath::Cos(Psi2C), TMath::Sin(Psi2C), 0).Unit(); + values[kCosThetaStarFT0C] = v_CM.Dot(zaxisFT0C); + } + // kV4, kC4POI, kC4REF etc. if constexpr ((fillMap & ReducedEventQvectorExtra) > 0) { complex Q21(values[kQ2X0A] * values[kS11A], values[kQ2Y0A] * values[kS11A]); @@ -4383,6 +4875,35 @@ void VarManager::FillPairVn(T1 const& t1, T2 const& t2, float* values) values[kM01M0111overMp] = values[kMultDimuons] > 0 && !(std::isnan(values[kM01POI]) || std::isinf(values[kM01POI]) || std::isnan(values[kM0111POI]) || std::isinf(values[kM0111POI]) || std::isnan(values[kCORR2POI]) || std::isinf(values[kCORR2POI]) || std::isnan(values[kCORR4POI]) || std::isinf(values[kCORR4POI])) ? (values[kM01POI] * values[kM0111POI]) / values[kMultDimuons] : 0; values[kM11M0111overMp] = values[kMultDimuons] > 0 && !(std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kM0111POI]) || std::isinf(values[kM0111POI]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kCORR4POI]) || std::isinf(values[kCORR4POI])) ? (values[kM11REF] * values[kM0111POI]) / values[kMultDimuons] : 0; values[kM11M01overMp] = values[kMultDimuons] > 0 && !(std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kM01POI]) || std::isinf(values[kM01POI]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kCORR2POI]) || std::isinf(values[kCORR2POI])) ? (values[kM11REF] * values[kM01POI]) / values[kMultDimuons] : 0; + + complex P2plus(TMath::Cos(2 * v1.Phi()), TMath::Sin(2 * v1.Phi())); + complex P2minus(TMath::Cos(2 * v2.Phi()), TMath::Sin(2 * v2.Phi())); + values[kM11REFoverMpplus] = values[kMultAntiMuons] > 0 && !(std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF])) ? values[kM11REF] / values[kMultAntiMuons] : 0; + values[kM1111REFoverMpplus] = values[kMultAntiMuons] > 0 && !(std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF])) ? values[kM1111REF] / values[kMultAntiMuons] : 0; + values[kM11REFoverMpminus] = values[kMultMuons] > 0 && !(std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF])) ? values[kM11REF] / values[kMultMuons] : 0; + values[kM1111REFoverMpminus] = values[kMultMuons] > 0 && !(std::isnan(values[kM11REF]) || std::isinf(values[kM11REF]) || std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) || std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF]) || std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF])) ? values[kM1111REF] / values[kMultMuons] : 0; + values[kCORR2POIplus] = (P2plus * conj(Q21)).real() / values[kM01POI]; + values[kCORR2POIminus] = (P2minus * conj(Q21)).real() / values[kM01POI]; + values[kM01POIplus] = values[kMultAntiMuons] * values[kS11A]; + values[kM0111POIplus] = values[kMultAntiMuons] * (values[kS31A] - 3. * values[kS11A] * values[kS12A] + 2. * values[kS13A]); + values[kCORR2POIplus] = (P2plus * conj(Q21)).real() / values[kM01POIplus]; + values[kCORR4POIplus] = (P2plus * Q21 * conj(Q21) * conj(Q21) - P2plus * Q21 * conj(Q42) - 2. * values[kS12A] * P2plus * conj(Q21) + 2. * P2plus * conj(Q23)).real() / values[kM0111POIplus]; + values[kM01POIminus] = values[kMultMuons] * values[kS11A]; + values[kM0111POIminus] = values[kMultMuons] * (values[kS31A] - 3. * values[kS11A] * values[kS12A] + 2. * values[kS13A]); + values[kCORR2POIminus] = (P2minus * conj(Q21)).real() / values[kM01POIminus]; + values[kCORR4POIminus] = (P2minus * Q21 * conj(Q21) * conj(Q21) - P2minus * Q21 * conj(Q42) - 2. * values[kS12A] * P2minus * conj(Q21) + 2. * P2minus * conj(Q23)).real() / values[kM0111POIminus]; + values[kM01POIplus] = std::isnan(values[kM01POIplus]) || std::isinf(values[kM01POIplus]) || std::isnan(values[kM0111POIplus]) || std::isinf(values[kM0111POIplus]) || std::isnan(values[kCORR2POIplus]) || std::isinf(values[kCORR2POIplus]) || std::isnan(values[kCORR4POIplus]) || std::isinf(values[kCORR4POIplus]) ? 0 : values[kM01POIplus]; + values[kM0111POIplus] = std::isnan(values[kM0111POIplus]) || std::isinf(values[kM0111POIplus]) || std::isnan(values[kCORR2POIplus]) || std::isinf(values[kCORR2POIplus]) || std::isnan(values[kCORR4POIplus]) || std::isinf(values[kCORR4POIplus]) ? 0 : values[kM0111POIplus]; + values[kCORR2POIplus] = std::isnan(values[kM01POIplus]) || std::isinf(values[kM01POIplus]) || std::isnan(values[kM0111POIplus]) || std::isinf(values[kM0111POIplus]) || std::isnan(values[kCORR2POIplus]) || std::isinf(values[kCORR2POIplus]) || std::isnan(values[kCORR4POIplus]) || std::isinf(values[kCORR4POIplus]) ? 0 : values[kCORR2POIplus]; + values[kCORR4POIplus] = std::isnan(values[kM01POIplus]) || std::isinf(values[kM01POIplus]) || std::isnan(values[kM0111POIplus]) || std::isinf(values[kM0111POIplus]) || std::isnan(values[kCORR2POIplus]) || std::isinf(values[kCORR2POIplus]) || std::isnan(values[kCORR4POIplus]) || std::isinf(values[kCORR4POIplus]) ? 0 : values[kCORR4POIplus]; + values[kM01POIminus] = std::isnan(values[kM01POIminus]) || std::isinf(values[kM01POIminus]) || std::isnan(values[kM0111POIminus]) || std::isinf(values[kM0111POIminus]) || std::isnan(values[kCORR2POIminus]) || std::isinf(values[kCORR2POIminus]) || std::isnan(values[kCORR4POIminus]) || std::isinf(values[kCORR4POIminus]) ? 0 : values[kM01POIminus]; + values[kM0111POIminus] = std::isnan(values[kM01POIminus]) || std::isinf(values[kM01POIminus]) || std::isnan(values[kM0111POIminus]) || std::isinf(values[kM0111POIminus]) || std::isnan(values[kCORR2POIminus]) || std::isinf(values[kCORR2POIminus]) || std::isnan(values[kCORR4POIminus]) || std::isinf(values[kCORR4POIminus]) ? 0 : values[kM0111POIminus]; + values[kCORR2POIminus] = std::isnan(values[kM01POIminus]) || std::isinf(values[kM01POIminus]) || std::isnan(values[kM0111POIminus]) || std::isinf(values[kM0111POIminus]) || std::isnan(values[kCORR2POIminus]) || std::isinf(values[kCORR2POIminus]) || std::isnan(values[kCORR4POIminus]) || std::isinf(values[kCORR4POIminus]) ? 0 : values[kCORR2POIminus]; + values[kCORR4POIminus] = std::isnan(values[kM01POIminus]) || std::isinf(values[kM01POIminus]) || std::isnan(values[kM0111POIminus]) || std::isinf(values[kM0111POIminus]) || std::isnan(values[kCORR2POIminus]) || std::isinf(values[kCORR2POIminus]) || std::isnan(values[kCORR4POIminus]) || std::isinf(values[kCORR4POIminus]) ? 0 : values[kCORR4POIminus]; + values[kM01POIoverMpminus] = values[kMultMuons] > 0 && !(std::isnan(values[kM0111POIminus]) || std::isinf(values[kM0111POIminus]) || std::isnan(values[kCORR4POIminus]) || std::isinf(values[kCORR4POIminus]) || std::isnan(values[kM01POIminus]) || std::isinf(values[kM01POIminus]) || std::isnan(values[kCORR2POIminus]) || std::isinf(values[kCORR2POIminus])) ? values[kM01POIminus] / values[kMultMuons] : 0; + values[kM0111POIoverMpminus] = values[kMultMuons] > 0 && !(std::isnan(values[kM0111POIminus]) || std::isinf(values[kM0111POIminus]) || std::isnan(values[kCORR4POIminus]) || std::isinf(values[kCORR4POIminus]) || std::isnan(values[kM01POIminus]) || std::isinf(values[kM01POIminus]) || std::isnan(values[kCORR2POIminus]) || std::isinf(values[kCORR2POIminus])) ? values[kM0111POIminus] / values[kMultMuons] : 0; + values[kM01POIoverMpplus] = values[kMultAntiMuons] > 0 && !(std::isnan(values[kM0111POIplus]) || std::isinf(values[kM0111POIplus]) || std::isnan(values[kCORR4POIplus]) || std::isinf(values[kCORR4POIplus]) || std::isnan(values[kM01POIplus]) || std::isinf(values[kM01POIplus]) || std::isnan(values[kCORR2POIplus]) || std::isinf(values[kCORR2POIplus])) ? values[kM01POIplus] / values[kMultAntiMuons] : 0; + values[kM0111POIoverMpplus] = values[kMultMuons] > 0 && !(std::isnan(values[kM0111POIplus]) || std::isinf(values[kM0111POIplus]) || std::isnan(values[kCORR4POIplus]) || std::isinf(values[kCORR4POIplus]) || std::isnan(values[kM01POIplus]) || std::isinf(values[kM01POIplus]) || std::isnan(values[kCORR2POIplus]) || std::isinf(values[kCORR2POIplus])) ? values[kM0111POIplus] / values[kMultAntiMuons] : 0; } ROOT::Math::PtEtaPhiMVector v1_vp(v1.Pt(), v1.Eta(), v1.Phi() - Psi2B, v1.M()); @@ -4393,6 +4914,7 @@ void VarManager::FillPairVn(T1 const& t1, T2 const& t2, float* values) auto vDimu = (t1.sign() > 0 ? ROOT::Math::XYZVectorF(v1_vp.Px(), v1_vp.Py(), v1_vp.Pz()).Cross(ROOT::Math::XYZVectorF(v2_vp.Px(), v2_vp.Py(), v2_vp.Pz())) : ROOT::Math::XYZVectorF(v2_vp.Px(), v2_vp.Py(), v2_vp.Pz()).Cross(ROOT::Math::XYZVectorF(v1_vp.Px(), v1_vp.Py(), v1_vp.Pz()))); auto vRef = p12_vp.Cross(p12_vp_projXZ); + values[kCosPhiVP] = vDimu.Dot(vRef) / (vRef.R() * vDimu.R()); values[kPhiVP] = std::acos(vDimu.Dot(vRef) / (vRef.R() * vDimu.R())); } @@ -4420,7 +4942,7 @@ void VarManager::FillDileptonHadron(T1 const& dilepton, T2 const& hadron, float* values = fgValues; } - if (fgUsedVars[kPairMass] || fgUsedVars[kPairPt] || fgUsedVars[kPairEta] || fgUsedVars[kPairPhi] || fgUsedVars[kPairMassDau] || fgUsedVars[kPairPtDau]) { + if (fgUsedVars[kPairMass] || fgUsedVars[kPairPt] || fgUsedVars[kPairEta] || fgUsedVars[kPairPhi] || fgUsedVars[kPairMassDau] || fgUsedVars[kPairPtDau] || fgUsedVars[kDileptonHadronKstar]) { ROOT::Math::PtEtaPhiMVector v1(dilepton.pt(), dilepton.eta(), dilepton.phi(), dilepton.mass()); ROOT::Math::PtEtaPhiMVector v2(hadron.pt(), hadron.eta(), hadron.phi(), hadronMass); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; @@ -4432,6 +4954,11 @@ void VarManager::FillDileptonHadron(T1 const& dilepton, T2 const& hadron, float* values[kPairPtDau] = dilepton.pt(); values[kMassDau] = hadronMass; values[kDeltaMass] = v12.M() - dilepton.mass(); + // Calculate kstar of Dilepton and hadron pair + ROOT::Math::PtEtaPhiMVector v12_Qvect = v1 - v2; + double Pinv = v12.M(); + double Q1 = (dilepton.mass() * dilepton.mass() - hadronMass * hadronMass) / Pinv; + values[kDileptonHadronKstar] = sqrt(Q1 * Q1 - v12_Qvect.M2()) / 2.0; } if (fgUsedVars[kDeltaPhi]) { double delta = dilepton.phi() - hadron.phi(); @@ -4580,15 +5107,276 @@ void VarManager::FillDileptonTrackTrack(T1 const& dilepton, T2 const& hadron1, T values[kDitrackPt] = v23.Pt(); values[kCosthetaDileptonDitrack] = (v1.Px() * v123.Px() + v1.Py() * v123.Py() + v1.Pz() * v123.Pz()) / (v1.P() * v123.P()); values[kQ] = v123.M() - defaultDileptonMass - v23.M(); - values[kDeltaR1] = sqrt(pow(v1.Eta() - v2.Eta(), 2) + pow(v1.Phi() - v2.Phi(), 2)); - values[kDeltaR2] = sqrt(pow(v1.Eta() - v3.Eta(), 2) + pow(v1.Phi() - v3.Phi(), 2)); + values[kDeltaR1] = ROOT::Math::VectorUtil::DeltaR(v1, v2); + values[kDeltaR2] = ROOT::Math::VectorUtil::DeltaR(v1, v3); + values[kDeltaR] = sqrt(pow(values[kDeltaR1], 2) + pow(values[kDeltaR2], 2)); values[kRap] = v123.Rapidity(); } } +//__________________________________________________________________ +template +void VarManager::FillDileptonTrackTrackVertexing(C const& collision, T1 const& lepton1, T1 const& lepton2, T1 const& track1, T1 const& track2, float* values) +{ + constexpr bool eventHasVtxCov = ((collFillMap & Collision) > 0 || (collFillMap & ReducedEventVtxCov) > 0); + constexpr bool trackHasCov = ((fillMap & TrackCov) > 0 || (fillMap & ReducedTrackBarrelCov) > 0); + + if (!eventHasVtxCov || !trackHasCov) { + return; + } + + if (!values) { + values = fgValues; + } + + float mtrack1, mtrack2; + float mlepton1, mlepton2; + + if constexpr (candidateType == kXtoJpsiPiPi || candidateType == kPsi2StoJpsiPiPi) { + mlepton1 = o2::constants::physics::MassElectron; + mlepton2 = o2::constants::physics::MassElectron; + mtrack1 = o2::constants::physics::MassPionCharged; + mtrack2 = o2::constants::physics::MassPionCharged; + } + + ROOT::Math::PtEtaPhiMVector v1(lepton1.pt(), lepton1.eta(), lepton1.phi(), mlepton1); + ROOT::Math::PtEtaPhiMVector v2(lepton2.pt(), lepton2.eta(), lepton2.phi(), mlepton2); + ROOT::Math::PtEtaPhiMVector v3(track1.pt(), track1.eta(), track1.phi(), mtrack1); + ROOT::Math::PtEtaPhiMVector v4(track2.pt(), track2.eta(), track2.phi(), mtrack2); + ROOT::Math::PtEtaPhiMVector v1234 = v1 + v2 + v3 + v4; + + int procCodeDilepton = 0; + int procCodeDileptonTrackTrack = 0; + + values[kUsedKF] = fgUsedKF; + if (!fgUsedKF) { + // create covariance matrix + std::array lepton1pars = {lepton1.y(), lepton1.z(), lepton1.snp(), lepton1.tgl(), lepton1.signed1Pt()}; + std::array lepton1covs = {lepton1.cYY(), lepton1.cZY(), lepton1.cZZ(), lepton1.cSnpY(), lepton1.cSnpZ(), + lepton1.cSnpSnp(), lepton1.cTglY(), lepton1.cTglZ(), lepton1.cTglSnp(), lepton1.cTglTgl(), + lepton1.c1PtY(), lepton1.c1PtZ(), lepton1.c1PtSnp(), lepton1.c1PtTgl(), lepton1.c1Pt21Pt2()}; + o2::track::TrackParCov pars1{lepton1.x(), lepton1.alpha(), lepton1pars, lepton1covs}; + std::array lepton2pars = {lepton2.y(), lepton2.z(), lepton2.snp(), lepton2.tgl(), lepton2.signed1Pt()}; + std::array lepton2covs = {lepton2.cYY(), lepton2.cZY(), lepton2.cZZ(), lepton2.cSnpY(), lepton2.cSnpZ(), + lepton2.cSnpSnp(), lepton2.cTglY(), lepton2.cTglZ(), lepton2.cTglSnp(), lepton2.cTglTgl(), + lepton2.c1PtY(), lepton2.c1PtZ(), lepton2.c1PtSnp(), lepton2.c1PtTgl(), lepton2.c1Pt21Pt2()}; + o2::track::TrackParCov pars2{lepton2.x(), lepton2.alpha(), lepton2pars, lepton2covs}; + std::array track1pars = {track1.y(), track1.z(), track1.snp(), track1.tgl(), track1.signed1Pt()}; + std::array track1covs = {track1.cYY(), track1.cZY(), track1.cZZ(), track1.cSnpY(), track1.cSnpZ(), + track1.cSnpSnp(), track1.cTglY(), track1.cTglZ(), track1.cTglSnp(), track1.cTglTgl(), + track1.c1PtY(), track1.c1PtZ(), track1.c1PtSnp(), track1.c1PtTgl(), track1.c1Pt21Pt2()}; + o2::track::TrackParCov pars3{track1.x(), track1.alpha(), track1pars, track1covs}; + std::array track2pars = {track2.y(), track2.z(), track2.snp(), track2.tgl(), track2.signed1Pt()}; + std::array track2covs = {track2.cYY(), track2.cZY(), track2.cZZ(), track2.cSnpY(), track2.cSnpZ(), + track2.cSnpSnp(), track2.cTglY(), track2.cTglZ(), track2.cTglSnp(), track2.cTglTgl(), + track2.c1PtY(), track2.c1PtZ(), track2.c1PtSnp(), track2.c1PtTgl(), track2.c1Pt21Pt2()}; + o2::track::TrackParCov pars4{track2.x(), track2.alpha(), track2pars, track2covs}; + + procCodeDilepton = VarManager::fgFitterTwoProngBarrel.process(pars1, pars2); + // create dilepton track + // o2::track::TrackParCov parsDilepton = VarManager::fgFitterTwoProngBarrel.createParentTrackParCov(0); + // procCodeDileptonTrackTrack = VarManager::fgFitterThreeProngBarrel.process(parsDilepton, pars3, pars4); + procCodeDileptonTrackTrack = VarManager::fgFitterFourProngBarrel.process(pars1, pars2, pars3, pars4); + + // fill values + if (procCodeDilepton == 0 && procCodeDileptonTrackTrack == 0) { + // TODO: set the other variables to appropriate values and return + values[kVertexingLxy] = -999.; + values[kVertexingLxyz] = -999.; + values[kVertexingLz] = -999.; + values[kVertexingLxyErr] = -999.; + values[kVertexingLxyzErr] = -999.; + values[kVertexingLzErr] = -999.; + values[kVertexingTauxy] = -999.; + values[kVertexingTauxyErr] = -999.; + values[kVertexingTauz] = -999.; + values[kVertexingTauzErr] = -999.; + values[kVertexingLzProjected] = -999.; + values[kVertexingLxyProjected] = -999.; + values[kVertexingLxyzProjected] = -999.; + values[kVertexingTauzProjected] = -999.; + values[kVertexingTauxyProjected] = -999.; + values[kVertexingTauxyzProjected] = -999.; + return; + } else { + Vec3D secondaryVertex; + std::array covMatrixPCA; + secondaryVertex = fgFitterFourProngBarrel.getPCACandidate(); + covMatrixPCA = fgFitterFourProngBarrel.calcPCACovMatrixFlat(); + + o2::math_utils::Point3D vtxXYZ(collision.posX(), collision.posY(), collision.posZ()); + std::array vtxCov{collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}; + o2::dataformats::VertexBase primaryVertex = {std::move(vtxXYZ), std::move(vtxCov)}; + auto covMatrixPV = primaryVertex.getCov(); + + double phi = std::atan2(secondaryVertex[1] - collision.posY(), secondaryVertex[0] - collision.posX()); + double theta = std::atan2(secondaryVertex[2] - collision.posZ(), + std::sqrt((secondaryVertex[0] - collision.posX()) * (secondaryVertex[0] - collision.posX()) + + (secondaryVertex[1] - collision.posY()) * (secondaryVertex[1] - collision.posY()))); + + values[kVertexingLxy] = (collision.posX() - secondaryVertex[0]) * (collision.posX() - secondaryVertex[0]) + + (collision.posY() - secondaryVertex[1]) * (collision.posY() - secondaryVertex[1]); + values[kVertexingLz] = (collision.posZ() - secondaryVertex[2]) * (collision.posZ() - secondaryVertex[2]); + values[kVertexingLxyz] = values[kVertexingLxy] + values[kVertexingLz]; + values[kVertexingLxy] = std::sqrt(values[kVertexingLxy]); + values[kVertexingLz] = std::sqrt(values[kVertexingLz]); + values[kVertexingLxyz] = std::sqrt(values[kVertexingLxyz]); + + values[kVertexingLxyzErr] = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta)); + values[kVertexingLxyErr] = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); + values[kVertexingLzErr] = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, 0, theta) + getRotatedCovMatrixXX(covMatrixPCA, 0, theta)); + + values[kVertexingTauz] = (collision.posZ() - secondaryVertex[2]) * v1234.M() / (TMath::Abs(v1234.Pz()) * o2::constants::physics::LightSpeedCm2NS); + values[kVertexingTauxy] = values[kVertexingLxy] * v1234.M() / (v1234.Pt() * o2::constants::physics::LightSpeedCm2NS); + + values[kVertexingTauzErr] = values[kVertexingLzErr] * v1234.M() / (TMath::Abs(v1234.Pz()) * o2::constants::physics::LightSpeedCm2NS); + values[kVertexingTauxyErr] = values[kVertexingLxyErr] * v1234.M() / (v1234.Pt() * o2::constants::physics::LightSpeedCm2NS); + + values[kCosPointingAngle] = ((collision.posX() - secondaryVertex[0]) * v1234.Px() + + (collision.posY() - secondaryVertex[1]) * v1234.Py() + + (collision.posZ() - secondaryVertex[2]) * v1234.Pz()) / + (v1234.P() * values[VarManager::kVertexingLxyz]); + // // run 2 definitions: Decay length projected onto the momentum vector of the candidate + values[kVertexingLzProjected] = (secondaryVertex[2] - collision.posZ()) * v1234.Pz(); + values[kVertexingLzProjected] = values[kVertexingLzProjected] / TMath::Sqrt(v1234.Pz() * v1234.Pz()); + values[kVertexingLxyProjected] = ((secondaryVertex[0] - collision.posX()) * v1234.Px()) + ((secondaryVertex[1] - collision.posY()) * v1234.Py()); + values[kVertexingLxyProjected] = values[kVertexingLxyProjected] / TMath::Sqrt((v1234.Px() * v1234.Px()) + (v1234.Py() * v1234.Py())); + values[kVertexingLxyzProjected] = ((secondaryVertex[0] - collision.posX()) * v1234.Px()) + ((secondaryVertex[1] - collision.posY()) * v1234.Py()) + ((secondaryVertex[2] - collision.posZ()) * v1234.Pz()); + values[kVertexingLxyzProjected] = values[kVertexingLxyzProjected] / TMath::Sqrt((v1234.Px() * v1234.Px()) + (v1234.Py() * v1234.Py()) + (v1234.Pz() * v1234.Pz())); + + values[kVertexingTauzProjected] = values[kVertexingLzProjected] * v1234.M() / TMath::Abs(v1234.Pz()); + values[kVertexingTauxyProjected] = values[kVertexingLxyProjected] * v1234.M() / (v1234.Pt()); + values[kVertexingTauxyzProjected] = values[kVertexingLxyzProjected] * v1234.M() / (v1234.P()); + } + } else if (fgUsedKF) { + KFParticle lepton1KF; // lepton1 + KFParticle lepton2KF; // lepton2 + KFParticle KFGeoTwoLeptons; + KFParticle trk1KF; // track1 + KFParticle trk2KF; // track2 + KFParticle KFGeoTwoTracks; + KFParticle KFGeoFourProng; + if constexpr (candidateType == kXtoJpsiPiPi) { + KFPTrack kfpTrack0 = createKFPTrackFromTrack(lepton1); + lepton1KF = KFParticle(kfpTrack0, -11 * lepton1.sign()); + KFPTrack kfpTrack1 = createKFPTrackFromTrack(lepton2); + lepton2KF = KFParticle(kfpTrack1, -11 * lepton2.sign()); + KFPTrack kfpTrack2 = createKFPTrackFromTrack(track1); + trk1KF = KFParticle(kfpTrack2, 211 * track1.sign()); + KFPTrack kfpTrack3 = createKFPTrackFromTrack(track2); + trk2KF = KFParticle(kfpTrack3, 211 * track2.sign()); + + KFGeoTwoLeptons.SetConstructMethod(2); + KFGeoTwoLeptons.AddDaughter(lepton1KF); + KFGeoTwoLeptons.AddDaughter(lepton2KF); + + if (fgUsedVars[kPairMass] || fgUsedVars[kPairPt]) { + values[VarManager::kPairMass] = KFGeoTwoLeptons.GetMass(); + values[VarManager::kPairPt] = KFGeoTwoLeptons.GetPt(); + } + + KFGeoTwoTracks.SetConstructMethod(2); + KFGeoTwoTracks.AddDaughter(trk1KF); + KFGeoTwoTracks.AddDaughter(trk2KF); + + if (fgUsedVars[kDitrackMass] || fgUsedVars[kDitrackPt]) { + values[VarManager::kDitrackMass] = KFGeoTwoTracks.GetMass(); + values[VarManager::kDitrackPt] = KFGeoTwoTracks.GetPt(); + } + + KFGeoFourProng.SetConstructMethod(2); + KFGeoFourProng.AddDaughter(KFGeoTwoLeptons); + KFGeoFourProng.AddDaughter(KFGeoTwoTracks); + } + + if constexpr (candidateType == kPsi2StoJpsiPiPi) { + KFPTrack kfpTrack0 = createKFPTrackFromTrack(lepton1); + lepton1KF = KFParticle(kfpTrack0, -11 * lepton1.sign()); + KFPTrack kfpTrack1 = createKFPTrackFromTrack(lepton2); + lepton2KF = KFParticle(kfpTrack1, -11 * lepton2.sign()); + KFPTrack kfpTrack2 = createKFPTrackFromTrack(track1); + trk1KF = KFParticle(kfpTrack2, 211 * track1.sign()); + KFPTrack kfpTrack3 = createKFPTrackFromTrack(track2); + trk2KF = KFParticle(kfpTrack3, 211 * track2.sign()); + + KFGeoTwoLeptons.SetConstructMethod(2); + KFGeoTwoLeptons.AddDaughter(lepton1KF); + KFGeoTwoLeptons.AddDaughter(lepton2KF); + + if (fgUsedVars[kPairMass] || fgUsedVars[kPairPt]) { + values[VarManager::kPairMass] = KFGeoTwoLeptons.GetMass(); + values[VarManager::kPairPt] = KFGeoTwoLeptons.GetPt(); + } + + KFGeoFourProng.SetConstructMethod(2); + KFGeoFourProng.AddDaughter(KFGeoTwoLeptons); + KFGeoFourProng.AddDaughter(trk1KF); + KFGeoFourProng.AddDaughter(trk2KF); + } + + if (fgUsedVars[kKFMass]) { + float mass = 0., massErr = 0.; + if (!KFGeoFourProng.GetMass(mass, massErr)) + values[kKFMass] = mass; + else + values[kKFMass] = -999.; + } + + KFPVertex kfpVertex = createKFPVertexFromCollision(collision); + values[kKFNContributorsPV] = kfpVertex.GetNContributors(); + KFParticle KFPV(kfpVertex); + double dxQuadlet2PV = KFGeoFourProng.GetX() - KFPV.GetX(); + double dyQuadlet2PV = KFGeoFourProng.GetY() - KFPV.GetY(); + double dzQuadlet2PV = KFGeoFourProng.GetZ() - KFPV.GetZ(); + + values[kVertexingLxy] = std::sqrt(dxQuadlet2PV * dxQuadlet2PV + dyQuadlet2PV * dyQuadlet2PV); + values[kVertexingLz] = std::sqrt(dzQuadlet2PV * dzQuadlet2PV); + values[kVertexingLxyz] = std::sqrt(dxQuadlet2PV * dxQuadlet2PV + dyQuadlet2PV * dyQuadlet2PV + dzQuadlet2PV * dzQuadlet2PV); + + values[kVertexingLxyErr] = (KFPV.GetCovariance(0) + KFGeoFourProng.GetCovariance(0)) * dxQuadlet2PV * dxQuadlet2PV + (KFPV.GetCovariance(2) + KFGeoFourProng.GetCovariance(2)) * dyQuadlet2PV * dyQuadlet2PV + 2 * ((KFPV.GetCovariance(1) + KFGeoFourProng.GetCovariance(1)) * dxQuadlet2PV * dyQuadlet2PV); + values[kVertexingLzErr] = (KFPV.GetCovariance(5) + KFGeoFourProng.GetCovariance(5)) * dzQuadlet2PV * dzQuadlet2PV; + values[kVertexingLxyzErr] = (KFPV.GetCovariance(0) + KFGeoFourProng.GetCovariance(0)) * dxQuadlet2PV * dxQuadlet2PV + (KFPV.GetCovariance(2) + KFGeoFourProng.GetCovariance(2)) * dyQuadlet2PV * dyQuadlet2PV + (KFPV.GetCovariance(5) + KFGeoFourProng.GetCovariance(5)) * dzQuadlet2PV * dzQuadlet2PV + 2 * ((KFPV.GetCovariance(1) + KFGeoFourProng.GetCovariance(1)) * dxQuadlet2PV * dyQuadlet2PV + (KFPV.GetCovariance(3) + KFGeoFourProng.GetCovariance(3)) * dxQuadlet2PV * dzQuadlet2PV + (KFPV.GetCovariance(4) + KFGeoFourProng.GetCovariance(4)) * dyQuadlet2PV * dzQuadlet2PV); + + if (fabs(values[kVertexingLxy]) < 1.e-8f) + values[kVertexingLxy] = 1.e-8f; + values[kVertexingLxyErr] = values[kVertexingLxyErr] < 0. ? 1.e8f : std::sqrt(values[kVertexingLxyErr]) / values[kVertexingLxy]; + if (fabs(values[kVertexingLz]) < 1.e-8f) + values[kVertexingLz] = 1.e-8f; + values[kVertexingLzErr] = values[kVertexingLzErr] < 0. ? 1.e8f : std::sqrt(values[kVertexingLzErr]) / values[kVertexingLz]; + if (fabs(values[kVertexingLxyz]) < 1.e-8f) + values[kVertexingLxyz] = 1.e-8f; + values[kVertexingLxyzErr] = values[kVertexingLxyzErr] < 0. ? 1.e8f : std::sqrt(values[kVertexingLxyzErr]) / values[kVertexingLxyz]; + + values[kVertexingTauxy] = KFGeoFourProng.GetPseudoProperDecayTime(KFPV, KFGeoFourProng.GetMass()) / (o2::constants::physics::LightSpeedCm2NS); + values[kVertexingTauz] = -1 * dzQuadlet2PV * KFGeoFourProng.GetMass() / (TMath::Abs(KFGeoFourProng.GetPz()) * o2::constants::physics::LightSpeedCm2NS); + values[kVertexingPz] = TMath::Abs(KFGeoFourProng.GetPz()); + values[kVertexingSV] = KFGeoFourProng.GetZ(); + + values[kVertexingTauxyErr] = values[kVertexingLxyErr] * KFGeoFourProng.GetMass() / (KFGeoFourProng.GetPt() * o2::constants::physics::LightSpeedCm2NS); + values[kVertexingTauzErr] = values[kVertexingLzErr] * KFGeoFourProng.GetMass() / (TMath::Abs(KFGeoFourProng.GetPz()) * o2::constants::physics::LightSpeedCm2NS); + values[kVertexingChi2PCA] = KFGeoFourProng.GetChi2(); + values[kCosPointingAngle] = (std::sqrt(dxQuadlet2PV * dxQuadlet2PV) * v1234.Px() + + std::sqrt(dyQuadlet2PV * dyQuadlet2PV) * v1234.Py() + + std::sqrt(dzQuadlet2PV * dzQuadlet2PV) * v1234.Pz()) / + (v1234.P() * values[VarManager::kVertexingLxyz]); + // // run 2 definitions: Decay length projected onto the momentum vector of the candidate + values[kVertexingLzProjected] = (dzQuadlet2PV * KFGeoFourProng.GetPz()) / TMath::Sqrt(KFGeoFourProng.GetPz() * KFGeoFourProng.GetPz()); + values[kVertexingLxyProjected] = (dxQuadlet2PV * KFGeoFourProng.GetPx()) + (dyQuadlet2PV * KFGeoFourProng.GetPy()); + values[kVertexingLxyProjected] = values[kVertexingLxyProjected] / TMath::Sqrt((KFGeoFourProng.GetPx() * KFGeoFourProng.GetPx()) + (KFGeoFourProng.GetPy() * KFGeoFourProng.GetPy())); + values[kVertexingLxyzProjected] = (dxQuadlet2PV * KFGeoFourProng.GetPx()) + (dyQuadlet2PV * KFGeoFourProng.GetPy()) + (dzQuadlet2PV * KFGeoFourProng.GetPz()); + values[kVertexingLxyzProjected] = values[kVertexingLxyzProjected] / TMath::Sqrt((KFGeoFourProng.GetPx() * KFGeoFourProng.GetPx()) + (KFGeoFourProng.GetPy() * KFGeoFourProng.GetPy()) + (KFGeoFourProng.GetPz() * KFGeoFourProng.GetPz())); + values[kVertexingTauxyProjected] = values[kVertexingLxyProjected] * KFGeoFourProng.GetMass() / (KFGeoFourProng.GetPt()); + values[kVertexingTauxyProjectedNs] = values[kVertexingTauxyProjected] / o2::constants::physics::LightSpeedCm2NS; + values[kVertexingTauzProjected] = values[kVertexingLzProjected] * KFGeoFourProng.GetMass() / TMath::Abs(KFGeoFourProng.GetPz()); + values[kKFChi2OverNDFGeo] = KFGeoFourProng.GetChi2() / KFGeoFourProng.GetNDF(); + } else { + return; + } +} + //__________________________________________________________________ template -void VarManager::FillQaudMC(T1 const& dilepton, T2 const& track1, T2 const& track2, float* values) +void VarManager::FillQuadMC(T1 const& dilepton, T2 const& track1, T2 const& track2, float* values) { if (!values) { values = fgValues; @@ -4614,8 +5402,9 @@ void VarManager::FillQaudMC(T1 const& dilepton, T2 const& track1, T2 const& trac values[kQuadEta] = v123.Eta(); values[kQuadPhi] = v123.Phi(); values[kQ] = v123.M() - defaultDileptonMass - v23.M(); - values[kDeltaR1] = sqrt(pow(v1.Eta() - v2.Eta(), 2) + pow(v1.Phi() - v2.Phi(), 2)); - values[kDeltaR2] = sqrt(pow(v1.Eta() - v3.Eta(), 2) + pow(v1.Phi() - v3.Phi(), 2)); + values[kDeltaR1] = ROOT::Math::VectorUtil::DeltaR(v1, v2); + values[kDeltaR2] = ROOT::Math::VectorUtil::DeltaR(v1, v3); + values[kDeltaR] = sqrt(pow(values[kDeltaR1], 2) + pow(values[kDeltaR2], 2)); values[kDitrackMass] = v23.M(); values[kDitrackPt] = v23.Pt(); } diff --git a/PWGDQ/DataModel/ReducedInfoTables.h b/PWGDQ/DataModel/ReducedInfoTables.h index 86e38033136..ae5fd853bf9 100644 --- a/PWGDQ/DataModel/ReducedInfoTables.h +++ b/PWGDQ/DataModel/ReducedInfoTables.h @@ -15,39 +15,62 @@ #ifndef PWGDQ_DATAMODEL_REDUCEDINFOTABLES_H_ #define PWGDQ_DATAMODEL_REDUCEDINFOTABLES_H_ -#include -#include -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGHF/Utils/utilsPid.h" + #include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Qvectors.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Qvectors.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" #include "MathUtils/Utils.h" -#include "PWGHF/Utils/utilsPid.h" +#include +#include namespace o2::aod { namespace dqppfilter { -DECLARE_SOA_COLUMN(EventFilter, eventFilter, uint64_t); //! Bit-field used for the high level event triggering -} +DECLARE_SOA_COLUMN(EventFilter, eventFilter, uint64_t); //! Bit-field used for the high level event triggering +DECLARE_SOA_COLUMN(NewBcMultFT0A, newBcMultFT0A, float); //! sum of amplitudes on A side of FT0 +DECLARE_SOA_COLUMN(NewBcMultFT0C, newBcMultFT0C, float); //! sum of amplitudes on C side of FT0 +DECLARE_SOA_COLUMN(NewBcMultFDDA, newBcMultFDDA, float); //! sum of amplitudes on A side of FDD +DECLARE_SOA_COLUMN(NewBcMultFDDC, newBcMultFDDC, float); //! sum of amplitudes on C side of FDD +DECLARE_SOA_COLUMN(NewBcMultFV0A, newBcMultFV0A, float); //! sum of amplitudes on A side of FDD +} // namespace dqppfilter DECLARE_SOA_TABLE(DQEventFilter, "AOD", "EVENTFILTER", //! Store event-level decisions (DQ high level triggers) dqppfilter::EventFilter); +DECLARE_SOA_TABLE(DQRapidityGapFilter, "AOD", "RAPIDITYGAPFILTER", + dqppfilter::EventFilter, + dqppfilter::NewBcMultFT0A, + dqppfilter::NewBcMultFT0C, + dqppfilter::NewBcMultFDDA, + dqppfilter::NewBcMultFDDC, + dqppfilter::NewBcMultFV0A, + zdc::EnergyCommonZNA, + zdc::EnergyCommonZNC, + zdc::EnergyCommonZPA, + zdc::EnergyCommonZPC, + zdc::TimeZNA, + zdc::TimeZNC, + zdc::TimeZPA, + zdc::TimeZPC); + namespace reducedevent { // basic event information -DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! -DECLARE_SOA_BITMAP_COLUMN(Tag, tag, 64); //! Bit-field for storing event information (e.g. high level info, cut decisions) -DECLARE_SOA_COLUMN(MCPosX, mcPosX, float); //! MC event position X -DECLARE_SOA_COLUMN(MCPosY, mcPosY, float); //! MC event position Y -DECLARE_SOA_COLUMN(MCPosZ, mcPosZ, float); //! MC event position Z +DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! +DECLARE_SOA_BITMAP_COLUMN(Tag, tag, 64); //! Bit-field for storing event information (e.g. high level info, cut decisions) +DECLARE_SOA_COLUMN(MCPosX, mcPosX, float); //! MC event position X +DECLARE_SOA_COLUMN(MCPosY, mcPosY, float); //! MC event position Y +DECLARE_SOA_COLUMN(MCPosZ, mcPosZ, float); //! MC event position Z DECLARE_SOA_COLUMN(NTPCoccupContribLongA, nTPCoccupContribLongA, int); //! TPC pileup occupancy on A side (long time range) DECLARE_SOA_COLUMN(NTPCoccupContribLongC, nTPCoccupContribLongC, int); //! TPC pileup occupancy on C side (long time range) DECLARE_SOA_COLUMN(NTPCoccupMeanTimeLongA, nTPCoccupMeanTimeLongA, float); //! TPC pileup mean time on A side (long time range) @@ -72,51 +95,51 @@ DECLARE_SOA_COLUMN(NTrkBPos, nTrkBPos, int); DECLARE_SOA_COLUMN(NTrkBNeg, nTrkBNeg, int); DECLARE_SOA_COLUMN(NTrkBAll, nTrkBAll, int); -DECLARE_SOA_COLUMN(Q1ZNAX, q1znax, float); //! Q-vector x component, evaluated with ZNA (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q1ZNAY, q1znay, float); //! Q-vector y component, evaluated with ZNA (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q1ZNCX, q1zncx, float); //! Q-vector x component, evaluated with ZNC (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q1ZNCY, q1zncy, float); //! Q-vector y component, evaluated with ZNC (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q1X0A, q1x0a, float); //! Q-vector x component, with event eta gap A (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q1Y0A, q1y0a, float); //! Q-vector y component, with event eta gap A (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q1X0B, q1x0b, float); //! Q-vector x component, with event eta gap B (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q1Y0B, q1y0b, float); //! Q-vector y component, with event eta gap B (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q1X0C, q1x0c, float); //! Q-vector x component, with event eta gap C (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q1Y0C, q1y0c, float); //! Q-vector y component, with event eta gap C (harmonic 1 and power 1) -DECLARE_SOA_COLUMN(Q2X0A, q2x0a, float); //! Q-vector x component, with event eta gap A (harmonic 2 and power 1) -DECLARE_SOA_COLUMN(Q2Y0A, q2y0a, float); //! Q-vector y component, with event eta gap A (harmonic 2 and power 1) -DECLARE_SOA_COLUMN(Q2X0B, q2x0b, float); //! Q-vector x component, with event eta gap B (harmonic 2 and power 1) -DECLARE_SOA_COLUMN(Q2Y0B, q2y0b, float); //! Q-vector y component, with event eta gap B (harmonic 2 and power 1) -DECLARE_SOA_COLUMN(Q2X0C, q2x0c, float); //! Q-vector x component, with event eta gap C (harmonic 2 and power 1) -DECLARE_SOA_COLUMN(Q2Y0C, q2y0c, float); //! Q-vector y component, with event eta gap C (harmonic 2 and power 1) -DECLARE_SOA_COLUMN(MultA, multa, float); //! Event multiplicity eta gap A -DECLARE_SOA_COLUMN(MultB, multb, float); //! Event multiplicity eta gap B -DECLARE_SOA_COLUMN(MultC, multc, float); //! Event multiplicity eta gap C -DECLARE_SOA_COLUMN(Q3X0A, q3x0a, float); //! Q-vector x component, with event eta gap A (harmonic 3 and power 1) -DECLARE_SOA_COLUMN(Q3Y0A, q3y0a, float); //! Q-vector y component, with event eta gap A (harmonic 3 and power 1) -DECLARE_SOA_COLUMN(Q3X0B, q3x0b, float); //! Q-vector x component, with event eta gap B (harmonic 3 and power 1) -DECLARE_SOA_COLUMN(Q3Y0B, q3y0b, float); //! Q-vector y component, with event eta gap B (harmonic 3 and power 1) -DECLARE_SOA_COLUMN(Q3X0C, q3x0c, float); //! Q-vector x component, with event eta gap C (harmonic 3 and power 1) -DECLARE_SOA_COLUMN(Q3Y0C, q3y0c, float); //! Q-vector y component, with event eta gap C (harmonic 3 and power 1) -DECLARE_SOA_COLUMN(Q4X0A, q4x0a, float); //! Q-vector x component, with event eta gap A (harmonic 4 and power 1) -DECLARE_SOA_COLUMN(Q4Y0A, q4y0a, float); //! Q-vector y component, with event eta gap A (harmonic 4 and power 1) -DECLARE_SOA_COLUMN(Q4X0B, q4x0b, float); //! Q-vector x component, with event eta gap B (harmonic 4 and power 1) -DECLARE_SOA_COLUMN(Q4Y0B, q4y0b, float); //! Q-vector y component, with event eta gap B (harmonic 4 and power 1) -DECLARE_SOA_COLUMN(Q4X0C, q4x0c, float); //! Q-vector x component, with event eta gap C (harmonic 4 and power 1) -DECLARE_SOA_COLUMN(Q4Y0C, q4y0c, float); //! Q-vector y component, with event eta gap C (harmonic 4 and power 1) -DECLARE_SOA_COLUMN(Q42XA, q42xa, float); //! Q-vector x component, with event eta gap A (harmonic 4 and power 2) -DECLARE_SOA_COLUMN(Q42YA, q42ya, float); //! Q-vector y component, with event eta gap A (harmonic 4 and power 2) -DECLARE_SOA_COLUMN(Q23XA, q23xa, float); //! Q-vector x component, with event eta gap A (harmonic 2 and power 3) -DECLARE_SOA_COLUMN(Q23YA, q23ya, float); //! Q-vector y component, with event eta gap A (harmonic 2 and power 3) -DECLARE_SOA_COLUMN(S11A, s11a, float); //! Weighted multiplicity (p = 1, k = 1) -DECLARE_SOA_COLUMN(S12A, s12a, float); //! Weighted multiplicity (p = 1, k = 2) -DECLARE_SOA_COLUMN(S13A, s13a, float); //! Weighted multiplicity (p = 1, k = 3) -DECLARE_SOA_COLUMN(S31A, s31a, float); //! Weighted multiplicity (p = 3, k = 1) -DECLARE_SOA_COLUMN(CORR2REF, corr2ref, float); //! Ref Flow correlator <2> +DECLARE_SOA_COLUMN(Q1ZNAX, q1znax, float); //! Q-vector x component, evaluated with ZNA (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q1ZNAY, q1znay, float); //! Q-vector y component, evaluated with ZNA (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q1ZNCX, q1zncx, float); //! Q-vector x component, evaluated with ZNC (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q1ZNCY, q1zncy, float); //! Q-vector y component, evaluated with ZNC (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q1X0A, q1x0a, float); //! Q-vector x component, with event eta gap A (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q1Y0A, q1y0a, float); //! Q-vector y component, with event eta gap A (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q1X0B, q1x0b, float); //! Q-vector x component, with event eta gap B (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q1Y0B, q1y0b, float); //! Q-vector y component, with event eta gap B (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q1X0C, q1x0c, float); //! Q-vector x component, with event eta gap C (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q1Y0C, q1y0c, float); //! Q-vector y component, with event eta gap C (harmonic 1 and power 1) +DECLARE_SOA_COLUMN(Q2X0A, q2x0a, float); //! Q-vector x component, with event eta gap A (harmonic 2 and power 1) +DECLARE_SOA_COLUMN(Q2Y0A, q2y0a, float); //! Q-vector y component, with event eta gap A (harmonic 2 and power 1) +DECLARE_SOA_COLUMN(Q2X0B, q2x0b, float); //! Q-vector x component, with event eta gap B (harmonic 2 and power 1) +DECLARE_SOA_COLUMN(Q2Y0B, q2y0b, float); //! Q-vector y component, with event eta gap B (harmonic 2 and power 1) +DECLARE_SOA_COLUMN(Q2X0C, q2x0c, float); //! Q-vector x component, with event eta gap C (harmonic 2 and power 1) +DECLARE_SOA_COLUMN(Q2Y0C, q2y0c, float); //! Q-vector y component, with event eta gap C (harmonic 2 and power 1) +DECLARE_SOA_COLUMN(MultA, multa, float); //! Event multiplicity eta gap A +DECLARE_SOA_COLUMN(MultB, multb, float); //! Event multiplicity eta gap B +DECLARE_SOA_COLUMN(MultC, multc, float); //! Event multiplicity eta gap C +DECLARE_SOA_COLUMN(Q3X0A, q3x0a, float); //! Q-vector x component, with event eta gap A (harmonic 3 and power 1) +DECLARE_SOA_COLUMN(Q3Y0A, q3y0a, float); //! Q-vector y component, with event eta gap A (harmonic 3 and power 1) +DECLARE_SOA_COLUMN(Q3X0B, q3x0b, float); //! Q-vector x component, with event eta gap B (harmonic 3 and power 1) +DECLARE_SOA_COLUMN(Q3Y0B, q3y0b, float); //! Q-vector y component, with event eta gap B (harmonic 3 and power 1) +DECLARE_SOA_COLUMN(Q3X0C, q3x0c, float); //! Q-vector x component, with event eta gap C (harmonic 3 and power 1) +DECLARE_SOA_COLUMN(Q3Y0C, q3y0c, float); //! Q-vector y component, with event eta gap C (harmonic 3 and power 1) +DECLARE_SOA_COLUMN(Q4X0A, q4x0a, float); //! Q-vector x component, with event eta gap A (harmonic 4 and power 1) +DECLARE_SOA_COLUMN(Q4Y0A, q4y0a, float); //! Q-vector y component, with event eta gap A (harmonic 4 and power 1) +DECLARE_SOA_COLUMN(Q4X0B, q4x0b, float); //! Q-vector x component, with event eta gap B (harmonic 4 and power 1) +DECLARE_SOA_COLUMN(Q4Y0B, q4y0b, float); //! Q-vector y component, with event eta gap B (harmonic 4 and power 1) +DECLARE_SOA_COLUMN(Q4X0C, q4x0c, float); //! Q-vector x component, with event eta gap C (harmonic 4 and power 1) +DECLARE_SOA_COLUMN(Q4Y0C, q4y0c, float); //! Q-vector y component, with event eta gap C (harmonic 4 and power 1) +DECLARE_SOA_COLUMN(Q42XA, q42xa, float); //! Q-vector x component, with event eta gap A (harmonic 4 and power 2) +DECLARE_SOA_COLUMN(Q42YA, q42ya, float); //! Q-vector y component, with event eta gap A (harmonic 4 and power 2) +DECLARE_SOA_COLUMN(Q23XA, q23xa, float); //! Q-vector x component, with event eta gap A (harmonic 2 and power 3) +DECLARE_SOA_COLUMN(Q23YA, q23ya, float); //! Q-vector y component, with event eta gap A (harmonic 2 and power 3) +DECLARE_SOA_COLUMN(S11A, s11a, float); //! Weighted multiplicity (p = 1, k = 1) +DECLARE_SOA_COLUMN(S12A, s12a, float); //! Weighted multiplicity (p = 1, k = 2) +DECLARE_SOA_COLUMN(S13A, s13a, float); //! Weighted multiplicity (p = 1, k = 3) +DECLARE_SOA_COLUMN(S31A, s31a, float); //! Weighted multiplicity (p = 3, k = 1) +DECLARE_SOA_COLUMN(CORR2REF, corr2ref, float); //! Ref Flow correlator <2> DECLARE_SOA_COLUMN(CORR2REFetagap, corr2refetagap, float); //! Ref Flow correlator <2> -DECLARE_SOA_COLUMN(CORR4REF, corr4ref, float); //! Ref Flow correlator <4> -DECLARE_SOA_COLUMN(M11REF, m11ref, float); //! Weighted multiplicity of <<2>> for reference flow -DECLARE_SOA_COLUMN(M1111REF, m1111ref, float); //! Weighted multiplicity of <<4>> for reference flow -DECLARE_SOA_COLUMN(M11REFetagap, m11refetagap, float); //! Weighted multiplicity of <<2>> etagap for reference flow +DECLARE_SOA_COLUMN(CORR4REF, corr4ref, float); //! Ref Flow correlator <4> +DECLARE_SOA_COLUMN(M11REF, m11ref, float); //! Weighted multiplicity of <<2>> for reference flow +DECLARE_SOA_COLUMN(M1111REF, m1111ref, float); //! Weighted multiplicity of <<4>> for reference flow +DECLARE_SOA_COLUMN(M11REFetagap, m11refetagap, float); //! Weighted multiplicity of <<2>> etagap for reference flow } // namespace reducedevent DECLARE_SOA_TABLE_STAGED(ReducedEvents, "REDUCEDEVENT", //! Main event information table @@ -125,17 +148,32 @@ DECLARE_SOA_TABLE_STAGED(ReducedEvents, "REDUCEDEVENT", //! Main event informa collision::PosX, collision::PosY, collision::PosZ, collision::NumContrib, collision::CollisionTime, collision::CollisionTimeRes); -DECLARE_SOA_TABLE(ReducedEventsExtended, "AOD", "REEXTENDED", //! Extended event information +DECLARE_SOA_TABLE(ReducedEventsExtended_000, "AOD", "REEXTENDED", //! Extended event information bc::GlobalBC, evsel::Alias, evsel::Selection, timestamp::Timestamp, cent::CentRun2V0M, mult::MultTPC, mult::MultFV0A, mult::MultFV0C, mult::MultFT0A, mult::MultFT0C, mult::MultFDDA, mult::MultFDDC, mult::MultZNA, mult::MultZNC, mult::MultTracklets, mult::MultNTracksPV, cent::CentFT0C); -DECLARE_SOA_TABLE(ReducedEventsMultPV, "AOD", "REMULTPV", //! Multiplicity information for primary vertex +DECLARE_SOA_TABLE_VERSIONED(ReducedEventsExtended_001, "AOD", "REEXTENDED", 1, //! Extended event information + bc::GlobalBC, evsel::Alias, evsel::Selection, timestamp::Timestamp, cent::CentRun2V0M, + mult::MultTPC, mult::MultFV0A, mult::MultFV0C, mult::MultFT0A, mult::MultFT0C, + mult::MultFDDA, mult::MultFDDC, mult::MultZNA, mult::MultZNC, mult::MultTracklets, mult::MultNTracksPV, + cent::CentFT0C, cent::CentFT0A, cent::CentFT0M); + +using ReducedEventsExtended = ReducedEventsExtended_001; + +DECLARE_SOA_TABLE(ReducedEventsMultPV_000, "AOD", "REMULTPV", //! Multiplicity information for primary vertex mult::MultNTracksHasITS, mult::MultNTracksHasTPC, mult::MultNTracksHasTOF, mult::MultNTracksHasTRD, mult::MultNTracksITSOnly, mult::MultNTracksTPCOnly, mult::MultNTracksITSTPC, evsel::NumTracksInTimeRange); +DECLARE_SOA_TABLE_VERSIONED(ReducedEventsMultPV_001, "AOD", "REMULTPV", 1, //! Multiplicity information for primary vertex + mult::MultNTracksHasITS, mult::MultNTracksHasTPC, mult::MultNTracksHasTOF, mult::MultNTracksHasTRD, + mult::MultNTracksITSOnly, mult::MultNTracksTPCOnly, mult::MultNTracksITSTPC, + mult::MultNTracksPVeta1, mult::MultNTracksPVetaHalf, evsel::NumTracksInTimeRange, evsel::SumAmpFT0CInTimeRange); + +using ReducedEventsMultPV = ReducedEventsMultPV_001; + DECLARE_SOA_TABLE(ReducedEventsMultAll, "AOD", "REMULTALL", //! Multiplicity information for all tracks in the event mult::MultAllTracksTPCOnly, mult::MultAllTracksITSTPC, reducedevent::NTPCoccupContribLongA, reducedevent::NTPCoccupContribLongC, @@ -380,6 +418,7 @@ DECLARE_SOA_TABLE(ReducedMCTracks, "AOD", "REDUCEDMCTRACK", //! MC track inform mcparticle::FromBackgroundEvent, mcparticle::GetGenStatusCode, mcparticle::GetProcess, + mcparticle::GetHepMCStatusCode, mcparticle::IsPhysicalPrimary); using ReducedMCTrack = ReducedMCTracks::iterator; @@ -585,42 +624,42 @@ DECLARE_SOA_COLUMN(Vt2, vt2, float); //! Production vertex time DECLARE_SOA_COLUMN(IsAmbig1, isAmbig1, int); //! DECLARE_SOA_COLUMN(IsAmbig2, isAmbig2, int); //! -DECLARE_SOA_COLUMN(FwdDcaX1, fwdDcaX1, float); //! X component of forward DCA -DECLARE_SOA_COLUMN(FwdDcaY1, fwdDcaY1, float); //! Y component of forward DCA -DECLARE_SOA_COLUMN(FwdDcaX2, fwdDcaX2, float); //! X component of forward DCA -DECLARE_SOA_COLUMN(FwdDcaY2, fwdDcaY2, float); //! Y component of forward DCA -DECLARE_SOA_COLUMN(ITSNCls1, itsNCls1, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(FwdDcaX1, fwdDcaX1, float); //! X component of forward DCA +DECLARE_SOA_COLUMN(FwdDcaY1, fwdDcaY1, float); //! Y component of forward DCA +DECLARE_SOA_COLUMN(FwdDcaX2, fwdDcaX2, float); //! X component of forward DCA +DECLARE_SOA_COLUMN(FwdDcaY2, fwdDcaY2, float); //! Y component of forward DCA +DECLARE_SOA_COLUMN(ITSNCls1, itsNCls1, int); //! Number of ITS clusters DECLARE_SOA_COLUMN(ITSClusterMap1, itsClusterMap1, uint8_t); //! ITS clusters map DECLARE_SOA_COLUMN(ITSChi2NCl1, itsChi2NCl1, float); //! ITS chi2/Ncls -DECLARE_SOA_COLUMN(TPCNClsFound1, tpcNClsFound1, float); //! Number of TPC clusters found -DECLARE_SOA_COLUMN(TPCNClsCR1, tpcNClsCR1, float); //! Number of TPC crossed rows -DECLARE_SOA_COLUMN(TPCChi2NCl1, tpcChi2NCl1, float); //! TPC chi2/Ncls -DECLARE_SOA_COLUMN(DcaXY1, dcaXY1, float); //! DCA in XY plane -DECLARE_SOA_COLUMN(DcaZ1, dcaZ1, float); //! DCA in Z -DECLARE_SOA_COLUMN(TPCSignal1, tpcSignal1, float); //! TPC dE/dx signal -DECLARE_SOA_COLUMN(TPCNSigmaEl1, tpcNSigmaEl1, float); //! TPC nSigma electron -DECLARE_SOA_COLUMN(TPCNSigmaPi1, tpcNSigmaPi1, float); //! TPC nSigma pion -DECLARE_SOA_COLUMN(TPCNSigmaPr1, tpcNSigmaPr1, float); //! TPC nSigma proton -DECLARE_SOA_COLUMN(TOFBeta1, tofBeta1, float); //! TOF beta -DECLARE_SOA_COLUMN(TOFNSigmaEl1, tofNSigmaEl1, float); //! TOF nSigma electron -DECLARE_SOA_COLUMN(TOFNSigmaPi1, tofNSigmaPi1, float); //! TOF nSigma pion -DECLARE_SOA_COLUMN(TOFNSigmaPr1, tofNSigmaPr1, float); //! TOF nSigma proton -DECLARE_SOA_COLUMN(ITSNCls2, itsNCls2, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(TPCNClsFound1, tpcNClsFound1, float); //! Number of TPC clusters found +DECLARE_SOA_COLUMN(TPCNClsCR1, tpcNClsCR1, float); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(TPCChi2NCl1, tpcChi2NCl1, float); //! TPC chi2/Ncls +DECLARE_SOA_COLUMN(DcaXY1, dcaXY1, float); //! DCA in XY plane +DECLARE_SOA_COLUMN(DcaZ1, dcaZ1, float); //! DCA in Z +DECLARE_SOA_COLUMN(TPCSignal1, tpcSignal1, float); //! TPC dE/dx signal +DECLARE_SOA_COLUMN(TPCNSigmaEl1, tpcNSigmaEl1, float); //! TPC nSigma electron +DECLARE_SOA_COLUMN(TPCNSigmaPi1, tpcNSigmaPi1, float); //! TPC nSigma pion +DECLARE_SOA_COLUMN(TPCNSigmaPr1, tpcNSigmaPr1, float); //! TPC nSigma proton +DECLARE_SOA_COLUMN(TOFBeta1, tofBeta1, float); //! TOF beta +DECLARE_SOA_COLUMN(TOFNSigmaEl1, tofNSigmaEl1, float); //! TOF nSigma electron +DECLARE_SOA_COLUMN(TOFNSigmaPi1, tofNSigmaPi1, float); //! TOF nSigma pion +DECLARE_SOA_COLUMN(TOFNSigmaPr1, tofNSigmaPr1, float); //! TOF nSigma proton +DECLARE_SOA_COLUMN(ITSNCls2, itsNCls2, int); //! Number of ITS clusters DECLARE_SOA_COLUMN(ITSClusterMap2, itsClusterMap2, uint8_t); //! ITS clusters map DECLARE_SOA_COLUMN(ITSChi2NCl2, itsChi2NCl2, float); //! ITS chi2/Ncls -DECLARE_SOA_COLUMN(TPCNClsFound2, tpcNClsFound2, float); //! Number of TPC clusters found -DECLARE_SOA_COLUMN(TPCNClsCR2, tpcNClsCR2, float); //! Number of TPC crossed rows -DECLARE_SOA_COLUMN(TPCChi2NCl2, tpcChi2NCl2, float); //! TPC chi2/Ncls -DECLARE_SOA_COLUMN(DcaXY2, dcaXY2, float); //! DCA in XY plane -DECLARE_SOA_COLUMN(DcaZ2, dcaZ2, float); //! DCA in Z -DECLARE_SOA_COLUMN(TPCSignal2, tpcSignal2, float); //! TPC dE/dx signal -DECLARE_SOA_COLUMN(TPCNSigmaEl2, tpcNSigmaEl2, float); //! TPC nSigma electron -DECLARE_SOA_COLUMN(TPCNSigmaPi2, tpcNSigmaPi2, float); //! TPC nSigma pion -DECLARE_SOA_COLUMN(TPCNSigmaPr2, tpcNSigmaPr2, float); //! TPC nSigma proton -DECLARE_SOA_COLUMN(TOFBeta2, tofBeta2, float); //! TOF beta -DECLARE_SOA_COLUMN(TOFNSigmaEl2, tofNSigmaEl2, float); //! TOF nSigma electron -DECLARE_SOA_COLUMN(TOFNSigmaPi2, tofNSigmaPi2, float); //! TOF nSigma pion -DECLARE_SOA_COLUMN(TOFNSigmaPr2, tofNSigmaPr2, float); //! TOF nSigma proton +DECLARE_SOA_COLUMN(TPCNClsFound2, tpcNClsFound2, float); //! Number of TPC clusters found +DECLARE_SOA_COLUMN(TPCNClsCR2, tpcNClsCR2, float); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(TPCChi2NCl2, tpcChi2NCl2, float); //! TPC chi2/Ncls +DECLARE_SOA_COLUMN(DcaXY2, dcaXY2, float); //! DCA in XY plane +DECLARE_SOA_COLUMN(DcaZ2, dcaZ2, float); //! DCA in Z +DECLARE_SOA_COLUMN(TPCSignal2, tpcSignal2, float); //! TPC dE/dx signal +DECLARE_SOA_COLUMN(TPCNSigmaEl2, tpcNSigmaEl2, float); //! TPC nSigma electron +DECLARE_SOA_COLUMN(TPCNSigmaPi2, tpcNSigmaPi2, float); //! TPC nSigma pion +DECLARE_SOA_COLUMN(TPCNSigmaPr2, tpcNSigmaPr2, float); //! TPC nSigma proton +DECLARE_SOA_COLUMN(TOFBeta2, tofBeta2, float); //! TOF beta +DECLARE_SOA_COLUMN(TOFNSigmaEl2, tofNSigmaEl2, float); //! TOF nSigma electron +DECLARE_SOA_COLUMN(TOFNSigmaPi2, tofNSigmaPi2, float); //! TOF nSigma pion +DECLARE_SOA_COLUMN(TOFNSigmaPr2, tofNSigmaPr2, float); //! TOF nSigma proton DECLARE_SOA_COLUMN(DCAxyzTrk0KF, dcaxyztrk0KF, float); //! 3D DCA to primary vertex of the first track DECLARE_SOA_COLUMN(DCAxyzTrk1KF, dcaxyztrk1KF, float); //! 3D DCA to primary vertex of the second track @@ -636,58 +675,58 @@ DECLARE_SOA_COLUMN(DeviationxyTrk1KF, deviationxyTrk1KF, float); //! 2D chi2 dev // pair information namespace reducedpair { -DECLARE_SOA_INDEX_COLUMN(ReducedEvent, reducedevent); //! -DECLARE_SOA_INDEX_COLUMN_FULL(Index0, index0, int, ReducedTracks, "_0"); //! Index to first prong -DECLARE_SOA_INDEX_COLUMN_FULL(Index1, index1, int, ReducedTracks, "_1"); //! Index to second prong -DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, Tracks, "_0"); //! Index of first prong in Tracks table -DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, Tracks, "_1"); //! Index of second prong in Tracks table -DECLARE_SOA_BITMAP_COLUMN(EventSelection, evSelection, 8); //! Event selection bits (ambiguity, splitting candidate) -DECLARE_SOA_COLUMN(Mass, mass, float); //! -DECLARE_SOA_COLUMN(Pt, pt, float); //! -DECLARE_SOA_COLUMN(Eta, eta, float); //! -DECLARE_SOA_COLUMN(Phi, phi, float); //! -DECLARE_SOA_COLUMN(Sign, sign, int); //! -DECLARE_SOA_BITMAP_COLUMN(FilterMap, filterMap, 32); //! -DECLARE_SOA_BITMAP_COLUMN(PairFilterMap, pairFilterMap, 32); //! -DECLARE_SOA_BITMAP_COLUMN(CommonFilterMap, commonFilterMap, 32); //! -DECLARE_SOA_COLUMN(McDecision, mcDecision, uint32_t); //! -DECLARE_SOA_COLUMN(Tauz, tauz, float); //! Longitudinal pseudo-proper time of lepton pair (in ns) -DECLARE_SOA_COLUMN(TauzErr, tauzErr, float); //! Error on longitudinal pseudo-proper time of lepton pair (in ns) -DECLARE_SOA_COLUMN(VertexPz, vertexPz, float); //! Longitudinal projection of impulsion -DECLARE_SOA_COLUMN(SVertex, sVertex, float); //! Secondary vertex of lepton pair -DECLARE_SOA_COLUMN(Tauxy, tauxy, float); //! Transverse pseudo-proper time of lepton pair (in ns) -DECLARE_SOA_COLUMN(TauxyErr, tauxyErr, float); //! Error on transverse pseudo-proper time of lepton pair (in ns) -DECLARE_SOA_COLUMN(Lz, lz, float); //! Longitudinal projection of decay length -DECLARE_SOA_COLUMN(Lxy, lxy, float); //! Transverse projection of decay length -DECLARE_SOA_COLUMN(Chi2pca, chi2pca, float); //! Chi2 for PCA of the dilepton -DECLARE_SOA_COLUMN(CosPointingAngle, cosPointingAngle, float); //! Cosine of the pointing angle -DECLARE_SOA_COLUMN(U2Q2, u2q2, float); //! Scalar product between unitary vector with event flow vector (harmonic 2) -DECLARE_SOA_COLUMN(U3Q3, u3q3, float); //! Scalar product between unitary vector with event flow vector (harmonic 3) -DECLARE_SOA_COLUMN(Cos2DeltaPhi, cos2deltaphi, float); //! Cosinus term using event plane angle (harmonic 2) -DECLARE_SOA_COLUMN(Cos3DeltaPhi, cos3deltaphi, float); //! Cosinus term using event plane angle (harmonic 3) -DECLARE_SOA_COLUMN(R2SP_AB, r2spab, float); //! Event plane resolution for SP method n=2 (A,B) TPC-FT0A -DECLARE_SOA_COLUMN(R2SP_AC, r2spac, float); //! Event plane resolution for SP method n=2 (A,C) TPC-FT0C -DECLARE_SOA_COLUMN(R2SP_BC, r2spbc, float); //! Event plane resolution for SP method n=2 (B,C) FT0A-FT0C -DECLARE_SOA_COLUMN(R3SP, r3sp, float); //! Event plane resolution for SP method n=3 -DECLARE_SOA_COLUMN(R2EP, r2ep, float); //! Event plane resolution for EP method n=2 -DECLARE_SOA_COLUMN(R2EP_AB, r2epab, float); //! Event plane resolution for EP method n=2 (A,B) TPC-FT0A -DECLARE_SOA_COLUMN(R2EP_AC, r2epac, float); //! Event plane resolution for EP method n=2 (A,C) TPC-FT0C -DECLARE_SOA_COLUMN(R2EP_BC, r2epbc, float); //! Event plane resolution for EP method n=2 (B,C) FT0A-FT0C -DECLARE_SOA_COLUMN(R3EP, r3ep, float); //! Event plane resolution for EP method n=3 -DECLARE_SOA_COLUMN(CORR2POI, corr2poi, float); //! POI FLOW CORRELATOR <2'> -DECLARE_SOA_COLUMN(CORR4POI, corr4poi, float); //! POI FLOW CORRELATOR <4'> -DECLARE_SOA_COLUMN(M01POI, m01poi, float); //! POI event weight for <2'> -DECLARE_SOA_COLUMN(M0111POI, m0111poi, float); //! POI event weight for <4'> -DECLARE_SOA_COLUMN(MultDimuons, multdimuons, int); //! Dimuon multiplicity -DECLARE_SOA_COLUMN(CentFT0C, centft0c, float); //! Centrality information from FT0C -DECLARE_SOA_COLUMN(CollisionId, collisionId, int32_t); //! -DECLARE_SOA_COLUMN(IsFirst, isfirst, int); //! Flag for the first dilepton in the collision -DECLARE_SOA_COLUMN(DCAxyzBetweenTrksKF, dcaxyzbetweentrksKF, float); //! DCAxyz between the two tracks -DECLARE_SOA_COLUMN(DCAxyBetweenTrksKF, dcaxybetweentrksKF, float); //! DCAxy between the two tracks -DECLARE_SOA_COLUMN(MassKFGeo, massKFGeo, float); //! Pair mass from KFParticle -DECLARE_SOA_COLUMN(CosPAKFGeo, cosPAKFGeo, float); //! Cosine of the pointing angle from KFParticle -DECLARE_SOA_COLUMN(Chi2OverNDFKFGeo, chi2overndfKFGeo, float); //! Chi2 over NDF from KFParticle -DECLARE_SOA_COLUMN(DecayLengthKFGeo, decaylengthKFGeo, float); //! Decay length from KFParticle +DECLARE_SOA_INDEX_COLUMN(ReducedEvent, reducedevent); //! +DECLARE_SOA_INDEX_COLUMN_FULL(Index0, index0, int, ReducedTracks, "_0"); //! Index to first prong +DECLARE_SOA_INDEX_COLUMN_FULL(Index1, index1, int, ReducedTracks, "_1"); //! Index to second prong +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, Tracks, "_0"); //! Index of first prong in Tracks table +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, Tracks, "_1"); //! Index of second prong in Tracks table +DECLARE_SOA_BITMAP_COLUMN(EventSelection, evSelection, 8); //! Event selection bits (ambiguity, splitting candidate) +DECLARE_SOA_COLUMN(Mass, mass, float); //! +DECLARE_SOA_COLUMN(Pt, pt, float); //! +DECLARE_SOA_COLUMN(Eta, eta, float); //! +DECLARE_SOA_COLUMN(Phi, phi, float); //! +DECLARE_SOA_COLUMN(Sign, sign, int); //! +DECLARE_SOA_BITMAP_COLUMN(FilterMap, filterMap, 32); //! +DECLARE_SOA_BITMAP_COLUMN(PairFilterMap, pairFilterMap, 32); //! +DECLARE_SOA_BITMAP_COLUMN(CommonFilterMap, commonFilterMap, 32); //! +DECLARE_SOA_COLUMN(McDecision, mcDecision, uint32_t); //! +DECLARE_SOA_COLUMN(Tauz, tauz, float); //! Longitudinal pseudo-proper time of lepton pair (in ns) +DECLARE_SOA_COLUMN(TauzErr, tauzErr, float); //! Error on longitudinal pseudo-proper time of lepton pair (in ns) +DECLARE_SOA_COLUMN(VertexPz, vertexPz, float); //! Longitudinal projection of impulsion +DECLARE_SOA_COLUMN(SVertex, sVertex, float); //! Secondary vertex of lepton pair +DECLARE_SOA_COLUMN(Tauxy, tauxy, float); //! Transverse pseudo-proper time of lepton pair (in ns) +DECLARE_SOA_COLUMN(TauxyErr, tauxyErr, float); //! Error on transverse pseudo-proper time of lepton pair (in ns) +DECLARE_SOA_COLUMN(Lz, lz, float); //! Longitudinal projection of decay length +DECLARE_SOA_COLUMN(Lxy, lxy, float); //! Transverse projection of decay length +DECLARE_SOA_COLUMN(Chi2pca, chi2pca, float); //! Chi2 for PCA of the dilepton +DECLARE_SOA_COLUMN(CosPointingAngle, cosPointingAngle, float); //! Cosine of the pointing angle +DECLARE_SOA_COLUMN(U2Q2, u2q2, float); //! Scalar product between unitary vector with event flow vector (harmonic 2) +DECLARE_SOA_COLUMN(U3Q3, u3q3, float); //! Scalar product between unitary vector with event flow vector (harmonic 3) +DECLARE_SOA_COLUMN(Cos2DeltaPhi, cos2deltaphi, float); //! Cosinus term using event plane angle (harmonic 2) +DECLARE_SOA_COLUMN(Cos3DeltaPhi, cos3deltaphi, float); //! Cosinus term using event plane angle (harmonic 3) +DECLARE_SOA_COLUMN(R2SP_AB, r2spab, float); //! Event plane resolution for SP method n=2 (A,B) TPC-FT0A +DECLARE_SOA_COLUMN(R2SP_AC, r2spac, float); //! Event plane resolution for SP method n=2 (A,C) TPC-FT0C +DECLARE_SOA_COLUMN(R2SP_BC, r2spbc, float); //! Event plane resolution for SP method n=2 (B,C) FT0A-FT0C +DECLARE_SOA_COLUMN(R3SP, r3sp, float); //! Event plane resolution for SP method n=3 +DECLARE_SOA_COLUMN(R2EP, r2ep, float); //! Event plane resolution for EP method n=2 +DECLARE_SOA_COLUMN(R2EP_AB, r2epab, float); //! Event plane resolution for EP method n=2 (A,B) TPC-FT0A +DECLARE_SOA_COLUMN(R2EP_AC, r2epac, float); //! Event plane resolution for EP method n=2 (A,C) TPC-FT0C +DECLARE_SOA_COLUMN(R2EP_BC, r2epbc, float); //! Event plane resolution for EP method n=2 (B,C) FT0A-FT0C +DECLARE_SOA_COLUMN(R3EP, r3ep, float); //! Event plane resolution for EP method n=3 +DECLARE_SOA_COLUMN(CORR2POI, corr2poi, float); //! POI FLOW CORRELATOR <2'> +DECLARE_SOA_COLUMN(CORR4POI, corr4poi, float); //! POI FLOW CORRELATOR <4'> +DECLARE_SOA_COLUMN(M01POI, m01poi, float); //! POI event weight for <2'> +DECLARE_SOA_COLUMN(M0111POI, m0111poi, float); //! POI event weight for <4'> +DECLARE_SOA_COLUMN(MultDimuons, multdimuons, int); //! Dimuon multiplicity +DECLARE_SOA_COLUMN(CentFT0C, centft0c, float); //! Centrality information from FT0C +DECLARE_SOA_COLUMN(CollisionId, collisionId, int32_t); //! +DECLARE_SOA_COLUMN(IsFirst, isfirst, int); //! Flag for the first dilepton in the collision +DECLARE_SOA_COLUMN(DCAxyzBetweenTrksKF, dcaxyzbetweentrksKF, float); //! DCAxyz between the two tracks +DECLARE_SOA_COLUMN(DCAxyBetweenTrksKF, dcaxybetweentrksKF, float); //! DCAxy between the two tracks +DECLARE_SOA_COLUMN(MassKFGeo, massKFGeo, float); //! Pair mass from KFParticle +DECLARE_SOA_COLUMN(CosPAKFGeo, cosPAKFGeo, float); //! Cosine of the pointing angle from KFParticle +DECLARE_SOA_COLUMN(Chi2OverNDFKFGeo, chi2overndfKFGeo, float); //! Chi2 over NDF from KFParticle +DECLARE_SOA_COLUMN(DecayLengthKFGeo, decaylengthKFGeo, float); //! Decay length from KFParticle DECLARE_SOA_COLUMN(DecayLengthOverErrKFGeo, decaylengthovererrKFGeo, float); //! Decay length over error from KFParticle DECLARE_SOA_COLUMN(DecayLengthXYKFGeo, decaylengthxyKFGeo, float); //! Decay length XY from KFParticle DECLARE_SOA_COLUMN(DecayLengthXYOverErrKFGeo, decaylengthxyovererrKFGeo, float); //! Decay length XY over error from KFParticle @@ -700,6 +739,19 @@ DECLARE_SOA_COLUMN(PairDCAxy, pairDCAxy, float); DECLARE_SOA_COLUMN(DeviationPairKF, deviationPairKF, float); //! Pair chi2 deviation to PV from KFParticle DECLARE_SOA_COLUMN(DeviationxyPairKF, deviationxyPairKF, float); //! Pair chi2 deviation to PV in XY from KFParticle // DECLARE_SOA_INDEX_COLUMN(ReducedMuon, reducedmuon2); //! +DECLARE_SOA_COLUMN(CosThetaHE, costhetaHE, float); //! Cosine in the helicity frame +DECLARE_SOA_COLUMN(PhiHE, phiHe, float); //! Phi in the helicity frame +DECLARE_SOA_COLUMN(PhiTildeHE, phiTildeHe, float); //! Tilde Phi in the helicity frame +DECLARE_SOA_COLUMN(CosThetaCS, costhetaCS, float); //! Cosine in the Collins-Soper frame +DECLARE_SOA_COLUMN(PhiCS, phiCS, float); //! Phi in the Collins-Soper frame +DECLARE_SOA_COLUMN(PhiTildeCS, phiTildeCS, float); //! Tilde Phi in the Collins-Soper frame +DECLARE_SOA_COLUMN(CosThetaPP, costhetaPP, float); //! Cosine in the Production Plane frame +DECLARE_SOA_COLUMN(PhiPP, phiPP, float); //! Phi in the Production Plane frame +DECLARE_SOA_COLUMN(PhiTildePP, phiTildePP, float); //! Tilde Phi in the Production Plane frame +DECLARE_SOA_COLUMN(CosThetaRM, costhetaRM, float); //! Cosine in the Random frame +DECLARE_SOA_COLUMN(CosThetaStarTPC, costhetaStarTPC, float); //! global polarization, event plane reconstructed from TPC tracks +DECLARE_SOA_COLUMN(CosThetaStarFT0A, costhetaStarFT0A, float); //! global polarization, event plane reconstructed from FT0A tracks +DECLARE_SOA_COLUMN(CosThetaStarFT0C, costhetaStarFT0C, float); //! global polarization, event plane reconstructed from FT0C tracks DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! [](float pt, float phi) -> float { return pt * std::cos(phi); }); DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! @@ -820,7 +872,28 @@ DECLARE_SOA_TABLE(DimuonsAll, "AOD", "RTDIMUONALL", //! reducedpair::SVertex); DECLARE_SOA_TABLE(DileptonsMiniTree, "AOD", "RTDILEPTMTREE", //! - reducedpair::Mass, reducedpair::Pt, reducedpair::Eta, reducedpair::CentFT0C, reducedpair::Cos2DeltaPhi); + reducedpair::Mass, reducedpair::Pt, reducedpair::Eta, reducedpair::CentFT0C, reducedpair::Cos2DeltaPhi, + dilepton_track_index::Pt1, dilepton_track_index::Eta1, dilepton_track_index::Phi1, + dilepton_track_index::Pt2, dilepton_track_index::Eta2, dilepton_track_index::Phi2); + +DECLARE_SOA_TABLE(DileptonsMiniTreeGen, "AOD", "RTDILMTREEGEN", //! + reducedpair::McDecision, mccollision::ImpactParameter, + dilepton_track_index::PtMC1, dilepton_track_index::EtaMC1, dilepton_track_index::PhiMC1, + dilepton_track_index::PtMC2, dilepton_track_index::EtaMC2, dilepton_track_index::PhiMC2); + +DECLARE_SOA_TABLE(DileptonsMiniTreeRec, "AOD", "RTDILMTREEREC", //! + reducedpair::McDecision, reducedpair::Mass, reducedpair::Pt, reducedpair::Eta, reducedpair::Phi, reducedpair::CentFT0C, + dilepton_track_index::PtMC1, dilepton_track_index::EtaMC1, dilepton_track_index::PhiMC1, + dilepton_track_index::PtMC2, dilepton_track_index::EtaMC2, dilepton_track_index::PhiMC2, + dilepton_track_index::Pt1, dilepton_track_index::Eta1, dilepton_track_index::Phi1, + dilepton_track_index::Pt2, dilepton_track_index::Eta2, dilepton_track_index::Phi2); + +DECLARE_SOA_TABLE(DileptonsPolarization, "AOD", "RTDILPOLAR", //! + reducedpair::CosThetaHE, reducedpair::PhiHE, reducedpair::PhiTildeHE, + reducedpair::CosThetaCS, reducedpair::PhiCS, reducedpair::PhiTildeCS, + reducedpair::CosThetaPP, reducedpair::PhiPP, reducedpair::PhiTildePP, + reducedpair::CosThetaRM, + reducedpair::CosThetaStarTPC, reducedpair::CosThetaStarFT0A, reducedpair::CosThetaStarFT0C); using Dielectron = Dielectrons::iterator; using StoredDielectron = StoredDielectrons::iterator; @@ -833,6 +906,9 @@ using DileptonInfo = DileptonsInfo::iterator; using DielectronAll = DielectronsAll::iterator; using DimuonAll = DimuonsAll::iterator; using DileptonMiniTree = DileptonsMiniTree::iterator; +using DileptonMiniTreeGen = DileptonsMiniTreeGen::iterator; +using DileptonMiniTreeRec = DileptonsMiniTreeRec::iterator; +using DileptonPolarization = DileptonsPolarization::iterator; // Tables for using analysis-dilepton-track with analysis-asymmetric-pairing DECLARE_SOA_TABLE(Ditracks, "AOD", "RTDITRACK", //! @@ -901,29 +977,65 @@ using DileptonTrackCandidate = DileptonTrackCandidates::iterator; namespace dileptonTrackTrackCandidate { // infotmation about the dilepton-track-track -DECLARE_SOA_COLUMN(Mass, mass, float); //! -DECLARE_SOA_COLUMN(Pt, pt, float); //! -DECLARE_SOA_COLUMN(Eta, eta, float); //! -DECLARE_SOA_COLUMN(Phi, phi, float); //! -DECLARE_SOA_COLUMN(Rap, rap, float); //! -DECLARE_SOA_COLUMN(DeltaQ, deltaQ, float); //! -DECLARE_SOA_COLUMN(R1, r1, float); //! distance between the dilepton and the track1 in theta-phi plane -DECLARE_SOA_COLUMN(R2, r2, float); //! distance between the dilepton and the track2 in theta-phi plane -DECLARE_SOA_COLUMN(DileptonMass, dileptonMass, float); //! -DECLARE_SOA_COLUMN(DileptonPt, dileptonPt, float); //! -DECLARE_SOA_COLUMN(DileptonEta, dileptonEta, float); //! -DECLARE_SOA_COLUMN(DileptonPhi, dileptonPhi, float); //! -DECLARE_SOA_COLUMN(DileptonSign, dileptonSign, int); //! -DECLARE_SOA_COLUMN(DiTracksMass, diTracksMass, float); //! -DECLARE_SOA_COLUMN(DiTracksPt, diTracksPt, float); //! -DECLARE_SOA_COLUMN(TrackPt1, trackPt1, float); //! -DECLARE_SOA_COLUMN(TrackPt2, trackPt2, float); //! -DECLARE_SOA_COLUMN(TrackEta1, trackEta1, float); //! -DECLARE_SOA_COLUMN(TrackEta2, trackEta2, float); //! -DECLARE_SOA_COLUMN(TrackPhi1, trackPhi1, float); //! -DECLARE_SOA_COLUMN(TrackPhi2, trackPhi2, float); //! -DECLARE_SOA_COLUMN(TrackSign1, trackSign1, int); //! -DECLARE_SOA_COLUMN(TrackSign2, trackSign2, int); //! +DECLARE_SOA_COLUMN(Mass, mass, float); //! +DECLARE_SOA_COLUMN(Pt, pt, float); //! +DECLARE_SOA_COLUMN(Eta, eta, float); //! +DECLARE_SOA_COLUMN(Phi, phi, float); //! +DECLARE_SOA_COLUMN(Rap, rap, float); //! +DECLARE_SOA_COLUMN(DeltaQ, deltaQ, float); //! +DECLARE_SOA_COLUMN(R1, r1, float); //! distance between the dilepton and the track1 in theta-phi plane +DECLARE_SOA_COLUMN(R2, r2, float); //! distance between the dilepton and the track2 in theta-phi plane +DECLARE_SOA_COLUMN(R, r, float); //! +DECLARE_SOA_COLUMN(DileptonMass, dileptonMass, float); //! +DECLARE_SOA_COLUMN(DileptonPt, dileptonPt, float); //! +DECLARE_SOA_COLUMN(DileptonEta, dileptonEta, float); //! +DECLARE_SOA_COLUMN(DileptonPhi, dileptonPhi, float); //! +DECLARE_SOA_COLUMN(DileptonSign, dileptonSign, int); //! +DECLARE_SOA_COLUMN(DileptonTPCnSigmaEl1, dileptonTPCnSigmaEl1, float); //! +DECLARE_SOA_COLUMN(DileptonTPCnSigmaPi1, dileptonTPCnSigmaPi1, float); //! +DECLARE_SOA_COLUMN(DileptonTPCnSigmaPr1, dileptonTPCnSigmaPr1, float); //! +DECLARE_SOA_COLUMN(DileptonTPCnCls1, dileptonTPCnCls1, float); //! +DECLARE_SOA_COLUMN(DileptonTPCnSigmaEl2, dileptonTPCnSigmaEl2, float); //! +DECLARE_SOA_COLUMN(DileptonTPCnSigmaPi2, dileptonTPCnSigmaPi2, float); //! +DECLARE_SOA_COLUMN(DileptonTPCnSigmaPr2, dileptonTPCnSigmaPr2, float); //! +DECLARE_SOA_COLUMN(DileptonTPCnCls2, dileptonTPCnCls2, float); //! +DECLARE_SOA_COLUMN(DiTracksMass, diTracksMass, float); //! +DECLARE_SOA_COLUMN(DiTracksPt, diTracksPt, float); //! +DECLARE_SOA_COLUMN(TrackPt1, trackPt1, float); //! +DECLARE_SOA_COLUMN(TrackPt2, trackPt2, float); //! +DECLARE_SOA_COLUMN(TrackEta1, trackEta1, float); //! +DECLARE_SOA_COLUMN(TrackEta2, trackEta2, float); //! +DECLARE_SOA_COLUMN(TrackPhi1, trackPhi1, float); //! +DECLARE_SOA_COLUMN(TrackPhi2, trackPhi2, float); //! +DECLARE_SOA_COLUMN(TrackSign1, trackSign1, int); //! +DECLARE_SOA_COLUMN(TrackSign2, trackSign2, int); //! +DECLARE_SOA_COLUMN(TrackTPCNSigmaPi1, trackTPCNSigmaPi1, float); //! +DECLARE_SOA_COLUMN(TrackTPCNSigmaPi2, trackTPCNSigmaPi2, float); //! +DECLARE_SOA_COLUMN(TrackTPCNSigmaKa1, trackTPCNSigmaKa1, float); //! +DECLARE_SOA_COLUMN(TrackTPCNSigmaKa2, trackTPCNSigmaKa2, float); //! +DECLARE_SOA_COLUMN(TrackTPCNSigmaPr1, trackTPCNSigmaPr1, float); //! +DECLARE_SOA_COLUMN(TrackTPCNSigmaPr2, trackTPCNSigmaPr2, float); //! +DECLARE_SOA_COLUMN(TrackTPCNCls1, trackTPCNCls1, float); //! +DECLARE_SOA_COLUMN(TrackTPCNCls2, trackTPCNCls2, float); //! +DECLARE_SOA_COLUMN(KFMass, kfMass, float); //! +DECLARE_SOA_COLUMN(VertexingProcCode, vertexingProcCode, float); //! +DECLARE_SOA_COLUMN(VertexingChi2PCA, vertexingChi2PCA, float); //! +DECLARE_SOA_COLUMN(CosPointingAngle, cosPointingAngle, float); //! +DECLARE_SOA_COLUMN(KFDCAxyzBetweenProngs, kfDCAxyzBetweenProngs, float); //! +DECLARE_SOA_COLUMN(KFChi2OverNDFGeo, kfChi2OverNDFGeo, float); //! +DECLARE_SOA_COLUMN(VertexingLz, vertexingLz, float); //! +DECLARE_SOA_COLUMN(VertexingLxy, vertexingLxy, float); //! +DECLARE_SOA_COLUMN(VertexingLxyz, vertexingLxyz, float); //! +DECLARE_SOA_COLUMN(VertexingTauz, vertexingTauz, float); //! +DECLARE_SOA_COLUMN(VertexingTauxy, vertexingTauxy, float); //! +DECLARE_SOA_COLUMN(VertexingLzErr, vertexingLzErr, float); //! +DECLARE_SOA_COLUMN(VertexingLxyzErr, vertexingLxyzErr, float); //! +DECLARE_SOA_COLUMN(VertexingTauzErr, vertexingTauzErr, float); //! +DECLARE_SOA_COLUMN(VertexingLzProjected, vertexingLzProjected, float); //! +DECLARE_SOA_COLUMN(VertexingLxyProjected, vertexingLxyProjected, float); //! +DECLARE_SOA_COLUMN(VertexingLxyzProjected, vertexingLxyzProjected, float); //! +DECLARE_SOA_COLUMN(VertexingTauzProjected, vertexingTauzProjected, float); //! +DECLARE_SOA_COLUMN(VertexingTauxyProjected, vertexingTauxyProjected, float); //! } // namespace dileptonTrackTrackCandidate DECLARE_SOA_TABLE(DileptonTrackTrackCandidates, "AOD", "RTDQUADPLET", //! @@ -935,11 +1047,20 @@ DECLARE_SOA_TABLE(DileptonTrackTrackCandidates, "AOD", "RTDQUADPLET", //! dileptonTrackTrackCandidate::DeltaQ, dileptonTrackTrackCandidate::R1, dileptonTrackTrackCandidate::R2, + dileptonTrackTrackCandidate::R, dileptonTrackTrackCandidate::DileptonMass, dileptonTrackTrackCandidate::DileptonPt, dileptonTrackTrackCandidate::DileptonEta, dileptonTrackTrackCandidate::DileptonPhi, dileptonTrackTrackCandidate::DileptonSign, + dileptonTrackTrackCandidate::DileptonTPCnSigmaEl1, + dileptonTrackTrackCandidate::DileptonTPCnSigmaPi1, + dileptonTrackTrackCandidate::DileptonTPCnSigmaPr1, + dileptonTrackTrackCandidate::DileptonTPCnCls1, + dileptonTrackTrackCandidate::DileptonTPCnSigmaEl2, + dileptonTrackTrackCandidate::DileptonTPCnSigmaPi2, + dileptonTrackTrackCandidate::DileptonTPCnSigmaPr2, + dileptonTrackTrackCandidate::DileptonTPCnCls2, dileptonTrackTrackCandidate::DiTracksMass, dileptonTrackTrackCandidate::DiTracksPt, dileptonTrackTrackCandidate::TrackPt1, @@ -949,7 +1070,34 @@ DECLARE_SOA_TABLE(DileptonTrackTrackCandidates, "AOD", "RTDQUADPLET", //! dileptonTrackTrackCandidate::TrackPhi1, dileptonTrackTrackCandidate::TrackPhi2, dileptonTrackTrackCandidate::TrackSign1, - dileptonTrackTrackCandidate::TrackSign2); + dileptonTrackTrackCandidate::TrackSign2, + dileptonTrackTrackCandidate::TrackTPCNSigmaPi1, + dileptonTrackTrackCandidate::TrackTPCNSigmaPi2, + dileptonTrackTrackCandidate::TrackTPCNSigmaKa1, + dileptonTrackTrackCandidate::TrackTPCNSigmaKa2, + dileptonTrackTrackCandidate::TrackTPCNSigmaPr1, + dileptonTrackTrackCandidate::TrackTPCNSigmaPr2, + dileptonTrackTrackCandidate::TrackTPCNCls1, + dileptonTrackTrackCandidate::TrackTPCNCls2, + dileptonTrackTrackCandidate::KFMass, + dileptonTrackTrackCandidate::VertexingProcCode, + dileptonTrackTrackCandidate::VertexingChi2PCA, + dileptonTrackTrackCandidate::CosPointingAngle, + dileptonTrackTrackCandidate::KFDCAxyzBetweenProngs, + dileptonTrackTrackCandidate::KFChi2OverNDFGeo, + dileptonTrackTrackCandidate::VertexingLz, + dileptonTrackTrackCandidate::VertexingLxy, + dileptonTrackTrackCandidate::VertexingLxyz, + dileptonTrackTrackCandidate::VertexingTauz, + dileptonTrackTrackCandidate::VertexingTauxy, + dileptonTrackTrackCandidate::VertexingLzErr, + dileptonTrackTrackCandidate::VertexingLxyzErr, + dileptonTrackTrackCandidate::VertexingTauzErr, + dileptonTrackTrackCandidate::VertexingLzProjected, + dileptonTrackTrackCandidate::VertexingLxyProjected, + dileptonTrackTrackCandidate::VertexingLxyzProjected, + dileptonTrackTrackCandidate::VertexingTauzProjected, + dileptonTrackTrackCandidate::VertexingTauxyProjected); using DileptonTrackTrackCandidate = DileptonTrackTrackCandidates::iterator; @@ -965,6 +1113,14 @@ DECLARE_SOA_TABLE(V0Bits, "AOD", "V0BITS", //! // iterators using V0Bit = V0Bits::iterator; +namespace v0mapID +{ +DECLARE_SOA_COLUMN(V0AddID, v0addid, int8_t); //! +} // namespace v0mapID + +DECLARE_SOA_TABLE(V0MapID, "AOD", "V0MAPID", //! + v0mapID::V0AddID); + namespace DalBits { DECLARE_SOA_COLUMN(DALITZBits, dalitzBits, uint8_t); //! diff --git a/PWGDQ/Macros/Prompt-np-Seprataion.zip b/PWGDQ/Macros/Prompt-np-Seprataion.zip new file mode 100644 index 00000000000..06471293445 Binary files /dev/null and b/PWGDQ/Macros/Prompt-np-Seprataion.zip differ diff --git a/PWGDQ/Macros/evalMchTrackingEfficiency.cxx b/PWGDQ/Macros/evalMchTrackingEfficiency.cxx new file mode 100644 index 00000000000..34610915850 --- /dev/null +++ b/PWGDQ/Macros/evalMchTrackingEfficiency.cxx @@ -0,0 +1,424 @@ +// 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. + +/// \file evalMchTrackingEfficiency.cxx +/// \brief Macro to evaluate the MCH tracking efficiency using the results from taskMuonTrkEfficiency.cxx +/// +/// \author Zaida Conesa del Valle +/// \author Andrea Tavira García +#include + +#include "TFile.h" +#include "TDirectoryFile.h" +#include "THn.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TAxis.h" +#include "TCanvas.h" +#include "TStyle.h" +#include "TLegend.h" + +double computeEfficiencyPerChamber(THnF* hnf, int iAxis, int iCh, double binLimits[2]); +double computeEfficiencyPerChamber(THnF* hnf, const int iAxis[3], int iCh, double binLimits[3][2]); +double computeStationEfficiency(double effPerChamber[4], int iStation); +double computeTotalEfficiency(double effPerStation[5]); + +void getBinLimits(THnF* hnf, int nBins, int iAxis, std::vector& limits); +void setHistoMinPt(THnF* hnf, int iAxis, float minPt); +void setStyleCanvas(TCanvas* c); +void setHistoStylePerChamber(TH1F* h, int iCh); + +// +// Main function to evaluate the muon tracking efficiency +// +void evalMchTrackingEfficiency(const char* inFile = "AnalysisResults.root", const char* outFileName = "evalMchTrkEff.root", const char* suffix = "", const float minPt = 0.5) +{ + // read ouput from the taskComputeMchEfficiency + TFile* file = TFile::Open(inFile, "read"); + TDirectoryFile* dir = reinterpret_cast(file->Get("task-muon-mch-trk-efficiency")); + THnF* hHitsEtaPtPhi = reinterpret_cast(dir->Get("hHitsEtaPtPhi")); + + // retrieve the eta/pt/phi axis binning configuration + const int etaAx = 1, ptAx = 2, phiAx = 3; + const int listAx[3] = {etaAx, ptAx, phiAx}; + + int nBinsEta = hHitsEtaPtPhi->GetAxis(etaAx)->GetNbins(); + int nBinsPt = hHitsEtaPtPhi->GetAxis(ptAx)->GetNbins(); + int nBinsPhi = hHitsEtaPtPhi->GetAxis(phiAx)->GetNbins(); + + std::vector limitsEta, limitsPt, limitsPhi; + + getBinLimits(hHitsEtaPtPhi, nBinsEta, etaAx, limitsEta); // these are values! + getBinLimits(hHitsEtaPtPhi, nBinsPt, ptAx, limitsPt); // these are values! + getBinLimits(hHitsEtaPtPhi, nBinsPhi, phiAx, limitsPhi); // these are values! + + int nBinMinPt = hHitsEtaPtPhi->GetAxis(ptAx)->FindBin(minPt); + + // Define the output file + TFile* outFile = new TFile(outFileName, "recreate"); + + // define histograms efficiency per chamber + // vs eta, pt, phi + int const kChamber = 10, kStation = 5; + TH1F *hEffPerChamberEta[kChamber], *hEffPerChamberPt[kChamber], *hEffPerChamberPhi[kChamber]; + + for (int iCh = 0; iCh < kChamber; iCh++) { + hEffPerChamberEta[iCh] = new TH1F(Form("hEffPerChamberEta_%d", iCh), Form("hEff Chamber %d vs. #eta; #eta ; Efficiency", iCh), nBinsEta, limitsEta.data()); + hEffPerChamberPt[iCh] = new TH1F(Form("hEffPerChamberPt_%d", iCh), Form("hEff Chamber %d vs. #it{p}_{T}; #it{p}_{T} (GeV/#it{c}) ; Efficiency", iCh), nBinsPt, limitsPt.data()); + hEffPerChamberPhi[iCh] = new TH1F(Form("hEffPerChamberPhi_%d", iCh), Form("hEff Chamber %d vs. #varphi; #varphi (rad.) ; Efficiency", iCh), nBinsPhi, limitsPhi.data()); + } + + // define histogram for integrated efficiency per chamber + // as well as the one per station + // the total integrated value is stored in both histos as last quantity for reference + TH1F* hEffIntegratedChamber = new TH1F("hEffIntegratedChamber", "integrated efficiency per chamber; ;Efficiency", kChamber + 1, -0.5, kChamber + 0.5); + const char* hChNames[kChamber + 1]; + for (int i = 0; i < kChamber; i++) { + hEffIntegratedChamber->GetXaxis()->SetBinLabel(i + 1, Form("Chamber %d", i)); + } + hEffIntegratedChamber->GetXaxis()->SetBinLabel(kChamber + 1, "Total"); + + // Define histogram for integrated efficiency per station + TH1F* hEffIntegratedStation = new TH1F("hEffIntegratedStation", "integrated efficiency per station; ;Efficiency", kStation, -0.5, kStation + 0.5); + const char* hStNames[kStation]; + for (int i = 0; i < 3; i++) { + hEffIntegratedStation->GetXaxis()->SetBinLabel(i + 1, Form("Station %d", i)); + } + hEffIntegratedStation->GetXaxis()->SetBinLabel(4, "Station 3 & 4"); + hEffIntegratedStation->GetXaxis()->SetBinLabel(kStation, "Total"); + + // define also the eta-phi efficiency per chamber + TH2F* hEffPerChamberEtaPhi[kChamber]; + for (int iCh = 0; iCh < kChamber; iCh++) { + hEffPerChamberEtaPhi[iCh] = new TH2F(Form("hEffPerChamberEtaPhi_%d", iCh), Form("hEff Chamber %d vs. #eta vs. #varphi; #eta ; #varphi ; Efficiency", iCh), nBinsEta, limitsEta.data(), nBinsPhi, limitsPhi.data()); + } + + double effIntChamber[kChamber]; + double effIntStation[kStation]; + double effIntegrated = 0.; + + // Calculation of the efficiency per chamber for each variable + for (int iCh = 0; iCh < 10; iCh++) { + double binLimits[2] = {0., 0.}; + + // Calculation vs. eta + // check min pt interval + setHistoMinPt(hHitsEtaPtPhi, ptAx, minPt); + for (int ikBin = 1; ikBin <= nBinsEta; ikBin++) { + binLimits[0] = limitsEta[ikBin - 1]; // these are NOT bins + binLimits[1] = limitsEta[ikBin]; // these are NOT bins + double eff = computeEfficiencyPerChamber(hHitsEtaPtPhi, etaAx, iCh, binLimits); + int hBin = hEffPerChamberEta[iCh]->FindBin(binLimits[0] + (binLimits[1] - binLimits[0]) / 2.); + hEffPerChamberEta[iCh]->SetBinContent(hBin, eff); + } + // Calculation vs pt + for (int ikBin = 1; ikBin <= nBinsPt; ikBin++) { + binLimits[0] = limitsPt[ikBin - 1]; + binLimits[1] = limitsPt[ikBin]; + double eff = computeEfficiencyPerChamber(hHitsEtaPtPhi, ptAx, iCh, binLimits); + int hBin = hEffPerChamberPt[iCh]->FindBin(binLimits[0] + (binLimits[1] - binLimits[0]) / 2.); + hEffPerChamberPt[iCh]->SetBinContent(hBin, eff); + } + // Calculation vs phi + // check min pt interval + setHistoMinPt(hHitsEtaPtPhi, ptAx, minPt); + for (int ikBin = 1; ikBin <= nBinsPhi; ikBin++) { + binLimits[0] = limitsPhi[ikBin - 1]; + binLimits[1] = limitsPhi[ikBin]; + double eff = computeEfficiencyPerChamber(hHitsEtaPtPhi, phiAx, iCh, binLimits); + int hBin = hEffPerChamberPhi[iCh]->FindBin(binLimits[0] + (binLimits[1] - binLimits[0]) / 2.); + hEffPerChamberPhi[iCh]->SetBinContent(hBin, eff); + } + // Calculation of the integrated quantity per chamber + binLimits[0] = limitsEta[0]; + binLimits[1] = limitsEta[nBinsEta]; + effIntChamber[iCh] = computeEfficiencyPerChamber(hHitsEtaPtPhi, etaAx, iCh, binLimits); + hEffIntegratedChamber->SetBinContent(iCh + 1, effIntChamber[iCh]); + + } // end calculation efficiency per chamber + + // Do integrated calculation per station + double tmp[4] = {effIntChamber[0], effIntChamber[1], 0., 0.}; + effIntStation[0] = computeStationEfficiency(tmp, 0); // Station 1 + tmp[0] = effIntChamber[2]; + tmp[1] = effIntChamber[3]; + effIntStation[1] = computeStationEfficiency(tmp, 1); // Station 2 + tmp[0] = effIntChamber[4]; + tmp[1] = effIntChamber[5]; + effIntStation[2] = computeStationEfficiency(tmp, 2); // Station 3 + tmp[0] = effIntChamber[6]; + tmp[1] = effIntChamber[7]; + tmp[2] = effIntChamber[8]; + tmp[3] = effIntChamber[9]; + effIntStation[3] = computeStationEfficiency(tmp, 3); // Station 4 & 5 + + for (int i = 1; i <= 4; i++) { + hEffIntegratedStation->SetBinContent(i, effIntStation[i - 1]); + } + + // Do integrated total calculation + effIntegrated = computeTotalEfficiency(effIntStation); + hEffIntegratedStation->SetBinContent(kStation, effIntegrated); + hEffIntegratedChamber->SetBinContent(kChamber + 1, effIntegrated); + + // Calculation of the 2D eta-phi efficiency per chamber + for (int iCh = 0; iCh < 10; iCh++) { + double binLimits[3][2] = {{0., 0.}, {0., 0.}, {0., 0.}}; + binLimits[ptAx - 1][0] = minPt; // these are values!! + binLimits[ptAx - 1][1] = hHitsEtaPtPhi->GetAxis(ptAx)->GetBinUpEdge(nBinsPt); // these are values!! + // Loop over eta + for (int ikBin = 1; ikBin <= nBinsEta; ikBin++) { + binLimits[etaAx - 1][0] = limitsEta[ikBin - 1]; + binLimits[etaAx - 1][1] = limitsEta[ikBin]; + + // Loop over phi + for (int isbin = 1; isbin <= nBinsPhi; isbin++) { + binLimits[phiAx - 1][0] = limitsPhi[isbin - 1]; + binLimits[phiAx - 1][1] = limitsPhi[isbin]; + double eff = computeEfficiencyPerChamber(hHitsEtaPtPhi, listAx, iCh, binLimits); + int xBin = hEffPerChamberEtaPhi[iCh]->GetXaxis()->FindBin(binLimits[etaAx - 1][0] + (binLimits[etaAx - 1][1] - binLimits[etaAx - 1][0]) / 2.); + int yBin = hEffPerChamberEtaPhi[iCh]->GetYaxis()->FindBin(binLimits[phiAx - 1][0] + (binLimits[phiAx - 1][1] - binLimits[phiAx - 1][0]) / 2.); + hEffPerChamberEtaPhi[iCh]->SetBinContent(xBin, yBin, eff); + } + } + } + + // Drawing output values + double yPlotLimits[2] = {0, 1.1}; + gStyle->SetOptStat(0); + TLegend* legEffChamber = new TLegend(0.6, 0.2, 0.8, 0.7); + + TCanvas* cEffChEta = new TCanvas(Form("cEffChEta%s", suffix), Form("MCH tracking efficiency per chamber vs. eta %s", suffix)); + setStyleCanvas(cEffChEta); + hEffPerChamberEta[0]->GetYaxis()->SetRangeUser(yPlotLimits[0], yPlotLimits[1]); + hEffPerChamberEta[0]->Draw(); + + for (int iCh = 0; iCh < 10; iCh++) { + setHistoStylePerChamber(hEffPerChamberEta[iCh], iCh); + hEffPerChamberEta[iCh]->Draw("hsame"); + legEffChamber->AddEntry(hEffPerChamberEta[iCh], Form("Chamber %d", iCh), "l"); + } + legEffChamber->Draw(); + + TCanvas* cEffChPt = new TCanvas(Form("cEffChPt%s", suffix), Form("MCH tracking efficiency per chamber vs. pT %s", suffix)); + setStyleCanvas(cEffChPt); + hEffPerChamberPt[0]->GetYaxis()->SetRangeUser(yPlotLimits[0], yPlotLimits[1]); + hEffPerChamberPt[0]->Draw(); + for (int iCh = 0; iCh < 10; iCh++) { + setHistoStylePerChamber(hEffPerChamberPt[iCh], iCh); + hEffPerChamberPt[iCh]->Draw("hsame"); + } + legEffChamber->Draw(); + + TCanvas* cEffChPhi = new TCanvas(Form("cEffChPhi%s", suffix), Form("MCH tracking efficiency per chamber vs. phi %s", suffix)); + setStyleCanvas(cEffChPhi); + hEffPerChamberPhi[0]->GetYaxis()->SetRangeUser(yPlotLimits[0], yPlotLimits[1]); + hEffPerChamberPhi[0]->Draw(); + for (int iCh = 0; iCh < 10; iCh++) { + setHistoStylePerChamber(hEffPerChamberPhi[iCh], iCh); + hEffPerChamberPhi[iCh]->Draw("hsame"); + } + legEffChamber->Draw(); + + TCanvas* cEffIntegrated = new TCanvas(Form("cEffIntegrated%s", suffix), Form("MCH tracking integrated efficiency %s", suffix)); + setStyleCanvas(cEffIntegrated); + setHistoStylePerChamber(hEffIntegratedChamber, 10); + setHistoStylePerChamber(hEffIntegratedStation, 10); + cEffIntegrated->Divide(1, 2); + cEffIntegrated->cd(1); + hEffIntegratedChamber->GetYaxis()->SetRangeUser(yPlotLimits[0], yPlotLimits[1]); + hEffIntegratedChamber->SetMarkerSize(1.8); + hEffIntegratedChamber->Draw("h,text"); + cEffIntegrated->cd(2); + hEffIntegratedStation->SetMarkerSize(1.8); + hEffIntegratedStation->Draw("h,text"); + + TCanvas* cEffEtaPhi = new TCanvas(Form("cEffEtaPhi%s", suffix), Form("MCH tracking eta-phi efficiency %s", suffix)); + cEffEtaPhi->Divide(2, 5); + for (int iCh = 0; iCh < 10; iCh++) { + cEffEtaPhi->cd(iCh + 1); + hEffPerChamberEtaPhi[iCh]->Draw("colz"); + } + + outFile->Write(); + file->Close(); +} + +// Function to retrieve the axis limits from the THn +void getBinLimits(THnF* hnf, int nBins, int iAxis, std::vector& limits) +{ + TAxis* ax = hnf->GetAxis(iAxis); + for (int i = 1; i <= nBins; i++) { + limits.push_back(ax->GetBinLowEdge(i)); + } + limits.push_back(ax->GetBinUpEdge(nBins)); + return; +} + +// Evaluate the efficiency per Chamber +// Eff(i) = N(i+j) / ( N(i+j) + N(0+j) ) +double computeEfficiencyPerChamber(THnF* hnf, int iAxis, int iCh, double binLimits[2]) +{ + // Set range of study + hnf->GetAxis(iAxis)->SetRangeUser(binLimits[0], binLimits[1]); + + // Project onto the Nhits axis + TH1F* htmp = reinterpret_cast(hnf->Projection(0)); + double NhitPairing[16]; + for (int i = 0; i < 16; i++) { + NhitPairing[i] = 0; + NhitPairing[i] = htmp->GetBinContent(i + 1); + } + double eff = 0.; + if (iCh == 0 && (NhitPairing[0] + NhitPairing[2]) > 0.) { // Chamber 0 : St 1 + eff = NhitPairing[0] / (NhitPairing[0] + NhitPairing[2]); + } else if (iCh == 1 && NhitPairing[0] > 0.) { // Chamber 1 : St 1 + eff = NhitPairing[0] / (NhitPairing[0] + NhitPairing[1]); + } else if (iCh == 2 && NhitPairing[3] > 0.) { // Chamber 2 : St 2 + eff = NhitPairing[3] / (NhitPairing[3] + NhitPairing[5]); + } else if (iCh == 3 && NhitPairing[3] > 0.) { // Chamber 3 : St 2 + eff = NhitPairing[3] / (NhitPairing[3] + NhitPairing[4]); + } else if (iCh == 4 && NhitPairing[6] > 0.) { // Chamber 4 : St 3 + eff = NhitPairing[6] / (NhitPairing[6] + NhitPairing[8]); + } else if (iCh == 5 && NhitPairing[6] > 0.) { // Chamber 5 : St 3 + eff = NhitPairing[6] / (NhitPairing[6] + NhitPairing[7]); + } else if (iCh == 6 && NhitPairing[9] > 0.) { // Chamber 6 : St 4 + eff = NhitPairing[9] / (NhitPairing[9] + NhitPairing[11]); + } else if (iCh == 7 && NhitPairing[9] > 0.) { // Chamber 7 : St 4 + eff = NhitPairing[9] / (NhitPairing[9] + NhitPairing[10]); + } else if (iCh == 8 && NhitPairing[12] > 0.) { // Chamber 8 : St 5 + eff = NhitPairing[12] / (NhitPairing[12] + NhitPairing[14]); + } else if (iCh == 9 && NhitPairing[12] > 0.) { // Chamber 9 : St 5 + eff = NhitPairing[12] / (NhitPairing[12] + NhitPairing[13]); + } + + delete htmp; + + // reset to full range + int nBins = hnf->GetAxis(iAxis)->GetNbins(); + hnf->GetAxis(iAxis)->SetRange(1, nBins); + + return eff; +} + +// Evaluate the efficiency per Chamber +// Eff(i) = N(i+j) / ( N(i+j) + N(0+j) ) +double computeEfficiencyPerChamber(THnF* hnf, const int iAxis[3], int iCh, double binLimits[3][2]) +{ + // Set range of study + for (int i = 0; i < 3; i++) { + hnf->GetAxis(iAxis[i])->SetRangeUser(binLimits[i][0], binLimits[i][1]); + } + + // Project onto the Nhits axis + TH1F* htmp = reinterpret_cast(hnf->Projection(0)); + double NhitPairing[16]; + for (int i = 0; i < 16; i++) { + NhitPairing[i] = 0; + NhitPairing[i] = htmp->GetBinContent(i + 1); + } + double eff = 0.; + if (iCh == 0 && (NhitPairing[0] + NhitPairing[2]) > 0.) { // Chamber 0 : St 1 + eff = NhitPairing[0] / (NhitPairing[0] + NhitPairing[2]); + } else if (iCh == 1 && NhitPairing[0] > 0.) { // Chamber 1 : St 1 + eff = NhitPairing[0] / (NhitPairing[0] + NhitPairing[1]); + } else if (iCh == 2 && NhitPairing[3] > 0.) { // Chamber 2 : St 2 + eff = NhitPairing[3] / (NhitPairing[3] + NhitPairing[5]); + } else if (iCh == 3 && NhitPairing[3] > 0.) { // Chamber 3 : St 2 + eff = NhitPairing[3] / (NhitPairing[3] + NhitPairing[4]); + } else if (iCh == 4 && NhitPairing[6] > 0.) { // Chamber 4 : St 3 + eff = NhitPairing[6] / (NhitPairing[6] + NhitPairing[8]); + } else if (iCh == 5 && NhitPairing[6] > 0.) { // Chamber 5 : St 3 + eff = NhitPairing[6] / (NhitPairing[6] + NhitPairing[7]); + } else if (iCh == 6 && NhitPairing[9] > 0.) { // Chamber 6 : St 4 + eff = NhitPairing[9] / (NhitPairing[9] + NhitPairing[11]); + } else if (iCh == 7 && NhitPairing[9] > 0.) { // Chamber 7 : St 4 + eff = NhitPairing[9] / (NhitPairing[9] + NhitPairing[10]); + } else if (iCh == 8 && NhitPairing[12] > 0.) { // Chamber 8 : St 5 + eff = NhitPairing[12] / (NhitPairing[12] + NhitPairing[14]); + } else if (iCh == 9 && NhitPairing[12] > 0.) { // Chamber 9 : St 5 + eff = NhitPairing[12] / (NhitPairing[12] + NhitPairing[13]); + } + + delete htmp; + + // reset to full range + for (int i = 0; i < 3; i++) { + int nBins = hnf->GetAxis(iAxis[i])->GetNbins(); + hnf->GetAxis(iAxis[i])->SetRange(1, nBins); + } + + return eff; +} + +// Compute the efficiency per station +// Stations 1, 2, 3: Eff = 1 - ( 1 - E(i) ) * ( 1 - (E(j) ) +// Stations 4 & 5 together: Eff = product(i=6...9) E(i) + sum(i=6...9) [ ( 1 - E(i) )* product(j=6...9, i!=i) E(j) ] +double computeStationEfficiency(double effPerChamber[4], int iStation) +{ + double effSt = 0.; + if (iStation < 3) { // Calculation for Station 1, 2, 3 + effSt = 1. - (1. - effPerChamber[0]) * (1. - effPerChamber[1]); + } else { // Calculation for Station 4 & 5 + double product = 1., sum = 0.; + for (int i = 0; i < 4; i++) { + product *= effPerChamber[i]; + } + for (int i = 0; i < 4; i++) { + double tmpProduct = 1.; + for (int j = 0; j < 4; j++) { + if (i != j) { + tmpProduct *= effPerChamber[j]; + } + } + sum += (1. - effPerChamber[i]) * tmpProduct; + } + effSt = product + sum; + } + return effSt; +} + +// Total efficiency corresponds to the product of the efficiency per station +double computeTotalEfficiency(double effPerStation[5]) +{ + double effTot = 1.; + for (int i = 0; i < 4; i++) { + effTot *= effPerStation[i]; + } + return effTot; +} + +// Set style for histos +void setHistoStylePerChamber(TH1F* h, int iCh) +{ + int iColor[11] = {kRed, kMagenta, kBlue, kAzure + 10, kGreen, kGreen + 3, kOrange + 7, kOrange + 4, kGray + 1, kGray + 3, kBlack}; + h->SetLineColor(iColor[iCh]); + h->SetMarkerColor(iColor[iCh]); +} +// Set style for canvas +void setStyleCanvas(TCanvas* c) +{ + c->SetTickx(); + c->SetTicky(); +} + +void setHistoMinPt(THnF* hnf, int iAxis, float minPt) +{ + // Get the axis and its number of bins + TAxis* axis = hnf->GetAxis(iAxis); + int nBinsPt = axis->GetNbins(); + + // Find the bin corresponding to minPt + int nBinMinPt = axis->FindBin(minPt); // FindBin already gives the correct bin index + + // Set range using bin indices + axis->SetRange(nBinMinPt, nBinsPt); +} diff --git a/PWGDQ/TableProducer/tableMaker.cxx b/PWGDQ/TableProducer/tableMaker.cxx index 48961a3ae0e..87d1183d385 100644 --- a/PWGDQ/TableProducer/tableMaker.cxx +++ b/PWGDQ/TableProducer/tableMaker.cxx @@ -37,6 +37,7 @@ #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/MftmchMatchingML.h" +#include "Common/DataModel/FwdTrackReAlignTables.h" #include "PWGDQ/DataModel/ReducedInfoTables.h" #include "PWGDQ/Core/VarManager.h" #include "PWGDQ/Core/HistogramManager.h" @@ -112,12 +113,13 @@ using MyEvents = soa::Join; using MyEventsWithMults = soa::Join; using MyEventsWithFilter = soa::Join; using MyEventsWithMultsAndFilter = soa::Join; -using MyEventsWithCent = soa::Join; -using MyEventsWithCentAndMults = soa::Join; +using MyEventsWithCent = soa::Join; +using MyEventsWithCentAndMults = soa::Join; using MyMuons = soa::Join; using MyMuonsWithCov = soa::Join; using MyMuonsColl = soa::Join; using MyMuonsCollWithCov = soa::Join; +using MyMuonsRealignCollWithCov = soa::Join; using ExtBCs = soa::Join; constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision; @@ -137,6 +139,7 @@ constexpr static uint32_t gkTrackFillMapForElectronMuon = VarManager::ObjTypes:: constexpr static uint32_t gkMuonFillMap = VarManager::ObjTypes::Muon; constexpr static uint32_t gkMuonFillMapWithCov = VarManager::ObjTypes::Muon | VarManager::ObjTypes::MuonCov; constexpr static uint32_t gkMuonFillMapWithCovAmbi = VarManager::ObjTypes::Muon | VarManager::ObjTypes::MuonCov | VarManager::ObjTypes::AmbiMuon; +constexpr static uint32_t gkMuonRealignFillMapWithCovAmbi = VarManager::ObjTypes::MuonRealign | VarManager::ObjTypes::MuonCovRealign | VarManager::ObjTypes::AmbiMuon; constexpr static uint32_t gkTrackFillMapWithAmbi = VarManager::ObjTypes::Track | VarManager::ObjTypes::AmbiTrack; constexpr static uint32_t gkMFTFillMap = VarManager::ObjTypes::TrackMFT; @@ -164,9 +167,11 @@ struct TableMaker { OutputObj fStatsList{"Statistics"}; //! skimming statistics HistogramManager* fHistMan; - Configurable fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"}; - Configurable fConfigTrackCuts{"cfgBarrelTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; - Configurable fConfigMuonCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; + struct : ConfigurableGroup { + Configurable fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"}; + Configurable fConfigTrackCuts{"cfgBarrelTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; + Configurable fConfigMuonCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; + } configCuts; struct : ConfigurableGroup { Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; Configurable fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"}; @@ -175,17 +180,20 @@ struct TableMaker { Configurable fConfigBarrelTrackPtLow{"cfgBarrelLowPt", 1.0f, "Low pt cut for tracks in the barrel"}; Configurable fConfigBarrelTrackMaxAbsEta{"cfgBarrelMaxAbsEta", 0.9f, "Eta absolute value cut for tracks in the barrel"}; Configurable fConfigMuonPtLow{"cfgMuonLowPt", 1.0f, "Low pt cut for muons"}; - Configurable fConfigMinTpcSignal{"cfgMinTpcSignal", 30.0, "Minimum TPC signal"}; - Configurable fConfigMaxTpcSignal{"cfgMaxTpcSignal", 300.0, "Maximum TPC signal"}; + struct : ConfigurableGroup { + Configurable fConfigMinTpcSignal{"cfgMinTpcSignal", 30.0, "Minimum TPC signal"}; + Configurable fConfigMaxTpcSignal{"cfgMaxTpcSignal", 300.0, "Maximum TPC signal"}; + } configTpcSignal; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; Configurable fConfigDetailedQA{"cfgDetailedQA", false, "If true, include more QA histograms (BeforeCuts classes)"}; Configurable fIsRun2{"cfgIsRun2", false, "Whether we analyze Run-2 or Run-3 data"}; Configurable fIsAmbiguous{"cfgIsAmbiguous", false, "Whether we enable QA plots for ambiguous tracks"}; struct : ConfigurableGroup { - Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; + Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro"}; Configurable fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"}; Configurable fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"}; + Configurable fBcTolerance{"cfgBcTolerance", 100, "Number of BCs of margin for software triggers"}; } useZorro; struct : ConfigurableGroup { @@ -198,8 +206,6 @@ struct TableMaker { Configurable fConfigComputeTPCpostCalib{"cfgTPCpostCalib", false, "If true, compute TPC post-calibrated n-sigmas(electrons, pions, protons)"}; Configurable fConfigComputeTPCpostCalibKaon{"cfgTPCpostCalibKaon", false, "If true, compute TPC post-calibrated n-sigmas for kaons"}; Configurable fConfigIsOnlyforMaps{"cfgIsforMaps", false, "If true, run for postcalibration maps only"}; - Configurable fConfigDummyRunlist{"cfgDummyRunlist", false, "If true, use dummy runlist"}; - Configurable fConfigInitRunNumber{"cfgInitRunNumber", 543215, "Initial run number used in run by run checks"}; Configurable fPropMuon{"cfgPropMuon", false, "Propgate muon tracks through absorber"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; @@ -223,12 +229,11 @@ struct TableMaker { Preslice perCollisionMuons = aod::fwdtrack::collisionId; Preslice trackIndicesPerCollision = aod::track_association::collisionId; Preslice fwdtrackIndicesPerCollision = aod::track_association::collisionId; - bool fDoDetailedQA = false; // Bool to set detailed QA true, if QA is set true int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. // TODO: filter on TPC dedx used temporarily until electron PID will be improved - Filter barrelSelectedTracks = ifnode(fIsRun2.node() == true, aod::track::trackType == uint8_t(aod::track::Run2Track), aod::track::trackType == uint8_t(aod::track::Track)) && o2::aod::track::pt >= fConfigBarrelTrackPtLow && nabs(o2::aod::track::eta) <= fConfigBarrelTrackMaxAbsEta && o2::aod::track::tpcSignal >= fConfigMinTpcSignal && o2::aod::track::tpcSignal <= fConfigMaxTpcSignal && o2::aod::track::tpcChi2NCl < 4.0f && o2::aod::track::itsChi2NCl < 36.0f; + Filter barrelSelectedTracks = ifnode(fIsRun2.node() == true, aod::track::trackType == uint8_t(aod::track::Run2Track), aod::track::trackType == uint8_t(aod::track::Track)) && o2::aod::track::pt >= fConfigBarrelTrackPtLow && nabs(o2::aod::track::eta) <= fConfigBarrelTrackMaxAbsEta && o2::aod::track::tpcSignal >= configTpcSignal.fConfigMinTpcSignal && o2::aod::track::tpcSignal <= configTpcSignal.fConfigMaxTpcSignal && o2::aod::track::tpcChi2NCl < 4.0f && o2::aod::track::itsChi2NCl < 36.0f; Filter muonFilter = o2::aod::fwdtrack::pt >= fConfigMuonPtLow; @@ -279,9 +284,9 @@ struct TableMaker { context.mOptions.get("processBarrelWithV0AndDalitzEvent") || context.mOptions.get("processBarrelOnlyWithV0BitsAndMults"); bool enableMuonHistos = (context.mOptions.get("processFull") || context.mOptions.get("processFullWithCov") || context.mOptions.get("processFullWithCent") || context.mOptions.get("processFullWithCovAndEventFilter") || - context.mOptions.get("processFullWithCovMultsAndEventFilter") || context.mOptions.get("processMuonOnlyWithCovAndCent") || + context.mOptions.get("processFullWithCovMultsAndEventFilter") || context.mOptions.get("processMuonOnlyWithCovAndCentMults") || context.mOptions.get("processMuonOnlyWithCov") || context.mOptions.get("processMuonOnlyWithCovAndEventFilter") || context.mOptions.get("processAmbiguousMuonOnlyWithCov") || - context.mOptions.get("processMuonsAndMFT") || context.mOptions.get("processMuonsAndMFTWithFilter") || context.mOptions.get("processMuonMLOnly")); + context.mOptions.get("processMuonsAndMFT") || context.mOptions.get("processMuonsAndMFTWithFilter") || context.mOptions.get("processMuonMLOnly") || context.mOptions.get("processAssociatedMuonOnlyWithCov") || context.mOptions.get("processAssociatedRealignedMuonOnlyWithCov")); if (enableBarrelHistos) { if (fDoDetailedQA) { @@ -325,10 +330,6 @@ struct TableMaker { } } - if (fConfigDummyRunlist) { - VarManager::SetDummyRunlist(fConfigInitRunNumber); - } - DefineHistograms(histClasses); // define all histograms VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); @@ -346,11 +347,11 @@ struct TableMaker { { // Event cuts fEventCut = new AnalysisCompositeCut(true); - TString eventCutStr = fConfigEventCuts.value; + TString eventCutStr = configCuts.fConfigEventCuts.value; fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); // Barrel track cuts - TString cutNamesStr = fConfigTrackCuts.value; + TString cutNamesStr = configCuts.fConfigTrackCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { @@ -359,7 +360,7 @@ struct TableMaker { } // Muon cuts - cutNamesStr = fConfigMuonCuts.value; + cutNamesStr = configCuts.fConfigMuonCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { @@ -432,7 +433,6 @@ struct TableMaker { VarManager::fgValues[VarManager::kRunNo] = bc.runNumber(); VarManager::fgValues[VarManager::kBC] = bc.globalBC(); VarManager::fgValues[VarManager::kTimestamp] = bc.timestamp(); - VarManager::fgValues[VarManager::kRunIndex] = VarManager::GetRunIndex(bc.runNumber()); VarManager::FillEvent(collision); // extract event information and place it in the fValues array if (fDoDetailedQA) { fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues); @@ -449,9 +449,10 @@ struct TableMaker { if (useZorro.fConfigRunZorro) { zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value); + zorro.setBCtolerance(useZorro.fBcTolerance); zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value); zorro.populateExternalHists(fCurrentRun, reinterpret_cast(fStatsList->At(3)), reinterpret_cast(fStatsList->At(4))); - bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast(fStatsList->At(4))); + bool zorroSel = zorro.isSelected(bc.globalBC(), useZorro.fBcTolerance, reinterpret_cast(fStatsList->At(4))); if (zorroSel) { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } @@ -480,23 +481,24 @@ struct TableMaker { eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), - collision.centFT0C()); + collision.centFT0C(), collision.centFT0A(), collision.centFT0M()); } else if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMult) > 0) { eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), - -1); + -1, -1, -1); } else if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionCent) > 0) { eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, collision.centFT0C()); + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, collision.centFT0C(), collision.centFT0A(), collision.centFT0M()); } else { - eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); + eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); } eventVtxCov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); eventInfo(collision.globalIndex()); if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMultExtra) > 0) { multPV(collision.multNTracksHasITS(), collision.multNTracksHasTPC(), collision.multNTracksHasTOF(), collision.multNTracksHasTRD(), - collision.multNTracksITSOnly(), collision.multNTracksTPCOnly(), collision.multNTracksITSTPC(), collision.trackOccupancyInTimeRange()); + collision.multNTracksITSOnly(), collision.multNTracksTPCOnly(), collision.multNTracksITSTPC(), + collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); multAll(collision.multAllTracksTPCOnly(), collision.multAllTracksITSTPC(), 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0.0, 0.0, 0.0, 0.0); } @@ -904,7 +906,6 @@ struct TableMaker { VarManager::fgValues[VarManager::kRunNo] = bc.runNumber(); VarManager::fgValues[VarManager::kBC] = bc.globalBC(); VarManager::fgValues[VarManager::kTimestamp] = bc.timestamp(); - VarManager::fgValues[VarManager::kRunIndex] = VarManager::GetRunIndex(bc.runNumber()); VarManager::FillEvent(collision); // extract event information and place it in the fValues array if (fDoDetailedQA) { fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues); @@ -920,9 +921,10 @@ struct TableMaker { if (useZorro.fConfigRunZorro) { zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value); + zorro.setBCtolerance(useZorro.fBcTolerance); zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), useZorro.fConfigZorroTrigMask.value); zorro.populateExternalHists(fCurrentRun, reinterpret_cast(fStatsList->At(3)), reinterpret_cast(fStatsList->At(4))); - bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast(fStatsList->At(4))); + bool zorroSel = zorro.isSelected(bc.globalBC(), useZorro.fBcTolerance, reinterpret_cast(fStatsList->At(4))); if (zorroSel) { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } @@ -951,19 +953,27 @@ struct TableMaker { eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), - collision.centFT0C()); + collision.centFT0C(), collision.centFT0A(), collision.centFT0M()); } else if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMult) > 0) { eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), - -1); + -1, -1, -1); } else if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionCent) > 0) { eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, collision.centFT0C()); + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, collision.centFT0C(), collision.centFT0A(), collision.centFT0M()); } else { - eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); + eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); } eventVtxCov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); + eventInfo(collision.globalIndex()); + if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMultExtra) > 0) { + multPV(collision.multNTracksHasITS(), collision.multNTracksHasTPC(), collision.multNTracksHasTOF(), collision.multNTracksHasTRD(), + collision.multNTracksITSOnly(), collision.multNTracksTPCOnly(), collision.multNTracksITSTPC(), + collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); + multAll(collision.multAllTracksTPCOnly(), collision.multAllTracksITSTPC(), + 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0.0, 0.0, 0.0, 0.0); + } uint64_t trackFilteringTag = 0; uint8_t trackTempFilterMap = 0; @@ -1094,7 +1104,7 @@ struct TableMaker { muonBasic.reserve(tracksMuon.size()); muonExtra.reserve(tracksMuon.size()); muonInfo.reserve(tracksMuon.size()); - if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCov)) { + if constexpr (static_cast((TMuonFillMap & VarManager::ObjTypes::MuonCov) || (TMuonFillMap & VarManager::ObjTypes::MuonCovRealign))) { muonCov.reserve(tracksMuon.size()); } // loop over muons @@ -1106,8 +1116,9 @@ struct TableMaker { std::map newMatchIndex; for (const auto& muonId : fwdtrackIndices) { // start loop over tracks - auto muon = muonId.template fwdtrack_as(); + auto muon = tracksMuon.rawIteratorAt(muonId.fwdtrackId()); trackFilteringTag = static_cast(0); + VarManager::FillTrack(muon); if (muon.index() > idxPrev + 1) { // checks if some muons are filtered even before the skimming function @@ -1131,7 +1142,7 @@ struct TableMaker { // now let's save the muons with the correct indices and matches for (const auto& muonId : fwdtrackIndices) { // start loop over tracks - auto muon = muonId.template fwdtrack_as(); + auto muon = tracksMuon.rawIteratorAt(muonId.fwdtrackId()); if constexpr ((TMuonFillMap & VarManager::ObjTypes::AmbiMuon) > 0) { if (fIsAmbiguous) { isAmbiguous = (muon.compatibleCollIds().size() != 1); @@ -1140,6 +1151,12 @@ struct TableMaker { trackFilteringTag = static_cast(0); trackTempFilterMap = uint8_t(0); + if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonRealign)) { + if (static_cast(muon.isRemovable())) { + continue; + } + } + VarManager::FillTrack(muon); // recalculte pDca for global muon tracks @@ -1201,17 +1218,17 @@ struct TableMaker { muonBasic(event.lastIndex(), newMatchIndex.find(muon.index())->second, -1, trackFilteringTag, VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], muon.sign(), isAmbiguous); muonInfo(muon.collisionId(), collision.posX(), collision.posY(), collision.posZ()); - if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCov)) { + if constexpr (static_cast((TMuonFillMap & VarManager::ObjTypes::MuonCov) || (TMuonFillMap & VarManager::ObjTypes::MuonCovRealign))) { if (fPropMuon) { muonExtra(muon.nClusters(), VarManager::fgValues[VarManager::kMuonPDca], VarManager::fgValues[VarManager::kMuonRAtAbsorberEnd], - muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), + VarManager::fgValues[VarManager::kMuonChi2], muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), muon.midBoards(), muon.trackType(), VarManager::fgValues[VarManager::kMuonDCAx], VarManager::fgValues[VarManager::kMuonDCAy], muon.trackTime(), muon.trackTimeRes()); } else { muonExtra(muon.nClusters(), muon.pDca(), muon.rAtAbsorberEnd(), - muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), + VarManager::fgValues[VarManager::kMuonChi2], muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), muon.midBoards(), muon.trackType(), muon.fwdDcaX(), muon.fwdDcaY(), muon.trackTime(), muon.trackTimeRes()); @@ -1554,10 +1571,10 @@ struct TableMaker { } // Produce muon tables only, with centrality and muon cov matrix ------------------------------------------------------------------------------------------------- - void processMuonOnlyWithCovAndCent(MyEventsWithCent::iterator const& collision, aod::BCsWithTimestamps const& bcs, - soa::Filtered const& tracksMuon) + void processMuonOnlyWithCovAndCentMults(MyEventsWithCentAndMults::iterator const& collision, aod::BCsWithTimestamps const& bcs, + soa::Filtered const& tracksMuon) { - fullSkimming(collision, bcs, nullptr, tracksMuon, nullptr, nullptr); + fullSkimming(collision, bcs, nullptr, tracksMuon, nullptr, nullptr); } // Produce muon tables only, with muon cov matrix -------------------------------------------------------------------------------------------- @@ -1615,12 +1632,21 @@ struct TableMaker { } } - void processAssociatedMuonOnlyWithCovAndCent(MyEventsWithCent const& collisions, aod::BCsWithTimestamps const& bcs, - soa::Filtered const& tracksMuon, aod::AmbiguousFwdTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) + void processAssociatedRealignedMuonOnlyWithCov(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, + soa::Filtered const& tracksMuon, aod::AmbiguousFwdTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) + { + for (auto& collision : collisions) { + auto muonIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); + fullSkimmingIndices(collision, bcs, nullptr, tracksMuon, nullptr, muonIdsThisCollision); + } + } + + void processAssociatedMuonOnlyWithCovAndCentMults(MyEventsWithCentAndMults const& collisions, aod::BCsWithTimestamps const& bcs, + soa::Filtered const& tracksMuon, aod::AmbiguousFwdTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) { for (auto& collision : collisions) { auto muonIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); - fullSkimmingIndices(collision, bcs, nullptr, tracksMuon, nullptr, muonIdsThisCollision); + fullSkimmingIndices(collision, bcs, nullptr, tracksMuon, nullptr, muonIdsThisCollision); } } @@ -1783,7 +1809,7 @@ struct TableMaker { PROCESS_SWITCH(TableMaker, processBarrelOnlyWithCov, "Build barrel-only DQ skimmed data model, w/ track cov matrix", false); PROCESS_SWITCH(TableMaker, processBarrelOnlyWithCovOnlyStdPID, "Build barrel-only DQ skimmed data model, w/ track cov matrix, only std PID information used", false); PROCESS_SWITCH(TableMaker, processBarrelOnly, "Build barrel-only DQ skimmed data model, w/o centrality", false); - PROCESS_SWITCH(TableMaker, processMuonOnlyWithCovAndCent, "Build muon-only DQ skimmed data model, w/ centrality and muon cov matrix", false); + PROCESS_SWITCH(TableMaker, processMuonOnlyWithCovAndCentMults, "Build muon-only DQ skimmed data model, w/ centrality and muon cov matrix", false); PROCESS_SWITCH(TableMaker, processMuonOnlyWithCov, "Build muon-only DQ skimmed data model, w/ muon cov matrix", false); PROCESS_SWITCH(TableMaker, processMuonOnlyWithCovAndEventFilter, "Build muon-only DQ skimmed data model, w/ muon cov matrix, w/ event filter", false); PROCESS_SWITCH(TableMaker, processMuonMLOnly, "Build muon-only DQ skimmed data model with global muon track by ML matching", false); @@ -1791,7 +1817,8 @@ struct TableMaker { PROCESS_SWITCH(TableMaker, processAmbiguousMuonOnlyWithCov, "Build muon-only with cov DQ skimmed data model with QA plots for ambiguous muons", false); PROCESS_SWITCH(TableMaker, processAmbiguousBarrelOnly, "Build barrel-only DQ skimmed data model with QA plots for ambiguous tracks", false); PROCESS_SWITCH(TableMaker, processAssociatedMuonOnlyWithCov, "Build muon-only with cov DQ skimmed data model using track-collision association tables", false); - PROCESS_SWITCH(TableMaker, processAssociatedMuonOnlyWithCovAndCent, "Build muon-only with cov DQ skimmed data model using track-collision association tables and centrality", false); + PROCESS_SWITCH(TableMaker, processAssociatedRealignedMuonOnlyWithCov, "Build realigned muon-only with cov DQ skimmed data model using track-collision association tables", false); + PROCESS_SWITCH(TableMaker, processAssociatedMuonOnlyWithCovAndCentMults, "Build muon-only with cov DQ skimmed data model using track-collision association tables and centrality", false); PROCESS_SWITCH(TableMaker, processAssociatedMuonOnlyWithCovAndMults, "Build muon-only with cov DQ skimmed data model using track-collision association tables and multiplicity", false); PROCESS_SWITCH(TableMaker, processMuonsAndMFT, "Build MFT and muons DQ skimmed data model", false); PROCESS_SWITCH(TableMaker, processMuonsAndMFTWithFilter, "Build MFT and muons DQ skimmed data model, w/ event filter", false); diff --git a/PWGDQ/TableProducer/tableMakerMC.cxx b/PWGDQ/TableProducer/tableMakerMC.cxx index cd25c5c1a9d..1d43d196f9d 100644 --- a/PWGDQ/TableProducer/tableMakerMC.cxx +++ b/PWGDQ/TableProducer/tableMakerMC.cxx @@ -87,8 +87,8 @@ using MyMftTracks = soa::Join; using MyEvents = soa::Join; using MyEventsWithMults = soa::Join; -using MyEventsWithCent = soa::Join; -using MyEventsWithCentAndMults = soa::Join; +using MyEventsWithCent = soa::Join; +using MyEventsWithCentAndMults = soa::Join; constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision; constexpr static uint32_t gkEventFillMapWithMults = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult; @@ -444,17 +444,17 @@ struct TableMakerMC { eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), - collision.centFT0C()); + collision.centFT0C(), collision.centFT0A(), collision.centFT0M()); } else if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMult) > 0) { eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), - -1); + -1, -1, -1); } else if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionCent) > 0) { eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, collision.centFT0C()); + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, collision.centFT0C(), collision.centFT0A(), collision.centFT0M()); } else { - eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); + eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); } eventVtxCov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); eventInfo(collision.globalIndex()); @@ -468,7 +468,8 @@ struct TableMakerMC { eventMClabels(fEventLabels.find(mcCollision.globalIndex())->second, collision.mcMask()); if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMultExtra) > 0) { multPV(collision.multNTracksHasITS(), collision.multNTracksHasTPC(), collision.multNTracksHasTOF(), collision.multNTracksHasTRD(), - collision.multNTracksITSOnly(), collision.multNTracksTPCOnly(), collision.multNTracksITSTPC(), collision.trackOccupancyInTimeRange()); + collision.multNTracksITSOnly(), collision.multNTracksTPCOnly(), collision.multNTracksITSTPC(), + collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); multAll(collision.multAllTracksTPCOnly(), collision.multAllTracksITSTPC(), 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0.0, 0.0, 0.0, 0.0); } @@ -761,10 +762,6 @@ struct TableMakerMC { for (auto& cut : fMuonCuts) { if (cut.IsSelected(VarManager::fgValues)) { trackTempFilterMap |= (uint8_t(1) << i); - if (fConfigQA) { - fHistMan->FillHistClass(Form("Muons_%s", cut.GetName()), VarManager::fgValues); - } - (reinterpret_cast(fStatsList->At(2)))->Fill(static_cast(i)); } i++; } @@ -813,7 +810,6 @@ struct TableMakerMC { for (auto& cut : fMuonCuts) { if (cut.IsSelected(VarManager::fgValues)) { trackTempFilterMap |= (uint8_t(1) << i); - fHistMan->FillHistClass(Form("Muons_%s", cut.GetName()), VarManager::fgValues); if (fIsAmbiguous && isAmbiguous == 1) { fHistMan->FillHistClass(Form("Ambiguous_Muons_%s", cut.GetName()), VarManager::fgValues); } @@ -835,6 +831,7 @@ struct TableMakerMC { if (sig.CheckSignal(true, mctrack)) { mcflags |= (static_cast(1) << i); if (fDoDetailedQA) { + j = 0; for (auto& cut : fMuonCuts) { if (trackTempFilterMap & (uint8_t(1) << j)) { fHistMan->FillHistClass(Form("Muons_%s_%s", cut.GetName(), sig.GetName()), VarManager::fgValues); // fill the reconstructed truth @@ -1082,17 +1079,17 @@ struct TableMakerMC { eventExtended(collision.bc().globalBC(), collision.bc().triggerMask(), 0, triggerAliases, VarManager::fgValues[VarManager::kCentVZERO], collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), - collision.centFT0C()); + collision.centFT0C(), collision.centFT0A(), collision.centFT0M()); } else if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMult) > 0) { eventExtended(bc.globalBC(), bc.triggerMask(), bc.timestamp(), triggerAliases, VarManager::fgValues[VarManager::kCentVZERO], collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), - -1); + -1, -1, -1); } else if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionCent) > 0) { eventExtended(bc.globalBC(), bc.triggerMask(), bc.timestamp(), triggerAliases, VarManager::fgValues[VarManager::kCentVZERO], - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, collision.centFT0C()); + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, collision.centFT0C(), collision.centFT0A(), collision.centFT0M()); } else { - eventExtended(bc.globalBC(), bc.triggerMask(), bc.timestamp(), triggerAliases, VarManager::fgValues[VarManager::kCentVZERO], -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); + eventExtended(bc.globalBC(), bc.triggerMask(), bc.timestamp(), triggerAliases, VarManager::fgValues[VarManager::kCentVZERO], -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); } eventVtxCov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); eventInfo(collision.globalIndex()); @@ -1324,10 +1321,6 @@ struct TableMakerMC { for (auto& cut : fMuonCuts) { if (cut.IsSelected(VarManager::fgValues)) { trackTempFilterMap |= (uint8_t(1) << i); - if (fConfigQA) { - fHistMan->FillHistClass(Form("Muons_%s", cut.GetName()), VarManager::fgValues); - } - (reinterpret_cast(fStatsList->At(2)))->Fill(static_cast(i)); } i++; } @@ -1395,6 +1388,7 @@ struct TableMakerMC { if (sig.CheckSignal(true, mctrack)) { mcflags |= (static_cast(1) << i); if (fDoDetailedQA) { + j = 0; for (auto& cut : fMuonCuts) { if (trackTempFilterMap & (uint8_t(1) << j)) { fHistMan->FillHistClass(Form("Muons_%s_%s", cut.GetName(), sig.GetName()), VarManager::fgValues); // fill the reconstructed truth diff --git a/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx b/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx index 14d844e3393..7dc49516e8a 100644 --- a/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx +++ b/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx @@ -16,11 +16,14 @@ // The skimmed MC stack includes the MC truth particles corresponding to the list of user specified MC signals (see MCsignal.h) // and the MC truth particles corresponding to the reconstructed tracks selected by the specified track cuts on reconstructed data. +#include #include #include #include #include #include +#include +#include #include "TList.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -43,6 +46,7 @@ #include "PWGDQ/Core/MCSignalLibrary.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/FwdTrackReAlignTables.h" #include "Common/DataModel/CollisionAssociationTables.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" @@ -81,28 +85,41 @@ using MyBarrelTracksWithCov = soa::Join; using MyMuons = soa::Join; using MyMuonsWithCov = soa::Join; +using MyMuonsRealignWithCov = soa::Join; using MyEvents = soa::Join; using MyEventsWithMults = soa::Join; -using MyEventsWithCent = soa::Join; -using MyEventsWithCentAndMults = soa::Join; +using MyEventsWithMultsAndRapidityGapFilter = soa::Join; +using MyEventsWithCent = soa::Join; +using MyEventsWithCentAndMults = soa::Join; +using MFTTrackLabeled = soa::Join; // Declare bit maps containing information on the table joins content (used as argument in templated functions) -// constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision; +constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision; constexpr static uint32_t gkEventFillMapWithMults = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult | VarManager::ObjTypes::CollisionMultExtra; // constexpr static uint32_t gkEventFillMapWithCent = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCent; constexpr static uint32_t gkEventFillMapWithCentAndMults = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCent | VarManager::CollisionMult | VarManager::CollisionMultExtra; +constexpr static uint32_t gkEventFillMapWithMultsRapidityGapFilter = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult | VarManager::ObjTypes::CollisionMultExtra | VarManager::ObjTypes::RapidityGapFilter; // constexpr static uint32_t gkEventMCFillMap = VarManager::ObjTypes::CollisionMC; // constexpr static uint32_t gkTrackFillMap = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackSelection | VarManager::ObjTypes::TrackPID; constexpr static uint32_t gkTrackFillMapWithCov = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackSelection | VarManager::ObjTypes::TrackCov | VarManager::ObjTypes::TrackPID; // constexpr static uint32_t gkTrackFillMapWithDalitzBits = gkTrackFillMap | VarManager::ObjTypes::DalitzBits; // constexpr static uint32_t gkMuonFillMap = VarManager::ObjTypes::Muon; constexpr static uint32_t gkMuonFillMapWithCov = VarManager::ObjTypes::Muon | VarManager::ObjTypes::MuonCov; +constexpr static uint32_t gkMuonRealignFillMapWithCov = VarManager::ObjTypes::MuonRealign | VarManager::ObjTypes::MuonCovRealign; // constexpr static uint32_t gkMuonFillMapWithAmbi = VarManager::ObjTypes::Muon | VarManager::ObjTypes::AmbiMuon; // constexpr static uint32_t gkMuonFillMapWithCovAmbi = VarManager::ObjTypes::Muon | VarManager::ObjTypes::MuonCov | VarManager::ObjTypes::AmbiMuon; // constexpr static uint32_t gkTrackFillMapWithAmbi = VarManager::ObjTypes::Track | VarManager::ObjTypes::AmbiTrack; constexpr static uint32_t gkMFTFillMap = VarManager::ObjTypes::TrackMFT; +template +void PrintBitMap(TMap map, int nbits) +{ + for (int i = 0; i < nbits; i++) { + cout << ((map & (TMap(1) << i)) > 0 ? "1" : "0"); + } +} + struct TableMakerMC { Produces eventMC; @@ -133,6 +150,7 @@ struct TableMakerMC { Produces mftTrack; Produces mftTrackExtra; Produces mftAssoc; + Produces mftLabels; OutputObj fOutputList{"output"}; OutputObj fStatsList{"Statistics"}; //! skimming statistics @@ -145,10 +163,14 @@ struct TableMakerMC { Configurable fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"}; Configurable fConfigTrackCuts{"cfgBarrelTrackCuts", "jpsiPID1", "barrel track cut"}; Configurable fConfigMuonCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; + Configurable fConfigEventCutsJSON{"cfgEventCutsJSON", "", "Additional event selection in JSON format"}; + Configurable fConfigTrackCutsJSON{"cfgBarrelTrackCutsJSON", "", "Additional list of barrel track cuts in JSON format"}; + Configurable fConfigMuonCutsJSON{"cfgMuonCutsJSON", "", "Additional list of muon cuts in JSON format"}; } fConfigCuts; // MC signals to be skimmed Configurable fConfigMCSignals{"cfgMCsignals", "", "Comma separated list of MC signals"}; + Configurable fConfigMCSignalsJSON{"cfgMCsignalsJSON", "", "Additional list of MC signals via JSON"}; // Steer QA output struct : ConfigurableGroup { @@ -158,6 +180,7 @@ struct TableMakerMC { Configurable fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"}; Configurable fConfigAddMuonHistogram{"cfgAddMuonHistogram", "", "Comma separated list of histograms"}; Configurable fConfigAddMCTruthHistogram{"cfgAddMCTruthHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; } fConfigHistOutput; // Selections to be applied as Filter on the Track and FwdTrack @@ -183,6 +206,7 @@ struct TableMakerMC { // Muon related options Configurable fPropMuon{"cfgPropMuon", true, "Propagate muon tracks through absorber (do not use if applying pairing)"}; Configurable fRefitGlobalMuon{"cfgRefitGlobalMuon", true, "Correct global muon parameters"}; + Configurable fKeepBestMatch{"cfgKeepBestMatch", false, "Keep only the best match global muons in the skimming"}; Configurable fMuonMatchEtaMin{"cfgMuonMatchEtaMin", -4.0f, "Definition of the acceptance of muon tracks to be matched with MFT"}; Configurable fMuonMatchEtaMax{"cfgMuonMatchEtaMax", -2.5f, "Definition of the acceptance of muon tracks to be matched with MFT"}; } fConfigVariousOptions; @@ -193,15 +217,15 @@ struct TableMakerMC { o2::parameters::GRPObject* fGrpMagRun2 = nullptr; // for run 2, we access the GRPObject from GLO/GRP/GRP o2::parameters::GRPMagField* fGrpMag = nullptr; // for run 3, we access GRPMagField from GLO/Config/GRPMagField - AnalysisCompositeCut* fEventCut; //! Event selection cut - std::vector fTrackCuts; //! Barrel track cuts - std::vector fMuonCuts; //! Muon track cuts + AnalysisCompositeCut* fEventCut; //! Event selection cut + std::vector fTrackCuts; //! Barrel track cuts + std::vector fMuonCuts; //! Muon track cuts bool fDoDetailedQA = false; // Bool to set detailed QA true, if QA is set true int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. // list of MCsignal objects - std::vector fMCSignals; + std::vector fMCSignals; std::map fLabelsMap; std::map fLabelsMapReversed; std::map fMCFlags; @@ -212,21 +236,24 @@ struct TableMakerMC { std::map fFwdTrackFilterMap; // key: fwd-track global index, value: fwd-track filter map std::map fMftIndexMap; // key: MFT tracklet global index, value: new MFT tracklet global index + std::map fBestMatch; + void init(o2::framework::InitContext& context) { // Check whether barrel or muon are enabled bool isProcessBCenabled = context.mOptions.get("processPP"); - bool isBarrelEnabled = (context.mOptions.get("processPP") || context.mOptions.get("processPPBarrelOnly") || context.mOptions.get("processPbPbBarrelOnly")); - bool isMuonEnabled = (context.mOptions.get("processPP") || context.mOptions.get("processPPMuonOnly") || context.mOptions.get("processPbPbMuonOnly")); + bool isBarrelEnabled = (context.mOptions.get("processPP") || context.mOptions.get("processPPBarrelOnly") || context.mOptions.get("processPbPbBarrelOnly") || context.mOptions.get("processPbPbWithFilterBarrelOnly")); + bool isMuonEnabled = (context.mOptions.get("processPP") || context.mOptions.get("processPPMuonOnlyBasic") || context.mOptions.get("processPPMuonOnly") || context.mOptions.get("processPPRealignedMuonOnly") || context.mOptions.get("processPbPbMuonOnly") || context.mOptions.get("processPbPbRealignedMuonOnly")); // Make sure at least one process function is enabled if (!(isProcessBCenabled || isBarrelEnabled || isMuonEnabled)) { LOG(fatal) << "No process function was enabled for TableMakerMC. Check it out!!!"; } + VarManager::SetDefaultVarNames(); // Important that this is called before DefineCuts() !!! + // Define user specified cut DefineCuts(); - VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); @@ -256,7 +283,7 @@ struct TableMakerMC { // Barrel track histograms after cuts; one directory per cut if (fConfigHistOutput.fConfigQA) { for (auto& cut : fTrackCuts) { - histClasses += Form("TrackBarrel_%s;", cut.GetName()); + histClasses += Form("TrackBarrel_%s;", cut->GetName()); } } } @@ -269,7 +296,7 @@ struct TableMakerMC { // Muon track histograms after cuts; one directory per cut if (fConfigHistOutput.fConfigQA) { for (auto& muonCut : fMuonCuts) { - histClasses += Form("Muons_%s;", muonCut.GetName()); + histClasses += Form("Muons_%s;", muonCut->GetName()); } } } @@ -278,36 +305,52 @@ struct TableMakerMC { TString configNamesStr = fConfigMCSignals.value; std::unique_ptr objArray(configNamesStr.Tokenize(",")); if (objArray->GetEntries() > 0) { - // loop over MC signals + // loop over MC signals and add them to the signals array for (int isig = 0; isig < objArray->GetEntries(); ++isig) { MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objArray->At(isig)->GetName()); if (sig) { - fMCSignals.push_back(*sig); - // setup a histogram directory for this MC signal - if (fConfigHistOutput.fConfigQA) { - histClasses += Form("MCTruth_%s;", objArray->At(isig)->GetName()); - } - } else { - continue; + fMCSignals.push_back(sig); } - if (fDoDetailedQA) { - if (isBarrelEnabled) { - // in case of detailed QA, setup histogram directories for each combination of reconstructed track cuts and MC signals - for (auto& cut : fTrackCuts) { - histClasses += Form("TrackBarrel_%s_%s;", cut.GetName(), objArray->At(isig)->GetName()); - } + } + } + // Adding additional signals via JSON + TString addMCSignalsStr = fConfigMCSignalsJSON.value; + if (addMCSignalsStr != "") { + std::vector addMCSignals = dqmcsignals::GetMCSignalsFromJSON(addMCSignalsStr.Data()); + for (auto& mcIt : addMCSignals) { + if (mcIt) { + fMCSignals.push_back(mcIt); + } + } + } + + for (auto& mcIt : fMCSignals) { + if (fConfigHistOutput.fConfigQA) { + histClasses += Form("MCTruth_%s;", mcIt->GetName()); + } + if (fDoDetailedQA) { + if (isBarrelEnabled) { + // in case of detailed QA, setup histogram directories for each combination of reconstructed track cuts and MC signals + for (auto& cut : fTrackCuts) { + histClasses += Form("TrackBarrel_%s_%s;", cut->GetName(), mcIt->GetName()); } - if (isMuonEnabled) { - // in case of detailed QA, setup histogram directories for each combination of reconstructed muon cuts and MC signals - for (auto& cut : fMuonCuts) { - histClasses += Form("Muons_%s_%s;", cut.GetName(), objArray->At(isig)->GetName()); - } + } + if (isMuonEnabled) { + // in case of detailed QA, setup histogram directories for each combination of reconstructed muon cuts and MC signals + for (auto& cut : fMuonCuts) { + histClasses += Form("Muons_%s_%s;", cut->GetName(), mcIt->GetName()); } } } } - DefineHistograms(histClasses); // define all histograms + DefineHistograms(histClasses); // define all histograms + // Additional histogram via the JSON configurable + TString addHistsStr = fConfigHistOutput.fConfigAddJSONHistograms.value; + if (fConfigHistOutput.fConfigQA && addHistsStr != "") { + dqhistograms::AddHistogramsFromJSON(fHistMan, addHistsStr.Data()); + } + VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); @@ -327,13 +370,29 @@ struct TableMakerMC { fEventCut = new AnalysisCompositeCut(true); TString eventCutStr = fConfigCuts.fConfigEventCuts.value; fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); + // Extra event cuts via JSON + TString addEvCutsStr = fConfigCuts.fConfigEventCutsJSON.value; + if (addEvCutsStr != "") { + std::vector addEvCuts = dqcuts::GetCutsFromJSON(addEvCutsStr.Data()); + for (auto& cutIt : addEvCuts) { + fEventCut->AddCut(cutIt); + } + } // Barrel track cuts TString cutNamesStr = fConfigCuts.fConfigTrackCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fTrackCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fTrackCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + } + } + // Additional Barrel track cuts via JSON + TString addTrackCutsStr = fConfigCuts.fConfigTrackCutsJSON.value; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + fTrackCuts.push_back(reinterpret_cast(t)); } } @@ -342,7 +401,15 @@ struct TableMakerMC { if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fMuonCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fMuonCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + } + } + // Additional muon cuts via JSON + TString addMuonCutsStr = fConfigCuts.fConfigMuonCutsJSON.value; + if (addMuonCutsStr != "") { + std::vector addMuonCuts = dqcuts::GetCutsFromJSON(addMuonCutsStr.Data()); + for (auto& t : addMuonCuts) { + fMuonCuts.push_back(reinterpret_cast(t)); } } @@ -395,15 +462,45 @@ struct TableMakerMC { bool checked = false; if constexpr (soa::is_soa_filtered_v) { auto mctrack_raw = mcTracks.rawIteratorAt(mctrack.globalIndex()); - checked = sig.CheckSignal(true, mctrack_raw); + checked = sig->CheckSignal(true, mctrack_raw); } else { - checked = sig.CheckSignal(true, mctrack); + checked = sig->CheckSignal(true, mctrack); } if (checked) { mcflags |= (static_cast(1) << i); } i++; } + + /*if ((std::abs(mctrack.pdgCode())>400 && std::abs(mctrack.pdgCode())<599) || + (std::abs(mctrack.pdgCode())>4000 && std::abs(mctrack.pdgCode())<5999) || + (mcflags > 0)) { + cout << ">>>>>>>>>>>>>>>>>>>>>>> track idx / pdg / process / status code / HEPMC status / primary : " + << mctrack.globalIndex() << " / " << mctrack.pdgCode() << " / " + << mctrack.getProcess() << " / " << mctrack.getGenStatusCode() << " / " << mctrack.getHepMCStatusCode() << " / " << mctrack.isPhysicalPrimary() << endl; + cout << ">>>>>>>>>>>>>>>>>>>>>>> track bitmap: "; + PrintBitMap(mcflags, 16); + cout << endl; + if (mctrack.has_mothers()) { + for (auto& m : mctrack.mothersIds()) { + if (m < mcTracks.size()) { // protect against bad mother indices + auto aMother = mcTracks.rawIteratorAt(m); + cout << "<<<<<< mother idx / pdg: " << m << " / " << aMother.pdgCode() << endl; + } + } + } + + if (mctrack.has_daughters()) { + for (int d = mctrack.daughtersIds()[0]; d <= mctrack.daughtersIds()[1]; ++d) { + + if (d < mcTracks.size()) { // protect against bad daughter indices + auto aDaughter = mcTracks.rawIteratorAt(d); + cout << "<<<<<< daughter idx / pdg: " << d << " / " << aDaughter.pdgCode() << endl; + } + } + } + }*/ + // if no MC signals were matched, continue if (mcflags == 0) { continue; @@ -423,7 +520,7 @@ struct TableMakerMC { int j = 0; for (auto signal = fMCSignals.begin(); signal != fMCSignals.end(); signal++, j++) { if (mcflags & (static_cast(1) << j)) { - fHistMan->FillHistClass(Form("MCTruth_%s", (*signal).GetName()), VarManager::fgValues); + fHistMan->FillHistClass(Form("MCTruth_%s", (*signal)->GetName()), VarManager::fgValues); } } } @@ -450,6 +547,8 @@ struct TableMakerMC { int multTracklets = -1.0; int multTracksPV = -1.0; float centFT0C = -1.0; + float centFT0A = -1.0; + float centFT0M = -1.0; // Loop over collisions for (const auto& collision : collisions) { @@ -462,6 +561,13 @@ struct TableMakerMC { } (reinterpret_cast(fStatsList->At(0)))->Fill(1.0, static_cast(o2::aod::evsel::kNsel)); + // apply the event filter + if constexpr ((TEventFillMap & VarManager::ObjTypes::RapidityGapFilter) > 0) { + if (!collision.eventFilter()) { + continue; + } + } + auto bc = collision.template bc_as(); // store the selection decisions uint64_t tag = static_cast(0); @@ -471,6 +577,10 @@ struct TableMakerMC { if (bcEvSel.globalIndex() != bc.globalIndex()) { tag |= (static_cast(1) << 0); } + // Put the 8 first bits of the event filter in the last 8 bits of the tag + if constexpr ((TEventFillMap & VarManager::ObjTypes::RapidityGapFilter) > 0) { + tag |= (collision.eventFilter() << 56); + } // Compute BC and event quantities and fill histograms VarManager::ResetValues(0, VarManager::kNEventWiseVariables); @@ -511,28 +621,40 @@ struct TableMakerMC { event(tag, bc.runNumber(), collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), collision.collisionTime(), collision.collisionTimeRes()); if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMult) > 0) { multTPC = collision.multTPC(); - multFV0A = collision.multFV0A(); multFV0C = collision.multFV0C(); - multFT0A = collision.multFT0A(); - multFT0C = collision.multFT0C(); - multFDDA = collision.multFDDA(); - multFDDC = collision.multFDDC(); multZNA = collision.multZNA(); multZNC = collision.multZNC(); multTracklets = collision.multTracklets(); multTracksPV = collision.multNTracksPV(); + if constexpr ((TEventFillMap & VarManager::ObjTypes::RapidityGapFilter) > 0) { + // Use the FIT signals from the nearest BC with FIT amplitude above threshold + multFV0A = collision.newBcMultFV0A(); + multFT0A = collision.newBcMultFT0A(); + multFT0C = collision.newBcMultFT0C(); + multFDDA = collision.newBcMultFDDA(); + multFDDC = collision.newBcMultFDDC(); + } else { + multFV0A = collision.multFV0A(); + multFT0A = collision.multFT0A(); + multFT0C = collision.multFT0C(); + multFDDA = collision.multFDDA(); + multFDDC = collision.multFDDC(); + } } if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionCent) > 0) { centFT0C = collision.centFT0C(); + centFT0A = collision.centFT0A(); + centFT0M = collision.centFT0M(); } eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], - multTPC, multFV0A, multFV0C, multFT0A, multFT0C, multFDDA, multFDDC, multZNA, multZNC, multTracklets, multTracksPV, centFT0C); + multTPC, multFV0A, multFV0C, multFT0A, multFT0C, multFDDA, multFDDC, multZNA, multZNC, multTracklets, multTracksPV, centFT0C, centFT0A, centFT0M); eventVtxCov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); eventMClabels(collision.mcCollisionId(), collision.mcMask()); eventInfo(collision.globalIndex()); if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMultExtra) > 0) { multPV(collision.multNTracksHasITS(), collision.multNTracksHasTPC(), collision.multNTracksHasTOF(), collision.multNTracksHasTRD(), - collision.multNTracksITSOnly(), collision.multNTracksTPCOnly(), collision.multNTracksITSTPC(), collision.trackOccupancyInTimeRange()); + collision.multNTracksITSOnly(), collision.multNTracksTPCOnly(), collision.multNTracksITSTPC(), + collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); multAll(collision.multAllTracksTPCOnly(), collision.multAllTracksITSTPC(), 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0.0, 0.0, 0.0, 0.0); } @@ -584,10 +706,10 @@ struct TableMakerMC { // apply track cuts and fill histograms int i = 0; for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++, i++) { - if ((*cut).IsSelected(VarManager::fgValues)) { + if ((*cut)->IsSelected(VarManager::fgValues)) { trackTempFilterMap |= (static_cast(1) << i); if (fConfigHistOutput.fConfigQA) { - fHistMan->FillHistClass(Form("TrackBarrel_%s", (*cut).GetName()), VarManager::fgValues); + fHistMan->FillHistClass(Form("TrackBarrel_%s", (*cut)->GetName()), VarManager::fgValues); } (reinterpret_cast(fStatsList->At(1)))->Fill(static_cast(i)); } @@ -660,14 +782,14 @@ struct TableMakerMC { int j = 0; // runs over the track cuts // check all the specified signals and fill histograms for MC truth matched tracks for (auto& sig : fMCSignals) { - if (sig.CheckSignal(true, mctrack)) { + if (sig->CheckSignal(true, mctrack)) { mcflags |= (static_cast(1) << i); // If detailed QA is on, fill histograms for each MC signal and track cut combination if (fDoDetailedQA) { j = 0; for (auto& cut : fTrackCuts) { if (trackTempFilterMap & (uint8_t(1) << j)) { - fHistMan->FillHistClass(Form("TrackBarrel_%s_%s", cut.GetName(), sig.GetName()), VarManager::fgValues); // fill the reconstructed truth + fHistMan->FillHistClass(Form("TrackBarrel_%s_%s", cut->GetName(), sig->GetName()), VarManager::fgValues); // fill the reconstructed truth } j++; } @@ -691,13 +813,16 @@ struct TableMakerMC { } // end loop over associations } // end skimTracks - template - void skimMFT(TEvent const& collision, MFTTracks const& /*mfts*/, MFTTrackAssoc const& mftAssocs) + template + void skimMFT(TEvent const& collision, TMFTTracks const& /*mfts*/, MFTTrackAssoc const& mftAssocs, aod::McParticles const& mcTracks) { // Skim MFT tracks // So far no cuts are applied here + uint16_t mcflags = static_cast(0); + int trackCounter = fLabelsMap.size(); + for (const auto& assoc : mftAssocs) { - auto track = assoc.template mfttrack_as(); + auto track = assoc.template mfttrack_as(); if (fConfigHistOutput.fConfigQA) { VarManager::FillTrack(track); @@ -712,11 +837,63 @@ struct TableMakerMC { mftTrackExtra(track.mftClusterSizesAndTrackFlags(), track.sign(), 0.0, 0.0, track.nClusters()); fMftIndexMap[track.globalIndex()] = mftTrack.lastIndex(); + if (!track.has_mcParticle()) { + mftLabels(-1, 0, 0); // this is the case when there is no matched MCParticle + } else { + auto mctrack = track.template mcParticle_as(); + VarManager::FillTrackMC(mcTracks, mctrack); + + mcflags = 0; + int i = 0; // runs over the MC signals + // check all the specified signals and fill histograms for MC truth matched tracks + for (auto& sig : fMCSignals) { + if (sig->CheckSignal(true, mctrack)) { + mcflags |= (static_cast(1) << i); + // If detailed QA is on, fill histograms for each MC signal and track cut combination + if (fDoDetailedQA) { + fHistMan->FillHistClass(Form("MFTTrack_%s", sig->GetName()), VarManager::fgValues); // fill the reconstructed truth + } + } + i++; + } + + // if the MC truth particle corresponding to this reconstructed track is not already written, + // add it to the skimmed stack + if (!(fLabelsMap.find(mctrack.globalIndex()) != fLabelsMap.end())) { + fLabelsMap[mctrack.globalIndex()] = trackCounter; + fLabelsMapReversed[trackCounter] = mctrack.globalIndex(); + fMCFlags[mctrack.globalIndex()] = mcflags; + trackCounter++; + } + mftLabels(fLabelsMap.find(mctrack.globalIndex())->second, track.mcMask(), mcflags); + } } mftAssoc(fCollIndexMap[collision.globalIndex()], fMftIndexMap[track.globalIndex()]); } } + template + void skimBestMuonMatches(TMuons const& muons) + { + std::unordered_map> mCandidates; + for (const auto& muon : muons) { + if (static_cast(muon.trackType()) < 2) { + auto muonID = muon.matchMCHTrackId(); + auto chi2 = muon.chi2MatchMCHMFT(); + if (mCandidates.find(muonID) == mCandidates.end()) { + mCandidates[muonID] = {chi2, muon.globalIndex()}; + } else { + if (chi2 < mCandidates[muonID].first) { + mCandidates[muonID] = {chi2, muon.globalIndex()}; + } + } + } + } + for (auto& pairCand : mCandidates) { + fBestMatch[pairCand.second.second] = true; + } + } + template void skimMuons(TEvent const& collision, TMuons const& muons, FwdTrackAssoc const& muonAssocs, aod::McParticles const& mcTracks, TMFTTracks const& /*mftTracks*/) { @@ -734,10 +911,23 @@ struct TableMakerMC { uint32_t counter = 0; for (const auto& assoc : muonAssocs) { // get the muon - auto muon = assoc.template fwdtrack_as(); + auto muon = muons.rawIteratorAt(assoc.fwdtrackId()); + if (fConfigVariousOptions.fKeepBestMatch && static_cast(muon.trackType()) < 2) { + if (fBestMatch.find(muon.globalIndex()) == fBestMatch.end()) { + continue; + } + } trackFilteringTag = uint8_t(0); trackTempFilterMap = uint8_t(0); + + if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonRealign)) { + // Check refit flag in case of realigned muons + if (static_cast(muon.isRemovable())) { + continue; + } + } + VarManager::FillTrack(muon); // NOTE: If a muon is associated to multiple collisions, depending on the selections, // it may be accepted for some associations and rejected for other @@ -750,7 +940,7 @@ struct TableMakerMC { if (muontrack.eta() < fConfigVariousOptions.fMuonMatchEtaMin || muontrack.eta() > fConfigVariousOptions.fMuonMatchEtaMax) { continue; } - auto mfttrack = muon.template matchMFTTrack_as(); + auto mfttrack = muon.template matchMFTTrack_as(); VarManager::FillTrackCollision(muontrack, collision); VarManager::FillGlobalMuonRefit(muontrack, mfttrack, collision); } else { @@ -763,10 +953,10 @@ struct TableMakerMC { // check the cuts and fill histograms for each fulfilled cut int i = 0; for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++, i++) { - if ((*cut).IsSelected(VarManager::fgValues)) { + if ((*cut)->IsSelected(VarManager::fgValues)) { trackTempFilterMap |= (uint8_t(1) << i); if (fConfigHistOutput.fConfigQA) { - fHistMan->FillHistClass(Form("Muons_%s", (*cut).GetName()), VarManager::fgValues); + fHistMan->FillHistClass(Form("Muons_%s", (*cut)->GetName()), VarManager::fgValues); } (reinterpret_cast(fStatsList->At(2)))->Fill(static_cast(i)); } @@ -800,12 +990,13 @@ struct TableMakerMC { int j = 0; // runs over the track cuts // check all the specified signals and fill histograms for MC truth matched tracks for (auto& sig : fMCSignals) { - if (sig.CheckSignal(true, mctrack)) { + if (sig->CheckSignal(true, mctrack)) { mcflags |= (static_cast(1) << i); if (fDoDetailedQA) { + j = 0; for (auto& cut : fMuonCuts) { if (trackTempFilterMap & (uint8_t(1) << j)) { - fHistMan->FillHistClass(Form("Muons_%s_%s", cut.GetName(), sig.GetName()), VarManager::fgValues); // fill the reconstructed truth + fHistMan->FillHistClass(Form("Muons_%s_%s", cut->GetName(), sig->GetName()), VarManager::fgValues); // fill the reconstructed truth } j++; } @@ -823,7 +1014,7 @@ struct TableMakerMC { trackCounter++; } - } // end if (has_mcParticle) + } // end if (has_mcParticle) } else { // if muon already in the map, make a bitwise OR with previous existing cuts fFwdTrackFilterMap[muon.globalIndex()] |= trackFilteringTag; } @@ -855,6 +1046,14 @@ struct TableMakerMC { mftIdx = fMftIndexMap[muon.matchMFTTrackId()]; } } + + if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonRealign)) { + // Check refit flag in case of realigned muons + if (static_cast(muon.isRemovable())) { + continue; + } + } + VarManager::FillTrack(muon); if (fConfigVariousOptions.fPropMuon) { VarManager::FillPropagateMuon(muon, collision); @@ -862,7 +1061,7 @@ struct TableMakerMC { // recalculte pDca and global muon kinematics if (static_cast(muon.trackType()) < 2 && fConfigVariousOptions.fRefitGlobalMuon) { auto muontrack = muon.template matchMCHTrack_as(); - auto mfttrack = muon.template matchMFTTrack_as(); + auto mfttrack = muon.template matchMFTTrack_as(); VarManager::FillTrackCollision(muontrack, collision); VarManager::FillGlobalMuonRefit(muontrack, mfttrack, collision); } else { @@ -870,12 +1069,12 @@ struct TableMakerMC { } muonBasic(reducedEventIdx, mchIdx, mftIdx, fFwdTrackFilterMap[muon.globalIndex()], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], muon.sign(), 0); muonExtra(muon.nClusters(), VarManager::fgValues[VarManager::kMuonPDca], VarManager::fgValues[VarManager::kMuonRAtAbsorberEnd], - muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), + VarManager::fgValues[VarManager::kMuonChi2], muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), muon.midBoards(), muon.trackType(), VarManager::fgValues[VarManager::kMuonDCAx], VarManager::fgValues[VarManager::kMuonDCAy], muon.trackTime(), muon.trackTimeRes()); - if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCov)) { + if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCov) || static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCovRealign)) { muonCov(VarManager::fgValues[VarManager::kX], VarManager::fgValues[VarManager::kY], VarManager::fgValues[VarManager::kZ], VarManager::fgValues[VarManager::kPhi], VarManager::fgValues[VarManager::kTgl], muon.sign() / VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kMuonCXX], VarManager::fgValues[VarManager::kMuonCXY], VarManager::fgValues[VarManager::kMuonCYY], VarManager::fgValues[VarManager::kMuonCPhiX], VarManager::fgValues[VarManager::kMuonCPhiY], VarManager::fgValues[VarManager::kMuonCPhiPhi], VarManager::fgValues[VarManager::kMuonCTglX], VarManager::fgValues[VarManager::kMuonCTglY], VarManager::fgValues[VarManager::kMuonCTglPhi], VarManager::fgValues[VarManager::kMuonCTglTgl], VarManager::fgValues[VarManager::kMuonC1Pt2X], VarManager::fgValues[VarManager::kMuonC1Pt2Y], @@ -909,6 +1108,9 @@ struct TableMakerMC { if (fGrpMag != nullptr) { o2::base::Propagator::initFieldFromGRP(fGrpMag); } + if (fConfigVariousOptions.fPropMuon) { + VarManager::SetupMuonMagField(); + } } std::map metadataRCT, header; header = fCCDBApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", bcs.begin().runNumber()), metadataRCT, -1); @@ -956,12 +1158,14 @@ struct TableMakerMC { mftTrack.reserve(mftTracks.size()); mftTrackExtra.reserve(mftTracks.size()); mftAssoc.reserve(mftTracks.size()); + mftLabels.reserve(mftTracks.size()); } // Clear index map and reserve memory for muon tables if constexpr (static_cast(TMuonFillMap)) { fFwdTrackIndexMap.clear(); fFwdTrackFilterMap.clear(); + fBestMatch.clear(); muonBasic.reserve(muons.size()); muonExtra.reserve(muons.size()); muonCov.reserve(muons.size()); @@ -980,11 +1184,14 @@ struct TableMakerMC { } if constexpr (static_cast(TMFTFillMap)) { auto groupedMFTIndices = mftAssocs.sliceBy(mfttrackIndicesPerCollision, origIdx); - skimMFT(collision, mftTracks, groupedMFTIndices); + skimMFT(collision, mftTracks, groupedMFTIndices, mcParticles); } if constexpr (static_cast(TMuonFillMap)) { if constexpr (static_cast(TMFTFillMap)) { auto groupedMuonIndices = fwdTrackAssocs.sliceBy(fwdtrackIndicesPerCollision, origIdx); + if (fConfigVariousOptions.fKeepBestMatch) { + skimBestMuonMatches(muons); + } skimMuons(collision, muons, groupedMuonIndices, mcParticles, mftTracks); } else { auto groupedMuonIndices = fwdTrackAssocs.sliceBy(fwdtrackIndicesPerCollision, origIdx); @@ -1110,7 +1317,7 @@ struct TableMakerMC { TH1I* histTracks = new TH1I("TrackStats", "Track statistics", fTrackCuts.size() + 5.0, -0.5, fTrackCuts.size() - 0.5 + 5.0); ib = 1; for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++, ib++) { - histTracks->GetXaxis()->SetBinLabel(ib, (*cut).GetName()); + histTracks->GetXaxis()->SetBinLabel(ib, (*cut)->GetName()); } const char* v0TagNames[5] = {"Photon conversion", "K^{0}_{s}", "#Lambda", "#bar{#Lambda}", "#Omega"}; for (int ib = 0; ib < 5; ib++) { @@ -1120,20 +1327,20 @@ struct TableMakerMC { TH1I* histMuons = new TH1I("MuonStats", "Muon statistics", fMuonCuts.size(), -0.5, fMuonCuts.size() - 0.5); ib = 1; for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++, ib++) { - histMuons->GetXaxis()->SetBinLabel(ib, (*cut).GetName()); + histMuons->GetXaxis()->SetBinLabel(ib, (*cut)->GetName()); } fStatsList->Add(histMuons); TH1I* histMCsignals = new TH1I("MCsignals", "MC signals", fMCSignals.size() + 1, -0.5, fMCSignals.size() - 0.5 + 1.0); ib = 1; for (auto signal = fMCSignals.begin(); signal != fMCSignals.end(); signal++, ib++) { - histMCsignals->GetXaxis()->SetBinLabel(ib, (*signal).GetName()); + histMCsignals->GetXaxis()->SetBinLabel(ib, (*signal)->GetName()); } histMCsignals->GetXaxis()->SetBinLabel(fMCSignals.size() + 1, "Others (matched to reco tracks)"); fStatsList->Add(histMCsignals); } void processPP(MyEventsWithMults const& collisions, aod::BCsWithTimestamps const& bcs, - MyBarrelTracksWithCov const& tracksBarrel, MyMuonsWithCov const& tracksMuon, aod::MFTTracks const& mftTracks, + MyBarrelTracksWithCov const& tracksBarrel, MyMuonsWithCov const& tracksMuon, MFTTrackLabeled const& mftTracks, aod::TrackAssoc const& trackAssocs, aod::FwdTrackAssoc const& fwdTrackAssocs, aod::MFTTrackAssoc const& mftAssocs, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) { @@ -1147,16 +1354,32 @@ struct TableMakerMC { fullSkimming(collisions, bcs, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr, mcCollisions, mcParticles); } + void processPPMuonOnlyBasic(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, + MyMuonsWithCov const& tracksMuon, MFTTrackLabeled const& mftTracks, + aod::FwdTrackAssoc const& fwdTrackAssocs, aod::MFTTrackAssoc const& mftAssocs, + aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) + { + fullSkimming(collisions, bcs, nullptr, tracksMuon, mftTracks, nullptr, fwdTrackAssocs, mftAssocs, mcCollisions, mcParticles); + } + void processPPMuonOnly(MyEventsWithMults const& collisions, aod::BCsWithTimestamps const& bcs, - MyMuonsWithCov const& tracksMuon, aod::MFTTracks const& mftTracks, + MyMuonsWithCov const& tracksMuon, MFTTrackLabeled const& mftTracks, aod::FwdTrackAssoc const& fwdTrackAssocs, aod::MFTTrackAssoc const& mftAssocs, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) { fullSkimming(collisions, bcs, nullptr, tracksMuon, mftTracks, nullptr, fwdTrackAssocs, mftAssocs, mcCollisions, mcParticles); } + void processPPRealignedMuonOnly(MyEventsWithMults const& collisions, aod::BCsWithTimestamps const& bcs, + MyMuonsRealignWithCov const& tracksMuon, MFTTrackLabeled const& mftTracks, + aod::FwdTrackAssoc const& fwdTrackAssocs, aod::MFTTrackAssoc const& mftAssocs, + aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) + { + fullSkimming(collisions, bcs, nullptr, tracksMuon, mftTracks, nullptr, fwdTrackAssocs, mftAssocs, mcCollisions, mcParticles); + } + void processPbPb(MyEventsWithCentAndMults const& collisions, aod::BCsWithTimestamps const& bcs, - MyBarrelTracksWithCov const& tracksBarrel, MyMuonsWithCov const& tracksMuon, aod::MFTTracks const& mftTracks, + MyBarrelTracksWithCov const& tracksBarrel, MyMuonsWithCov const& tracksMuon, MFTTrackLabeled const& mftTracks, aod::TrackAssoc const& trackAssocs, aod::FwdTrackAssoc const& fwdTrackAssocs, aod::MFTTrackAssoc const& mftAssocs, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) { @@ -1170,14 +1393,29 @@ struct TableMakerMC { fullSkimming(collisions, bcs, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr, mcCollisions, mcParticles); } + void processPbPbWithFilterBarrelOnly(MyEventsWithMultsAndRapidityGapFilter const& collisions, aod::BCsWithTimestamps const& bcs, + MyBarrelTracksWithCov const& tracksBarrel, aod::TrackAssoc const& trackAssocs, + aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) + { + fullSkimming(collisions, bcs, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr, mcCollisions, mcParticles); + } + void processPbPbMuonOnly(MyEventsWithCentAndMults const& collisions, aod::BCsWithTimestamps const& bcs, - MyMuonsWithCov const& tracksMuon, aod::MFTTracks const& mftTracks, + MyMuonsWithCov const& tracksMuon, MFTTrackLabeled const& mftTracks, aod::FwdTrackAssoc const& fwdTrackAssocs, aod::MFTTrackAssoc const& mftAssocs, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) { fullSkimming(collisions, bcs, nullptr, tracksMuon, mftTracks, nullptr, fwdTrackAssocs, mftAssocs, mcCollisions, mcParticles); } + void processPbPbRealignedMuonOnly(MyEventsWithCentAndMults const& collisions, aod::BCsWithTimestamps const& bcs, + MyMuonsRealignWithCov const& tracksMuon, MFTTrackLabeled const& mftTracks, + aod::FwdTrackAssoc const& fwdTrackAssocs, aod::MFTTrackAssoc const& mftAssocs, + aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) + { + fullSkimming(collisions, bcs, nullptr, tracksMuon, mftTracks, nullptr, fwdTrackAssocs, mftAssocs, mcCollisions, mcParticles); + } + // Process the BCs and store stats for luminosity retrieval ----------------------------------------------------------------------------------- void processOnlyBCs(soa::Join::iterator const& bc) { @@ -1191,10 +1429,14 @@ struct TableMakerMC { PROCESS_SWITCH(TableMakerMC, processPP, "Produce both barrel and muon skims, pp settings", false); PROCESS_SWITCH(TableMakerMC, processPPBarrelOnly, "Produce only barrel skims, pp settings ", false); + PROCESS_SWITCH(TableMakerMC, processPPMuonOnlyBasic, "Produce only muon skims, pp settings, no multiplicity", false); PROCESS_SWITCH(TableMakerMC, processPPMuonOnly, "Produce only muon skims, pp settings", false); + PROCESS_SWITCH(TableMakerMC, processPPRealignedMuonOnly, "Build realigned muon only DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb", false); PROCESS_SWITCH(TableMakerMC, processPbPb, "Produce both barrel and muon skims, PbPb settings", false); PROCESS_SWITCH(TableMakerMC, processPbPbBarrelOnly, "Produce only barrel skims, PbPb settings", false); + PROCESS_SWITCH(TableMakerMC, processPbPbWithFilterBarrelOnly, "Produce only barrel skims, pp settings with rapidity gap filter ", false); PROCESS_SWITCH(TableMakerMC, processPbPbMuonOnly, "Produce only muon skims, PbPb settings", false); + PROCESS_SWITCH(TableMakerMC, processPbPbRealignedMuonOnly, "Build realigned muon only DQ skimmed data model typically for Pb-Pb, w/o event filtering", false); PROCESS_SWITCH(TableMakerMC, processOnlyBCs, "Analyze the BCs to store sampled lumi", false); }; diff --git a/PWGDQ/TableProducer/tableMakerMuonMchTrkEfficiency.cxx b/PWGDQ/TableProducer/tableMakerMuonMchTrkEfficiency.cxx index a15c1a98a8c..11634be2e0d 100644 --- a/PWGDQ/TableProducer/tableMakerMuonMchTrkEfficiency.cxx +++ b/PWGDQ/TableProducer/tableMakerMuonMchTrkEfficiency.cxx @@ -18,8 +18,10 @@ /// /// \author Zaida Conesa del Valle /// -#include + #include +#include +#include #include #include #include @@ -128,8 +130,8 @@ struct tableMakerMuonMchTrkEfficiency { using myMuons = soa::Join; using myMuonsMC = soa::Join; - using myReducedMuons = soa::Join; - using myReducedMuonsMC = soa::Join; + using myReducedMuons = soa::Join; + using myReducedMuonsMC = soa::Join; // bit maps used for the Fill functions of the VarManager constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision; diff --git a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx index 295fd1168cd..3b3d4c4e0af 100644 --- a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx +++ b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx @@ -36,6 +36,8 @@ #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/MftmchMatchingML.h" +#include "Common/DataModel/FwdTrackReAlignTables.h" +#include "Common/Core/TableHelper.h" #include "PWGDQ/DataModel/ReducedInfoTables.h" #include "PWGDQ/Core/VarManager.h" #include "PWGDQ/Core/HistogramManager.h" @@ -81,6 +83,9 @@ using MyBarrelTracksWithCov = soa::Join; +using MyBarrelTracksWithCovNoTOF = soa::Join; using MyBarrelTracksWithV0Bits = soa::Join; using MyEventsWithMults = soa::Join; using MyEventsWithFilter = soa::Join; using MyEventsWithMultsAndFilter = soa::Join; -using MyEventsWithCent = soa::Join; -using MyEventsWithCentAndMults = soa::Join; +using MyEventsWithMultsAndRapidityGapFilter = soa::Join; +using MyEventsWithCent = soa::Join; +using MyEventsWithCentAndMults = soa::Join; +using MyEventsWithMultsExtra = soa::Join; using MyMuons = soa::Join; using MyMuonsWithCov = soa::Join; +using MyMuonsRealignWithCov = soa::Join; using MyMuonsColl = soa::Join; using MyMuonsCollWithCov = soa::Join; using MyBCs = soa::Join; @@ -114,17 +122,21 @@ using ExtBCs = soa::Join fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"}; + Configurable fConfigEventCuts{"cfgEventCuts", "eventStandardNoINT7", "Event selection"}; Configurable fConfigTrackCuts{"cfgBarrelTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; Configurable fConfigMuonCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; + Configurable fConfigEventCutsJSON{"cfgEventCutsJSON", "", "Additional event selection in JSON format"}; + Configurable fConfigTrackCutsJSON{"cfgBarrelTrackCutsJSON", "", "Additional list of barrel track cuts in JSON format"}; + Configurable fConfigMuonCutsJSON{"cfgMuonCutsJSON", "", "Additional list of muon cuts in JSON format"}; } fConfigCuts; // Zorro selection struct : ConfigurableGroup { - Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; + Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro"}; Configurable fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"}; Configurable fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"}; + Configurable fBcTolerance{"cfgBcTolerance", 100, "Number of BCs of margin for software triggers"}; } fConfigZorro; // Steer QA output @@ -190,6 +206,7 @@ struct TableMaker { Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; Configurable fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"}; Configurable fConfigAddMuonHistogram{"cfgAddMuonHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; } fConfigHistOutput; Configurable fIsRun2{"cfgIsRun2", false, "Whether we analyze Run-2 or Run-3 data"}; @@ -223,8 +240,6 @@ struct TableMaker { Configurable fConfigComputeTPCpostCalibKaon{"cfgTPCpostCalibKaon", false, "If true, compute TPC post-calibrated n-sigmas for kaons"}; Configurable fConfigIsOnlyforMaps{"cfgIsforMaps", false, "If true, run for postcalibration maps only"}; Configurable fConfigSaveElectronSample{"cfgSaveElectronSample", false, "If true, only save electron sample"}; - Configurable fConfigDummyRunlist{"cfgDummyRunlist", false, "If true, use dummy runlist"}; - Configurable fConfigInitRunNumber{"cfgInitRunNumber", 543215, "Initial run number used in run by run checks"}; } fConfigPostCalibTPC; struct : ConfigurableGroup { @@ -250,9 +265,9 @@ struct TableMaker { o2::parameters::GRPObject* fGrpMagRun2 = nullptr; // for run 2, we access the GRPObject from GLO/GRP/GRP o2::parameters::GRPMagField* fGrpMag = nullptr; // for run 3, we access GRPMagField from GLO/Config/GRPMagField - AnalysisCompositeCut* fEventCut; //! Event selection cut - std::vector fTrackCuts; //! Barrel track cuts - std::vector fMuonCuts; //! Muon track cuts + AnalysisCompositeCut* fEventCut; //! Event selection cut + std::vector fTrackCuts; //! Barrel track cuts + std::vector fMuonCuts; //! Muon track cuts bool fDoDetailedQA = false; // Bool to set detailed QA true, if QA is set true int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. @@ -288,6 +303,10 @@ struct TableMaker { Partition tracksPosNoTOF = (((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)) && (aod::track::tgl > static_cast(0.05))); Partition tracksNegNoTOF = (((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)) && (aod::track::tgl < static_cast(-0.05))); + Preslice presliceWithCovNoTOF = aod::track::collisionId; + Partition tracksPosWithCovNoTOF = (((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)) && (aod::track::tgl > static_cast(0.05))); + Partition tracksNegWithCovNoTOF = (((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)) && (aod::track::tgl < static_cast(-0.05))); + struct { std::map oMeanTimeShortA; std::map oMeanTimeShortC; @@ -318,12 +337,12 @@ struct TableMaker { if (!o2::base::GeometryManager::isGeometryLoaded()) { fCCDB->get(fConfigCCDB.fConfigGeoPath); } + VarManager::SetDefaultVarNames(); // Important that this is called before DefineCuts() !! // Define the event, track and muon cuts DefineCuts(); // Initialize the histogram manager - VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); @@ -349,10 +368,11 @@ struct TableMaker { // Check whether we have to define barrel or muon histograms bool enableBarrelHistos = (context.mOptions.get("processPPWithFilter") || context.mOptions.get("processPPWithFilterBarrelOnly") || context.mOptions.get("processPPBarrelOnly") || - context.mOptions.get("processPbPb") || context.mOptions.get("processPbPbBarrelOnly") || context.mOptions.get("processPbPbBarrelOnlyWithV0Bits") || context.mOptions.get("processPbPbBarrelOnlyWithV0BitsNoTOF")); + context.mOptions.get("processPbPb") || context.mOptions.get("processPbPbBarrelOnly") || context.mOptions.get("processPbPbBarrelOnlyWithV0Bits") || context.mOptions.get("processPbPbBarrelOnlyWithV0BitsNoTOF")) || + context.mOptions.get("processPbPbWithFilterBarrelOnly") || context.mOptions.get("processPPBarrelOnlyWithV0s") || context.mOptions.get("processPbPbBarrelOnlyNoTOF"); - bool enableMuonHistos = (context.mOptions.get("processPPWithFilter") || context.mOptions.get("processPPWithFilterMuonOnly") || context.mOptions.get("processPPWithFilterMuonMFT") || context.mOptions.get("processPPMuonOnly") || context.mOptions.get("processPPMuonMFT") || - context.mOptions.get("processPbPb") || context.mOptions.get("processPbPbMuonOnly") || context.mOptions.get("processPbPbMuonMFT")); + bool enableMuonHistos = (context.mOptions.get("processPPWithFilter") || context.mOptions.get("processPPWithFilterMuonOnly") || context.mOptions.get("processPPWithFilterMuonMFT") || context.mOptions.get("processPPMuonOnly") || context.mOptions.get("processPPRealignedMuonOnly") || context.mOptions.get("processPPMuonMFT") || context.mOptions.get("processPPMuonMFTWithMultsExtra") || + context.mOptions.get("processPbPb") || context.mOptions.get("processPbPbMuonOnly") || context.mOptions.get("processPbPbRealignedMuonOnly") || context.mOptions.get("processPbPbMuonMFT")); if (enableBarrelHistos) { // Barrel track histograms, before selections @@ -362,7 +382,7 @@ struct TableMaker { if (fConfigHistOutput.fConfigQA) { // Barrel track histograms after selections; one histogram directory for each user specified selection for (auto& cut : fTrackCuts) { - histClasses += Form("TrackBarrel_%s;", cut.GetName()); + histClasses += Form("TrackBarrel_%s;", cut->GetName()); } } // Barrel histograms for clean samples of V0 legs used for post-calibration @@ -381,16 +401,17 @@ struct TableMaker { if (fConfigHistOutput.fConfigQA) { // Muon tracks after selections; one directory per selection for (auto& muonCut : fMuonCuts) { - histClasses += Form("Muons_%s;", muonCut.GetName()); + histClasses += Form("Muons_%s;", muonCut->GetName()); } } } - if (fConfigPostCalibTPC.fConfigDummyRunlist) { - VarManager::SetDummyRunlist(fConfigPostCalibTPC.fConfigInitRunNumber); + DefineHistograms(histClasses); // define all histograms + // Additional histogram via the JSON configurable + TString addHistsStr = fConfigHistOutput.fConfigAddJSONHistograms.value; + if (fConfigHistOutput.fConfigQA && addHistsStr != "") { + dqhistograms::AddHistogramsFromJSON(fHistMan, addHistsStr.Data()); } - - DefineHistograms(histClasses); // define all histograms VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -400,14 +421,32 @@ struct TableMaker { // Event cuts fEventCut = new AnalysisCompositeCut(true); TString eventCutStr = fConfigCuts.fConfigEventCuts.value; - fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); + if (eventCutStr != "") { + fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); + } + // Extra event cuts via JSON + TString addEvCutsStr = fConfigCuts.fConfigEventCutsJSON.value; + if (addEvCutsStr != "") { + std::vector addEvCuts = dqcuts::GetCutsFromJSON(addEvCutsStr.Data()); + for (auto& cutIt : addEvCuts) { + fEventCut->AddCut(cutIt); + } + } // Barrel track cuts TString cutNamesStr = fConfigCuts.fConfigTrackCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fTrackCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fTrackCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + } + } + // extra cuts via JSON + TString addTrackCutsStr = fConfigCuts.fConfigTrackCutsJSON.value; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + fTrackCuts.push_back(reinterpret_cast(t)); } } @@ -416,7 +455,15 @@ struct TableMaker { if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fMuonCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fMuonCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + } + } + // Extra cuts via JSON + TString addMuonCutsStr = fConfigCuts.fConfigMuonCutsJSON.value; + if (addMuonCutsStr != "") { + std::vector addMuonCuts = dqcuts::GetCutsFromJSON(addMuonCutsStr.Data()); + for (auto& t : addMuonCuts) { + fMuonCuts.push_back(reinterpret_cast(t)); } } @@ -500,7 +547,7 @@ struct TableMaker { TH1D* histTracks = new TH1D("TrackStats", "Track statistics", fTrackCuts.size() + 5.0, -0.5, fTrackCuts.size() - 0.5 + 5.0); ib = 1; for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++, ib++) { - histTracks->GetXaxis()->SetBinLabel(ib, (*cut).GetName()); + histTracks->GetXaxis()->SetBinLabel(ib, (*cut)->GetName()); } const char* v0TagNames[5] = {"Photon conversion", "K^{0}_{s}", "#Lambda", "#bar{#Lambda}", "#Omega"}; for (ib = 0; ib < 5; ib++) { @@ -511,7 +558,7 @@ struct TableMaker { TH1D* histMuons = new TH1D("MuonStats", "Muon statistics", fMuonCuts.size(), -0.5, fMuonCuts.size() - 0.5); ib = 1; for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++, ib++) { - histMuons->GetXaxis()->SetBinLabel(ib, (*cut).GetName()); + histMuons->GetXaxis()->SetBinLabel(ib, (*cut)->GetName()); } fStatsList->AddAt(histMuons, kStatsMuons); @@ -723,6 +770,8 @@ struct TableMaker { int multTracklets = -1.0; int multTracksPV = -1.0; float centFT0C = -1.0; + float centFT0A = -1.0; + float centFT0M = -1.0; for (const auto& collision : collisions) { @@ -734,7 +783,7 @@ struct TableMaker { (reinterpret_cast(fStatsList->At(kStatsEvent)))->Fill(1.0, static_cast(o2::aod::evsel::kNsel)); // apply the event filter computed by filter-PP - if constexpr ((TEventFillMap & VarManager::ObjTypes::EventFilter) > 0) { + if constexpr ((TEventFillMap & VarManager::ObjTypes::EventFilter) > 0 || (TEventFillMap & VarManager::ObjTypes::RapidityGapFilter) > 0) { if (!collision.eventFilter()) { continue; } @@ -750,7 +799,7 @@ struct TableMaker { tag |= (static_cast(1) << 0); } // Put the 8 first bits of the event filter in the last 8 bits of the tag - if constexpr ((TEventFillMap & VarManager::ObjTypes::EventFilter) > 0) { + if constexpr ((TEventFillMap & VarManager::ObjTypes::EventFilter) > 0 || (TEventFillMap & VarManager::ObjTypes::RapidityGapFilter) > 0) { tag |= (collision.eventFilter() << 56); } @@ -758,7 +807,10 @@ struct TableMaker { VarManager::FillBC(bc); VarManager::FillEvent(collision); // extract event information and place it in the fValues array if constexpr ((TEventFillMap & VarManager::ObjTypes::Zdc) > 0) { - if (bcEvSel.has_zdc()) { + if constexpr ((TEventFillMap & VarManager::ObjTypes::RapidityGapFilter) > 0) { + // Collision table already has ZDC info + VarManager::FillZDC(collision); + } else if (bcEvSel.has_zdc()) { auto bc_zdc = bcEvSel.zdc(); VarManager::FillZDC(bc_zdc); } @@ -796,9 +848,10 @@ struct TableMaker { if (fConfigZorro.fConfigRunZorro) { zorro.setBaseCCDBPath(fConfigCCDB.fConfigCcdbPathZorro.value); + zorro.setBCtolerance(fConfigZorro.fBcTolerance); zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), fConfigZorro.fConfigZorroTrigMask.value); zorro.populateExternalHists(fCurrentRun, reinterpret_cast(fStatsList->At(kStatsZorroInfo)), reinterpret_cast(fStatsList->At(kStatsZorroSel))); - bool zorroSel = zorro.isSelected(bc.globalBC(), 100UL, reinterpret_cast(fStatsList->At(kStatsZorroSel))); + bool zorroSel = zorro.isSelected(bc.globalBC(), fConfigZorro.fBcTolerance, reinterpret_cast(fStatsList->At(kStatsZorroSel))); if (zorroSel) { tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb } @@ -824,27 +877,42 @@ struct TableMaker { // create the event tables event(tag, bc.runNumber(), collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), collision.collisionTime(), collision.collisionTimeRes()); if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMult) > 0) { - multTPC = collision.multTPC(); - multFV0A = collision.multFV0A(); multFV0C = collision.multFV0C(); - multFT0A = collision.multFT0A(); - multFT0C = collision.multFT0C(); - multFDDA = collision.multFDDA(); - multFDDC = collision.multFDDC(); + multTPC = collision.multTPC(); multZNA = collision.multZNA(); multZNC = collision.multZNC(); multTracklets = collision.multTracklets(); multTracksPV = collision.multNTracksPV(); + if constexpr ((TEventFillMap & VarManager::ObjTypes::RapidityGapFilter) > 0) { + // Use the FIT signals from the nearest BC with FIT amplitude above threshold + multFV0A = collision.newBcMultFV0A(); + multFT0A = collision.newBcMultFT0A(); + multFT0C = collision.newBcMultFT0C(); + multFDDA = collision.newBcMultFDDA(); + multFDDC = collision.newBcMultFDDC(); + } else { + multFV0A = collision.multFV0A(); + multFT0A = collision.multFT0A(); + multFT0C = collision.multFT0C(); + multFDDA = collision.multFDDA(); + multFDDC = collision.multFDDC(); + } } if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionCent) > 0) { centFT0C = collision.centFT0C(); + centFT0A = collision.centFT0A(); + centFT0M = collision.centFT0M(); } eventExtended(bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), VarManager::fgValues[VarManager::kCentVZERO], - multTPC, multFV0A, multFV0C, multFT0A, multFT0C, multFDDA, multFDDC, multZNA, multZNC, multTracklets, multTracksPV, centFT0C); + multTPC, multFV0A, multFV0C, multFT0A, multFT0C, multFDDA, multFDDC, multZNA, multZNC, multTracklets, multTracksPV, centFT0C, centFT0A, centFT0M); eventVtxCov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); eventInfo(collision.globalIndex()); if constexpr ((TEventFillMap & VarManager::ObjTypes::Zdc) > 0) { - if (bcEvSel.has_zdc()) { + if constexpr ((TEventFillMap & VarManager::ObjTypes::RapidityGapFilter) > 0) { + // ZDC information is already in the DQRapidityGapFilter + zdc(collision.energyCommonZNA(), collision.energyCommonZNC(), collision.energyCommonZPA(), collision.energyCommonZPC(), + collision.timeZNA(), collision.timeZNC(), collision.timeZPA(), collision.timeZPC()); + } else if (bcEvSel.has_zdc()) { auto bc_zdc = bcEvSel.zdc(); zdc(bc_zdc.energyCommonZNA(), bc_zdc.energyCommonZNC(), bc_zdc.energyCommonZPA(), bc_zdc.energyCommonZPC(), bc_zdc.timeZNA(), bc_zdc.timeZNC(), bc_zdc.timeZPA(), bc_zdc.timeZPC()); @@ -854,7 +922,8 @@ struct TableMaker { } if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMultExtra) > 0) { multPV(collision.multNTracksHasITS(), collision.multNTracksHasTPC(), collision.multNTracksHasTOF(), collision.multNTracksHasTRD(), - collision.multNTracksITSOnly(), collision.multNTracksTPCOnly(), collision.multNTracksITSTPC(), collision.trackOccupancyInTimeRange()); + collision.multNTracksITSOnly(), collision.multNTracksTPCOnly(), collision.multNTracksITSTPC(), + collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); multAll(collision.multAllTracksTPCOnly(), collision.multAllTracksITSTPC(), fOccup.oContribLongA[collision.globalIndex()], fOccup.oContribLongC[collision.globalIndex()], @@ -912,12 +981,12 @@ struct TableMaker { // apply track cuts and fill stats histogram int i = 0; for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++, i++) { - if ((*cut).IsSelected(VarManager::fgValues)) { + if ((*cut)->IsSelected(VarManager::fgValues)) { trackTempFilterMap |= (static_cast(1) << i); // NOTE: the QA is filled here just for the first occurence of this track. // So if there are histograms of quantities which depend on the collision association, these will not be accurate if (fConfigHistOutput.fConfigQA && (fTrackIndexMap.find(track.globalIndex()) == fTrackIndexMap.end())) { - fHistMan->FillHistClass(Form("TrackBarrel_%s", (*cut).GetName()), VarManager::fgValues); + fHistMan->FillHistClass(Form("TrackBarrel_%s", (*cut)->GetName()), VarManager::fgValues); } (reinterpret_cast(fStatsList->At(kStatsTracks)))->Fill(static_cast(i)); } @@ -1074,10 +1143,18 @@ struct TableMaker { uint32_t counter = 0; for (const auto& assoc : muonAssocs) { // get the muon - auto muon = assoc.template fwdtrack_as(); + auto muon = muons.rawIteratorAt(assoc.fwdtrackId()); trackFilteringTag = static_cast(0); trackTempFilterMap = static_cast(0); + + if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonRealign)) { + // Check refit flag in case of realigned muons + if (static_cast(muon.isRemovable())) { + continue; + } + } + VarManager::FillTrack(muon); // NOTE: Muons are propagated to the current associated collisions. // So if a muon is associated to multiple collisions, depending on the selections, @@ -1106,13 +1183,13 @@ struct TableMaker { // check the cuts and filters int i = 0; for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++, i++) { - if ((*cut).IsSelected(VarManager::fgValues)) { + if ((*cut)->IsSelected(VarManager::fgValues)) { trackTempFilterMap |= (static_cast(1) << i); // NOTE: the QA is filled here just for the first occurence of this muon, which means the current association // will be skipped from histograms if this muon was already filled in the skimming map. // So if there are histograms of quantities which depend on the collision association, these histograms will not be completely accurate if (fConfigHistOutput.fConfigQA && (fFwdTrackIndexMap.find(muon.globalIndex()) == fFwdTrackIndexMap.end())) { - fHistMan->FillHistClass(Form("Muons_%s", (*cut).GetName()), VarManager::fgValues); + fHistMan->FillHistClass(Form("Muons_%s", (*cut)->GetName()), VarManager::fgValues); } (reinterpret_cast(fStatsList->At(kStatsMuons)))->Fill(static_cast(i)); } @@ -1163,28 +1240,38 @@ struct TableMaker { mftIdx = fMftIndexMap[muon.matchMFTTrackId()]; } } + + if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonRealign)) { + // Check refit flag in case of realigned muons + if (static_cast(muon.isRemovable())) { + continue; + } + } + VarManager::FillTrack(muon); if (fConfigVariousOptions.fPropMuon) { VarManager::FillPropagateMuon(muon, collision); } // recalculte pDca and global muon kinematics + int globalClusters = muon.nClusters(); if (static_cast(muon.trackType()) < 2 && fConfigVariousOptions.fRefitGlobalMuon) { auto muontrack = muon.template matchMCHTrack_as(); auto mfttrack = muon.template matchMFTTrack_as(); + globalClusters += mfttrack.nClusters(); VarManager::FillTrackCollision(muontrack, collision); VarManager::FillGlobalMuonRefit(muontrack, mfttrack, collision); } else { VarManager::FillTrackCollision(muon, collision); } muonBasic(reducedEventIdx, mchIdx, mftIdx, fFwdTrackFilterMap[muon.globalIndex()], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], muon.sign(), 0); - muonExtra(muon.nClusters(), VarManager::fgValues[VarManager::kMuonPDca], VarManager::fgValues[VarManager::kMuonRAtAbsorberEnd], - muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), + muonExtra(globalClusters, VarManager::fgValues[VarManager::kMuonPDca], VarManager::fgValues[VarManager::kMuonRAtAbsorberEnd], + VarManager::fgValues[VarManager::kMuonChi2], muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), muon.midBoards(), muon.trackType(), VarManager::fgValues[VarManager::kMuonDCAx], VarManager::fgValues[VarManager::kMuonDCAy], muon.trackTime(), muon.trackTimeRes()); muonInfo(muon.collisionId(), collision.posX(), collision.posY(), collision.posZ()); - if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCov)) { + if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCov) || static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCovRealign)) { muonCov(VarManager::fgValues[VarManager::kX], VarManager::fgValues[VarManager::kY], VarManager::fgValues[VarManager::kZ], VarManager::fgValues[VarManager::kPhi], VarManager::fgValues[VarManager::kTgl], muon.sign() / VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kMuonCXX], VarManager::fgValues[VarManager::kMuonCXY], VarManager::fgValues[VarManager::kMuonCYY], VarManager::fgValues[VarManager::kMuonCPhiX], VarManager::fgValues[VarManager::kMuonCPhiY], VarManager::fgValues[VarManager::kMuonCPhiPhi], VarManager::fgValues[VarManager::kMuonCTglX], VarManager::fgValues[VarManager::kMuonCTglY], VarManager::fgValues[VarManager::kMuonCTglPhi], VarManager::fgValues[VarManager::kMuonCTglTgl], VarManager::fgValues[VarManager::kMuonC1Pt2X], VarManager::fgValues[VarManager::kMuonC1Pt2Y], @@ -1226,6 +1313,9 @@ struct TableMaker { if (fGrpMag != nullptr) { o2::base::Propagator::initFieldFromGRP(fGrpMag); } + if (fConfigVariousOptions.fPropMuon) { + VarManager::SetupMuonMagField(); + } } std::map metadataRCT, header; header = fCCDBApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", bcs.begin().runNumber()), metadataRCT, -1); @@ -1298,9 +1388,9 @@ struct TableMaker { } } // end loop over skimmed collisions - LOG(info) << "Skims in this TF: " << fCollIndexMap.size() << " collisions; " << trackBasic.lastIndex() << " barrel tracks; " - << muonBasic.lastIndex() << " muon tracks; " << mftTrack.lastIndex() << " MFT tracks; "; - LOG(info) << " " << trackBarrelAssoc.lastIndex() << " barrel assocs; " << muonAssoc.lastIndex() << " muon assocs; " << mftAssoc.lastIndex() << " MFT assoc"; + // LOG(info) << "Skims in this TF: " << fCollIndexMap.size() << " collisions; " << trackBasic.lastIndex() << " barrel tracks; " + //<< muonBasic.lastIndex() << " muon tracks; " << mftTrack.lastIndex() << " MFT tracks; "; + // LOG(info) << " " << trackBarrelAssoc.lastIndex() << " barrel assocs; " << muonAssoc.lastIndex() << " muon assocs; " << mftAssoc.lastIndex() << " MFT assoc"; } // produce the full DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), subscribe to the DQ event filter (filter-pp or filter-PbPb) @@ -1344,6 +1434,14 @@ struct TableMaker { fullSkimming(collisions, bcs, zdcs, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr); } + // produce the barrel-only DQ skimmed barrel data model, with V0 tagged tracks + void processPPBarrelOnlyWithV0s(MyEventsWithMults const& collisions, MyBCs const& bcs, + MyBarrelTracksWithV0BitsNoTOF const& tracksBarrel, + TrackAssoc const& trackAssocs) + { + fullSkimming(collisions, bcs, nullptr, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr); + } + // produce the muon-only DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), meant to run on skimmed data void processPPMuonOnly(MyEventsWithMults const& collisions, BCsWithTimestamps const& bcs, MyMuonsWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs) @@ -1351,6 +1449,13 @@ struct TableMaker { fullSkimming(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr); } + // produce the realigned muon-only DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), meant to run on skimmed data + void processPPRealignedMuonOnly(MyEventsWithMults const& collisions, BCsWithTimestamps const& bcs, + MyMuonsRealignWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs) + { + fullSkimming(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr); + } + // produce the muon+mft DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), meant to run on skimmed data void processPPMuonMFT(MyEventsWithMults const& collisions, BCsWithTimestamps const& bcs, MyMuonsWithCov const& muons, MFTTracks const& mftTracks, @@ -1359,6 +1464,14 @@ struct TableMaker { fullSkimming(collisions, bcs, nullptr, nullptr, muons, mftTracks, nullptr, fwdTrackAssocs, mftAssocs); } + // Central barrel multiplicity estimation + void processPPMuonMFTWithMultsExtra(MyEventsWithMultsExtra const& collisions, BCsWithTimestamps const& bcs, + MyMuonsWithCov const& muons, MFTTracks const& mftTracks, + FwdTrackAssoc const& fwdTrackAssocs, MFTTrackAssoc const& mftAssocs) + { + fullSkimming(collisions, bcs, nullptr, nullptr, muons, mftTracks, nullptr, fwdTrackAssocs, mftAssocs); + } + // produce the full DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter void processPbPb(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs, MyBarrelTracksWithCov const& tracksBarrel, @@ -1377,6 +1490,23 @@ struct TableMaker { fullSkimming(collisions, bcs, nullptr, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr); } + // produce the barrel only DQ skimmed data model typically for Pb-Pb (with centrality), no TOF + void processPbPbBarrelOnlyNoTOF(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs, + MyBarrelTracksWithCovNoTOF const& tracksBarrel, + TrackAssoc const& trackAssocs) + { + computeOccupancyEstimators(collisions, tracksPosWithCovNoTOF, tracksNegWithCovNoTOF, presliceWithCovNoTOF, bcs); + fullSkimming(collisions, bcs, nullptr, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr); + } + + // produce the barrel-only DQ skimmed data model typically for UPC Pb-Pb (no centrality), subscribe to the DQ rapidity gap event filter (filter-PbPb) + void processPbPbWithFilterBarrelOnly(MyEventsWithMultsAndRapidityGapFilter const& collisions, MyBCs const& bcs, aod::Zdcs& zdcs, + MyBarrelTracksWithCov const& tracksBarrel, + TrackAssoc const& trackAssocs) + { + fullSkimming(collisions, bcs, zdcs, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr); + } + // produce the barrel only DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter void processPbPbBarrelOnlyWithV0Bits(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs, MyBarrelTracksWithV0Bits const& tracksBarrel, @@ -1402,6 +1532,13 @@ struct TableMaker { fullSkimming(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr); } + // produce the realigned muon only DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter + void processPbPbRealignedMuonOnly(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs, + MyMuonsRealignWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs) + { + fullSkimming(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr); + } + // produce the muon+mft DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter void processPbPbMuonMFT(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs, MyMuonsWithCov const& muons, MFTTracks const& mftTracks, @@ -1426,13 +1563,19 @@ struct TableMaker { PROCESS_SWITCH(TableMaker, processPPWithFilterMuonOnly, "Build muon only DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb, w/ event filtering", false); PROCESS_SWITCH(TableMaker, processPPWithFilterMuonMFT, "Build muon + mft DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb, w/ event filtering", false); PROCESS_SWITCH(TableMaker, processPPBarrelOnly, "Build barrel only DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb", false); + PROCESS_SWITCH(TableMaker, processPPBarrelOnlyWithV0s, "Build barrel only DQ skimmed data model, pp like, with V0 tagged tracks", false); PROCESS_SWITCH(TableMaker, processPPMuonOnly, "Build muon only DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb", false); + PROCESS_SWITCH(TableMaker, processPPRealignedMuonOnly, "Build realigned muon only DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb", false); PROCESS_SWITCH(TableMaker, processPPMuonMFT, "Build muon + mft DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb", false); + PROCESS_SWITCH(TableMaker, processPPMuonMFTWithMultsExtra, "Build muon + mft DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb", false); PROCESS_SWITCH(TableMaker, processPbPb, "Build full DQ skimmed data model typically for Pb-Pb, w/o event filtering", false); PROCESS_SWITCH(TableMaker, processPbPbBarrelOnly, "Build barrel only DQ skimmed data model typically for Pb-Pb, w/o event filtering", false); + PROCESS_SWITCH(TableMaker, processPbPbBarrelOnlyNoTOF, "Build barrel only DQ skimmed data model typically for Pb-Pb, w/o event filtering, no TOF", false); + PROCESS_SWITCH(TableMaker, processPbPbWithFilterBarrelOnly, "Build barrel only DQ skimmed data model typically for UPC Pb-Pb, w/ event filtering", false); PROCESS_SWITCH(TableMaker, processPbPbBarrelOnlyWithV0Bits, "Build barrel only DQ skimmed data model typically for Pb-Pb, w/ V0 bits, w/o event filtering", false); PROCESS_SWITCH(TableMaker, processPbPbBarrelOnlyWithV0BitsNoTOF, "Build barrel only DQ skimmed data model typically for Pb-Pb, w/ V0 bits, no TOF, w/o event filtering", false); PROCESS_SWITCH(TableMaker, processPbPbMuonOnly, "Build muon only DQ skimmed data model typically for Pb-Pb, w/o event filtering", false); + PROCESS_SWITCH(TableMaker, processPbPbRealignedMuonOnly, "Build realigned muon only DQ skimmed data model typically for Pb-Pb, w/o event filtering", false); PROCESS_SWITCH(TableMaker, processPbPbMuonMFT, "Build muon + mft DQ skimmed data model typically for Pb-Pb, w/o event filtering", false); PROCESS_SWITCH(TableMaker, processOnlyBCs, "Analyze the BCs to store sampled lumi", false); }; diff --git a/PWGDQ/Tasks/CMakeLists.txt b/PWGDQ/Tasks/CMakeLists.txt index f64f67ee394..5095140a2b8 100644 --- a/PWGDQ/Tasks/CMakeLists.txt +++ b/PWGDQ/Tasks/CMakeLists.txt @@ -41,7 +41,7 @@ o2physics_add_dpl_workflow(filter-pp-with-association o2physics_add_dpl_workflow(filter-pb-pb SOURCES filterPbPb.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGDQCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGDQCore O2Physics::SGCutParHolder COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(v0-selector @@ -112,4 +112,19 @@ o2physics_add_dpl_workflow(task-fwd-track-pid o2physics_add_dpl_workflow(quarkonia-to-hyperons SOURCES quarkoniaToHyperons.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(model-converter-mult-pv + SOURCES ModelConverterMultPv.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGDQCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(model-converter-event-extended + SOURCES ModelConverterEventExtended.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGDQCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(tag-and-probe + SOURCES TagAndProbe.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::PWGDQCore COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGDQ/Tasks/MIDefficiency.cxx b/PWGDQ/Tasks/MIDefficiency.cxx index 13377e5cc5c..3dcbcc4d595 100644 --- a/PWGDQ/Tasks/MIDefficiency.cxx +++ b/PWGDQ/Tasks/MIDefficiency.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/PWGDQ/Tasks/ModelConverterEventExtended.cxx b/PWGDQ/Tasks/ModelConverterEventExtended.cxx new file mode 100644 index 00000000000..ec0a6a0c4be --- /dev/null +++ b/PWGDQ/Tasks/ModelConverterEventExtended.cxx @@ -0,0 +1,53 @@ +// 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. +// +// Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no +// +// Task used to convert the data model from the old format to the new format. To avoid +// the conflict with the old data model. + +// other includes +#include "PWGDQ/DataModel/ReducedInfoTables.h" + +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod; + +struct eventExtendedConverter000_001 { + Produces eventExtended_001; + + void process(aod::ReducedEventsExtended_000 const& events) + { + for (const auto& event : events) { + eventExtended_001(event.globalBC(), event.alias_raw(), event.selection_raw(), event.timestamp(), event.centRun2V0M(), + event.multTPC(), event.multFV0A(), event.multFV0C(), event.multFT0A(), event.multFT0C(), + event.multFDDA(), event.multFDDC(), event.multZNA(), event.multZNC(), event.multTracklets(), event.multNTracksPV(), + event.centFT0C(), -1.0f, -1.0f); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGDQ/Tasks/ModelConverterMultPv.cxx b/PWGDQ/Tasks/ModelConverterMultPv.cxx new file mode 100644 index 00000000000..088590435b8 --- /dev/null +++ b/PWGDQ/Tasks/ModelConverterMultPv.cxx @@ -0,0 +1,56 @@ +// 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. +// +// Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no +// +// Task used to convert the data model from the old format to the new format. To avoid +// the conflict with the old data model. + +// other includes +#include +#include +#include +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "PWGDQ/DataModel/ReducedInfoTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod; + +struct MultPVConverter000_001 { + Produces multPV_001; + void processConverting(aod::ReducedEventsMultPV_000 const& multsPV) + { + for (const auto& r : multsPV) { + multPV_001(r.multNTracksHasITS(), r.multNTracksHasTPC(), r.multNTracksHasTOF(), r.multNTracksHasTRD(), + r.multNTracksITSOnly(), r.multNTracksTPCOnly(), r.multNTracksITSTPC(), -1.0f, -1.0f, r.trackOccupancyInTimeRange(), -999.0f); + } + } + + void processDummy(o2::aod::ReducedEvents&) + { + // do nothing + } + + PROCESS_SWITCH(MultPVConverter000_001, processConverting, "Convert Table MultPV_000 to Table MultPV_001", false); + PROCESS_SWITCH(MultPVConverter000_001, processDummy, "do nothing", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGDQ/Tasks/TagAndProbe.cxx b/PWGDQ/Tasks/TagAndProbe.cxx new file mode 100644 index 00000000000..33bfe2ea06c --- /dev/null +++ b/PWGDQ/Tasks/TagAndProbe.cxx @@ -0,0 +1,442 @@ +// 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. +// +/// \file TagAndProbe.cxx +/// \brief Task Tag-And-Probe matching efficiency studies + +#include "PWGDQ/Core/AnalysisCompositeCut.h" +#include "PWGDQ/Core/AnalysisCut.h" +#include "PWGDQ/Core/CutsLibrary.h" +#include "PWGDQ/Core/HistogramManager.h" +#include "PWGDQ/Core/HistogramsLibrary.h" +#include "PWGDQ/Core/MixingHandler.h" +#include "PWGDQ/Core/MixingLibrary.h" +#include "PWGDQ/Core/VarManager.h" +#include "PWGDQ/DataModel/ReducedInfoTables.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/TableHelper.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Field/MagneticField.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" +#include "Framework/OutputObjHeader.h" +#include "Framework/runDataProcessing.h" +#include "ITSMFTBase/DPLAlpideParam.h" + +#include "TGeoGlobalMagField.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using std::cout; +using std::endl; +using std::string; + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod; + +// Some definitions +namespace o2::aod +{ +namespace dqanalysisflags +{ +DECLARE_SOA_BITMAP_COLUMN(IsEventSelected, isEventSelected, 8); //! Event decision +DECLARE_SOA_BITMAP_COLUMN(IsMuonSelected, isMuonSelected, 32); //! Muon track decisions (joinable to ReducedMuonsAssoc) +} // namespace dqanalysisflags + +DECLARE_SOA_TABLE(EventCuts, "AOD", "DQANAEVCUTSA", dqanalysisflags::IsEventSelected); //! joinable to ReducedEvents +DECLARE_SOA_TABLE(MuonTrackCuts, "AOD", "DQANAMUONCUTSA", dqanalysisflags::IsMuonSelected); //! joinable to ReducedMuonsAssoc //! joinable to ReducedTracksAssoc +} // namespace o2::aod + +// Declarations of various short names +using MyEvents = soa::Join; +using MyEventsVtxCov = soa::Join; + +using MyMuonTracksWithCov = soa::Join; + +// bit maps used for the Fill functions of the VarManager +constexpr static uint32_t gkEventFillMapWithCov = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov; + +constexpr static uint32_t gkMuonFillMapWithCov = VarManager::ObjTypes::ReducedMuon | VarManager::ObjTypes::ReducedMuonExtra | VarManager::ObjTypes::ReducedMuonCov; + +// Global function used to define needed histogram classes +void DefineHistograms(HistogramManager* histMan, TString histClasses, const char* histGroups); // defines histograms for all tasks + +template +void PrintBitMap(TMap map, int nbits) +{ + for (int i = 0; i < nbits; i++) { + cout << ((map & (TMap(1) << i)) > 0 ? "1" : "0"); + } +} + +// Run the AnalysisTagAndProbe +// This task assumes that both legs of the resonance fulfill the same cuts (symmetric decay channel) +// Runs combinatorics for muon-muon combinations +struct AnalysisTagAndProbe { + + o2::base::MatLayerCylSet* fLUT = nullptr; + int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. + + OutputObj fOutputList{"output"}; + + struct : ConfigurableGroup { + Configurable muon{"cfgMuonCuts", "", "Comma separated list of muon cuts"}; + // TODO: Add pair cuts via JSON + } fConfigCuts; + + Configurable fConfigAddSEPHistogram{"cfgAddSEPHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigQA{"cfgQA", true, "If true, fill output histograms"}; + + struct : ConfigurableGroup { + Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + } fConfigCCDB; + + struct : ConfigurableGroup { + Configurable useRemoteField{"cfgUseRemoteField", false, "Chose whether to fetch the magnetic field from ccdb or set it manually"}; + Configurable magField{"cfgMagField", 5.0f, "Manually set magnetic field"}; + Configurable flatTables{"cfgFlatTables", false, "Produce a single flat tables with all relevant information of the pairs and single tracks"}; + Configurable useKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"}; + Configurable useAbsDCA{"cfgUseAbsDCA", false, "Use absolute DCA minimization instead of chi^2 minimization in secondary vertexing"}; + Configurable propToPCA{"cfgPropToPCA", false, "Propagate tracks to secondary vertex"}; + Configurable corrFullGeo{"cfgCorrFullGeo", false, "Use full geometry to correct for MCS effects in track propagation"}; + Configurable noCorr{"cfgNoCorrFwdProp", false, "Do not correct for MCS effects in track propagation"}; + Configurable collisionSystem{"syst", "pp", "Collision system, pp or PbPb"}; + Configurable centerMassEnergy{"energy", 13600, "Center of mass energy in GeV"}; + Configurable propTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; + } fConfigOptions; + + Service fCCDB; + o2::ccdb::CcdbApi fCCDBApi; + + HistogramManager* fHistMan; + + // keep histogram class names in maps, so we don't have to buld their names in the pair loops + std::map> fMuonHistNames; + + uint32_t fMuonFilterMask; // mask for the muon cuts required in this task to be applied on the muon cuts produced upstream + int fNCutsMuon; + + bool fEnableMuonHistos; + + Preslice muonAssocsPerCollision = aod::reducedtrack_association::reducedeventId; + + void init(o2::framework::InitContext& context) + { + fEnableMuonHistos = context.mOptions.get("processMuonTagAndProbe"); + + if (context.mOptions.get("processDummy")) { + if (fEnableMuonHistos) { + LOG(fatal) << "No other processing tasks should be enabled if the processDummy is enabled!!"; + } + return; + } + VarManager::SetDefaultVarNames(); + + // Keep track of all the histogram class names to avoid composing strings in the pairing loop + TString histNames = ""; + std::vector names; + + // get the list of cuts for muons + // and make a mask for active cuts (muon selection tasks may run more cuts, needed for other analyses) + TString muonCutsStr = fConfigCuts.muon.value; + TObjArray* objArrayMuonCuts = nullptr; + if (!muonCutsStr.IsNull()) { + objArrayMuonCuts = muonCutsStr.Tokenize(","); + } + + // get the muon track selection cuts + TString tempCutsStr = fConfigCuts.muon.value; + + if (!muonCutsStr.IsNull()) { + std::unique_ptr objArray(tempCutsStr.Tokenize(",")); + fNCutsMuon = objArray->GetEntries(); + for (int icut = 0; icut < objArray->GetEntries(); ++icut) { + TString tempStr = objArray->At(icut)->GetName(); + if (objArrayMuonCuts->FindObject(tempStr.Data()) != nullptr) { + fMuonFilterMask |= (static_cast(1) << icut); + + if (fEnableMuonHistos) { + // no pair cuts + names = { + Form("PairsMuonSEPM_%s", objArray->At(icut)->GetName()), + Form("PairsMuonSEPM_%s_PassingProbes", objArray->At(icut)->GetName()), + Form("PairsMuonSEPM_%s_FailingProbes", objArray->At(icut)->GetName())}; + histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); + fMuonHistNames[icut] = names; + } + } + } + } + + fCurrentRun = 0; + + fCCDB->setURL(fConfigCCDB.url.value); + fCCDB->setCaching(true); + fCCDB->setLocalObjectValidityChecking(); + fCCDBApi.init(fConfigCCDB.url.value); + + if (fConfigOptions.noCorr) { + VarManager::SetupFwdDCAFitterNoCorr(); + } else if (fConfigOptions.corrFullGeo || (fConfigOptions.useKFVertexing && fConfigOptions.propToPCA)) { + if (!o2::base::GeometryManager::isGeometryLoaded()) { + fCCDB->get(fConfigCCDB.geoPath); + } + } else { + fLUT = o2::base::MatLayerCylSet::rectifyPtrFromFile(fCCDB->get(fConfigCCDB.lutPath)); + VarManager::SetupMatLUTFwdDCAFitter(fLUT); + } + + if (fConfigQA) { + fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); + fHistMan->SetUseDefaultVariableNames(true); + fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); + VarManager::SetCollisionSystem((TString)fConfigOptions.collisionSystem, fConfigOptions.centerMassEnergy); // set collision system and center of mass energy + DefineHistograms(fHistMan, histNames.Data(), fConfigAddSEPHistogram.value.data()); // define all histograms + // dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON + VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill + fOutputList.setObject(fHistMan->GetMainHistogramList()); + } + } + + void initParamsFromCCDB(uint64_t timestamp, int runNumber, bool withTwoProngFitter = true) + { + + if (fConfigOptions.useRemoteField.value) { + o2::parameters::GRPMagField* grpmag = fCCDB->getForTimeStamp(fConfigCCDB.grpMagPath, timestamp); + float magField = 0.0; + if (grpmag != nullptr) { + magField = grpmag->getNominalL3Field(); + } else { + LOGF(fatal, "GRP object is not available in CCDB at timestamp=%llu", timestamp); + } + if (withTwoProngFitter) { + if (fConfigOptions.useKFVertexing.value) { + VarManager::SetupTwoProngKFParticle(magField); + } else { + VarManager::SetupTwoProngDCAFitter(magField, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, fConfigOptions.useAbsDCA.value); // TODO: get these parameters from Configurables + VarManager::SetupTwoProngFwdDCAFitter(magField, true, 200.0f, 1.0e-3f, 0.9f, fConfigOptions.useAbsDCA.value); + } + } else { + VarManager::SetupTwoProngDCAFitter(magField, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, fConfigOptions.useAbsDCA.value); // needed because take in varmanager Bz from fgFitterTwoProngBarrel for PhiV calculations + } + } else { + if (withTwoProngFitter) { + if (fConfigOptions.useKFVertexing.value) { + VarManager::SetupTwoProngKFParticle(fConfigOptions.magField.value); + } else { + VarManager::SetupTwoProngDCAFitter(fConfigOptions.magField.value, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, fConfigOptions.useAbsDCA.value); // TODO: get these parameters from Configurables + VarManager::SetupTwoProngFwdDCAFitter(fConfigOptions.magField.value, true, 200.0f, 1.0e-3f, 0.9f, fConfigOptions.useAbsDCA.value); + } + } else { + VarManager::SetupTwoProngDCAFitter(fConfigOptions.magField.value, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, fConfigOptions.useAbsDCA.value); // needed because take in varmanager Bz from fgFitterTwoProngBarrel for PhiV calculations + } + } + + std::map metadataRCT, header; + header = fCCDBApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", runNumber), metadataRCT, -1); + uint64_t sor = std::atol(header["SOR"].c_str()); + uint64_t eor = std::atol(header["EOR"].c_str()); + VarManager::SetSORandEOR(sor, eor); + } + + // Template function to run run Tag And Probe (muon-muon) + template + void runTagAndProbe(TEvents const& events, Preslice& preslice, TTrackAssocs const& assocs, TTracks const& /*tracks*/) + { + if (events.size() > 0) { // Additional protection to avoid crashing of events.begin().runNumber() + if (fCurrentRun != events.begin().runNumber()) { + initParamsFromCCDB(events.begin().timestamp(), events.begin().runNumber(), TTwoProngFitter); + fCurrentRun = events.begin().runNumber(); + } + } + + TString cutNames = fConfigCuts.muon.value; + std::map> histNames = fMuonHistNames; + int ncuts = fNCutsMuon; + int sign1 = 0; + int sign2 = 0; + + if (events.size() > 0) { + for (auto& event : events) { + // Reset the fValues array + VarManager::ResetValues(0, VarManager::kNVars); + // VarManager::FillEvent(event, VarManager::fgValues); + VarManager::FillEvent(event, VarManager::fgValues); + + auto groupedAssocs = assocs.sliceBy(preslice, event.globalIndex()); + if (groupedAssocs.size() == 0) { + continue; + } + + for (auto& [a1, a2] : o2::soa::combinations(groupedAssocs, groupedAssocs)) { + if constexpr (TPairType == VarManager::kDecayToMuMu) { + + auto t1 = a1.template reducedmuon_as(); + auto t2 = a2.template reducedmuon_as(); + if (t1.matchMCHTrackId() == t2.matchMCHTrackId() && t1.matchMCHTrackId() >= 0) + continue; + if (t1.matchMFTTrackId() == t2.matchMFTTrackId() && t1.matchMFTTrackId() >= 0) + continue; + sign1 = t1.sign(); + sign2 = t2.sign(); + + VarManager::FillPair(t1, t2); + + for (int icut = 0; icut < ncuts; icut++) { + if (sign1 * sign2 < 0) { + fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); + + if (static_cast(t1.trackType()) == 3) { // t1 is the tag (track MCHMID) + if (static_cast(t2.trackType()) == 3) { // t2 is the passing probe (track MCHMID) + fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); + } else if (static_cast(t2.trackType()) == 4) { // t2 is the failing probe (MCHStandalone) + fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues); + } else { + continue; + } + } + } + } // end loop (cuts) + } // end if (kDecayToMuMu) + } // end loop over pairs of track associations + } // end loop over events + } // end if (events.size() > 0) + + } // end runTagAndProbe + + void processMuonTagAndProbe(MyEventsVtxCov const& events, + aod::ReducedMuonsAssoc const& muonAssocs, MyMuonTracksWithCov const& muons) + { + runTagAndProbe(events, muonAssocsPerCollision, muonAssocs, muons); + } + + void processDummy(MyEvents&) + { + // do nothing + } + + PROCESS_SWITCH(AnalysisTagAndProbe, processMuonTagAndProbe, "Run muon - pairing & TagAndProbe", false); + PROCESS_SWITCH(AnalysisTagAndProbe, processDummy, "Dummy function, enabled only if none of the others are enabled", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} + +void DefineHistograms(HistogramManager* histMan, TString histClasses, const char* histGroups) +{ + // + // Define here the histograms for all the classes required in analysis. + // The histogram classes are provided in the histClasses string, separated by semicolon ";" + // The histogram classes and their components histograms are defined below depending on the name of the histogram class + // + std::unique_ptr objArray(histClasses.Tokenize(";")); + for (Int_t iclass = 0; iclass < objArray->GetEntries(); ++iclass) { + TString classStr = objArray->At(iclass)->GetName(); + histMan->AddHistClass(classStr.Data()); + + TString histName = histGroups; + // NOTE: The level of detail for histogramming can be controlled via configurables + if (classStr.Contains("Event")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "event", histName); + } + + if (classStr.Contains("SameBunchCorrelations") || classStr.Contains("OutOfBunchCorrelations")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "two-collisions", histName); + } + + if (classStr.Contains("Track") && !classStr.Contains("Pairs")) { + if (classStr.Contains("Barrel")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", histName); + if (classStr.Contains("PIDCalibElectron")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", "postcalib_electron"); + } + if (classStr.Contains("PIDCalibPion")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", "postcalib_pion"); + } + if (classStr.Contains("PIDCalibProton")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", "postcalib_proton"); + } + if (classStr.Contains("Ambiguity")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", "ambiguity"); + } + } + if (classStr.Contains("Muon")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", histName); + } + } + + if (classStr.Contains("Pairs")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair", histName); + } + + if (classStr.Contains("Triplets")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair", histName); + } + + if (classStr.Contains("DileptonsSelected")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair", "barrel,vertexing"); + } + + if (classStr.Contains("DileptonTrack") && !classStr.Contains("ME")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "dilepton-track", histName); + } + + if (classStr.Contains("DileptonTrackME")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "dilepton-track", "mixedevent"); + } + + if (classStr.Contains("HadronsSelected")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", histName); + } + + if (classStr.Contains("DileptonHadronInvMass")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "dilepton-hadron-mass"); + } + + if (classStr.Contains("DileptonHadronCorrelation")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "dilepton-hadron-correlation"); + } + } // end loop over histogram classes +} diff --git a/PWGDQ/Tasks/dqCorrelation.cxx b/PWGDQ/Tasks/dqCorrelation.cxx index d2fa3a0dd4b..950e82364cb 100644 --- a/PWGDQ/Tasks/dqCorrelation.cxx +++ b/PWGDQ/Tasks/dqCorrelation.cxx @@ -303,7 +303,7 @@ struct DqCumulantFlow { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), event.posZ()); + wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), event.posZ()); } else { wacc = 1.0; } diff --git a/PWGDQ/Tasks/dqEfficiency.cxx b/PWGDQ/Tasks/dqEfficiency.cxx index 8532525b834..ed62df14a5e 100644 --- a/PWGDQ/Tasks/dqEfficiency.cxx +++ b/PWGDQ/Tasks/dqEfficiency.cxx @@ -308,8 +308,8 @@ struct AnalysisTrackSelection { fHistMan->FillHistClass(fHistNamesMCMatched[j][i].Data(), VarManager::fgValues); } } // end loop over cuts - } // end loop over MC signals - } // end loop over tracks + } // end loop over MC signals + } // end loop over tracks } void processSkimmed(MyEventsSelected::iterator const& event, MyBarrelTracks const& tracks, ReducedMCEvents const& eventsMC, ReducedMCTracks const& tracksMC) @@ -481,8 +481,8 @@ struct AnalysisMuonSelection { fHistMan->FillHistClass(fHistNamesMCMatched[j][i].Data(), VarManager::fgValues); } } // end loop over cuts - } // end loop over MC signals - } // end loop over muons + } // end loop over MC signals + } // end loop over muons } void processSkimmed(MyEventsSelected::iterator const& event, MyMuonTracks const& muons, ReducedMCEvents const& eventsMC, ReducedMCTracks const& tracksMC) @@ -622,8 +622,8 @@ struct AnalysisSameEventPairing { } fBarrelHistNamesMCmatched.push_back(mcSigClasses); } // end loop over cuts - } // end if(cutNames.IsNull()) - } // end if processBarrel + } // end if(cutNames.IsNull()) + } // end if processBarrel if (enableMuonHistos) { TString cutNames = fConfigMuonCuts.value; @@ -650,8 +650,8 @@ struct AnalysisSameEventPairing { } fMuonHistNamesMCmatched.push_back(mcSigClasses); } // end loop over cuts - } // end if(cutNames.IsNull()) - } // end if processMuon + } // end if(cutNames.IsNull()) + } // end if processMuon // NOTE: For the electron-muon pairing, the policy is that the user specifies n track and n muon cuts via configurables // So for each barrel cut there is a corresponding muon cut @@ -897,7 +897,7 @@ struct AnalysisSameEventPairing { } } } // end loop over barrel track pairs - } // end runPairing + } // end runPairing template void runMCGen(TTracksMC& groupedMCTracks) @@ -942,12 +942,12 @@ struct AnalysisSameEventPairing { checked = sig.CheckSignal(false, t1, t2); } if (checked) { - VarManager::FillPairMC(t1, t2); + VarManager::FillPairMC(t1, t2); fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig.GetName()), VarManager::fgValues); } } } // end of true pairing loop - } // end runMCGen + } // end runMCGen // Preslice perReducedMcEvent = aod::reducedtrackMC::reducedMCeventId; PresliceUnsorted perReducedMcEvent = aod::reducedtrackMC::reducedMCeventId; @@ -1040,9 +1040,18 @@ struct AnalysisSameEventPairing { struct AnalysisDileptonTrack { Produces dileptontrackcandidatesList; OutputObj fOutputList{"output"}; + Service ccdb; + o2::base::MatLayerCylSet* lut = nullptr; + // TODO: For now this is only used to determine the position in the filter bit map for the hadron cut Configurable fConfigTrackCuts{"cfgLeptonCuts", "", "Comma separated list of barrel track cuts"}; Configurable fConfigFillCandidateTable{"cfgFillCandidateTable", false, "Produce a single flat tables with all relevant information dilepton-track candidates"}; + Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable fCorrFullGeo{"cfgCorrFullGeo", false, "Use full geometry to correct for MCS effects in track propagation"}; + Configurable fNoCorr{"cfgNoCorrFwdProp", false, "Do not correct for MCS effects in track propagation"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Filter eventFilter = aod::dqanalysisflags::isEventSelected == 1; // Filter dileptonFilter = aod::reducedpair::mass > 2.92f && aod::reducedpair::mass < 3.16f && aod::reducedpair::sign == 0; // Filter dileptonFilter = aod::reducedpair::mass > 2.6f && aod::reducedpair::mass < 3.5f && aod::reducedpair::sign == 0; @@ -1075,6 +1084,21 @@ struct AnalysisDileptonTrack { return; } + ccdb->setURL(ccdburl.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + if (fNoCorr) { + VarManager::SetupFwdDCAFitterNoCorr(); + } else if (fCorrFullGeo) { + if (!o2::base::GeometryManager::isGeometryLoaded()) { + ccdb->get(geoPath); + } + } else { + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); + VarManager::SetupMatLUTFwdDCAFitter(lut); + } + TString sigNamesStr = fConfigMCRecSignals.value; std::unique_ptr objRecSigArray(sigNamesStr.Tokenize(",")); TString histNames; @@ -1320,6 +1344,8 @@ struct AnalysisDileptonTrackTrack { Configurable fConfigMCRecSignals{"cfgBarrelMCRecSignals", "", "Comma separated list of MC signals (reconstructed)"}; Configurable fConfigMCGenSignals{"cfgBarrelMCGenSignals", "", "Comma separated list of MC signals (generated)"}; Configurable fConfigDileptonMCRecSignal{"cfgDileptonMCRecSignal", "", "Comma separated list of MC signals (reconstructed)"}; + Configurable fConfigUseKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"}; + Configurable fConfigUseDCAVertexing{"cfgUseDCAVertexing", false, "Use DCA for secondary vertex reconstruction (DCAFitter is used by default)"}; Produces DileptonTrackTrackTable; HistogramManager* fHistMan; @@ -1410,7 +1436,7 @@ struct AnalysisDileptonTrackTrack { if (sig->GetNProngs() == 4) { fRecMCSignals.push_back(*sig); fRecMCSignalsNames.push_back(sig->GetName()); - histNames += Form("MCTruthRecQaud_%s_%s;", fQuadrupletCutNames[icut].Data(), sig->GetName()); + histNames += Form("MCTruthRecQuad_%s_%s;", fQuadrupletCutNames[icut].Data(), sig->GetName()); } } } @@ -1426,7 +1452,7 @@ struct AnalysisDileptonTrackTrack { if (sig) { if (sig->GetNProngs() == 1) { // NOTE: 1-prong signals required fGenMCSignals.push_back(*sig); - histNames += Form("MCTruthGenQaud_%s;", sig->GetName()); // TODO: Add these names to a std::vector to avoid using Form in the process function + histNames += Form("MCTruthGenQuad_%s;", sig->GetName()); // TODO: Add these names to a std::vector to avoid using Form in the process function } } } @@ -1455,6 +1481,15 @@ struct AnalysisDileptonTrackTrack { VarManager::ResetValues(0, VarManager::kNVars, fValuesQuadruplet); VarManager::FillEvent(event, fValuesQuadruplet); + // set up KF or DCAfitter + if (fConfigUseDCAVertexing) { + VarManager::SetupTwoProngDCAFitter(5.0f, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + // VarManager::SetupThreeProngDCAFitter(5.0f, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + VarManager::SetupFourProngDCAFitter(5.0f, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + } else if (fConfigUseKFVertexing) { + VarManager::SetupFourProngKFParticle(5.0f); + } + // LOGF(info, "Number of dileptons: %d", dileptons.size()); int indexOffset = -999; std::vector trackGlobalIndexes; @@ -1506,6 +1541,10 @@ struct AnalysisDileptonTrackTrack { // Fill the Histograms VarManager::FillDileptonTrackTrack(dilepton, t1, t2, fValuesQuadruplet); + // reconstruct the secondary vertex + if (fConfigUseDCAVertexing || fConfigUseKFVertexing) { + VarManager::FillDileptonTrackTrackVertexing(event, lepton1, lepton2, t1, t2, fValuesQuadruplet); + } uint32_t CutDecision = 0; uint32_t mcDecision = 0; int iCut = 0; @@ -1539,7 +1578,7 @@ struct AnalysisDileptonTrackTrack { } for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { if (mcDecision & (static_cast(1) << isig)) { - fHistMan->FillHistClass(Form("MCTruthRecQaud_%s_%s", fQuadrupletCutNames[iCut].Data(), fRecMCSignalsNames[isig].Data()), fValuesQuadruplet); + fHistMan->FillHistClass(Form("MCTruthRecQuad_%s_%s", fQuadrupletCutNames[iCut].Data(), fRecMCSignalsNames[isig].Data()), fValuesQuadruplet); } } } @@ -1552,9 +1591,14 @@ struct AnalysisDileptonTrackTrack { if (!mcDecision) continue; DileptonTrackTrackTable(fValuesQuadruplet[VarManager::kQuadMass], fValuesQuadruplet[VarManager::kQuadPt], fValuesQuadruplet[VarManager::kQuadEta], fValuesQuadruplet[VarManager::kQuadPhi], fValuesQuadruplet[VarManager::kRap], - fValuesQuadruplet[VarManager::kQ], fValuesQuadruplet[VarManager::kDeltaR1], fValuesQuadruplet[VarManager::kDeltaR2], + fValuesQuadruplet[VarManager::kQ], fValuesQuadruplet[VarManager::kDeltaR1], fValuesQuadruplet[VarManager::kDeltaR2], fValuesQuadruplet[VarManager::kDeltaR], dilepton.mass(), dilepton.pt(), dilepton.eta(), dilepton.phi(), dilepton.sign(), - fValuesQuadruplet[VarManager::kDitrackMass], fValuesQuadruplet[VarManager::kDitrackPt], t1.pt(), t2.pt(), t1.eta(), t2.eta(), t1.phi(), t2.phi(), t1.sign(), t2.sign()); + lepton1.tpcNSigmaEl(), lepton1.tpcNSigmaPi(), lepton1.tpcNSigmaPr(), lepton1.tpcNClsFound(), + lepton2.tpcNSigmaEl(), lepton2.tpcNSigmaPi(), lepton2.tpcNSigmaPr(), lepton2.tpcNClsFound(), + fValuesQuadruplet[VarManager::kDitrackMass], fValuesQuadruplet[VarManager::kDitrackPt], t1.pt(), t2.pt(), t1.eta(), t2.eta(), t1.phi(), t2.phi(), t1.sign(), t2.sign(), t1.tpcNSigmaPi(), t2.tpcNSigmaPi(), t1.tpcNSigmaKa(), t2.tpcNSigmaKa(), t1.tpcNSigmaPr(), t1.tpcNSigmaPr(), t1.tpcNClsFound(), t2.tpcNClsFound(), + fValuesQuadruplet[VarManager::kKFMass], fValuesQuadruplet[VarManager::kVertexingProcCode], fValuesQuadruplet[VarManager::kVertexingChi2PCA], fValuesQuadruplet[VarManager::kCosPointingAngle], fValuesQuadruplet[VarManager::kKFDCAxyzBetweenProngs], fValuesQuadruplet[VarManager::kKFChi2OverNDFGeo], + fValuesQuadruplet[VarManager::kVertexingLz], fValuesQuadruplet[VarManager::kVertexingLxy], fValuesQuadruplet[VarManager::kVertexingLxyz], fValuesQuadruplet[VarManager::kVertexingTauz], fValuesQuadruplet[VarManager::kVertexingTauxy], fValuesQuadruplet[VarManager::kVertexingLzErr], fValuesQuadruplet[VarManager::kVertexingLxyzErr], + fValuesQuadruplet[VarManager::kVertexingTauzErr], fValuesQuadruplet[VarManager::kVertexingLzProjected], fValuesQuadruplet[VarManager::kVertexingLxyProjected], fValuesQuadruplet[VarManager::kVertexingLxyzProjected], fValuesQuadruplet[VarManager::kVertexingTauzProjected], fValuesQuadruplet[VarManager::kVertexingTauxyProjected]); } // end loop over track - track combinations } // end loop over dileptons }; @@ -1574,9 +1618,9 @@ struct AnalysisDileptonTrackTrack { auto dilepton = mcTracks.rawIteratorAt(daughterIdFirst); auto track1 = mcTracks.rawIteratorAt(daughterIdFirst + 1); auto track2 = mcTracks.rawIteratorAt(daughterIdFirst + 2); - VarManager::FillQaudMC(dilepton, track1, track2); + VarManager::FillQuadMC(dilepton, track1, track2); } - fHistMan->FillHistClass(Form("MCTruthGenQaud_%s", sig.GetName()), VarManager::fgValues); + fHistMan->FillHistClass(Form("MCTruthGenQuad_%s", sig.GetName()), VarManager::fgValues); } } } @@ -1654,7 +1698,7 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses) // histMan->AddHistogram(objArray->At(iclass)->GetName(), "Rapidity", "MC generator y distribution", false, 150, 2.5, 4.0, VarManager::kMCY); histMan->AddHistogram(objArray->At(iclass)->GetName(), "Phi", "MC generator #varphi distribution", false, 50, 0.0, 2. * TMath::Pi(), VarManager::kMCPhi); } - if (classStr.Contains("MCTruthGenQaud")) { + if (classStr.Contains("MCTruthGenQuad")) { dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "mctruth_quad"); } if (classStr.Contains("MCTruthGen")) { @@ -1673,7 +1717,7 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses) if (classStr.Contains("DileptonTrackInvMass")) { dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "dilepton-hadron-mass"); } - if (classStr.Contains("Quadruplet") || classStr.Contains("MCTruthRecQaud")) { + if (classStr.Contains("Quadruplet") || classStr.Contains("MCTruthRecQuad")) { dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "dilepton-dihadron", "xtojpsipipi"); } diff --git a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx index 2cda1a7d417..17ae4e76d22 100644 --- a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx +++ b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx @@ -18,11 +18,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include "CCDB/BasicCCDBManager.h" #include "DataFormatsParameters/GRPObject.h" #include "Framework/runDataProcessing.h" @@ -72,6 +74,7 @@ DECLARE_SOA_COLUMN(MuonAmbiguityOutOfBunch, muonAmbiguityOutOfBunch, int8_t); DECLARE_SOA_BITMAP_COLUMN(IsBarrelSelectedPrefilter, isBarrelSelectedPrefilter, 32); //! Barrel prefilter decisions (joinable to ReducedTracksAssoc) // Bcandidate columns for ML analysis of B->Jpsi+K DECLARE_SOA_COLUMN(massBcandidate, MBcandidate, float); +DECLARE_SOA_COLUMN(MassDileptonCandidate, massDileptonCandidate, float); DECLARE_SOA_COLUMN(deltaMassBcandidate, deltaMBcandidate, float); DECLARE_SOA_COLUMN(pTBcandidate, PtBcandidate, float); DECLARE_SOA_COLUMN(LxyBcandidate, lxyBcandidate, float); @@ -81,8 +84,53 @@ DECLARE_SOA_COLUMN(TauxyBcandidate, tauxyBcandidate, float); DECLARE_SOA_COLUMN(TauzBcandidate, tauzBcandidate, float); DECLARE_SOA_COLUMN(CosPBcandidate, cosPBcandidate, float); DECLARE_SOA_COLUMN(Chi2Bcandidate, chi2Bcandidate, float); -DECLARE_SOA_COLUMN(DCAxyzBetweenProngs, dcaxyzBetweenProngs, float); +DECLARE_SOA_COLUMN(PINassoc, pINassoc, float); +DECLARE_SOA_COLUMN(Etaassoc, etaassoc, float); +DECLARE_SOA_COLUMN(Ptpair, ptpair, float); +DECLARE_SOA_COLUMN(Etapair, etapair, float); +DECLARE_SOA_COLUMN(PINleg1, pINleg1, float); +DECLARE_SOA_COLUMN(Etaleg1, etaleg1, float); +DECLARE_SOA_COLUMN(PINleg2, pINleg2, float); +DECLARE_SOA_COLUMN(Etaleg2, etaleg2, float); +DECLARE_SOA_COLUMN(TPCnsigmaKaassoc, tpcnsigmaKaassoc, float); +DECLARE_SOA_COLUMN(TPCnsigmaPiassoc, tpcnsigmaPiassoc, float); +DECLARE_SOA_COLUMN(TPCnsigmaPrassoc, tpcnsigmaPrassoc, float); +DECLARE_SOA_COLUMN(TOFnsigmaKaassoc, tofnsigmaKaassoc, float); +DECLARE_SOA_COLUMN(TPCnsigmaElleg1, tpcnsigmaElleg1, float); +DECLARE_SOA_COLUMN(TPCnsigmaPileg1, tpcnsigmaPileg1, float); +DECLARE_SOA_COLUMN(TPCnsigmaPrleg1, tpcnsigmaPrleg1, float); +DECLARE_SOA_COLUMN(TPCnsigmaElleg2, tpcnsigmaElleg2, float); +DECLARE_SOA_COLUMN(TPCnsigmaPileg2, tpcnsigmaPileg2, float); +DECLARE_SOA_COLUMN(TPCnsigmaPrleg2, tpcnsigmaPrleg2, float); +DECLARE_SOA_COLUMN(DCAXYassoc, dcaXYassoc, float); +DECLARE_SOA_COLUMN(DCAZassoc, dcaZassoc, float); +DECLARE_SOA_COLUMN(DCAXYleg1, dcaXYleg1, float); +DECLARE_SOA_COLUMN(DCAZleg1, dcaZleg1, float); +DECLARE_SOA_COLUMN(DCAXYleg2, dcaXYleg2, float); +DECLARE_SOA_COLUMN(DCAZleg2, dcaZleg2, float); +DECLARE_SOA_COLUMN(ITSClusterMapassoc, itsClusterMapassoc, uint8_t); +DECLARE_SOA_COLUMN(ITSClusterMapleg1, itsClusterMapleg1, uint8_t); +DECLARE_SOA_COLUMN(ITSClusterMapleg2, itsClusterMapleg2, uint8_t); +DECLARE_SOA_COLUMN(ITSChi2assoc, itsChi2assoc, float); +DECLARE_SOA_COLUMN(ITSChi2leg1, itsChi2leg1, float); +DECLARE_SOA_COLUMN(ITSChi2leg2, itsChi2leg2, float); +DECLARE_SOA_COLUMN(TPCNclsassoc, tpcNclsassoc, float); +DECLARE_SOA_COLUMN(TPCNclsleg1, tpcNclsleg1, float); +DECLARE_SOA_COLUMN(TPCNclsleg2, tpcNclsleg2, float); +DECLARE_SOA_COLUMN(TPCChi2assoc, tpcChi2assoc, float); +DECLARE_SOA_COLUMN(TPCChi2leg1, tpcChi2leg1, float); +DECLARE_SOA_COLUMN(TPCChi2leg2, tpcChi2leg2, float); DECLARE_SOA_COLUMN(McFlag, mcFlag, int8_t); +DECLARE_SOA_BITMAP_COLUMN(IsJpsiFromBSelected, isJpsiFromBSelected, 32); +// Candidate columns for prompt-non-prompt JPsi separation +DECLARE_SOA_COLUMN(Massee, massee, float); +DECLARE_SOA_COLUMN(Ptee, ptee, float); +DECLARE_SOA_COLUMN(Lxyee, lxyee, float); +DECLARE_SOA_COLUMN(LxyeePoleMass, lxyeepolemass, float); +DECLARE_SOA_COLUMN(Lzee, lzee, float); +DECLARE_SOA_COLUMN(AmbiguousInBunchPairs, AmbiguousJpsiPairsInBunch, bool); +DECLARE_SOA_COLUMN(AmbiguousOutOfBunchPairs, AmbiguousJpsiPairsOutOfBunch, bool); +DECLARE_SOA_COLUMN(Corrassoc, corrassoc, bool); } // namespace dqanalysisflags DECLARE_SOA_TABLE(EventCuts, "AOD", "DQANAEVCUTS", dqanalysisflags::IsEventSelected); //! joinable to ReducedEvents @@ -91,7 +139,22 @@ DECLARE_SOA_TABLE(BarrelAmbiguities, "AOD", "DQBARRELAMB", dqanalysisflags::Barr DECLARE_SOA_TABLE(MuonTrackCuts, "AOD", "DQANAMUONCUTS", dqanalysisflags::IsMuonSelected); //! joinable to ReducedMuonsAssoc DECLARE_SOA_TABLE(MuonAmbiguities, "AOD", "DQMUONAMB", dqanalysisflags::MuonAmbiguityInBunch, dqanalysisflags::MuonAmbiguityOutOfBunch); //! joinable to ReducedMuonTracks DECLARE_SOA_TABLE(Prefilter, "AOD", "DQPREFILTER", dqanalysisflags::IsBarrelSelectedPrefilter); //! joinable to ReducedTracksAssoc -DECLARE_SOA_TABLE(BmesonCandidates, "AOD", "DQBMESONS", dqanalysisflags::massBcandidate, dqanalysisflags::deltaMassBcandidate, dqanalysisflags::pTBcandidate, dqanalysisflags::LxyBcandidate, dqanalysisflags::LxyzBcandidate, dqanalysisflags::LzBcandidate, dqanalysisflags::TauxyBcandidate, dqanalysisflags::TauzBcandidate, dqanalysisflags::DCAxyzBetweenProngs, dqanalysisflags::CosPBcandidate, dqanalysisflags::Chi2Bcandidate, dqanalysisflags::McFlag); +DECLARE_SOA_TABLE(BmesonCandidates, "AOD", "DQBMESONS", + dqanalysisflags::massBcandidate, dqanalysisflags::MassDileptonCandidate, dqanalysisflags::deltaMassBcandidate, dqanalysisflags::pTBcandidate, + dqanalysisflags::LxyBcandidate, dqanalysisflags::LxyzBcandidate, dqanalysisflags::LzBcandidate, + dqanalysisflags::TauxyBcandidate, dqanalysisflags::TauzBcandidate, dqanalysisflags::CosPBcandidate, dqanalysisflags::Chi2Bcandidate, + dqanalysisflags::PINassoc, dqanalysisflags::Etaassoc, dqanalysisflags::Ptpair, dqanalysisflags::Etapair, + dqanalysisflags::PINleg1, dqanalysisflags::Etaleg1, dqanalysisflags::PINleg2, dqanalysisflags::Etaleg2, + dqanalysisflags::TPCnsigmaKaassoc, dqanalysisflags::TPCnsigmaPiassoc, dqanalysisflags::TPCnsigmaPrassoc, dqanalysisflags::TOFnsigmaKaassoc, + dqanalysisflags::TPCnsigmaElleg1, dqanalysisflags::TPCnsigmaPileg1, dqanalysisflags::TPCnsigmaPrleg1, + dqanalysisflags::TPCnsigmaElleg2, dqanalysisflags::TPCnsigmaPileg2, dqanalysisflags::TPCnsigmaPrleg2, + dqanalysisflags::DCAXYassoc, dqanalysisflags::DCAZassoc, dqanalysisflags::DCAXYleg1, dqanalysisflags::DCAZleg1, dqanalysisflags::DCAXYleg2, dqanalysisflags::DCAZleg2, + dqanalysisflags::ITSClusterMapassoc, dqanalysisflags::ITSClusterMapleg1, dqanalysisflags::ITSClusterMapleg2, + dqanalysisflags::ITSChi2assoc, dqanalysisflags::ITSChi2leg1, dqanalysisflags::ITSChi2leg2, + dqanalysisflags::TPCNclsassoc, dqanalysisflags::TPCNclsleg1, dqanalysisflags::TPCNclsleg2, + dqanalysisflags::TPCChi2assoc, dqanalysisflags::TPCChi2leg1, dqanalysisflags::TPCChi2leg2, + dqanalysisflags::IsJpsiFromBSelected, dqanalysisflags::IsBarrelSelected, dqanalysisflags::McFlag); +DECLARE_SOA_TABLE(JPsieeCandidates, "AOD", "DQPSEUDOPROPER", dqanalysisflags::Massee, dqanalysisflags::Ptee, dqanalysisflags::Lxyee, dqanalysisflags::LxyeePoleMass, dqanalysisflags::Lzee, dqanalysisflags::AmbiguousInBunchPairs, dqanalysisflags::AmbiguousOutOfBunchPairs, dqanalysisflags::Corrassoc); } // namespace o2::aod // Declarations of various short names @@ -99,6 +162,7 @@ using MyEvents = soa::Join; using MyEventsVtxCov = soa::Join; using MyEventsVtxCovSelected = soa::Join; +using MyEventsVtxCovSelectedMultExtra = soa::Join; using MyEventsVtxCovSelectedQvector = soa::Join; using MyEventsQvector = soa::Join; @@ -118,6 +182,7 @@ using MyMuonTracksWithCovWithAmbiguities = soa::Join fOutputList{"output"}; Configurable fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"}; + Configurable fConfigEventCutsJSON{"cfgEventCutsJSON", "", "Additional event cuts specified in JSON format"}; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; Configurable fConfigAddEventMCHistogram{"cfgAddEventMCHistogram", "generator", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Add event histograms defined via JSON formatting (see HistogramsLibrary)"}; Configurable fConfigSplitCollisionsDeltaZ{"splitCollisionsDeltaZ", 1.0, "maximum delta-z (cm) between two collisions to consider them as split candidates"}; Configurable fConfigSplitCollisionsDeltaBC{"splitCollisionsDeltaBC", 100, "maximum delta-BC between two collisions to consider them as split candidates; do not apply if value is negative"}; @@ -173,13 +240,27 @@ struct AnalysisEventSelection { if (context.mOptions.get("processDummy")) { return; } + VarManager::SetDefaultVarNames(); fEventCut = new AnalysisCompositeCut(true); TString eventCutStr = fConfigEventCuts.value; - fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); + if (eventCutStr != "") { + AnalysisCut* cut = dqcuts::GetAnalysisCut(eventCutStr.Data()); + if (cut != nullptr) { + fEventCut->AddCut(cut); + } + } + // Additional cuts via JSON + TString eventCutJSONStr = fConfigEventCutsJSON.value; + if (eventCutJSONStr != "") { + std::vector jsonCuts = dqcuts::GetCutsFromJSON(eventCutJSONStr.Data()); + for (auto& cutIt : jsonCuts) { + fEventCut->AddCut(cutIt); + } + } + VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill - VarManager::SetDefaultVarNames(); if (fConfigQA) { fHistMan = new HistogramManager("analysisHistos", "", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(kTRUE); @@ -189,6 +270,7 @@ struct AnalysisEventSelection { DefineHistograms(fHistMan, "OutOfBunchCorrelations;SameBunchCorrelations;", ""); } DefineHistograms(fHistMan, "EventsMC", fConfigAddEventMCHistogram.value.data()); + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // aditional histograms via JSON VarManager::SetUseVars(fHistMan->GetUsedVars()); fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -349,24 +431,25 @@ struct AnalysisTrackSelection { OutputObj fOutputList{"output"}; Configurable fConfigCuts{"cfgTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; + Configurable fConfigCutsJSON{"cfgBarrelTrackCutsJSON", "", "Additional list of barrel track cuts in JSON format"}; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; Configurable fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Configurable fConfigPublishAmbiguity{"cfgPublishAmbiguity", true, "If true, publish ambiguity table and fill QA histograms"}; Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable fConfigCcdbPathTPC{"ccdb-path-tpc", "Users/z/zhxiong/TPCPID/PostCalib", "base path to the ccdb object"}; Configurable fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; Configurable fConfigComputeTPCpostCalib{"cfgTPCpostCalib", false, "If true, compute TPC post-calibrated n-sigmas"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable fConfigDummyRunlist{"cfgDummyRunlist", false, "If true, use dummy runlist"}; - Configurable fConfigInitRunNumber{"cfgInitRunNumber", 543215, "Initial run number used in run by run checks"}; Configurable fConfigMCSignals{"cfgTrackMCSignals", "", "Comma separated list of MC signals"}; + Configurable fConfigMCSignalsJSON{"cfgTrackMCsignalsJSON", "", "Additional list of MC signals via JSON"}; Service fCCDB; HistogramManager* fHistMan; - std::vector fTrackCuts; - std::vector fMCSignals; // list of signals to be checked + std::vector fTrackCuts; + std::vector fMCSignals; // list of signals to be checked std::vector fHistNamesReco; std::vector fHistNamesMCMatched; @@ -380,13 +463,22 @@ struct AnalysisTrackSelection { if (context.mOptions.get("processDummy")) { return; } + VarManager::SetDefaultVarNames(); fCurrentRun = 0; TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fTrackCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fTrackCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + } + } + // add extra cuts from JSON + TString addTrackCutsStr = fConfigCutsJSON.value; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + fTrackCuts.push_back(reinterpret_cast(t)); } } VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill @@ -400,12 +492,22 @@ struct AnalysisTrackSelection { if (sig->GetNProngs() != 1) { // NOTE: only 1 prong signals continue; } - fMCSignals.push_back(*sig); + fMCSignals.push_back(sig); + } + } + // Add the MCSignals from the JSON config + TString addMCSignalsStr = fConfigMCSignalsJSON.value; + if (addMCSignalsStr != "") { + std::vector addMCSignals = dqmcsignals::GetMCSignalsFromJSON(addMCSignalsStr.Data()); + for (auto& mcIt : addMCSignals) { + if (mcIt->GetNProngs() != 1) { // NOTE: only 1 prong signals + continue; + } + fMCSignals.push_back(mcIt); } } if (fConfigQA) { - VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); @@ -414,14 +516,14 @@ struct AnalysisTrackSelection { // Add histogram classes for each track cut and for each requested MC signal (reconstructed tracks with MC truth) TString histClasses = "AssocsBarrel_BeforeCuts;"; for (auto& cut : fTrackCuts) { - TString nameStr = Form("AssocsBarrel_%s", cut.GetName()); + TString nameStr = Form("AssocsBarrel_%s", cut->GetName()); fHistNamesReco.push_back(nameStr); histClasses += Form("%s;", nameStr.Data()); for (auto& sig : fMCSignals) { - TString nameStr2 = Form("AssocsCorrectBarrel_%s_%s", cut.GetName(), sig.GetName()); + TString nameStr2 = Form("AssocsCorrectBarrel_%s_%s", cut->GetName(), sig->GetName()); fHistNamesMCMatched.push_back(nameStr2); histClasses += Form("%s;", nameStr2.Data()); - nameStr2 = Form("AssocsIncorrectBarrel_%s_%s", cut.GetName(), sig.GetName()); + nameStr2 = Form("AssocsIncorrectBarrel_%s_%s", cut->GetName(), sig->GetName()); fHistNamesMCMatched.push_back(nameStr2); histClasses += Form("%s;", nameStr2.Data()); } @@ -431,13 +533,11 @@ struct AnalysisTrackSelection { if (fConfigPublishAmbiguity) { DefineHistograms(fHistMan, "TrackBarrel_AmbiguityInBunch;TrackBarrel_AmbiguityOutOfBunch;", "ambiguity"); } + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } - if (fConfigDummyRunlist) { - VarManager::SetDummyRunlist(fConfigInitRunNumber); - } if (fConfigComputeTPCpostCalib) { fCCDB->setURL(fConfigCcdbUrl.value); fCCDB->setCaching(true); @@ -488,8 +588,11 @@ struct AnalysisTrackSelection { VarManager::ResetValues(0, VarManager::kNBarrelTrackVariables); // fill event information which might be needed in histograms/cuts that combine track and event properties VarManager::FillEvent(event); - auto eventMC = event.reducedMCevent(); - VarManager::FillEvent(eventMC); + ReducedMCEvent* eventMC = nullptr; + if (event.has_reducedMCevent()) { + auto eventMC = event.reducedMCevent(); + VarManager::FillEvent(eventMC); + } auto track = assoc.template reducedtrack_as(); VarManager::FillTrack(track); @@ -500,7 +603,9 @@ struct AnalysisTrackSelection { if (track.has_reducedMCTrack()) { auto trackMC = track.reducedMCTrack(); auto eventMCfromTrack = trackMC.reducedMCevent(); - isCorrectAssoc = (eventMCfromTrack.globalIndex() == eventMC.globalIndex()); + if (eventMC != nullptr) { + isCorrectAssoc = (eventMCfromTrack.globalIndex() == eventMC->globalIndex()); + } VarManager::FillTrackMC(tracksMC, trackMC); } @@ -511,7 +616,7 @@ struct AnalysisTrackSelection { int iCut = 0; uint32_t filterMap = static_cast(0); for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++, iCut++) { - if ((*cut).IsSelected(VarManager::fgValues)) { + if ((*cut)->IsSelected(VarManager::fgValues)) { filterMap |= (static_cast(1) << iCut); if (fConfigQA) { fHistMan->FillHistClass(fHistNamesReco[iCut], VarManager::fgValues); @@ -521,19 +626,28 @@ struct AnalysisTrackSelection { trackSel(filterMap); // compute MC matching decisions and fill histograms for matched associations - uint32_t mcDecision = static_cast(0); int isig = 0; - if (filterMap > 0) { + if (filterMap > 0 && track.has_reducedMCTrack()) { + // loop over all MC signals for (auto sig = fMCSignals.begin(); sig != fMCSignals.end(); sig++, isig++) { - if (track.has_reducedMCTrack()) { - if ((*sig).CheckSignal(true, track.reducedMCTrack())) { - mcDecision |= (static_cast(1) << isig); - } + // check if this MC signal is matched + if ((*sig)->CheckSignal(true, track.reducedMCTrack())) { + // mcDecision |= (static_cast(1) << isig); + // loop over cuts and fill histograms for the cuts that are fulfilled + for (unsigned int icut = 0; icut < fTrackCuts.size(); icut++) { + if (filterMap & (static_cast(1) << icut)) { + if (isCorrectAssoc) { + fHistMan->FillHistClass(fHistNamesMCMatched[icut * 2 * fMCSignals.size() + 2 * isig].Data(), VarManager::fgValues); + } else { + fHistMan->FillHistClass(fHistNamesMCMatched[icut * 2 * fMCSignals.size() + 2 * isig + 1].Data(), VarManager::fgValues); + } + } + } // end loop over cuts } } // fill histograms - for (unsigned int i = 0; i < fMCSignals.size(); i++) { + /*for (unsigned int i = 0; i < fMCSignals.size(); i++) { if (!(mcDecision & (static_cast(1) << i))) { continue; } @@ -547,6 +661,7 @@ struct AnalysisTrackSelection { } } // end loop over cuts } // end loop over MC signals + */ } // end if (filterMap > 0) // count the number of associations per track @@ -641,8 +756,10 @@ struct AnalysisMuonSelection { OutputObj fOutputList{"output"}; Configurable fConfigCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; + Configurable fConfigCutsJSON{"cfgMuonCutsJSON", "", "Additional list of muon cuts in JSON format"}; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; Configurable fConfigAddMuonHistogram{"cfgAddMuonHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Configurable fConfigPublishAmbiguity{"cfgPublishAmbiguity", true, "If true, publish ambiguity table and fill QA histograms"}; Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; @@ -650,14 +767,15 @@ struct AnalysisMuonSelection { Configurable fConfigGeoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable fConfigMCSignals{"cfgMuonMCSignals", "", "Comma separated list of MC signals"}; + Configurable fConfigMCSignalsJSON{"cfgMuonMCsignalsJSON", "", "Additional list of MC signals via JSON"}; Service fCCDB; HistogramManager* fHistMan; - std::vector fMuonCuts; + std::vector fMuonCuts; std::vector fHistNamesReco; std::vector fHistNamesMCMatched; - std::vector fMCSignals; // list of signals to be checked + std::vector fMCSignals; // list of signals to be checked int fCurrentRun; // current run kept to detect run changes and trigger loading params from CCDB @@ -669,13 +787,22 @@ struct AnalysisMuonSelection { if (context.mOptions.get("processDummy")) { return; } + VarManager::SetDefaultVarNames(); fCurrentRun = 0; TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fMuonCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fMuonCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + } + } + // Add cuts configured via JSON + TString addCutsStr = fConfigCutsJSON.value; + if (addCutsStr != "") { + std::vector addCuts = dqcuts::GetCutsFromJSON(addCutsStr.Data()); + for (auto& t : addCuts) { + fMuonCuts.push_back(reinterpret_cast(t)); } } VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill @@ -689,12 +816,22 @@ struct AnalysisMuonSelection { if (sig->GetNProngs() != 1) { // NOTE: only 1 prong signals continue; } - fMCSignals.push_back(*sig); + fMCSignals.push_back(sig); + } + } + // Add the MCSignals from the JSON config + TString addMCSignalsStr = fConfigMCSignalsJSON.value; + if (addMCSignalsStr != "") { + std::vector addMCSignals = dqmcsignals::GetMCSignalsFromJSON(addMCSignalsStr.Data()); + for (auto& mcIt : addMCSignals) { + if (mcIt->GetNProngs() != 1) { // NOTE: only 1 prong signals + continue; + } + fMCSignals.push_back(mcIt); } } if (fConfigQA) { - VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); @@ -703,14 +840,14 @@ struct AnalysisMuonSelection { // Add histogram classes for each track cut and for each requested MC signal (reconstructed tracks with MC truth) TString histClasses = "AssocsMuon_BeforeCuts;"; for (auto& cut : fMuonCuts) { - TString nameStr = Form("AssocsMuon_%s", cut.GetName()); + TString nameStr = Form("AssocsMuon_%s", cut->GetName()); fHistNamesReco.push_back(nameStr); histClasses += Form("%s;", nameStr.Data()); for (auto& sig : fMCSignals) { - TString nameStr2 = Form("AssocsCorrectMuon_%s_%s", cut.GetName(), sig.GetName()); + TString nameStr2 = Form("AssocsCorrectMuon_%s_%s", cut->GetName(), sig->GetName()); fHistNamesMCMatched.push_back(nameStr2); histClasses += Form("%s;", nameStr2.Data()); - nameStr2 = Form("AssocsIncorrectMuon_%s_%s", cut.GetName(), sig.GetName()); + nameStr2 = Form("AssocsIncorrectMuon_%s_%s", cut->GetName(), sig->GetName()); fHistNamesMCMatched.push_back(nameStr2); histClasses += Form("%s;", nameStr2.Data()); } @@ -720,6 +857,7 @@ struct AnalysisMuonSelection { } DefineHistograms(fHistMan, histClasses.Data(), fConfigAddMuonHistogram.value.data()); // define all histograms + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -780,7 +918,7 @@ struct AnalysisMuonSelection { int iCut = 0; uint32_t filterMap = static_cast(0); for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++, iCut++) { - if ((*cut).IsSelected(VarManager::fgValues)) { + if ((*cut)->IsSelected(VarManager::fgValues)) { filterMap |= (static_cast(1) << iCut); if (fConfigQA) { fHistMan->FillHistClass(fHistNamesReco[iCut].Data(), VarManager::fgValues); @@ -806,7 +944,7 @@ struct AnalysisMuonSelection { for (auto sig = fMCSignals.begin(); sig != fMCSignals.end(); sig++, isig++) { if constexpr ((TMuonFillMap & VarManager::ObjTypes::ReducedMuon) > 0) { if (track.has_reducedMCTrack()) { - if ((*sig).CheckSignal(true, track.reducedMCTrack())) { + if ((*sig)->CheckSignal(true, track.reducedMCTrack())) { mcDecision |= (static_cast(1) << isig); } } @@ -821,9 +959,9 @@ struct AnalysisMuonSelection { for (unsigned int j = 0; j < fMuonCuts.size(); j++) { if (filterMap & (static_cast(1) << j)) { if (isCorrectAssoc) { - fHistMan->FillHistClass(fHistNamesMCMatched[j * fMCSignals.size() + 2 * i].Data(), VarManager::fgValues); + fHistMan->FillHistClass(fHistNamesMCMatched[j * 2 * fMCSignals.size() + 2 * i].Data(), VarManager::fgValues); } else { - fHistMan->FillHistClass(fHistNamesMCMatched[j * fMCSignals.size() + 2 * i + 1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(fHistNamesMCMatched[j * 2 * fMCSignals.size() + 2 * i + 1].Data(), VarManager::fgValues); } } } // end loop over cuts @@ -967,6 +1105,15 @@ struct AnalysisPrefilterSelection { string trackCuts; getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", trackCuts, false); TString allTrackCutsStr = trackCuts; + // check also the cuts added via JSON and add them to the string of cuts + getTaskOptionValue(context, "analysis-track-selection", "cfgBarrelTrackCutsJSON", trackCuts, false); + TString addTrackCutsStr = trackCuts; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + allTrackCutsStr += Form(",%s", t->GetName()); + } + } std::unique_ptr objArray(allTrackCutsStr.Tokenize(",")); if (objArray == nullptr) { @@ -1102,7 +1249,10 @@ struct AnalysisSameEventPairing { Produces dielectronInfoList; Produces dimuonsExtraList; Produces dimuonAllList; + Produces dileptonMiniTreeGen; + Produces dileptonMiniTreeRec; Produces dileptonInfoList; + Produces PromptNonPromptSepTable; o2::base::MatLayerCylSet* fLUT = nullptr; int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. @@ -1113,10 +1263,12 @@ struct AnalysisSameEventPairing { Configurable track{"cfgTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; Configurable muon{"cfgMuonCuts", "", "Comma separated list of muon cuts"}; Configurable pair{"cfgPairCuts", "", "Comma separated list of pair cuts, !!! Use only if you know what you are doing, otherwise leave empty"}; + // TODO: Add pair cuts via JSON } fConfigCuts; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; Configurable fConfigAddSEPHistogram{"cfgAddSEPHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; struct : ConfigurableGroup { Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -1140,17 +1292,26 @@ struct AnalysisSameEventPairing { struct : ConfigurableGroup { Configurable genSignals{"cfgBarrelMCGenSignals", "", "Comma separated list of MC signals (generated)"}; + Configurable genSignalsJSON{"cfgMCGenSignalsJSON", "", "Additional list of MC signals (generated) via JSON"}; Configurable recSignals{"cfgBarrelMCRecSignals", "", "Comma separated list of MC signals (reconstructed)"}; + Configurable recSignalsJSON{"cfgMCRecSignalsJSON", "", "Comma separated list of MC signals (reconstructed) via JSON"}; Configurable skimSignalOnly{"cfgSkimSignalOnly", false, "Configurable to select only matched candidates"}; - Configurable runMCGenPair{"cfgRunMCGenPair", false, "Do pairing of true MC particles"}; + // Configurable runMCGenPair{"cfgRunMCGenPair", false, "Do pairing of true MC particles"}; } fConfigMC; + struct : ConfigurableGroup { + Configurable fConfigMiniTree{"useMiniTree.cfgMiniTree", false, "Produce a single flat table with minimal information for analysis"}; + Configurable fConfigMiniTreeMinMass{"useMiniTree.cfgMiniTreeMinMass", 2, "Min. mass cut for minitree"}; + Configurable fConfigMiniTreeMaxMass{"useMiniTree.cfgMiniTreeMaxMass", 5, "Max. mass cut for minitree"}; + } useMiniTree; + // Track related options Configurable fPropTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; Service fCCDB; // Filter filterEventSelected = aod::dqanalysisflags::isEventSelected & uint32_t(1); + Filter eventFilter = aod::dqanalysisflags::isEventSelected > static_cast(0); HistogramManager* fHistMan; @@ -1159,8 +1320,8 @@ struct AnalysisSameEventPairing { std::map> fBarrelHistNamesMCmatched; std::map> fMuonHistNames; std::map> fMuonHistNamesMCmatched; - std::vector fRecMCSignals; - std::vector fGenMCSignals; + std::vector fRecMCSignals; + std::vector fGenMCSignals; std::vector fPairCuts; @@ -1182,6 +1343,8 @@ struct AnalysisSameEventPairing { if (context.mOptions.get("processDummy")) { return; } + bool isMCGen = context.mOptions.get("processMCGen"); + VarManager::SetDefaultVarNames(); fEnableBarrelHistos = context.mOptions.get("processAllSkimmed") || context.mOptions.get("processBarrelOnlySkimmed") || context.mOptions.get("processBarrelOnlyWithCollSkimmed"); fEnableMuonHistos = context.mOptions.get("processAllSkimmed") || context.mOptions.get("processMuonOnlySkimmed"); @@ -1212,14 +1375,25 @@ struct AnalysisSameEventPairing { // Setting the MC rec signal names TString sigNamesStr = fConfigMC.recSignals.value; std::unique_ptr objRecSigArray(sigNamesStr.Tokenize(",")); - for (int isig = 0; isig < objRecSigArray->GetEntries(); ++isig) { MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objRecSigArray->At(isig)->GetName()); if (sig) { if (sig->GetNProngs() != 2) { // NOTE: 2-prong signals required continue; } - fRecMCSignals.push_back(*sig); + fRecMCSignals.push_back(sig); + } + } + + // Add the MCSignals from the JSON config + TString addMCSignalsStr = fConfigMC.recSignalsJSON.value; + if (addMCSignalsStr != "") { + std::vector addMCSignals = dqmcsignals::GetMCSignalsFromJSON(addMCSignalsStr.Data()); + for (auto& mcIt : addMCSignals) { + if (mcIt->GetNProngs() != 2) { // NOTE: only 2 prong signals + continue; + } + fRecMCSignals.push_back(mcIt); } } @@ -1227,6 +1401,16 @@ struct AnalysisSameEventPairing { string tempCuts; getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", tempCuts, false); TString tempCutsStr = tempCuts; + // check also the cuts added via JSON and add them to the string of cuts + getTaskOptionValue(context, "analysis-track-selection", "cfgBarrelTrackCutsJSON", tempCuts, false); + TString addTrackCutsStr = tempCuts; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + tempCutsStr += Form(",%s", t->GetName()); + } + } + // check that the barrel track cuts array required in this task is not empty if (!trackCutsStr.IsNull()) { // tokenize and loop over the barrel cuts produced by the barrel track selection task @@ -1282,18 +1466,18 @@ struct AnalysisSameEventPairing { for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { auto sig = fRecMCSignals.at(isig); names = { - Form("PairsBarrelSEPM_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsBarrelSEPP_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsBarrelSEMM_%s_%s", objArray->At(icut)->GetName(), sig.GetName())}; + Form("PairsBarrelSEPM_%s_%s", objArray->At(icut)->GetName(), sig->GetName()), + Form("PairsBarrelSEPP_%s_%s", objArray->At(icut)->GetName(), sig->GetName()), + Form("PairsBarrelSEMM_%s_%s", objArray->At(icut)->GetName(), sig->GetName())}; if (fConfigQA) { - names.push_back(Form("PairsBarrelSEPMCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsBarrelSEPMIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsBarrelSEPM_ambiguousInBunch_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsBarrelSEPM_ambiguousInBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsBarrelSEPM_ambiguousInBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunch_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); + names.push_back(Form("PairsBarrelSEPMCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsBarrelSEPMIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsBarrelSEPM_ambiguousInBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsBarrelSEPM_ambiguousInBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsBarrelSEPM_ambiguousInBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); } for (auto& n : names) { histNames += Form("%s;", n.Data()); @@ -1309,6 +1493,16 @@ struct AnalysisSameEventPairing { // get the muon track selection cuts getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCuts", tempCuts, false); tempCutsStr = tempCuts; + // check also the cuts added via JSON and add them to the string of cuts + getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCutsJSON", tempCuts, false); + TString addMuonCutsStr = tempCuts; + if (addMuonCutsStr != "") { + std::vector addMuonCuts = dqcuts::GetCutsFromJSON(addMuonCutsStr.Data()); + for (auto& t : addMuonCuts) { + tempCutsStr += Form(",%s", t->GetName()); + } + } + // check that in this task we have specified muon cuts if (!muonCutsStr.IsNull()) { // loop over the muon cuts computed by the muon selection task and build a filter mask for those required in this task @@ -1357,28 +1551,29 @@ struct AnalysisSameEventPairing { // assign hist directories for pairs matched to MC signals for each (muon cut, MCrec signal) combination if (!sigNamesStr.IsNull()) { - for (auto& sig : fRecMCSignals) { + for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { + auto sig = fRecMCSignals.at(isig); names = { - Form("PairsMuonSEPM_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsMuonSEPP_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsMuonSEMM_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), + Form("PairsMuonSEPM_%s_%s", objArray->At(icut)->GetName(), sig->GetName()), + Form("PairsMuonSEPP_%s_%s", objArray->At(icut)->GetName(), sig->GetName()), + Form("PairsMuonSEMM_%s_%s", objArray->At(icut)->GetName(), sig->GetName()), }; if (fConfigQA) { - names.push_back(Form("PairsMuonSEPMCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsMuonSEPMIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsMuonSEPM_ambiguousInBunch_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsMuonSEPM_ambiguousInBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsMuonSEPM_ambiguousInBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunch_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); - names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())); + names.push_back(Form("PairsMuonSEPMCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsMuonSEPMIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsMuonSEPM_ambiguousInBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsMuonSEPM_ambiguousInBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsMuonSEPM_ambiguousInBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunch_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); + names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig->GetName())); } for (auto& n : names) { histNames += Form("%s;", n.Data()); } + fMuonHistNamesMCmatched.try_emplace(icut * fRecMCSignals.size() + isig, names); } // end loop over MC signals } - fMuonHistNamesMCmatched[icut] = names; } } } // end loop over cuts @@ -1391,12 +1586,30 @@ struct AnalysisSameEventPairing { for (int isig = 0; isig < objGenSigArray->GetEntries(); isig++) { MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objGenSigArray->At(isig)->GetName()); if (sig) { - if (sig->GetNProngs() == 1) { // NOTE: 1-prong signals required - fGenMCSignals.push_back(*sig); + fGenMCSignals.push_back(sig); + } + } + + // Add the MCSignals from the JSON config + TString addMCSignalsGenStr = fConfigMC.genSignalsJSON.value; + if (addMCSignalsGenStr != "") { + std::vector addMCSignals = dqmcsignals::GetMCSignalsFromJSON(addMCSignalsGenStr.Data()); + for (auto& mcIt : addMCSignals) { + if (mcIt->GetNProngs() > 2) { // NOTE: only 2 prong signals + continue; + } + fGenMCSignals.push_back(mcIt); + } + } + + if (isMCGen) { + for (auto& sig : fGenMCSignals) { + if (sig->GetNProngs() == 1) { histNames += Form("MCTruthGen_%s;", sig->GetName()); // TODO: Add these names to a std::vector to avoid using Form in the process function - } else if (sig->GetNProngs() == 2) { // NOTE: 2-prong signals required - fGenMCSignals.push_back(*sig); + histNames += Form("MCTruthGenSel_%s;", sig->GetName()); + } else if (sig->GetNProngs() == 2) { histNames += Form("MCTruthGenPair_%s;", sig->GetName()); + histNames += Form("MCTruthGenPairSel_%s;", sig->GetName()); fHasTwoProngGenMCsignals = true; } } @@ -1419,7 +1632,6 @@ struct AnalysisSameEventPairing { VarManager::SetupMatLUTFwdDCAFitter(fLUT); } - VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); @@ -1427,6 +1639,7 @@ struct AnalysisSameEventPairing { VarManager::SetCollisionSystem((TString)fConfigOptions.collisionSystem, fConfigOptions.centerMassEnergy); // set collision system and center of mass energy DefineHistograms(fHistMan, histNames.Data(), fConfigAddSEPHistogram.value.data()); // define all histograms + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -1500,6 +1713,10 @@ struct AnalysisSameEventPairing { if (fConfigOptions.flatTables.value) { dimuonAllList.reserve(1); } + if (useMiniTree.fConfigMiniTree) { + dileptonMiniTreeGen.reserve(1); + dileptonMiniTreeRec.reserve(1); + } constexpr bool eventHasQvector = ((TEventFillMap & VarManager::ObjTypes::ReducedEventQvector) > 0); constexpr bool trackHasCov = ((TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelCov) > 0); @@ -1550,7 +1767,7 @@ struct AnalysisSameEventPairing { mcDecision = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { if (t1.has_reducedMCTrack() && t2.has_reducedMCTrack()) { - if ((*sig).CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack())) { + if ((*sig)->CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack())) { mcDecision |= (static_cast(1) << isig); } } @@ -1617,7 +1834,7 @@ struct AnalysisSameEventPairing { mcDecision = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { if (t1.has_reducedMCTrack() && t2.has_reducedMCTrack()) { - if ((*sig).CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack())) { + if ((*sig)->CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack())) { mcDecision |= (static_cast(1) << isig); } } @@ -1648,10 +1865,10 @@ struct AnalysisSameEventPairing { if constexpr (TTwoProngFitter) { dimuonsExtraList(t1.globalIndex(), t2.globalIndex(), VarManager::fgValues[VarManager::kVertexingTauz], VarManager::fgValues[VarManager::kVertexingLz], VarManager::fgValues[VarManager::kVertexingLxy]); - if (fConfigOptions.flatTables.value) { + if (fConfigOptions.flatTables.value && t1.has_reducedMCTrack() && t2.has_reducedMCTrack()) { dimuonAllList(event.posX(), event.posY(), event.posZ(), event.numContrib(), event.selection_raw(), evSel, - -999., -999., -999., + event.reducedMCevent().mcPosX(), event.reducedMCevent().mcPosY(), event.reducedMCevent().mcPosZ(), VarManager::fgValues[VarManager::kMass], mcDecision, VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], t1.sign() + t2.sign(), VarManager::fgValues[VarManager::kVertexingChi2PCA], @@ -1661,15 +1878,15 @@ struct AnalysisSameEventPairing { VarManager::fgValues[VarManager::kPt1], VarManager::fgValues[VarManager::kEta1], VarManager::fgValues[VarManager::kPhi1], t1.sign(), VarManager::fgValues[VarManager::kPt2], VarManager::fgValues[VarManager::kEta2], VarManager::fgValues[VarManager::kPhi2], t2.sign(), t1.fwdDcaX(), t1.fwdDcaY(), t2.fwdDcaX(), t2.fwdDcaY(), - 0., 0., + t1.mcMask(), t2.mcMask(), t1.chi2MatchMCHMID(), t2.chi2MatchMCHMID(), t1.chi2MatchMCHMFT(), t2.chi2MatchMCHMFT(), t1.chi2(), t2.chi2(), - -999., -999., -999., -999., - -999., -999., -999., -999., - -999., -999., -999., -999., - -999., -999., -999., -999., - (twoTrackFilter & (static_cast(1) << 28)) || (twoTrackFilter & (static_cast(1) << 30)), (twoTrackFilter & (static_cast(1) << 29)) || (twoTrackFilter & (static_cast(1) << 31)), + t1.reducedMCTrack().pt(), t1.reducedMCTrack().eta(), t1.reducedMCTrack().phi(), t1.reducedMCTrack().e(), + t2.reducedMCTrack().pt(), t2.reducedMCTrack().eta(), t2.reducedMCTrack().phi(), t2.reducedMCTrack().e(), + t1.reducedMCTrack().vx(), t1.reducedMCTrack().vy(), t1.reducedMCTrack().vz(), t1.reducedMCTrack().vt(), + t2.reducedMCTrack().vx(), t2.reducedMCTrack().vy(), t2.reducedMCTrack().vz(), t2.reducedMCTrack().vt(), + (twoTrackFilter & (static_cast(1) << 28)) || (twoTrackFilter & (static_cast(1) << 29)), (twoTrackFilter & (static_cast(1) << 30)) || (twoTrackFilter & (static_cast(1) << 31)), -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, -999.0, VarManager::fgValues[VarManager::kMultDimuons], @@ -1685,6 +1902,10 @@ struct AnalysisSameEventPairing { // Fill histograms bool isAmbiInBunch = false; bool isAmbiOutOfBunch = false; + bool isCorrect_pair = false; + if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) + isCorrect_pair = true; + for (int icut = 0; icut < ncuts; icut++) { if (twoTrackFilter & (static_cast(1) << icut)) { isAmbiInBunch = (twoTrackFilter & (static_cast(1) << 28)) || (twoTrackFilter & (static_cast(1) << 29)); @@ -1693,7 +1914,47 @@ struct AnalysisSameEventPairing { fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); // reconstructed, unmatched for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals if (mcDecision & (static_cast(1) << isig)) { + PromptNonPromptSepTable(VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kVertexingTauxyProjected], VarManager::fgValues[VarManager::kVertexingTauxyProjectedPoleJPsiMass], VarManager::fgValues[VarManager::kVertexingTauzProjected], isAmbiInBunch, isAmbiOutOfBunch, isCorrect_pair); fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][0].Data(), VarManager::fgValues); // matched signal + if (useMiniTree.fConfigMiniTree) { + if constexpr (TPairType == VarManager::kDecayToMuMu) { + twoTrackFilter = a1.isMuonSelected_raw() & a2.isMuonSelected_raw() & fMuonFilterMask; + if (!twoTrackFilter) { // the tracks must have at least one filter bit in common to continue + continue; + } + auto t1 = a1.template reducedmuon_as(); + auto t2 = a2.template reducedmuon_as(); + + float dileptonMass = VarManager::fgValues[VarManager::kMass]; + if (dileptonMass > useMiniTree.fConfigMiniTreeMinMass && dileptonMass < useMiniTree.fConfigMiniTreeMaxMass) { + // In the miniTree the positive daughter is positioned as first + if (t1.sign() > 0) { + dileptonMiniTreeRec(mcDecision, + VarManager::fgValues[VarManager::kMass], + VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], VarManager::fgValues[VarManager::kCentFT0C], + t1.reducedMCTrack().pt(), t1.reducedMCTrack().eta(), t1.reducedMCTrack().phi(), + t2.reducedMCTrack().pt(), t2.reducedMCTrack().eta(), t2.reducedMCTrack().phi(), + t1.pt(), t1.eta(), t1.phi(), + t2.pt(), t2.eta(), t2.phi()); + } else { + dileptonMiniTreeRec(mcDecision, + VarManager::fgValues[VarManager::kMass], + VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], VarManager::fgValues[VarManager::kCentFT0C], + t2.reducedMCTrack().pt(), t2.reducedMCTrack().eta(), t2.reducedMCTrack().phi(), + t1.reducedMCTrack().pt(), t1.reducedMCTrack().eta(), t1.reducedMCTrack().phi(), + t2.pt(), t2.eta(), t2.phi(), + t2.pt(), t2.eta(), t2.phi()); + } + dileptonMiniTreeRec(mcDecision, + VarManager::fgValues[VarManager::kMass], + VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], VarManager::fgValues[VarManager::kCentFT0C], + t1.reducedMCTrack().pt(), t1.reducedMCTrack().eta(), t1.reducedMCTrack().phi(), + t2.reducedMCTrack().pt(), t2.reducedMCTrack().eta(), t2.reducedMCTrack().phi(), + VarManager::fgValues[VarManager::kPt1], VarManager::fgValues[VarManager::kEta1], VarManager::fgValues[VarManager::kPhi1], + VarManager::fgValues[VarManager::kPt2], VarManager::fgValues[VarManager::kEta2], VarManager::fgValues[VarManager::kPhi2]); + } + } + } if (fConfigQA) { if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) { // correct track-collision association fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][3].Data(), VarManager::fgValues); @@ -1783,18 +2044,21 @@ struct AnalysisSameEventPairing { // Preslice perReducedMcEvent = aod::reducedtrackMC::reducedMCeventId; PresliceUnsorted perReducedMcEvent = aod::reducedtrackMC::reducedMCeventId; + template void runMCGen(ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) { // loop over mc stack and fill histograms for pure MC truth signals // group all the MC tracks which belong to the MC event corresponding to the current reconstructed event // auto groupedMCTracks = tracksMC.sliceBy(aod::reducedtrackMC::reducedMCeventId, event.reducedMCevent().globalIndex()); + uint32_t mcDecision = 0; + int isig = 0; for (auto& mctrack : mcTracks) { VarManager::FillTrackMC(mcTracks, mctrack); // NOTE: Signals are checked here mostly based on the skimmed MC stack, so depending on the requested signal, the stack could be incomplete. // NOTE: However, the working model is that the decisions on MC signals are precomputed during skimming and are stored in the mcReducedFlags member. // TODO: Use the mcReducedFlags to select signals for (auto& sig : fGenMCSignals) { - if (sig.GetNProngs() != 1) { // NOTE: 1-prong signals required here + if (sig->GetNProngs() != 1) { // NOTE: 1-prong signals required here continue; } bool checked = false; @@ -1802,32 +2066,42 @@ struct AnalysisSameEventPairing { auto mctrack_raw = groupedMCTracks.rawIteratorAt(mctrack.globalIndex()); checked = sig.CheckSignal(true, mctrack_raw); } else {*/ - checked = sig.CheckSignal(true, mctrack); + checked = sig->CheckSignal(true, mctrack); //} if (checked) { - fHistMan->FillHistClass(Form("MCTruthGen_%s", sig.GetName()), VarManager::fgValues); + mcDecision |= (static_cast(1) << isig); + fHistMan->FillHistClass(Form("MCTruthGen_%s", sig->GetName()), VarManager::fgValues); + if (useMiniTree.fConfigMiniTree) { + auto mcEvent = mcEvents.rawIteratorAt(mctrack.reducedMCeventId()); + dileptonMiniTreeGen(mcDecision, mcEvent.impactParameter(), mctrack.pt(), mctrack.eta(), mctrack.phi(), -999, -999, -999); + } } } + isig++; } if (fHasTwoProngGenMCsignals) { - for (auto& event : mcEvents) { - auto groupedMCTracks = mcTracks.sliceBy(perReducedMcEvent, event.globalIndex()); - groupedMCTracks.bindInternalIndicesTo(&mcTracks); - for (auto& [t1, t2] : combinations(groupedMCTracks, groupedMCTracks)) { - auto t1_raw = groupedMCTracks.rawIteratorAt(t1.globalIndex()); - auto t2_raw = groupedMCTracks.rawIteratorAt(t2.globalIndex()); + for (auto& [t1, t2] : combinations(mcTracks, mcTracks)) { + auto t1_raw = mcTracks.rawIteratorAt(t1.globalIndex()); + auto t2_raw = mcTracks.rawIteratorAt(t2.globalIndex()); + if (t1_raw.reducedMCeventId() == t2_raw.reducedMCeventId()) { for (auto& sig : fGenMCSignals) { - if (sig.GetNProngs() != 2) { // NOTE: 2-prong signals required here + if (sig->GetNProngs() != 2) { // NOTE: 2-prong signals required here continue; } - if (sig.CheckSignal(true, t1_raw, t2_raw)) { - VarManager::FillPairMC(t1, t2); - fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig.GetName()), VarManager::fgValues); + if (sig->CheckSignal(true, t1_raw, t2_raw)) { + mcDecision |= (static_cast(1) << isig); + VarManager::FillPairMC(t1, t2); + fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig->GetName()), VarManager::fgValues); + if (useMiniTree.fConfigMiniTree) { + // WARNING! To be checked + dileptonMiniTreeGen(mcDecision, -999, t1.pt(), t1.eta(), t1.phi(), t2.pt(), t2.eta(), t2.phi()); + } } - } // end loop over MC signals - } // end loop over pairs - } // end loop over events + isig++; + } + } + } } } // end runMCGen @@ -1838,9 +2112,10 @@ struct AnalysisSameEventPairing { { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks); runSameEventPairing(events, muonAssocsPerCollision, muonAssocs, muons, mcEvents, mcTracks); - if (fConfigMC.runMCGenPair) { - runMCGen(mcEvents, mcTracks); - } + // Feature replaced by processMCGen + /*if (fConfigMC.runMCGenPair) { + runMCGen(mcEvents, mcTracks); + }*/ // runSameEventPairing(event, tracks, muons); } @@ -1849,9 +2124,10 @@ struct AnalysisSameEventPairing { MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks); - if (fConfigMC.runMCGenPair) { - runMCGen(mcEvents, mcTracks); - } + // Feature replaced by processMCGen + /*if (fConfigMC.runMCGenPair) { + runMCGen(mcEvents, mcTracks); + }*/ } void processBarrelOnlyWithCollSkimmed(MyEventsVtxCovSelected const& events, @@ -1859,17 +2135,82 @@ struct AnalysisSameEventPairing { MyBarrelTracksWithCovWithAmbiguitiesWithColl const& barrelTracks, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks); - if (fConfigMC.runMCGenPair) { - runMCGen(mcEvents, mcTracks); - } + // Feature replaced by processMCGen + /* if (fConfigMC.runMCGenPair) { + runMCGen(mcEvents, mcTracks); + }*/ } void processMuonOnlySkimmed(MyEventsVtxCovSelected const& events, soa::Join const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) { runSameEventPairing(events, muonAssocsPerCollision, muonAssocs, muons, mcEvents, mcTracks); - if (fConfigMC.runMCGenPair) { - runMCGen(mcEvents, mcTracks); + // Feature replaced by processMCGen + /* if (fConfigMC.runMCGenPair) { + runMCGen(mcEvents, mcTracks); + }*/ + } + + PresliceUnsorted perReducedMcGenEvent = aod::reducedtrackMC::reducedMCeventId; + + void processMCGen(soa::Filtered const& events, ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& mcTracks) + { + // Fill Generated histograms taking into account all generated tracks + for (auto& mctrack : mcTracks) { + VarManager::FillTrackMC(mcTracks, mctrack); + // NOTE: Signals are checked here mostly based on the skimmed MC stack, so depending on the requested signal, the stack could be incomplete. + // NOTE: However, the working model is that the decisions on MC signals are precomputed during skimming and are stored in the mcReducedFlags member. + // TODO: Use the mcReducedFlags to select signals + for (auto& sig : fGenMCSignals) { + if (sig->CheckSignal(true, mctrack)) { + fHistMan->FillHistClass(Form("MCTruthGen_%s", sig->GetName()), VarManager::fgValues); + } + } + } + + // Fill Generated histograms taking into account selected collisions + for (auto& event : events) { + if (!event.isEventSelected_bit(0)) { + continue; + } + if (!event.has_reducedMCevent()) { + continue; + } + + // auto groupedMCTracks = mcTracks.sliceBy(perReducedMcGenEvent, event.reducedMCeventId()); + // groupedMCTracks.bindInternalIndicesTo(&mcTracks); + // for (auto& track : groupedMCTracks) { + for (auto& track : mcTracks) { + if (track.reducedMCeventId() != event.reducedMCeventId()) { + continue; + } + VarManager::FillTrackMC(mcTracks, track); + auto track_raw = mcTracks.rawIteratorAt(track.globalIndex()); + // auto track_raw = groupedMCTracks.rawIteratorAt(track.globalIndex()); + for (auto& sig : fGenMCSignals) { + if (sig->CheckSignal(true, track_raw)) { + fHistMan->FillHistClass(Form("MCTruthGenSel_%s", sig->GetName()), VarManager::fgValues); + } + } + } + } // end loop over reconstructed events + if (fHasTwoProngGenMCsignals) { + for (auto& [t1, t2] : combinations(mcTracks, mcTracks)) { + auto t1_raw = mcTracks.rawIteratorAt(t1.globalIndex()); + auto t2_raw = mcTracks.rawIteratorAt(t2.globalIndex()); + if (t1_raw.reducedMCeventId() == t2_raw.reducedMCeventId()) { + for (auto& sig : fGenMCSignals) { + if (sig->GetNProngs() != 2) { // NOTE: 2-prong signals required here + continue; + } + if (sig->CheckSignal(true, t1_raw, t2_raw)) { + // mcDecision |= (static_cast(1) << isig); + VarManager::FillPairMC(t1, t2); // NOTE: This feature will only work for muons + fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig->GetName()), VarManager::fgValues); + } + } + } + } } } @@ -1882,6 +2223,7 @@ struct AnalysisSameEventPairing { PROCESS_SWITCH(AnalysisSameEventPairing, processBarrelOnlySkimmed, "Run barrel only pairing, with skimmed tracks", false); PROCESS_SWITCH(AnalysisSameEventPairing, processBarrelOnlyWithCollSkimmed, "Run barrel only pairing, with skimmed tracks and with collision information", false); PROCESS_SWITCH(AnalysisSameEventPairing, processMuonOnlySkimmed, "Run muon only pairing, with skimmed tracks", false); + PROCESS_SWITCH(AnalysisSameEventPairing, processMCGen, "Loop over MC particle stack and fill generator level histograms", false); PROCESS_SWITCH(AnalysisSameEventPairing, processDummy, "Dummy function, enabled only if none of the others are enabled", false); }; @@ -1904,12 +2246,15 @@ struct AnalysisAsymmetricPairing { Configurable fConfigLegCFilterMask{"cfgLegCFilterMask", 0, "Filter mask corresponding to cuts in event-selection"}; Configurable fConfigCommonTrackCuts{"cfgCommonTrackCuts", "", "Comma separated list of cuts to be applied to all legs"}; Configurable fConfigPairCuts{"cfgPairCuts", "", "Comma separated list of pair cuts"}; + Configurable fConfigPairCutsJSON{"cfgPairCutsJSON", "", "Additional list of pair cuts in JSON format"}; Configurable fConfigSkipAmbiguousIdCombinations{"cfgSkipAmbiguousIdCombinations", true, "Choose whether to skip pairs/triples which pass a stricter combination of cuts, e.g. KKPi triplets for D+ -> KPiPi"}; Configurable fConfigHistogramSubgroups{"cfgAsymmetricPairingHistogramsSubgroups", "barrel,vertexing", "Comma separated list of asymmetric-pairing histogram subgroups"}; Configurable fConfigSameSignHistograms{"cfgSameSignHistograms", false, "Include same sign pair histograms for 2-prong decays"}; // Configurable fConfigAmbiguousHistograms{"cfgAmbiguousHistograms", false, "Include separate histograms for pairs/triplets with ambiguous tracks"}; + Configurable fConfigReflectedHistograms{"cfgReflectedHistograms", false, "Include separate histograms for pairs which are reflections of previously counted pairs"}; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable fConfigGRPMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; @@ -1921,27 +2266,29 @@ struct AnalysisAsymmetricPairing { Configurable fConfigPropToPCA{"cfgPropToPCA", false, "Propagate tracks to secondary vertex"}; Configurable fConfigLutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable fConfigRunMCGenPair{"cfgRunMCGenPair", false, "Do pairing of true MC particles"}; Configurable fConfigMCGenSignals{"cfgBarrelMCGenSignals", "", "Comma separated list of MC signals (generated)"}; Configurable fConfigMCRecSignals{"cfgBarrelMCRecSignals", "", "Comma separated list of MC signals (reconstructed)"}; + Configurable fConfigMCRecSignalsJSON{"cfgMCRecSignalsJSON", "", "Additional list of MC signals (reconstructed) via JSON"}; + Configurable fConfigMCGenSignalsJSON{"cfgMCGenSignalsJSON", "", "Comma separated list of MC signals (generated) via JSON"}; Service fCCDB; HistogramManager* fHistMan; - std::map> fTrackHistNames; - std::map> fBarrelHistNamesMCmatched; - std::vector fPairCuts; + std::vector fPairCuts; + int fNPairHistPrefixes; - std::vector fRecMCSignals; - std::vector fGenMCSignals; + std::vector fRecMCSignals; + std::vector fGenMCSignals; // Filter masks to find legs in BarrelTrackCuts table uint32_t fLegAFilterMask; uint32_t fLegBFilterMask; uint32_t fLegCFilterMask; - // Map tracking which pair of leg cuts the track cuts participate in - std::map fTrackCutFilterMasks; + // Maps tracking which combination of leg cuts the track cuts participate in + std::map fConstructedLegAFilterMasksMap; + std::map fConstructedLegBFilterMasksMap; + std::map fConstructedLegCFilterMasksMap; // Filter map for common track cuts uint32_t fCommonTrackCutMask; // Map tracking which common track cut the track cuts correspond to @@ -1950,6 +2297,13 @@ struct AnalysisAsymmetricPairing { int fNLegCuts; int fNPairCuts = 0; int fNCommonTrackCuts; + // vectors for cut names and signal names, for easy access when calling FillHistogramList() + std::vector fLegCutNames; + std::vector fPairCutNames; + std::vector fCommonCutNames; + std::vector fRecMCSignalNames; + + Filter eventFilter = aod::dqanalysisflags::isEventSelected > static_cast(0); Preslice> trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId; @@ -1958,43 +2312,89 @@ struct AnalysisAsymmetricPairing { Partition> legBCandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fConfigLegBFilterMask) > static_cast(0); Partition> legCCandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fConfigLegCFilterMask) > static_cast(0); + // Map to track how many times a pair of tracks has been encountered + std::map, int8_t> fPairCount; + void init(o2::framework::InitContext& context) { + bool isMCGen = context.mOptions.get("processMCGen") || context.mOptions.get("processMCGenWithEventSelection"); if (context.mOptions.get("processDummy")) { return; } - TString histNames = ""; - std::vector names; + VarManager::SetDefaultVarNames(); + fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); + fHistMan->SetUseDefaultVariableNames(kTRUE); + fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); - // Get the leg cut filter maps + // Get the leg cut filter masks fLegAFilterMask = fConfigLegAFilterMask.value; fLegBFilterMask = fConfigLegBFilterMask.value; fLegCFilterMask = fConfigLegCFilterMask.value; + // Get the pair cuts TString cutNamesStr = fConfigPairCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fPairCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fPairCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + } + } + // Extra pair cuts via JSON + TString addPairCutsStr = fConfigPairCutsJSON.value; + if (addPairCutsStr != "") { + std::vector addPairCuts = dqcuts::GetCutsFromJSON(addPairCutsStr.Data()); + for (auto& t : addPairCuts) { + fPairCuts.push_back(reinterpret_cast(t)); + cutNamesStr += Form(",%s", t->GetName()); } } + std::unique_ptr objArrayPairCuts(cutNamesStr.Tokenize(",")); + fNPairCuts = objArrayPairCuts->GetEntries(); + for (int j = 0; j < fNPairCuts; j++) { + fPairCutNames.push_back(objArrayPairCuts->At(j)->GetName()); + } // Setting the MC rec signal names TString sigNamesStr = fConfigMCRecSignals.value; std::unique_ptr objRecSigArray(sigNamesStr.Tokenize(",")); - for (int isig = 0; isig < objRecSigArray->GetEntries(); ++isig) { MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objRecSigArray->At(isig)->GetName()); if (sig) { - fRecMCSignals.push_back(*sig); + fRecMCSignals.push_back(sig); } } + // Add the reco MCSignals from the JSON config + TString addMCSignalsStr = fConfigMCRecSignalsJSON.value; + if (addMCSignalsStr != "") { + std::vector addMCSignals = dqmcsignals::GetMCSignalsFromJSON(addMCSignalsStr.Data()); + for (auto& mcIt : addMCSignals) { + if (mcIt->GetNProngs() != 2 && mcIt->GetNProngs() != 3) { + LOG(fatal) << "Signal at reconstructed level requested (" << mcIt->GetName() << ") " << "does not have 2 or 3 prongs! Fix it"; + } + fRecMCSignals.push_back(mcIt); + sigNamesStr += Form(",%s", mcIt->GetName()); + } + } + // Put all the reco MCSignal names in the vector for histogram naming + std::unique_ptr objArrayRecMCSignals(sigNamesStr.Tokenize(",")); + for (int i = 0; i < objArrayRecMCSignals->GetEntries(); i++) { + fRecMCSignalNames.push_back(objArrayRecMCSignals->At(i)->GetName()); + } // Get the barrel track selection cuts string tempCuts; getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", tempCuts, false); TString tempCutsStr = tempCuts; + // check also the cuts added via JSON and add them to the string of cuts + getTaskOptionValue(context, "analysis-track-selection", "cfgBarrelTrackCutsJSON", tempCuts, false); + TString addTrackCutsStr = tempCuts; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + tempCutsStr += Form(",%s", t->GetName()); + } + } std::unique_ptr objArray(tempCutsStr.Tokenize(",")); // Get the common leg cuts int commonCutIdx; @@ -2007,6 +2407,7 @@ struct AnalysisAsymmetricPairing { if (commonCutIdx >= 0) { fCommonTrackCutMask |= static_cast(1) << objArray->IndexOf(objArrayCommon->At(icut)); fCommonTrackCutFilterMasks[icut] = static_cast(1) << objArray->IndexOf(objArrayCommon->At(icut)); + fCommonCutNames.push_back(objArrayCommon->At(icut)->GetName()); } else { LOGF(fatal, "Common track cut %s was not calculated upstream. Check the config!", objArrayCommon->At(icut)->GetName()); } @@ -2029,7 +2430,7 @@ struct AnalysisAsymmetricPairing { uint32_t fConstructedLegCFilterMask = 0; TString legCutsStr = fConfigLegCuts.value; std::unique_ptr objArrayLegs(legCutsStr.Tokenize(",")); - if (objArrayLegs->GetEntries() == 0) { + if (objArrayLegs->GetEntries() == 0 && !isMCGen) { LOG(fatal) << "No cuts defining legs. Check the config!"; } fNLegCuts = objArrayLegs->GetEntries(); @@ -2053,7 +2454,7 @@ struct AnalysisAsymmetricPairing { legAIdx = objArray->IndexOf(legs->At(0)); if (legAIdx >= 0) { fConstructedLegAFilterMask |= static_cast(1) << legAIdx; - fTrackCutFilterMasks[icut] |= static_cast(1) << legAIdx; + fConstructedLegAFilterMasksMap[icut] |= static_cast(1) << legAIdx; } else { LOGF(fatal, "Leg A cut %s was not calculated upstream. Check the config!", legs->At(0)->GetName()); continue; @@ -2061,7 +2462,7 @@ struct AnalysisAsymmetricPairing { legBIdx = objArray->IndexOf(legs->At(1)); if (legBIdx >= 0) { fConstructedLegBFilterMask |= static_cast(1) << legBIdx; - fTrackCutFilterMasks[icut] |= static_cast(1) << legBIdx; + fConstructedLegBFilterMasksMap[icut] |= static_cast(1) << legBIdx; } else { LOGF(fatal, "Leg B cut %s was not calculated upstream. Check the config!", legs->At(1)->GetName()); continue; @@ -2070,28 +2471,25 @@ struct AnalysisAsymmetricPairing { legCIdx = objArray->IndexOf(legs->At(2)); if (legCIdx >= 0) { fConstructedLegCFilterMask |= static_cast(1) << legCIdx; - fTrackCutFilterMasks[icut] |= static_cast(1) << legCIdx; + fConstructedLegCFilterMasksMap[icut] |= static_cast(1) << legCIdx; } else { LOGF(fatal, "Leg C cut %s was not calculated upstream. Check the config!", legs->At(2)->GetName()); continue; } } + // Leg cut config is fine, store the leg cut name in a vector + fLegCutNames.push_back(legsStr); + + // Define histogram and histogram directory names if (isThreeProng[icut]) { - names = { - Form("TripletsBarrelSE_%s", legsStr.Data())}; - histNames += Form("%s;", names[0].Data()); + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s", legsStr.Data()), fConfigHistogramSubgroups.value.data()); if (fConfigQA) { - names.push_back(Form("TripletsBarrelSE_ambiguous_%s", legsStr.Data())); - histNames += Form("%s;", names[1].Data()); + DefineHistograms(fHistMan, Form("TripletsBarrelSE_ambiguous_%s", legsStr.Data()), fConfigHistogramSubgroups.value.data()); } - fTrackHistNames[icut] = names; std::unique_ptr objArrayCommon(commonNamesStr.Tokenize(",")); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; - names.push_back(Form("TripletsBarrelSE_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName())); - histNames += Form("%s;", names[0].Data()); - fTrackHistNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName()), fConfigHistogramSubgroups.value.data()); } TString cutNamesStr = fConfigPairCuts.value; @@ -2099,15 +2497,9 @@ struct AnalysisAsymmetricPairing { std::unique_ptr objArrayPair(cutNamesStr.Tokenize(",")); fNPairCuts = objArrayPair->GetEntries(); for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { // loop over pair cuts - names = {}; - names.push_back(Form("TripletsBarrelSE_%s_%s", legsStr.Data(), objArrayPair->At(iPairCut)->GetName())); - histNames += Form("%s;", names[0].Data()); - fTrackHistNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s", legsStr.Data(), objArrayPair->At(iPairCut)->GetName()), fConfigHistogramSubgroups.value.data()); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; - names.push_back(Form("TripletsBarrelSE_%s_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName())); - histNames += Form("%s;", names[0].Data()); - fTrackHistNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName()), fConfigHistogramSubgroups.value.data()); } // end loop (common cuts) } // end loop (pair cuts) } // end if (pair cuts) @@ -2116,84 +2508,63 @@ struct AnalysisAsymmetricPairing { if (!sigNamesStr.IsNull()) { for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { auto sig = fRecMCSignals.at(isig); - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); - names = { - Form("TripletsBarrelSE_%s_%s", legsStr.Data(), sig.GetName())}; - histNames += Form("%s;", names[0].Data()); - fBarrelHistNamesMCmatched[offset + icut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s", legsStr.Data(), sig->GetName()), fConfigHistogramSubgroups.value.data()); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; - names.push_back(Form("TripletsBarrelSE_%s_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), sig.GetName())); - histNames += Form("%s;", names[0].Data()); - fBarrelHistNamesMCmatched[offset + fNLegCuts + icut * fNCommonTrackCuts + iCommonCut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), sig->GetName()), fConfigHistogramSubgroups.value.data()); } if (!cutNamesStr.IsNull()) { // if pair cuts std::unique_ptr objArrayPair(cutNamesStr.Tokenize(",")); for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { // loop over pair cuts - names = {}; - names.push_back(Form("TripletsBarrelSE_%s_%s_%s", legsStr.Data(), objArrayPair->At(iPairCut)->GetName(), sig.GetName())); - histNames += Form("%s;", names[0].Data()); - fBarrelHistNamesMCmatched[offset + fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s_%s", legsStr.Data(), objArrayPair->At(iPairCut)->GetName(), sig->GetName()), fConfigHistogramSubgroups.value.data()); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; - names.push_back(Form("TripletsBarrelSE_%s_%s_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName(), sig.GetName())); - histNames += Form("%s;", names[0].Data()); - fBarrelHistNamesMCmatched[offset + (fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName(), sig->GetName()), fConfigHistogramSubgroups.value.data()); } // end loop (common cuts) } // end loop (pair cuts) } // end if (pair cuts) } // end loop over MC signals } // end if (MC signals) } else { - names = {}; std::vector pairHistPrefixes = {"PairsBarrelSEPM"}; if (fConfigSameSignHistograms.value) { pairHistPrefixes.push_back("PairsBarrelSEPP"); pairHistPrefixes.push_back("PairsBarrelSEMM"); } - int fNPairHistPrefixes = pairHistPrefixes.size(); + fNPairHistPrefixes = pairHistPrefixes.size(); for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data()), fConfigHistogramSubgroups.value.data()); } if (fConfigQA) { for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_ambiguous_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data())); - histNames += Form("%s;", names[fNPairHistPrefixes + iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_ambiguous_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data()), fConfigHistogramSubgroups.value.data()); + } + } + if (fConfigReflectedHistograms.value) { + for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { + DefineHistograms(fHistMan, Form("%s_reflected_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data()), fConfigHistogramSubgroups.value.data()); } } - fTrackHistNames[icut] = names; std::unique_ptr objArrayCommon(commonNamesStr.Tokenize(",")); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName()), fConfigHistogramSubgroups.value.data()); } - fTrackHistNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut] = names; } if (!cutNamesStr.IsNull()) { // if pair cuts std::unique_ptr objArrayPair(cutNamesStr.Tokenize(",")); fNPairCuts = objArrayPair->GetEntries(); for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { // loop over pair cuts - names = {}; for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayPair->At(iPairCut)->GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayPair->At(iPairCut)->GetName()), fConfigHistogramSubgroups.value.data()); } - fTrackHistNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = names; for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName()), fConfigHistogramSubgroups.value.data()); } - fTrackHistNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut] = names; } // end loop (common cuts) } // end loop (pair cuts) } // end if (pair cuts) @@ -2202,39 +2573,31 @@ struct AnalysisAsymmetricPairing { if (!sigNamesStr.IsNull()) { for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { auto sig = fRecMCSignals.at(isig); - names = {}; - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), sig.GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), sig->GetName()), fConfigHistogramSubgroups.value.data()); + } + if (fConfigReflectedHistograms.value) { + for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { + DefineHistograms(fHistMan, Form("%s_reflected_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), sig->GetName()), fConfigHistogramSubgroups.value.data()); + } } - fBarrelHistNamesMCmatched[offset + icut] = names; for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), sig.GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), sig->GetName()), fConfigHistogramSubgroups.value.data()); } - fBarrelHistNamesMCmatched[offset + fNLegCuts + icut * fNCommonTrackCuts + iCommonCut] = names; } if (!cutNamesStr.IsNull()) { // if pair cuts std::unique_ptr objArrayPair(cutNamesStr.Tokenize(",")); for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { // loop over pair cuts - names = {}; for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayPair->At(iPairCut)->GetName(), sig.GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayPair->At(iPairCut)->GetName(), sig->GetName()), fConfigHistogramSubgroups.value.data()); } - fBarrelHistNamesMCmatched[offset + fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = names; for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName(), sig.GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName(), sig->GetName()), fConfigHistogramSubgroups.value.data()); } - fBarrelHistNamesMCmatched[offset + (fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut] = names; } // end loop (common cuts) } // end loop (pair cuts) } // end if (pair cuts) @@ -2251,8 +2614,22 @@ struct AnalysisAsymmetricPairing { MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objGenSigArray->At(isig)->GetName()); if (sig) { if (sig->GetNProngs() == 1) { // NOTE: 1-prong signals required - fGenMCSignals.push_back(*sig); - histNames += Form("MCTruthGen_%s;", sig->GetName()); // TODO: Add these names to a std::vector to avoid using Form in the process function + fGenMCSignals.push_back(sig); + DefineHistograms(fHistMan, Form("MCTruthGen_%s;", sig->GetName()), fConfigHistogramSubgroups.value.data()); // TODO: Add these names to a std::vector to avoid using Form in the process function + DefineHistograms(fHistMan, Form("MCTruthGenSel_%s;", sig->GetName()), fConfigHistogramSubgroups.value.data()); // TODO: Add these names to a std::vector to avoid using Form in the process function + } + } + } + + // Add the gen MCSignals from the JSON config + addMCSignalsStr = fConfigMCGenSignalsJSON.value; + if (addMCSignalsStr != "") { + std::vector addMCSignals = dqmcsignals::GetMCSignalsFromJSON(addMCSignalsStr.Data()); + for (auto& mcIt : addMCSignals) { + if (mcIt->GetNProngs() == 1) { + fGenMCSignals.push_back(mcIt); + DefineHistograms(fHistMan, Form("MCTruthGen_%s;", mcIt->GetName()), fConfigHistogramSubgroups.value.data()); // TODO: Add these names to a std::vector to avoid using Form in the process function + DefineHistograms(fHistMan, Form("MCTruthGenSel_%s;", mcIt->GetName()), fConfigHistogramSubgroups.value.data()); // TODO: Add these names to a std::vector to avoid using Form in the process function } } } @@ -2282,12 +2659,7 @@ struct AnalysisAsymmetricPairing { fLUT = o2::base::MatLayerCylSet::rectifyPtrFromFile(fCCDB->get(fConfigLutPath)); VarManager::SetupMatLUTFwdDCAFitter(fLUT); - VarManager::SetDefaultVarNames(); - fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); - fHistMan->SetUseDefaultVariableNames(kTRUE); - fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); - - DefineHistograms(fHistMan, histNames.Data(), fConfigHistogramSubgroups.value.data()); // define all histograms + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -2336,6 +2708,8 @@ struct AnalysisAsymmetricPairing { template void runAsymmetricPairing(TEvents const& events, Preslice& preslice, TTrackAssocs const& /*assocs*/, TTracks const& /*tracks*/, ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& /*mcTracks*/) { + fPairCount.clear(); + if (events.size() > 0) { // Additional protection to avoid crashing of events.begin().runNumber() if (fCurrentRun != events.begin().runNumber()) { initParamsFromCCDB(events.begin().timestamp(), false); @@ -2343,9 +2717,6 @@ struct AnalysisAsymmetricPairing { } } - std::map> histNamesMC = fBarrelHistNamesMCmatched; - std::map> histNames = fTrackHistNames; - int sign1 = 0; int sign2 = 0; uint32_t mcDecision = 0; @@ -2379,7 +2750,7 @@ struct AnalysisAsymmetricPairing { bool isPairIdWrong = false; for (int icut = 0; icut < fNLegCuts; ++icut) { // Find leg pair definitions both candidates participate in - if ((((a1.isBarrelSelected_raw() & fLegAFilterMask) | (a2.isBarrelSelected_raw() & fLegBFilterMask)) & fTrackCutFilterMasks[icut]) == fTrackCutFilterMasks[icut]) { + if ((a1.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) && (a2.isBarrelSelected_raw() & fConstructedLegBFilterMasksMap[icut])) { twoTrackFilter |= static_cast(1) << icut; // If the supposed pion passes a kaon cut, this is a K+K-. Skip it. if (TPairType == VarManager::kDecayToKPi && fConfigSkipAmbiguousIdCombinations.value) { @@ -2405,6 +2776,18 @@ struct AnalysisAsymmetricPairing { continue; } + bool isReflected = false; + std::pair trackIds(t1.globalIndex(), t2.globalIndex()); + if (fPairCount.find(trackIds) != fPairCount.end()) { + // Double counting is possible due to track-collision ambiguity. Skip pairs which were counted before + fPairCount[trackIds] += 1; + continue; + } + if (fPairCount.find(std::pair(trackIds.second, trackIds.first)) != fPairCount.end()) { + isReflected = true; + } + fPairCount[trackIds] += 1; + sign1 = t1.sign(); sign2 = t2.sign(); // store the ambiguity number of the two dilepton legs in the last 4 digits of the two-track filter @@ -2420,7 +2803,8 @@ struct AnalysisAsymmetricPairing { mcDecision = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { if (t1.has_reducedMCTrack() && t2.has_reducedMCTrack()) { - if ((*sig).CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack())) { + VarManager::FillPairMC(t1.reducedMCTrack(), t2.reducedMCTrack()); + if ((*sig)->CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack())) { mcDecision |= static_cast(1) << isig; } } @@ -2437,33 +2821,50 @@ struct AnalysisAsymmetricPairing { if (twoTrackFilter & (static_cast(1) << icut)) { isAmbi = (twoTrackFilter & (static_cast(1) << 30)) || (twoTrackFilter & (static_cast(1) << 31)); if (sign1 * sign2 < 0) { // +- pairs - fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); // reconstructed, unmatched + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s", fLegCutNames[icut].Data()), VarManager::fgValues); // reconstructed, unmatched if (isAmbi && fConfigQA) { - fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_ambiguous_%s", fLegCutNames[icut].Data()), VarManager::fgValues); + } + if (isReflected && fConfigReflectedHistograms.value) { + fHistMan->FillHistClass(Form("PairsBarrelSEPM_reflected_%s", fLegCutNames[icut].Data()), VarManager::fgValues); } } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { // ++ pairs - fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s", fLegCutNames[icut].Data()), VarManager::fgValues); if (isAmbi && fConfigQA) { - fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_ambiguous_%s", fLegCutNames[icut].Data()), VarManager::fgValues); + } + if (isReflected && fConfigReflectedHistograms.value) { + fHistMan->FillHistClass(Form("PairsBarrelSEPP_reflected_%s", fLegCutNames[icut].Data()), VarManager::fgValues); } } else { // -- pairs - fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s", fLegCutNames[icut].Data()), VarManager::fgValues); if (isAmbi && fConfigQA) { - fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_ambiguous_%s", fLegCutNames[icut].Data()), VarManager::fgValues); + } + if (isReflected && fConfigReflectedHistograms) { + fHistMan->FillHistClass(Form("PairsBarrelSEMM_reflected_%s", fLegCutNames[icut].Data()), VarManager::fgValues); } } } for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); if (mcDecision & (static_cast(1) << isig)) { if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNamesMC[offset + icut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s", fLegCutNames[icut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); + if (isReflected && fConfigReflectedHistograms.value) { + fHistMan->FillHistClass(Form("PairsBarrelSEPM_reflected_%s_%s", fLegCutNames[icut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); + } } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNamesMC[offset + icut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s", fLegCutNames[icut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); + if (isReflected && fConfigReflectedHistograms.value) { + fHistMan->FillHistClass(Form("PairsBarrelSEPP_reflected_%s_%s", fLegCutNames[icut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); + } } else { - fHistMan->FillHistClass(histNamesMC[offset + icut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s", fLegCutNames[icut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); + if (isReflected && fConfigReflectedHistograms.value) { + fHistMan->FillHistClass(Form("PairsBarrelSEMM_reflected_%s_%s", fLegCutNames[icut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); + } } } } @@ -2471,55 +2872,53 @@ struct AnalysisAsymmetricPairing { for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { if (twoTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) { if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data()), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data()), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data()), VarManager::fgValues); } } for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); if (mcDecision & (static_cast(1) << isig)) { if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNamesMC[offset + fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNamesMC[offset + fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNamesMC[offset + fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); } } } } } } // end loop (common cuts) - for (unsigned int iPairCut = 0; iPairCut < fPairCuts.size(); iPairCut++) { - AnalysisCompositeCut cut = fPairCuts.at(iPairCut); - if (!(cut.IsSelected(VarManager::fgValues))) // apply pair cuts + int iPairCut = 0; + for (auto cut = fPairCuts.begin(); cut != fPairCuts.end(); cut++, iPairCut++) { + if (!((*cut)->IsSelected(VarManager::fgValues))) // apply pair cuts continue; pairFilter |= (static_cast(1) << iPairCut); // Histograms with pair cuts if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } } for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); if (mcDecision & (static_cast(1) << isig)) { if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNamesMC[offset + fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNamesMC[offset + fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNamesMC[offset + fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); } } } @@ -2528,24 +2927,23 @@ struct AnalysisAsymmetricPairing { for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { if (twoTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) { if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } } for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); if (mcDecision & (static_cast(1) << isig)) { if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNamesMC[offset + (fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNamesMC[offset + (fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNamesMC[offset + (fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); } } } @@ -2576,9 +2974,6 @@ struct AnalysisAsymmetricPairing { } } - std::map> histNames = fTrackHistNames; - std::map> histNamesMC = fBarrelHistNamesMCmatched; - for (auto& event : events) { if (!event.isEventSelected_bit(0)) { continue; @@ -2603,12 +2998,12 @@ struct AnalysisAsymmetricPairing { // Based on triplet type, make suitable combinations of the partitions if (tripletType == VarManager::kTripleCandidateToPKPi) { for (auto& [a1, a2, a3] : combinations(soa::CombinationsFullIndexPolicy(groupedLegAAssocs, groupedLegBAssocs, groupedLegCAssocs))) { - readTriplet(a1, a2, a3, tracks, event, tripletType, histNames, histNamesMC); + readTriplet(a1, a2, a3, tracks, event, tripletType); } } else if (tripletType == VarManager::kTripleCandidateToKPiPi) { for (auto& a1 : groupedLegAAssocs) { for (auto& [a2, a3] : combinations(groupedLegBAssocs, groupedLegCAssocs)) { - readTriplet(a1, a2, a3, tracks, event, tripletType, histNames, histNamesMC); + readTriplet(a1, a2, a3, tracks, event, tripletType); } } } else { @@ -2619,15 +3014,15 @@ struct AnalysisAsymmetricPairing { // Helper function to process triplet template - void readTriplet(TTrackAssoc const& a1, TTrackAssoc const& a2, TTrackAssoc const& a3, TTracks const& /*tracks*/, TEvent const& event, VarManager::PairCandidateType tripletType, std::map> histNames, std::map> histNamesMC) + void readTriplet(TTrackAssoc const& a1, TTrackAssoc const& a2, TTrackAssoc const& a3, TTracks const& /*tracks*/, TEvent const& event, VarManager::PairCandidateType tripletType) { uint32_t mcDecision = 0; uint32_t threeTrackFilter = 0; uint32_t threeTrackCommonFilter = 0; for (int icut = 0; icut < fNLegCuts; ++icut) { - // Find out which leg cut combination the triplet passes - if ((((a1.isBarrelSelected_raw() & fLegAFilterMask) | (a2.isBarrelSelected_raw() & fLegBFilterMask) | (a3.isBarrelSelected_raw() & fLegCFilterMask)) & fTrackCutFilterMasks[icut]) == fTrackCutFilterMasks[icut]) { + // Find out which leg cut combinations the triplet passes + if ((a1.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) && (a2.isBarrelSelected_raw() & fConstructedLegBFilterMasksMap[icut]) && (a3.isBarrelSelected_raw() & fConstructedLegCFilterMasksMap[icut])) { threeTrackFilter |= (static_cast(1) << icut); if (tripletType == VarManager::kTripleCandidateToPKPi && fConfigSkipAmbiguousIdCombinations.value) { // Check if the supposed pion passes as a proton or kaon, if so, skip this triplet. It is pKp or pKK. @@ -2662,6 +3057,17 @@ struct AnalysisAsymmetricPairing { if (t1 == t2 || t1 == t3 || t2 == t3) { return; } + // Check charge + if (tripletType == VarManager::kTripleCandidateToKPiPi) { + if (!((t1.sign() == -1 && t2.sign() == 1 && t3.sign() == 1) || (t1.sign() == 1 && t2.sign() == -1 && t3.sign() == -1))) { + return; + } + } + if (tripletType == VarManager::kTripleCandidateToPKPi) { + if (!((t1.sign() == 1 && t2.sign() == -1 && t3.sign() == 1) || (t1.sign() == -1 && t2.sign() == 1 && t3.sign() == -1))) { + return; + } + } // store the ambiguity of the three legs in the last 3 digits of the two-track filter if (t1.barrelAmbiguityInBunch() > 1 || t1.barrelAmbiguityOutOfBunch() > 1) { @@ -2679,7 +3085,7 @@ struct AnalysisAsymmetricPairing { mcDecision = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { if (t1.has_reducedMCTrack() && t2.has_reducedMCTrack() && t3.has_reducedMCTrack()) { - if ((*sig).CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack(), t3.reducedMCTrack())) { + if ((*sig)->CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack(), t3.reducedMCTrack())) { mcDecision |= (static_cast(1) << isig); } } @@ -2695,49 +3101,43 @@ struct AnalysisAsymmetricPairing { for (int icut = 0; icut < fNLegCuts; icut++) { isAmbi = (threeTrackFilter & (static_cast(1) << 29)) || (threeTrackFilter & (static_cast(1) << 30)) || (threeTrackFilter & (static_cast(1) << 31)); if (threeTrackFilter & (static_cast(1) << icut)) { - fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); - // TODO: loop over MC signals + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s", fLegCutNames[icut].Data()), VarManager::fgValues); for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); if (mcDecision & (static_cast(1) << isig)) { - fHistMan->FillHistClass(histNamesMC[offset + icut][0].Data(), VarManager::fgValues); // matched signal + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s", fLegCutNames[icut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); // matched signal } } // end loop (MC signals) if (fConfigQA && isAmbi) { - fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("TripletsBarrelSE_ambiguous_%s", fLegCutNames[icut].Data()), VarManager::fgValues); } for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { if (threeTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data()), VarManager::fgValues); for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); if (mcDecision & (static_cast(1) << isig)) { - fHistMan->FillHistClass(histNamesMC[offset + fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][0].Data(), VarManager::fgValues); // matched signal + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); // matched signal } } // end loop (MC signals) } } // end loop (common cuts) - for (unsigned int iPairCut = 0; iPairCut < fPairCuts.size(); iPairCut++) { - AnalysisCompositeCut cut = fPairCuts.at(iPairCut); - if (!(cut.IsSelected(VarManager::fgValues))) { // apply pair cuts + int iPairCut = 0; + for (auto cut = fPairCuts.begin(); cut != fPairCuts.end(); cut++, iPairCut++) { + if (!((*cut)->IsSelected(VarManager::fgValues))) // apply pair cuts continue; - } // Histograms with pair cuts - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); if (mcDecision & (static_cast(1) << isig)) { - fHistMan->FillHistClass(histNamesMC[offset + fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][0].Data(), VarManager::fgValues); // matched signal + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); // matched signal } } // end loop (MC signals) // Histograms with pair cuts and common track cuts for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { if (threeTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals - int offset = fNLegCuts * isig * (1 + fNCommonTrackCuts + fNPairCuts + fNCommonTrackCuts * fNPairCuts); if (mcDecision & (static_cast(1) << isig)) { - fHistMan->FillHistClass(histNamesMC[offset + (fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * (1 + fNPairCuts) + iPairCut][0].Data(), VarManager::fgValues); // matched signal + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fRecMCSignalNames[isig].Data()), VarManager::fgValues); // matched signal } } // end loop (MC signals) } @@ -2747,48 +3147,76 @@ struct AnalysisAsymmetricPairing { } // end loop (cuts) } - PresliceUnsorted perReducedMcEvent = aod::reducedtrackMC::reducedMCeventId; + void processKaonPionSkimmed(MyEventsVtxCovSelected const& events, + soa::Join const& barrelAssocs, + MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, + ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) + { + runAsymmetricPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks); + } + + void processKaonPionSkimmedMultExtra(MyEventsVtxCovSelectedMultExtra const& events, + soa::Join const& barrelAssocs, + MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, + ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) + { + runAsymmetricPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks); + } + + void processKaonPionPionSkimmed(MyEventsVtxCovSelected const& events, + soa::Join const& barrelAssocs, + MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, + ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) + { + runThreeProng(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks, VarManager::kTripleCandidateToKPiPi); + } - void runMCGen(ReducedMCTracks const& mcTracks) + void processMCGen(ReducedMCTracks const& mcTracks) { // loop over mc stack and fill histograms for pure MC truth signals // group all the MC tracks which belong to the MC event corresponding to the current reconstructed event + // auto groupedMCTracks = tracksMC.sliceBy(aod::reducedtrackMC::reducedMCeventId, event.reducedMCevent().globalIndex()); for (auto& mctrack : mcTracks) { + VarManager::FillTrackMC(mcTracks, mctrack); // NOTE: Signals are checked here mostly based on the skimmed MC stack, so depending on the requested signal, the stack could be incomplete. // NOTE: However, the working model is that the decisions on MC signals are precomputed during skimming and are stored in the mcReducedFlags member. // TODO: Use the mcReducedFlags to select signals for (auto& sig : fGenMCSignals) { - if (sig.GetNProngs() != 1) { // NOTE: 1-prong signals required here - continue; - } - bool checked = false; - checked = sig.CheckSignal(true, mctrack); - if (checked) { - fHistMan->FillHistClass(Form("MCTruthGen_%s", sig.GetName()), VarManager::fgValues); + if (sig->CheckSignal(true, mctrack)) { + fHistMan->FillHistClass(Form("MCTruthGen_%s", sig->GetName()), VarManager::fgValues); } } } - } // end runMCGen - - void processKaonPionSkimmed(MyEventsVtxCovSelected const& events, - soa::Join const& barrelAssocs, - MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, - ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) - { - runAsymmetricPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks); - if (fConfigRunMCGenPair) - runMCGen(mcTracks); } - void processKaonPionPionSkimmed(MyEventsVtxCovSelected const& events, - soa::Join const& barrelAssocs, - MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, - ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) + PresliceUnsorted perReducedMcEvent = aod::reducedtrackMC::reducedMCeventId; + + void processMCGenWithEventSelection(soa::Filtered const& events, + ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& mcTracks) { - runThreeProng(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks, VarManager::kTripleCandidateToKPiPi); - if (fConfigRunMCGenPair) - runMCGen(mcTracks); + for (auto& event : events) { + if (!event.isEventSelected_bit(0)) { + continue; + } + if (!event.has_reducedMCevent()) { + continue; + } + + auto groupedMCTracks = mcTracks.sliceBy(perReducedMcEvent, event.reducedMCeventId()); + groupedMCTracks.bindInternalIndicesTo(&mcTracks); + for (auto& track : groupedMCTracks) { + + VarManager::FillTrackMC(mcTracks, track); + + auto track_raw = groupedMCTracks.rawIteratorAt(track.globalIndex()); + for (auto& sig : fGenMCSignals) { + if (sig->CheckSignal(true, track_raw)) { + fHistMan->FillHistClass(Form("MCTruthGenSel_%s", sig->GetName()), VarManager::fgValues); + } + } + } + } // end loop over reconstructed events } void processDummy(MyEvents&) @@ -2797,7 +3225,10 @@ struct AnalysisAsymmetricPairing { } PROCESS_SWITCH(AnalysisAsymmetricPairing, processKaonPionSkimmed, "Run kaon pion pairing, with skimmed tracks", false); + PROCESS_SWITCH(AnalysisAsymmetricPairing, processKaonPionSkimmedMultExtra, "Run kaon pion pairing, with skimmed tracks", false); PROCESS_SWITCH(AnalysisAsymmetricPairing, processKaonPionPionSkimmed, "Run kaon pion pion triplets, with skimmed tracks", false); + PROCESS_SWITCH(AnalysisAsymmetricPairing, processMCGen, "Loop over MC particle stack and fill generator level histograms", false); + PROCESS_SWITCH(AnalysisAsymmetricPairing, processMCGenWithEventSelection, "Loop over MC particle stack and fill generator level histograms", false); PROCESS_SWITCH(AnalysisAsymmetricPairing, processDummy, "Dummy function, enabled only if none of the others are enabled", true); }; @@ -2808,7 +3239,7 @@ struct AnalysisDileptonTrack { Produces BmesonsTable; OutputObj fOutputList{"output"}; - Configurable fConfigTrackCut{"cfgTrackCut", "kaonPID", "Cut for the track to be correlated with the dileptons"}; + Configurable fConfigTrackCuts{"cfgTrackCuts", "kaonPID", "Comma separated list of track cuts to be correlated with the dileptons"}; Configurable fConfigDileptonLowMass{"cfgDileptonLowMass", 2.8, "Low mass cut for the dileptons used in analysis"}; Configurable fConfigDileptonHighMass{"cfgDileptonHighMass", 3.2, "High mass cut for the dileptons used in analysis"}; Configurable fConfigDileptonpTCut{"cfgDileptonpTCut", 0.0, "pT cut for dileptons used in the triplet vertexing"}; @@ -2816,25 +3247,37 @@ struct AnalysisDileptonTrack { Configurable fConfigUseKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"}; Configurable fConfigHistogramSubgroups{"cfgDileptonTrackHistogramsSubgroups", "invmass,vertexing", "Comma separated list of dilepton-track histogram subgroups"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Configurable fConfigUseRemoteField{"cfgUseRemoteField", false, "Chose whether to fetch the magnetic field from ccdb or set it manually"}; Configurable fConfigGRPmagPath{"cfgGrpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable fConfigMagField{"cfgMagField", 5.0f, "Manually set magnetic field"}; - Configurable fConfigMCRecSignals{"cfgBarrelMCRecSignals", "", "Comma separated list of MC signals (reconstructed)"}; - Configurable fConfigMCGenSignals{"cfgBarrelMCGenSignals", "", "Comma separated list of MC signals (generated)"}; + Configurable fConfigMCRecSignals{"cfgMCRecSignals", "", "Comma separated list of MC signals (reconstructed)"}; + Configurable fConfigMCGenSignals{"cfgMCGenSignals", "", "Comma separated list of MC signals (generated)"}; + Configurable fConfigMCRecSignalsJSON{"cfgMCRecSignalsJSON", "", "Additional list of MC signals (reconstructed) via JSON"}; + Configurable fConfigMCGenSignalsJSON{"cfgMCGenSignalsJSON", "", "Comma separated list of MC signals (generated) via JSON"}; + Configurable fConfigMCGenSignalDileptonLegPos{"cfgMCGenSignalDileptonLegPos", 0, "generator level positive dilepton leg signal (bit number according to table-maker)"}; + Configurable fConfigMCGenSignalDileptonLegNeg{"cfgMCGenSignalDileptonLegNeg", 0, "generator level negative dilepton leg signal (bit number according to table-maker)"}; + Configurable fConfigMCGenSignalHadron{"cfgMCGenSignalHadron", 0, "generator level associated hadron signal (bit number according to table-maker)"}; + Configurable fConfigMCGenDileptonLegPtMin{"cfgMCGenDileptonLegPtMin", 1.0f, "minimum pt for the dilepton leg"}; + Configurable fConfigMCGenHadronPtMin{"cfgMCGenHadronPtMin", 1.0f, "minimum pt for the hadron"}; + Configurable fConfigMCGenDileptonLegEtaAbs{"cfgMCGenDileptonLegEtaAbs", 0.9f, "eta abs range for the dilepton leg"}; + Configurable fConfigMCGenHadronEtaAbs{"cfgMCGenHadronEtaAbs", 0.9f, "eta abs range for the hadron"}; int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. int fNCuts; + int fNLegCuts; int fNPairCuts; int fNCommonTrackCuts; std::map fCommonTrackCutMap; - int fTrackCutBit; - std::map fHistNamesDileptonTrack; - // std::map fHistNamesDileptonTrackMCmatched; - std::map> fHistNamesDileptonTrackMCmatched; - std::vector fHistNamesMCgen; - std::map fHistNamesDileptons; + uint32_t fTrackCutBitMap; // track cut bit mask to be used in the selection of tracks associated with dileptons + // vector for single-lepton and track cut names for easy access when calling FillHistogramList() + std::vector fTrackCutNames; + std::vector fLegCutNames; + // vector for pair cut names, used mainly for pairs built via the asymmetric pairing task + std::vector fPairCutNames; + std::vector fCommonPairCutNames; Service fCCDB; @@ -2851,23 +3294,20 @@ struct AnalysisDileptonTrack { float* fValuesHadron; HistogramManager* fHistMan; - std::vector fRecMCSignals; - std::vector fGenMCSignals; + std::vector fRecMCSignals; + std::vector fGenMCSignals; void init(o2::framework::InitContext& context) { - if (context.mOptions.get("processDummy")) { - return; - } - bool isBarrel = context.mOptions.get("processBarrelSkimmed"); bool isBarrelAsymmetric = context.mOptions.get("processDstarToD0Pi"); bool isMuon = context.mOptions.get("processMuonSkimmed"); - bool isAnyProcessEnabled = isBarrel || isMuon || isBarrelAsymmetric; + bool isMCGen = context.mOptions.get("processMCGen") || context.mOptions.get("processMCGenWithEventSelection"); bool isDummy = context.mOptions.get("processDummy"); + if (isDummy) { - if (isAnyProcessEnabled) { - LOG(warning) << "Dummy function is enabled even if there are normal process functions running! Fix your config!" << endl; + if (isBarrel || isMuon || isBarrelAsymmetric || isMCGen) { + LOG(fatal) << "Dummy function is enabled even if there are normal process functions running! Fix your config!" << endl; } else { LOG(info) << "Dummy function is enabled. Skipping the rest of the init function" << endl; return; @@ -2877,10 +3317,10 @@ struct AnalysisDileptonTrack { fCurrentRun = 0; fValuesDilepton = new float[VarManager::kNVars]; fValuesHadron = new float[VarManager::kNVars]; - fTrackCutBit = -1; + fTrackCutBitMap = 0; VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); - fHistMan->SetUseDefaultVariableNames(kTRUE); + fHistMan->SetUseDefaultVariableNames(true); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); TString sigNamesStr = fConfigMCRecSignals.value; @@ -2890,154 +3330,259 @@ struct AnalysisDileptonTrack { MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objRecSigArray->At(isig)->GetName()); if (sig) { if (sig->GetNProngs() != 3) { - continue; + LOG(fatal) << "Signal at reconstructed level requested (" << sig->GetName() << ") " << "does not have 3 prongs! Fix it"; } - fRecMCSignals.push_back(*sig); + fRecMCSignals.push_back(sig); + } else { + LOG(fatal) << "Signal at reconstructed level requested (" << objRecSigArray->At(isig)->GetName() << ") " << "could not be retrieved from the library! -> skipped"; + } + } + } + + // Add the reco MCSignals from the JSON config + TString addMCSignalsStr = fConfigMCRecSignalsJSON.value; + if (addMCSignalsStr != "") { + std::vector addMCSignals = dqmcsignals::GetMCSignalsFromJSON(addMCSignalsStr.Data()); + for (auto& mcIt : addMCSignals) { + if (mcIt->GetNProngs() != 3) { + LOG(fatal) << "Signal at reconstructed level requested (" << mcIt->GetName() << ") " << "does not have 3 prongs! Fix it"; + } + fRecMCSignals.push_back(mcIt); + } + } + + // Add histogram classes for each specified MCsignal at the generator level + // TODO: create a std::vector of hist classes to be used at Fill time, to avoid using Form in the process function + TString sigGenNamesStr = fConfigMCGenSignals.value; + std::unique_ptr objGenSigArray(sigGenNamesStr.Tokenize(",")); + for (int isig = 0; isig < objGenSigArray->GetEntries(); isig++) { + MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objGenSigArray->At(isig)->GetName()); + if (sig) { + if (sig->GetNProngs() == 1) { // NOTE: 1-prong signals required + fGenMCSignals.push_back(sig); + } + } + } + + // Add the gen MCSignals from the JSON config + addMCSignalsStr = fConfigMCGenSignalsJSON.value; + if (addMCSignalsStr != "") { + std::vector addMCSignals = dqmcsignals::GetMCSignalsFromJSON(addMCSignalsStr.Data()); + for (auto& mcIt : addMCSignals) { + if (mcIt->GetNProngs() == 1) { + fGenMCSignals.push_back(mcIt); } } } // For each track/muon selection used to produce dileptons, create a separate histogram directory using the // name of the track/muon cut. - // Also, create a map which will hold the name of the histogram directories so they can be accessed directly in the pairing loop - if (isBarrel || isMuon || isBarrelAsymmetric) { - // get the list of single track and muon cuts computed in the dedicated tasks upstream - string tempCutsSingle; - if (isBarrel || isBarrelAsymmetric) { - getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", tempCutsSingle, false); - } else { - getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCuts", tempCutsSingle, false); - } - TString tempCutsSingleStr = tempCutsSingle; - TObjArray* objArraySingleCuts = nullptr; - if (!tempCutsSingleStr.IsNull()) { - objArraySingleCuts = tempCutsSingleStr.Tokenize(","); - } - if (objArraySingleCuts->FindObject(fConfigTrackCut.value.data()) == nullptr) { - LOG(fatal) << " Track cut chosen for the correlation task was not computed in the single-track task! Check it out!"; - } - // Loop over single-track/muon task cuts and find the cuts used for the track to be combined with dileptons - for (int icut = 0; icut < objArraySingleCuts->GetEntries(); ++icut) { - TString tempStr = objArraySingleCuts->At(icut)->GetName(); - if (tempStr.CompareTo(fConfigTrackCut.value.data()) == 0) { - fTrackCutBit = icut; // the bit corresponding to the track to be combined with dileptons - } - } - // get the cuts employed for same-event pairing - string tempCutsPair; - string tempCutsAsymPair; - string tempCutsAsymCommon; - if (isBarrel) { - getTaskOptionValue(context, "analysis-same-event-pairing", "cfgTrackCuts", tempCutsPair, false); - } else if (isMuon) { - getTaskOptionValue(context, "analysis-same-event-pairing", "cfgMuonCuts", tempCutsPair, false); - } else if (isBarrelAsymmetric) { - getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgLegCuts", tempCutsPair, false); - getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgPairCuts", tempCutsAsymPair, false); - getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgCommonTrackCuts", tempCutsAsymCommon, false); - } - - // If asymmetric pair is used, it may have common track cuts - TString tempCutsAsymCommonStr = tempCutsAsymCommon; - if (!tempCutsAsymCommonStr.IsNull()) { // if common track cuts - std::unique_ptr objArrayCommon(tempCutsAsymCommonStr.Tokenize(",")); - fNCommonTrackCuts = objArrayCommon->GetEntries(); - for (int icut = 0; icut < fNCommonTrackCuts; ++icut) { - for (int iicut = 0; iicut < objArraySingleCuts->GetEntries(); ++iicut) { - if (std::strcmp(objArrayCommon->At(icut)->GetName(), objArraySingleCuts->At(iicut)->GetName()) == 0) { - fCommonTrackCutMap[icut] = iicut; - } + + // Get the list of single track and muon cuts computed in the dedicated tasks upstream + // We need this to know the order in which they were computed, and also to make sure that in this task we do not ask + // for cuts which were not computed (in which case this will trigger a fatal) + string cfgTrackSelection_TrackCuts; + if (isBarrel || isBarrelAsymmetric) { + getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", cfgTrackSelection_TrackCuts, false); + } else { + getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCuts", cfgTrackSelection_TrackCuts, false); + } + TObjArray* cfgTrackSelection_objArrayTrackCuts = nullptr; + if (!cfgTrackSelection_TrackCuts.empty()) { + cfgTrackSelection_objArrayTrackCuts = TString(cfgTrackSelection_TrackCuts).Tokenize(","); + } + // get also the list of cuts specified via the JSON parameters + if (isBarrel || isBarrelAsymmetric) { + getTaskOptionValue(context, "analysis-track-selection", "cfgBarrelTrackCutsJSON", cfgTrackSelection_TrackCuts, false); + } else { + getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCutsJSON", cfgTrackSelection_TrackCuts, false); + } + if (!cfgTrackSelection_TrackCuts.empty()) { + if (cfgTrackSelection_objArrayTrackCuts == nullptr) { + cfgTrackSelection_objArrayTrackCuts = new TObjArray(); + } + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(cfgTrackSelection_TrackCuts.data()); + for (auto& t : addTrackCuts) { + TObjString* tempObjStr = new TObjString(t->GetName()); + cfgTrackSelection_objArrayTrackCuts->Add(tempObjStr); + } + } + if (cfgTrackSelection_objArrayTrackCuts->GetEntries() == 0) { + LOG(fatal) << " No track cuts found in the barrel or muon upstream tasks"; + } + // store all the computed track cut names in a vector + for (int icut = 0; icut < cfgTrackSelection_objArrayTrackCuts->GetEntries(); icut++) { + fTrackCutNames.push_back(cfgTrackSelection_objArrayTrackCuts->At(icut)->GetName()); + } + // get the list of associated track cuts to be combined with the dileptons, + // check that these were computed upstream, and create a bit mask + TObjArray* cfgDileptonTrack_objArrayTrackCuts = nullptr; + if (!fConfigTrackCuts.value.empty()) { + cfgDileptonTrack_objArrayTrackCuts = TString(fConfigTrackCuts.value).Tokenize(","); + } else { + LOG(fatal) << " No track cuts specified! Check it out!"; + } + // loop over these cuts and check they were computed upstream (otherwise trigger a fatal) + for (int icut = 0; icut < cfgDileptonTrack_objArrayTrackCuts->GetEntries(); icut++) { + if (!cfgTrackSelection_objArrayTrackCuts->FindObject(cfgDileptonTrack_objArrayTrackCuts->At(icut)->GetName())) { + LOG(fatal) << "Specified track cut (" << cfgDileptonTrack_objArrayTrackCuts->At(icut)->GetName() << ") not found in the list of computed cuts by the single barrel / muon selection tasks"; + } + } + // loop over all the upstream cuts and make a bit mask for the track cuts specified in this task + for (int icut = 0; icut < cfgTrackSelection_objArrayTrackCuts->GetEntries(); icut++) { + if (cfgDileptonTrack_objArrayTrackCuts->FindObject(cfgTrackSelection_objArrayTrackCuts->At(icut)->GetName())) { + fTrackCutBitMap |= (static_cast(1) << icut); + } + } + // finally, store the total number of upstream tasks, for easy access + fNCuts = fTrackCutNames.size(); + + // get the cuts employed for same-event pairing + // NOTE: The track/muon cuts in analysis-same-event-pairing are used to select electrons/muons to build dielectrons/dimuons + // NOTE: The cfgPairCuts in analysis-same-event-pairing are used to apply an additional selection on top of the already produced dileptons + // but this is only used for histograms, not for the produced dilepton tables + string cfgPairing_TrackCuts; + string cfgPairing_PairCuts; + string cfgPairing_PairCutsJSON; + string cfgPairing_CommonTrackCuts; + if (isBarrel) { + getTaskOptionValue(context, "analysis-same-event-pairing", "cfgTrackCuts", cfgPairing_TrackCuts, false); + getTaskOptionValue(context, "analysis-same-event-pairing", "cfgPairCuts", cfgPairing_PairCuts, false); + } else if (isMuon) { + getTaskOptionValue(context, "analysis-same-event-pairing", "cfgMuonCuts", cfgPairing_TrackCuts, false); + getTaskOptionValue(context, "analysis-same-event-pairing", "cfgPairCuts", cfgPairing_PairCuts, false); + } else if (isBarrelAsymmetric) { + getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgLegCuts", cfgPairing_TrackCuts, false); + getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgPairCuts", cfgPairing_PairCuts, false); + getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgCommonTrackCuts", cfgPairing_CommonTrackCuts, false); + } + if (cfgPairing_TrackCuts.empty()) { + LOG(fatal) << "There are no dilepton cuts specified in the upstream in the same-event-pairing or asymmetric-pairing"; + } + + // If asymmetric pair is used, it may have common track cuts + TString cfgPairing_strCommonTrackCuts = cfgPairing_CommonTrackCuts; + if (!cfgPairing_strCommonTrackCuts.IsNull()) { // if common track cuts + std::unique_ptr objArrayCommon(cfgPairing_strCommonTrackCuts.Tokenize(",")); + fNCommonTrackCuts = objArrayCommon->GetEntries(); + for (int icut = 0; icut < fNCommonTrackCuts; ++icut) { + for (int iicut = 0; iicut < cfgTrackSelection_objArrayTrackCuts->GetEntries(); iicut++) { + if (std::strcmp(cfgTrackSelection_objArrayTrackCuts->At(iicut)->GetName(), objArrayCommon->At(icut)->GetName()) == 0) { + fCommonTrackCutMap[icut] = iicut; + fCommonPairCutNames.push_back(objArrayCommon->At(icut)->GetName()); } } } + } // end if (common cuts) + + // Get also the pair cuts specified via the JSON parameters + if (isBarrelAsymmetric) { + getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgPairCutsJSON", cfgPairing_PairCutsJSON, false); + TString addPairCutsStr = cfgPairing_PairCutsJSON; + if (addPairCutsStr != "") { + std::vector addPairCuts = dqcuts::GetCutsFromJSON(addPairCutsStr.Data()); + for (auto& t : addPairCuts) { + cfgPairing_PairCuts += Form(",%s", t->GetName()); + } + } + } + + std::unique_ptr objArrayPairCuts(TString(cfgPairing_PairCuts).Tokenize(",")); + fNPairCuts = objArrayPairCuts->GetEntries(); + for (int j = 0; j < fNPairCuts; j++) { + fPairCutNames.push_back(objArrayPairCuts->At(j)->GetName()); + } + + // array of single lepton cuts specified in the same-analysis-pairing task + std::unique_ptr cfgPairing_objArrayTrackCuts(TString(cfgPairing_TrackCuts).Tokenize(",")); + // If asymmetric pairs are used, the number of cuts should come from the asymmetric-pairing task + if (isBarrelAsymmetric) { + fNLegCuts = cfgPairing_objArrayTrackCuts->GetEntries(); + } else { + fNLegCuts = fNCuts; + } + + // loop over single lepton cuts + if (isBarrel || isBarrelAsymmetric || isMuon) { + for (int icut = 0; icut < fNLegCuts; ++icut) { + + TString pairLegCutName; + + // here we check that this cut is one of those used for building the dileptons + if (!isBarrelAsymmetric) { + if (!cfgPairing_objArrayTrackCuts->FindObject(fTrackCutNames[icut].Data())) { + continue; + } + pairLegCutName = fTrackCutNames[icut].Data(); + } else { + // For asymmetric pairs we access the leg cuts instead + pairLegCutName = static_cast(cfgPairing_objArrayTrackCuts->At(icut))->GetString(); + } + fLegCutNames.push_back(pairLegCutName); + + // define dilepton histograms + DefineHistograms(fHistMan, Form("DileptonsSelected_%s", pairLegCutName.Data()), "barrel,vertexing"); + // loop over track cuts and create dilepton - track histogram directories + for (int iCutTrack = 0; iCutTrack < fNCuts; iCutTrack++) { + + // here we check that this track cut is one of those required to associate with the dileptons + if (!(fTrackCutBitMap & (static_cast(1) << iCutTrack))) { + continue; + } + + DefineHistograms(fHistMan, Form("DileptonTrack_%s_%s", pairLegCutName.Data(), fTrackCutNames[iCutTrack].Data()), fConfigHistogramSubgroups.value.data()); + for (auto& sig : fRecMCSignals) { + DefineHistograms(fHistMan, Form("DileptonTrackMCMatched_%s_%s_%s", pairLegCutName.Data(), fTrackCutNames[iCutTrack].Data(), sig->GetName()), fConfigHistogramSubgroups.value.data()); + } - TString tempCutsPairStr = tempCutsPair; - if (!tempCutsSingleStr.IsNull() && !tempCutsPairStr.IsNull()) { - std::unique_ptr objArray(tempCutsPairStr.Tokenize(",")); - fNCuts = objArray->GetEntries(); - for (int icut = 0; icut < fNCuts; ++icut) { - TString tempStr = objArray->At(icut)->GetName(); - fHistNamesDileptonTrack[icut] = Form("DileptonTrack_%s_%s", tempStr.Data(), fConfigTrackCut.value.data()); - fHistNamesDileptons[icut] = Form("DileptonsSelected_%s", tempStr.Data()); - DefineHistograms(fHistMan, fHistNamesDileptonTrack[icut], fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - DefineHistograms(fHistMan, fHistNamesDileptons[icut], "barrel,vertexing"); // define dilepton histograms - if (!tempCutsAsymCommonStr.IsNull()) { - std::unique_ptr objArrayCommon(tempCutsAsymCommonStr.Tokenize(",")); + if (!cfgPairing_strCommonTrackCuts.IsNull()) { + std::unique_ptr objArrayCommon(cfgPairing_strCommonTrackCuts.Tokenize(",")); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - fHistNamesDileptonTrack[fNCuts + icut * fNCommonTrackCuts + iCommonCut] = Form("DileptonTrack_%s_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), fConfigTrackCut.value.data()); - fHistNamesDileptons[fNCuts + icut * fNCommonTrackCuts + iCommonCut] = Form("DileptonsSelected_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName()); - DefineHistograms(fHistMan, fHistNamesDileptonTrack[fNCuts + icut * fNCommonTrackCuts + iCommonCut], fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - DefineHistograms(fHistMan, fHistNamesDileptons[fNCuts + icut * fNCommonTrackCuts + iCommonCut], "barrel,vertexing"); // define dilepton histograms + DefineHistograms(fHistMan, Form("DileptonsSelected_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data()), "barrel,vertexing"); + DefineHistograms(fHistMan, Form("DileptonTrack_%s_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data(), fTrackCutNames[iCutTrack].Data()), fConfigHistogramSubgroups.value.data()); + for (auto& sig : fRecMCSignals) { + DefineHistograms(fHistMan, Form("DileptonTrackMCMatched_%s_%s_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data(), fTrackCutNames[iCutTrack].Data(), sig->GetName()), fConfigHistogramSubgroups.value.data()); + } } } - TString tempCutsAsymPairStr = tempCutsAsymPair; - if (!tempCutsAsymPairStr.IsNull()) { - std::unique_ptr objArrayPairCuts(tempCutsAsymPairStr.Tokenize(",")); - fNPairCuts = objArrayPairCuts->GetEntries(); + + if (fNPairCuts != 0) { + for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { - fHistNamesDileptonTrack[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = Form("DileptonTrack_%s_%s_%s", tempStr.Data(), objArrayPairCuts->At(iPairCut)->GetName(), fConfigTrackCut.value.data()); - fHistNamesDileptons[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = Form("DileptonsSelected_%s_%s", tempStr.Data(), objArrayPairCuts->At(iPairCut)->GetName()); - DefineHistograms(fHistMan, fHistNamesDileptonTrack[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut], fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - DefineHistograms(fHistMan, fHistNamesDileptons[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut], "barrel,vertexing"); // define dilepton histograms - if (!tempCutsAsymCommonStr.IsNull()) { - std::unique_ptr objArrayCommon(tempCutsAsymCommonStr.Tokenize(",")); + DefineHistograms(fHistMan, Form("DileptonsSelected_%s_%s", pairLegCutName.Data(), fPairCutNames[iPairCut].Data()), "barrel,vertexing"); + DefineHistograms(fHistMan, Form("DileptonTrack_%s_%s_%s", pairLegCutName.Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iCutTrack].Data()), fConfigHistogramSubgroups.value.data()); + for (auto& sig : fRecMCSignals) { + DefineHistograms(fHistMan, Form("DileptonTrackMCMatched_%s_%s_%s_%s", pairLegCutName.Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iCutTrack].Data(), sig->GetName()), fConfigHistogramSubgroups.value.data()); + } + + if (!cfgPairing_strCommonTrackCuts.IsNull()) { + std::unique_ptr objArrayCommon(cfgPairing_strCommonTrackCuts.Tokenize(",")); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - fHistNamesDileptonTrack[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * fNPairCuts + iPairCut] = Form("DileptonTrack_%s_%s_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPairCuts->At(iPairCut)->GetName(), fConfigTrackCut.value.data()); - fHistNamesDileptons[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * fNPairCuts + iPairCut] = Form("DileptonsSelected_%s_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPairCuts->At(iPairCut)->GetName()); - DefineHistograms(fHistMan, fHistNamesDileptonTrack[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * fNPairCuts + iPairCut], fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - DefineHistograms(fHistMan, fHistNamesDileptons[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * fNPairCuts + iPairCut], "barrel,vertexing"); // define dilepton histograms + DefineHistograms(fHistMan, Form("DileptonsSelected_%s_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), "barrel,vertexing"); + DefineHistograms(fHistMan, Form("DileptonTrack_%s_%s_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iCutTrack].Data()), fConfigHistogramSubgroups.value.data()); + for (auto& sig : fRecMCSignals) { + DefineHistograms(fHistMan, Form("DileptonTrack_%s_%s_%s_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iCutTrack].Data(), sig->GetName()), fConfigHistogramSubgroups.value.data()); + } } } - } // end loop (pair cuts) - } - for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { - auto sig = fRecMCSignals.at(isig); - fHistNamesDileptonTrackMCmatched[icut].push_back(Form("DileptonTrackMCMatched_%s_%s_%s", tempStr.Data(), fConfigTrackCut.value.data(), sig.GetName())); - DefineHistograms(fHistMan, fHistNamesDileptonTrackMCmatched[icut].back(), fConfigHistogramSubgroups.value.data()); - if (!tempCutsAsymCommonStr.IsNull()) { - std::unique_ptr objArrayCommon(tempCutsAsymCommonStr.Tokenize(",")); - for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - fHistNamesDileptonTrackMCmatched[fNCuts + icut * fNCommonTrackCuts + iCommonCut].push_back(Form("DileptonTrackMCMatched_%s_%s_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), fConfigTrackCut.value.data(), sig.GetName())); - DefineHistograms(fHistMan, fHistNamesDileptonTrackMCmatched[fNCuts + icut * fNCommonTrackCuts + iCommonCut].back(), fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - } } - if (!tempCutsAsymPairStr.IsNull()) { - std::unique_ptr objArrayPairCuts(tempCutsAsymPairStr.Tokenize(",")); - fNPairCuts = objArrayPairCuts->GetEntries(); - for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { - fHistNamesDileptonTrackMCmatched[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut].push_back(Form("DileptonTrackMCMatched_%s_%s_%s_%s", tempStr.Data(), objArrayPairCuts->At(iPairCut)->GetName(), fConfigTrackCut.value.data(), sig.GetName())); - DefineHistograms(fHistMan, fHistNamesDileptonTrackMCmatched[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut].back(), fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - if (!tempCutsAsymCommonStr.IsNull()) { - std::unique_ptr objArrayCommon(tempCutsAsymCommonStr.Tokenize(",")); - for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - fHistNamesDileptonTrackMCmatched[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * fNPairCuts + iPairCut].push_back(Form("DileptonTrackMCMatched_%s_%s_%s_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPairCuts->At(iPairCut)->GetName(), fConfigTrackCut.value.data(), sig.GetName())); - DefineHistograms(fHistMan, fHistNamesDileptonTrackMCmatched[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * fNPairCuts + iPairCut].back(), fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - } // end loop (common cuts) - } - } // end loop (pair cuts) - } - } // end loop (MC signals) - } // end loop (leg defining cuts) - } - // Add histogram classes for each specified MCsignal at the generator level - // TODO: create a std::vector of hist classes to be used at Fill time, to avoid using Form in the process function - TString sigGenNamesStr = fConfigMCGenSignals.value; - std::unique_ptr objGenSigArray(sigGenNamesStr.Tokenize(",")); - for (int isig = 0; isig < objGenSigArray->GetEntries(); isig++) { - MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objGenSigArray->At(isig)->GetName()); - if (sig) { - if (sig->GetNProngs() == 1) { // NOTE: 1-prong signals required - fGenMCSignals.push_back(*sig); - fHistNamesMCgen.push_back(Form("MCTruthGen_%s", sig->GetName())); - DefineHistograms(fHistMan, fHistNamesMCgen[fHistNamesMCgen.size() - 1], ""); } - } + } // end loop over track cuts to be combined with dileptons / di-tracks + } // end loop over pair leg track cuts + } // end if (isBarrel || isBarrelAsymmetric || isMuon) + + if (isMCGen) { + for (auto& sig : fGenMCSignals) { + DefineHistograms(fHistMan, Form("MCTruthGen_%s", sig->GetName()), ""); + DefineHistograms(fHistMan, Form("MCTruthGenSel_%s", sig->GetName()), ""); } - } - if (fHistNamesDileptons.size() == 0) { - LOG(fatal) << " No valid dilepton cuts "; + DefineHistograms(fHistMan, "MCTruthGenAccepted", ""); } + TString addHistsStr = fConfigAddJSONHistograms.value; + if (addHistsStr != "") { + dqhistograms::AddHistogramsFromJSON(fHistMan, addHistsStr.Data()); + } VarManager::SetUseVars(fHistMan->GetUsedVars()); fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -3093,22 +3638,30 @@ struct AnalysisDileptonTrack { } VarManager::FillTrack(dilepton, fValuesDilepton); - for (int icut = 0; icut < fNCuts; icut++) { - if (dilepton.filterMap_bit(icut)) { - fHistMan->FillHistClass(fHistNamesDileptons[icut].Data(), fValuesDilepton); - if constexpr (TCandidateType == VarManager::kDstarToD0KPiPi) { // Dielectrons and Dimuons don't have the PairFilterMap column - for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { - if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { - fHistMan->FillHistClass(fHistNamesDileptons[fNCuts + icut * fNCommonTrackCuts + iCommonCut].Data(), fValuesDilepton); - } + + // fill selected dilepton histograms for each specified selection + for (int icut = 0; icut < fNLegCuts; icut++) { + + if (!dilepton.filterMap_bit(icut)) { + continue; + } + + // regular dileptons + fHistMan->FillHistClass(Form("DileptonsSelected_%s", fLegCutNames[icut].Data()), fValuesDilepton); + + // other pairs, e.g.: D0s + if constexpr (TCandidateType == VarManager::kDstarToD0KPiPi) { // Dielectrons and Dimuons don't have the PairFilterMap column + for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { + if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { + fHistMan->FillHistClass(Form("DileptonsSelected_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data()), fValuesDilepton); } - for (int iPairCut = 0; iPairCut < fNPairCuts; iPairCut++) { - if (dilepton.pairFilterMap_bit(iPairCut)) { - fHistMan->FillHistClass(fHistNamesDileptons[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut].Data(), fValuesDilepton); - for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { - if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { - fHistMan->FillHistClass(fHistNamesDileptons[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * fNPairCuts + iPairCut].Data(), fValuesDilepton); - } + } + for (int iPairCut = 0; iPairCut < fNPairCuts; iPairCut++) { + if (dilepton.pairFilterMap_bit(iPairCut)) { + fHistMan->FillHistClass(Form("DileptonsSelected_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[icut].Data()), fValuesDilepton); + for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { + if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { + fHistMan->FillHistClass(Form("DileptonsSelected_%s_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[icut].Data()), fValuesDilepton); } } } @@ -3116,16 +3669,65 @@ struct AnalysisDileptonTrack { } } - // loop over hadrons + // loop over track associations for (auto& assoc : assocs) { - if constexpr (TCandidateType == VarManager::kBtoJpsiEEK || TCandidateType == VarManager::kDstarToD0KPiPi) { - if (!assoc.isBarrelSelected_bit(fTrackCutBit)) { + + uint32_t trackSelection = 0; + if constexpr (TCandidateType == VarManager::kBtoJpsiEEK) { + // check the cuts fulfilled by this candidate track; if none just continue + trackSelection = (assoc.isBarrelSelected_raw() & fTrackCutBitMap); + if (!trackSelection) { + continue; + } + // get the track from this association + auto track = assoc.template reducedtrack_as(); + // check that this track is not included in the current dilepton + if (track.globalIndex() == dilepton.index0Id() || track.globalIndex() == dilepton.index1Id()) { + continue; + } + // compute needed quantities + VarManager::FillDileptonHadron(dilepton, track, fValuesHadron); + VarManager::FillDileptonTrackVertexing(event, lepton1, lepton2, track, fValuesHadron); + + auto trackMC = track.reducedMCTrack(); + mcDecision = 0; + isig = 0; + for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { + if ((*sig)->CheckSignal(true, lepton1MC, lepton2MC, trackMC)) { + mcDecision |= (static_cast(1) << isig); + } + } + // table to be written out for ML analysis + BmesonsTable(fValuesHadron[VarManager::kPairMass], dilepton.mass(), fValuesHadron[VarManager::kDeltaMass], fValuesHadron[VarManager::kPairPt], + fValuesHadron[VarManager::kVertexingLxy], fValuesHadron[VarManager::kVertexingLxyz], fValuesHadron[VarManager::kVertexingLz], + fValuesHadron[VarManager::kVertexingTauxy], fValuesHadron[VarManager::kVertexingTauz], fValuesHadron[VarManager::kCosPointingAngle], + fValuesHadron[VarManager::kVertexingChi2PCA], + track.tpcInnerParam(), track.eta(), dilepton.pt(), dilepton.eta(), lepton1.tpcInnerParam(), lepton1.eta(), lepton2.tpcInnerParam(), lepton2.eta(), + track.tpcNSigmaKa(), track.tpcNSigmaPi(), track.tpcNSigmaPr(), track.tofNSigmaKa(), + lepton1.tpcNSigmaEl(), lepton1.tpcNSigmaPi(), lepton1.tpcNSigmaPr(), + lepton2.tpcNSigmaEl(), lepton2.tpcNSigmaPi(), lepton2.tpcNSigmaPr(), + track.dcaXY(), track.dcaZ(), lepton1.dcaXY(), lepton1.dcaZ(), lepton2.dcaXY(), lepton2.dcaZ(), + track.itsClusterMap(), lepton1.itsClusterMap(), lepton2.itsClusterMap(), + track.itsChi2NCl(), lepton1.itsChi2NCl(), lepton2.itsChi2NCl(), + track.tpcNClsFound(), lepton1.tpcNClsFound(), lepton2.tpcNClsFound(), + track.tpcChi2NCl(), lepton1.tpcChi2NCl(), lepton2.tpcChi2NCl(), + dilepton.filterMap_raw(), trackSelection, mcDecision); + } + + if constexpr (TCandidateType == VarManager::kDstarToD0KPiPi) { + trackSelection = (assoc.isBarrelSelected_raw() & fTrackCutBitMap); + if (!trackSelection) { continue; } + auto track = assoc.template reducedtrack_as(); if (track.globalIndex() == dilepton.index0Id() || track.globalIndex() == dilepton.index1Id()) { continue; } + // Check that the charge combination makes sense for D*+ -> D0 pi+ or D*- -> D0bar pi- + if (!((track.sign() == 1 && lepton1.sign() == -1 && lepton2.sign() == 1) || (track.sign() == -1 && lepton1.sign() == 1 && lepton2.sign() == -1))) { + continue; + } VarManager::FillDileptonHadron(dilepton, track, fValuesHadron); VarManager::FillDileptonTrackVertexing(event, lepton1, lepton2, track, fValuesHadron); @@ -3133,15 +3735,18 @@ struct AnalysisDileptonTrack { mcDecision = 0; isig = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { - if ((*sig).CheckSignal(true, lepton1MC, lepton2MC, trackMC)) { + if ((*sig)->CheckSignal(true, lepton1MC, lepton2MC, trackMC)) { mcDecision |= (static_cast(1) << isig); } } } + if constexpr (TCandidateType == VarManager::kBcToThreeMuons) { - if (!assoc.isMuonSelected_bit(fTrackCutBit)) { + trackSelection = (assoc.isMuonSelected_raw() & fTrackCutBitMap); + if (!trackSelection) { continue; } + auto track = assoc.template reducedmuon_as(); if (track.globalIndex() == dilepton.index0Id() || track.globalIndex() == dilepton.index1Id()) { continue; @@ -3154,58 +3759,69 @@ struct AnalysisDileptonTrack { mcDecision = 0; isig = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { - if ((*sig).CheckSignal(true, lepton1MC, lepton2MC, trackMC)) { + if ((*sig)->CheckSignal(true, lepton1MC, lepton2MC, trackMC)) { mcDecision |= (static_cast(1) << isig); } } } + // Fill histograms for the triplets + // loop over dilepton / ditrack cuts and MC signals for (int icut = 0; icut < fNCuts; icut++) { - if (dilepton.filterMap_bit(icut)) { - fHistMan->FillHistClass(fHistNamesDileptonTrack[icut].Data(), fValuesHadron); - for (isig = 0; isig < fRecMCSignals.size(); isig++) { + + if (!dilepton.filterMap_bit(icut)) { + continue; + } + + // loop over specified track cuts (the tracks to be combined with the dileptons) + for (int iTrackCut = 0; iTrackCut < fNCuts; iTrackCut++) { + + if (!(trackSelection & (static_cast(1) << iTrackCut))) { + continue; + } + + fHistMan->FillHistClass(Form("DileptonTrack_%s_%s", fLegCutNames[icut].Data(), fTrackCutNames[iTrackCut].Data()), fValuesHadron); + for (uint32_t isig = 0; isig < fRecMCSignals.size(); isig++) { if (mcDecision & (static_cast(1) << isig)) { - // TODO: check also whether the collision association is correct (add dedicated histogram dirs) - fHistMan->FillHistClass(fHistNamesDileptonTrackMCmatched[icut][isig], fValuesHadron); + fHistMan->FillHistClass(Form("DileptonTrackMCMatched_%s_%s_%s", fLegCutNames[icut].Data(), fTrackCutNames[iTrackCut].Data(), fRecMCSignals[isig]->GetName()), fValuesHadron); } } + if constexpr (TCandidateType == VarManager::kDstarToD0KPiPi) { // Dielectrons and Dimuons don't have the PairFilterMap column for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { - fHistMan->FillHistClass(fHistNamesDileptonTrack[fNCuts + icut * fNCommonTrackCuts + iCommonCut].Data(), fValuesHadron); - for (isig = 0; isig < fRecMCSignals.size(); isig++) { + fHistMan->FillHistClass(Form("DileptonTrack_%s_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data(), fTrackCutNames[iTrackCut].Data()), fValuesHadron); + for (uint32_t isig = 0; isig < fRecMCSignals.size(); isig++) { if (mcDecision & (static_cast(1) << isig)) { - fHistMan->FillHistClass(fHistNamesDileptonTrackMCmatched[fNCuts + icut * fNCommonTrackCuts + iCommonCut][isig], fValuesHadron); + fHistMan->FillHistClass(Form("DileptonTrackMCMatched_%s_%s_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data(), fTrackCutNames[iTrackCut].Data(), fRecMCSignals[isig]->GetName()), fValuesHadron); } - } // end loop (MC signals) + } } - } // end loop (common track cuts) + } for (int iPairCut = 0; iPairCut < fNPairCuts; iPairCut++) { if (dilepton.pairFilterMap_bit(iPairCut)) { - fHistMan->FillHistClass(fHistNamesDileptonTrack[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut].Data(), fValuesHadron); - for (isig = 0; isig < fRecMCSignals.size(); isig++) { + fHistMan->FillHistClass(Form("DileptonTrack_%s_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iTrackCut].Data()), fValuesHadron); + for (uint32_t isig = 0; isig < fRecMCSignals.size(); isig++) { if (mcDecision & (static_cast(1) << isig)) { - fHistMan->FillHistClass(fHistNamesDileptonTrackMCmatched[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][isig], fValuesHadron); + fHistMan->FillHistClass(Form("DileptonTrackMCMatched_%s_%s_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iTrackCut].Data(), fRecMCSignals[isig]->GetName()), fValuesHadron); } } for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { - fHistMan->FillHistClass(fHistNamesDileptonTrack[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * fNPairCuts + iPairCut].Data(), fValuesHadron); - for (isig = 0; isig < fRecMCSignals.size(); isig++) { + fHistMan->FillHistClass(Form("DileptonTrack_%s_%s_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iTrackCut].Data()), fValuesHadron); + for (uint32_t isig = 0; isig < fRecMCSignals.size(); isig++) { if (mcDecision & (static_cast(1) << isig)) { - fHistMan->FillHistClass(fHistNamesDileptonTrackMCmatched[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts) + iCommonCut * fNPairCuts + iPairCut][isig], fValuesHadron); + fHistMan->FillHistClass(Form("DileptonTrackMCMatched_%s_%s_%s_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iTrackCut].Data(), fRecMCSignals[isig]->GetName()), fValuesHadron); } - } // end loop (MC signals) + } } - } // end loop (common track cuts) + } } - } // end loop (pair cuts) + } } - } // end loop (cuts) - } - // table to be written out for ML analysis - BmesonsTable(fValuesHadron[VarManager::kPairMass], fValuesHadron[VarManager::kDeltaMass], fValuesHadron[VarManager::kPairPt], fValuesHadron[VarManager::kVertexingLxy], fValuesHadron[VarManager::kVertexingLxyz], fValuesHadron[VarManager::kVertexingLz], fValuesHadron[VarManager::kVertexingTauxy], fValuesHadron[VarManager::kVertexingTauz], fValuesHadron[VarManager::kKFDCAxyzBetweenProngs], fValuesHadron[VarManager::kCosPointingAngle], fValuesHadron[VarManager::kVertexingChi2PCA], mcDecision); - } + } // end loop over track cuts + } // end loop over dilepton cuts + } // end loop over associations } // end loop over dileptons } @@ -3287,21 +3903,109 @@ struct AnalysisDileptonTrack { // loop over mc stack and fill histograms for pure MC truth signals // group all the MC tracks which belong to the MC event corresponding to the current reconstructed event // auto groupedMCTracks = tracksMC.sliceBy(aod::reducedtrackMC::reducedMCeventId, event.reducedMCevent().globalIndex()); - int isig = 0; - for (auto& track : mcTracks) { - VarManager::FillTrackMC(mcTracks, track); + for (auto& mctrack : mcTracks) { + + if ((std::abs(mctrack.pdgCode()) > 400 && std::abs(mctrack.pdgCode()) < 599) || + (std::abs(mctrack.pdgCode()) > 4000 && std::abs(mctrack.pdgCode()) < 5999) || + mctrack.mcReducedFlags() > 0) { + /*cout << ">>>>>>>>>>>>>>>>>>>>>>> track idx / pdg / selections: " << mctrack.globalIndex() << " / " << mctrack.pdgCode() << " / "; + PrintBitMap(mctrack.mcReducedFlags(), 16); + cout << endl; + if (mctrack.has_mothers()) { + for (auto& m : mctrack.mothersIds()) { + if (m < mcTracks.size()) { // protect against bad mother indices + auto aMother = mcTracks.rawIteratorAt(m); + cout << "<<<<<< mother idx / pdg: " << m << " / " << aMother.pdgCode() << endl; + } + } + } + + if (mctrack.has_daughters()) { + for (int d = mctrack.daughtersIds()[0]; d <= mctrack.daughtersIds()[1]; ++d) { + if (d < mcTracks.size()) { // protect against bad daughter indices + auto aDaughter = mcTracks.rawIteratorAt(d); + cout << "<<<<<< daughter idx / pdg: " << d << " / " << aDaughter.pdgCode() << endl; + } + } + }*/ + } + + VarManager::FillTrackMC(mcTracks, mctrack); // NOTE: Signals are checked here mostly based on the skimmed MC stack, so depending on the requested signal, the stack could be incomplete. // NOTE: However, the working model is that the decisions on MC signals are precomputed during skimming and are stored in the mcReducedFlags member. // TODO: Use the mcReducedFlags to select signals - isig = 0; for (auto& sig : fGenMCSignals) { - if (sig.CheckSignal(true, track)) { - fHistMan->FillHistClass(fHistNamesMCgen[isig++], VarManager::fgValues); + if (sig->CheckSignal(true, mctrack)) { + fHistMan->FillHistClass(Form("MCTruthGen_%s", sig->GetName()), VarManager::fgValues); } } } } + PresliceUnsorted perReducedMcEvent = aod::reducedtrackMC::reducedMCeventId; + + void processMCGenWithEventSelection(soa::Filtered const& events, + ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& mcTracks) + { + for (auto& event : events) { + if (!event.isEventSelected_bit(0)) { + continue; + } + if (!event.has_reducedMCevent()) { + continue; + } + + auto groupedMCTracks = mcTracks.sliceBy(perReducedMcEvent, event.reducedMCeventId()); + groupedMCTracks.bindInternalIndicesTo(&mcTracks); + for (auto& track : groupedMCTracks) { + + VarManager::FillTrackMC(mcTracks, track); + + auto track_raw = groupedMCTracks.rawIteratorAt(track.globalIndex()); + for (auto& sig : fGenMCSignals) { + if (sig->CheckSignal(true, track_raw)) { + fHistMan->FillHistClass(Form("MCTruthGenSel_%s", sig->GetName()), VarManager::fgValues); + } + } + } + + /*for (auto& [t1, t2, t3] : combinations(groupedMCTracks, groupedMCTracks, groupedMCTracks)) { + + if (! (t1.mcReducedFlags() & (uint16_t(1) << fConfigMCGenSignalDileptonLegPos.value))) { + continue; + } + if (t1.pt() < fConfigMCGenDileptonLegPtMin.value) { + continue; + } + if (std::abs(t1.eta()) > fConfigMCGenDileptonLegEtaAbs.value) { + continue; + } + + if (! (t2.mcReducedFlags() & (uint16_t(1) << fConfigMCGenSignalDileptonLegNeg.value))) { + continue; + } + if (t2.pt() < fConfigMCGenDileptonLegPtMin.value) { + continue; + } + if (std::abs(t2.eta()) > fConfigMCGenDileptonLegEtaAbs.value) { + continue; + } + + if (! (t3.mcReducedFlags() & (uint16_t(1) << fConfigMCGenSignalHadron.value))) { + continue; + } + if (t3.pt() < fConfigMCGenHadronPtMin.value) { + continue; + } + if (std::abs(t3.eta()) > fConfigMCGenHadronEtaAbs.value) { + continue; + } + + fHistMan->FillHistClass("MCTruthGenSelAccepted", VarManager::fgValues); + }*/ + } // end loop over reconstructed events + } + void processDummy(MyEvents&) { // do nothing @@ -3311,6 +4015,7 @@ struct AnalysisDileptonTrack { PROCESS_SWITCH(AnalysisDileptonTrack, processDstarToD0Pi, "Run barrel pairing of D0 daughters with pion candidate, using skimmed data", false); PROCESS_SWITCH(AnalysisDileptonTrack, processMuonSkimmed, "Run muon dilepton-track pairing, using skimmed data", false); PROCESS_SWITCH(AnalysisDileptonTrack, processMCGen, "Loop over MC particle stack and fill generator level histograms", false); + PROCESS_SWITCH(AnalysisDileptonTrack, processMCGenWithEventSelection, "Loop over MC particle stack and fill generator level histograms", false); PROCESS_SWITCH(AnalysisDileptonTrack, processDummy, "Dummy function", false); }; diff --git a/PWGDQ/Tasks/dqFlow.cxx b/PWGDQ/Tasks/dqFlow.cxx index b5e855d3d13..52e3ca8c29c 100644 --- a/PWGDQ/Tasks/dqFlow.cxx +++ b/PWGDQ/Tasks/dqFlow.cxx @@ -16,11 +16,13 @@ /// o2-analysis-timestamp --aod-file AO2D.root -b | o2-analysis-event-selection -b | o2-analysis-multiplicity-table -b | o2-analysis-centrality-table -b | o2-analysis-fdd-converter -b | o2-analysis-trackselection -b | o2-analysis-trackextension -b | o2-analysis-pid-tpc-full -b | o2-analysis-pid-tof-full -b | o2-analysis-pid-tof-base -b | o2-analysis-pid-tof-beta -b | o2-analysis-dq-flow -b /// tested (June 2, 2022) on AO2D.root files from train production 242 +#include +#include +#include +#include #include #include #include -#include -#include #include #include "CCDB/BasicCCDBManager.h" #include "Framework/runDataProcessing.h" @@ -64,20 +66,23 @@ using MyBcs = soa::Join; using MyEvents = soa::Join; using MyEventsWithCent = soa::Join; -using MyEventsWithCentRun3 = soa::Join; +using MyEventsWithCentRun3 = soa::Join; // using MyEventsWithCentQvectRun3 = soa::Join; // using MyEventsWithCentQvectRun3 = soa::Join; using MyEventsWithCentQvectRun3 = soa::Join; -using MyBarrelTracks = soa::Join; -using MyBarrelTracksWithCov = soa::Join; +// using MyBarrelTracks = soa::Join; +// using MyBarrelTracksWithCov = soa::Joini; + +using MyBarrelTracks = soa::Join; +using MyBarrelTracksWithCov = soa::Join; using MyTracks = soa::Filtered>; using MyMuons = aod::FwdTracks; using MyMuonsWithCov = soa::Join; @@ -103,8 +108,6 @@ struct DQEventQvector { Produces eventQvectorCentrExtra; Produces eventRefFlow; Produces eventQvectorZN; - Produces eventReducedZdc; - Produces eventReducedZdcExtra; Configurable fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"}; Configurable fConfigQA{"cfgQA", true, "If true, fill QA histograms"}; @@ -189,7 +192,7 @@ struct DQEventQvector { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (fConfigFillWeights) { // fWeights->SetPtBins(ptbins, &ptbinning[0]); // in the default case, it will accept everything - fWeights->Init(true, false); // true for data, false for MC + fWeights->init(true, false); // true for data, false for MC } // Reference flow @@ -383,7 +386,7 @@ struct DQEventQvector { // Fill weights for Q-vector correction: this should be enabled for a first run to get weights if (fConfigFillWeights) { - fWeights->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); + fWeights->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); } if (cfg.mEfficiency) { @@ -396,7 +399,7 @@ struct DQEventQvector { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), collision.posZ()); + wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), collision.posZ()); } else { wacc = 1.0; } @@ -532,14 +535,8 @@ struct DQEventQvector { eventQvectorCentrExtra(collision.qvecTPCallRe(), collision.qvecTPCallIm(), collision.nTrkTPCall()); if (bc.has_zdc()) { eventQvectorZN(VarManager::fgValues[VarManager::kQ1ZNAX], VarManager::fgValues[VarManager::kQ1ZNAY], VarManager::fgValues[VarManager::kQ1ZNCX], VarManager::fgValues[VarManager::kQ1ZNCY]); - eventReducedZdc(VarManager::fgValues[VarManager::kEnergyCommonZNA], VarManager::fgValues[VarManager::kEnergyCommonZNC], VarManager::fgValues[VarManager::kEnergyCommonZPA], VarManager::fgValues[VarManager::kEnergyCommonZPC], - VarManager::fgValues[VarManager::kTimeZNA], VarManager::fgValues[VarManager::kTimeZNC], VarManager::fgValues[VarManager::kTimeZPA], VarManager::fgValues[VarManager::kTimeZPC]); - eventReducedZdcExtra(VarManager::fgValues[VarManager::kEnergyZNA1], VarManager::fgValues[VarManager::kEnergyZNA2], VarManager::fgValues[VarManager::kEnergyZNA3], VarManager::fgValues[VarManager::kEnergyZNA4], - VarManager::fgValues[VarManager::kEnergyZNC1], VarManager::fgValues[VarManager::kEnergyZNC2], VarManager::fgValues[VarManager::kEnergyZNC3], VarManager::fgValues[VarManager::kEnergyZNC4]); } else { eventQvectorZN(-999, -999, -999, -999); - eventReducedZdc(-999, -999, -999, -999, -999, -999, -999, -999); - eventReducedZdcExtra(-999, -999, -999, -999, -999, -999, -999, -999); } } } diff --git a/PWGDQ/Tasks/filterPP.cxx b/PWGDQ/Tasks/filterPP.cxx index 6cd9fad6d7e..c9239f8366d 100644 --- a/PWGDQ/Tasks/filterPP.cxx +++ b/PWGDQ/Tasks/filterPP.cxx @@ -13,6 +13,8 @@ // #include #include +#include +#include #include #include #include @@ -59,6 +61,7 @@ enum DQTriggers { kSingleMuLow, kSingleMuHigh, kDiMuon, + kElectronMuon, kNTriggersDQ }; } // namespace @@ -247,14 +250,14 @@ struct DQBarrelTrackSelection { fCurrentRun = bc.runNumber(); } - uint32_t filterMap = uint32_t(0); + uint32_t filterMap = static_cast(0); trackSel.reserve(tracksBarrel.size()); VarManager::ResetValues(0, VarManager::kNBarrelTrackVariables); for (auto& track : tracksBarrel) { - filterMap = uint32_t(0); + filterMap = static_cast(0); if (!track.has_collision()) { - trackSel(uint32_t(0)); + trackSel(static_cast(0)); } else { VarManager::FillTrack(track); if (fConfigQA) { @@ -263,7 +266,7 @@ struct DQBarrelTrackSelection { int i = 0; for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); ++cut, ++i) { if ((*cut).IsSelected(VarManager::fgValues)) { - filterMap |= (uint32_t(1) << i); + filterMap |= (static_cast(1) << i); if (fConfigQA) { fHistMan->FillHistClass(fCutHistNames[i].Data(), VarManager::fgValues); } @@ -331,16 +334,16 @@ struct DQMuonsSelection { template void runMuonSelection(TMuons const& muons) { - uint32_t filterMap = uint32_t(0); + uint32_t filterMap = static_cast(0); trackSel.reserve(muons.size()); VarManager::ResetValues(0, VarManager::kNMuonTrackVariables); // fill event information which might be needed in histograms or cuts that combine track and event properties for (auto& muon : muons) { - filterMap = uint32_t(0); + filterMap = static_cast(0); if (!muon.has_collision()) { - trackSel(uint32_t(0)); + trackSel(static_cast(0)); } else { VarManager::FillTrack(muon); if (fConfigQA) { @@ -349,7 +352,7 @@ struct DQMuonsSelection { int i = 0; for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); ++cut, ++i) { if ((*cut).IsSelected(VarManager::fgValues)) { - filterMap |= (uint32_t(1) << i); + filterMap |= (static_cast(1) << i); if (fConfigQA) { fHistMan->FillHistClass(fCutHistNames[i].Data(), VarManager::fgValues); } @@ -386,8 +389,8 @@ struct DQFilterPPTask { Configurable fConfigFilterLsBarrelTracksPairs{"cfgWithBarrelLS", "false", "Comma separated list of booleans for each trigger, If true, also select like sign (--/++) barrel track pairs"}; Configurable fConfigFilterLsMuonsPairs{"cfgWithMuonLS", "false", "Comma separated list of booleans for each trigger, If true, also select like sign (--/++) muon pairs"}; - Filter filterBarrelTrackSelected = aod::dqppfilter::isDQBarrelSelected > uint32_t(0); - Filter filterMuonTrackSelected = aod::dqppfilter::isDQMuonSelected > uint32_t(0); + Filter filterBarrelTrackSelected = aod::dqppfilter::isDQBarrelSelected > static_cast(0); + Filter filterMuonTrackSelected = aod::dqppfilter::isDQMuonSelected > static_cast(0); int fNBarrelCuts; // number of barrel selections int fNMuonCuts; // number of muon selections @@ -496,14 +499,14 @@ struct DQFilterPPTask { // if the event is not selected produce tables and return if (!collision.isDQEventSelected()) { eventFilter(0); - dqtable(false, false, false, false, false, false, false); + dqtable(false, false, false, false, false, false, false, false); return; } fStats->Fill(-1.0); if (tracksBarrel.size() == 0 && muons.size() == 0) { eventFilter(0); - dqtable(false, false, false, false, false, false, false); + dqtable(false, false, false, false, false, false, false, false); return; } @@ -515,7 +518,7 @@ struct DQFilterPPTask { // count the number of barrel tracks fulfilling each cut for (auto track : tracksBarrel) { for (int i = 0; i < fNBarrelCuts; ++i) { - if (track.isDQBarrelSelected() & (uint32_t(1) << i)) { + if (track.isDQBarrelSelected() & (static_cast(1) << i)) { objCountersBarrel[i] += 1; } } @@ -526,7 +529,7 @@ struct DQFilterPPTask { for (int i = 0; i < fNBarrelCuts; i++) { if (fBarrelRunPairing[i]) { if (objCountersBarrel[i] > 1) { // pairing has to be enabled and at least two tracks are needed - pairingMask |= (uint32_t(1) << i); + pairingMask |= (static_cast(1) << i); } objCountersBarrel[i] = 0; // reset counters for selections where pairing is needed (count pairs instead) } @@ -539,7 +542,7 @@ struct DQFilterPPTask { for (int icut = 0; icut < fNBarrelCuts; icut++) { TString objStr = objArrayLS->At(icut)->GetName(); if (!objStr.CompareTo("true")) { - pairingLS |= (uint32_t(1) << icut); + pairingLS |= (static_cast(1) << icut); } } @@ -556,12 +559,12 @@ struct DQFilterPPTask { VarManager::FillPair(t1, t2); // compute pair quantities for (int icut = 0; icut < fNBarrelCuts; icut++) { // select like-sign pairs if trigger has set boolean true within fConfigFilterLsBarrelTracksPairs - if (!(pairingLS & (uint32_t(1) << icut))) { + if (!(pairingLS & (static_cast(1) << icut))) { if (t1.sign() * t2.sign() > 0) { continue; } } - if (!(pairFilter & (uint32_t(1) << icut))) { + if (!(pairFilter & (static_cast(1) << icut))) { continue; } if (!fBarrelPairCuts[icut].IsSelected(VarManager::fgValues)) { @@ -579,7 +582,7 @@ struct DQFilterPPTask { // count the number of muon tracks fulfilling each selection for (auto muon : muons) { for (int i = 0; i < fNMuonCuts; ++i) { - if (muon.isDQMuonSelected() & (uint32_t(1) << i)) { + if (muon.isDQMuonSelected() & (static_cast(1) << i)) { objCountersMuon[i] += 1; } } @@ -590,7 +593,7 @@ struct DQFilterPPTask { for (int i = 0; i < fNMuonCuts; i++) { if (fMuonRunPairing[i]) { // pairing has to be enabled and at least two tracks are needed if (objCountersMuon[i] > 1) { - pairingMask |= (uint32_t(1) << i); + pairingMask |= (static_cast(1) << i); } objCountersMuon[i] = 0; // reset counters for selections where pairing is needed (count pairs instead) } @@ -603,7 +606,7 @@ struct DQFilterPPTask { for (int icut = 0; icut < fNMuonCuts; icut++) { TString objStr = objArrayMuonLS->At(icut)->GetName(); if (!objStr.CompareTo("true")) { - pairingLS |= (uint32_t(1) << icut); + pairingLS |= (static_cast(1) << icut); } } @@ -620,12 +623,12 @@ struct DQFilterPPTask { VarManager::FillPair(t1, t2); // compute pair quantities for (int icut = 0; icut < fNMuonCuts; icut++) { // select like-sign pairs if trigger has set boolean true within fConfigFilterLsMuonsPairs - if (!(pairingLS & (uint32_t(1) << icut))) { + if (!(pairingLS & (static_cast(1) << icut))) { if (t1.sign() * t2.sign() > 0) { continue; } } - if (!(pairFilter & (uint32_t(1) << icut))) { + if (!(pairFilter & (static_cast(1) << icut))) { continue; } if (!fMuonPairCuts[icut].IsSelected(VarManager::fgValues)) { @@ -648,7 +651,7 @@ struct DQFilterPPTask { uint64_t filter = 0; for (int i = 0; i < fNBarrelCuts; i++) { if (objCountersBarrel[i] >= fBarrelNreqObjs[i]) { - filter |= (uint64_t(1) << i); + filter |= (static_cast(1) << i); fStats->Fill(static_cast(i)); if (i < kNTriggersDQ) { decisions[i] = true; @@ -657,7 +660,7 @@ struct DQFilterPPTask { } for (int i = 0; i < fNMuonCuts; i++) { if (objCountersMuon[i] >= fMuonNreqObjs[i]) { - filter |= (uint64_t(1) << (i + fNBarrelCuts)); + filter |= (static_cast(1) << (i + fNBarrelCuts)); fStats->Fill(static_cast(i + fNBarrelCuts)); if (i + fNBarrelCuts < kNTriggersDQ) { decisions[i + fNBarrelCuts] = true; @@ -665,7 +668,7 @@ struct DQFilterPPTask { } } eventFilter(filter); - dqtable(decisions[0], decisions[1], decisions[2], decisions[3], decisions[4], decisions[5], decisions[6]); + dqtable(decisions[0], decisions[1], decisions[2], decisions[3], decisions[4], decisions[5], decisions[6], decisions[7]); } void processFilterPP(MyEventsSelected::iterator const& collision, aod::BCs const& bcs, diff --git a/PWGDQ/Tasks/filterPPwithAssociation.cxx b/PWGDQ/Tasks/filterPPwithAssociation.cxx index d2d374b06ef..532482e641b 100644 --- a/PWGDQ/Tasks/filterPPwithAssociation.cxx +++ b/PWGDQ/Tasks/filterPPwithAssociation.cxx @@ -70,7 +70,7 @@ enum DQTriggers { kSingleMuLow, kSingleMuHigh, kDiMuon, - // kElectronMuon, // the ElectronMuon trigger is not available now + kElectronMuon, kNTriggersDQ }; } // namespace @@ -105,21 +105,29 @@ using MyBarrelTracks = soa::Join; -using MyBarrelTracksSelected = soa::Join; +using MyBarrelTracksTPCPID = soa::Join; + using MyBarrelTracksAssocSelected = soa::Join; // As the kinelatic values must be re-computed for the tracks everytime it is associated to a collision, the selection is done not on the tracks, but on the track-collision association using MyMuons = soa::Join; using MyMuonsAssocSelected = soa::Join; // As the kinelatic values must be re-computed for the muons tracks everytime it is associated to a collision, the selection is done not on the muon, but on the muon-collision association -constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision; +constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::Collision; constexpr static uint32_t gkTrackFillMap = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackPID; +constexpr static uint32_t gkTrackFillMapTPCPID = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackTPCPID; constexpr static uint32_t gkMuonFillMap = VarManager::ObjTypes::Muon | VarManager::ObjTypes::MuonCov; -void DefineHistograms(HistogramManager* histMan, TString histClasses); +void DefineHistograms(HistogramManager* histMan, TString histClasses, TString subgroups = ""); + +template +void PrintBitMap(TMap map, int nbits) +{ + for (int i = 0; i < nbits; i++) { + cout << ((map & (TMap(1) << i)) > 0 ? "1" : "0"); + } +} struct DQEventSelectionTask { Produces eventSel; @@ -129,6 +137,7 @@ struct DQEventSelectionTask { Configurable fConfigEventCuts{"cfgEventCuts", "eventStandard", "Comma separated list of event cuts; multiple cuts are applied with a logical AND"}; Configurable fConfigQA{"cfgWithQA", false, "If true, fill QA histograms"}; + Configurable fConfigHistClasses{"cfgHistClasses", "vtxpp", "Comma separated list of histogram groups to be filled"}; // TODO: configure the histogram classes to be filled by QA void init(o2::framework::InitContext&) @@ -150,14 +159,14 @@ struct DQEventSelectionTask { fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); - DefineHistograms(fHistMan, "Event_BeforeCuts;Event_AfterCuts;"); // define all histograms + DefineHistograms(fHistMan, "Event_BeforeCuts;Event_AfterCuts;", fConfigHistClasses.value); // define all histograms VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } } template - void runEventSelection(TEvent const& collision, aod::BCs const& /*bcs*/) + void runEventSelection(TEvent const& collision) { // Reset the Values array VarManager::ResetValues(0, VarManager::kNEventWiseVariables); @@ -176,9 +185,9 @@ struct DQEventSelectionTask { } } - void processEventSelection(MyEvents::iterator const& collision, aod::BCs const& bcs) + void processEventSelection(MyEvents::iterator const& collision) { - runEventSelection(collision, bcs); + runEventSelection(collision); } void processDummy(MyEvents&) @@ -199,7 +208,8 @@ struct DQBarrelTrackSelection { Configurable fConfigCuts{"cfgBarrelTrackCuts", "jpsiPID1", "Comma separated list of barrel track cuts"}; Configurable fConfigCutsForEMu{"cfgBarrelTrackCutsForEMu", "jpsiPID1", "Comma separated list of barrel track cuts"}; Configurable fConfigQA{"cfgWithQA", false, "If true, fill QA histograms"}; - Configurable fPropTrack{"cfgPropTrack", false, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; + Configurable fConfigHistClasses{"cfgHistClasses", "its,tpcpid,dca", "If true, fill QA histograms"}; + Configurable fPropTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable fConfigCcdbPathTPC{"ccdb-path-tpc", "Users/i/iarsene/Calib/TPCpostCalib", "base path to the ccdb object"}; Configurable fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; @@ -255,18 +265,15 @@ struct DQBarrelTrackSelection { fCutHistNames.push_back(Form("TrackBarrel_%s", cut.GetName())); } - DefineHistograms(fHistMan, cutNames.Data()); // define all histograms + DefineHistograms(fHistMan, cutNames.Data(), fConfigHistClasses.value); // define all histograms VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); // CCDB configuration - if (fConfigComputeTPCpostCalib) { - fCCDB->setURL(fConfigCcdbUrl.value); - fCCDB->setCaching(true); - fCCDB->setLocalObjectValidityChecking(); - // Not later than now objects - fCCDB->setCreatedNotAfter(fConfigNoLaterThan.value); - } + fCCDB->setURL(fConfigCcdbUrl.value); + fCCDB->setCaching(true); + fCCDB->setLocalObjectValidityChecking(); + fCCDB->setCreatedNotAfter(fConfigNoLaterThan.value); } } @@ -277,8 +284,14 @@ struct DQBarrelTrackSelection { auto bc = bcs.begin(); // check just the first bc to get the run number if (fCurrentRun != bc.runNumber()) { fCurrentRun = bc.runNumber(); - o2::parameters::GRPMagField* grpo = fCCDB->getForTimeStamp("GLO/Config/GRPMagField", bc.timestamp()); - o2::base::Propagator::initFieldFromGRP(grpo); + + o2::parameters::GRPMagField* grpmag = fCCDB->getForTimeStamp("GLO/Config/GRPMagField", bc.timestamp()); + if (grpmag != nullptr) { + VarManager::SetMagneticField(grpmag->getNominalL3Field()); + } else { + LOGF(fatal, "GRP object is not available in CCDB at timestamp=%llu", bc.timestamp()); + } + if (fConfigComputeTPCpostCalib) { auto calibList = fCCDB->getForTimeStamp(fConfigCcdbPathTPC.value, bc.timestamp()); VarManager::SetCalibrationObject(VarManager::kTPCElectronMean, calibList->FindObject("mean_map_electron")); @@ -292,7 +305,7 @@ struct DQBarrelTrackSelection { // material correction for track propagation // o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; - o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + // o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; uint32_t filterMap = static_cast(0); uint32_t filterMapEMu = static_cast(0); @@ -309,7 +322,7 @@ struct DQBarrelTrackSelection { VarManager::FillTrack(track); // compute quantities which depend on the associated collision, such as DCA if (fPropTrack && (track.collisionId() != collision.globalIndex())) { - VarManager::FillTrackCollisionMatCorr(track, collision, noMatCorr, o2::base::Propagator::Instance()); + VarManager::FillTrackCollision(track, collision); } if (fConfigQA) { fHistMan->FillHistClass("TrackBarrel_BeforeCuts", VarManager::fgValues); @@ -342,12 +355,21 @@ struct DQBarrelTrackSelection { } } + void processSelectionTPCPID(Collisions const& collisions, aod::BCsWithTimestamps const& bcs, MyBarrelTracksTPCPID const& tracks, aod::TrackAssoc const& trackAssocs) + { + for (auto& collision : collisions) { + auto trackIdsThisCollision = trackAssocs.sliceBy(barrelTrackIndicesPerCollision, collision.globalIndex()); + runTrackSelection(collision, bcs, tracks, trackIdsThisCollision); + } + } + void processDummy(MyBarrelTracks&) { // do nothing } PROCESS_SWITCH(DQBarrelTrackSelection, processSelection, "Run barrel track selection", false); + PROCESS_SWITCH(DQBarrelTrackSelection, processSelectionTPCPID, "Run barrel track selection, just TPC PID (no TOF)", false); PROCESS_SWITCH(DQBarrelTrackSelection, processDummy, "Dummy function", false); }; @@ -360,6 +382,7 @@ struct DQMuonsSelection { Configurable fConfigCuts{"cfgMuonsCuts", "muonQualityCuts", "Comma separated list of ADDITIONAL muon track cuts"}; Configurable fConfigCutsForEMu{"cfgMuonsCutsForEMu", "muonQualityCuts", "Comma separated list of ADDITIONAL muon track cuts"}; Configurable fConfigQA{"cfgWithQA", false, "If true, fill QA histograms"}; + Configurable fConfigHistClasses{"cfgHistClasses", "muon", "If true, fill QA histograms"}; Configurable fPropMuon{"cfgPropMuon", false, "Propgate muon tracks through absorber"}; Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; @@ -417,7 +440,7 @@ struct DQMuonsSelection { fCutHistNames.push_back(Form("Muon_%s", fTrackCuts[i].GetName())); } - DefineHistograms(fHistMan, cutNames.Data()); // define all histograms + DefineHistograms(fHistMan, cutNames.Data(), fConfigHistClasses.value); // define all histograms VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -492,67 +515,6 @@ struct DQMuonsSelection { PROCESS_SWITCH(DQMuonsSelection, processDummy, "Dummy function", false); }; -/* -struct DQTrackToCollisionAssociation { - - Produces association; - Produces reverseIndices; - Produces fwdassociation; - Produces fwdreverseIndices; - - // NOTE: the options for the collision associator are common for both the barrel and muon - // We should add separate ones if needed - Configurable nSigmaForTimeCompat{"nSigmaForTimeCompat", 4.f, "number of sigmas for time compatibility"}; - Configurable timeMargin{"timeMargin", 0.f, "time margin in ns added to uncertainty because of uncalibrated TPC"}; - Configurable usePVAssociation{"usePVAssociation", true, "if the track is a PV contributor, use the collision time for it"}; - Configurable includeUnassigned{"includeUnassigned", false, "consider also tracks which are not assigned to any collision"}; - Configurable fillTableOfCollIdsPerTrack{"fillTableOfCollIdsPerTrack", false, "fill additional table with vector of collision ids per track"}; - Configurable bcWindowForOneSigma{"bcWindowForOneSigma", 60, "BC window to be multiplied by the number of sigmas to define maximum window to be considered"}; - - CollisionAssociation collisionAssociatorBarrel; - CollisionAssociation collisionAssociatorMuon; - - Filter filterBarrelTrackSelected = aod::dqppfilter::isDQBarrelSelected > uint32_t(0); - Filter filterMuonTrackSelected = aod::dqppfilter::isDQMuonSelected > uint32_t(0); - - void init(o2::framework::InitContext const&) - { - // set options in track-to-collision association - collisionAssociatorBarrel.setNumSigmaForTimeCompat(nSigmaForTimeCompat); - collisionAssociatorBarrel.setTimeMargin(timeMargin); - collisionAssociatorBarrel.setTrackSelectionOptionForStdAssoc(track_association::TrackSelection::None); - collisionAssociatorBarrel.setUsePvAssociation(usePVAssociation); - collisionAssociatorBarrel.setIncludeUnassigned(includeUnassigned); - collisionAssociatorBarrel.setFillTableOfCollIdsPerTrack(fillTableOfCollIdsPerTrack); - collisionAssociatorBarrel.setBcWindow(bcWindowForOneSigma); - // set options in muon-to-collision association - collisionAssociatorMuon.setNumSigmaForTimeCompat(nSigmaForTimeCompat); - collisionAssociatorMuon.setTimeMargin(timeMargin); - collisionAssociatorMuon.setTrackSelectionOptionForStdAssoc(track_association::TrackSelection::None); - collisionAssociatorMuon.setUsePvAssociation(false); - collisionAssociatorMuon.setIncludeUnassigned(includeUnassigned); - collisionAssociatorMuon.setFillTableOfCollIdsPerTrack(fillTableOfCollIdsPerTrack); - collisionAssociatorMuon.setBcWindow(bcWindowForOneSigma); - } - - void processAssocWithTime(Collisions const& collisions, - MyBarrelTracksSelected const& tracksUnfiltered, soa::Filtered const& tracks, - FwdTracks const& muons, - AmbiguousTracks const& ambiguousTracks, AmbiguousFwdTracks const& ambiguousFwdTracks, BCs const& bcs) - { - collisionAssociatorBarrel.runAssocWithTime(collisions, tracksUnfiltered, tracks, ambiguousTracks, bcs, association, reverseIndices); - collisionAssociatorMuon.runAssocWithTime(collisions, muons, muons, ambiguousFwdTracks, bcs, fwdassociation, fwdreverseIndices); - }; - void processDummy(Collisions&) - { - // do nothing - } - - PROCESS_SWITCH(DQTrackToCollisionAssociation, processAssocWithTime, "Produce track-to-collision associations based on time", false); - PROCESS_SWITCH(DQTrackToCollisionAssociation, processDummy, "Dummy function", false); -}; -*/ - struct DQFilterPPTask { Produces eventFilter; Produces dqtable; @@ -596,6 +558,10 @@ struct DQFilterPPTask { std::map fFiltersMap; // map of filters for events that passed at least one filter std::map> fCEFPfilters; // map of CEFP filters for events that passed at least one filter + uint32_t fPairingLSBarrel; // used to set in which cut setting LS pairs will be analysed + uint32_t fPairingLSMuon; // used to set in which cut setting LS pairs will be analysed + uint32_t fPairingLSBarrelMuon; // used to set in which cut setting LS pairs will be analysed + void DefineCuts() { TString barrelSelsStr = fConfigBarrelSelections.value; @@ -699,6 +665,39 @@ struct DQFilterPPTask { } DefineCuts(); + // check which selection should use like sign (LS) (--/++) barrel track pairs + fPairingLSBarrel = 0; + TString barrelLSstr = fConfigFilterLsBarrelTracksPairs.value; + std::unique_ptr objArrayLS(barrelLSstr.Tokenize(",")); + for (int icut = 0; icut < fNBarrelCuts; icut++) { + TString objStr = objArrayLS->At(icut)->GetName(); + if (!objStr.CompareTo("true")) { + fPairingLSBarrel |= (static_cast(1) << icut); + } + } + + // check which selection should use like sign (LS) (--/++) muon track pairs + fPairingLSMuon = 0; + TString musonLSstr = fConfigFilterLsMuonsPairs.value; + std::unique_ptr objArrayMuonLS(musonLSstr.Tokenize(",")); + for (int icut = 0; icut < fNMuonCuts; icut++) { + TString objStr = objArrayMuonLS->At(icut)->GetName(); + if (!objStr.CompareTo("true")) { + fPairingLSMuon |= (static_cast(1) << icut); + } + } + + // check which selection should use like sign (LS) (--/++) muon-barrel pairs + fPairingLSBarrelMuon = 0; // reset the decisions for electron-muons + TString electronMuonLSstr = fConfigFilterLsElectronMuonsPairs.value; + std::unique_ptr objArrayElectronMuonLS(electronMuonLSstr.Tokenize(",")); + for (int icut = 0; icut < fNElectronMuonCuts; icut++) { + TString objStr = objArrayElectronMuonLS->At(icut)->GetName(); + if (!objStr.CompareTo("true")) { + fPairingLSBarrelMuon |= (static_cast(1) << icut); + } + } + if (fConfigQA) { // initialize the variable manager VarManager::SetDefaultVarNames(); @@ -718,7 +717,7 @@ struct DQFilterPPTask { histNames += value; histNames += ";"; } - DefineHistograms(fHistMan, histNames.Data()); + DefineHistograms(fHistMan, histNames.Data(), "cepf"); VarManager::SetUseVars(fHistMan->GetUsedVars()); fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -746,146 +745,161 @@ struct DQFilterPPTask { VarManager::ResetValues(0, VarManager::kNVars); VarManager::FillEvent(collision); // event properties could be needed for cuts or histogramming + std::vector> taggedCollisions(fNBarrelCuts + fNMuonCuts + fNElectronMuonCuts); // collisions corresponding to selected associations or to which selected tracks are assigned in AO2D + std::vector objCountersBarrel(fNBarrelCuts, 0); // init all counters to zero + uint32_t pairingMask = 0; // in order to know which of the selections actually require pairing + uint32_t pairFilter = 0; // count the number of barrel tracks fulfilling each cut - for (auto trackAssoc : barrelAssocs) { - for (int i = 0; i < fNBarrelCuts; ++i) { - if (trackAssoc.isDQBarrelSelected() & (static_cast(1) << i)) { - objCountersBarrel[i] += 1; + if constexpr (static_cast(TTrackFillMap)) { + for (auto trackAssoc : barrelAssocs) { + for (int i = 0; i < fNBarrelCuts; ++i) { + if (trackAssoc.isDQBarrelSelected() & (static_cast(1) << i)) { + objCountersBarrel[i] += 1; + taggedCollisions[i][collision.globalIndex()] = 1; // add the current associated collision to the map + auto t1 = trackAssoc.template track_as(); + if (t1.has_collision()) { + taggedCollisions[i][t1.collisionId()] = 1; // add the originally assigned collision to the map + } + } } } - } - // check which selections require pairing - uint32_t pairingMask = 0; // in order to know which of the selections actually require pairing - for (int i = 0; i < fNBarrelCuts; i++) { - if (fBarrelRunPairing[i]) { - if (objCountersBarrel[i] > 1) { // pairing has to be enabled and at least two tracks are needed - pairingMask |= (static_cast(1) << i); + // check which selections require pairing + for (int i = 0; i < fNBarrelCuts; i++) { + if (fBarrelRunPairing[i]) { + if (objCountersBarrel[i] > 1) { // pairing has to be enabled and at least two tracks are needed + pairingMask |= (static_cast(1) << i); + } + objCountersBarrel[i] = 0; // reset counters for selections where pairing is needed (count pairs instead) + taggedCollisions[i].clear(); // empty the list of tagged collisions if pairing is needed (so we count just events with pairs or containing selected pair legs) } - objCountersBarrel[i] = 0; // reset counters for selections where pairing is needed (count pairs instead) } - } - // check which selection should use like sign (LS) (--/++) barrel track pairs - uint32_t pairingLS = 0; // used to set in which cut setting LS pairs will be analysed - TString barrelLSstr = fConfigFilterLsBarrelTracksPairs.value; - std::unique_ptr objArrayLS(barrelLSstr.Tokenize(",")); - for (int icut = 0; icut < fNBarrelCuts; icut++) { - TString objStr = objArrayLS->At(icut)->GetName(); - if (!objStr.CompareTo("true")) { - pairingLS |= (static_cast(1) << icut); - } - } + // run pairing if there is at least one selection that requires it + if (pairingMask > 0) { + // run pairing on the collision grouped associations + for (auto& [a1, a2] : combinations(barrelAssocs, barrelAssocs)) { - // run pairing if there is at least one selection that requires it - uint32_t pairFilter = 0; - if (pairingMask > 0) { - // run pairing on the collision grouped associations - for (auto& [a1, a2] : combinations(barrelAssocs, barrelAssocs)) { + // get the tracks from the index stored in the association + auto t1 = a1.template track_as(); + auto t2 = a2.template track_as(); - // get the tracks from the index stored in the association - auto t1 = a1.template track_as(); - auto t2 = a2.template track_as(); + // check the pairing mask and that the tracks share a cut bit + pairFilter = pairingMask & a1.isDQBarrelSelected() & a2.isDQBarrelSelected(); + if (pairFilter == 0) { + continue; + } - // check the pairing mask and that the tracks share a cut bit - pairFilter = pairingMask & a1.isDQBarrelSelected() & a2.isDQBarrelSelected(); - if (pairFilter == 0) { - continue; - } - // construct the pair and apply pair cuts - VarManager::FillPair(t1, t2); // compute pair quantities - for (int icut = 0; icut < fNBarrelCuts; icut++) { - // select like-sign pairs if trigger has set boolean true within fConfigFilterLsBarrelTracksPairs - if (!(pairingLS & (static_cast(1) << icut))) { - if (t1.sign() * t2.sign() > 0) { + // construct the pair and apply pair cuts + VarManager::FillPair(t1, t2); // compute pair quantities + for (int icut = 0; icut < fNBarrelCuts; icut++) { + // select like-sign pairs if trigger has set boolean true within fConfigFilterLsBarrelTracksPairs + if (!(fPairingLSBarrel & (static_cast(1) << icut))) { + if (t1.sign() * t2.sign() > 0) { + continue; + } + } + + if (!(pairFilter & (static_cast(1) << icut))) { + continue; + } + if (!fBarrelPairCuts[icut].IsSelected(VarManager::fgValues)) { continue; } - } - if (!(pairFilter & (static_cast(1) << icut))) { - continue; - } - if (!fBarrelPairCuts[icut].IsSelected(VarManager::fgValues)) { - continue; - } - objCountersBarrel[icut] += 1; // count the pair - if (fConfigQA) { // fill histograms if QA is enabled - fHistMan->FillHistClass(fBarrelPairHistNames[icut].Data(), VarManager::fgValues); + taggedCollisions[icut][collision.globalIndex()] = 1; // add the originally assigned collision to the map + if (t1.has_collision()) { + taggedCollisions[icut][t1.collisionId()] = 1; // add the originally assigned collision to the map + } + if (t2.has_collision()) { + taggedCollisions[icut][t2.collisionId()] = 1; // add the originally assigned collision to the map + } + + objCountersBarrel[icut] += 1; // count the pair + if (fConfigQA) { // fill histograms if QA is enabled + fHistMan->FillHistClass(fBarrelPairHistNames[icut].Data(), VarManager::fgValues); + } } } } } std::vector objCountersMuon(fNMuonCuts, 0); // init all counters to zero - // count the number of muon-collision associations fulfilling each selection - for (auto muon : muonAssocs) { - for (int i = 0; i < fNMuonCuts; ++i) { - if (muon.isDQMuonSelected() & (static_cast(1) << i)) { - objCountersMuon[i] += 1; + if constexpr (static_cast(TMuonFillMap)) { + // count the number of muon-collision associations fulfilling each selection + for (auto muon : muonAssocs) { + for (int i = 0; i < fNMuonCuts; ++i) { + if (muon.isDQMuonSelected() & (static_cast(1) << i)) { + objCountersMuon[i] += 1; + taggedCollisions[i + fNBarrelCuts][collision.globalIndex()] = 1; // add the current associated collision to the map + auto t1 = muon.template fwdtrack_as(); + if (t1.has_collision()) { + taggedCollisions[i + fNBarrelCuts][t1.collisionId()] = 1; // add the originally assigned collision to the map + } + } } } - } - // check which muon selections require pairing - pairingMask = 0; // reset the mask for the muons - for (int i = 0; i < fNMuonCuts; i++) { - if (fMuonRunPairing[i]) { // pairing has to be enabled and at least two tracks are needed - if (objCountersMuon[i] > 1) { - pairingMask |= (static_cast(1) << i); + // check which muon selections require pairing + pairingMask = 0; // reset the mask for the muons + for (int i = 0; i < fNMuonCuts; i++) { + if (fMuonRunPairing[i]) { // pairing has to be enabled and at least two tracks are needed + if (objCountersMuon[i] > 1) { + pairingMask |= (static_cast(1) << i); + } + objCountersMuon[i] = 0; // reset counters for selections where pairing is needed (count pairs instead) + taggedCollisions[i + fNBarrelCuts].clear(); // empty the list of tagged collisions if pairing is needed (so we count just events with pairs or containing selected pair legs) } - objCountersMuon[i] = 0; // reset counters for selections where pairing is needed (count pairs instead) } - } - // check which selection should use like sign (LS) (--/++) muon track pairs - pairingLS = 0; // reset the decisions for muons - TString musonLSstr = fConfigFilterLsMuonsPairs.value; - std::unique_ptr objArrayMuonLS(musonLSstr.Tokenize(",")); - for (int icut = 0; icut < fNMuonCuts; icut++) { - TString objStr = objArrayMuonLS->At(icut)->GetName(); - if (!objStr.CompareTo("true")) { - pairingLS |= (static_cast(1) << icut); - } - } + // run pairing if there is at least one selection that requires it + pairFilter = 0; + if (pairingMask > 0) { + // pairing is done using the collision grouped muon associations + for (auto& [a1, a2] : combinations(muonAssocs, muonAssocs)) { - // run pairing if there is at least one selection that requires it - pairFilter = 0; - if (pairingMask > 0) { - // pairing is done using the collision grouped muon associations - for (auto& [a1, a2] : combinations(muonAssocs, muonAssocs)) { - - // check the pairing mask and that the tracks share a cut bit - pairFilter = pairingMask & a1.isDQMuonSelected() & a2.isDQMuonSelected(); - if (pairFilter == 0) { - continue; - } + // check the pairing mask and that the tracks share a cut bit + pairFilter = pairingMask & a1.isDQMuonSelected() & a2.isDQMuonSelected(); + if (pairFilter == 0) { + continue; + } - // get the real muon tracks - auto t1 = a1.template fwdtrack_as(); - auto t2 = a2.template fwdtrack_as(); + // get the real muon tracks + auto t1 = a1.template fwdtrack_as(); + auto t2 = a2.template fwdtrack_as(); - // construct the pair and apply cuts - VarManager::FillPair(t1, t2); // compute pair quantities - if (fPropMuon) { - VarManager::FillPairPropagateMuon(t1, t2, collision); - } - for (int icut = 0; icut < fNMuonCuts; icut++) { - // select like-sign pairs if trigger has set boolean true within fConfigFilterLsMuonsPairs - if (!(pairingLS & (static_cast(1) << icut))) { - if (t1.sign() * t2.sign() > 0) { + // construct the pair and apply cuts + VarManager::FillPair(t1, t2); // compute pair quantities + if (fPropMuon) { + VarManager::FillPairPropagateMuon(t1, t2, collision); + } + for (int icut = 0; icut < fNMuonCuts; icut++) { + // select like-sign pairs if trigger has set boolean true within fConfigFilterLsMuonsPairs + if (!(fPairingLSMuon & (static_cast(1) << icut))) { + if (t1.sign() * t2.sign() > 0) { + continue; + } + } + if (!(pairFilter & (static_cast(1) << icut))) { continue; } - } - if (!(pairFilter & (static_cast(1) << icut))) { - continue; - } - if (!fMuonPairCuts[icut].IsSelected(VarManager::fgValues)) { - continue; - } - objCountersMuon[icut] += 1; - if (fConfigQA) { - fHistMan->FillHistClass(fMuonPairHistNames[icut].Data(), VarManager::fgValues); + if (!fMuonPairCuts[icut].IsSelected(VarManager::fgValues)) { + continue; + } + + taggedCollisions[icut + fNBarrelCuts][collision.globalIndex()] = 1; // add the originally assigned collision to the map + if (t1.has_collision()) { + taggedCollisions[icut + fNBarrelCuts][t1.collisionId()] = 1; // add the originally assigned collision to the map + } + if (t2.has_collision()) { + taggedCollisions[icut + fNBarrelCuts][t2.collisionId()] = 1; // add the originally assigned collision to the map + } + + objCountersMuon[icut] += 1; + if (fConfigQA) { + fHistMan->FillHistClass(fMuonPairHistNames[icut].Data(), VarManager::fgValues); + } } } } @@ -893,77 +907,145 @@ struct DQFilterPPTask { // electron-muon pair std::vector objCountersElectronMuon(fNElectronMuonCuts, 0); // init all counters to zero - pairingMask = 0; - for (auto& [trackAssoc, muon] : combinations(barrelAssocs, muonAssocs)) { - for (int i = 0; i < fNElectronMuonCuts; ++i) { - if (trackAssoc.isDQEMuBarrelSelected() & muon.isDQEMuMuonSelected() & (static_cast(1) << i)) { - if (fElectronMuonRunPairing[i]) { - pairingMask |= (static_cast(1) << i); + if constexpr (static_cast(TTrackFillMap) && static_cast(TMuonFillMap)) { + pairingMask = 0; + for (auto& [trackAssoc, muon] : combinations(barrelAssocs, muonAssocs)) { + for (int i = 0; i < fNElectronMuonCuts; ++i) { + if (trackAssoc.isDQEMuBarrelSelected() & muon.isDQEMuMuonSelected() & (static_cast(1) << i)) { + if (fElectronMuonRunPairing[i]) { + pairingMask |= (static_cast(1) << i); + } } } } - } - // check which selection should use like sign (LS) (--/++) muon track pairs - pairingLS = 0; // reset the decisions for electron-muons - TString electronMuonLSstr = fConfigFilterLsElectronMuonsPairs.value; - std::unique_ptr objArrayElectronMuonLS(electronMuonLSstr.Tokenize(",")); - for (int icut = 0; icut < fNElectronMuonCuts; icut++) { - TString objStr = objArrayElectronMuonLS->At(icut)->GetName(); - if (!objStr.CompareTo("true")) { - pairingLS |= (static_cast(1) << icut); - } - } - // run pairing if there is at least one selection that requires it - pairFilter = 0; - if (pairingMask > 0) { - // pairing is done using the collision grouped electron and muon associations - for (auto& [a1, a2] : combinations(barrelAssocs, muonAssocs)) { - // check the pairing mask and that the tracks share a cut bit - pairFilter = pairingMask & a1.isDQEMuBarrelSelected() & a2.isDQEMuMuonSelected(); - if (pairFilter == 0) { - continue; - } - // get the real electron and muon tracks - auto t1 = a1.template track_as(); - auto t2 = a2.template fwdtrack_as(); - // construct the pair and apply cuts - VarManager::FillPair(t1, t2); // compute pair quantities - for (int icut = 0; icut < fNElectronMuonCuts; icut++) { - // select like-sign pairs if trigger has set boolean true within fConfigFilterLsElectronMuonsPairs - if (!(pairingLS & (static_cast(1) << icut))) { - if (t1.sign() * t2.sign() > 0) { - continue; - } - } - if (!(pairFilter & (static_cast(1) << icut))) { - continue; - } - if (!fElectronMuonPairCuts[icut].IsSelected(VarManager::fgValues)) { + // run pairing if there is at least one selection that requires it + pairFilter = 0; + if (pairingMask > 0) { + // pairing is done using the collision grouped electron and muon associations + for (auto& [a1, a2] : combinations(barrelAssocs, muonAssocs)) { + // check the pairing mask and that the tracks share a cut bit + pairFilter = pairingMask & a1.isDQEMuBarrelSelected() & a2.isDQEMuMuonSelected(); + if (pairFilter == 0) { continue; } - objCountersElectronMuon[icut] += 1; - if (fConfigQA) { - fHistMan->FillHistClass(fElectronMuonPairHistNames[icut].Data(), VarManager::fgValues); + // get the real electron and muon tracks + auto t1 = a1.template track_as(); + auto t2 = a2.template fwdtrack_as(); + // construct the pair and apply cuts + VarManager::FillPair(t1, t2); // compute pair quantities + for (int icut = 0; icut < fNElectronMuonCuts; icut++) { + // select like-sign pairs if trigger has set boolean true within fConfigFilterLsElectronMuonsPairs + if (!(fPairingLSBarrelMuon & (static_cast(1) << icut))) { + if (t1.sign() * t2.sign() > 0) { + continue; + } + } + if (!(pairFilter & (static_cast(1) << icut))) { + continue; + } + if (!fElectronMuonPairCuts[icut].IsSelected(VarManager::fgValues)) { + continue; + } + + taggedCollisions[icut + fNBarrelCuts + fNMuonCuts][collision.globalIndex()] = 1; // add the originally assigned collision to the map + if (t1.has_collision()) { + taggedCollisions[icut + fNBarrelCuts + fNMuonCuts][t1.collisionId()] = 1; // add the originally assigned collision to the map + } + if (t2.has_collision()) { + taggedCollisions[icut + fNBarrelCuts + fNMuonCuts][t2.collisionId()] = 1; // add the originally assigned collision to the map + } + + objCountersElectronMuon[icut] += 1; + if (fConfigQA) { + fHistMan->FillHistClass(fElectronMuonPairHistNames[icut].Data(), VarManager::fgValues); + } } } } } // compute the decisions and publish uint64_t filter = 0; - for (int i = 0; i < fNBarrelCuts; i++) { - if (objCountersBarrel[i] >= fBarrelNreqObjs[i]) { - filter |= (static_cast(1) << i); + if constexpr (static_cast(TTrackFillMap)) { + for (int i = 0; i < fNBarrelCuts; i++) { + if (objCountersBarrel[i] >= fBarrelNreqObjs[i]) { + filter |= (static_cast(1) << i); + } else { + taggedCollisions[i].clear(); + } } } - for (int i = 0; i < fNMuonCuts; i++) { - if (objCountersMuon[i] >= fMuonNreqObjs[i]) { - filter |= (static_cast(1) << (i + fNBarrelCuts)); + if constexpr (static_cast(TMuonFillMap)) { + for (int i = 0; i < fNMuonCuts; i++) { + if (objCountersMuon[i] >= fMuonNreqObjs[i]) { + filter |= (static_cast(1) << (i + fNBarrelCuts)); + } else { + taggedCollisions[i + fNBarrelCuts].clear(); + } } } - for (int i = 0; i < fNElectronMuonCuts; i++) { - if (objCountersElectronMuon[i] >= fElectronMuonNreqObjs[i]) { - filter |= (static_cast(1) << (i + fNBarrelCuts + fNMuonCuts)); + if constexpr (static_cast(TTrackFillMap) && static_cast(TMuonFillMap)) { + for (int i = 0; i < fNElectronMuonCuts; i++) { + if (objCountersElectronMuon[i] >= fElectronMuonNreqObjs[i]) { + filter |= (static_cast(1) << (i + fNBarrelCuts + fNMuonCuts)); + } else { + taggedCollisions[i + fNBarrelCuts + fNMuonCuts].clear(); + } + } + } + + if (filter > 0) { + std::vector decisions(kNTriggersDQ, false); // event decisions to be transmitted to CEFP + for (int i = 0; i < fNBarrelCuts; i++) { + if (filter & (static_cast(1) << i)) { + if (i < kNTriggersDQ) { + decisions[i] = true; + } + } + } + for (int i = fNBarrelCuts; i < fNBarrelCuts + fNMuonCuts; i++) { + if (filter & (static_cast(1) << i)) { + if (i < kNTriggersDQ) { + decisions[i] = true; + } + } + } + for (int i = fNBarrelCuts + fNMuonCuts; i < fNBarrelCuts + fNMuonCuts + fNElectronMuonCuts; i++) { + if (filter & (static_cast(1) << i)) { + if (i < kNTriggersDQ) { + decisions[i] = true; + } + } + } + // if this collision fired at least one input, add it to the map, or if it is there already, update the decisions with a logical OR + // This may happen in the case when some collisions beyond the iterator are added because they contain ambiguous tracks fired on by another collision + if (fFiltersMap.find(collision.globalIndex()) == fFiltersMap.end()) { + fFiltersMap[collision.globalIndex()] = filter; + fCEFPfilters[collision.globalIndex()] = decisions; + } else { // this collision was already fired, possible via collision - track association; add as an OR the new decisions + fFiltersMap[collision.globalIndex()] |= filter; + for (int i = 0; i < kNTriggersDQ; i++) { + if (decisions[i]) { + fCEFPfilters[collision.globalIndex()][i] = true; + } + } + } + + // Go through the list of tagged collisions and add also those to the maps + // The reason is that in the tagged collisions we include also those collisions which did not fired the trigger conditions, but they contain + // tracks which in other associations contributed to fired triggers in other events. + for (int iTrig = 0; iTrig < fNBarrelCuts + fNMuonCuts + fNElectronMuonCuts; iTrig++) { + for (auto& [collId, aValue] : taggedCollisions[iTrig]) { + if (fFiltersMap.find(collId) == fFiltersMap.end()) { + fFiltersMap[collId] = (static_cast(1) << iTrig); + std::vector decisionsAdds(kNTriggersDQ, false); // event decisions to be transmitted to CEFP + decisionsAdds[iTrig] = true; + fCEFPfilters[collId] = decisionsAdds; + } else { // this collision was already fired, possible via collision - track association; add as an OR the new decisions + fFiltersMap[collId] |= (static_cast(1) << iTrig); + fCEFPfilters[collId][iTrig] = true; + } + } } } return filter; @@ -974,21 +1056,79 @@ struct DQFilterPPTask { void processFilterPP(MyEventsSelected const& collisions, aod::BCsWithTimestamps const& bcs, - MyBarrelTracksSelected const& tracks, + MyBarrelTracksTPCPID const& tracks, MyMuons const& muons, MyBarrelTracksAssocSelected const& trackAssocs, MyMuonsAssocSelected const& muonAssocs) { fFiltersMap.clear(); fCEFPfilters.clear(); - cout << "------------------- filterPP, n assocs barrel/muon :: " << trackAssocs.size() << " / " << muonAssocs.size() << endl; + // Loop over collisions + int eventsFired = 0; + for (const auto& collision : collisions) { + // skip those that do not pass our selection + if (!collision.isDQEventSelected()) { + continue; + } + // group the tracks and muons for this collision + auto groupedTrackIndices = trackAssocs.sliceBy(trackIndicesPerCollision, collision.globalIndex()); + auto groupedMuonIndices = muonAssocs.sliceBy(muonIndicesPerCollision, collision.globalIndex()); + + uint64_t filter = 0; + // if there is at least one track or muon, run the filtering function and compute triggers + if (groupedTrackIndices.size() > 0 || groupedMuonIndices.size() > 0) { + filter = runFilterPP(collision, bcs, tracks, muons, groupedTrackIndices, groupedMuonIndices); + } + if (filter == 0) { + continue; + } + eventsFired++; + } + + // At this point, we have all the non-null decisions for all collisions. + // we loop again over collisions and create the decision tables + // NOTE: For the CEFP decisions, decisions are placed in a vector of bool in an ordered way: + // start with all configured barrel selections and then continue with those from muons + // The configured order has to be in sync with that implemented in the cefp task and can be done + // by preparing a dedicated json configuration file + int totalEventsTriggered = 0; + for (const auto& collision : collisions) { + fStats->Fill(-2.0); + if (!collision.isDQEventSelected()) { + eventFilter(0); + dqtable(false, false, false, false, false, false, false, false); + continue; + } + fStats->Fill(-1.0); - uint64_t barrelMask = 0; - for (int i = 0; i < fNBarrelCuts; i++) { - barrelMask |= (static_cast(1) << i); + if (fFiltersMap.find(collision.globalIndex()) == fFiltersMap.end()) { + eventFilter(0); + dqtable(false, false, false, false, false, false, false, false); + } else { + totalEventsTriggered++; + for (int i = 0; i < fNBarrelCuts + fNMuonCuts + fNElectronMuonCuts; i++) { + if (fFiltersMap[collision.globalIndex()] & (static_cast(1) << i)) + fStats->Fill(static_cast(i)); + } + eventFilter(fFiltersMap[collision.globalIndex()]); + auto dqDecisions = fCEFPfilters[collision.globalIndex()]; + dqtable(dqDecisions[0], dqDecisions[1], dqDecisions[2], dqDecisions[3], dqDecisions[4], dqDecisions[5], dqDecisions[6], dqDecisions[7]); + } } + + cout << "-------------------- In this TF, eventsFired / totalTriggered :: " << eventsFired << "/" << totalEventsTriggered << endl; + } + + void processFilterMuonPP(MyEventsSelected const& collisions, + aod::BCsWithTimestamps const& bcs, + MyMuons const& muons, + MyMuonsAssocSelected const& muonAssocs) + { + fFiltersMap.clear(); + fCEFPfilters.clear(); + uint64_t muonMask = 0; - for (int i = fNBarrelCuts; i < fNBarrelCuts + fNMuonCuts; i++) { + for (int i = 0; i < fNMuonCuts; i++) { muonMask |= (static_cast(1) << i); } // Loop over collisions @@ -1000,14 +1140,13 @@ struct DQFilterPPTask { // event++; continue; } - // group the tracks and muons for this collision - auto groupedTrackIndices = trackAssocs.sliceBy(trackIndicesPerCollision, collision.globalIndex()); + // group the muons for this collision auto groupedMuonIndices = muonAssocs.sliceBy(muonIndicesPerCollision, collision.globalIndex()); uint64_t filter = 0; // if there is at least one track or muon, run the filtering function and compute triggers - if (groupedTrackIndices.size() > 0 || groupedMuonIndices.size() > 0) { - filter = runFilterPP(collision, bcs, tracks, muons, groupedTrackIndices, groupedMuonIndices); + if (groupedMuonIndices.size() > 0) { + filter = runFilterPP(collision, bcs, nullptr, muons, nullptr, groupedMuonIndices); } if (filter == 0) { // event++; @@ -1016,30 +1155,13 @@ struct DQFilterPPTask { eventsFired++; // compute the CEPF decisions (this is done in a spacial setup with exactly kNTriggersDQ configured triggers) std::vector decisions(kNTriggersDQ, false); // event decisions to be transmitted to CEFP - for (int i = 0; i < fNBarrelCuts; i++) { - if (filter & (static_cast(1) << i)) { - if (i < kNTriggersDQ) { - decisions[i] = true; - } - } - } - for (int i = fNBarrelCuts; i < fNBarrelCuts + fNMuonCuts; i++) { + for (int i = 0; i < fNMuonCuts; i++) { if (filter & (static_cast(1) << i)) { if (i < kNTriggersDQ) { decisions[i] = true; } } } - // the ElectronMuon trigger is not available now - /* - for (int i = fNBarrelCuts + fNMuonCuts; i < fNBarrelCuts + fNMuonCuts + fNElectronMuonCuts; i++) { - if (filter & (static_cast(1) << i)) { - if (i < kNTriggersDQ) { - decisions[i] = true; - } - } - } - */ // if this collision fired at least one input, add it to the map, or if it is there already, update the decisions with a logical OR // This may happen in the case when some collisions beyond the iterator are added because they contain ambiguous tracks fired on by another collision if (fFiltersMap.find(collision.globalIndex()) == fFiltersMap.end()) { @@ -1054,33 +1176,6 @@ struct DQFilterPPTask { } } - // Now check through the associated tracks / fwdtracks and assign the same filter to their parent collisions - // This is needed since if a collision was selected because of a track association from a neighbouring collision, - // then one needs to select also that collision in order to be able to redo the pairing at analysis time. - if (filter & barrelMask) { - for (auto& a : groupedTrackIndices) { - auto t = a.template track_as(); - if (!t.has_collision()) { - continue; - } - auto tColl = t.collisionId(); - if (tColl == collision.globalIndex()) { // track from this collision, nothing to do - continue; - } else { - if (fFiltersMap.find(tColl) == fFiltersMap.end()) { - fFiltersMap[tColl] = filter; - fCEFPfilters[tColl] = decisions; - } else { // this collision was already fired, possible via collision - track association; add as an OR the new decisions - fFiltersMap[tColl] |= filter; - for (int i = 0; i < kNTriggersDQ; i++) { - if (decisions[i]) { - fCEFPfilters[tColl][i] = true; - } - } - } - } - } - } // Do the same for muons if (filter & muonMask) { for (auto& a : groupedMuonIndices) { @@ -1120,26 +1215,23 @@ struct DQFilterPPTask { fStats->Fill(-2.0); if (!collision.isDQEventSelected()) { eventFilter(0); - dqtable(false, false, false, false, false, false, false); - // dqtable(false, false, false, false, false, false, false, false); // the ElectronMuon trigger is not available now + dqtable(false, false, false, false, false, false, false, false); continue; } fStats->Fill(-1.0); if (fFiltersMap.find(collision.globalIndex()) == fFiltersMap.end()) { eventFilter(0); - dqtable(false, false, false, false, false, false, false); - // dqtable(false, false, false, false, false, false, false, false); // the ElectronMuon trigger is not available now + dqtable(false, false, false, false, false, false, false, false); } else { totalEventsTriggered++; - for (int i = 0; i < fNBarrelCuts + fNMuonCuts + fNElectronMuonCuts; i++) { + for (int i = 0; i < fNMuonCuts; i++) { if (fFiltersMap[collision.globalIndex()] & (static_cast(1) << i)) fStats->Fill(static_cast(i)); } eventFilter(fFiltersMap[collision.globalIndex()]); auto dqDecisions = fCEFPfilters[collision.globalIndex()]; - dqtable(dqDecisions[0], dqDecisions[1], dqDecisions[2], dqDecisions[3], dqDecisions[4], dqDecisions[5], dqDecisions[6]); - // dqtable(dqDecisions[0], dqDecisions[1], dqDecisions[2], dqDecisions[3], dqDecisions[4], dqDecisions[5], dqDecisions[6], dqDecisions[7]); // the ElectronMuon trigger is not available now + dqtable(dqDecisions[0], dqDecisions[1], dqDecisions[2], dqDecisions[3], dqDecisions[4], dqDecisions[5], dqDecisions[6], dqDecisions[7]); } } @@ -1153,6 +1245,7 @@ struct DQFilterPPTask { } PROCESS_SWITCH(DQFilterPPTask, processFilterPP, "Run filter task", false); + PROCESS_SWITCH(DQFilterPPTask, processFilterMuonPP, "Run filter task for muons only", false); PROCESS_SWITCH(DQFilterPPTask, processDummy, "Dummy function", false); }; @@ -1166,7 +1259,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) adaptAnalysisTask(cfgc)}; } -void DefineHistograms(HistogramManager* histMan, TString histClasses) +void DefineHistograms(HistogramManager* histMan, TString histClasses, TString subgroups) { // // Define here the histograms for all the classes required in analysis. @@ -1177,26 +1270,26 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses) histMan->AddHistClass(classStr.Data()); if (classStr.Contains("Event")) { - dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "event", "trigger,vtxPbPb"); + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "event", subgroups.Data()); } if (classStr.Contains("Track")) { - dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", "its,tpcpid,dca"); + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", subgroups.Data()); } if (classStr.Contains("Muon") && !classStr.Contains("Electron")) { - dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", "muon"); + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", subgroups.Data()); } if (classStr.Contains("Pairs")) { if (classStr.Contains("Barrel")) { - dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair", "vertexing-barrel"); + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair", subgroups.Data()); } if (classStr.Contains("Forward")) { - dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair", "dimuon,vertexing-forward"); + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair", subgroups.Data()); } if (classStr.Contains("ElectronMuon")) { - dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair", "electronmuon"); + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair", subgroups.Data()); } } } diff --git a/PWGDQ/Tasks/filterPbPb.cxx b/PWGDQ/Tasks/filterPbPb.cxx index 81dfa35a996..1544ea14f21 100644 --- a/PWGDQ/Tasks/filterPbPb.cxx +++ b/PWGDQ/Tasks/filterPbPb.cxx @@ -18,6 +18,7 @@ #include "PWGDQ/Core/VarManager.h" #include "CommonConstants/LHCConstants.h" #include "ReconstructionDataFormats/Vertex.h" +#include "PWGUD/Core/SGSelector.h" using namespace std; @@ -30,11 +31,10 @@ using MyEvents = soa::Join; using MyBCs = soa::Join; struct DQFilterPbPbTask { + Produces eventRapidityGapFilter; Produces eventFilter; - OutputObj fStats{"Statistics"}; OutputObj fFilterOutcome{"Filter outcome"}; - Configurable fConfigEventTypes{"cfgEventTypes", "doublegap,singlegap", "Which event types to select. doublegap, singlegap or both, comma separated"}; Configurable fConfigNDtColl{"cfgNDtColl", 4, "Number of standard deviations to consider in BC range"}; Configurable fConfigMinNBCs{"cfgMinNBCs", 7, "Minimum number of BCs to consider in BC range"}; Configurable fConfigMinNPVCs{"cfgMinNPVCs", 2, "Minimum number of PV contributors"}; @@ -52,47 +52,51 @@ struct DQFilterPbPbTask { int eventTypeMap = 0; std::vector eventTypeOptions = {"doublegap", "singlegap"}; // Map for which types of event to select + SGSelector sgSelector; + SGCutParHolder sgCuts = SGCutParHolder(); + void init(o2::framework::InitContext&) { - // setup the Stats histogram - fStats.setObject(new TH1D("Statistics", "Stats for DQ triggers", 2, -2.5, -0.5)); - fStats->GetXaxis()->SetBinLabel(1, "Events inspected"); - fStats->GetXaxis()->SetBinLabel(2, "Events selected"); // setup the FilterOutcome histogram - fFilterOutcome.setObject(new TH1D("Filter outcome", "Filter outcome", 9, 0.5, 9.5)); + fFilterOutcome.setObject(new TH1D("Filter outcome", "Filter outcome", 8, 0.5, 8.5)); fFilterOutcome->GetXaxis()->SetBinLabel(1, "Events inspected"); - fFilterOutcome->GetXaxis()->SetBinLabel(2, "Events selected"); - fFilterOutcome->GetXaxis()->SetBinLabel(3, "!A && !C"); - fFilterOutcome->GetXaxis()->SetBinLabel(4, "!A && C"); - fFilterOutcome->GetXaxis()->SetBinLabel(5, "A && !C"); - fFilterOutcome->GetXaxis()->SetBinLabel(6, "A && C"); - fFilterOutcome->GetXaxis()->SetBinLabel(7, Form("numContrib not in [%d, %d]", fConfigMinNPVCs.value, fConfigMaxNPVCs.value)); - fFilterOutcome->GetXaxis()->SetBinLabel(8, "BC not found"); - fFilterOutcome->GetXaxis()->SetBinLabel(9, "ITS UPC settings used"); + fFilterOutcome->GetXaxis()->SetBinLabel(2, "!A && !C"); + fFilterOutcome->GetXaxis()->SetBinLabel(3, "!A && C"); + fFilterOutcome->GetXaxis()->SetBinLabel(4, "A && !C"); + fFilterOutcome->GetXaxis()->SetBinLabel(5, "A && C"); + fFilterOutcome->GetXaxis()->SetBinLabel(6, Form("numContrib not in [%d, %d]", fConfigMinNPVCs.value, fConfigMaxNPVCs.value)); + fFilterOutcome->GetXaxis()->SetBinLabel(7, "BC not found"); + fFilterOutcome->GetXaxis()->SetBinLabel(8, "ITS UPC settings used"); - TString eventTypesString = fConfigEventTypes.value; - for (std::vector::size_type i = 0; i < eventTypeOptions.size(); i++) { - if (eventTypesString.Contains(eventTypeOptions[i])) { - eventTypeMap |= (uint32_t(1) << i); - LOGF(info, "filterPbPb will select '%s' events", eventTypeOptions[i]); - } - } - if (eventTypeMap == 0) { - LOGF(fatal, "No valid choice of event types to select. Use 'doublegap', 'singlegap' or both"); - } + sgCuts.SetNDtcoll(fConfigNDtColl); + sgCuts.SetMinNBCs(fConfigMinNBCs); + sgCuts.SetNTracks(fConfigMinNPVCs, fConfigMaxNPVCs); + sgCuts.SetMaxFITtime(fConfigMaxFITTime); + sgCuts.SetFITAmpLimits({static_cast((fConfigUseFV0) ? fConfigFV0AmpLimit : -1.), + static_cast((fConfigUseFT0) ? fConfigFT0AAmpLimit : -1.), + static_cast((fConfigUseFT0) ? fConfigFT0CAmpLimit : -1.), + static_cast((fConfigUseFDD) ? fConfigFDDAAmpLimit : -1.), + static_cast((fConfigUseFDD) ? fConfigFDDCAmpLimit : -1.)}); } // Helper function for selecting double gap and single gap events template uint64_t rapidityGapFilter(TEvent const& collision, TBCs const& bcs, aod::FT0s& ft0s, aod::FV0As& fv0as, aod::FDDs& fdds, - int eventTypes, std::vector FITAmpLimits, int nDtColl, int minNBCs, int minNPVCs, int maxNPVCs, float maxFITTime, + std::vector FITAmpLimits, int nDtColl, int minNBCs, int minNPVCs, int maxNPVCs, float maxFITTime, bool useFV0, bool useFT0, bool useFDD) { fFilterOutcome->Fill(1., 1.); + + // Number of primary vertex contributors + if (collision.numContrib() < minNPVCs || collision.numContrib() > maxNPVCs) { + fFilterOutcome->Fill(6, 1); + return 0; + } + // Find BC associated with collision if (!collision.has_foundBC()) { - fFilterOutcome->Fill(8., 1); + fFilterOutcome->Fill(7., 1); return 0; } // foundBCId is stored in EvSels @@ -218,37 +222,23 @@ struct DQFilterPbPbTask { // Compute FIT decision uint64_t FITDecision = 0; if (isSideAClean && isSideCClean) { - fFilterOutcome->Fill(3, 1); - if (eventTypes & (uint32_t(1) << 0)) { - FITDecision |= (uint64_t(1) << VarManager::kDoubleGap); - } + fFilterOutcome->Fill(2, 1); + FITDecision |= (uint64_t(1) << VarManager::kDoubleGap); } if (isSideAClean && !isSideCClean) { - fFilterOutcome->Fill(4, 1); - if (eventTypes & (uint32_t(1) << 1)) { - FITDecision |= (uint64_t(1) << VarManager::kSingleGapA); - } + fFilterOutcome->Fill(3, 1); + FITDecision |= (uint64_t(1) << VarManager::kSingleGapA); } else if (!isSideAClean && isSideCClean) { - fFilterOutcome->Fill(5, 1); - if (eventTypes & (uint32_t(1) << 1)) { - FITDecision |= (uint64_t(1) << VarManager::kSingleGapC); - } + fFilterOutcome->Fill(4, 1); + FITDecision |= (uint64_t(1) << VarManager::kSingleGapC); } else if (!isSideAClean && !isSideCClean) { - fFilterOutcome->Fill(6, 1); + fFilterOutcome->Fill(5, 1); } if (!FITDecision) { return 0; } - // Number of primary vertex contributors - if (collision.numContrib() < minNPVCs || collision.numContrib() > maxNPVCs) { - fFilterOutcome->Fill(7, 1); - return 0; - } - - // If we made it here, the event passed - fFilterOutcome->Fill(2, 1); // Return filter bitmap corresponding to FIT decision return FITDecision; } @@ -256,23 +246,75 @@ struct DQFilterPbPbTask { void processFilterPbPb(MyEvents::iterator const& collision, MyBCs const& bcs, aod::FT0s& ft0s, aod::FV0As& fv0as, aod::FDDs& fdds) { - fStats->Fill(-2.0); - std::vector FITAmpLimits = {fConfigFV0AmpLimit, fConfigFT0AAmpLimit, fConfigFT0CAmpLimit, fConfigFDDAAmpLimit, fConfigFDDCAmpLimit}; uint64_t filter = rapidityGapFilter(collision, bcs, ft0s, fv0as, fdds, - eventTypeMap, FITAmpLimits, fConfigNDtColl, fConfigMinNBCs, fConfigMinNPVCs, fConfigMaxNPVCs, fConfigMaxFITTime, + FITAmpLimits, fConfigNDtColl, fConfigMinNBCs, fConfigMinNPVCs, fConfigMaxNPVCs, fConfigMaxFITTime, fConfigUseFV0, fConfigUseFT0, fConfigUseFDD); - bool isSelected = filter; - fStats->Fill(-1.0, isSelected); + // Record whether UPC settings were used for this event + if (collision.flags() & dataformats::Vertex>::Flags::UPCMode) { + filter |= (uint64_t(1) << VarManager::kITSUPCMode); + fFilterOutcome->Fill(8, 1); + } + + eventRapidityGapFilter(filter, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0); + eventFilter(filter); + } + + void processUDSGSelector(MyEvents::iterator const& collision, MyBCs const& bcs, + aod::FT0s& ft0s, aod::FV0As& fv0as, aod::FDDs& fdds, aod::Zdcs& /*zdcs*/) + { + uint64_t filter = 0; + fFilterOutcome->Fill(1, 1.); + if (!collision.has_foundBC()) { + fFilterOutcome->Fill(7, 1); + return; + } + + auto bc = collision.foundBC_as(); + auto newbc = bc; + auto bcRange = udhelpers::compatibleBCs(collision, fConfigNDtColl, bcs, fConfigMinNBCs); + auto isSGEvent = sgSelector.IsSelected(sgCuts, collision, bcRange, bc); + int issgevent = isSGEvent.value; + // Translate SGSelector values to DQEventFilter values + if (issgevent == 0) { + filter |= (uint64_t(1) << VarManager::kSingleGapA); + fFilterOutcome->Fill(3, 1); + } else if (issgevent == 1) { + filter |= (uint64_t(1) << VarManager::kSingleGapC); + fFilterOutcome->Fill(4, 1); + } else if (issgevent == 2) { + filter |= (uint64_t(1) << VarManager::kDoubleGap); + fFilterOutcome->Fill(2, 1); + } else if (issgevent == 3) { + fFilterOutcome->Fill(5, 1); + } else if (issgevent == 4) { + fFilterOutcome->Fill(6, 1); + } + + // Get closest bc with FIT activity above threshold + if (isSGEvent.bc && issgevent < 2) { + newbc = *(isSGEvent.bc); + } + upchelpers::FITInfo fitInfo{}; + udhelpers::getFITinfo(fitInfo, newbc, bcs, ft0s, fv0as, fdds); // Record whether UPC settings were used for this event if (collision.flags() & dataformats::Vertex>::Flags::UPCMode) { filter |= (uint64_t(1) << VarManager::kITSUPCMode); - fFilterOutcome->Fill(9, 1); + fFilterOutcome->Fill(8, 1); } + if (newbc.has_zdc()) { + auto zdc = newbc.zdc(); + eventRapidityGapFilter(filter, fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.ampFDDA, fitInfo.ampFDDC, fitInfo.ampFV0A, + zdc.energyCommonZNA(), zdc.energyCommonZNC(), zdc.energyCommonZPA(), zdc.energyCommonZPC(), + zdc.timeZNA(), zdc.timeZNC(), zdc.timeZPA(), zdc.timeZPC()); + } else { + eventRapidityGapFilter(filter, fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.ampFDDA, fitInfo.ampFDDC, fitInfo.ampFV0A, + -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0); + } eventFilter(filter); } @@ -282,6 +324,7 @@ struct DQFilterPbPbTask { } PROCESS_SWITCH(DQFilterPbPbTask, processFilterPbPb, "Run filter task", true); + PROCESS_SWITCH(DQFilterPbPbTask, processUDSGSelector, "Run filter task with SG selector from UD", false); PROCESS_SWITCH(DQFilterPbPbTask, processDummy, "Dummy function", false); }; diff --git a/PWGDQ/Tasks/mchAlignRecord.cxx b/PWGDQ/Tasks/mchAlignRecord.cxx index 6dfe8259564..2f612493b6e 100644 --- a/PWGDQ/Tasks/mchAlignRecord.cxx +++ b/PWGDQ/Tasks/mchAlignRecord.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -111,6 +112,25 @@ struct mchAlignRecordTask { Configurable fDoNewGeo{"do-realign", false, "Transform to a given new geometry"}; Configurable fDoEvaluation{"do-evaluation", false, "Enable storage of residuals"}; Configurable fConfigNewGeoFile{"new-geo", "o2sim_geometry-aligned.root", "New geometry for transformation"}; + Configurable fAllowedVarX{"variation-x", 2.0, "Allowed variation for x axis in cm"}; + Configurable fAllowedVarY{"variation-y", 0.3, "Allowed variation for y axis in cm"}; + Configurable fAllowedVarPhi{"variation-phi", 0.002, "Allowed variation for phi axis in rad"}; + Configurable fAllowedVarZ{"variation-z", 2.0, "Allowed variation for z axis in cm"}; + Configurable cfgSigmaX{"cfgSigmaX", 1000., "Sigma cut along X"}; + Configurable cfgSigmaY{"cfgSigmaY", 1000., "Sigma cut along Y"}; + Configurable cfgChamberResolutionX{"cfgChamberResolutionX", 0.4, "Chamber resolution along X configuration for refit"}; // 0.4cm pp, 0.2cm PbPb + Configurable cfgChamberResolutionY{"cfgChamberResolutionY", 0.4, "Chamber resolution along Y configuration for refit"}; // 0.4cm pp, 0.2cm PbPb + Configurable cfgSigmaCutImprove{"cfgSigmaCutImprove", 6., "Sigma cut for track improvement"}; + struct : ConfigurableGroup { + Configurable> cfgDetElem{"cfgDetElem", + {}, + "List of DetElem to be fixed"}; + Configurable> cfgParMask{"cfgParMask", + {}, + "List of param mask for d.o.f to be fixed"}; + } fFixDetElem; + + Preslice perMuon = aod::fwdtrkcl::fwdtrackId; void init(InitContext& ic) { @@ -122,27 +142,41 @@ struct mchAlignRecordTask { // Configuration for alignment object mAlign.SetDoEvaluation(fDoEvaluation.value); - mAlign.SetAllowedVariation(0, 2.0); - mAlign.SetAllowedVariation(1, 0.3); - mAlign.SetAllowedVariation(2, 0.002); - mAlign.SetAllowedVariation(3, 2.0); + mAlign.SetAllowedVariation(0, fAllowedVarX.value); + mAlign.SetAllowedVariation(1, fAllowedVarY.value); + mAlign.SetAllowedVariation(2, fAllowedVarPhi.value); + mAlign.SetAllowedVariation(3, fAllowedVarZ.value); + mAlign.SetSigmaXY(cfgSigmaX.value, cfgSigmaY.value); // Configuration for track fitter const auto& trackerParam = o2::mch::TrackerParam::Instance(); trackFitter.setBendingVertexDispersion(trackerParam.bendingVertexDispersion); - trackFitter.setChamberResolution(trackerParam.chamberResolutionX, trackerParam.chamberResolutionY); + trackFitter.setChamberResolution(cfgChamberResolutionX.value, cfgChamberResolutionY.value); trackFitter.smoothTracks(true); trackFitter.useChamberResolution(); - mImproveCutChi2 = 2. * trackerParam.sigmaCutForImprovement * trackerParam.sigmaCutForImprovement; + mImproveCutChi2 = 2. * cfgSigmaCutImprove.value * cfgSigmaCutImprove.value; // Configuration for chamber fixing - auto chambers = fFixChamber.value; - for (std::size_t i = 0; i < chambers.length(); ++i) { - if (chambers[i] == ',') - continue; - int chamber = chambers[i] - '0'; - LOG(info) << Form("%s%d", "Fixing chamber: ", chamber); - mAlign.FixChamber(chamber); + TString chambersString = fFixChamber.value; + std::unique_ptr objArray(chambersString.Tokenize(",")); + if (objArray->GetEntries() > 0) { + for (int iVar = 0; iVar < objArray->GetEntries(); ++iVar) { + LOG(info) << Form("%s%d", "Fixing chamber: ", std::stoi(objArray->At(iVar)->GetName())); + mAlign.FixChamber(std::stoi(objArray->At(iVar)->GetName())); + } + } + + // Configuration for DE fixing with given axes + auto DEs = fFixDetElem.cfgDetElem.value; + auto Masks = fFixDetElem.cfgParMask.value; + if (DEs.size() > 0) { + if (DEs.size() != Masks.size()) { + LOG(fatal) << "Inconsistent size of mask list."; + } + for (int i = 0; i < static_cast(DEs.size()); i++) { + LOG(info) << Form("%s%d%s%d", "Fixing DE: ", DEs.at(i), " with mask: ", Masks.at(i)); + mAlign.FixDetElem(DEs.at(i), Masks.at(i)); + } } // Init for output saving @@ -304,13 +338,9 @@ struct mchAlignRecordTask { continue; } + auto clustersSliced = clusters.sliceBy(perMuon, track.globalIndex()); // Slice clusters by muon id // Loop over attached clusters - for (auto const& cluster : clusters) { - - if (cluster.template fwdtrack_as() != track) { - continue; - } - + for (auto const& cluster : clustersSliced) { clIndex += 1; mch::Cluster* mch_cluster = new mch::Cluster(); diff --git a/PWGDQ/Tasks/tableReader.cxx b/PWGDQ/Tasks/tableReader.cxx index 600ac3ec440..ece46047109 100644 --- a/PWGDQ/Tasks/tableReader.cxx +++ b/PWGDQ/Tasks/tableReader.cxx @@ -91,6 +91,7 @@ DECLARE_SOA_TABLE(BmesonCandidates, "AOD", "DQBMESONS", dqanalysisflags::massBca // Declarations of various short names using MyEvents = soa::Join; +using MyEventsMultExtra = soa::Join; using MyEventsSelected = soa::Join; using MyEventsHashSelected = soa::Join; using MyEventsVtxCov = soa::Join; @@ -106,8 +107,9 @@ using MyEventsQvectorCentr = soa::Join; using MyEventsQvectorExtra = soa::Join; using MyEventsHashSelectedQvector = soa::Join; -using MyEventsHashSelectedQvectorExtra = soa::Join; +using MyEventsHashSelectedQvectorExtra = soa::Join; using MyEventsHashSelectedQvectorCentr = soa::Join; +using MyEventsVtxCovQvectorMultExtraWithRefFlow = soa::Join; using MyBarrelTracks = soa::Join; using MyBarrelTracksWithCov = soa::Join; @@ -133,6 +135,7 @@ constexpr static uint32_t gkEventFillMapWithQvectorCentr = VarManager::ObjTypes: constexpr static uint32_t gkEventFillMapWithQvectorCentrMultExtra = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::CollisionQvect | VarManager::ObjTypes::ReducedEventMultExtra; constexpr static uint32_t gkEventFillMapWithCovQvector = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov | VarManager::ObjTypes::ReducedEventQvector; constexpr static uint32_t gkEventFillMapWithCovQvectorExtraWithRefFlow = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov | VarManager::ObjTypes::ReducedEventQvector | VarManager::ObjTypes::ReducedEventQvectorExtra | VarManager::ObjTypes::ReducedEventRefFlow; +constexpr static uint32_t gkEventFillMapWithCovQvectorMultExtraWithRefFlow = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov | VarManager::ObjTypes::ReducedEventQvector | VarManager::ObjTypes::ReducedEventQvectorExtra | VarManager::ObjTypes::ReducedEventRefFlow | VarManager::ObjTypes::ReducedEventMultExtra; constexpr static uint32_t gkEventFillMapWithCovQvectorCentr = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov | VarManager::ObjTypes::CollisionQvect; constexpr static uint32_t gkTrackFillMap = VarManager::ObjTypes::ReducedTrack | VarManager::ObjTypes::ReducedTrackBarrel | VarManager::ObjTypes::ReducedTrackBarrelPID; constexpr static uint32_t gkTrackFillMapWithCov = VarManager::ObjTypes::ReducedTrack | VarManager::ObjTypes::ReducedTrackBarrel | VarManager::ObjTypes::ReducedTrackBarrelCov | VarManager::ObjTypes::ReducedTrackBarrelPID; @@ -215,11 +218,12 @@ struct AnalysisEventSelection { void runEventSelection(TEvent const& event) { if (event.runNumber() != fLastRun) { - auto alppar = fCCDB->getForTimeStamp>("ITS/Config/AlpideParam", event.timestamp()); - EventSelectionParams* par = fCCDB->getForTimeStamp("EventSelection/EventSelectionParams", event.timestamp()); - int itsROFrameStartBorderMargin = fConfigITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : fConfigITSROFrameStartBorderMargin; - int itsROFrameEndBorderMargin = fConfigITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : fConfigITSROFrameEndBorderMargin; - VarManager::SetITSROFBorderselection(alppar->roFrameBiasInBC, alppar->roFrameLengthInBC, itsROFrameStartBorderMargin, itsROFrameEndBorderMargin); + // Part temporary removed to study the issue to run on derived data on hyperloop + // auto alppar = fCCDB->getForTimeStamp>("ITS/Config/AlpideParam", event.timestamp()); + // EventSelectionParams* par = fCCDB->getForTimeStamp("EventSelection/EventSelectionParams", event.timestamp()); + // int itsROFrameStartBorderMargin = fConfigITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : fConfigITSROFrameStartBorderMargin; + // int itsROFrameEndBorderMargin = fConfigITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : fConfigITSROFrameEndBorderMargin; + // VarManager::SetITSROFBorderselection(alppar->roFrameBiasInBC, alppar->roFrameLengthInBC, itsROFrameStartBorderMargin, itsROFrameEndBorderMargin); fLastRun = event.runNumber(); } @@ -262,6 +266,10 @@ struct AnalysisEventSelection { { runEventSelection(event); } + void processSkimmedWithMultPV(MyEventsMultExtra::iterator const& event) + { + runEventSelection(event); + } void processSkimmedQVector(MyEventsQvector::iterator const& event) { runEventSelection(event); @@ -282,17 +290,23 @@ struct AnalysisEventSelection { { runEventSelection(event); } + void processSkimmedQVectorMultExtraRef(MyEventsVtxCovQvectorMultExtraWithRefFlow::iterator const& event) + { + runEventSelection(event); + } void processDummy(MyEvents&) { // do nothing } PROCESS_SWITCH(AnalysisEventSelection, processSkimmed, "Run event selection on DQ skimmed events", false); + PROCESS_SWITCH(AnalysisEventSelection, processSkimmedWithMultPV, "Run event selection on DQ skimmed events with mult", false); PROCESS_SWITCH(AnalysisEventSelection, processSkimmedQVector, "Run event selection on DQ skimmed events with Q vector from GFW", false); PROCESS_SWITCH(AnalysisEventSelection, processSkimmedQVectorCentr, "Run event selection on DQ skimmed events with Q vector from CFW", false); PROCESS_SWITCH(AnalysisEventSelection, processSkimmedQVectorMultExtra, "Run event selection on DQ skimmed events with Q vector from GFW and MultPV", false); PROCESS_SWITCH(AnalysisEventSelection, processSkimmedQVectorCentrMultExtra, "Run event selection on DQ skimmed events with Q vector from CFW and MultPV", false); PROCESS_SWITCH(AnalysisEventSelection, processSkimmedQVectorExtraRef, "Run event selection on DQ skimmed events with Q vector and subscribing to reference flow table", false); + PROCESS_SWITCH(AnalysisEventSelection, processSkimmedQVectorMultExtraRef, "Run event selection on DQ skimmed events with Q vector and subscribing to reference flow table with MultPV", false); PROCESS_SWITCH(AnalysisEventSelection, processDummy, "Dummy function", false); // TODO: Add process functions subscribing to Framework Collision }; @@ -313,8 +327,6 @@ struct AnalysisTrackSelection { Configurable fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; Configurable fConfigComputeTPCpostCalib{"cfgTPCpostCalib", false, "If true, compute TPC post-calibrated n-sigmas"}; Configurable fConfigRunPeriods{"cfgRunPeriods", "LHC22f", "run periods for used data"}; - Configurable fConfigDummyRunlist{"cfgDummyRunlist", false, "If true, use dummy runlist"}; - Configurable fConfigInitRunNumber{"cfgInitRunNumber", 543215, "Initial run number used in run by run checks"}; Service fCCDB; @@ -357,9 +369,6 @@ struct AnalysisTrackSelection { VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } - if (fConfigDummyRunlist) { - VarManager::SetDummyRunlist(fConfigInitRunNumber); - } if (fConfigComputeTPCpostCalib) { // CCDB configuration fCCDB->setURL(fConfigCcdbUrl.value); @@ -451,6 +460,8 @@ struct AnalysisMuonSelection { HistogramManager* fHistMan; std::vector fMuonCuts; + Filter filterEventSelected = aod::dqanalysisflags::isEventSelected == 1; + void init(o2::framework::InitContext& context) { if (context.mOptions.get("processDummy")) { @@ -494,6 +505,26 @@ struct AnalysisMuonSelection { uint32_t filterMap = 0; int iCut = 0; + // First loop to get muon multiplicity for single muon cumulants + if constexpr (static_cast(TEventFillMap & VarManager::ObjTypes::ReducedEventQvector)) { + int multMuon = 0; + for (auto& muon : muons) { + filterMap = 0; + VarManager::FillTrack(muon); + + iCut = 0; + for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++, iCut++) { + if ((*cut).IsSelected(VarManager::fgValues)) { + filterMap |= (static_cast(1) << iCut); + } + } + if (static_cast(filterMap) > 0) { + multMuon++; + } + } + VarManager::fgValues[VarManager::kMultSingleMuons] = multMuon; + } + for (auto& muon : muons) { filterMap = 0; VarManager::FillTrack(muon); @@ -518,12 +549,18 @@ struct AnalysisMuonSelection { { runMuonSelection(event, muons); } + void processVnSingleMuonCumulantSkimmed(soa::Filtered::iterator const& event, MyMuonTracks const& muons) + { + VarManager::FillEvent(event, VarManager::fgValues); + runMuonSelection(event, muons); + } void processDummy(MyEvents&) { // do nothing } PROCESS_SWITCH(AnalysisMuonSelection, processSkimmed, "Run muon selection on DQ skimmed muons", false); + PROCESS_SWITCH(AnalysisMuonSelection, processVnSingleMuonCumulantSkimmed, "Run muon selection for single muon cumulant correlators", false); PROCESS_SWITCH(AnalysisMuonSelection, processDummy, "Dummy function", false); }; @@ -645,13 +682,19 @@ struct AnalysisEventMixing { Configurable fConfigAmbiguousHist{"cfgAmbiHist", false, "Enable Ambiguous histograms for time association studies"}; Configurable ccdbPathFlow{"ccdb-path-flow", "Users/c/chizh/FlowResolution", "path to the ccdb object for flow resolution factors"}; Configurable fConfigFlowReso{"cfgFlowReso", false, "Enable loading of flow resolution factors from CCDB"}; + Configurable fConfigSingleMuCumulants{"cfgSingleMuCumulants", false, "Enable loading of flow resolution factors from CCDB"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Service ccdb; o2::parameters::GRPMagField* grpmag = nullptr; - TH1D* ResoFlowSP = nullptr; // Resolution factors for flow analysis, this will be loaded from CCDB - TH1D* ResoFlowEP = nullptr; // Resolution factors for flow analysis, this will be loaded from CCDB - int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. + TH1D* ResoFlowSP = nullptr; // Resolution factors for flow analysis, this will be loaded from CCDB + TH1D* ResoFlowEP = nullptr; // Resolution factors for flow analysis, this will be loaded from CCDB + TH2D* SingleMuv22m = nullptr; // Single muon v22, loaded from CCDB + TH2D* SingleMuv24m = nullptr; // Single muon v24, loaded from CCDB + TH2D* SingleMuv22p = nullptr; // Single antimuon v22, loaded from CCDB + TH2D* SingleMuv24p = nullptr; // Single antimuon v24, loaded from CCDB + int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. Filter filterEventSelected = aod::dqanalysisflags::isEventSelected == 1; Filter filterTrackSelected = aod::dqanalysisflags::isBarrelSelected > 0; @@ -701,7 +744,7 @@ struct AnalysisEventMixing { } } } - if (context.mOptions.get("processMuonSkimmed") || context.mOptions.get("processMuonVnSkimmed") || context.mOptions.get("processMuonVnCentrSkimmed")) { + if (context.mOptions.get("processMuonSkimmed") || context.mOptions.get("processMuonVnSkimmed") || context.mOptions.get("processMuonVnCentrSkimmed") || context.mOptions.get("processMuonVnExtraSkimmed")) { TString cutNames = fConfigMuonCuts.value; if (!cutNames.IsNull()) { std::unique_ptr objArray(cutNames.Tokenize(",")); @@ -742,7 +785,9 @@ struct AnalysisEventMixing { } DefineHistograms(fHistMan, histNames.Data(), fConfigAddEventMixingHistogram); // define all histograms - VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill + // Additional histograms via JSON + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); + VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -762,6 +807,20 @@ struct AnalysisEventMixing { } uint32_t twoTrackFilter = 0; + uint32_t mult_dimuons = 0; + for (auto& track1 : tracks1) { + for (auto& track2 : tracks2) { + if constexpr (TPairType == VarManager::kDecayToMuMu) { + twoTrackFilter = static_cast(track1.isMuonSelected()) & static_cast(track2.isMuonSelected()) & fTwoMuonFilterMask; + } + if (twoTrackFilter && track1.sign() * track2.sign() < 0) { + mult_dimuons++; + } + } // end for (track2) + } // end for (track1) + VarManager::fgValues[VarManager::kMultDimuonsME] = mult_dimuons; + + twoTrackFilter = 0; for (auto& track1 : tracks1) { for (auto& track2 : tracks2) { if constexpr (TPairType == VarManager::kDecayToEE) { @@ -769,6 +828,9 @@ struct AnalysisEventMixing { } if constexpr (TPairType == VarManager::kDecayToMuMu) { twoTrackFilter = static_cast(track1.isMuonSelected()) & static_cast(track2.isMuonSelected()) & fTwoMuonFilterMask; + if (fConfigSingleMuCumulants) { + VarManager::FillTwoMixEventsCumulants(SingleMuv22m, SingleMuv24m, SingleMuv22p, SingleMuv24p, track1, track2); + } } if constexpr (TPairType == VarManager::kElectronMuon) { twoTrackFilter = static_cast(track1.isBarrelSelected()) & static_cast(track2.isMuonSelected()) & fTwoTrackFilterMask; @@ -826,6 +888,20 @@ struct AnalysisEventMixing { LOGF(fatal, "Resolution factor is not available in CCDB at timestamp=%llu", events.begin().timestamp()); } } + if (fConfigSingleMuCumulants) { + TString PathFlow = ccdbPathFlow.value; + TString ccdbPathMuv22m = Form("%s/SingleMuv22m", PathFlow.Data()); + TString ccdbPathMuv24m = Form("%s/SingleMuv24m", PathFlow.Data()); + TString ccdbPathMuv22p = Form("%s/SingleMuv22p", PathFlow.Data()); + TString ccdbPathMuv24p = Form("%s/SingleMuv24p", PathFlow.Data()); + SingleMuv22m = ccdb->getForTimeStamp(ccdbPathMuv22m.Data(), events.begin().timestamp()); + SingleMuv24m = ccdb->getForTimeStamp(ccdbPathMuv24m.Data(), events.begin().timestamp()); + SingleMuv22p = ccdb->getForTimeStamp(ccdbPathMuv22p.Data(), events.begin().timestamp()); + SingleMuv24p = ccdb->getForTimeStamp(ccdbPathMuv24p.Data(), events.begin().timestamp()); + if (SingleMuv22m == nullptr || SingleMuv24m == nullptr || SingleMuv22p == nullptr || SingleMuv24p == nullptr) { + LOGF(fatal, "Single muon cumulants are not available in CCDB at timestamp=%llu", events.begin().timestamp()); + } + } fCurrentRun = events.begin().runNumber(); } @@ -843,7 +919,7 @@ struct AnalysisEventMixing { VarManager::FillTwoMixEvents(event1, event2, tracks1, tracks2); if (fConfigFlowReso) { - VarManager::FillEventFlowResoFactor(ResoFlowSP, ResoFlowEP); + VarManager::FillTwoMixEventsFlowResoFactor(ResoFlowSP, ResoFlowEP); } runMixedPairing(tracks1, tracks2); } // end event loop @@ -906,6 +982,10 @@ struct AnalysisEventMixing { { runSameSide(events, muons, perEventsSelectedM); } + void processMuonVnExtraSkimmed(soa::Filtered& events, soa::Filtered const& muons) + { + runSameSide(events, muons, perEventsSelectedM); + } // TODO: This is a dummy process function for the case when the user does not want to run any of the process functions (no event mixing) // If there is no process function enabled, the workflow hangs void processDummy(MyEvents&) @@ -919,6 +999,7 @@ struct AnalysisEventMixing { PROCESS_SWITCH(AnalysisEventMixing, processBarrelVnSkimmed, "Run barrel-barrel vn mixing on skimmed tracks", false); PROCESS_SWITCH(AnalysisEventMixing, processMuonVnSkimmed, "Run muon-muon vn mixing on skimmed tracks", false); PROCESS_SWITCH(AnalysisEventMixing, processMuonVnCentrSkimmed, "Run muon-muon vn mixing on skimmed tracks from central framework", false); + PROCESS_SWITCH(AnalysisEventMixing, processMuonVnExtraSkimmed, "Run muon-muon vn mixing on skimmed tracks from GFW", false); PROCESS_SWITCH(AnalysisEventMixing, processDummy, "Dummy function", false); }; @@ -967,6 +1048,8 @@ struct AnalysisSameEventPairing { Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable fCollisionSystem{"syst", "pp", "Collision system, pp or PbPb"}; Configurable fCenterMassEnergy{"energy", 13600, "Center of mass energy in GeV"}; + Configurable fConfigCumulants{"cfgCumulants", false, "If true, fill Cumulants with Weights different than 0"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; // Configurables to create output tree (flat tables or minitree) struct : ConfigurableGroup { @@ -1144,8 +1227,9 @@ struct AnalysisSameEventPairing { VarManager::SetCollisionSystem((TString)fCollisionSystem, fCenterMassEnergy); // set collision system and center of mass energy - DefineHistograms(fHistMan, histNames.Data(), fConfigAddSEPHistogram); // define all histograms - VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill + DefineHistograms(fHistMan, histNames.Data(), fConfigAddSEPHistogram); // define all histograms + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON + VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -1153,6 +1237,10 @@ struct AnalysisSameEventPairing { template void runSameEventPairing(TEvent const& event, TTracks1 const& tracks1, TTracks2 const& tracks2) { + if (fConfigCumulants && VarManager::fgValues[VarManager::kM11REF] == 0) { + + return; + } if (fCurrentRun != event.runNumber()) { if (fUseRemoteField) { grpmag = ccdb->getForTimeStamp(grpmagPath, event.timestamp()); @@ -1228,6 +1316,20 @@ struct AnalysisSameEventPairing { if (fConfigMultDimuons.value) { uint32_t mult_dimuons = 0; + uint32_t mult_antimuons = 0; + uint32_t mult_muons = 0; + + for (auto& t : tracks1) { + if constexpr (TPairType == VarManager::kDecayToMuMu) { + if (static_cast(t.isMuonSelected()) & fTwoMuonFilterMask) { + if (t.sign() < 0) { + mult_muons++; + } else { + mult_antimuons++; + } + } + } + } for (auto& [t1, t2] : combinations(tracks1, tracks2)) { if constexpr (TPairType == VarManager::kDecayToMuMu) { @@ -1240,6 +1342,8 @@ struct AnalysisSameEventPairing { } VarManager::fgValues[VarManager::kMultDimuons] = mult_dimuons; + VarManager::fgValues[VarManager::kMultMuons] = mult_muons; + VarManager::fgValues[VarManager::kMultAntiMuons] = mult_antimuons; } if (fConfigFlowReso) { @@ -1369,13 +1473,19 @@ struct AnalysisSameEventPairing { fHistMan->FillHistClass(Form("%s_unambiguous", histNames[iCut][0].Data()), VarManager::fgValues); } if (useMiniTree.fConfigMiniTree) { + // By default (kPt1, kEta1, kPhi1) are for the positive charge float dileptonMass = VarManager::fgValues[VarManager::kMass]; if (dileptonMass > useMiniTree.fConfigMiniTreeMinMass && dileptonMass < useMiniTree.fConfigMiniTreeMaxMass) { - dileptonMiniTree(VarManager::fgValues[VarManager::kMass], - VarManager::fgValues[VarManager::kPt], - VarManager::fgValues[VarManager::kRap], - VarManager::fgValues[VarManager::kCentFT0C], - VarManager::fgValues[VarManager::kCos2DeltaPhi]); + // In the miniTree the positive daughter is positioned as first + if (t1.sign() > 0) { + dileptonMiniTree(VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kRap], + VarManager::fgValues[VarManager::kCentFT0C], VarManager::fgValues[VarManager::kCos2DeltaPhi], + t1.pt(), t1.eta(), t1.phi(), t2.pt(), t2.eta(), t2.phi()); + } else { + dileptonMiniTree(VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kRap], + VarManager::fgValues[VarManager::kCentFT0C], VarManager::fgValues[VarManager::kCos2DeltaPhi], + t2.pt(), t2.eta(), t2.phi(), t1.pt(), t1.eta(), t1.phi()); + } } } } else { @@ -1429,6 +1539,13 @@ struct AnalysisSameEventPairing { VarManager::FillEvent(event, VarManager::fgValues); runSameEventPairing(event, tracks, tracks); } + void processDecayToEESkimmedWithMult(soa::Filtered::iterator const& event, soa::Filtered const& tracks) + { + // Reset the fValues array + VarManager::ResetValues(0, VarManager::kNVars); + VarManager::FillEvent(event, VarManager::fgValues); + runSameEventPairing(event, tracks, tracks); + } void processDecayToEESkimmedNoTwoProngFitter(soa::Filtered::iterator const& event, soa::Filtered const& tracks) { // Reset the fValues array @@ -1580,6 +1697,7 @@ struct AnalysisSameEventPairing { } PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToEESkimmed, "Run electron-electron pairing, with skimmed tracks", false); + PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToEESkimmedWithMult, "Run electron-electron pairing, with skimmed tracks and multiplicity", false); PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToEESkimmedNoTwoProngFitter, "Run electron-electron pairing, with skimmed tracks but no two prong fitter", false); PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToEESkimmedWithCov, "Run electron-electron pairing, with skimmed covariant tracks", false); PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToEESkimmedWithCovNoTwoProngFitter, "Run electron-electron pairing, with skimmed covariant tracks but no two prong fitter", false); @@ -1841,6 +1959,8 @@ struct AnalysisDileptonTrackTrack { Configurable fConfigQuadrupletCuts{"cfgQuadrupletCuts", "pairX3872Cut1", "Comma separated list of Dilepton-Track-Track cut"}; Configurable fConfigAddDileptonHistogram{"cfgAddDileptonHistogram", "barrel", "Comma separated list of histograms"}; Configurable fConfigAddQuadrupletHistogram{"cfgAddQuadrupletHistogram", "xtojpsipipi", "Comma separated list of histograms"}; + Configurable fConfigUseKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"}; + Configurable fConfigUseDCAVertexing{"cfgUseDCAVertexing", false, "Use DCA for secondary vertex reconstruction (DCAFitter is used by default)"}; Produces DileptonTrackTrackTable; @@ -1851,7 +1971,6 @@ struct AnalysisDileptonTrackTrack { constexpr static uint32_t fgDileptonFillMap = VarManager::ObjTypes::ReducedTrack | VarManager::ObjTypes::Pair; // fill map // use some values array to avoid mixing up the quantities - float* fValuesDitrack; float* fValuesQuadruplet; HistogramManager* fHistMan; @@ -1892,7 +2011,7 @@ struct AnalysisDileptonTrackTrack { } if (!context.mOptions.get("processDummy")) { - DefineHistograms(fHistMan, Form("Dileptons_%s", configDileptonCutNamesStr.Data()), fConfigAddDileptonHistogram); + DefineHistograms(fHistMan, Form("Pairs_%s", configDileptonCutNamesStr.Data()), fConfigAddDileptonHistogram); if (!configQuadruletCutNamesStr.IsNull()) { for (std::size_t icut = 0; icut < fQuadrupletCutNames.size(); ++icut) { if (fIsSameTrackCut) { @@ -1919,6 +2038,25 @@ struct AnalysisDileptonTrackTrack { // LOGF(info, "Number of dileptons: %d", dileptons.size()); + // set up KF or DCAfitter + if (fConfigUseDCAVertexing) { + VarManager::SetupTwoProngDCAFitter(5.0f, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + // VarManager::SetupThreeProngDCAFitter(5.0f, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + VarManager::SetupFourProngDCAFitter(5.0f, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + } else if (fConfigUseKFVertexing) { + VarManager::SetupFourProngKFParticle(5.0f); + } + + int indexOffset = -999; + std::vector trackGlobalIndexes; + + if (dileptons.size() > 0) { + for (auto track : tracks) { + trackGlobalIndexes.push_back(track.globalIndex()); + // std::cout << track.index() << " " << track.globalIndex() << std::endl; + } + } + // loop over dileptons for (auto dilepton : dileptons) { VarManager::FillTrack(dilepton, fValuesQuadruplet); @@ -1927,12 +2065,20 @@ struct AnalysisDileptonTrackTrack { if (!fDileptonCut.IsSelected(fValuesQuadruplet)) continue; - fHistMan->FillHistClass(Form("Dileptons_%s", fDileptonCut.GetName()), fValuesQuadruplet); + fHistMan->FillHistClass(Form("Pairs_%s", fDileptonCut.GetName()), fValuesQuadruplet); // get the index of the electron legs int indexLepton1 = dilepton.index0Id(); int indexLepton2 = dilepton.index1Id(); + if (indexOffset == -999) { + indexOffset = trackGlobalIndexes.at(0); + } + trackGlobalIndexes.clear(); + + auto lepton1 = tracks.iteratorAt(indexLepton1 - indexOffset); + auto lepton2 = tracks.iteratorAt(indexLepton2 - indexOffset); + // loop over hadrons pairs for (auto& [t1, t2] : combinations(tracks, tracks)) { // avoid self-combinations @@ -1952,6 +2098,10 @@ struct AnalysisDileptonTrackTrack { // fill variables VarManager::FillDileptonTrackTrack(dilepton, t1, t2, fValuesQuadruplet); + // reconstruct the secondary vertex + if (fConfigUseDCAVertexing || fConfigUseKFVertexing) { + VarManager::FillDileptonTrackTrackVertexing(event, lepton1, lepton2, t1, t2, fValuesQuadruplet); + } int iCut = 0; uint32_t CutDecision = 0; @@ -1982,24 +2132,35 @@ struct AnalysisDileptonTrackTrack { if (!CutDecision) continue; DileptonTrackTrackTable(fValuesQuadruplet[VarManager::kQuadMass], fValuesQuadruplet[VarManager::kQuadPt], fValuesQuadruplet[VarManager::kQuadEta], fValuesQuadruplet[VarManager::kQuadPhi], fValuesQuadruplet[VarManager::kRap], - fValuesQuadruplet[VarManager::kQ], fValuesQuadruplet[VarManager::kDeltaR1], fValuesQuadruplet[VarManager::kDeltaR2], + fValuesQuadruplet[VarManager::kQ], fValuesQuadruplet[VarManager::kDeltaR1], fValuesQuadruplet[VarManager::kDeltaR2], fValuesQuadruplet[VarManager::kDeltaR], dilepton.mass(), dilepton.pt(), dilepton.eta(), dilepton.phi(), dilepton.sign(), - fValuesQuadruplet[VarManager::kDitrackMass], fValuesQuadruplet[VarManager::kDitrackPt], t1.pt(), t2.pt(), t1.eta(), t2.eta(), t1.phi(), t2.phi(), t1.sign(), t2.sign()); + lepton1.tpcNSigmaEl(), lepton1.tpcNSigmaPi(), lepton1.tpcNSigmaPr(), lepton1.tpcNClsFound(), + lepton2.tpcNSigmaEl(), lepton2.tpcNSigmaPi(), lepton2.tpcNSigmaPr(), lepton2.tpcNClsFound(), + fValuesQuadruplet[VarManager::kDitrackMass], fValuesQuadruplet[VarManager::kDitrackPt], t1.pt(), t2.pt(), t1.eta(), t2.eta(), t1.phi(), t2.phi(), t1.sign(), t2.sign(), t1.tpcNSigmaPi(), t2.tpcNSigmaPi(), t1.tpcNSigmaKa(), t2.tpcNSigmaKa(), t1.tpcNSigmaPr(), t1.tpcNSigmaPr(), t1.tpcNClsFound(), t2.tpcNClsFound(), + fValuesQuadruplet[VarManager::kKFMass], fValuesQuadruplet[VarManager::kVertexingProcCode], fValuesQuadruplet[VarManager::kVertexingChi2PCA], fValuesQuadruplet[VarManager::kCosPointingAngle], fValuesQuadruplet[VarManager::kKFDCAxyzBetweenProngs], fValuesQuadruplet[VarManager::kKFChi2OverNDFGeo], + fValuesQuadruplet[VarManager::kVertexingLz], fValuesQuadruplet[VarManager::kVertexingLxy], fValuesQuadruplet[VarManager::kVertexingLxyz], fValuesQuadruplet[VarManager::kVertexingTauz], fValuesQuadruplet[VarManager::kVertexingTauxy], fValuesQuadruplet[VarManager::kVertexingLzErr], fValuesQuadruplet[VarManager::kVertexingLxyzErr], + fValuesQuadruplet[VarManager::kVertexingTauzErr], fValuesQuadruplet[VarManager::kVertexingLzProjected], fValuesQuadruplet[VarManager::kVertexingLxyProjected], fValuesQuadruplet[VarManager::kVertexingLxyzProjected], fValuesQuadruplet[VarManager::kVertexingTauzProjected], fValuesQuadruplet[VarManager::kVertexingTauxyProjected]); } // end loop over track-track pairs } // end loop over dileptons } - void processJpsiPiPi(soa::Filtered::iterator const& event, MyBarrelTracksSelectedWithCov const& tracks, soa::Filtered const& dileptons) + void processChicToJpsiPiPi(soa::Filtered::iterator const& event, MyBarrelTracksSelectedWithCov const& tracks, soa::Filtered const& dileptons) { runDileptonTrackTrack(event, tracks, dileptons); } + void processPsi2SToJpsiPiPi(soa::Filtered::iterator const& event, MyBarrelTracksSelectedWithCov const& tracks, soa::Filtered const& dileptons) + { + runDileptonTrackTrack(event, tracks, dileptons); + } + void processDummy(MyEvents&) { // do nothing } - PROCESS_SWITCH(AnalysisDileptonTrackTrack, processJpsiPiPi, "Run dilepton-dihadron pairing to study X(3872), using skimmed data", false); + PROCESS_SWITCH(AnalysisDileptonTrackTrack, processChicToJpsiPiPi, "Run dilepton-dihadron pairing to study X(3872), using skimmed data", false); + PROCESS_SWITCH(AnalysisDileptonTrackTrack, processPsi2SToJpsiPiPi, "Run dilepton-dihadron pairing to study Psi(2S), using skimmed data", false); PROCESS_SWITCH(AnalysisDileptonTrackTrack, processDummy, "Dummy function", false); }; diff --git a/PWGDQ/Tasks/tableReader_withAssoc.cxx b/PWGDQ/Tasks/tableReader_withAssoc.cxx index ff630d2f12a..162ff8f86f8 100644 --- a/PWGDQ/Tasks/tableReader_withAssoc.cxx +++ b/PWGDQ/Tasks/tableReader_withAssoc.cxx @@ -19,15 +19,18 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include #include #include +#include #include "CCDB/BasicCCDBManager.h" #include "DataFormatsParameters/GRPObject.h" #include "Framework/AnalysisHelpers.h" @@ -80,8 +83,10 @@ DECLARE_SOA_COLUMN(MuonAmbiguityOutOfBunch, muonAmbiguityOutOfBunch, int8_t); DECLARE_SOA_BITMAP_COLUMN(IsBarrelSelectedPrefilter, isBarrelSelectedPrefilter, 32); //! Barrel prefilter decisions (joinable to ReducedTracksAssoc) // Bcandidate columns for ML analysis of B->Jpsi+K DECLARE_SOA_COLUMN(massBcandidate, MBcandidate, float); +DECLARE_SOA_COLUMN(MassDileptonCandidate, massDileptonCandidate, float); DECLARE_SOA_COLUMN(deltamassBcandidate, deltaMBcandidate, float); DECLARE_SOA_COLUMN(pTBcandidate, PtBcandidate, float); +DECLARE_SOA_COLUMN(EtaBcandidate, etaBcandidate, float); DECLARE_SOA_COLUMN(LxyBcandidate, lxyBcandidate, float); DECLARE_SOA_COLUMN(LxyzBcandidate, lxyzBcandidate, float); DECLARE_SOA_COLUMN(LzBcandidate, lzBcandidate, float); @@ -89,6 +94,55 @@ DECLARE_SOA_COLUMN(TauxyBcandidate, tauxyBcandidate, float); DECLARE_SOA_COLUMN(TauzBcandidate, tauzBcandidate, float); DECLARE_SOA_COLUMN(CosPBcandidate, cosPBcandidate, float); DECLARE_SOA_COLUMN(Chi2Bcandidate, chi2Bcandidate, float); +DECLARE_SOA_COLUMN(Ptassoc, ptassoc, float); +DECLARE_SOA_COLUMN(PINassoc, pINassoc, float); +DECLARE_SOA_COLUMN(Etaassoc, etaassoc, float); +DECLARE_SOA_COLUMN(Ptpair, ptpair, float); +DECLARE_SOA_COLUMN(Etapair, etapair, float); +DECLARE_SOA_COLUMN(PINleg1, pINleg1, float); +DECLARE_SOA_COLUMN(Etaleg1, etaleg1, float); +DECLARE_SOA_COLUMN(PINleg2, pINleg2, float); +DECLARE_SOA_COLUMN(Etaleg2, etaleg2, float); +DECLARE_SOA_COLUMN(TPCnsigmaKaassoc, tpcnsigmaKaassoc, float); +DECLARE_SOA_COLUMN(TPCnsigmaPiassoc, tpcnsigmaPiassoc, float); +DECLARE_SOA_COLUMN(TPCnsigmaPrassoc, tpcnsigmaPrassoc, float); +DECLARE_SOA_COLUMN(TOFnsigmaKaassoc, tofnsigmaKaassoc, float); +DECLARE_SOA_COLUMN(TPCnsigmaElleg1, tpcnsigmaElleg1, float); +DECLARE_SOA_COLUMN(TPCnsigmaPileg1, tpcnsigmaPileg1, float); +DECLARE_SOA_COLUMN(TPCnsigmaPrleg1, tpcnsigmaPrleg1, float); +DECLARE_SOA_COLUMN(TPCnsigmaElleg2, tpcnsigmaElleg2, float); +DECLARE_SOA_COLUMN(TPCnsigmaPileg2, tpcnsigmaPileg2, float); +DECLARE_SOA_COLUMN(TPCnsigmaPrleg2, tpcnsigmaPrleg2, float); +DECLARE_SOA_COLUMN(DCAXYassoc, dcaXYassoc, float); +DECLARE_SOA_COLUMN(DCAZassoc, dcaZassoc, float); +DECLARE_SOA_COLUMN(DCAXYleg1, dcaXYleg1, float); +DECLARE_SOA_COLUMN(DCAZleg1, dcaZleg1, float); +DECLARE_SOA_COLUMN(DCAXYleg2, dcaXYleg2, float); +DECLARE_SOA_COLUMN(DCAZleg2, dcaZleg2, float); +DECLARE_SOA_COLUMN(ITSClusterMapassoc, itsClusterMapassoc, uint8_t); +DECLARE_SOA_COLUMN(ITSClusterMapleg1, itsClusterMapleg1, uint8_t); +DECLARE_SOA_COLUMN(ITSClusterMapleg2, itsClusterMapleg2, uint8_t); +DECLARE_SOA_COLUMN(ITSChi2assoc, itsChi2assoc, float); +DECLARE_SOA_COLUMN(ITSChi2leg1, itsChi2leg1, float); +DECLARE_SOA_COLUMN(ITSChi2leg2, itsChi2leg2, float); +DECLARE_SOA_COLUMN(TPCNclsassoc, tpcNclsassoc, float); +DECLARE_SOA_COLUMN(TPCNclsleg1, tpcNclsleg1, float); +DECLARE_SOA_COLUMN(TPCNclsleg2, tpcNclsleg2, float); +DECLARE_SOA_COLUMN(TPCChi2assoc, tpcChi2assoc, float); +DECLARE_SOA_COLUMN(TPCChi2leg1, tpcChi2leg1, float); +DECLARE_SOA_COLUMN(TPCChi2leg2, tpcChi2leg2, float); +DECLARE_SOA_BITMAP_COLUMN(IsJpsiFromBSelected, isJpsiFromBSelected, 32); +// Candidate columns for prompt-non-prompt JPsi separation +DECLARE_SOA_COLUMN(Massee, massJPsi2ee, float); +DECLARE_SOA_COLUMN(Ptee, ptJPsi2ee, float); +DECLARE_SOA_COLUMN(Lxyee, lxyJPsi2ee, float); +DECLARE_SOA_COLUMN(LxyeePoleMass, lxyJPsi2eePoleMass, float); +DECLARE_SOA_COLUMN(Lzee, lzJPsi2ee, float); +DECLARE_SOA_COLUMN(AmbiguousInBunchPairs, AmbiguousJpsiPairsInBunch, bool); +DECLARE_SOA_COLUMN(AmbiguousOutOfBunchPairs, AmbiguousJpsiPairsOutOfBunch, bool); +// Candidate columns for JPsi/muon correlations +DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); +DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); } // namespace dqanalysisflags DECLARE_SOA_TABLE(EventCuts, "AOD", "DQANAEVCUTSA", dqanalysisflags::IsEventSelected); //! joinable to ReducedEvents @@ -98,22 +152,45 @@ DECLARE_SOA_TABLE(BarrelAmbiguities, "AOD", "DQBARRELAMBA", dqanalysisflags::Bar DECLARE_SOA_TABLE(MuonTrackCuts, "AOD", "DQANAMUONCUTSA", dqanalysisflags::IsMuonSelected); //! joinable to ReducedMuonsAssoc DECLARE_SOA_TABLE(MuonAmbiguities, "AOD", "DQMUONAMBA", dqanalysisflags::MuonAmbiguityInBunch, dqanalysisflags::MuonAmbiguityOutOfBunch); //! joinable to ReducedMuonTracks DECLARE_SOA_TABLE(Prefilter, "AOD", "DQPREFILTERA", dqanalysisflags::IsBarrelSelectedPrefilter); //! joinable to ReducedTracksAssoc -DECLARE_SOA_TABLE(BmesonCandidates, "AOD", "DQBMESONSA", dqanalysisflags::massBcandidate, dqanalysisflags::deltamassBcandidate, dqanalysisflags::pTBcandidate, dqanalysisflags::LxyBcandidate, dqanalysisflags::LxyzBcandidate, dqanalysisflags::LzBcandidate, dqanalysisflags::TauxyBcandidate, dqanalysisflags::TauzBcandidate, dqanalysisflags::CosPBcandidate, dqanalysisflags::Chi2Bcandidate); +DECLARE_SOA_TABLE(BmesonCandidates, "AOD", "DQBMESONSA", + dqanalysisflags::massBcandidate, dqanalysisflags::MassDileptonCandidate, dqanalysisflags::deltamassBcandidate, dqanalysisflags::pTBcandidate, dqanalysisflags::EtaBcandidate, + dqanalysisflags::LxyBcandidate, dqanalysisflags::LxyzBcandidate, dqanalysisflags::LzBcandidate, + dqanalysisflags::TauxyBcandidate, dqanalysisflags::TauzBcandidate, dqanalysisflags::CosPBcandidate, dqanalysisflags::Chi2Bcandidate, + dqanalysisflags::PINassoc, dqanalysisflags::Etaassoc, dqanalysisflags::Ptpair, dqanalysisflags::Etapair, + dqanalysisflags::PINleg1, dqanalysisflags::Etaleg1, dqanalysisflags::PINleg2, dqanalysisflags::Etaleg2, + dqanalysisflags::TPCnsigmaKaassoc, dqanalysisflags::TPCnsigmaPiassoc, dqanalysisflags::TPCnsigmaPrassoc, dqanalysisflags::TOFnsigmaKaassoc, + dqanalysisflags::TPCnsigmaElleg1, dqanalysisflags::TPCnsigmaPileg1, dqanalysisflags::TPCnsigmaPrleg1, + dqanalysisflags::TPCnsigmaElleg2, dqanalysisflags::TPCnsigmaPileg2, dqanalysisflags::TPCnsigmaPrleg2, + dqanalysisflags::DCAXYassoc, dqanalysisflags::DCAZassoc, dqanalysisflags::DCAXYleg1, dqanalysisflags::DCAZleg1, dqanalysisflags::DCAXYleg2, dqanalysisflags::DCAZleg2, + dqanalysisflags::ITSClusterMapassoc, dqanalysisflags::ITSClusterMapleg1, dqanalysisflags::ITSClusterMapleg2, + dqanalysisflags::ITSChi2assoc, dqanalysisflags::ITSChi2leg1, dqanalysisflags::ITSChi2leg2, + dqanalysisflags::TPCNclsassoc, dqanalysisflags::TPCNclsleg1, dqanalysisflags::TPCNclsleg2, + dqanalysisflags::TPCChi2assoc, dqanalysisflags::TPCChi2leg1, dqanalysisflags::TPCChi2leg2, + dqanalysisflags::IsJpsiFromBSelected, dqanalysisflags::IsBarrelSelected); +DECLARE_SOA_TABLE(JPsiMuonCandidates, "AOD", "DQJPSIMUONA", + dqanalysisflags::DeltaEta, dqanalysisflags::DeltaPhi, + dqanalysisflags::MassDileptonCandidate, dqanalysisflags::Ptpair, dqanalysisflags::Etapair, dqanalysisflags::Ptassoc, dqanalysisflags::Etaassoc); +DECLARE_SOA_TABLE(JPsieeCandidates, "AOD", "DQPSEUDOPROPER", dqanalysisflags::Massee, dqanalysisflags::Ptee, dqanalysisflags::Lxyee, dqanalysisflags::LxyeePoleMass, dqanalysisflags::Lzee, dqanalysisflags::AmbiguousInBunchPairs, dqanalysisflags::AmbiguousOutOfBunchPairs); } // namespace o2::aod // Declarations of various short names using MyEvents = soa::Join; using MyEventsMultExtra = soa::Join; using MyEventsZdc = soa::Join; +using MyEventsMultExtraZdc = soa::Join; using MyEventsSelected = soa::Join; using MyEventsMultExtraSelected = soa::Join; +using MyEventsVtxCovSelectedMultExtra = soa::Join; using MyEventsHashSelected = soa::Join; using MyEventsVtxCov = soa::Join; using MyEventsVtxCovSelected = soa::Join; using MyEventsVtxCovSelectedQvector = soa::Join; using MyEventsVtxCovZdcSelected = soa::Join; +using MyEventsVtxCovZdcSelectedMultExtra = soa::Join; using MyEventsQvector = soa::Join; using MyEventsHashSelectedQvector = soa::Join; +using MyEventsQvectorCentr = soa::Join; +using MyEventsQvectorCentrSelected = soa::Join; using MyBarrelTracks = soa::Join; using MyBarrelTracksWithAmbiguities = soa::Join; @@ -130,10 +207,13 @@ using MyMuonTracksSelectedWithColl = soa::Join eventSel; Produces hash; OutputObj fOutputList{"output"}; @@ -168,7 +249,9 @@ struct AnalysisEventSelection { // TODO: Provide the mixing variables and binning directly via configurables (e.g. vectors of float) Configurable fConfigMixingVariables{"cfgMixingVars", "", "Mixing configs separated by a comma, default no mixing"}; Configurable fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"}; + Configurable fConfigEventCutsJSON{"cfgEventCutsJSON", "", "Additional event cuts specified in JSON format"}; Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Add event histograms defined via JSON formatting (see HistogramsLibrary)"}; Configurable fConfigQA{"cfgQA", true, "If true, QA histograms will be created and filled"}; Configurable fConfigITSROFrameStartBorderMargin{"cfgITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"}; @@ -195,16 +278,42 @@ struct AnalysisEventSelection { void init(o2::framework::InitContext& context) { - if (context.mOptions.get("processDummy")) { + LOG(info) << "Starting initialization of AnalysisEventSelection (idstoreh)"; + + bool isAnyProcessEnabled = context.mOptions.get("processSkimmed") || context.mOptions.get("processSkimmedWithZdc") || context.mOptions.get("processSkimmedWithMultExtra") || context.mOptions.get("processSkimmedWithMultExtraZdc") || context.mOptions.get("processSkimmedWithQvectorCentr"); + bool isDummyEnabled = context.mOptions.get("processDummy"); + + if (isDummyEnabled) { + if (isAnyProcessEnabled) { + LOG(fatal) << "You have enabled both the dummy process and at least one normal process function! Check your config!"; + } + return; + } + if (!isAnyProcessEnabled) { return; } + VarManager::SetDefaultVarNames(); + fEventCut = new AnalysisCompositeCut(true); TString eventCutStr = fConfigEventCuts.value; - fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); + if (eventCutStr != "") { + AnalysisCut* cut = dqcuts::GetAnalysisCut(eventCutStr.Data()); + if (cut != nullptr) { + fEventCut->AddCut(cut); + } + } + // Additional cuts via JSON + TString eventCutJSONStr = fConfigEventCutsJSON.value; + if (eventCutJSONStr != "") { + std::vector jsonCuts = dqcuts::GetCutsFromJSON(eventCutJSONStr.Data()); + for (auto& cutIt : jsonCuts) { + fEventCut->AddCut(cutIt); + } + } + VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill - VarManager::SetDefaultVarNames(); if (fConfigQA) { fHistMan = new HistogramManager("analysisHistos", "", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(kTRUE); @@ -213,6 +322,8 @@ struct AnalysisEventSelection { if (fConfigCheckSplitCollisions) { DefineHistograms(fHistMan, "SameBunchCorrelations;OutOfBunchCorrelations;", ""); } + // Additional histograms via JSON + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); VarManager::SetUseVars(fHistMan->GetUsedVars()); fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -233,6 +344,7 @@ struct AnalysisEventSelection { fCCDB->setLocalObjectValidityChecking(); fCCDB->setCreatedNotAfter(fConfigNoLaterThan.value); fCCDBApi.init(fConfigCcdbUrl.value); + LOG(info) << "Initialization of AnalysisEventSelection finished (idstoreh)"; } template @@ -400,6 +512,16 @@ struct AnalysisEventSelection { runEventSelection(events); publishSelections(events); } + void processSkimmedWithMultExtraZdc(MyEventsMultExtraZdc const& events) + { + runEventSelection(events); + publishSelections(events); + } + void processSkimmedWithQvectorCentr(MyEventsQvectorCentr const& events) + { + runEventSelection(events); + publishSelections(events); + } void processDummy(MyEvents&) { // do nothing @@ -408,6 +530,8 @@ struct AnalysisEventSelection { PROCESS_SWITCH(AnalysisEventSelection, processSkimmed, "Run event selection on DQ skimmed events", false); PROCESS_SWITCH(AnalysisEventSelection, processSkimmedWithZdc, "Run event selection on DQ skimmed events, with ZDC", false); PROCESS_SWITCH(AnalysisEventSelection, processSkimmedWithMultExtra, "Run event selection on DQ skimmed events, with mult extra", false); + PROCESS_SWITCH(AnalysisEventSelection, processSkimmedWithMultExtraZdc, "Run event selection on DQ skimmed events, with mult extra and ZDC", false); + PROCESS_SWITCH(AnalysisEventSelection, processSkimmedWithQvectorCentr, "Run event selection on DQ skimmed events, with Q-vector", false); PROCESS_SWITCH(AnalysisEventSelection, processDummy, "Dummy function", false); }; @@ -419,7 +543,9 @@ struct AnalysisTrackSelection { OutputObj fOutputList{"output"}; Configurable fConfigCuts{"cfgTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; + Configurable fConfigCutsJSON{"cfgBarrelTrackCutsJSON", "", "Additional list of barrel track cuts in JSON format"}; Configurable fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; Configurable fConfigPublishAmbiguity{"cfgPublishAmbiguity", true, "If true, publish ambiguity table and fill QA histograms"}; @@ -429,8 +555,6 @@ struct AnalysisTrackSelection { Configurable fConfigComputeTPCpostCalib{"cfgTPCpostCalib", false, "If true, compute TPC post-calibrated n-sigmas"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable fConfigDummyRunlist{"cfgDummyRunlist", false, "If true, use dummy runlist"}; - Configurable fConfigInitRunNumber{"cfgInitRunNumber", 543215, "Initial run number used in run by run checks"}; // Track related options Configurable fPropTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; @@ -438,7 +562,7 @@ struct AnalysisTrackSelection { o2::ccdb::CcdbApi fCCDBApi; HistogramManager* fHistMan; - std::vector fTrackCuts; + std::vector fTrackCuts; int fCurrentRun; // current run kept to detect run changes and trigger loading params from CCDB @@ -447,23 +571,32 @@ struct AnalysisTrackSelection { void init(o2::framework::InitContext& context) { + LOG(info) << "Starting initialization of AnalysisTrackSelection (idstoreh)"; if (context.mOptions.get("processDummy")) { return; } + VarManager::SetDefaultVarNames(); fCurrentRun = 0; TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fTrackCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fTrackCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + } + } + // Extra cuts via JSON + TString addTrackCutsStr = fConfigCutsJSON.value; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + fTrackCuts.push_back(reinterpret_cast(t)); } } VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill if (fConfigQA) { - VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); @@ -471,25 +604,24 @@ struct AnalysisTrackSelection { // set one histogram directory for each defined track cut TString histDirNames = "TrackBarrel_BeforeCuts;"; for (auto& cut : fTrackCuts) { - histDirNames += Form("TrackBarrel_%s;", cut.GetName()); + histDirNames += Form("TrackBarrel_%s;", cut->GetName()); } if (fConfigPublishAmbiguity) { histDirNames += "TrackBarrel_AmbiguityInBunch;TrackBarrel_AmbiguityOutOfBunch;"; } DefineHistograms(fHistMan, histDirNames.Data(), fConfigAddTrackHistogram.value.data()); // define all histograms + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } - if (fConfigDummyRunlist) { - VarManager::SetDummyRunlist(fConfigInitRunNumber); - } fCCDB->setURL(fConfigCcdbUrl.value); fCCDB->setCaching(true); fCCDB->setLocalObjectValidityChecking(); fCCDB->setCreatedNotAfter(fConfigNoLaterThan.value); fCCDBApi.init(fConfigCcdbUrl.value); + LOG(info) << "Initialization of AnalysisTrackSelection finished (idstoreh)"; } template @@ -554,10 +686,10 @@ struct AnalysisTrackSelection { } iCut = 0; for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++, iCut++) { - if ((*cut).IsSelected(VarManager::fgValues)) { + if ((*cut)->IsSelected(VarManager::fgValues)) { filterMap |= (static_cast(1) << iCut); if (fConfigQA) { - fHistMan->FillHistClass(Form("TrackBarrel_%s", (*cut).GetName()), VarManager::fgValues); + fHistMan->FillHistClass(Form("TrackBarrel_%s", (*cut)->GetName()), VarManager::fgValues); } } } // end loop over cuts @@ -663,8 +795,10 @@ struct AnalysisMuonSelection { OutputObj fOutputList{"output"}; Configurable fConfigCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; + Configurable fConfigCutsJSON{"cfgMuonCutsJSON", "", "Additional list of muon cuts in JSON format"}; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; Configurable fConfigAddMuonHistogram{"cfgAddMuonHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Configurable fConfigPublishAmbiguity{"cfgPublishAmbiguity", true, "If true, publish ambiguity table and fill QA histograms"}; Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -675,7 +809,7 @@ struct AnalysisMuonSelection { Service fCCDB; HistogramManager* fHistMan; - std::vector fMuonCuts; + std::vector fMuonCuts; int fCurrentRun; // current run kept to detect run changes and trigger loading params from CCDB @@ -684,22 +818,32 @@ struct AnalysisMuonSelection { void init(o2::framework::InitContext& context) { + LOG(info) << "Starting initialization of AnalysisMuonSelection (idstoreh)"; if (context.mOptions.get("processDummy")) { return; } + VarManager::SetDefaultVarNames(); fCurrentRun = 0; TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fMuonCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fMuonCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + } + } + // extra cuts from JSON + TString addCutsStr = fConfigCutsJSON.value; + if (addCutsStr != "") { + std::vector addCuts = dqcuts::GetCutsFromJSON(addCutsStr.Data()); + for (auto& t : addCuts) { + fMuonCuts.push_back(reinterpret_cast(t)); } } + VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill if (fConfigQA) { - VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); @@ -707,13 +851,14 @@ struct AnalysisMuonSelection { // set one histogram directory for each defined track cut TString histDirNames = "TrackMuon_BeforeCuts;"; for (auto& cut : fMuonCuts) { - histDirNames += Form("TrackMuon_%s;", cut.GetName()); + histDirNames += Form("TrackMuon_%s;", cut->GetName()); } if (fConfigPublishAmbiguity) { histDirNames += "TrackMuon_AmbiguityInBunch;TrackMuon_AmbiguityOutOfBunch;"; } DefineHistograms(fHistMan, histDirNames.Data(), fConfigAddMuonHistogram.value.data()); // define all histograms + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -725,6 +870,7 @@ struct AnalysisMuonSelection { if (!o2::base::GeometryManager::isGeometryLoaded()) { fCCDB->get(fConfigGeoPath); } + LOG(info) << "Initialization of AnalysisMuonSelection finished (idstoreh)"; } template @@ -767,10 +913,10 @@ struct AnalysisMuonSelection { } iCut = 0; for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++, iCut++) { - if ((*cut).IsSelected(VarManager::fgValues)) { + if ((*cut)->IsSelected(VarManager::fgValues)) { filterMap |= (static_cast(1) << iCut); if (fConfigQA) { - fHistMan->FillHistClass(Form("TrackMuon_%s", (*cut).GetName()), VarManager::fgValues); + fHistMan->FillHistClass(Form("TrackMuon_%s", (*cut)->GetName()), VarManager::fgValues); } } } // end loop over cuts @@ -864,6 +1010,8 @@ struct AnalysisPrefilterSelection { Configurable fConfigPrefilterPairCut{"cfgPrefilterPairCut", "", "Prefilter pair cut"}; Configurable fConfigTrackCuts{"cfgTrackCuts", "", "Track cuts for which to run the prefilter"}; + // TODO: Add prefilter pair cut via JSON + std::map fPrefilterMap; AnalysisCompositeCut* fPairCut; uint32_t fPrefilterMask; @@ -873,9 +1021,11 @@ struct AnalysisPrefilterSelection { void init(o2::framework::InitContext& context) { + LOG(info) << "Starting initialization of AnalysisPrefilterSelection (idstoreh)"; if (context.mOptions.get("processDummy")) { return; } + VarManager::SetDefaultVarNames(); bool runPrefilter = true; // get the list of track cuts to be prefiltered @@ -905,6 +1055,15 @@ struct AnalysisPrefilterSelection { string trackCuts; getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", trackCuts, false); TString allTrackCutsStr = trackCuts; + // check also the cuts added via JSON and add them to the string of cuts + getTaskOptionValue(context, "analysis-track-selection", "cfgBarrelTrackCutsJSON", trackCuts, false); + TString addTrackCutsStr = trackCuts; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + allTrackCutsStr += Form(",%s", t->GetName()); + } + } std::unique_ptr objArray(allTrackCutsStr.Tokenize(",")); if (objArray == nullptr) { @@ -933,11 +1092,10 @@ struct AnalysisPrefilterSelection { LOG(warn) << "No specified loose cut or track cuts for prefiltering. This task will do nothing."; } - VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill - VarManager::SetDefaultVarNames(); - + VarManager::SetUseVars(AnalysisCut::fgUsedVars); // provide the list of required variables so that VarManager knows what to fill VarManager::SetupTwoProngDCAFitter(5.0f, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, true); // TODO: get these parameters from Configurables // VarManager::SetupTwoProngFwdDCAFitter(5.0f, true, 200.0f, 1.0e-3f, 0.9f, true); + LOG(info) << "Initialization of AnalysisPrefilterSelection finished (idstoreh)"; } template @@ -1040,6 +1198,8 @@ struct AnalysisSameEventPairing { Produces dimuonAllList; Produces dileptonFlowList; Produces dileptonInfoList; + Produces PromptNonPromptSepTable; + Produces dileptonPolarList; o2::base::MatLayerCylSet* fLUT = nullptr; int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. @@ -1050,11 +1210,14 @@ struct AnalysisSameEventPairing { Configurable track{"cfgTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; Configurable muon{"cfgMuonCuts", "", "Comma separated list of muon cuts"}; Configurable pair{"cfgPairCuts", "", "Comma separated list of pair cuts"}; + Configurable event{"cfgRemoveCollSplittingCandidates", false, "If true, remove collision splitting candidates as determined by the event selection task upstream"}; + // TODO: Add pair cuts via JSON } fConfigCuts; Configurable fConfigMixingDepth{"cfgMixingDepth", 100, "Number of Events stored for event mixing"}; // Configurable fConfigAddEventMixingHistogram{"cfgAddEventMixingHistogram", "", "Comma separated list of histograms"}; Configurable fConfigAddSEPHistogram{"cfgAddSEPHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Configurable fConfigQA{"cfgQA", true, "If true, fill output histograms"}; struct : ConfigurableGroup { @@ -1062,12 +1225,14 @@ struct AnalysisSameEventPairing { Configurable grpMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable GrpLhcIfPath{"grplhcif", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"}; } fConfigCCDB; struct : ConfigurableGroup { Configurable useRemoteField{"cfgUseRemoteField", false, "Chose whether to fetch the magnetic field from ccdb or set it manually"}; Configurable magField{"cfgMagField", 5.0f, "Manually set magnetic field"}; Configurable flatTables{"cfgFlatTables", false, "Produce a single flat tables with all relevant information of the pairs and single tracks"}; + Configurable polarTables{"cfgPolarTables", false, "Produce tables with dilepton polarization information"}; Configurable useKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"}; Configurable useAbsDCA{"cfgUseAbsDCA", false, "Use absolute DCA minimization instead of chi^2 minimization in secondary vertexing"}; Configurable propToPCA{"cfgPropToPCA", false, "Propagate tracks to secondary vertex"}; @@ -1076,12 +1241,13 @@ struct AnalysisSameEventPairing { Configurable collisionSystem{"syst", "pp", "Collision system, pp or PbPb"}; Configurable centerMassEnergy{"energy", 13600, "Center of mass energy in GeV"}; Configurable propTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; + Configurable useRemoteCollisionInfo{"cfgUseRemoteCollisionInfo", false, "Use remote collision information from CCDB"}; } fConfigOptions; Service fCCDB; o2::ccdb::CcdbApi fCCDBApi; - Filter filterEventSelected = aod::dqanalysisflags::isEventSelected > static_cast(1); + Filter filterEventSelected = aod::dqanalysisflags::isEventSelected > static_cast(0); HistogramManager* fHistMan; @@ -1090,6 +1256,8 @@ struct AnalysisSameEventPairing { std::map> fMuonHistNames; std::map> fTrackMuonHistNames; std::vector fPairCuts; + std::vector fTrackCuts; + std::map, uint32_t> fAmbiguousPairs; uint32_t fTrackFilterMask; // mask for the track cuts required in this task to be applied on the barrel cuts produced upstream uint32_t fMuonFilterMask; // mask for the muon cuts required in this task to be applied on the muon cuts produced upstream @@ -1109,19 +1277,26 @@ struct AnalysisSameEventPairing { void init(o2::framework::InitContext& context) { + LOG(info) << "Starting initialization of AnalysisSameEventPairing (idstoreh)"; + fEnableBarrelHistos = context.mOptions.get("processAllSkimmed") || context.mOptions.get("processBarrelOnlySkimmed") || context.mOptions.get("processBarrelOnlyWithCollSkimmed") || context.mOptions.get("processBarrelOnlySkimmedNoCov") || context.mOptions.get("processBarrelOnlySkimmedNoCovWithMultExtra") || context.mOptions.get("processBarrelOnlyWithQvectorCentrSkimmedNoCov"); + fEnableBarrelMixingHistos = context.mOptions.get("processMixingAllSkimmed") || context.mOptions.get("processMixingBarrelSkimmed"); + fEnableMuonHistos = context.mOptions.get("processAllSkimmed") || context.mOptions.get("processMuonOnlySkimmed") || context.mOptions.get("processMuonOnlySkimmedMultExtra") || context.mOptions.get("processMixingMuonSkimmed"); + fEnableMuonMixingHistos = context.mOptions.get("processMixingAllSkimmed") || context.mOptions.get("processMixingMuonSkimmed"); + if (context.mOptions.get("processDummy")) { + if (fEnableBarrelHistos || fEnableBarrelMixingHistos || fEnableMuonHistos || fEnableMuonMixingHistos) { + LOG(fatal) << "No other processing tasks should be enabled if the processDummy is enabled!!"; + } return; } - - fEnableBarrelHistos = context.mOptions.get("processAllSkimmed") || context.mOptions.get("processBarrelOnlySkimmed") || context.mOptions.get("processBarrelOnlyWithCollSkimmed") || context.mOptions.get("processBarrelOnlySkimmedNoCov"); - fEnableBarrelMixingHistos = context.mOptions.get("processMixingAllSkimmed") || context.mOptions.get("processMixingBarrelSkimmed"); - fEnableMuonHistos = context.mOptions.get("processAllSkimmed") || context.mOptions.get("processMuonOnlySkimmed"); - fEnableMuonMixingHistos = context.mOptions.get("processMixingAllSkimmed"); + VarManager::SetDefaultVarNames(); // Keep track of all the histogram class names to avoid composing strings in the pairing loop TString histNames = ""; std::vector names; + fTrackCuts.clear(); + // NOTE: Pair cuts are only applied on the histogram output. The produced pair tables do not have these cuts applied TString cutNamesStr = fConfigCuts.pair.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); @@ -1147,11 +1322,21 @@ struct AnalysisSameEventPairing { string tempCuts; getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", tempCuts, false); TString tempCutsStr = tempCuts; + // check also the cuts added via JSON and add them to the string of cuts + getTaskOptionValue(context, "analysis-track-selection", "cfgBarrelTrackCutsJSON", tempCuts, false); + TString addTrackCutsStr = tempCuts; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + tempCutsStr += Form(",%s", t->GetName()); + } + } if (!trackCutsStr.IsNull()) { std::unique_ptr objArray(tempCutsStr.Tokenize(",")); fNCutsBarrel = objArray->GetEntries(); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { TString tempStr = objArray->At(icut)->GetName(); + fTrackCuts.push_back(tempStr); if (objArrayTrackCuts->FindObject(tempStr.Data()) != nullptr) { fTrackFilterMask |= (static_cast(1) << icut); @@ -1161,20 +1346,16 @@ struct AnalysisSameEventPairing { Form("PairsBarrelSEPP_%s", objArray->At(icut)->GetName()), Form("PairsBarrelSEMM_%s", objArray->At(icut)->GetName())}; histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); + names.push_back(Form("PairsBarrelSEPM_ambiguousextra_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsBarrelSEPP_ambiguousextra_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsBarrelSEMM_ambiguousextra_%s", objArray->At(icut)->GetName())); + histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data()); if (fEnableBarrelMixingHistos) { names.push_back(Form("PairsBarrelMEPM_%s", objArray->At(icut)->GetName())); names.push_back(Form("PairsBarrelMEPP_%s", objArray->At(icut)->GetName())); names.push_back(Form("PairsBarrelMEMM_%s", objArray->At(icut)->GetName())); - histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data()); + histNames += Form("%s;%s;%s;", names[6].Data(), names[7].Data(), names[8].Data()); } - names.push_back(Form("PairsBarrelSEPM_ambiguousInBunch_%s", objArray->At(icut)->GetName())); - names.push_back(Form("PairsBarrelSEPP_ambiguousInBunch_%s", objArray->At(icut)->GetName())); - names.push_back(Form("PairsBarrelSEMM_ambiguousInBunch_%s", objArray->At(icut)->GetName())); - names.push_back(Form("PairsBarrelSEPM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); - names.push_back(Form("PairsBarrelSEPP_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); - names.push_back(Form("PairsBarrelSEMM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); - histNames += Form("%s;%s;%s;", names[(fEnableBarrelMixingHistos ? 6 : 3)].Data(), names[(fEnableBarrelMixingHistos ? 7 : 4)].Data(), names[(fEnableBarrelMixingHistos ? 8 : 5)].Data()); - histNames += Form("%s;%s;%s;", names[(fEnableBarrelMixingHistos ? 9 : 6)].Data(), names[(fEnableBarrelMixingHistos ? 10 : 7)].Data(), names[(fEnableBarrelMixingHistos ? 11 : 8)].Data()); fTrackHistNames[icut] = names; TString cutNamesStr = fConfigCuts.pair.value; @@ -1194,9 +1375,21 @@ struct AnalysisSameEventPairing { } } } + LOG(info) << "Initialization of AnalysisSameEventPairing 1 (idstoreh)"; + // get the muon track selection cuts getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCuts", tempCuts, false); tempCutsStr = tempCuts; + // check also the cuts added via JSON and add them to the string of cuts + getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCutsJSON", tempCuts, false); + TString addMuonCutsStr = tempCuts; + if (addMuonCutsStr != "") { + std::vector addMuonCuts = dqcuts::GetCutsFromJSON(addMuonCutsStr.Data()); + for (auto& t : addMuonCuts) { + tempCutsStr += Form(",%s", t->GetName()); + } + } + if (!muonCutsStr.IsNull()) { std::unique_ptr objArray(tempCutsStr.Tokenize(",")); fNCutsMuon = objArray->GetEntries(); @@ -1264,6 +1457,8 @@ struct AnalysisSameEventPairing { } } + LOG(info) << "Initialization of AnalysisSameEventPairing 2 (idstoreh)"; + fCurrentRun = 0; fCCDB->setURL(fConfigCCDB.url.value); @@ -1316,15 +1511,16 @@ struct AnalysisSameEventPairing { }*/ if (fConfigQA) { - VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); fHistMan->SetUseDefaultVariableNames(true); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); VarManager::SetCollisionSystem((TString)fConfigOptions.collisionSystem, fConfigOptions.centerMassEnergy); // set collision system and center of mass energy DefineHistograms(fHistMan, histNames.Data(), fConfigAddSEPHistogram.value.data()); // define all histograms + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } + LOG(info) << "Finished initialization of AnalysisSameEventPairing (idstoreh)"; } void initParamsFromCCDB(uint64_t timestamp, int runNumber, bool withTwoProngFitter = true) @@ -1366,6 +1562,11 @@ struct AnalysisSameEventPairing { uint64_t sor = std::atol(header["SOR"].c_str()); uint64_t eor = std::atol(header["EOR"].c_str()); VarManager::SetSORandEOR(sor, eor); + + if (fConfigOptions.useRemoteCollisionInfo) { + o2::parameters::GRPLHCIFData* grpo = fCCDB->getForTimeStamp(fConfigCCDB.GrpLhcIfPath, timestamp); + VarManager::SetCollisionSystem(grpo); + } } // Template function to run same event pairing (barrel-barrel, muon-muon, barrel-muon) @@ -1416,6 +1617,10 @@ struct AnalysisSameEventPairing { dielectronAllList.reserve(1); dimuonAllList.reserve(1); } + if (fConfigOptions.polarTables.value) { + dileptonPolarList.reserve(1); + } + fAmbiguousPairs.clear(); constexpr bool eventHasQvector = ((TEventFillMap & VarManager::ObjTypes::ReducedEventQvector) > 0); constexpr bool eventHasQvectorCentr = ((TEventFillMap & VarManager::ObjTypes::CollisionQvect) > 0); constexpr bool trackHasCov = ((TTrackFillMap & VarManager::ObjTypes::TrackCov) > 0 || (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelCov) > 0); @@ -1424,10 +1629,14 @@ struct AnalysisSameEventPairing { if (!event.isEventSelected_bit(0)) { continue; } + if (fConfigCuts.event && event.isEventSelected_bit(2)) { + continue; + } uint8_t evSel = event.isEventSelected_raw(); // Reset the fValues array VarManager::ResetValues(0, VarManager::kNVars); - VarManager::FillEvent(event, VarManager::fgValues); + // VarManager::FillEvent(event, VarManager::fgValues); + VarManager::FillEvent(event, VarManager::fgValues); auto groupedAssocs = assocs.sliceBy(preslice, event.globalIndex()); if (groupedAssocs.size() == 0) { @@ -1473,6 +1682,9 @@ struct AnalysisSameEventPairing { if constexpr (eventHasQvector) { VarManager::FillPairVn(t1, t2); } + if constexpr (eventHasQvectorCentr) { + VarManager::FillPairVn(t1, t2); + } dielectronList(event.globalIndex(), VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], @@ -1482,6 +1694,13 @@ struct AnalysisSameEventPairing { dielectronInfoList(t1.collisionId(), t1.trackId(), t2.trackId()); dileptonInfoList(t1.collisionId(), event.posX(), event.posY(), event.posZ()); } + if (fConfigOptions.polarTables.value) { + dileptonPolarList(VarManager::fgValues[VarManager::kCosThetaHE], VarManager::fgValues[VarManager::kPhiHE], VarManager::fgValues[VarManager::kPhiTildeHE], + VarManager::fgValues[VarManager::kCosThetaCS], VarManager::fgValues[VarManager::kPhiCS], VarManager::fgValues[VarManager::kPhiTildeCS], + VarManager::fgValues[VarManager::kCosThetaPP], VarManager::fgValues[VarManager::kPhiPP], VarManager::fgValues[VarManager::kPhiTildePP], + VarManager::fgValues[VarManager::kCosThetaRM], + VarManager::fgValues[VarManager::kCosThetaStarTPC], VarManager::fgValues[VarManager::kCosThetaStarFT0A], VarManager::fgValues[VarManager::kCosThetaStarFT0C]); + } if constexpr (trackHasCov && TTwoProngFitter) { dielectronsExtraList(t1.globalIndex(), t2.globalIndex(), VarManager::fgValues[VarManager::kVertexingTauzProjected], VarManager::fgValues[VarManager::kVertexingLzProjected], VarManager::fgValues[VarManager::kVertexingLxyProjected]); if constexpr ((TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelPID) > 0) { @@ -1538,6 +1757,9 @@ struct AnalysisSameEventPairing { if constexpr (eventHasQvector) { VarManager::FillPairVn(t1, t2); } + if constexpr (eventHasQvectorCentr) { + VarManager::FillPairVn(t1, t2); + } dimuonList(event.globalIndex(), VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], @@ -1569,7 +1791,7 @@ struct AnalysisSameEventPairing { -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., - (twoTrackFilter & (static_cast(1) << 28)) || (twoTrackFilter & (static_cast(1) << 30)), (twoTrackFilter & (static_cast(1) << 29)) || (twoTrackFilter & (static_cast(1) << 31)), + (twoTrackFilter & (static_cast(1) << 28)) || (twoTrackFilter & (static_cast(1) << 29)), (twoTrackFilter & (static_cast(1) << 30)) || (twoTrackFilter & (static_cast(1) << 31)), VarManager::fgValues[VarManager::kU2Q2], VarManager::fgValues[VarManager::kU3Q3], VarManager::fgValues[VarManager::kR2EP_AB], VarManager::fgValues[VarManager::kR2SP_AB], VarManager::fgValues[VarManager::kCentFT0C], VarManager::fgValues[VarManager::kCos2DeltaPhi], VarManager::fgValues[VarManager::kCos3DeltaPhi], @@ -1603,51 +1825,89 @@ struct AnalysisSameEventPairing { bool isAmbiInBunch = false; bool isAmbiOutOfBunch = false; bool isUnambiguous = false; + bool isLeg1Ambi = false; + bool isLeg2Ambi = false; + bool isAmbiExtra = false; for (int icut = 0; icut < ncuts; icut++) { if (twoTrackFilter & (static_cast(1) << icut)) { isAmbiInBunch = (twoTrackFilter & (static_cast(1) << 28)) || (twoTrackFilter & (static_cast(1) << 29)); isAmbiOutOfBunch = (twoTrackFilter & (static_cast(1) << 30)) || (twoTrackFilter & (static_cast(1) << 31)); isUnambiguous = !(isAmbiInBunch || isAmbiOutOfBunch); - if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); - if (isAmbiInBunch) { - fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset].Data(), VarManager::fgValues); - } - if (isAmbiOutOfBunch) { - fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 3].Data(), VarManager::fgValues); + isLeg1Ambi = (twoTrackFilter & (static_cast(1) << 28) || (twoTrackFilter & (static_cast(1) << 30))); + isLeg2Ambi = (twoTrackFilter & (static_cast(1) << 29) || (twoTrackFilter & (static_cast(1) << 31))); + if constexpr (TPairType == VarManager::kDecayToEE) { + if (isLeg1Ambi && isLeg2Ambi) { + std::pair iPair(a1.reducedtrackId(), a2.reducedtrackId()); + if (fAmbiguousPairs.find(iPair) != fAmbiguousPairs.end()) { + if (fAmbiguousPairs[iPair] & (static_cast(1) << icut)) { // if this pair is already stored with this cut + isAmbiExtra = true; + } else { + fAmbiguousPairs[iPair] |= static_cast(1) << icut; + } + } else { + fAmbiguousPairs[iPair] = static_cast(1) << icut; + } } + } + if (sign1 * sign2 < 0) { + PromptNonPromptSepTable(VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kVertexingTauxyProjected], VarManager::fgValues[VarManager::kVertexingTauxyProjectedPoleJPsiMass], VarManager::fgValues[VarManager::kVertexingTauzProjected], isAmbiInBunch, isAmbiOutOfBunch); if constexpr (TPairType == VarManager::kDecayToMuMu) { + fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); + if (isAmbiInBunch) { + fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset].Data(), VarManager::fgValues); + } + if (isAmbiOutOfBunch) { + fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 3].Data(), VarManager::fgValues); + } if (isUnambiguous) { fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 6].Data(), VarManager::fgValues); } } + if constexpr (TPairType == VarManager::kDecayToEE) { + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s", fTrackCuts[icut].Data()), VarManager::fgValues); + if (isAmbiExtra) { + fHistMan->FillHistClass(Form("PairsBarrelSEPM_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues); + } + } } else { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); - if (isAmbiInBunch) { - fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset].Data(), VarManager::fgValues); - } - if (isAmbiOutOfBunch) { - fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset + 3].Data(), VarManager::fgValues); - } if constexpr (TPairType == VarManager::kDecayToMuMu) { + fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); + if (isAmbiInBunch) { + fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset].Data(), VarManager::fgValues); + } + if (isAmbiOutOfBunch) { + fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset + 3].Data(), VarManager::fgValues); + } if (isUnambiguous) { fHistMan->FillHistClass(histNames[icut][4 + histIdxOffset + 6].Data(), VarManager::fgValues); } } - } else { - fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues); - if (isAmbiInBunch) { - fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset].Data(), VarManager::fgValues); - } - if (isAmbiOutOfBunch) { - fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 3].Data(), VarManager::fgValues); + if constexpr (TPairType == VarManager::kDecayToEE) { + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s", fTrackCuts[icut].Data()), VarManager::fgValues); + if (isAmbiExtra) { + fHistMan->FillHistClass(Form("PairsBarrelSEPP_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues); + } } + } else { if constexpr (TPairType == VarManager::kDecayToMuMu) { + fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues); + if (isAmbiInBunch) { + fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset].Data(), VarManager::fgValues); + } + if (isAmbiOutOfBunch) { + fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 3].Data(), VarManager::fgValues); + } if (isUnambiguous) { fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 6].Data(), VarManager::fgValues); } } + if constexpr (TPairType == VarManager::kDecayToEE) { + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s", fTrackCuts[icut].Data()), VarManager::fgValues); + if (isAmbiExtra) { + fHistMan->FillHistClass(Form("PairsBarrelSEMM_ambiguousextra_%s", fTrackCuts[icut].Data()), VarManager::fgValues); + } + } } } for (unsigned int iPairCut = 0; iPairCut < fPairCuts.size(); iPairCut++) { @@ -1724,6 +1984,35 @@ struct AnalysisSameEventPairing { } ncuts = fNCutsMuon; histNames = fMuonHistNames; + + if (fConfigOptions.flatTables.value) { + dimuonAllList(-999., -999., -999., -999., + 0, 0, + -999., -999., -999., + VarManager::fgValues[VarManager::kMass], + false, + VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], t1.sign() + t2.sign(), VarManager::fgValues[VarManager::kVertexingChi2PCA], + VarManager::fgValues[VarManager::kVertexingTauz], VarManager::fgValues[VarManager::kVertexingTauzErr], + VarManager::fgValues[VarManager::kVertexingTauxy], VarManager::fgValues[VarManager::kVertexingTauxyErr], + VarManager::fgValues[VarManager::kCosPointingAngle], + t1.pt(), t1.eta(), t1.phi(), t1.sign(), + t2.pt(), t2.eta(), t2.phi(), t2.sign(), + t1.fwdDcaX(), t1.fwdDcaY(), t2.fwdDcaX(), t2.fwdDcaY(), + 0., 0., + t1.chi2MatchMCHMID(), t2.chi2MatchMCHMID(), + t1.chi2MatchMCHMFT(), t2.chi2MatchMCHMFT(), + t1.chi2(), t2.chi2(), + -999., -999., -999., -999., + -999., -999., -999., -999., + -999., -999., -999., -999., + -999., -999., -999., -999., + (twoTrackFilter & (static_cast(1) << 28)) || (twoTrackFilter & (static_cast(1) << 29)), (twoTrackFilter & (static_cast(1) << 30)) || (twoTrackFilter & (static_cast(1) << 31)), + VarManager::fgValues[VarManager::kU2Q2], VarManager::fgValues[VarManager::kU3Q3], + VarManager::fgValues[VarManager::kR2EP_AB], VarManager::fgValues[VarManager::kR2SP_AB], VarManager::fgValues[VarManager::kCentFT0C], + VarManager::fgValues[VarManager::kCos2DeltaPhi], VarManager::fgValues[VarManager::kCos3DeltaPhi], + VarManager::fgValues[VarManager::kCORR2POI], VarManager::fgValues[VarManager::kCORR4POI], VarManager::fgValues[VarManager::kM01POI], VarManager::fgValues[VarManager::kM0111POI], VarManager::fgValues[VarManager::kMultDimuons], + VarManager::fgValues[VarManager::kVertexingPz], VarManager::fgValues[VarManager::kVertexingSV]); + } } /*if constexpr (TPairType == VarManager::kElectronMuon) { twoTrackFilter = a1.isBarrelSelected_raw() & a1.isBarrelSelectedPrefilter_raw() & a2.isMuonSelected_raw() & fTrackFilterMask; @@ -1740,8 +2029,8 @@ struct AnalysisSameEventPairing { isAmbiOutOfBunch = (twoTrackFilter & (static_cast(1) << 30)) || (twoTrackFilter & (static_cast(1) << 31)); isUnambiguous = !((twoTrackFilter & (static_cast(1) << 28)) || (twoTrackFilter & (static_cast(1) << 29)) || (twoTrackFilter & (static_cast(1) << 30)) || (twoTrackFilter & (static_cast(1) << 31))); if (pairSign == 0) { - fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues); if constexpr (TPairType == VarManager::kDecayToMuMu) { + fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues); if (isAmbiInBunch) { fHistMan->FillHistClass(histNames[icut][15].Data(), VarManager::fgValues); } @@ -1752,10 +2041,13 @@ struct AnalysisSameEventPairing { fHistMan->FillHistClass(histNames[icut][21].Data(), VarManager::fgValues); } } + if constexpr (TPairType == VarManager::kDecayToEE) { + fHistMan->FillHistClass(Form("PairsBarrelMEPM_%s", fTrackCuts[icut].Data()), VarManager::fgValues); + } } else { if (pairSign > 0) { - fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues); if constexpr (TPairType == VarManager::kDecayToMuMu) { + fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues); if (isAmbiInBunch) { fHistMan->FillHistClass(histNames[icut][16].Data(), VarManager::fgValues); } @@ -1766,9 +2058,12 @@ struct AnalysisSameEventPairing { fHistMan->FillHistClass(histNames[icut][22].Data(), VarManager::fgValues); } } + if constexpr (TPairType == VarManager::kDecayToEE) { + fHistMan->FillHistClass(Form("PairsBarrelMEPP_%s", fTrackCuts[icut].Data()), VarManager::fgValues); + } } else { - fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues); if constexpr (TPairType == VarManager::kDecayToMuMu) { + fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues); if (isAmbiInBunch) { fHistMan->FillHistClass(histNames[icut][17].Data(), VarManager::fgValues); } @@ -1779,6 +2074,9 @@ struct AnalysisSameEventPairing { fHistMan->FillHistClass(histNames[icut][23].Data(), VarManager::fgValues); } } + if constexpr (TPairType == VarManager::kDecayToEE) { + fHistMan->FillHistClass(Form("PairsBarrelMEMM_%s", fTrackCuts[icut].Data()), VarManager::fgValues); + } } } } // end for (cuts) @@ -1792,6 +2090,7 @@ struct AnalysisSameEventPairing { { events.bindExternalIndices(&assocs); int mixingDepth = fConfigMixingDepth.value; + fAmbiguousPairs.clear(); for (auto& [event1, event2] : selfCombinations(hashBin, mixingDepth, -1, events, events)) { VarManager::ResetValues(0, VarManager::kNVars); VarManager::FillEvent(event1, VarManager::fgValues); @@ -1829,6 +2128,13 @@ struct AnalysisSameEventPairing { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks); } + void processBarrelOnlySkimmedNoCovWithMultExtra(MyEventsMultExtraSelected const& events, + soa::Join const& barrelAssocs, + MyBarrelTracksWithAmbiguities const& barrelTracks) + { + runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks); + } + void processBarrelOnlyWithCollSkimmed(MyEventsVtxCovSelected const& events, soa::Join const& barrelAssocs, MyBarrelTracksWithCovWithAmbiguitiesWithColl const& barrelTracks) @@ -1836,12 +2142,25 @@ struct AnalysisSameEventPairing { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks); } + void processBarrelOnlyWithQvectorCentrSkimmedNoCov(MyEventsQvectorCentrSelected const& events, + soa::Join const& barrelAssocs, + MyBarrelTracksWithAmbiguities const& barrelTracks) + { + runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks); + } + void processMuonOnlySkimmed(MyEventsVtxCovSelected const& events, soa::Join const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons) { runSameEventPairing(events, muonAssocsPerCollision, muonAssocs, muons); } + void processMuonOnlySkimmedMultExtra(MyEventsVtxCovSelectedMultExtra const& events, + soa::Join const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons) + { + runSameEventPairing(events, muonAssocsPerCollision, muonAssocs, muons); + } + void processMixingAllSkimmed(soa::Filtered& events, soa::Join const& trackAssocs, MyBarrelTracksWithCov const& tracks, soa::Join const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons) @@ -1856,6 +2175,12 @@ struct AnalysisSameEventPairing { runSameSideMixing(events, trackAssocs, tracks, trackAssocsPerCollision); } + void processMixingMuonSkimmed(soa::Filtered& events, + soa::Join const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons) + { + runSameSideMixing(events, muonAssocs, muons, muonAssocsPerCollision); + } + void processDummy(MyEvents&) { // do nothing @@ -1865,9 +2190,13 @@ struct AnalysisSameEventPairing { PROCESS_SWITCH(AnalysisSameEventPairing, processBarrelOnlySkimmed, "Run barrel only pairing, with skimmed tracks", false); PROCESS_SWITCH(AnalysisSameEventPairing, processBarrelOnlyWithCollSkimmed, "Run barrel only pairing, with skimmed tracks and with collision information", false); PROCESS_SWITCH(AnalysisSameEventPairing, processBarrelOnlySkimmedNoCov, "Run barrel only pairing (no covariances), with skimmed tracks and with collision information", false); + PROCESS_SWITCH(AnalysisSameEventPairing, processBarrelOnlySkimmedNoCovWithMultExtra, "Run barrel only pairing (no covariances), with skimmed tracks, with collision information, with MultsExtra", false); + PROCESS_SWITCH(AnalysisSameEventPairing, processBarrelOnlyWithQvectorCentrSkimmedNoCov, "Run barrel only pairing (no covariances), with skimmed tracks, with Qvector from central framework", false); PROCESS_SWITCH(AnalysisSameEventPairing, processMuonOnlySkimmed, "Run muon only pairing, with skimmed tracks", false); + PROCESS_SWITCH(AnalysisSameEventPairing, processMuonOnlySkimmedMultExtra, "Run muon only pairing, with skimmed tracks", false); PROCESS_SWITCH(AnalysisSameEventPairing, processMixingAllSkimmed, "Run all types of mixed pairing, with skimmed tracks/muons", false); PROCESS_SWITCH(AnalysisSameEventPairing, processMixingBarrelSkimmed, "Run barrel type mixing pairing, with skimmed tracks", false); + PROCESS_SWITCH(AnalysisSameEventPairing, processMixingMuonSkimmed, "Run muon type mixing pairing, with skimmed muons", false); PROCESS_SWITCH(AnalysisSameEventPairing, processDummy, "Dummy function, enabled only if none of the others are enabled", false); }; @@ -1890,11 +2219,14 @@ struct AnalysisAsymmetricPairing { Configurable fConfigLegCFilterMask{"cfgLegCFilterMask", 0, "Filter mask corresponding to cuts in track-selection"}; Configurable fConfigCommonTrackCuts{"cfgCommonTrackCuts", "", "Comma separated list of cuts to be applied to all legs"}; Configurable fConfigPairCuts{"cfgPairCuts", "", "Comma separated list of pair cuts"}; + Configurable fConfigPairCutsJSON{"cfgPairCutsJSON", "", "Additional list of pair cuts in JSON format"}; Configurable fConfigSkipAmbiguousIdCombinations{"cfgSkipAmbiguousIdCombinations", true, "Choose whether to skip pairs/triples which pass a stricter combination of cuts, e.g. KKPi triplets for D+ -> KPiPi"}; Configurable fConfigHistogramSubgroups{"cfgAsymmetricPairingHistogramsSubgroups", "barrel,vertexing", "Comma separated list of asymmetric-pairing histogram subgroups"}; Configurable fConfigSameSignHistograms{"cfgSameSignHistograms", false, "Include same sign pair histograms for 2-prong decays"}; Configurable fConfigAmbiguousHistograms{"cfgAmbiguousHistograms", false, "Include separate histograms for pairs/triplets with ambiguous tracks"}; + Configurable fConfigReflectedHistograms{"cfgReflectedHistograms", false, "Include separate histograms for pairs which are reflections of previously counted pairs"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable fConfigGRPMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; @@ -1910,15 +2242,17 @@ struct AnalysisAsymmetricPairing { HistogramManager* fHistMan; - std::map> fTrackHistNames; - std::vector fPairCuts; + std::vector fPairCuts; + int fNPairHistPrefixes; // Filter masks to find legs in BarrelTrackCuts table uint32_t fLegAFilterMask; uint32_t fLegBFilterMask; uint32_t fLegCFilterMask; - // Map tracking which pair of leg cuts the track cuts participate in - std::map fTrackCutFilterMasks; + // Maps tracking which combination of leg cuts the track cuts participate in + std::map fConstructedLegAFilterMasksMap; + std::map fConstructedLegBFilterMasksMap; + std::map fConstructedLegCFilterMasksMap; // Filter map for common track cuts uint32_t fCommonTrackCutMask; // Map tracking which common track cut the track cuts correspond to @@ -1927,6 +2261,10 @@ struct AnalysisAsymmetricPairing { int fNLegCuts; int fNPairCuts; int fNCommonTrackCuts; + // vectors for cut names and signal names, for easy access when calling FillHistogramList() + std::vector fLegCutNames; + std::vector fPairCutNames; + std::vector fCommonCutNames; Preslice> trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId; @@ -1935,14 +2273,20 @@ struct AnalysisAsymmetricPairing { Partition> legBCandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fConfigLegBFilterMask) > static_cast(0); Partition> legCCandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fConfigLegCFilterMask) > static_cast(0); + // Map to track how many times a pair of tracks has been encountered + std::map, int8_t> fPairCount; + void init(o2::framework::InitContext& context) { + LOG(info) << "Initialization of AnalysisAsymmetricPairing started (idstoreh)"; if (context.mOptions.get("processDummy")) { return; } - TString histNames = ""; - std::vector names; + VarManager::SetDefaultVarNames(); + fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); + fHistMan->SetUseDefaultVariableNames(kTRUE); + fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); // Get the leg cut filter maps fLegAFilterMask = fConfigLegAFilterMask.value; @@ -1953,13 +2297,36 @@ struct AnalysisAsymmetricPairing { if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - fPairCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); + fPairCuts.push_back(dqcuts::GetCompositeCut(objArray->At(icut)->GetName())); } } + // Extra pair cuts via JSON + TString addPairCutsStr = fConfigPairCutsJSON.value; + if (addPairCutsStr != "") { + std::vector addPairCuts = dqcuts::GetCutsFromJSON(addPairCutsStr.Data()); + for (auto& t : addPairCuts) { + fPairCuts.push_back(reinterpret_cast(t)); + cutNamesStr += Form(",%s", t->GetName()); + } + } + std::unique_ptr objArrayPairCuts(cutNamesStr.Tokenize(",")); + fNPairCuts = objArrayPairCuts->GetEntries(); + for (int j = 0; j < fNPairCuts; j++) { + fPairCutNames.push_back(objArrayPairCuts->At(j)->GetName()); + } // Get the barrel track selection cuts string tempCuts; getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", tempCuts, false); TString tempCutsStr = tempCuts; + // check also the cuts added via JSON and add them to the string of cuts + getTaskOptionValue(context, "analysis-track-selection", "cfgBarrelTrackCutsJSON", tempCuts, false); + TString addTrackCutsStr = tempCuts; + if (addTrackCutsStr != "") { + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(addTrackCutsStr.Data()); + for (auto& t : addTrackCuts) { + tempCutsStr += Form(",%s", t->GetName()); + } + } std::unique_ptr objArray(tempCutsStr.Tokenize(",")); // Get the common leg cuts int commonCutIdx; @@ -1972,6 +2339,7 @@ struct AnalysisAsymmetricPairing { if (commonCutIdx >= 0) { fCommonTrackCutMask |= static_cast(1) << objArray->IndexOf(objArrayCommon->At(icut)); fCommonTrackCutFilterMasks[icut] = static_cast(1) << objArray->IndexOf(objArrayCommon->At(icut)); + fCommonCutNames.push_back(objArrayCommon->At(icut)->GetName()); } else { LOGF(fatal, "Common track cut %s was not calculated upstream. Check the config!", objArrayCommon->At(icut)->GetName()); } @@ -2018,7 +2386,7 @@ struct AnalysisAsymmetricPairing { legAIdx = objArray->IndexOf(legs->At(0)); if (legAIdx >= 0) { fConstructedLegAFilterMask |= (static_cast(1) << legAIdx); - fTrackCutFilterMasks[icut] |= static_cast(1) << legAIdx; + fConstructedLegAFilterMasksMap[icut] |= static_cast(1) << legAIdx; } else { LOGF(fatal, "Leg A cut %s was not calculated upstream. Check the config!", legs->At(0)->GetName()); continue; @@ -2026,7 +2394,7 @@ struct AnalysisAsymmetricPairing { legBIdx = objArray->IndexOf(legs->At(1)); if (legBIdx >= 0) { fConstructedLegBFilterMask |= (static_cast(1) << legBIdx); - fTrackCutFilterMasks[icut] |= static_cast(1) << legBIdx; + fConstructedLegBFilterMasksMap[icut] |= static_cast(1) << legBIdx; } else { LOGF(fatal, "Leg B cut %s was not calculated upstream. Check the config!", legs->At(1)->GetName()); continue; @@ -2035,100 +2403,82 @@ struct AnalysisAsymmetricPairing { legCIdx = objArray->IndexOf(legs->At(2)); if (legCIdx >= 0) { fConstructedLegCFilterMask |= (static_cast(1) << legCIdx); - fTrackCutFilterMasks[icut] |= static_cast(1) << legCIdx; + fConstructedLegCFilterMasksMap[icut] |= static_cast(1) << legCIdx; } else { LOGF(fatal, "Leg C cut %s was not calculated upstream. Check the config!", legs->At(2)->GetName()); continue; } } + // Leg cut config is fine, store the leg cut name in a vector + fLegCutNames.push_back(legsStr); + if (isThreeProng[icut]) { - names = { - Form("TripletsBarrelSE_%s", legsStr.Data())}; - histNames += Form("%s;", names[0].Data()); + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s", legsStr.Data()), fConfigHistogramSubgroups.value.data()); if (fConfigAmbiguousHistograms.value) { - names.push_back(Form("TripletsBarrelSE_ambiguous_%s", legsStr.Data())); - histNames += Form("%s;", names[1].Data()); + DefineHistograms(fHistMan, Form("TripletsBarrelSE_ambiguous_%s", legsStr.Data()), fConfigHistogramSubgroups.value.data()); } - fTrackHistNames[icut] = names; std::unique_ptr objArrayCommon(commonNamesStr.Tokenize(",")); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; - names.push_back(Form("TripletsBarrelSE_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName())); - histNames += Form("%s;", names[0].Data()); - fTrackHistNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName()), fConfigHistogramSubgroups.value.data()); } - TString cutNamesStr = fConfigPairCuts.value; if (!cutNamesStr.IsNull()) { // if pair cuts std::unique_ptr objArrayPair(cutNamesStr.Tokenize(",")); fNPairCuts = objArrayPair->GetEntries(); for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { // loop over pair cuts - names = {}; - names.push_back(Form("TripletsBarrelSE_%s_%s", legsStr.Data(), objArrayPair->At(iPairCut)->GetName())); - histNames += Form("%s;", names[0].Data()); - fTrackHistNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s", legsStr.Data(), objArrayPair->At(iPairCut)->GetName()), fConfigHistogramSubgroups.value.data()); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; - names.push_back(Form("TripletsBarrelSE_%s_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName())); - histNames += Form("%s;", names[0].Data()); - fTrackHistNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + (icut * fNPairCuts * fNCommonTrackCuts) + (iCommonCut * fNPairCuts) + iPairCut] = names; + DefineHistograms(fHistMan, Form("TripletsBarrelSE_%s_%s_%s", legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName()), fConfigHistogramSubgroups.value.data()); } // end loop (common cuts) } // end loop (pair cuts) } // end if (pair cuts) } else { - names = {}; std::vector pairHistPrefixes = {"PairsBarrelSEPM"}; if (fConfigSameSignHistograms.value) { pairHistPrefixes.push_back("PairsBarrelSEPP"); pairHistPrefixes.push_back("PairsBarrelSEMM"); } - int fNPairHistPrefixes = pairHistPrefixes.size(); + fNPairHistPrefixes = pairHistPrefixes.size(); for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data()), fConfigHistogramSubgroups.value.data()); } if (fConfigAmbiguousHistograms.value) { for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_ambiguous_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data())); - histNames += Form("%s;", names[fNPairHistPrefixes + iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_ambiguous_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data()), fConfigHistogramSubgroups.value.data()); + } + } + if (fConfigReflectedHistograms.value) { + for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { + DefineHistograms(fHistMan, Form("%s_reflected_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data()), fConfigHistogramSubgroups.value.data()); } } - fTrackHistNames[icut] = names; std::unique_ptr objArrayCommon(commonNamesStr.Tokenize(",")); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName()), fConfigHistogramSubgroups.value.data()); } - fTrackHistNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut] = names; } if (!cutNamesStr.IsNull()) { // if pair cuts std::unique_ptr objArrayPair(cutNamesStr.Tokenize(",")); fNPairCuts = objArrayPair->GetEntries(); for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { // loop over pair cuts - names = {}; for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayPair->At(iPairCut)->GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayPair->At(iPairCut)->GetName()), fConfigHistogramSubgroups.value.data()); } - fTrackHistNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = names; for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - names = {}; for (int iPrefix = 0; iPrefix < fNPairHistPrefixes; ++iPrefix) { - names.push_back(Form("%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName())); - histNames += Form("%s;", names[iPrefix].Data()); + DefineHistograms(fHistMan, Form("%s_%s_%s_%s", pairHistPrefixes[iPrefix].Data(), legsStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPair->At(iPairCut)->GetName()), fConfigHistogramSubgroups.value.data()); } - fTrackHistNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + (icut * fNPairCuts * fNCommonTrackCuts) + (iCommonCut * fNPairCuts) + iPairCut] = names; } // end loop (common cuts) } // end loop (pair cuts) } // end if (pair cuts) } } + // Make sure the leg cuts are covered by the configured filter masks if (fLegAFilterMask != fConstructedLegAFilterMask) { LOGF(fatal, "cfgLegAFilterMask (%d) is not equal to the mask constructed by the cuts specified in cfgLegCuts (%d)!", fLegAFilterMask, fConstructedLegAFilterMask); @@ -2154,14 +2504,10 @@ struct AnalysisAsymmetricPairing { fLUT = o2::base::MatLayerCylSet::rectifyPtrFromFile(fCCDB->get(fConfigLutPath)); VarManager::SetupMatLUTFwdDCAFitter(fLUT); - VarManager::SetDefaultVarNames(); - fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); - fHistMan->SetUseDefaultVariableNames(kTRUE); - fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); - - DefineHistograms(fHistMan, histNames.Data(), fConfigHistogramSubgroups.value.data()); // define all histograms - VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON + VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); + LOG(info) << "Initialization of AnalysisAsymmetricPairing finished (idstoreh)"; } void initParamsFromCCDB(uint64_t timestamp, bool isTriplets) @@ -2208,6 +2554,8 @@ struct AnalysisAsymmetricPairing { template void runAsymmetricPairing(TEvents const& events, Preslice& preslice, TTrackAssocs const& /*assocs*/, TTracks const& /*tracks*/) { + fPairCount.clear(); + if (events.size() > 0) { // Additional protection to avoid crashing of events.begin().runNumber() if (fCurrentRun != events.begin().runNumber()) { initParamsFromCCDB(events.begin().timestamp(), false); @@ -2215,8 +2563,6 @@ struct AnalysisAsymmetricPairing { } } - std::map> histNames = fTrackHistNames; - int sign1 = 0; int sign2 = 0; ditrackList.reserve(1); @@ -2246,21 +2592,19 @@ struct AnalysisAsymmetricPairing { uint32_t twoTrackFilter = static_cast(0); uint32_t twoTrackCommonFilter = static_cast(0); uint32_t pairFilter = static_cast(0); - bool isPairIdWrong = false; for (int icut = 0; icut < fNLegCuts; ++icut) { // Find leg pair definitions both candidates participate in - if ((((a1.isBarrelSelected_raw() & fLegAFilterMask) | (a2.isBarrelSelected_raw() & fLegBFilterMask)) & fTrackCutFilterMasks[icut]) == fTrackCutFilterMasks[icut]) { + if ((a1.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) && (a2.isBarrelSelected_raw() & fConstructedLegBFilterMasksMap[icut])) { twoTrackFilter |= (static_cast(1) << icut); // If the supposed pion passes a kaon cut, this is a K+K-. Skip it. if (TPairType == VarManager::kDecayToKPi && fConfigSkipAmbiguousIdCombinations.value) { - if (a2.isBarrelSelected_raw() & fLegAFilterMask) { - isPairIdWrong = true; + if (a2.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) { + twoTrackFilter &= ~(static_cast(1) << icut); } } } } - - if (!twoTrackFilter || isPairIdWrong) { + if (!twoTrackFilter) { continue; } @@ -2275,6 +2619,18 @@ struct AnalysisAsymmetricPairing { continue; } + bool isReflected = false; + std::pair trackIds(t1.globalIndex(), t2.globalIndex()); + if (fPairCount.find(trackIds) != fPairCount.end()) { + // Double counting is possible due to track-collision ambiguity. Skip pairs which were counted before + fPairCount[trackIds] += 1; + continue; + } + if (fPairCount.find(std::pair(trackIds.second, trackIds.first)) != fPairCount.end()) { + isReflected = true; + } + fPairCount[trackIds] += 1; + sign1 = t1.sign(); sign2 = t2.sign(); // store the ambiguity number of the two dilepton legs in the last 4 digits of the two-track filter @@ -2296,61 +2652,70 @@ struct AnalysisAsymmetricPairing { if (twoTrackFilter & (static_cast(1) << icut)) { isAmbi = (twoTrackFilter & (static_cast(1) << 30)) || (twoTrackFilter & (static_cast(1) << 31)); if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s", fLegCutNames[icut].Data()), VarManager::fgValues); // reconstructed, unmatched if (isAmbi && fConfigAmbiguousHistograms.value) { - fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_ambiguous_%s", fLegCutNames[icut].Data()), VarManager::fgValues); + } + if (isReflected && fConfigReflectedHistograms.value) { + fHistMan->FillHistClass(Form("PairsBarrelSEPM_reflected_%s", fLegCutNames[icut].Data()), VarManager::fgValues); } } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s", fLegCutNames[icut].Data()), VarManager::fgValues); if (isAmbi && fConfigAmbiguousHistograms.value) { - fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_ambiguous_%s", fLegCutNames[icut].Data()), VarManager::fgValues); + } + if (isReflected && fConfigReflectedHistograms.value) { + fHistMan->FillHistClass(Form("PairsBarrelSEPP_reflected_%s", fLegCutNames[icut].Data()), VarManager::fgValues); } } else { - fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s", fLegCutNames[icut].Data()), VarManager::fgValues); if (isAmbi && fConfigAmbiguousHistograms.value) { - fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_ambiguous_%s", fLegCutNames[icut].Data()), VarManager::fgValues); + } + if (isReflected && fConfigReflectedHistograms) { + fHistMan->FillHistClass(Form("PairsBarrelSEMM_reflected_%s", fLegCutNames[icut].Data()), VarManager::fgValues); } } } for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { if (twoTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) { if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data()), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data()), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data()), VarManager::fgValues); } } } } // end loop (common cuts) - for (unsigned int iPairCut = 0; iPairCut < fPairCuts.size(); iPairCut++) { - AnalysisCompositeCut cut = fPairCuts.at(iPairCut); - if (!(cut.IsSelected(VarManager::fgValues))) // apply pair cuts + int iPairCut = 0; + for (auto cut = fPairCuts.begin(); cut != fPairCuts.end(); cut++, iPairCut++) { + if (!((*cut)->IsSelected(VarManager::fgValues))) // apply pair cuts continue; pairFilter |= (static_cast(1) << iPairCut); // Histograms with pair cuts if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } } // Histograms with pair cuts and common track cuts for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { if (twoTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) { if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + (icut * fNPairCuts * fNCommonTrackCuts) + (iCommonCut * fNPairCuts) + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPM_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + (icut * fNPairCuts * fNCommonTrackCuts) + (iCommonCut * fNPairCuts) + iPairCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEPP_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + (icut * fNPairCuts * fNCommonTrackCuts) + (iCommonCut * fNPairCuts) + iPairCut][2].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("PairsBarrelSEMM_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } } } @@ -2379,8 +2744,6 @@ struct AnalysisAsymmetricPairing { } } - std::map> histNames = fTrackHistNames; - for (auto& event : events) { if (!event.isEventSelected_bit(0)) { continue; @@ -2405,12 +2768,12 @@ struct AnalysisAsymmetricPairing { // Based on triplet type, make suitable combinations of the partitions if (tripletType == VarManager::kTripleCandidateToPKPi) { for (auto& [a1, a2, a3] : combinations(soa::CombinationsFullIndexPolicy(groupedLegAAssocs, groupedLegBAssocs, groupedLegCAssocs))) { - readTriplet(a1, a2, a3, tracks, event, tripletType, histNames); + readTriplet(a1, a2, a3, tracks, event, tripletType); } } else if (tripletType == VarManager::kTripleCandidateToKPiPi) { for (auto& a1 : groupedLegAAssocs) { for (auto& [a2, a3] : combinations(groupedLegBAssocs, groupedLegCAssocs)) { - readTriplet(a1, a2, a3, tracks, event, tripletType, histNames); + readTriplet(a1, a2, a3, tracks, event, tripletType); } } } else { @@ -2421,27 +2784,27 @@ struct AnalysisAsymmetricPairing { // Helper function to process triplet template - void readTriplet(TTrackAssoc const& a1, TTrackAssoc const& a2, TTrackAssoc const& a3, TTracks const& /*tracks*/, TEvent const& event, VarManager::PairCandidateType tripletType, std::map> histNames) + void readTriplet(TTrackAssoc const& a1, TTrackAssoc const& a2, TTrackAssoc const& a3, TTracks const& /*tracks*/, TEvent const& event, VarManager::PairCandidateType tripletType) { uint32_t threeTrackFilter = static_cast(0); uint32_t threeTrackCommonFilter = static_cast(0); for (int icut = 0; icut < fNLegCuts; ++icut) { - // Find out which leg cut combination the triplet passes - if ((((a1.isBarrelSelected_raw() & fLegAFilterMask) | (a2.isBarrelSelected_raw() & fLegBFilterMask) | (a3.isBarrelSelected_raw() & fLegCFilterMask)) & fTrackCutFilterMasks[icut]) == fTrackCutFilterMasks[icut]) { + // Find out which leg cut combinations the triplet passes + if ((a1.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) && (a2.isBarrelSelected_raw() & fConstructedLegBFilterMasksMap[icut]) && (a3.isBarrelSelected_raw() & fConstructedLegCFilterMasksMap[icut])) { threeTrackFilter |= (static_cast(1) << icut); if (tripletType == VarManager::kTripleCandidateToPKPi && fConfigSkipAmbiguousIdCombinations.value) { // Check if the supposed pion passes as a proton or kaon, if so, skip this triplet. It is pKp or pKK. - if ((a3.isBarrelSelected_raw() & fLegAFilterMask) || (a3.isBarrelSelected_raw() & fLegBFilterMask)) { + if ((a3.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) || (a3.isBarrelSelected_raw() & fConstructedLegBFilterMasksMap[icut])) { return; } // Check if the supposed kaon passes as a proton, if so, skip this triplet. It is ppPi. - if (a2.isBarrelSelected_raw() & fLegAFilterMask) { + if (a2.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) { return; } } if (tripletType == VarManager::kTripleCandidateToKPiPi && fConfigSkipAmbiguousIdCombinations.value) { // Check if one of the supposed pions pass as a kaon, if so, skip this triplet. It is KKPi. - if ((a2.isBarrelSelected_raw() & fLegAFilterMask) || (a3.isBarrelSelected_raw() & fLegAFilterMask)) { + if ((a2.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut]) || (a3.isBarrelSelected_raw() & fConstructedLegAFilterMasksMap[icut])) { return; } } @@ -2462,6 +2825,17 @@ struct AnalysisAsymmetricPairing { if (t1 == t2 || t1 == t3 || t2 == t3) { return; } + // Check charge + if (tripletType == VarManager::kTripleCandidateToKPiPi) { + if (!((t1.sign() == -1 && t2.sign() == 1 && t3.sign() == 1) || (t1.sign() == 1 && t2.sign() == -1 && t3.sign() == -1))) { + return; + } + } + if (tripletType == VarManager::kTripleCandidateToPKPi) { + if (!((t1.sign() == 1 && t2.sign() == -1 && t3.sign() == 1) || (t1.sign() == -1 && t2.sign() == 1 && t3.sign() == -1))) { + return; + } + } // store the ambiguity of the three legs in the last 3 digits of the two-track filter if (t1.barrelAmbiguityInBunch() > 1 || t1.barrelAmbiguityOutOfBunch() > 1) { @@ -2482,26 +2856,25 @@ struct AnalysisAsymmetricPairing { // Fill histograms for (int icut = 0; icut < fNLegCuts; icut++) { if (threeTrackFilter & (static_cast(1) << icut)) { - fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s", fLegCutNames[icut].Data()), VarManager::fgValues); if (fConfigAmbiguousHistograms.value && ((threeTrackFilter & (static_cast(1) << 29)) || (threeTrackFilter & (static_cast(1) << 30)) || (threeTrackFilter & (static_cast(1) << 31)))) { - fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("TripletsBarrelSE_ambiguous_%s", fLegCutNames[icut].Data()), VarManager::fgValues); } for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { if (threeTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data()), VarManager::fgValues); } } // end loop (common cuts) - for (unsigned int iPairCut = 0; iPairCut < fPairCuts.size(); iPairCut++) { - AnalysisCompositeCut cut = fPairCuts.at(iPairCut); - if (!(cut.IsSelected(VarManager::fgValues))) { // apply pair cuts + int iPairCut = 0; + for (auto cut = fPairCuts.begin(); cut != fPairCuts.end(); cut++, iPairCut++) { + if (!((*cut)->IsSelected(VarManager::fgValues))) // apply pair cuts continue; - } // Histograms with pair cuts - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); // Histograms with pair cuts and common track cuts for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { if (threeTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + (icut * fNPairCuts * fNCommonTrackCuts) + (iCommonCut * fNPairCuts) + iPairCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(Form("TripletsBarrelSE_%s_%s_%s", fLegCutNames[icut].Data(), fCommonCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), VarManager::fgValues); } } } // end loop (pair cuts) @@ -2516,6 +2889,13 @@ struct AnalysisAsymmetricPairing { runAsymmetricPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks); } + void processKaonPionSkimmedMultExtra(MyEventsVtxCovZdcSelectedMultExtra const& events, + soa::Join const& barrelAssocs, + MyBarrelTracksWithCovWithAmbiguities const& barrelTracks) + { + runAsymmetricPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks); + } + void processKaonPionPionSkimmed(MyEventsVtxCovZdcSelected const& events, soa::Join const& barrelAssocs, MyBarrelTracksWithCovWithAmbiguities const& barrelTracks) @@ -2523,6 +2903,13 @@ struct AnalysisAsymmetricPairing { runThreeProng(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, VarManager::kTripleCandidateToKPiPi); } + void processKaonPionPionSkimmedMultExtra(MyEventsVtxCovZdcSelectedMultExtra const& events, + soa::Join const& barrelAssocs, + MyBarrelTracksWithCovWithAmbiguities const& barrelTracks) + { + runThreeProng(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, VarManager::kTripleCandidateToKPiPi); + } + void processProtonKaonPionSkimmed(MyEventsVtxCovZdcSelected const& events, soa::Join const& barrelAssocs, MyBarrelTracksWithCovWithAmbiguities const& barrelTracks) @@ -2537,6 +2924,8 @@ struct AnalysisAsymmetricPairing { PROCESS_SWITCH(AnalysisAsymmetricPairing, processKaonPionSkimmed, "Run kaon pion pairing, with skimmed tracks", false); PROCESS_SWITCH(AnalysisAsymmetricPairing, processKaonPionPionSkimmed, "Run kaon pion pion triplets, with skimmed tracks", false); + PROCESS_SWITCH(AnalysisAsymmetricPairing, processKaonPionSkimmedMultExtra, "Run kaon pion pairing, with skimmed tracks", false); + PROCESS_SWITCH(AnalysisAsymmetricPairing, processKaonPionPionSkimmedMultExtra, "Run kaon pion pion triplets, with skimmed tracks", false); PROCESS_SWITCH(AnalysisAsymmetricPairing, processProtonKaonPionSkimmed, "Run proton kaon pion triplets, with skimmed tracks", false); PROCESS_SWITCH(AnalysisAsymmetricPairing, processDummy, "Dummy function, enabled only if none of the others are enabled", true); }; @@ -2546,9 +2935,10 @@ struct AnalysisAsymmetricPairing { // tracks passing the fConfigTrackCut cut. The dileptons cuts from the same-event pairing task are auto-detected struct AnalysisDileptonTrack { Produces BmesonsTable; + Produces DileptonTrackTable; OutputObj fOutputList{"output"}; - Configurable fConfigTrackCut{"cfgTrackCut", "kaonPID", "Cut for the track to be correlated with the dileptons"}; + Configurable fConfigTrackCuts{"cfgTrackCuts", "kaonPID", "Comma separated list of cuts for the track to be correlated with the dileptons"}; Configurable fConfigDileptonLowMass{"cfgDileptonLowMass", 2.8, "Low mass cut for the dileptons used in analysis"}; Configurable fConfigDileptonHighMass{"cfgDileptonHighMass", 3.2, "High mass cut for the dileptons used in analysis"}; Configurable fConfigDileptonpTCut{"cfgDileptonpTCut", 0.0, "pT cut for dileptons used in the triplet vertexing"}; @@ -2556,26 +2946,35 @@ struct AnalysisDileptonTrack { Configurable fConfigUseKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"}; Configurable fConfigHistogramSubgroups{"cfgDileptonTrackHistogramsSubgroups", "invmass,vertexing", "Comma separated list of dilepton-track histogram subgroups"}; + Configurable fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"}; Configurable fConfigMixingDepth{"cfgMixingDepth", 5, "Event mixing pool depth"}; Configurable fConfigUseRemoteField{"cfgUseRemoteField", false, "Chose whether to fetch the magnetic field from ccdb or set it manually"}; Configurable fConfigGRPmagPath{"cfgGrpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable fConfigMagField{"cfgMagField", 5.0f, "Manually set magnetic field"}; + Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable fConfigGeoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. - int fNCuts; - int fNPairCuts; + int fNCuts; // number of dilepton leg cuts + int fNLegCuts; + int fNPairCuts; // number of pair cuts int fNCommonTrackCuts; std::map fCommonTrackCutMap; - int fTrackCutBit; - std::map fHistNamesDileptonTrack; - std::map fHistNamesDileptons; - std::map fHistNamesME; + uint32_t fTrackCutBitMap; // track cut bit mask to be used in the selection of tracks associated with dileptons + // vector for single-lepton and track cut names for easy access when calling FillHistogramList() + std::vector fTrackCutNames; + std::vector fLegCutNames; + // vector for pair cut names, used mainly for pairs built via the asymmetric pairing task + std::vector fPairCutNames; + std::vector fCommonPairCutNames; Service fCCDB; // TODO: The filter expressions seem to always use the default value of configurables, not the values from the actual configuration file - Filter eventFilter = aod::dqanalysisflags::isEventSelected > static_cast(1); + Filter eventFilter = aod::dqanalysisflags::isEventSelected > static_cast(0); Filter dileptonFilter = aod::reducedpair::pt > fConfigDileptonpTCut&& aod::reducedpair::mass > fConfigDileptonLowMass&& aod::reducedpair::mass fConfigDileptonLxyCut; Filter filterBarrel = aod::dqanalysisflags::isBarrelSelected > static_cast(0); Filter filterMuon = aod::dqanalysisflags::isMuonSelected > static_cast(0); @@ -2591,158 +2990,233 @@ struct AnalysisDileptonTrack { void init(o2::framework::InitContext& context) { - if (context.mOptions.get("processDummy")) { - return; - } - + LOG(info) << "Initialization of AnalysisDileptonTrack started (idstoreh)"; bool isBarrel = context.mOptions.get("processBarrelSkimmed"); bool isBarrelME = context.mOptions.get("processBarrelMixedEvent"); bool isBarrelAsymmetric = context.mOptions.get("processDstarToD0Pi"); bool isMuon = context.mOptions.get("processMuonSkimmed"); bool isMuonME = context.mOptions.get("processMuonMixedEvent"); + // If the dummy process is enabled, skip the entire init + if (context.mOptions.get("processDummy")) { + if (isBarrel || isBarrelME || isBarrelAsymmetric || isMuon || isMuonME) { + LOG(fatal) << "If processDummy is enabled, no other process functions should be enabled! Or switch off the processDummy!"; + } + return; + } + fCurrentRun = 0; + fTrackCutBitMap = 0; fValuesDilepton = new float[VarManager::kNVars]; fValuesHadron = new float[VarManager::kNVars]; - fTrackCutBit = -1; VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); - fHistMan->SetUseDefaultVariableNames(kTRUE); + fHistMan->SetUseDefaultVariableNames(true); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); - TString histNames = ""; // For each track/muon selection used to produce dileptons, create a separate histogram directory using the // name of the track/muon cut. - // Also, create a map which will hold the name of the histogram directories so they can be accessed directly in the pairing loop + LOG(info) << "Initialization of AnalysisDileptonTrack 1 (idstoreh)"; if (isBarrel || isMuon || isBarrelAsymmetric) { - // get the list of single track and muon cuts computed in the dedicated tasks upstream - string tempCutsSingle; + // Get the list of single track and muon cuts computed in the dedicated tasks upstream + // We need this to know the order in which they were computed, and also to make sure that in this task we do not ask + // for cuts which were not computed (in which case this will trigger a fatal) + string cfgTrackSelection_TrackCuts; if (isBarrel || isBarrelAsymmetric) { - getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", tempCutsSingle, false); + getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", cfgTrackSelection_TrackCuts, false); } else { - getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCuts", tempCutsSingle, false); + getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCuts", cfgTrackSelection_TrackCuts, false); } - TString tempCutsSingleStr = tempCutsSingle; - TObjArray* objArraySingleCuts = nullptr; - if (!tempCutsSingleStr.IsNull()) { - objArraySingleCuts = tempCutsSingleStr.Tokenize(","); + + TObjArray* cfgTrackSelection_objArrayTrackCuts = nullptr; + if (!cfgTrackSelection_TrackCuts.empty()) { + cfgTrackSelection_objArrayTrackCuts = TString(cfgTrackSelection_TrackCuts).Tokenize(","); } - if (objArraySingleCuts->FindObject(fConfigTrackCut.value.data()) == nullptr) { - LOG(fatal) << " Track cut chosen for the correlation task was not computed in the single-track task! Check it out!"; + // get also the list of cuts specified via the JSON parameters + if (isBarrel || isBarrelAsymmetric) { + getTaskOptionValue(context, "analysis-track-selection", "cfgBarrelTrackCutsJSON", cfgTrackSelection_TrackCuts, false); + } else { + getTaskOptionValue(context, "analysis-muon-selection", "cfgMuonCutsJSON", cfgTrackSelection_TrackCuts, false); + } + if (!cfgTrackSelection_TrackCuts.empty()) { + if (cfgTrackSelection_objArrayTrackCuts == nullptr) { + cfgTrackSelection_objArrayTrackCuts = new TObjArray(); + } + std::vector addTrackCuts = dqcuts::GetCutsFromJSON(cfgTrackSelection_TrackCuts.data()); + for (auto& t : addTrackCuts) { + TObjString* tempObjStr = new TObjString(t->GetName()); + cfgTrackSelection_objArrayTrackCuts->Add(tempObjStr); + } } + if (cfgTrackSelection_objArrayTrackCuts->GetEntries() == 0) { + LOG(fatal) << " No track cuts found in the barrel or muon upstream tasks"; + } + // store all the computed track cut names in a vector + for (int icut = 0; icut < cfgTrackSelection_objArrayTrackCuts->GetEntries(); icut++) { + fTrackCutNames.push_back(cfgTrackSelection_objArrayTrackCuts->At(icut)->GetName()); + } + LOG(info) << "Initialization of AnalysisDileptonTrack 2 (idstoreh)"; + // get the list of associated track cuts to be combined with the dileptons and + // check that these were computed upstream and create a bit mask + TObjArray* cfgDileptonTrack_objArrayTrackCuts = nullptr; + if (!fConfigTrackCuts.value.empty()) { + cfgDileptonTrack_objArrayTrackCuts = TString(fConfigTrackCuts.value).Tokenize(","); + } else { + LOG(fatal) << " No track cuts specified! Check it out!"; + } + for (int icut = 0; icut < cfgDileptonTrack_objArrayTrackCuts->GetEntries(); icut++) { + if (!cfgTrackSelection_objArrayTrackCuts->FindObject(cfgDileptonTrack_objArrayTrackCuts->At(icut)->GetName())) { + LOG(fatal) << "Specified track cut (" << cfgDileptonTrack_objArrayTrackCuts->At(icut)->GetName() << ") not found in the list of computed cuts by the single barrel / muon selection tasks"; + } + } + for (int icut = 0; icut < cfgTrackSelection_objArrayTrackCuts->GetEntries(); icut++) { + if (cfgDileptonTrack_objArrayTrackCuts->FindObject(cfgTrackSelection_objArrayTrackCuts->At(icut)->GetName())) { + fTrackCutBitMap |= (static_cast(1) << icut); + } + } + fNCuts = fTrackCutNames.size(); + // get the cuts employed for same-event pairing - string tempCutsSinglePair; - string pairCuts; - string pairCommonCuts; - string tempCutsTrack; + // NOTE: The track/muon cuts in analysis-same-event-pairing are used to select electrons/muons to build dielectrons/dimuons + // NOTE: The cfgPairCuts in analysis-same-event-pairing are used to apply an additional selection on top of the already produced dileptons + // but this is only used for histograms, not for the produced dilepton tables + string cfgPairing_TrackCuts; + string cfgPairing_PairCuts; + string cfgPairing_PairCutsJSON; + string cfgPairing_CommonTrackCuts; if (isBarrel) { - getTaskOptionValue(context, "analysis-same-event-pairing", "cfgTrackCuts", tempCutsSinglePair, false); - getTaskOptionValue(context, "analysis-same-event-pairing", "cfgPairCuts", pairCuts, false); + getTaskOptionValue(context, "analysis-same-event-pairing", "cfgTrackCuts", cfgPairing_TrackCuts, false); + getTaskOptionValue(context, "analysis-same-event-pairing", "cfgPairCuts", cfgPairing_PairCuts, false); } else if (isMuon) { - getTaskOptionValue(context, "analysis-same-event-pairing", "cfgMuonCuts", tempCutsSinglePair, false); - getTaskOptionValue(context, "analysis-same-event-pairing", "cfgPairCuts", pairCuts, false); + getTaskOptionValue(context, "analysis-same-event-pairing", "cfgMuonCuts", cfgPairing_TrackCuts, false); + getTaskOptionValue(context, "analysis-same-event-pairing", "cfgPairCuts", cfgPairing_PairCuts, false); } else if (isBarrelAsymmetric) { - getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", tempCutsTrack, false); - getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgLegCuts", tempCutsSinglePair, false); - getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgPairCuts", pairCuts, false); - getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgCommonTrackCuts", pairCommonCuts, false); + getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgLegCuts", cfgPairing_TrackCuts, false); + getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgPairCuts", cfgPairing_PairCuts, false); + getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgCommonTrackCuts", cfgPairing_CommonTrackCuts, false); + } + LOG(info) << "Initialization of AnalysisDileptonTrack 3 (idstoreh)"; + if (cfgPairing_TrackCuts.empty()) { + LOG(fatal) << "There are no dilepton cuts specified in the upstream in the same-event-pairing or asymmetric-pairing"; } // If asymmetric pair is used, it may have common track cuts - TString pairCommonCutsStr = pairCommonCuts; - if (!pairCommonCutsStr.IsNull()) { // if common track cuts - TString tempCutsTrackStr = tempCutsTrack; - std::unique_ptr objArrayTempTrack(tempCutsTrackStr.Tokenize(",")); - int fNTempTrackCuts = objArrayTempTrack->GetEntries(); - std::unique_ptr objArrayCommon(pairCommonCutsStr.Tokenize(",")); + TString cfgPairing_strCommonTrackCuts = cfgPairing_CommonTrackCuts; + if (!cfgPairing_strCommonTrackCuts.IsNull()) { // if common track cuts + std::unique_ptr objArrayCommon(cfgPairing_strCommonTrackCuts.Tokenize(",")); fNCommonTrackCuts = objArrayCommon->GetEntries(); for (int icut = 0; icut < fNCommonTrackCuts; ++icut) { - for (int iicut = 0; iicut < fNTempTrackCuts; ++iicut) { - if (std::strcmp(objArrayCommon->At(icut)->GetName(), objArrayTempTrack->At(iicut)->GetName()) == 0) { + for (int iicut = 0; iicut < cfgTrackSelection_objArrayTrackCuts->GetEntries(); iicut++) { + if (std::strcmp(cfgTrackSelection_objArrayTrackCuts->At(iicut)->GetName(), objArrayCommon->At(icut)->GetName()) == 0) { fCommonTrackCutMap[icut] = iicut; + fCommonPairCutNames.push_back(objArrayCommon->At(icut)->GetName()); } } } + } // end if (common cuts) + LOG(info) << "Initialization of AnalysisDileptonTrack 4 (idstoreh)"; + // Get also the pair cuts specified via the JSON parameters + if (isBarrelAsymmetric) { + getTaskOptionValue(context, "analysis-asymmetric-pairing", "cfgPairCutsJSON", cfgPairing_PairCutsJSON, false); + TString addPairCutsStr = cfgPairing_PairCutsJSON; + if (addPairCutsStr != "") { + std::vector addPairCuts = dqcuts::GetCutsFromJSON(addPairCutsStr.Data()); + for (auto& t : addPairCuts) { + cfgPairing_PairCuts += Form(",%s", t->GetName()); + } + } } - TString tempCutsSinglePairStr = tempCutsSinglePair; - bool cutFound; - if (!tempCutsSingleStr.IsNull() && !tempCutsSinglePairStr.IsNull()) { - std::unique_ptr objArray(tempCutsSinglePairStr.Tokenize(",")); - fNCuts = objArray->GetEntries(); - for (int icut = 0; icut < fNCuts; ++icut) { - TString tempStr = objArray->At(icut)->GetName(); - if (!isBarrelAsymmetric) { - cutFound = objArraySingleCuts->FindObject(tempStr.Data()) != nullptr; - } else { - std::unique_ptr legObjArray(tempStr.Tokenize(":")); - cutFound = true; - for (int iicut = 0; iicut < legObjArray->GetEntries(); ++iicut) { - TString tempLegStr = legObjArray->At(iicut)->GetName(); - if (objArraySingleCuts->FindObject(tempLegStr.Data()) == nullptr) { - cutFound = false; - } - } + std::unique_ptr objArrayPairCuts(TString(cfgPairing_PairCuts).Tokenize(",")); + fNPairCuts = objArrayPairCuts->GetEntries(); + for (int j = 0; j < fNPairCuts; j++) { + fPairCutNames.push_back(objArrayPairCuts->At(j)->GetName()); + } + + // array of single lepton cuts specified in the same-analysis-pairing task + std::unique_ptr cfgPairing_objArrayTrackCuts(TString(cfgPairing_TrackCuts).Tokenize(",")); + // If asymmetric pairs are used, the number of cuts should come from the asymmetric-pairing task + if (isBarrelAsymmetric) { + fNLegCuts = cfgPairing_objArrayTrackCuts->GetEntries(); + } else { + fNLegCuts = fNCuts; + } + LOG(info) << "Initialization of AnalysisDileptonTrack 5 (idstoreh)"; + // loop over single lepton cuts + for (int icut = 0; icut < fNLegCuts; ++icut) { + + TString pairLegCutName; + + // here we check that this cut is one of those used for building the dileptons + if (!isBarrelAsymmetric) { + if (!cfgPairing_objArrayTrackCuts->FindObject(fTrackCutNames[icut].Data())) { + continue; } - if (cutFound) { - fHistNamesDileptonTrack[icut] = Form("DileptonTrack_%s_%s", tempStr.Data(), fConfigTrackCut.value.data()); - fHistNamesDileptons[icut] = Form("DileptonsSelected_%s", tempStr.Data()); - TString pairCutsStr = pairCuts; - DefineHistograms(fHistMan, fHistNamesDileptonTrack[icut], fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - DefineHistograms(fHistMan, fHistNamesDileptons[icut], "barrel,vertexing"); // define dilepton histograms - if (!pairCommonCutsStr.IsNull()) { - std::unique_ptr objArrayCommon(pairCommonCutsStr.Tokenize(",")); - for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - // fTrackHistNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut] = names; - fHistNamesDileptonTrack[fNCuts + icut * fNCommonTrackCuts + iCommonCut] = Form("DileptonTrack_%s_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), fConfigTrackCut.value.data()); - fHistNamesDileptons[fNCuts + icut * fNCommonTrackCuts + iCommonCut] = Form("DileptonsSelected_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName()); - DefineHistograms(fHistMan, fHistNamesDileptonTrack[fNCuts + icut * fNCommonTrackCuts + iCommonCut], fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - DefineHistograms(fHistMan, fHistNamesDileptons[fNCuts + icut * fNCommonTrackCuts + iCommonCut], "barrel,vertexing"); // define dilepton histograms - } + pairLegCutName = fTrackCutNames[icut].Data(); + } else { + // For asymmetric pairs we access the leg cuts instead + pairLegCutName = static_cast(cfgPairing_objArrayTrackCuts->At(icut))->GetString(); + } + fLegCutNames.push_back(pairLegCutName); + + // define dilepton histograms + DefineHistograms(fHistMan, Form("DileptonsSelected_%s", pairLegCutName.Data()), "barrel,vertexing"); + // loop over track cuts and create dilepton - track histogram directories + for (int iCutTrack = 0; iCutTrack < fNCuts; iCutTrack++) { + + // here we check that this track cut is one of those required to associate with the dileptons + if (!(fTrackCutBitMap & (static_cast(1) << iCutTrack))) { + continue; + } + + DefineHistograms(fHistMan, Form("DileptonTrack_%s_%s", pairLegCutName.Data(), fTrackCutNames[iCutTrack].Data()), fConfigHistogramSubgroups.value.data()); + + if (!cfgPairing_strCommonTrackCuts.IsNull()) { + std::unique_ptr objArrayCommon(cfgPairing_strCommonTrackCuts.Tokenize(",")); + for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { + DefineHistograms(fHistMan, Form("DileptonsSelected_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data()), "barrel,vertexing"); + DefineHistograms(fHistMan, Form("DileptonTrack_%s_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data(), fTrackCutNames[iCutTrack].Data()), fConfigHistogramSubgroups.value.data()); } - if (!pairCutsStr.IsNull()) { - std::unique_ptr objArrayPairCuts(pairCutsStr.Tokenize(",")); - fNPairCuts = objArrayPairCuts->GetEntries(); - for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { - fHistNamesDileptonTrack[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = Form("DileptonTrack_%s_%s_%s", tempStr.Data(), objArrayPairCuts->At(iPairCut)->GetName(), fConfigTrackCut.value.data()); - fHistNamesDileptons[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut] = Form("DileptonsSelected_%s_%s", tempStr.Data(), objArrayPairCuts->At(iPairCut)->GetName()); - DefineHistograms(fHistMan, fHistNamesDileptonTrack[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut], fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - DefineHistograms(fHistMan, fHistNamesDileptons[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut], "barrel,vertexing"); // define dilepton histograms - if (!pairCommonCutsStr.IsNull()) { - std::unique_ptr objArrayCommon(pairCommonCutsStr.Tokenize(",")); - for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - fHistNamesDileptonTrack[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut] = Form("DileptonTrack_%s_%s_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPairCuts->At(iPairCut)->GetName(), fConfigTrackCut.value.data()); - fHistNamesDileptons[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut] = Form("DileptonsSelected_%s_%s_%s", tempStr.Data(), objArrayCommon->At(iCommonCut)->GetName(), objArrayPairCuts->At(iPairCut)->GetName()); - DefineHistograms(fHistMan, fHistNamesDileptonTrack[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut], fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - DefineHistograms(fHistMan, fHistNamesDileptons[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut], "barrel,vertexing"); // define dilepton histograms - } + } + + if (fNPairCuts != 0) { + + for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { + DefineHistograms(fHistMan, Form("DileptonsSelected_%s_%s", pairLegCutName.Data(), fPairCutNames[iPairCut].Data()), "barrel,vertexing"); + DefineHistograms(fHistMan, Form("DileptonTrack_%s_%s_%s", pairLegCutName.Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iCutTrack].Data()), fConfigHistogramSubgroups.value.data()); + + if (!cfgPairing_strCommonTrackCuts.IsNull()) { + std::unique_ptr objArrayCommon(cfgPairing_strCommonTrackCuts.Tokenize(",")); + for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { + DefineHistograms(fHistMan, Form("DileptonsSelected_%s_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data()), "barrel,vertexing"); + DefineHistograms(fHistMan, Form("DileptonTrack_%s_%s_%s_%s", pairLegCutName.Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iCutTrack].Data()), fConfigHistogramSubgroups.value.data()); } } } - if (isBarrelME || isMuonME) { - fHistNamesME[icut] = Form("DileptonTrackME_%s", tempStr.Data()); - DefineHistograms(fHistMan, fHistNamesME[icut], "mixedevent"); // define ME histograms - } } - } - for (int icut = 0; icut < objArraySingleCuts->GetEntries(); ++icut) { - TString tempStr = objArraySingleCuts->At(icut)->GetName(); - if (tempStr.CompareTo(fConfigTrackCut.value.data()) == 0) { - fTrackCutBit = icut; // the bit correspoding to the track to be combined with dileptons + + if (isBarrelME || isMuonME) { + DefineHistograms(fHistMan, Form("DileptonTrackME_%s_%s", pairLegCutName.Data(), fTrackCutNames[iCutTrack].Data()), "mixedevent"); // define ME histograms } - } - } - } - if (fHistNamesDileptons.size() == 0) { - LOG(fatal) << " No valid dilepton cuts "; + } // end loop over track cuts to be combined with dileptons / di-tracks + } // end loop over pair leg track cuts } - if (context.mOptions.get("processBarrelMixedEvent")) { - DefineHistograms(fHistMan, "DileptonTrackME", "mixedevent"); // define all histograms - } + dqhistograms::AddHistogramsFromJSON(fHistMan, fConfigAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON VarManager::SetUseVars(fHistMan->GetUsedVars()); fOutputList.setObject(fHistMan->GetMainHistogramList()); + + fCCDB->setURL(fConfigCcdbUrl.value); + fCCDB->setCaching(true); + fCCDB->setLocalObjectValidityChecking(); + fCCDB->setCreatedNotAfter(fConfigNoLaterThan.value); + if (!o2::base::GeometryManager::isGeometryLoaded()) { + LOG(info) << "Loading geometry from CCDB in dilepton-track task"; + fCCDB->get(fConfigGeoPath); + } + + LOG(info) << "Initialization of AnalysisDileptonTrack finished (idstoreh)"; } // init parameters from CCDB @@ -2787,46 +3261,93 @@ struct AnalysisDileptonTrack { if (dilepton.sign() != 0) { continue; } - VarManager::FillTrack(dilepton, fValuesDilepton); - for (int icut = 0; icut < fNCuts; icut++) { - if (dilepton.filterMap_bit(icut)) { - fHistMan->FillHistClass(fHistNamesDileptons[icut].Data(), fValuesDilepton); - if constexpr (TCandidateType == VarManager::kDstarToD0KPiPi) { // Dielectrons and Dimuons don't have the PairFilterMap column - for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { - if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { - fHistMan->FillHistClass(fHistNamesDileptons[fNCuts + icut * fNCommonTrackCuts + iCommonCut].Data(), fValuesDilepton); - } + + // loop over existing dilepton leg cuts (e.g. electron1, electron2, etc) + for (int icut = 0; icut < fNLegCuts; icut++) { + + if (!dilepton.filterMap_bit(icut)) { + continue; + } + + // regular dileptons + fHistMan->FillHistClass(Form("DileptonsSelected_%s", fLegCutNames[icut].Data()), fValuesDilepton); + + // other pairs, e.g.: D0s + if constexpr (TCandidateType == VarManager::kDstarToD0KPiPi) { // Dielectrons and Dimuons don't have the PairFilterMap column + for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { + if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { + fHistMan->FillHistClass(Form("DileptonsSelected_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data()), fValuesDilepton); } - for (int iPairCut = 0; iPairCut < fNPairCuts; iPairCut++) { - if (dilepton.pairFilterMap_bit(iPairCut)) { - fHistMan->FillHistClass(fHistNamesDileptons[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut].Data(), fValuesDilepton); - for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { - if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { - fHistMan->FillHistClass(fHistNamesDileptons[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut].Data(), fValuesDilepton); - } + } + for (int iPairCut = 0; iPairCut < fNPairCuts; iPairCut++) { + if (dilepton.pairFilterMap_bit(iPairCut)) { + fHistMan->FillHistClass(Form("DileptonsSelected_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[icut].Data()), fValuesDilepton); + for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { + if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { + fHistMan->FillHistClass(Form("DileptonsSelected_%s_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[icut].Data()), fValuesDilepton); } } } } } - } + } // end loop over single lepton selections // loop over hadrons for (auto& assoc : assocs) { - if constexpr (TCandidateType == VarManager::kBtoJpsiEEK || TCandidateType == VarManager::kDstarToD0KPiPi) { - if (!assoc.isBarrelSelected_bit(fTrackCutBit)) { + + uint32_t trackSelection = 0; + if constexpr (TCandidateType == VarManager::kBtoJpsiEEK) { + // check the cuts fulfilled by this candidate track; if none just continue + trackSelection = (assoc.isBarrelSelected_raw() & fTrackCutBitMap); + if (!trackSelection) { continue; } + + // get the track from this association auto track = assoc.template reducedtrack_as(); + // check that this track is not included in the current dilepton if (track.globalIndex() == dilepton.index0Id() || track.globalIndex() == dilepton.index1Id()) { continue; } + // compute needed quantities + VarManager::FillDileptonHadron(dilepton, track, fValuesHadron); + VarManager::FillDileptonTrackVertexing(event, lepton1, lepton2, track, fValuesHadron); + // table to be written out for ML analysis + BmesonsTable(fValuesHadron[VarManager::kPairMass], dilepton.mass(), fValuesHadron[VarManager::kDeltaMass], fValuesHadron[VarManager::kPairPt], fValuesHadron[VarManager::kPairEta], + fValuesHadron[VarManager::kVertexingLxy], fValuesHadron[VarManager::kVertexingLxyz], fValuesHadron[VarManager::kVertexingLz], + fValuesHadron[VarManager::kVertexingTauxy], fValuesHadron[VarManager::kVertexingTauz], fValuesHadron[VarManager::kCosPointingAngle], + fValuesHadron[VarManager::kVertexingChi2PCA], + track.tpcInnerParam(), track.eta(), dilepton.pt(), dilepton.eta(), lepton1.tpcInnerParam(), lepton1.eta(), lepton2.tpcInnerParam(), lepton2.eta(), + track.tpcNSigmaKa(), track.tpcNSigmaPi(), track.tpcNSigmaPr(), track.tofNSigmaKa(), + lepton1.tpcNSigmaEl(), lepton1.tpcNSigmaPi(), lepton1.tpcNSigmaPr(), + lepton2.tpcNSigmaEl(), lepton2.tpcNSigmaPi(), lepton2.tpcNSigmaPr(), + track.dcaXY(), track.dcaZ(), lepton1.dcaXY(), lepton1.dcaZ(), lepton2.dcaXY(), lepton2.dcaZ(), + track.itsClusterMap(), lepton1.itsClusterMap(), lepton2.itsClusterMap(), + track.itsChi2NCl(), lepton1.itsChi2NCl(), lepton2.itsChi2NCl(), + track.tpcNClsFound(), lepton1.tpcNClsFound(), lepton2.tpcNClsFound(), + track.tpcChi2NCl(), lepton1.tpcChi2NCl(), lepton2.tpcChi2NCl(), + dilepton.filterMap_raw(), trackSelection); + } + if constexpr (TCandidateType == VarManager::kDstarToD0KPiPi) { + trackSelection = (assoc.isBarrelSelected_raw() & fTrackCutBitMap); + if (!trackSelection) { + continue; + } + auto track = assoc.template reducedtrack_as(); + if (track.globalIndex() == dilepton.index0Id() || track.globalIndex() == dilepton.index1Id()) { + continue; + } + // Check that the charge combination makes sense for D*+ -> D0 pi+ or D*- -> D0bar pi- + if (!((track.sign() == 1 && lepton1.sign() == -1 && lepton2.sign() == 1) || (track.sign() == -1 && lepton1.sign() == 1 && lepton2.sign() == -1))) { + continue; + } VarManager::FillDileptonHadron(dilepton, track, fValuesHadron); VarManager::FillDileptonTrackVertexing(event, lepton1, lepton2, track, fValuesHadron); } if constexpr (TCandidateType == VarManager::kBcToThreeMuons) { - if (!assoc.isMuonSelected_bit(fTrackCutBit)) { + trackSelection = (assoc.isMuonSelected_raw() & fTrackCutBitMap); + if (!trackSelection) { continue; } auto track = assoc.template reducedmuon_as(); @@ -2836,32 +3357,45 @@ struct AnalysisDileptonTrack { VarManager::FillDileptonHadron(dilepton, track, fValuesHadron); VarManager::FillDileptonTrackVertexing(event, lepton1, lepton2, track, fValuesHadron); + // Fill table for correlation analysis + DileptonTrackTable(fValuesHadron[VarManager::kDeltaEta], fValuesHadron[VarManager::kDeltaPhi], dilepton.mass(), dilepton.pt(), dilepton.eta(), track.pt(), track.eta()); } - for (int icut = 0; icut < fNCuts; icut++) { - if (dilepton.filterMap_bit(icut)) { - fHistMan->FillHistClass(fHistNamesDileptonTrack[icut].Data(), fValuesHadron); + // Fill histograms for the triplets + // loop over dilepton / ditrack cuts + for (int icut = 0; icut < fNLegCuts; icut++) { + + if (!dilepton.filterMap_bit(icut)) { + continue; + } + + // loop over specified track cuts (the tracks to be combined with the dileptons) + for (int iTrackCut = 0; iTrackCut < fNCuts; iTrackCut++) { + + if (!(trackSelection & (static_cast(1) << iTrackCut))) { + continue; + } + fHistMan->FillHistClass(Form("DileptonTrack_%s_%s", fLegCutNames[icut].Data(), fTrackCutNames[iTrackCut].Data()), fValuesHadron); + if constexpr (TCandidateType == VarManager::kDstarToD0KPiPi) { // Dielectrons and Dimuons don't have the PairFilterMap column for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { - fHistMan->FillHistClass(fHistNamesDileptonTrack[fNCuts + icut * fNCommonTrackCuts + iCommonCut].Data(), fValuesHadron); + fHistMan->FillHistClass(Form("DileptonTrack_%s_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data(), fTrackCutNames[iTrackCut].Data()), fValuesHadron); } } for (int iPairCut = 0; iPairCut < fNPairCuts; iPairCut++) { if (dilepton.pairFilterMap_bit(iPairCut)) { - fHistMan->FillHistClass(fHistNamesDileptonTrack[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut].Data(), fValuesHadron); + fHistMan->FillHistClass(Form("DileptonTrack_%s_%s_%s", fLegCutNames[icut].Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iTrackCut].Data()), fValuesHadron); for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { if (dilepton.commonFilterMap_bit(fCommonTrackCutMap[iCommonCut])) { - fHistMan->FillHistClass(fHistNamesDileptonTrack[(fNCuts * (fNCommonTrackCuts + 1) + fNCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut].Data(), fValuesHadron); + fHistMan->FillHistClass(Form("DileptonTrack_%s_%s_%s_%s", fLegCutNames[icut].Data(), fCommonPairCutNames[iCommonCut].Data(), fPairCutNames[iPairCut].Data(), fTrackCutNames[iTrackCut].Data()), fValuesHadron); } } } } } - } - } - // table to be written out for ML analysis - BmesonsTable(fValuesHadron[VarManager::kPairMass], fValuesHadron[VarManager::kDeltaMass], fValuesHadron[VarManager::kPairPt], fValuesHadron[VarManager::kVertexingLxy], fValuesHadron[VarManager::kVertexingLxyz], fValuesHadron[VarManager::kVertexingLz], fValuesHadron[VarManager::kVertexingTauxy], fValuesHadron[VarManager::kVertexingTauz], fValuesHadron[VarManager::kCosPointingAngle], fValuesHadron[VarManager::kVertexingChi2PCA]); + } // end loop over track cuts + } // end loop over dilepton cuts } } } @@ -2940,27 +3474,47 @@ struct AnalysisDileptonTrack { events.bindExternalIndices(&dileptons); events.bindExternalIndices(&assocs); + // loop over two event comibnations for (auto& [event1, event2] : selfCombinations(fHashBin, fConfigMixingDepth.value, -1, events, events)) { + // fill event quantities VarManager::ResetValues(0, VarManager::kNVars); VarManager::FillEvent(event1, VarManager::fgValues); + // get the dilepton slice for event1 auto evDileptons = dileptons.sliceBy(dielectronsPerCollision, event1.globalIndex()); evDileptons.bindExternalIndices(&events); + // get the track associations slice for event2 auto evAssocs = assocs.sliceBy(trackAssocsPerCollision, event2.globalIndex()); evAssocs.bindExternalIndices(&events); + // loop over associations for (auto& assoc : evAssocs) { - if (!assoc.isBarrelSelected_bit(fTrackCutBit)) { + + // check that this track fulfills at least one of the specified cuts + uint32_t trackSelection = (assoc.isBarrelSelected_raw() & fTrackCutBitMap); + if (!trackSelection) { continue; } + + // get the track from this association auto track = assoc.template reducedtrack_as(); + // loop over dileptons for (auto dilepton : evDileptons) { + + // compute dilepton - track quantities VarManager::FillDileptonHadron(dilepton, track, VarManager::fgValues); + + // loop over dilepton leg cuts and track cuts and fill histograms separately for each combination for (int icut = 0; icut < fNCuts; icut++) { - if (dilepton.filterMap_bit(icut)) { - fHistMan->FillHistClass(fHistNamesME[icut].Data(), VarManager::fgValues); + if (!dilepton.filterMap_bit(icut)) { + continue; + } + for (uint32_t iTrackCut = 0; iTrackCut < fTrackCutNames.size(); iTrackCut++) { + if (trackSelection & (static_cast(1) << iTrackCut)) { + fHistMan->FillHistClass(Form("DileptonTrackME_%s_%s", fTrackCutNames[icut].Data(), fTrackCutNames[iTrackCut].Data()), VarManager::fgValues); + } } } } // end for (dileptons) @@ -2990,7 +3544,8 @@ struct AnalysisDileptonTrack { for (auto& assoc : evAssocs) { - if (!assoc.isMuonSelected_bit(fTrackCutBit)) { + uint32_t muonSelection = assoc.isMuonSelected_raw() & fTrackCutBitMap; + if (!muonSelection) { continue; } auto track = assoc.template reducedmuon_as(); @@ -2998,8 +3553,13 @@ struct AnalysisDileptonTrack { for (auto dilepton : evDileptons) { VarManager::FillDileptonHadron(dilepton, track, VarManager::fgValues); for (int icut = 0; icut < fNCuts; icut++) { - if (dilepton.filterMap_bit(icut)) { - fHistMan->FillHistClass(fHistNamesME[icut].Data(), VarManager::fgValues); + if (!dilepton.filterMap_bit(icut)) { + continue; + } + for (uint32_t iTrackCut = 0; iTrackCut < fTrackCutNames.size(); iTrackCut++) { + if (muonSelection & (static_cast(1) << iTrackCut)) { + fHistMan->FillHistClass(Form("DileptonTrackME_%s_%s", fTrackCutNames[icut].Data(), fTrackCutNames[iTrackCut].Data()), VarManager::fgValues); + } } } } // end for (dileptons) @@ -3020,6 +3580,257 @@ struct AnalysisDileptonTrack { PROCESS_SWITCH(AnalysisDileptonTrack, processDummy, "Dummy function", false); }; +struct AnalysisDileptonTrackTrack { + OutputObj fOutputList{"output"}; + + Configurable fConfigTrackCut1{"cfgTrackCut1", "pionPIDCut1", "track1 cut"}; // used for select the tracks from SelectedTracks + Configurable fConfigTrackCut2{"cfgTrackCut2", "pionPIDCut2", "track2 cut"}; // used for select the tracks from SelectedTracks + Configurable fConfigDileptonCut{"cfgDiLeptonCut", "pairJpsi2", "Dilepton cut"}; + Configurable fConfigQuadrupletCuts{"cfgQuadrupletCuts", "pairX3872Cut1", "Comma separated list of Dilepton-Track-Track cut"}; + Configurable fConfigAddDileptonHistogram{"cfgAddDileptonHistogram", "barrel", "Comma separated list of histograms"}; + Configurable fConfigAddQuadrupletHistogram{"cfgAddQuadrupletHistogram", "xtojpsipipi", "Comma separated list of histograms"}; + + Configurable fConfigSetupFourProngFitter{"cfgSetupFourProngFitter", false, "Use DCA for secondary vertex reconstruction (DCAFitter is used by default)"}; + Configurable fConfigUseKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"}; + Configurable fConfigUseRemoteField{"cfgUseRemoteField", false, "Chose whether to fetch the magnetic field from ccdb or set it manually"}; + Configurable fConfigGRPmagPath{"cfgGrpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable fConfigMagField{"cfgMagField", 5.0f, "Manually set magnetic field"}; + + Produces DileptonTrackTrackTable; + + int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. + // uint32_t fTrackCutBitMap; // track cut bit mask to be used in the selection of tracks associated with dileptons + // cut name setting + TString fTrackCutName1; + TString fTrackCutName2; + bool fIsSameTrackCut = false; + AnalysisCompositeCut fDileptonCut; + std::vector fQuadrupletCutNames; + std::vector fQuadrupletCuts; + + Service fCCDB; + + Filter eventFilter = aod::dqanalysisflags::isEventSelected > static_cast(0); + Filter dileptonFilter = aod::reducedpair::sign == 0; + Filter filterBarrelTrackSelected = aod::dqanalysisflags::isBarrelSelected > static_cast(0); + + constexpr static uint32_t fgDileptonFillMap = VarManager::ObjTypes::ReducedTrack | VarManager::ObjTypes::Pair; // fill map + + // use some values array to avoid mixing up the quantities + float* fValuesQuadruplet; + HistogramManager* fHistMan; + + void init(o2::framework::InitContext& context) + { + // bool isBarrel = context.mOptions.get("processJpsiPiPi"); + + if (context.mOptions.get("processDummy")) { + return; + } + + fCurrentRun = 0; + + fValuesQuadruplet = new float[VarManager::kNVars]; + VarManager::SetDefaultVarNames(); + fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); + fHistMan->SetUseDefaultVariableNames(kTRUE); + fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); + + // define cuts + fTrackCutName1 = fConfigTrackCut1.value; + fTrackCutName2 = fConfigTrackCut2.value; + if (fTrackCutName1 == fTrackCutName2) { + fIsSameTrackCut = true; + } + TString configDileptonCutNamesStr = fConfigDileptonCut.value; + fDileptonCut = *dqcuts::GetCompositeCut(configDileptonCutNamesStr.Data()); + TString configQuadruletCutNamesStr = fConfigQuadrupletCuts.value; + std::unique_ptr objArray(configQuadruletCutNamesStr.Tokenize(",")); + for (Int_t icut = 0; icut < objArray->GetEntries(); ++icut) { + TString cutName = objArray->At(icut)->GetName(); + fQuadrupletCutNames.push_back(cutName); + fQuadrupletCuts.push_back(*dqcuts::GetCompositeCut(cutName.Data())); + } + + if (!context.mOptions.get("processDummy")) { + DefineHistograms(fHistMan, Form("Pairs_%s", configDileptonCutNamesStr.Data()), fConfigAddDileptonHistogram.value.data()); + if (!configQuadruletCutNamesStr.IsNull()) { + for (std::size_t icut = 0; icut < fQuadrupletCutNames.size(); ++icut) { + if (fIsSameTrackCut) { + DefineHistograms(fHistMan, Form("QuadrupletSEPM_%s", fQuadrupletCutNames[icut].Data()), fConfigAddQuadrupletHistogram.value.data()); + } else { + DefineHistograms(fHistMan, Form("QuadrupletSEPM_%s", fQuadrupletCutNames[icut].Data()), fConfigAddQuadrupletHistogram.value.data()); + DefineHistograms(fHistMan, Form("QuadrupletSEMP_%s", fQuadrupletCutNames[icut].Data()), fConfigAddQuadrupletHistogram.value.data()); + } + DefineHistograms(fHistMan, Form("QuadrupletSEPP_%s", fQuadrupletCutNames[icut].Data()), fConfigAddQuadrupletHistogram.value.data()); + DefineHistograms(fHistMan, Form("QuadrupletSEMM_%s", fQuadrupletCutNames[icut].Data()), fConfigAddQuadrupletHistogram.value.data()); + } + } + } + + VarManager::SetUseVars(fHistMan->GetUsedVars()); + fOutputList.setObject(fHistMan->GetMainHistogramList()); + } + + // init parameters from CCDB + void initParamsFromCCDB(uint64_t timestamp) + { + if (fConfigUseRemoteField.value) { + o2::parameters::GRPMagField* grpmag = fCCDB->getForTimeStamp(fConfigGRPmagPath.value, timestamp); + float magField = 0.0; + if (grpmag != nullptr) { + magField = grpmag->getNominalL3Field(); + } else { + LOGF(fatal, "GRP object is not available in CCDB at timestamp=%llu", timestamp); + } + if (fConfigUseKFVertexing.value) { + VarManager::SetupTwoProngKFParticle(magField); + VarManager::SetupFourProngKFParticle(magField); + } else if (fConfigSetupFourProngFitter.value) { + VarManager::SetupTwoProngDCAFitter(magField, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + VarManager::SetupFourProngDCAFitter(magField, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + } + } else { + if (fConfigUseKFVertexing.value) { + VarManager::SetupTwoProngKFParticle(fConfigMagField.value); + VarManager::SetupFourProngKFParticle(fConfigMagField.value); + } else if (fConfigSetupFourProngFitter.value) { + LOGP(info, "Setting up DCA fitter for two and four prong candidates"); + VarManager::SetupTwoProngDCAFitter(fConfigMagField.value, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + VarManager::SetupFourProngDCAFitter(fConfigMagField.value, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, false); // TODO: get these parameters from Configurables + } + } + } + + // Template function to run pair - hadron combinations + template + void runDileptonTrackTrack(TEvent const& event, TTrackAssocs const& assocs, TTracks const& tracks, TDileptons const& dileptons) + { + VarManager::ResetValues(0, VarManager::kNVars, fValuesQuadruplet); + VarManager::FillEvent(event, fValuesQuadruplet); + // int indexOffset = -999; + // std::vector trackGlobalIndexes; + + for (auto dilepton : dileptons) { + // get full track info of tracks based on the index + + int indexLepton1 = dilepton.index0Id(); + int indexLepton2 = dilepton.index1Id(); + auto lepton1 = tracks.rawIteratorAt(dilepton.index0Id()); + auto lepton2 = tracks.rawIteratorAt(dilepton.index1Id()); + // Check that the dilepton has zero charge + if (dilepton.sign() != 0) { + continue; + } + VarManager::FillTrack(dilepton, fValuesQuadruplet); + // LOGP(info, "is dilepton selected: {}", fDileptonCut.IsSelected(fValuesQuadruplet)); + + // apply the dilepton cut + if (!fDileptonCut.IsSelected(fValuesQuadruplet)) + continue; + + fHistMan->FillHistClass(Form("Pairs_%s", fDileptonCut.GetName()), fValuesQuadruplet); + + // loop over hadrons pairs + for (auto& [a1, a2] : o2::soa::combinations(assocs, assocs)) { + uint32_t trackSelection = 0; + if (fIsSameTrackCut) { + trackSelection = ((a1.isBarrelSelected_raw() & (static_cast(1) << 1)) || (a2.isBarrelSelected_raw() & (static_cast(1) << 1))); + } else { + trackSelection = ((a1.isBarrelSelected_raw() & (static_cast(1) << 1)) && (a2.isBarrelSelected_raw() & (static_cast(1) << 2))); + } + // LOGP(info, "trackSelection: {}, a1: {}, a2: {}", trackSelection, a1.isBarrelSelected_raw(), a2.isBarrelSelected_raw()); + if (!trackSelection) { + continue; + } + + // get the track from this association + auto track1 = a1.template reducedtrack_as(); + auto track2 = a2.template reducedtrack_as(); + // avoid self combinations + if (track1.globalIndex() == indexLepton1 || track1.globalIndex() == indexLepton2 || track2.globalIndex() == indexLepton1 || track2.globalIndex() == indexLepton2) { + continue; + } + + // fill variables + VarManager::FillDileptonTrackTrack(dilepton, track1, track2, fValuesQuadruplet); + if (fConfigSetupFourProngFitter || fConfigUseKFVertexing) { + // LOGP(info, "Using KF or DCA fitter for secondary vertexing"); + VarManager::FillDileptonTrackTrackVertexing(event, lepton1, lepton2, track1, track2, fValuesQuadruplet); + } + + int iCut = 0; + uint32_t CutDecision = 0; + for (auto cutname = fQuadrupletCutNames.begin(); cutname != fQuadrupletCutNames.end(); cutname++, iCut++) { + // apply dilepton-track-track cut + if (fQuadrupletCuts[iCut].IsSelected(fValuesQuadruplet)) { + CutDecision |= (1 << iCut); + if (fIsSameTrackCut) { + if (track1.sign() * track2.sign() < 0) { + fHistMan->FillHistClass(Form("QuadrupletSEPM_%s", fQuadrupletCutNames[iCut].Data()), fValuesQuadruplet); + } + } else { + if ((track1.sign() < 0) && (track2.sign() > 0)) { + fHistMan->FillHistClass(Form("QuadrupletSEMP_%s", fQuadrupletCutNames[iCut].Data()), fValuesQuadruplet); + } else if ((track1.sign() > 0) && (track2.sign() < 0)) { + fHistMan->FillHistClass(Form("QuadrupletSEPM_%s", fQuadrupletCutNames[iCut].Data()), fValuesQuadruplet); + } + } + if ((track1.sign() > 0) && (track2.sign() > 0)) { + fHistMan->FillHistClass(Form("QuadrupletSEPP_%s", fQuadrupletCutNames[iCut].Data()), fValuesQuadruplet); + } else if ((track1.sign() < 0) && (track2.sign() < 0)) { + fHistMan->FillHistClass(Form("QuadrupletSEMM_%s", fQuadrupletCutNames[iCut].Data()), fValuesQuadruplet); + } + } + } // loop over dilepton-track-track cuts + + // fill table + if (!CutDecision) + continue; + DileptonTrackTrackTable(fValuesQuadruplet[VarManager::kQuadMass], fValuesQuadruplet[VarManager::kQuadPt], fValuesQuadruplet[VarManager::kQuadEta], fValuesQuadruplet[VarManager::kQuadPhi], fValuesQuadruplet[VarManager::kRap], + fValuesQuadruplet[VarManager::kQ], fValuesQuadruplet[VarManager::kDeltaR1], fValuesQuadruplet[VarManager::kDeltaR2], fValuesQuadruplet[VarManager::kDeltaR], + dilepton.mass(), dilepton.pt(), dilepton.eta(), dilepton.phi(), dilepton.sign(), + lepton1.tpcNSigmaEl(), lepton1.tpcNSigmaPi(), lepton1.tpcNSigmaPr(), lepton1.tpcNClsFound(), + lepton2.tpcNSigmaEl(), lepton2.tpcNSigmaPi(), lepton2.tpcNSigmaPr(), lepton2.tpcNClsFound(), + fValuesQuadruplet[VarManager::kDitrackMass], fValuesQuadruplet[VarManager::kDitrackPt], track1.pt(), track2.pt(), track1.eta(), track2.eta(), track1.phi(), track2.phi(), track1.sign(), track2.sign(), track1.tpcNSigmaPi(), track2.tpcNSigmaPi(), track1.tpcNSigmaKa(), track2.tpcNSigmaKa(), track1.tpcNSigmaPr(), track1.tpcNSigmaPr(), track1.tpcNClsFound(), track2.tpcNClsFound(), + fValuesQuadruplet[VarManager::kKFMass], fValuesQuadruplet[VarManager::kVertexingProcCode], fValuesQuadruplet[VarManager::kVertexingChi2PCA], fValuesQuadruplet[VarManager::kCosPointingAngle], fValuesQuadruplet[VarManager::kKFDCAxyzBetweenProngs], fValuesQuadruplet[VarManager::kKFChi2OverNDFGeo], + fValuesQuadruplet[VarManager::kVertexingLz], fValuesQuadruplet[VarManager::kVertexingLxy], fValuesQuadruplet[VarManager::kVertexingLxyz], fValuesQuadruplet[VarManager::kVertexingTauz], fValuesQuadruplet[VarManager::kVertexingTauxy], fValuesQuadruplet[VarManager::kVertexingLzErr], fValuesQuadruplet[VarManager::kVertexingLxyzErr], + fValuesQuadruplet[VarManager::kVertexingTauzErr], fValuesQuadruplet[VarManager::kVertexingLzProjected], fValuesQuadruplet[VarManager::kVertexingLxyProjected], fValuesQuadruplet[VarManager::kVertexingLxyzProjected], fValuesQuadruplet[VarManager::kVertexingTauzProjected], fValuesQuadruplet[VarManager::kVertexingTauxyProjected]); + } + } + } + + Preslice trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId; + Preslice dielectronsPerCollision = aod::reducedpair::reducedeventId; + Preslice ditracksPerCollision = aod::reducedpair::reducedeventId; + + void processJpsiPiPi(soa::Filtered const& events, + soa::Filtered> const& assocs, + MyBarrelTracksWithCov const& tracks, soa::Filtered const& dileptons) + { + if (events.size() == 0) { + return; + } + if (fCurrentRun != events.begin().runNumber()) { // start: runNumber + initParamsFromCCDB(events.begin().timestamp()); + fCurrentRun = events.begin().runNumber(); + } // end: runNumber + for (auto& event : events) { + auto groupedBarrelAssocs = assocs.sliceBy(trackAssocsPerCollision, event.globalIndex()); + auto groupedDielectrons = dileptons.sliceBy(dielectronsPerCollision, event.globalIndex()); + runDileptonTrackTrack(event, groupedBarrelAssocs, tracks, groupedDielectrons); + } + } + + void processDummy(MyEvents&) + { + // do nothing + } + + PROCESS_SWITCH(AnalysisDileptonTrackTrack, processJpsiPiPi, "Run barrel pairing of J/psi with pion candidate", false); + PROCESS_SWITCH(AnalysisDileptonTrackTrack, processDummy, "Dummy function", true); +}; + WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ @@ -3029,7 +3840,8 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; } void DefineHistograms(HistogramManager* histMan, TString histClasses, const char* histGroups) @@ -3106,5 +3918,9 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses, const char if (classStr.Contains("DileptonHadronCorrelation")) { dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "dilepton-hadron-correlation"); } + + if (classStr.Contains("Quadruplet")) { + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "dilepton-dihadron", histName); + } } // end loop over histogram classes } diff --git a/PWGDQ/Tasks/taskFwdTrackPid.cxx b/PWGDQ/Tasks/taskFwdTrackPid.cxx index 7a135596d56..cbe6e233630 100644 --- a/PWGDQ/Tasks/taskFwdTrackPid.cxx +++ b/PWGDQ/Tasks/taskFwdTrackPid.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -139,13 +139,11 @@ struct taskFwdTrackPid { template void runFwdTrackPid(TEvent const& event, Muons const& muons, MftTracks const& mftTracks) { - uint32_t mcDecision = 0; - fwdPidAllList.reserve(1); for (const auto& muon : muons) { if (muon.has_matchMFTTrack() && muon.trackType() == 0 && TMath::Abs(muon.fwdDcaX()) < fConfigMaxDCA && TMath::Abs(muon.fwdDcaY()) < fConfigMaxDCA) { auto mftTrack = muon.template matchMFTTrack_as(); - fwdPidAllList(muon.trackType(), event.posX(), event.posY(), event.posZ(), event.numContrib(), muon.pt(), muon.eta(), muon.phi(), muon.sign(), mftTrack.mftClusterSizesAndTrackFlags(), muon.fwdDcaX(), muon.fwdDcaY(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), mcDecision); + fwdPidAllList(muon.trackType(), event.posX(), event.posY(), event.posZ(), event.numContrib(), muon.pt(), muon.eta(), muon.phi(), muon.sign(), mftTrack.mftClusterSizesAndTrackFlags(), muon.fwdDcaX(), muon.fwdDcaY(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), 0); } } if constexpr (TMatchedOnly == false) { @@ -157,7 +155,7 @@ struct taskFwdTrackPid { continue; } } - fwdPidAllList(4, event.posX(), event.posY(), event.posZ(), event.numContrib(), mftTrack.pt(), mftTrack.eta(), mftTrack.phi(), mftTrack.sign(), mftTrack.mftClusterSizesAndTrackFlags(), mftTrack.fwdDcaX(), mftTrack.fwdDcaY(), -999, -999, mcDecision); + fwdPidAllList(4, event.posX(), event.posY(), event.posZ(), event.numContrib(), mftTrack.pt(), mftTrack.eta(), mftTrack.phi(), mftTrack.sign(), mftTrack.mftClusterSizesAndTrackFlags(), mftTrack.fwdDcaX(), mftTrack.fwdDcaY(), -999, -999, 0); } } } @@ -169,31 +167,16 @@ struct taskFwdTrackPid { { fwdPidAllList.reserve(1); for (const auto& muon : muons) { - uint32_t mcDecision = 0; - int isig = 0; - for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { - if ((*sig).CheckSignal(false, muon.reducedMCTrack())) { - mcDecision |= (uint32_t(1) << isig); - } - } - if (muon.has_matchMFTTrack() && muon.trackType() == 0 && TMath::Abs(muon.fwdDcaX()) < fConfigMaxDCA && TMath::Abs(muon.fwdDcaY()) < fConfigMaxDCA) { auto mftTrack = muon.template matchMFTTrack_as(); - fwdPidAllList(muon.trackType(), event.posX(), event.posY(), event.posZ(), event.numContrib(), muon.pt(), muon.eta(), muon.phi(), muon.sign(), mftTrack.mftClusterSizesAndTrackFlags(), muon.fwdDcaX(), muon.fwdDcaY(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), mcDecision); + fwdPidAllList(muon.trackType(), event.posX(), event.posY(), event.posZ(), event.numContrib(), muon.pt(), muon.eta(), muon.phi(), muon.sign(), mftTrack.mftClusterSizesAndTrackFlags(), muon.fwdDcaX(), muon.fwdDcaY(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), muon.mcReducedFlags()); } } if constexpr (TMatchedOnly == false) { for (const auto& mftTrack : mftTracks) { - uint32_t mcDecision = 0; - int isig = 0; - for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { - if ((*sig).CheckSignal(false, mftTrack.reducedMCTrack())) { - mcDecision |= (uint32_t(1) << isig); - } - } if (TMath::Abs(mftTrack.fwdDcaX()) < fConfigMaxDCA && TMath::Abs(mftTrack.fwdDcaY()) < fConfigMaxDCA) { - fwdPidAllList(4, event.posX(), event.posY(), event.posZ(), event.numContrib(), mftTrack.pt(), mftTrack.eta(), mftTrack.phi(), mftTrack.sign(), mftTrack.mftClusterSizesAndTrackFlags(), mftTrack.fwdDcaX(), mftTrack.fwdDcaY(), -999, -999, mcDecision); + fwdPidAllList(4, event.posX(), event.posY(), event.posZ(), event.numContrib(), mftTrack.pt(), mftTrack.eta(), mftTrack.phi(), mftTrack.sign(), mftTrack.mftClusterSizesAndTrackFlags(), mftTrack.fwdDcaX(), mftTrack.fwdDcaY(), -999, -999, mftTrack.mcReducedFlags()); } } } @@ -206,19 +189,10 @@ struct taskFwdTrackPid { for (auto& mctrack : groupedMCTracks) { VarManager::FillTrackMC(groupedMCTracks, mctrack); - for (auto& sig : fGenMCSignals) { - if (sig.GetNProngs() != 1) { // NOTE: 1-prong signals required - continue; - } - bool checked = false; - if constexpr (soa::is_soa_filtered_v) { - auto mctrack_raw = groupedMCTracks.rawIteratorAt(mctrack.globalIndex()); - checked = sig.CheckSignal(false, mctrack_raw); - } else { - checked = sig.CheckSignal(false, mctrack); - } - if (checked) { - fHistMan->FillHistClass(Form("MCTruthGen_%s", sig.GetName()), VarManager::fgValues); + int isig = 0; + for (auto sig = fGenMCSignals.begin(); sig != fGenMCSignals.end(); sig++, isig++) { + if (mctrack.mcReducedFlags() & (static_cast(1) << isig)) { + fHistMan->FillHistClass(Form("MCTruthGen_%s", sig->GetName()), VarManager::fgValues); } } } @@ -287,8 +261,7 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses) if (classStr.Contains("MCTruthGen")) { dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "mctruth"); histMan->AddHistogram(objArray->At(iclass)->GetName(), "Pt_Rapidity", "MC generator p_{T}, y distribution", false, 120, 0.0, 30.0, VarManager::kMCPt, 150, 2.5, 4.0, VarManager::kMCY); - histMan->AddHistogram(objArray->At(iclass)->GetName(), "Eta", "MC generator #eta distribution", false, 200, 2.5, 4.0, VarManager::kMCEta); - // histMan->AddHistogram(objArray->At(iclass)->GetName(), "Rapidity", "MC generator y distribution", false, 150, 2.5, 4.0, VarManager::kMCY); + histMan->AddHistogram(objArray->At(iclass)->GetName(), "Eta", "MC generator #eta distribution", false, 200, -5.0, 5.0, VarManager::kMCEta); histMan->AddHistogram(objArray->At(iclass)->GetName(), "Phi", "MC generator #varphi distribution", false, 50, 0.0, 2. * TMath::Pi(), VarManager::kMCPhi); } diff --git a/PWGDQ/Tasks/v0selector.cxx b/PWGDQ/Tasks/v0selector.cxx index 52068b44958..0c970d80c91 100644 --- a/PWGDQ/Tasks/v0selector.cxx +++ b/PWGDQ/Tasks/v0selector.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include "Math/Vector4D.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -74,6 +75,7 @@ struct v0selector { Configurable cutQTK0SHigh{"cutQTK0SHigh", 0.215, "cutQTK0SHigh"}; Configurable cutAPK0SLow{"cutAPK0SLow", 0.199, "cutAPK0SLow"}; Configurable cutAPK0SHigh{"cutAPK0SHigh", 0.8, "cutAPK0SHigh"}; + Configurable cutAPK0SHighTop{"cutAPK0SHighTop", 0.9, "cutAPK0SHighTop"}; // Lambda & A-Lambda cuts Configurable cutQTL{"cutQTL", 0.03, "cutQTL"}; Configurable cutAlphaLLow{"cutAlphaLLow", 0.35, "cutAlphaLLow"}; @@ -83,6 +85,7 @@ struct v0selector { Configurable cutAPL1{"cutAPL1", 0.107, "cutAPL1"}; Configurable cutAPL2{"cutAPL2", -0.69, "cutAPL2"}; Configurable cutAPL3{"cutAPL3", 0.5, "cutAPL3"}; + Configurable produceV0ID{"produceV0ID", false, "Produce additional V0ID table"}; enum { // Reconstructed V0 kUndef = -1, @@ -94,6 +97,7 @@ struct v0selector { }; Produces v0bits; + Produces v0mapID; // int checkV0(const array& ppos, const array& pneg) int checkV0(const float alpha, const float qt) @@ -117,31 +121,32 @@ struct v0selector { // const float cutAPL[3] = {0.107, -0.69, 0.5}; // parameters for curved QT cut if (qt < cutQTG) { - if ((TMath::Abs(alpha) < cutAlphaG)) { + if ((std::abs(alpha) < cutAlphaG)) { return kGamma; } } if (qt < cutQTG2) { // additional region - should help high pT gammas - if ((TMath::Abs(alpha) > cutAlphaGLow) && (TMath::Abs(alpha) < cutAlphaGHigh)) { + if ((std::abs(alpha) > cutAlphaGLow) && (std::abs(alpha) < cutAlphaGHigh)) { return kGamma; } } // Check for K0S candidates - float q = cutAPK0SLow * TMath::Sqrt(TMath::Abs(1 - alpha * alpha / (cutAPK0SHigh * cutAPK0SHigh))); - if ((qt > cutQTK0SLow) && (qt < cutQTK0SHigh) && (qt > q)) { + float q = cutAPK0SLow * std::sqrt(std::abs(1.0f - alpha * alpha / (cutAPK0SHigh * cutAPK0SHigh))); + float qtop = cutQTK0SHigh * std::sqrt(std::abs(1.0f - alpha * alpha / (cutAPK0SHighTop * cutAPK0SHighTop))); + if ((qt > cutQTK0SLow) && (qt < cutQTK0SHigh) && (qt > q) && (qt < qtop)) { return kK0S; } // Check for Lambda candidates - q = cutAPL1 * TMath::Sqrt(TMath::Abs(1 - ((alpha + cutAPL2) * (alpha + cutAPL2)) / (cutAPL3 * cutAPL3))); + q = cutAPL1 * std::sqrt(std::abs(1.0f - ((alpha + cutAPL2) * (alpha + cutAPL2)) / (cutAPL3 * cutAPL3))); if ((alpha > cutAlphaLLow) && (alpha < cutAlphaLHigh) && (qt > cutQTL) && (qt < q)) { return kLambda; } // Check for AntiLambda candidates - q = cutAPL1 * TMath::Sqrt(TMath::Abs(1 - ((alpha - cutAPL2) * (alpha - cutAPL2)) / (cutAPL3 * cutAPL3))); + q = cutAPL1 * std::sqrt(std::abs(1.0f - ((alpha - cutAPL2) * (alpha - cutAPL2)) / (cutAPL3 * cutAPL3))); if ((alpha > cutAlphaALLow) && (alpha < cutAlphaALHigh) && (qt > cutQTL) && (qt < q)) { return kAntiLambda; } @@ -189,14 +194,22 @@ struct v0selector { registry.add("hDCAzNegToPV", "hDCAzNegToPV", HistType::kTH1F, {{1000, -5.0f, 5.0f}}); registry.add("hDCAV0Dau", "hDCAV0Dau", HistType::kTH1F, {{1000, 0.0f, 10.0f}}); registry.add("hV0APplot", "hV0APplot", HistType::kTH2F, {{200, -1.0f, +1.0f}, {250, 0.0f, 0.25f}}); + registry.add("hV0APplotSelected", "hV0APplotSelected", HistType::kTH2F, {{200, -1.0f, +1.0f}, {250, 0.0f, 0.25f}}); registry.add("hV0Psi", "hV0Psi", HistType::kTH2F, {{100, 0, TMath::PiOver2()}, {100, 0, 0.1}}); } } void process(aod::V0Datas const& V0s, FullTracksExt const& tracks, aod::Collisions const&) { - std::map pidmap; - + std::vector pidmap; + pidmap.clear(); + pidmap.resize(tracks.size(), 0); + + std::vector v0pidmap; + v0pidmap.clear(); + if (produceV0ID.value) { + v0pidmap.resize(V0s.size(), -1); + } for (auto& V0 : V0s) { // if (!(V0.posTrack_as().trackType() & o2::aod::track::TPCrefit)) { // continue; @@ -209,10 +222,10 @@ struct v0selector { if (fillhisto) { registry.fill(HIST("hV0Candidate"), 1); } - if (fabs(V0.posTrack_as().eta()) > 0.9) { + if (std::fabs(V0.posTrack_as().eta()) > 0.9) { continue; } - if (fabs(V0.negTrack_as().eta()) > 0.9) { + if (std::fabs(V0.negTrack_as().eta()) > 0.9) { continue; } @@ -222,25 +235,22 @@ struct v0selector { if (V0.negTrack_as().tpcNClsCrossedRows() < mincrossedrows) { continue; } - if (V0.posTrack_as().tpcChi2NCl() > maxchi2tpc) { continue; } if (V0.negTrack_as().tpcChi2NCl() > maxchi2tpc) { continue; } - - if (fabs(V0.posTrack_as().dcaXY()) < dcamin) { + if (std::fabs(V0.posTrack_as().dcaXY()) < dcamin) { continue; } - if (fabs(V0.negTrack_as().dcaXY()) < dcamin) { + if (std::fabs(V0.negTrack_as().dcaXY()) < dcamin) { continue; } - - if (fabs(V0.posTrack_as().dcaXY()) > dcamax) { + if (std::fabs(V0.posTrack_as().dcaXY()) > dcamax) { continue; } - if (fabs(V0.negTrack_as().dcaXY()) > dcamax) { + if (std::fabs(V0.negTrack_as().dcaXY()) > dcamax) { continue; } @@ -304,15 +314,24 @@ struct v0selector { // printf("This is not [Gamma/K0S/Lambda/AntiLambda] candidate.\n"); continue; } + if (fillhisto) { + registry.fill(HIST("hV0APplotSelected"), V0.alpha(), V0.qtarm()); + } + auto storeV0AddID = [&](auto gix, auto id) { + if (produceV0ID.value) { + v0pidmap[gix] = id; + } + }; if (v0id == kGamma) { // photon conversion if (fillhisto) { registry.fill(HIST("hMassGamma"), V0radius, mGamma); registry.fill(HIST("hV0Psi"), psipair, mGamma); } - if (mGamma < v0max_mee && TMath::Abs(V0.posTrack_as().tpcNSigmaEl()) < cutNsigmaElTPC && TMath::Abs(V0.negTrack_as().tpcNSigmaEl()) < cutNsigmaElTPC && TMath::Abs(psipair) < maxpsipair) { + if (mGamma < v0max_mee && std::abs(V0.posTrack_as().tpcNSigmaEl()) < cutNsigmaElTPC && std::abs(V0.negTrack_as().tpcNSigmaEl()) < cutNsigmaElTPC && std::abs(psipair) < maxpsipair) { pidmap[V0.posTrackId()] |= (uint8_t(1) << kGamma); pidmap[V0.negTrackId()] |= (uint8_t(1) << kGamma); + storeV0AddID(V0.globalIndex(), kGamma); if (fillhisto) { registry.fill(HIST("hGammaRxy"), V0.x(), V0.y()); } @@ -324,33 +343,39 @@ struct v0selector { registry.fill(HIST("hMassK0SEta"), V0.eta(), mK0S); registry.fill(HIST("hMassK0SPhi"), V0.phi(), mK0S); } - if ((0.48 < mK0S && mK0S < 0.51) && TMath::Abs(V0.posTrack_as().tpcNSigmaPi()) < cutNsigmaPiTPC && TMath::Abs(V0.negTrack_as().tpcNSigmaPi()) < cutNsigmaPiTPC) { + if ((0.48 < mK0S && mK0S < 0.51) && std::abs(V0.posTrack_as().tpcNSigmaPi()) < cutNsigmaPiTPC && std::abs(V0.negTrack_as().tpcNSigmaPi()) < cutNsigmaPiTPC) { pidmap[V0.posTrackId()] |= (uint8_t(1) << kK0S); pidmap[V0.negTrackId()] |= (uint8_t(1) << kK0S); + storeV0AddID(V0.globalIndex(), kK0S); } } else if (v0id == kLambda) { // L->p + pi- if (fillhisto) { registry.fill(HIST("hMassLambda"), V0radius, mLambda); } - if (v0id == kLambda && (1.110 < mLambda && mLambda < 1.120) && TMath::Abs(V0.posTrack_as().tpcNSigmaPr()) < cutNsigmaPrTPC && TMath::Abs(V0.negTrack_as().tpcNSigmaPi()) < cutNsigmaPiTPC) { + if (v0id == kLambda && (1.110 < mLambda && mLambda < 1.120) && std::abs(V0.posTrack_as().tpcNSigmaPr()) < cutNsigmaPrTPC && std::abs(V0.negTrack_as().tpcNSigmaPi()) < cutNsigmaPiTPC) { pidmap[V0.posTrackId()] |= (uint8_t(1) << kLambda); pidmap[V0.negTrackId()] |= (uint8_t(1) << kLambda); + storeV0AddID(V0.globalIndex(), kLambda); } } else if (v0id == kAntiLambda) { // Lbar -> pbar + pi+ if (fillhisto) { registry.fill(HIST("hMassAntiLambda"), V0radius, mAntiLambda); } - if ((1.110 < mAntiLambda && mAntiLambda < 1.120) && TMath::Abs(V0.posTrack_as().tpcNSigmaPi()) < cutNsigmaPiTPC && TMath::Abs(V0.negTrack_as().tpcNSigmaPr()) < cutNsigmaPrTPC) { + if ((1.110 < mAntiLambda && mAntiLambda < 1.120) && std::abs(V0.posTrack_as().tpcNSigmaPi()) < cutNsigmaPiTPC && std::abs(V0.negTrack_as().tpcNSigmaPr()) < cutNsigmaPrTPC) { pidmap[V0.posTrackId()] |= (uint8_t(1) << kAntiLambda); pidmap[V0.negTrackId()] |= (uint8_t(1) << kAntiLambda); + storeV0AddID(V0.globalIndex(), kAntiLambda); } } - // printf("posTrackId = %d\n",V0.posTrackId()); // printf("negTrackId = %d\n",V0.negTrackId()); } // end of V0 loop - + if (produceV0ID.value) { + for (auto& V0 : V0s) { + v0mapID(v0pidmap[V0.globalIndex()]); + } + } for (auto& track : tracks) { // printf("setting pidmap[%lld] = %d\n",track.globalIndex(),pidmap[track.globalIndex()]); v0bits(pidmap[track.globalIndex()]); @@ -455,15 +480,15 @@ struct trackPIDQA { continue; } - if (fabs(track.dcaXY()) < dcamin) { + if (std::fabs(track.dcaXY()) < dcamin) { continue; } - if (fabs(track.dcaXY()) > dcamax) { + if (std::fabs(track.dcaXY()) > dcamax) { continue; } - if (fabs(track.eta()) > 0.9) { + if (std::fabs(track.eta()) > 0.9) { continue; } diff --git a/PWGEM/Dilepton/Core/CMakeLists.txt b/PWGEM/Dilepton/Core/CMakeLists.txt index 92d06924294..97501004c4a 100644 --- a/PWGEM/Dilepton/Core/CMakeLists.txt +++ b/PWGEM/Dilepton/Core/CMakeLists.txt @@ -13,10 +13,12 @@ o2physics_add_library(PWGEMDileptonCore SOURCES EMEventCut.cxx DielectronCut.cxx DimuonCut.cxx + EMTrackCut.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::MLCore) o2physics_target_root_dictionary(PWGEMDileptonCore HEADERS EMEventCut.h DielectronCut.h DimuonCut.h + EMTrackCut.h LINKDEF PWGEMDileptonCoreLinkDef.h) diff --git a/PWGEM/Dilepton/Core/DielectronCut.cxx b/PWGEM/Dilepton/Core/DielectronCut.cxx index 784e09707bd..7f86c7babbe 100644 --- a/PWGEM/Dilepton/Core/DielectronCut.cxx +++ b/PWGEM/Dilepton/Core/DielectronCut.cxx @@ -13,11 +13,12 @@ // Class for dielectron Cut // -#include -#include +#include "PWGEM/Dilepton/Core/DielectronCut.h" #include "Framework/Logger.h" -#include "PWGEM/Dilepton/Core/DielectronCut.h" + +#include +#include ClassImp(DielectronCut); @@ -66,12 +67,13 @@ void DielectronCut::SelectPhotonConversion(bool flag) mSelectPC = flag; LOG(info) << "Dielectron Cut, select photon conversion: " << mSelectPC; } -void DielectronCut::SetMindEtadPhi(bool flag, float min_deta, float min_dphi) +void DielectronCut::SetMindEtadPhi(bool flag1, bool flag2, float min_deta, float min_dphi) { - mApplydEtadPhi = flag; + mApplydEtadPhi = flag1; + mApplydEtadPhiPosition = flag2; mMinDeltaEta = min_deta; mMinDeltaPhi = min_dphi; - LOG(info) << "Dielectron Cut, set apply deta-dphi cut: " << mApplydEtadPhi << " min_deta: " << mMinDeltaEta << " min_dphi: " << mMinDeltaPhi; + LOG(info) << "Dielectron Cut, set apply deta-dphi cut: " << mApplydEtadPhi << " apply deta-dphi* cut: " << mApplydEtadPhiPosition << " min_deta: " << mMinDeltaEta << " min_dphi: " << mMinDeltaPhi; } void DielectronCut::SetRequireDifferentSides(bool flag) { @@ -90,11 +92,13 @@ void DielectronCut::SetTrackEtaRange(float minEta, float maxEta) mMaxTrackEta = maxEta; LOG(info) << "Dielectron Cut, set track eta range: " << mMinTrackEta << " - " << mMaxTrackEta; } -void DielectronCut::SetTrackPhiRange(float minPhi, float maxPhi) +void DielectronCut::SetTrackPhiRange(float minPhi, float maxPhi, bool mirror, bool reject) { mMinTrackPhi = minPhi; mMaxTrackPhi = maxPhi; - LOG(info) << "Dielectron Cut, set track phi range (rad.): " << mMinTrackPhi << " - " << mMaxTrackPhi; + mMirrorTrackPhi = mirror; + mRejectTrackPhi = reject; + LOG(info) << "Dielectron Cut, set track phi range (rad.): " << mMinTrackPhi << " - " << mMaxTrackPhi << " with mirror: " << mMirrorTrackPhi << " and rejection: " << mRejectTrackPhi; } void DielectronCut::SetMinNClustersTPC(int minNClustersTPC) { @@ -141,12 +145,12 @@ void DielectronCut::SetChi2PerClusterITS(float min, float max) mMaxChi2PerClusterITS = max; LOG(info) << "Dielectron Cut, set chi2 per cluster ITS range: " << mMinChi2PerClusterITS << " - " << mMaxChi2PerClusterITS; } -void DielectronCut::SetMeanClusterSizeITS(float min, float max, float minP, float maxP) +void DielectronCut::SetMeanClusterSizeITS(float min, float max) { mMinMeanClusterSizeITS = min; mMaxMeanClusterSizeITS = max; - mMinP_ITSClusterSize = minP; - mMaxP_ITSClusterSize = maxP; + // mMinP_ITSClusterSize = minP; + // mMaxP_ITSClusterSize = maxP; LOG(info) << "Dielectron Cut, set mean cluster size ITS range: " << mMinMeanClusterSizeITS << " - " << mMaxMeanClusterSizeITS; } void DielectronCut::SetChi2TOF(float min, float max) @@ -219,12 +223,12 @@ void DielectronCut::SetTPCNsigmaElRange(float min, float max) mMaxTPCNsigmaEl = max; LOG(info) << "Dielectron Cut, set TPC n sigma El range: " << mMinTPCNsigmaEl << " - " << mMaxTPCNsigmaEl; } -void DielectronCut::SetTPCNsigmaMuRange(float min, float max) -{ - mMinTPCNsigmaMu = min; - mMaxTPCNsigmaMu = max; - LOG(info) << "Dielectron Cut, set TPC n sigma Mu range: " << mMinTPCNsigmaMu << " - " << mMaxTPCNsigmaMu; -} +// void DielectronCut::SetTPCNsigmaMuRange(float min, float max) +// { +// mMinTPCNsigmaMu = min; +// mMaxTPCNsigmaMu = max; +// LOG(info) << "Dielectron Cut, set TPC n sigma Mu range: " << mMinTPCNsigmaMu << " - " << mMaxTPCNsigmaMu; +// } void DielectronCut::SetTPCNsigmaPiRange(float min, float max) { mMinTPCNsigmaPi = min; @@ -250,12 +254,12 @@ void DielectronCut::SetTOFNsigmaElRange(float min, float max) mMaxTOFNsigmaEl = max; LOG(info) << "Dielectron Cut, set TOF n sigma El range: " << mMinTOFNsigmaEl << " - " << mMaxTOFNsigmaEl; } -void DielectronCut::SetTOFNsigmaMuRange(float min, float max) -{ - mMinTOFNsigmaMu = min; - mMaxTOFNsigmaMu = max; - LOG(info) << "Dielectron Cut, set TOF n sigma Mu range: " << mMinTOFNsigmaMu << " - " << mMaxTOFNsigmaMu; -} +// void DielectronCut::SetTOFNsigmaMuRange(float min, float max) +// { +// mMinTOFNsigmaMu = min; +// mMaxTOFNsigmaMu = max; +// LOG(info) << "Dielectron Cut, set TOF n sigma Mu range: " << mMinTOFNsigmaMu << " - " << mMaxTOFNsigmaMu; +// } void DielectronCut::SetTOFNsigmaPiRange(float min, float max) { mMinTOFNsigmaPi = min; @@ -275,60 +279,61 @@ void DielectronCut::SetTOFNsigmaPrRange(float min, float max) LOG(info) << "Dielectron Cut, set TOF n sigma Pr range: " << mMinTOFNsigmaPr << " - " << mMaxTOFNsigmaPr; } -void DielectronCut::SetITSNsigmaElRange(float min, float max) -{ - mMinITSNsigmaEl = min; - mMaxITSNsigmaEl = max; - LOG(info) << "Dielectron Cut, set ITS n sigma El range: " << mMinITSNsigmaEl << " - " << mMaxITSNsigmaEl; -} -void DielectronCut::SetITSNsigmaMuRange(float min, float max) -{ - mMinITSNsigmaMu = min; - mMaxITSNsigmaMu = max; - LOG(info) << "Dielectron Cut, set ITS n sigma Mu range: " << mMinITSNsigmaMu << " - " << mMaxITSNsigmaMu; -} -void DielectronCut::SetITSNsigmaPiRange(float min, float max) -{ - mMinITSNsigmaPi = min; - mMaxITSNsigmaPi = max; - LOG(info) << "Dielectron Cut, set ITS n sigma Pi range: " << mMinITSNsigmaPi << " - " << mMaxITSNsigmaPi; -} -void DielectronCut::SetITSNsigmaKaRange(float min, float max) -{ - mMinITSNsigmaKa = min; - mMaxITSNsigmaKa = max; - LOG(info) << "Dielectron Cut, set ITS n sigma Ka range: " << mMinITSNsigmaKa << " - " << mMaxITSNsigmaKa; -} -void DielectronCut::SetITSNsigmaPrRange(float min, float max) -{ - mMinITSNsigmaPr = min; - mMaxITSNsigmaPr = max; - LOG(info) << "Dielectron Cut, set ITS n sigma Pr range: " << mMinITSNsigmaPr << " - " << mMaxITSNsigmaPr; -} - -void DielectronCut::SetPRangeForITSNsigmaKa(float min, float max) -{ - mMinP_ITSNsigmaKa = min; - mMaxP_ITSNsigmaKa = max; - LOG(info) << "Dielectron Cut, set p range for ITS n sigma Ka: " << mMinP_ITSNsigmaKa << " - " << mMaxP_ITSNsigmaKa; -} - -void DielectronCut::SetPRangeForITSNsigmaPr(float min, float max) -{ - mMinP_ITSNsigmaPr = min; - mMaxP_ITSNsigmaPr = max; - LOG(info) << "Dielectron Cut, set p range for ITS n sigma Pr: " << mMinP_ITSNsigmaPr << " - " << mMaxP_ITSNsigmaPr; -} +// void DielectronCut::SetITSNsigmaElRange(float min, float max) +// { +// mMinITSNsigmaEl = min; +// mMaxITSNsigmaEl = max; +// LOG(info) << "Dielectron Cut, set ITS n sigma El range: " << mMinITSNsigmaEl << " - " << mMaxITSNsigmaEl; +// } +// void DielectronCut::SetITSNsigmaMuRange(float min, float max) +// { +// mMinITSNsigmaMu = min; +// mMaxITSNsigmaMu = max; +// LOG(info) << "Dielectron Cut, set ITS n sigma Mu range: " << mMinITSNsigmaMu << " - " << mMaxITSNsigmaMu; +// } +// void DielectronCut::SetITSNsigmaPiRange(float min, float max) +// { +// mMinITSNsigmaPi = min; +// mMaxITSNsigmaPi = max; +// LOG(info) << "Dielectron Cut, set ITS n sigma Pi range: " << mMinITSNsigmaPi << " - " << mMaxITSNsigmaPi; +// } +// void DielectronCut::SetITSNsigmaKaRange(float min, float max) +// { +// mMinITSNsigmaKa = min; +// mMaxITSNsigmaKa = max; +// LOG(info) << "Dielectron Cut, set ITS n sigma Ka range: " << mMinITSNsigmaKa << " - " << mMaxITSNsigmaKa; +// } +// void DielectronCut::SetITSNsigmaPrRange(float min, float max) +// { +// mMinITSNsigmaPr = min; +// mMaxITSNsigmaPr = max; +// LOG(info) << "Dielectron Cut, set ITS n sigma Pr range: " << mMinITSNsigmaPr << " - " << mMaxITSNsigmaPr; +// } +// +// void DielectronCut::SetPRangeForITSNsigmaKa(float min, float max) +// { +// mMinP_ITSNsigmaKa = min; +// mMaxP_ITSNsigmaKa = max; +// LOG(info) << "Dielectron Cut, set p range for ITS n sigma Ka: " << mMinP_ITSNsigmaKa << " - " << mMaxP_ITSNsigmaKa; +// } +// +// void DielectronCut::SetPRangeForITSNsigmaPr(float min, float max) +// { +// mMinP_ITSNsigmaPr = min; +// mMaxP_ITSNsigmaPr = max; +// LOG(info) << "Dielectron Cut, set p range for ITS n sigma Pr: " << mMinP_ITSNsigmaPr << " - " << mMaxP_ITSNsigmaPr; +// } void DielectronCut::SetMaxPinMuonTPConly(float max) { mMaxPinMuonTPConly = max; LOG(info) << "Dielectron Cut, set max pin for Muon ID with TPC only: " << mMaxPinMuonTPConly; } -void DielectronCut::SetMaxPinForPionRejectionTPC(float max) +void DielectronCut::SetPinRangeForPionRejectionTPC(float min, float max) { + mMinPinForPionRejectionTPC = min; mMaxPinForPionRejectionTPC = max; - LOG(info) << "Dielectron Cut, set max pin for pion rejection in TPC: " << mMaxPinForPionRejectionTPC; + LOG(info) << "Dielectron Cut, set pin range for pion rejection in TPC: " << mMinPinForPionRejectionTPC << " - " << mMaxPinForPionRejectionTPC; } void DielectronCut::RequireITSibAny(bool flag) { @@ -340,3 +345,9 @@ void DielectronCut::RequireITSib1st(bool flag) mRequireITSib1st = flag; LOG(info) << "Dielectron Cut, require ITS ib 1st: " << mRequireITSib1st; } +void DielectronCut::IncludeITSsa(bool flag, float max) +{ + mIncludeITSsa = flag; + mMaxPtITSsa = max; + LOG(info) << "Dielectron Cut, include ITSsa tracks: " << mIncludeITSsa << ", mMaxPtITSsa = " << mMaxPtITSsa; +} diff --git a/PWGEM/Dilepton/Core/DielectronCut.h b/PWGEM/Dilepton/Core/DielectronCut.h index 006624d75ed..0dc108b05c5 100644 --- a/PWGEM/Dilepton/Core/DielectronCut.h +++ b/PWGEM/Dilepton/Core/DielectronCut.h @@ -16,21 +16,22 @@ #ifndef PWGEM_DILEPTON_CORE_DIELECTRONCUT_H_ #define PWGEM_DILEPTON_CORE_DIELECTRONCUT_H_ -#include -#include -#include -#include -#include -#include "TNamed.h" -#include "Math/Vector4D.h" - +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" #include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "Framework/Logger.h" -#include "Framework/DataTypes.h" #include "CommonConstants/PhysicsConstants.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "Framework/DataTypes.h" +#include "Framework/Logger.h" + +#include "Math/Vector4D.h" +#include "TNamed.h" + +#include +#include +#include +#include +#include using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; using namespace o2::aod::pwgem::dilepton::utils::pairutil; @@ -64,7 +65,7 @@ class DielectronCut : public TNamed kDCAz, kITSNCls, kITSChi2NDF, - kITSClusterSize, + // kITSClusterSize, kPrefilter, kNCuts }; @@ -77,7 +78,8 @@ class DielectronCut : public TNamed kTPConly = 3, kTOFif = 4, kPIDML = 5, - kTPChadrejORTOFreq_woTOFif = 6 + kTPChadrejORTOFreq_woTOFif = 6, + kTPChadrejORTOFreqLowB = 7, }; template @@ -99,7 +101,7 @@ class DielectronCut : public TNamed } template - bool IsSelectedPair(TTrack1 const& t1, TTrack2 const& t2, const float bz) const + bool IsSelectedPair(TTrack1 const& t1, TTrack2 const& t2, const float bz, const float refR) const { ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassElectron); @@ -135,6 +137,10 @@ class DielectronCut : public TNamed return false; } + if (mApplydEtadPhi && mApplydEtadPhiPosition) { // applying both cuts is not allowed. + return false; + } + float deta = v1.Eta() - v2.Eta(); float dphi = v1.Phi() - v2.Phi(); o2::math_utils::bringToPMPi(dphi); @@ -142,13 +148,24 @@ class DielectronCut : public TNamed return false; } + float phiPosition1 = t1.phi() + std::asin(t1.sign() * 0.30282 * (bz * 0.1) * refR / (2.f * t1.pt())); + float phiPosition2 = t2.phi() + std::asin(t2.sign() * 0.30282 * (bz * 0.1) * refR / (2.f * t2.pt())); + + phiPosition1 = RecoDecay::constrainAngle(phiPosition1, 0, 1); // 0-2pi + phiPosition2 = RecoDecay::constrainAngle(phiPosition2, 0, 1); // 0-2pi + float dphiPosition = phiPosition1 - phiPosition2; + o2::math_utils::bringToPMPi(dphiPosition); + if (mApplydEtadPhiPosition && std::pow(deta / mMinDeltaEta, 2) + std::pow(dphiPosition / mMinDeltaPhi, 2) < 1.f) { + return false; + } + return true; } template bool IsSelectedTrack(TTrack const& track, TCollision const& collision = 0) const { - if (!track.hasITS() || !track.hasTPC()) { // track has to be ITS-TPC matched track + if (!track.hasITS()) { return false; } @@ -181,9 +198,10 @@ class DielectronCut : public TNamed if (!IsSelectedTrack(track, DielectronCuts::kITSChi2NDF)) { return false; } - if (!IsSelectedTrack(track, DielectronCuts::kITSClusterSize)) { - return false; - } + + // if (!IsSelectedTrack(track, DielectronCuts::kITSClusterSize)) { + // return false; + // } if (mRequireITSibAny) { auto hits_ib = std::count_if(its_ib_any_Requirement.second.begin(), its_ib_any_Requirement.second.end(), [&](auto&& requiredLayer) { return track.itsClusterMap() & (1 << requiredLayer); }); @@ -199,24 +217,34 @@ class DielectronCut : public TNamed } } - // TPC cuts - if (!IsSelectedTrack(track, DielectronCuts::kTPCNCls)) { + if (!mIncludeITSsa && (!track.hasITS() || !track.hasTPC())) { // track has to be ITS-TPC matched track return false; } - if (!IsSelectedTrack(track, DielectronCuts::kTPCCrossedRows)) { - return false; - } - if (!IsSelectedTrack(track, DielectronCuts::kTPCCrossedRowsOverNCls)) { - return false; - } - if (!IsSelectedTrack(track, DielectronCuts::kTPCFracSharedClusters)) { - return false; - } - if (!IsSelectedTrack(track, DielectronCuts::kRelDiffPin)) { + + if ((track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF()) && track.pt() > mMaxPtITSsa) { // ITSsa return false; } - if (!IsSelectedTrack(track, DielectronCuts::kTPCChi2NDF)) { - return false; + + // TPC cuts + if (track.hasTPC()) { + if (!IsSelectedTrack(track, DielectronCuts::kTPCNCls)) { + return false; + } + if (!IsSelectedTrack(track, DielectronCuts::kTPCCrossedRows)) { + return false; + } + if (!IsSelectedTrack(track, DielectronCuts::kTPCCrossedRowsOverNCls)) { + return false; + } + if (!IsSelectedTrack(track, DielectronCuts::kTPCFracSharedClusters)) { + return false; + } + if (!IsSelectedTrack(track, DielectronCuts::kRelDiffPin)) { + return false; + } + if (!IsSelectedTrack(track, DielectronCuts::kTPCChi2NDF)) { + return false; + } } if (mApplyPF && !IsSelectedTrack(track, DielectronCuts::kPrefilter)) { @@ -229,8 +257,15 @@ class DielectronCut : public TNamed return false; } } else { - if (!PassPID(track)) { - return false; + if (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF()) { // ITSsa + float meanClusterSizeITS = track.meanClusterSizeITS() * std::cos(std::atan(track.tgl())); + if (meanClusterSizeITS < mMinMeanClusterSizeITS || mMaxMeanClusterSizeITS < meanClusterSizeITS) { + return false; + } + } else { // not ITSsa + if (!PassPID(track)) { + return false; + } } } @@ -238,14 +273,15 @@ class DielectronCut : public TNamed } template - bool PassPIDML(TTrack const& track, TCollision const& collision) const + bool PassPIDML(TTrack const&, TCollision const&) const { + return false; /*if (!PassTOFif(track)) { // Allows for pre-selection. But potentially dangerous if analyzers are not aware of it return false; }*/ - std::vector inputFeatures = mPIDMlResponse->getInputFeatures(track, collision); - float binningFeature = mPIDMlResponse->getBinningFeature(track, collision); - return mPIDMlResponse->isSelectedMl(inputFeatures, binningFeature); + // std::vector inputFeatures = mPIDMlResponse->getInputFeatures(track, collision); + // float binningFeature = mPIDMlResponse->getBinningFeature(track, collision); + // return mPIDMlResponse->isSelectedMl(inputFeatures, binningFeature); } template @@ -261,6 +297,9 @@ class DielectronCut : public TNamed case static_cast(PIDSchemes::kTPChadrejORTOFreq): return PassTPChadrej(track) || PassTOFreq(track); + case static_cast(PIDSchemes::kTPChadrejORTOFreqLowB): + return PassTPChadrej(track) || PassTOFreqLowB(track); + case static_cast(PIDSchemes::kTPConly): return PassTPConly(track); @@ -281,51 +320,62 @@ class DielectronCut : public TNamed } } + template + bool PassTOFreqLowB(T const& track) const + { + bool is_el_included_TPC = mMinTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < mMaxTPCNsigmaEl; + bool is_pi_excluded_TPC = (track.tpcInnerParam() > mMinPinForPionRejectionTPC && track.tpcInnerParam() < mMaxPinForPionRejectionTPC) ? (track.tpcNSigmaPi() < mMinTPCNsigmaPi || mMaxTPCNsigmaPi < track.tpcNSigmaPi()) : true; + bool is_el_included_TOF = (mMinTOFNsigmaEl < track.tofNSigmaEl() && track.tofNSigmaEl() < mMaxTOFNsigmaEl) && (track.hasTOF() && track.tofChi2() < mMaxChi2TOF); + // bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; + // bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; + return is_el_included_TPC && is_pi_excluded_TPC && is_el_included_TOF; + } + template bool PassTOFreq(T const& track) const { bool is_el_included_TPC = mMinTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < mMaxTPCNsigmaEl; bool is_pi_excluded_TPC = track.tpcInnerParam() < mMaxPinForPionRejectionTPC ? (track.tpcNSigmaPi() < mMinTPCNsigmaPi || mMaxTPCNsigmaPi < track.tpcNSigmaPi()) : true; bool is_el_included_TOF = (mMinTOFNsigmaEl < track.tofNSigmaEl() && track.tofNSigmaEl() < mMaxTOFNsigmaEl) && (track.hasTOF() && track.tofChi2() < mMaxChi2TOF); - bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; - bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; - return is_el_included_TPC && is_pi_excluded_TPC && is_el_included_TOF && is_ka_excluded_ITS && is_pr_excluded_ITS; + // bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; + // bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; + return is_el_included_TPC && is_pi_excluded_TPC && is_el_included_TOF; } template bool PassTPChadrej(T const& track) const { bool is_el_included_TPC = mMinTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < mMaxTPCNsigmaEl; - bool is_mu_excluded_TPC = mMuonExclusionTPC ? track.tpcNSigmaMu() < mMinTPCNsigmaMu || mMaxTPCNsigmaMu < track.tpcNSigmaMu() : true; + // bool is_mu_excluded_TPC = mMuonExclusionTPC ? track.tpcNSigmaMu() < mMinTPCNsigmaMu || mMaxTPCNsigmaMu < track.tpcNSigmaMu() : true; bool is_pi_excluded_TPC = track.tpcInnerParam() < mMaxPinForPionRejectionTPC ? (track.tpcNSigmaPi() < mMinTPCNsigmaPi || mMaxTPCNsigmaPi < track.tpcNSigmaPi()) : true; bool is_ka_excluded_TPC = track.tpcNSigmaKa() < mMinTPCNsigmaKa || mMaxTPCNsigmaKa < track.tpcNSigmaKa(); bool is_pr_excluded_TPC = track.tpcNSigmaPr() < mMinTPCNsigmaPr || mMaxTPCNsigmaPr < track.tpcNSigmaPr(); bool is_el_included_TOF = track.hasTOF() ? (mMinTOFNsigmaEl < track.tofNSigmaEl() && track.tofNSigmaEl() < mMaxTOFNsigmaEl && track.tofChi2() < mMaxChi2TOF) : true; - bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; - bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; - return is_el_included_TPC && is_mu_excluded_TPC && is_pi_excluded_TPC && is_ka_excluded_TPC && is_pr_excluded_TPC && is_el_included_TOF && is_ka_excluded_ITS && is_pr_excluded_ITS; + // bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; + // bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; + return is_el_included_TPC && is_pi_excluded_TPC && is_ka_excluded_TPC && is_pr_excluded_TPC && is_el_included_TOF; } template bool PassTPConly(T const& track) const { bool is_el_included_TPC = mMinTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < mMaxTPCNsigmaEl; - bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; - bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; - return is_el_included_TPC && is_ka_excluded_ITS && is_pr_excluded_ITS; + // bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; + // bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; + return is_el_included_TPC; } template bool PassTPConlyhadrej(T const& track) const { bool is_el_included_TPC = mMinTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < mMaxTPCNsigmaEl; - bool is_mu_excluded_TPC = mMuonExclusionTPC ? track.tpcNSigmaMu() < mMinTPCNsigmaMu || mMaxTPCNsigmaMu < track.tpcNSigmaMu() : true; + // bool is_mu_excluded_TPC = mMuonExclusionTPC ? track.tpcNSigmaMu() < mMinTPCNsigmaMu || mMaxTPCNsigmaMu < track.tpcNSigmaMu() : true; bool is_pi_excluded_TPC = track.tpcInnerParam() < mMaxPinForPionRejectionTPC ? (track.tpcNSigmaPi() < mMinTPCNsigmaPi || mMaxTPCNsigmaPi < track.tpcNSigmaPi()) : true; bool is_ka_excluded_TPC = track.tpcNSigmaKa() < mMinTPCNsigmaKa || mMaxTPCNsigmaKa < track.tpcNSigmaKa(); bool is_pr_excluded_TPC = track.tpcNSigmaPr() < mMinTPCNsigmaPr || mMaxTPCNsigmaPr < track.tpcNSigmaPr(); - bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; - bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; - return is_el_included_TPC && is_mu_excluded_TPC && is_pi_excluded_TPC && is_ka_excluded_TPC && is_pr_excluded_TPC && is_ka_excluded_ITS && is_pr_excluded_ITS; + // bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; + // bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; + return is_el_included_TPC && is_pi_excluded_TPC && is_ka_excluded_TPC && is_pr_excluded_TPC; } template @@ -334,9 +384,9 @@ class DielectronCut : public TNamed bool is_el_included_TPC = mMinTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < mMaxTPCNsigmaEl; bool is_pi_excluded_TPC = track.tpcInnerParam() < mMaxPinForPionRejectionTPC ? (track.tpcNSigmaPi() < mMinTPCNsigmaPi || mMaxTPCNsigmaPi < track.tpcNSigmaPi()) : true; bool is_el_included_TOF = track.hasTOF() ? (mMinTOFNsigmaEl < track.tofNSigmaEl() && track.tofNSigmaEl() < mMaxTOFNsigmaEl && track.tofChi2() < mMaxChi2TOF) : true; - bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; - bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; - return is_el_included_TPC && is_pi_excluded_TPC && is_el_included_TOF && is_ka_excluded_ITS && is_pr_excluded_ITS; + // bool is_ka_excluded_ITS = (mMinP_ITSNsigmaKa < track.p() && track.p() < mMaxP_ITSNsigmaKa) ? (track.itsNSigmaKa() < mMinITSNsigmaKa || mMaxITSNsigmaKa < track.itsNSigmaKa()) : true; + // bool is_pr_excluded_ITS = (mMinP_ITSNsigmaPr < track.p() && track.p() < mMaxP_ITSNsigmaPr) ? (track.itsNSigmaPr() < mMinITSNsigmaPr || mMaxITSNsigmaPr < track.itsNSigmaPr()) : true; + return is_el_included_TPC && is_pi_excluded_TPC && is_el_included_TOF; } template @@ -344,13 +394,21 @@ class DielectronCut : public TNamed { switch (cut) { case DielectronCuts::kTrackPtRange: - return track.pt() >= mMinTrackPt && track.pt() <= mMaxTrackPt; + return track.pt() > mMinTrackPt && track.pt() < mMaxTrackPt; case DielectronCuts::kTrackEtaRange: - return track.eta() >= mMinTrackEta && track.eta() <= mMaxTrackEta; + return track.eta() > mMinTrackEta && track.eta() < mMaxTrackEta; case DielectronCuts::kTrackPhiRange: - return track.phi() >= mMinTrackPhi && track.phi() <= mMaxTrackPhi; + if (!mMirrorTrackPhi) { + bool is_in_phi_range = track.phi() > mMinTrackPhi && track.phi() < mMaxTrackPhi; + return mRejectTrackPhi ? !is_in_phi_range : is_in_phi_range; + } else { + double minTrackPhiMirror = mMinTrackPhi + TMath::Pi(); + double maxTrackPhiMirror = mMaxTrackPhi + TMath::Pi(); + bool is_in_phi_range = (track.phi() > mMinTrackPhi && track.phi() < mMaxTrackPhi) || (track.phi() > minTrackPhiMirror && track.phi() < maxTrackPhiMirror); + return mRejectTrackPhi ? !is_in_phi_range : is_in_phi_range; + } case DielectronCuts::kTPCNCls: return track.tpcNClsFound() >= mMinNClustersTPC; @@ -359,10 +417,10 @@ class DielectronCut : public TNamed return track.tpcNClsCrossedRows() >= mMinNCrossedRowsTPC; case DielectronCuts::kTPCCrossedRowsOverNCls: - return track.tpcCrossedRowsOverFindableCls() >= mMinNCrossedRowsOverFindableClustersTPC; + return track.tpcCrossedRowsOverFindableCls() > mMinNCrossedRowsOverFindableClustersTPC; case DielectronCuts::kTPCFracSharedClusters: - return track.tpcFractionSharedCls() <= mMaxFracSharedClustersTPC; + return track.tpcFractionSharedCls() < mMaxFracSharedClustersTPC; case DielectronCuts::kRelDiffPin: return mMinRelDiffPin < (track.tpcInnerParam() - track.p()) / track.p() && (track.tpcInnerParam() - track.p()) / track.p() < mMaxRelDiffPin; @@ -371,13 +429,13 @@ class DielectronCut : public TNamed return mMinChi2PerClusterTPC < track.tpcChi2NCl() && track.tpcChi2NCl() < mMaxChi2PerClusterTPC; case DielectronCuts::kDCA3Dsigma: - return mMinDca3D <= dca3DinSigma(track) && dca3DinSigma(track) <= mMaxDca3D; // in sigma for single leg + return mMinDca3D < dca3DinSigma(track) && dca3DinSigma(track) < mMaxDca3D; // in sigma for single leg case DielectronCuts::kDCAxy: - return abs(track.dcaXY()) <= ((mMaxDcaXYPtDep) ? mMaxDcaXYPtDep(track.pt()) : mMaxDcaXY); + return std::fabs(track.dcaXY()) < ((mMaxDcaXYPtDep) ? mMaxDcaXYPtDep(track.pt()) : mMaxDcaXY); case DielectronCuts::kDCAz: - return abs(track.dcaZ()) <= mMaxDcaZ; + return std::fabs(track.dcaZ()) < mMaxDcaZ; case DielectronCuts::kITSNCls: return mMinNClustersITS <= track.itsNCls() && track.itsNCls() <= mMaxNClustersITS; @@ -385,9 +443,6 @@ class DielectronCut : public TNamed case DielectronCuts::kITSChi2NDF: return mMinChi2PerClusterITS < track.itsChi2NCl() && track.itsChi2NCl() < mMaxChi2PerClusterITS; - case DielectronCuts::kITSClusterSize: - return ((mMinP_ITSClusterSize < track.p() && track.p() < mMaxP_ITSClusterSize) ? (mMinMeanClusterSizeITS < track.meanClusterSizeITS() * std::cos(std::atan(track.tgl())) && track.meanClusterSizeITS() * std::cos(std::atan(track.tgl())) < mMaxMeanClusterSizeITS) : true); - case DielectronCuts::kPrefilter: return track.pfb() <= 0; @@ -404,12 +459,12 @@ class DielectronCut : public TNamed void SetPairOpAng(float minOpAng = 0.f, float maxOpAng = 1e10f); void SetMaxMeePhiVDep(std::function phivDepCut, float min_phiv, float max_phiv); void SelectPhotonConversion(bool flag); - void SetMindEtadPhi(bool flag, float min_deta, float min_dphi); + void SetMindEtadPhi(bool applydEtadPhi, bool applydEtadPhiPosition, float min_deta, float min_dphi); void SetRequireDifferentSides(bool flag); void SetTrackPtRange(float minPt = 0.f, float maxPt = 1e10f); void SetTrackEtaRange(float minEta = -1e10f, float maxEta = 1e10f); - void SetTrackPhiRange(float minPhi = 0.f, float maxPhi = 2.f * M_PI); + void SetTrackPhiRange(float minPhi = 0.f, float maxPhi = 2.f * M_PI, bool mirror = false, bool reject = false); void SetMinNClustersTPC(int minNClustersTPC); void SetMinNCrossedRowsTPC(int minNCrossedRowsTPC); void SetMinNCrossedRowsOverFindableClustersTPC(float minNCrossedRowsOverFindableClustersTPC); @@ -418,7 +473,7 @@ class DielectronCut : public TNamed void SetChi2PerClusterTPC(float min, float max); void SetNClustersITS(int min, int max); void SetChi2PerClusterITS(float min, float max); - void SetMeanClusterSizeITS(float min, float max, float minP = 0.f, float maxP = 0.f); + void SetMeanClusterSizeITS(float min, float max); void SetChi2TOF(float min, float max); void SetPIDScheme(int scheme); @@ -426,26 +481,26 @@ class DielectronCut : public TNamed void SetMuonExclusionTPC(bool flag); void SetTOFbetaRange(float min, float max); void SetTPCNsigmaElRange(float min, float max); - void SetTPCNsigmaMuRange(float min, float max); + // void SetTPCNsigmaMuRange(float min, float max); void SetTPCNsigmaPiRange(float min, float max); void SetTPCNsigmaKaRange(float min, float max); void SetTPCNsigmaPrRange(float min, float max); void SetTOFNsigmaElRange(float min, float max); - void SetTOFNsigmaMuRange(float min, float max); + // void SetTOFNsigmaMuRange(float min, float max); void SetTOFNsigmaPiRange(float min, float max); void SetTOFNsigmaKaRange(float min, float max); void SetTOFNsigmaPrRange(float min, float max); - void SetITSNsigmaElRange(float min, float max); - void SetITSNsigmaMuRange(float min, float max); - void SetITSNsigmaPiRange(float min, float max); - void SetITSNsigmaKaRange(float min, float max); - void SetITSNsigmaPrRange(float min, float max); + // void SetITSNsigmaElRange(float min, float max); + // void SetITSNsigmaMuRange(float min, float max); + // void SetITSNsigmaPiRange(float min, float max); + // void SetITSNsigmaKaRange(float min, float max); + // void SetITSNsigmaPrRange(float min, float max); - void SetPRangeForITSNsigmaKa(float min, float max); - void SetPRangeForITSNsigmaPr(float min, float max); + // void SetPRangeForITSNsigmaKa(float min, float max); + // void SetPRangeForITSNsigmaPr(float min, float max); void SetMaxPinMuonTPConly(float max); - void SetMaxPinForPionRejectionTPC(float max); + void SetPinRangeForPionRejectionTPC(float min, float max); void RequireITSibAny(bool flag); void RequireITSib1st(bool flag); @@ -455,6 +510,7 @@ class DielectronCut : public TNamed void SetTrackMaxDcaXYPtDep(std::function ptDepCut); void ApplyPrefilter(bool flag); void ApplyPhiV(bool flag); + void IncludeITSsa(bool flag, float maxpt); void SetPIDMlResponse(o2::analysis::MlResponseDielectronSingleTrack* mlResponse) { @@ -476,27 +532,29 @@ class DielectronCut : public TNamed std::function mMaxMeePhiVDep{}; // max mee as a function of phiv bool mSelectPC{false}; // flag to select photon conversion used in mMaxPhivPairMeeDep bool mApplydEtadPhi{false}; // flag to apply deta, dphi cut between 2 tracks + bool mApplydEtadPhiPosition{false}; // flag to apply deta, dphi cut between 2 tracks float mMinDeltaEta{0.f}; float mMinDeltaPhi{0.f}; float mMinOpAng{0.f}, mMaxOpAng{1e10f}; bool mRequireDiffSides{false}; // flag to require 2 tracks to be from different sides. (A-C combination). If one wants 2 tracks to be in the same side (A-A or C-C), one can simply use track eta cut. // kinematic cuts - float mMinTrackPt{0.f}, mMaxTrackPt{1e10f}; // range in pT - float mMinTrackEta{-1e10f}, mMaxTrackEta{1e10f}; // range in eta - float mMinTrackPhi{0.f}, mMaxTrackPhi{2.f * M_PI}; // range in phi + float mMinTrackPt{0.f}, mMaxTrackPt{1e10f}; // range in pT + float mMinTrackEta{-1e10f}, mMaxTrackEta{1e10f}; // range in eta + float mMinTrackPhi{0.f}, mMaxTrackPhi{2.f * M_PI}; // range in phi + bool mMirrorTrackPhi{false}, mRejectTrackPhi{false}; // phi cut mirror by Pi, rejected/accepted // track quality cuts - int mMinNClustersTPC{0}; // min number of TPC clusters - int mMinNCrossedRowsTPC{0}; // min number of crossed rows in TPC - float mMinChi2PerClusterTPC{-1e10f}, mMaxChi2PerClusterTPC{1e10f}; // max tpc fit chi2 per TPC cluster - float mMinNCrossedRowsOverFindableClustersTPC{0.f}; // min ratio crossed rows / findable clusters - float mMaxFracSharedClustersTPC{999.f}; // max ratio shared clusters / clusters in TPC - float mMinRelDiffPin{-1e10f}, mMaxRelDiffPin{1e10f}; // max relative difference between p at TPC inner wall and p at PV - int mMinNClustersITS{0}, mMaxNClustersITS{7}; // range in number of ITS clusters - float mMinChi2PerClusterITS{-1e10f}, mMaxChi2PerClusterITS{1e10f}; // max its fit chi2 per ITS cluster - float mMaxPinMuonTPConly{0.2f}; // max pin cut for muon ID with TPConly - float mMaxPinForPionRejectionTPC{1e10f}; // max pin for pion rejection in TPC + int mMinNClustersTPC{0}; // min number of TPC clusters + int mMinNCrossedRowsTPC{0}; // min number of crossed rows in TPC + float mMinChi2PerClusterTPC{-1e10f}, mMaxChi2PerClusterTPC{1e10f}; // max tpc fit chi2 per TPC cluster + float mMinNCrossedRowsOverFindableClustersTPC{0.f}; // min ratio crossed rows / findable clusters + float mMaxFracSharedClustersTPC{999.f}; // max ratio shared clusters / clusters in TPC + float mMinRelDiffPin{-1e10f}, mMaxRelDiffPin{1e10f}; // max relative difference between p at TPC inner wall and p at PV + int mMinNClustersITS{0}, mMaxNClustersITS{7}; // range in number of ITS clusters + float mMinChi2PerClusterITS{-1e10f}, mMaxChi2PerClusterITS{1e10f}; // max its fit chi2 per ITS cluster + float mMaxPinMuonTPConly{0.2f}; // max pin cut for muon ID with TPConly + float mMinPinForPionRejectionTPC{0.f}, mMaxPinForPionRejectionTPC{1e10f}; // pin range for pion rejection in TPC bool mRequireITSibAny{true}; bool mRequireITSib1st{false}; float mMinChi2TOF{-1e10f}, mMaxChi2TOF{1e10f}; // max tof chi2 per @@ -508,8 +566,10 @@ class DielectronCut : public TNamed std::function mMaxDcaXYPtDep{}; // max dca in xy plane as function of pT bool mApplyPhiV{true}; bool mApplyPF{false}; - float mMinMeanClusterSizeITS{-1e10f}, mMaxMeanClusterSizeITS{1e10f}; // max x cos(Lmabda) - float mMinP_ITSClusterSize{0.0}, mMaxP_ITSClusterSize{0.0}; + float mMinMeanClusterSizeITS{0.0}, mMaxMeanClusterSizeITS{1e10f}; // x cos(lmabda) + // float mMinP_ITSClusterSize{0.0}, mMaxP_ITSClusterSize{0.0}; + bool mIncludeITSsa{false}; + float mMaxPtITSsa{0.15}; // pid cuts int mPIDScheme{-1}; @@ -517,24 +577,24 @@ class DielectronCut : public TNamed bool mMuonExclusionTPC{false}; // flag to reject muon in TPC for low B float mMinTOFbeta{-999}, mMaxTOFbeta{999}; float mMinTPCNsigmaEl{-1e+10}, mMaxTPCNsigmaEl{+1e+10}; - float mMinTPCNsigmaMu{-1e+10}, mMaxTPCNsigmaMu{+1e+10}; + // float mMinTPCNsigmaMu{-1e+10}, mMaxTPCNsigmaMu{+1e+10}; float mMinTPCNsigmaPi{-1e+10}, mMaxTPCNsigmaPi{+1e+10}; float mMinTPCNsigmaKa{-1e+10}, mMaxTPCNsigmaKa{+1e+10}; float mMinTPCNsigmaPr{-1e+10}, mMaxTPCNsigmaPr{+1e+10}; float mMinTOFNsigmaEl{-1e+10}, mMaxTOFNsigmaEl{+1e+10}; - float mMinTOFNsigmaMu{-1e+10}, mMaxTOFNsigmaMu{+1e+10}; + // float mMinTOFNsigmaMu{-1e+10}, mMaxTOFNsigmaMu{+1e+10}; float mMinTOFNsigmaPi{-1e+10}, mMaxTOFNsigmaPi{+1e+10}; float mMinTOFNsigmaKa{-1e+10}, mMaxTOFNsigmaKa{+1e+10}; float mMinTOFNsigmaPr{-1e+10}, mMaxTOFNsigmaPr{+1e+10}; - float mMinITSNsigmaEl{-1e+10}, mMaxITSNsigmaEl{+1e+10}; - float mMinITSNsigmaMu{-1e+10}, mMaxITSNsigmaMu{+1e+10}; - float mMinITSNsigmaPi{-1e+10}, mMaxITSNsigmaPi{+1e+10}; - float mMinITSNsigmaKa{-1e+10}, mMaxITSNsigmaKa{+1e+10}; - float mMinITSNsigmaPr{-1e+10}, mMaxITSNsigmaPr{+1e+10}; - float mMinP_ITSNsigmaKa{0.0}, mMaxP_ITSNsigmaKa{0.0}; - float mMinP_ITSNsigmaPr{0.0}, mMaxP_ITSNsigmaPr{0.0}; + // float mMinITSNsigmaEl{-1e+10}, mMaxITSNsigmaEl{+1e+10}; + // float mMinITSNsigmaMu{-1e+10}, mMaxITSNsigmaMu{+1e+10}; + // float mMinITSNsigmaPi{-1e+10}, mMaxITSNsigmaPi{+1e+10}; + // float mMinITSNsigmaKa{-1e+10}, mMaxITSNsigmaKa{+1e+10}; + // float mMinITSNsigmaPr{-1e+10}, mMaxITSNsigmaPr{+1e+10}; + // float mMinP_ITSNsigmaKa{0.0}, mMaxP_ITSNsigmaKa{0.0}; + // float mMinP_ITSNsigmaPr{0.0}, mMaxP_ITSNsigmaPr{0.0}; o2::analysis::MlResponseDielectronSingleTrack* mPIDMlResponse{nullptr}; diff --git a/PWGEM/Dilepton/Core/Dilepton.h b/PWGEM/Dilepton/Core/Dilepton.h index af2da40268c..531a1eb1043 100644 --- a/PWGEM/Dilepton/Core/Dilepton.h +++ b/PWGEM/Dilepton/Core/Dilepton.h @@ -17,48 +17,48 @@ #ifndef PWGEM_DILEPTON_CORE_DILEPTON_H_ #define PWGEM_DILEPTON_CORE_DILEPTON_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include "TH1D.h" -#include "TString.h" -#include "Math/Vector4D.h" +#include "PWGEM/Dilepton/Core/DielectronCut.h" +#include "PWGEM/Dilepton/Core/DimuonCut.h" +#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/EMFwdTrack.h" +#include "PWGEM/Dilepton/Utils/EMTrack.h" +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/Utils/EventMixingHandler.h" +#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" +#include "Common/CCDB/RCTSelectionFlags.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "DCAFitter/DCAFitterN.h" -#include "DCAFitter/FwdDCAFitterN.h" +#include "Tools/ML/MlResponse.h" + +#include "CCDB/BasicCCDBManager.h" #include "CommonConstants/LHCConstants.h" -#include "DataFormatsParameters/GRPLHCIFData.h" #include "DataFormatsParameters/GRPECSObject.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" #include "MathUtils/Utils.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Tools/ML/MlResponse.h" +#include "Math/Vector4D.h" +#include "TH1D.h" +#include "TString.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" -#include "PWGEM/Dilepton/Core/DielectronCut.h" -#include "PWGEM/Dilepton/Core/DimuonCut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.h" -#include "PWGEM/Dilepton/Utils/EMTrack.h" -#include "PWGEM/Dilepton/Utils/EMFwdTrack.h" -#include "PWGEM/Dilepton/Utils/EventMixingHandler.h" -#include "PWGEM/Dilepton/Utils/EventHistograms.h" -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -75,18 +75,18 @@ using MyCollision = MyCollisions::iterator; using MyCollisionsWithSWT = soa::Join; using MyCollisionWithSWT = MyCollisionsWithSWT::iterator; -using MyElectrons = soa::Join; +using MyElectrons = soa::Join; using MyElectron = MyElectrons::iterator; using FilteredMyElectrons = soa::Filtered; using FilteredMyElectron = FilteredMyElectrons::iterator; -using MyMuons = soa::Join; +using MyMuons = soa::Join; using MyMuon = MyMuons::iterator; using FilteredMyMuons = soa::Filtered; using FilteredMyMuon = FilteredMyMuons::iterator; -using MyEMH_electron = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrackWithCov>; -using MyEMH_muon = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMFwdTrackWithCov>; +using MyEMH_electron = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrack>; +using MyEMH_muon = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMFwdTrack>; template struct Dilepton { @@ -110,7 +110,7 @@ struct Dilepton { Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; Configurable cfgDoMix{"cfgDoMix", true, "flag for event mixing"}; Configurable ndepth{"ndepth", 100, "depth for event mixing"}; - Configurable ndiff_bc_mix{"ndiff_bc_mix", 5, "difference in global BC required in mixed events"}; + Configurable ndiff_bc_mix{"ndiff_bc_mix", 594, "difference in global BC required in mixed events"}; ConfigurableAxis ConfVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.f, 999.f}, "Mixing bins - centrality"}; ConfigurableAxis ConfEPBins{"ConfEPBins", {16, -M_PI / 2, +M_PI / 2}, "Mixing bins - event plane angle"}; @@ -140,7 +140,8 @@ struct Dilepton { Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; - Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexTOFmatched{"cfgRequireVertexTOFmatched", false, "require Vertex TOFmatched in event cut"}; // ITS-TPC-TOF matched track contributes PV. Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; @@ -151,6 +152,14 @@ struct Dilepton { Configurable cfgRequireNoCollInITSROFStandard{"cfgRequireNoCollInITSROFStandard", false, "require no collision in time range standard"}; Configurable cfgRequireNoCollInITSROFStrict{"cfgRequireNoCollInITSROFStrict", false, "require no collision in time range strict"}; Configurable cfgRequireNoHighMultCollInPrevRof{"cfgRequireNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + Configurable cfgRequireGoodITSLayer3{"cfgRequireGoodITSLayer3", false, "number of inactive chips on ITS layer 3 are below threshold "}; + Configurable cfgRequireGoodITSLayer0123{"cfgRequireGoodITSLayer0123", false, "number of inactive chips on ITS layers 0-3 are below threshold "}; + Configurable cfgRequireGoodITSLayersAll{"cfgRequireGoodITSLayersAll", false, "number of inactive chips on all ITS layers are below threshold "}; + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; } eventcuts; DielectronCut fDielectronCut; @@ -169,7 +178,8 @@ struct Dilepton { Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; Configurable cfg_min_phiv{"cfg_min_phiv", 0.0, "min phiv (constant)"}; Configurable cfg_max_phiv{"cfg_max_phiv", 3.2, "max phiv (constant)"}; - Configurable cfg_apply_detadphi{"cfg_apply_detadphi", false, "flag to apply deta-dphi elliptic cut"}; + Configurable cfg_apply_detadphi{"cfg_apply_detadphi", false, "flag to apply deta-dphi elliptic cut at PV"}; + Configurable cfg_apply_detadphiposition{"cfg_apply_detadphiposition", false, "flag to apply deta-dphi elliptic cut at certain radius"}; Configurable cfg_min_deta{"cfg_min_deta", 0.02, "min deta between 2 electrons (elliptic cut)"}; Configurable cfg_min_dphi{"cfg_min_dphi", 0.2, "min dphi between 2 electrons (elliptic cut)"}; Configurable cfg_min_opang{"cfg_min_opang", 0.0, "min opening angle"}; @@ -188,6 +198,8 @@ struct Dilepton { Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.8, "max eta for single track"}; Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "min phi for single track"}; Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; + Configurable cfg_mirror_phi_track{"cfg_mirror_phi_track", false, "mirror the phi cut around Pi, min and max Phi should be in 0-Pi"}; + Configurable cfg_reject_phi_track{"cfg_reject_phi_track", false, "reject the phi interval"}; Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 100, "min ncrossed rows"}; @@ -201,16 +213,15 @@ struct Dilepton { Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; Configurable cfg_min_its_cluster_size{"cfg_min_its_cluster_size", 0.f, "min ITS cluster size"}; Configurable cfg_max_its_cluster_size{"cfg_max_its_cluster_size", 16.f, "max ITS cluster size"}; - Configurable cfg_min_p_its_cluster_size{"cfg_min_p_its_cluster_size", 0.0, "min p to apply ITS cluster size cut"}; - Configurable cfg_max_p_its_cluster_size{"cfg_max_p_its_cluster_size", 0.0, "max p to apply ITS cluster size cut"}; Configurable cfg_min_rel_diff_pin{"cfg_min_rel_diff_pin", -1e+10, "min rel. diff. between pin and ppv"}; Configurable cfg_max_rel_diff_pin{"cfg_max_rel_diff_pin", +1e+10, "max rel. diff. between pin and ppv"}; + Configurable cfgRefR{"cfgRefR", 1.2, "reference R (in m) for extrapolation"}; // https://cds.cern.ch/record/1419204 Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3, kTOFif : 4, kPIDML : 5, kTPChadrejORTOFreq_woTOFif : 6]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; - Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; + // Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; + // Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -3.0, "min. TPC n sigma for kaon exclusion"}; @@ -219,16 +230,19 @@ struct Dilepton { Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +3.0, "max. TPC n sigma for proton exclusion"}; Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + Configurable cfg_min_pin_pirejTPC{"cfg_min_pin_pirejTPC", 0.f, "min. pin for pion rejection in TPC"}; Configurable cfg_max_pin_pirejTPC{"cfg_max_pin_pirejTPC", 1e+10, "max. pin for pion rejection in TPC"}; - Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; - Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; - Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; - Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; - Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; - Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; + // Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; + // Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; + // Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; + // Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; + // Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; + // Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; // configuration for PID ML Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; @@ -257,8 +271,8 @@ struct Dilepton { Configurable cfg_min_deta{"cfg_min_deta", 0.02, "min deta between 2 muons (elliptic cut)"}; Configurable cfg_min_dphi{"cfg_min_dphi", 0.02, "min dphi between 2 muons (elliptic cut)"}; - Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; - Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.1, "min pT for single track"}; + Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; Configurable cfg_min_eta_track{"cfg_min_eta_track", -4.0, "min eta for single track"}; Configurable cfg_max_eta_track{"cfg_max_eta_track", -2.5, "max eta for single track"}; @@ -266,21 +280,25 @@ struct Dilepton { Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; Configurable cfg_min_ncluster_mft{"cfg_min_ncluster_mft", 5, "min ncluster MFT"}; Configurable cfg_min_ncluster_mch{"cfg_min_ncluster_mch", 5, "min ncluster MCH"}; - Configurable cfg_max_chi2{"cfg_max_chi2", 1e+10, "max chi2"}; - Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 1e+10, "max chi2 for MFT-MCH matching"}; + Configurable cfg_max_chi2{"cfg_max_chi2", 1e+6, "max chi2"}; + Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 40, "max chi2 for MFT-MCH matching"}; Configurable cfg_max_matching_chi2_mchmid{"cfg_max_matching_chi2_mchmid", 1e+10, "max chi2 for MCH-MID matching"}; Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1e+10, "max dca XY for single track in cm"}; Configurable cfg_min_rabs{"cfg_min_rabs", 17.6, "min Radius at the absorber end"}; Configurable cfg_max_rabs{"cfg_max_rabs", 89.5, "max Radius at the absorber end"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable cfg_max_relDPt_wrt_matchedMCHMID{"cfg_max_relDPt_wrt_matchedMCHMID", 1e+10f, "max. relative dpt between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DEta_wrt_matchedMCHMID{"cfg_max_DEta_wrt_matchedMCHMID", 1e+10f, "max. deta between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DPhi_wrt_matchedMCHMID{"cfg_max_DPhi_wrt_matchedMCHMID", 1e+10f, "max. dphi between MFT-MCH-MID and MCH-MID"}; + Configurable requireMFTHitMap{"requireMFTHitMap", false, "flag to apply MFT hit map"}; + Configurable> requiredMFTDisks{"requiredMFTDisks", std::vector{0}, "hit map on MFT disks [0,1,2,3,4]. logical-OR of each double-sided disk"}; } dimuoncuts; + o2::aod::rctsel::RCTFlagsChecker rctChecker; o2::ccdb::CcdbApi ccdbApi; Service ccdb; int mRunNumber; float d_bz; - // o2::vertexing::DCAFitterN<2> fitter; - // o2::vertexing::FwdDCAFitterN<2> fwdfitter; o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; @@ -314,11 +332,12 @@ struct Dilepton { ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); + rctChecker.init(eventcuts.cfgRCTLabel.value, eventcuts.cfgCheckZDC.value, eventcuts.cfgTreatLimitedAcceptanceAsBad.value); if (ConfVtxBins.value[0] == VARIABLE_WIDTH) { zvtx_bin_edges = std::vector(ConfVtxBins.value.begin(), ConfVtxBins.value.end()); zvtx_bin_edges.erase(zvtx_bin_edges.begin()); - for (auto& edge : zvtx_bin_edges) { + for (const auto& edge : zvtx_bin_edges) { LOGF(info, "VARIABLE_WIDTH: zvtx_bin_edges = %f", edge); } } else { @@ -335,7 +354,7 @@ struct Dilepton { if (ConfCentBins.value[0] == VARIABLE_WIDTH) { cent_bin_edges = std::vector(ConfCentBins.value.begin(), ConfCentBins.value.end()); cent_bin_edges.erase(cent_bin_edges.begin()); - for (auto& edge : cent_bin_edges) { + for (const auto& edge : cent_bin_edges) { LOGF(info, "VARIABLE_WIDTH: cent_bin_edges = %f", edge); } } else { @@ -352,7 +371,7 @@ struct Dilepton { if (ConfEPBins.value[0] == VARIABLE_WIDTH) { ep_bin_edges = std::vector(ConfEPBins.value.begin(), ConfEPBins.value.end()); ep_bin_edges.erase(ep_bin_edges.begin()); - for (auto& edge : ep_bin_edges) { + for (const auto& edge : ep_bin_edges) { LOGF(info, "VARIABLE_WIDTH: ep_bin_edges = %f", edge); } } else { @@ -370,7 +389,7 @@ struct Dilepton { if (ConfOccupancyBins.value[0] == VARIABLE_WIDTH) { occ_bin_edges = std::vector(ConfOccupancyBins.value.begin(), ConfOccupancyBins.value.end()); occ_bin_edges.erase(occ_bin_edges.begin()); - for (auto& edge : occ_bin_edges) { + for (const auto& edge : occ_bin_edges) { LOGF(info, "VARIABLE_WIDTH: occ_bin_edges = %f", edge); } } else { @@ -393,33 +412,29 @@ struct Dilepton { DefineDielectronCut(); leptonM1 = o2::constants::physics::MassElectron; leptonM2 = o2::constants::physics::MassElectron; - // fitter.setPropagateToPCA(true); - // fitter.setMaxR(5.f); - // fitter.setMinParamChange(1e-3); - // fitter.setMinRelChi2Change(0.9); - // fitter.setMaxDZIni(1e9); - // fitter.setMaxChi2(1e9); - // fitter.setUseAbsDCA(true); - // fitter.setWeightedFinalPCA(false); - // fitter.setMatCorrType(matCorr); } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { DefineDimuonCut(); leptonM1 = o2::constants::physics::MassMuon; leptonM2 = o2::constants::physics::MassMuon; - // fwdfitter.setPropagateToPCA(true); - // fwdfitter.setMaxR(90.f); - // fwdfitter.setMinParamChange(1e-3); - // fwdfitter.setMinRelChi2Change(0.9); - // fwdfitter.setMaxChi2(1e9); - // fwdfitter.setUseAbsDCA(true); - // fwdfitter.setTGeoMat(false); } - fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter"); fRegistry.add("Pair/mix/hDiffBC", "diff. global BC in mixed event;|BC_{current} - BC_{mixed}|", kTH1D, {{10001, -0.5, 10000.5}}, true); + + if (doprocessNorm) { + fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter"); + } if (doprocessTriggerAnalysis) { fRegistry.add("Event/hNInspectedTVX", "N inspected TVX;run number;N_{TVX}", kTProfile, {{80000, 520000.5, 600000.5}}, true); } + if (doprocessBC) { + auto hTVXCounter = fRegistry.add("BC/hTVXCounter", "TVX counter", kTH1D, {{6, -0.5f, 5.5f}}); + hTVXCounter->GetXaxis()->SetBinLabel(1, "TVX"); + hTVXCounter->GetXaxis()->SetBinLabel(2, "TVX && NoTFB"); + hTVXCounter->GetXaxis()->SetBinLabel(3, "TVX && NoITSROFB"); + hTVXCounter->GetXaxis()->SetBinLabel(4, "TVX && GoodRCT"); + hTVXCounter->GetXaxis()->SetBinLabel(5, "TVX && NoTFB && NoITSROFB"); + hTVXCounter->GetXaxis()->SetBinLabel(6, "TVX && NoTFB && NoITSROFB && GoodRCT"); + } } template @@ -433,13 +448,11 @@ struct Dilepton { if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } o2::base::Propagator::initFieldFromGRP(&grpmag); mRunNumber = collision.runNumber(); - // fitter.setBz(d_bz); - // fwdfitter.setBz(d_bz); return; } @@ -452,7 +465,7 @@ struct Dilepton { o2::base::Propagator::initFieldFromGRP(grpo); // Fetch magnetic field from ccdb for current collision d_bz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kG"; } else { grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); if (!grpmag) { @@ -461,11 +474,9 @@ struct Dilepton { o2::base::Propagator::initFieldFromGRP(grpmag); // Fetch magnetic field from ccdb for current collision d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kG"; } mRunNumber = collision.runNumber(); - // fitter.setBz(d_bz); - // fwdfitter.setBz(d_bz); auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", collision.timestamp()); int beamZ1 = grplhcif->getBeamZ(o2::constants::lhc::BeamC); @@ -538,7 +549,9 @@ struct Dilepton { if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kQC)) { fRegistry.add("Pair/same/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca}, true); - fRegistry.add("Pair/same/uls/hDeltaEtaDeltaPhi", "#Delta#eta-#Delta#varphi between 2 tracks;#Delta#varphi (rad.);#Delta#eta;", kTH2D, {{180, -M_PI, M_PI}, {200, -1, +1}}, true); + fRegistry.add("Pair/same/uls/hDeltaEtaDeltaPhi", "#Delta#eta-#Delta#varphi between 2 tracks;#Delta#varphi (rad.);#Delta#eta;", kTH2D, {{180, -M_PI, M_PI}, {400, -2, +2}}, true); + fRegistry.add("Pair/same/uls/hDeltaEtaDeltaPhiPosition", "#Delta#eta-#Delta#varphi^{*} between 2 tracks;#Delta#varphi^{*} (rad.);#Delta#eta;", kTH2D, {{180, -M_PI, M_PI}, {400, -2, +2}}, true); + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { fRegistry.add("Pair/same/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi_{V} (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 1.0f}}, true); // phiv is only for dielectron fRegistry.add("Pair/same/uls/hMvsOpAng", "m_{ee} vs. angle between 2 tracks;#omega (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 1.0f}}, true); @@ -637,12 +650,16 @@ struct Dilepton { fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); + fEMEventCut.SetRequireVertexTOFmatched(eventcuts.cfgRequireVertexTOFmatched); fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); fEMEventCut.SetRequireNoHighMultCollInPrevRof(eventcuts.cfgRequireNoHighMultCollInPrevRof); + fEMEventCut.SetRequireGoodITSLayer3(eventcuts.cfgRequireGoodITSLayer3); + fEMEventCut.SetRequireGoodITSLayer0123(eventcuts.cfgRequireGoodITSLayer0123); + fEMEventCut.SetRequireGoodITSLayersAll(eventcuts.cfgRequireGoodITSLayersAll); } o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; @@ -657,14 +674,14 @@ struct Dilepton { fDielectronCut.SetPairDCARange(dielectroncuts.cfg_min_pair_dca3d, dielectroncuts.cfg_max_pair_dca3d); // in sigma fDielectronCut.SetMaxMeePhiVDep([&](float phiv) { return dielectroncuts.cfg_phiv_intercept + phiv * dielectroncuts.cfg_phiv_slope; }, dielectroncuts.cfg_min_phiv, dielectroncuts.cfg_max_phiv); fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); - fDielectronCut.SetMindEtadPhi(dielectroncuts.cfg_apply_detadphi, dielectroncuts.cfg_min_deta, dielectroncuts.cfg_min_dphi); + fDielectronCut.SetMindEtadPhi(dielectroncuts.cfg_apply_detadphi, dielectroncuts.cfg_apply_detadphiposition, dielectroncuts.cfg_min_deta, dielectroncuts.cfg_min_dphi); fDielectronCut.SetPairOpAng(dielectroncuts.cfg_min_opang, dielectroncuts.cfg_max_opang); fDielectronCut.SetRequireDifferentSides(dielectroncuts.cfg_require_diff_sides); // for track fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, dielectroncuts.cfg_max_pt_track); fDielectronCut.SetTrackEtaRange(dielectroncuts.cfg_min_eta_track, dielectroncuts.cfg_max_eta_track); - fDielectronCut.SetTrackPhiRange(dielectroncuts.cfg_min_phi_track, dielectroncuts.cfg_max_phi_track); + fDielectronCut.SetTrackPhiRange(dielectroncuts.cfg_min_phi_track, dielectroncuts.cfg_max_phi_track, dielectroncuts.cfg_mirror_phi_track, dielectroncuts.cfg_reject_phi_track); fDielectronCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); fDielectronCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); fDielectronCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); @@ -672,38 +689,39 @@ struct Dilepton { fDielectronCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); fDielectronCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); fDielectronCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size, dielectroncuts.cfg_min_p_its_cluster_size, dielectroncuts.cfg_max_p_its_cluster_size); + fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size); fDielectronCut.SetTrackMaxDcaXY(dielectroncuts.cfg_max_dcaxy); fDielectronCut.SetTrackMaxDcaZ(dielectroncuts.cfg_max_dcaz); fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); fDielectronCut.SetChi2TOF(0, dielectroncuts.cfg_max_chi2tof); fDielectronCut.SetRelDiffPin(dielectroncuts.cfg_min_rel_diff_pin, dielectroncuts.cfg_max_rel_diff_pin); + fDielectronCut.IncludeITSsa(dielectroncuts.includeITSsa, dielectroncuts.cfg_max_pt_track_ITSsa); // for eID fDielectronCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); fDielectronCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); + // fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); fDielectronCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); fDielectronCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); fDielectronCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); fDielectronCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); - fDielectronCut.SetMaxPinForPionRejectionTPC(dielectroncuts.cfg_max_pin_pirejTPC); - fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); - fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); - fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); - fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); + fDielectronCut.SetPinRangeForPionRejectionTPC(dielectroncuts.cfg_min_pin_pirejTPC, dielectroncuts.cfg_max_pin_pirejTPC); + // fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); + // fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); + // fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); + // fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut static constexpr int nClassesMl = 2; - const std::vector cutDirMl = {o2::cuts_ml::CutSmaller, o2::cuts_ml::CutNot}; - const std::vector labelsClasses = {"Signal", "Background"}; + const std::vector cutDirMl = {o2::cuts_ml::CutNot, o2::cuts_ml::CutSmaller}; + const std::vector labelsClasses = {"Background", "Signal"}; const uint32_t nBinsMl = dielectroncuts.binsMl.value.size() - 1; const std::vector labelsBins(nBinsMl, "bin"); double cutsMlArr[nBinsMl][nClassesMl]; for (uint32_t i = 0; i < nBinsMl; i++) { - cutsMlArr[i][0] = dielectroncuts.cutsMl.value[i]; - cutsMlArr[i][1] = 0.; + cutsMlArr[i][0] = 0.; + cutsMlArr[i][1] = dielectroncuts.cutsMl.value[i]; } o2::framework::LabeledArray cutsMl = {cutsMlArr[0], nBinsMl, nClassesMl, labelsBins, labelsClasses}; @@ -737,7 +755,7 @@ struct Dilepton { fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, dimuoncuts.cfg_max_pt_track); fDimuonCut.SetTrackEtaRange(dimuoncuts.cfg_min_eta_track, dimuoncuts.cfg_max_eta_track); - fDimuonCut.SetTrackEtaRange(dimuoncuts.cfg_min_phi_track, dimuoncuts.cfg_max_phi_track); + fDimuonCut.SetTrackPhiRange(dimuoncuts.cfg_min_phi_track, dimuoncuts.cfg_max_phi_track); fDimuonCut.SetNClustersMFT(dimuoncuts.cfg_min_ncluster_mft, 10); fDimuonCut.SetNClustersMCHMID(dimuoncuts.cfg_min_ncluster_mch, 16); fDimuonCut.SetChi2(0.f, dimuoncuts.cfg_max_chi2); @@ -746,14 +764,16 @@ struct Dilepton { fDimuonCut.SetDCAxy(0.f, dimuoncuts.cfg_max_dcaxy); fDimuonCut.SetRabs(dimuoncuts.cfg_min_rabs, dimuoncuts.cfg_max_rabs); fDimuonCut.SetMaxPDCARabsDep([&](float rabs) { return (rabs < 26.5 ? 594.f : 324.f); }); + fDimuonCut.SetMaxdPtdEtadPhiwrtMCHMID(dimuoncuts.cfg_max_relDPt_wrt_matchedMCHMID, dimuoncuts.cfg_max_DEta_wrt_matchedMCHMID, dimuoncuts.cfg_max_DPhi_wrt_matchedMCHMID); // this is relevant for global muons + fDimuonCut.SetMFTHitMap(dimuoncuts.requireMFTHitMap, dimuoncuts.requiredMFTDisks); } template bool isGoodQvector(TQvectors const& qvectors) { bool is_good = true; - for (auto& qn : qvectors[nmod]) { - if (fabs(qn[0]) > 20.f || fabs(qn[1]) > 20.f) { + for (const auto& qn : qvectors[nmod]) { + if (std::fabs(qn[0]) > 20.f || std::fabs(qn[1]) > 20.f) { is_good = false; break; } @@ -786,8 +806,8 @@ struct Dilepton { } } - template - bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut) + template + bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const& tracks) { if constexpr (ev_id == 1) { if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { @@ -825,26 +845,29 @@ struct Dilepton { } } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { + if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { + return false; + } + + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) { + return false; + } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) { return false; } } } if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - if (!cut.template IsSelectedPair(t1, t2, d_bz)) { + if (!cut.IsSelectedPair(t1, t2, d_bz, dielectroncuts.cfgRefR)) { return false; } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - if (!cut.template IsSelectedPair(t1, t2)) { + if (!cut.IsSelectedPair(t1, t2)) { return false; } } - // float pca = 999.f, lxy = 999.f; // in unit of cm - // o2::aod::pwgem::dilepton::utils::pairutil::isSVFound(fitter, collision, t1, t2, pca, lxy); - // o2::aod::pwgem::dilepton::utils::pairutil::isSVFoundFwd(fwdfitter, collision, t1, t2, pca, lxy); - float weight = 1.f; if (cfgApplyWeightTTCA) { weight = map_weight[std::make_pair(t1.globalIndex(), t2.globalIndex())]; @@ -888,36 +911,62 @@ struct Dilepton { float dphi = t1.sign() * v1.Pt() > t2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); o2::math_utils::bringToPMPi(dphi); + float phiPosition1 = t1.phi() + std::asin(t1.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * t1.pt())); + float phiPosition2 = t2.phi() + std::asin(t2.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * t2.pt())); + + phiPosition1 = RecoDecay::constrainAngle(phiPosition1, 0, 1); // 0-2pi + phiPosition2 = RecoDecay::constrainAngle(phiPosition2, 0, 1); // 0-2pi + float dphiPosition = t1.sign() * v1.Pt() > t2.sign() * v2.Pt() ? phiPosition1 - phiPosition2 : phiPosition2 - phiPosition1; + o2::math_utils::bringToPMPi(dphiPosition); + float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz(), t1.sign(), t2.sign(), d_bz); float opAng = o2::aod::pwgem::dilepton::utils::pairutil::getOpeningAngle(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz()); if (t1.sign() * t2.sign() < 0) { // ULS fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), pair_dca, weight); fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hDeltaEtaDeltaPhi"), dphi, deta, weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hDeltaEtaDeltaPhiPosition"), dphiPosition, deta, weight); if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsPhiV"), phiv, v12.M(), weight); fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsOpAng"), opAng, v12.M(), weight); + if (cfgDCAType == 1) { + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hDCA1vsDCA2"), dcaXYinSigma(t1), dcaXYinSigma(t2), weight); + } else if (cfgDCAType == 2) { + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hDCA1vsDCA2"), dcaZinSigma(t1), dcaZinSigma(t2), weight); + } } } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++ fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hs"), v12.M(), v12.Pt(), pair_dca, weight); fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hDeltaEtaDeltaPhi"), dphi, deta, weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hDeltaEtaDeltaPhiPosition"), dphiPosition, deta, weight); if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsPhiV"), phiv, v12.M(), weight); fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsOpAng"), opAng, v12.M(), weight); + if (cfgDCAType == 1) { + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hDCA1vsDCA2"), dcaXYinSigma(t1), dcaXYinSigma(t2), weight); + } else if (cfgDCAType == 2) { + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hDCA1vsDCA2"), dcaZinSigma(t1), dcaZinSigma(t2), weight); + } } } else if (t1.sign() < 0 && t2.sign() < 0) { // LS-- fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hs"), v12.M(), v12.Pt(), pair_dca, weight); fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hDeltaEtaDeltaPhi"), dphi, deta, weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hDeltaEtaDeltaPhiPosition"), dphiPosition, deta, weight); if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsPhiV"), phiv, v12.M(), weight); fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsOpAng"), opAng, v12.M(), weight); + if (cfgDCAType == 1) { + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hDCA1vsDCA2"), dcaXYinSigma(t1), dcaXYinSigma(t2), weight); + } else if (cfgDCAType == 2) { + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hDCA1vsDCA2"), dcaZinSigma(t1), dcaZinSigma(t2), weight); + } } } } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kUPC)) { float dphi = v1.Phi() - v2.Phi(); o2::math_utils::bringToPMPi(dphi); - float aco = 1.f - abs(dphi) / M_PI; - float asym = abs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); + float aco = 1.f - std::fabs(dphi) / M_PI; + float asym = std::fabs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); float dphi_e_ee = v1.Phi() - v12.Phi(); o2::math_utils::bringToPMPi(dphi_e_ee); @@ -925,11 +974,11 @@ struct Dilepton { o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, leptonM1, leptonM2, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), pair_dca, aco, asym, abs(dphi_e_ee), abs(cos_thetaCS), weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), pair_dca, aco, asym, std::fabs(dphi_e_ee), std::fabs(cos_thetaCS), weight); } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++ - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hs"), v12.M(), v12.Pt(), pair_dca, aco, asym, abs(dphi_e_ee), abs(cos_thetaCS), weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hs"), v12.M(), v12.Pt(), pair_dca, aco, asym, std::fabs(dphi_e_ee), std::fabs(cos_thetaCS), weight); } else if (t1.sign() < 0 && t2.sign() < 0) { // LS-- - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hs"), v12.M(), v12.Pt(), pair_dca, aco, asym, abs(dphi_e_ee), abs(cos_thetaCS), weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hs"), v12.M(), v12.Pt(), pair_dca, aco, asym, std::fabs(dphi_e_ee), std::fabs(cos_thetaCS), weight); } } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV2) || cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV3)) { std::array q2ft0m = {collision.q2xft0m(), collision.q2yft0m()}; @@ -978,11 +1027,11 @@ struct Dilepton { o2::math_utils::bringToPMPi(phiCS); if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), pair_dca, abs(cos_thetaCS), abs(phiCS), weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), pair_dca, std::fabs(cos_thetaCS), std::fabs(phiCS), weight); } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++ - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hs"), v12.M(), v12.Pt(), pair_dca, abs(cos_thetaCS), abs(phiCS), weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hs"), v12.M(), v12.Pt(), pair_dca, std::fabs(cos_thetaCS), std::fabs(phiCS), weight); } else if (t1.sign() < 0 && t2.sign() < 0) { // LS-- - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hs"), v12.M(), v12.Pt(), pair_dca, abs(cos_thetaCS), abs(phiCS), weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hs"), v12.M(), v12.Pt(), pair_dca, std::fabs(cos_thetaCS), std::fabs(phiCS), weight); } } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kVM)) { @@ -1033,13 +1082,9 @@ struct Dilepton { used_trackIds.emplace_back(pair_tmp_id1); if (cfgDoMix) { if (t1.sign() > 0) { - emh_pos->AddTrackToEventPool(key_df_collision, EMTrackWithCov(ndf, t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.dcaXY(), t1.dcaZ(), possibleIds1, - t1.x(), t1.y(), t1.z(), t1.alpha(), t1.snp(), t1.tgl(), t1.cYY(), t1.cZY(), t1.cZZ(), - t1.cSnpY(), t1.cSnpZ(), t1.cSnpSnp(), t1.cTglY(), t1.cTglZ(), t1.cTglSnp(), t1.cTglTgl(), t1.c1PtY(), t1.c1PtZ(), t1.c1PtSnp(), t1.c1PtTgl(), t1.c1Pt21Pt2())); + emh_pos->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.dcaXY(), t1.dcaZ(), possibleIds1, t1.cYY(), t1.cZY(), t1.cZZ())); } else { - emh_neg->AddTrackToEventPool(key_df_collision, EMTrackWithCov(ndf, t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.dcaXY(), t1.dcaZ(), possibleIds1, - t1.x(), t1.y(), t1.z(), t1.alpha(), t1.snp(), t1.tgl(), t1.cYY(), t1.cZY(), t1.cZZ(), - t1.cSnpY(), t1.cSnpZ(), t1.cSnpSnp(), t1.cTglY(), t1.cTglZ(), t1.cTglSnp(), t1.cTglTgl(), t1.c1PtY(), t1.c1PtZ(), t1.c1PtSnp(), t1.c1PtTgl(), t1.c1Pt21Pt2())); + emh_neg->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.dcaXY(), t1.dcaZ(), possibleIds1, t1.cYY(), t1.cZY(), t1.cZZ())); } } } @@ -1047,13 +1092,9 @@ struct Dilepton { used_trackIds.emplace_back(pair_tmp_id2); if (cfgDoMix) { if (t2.sign() > 0) { - emh_pos->AddTrackToEventPool(key_df_collision, EMTrackWithCov(ndf, t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds2, - t2.x(), t2.y(), t2.z(), t2.alpha(), t2.snp(), t2.tgl(), t2.cYY(), t2.cZY(), t2.cZZ(), - t2.cSnpY(), t2.cSnpZ(), t2.cSnpSnp(), t2.cTglY(), t2.cTglZ(), t2.cTglSnp(), t2.cTglTgl(), t2.c1PtY(), t2.c1PtZ(), t2.c1PtSnp(), t2.c1PtTgl(), t2.c1Pt21Pt2())); + emh_pos->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds2, t2.cYY(), t2.cZY(), t2.cZZ())); } else { - emh_neg->AddTrackToEventPool(key_df_collision, EMTrackWithCov(ndf, t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds2, - t2.x(), t2.y(), t2.z(), t2.alpha(), t2.snp(), t2.tgl(), t2.cYY(), t2.cZY(), t2.cZZ(), - t2.cSnpY(), t2.cSnpZ(), t2.cSnpSnp(), t2.cTglY(), t2.cTglZ(), t2.cTglSnp(), t2.cTglTgl(), t2.c1PtY(), t2.c1PtZ(), t2.c1PtSnp(), t2.c1PtTgl(), t2.c1Pt21Pt2())); + emh_neg->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds2, t2.cYY(), t2.cZY(), t2.cZZ())); } } } @@ -1065,13 +1106,11 @@ struct Dilepton { used_trackIds.emplace_back(pair_tmp_id1); if (cfgDoMix) { if (t1.sign() > 0) { - emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(ndf, t1.globalIndex(), collision.globalIndex(), t1.fwdtrackId(), t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon, t1.sign(), t1.fwdDcaX(), t1.fwdDcaY(), possibleIds1, - t1.x(), t1.y(), t1.z(), t1.tgl(), t1.cXX(), t1.cXY(), t1.cYY(), - t1.cPhiX(), t1.cPhiY(), t1.cPhiPhi(), t1.cTglX(), t1.cTglY(), t1.cTglPhi(), t1.cTglTgl(), t1.c1PtX(), t1.c1PtY(), t1.c1PtPhi(), t1.c1PtTgl(), t1.c1Pt21Pt2(), t1.chi2())); + emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.fwdtrackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.fwdDcaX(), t1.fwdDcaY(), possibleIds1, + t1.cXXatDCA(), t1.cXYatDCA(), t1.cYYatDCA())); } else { - emh_neg->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(ndf, t1.globalIndex(), collision.globalIndex(), t1.fwdtrackId(), t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon, t1.sign(), t1.fwdDcaX(), t1.fwdDcaY(), possibleIds1, - t1.x(), t1.y(), t1.z(), t1.tgl(), t1.cXX(), t1.cXY(), t1.cYY(), - t1.cPhiX(), t1.cPhiY(), t1.cPhiPhi(), t1.cTglX(), t1.cTglY(), t1.cTglPhi(), t1.cTglTgl(), t1.c1PtX(), t1.c1PtY(), t1.c1PtPhi(), t1.c1PtTgl(), t1.c1Pt21Pt2(), t1.chi2())); + emh_neg->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.fwdtrackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.fwdDcaX(), t1.fwdDcaY(), possibleIds1, + t1.cXXatDCA(), t1.cXYatDCA(), t1.cYYatDCA())); } } } @@ -1079,13 +1118,11 @@ struct Dilepton { used_trackIds.emplace_back(pair_tmp_id2); if (cfgDoMix) { if (t2.sign() > 0) { - emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(ndf, t2.globalIndex(), collision.globalIndex(), t2.fwdtrackId(), t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon, t2.sign(), t2.fwdDcaX(), t2.fwdDcaY(), possibleIds2, - t2.x(), t2.y(), t2.z(), t2.tgl(), t2.cXX(), t2.cXY(), t2.cYY(), - t2.cPhiX(), t2.cPhiY(), t2.cPhiPhi(), t2.cTglX(), t2.cTglY(), t2.cTglPhi(), t2.cTglTgl(), t2.c1PtX(), t2.c1PtY(), t2.c1PtPhi(), t2.c1PtTgl(), t2.c1Pt21Pt2(), t2.chi2())); + emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.fwdtrackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.fwdDcaX(), t2.fwdDcaY(), possibleIds2, + t2.cXXatDCA(), t2.cXYatDCA(), t2.cYYatDCA())); } else { - emh_neg->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(ndf, t2.globalIndex(), collision.globalIndex(), t2.fwdtrackId(), t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon, t2.sign(), t2.fwdDcaX(), t2.fwdDcaY(), possibleIds2, - t2.x(), t2.y(), t2.z(), t2.tgl(), t2.cXX(), t2.cXY(), t2.cYY(), - t2.cPhiX(), t2.cPhiY(), t2.cPhiPhi(), t2.cTglX(), t2.cTglY(), t2.cTglPhi(), t2.cTglTgl(), t2.c1PtX(), t2.c1PtY(), t2.c1PtPhi(), t2.c1PtTgl(), t2.c1Pt21Pt2(), t2.chi2())); + emh_neg->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.fwdtrackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.fwdDcaX(), t2.fwdDcaY(), possibleIds2, + t2.cXXatDCA(), t2.cXYatDCA(), t2.cYYatDCA())); } } } @@ -1097,13 +1134,12 @@ struct Dilepton { Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); // Filter collisionFilter_multiplicity = cfgNtracksPV08Min <= o2::aod::mult::multNTracksPV && o2::aod::mult::multNTracksPV < cfgNtracksPV08Max; Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; - Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin < o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; using FilteredMyCollisions = soa::Filtered; SliceCache cache; Preslice perCollision_electron = aod::emprimaryelectron::emeventId; - Filter trackFilter_electron = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && dielectroncuts.cfg_min_eta_track < o2::aod::track::eta && o2::aod::track::eta < dielectroncuts.cfg_max_eta_track && dielectroncuts.cfg_min_phi_track < o2::aod::track::phi && o2::aod::track::phi < dielectroncuts.cfg_max_phi_track && o2::aod::track::tpcChi2NCl < dielectroncuts.cfg_max_chi2tpc && o2::aod::track::itsChi2NCl < dielectroncuts.cfg_max_chi2its && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz; - Filter pidFilter_electron = dielectroncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dielectroncuts.cfg_max_TPCNsigmaEl; + Filter trackFilter_electron = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && dielectroncuts.cfg_min_eta_track < o2::aod::track::eta && o2::aod::track::eta < dielectroncuts.cfg_max_eta_track && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz; Filter ttcaFilter_electron = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); Filter prefilter_derived_electron = ifnode(dielectroncuts.cfg_apply_cuts_from_prefilter_derived.node() && dielectroncuts.cfg_prefilter_bits_derived.node() >= static_cast(1), ifnode((dielectroncuts.cfg_prefilter_bits_derived.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kMee))) > static_cast(0), (o2::aod::emprimaryelectron::pfbderived & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kMee))) <= static_cast(0), true) && @@ -1123,7 +1159,7 @@ struct Dilepton { Partition negative_electrons = o2::aod::emprimaryelectron::sign < int8_t(0); Preslice perCollision_muon = aod::emprimarymuon::emeventId; - Filter trackFilter_muon = o2::aod::fwdtrack::trackType == dimuoncuts.cfg_track_type && dimuoncuts.cfg_min_pt_track < o2::aod::fwdtrack::pt && dimuoncuts.cfg_min_eta_track < o2::aod::fwdtrack::eta && o2::aod::fwdtrack::eta < dimuoncuts.cfg_max_eta_track && dimuoncuts.cfg_min_phi_track < o2::aod::fwdtrack::phi && o2::aod::fwdtrack::phi < dimuoncuts.cfg_max_phi_track; + Filter trackFilter_muon = o2::aod::fwdtrack::trackType == dimuoncuts.cfg_track_type && dimuoncuts.cfg_min_pt_track < o2::aod::fwdtrack::pt && o2::aod::fwdtrack::pt < dimuoncuts.cfg_max_pt_track && dimuoncuts.cfg_min_eta_track < o2::aod::fwdtrack::eta && o2::aod::fwdtrack::eta < dimuoncuts.cfg_max_eta_track; Filter ttcaFilter_muon = ifnode(dimuoncuts.enableTTCA.node(), o2::aod::emprimarymuon::isAssociatedToMPC == true || o2::aod::emprimarymuon::isAssociatedToMPC == false, o2::aod::emprimarymuon::isAssociatedToMPC == true); Partition positive_muons = o2::aod::emprimarymuon::sign > int8_t(0); Partition negative_muons = o2::aod::emprimarymuon::sign < int8_t(0); @@ -1135,10 +1171,10 @@ struct Dilepton { std::vector> used_trackIds; int ndf = 0; - template - void runPairing(TCollisions const& collisions, TLeptons const& posTracks, TLeptons const& negTracks, TPresilce const& perCollision, TCut const& cut) + template + void runPairing(TCollisions const& collisions, TLeptons const& posTracks, TLeptons const& negTracks, TPresilce const& perCollision, TCut const& cut, TAllTracks const& tracks) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { initCCDB(collision); const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; float centrality = centralities[cfgCentEstimator]; @@ -1189,6 +1225,9 @@ struct Dilepton { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } if (nmod > 0 && !isGoodQvector(qvectors)) { continue; @@ -1212,20 +1251,20 @@ struct Dilepton { // LOGF(info, "collision.globalIndex() = %d , collision.posZ() = %f , collision.numContrib() = %d, centrality = %f , posTracks_per_coll.size() = %d, negTracks_per_coll.size() = %d", collision.globalIndex(), collision.posZ(), collision.numContrib(), centralities[cfgCentEstimator], posTracks_per_coll.size(), negTracks_per_coll.size()); int nuls = 0, nlspp = 0, nlsmm = 0; - for (auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS - bool is_pair_ok = fillPairInfo<0>(collision, pos, neg, cut); + for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + bool is_pair_ok = fillPairInfo<0>(collision, pos, neg, cut, tracks); if (is_pair_ok) { nuls++; } } - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ - bool is_pair_ok = fillPairInfo<0>(collision, pos1, pos2, cut); + for (const auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ + bool is_pair_ok = fillPairInfo<0>(collision, pos1, pos2, cut, tracks); if (is_pair_ok) { nlspp++; } } - for (auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- - bool is_pair_ok = fillPairInfo<0>(collision, neg1, neg2, cut); + for (const auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- + bool is_pair_ok = fillPairInfo<0>(collision, neg1, neg2, cut, tracks); if (is_pair_ok) { nlsmm++; } @@ -1285,7 +1324,7 @@ struct Dilepton { auto collisionIds_in_mixing_pool = emh_pos->GetCollisionIdsFromEventPool(key_bin); // pos/neg does not matter. // LOGF(info, "collisionIds_in_mixing_pool.size() = %d", collisionIds_in_mixing_pool.size()); - for (auto& mix_dfId_collisionId : collisionIds_in_mixing_pool) { + for (const auto& mix_dfId_collisionId : collisionIds_in_mixing_pool) { int mix_dfId = mix_dfId_collisionId.first; int mix_collisionId = mix_dfId_collisionId.second; if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. @@ -1303,27 +1342,27 @@ struct Dilepton { auto negTracks_from_event_pool = emh_neg->GetTracksPerCollision(mix_dfId_collisionId); // LOGF(info, "Do event mixing: current event (%d, %d) | event pool (%d, %d), npos = %d , nneg = %d", ndf, collision.globalIndex(), mix_dfId, mix_collisionId, posTracks_from_event_pool.size(), negTracks_from_event_pool.size()); - for (auto& pos : selected_posTracks_in_this_event) { // ULS mix - for (auto& neg : negTracks_from_event_pool) { - fillPairInfo<1>(collision, pos, neg, cut); + for (const auto& pos : selected_posTracks_in_this_event) { // ULS mix + for (const auto& neg : negTracks_from_event_pool) { + fillPairInfo<1>(collision, pos, neg, cut, tracks); } } - for (auto& neg : selected_negTracks_in_this_event) { // ULS mix - for (auto& pos : posTracks_from_event_pool) { - fillPairInfo<1>(collision, neg, pos, cut); + for (const auto& neg : selected_negTracks_in_this_event) { // ULS mix + for (const auto& pos : posTracks_from_event_pool) { + fillPairInfo<1>(collision, neg, pos, cut, tracks); } } - for (auto& pos1 : selected_posTracks_in_this_event) { // LS++ mix - for (auto& pos2 : posTracks_from_event_pool) { - fillPairInfo<1>(collision, pos1, pos2, cut); + for (const auto& pos1 : selected_posTracks_in_this_event) { // LS++ mix + for (const auto& pos2 : posTracks_from_event_pool) { + fillPairInfo<1>(collision, pos1, pos2, cut, tracks); } } - for (auto& neg1 : selected_negTracks_in_this_event) { // LS-- mix - for (auto& neg2 : negTracks_from_event_pool) { - fillPairInfo<1>(collision, neg1, neg2, cut); + for (const auto& neg1 : selected_negTracks_in_this_event) { // LS-- mix + for (const auto& neg2 : negTracks_from_event_pool) { + fillPairInfo<1>(collision, neg1, neg2, cut, tracks); } } } // end of loop over mixed event pool @@ -1338,8 +1377,8 @@ struct Dilepton { } // end of DF - template - bool isPairOK(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut) + template + bool isPairOK(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const& tracks) { if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { @@ -1352,17 +1391,24 @@ struct Dilepton { } } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { + if (!cut.IsSelectedTrack(t1) || !cut.IsSelectedTrack(t2)) { + return false; + } + + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) { + return false; + } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) { return false; } } if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - if (!cut.template IsSelectedPair(t1, t2, d_bz)) { + if (!cut.IsSelectedPair(t1, t2, d_bz, dielectroncuts.cfgRefR)) { return false; } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - if (!cut.template IsSelectedPair(t1, t2)) { + if (!cut.IsSelectedPair(t1, t2)) { return false; } } @@ -1376,7 +1422,7 @@ struct Dilepton { std::vector> passed_pairIds; passed_pairIds.reserve(posTracks.size() * negTracks.size()); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { initCCDB(collision); const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { @@ -1412,6 +1458,9 @@ struct Dilepton { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } if (nmod > 0 && !isGoodQvector(qvectors)) { continue; @@ -1420,32 +1469,32 @@ struct Dilepton { auto posTracks_per_coll = posTracks.sliceByCached(perCollision, collision.globalIndex(), cache); auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache); - for (auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS - if (isPairOK(collision, pos, neg, cut)) { + for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + if (isPairOK(collision, pos, neg, cut, tracks)) { passed_pairIds.emplace_back(std::make_pair(pos.globalIndex(), neg.globalIndex())); } } - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ - if (isPairOK(collision, pos1, pos2, cut)) { + for (const auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ + if (isPairOK(collision, pos1, pos2, cut, tracks)) { passed_pairIds.emplace_back(std::make_pair(pos1.globalIndex(), pos2.globalIndex())); } } - for (auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- - if (isPairOK(collision, neg1, neg2, cut)) { + for (const auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- + if (isPairOK(collision, neg1, neg2, cut, tracks)) { passed_pairIds.emplace_back(std::make_pair(neg1.globalIndex(), neg2.globalIndex())); } } } // end of collision loop if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - for (auto& pairId : passed_pairIds) { + for (const auto& pairId : passed_pairIds) { auto t1 = tracks.rawIteratorAt(std::get<0>(pairId)); auto t2 = tracks.rawIteratorAt(std::get<1>(pairId)); // LOGF(info, "std::get<0>(pairId) = %d, std::get<1>(pairId) = %d, t1.globalIndex() = %d, t2.globalIndex() = %d", std::get<0>(pairId), std::get<1>(pairId), t1.globalIndex(), t2.globalIndex()); float n = 1.f; // include myself. - for (auto& ambId1 : t1.ambiguousElectronsIds()) { - for (auto& ambId2 : t2.ambiguousElectronsIds()) { + for (const auto& ambId1 : t1.ambiguousElectronsIds()) { + for (const auto& ambId2 : t2.ambiguousElectronsIds()) { if (std::find(passed_pairIds.begin(), passed_pairIds.end(), std::make_pair(ambId1, ambId2)) != passed_pairIds.end()) { n += 1.f; } @@ -1454,13 +1503,13 @@ struct Dilepton { map_weight[pairId] = 1.f / n; } // end of passed_pairIds loop } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - for (auto& pairId : passed_pairIds) { + for (const auto& pairId : passed_pairIds) { auto t1 = tracks.rawIteratorAt(std::get<0>(pairId)); auto t2 = tracks.rawIteratorAt(std::get<1>(pairId)); float n = 1.f; // include myself. - for (auto& ambId1 : t1.ambiguousMuonsIds()) { - for (auto& ambId2 : t2.ambiguousMuonsIds()) { + for (const auto& ambId1 : t1.ambiguousMuonsIds()) { + for (const auto& ambId2 : t2.ambiguousMuonsIds()) { if (std::find(passed_pairIds.begin(), passed_pairIds.end(), std::make_pair(ambId1, ambId2)) != passed_pairIds.end()) { n += 1.f; } @@ -1480,13 +1529,13 @@ struct Dilepton { if (cfgApplyWeightTTCA) { fillPairWeightMap(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, electrons); } - runPairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut); + runPairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, electrons); } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { auto muons = std::get<0>(std::tie(args...)); if (cfgApplyWeightTTCA) { fillPairWeightMap(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons); } - runPairing(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut); + runPairing(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons); } map_weight.clear(); ndf++; @@ -1501,13 +1550,13 @@ struct Dilepton { if (cfgApplyWeightTTCA) { fillPairWeightMap(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, electrons); } - runPairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut); + runPairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, electrons); } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { auto muons = std::get<0>(std::tie(args...)); if (cfgApplyWeightTTCA) { fillPairWeightMap(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons); } - runPairing(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut); + runPairing(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons); } map_weight.clear(); ndf++; @@ -1519,7 +1568,7 @@ struct Dilepton { void processNorm(FilteredNormInfos const& collisions) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { if (collision.centFT0C() < cfgCentMin || cfgCentMax < collision.centFT0C()) { continue; } @@ -1552,7 +1601,7 @@ struct Dilepton { if (collision.sel8()) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 10.0); } - if (abs(collision.posZ()) < 10.0) { + if (std::fabs(collision.posZ()) < 10.0) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 11.0); } if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { @@ -1570,14 +1619,52 @@ struct Dilepton { if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 16.0); } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 17.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 18.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 19.0); + } if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } fRegistry.fill(HIST("Event/norm/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted } // end of collision loop } PROCESS_SWITCH(Dilepton, processNorm, "process normalization info", false); + void processBC(aod::EMBCs const& bcs) + { + for (const auto& bc : bcs) { + if (bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 0.f); + + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 1.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 2.f); + } + if (rctChecker(bc)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 3.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 4.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) && rctChecker(bc)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 5.f); + } + } + } + } + PROCESS_SWITCH(Dilepton, processBC, "process BC counter", false); + void processDummy(MyCollisions const&) {} PROCESS_SWITCH(Dilepton, processDummy, "Dummy function", false); }; diff --git a/PWGEM/Dilepton/Core/DileptonHadronMPC.h b/PWGEM/Dilepton/Core/DileptonHadronMPC.h new file mode 100644 index 00000000000..2e1d94ab6bd --- /dev/null +++ b/PWGEM/Dilepton/Core/DileptonHadronMPC.h @@ -0,0 +1,1455 @@ +// 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. +// +// ======================== +// +// This code runs loop over leptons. +// Please write to: daiki.sekihata@cern.ch + +#ifndef PWGEM_DILEPTON_CORE_DILEPTONHADRONMPC_H_ +#define PWGEM_DILEPTON_CORE_DILEPTONHADRONMPC_H_ + +#include "PWGEM/Dilepton/Core/DielectronCut.h" +#include "PWGEM/Dilepton/Core/DimuonCut.h" +#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/Dilepton/Core/EMTrackCut.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/EMFwdTrack.h" +#include "PWGEM/Dilepton/Utils/EMTrack.h" +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/Utils/EventMixingHandler.h" +#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" + +#include "Common/CCDB/RCTSelectionFlags.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Tools/ML/MlResponse.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/LHCConstants.h" +#include "DataFormatsParameters/GRPECSObject.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "MathUtils/Utils.h" + +#include "Math/Vector4D.h" +#include "TH1D.h" +#include "TString.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::aod::pwgem::dilepton::utils; +using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; +using namespace o2::aod::pwgem::dilepton::utils::pairutil; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyCollisionsWithSWT = soa::Join; +using MyCollisionWithSWT = MyCollisionsWithSWT::iterator; + +using MyElectrons = soa::Join; +using MyElectron = MyElectrons::iterator; +using FilteredMyElectrons = soa::Filtered; +using FilteredMyElectron = FilteredMyElectrons::iterator; + +using MyMuons = soa::Join; +using MyMuon = MyMuons::iterator; +using FilteredMyMuons = soa::Filtered; +using FilteredMyMuon = FilteredMyMuons::iterator; + +using MyTracks = soa::Join; +using MyTrack = MyTracks::iterator; + +using MyEMH_electron = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrack>; +using MyEMH_muon = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMFwdTrack>; +using MyEMH_track = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrack>; // for charged track + +template +struct DileptonHadronMPC { + + // Configurables + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; + Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; + + Configurable cfgAnalysisType{"cfgAnalysisType", static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonHadronAnalysisType::kAzimuthalCorrelation), "kAzimuthalCorrelation:0, kCumulant:1"}; + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgOccupancyEstimator{"cfgOccupancyEstimator", 0, "FT0C:0, Track:1"}; + Configurable cfgCentMin{"cfgCentMin", -1, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; + Configurable cfgDoMix{"cfgDoMix", true, "flag for event mixing"}; + Configurable ndepth_lepton{"ndepth_lepton", 100, "depth for event mixing between lepton-lepton"}; + Configurable ndepth_hadron{"ndepth_hadron", 1, "depth for event mixing between hadron-hadron"}; + Configurable ndiff_bc_mix{"ndiff_bc_mix", 594, "difference in global BC required in mixed events"}; + ConfigurableAxis ConfVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0.0f, 0.1, 1, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.f, 999.f}, "Mixing bins - centrality"}; + ConfigurableAxis ConfOccupancyBins{"ConfOccupancyBins", {VARIABLE_WIDTH, -1, 1e+10}, "Mixing bins - occupancy"}; + Configurable cfg_swt_name{"cfg_swt_name", "fHighTrackMult", "desired software trigger name"}; // 1 trigger name per 1 task. fHighTrackMult, fHighFt0Mult + // Configurable cfgNtracksPV08Min{"cfgNtracksPV08Min", -1, "min. multNTracksPV"}; + // Configurable cfgNtracksPV08Max{"cfgNtracksPV08Max", static_cast(1e+9), "max. multNTracksPV"}; + Configurable cfgApplyWeightTTCA{"cfgApplyWeightTTCA", false, "flag to apply weighting by 1/N"}; + Configurable cfgDCAType{"cfgDCAType", 0, "type of DCA for output. 0:3D, 1:XY, 2:Z, else:3D"}; + + ConfigurableAxis ConfMllBins{"ConfMllBins", {VARIABLE_WIDTH, 0.00, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, 0.13, 0.14, 0.20, 0.30, 0.40, 0.50, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.60, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.70, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.80, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.90, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.00, 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.75, 2.80, 2.85, 2.90, 2.95, 3.00, 3.05, 3.10, 3.15, 3.20, 3.25, 3.30, 3.35, 3.40, 3.45, 3.50, 3.55, 3.60, 3.65, 3.70, 3.75, 3.80, 3.85, 3.90, 3.95, 4.00}, "mll bins for output histograms"}; + ConfigurableAxis ConfPtllBins{"ConfPtllBins", {VARIABLE_WIDTH, 0.00, 0.15, 0.50, 1.00, 1.50, 2.00, 2.50, 3.00, 3.50, 4.00, 4.50, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00}, "pTll bins for output histograms"}; + ConfigurableAxis ConfDCAllBins{"ConfDCAllBins", {VARIABLE_WIDTH, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCAll bins for output histograms"}; + + // ConfigurableAxis ConfMmumuBins{"ConfMmumuBins", {VARIABLE_WIDTH, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.40, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.60, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.70, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.80, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.90, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.00, 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.10, 1.11,1.12,1.13,1.14,1.15,1.16,1.17,1.18,1.19, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.75, 2.80, 2.85, 2.90, 2.95, 3.00, 3.05, 3.10, 3.15, 3.20, 3.25, 3.30, 3.35, 3.40, 3.45, 3.50, 3.55, 3.60, 3.65, 3.70, 3.75, 3.80, 3.85, 3.90, 3.95, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50, 4.60, 4.70, 4.80, 4.90, 5.00, 5.10, 5.20, 5.30, 5.40, 5.50, 5.60, 5.70, 5.80, 5.90, 6.00, 6.10, 6.20, 6.30, 6.40, 6.50, 6.60, 6.70, 6.80, 6.90, 7.00, 7.10, 7.20, 7.30, 7.40, 7.50, 7.60, 7.70, 7.80, 7.90, 8.00, 8.10, 8.20, 8.30, 8.40, 8.50, 8.60, 8.70, 8.80, 8.90, 9.00, 9.10, 9.20, 9.30, 9.40, 9.50, 9.60, 9.70, 9.80, 9.90, 10.00, 10.10, 10.20, 10.30, 10.40, 10.50, 10.60, 10.70, 10.80, 10.90, 11.00, 11.50, 12.00}, "mmumu bins for output histograms"}; // for dimuon. one can copy bins here to hyperloop page. + + ConfigurableAxis ConfPtHadronBins{"ConfPtHadronBins", {VARIABLE_WIDTH, 0.00, 0.15, 0.2, 0.3, 0.4, 0.50, 1.00, 2.00, 3.00, 4.00, 5.00}, "pT,h bins for output histograms"}; + ConfigurableAxis ConfRapidityBins{"ConfRapidityBins", {20, -1, 1}, "rapidity bins for output histograms"}; + ConfigurableAxis ConfDEtaBins{"ConfDEtaBins", {60, -3, 3}, "deta bins for output histograms"}; + Configurable cfgNbinsDPhi{"cfgNbinsDPhi", 36, "nbins in dphi for output histograms"}; + Configurable cfgNbinsCosNDPhi{"cfgNbinsCosNDPhi", 200, "nbins in cos(n(dphi)) for output histograms"}; + Configurable cfgNmod{"cfgNmod", 2, "n-th harmonics"}; + + EMEventCut fEMEventCut; + struct : ConfigurableGroup { + std::string prefix = "eventcut_group"; + Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; + Configurable cfgZvtxMax{"cfgZvtxMax", +10.f, "max. Zvtx"}; + Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexTOFmatched{"cfgRequireVertexTOFmatched", false, "require Vertex TOFmatched in event cut"}; // ITS-TPC-TOF matched track contributes PV. + Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; + Configurable cfgRequireNoCollInTimeRangeStandard{"cfgRequireNoCollInTimeRangeStandard", false, "require no collision in time range standard"}; + Configurable cfgRequireNoCollInTimeRangeStrict{"cfgRequireNoCollInTimeRangeStrict", false, "require no collision in time range strict"}; + Configurable cfgRequireNoCollInITSROFStandard{"cfgRequireNoCollInITSROFStandard", false, "require no collision in time range standard"}; + Configurable cfgRequireNoCollInITSROFStrict{"cfgRequireNoCollInITSROFStrict", false, "require no collision in time range strict"}; + Configurable cfgRequireNoHighMultCollInPrevRof{"cfgRequireNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + Configurable cfgRequireGoodITSLayer3{"cfgRequireGoodITSLayer3", false, "number of inactive chips on ITS layer 3 are below threshold "}; + Configurable cfgRequireGoodITSLayer0123{"cfgRequireGoodITSLayer0123", false, "number of inactive chips on ITS layers 0-3 are below threshold "}; + Configurable cfgRequireGoodITSLayersAll{"cfgRequireGoodITSLayersAll", false, "number of inactive chips on all ITS layers are below threshold "}; + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; + } eventcuts; + + DielectronCut fDielectronCut; + struct : ConfigurableGroup { + std::string prefix = "dielectroncut_group"; + Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; + Configurable cfg_max_mass{"cfg_max_mass", 1e+10, "max mass"}; + Configurable cfg_min_pair_pt{"cfg_min_pair_pt", 0.0, "min pair pT"}; + Configurable cfg_max_pair_pt{"cfg_max_pair_pt", 1e+10, "max pair pT"}; + Configurable cfg_min_pair_y{"cfg_min_pair_y", -0.8, "min pair rapidity"}; + Configurable cfg_max_pair_y{"cfg_max_pair_y", +0.8, "max pair rapidity"}; + Configurable cfg_min_pair_dca3d{"cfg_min_pair_dca3d", 0.0, "min pair dca3d in sigma"}; + Configurable cfg_max_pair_dca3d{"cfg_max_pair_dca3d", 1e+10, "max pair dca3d in sigma"}; + Configurable cfg_apply_phiv{"cfg_apply_phiv", true, "flag to apply phiv cut"}; + Configurable cfg_phiv_slope{"cfg_phiv_slope", 0.0185, "slope for m vs. phiv"}; + Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; + Configurable cfg_min_phiv{"cfg_min_phiv", 0.0, "min phiv (constant)"}; + Configurable cfg_max_phiv{"cfg_max_phiv", 3.2, "max phiv (constant)"}; + Configurable cfg_apply_detadphi{"cfg_apply_detadphi", false, "flag to apply deta-dphi elliptic cut at PV"}; + Configurable cfg_apply_detadphiposition{"cfg_apply_detadphiposition", false, "flag to apply deta-dphi elliptic cut at certain radius"}; + Configurable cfg_min_deta{"cfg_min_deta", 0.02, "min deta between 2 electrons (elliptic cut)"}; + Configurable cfg_min_dphi{"cfg_min_dphi", 0.2, "min dphi between 2 electrons (elliptic cut)"}; + + Configurable cfg_apply_cuts_from_prefilter{"cfg_apply_cuts_from_prefilter", false, "flag to apply prefilter set when producing derived data"}; + Configurable cfg_prefilter_bits{"cfg_prefilter_bits", 0, "prefilter bits [kNone : 0, kElFromPC : 1, kElFromPi0_1 : 2, kElFromPi0_2 : 4, kElFromPi0_3 : 8] Please consider logical-OR among them."}; // see PairUtilities.h + + Configurable cfg_apply_cuts_from_prefilter_derived{"cfg_apply_cuts_from_prefilter_derived", false, "flag to apply pair cut same as prefilter set in derived data"}; + Configurable cfg_prefilter_bits_derived{"cfg_prefilter_bits_derived", 0, "prefilter bits [kNone : 0, kMee : 1, kPhiV : 2, kSplitOrMergedTrackLS : 4, kSplitOrMergedTrackULS : 8] Please consider logical-OR among them."}; // see PairUtilities.h + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; + Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "min eta for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.8, "max eta for single track"}; + Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "min phi for single track"}; + Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; + Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 100, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_chi2tof{"cfg_max_chi2tof", 1e+10, "max chi2 TOF"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1.0, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.0, "max dca Z for single track in cm"}; + Configurable cfg_require_itsib_any{"cfg_require_itsib_any", false, "flag to require ITS ib any hits"}; + Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; + Configurable cfgRefR{"cfgRefR", 1.2, "reference R (in m) for extrapolation"}; // https://cds.cern.ch/record/1419204 + + Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3, kTOFif : 4, kPIDML : 5, kTPChadrejORTOFreq_woTOFif : 6]"}; + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -3.0, "min. TPC n sigma for kaon exclusion"}; + Configurable cfg_max_TPCNsigmaKa{"cfg_max_TPCNsigmaKa", +3.0, "max. TPC n sigma for kaon exclusion"}; + Configurable cfg_min_TPCNsigmaPr{"cfg_min_TPCNsigmaPr", -3.0, "min. TPC n sigma for proton exclusion"}; + Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +3.0, "max. TPC n sigma for proton exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + Configurable cfg_min_pin_pirejTPC{"cfg_min_pin_pirejTPC", 0.f, "min. pin for pion rejection in TPC"}; + Configurable cfg_max_pin_pirejTPC{"cfg_max_pin_pirejTPC", 1e+10, "max. pin for pion rejection in TPC"}; + Configurable enableTTCA{"enableTTCA", false, "Flag to enable or disable TTCA"}; + + // configuration for PID ML + Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; + Configurable> onnxPathsCCDB{"onnxPathsCCDB", std::vector{"path"}, "Paths of models on CCDB"}; + Configurable> binsMl{"binsMl", std::vector{-999999., 999999.}, "Bin limits for ML application"}; + Configurable> cutsMl{"cutsMl", std::vector{0.95}, "ML cuts per bin"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature"}, "Names of ML model input features"}; + Configurable nameBinningFeature{"nameBinningFeature", "pt", "Names of ML model binning feature"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB. Exceptions: > 0 for the specific timestamp, 0 gets the run dependent timestamp"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + Configurable enableOptimizations{"enableOptimizations", false, "Enables the ONNX extended model-optimization: sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED)"}; + } dielectroncuts; + + DimuonCut fDimuonCut; + struct : ConfigurableGroup { + std::string prefix = "dimuoncut_group"; + Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; + Configurable cfg_max_mass{"cfg_max_mass", 1e+10, "max mass"}; + Configurable cfg_min_pair_pt{"cfg_min_pair_pt", 0.0, "min pair pt"}; + Configurable cfg_max_pair_pt{"cfg_max_pair_pt", 1e+10, "max pair pt"}; + Configurable cfg_min_pair_y{"cfg_min_pair_y", -4.0, "min pair rapidity"}; + Configurable cfg_max_pair_y{"cfg_max_pair_y", -2.5, "max pair rapidity"}; + Configurable cfg_min_pair_dcaxy{"cfg_min_pair_dcaxy", 0.0, "min pair dca3d in sigma"}; + Configurable cfg_max_pair_dcaxy{"cfg_max_pair_dcaxy", 1e+10, "max pair dca3d in sigma"}; + Configurable cfg_apply_detadphi{"cfg_apply_detadphi", false, "flag to apply deta-dphi elliptic cut"}; + Configurable cfg_min_deta{"cfg_min_deta", 0.02, "min deta between 2 muons (elliptic cut)"}; + Configurable cfg_min_dphi{"cfg_min_dphi", 0.02, "min dphi between 2 muons (elliptic cut)"}; + + Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; + Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -4.0, "min eta for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", -2.5, "max eta for single track"}; + Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "min phi for single track"}; + Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; + Configurable cfg_min_ncluster_mft{"cfg_min_ncluster_mft", 6, "min ncluster MFT"}; + Configurable cfg_min_ncluster_mch{"cfg_min_ncluster_mch", 8, "min ncluster MCH"}; + Configurable cfg_max_chi2{"cfg_max_chi2", 1e+6, "max chi2"}; + Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 40, "max chi2 for MFT-MCH matching"}; + Configurable cfg_max_matching_chi2_mchmid{"cfg_max_matching_chi2_mchmid", 1e+10, "max chi2 for MCH-MID matching"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1e+10, "max dca XY for single track in cm"}; + Configurable cfg_min_rabs{"cfg_min_rabs", 17.6, "min Radius at the absorber end"}; + Configurable cfg_max_rabs{"cfg_max_rabs", 89.5, "max Radius at the absorber end"}; + Configurable enableTTCA{"enableTTCA", false, "Flag to enable or disable TTCA"}; + Configurable cfg_max_relDPt_wrt_matchedMCHMID{"cfg_max_relDPt_wrt_matchedMCHMID", 1e+10f, "max. relative dpt between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DEta_wrt_matchedMCHMID{"cfg_max_DEta_wrt_matchedMCHMID", 1e+10f, "max. deta between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DPhi_wrt_matchedMCHMID{"cfg_max_DPhi_wrt_matchedMCHMID", 1e+10f, "max. dphi between MFT-MCH-MID and MCH-MID"}; + Configurable requireMFTHitMap{"requireMFTHitMap", false, "flag to apply MFT hit map"}; + Configurable> requiredMFTDisks{"requiredMFTDisks", std::vector{0}, "hit map on MFT disks [0,1,2,3,4]. logical-OR of each double-sided disk"}; + } dimuoncuts; + + EMTrackCut fEMTrackCut; + struct : ConfigurableGroup { + std::string prefix = "trackcut_group"; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for ref. track"}; + Configurable cfg_max_pt_track{"cfg_max_pt_track", 3.0, "max pT for ref. track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "min eta for ref. track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.8, "max eta for ref. track"}; + Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.0, "min phi for ref. track"}; + Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for ref. track"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.5, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.5, "max dca Z for single track in cm"}; + Configurable cfg_track_bits{"cfg_track_bits", 645, "required track bits"}; // default:645, loose:0, tight:778 + // Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; + // Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + // Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 70, "min ncrossed rows"}; + // Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 0.7, "max fraction of shared clusters in TPC"}; + // Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + // Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + // Configurable cfg_require_itsib_any{"cfg_require_itsib_any", true, "flag to require ITS ib any hits"}; + // Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", false, "flag to require ITS ib 1st hit"}; + } trackcuts; + + o2::aod::rctsel::RCTFlagsChecker rctChecker; + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber; + float d_bz; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + static constexpr std::string_view event_cut_types[2] = {"before/", "after/"}; + static constexpr std::string_view event_pair_types[2] = {"same/", "mix/"}; + + std::vector cent_bin_edges; + std::vector zvtx_bin_edges; + std::vector occ_bin_edges; + int nmod = -1; // this is for flow analysis + int subdet2 = -1; // this is for flow analysis + int subdet3 = -1; // this is for flow analysis + float leptonM1 = 0.f; + float leptonM2 = 0.f; + + void init(InitContext& /*context*/) + { + mRunNumber = 0; + d_bz = 0; + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + rctChecker.init(eventcuts.cfgRCTLabel.value, eventcuts.cfgCheckZDC.value, eventcuts.cfgTreatLimitedAcceptanceAsBad.value); + + if (ConfVtxBins.value[0] == VARIABLE_WIDTH) { + zvtx_bin_edges = std::vector(ConfVtxBins.value.begin(), ConfVtxBins.value.end()); + zvtx_bin_edges.erase(zvtx_bin_edges.begin()); + for (const auto& edge : zvtx_bin_edges) { + LOGF(info, "VARIABLE_WIDTH: zvtx_bin_edges = %f", edge); + } + } else { + int nbins = static_cast(ConfVtxBins.value[0]); + float xmin = static_cast(ConfVtxBins.value[1]); + float xmax = static_cast(ConfVtxBins.value[2]); + zvtx_bin_edges.resize(nbins + 1); + for (int i = 0; i < nbins + 1; i++) { + zvtx_bin_edges[i] = (xmax - xmin) / (nbins)*i + xmin; + LOGF(info, "FIXED_WIDTH: zvtx_bin_edges[%d] = %f", i, zvtx_bin_edges[i]); + } + } + + if (ConfCentBins.value[0] == VARIABLE_WIDTH) { + cent_bin_edges = std::vector(ConfCentBins.value.begin(), ConfCentBins.value.end()); + cent_bin_edges.erase(cent_bin_edges.begin()); + for (const auto& edge : cent_bin_edges) { + LOGF(info, "VARIABLE_WIDTH: cent_bin_edges = %f", edge); + } + } else { + int nbins = static_cast(ConfCentBins.value[0]); + float xmin = static_cast(ConfCentBins.value[1]); + float xmax = static_cast(ConfCentBins.value[2]); + cent_bin_edges.resize(nbins + 1); + for (int i = 0; i < nbins + 1; i++) { + cent_bin_edges[i] = (xmax - xmin) / (nbins)*i + xmin; + LOGF(info, "FIXED_WIDTH: cent_bin_edges[%d] = %f", i, cent_bin_edges[i]); + } + } + + LOGF(info, "cfgOccupancyEstimator = %d", cfgOccupancyEstimator.value); + if (ConfOccupancyBins.value[0] == VARIABLE_WIDTH) { + occ_bin_edges = std::vector(ConfOccupancyBins.value.begin(), ConfOccupancyBins.value.end()); + occ_bin_edges.erase(occ_bin_edges.begin()); + for (const auto& edge : occ_bin_edges) { + LOGF(info, "VARIABLE_WIDTH: occ_bin_edges = %f", edge); + } + } else { + int nbins = static_cast(ConfOccupancyBins.value[0]); + float xmin = static_cast(ConfOccupancyBins.value[1]); + float xmax = static_cast(ConfOccupancyBins.value[2]); + occ_bin_edges.resize(nbins + 1); + for (int i = 0; i < nbins + 1; i++) { + occ_bin_edges[i] = (xmax - xmin) / (nbins)*i + xmin; + LOGF(info, "FIXED_WIDTH: occ_bin_edges[%d] = %f", i, occ_bin_edges[i]); + } + } + + emh_pos = new TEMH(ndepth_lepton); + emh_neg = new TEMH(ndepth_lepton); + emh_ref = new MyEMH_track(ndepth_hadron); // for reference flow + + DefineEMEventCut(); + DefineEMTrackCut(); + addhistograms(); + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + DefineDielectronCut(); + leptonM1 = o2::constants::physics::MassElectron; + leptonM2 = o2::constants::physics::MassElectron; + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + DefineDimuonCut(); + leptonM1 = o2::constants::physics::MassMuon; + leptonM2 = o2::constants::physics::MassMuon; + } + + if (doprocessTriggerAnalysis) { + fRegistry.add("Event/hNInspectedTVX", "N inspected TVX;run number;N_{TVX}", kTProfile, {{80000, 520000.5, 600000.5}}, true); + } + } + + template + void initCCDB(TCollision const& collision) + { + if (mRunNumber == collision.runNumber()) { + return; + } + + // In case override, don't proceed, please - no CCDB access required + if (d_bz_input > -990) { + d_bz = d_bz_input; + o2::parameters::GRPMagField grpmag; + if (std::fabs(d_bz) > 1e-5) { + grpmag.setL3Current(30000.f / (d_bz / 5.0f)); + } + o2::base::Propagator::initFieldFromGRP(&grpmag); + mRunNumber = collision.runNumber(); + return; + } + + auto run3grp_timestamp = collision.timestamp(); + o2::parameters::GRPObject* grpo = 0x0; + o2::parameters::GRPMagField* grpmag = 0x0; + if (!skipGRPOquery) + grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + // Fetch magnetic field from ccdb for current collision + d_bz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + // Fetch magnetic field from ccdb for current collision + d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } + mRunNumber = collision.runNumber(); + + if constexpr (isTriggerAnalysis) { + LOGF(info, "Trigger analysis is enabled. Desired trigger name = %s", cfg_swt_name.value); + LOGF(info, "total inspected TVX events = %d in run number %d", collision.nInspectedTVX(), collision.runNumber()); + fRegistry.fill(HIST("Event/hNInspectedTVX"), collision.runNumber(), collision.nInspectedTVX()); + } + } + + ~DileptonHadronMPC() + { + delete emh_pos; + emh_pos = 0x0; + delete emh_neg; + emh_neg = 0x0; + delete emh_ref; + emh_ref = 0x0; + + used_trackIds.clear(); + used_trackIds.shrink_to_fit(); + used_refTrackIds.clear(); + used_refTrackIds.shrink_to_fit(); + } + + void addhistograms() + { + // event info + o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms<-1>(&fRegistry); + + std::string mass_axis_title = "m_{ll} (GeV/c^{2})"; + std::string pair_pt_axis_title = "p_{T,ll}^{trg} (GeV/c)"; + std::string pair_dca_axis_title = "DCA_{ll} (#sigma)"; + std::string pair_rapidity_axis_title = "y_{ll}"; + std::string deta_axis_title = "#Delta#eta = #eta_{ll} - #eta_{h}"; + std::string dphi_axis_title = "#Delta#varphi = #varphi_{ll} - #varphi_{h} (rad.)"; + std::string cosndphi_axis_title = std::format("cos({0:d}(#varphi_{{ll}} - #varphi_{{h}}))", cfgNmod.value); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + mass_axis_title = "m_{ee} (GeV/c^{2})"; + pair_pt_axis_title = "p_{T,ee} (GeV/c)"; + pair_rapidity_axis_title = "y_{ee}"; + pair_dca_axis_title = "DCA_{ee}^{3D} (#sigma)"; + if (cfgDCAType == 1) { + pair_dca_axis_title = "DCA_{ee}^{XY} (#sigma)"; + } else if (cfgDCAType == 2) { + pair_dca_axis_title = "DCA_{ee}^{Z} (#sigma)"; + } + deta_axis_title = "#Delta#eta = #eta_{ee} - #eta_{h}"; + dphi_axis_title = "#Delta#varphi = #varphi_{ee} - #varphi_{h} (rad.)"; + cosndphi_axis_title = std::format("cos({0:d}(#varphi_{{ee}} - #varphi_{{h}}))", cfgNmod.value); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + mass_axis_title = "m_{#mu#mu} (GeV/c^{2})"; + pair_pt_axis_title = "p_{T,#mu#mu} (GeV/c)"; + pair_rapidity_axis_title = "y_{#mu#mu}"; + pair_dca_axis_title = "DCA_{#mu#mu}^{XY} (#sigma)"; + deta_axis_title = "#Delta#eta = #eta_{#mu#mu} - #eta_{h}"; + dphi_axis_title = "#Delta#varphi = #varphi_{#mu#mu} - #varphi_{h} (rad.)"; + cosndphi_axis_title = std::format("cos({0:d}(#varphi_{{#mu#mu}} - #varphi_{{h}}))", cfgNmod.value); + } + + // dilepton info + const AxisSpec axis_mass{ConfMllBins, mass_axis_title}; + const AxisSpec axis_pt{ConfPtllBins, pair_pt_axis_title}; + const AxisSpec axis_dca{ConfDCAllBins, pair_dca_axis_title}; + const AxisSpec axis_y{ConfRapidityBins, pair_rapidity_axis_title}; + + // dilepton-hadron info + const AxisSpec axis_pt_ref{ConfPtHadronBins, "p_{T,h}^{ref} (GeV/c)"}; + const AxisSpec axis_deta{ConfDEtaBins, deta_axis_title}; + + // hadron-hadron info + const AxisSpec axis_deta_hh{60, -3, +3, "#Delta#eta = #eta_{h}^{trg} - #eta_{h}^{ref}"}; + + const AxisSpec axis_pt_trg{ConfPtHadronBins, "p_{T,h} (GeV/c)"}; + const AxisSpec axis_eta_trg{40, -2, +2, "#eta_{h}"}; + const AxisSpec axis_phi_trg{36, 0, 2 * M_PI, "#varphi_{h} (rad.)"}; + fRegistry.add("Hadron/hs", "hadron", kTHnSparseD, {axis_pt_trg, axis_eta_trg, axis_phi_trg}, true); + fRegistry.add("Dilepton/same/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_y}, true); + fRegistry.addClone("Dilepton/same/uls/", "Dilepton/same/lspp/"); + fRegistry.addClone("Dilepton/same/uls/", "Dilepton/same/lsmm/"); + fRegistry.addClone("Dilepton/same/", "Dilepton/mix/"); + + if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonHadronAnalysisType::kAzimuthalCorrelation)) { + const AxisSpec axis_dphi{cfgNbinsDPhi, -M_PI / 2, 3 * M_PI / 2, dphi_axis_title}; + const AxisSpec axis_dphi_hh{cfgNbinsDPhi, -M_PI / 2, 3 * M_PI / 2, "#Delta#varphi = #varphi_{h}^{trg} - #varphi_{h}^{ref} (rad.)"}; + // dilepton-hadron + fRegistry.add("DileptonHadron/same/uls/hs", "dilepton-hadron 2PC", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_y, axis_pt_ref, axis_deta, axis_dphi}, true); + fRegistry.addClone("DileptonHadron/same/uls/", "DileptonHadron/same/lspp/"); + fRegistry.addClone("DileptonHadron/same/uls/", "DileptonHadron/same/lsmm/"); + // fRegistry.addClone("DileptonHadron/same/", "DileptonHadron/mix/"); + + // hadron-hadron + const AxisSpec axis_cosndphi_hh{cfgNbinsCosNDPhi, -1, +1, std::format("cos({0:d}(#varphi_{{h}}^{{trg}} - #varphi_{{h}}^{{ref}}))", cfgNmod.value)}; + fRegistry.add("HadronHadron/same/hs", "hadron-hadron 2PC", kTHnSparseD, {axis_pt_trg, axis_pt_ref, axis_deta_hh, axis_dphi_hh}, true); + fRegistry.addClone("HadronHadron/same/", "HadronHadron/mix/"); + fRegistry.add("HadronHadron/mix/hDiffBC", "diff. global BC in mixed event;|BC_{current} - BC_{mixed}|", kTH1D, {{10001, -0.5, 10000.5}}, true); + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonHadronAnalysisType::kCumulant)) { + const AxisSpec axis_cos_ndphi{cfgNbinsCosNDPhi, -1, +1, cosndphi_axis_title}; + + // dilepton-hadron + fRegistry.add("DileptonHadron/same/uls/hs", "dilepton-hadron 2PC", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_y, axis_pt_ref, axis_deta, axis_cos_ndphi}, true); + fRegistry.addClone("DileptonHadron/same/uls/", "DileptonHadron/same/lspp/"); + fRegistry.addClone("DileptonHadron/same/uls/", "DileptonHadron/same/lsmm/"); + fRegistry.addClone("DileptonHadron/same/", "DileptonHadron/mix/"); + + // hadron-hadron + const AxisSpec axis_cosndphi_hh{cfgNbinsCosNDPhi, -1, +1, std::format("cos({0:d}(#varphi_{{h}}^{{trg}} - #varphi_{{h}}^{{ref}}))", cfgNmod.value)}; + fRegistry.add("HadronHadron/same/hs", "hadron-hadron 2PC", kTHnSparseD, {axis_pt_trg, axis_pt_ref, axis_deta_hh, axis_cosndphi_hh}, true); + } + fRegistry.add("Dilepton/mix/hDiffBC", "diff. global BC in mixed event;|BC_{current} - BC_{mixed}|", kTH1D, {{10001, -0.5, 10000.5}}, true); + } + + void DefineEMEventCut() + { + fEMEventCut = EMEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); + fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); + fEMEventCut.SetZvtxRange(eventcuts.cfgZvtxMin, eventcuts.cfgZvtxMax); + fEMEventCut.SetRequireNoTFB(eventcuts.cfgRequireNoTFB); + fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); + fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); + fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); + fEMEventCut.SetRequireVertexTOFmatched(eventcuts.cfgRequireVertexTOFmatched); + fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); + fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); + fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); + fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); + fEMEventCut.SetRequireNoHighMultCollInPrevRof(eventcuts.cfgRequireNoHighMultCollInPrevRof); + fEMEventCut.SetRequireGoodITSLayer3(eventcuts.cfgRequireGoodITSLayer3); + fEMEventCut.SetRequireGoodITSLayer0123(eventcuts.cfgRequireGoodITSLayer0123); + fEMEventCut.SetRequireGoodITSLayersAll(eventcuts.cfgRequireGoodITSLayersAll); + } + + o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; + void DefineDielectronCut() + { + fDielectronCut = DielectronCut("fDielectronCut", "fDielectronCut"); + + // for pair + fDielectronCut.SetMeeRange(dielectroncuts.cfg_min_mass, dielectroncuts.cfg_max_mass); + fDielectronCut.SetPairPtRange(dielectroncuts.cfg_min_pair_pt, dielectroncuts.cfg_max_pair_pt); + fDielectronCut.SetPairYRange(dielectroncuts.cfg_min_pair_y, dielectroncuts.cfg_max_pair_y); + fDielectronCut.SetPairDCARange(dielectroncuts.cfg_min_pair_dca3d, dielectroncuts.cfg_max_pair_dca3d); // in sigma + fDielectronCut.SetMaxMeePhiVDep([&](float phiv) { return dielectroncuts.cfg_phiv_intercept + phiv * dielectroncuts.cfg_phiv_slope; }, dielectroncuts.cfg_min_phiv, dielectroncuts.cfg_max_phiv); + fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); + fDielectronCut.SetMindEtadPhi(dielectroncuts.cfg_apply_detadphi, dielectroncuts.cfg_apply_detadphiposition, dielectroncuts.cfg_min_deta, dielectroncuts.cfg_min_dphi); + fDielectronCut.SetPairOpAng(0.f, 6.3); + fDielectronCut.SetRequireDifferentSides(false); + + // for track + fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, dielectroncuts.cfg_max_pt_track); + fDielectronCut.SetTrackEtaRange(dielectroncuts.cfg_min_eta_track, dielectroncuts.cfg_max_eta_track); + fDielectronCut.SetTrackPhiRange(dielectroncuts.cfg_min_phi_track, dielectroncuts.cfg_max_phi_track, false, false); + fDielectronCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); + fDielectronCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); + fDielectronCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fDielectronCut.SetMaxFracSharedClustersTPC(dielectroncuts.cfg_max_frac_shared_clusters_tpc); + fDielectronCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); + fDielectronCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); + fDielectronCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); + fDielectronCut.SetMeanClusterSizeITS(0.f, 16.f); + fDielectronCut.SetTrackMaxDcaXY(dielectroncuts.cfg_max_dcaxy); + fDielectronCut.SetTrackMaxDcaZ(dielectroncuts.cfg_max_dcaz); + fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); + fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); + fDielectronCut.SetChi2TOF(0, dielectroncuts.cfg_max_chi2tof); + fDielectronCut.SetRelDiffPin(-1e+10, +1e+10); + fDielectronCut.IncludeITSsa(false, 0.15); + + // for eID + fDielectronCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); + fDielectronCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); + fDielectronCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); + fDielectronCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); + fDielectronCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); + fDielectronCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); + fDielectronCut.SetPinRangeForPionRejectionTPC(dielectroncuts.cfg_min_pin_pirejTPC, dielectroncuts.cfg_max_pin_pirejTPC); + + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut + static constexpr int nClassesMl = 2; + const std::vector cutDirMl = {o2::cuts_ml::CutNot, o2::cuts_ml::CutSmaller}; + const std::vector labelsClasses = {"Background", "Signal"}; + const uint32_t nBinsMl = dielectroncuts.binsMl.value.size() - 1; + const std::vector labelsBins(nBinsMl, "bin"); + double cutsMlArr[nBinsMl][nClassesMl]; + for (uint32_t i = 0; i < nBinsMl; i++) { + cutsMlArr[i][0] = 0.; + cutsMlArr[i][1] = dielectroncuts.cutsMl.value[i]; + } + o2::framework::LabeledArray cutsMl = {cutsMlArr[0], nBinsMl, nClassesMl, labelsBins, labelsClasses}; + + mlResponseSingleTrack.configure(dielectroncuts.binsMl.value, cutsMl, cutDirMl, nClassesMl); + if (dielectroncuts.loadModelsFromCCDB) { + ccdbApi.init(ccdburl); + mlResponseSingleTrack.setModelPathsCCDB(dielectroncuts.onnxFileNames.value, ccdbApi, dielectroncuts.onnxPathsCCDB.value, dielectroncuts.timestampCCDB.value); + } else { + mlResponseSingleTrack.setModelPathsLocal(dielectroncuts.onnxFileNames.value); + } + mlResponseSingleTrack.cacheInputFeaturesIndices(dielectroncuts.namesInputFeatures); + mlResponseSingleTrack.cacheBinningIndex(dielectroncuts.nameBinningFeature); + mlResponseSingleTrack.init(dielectroncuts.enableOptimizations.value); + + fDielectronCut.SetPIDMlResponse(&mlResponseSingleTrack); + } // end of PID ML + } + + void DefineDimuonCut() + { + fDimuonCut = DimuonCut("fDimuonCut", "fDimuonCut"); + + // for pair + fDimuonCut.SetMassRange(dimuoncuts.cfg_min_mass, dimuoncuts.cfg_max_mass); + fDimuonCut.SetPairPtRange(dimuoncuts.cfg_min_pair_pt, dimuoncuts.cfg_max_pair_pt); + fDimuonCut.SetPairYRange(dimuoncuts.cfg_min_pair_y, dimuoncuts.cfg_max_pair_y); + fDimuonCut.SetPairDCAxyRange(dimuoncuts.cfg_min_pair_dcaxy, dimuoncuts.cfg_max_pair_dcaxy); + fDimuonCut.SetMindEtadPhi(dimuoncuts.cfg_apply_detadphi, dimuoncuts.cfg_min_deta, dimuoncuts.cfg_min_dphi); + + // for track + fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); + fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, dimuoncuts.cfg_max_pt_track); + fDimuonCut.SetTrackEtaRange(dimuoncuts.cfg_min_eta_track, dimuoncuts.cfg_max_eta_track); + fDimuonCut.SetTrackPhiRange(dimuoncuts.cfg_min_phi_track, dimuoncuts.cfg_max_phi_track); + fDimuonCut.SetNClustersMFT(dimuoncuts.cfg_min_ncluster_mft, 10); + fDimuonCut.SetNClustersMCHMID(dimuoncuts.cfg_min_ncluster_mch, 16); + fDimuonCut.SetChi2(0.f, dimuoncuts.cfg_max_chi2); + fDimuonCut.SetMatchingChi2MCHMFT(0.f, dimuoncuts.cfg_max_matching_chi2_mftmch); + fDimuonCut.SetMatchingChi2MCHMID(0.f, dimuoncuts.cfg_max_matching_chi2_mchmid); + fDimuonCut.SetDCAxy(0.f, dimuoncuts.cfg_max_dcaxy); + fDimuonCut.SetRabs(dimuoncuts.cfg_min_rabs, dimuoncuts.cfg_max_rabs); + fDimuonCut.SetMaxPDCARabsDep([&](float rabs) { return (rabs < 26.5 ? 594.f : 324.f); }); + fDimuonCut.SetMaxdPtdEtadPhiwrtMCHMID(dimuoncuts.cfg_max_relDPt_wrt_matchedMCHMID, dimuoncuts.cfg_max_DEta_wrt_matchedMCHMID, dimuoncuts.cfg_max_DPhi_wrt_matchedMCHMID); // this is relevant for global muons + fDimuonCut.SetMFTHitMap(dimuoncuts.requireMFTHitMap, dimuoncuts.requiredMFTDisks); + } + + void DefineEMTrackCut() + { + fEMTrackCut = EMTrackCut("fEMTrackCut", "fEMTrackCut"); + fEMTrackCut.SetTrackPtRange(trackcuts.cfg_min_pt_track, trackcuts.cfg_max_pt_track); + fEMTrackCut.SetTrackEtaRange(trackcuts.cfg_min_eta_track, trackcuts.cfg_max_eta_track); + fEMTrackCut.SetTrackPhiRange(trackcuts.cfg_min_phi_track, trackcuts.cfg_max_phi_track); + fEMTrackCut.SetTrackMaxDcaXY(trackcuts.cfg_max_dcaxy); + fEMTrackCut.SetTrackMaxDcaZ(trackcuts.cfg_max_dcaz); + fEMTrackCut.SetTrackBit(trackcuts.cfg_track_bits); + // fEMTrackCut.SetMinNClustersTPC(trackcuts.cfg_min_ncluster_tpc); + // fEMTrackCut.SetMinNCrossedRowsTPC(trackcuts.cfg_min_ncrossedrows); + // fEMTrackCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + // fEMTrackCut.SetMaxFracSharedClustersTPC(trackcuts.cfg_max_frac_shared_clusters_tpc); + // fEMTrackCut.SetChi2PerClusterTPC(0.0, trackcuts.cfg_max_chi2tpc); + // fEMTrackCut.SetChi2PerClusterITS(0.0, trackcuts.cfg_max_chi2its); + // fEMTrackCut.SetNClustersITS(trackcuts.cfg_min_ncluster_its, 7); + // fEMTrackCut.RequireITSibAny(trackcuts.cfg_require_itsib_any); + // fEMTrackCut.RequireITSib1st(trackcuts.cfg_require_itsib_1st); + } + + template + bool fillDilepton(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const& tracks) + { + if constexpr (ev_id == 1) { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + auto v1ambIds = t1.ambiguousElectronsIds(); + auto v2ambIds = t2.ambiguousElectronsIds(); + + if ((t1.dfId() == t2.dfId()) && std::find(v2ambIds.begin(), v2ambIds.end(), t1.globalIndex()) != v2ambIds.end() && std::find(v1ambIds.begin(), v1ambIds.end(), t2.globalIndex()) != v1ambIds.end()) { + return false; // this is protection against pairing 2 identical tracks. This happens, when TTCA is used. TTCA can assign a track to several possible collisions. + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + auto v1ambIds = t1.ambiguousMuonsIds(); + auto v2ambIds = t2.ambiguousMuonsIds(); + + if ((t1.dfId() == t2.dfId()) && std::find(v2ambIds.begin(), v2ambIds.end(), t1.globalIndex()) != v2ambIds.end() && std::find(v1ambIds.begin(), v1ambIds.end(), t2.globalIndex()) != v1ambIds.end()) { + return false; // this is protection against pairing 2 identical tracks. This happens, when TTCA is used. TTCA can assign a track to several possible collisions. + } + } + } + + if constexpr (ev_id == 0) { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut.template IsSelectedTrack(t1, collision) || !cut.template IsSelectedTrack(t2, collision)) { + return false; + } + } else { // cut-based + if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { + return false; + } + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { + return false; + } + + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) { + return false; + } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) { + return false; + } + } + } + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (!cut.IsSelectedPair(t1, t2, d_bz, dielectroncuts.cfgRefR)) { + return false; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.IsSelectedPair(t1, t2)) { + return false; + } + } + + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[std::make_pair(t1.globalIndex(), t2.globalIndex())]; + } + if (ev_id == 1) { + weight = 1.f; + } + + ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), leptonM1); + ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), leptonM2); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + + float pair_dca = 999.f; + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + pair_dca = pairDCAQuadSum(dca3DinSigma(t1), dca3DinSigma(t2)); + if (cfgDCAType == 1) { + pair_dca = pairDCAQuadSum(dcaXYinSigma(t1), dcaXYinSigma(t2)); + } else if (cfgDCAType == 2) { + pair_dca = pairDCAQuadSum(dcaZinSigma(t1), dcaZinSigma(t2)); + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + pair_dca = pairDCAQuadSum(fwdDcaXYinSigma(t1), fwdDcaXYinSigma(t2)); + } + + if (t1.sign() * t2.sign() < 0) { // ULS + fRegistry.fill(HIST("Dilepton/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), pair_dca, v12.Rapidity(), weight); + } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++ + fRegistry.fill(HIST("Dilepton/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hs"), v12.M(), v12.Pt(), pair_dca, v12.Rapidity(), weight); + } else if (t1.sign() < 0 && t2.sign() < 0) { // LS-- + fRegistry.fill(HIST("Dilepton/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hs"), v12.M(), v12.Pt(), pair_dca, v12.Rapidity(), weight); + } + + // store tracks for event mixing without double counting + if constexpr (ev_id == 0) { + std::pair key_df_collision = std::make_pair(ndf, collision.globalIndex()); + std::pair pair_tmp_id1 = std::make_pair(ndf, t1.globalIndex()); + std::pair pair_tmp_id2 = std::make_pair(ndf, t2.globalIndex()); + + std::vector possibleIds1; + std::vector possibleIds2; + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + std::copy(t1.ambiguousElectronsIds().begin(), t1.ambiguousElectronsIds().end(), std::back_inserter(possibleIds1)); + std::copy(t2.ambiguousElectronsIds().begin(), t2.ambiguousElectronsIds().end(), std::back_inserter(possibleIds2)); + + if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id1) == used_trackIds.end()) { + used_trackIds.emplace_back(pair_tmp_id1); + if (cfgDoMix) { + if (t1.sign() > 0) { + emh_pos->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.dcaXY(), t1.dcaZ(), possibleIds1, t1.cYY(), t1.cZY(), t1.cZZ())); + } else { + emh_neg->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), leptonM1, t1.sign(), t1.dcaXY(), t1.dcaZ(), possibleIds1, t1.cYY(), t1.cZY(), t1.cZZ())); + } + } + } + if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id2) == used_trackIds.end()) { + used_trackIds.emplace_back(pair_tmp_id2); + if (cfgDoMix) { + if (t2.sign() > 0) { + emh_pos->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds2, t2.cYY(), t2.cZY(), t2.cZZ())); + } else { + emh_neg->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), leptonM2, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds2, t2.cYY(), t2.cZY(), t2.cZZ())); + } + } + } + } else if (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + std::copy(t1.ambiguousMuonsIds().begin(), t1.ambiguousMuonsIds().end(), std::back_inserter(possibleIds1)); + std::copy(t2.ambiguousMuonsIds().begin(), t2.ambiguousMuonsIds().end(), std::back_inserter(possibleIds2)); + + if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id1) == used_trackIds.end()) { + used_trackIds.emplace_back(pair_tmp_id1); + if (cfgDoMix) { + if (t1.sign() > 0) { + emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.fwdtrackId(), t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon, t1.sign(), t1.fwdDcaX(), t1.fwdDcaY(), possibleIds1, + t1.cXXatDCA(), t1.cXYatDCA(), t1.cYYatDCA())); + } else { + emh_neg->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.fwdtrackId(), t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon, t1.sign(), t1.fwdDcaX(), t1.fwdDcaY(), possibleIds1, + t1.cXXatDCA(), t1.cXYatDCA(), t1.cYYatDCA())); + } + } + } + if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id2) == used_trackIds.end()) { + used_trackIds.emplace_back(pair_tmp_id2); + if (cfgDoMix) { + if (t2.sign() > 0) { + emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.fwdtrackId(), t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon, t2.sign(), t2.fwdDcaX(), t2.fwdDcaY(), possibleIds2, + t2.cXXatDCA(), t2.cXYatDCA(), t2.cYYatDCA())); + } else { + emh_neg->AddTrackToEventPool(key_df_collision, EMFwdTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.fwdtrackId(), t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon, t2.sign(), t2.fwdDcaX(), t2.fwdDcaY(), possibleIds2, + t2.cXXatDCA(), t2.cXYatDCA(), t2.cYYatDCA())); + } + } + } + } + + // possibleIds1.clear(); + // possibleIds1.shrink_to_fit(); + // possibleIds2.clear(); + // possibleIds2.shrink_to_fit(); + } + return true; + } + + template + bool fillDileptonHadron(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const& tracks, TRefTrack const& t3) + { + // this function must be called, if dilepton passes the cut. + if constexpr (ev_id == 1) { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + // bool is_found1 = std::find(t2.ambiguousElectronsIds.begin(), t2.ambiguousElectronsIds.end(), t1.globalIndex()) != t2.ambiguousElectronsIds.end(); // this does not work. + // bool is_found2 = std::find(t1.ambiguousElectronsIds.begin(), t1.ambiguousElectronsIds.end(), t2.globalIndex()) != t1.ambiguousElectronsIds.end(); // this does not work. + auto v1ambIds = t1.ambiguousElectronsIds(); + auto v2ambIds = t2.ambiguousElectronsIds(); + + if ((t1.dfId() == t2.dfId()) && std::find(v2ambIds.begin(), v2ambIds.end(), t1.globalIndex()) != v2ambIds.end() && std::find(v1ambIds.begin(), v1ambIds.end(), t2.globalIndex()) != v1ambIds.end()) { + return false; // this is protection against pairing 2 identical tracks. This happens, when TTCA is used. TTCA can assign a track to several possible collisions. + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + // bool is_found1 = std::find(t2.ambiguousMuonsIds.begin(), t2.ambiguousMuonsIds.end(), t1.globalIndex()) != t2.ambiguousMuonsIds.end(); // this does not work. + // bool is_found2 = std::find(t1.ambiguousMuonsIds.begin(), t1.ambiguousMuonsIds.end(), t2.globalIndex()) != t1.ambiguousMuonsIds.end(); // this does not work. + auto v1ambIds = t1.ambiguousMuonsIds(); + auto v2ambIds = t2.ambiguousMuonsIds(); + + if ((t1.dfId() == t2.dfId()) && std::find(v2ambIds.begin(), v2ambIds.end(), t1.globalIndex()) != v2ambIds.end() && std::find(v1ambIds.begin(), v1ambIds.end(), t2.globalIndex()) != v1ambIds.end()) { + return false; // this is protection against pairing 2 identical tracks. This happens, when TTCA is used. TTCA can assign a track to several possible collisions. + } + } + } + + if constexpr (ev_id == 0) { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut.template IsSelectedTrack(t1, collision) || !cut.template IsSelectedTrack(t2, collision)) { + return false; + } + } else { // cut-based + if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { + return false; + } + } + if (t1.trackId() == t3.trackId() || t2.trackId() == t3.trackId()) { + return false; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { + return false; + } + + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) { + return false; + } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) { + return false; + } + } + + if (!fEMTrackCut.IsSelected(t3)) { // for charged track + return false; + } + } + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (!cut.IsSelectedPair(t1, t2, d_bz, dielectroncuts.cfgRefR)) { + return false; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.IsSelectedPair(t1, t2)) { + return false; + } + } + + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[std::make_pair(t1.globalIndex(), t2.globalIndex())]; + } + if (ev_id == 1) { + weight = 1.f; + } + + ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), leptonM1); + ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), leptonM2); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + + ROOT::Math::PtEtaPhiMVector v3(t3.pt(), t3.eta(), t3.phi(), 0.139); // mass of hadron does not matter. + float deta = v12.Eta() - v3.Eta(); + float dphi = v12.Phi() - v3.Phi(); + + float pair_dca = 999.f; + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + pair_dca = pairDCAQuadSum(dca3DinSigma(t1), dca3DinSigma(t2)); + if (cfgDCAType == 1) { + pair_dca = pairDCAQuadSum(dcaXYinSigma(t1), dcaXYinSigma(t2)); + } else if (cfgDCAType == 2) { + pair_dca = pairDCAQuadSum(dcaZinSigma(t1), dcaZinSigma(t2)); + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + pair_dca = pairDCAQuadSum(fwdDcaXYinSigma(t1), fwdDcaXYinSigma(t2)); + } + + if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonHadronAnalysisType::kAzimuthalCorrelation)) { + dphi = RecoDecay::constrainAngle(dphi, -M_PI / 2, 1U); + if (t1.sign() * t2.sign() < 0) { // ULS + fRegistry.fill(HIST("DileptonHadron/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), pair_dca, v12.Rapidity(), v3.Pt(), deta, dphi, weight); + } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++ + fRegistry.fill(HIST("DileptonHadron/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hs"), v12.M(), v12.Pt(), pair_dca, v12.Rapidity(), v3.Pt(), deta, dphi, weight); + } else if (t1.sign() < 0 && t2.sign() < 0) { // LS-- + fRegistry.fill(HIST("DileptonHadron/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hs"), v12.M(), v12.Pt(), pair_dca, v12.Rapidity(), v3.Pt(), deta, dphi, weight); + } + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonHadronAnalysisType::kCumulant)) { + o2::math_utils::bringTo02Pi(dphi); + float cosndphi = std::cos(cfgNmod * dphi); + if (t1.sign() * t2.sign() < 0) { // ULS + fRegistry.fill(HIST("DileptonHadron/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), pair_dca, v12.Rapidity(), v3.Pt(), deta, cosndphi, weight); + } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++ + fRegistry.fill(HIST("DileptonHadron/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hs"), v12.M(), v12.Pt(), pair_dca, v12.Rapidity(), v3.Pt(), deta, cosndphi, weight); + } else if (t1.sign() < 0 && t2.sign() < 0) { // LS-- + fRegistry.fill(HIST("DileptonHadron/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hs"), v12.M(), v12.Pt(), pair_dca, v12.Rapidity(), v3.Pt(), deta, cosndphi, weight); + } + } + + return true; + } + + template + bool fillHadronHadron(TCollision const& collision, TRefTrack const& t1, TRefTrack const& t2, TLeptons const& posLeptons, TLeptons const& negLeptons) + { + if constexpr (ev_id == 0) { + if (!fEMTrackCut.IsSelected(t1) || !fEMTrackCut.IsSelected(t2)) { // for charged track + return false; + } + + // Leptons should not be in reference track sample. + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + for (const auto& pos : posLeptons) { // leptons per collision + if (t1.trackId() == pos.trackId() || t2.trackId() == pos.trackId()) { + return false; + } + } + for (const auto& neg : negLeptons) { // leptons per collision + if (t1.trackId() == neg.trackId() || t2.trackId() == neg.trackId()) { + return false; + } + } + } + } + + if constexpr (ev_id == 1) { + if (t1.dfId() == t2.dfId() && t1.globalIndex() == t2.globalIndex()) { + return false; // this never happens. only for protection. + } + } + + float weight = 1.f; + float deta = t1.eta() - t2.eta(); // t1 is trigger, t2 is associated + float dphi = t1.phi() - t2.phi(); // t1 is trigger, t2 is associated + + if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonHadronAnalysisType::kAzimuthalCorrelation)) { + dphi = RecoDecay::constrainAngle(dphi, -M_PI / 2, 1U); + fRegistry.fill(HIST("HadronHadron/") + HIST(event_pair_types[ev_id]) + HIST("hs"), t1.pt(), t2.pt(), deta, dphi, weight); + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonHadronAnalysisType::kCumulant)) { + o2::math_utils::bringTo02Pi(dphi); + float cosndphi = std::cos(cfgNmod * dphi); + fRegistry.fill(HIST("HadronHadron/") + HIST(event_pair_types[ev_id]) + HIST("hs"), t1.pt(), t2.pt(), deta, cosndphi, weight); + } + + // store ref tracks for mixed event in case of kAzimuthalCorrelation + if constexpr (ev_id == 0) { + if (cfgDoMix && cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonHadronAnalysisType::kAzimuthalCorrelation)) { + std::pair key_df_collision = std::make_pair(ndf, collision.globalIndex()); + std::pair pair_tmp_id1 = std::make_pair(ndf, t1.globalIndex()); + std::pair pair_tmp_id2 = std::make_pair(ndf, t2.globalIndex()); + if (std::find(used_refTrackIds.begin(), used_refTrackIds.end(), pair_tmp_id1) == used_refTrackIds.end()) { + used_refTrackIds.emplace_back(pair_tmp_id1); + emh_ref->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), 0.139)); + } // store t1 + if (std::find(used_refTrackIds.begin(), used_refTrackIds.end(), pair_tmp_id2) == used_refTrackIds.end()) { + used_refTrackIds.emplace_back(pair_tmp_id2); + emh_ref->AddTrackToEventPool(key_df_collision, EMTrack(ndf, t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), 0.139)); + } // store t2 + } + } + + return true; + } + + Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); + // Filter collisionFilter_multiplicity = cfgNtracksPV08Min <= o2::aod::mult::multNTracksPV && o2::aod::mult::multNTracksPV < cfgNtracksPV08Max; + Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + using FilteredMyCollisions = soa::Filtered; + + SliceCache cache; + Preslice perCollision_electron = aod::emprimaryelectron::emeventId; + Filter trackFilter_electron = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && dielectroncuts.cfg_min_eta_track < o2::aod::track::eta && o2::aod::track::eta < dielectroncuts.cfg_max_eta_track && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz; + Filter ttcaFilter_electron = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); + Filter prefilter_derived_electron = ifnode(dielectroncuts.cfg_apply_cuts_from_prefilter_derived.node() && dielectroncuts.cfg_prefilter_bits_derived.node() >= static_cast(1), + ifnode((dielectroncuts.cfg_prefilter_bits_derived.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kMee))) > static_cast(0), (o2::aod::emprimaryelectron::pfbderived & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kMee))) <= static_cast(0), true) && + ifnode((dielectroncuts.cfg_prefilter_bits_derived.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kPhiV))) > static_cast(0), (o2::aod::emprimaryelectron::pfbderived & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kPhiV))) <= static_cast(0), true) && + ifnode((dielectroncuts.cfg_prefilter_bits_derived.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS))) > static_cast(0), (o2::aod::emprimaryelectron::pfbderived & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS))) <= static_cast(0), true) && + ifnode((dielectroncuts.cfg_prefilter_bits_derived.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackULS))) > static_cast(0), (o2::aod::emprimaryelectron::pfbderived & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackULS))) <= static_cast(0), true), + o2::aod::emprimaryelectron::pfbderived >= static_cast(0)); + + Filter prefilter_electron = ifnode(dielectroncuts.cfg_apply_cuts_from_prefilter.node() && dielectroncuts.cfg_prefilter_bits.node() >= static_cast(1), + ifnode((dielectroncuts.cfg_prefilter_bits.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPC))) > static_cast(0), (o2::aod::emprimaryelectron::pfb & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPC))) <= static_cast(0), true) && + ifnode((dielectroncuts.cfg_prefilter_bits.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPi0_1))) > static_cast(0), (o2::aod::emprimaryelectron::pfb & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPi0_1))) <= static_cast(0), true) && + ifnode((dielectroncuts.cfg_prefilter_bits.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPi0_2))) > static_cast(0), (o2::aod::emprimaryelectron::pfb & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPi0_2))) <= static_cast(0), true) && + ifnode((dielectroncuts.cfg_prefilter_bits.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPi0_3))) > static_cast(0), (o2::aod::emprimaryelectron::pfb & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kElFromPi0_3))) <= static_cast(0), true), + o2::aod::emprimaryelectron::pfb >= static_cast(0)); + + Partition positive_electrons = o2::aod::emprimaryelectron::sign > int8_t(0); + Partition negative_electrons = o2::aod::emprimaryelectron::sign < int8_t(0); + + Preslice perCollision_track = aod::emprimarytrack::emeventId; + + Preslice perCollision_muon = aod::emprimarymuon::emeventId; + Filter trackFilter_muon = o2::aod::fwdtrack::trackType == dimuoncuts.cfg_track_type && dimuoncuts.cfg_min_pt_track < o2::aod::fwdtrack::pt && o2::aod::fwdtrack::pt < dimuoncuts.cfg_max_pt_track && dimuoncuts.cfg_min_eta_track < o2::aod::fwdtrack::eta && o2::aod::fwdtrack::eta < dimuoncuts.cfg_max_eta_track && dimuoncuts.cfg_min_phi_track < o2::aod::fwdtrack::phi && o2::aod::fwdtrack::phi < dimuoncuts.cfg_max_phi_track; + Filter ttcaFilter_muon = ifnode(dimuoncuts.enableTTCA.node(), o2::aod::emprimarymuon::isAssociatedToMPC == true || o2::aod::emprimarymuon::isAssociatedToMPC == false, o2::aod::emprimarymuon::isAssociatedToMPC == true); + Partition positive_muons = o2::aod::emprimarymuon::sign > int8_t(0); + Partition negative_muons = o2::aod::emprimarymuon::sign < int8_t(0); + + TEMH* emh_pos = nullptr; + TEMH* emh_neg = nullptr; + MyEMH_track* emh_ref = nullptr; // for reference flow + std::map, uint64_t> map_mixed_eventId_to_globalBC; + + std::vector> used_trackIds; + std::vector> used_refTrackIds; + int ndf = 0; + + template + void run2PC(TCollisions const& collisions, TLeptons const& posTracks, TLeptons const& negTracks, TPresilce const& perCollision, TCut const& cut, TAllTracks const& tracks, TRefTracks const& refTracks) + { + for (const auto& collision : collisions) { + initCCDB(collision); + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + float centrality = centralities[cfgCentEstimator]; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + if constexpr (isTriggerAnalysis) { + if (!collision.swtalias_bit(o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value))) { + continue; + } + } + + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0, -1>(&fRegistry, collision); + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } + + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1, -1>(&fRegistry, collision); + fRegistry.fill(HIST("Event/before/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted + + auto refTracks_per_coll = refTracks.sliceBy(perCollision_track, collision.globalIndex()); + + auto posTracks_per_coll = posTracks.sliceByCached(perCollision, collision.globalIndex(), cache); + auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache); + + int nuls = 0, nlspp = 0, nlsmm = 0; + + for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + bool is_pair_ok = fillDilepton<0>(collision, pos, neg, cut, tracks); + if (is_pair_ok) { + nuls++; + for (const auto& refTrack : refTracks_per_coll) { + fillDileptonHadron<0>(collision, pos, neg, cut, tracks, refTrack); + } + } + } + for (const auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ + bool is_pair_ok = fillDilepton<0>(collision, pos1, pos2, cut, tracks); + if (is_pair_ok) { + nlspp++; + for (const auto& refTrack : refTracks_per_coll) { + fillDileptonHadron<0>(collision, pos1, pos2, cut, tracks, refTrack); + } + } + } + for (const auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- + bool is_pair_ok = fillDilepton<0>(collision, neg1, neg2, cut, tracks); + if (is_pair_ok) { + nlsmm++; + for (const auto& refTrack : refTracks_per_coll) { + fillDileptonHadron<0>(collision, neg1, neg2, cut, tracks, refTrack); + } + } + } + + if (nuls > 0 || nlspp > 0 || nlsmm > 0) { // at least 1 pair exists. + for (const auto& track : refTracks_per_coll) { + if (fEMTrackCut.IsSelected(track)) { + fRegistry.fill(HIST("Hadron/hs"), track.pt(), track.eta(), track.phi()); + } + } + for (const auto& [trg, ref] : combinations(CombinationsStrictlyUpperIndexPolicy(refTracks_per_coll, refTracks_per_coll))) { + fillHadronHadron<0>(collision, trg, ref, posTracks_per_coll, negTracks_per_coll); + } + } + + if (!cfgDoMix || !(nuls > 0 || nlspp > 0 || nlsmm > 0)) { + continue; + } + + // event mixing + int zbin = lower_bound(zvtx_bin_edges.begin(), zvtx_bin_edges.end(), collision.posZ()) - zvtx_bin_edges.begin() - 1; + if (zbin < 0) { + zbin = 0; + } else if (static_cast(zvtx_bin_edges.size()) - 2 < zbin) { + zbin = static_cast(zvtx_bin_edges.size()) - 2; + } + + int centbin = lower_bound(cent_bin_edges.begin(), cent_bin_edges.end(), centrality) - cent_bin_edges.begin() - 1; + if (centbin < 0) { + centbin = 0; + } else if (static_cast(cent_bin_edges.size()) - 2 < centbin) { + centbin = static_cast(cent_bin_edges.size()) - 2; + } + + int epbin = 0; + + int occbin = -1; + if (cfgOccupancyEstimator == 0) { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.ft0cOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } else if (cfgOccupancyEstimator == 1) { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.trackOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } else { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.ft0cOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } + + if (occbin < 0) { + occbin = 0; + } else if (static_cast(occ_bin_edges.size()) - 2 < occbin) { + occbin = static_cast(occ_bin_edges.size()) - 2; + } + + std::tuple key_bin = std::make_tuple(zbin, centbin, epbin, occbin); + std::pair key_df_collision = std::make_pair(ndf, collision.globalIndex()); + + // make a vector of selected electrons in this collision. + auto selected_posTracks_in_this_event = emh_pos->GetTracksPerCollision(key_df_collision); + auto selected_negTracks_in_this_event = emh_neg->GetTracksPerCollision(key_df_collision); + + auto collisionIds_in_mixing_pool = emh_pos->GetCollisionIdsFromEventPool(key_bin); // pos/neg does not matter. + + // perform event mixing, only if at least 1 dilepton exists. + + for (const auto& mix_dfId_collisionId : collisionIds_in_mixing_pool) { + int mix_dfId = mix_dfId_collisionId.first; + int mix_collisionId = mix_dfId_collisionId.second; + if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. + continue; + } + + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + fRegistry.fill(HIST("Dilepton/mix/hDiffBC"), diffBC); + if (diffBC < ndiff_bc_mix) { + continue; + } + + auto posTracks_from_event_pool = emh_pos->GetTracksPerCollision(mix_dfId_collisionId); + auto negTracks_from_event_pool = emh_neg->GetTracksPerCollision(mix_dfId_collisionId); + + for (const auto& pos : selected_posTracks_in_this_event) { // ULS mix + for (const auto& neg : negTracks_from_event_pool) { + fillDilepton<1>(collision, pos, neg, cut, tracks); + } + } + + for (const auto& neg : selected_negTracks_in_this_event) { // ULS mix + for (const auto& pos : posTracks_from_event_pool) { + fillDilepton<1>(collision, neg, pos, cut, tracks); + } + } + + for (const auto& pos1 : selected_posTracks_in_this_event) { // LS++ mix + for (const auto& pos2 : posTracks_from_event_pool) { + fillDilepton<1>(collision, pos1, pos2, cut, tracks); + } + } + + for (const auto& neg1 : selected_negTracks_in_this_event) { // LS-- mix + for (const auto& neg2 : negTracks_from_event_pool) { + fillDilepton<1>(collision, neg1, neg2, cut, tracks); + } + } + } // end of loop over mixed event pool for lepton-lepton + + if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonHadronAnalysisType::kAzimuthalCorrelation)) { + auto selected_refTracks_in_this_event = emh_ref->GetTracksPerCollision(key_df_collision); + auto collisionIds_in_mixing_pool_hadron = emh_ref->GetCollisionIdsFromEventPool(key_bin); + + for (const auto& mix_dfId_collisionId : collisionIds_in_mixing_pool_hadron) { + int mix_dfId = mix_dfId_collisionId.first; + int mix_collisionId = mix_dfId_collisionId.second; + if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. + continue; + } + + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + fRegistry.fill(HIST("HadronHadron/mix/hDiffBC"), diffBC); + if (diffBC < ndiff_bc_mix) { + continue; + } + + auto refTracks_from_event_pool = emh_ref->GetTracksPerCollision(mix_dfId_collisionId); + for (const auto& ref1 : selected_refTracks_in_this_event) { // ref-ref mix + for (const auto& ref2 : refTracks_from_event_pool) { + fillHadronHadron<1>(collision, ref1, ref2, nullptr, nullptr); + } + } + } // end of loop over mixed event pool for lepton-lepton + } + + if (nuls > 0 || nlspp > 0 || nlsmm > 0) { + map_mixed_eventId_to_globalBC[key_df_collision] = collision.globalBC(); + emh_pos->AddCollisionIdAtLast(key_bin, key_df_collision); + emh_neg->AddCollisionIdAtLast(key_bin, key_df_collision); + emh_ref->AddCollisionIdAtLast(key_bin, key_df_collision); + } + + } // end of collision loop + + } // end of DF + + template + bool isPairOK(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const& tracks) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut.template IsSelectedTrack(t1, collision) || !cut.template IsSelectedTrack(t2, collision)) { + return false; + } + } else { // cut-based + if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { + return false; + } + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.IsSelectedTrack(t1) || !cut.IsSelectedTrack(t2)) { + return false; + } + + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) { + return false; + } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) { + return false; + } + } + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (!cut.IsSelectedPair(t1, t2, d_bz, dielectroncuts.cfgRefR)) { + return false; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.IsSelectedPair(t1, t2)) { + return false; + } + } + return true; + } + + std::map, float> map_weight; // -> float + template + void fillPairWeightMap(TCollisions const& collisions, TLeptons const& posTracks, TLeptons const& negTracks, TPresilce const& perCollision, TCut const& cut, TAllTracks const& tracks) + { + std::vector> passed_pairIds; + passed_pairIds.reserve(posTracks.size() * negTracks.size()); + + for (const auto& collision : collisions) { + initCCDB(collision); + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + if constexpr (isTriggerAnalysis) { + if (!collision.swtalias_bit(o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value))) { + continue; + } + } + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } + + auto posTracks_per_coll = posTracks.sliceByCached(perCollision, collision.globalIndex(), cache); + auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache); + + for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + if (isPairOK(collision, pos, neg, cut, tracks)) { + passed_pairIds.emplace_back(std::make_pair(pos.globalIndex(), neg.globalIndex())); + } + } + for (const auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ + if (isPairOK(collision, pos1, pos2, cut, tracks)) { + passed_pairIds.emplace_back(std::make_pair(pos1.globalIndex(), pos2.globalIndex())); + } + } + for (const auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- + if (isPairOK(collision, neg1, neg2, cut, tracks)) { + passed_pairIds.emplace_back(std::make_pair(neg1.globalIndex(), neg2.globalIndex())); + } + } + } // end of collision loop + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + for (const auto& pairId : passed_pairIds) { + auto t1 = tracks.rawIteratorAt(std::get<0>(pairId)); + auto t2 = tracks.rawIteratorAt(std::get<1>(pairId)); + + float n = 1.f; // include myself. + for (const auto& ambId1 : t1.ambiguousElectronsIds()) { + for (const auto& ambId2 : t2.ambiguousElectronsIds()) { + if (std::find(passed_pairIds.begin(), passed_pairIds.end(), std::make_pair(ambId1, ambId2)) != passed_pairIds.end()) { + n += 1.f; + } + } + } + map_weight[pairId] = 1.f / n; + } // end of passed_pairIds loop + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + for (const auto& pairId : passed_pairIds) { + auto t1 = tracks.rawIteratorAt(std::get<0>(pairId)); + auto t2 = tracks.rawIteratorAt(std::get<1>(pairId)); + + float n = 1.f; // include myself. + for (const auto& ambId1 : t1.ambiguousMuonsIds()) { + for (const auto& ambId2 : t2.ambiguousMuonsIds()) { + if (std::find(passed_pairIds.begin(), passed_pairIds.end(), std::make_pair(ambId1, ambId2)) != passed_pairIds.end()) { + n += 1.f; + } + } + } + map_weight[pairId] = 1.f / n; + } // end of passed_pairIds loop + } + passed_pairIds.clear(); + passed_pairIds.shrink_to_fit(); + } + + void processAnalysis(FilteredMyCollisions const& collisions, MyTracks const& refTracks, Types const&... args) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + auto electrons = std::get<0>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillPairWeightMap(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, electrons); + } + run2PC(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, electrons, refTracks); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + auto muons = std::get<0>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillPairWeightMap(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons); + } + run2PC(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons, refTracks); + } + map_weight.clear(); + ndf++; + } + PROCESS_SWITCH(DileptonHadronMPC, processAnalysis, "run dilepton analysis", true); + + using FilteredMyCollisionsWithSWT = soa::Filtered; + void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, MyTracks const& refTracks, Types const&... args) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + auto electrons = std::get<0>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillPairWeightMap(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, electrons); + } + run2PC(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, electrons, refTracks); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + auto muons = std::get<0>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillPairWeightMap(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons); + } + run2PC(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, muons, refTracks); + } + map_weight.clear(); + ndf++; + } + PROCESS_SWITCH(DileptonHadronMPC, processTriggerAnalysis, "run dilepton analysis on triggered data", false); + + void processDummy(MyCollisions const&) {} + PROCESS_SWITCH(DileptonHadronMPC, processDummy, "Dummy function", false); +}; + +#endif // PWGEM_DILEPTON_CORE_DILEPTONHADRONMPC_H_ diff --git a/PWGEM/Dilepton/Core/DileptonMC.h b/PWGEM/Dilepton/Core/DileptonMC.h index a03ef162067..46e7ecbe9be 100644 --- a/PWGEM/Dilepton/Core/DileptonMC.h +++ b/PWGEM/Dilepton/Core/DileptonMC.h @@ -17,41 +17,40 @@ #ifndef PWGEM_DILEPTON_CORE_DILEPTONMC_H_ #define PWGEM_DILEPTON_CORE_DILEPTONMC_H_ -#include -#include -#include -#include +#include "PWGEM/Dilepton/Core/DielectronCut.h" +#include "PWGEM/Dilepton/Core/DimuonCut.h" +#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/Utils/MCUtilities.h" +#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" +#include "Common/CCDB/RCTSelectionFlags.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Tools/ML/MlResponse.h" + +#include "CCDB/BasicCCDBManager.h" #include "CommonConstants/LHCConstants.h" -#include "DataFormatsParameters/GRPLHCIFData.h" #include "DataFormatsParameters/GRPECSObject.h" - -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPLHCIFData.h" #include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Tools/ML/MlResponse.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "DCAFitter/DCAFitterN.h" -#include "DCAFitter/FwdDCAFitterN.h" +#include "Math/Vector4D.h" +#include "TString.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" -#include "PWGEM/Dilepton/Core/DielectronCut.h" -#include "PWGEM/Dilepton/Core/DimuonCut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.h" -#include "PWGEM/Dilepton/Utils/MCUtilities.h" -#include "PWGEM/Dilepton/Utils/EventHistograms.h" -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -68,12 +67,12 @@ using MyCollision = MyCollisions::iterator; using MyMCCollisions = soa::Join; using MyMCCollision = MyMCCollisions::iterator; -using MyMCElectrons = soa::Join; +using MyMCElectrons = soa::Join; using MyMCElectron = MyMCElectrons::iterator; using FilteredMyMCElectrons = soa::Filtered; using FilteredMyMCElectron = FilteredMyMCElectrons::iterator; -using MyMCMuons = soa::Join; +using MyMCMuons = soa::Join; using MyMCMuon = MyMCMuons::iterator; using FilteredMyMCMuons = soa::Filtered; using FilteredMyMCMuon = FilteredMyMCMuons::iterator; @@ -104,24 +103,40 @@ struct DileptonMC { Configurable cfgApplyWeightTTCA{"cfgApplyWeightTTCA", false, "flag to apply weighting by 1/N"}; Configurable cfgDCAType{"cfgDCAType", 0, "type of DCA for output. 0:3D, 1:XY, 2:Z, else:3D"}; Configurable cfgFillUnfolding{"cfgFillUnfolding", false, "flag to fill histograms for unfolding"}; + Configurable cfgRequireTrueAssociation{"cfgRequireTrueAssociation", false, "flag to require true mc collision association"}; ConfigurableAxis ConfMllBins{"ConfMllBins", {VARIABLE_WIDTH, 0.00, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.40, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.60, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.70, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.80, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.90, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.00, 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.75, 2.80, 2.85, 2.90, 2.95, 3.00, 3.05, 3.10, 3.15, 3.20, 3.25, 3.30, 3.35, 3.40, 3.45, 3.50, 3.55, 3.60, 3.65, 3.70, 3.75, 3.80, 3.85, 3.90, 3.95, 4.00}, "mll bins for output histograms"}; ConfigurableAxis ConfPtllBins{"ConfPtllBins", {VARIABLE_WIDTH, 0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.50, 3.00, 3.50, 4.00, 4.50, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00}, "pTll bins for output histograms"}; ConfigurableAxis ConfDCAllBins{"ConfDCAllBins", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCAll bins for output histograms"}; + ConfigurableAxis ConfDPtBins{"ConfDPtBins", {220, -1.0, +10.0}, "dpt bins for output histograms"}; + ConfigurableAxis ConfDCAllNarrowBins{"ConfDCAllNarrowBins", {200, 0.0, 10.0}, "narrow DCAll bins for output histograms"}; + ConfigurableAxis ConfTrackDCA{"ConfTrackDCA", {VARIABLE_WIDTH, -10, -9, -8, -7, -6, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.5, 3, 3.5, 4, 4.5, 5, 6, 7, 8, 9, 10}, "DCA binning for single tacks"}; + + ConfigurableAxis ConfYllBins{"ConfYllBins", {VARIABLE_WIDTH, -10.f, +10.f}, "yll bins for output histograms"}; + // ConfigurableAxis ConfMmumuBins{"ConfMmumuBins", {VARIABLE_WIDTH, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.40, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.60, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.70, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.80, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.90, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.00, 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.10, 1.11,1.12,1.13,1.14,1.15,1.16,1.17,1.18,1.19, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.75, 2.80, 2.85, 2.90, 2.95, 3.00, 3.05, 3.10, 3.15, 3.20, 3.25, 3.30, 3.35, 3.40, 3.45, 3.50, 3.55, 3.60, 3.65, 3.70, 3.75, 3.80, 3.85, 3.90, 3.95, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50, 4.60, 4.70, 4.80, 4.90, 5.00, 5.10, 5.20, 5.30, 5.40, 5.50, 5.60, 5.70, 5.80, 5.90, 6.00, 6.10, 6.20, 6.30, 6.40, 6.50, 6.60, 6.70, 6.80, 6.90, 7.00, 7.10, 7.20, 7.30, 7.40, 7.50, 7.60, 7.70, 7.80, 7.90, 8.00, 8.10, 8.20, 8.30, 8.40, 8.50, 8.60, 8.70, 8.80, 8.90, 9.00, 9.10, 9.20, 9.30, 9.40, 9.50, 9.60, 9.70, 9.80, 9.90, 10.00, 10.10, 10.20, 10.30, 10.40, 10.50, 10.60, 10.70, 10.80, 10.90, 11.00, 11.50, 12.00}, "mmumu bins for output histograms"}; // for dimuon. one can copy bins here to hyperloop page. + Configurable cfg_nbin_dphi_ee{"cfg_nbin_dphi_ee", 1, "number of bins for dphi_ee"}; // 36 + Configurable cfg_nbin_deta_ee{"cfg_nbin_deta_ee", 1, "number of bins for deta_ee"}; // 40 + Configurable cfg_nbin_cos_theta_cs{"cfg_nbin_cos_theta_cs", 1, "number of bins for cos theta cs"}; // 10 + Configurable cfg_nbin_phi_cs{"cfg_nbin_phi_cs", 1, "number of bins for phi cs"}; // 18 + Configurable cfg_nbin_aco{"cfg_nbin_aco", 1, "number of bins for acoplanarity"}; // 10 + Configurable cfg_nbin_asym_pt{"cfg_nbin_asym_pt", 1, "number of bins for pt asymmetry"}; // 10 + Configurable cfg_nbin_dphi_e_ee{"cfg_nbin_dphi_e_ee", 1, "number of bins for dphi_ee_e"}; // 18 + EMEventCut fEMEventCut; struct : ConfigurableGroup { std::string prefix = "eventcut_group"; Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; Configurable cfgZvtxMax{"cfgZvtxMax", +10.f, "max. Zvtx"}; - Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; + Configurable cfgRequireSel8{"cfgRequireSel8", false, "require sel8 in event cut"}; Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; - Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexTOFmatched{"cfgRequireVertexTOFmatched", false, "require Vertex TOFmatched in event cut"}; // ITS-TPC-TOF matched track contributes PV. Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; @@ -132,6 +147,14 @@ struct DileptonMC { Configurable cfgRequireNoCollInITSROFStandard{"cfgRequireNoCollInITSROFStandard", false, "require no collision in time range standard"}; Configurable cfgRequireNoCollInITSROFStrict{"cfgRequireNoCollInITSROFStrict", false, "require no collision in time range strict"}; Configurable cfgRequireNoHighMultCollInPrevRof{"cfgRequireNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + Configurable cfgRequireGoodITSLayer3{"cfgRequireGoodITSLayer3", false, "number of inactive chips on ITS layer 3 are below threshold "}; + Configurable cfgRequireGoodITSLayer0123{"cfgRequireGoodITSLayer0123", false, "number of inactive chips on ITS layers 0-3 are below threshold "}; + Configurable cfgRequireGoodITSLayersAll{"cfgRequireGoodITSLayersAll", false, "number of inactive chips on all ITS layers are below threshold "}; + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; } eventcuts; DielectronCut fDielectronCut; @@ -150,7 +173,8 @@ struct DileptonMC { Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; Configurable cfg_min_phiv{"cfg_min_phiv", 0.0, "min phiv (constant)"}; Configurable cfg_max_phiv{"cfg_max_phiv", 3.2, "max phiv (constant)"}; - Configurable cfg_apply_detadphi{"cfg_apply_detadphi", false, "flag to apply deta-dphi elliptic cut"}; + Configurable cfg_apply_detadphi{"cfg_apply_detadphi", false, "flag to apply deta-dphi elliptic cut at PV"}; + Configurable cfg_apply_detadphiposition{"cfg_apply_detadphiposition", false, "flag to apply deta-dphi elliptic cut at certain radius"}; Configurable cfg_min_deta{"cfg_min_deta", 0.02, "min deta between 2 electrons (elliptic cut)"}; Configurable cfg_min_dphi{"cfg_min_dphi", 0.2, "min dphi between 2 electrons (elliptic cut)"}; Configurable cfg_min_opang{"cfg_min_opang", 0.0, "min opening angle"}; @@ -165,10 +189,12 @@ struct DileptonMC { Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; - Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "max eta for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "min eta for single track"}; Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.8, "max eta for single track"}; - Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "max phi for single track"}; + Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "min phi for single track"}; Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; + Configurable cfg_mirror_phi_track{"cfg_mirror_phi_track", false, "mirror the phi cut around Pi, min and max Phi should be in 0-Pi"}; + Configurable cfg_reject_phi_track{"cfg_reject_phi_track", false, "reject the phi interval"}; Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 100, "min ncrossed rows"}; @@ -182,16 +208,15 @@ struct DileptonMC { Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; Configurable cfg_min_its_cluster_size{"cfg_min_its_cluster_size", 0.f, "min ITS cluster size"}; Configurable cfg_max_its_cluster_size{"cfg_max_its_cluster_size", 16.f, "max ITS cluster size"}; - Configurable cfg_min_p_its_cluster_size{"cfg_min_p_its_cluster_size", 0.0, "min p to apply ITS cluster size cut"}; - Configurable cfg_max_p_its_cluster_size{"cfg_max_p_its_cluster_size", 0.0, "max p to apply ITS cluster size cut"}; Configurable cfg_min_rel_diff_pin{"cfg_min_rel_diff_pin", -1e+10, "min rel. diff. between pin and ppv"}; Configurable cfg_max_rel_diff_pin{"cfg_max_rel_diff_pin", +1e+10, "max rel. diff. between pin and ppv"}; + Configurable cfgRefR{"cfgRefR", 1.2, "reference R (in m) for extrapolation"}; // https://cds.cern.ch/record/1419204 Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3, kTOFif = 4, kPIDML = 5]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; - Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; + // Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; + // Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -3.0, "min. TPC n sigma for kaon exclusion"}; @@ -200,16 +225,19 @@ struct DileptonMC { Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +3.0, "max. TPC n sigma for proton exclusion"}; Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + Configurable cfg_min_pin_pirejTPC{"cfg_min_pin_pirejTPC", 0.f, "min. pin for pion rejection in TPC"}; Configurable cfg_max_pin_pirejTPC{"cfg_max_pin_pirejTPC", 1e+10, "max. pin for pion rejection in TPC"}; - Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; - Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; - Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; - Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; - Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; - Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; + // Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; + // Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; + // Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; + // Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; + // Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; + // Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; // configuration for PID ML Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; @@ -238,8 +266,8 @@ struct DileptonMC { Configurable cfg_min_deta{"cfg_min_deta", 0.02, "min deta between 2 muons (elliptic cut)"}; Configurable cfg_min_dphi{"cfg_min_dphi", 0.02, "min dphi between 2 muons (elliptic cut)"}; - Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; - Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.1, "min pT for single track"}; + Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; Configurable cfg_min_eta_track{"cfg_min_eta_track", -4.0, "min eta for single track"}; Configurable cfg_max_eta_track{"cfg_max_eta_track", -2.5, "max eta for single track"}; @@ -247,19 +275,24 @@ struct DileptonMC { Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; Configurable cfg_min_ncluster_mft{"cfg_min_ncluster_mft", 5, "min ncluster MFT"}; Configurable cfg_min_ncluster_mch{"cfg_min_ncluster_mch", 5, "min ncluster MCH"}; - Configurable cfg_max_chi2{"cfg_max_chi2", 1e+10, "max chi2"}; - Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 1e+10, "max chi2 for MFT-MCH matching"}; + Configurable cfg_max_chi2{"cfg_max_chi2", 1e+6, "max chi2"}; + Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 40, "max chi2 for MFT-MCH matching"}; Configurable cfg_max_matching_chi2_mchmid{"cfg_max_matching_chi2_mchmid", 1e+10, "max chi2 for MCH-MID matching"}; Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1e+10, "max dca XY for single track in cm"}; Configurable cfg_min_rabs{"cfg_min_rabs", 17.6, "min Radius at the absorber end"}; Configurable cfg_max_rabs{"cfg_max_rabs", 89.5, "max Radius at the absorber end"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable cfg_max_relDPt_wrt_matchedMCHMID{"cfg_max_relDPt_wrt_matchedMCHMID", 1e+10f, "max. relative dpt between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DEta_wrt_matchedMCHMID{"cfg_max_DEta_wrt_matchedMCHMID", 1e+10f, "max. deta between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DPhi_wrt_matchedMCHMID{"cfg_max_DPhi_wrt_matchedMCHMID", 1e+10f, "max. dphi between MFT-MCH-MID and MCH-MID"}; + Configurable requireMFTHitMap{"requireMFTHitMap", false, "flag to apply MFT hit map"}; + Configurable> requiredMFTDisks{"requiredMFTDisks", std::vector{0}, "hit map on MFT disks [0,1,2,3,4]. logical-OR of each double-sided disk"}; + Configurable rejectWrongMatch{"rejectWrongMatch", false, "flag to reject wrong match between MFT and MCH-MID"}; // this is only for MC study, as we don't know correct match in data. } dimuoncuts; + o2::aod::rctsel::RCTFlagsChecker rctChecker; o2::ccdb::CcdbApi ccdbApi; Service ccdb; - // o2::vertexing::DCAFitterN<2> fitter; - // o2::vertexing::FwdDCAFitterN<2> fwdfitter; o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; int mRunNumber; float d_bz; @@ -281,16 +314,14 @@ struct DileptonMC { { // event info o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry); - fRegistry.add("MCEvent/before/hZvtx", "vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); + fRegistry.add("MCEvent/before/hZvtx", "mc vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); + fRegistry.add("MCEvent/before/hZvtx_rec", "rec. mc vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); fRegistry.addClone("MCEvent/before/", "MCEvent/after/"); std::string mass_axis_title = "m_{ll} (GeV/c^{2})"; std::string pair_pt_axis_title = "p_{T,ll} (GeV/c)"; std::string pair_y_axis_title = "y_{ll}"; std::string pair_dca_axis_title = "DCA_{ll} (#sigma)"; - int nbin_y = 20; - float min_y = -1.0; - float max_y = +1.0; if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { mass_axis_title = "m_{ee} (GeV/c^{2})"; pair_pt_axis_title = "p_{T,ee} (GeV/c)"; @@ -301,48 +332,48 @@ struct DileptonMC { } else if (cfgDCAType == 2) { pair_dca_axis_title = "DCA_{ee}^{Z} (#sigma)"; } - nbin_y = 20; - min_y = -1.0; - max_y = +1.0; } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { mass_axis_title = "m_{#mu#mu} (GeV/c^{2})"; pair_pt_axis_title = "p_{T,#mu#mu} (GeV/c)"; pair_y_axis_title = "y_{#mu#mu}"; pair_dca_axis_title = "DCA_{#mu#mu}^{XY} (#sigma)"; - nbin_y = 25; - min_y = -4.5; - max_y = -2.0; } // pair info const AxisSpec axis_mass{ConfMllBins, mass_axis_title}; const AxisSpec axis_pt{ConfPtllBins, pair_pt_axis_title}; - const AxisSpec axis_y{nbin_y, min_y, max_y, pair_y_axis_title}; + const AxisSpec axis_y{ConfYllBins, pair_y_axis_title}; const AxisSpec axis_dca{ConfDCAllBins, pair_dca_axis_title}; const AxisSpec axis_pt_meson{ConfPtllBins, "p_{T} (GeV/c)"}; // for omega, phi meson pT spectra - const AxisSpec axis_y_meson{nbin_y, min_y, max_y, "y"}; // rapidity of meson + const AxisSpec axis_y_meson{ConfYllBins, "y"}; // rapidity of meson + + const AxisSpec axis_dca_narrow{ConfDCAllNarrowBins, pair_dca_axis_title}; + const AxisSpec axis_dpt{ConfDPtBins, "#Delta p_{T,1}^{gen-rec} + #Delta p_{T,2}^{gen-rec} (GeV/c)"}; + const AxisSpec axis_dca_track1{ConfTrackDCA, "DCA_{e,1}^{Z} (#sigma)"}; + const AxisSpec axis_dca_track2{ConfTrackDCA, "DCA_{e,2}^{Z} (#sigma)"}; - const AxisSpec axis_dphi_ee{36, -M_PI / 2., 3. / 2. * M_PI, "#Delta#varphi = #varphi_{l1} - #varphi_{l2} (rad.)"}; // for kHFll - const AxisSpec axis_deta_ee{40, -2., 2., "#Delta#eta = #eta_{l1} - #eta_{l2}"}; // for kHFll - const AxisSpec axis_cos_theta_cs{10, 0.f, 1.f, "|cos(#theta_{CS})|"}; // for kPolarization, kUPC - const AxisSpec axis_phi_cs{18, 0.f, M_PI, "|#varphi_{CS}| (rad.)"}; // for kPolarization - const AxisSpec axis_aco{10, 0, 1.f, "#alpha = 1 - #frac{|#varphi_{l^{+}} - #varphi_{l^{-}}|}{#pi}"}; // for kUPC - const AxisSpec axis_asym_pt{10, 0, 1.f, "A = #frac{|p_{T,l^{+}} - p_{T,l^{-}}|}{|p_{T,l^{+}} + p_{T,l^{-}}|}"}; // for kUPC - const AxisSpec axis_dphi_e_ee{18, 0, M_PI, "#Delta#varphi = #varphi_{l} - #varphi_{ll} (rad.)"}; // for kUPC + const AxisSpec axis_dphi_ee{cfg_nbin_dphi_ee, -M_PI / 2., 3. / 2. * M_PI, "#Delta#varphi = #varphi_{l1} - #varphi_{l2} (rad.)"}; // for kHFll + const AxisSpec axis_deta_ee{cfg_nbin_deta_ee, -2., 2., "#Delta#eta = #eta_{l1} - #eta_{l2}"}; // for kHFll + const AxisSpec axis_cos_theta_cs{cfg_nbin_cos_theta_cs, 0.f, 1.f, "|cos(#theta_{CS})|"}; // for kPolarization, kUPC + const AxisSpec axis_phi_cs{cfg_nbin_phi_cs, 0.f, M_PI, "|#varphi_{CS}| (rad.)"}; // for kPolarization + const AxisSpec axis_aco{cfg_nbin_aco, 0, 1.f, "#alpha = 1 - #frac{|#varphi_{l^{+}} - #varphi_{l^{-}}|}{#pi}"}; // for kUPC + const AxisSpec axis_asym_pt{cfg_nbin_asym_pt, 0, 1.f, "A = #frac{|p_{T,l^{+}} - p_{T,l^{-}}|}{|p_{T,l^{+}} + p_{T,l^{-}}|}"}; // for kUPC + const AxisSpec axis_dphi_e_ee{cfg_nbin_dphi_e_ee, 0, M_PI, "#Delta#varphi = #varphi_{l} - #varphi_{ll} (rad.)"}; // for kUPC // generated info - fRegistry.add("Generated/sm/Pi0/hs", "gen. dilepton signal", kTHnSparseD, {axis_mass, axis_pt, axis_y, axis_dphi_ee, axis_deta_ee, axis_cos_theta_cs, axis_phi_cs, axis_aco, axis_asym_pt, axis_dphi_e_ee}, true); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/Eta/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/EtaPrime/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/Rho/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/Omega/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/Omega2ll/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/Phi/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/Phi2ll/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/PromptJPsi/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/NonPromptJPsi/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/PromptPsi2S/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/NonPromptPsi2S/"); + fRegistry.add("Generated/sm/PromptPi0/hs", "gen. dilepton signal", kTHnSparseD, {axis_mass, axis_pt, axis_y, axis_dphi_ee, axis_deta_ee, axis_cos_theta_cs, axis_phi_cs, axis_aco, axis_asym_pt, axis_dphi_e_ee}, true); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/NonPromptPi0/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/Eta/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/EtaPrime/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/Rho/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/Omega/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/Omega2ll/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/Phi/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/Phi2ll/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/PromptJPsi/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/NonPromptJPsi/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/PromptPsi2S/"); + fRegistry.addClone("Generated/sm/PromptPi0/", "Generated/sm/NonPromptPsi2S/"); fRegistry.add("Generated/sm/Omega2ll/hPtY", "pT of #omega meson", kTH2F, {axis_y_meson, axis_pt_meson}, true); fRegistry.add("Generated/sm/Phi2ll/hPtY", "pT of #phi meson", kTH2F, {axis_y_meson, axis_pt_meson}, true); @@ -355,9 +386,42 @@ struct DileptonMC { fRegistry.addClone("Generated/ccbar/c2l_c2l/", "Generated/bbbar/b2c2l_b2l_sameb/"); fRegistry.addClone("Generated/ccbar/c2l_c2l/", "Generated/bbbar/b2c2l_b2l_diffb/"); // LS + // for charmed hadrons // create 28 combinations + static constexpr std::string_view charmed_mesons[] = {"Dplus", "D0", "Dsplus"}; // 411, 421, 431 + static constexpr std::string_view anti_charmed_mesons[] = {"Dminus", "D0bar", "Dsminus"}; + const int nm = sizeof(charmed_mesons) / sizeof(charmed_mesons[0]); + static constexpr std::string_view charmed_baryons[] = {"Lcplus", "Xicplus", "Xic0", "Omegac0"}; // 4122, 4232, 4132, 4332 + static constexpr std::string_view anti_charmed_baryons[] = {"Lcminus", "Xicminus", "Xic0bar", "Omegac0bar"}; + const int nb = sizeof(charmed_baryons) / sizeof(charmed_baryons[0]); + static constexpr std::string_view sum_charmed_mesons[] = {"Dpm", "D0", "Dspm"}; + static constexpr std::string_view sum_charmed_baryons[] = {"Lcpm", "Xicpm", "Xic0", "Omegac0"}; + + for (int im = 0; im < nm; im++) { + fRegistry.addClone("Generated/ccbar/c2l_c2l/hadron_hadron/", Form("Generated/ccbar/c2l_c2l/%s_%s/", charmed_mesons[im].data(), anti_charmed_mesons[im].data())); + } + for (int ib = 0; ib < nb; ib++) { + fRegistry.addClone("Generated/ccbar/c2l_c2l/hadron_hadron/", Form("Generated/ccbar/c2l_c2l/%s_%s/", charmed_baryons[ib].data(), anti_charmed_baryons[ib].data())); + } + for (int im1 = 0; im1 < nm - 1; im1++) { + for (int im2 = im1 + 1; im2 < nm; im2++) { + fRegistry.addClone("Generated/ccbar/c2l_c2l/hadron_hadron/", Form("Generated/ccbar/c2l_c2l/%s_%s/", sum_charmed_mesons[im1].data(), sum_charmed_mesons[im2].data())); + } + } + for (int ib1 = 0; ib1 < nb - 1; ib1++) { + for (int ib2 = ib1 + 1; ib2 < nb; ib2++) { + fRegistry.addClone("Generated/ccbar/c2l_c2l/hadron_hadron/", Form("Generated/ccbar/c2l_c2l/%s_%s/", sum_charmed_baryons[ib1].data(), sum_charmed_baryons[ib2].data())); + } + } + for (int im = 0; im < nm; im++) { + for (int ib = 0; ib < nb; ib++) { + fRegistry.addClone("Generated/ccbar/c2l_c2l/hadron_hadron/", Form("Generated/ccbar/c2l_c2l/%s_%s/", sum_charmed_mesons[im].data(), sum_charmed_baryons[ib].data())); + } + } + // reconstructed pair info fRegistry.add("Pair/sm/Photon/hs", "rec. dilepton signal", kTHnSparseD, {axis_mass, axis_pt, axis_y, axis_dphi_ee, axis_deta_ee, axis_cos_theta_cs, axis_phi_cs, axis_aco, axis_asym_pt, axis_dphi_e_ee, axis_dca}, true); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Pi0/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/PromptPi0/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/NonPromptPi0/"); fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Eta/"); fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/EtaPrime/"); fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Rho/"); @@ -373,7 +437,14 @@ struct DileptonMC { if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { fRegistry.add("Pair/sm/Photon/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{90, 0, M_PI}, {100, 0.0f, 1.0f}}, true); fRegistry.add("Pair/sm/Photon/hMvsRxy", "m_{ee} vs. r_{xy};r_{xy}^{true} (cm);m_{ee} (GeV/c^{2})", kTH2F, {{100, 0, 100}, {100, 0.0f, 1.0f}}, true); - fRegistry.add("Pair/sm/Pi0/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{90, 0, M_PI}, {100, 0.0f, 1.0f}}, true); + fRegistry.add("Pair/sm/PromptPi0/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{90, 0, M_PI}, {100, 0.0f, 1.0f}}, true); + fRegistry.add("Pair/sm/NonPromptPi0/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{90, 0, M_PI}, {100, 0.0f, 1.0f}}, true); + fRegistry.add("Pair/sm/PromptPi0/hDeltaPtvsDCA", "#Delta p_{T,1}^{gen-rec} + #Delta p_{T,2}^{gen-rec} vs. DCA_{ee}", kTH2F, {axis_dca_narrow, axis_dpt}, true); + fRegistry.add("Pair/sm/NonPromptPi0/hDeltaPtvsDCA", "#Delta p_{T,1}^{gen-rec} + #Delta p_{T,2}^{gen-rec} vs. DCA_{ee}", kTH2F, {axis_dca_narrow, axis_dpt}, true); + fRegistry.add("Pair/sm/PromptJPsi/hDeltaPtvsDCA", "#Delta p_{T,1}^{gen-rec} + #Delta p_{T,2}^{gen-rec} vs. DCA_{ee}", kTH2F, {axis_dca_narrow, axis_dpt}, true); + fRegistry.add("Pair/sm/NonPromptJPsi/hDeltaPtvsDCA", "#Delta p_{T,1}^{gen-rec} + #Delta p_{T,2}^{gen-rec} vs. DCA_{ee}", kTH2F, {axis_dca_narrow, axis_dpt}, true); + fRegistry.add("Pair/sm/PromptPi0/hDCAz1vsDCAz2", "DCA_{z,1} vs DCA_{z,2}", kTH2F, {axis_dca_track1, axis_dca_track2}, true); + fRegistry.add("Pair/sm/PromptJPsi/hDCAz1vsDCAz2", "DCA_{z,1} vs DCA_{z,2}", kTH2F, {axis_dca_track1, axis_dca_track2}, true); } fRegistry.add("Pair/ccbar/c2l_c2l/hadron_hadron/hs", "hs pair", kTHnSparseD, {axis_mass, axis_pt, axis_y, axis_dphi_ee, axis_deta_ee, axis_cos_theta_cs, axis_phi_cs, axis_aco, axis_asym_pt, axis_dphi_e_ee, axis_dca}, true); @@ -385,12 +456,34 @@ struct DileptonMC { fRegistry.addClone("Pair/ccbar/c2l_c2l/", "Pair/bbbar/b2c2l_b2l_sameb/"); fRegistry.addClone("Pair/ccbar/c2l_c2l/", "Pair/bbbar/b2c2l_b2l_diffb/"); // LS + for (int im = 0; im < nm; im++) { + fRegistry.addClone("Pair/ccbar/c2l_c2l/hadron_hadron/", Form("Pair/ccbar/c2l_c2l/%s_%s/", charmed_mesons[im].data(), anti_charmed_mesons[im].data())); + } + for (int ib = 0; ib < nb; ib++) { + fRegistry.addClone("Pair/ccbar/c2l_c2l/hadron_hadron/", Form("Pair/ccbar/c2l_c2l/%s_%s/", charmed_baryons[ib].data(), anti_charmed_baryons[ib].data())); + } + for (int im1 = 0; im1 < nm - 1; im1++) { + for (int im2 = im1 + 1; im2 < nm; im2++) { + fRegistry.addClone("Pair/ccbar/c2l_c2l/hadron_hadron/", Form("Pair/ccbar/c2l_c2l/%s_%s/", sum_charmed_mesons[im1].data(), sum_charmed_mesons[im2].data())); + } + } + for (int ib1 = 0; ib1 < nb - 1; ib1++) { + for (int ib2 = ib1 + 1; ib2 < nb; ib2++) { + fRegistry.addClone("Pair/ccbar/c2l_c2l/hadron_hadron/", Form("Pair/ccbar/c2l_c2l/%s_%s/", sum_charmed_baryons[ib1].data(), sum_charmed_baryons[ib2].data())); + } + } + for (int im = 0; im < nm; im++) { + for (int ib = 0; ib < nb; ib++) { + fRegistry.addClone("Pair/ccbar/c2l_c2l/hadron_hadron/", Form("Pair/ccbar/c2l_c2l/%s_%s/", sum_charmed_mesons[im].data(), sum_charmed_baryons[ib].data())); + } + } + // for correlated bkg due to mis-identified hadrons, and true combinatorial bkg - fRegistry.add("Pair/corr_bkg_eh/uls/hs", "rec. bkg", kTHnSparseD, {axis_mass, axis_pt, axis_y, axis_dphi_ee, axis_deta_ee, axis_cos_theta_cs, axis_phi_cs, axis_aco, axis_asym_pt, axis_dphi_e_ee, axis_dca}, true); - fRegistry.addClone("Pair/corr_bkg_eh/uls/", "Pair/corr_bkg_eh/lspp/"); - fRegistry.addClone("Pair/corr_bkg_eh/uls/", "Pair/corr_bkg_eh/lsmm/"); - fRegistry.addClone("Pair/corr_bkg_eh/", "Pair/corr_bkg_hh/"); - fRegistry.addClone("Pair/corr_bkg_eh/", "Pair/comb_bkg/"); + fRegistry.add("Pair/corr_bkg_lh/uls/hs", "rec. bkg", kTHnSparseD, {axis_mass, axis_pt, axis_y, axis_dphi_ee, axis_deta_ee, axis_cos_theta_cs, axis_phi_cs, axis_aco, axis_asym_pt, axis_dphi_e_ee, axis_dca}, true); + fRegistry.addClone("Pair/corr_bkg_lh/uls/", "Pair/corr_bkg_lh/lspp/"); + fRegistry.addClone("Pair/corr_bkg_lh/uls/", "Pair/corr_bkg_lh/lsmm/"); + fRegistry.addClone("Pair/corr_bkg_lh/", "Pair/corr_bkg_hh/"); + fRegistry.addClone("Pair/corr_bkg_lh/", "Pair/comb_bkg/"); if (cfgFillUnfolding) { // for 2D unfolding @@ -434,6 +527,7 @@ struct DileptonMC { ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); + rctChecker.init(eventcuts.cfgRCTLabel.value, eventcuts.cfgCheckZDC.value, eventcuts.cfgTreatLimitedAcceptanceAsBad.value); DefineEMEventCut(); addhistograms(); @@ -443,29 +537,24 @@ struct DileptonMC { leptonM1 = o2::constants::physics::MassElectron; leptonM2 = o2::constants::physics::MassElectron; pdg_lepton = 11; - // fitter.setPropagateToPCA(true); - // fitter.setMaxR(5.f); - // fitter.setMinParamChange(1e-3); - // fitter.setMinRelChi2Change(0.9); - // fitter.setMaxDZIni(1e9); - // fitter.setMaxChi2(1e9); - // fitter.setUseAbsDCA(true); - // fitter.setWeightedFinalPCA(false); - // fitter.setMatCorrType(matCorr); } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { DefineDimuonCut(); leptonM1 = o2::constants::physics::MassMuon; leptonM2 = o2::constants::physics::MassMuon; pdg_lepton = 13; - // fwdfitter.setPropagateToPCA(true); - // fwdfitter.setMaxR(90.f); - // fwdfitter.setMinParamChange(1e-3); - // fwdfitter.setMinRelChi2Change(0.9); - // fwdfitter.setMaxChi2(1e9); - // fwdfitter.setUseAbsDCA(true); - // fwdfitter.setTGeoMat(false); } - fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter"); + if (doprocessNorm) { + fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter"); + } + if (doprocessBC) { + auto hTVXCounter = fRegistry.add("BC/hTVXCounter", "TVX counter", kTH1D, {{6, -0.5f, 5.5f}}); + hTVXCounter->GetXaxis()->SetBinLabel(1, "TVX"); + hTVXCounter->GetXaxis()->SetBinLabel(2, "TVX && NoTFB"); + hTVXCounter->GetXaxis()->SetBinLabel(3, "TVX && NoITSROFB"); + hTVXCounter->GetXaxis()->SetBinLabel(4, "TVX && GoodRCT"); + hTVXCounter->GetXaxis()->SetBinLabel(5, "TVX && NoTFB && NoITSROFB"); + hTVXCounter->GetXaxis()->SetBinLabel(6, "TVX && NoTFB && NoITSROFB && GoodRCT"); + } } template @@ -479,13 +568,11 @@ struct DileptonMC { if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } o2::base::Propagator::initFieldFromGRP(&grpmag); mRunNumber = collision.runNumber(); - // fitter.setBz(d_bz); - // fwdfitter.setBz(d_bz); return; } @@ -498,7 +585,7 @@ struct DileptonMC { o2::base::Propagator::initFieldFromGRP(grpo); // Fetch magnetic field from ccdb for current collision d_bz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kG"; } else { grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); if (!grpmag) { @@ -507,11 +594,9 @@ struct DileptonMC { o2::base::Propagator::initFieldFromGRP(grpmag); // Fetch magnetic field from ccdb for current collision d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kG"; } mRunNumber = collision.runNumber(); - // fitter.setBz(d_bz); - // fwdfitter.setBz(d_bz); //// for muon // o2::base::Propagator::initFieldFromGRP(grpmag); @@ -544,12 +629,16 @@ struct DileptonMC { fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); + fEMEventCut.SetRequireVertexTOFmatched(eventcuts.cfgRequireVertexTOFmatched); fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); fEMEventCut.SetRequireNoHighMultCollInPrevRof(eventcuts.cfgRequireNoHighMultCollInPrevRof); + fEMEventCut.SetRequireGoodITSLayer3(eventcuts.cfgRequireGoodITSLayer3); + fEMEventCut.SetRequireGoodITSLayer0123(eventcuts.cfgRequireGoodITSLayer0123); + fEMEventCut.SetRequireGoodITSLayersAll(eventcuts.cfgRequireGoodITSLayersAll); } o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; @@ -564,14 +653,14 @@ struct DileptonMC { fDielectronCut.SetPairDCARange(dielectroncuts.cfg_min_pair_dca3d, dielectroncuts.cfg_max_pair_dca3d); // in sigma fDielectronCut.SetMaxMeePhiVDep([&](float phiv) { return dielectroncuts.cfg_phiv_intercept + phiv * dielectroncuts.cfg_phiv_slope; }, dielectroncuts.cfg_min_phiv, dielectroncuts.cfg_max_phiv); fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); - fDielectronCut.SetMindEtadPhi(dielectroncuts.cfg_apply_detadphi, dielectroncuts.cfg_min_deta, dielectroncuts.cfg_min_dphi); + fDielectronCut.SetMindEtadPhi(dielectroncuts.cfg_apply_detadphi, dielectroncuts.cfg_apply_detadphiposition, dielectroncuts.cfg_min_deta, dielectroncuts.cfg_min_dphi); fDielectronCut.SetPairOpAng(dielectroncuts.cfg_min_opang, dielectroncuts.cfg_max_opang); fDielectronCut.SetRequireDifferentSides(dielectroncuts.cfg_require_diff_sides); // for track fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, dielectroncuts.cfg_max_pt_track); - fDielectronCut.SetTrackEtaRange(-dielectroncuts.cfg_max_eta_track, +dielectroncuts.cfg_max_eta_track); - fDielectronCut.SetTrackPhiRange(-dielectroncuts.cfg_max_phi_track, +dielectroncuts.cfg_max_phi_track); + fDielectronCut.SetTrackEtaRange(dielectroncuts.cfg_min_eta_track, +dielectroncuts.cfg_max_eta_track); + fDielectronCut.SetTrackPhiRange(dielectroncuts.cfg_min_phi_track, dielectroncuts.cfg_max_phi_track, dielectroncuts.cfg_mirror_phi_track, dielectroncuts.cfg_reject_phi_track); fDielectronCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); fDielectronCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); fDielectronCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); @@ -579,38 +668,39 @@ struct DileptonMC { fDielectronCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); fDielectronCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); fDielectronCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size, dielectroncuts.cfg_min_p_its_cluster_size, dielectroncuts.cfg_max_p_its_cluster_size); + fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size); fDielectronCut.SetTrackMaxDcaXY(dielectroncuts.cfg_max_dcaxy); fDielectronCut.SetTrackMaxDcaZ(dielectroncuts.cfg_max_dcaz); fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); fDielectronCut.SetChi2TOF(0.0, dielectroncuts.cfg_max_chi2tof); fDielectronCut.SetRelDiffPin(dielectroncuts.cfg_min_rel_diff_pin, dielectroncuts.cfg_max_rel_diff_pin); + fDielectronCut.IncludeITSsa(dielectroncuts.includeITSsa, dielectroncuts.cfg_max_pt_track_ITSsa); // for eID fDielectronCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); fDielectronCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); + // fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); fDielectronCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); fDielectronCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); fDielectronCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); fDielectronCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); - fDielectronCut.SetMaxPinForPionRejectionTPC(dielectroncuts.cfg_max_pin_pirejTPC); - fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); - fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); - fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); - fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); + fDielectronCut.SetPinRangeForPionRejectionTPC(dielectroncuts.cfg_min_pin_pirejTPC, dielectroncuts.cfg_max_pin_pirejTPC); + // fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); + // fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); + // fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); + // fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut static constexpr int nClassesMl = 2; - const std::vector cutDirMl = {o2::cuts_ml::CutSmaller, o2::cuts_ml::CutNot}; - const std::vector labelsClasses = {"Signal", "Background"}; + const std::vector cutDirMl = {o2::cuts_ml::CutNot, o2::cuts_ml::CutSmaller}; + const std::vector labelsClasses = {"Background", "Signal"}; const uint32_t nBinsMl = dielectroncuts.binsMl.value.size() - 1; const std::vector labelsBins(nBinsMl, "bin"); double cutsMlArr[nBinsMl][nClassesMl]; for (uint32_t i = 0; i < nBinsMl; i++) { - cutsMlArr[i][0] = dielectroncuts.cutsMl.value[i]; - cutsMlArr[i][1] = 0.; + cutsMlArr[i][0] = 0.; + cutsMlArr[i][1] = dielectroncuts.cutsMl.value[i]; } o2::framework::LabeledArray cutsMl = {cutsMlArr[0], nBinsMl, nClassesMl, labelsBins, labelsClasses}; @@ -653,6 +743,8 @@ struct DileptonMC { fDimuonCut.SetDCAxy(0.f, dimuoncuts.cfg_max_dcaxy); fDimuonCut.SetRabs(dimuoncuts.cfg_min_rabs, dimuoncuts.cfg_max_rabs); fDimuonCut.SetMaxPDCARabsDep([&](float rabs) { return (rabs < 26.5 ? 594.f : 324.f); }); + fDimuonCut.SetMaxdPtdEtadPhiwrtMCHMID(dimuoncuts.cfg_max_relDPt_wrt_matchedMCHMID, dimuoncuts.cfg_max_DEta_wrt_matchedMCHMID, dimuoncuts.cfg_max_DPhi_wrt_matchedMCHMID); // this is relevant for global muons + fDimuonCut.SetMFTHitMap(dimuoncuts.requireMFTHitMap, dimuoncuts.requiredMFTDisks); } template @@ -709,12 +801,12 @@ struct DileptonMC { } } - template - bool fillTruePairInfo(TCollision const& collision, TMCCollisions const&, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TMCParticles const& mcparticles) + template + bool fillTruePairInfo(TCollision const& collision, TMCCollisions const&, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const& tracks, TMCParticles const& mcparticles) { auto t1mc = mcparticles.iteratorAt(t1.emmcparticleId()); auto t2mc = mcparticles.iteratorAt(t2.emmcparticleId()); - bool is_from_same_mcevent = t1mc.emmceventId() == t2mc.emmceventId(); + bool is_pair_from_same_mcevent = (t1mc.emmceventId() == t2mc.emmceventId()); auto mccollision1 = t1mc.template emmcevent_as(); auto mccollision2 = t2mc.template emmcevent_as(); @@ -738,20 +830,34 @@ struct DileptonMC { return false; } } - if (!cut.template IsSelectedPair(t1, t2, d_bz)) { + if (!cut.IsSelectedPair(t1, t2, d_bz, dielectroncuts.cfgRefR)) { return false; } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { + if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { return false; } - if (!cut.template IsSelectedPair(t1, t2)) { + + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) { + return false; + } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) { + return false; + } + if (dimuoncuts.rejectWrongMatch) { + if (t1.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && t1.emmcparticleId() != t1.emmftmcparticleId()) { + return false; + } + if (t2.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && t2.emmcparticleId() != t2.emmftmcparticleId()) { + return false; + } + } + + if (!cut.IsSelectedPair(t1, t2)) { return false; } } - // float pca = 999.f, lxy = 999.f; // in unit of cm - // o2::aod::pwgem::dilepton::utils::pairutil::isSVFound(fitter, collision, t1, t2, pca, lxy); float pt1 = 0.f, eta1 = 0.f, phi1 = 0.f, pt2 = 0.f, eta2 = 0.f, phi2 = 0.f; if constexpr (isSmeared) { if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { @@ -835,50 +941,54 @@ struct DileptonMC { float dphi = v1.Phi() - v2.Phi(); o2::math_utils::bringToPMPi(dphi); - float aco = 1.f - abs(dphi) / M_PI; - float asym = abs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); + float aco = 1.f - std::fabs(dphi) / M_PI; + float asym = std::fabs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); float dphi_e_ee = v1.Phi() - v12.Phi(); o2::math_utils::bringToPMPi(dphi_e_ee); + dphi = RecoDecay::constrainAngle(dphi, -o2::constants::math::PIHalf, 1); // shift dphi in [-pi/2, +3pi/2] rad. float cos_thetaCS = 999, phiCS = 999.f; o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, leptonM1, leptonM2, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); o2::math_utils::bringToPMPi(phiCS); - if ((FindCommonMotherFrom2ProngsWithoutPDG(t1mc, t2mc) > 0 || IsHF(t1mc, t2mc, mcparticles) > 0) && is_from_same_mcevent) { // for bkg study - if (abs(t1mc.pdgCode()) != pdg_lepton || abs(t2mc.pdgCode()) != pdg_lepton) { // hh or eh correlated bkg - if (abs(t1mc.pdgCode()) != pdg_lepton && abs(t2mc.pdgCode()) != pdg_lepton) { // hh correlated bkg - if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/corr_bkg_hh/uls/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + if ((FindCommonMotherFrom2ProngsWithoutPDG(t1mc, t2mc) > 0 || IsHF(t1mc, t2mc, mcparticles) > 0) && is_pair_from_same_mcevent) { // for bkg study + if (std::abs(t1mc.pdgCode()) != pdg_lepton || std::abs(t2mc.pdgCode()) != pdg_lepton) { // hh or lh correlated bkg + if (std::abs(t1mc.pdgCode()) != pdg_lepton && std::abs(t2mc.pdgCode()) != pdg_lepton) { // hh correlated bkg + if (t1.sign() * t2.sign() < 0) { // ULS + fRegistry.fill(HIST("Pair/corr_bkg_hh/uls/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++ - fRegistry.fill(HIST("Pair/corr_bkg_hh/lspp/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/corr_bkg_hh/lspp/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if (t1.sign() < 0 && t2.sign() < 0) { // LS-- - fRegistry.fill(HIST("Pair/corr_bkg_hh/lsmm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/corr_bkg_hh/lsmm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } - } else { // eh correlated bkg + } else { // lh correlated bkg if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/corr_bkg_eh/uls/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/corr_bkg_lh/uls/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++ - fRegistry.fill(HIST("Pair/corr_bkg_eh/lspp/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/corr_bkg_lh/lspp/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if (t1.sign() < 0 && t2.sign() < 0) { // LS-- - fRegistry.fill(HIST("Pair/corr_bkg_eh/lsmm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/corr_bkg_lh/lsmm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } } } } else { // true combinatorial bkg if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/comb_bkg/uls/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/comb_bkg/uls/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if (t1.sign() > 0 && t2.sign() > 0) { // LS++ - fRegistry.fill(HIST("Pair/comb_bkg/lspp/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/comb_bkg/lspp/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if (t1.sign() < 0 && t2.sign() < 0) { // LS-- - fRegistry.fill(HIST("Pair/comb_bkg/lsmm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/comb_bkg/lsmm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } } - if (abs(t1mc.pdgCode()) != pdg_lepton || abs(t2mc.pdgCode()) != pdg_lepton) { + if (std::abs(t1mc.pdgCode()) != pdg_lepton || std::abs(t2mc.pdgCode()) != pdg_lepton) { return false; } - if (!is_from_same_mcevent) { + if (!is_pair_from_same_mcevent) { + return false; + } + if (cfgRequireTrueAssociation && (t1mc.emmceventId() != collision.emmceventId() || t2mc.emmceventId() != collision.emmceventId())) { return false; } int mother_id = FindLF(t1mc, t2mc, mcparticles); @@ -891,47 +1001,66 @@ struct DileptonMC { auto mcmother = mcparticles.iteratorAt(mother_id); if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { if ((t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && (t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { - switch (abs(mcmother.pdgCode())) { + float deltaPt1 = t1mc.pt() - t1.pt(); + float deltaPt2 = t2mc.pt() - t2.pt(); + switch (std::abs(mcmother.pdgCode())) { case 111: - fRegistry.fill(HIST("Pair/sm/Pi0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); - if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - fRegistry.fill(HIST("Pair/sm/Pi0/hMvsPhiV"), phiv, v12.M()); + if (IsFromCharm(mcmother, mcparticles) < 0 && IsFromBeauty(mcmother, mcparticles) < 0) { // prompt pi0 + fRegistry.fill(HIST("Pair/sm/PromptPi0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + fRegistry.fill(HIST("Pair/sm/PromptPi0/hDeltaPtvsDCA"), pair_dca, deltaPt1 + deltaPt2); + fRegistry.fill(HIST("Pair/sm/PromptPi0/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/sm/PromptPi0/hDCAz1vsDCAz2"), dcaZinSigma(t1), dcaZinSigma(t2)); + } + } else { // non-prompt pi0 + fRegistry.fill(HIST("Pair/sm/NonPromptPi0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + fRegistry.fill(HIST("Pair/sm/NonPromptPi0/hDeltaPtvsDCA"), pair_dca, deltaPt1 + deltaPt2); + fRegistry.fill(HIST("Pair/sm/NonPromptPi0/hMvsPhiV"), phiv, v12.M()); + } } break; case 221: - fRegistry.fill(HIST("Pair/sm/Eta/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/Eta/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); break; case 331: - fRegistry.fill(HIST("Pair/sm/EtaPrime/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/EtaPrime/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); break; case 113: - fRegistry.fill(HIST("Pair/sm/Rho/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/Rho/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); break; case 223: - fRegistry.fill(HIST("Pair/sm/Omega/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/Omega/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); if (mcmother.daughtersIds().size() == 2) { // omeag->ee - fRegistry.fill(HIST("Pair/sm/Omega2ll/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/Omega2ll/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } break; case 333: - fRegistry.fill(HIST("Pair/sm/Phi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/Phi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); if (mcmother.daughtersIds().size() == 2) { // phi->ee - fRegistry.fill(HIST("Pair/sm/Phi2ll/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/Phi2ll/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } break; case 443: { if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Pair/sm/NonPromptJPsi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/NonPromptJPsi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + fRegistry.fill(HIST("Pair/sm/NonPromptJPsi/hDeltaPtvsDCA"), pair_dca, deltaPt1 + deltaPt2); + } } else { - fRegistry.fill(HIST("Pair/sm/PromptJPsi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/PromptJPsi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + fRegistry.fill(HIST("Pair/sm/PromptJPsi/hDeltaPtvsDCA"), pair_dca, deltaPt1 + deltaPt2); + fRegistry.fill(HIST("Pair/sm/PromptJPsi/hDCAz1vsDCAz2"), dcaZinSigma(t1), dcaZinSigma(t2)); + } } break; } case 100443: { if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Pair/sm/NonPromptPsi2S/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/NonPromptPsi2S/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else { - fRegistry.fill(HIST("Pair/sm/PromptPsi2S/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/PromptPsi2S/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } break; } @@ -939,9 +1068,9 @@ struct DileptonMC { break; } } else if (!(t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && !(t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { - switch (abs(mcmother.pdgCode())) { + switch (std::abs(mcmother.pdgCode())) { case 22: - fRegistry.fill(HIST("Pair/sm/Photon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/sm/Photon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { fRegistry.fill(HIST("Pair/sm/Photon/hMvsPhiV"), phiv, v12.M()); float rxy_gen = std::sqrt(std::pow(t1mc.vx(), 2) + std::pow(t1mc.vy(), 2)); @@ -960,46 +1089,105 @@ struct DileptonMC { if (t1mc.pdgCode() * t2mc.pdgCode() < 0) { // ULS switch (hfee_type) { case static_cast(EM_HFeeType::kCe_Ce): { - fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + if (std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 411) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dplus_Dminus/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if (std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 421) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/D0_D0bar/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if (std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 431) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dsplus_Dsminus/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 421) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 421)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dpm_D0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 431) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 431)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dpm_Dspm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 431) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 431)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/D0_Dspm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + if (std::abs(mp1.pdgCode()) == 4122 && std::abs(mp2.pdgCode()) == 4122) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Lcplus_Lcminus/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if (std::abs(mp1.pdgCode()) == 4232 && std::abs(mp2.pdgCode()) == 4232) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Xicplus_Xicminus/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if (std::abs(mp1.pdgCode()) == 4132 && std::abs(mp2.pdgCode()) == 4132) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Xic0_Xic0bar/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if (std::abs(mp1.pdgCode()) == 4332 && std::abs(mp2.pdgCode()) == 4332) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Omegac0_Omegac0bar/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 4122 && std::abs(mp2.pdgCode()) == 4232) || (std::abs(mp2.pdgCode()) == 4122 && std::abs(mp1.pdgCode()) == 4232)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Lcpm_Xicpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 4122 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 4122 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Lcpm_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 4122 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 4122 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Lcpm_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 4232 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 4232 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Xicpm_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 4232 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 4232 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Xicpm_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 4132 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 4132 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Xic0_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } } else { - fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 4122) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 4122)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dpm_Lcpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 4232) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 4232)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dpm_Xicpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dpm_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dpm_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 4122) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 4122)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/D0_Lcpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 4232) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 4232)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/D0_Xicpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/D0_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/D0_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 4122) || (std::abs(mp2.pdgCode()) == 431 && std::abs(mp1.pdgCode()) == 4122)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dspm_Lcpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 4232) || (std::abs(mp2.pdgCode()) == 431 && std::abs(mp1.pdgCode()) == 4232)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dspm_Xicpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 431 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dspm_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } else if ((std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 431 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Pair/ccbar/c2l_c2l/Dspm_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); + } } break; } case static_cast(EM_HFeeType::kBe_Be): { - fRegistry.fill(HIST("Pair/bbbar/b2l_b2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2l_b2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); if (isBeautyMeson(mp1) && isBeautyMeson(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2l_b2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2l_b2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if (isBeautyBaryon(mp1) && isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2l_b2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2l_b2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else { - fRegistry.fill(HIST("Pair/bbbar/b2l_b2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2l_b2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } break; } case static_cast(EM_HFeeType::kBCe_BCe): { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2c2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2c2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2c2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2c2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2c2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2c2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2c2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2c2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } break; } case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } break; } @@ -1024,13 +1212,13 @@ struct DileptonMC { LOGF(info, "You should not see kBCe_Be_SameB in LS. Good luck."); break; case static_cast(EM_HFeeType::kBCe_Be_DiffB): { // LS - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), pair_dca, weight); + fRegistry.fill(HIST("Pair/bbbar/b2c2l_b2l_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee), pair_dca, weight); } break; } @@ -1045,8 +1233,7 @@ struct DileptonMC { SliceCache cache; Preslice perCollision_electron = aod::emprimaryelectron::emeventId; - Filter trackFilter_electron = dielectroncuts.cfg_min_phi_track < o2::aod::track::phi && o2::aod::track::phi < dielectroncuts.cfg_max_phi_track && o2::aod::track::tpcChi2NCl < dielectroncuts.cfg_max_chi2tpc && o2::aod::track::itsChi2NCl < dielectroncuts.cfg_max_chi2its && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz; - Filter pidFilter_electron = dielectroncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dielectroncuts.cfg_max_TPCNsigmaEl; + Filter trackFilter_electron = nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz; Filter ttcaFilter_electron = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); Filter prefilter_derived_electron = ifnode(dielectroncuts.cfg_apply_cuts_from_prefilter_derived.node() && dielectroncuts.cfg_prefilter_bits_derived.node() >= static_cast(1), ifnode((dielectroncuts.cfg_prefilter_bits_derived.node() & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kMee))) > static_cast(0), (o2::aod::emprimaryelectron::pfbderived & static_cast(1 << int(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kMee))) <= static_cast(0), true) && @@ -1063,19 +1250,19 @@ struct DileptonMC { o2::aod::emprimaryelectron::pfb >= static_cast(0)); Preslice perCollision_muon = aod::emprimarymuon::emeventId; - Filter trackFilter_muon = o2::aod::fwdtrack::trackType == dimuoncuts.cfg_track_type && dimuoncuts.cfg_min_phi_track < o2::aod::fwdtrack::phi && o2::aod::fwdtrack::phi < dimuoncuts.cfg_max_phi_track; + Filter trackFilter_muon = o2::aod::fwdtrack::trackType == dimuoncuts.cfg_track_type; Filter ttcaFilter_muon = ifnode(dimuoncuts.enableTTCA.node(), o2::aod::emprimarymuon::isAssociatedToMPC == true || o2::aod::emprimarymuon::isAssociatedToMPC == false, o2::aod::emprimarymuon::isAssociatedToMPC == true); Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); // Filter collisionFilter_multiplicity = cfgNtracksPV08Min <= o2::aod::mult::multNTracksPV && o2::aod::mult::multNTracksPV < cfgNtracksPV08Max; Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; - Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin < o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; using FilteredMyCollisions = soa::Filtered; - template - void runTruePairing(TCollisions const& collisions, TMCLeptons const& posTracks, TMCLeptons const& negTracks, TPreslice const& perCollision, TCut const& cut, TMCCollisions const& mccollisions, TMCParticles const& mcparticles) + template + void runTruePairing(TCollisions const& collisions, TMCLeptons const& posTracks, TMCLeptons const& negTracks, TPreslice const& perCollision, TCut const& cut, TAllTracks const& tracks, TMCCollisions const& mccollisions, TMCParticles const& mcparticles) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { initCCDB(collision); float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { @@ -1086,6 +1273,9 @@ struct DileptonMC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1, -1>(&fRegistry, collision); fRegistry.fill(HIST("Event/before/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted fRegistry.fill(HIST("Event/after/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted @@ -1094,16 +1284,16 @@ struct DileptonMC { auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache); // LOGF(info, "centrality = %f , posTracks_per_coll.size() = %d, negTracks_per_coll.size() = %d", centralities[cfgCentEstimator], posTracks_per_coll.size(), negTracks_per_coll.size()); - for (auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS - fillTruePairInfo(collision, mccollisions, pos, neg, cut, mcparticles); + for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + fillTruePairInfo(collision, mccollisions, pos, neg, cut, tracks, mcparticles); } // end of ULS pair loop - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ - fillTruePairInfo(collision, mccollisions, pos1, pos2, cut, mcparticles); + for (const auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ + fillTruePairInfo(collision, mccollisions, pos1, pos2, cut, tracks, mcparticles); } // end of LS++ pair loop - for (auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- - fillTruePairInfo(collision, mccollisions, neg1, neg2, cut, mcparticles); + for (const auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- + fillTruePairInfo(collision, mccollisions, neg1, neg2, cut, tracks, mcparticles); } // end of LS-- pair loop } // end of collision loop @@ -1112,28 +1302,11 @@ struct DileptonMC { template void runGenInfo(TCollisions const& collisions, TMCCollisions const& mccollisions, TMCLeptons const& posTracksMC, TMCLeptons const& negTracksMC, TMCParticles const& mcparticles) { - for (auto& mccollision : mccollisions) { + for (const auto& mccollision : mccollisions) { if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { continue; } fRegistry.fill(HIST("MCEvent/before/hZvtx"), mccollision.posZ()); - - // auto rec_colls_per_mccoll = collisions.sliceBy(recColperMcCollision, mccollision.globalIndex()); - // // LOGF(info, "rec_colls_per_mccoll.size() = %d", rec_colls_per_mccoll.size()); - // if (rec_colls_per_mccoll.size() < 1) { - // continue; - // } - - // uint32_t maxNumContrib = 0; - // int rec_col_globalIndex = -999; - // for (auto& rec_col : rec_colls_per_mccoll) { - // if (rec_col.numContrib() > maxNumContrib) { - // rec_col_globalIndex = rec_col.globalIndex(); - // maxNumContrib = rec_col.numContrib(); // assign mc collision to collision where the number of contibutor is lager. LF/MM recommendation - // } - // } - // auto collision = collisions.rawIteratorAt(rec_col_globalIndex); - if (mccollision.mpemeventId() < 0) { continue; } @@ -1143,15 +1316,19 @@ struct DileptonMC { if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { continue; } + fRegistry.fill(HIST("MCEvent/before/hZvtx_rec"), mccollision.posZ()); if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } fRegistry.fill(HIST("MCEvent/after/hZvtx"), mccollision.posZ()); auto posTracks_per_coll = posTracksMC.sliceByCachedUnsorted(aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); auto negTracks_per_coll = negTracksMC.sliceByCachedUnsorted(aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS // LOGF(info, "pdg1 = %d, pdg2 = %d", t1.pdgCode(), t2.pdgCode()); if (!isInAcceptance(t1) || !isInAcceptance(t2)) { @@ -1237,10 +1414,11 @@ struct DileptonMC { } } - float aco = 1.f - abs(dphi) / M_PI; - float asym = abs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); + float aco = 1.f - std::fabs(dphi) / M_PI; + float asym = std::fabs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); float dphi_e_ee = v1.Phi() - v12.Phi(); o2::math_utils::bringToPMPi(dphi_e_ee); + dphi = RecoDecay::constrainAngle(dphi, -o2::constants::math::PIHalf, 1); // shift dphi in [-pi/2, +3pi/2] rad. after deta-dphi cut. float cos_thetaCS = 999, phiCS = 999.f; o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, leptonM1, leptonM2, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); @@ -1250,44 +1428,48 @@ struct DileptonMC { auto mcmother = mcparticles.iteratorAt(mother_id); if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { - switch (abs(mcmother.pdgCode())) { + switch (std::abs(mcmother.pdgCode())) { case 111: - fRegistry.fill(HIST("Generated/sm/Pi0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + if (IsFromCharm(mcmother, mcparticles) < 0 && IsFromBeauty(mcmother, mcparticles) < 0) { // prompt pi0 + fRegistry.fill(HIST("Generated/sm/PromptPi0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else { // non-prompt pi0 + fRegistry.fill(HIST("Generated/sm/NonPromptPi0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } break; case 221: - fRegistry.fill(HIST("Generated/sm/Eta/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/Eta/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); break; case 331: - fRegistry.fill(HIST("Generated/sm/EtaPrime/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/EtaPrime/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); break; case 113: - fRegistry.fill(HIST("Generated/sm/Rho/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/Rho/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); break; case 223: - fRegistry.fill(HIST("Generated/sm/Omega/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/Omega/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); if (mcmother.daughtersIds().size() == 2) { // omega->ee - fRegistry.fill(HIST("Generated/sm/Omega2ll/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/Omega2ll/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } break; case 333: - fRegistry.fill(HIST("Generated/sm/Phi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/Phi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); if (mcmother.daughtersIds().size() == 2) { // phi->ee - fRegistry.fill(HIST("Generated/sm/Phi2ll/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/Phi2ll/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } break; case 443: { if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Generated/sm/NonPromptJPsi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/NonPromptJPsi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else { - fRegistry.fill(HIST("Generated/sm/PromptJPsi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/PromptJPsi/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } break; } case 100443: { if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Generated/sm/NonPromptPsi2S/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/NonPromptPsi2S/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else { - fRegistry.fill(HIST("Generated/sm/PromptPsi2S/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/sm/PromptPsi2S/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } break; } @@ -1300,46 +1482,105 @@ struct DileptonMC { auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); switch (hfee_type) { case static_cast(EM_HFeeType::kCe_Ce): { - fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + if (std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 411) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dplus_Dminus/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if (std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 421) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/D0_D0bar/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if (std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 431) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dsplus_Dsminus/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 421) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 421)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dpm_D0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 431) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 431)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dpm_Dspm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 431) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 431)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/D0_Dspm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + if (std::abs(mp1.pdgCode()) == 4122 && std::abs(mp2.pdgCode()) == 4122) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Lcplus_Lcminus/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if (std::abs(mp1.pdgCode()) == 4232 && std::abs(mp2.pdgCode()) == 4232) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Xicplus_Xicminus/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if (std::abs(mp1.pdgCode()) == 4132 && std::abs(mp2.pdgCode()) == 4132) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Xic0_Xic0bar/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if (std::abs(mp1.pdgCode()) == 4332 && std::abs(mp2.pdgCode()) == 4332) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Omegac0_Omegac0bar/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 4122 && std::abs(mp2.pdgCode()) == 4232) || (std::abs(mp2.pdgCode()) == 4122 && std::abs(mp1.pdgCode()) == 4232)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Lcpm_Xicpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 4122 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 4122 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Lcpm_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 4122 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 4122 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Lcpm_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 4232 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 4232 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Xicpm_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 4232 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 4232 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Xicpm_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 4132 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 4132 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Xic0_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } } else { - fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 4122) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 4122)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dpm_Lcpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 4232) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 4232)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dpm_Xicpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dpm_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 411 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 411 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dpm_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 4122) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 4122)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/D0_Lcpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 4232) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 4232)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/D0_Xicpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/D0_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 421 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 421 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/D0_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 4122) || (std::abs(mp2.pdgCode()) == 431 && std::abs(mp1.pdgCode()) == 4122)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dspm_Lcpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 4232) || (std::abs(mp2.pdgCode()) == 431 && std::abs(mp1.pdgCode()) == 4232)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dspm_Xicpm/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 4132) || (std::abs(mp2.pdgCode()) == 431 && std::abs(mp1.pdgCode()) == 4132)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dspm_Xic0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } else if ((std::abs(mp1.pdgCode()) == 431 && std::abs(mp2.pdgCode()) == 4332) || (std::abs(mp2.pdgCode()) == 431 && std::abs(mp1.pdgCode()) == 4332)) { + fRegistry.fill(HIST("Generated/ccbar/c2l_c2l/Dspm_Omegac0/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); + } } break; } case static_cast(EM_HFeeType::kBe_Be): { - fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); if (isBeautyMeson(mp1) && isBeautyMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else if (isBeautyBaryon(mp1) && isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else { - fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } break; } case static_cast(EM_HFeeType::kBCe_BCe): { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2c2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2c2l/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else { - fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2l_b2l/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } break; } case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } break; } @@ -1352,7 +1593,7 @@ struct DileptonMC { } // end of HF evaluation } // end of true ULS pair loop - for (auto& [t1, t2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { + for (const auto& [t1, t2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LOGF(info, "pdg1 = %d, pdg2 = %d", t1.pdgCode(), t2.pdgCode()); if (!isInAcceptance(t1) || !isInAcceptance(t2)) { @@ -1447,10 +1688,11 @@ struct DileptonMC { } } - float aco = 1.f - abs(dphi) / M_PI; - float asym = abs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); + float aco = 1.f - std::fabs(dphi) / M_PI; + float asym = std::fabs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); float dphi_e_ee = v1.Phi() - v12.Phi(); o2::math_utils::bringToPMPi(dphi_e_ee); + dphi = RecoDecay::constrainAngle(dphi, -o2::constants::math::PIHalf, 1); // shift dphi in [-pi/2, +3pi/2] rad. after deta-dphi cut. float cos_thetaCS = 999, phiCS = 999.f; o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, leptonM1, leptonM2, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); @@ -1473,13 +1715,13 @@ struct DileptonMC { LOGF(info, "You should not see kBCe_Be_SameB in LS++. Good luck."); break; case static_cast(EM_HFeeType::kBCe_Be_DiffB): { // LS - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } break; } @@ -1489,7 +1731,7 @@ struct DileptonMC { } } // end of true LS++ pair loop - for (auto& [t1, t2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { + for (const auto& [t1, t2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LOGF(info, "pdg1 = %d, pdg2 = %d", t1.pdgCode(), t2.pdgCode()); if (!isInAcceptance(t1) || !isInAcceptance(t2)) { @@ -1584,10 +1826,11 @@ struct DileptonMC { } } - float aco = 1.f - abs(dphi) / M_PI; - float asym = abs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); + float aco = 1.f - std::fabs(dphi) / M_PI; + float asym = std::fabs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); float dphi_e_ee = v1.Phi() - v12.Phi(); o2::math_utils::bringToPMPi(dphi_e_ee); + dphi = RecoDecay::constrainAngle(dphi, -o2::constants::math::PIHalf, 1); // shift dphi in [-pi/2, +3pi/2] rad. after deta-dphi cut. float cos_thetaCS = 999, phiCS = 999.f; o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, leptonM1, leptonM2, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); @@ -1610,13 +1853,13 @@ struct DileptonMC { LOGF(info, "You should not see kBCe_Be_SameB in LS--. Good luck."); break; case static_cast(EM_HFeeType::kBCe_Be_DiffB): { // LS - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), abs(dphi), deta, abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); + fRegistry.fill(HIST("Generated/bbbar/b2c2l_b2l_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, deta, std::fabs(cos_thetaCS), std::fabs(phiCS), aco, asym, std::fabs(dphi_e_ee)); } break; } @@ -1628,8 +1871,8 @@ struct DileptonMC { } // end of collision loop } - template - bool isPairOK(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut) + template + bool isPairOK(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const& tracks) { if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { @@ -1645,10 +1888,16 @@ struct DileptonMC { if (!cut.template IsSelectedTrack(t1) || !cut.template IsSelectedTrack(t2)) { return false; } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t1, cut, tracks)) { + return false; + } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(t2, cut, tracks)) { + return false; + } } if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - if (!cut.template IsSelectedPair(t1, t2, d_bz)) { + if (!cut.template IsSelectedPair(t1, t2, d_bz, dielectroncuts.cfgRefR)) { return false; } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { @@ -1666,7 +1915,7 @@ struct DileptonMC { std::vector> passed_pairIds; passed_pairIds.reserve(posTracks.size() * negTracks.size()); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { initCCDB(collision); const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { @@ -1676,6 +1925,9 @@ struct DileptonMC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } // auto mccollision = collision.template emmcevent_as(); // if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { @@ -1685,7 +1937,7 @@ struct DileptonMC { auto posTracks_per_coll = posTracks.sliceByCached(perCollision, collision.globalIndex(), cache); auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache); - for (auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS auto mcpos = mcparticles.iteratorAt(pos.emmcparticleId()); auto mccollision_from_pos = mcpos.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision_from_pos.getSubGeneratorId() != cfgEventGeneratorType) { @@ -1697,11 +1949,11 @@ struct DileptonMC { continue; } - if (isPairOK(collision, pos, neg, cut)) { + if (isPairOK(collision, pos, neg, cut, tracks)) { passed_pairIds.emplace_back(std::make_pair(pos.globalIndex(), neg.globalIndex())); } } - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ + for (const auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ auto mcpos1 = mcparticles.iteratorAt(pos1.emmcparticleId()); auto mccollision_from_pos1 = mcpos1.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision_from_pos1.getSubGeneratorId() != cfgEventGeneratorType) { @@ -1713,11 +1965,11 @@ struct DileptonMC { continue; } - if (isPairOK(collision, pos1, pos2, cut)) { + if (isPairOK(collision, pos1, pos2, cut, tracks)) { passed_pairIds.emplace_back(std::make_pair(pos1.globalIndex(), pos2.globalIndex())); } } - for (auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- + for (const auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- auto mcneg1 = mcparticles.iteratorAt(neg1.emmcparticleId()); auto mccollision_from_neg1 = mcneg1.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision_from_neg1.getSubGeneratorId() != cfgEventGeneratorType) { @@ -1728,21 +1980,21 @@ struct DileptonMC { if (cfgEventGeneratorType >= 0 && mccollision_from_neg2.getSubGeneratorId() != cfgEventGeneratorType) { continue; } - if (isPairOK(collision, neg1, neg2, cut)) { + if (isPairOK(collision, neg1, neg2, cut, tracks)) { passed_pairIds.emplace_back(std::make_pair(neg1.globalIndex(), neg2.globalIndex())); } } } // end of collision loop if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - for (auto& pairId : passed_pairIds) { + for (const auto& pairId : passed_pairIds) { auto t1 = tracks.rawIteratorAt(std::get<0>(pairId)); auto t2 = tracks.rawIteratorAt(std::get<1>(pairId)); // LOGF(info, "std::get<0>(pairId) = %d, std::get<1>(pairId) = %d, t1.globalIndex() = %d, t2.globalIndex() = %d", std::get<0>(pairId), std::get<1>(pairId), t1.globalIndex(), t2.globalIndex()); float n = 1.f; // include myself. - for (auto& ambId1 : t1.ambiguousElectronsIds()) { - for (auto& ambId2 : t2.ambiguousElectronsIds()) { + for (const auto& ambId1 : t1.ambiguousElectronsIds()) { + for (const auto& ambId2 : t2.ambiguousElectronsIds()) { if (std::find(passed_pairIds.begin(), passed_pairIds.end(), std::make_pair(ambId1, ambId2)) != passed_pairIds.end()) { n += 1.f; } @@ -1751,13 +2003,13 @@ struct DileptonMC { map_weight[pairId] = 1.f / n; } // end of passed_pairIds loop } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - for (auto& pairId : passed_pairIds) { + for (const auto& pairId : passed_pairIds) { auto t1 = tracks.rawIteratorAt(std::get<0>(pairId)); auto t2 = tracks.rawIteratorAt(std::get<1>(pairId)); float n = 1.f; // include myself. - for (auto& ambId1 : t1.ambiguousMuonsIds()) { - for (auto& ambId2 : t2.ambiguousMuonsIds()) { + for (const auto& ambId1 : t1.ambiguousMuonsIds()) { + for (const auto& ambId2 : t2.ambiguousMuonsIds()) { if (std::find(passed_pairIds.begin(), passed_pairIds.end(), std::make_pair(ambId1, ambId2)) != passed_pairIds.end()) { n += 1.f; } @@ -1804,10 +2056,10 @@ struct DileptonMC { return true; } - template - void fillUnfolding(TCollisions const& collisions, TTracks1 const& posTracks, TTracks2 const& negTracks, TPresilce const& perCollision, TCut const& cut, TMCCollisions const&, TMCParticles const& mcparticles) + template + void fillUnfolding(TCollisions const& collisions, TTracks1 const& posTracks, TTracks2 const& negTracks, TPresilce const& perCollision, TCut const& cut, TAllTracks const& tracks, TMCCollisions const&, TMCParticles const& mcparticles) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { initCCDB(collision); const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { @@ -1817,11 +2069,14 @@ struct DileptonMC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } auto posTracks_per_coll = posTracks.sliceByCached(perCollision, collision.globalIndex(), cache); // reconstructed pos tracks auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache); // reconstructed neg tracks - for (auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS auto mcpos = mcparticles.iteratorAt(pos.emmcparticleId()); auto mccollision_from_pos = mcpos.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision_from_pos.getSubGeneratorId() != cfgEventGeneratorType) { @@ -1834,7 +2089,7 @@ struct DileptonMC { continue; } - if ((abs(mcpos.pdgCode()) != pdg_lepton || abs(mcneg.pdgCode()) != pdg_lepton) || (mcpos.emmceventId() != mcneg.emmceventId())) { + if ((std::abs(mcpos.pdgCode()) != pdg_lepton || std::abs(mcneg.pdgCode()) != pdg_lepton) || (mcpos.emmceventId() != mcneg.emmceventId())) { continue; } if (mcpos.pdgCode() * mcneg.pdgCode() > 0) { // ULS @@ -1849,7 +2104,7 @@ struct DileptonMC { continue; } - if (!isPairOK(collision, pos, neg, cut)) { // without acceptance + if (!isPairOK(collision, pos, neg, cut, tracks)) { // without acceptance continue; } @@ -1868,7 +2123,7 @@ struct DileptonMC { if (mother_id > -1) { auto mcmother = mcparticles.iteratorAt(mother_id); if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { - switch (abs(mcmother.pdgCode())) { + switch (std::abs(mcmother.pdgCode())) { case 111: case 221: case 331: @@ -1961,7 +2216,7 @@ struct DileptonMC { } } // end of ULS pairing - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ + for (const auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ auto mcpos1 = mcparticles.iteratorAt(pos1.emmcparticleId()); auto mccollision_from_pos1 = mcpos1.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision_from_pos1.getSubGeneratorId() != cfgEventGeneratorType) { @@ -1973,7 +2228,7 @@ struct DileptonMC { continue; } - if ((abs(mcpos1.pdgCode()) != pdg_lepton || abs(mcpos2.pdgCode()) != pdg_lepton) || (mcpos1.emmceventId() != mcpos2.emmceventId())) { + if ((std::abs(mcpos1.pdgCode()) != pdg_lepton || std::abs(mcpos2.pdgCode()) != pdg_lepton) || (mcpos1.emmceventId() != mcpos2.emmceventId())) { continue; } if (mcpos1.pdgCode() * mcpos2.pdgCode() < 0) { // LS @@ -1987,7 +2242,7 @@ struct DileptonMC { continue; } - if (!isPairOK(collision, pos1, pos2, cut)) { // without acceptance + if (!isPairOK(collision, pos1, pos2, cut, tracks)) { // without acceptance continue; } @@ -2033,7 +2288,7 @@ struct DileptonMC { } } // end of LS++ pairing - for (auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- + for (const auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- auto mcneg1 = mcparticles.iteratorAt(neg1.emmcparticleId()); auto mccollision_from_neg1 = mcneg1.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision_from_neg1.getSubGeneratorId() != cfgEventGeneratorType) { @@ -2044,10 +2299,10 @@ struct DileptonMC { if (cfgEventGeneratorType >= 0 && mccollision_from_neg2.getSubGeneratorId() != cfgEventGeneratorType) { continue; } - if (!isPairOK(collision, neg1, neg2, cut)) { // without acceptance + if (!isPairOK(collision, neg1, neg2, cut, tracks)) { // without acceptance continue; } - if ((abs(mcneg1.pdgCode()) != pdg_lepton || abs(mcneg2.pdgCode()) != pdg_lepton) || (mcneg1.emmceventId() != mcneg2.emmceventId())) { + if ((std::abs(mcneg1.pdgCode()) != pdg_lepton || std::abs(mcneg2.pdgCode()) != pdg_lepton) || (mcneg1.emmceventId() != mcneg2.emmceventId())) { continue; } if (mcneg1.pdgCode() * mcneg2.pdgCode() < 0) { // LS @@ -2061,7 +2316,7 @@ struct DileptonMC { continue; } - if (!isPairOK(collision, neg1, neg2, cut)) { // without acceptance + if (!isPairOK(collision, neg1, neg2, cut, tracks)) { // without acceptance continue; } @@ -2129,19 +2384,19 @@ struct DileptonMC { if (cfgApplyWeightTTCA) { fillPairWeightMap(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, leptons, mccollisions, mcparticles); } - runTruePairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, mccollisions, mcparticles); + runTruePairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, leptons, mccollisions, mcparticles); runGenInfo(collisions, mccollisions, positive_electronsMC, negative_electronsMC, mcparticles); if (cfgFillUnfolding) { - fillUnfolding(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, mccollisions, mcparticles); + fillUnfolding(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, leptons, mccollisions, mcparticles); } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { if (cfgApplyWeightTTCA) { fillPairWeightMap(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, leptons, mccollisions, mcparticles); } - runTruePairing(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, mccollisions, mcparticles); + runTruePairing(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, leptons, mccollisions, mcparticles); runGenInfo(collisions, mccollisions, positive_muonsMC, negative_muonsMC, mcparticles); if (cfgFillUnfolding) { - fillUnfolding(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, mccollisions, mcparticles); + fillUnfolding(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, leptons, mccollisions, mcparticles); } } map_weight.clear(); @@ -2160,19 +2415,19 @@ struct DileptonMC { if (cfgApplyWeightTTCA) { fillPairWeightMap(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, leptons, mccollisions, mcparticles_smeared); } - runTruePairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, mccollisions, mcparticles_smeared); + runTruePairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, leptons, mccollisions, mcparticles_smeared); runGenInfo(collisions, mccollisions, positive_electronsMC_smeared, negative_electronsMC_smeared, mcparticles_smeared); if (cfgFillUnfolding) { - fillUnfolding(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, mccollisions, mcparticles_smeared); + fillUnfolding(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, leptons, mccollisions, mcparticles_smeared); } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { if (cfgApplyWeightTTCA) { fillPairWeightMap(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, leptons, mccollisions, mcparticles_smeared); } - runTruePairing(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, mccollisions, mcparticles_smeared); + runTruePairing(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, leptons, mccollisions, mcparticles_smeared); runGenInfo(collisions, mccollisions, positive_muonsMC_smeared, negative_muonsMC_smeared, mcparticles_smeared); if (cfgFillUnfolding) { - fillUnfolding(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, mccollisions, mcparticles_smeared); + fillUnfolding(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, leptons, mccollisions, mcparticles_smeared); } } map_weight.clear(); @@ -2182,7 +2437,7 @@ struct DileptonMC { void processGen_VM(FilteredMyCollisions const& collisions, MyMCCollisions const&, aod::EMMCGenVectorMesons const& mcparticles) { // for oemga, phi efficiency - for (auto& collision : collisions) { + for (const auto& collision : collisions) { float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { continue; @@ -2191,13 +2446,16 @@ struct DileptonMC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } auto mccollision = collision.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { continue; } auto mctracks_per_coll = mcparticles.sliceBy(perMcCollision_vm, mccollision.globalIndex()); - for (auto& mctrack : mctracks_per_coll) { + for (const auto& mctrack : mctracks_per_coll) { if (!(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { continue; @@ -2213,7 +2471,7 @@ struct DileptonMC { } } - switch (abs(mctrack.pdgCode())) { + switch (std::abs(mctrack.pdgCode())) { case 223: fRegistry.fill(HIST("Generated/sm/Omega2ll/hPtY"), mctrack.y(), mctrack.pt(), 1.f / mctrack.dsf()); break; @@ -2231,7 +2489,7 @@ struct DileptonMC { void processNorm(aod::EMEventNormInfos const& collisions) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 1.0); if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 2.0); @@ -2260,7 +2518,7 @@ struct DileptonMC { if (collision.sel8()) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 10.0); } - if (abs(collision.posZ()) < 10.0) { + if (std::fabs(collision.posZ()) < 10.0) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 11.0); } if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { @@ -2278,14 +2536,52 @@ struct DileptonMC { if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 16.0); } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 17.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 18.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 19.0); + } if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } fRegistry.fill(HIST("Event/norm/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted } // end of collision loop } PROCESS_SWITCH(DileptonMC, processNorm, "process normalization info", false); + void processBC(aod::EMBCs const& bcs) + { + for (const auto& bc : bcs) { + if (bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 0.f); + + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 1.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 2.f); + } + if (rctChecker(bc)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 3.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 4.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) && rctChecker(bc)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 5.f); + } + } + } + } + PROCESS_SWITCH(DileptonMC, processBC, "process BC counter", false); + void processDummy(FilteredMyCollisions const&) {} PROCESS_SWITCH(DileptonMC, processDummy, "Dummy function", false); }; diff --git a/PWGEM/Dilepton/Core/DimuonCut.cxx b/PWGEM/Dilepton/Core/DimuonCut.cxx index ec101afa855..ef5e44123aa 100644 --- a/PWGEM/Dilepton/Core/DimuonCut.cxx +++ b/PWGEM/Dilepton/Core/DimuonCut.cxx @@ -13,9 +13,12 @@ // Class for dimuon Cut // -#include "Framework/Logger.h" #include "PWGEM/Dilepton/Core/DimuonCut.h" +#include "Framework/Logger.h" + +#include + ClassImp(DimuonCut); void DimuonCut::SetMassRange(float min, float max) @@ -34,7 +37,7 @@ void DimuonCut::SetPairYRange(float minY, float maxY) { mMinPairY = minY; mMaxPairY = maxY; - LOG(info) << "Dimuon Cut, set pair eta range: " << mMinPairY << " - " << mMaxPairY; + LOG(info) << "Dimuon Cut, set pair rapidity range: " << mMinPairY << " - " << mMaxPairY; } void DimuonCut::SetPairDCAxyRange(float min, float max) { @@ -119,3 +122,22 @@ void DimuonCut::SetMaxPDCARabsDep(std::function RabsDepCut) mMaxPDCARabsDep = RabsDepCut; LOG(info) << "Dimuon Cut, set max pDCA as a function of Rabs: " << mMaxPDCARabsDep(10.0); } +void DimuonCut::SetMFTHitMap(bool flag, std::vector hitMap) +{ + mApplyMFTHitMap = flag; + mRequiredMFTDisks = hitMap; + if (mApplyMFTHitMap) { + for (const auto& iDisk : mRequiredMFTDisks) { + LOG(info) << "Dimuon Cut, require MFT hit on Disk: " << iDisk; + } + } +} +void DimuonCut::SetMaxdPtdEtadPhiwrtMCHMID(float reldPtMax, float dEtaMax, float dPhiMax) +{ + mMaxReldPtwrtMCHMID = reldPtMax; + mMaxdEtawrtMCHMID = dEtaMax; + mMaxdPhiwrtMCHMID = dPhiMax; + LOG(info) << "Dimuon Cut, set max rel. dpt between MFT-MCH-MID and associated MCH-MID: " << mMaxReldPtwrtMCHMID; + LOG(info) << "Dimuon Cut, set max deta between MFT-MCH-MID and associated MCH-MID: " << mMaxdEtawrtMCHMID; + LOG(info) << "Dimuon Cut, set max dphi between MFT-MCH-MID and associated MCH-MID: " << mMaxdPhiwrtMCHMID; +} diff --git a/PWGEM/Dilepton/Core/DimuonCut.h b/PWGEM/Dilepton/Core/DimuonCut.h index b13569387da..2895c95f311 100644 --- a/PWGEM/Dilepton/Core/DimuonCut.h +++ b/PWGEM/Dilepton/Core/DimuonCut.h @@ -16,19 +16,21 @@ #ifndef PWGEM_DILEPTON_CORE_DIMUONCUT_H_ #define PWGEM_DILEPTON_CORE_DIMUONCUT_H_ +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/DataTypes.h" +#include "Framework/Logger.h" +#include "MathUtils/Utils.h" + +#include "Math/Vector4D.h" +#include "TNamed.h" + #include #include -#include -#include #include -#include "TNamed.h" -#include "Math/Vector4D.h" - -#include "MathUtils/Utils.h" -#include "Framework/Logger.h" -#include "Framework/DataTypes.h" -#include "CommonConstants/PhysicsConstants.h" -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include +#include using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; @@ -59,6 +61,8 @@ class DimuonCut : public TNamed kMatchingChi2MCHMID, kRabs, kPDCA, + kMFTHitMap, + kDPtDEtaDPhiwrtMCHMID, kNCuts }; @@ -154,41 +158,10 @@ class DimuonCut : public TNamed if (!IsSelectedTrack(track, DimuonCuts::kRabs)) { return false; } - - return true; - } - - template - bool IsSelectedTrackWoPtEta(TTrack const& track) const - { - if (!IsSelectedTrack(track, DimuonCuts::kTrackType)) { - return false; - } - if (!IsSelectedTrack(track, DimuonCuts::kTrackPhiRange)) { - return false; - } - if (!IsSelectedTrack(track, DimuonCuts::kDCAxy)) { - return false; - } - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && !IsSelectedTrack(track, DimuonCuts::kMFTNCls)) { - return false; - } - if (!IsSelectedTrack(track, DimuonCuts::kMCHMIDNCls)) { - return false; - } - if (!IsSelectedTrack(track, DimuonCuts::kChi2)) { - return false; - } - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && !IsSelectedTrack(track, DimuonCuts::kMatchingChi2MCHMFT)) { - return false; - } - if (!IsSelectedTrack(track, DimuonCuts::kMatchingChi2MCHMID)) { + if (mApplyMFTHitMap && track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && !IsSelectedTrack(track, DimuonCuts::kMFTHitMap)) { return false; } - if (!IsSelectedTrack(track, DimuonCuts::kPDCA)) { - return false; - } - if (!IsSelectedTrack(track, DimuonCuts::kRabs)) { + if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && !IsSelectedTrack(track, DimuonCuts::kDPtDEtaDPhiwrtMCHMID)) { return false; } @@ -221,7 +194,7 @@ class DimuonCut : public TNamed return track.nClusters() >= mMinNClustersMCHMID; case DimuonCuts::kChi2: - return track.chi2() < mMaxChi2; + return (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) ? track.chi2() / (2.f * (track.nClusters() + track.nClustersMFT()) - 5.f) : track.chi2()) < mMaxChi2; case DimuonCuts::kMatchingChi2MCHMFT: return track.chi2MatchMCHMFT() < mMaxMatchingChi2MCHMFT; @@ -235,6 +208,19 @@ class DimuonCut : public TNamed case DimuonCuts::kRabs: return mMinRabs < track.rAtAbsorberEnd() && track.rAtAbsorberEnd() < mMaxRabs; + case DimuonCuts::kMFTHitMap: { + std::vector mftHitMap{checkMFTHitMap<0, 1>(track), checkMFTHitMap<2, 3>(track), checkMFTHitMap<4, 5>(track), checkMFTHitMap<6, 7>(track), checkMFTHitMap<8, 9>(track)}; + for (const auto& iDisk : mRequiredMFTDisks) { + if (!mftHitMap[iDisk]) { + return false; + } + } + return true; + } + + case DimuonCuts::kDPtDEtaDPhiwrtMCHMID: + return std::fabs(track.ptMatchedMCHMID() - track.pt()) / track.pt() < mMaxReldPtwrtMCHMID && std::sqrt(std::pow((track.etaMatchedMCHMID() - track.eta()) / mMaxdEtawrtMCHMID, 2) + std::pow((track.phiMatchedMCHMID() - track.phi()) / mMaxdPhiwrtMCHMID, 2)) < 1.f; + default: return false; } @@ -259,6 +245,8 @@ class DimuonCut : public TNamed void SetDCAxy(float min, float max); // in cm void SetRabs(float min, float max); // in cm void SetMaxPDCARabsDep(std::function RabsDepCut); + void SetMFTHitMap(bool flag, std::vector hitMap); + void SetMaxdPtdEtadPhiwrtMCHMID(float reldPtMax, float dEtaMax, float dPhiMax); // this is relevant for global muons private: // pair cuts @@ -286,6 +274,9 @@ class DimuonCut : public TNamed float mMinRabs{17.6}, mMaxRabs{89.5}; float mMinDcaXY{0.0f}, mMaxDcaXY{1e10f}; + float mMaxReldPtwrtMCHMID{1e10f}, mMaxdEtawrtMCHMID{1e10f}, mMaxdPhiwrtMCHMID{1e10f}; + bool mApplyMFTHitMap{false}; + std::vector mRequiredMFTDisks{}; ClassDef(DimuonCut, 1); }; diff --git a/PWGEM/Dilepton/Core/EMEventCut.cxx b/PWGEM/Dilepton/Core/EMEventCut.cxx index 07bdaf8cb52..58e3c5be4e8 100644 --- a/PWGEM/Dilepton/Core/EMEventCut.cxx +++ b/PWGEM/Dilepton/Core/EMEventCut.cxx @@ -13,9 +13,10 @@ // Class for em event selection // -#include "Framework/Logger.h" #include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "Framework/Logger.h" + ClassImp(EMEventCut); void EMEventCut::SetRequireSel8(bool flag) @@ -61,6 +62,12 @@ void EMEventCut::SetRequireVertexITSTPC(bool flag) LOG(info) << "EM Event Cut, require vertex reconstructed by ITS-TPC matched track: " << mRequireVertexITSTPC; } +void EMEventCut::SetRequireVertexTOFmatched(bool flag) +{ + mRequireVertexTOFmatched = flag; + LOG(info) << "EM Event Cut, require vertex reconstructed by ITS-TPC-TOF matched track: " << mRequireVertexTOFmatched; +} + void EMEventCut::SetRequireGoodZvtxFT0vsPV(bool flag) { mRequireGoodZvtxFT0vsPV = flag; @@ -95,3 +102,21 @@ void EMEventCut::SetRequireNoHighMultCollInPrevRof(bool flag) mRequireNoHighMultCollInPrevRof = flag; LOG(info) << "EM Event Cut, require No HM collision in previous ITS ROF: " << mRequireNoHighMultCollInPrevRof; } + +void EMEventCut::SetRequireGoodITSLayer3(bool flag) +{ + mRequireGoodITSLayer3 = flag; + LOG(info) << "EM Event Cut, require GoodITSLayer3: " << mRequireGoodITSLayer3; +} + +void EMEventCut::SetRequireGoodITSLayer0123(bool flag) +{ + mRequireGoodITSLayer0123 = flag; + LOG(info) << "EM Event Cut, require GoodITSLayer0123: " << mRequireGoodITSLayer0123; +} + +void EMEventCut::SetRequireGoodITSLayersAll(bool flag) +{ + mRequireGoodITSLayersAll = flag; + LOG(info) << "EM Event Cut, require GoodITSLayersAll: " << mRequireGoodITSLayersAll; +} diff --git a/PWGEM/Dilepton/Core/EMEventCut.h b/PWGEM/Dilepton/Core/EMEventCut.h index a5636c13630..8dc1b7ef961 100644 --- a/PWGEM/Dilepton/Core/EMEventCut.h +++ b/PWGEM/Dilepton/Core/EMEventCut.h @@ -16,10 +16,11 @@ #ifndef PWGEM_DILEPTON_CORE_EMEVENTCUT_H_ #define PWGEM_DILEPTON_CORE_EMEVENTCUT_H_ -#include "TNamed.h" #include "Common/CCDB/EventSelectionParams.h" #include "Common/CCDB/TriggerAliases.h" +#include "TNamed.h" + using namespace std; class EMEventCut : public TNamed @@ -37,12 +38,16 @@ class EMEventCut : public TNamed kNoITSROFB, // no ITS read out frame border kNoSameBunchPileup, kIsVertexITSTPC, + kIsVertexTOFmatched, kIsGoodZvtxFT0vsPV, kNoCollInTimeRangeStandard, kNoCollInTimeRangeStrict, kNoCollInITSROFStandard, kNoCollInITSROFStrict, kNoHighMultCollInPrevRof, + kIsGoodITSLayer3, + kIsGoodITSLayer0123, + kIsGoodITSLayersAll, kNCuts }; @@ -70,6 +75,9 @@ class EMEventCut : public TNamed if (mRequireVertexITSTPC && !IsSelected(collision, EMEventCuts::kIsVertexITSTPC)) { return false; } + if (mRequireVertexTOFmatched && !IsSelected(collision, EMEventCuts::kIsVertexTOFmatched)) { + return false; + } if (mRequireGoodZvtxFT0vsPV && !IsSelected(collision, EMEventCuts::kIsGoodZvtxFT0vsPV)) { return false; } @@ -88,6 +96,15 @@ class EMEventCut : public TNamed if (mRequireNoHighMultCollInPrevRof && !IsSelected(collision, EMEventCuts::kNoHighMultCollInPrevRof)) { return false; } + if (mRequireGoodITSLayer3 && !IsSelected(collision, EMEventCuts::kIsGoodITSLayer3)) { + return false; + } + if (mRequireGoodITSLayer0123 && !IsSelected(collision, EMEventCuts::kIsGoodITSLayer0123)) { + return false; + } + if (mRequireGoodITSLayersAll && !IsSelected(collision, EMEventCuts::kIsGoodITSLayersAll)) { + return false; + } return true; } @@ -116,6 +133,9 @@ class EMEventCut : public TNamed case EMEventCuts::kIsVertexITSTPC: return collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC); + case EMEventCuts::kIsVertexTOFmatched: + return collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched); + case EMEventCuts::kIsGoodZvtxFT0vsPV: return collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV); @@ -134,6 +154,15 @@ class EMEventCut : public TNamed case EMEventCuts::kNoHighMultCollInPrevRof: return collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof); + case EMEventCuts::kIsGoodITSLayer3: + return collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3); + + case EMEventCuts::kIsGoodITSLayer0123: + return collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123); + + case EMEventCuts::kIsGoodITSLayersAll: + return collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll); + default: return true; } @@ -147,12 +176,16 @@ class EMEventCut : public TNamed void SetRequireNoITSROFB(bool flag); void SetRequireNoSameBunchPileup(bool flag); void SetRequireVertexITSTPC(bool flag); + void SetRequireVertexTOFmatched(bool flag); void SetRequireGoodZvtxFT0vsPV(bool flag); void SetRequireNoCollInTimeRangeStandard(bool flag); void SetRequireNoCollInTimeRangeStrict(bool flag); void SetRequireNoCollInITSROFStandard(bool flag); void SetRequireNoCollInITSROFStrict(bool flag); void SetRequireNoHighMultCollInPrevRof(bool flag); + void SetRequireGoodITSLayer3(bool flag); + void SetRequireGoodITSLayer0123(bool flag); + void SetRequireGoodITSLayersAll(bool flag); private: bool mRequireSel8{false}; @@ -162,12 +195,16 @@ class EMEventCut : public TNamed bool mRequireNoITSROFB{false}; bool mRequireNoSameBunchPileup{false}; bool mRequireVertexITSTPC{false}; + bool mRequireVertexTOFmatched{false}; bool mRequireGoodZvtxFT0vsPV{false}; bool mRequireNoCollInTimeRangeStandard{false}; bool mRequireNoCollInTimeRangeStrict{false}; bool mRequireNoCollInITSROFStandard{false}; bool mRequireNoCollInITSROFStrict{false}; bool mRequireNoHighMultCollInPrevRof{false}; + bool mRequireGoodITSLayer3{false}; + bool mRequireGoodITSLayer0123{false}; + bool mRequireGoodITSLayersAll{false}; ClassDef(EMEventCut, 1); }; diff --git a/PWGEM/Dilepton/Core/EMTrackCut.cxx b/PWGEM/Dilepton/Core/EMTrackCut.cxx new file mode 100644 index 00000000000..2ea7934a30b --- /dev/null +++ b/PWGEM/Dilepton/Core/EMTrackCut.cxx @@ -0,0 +1,119 @@ +// 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. + +// +// Class for track Cut +// + +#include "PWGEM/Dilepton/Core/EMTrackCut.h" + +#include "Framework/Logger.h" + +#include +#include + +ClassImp(EMTrackCut); + +const std::pair> EMTrackCut::its_ib_any_Requirement = {1, {0, 1, 2}}; // hits on any ITS ib layers. +const std::pair> EMTrackCut::its_ib_1st_Requirement = {1, {0}}; // hit on 1st ITS ib layers. + +void EMTrackCut::SetTrackPtRange(float minPt, float maxPt) +{ + mMinTrackPt = minPt; + mMaxTrackPt = maxPt; + LOG(info) << "EMTrack Cut, set track pt range: " << mMinTrackPt << " - " << mMaxTrackPt; +} +void EMTrackCut::SetTrackEtaRange(float minEta, float maxEta) +{ + mMinTrackEta = minEta; + mMaxTrackEta = maxEta; + LOG(info) << "EMTrack Cut, set track eta range: " << mMinTrackEta << " - " << mMaxTrackEta; +} +void EMTrackCut::SetTrackPhiRange(float minPhi, float maxPhi) +{ + mMinTrackPhi = minPhi; + mMaxTrackPhi = maxPhi; + LOG(info) << "EMTrack Cut, set track phi range (rad.): " << mMinTrackPhi << " - " << mMaxTrackPhi; +} +void EMTrackCut::SetMinNClustersTPC(int minNClustersTPC) +{ + mMinNClustersTPC = minNClustersTPC; + LOG(info) << "EMTrack Cut, set min N clusters TPC: " << mMinNClustersTPC; +} +void EMTrackCut::SetMinNCrossedRowsTPC(int minNCrossedRowsTPC) +{ + mMinNCrossedRowsTPC = minNCrossedRowsTPC; + LOG(info) << "EMTrack Cut, set min N crossed rows TPC: " << mMinNCrossedRowsTPC; +} +void EMTrackCut::SetMinNCrossedRowsOverFindableClustersTPC(float minNCrossedRowsOverFindableClustersTPC) +{ + mMinNCrossedRowsOverFindableClustersTPC = minNCrossedRowsOverFindableClustersTPC; + LOG(info) << "EMTrack Cut, set min N crossed rows over findable clusters TPC: " << mMinNCrossedRowsOverFindableClustersTPC; +} +void EMTrackCut::SetMaxFracSharedClustersTPC(float max) +{ + mMaxFracSharedClustersTPC = max; + LOG(info) << "EMTrack Cut, set max fraction of shared clusters in TPC: " << mMaxFracSharedClustersTPC; +} +void EMTrackCut::SetChi2PerClusterTPC(float min, float max) +{ + mMinChi2PerClusterTPC = min; + mMaxChi2PerClusterTPC = max; + LOG(info) << "EMTrack Cut, set chi2 per cluster TPC range: " << mMinChi2PerClusterTPC << " - " << mMaxChi2PerClusterTPC; +} + +void EMTrackCut::SetNClustersITS(int min, int max) +{ + mMinNClustersITS = min; + mMaxNClustersITS = max; + LOG(info) << "EMTrack Cut, set N clusters ITS range: " << mMinNClustersITS << " - " << mMaxNClustersITS; +} +void EMTrackCut::SetChi2PerClusterITS(float min, float max) +{ + mMinChi2PerClusterITS = min; + mMaxChi2PerClusterITS = max; + LOG(info) << "EMTrack Cut, set chi2 per cluster ITS range: " << mMinChi2PerClusterITS << " - " << mMaxChi2PerClusterITS; +} + +void EMTrackCut::SetTrackMaxDcaXY(float maxDcaXY) +{ + mMaxDcaXY = maxDcaXY; + LOG(info) << "EMTrack Cut, set max DCA xy: " << mMaxDcaXY; +} +void EMTrackCut::SetTrackMaxDcaZ(float maxDcaZ) +{ + mMaxDcaZ = maxDcaZ; + LOG(info) << "EMTrack Cut, set max DCA z: " << mMaxDcaZ; +} + +void EMTrackCut::SetTrackMaxDcaXYPtDep(std::function ptDepCut) +{ + mMaxDcaXYPtDep = ptDepCut; + LOG(info) << "EMTrack Cut, set max DCA xy pt dep: " << mMaxDcaXYPtDep(1.0); +} + +void EMTrackCut::RequireITSibAny(bool flag) +{ + mRequireITSibAny = flag; + LOG(info) << "EMTrack Cut, require ITS ib any: " << mRequireITSibAny; +} + +void EMTrackCut::RequireITSib1st(bool flag) +{ + mRequireITSib1st = flag; + LOG(info) << "EMTrack Cut, require ITS ib 1st: " << mRequireITSib1st; +} + +void EMTrackCut::SetTrackBit(uint16_t bit) +{ + mTrackBit = bit; + LOG(info) << "EMTrack Cut, require track bits: " << mTrackBit; +} diff --git a/PWGEM/Dilepton/Core/EMTrackCut.h b/PWGEM/Dilepton/Core/EMTrackCut.h new file mode 100644 index 00000000000..58503b8a82e --- /dev/null +++ b/PWGEM/Dilepton/Core/EMTrackCut.h @@ -0,0 +1,233 @@ +// 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. + +// +// Class for track selection +// + +#ifndef PWGEM_DILEPTON_CORE_EMTRACKCUT_H_ +#define PWGEM_DILEPTON_CORE_EMTRACKCUT_H_ + +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/DataTypes.h" +#include "Framework/Logger.h" + +#include "Math/Vector4D.h" +#include "TNamed.h" + +#include +#include +#include +#include +#include + +using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; + +class EMTrackCut : public TNamed +{ + public: + EMTrackCut() = default; + EMTrackCut(const char* name, const char* title) : TNamed(name, title) {} + ~EMTrackCut() {} + + enum class EMTrackCuts : int { + // track cut + kTrackPtRange, + kTrackEtaRange, + kTrackPhiRange, + kDCAxy, + kDCAz, + // kTPCNCls, + // kTPCCrossedRows, + // kTPCCrossedRowsOverNCls, + // kTPCFracSharedClusters, + // kTPCChi2NDF, + // kITSNCls, + // kITSChi2NDF, + kTrackBit, + kNCuts + }; + + template + bool IsSelected(TTrack const& track) const + { + // if (!track.hasITS() || !track.hasTPC()) { + // return false; + // } + + if (!IsSelectedTrack(track, EMTrackCuts::kTrackPtRange)) { + return false; + } + if (!IsSelectedTrack(track, EMTrackCuts::kTrackEtaRange)) { + return false; + } + if (!IsSelectedTrack(track, EMTrackCuts::kTrackPhiRange)) { + return false; + } + + if (!IsSelectedTrack(track, EMTrackCuts::kDCAxy)) { + return false; + } + if (!IsSelectedTrack(track, EMTrackCuts::kDCAz)) { + return false; + } + if (!IsSelectedTrack(track, EMTrackCuts::kTrackBit)) { + return false; + } + + // // ITS cuts + // if (!IsSelectedTrack(track, EMTrackCuts::kITSNCls)) { + // return false; + // } + // if (!IsSelectedTrack(track, EMTrackCuts::kITSChi2NDF)) { + // return false; + // } + // + // if (mRequireITSibAny) { + // auto hits_ib = std::count_if(its_ib_any_Requirement.second.begin(), its_ib_any_Requirement.second.end(), [&](auto&& requiredLayer) { return track.itsClusterMap() & (1 << requiredLayer); }); + // if (hits_ib < its_ib_any_Requirement.first) { + // return false; + // } + // } + // + // if (mRequireITSib1st) { + // auto hits_ib = std::count_if(its_ib_1st_Requirement.second.begin(), its_ib_1st_Requirement.second.end(), [&](auto&& requiredLayer) { return track.itsClusterMap() & (1 << requiredLayer); }); + // if (hits_ib < its_ib_1st_Requirement.first) { + // return false; + // } + // } + // + // // TPC cuts + // if (!IsSelectedTrack(track, EMTrackCuts::kTPCNCls)) { + // return false; + // } + // if (!IsSelectedTrack(track, EMTrackCuts::kTPCCrossedRows)) { + // return false; + // } + // if (!IsSelectedTrack(track, EMTrackCuts::kTPCCrossedRowsOverNCls)) { + // return false; + // } + // if (!IsSelectedTrack(track, EMTrackCuts::kTPCFracSharedClusters)) { + // return false; + // } + // if (!IsSelectedTrack(track, EMTrackCuts::kTPCChi2NDF)) { + // return false; + // } + + return true; + } + + template + bool IsSelectedTrack(T const& track, const EMTrackCuts& cut) const + { + switch (cut) { + case EMTrackCuts::kTrackPtRange: + return track.pt() > mMinTrackPt && track.pt() < mMaxTrackPt; + + case EMTrackCuts::kTrackEtaRange: + return track.eta() > mMinTrackEta && track.eta() < mMaxTrackEta; + + case EMTrackCuts::kTrackPhiRange: + return track.phi() > mMinTrackPhi && track.phi() < mMaxTrackPhi; + + // case EMTrackCuts::kDCAxy: + // return std::fabs(track.dcaXY()) < ((mMaxDcaXYPtDep) ? mMaxDcaXYPtDep(track.pt()) : mMaxDcaXY); + + // case EMTrackCuts::kDCAz: + // return std::fabs(track.dcaZ()) < mMaxDcaZ; + + case EMTrackCuts::kTrackBit: { + // for (int i = 0; i < 10; i++) { + // if ((mTrackBit & (1 << i)) > 0 && !((track.trackBit() & (1 << i)) > 0)) { + // return false; + // } + // } + // return true; + return (track.trackBit() & mTrackBit) >= mTrackBit; + } + + // case EMTrackCuts::kTPCNCls: + // return track.tpcNClsFound() >= mMinNClustersTPC; + + // case EMTrackCuts::kTPCCrossedRows: + // return track.tpcNClsCrossedRows() >= mMinNCrossedRowsTPC; + + // case EMTrackCuts::kTPCCrossedRowsOverNCls: + // return track.tpcCrossedRowsOverFindableCls() > mMinNCrossedRowsOverFindableClustersTPC; + + // case EMTrackCuts::kTPCFracSharedClusters: + // return track.tpcFractionSharedCls() < mMaxFracSharedClustersTPC; + + // case EMTrackCuts::kTPCChi2NDF: + // return mMinChi2PerClusterTPC < track.tpcChi2NCl() && track.tpcChi2NCl() < mMaxChi2PerClusterTPC; + + // case EMTrackCuts::kITSNCls: + // return mMinNClustersITS <= track.itsNCls() && track.itsNCls() <= mMaxNClustersITS; + + // case EMTrackCuts::kITSChi2NDF: + // return mMinChi2PerClusterITS < track.itsChi2NCl() && track.itsChi2NCl() < mMaxChi2PerClusterITS; + + default: + return false; + } + } + + // Setters + void SetTrackPtRange(float minPt = 0.f, float maxPt = 1e10f); + void SetTrackEtaRange(float minEta = -1e10f, float maxEta = 1e10f); + void SetTrackPhiRange(float minPhi = 0.f, float maxPhi = 6.3f); + void SetMinNClustersTPC(int minNClustersTPC); + void SetMinNCrossedRowsTPC(int minNCrossedRowsTPC); + void SetMinNCrossedRowsOverFindableClustersTPC(float minNCrossedRowsOverFindableClustersTPC); + void SetMaxFracSharedClustersTPC(float max); + void SetChi2PerClusterTPC(float min, float max); + void SetNClustersITS(int min, int max); + void SetChi2PerClusterITS(float min, float max); + + void SetTrackDca3DRange(float min, float max); // in sigma + void SetTrackMaxDcaXY(float maxDcaXY); // in cm + void SetTrackMaxDcaZ(float maxDcaZ); // in cm + void SetTrackMaxDcaXYPtDep(std::function ptDepCut); + void RequireITSibAny(bool flag); + void RequireITSib1st(bool flag); + void SetTrackBit(uint16_t bits); + + private: + static const std::pair> its_ib_any_Requirement; + static const std::pair> its_ib_1st_Requirement; + + // kinematic cuts + float mMinTrackPt{0.f}, mMaxTrackPt{1e10f}; // range in pT + float mMinTrackEta{-1e10f}, mMaxTrackEta{1e10f}; // range in eta + float mMinTrackPhi{0.f}, mMaxTrackPhi{6.3}; // range in phi + + // track quality cuts + int mMinNClustersTPC{0}; // min number of TPC clusters + int mMinNCrossedRowsTPC{0}; // min number of crossed rows in TPC + float mMinChi2PerClusterTPC{0.f}, mMaxChi2PerClusterTPC{1e10f}; // max tpc fit chi2 per TPC cluster + float mMinNCrossedRowsOverFindableClustersTPC{0.f}; // min ratio crossed rows / findable clusters + float mMaxFracSharedClustersTPC{999.f}; // max ratio shared clusters / clusters in TPC + int mMinNClustersITS{0}, mMaxNClustersITS{7}; // range in number of ITS clusters + float mMinChi2PerClusterITS{0.f}, mMaxChi2PerClusterITS{1e10f}; // max its fit chi2 per ITS cluster + bool mRequireITSibAny{true}; + bool mRequireITSib1st{false}; + uint16_t mTrackBit{0}; + + float mMaxDcaXY{1.0f}; // max dca in xy plane + float mMaxDcaZ{1.0f}; // max dca in z direction + std::function mMaxDcaXYPtDep{}; // max dca in xy plane as function of pT + + ClassDef(EMTrackCut, 1); +}; + +#endif // PWGEM_DILEPTON_CORE_EMTRACKCUT_H_ diff --git a/PWGEM/Dilepton/Core/PWGEMDileptonCoreLinkDef.h b/PWGEM/Dilepton/Core/PWGEMDileptonCoreLinkDef.h index c1af31aa27b..fe78534478e 100644 --- a/PWGEM/Dilepton/Core/PWGEMDileptonCoreLinkDef.h +++ b/PWGEM/Dilepton/Core/PWGEMDileptonCoreLinkDef.h @@ -19,5 +19,6 @@ #pragma link C++ class EMEventCut + ; #pragma link C++ class DielectronCut + ; #pragma link C++ class DimuonCut + ; +#pragma link C++ class EMTrackCut + ; #endif // PWGEM_DILEPTON_CORE_PWGEMDILEPTONCORELINKDEF_H_ diff --git a/PWGEM/Dilepton/Core/PhotonHBT.h b/PWGEM/Dilepton/Core/PhotonHBT.h index 9979b9be8d5..6dde60789ea 100644 --- a/PWGEM/Dilepton/Core/PhotonHBT.h +++ b/PWGEM/Dilepton/Core/PhotonHBT.h @@ -17,40 +17,41 @@ #ifndef PWGEM_DILEPTON_CORE_PHOTONHBT_H_ #define PWGEM_DILEPTON_CORE_PHOTONHBT_H_ +#include "PWGEM/Dilepton/Core/DielectronCut.h" +#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/Dilepton/Utils/EMTrack.h" +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/Utils/EventMixingHandler.h" +#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" + +#include "Tools/ML/MlResponse.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TString.h" + #include #include #include #include +#include #include -#include #include +#include #include -#include - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Math/Vector3D.h" -#include "Math/GenVector/Boost.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Tools/ML/MlResponse.h" - -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" -#include "PWGEM/Dilepton/Core/EMEventCut.h" -#include "PWGEM/Dilepton/Core/DielectronCut.h" -#include "PWGEM/Dilepton/Utils/EMTrack.h" -#include "PWGEM/Dilepton/Utils/EventMixingHandler.h" -#include "PWGEM/Dilepton/Utils/EventHistograms.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" namespace o2::aod::pwgem::dilepton::core::photonhbt { @@ -79,7 +80,7 @@ using MyCollisionWithSWT = MyCollisionsWithSWT::iterator; using MyV0Photons = soa::Join; using MyV0Photon = MyV0Photons::iterator; -using MyTracks = soa::Join; +using MyTracks = soa::Join; using MyTrack = MyTracks::iterator; using FilteredMyTracks = soa::Filtered; using FilteredMyTrack = FilteredMyTracks::iterator; @@ -103,7 +104,7 @@ struct PhotonHBT { Configurable maxY{"maxY", 0.8, "maximum rapidity for reconstructed particles"}; Configurable cfgDoMix{"cfgDoMix", true, "flag for event mixing"}; Configurable ndepth{"ndepth", 100, "depth for event mixing"}; - Configurable ndiff_bc_mix{"ndiff_bc_mix", 5, "difference in global BC required in mixed events"}; + Configurable ndiff_bc_mix{"ndiff_bc_mix", 198, "difference in global BC required in mixed events"}; ConfigurableAxis ConfVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.f, 999.f}, "Mixing bins - centrality"}; ConfigurableAxis ConfEPBins{"ConfEPBins", {16, -M_PI / 2, +M_PI / 2}, "Mixing bins - event plane angle"}; @@ -116,8 +117,8 @@ struct PhotonHBT { ConfigurableAxis ConfQBins{"ConfQBins", {60, 0, +0.3f}, "q bins for output histograms"}; ConfigurableAxis ConfKtBins{"ConfKtBins", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0}, "kT bins for output histograms"}; - ConfigurableAxis ConfM1Bins{"ConfM1Bins", {VARIABLE_WIDTH, 0.0, 0.14, 0.5, 1.1, 2.7, 3.2, 4.0}, "m1 bins for output histograms"}; - ConfigurableAxis ConfM2Bins{"ConfM2Bins", {VARIABLE_WIDTH, 0.0, 0.14, 0.5, 1.1, 2.7, 3.2, 4.0}, "m1 bins for output histograms"}; + ConfigurableAxis ConfM1Bins{"ConfM1Bins", {VARIABLE_WIDTH, 0.0, 0.14, 0.5, 1.1, 2.0, 2.7, 3.2, 4.0}, "m1 bins for output histograms"}; + ConfigurableAxis ConfM2Bins{"ConfM2Bins", {VARIABLE_WIDTH, 0.0, 0.14, 0.5, 1.1, 2.0, 2.7, 3.2, 4.0}, "m2 bins for output histograms"}; EMEventCut fEMEventCut; struct : ConfigurableGroup { @@ -140,6 +141,9 @@ struct PhotonHBT { Configurable cfgRequireNoCollInITSROFStandard{"cfgRequireNoCollInITSROFStandard", false, "require no collision in time range standard"}; Configurable cfgRequireNoCollInITSROFStrict{"cfgRequireNoCollInITSROFStrict", false, "require no collision in time range strict"}; Configurable cfgRequireNoHighMultCollInPrevRof{"cfgRequireNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + Configurable cfgRequireGoodITSLayer3{"cfgRequireGoodITSLayer3", false, "number of inactive chips on ITS layer 3 are below threshold "}; + Configurable cfgRequireGoodITSLayer0123{"cfgRequireGoodITSLayer0123", false, "number of inactive chips on ITS layers 0-3 are below threshold "}; + Configurable cfgRequireGoodITSLayersAll{"cfgRequireGoodITSLayersAll", false, "number of inactive chips on all ITS layers are below threshold "}; } eventcuts; V0PhotonCut fV0PhotonCut; @@ -148,7 +152,6 @@ struct PhotonHBT { Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; - Configurable cfg_require_v0_on_wwire_ib{"cfg_require_v0_on_wwire_ib", false, "flag to select V0s on W wires ITSib"}; Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; Configurable cfg_max_eta_v0{"cfg_max_eta_v0", 0.8, "max eta for v0 photons at PV"}; Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; @@ -162,6 +165,7 @@ struct PhotonHBT { Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 10, "min ncluster tpc"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; @@ -205,18 +209,17 @@ struct PhotonHBT { Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.2, "max dca Z for single track in cm"}; Configurable cfg_min_its_cluster_size{"cfg_min_its_cluster_size", 0.f, "min ITS cluster size"}; Configurable cfg_max_its_cluster_size{"cfg_max_its_cluster_size", 16.f, "max ITS cluster size"}; - Configurable cfg_min_p_its_cluster_size{"cfg_min_p_its_cluster_size", 0.0, "min p to apply ITS cluster size cut"}; - Configurable cfg_max_p_its_cluster_size{"cfg_max_p_its_cluster_size", 0.0, "max p to apply ITS cluster size cut"}; Configurable cfg_min_rel_diff_pin{"cfg_min_rel_diff_pin", -1e+10, "min rel. diff. between pin and ppv"}; Configurable cfg_max_rel_diff_pin{"cfg_max_rel_diff_pin", +1e+10, "max rel. diff. between pin and ppv"}; Configurable cfg_require_itsib_any{"cfg_require_itsib_any", false, "flag to require ITS ib any hits"}; Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; + Configurable cfgRefR{"cfgRefR", 1.2, "reference R (in m) for extrapolation"}; // https://cds.cern.ch/record/1419204 Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3, kTOFif = 4, kPIDML = 5]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; - Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; + // Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; + // Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -3.0, "min. TPC n sigma for pion exclusion"}; Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -3.0, "min. TPC n sigma for kaon exclusion"}; @@ -225,16 +228,19 @@ struct PhotonHBT { Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +3.0, "max. TPC n sigma for proton exclusion"}; Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + Configurable cfg_min_pin_pirejTPC{"cfg_min_pin_pirejTPC", 0.f, "min. pin for pion rejection in TPC"}; Configurable cfg_max_pin_pirejTPC{"cfg_max_pin_pirejTPC", 0.5, "max. pin for pion rejection in TPC"}; - Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; - Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; - Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; - Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; - Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; - Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; + // Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; + // Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; + // Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; + // Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; + // Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; + // Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; // configuration for PID ML Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; @@ -250,17 +256,17 @@ struct PhotonHBT { struct : ConfigurableGroup { std::string prefix = "ggpaircut_group"; - Configurable applydRdZ{"applydRdZ", false, "apply dr-dz cut to avoid track splitting/merging only for kPCMPCM"}; - Configurable cfgMinDeltaR{"cfgMinDeltaR", 20.f, "min. delta-r between 2 conversion points only for kPCMPCM"}; - Configurable cfgMinDeltaZ{"cfgMinDeltaZ", 20.f, "min. delta-z between 2 conversion points only for kPCMPCM"}; + // Configurable applydRdZ{"applydRdZ", false, "apply dr-dz cut to avoid track splitting/merging only for kPCMPCM"}; + // Configurable cfgMinDeltaR{"cfgMinDeltaR", 20.f, "min. delta-r between 2 conversion points only for kPCMPCM"}; + // Configurable cfgMinDeltaZ{"cfgMinDeltaZ", 20.f, "min. delta-z between 2 conversion points only for kPCMPCM"}; Configurable applydEtadPhi_Photon{"applydEtadPhi_Photon", false, "apply deta-dphi cut to avoid track splitting/merging"}; Configurable cfgMinDeltaEta_Photon{"cfgMinDeltaEta_Photon", 0.1f, "min. delta-eta between 2 photons"}; Configurable cfgMinDeltaPhi_Photon{"cfgMinDeltaPhi_Photon", 0.3f, "min. delta-phi between 2 photons"}; - Configurable applydEtadPhi_Leg{"applydEtadPhi_Leg", false, "apply deta-dphi cut to avoid track splitting/merging"}; - Configurable cfgMinDeltaEta_Leg{"cfgMinDeltaEta_Leg", 0.1f, "min. delta-eta between 2 LS tracks"}; - Configurable cfgMinDeltaPhi_Leg{"cfgMinDeltaPhi_Leg", 0.3f, "min. delta-phi between 2 LS tracks"}; + // Configurable applydEtadPhi_Leg{"applydEtadPhi_Leg", false, "apply deta-dphi cut to avoid track splitting/merging"}; + // Configurable cfgMinDeltaEta_Leg{"cfgMinDeltaEta_Leg", 0.1f, "min. delta-eta between 2 LS tracks"}; + // Configurable cfgMinDeltaPhi_Leg{"cfgMinDeltaPhi_Leg", 0.3f, "min. delta-phi between 2 LS tracks"}; } ggpaircuts; ~PhotonHBT() @@ -400,7 +406,7 @@ struct PhotonHBT { if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } mRunNumber = collision.runNumber(); @@ -474,11 +480,11 @@ struct PhotonHBT { } } - fRegistry.add("Pair/same/hDeltaEtaDeltaPhi_Photon", "distance between 2 photons in #eta-#varphi plane;#Delta#varphi (rad.);#Delta#eta", kTH2D, {{180, -M_PI, M_PI}, {200, -1, +1}}, true); // deta, dphi of photon momentum - fRegistry.add("Pair/same/hDeltaEtaDeltaPhi_Leg", "distance between 2 LS tracks in #eta-#varphi plane;#Delta#varphi (rad.);#Delta#eta", kTH2D, {{180, -M_PI, M_PI}, {200, -1, +1}}, true); // deta, dphi of track momentum - if constexpr (pairtype == ggHBTPairType::kPCMPCM) { - fRegistry.add("Pair/same/hDeltaRDeltaZ", "diphoton distance in RZ;#Deltar = #sqrt{(#Deltax)^{2} + (#Deltay)^{2}} (cm);|#Deltaz| (cm)", kTH2D, {{100, 0, 50}, {100, 0, 50}}, true); // dr, dz of conversion points - } + fRegistry.add("Pair/same/hDeltaEtaDeltaPhi_Photon", "distance between 2 photons in #eta-#varphi plane;#Delta#varphi (rad.);#Delta#eta", kTH2D, {{180, -M_PI, M_PI}, {400, -2, +2}}, true); // deta, dphi of photon momentum + // fRegistry.add("Pair/same/hDeltaEtaDeltaPhi_Leg", "distance between 2 LS tracks in #eta-#varphi plane;#Delta#varphi (rad.);#Delta#eta", kTH2D, {{180, -M_PI, M_PI}, {400, -2, +2}}, true); // deta, dphi of track momentum + // if constexpr (pairtype == ggHBTPairType::kPCMPCM) { + // fRegistry.add("Pair/same/hDeltaRDeltaZ", "diphoton distance in RZ;#Deltar = #sqrt{(#Deltax)^{2} + (#Deltay)^{2}} (cm);|#Deltaz| (cm)", kTH2D, {{100, 0, 50}, {100, 0, 50}}, true); // dr, dz of conversion points + // } fRegistry.addClone("Pair/same/", "Pair/mix/"); } @@ -499,6 +505,9 @@ struct PhotonHBT { fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); fEMEventCut.SetRequireNoHighMultCollInPrevRof(eventcuts.cfgRequireNoHighMultCollInPrevRof); + fEMEventCut.SetRequireGoodITSLayer3(eventcuts.cfgRequireGoodITSLayer3); + fEMEventCut.SetRequireGoodITSLayer0123(eventcuts.cfgRequireGoodITSLayer0123); + fEMEventCut.SetRequireGoodITSLayersAll(eventcuts.cfgRequireGoodITSLayersAll); } void DefinePCMCut() @@ -516,8 +525,6 @@ struct PhotonHBT { fV0PhotonCut.RejectITSib(pcmcuts.cfg_reject_v0_on_itsib); // for track - fV0PhotonCut.SetTrackPtRange(pcmcuts.cfg_min_pt_v0 * 0.5, 1e+10f); - fV0PhotonCut.SetTrackEtaRange(-pcmcuts.cfg_max_eta_v0, +pcmcuts.cfg_max_eta_v0); fV0PhotonCut.SetMinNClustersTPC(pcmcuts.cfg_min_ncluster_tpc); fV0PhotonCut.SetMinNCrossedRowsTPC(pcmcuts.cfg_min_ncrossedrows); fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); @@ -526,32 +533,13 @@ struct PhotonHBT { fV0PhotonCut.SetTPCNsigmaElRange(pcmcuts.cfg_min_TPCNsigmaEl, pcmcuts.cfg_max_TPCNsigmaEl); fV0PhotonCut.SetChi2PerClusterITS(-1e+10, pcmcuts.cfg_max_chi2its); fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); - - if (pcmcuts.cfg_reject_v0_on_itsib) { - fV0PhotonCut.SetNClustersITS(2, 4); - } else { - fV0PhotonCut.SetNClustersITS(0, 7); - } + fV0PhotonCut.SetDisableTPConly(pcmcuts.cfg_disable_tpconly_track); + fV0PhotonCut.SetNClustersITS(0, 7); fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); fV0PhotonCut.SetIsWithinBeamPipe(pcmcuts.cfg_require_v0_with_correct_xz); - - if (pcmcuts.cfg_require_v0_with_itstpc) { - fV0PhotonCut.SetRequireITSTPC(true); - fV0PhotonCut.SetRxyRange(4, 40); - } - if (pcmcuts.cfg_require_v0_with_itsonly) { - fV0PhotonCut.SetRequireITSonly(true); - fV0PhotonCut.SetRxyRange(4, 24); - } - if (pcmcuts.cfg_require_v0_with_tpconly) { - fV0PhotonCut.SetRequireTPConly(true); - fV0PhotonCut.SetRxyRange(32, 90); - } - if (pcmcuts.cfg_require_v0_on_wwire_ib) { - fV0PhotonCut.SetOnWwireIB(true); - fV0PhotonCut.SetOnWwireOB(false); - fV0PhotonCut.SetRxyRange(7, 14); - } + fV0PhotonCut.SetRequireITSTPC(pcmcuts.cfg_require_v0_with_itstpc); + fV0PhotonCut.SetRequireITSonly(pcmcuts.cfg_require_v0_with_itsonly); + fV0PhotonCut.SetRequireTPConly(pcmcuts.cfg_require_v0_with_tpconly); } o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; @@ -581,36 +569,37 @@ struct PhotonHBT { fDielectronCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); fDielectronCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); fDielectronCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size, dielectroncuts.cfg_min_p_its_cluster_size, dielectroncuts.cfg_max_p_its_cluster_size); + fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size); fDielectronCut.SetTrackMaxDcaXY(dielectroncuts.cfg_max_dcaxy); fDielectronCut.SetTrackMaxDcaZ(dielectroncuts.cfg_max_dcaz); fDielectronCut.SetChi2TOF(0.0, dielectroncuts.cfg_max_chi2tof); fDielectronCut.SetRelDiffPin(dielectroncuts.cfg_min_rel_diff_pin, dielectroncuts.cfg_max_rel_diff_pin); + fDielectronCut.IncludeITSsa(dielectroncuts.includeITSsa, dielectroncuts.cfg_max_pt_track_ITSsa); // for eID fDielectronCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); fDielectronCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); + // fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); fDielectronCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); fDielectronCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); fDielectronCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); fDielectronCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); - fDielectronCut.SetMaxPinForPionRejectionTPC(dielectroncuts.cfg_max_pin_pirejTPC); - fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); - fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); - fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); - fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); + fDielectronCut.SetPinRangeForPionRejectionTPC(dielectroncuts.cfg_min_pin_pirejTPC, dielectroncuts.cfg_max_pin_pirejTPC); + // fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); + // fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); + // fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); + // fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut static constexpr int nClassesMl = 2; - const std::vector cutDirMl = {o2::cuts_ml::CutSmaller, o2::cuts_ml::CutNot}; - const std::vector labelsClasses = {"Signal", "Background"}; + const std::vector cutDirMl = {o2::cuts_ml::CutNot, o2::cuts_ml::CutSmaller}; + const std::vector labelsClasses = {"Background", "Signal"}; const uint32_t nBinsMl = dielectroncuts.binsMl.value.size() - 1; const std::vector labelsBins(nBinsMl, "bin"); double cutsMlArr[nBinsMl][nClassesMl]; for (uint32_t i = 0; i < nBinsMl; i++) { - cutsMlArr[i][0] = dielectroncuts.cutsMl.value[i]; - cutsMlArr[i][1] = 0.; + cutsMlArr[i][0] = 0.; + cutsMlArr[i][1] = dielectroncuts.cutsMl.value[i]; } o2::framework::LabeledArray cutsMl = {cutsMlArr[0], nBinsMl, nClassesMl, labelsBins, labelsClasses}; @@ -686,7 +675,7 @@ struct PhotonHBT { // LOGF(info, "qabs_lcms = %f, qabs_lcms_tmp = %f", qabs_lcms, qabs_lcms_tmp); if (cfgDo3D) { - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("hs_3d"), fabs(qout_lcms), fabs(qside_lcms), fabs(qlong_lcms), kt, v1.M(), v2.M(), weight); // qosl can be [-inf, +inf] and CF is symmetric for pos and neg qosl. To reduce stat. unc. absolute value is taken here. + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("hs_3d"), std::fabs(qout_lcms), std::fabs(qside_lcms), std::fabs(qlong_lcms), kt, v1.M(), v2.M(), weight); // qosl can be [-inf, +inf] and CF is symmetric for pos and neg qosl. To reduce stat. unc. absolute value is taken here. } else { if (cfgUseLCMS) { fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("hs_1d"), qabs_lcms, kt, v1.M(), v2.M(), weight); @@ -789,24 +778,24 @@ struct PhotonHBT { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); - float dz = g1.vz() - g2.vz(); - float dr = std::sqrt(std::pow(g1.vx() - g2.vx(), 2) + std::pow(g1.vy() - g2.vy(), 2)); - if (ggpaircuts.applydRdZ && std::pow(dz / ggpaircuts.cfgMinDeltaZ, 2) + std::pow(dr / ggpaircuts.cfgMinDeltaR, 2) < 1.f) { - continue; - } - - float deta_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.eta() - pos2.eta() : pos2.eta() - pos1.eta(); - float dphi_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.phi() - pos2.phi() : pos2.phi() - pos1.phi(); - o2::math_utils::bringToPMPi(dphi_pos); - float deta_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.eta() - ele2.eta() : ele2.eta() - ele1.eta(); - float dphi_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.phi() - ele2.phi() : ele2.phi() - ele1.phi(); - o2::math_utils::bringToPMPi(dphi_ele); - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } + // float dz = g1.vz() - g2.vz(); + // float dr = std::sqrt(std::pow(g1.vx() - g2.vx(), 2) + std::pow(g1.vy() - g2.vy(), 2)); + // if (ggpaircuts.applydRdZ && std::pow(dz / ggpaircuts.cfgMinDeltaZ, 2) + std::pow(dr / ggpaircuts.cfgMinDeltaR, 2) < 1.f) { + // continue; + // } + + // float deta_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.eta() - pos2.eta() : pos2.eta() - pos1.eta(); + // float dphi_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.phi() - pos2.phi() : pos2.phi() - pos1.phi(); + // o2::math_utils::bringToPMPi(dphi_pos); + // float deta_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.eta() - ele2.eta() : ele2.eta() - ele1.eta(); + // float dphi_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.phi() - ele2.phi() : ele2.phi() - ele1.phi(); + // o2::math_utils::bringToPMPi(dphi_ele); + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } float deta_photon = v1.Pt() > v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); float dphi_photon = v1.Pt() > v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); @@ -815,9 +804,9 @@ struct PhotonHBT { } fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Photon"), dphi_photon, deta_photon, 1.f); // distance between 2 photons - fRegistry.fill(HIST("Pair/same/hDeltaRDeltaZ"), dr, fabs(dz), 1.f); - fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), pos1.phi() - pos2.phi(), pos1.eta() - pos2.eta(), 1.f); // distance between 2 LS tracks - fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), ele1.phi() - ele2.phi(), ele1.eta() - ele2.eta(), 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/same/hDeltaRDeltaZ"), dr, fabs(dz), 1.f); + // fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), pos1.phi() - pos2.phi(), pos1.eta() - pos2.eta(), 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), ele1.phi() - ele2.phi(), ele1.eta() - ele2.eta(), 1.f); // distance between 2 LS tracks fillPairHistogram<0>(collision, v1, v2, 1.f); ndiphoton++; @@ -861,7 +850,7 @@ struct PhotonHBT { continue; } } - if (!cut1.IsSelectedPair(pos1, ele1, d_bz)) { + if (!cut1.IsSelectedPair(pos1, ele1, d_bz, dielectroncuts.cfgRefR)) { continue; } @@ -889,7 +878,7 @@ struct PhotonHBT { continue; } } - if (!cut2.IsSelectedPair(pos2, ele2, d_bz)) { + if (!cut2.IsSelectedPair(pos2, ele2, d_bz, dielectroncuts.cfgRefR)) { continue; } @@ -912,18 +901,18 @@ struct PhotonHBT { std::pair pair_tmp = std::make_pair(std::make_pair(pos1.trackId(), ele1.trackId()), std::make_pair(pos2.trackId(), ele2.trackId())); if (std::find(used_pairs_per_collision.begin(), used_pairs_per_collision.end(), pair_tmp) == used_pairs_per_collision.end()) { - float deta_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.eta() - pos2.eta() : pos2.eta() - pos1.eta(); - float dphi_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.phi() - pos2.phi() : pos2.phi() - pos1.phi(); - o2::math_utils::bringToPMPi(dphi_pos); - float deta_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.eta() - ele2.eta() : ele2.eta() - ele1.eta(); - float dphi_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.phi() - ele2.phi() : ele2.phi() - ele1.phi(); - o2::math_utils::bringToPMPi(dphi_ele); - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } + // float deta_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.eta() - pos2.eta() : pos2.eta() - pos1.eta(); + // float dphi_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.phi() - pos2.phi() : pos2.phi() - pos1.phi(); + // o2::math_utils::bringToPMPi(dphi_pos); + // float deta_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.eta() - ele2.eta() : ele2.eta() - ele1.eta(); + // float dphi_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.phi() - ele2.phi() : ele2.phi() - ele1.phi(); + // o2::math_utils::bringToPMPi(dphi_ele); + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } float deta_photon = v1_ee.Pt() > v2_ee.Pt() ? v1_ee.Eta() - v2_ee.Eta() : v2_ee.Eta() - v1_ee.Eta(); float dphi_photon = v1_ee.Pt() > v2_ee.Pt() ? v1_ee.Phi() - v2_ee.Phi() : v2_ee.Phi() - v1_ee.Phi(); @@ -932,8 +921,8 @@ struct PhotonHBT { } fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Photon"), dphi_photon, deta_photon, weight1 * weight2); // distance between 2 photons - fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, weight1 * weight2); // distance between 2 LS tracks - fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, weight1 * weight2); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, weight1 * weight2); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, weight1 * weight2); // distance between 2 LS tracks fillPairHistogram<0>(collision, v1_ee, v2_ee, weight1 * weight2); ndiphoton++; used_pairs_per_collision.emplace_back(std::make_pair(pair_tmp.first, pair_tmp.second)); @@ -1007,7 +996,7 @@ struct PhotonHBT { continue; } } - if (!cut2.IsSelectedPair(pos2, ele2, d_bz)) { + if (!cut2.IsSelectedPair(pos2, ele2, d_bz, dielectroncuts.cfgRefR)) { continue; } @@ -1029,18 +1018,18 @@ struct PhotonHBT { ROOT::Math::PtEtaPhiMVector v_ele2(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v2_ee = v_pos2 + v_ele2; - float deta_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.eta() - pos2.eta() : pos2.eta() - pos1.eta(); - float dphi_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.phi() - pos2.phi() : pos2.phi() - pos1.phi(); - o2::math_utils::bringToPMPi(dphi_pos); - float deta_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.eta() - ele2.eta() : ele2.eta() - ele1.eta(); - float dphi_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.phi() - ele2.phi() : ele2.phi() - ele1.phi(); - o2::math_utils::bringToPMPi(dphi_ele); - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } + // float deta_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.eta() - pos2.eta() : pos2.eta() - pos1.eta(); + // float dphi_pos = pos1.sign() * pos1.pt() > pos2.sign() * pos2.pt() ? pos1.phi() - pos2.phi() : pos2.phi() - pos1.phi(); + // o2::math_utils::bringToPMPi(dphi_pos); + // float deta_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.eta() - ele2.eta() : ele2.eta() - ele1.eta(); + // float dphi_ele = ele1.sign() * ele1.pt() > ele2.sign() * ele2.pt() ? ele1.phi() - ele2.phi() : ele2.phi() - ele1.phi(); + // o2::math_utils::bringToPMPi(dphi_ele); + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } float deta_photon = v1_gamma.Pt() > v2_ee.Pt() ? v1_gamma.Eta() - v2_ee.Eta() : v2_ee.Eta() - v1_gamma.Eta(); float dphi_photon = v1_gamma.Pt() > v2_ee.Pt() ? v1_gamma.Phi() - v2_ee.Phi() : v2_ee.Phi() - v1_gamma.Phi(); @@ -1049,8 +1038,8 @@ struct PhotonHBT { } fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Photon"), dphi_photon, deta_photon, weight); // distance between 2 photons - fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, weight); - fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, weight); + // fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, weight); + // fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, weight); fillPairHistogram<0>(collision, v1_gamma, v2_ee, weight); ndiphoton++; @@ -1112,29 +1101,29 @@ struct PhotonHBT { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); - auto pos1 = g1.getPositiveLeg(); - auto ele1 = g1.getNegativeLeg(); - auto pos2 = g2.getPositiveLeg(); - auto ele2 = g2.getNegativeLeg(); - - float dz = g1.vz() - g2.vz(); - float dr = std::sqrt(std::pow(g1.vx() - g2.vx(), 2) + std::pow(g1.vy() - g2.vy(), 2)); - if (ggpaircuts.applydRdZ && std::pow(dz / ggpaircuts.cfgMinDeltaZ, 2) + std::pow(dr / ggpaircuts.cfgMinDeltaR, 2) < 1.f) { - continue; - } - - float deta_pos = pos1.Pt() > pos2.Pt() ? pos1.Eta() - pos2.Eta() : pos2.Eta() - pos1.Eta(); - float dphi_pos = pos1.Pt() > pos2.Pt() ? pos1.Phi() - pos2.Phi() : pos2.Phi() - pos1.Phi(); - o2::math_utils::bringToPMPi(dphi_pos); - float deta_ele = ele1.Pt() < ele2.Pt() ? ele1.Eta() - ele2.Eta() : ele2.Eta() - ele1.Eta(); // flipped - float dphi_ele = ele1.Pt() < ele2.Pt() ? ele1.Phi() - ele2.Phi() : ele2.Phi() - ele1.Phi(); // flipped - o2::math_utils::bringToPMPi(dphi_ele); - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } + // auto pos1 = g1.getPositiveLeg(); + // auto ele1 = g1.getNegativeLeg(); + // auto pos2 = g2.getPositiveLeg(); + // auto ele2 = g2.getNegativeLeg(); + + // float dz = g1.vz() - g2.vz(); + // float dr = std::sqrt(std::pow(g1.vx() - g2.vx(), 2) + std::pow(g1.vy() - g2.vy(), 2)); + // if (ggpaircuts.applydRdZ && std::pow(dz / ggpaircuts.cfgMinDeltaZ, 2) + std::pow(dr / ggpaircuts.cfgMinDeltaR, 2) < 1.f) { + // continue; + // } + + // float deta_pos = pos1.Pt() > pos2.Pt() ? pos1.Eta() - pos2.Eta() : pos2.Eta() - pos1.Eta(); + // float dphi_pos = pos1.Pt() > pos2.Pt() ? pos1.Phi() - pos2.Phi() : pos2.Phi() - pos1.Phi(); + // o2::math_utils::bringToPMPi(dphi_pos); + // float deta_ele = ele1.Pt() < ele2.Pt() ? ele1.Eta() - ele2.Eta() : ele2.Eta() - ele1.Eta(); // flipped + // float dphi_ele = ele1.Pt() < ele2.Pt() ? ele1.Phi() - ele2.Phi() : ele2.Phi() - ele1.Phi(); // flipped + // o2::math_utils::bringToPMPi(dphi_ele); + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } float deta_photon = v1.Pt() > v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); float dphi_photon = v1.Pt() > v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); @@ -1143,9 +1132,9 @@ struct PhotonHBT { } fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Photon"), dphi_photon, deta_photon, 1.f); // distance between 2 photons - fRegistry.fill(HIST("Pair/mix/hDeltaRDeltaZ"), dr, fabs(dz), 1.f); - fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks - fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/mix/hDeltaRDeltaZ"), dr, fabs(dz), 1.f); + // fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks fillPairHistogram<1>(collision, v1, v2, 1.f); } } @@ -1181,10 +1170,10 @@ struct PhotonHBT { bool is_found_neg2 = std::find(v1amb_neg_Ids.begin(), v1amb_neg_Ids.end(), g2.globalIndexPos()) != v1amb_neg_Ids.end(); // LOGF(info, "is_found_pos1 = %d, is_found_neg1 = %d, is_found_pos2 = %d, is_found_neg2 = %d", is_found_pos1, is_found_neg1, is_found_pos2, is_found_neg2); - auto pos1 = g1.getPositiveLeg(); - auto ele1 = g1.getNegativeLeg(); - auto pos2 = g2.getPositiveLeg(); - auto ele2 = g2.getNegativeLeg(); + // auto pos1 = g1.getPositiveLeg(); + // auto ele1 = g1.getNegativeLeg(); + // auto pos2 = g2.getPositiveLeg(); + // auto ele2 = g2.getNegativeLeg(); if ((g1.dfId() == g2.dfId()) && ((is_found_pos1 && is_found_pos2) || (is_found_neg1 && is_found_neg2))) { // LOGF(info, "event id = %d: same track is found. t1.globalIndex() = %d, t1.sign() = %d, t1.pt() = %f, t1.eta() = %f, t1.phi() = %f, t2.globalIndex() = %d, t2.sign() = %d, t2.pt() = %f, t2.eta() = %f, t2.phi() = %f, deta = %f, dphi = %f (rad.)", ev_id, t1.globalIndex(), t1.sign(), t1.pt(), t1.eta(), t1.phi(), t2.globalIndex(), t2.sign(), t2.pt(), t2.eta(), t2.phi(), t1.eta() - t2.eta(), t1.phi() - t2.phi()); @@ -1194,26 +1183,27 @@ struct PhotonHBT { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), g1.mass()); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), g2.mass()); - float deta_pos = pos1.Eta() - pos2.Eta(); - float dphi_pos = pos1.Phi() - pos2.Phi(); - o2::math_utils::bringToPMPi(dphi_pos); - float deta_ele = ele1.Eta() - ele2.Eta(); - float dphi_ele = ele1.Phi() - ele2.Phi(); - o2::math_utils::bringToPMPi(dphi_ele); - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } + // float deta_pos = pos1.Eta() - pos2.Eta(); + // float dphi_pos = pos1.Phi() - pos2.Phi(); + // o2::math_utils::bringToPMPi(dphi_pos); + // float deta_ele = ele1.Eta() - ele2.Eta(); + // float dphi_ele = ele1.Phi() - ele2.Phi(); + // o2::math_utils::bringToPMPi(dphi_ele); + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } + float deta_photon = v1.Pt() > v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); float dphi_photon = v1.Pt() > v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); if (ggpaircuts.applydEtadPhi_Photon && std::pow(deta_photon / ggpaircuts.cfgMinDeltaEta_Photon, 2) + std::pow(dphi_photon / ggpaircuts.cfgMinDeltaPhi_Photon, 2) < 1.f) { continue; } fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Photon"), dphi_photon, deta_photon, 1.f); // distance between 2 photons - fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks - fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks fillPairHistogram<1>(collision, v1, v2, 1.f); } } @@ -1241,23 +1231,23 @@ struct PhotonHBT { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.0); // keep v1 for PCM ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), g2.mass()); - auto pos1 = g1.getPositiveLeg(); - auto ele1 = g1.getNegativeLeg(); - auto pos2 = g2.getPositiveLeg(); - auto ele2 = g2.getNegativeLeg(); - - float deta_pos = pos1.Eta() - pos2.Eta(); - float dphi_pos = pos1.Phi() - pos2.Phi(); - o2::math_utils::bringToPMPi(dphi_pos); - float deta_ele = ele1.Eta() - ele2.Eta(); - float dphi_ele = ele1.Phi() - ele2.Phi(); - o2::math_utils::bringToPMPi(dphi_ele); - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } + // auto pos1 = g1.getPositiveLeg(); + // auto ele1 = g1.getNegativeLeg(); + // auto pos2 = g2.getPositiveLeg(); + // auto ele2 = g2.getNegativeLeg(); + + // float deta_pos = pos1.Eta() - pos2.Eta(); + // float dphi_pos = pos1.Phi() - pos2.Phi(); + // o2::math_utils::bringToPMPi(dphi_pos); + // float deta_ele = ele1.Eta() - ele2.Eta(); + // float dphi_ele = ele1.Phi() - ele2.Phi(); + // o2::math_utils::bringToPMPi(dphi_ele); + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } float deta_photon = v1.Pt() > v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); float dphi_photon = v1.Pt() > v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); @@ -1265,8 +1255,8 @@ struct PhotonHBT { continue; } fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Photon"), dphi_photon, deta_photon, 1.f); // distance between 2 photons - fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks - fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks fillPairHistogram<1>(collision, v1, v2, 1.f); } } @@ -1294,32 +1284,31 @@ struct PhotonHBT { ROOT::Math::PtEtaPhiMVector v1(g2.pt(), g2.eta(), g2.phi(), 0.0); // keep v1 for PCM ROOT::Math::PtEtaPhiMVector v2(g1.pt(), g1.eta(), g1.phi(), g1.mass()); - auto pos1 = g1.getPositiveLeg(); - auto ele1 = g1.getNegativeLeg(); - auto pos2 = g2.getPositiveLeg(); - auto ele2 = g2.getNegativeLeg(); - - float deta_pos = pos1.Eta() - pos2.Eta(); - float dphi_pos = pos1.Phi() - pos2.Phi(); - o2::math_utils::bringToPMPi(dphi_pos); - float deta_ele = ele1.Eta() - ele2.Eta(); - float dphi_ele = ele1.Phi() - ele2.Phi(); - o2::math_utils::bringToPMPi(dphi_ele); - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } - if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { - continue; - } + // auto pos1 = g1.getPositiveLeg(); + // auto ele1 = g1.getNegativeLeg(); + // auto pos2 = g2.getPositiveLeg(); + // auto ele2 = g2.getNegativeLeg(); + + // float deta_pos = pos1.Eta() - pos2.Eta(); + // float dphi_pos = pos1.Phi() - pos2.Phi(); + // o2::math_utils::bringToPMPi(dphi_pos); + // float deta_ele = ele1.Eta() - ele2.Eta(); + // float dphi_ele = ele1.Phi() - ele2.Phi(); + // o2::math_utils::bringToPMPi(dphi_ele); + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } + // if (ggpaircuts.applydEtadPhi_Leg && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta_Leg, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi_Leg, 2) < 1.f) { + // continue; + // } float deta_photon = v1.Pt() > v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); float dphi_photon = v1.Pt() > v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); if (ggpaircuts.applydEtadPhi_Photon && std::pow(deta_photon / ggpaircuts.cfgMinDeltaEta_Photon, 2) + std::pow(dphi_photon / ggpaircuts.cfgMinDeltaPhi_Photon, 2) < 1.f) { continue; } fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Photon"), dphi_photon, deta_photon, 1.f); // distance between 2 photons - - fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks - fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks + // fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi_Leg"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks fillPairHistogram<1>(collision, v1, v2, 1.f); } } @@ -1375,7 +1364,7 @@ struct PhotonHBT { continue; } } - if (!cut.IsSelectedPair(pos, ele, d_bz)) { + if (!cut.IsSelectedPair(pos, ele, d_bz, dielectroncuts.cfgRefR)) { continue; } passed_pairIds.emplace_back(std::make_pair(pos.globalIndex(), ele.globalIndex())); @@ -1425,7 +1414,7 @@ struct PhotonHBT { Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); // Filter collisionFilter_multiplicity = cfgNtracksPV08Min <= o2::aod::mult::multNTracksPV && o2::aod::mult::multNTracksPV < cfgNtracksPV08Max; Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; - Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin < o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; using FilteredMyCollisions = soa::Filtered; int ndf = 0; diff --git a/PWGEM/Dilepton/Core/SingleTrackQC.h b/PWGEM/Dilepton/Core/SingleTrackQC.h index f193081706a..9810d1eb63e 100644 --- a/PWGEM/Dilepton/Core/SingleTrackQC.h +++ b/PWGEM/Dilepton/Core/SingleTrackQC.h @@ -17,31 +17,33 @@ #ifndef PWGEM_DILEPTON_CORE_SINGLETRACKQC_H_ #define PWGEM_DILEPTON_CORE_SINGLETRACKQC_H_ -#include -#include -#include -#include - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Tools/ML/MlResponse.h" - -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/Dilepton/Core/DielectronCut.h" #include "PWGEM/Dilepton/Core/DimuonCut.h" #include "PWGEM/Dilepton/Core/EMEventCut.h" -#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/Dilepton/Utils/EventHistograms.h" #include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" + +#include "Common/CCDB/RCTSelectionFlags.h" +#include "Tools/ML/MlResponse.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" +#include "TString.h" + +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -56,12 +58,12 @@ using MyCollision = MyCollisions::iterator; using MyCollisionsWithSWT = soa::Join; using MyCollisionWithSWT = MyCollisionsWithSWT::iterator; -using MyElectrons = soa::Join; +using MyElectrons = soa::Join; using MyElectron = MyElectrons::iterator; using FilteredMyElectrons = soa::Filtered; using FilteredMyElectron = FilteredMyElectrons::iterator; -using MyMuons = soa::Join; +using MyMuons = soa::Join; using MyMuon = MyMuons::iterator; using FilteredMyMuons = soa::Filtered; using FilteredMyMuon = FilteredMyMuons::iterator; @@ -79,10 +81,11 @@ struct SingleTrackQC { // Configurable cfgNtracksPV08Min{"cfgNtracksPV08Min", -1, "min. multNTracksPV"}; // Configurable cfgNtracksPV08Max{"cfgNtracksPV08Max", static_cast(1e+9), "max. multNTracksPV"}; Configurable cfgApplyWeightTTCA{"cfgApplyWeightTTCA", false, "flag to apply weighting by 1/N"}; - Configurable cfgDCAType{"cfgDCAType", 0, "type of DCA for output. 0:3D, 1:XY, 2:Z, else:3D"}; ConfigurableAxis ConfPtlBins{"ConfPtlBins", {VARIABLE_WIDTH, 0.00, 0.05, 0.10, 0.15, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.50, 3.00, 3.50, 4.00, 4.50, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00}, "pTl bins for output histograms"}; - ConfigurableAxis ConfDCABins{"ConfDCABins", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCA bins for output histograms"}; + ConfigurableAxis ConfDCA3DBins{"ConfDCA3DBins", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCA3d bins in sigma for output histograms"}; + ConfigurableAxis ConfDCAXYBins{"ConfDCAXYBins", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.5, -4.0, -3.5, -3.0, -2.5, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCAxy bins in sigma for output histograms"}; + ConfigurableAxis ConfDCAZBins{"ConfDCAZBins", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.5, -4.0, -3.5, -3.0, -2.5, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCAz bins in sigma for output histograms"}; EMEventCut fEMEventCut; struct : ConfigurableGroup { @@ -94,7 +97,8 @@ struct SingleTrackQC { Configurable cfgRequireNoTFB{"cfgRequireNoTFB", true, "require No time frame border in event cut"}; Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", true, "require no ITS readout frame border in event cut"}; Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; - Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexTOFmatched{"cfgRequireVertexTOFmatched", false, "require Vertex TOFmatched in event cut"}; // ITS-TPC-TOF matched track contributes PV. Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; @@ -105,6 +109,14 @@ struct SingleTrackQC { Configurable cfgRequireNoCollInITSROFStandard{"cfgRequireNoCollInITSROFStandard", false, "require no collision in time range standard"}; Configurable cfgRequireNoCollInITSROFStrict{"cfgRequireNoCollInITSROFStrict", false, "require no collision in time range strict"}; Configurable cfgRequireNoHighMultCollInPrevRof{"cfgRequireNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + Configurable cfgRequireGoodITSLayer3{"cfgRequireGoodITSLayer3", false, "number of inactive chips on ITS layer 3 are below threshold "}; + Configurable cfgRequireGoodITSLayer0123{"cfgRequireGoodITSLayer0123", false, "number of inactive chips on ITS layers 0-3 are below threshold "}; + Configurable cfgRequireGoodITSLayersAll{"cfgRequireGoodITSLayersAll", false, "number of inactive chips on all ITS layers are below threshold "}; + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; } eventcuts; DielectronCut fDielectronCut; @@ -113,10 +125,12 @@ struct SingleTrackQC { Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; - Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "max eta for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "min eta for single track"}; Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.8, "max eta for single track"}; - Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "max phi for single track"}; + Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "min phi for single track"}; Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; + Configurable cfg_mirror_phi_track{"cfg_mirror_phi_track", false, "mirror the phi cut around Pi, min and max phi should be in 0-Pi"}; + Configurable cfg_reject_phi_track{"cfg_reject_phi_track", false, "reject the phi interval"}; Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 100, "min ncrossed rows"}; @@ -130,16 +144,14 @@ struct SingleTrackQC { Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; Configurable cfg_min_its_cluster_size{"cfg_min_its_cluster_size", 0.f, "min ITS cluster size"}; Configurable cfg_max_its_cluster_size{"cfg_max_its_cluster_size", 16.f, "max ITS cluster size"}; - Configurable cfg_min_p_its_cluster_size{"cfg_min_p_its_cluster_size", 0.0, "min p to apply ITS cluster size cut"}; - Configurable cfg_max_p_its_cluster_size{"cfg_max_p_its_cluster_size", 0.0, "max p to apply ITS cluster size cut"}; Configurable cfg_min_rel_diff_pin{"cfg_min_rel_diff_pin", -1e+10, "min rel. diff. between pin and ppv"}; Configurable cfg_max_rel_diff_pin{"cfg_max_rel_diff_pin", +1e+10, "max rel. diff. between pin and ppv"}; Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3, kTOFif = 4, kPIDML = 5]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; - Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; + // Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; + // Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -3.0, "min. TPC n sigma for kaon exclusion"}; @@ -148,16 +160,19 @@ struct SingleTrackQC { Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +3.0, "max. TPC n sigma for proton exclusion"}; Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + Configurable cfg_min_pin_pirejTPC{"cfg_min_pin_pirejTPC", 0.f, "min. pin for pion rejection in TPC"}; Configurable cfg_max_pin_pirejTPC{"cfg_max_pin_pirejTPC", 1e+10, "max. pin for pion rejection in TPC"}; - Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; - Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; - Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; - Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; - Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; - Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; + // Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; + // Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; + // Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; + // Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; + // Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; + // Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; // configuration for PID ML Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; @@ -175,23 +190,30 @@ struct SingleTrackQC { struct : ConfigurableGroup { std::string prefix = "dimuoncut_group"; - Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; - Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.1, "min pT for single track"}; + Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; + Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "min pT for single track"}; Configurable cfg_min_eta_track{"cfg_min_eta_track", -4.0, "min eta for single track"}; Configurable cfg_max_eta_track{"cfg_max_eta_track", -2.5, "max eta for single track"}; Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "max phi for single track"}; Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; Configurable cfg_min_ncluster_mft{"cfg_min_ncluster_mft", 5, "min ncluster MFT"}; Configurable cfg_min_ncluster_mch{"cfg_min_ncluster_mch", 5, "min ncluster MCH"}; - Configurable cfg_max_chi2{"cfg_max_chi2", 1e+10, "max chi2"}; - Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 1e+10, "max chi2 for MFT-MCH matching"}; + Configurable cfg_max_chi2{"cfg_max_chi2", 1e+6, "max chi2"}; + Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 40, "max chi2 for MFT-MCH matching"}; Configurable cfg_max_matching_chi2_mchmid{"cfg_max_matching_chi2_mchmid", 1e+10, "max chi2 for MCH-MID matching"}; Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1e+10, "max dca XY for single track in cm"}; Configurable cfg_min_rabs{"cfg_min_rabs", 17.6, "min Radius at the absorber end"}; Configurable cfg_max_rabs{"cfg_max_rabs", 89.5, "max Radius at the absorber end"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable cfg_max_relDPt_wrt_matchedMCHMID{"cfg_max_relDPt_wrt_matchedMCHMID", 1e+10f, "max. relative dpt between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DEta_wrt_matchedMCHMID{"cfg_max_DEta_wrt_matchedMCHMID", 1e+10f, "max. deta between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DPhi_wrt_matchedMCHMID{"cfg_max_DPhi_wrt_matchedMCHMID", 1e+10f, "max. dphi between MFT-MCH-MID and MCH-MID"}; + Configurable requireMFTHitMap{"requireMFTHitMap", false, "flag to apply MFT hit map"}; + Configurable> requiredMFTDisks{"requiredMFTDisks", std::vector{0}, "hit map on MFT disks [0,1,2,3,4]. logical-OR of each double-sided disk"}; } dimuoncuts; + o2::aod::rctsel::RCTFlagsChecker rctChecker; o2::ccdb::CcdbApi ccdbApi; Service ccdb; @@ -209,43 +231,40 @@ struct SingleTrackQC { const AxisSpec axis_pt{ConfPtlBins, "p_{T,e} (GeV/c)"}; const AxisSpec axis_eta{20, -1.0, +1.0, "#eta_{e}"}; const AxisSpec axis_phi{36, 0.0, 2 * M_PI, "#varphi_{e} (rad.)"}; - std::string dca_axis_title = "DCA_{e}^{3D} (#sigma)"; - if (cfgDCAType == 1) { - dca_axis_title = "DCA_{e}^{XY} (#sigma)"; - } else if (cfgDCAType == 2) { - dca_axis_title = "DCA_{e}^{Z} (#sigma)"; - } - const AxisSpec axis_dca{ConfDCABins, dca_axis_title}; + const AxisSpec axis_dca3D{ConfDCA3DBins, "DCA_{e}^{3D} (#sigma)"}; + const AxisSpec axis_dcaXY{ConfDCAXYBins, "DCA_{e}^{XY} (#sigma)"}; + const AxisSpec axis_dcaZ{ConfDCAZBins, "DCA_{e}^{Z} (#sigma)"}; // track info - fRegistry.add("Track/positive/hs", "rec. single electron", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_dca}, true); - fRegistry.add("Track/positive/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/positive/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); - fRegistry.add("Track/positive/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); - fRegistry.add("Track/positive/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{200, 0, 10}, {200, 0., 400}}, false); - fRegistry.add("Track/positive/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{200, 0, 10}, {200, 0., 400}}, false); - fRegistry.add("Track/positive/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/positive/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/positive/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/positive/hs", "rec. single electron", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_dca3D, axis_dcaXY, axis_dcaZ}, true); + fRegistry.add("Track/positive/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{2000, -5, 5}}, false); + fRegistry.add("Track/positive/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.f, 1.f}}, false); + fRegistry.add("Track/positive/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{400, -20.0f, 20.0f}, {400, -20.0f, 20.0f}}, false); + fRegistry.add("Track/positive/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/positive/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 400}}, false); + fRegistry.add("Track/positive/hDCA3dRes_Pt", "DCA_{3D} resolution vs. pT;p_{T} (GeV/c);DCA_{3D} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/positive/hNclsTPC_Pt", "number of TPC clusters;p_{T,e} (GeV/c);TPC N_{cls}", kTH2F, {axis_pt, {161, -0.5, 160.5}}, false); + fRegistry.add("Track/positive/hNcrTPC_Pt", "number of TPC crossed rows;p_{T,e} (GeV/c);TPC N_{CR}", kTH2F, {axis_pt, {161, -0.5, 160.5}}, false); + fRegistry.add("Track/positive/hChi2TPC", "chi2/number of TPC clusters;TPC #chi^{2}/N_{CR}", kTH1F, {{100, 0, 10}}, false); fRegistry.add("Track/positive/hDeltaPin", "p_{in} vs. p_{pv};p_{pv} (GeV/c);(p_{in} - p_{pv})/p_{pv}", kTH2F, {{1000, 0, 10}, {200, -1, +1}}, false); - fRegistry.add("Track/positive/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/positive/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/positive/hTPCNcr2Nf", "TPC Ncr/Nfindable;TPC N_{CR}/N_{cls}^{findable}", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/positive/hTPCNcls2Nf", "TPC Ncls/Nfindable;TPC N_{cls}/N_{cls}^{findable}", kTH1F, {{200, 0, 2}}, false); fRegistry.add("Track/positive/hTPCNclsShared", "TPC Ncls shared/Ncls;p_{T} (GeV/c);N_{cls}^{shared}/N_{cls} in TPC", kTH2F, {{1000, 0, 10}, {100, 0, 1}}, false); - fRegistry.add("Track/positive/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("Track/positive/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/positive/hNclsITS", "number of ITS clusters;ITS N_{cls}", kTH1F, {{8, -0.5, 7.5}}, false); + fRegistry.add("Track/positive/hChi2ITS", "chi2/number of ITS clusters;ITS #chi^{2}/N_{cls}", kTH1F, {{100, 0, 10}}, false); fRegistry.add("Track/positive/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("Track/positive/hChi2TOF", "TOF Chi2;p_{pv} (GeV/c);chi2", kTH2F, {{1000, 0, 10}, {100, 0, 10}}, false); + fRegistry.add("Track/positive/hChi2TOF", "TOF Chi2;p_{pv} (GeV/c);TOF #chi^{2}", kTH2F, {{1000, 0, 10}, {100, 0, 10}}, false); fRegistry.add("Track/positive/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); fRegistry.add("Track/positive/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/positive/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTOFbeta", "TOF #beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, false); fRegistry.add("Track/positive/hTOFNsigmaEl", "TOF n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hTOFNsigmaMu", "TOF n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/positive/hTOFNsigmaMu", "TOF n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTOFNsigmaPi", "TOF n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTOFNsigmaKa", "TOF n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTOFNsigmaPr", "TOF n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); @@ -253,31 +272,34 @@ struct SingleTrackQC { fRegistry.add("Track/positive/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); on ITS #times cos(#lambda);", kTH2F, {{1000, 0.f, 10.f}, {150, 0, 15}}, false); fRegistry.add("Track/positive/hMeanClusterSizeITSib", "mean cluster size ITS inner barrel;p_{pv} (GeV/c); on ITS #times cos(#lambda);", kTH2F, {{1000, 0.f, 10.f}, {150, 0, 15}}, false); fRegistry.add("Track/positive/hMeanClusterSizeITSob", "mean cluster size ITS outer barrel;p_{pv} (GeV/c); on ITS #times cos(#lambda);", kTH2F, {{1000, 0.f, 10.f}, {150, 0, 15}}, false); - fRegistry.add("Track/positive/hITSNsigmaEl", "ITS n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hITSNsigmaMu", "ITS n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hITSNsigmaPi", "ITS n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hITSNsigmaKa", "ITS n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hITSNsigmaPr", "ITS n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/positive/hITSNsigmaEl", "ITS n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/positive/hITSNsigmaMu", "ITS n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/positive/hITSNsigmaPi", "ITS n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/positive/hITSNsigmaKa", "ITS n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/positive/hITSNsigmaPr", "ITS n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.addClone("Track/positive/", "Track/negative/"); } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { const AxisSpec axis_pt{ConfPtlBins, "p_{T,#mu} (GeV/c)"}; - const AxisSpec axis_eta{25, -4.5, -2.0, "#eta_{#mu}"}; - const AxisSpec axis_phi{36, 0.0, 2 * M_PI, "#varphi_{#mu} (rad.)"}; - const AxisSpec axis_dca{ConfDCABins, "DCA_{#mu}^{XY} (#sigma)"}; + const AxisSpec axis_eta{50, -6, -1, "#eta_{#mu}"}; + const AxisSpec axis_phi{36, 0, 2 * M_PI, "#varphi_{#mu} (rad.)"}; + const AxisSpec axis_dca{ConfDCAXYBins, "DCA_{#mu}^{XY} (#sigma)"}; // track info fRegistry.add("Track/positive/hs", "rec. single muon", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_dca}, true); + fRegistry.add("Track/positive/hEtaPhi_MatchMCHMID", "#eta vs. #varphi of matched MCHMID", kTH2F, {{180, 0, 2.f * M_PI}, {100, -6, -1}}, false); + fRegistry.add("Track/positive/hdEtadPhi", "#Delta#eta vs. #Delta#varphi between MFT-MCH-MID and MCH-MID;#varphi_{sa} - #varphi_{gl} (rad.);#eta_{sa} - #eta_{gl}", kTH2F, {{90, -M_PI / 4, M_PI / 4}, {100, -0.5, +0.5}}, false); fRegistry.add("Track/positive/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); fRegistry.add("Track/positive/hTrackType", "track type", kTH1F, {{6, -0.5f, 5.5}}, false); - fRegistry.add("Track/positive/hDCAxy", "DCA x vs. y;DCA_{x} (cm);DCA_{y} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); + fRegistry.add("Track/positive/hDCAxy", "DCA x vs. y;DCA_{x} (cm);DCA_{y} (cm)", kTH2F, {{200, -0.5f, 0.5f}, {200, -0.5f, 0.5f}}, false); fRegistry.add("Track/positive/hDCAxySigma", "DCA x vs. y;DCA_{x} (#sigma);DCA_{y} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); - fRegistry.add("Track/positive/hDCAxRes_Pt", "DCA_{x} resolution vs. pT;p_{T} (GeV/c);DCA_{x} resolution (#mum)", kTH2F, {{200, 0, 10}, {200, 0., 400}}, false); - fRegistry.add("Track/positive/hDCAyRes_Pt", "DCA_{y} resolution vs. pT;p_{T} (GeV/c);DCA_{y} resolution (#mum)", kTH2F, {{200, 0, 10}, {200, 0., 400}}, false); + fRegistry.add("Track/positive/hDCAxRes_Pt", "DCA_{x} resolution vs. pT;p_{T} (GeV/c);DCA_{x} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0, 500}}, false); + fRegistry.add("Track/positive/hDCAyRes_Pt", "DCA_{y} resolution vs. pT;p_{T} (GeV/c);DCA_{y} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0, 500}}, false); + fRegistry.add("Track/positive/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0, 500}}, false); fRegistry.add("Track/positive/hNclsMCH", "number of MCH clusters", kTH1F, {{21, -0.5, 20.5}}, false); fRegistry.add("Track/positive/hNclsMFT", "number of MFT clusters", kTH1F, {{11, -0.5, 10.5}}, false); - fRegistry.add("Track/positive/hPDCA", "pDCA;p_{T} at PV (GeV/c);p #times DCA (GeV/c #upoint cm)", kTH2F, {{100, 0, 10}, {100, 0.0f, 1000}}, false); - fRegistry.add("Track/positive/hChi2", "chi2;chi2", kTH1F, {{100, 0.0f, 100}}, false); + fRegistry.add("Track/positive/hPDCA", "pDCA;R at absorber end (cm);p #times DCA (GeV/c #upoint cm)", kTH2F, {{100, 0, 100}, {100, 0.0f, 1000}}, false); + fRegistry.add("Track/positive/hChi2", "chi2;chi2/ndf", kTH1F, {{100, 0.0f, 10}}, false); fRegistry.add("Track/positive/hChi2MatchMCHMID", "chi2 match MCH-MID;chi2", kTH1F, {{100, 0.0f, 100}}, false); fRegistry.add("Track/positive/hChi2MatchMCHMFT", "chi2 match MCH-MFT;chi2", kTH1F, {{100, 0.0f, 100}}, false); fRegistry.add("Track/positive/hMFTClusterMap", "MFT cluster map", kTH1F, {{1024, -0.5, 1023.5}}, false); @@ -292,6 +314,7 @@ struct SingleTrackQC { ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); + rctChecker.init(eventcuts.cfgRCTLabel.value, eventcuts.cfgCheckZDC.value, eventcuts.cfgTreatLimitedAcceptanceAsBad.value); DefineEMEventCut(); DefineDielectronCut(); @@ -299,10 +322,21 @@ struct SingleTrackQC { addhistograms(); mRunNumber = 0; - fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter"); + if (doprocessNorm) { + fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter"); + } if (doprocessQC_TriggeredData) { fRegistry.add("Event/hNInspectedTVX", "N inspected TVX;run number;N_{TVX}", kTProfile, {{80000, 520000.5, 600000.5}}, true); } + if (doprocessBC) { + auto hTVXCounter = fRegistry.add("BC/hTVXCounter", "TVX counter", kTH1D, {{6, -0.5f, 5.5f}}); + hTVXCounter->GetXaxis()->SetBinLabel(1, "TVX"); + hTVXCounter->GetXaxis()->SetBinLabel(2, "TVX && NoTFB"); + hTVXCounter->GetXaxis()->SetBinLabel(3, "TVX && NoITSROFB"); + hTVXCounter->GetXaxis()->SetBinLabel(4, "TVX && GoodRCT"); + hTVXCounter->GetXaxis()->SetBinLabel(5, "TVX && NoTFB && NoITSROFB"); + hTVXCounter->GetXaxis()->SetBinLabel(6, "TVX && NoTFB && NoITSROFB && GoodRCT"); + } } template @@ -331,12 +365,16 @@ struct SingleTrackQC { fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); + fEMEventCut.SetRequireVertexTOFmatched(eventcuts.cfgRequireVertexTOFmatched); fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); fEMEventCut.SetRequireNoHighMultCollInPrevRof(eventcuts.cfgRequireNoHighMultCollInPrevRof); + fEMEventCut.SetRequireGoodITSLayer3(eventcuts.cfgRequireGoodITSLayer3); + fEMEventCut.SetRequireGoodITSLayer0123(eventcuts.cfgRequireGoodITSLayer0123); + fEMEventCut.SetRequireGoodITSLayersAll(eventcuts.cfgRequireGoodITSLayersAll); } o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; @@ -347,7 +385,7 @@ struct SingleTrackQC { // for track fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, dielectroncuts.cfg_max_pt_track); fDielectronCut.SetTrackEtaRange(dielectroncuts.cfg_min_eta_track, dielectroncuts.cfg_max_eta_track); - fDielectronCut.SetTrackPhiRange(dielectroncuts.cfg_min_phi_track, dielectroncuts.cfg_max_phi_track); + fDielectronCut.SetTrackPhiRange(dielectroncuts.cfg_min_phi_track, dielectroncuts.cfg_max_phi_track, dielectroncuts.cfg_mirror_phi_track, dielectroncuts.cfg_reject_phi_track); fDielectronCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); fDielectronCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); fDielectronCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); @@ -355,38 +393,39 @@ struct SingleTrackQC { fDielectronCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); fDielectronCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); fDielectronCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size, dielectroncuts.cfg_min_p_its_cluster_size, dielectroncuts.cfg_max_p_its_cluster_size); + fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size); fDielectronCut.SetTrackMaxDcaXY(dielectroncuts.cfg_max_dcaxy); fDielectronCut.SetTrackMaxDcaZ(dielectroncuts.cfg_max_dcaz); fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); fDielectronCut.SetChi2TOF(0.0, dielectroncuts.cfg_max_chi2tof); fDielectronCut.SetRelDiffPin(dielectroncuts.cfg_min_rel_diff_pin, dielectroncuts.cfg_max_rel_diff_pin); + fDielectronCut.IncludeITSsa(dielectroncuts.includeITSsa, dielectroncuts.cfg_max_pt_track_ITSsa); // for eID fDielectronCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); fDielectronCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); + // fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); fDielectronCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); fDielectronCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); fDielectronCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); fDielectronCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); - fDielectronCut.SetMaxPinForPionRejectionTPC(dielectroncuts.cfg_max_pin_pirejTPC); - fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); - fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); - fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); - fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); + fDielectronCut.SetPinRangeForPionRejectionTPC(dielectroncuts.cfg_min_pin_pirejTPC, dielectroncuts.cfg_max_pin_pirejTPC); + // fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); + // fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); + // fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); + // fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut static constexpr int nClassesMl = 2; - const std::vector cutDirMl = {o2::cuts_ml::CutSmaller, o2::cuts_ml::CutNot}; - const std::vector labelsClasses = {"Signal", "Background"}; + const std::vector cutDirMl = {o2::cuts_ml::CutNot, o2::cuts_ml::CutSmaller}; + const std::vector labelsClasses = {"Background", "Signal"}; const uint32_t nBinsMl = dielectroncuts.binsMl.value.size() - 1; const std::vector labelsBins(nBinsMl, "bin"); double cutsMlArr[nBinsMl][nClassesMl]; for (uint32_t i = 0; i < nBinsMl; i++) { - cutsMlArr[i][0] = dielectroncuts.cutsMl.value[i]; - cutsMlArr[i][1] = 0.; + cutsMlArr[i][0] = 0.; + cutsMlArr[i][1] = dielectroncuts.cutsMl.value[i]; } o2::framework::LabeledArray cutsMl = {cutsMlArr[0], nBinsMl, nClassesMl, labelsBins, labelsClasses}; @@ -411,17 +450,19 @@ struct SingleTrackQC { // for track fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); - fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, 1e10f); + fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, dimuoncuts.cfg_max_pt_track); fDimuonCut.SetTrackEtaRange(dimuoncuts.cfg_min_eta_track, dimuoncuts.cfg_max_eta_track); fDimuonCut.SetTrackPhiRange(dimuoncuts.cfg_min_phi_track, dimuoncuts.cfg_max_phi_track); fDimuonCut.SetNClustersMFT(dimuoncuts.cfg_min_ncluster_mft, 10); - fDimuonCut.SetNClustersMCHMID(dimuoncuts.cfg_min_ncluster_mch, 16); + fDimuonCut.SetNClustersMCHMID(dimuoncuts.cfg_min_ncluster_mch, 20); fDimuonCut.SetChi2(0.f, dimuoncuts.cfg_max_chi2); fDimuonCut.SetMatchingChi2MCHMFT(0.f, dimuoncuts.cfg_max_matching_chi2_mftmch); fDimuonCut.SetMatchingChi2MCHMID(0.f, dimuoncuts.cfg_max_matching_chi2_mchmid); fDimuonCut.SetDCAxy(0.f, dimuoncuts.cfg_max_dcaxy); fDimuonCut.SetRabs(dimuoncuts.cfg_min_rabs, dimuoncuts.cfg_max_rabs); fDimuonCut.SetMaxPDCARabsDep([&](float rabs) { return (rabs < 26.5 ? 594.f : 324.f); }); + fDimuonCut.SetMaxdPtdEtadPhiwrtMCHMID(dimuoncuts.cfg_max_relDPt_wrt_matchedMCHMID, dimuoncuts.cfg_max_DEta_wrt_matchedMCHMID, dimuoncuts.cfg_max_DPhi_wrt_matchedMCHMID); // this is relevant for global muons + fDimuonCut.SetMFTHitMap(dimuoncuts.requireMFTHitMap, dimuoncuts.requiredMFTDisks); } template @@ -432,23 +473,21 @@ struct SingleTrackQC { weight = map_weight[track.globalIndex()]; } - float dca = dca3DinSigma(track); - if (cfgDCAType == 1) { - dca = dcaXYinSigma(track); - } else if (cfgDCAType == 2) { - dca = dcaZinSigma(track); - } + float dca3D = dca3DinSigma(track); + float dcaXY = dcaXYinSigma(track); + float dcaZ = dcaZinSigma(track); if (track.sign() > 0) { - fRegistry.fill(HIST("Track/positive/hs"), track.pt(), track.eta(), track.phi(), dca, weight); + fRegistry.fill(HIST("Track/positive/hs"), track.pt(), track.eta(), track.phi(), dca3D, dcaXY, dcaZ, weight); fRegistry.fill(HIST("Track/positive/hQoverPt"), track.sign() / track.pt()); fRegistry.fill(HIST("Track/positive/hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/positive/hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); - fRegistry.fill(HIST("Track/positive/hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/positive/hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/positive/hDCAxyzSigma"), dcaXY, dcaZ); + fRegistry.fill(HIST("Track/positive/hDCAxyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/positive/hDCAzRes_Pt"), track.pt(), std::sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/positive/hDCA3dRes_Pt"), track.pt(), sigmaDca3D(track) * 1e+4); // convert cm to um fRegistry.fill(HIST("Track/positive/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/positive/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/positive/hNcrTPC"), track.tpcNClsCrossedRows()); + fRegistry.fill(HIST("Track/positive/hNclsTPC_Pt"), track.pt(), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/positive/hNcrTPC_Pt"), track.pt(), track.tpcNClsCrossedRows()); fRegistry.fill(HIST("Track/positive/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); fRegistry.fill(HIST("Track/positive/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); fRegistry.fill(HIST("Track/positive/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); @@ -464,30 +503,31 @@ struct SingleTrackQC { fRegistry.fill(HIST("Track/positive/hMeanClusterSizeITSib"), track.p(), track.meanClusterSizeITSib() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/positive/hMeanClusterSizeITSob"), track.p(), track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/positive/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/positive/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); + // fRegistry.fill(HIST("Track/positive/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); fRegistry.fill(HIST("Track/positive/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); fRegistry.fill(HIST("Track/positive/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); fRegistry.fill(HIST("Track/positive/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); fRegistry.fill(HIST("Track/positive/hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/positive/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); + // fRegistry.fill(HIST("Track/positive/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); fRegistry.fill(HIST("Track/positive/hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); fRegistry.fill(HIST("Track/positive/hTOFNsigmaKa"), track.p(), track.tofNSigmaKa()); fRegistry.fill(HIST("Track/positive/hTOFNsigmaPr"), track.p(), track.tofNSigmaPr()); - fRegistry.fill(HIST("Track/positive/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); - fRegistry.fill(HIST("Track/positive/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); - fRegistry.fill(HIST("Track/positive/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); - fRegistry.fill(HIST("Track/positive/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); - fRegistry.fill(HIST("Track/positive/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); + // fRegistry.fill(HIST("Track/positive/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); + // fRegistry.fill(HIST("Track/positive/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); + // fRegistry.fill(HIST("Track/positive/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); + // fRegistry.fill(HIST("Track/positive/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); + // fRegistry.fill(HIST("Track/positive/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); } else { - fRegistry.fill(HIST("Track/negative/hs"), track.pt(), track.eta(), track.phi(), dca, weight); + fRegistry.fill(HIST("Track/negative/hs"), track.pt(), track.eta(), track.phi(), dca3D, dcaXY, dcaZ, weight); fRegistry.fill(HIST("Track/negative/hQoverPt"), track.sign() / track.pt()); fRegistry.fill(HIST("Track/negative/hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/negative/hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); - fRegistry.fill(HIST("Track/negative/hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/negative/hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/negative/hDCAxyzSigma"), dcaXY, dcaZ); + fRegistry.fill(HIST("Track/negative/hDCAxyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/negative/hDCAzRes_Pt"), track.pt(), std::sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/negative/hDCA3dRes_Pt"), track.pt(), sigmaDca3D(track) * 1e+4); // convert cm to um fRegistry.fill(HIST("Track/negative/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/negative/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/negative/hNcrTPC"), track.tpcNClsCrossedRows()); + fRegistry.fill(HIST("Track/negative/hNclsTPC_Pt"), track.pt(), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/negative/hNcrTPC_Pt"), track.pt(), track.tpcNClsCrossedRows()); fRegistry.fill(HIST("Track/negative/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); fRegistry.fill(HIST("Track/negative/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); fRegistry.fill(HIST("Track/negative/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); @@ -503,20 +543,20 @@ struct SingleTrackQC { fRegistry.fill(HIST("Track/negative/hMeanClusterSizeITSib"), track.p(), track.meanClusterSizeITSib() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/negative/hMeanClusterSizeITSob"), track.p(), track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/negative/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/negative/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); + // fRegistry.fill(HIST("Track/negative/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); fRegistry.fill(HIST("Track/negative/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); fRegistry.fill(HIST("Track/negative/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); fRegistry.fill(HIST("Track/negative/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); fRegistry.fill(HIST("Track/negative/hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/negative/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); + // fRegistry.fill(HIST("Track/negative/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); fRegistry.fill(HIST("Track/negative/hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); fRegistry.fill(HIST("Track/negative/hTOFNsigmaKa"), track.p(), track.tofNSigmaKa()); fRegistry.fill(HIST("Track/negative/hTOFNsigmaPr"), track.p(), track.tofNSigmaPr()); - fRegistry.fill(HIST("Track/negative/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); - fRegistry.fill(HIST("Track/negative/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); - fRegistry.fill(HIST("Track/negative/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); - fRegistry.fill(HIST("Track/negative/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); - fRegistry.fill(HIST("Track/negative/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); + // fRegistry.fill(HIST("Track/negative/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); + // fRegistry.fill(HIST("Track/negative/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); + // fRegistry.fill(HIST("Track/negative/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); + // fRegistry.fill(HIST("Track/negative/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); + // fRegistry.fill(HIST("Track/negative/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); } } @@ -528,33 +568,44 @@ struct SingleTrackQC { weight = map_weight[track.globalIndex()]; } float dca_xy = fwdDcaXYinSigma(track); + + float deta = track.etaMatchedMCHMID() - track.eta(); + float dphi = track.phiMatchedMCHMID() - track.phi(); + o2::math_utils::bringToPMPi(dphi); + if (track.sign() > 0) { fRegistry.fill(HIST("Track/positive/hs"), track.pt(), track.eta(), track.phi(), dca_xy, weight); + fRegistry.fill(HIST("Track/positive/hEtaPhi_MatchMCHMID"), track.phiMatchedMCHMID(), track.etaMatchedMCHMID(), weight); + fRegistry.fill(HIST("Track/positive/hdEtadPhi"), dphi, deta, weight); fRegistry.fill(HIST("Track/positive/hQoverPt"), track.sign() / track.pt()); fRegistry.fill(HIST("Track/positive/hTrackType"), track.trackType()); fRegistry.fill(HIST("Track/positive/hDCAxy"), track.fwdDcaX(), track.fwdDcaY()); - fRegistry.fill(HIST("Track/positive/hDCAxySigma"), track.fwdDcaX() / std::sqrt(track.cXX()), track.fwdDcaY() / std::sqrt(track.cYY())); - fRegistry.fill(HIST("Track/positive/hDCAxRes_Pt"), track.pt(), std::sqrt(track.cXX()) * 1e+4); - fRegistry.fill(HIST("Track/positive/hDCAyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); + fRegistry.fill(HIST("Track/positive/hDCAxySigma"), track.fwdDcaX() / std::sqrt(track.cXXatDCA()), track.fwdDcaY() / std::sqrt(track.cYYatDCA())); + fRegistry.fill(HIST("Track/positive/hDCAxRes_Pt"), track.pt(), std::sqrt(track.cXXatDCA()) * 1e+4); + fRegistry.fill(HIST("Track/positive/hDCAyRes_Pt"), track.pt(), std::sqrt(track.cYYatDCA()) * 1e+4); + fRegistry.fill(HIST("Track/positive/hDCAxyRes_Pt"), track.pt(), sigmaFwdDcaXY(track) * 1e+4); fRegistry.fill(HIST("Track/positive/hNclsMCH"), track.nClusters()); fRegistry.fill(HIST("Track/positive/hNclsMFT"), track.nClustersMFT()); - fRegistry.fill(HIST("Track/positive/hPDCA"), track.pt(), track.pDca()); - fRegistry.fill(HIST("Track/positive/hChi2"), track.chi2()); + fRegistry.fill(HIST("Track/positive/hPDCA"), track.rAtAbsorberEnd(), track.pDca()); + fRegistry.fill(HIST("Track/positive/hChi2"), track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) ? track.chi2() / (2.f * (track.nClusters() + track.nClustersMFT()) - 5.f) : track.chi2()); fRegistry.fill(HIST("Track/positive/hChi2MatchMCHMID"), track.chi2MatchMCHMID()); fRegistry.fill(HIST("Track/positive/hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); fRegistry.fill(HIST("Track/positive/hMFTClusterMap"), track.mftClusterMap()); } else { fRegistry.fill(HIST("Track/negative/hs"), track.pt(), track.eta(), track.phi(), dca_xy, weight); + fRegistry.fill(HIST("Track/negative/hEtaPhi_MatchMCHMID"), track.phiMatchedMCHMID(), track.etaMatchedMCHMID(), weight); + fRegistry.fill(HIST("Track/negative/hdEtadPhi"), dphi, deta, weight); fRegistry.fill(HIST("Track/negative/hQoverPt"), track.sign() / track.pt()); fRegistry.fill(HIST("Track/negative/hTrackType"), track.trackType()); fRegistry.fill(HIST("Track/negative/hDCAxy"), track.fwdDcaX(), track.fwdDcaY()); - fRegistry.fill(HIST("Track/negative/hDCAxySigma"), track.fwdDcaX() / std::sqrt(track.cXX()), track.fwdDcaY() / std::sqrt(track.cYY())); - fRegistry.fill(HIST("Track/negative/hDCAxRes_Pt"), track.pt(), std::sqrt(track.cXX()) * 1e+4); - fRegistry.fill(HIST("Track/negative/hDCAyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); + fRegistry.fill(HIST("Track/negative/hDCAxySigma"), track.fwdDcaX() / std::sqrt(track.cXXatDCA()), track.fwdDcaY() / std::sqrt(track.cYYatDCA())); + fRegistry.fill(HIST("Track/negative/hDCAxRes_Pt"), track.pt(), std::sqrt(track.cXXatDCA()) * 1e+4); + fRegistry.fill(HIST("Track/negative/hDCAyRes_Pt"), track.pt(), std::sqrt(track.cYYatDCA()) * 1e+4); + fRegistry.fill(HIST("Track/negative/hDCAxyRes_Pt"), track.pt(), sigmaFwdDcaXY(track) * 1e+4); fRegistry.fill(HIST("Track/negative/hNclsMCH"), track.nClusters()); fRegistry.fill(HIST("Track/negative/hNclsMFT"), track.nClustersMFT()); - fRegistry.fill(HIST("Track/negative/hPDCA"), track.pt(), track.pDca()); - fRegistry.fill(HIST("Track/negative/hChi2"), track.chi2()); + fRegistry.fill(HIST("Track/negative/hPDCA"), track.rAtAbsorberEnd(), track.pDca()); + fRegistry.fill(HIST("Track/negative/hChi2"), track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) ? track.chi2() / (2.f * (track.nClusters() + track.nClustersMFT()) - 5.f) : track.chi2()); fRegistry.fill(HIST("Track/negative/hChi2MatchMCHMID"), track.chi2MatchMCHMID()); fRegistry.fill(HIST("Track/negative/hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); fRegistry.fill(HIST("Track/negative/hMFTClusterMap"), track.mftClusterMap()); @@ -564,7 +615,7 @@ struct SingleTrackQC { template void runQC(TCollisions const& collisions, TTracks const& tracks, TPreslice const& perCollision, TCut const& cut) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { initCCDB(collision); float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { @@ -580,6 +631,9 @@ struct SingleTrackQC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1, -1>(&fRegistry, collision); fRegistry.fill(HIST("Event/before/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted fRegistry.fill(HIST("Event/after/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted @@ -587,7 +641,7 @@ struct SingleTrackQC { auto tracks_per_coll = tracks.sliceBy(perCollision, collision.globalIndex()); if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - for (auto& track : tracks_per_coll) { + for (const auto& track : tracks_per_coll) { if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { if (!cut.template IsSelectedTrack(track, collision)) { continue; @@ -600,10 +654,14 @@ struct SingleTrackQC { fillElectronInfo(track); } // end of track loop } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - for (auto& track : tracks_per_coll) { - if (!cut.template IsSelectedTrack(track)) { + for (const auto& track : tracks_per_coll) { + if (!cut.template IsSelectedTrack(track)) { continue; } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(track, cut, tracks)) { + continue; + } + fillMuonInfo(track); } // end of track loop } @@ -616,7 +674,7 @@ struct SingleTrackQC { { std::vector passed_trackIds; passed_trackIds.reserve(tracks.size()); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { initCCDB(collision); float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { @@ -631,11 +689,14 @@ struct SingleTrackQC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } auto tracks_per_coll = tracks.sliceBy(perCollision, collision.globalIndex()); if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - for (auto& track : tracks_per_coll) { + for (const auto& track : tracks_per_coll) { if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { if (!cut.template IsSelectedTrack(track, collision)) { continue; @@ -648,8 +709,11 @@ struct SingleTrackQC { passed_trackIds.emplace_back(track.globalIndex()); } // end of track loop } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - for (auto& track : tracks_per_coll) { - if (!cut.template IsSelectedTrack(track)) { + for (const auto& track : tracks_per_coll) { + if (!cut.template IsSelectedTrack(track)) { + continue; + } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(track, cut, tracks)) { continue; } passed_trackIds.emplace_back(track.globalIndex()); @@ -658,11 +722,11 @@ struct SingleTrackQC { } // end of collision loop if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - for (auto& trackId : passed_trackIds) { + for (const auto& trackId : passed_trackIds) { auto track = tracks.rawIteratorAt(trackId); auto ambIds = track.ambiguousElectronsIds(); float n = 1.f; // include myself. - for (auto& ambId : ambIds) { + for (const auto& ambId : ambIds) { if (std::find(passed_trackIds.begin(), passed_trackIds.end(), ambId) != passed_trackIds.end()) { n += 1.f; } @@ -670,11 +734,11 @@ struct SingleTrackQC { map_weight[trackId] = 1.f / n; } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - for (auto& trackId : passed_trackIds) { + for (const auto& trackId : passed_trackIds) { auto track = tracks.rawIteratorAt(trackId); auto ambIds = track.ambiguousMuonsIds(); float n = 1.f; // include myself. - for (auto& ambId : ambIds) { + for (const auto& ambId : ambIds) { if (std::find(passed_trackIds.begin(), passed_trackIds.end(), ambId) != passed_trackIds.end()) { n += 1.f; } @@ -689,18 +753,18 @@ struct SingleTrackQC { SliceCache cache; Preslice perCollision_electron = aod::emprimaryelectron::emeventId; - Filter trackFilter_electron = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && dielectroncuts.cfg_min_eta_track < o2::aod::track::eta && o2::aod::track::eta < dielectroncuts.cfg_max_eta_track && dielectroncuts.cfg_min_phi_track < o2::aod::track::phi && o2::aod::track::phi < dielectroncuts.cfg_max_phi_track && o2::aod::track::tpcChi2NCl < dielectroncuts.cfg_max_chi2tpc && o2::aod::track::itsChi2NCl < dielectroncuts.cfg_max_chi2its && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz; - Filter pidFilter_electron = (dielectroncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dielectroncuts.cfg_max_TPCNsigmaEl) && (o2::aod::pidtpc::tpcNSigmaPi < dielectroncuts.cfg_min_TPCNsigmaPi || dielectroncuts.cfg_max_TPCNsigmaPi < o2::aod::pidtpc::tpcNSigmaPi); + Filter trackFilter_electron = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && dielectroncuts.cfg_min_eta_track < o2::aod::track::eta && o2::aod::track::eta < dielectroncuts.cfg_max_eta_track && o2::aod::track::tpcChi2NCl < dielectroncuts.cfg_max_chi2tpc && o2::aod::track::itsChi2NCl < dielectroncuts.cfg_max_chi2its && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz; + Filter pidFilter_electron = dielectroncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dielectroncuts.cfg_max_TPCNsigmaEl; Filter ttcaFilter_electron = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); Preslice perCollision_muon = aod::emprimarymuon::emeventId; - Filter trackFilter_muon = o2::aod::fwdtrack::trackType == dimuoncuts.cfg_track_type && dimuoncuts.cfg_min_pt_track < o2::aod::fwdtrack::pt && dimuoncuts.cfg_min_eta_track < o2::aod::fwdtrack::eta && o2::aod::fwdtrack::eta < dimuoncuts.cfg_max_eta_track && dimuoncuts.cfg_min_phi_track < o2::aod::fwdtrack::phi && o2::aod::fwdtrack::phi < dimuoncuts.cfg_max_phi_track; + Filter trackFilter_muon = o2::aod::fwdtrack::trackType == dimuoncuts.cfg_track_type && dimuoncuts.cfg_min_pt_track < o2::aod::fwdtrack::pt && o2::aod::fwdtrack::pt < dimuoncuts.cfg_max_pt_track && dimuoncuts.cfg_min_eta_track < o2::aod::fwdtrack::eta && o2::aod::fwdtrack::eta < dimuoncuts.cfg_max_eta_track && dimuoncuts.cfg_min_phi_track < o2::aod::fwdtrack::phi && o2::aod::fwdtrack::phi < dimuoncuts.cfg_max_phi_track; Filter ttcaFilter_muon = ifnode(dimuoncuts.enableTTCA.node(), o2::aod::emprimarymuon::isAssociatedToMPC == true || o2::aod::emprimarymuon::isAssociatedToMPC == false, o2::aod::emprimarymuon::isAssociatedToMPC == true); Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); // Filter collisionFilter_multiplicity = cfgNtracksPV08Min <= o2::aod::mult::multNTracksPV && o2::aod::mult::multNTracksPV < cfgNtracksPV08Max; Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; - Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin < o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; using FilteredMyCollisions = soa::Filtered; void processQC(FilteredMyCollisions const& collisions, Types const&... args) @@ -746,7 +810,7 @@ struct SingleTrackQC { void processNorm(aod::EMEventNormInfos const& collisions) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 1.0); if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 2.0); @@ -775,20 +839,70 @@ struct SingleTrackQC { if (collision.sel8()) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 10.0); } - if (abs(collision.posZ()) < 10.0) { + if (std::fabs(collision.posZ()) < 10.0) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 11.0); } if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 12.0); } + if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 13.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 14.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 15.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 16.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 17.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 18.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 19.0); + } if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } fRegistry.fill(HIST("Event/norm/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted } // end of collision loop } PROCESS_SWITCH(SingleTrackQC, processNorm, "process normalization info", false); + void processBC(aod::EMBCs const& bcs) + { + for (const auto& bc : bcs) { + if (bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 0.f); + + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 1.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 2.f); + } + if (rctChecker(bc)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 3.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 4.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) && rctChecker(bc)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 5.f); + } + } + } + } + PROCESS_SWITCH(SingleTrackQC, processBC, "process BC counter", false); + void processDummy(MyCollisions const&) {} PROCESS_SWITCH(SingleTrackQC, processDummy, "Dummy function", false); }; diff --git a/PWGEM/Dilepton/Core/SingleTrackQCMC.h b/PWGEM/Dilepton/Core/SingleTrackQCMC.h index f202be5b916..c6b4ad94bb9 100644 --- a/PWGEM/Dilepton/Core/SingleTrackQCMC.h +++ b/PWGEM/Dilepton/Core/SingleTrackQCMC.h @@ -17,32 +17,34 @@ #ifndef PWGEM_DILEPTON_CORE_SINGLETRACKQCMC_H_ #define PWGEM_DILEPTON_CORE_SINGLETRACKQCMC_H_ -#include -#include -#include -#include - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Tools/ML/MlResponse.h" - -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/Dilepton/Core/DielectronCut.h" #include "PWGEM/Dilepton/Core/DimuonCut.h" #include "PWGEM/Dilepton/Core/EMEventCut.h" -#include "PWGEM/Dilepton/Utils/MCUtilities.h" -#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/Utils/MCUtilities.h" #include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" + +#include "Common/CCDB/RCTSelectionFlags.h" +#include "Tools/ML/MlResponse.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" +#include "TString.h" + +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -58,11 +60,11 @@ using MyCollision = MyCollisions::iterator; using MyMCCollisions = soa::Join; using MyMCCollision = MyMCCollisions::iterator; -using MyMCElectrons = soa::Join; +using MyMCElectrons = soa::Join; using MyMCElectron = MyMCElectrons::iterator; using FilteredMyMCElectrons = soa::Filtered; -using MyMCMuons = soa::Join; +using MyMCMuons = soa::Join; using MyMCMuon = MyMCMuons::iterator; using FilteredMyMCMuons = soa::Filtered; @@ -86,22 +88,25 @@ struct SingleTrackQCMC { // Configurable cfgNtracksPV08Max{"cfgNtracksPV08Max", static_cast(1e+9), "max. multNTracksPV"}; Configurable cfgFillQA{"cfgFillQA", false, "flag to fill QA histograms"}; Configurable cfgApplyWeightTTCA{"cfgApplyWeightTTCA", false, "flag to apply weighting by 1/N"}; - Configurable cfgDCAType{"cfgDCAType", 0, "type of DCA for output. 0:3D, 1:XY, 2:Z, else:3D"}; + Configurable cfgRequireTrueAssociation{"cfgRequireTrueAssociation", false, "flag to require true mc collision association"}; ConfigurableAxis ConfPtlBins{"ConfPtlBins", {VARIABLE_WIDTH, 0.00, 0.05, 0.10, 0.15, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.50, 3.00, 3.50, 4.00, 4.50, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00}, "pTl bins for output histograms"}; - ConfigurableAxis ConfDCABins{"ConfDCABins", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCA bins for output histograms"}; + ConfigurableAxis ConfDCA3DBins{"ConfDCA3DBins", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCA3d bins in sigma for output histograms"}; + ConfigurableAxis ConfDCAXYBins{"ConfDCAXYBins", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.5, -4.0, -3.5, -3.0, -2.5, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCAxy bins in sigma for output histograms"}; + ConfigurableAxis ConfDCAZBins{"ConfDCAZBins", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.5, -4.0, -3.5, -3.0, -2.5, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "DCAz bins in sigma for output histograms"}; EMEventCut fEMEventCut; struct : ConfigurableGroup { std::string prefix = "eventcut_group"; Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; Configurable cfgZvtxMax{"cfgZvtxMax", +10.f, "max. Zvtx"}; - Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; + Configurable cfgRequireSel8{"cfgRequireSel8", false, "require sel8 in event cut"}; Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; - Configurable cfgRequireNoTFB{"cfgRequireNoTFB", true, "require No time frame border in event cut"}; - Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", true, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; - Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexTOFmatched{"cfgRequireVertexTOFmatched", false, "require Vertex TOFmatched in event cut"}; // ITS-TPC-TOF matched track contributes PV. Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; @@ -112,6 +117,14 @@ struct SingleTrackQCMC { Configurable cfgRequireNoCollInITSROFStandard{"cfgRequireNoCollInITSROFStandard", false, "require no collision in time range standard"}; Configurable cfgRequireNoCollInITSROFStrict{"cfgRequireNoCollInITSROFStrict", false, "require no collision in time range strict"}; Configurable cfgRequireNoHighMultCollInPrevRof{"cfgRequireNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + Configurable cfgRequireGoodITSLayer3{"cfgRequireGoodITSLayer3", false, "number of inactive chips on ITS layer 3 are below threshold "}; + Configurable cfgRequireGoodITSLayer0123{"cfgRequireGoodITSLayer0123", false, "number of inactive chips on ITS layers 0-3 are below threshold "}; + Configurable cfgRequireGoodITSLayersAll{"cfgRequireGoodITSLayersAll", false, "number of inactive chips on all ITS layers are below threshold "}; + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; } eventcuts; DielectronCut fDielectronCut; @@ -119,10 +132,12 @@ struct SingleTrackQCMC { std::string prefix = "dielectroncut_group"; Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; - Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "max eta for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "min eta for single track"}; Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.8, "max eta for single track"}; - Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "max phi for single track"}; + Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "min phi for single track"}; Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; + Configurable cfg_mirror_phi_track{"cfg_mirror_phi_track", false, "mirror the phi cut around Pi, min and max Phi should be in 0-Pi"}; + Configurable cfg_reject_phi_track{"cfg_reject_phi_track", false, "reject the phi interval"}; Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 100, "min ncrossed rows"}; @@ -136,16 +151,14 @@ struct SingleTrackQCMC { Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; Configurable cfg_min_its_cluster_size{"cfg_min_its_cluster_size", 0.f, "min ITS cluster size"}; Configurable cfg_max_its_cluster_size{"cfg_max_its_cluster_size", 16.f, "max ITS cluster size"}; - Configurable cfg_min_p_its_cluster_size{"cfg_min_p_its_cluster_size", 0.0, "min p to apply ITS cluster size cut"}; - Configurable cfg_max_p_its_cluster_size{"cfg_max_p_its_cluster_size", 0.0, "max p to apply ITS cluster size cut"}; Configurable cfg_min_rel_diff_pin{"cfg_min_rel_diff_pin", -1e+10, "min rel. diff. between pin and ppv"}; Configurable cfg_max_rel_diff_pin{"cfg_max_rel_diff_pin", +1e+10, "max rel. diff. between pin and ppv"}; Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3, kTOFif = 4, kPIDML = 5]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; - Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; + // Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; + // Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -3.0, "min. TPC n sigma for kaon exclusion"}; @@ -154,16 +167,19 @@ struct SingleTrackQCMC { Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +3.0, "max. TPC n sigma for proton exclusion"}; Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + Configurable cfg_min_pin_pirejTPC{"cfg_min_pin_pirejTPC", 0.f, "min. pin for pion rejection in TPC"}; Configurable cfg_max_pin_pirejTPC{"cfg_max_pin_pirejTPC", 1e+10, "max. pin for pion rejection in TPC"}; - Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; - Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; - Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; - Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; - Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; - Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; - Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; + // Configurable cfg_min_ITSNsigmaKa{"cfg_min_ITSNsigmaKa", -1.0, "min. ITS n sigma for kaon exclusion"}; + // Configurable cfg_max_ITSNsigmaKa{"cfg_max_ITSNsigmaKa", 1e+10, "max. ITS n sigma for kaon exclusion"}; + // Configurable cfg_min_ITSNsigmaPr{"cfg_min_ITSNsigmaPr", -1.0, "min. ITS n sigma for proton exclusion"}; + // Configurable cfg_max_ITSNsigmaPr{"cfg_max_ITSNsigmaPr", 1e+10, "max. ITS n sigma for proton exclusion"}; + // Configurable cfg_min_p_ITSNsigmaKa{"cfg_min_p_ITSNsigmaKa", 0.0, "min p for kaon exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaKa{"cfg_max_p_ITSNsigmaKa", 0.0, "max p for kaon exclusion in ITS"}; + // Configurable cfg_min_p_ITSNsigmaPr{"cfg_min_p_ITSNsigmaPr", 0.0, "min p for proton exclusion in ITS"}; + // Configurable cfg_max_p_ITSNsigmaPr{"cfg_max_p_ITSNsigmaPr", 0.0, "max p for proton exclusion in ITS"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; // configuration for PID ML Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; @@ -180,23 +196,31 @@ struct SingleTrackQCMC { DimuonCut fDimuonCut; struct : ConfigurableGroup { std::string prefix = "dimuoncut_group"; - Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; + Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; + Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; Configurable cfg_min_eta_track{"cfg_min_eta_track", -4.0, "min eta for single track"}; Configurable cfg_max_eta_track{"cfg_max_eta_track", -2.5, "max eta for single track"}; Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.f, "max phi for single track"}; Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for single track"}; Configurable cfg_min_ncluster_mft{"cfg_min_ncluster_mft", 5, "min ncluster MFT"}; Configurable cfg_min_ncluster_mch{"cfg_min_ncluster_mch", 5, "min ncluster MCH"}; - Configurable cfg_max_chi2{"cfg_max_chi2", 1e+10, "max chi2"}; - Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 1e+10, "max chi2 for MFT-MCH matching"}; + Configurable cfg_max_chi2{"cfg_max_chi2", 1e+6, "max chi2"}; + Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 40, "max chi2 for MFT-MCH matching"}; Configurable cfg_max_matching_chi2_mchmid{"cfg_max_matching_chi2_mchmid", 1e+10, "max chi2 for MCH-MID matching"}; Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1e+10, "max dca XY for single track in cm"}; Configurable cfg_min_rabs{"cfg_min_rabs", 17.6, "min Radius at the absorber end"}; Configurable cfg_max_rabs{"cfg_max_rabs", 89.5, "max Radius at the absorber end"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable cfg_max_relDPt_wrt_matchedMCHMID{"cfg_max_relDPt_wrt_matchedMCHMID", 1e+10f, "max. relative dpt between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DEta_wrt_matchedMCHMID{"cfg_max_DEta_wrt_matchedMCHMID", 1e+10f, "max. deta between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_DPhi_wrt_matchedMCHMID{"cfg_max_DPhi_wrt_matchedMCHMID", 1e+10f, "max. dphi between MFT-MCH-MID and MCH-MID"}; + Configurable requireMFTHitMap{"requireMFTHitMap", false, "flag to apply MFT hit map"}; + Configurable> requiredMFTDisks{"requiredMFTDisks", std::vector{0}, "hit map on MFT disks [0,1,2,3,4]. logical-OR of each double-sided disk"}; + Configurable rejectWrongMatch{"rejectWrongMatch", false, "flag to reject wrong match between MFT and MCH-MID"}; // this is only for MC study, as we don't know correct match in data. } dimuoncuts; + o2::aod::rctsel::RCTFlagsChecker rctChecker; o2::ccdb::CcdbApi ccdbApi; Service ccdb; @@ -218,7 +242,8 @@ struct SingleTrackQCMC { { // event info o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms<-1>(&fRegistry); - fRegistry.add("MCEvent/before/hZvtx", "vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); + fRegistry.add("MCEvent/before/hZvtx", "mc vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); + fRegistry.add("MCEvent/before/hZvtx_rec", "rec. mc vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); fRegistry.addClone("MCEvent/before/", "MCEvent/after/"); if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { @@ -226,13 +251,9 @@ struct SingleTrackQCMC { const AxisSpec axis_eta{20, -1.0, +1.0, "#eta_{e}"}; const AxisSpec axis_phi{36, 0.0, 2 * M_PI, "#varphi_{e} (rad.)"}; const AxisSpec axis_charge_gen{3, -1.5, +1.5, "true charge"}; - std::string dca_axis_title = "DCA_{e}^{3D} (#sigma)"; - if (cfgDCAType == 1) { - dca_axis_title = "DCA_{e}^{XY} (#sigma)"; - } else if (cfgDCAType == 2) { - dca_axis_title = "DCA_{e}^{Z} (#sigma)"; - } - const AxisSpec axis_dca{ConfDCABins, dca_axis_title}; + const AxisSpec axis_dca3D{ConfDCA3DBins, "DCA_{e}^{3D} (#sigma)"}; + const AxisSpec axis_dcaXY{ConfDCAXYBins, "DCA_{e}^{XY} (#sigma)"}; + const AxisSpec axis_dcaZ{ConfDCAZBins, "DCA_{e}^{Z} (#sigma)"}; // generated info fRegistry.add("Generated/lf/hs", "gen. single electron", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_charge_gen}, true); @@ -246,15 +267,19 @@ struct SingleTrackQCMC { fRegistry.addClone("Generated/lf/", "Generated/b2c2l/"); // track info - fRegistry.add("Track/lf/positive/hs", "rec. single electron", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_dca, axis_charge_gen}, true); + fRegistry.add("Track/lf/positive/hs", "rec. single electron", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_dca3D, axis_dcaXY, axis_dcaZ, axis_charge_gen}, true); + if (fillGenValuesForRec) { + fRegistry.add("Track/lf/positive/hsGenRec", "rec. single electron", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_dca3D, axis_dcaXY, axis_dcaZ, axis_charge_gen}, true); + } if (cfgFillQA) { fRegistry.add("Track/lf/positive/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/lf/positive/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); - fRegistry.add("Track/lf/positive/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); - fRegistry.add("Track/lf/positive/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{200, 0, 10}, {200, 0., 400}}, false); - fRegistry.add("Track/lf/positive/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{200, 0, 10}, {200, 0., 400}}, false); - fRegistry.add("Track/lf/positive/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/lf/positive/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); + fRegistry.add("Track/lf/positive/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.f, 1.f}}, false); + fRegistry.add("Track/lf/positive/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{400, -20.0f, 20.0f}, {400, -20.0f, 20.0f}}, false); + fRegistry.add("Track/lf/positive/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/lf/positive/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/lf/positive/hDCA3dRes_Pt", "DCA_{3D} resolution vs. pT;p_{T} (GeV/c);DCA_{3D} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/lf/positive/hNclsTPC_Pt", "number of TPC clusters;p_{T,e} (GeV/c);;TPC N_{cls}", kTH2F, {axis_pt, {161, -0.5, 160.5}}, false); + fRegistry.add("Track/lf/positive/hNcrTPC_Pt", "number of TPC crossed rows;p_{T,e} (GeV/c);;TPC N_{CR}", kTH2F, {axis_pt, {161, -0.5, 160.5}}, false); fRegistry.add("Track/lf/positive/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); fRegistry.add("Track/lf/positive/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); fRegistry.add("Track/lf/positive/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); @@ -282,31 +307,31 @@ struct SingleTrackQCMC { if (cfgFillQA) { fRegistry.add("Track/PID/positive/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); fRegistry.add("Track/PID/positive/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/PID/positive/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/PID/positive/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/PID/positive/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/PID/positive/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/PID/positive/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/PID/positive/hTOFbeta", "TOF #beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, false); fRegistry.add("Track/PID/positive/hTOFNsigmaEl", "TOF n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/PID/positive/hTOFNsigmaMu", "TOF n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/PID/positive/hTOFNsigmaMu", "TOF n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/PID/positive/hTOFNsigmaPi", "TOF n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/PID/positive/hTOFNsigmaKa", "TOF n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/PID/positive/hTOFNsigmaPr", "TOF n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/PID/positive/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); on ITS #times cos(#lambda)", kTH2F, {{1000, 0.f, 10.f}, {150, 0, 15}}, false); fRegistry.add("Track/PID/positive/hMeanClusterSizeITSib", "mean cluster size ITS inner barrel;p_{pv} (GeV/c); on ITS #times cos(#lambda)", kTH2F, {{1000, 0.f, 10.f}, {150, 0, 15}}, false); fRegistry.add("Track/PID/positive/hMeanClusterSizeITSob", "mean cluster size ITS outer barrel;p_{pv} (GeV/c); on ITS #times cos(#lambda)", kTH2F, {{1000, 0.f, 10.f}, {150, 0, 15}}, false); - fRegistry.add("Track/PID/positive/hITSNsigmaEl", "ITS n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/PID/positive/hITSNsigmaMu", "ITS n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/PID/positive/hITSNsigmaPi", "ITS n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/PID/positive/hITSNsigmaKa", "ITS n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/PID/positive/hITSNsigmaPr", "ITS n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/PID/positive/hITSNsigmaEl", "ITS n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/PID/positive/hITSNsigmaMu", "ITS n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/PID/positive/hITSNsigmaPi", "ITS n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/PID/positive/hITSNsigmaKa", "ITS n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/PID/positive/hITSNsigmaPr", "ITS n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.addClone("Track/PID/positive/", "Track/PID/negative/"); } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { const AxisSpec axis_pt{ConfPtlBins, "p_{T,#mu} (GeV/c)"}; - const AxisSpec axis_eta{25, -4.5, -2.0, "#eta_{#mu}"}; + const AxisSpec axis_eta{50, -6, -1, "#eta_{#mu}"}; const AxisSpec axis_phi{36, 0.0, 2 * M_PI, "#varphi_{#mu} (rad.)"}; - const AxisSpec axis_dca{ConfDCABins, "DCA_{#mu}^{XY} (#sigma)"}; + const AxisSpec axis_dca{ConfDCAXYBins, "DCA_{#mu}^{XY} (#sigma)"}; const AxisSpec axis_charge_gen{3, -1.5, +1.5, "true charge"}; // generated info @@ -322,17 +347,23 @@ struct SingleTrackQCMC { // track info fRegistry.add("Track/lf/positive/hs", "rec. single muon", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_dca, axis_charge_gen}, true); + if (fillGenValuesForRec) { + fRegistry.add("Track/lf/positive/hsGenRec", "gen. info of rec. single muon", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_dca, axis_charge_gen}, true); + } if (cfgFillQA) { + fRegistry.add("Track/lf/positive/hEtaPhi_MatchMCHMID", "#eta vs. #varphi of matched MCHMID", kTH2F, {{180, 0, 2.f * M_PI}, {100, -6, -1}}, false); + fRegistry.add("Track/lf/positive/hdEtadPhi", "#Delta#eta vs. #Delta#varphi between MFT-MCH-MID and MCH-MID;#varphi_{sa} - #varphi_{gl} (rad.);#eta_{sa} - #eta_{gl}", kTH2F, {{90, -M_PI / 4, M_PI / 4}, {100, -0.5, +0.5}}, false); fRegistry.add("Track/lf/positive/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); fRegistry.add("Track/lf/positive/hTrackType", "track type", kTH1F, {{6, -0.5f, 5.5}}, false); - fRegistry.add("Track/lf/positive/hDCAxy", "DCA x vs. y;DCA_{x} (cm);DCA_{y} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); + fRegistry.add("Track/lf/positive/hDCAxy", "DCA x vs. y;DCA_{x} (cm);DCA_{y} (cm)", kTH2F, {{200, -0.5f, 0.5f}, {200, -0.5f, 0.5f}}, false); fRegistry.add("Track/lf/positive/hDCAxySigma", "DCA x vs. y;DCA_{x} (#sigma);DCA_{y} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); - fRegistry.add("Track/lf/positive/hDCAxRes_Pt", "DCA_{x} resolution vs. pT;p_{T} (GeV/c);DCA_{x} resolution (#mum)", kTH2F, {{200, 0, 10}, {200, 0., 400}}, false); - fRegistry.add("Track/lf/positive/hDCAyRes_Pt", "DCA_{y} resolution vs. pT;p_{T} (GeV/c);DCA_{y} resolution (#mum)", kTH2F, {{200, 0, 10}, {200, 0., 400}}, false); + fRegistry.add("Track/lf/positive/hDCAxRes_Pt", "DCA_{x} resolution vs. pT;p_{T} (GeV/c);DCA_{x} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0, 500}}, false); + fRegistry.add("Track/lf/positive/hDCAyRes_Pt", "DCA_{y} resolution vs. pT;p_{T} (GeV/c);DCA_{y} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0, 500}}, false); + fRegistry.add("Track/lf/positive/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0, 500}}, false); fRegistry.add("Track/lf/positive/hNclsMCH", "number of MCH clusters", kTH1F, {{21, -0.5, 20.5}}, false); fRegistry.add("Track/lf/positive/hNclsMFT", "number of MFT clusters", kTH1F, {{11, -0.5, 10.5}}, false); - fRegistry.add("Track/lf/positive/hPDCA", "pDCA;p_{T} at PV (GeV/c);p #times DCA (GeV/c #upoint cm)", kTH2F, {{100, 0, 10}, {100, 0.0f, 1000}}, false); - fRegistry.add("Track/lf/positive/hChi2", "chi2;chi2", kTH1F, {{100, 0.0f, 100}}, false); + fRegistry.add("Track/lf/positive/hPDCA", "pDCA;R at absorber (cm);p #times DCA (GeV/c #upoint cm)", kTH2F, {{100, 0, 100}, {100, 0.0f, 1000}}, false); + fRegistry.add("Track/lf/positive/hChi2", "chi2;chi2/ndf", kTH1F, {{100, 0.0f, 10}}, false); fRegistry.add("Track/lf/positive/hChi2MatchMCHMID", "chi2 match MCH-MID;chi2", kTH1F, {{100, 0.0f, 100}}, false); fRegistry.add("Track/lf/positive/hChi2MatchMCHMFT", "chi2 match MCH-MFT;chi2", kTH1F, {{100, 0.0f, 100}}, false); fRegistry.add("Track/lf/positive/hMFTClusterMap", "MFT cluster map", kTH1F, {{1024, -0.5, 1023.5}}, false); @@ -353,17 +384,22 @@ struct SingleTrackQCMC { } } + bool fillGenValuesForRec = false; int pdg_lepton = 0; void init(InitContext&) { if (doprocessQCMC && doprocessQCMC_Smeared) { LOGF(fatal, "Cannot enable processQCMC and processQCMC_Smeared at the same time. Please choose one."); } + if (doprocessQCMC) { + fillGenValuesForRec = true; + } ccdb->setURL(ccdburl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); + rctChecker.init(eventcuts.cfgRCTLabel.value, eventcuts.cfgCheckZDC.value, eventcuts.cfgTreatLimitedAcceptanceAsBad.value); DefineEMEventCut(); addhistograms(); @@ -375,7 +411,18 @@ struct SingleTrackQCMC { pdg_lepton = 13; DefineDimuonCut(); } - fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter"); + if (doprocessNorm) { + fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter"); + } + if (doprocessBC) { + auto hTVXCounter = fRegistry.add("BC/hTVXCounter", "TVX counter", kTH1D, {{6, -0.5f, 5.5f}}); + hTVXCounter->GetXaxis()->SetBinLabel(1, "TVX"); + hTVXCounter->GetXaxis()->SetBinLabel(2, "TVX && NoTFB"); + hTVXCounter->GetXaxis()->SetBinLabel(3, "TVX && NoITSROFB"); + hTVXCounter->GetXaxis()->SetBinLabel(4, "TVX && GoodRCT"); + hTVXCounter->GetXaxis()->SetBinLabel(5, "TVX && NoTFB && NoITSROFB"); + hTVXCounter->GetXaxis()->SetBinLabel(6, "TVX && NoTFB && NoITSROFB && GoodRCT"); + } } void DefineEMEventCut() @@ -388,12 +435,16 @@ struct SingleTrackQCMC { fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); + fEMEventCut.SetRequireVertexTOFmatched(eventcuts.cfgRequireVertexTOFmatched); fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); fEMEventCut.SetRequireNoHighMultCollInPrevRof(eventcuts.cfgRequireNoHighMultCollInPrevRof); + fEMEventCut.SetRequireGoodITSLayer3(eventcuts.cfgRequireGoodITSLayer3); + fEMEventCut.SetRequireGoodITSLayer0123(eventcuts.cfgRequireGoodITSLayer0123); + fEMEventCut.SetRequireGoodITSLayersAll(eventcuts.cfgRequireGoodITSLayersAll); } o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; @@ -404,7 +455,7 @@ struct SingleTrackQCMC { // for track fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, dielectroncuts.cfg_max_pt_track); fDielectronCut.SetTrackEtaRange(dielectroncuts.cfg_min_eta_track, dielectroncuts.cfg_max_eta_track); - fDielectronCut.SetTrackPhiRange(dielectroncuts.cfg_min_phi_track, dielectroncuts.cfg_max_phi_track); + fDielectronCut.SetTrackPhiRange(dielectroncuts.cfg_min_phi_track, dielectroncuts.cfg_max_phi_track, dielectroncuts.cfg_mirror_phi_track, dielectroncuts.cfg_reject_phi_track); fDielectronCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); fDielectronCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); fDielectronCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); @@ -412,38 +463,39 @@ struct SingleTrackQCMC { fDielectronCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); fDielectronCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); fDielectronCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size, dielectroncuts.cfg_min_p_its_cluster_size, dielectroncuts.cfg_max_p_its_cluster_size); + fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size); fDielectronCut.SetTrackMaxDcaXY(dielectroncuts.cfg_max_dcaxy); fDielectronCut.SetTrackMaxDcaZ(dielectroncuts.cfg_max_dcaz); fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); fDielectronCut.SetChi2TOF(0.0, dielectroncuts.cfg_max_chi2tof); fDielectronCut.SetRelDiffPin(dielectroncuts.cfg_min_rel_diff_pin, dielectroncuts.cfg_max_rel_diff_pin); + fDielectronCut.IncludeITSsa(dielectroncuts.includeITSsa, dielectroncuts.cfg_max_pt_track_ITSsa); // for eID fDielectronCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); fDielectronCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); + // fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); fDielectronCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); fDielectronCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); fDielectronCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); fDielectronCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); - fDielectronCut.SetMaxPinForPionRejectionTPC(dielectroncuts.cfg_max_pin_pirejTPC); - fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); - fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); - fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); - fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); + fDielectronCut.SetPinRangeForPionRejectionTPC(dielectroncuts.cfg_min_pin_pirejTPC, dielectroncuts.cfg_max_pin_pirejTPC); + // fDielectronCut.SetITSNsigmaKaRange(dielectroncuts.cfg_min_ITSNsigmaKa, dielectroncuts.cfg_max_ITSNsigmaKa); + // fDielectronCut.SetITSNsigmaPrRange(dielectroncuts.cfg_min_ITSNsigmaPr, dielectroncuts.cfg_max_ITSNsigmaPr); + // fDielectronCut.SetPRangeForITSNsigmaKa(dielectroncuts.cfg_min_p_ITSNsigmaKa, dielectroncuts.cfg_max_p_ITSNsigmaKa); + // fDielectronCut.SetPRangeForITSNsigmaPr(dielectroncuts.cfg_min_p_ITSNsigmaPr, dielectroncuts.cfg_max_p_ITSNsigmaPr); if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut static constexpr int nClassesMl = 2; - const std::vector cutDirMl = {o2::cuts_ml::CutSmaller, o2::cuts_ml::CutNot}; - const std::vector labelsClasses = {"Signal", "Background"}; + const std::vector cutDirMl = {o2::cuts_ml::CutNot, o2::cuts_ml::CutSmaller}; + const std::vector labelsClasses = {"Background", "Signal"}; const uint32_t nBinsMl = dielectroncuts.binsMl.value.size() - 1; const std::vector labelsBins(nBinsMl, "bin"); double cutsMlArr[nBinsMl][nClassesMl]; for (uint32_t i = 0; i < nBinsMl; i++) { - cutsMlArr[i][0] = dielectroncuts.cutsMl.value[i]; - cutsMlArr[i][1] = 0.; + cutsMlArr[i][0] = 0.; + cutsMlArr[i][1] = dielectroncuts.cutsMl.value[i]; } o2::framework::LabeledArray cutsMl = {cutsMlArr[0], nBinsMl, nClassesMl, labelsBins, labelsClasses}; @@ -468,17 +520,19 @@ struct SingleTrackQCMC { // for track fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); - fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, 1e10f); + fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, dimuoncuts.cfg_max_pt_track); fDimuonCut.SetTrackEtaRange(dimuoncuts.cfg_min_eta_track, dimuoncuts.cfg_max_eta_track); fDimuonCut.SetTrackPhiRange(dimuoncuts.cfg_min_phi_track, dimuoncuts.cfg_max_phi_track); fDimuonCut.SetNClustersMFT(dimuoncuts.cfg_min_ncluster_mft, 10); - fDimuonCut.SetNClustersMCHMID(dimuoncuts.cfg_min_ncluster_mch, 16); + fDimuonCut.SetNClustersMCHMID(dimuoncuts.cfg_min_ncluster_mch, 20); fDimuonCut.SetChi2(0.f, dimuoncuts.cfg_max_chi2); fDimuonCut.SetMatchingChi2MCHMFT(0.f, dimuoncuts.cfg_max_matching_chi2_mftmch); fDimuonCut.SetMatchingChi2MCHMID(0.f, dimuoncuts.cfg_max_matching_chi2_mchmid); fDimuonCut.SetDCAxy(0.f, dimuoncuts.cfg_max_dcaxy); fDimuonCut.SetRabs(dimuoncuts.cfg_min_rabs, dimuoncuts.cfg_max_rabs); fDimuonCut.SetMaxPDCARabsDep([&](float rabs) { return (rabs < 26.5 ? 594.f : 324.f); }); + fDimuonCut.SetMaxdPtdEtadPhiwrtMCHMID(dimuoncuts.cfg_max_relDPt_wrt_matchedMCHMID, dimuoncuts.cfg_max_DEta_wrt_matchedMCHMID, dimuoncuts.cfg_max_DPhi_wrt_matchedMCHMID); // this is relevant for global muons + fDimuonCut.SetMFTHitMap(dimuoncuts.requireMFTHitMap, dimuoncuts.requiredMFTDisks); } template @@ -527,12 +581,9 @@ struct SingleTrackQCMC { void fillElectronInfo(TTrack const& track) { auto mctrack = track.template emmcparticle_as(); - float dca = dca3DinSigma(track); - if (cfgDCAType == 1) { - dca = dcaXYinSigma(track); - } else if (cfgDCAType == 2) { - dca = dcaZinSigma(track); - } + float dca3D = dca3DinSigma(track); + float dcaXY = dcaXYinSigma(track); + float dcaZ = dcaZinSigma(track); float weight = 1.f; if (cfgApplyWeightTTCA) { @@ -541,16 +592,20 @@ struct SingleTrackQCMC { // LOGF(info, "map_weight[%d] = %f", track.globalIndex(), weight); if (track.sign() > 0) { - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hs"), track.pt(), track.eta(), track.phi(), dca, -mctrack.pdgCode() / pdg_lepton, weight); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hs"), track.pt(), track.eta(), track.phi(), dca3D, dcaXY, dcaZ, -mctrack.pdgCode() / pdg_lepton, weight); + if (fillGenValuesForRec) { + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hsGenRec"), mctrack.pt(), mctrack.eta(), mctrack.phi(), dca3D, dcaXY, dcaZ, -mctrack.pdgCode() / pdg_lepton, weight); + } if (cfgFillQA) { fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hQoverPt"), track.sign() / track.pt()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxyzSigma"), dcaXY, dcaZ); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAzRes_Pt"), track.pt(), std::sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCA3dRes_Pt"), track.pt(), sigmaDca3D(track) * 1e+4); // convert cm to um fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hNcrTPC"), track.tpcNClsCrossedRows()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hNclsTPC_Pt"), track.pt(), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hNcrTPC_Pt"), track.pt(), track.tpcNClsCrossedRows()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); @@ -569,32 +624,36 @@ struct SingleTrackQCMC { fRegistry.fill(HIST("Track/PID/positive/hMeanClusterSizeITSib"), track.p(), track.meanClusterSizeITSib() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/PID/positive/hMeanClusterSizeITSob"), track.p(), track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/PID/positive/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/PID/positive/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); + // fRegistry.fill(HIST("Track/PID/positive/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); fRegistry.fill(HIST("Track/PID/positive/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); fRegistry.fill(HIST("Track/PID/positive/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); fRegistry.fill(HIST("Track/PID/positive/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); + // fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaKa"), track.p(), track.tofNSigmaKa()); fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaPr"), track.p(), track.tofNSigmaPr()); - fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); - fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); - fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); - fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); - fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); + // fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); + // fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); + // fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); + // fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); + // fRegistry.fill(HIST("Track/PID/positive/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); } } else { - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hs"), track.pt(), track.eta(), track.phi(), dca, -mctrack.pdgCode() / pdg_lepton, weight); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hs"), track.pt(), track.eta(), track.phi(), dca3D, dcaXY, dcaZ, -mctrack.pdgCode() / pdg_lepton, weight); + if (fillGenValuesForRec) { + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hsGenRec"), mctrack.pt(), mctrack.eta(), mctrack.phi(), dca3D, dcaXY, dcaZ, -mctrack.pdgCode() / pdg_lepton, weight); + } if (cfgFillQA) { fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hQoverPt"), track.sign() / track.pt()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxyzSigma"), dcaXY, dcaZ); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAzRes_Pt"), track.pt(), std::sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCA3dRes_Pt"), track.pt(), sigmaDca3D(track) * 1e+4); // convert cm to um fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hNcrTPC"), track.tpcNClsCrossedRows()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hNclsTPC_Pt"), track.pt(), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hNcrTPC_Pt"), track.pt(), track.tpcNClsCrossedRows()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); @@ -613,20 +672,20 @@ struct SingleTrackQCMC { fRegistry.fill(HIST("Track/PID/negative/hMeanClusterSizeITSib"), track.p(), track.meanClusterSizeITSib() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/PID/negative/hMeanClusterSizeITSob"), track.p(), track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/PID/negative/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/PID/negative/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); + // fRegistry.fill(HIST("Track/PID/negative/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); fRegistry.fill(HIST("Track/PID/negative/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); fRegistry.fill(HIST("Track/PID/negative/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); fRegistry.fill(HIST("Track/PID/negative/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); + // fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaKa"), track.p(), track.tofNSigmaKa()); fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaPr"), track.p(), track.tofNSigmaPr()); - fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); - fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); - fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); - fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); - fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); + // fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); + // fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); + // fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); + // fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); + // fRegistry.fill(HIST("Track/PID/negative/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); } } } @@ -636,6 +695,9 @@ struct SingleTrackQCMC { { auto mctrack = track.template emmcparticle_as(); float dca_xy = fwdDcaXYinSigma(track); + float deta = track.etaMatchedMCHMID() - track.eta(); + float dphi = track.phiMatchedMCHMID() - track.phi(); + o2::math_utils::bringToPMPi(dphi); float weight = 1.f; if (cfgApplyWeightTTCA) { @@ -645,17 +707,23 @@ struct SingleTrackQCMC { if (track.sign() > 0) { fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hs"), track.pt(), track.eta(), track.phi(), dca_xy, -mctrack.pdgCode() / pdg_lepton, weight); + if (fillGenValuesForRec) { + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hsGenRec"), mctrack.pt(), mctrack.eta(), mctrack.phi(), dca_xy, -mctrack.pdgCode() / pdg_lepton, weight); + } if (cfgFillQA) { + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hEtaPhi_MatchMCHMID"), track.phiMatchedMCHMID(), track.etaMatchedMCHMID(), weight); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hdEtadPhi"), dphi, deta, weight); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hQoverPt"), track.sign() / track.pt()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hTrackType"), track.trackType()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxy"), track.fwdDcaX(), track.fwdDcaY()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxySigma"), track.fwdDcaX() / std::sqrt(track.cXX()), track.fwdDcaY() / std::sqrt(track.cYY())); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxRes_Pt"), track.pt(), std::sqrt(track.cXX()) * 1e+4); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxySigma"), track.fwdDcaX() / std::sqrt(track.cXXatDCA()), track.fwdDcaY() / std::sqrt(track.cYYatDCA())); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxRes_Pt"), track.pt(), std::sqrt(track.cXXatDCA()) * 1e+4); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAyRes_Pt"), track.pt(), std::sqrt(track.cYYatDCA()) * 1e+4); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDCAxyRes_Pt"), track.pt(), sigmaFwdDcaXY(track) * 1e+4); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hNclsMCH"), track.nClusters()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hNclsMFT"), track.nClustersMFT()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hPDCA"), track.pt(), track.pDca()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hChi2"), track.chi2()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hPDCA"), track.rAtAbsorberEnd(), track.pDca()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hChi2"), track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) ? track.chi2() / (2.f * (track.nClusters() + track.nClustersMFT()) - 5.f) : track.chi2()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hChi2MatchMCHMID"), track.chi2MatchMCHMID()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hMFTClusterMap"), track.mftClusterMap()); @@ -665,17 +733,23 @@ struct SingleTrackQCMC { } } else { fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hs"), track.pt(), track.eta(), track.phi(), dca_xy, -mctrack.pdgCode() / pdg_lepton, weight); + if (fillGenValuesForRec) { + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hsGenRec"), mctrack.pt(), mctrack.eta(), mctrack.phi(), dca_xy, -mctrack.pdgCode() / pdg_lepton, weight); + } if (cfgFillQA) { + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hEtaPhi_MatchMCHMID"), track.phiMatchedMCHMID(), track.etaMatchedMCHMID(), weight); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hdEtadPhi"), dphi, deta, weight); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hQoverPt"), track.sign() / track.pt()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hTrackType"), track.trackType()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxy"), track.fwdDcaX(), track.fwdDcaY()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxySigma"), track.fwdDcaX() / std::sqrt(track.cXX()), track.fwdDcaY() / std::sqrt(track.cYY())); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxRes_Pt"), track.pt(), std::sqrt(track.cXX()) * 1e+4); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxySigma"), track.fwdDcaX() / std::sqrt(track.cXXatDCA()), track.fwdDcaY() / std::sqrt(track.cYYatDCA())); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxRes_Pt"), track.pt(), std::sqrt(track.cXXatDCA()) * 1e+4); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAyRes_Pt"), track.pt(), std::sqrt(track.cYYatDCA()) * 1e+4); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDCAxyRes_Pt"), track.pt(), sigmaFwdDcaXY(track) * 1e+4); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hNclsMCH"), track.nClusters()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hNclsMFT"), track.nClustersMFT()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hPDCA"), track.pt(), track.pDca()); - fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hChi2"), track.chi2()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hPDCA"), track.rAtAbsorberEnd(), track.pDca()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hChi2"), track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) ? track.chi2() / (2.f * (track.nClusters() + track.nClustersMFT()) - 5.f) : track.chi2()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hChi2MatchMCHMID"), track.chi2MatchMCHMID()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hMFTClusterMap"), track.mftClusterMap()); @@ -689,45 +763,46 @@ struct SingleTrackQCMC { template void runQCMC(TCollisions const& collisions, TTracks const& tracks, TPreslice const& perCollision, TCut const& cut, TMCCollisions const&, TMCParticles const& mcparticles) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { continue; } - // auto mccollision = collision.template emmcevent_as(); - // if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { - // continue; - // } - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0, -1>(&fRegistry, collision); if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1, -1>(&fRegistry, collision); fRegistry.fill(HIST("Event/before/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted fRegistry.fill(HIST("Event/after/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted auto tracks_per_coll = tracks.sliceBy(perCollision, collision.globalIndex()); - for (auto& track : tracks_per_coll) { + for (const auto& track : tracks_per_coll) { auto mctrack = track.template emmcparticle_as(); - if (abs(mctrack.pdgCode()) != pdg_lepton) { + if (std::abs(mctrack.pdgCode()) != pdg_lepton) { continue; } if (!isInAcceptance(mctrack)) { continue; } + if (!mctrack.has_mothers()) { + continue; + } auto mccollision_from_track = mctrack.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision_from_track.getSubGeneratorId() != cfgEventGeneratorType) { continue; } - // if (mctrack.emmceventId() != collision.emmceventId()) { - // continue; - // } + if (cfgRequireTrueAssociation && (mctrack.emmceventId() != collision.emmceventId())) { + continue; + } if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { @@ -740,16 +815,19 @@ struct SingleTrackQCMC { } } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - if (!cut.template IsSelectedTrack(track)) { + if (!cut.template IsSelectedTrack(track)) { + continue; + } + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(track, cut, tracks)) { + continue; + } + if (dimuoncuts.rejectWrongMatch && track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && track.emmcparticleId() != track.emmftmcparticleId()) { continue; } } - if (!mctrack.has_mothers()) { - continue; - } auto mcmother = mcparticles.iteratorAt(mctrack.mothersIds()[0]); - int pdg_mother = abs(mcmother.pdgCode()); + int pdg_mother = std::abs(mcmother.pdgCode()); if (mctrack.isPhysicalPrimary() || mctrack.producedByGenerator()) { if (pdg_mother == 111 || pdg_mother == 221 || pdg_mother == 331 || pdg_mother == 113 || pdg_mother == 223 || pdg_mother == 333) { @@ -779,7 +857,9 @@ struct SingleTrackQCMC { fillTrackInfo<7, TMCParticles>(track); } } else { - fillTrackInfo<2, TMCParticles>(track); + if (pdg_mother == 22) { // photon conversion + fillTrackInfo<2, TMCParticles>(track); + } } } // end of track loop @@ -790,26 +870,12 @@ struct SingleTrackQCMC { template void runGenInfo(TCollisions const& collisions, TMCLeptons const& leptonsMC, TMCCollisions const& mccollisions, TMCParticles const& mcparticles) { - for (auto& mccollision : mccollisions) { + for (const auto& mccollision : mccollisions) { if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { continue; } fRegistry.fill(HIST("MCEvent/before/hZvtx"), mccollision.posZ()); - // auto rec_colls_per_mccoll = collisions.sliceBy(recColperMcCollision, mccollision.globalIndex()); - // if (rec_colls_per_mccoll.size() < 1) { - // continue; - // } - // uint32_t maxNumContrib = 0; - // int rec_col_globalIndex = -999; - // for (auto& rec_col : rec_colls_per_mccoll) { - // if (rec_col.numContrib() > maxNumContrib) { - // rec_col_globalIndex = rec_col.globalIndex(); - // maxNumContrib = rec_col.numContrib(); // assign mc collision to collision where the number of contibutor is lager. LF/MM recommendation - // } - // } - // auto collision = collisions.rawIteratorAt(rec_col_globalIndex); - if (mccollision.mpemeventId() < 0) { continue; } @@ -819,13 +885,17 @@ struct SingleTrackQCMC { if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { continue; } + fRegistry.fill(HIST("MCEvent/before/hZvtx_rec"), mccollision.posZ()); if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } fRegistry.fill(HIST("MCEvent/after/hZvtx"), mccollision.posZ()); auto leptonsMC_per_coll = leptonsMC.sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - for (auto& lepton : leptonsMC_per_coll) { + for (const auto& lepton : leptonsMC_per_coll) { if (!(lepton.isPhysicalPrimary() || lepton.producedByGenerator())) { continue; } @@ -836,7 +906,7 @@ struct SingleTrackQCMC { continue; } auto mcmother = mcparticles.iteratorAt(lepton.mothersIds()[0]); - int pdg_mother = abs(mcmother.pdgCode()); + int pdg_mother = std::abs(mcmother.pdgCode()); float pt = 0.f, eta = 0.f, phi = 0.f; if constexpr (isSmeared) { @@ -902,7 +972,7 @@ struct SingleTrackQCMC { { std::vector passed_trackIds; passed_trackIds.reserve(tracks.size()); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { continue; @@ -911,6 +981,9 @@ struct SingleTrackQCMC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } // auto mccollision = collision.template emmcevent_as(); // if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { @@ -920,7 +993,7 @@ struct SingleTrackQCMC { auto tracks_per_coll = tracks.sliceBy(perCollision, collision.globalIndex()); if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - for (auto& track : tracks_per_coll) { + for (const auto& track : tracks_per_coll) { auto mctrack = track.template emmcparticle_as(); auto mccollision_from_track = mctrack.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision_from_track.getSubGeneratorId() != cfgEventGeneratorType) { @@ -939,14 +1012,17 @@ struct SingleTrackQCMC { passed_trackIds.emplace_back(track.globalIndex()); } // end of track loop } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - for (auto& track : tracks_per_coll) { + for (const auto& track : tracks_per_coll) { auto mctrack = track.template emmcparticle_as(); auto mccollision_from_track = mctrack.template emmcevent_as(); if (cfgEventGeneratorType >= 0 && mccollision_from_track.getSubGeneratorId() != cfgEventGeneratorType) { continue; } + if (!cut.template IsSelectedTrack(track)) { + continue; + } - if (!cut.template IsSelectedTrack(track)) { + if (!o2::aod::pwgem::dilepton::utils::emtrackutil::isBestMatch(track, cut, tracks)) { continue; } passed_trackIds.emplace_back(track.globalIndex()); @@ -955,11 +1031,11 @@ struct SingleTrackQCMC { } // end of collision loop if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { - for (auto& trackId : passed_trackIds) { + for (const auto& trackId : passed_trackIds) { auto track = tracks.rawIteratorAt(trackId); auto ambIds = track.ambiguousElectronsIds(); float n = 1.f; // include myself. - for (auto& ambId : ambIds) { + for (const auto& ambId : ambIds) { if (std::find(passed_trackIds.begin(), passed_trackIds.end(), ambId) != passed_trackIds.end()) { n += 1.f; } @@ -967,11 +1043,11 @@ struct SingleTrackQCMC { map_weight[trackId] = 1.f / n; } } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { - for (auto& trackId : passed_trackIds) { + for (const auto& trackId : passed_trackIds) { auto track = tracks.rawIteratorAt(trackId); auto ambIds = track.ambiguousMuonsIds(); float n = 1.f; // include myself. - for (auto& ambId : ambIds) { + for (const auto& ambId : ambIds) { if (std::find(passed_trackIds.begin(), passed_trackIds.end(), ambId) != passed_trackIds.end()) { n += 1.f; } @@ -986,8 +1062,8 @@ struct SingleTrackQCMC { SliceCache cache; Preslice perCollision_electron = aod::emprimaryelectron::emeventId; - Filter trackFilter_electron = dielectroncuts.cfg_min_phi_track < o2::aod::track::phi && o2::aod::track::phi < dielectroncuts.cfg_max_phi_track && o2::aod::track::tpcChi2NCl < dielectroncuts.cfg_max_chi2tpc && o2::aod::track::itsChi2NCl < dielectroncuts.cfg_max_chi2its && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz; - Filter pidFilter_electron = (dielectroncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dielectroncuts.cfg_max_TPCNsigmaEl) && (o2::aod::pidtpc::tpcNSigmaPi < dielectroncuts.cfg_min_TPCNsigmaPi || dielectroncuts.cfg_max_TPCNsigmaPi < o2::aod::pidtpc::tpcNSigmaPi); + Filter trackFilter_electron = o2::aod::track::tpcChi2NCl < dielectroncuts.cfg_max_chi2tpc && o2::aod::track::itsChi2NCl < dielectroncuts.cfg_max_chi2its && nabs(o2::aod::track::dcaXY) < dielectroncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dielectroncuts.cfg_max_dcaz; + Filter pidFilter_electron = dielectroncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dielectroncuts.cfg_max_TPCNsigmaEl; Filter ttcaFilter_electron = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); Preslice perCollision_muon = aod::emprimarymuon::emeventId; @@ -997,7 +1073,7 @@ struct SingleTrackQCMC { Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); // Filter collisionFilter_multiplicity = cfgNtracksPV08Min <= o2::aod::mult::multNTracksPV && o2::aod::mult::multNTracksPV < cfgNtracksPV08Max; Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; - Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin < o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; using FilteredMyCollisions = soa::Filtered; Partition electronsMC = nabs(o2::aod::mcparticle::pdgCode) == 11; // e+, e- @@ -1049,7 +1125,7 @@ struct SingleTrackQCMC { void processNorm(aod::EMEventNormInfos const& collisions) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 1.0); if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 2.0); @@ -1078,20 +1154,70 @@ struct SingleTrackQCMC { if (collision.sel8()) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 10.0); } - if (abs(collision.posZ()) < 10.0) { + if (std::fabs(collision.posZ()) < 10.0) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 11.0); } if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 12.0); } + if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 13.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 14.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 15.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 16.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 17.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 18.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 19.0); + } if (!fEMEventCut.IsSelected(collision)) { continue; } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } fRegistry.fill(HIST("Event/norm/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted } // end of collision loop } PROCESS_SWITCH(SingleTrackQCMC, processNorm, "process normalization info", false); + void processBC(aod::EMBCs const& bcs) + { + for (const auto& bc : bcs) { + if (bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 0.f); + + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 1.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 2.f); + } + if (rctChecker(bc)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 3.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 4.f); + } + if (bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) && rctChecker(bc)) { + fRegistry.fill(HIST("BC/hTVXCounter"), 5.f); + } + } + } + } + PROCESS_SWITCH(SingleTrackQCMC, processBC, "process BC counter", false); + void processDummy(FilteredMyCollisions const&) {} PROCESS_SWITCH(SingleTrackQCMC, processDummy, "Dummy function", false); }; diff --git a/PWGEM/Dilepton/DataModel/dileptonTables.h b/PWGEM/Dilepton/DataModel/dileptonTables.h index cc1c2a627d6..74b9d1b604d 100644 --- a/PWGEM/Dilepton/DataModel/dileptonTables.h +++ b/PWGEM/Dilepton/DataModel/dileptonTables.h @@ -9,17 +9,19 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include -#include #include "Common/Core/RecoDecay.h" -#include "Framework/AnalysisDataModel.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/AnalysisDataModel.h" + +#include +#include +#include #ifndef PWGEM_DILEPTON_DATAMODEL_DILEPTONTABLES_H_ #define PWGEM_DILEPTON_DATAMODEL_DILEPTONTABLES_H_ @@ -55,6 +57,20 @@ const std::unordered_map aliasLabels = { }; } // namespace pwgem::dilepton::swt +// namespace embc +// { +// DECLARE_SOA_COLUMN(IsTriggerTVX, isTriggerTVX, bool); //! kIsTriggerTVX +// DECLARE_SOA_COLUMN(IsNoTimeFrameBorder, isNoTimeFrameBorder, bool); //! kIsNoTimeFrameBorder +// DECLARE_SOA_COLUMN(IsNoITSROFrameBorder, isNoITSROFrameBorder, bool); //! kNoITSROFrameBorder +// DECLARE_SOA_COLUMN(IsCollisionFound, isCollisionFound, bool); //! at least 1 collision is found in this BC. +// } // namespace embc +// DECLARE_SOA_TABLE(EMBCs, "AOD", "EMBC", //! bc information for normalization +// o2::soa::Index<>, embc::IsTriggerTVX, embc::IsNoTimeFrameBorder, embc::IsNoITSROFrameBorder, embc::IsCollisionFound); + +DECLARE_SOA_TABLE(EMBCs, "AOD", "EMBC", //! bc information for normalization + o2::soa::Index<>, evsel::Alias, evsel::Selection, evsel::Rct); +using EMBC = EMBCs::iterator; + namespace emevent { DECLARE_SOA_COLUMN(CollisionId, collisionId, int); @@ -106,6 +122,8 @@ DECLARE_SOA_COLUMN(SpherocityPtUnWeighted, spherocity_ptunweighted, float); //! DECLARE_SOA_COLUMN(NtrackSpherocity, ntspherocity, int); DECLARE_SOA_COLUMN(IsSelected, isSelected, bool); //! MB event selection info DECLARE_SOA_COLUMN(IsEoI, isEoI, bool); //! lepton or photon exists in MB event (not for CEFP) +DECLARE_SOA_COLUMN(PosX, posX, float); //! only for treeCreatetorML.cxx +DECLARE_SOA_COLUMN(PosY, posY, float); //! only for treeCreatetorML.cxx DECLARE_SOA_COLUMN(PosZint16, posZint16, int16_t); //! this is only to reduce data size DECLARE_SOA_DYNAMIC_COLUMN(PosZ, posZ, [](int16_t posZint16) -> float { return static_cast(posZint16) * 0.1f; }); @@ -130,19 +148,27 @@ DECLARE_SOA_DYNAMIC_COLUMN(EP4BNeg, ep4bneg, [](float q4x, float q4y) -> float { DECLARE_SOA_DYNAMIC_COLUMN(EP4BTot, ep4btot, [](float q4x, float q4y) -> float { return std::atan2(q4y, q4x) / 4.0; }); } // namespace emevent -DECLARE_SOA_TABLE(EMEvents_000, "AOD", "EMEVENT", //! Main event information table - o2::soa::Index<>, emevent::CollisionId, bc::RunNumber, bc::GlobalBC, evsel::Alias, evsel::Selection, timestamp::Timestamp, - collision::PosX, collision::PosY, collision::PosZ, - collision::NumContrib, evsel::NumTracksInTimeRange, emevent::Sel8); - DECLARE_SOA_TABLE_VERSIONED(EMEvents_001, "AOD", "EMEVENT", 1, //! Main event information table o2::soa::Index<>, emevent::CollisionId, bc::RunNumber, bc::GlobalBC, evsel::Alias, evsel::Selection, timestamp::Timestamp, collision::PosX, collision::PosY, collision::PosZ, collision::NumContrib, evsel::NumTracksInTimeRange, evsel::SumAmpFT0CInTimeRange, emevent::Sel8); -using EMEvents = EMEvents_001; +DECLARE_SOA_TABLE_VERSIONED(EMEvents_002, "AOD", "EMEVENT", 2, //! Main event information table + o2::soa::Index<>, emevent::CollisionId, bc::RunNumber, bc::GlobalBC, evsel::Alias, evsel::Selection, evsel::Rct, timestamp::Timestamp, + collision::PosX, collision::PosY, collision::PosZ, + collision::NumContrib, evsel::NumTracksInTimeRange, evsel::SumAmpFT0CInTimeRange, emevent::Sel8); + +DECLARE_SOA_TABLE_VERSIONED(EMEvents_003, "AOD", "EMEVENT", 3, //! Main event information table + o2::soa::Index<>, emevent::CollisionId, bc::RunNumber, bc::GlobalBC, evsel::Alias, evsel::Selection, evsel::Rct, timestamp::Timestamp, + collision::PosZ, + collision::NumContrib, evsel::NumTracksInTimeRange, evsel::SumAmpFT0CInTimeRange, emevent::Sel8); + +using EMEvents = EMEvents_003; using EMEvent = EMEvents::iterator; +DECLARE_SOA_TABLE(EMEventsXY, "AOD", "EMEVENTXY", emevent::PosX, emevent::PosY); // joinable to EMEvents, only for treeCreatetorML.cxx +using EMEventXY = EMEventsXY::iterator; + DECLARE_SOA_TABLE(EMEventsCov, "AOD", "EMEVENTCOV", //! joinable to EMEvents collision::CovXX, collision::CovXY, collision::CovXZ, collision::CovYY, collision::CovYZ, collision::CovZZ, collision::Chi2, o2::soa::Marker<1>); using EMEventCov = EMEventsCov::iterator; @@ -212,7 +238,7 @@ DECLARE_SOA_TABLE(EMEoIs, "AOD", "EMEOI", //! joinable to aod::Collisions in cre using EMEoI = EMEoIs::iterator; DECLARE_SOA_TABLE(EMEventNormInfos, "AOD", "EMEVENTNORMINFO", //! event information for normalization - o2::soa::Index<>, evsel::Alias, evsel::Selection, emevent::PosZint16, cent::CentFT0C, emevent::PosZ, emevent::Sel8); + o2::soa::Index<>, evsel::Alias, evsel::Selection, evsel::Rct, emevent::PosZint16, cent::CentFT0C, emevent::PosZ, emevent::Sel8); using EMEventNormInfo = EMEventNormInfos::iterator; namespace emmcevent @@ -361,6 +387,18 @@ DECLARE_SOA_TABLE(EMPrimaryMuonMCLabels, "AOD", "EMPRMMUMCLABEL", //! emprimarymuonmclabel::EMMCParticleId, emprimarymuonmclabel::McMask); using EMPrimaryMuonMCLabel = EMPrimaryMuonMCLabels::iterator; +namespace emmftmclabel +{ +// DECLARE_SOA_INDEX_COLUMN_FULL(EMMCParticle, emmcparticle); +DECLARE_SOA_INDEX_COLUMN_FULL(EMMFTMCParticle, emmftmcparticle, int, EMMCParticles, "_MFT"); +DECLARE_SOA_COLUMN(McMask, mcMask, uint16_t); +} // namespace emmftmclabel + +// NOTE: MC labels. This table has one entry for each reconstructed track (joinable with EMPrimaryMuons table) +DECLARE_SOA_TABLE(EMMFTMCLabels, "AOD", "EMMFTMCLABEL", //! + emmftmclabel::EMMFTMCParticleId, emmftmclabel::McMask); +using EMMFTMCLabel = EMMFTMCLabels::iterator; + namespace emprimaryelectron { DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! @@ -368,14 +406,60 @@ DECLARE_SOA_COLUMN(CollisionId, collisionId, int); //! DECLARE_SOA_COLUMN(TrackId, trackId, int); //! DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(AmbiguousElectrons, ambiguousElectrons); DECLARE_SOA_COLUMN(IsAssociatedToMPC, isAssociatedToMPC, bool); //! is associated to most probable collision +DECLARE_SOA_COLUMN(IsAmbiguous, isAmbiguous, bool); //! is ambiguous DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! DECLARE_SOA_COLUMN(PrefilterBit, pfb, uint8_t); //! DECLARE_SOA_COLUMN(PrefilterBitDerived, pfbderived, uint16_t); //! -DECLARE_SOA_COLUMN(ITSNSigmaEl, itsNSigmaEl, float); //! -DECLARE_SOA_COLUMN(ITSNSigmaMu, itsNSigmaMu, float); //! -DECLARE_SOA_COLUMN(ITSNSigmaPi, itsNSigmaPi, float); //! -DECLARE_SOA_COLUMN(ITSNSigmaKa, itsNSigmaKa, float); //! -DECLARE_SOA_COLUMN(ITSNSigmaPr, itsNSigmaPr, float); //! + +DECLARE_SOA_COLUMN(ITSNSigmaEl, itsNSigmaEl, float); //! +DECLARE_SOA_COLUMN(ITSNSigmaMu, itsNSigmaMu, float); //! +DECLARE_SOA_COLUMN(ITSNSigmaPi, itsNSigmaPi, float); //! +DECLARE_SOA_COLUMN(ITSNSigmaKa, itsNSigmaKa, float); //! +DECLARE_SOA_COLUMN(ITSNSigmaPr, itsNSigmaPr, float); //! + +DECLARE_SOA_COLUMN(TPCSignalUINT16, tpcSignalUINT16, uint16_t); //! 0 - +65535 +DECLARE_SOA_COLUMN(DeDxTunedMcUINT16, mcTunedTPCSignalUINT16, uint16_t); //! 0 - +65535 +DECLARE_SOA_COLUMN(ProbElBDT, probElBDT, float); //! +// DECLARE_SOA_COLUMN(ProbEbdtUINT16, probEbdtUINT16, uint16_t); //! 0 - +65535 + +DECLARE_SOA_COLUMN(TPCChi2NClINT16, tpcChi2NClINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(ITSChi2NClINT16, itsChi2NClINT16, int16_t); //! -32768 - +32767 + +DECLARE_SOA_COLUMN(BetaINT16, betaINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TOFChi2INT16, tofChi2INT16, int16_t); //! -32768 - +32767 + +DECLARE_SOA_COLUMN(TPCNSigmaElINT16, tpcNSigmaElINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TPCNSigmaMuINT16, tpcNSigmaMuINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TPCNSigmaPiINT16, tpcNSigmaPiINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TPCNSigmaKaINT16, tpcNSigmaKaINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TPCNSigmaPrINT16, tpcNSigmaPrINT16, int16_t); //! -32768 - +32767 + +DECLARE_SOA_COLUMN(TOFNSigmaElINT16, tofNSigmaElINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TOFNSigmaMuINT16, tofNSigmaMuINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TOFNSigmaPiINT16, tofNSigmaPiINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TOFNSigmaKaINT16, tofNSigmaKaINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TOFNSigmaPrINT16, tofNSigmaPrINT16, int16_t); //! -32768 - +32767 + +DECLARE_SOA_DYNAMIC_COLUMN(TPCSignal, tpcSignal, [](uint16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(DeDxTunedMc, mcTunedTPCSignal, [](uint16_t x) -> float { return static_cast(x) * 1e-2; }); +// DECLARE_SOA_DYNAMIC_COLUMN(ProbEbdt, probEbdt, [](uint16_t x) -> float { return static_cast(x) * 1e-4; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCChi2NCl, tpcChi2NCl, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(ITSChi2NCl, itsChi2NCl, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(Beta, beta, [](int16_t x) -> float { return static_cast(x) * 1e-3; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFChi2, tofChi2, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); + +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaEl, tpcNSigmaEl, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaMu, tpcNSigmaMu, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPi, tpcNSigmaPi, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaKa, tpcNSigmaKa, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPr, tpcNSigmaPr, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); + +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaEl, tofNSigmaEl, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaMu, tofNSigmaMu, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPi, tofNSigmaPi, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaKa, tofNSigmaKa, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPr, tofNSigmaPr, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); + DECLARE_SOA_DYNAMIC_COLUMN(Signed1Pt, signed1Pt, [](float pt, int8_t sign) -> float { return sign * 1. / pt; }); DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float pt, float eta) -> float { return pt * std::cosh(eta); }); DECLARE_SOA_DYNAMIC_COLUMN(Px, px, [](float pt, float phi) -> float { return pt * std::cos(phi); }); @@ -488,11 +572,96 @@ DECLARE_SOA_TABLE_VERSIONED(EMPrimaryElectrons_002, "AOD", "EMPRIMARYEL", 2, //! emprimaryelectron::MeanClusterSizeITSib, emprimaryelectron::MeanClusterSizeITSob); -using EMPrimaryElectrons = EMPrimaryElectrons_002; +DECLARE_SOA_TABLE_VERSIONED(EMPrimaryElectrons_003, "AOD", "EMPRIMARYEL", 3, //! + o2::soa::Index<>, emprimaryelectron::CollisionId, + emprimaryelectron::TrackId, emprimaryelectron::Sign, + track::Pt, track::Eta, track::Phi, track::DcaXY, track::DcaZ, + track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, track::TPCNClsShared, + track::TPCChi2NCl, track::TPCInnerParam, + track::TPCSignal, pidtpc::TPCNSigmaEl, /*pidtpc::TPCNSigmaMu,*/ pidtpc::TPCNSigmaPi, pidtpc::TPCNSigmaKa, pidtpc::TPCNSigmaPr, + pidtofbeta::Beta, pidtof::TOFNSigmaEl, /*pidtof::TOFNSigmaMu,*/ pidtof::TOFNSigmaPi, pidtof::TOFNSigmaKa, pidtof::TOFNSigmaPr, + track::ITSClusterSizes, + // emprimaryelectron::ITSNSigmaEl, emprimaryelectron::ITSNSigmaMu, emprimaryelectron::ITSNSigmaPi, emprimaryelectron::ITSNSigmaKa, emprimaryelectron::ITSNSigmaPr, + track::ITSChi2NCl, track::TOFChi2, track::DetectorMap, + track::X, track::Alpha, track::Y, track::Z, track::Snp, track::Tgl, emprimaryelectron::IsAssociatedToMPC, + mcpidtpc::DeDxTunedMc, + + // dynamic column + track::TPCNClsFound, + track::TPCNClsCrossedRows, + track::TPCCrossedRowsOverFindableCls, + track::TPCFoundOverFindableCls, + track::TPCFractionSharedCls, + track::v001::ITSClusterMap, track::v001::ITSNCls, track::v001::ITSNClsInnerBarrel, + track::HasITS, track::HasTPC, track::HasTRD, track::HasTOF, + emprimaryelectron::Signed1Pt, + emprimaryelectron::P, + emprimaryelectron::Px, + emprimaryelectron::Py, + emprimaryelectron::Pz, + emprimaryelectron::Theta, + emprimaryelectron::MeanClusterSizeITS, + emprimaryelectron::MeanClusterSizeITSib, + emprimaryelectron::MeanClusterSizeITSob); + +DECLARE_SOA_TABLE_VERSIONED(EMPrimaryElectrons_004, "AOD", "EMPRIMARYEL", 4, //! + o2::soa::Index<>, emprimaryelectron::CollisionId, + emprimaryelectron::TrackId, emprimaryelectron::Sign, + track::Pt, track::Eta, track::Phi, + track::DcaXY, track::DcaZ, aod::track::CYY, aod::track::CZY, aod::track::CZZ, + track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, track::TPCNClsShared, + emprimaryelectron::TPCChi2NClINT16, track::TPCInnerParam, + emprimaryelectron::TPCSignalUINT16, emprimaryelectron::TPCNSigmaElINT16, emprimaryelectron::TPCNSigmaPiINT16, emprimaryelectron::TPCNSigmaKaINT16, emprimaryelectron::TPCNSigmaPrINT16, + emprimaryelectron::BetaINT16, emprimaryelectron::TOFNSigmaElINT16, emprimaryelectron::TOFNSigmaPiINT16, emprimaryelectron::TOFNSigmaKaINT16, emprimaryelectron::TOFNSigmaPrINT16, + track::ITSClusterSizes, + emprimaryelectron::ITSChi2NClINT16, emprimaryelectron::TOFChi2INT16, track::DetectorMap, + track::Tgl, + emprimaryelectron::IsAssociatedToMPC, emprimaryelectron::IsAmbiguous, emprimaryelectron::ProbElBDT, + emprimaryelectron::DeDxTunedMcUINT16, + + // dynamic column + track::TPCNClsFound, + track::TPCNClsCrossedRows, + track::TPCCrossedRowsOverFindableCls, + track::TPCFoundOverFindableCls, + track::TPCFractionSharedCls, + track::v001::ITSClusterMap, track::v001::ITSNCls, track::v001::ITSNClsInnerBarrel, + track::HasITS, track::HasTPC, track::HasTRD, track::HasTOF, + + emprimaryelectron::TPCSignal, + emprimaryelectron::TPCChi2NCl, + emprimaryelectron::ITSChi2NCl, + emprimaryelectron::DeDxTunedMc, + // emprimaryelectron::ProbEbdt, + emprimaryelectron::Beta, + emprimaryelectron::TOFChi2, + + emprimaryelectron::TPCNSigmaEl, + emprimaryelectron::TPCNSigmaMu, + emprimaryelectron::TPCNSigmaPi, + emprimaryelectron::TPCNSigmaKa, + emprimaryelectron::TPCNSigmaPr, + emprimaryelectron::TOFNSigmaEl, + emprimaryelectron::TOFNSigmaMu, + emprimaryelectron::TOFNSigmaPi, + emprimaryelectron::TOFNSigmaKa, + emprimaryelectron::TOFNSigmaPr, + + emprimaryelectron::Signed1Pt, + emprimaryelectron::P, + emprimaryelectron::Px, + emprimaryelectron::Py, + emprimaryelectron::Pz, + emprimaryelectron::Theta, + emprimaryelectron::MeanClusterSizeITS, + emprimaryelectron::MeanClusterSizeITSib, + emprimaryelectron::MeanClusterSizeITSob); + +using EMPrimaryElectrons = EMPrimaryElectrons_004; // iterators using EMPrimaryElectron = EMPrimaryElectrons::iterator; -DECLARE_SOA_TABLE(EMPrimaryElectronsCov, "AOD", "EMPRIMARYELCOV", //! +DECLARE_SOA_TABLE(EMPrimaryElectronsCov_000, "AOD", "EMPRIMARYELCOV", //! aod::track::CYY, aod::track::CZY, aod::track::CZZ, @@ -508,6 +677,27 @@ DECLARE_SOA_TABLE(EMPrimaryElectronsCov, "AOD", "EMPRIMARYELCOV", //! aod::track::C1PtSnp, aod::track::C1PtTgl, aod::track::C1Pt21Pt2, o2::soa::Marker<1>); + +DECLARE_SOA_TABLE_VERSIONED(EMPrimaryElectronsCov_001, "AOD", "EMPRIMARYELCOV", 1, //! + aod::track::X, + aod::track::Alpha, + aod::track::Y, + aod::track::Z, + aod::track::Snp, + aod::track::CSnpY, + aod::track::CSnpZ, + aod::track::CSnpSnp, + aod::track::CTglY, + aod::track::CTglZ, + aod::track::CTglSnp, + aod::track::CTglTgl, + aod::track::C1PtY, + aod::track::C1PtZ, + aod::track::C1PtSnp, + aod::track::C1PtTgl, + aod::track::C1Pt21Pt2); // CYY, CZY, CZZ, Tgl are in the main electron table. + +using EMPrimaryElectronsCov = EMPrimaryElectronsCov_001; // iterators using EMPrimaryElectronCov = EMPrimaryElectronsCov::iterator; @@ -529,21 +719,28 @@ using EMPrimaryElectronPrefilterBitDerived = EMPrimaryElectronsPrefilterBitDeriv namespace emprimarymuon { -DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! -DECLARE_SOA_COLUMN(CollisionId, collisionId, int); //! -DECLARE_SOA_COLUMN(FwdTrackId, fwdtrackId, int); //! -DECLARE_SOA_SELF_INDEX_COLUMN_FULL(MCHTrack, matchMCHTrack, int, "EMPRIMARYMUs_MatchMCHTrack"); //! Index of matched MCH track for GlobalMuonTracks and GlobalForwardTracks +DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! +DECLARE_SOA_COLUMN(CollisionId, collisionId, int); //! +DECLARE_SOA_COLUMN(FwdTrackId, fwdtrackId, int); //! +DECLARE_SOA_COLUMN(MFTTrackId, mfttrackId, int); //! +DECLARE_SOA_COLUMN(MCHTrackId, mchtrackId, int); //! +DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(GlobalMuonsWithSameMFT, globalMuonsWithSameMFT); //! self indices to global muons that have the same MFTTrackId DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(AmbiguousMuons, ambiguousMuons); +DECLARE_SOA_COLUMN(CXXatDCA, cXXatDCA, float); //! DCAx resolution squared at DCA +DECLARE_SOA_COLUMN(CYYatDCA, cYYatDCA, float); //! DCAy resolution squared at DCA +DECLARE_SOA_COLUMN(CXYatDCA, cXYatDCA, float); //! correlation term of DCAx,y resolution at DCA +DECLARE_SOA_COLUMN(PtMatchedMCHMID, ptMatchedMCHMID, float); //! pt of MCH-MID track in MFT-MCH-MID track at PV +DECLARE_SOA_COLUMN(EtaMatchedMCHMID, etaMatchedMCHMID, float); //! eta of MCH-MID track in MFT-MCH-MID track at PV +DECLARE_SOA_COLUMN(PhiMatchedMCHMID, phiMatchedMCHMID, float); //! phi of MCH-MID track in MFT-MCH-MID track at PV DECLARE_SOA_COLUMN(IsAssociatedToMPC, isAssociatedToMPC, bool); //! is associated to most probable collision +DECLARE_SOA_COLUMN(IsAmbiguous, isAmbiguous, bool); //! is ambiguous DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! -DECLARE_SOA_COLUMN(Chi2MFTsa, chi2MFTsa, float); //! chi2 of MFT standalone track +DECLARE_SOA_COLUMN(Chi2MFT, chi2MFT, float); //! chi2 of MFT standalone track DECLARE_SOA_DYNAMIC_COLUMN(Signed1Pt, signed1Pt, [](float pt, int8_t sign) -> float { return sign * 1. / pt; }); DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float pt, float eta) -> float { return pt * std::cosh(eta); }); DECLARE_SOA_DYNAMIC_COLUMN(Px, px, [](float pt, float phi) -> float { return pt * std::cos(phi); }); DECLARE_SOA_DYNAMIC_COLUMN(Py, py, [](float pt, float phi) -> float { return pt * std::sin(phi); }); DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, [](float pt, float eta) -> float { return pt * std::sinh(eta); }); -DECLARE_SOA_DYNAMIC_COLUMN(Theta, theta, [](float tgl) -> float { return M_PI_2 - std::atan(tgl); }); -DECLARE_SOA_DYNAMIC_COLUMN(DcaXY, dcaXY, [](float dcaX, float dcaY) -> float { return std::sqrt(dcaX * dcaX + dcaY * dcaY); }); DECLARE_SOA_DYNAMIC_COLUMN(NClustersMFT, nClustersMFT, //! Number of MFT clusters [](uint64_t mftClusterSizesAndTrackFlags) -> uint8_t { uint8_t nClusters = 0; @@ -567,17 +764,16 @@ DECLARE_SOA_DYNAMIC_COLUMN(MFTClusterMap, mftClusterMap, //! MFT cluster map, on } // namespace emprimarymuon DECLARE_SOA_TABLE(EMPrimaryMuons, "AOD", "EMPRIMARYMU", //! o2::soa::Index<>, emprimarymuon::CollisionId, - emprimarymuon::FwdTrackId, fwdtrack::TrackType, + emprimarymuon::FwdTrackId, emprimarymuon::MFTTrackId, emprimarymuon::MCHTrackId, fwdtrack::TrackType, fwdtrack::Pt, fwdtrack::Eta, fwdtrack::Phi, emprimarymuon::Sign, - fwdtrack::FwdDcaX, fwdtrack::FwdDcaY, - fwdtrack::X, fwdtrack::Y, fwdtrack::Z, fwdtrack::Tgl, + fwdtrack::FwdDcaX, fwdtrack::FwdDcaY, emprimarymuon::CXXatDCA, emprimarymuon::CYYatDCA, emprimarymuon::CXYatDCA, + emprimarymuon::PtMatchedMCHMID, emprimarymuon::EtaMatchedMCHMID, emprimarymuon::PhiMatchedMCHMID, + // fwdtrack::X, fwdtrack::Y, fwdtrack::Z, fwdtrack::Tgl, fwdtrack::NClusters, fwdtrack::PDca, fwdtrack::RAtAbsorberEnd, fwdtrack::Chi2, fwdtrack::Chi2MatchMCHMID, fwdtrack::Chi2MatchMCHMFT, - // fwdtrack::MatchScoreMCHMFT, fwdtrack::MFTTrackId, fwdtrack::MCHTrackId, - emprimarymuon::MCHTrackId, fwdtrack::MCHBitMap, fwdtrack::MIDBitMap, fwdtrack::MIDBoards, - fwdtrack::MFTClusterSizesAndTrackFlags, emprimarymuon::Chi2MFTsa, emprimarymuon::IsAssociatedToMPC, + fwdtrack::MFTClusterSizesAndTrackFlags, emprimarymuon::Chi2MFT, emprimarymuon::IsAssociatedToMPC, emprimarymuon::IsAmbiguous, // dynamic column emprimarymuon::Signed1Pt, @@ -586,9 +782,7 @@ DECLARE_SOA_TABLE(EMPrimaryMuons, "AOD", "EMPRIMARYMU", //! emprimarymuon::P, emprimarymuon::Px, emprimarymuon::Py, - emprimarymuon::Pz, - emprimarymuon::Theta, - emprimarymuon::DcaXY); + emprimarymuon::Pz); // iterators using EMPrimaryMuon = EMPrimaryMuons::iterator; @@ -619,6 +813,75 @@ DECLARE_SOA_TABLE(EMAmbiguousMuonSelfIds, "AOD", "EMAMBMUSELFID", emprimarymuon: // iterators using EMAmbiguousMuonSelfId = EMAmbiguousMuonSelfIds::iterator; +DECLARE_SOA_TABLE(EMGlobalMuonSelfIds, "AOD", "EMGLMUSELFID", emprimarymuon::GlobalMuonsWithSameMFTIds); // To be joined with EMPrimaryMuons table at analysis level. +// iterators +using EMGlobalMuonSelfId = EMGlobalMuonSelfIds::iterator; + +namespace emprimarytrack +{ +DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! +DECLARE_SOA_COLUMN(CollisionId, collisionId, int); //! +DECLARE_SOA_COLUMN(TrackId, trackId, int); //! +DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! +DECLARE_SOA_COLUMN(TrackBit, trackBit, uint16_t); //! +} // namespace emprimarytrack + +DECLARE_SOA_TABLE_VERSIONED(EMPrimaryTracks_000, "AOD", "EMPRIMARYTRACK", 0, //! primary charged track table for 2PC + o2::soa::Index<>, emprimarytrack::CollisionId, emprimarytrack::TrackId, emprimarytrack::Sign, track::Pt, track::Eta, track::Phi, emprimarytrack::TrackBit); + +using EMPrimaryTracks = EMPrimaryTracks_000; +// iterators +using EMPrimaryTrack = EMPrimaryTracks::iterator; + +DECLARE_SOA_TABLE(EMPrimaryTrackEMEventIds, "AOD", "PRMTRKEMEVENTID", emprimarytrack::EMEventId); // To be joined with EMPrimaryTracks table at analysis level. +// iterators +using EMPrimaryTrackEMEventId = EMPrimaryTrackEMEventIds::iterator; + +DECLARE_SOA_TABLE(EMPrimaryTrackEMEventIdsTMP, "AOD", "PRMTRKEVIDTMP", track::CollisionId); // To be joined with EMPrimaryTracks in associateDileptonToEMEvent +// iterators +using EMPrimaryTrackEMEventIdTMP = EMPrimaryTrackEMEventIdsTMP::iterator; + +// Dummy data for MC +namespace emdummydata +{ +DECLARE_SOA_COLUMN(A, a, float); +DECLARE_SOA_COLUMN(B, b, float); +DECLARE_SOA_COLUMN(C, c, float); +DECLARE_SOA_COLUMN(D, d, float); +DECLARE_SOA_COLUMN(E, e, float); +DECLARE_SOA_COLUMN(F, f, float); +DECLARE_SOA_COLUMN(G, g, float); +DECLARE_SOA_COLUMN(H, h, float); +DECLARE_SOA_COLUMN(I, i, float); +DECLARE_SOA_COLUMN(J, j, float); +DECLARE_SOA_COLUMN(K, k, float); +DECLARE_SOA_COLUMN(L, l, float); +DECLARE_SOA_COLUMN(M, m, float); +DECLARE_SOA_COLUMN(N, n, float); +DECLARE_SOA_COLUMN(O, o, float); +DECLARE_SOA_COLUMN(P, p, float); +DECLARE_SOA_COLUMN(Q, q, float); +DECLARE_SOA_COLUMN(R, r, float); +DECLARE_SOA_COLUMN(S, s, float); +DECLARE_SOA_COLUMN(T, t, float); +DECLARE_SOA_COLUMN(U, u, float); +DECLARE_SOA_COLUMN(V, v, float); +DECLARE_SOA_COLUMN(W, w, float); +DECLARE_SOA_COLUMN(X, x, float); +DECLARE_SOA_COLUMN(Y, y, float); +DECLARE_SOA_COLUMN(Z, z, float); +} // namespace emdummydata +DECLARE_SOA_TABLE(EMDummyDatas, "AOD", "EMDUMMYDATA", + o2::soa::Index<>, + emdummydata::A, emdummydata::B, emdummydata::C, emdummydata::D, emdummydata::E, + emdummydata::F, emdummydata::G, emdummydata::H, emdummydata::I, emdummydata::J, + emdummydata::K, emdummydata::L, emdummydata::M, emdummydata::N, emdummydata::O, + emdummydata::P, emdummydata::Q, emdummydata::R, emdummydata::S, emdummydata::T, + emdummydata::U, emdummydata::V, emdummydata::W, emdummydata::X, emdummydata::Y, + emdummydata::Z); + +// iterators +using EMDummyData = EMDummyDatas::iterator; } // namespace o2::aod #endif // PWGEM_DILEPTON_DATAMODEL_DILEPTONTABLES_H_ diff --git a/PWGEM/Dilepton/DataModel/lmeeMLTables.h b/PWGEM/Dilepton/DataModel/lmeeMLTables.h index 1c925cf9bc7..f2000b0f4a4 100644 --- a/PWGEM/Dilepton/DataModel/lmeeMLTables.h +++ b/PWGEM/Dilepton/DataModel/lmeeMLTables.h @@ -9,14 +9,15 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include "Framework/AnalysisDataModel.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/AnalysisDataModel.h" + +#include #ifndef PWGEM_DILEPTON_DATAMODEL_LMEEMLTABLES_H_ #define PWGEM_DILEPTON_DATAMODEL_LMEEMLTABLES_H_ @@ -24,32 +25,34 @@ namespace o2::aod { -namespace pwgem::dilepton +namespace pwgem::dilepton::ml { -enum class PID_Label : int { - kUnDef = -1, +enum class PID_Label : uint8_t { kElectron = 0, kMuon = 1, kPion = 2, kKaon = 3, kProton = 4, -}; // this can be used for eID with ITSsa. +}; // this can be used for eID. -enum class Track_Type : int { +enum class Track_Type : uint8_t { kPrimary = 0, kSecondary = 1, }; // this can be used for selecting electron from primary or photon conversion. -} // namespace pwgem::dilepton +} // namespace pwgem::dilepton::ml -namespace emprimarytrack +namespace emmltrack { -DECLARE_SOA_COLUMN(CollisionId, collisionId, int); //! -DECLARE_SOA_COLUMN(PIDLabel, pidlabel, int); //! -DECLARE_SOA_COLUMN(TrackType, tracktype, int); //! -DECLARE_SOA_COLUMN(TPCNClsFound, tpcNClsFound, int); //! -DECLARE_SOA_COLUMN(TPCNClsCrossedRows, tpcNClsCrossedRows, int); //! -DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float pt, float eta) -> float { return pt * std::cosh(eta); }); +DECLARE_SOA_COLUMN(CollisionId, collisionId, int); //! +DECLARE_SOA_COLUMN(PIDLabel, pidlabel, uint8_t); //! +DECLARE_SOA_COLUMN(TrackType, tracktype, uint8_t); //! +DECLARE_SOA_COLUMN(TPCNClsFound, tpcNClsFound, uint8_t); //! +DECLARE_SOA_COLUMN(TPCNClsCrossedRows, tpcNClsCrossedRows, uint8_t); //! +DECLARE_SOA_COLUMN(IsForValidation, isForValidation, bool); //! +DECLARE_SOA_COLUMN(Sign, sign, short); //! +DECLARE_SOA_COLUMN(P, p, float); //! +// DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float pt, float eta) -> float { return pt * std::cosh(eta); }); DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITS, meanClusterSizeITS, [](uint32_t itsClusterSizes) -> float { int total_cluster_size = 0, nl = 0; for (unsigned int layer = 0; layer < 7; layer++) { @@ -65,25 +68,39 @@ DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITS, meanClusterSizeITS, [](uint32_t i return 0; } }); -} // namespace emprimarytrack +DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITSob, meanClusterSizeITSob, [](uint32_t itsClusterSizes) -> float { + int total_cluster_size = 0, nl = 0; + for (unsigned int layer = 3; layer < 7; layer++) { + int cluster_size_per_layer = (itsClusterSizes >> (layer * 4)) & 0xf; + if (cluster_size_per_layer > 0) { + nl++; + } + total_cluster_size += cluster_size_per_layer; + } + if (nl > 0) { + return static_cast(total_cluster_size) / static_cast(nl); + } else { + return 0; + } +}); +} // namespace emmltrack // reconstructed track information -DECLARE_SOA_TABLE(EMPrimaryTracks, "AOD", "EMPTRACK", //! - o2::soa::Index<>, emprimarytrack::CollisionId, collision::PosZ, collision::NumContrib, - track::Pt, track::Eta, track::Phi, track::Tgl, track::Signed1Pt, - track::DcaXY, track::DcaZ, track::CYY, track::CZZ, track::CZY, - track::TPCNClsFindable, emprimarytrack::TPCNClsFound, emprimarytrack::TPCNClsCrossedRows, +DECLARE_SOA_TABLE(EMTracksForMLPID, "AOD", "EMTRACKMLPID", //! + o2::soa::Index<>, collision::NumContrib, evsel::NumTracksInTimeRange, evsel::SumAmpFT0CInTimeRange, + emmltrack::P, track::Tgl, emmltrack::Sign, + track::TPCNClsFindable, emmltrack::TPCNClsFound, emmltrack::TPCNClsCrossedRows, track::TPCChi2NCl, track::TPCInnerParam, - track::TPCSignal, pidtpc::TPCNSigmaEl, pidtpc::TPCNSigmaMu, pidtpc::TPCNSigmaPi, pidtpc::TPCNSigmaKa, pidtpc::TPCNSigmaPr, - pidtofbeta::Beta, pidtof::TOFNSigmaEl, pidtof::TOFNSigmaMu, pidtof::TOFNSigmaPi, pidtof::TOFNSigmaKa, pidtof::TOFNSigmaPr, - track::ITSClusterSizes, track::ITSChi2NCl, track::TOFChi2, track::DetectorMap, emprimarytrack::PIDLabel, emprimarytrack::TrackType, + track::TPCSignal, pidtpc::TPCNSigmaEl, pidtpc::TPCNSigmaPi, pidtpc::TPCNSigmaKa, pidtpc::TPCNSigmaPr, + pidtofbeta::Beta, pidtof::TOFNSigmaEl, pidtof::TOFNSigmaPi, pidtof::TOFNSigmaKa, pidtof::TOFNSigmaPr, + track::ITSClusterSizes, track::ITSChi2NCl, track::TOFChi2, track::DetectorMap, emmltrack::PIDLabel, // dynamic column - emprimarytrack::P, - emprimarytrack::MeanClusterSizeITS); + emmltrack::MeanClusterSizeITS, + emmltrack::MeanClusterSizeITSob); // iterators -using EMPrimaryTrack = EMPrimaryTracks::iterator; +using EMTrackForMLPID = EMTracksForMLPID::iterator; } // namespace o2::aod diff --git a/PWGEM/Dilepton/TableProducer/CMakeLists.txt b/PWGEM/Dilepton/TableProducer/CMakeLists.txt index c95928b3eb1..d234ee0d2b4 100644 --- a/PWGEM/Dilepton/TableProducer/CMakeLists.txt +++ b/PWGEM/Dilepton/TableProducer/CMakeLists.txt @@ -22,7 +22,7 @@ o2physics_add_dpl_workflow(tree-creator-electron-ml-dda o2physics_add_dpl_workflow(skimmer-primary-electron SOURCES skimmerPrimaryElectron.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(skimmer-primary-muon @@ -30,8 +30,8 @@ o2physics_add_dpl_workflow(skimmer-primary-muon PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::GlobalTracking COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(skimmer-secondary-electron - SOURCES skimmerSecondaryElectron.cxx +o2physics_add_dpl_workflow(skimmer-primary-track + SOURCES skimmerPrimaryTrack.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -50,11 +50,6 @@ o2physics_add_dpl_workflow(associate-mc-info-dilepton PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(filter-dielectron-event - SOURCES filterDielectronEvent.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(event-selection SOURCES eventSelection.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore diff --git a/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx b/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx index 6cf6b0865d0..52867a7609d 100644 --- a/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx +++ b/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx @@ -14,25 +14,27 @@ // This code produces reduced events for photon analyses. // Please write to: daiki.sekihata@cern.ch -#include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/TableHelper.h" #include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "Common/Core/TableHelper.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -using MyCollisionsMC = soa::Join; -using TracksMC = soa::Join; -using FwdTracksMC = soa::Join; - struct AssociateMCInfoDilepton { enum SubSystem { kElectron = 0x1, @@ -40,6 +42,11 @@ struct AssociateMCInfoDilepton { kPCM = 0x4, }; + using MyCollisionsMC = soa::Join; + using TracksMC = soa::Join; + using FwdTracksMC = soa::Join; + using MFTTracksMC = soa::Join; + Produces mcevents; Produces mceventlabels; Produces emmcparticles; @@ -47,13 +54,16 @@ struct AssociateMCInfoDilepton { Produces v0legmclabels; Produces emprimaryelectronmclabels; Produces emprimarymuonmclabels; + Produces emmftmclabels; + Produces emdummydata; - Configurable down_scaling_omega{"down_scaling_omega", 1.0, "down scaling factor to store omega"}; - Configurable down_scaling_phi{"down_scaling_phi", 1.0, "down scaling factor to store phi"}; - Configurable min_eta_gen_primary{"min_eta_gen_primary", -1.2, "min rapidity Y to store generated information"}; // smearing might be applied at analysis stage. set wider value. - Configurable max_eta_gen_primary{"max_eta_gen_primary", +1.2, "max rapidity Y to store generated information"}; // smearing might be applied at analysis stage. set wider value. - Configurable min_eta_gen_primary_fwd{"min_eta_gen_primary_fwd", -4.5, "min eta to store generated information"}; // smearing might be applied at analysis stage. set wider value. - Configurable max_eta_gen_primary_fwd{"max_eta_gen_primary_fwd", -2.0, "max eta to store generated information"}; // smearing might be applied at analysis stage. set wider value. + Configurable n_dummy_loop{"n_dummy_loop", 0, "for loop runs over n times"}; + Configurable down_scaling_omega{"down_scaling_omega", 1.1, "down scaling factor to store omega"}; + Configurable down_scaling_phi{"down_scaling_phi", 1.1, "down scaling factor to store phi"}; + Configurable min_eta_gen_primary{"min_eta_gen_primary", -1.5, "min rapidity Y to store generated information"}; // smearing is applied at analysis stage. set wider value. + Configurable max_eta_gen_primary{"max_eta_gen_primary", +1.5, "max rapidity Y to store generated information"}; // smearing is applied at analysis stage. set wider value. + Configurable min_eta_gen_primary_fwd{"min_eta_gen_primary_fwd", -5.0, "min eta to store generated information"}; // smearing is applied at analysis stage. set wider value. + Configurable max_eta_gen_primary_fwd{"max_eta_gen_primary_fwd", -1.5, "max eta to store generated information"}; // smearing is applied at analysis stage. set wider value. HistogramRegistry registry{"EMMCEvent"}; std::mt19937 engine; @@ -129,8 +139,8 @@ struct AssociateMCInfoDilepton { Partition mcmuons = nabs(o2::aod::mcparticle::pdgCode) == 13 && min_eta_gen_primary_fwd < o2::aod::mcparticle::eta && o2::aod::mcparticle::eta < max_eta_gen_primary_fwd; Partition mcvectormesons = o2::aod::mcparticle::pdgCode == 223 || o2::aod::mcparticle::pdgCode == 333; - template - void skimmingMC(MyCollisionsMC const& collisions, aod::BCs const&, aod::McCollisions const& mcCollisions, aod::McParticles const& mcTracks, TTracks const& o2tracks, TFwdTracks const& o2fwdtracks, TPCMs const& v0photons, TPCMLegs const& /*v0legs*/, TEMPrimaryElectrons const& emprimaryelectrons, TEMPrimaryMuons const& emprimarymuons) + template + void skimmingMC(MyCollisionsMC const& collisions, aod::BCs const&, aod::McCollisions const& mcCollisions, aod::McParticles const& mcTracks, TTracks const& o2tracks, TFwdTracks const& o2fwdtracks, TMFTTracks const&, TPCMs const& v0photons, TPCMLegs const&, TEMPrimaryElectrons const& emprimaryelectrons, TEMPrimaryMuons const& emprimarymuons) { // temporary variables used for the indexing of the skimmed MC stack std::map fNewLabels; @@ -141,7 +151,7 @@ struct AssociateMCInfoDilepton { int fCounters[2] = {0, 0}; //! [0] - particle counter, [1] - event counter // first, run loop over mc collisions to create map between aod::McCollisions and aod::EMMCEvents - for (auto& mcCollision : mcCollisions) { + for (const auto& mcCollision : mcCollisions) { // make an entry for this MC event only if it was not already added to the table if (!(fEventLabels.find(mcCollision.globalIndex()) != fEventLabels.end())) { mcevents(mcCollision.globalIndex(), mcCollision.generatorsID(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.impactParameter(), mcCollision.eventPlaneAngle()); @@ -150,7 +160,7 @@ struct AssociateMCInfoDilepton { } } // end of mc collision loop - for (auto& collision : collisions) { + for (const auto& collision : collisions) { registry.fill(HIST("hEventCounter"), 1); // TODO: investigate the collisions without corresponding mcCollision @@ -168,13 +178,13 @@ struct AssociateMCInfoDilepton { } // end of reconstructed collision loop - for (auto& mcCollision : mcCollisions) { + for (const auto& mcCollision : mcCollisions) { // store MC true information auto mcelectrons_per_mccollision = mcelectrons.sliceBy(perMcCollision, mcCollision.globalIndex()); auto mcmuons_per_mccollision = mcmuons.sliceBy(perMcCollision, mcCollision.globalIndex()); auto mcvectormesons_per_mccollision = mcvectormesons.sliceBy(perMcCollision, mcCollision.globalIndex()); - for (auto& mctrack : mcelectrons_per_mccollision) { // store necessary information for denominator of efficiency + for (const auto& mctrack : mcelectrons_per_mccollision) { // store necessary information for denominator of efficiency if (!mctrack.isPhysicalPrimary() && !mctrack.producedByGenerator()) { continue; } @@ -226,7 +236,7 @@ struct AssociateMCInfoDilepton { } // end of ndau protection } // end of mc electron loop - for (auto& mctrack : mcmuons_per_mccollision) { // store necessary information for denominator of efficiency + for (const auto& mctrack : mcmuons_per_mccollision) { // store necessary information for denominator of efficiency if (!mctrack.isPhysicalPrimary() && !mctrack.producedByGenerator()) { continue; } @@ -278,7 +288,7 @@ struct AssociateMCInfoDilepton { } // end of ndau protection } // end of mc muon loop - for (auto& mctrack : mcvectormesons_per_mccollision) { // store necessary information for denominator of efficiency + for (const auto& mctrack : mcvectormesons_per_mccollision) { // store necessary information for denominator of efficiency // Be careful!! dilepton rapidity is different from meson rapidity! No acceptance cut here. if (!mctrack.isPhysicalPrimary() && !mctrack.producedByGenerator()) { @@ -309,7 +319,7 @@ struct AssociateMCInfoDilepton { // TODO: remove this check as soon as issues with MC production are fixed if (d < mcTracks.size()) { // protect against bad daughter indices auto daughter = mcTracks.iteratorAt(d); - if (abs(daughter.pdgCode()) == 11 || abs(daughter.pdgCode()) == 13) { + if (std::abs(daughter.pdgCode()) == 11 || std::abs(daughter.pdgCode()) == 13) { is_lepton_involved = true; break; } @@ -346,14 +356,14 @@ struct AssociateMCInfoDilepton { } // end of mc collision loop if constexpr (static_cast(system & kPCM)) { - for (auto& v0 : v0photons) { + for (const auto& v0 : v0photons) { auto collision_from_v0 = collisions.iteratorAt(v0.collisionId()); if (!collision_from_v0.has_mcCollision()) { continue; } - auto ele = v0.template negTrack_as(); - auto pos = v0.template posTrack_as(); + auto ele = v0.template negTrack_as(); + auto pos = v0.template posTrack_as(); auto o2track_ele = o2tracks.iteratorAt(ele.trackId()); auto o2track_pos = o2tracks.iteratorAt(pos.trackId()); @@ -362,7 +372,7 @@ struct AssociateMCInfoDilepton { continue; // If no MC particle is found, skip the v0 } - for (auto& leg : {pos, ele}) { // be carefull of order {pos, ele}! + for (const auto& leg : {pos, ele}) { // be carefull of order {pos, ele}! auto o2track = o2tracks.iteratorAt(leg.trackId()); auto mctrack = o2track.template mcParticle_as(); // LOGF(info, "mctrack.globalIndex() = %d, mctrack.index() = %d", mctrack.globalIndex(), mctrack.index()); // these are exactly the same. @@ -410,7 +420,7 @@ struct AssociateMCInfoDilepton { if constexpr (static_cast(system & kElectron)) { // auto emprimaryelectrons_coll = emprimaryelectrons.sliceBy(perCollision_el, collision.globalIndex()); - for (auto& emprimaryelectron : emprimaryelectrons) { + for (const auto& emprimaryelectron : emprimaryelectrons) { auto collision_from_el = collisions.iteratorAt(emprimaryelectron.collisionId()); if (!collision_from_el.has_mcCollision()) { continue; @@ -465,7 +475,7 @@ struct AssociateMCInfoDilepton { if constexpr (static_cast(system & kFwdMuon)) { // auto emprimarymuons_coll = emprimarymuons.sliceBy(perCollision_mu, collision.globalIndex()); - for (auto& emprimarymuon : emprimarymuons) { + for (const auto& emprimarymuon : emprimarymuons) { auto collision_from_mu = collisions.iteratorAt(emprimarymuon.collisionId()); if (!collision_from_mu.has_mcCollision()) { continue; @@ -515,6 +525,54 @@ struct AssociateMCInfoDilepton { } } // end of mother chain loop + // mc label for tracks registered in MFT in global muons + if (o2track.matchMFTTrackId() > -1) { + const auto& o2mfttrack = o2track.template matchMFTTrack_as(); + if (!o2mfttrack.has_mcParticle()) { + emmftmclabels(-1, 0); + break; + } + + const auto& mco2mfttrack = o2mfttrack.template mcParticle_as(); + if (!(fNewLabels.find(mco2mfttrack.globalIndex()) != fNewLabels.end())) { + fNewLabels[mco2mfttrack.globalIndex()] = fCounters[0]; + fNewLabelsReversed[fCounters[0]] = mco2mfttrack.globalIndex(); + // fMCFlags[mco2mfttrack.globalIndex()] = mcflags; + fEventIdx[mco2mfttrack.globalIndex()] = fEventLabels.find(mco2mfttrack.mcCollisionId())->second; + fCounters[0]++; + } + emmftmclabels(fNewLabels.find(mco2mfttrack.index())->second, o2track.mcMask()); + + // Next, store mother-chain of this reconstructed track. + int motherid = -999; // first mother index + if (mctrack.has_mothers()) { + motherid = mctrack.mothersIds()[0]; // first mother index + } + while (motherid > -1) { + if (motherid < mcTracks.size()) { // protect against bad mother indices. why is this needed? + auto mp = mcTracks.iteratorAt(motherid); + + // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack + if (!(fNewLabels.find(mp.globalIndex()) != fNewLabels.end())) { + fNewLabels[mp.globalIndex()] = fCounters[0]; + fNewLabelsReversed[fCounters[0]] = mp.globalIndex(); + // fMCFlags[mp.globalIndex()] = mcflags; + fEventIdx[mp.globalIndex()] = fEventLabels.find(mp.mcCollisionId())->second; + fCounters[0]++; + } + + if (mp.has_mothers()) { + motherid = mp.mothersIds()[0]; // first mother index + } else { + motherid = -999; + } + } else { + motherid = -999; + } + } // end of mother chain loop + } else { + emmftmclabels(-1, 0); + } } // end of em primary muon loop } @@ -525,7 +583,7 @@ struct AssociateMCInfoDilepton { std::vector mothers; if (mctrack.has_mothers()) { - for (auto& m : mctrack.mothersIds()) { + for (const auto& m : mctrack.mothersIds()) { if (m < mcTracks.size()) { // protect against bad mother indices if (fNewLabels.find(m) != fNewLabels.end()) { mothers.push_back(fNewLabels.find(m)->second); @@ -575,9 +633,9 @@ struct AssociateMCInfoDilepton { } // end loop over labels // only for omega, phi mesons - for (auto& mcCollision : mcCollisions) { + for (const auto& mcCollision : mcCollisions) { auto mcvectormesons_per_mccollision = mcvectormesons.sliceBy(perMcCollision, mcCollision.globalIndex()); - for (auto& mctrack : mcvectormesons_per_mccollision) { // store necessary information for denominator of efficiency + for (const auto& mctrack : mcvectormesons_per_mccollision) { // store necessary information for denominator of efficiency if (!mctrack.isPhysicalPrimary() && !mctrack.producedByGenerator()) { continue; } @@ -606,36 +664,49 @@ struct AssociateMCInfoDilepton { void processMC_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::EMPrimaryElectrons const& emprimaryelectrons) { const uint8_t sysflag = kElectron; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, nullptr, nullptr, emprimaryelectrons, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, nullptr, nullptr, nullptr, emprimaryelectrons, nullptr); } - void processMC_FwdMuon(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, FwdTracksMC const& o2fwdtracks, aod::EMPrimaryMuons const& emprimarymuons) + void processMC_FwdMuon(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, FwdTracksMC const& o2fwdtracks, MFTTracksMC const& o2mfttracks, aod::EMPrimaryMuons const& emprimarymuons) { const uint8_t sysflag = kFwdMuon; - skimmingMC(collisions, bcs, mccollisions, mcTracks, nullptr, o2fwdtracks, nullptr, nullptr, nullptr, emprimarymuons); + skimmingMC(collisions, bcs, mccollisions, mcTracks, nullptr, o2fwdtracks, o2mfttracks, nullptr, nullptr, nullptr, emprimarymuons); } - void processMC_Electron_FwdMuon(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, FwdTracksMC const& o2fwdtracks, aod::EMPrimaryElectrons const& emprimaryelectrons, aod::EMPrimaryMuons const& emprimarymuons) + void processMC_Electron_FwdMuon(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, FwdTracksMC const& o2fwdtracks, MFTTracksMC const& o2mfttracks, aod::EMPrimaryElectrons const& emprimaryelectrons, aod::EMPrimaryMuons const& emprimarymuons) { const uint8_t sysflag = kElectron | kFwdMuon; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, o2fwdtracks, nullptr, nullptr, emprimaryelectrons, emprimarymuons); + skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, o2fwdtracks, o2mfttracks, nullptr, nullptr, emprimaryelectrons, emprimarymuons); } - void processMC_Electron_FwdMuon_PCM(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, FwdTracksMC const& o2fwdtracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::EMPrimaryElectrons const& emprimaryelectrons, aod::EMPrimaryMuons const& emprimarymuons) + void processMC_Electron_FwdMuon_PCM(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, FwdTracksMC const& o2fwdtracks, MFTTracksMC const& o2mfttracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::EMPrimaryElectrons const& emprimaryelectrons, aod::EMPrimaryMuons const& emprimarymuons) { const uint8_t sysflag = kPCM | kElectron | kFwdMuon; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, o2fwdtracks, v0photons, v0legs, emprimaryelectrons, emprimarymuons); + skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, o2fwdtracks, o2mfttracks, v0photons, v0legs, emprimaryelectrons, emprimarymuons); } void processMC_Electron_PCM(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::EMPrimaryElectrons const& emprimaryelectrons) { const uint8_t sysflag = kPCM | kElectron; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, emprimaryelectrons, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, nullptr, v0photons, v0legs, emprimaryelectrons, nullptr); } void processMC_PCM(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs) { - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, nullptr, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, nullptr, v0photons, v0legs, nullptr, nullptr); + } + + void processGenDummy(MyCollisionsMC const&) + { + for (int i = 0; i < n_dummy_loop; i++) { + emdummydata( + 0.f, 0.f, 0.f, 0.f, 0.f, + 0.f, 0.f, 0.f, 0.f, 0.f, + 0.f, 0.f, 0.f, 0.f, 0.f, + 0.f, 0.f, 0.f, 0.f, 0.f, + 0.f, 0.f, 0.f, 0.f, 0.f, + 0.f); + } } void processDummy(MyCollisionsMC const&) {} @@ -646,6 +717,7 @@ struct AssociateMCInfoDilepton { PROCESS_SWITCH(AssociateMCInfoDilepton, processMC_Electron_FwdMuon_PCM, "create em mc event table for PCM, Electron, FwdMuon", false); PROCESS_SWITCH(AssociateMCInfoDilepton, processMC_Electron_PCM, "create em mc event table for PCM, Electron", false); PROCESS_SWITCH(AssociateMCInfoDilepton, processMC_PCM, "create em mc event table for PCM", false); + PROCESS_SWITCH(AssociateMCInfoDilepton, processGenDummy, "produce dummy data", false); PROCESS_SWITCH(AssociateMCInfoDilepton, processDummy, "processDummy", true); }; diff --git a/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx b/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx index 5d57b999491..b8575494195 100644 --- a/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx +++ b/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx @@ -14,24 +14,25 @@ // This code produces reduced events for photon analyses. // Please write to: daiki.sekihata@cern.ch -#include +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" +#include "Common/Core/TableHelper.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" -#include "Common/Core/TableHelper.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include using namespace o2; +using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; @@ -52,7 +53,9 @@ using MyCollisionsMC_Cent = soa::Join; struct CreateEMEventDilepton { + Produces embc; Produces event; + Produces eventXY; // Produces eventcov; Produces event_mult; Produces event_cent; @@ -133,14 +136,23 @@ struct CreateEMEventDilepton { mRunNumber = bc.runNumber(); } - Preslice perCollision_pcm = aod::v0photonkf::collisionId; - PresliceUnsorted perCollision_el = aod::emprimaryelectron::collisionId; - PresliceUnsorted perCollision_mu = aod::emprimarymuon::collisionId; + Preslice perBC = aod::collision::bcId; + // Preslice perCollision_pcm = aod::v0photonkf::collisionId; + // PresliceUnsorted perCollision_el = aod::emprimaryelectron::collisionId; + // PresliceUnsorted perCollision_mu = aod::emprimarymuon::collisionId; template - void skimEvent(TCollisions const& collisions, TBCs const&) + void skimEvent(TCollisions const& collisions, TBCs const& bcs) { - for (auto& collision : collisions) { + for (const auto& bc : bcs) { + if (bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + // const auto& collisions_perBC = collisions.sliceBy(perBC, bc.globalIndex()); + // embc(bc.selection_bit(o2::aod::evsel::kIsTriggerTVX), bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder), bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder), static_cast(collisions_perBC.size() > 0)); // TVX is fired. + embc(bc.alias_raw(), bc.selection_raw(), bc.rct_raw()); // TVX is fired. + } + } // end of bc loop + + for (const auto& collision : collisions) { if constexpr (isMC) { if (!collision.has_mcCollision()) { continue; @@ -151,15 +163,19 @@ struct CreateEMEventDilepton { auto bc = collision.template foundBC_as(); initCCDB(bc); + if (!collision.isSelected()) { // minimal cut for MB + continue; + } + if constexpr (eventtype == EMEventType::kEvent) { - event_norm_info(collision.alias_raw(), collision.selection_raw(), static_cast(10.f * collision.posZ()), 105.f); + event_norm_info(collision.alias_raw(), collision.selection_raw(), collision.rct_raw(), static_cast(10.f * collision.posZ()), 105.f); } else if constexpr (eventtype == EMEventType::kEvent_Cent || eventtype == EMEventType::kEvent_Cent_Qvec) { - event_norm_info(collision.alias_raw(), collision.selection_raw(), static_cast(10.f * collision.posZ()), collision.centFT0C()); + event_norm_info(collision.alias_raw(), collision.selection_raw(), collision.rct_raw(), static_cast(10.f * collision.posZ()), collision.centFT0C()); } else { - event_norm_info(collision.alias_raw(), collision.selection_raw(), static_cast(10.f * collision.posZ()), 105.f); + event_norm_info(collision.alias_raw(), collision.selection_raw(), collision.rct_raw(), static_cast(10.f * collision.posZ()), 105.f); } - if (!collision.isSelected() || !collision.isEoI()) { + if (!collision.isEoI()) { // events with at least 1 lepton for data reduction. continue; } @@ -173,10 +189,12 @@ struct CreateEMEventDilepton { registry.fill(HIST("hEventCounter"), 2); - event(collision.globalIndex(), bc.runNumber(), bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), - collision.posX(), collision.posY(), collision.posZ(), + event(collision.globalIndex(), bc.runNumber(), bc.globalBC(), collision.alias_raw(), collision.selection_raw(), collision.rct_raw(), bc.timestamp(), + collision.posZ(), collision.numContrib(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); + eventXY(collision.posX(), collision.posY()); + // eventcov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); event_mult(collision.multFT0A(), collision.multFT0C(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); @@ -284,17 +302,20 @@ struct AssociateDileptonToEMEvent { Produces v0kfeventid; Produces prmeleventid; Produces prmmueventid; + Produces prmtrackeventid; Preslice perCollision_pcm = aod::v0photonkf::collisionId; PresliceUnsorted perCollision_el = aod::emprimaryelectron::collisionId; PresliceUnsorted perCollision_mu = aod::emprimarymuon::collisionId; + Preslice perCollision_track = aod::emprimarytrack::collisionId; + // Preslice perCollision_track = aod::track::collisionId; void init(o2::framework::InitContext&) {} template void fillEventId(TCollisions const& collisions, TLeptons const& leptons, TEventIds& eventIds, TPreslice const& perCollision) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto leptons_coll = leptons.sliceBy(perCollision, collision.collisionId()); int nl = leptons_coll.size(); // LOGF(info, "collision.collisionId() = %d , nl = %d", collision.collisionId(), nl); @@ -322,11 +343,18 @@ struct AssociateDileptonToEMEvent { fillEventId(collisions, tracks, prmmueventid, perCollision_mu); } + void processChargedTrack(aod::EMEvents const& collisions, aod::EMPrimaryTracks const& tracks) + // void processChargedTrack(aod::EMEvents const& collisions, aod::EMPrimaryTrackEMEventIdsTMP const& tracks) + { + fillEventId(collisions, tracks, prmtrackeventid, perCollision_track); + } + void processDummy(aod::EMEvents const&) {} - PROCESS_SWITCH(AssociateDileptonToEMEvent, processPCM, "process pcm-event indexing", false); - PROCESS_SWITCH(AssociateDileptonToEMEvent, processElectron, "process dalitzee-event indexing", false); - PROCESS_SWITCH(AssociateDileptonToEMEvent, processFwdMuon, "process forward muon indexing", false); + PROCESS_SWITCH(AssociateDileptonToEMEvent, processPCM, "process indexing for PCM", false); + PROCESS_SWITCH(AssociateDileptonToEMEvent, processElectron, "process indexing for electrons", false); + PROCESS_SWITCH(AssociateDileptonToEMEvent, processFwdMuon, "process indexing for forward muons", false); + PROCESS_SWITCH(AssociateDileptonToEMEvent, processChargedTrack, "process indexing for charged tracks", false); PROCESS_SWITCH(AssociateDileptonToEMEvent, processDummy, "process dummy", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGEM/Dilepton/TableProducer/eventSelection.cxx b/PWGEM/Dilepton/TableProducer/eventSelection.cxx index dfe19f1a2e9..d4d33e83cc5 100644 --- a/PWGEM/Dilepton/TableProducer/eventSelection.cxx +++ b/PWGEM/Dilepton/TableProducer/eventSelection.cxx @@ -14,10 +14,12 @@ // This code produces event selection table for PWG-EM. // Please write to: daiki.sekihata@cern.ch +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" +#include "Common/CCDB/RCTSelectionFlags.h" #include "PWGEM/Dilepton/DataModel/dileptonTables.h" using namespace o2; @@ -36,14 +38,21 @@ struct EMEventSelection { // Configurables Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; - Configurable cfgCentMin{"cfgCentMin", 0.f, "min. centrality"}; + Configurable cfgCentMin{"cfgCentMin", -1.f, "min. centrality"}; Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; - Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; - Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; - Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; - Configurable cfgRequireNoTFB{"cfgRequireNoTFB", true, "require No time frame border in event cut"}; - Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", true, "require no ITS readout frame border in event cut"}; + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; + + Configurable cfgZvtxMin{"cfgZvtxMin", -1e+10, "min. Zvtx"}; + Configurable cfgZvtxMax{"cfgZvtxMax", 1e+10, "max. Zvtx"}; + Configurable cfgRequireSel8{"cfgRequireSel8", false, "require sel8 in event cut"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", false, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. track occupancy"}; @@ -52,7 +61,12 @@ struct EMEventSelection { Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. occupancy"}; Configurable cfgRequireNoCollInTimeRangeStandard{"cfgRequireNoCollInTimeRangeStandard", false, "require no collision in time range standard"}; - void init(InitContext&) {} + o2::aod::rctsel::RCTFlagsChecker rctChecker; + + void init(InitContext&) + { + rctChecker.init(cfgRCTLabel.value, cfgCheckZDC.value, cfgTreatLimitedAcceptanceAsBad.value); + } template bool isSelectedEvent(TCollision const& collision) @@ -63,7 +77,7 @@ struct EMEventSelection { } } - if (fabs(collision.posZ()) > cfgZvtxMax) { + if (collision.posZ() < cfgZvtxMin || cfgZvtxMax < collision.posZ()) { return false; } @@ -95,7 +109,7 @@ struct EMEventSelection { return false; } - if (!(cfgFT0COccupancyMin < collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < cfgFT0COccupancyMax)) { + if (!(cfgFT0COccupancyMin <= collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < cfgFT0COccupancyMax)) { return false; } @@ -106,13 +120,18 @@ struct EMEventSelection { } } + if (cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + // LOGF(info, "rejected by RCT flag"); + return false; + } + return true; } template void processEventSelection(TCollisions const& collisions) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { emevsel(isSelectedEvent(collision)); } // end of collision loop } // end of process diff --git a/PWGEM/Dilepton/TableProducer/filterDielectronEvent.cxx b/PWGEM/Dilepton/TableProducer/filterDielectronEvent.cxx deleted file mode 100644 index ee7153c20b4..00000000000 --- a/PWGEM/Dilepton/TableProducer/filterDielectronEvent.cxx +++ /dev/null @@ -1,1386 +0,0 @@ -// 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. - -/// \brief write relevant information about primary electrons. -/// \author daiki.sekihata@cern.ch - -#include -#include -#include -#include -#include - -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/DataModel/CollisionAssociationTables.h" -#include "Common/Core/TableHelper.h" - -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" - -using namespace o2; -using namespace o2::soa; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::constants::physics; - -using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; - -using MyTracks = soa::Join; -using MyTrack = MyTracks::iterator; -using MyTracksMC = soa::Join; -using MyTrackMC = MyTracksMC::iterator; - -struct filterDielectronEvent { - using MyCollisions = soa::Join; - using MyCollisionsWithSWT = soa::Join; - - SliceCache cache; - Preslice perCol = o2::aod::track::collisionId; - Produces emprimaryelectrons; - Produces emprimaryelectronscov; - Produces filter; - - // Configurables - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; - - // Operation and minimisation criteria - Configurable fillQAHistogram{"fillQAHistogram", false, "flag to fill QA histograms"}; - Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; - Configurable min_ncluster_tpc{"min_ncluster_tpc", 0, "min ncluster tpc"}; - Configurable mincrossedrows{"mincrossedrows", 80, "min. crossed rows"}; - Configurable min_tpc_cr_findable_ratio{"min_tpc_cr_findable_ratio", 0.8, "min. TPC Ncr/Nf ratio"}; - Configurable max_pin_for_pion_rejection{"max_pin_for_pion_rejection", 1e+10, "pion rejection is applied below this pin"}; - Configurable max_frac_shared_clusters_tpc{"max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; - Configurable min_ncluster_its{"min_ncluster_its", 4, "min ncluster its"}; - Configurable min_ncluster_itsib{"min_ncluster_itsib", 1, "min ncluster itsib"}; - Configurable maxchi2tpc{"maxchi2tpc", 5.0, "max. chi2/NclsTPC"}; - Configurable maxchi2its{"maxchi2its", 6.0, "max. chi2/NclsITS"}; - Configurable minpt{"minpt", 0.15, "min pt for track"}; - Configurable maxeta{"maxeta", 0.9, "eta acceptance"}; - Configurable dca_xy_max{"dca_xy_max", 0.1f, "max DCAxy in cm"}; - Configurable dca_z_max{"dca_z_max", 0.1f, "max DCAz in cm"}; - Configurable dca_3d_sigma_max{"dca_3d_sigma_max", 1.5, "max DCA 3D in sigma"}; - Configurable minTPCNsigmaEl{"minTPCNsigmaEl", -2.5, "min. TPC n sigma for electron inclusion"}; - Configurable maxTPCNsigmaEl{"maxTPCNsigmaEl", 3.5, "max. TPC n sigma for electron inclusion"}; - Configurable maxTOFNsigmaEl{"maxTOFNsigmaEl", 3.5, "max. TOF n sigma for electron inclusion"}; - Configurable minTPCNsigmaPi{"minTPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; - Configurable maxTPCNsigmaPi{"maxTPCNsigmaPi", 2.0, "max. TPC n sigma for pion exclusion"}; - Configurable minTPCNsigmaKa{"minTPCNsigmaKa", -3.0, "min. TPC n sigma for kaon exclusion"}; - Configurable maxTPCNsigmaKa{"maxTPCNsigmaKa", +3.0, "max. TPC n sigma for kaon exclusion"}; - Configurable minTPCNsigmaPr{"minTPCNsigmaPr", -3.0, "min. TPC n sigma for proton exclusion"}; - Configurable maxTPCNsigmaPr{"maxTPCNsigmaPr", +3.0, "max. TPC n sigma for proton exclusion"}; - Configurable maxMee{"maxMee", 1e+10, "max mee for virtual photon selection"}; - - Configurable apply_phiv{"apply_phiv", true, "flag to apply phiv cut"}; - Configurable slope{"slope", 0.0181, "slope for mee vs. phiv"}; - Configurable intercept{"intercept", -0.0370, "intercept for mee vs. phiv"}; - - HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - - int mRunNumber; - float d_bz; - Service ccdb; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - - void init(InitContext&) - { - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - if (fillQAHistogram) { - fRegistry.add("Track/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/hRelSigma1Pt", "relative p_{T} resolution;p_{T} (GeV/c);#sigma_{1/p_{T}} #times p_{T}", kTH2F, {{1000, 0, 10}, {100, 0, 0.1}}, false); - fRegistry.add("Track/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {20, -1.0f, 1.0f}}, false); - fRegistry.add("Track/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); - fRegistry.add("Track/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); - fRegistry.add("Track/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{1000, 0, 10}, {500, 0., 500}}, false); - fRegistry.add("Track/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{1000, 0, 10}, {500, 0., 500}}, false); - fRegistry.add("Track/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFbeta", "TOF beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, false); - fRegistry.add("Track/hTOFNsigmaEl", "TOF n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFNsigmaMu", "TOF n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFNsigmaPi", "TOF n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFNsigmaKa", "TOF n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFNsigmaPr", "TOF n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/hTPCNclsShared", "TPC Ncls/Nfindable;p_{T} (GeV/c);N_{cls}^{shared}/N_{cls} in TPC", kTH2F, {{1000, 0, 10}, {100, 0, 1}}, false); - fRegistry.add("Track/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("Track/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); on ITS #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {150, 0, 15}}, false); - fRegistry.add("Pair/before/hMvsPt", "m_{ee} vs. p_{T,ee};m_{ee} (GeV/c^{2});p_{T,ee} (GeV/c)", kTH2F, {{100, 0, 0.1}, {200, 0, 2}}, false); - fRegistry.add("Pair/before/hMvsPhiV", "mee vs. phiv;#varphi_{V} (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{90, 0, M_PI}, {100, 0, 0.1}}, false); - fRegistry.addClone("Pair/before/", "Pair/after/"); - fRegistry.add("Pair/uls/hM", "m_{ee};m_{ee} (GeV/c^{2})", kTH1F, {{100, 0, 0.1}}, false); - fRegistry.add("Pair/lspp/hM", "m_{ee};m_{ee} (GeV/c^{2})", kTH1F, {{100, 0, 0.1}}, false); - fRegistry.add("Pair/lsmm/hM", "m_{ee};m_{ee} (GeV/c^{2})", kTH1F, {{100, 0, 0.1}}, false); - } - } - - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) - { - if (mRunNumber == bc.runNumber()) { - return; - } - - // In case override, don't proceed, please - no CCDB access required - if (d_bz_input > -990) { - d_bz = d_bz_input; - o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { - grpmag.setL3Current(30000.f / (d_bz / 5.0f)); - } - o2::base::Propagator::initFieldFromGRP(&grpmag); - mRunNumber = bc.runNumber(); - return; - } - - auto run3grp_timestamp = bc.timestamp(); - o2::parameters::GRPObject* grpo = 0x0; - o2::parameters::GRPMagField* grpmag = 0x0; - if (!skipGRPOquery) - grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); - if (grpo) { - o2::base::Propagator::initFieldFromGRP(grpo); - // Fetch magnetic field from ccdb for current collision - d_bz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); - if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; - } - o2::base::Propagator::initFieldFromGRP(grpmag); - // Fetch magnetic field from ccdb for current collision - d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } - mRunNumber = bc.runNumber(); - } - - template - bool checkTrack(TCollision const& collision, TTrack const& track) - { - if constexpr (isMC) { - if (!track.has_mcParticle()) { - return false; - } - } - - if (track.tpcChi2NCl() > maxchi2tpc) { - return false; - } - - if (track.itsChi2NCl() > maxchi2its) { - return false; - } - - if (!track.hasITS() || !track.hasTPC()) { - return false; - } - if (track.itsNCls() < min_ncluster_its) { - return false; - } - if (track.itsNClsInnerBarrel() < min_ncluster_itsib) { - return false; - } - - if (track.tpcNClsFound() < min_ncluster_tpc) { - return false; - } - - if (track.tpcNClsCrossedRows() < mincrossedrows) { - return false; - } - - if (track.tpcCrossedRowsOverFindableCls() < min_tpc_cr_findable_ratio) { - return false; - } - - if (track.tpcFractionSharedCls() > max_frac_shared_clusters_tpc) { - return false; - } - - gpu::gpustd::array dcaInfo; - auto track_par_cov_recalc = getTrackParCov(track); - track_par_cov_recalc.setPID(o2::track::PID::Electron); - // std::array pVec_recalc = {0, 0, 0}; // px, py, pz - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - // getPxPyPz(track_par_cov_recalc, pVec_recalc); - float dcaXY = dcaInfo[0]; - float dcaZ = dcaInfo[1]; - - if (fabs(dcaXY) > dca_xy_max || fabs(dcaZ) > dca_z_max) { - return false; - } - - if (track_par_cov_recalc.getPt() < minpt || fabs(track_par_cov_recalc.getEta()) > maxeta) { - return false; - } - - float dca_3d = 999.f; - float det = track_par_cov_recalc.getSigmaY2() * track_par_cov_recalc.getSigmaZ2() - track_par_cov_recalc.getSigmaZY() * track_par_cov_recalc.getSigmaZY(); - if (det < 0) { - dca_3d = 999.f; - } else { - float chi2 = (dcaXY * dcaXY * track_par_cov_recalc.getSigmaZ2() + dcaZ * dcaZ * track_par_cov_recalc.getSigmaY2() - 2. * dcaXY * dcaZ * track_par_cov_recalc.getSigmaZY()) / det; - dca_3d = std::sqrt(fabs(chi2) / 2.); - } - if (dca_3d > dca_3d_sigma_max) { - return false; - } - - return true; - } - - template - bool isElectron(TTrack const& track) - { - return isElectron_TPChadrej(track) || isElectron_TOFreq(track); - } - - template - bool isElectron_TPChadrej(TTrack const& track) - { - if (track.tpcNSigmaEl() < minTPCNsigmaEl || maxTPCNsigmaEl < track.tpcNSigmaEl()) { - return false; - } - if (minTPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < maxTPCNsigmaPi && track.tpcInnerParam() < max_pin_for_pion_rejection) { - return false; - } - if (minTPCNsigmaKa < track.tpcNSigmaKa() && track.tpcNSigmaKa() < maxTPCNsigmaKa) { - return false; - } - if (minTPCNsigmaPr < track.tpcNSigmaPr() && track.tpcNSigmaPr() < maxTPCNsigmaPr) { - return false; - } - if (track.hasTOF() && (maxTOFNsigmaEl < fabs(track.tofNSigmaEl()))) { - return false; - } - return true; - } - - template - bool isElectron_TOFreq(TTrack const& track) - { - if (minTPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < maxTPCNsigmaPi && track.tpcInnerParam() < max_pin_for_pion_rejection) { - return false; - } - return minTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < maxTPCNsigmaEl && fabs(track.tofNSigmaEl()) < maxTOFNsigmaEl; - } - - template - void fillTrackTable(TCollision const& collision, TTrack const& track) - { - if (std::find(stored_trackIds.begin(), stored_trackIds.end(), std::pair{collision.globalIndex(), track.globalIndex()}) == stored_trackIds.end()) { - gpu::gpustd::array dcaInfo; - auto track_par_cov_recalc = getTrackParCov(track); - track_par_cov_recalc.setPID(o2::track::PID::Electron); - // std::array pVec_recalc = {0, 0, 0}; // px, py, pz - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - // getPxPyPz(track_par_cov_recalc, pVec_recalc); - float dcaXY = dcaInfo[0]; - float dcaZ = dcaInfo[1]; - - float pt_recalc = track_par_cov_recalc.getPt(); - float eta_recalc = track_par_cov_recalc.getEta(); - float phi_recalc = track_par_cov_recalc.getPhi(); - - bool isAssociatedToMPC = collision.globalIndex() == track.collisionId(); - - emprimaryelectrons(collision.globalIndex(), track.globalIndex(), track.sign(), - pt_recalc, eta_recalc, phi_recalc, dcaXY, dcaZ, - track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), track.tpcNClsShared(), - track.tpcChi2NCl(), track.tpcInnerParam(), - track.tpcSignal(), track.tpcNSigmaEl(), track.tpcNSigmaMu(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), - track.beta(), track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), - track.itsClusterSizes(), 0, 0, 0, 0, 0, - track.itsChi2NCl(), track.tofChi2(), track.detectorMap(), - track_par_cov_recalc.getX(), track_par_cov_recalc.getAlpha(), track_par_cov_recalc.getY(), track_par_cov_recalc.getZ(), track_par_cov_recalc.getSnp(), track_par_cov_recalc.getTgl(), isAssociatedToMPC); - - emprimaryelectronscov( - track_par_cov_recalc.getSigmaY2(), - track_par_cov_recalc.getSigmaZY(), - track_par_cov_recalc.getSigmaZ2(), - track_par_cov_recalc.getSigmaSnpY(), - track_par_cov_recalc.getSigmaSnpZ(), - track_par_cov_recalc.getSigmaSnp2(), - track_par_cov_recalc.getSigmaTglY(), - track_par_cov_recalc.getSigmaTglZ(), - track_par_cov_recalc.getSigmaTglSnp(), - track_par_cov_recalc.getSigmaTgl2(), - track_par_cov_recalc.getSigma1PtY(), - track_par_cov_recalc.getSigma1PtZ(), - track_par_cov_recalc.getSigma1PtSnp(), - track_par_cov_recalc.getSigma1PtTgl(), - track_par_cov_recalc.getSigma1Pt2()); - - stored_trackIds.emplace_back(std::pair{collision.globalIndex(), track.globalIndex()}); - - if (fillQAHistogram) { - uint32_t itsClusterSizes = track.itsClusterSizes(); - int total_cluster_size = 0, nl = 0; - for (unsigned int layer = 0; layer < 7; layer++) { - int cluster_size_per_layer = (itsClusterSizes >> (layer * 4)) & 0xf; - if (cluster_size_per_layer > 0) { - nl++; - } - total_cluster_size += cluster_size_per_layer; - } - - fRegistry.fill(HIST("Track/hPt"), pt_recalc); - fRegistry.fill(HIST("Track/hQoverPt"), track.sign() / pt_recalc); - fRegistry.fill(HIST("Track/hRelSigma1Pt"), pt_recalc, std::sqrt(track_par_cov_recalc.getSigma1Pt2()) * pt_recalc); - fRegistry.fill(HIST("Track/hEtaPhi"), phi_recalc, eta_recalc); - fRegistry.fill(HIST("Track/hDCAxyz"), dcaXY, dcaZ); - fRegistry.fill(HIST("Track/hDCAxyzSigma"), dcaXY / sqrt(track_par_cov_recalc.getSigmaY2()), dcaZ / sqrt(track_par_cov_recalc.getSigmaZ2())); - fRegistry.fill(HIST("Track/hDCAxyRes_Pt"), pt_recalc, sqrt(track_par_cov_recalc.getSigmaY2()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/hDCAzRes_Pt"), pt_recalc, sqrt(track_par_cov_recalc.getSigmaZ2()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); - fRegistry.fill(HIST("Track/hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), track.p(), static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(track.tgl()))); - fRegistry.fill(HIST("Track/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); - fRegistry.fill(HIST("Track/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); - fRegistry.fill(HIST("Track/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); - fRegistry.fill(HIST("Track/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); - fRegistry.fill(HIST("Track/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); - fRegistry.fill(HIST("Track/hTOFbeta"), track.p(), track.beta()); - fRegistry.fill(HIST("Track/hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); - fRegistry.fill(HIST("Track/hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); - fRegistry.fill(HIST("Track/hTOFNsigmaKa"), track.p(), track.tofNSigmaKa()); - fRegistry.fill(HIST("Track/hTOFNsigmaPr"), track.p(), track.tofNSigmaPr()); - } - } - } - - template - o2::track::TrackParCov propagateTrack(TCollision const& collision, TTrack const& track) - { - gpu::gpustd::array dcaInfo; - auto track_par_cov_recalc = getTrackParCov(track); - track_par_cov_recalc.setPID(o2::track::PID::Electron); - // std::array pVec_recalc = {0, 0, 0}; // px, py, pz - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - // getPxPyPz(track_par_cov_recalc, pVec_recalc); - return track_par_cov_recalc; - } - - std::vector> stored_trackIds; - std::vector> stored_pairIds; - Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::tpcChi2NCl < maxchi2tpc&& o2::aod::track::itsChi2NCl < maxchi2its&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true; - Filter pidFilter = minTPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < maxTPCNsigmaEl; - using MyFilteredTracks = soa::Filtered; - - Partition posTracks = o2::aod::track::signed1Pt > 0.f; - Partition negTracks = o2::aod::track::signed1Pt < 0.f; - - // ---------- for data ---------- - - void processRec_SA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const&) - { - stored_trackIds.reserve(posTracks.size() + negTracks.size()); - - for (auto& collision : collisions) { - auto bc = collision.template foundBC_as(); - initCCDB(bc); - - if (!collision.isSelected()) { - filter(0, 0, 0); - continue; - } - - int nee_uls = 0; - auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - - for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { - if (!checkTrack(collision, pos) || !checkTrack(collision, ele)) { - continue; - } - if (!isElectron(pos) || !isElectron(ele)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele.pt(), ele.eta(), ele.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/uls/hM"), v12.M()); - fRegistry.fill(HIST("Pair/before/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/before/hMvsPhiV"), phiv, v12.M()); - } - if (apply_phiv ? (v12.M() < maxMee && slope * phiv + intercept < v12.M()) : (v12.M() < maxMee)) { - fillTrackTable(collision, pos); - fillTrackTable(collision, ele); - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/after/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/after/hMvsPhiV"), phiv, v12.M()); - } - nee_uls++; - } - - } // end of pairing loop - - if (fillQAHistogram) { - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { - if (!checkTrack(collision, pos1) || !checkTrack(collision, pos2)) { - continue; - } - if (!isElectron(pos1) || !isElectron(pos2)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(pos1.pt(), pos1.eta(), pos1.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lspp/hM"), v12.M()); - } // end of pairing loop - - for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { - if (!checkTrack(collision, ele1) || !checkTrack(collision, ele2)) { - continue; - } - if (!isElectron(ele1) || !isElectron(ele2)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(ele1.pt(), ele1.eta(), ele1.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lsmm/hM"), v12.M()); - } // end of pairing loop - } - - if (nee_uls < 1) { - filter(nee_uls, 0, 0); - continue; - } - filter(nee_uls, 0, 0); - - } // end of collision loop - - stored_trackIds.clear(); - stored_trackIds.shrink_to_fit(); - stored_pairIds.clear(); - stored_pairIds.shrink_to_fit(); - } - PROCESS_SWITCH(filterDielectronEvent, processRec_SA, "process reconstructed info only", true); // standalone - - Preslice trackIndicesPerCollision = aod::track_association::collisionId; - void processRec_TTCA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::TrackAssoc const& trackIndices) - { - stored_trackIds.reserve(tracks.size() * 2); - - for (auto& collision : collisions) { - auto bc = collision.template foundBC_as(); - initCCDB(bc); - - if (!collision.isSelected()) { - filter(0, 0, 0); - continue; - } - - int nee_uls = 0; - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); - std::vector posTracks_per_coll; - std::vector negTracks_per_coll; - posTracks_per_coll.reserve(trackIdsThisCollision.size()); - negTracks_per_coll.reserve(trackIdsThisCollision.size()); - - for (auto& trackId : trackIdsThisCollision) { - auto track = trackId.template track_as(); - if (!checkTrack(collision, track) || !isElectron(track)) { - continue; - } - - if (track.sign() > 0) { - posTracks_per_coll.emplace_back(track); - } else { - negTracks_per_coll.emplace_back(track); - } - } // end of track loop - - for (auto& pos : posTracks_per_coll) { - for (auto& ele : negTracks_per_coll) { - - auto pos_prop = propagateTrack(collision, pos); - auto ele_prop = propagateTrack(collision, ele); - - std::array pVec_pos = {0, 0, 0}; // px, py, pz - getPxPyPz(pos_prop, pVec_pos); - std::array pVec_ele = {0, 0, 0}; // px, py, pz - getPxPyPz(ele_prop, pVec_ele); - - ROOT::Math::PtEtaPhiMVector v1(pos_prop.getPt(), pos_prop.getEta(), pos_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele_prop.getPt(), ele_prop.getEta(), ele_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pVec_pos[0], pVec_pos[1], pVec_pos[2], pVec_ele[0], pVec_ele[1], pVec_ele[2], pos.sign(), ele.sign(), d_bz); - - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/uls/hM"), v12.M()); - fRegistry.fill(HIST("Pair/before/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/before/hMvsPhiV"), phiv, v12.M()); - } - if (apply_phiv ? (v12.M() < maxMee && slope * phiv + intercept < v12.M()) : (v12.M() < maxMee)) { - fillTrackTable(collision, pos); - fillTrackTable(collision, ele); - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/after/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/after/hMvsPhiV"), phiv, v12.M()); - } - nee_uls++; - } - - } // end of negative track loop - } // end of postive track loop - - if (fillQAHistogram) { - for (auto& pos1 : posTracks_per_coll) { - for (auto& pos2 : posTracks_per_coll) { - if (pos1.globalIndex() == pos2.globalIndex()) { - continue; - } - - auto pos1_prop = propagateTrack(collision, pos1); - auto pos2_prop = propagateTrack(collision, pos2); - - std::array pVec_pos1 = {0, 0, 0}; // px, py, pz - getPxPyPz(pos1_prop, pVec_pos1); - std::array pVec_pos2 = {0, 0, 0}; // px, py, pz - getPxPyPz(pos2_prop, pVec_pos2); - - ROOT::Math::PtEtaPhiMVector v1(pos1_prop.getPt(), pos1_prop.getEta(), pos1_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos2_prop.getPt(), pos2_prop.getEta(), pos2_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lspp/hM"), v12.M()); - } // end of positive track loop - } // end of postive track loop - - for (auto& ele1 : negTracks_per_coll) { - for (auto& ele2 : negTracks_per_coll) { - if (ele1.globalIndex() == ele2.globalIndex()) { - continue; - } - - auto ele1_prop = propagateTrack(collision, ele1); - auto ele2_prop = propagateTrack(collision, ele2); - - std::array pVec_ele1 = {0, 0, 0}; // px, py, pz - getPxPyPz(ele1_prop, pVec_ele1); - std::array pVec_ele2 = {0, 0, 0}; // px, py, pz - getPxPyPz(ele2_prop, pVec_ele2); - - ROOT::Math::PtEtaPhiMVector v1(ele1_prop.getPt(), ele1_prop.getEta(), ele1_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele2_prop.getPt(), ele2_prop.getEta(), ele2_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lsmm/hM"), v12.M()); - } // end of negative track loop - } // end of negative track loop - } - - if (nee_uls < 1) { - filter(nee_uls, 0, 0); - continue; - } - - filter(nee_uls, 0, 0); - - posTracks_per_coll.clear(); - negTracks_per_coll.clear(); - posTracks_per_coll.shrink_to_fit(); - negTracks_per_coll.shrink_to_fit(); - - } // end of collision loop - - stored_trackIds.clear(); - stored_trackIds.shrink_to_fit(); - stored_pairIds.clear(); - stored_pairIds.shrink_to_fit(); - } - PROCESS_SWITCH(filterDielectronEvent, processRec_TTCA, "process reconstructed info only", false); // with TTCA - - // ---------- for data ---------- - - void processRec_SA_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const&) - { - stored_trackIds.reserve(posTracks.size() + negTracks.size()); - - for (auto& collision : collisions) { - auto bc = collision.template foundBC_as(); - initCCDB(bc); - - if (!collision.isSelected()) { - filter(0, 0, 0); - continue; - } - if (collision.swtaliastmp_raw() == 0) { - filter(0, 0, 0); - continue; - } - - int nee_uls = 0; - auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - - for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { - if (!checkTrack(collision, pos) || !checkTrack(collision, ele)) { - continue; - } - if (!isElectron(pos) || !isElectron(ele)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele.pt(), ele.eta(), ele.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/uls/hM"), v12.M()); - fRegistry.fill(HIST("Pair/before/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/before/hMvsPhiV"), phiv, v12.M()); - } - if (apply_phiv ? (v12.M() < maxMee && slope * phiv + intercept < v12.M()) : (v12.M() < maxMee)) { - fillTrackTable(collision, pos); - fillTrackTable(collision, ele); - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/after/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/after/hMvsPhiV"), phiv, v12.M()); - } - nee_uls++; - } - - } // end of pairing loop - - if (fillQAHistogram) { - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { - if (!checkTrack(collision, pos1) || !checkTrack(collision, pos2)) { - continue; - } - if (!isElectron(pos1) || !isElectron(pos2)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(pos1.pt(), pos1.eta(), pos1.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lspp/hM"), v12.M()); - } // end of pairing loop - - for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { - if (!checkTrack(collision, ele1) || !checkTrack(collision, ele2)) { - continue; - } - if (!isElectron(ele1) || !isElectron(ele2)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(ele1.pt(), ele1.eta(), ele1.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lsmm/hM"), v12.M()); - } // end of pairing loop - } - - if (nee_uls < 1) { - filter(nee_uls, 0, 0); - continue; - } - filter(nee_uls, 0, 0); - - } // end of collision loop - - stored_trackIds.clear(); - stored_trackIds.shrink_to_fit(); - stored_pairIds.clear(); - stored_pairIds.shrink_to_fit(); - } - PROCESS_SWITCH(filterDielectronEvent, processRec_SA_SWT, "process reconstructed info only", false); // standalone - - void processRec_TTCA_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::TrackAssoc const& trackIndices) - { - stored_trackIds.reserve(tracks.size() * 2); - - for (auto& collision : collisions) { - auto bc = collision.template foundBC_as(); - initCCDB(bc); - - if (!collision.isSelected()) { - filter(0, 0, 0); - continue; - } - if (collision.swtaliastmp_raw() == 0) { - filter(0, 0, 0); - continue; - } - - int nee_uls = 0; - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); - std::vector posTracks_per_coll; - std::vector negTracks_per_coll; - posTracks_per_coll.reserve(trackIdsThisCollision.size()); - negTracks_per_coll.reserve(trackIdsThisCollision.size()); - - for (auto& trackId : trackIdsThisCollision) { - auto track = trackId.template track_as(); - if (!checkTrack(collision, track) || !isElectron(track)) { - continue; - } - - if (track.sign() > 0) { - posTracks_per_coll.emplace_back(track); - } else { - negTracks_per_coll.emplace_back(track); - } - } // end of track loop - - for (auto& pos : posTracks_per_coll) { - for (auto& ele : negTracks_per_coll) { - - auto pos_prop = propagateTrack(collision, pos); - auto ele_prop = propagateTrack(collision, ele); - - std::array pVec_pos = {0, 0, 0}; // px, py, pz - getPxPyPz(pos_prop, pVec_pos); - std::array pVec_ele = {0, 0, 0}; // px, py, pz - getPxPyPz(ele_prop, pVec_ele); - - ROOT::Math::PtEtaPhiMVector v1(pos_prop.getPt(), pos_prop.getEta(), pos_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele_prop.getPt(), ele_prop.getEta(), ele_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pVec_pos[0], pVec_pos[1], pVec_pos[2], pVec_ele[0], pVec_ele[1], pVec_ele[2], pos.sign(), ele.sign(), d_bz); - - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/uls/hM"), v12.M()); - fRegistry.fill(HIST("Pair/before/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/before/hMvsPhiV"), phiv, v12.M()); - } - if (apply_phiv ? (v12.M() < maxMee && slope * phiv + intercept < v12.M()) : (v12.M() < maxMee)) { - fillTrackTable(collision, pos); - fillTrackTable(collision, ele); - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/after/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/after/hMvsPhiV"), phiv, v12.M()); - } - nee_uls++; - } - - } // end of negative track loop - } // end of postive track loop - - if (fillQAHistogram) { - for (auto& pos1 : posTracks_per_coll) { - for (auto& pos2 : posTracks_per_coll) { - if (pos1.globalIndex() == pos2.globalIndex()) { - continue; - } - - auto pos1_prop = propagateTrack(collision, pos1); - auto pos2_prop = propagateTrack(collision, pos2); - - std::array pVec_pos1 = {0, 0, 0}; // px, py, pz - getPxPyPz(pos1_prop, pVec_pos1); - std::array pVec_pos2 = {0, 0, 0}; // px, py, pz - getPxPyPz(pos2_prop, pVec_pos2); - - ROOT::Math::PtEtaPhiMVector v1(pos1_prop.getPt(), pos1_prop.getEta(), pos1_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos2_prop.getPt(), pos2_prop.getEta(), pos2_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lspp/hM"), v12.M()); - } // end of positive track loop - } // end of postive track loop - - for (auto& ele1 : negTracks_per_coll) { - for (auto& ele2 : negTracks_per_coll) { - if (ele1.globalIndex() == ele2.globalIndex()) { - continue; - } - - auto ele1_prop = propagateTrack(collision, ele1); - auto ele2_prop = propagateTrack(collision, ele2); - - std::array pVec_ele1 = {0, 0, 0}; // px, py, pz - getPxPyPz(ele1_prop, pVec_ele1); - std::array pVec_ele2 = {0, 0, 0}; // px, py, pz - getPxPyPz(ele2_prop, pVec_ele2); - - ROOT::Math::PtEtaPhiMVector v1(ele1_prop.getPt(), ele1_prop.getEta(), ele1_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele2_prop.getPt(), ele2_prop.getEta(), ele2_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lsmm/hM"), v12.M()); - } // end of negative track loop - } // end of negative track loop - } - - if (nee_uls < 1) { - filter(nee_uls, 0, 0); - continue; - } - - filter(nee_uls, 0, 0); - - posTracks_per_coll.clear(); - negTracks_per_coll.clear(); - posTracks_per_coll.shrink_to_fit(); - negTracks_per_coll.shrink_to_fit(); - - } // end of collision loop - - stored_trackIds.clear(); - stored_trackIds.shrink_to_fit(); - stored_pairIds.clear(); - stored_pairIds.shrink_to_fit(); - } - PROCESS_SWITCH(filterDielectronEvent, processRec_TTCA_SWT, "process reconstructed info only", false); // with TTCA - - // ---------- for MC ---------- - - using MyFilteredTracksMC = soa::Filtered; - Partition posTracksMC = o2::aod::track::signed1Pt > 0.f; - Partition negTracksMC = o2::aod::track::signed1Pt < 0.f; - void processMC_SA(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks) - { - stored_trackIds.reserve(tracks.size()); - - for (auto& collision : collisions) { - if (!collision.has_mcCollision()) { - continue; - } - auto bc = collision.template foundBC_as(); - initCCDB(bc); - - if (!collision.isSelected()) { - filter(0, 0, 0); - continue; - } - - int nee_uls = 0; - auto posTracks_per_coll = posTracksMC->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracksMC->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - - for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { - if (!checkTrack(collision, pos) || !checkTrack(collision, ele)) { - continue; - } - if (!isElectron(pos) || !isElectron(ele)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele.pt(), ele.eta(), ele.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/uls/hM"), v12.M()); - fRegistry.fill(HIST("Pair/before/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/before/hMvsPhiV"), phiv, v12.M()); - } - if (apply_phiv ? (v12.M() < maxMee && slope * phiv + intercept < v12.M()) : (v12.M() < maxMee)) { - fillTrackTable(collision, pos); - fillTrackTable(collision, ele); - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/after/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/after/hMvsPhiV"), phiv, v12.M()); - } - nee_uls++; - } - - } // end of pairing loop - - if (fillQAHistogram) { - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { - if (!checkTrack(collision, pos1) || !checkTrack(collision, pos2)) { - continue; - } - if (!isElectron(pos1) || !isElectron(pos2)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(pos1.pt(), pos1.eta(), pos1.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lspp/hM"), v12.M()); - } // end of pairing loop - - for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { - if (!checkTrack(collision, ele1) || !checkTrack(collision, ele2)) { - continue; - } - if (!isElectron(ele1) || !isElectron(ele2)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(ele1.pt(), ele1.eta(), ele1.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lsmm/hM"), v12.M()); - } // end of pairing loop - } - - if (nee_uls < 1) { - filter(nee_uls, 0, 0); - continue; - } - filter(nee_uls, 0, 0); - } // end of collision loop - - stored_trackIds.clear(); - stored_trackIds.shrink_to_fit(); - stored_pairIds.clear(); - stored_pairIds.shrink_to_fit(); - } - PROCESS_SWITCH(filterDielectronEvent, processMC_SA, "process reconstructed and MC info ", false); - - void processMC_TTCA(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyTracksMC const& tracks, aod::TrackAssoc const& trackIndices) - { - stored_trackIds.reserve(tracks.size() * 2); - - for (auto& collision : collisions) { - if (!collision.has_mcCollision()) { - continue; - } - auto bc = collision.template foundBC_as(); - initCCDB(bc); - - if (!collision.isSelected()) { - filter(0, 0, 0); - continue; - } - - int nee_uls = 0; - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); - std::vector posTracks_per_coll; - std::vector negTracks_per_coll; - posTracks_per_coll.reserve(trackIdsThisCollision.size()); - negTracks_per_coll.reserve(trackIdsThisCollision.size()); - - for (auto& trackId : trackIdsThisCollision) { - auto track = trackId.template track_as(); - if (!checkTrack(collision, track) || !isElectron(track)) { - continue; - } - - if (track.sign() > 0) { - posTracks_per_coll.emplace_back(track); - } else { - negTracks_per_coll.emplace_back(track); - } - } // end of track loop - - for (auto& pos : posTracks_per_coll) { - for (auto& ele : negTracks_per_coll) { - auto pos_prop = propagateTrack(collision, pos); - auto ele_prop = propagateTrack(collision, ele); - std::array pVec_pos = {0, 0, 0}; // px, py, pz - getPxPyPz(pos_prop, pVec_pos); - std::array pVec_ele = {0, 0, 0}; // px, py, pz - getPxPyPz(ele_prop, pVec_ele); - - ROOT::Math::PtEtaPhiMVector v1(pos_prop.getPt(), pos_prop.getEta(), pos_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele_prop.getPt(), ele_prop.getEta(), ele_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pVec_pos[0], pVec_pos[1], pVec_pos[2], pVec_ele[0], pVec_ele[1], pVec_ele[2], pos.sign(), ele.sign(), d_bz); - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/uls/hM"), v12.M()); - fRegistry.fill(HIST("Pair/before/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/before/hMvsPhiV"), phiv, v12.M()); - } - if (apply_phiv ? (v12.M() < maxMee && slope * phiv + intercept < v12.M()) : (v12.M() < maxMee)) { - fillTrackTable(collision, pos); - fillTrackTable(collision, ele); - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/after/hMvsPt"), v12.M(), v12.Pt()); - fRegistry.fill(HIST("Pair/after/hMvsPhiV"), phiv, v12.M()); - } - nee_uls++; - } - - } // end of negative track loop - } // end of postive track loop - - if (fillQAHistogram) { - for (auto& pos1 : posTracks_per_coll) { - for (auto& pos2 : posTracks_per_coll) { - if (pos1.globalIndex() == pos2.globalIndex()) { - continue; - } - - auto pos1_prop = propagateTrack(collision, pos1); - auto pos2_prop = propagateTrack(collision, pos2); - - std::array pVec_pos1 = {0, 0, 0}; // px, py, pz - getPxPyPz(pos1_prop, pVec_pos1); - std::array pVec_pos2 = {0, 0, 0}; // px, py, pz - getPxPyPz(pos2_prop, pVec_pos2); - - ROOT::Math::PtEtaPhiMVector v1(pos1_prop.getPt(), pos1_prop.getEta(), pos1_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos2_prop.getPt(), pos2_prop.getEta(), pos2_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lspp/hM"), v12.M()); - } // end of positive track loop - } // end of postive track loop - - for (auto& ele1 : negTracks_per_coll) { - for (auto& ele2 : negTracks_per_coll) { - if (ele1.globalIndex() == ele2.globalIndex()) { - continue; - } - - auto ele1_prop = propagateTrack(collision, ele1); - auto ele2_prop = propagateTrack(collision, ele2); - - std::array pVec_ele1 = {0, 0, 0}; // px, py, pz - getPxPyPz(ele1_prop, pVec_ele1); - std::array pVec_ele2 = {0, 0, 0}; // px, py, pz - getPxPyPz(ele2_prop, pVec_ele2); - - ROOT::Math::PtEtaPhiMVector v1(ele1_prop.getPt(), ele1_prop.getEta(), ele1_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(ele2_prop.getPt(), ele2_prop.getEta(), ele2_prop.getPhi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - fRegistry.fill(HIST("Pair/lsmm/hM"), v12.M()); - } // end of negative track loop - } // end of negative track loop - } - - if (nee_uls < 1) { - filter(nee_uls, 0, 0); - continue; - } - filter(nee_uls, 0, 0); - - posTracks_per_coll.clear(); - negTracks_per_coll.clear(); - posTracks_per_coll.shrink_to_fit(); - negTracks_per_coll.shrink_to_fit(); - - } // end of collision loop - - stored_trackIds.clear(); - stored_trackIds.shrink_to_fit(); - stored_pairIds.clear(); - stored_pairIds.shrink_to_fit(); - } - PROCESS_SWITCH(filterDielectronEvent, processMC_TTCA, "process reconstructed info only", false); // with TTCA -}; -struct prefilterPrimaryElectron { - Produces ele_pfb; - void process(aod::EMPrimaryElectrons const& primaryelectrons) - { - for (int i = 0; i < primaryelectrons.size(); i++) { - ele_pfb(0); - } - } -}; -struct associateAmbiguousElectron { - Produces em_amb_ele_ids; - - SliceCache cache; - PresliceUnsorted perTrack = o2::aod::emprimaryelectron::trackId; - std::vector ambele_self_Ids; - - void process(aod::EMPrimaryElectrons const& electrons) - { - for (auto& electron : electrons) { - auto electrons_with_same_trackId = electrons.sliceBy(perTrack, electron.trackId()); - ambele_self_Ids.reserve(electrons_with_same_trackId.size()); - for (auto& amb_ele : electrons_with_same_trackId) { - if (amb_ele.globalIndex() == electron.globalIndex()) { // don't store myself. - continue; - } - ambele_self_Ids.emplace_back(amb_ele.globalIndex()); - } - em_amb_ele_ids(ambele_self_Ids); - ambele_self_Ids.clear(); - ambele_self_Ids.shrink_to_fit(); - } - } -}; -struct createEMEvent2VP { - using MyBCs = soa::Join; - using MyQvectors = soa::Join; - - using MyCollisions = soa::Join; - using MyCollisions_Cent = soa::Join; // centrality table has dependency on multiplicity table. - using MyCollisions_Cent_Qvec = soa::Join; - - using MyCollisionsWithSWT = soa::Join; - using MyCollisionsWithSWT_Cent = soa::Join; // centrality table has dependency on multiplicity table. - using MyCollisionsWithSWT_Cent_Qvec = soa::Join; - - using MyCollisionsMC = soa::Join; - using MyCollisionsMC_Cent = soa::Join; // centrality table has dependency on multiplicity table. - using MyCollisionsMC_Cent_Qvec = soa::Join; - - Produces event; - // Produces eventcov; - Produces event_mult; - Produces event_cent; - Produces event_qvec; - Produces emswtbit; - - enum class EMEventType : int { - kEvent = 0, - kEvent_Cent = 1, - kEvent_Cent_Qvec = 2, - }; - - HistogramRegistry registry{"registry"}; - void init(o2::framework::InitContext&) - { - auto hEventCounter = registry.add("hEventCounter", "hEventCounter", kTH1I, {{7, 0.5f, 7.5f}}); - hEventCounter->GetXaxis()->SetBinLabel(1, "all"); - hEventCounter->GetXaxis()->SetBinLabel(2, "sel8"); - - registry.add("hNInspectedTVX", "N inspected TVX;run number;N_{TVX}", kTProfile, {{80000, 520000.5, 600000.5}}, true); - } - - ~createEMEvent2VP() - { - swt_names.clear(); - swt_names.shrink_to_fit(); - } - - std::vector mTOIidx; - std::vector swt_names; - uint64_t mNinspectedTVX{0}; - - int mRunNumber; - - template - void skimEvent(TCollisions const& collisions, TBCs const&) - { - for (auto& collision : collisions) { - if constexpr (isMC) { - if (!collision.has_mcCollision()) { - continue; - } - } - - if constexpr (isTriggerAnalysis) { - if (collision.swtaliastmp_raw() == 0) { - continue; - } - } - - auto bc = collision.template foundBC_as(); - - if (!collision.isSelected()) { - continue; - } - - if (!(collision.neeuls() >= 1 || collision.neeuls() + collision.ngpcm() >= 2)) { - continue; - } - - if constexpr (isTriggerAnalysis) { - emswtbit(collision.swtaliastmp_raw(), collision.nInspectedTVX()); - } - - // LOGF(info, "collision.neeuls() = %d, collision.ngpcm() = %d", collision.neeuls(), collision.ngpcm()); - // LOGF(info, "collision.multNTracksPV() = %d, collision.multFT0A() = %f, collision.multFT0C() = %f", collision.multNTracksPV(), collision.multFT0A(), collision.multFT0C()); - - registry.fill(HIST("hEventCounter"), 1); - - event(collision.globalIndex(), bc.runNumber(), bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), - collision.posX(), collision.posY(), collision.posZ(), - collision.numContrib(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); - - // eventcov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); - - event_mult(collision.multFT0A(), collision.multFT0C(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); - - if constexpr (eventype == EMEventType::kEvent) { - event_cent(105.f, 105.f, 105.f); - event_qvec( - 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, - 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f); - } else if constexpr (eventype == EMEventType::kEvent_Cent) { - event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C()); - event_qvec( - 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, - 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f); - } else if constexpr (eventype == EMEventType::kEvent_Cent_Qvec) { - event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C()); - float q2xft0m = 999.f, q2yft0m = 999.f, q2xft0a = 999.f, q2yft0a = 999.f, q2xft0c = 999.f, q2yft0c = 999.f, q2xbpos = 999.f, q2ybpos = 999.f, q2xbneg = 999.f, q2ybneg = 999.f, q2xbtot = 999.f, q2ybtot = 999.f; - float q3xft0m = 999.f, q3yft0m = 999.f, q3xft0a = 999.f, q3yft0a = 999.f, q3xft0c = 999.f, q3yft0c = 999.f, q3xbpos = 999.f, q3ybpos = 999.f, q3xbneg = 999.f, q3ybneg = 999.f, q3xbtot = 999.f, q3ybtot = 999.f; - - if (collision.qvecFT0CReVec().size() >= 2) { // harmonics 2,3 - q2xft0m = collision.qvecFT0MReVec()[0], q2xft0a = collision.qvecFT0AReVec()[0], q2xft0c = collision.qvecFT0CReVec()[0], q2xbpos = collision.qvecBPosReVec()[0], q2xbneg = collision.qvecBNegReVec()[0], q2xbtot = collision.qvecBTotReVec()[0]; - q2yft0m = collision.qvecFT0MImVec()[0], q2yft0a = collision.qvecFT0AImVec()[0], q2yft0c = collision.qvecFT0CImVec()[0], q2ybpos = collision.qvecBPosImVec()[0], q2ybneg = collision.qvecBNegImVec()[0], q2ybtot = collision.qvecBTotImVec()[0]; - q3xft0m = collision.qvecFT0MReVec()[1], q3xft0a = collision.qvecFT0AReVec()[1], q3xft0c = collision.qvecFT0CReVec()[1], q3xbpos = collision.qvecBPosReVec()[1], q3xbneg = collision.qvecBNegReVec()[1], q3xbtot = collision.qvecBTotReVec()[1]; - q3yft0m = collision.qvecFT0MImVec()[1], q3yft0a = collision.qvecFT0AImVec()[1], q3yft0c = collision.qvecFT0CImVec()[1], q3ybpos = collision.qvecBPosImVec()[1], q3ybneg = collision.qvecBNegImVec()[1], q3ybtot = collision.qvecBTotImVec()[1]; - } else if (collision.qvecFT0CReVec().size() >= 1) { // harmonics 2 - q2xft0m = collision.qvecFT0MReVec()[0], q2xft0a = collision.qvecFT0AReVec()[0], q2xft0c = collision.qvecFT0CReVec()[0], q2xbpos = collision.qvecBPosReVec()[0], q2xbneg = collision.qvecBNegReVec()[0], q2xbtot = collision.qvecBTotReVec()[0]; - q2yft0m = collision.qvecFT0MImVec()[0], q2yft0a = collision.qvecFT0AImVec()[0], q2yft0c = collision.qvecFT0CImVec()[0], q2ybpos = collision.qvecBPosImVec()[0], q2ybneg = collision.qvecBNegImVec()[0], q2ybtot = collision.qvecBTotImVec()[0]; - } - event_qvec( - q2xft0m, q2yft0m, q2xft0a, q2yft0a, q2xft0c, q2yft0c, q2xbpos, q2ybpos, q2xbneg, q2ybneg, q2xbtot, q2ybtot, - q3xft0m, q3yft0m, q3xft0a, q3yft0a, q3xft0c, q3yft0c, q3xbpos, q3ybpos, q3xbneg, q3ybneg, q3xbtot, q3ybtot); - } else { - event_cent(105.f, 105.f, 105.f); - event_qvec( - 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, - 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f); - } - } // end of collision loop - } // end of skimEvent - - void processEvent(MyCollisions const& collisions, MyBCs const& bcs) - { - skimEvent(collisions, bcs); - } - PROCESS_SWITCH(createEMEvent2VP, processEvent, "process event info", false); - - void processEvent_Cent(MyCollisions_Cent const& collisions, MyBCs const& bcs) - { - skimEvent(collisions, bcs); - } - PROCESS_SWITCH(createEMEvent2VP, processEvent_Cent, "process event info", false); - - void processEvent_Cent_Qvec(MyCollisions_Cent_Qvec const& collisions, MyBCs const& bcs) - { - skimEvent(collisions, bcs); - } - PROCESS_SWITCH(createEMEvent2VP, processEvent_Cent_Qvec, "process event info", false); - - void processEvent_SWT(MyCollisionsWithSWT const& collisions, MyBCs const& bcs) - { - skimEvent(collisions, bcs); - } - PROCESS_SWITCH(createEMEvent2VP, processEvent_SWT, "process event info", false); - - void processEvent_SWT_Cent(MyCollisionsWithSWT_Cent const& collisions, MyBCs const& bcs) - { - skimEvent(collisions, bcs); - } - PROCESS_SWITCH(createEMEvent2VP, processEvent_SWT_Cent, "process event info", false); - - void processEvent_SWT_Cent_Qvec(MyCollisionsWithSWT_Cent_Qvec const& collisions, MyBCs const& bcs) - { - skimEvent(collisions, bcs); - } - PROCESS_SWITCH(createEMEvent2VP, processEvent_SWT_Cent_Qvec, "process event info", false); - - void processEventMC(MyCollisionsMC const& collisions, MyBCs const& bcs) - { - skimEvent(collisions, bcs); - } - PROCESS_SWITCH(createEMEvent2VP, processEventMC, "process event info", false); - - void processEventMC_Cent(MyCollisionsMC_Cent const& collisions, MyBCs const& bcs) - { - skimEvent(collisions, bcs); - } - PROCESS_SWITCH(createEMEvent2VP, processEventMC_Cent, "process event info", false); - - void processEventMC_Cent_Qvec(MyCollisionsMC_Cent_Qvec const& collisions, MyBCs const& bcs) - { - skimEvent(collisions, bcs); - } - PROCESS_SWITCH(createEMEvent2VP, processEventMC_Cent_Qvec, "process event info", false); - - void processDummy(aod::Collisions const&) {} - PROCESS_SWITCH(createEMEvent2VP, processDummy, "processDummy", true); -}; -struct AssociateDileptonToEMEvent2VP { - Produces v0kfeventid; - Produces prmeleventid; - - Preslice perCollision_pcm = aod::v0photonkf::collisionId; - PresliceUnsorted perCollision_el = aod::emprimaryelectron::collisionId; - - void init(o2::framework::InitContext&) {} - - template - void fillEventId(TCollisions const& collisions, TLeptons const& leptons, TEventIds& eventIds, TPreslice const& perCollision) - { - for (auto& collision : collisions) { - auto leptons_coll = leptons.sliceBy(perCollision, collision.collisionId()); - int nl = leptons_coll.size(); - // LOGF(info, "collision.collisionId() = %d , nl = %d", collision.collisionId(), nl); - for (int il = 0; il < nl; il++) { - eventIds(collision.globalIndex()); - } // end of photon loop - } // end of collision loop - } - - // This struct is for both data and MC. - // Note that reconstructed collisions without mc collisions are already rejected in CreateEMEventDilepton in MC. - - void processPCM(aod::EMEvents const& collisions, aod::V0PhotonsKF const& photons) - { - fillEventId(collisions, photons, v0kfeventid, perCollision_pcm); - } - - void processElectron(aod::EMEvents const& collisions, aod::EMPrimaryElectrons const& tracks) - { - fillEventId(collisions, tracks, prmeleventid, perCollision_el); - } - - void processDummy(aod::EMEvents const&) {} - - PROCESS_SWITCH(AssociateDileptonToEMEvent2VP, processPCM, "process pcm-event indexing", false); - PROCESS_SWITCH(AssociateDileptonToEMEvent2VP, processElectron, "process dalitzee-event indexing", false); - PROCESS_SWITCH(AssociateDileptonToEMEvent2VP, processDummy, "process dummy", true); -}; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"filter-dielectron-event"}), - adaptAnalysisTask(cfgc, TaskName{"prefilter-primary-electron"}), - adaptAnalysisTask(cfgc, TaskName{"associate-ambiguous-electron"}), - adaptAnalysisTask(cfgc, TaskName{"create-emevent-2vp"}), - adaptAnalysisTask(cfgc, TaskName{"associate-dilepton-to-emevent2VP"}), - }; -} diff --git a/PWGEM/Dilepton/TableProducer/filterEoI.cxx b/PWGEM/Dilepton/TableProducer/filterEoI.cxx index ca7b524e19d..ef232718485 100644 --- a/PWGEM/Dilepton/TableProducer/filterEoI.cxx +++ b/PWGEM/Dilepton/TableProducer/filterEoI.cxx @@ -14,11 +14,13 @@ // This code filters events that are interesting for dilepton analyses. // Please write to: daiki.sekihata@cern.ch -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" #include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" using namespace o2; using namespace o2::framework; @@ -29,55 +31,73 @@ struct filterEoI { enum SubSystem { kElectron = 0x1, kFwdMuon = 0x2, + kPCM = 0x4, }; Produces emeoi; + Configurable minNElectrons{"minNElectrons", 1, "min number of e+ or e- at midrapidity"}; + Configurable minNMuons{"minNMuons", 1, "min number of mu+ or mu- at forward rapidity"}; + Configurable minNV0s{"minNV0s", 1, "min number of v0 photons at midrapidity"}; HistogramRegistry fRegistry{"output"}; void init(o2::framework::InitContext&) { - auto hEventCounter = fRegistry.add("hEventCounter", "hEventCounter", kTH1D, {{5, 0.5f, 5.5f}}); + auto hEventCounter = fRegistry.add("hEventCounter", "hEventCounter", kTH1D, {{7, 0.5f, 7.5f}}); hEventCounter->GetXaxis()->SetBinLabel(1, "all"); hEventCounter->GetXaxis()->SetBinLabel(2, "event with electron"); hEventCounter->GetXaxis()->SetBinLabel(3, "event with forward muon"); - hEventCounter->GetXaxis()->SetBinLabel(4, "event with electron or forward muon"); - hEventCounter->GetXaxis()->SetBinLabel(5, "event with electron and forward muon"); + hEventCounter->GetXaxis()->SetBinLabel(4, "event with v0"); + hEventCounter->GetXaxis()->SetBinLabel(5, "event with electron or forward muon"); + hEventCounter->GetXaxis()->SetBinLabel(6, "event with electron and forward muon"); + hEventCounter->GetXaxis()->SetBinLabel(7, "event with electron or forward muon or v0"); } SliceCache cache; Preslice perCollision_el = aod::emprimaryelectron::collisionId; Preslice perCollision_mu = aod::emprimarymuon::collisionId; + Preslice perCollision_v0 = aod::v0photonkf::collisionId; - template - void selectEoI(TCollisions const& collisions, TElectrons const& electrons, TMuons const& muons) + template + void selectEoI(TCollisions const& collisions, TElectrons const& electrons, TMuons const& muons, TV0s const& v0s) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { bool does_electron_exist = false; bool does_fwdmuon_exist = false; + bool does_pcm_exist = false; fRegistry.fill(HIST("hEventCounter"), 1); if constexpr (static_cast(system & kElectron)) { auto electrons_coll = electrons.sliceBy(perCollision_el, collision.globalIndex()); - if (electrons_coll.size() > 0) { + if (electrons_coll.size() >= minNElectrons) { does_electron_exist = true; fRegistry.fill(HIST("hEventCounter"), 2); } } if constexpr (static_cast(system & kFwdMuon)) { auto muons_coll = muons.sliceBy(perCollision_mu, collision.globalIndex()); - if (muons_coll.size() > 0) { + if (muons_coll.size() >= minNMuons) { does_fwdmuon_exist = true; fRegistry.fill(HIST("hEventCounter"), 3); } } + if constexpr (static_cast(system & kPCM)) { + auto v0s_coll = v0s.sliceBy(perCollision_v0, collision.globalIndex()); + if (v0s_coll.size() >= minNV0s) { + does_pcm_exist = true; + fRegistry.fill(HIST("hEventCounter"), 4); + } + } if (does_electron_exist || does_fwdmuon_exist) { - fRegistry.fill(HIST("hEventCounter"), 4); + fRegistry.fill(HIST("hEventCounter"), 5); } if (does_electron_exist && does_fwdmuon_exist) { - fRegistry.fill(HIST("hEventCounter"), 5); + fRegistry.fill(HIST("hEventCounter"), 6); + } + if (does_electron_exist || does_fwdmuon_exist || does_pcm_exist) { + fRegistry.fill(HIST("hEventCounter"), 7); } - emeoi(does_electron_exist || does_fwdmuon_exist); + emeoi(does_electron_exist || does_fwdmuon_exist || does_pcm_exist); } // end of collision loop @@ -86,19 +106,31 @@ struct filterEoI { void process_Electron(aod::Collisions const& collisions, aod::EMPrimaryElectrons const& electrons) { const uint8_t sysflag = kElectron; - selectEoI(collisions, electrons, nullptr); + selectEoI(collisions, electrons, nullptr, nullptr); } void process_FwdMuon(aod::Collisions const& collisions, aod::EMPrimaryMuons const& muons) { const uint8_t sysflag = kFwdMuon; - selectEoI(collisions, nullptr, muons); + selectEoI(collisions, nullptr, muons, nullptr); } void process_Electron_FwdMuon(aod::Collisions const& collisions, aod::EMPrimaryElectrons const& electrons, aod::EMPrimaryMuons const& muons) { const uint8_t sysflag = kElectron | kFwdMuon; - selectEoI(collisions, electrons, muons); + selectEoI(collisions, electrons, muons, nullptr); + } + + void process_PCM(aod::Collisions const& collisions, aod::V0PhotonsKF const& v0s) + { + const uint8_t sysflag = kPCM; + selectEoI(collisions, nullptr, nullptr, v0s); + } + + void process_Electron_FwdMuon_PCM(aod::Collisions const& collisions, aod::EMPrimaryElectrons const& electrons, aod::EMPrimaryMuons const& muons, aod::V0PhotonsKF const& v0s) + { + const uint8_t sysflag = kElectron | kFwdMuon | kPCM; + selectEoI(collisions, electrons, muons, v0s); } void processDummy(aod::Collisions const& collisions) @@ -110,7 +142,9 @@ struct filterEoI { PROCESS_SWITCH(filterEoI, process_Electron, "create filter bit for Electron", false); PROCESS_SWITCH(filterEoI, process_FwdMuon, "create filter bit for Forward Muon", false); + PROCESS_SWITCH(filterEoI, process_PCM, "create filter bit for PCM", false); PROCESS_SWITCH(filterEoI, process_Electron_FwdMuon, "create filter bit for Electron, FwdMuon", false); + PROCESS_SWITCH(filterEoI, process_Electron_FwdMuon_PCM, "create filter bit for Electron, FwdMuon, PCM", false); PROCESS_SWITCH(filterEoI, processDummy, "processDummy", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx b/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx index 3ea6dc842d8..997f8c4e6a5 100644 --- a/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx +++ b/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx @@ -14,16 +14,19 @@ // This code produces trigger information. OTS = offline trigger selection. // Please write to: daiki.sekihata@cern.ch -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" -#include "CCDB/BasicCCDBManager.h" -#include "EventFiltering/Zorro.h" #include "Common/Core/TableHelper.h" +#include "EventFiltering/Zorro.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "CCDB/BasicCCDBManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include +#include using namespace o2; using namespace o2::framework; @@ -100,7 +103,7 @@ struct skimmerOTS { void process(MyCollisions const& collisions, MyBCs const&) { for (auto& collision : collisions) { - auto bc = collision.template foundBC_as(); + auto bc = collision.template bc_as(); // don't use foundBC. initCCDB(bc); uint16_t trigger_bitmap = 0; diff --git a/PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx b/PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx index 22f25acd26a..8d19b297dcf 100644 --- a/PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx +++ b/PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx @@ -12,29 +12,34 @@ /// \brief write relevant information about primary electrons. /// \author daiki.sekihata@cern.ch -#include -#include -#include -#include +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/MlResponseO2Track.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" +#include "Common/Core/TableHelper.h" #include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" #include "Common/DataModel/CollisionAssociationTables.h" -#include "Common/Core/TableHelper.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/PIDResponseITS.h" +#include "Tools/ML/MlResponse.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" + +#include +#include +#include +#include using namespace o2; using namespace o2::soa; @@ -45,16 +50,16 @@ using namespace o2::constants::physics; using MyCollisions = soa::Join; using MyCollisionsWithSWT = soa::Join; -using MyTracks = soa::Join; using MyTrack = MyTracks::iterator; -using MyTracksMC = soa::Join; +using MyTracksMC = soa::Join; using MyTrackMC = MyTracksMC::iterator; struct skimmerPrimaryElectron { SliceCache cache; - Preslice perCol = o2::aod::track::collisionId; + Preslice perCol = o2::aod::track::collisionId; Produces emprimaryelectrons; Produces emprimaryelectronscov; @@ -62,22 +67,24 @@ struct skimmerPrimaryElectron { Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; // Operation and minimisation criteria Configurable fillQAHistogram{"fillQAHistogram", false, "flag to fill QA histograms"}; Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; - Configurable min_ncluster_tpc{"min_ncluster_tpc", 10, "min ncluster tpc"}; + Configurable min_ncluster_tpc{"min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable mincrossedrows{"mincrossedrows", 70, "min. crossed rows"}; Configurable min_tpc_cr_findable_ratio{"min_tpc_cr_findable_ratio", 0.8, "min. TPC Ncr/Nf ratio"}; Configurable min_ncluster_its{"min_ncluster_its", 4, "min ncluster its"}; Configurable min_ncluster_itsib{"min_ncluster_itsib", 1, "min ncluster itsib"}; Configurable maxchi2tpc{"maxchi2tpc", 5.0, "max. chi2/NclsTPC"}; Configurable maxchi2its{"maxchi2its", 6.0, "max. chi2/NclsITS"}; - Configurable minpt{"minpt", 0.15, "min pt for track"}; + Configurable minpt{"minpt", 0.15, "min pt for ITS-TPC track"}; Configurable maxeta{"maxeta", 0.9, "eta acceptance"}; - Configurable dca_xy_max{"dca_xy_max", 1.0f, "max DCAxy in cm"}; - Configurable dca_z_max{"dca_z_max", 1.0f, "max DCAz in cm"}; + Configurable dca_xy_max{"dca_xy_max", 1.0, "max DCAxy in cm"}; + Configurable dca_z_max{"dca_z_max", 1.0, "max DCAz in cm"}; Configurable dca_3d_sigma_max{"dca_3d_sigma_max", 1e+10, "max DCA 3D in sigma"}; Configurable minTPCNsigmaEl{"minTPCNsigmaEl", -2.5, "min. TPC n sigma for electron inclusion"}; Configurable maxTPCNsigmaEl{"maxTPCNsigmaEl", 3.5, "max. TPC n sigma for electron inclusion"}; @@ -89,15 +96,38 @@ struct skimmerPrimaryElectron { Configurable maxTPCNsigmaPr{"maxTPCNsigmaPr", 2.5, "max. TPC n sigma for proton exclusion"}; Configurable minTPCNsigmaPr{"minTPCNsigmaPr", -2.5, "min. TPC n sigma for proton exclusion"}; Configurable requireTOF{"requireTOF", false, "require TOF hit"}; - Configurable max_pin_for_pion_rejection{"max_pin_for_pion_rejection", 1e+10, "pion rejection is applied below this pin"}; + Configurable min_pin_for_pion_rejection{"min_pin_for_pion_rejection", 0.0, "pion rejection is applied above this pin"}; // this is used only in TOFreq + Configurable max_pin_for_pion_rejection{"max_pin_for_pion_rejection", 0.5, "pion rejection is applied below this pin"}; Configurable max_frac_shared_clusters_tpc{"max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to include ITSsa tracks"}; + Configurable maxpt_itssa{"maxpt_itssa", 0.15, "max pt for ITSsa track"}; + Configurable maxMeanITSClusterSize{"maxMeanITSClusterSize", 16, "max x cos(lambda)"}; + Configurable storeOnlyTrueElectronMC{"storeOnlyTrueElectronMC", false, "Flag to store only true electron in MC"}; + + // configuration for PID ML + Configurable usePIDML{"usePIDML", false, "Flag to use PID ML"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; + Configurable> onnxPathsCCDB{"onnxPathsCCDB", std::vector{"path"}, "Paths of models on CCDB"}; + Configurable> binsMl{"binsMl", std::vector{-999999., 999999.}, "Bin limits for ML application"}; + Configurable> cutsMl{"cutsMl", std::vector{0.95}, "ML cuts per bin"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature"}, "Names of ML model input features"}; + Configurable nameBinningFeature{"nameBinningFeature", "pt", "Names of ML model binning feature"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB. Exceptions: > 0 for the specific timestamp, 0 gets the run dependent timestamp"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + Configurable enableOptimizations{"enableOptimizations", false, "Enables the ONNX extended model-optimization: sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED)"}; HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + o2::analysis::MlResponseO2Track mlResponseSingleTrack; int mRunNumber; float d_bz; Service ccdb; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + // o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + o2::dataformats::VertexBase mVtx; + const o2::dataformats::MeanVertexObject* mMeanVtx = nullptr; + o2::base::MatLayerCylSet* lut = nullptr; + o2::ccdb::CcdbApi ccdbApi; void init(InitContext&) { @@ -108,6 +138,7 @@ struct skimmerPrimaryElectron { ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); + ccdbApi.init(ccdburl); if (fillQAHistogram) { fRegistry.add("Track/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); @@ -128,6 +159,7 @@ struct skimmerPrimaryElectron { fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); fRegistry.add("Track/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); + fRegistry.add("Track/hTPCdEdxMC", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); fRegistry.add("Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); @@ -139,13 +171,35 @@ struct skimmerPrimaryElectron { fRegistry.add("Track/hTOFNsigmaPi", "TOF n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/hTOFNsigmaKa", "TOF n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/hTOFNsigmaPr", "TOF n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); on ITS #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {150, 0, 15}}, false); - fRegistry.add("Track/hITSNsigmaEl", "ITS n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hITSNsigmaMu", "ITS n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hITSNsigmaPi", "ITS n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hITSNsigmaKa", "ITS n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hITSNsigmaPr", "ITS n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {150, 0, 15}}, false); + fRegistry.add("Track/hMeanClusterSizeITSib", "mean cluster size ITSib;p_{pv} (GeV/c); #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {150, 0, 15}}, false); + fRegistry.add("Track/hMeanClusterSizeITSob", "mean cluster size ITSob;p_{pv} (GeV/c); #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {150, 0, 15}}, false); } + + if (usePIDML) { + static constexpr int nClassesMl = 2; + const std::vector cutDirMl = {o2::cuts_ml::CutNot, o2::cuts_ml::CutSmaller}; + const std::vector labelsClasses = {"Background", "Signal"}; + const uint32_t nBinsMl = binsMl.value.size() - 1; + const std::vector labelsBins(nBinsMl, "bin"); + double cutsMlArr[nBinsMl][nClassesMl]; + for (uint32_t i = 0; i < nBinsMl; i++) { + cutsMlArr[i][0] = 0.0; + cutsMlArr[i][1] = cutsMl.value[i]; + } + o2::framework::LabeledArray cutsMl = {cutsMlArr[0], nBinsMl, nClassesMl, labelsBins, labelsClasses}; + + mlResponseSingleTrack.configure(binsMl.value, cutsMl, cutDirMl, nClassesMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdburl); + mlResponseSingleTrack.setModelPathsCCDB(onnxFileNames.value, ccdbApi, onnxPathsCCDB.value, timestampCCDB.value); + } else { + mlResponseSingleTrack.setModelPathsLocal(onnxFileNames.value); + } + mlResponseSingleTrack.cacheInputFeaturesIndices(namesInputFeatures); + mlResponseSingleTrack.cacheBinningIndex(nameBinningFeature); + mlResponseSingleTrack.init(enableOptimizations.value); + } // end of PID ML } void initCCDB(aod::BCsWithTimestamps::iterator const& bc) @@ -154,14 +208,24 @@ struct skimmerPrimaryElectron { return; } + // load matLUT for this timestamp + if (!lut) { + LOG(info) << "Loading material look-up table for timestamp: " << bc.timestamp(); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(lutPath, bc.timestamp())); + } else { + LOG(info) << "Material look-up table already in place. Not reloading."; + } + // In case override, don't proceed, please - no CCDB access required if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } o2::base::Propagator::initFieldFromGRP(&grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); mRunNumber = bc.runNumber(); return; } @@ -169,10 +233,13 @@ struct skimmerPrimaryElectron { auto run3grp_timestamp = bc.timestamp(); o2::parameters::GRPObject* grpo = 0x0; o2::parameters::GRPMagField* grpmag = 0x0; - if (!skipGRPOquery) + if (!skipGRPOquery) { grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + } if (grpo) { o2::base::Propagator::initFieldFromGRP(grpo); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); // Fetch magnetic field from ccdb for current collision d_bz = grpo->getNominalL3Field(); LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; @@ -182,6 +249,9 @@ struct skimmerPrimaryElectron { LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; } o2::base::Propagator::initFieldFromGRP(grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + // Fetch magnetic field from ccdb for current collision d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; @@ -196,21 +266,23 @@ struct skimmerPrimaryElectron { if (!track.has_mcParticle()) { return false; } + if (storeOnlyTrueElectronMC) { + const auto& mcParticle = track.template mcParticle_as(); + if (std::abs(mcParticle.pdgCode()) != 11) { + return false; + } + } } - if (requireTOF && !(track.hasTOF() && abs(track.tofNSigmaEl()) < maxTOFNsigmaEl)) { - return false; - } - - if (track.tpcChi2NCl() > maxchi2tpc) { + if (requireTOF && !(track.hasTOF() && std::fabs(track.tofNSigmaEl()) < maxTOFNsigmaEl)) { return false; } - if (track.itsChi2NCl() > maxchi2its) { + if (!track.hasITS()) { return false; } - if (!track.hasITS() || !track.hasTPC()) { + if (track.itsChi2NCl() < 0.f || maxchi2its < track.itsChi2NCl()) { return false; } if (track.itsNCls() < min_ncluster_its) { @@ -220,62 +292,151 @@ struct skimmerPrimaryElectron { return false; } - if (track.tpcNClsFound() < min_ncluster_tpc) { - return false; - } - - if (track.tpcNClsCrossedRows() < mincrossedrows) { + if (!includeITSsa && (!track.hasITS() || !track.hasTPC())) { return false; } - if (track.tpcCrossedRowsOverFindableCls() < min_tpc_cr_findable_ratio) { - return false; - } + if (track.hasTPC()) { + if (track.tpcChi2NCl() < 0.f || maxchi2tpc < track.tpcChi2NCl()) { + return false; + } - if (track.tpcFractionSharedCls() > max_frac_shared_clusters_tpc) { - return false; - } + if (track.tpcNClsFound() < min_ncluster_tpc) { + return false; + } - if (track.hasTOF() && (maxTOFNsigmaEl < fabs(track.tofNSigmaEl()))) { - return false; - } + if (track.tpcNClsCrossedRows() < mincrossedrows) { + return false; + } - gpu::gpustd::array dcaInfo; - auto track_par_cov_recalc = getTrackParCov(track); - track_par_cov_recalc.setPID(o2::track::PID::Electron); - std::array pVec_recalc = {0, 0, 0}; // px, py, pz - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); - float dcaXY = dcaInfo[0]; - float dcaZ = dcaInfo[1]; + if (track.tpcCrossedRowsOverFindableCls() < min_tpc_cr_findable_ratio) { + return false; + } - if (fabs(dcaXY) > dca_xy_max || fabs(dcaZ) > dca_z_max) { - return false; + if (track.tpcFractionSharedCls() > max_frac_shared_clusters_tpc) { + return false; + } } - if (track_par_cov_recalc.getPt() < minpt || fabs(track_par_cov_recalc.getEta()) > maxeta) { + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(o2::track::PID::Electron); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + if (std::fabs(dcaXY) > dca_xy_max || std::fabs(dcaZ) > dca_z_max) { return false; } float dca_3d = 999.f; - float det = track_par_cov_recalc.getSigmaY2() * track_par_cov_recalc.getSigmaZ2() - track_par_cov_recalc.getSigmaZY() * track_par_cov_recalc.getSigmaZY(); + float det = trackParCov.getSigmaY2() * trackParCov.getSigmaZ2() - trackParCov.getSigmaZY() * trackParCov.getSigmaZY(); if (det < 0) { dca_3d = 999.f; } else { - float chi2 = (dcaXY * dcaXY * track_par_cov_recalc.getSigmaZ2() + dcaZ * dcaZ * track_par_cov_recalc.getSigmaY2() - 2. * dcaXY * dcaZ * track_par_cov_recalc.getSigmaZY()) / det; + float chi2 = (dcaXY * dcaXY * trackParCov.getSigmaZ2() + dcaZ * dcaZ * trackParCov.getSigmaY2() - 2. * dcaXY * dcaZ * trackParCov.getSigmaZY()) / det; dca_3d = std::sqrt(std::fabs(chi2) / 2.); } if (dca_3d > dca_3d_sigma_max) { return false; } + if (trackParCov.getPt() < minpt || std::fabs(trackParCov.getEta()) > maxeta) { + return false; + } + + if ((track.hasITS() && !track.hasTPC() && !track.hasTOF() && !track.hasTRD()) && maxpt_itssa < trackParCov.getPt()) { + return false; + } + + if (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF()) { + int total_cluster_size = 0, nl = 0; + for (unsigned int layer = 0; layer < 7; layer++) { + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); + if (cluster_size_per_layer > 0) { + nl++; + } + total_cluster_size += cluster_size_per_layer; + } + + if (maxMeanITSClusterSize < static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(trackParCov.getTgl()))) { + return false; + } + } + + // these are necessary cuts for converting float into int16_t. + if (track.hasTPC()) { + if (std::fabs(track.tpcNSigmaEl()) > 300.f) { + return false; + } + if (std::fabs(track.tpcNSigmaPi()) > 300.f) { + return false; + } + if (std::fabs(track.tpcNSigmaKa()) > 300.f) { + return false; + } + if (std::fabs(track.tpcNSigmaPr()) > 300.f) { + return false; + } + if (track.tpcSignal() > 600.f) { + return false; + } + if constexpr (isMC) { + if (track.mcTunedTPCSignal() > 600.f) { + return false; + } + } + } + if (track.hasTOF()) { + if (std::fabs(track.tofNSigmaEl()) > 300.f) { + return false; + } + if (std::fabs(track.tofNSigmaPi()) > 300.f) { + return false; + } + if (std::fabs(track.tofNSigmaKa()) > 300.f) { + return false; + } + if (std::fabs(track.tofNSigmaPr()) > 300.f) { + return false; + } + } return true; } - template - bool isElectron(TTrack const& track) + template + bool isElectron(TCollision const& collision, TTrack const& track) { - return isElectron_TPChadrej(track) || isElectron_TOFreq(track); + if (includeITSsa && (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF())) { + return true; + } + + if (usePIDML) { + if (track.tpcNSigmaEl() < minTPCNsigmaEl || maxTPCNsigmaEl < track.tpcNSigmaEl()) { + return false; + } + if (track.hasTOF() && (maxTOFNsigmaEl < std::fabs(track.tofNSigmaEl()))) { + return false; + } + + // return false; + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(o2::track::PID::Electron); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + + std::vector inputFeatures = mlResponseSingleTrack.getInputFeatures(track, trackParCov, collision); + float binningFeature = mlResponseSingleTrack.getBinningFeature(track, trackParCov, collision); + return mlResponseSingleTrack.isSelectedMl(inputFeatures, binningFeature); + } else { + return isElectron_TPChadrej(track) || isElectron_TOFreq(track); + } } template @@ -293,7 +454,7 @@ struct skimmerPrimaryElectron { if (minTPCNsigmaPr < track.tpcNSigmaPr() && track.tpcNSigmaPr() < maxTPCNsigmaPr) { return false; } - if (track.hasTOF() && (maxTOFNsigmaEl < fabs(track.tofNSigmaEl()))) { + if (track.hasTOF() && (maxTOFNsigmaEl < std::fabs(track.tofNSigmaEl()))) { return false; } return true; @@ -302,78 +463,127 @@ struct skimmerPrimaryElectron { template bool isElectron_TOFreq(TTrack const& track) { - if (minTPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < maxTPCNsigmaPi && track.tpcInnerParam() < max_pin_for_pion_rejection) { + if (minTPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < maxTPCNsigmaPi && (min_pin_for_pion_rejection < track.tpcInnerParam() && track.tpcInnerParam() < max_pin_for_pion_rejection)) { return false; } - return minTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < maxTPCNsigmaEl && fabs(track.tofNSigmaEl()) < maxTOFNsigmaEl; + return minTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < maxTPCNsigmaEl && std::fabs(track.tofNSigmaEl()) < maxTOFNsigmaEl; } - template + template void fillTrackTable(TCollision const& collision, TTrack const& track) { if (std::find(stored_trackIds.begin(), stored_trackIds.end(), std::pair{collision.globalIndex(), track.globalIndex()}) == stored_trackIds.end()) { - gpu::gpustd::array dcaInfo; - auto track_par_cov_recalc = getTrackParCov(track); - track_par_cov_recalc.setPID(o2::track::PID::Electron); - std::array pVec_recalc = {0, 0, 0}; // px, py, pz - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); - float dcaXY = dcaInfo[0]; - float dcaZ = dcaInfo[1]; - - float pt_recalc = track_par_cov_recalc.getPt(); - float eta_recalc = track_par_cov_recalc.getEta(); - float phi_recalc = track_par_cov_recalc.getPhi(); + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(o2::track::PID::Electron); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + float pt_recalc = trackParCov.getPt(); + float eta_recalc = trackParCov.getEta(); + float phi_recalc = trackParCov.getPhi(); + o2::math_utils::bringTo02Pi(phi_recalc); bool isAssociatedToMPC = collision.globalIndex() == track.collisionId(); + float mcTunedTPCSignal = 0.f; + if constexpr (isMC) { + if (track.hasTPC()) { + mcTunedTPCSignal = track.mcTunedTPCSignal(); + } + } + + float itsChi2NCl = (track.hasITS() && track.itsChi2NCl() > 0.f) ? track.itsChi2NCl() : -299.f; + float tpcChi2NCl = (track.hasTPC() && track.tpcChi2NCl() > 0.f) ? track.tpcChi2NCl() : -299.f; + float beta = track.hasTOF() ? track.beta() : -29.f; + float tofNSigmaEl = track.hasTOF() ? track.tofNSigmaEl() : -299.f; + float tofNSigmaPi = track.hasTOF() ? track.tofNSigmaPi() : -299.f; + float tofNSigmaKa = track.hasTOF() ? track.tofNSigmaKa() : -299.f; + float tofNSigmaPr = track.hasTOF() ? track.tofNSigmaPr() : -299.f; + float tofChi2 = track.hasTOF() ? track.tofChi2() : -299.f; + + float tpcSignal = track.hasTPC() ? track.tpcSignal() : 0.f; + float tpcNSigmaEl = track.hasTPC() ? track.tpcNSigmaEl() : -299.f; + float tpcNSigmaPi = track.hasTPC() ? track.tpcNSigmaPi() : -299.f; + float tpcNSigmaKa = track.hasTPC() ? track.tpcNSigmaKa() : -299.f; + float tpcNSigmaPr = track.hasTPC() ? track.tpcNSigmaPr() : -299.f; emprimaryelectrons(collision.globalIndex(), track.globalIndex(), track.sign(), - pt_recalc, eta_recalc, phi_recalc, dcaXY, dcaZ, + pt_recalc, eta_recalc, phi_recalc, + dcaXY, dcaZ, trackParCov.getSigmaY2(), trackParCov.getSigmaZY(), trackParCov.getSigmaZ2(), track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), track.tpcNClsShared(), - track.tpcChi2NCl(), track.tpcInnerParam(), - track.tpcSignal(), track.tpcNSigmaEl(), track.tpcNSigmaMu(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), - track.beta(), track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), - track.itsClusterSizes(), track.itsNSigmaEl(), track.itsNSigmaMu(), track.itsNSigmaPi(), track.itsNSigmaKa(), track.itsNSigmaPr(), - track.itsChi2NCl(), track.tofChi2(), track.detectorMap(), - track_par_cov_recalc.getX(), track_par_cov_recalc.getAlpha(), track_par_cov_recalc.getY(), track_par_cov_recalc.getZ(), track_par_cov_recalc.getSnp(), track_par_cov_recalc.getTgl(), isAssociatedToMPC); + static_cast(tpcChi2NCl * 1e+2), track.tpcInnerParam(), + static_cast(tpcSignal * 1e+2), static_cast(tpcNSigmaEl * 1e+2), static_cast(tpcNSigmaPi * 1e+2), static_cast(tpcNSigmaKa * 1e+2), static_cast(tpcNSigmaPr * 1e+2), + static_cast(beta * 1e+3), static_cast(tofNSigmaEl * 1e+2), static_cast(tofNSigmaPi * 1e+2), static_cast(tofNSigmaKa * 1e+2), static_cast(tofNSigmaPr * 1e+2), + track.itsClusterSizes(), + static_cast(itsChi2NCl * 1e+2), static_cast(tofChi2 * 1e+2), track.detectorMap(), + trackParCov.getTgl(), + isAssociatedToMPC, false, 1.f, static_cast(mcTunedTPCSignal * 1e+2)); emprimaryelectronscov( - track_par_cov_recalc.getSigmaY2(), - track_par_cov_recalc.getSigmaZY(), - track_par_cov_recalc.getSigmaZ2(), - track_par_cov_recalc.getSigmaSnpY(), - track_par_cov_recalc.getSigmaSnpZ(), - track_par_cov_recalc.getSigmaSnp2(), - track_par_cov_recalc.getSigmaTglY(), - track_par_cov_recalc.getSigmaTglZ(), - track_par_cov_recalc.getSigmaTglSnp(), - track_par_cov_recalc.getSigmaTgl2(), - track_par_cov_recalc.getSigma1PtY(), - track_par_cov_recalc.getSigma1PtZ(), - track_par_cov_recalc.getSigma1PtSnp(), - track_par_cov_recalc.getSigma1PtTgl(), - track_par_cov_recalc.getSigma1Pt2()); + trackParCov.getX(), + trackParCov.getAlpha(), + trackParCov.getY(), + trackParCov.getZ(), + trackParCov.getSnp(), + // trackParCov.getTgl(), + // trackParCov.getSigmaY2(), + // trackParCov.getSigmaZY(), + // trackParCov.getSigmaZ2(), + trackParCov.getSigmaSnpY(), + trackParCov.getSigmaSnpZ(), + trackParCov.getSigmaSnp2(), + trackParCov.getSigmaTglY(), + trackParCov.getSigmaTglZ(), + trackParCov.getSigmaTglSnp(), + trackParCov.getSigmaTgl2(), + trackParCov.getSigma1PtY(), + trackParCov.getSigma1PtZ(), + trackParCov.getSigma1PtSnp(), + trackParCov.getSigma1PtTgl(), + trackParCov.getSigma1Pt2()); stored_trackIds.emplace_back(std::pair{collision.globalIndex(), track.globalIndex()}); if (fillQAHistogram) { - uint32_t itsClusterSizes = track.itsClusterSizes(); + // uint32_t itsClusterSizes = track.itsClusterSizes(); int total_cluster_size = 0, nl = 0; for (unsigned int layer = 0; layer < 7; layer++) { - int cluster_size_per_layer = (itsClusterSizes >> (layer * 4)) & 0xf; + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); if (cluster_size_per_layer > 0) { nl++; } total_cluster_size += cluster_size_per_layer; } + int total_cluster_size_ib = 0, nl_ib = 0; + for (unsigned int layer = 0; layer < 3; layer++) { + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); + if (cluster_size_per_layer > 0) { + nl_ib++; + } + total_cluster_size_ib += cluster_size_per_layer; + } + + int total_cluster_size_ob = 0, nl_ob = 0; + for (unsigned int layer = 3; layer < 7; layer++) { + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); + if (cluster_size_per_layer > 0) { + nl_ob++; + } + total_cluster_size_ob += cluster_size_per_layer; + } + fRegistry.fill(HIST("Track/hPt"), pt_recalc); fRegistry.fill(HIST("Track/hQoverPt"), track.sign() / pt_recalc); fRegistry.fill(HIST("Track/hEtaPhi"), phi_recalc, eta_recalc); fRegistry.fill(HIST("Track/hDCAxyz"), dcaXY, dcaZ); - fRegistry.fill(HIST("Track/hDCAxyzSigma"), dcaXY / sqrt(track_par_cov_recalc.getSigmaY2()), dcaZ / sqrt(track_par_cov_recalc.getSigmaZ2())); - fRegistry.fill(HIST("Track/hDCAxyRes_Pt"), pt_recalc, sqrt(track_par_cov_recalc.getSigmaY2()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/hDCAzRes_Pt"), pt_recalc, sqrt(track_par_cov_recalc.getSigmaZ2()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/hDCAxyzSigma"), dcaXY / std::sqrt(trackParCov.getSigmaY2()), dcaZ / std::sqrt(trackParCov.getSigmaZ2())); + fRegistry.fill(HIST("Track/hDCAxyRes_Pt"), pt_recalc, std::sqrt(trackParCov.getSigmaY2()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/hDCAzRes_Pt"), pt_recalc, std::sqrt(trackParCov.getSigmaZ2()) * 1e+4); // convert cm to um fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); @@ -385,31 +595,28 @@ struct skimmerPrimaryElectron { fRegistry.fill(HIST("Track/hChi2TOF"), track.tofChi2()); fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); fRegistry.fill(HIST("Track/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + fRegistry.fill(HIST("Track/hTPCdEdxMC"), track.tpcInnerParam(), mcTunedTPCSignal); fRegistry.fill(HIST("Track/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); fRegistry.fill(HIST("Track/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); fRegistry.fill(HIST("Track/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); fRegistry.fill(HIST("Track/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); fRegistry.fill(HIST("Track/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); - fRegistry.fill(HIST("Track/hTOFbeta"), track.p(), track.beta()); + fRegistry.fill(HIST("Track/hTOFbeta"), trackParCov.getP(), track.beta()); fRegistry.fill(HIST("Track/hTOFNsigmaEl"), track.tpcInnerParam(), track.tofNSigmaEl()); fRegistry.fill(HIST("Track/hTOFNsigmaMu"), track.tpcInnerParam(), track.tofNSigmaMu()); fRegistry.fill(HIST("Track/hTOFNsigmaPi"), track.tpcInnerParam(), track.tofNSigmaPi()); fRegistry.fill(HIST("Track/hTOFNsigmaKa"), track.tpcInnerParam(), track.tofNSigmaKa()); fRegistry.fill(HIST("Track/hTOFNsigmaPr"), track.tpcInnerParam(), track.tofNSigmaPr()); - fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), track.p(), static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(track.tgl()))); - fRegistry.fill(HIST("Track/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); - fRegistry.fill(HIST("Track/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); - fRegistry.fill(HIST("Track/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); - fRegistry.fill(HIST("Track/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); - fRegistry.fill(HIST("Track/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); + fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), trackParCov.getP(), static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(trackParCov.getTgl()))); + fRegistry.fill(HIST("Track/hMeanClusterSizeITSib"), trackParCov.getP(), static_cast(total_cluster_size_ib) / static_cast(nl_ib) * std::cos(std::atan(trackParCov.getTgl()))); + fRegistry.fill(HIST("Track/hMeanClusterSizeITSob"), trackParCov.getP(), static_cast(total_cluster_size_ob) / static_cast(nl_ob) * std::cos(std::atan(trackParCov.getTgl()))); } } } Preslice trackIndicesPerCollision = aod::track_association::collisionId; std::vector> stored_trackIds; - Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::tpcChi2NCl < maxchi2tpc&& o2::aod::track::itsChi2NCl < maxchi2its&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true; - Filter pidFilter = minTPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < maxTPCNsigmaEl; + Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::itsChi2NCl < maxchi2its&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true; using MyFilteredTracks = soa::Filtered; Partition posTracks = o2::aod::track::signed1Pt > 0.f; @@ -419,10 +626,9 @@ struct skimmerPrimaryElectron { void processRec_SA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks) { - auto tracksWithITSPid = soa::Attach(tracks); stored_trackIds.reserve(tracks.size()); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto bc = collision.template foundBC_as(); initCCDB(bc); @@ -430,12 +636,12 @@ struct skimmerPrimaryElectron { continue; } - auto tracks_per_coll = tracksWithITSPid.sliceBy(perCol, collision.globalIndex()); - for (auto& track : tracks_per_coll) { - if (!checkTrack(collision, track) || !isElectron(track)) { + auto tracks_per_coll = tracks.sliceBy(perCol, collision.globalIndex()); + for (const auto& track : tracks_per_coll) { + if (!checkTrack(collision, track) || !isElectron(collision, track)) { continue; } - fillTrackTable(collision, track); + fillTrackTable(collision, track); } } // end of collision loop @@ -447,10 +653,9 @@ struct skimmerPrimaryElectron { void processRec_TTCA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::TrackAssoc const& trackIndices) { - auto tracksWithITSPid = soa::Attach(tracks); stored_trackIds.reserve(tracks.size() * 2); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto bc = collision.template foundBC_as(); initCCDB(bc); @@ -460,13 +665,12 @@ struct skimmerPrimaryElectron { auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); - for (auto& trackId : trackIdsThisCollision) { - // auto track = trackId.template track_as(); - auto track = tracksWithITSPid.rawIteratorAt(trackId.trackId()); - if (!checkTrack(collision, track) || !isElectron(track)) { + for (const auto& trackId : trackIdsThisCollision) { + auto track = trackId.template track_as(); + if (!checkTrack(collision, track) || !isElectron(collision, track)) { continue; } - fillTrackTable(collision, track); + fillTrackTable(collision, track); } } // end of collision loop @@ -477,10 +681,9 @@ struct skimmerPrimaryElectron { void processRec_SA_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks) { - auto tracksWithITSPid = soa::Attach(tracks); stored_trackIds.reserve(tracks.size()); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto bc = collision.template foundBC_as(); initCCDB(bc); @@ -492,12 +695,12 @@ struct skimmerPrimaryElectron { continue; } - auto tracks_per_coll = tracksWithITSPid.sliceBy(perCol, collision.globalIndex()); - for (auto& track : tracks_per_coll) { - if (!checkTrack(collision, track) || !isElectron(track)) { + auto tracks_per_coll = tracks.sliceBy(perCol, collision.globalIndex()); + for (const auto& track : tracks_per_coll) { + if (!checkTrack(collision, track) || !isElectron(collision, track)) { continue; } - fillTrackTable(collision, track); + fillTrackTable(collision, track); } } // end of collision loop @@ -509,10 +712,9 @@ struct skimmerPrimaryElectron { void processRec_TTCA_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::TrackAssoc const& trackIndices) { - auto tracksWithITSPid = soa::Attach(tracks); stored_trackIds.reserve(tracks.size() * 2); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto bc = collision.template foundBC_as(); initCCDB(bc); @@ -525,13 +727,12 @@ struct skimmerPrimaryElectron { auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); - for (auto& trackId : trackIdsThisCollision) { - // auto track = trackId.template track_as(); - auto track = tracksWithITSPid.rawIteratorAt(trackId.trackId()); - if (!checkTrack(collision, track) || !isElectron(track)) { + for (const auto& trackId : trackIdsThisCollision) { + auto track = trackId.template track_as(); + if (!checkTrack(collision, track) || !isElectron(collision, track)) { continue; } - fillTrackTable(collision, track); + fillTrackTable(collision, track); } } // end of collision loop @@ -545,12 +746,11 @@ struct skimmerPrimaryElectron { using MyFilteredTracksMC = soa::Filtered; Partition posTracksMC = o2::aod::track::signed1Pt > 0.f; Partition negTracksMC = o2::aod::track::signed1Pt < 0.f; - void processMC_SA(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks) + void processMC_SA(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks, aod::McParticles const&) { - auto tracksWithITSPid = soa::Attach(tracks); stored_trackIds.reserve(tracks.size()); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { if (!collision.has_mcCollision()) { continue; } @@ -561,12 +761,12 @@ struct skimmerPrimaryElectron { continue; } - auto tracks_per_coll = tracksWithITSPid.sliceBy(perCol, collision.globalIndex()); - for (auto& track : tracks_per_coll) { - if (!checkTrack(collision, track) || !isElectron(track)) { + auto tracks_per_coll = tracks.sliceBy(perCol, collision.globalIndex()); + for (const auto& track : tracks_per_coll) { + if (!checkTrack(collision, track) || !isElectron(collision, track)) { continue; } - fillTrackTable(collision, track); + fillTrackTable(collision, track); } } // end of collision loop @@ -575,12 +775,11 @@ struct skimmerPrimaryElectron { } PROCESS_SWITCH(skimmerPrimaryElectron, processMC_SA, "process reconstructed and MC info ", false); - void processMC_TTCA(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyTracksMC const& tracks, aod::TrackAssoc const& trackIndices) + void processMC_TTCA(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyTracksMC const& tracks, aod::TrackAssoc const& trackIndices, aod::McParticles const&) { - auto tracksWithITSPid = soa::Attach(tracks); stored_trackIds.reserve(tracks.size() * 2); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { if (!collision.has_mcCollision()) { continue; } @@ -593,13 +792,12 @@ struct skimmerPrimaryElectron { auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); - for (auto& trackId : trackIdsThisCollision) { - // auto track = trackId.template track_as(); - auto track = tracksWithITSPid.rawIteratorAt(trackId.trackId()); - if (!checkTrack(collision, track) || !isElectron(track)) { + for (const auto& trackId : trackIdsThisCollision) { + auto track = trackId.template track_as(); + if (!checkTrack(collision, track) || !isElectron(collision, track)) { continue; } - fillTrackTable(collision, track); + fillTrackTable(collision, track); } } // end of collision loop @@ -613,22 +811,25 @@ struct prefilterPrimaryElectron { Produces ele_pfb; SliceCache cache; - Preslice perCol_track = o2::aod::track::collisionId; + Preslice perCol_track = o2::aod::track::collisionId; PresliceUnsorted perCol_ele = o2::aod::emprimaryelectron::collisionId; // CCDB options Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; // Operation and minimisation criteria Configurable d_bz_input{"d_bz", -999, "bz field, -999 is automatic"}; + Configurable fillQAHistogram{"fillQAHistogram", false, "flag to fill QA histograms"}; Configurable max_dcaxy{"max_dcaxy", 0.3, "DCAxy To PV for loose track sample"}; Configurable max_dcaz{"max_dcaz", 0.3, "DCAz To PV for loose track sample"}; - Configurable minpt{"minpt", 0.1, "min pt for track for loose track sample"}; - Configurable maxeta{"maxeta", 0.9, "eta acceptance for loose track sample"}; + Configurable minpt{"minpt", 0.1, "min pt for ITS-TPC track"}; + Configurable maxeta{"maxeta", 1.2, "eta acceptance for loose track sample"}; Configurable min_ncluster_tpc{"min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable mincrossedrows{"mincrossedrows", 70, "min crossed rows"}; Configurable max_frac_shared_clusters_tpc{"max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; @@ -637,19 +838,26 @@ struct prefilterPrimaryElectron { Configurable maxchi2its{"maxchi2its", 6.0, "max chi2/NclsITS"}; Configurable min_ncluster_its{"min_ncluster_its", 4, "min ncluster its"}; Configurable min_ncluster_itsib{"min_ncluster_itsib", 1, "min ncluster itsib"}; - Configurable minTPCNsigmaEl{"minTPCNsigmaEl", -3.0, "min. TPC n sigma for electron inclusion"}; + Configurable minTPCNsigmaEl{"minTPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable maxTPCNsigmaEl{"maxTPCNsigmaEl", 3.0, "max. TPC n sigma for electron inclusion"}; Configurable slope{"slope", 0.0185, "slope for m vs. phiv"}; Configurable intercept{"intercept", -0.0280, "intercept for m vs. phiv"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to include ITSsa tracks"}; + Configurable maxpt_itssa{"maxpt_itssa", 0.15, "mix pt for ITSsa track"}; + Configurable maxMeanITSClusterSize{"maxMeanITSClusterSize", 16, "max x cos(lambda)"}; - Configurable> max_mee_vec{"max_mee_vec", std::vector{0.08, 0.10, 0.12}, "vector fo max mee for prefilter in ULS. Please sort this by increasing order."}; // currently, 3 thoresholds are allowed. + Configurable> max_mee_vec{"max_mee_vec", std::vector{0.06, 0.08, 0.10}, "vector fo max mee for prefilter in ULS. Please sort this by increasing order."}; // currently, 3 thoresholds are allowed. HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; int mRunNumber; float d_bz; Service ccdb; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + // o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + o2::dataformats::VertexBase mVtx; + const o2::dataformats::MeanVertexObject* mMeanVtx = nullptr; + o2::base::MatLayerCylSet* lut = nullptr; void init(InitContext&) { @@ -661,7 +869,7 @@ struct prefilterPrimaryElectron { ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); - if (!doprocessDummy) { + if (!doprocessDummy && fillQAHistogram) { addHistograms(); } } @@ -669,10 +877,10 @@ struct prefilterPrimaryElectron { void addHistograms() { fRegistry.add("Track/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -1.0f, 1.0f}}, false); + fRegistry.add("Track/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {80, -2.0f, 2.0f}}, false); fRegistry.add("Track/hTPCNsigmaEl", "loose track TPC PID", kTH2F, {{1000, 0.f, 10}, {100, -5, +5}}); - fRegistry.add("Pair/before/uls/hMvsPt", "mass vs. pT;m_{ee} (GeV/c^{2});p_{T,ee} (GeV/c)", kTH2F, {{400, 0, 4}, {100, 0, 10}}); - fRegistry.add("Pair/before/uls/hMvsPhiV", "mass vs. phiv;#varphi_{V} (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{90, 0.f, M_PI}, {100, 0, 1.f}}); + fRegistry.add("Pair/before/uls/hMvsPt", "mass vs. pT;m_{ee} (GeV/c^{2});p_{T,ee} (GeV/c)", kTH2F, {{500, 0, 0.5}, {100, 0, 1}}); + fRegistry.add("Pair/before/uls/hMvsPhiV", "mass vs. phiv;#varphi_{V} (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{90, 0.f, M_PI}, {100, 0, 0.1}}); fRegistry.addClone("Pair/before/uls/", "Pair/before/lspp/"); fRegistry.addClone("Pair/before/uls/", "Pair/before/lsmm/"); fRegistry.addClone("Pair/before/", "Pair/after/"); @@ -684,14 +892,24 @@ struct prefilterPrimaryElectron { return; } + // load matLUT for this timestamp + if (!lut) { + LOG(info) << "Loading material look-up table for timestamp: " << bc.timestamp(); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(lutPath, bc.timestamp())); + } else { + LOG(info) << "Material look-up table already in place. Not reloading."; + } + // In case override, don't proceed, please - no CCDB access required if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } o2::base::Propagator::initFieldFromGRP(&grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); mRunNumber = bc.runNumber(); return; } @@ -703,6 +921,8 @@ struct prefilterPrimaryElectron { grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); if (grpo) { o2::base::Propagator::initFieldFromGRP(grpo); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); // Fetch magnetic field from ccdb for current collision d_bz = grpo->getNominalL3Field(); LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; @@ -712,6 +932,8 @@ struct prefilterPrimaryElectron { LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; } o2::base::Propagator::initFieldFromGRP(grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); // Fetch magnetic field from ccdb for current collision d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; @@ -737,40 +959,66 @@ struct prefilterPrimaryElectron { return false; } - if (!track.hasTPC()) { - return false; - } - if (track.tpcNSigmaEl() < minTPCNsigmaEl || maxTPCNsigmaEl < track.tpcNSigmaEl()) { - return false; - } - if (track.tpcNClsFound() < min_ncluster_tpc) { + if (!includeITSsa && (!track.hasITS() || !track.hasTPC())) { return false; } - if (track.tpcNClsCrossedRows() < mincrossedrows) { - return false; - } - if (track.tpcCrossedRowsOverFindableCls() < min_tpc_cr_findable_ratio) { - return false; + + if (track.hasTPC()) { + if (track.tpcNSigmaEl() < minTPCNsigmaEl || maxTPCNsigmaEl < track.tpcNSigmaEl()) { + return false; + } + if (track.tpcNClsFound() < min_ncluster_tpc) { + return false; + } + if (track.tpcNClsCrossedRows() < mincrossedrows) { + return false; + } + if (track.tpcCrossedRowsOverFindableCls() < min_tpc_cr_findable_ratio) { + return false; + } + if (track.tpcFractionSharedCls() > max_frac_shared_clusters_tpc) { + return false; + } + if (track.tpcChi2NCl() > maxchi2tpc) { + return false; + } } - if (track.tpcFractionSharedCls() > max_frac_shared_clusters_tpc) { + + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(o2::track::PID::Electron); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + if (std::fabs(dcaXY) > max_dcaxy || std::fabs(dcaZ) > max_dcaz) { return false; } - if (track.tpcChi2NCl() > maxchi2its) { + + if (trackParCov.getPt() < minpt || std::fabs(trackParCov.getEta()) > maxeta) { return false; } - gpu::gpustd::array dcaInfo; - auto track_par_cov_recalc = getTrackParCov(track); - std::array pVec_recalc = {0, 0, 0}; // px, py, pz - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); - - if (fabs(dcaInfo[0]) > max_dcaxy || fabs(dcaInfo[1]) > max_dcaz) { + if ((track.hasITS() && !track.hasTPC() && !track.hasTOF() && !track.hasTRD()) && maxpt_itssa < trackParCov.getPt()) { return false; } - if (track_par_cov_recalc.getPt() < minpt || fabs(track_par_cov_recalc.getEta()) > maxeta) { - return false; + if (track.hasITS() && !track.hasTPC() && !track.hasTOF() && !track.hasTRD()) { + int total_cluster_size = 0, nl = 0; + for (unsigned int layer = 0; layer < 7; layer++) { + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); + if (cluster_size_per_layer > 0) { + nl++; + } + total_cluster_size += cluster_size_per_layer; + } + + if (maxMeanITSClusterSize < static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(trackParCov.getTgl()))) { + return false; + } } return true; @@ -780,25 +1028,28 @@ struct prefilterPrimaryElectron { bool reconstructPC(TCollision const& collision, TTrack1 const& ele, TTrack2 const& pos) { float mee = 0, phiv = 0; - gpu::gpustd::array dcaInfo; + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); std::array pVec_recalc = {0, 0, 0}; // px, py, pz + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); if constexpr (loose_track_sign > 0) { // positive track is loose track - auto track_par_cov_recalc = getTrackParCov(pos); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); + auto trackParCov = getTrackParCov(pos); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + getPxPyPz(trackParCov, pVec_recalc); ROOT::Math::PtEtaPhiMVector v1(ele.pt(), ele.eta(), ele.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(track_par_cov_recalc.getPt(), track_par_cov_recalc.getEta(), track_par_cov_recalc.getPhi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v2(trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; mee = v12.M(); phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pVec_recalc[0], pVec_recalc[1], pVec_recalc[2], ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); } else { - auto track_par_cov_recalc = getTrackParCov(ele); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); + auto trackParCov = getTrackParCov(ele); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + getPxPyPz(trackParCov, pVec_recalc); - ROOT::Math::PtEtaPhiMVector v1(track_par_cov_recalc.getPt(), track_par_cov_recalc.getEta(), track_par_cov_recalc.getPhi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v1(trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v2(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; mee = v12.M(); @@ -814,7 +1065,7 @@ struct prefilterPrimaryElectron { Preslice trackIndicesPerCollision = aod::track_association::collisionId; - Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true; + Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::itsChi2NCl < maxchi2its&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true; using MyFilteredTracks = soa::Filtered; Partition posTracks = o2::aod::track::signed1Pt > 0.f; Partition negTracks = o2::aod::track::signed1Pt < 0.f; @@ -826,7 +1077,7 @@ struct prefilterPrimaryElectron { { std::unordered_map pfb_map; // map track.globalIndex -> prefilter bit - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto bc = collision.template foundBC_as(); initCCDB(bc); if (!collision.isSelected()) { @@ -842,13 +1093,15 @@ struct prefilterPrimaryElectron { posTracks_per_coll.reserve(trackIdsThisCollision.size()); negTracks_per_coll.reserve(trackIdsThisCollision.size()); - for (auto& trackId : trackIdsThisCollision) { + for (const auto& trackId : trackIdsThisCollision) { auto track = trackId.template track_as(); if (!checkTrack(collision, track)) { continue; } - fRegistry.fill(HIST("Track/hPt"), track.pt()); - fRegistry.fill(HIST("Track/hEtaPhi"), track.phi(), track.eta()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Track/hPt"), track.pt()); + fRegistry.fill(HIST("Track/hEtaPhi"), track.phi(), track.eta()); + } if (track.sign() > 0) { posTracks_per_coll.emplace_back(track); } else { @@ -856,29 +1109,37 @@ struct prefilterPrimaryElectron { } } - for (auto& ele : negTracks_per_coll) { - if (!checkTrack(collision, ele)) { - continue; - } - gpu::gpustd::array dcaInfo; + for (const auto& ele : negTracks_per_coll) { + // if (!checkTrack(collision, ele)) { + // continue; + // } + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); std::array pVec_recalc = {0, 0, 0}; // px, py, pz - auto track_par_cov_recalc = getTrackParCov(ele); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); - - for (auto& empos : positrons_per_coll) { + auto trackParCov = getTrackParCov(ele); + trackParCov.setPID(o2::track::PID::Electron); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + getPxPyPz(trackParCov, pVec_recalc); + + for (const auto& empos : positrons_per_coll) { if (empos.trackId() == ele.globalIndex()) { continue; } - ROOT::Math::PtEtaPhiMVector v1(track_par_cov_recalc.getPt(), track_par_cov_recalc.getEta(), track_par_cov_recalc.getPhi(), o2::constants::physics::MassElectron); // loose track - ROOT::Math::PtEtaPhiMVector v2(empos.pt(), empos.eta(), empos.phi(), o2::constants::physics::MassElectron); // signal track + ROOT::Math::PtEtaPhiMVector v1(trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), o2::constants::physics::MassElectron); // loose track + ROOT::Math::PtEtaPhiMVector v2(empos.pt(), empos.eta(), empos.phi(), o2::constants::physics::MassElectron); // signal track ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(empos.px(), empos.py(), empos.pz(), pVec_recalc[0], pVec_recalc[1], pVec_recalc[2], empos.sign(), ele.sign(), d_bz); - fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); + } if (v12.M() < max_mee_vec->at(static_cast(max_mee_vec->size()) - 1)) { - fRegistry.fill(HIST("Track/hTPCNsigmaEl"), ele.tpcInnerParam(), ele.tpcNSigmaEl()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Track/hTPCNsigmaEl"), ele.tpcInnerParam(), ele.tpcNSigmaEl()); + } } for (int i = 0; i < static_cast(max_mee_vec->size()); i++) { if (v12.M() < max_mee_vec->at(i)) { @@ -893,28 +1154,36 @@ struct prefilterPrimaryElectron { } // end of signal positon loop } // end of loose electron loop - for (auto& pos : posTracks_per_coll) { - if (!checkTrack(collision, pos)) { // track cut is applied to loose sample - continue; - } - gpu::gpustd::array dcaInfo; + for (const auto& pos : posTracks_per_coll) { + // if (!checkTrack(collision, pos)) { // track cut is applied to loose sample + // continue; + // } + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); std::array pVec_recalc = {0, 0, 0}; // px, py, pz - auto track_par_cov_recalc = getTrackParCov(pos); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); - for (auto& emele : electrons_per_coll) { + auto trackParCov = getTrackParCov(pos); + trackParCov.setPID(o2::track::PID::Electron); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + getPxPyPz(trackParCov, pVec_recalc); + for (const auto& emele : electrons_per_coll) { if (emele.trackId() == pos.globalIndex()) { continue; } - ROOT::Math::PtEtaPhiMVector v1(emele.pt(), emele.eta(), emele.phi(), o2::constants::physics::MassElectron); // signal track - ROOT::Math::PtEtaPhiMVector v2(track_par_cov_recalc.getPt(), track_par_cov_recalc.getEta(), track_par_cov_recalc.getPhi(), o2::constants::physics::MassElectron); // loose track + ROOT::Math::PtEtaPhiMVector v1(emele.pt(), emele.eta(), emele.phi(), o2::constants::physics::MassElectron); // signal track + ROOT::Math::PtEtaPhiMVector v2(trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), o2::constants::physics::MassElectron); // loose track ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pVec_recalc[0], pVec_recalc[1], pVec_recalc[2], emele.px(), emele.py(), emele.pz(), pos.sign(), emele.sign(), d_bz); - fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); + } if (v12.M() < max_mee_vec->at(static_cast(max_mee_vec->size()) - 1)) { - fRegistry.fill(HIST("Track/hTPCNsigmaEl"), pos.tpcInnerParam(), pos.tpcNSigmaEl()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Track/hTPCNsigmaEl"), pos.tpcInnerParam(), pos.tpcNSigmaEl()); + } } for (int i = 0; i < static_cast(max_mee_vec->size()); i++) { if (v12.M() < max_mee_vec->at(i)) { @@ -928,50 +1197,62 @@ struct prefilterPrimaryElectron { } // end of signal electron loop } // end of loose positon loop - for (auto& pos : posTracks_per_coll) { - if (!checkTrack(collision, pos)) { // track cut is applied to loose sample - continue; - } - gpu::gpustd::array dcaInfo; + for (const auto& pos : posTracks_per_coll) { + // if (!checkTrack(collision, pos)) { // track cut is applied to loose sample + // continue; + // } + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); std::array pVec_recalc = {0, 0, 0}; // px, py, pz - auto track_par_cov_recalc = getTrackParCov(pos); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); - for (auto& empos : positrons_per_coll) { + auto trackParCov = getTrackParCov(pos); + trackParCov.setPID(o2::track::PID::Electron); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + getPxPyPz(trackParCov, pVec_recalc); + for (const auto& empos : positrons_per_coll) { if (empos.trackId() == pos.globalIndex()) { continue; } - ROOT::Math::PtEtaPhiMVector v1(empos.pt(), empos.eta(), empos.phi(), o2::constants::physics::MassElectron); // signal track - ROOT::Math::PtEtaPhiMVector v2(track_par_cov_recalc.getPt(), track_par_cov_recalc.getEta(), track_par_cov_recalc.getPhi(), o2::constants::physics::MassElectron); // loose track + ROOT::Math::PtEtaPhiMVector v1(empos.pt(), empos.eta(), empos.phi(), o2::constants::physics::MassElectron); // signal track + ROOT::Math::PtEtaPhiMVector v2(trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), o2::constants::physics::MassElectron); // loose track ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pVec_recalc[0], pVec_recalc[1], pVec_recalc[2], empos.px(), empos.py(), empos.pz(), pos.sign(), empos.sign(), d_bz); - fRegistry.fill(HIST("Pair/before/lspp/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/before/lspp/hMvsPt"), v12.M(), v12.Pt()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/before/lspp/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/before/lspp/hMvsPt"), v12.M(), v12.Pt()); + } } // end of signal positron loop } // end of loose positon loop - for (auto& ele : negTracks_per_coll) { - if (!checkTrack(collision, ele)) { - continue; - } - gpu::gpustd::array dcaInfo; + for (const auto& ele : negTracks_per_coll) { + // if (!checkTrack(collision, ele)) { + // continue; + // } + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); std::array pVec_recalc = {0, 0, 0}; // px, py, pz - auto track_par_cov_recalc = getTrackParCov(ele); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); - - for (auto& emele : electrons_per_coll) { + auto trackParCov = getTrackParCov(ele); + trackParCov.setPID(o2::track::PID::Electron); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + getPxPyPz(trackParCov, pVec_recalc); + + for (const auto& emele : electrons_per_coll) { if (emele.trackId() == ele.globalIndex()) { continue; } - ROOT::Math::PtEtaPhiMVector v1(track_par_cov_recalc.getPt(), track_par_cov_recalc.getEta(), track_par_cov_recalc.getPhi(), o2::constants::physics::MassElectron); // loose track - ROOT::Math::PtEtaPhiMVector v2(emele.pt(), emele.eta(), emele.phi(), o2::constants::physics::MassElectron); // signal track + ROOT::Math::PtEtaPhiMVector v1(trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), o2::constants::physics::MassElectron); // loose track + ROOT::Math::PtEtaPhiMVector v2(emele.pt(), emele.eta(), emele.phi(), o2::constants::physics::MassElectron); // signal track ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(emele.px(), emele.py(), emele.pz(), pVec_recalc[0], pVec_recalc[1], pVec_recalc[2], emele.sign(), ele.sign(), d_bz); - fRegistry.fill(HIST("Pair/before/lsmm/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/before/lsmm/hMvsPt"), v12.M(), v12.Pt()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/before/lsmm/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/before/lsmm/hMvsPt"), v12.M(), v12.Pt()); + } } // end of signal electron loop } // end of loose electron loop @@ -982,16 +1263,16 @@ struct prefilterPrimaryElectron { negTracks_per_coll.shrink_to_fit(); } // end of collision loop - for (auto& ele : primaryelectrons) { + for (const auto& ele : primaryelectrons) { ele_pfb(pfb_map[ele.globalIndex()]); } // check prefilter - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto positrons_per_coll = positrons->sliceByCachedUnsorted(o2::aod::emprimaryelectron::collisionId, collision.globalIndex(), cache); // signal sample auto electrons_per_coll = electrons->sliceByCachedUnsorted(o2::aod::emprimaryelectron::collisionId, collision.globalIndex(), cache); // signal sample - for (auto& [ele, pos] : combinations(CombinationsFullIndexPolicy(electrons_per_coll, positrons_per_coll))) { + for (const auto& [ele, pos] : combinations(CombinationsFullIndexPolicy(electrons_per_coll, positrons_per_coll))) { if (pfb_map[ele.globalIndex()] != 0 || pfb_map[pos.globalIndex()] != 0) { continue; } @@ -1000,9 +1281,10 @@ struct prefilterPrimaryElectron { ROOT::Math::PtEtaPhiMVector v2(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - fRegistry.fill(HIST("Pair/after/uls/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/after/uls/hMvsPt"), v12.M(), v12.Pt()); - + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/after/uls/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/after/uls/hMvsPt"), v12.M(), v12.Pt()); + } } // end of ULS pairing } // end of collision loop @@ -1014,7 +1296,7 @@ struct prefilterPrimaryElectron { { std::unordered_map pfb_map; // map track.globalIndex -> prefilter bit - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto bc = collision.template foundBC_as(); initCCDB(bc); if (!collision.isSelected()) { @@ -1027,22 +1309,26 @@ struct prefilterPrimaryElectron { auto positrons_per_coll = positrons->sliceByCachedUnsorted(o2::aod::emprimaryelectron::collisionId, collision.globalIndex(), cache); // signal sample auto electrons_per_coll = electrons->sliceByCachedUnsorted(o2::aod::emprimaryelectron::collisionId, collision.globalIndex(), cache); // signal sample - for (auto& pos : posTracks_per_coll) { + for (const auto& pos : posTracks_per_coll) { if (!checkTrack(collision, pos)) { // track cut is applied to loose sample continue; } - fRegistry.fill(HIST("Track/hPt"), pos.pt()); - fRegistry.fill(HIST("Track/hEtaPhi"), pos.phi(), pos.eta()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Track/hPt"), pos.pt()); + fRegistry.fill(HIST("Track/hEtaPhi"), pos.phi(), pos.eta()); + } } - for (auto& neg : negTracks_per_coll) { + for (const auto& neg : negTracks_per_coll) { if (!checkTrack(collision, neg)) { // track cut is applied to loose sample continue; } - fRegistry.fill(HIST("Track/hPt"), neg.pt()); - fRegistry.fill(HIST("Track/hEtaPhi"), neg.phi(), neg.eta()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Track/hPt"), neg.pt()); + fRegistry.fill(HIST("Track/hEtaPhi"), neg.phi(), neg.eta()); + } } - for (auto& [ele, empos] : combinations(CombinationsFullIndexPolicy(negTracks_per_coll, positrons_per_coll))) { + for (const auto& [ele, empos] : combinations(CombinationsFullIndexPolicy(negTracks_per_coll, positrons_per_coll))) { // auto pos = tracks.rawIteratorAt(empos.trackId()); // use rawIterator, if the table is filtered. if (!checkTrack(collision, ele)) { // track cut is applied to loose sample continue; @@ -1055,10 +1341,14 @@ struct prefilterPrimaryElectron { ROOT::Math::PtEtaPhiMVector v2(empos.pt(), empos.eta(), empos.phi(), o2::constants::physics::MassElectron); // signal track ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(empos.px(), empos.py(), empos.pz(), ele.px(), ele.py(), ele.pz(), empos.sign(), ele.sign(), d_bz); - fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); + } if (v12.M() < max_mee_vec->at(static_cast(max_mee_vec->size()) - 1)) { - fRegistry.fill(HIST("Track/hTPCNsigmaEl"), ele.tpcInnerParam(), ele.tpcNSigmaEl()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Track/hTPCNsigmaEl"), ele.tpcInnerParam(), ele.tpcNSigmaEl()); + } } for (int i = 0; i < static_cast(max_mee_vec->size()); i++) { if (v12.M() < max_mee_vec->at(i)) { @@ -1072,7 +1362,7 @@ struct prefilterPrimaryElectron { } // end of ULS pairing - for (auto& [pos, emele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, electrons_per_coll))) { + for (const auto& [pos, emele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, electrons_per_coll))) { // auto ele = tracks.rawIteratorAt(emele.trackId()); // use rawIterator, if the table is filtered. if (!checkTrack(collision, pos)) { // track cut is applied to loose sample continue; @@ -1085,10 +1375,14 @@ struct prefilterPrimaryElectron { ROOT::Math::PtEtaPhiMVector v2(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); // loose track ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), emele.px(), emele.py(), emele.pz(), pos.sign(), emele.sign(), d_bz); - fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); + } if (v12.M() < max_mee_vec->at(static_cast(max_mee_vec->size()) - 1)) { - fRegistry.fill(HIST("Track/hTPCNsigmaEl"), pos.tpcInnerParam(), pos.tpcNSigmaEl()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Track/hTPCNsigmaEl"), pos.tpcInnerParam(), pos.tpcNSigmaEl()); + } } for (int i = 0; i < static_cast(max_mee_vec->size()); i++) { if (v12.M() < max_mee_vec->at(i)) { @@ -1102,7 +1396,7 @@ struct prefilterPrimaryElectron { } // end of ULS pairing - for (auto& [pos, empos] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, positrons_per_coll))) { + for (const auto& [pos, empos] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, positrons_per_coll))) { // auto pos = tracks.rawIteratorAt(empos.trackId()); // use rawIterator, if the table is filtered. if (!checkTrack(collision, pos)) { // track cut is applied to loose sample continue; @@ -1115,11 +1409,13 @@ struct prefilterPrimaryElectron { ROOT::Math::PtEtaPhiMVector v2(empos.pt(), empos.eta(), empos.phi(), o2::constants::physics::MassElectron); // signal track ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(empos.px(), empos.py(), empos.pz(), pos.px(), pos.py(), pos.pz(), empos.sign(), pos.sign(), d_bz); - fRegistry.fill(HIST("Pair/before/lspp/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/before/lspp/hMvsPt"), v12.M(), v12.Pt()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/before/lspp/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/before/lspp/hMvsPt"), v12.M(), v12.Pt()); + } } // end of LS++ pairing - for (auto& [ele, emele] : combinations(CombinationsFullIndexPolicy(negTracks_per_coll, electrons_per_coll))) { + for (const auto& [ele, emele] : combinations(CombinationsFullIndexPolicy(negTracks_per_coll, electrons_per_coll))) { // auto ele = tracks.rawIteratorAt(emele.trackId()); // use rawIterator, if the table is filtered. if (!checkTrack(collision, ele)) { // track cut is applied to loose sample continue; @@ -1132,22 +1428,24 @@ struct prefilterPrimaryElectron { ROOT::Math::PtEtaPhiMVector v2(emele.pt(), emele.eta(), emele.phi(), o2::constants::physics::MassElectron); // signal track ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(emele.px(), emele.py(), emele.pz(), ele.px(), ele.py(), ele.pz(), emele.sign(), ele.sign(), d_bz); - fRegistry.fill(HIST("Pair/before/lsmm/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/before/lsmm/hMvsPt"), v12.M(), v12.Pt()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/before/lsmm/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/before/lsmm/hMvsPt"), v12.M(), v12.Pt()); + } } // end of LS-- pairing } // end of collision loop - for (auto& ele : primaryelectrons) { + for (const auto& ele : primaryelectrons) { ele_pfb(pfb_map[ele.globalIndex()]); } // check prefilter - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto positrons_per_coll = positrons->sliceByCachedUnsorted(o2::aod::emprimaryelectron::collisionId, collision.globalIndex(), cache); // signal sample auto electrons_per_coll = electrons->sliceByCachedUnsorted(o2::aod::emprimaryelectron::collisionId, collision.globalIndex(), cache); // signal sample - for (auto& [ele, pos] : combinations(CombinationsFullIndexPolicy(electrons_per_coll, positrons_per_coll))) { + for (const auto& [ele, pos] : combinations(CombinationsFullIndexPolicy(electrons_per_coll, positrons_per_coll))) { if (pfb_map[ele.globalIndex()] != 0 || pfb_map[pos.globalIndex()] != 0) { continue; } @@ -1156,8 +1454,10 @@ struct prefilterPrimaryElectron { ROOT::Math::PtEtaPhiMVector v2(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - fRegistry.fill(HIST("Pair/after/uls/hMvsPhiV"), phiv, v12.M()); - fRegistry.fill(HIST("Pair/after/uls/hMvsPt"), v12.M(), v12.Pt()); + if (fillQAHistogram) { + fRegistry.fill(HIST("Pair/after/uls/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/after/uls/hMvsPt"), v12.M(), v12.Pt()); + } } // end of ULS pairing } // end of collision loop @@ -1183,10 +1483,10 @@ struct associateAmbiguousElectron { void process(aod::EMPrimaryElectrons const& electrons) { - for (auto& electron : electrons) { + for (const auto& electron : electrons) { auto electrons_with_same_trackId = electrons.sliceBy(perTrack, electron.trackId()); ambele_self_Ids.reserve(electrons_with_same_trackId.size()); - for (auto& amb_ele : electrons_with_same_trackId) { + for (const auto& amb_ele : electrons_with_same_trackId) { if (amb_ele.globalIndex() == electron.globalIndex()) { // don't store myself. continue; } diff --git a/PWGEM/Dilepton/TableProducer/skimmerPrimaryMuon.cxx b/PWGEM/Dilepton/TableProducer/skimmerPrimaryMuon.cxx index fc46cf4760e..457e2787771 100644 --- a/PWGEM/Dilepton/TableProducer/skimmerPrimaryMuon.cxx +++ b/PWGEM/Dilepton/TableProducer/skimmerPrimaryMuon.cxx @@ -9,87 +9,90 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \brief write relevant information for dalitz ee analysis to an AO2D.root file. This file is then the only necessary input to perform pcm analysis. +/// \brief write relevant information for muons. /// \author daiki.sekihata@cern.ch -#include "Math/Vector4D.h" -#include "Math/SMatrix.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" -#include "Framework/DataTypes.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/DataModel/CollisionAssociationTables.h" #include "Common/Core/TableHelper.h" +#include "Common/Core/fwdtrackUtilities.h" +#include "Common/DataModel/CollisionAssociationTables.h" #include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" #include "DataFormatsParameters/GRPMagField.h" -#include "TGeoGlobalMagField.h" -#include "Field/MagneticField.h" - #include "DetectorsBase/Propagator.h" +#include "Field/MagneticField.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/DataTypes.h" +#include "Framework/runDataProcessing.h" #include "GlobalTracking/MatchGlobalFwd.h" #include "MCHTracking/TrackExtrap.h" #include "MCHTracking/TrackParam.h" #include "ReconstructionDataFormats/TrackFwd.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "Math/SMatrix.h" +#include "Math/Vector4D.h" +#include "TGeoGlobalMagField.h" + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::soa; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::constants::physics; +using namespace o2::aod::fwdtrackutils; -using MyCollisions = soa::Join; -using MyCollisionsWithSWT = soa::Join; - -using MyTracks = soa::Join; // muon tracks are repeated. i.e. not exclusive. -using MyTrack = MyTracks::iterator; - -using MyTracksMC = soa::Join; -using MyTrackMC = MyTracksMC::iterator; +struct skimmerPrimaryMuon { + using MyCollisions = soa::Join; + using MyCollisionsWithSWT = soa::Join; -using MFTTracksMC = soa::Join; -using MFTTrackMC = MFTTracksMC::iterator; + using MyFwdTracks = soa::Join; // muon tracks are repeated. i.e. not exclusive. + using MyFwdTrack = MyFwdTracks::iterator; -struct skimmerPrimaryMuon { - // Index used to set different options for Muon propagation - enum class MuonExtrapolation : int { - kToVertex = 0, // propagtion to vertex by default - kToDCA = 1, - kToRabs = 2, - }; + using MyFwdTracksMC = soa::Join; + using MyFwdTrackMC = MyFwdTracksMC::iterator; - using SMatrix55 = ROOT::Math::SMatrix>; - using SMatrix5 = ROOT::Math::SVector; + using MFTTracksMC = soa::Join; + using MFTTrackMC = MFTTracksMC::iterator; - SliceCache cache; - Preslice perCollision = o2::aod::fwdtrack::collisionId; - Preslice perCollision_mft = o2::aod::fwdtrack::collisionId; Produces emprimarymuons; Produces emprimarymuonscov; // Configurables - Configurable fillQAHistogram{"fillQAHistogram", false, "flag to fill QA histograms"}; Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - Configurable minpt{"minpt", 0.2, "min pt for muon"}; - Configurable mineta{"mineta", -4.0, "eta acceptance"}; - Configurable maxeta{"maxeta", -2.5, "eta acceptance"}; - Configurable mineta_mft{"mineta_mft", -3.6, "eta acceptance"}; - Configurable maxeta_mft{"maxeta_mft", -2.5, "eta acceptance"}; + Configurable fillQAHistograms{"fillQAHistograms", false, "flag to fill QA histograms"}; + Configurable minPt{"minPt", 0.2, "min pt for muon"}; + Configurable maxPt{"maxPt", 1e+10, "max pt for muon"}; + Configurable minEtaSA{"minEtaSA", -4.0, "min. eta acceptance for MCH-MID"}; + Configurable maxEtaSA{"maxEtaSA", -2.5, "max. eta acceptance for MCH-MID"}; + Configurable minEtaGL{"minEtaGL", -3.6, "min. eta acceptance for MFT-MCH-MID"}; + Configurable maxEtaGL{"maxEtaGL", -2.5, "max. eta acceptance for MFT-MCH-MID"}; + Configurable minRabsGL{"minRabsGL", 27.6, "min. R at absorber end for global muon (min. eta = -3.6)"}; // std::tan(2.f * std::atan(std::exp(- -3.6)) ) * -505. Configurable minRabs{"minRabs", 17.6, "min. R at absorber end"}; + Configurable midRabs{"midRabs", 26.5, "middle R at absorber end for pDCA cut"}; Configurable maxRabs{"maxRabs", 89.5, "max. R at absorber end"}; + Configurable maxDCAxy{"maxDCAxy", 1e+10, "max. DCAxy for global muons"}; + Configurable maxPDCAforLargeR{"maxPDCAforLargeR", 324.f, "max. pDCA for large R at absorber end"}; + Configurable maxPDCAforSmallR{"maxPDCAforSmallR", 594.f, "max. pDCA for small R at absorber end"}; + Configurable maxMatchingChi2MCHMFT{"maxMatchingChi2MCHMFT", 50.f, "max. chi2 for MCH-MFT matching"}; + Configurable maxChi2SA{"maxChi2SA", 1e+6, "max. chi2 for standalone muon"}; + Configurable maxChi2GL{"maxChi2GL", 1e+6, "max. chi2 for global muon"}; + Configurable refitGlobalMuon{"refitGlobalMuon", true, "flag to refit global muon"}; o2::ccdb::CcdbApi ccdbApi; Service ccdb; int mRunNumber; - o2::globaltracking::MatchGlobalFwd mMatching; HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; static constexpr std::string_view muon_types[5] = {"MFTMCHMID/", "MFTMCHMIDOtherMatch/", "MFTMCH/", "MCHMID/", "MCH/"}; @@ -101,8 +104,9 @@ struct skimmerPrimaryMuon { ccdb->setFatalWhenNull(false); ccdbApi.init(ccdburl); - addHistograms(); - + if (fillQAHistograms) { + addHistograms(); + } mRunNumber = 0; } @@ -111,8 +115,8 @@ struct skimmerPrimaryMuon { if (mRunNumber == bc.runNumber()) { return; } - mRunNumber = bc.runNumber(); + std::map metadata; auto soreor = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, mRunNumber); auto ts = soreor.first; @@ -126,476 +130,428 @@ struct skimmerPrimaryMuon { void addHistograms() { - fRegistry.add("Event/hCollisionCounter", "collision counter", kTH1F, {{2, -0.5f, 1.5}}, false); - fRegistry.add("Event/hNmuon", "Number of #mu per event;N_{#mu^{#minus}};N_{#mu^{+}}", kTH2F, {{101, -0.5f, 100.5}, {101, -0.5f, 100.5}}, false); - - // for track - if (fillQAHistogram) { - auto hMuonType = fRegistry.add("Track/hMuonType", "muon type", kTH1F, {{5, -0.5f, 4.5f}}); - hMuonType->GetXaxis()->SetBinLabel(1, "MFT-MCH-MID (global muon)"); - hMuonType->GetXaxis()->SetBinLabel(2, "MFT-MCH-MID (global muon other match)"); - hMuonType->GetXaxis()->SetBinLabel(3, "MFT-MCH"); - hMuonType->GetXaxis()->SetBinLabel(4, "MCH-MID"); - hMuonType->GetXaxis()->SetBinLabel(5, "MCH standalone"); - - fRegistry.add("Track/MFTMCHMID/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/MFTMCHMID/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{360, 0, 2 * M_PI}, {30, -5.0f, -2.0f}}, false); - fRegistry.add("Track/MFTMCHMID/hNclusters", "Nclusters;Nclusters", kTH1F, {{21, -0.5f, 20.5}}, false); - fRegistry.add("Track/MFTMCHMID/hNclustersMFT", "NclustersMFT;Nclusters MFT", kTH1F, {{11, -0.5f, 10.5}}, false); - fRegistry.add("Track/MFTMCHMID/hRatAbsorberEnd", "R at absorber end;R at absorber end (cm)", kTH1F, {{200, 0.0f, 200}}, false); - fRegistry.add("Track/MFTMCHMID/hPDCA", "pDCA;p_{T,#mu} at PV (GeV/c);p #times DCA (GeV/c #upoint cm)", kTH2F, {{100, 0, 10}, {100, 0.0f, 1000}}, false); - fRegistry.add("Track/MFTMCHMID/hPDCA_recalc", "pDCA relcalculated;p_{T,#mu} at PV (GeV/c);p #times DCA (GeV/c #upoint cm)", kTH2F, {{100, 0, 10}, {100, 0.0f, 1000}}, false); - fRegistry.add("Track/MFTMCHMID/hChi2", "chi2;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/MFTMCHMID/hChi2MatchMCHMID", "chi2 match MCH-MID;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/MFTMCHMID/hChi2MatchMCHMFT", "chi2 match MCH-MFT;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/MFTMCHMID/hMatchScoreMCHMFT", "match score MCH-MFT;score", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/MFTMCHMID/hDCAxy2D", "DCA xy;DCA_{x} (cm);DCA_{y} (cm)", kTH2F, {{200, -10, 10}, {200, -10, +10}}, false); - fRegistry.add("Track/MFTMCHMID/hDCAxy2DinSigma", "DCA xy;DCA_{x} (#sigma);DCA_{y} (#sigma)", kTH2F, {{200, -10, 10}, {200, -10, +10}}, false); - fRegistry.add("Track/MFTMCHMID/hDCAxySigma", "DCA_{xy};DCA_{xy} (#sigma);", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/MFTMCHMID/hDCAxResolutionvsPt", "DCA_{x} vs. p_{T,#mu};p_{T,#mu} (GeV/c);DCA_{x} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {100, 0, 100}}, false); - fRegistry.add("Track/MFTMCHMID/hDCAyResolutionvsPt", "DCA_{y} vs. p_{T,#mu};p_{T,#mu} (GeV/c);DCA_{y} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {100, 0, 100}}, false); - fRegistry.add("Track/MFTMCHMID/hChi2MatchMCHMFT_DCAxySigma", "chi2 match MCH-MFT;DCA_{xy,#mu} (#sigma);MFT-MCH matching chi2", kTH2F, {{100, 0, 10}, {100, 0.0f, 100}}, false); - fRegistry.add("Track/MFTMCHMID/hChi2MatchMCHMFT_Pt", "chi2 match MCH-MFT;p_{T,#mu} (GeV/c);MFT-MCH matching chi2", kTH2F, {{100, 0, 10}, {100, 0.0f, 100}}, false); - fRegistry.addClone("Track/MFTMCHMID/", "Track/MCHMID/"); - } + auto hMuonType = fRegistry.add("hMuonType", "muon type", kTH1F, {{5, -0.5f, 4.5f}}, false); + hMuonType->GetXaxis()->SetBinLabel(1, "MFT-MCH-MID (global muon)"); + hMuonType->GetXaxis()->SetBinLabel(2, "MFT-MCH-MID (global muon other match)"); + hMuonType->GetXaxis()->SetBinLabel(3, "MFT-MCH"); + hMuonType->GetXaxis()->SetBinLabel(4, "MCH-MID"); + hMuonType->GetXaxis()->SetBinLabel(5, "MCH standalone"); + + fRegistry.add("MFTMCHMID/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{100, 0.0f, 10}}, false); + fRegistry.add("MFTMCHMID/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {60, -5.f, -2.f}}, false); + fRegistry.add("MFTMCHMID/hEtaPhi_MatchedMCHMID", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {60, -5.f, -2.f}}, false); + fRegistry.add("MFTMCHMID/hDeltaPt_Pt", "#Deltap_{T}/p_{T} vs. p_{T};p_{T}^{gl} (GeV/c);(p_{T}^{sa} - p_{T}^{gl})/p_{T}^{gl}", kTH2F, {{100, 0, 10}, {200, -0.5, +0.5}}, false); + fRegistry.add("MFTMCHMID/hDeltaEta_Pt", "#Delta#eta vs. p_{T};p_{T}^{gl} (GeV/c);#Delta#eta", kTH2F, {{100, 0, 10}, {200, -0.5, +0.5}}, false); + fRegistry.add("MFTMCHMID/hDeltaPhi_Pt", "#Delta#varphi vs. p_{T};p_{T}^{gl} (GeV/c);#Delta#varphi (rad.)", kTH2F, {{100, 0, 10}, {200, -0.5, +0.5}}, false); + fRegistry.add("MFTMCHMID/hSign", "sign;sign", kTH1F, {{3, -1.5, +1.5}}, false); + fRegistry.add("MFTMCHMID/hNclusters", "Nclusters;Nclusters", kTH1F, {{21, -0.5f, 20.5}}, false); + fRegistry.add("MFTMCHMID/hNclustersMFT", "NclustersMFT;Nclusters MFT", kTH1F, {{11, -0.5f, 10.5}}, false); + fRegistry.add("MFTMCHMID/hRatAbsorberEnd", "R at absorber end;R at absorber end (cm)", kTH1F, {{100, 0.0f, 100}}, false); + fRegistry.add("MFTMCHMID/hPDCA_Rabs", "pDCA vs. Rabs;R at absorber end (cm);p #times DCA (GeV/c #upoint cm)", kTH2F, {{100, 0, 100}, {100, 0.0f, 1000}}, false); + fRegistry.add("MFTMCHMID/hChi2", "chi2;chi2/ndf", kTH1F, {{100, 0.0f, 10}}, false); + fRegistry.add("MFTMCHMID/hChi2MFT", "chi2 MFT;chi2 MFT/ndf", kTH1F, {{100, 0.0f, 10}}, false); + fRegistry.add("MFTMCHMID/hChi2MatchMCHMID", "chi2 match MCH-MID;chi2", kTH1F, {{100, 0.0f, 100}}, false); + fRegistry.add("MFTMCHMID/hChi2MatchMCHMFT", "chi2 match MCH-MFT;chi2", kTH1F, {{100, 0.0f, 100}}, false); + fRegistry.add("MFTMCHMID/hDCAxy2D", "DCA x vs. y;DCA_{x} (cm);DCA_{y} (cm)", kTH2F, {{200, -1, 1}, {200, -1, +1}}, false); + fRegistry.add("MFTMCHMID/hDCAxy2DinSigma", "DCA x vs. y in sigma;DCA_{x} (#sigma);DCA_{y} (#sigma)", kTH2F, {{200, -10, 10}, {200, -10, +10}}, false); + fRegistry.add("MFTMCHMID/hDCAxy", "DCAxy;DCA_{xy} (cm);", kTH1F, {{100, 0, 1}}, false); + fRegistry.add("MFTMCHMID/hDCAxyinSigma", "DCAxy in sigma;DCA_{xy} (#sigma);", kTH1F, {{100, 0, 10}}, false); + fRegistry.addClone("MFTMCHMID/", "MCHMID/"); + fRegistry.add("MFTMCHMID/hDCAxResolutionvsPt", "DCA_{x} vs. p_{T};p_{T} (GeV/c);DCA_{x} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {500, 0, 500}}, false); + fRegistry.add("MFTMCHMID/hDCAyResolutionvsPt", "DCA_{y} vs. p_{T};p_{T} (GeV/c);DCA_{y} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {500, 0, 500}}, false); + fRegistry.add("MFTMCHMID/hDCAxyResolutionvsPt", "DCA_{xy} vs. p_{T};p_{T} (GeV/c);DCA_{y} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {500, 0, 500}}, false); + fRegistry.add("MCHMID/hDCAxResolutionvsPt", "DCA_{x} vs. p_{T};p_{T} (GeV/c);DCA_{x} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {500, 0, 5e+5}}, false); + fRegistry.add("MCHMID/hDCAyResolutionvsPt", "DCA_{y} vs. p_{T};p_{T} (GeV/c);DCA_{y} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {500, 0, 5e+5}}, false); + fRegistry.add("MCHMID/hDCAxyResolutionvsPt", "DCA_{xy} vs. p_{T};p_{T} (GeV/c);DCA_{y} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {500, 0, 5e+5}}, false); } - template - void fillTrackHistogram(TTrack const& track, TCollision const& collision) + bool isSelected(const float pt, const float eta, const float rAtAbsorberEnd, const float pDCA, const float chi2_per_ndf, const uint8_t trackType, const float dcaXY) { - o2::dataformats::GlobalFwdTrack propmuonAtPV = PropagateMuon(track, collision, skimmerPrimaryMuon::MuonExtrapolation::kToVertex); // this is for MCH-MID tracks that cannot see the primary vertex. - o2::dataformats::GlobalFwdTrack propmuonAtDCA = PropagateMuon(track, collision, skimmerPrimaryMuon::MuonExtrapolation::kToDCA); - - float p = propmuonAtPV.getP(); - float pt = propmuonAtPV.getPt(); - float eta = propmuonAtPV.getEta(); - float phi = propmuonAtPV.getPhi(); - - o2::math_utils::bringTo02Pi(phi); - if (phi < 0.f || 2.f * M_PI < phi) { - return; - } - - if (eta < mineta || maxeta < eta) { - return; - } - - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - if (eta < mineta_mft || maxeta_mft < eta) { - return; - } - } - - float rAtAbsorberEnd = track.rAtAbsorberEnd(); - if (static_cast(track.trackType()) > 2) { // only for MUON standalone - o2::dataformats::GlobalFwdTrack propmuonAtRabs = PropagateMuon(track, collision, skimmerPrimaryMuon::MuonExtrapolation::kToRabs); - float xAbs = propmuonAtRabs.getX(); - float yAbs = propmuonAtRabs.getY(); - rAtAbsorberEnd = std::sqrt(xAbs * xAbs + yAbs * yAbs); - // Redo propagation only for muon tracks // propagation of MFT tracks alredy done in reconstruction + if (pt < minPt || maxPt < pt) { + return false; } - if (rAtAbsorberEnd < minRabs || maxRabs < rAtAbsorberEnd) { - return; + return false; } - - float dcaX = (propmuonAtDCA.getX() - collision.posX()); - float dcaY = (propmuonAtDCA.getY() - collision.posY()); - float dcaXY = std::sqrt(dcaX * dcaX + dcaY * dcaY); - float cXX = propmuonAtDCA.getSigma2X(); - float cYY = propmuonAtDCA.getSigma2Y(); - float cXY = propmuonAtDCA.getSigmaXY(); - - float dcaXYinSigma = 999.f; - float det = cXX * cYY - cXY * cXY; - if (det < 0) { - dcaXYinSigma = 999.f; - } else { - float chi2 = (dcaX * dcaX * cYY + dcaY * dcaY * cXX - 2. * dcaX * dcaY * cXY) / det; - dcaXYinSigma = std::sqrt(std::abs(chi2) / 2.); // in sigma + if (rAtAbsorberEnd < midRabs ? pDCA > maxPDCAforSmallR : pDCA > maxPDCAforLargeR) { + return false; } - fRegistry.fill(HIST("Track/hMuonType"), track.trackType()); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hPt"), pt); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hEtaPhi"), phi, eta); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hNclusters"), track.nClusters()); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hPDCA"), pt, track.pDca()); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hPDCA_recalc"), pt, p * dcaXY); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hRatAbsorberEnd"), rAtAbsorberEnd); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hChi2"), track.chi2()); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hChi2MatchMCHMID"), track.chi2MatchMCHMID()); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hMatchScoreMCHMFT"), track.matchScoreMCHMFT()); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hDCAxy2D"), dcaX, dcaY); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hDCAxy2DinSigma"), dcaX / std::sqrt(cXX), dcaY / std::sqrt(cYY)); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hDCAxySigma"), dcaXYinSigma); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hChi2MatchMCHMFT_DCAxySigma"), dcaXYinSigma, track.chi2MatchMCHMFT()); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hChi2MatchMCHMFT_Pt"), pt, track.chi2MatchMCHMFT()); - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hDCAxResolutionvsPt"), pt, std::sqrt(cXX) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/") + HIST(muon_types[mu_id]) + HIST("hDCAyResolutionvsPt"), pt, std::sqrt(cYY) * 1e+4); // convert cm to um - } - - template - o2::dataformats::GlobalFwdTrack PropagateMuon(T const& muon, C const& collision, const skimmerPrimaryMuon::MuonExtrapolation endPoint) - { - double chi2 = muon.chi2(); - SMatrix5 tpars(muon.x(), muon.y(), muon.phi(), muon.tgl(), muon.signed1Pt()); - std::vector v1{muon.cXX(), muon.cXY(), muon.cYY(), muon.cPhiX(), muon.cPhiY(), - muon.cPhiPhi(), muon.cTglX(), muon.cTglY(), muon.cTglPhi(), muon.cTglTgl(), - muon.c1PtX(), muon.c1PtY(), muon.c1PtPhi(), muon.c1PtTgl(), muon.c1Pt21Pt2()}; - SMatrix55 tcovs(v1.begin(), v1.end()); - o2::track::TrackParCovFwd fwdtrack{muon.z(), tpars, tcovs, chi2}; - o2::dataformats::GlobalFwdTrack propmuon; - - if (static_cast(muon.trackType()) > 2) { // MCH-MID or MCH standalone - o2::dataformats::GlobalFwdTrack track; - track.setParameters(tpars); - track.setZ(fwdtrack.getZ()); - track.setCovariances(tcovs); - auto mchTrack = mMatching.FwdtoMCH(track); - - if (endPoint == skimmerPrimaryMuon::MuonExtrapolation::kToVertex) { - o2::mch::TrackExtrap::extrapToVertex(mchTrack, collision.posX(), collision.posY(), collision.posZ(), collision.covXX(), collision.covYY()); + if (trackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + if (eta < minEtaGL || maxEtaGL < eta) { + return false; + } + if (maxDCAxy < dcaXY) { + return false; } - if (endPoint == skimmerPrimaryMuon::MuonExtrapolation::kToDCA) { - o2::mch::TrackExtrap::extrapToVertexWithoutBranson(mchTrack, collision.posZ()); + if (maxChi2GL < chi2_per_ndf) { + return false; } - if (endPoint == skimmerPrimaryMuon::MuonExtrapolation::kToRabs) { - o2::mch::TrackExtrap::extrapToZ(mchTrack, -505.); + if (rAtAbsorberEnd < minRabsGL || maxRabs < rAtAbsorberEnd) { + return false; } - - auto proptrack = mMatching.MCHtoFwd(mchTrack); - propmuon.setParameters(proptrack.getParameters()); - propmuon.setZ(proptrack.getZ()); - propmuon.setCovariances(proptrack.getCovariances()); - } else if (static_cast(muon.trackType()) < 2) { // MFT-MCH-MID - double centerMFT[3] = {0, 0, -61.4}; - o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); - auto Bz = field->getBz(centerMFT); // Get field at centre of MFT - auto geoMan = o2::base::GeometryManager::meanMaterialBudget(muon.x(), muon.y(), muon.z(), collision.posX(), collision.posY(), collision.posZ()); - auto x2x0 = static_cast(geoMan.meanX2X0); - fwdtrack.propagateToVtxhelixWithMCS(collision.posZ(), {collision.posX(), collision.posY()}, {collision.covXX(), collision.covYY()}, Bz, x2x0); - propmuon.setParameters(fwdtrack.getParameters()); - propmuon.setZ(fwdtrack.getZ()); - propmuon.setCovariances(fwdtrack.getCovariances()); + } else if (trackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + if (eta < minEtaSA || maxEtaSA < eta) { + return false; + } + if (maxChi2SA < chi2_per_ndf) { + return false; + } + } else { + return false; } - v1.clear(); - v1.shrink_to_fit(); - - return propmuon; + return true; } - template - bool isSelected(TMuon const& muon, TCollision const& collision) + template + void fillFwdTrackTable(TCollision const& collision, TFwdTrack fwdtrack, const bool isAmbiguous) { - if constexpr (isMC) { - if (!muon.has_mcParticle()) { - return false; - } + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && fwdtrack.chi2MatchMCHMFT() > maxMatchingChi2MCHMFT) { + return; + } // Users have to decide the best match between MFT and MCH-MID at analysis level. The same global muon is repeatedly stored. + + if (fwdtrack.chi2MatchMCHMID() < 0.f) { // this should never happen. only for protection. + return; } - o2::dataformats::GlobalFwdTrack propmuonAtPV = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToVertex); + if (fwdtrack.chi2() < 0.f) { // this should never happen. only for protection. + return; + } + o2::dataformats::GlobalFwdTrack propmuonAtPV = propagateMuon(fwdtrack, collision, propagationPoint::kToVertex); float pt = propmuonAtPV.getPt(); float eta = propmuonAtPV.getEta(); float phi = propmuonAtPV.getPhi(); + o2::math_utils::bringTo02Pi(phi); - if (pt < minpt) { - return false; - } + o2::dataformats::GlobalFwdTrack propmuonAtDCA = propagateMuon(fwdtrack, collision, propagationPoint::kToDCA); + float cXXatDCA = propmuonAtDCA.getSigma2X(); + float cYYatDCA = propmuonAtDCA.getSigma2Y(); + float cXYatDCA = propmuonAtDCA.getSigmaXY(); - if (eta < mineta || maxeta < eta) { - return false; - } + float dcaX = propmuonAtDCA.getX() - collision.posX(); + float dcaY = propmuonAtDCA.getY() - collision.posY(); + float dcaXY = std::sqrt(dcaX * dcaX + dcaY * dcaY); + float rAtAbsorberEnd = fwdtrack.rAtAbsorberEnd(); // this works only for GlobalMuonTrack - o2::math_utils::bringTo02Pi(phi); - if (phi < 0.f || 2.f * M_PI < phi) { - return false; + float det = cXXatDCA * cYYatDCA - cXYatDCA * cXYatDCA; // determinanat + float dcaXYinSigma = 999.f; + if (det < 0) { + dcaXYinSigma = 999.f; + } else { + dcaXYinSigma = std::sqrt(std::fabs((dcaX * dcaX * cYYatDCA + dcaY * dcaY * cXXatDCA - 2.f * dcaX * dcaY * cXYatDCA) / det / 2.f)); // dca xy in sigma } + float sigma_dcaXY = dcaXY / dcaXYinSigma; + + float pDCA = fwdtrack.p() * dcaXY; + int nClustersMFT = 0; + float ptMatchedMCHMID = propmuonAtPV.getPt(); + float etaMatchedMCHMID = propmuonAtPV.getEta(); + float phiMatchedMCHMID = propmuonAtPV.getPhi(); + o2::math_utils::bringTo02Pi(phiMatchedMCHMID); + // float x = fwdtrack.x(); + // float y = fwdtrack.y(); + // float z = fwdtrack.z(); + // float tgl = fwdtrack.tgl(); + float chi2mft = 0.f; + uint64_t mftClusterSizesAndTrackFlags = 0; + int ndf_mchmft = 1; + + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) { + // apply r-absorber cut here to minimize the number of calling propagateMuon. + if (fwdtrack.rAtAbsorberEnd() < minRabsGL || maxRabs < fwdtrack.rAtAbsorberEnd()) { + return; + } - // float dcaX = propmuonAtDCA.getX() - collision.posX(); - // float dcaY = propmuonAtDCA.getY() - collision.posY(); - float rAtAbsorberEnd = muon.rAtAbsorberEnd(); + // apply dca cut here to minimize the number of calling propagateMuon. + if (maxDCAxy < dcaXY) { + return; + } - if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - if (eta < mineta_mft || maxeta_mft < eta) { - return false; + const auto& mchtrack = fwdtrack.template matchMCHTrack_as(); // MCH-MID + const auto& mfttrack = fwdtrack.template matchMFTTrack_as(); // MFTsa + nClustersMFT = mfttrack.nClusters(); + mftClusterSizesAndTrackFlags = mfttrack.mftClusterSizesAndTrackFlags(); + ndf_mchmft = 2.f * (mchtrack.nClusters() + nClustersMFT) - 5.f; + chi2mft = mfttrack.chi2(); + // chi2mft = mfttrack.chi2() / (2.f * nClustersMFT - 5.f); + + // apply chi2/ndf cut here to minimize the number of calling propagateMuon. + if (maxChi2GL < fwdtrack.chi2() / ndf_mchmft) { + return; + } + + o2::dataformats::GlobalFwdTrack propmuonAtPV_Matched = propagateMuon(mchtrack, collision, propagationPoint::kToVertex); + ptMatchedMCHMID = propmuonAtPV_Matched.getPt(); + etaMatchedMCHMID = propmuonAtPV_Matched.getEta(); + phiMatchedMCHMID = propmuonAtPV_Matched.getPhi(); + o2::math_utils::bringTo02Pi(phiMatchedMCHMID); + + o2::dataformats::GlobalFwdTrack propmuonAtDCA_Matched = propagateMuon(mchtrack, collision, propagationPoint::kToDCA); + float dcaX_Matched = propmuonAtDCA_Matched.getX() - collision.posX(); + float dcaY_Matched = propmuonAtDCA_Matched.getY() - collision.posY(); + float dcaXY_Matched = std::sqrt(dcaX_Matched * dcaX_Matched + dcaY_Matched * dcaY_Matched); + pDCA = mchtrack.p() * dcaXY_Matched; + + if (refitGlobalMuon) { + eta = mfttrack.eta(); + phi = mfttrack.phi(); + o2::math_utils::bringTo02Pi(phi); + pt = propmuonAtPV_Matched.getP() * std::sin(2.f * std::atan(std::exp(-eta))); + + // x = mfttrack.x(); + // y = mfttrack.y(); + // z = mfttrack.z(); + // tgl = mfttrack.tgl(); } - } else if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - o2::dataformats::GlobalFwdTrack propmuonAtRabs = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToRabs); + } else if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + o2::dataformats::GlobalFwdTrack propmuonAtRabs = propagateMuon(fwdtrack, collision, propagationPoint::kToRabs); // this is necessary only for MuonStandaloneTrack float xAbs = propmuonAtRabs.getX(); float yAbs = propmuonAtRabs.getY(); rAtAbsorberEnd = std::sqrt(xAbs * xAbs + yAbs * yAbs); // Redo propagation only for muon tracks // propagation of MFT tracks alredy done in reconstruction } else { - return false; + return; } - if (rAtAbsorberEnd < minRabs || maxRabs < rAtAbsorberEnd) { - return false; + if (!isSelected(pt, eta, rAtAbsorberEnd, pDCA, fwdtrack.chi2() / ndf_mchmft, fwdtrack.trackType(), dcaXY)) { + return; } - return true; - } - - template - void fillMuonTable(TMuon const& muon, TCollision const& collision, const int new_muon_sa_id) - { - o2::dataformats::GlobalFwdTrack propmuonAtPV = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToVertex); - o2::dataformats::GlobalFwdTrack propmuonAtDCA = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToDCA); - - float pt = propmuonAtPV.getPt(); - float eta = propmuonAtPV.getEta(); - float phi = propmuonAtPV.getPhi(); - o2::math_utils::bringTo02Pi(phi); + float dpt = (ptMatchedMCHMID - pt) / pt; + float deta = etaMatchedMCHMID - eta; + float dphi = phiMatchedMCHMID - phi; + o2::math_utils::bringToPMPi(dphi); - float dcaX = propmuonAtDCA.getX() - collision.posX(); - float dcaY = propmuonAtDCA.getY() - collision.posY(); - float rAtAbsorberEnd = muon.rAtAbsorberEnd(); + bool isAssociatedToMPC = fwdtrack.collisionId() == collision.globalIndex(); + // LOGF(info, "isAmbiguous = %d, isAssociatedToMPC = %d, fwdtrack.globalIndex() = %d, fwdtrack.collisionId() = %d, collision.globalIndex() = %d", isAmbiguous, isAssociatedToMPC, fwdtrack.globalIndex(), fwdtrack.collisionId(), collision.globalIndex()); - if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - o2::dataformats::GlobalFwdTrack propmuonAtRabs = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToRabs); - float xAbs = propmuonAtRabs.getX(); - float yAbs = propmuonAtRabs.getY(); - rAtAbsorberEnd = std::sqrt(xAbs * xAbs + yAbs * yAbs); // Redo propagation only for muon tracks // propagation of MFT tracks alredy done in reconstruction - } + emprimarymuons(collision.globalIndex(), fwdtrack.globalIndex(), fwdtrack.matchMFTTrackId(), fwdtrack.matchMCHTrackId(), fwdtrack.trackType(), + pt, eta, phi, fwdtrack.sign(), dcaX, dcaY, cXXatDCA, cYYatDCA, cXYatDCA, ptMatchedMCHMID, etaMatchedMCHMID, phiMatchedMCHMID, + // x, y, z, tgl, + fwdtrack.nClusters(), pDCA, rAtAbsorberEnd, fwdtrack.chi2(), fwdtrack.chi2MatchMCHMID(), fwdtrack.chi2MatchMCHMFT(), + fwdtrack.mchBitMap(), fwdtrack.midBitMap(), fwdtrack.midBoards(), mftClusterSizesAndTrackFlags, chi2mft, isAssociatedToMPC, isAmbiguous); - bool isAssociatedToMPC = collision.globalIndex() == muon.collisionId(); - auto fwdcov = propmuonAtDCA.getCovariances(); - if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - auto mftsa_track = muon.template matchMFTTrack_as(); - - emprimarymuons(collision.globalIndex(), muon.globalIndex(), muon.trackType(), pt, eta, phi, muon.sign(), dcaX, dcaY, - propmuonAtDCA.getX(), propmuonAtDCA.getY(), propmuonAtDCA.getZ(), propmuonAtDCA.getTgl(), - muon.nClusters(), muon.pDca(), rAtAbsorberEnd, muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), - new_muon_sa_id, - muon.mchBitMap(), muon.midBitMap(), muon.midBoards(), mftsa_track.mftClusterSizesAndTrackFlags(), mftsa_track.chi2(), isAssociatedToMPC); - emprimarymuonscov( - fwdcov(0, 0), - fwdcov(0, 1), fwdcov(1, 1), - fwdcov(2, 0), fwdcov(2, 1), fwdcov(2, 2), - fwdcov(3, 0), fwdcov(3, 1), fwdcov(3, 2), fwdcov(3, 3), - fwdcov(4, 0), fwdcov(4, 1), fwdcov(4, 2), fwdcov(4, 3), fwdcov(4, 4)); - } else if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - emprimarymuons(collision.globalIndex(), muon.globalIndex(), muon.trackType(), pt, eta, phi, muon.sign(), dcaX, dcaY, - propmuonAtDCA.getX(), propmuonAtDCA.getY(), propmuonAtDCA.getZ(), propmuonAtDCA.getTgl(), - muon.nClusters(), muon.pDca(), rAtAbsorberEnd, muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), - new_muon_sa_id, - muon.mchBitMap(), muon.midBitMap(), muon.midBoards(), 0, 999999.f, isAssociatedToMPC); - emprimarymuonscov( - fwdcov(0, 0), - fwdcov(0, 1), fwdcov(1, 1), - fwdcov(2, 0), fwdcov(2, 1), fwdcov(2, 2), - fwdcov(3, 0), fwdcov(3, 1), fwdcov(3, 2), fwdcov(3, 3), - fwdcov(4, 0), fwdcov(4, 1), fwdcov(4, 2), fwdcov(4, 3), fwdcov(4, 4)); - } + const auto& fwdcov = propmuonAtPV.getCovariances(); // covatiant matrix at PV + emprimarymuonscov( + fwdcov(0, 0), + fwdcov(0, 1), fwdcov(1, 1), + fwdcov(2, 0), fwdcov(2, 1), fwdcov(2, 2), + fwdcov(3, 0), fwdcov(3, 1), fwdcov(3, 2), fwdcov(3, 3), + fwdcov(4, 0), fwdcov(4, 1), fwdcov(4, 2), fwdcov(4, 3), fwdcov(4, 4)); // See definition DataFormats/Reconstruction/include/ReconstructionDataFormats/TrackFwd.h - /// Covariance matrix of track parameters, ordered as follows:

-    ///                                     
-    ///                                     
-    ///                            
-    ///                        
-    ///                 
+ // + // + // + // + + if (fillQAHistograms) { + fRegistry.fill(HIST("hMuonType"), fwdtrack.trackType()); + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) { + fRegistry.fill(HIST("MFTMCHMID/hPt"), pt); + fRegistry.fill(HIST("MFTMCHMID/hEtaPhi"), phi, eta); + fRegistry.fill(HIST("MFTMCHMID/hEtaPhi_MatchedMCHMID"), phiMatchedMCHMID, etaMatchedMCHMID); + fRegistry.fill(HIST("MFTMCHMID/hDeltaPt_Pt"), pt, dpt); + fRegistry.fill(HIST("MFTMCHMID/hDeltaEta_Pt"), pt, deta); + fRegistry.fill(HIST("MFTMCHMID/hDeltaPhi_Pt"), pt, dphi); + fRegistry.fill(HIST("MFTMCHMID/hSign"), fwdtrack.sign()); + fRegistry.fill(HIST("MFTMCHMID/hNclusters"), fwdtrack.nClusters()); + fRegistry.fill(HIST("MFTMCHMID/hNclustersMFT"), nClustersMFT); + fRegistry.fill(HIST("MFTMCHMID/hPDCA_Rabs"), rAtAbsorberEnd, pDCA); + fRegistry.fill(HIST("MFTMCHMID/hRatAbsorberEnd"), rAtAbsorberEnd); + fRegistry.fill(HIST("MFTMCHMID/hChi2"), fwdtrack.chi2() / ndf_mchmft); + fRegistry.fill(HIST("MFTMCHMID/hChi2MFT"), chi2mft); + fRegistry.fill(HIST("MFTMCHMID/hChi2MatchMCHMID"), fwdtrack.chi2MatchMCHMID()); + fRegistry.fill(HIST("MFTMCHMID/hChi2MatchMCHMFT"), fwdtrack.chi2MatchMCHMFT()); + fRegistry.fill(HIST("MFTMCHMID/hDCAxy2D"), dcaX, dcaY); + fRegistry.fill(HIST("MFTMCHMID/hDCAxy2DinSigma"), dcaX / std::sqrt(cXXatDCA), dcaY / std::sqrt(cYYatDCA)); + fRegistry.fill(HIST("MFTMCHMID/hDCAxy"), dcaXY); + fRegistry.fill(HIST("MFTMCHMID/hDCAxyinSigma"), dcaXYinSigma); + fRegistry.fill(HIST("MFTMCHMID/hDCAxResolutionvsPt"), pt, std::sqrt(cXXatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/hDCAyResolutionvsPt"), pt, std::sqrt(cYYatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/hDCAxyResolutionvsPt"), pt, sigma_dcaXY * 1e+4); // convert cm to um + } else if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + fRegistry.fill(HIST("MCHMID/hPt"), pt); + fRegistry.fill(HIST("MCHMID/hEtaPhi"), phi, eta); + fRegistry.fill(HIST("MCHMID/hEtaPhi_MatchedMCHMID"), phiMatchedMCHMID, etaMatchedMCHMID); + fRegistry.fill(HIST("MCHMID/hDeltaPt_Pt"), pt, dpt); + fRegistry.fill(HIST("MCHMID/hDeltaEta_Pt"), pt, deta); + fRegistry.fill(HIST("MCHMID/hDeltaPhi_Pt"), pt, dphi); + fRegistry.fill(HIST("MCHMID/hSign"), fwdtrack.sign()); + fRegistry.fill(HIST("MCHMID/hNclusters"), fwdtrack.nClusters()); + fRegistry.fill(HIST("MCHMID/hNclustersMFT"), nClustersMFT); + fRegistry.fill(HIST("MCHMID/hPDCA_Rabs"), rAtAbsorberEnd, pDCA); + fRegistry.fill(HIST("MCHMID/hRatAbsorberEnd"), rAtAbsorberEnd); + fRegistry.fill(HIST("MCHMID/hChi2"), fwdtrack.chi2()); + fRegistry.fill(HIST("MCHMID/hChi2MFT"), chi2mft); + fRegistry.fill(HIST("MCHMID/hChi2MatchMCHMID"), fwdtrack.chi2MatchMCHMID()); + fRegistry.fill(HIST("MCHMID/hChi2MatchMCHMFT"), fwdtrack.chi2MatchMCHMFT()); + fRegistry.fill(HIST("MCHMID/hDCAxy2D"), dcaX, dcaY); + fRegistry.fill(HIST("MCHMID/hDCAxy2DinSigma"), dcaX / std::sqrt(cXXatDCA), dcaY / std::sqrt(cYYatDCA)); + fRegistry.fill(HIST("MCHMID/hDCAxy"), dcaXY); + fRegistry.fill(HIST("MCHMID/hDCAxyinSigma"), dcaXYinSigma); + fRegistry.fill(HIST("MCHMID/hDCAxResolutionvsPt"), pt, std::sqrt(cXXatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MCHMID/hDCAyResolutionvsPt"), pt, std::sqrt(cYYatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MCHMID/hDCAxyResolutionvsPt"), pt, sigma_dcaXY * 1e+4); // convert cm to um + } + } } - std::map, int> map_new_sa_muon_index; // new standalone muon index - - // Preslice fwdtrackIndicesPerMFTsa = aod::fwdtrack::matchMFTTrackId; + // std::map, float> mCandidates; // std::pair -> chi2MatchMCHMFT; + std::vector> vec_min_chi2MatchMCHMFT; // std::pair -> chi2MatchMCHMFT; + template + void findBestMatchPerMCHMID(TMuons const& muons) + { + vec_min_chi2MatchMCHMFT.reserve(muons.size()); + for (const auto& muon : muons) { + if (muon.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + const auto& muons_per_MCHMID = muons.sliceBy(fwdtracksPerMCHTrack, muon.globalIndex()); + // LOGF(info, "stanadalone: muon.globalIndex() = %d, muon.chi2MatchMCHMFT() = %f", muon.globalIndex(), muon.chi2MatchMCHMFT()); + // LOGF(info, "muons_per_MCHMID.size() = %d", muons_per_MCHMID.size()); + + float min_chi2MatchMCHMFT = 1e+10; + std::tuple tupleIds_at_min; + for (const auto& muon_tmp : muons_per_MCHMID) { + if (muon_tmp.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) { + // LOGF(info, "muon_tmp.globalIndex() = %d, muon_tmp.matchMCHTrackId() = %d, muon_tmp.matchMFTTrackId() = %d, muon_tmp.chi2MatchMCHMFT() = %f", muon_tmp.globalIndex(), muon_tmp.matchMCHTrackId(), muon_tmp.matchMFTTrackId(), muon_tmp.chi2MatchMCHMFT()); + if (0.f < muon_tmp.chi2MatchMCHMFT() && muon_tmp.chi2MatchMCHMFT() < min_chi2MatchMCHMFT) { + min_chi2MatchMCHMFT = muon_tmp.chi2MatchMCHMFT(); + tupleIds_at_min = std::make_tuple(muon_tmp.globalIndex(), muon_tmp.matchMCHTrackId(), muon_tmp.matchMFTTrackId()); + } + } + } + vec_min_chi2MatchMCHMFT.emplace_back(tupleIds_at_min); + // mCandidates[tupleIds_at_min] = min_chi2MatchMCHMFT; + // LOGF(info, "min: muon_tmp.globalIndex() = %d, muon_tmp.matchMCHTrackId() = %d, muon_tmp.matchMFTTrackId() = %d, muon_tmp.chi2MatchMCHMFT() = %f", std::get<0>(tupleIds_at_min), std::get<1>(tupleIds_at_min), std::get<2>(tupleIds_at_min), min_chi2MatchMCHMFT); + } + } // end of muon loop + } + SliceCache cache; + Preslice perCollision = o2::aod::fwdtrack::collisionId; Preslice fwdtrackIndicesPerCollision = aod::track_association::collisionId; - Partition global_muons = o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack); // MFT-MCH-MID - Partition sa_muons = o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack); // MCH-MID + PresliceUnsorted fwdtrackIndicesPerFwdTrack = aod::track_association::fwdtrackId; + PresliceUnsorted fwdtracksPerMCHTrack = aod::fwdtrack::matchMCHTrackId; - void processRec_SA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::MFTTracks const&) + void processRec_SA(MyCollisions const& collisions, MyFwdTracks const& fwdtracks, aod::MFTTracks const&, aod::BCsWithTimestamps const&) { - for (auto& collision : collisions) { - auto bc = collision.template foundBC_as(); + findBestMatchPerMCHMID(fwdtracks); + + for (const auto& collision : collisions) { + const auto& bc = collision.template bc_as(); initCCDB(bc); - fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); + if (!collision.isSelected()) { continue; } - auto sa_muons_per_coll = sa_muons->sliceByCached(o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); - auto global_muons_per_coll = global_muons->sliceByCached(o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); - - int counter = 0; - int offset = emprimarymuons.lastIndex() + 1; - - for (auto& track : sa_muons_per_coll) { - if (fillQAHistogram) { - fillTrackHistogram<3>(track, collision); - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } - } // end of standalone muon loop - for (auto& track : global_muons_per_coll) { - if (fillQAHistogram) { - fillTrackHistogram<0>(track, collision); + const auto& fwdtracks_per_coll = fwdtracks.sliceBy(perCollision, collision.globalIndex()); + for (const auto& fwdtrack : fwdtracks_per_coll) { + if (fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + continue; } - if (map_new_sa_muon_index.find(std::make_pair(collision.globalIndex(), track.matchMCHTrackId())) == map_new_sa_muon_index.end()) { // don't apply muon selection to MCH-MID track in MFT-MCH-MID track - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())] = counter + offset; - counter++; - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } - } // end of global muon loop - - // fill table after mapping - for (const auto& [key, value] : map_new_sa_muon_index) { - // int collisionId = std::get<0>(key); - // int fwdtrackId = std::get<1>(key); - // int new_fwdtrackId = value; - // LOGF(info, "collisionId = %d, fwdtrackId = %d, new_fwdtrackId = %d", collisionId, fwdtrackId, new_fwdtrackId); - auto track = tracks.iteratorAt(std::get<1>(key)); - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - fillMuonTable(track, collision, value); - } else if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - fillMuonTable(track, collision, map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())]); + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && std::find(vec_min_chi2MatchMCHMFT.begin(), vec_min_chi2MatchMCHMFT.end(), std::make_tuple(fwdtrack.globalIndex(), fwdtrack.matchMCHTrackId(), fwdtrack.matchMFTTrackId())) == vec_min_chi2MatchMCHMFT.end()) { + continue; } - } - map_new_sa_muon_index.clear(); + fillFwdTrackTable(collision, fwdtrack, false); + } // end of fwdtrack loop } // end of collision loop + + vec_min_chi2MatchMCHMFT.clear(); + vec_min_chi2MatchMCHMFT.shrink_to_fit(); } - PROCESS_SWITCH(skimmerPrimaryMuon, processRec_SA, "process reconstructed info only with standalone", true); + PROCESS_SWITCH(skimmerPrimaryMuon, processRec_SA, "process reconstructed info", false); - void processRec_TTCA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::MFTTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) + void processRec_TTCA(MyCollisions const& collisions, MyFwdTracks const& fwdtracks, aod::MFTTracks const&, aod::BCsWithTimestamps const&, aod::FwdTrackAssoc const& fwdtrackIndices) { - for (auto& collision : collisions) { - auto bc = collision.template foundBC_as(); + findBestMatchPerMCHMID(fwdtracks); + + std::unordered_map mapAmb; // fwdtrack.globalIndex() -> bool isAmb; + for (const auto& fwdtrack : fwdtracks) { + const auto& fwdtrackIdsPerFwdTrack = fwdtrackIndices.sliceBy(fwdtrackIndicesPerFwdTrack, fwdtrack.globalIndex()); + mapAmb[fwdtrack.globalIndex()] = fwdtrackIdsPerFwdTrack.size() > 1; + // LOGF(info, "fwdtrack.globalIndex() = %d, ntimes = %d, isAmbiguous = %d", fwdtrack.globalIndex(), fwdtrackIdsPerFwdTrack.size(), mapAmb[fwdtrack.globalIndex()]); + } // end of fwdtrack loop + + for (const auto& collision : collisions) { + const auto& bc = collision.template bc_as(); initCCDB(bc); - fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); + if (!collision.isSelected()) { continue; } - int counter = 0; - int offset = emprimarymuons.lastIndex() + 1; - - auto fwdtrackIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); - for (auto& fwdtrackId : fwdtrackIdsThisCollision) { - auto track = fwdtrackId.template fwdtrack_as(); - // LOGF(info, "TTCA | collision.globalIndex() = %d, track.globalIndex() = %d, track.trackType() = %d, track.matchMFTTrackId() = %d, track.matchMCHTrackId() = %d, track.offsets() = %d", collision.globalIndex(), track.globalIndex(), track.trackType(), track.matchMFTTrackId(), track.matchMCHTrackId(), track.offsets()); - - // auto collision_in_track = track.collision_as(); - // auto bc_in_track = collision_in_track.bc_as(); - // LOGF(info, "track.globalIndex() = %d , bc_in_track.globalBC() = %lld", track.globalIndex(), bc_in_track.globalBC()); - - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - if (fillQAHistogram) { - fillTrackHistogram<3>(track, collision); - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } - } else if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - if (fillQAHistogram) { - fillTrackHistogram<0>(track, collision); - } - if (map_new_sa_muon_index.find(std::make_pair(collision.globalIndex(), track.matchMCHTrackId())) == map_new_sa_muon_index.end()) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())] = counter + offset; - counter++; - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } + const auto& fwdtrackIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); + for (const auto& fwdtrackId : fwdtrackIdsThisCollision) { + const auto& fwdtrack = fwdtrackId.template fwdtrack_as(); + if (fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + continue; } - } // end of track loop - - for (const auto& [key, value] : map_new_sa_muon_index) { - // int collisionId = std::get<0>(key); - // int fwdtrackId = std::get<1>(key); - // int new_fwdtrackId = value; - auto track = tracks.iteratorAt(std::get<1>(key)); - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - fillMuonTable(track, collision, value); - } else if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - fillMuonTable(track, collision, map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())]); + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && std::find(vec_min_chi2MatchMCHMFT.begin(), vec_min_chi2MatchMCHMFT.end(), std::make_tuple(fwdtrack.globalIndex(), fwdtrack.matchMCHTrackId(), fwdtrack.matchMFTTrackId())) == vec_min_chi2MatchMCHMFT.end()) { + continue; } - } - map_new_sa_muon_index.clear(); + fillFwdTrackTable(collision, fwdtrack, mapAmb[fwdtrack.globalIndex()]); + } // end of fwdtrack loop } // end of collision loop + mapAmb.clear(); + vec_min_chi2MatchMCHMFT.clear(); + vec_min_chi2MatchMCHMFT.shrink_to_fit(); } - PROCESS_SWITCH(skimmerPrimaryMuon, processRec_TTCA, "process reconstructed info only with TTCA", false); + PROCESS_SWITCH(skimmerPrimaryMuon, processRec_TTCA, "process reconstructed info", false); - void processRec_SA_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::MFTTracks const&) + void processRec_SA_SWT(MyCollisionsWithSWT const& collisions, MyFwdTracks const& fwdtracks, aod::MFTTracks const&, aod::BCsWithTimestamps const&) { - for (auto& collision : collisions) { - auto bc = collision.template foundBC_as(); + findBestMatchPerMCHMID(fwdtracks); + + for (const auto& collision : collisions) { + const auto& bc = collision.template bc_as(); initCCDB(bc); - fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); + if (!collision.isSelected()) { continue; } + if (collision.swtaliastmp_raw() == 0) { continue; } - auto sa_muons_per_coll = sa_muons->sliceByCached(o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); - auto global_muons_per_coll = global_muons->sliceByCached(o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); - - int counter = 0; - int offset = emprimarymuons.lastIndex() + 1; - - for (auto& track : sa_muons_per_coll) { - if (fillQAHistogram) { - fillTrackHistogram<3>(track, collision); - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } - } // end of standalone muon loop - for (auto& track : global_muons_per_coll) { - if (fillQAHistogram) { - fillTrackHistogram<0>(track, collision); - } - - if (map_new_sa_muon_index.find(std::make_pair(collision.globalIndex(), track.matchMCHTrackId())) == map_new_sa_muon_index.end()) { // don't apply muon selection to MCH-MID track in MFT-MCH-MID track - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())] = counter + offset; - counter++; - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; + const auto& fwdtracks_per_coll = fwdtracks.sliceBy(perCollision, collision.globalIndex()); + for (const auto& fwdtrack : fwdtracks_per_coll) { + if (fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + continue; } - } // end of global muon loop - - // fill table after mapping - for (const auto& [key, value] : map_new_sa_muon_index) { - // int collisionId = std::get<0>(key); - // int fwdtrackId = std::get<1>(key); - // int new_fwdtrackId = value; - // LOGF(info, "collisionId = %d, fwdtrackId = %d, new_fwdtrackId = %d", collisionId, fwdtrackId, new_fwdtrackId); - auto track = tracks.iteratorAt(std::get<1>(key)); - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - fillMuonTable(track, collision, value); - } else if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - fillMuonTable(track, collision, map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())]); + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && std::find(vec_min_chi2MatchMCHMFT.begin(), vec_min_chi2MatchMCHMFT.end(), std::make_tuple(fwdtrack.globalIndex(), fwdtrack.matchMCHTrackId(), fwdtrack.matchMFTTrackId())) == vec_min_chi2MatchMCHMFT.end()) { + continue; } - } - map_new_sa_muon_index.clear(); + fillFwdTrackTable(collision, fwdtrack, false); + } // end of fwdtrack loop } // end of collision loop + vec_min_chi2MatchMCHMFT.clear(); + vec_min_chi2MatchMCHMFT.shrink_to_fit(); } PROCESS_SWITCH(skimmerPrimaryMuon, processRec_SA_SWT, "process reconstructed info only with standalone", false); - void processRec_TTCA_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::MFTTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) + void processRec_TTCA_SWT(MyCollisionsWithSWT const& collisions, MyFwdTracks const& fwdtracks, aod::MFTTracks const&, aod::BCsWithTimestamps const&, aod::FwdTrackAssoc const& fwdtrackIndices) { - for (auto& collision : collisions) { - auto bc = collision.template foundBC_as(); + findBestMatchPerMCHMID(fwdtracks); + + std::unordered_map mapAmb; // fwdtrack.globalIndex() -> bool isAmb; + for (const auto& fwdtrack : fwdtracks) { + const auto& fwdtrackIdsPerFwdTrack = fwdtrackIndices.sliceBy(fwdtrackIndicesPerFwdTrack, fwdtrack.globalIndex()); + mapAmb[fwdtrack.globalIndex()] = fwdtrackIdsPerFwdTrack.size() > 1; + // LOGF(info, "fwdtrack.globalIndex() = %d, ntimes = %d, isAmbiguous = %d", fwdtrack.globalIndex(), fwdtrackIdsPerFwdTrack.size(), mapAmb[fwdtrack.globalIndex()]); + } // end of fwdtrack loop + + for (const auto& collision : collisions) { + const auto& bc = collision.template bc_as(); initCCDB(bc); - fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); if (!collision.isSelected()) { continue; } @@ -603,190 +559,104 @@ struct skimmerPrimaryMuon { continue; } - int counter = 0; - int offset = emprimarymuons.lastIndex() + 1; - - auto fwdtrackIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); - for (auto& fwdtrackId : fwdtrackIdsThisCollision) { - auto track = fwdtrackId.template fwdtrack_as(); - // LOGF(info, "TTCA | collision.globalIndex() = %d, track.globalIndex() = %d, track.trackType() = %d, track.matchMFTTrackId() = %d, track.matchMCHTrackId() = %d, track.offsets() = %d", collision.globalIndex(), track.globalIndex(), track.trackType(), track.matchMFTTrackId(), track.matchMCHTrackId(), track.offsets()); - - // auto collision_in_track = track.collision_as(); - // auto bc_in_track = collision_in_track.bc_as(); - // LOGF(info, "track.globalIndex() = %d , bc_in_track.globalBC() = %lld", track.globalIndex(), bc_in_track.globalBC()); - - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - if (fillQAHistogram) { - fillTrackHistogram<3>(track, collision); - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } - } else if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - if (fillQAHistogram) { - fillTrackHistogram<0>(track, collision); - } - if (map_new_sa_muon_index.find(std::make_pair(collision.globalIndex(), track.matchMCHTrackId())) == map_new_sa_muon_index.end()) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())] = counter + offset; - counter++; - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } + const auto& fwdtrackIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); + for (const auto& fwdtrackId : fwdtrackIdsThisCollision) { + const auto& fwdtrack = fwdtrackId.template fwdtrack_as(); + if (fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + continue; } - } // end of track loop - - for (const auto& [key, value] : map_new_sa_muon_index) { - // int collisionId = std::get<0>(key); - // int fwdtrackId = std::get<1>(key); - // int new_fwdtrackId = value; - auto track = tracks.iteratorAt(std::get<1>(key)); - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - fillMuonTable(track, collision, value); - } else if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - fillMuonTable(track, collision, map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())]); + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && std::find(vec_min_chi2MatchMCHMFT.begin(), vec_min_chi2MatchMCHMFT.end(), std::make_tuple(fwdtrack.globalIndex(), fwdtrack.matchMCHTrackId(), fwdtrack.matchMFTTrackId())) == vec_min_chi2MatchMCHMFT.end()) { + continue; } - } - map_new_sa_muon_index.clear(); + fillFwdTrackTable(collision, fwdtrack, mapAmb[fwdtrack.globalIndex()]); + } // end of fwdtrack loop } // end of collision loop + mapAmb.clear(); + vec_min_chi2MatchMCHMFT.clear(); + vec_min_chi2MatchMCHMFT.shrink_to_fit(); } - PROCESS_SWITCH(skimmerPrimaryMuon, processRec_TTCA_SWT, "process reconstructed info only with TTCA", false); + PROCESS_SWITCH(skimmerPrimaryMuon, processRec_TTCA_SWT, "process reconstructed info", false); - Partition global_muons_mc = o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack); // MFT-MCH-MID - Partition sa_muons_mc = o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack); // MCH-MID - - void processMC_SA(soa::Join const& collisions, aod::BCsWithTimestamps const&, MyTracksMC const& tracks, MFTTracksMC const&) + void processMC_SA(soa::Join const& collisions, MyFwdTracksMC const& fwdtracks, MFTTracksMC const&, aod::BCsWithTimestamps const&) { - for (auto& collision : collisions) { - if (!collision.has_mcCollision()) { - continue; - } - auto bc = collision.template foundBC_as(); + findBestMatchPerMCHMID(fwdtracks); + + for (const auto& collision : collisions) { + const auto& bc = collision.template bc_as(); initCCDB(bc); - fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); if (!collision.isSelected()) { continue; } + if (!collision.has_mcCollision()) { + continue; + } - auto sa_muons_mc_per_coll = sa_muons_mc->sliceByCached(o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); - auto global_muons_mc_per_coll = global_muons_mc->sliceByCached(o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); - - int counter = 0; - int offset = emprimarymuons.lastIndex() + 1; - - for (auto& track : sa_muons_mc_per_coll) { - if (fillQAHistogram) { - fillTrackHistogram<3>(track, collision); - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } - } // end of standalone muon loop - for (auto& track : global_muons_mc_per_coll) { - auto sa_muon = tracks.iteratorAt(track.matchMCHTrackId()); - if (!sa_muon.has_mcParticle()) { + const auto& fwdtracks_per_coll = fwdtracks.sliceBy(perCollision, collision.globalIndex()); + for (const auto& fwdtrack : fwdtracks_per_coll) { + if (!fwdtrack.has_mcParticle()) { continue; } - if (fillQAHistogram) { - fillTrackHistogram<0>(track, collision); - } - if (map_new_sa_muon_index.find(std::make_pair(collision.globalIndex(), track.matchMCHTrackId())) == map_new_sa_muon_index.end()) { // don't apply muon selection to MCH-MID track in MFT-MCH-MID track - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())] = counter + offset; - counter++; - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; + if (fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + continue; } - } // end of global muon loop - - // fill table after mapping - for (const auto& [key, value] : map_new_sa_muon_index) { - // int collisionId = std::get<0>(key); - // int fwdtrackId = std::get<1>(key); - // int new_fwdtrackId = value; - // LOGF(info, "collisionId = %d, fwdtrackId = %d, new_fwdtrackId = %d", collisionId, fwdtrackId, new_fwdtrackId); - auto track = tracks.iteratorAt(std::get<1>(key)); - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - fillMuonTable(track, collision, value); - } else if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - fillMuonTable(track, collision, map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())]); + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && std::find(vec_min_chi2MatchMCHMFT.begin(), vec_min_chi2MatchMCHMFT.end(), std::make_tuple(fwdtrack.globalIndex(), fwdtrack.matchMCHTrackId(), fwdtrack.matchMFTTrackId())) == vec_min_chi2MatchMCHMFT.end()) { + continue; } - } - map_new_sa_muon_index.clear(); + fillFwdTrackTable(collision, fwdtrack, false); + } // end of fwdtrack loop } // end of collision loop + vec_min_chi2MatchMCHMFT.clear(); + vec_min_chi2MatchMCHMFT.shrink_to_fit(); } PROCESS_SWITCH(skimmerPrimaryMuon, processMC_SA, "process reconstructed and MC info", false); - void processMC_TTCA(soa::Join const& collisions, aod::BCsWithTimestamps const&, MyTracksMC const& tracks, MFTTracksMC const&, aod::FwdTrackAssoc const& fwdtrackIndices) + void processMC_TTCA(soa::Join const& collisions, MyFwdTracksMC const& fwdtracks, MFTTracksMC const&, aod::BCsWithTimestamps const&, aod::FwdTrackAssoc const& fwdtrackIndices) { - for (auto& collision : collisions) { - if (!collision.has_mcCollision()) { - continue; - } - auto bc = collision.template foundBC_as(); + findBestMatchPerMCHMID(fwdtracks); + + std::unordered_map mapAmb; // fwdtrack.globalIndex() -> bool isAmb; + for (const auto& fwdtrack : fwdtracks) { + const auto& fwdtrackIdsPerFwdTrack = fwdtrackIndices.sliceBy(fwdtrackIndicesPerFwdTrack, fwdtrack.globalIndex()); + mapAmb[fwdtrack.globalIndex()] = fwdtrackIdsPerFwdTrack.size() > 1; + // LOGF(info, "fwdtrack.globalIndex() = %d, ntimes = %d, isAmbiguous = %d", fwdtrack.globalIndex(), fwdtrackIdsPerFwdTrack.size(), mapAmb[fwdtrack.globalIndex()]); + } // end of fwdtrack loop + + for (const auto& collision : collisions) { + const auto& bc = collision.template bc_as(); initCCDB(bc); - fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); if (!collision.isSelected()) { continue; } + if (!collision.has_mcCollision()) { + continue; + } - int counter = 0; - int offset = emprimarymuons.lastIndex() + 1; - - auto fwdtrackIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); - for (auto& fwdtrackId : fwdtrackIdsThisCollision) { - auto track = fwdtrackId.template fwdtrack_as(); - // LOGF(info, "TTCA | track.globalIndex() = %d, track.trackType() = %d, track.matchMFTTrackId() = %d, track.matchMCHTrackId() = %d, track.offsets() = %d", track.globalIndex(), track.trackType(), track.matchMFTTrackId(), track.matchMCHTrackId(), track.offsets()); - - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - if (fillQAHistogram) { - fillTrackHistogram<3>(track, collision); - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } - } else if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - auto sa_muon = tracks.iteratorAt(track.matchMCHTrackId()); - if (!sa_muon.has_mcParticle()) { - continue; - } - if (fillQAHistogram) { - fillTrackHistogram<0>(track, collision); - } - if (map_new_sa_muon_index.find(std::make_pair(collision.globalIndex(), track.matchMCHTrackId())) == map_new_sa_muon_index.end()) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())] = counter + offset; - counter++; - } - if (isSelected(track, collision)) { - map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.globalIndex())] = counter + offset; - counter++; - } + const auto& fwdtrackIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); + for (const auto& fwdtrackId : fwdtrackIdsThisCollision) { + const auto& fwdtrack = fwdtrackId.template fwdtrack_as(); + if (!fwdtrack.has_mcParticle()) { + continue; + } + if (fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + continue; } - } // end of track loop - - for (const auto& [key, value] : map_new_sa_muon_index) { - // int collisionId = std::get<0>(key); - // int fwdtrackId = std::get<1>(key); - // int new_fwdtrackId = value; - auto track = tracks.iteratorAt(std::get<1>(key)); - if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - fillMuonTable(track, collision, value); - } else if (track.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - fillMuonTable(track, collision, map_new_sa_muon_index[std::make_pair(collision.globalIndex(), track.matchMCHTrackId())]); + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && std::find(vec_min_chi2MatchMCHMFT.begin(), vec_min_chi2MatchMCHMFT.end(), std::make_tuple(fwdtrack.globalIndex(), fwdtrack.matchMCHTrackId(), fwdtrack.matchMFTTrackId())) == vec_min_chi2MatchMCHMFT.end()) { + continue; } - } - map_new_sa_muon_index.clear(); + fillFwdTrackTable(collision, fwdtrack, mapAmb[fwdtrack.globalIndex()]); + } // end of fwdtrack loop } // end of collision loop + mapAmb.clear(); + vec_min_chi2MatchMCHMFT.clear(); + vec_min_chi2MatchMCHMFT.shrink_to_fit(); } - PROCESS_SWITCH(skimmerPrimaryMuon, processMC_TTCA, "process reconstructed and MC info with TTCA", false); + PROCESS_SWITCH(skimmerPrimaryMuon, processMC_TTCA, "process reconstructed and MC info", false); + + void processDummy(aod::Collisions const&) {} + PROCESS_SWITCH(skimmerPrimaryMuon, processDummy, "process dummy", true); }; struct associateAmbiguousMuon { Produces em_amb_muon_ids; @@ -797,28 +667,55 @@ struct associateAmbiguousMuon { void process(aod::EMPrimaryMuons const& muons) { - for (auto& muon : muons) { + for (const auto& muon : muons) { auto muons_with_same_trackId = muons.sliceBy(perTrack, muon.fwdtrackId()); ambmuon_self_Ids.reserve(muons_with_same_trackId.size()); - for (auto& amp_muon : muons_with_same_trackId) { - if (amp_muon.globalIndex() == muon.globalIndex()) { // don't store myself. + for (const auto& amb_muon : muons_with_same_trackId) { + if (amb_muon.globalIndex() == muon.globalIndex()) { // don't store myself. continue; } - ambmuon_self_Ids.emplace_back(amp_muon.globalIndex()); + ambmuon_self_Ids.emplace_back(amb_muon.globalIndex()); } em_amb_muon_ids(ambmuon_self_Ids); ambmuon_self_Ids.clear(); ambmuon_self_Ids.shrink_to_fit(); } + } +}; +struct associateSameMFT { + Produces em_same_mft_ids; + + SliceCache cache; + PresliceUnsorted perMFTTrack = o2::aod::emprimarymuon::mfttrackId; + std::vector self_Ids; - // for (auto& muon : muons) { - // auto sa_muon = muon.template matchMCHTrack_as(); - // LOGF(info, "muon.collisionId() = %d , muon.globalIndex() = %d, muon.fwdtrackId() = %d , muon.trackType() = %d, muon.matchMCHTrackId() = %d, sa_muon.fwdtrackId() = %d", muon.collisionId(), muon.globalIndex(), muon.fwdtrackId(), muon.trackType(), muon.matchMCHTrackId(), sa_muon.fwdtrackId()); - // } + void process(aod::EMPrimaryMuons const& muons) + { + for (const auto& muon : muons) { + if (muon.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) { + auto muons_with_same_mfttrackId = muons.sliceBy(perMFTTrack, muon.mfttrackId()); + self_Ids.reserve(muons_with_same_mfttrackId.size()); + for (const auto& global_muon : muons_with_same_mfttrackId) { + if (global_muon.globalIndex() == muon.globalIndex()) { // don't store myself. + continue; + } + if (global_muon.collisionId() == muon.collisionId()) { + self_Ids.emplace_back(global_muon.globalIndex()); + } + } + em_same_mft_ids(self_Ids); + self_Ids.clear(); + self_Ids.shrink_to_fit(); + } else { + em_same_mft_ids(std::vector{}); // empty for standalone muons + } + } // end of muon loop } }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"skimmer-primary-muon"}), - adaptAnalysisTask(cfgc, TaskName{"associate-ambiguous-muon"})}; + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"skimmer-primary-muon"}), + adaptAnalysisTask(cfgc, TaskName{"associate-ambiguous-muon"}), + adaptAnalysisTask(cfgc, TaskName{"associate-same-mft"})}; } diff --git a/PWGEM/Dilepton/TableProducer/skimmerPrimaryTrack.cxx b/PWGEM/Dilepton/TableProducer/skimmerPrimaryTrack.cxx new file mode 100644 index 00000000000..2da9262c0dc --- /dev/null +++ b/PWGEM/Dilepton/TableProducer/skimmerPrimaryTrack.cxx @@ -0,0 +1,469 @@ +// 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. + +/// \brief write relevant information about primary tracks. +/// \author daiki.sekihata@cern.ch + +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" + +#include "Common/Core/TableHelper.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::soa; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; + +using MyCollisions = soa::Join; +using MyCollisionsWithSWT = soa::Join; + +using MyTracks = soa::Join; +using MyTrack = MyTracks::iterator; +using MyTracksMC = soa::Join; +using MyTrackMC = MyTracksMC::iterator; + +struct skimmerPrimaryTrack { + SliceCache cache; + Preslice perCol = o2::aod::track::collisionId; + Produces emprimarytracks; + // Produces prmtrackeventidtmp; + + // Configurables + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; + Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; + + // Operation and minimisation criteria + Configurable fillQAHistogram{"fillQAHistogram", false, "flag to fill QA histograms"}; + Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; + + Configurable minpt{"minpt", 0.2, "min pt for ITS-TPC track"}; + Configurable maxpt{"maxpt", 5.0, "max pt for ITS-TPC track"}; + Configurable maxeta{"maxeta", 0.8, "eta acceptance"}; + Configurable dca_xy_max{"dca_xy_max", 1.0, "max DCAxy in cm"}; + Configurable dca_z_max{"dca_z_max", 1.0, "max DCAz in cm"}; + Configurable max_frac_shared_clusters_tpc{"max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + + // Configurable min_ncluster_tpc{"min_ncluster_tpc", 0, "min ncluster tpc"}; + // Configurable mincrossedrows{"mincrossedrows", 70, "min. crossed rows"}; + // Configurable min_tpc_cr_findable_ratio{"min_tpc_cr_findable_ratio", 0.8, "min. TPC Ncr/Nf ratio"}; + // Configurable min_ncluster_its{"min_ncluster_its", 4, "min ncluster its"}; + // Configurable min_ncluster_itsib{"min_ncluster_itsib", 1, "min ncluster itsib"}; + // Configurable maxchi2tpc{"maxchi2tpc", 5.0, "max. chi2/NclsTPC"}; + // Configurable maxchi2its{"maxchi2its", 36.0, "max. chi2/NclsITS"}; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + int mRunNumber; + float d_bz; + Service ccdb; + // o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + o2::dataformats::VertexBase mVtx; + const o2::dataformats::MeanVertexObject* mMeanVtx = nullptr; + o2::base::MatLayerCylSet* lut = nullptr; + + void init(InitContext&) + { + mRunNumber = 0; + d_bz = 0; + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + if (fillQAHistogram) { + fRegistry.add("Track/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); + fRegistry.add("Track/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{4000, -20, 20}}, false); + fRegistry.add("Track/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {80, -2.0f, 2.0f}}, false); + fRegistry.add("Track/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); + fRegistry.add("Track/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); + fRegistry.add("Track/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{1000, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{1000, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); + fRegistry.add("Track/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); + fRegistry.add("Track/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/hTPCNclsShared", "TPC Ncls shared/Ncls;p_{T} (GeV/c);N_{cls}^{shared}/N_{cls} in TPC", kTH2F, {{1000, 0, 10}, {100, 0, 1}}, false); + fRegistry.add("Track/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); + fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{800, 0, 40}}, false); + fRegistry.add("Track/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); + fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); + } + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + + // load matLUT for this timestamp + if (!lut) { + LOG(info) << "Loading material look-up table for timestamp: " << bc.timestamp(); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(lutPath, bc.timestamp())); + } else { + LOG(info) << "Material look-up table already in place. Not reloading."; + } + + // In case override, don't proceed, please - no CCDB access required + if (d_bz_input > -990) { + d_bz = d_bz_input; + o2::parameters::GRPMagField grpmag; + if (std::fabs(d_bz) > 1e-5) { + grpmag.setL3Current(30000.f / (d_bz / 5.0f)); + } + o2::base::Propagator::initFieldFromGRP(&grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + mRunNumber = bc.runNumber(); + return; + } + + auto run3grp_timestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = 0x0; + o2::parameters::GRPMagField* grpmag = 0x0; + if (!skipGRPOquery) { + grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + } + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + // Fetch magnetic field from ccdb for current collision + d_bz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + + // Fetch magnetic field from ccdb for current collision + d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } + mRunNumber = bc.runNumber(); + } + + template + bool checkTrack(TCollision const& collision, TTrack const& track) + { + if constexpr (isMC) { + if (!track.has_mcParticle()) { + return false; + } + } + + if (!track.hasITS() || !track.hasTPC()) { + return false; + } + + if (track.itsChi2NCl() > 36.f) { + return false; + } + if (track.itsNCls() < 4) { + return false; + } + if (track.itsNClsInnerBarrel() < 1) { + return false; + } + + if (track.tpcChi2NCl() > 5.f) { + return false; + } + + if (track.tpcNClsFound() < 0) { + return false; + } + + if (track.tpcNClsCrossedRows() < 50) { + return false; + } + + if (track.tpcCrossedRowsOverFindableCls() < 0.8) { + return false; + } + + if (track.tpcFractionSharedCls() > max_frac_shared_clusters_tpc) { + return false; + } + + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(track.pidForTracking()); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + if (std::fabs(dcaXY) > dca_xy_max || std::fabs(dcaZ) > dca_z_max) { + return false; + } + if (std::fabs(dcaZ) > 3.f) { + return false; + } + + if (std::fabs(trackParCov.getEta()) > maxeta || trackParCov.getPt() < minpt || maxpt < trackParCov.getPt()) { + return false; + } + if (trackParCov.getPt() > 5.f) { + return false; + } + + return true; + } + + template + void fillTrackTable(TCollision const& collision, TTrack const& track) + { + if (std::find(stored_trackIds.begin(), stored_trackIds.end(), std::pair{collision.globalIndex(), track.globalIndex()}) == stored_trackIds.end()) { + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(track.pidForTracking()); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + float pt = trackParCov.getPt(); + float eta = trackParCov.getEta(); + float phi = trackParCov.getPhi(); + o2::math_utils::bringTo02Pi(phi); + uint16_t trackBit = 0; + + // As minimal cuts, following cuts are applied. The cut values are hardcoded on the purpose for consistent bit operation. + // has info on ITS and TPC + // a hit on ITSib any + // Ncls ITS >= 4 + // chi2/Ncls ITS < 36 + // Ncr TPC >= 50 + // chi2/Ncls TPC < 5 + // Ncr/Nf ratio in TPC > 0.8 + + if (track.itsNCls() >= 5) { + trackBit |= static_cast(RefTrackBit::kNclsITS5); + } + if (track.itsNCls() >= 6) { + trackBit |= static_cast(RefTrackBit::kNclsITS6); + } + + if (track.tpcNClsCrossedRows() >= 70) { + trackBit |= static_cast(RefTrackBit::kNcrTPC70); + } + if (track.tpcNClsCrossedRows() >= 90) { + trackBit |= static_cast(RefTrackBit::kNcrTPC90); + } + if (track.tpcNClsFound() >= 50) { + trackBit |= static_cast(RefTrackBit::kNclsTPC50); + } + if (track.tpcNClsFound() >= 70) { + trackBit |= static_cast(RefTrackBit::kNclsTPC70); + } + if (track.tpcNClsFound() >= 90) { + trackBit |= static_cast(RefTrackBit::kNclsTPC90); + } + if (track.tpcChi2NCl() < 4.f) { + trackBit |= static_cast(RefTrackBit::kChi2TPC4); + } + if (track.tpcChi2NCl() < 3.f) { + trackBit |= static_cast(RefTrackBit::kChi2TPC3); + } + if (track.tpcFractionSharedCls() < 0.7) { + trackBit |= static_cast(RefTrackBit::kFracSharedTPC07); + } + + if (std::fabs(dcaZ) < 0.5) { + trackBit |= static_cast(RefTrackBit::kDCAz05cm); + } + if (std::fabs(dcaZ) < 0.3) { + trackBit |= static_cast(RefTrackBit::kDCAz03cm); + } + + if (std::fabs(dcaXY) < 0.5) { + trackBit |= static_cast(RefTrackBit::kDCAxy05cm); + } + if (std::fabs(dcaXY) < 0.3) { + trackBit |= static_cast(RefTrackBit::kDCAxy03cm); + } + + emprimarytracks(collision.globalIndex(), track.globalIndex(), track.sign(), pt, eta, phi, trackBit); + // prmtrackeventidtmp(collision.globalIndex()); + + stored_trackIds.emplace_back(std::pair{collision.globalIndex(), track.globalIndex()}); + + if (fillQAHistogram) { + fRegistry.fill(HIST("Track/hPt"), pt); + fRegistry.fill(HIST("Track/hQoverPt"), track.sign() / pt); + fRegistry.fill(HIST("Track/hEtaPhi"), phi, eta); + fRegistry.fill(HIST("Track/hDCAxyz"), dcaXY, dcaZ); + fRegistry.fill(HIST("Track/hDCAxyzSigma"), dcaXY / std::sqrt(trackParCov.getSigmaY2()), dcaZ / std::sqrt(trackParCov.getSigmaZ2())); + fRegistry.fill(HIST("Track/hDCAxyRes_Pt"), pt, std::sqrt(trackParCov.getSigmaY2()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/hDCAzRes_Pt"), pt, std::sqrt(trackParCov.getSigmaZ2()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); + fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); + fRegistry.fill(HIST("Track/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); + fRegistry.fill(HIST("Track/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); + fRegistry.fill(HIST("Track/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); + fRegistry.fill(HIST("Track/hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); + fRegistry.fill(HIST("Track/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + } + } + } + + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + std::vector> stored_trackIds; + Filter trackFilter = o2::aod::track::itsChi2NCl < 36.f && o2::aod::track::tpcChi2NCl < 5.f && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true; + using MyFilteredTracks = soa::Filtered; + + // ---------- for data ---------- + + void processRec(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks) + { + stored_trackIds.reserve(tracks.size()); + + for (const auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + if (!collision.isSelected()) { + continue; + } + if (!collision.isEoI()) { // events with at least 1 lepton for data reduction. + continue; + } + + auto tracks_per_coll = tracks.sliceBy(perCol, collision.globalIndex()); + for (const auto& track : tracks_per_coll) { + if (!checkTrack(collision, track)) { + continue; + } + fillTrackTable(collision, track); + } + + } // end of collision loop + + stored_trackIds.clear(); + stored_trackIds.shrink_to_fit(); + } + PROCESS_SWITCH(skimmerPrimaryTrack, processRec, "process reconstructed info only", true); // standalone + + void processRec_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks) + { + stored_trackIds.reserve(tracks.size()); + + for (const auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + + if (!collision.isSelected()) { + continue; + } + if (!collision.isEoI()) { // events with at least 1 lepton for data reduction. + continue; + } + if (collision.swtaliastmp_raw() == 0) { + continue; + } + + auto tracks_per_coll = tracks.sliceBy(perCol, collision.globalIndex()); + for (const auto& track : tracks_per_coll) { + if (!checkTrack(collision, track)) { + continue; + } + fillTrackTable(collision, track); + } + + } // end of collision loop + + stored_trackIds.clear(); + stored_trackIds.shrink_to_fit(); + } + PROCESS_SWITCH(skimmerPrimaryTrack, processRec_SWT, "process reconstructed info only", false); // standalone with swt + + // ---------- for MC ---------- + + using MyFilteredTracksMC = soa::Filtered; + void processMC(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks) + { + stored_trackIds.reserve(tracks.size()); + + for (const auto& collision : collisions) { + if (!collision.has_mcCollision()) { + continue; + } + auto bc = collision.template foundBC_as(); + initCCDB(bc); + + if (!collision.isSelected()) { + continue; + } + if (!collision.isEoI()) { // events with at least 1 lepton for data reduction. + continue; + } + + auto tracks_per_coll = tracks.sliceBy(perCol, collision.globalIndex()); + for (const auto& track : tracks_per_coll) { + if (!checkTrack(collision, track)) { + continue; + } + fillTrackTable(collision, track); + } + } // end of collision loop + + stored_trackIds.clear(); + stored_trackIds.shrink_to_fit(); + } + PROCESS_SWITCH(skimmerPrimaryTrack, processMC, "process reconstructed and MC info ", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"skimmer-primary-track"})}; +} diff --git a/PWGEM/Dilepton/TableProducer/skimmerSecondaryElectron.cxx b/PWGEM/Dilepton/TableProducer/skimmerSecondaryElectron.cxx deleted file mode 100644 index e59dc1225e0..00000000000 --- a/PWGEM/Dilepton/TableProducer/skimmerSecondaryElectron.cxx +++ /dev/null @@ -1,628 +0,0 @@ -// 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. - -/// \brief write relevant information about primary electrons. -/// \author daiki.sekihata@cern.ch - -#include -#include -#include -#include -#include -#include - -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/DataModel/CollisionAssociationTables.h" - -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" - -using namespace o2; -using namespace o2::soa; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::constants::physics; - -using MyCollisions = soa::Join; -using MyCollisionsMC = soa::Join; - -using MyTracks = soa::Join; -using MyTrack = MyTracks::iterator; -using MyTracksMC = soa::Join; -using MyTrackMC = MyTracksMC::iterator; - -struct skimmerSecondaryElectron { - // enum class EM_EEPairType : int { - // kULS = 0, - // kLSpp = +1, - // kLSmm = -1, - // }; - - SliceCache cache; - Preslice perCol = o2::aod::track::collisionId; - Produces emprimaryelectrons; - Produces emprimaryelectronscov; - Produces event; - Produces event_mult; - Produces event_cent; - - // Configurables - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; - - // Operation and minimisation criteria - Configurable fillQAHistogram{"fillQAHistogram", false, "flag to fill QA histograms"}; - Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; - Configurable min_ncluster_tpc{"min_ncluster_tpc", 10, "min ncluster tpc"}; - Configurable mincrossedrows{"mincrossedrows", 70, "min. crossed rows"}; - Configurable min_tpc_cr_findable_ratio{"min_tpc_cr_findable_ratio", 0.8, "min. TPC Ncr/Nf ratio"}; - Configurable minitsncls{"minitsncls", 4, "min. number of ITS clusters"}; - Configurable maxchi2tpc{"maxchi2tpc", 5.0, "max. chi2/NclsTPC"}; - Configurable maxchi2its{"maxchi2its", 6.0, "max. chi2/NclsITS"}; - Configurable minpt{"minpt", 0.15, "min pt for track"}; - Configurable maxeta{"maxeta", 0.9, "eta acceptance"}; - Configurable dca_xy_max{"dca_xy_max", 1.0f, "max DCAxy in cm"}; - Configurable dca_z_max{"dca_z_max", 1.0f, "max DCAz in cm"}; - Configurable dca_3d_sigma_max{"dca_3d_sigma_max", 1e+10, "max DCA 3D in sigma"}; - Configurable minTPCNsigmaEl{"minTPCNsigmaEl", -3.0, "min. TPC n sigma for electron inclusion"}; - Configurable maxTPCNsigmaEl{"maxTPCNsigmaEl", +4.0, "max. TPC n sigma for electron inclusion"}; - Configurable slope{"slope", 0.0185, "slope for m vs. phiv"}; - Configurable intercept{"intercept", -0.0280, "intercept for m vs. phiv"}; - Configurable mee_min{"mee_min", 0.0f, "minimum mee to distinguish photon conversion and dalitz decay"}; - - HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - - std::pair> itsRequirement = {1, {0, 1, 2}}; // any hits on 3 ITS ib layers. - - int mRunNumber; - float d_bz; - Service ccdb; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - - void init(InitContext&) - { - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - if (fillQAHistogram) { - fRegistry.add("Track/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {20, -1.0f, 1.0f}}, false); - fRegistry.add("Track/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); - fRegistry.add("Track/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); - fRegistry.add("Track/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{1000, 0, 10}, {500, 0., 500}}, false); - fRegistry.add("Track/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{1000, 0, 10}, {500, 0., 500}}, false); - fRegistry.add("Track/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFbeta", "TOF beta;p_{in} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {600, 0, 1.2}}, false); - fRegistry.add("Track/h1overTOFbeta", "TOF beta;p_{in} (GeV/c);1/#beta", kTH2F, {{1000, 0, 10}, {1000, 0.8, 1.8}}, false); - fRegistry.add("Track/hTOFNsigmaEl", "TOF n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFNsigmaMu", "TOF n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFNsigmaPi", "TOF n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFNsigmaKa", "TOF n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTOFNsigmaPr", "TOF n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("Track/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); on ITS #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {32, 0, 16}}, false); - fRegistry.add("Pair/hMvsPhiV", "mee vs. phiv;#varphi_{V} (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{90, 0, M_PI}, {100, 0, 0.1}}, false); - } - } - - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) - { - if (mRunNumber == bc.runNumber()) { - return; - } - - // In case override, don't proceed, please - no CCDB access required - if (d_bz_input > -990) { - d_bz = d_bz_input; - o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { - grpmag.setL3Current(30000.f / (d_bz / 5.0f)); - } - o2::base::Propagator::initFieldFromGRP(&grpmag); - mRunNumber = bc.runNumber(); - return; - } - - auto run3grp_timestamp = bc.timestamp(); - o2::parameters::GRPObject* grpo = 0x0; - o2::parameters::GRPMagField* grpmag = 0x0; - if (!skipGRPOquery) - grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); - if (grpo) { - o2::base::Propagator::initFieldFromGRP(grpo); - // Fetch magnetic field from ccdb for current collision - d_bz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); - if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; - } - o2::base::Propagator::initFieldFromGRP(grpmag); - // Fetch magnetic field from ccdb for current collision - d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } - mRunNumber = bc.runNumber(); - } - - template - bool checkTrack(TTrack const& track) - { - if constexpr (isMC) { - if (!track.has_mcParticle()) { - return false; - } - } - - if (track.tpcChi2NCl() > maxchi2tpc) { - return false; - } - - if (track.itsChi2NCl() > maxchi2its) { - return false; - } - - if (!track.hasITS() || !track.hasTPC()) { - return false; - } - if (track.itsNCls() < minitsncls) { - return false; - } - - auto hits = std::count_if(itsRequirement.second.begin(), itsRequirement.second.end(), [&](auto&& requiredLayer) { return track.itsClusterMap() & (1 << requiredLayer); }); - if (hits < itsRequirement.first) { - return false; - } - - if (track.tpcNClsFound() < min_ncluster_tpc) { - return false; - } - - if (track.tpcNClsCrossedRows() < mincrossedrows) { - return false; - } - - if (track.tpcCrossedRowsOverFindableCls() < min_tpc_cr_findable_ratio) { - return false; - } - - if (abs(track.dcaXY()) > dca_xy_max || abs(track.dcaZ()) > dca_z_max) { - return false; - } - - if (track.pt() < minpt || abs(track.eta()) > maxeta) { - return false; - } - - return true; - } - - template - void fillTrackTable(TCollision const& collision, TTrack const& track) - { - if (std::find(stored_trackIds.begin(), stored_trackIds.end(), std::pair{collision.globalIndex(), track.globalIndex()}) == stored_trackIds.end()) { - gpu::gpustd::array dcaInfo; - auto track_par_cov_recalc = getTrackParCov(track); - track_par_cov_recalc.setPID(o2::track::PID::Electron); - std::array pVec_recalc = {0, 0, 0}; // px, py, pz - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, track_par_cov_recalc, 2.f, matCorr, &dcaInfo); - getPxPyPz(track_par_cov_recalc, pVec_recalc); - float dcaXY = dcaInfo[0]; - float dcaZ = dcaInfo[1]; - - float pt_recalc = track_par_cov_recalc.getPt(); - float eta_recalc = track_par_cov_recalc.getEta(); - float phi_recalc = track_par_cov_recalc.getPhi(); - - bool isAssociatedToMPC = collision.globalIndex() == track.collisionId(); - - emprimaryelectrons(collision.globalIndex(), track.globalIndex(), track.sign(), - pt_recalc, eta_recalc, phi_recalc, dcaXY, dcaZ, - track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), track.tpcNClsShared(), - track.tpcChi2NCl(), track.tpcInnerParam(), - track.tpcSignal(), track.tpcNSigmaEl(), track.tpcNSigmaMu(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), - track.beta(), track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), - track.itsClusterSizes(), 0, 0, 0, 0, 0, - track.itsChi2NCl(), track.tofChi2(), track.detectorMap(), - track_par_cov_recalc.getX(), track_par_cov_recalc.getAlpha(), track_par_cov_recalc.getY(), track_par_cov_recalc.getZ(), track_par_cov_recalc.getSnp(), track_par_cov_recalc.getTgl(), isAssociatedToMPC); - - emprimaryelectronscov( - track_par_cov_recalc.getSigmaY2(), - track_par_cov_recalc.getSigmaZY(), - track_par_cov_recalc.getSigmaZ2(), - track_par_cov_recalc.getSigmaSnpY(), - track_par_cov_recalc.getSigmaSnpZ(), - track_par_cov_recalc.getSigmaSnp2(), - track_par_cov_recalc.getSigmaTglY(), - track_par_cov_recalc.getSigmaTglZ(), - track_par_cov_recalc.getSigmaTglSnp(), - track_par_cov_recalc.getSigmaTgl2(), - track_par_cov_recalc.getSigma1PtY(), - track_par_cov_recalc.getSigma1PtZ(), - track_par_cov_recalc.getSigma1PtSnp(), - track_par_cov_recalc.getSigma1PtTgl(), - track_par_cov_recalc.getSigma1Pt2()); - - stored_trackIds.emplace_back(std::pair{collision.globalIndex(), track.globalIndex()}); - - if (fillQAHistogram) { - uint32_t itsClusterSizes = track.itsClusterSizes(); - int total_cluster_size = 0, nl = 0; - for (unsigned int layer = 3; layer < 7; layer++) { - int cluster_size_per_layer = (itsClusterSizes >> (layer * 4)) & 0xf; - if (cluster_size_per_layer > 0) { - nl++; - } - total_cluster_size += cluster_size_per_layer; - } - - fRegistry.fill(HIST("Track/hPt"), pt_recalc); - fRegistry.fill(HIST("Track/hQoverPt"), track.sign() / pt_recalc); - fRegistry.fill(HIST("Track/hEtaPhi"), phi_recalc, eta_recalc); - fRegistry.fill(HIST("Track/hDCAxyz"), dcaXY, dcaZ); - fRegistry.fill(HIST("Track/hDCAxyzSigma"), dcaXY / sqrt(track_par_cov_recalc.getSigmaY2()), dcaZ / sqrt(track_par_cov_recalc.getSigmaZ2())); - fRegistry.fill(HIST("Track/hDCAxyRes_Pt"), pt_recalc, sqrt(track_par_cov_recalc.getSigmaY2()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/hDCAzRes_Pt"), pt_recalc, sqrt(track_par_cov_recalc.getSigmaZ2()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), track.p(), static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(track.tgl()))); - fRegistry.fill(HIST("Track/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); - fRegistry.fill(HIST("Track/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); - fRegistry.fill(HIST("Track/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); - fRegistry.fill(HIST("Track/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); - fRegistry.fill(HIST("Track/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); - fRegistry.fill(HIST("Track/hTOFbeta"), track.tpcInnerParam(), track.beta()); - fRegistry.fill(HIST("Track/h1overTOFbeta"), track.tpcInnerParam(), 1. / track.beta()); - fRegistry.fill(HIST("Track/hTOFNsigmaEl"), track.tpcInnerParam(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/hTOFNsigmaMu"), track.tpcInnerParam(), track.tofNSigmaMu()); - fRegistry.fill(HIST("Track/hTOFNsigmaPi"), track.tpcInnerParam(), track.tofNSigmaPi()); - fRegistry.fill(HIST("Track/hTOFNsigmaKa"), track.tpcInnerParam(), track.tofNSigmaKa()); - fRegistry.fill(HIST("Track/hTOFNsigmaPr"), track.tpcInnerParam(), track.tofNSigmaPr()); - } - } - } - - std::vector> stored_trackIds; - Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::tpcChi2NCl < maxchi2tpc&& o2::aod::track::itsChi2NCl < maxchi2its&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true && nabs(o2::aod::track::dcaXY) < dca_xy_max&& nabs(o2::aod::track::dcaZ) < dca_z_max; - Filter pidFilter = minTPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < maxTPCNsigmaEl; - using MyFilteredTracks = soa::Filtered; - - Partition posTracks = o2::aod::track::signed1Pt > 0.f; - Partition negTracks = o2::aod::track::signed1Pt < 0.f; - - // ---------- for data ---------- - - void processRec(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks) - { - stored_trackIds.reserve(tracks.size()); - - for (auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - if (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - continue; - } - - auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); // loose track sample - auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); // loose track sample - - int npair = 0; - for (auto& [pos, neg] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS - - if (!checkTrack(pos) || !checkTrack(neg)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(neg.pt(), neg.eta(), neg.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float mee = v12.M(); - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), neg.px(), neg.py(), neg.pz(), pos.sign(), neg.sign(), d_bz); - - if (mee < mee_min || slope * phiv + intercept < mee) { // select phocon conversions - continue; - } - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/hMvsPhiV"), phiv, mee); - } - fillTrackTable(collision, pos); - fillTrackTable(collision, neg); - npair++; - } - - if (npair < 0.5) { - continue; - } - - event(collision.globalIndex(), bc.runNumber(), bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), - collision.posX(), collision.posY(), collision.posZ(), - collision.numContrib(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); - event_mult(collision.multFT0A(), collision.multFT0C(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); - event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C()); - } // end of collision loop - - stored_trackIds.clear(); - stored_trackIds.shrink_to_fit(); - } - PROCESS_SWITCH(skimmerSecondaryElectron, processRec, "process reconstructed info only", true); // standalone - - // ---------- for MC ---------- - using MyFilteredTracksMC = soa::Filtered; - Partition posTracksMC = o2::aod::track::signed1Pt > 0.f; - Partition negTracksMC = o2::aod::track::signed1Pt < 0.f; - void processMC(MyCollisionsMC const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks) - { - stored_trackIds.reserve(tracks.size()); - - for (auto& collision : collisions) { - if (!collision.has_mcCollision()) { - continue; - } - auto bc = collision.bc_as(); - initCCDB(bc); - - if (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - continue; - } - - auto posTracks_per_coll = posTracksMC->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); // loose track sample - auto negTracks_per_coll = negTracksMC->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); // loose track sample - - int npair = 0; - for (auto& [pos, neg] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS - if (!checkTrack(pos) || !checkTrack(neg)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(neg.pt(), neg.eta(), neg.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float mee = v12.M(); - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), neg.px(), neg.py(), neg.pz(), pos.sign(), neg.sign(), d_bz); - - if (mee < mee_min || slope * phiv + intercept < mee) { // select phocon conversions - continue; - } - if (fillQAHistogram) { - fRegistry.fill(HIST("Pair/hMvsPhiV"), phiv, mee); - } - fillTrackTable(collision, pos); - fillTrackTable(collision, neg); - npair++; - } - - if (npair < 0.5) { - continue; - } - - event(collision.globalIndex(), bc.runNumber(), bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), - collision.posX(), collision.posY(), collision.posZ(), - collision.numContrib(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); - event_mult(collision.multFT0A(), collision.multFT0C(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); - event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C()); - } // end of collision loop - - stored_trackIds.clear(); - stored_trackIds.shrink_to_fit(); - } - PROCESS_SWITCH(skimmerSecondaryElectron, processMC, "process reconstructed and MC info ", false); -}; - -struct AssociateMCInfoSecondaryElectron { - Produces mcevents; - Produces mceventlabels; - Produces emmcparticles; - Produces emprimaryelectronmclabels; - - HistogramRegistry registry{"EMMCEvent"}; - void init(o2::framework::InitContext&) - { - auto hEventCounter = registry.add("hEventCounter", "hEventCounter", kTH1I, {{6, 0.5f, 6.5f}}); - hEventCounter->GetXaxis()->SetBinLabel(1, "all"); - hEventCounter->GetXaxis()->SetBinLabel(2, "has mc collision"); - } - - void processMC(MyCollisionsMC const& collisions, aod::McCollisions const&, aod::McParticles const& mcTracks, MyTracksMC const& o2tracks, aod::EMEvents const& emevents, aod::EMPrimaryElectrons const& emprimaryelectrons) - { - // temporary variables used for the indexing of the skimmed MC stack - std::map fNewLabels; - std::map fNewLabelsReversed; - // std::map fMCFlags; - std::map fEventIdx; - std::map fEventLabels; - int fCounters[2] = {0, 0}; //! [0] - particle counter, [1] - event counter - - for (auto& emevent : emevents) { - registry.fill(HIST("hEventCounter"), 1); - auto collision = collisions.iteratorAt(emevent.collisionId()); - auto mcCollision = collision.mcCollision(); - - if (!(fEventLabels.find(mcCollision.globalIndex()) != fEventLabels.end())) { - mcevents(mcCollision.globalIndex(), mcCollision.generatorsID(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.impactParameter(), mcCollision.eventPlaneAngle()); - fEventLabels[mcCollision.globalIndex()] = fCounters[1]; - fCounters[1]++; - } - - mceventlabels(fEventLabels.find(mcCollision.globalIndex())->second, collision.mcMask()); - } // end of reconstructed collision loop - - for (auto& emprimaryelectron : emprimaryelectrons) { - auto collision_from_el = collisions.iteratorAt(emprimaryelectron.collisionId()); - if (!collision_from_el.has_mcCollision()) { - continue; - } - auto mcCollision_from_el = collision_from_el.mcCollision(); - - auto o2track = o2tracks.iteratorAt(emprimaryelectron.trackId()); - if (!o2track.has_mcParticle()) { - continue; // If no MC particle is found, skip the dilepton - } - auto mctrack = o2track.template mcParticle_as(); - - // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack - if (!(fNewLabels.find(mctrack.globalIndex()) != fNewLabels.end())) { - fNewLabels[mctrack.globalIndex()] = fCounters[0]; - fNewLabelsReversed[fCounters[0]] = mctrack.globalIndex(); - // fMCFlags[mctrack.globalIndex()] = mcflags; - fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mcCollision_from_el.globalIndex())->second; - fCounters[0]++; - } - emprimaryelectronmclabels(fNewLabels.find(mctrack.index())->second, o2track.mcMask()); - - // Next, store mother-chain of this reconstructed track. - int motherid = -999; // first mother index - if (mctrack.has_mothers()) { - motherid = mctrack.mothersIds()[0]; // first mother index - } - while (motherid > -1) { - if (motherid < mcTracks.size()) { // protect against bad mother indices. why is this needed? - auto mp = mcTracks.iteratorAt(motherid); - - // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack - if (!(fNewLabels.find(mp.globalIndex()) != fNewLabels.end())) { - fNewLabels[mp.globalIndex()] = fCounters[0]; - fNewLabelsReversed[fCounters[0]] = mp.globalIndex(); - // fMCFlags[mp.globalIndex()] = mcflags; - fEventIdx[mp.globalIndex()] = fEventLabels.find(mcCollision_from_el.globalIndex())->second; - fCounters[0]++; - } - - if (mp.has_mothers()) { - motherid = mp.mothersIds()[0]; // first mother index - } else { - motherid = -999; - } - } else { - motherid = -999; - } - } // end of mother chain loop - - } // end of em primary electron loop - - // Loop over the label map, create the mother/daughter relationships if these exist and write the skimmed MC stack - for (const auto& [newLabel, oldLabel] : fNewLabelsReversed) { - auto mctrack = mcTracks.iteratorAt(oldLabel); - // uint16_t mcflags = fMCFlags.find(oldLabel)->second; - - std::vector mothers; - if (mctrack.has_mothers()) { - for (auto& m : mctrack.mothersIds()) { - if (m < mcTracks.size()) { // protect against bad mother indices - if (fNewLabels.find(m) != fNewLabels.end()) { - mothers.push_back(fNewLabels.find(m)->second); - } - } else { - std::cout << "Mother label (" << m << ") exceeds the McParticles size (" << mcTracks.size() << ")" << std::endl; - std::cout << " Check the MC generator" << std::endl; - } - } - } - - // Note that not all daughters from the original table are preserved in the skimmed MC stack - std::vector daughters; - if (mctrack.has_daughters()) { - // int ndau = mctrack.daughtersIds()[1] - mctrack.daughtersIds()[0] + 1; - // LOGF(info, "daughter range in original MC stack pdg = %d | %d - %d , n dau = %d", mctrack.pdgCode(), mctrack.daughtersIds()[0], mctrack.daughtersIds()[1], mctrack.daughtersIds()[1] -mctrack.daughtersIds()[0] +1); - for (int d = mctrack.daughtersIds()[0]; d <= mctrack.daughtersIds()[1]; ++d) { - // TODO: remove this check as soon as issues with MC production are fixed - if (d < mcTracks.size()) { // protect against bad daughter indices - // auto dau_tmp = mcTracks.iteratorAt(d); - // // LOGF(info, "daughter pdg = %d", dau_tmp.pdgCode()); - // if ((mctrack.pdgCode() == 223 || mctrack.pdgCode() == 333) && (mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { - // if (fNewLabels.find(d) == fNewLabels.end() && (abs(dau_tmp.pdgCode()) == 11 || abs(dau_tmp.pdgCode()) == 13)) { - // LOGF(info, "daughter lepton is not found mctrack.globalIndex() = %d, mctrack.producedByGenerator() == %d, ndau = %d | dau_tmp.globalIndex() = %d, dau_tmp.pdgCode() = %d, dau_tmp.producedByGenerator() = %d, dau_tmp.pt() = %f, dau_tmp.eta() = %f, dau_tmp.phi() = %f", mctrack.globalIndex(), mctrack.producedByGenerator(), ndau, dau_tmp.globalIndex(), dau_tmp.pdgCode(), dau_tmp.producedByGenerator(), dau_tmp.pt(), dau_tmp.eta(), dau_tmp.phi()); - // } - // } - - if (fNewLabels.find(d) != fNewLabels.end()) { - daughters.push_back(fNewLabels.find(d)->second); - } - } else { - std::cout << "Daughter label (" << d << ") exceeds the McParticles size (" << mcTracks.size() << ")" << std::endl; - std::cout << " Check the MC generator" << std::endl; - } - } - } - - emmcparticles(fEventIdx.find(oldLabel)->second, mctrack.pdgCode(), mctrack.flags(), - mothers, daughters, - mctrack.px(), mctrack.py(), mctrack.pz(), mctrack.e(), - mctrack.vx(), mctrack.vy(), mctrack.vz()); - - mothers.clear(); - mothers.shrink_to_fit(); - daughters.clear(); - daughters.shrink_to_fit(); - } // end loop over labels - - fNewLabels.clear(); - fNewLabelsReversed.clear(); - // fMCFlags.clear(); - fEventIdx.clear(); - fEventLabels.clear(); - fCounters[0] = 0; - fCounters[1] = 0; - } - - void processDummy(MyCollisions const&) {} - - PROCESS_SWITCH(AssociateMCInfoSecondaryElectron, processMC, "create em mc event table for Electron", false); - PROCESS_SWITCH(AssociateMCInfoSecondaryElectron, processDummy, "processDummy", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"skimmer-secondary-electron"}), - adaptAnalysisTask(cfgc, TaskName{"associate-mc-info-secondary-electron"}), - }; -} diff --git a/PWGEM/Dilepton/TableProducer/treeCreatorElectronML.cxx b/PWGEM/Dilepton/TableProducer/treeCreatorElectronML.cxx index 7643f79a984..79d21b1e059 100644 --- a/PWGEM/Dilepton/TableProducer/treeCreatorElectronML.cxx +++ b/PWGEM/Dilepton/TableProducer/treeCreatorElectronML.cxx @@ -14,33 +14,37 @@ // This code will create data table for inputs to machine learning for electrons. // Please write to: daiki.sekihata@cern.ch -#include -#include -#include -#include -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/trackUtilities.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/MCUtilities.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" + #include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" #include "CommonConstants/PhysicsConstants.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" #include "DCAFitter/DCAFitterN.h" -#include "CCDB/BasicCCDBManager.h" -#include "PWGEM/Dilepton/Utils/MCUtilities.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/Vector4D.h" + +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -96,8 +100,8 @@ DECLARE_SOA_TABLE(MyTracks, "AOD", "MYTRACK", //! track::DcaXY, track::DcaZ, mytrack::DCAresXY, mytrack::DCAresZ, track::CZY, track::TPCNClsFindable, mytrack::TPCNClsFound, mytrack::TPCNClsCrossedRows, track::TPCChi2NCl, track::TPCInnerParam, - track::TPCSignal, pidtpc::TPCNSigmaEl, pidtpc::TPCNSigmaMu, pidtpc::TPCNSigmaPi, pidtpc::TPCNSigmaKa, pidtpc::TPCNSigmaPr, - pidtofbeta::Beta, pidtof::TOFNSigmaEl, pidtof::TOFNSigmaMu, pidtof::TOFNSigmaPi, pidtof::TOFNSigmaKa, pidtof::TOFNSigmaPr, + track::TPCSignal, pidtpc::TPCNSigmaEl, /*pidtpc::TPCNSigmaMu,*/ pidtpc::TPCNSigmaPi, pidtpc::TPCNSigmaKa, pidtpc::TPCNSigmaPr, + pidtofbeta::Beta, pidtof::TOFNSigmaEl, /*pidtof::TOFNSigmaMu,*/ pidtof::TOFNSigmaPi, pidtof::TOFNSigmaKa, pidtof::TOFNSigmaPr, track::TOFChi2, track::ITSChi2NCl, track::ITSClusterSizes, mytrack::MCVx, mytrack::MCVy, mytrack::MCVz, mcparticle::PdgCode, mytrack::IsPhysicalPrimary, mytrack::MotherIds, mytrack::MotherPdgCodes); @@ -584,8 +588,8 @@ struct TreeCreatorElectronML { track.sign(), track.pt(), track.eta(), track.phi(), track.tgl(), track.dcaXY(), track.dcaZ(), sqrt(track.cYY()), sqrt(track.cZZ()), track.cZY(), track.tpcNClsFindable(), track.tpcNClsFound(), track.tpcNClsCrossedRows(), track.tpcChi2NCl(), track.tpcInnerParam(), - track.tpcSignal(), track.tpcNSigmaEl(), track.tpcNSigmaMu(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), - track.beta(), track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), + track.tpcSignal(), track.tpcNSigmaEl(), /*track.tpcNSigmaMu(),*/ track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), + track.beta(), track.tofNSigmaEl(), /*track.tofNSigmaMu(),*/ track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), track.tofChi2(), track.itsChi2NCl(), track.itsClusterSizes(), mctrack.vx(), mctrack.vy(), mctrack.vz(), mctrack.pdgCode(), mctrack.isPhysicalPrimary(), mothers_id, mothers_pdg); @@ -647,7 +651,7 @@ struct TreeCreatorElectronML { } PROCESS_SWITCH(TreeCreatorElectronML, processSingleTrack, "produce ML input for single track level", false); - using MyFilteredCollisionsSkimmed = soa::Filtered>; + using MyFilteredCollisionsSkimmed = soa::Filtered>; using MyFilteredTracksMCSkimmed = soa::Filtered>; Preslice perCollisionSkimmed = aod::emprimaryelectron::emeventId; diff --git a/PWGEM/Dilepton/TableProducer/treeCreatorElectronMLDDA.cxx b/PWGEM/Dilepton/TableProducer/treeCreatorElectronMLDDA.cxx index 2e5e0164aec..08b3f7ad8f3 100644 --- a/PWGEM/Dilepton/TableProducer/treeCreatorElectronMLDDA.cxx +++ b/PWGEM/Dilepton/TableProducer/treeCreatorElectronMLDDA.cxx @@ -14,32 +14,40 @@ // This code will create data table for inputs to machine learning for electrons. // Please write to: daiki.sekihata@cern.ch -#include -#include -#include -#include "Math/Vector4D.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" +#include "PWGEM/Dilepton/DataModel/lmeeMLTables.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/CCDB/RCTSelectionFlags.h" #include "Common/Core/RecoDecay.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" #include "CommonConstants/PhysicsConstants.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" +#include "DCAFitter/DCAFitterN.h" +#include "DataFormatsCalibration/MeanVertexObject.h" #include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "PWGEM/Dilepton/DataModel/lmeeMLTables.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/Vector4D.h" + +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -47,169 +55,226 @@ using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::constants::physics; -using MyCollisions = soa::Join; +using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; -using MyTracks = soa::Join; +using MyTracks = soa::Join; using MyTrack = MyTracks::iterator; struct TreeCreatorElectronMLDDA { - enum class EM_V0_Label : int { // Reconstructed V0 - kUndef = -1, - kGamma = 0, - kK0S = 1, - kLambda = 2, - kAntiLambda = 3, - }; - SliceCache cache; - Produces emprimarytracks; // flat table containing collision + track information + Produces emprimarytracks; // flat table containing collision + track information // Basic checks HistogramRegistry registry{ "registry", { {"hEventCounter", "hEventCounter", {HistType::kTH1F, {{5, 0.5f, 5.5f}}}}, - {"hAP", "Armenteros Podolanski", {HistType::kTH2F, {{200, -1.f, +1.f}, {250, 0, 0.25}}}}, - {"hXY_Gamma", "photon conversion point in XY;X (cm);Y (cm)", {HistType::kTH2F, {{400, -100, +100}, {400, -100, +100}}}}, - {"hMassGamma_Rxy", "V0 mass gamma", {HistType::kTH2F, {{200, 0, 100}, {100, 0, 0.1}}}}, - {"hCosPA", "V0 cosine of pointing angle", {HistType::kTH1F, {{100, 0.9, 1.f}}}}, - {"hPCA", "V0 distance between 2 legs", {HistType::kTH1F, {{200, 0.f, 2.f}}}}, - {"hMassGamma", "V0 mass gamma", {HistType::kTH1F, {{100, 0, 0.1}}}}, - {"hMassK0Short", "V0 mass K0S", {HistType::kTH1F, {{200, 0.4, 0.6}}}}, - {"hMassLambda", "V0 mass Lambda", {HistType::kTH1F, {{100, 1.05, 1.15}}}}, - {"hMassAntiLambda", "V0 mass AntiLambda", {HistType::kTH1F, {{100, 1.05, 1.15}}}}, - {"hMvsPhiV", "mee vs. phiv", {HistType::kTH2F, {{72, 0, M_PI}, {100, 0, 0.1}}}}, - {"hMvsPhiV_primary", "mee vs. phiv for primary e candidate", {HistType::kTH2F, {{72, 0, M_PI}, {100, 0, 0.1}}}}, - - {"hTPCdEdx_P", "TPC dEdx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, - {"hTOFbeta_P", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, - {"hTPCdEdx_P_El", "TPC dEdx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, - {"hTOFbeta_P_El", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, - {"hTPCdEdx_P_Mu", "TPC dEdx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, - {"hTOFbeta_P_Mu", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, - {"hTPCdEdx_P_Pi", "TPC dEdx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, - {"hTOFbeta_P_Pi", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, - {"hTPCdEdx_P_Ka", "TPC dEdx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, - {"hTOFbeta_P_Ka", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, - {"hTPCdEdx_P_Pr", "TPC dEdx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, - {"hTOFbeta_P_Pr", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, - - {"hTPCNsigmaEl_P", "TPC n#sigma_{e} vs. p;p^{ITS-TPC} (GeV/c);n #sigma_{e}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTPCNsigmaMu_P", "TPC n#sigma_{#mu} vs. p;p^{ITS-TPC} (GeV/c);n #sigma_{#mu}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTPCNsigmaPi_P", "TPC n#sigma_{#pi} vs. p;p^{ITS-TPC} (GeV/c);n #sigma_{#pi}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTPCNsigmaKa_P", "TPC n#sigma_{K} vs. p;p^{ITS-TPC} (GeV/c);n #sigma_{K}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTPCNsigmaPr_P", "TPC n#sigma_{p} vs. p;p^{ITS-TPC} (GeV/c);n #sigma_{p}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTOFNsigmaEl_P", "TOF n#sigma_{e} vs. p;p^{ITS-TOF} (GeV/c);n #sigma_{e}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTOFNsigmaMu_P", "TOF n#sigma_{#mu} vs. p;p^{ITS-TOF} (GeV/c);n #sigma_{#mu}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTOFNsigmaPi_P", "TOF n#sigma_{#pi} vs. p;p^{ITS-TOF} (GeV/c);n #sigma_{#pi}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTOFNsigmaKa_P", "TOF n#sigma_{K} vs. p;p^{ITS-TOF} (GeV/c);n #sigma_{K}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTOFNsigmaPr_P", "TOF n#sigma_{p} vs. p;p^{ITS-TOF} (GeV/c);n #sigma_{p}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - - {"Cascade/hAP", "Armenteros Podolanski for cascade", {HistType::kTH2F, {{200, -1.f, +1.f}, {250, 0, 0.25}}}}, - {"Cascade/hAP_V0", "Armenteros Podolanski for #Lambda and #bar{#Lambda}", {HistType::kTH2F, {{200, -1.f, +1.f}, {250, 0, 0.25}}}}, - {"Cascade/hRxy", "R_{xy} of cascade vs. in-V0;R_{xy} of V0 (cm);R_{xy} of cascade (cm)", {HistType::kTH2F, {{200, 0, 20.f}, {200, 0, 20.f}}}}, + {"V0/hAP", "Armenteros Podolanski", {HistType::kTH2F, {{200, -1.f, +1.f}, {250, 0, 0.25}}}}, + {"V0/hXY_Gamma", "photon conversion point in XY;X (cm);Y (cm)", {HistType::kTH2F, {{400, -100, +100}, {400, -100, +100}}}}, + {"V0/hMassGamma_Rxy", "V0 mass gamma", {HistType::kTH2F, {{200, 0, 100}, {100, 0, 0.1}}}}, + {"V0/hCosPA", "V0 cosine of pointing angle", {HistType::kTH1F, {{100, 0.99, 1.f}}}}, + {"V0/hPCA", "V0 distance between 2 legs", {HistType::kTH1F, {{50, 0.f, 0.5f}}}}, + {"V0/hMassGamma", "V0 mass gamma", {HistType::kTH1F, {{100, 0, 0.1}}}}, + {"V0/hMassK0Short", "V0 mass K0S", {HistType::kTH1F, {{200, 0.4, 0.6}}}}, + {"V0/hMassLambda", "V0 mass Lambda", {HistType::kTH1F, {{100, 1.08, 1.18}}}}, + {"V0/hMassAntiLambda", "V0 mass AntiLambda", {HistType::kTH1F, {{100, 1.08, 1.18}}}}, + + {"V0/hTPCdEdx_P_El", "TPC dEdx vs. p;p_{in} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, + {"V0/hTPCdEdx_P_Pi", "TPC dEdx vs. p;p_{in} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, + {"V0/hTPCdEdx_P_Ka", "TPC dEdx vs. p;p_{in} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, + {"V0/hTPCdEdx_P_Pr", "TPC dEdx vs. p;p_{in} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0, 5}, {200, 0, 200}}}}, + {"V0/hTOFbeta_P_El", "TOF beta vs. p;p_{in} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, + {"V0/hTOFbeta_P_Pi", "TOF beta vs. p;p_{in} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, + {"V0/hTOFbeta_P_Ka", "TOF beta vs. p;p_{in} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, + {"V0/hTOFbeta_P_Pr", "TOF beta vs. p;p_{in} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0, 5}, {220, 0, 1.1}}}}, + {"Cascade/hRxy_Xi", "R_{xy} of cascade vs. mass;m_{#Lambda#pi};R_{xy} (cm)", {HistType::kTH2F, {{200, 1.2, 1.4}, {200, 0, 20.f}}}}, {"Cascade/hRxy_Omega", "R_{xy} of cascade vs. mass;m_{#LambdaK};R_{xy} (cm)", {HistType::kTH2F, {{200, 1.6, 1.8}, {200, 0, 20.f}}}}, {"Cascade/hCTau_Xi", "c#tau vs. mass;m_{#Lambda#pi};c#tau (cm)", {HistType::kTH2F, {{200, 1.2, 1.4}, {200, 0, 20.f}}}}, {"Cascade/hCTau_Omega", "c#tau vs. mass;m_{#LambdaK};c#tau (cm)", {HistType::kTH2F, {{200, 1.6, 1.8}, {200, 0, 20.f}}}}, - {"Cascade/hV0CosPA", "V0 cosine of pointing angle", {HistType::kTH1F, {{100, 0.9, 1.f}}}}, - {"Cascade/hV0PCA", "V0 distance between 2 legs", {HistType::kTH1F, {{200, 0.f, 2.f}}}}, - {"Cascade/hCosPA", "cascade cosine of pointing angle", {HistType::kTH1F, {{100, 0.9, 1.f}}}}, - {"Cascade/hPCA", "cascade distance between 2 legs", {HistType::kTH1F, {{200, 0.f, 2.f}}}}, - {"Cascade/hMassLambda", "V0 mass Lambda in cascade", {HistType::kTH1F, {{100, 1.05, 1.15}}}}, - {"Cascade/hMassAntiLambda", "V0 mass AntiLambda in cascade", {HistType::kTH1F, {{100, 1.05, 1.15}}}}, + {"Cascade/hV0CosPA", "V0 cosine of pointing angle", {HistType::kTH1F, {{100, 0.99, 1.f}}}}, + {"Cascade/hV0PCA", "V0 distance between 2 legs", {HistType::kTH1F, {{50, 0.f, 0.5}}}}, + {"Cascade/hCosPA", "cascade cosine of pointing angle", {HistType::kTH1F, {{100, 0.99, 1.f}}}}, + {"Cascade/hPCA", "cascade distance between 2 legs", {HistType::kTH1F, {{50, 0.f, 0.5}}}}, + {"Cascade/hMassLambda", "V0 mass Lambda in cascade", {HistType::kTH1F, {{100, 1.08, 1.18}}}}, {"Cascade/hMassXi", "cascade mass #Xi", {HistType::kTH1F, {{200, 1.2, 1.4}}}}, {"Cascade/hMassOmega", "cascade mass #Omega", {HistType::kTH1F, {{200, 1.6, 1.8}}}}, - {"Cascade/hMassPt_Xi", "cascade mass #Xi;m_{#Lambda#pi} (GeV/c^{2});p_{T,#Lambda#pi} (GeV/c)", {HistType::kTH2F, {{200, 1.2, 1.4}, {100, 0, 10}}}}, - {"Cascade/hMassPt_Xi_bachelor", "cascade mass #Xi;m_{#Lambda#pi} (GeV/c^{2});p_{T,#pi} (GeV/c)", {HistType::kTH2F, {{200, 1.2, 1.4}, {100, 0, 10}}}}, - {"Cascade/hMassPt_Omega", "cascade mass #Omegam_{#LambdaK} (GeV/c^{2});p_{T,#LambdaK} (GeV/c)", {HistType::kTH2F, {{200, 1.6, 1.8}, {100, 0, 10}}}}, - {"Cascade/hMassPt_Omega_bachelor", "cascade mass #Omega;m_{#LambdaK} (GeV/c^{2});p_{T,K} (GeV/c)", {HistType::kTH2F, {{200, 1.6, 1.8}, {100, 0, 10}}}}, + {"Cascade/hMassPt_Xi", "cascade mass #Xi^{#pm};m_{#Lambda#pi} (GeV/c^{2});p_{T,#Lambda#pi} (GeV/c)", {HistType::kTH2F, {{200, 1.2, 1.4}, {100, 0, 10}}}}, + {"Cascade/hMassPt_Omega", "cascade mass #Omega^{#pm};m_{#LambdaK} (GeV/c^{2});p_{T,#LambdaK} (GeV/c)", {HistType::kTH2F, {{200, 1.6, 1.8}, {100, 0, 10}}}}, }, }; - // Configurables - // CCDB options Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; // Operation and minimisation criteria - Configurable d_bz_input{"d_bz", -999, "bz field, -999 is automatic"}; - Configurable d_UseAbsDCA{"d_UseAbsDCA", true, "Use Abs DCAs"}; - Configurable d_UseWeightedPCA{"d_UseWeightedPCA", false, "Vertices use cov matrices"}; - Configurable useMatCorrType{"useMatCorrType", 0, "0: none, 1: TGeo, 2: LUT"}; - - // TPC-related variables - Configurable mincrossedrows{"mincrossedrows", 40, "min. crossed rows"}; - Configurable maxchi2tpc{"maxchi2tpc", 5.0, "max. chi2/NclsTPC"}; - - // ITS-related variables - Configurable minitsibncls{"minitsibncls", 1, "min. number of ITSib clusters"}; - Configurable minitsncls{"minitsncls", 4, "min. number of ITS clusters"}; - Configurable maxchi2its{"maxchi2its", 6.0, "max. chi2/NclsITS"}; - - // for v0 - Configurable max_mee_pcm{"max_mee_pcm", 0.02, "max mee to v0 photon"}; - Configurable minv0cospa{"minv0cospa", 0.997, "minimum V0 CosPA"}; - Configurable maxdcav0dau{"maxdcav0dau", 0.2, "max distance between V0 Daughters"}; - Configurable mindcaxytopv_v0leg{"mindcaxytopv_v0leg", -1, "max dcaxy to pv for v0 leg"}; // 0.05 cm - Configurable downscaling_electron{"downscaling_electron", 0.005, "down scaling factor to store electron"}; - Configurable downscaling_pion{"downscaling_pion", 0.001, "down scaling factor to store pion"}; - Configurable downscaling_kaon{"downscaling_kaon", 1.1, "down scaling factor to store kaon"}; - Configurable downscaling_proton{"downscaling_proton", 0.01, "down scaling factor to store proton"}; - - // for pion - Configurable minTPCNsigmaPi{"minTPCNsigmaPi", -1e+10, "min. TPC n sigma for pion inclusion"}; // this is only for IsElectronTag - Configurable maxTPCNsigmaPi{"maxTPCNsigmaPi", 3.0, "max. TPC n sigma for pion inclusion"}; - Configurable maxTOFNsigmaPi{"maxTOFNsigmaPi", 3.0, "max. TOF n sigma for pion inclusion"}; - - // for kaon - Configurable maxTPCNsigmaKa{"maxTPCNsigmaKa", 3.0, "max. TPC n sigma for kaon inclusion"}; - Configurable maxTOFNsigmaKa{"maxTOFNsigmaKa", 3.0, "max. TOF n sigma for kaon inclusion"}; - - // for proton - Configurable maxTPCNsigmaPr{"maxTPCNsigmaPr", 3.0, "max. TPC n sigma for proton inclusion"}; - Configurable maxTOFNsigmaPr{"maxTOFNsigmaPr", 3.0, "max. TOF n sigma for proton inclusion"}; - - // for phiv vs. mee - Configurable minpt{"minpt", 0.05, "min pt for global tracks"}; - Configurable maxeta{"maxeta", 0.9, "max. eta for global tracks"}; - Configurable maxdcaXY{"maxdcaXY", 0.5, "max. DCA in XY"}; - Configurable maxdcaZ{"maxdcaZ", 0.5, "max. DCA in Z"}; - Configurable minTPCNsigmaEl{"minTPCNsigmaEl", -3.0, "min. TPC n sigma for electron inclusion"}; - Configurable maxTPCNsigmaEl{"maxTPCNsigmaEl", 3.0, "max. TPC n sigma for electron inclusion"}; - Configurable maxTOFNsigmaEl{"maxTOFNsigmaEl", 3.0, "max. TOF n sigma for electron inclusion"}; - Configurable slope{"slope", 0.0185, "slope for m vs. phiv"}; - Configurable intercept{"intercept", -0.0380, "intercept for m vs. phiv"}; - Configurable max_mee_pi0{"max_mee_pi0", -1, "max mee to tag ee from pi0"}; // 0.04 GeV/c2 - Configurable downscaling_primary_electron{"downscaling_primary_electron", 0.1, "down scaling factor to store electron"}; - Configurable downscaling_secondary_electron{"downscaling_secondary_electron", 0.1, "down scaling factor to store electron"}; - - // for cascade - Configurable minv0cospa_casc{"minv0cospa_casc", 0.97, "minimum V0 CosPA in cascade"}; - Configurable maxdcav0dau_casc{"maxdcav0dau_casc", 0.2, "max distance between V0 Daughters in cascade"}; - Configurable min_casc_cospa{"min_casc_cospa", 0.99, "minimum cascade CosPA"}; - Configurable max_casc_dcadau{"max_casc_dcadau", 0.4, "max distance between bachelor and V0"}; - Configurable min_v0rxy_in_cascade{"min_v0rxy_in_cascade", 1.2, "minimum V0 rxy in cascade"}; - Configurable min_cascade_rxy{"min_cascade_rxy", 0.5, "minimum V0 rxy in cascade"}; - Configurable min_dcav0topv_casc{"min_dcav0topv_casc", 0.04, "min 3D dca from V0 in cascade to PV"}; - Configurable mindcaxytopv_v0leg_casc{"mindcaxytopv_v0leg_casc", -1, "max dcaxy to pv for v0 leg in cascade"}; // 0.03 cm - Configurable mindcaxytopv_bach_casc{"mindcaxytopv_bach_casc", -1, "max dcaxy to pv for bachelor in cascade"}; // 0.03 cm + Configurable d_bz_input{"d_bz_input", -999, "bz field, -999 is automatic"}; + Configurable useMatCorrType{"useMatCorrType", 2, "0: none, 1: TGeo, 2: LUT"}; + + Configurable downscaling_electron_highP{"downscaling_electron_highP", 1.1, "down scaling factor to store electron at high p"}; + Configurable downscaling_pion_highP{"downscaling_pion_highP", 1.1, "down scaling factor to store pion at high p"}; + Configurable downscaling_kaon_highP{"downscaling_kaon_highP", 1.1, "down scaling factor to store kaon at high p"}; + Configurable downscaling_proton_highP{"downscaling_proton_highP", 1.1, "down scaling factor to store proton at high p"}; + + Configurable downscaling_electron_lowP{"downscaling_electron_lowP", 0.01, "down scaling factor to store electron at low p"}; + Configurable downscaling_pion_lowP{"downscaling_pion_lowP", 0.01, "down scaling factor to store pion at low p"}; + Configurable downscaling_kaon_lowP{"downscaling_kaon_lowP", 1.1, "down scaling factor to store kaon at low p"}; + Configurable downscaling_proton_lowP{"downscaling_proton_lowP", 0.01, "down scaling factor to store proton at low p"}; + + Configurable max_p_for_downscaling_electron{"max_p_for_downscaling_electron", 2.0, "max p to apply down scaling factor to store electron"}; + Configurable max_p_for_downscaling_pion{"max_p_for_downscaling_pion", 2.0, "max p to apply down scaling factor to store pion"}; + Configurable max_p_for_downscaling_kaon{"max_p_for_downscaling_kaon", 0.0, "max p to apply down scaling factor to store kaon"}; + Configurable max_p_for_downscaling_proton{"max_p_for_downscaling_proton", 2.0, "max p to apply down scaling factor to store proton"}; + Configurable store_ele_band_only{"store_ele_band_only", false, "flag to store tracks around electron band only to reduce output size"}; + + struct : ConfigurableGroup { + std::string prefix = "eventcut_group"; + Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; + Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", true, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", true, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexTOFmatched{"cfgRequireVertexTOFmatched", false, "require Vertex TOFmatched in event cut"}; // ITS-TPC-TOF matched track contributes PV. + Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; + Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. track occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. track occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; + Configurable cfgRequireNoCollInTimeRangeStandard{"cfgRequireNoCollInTimeRangeStandard", false, "require no collision in time range standard"}; + Configurable cfgRequireNoCollInTimeRangeStrict{"cfgRequireNoCollInTimeRangeStrict", false, "require no collision in time range strict"}; + Configurable cfgRequirekNoCollInRofStandard{"cfgRequirekNoCollInRofStandard", false, "require no other collisions in this Readout Frame with per-collision multiplicity above threshold"}; + Configurable cfgRequirekNoCollInRofStrict{"cfgRequirekNoCollInRofStrict", false, "require no other collisions in this Readout Frame"}; + Configurable cfgRequirekNoHighMultCollInPrevRof{"cfgRequirekNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + Configurable cfgRequireGoodITSLayer3{"cfgRequireGoodITSLayer3", false, "number of inactive chips on ITS layer 3 are below threshold "}; + Configurable cfgRequireGoodITSLayer0123{"cfgRequireGoodITSLayer0123", false, "number of inactive chips on ITS layers 0-3 are below threshold "}; + Configurable cfgRequireGoodITSLayersAll{"cfgRequireGoodITSLayersAll", false, "number of inactive chips on all ITS layers are below threshold "}; + } eventcuts; + + struct : ConfigurableGroup { + std::string prefix = "trackcut_group"; + Configurable cfg_min_pt{"cfg_min_pt", 0.05, "min pt for v0 legs"}; + Configurable cfg_max_eta{"cfg_max_eta", 0.9, "max. eta for v0 legs"}; + Configurable cfg_min_cr2findable_ratio_tpc{"cfg_min_cr2findable_ratio_tpc", 0.8, "min. TPC Ncr/Nf ratio"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 0.7, "max fraction of shared clusters in TPC"}; + Configurable cfg_min_ncrossedrows_tpc{"cfg_min_ncrossedrows_tpc", 70, "min ncrossed rows"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 4, "min ncluster its"}; + Configurable cfg_min_ncluster_itsib{"cfg_min_ncluster_itsib", 1, "min ncluster itsib"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 5.0, "max chi2/NclsTPC"}; // comment + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1.0, "max dca XY in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.0, "max dca Z in cm"}; + } trackcuts; + + struct : ConfigurableGroup { + std::string prefix = "v0cut_group"; + Configurable cfg_min_pt{"cfg_min_pt", 0.05, "min pt for v0 legs"}; + Configurable cfg_max_eta{"cfg_max_eta", 0.9, "max. eta for v0 legs"}; + Configurable cfg_min_mass_photon{"cfg_min_mass_photon", 0.00, "min mass for photon conversion"}; + Configurable cfg_max_mass_photon{"cfg_max_mass_photon", 0.02, "max mass for photon conversion"}; + Configurable cfg_min_mass_k0s{"cfg_min_mass_k0s", 0.490, "min mass for K0S"}; + Configurable cfg_max_mass_k0s{"cfg_max_mass_k0s", 0.505, "max mass for K0S"}; + Configurable cfg_min_mass_lambda{"cfg_min_mass_lambda", 1.113, "min mass for Lambda"}; + Configurable cfg_max_mass_lambda{"cfg_max_mass_lambda", 1.118, "max mass for Lambda"}; + + Configurable cfg_min_mass_k0s_veto{"cfg_min_mass_k0s_veto", 0.47, "min mass for K0S veto"}; + Configurable cfg_max_mass_k0s_veto{"cfg_max_mass_k0s_veto", 0.52, "max mass for K0S veto"}; + Configurable cfg_min_mass_lambda_veto{"cfg_min_mass_lambda_veto", 1.105, "min mass for Lambda veto"}; + Configurable cfg_max_mass_lambda_veto{"cfg_max_mass_lambda_veto", 1.125, "max mass for Lambda veto"}; + + Configurable cfg_min_cospa{"cfg_min_cospa", 0.9998, "min cospa for v0"}; + Configurable cfg_max_dcadau{"cfg_max_dcadau", 0.1, "max distance between 2 legs for v0"}; + Configurable cfg_min_cr2findable_ratio_tpc{"cfg_min_cr2findable_ratio_tpc", 0.8, "min. TPC Ncr/Nf ratio"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 0.7, "max fraction of shared clusters in TPC"}; + Configurable cfg_min_ncrossedrows_tpc{"cfg_min_ncrossedrows_tpc", 70, "min ncrossed rows"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 2, "min ncluster its"}; + Configurable cfg_min_ncluster_itsib{"cfg_min_ncluster_itsib", 0, "min ncluster itsib"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 5.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + Configurable cfg_min_dcaxy_v0leg{"cfg_min_dcaxy_v0leg", 0.1, "min dca XY to PV for v0 legs in cm"}; + Configurable cfg_includeITSsa{"cfg_includeITSsa", false, "Flag to include ITSsa tracks"}; + Configurable cfg_max_pt_itssa{"cfg_max_pt_itssa", 0.15, "mix pt for ITSsa track"}; + Configurable cfg_min_qt_strangeness{"cfg_min_qt_strangeness", 0.015, "min qt for Lambda and K0S"}; + + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -5, "min n sigma e in TPC"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +5, "max n sigma e in TPC"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -5, "min n sigma pi in TPC"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +5, "max n sigma pi in TPC"}; + Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -5, "min n sigma ka in TPC"}; + Configurable cfg_max_TPCNsigmaKa{"cfg_max_TPCNsigmaKa", +5, "max n sigma ka in TPC"}; + Configurable cfg_min_TPCNsigmaPr{"cfg_min_TPCNsigmaPr", -5, "min n sigma pr in TPC"}; + Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +5, "max n sigma pr in TPC"}; + + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -5, "min n sigma e in TOF"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +5, "max n sigma e in TOF"}; + Configurable cfg_min_TOFNsigmaPi{"cfg_min_TOFNsigmaPi", -5, "min n sigma pi in TOF"}; + Configurable cfg_max_TOFNsigmaPi{"cfg_max_TOFNsigmaPi", +5, "max n sigma pi in TOF"}; + Configurable cfg_min_TOFNsigmaKa{"cfg_min_TOFNsigmaKa", -5, "min n sigma ka in TOF"}; + Configurable cfg_max_TOFNsigmaKa{"cfg_max_TOFNsigmaKa", +5, "max n sigma ka in TOF"}; + Configurable cfg_min_TOFNsigmaPr{"cfg_min_TOFNsigmaPr", -5, "min n sigma pr in TOF"}; + Configurable cfg_max_TOFNsigmaPr{"cfg_max_TOFNsigmaPr", +5, "max n sigma pr in TOF"}; + + Configurable cfg_min_TPCNsigmaEl_tight{"cfg_min_TPCNsigmaEl_tight", -2, "min n sigma e in TPC for pi0->eeg"}; + Configurable cfg_max_TPCNsigmaEl_tight{"cfg_max_TPCNsigmaEl_tight", +2, "max n sigma e in TPC for pi0->eeg"}; + Configurable cfg_min_TOFNsigmaEl_tight{"cfg_min_TOFNsigmaEl_tight", -2, "min n sigma e in TOF for pi0->eeg"}; + Configurable cfg_max_TOFNsigmaEl_tight{"cfg_max_TOFNsigmaEl_tight", +2, "max n sigma e in TOF for pi0->eeg"}; + + Configurable cfg_min_TPCNsigmaPi_tight{"cfg_min_TPCNsigmaPi_tight", -2, "min n sigma pi in TPC for Lambda and cascade"}; + Configurable cfg_max_TPCNsigmaPi_tight{"cfg_max_TPCNsigmaPi_tight", +2, "max n sigma pi in TPC for Lambda and cascade"}; + Configurable cfg_min_TPCNsigmaPr_tight{"cfg_min_TPCNsigmaPr_tight", -2, "min n sigma pr in TPC for cascade"}; + Configurable cfg_max_TPCNsigmaPr_tight{"cfg_max_TPCNsigmaPr_tight", +2, "max n sigma pr in TPC for cascade"}; + + Configurable cfg_min_TOFNsigmaPi_tight{"cfg_min_TOFNsigmaPi_tight", -2, "min n sigma pi in TOF for Lambda and cascade"}; + Configurable cfg_max_TOFNsigmaPi_tight{"cfg_max_TOFNsigmaPi_tight", +2, "max n sigma pi in TOF for Lambda and cascade"}; + Configurable cfg_min_TOFNsigmaPr_tight{"cfg_min_TOFNsigmaPr_tight", -2, "min n sigma pr in TOF for cascade"}; + Configurable cfg_max_TOFNsigmaPr_tight{"cfg_max_TOFNsigmaPr_tight", +2, "max n sigma pr in TOF for cascade"}; + } v0cuts; + + struct : ConfigurableGroup { + std::string prefix = "cascadecut_group"; + Configurable cfg_min_mass_lambda{"cfg_min_mass_lambda", 1.11, "min mass for lambda in cascade"}; + Configurable cfg_max_mass_lambda{"cfg_max_mass_lambda", 1.12, "max mass for lambda in cascade"}; + Configurable cfg_min_mass_Xi_veto{"cfg_min_mass_Xi_veto", 1.31, "min mass for Xi veto"}; + Configurable cfg_max_mass_Xi_veto{"cfg_max_mass_Xi_veto", 1.33, "max mass for Xi veto"}; + Configurable cfg_min_mass_Omega{"cfg_min_mass_Omega", 1.669, "min mass for Omega"}; + Configurable cfg_max_mass_Omega{"cfg_max_mass_Omega", 1.675, "max mass for Omega"}; + Configurable cfg_min_cospa_v0{"cfg_min_cospa_v0", 0.995, "minimum V0 CosPA in cascade"}; + Configurable cfg_max_dcadau_v0{"cfg_max_dcadau_v0", 0.1, "max distance between V0 Daughters in cascade"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.9998, "minimum cascade CosPA"}; + Configurable cfg_max_dcadau{"cfg_max_dcadau", 0.1, "max distance between bachelor and V0"}; + Configurable cfg_min_rxy_v0{"cfg_min_rxy_v0", 1.2, "minimum V0 rxy in cascade"}; + Configurable cfg_min_rxy{"cfg_min_rxy", 0.5, "minimum V0 rxy in cascade"}; + Configurable cfg_min_dcaxy_v0leg{"cfg_min_dcaxy_v0leg", 0.1, "min dca XY for v0 legs in cm"}; + Configurable cfg_min_dcaxy_bachelor{"cfg_min_dcaxy_bachelor", 0.1, "min dca XY for bachelor in cm"}; + } cascadecuts; + + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; int mRunNumber; float d_bz; - float maxSnp; // max sine phi for propagation - float maxStep; // max step size (cm) for propagation Service ccdb; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + o2::dataformats::VertexBase mVtx; + const o2::dataformats::MeanVertexObject* mMeanVtx = nullptr; o2::base::MatLayerCylSet* lut = nullptr; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - o2::vertexing::DCAFitterN<2> fitter; + o2::dataformats::DCA mDcaInfoCov; + o2::aod::rctsel::RCTFlagsChecker rctChecker; std::mt19937 engine; std::uniform_real_distribution dist01; @@ -218,14 +283,14 @@ struct TreeCreatorElectronMLDDA { { mRunNumber = 0; d_bz = 0; - maxSnp = 0.85f; // could be changed later - maxStep = 2.00f; // could be changed later ccdb->setURL(ccdburl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); + rctChecker.init(cfgRCTLabel.value, cfgCheckZDC.value, cfgTreatLimitedAcceptanceAsBad.value); + if (useMatCorrType == 1) { LOGF(info, "TGeo correction requested, loading geometry"); if (!o2::base::GeometryManager::isGeometryLoaded()) { @@ -237,22 +302,6 @@ struct TreeCreatorElectronMLDDA { lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); } - fitter.setPropagateToPCA(true); - fitter.setMaxR(200.); - fitter.setMinParamChange(1e-3); - fitter.setMinRelChi2Change(0.9); - fitter.setMaxDZIni(1e9); - fitter.setMaxChi2(1e9); - fitter.setUseAbsDCA(d_UseAbsDCA); - fitter.setWeightedFinalPCA(d_UseWeightedPCA); - - if (useMatCorrType == 1) { - matCorr = o2::base::Propagator::MatCorrType::USEMatCorrTGeo; - } else if (useMatCorrType == 2) { - matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; - } - fitter.setMatCorrType(matCorr); - std::random_device seed_gen; engine = std::mt19937(seed_gen()); dist01 = std::uniform_real_distribution(0.0f, 1.0f); @@ -264,15 +313,24 @@ struct TreeCreatorElectronMLDDA { return; } + // load matLUT for this timestamp + if (!lut) { + LOG(info) << "Loading material look-up table for timestamp: " << bc.timestamp(); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(lutPath, bc.timestamp())); + } else { + LOG(info) << "Material look-up table already in place. Not reloading."; + } + // In case override, don't proceed, please - no CCDB access required if (d_bz_input > -990) { d_bz = d_bz_input; - fitter.setBz(d_bz); o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } o2::base::Propagator::initFieldFromGRP(&grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); mRunNumber = bc.runNumber(); return; } @@ -284,6 +342,8 @@ struct TreeCreatorElectronMLDDA { grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); if (grpo) { o2::base::Propagator::initFieldFromGRP(grpo); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); // Fetch magnetic field from ccdb for current collision d_bz = grpo->getNominalL3Field(); LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; @@ -293,751 +353,599 @@ struct TreeCreatorElectronMLDDA { LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; } o2::base::Propagator::initFieldFromGRP(grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); // Fetch magnetic field from ccdb for current collision d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; } mRunNumber = bc.runNumber(); - // Set magnetic field value once known - fitter.setBz(d_bz); - - if (useMatCorrType == 2) { - // setMatLUT only after magfield has been initalized (setMatLUT has implicit and problematic init field call if not) - o2::base::Propagator::Instance()->setMatLUT(lut); - } } - float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) + template + float meanClusterSizeITS(TTrack const& track) { - return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz)); - } - - EM_V0_Label checkV0(const float alpha, const float qt) - { - // Gamma cuts - const float cutAlphaG = 0.95; - const float cutQTG = 0.01; - - // K0S cuts - const float cutQTK0S[2] = {0.1075, 0.215}; - const float cutAPK0S[2] = {0.199, 0.8}; // parameters for curved QT cut - - // Lambda & A-Lambda cuts - const float cutQTL = 0.03; - const float cutAlphaL[2] = {0.35, 0.7}; - const float cutAlphaAL[2] = {-0.7, -0.35}; - const float cutAPL[3] = {0.107, -0.69, 0.5}; // parameters for curved QT cut - - // Check for Gamma candidates - if (std::pow(alpha / cutAlphaG, 2) + std::pow(qt / cutQTG, 2) < std::pow(1.f, 2)) { - return EM_V0_Label::kGamma; - } - - // Check for K0S candidates - float q = cutAPK0S[0] * sqrt(abs(1 - alpha * alpha / (cutAPK0S[1] * cutAPK0S[1]))); - if ((qt > cutQTK0S[0]) && (qt < cutQTK0S[1]) && (qt > q)) { - return EM_V0_Label::kK0S; - } - - // Check for Lambda candidates - q = cutAPL[0] * sqrt(abs(1 - ((alpha + cutAPL[1]) * (alpha + cutAPL[1])) / (cutAPL[2] * cutAPL[2]))); - if ((alpha > cutAlphaL[0]) && (alpha < cutAlphaL[1]) && (qt > cutQTL) && (qt < q)) { - return EM_V0_Label::kLambda; + int total_size = 0; + int nl = 0; + for (int il = il0; il < il1; il++) { + if (track.itsClsSizeInLayer(il) > 0) { + total_size += track.itsClsSizeInLayer(il); + nl++; + } } - - // Check for AntiLambda candidates - q = cutAPL[0] * sqrt(abs(1 - ((alpha - cutAPL[1]) * (alpha - cutAPL[1])) / (cutAPL[2] * cutAPL[2]))); - if ((alpha > cutAlphaAL[0]) && (alpha < cutAlphaAL[1]) && (qt > cutQTL) && (qt < q)) { - return EM_V0_Label::kAntiLambda; + if (nl > 0) { + return static_cast(total_size) / static_cast(nl); + } else { + return 0.f; } - - return EM_V0_Label::kUndef; } - template - bool IsSelected(TTrack const& track) + template + bool isSelectedTrack(TCollision const& collision, TTrack const& track) { - if (abs(track.eta()) > maxeta || track.pt() < minpt) { + if (!track.hasITS()) { return false; } - if (!track.hasITS() || !track.hasTPC()) { + if (track.itsNCls() < trackcuts.cfg_min_ncluster_its) { return false; } - - if (track.itsNClsInnerBarrel() < minitsibncls) { + if (track.itsNClsInnerBarrel() < trackcuts.cfg_min_ncluster_itsib) { return false; } - if (track.itsNCls() < minitsncls) { + if (track.itsChi2NCl() > trackcuts.cfg_max_chi2its) { return false; } - if (track.itsChi2NCl() > maxchi2its) { + + if (!v0cuts.cfg_includeITSsa && (!track.hasITS() || !track.hasTPC())) { return false; } - if (track.tpcNClsCrossedRows() < mincrossedrows) { + if (track.hasTPC()) { + if (track.tpcNClsCrossedRows() < trackcuts.cfg_min_ncrossedrows_tpc) { + return false; + } + if (track.tpcNClsFound() < trackcuts.cfg_min_ncluster_tpc) { + return false; + } + if (track.tpcChi2NCl() > trackcuts.cfg_max_chi2tpc) { + return false; + } + if (track.tpcCrossedRowsOverFindableCls() < trackcuts.cfg_min_cr2findable_ratio_tpc) { + return false; + } + if (track.tpcFractionSharedCls() > trackcuts.cfg_max_frac_shared_clusters_tpc) { + return false; + } + } + + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(track.pidForTracking()); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + if (std::fabs(dcaXY) > trackcuts.cfg_max_dcaxy) { return false; } - if (track.tpcChi2NCl() > maxchi2tpc) { + if (std::fabs(dcaZ) > trackcuts.cfg_max_dcaz) { return false; } - if (track.tpcCrossedRowsOverFindableCls() < 0.8) { + + if (std::fabs(trackParCov.getEta()) > trackcuts.cfg_max_eta || trackParCov.getPt() < trackcuts.cfg_min_pt) { return false; } + if ((track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF()) && v0cuts.cfg_max_pt_itssa < trackParCov.getPt()) { + return true; + } + return true; } - template - bool IsSelectedTag(TTrack const& track) + template + bool isSelectedV0Leg(TCollision const& collision, TTrack const& track) { - if (abs(track.eta()) > maxeta || track.pt() < minpt) { + if (!track.hasITS()) { return false; } - if (!track.hasITS() || !track.hasTPC()) { + if (track.itsNCls() < v0cuts.cfg_min_ncluster_its) { return false; } - - if (abs(track.dcaXY()) > 0.1 || abs(track.dcaZ()) > 0.1) { + if (track.itsNClsInnerBarrel() < v0cuts.cfg_min_ncluster_itsib) { return false; } - - if (track.itsNCls() < 5) { + if (track.itsChi2NCl() > v0cuts.cfg_max_chi2its) { return false; } - if (track.itsChi2NCl() > 5.f) { + + if (!v0cuts.cfg_includeITSsa && (!track.hasITS() || !track.hasTPC())) { return false; } - if (track.tpcNClsCrossedRows() < 100) { - return false; + if (track.hasTPC()) { + if (track.tpcNClsCrossedRows() < v0cuts.cfg_min_ncrossedrows_tpc) { + return false; + } + if (track.tpcNClsFound() < v0cuts.cfg_min_ncluster_tpc) { + return false; + } + if (track.tpcChi2NCl() > v0cuts.cfg_max_chi2tpc) { + return false; + } + if (track.tpcCrossedRowsOverFindableCls() < v0cuts.cfg_min_cr2findable_ratio_tpc) { + return false; + } + if (track.tpcFractionSharedCls() > v0cuts.cfg_max_frac_shared_clusters_tpc) { + return false; + } } - if (track.tpcChi2NCl() > 4.f) { + + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(track.pidForTracking()); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + // float dcaZ = mDcaInfoCov.getZ(); + + if (std::fabs(dcaXY) < v0cuts.cfg_min_dcaxy_v0leg) { // this is applied in filter. return false; } - if (track.tpcCrossedRowsOverFindableCls() < 0.8) { + + if (std::fabs(trackParCov.getEta()) > v0cuts.cfg_max_eta || trackParCov.getPt() < v0cuts.cfg_min_pt) { return false; } + + if ((track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF()) && v0cuts.cfg_max_pt_itssa < track.pt()) { + return true; + } + return true; } template - bool IsElectron(TTrack const& track) + bool isElectron(TTrack const& track) { - return (minTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < maxTPCNsigmaEl) && (abs(track.tofNSigmaEl()) < maxTOFNsigmaEl || track.beta() < 0.f); + if (v0cuts.cfg_includeITSsa && (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF())) { + return true; + } + bool is_El_TPC = v0cuts.cfg_min_TPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < v0cuts.cfg_max_TPCNsigmaEl; + bool is_El_TOF = track.hasTOF() ? v0cuts.cfg_min_TOFNsigmaEl < track.tofNSigmaEl() && track.tofNSigmaEl() < v0cuts.cfg_max_TOFNsigmaEl : true; // TOFif + return is_El_TPC && is_El_TOF; } template - bool IsElectronTag(TTrack const& track) + bool isPion(TTrack const& track) { - if (minTPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < maxTPCNsigmaPi) { - return false; // reject pion first + if (v0cuts.cfg_includeITSsa && (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF())) { + return true; } - if (track.p() < 0.4) { - return abs(track.tpcNSigmaEl()) < 2.f; - } else { - return abs(track.tpcNSigmaEl()) < 2.f && abs(track.tofNSigmaEl()) < 2.f; + bool is_Pi_TPC = v0cuts.cfg_min_TPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < v0cuts.cfg_max_TPCNsigmaPi; + bool is_Pi_TOF = track.hasTOF() ? v0cuts.cfg_min_TOFNsigmaPi < track.tofNSigmaPi() && track.tofNSigmaPi() < v0cuts.cfg_max_TOFNsigmaPi : true; // TOFif + return is_Pi_TPC && is_Pi_TOF; + } + + template + bool isKaon(TTrack const& track) + { + if (v0cuts.cfg_includeITSsa && (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF())) { + return true; } + bool is_Ka_TPC = v0cuts.cfg_min_TPCNsigmaKa < track.tpcNSigmaKa() && track.tpcNSigmaKa() < v0cuts.cfg_max_TPCNsigmaKa; + bool is_Ka_TOF = track.hasTOF() ? v0cuts.cfg_min_TOFNsigmaKa < track.tofNSigmaKa() && track.tofNSigmaKa() < v0cuts.cfg_max_TOFNsigmaKa : true; // TOFif + return is_Ka_TPC && is_Ka_TOF; } template - bool IsPion(TTrack const& track) + bool isProton(TTrack const& track) { - return abs(track.tpcNSigmaPi()) < maxTPCNsigmaPi && (abs(track.tofNSigmaPi()) < maxTOFNsigmaPi || track.beta() < 0.f); + if (v0cuts.cfg_includeITSsa && (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF())) { + return true; + } + bool is_Pr_TPC = v0cuts.cfg_min_TPCNsigmaPr < track.tpcNSigmaPr() && track.tpcNSigmaPr() < v0cuts.cfg_max_TPCNsigmaPr; + bool is_Pr_TOF = track.hasTOF() ? v0cuts.cfg_min_TOFNsigmaPr < track.tofNSigmaPr() && track.tofNSigmaPr() < v0cuts.cfg_max_TOFNsigmaPr : true; // TOFif + return is_Pr_TPC && is_Pr_TOF; } template - bool IsKaon(TTrack const& track) + bool isElectronTight(TTrack const& track) { - return abs(track.tpcNSigmaKa()) < maxTPCNsigmaKa && (abs(track.tofNSigmaKa()) < maxTOFNsigmaKa || track.beta() < 0.f); + bool is_El_TPC = v0cuts.cfg_min_TPCNsigmaEl_tight < track.tpcNSigmaEl() && track.tpcNSigmaEl() < v0cuts.cfg_max_TPCNsigmaEl_tight; + bool is_El_TOF = track.hasTOF() ? v0cuts.cfg_min_TOFNsigmaEl_tight < track.tofNSigmaEl() && track.tofNSigmaEl() < v0cuts.cfg_max_TOFNsigmaEl_tight : true; // TOFif + return is_El_TPC && is_El_TOF; } template - bool IsProton(TTrack const& track) + bool isPionTight(TTrack const& track) { - return abs(track.tpcNSigmaPr()) < maxTPCNsigmaPr && (abs(track.tofNSigmaPr()) < maxTOFNsigmaPr || track.beta() < 0.f); + bool is_Pi_TPC = v0cuts.cfg_min_TPCNsigmaPi_tight < track.tpcNSigmaPi() && track.tpcNSigmaPi() < v0cuts.cfg_max_TPCNsigmaPi_tight; + bool is_Pi_TOF = track.hasTOF() ? v0cuts.cfg_min_TOFNsigmaPi_tight < track.tofNSigmaPi() && track.tofNSigmaPi() < v0cuts.cfg_max_TOFNsigmaPi_tight : true; // TOFif + return is_Pi_TPC && is_Pi_TOF; + } + + template + bool isProtonTight(TTrack const& track) + { + bool is_Pr_TPC = v0cuts.cfg_min_TPCNsigmaPr_tight < track.tpcNSigmaPr() && track.tpcNSigmaPr() < v0cuts.cfg_max_TPCNsigmaPr_tight; + bool is_Pr_TOF = track.hasTOF() ? v0cuts.cfg_min_TOFNsigmaPr_tight < track.tofNSigmaPr() && track.tofNSigmaPr() < v0cuts.cfg_max_TOFNsigmaPr_tight : true; // TOFif + return is_Pr_TPC && is_Pr_TOF; } template - void fillTrackTable(TCollision const& collision, TTrack const& track, const int pidlabel, const int tracktype) + void fillTrackTable(TCollision const& collision, TTrack const& track, const uint8_t pidlabel) { + if (store_ele_band_only && !isElectron(track)) { + return; + } + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + // trackParCov.setPID(track.pidForTracking()); + trackParCov.setPID(o2::track::PID::Electron); // This is for eID in the end! + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + // float dcaXY = mDcaInfoCov.getY(); + // float dcaZ = mDcaInfoCov.getZ(); + + if (pidlabel == static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kElectron)) { + if (trackParCov.getP() < max_p_for_downscaling_electron) { + if (dist01(engine) > downscaling_electron_lowP) { + return; + } + } else { + if (dist01(engine) > downscaling_electron_highP) { + return; + } + } + } else if (pidlabel == static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kPion)) { + if (trackParCov.getP() < max_p_for_downscaling_pion) { + if (dist01(engine) > downscaling_pion_lowP) { + return; + } + } else { + if (dist01(engine) > downscaling_pion_highP) { + return; + } + } + } else if (pidlabel == static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kKaon)) { + if (trackParCov.getP() < max_p_for_downscaling_kaon) { + if (dist01(engine) > downscaling_kaon_lowP) { + return; + } + } else { + if (dist01(engine) > downscaling_kaon_highP) { + return; + } + } + } else if (pidlabel == static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kProton)) { + if (trackParCov.getP() < max_p_for_downscaling_proton) { + if (dist01(engine) > downscaling_proton_lowP) { + return; + } + } else { + if (dist01(engine) > downscaling_proton_highP) { + return; + } + } + } + if (std::find(stored_trackIds.begin(), stored_trackIds.end(), track.globalIndex()) == stored_trackIds.end()) { - emprimarytracks(collision.globalIndex(), collision.posZ(), collision.numContrib(), - track.pt(), track.eta(), track.phi(), track.tgl(), track.signed1Pt(), - track.dcaXY(), track.dcaZ(), track.cYY(), track.cZZ(), track.cZY(), + emprimarytracks(collision.numContrib(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange(), + trackParCov.getP(), trackParCov.getTgl(), track.sign(), track.tpcNClsFindable(), track.tpcNClsFound(), track.tpcNClsCrossedRows(), track.tpcChi2NCl(), track.tpcInnerParam(), - track.tpcSignal(), track.tpcNSigmaEl(), track.tpcNSigmaMu(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), - track.beta(), track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), - track.itsClusterSizes(), track.itsChi2NCl(), track.tofChi2(), track.detectorMap(), pidlabel, tracktype); + track.tpcSignal(), track.tpcNSigmaEl(), /*track.tpcNSigmaMu(),*/ track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), + track.beta(), track.tofNSigmaEl(), /*track.tofNSigmaMu(),*/ track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), + track.itsClusterSizes(), track.itsChi2NCl(), track.tofChi2(), track.detectorMap(), pidlabel); stored_trackIds.emplace_back(track.globalIndex()); } } - Filter collisionFilter_common = nabs(o2::aod::collision::posZ) < 10.f && o2::aod::collision::numContrib > (uint16_t)0 && o2::aod::evsel::sel8 == true; + template + bool isSelectedEvent(TCollision const& collision) + { + if (eventcuts.cfgRequireSel8 && !collision.sel8()) { + return false; + } + + if (collision.posZ() < eventcuts.cfgZvtxMin || eventcuts.cfgZvtxMax < collision.posZ()) { + return false; + } + + if (eventcuts.cfgRequireFT0AND && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + return false; + } + + if (eventcuts.cfgRequireNoTFB && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + + if (eventcuts.cfgRequireNoITSROFB && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + + if (eventcuts.cfgRequireVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + + if (eventcuts.cfgRequireVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + return false; + } + + if (eventcuts.cfgRequireNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + + if (eventcuts.cfgRequireGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + + if (eventcuts.cfgRequireNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + + if (eventcuts.cfgRequireNoCollInTimeRangeStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + return false; + } + + if (eventcuts.cfgRequirekNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + + if (eventcuts.cfgRequirekNoCollInRofStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; + } + + if (eventcuts.cfgRequirekNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return false; + } + + if (eventcuts.cfgRequireGoodITSLayer3 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { + return false; + } + + if (eventcuts.cfgRequireGoodITSLayer0123 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + return false; + } + + if (eventcuts.cfgRequireGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return false; + } + + if (!(eventcuts.cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { + return false; + } + + if (!(eventcuts.cfgFT0COccupancyMin <= collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) { + return false; + } + + return true; + } + + //! type of V0. 0: built solely for cascades (does not pass standard V0 cuts), 1: standard 2, 3: photon-like with TPC-only use. Regular analysis should always use type 1. + Filter v0Filter = o2::aod::v0data::v0Type == uint8_t(1) && o2::aod::v0data::v0cosPA > v0cuts.cfg_min_cospa&& o2::aod::v0data::dcaV0daughters v0cuts.cfg_min_dcaxy_v0leg&& nabs(o2::aod::v0data::dcanegtopv) > v0cuts.cfg_min_dcaxy_v0leg; + using filteredV0s = soa::Filtered; + + Filter cascadeFilter = o2::aod::cascdata::dcacascdaughters < cascadecuts.cfg_max_dcadau && nabs(o2::aod::cascdata::dcanegtopv) > cascadecuts.cfg_min_dcaxy_v0leg&& nabs(o2::aod::cascdata::dcanegtopv) > cascadecuts.cfg_min_dcaxy_v0leg&& nabs(o2::aod::cascdata::dcabachtopv) > cascadecuts.cfg_min_dcaxy_bachelor; + using filteredCascades = soa::Filtered; + + Filter collisionFilter_track_occupancy = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; + Filter collisionFilter_ft0c_occupancy = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_common = nabs(o2::aod::collision::posZ) < 10.f && o2::aod::evsel::sel8 == true; using filteredMyCollisions = soa::Filtered; - //! type of V0. 0: built solely for cascades (does not pass standard V0 cuts), 1: standard 2, 3: photon-like with TPC-only use. Regular analysis should always use type 1 or 3. - Preslice perCollision_v0 = o2::aod::v0::collisionId; - Preslice perCollision_cascade = o2::aod::cascade::collisionId; + Preslice perCollision_v0 = o2::aod::v0data::collisionId; + Preslice perCollision_cascade = o2::aod::cascdata::collisionId; Preslice perCollision_track = o2::aod::track::collisionId; - // Don't apply filter to tracks, because posTrack_as<>, negTrack_as<> is used. - Partition posTracks = o2::aod::track::signed1Pt > 0.f && o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::tpcChi2NCl < maxchi2tpc&& o2::aod::track::itsChi2NCl < maxchi2its&& nabs(o2::aod::track::dcaXY) < maxdcaXY&& nabs(o2::aod::track::dcaZ) < maxdcaZ&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true && (minTPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < maxTPCNsigmaEl); - Partition negTracks = o2::aod::track::signed1Pt < 0.f && o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::tpcChi2NCl < maxchi2tpc&& o2::aod::track::itsChi2NCl < maxchi2its&& nabs(o2::aod::track::dcaXY) < maxdcaXY&& nabs(o2::aod::track::dcaZ) < maxdcaZ&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true && (minTPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < maxTPCNsigmaEl); + Partition posTracks = o2::aod::track::signed1Pt > 0.f && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true; + Partition negTracks = o2::aod::track::signed1Pt < 0.f && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true; std::vector stored_trackIds; - void processPID(filteredMyCollisions const& collisions, aod::BCsWithTimestamps const&, aod::V0s const& v0s, aod::Cascades const& cascades, MyTracks const& tracks) + void processPID(filteredMyCollisions const& collisions, aod::BCsWithTimestamps const&, filteredV0s const& v0s, filteredCascades const& cascades, MyTracks const& tracks) { stored_trackIds.reserve(tracks.size()); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { registry.fill(HIST("hEventCounter"), 1.0); // all - auto bc = collision.template bc_as(); + auto bc = collision.template foundBC_as(); initCCDB(bc); - if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + if (!isSelectedEvent(collision)) { + continue; + } + + if (cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { continue; } + registry.fill(HIST("hEventCounter"), 2.0); // selected - std::array pVtx = {collision.posX(), collision.posY(), collision.posZ()}; auto v0s_coll = v0s.sliceBy(perCollision_v0, collision.globalIndex()); - for (auto& v0 : v0s_coll) { - if (v0.v0Type() != 1) { - continue; - } + for (const auto& v0 : v0s_coll) { auto pos = v0.template posTrack_as(); auto neg = v0.template negTrack_as(); - if (!IsSelected(pos) || !IsSelected(neg)) { - continue; - } - if (pos.sign() * neg.sign() > 0) { - continue; - } + // LOGF(info, "v0.globalIndex() = %d, v0.collisionId() = %d, v0.posTrackId() = %d, v0.negTrackId() = %d", v0.globalIndex(), v0.collisionId(), v0.posTrackId(), v0.negTrackId()); + // LOGF(info, "is pos ITSsa = %d", pos.hasITS() && !pos.hasTPC() && !pos.hasTRD() && !pos.hasTOF()); + // LOGF(info, "is neg ITSsa = %d", neg.hasITS() && !neg.hasTPC() && !neg.hasTRD() && !neg.hasTOF()); - // Calculate DCA with respect to the collision associated to the V0, not individual tracks - gpu::gpustd::array dcaInfo_pos; - auto pTrackPar = getTrackPar(pos); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, pTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo_pos); - if (abs(dcaInfo_pos[0]) < mindcaxytopv_v0leg) { + if (v0.dcaV0daughters() > v0cuts.cfg_max_dcadau) { continue; } - - gpu::gpustd::array dcaInfo_neg; - auto nTrackPar = getTrackPar(neg); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, nTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo_neg); - if (abs(dcaInfo_neg[0]) < mindcaxytopv_v0leg) { + if (v0.v0cosPA() < v0cuts.cfg_min_cospa) { continue; } - - // reconstruct V0s - auto pTrack = getTrackParCov(pos); // positive - auto nTrack = getTrackParCov(neg); // negative - std::array svpos = {0.}; // secondary vertex position - std::array pvec0 = {0.}; - std::array pvec1 = {0.}; - - int nCand = fitter.process(pTrack, nTrack); - if (nCand != 0) { - fitter.propagateTracksToVertex(); - const auto& vtx = fitter.getPCACandidate(); - for (int i = 0; i < 3; i++) { - svpos[i] = vtx[i]; - } - fitter.getTrack(0).getPxPyPzGlo(pvec0); // positive - fitter.getTrack(1).getPxPyPzGlo(pvec1); // negative - } else { - continue; - } - std::array pvxyz{pvec0[0] + pvec1[0], pvec0[1] + pvec1[1], pvec0[2] + pvec1[2]}; - - float v0dca = std::sqrt(fitter.getChi2AtPCACandidate()); // distance between 2 legs. - float v0CosinePA = RecoDecay::cpa(pVtx, svpos, pvxyz); - registry.fill(HIST("hPCA"), v0dca); - registry.fill(HIST("hCosPA"), v0CosinePA); - - if (v0dca > maxdcav0dau) { + if (pos.sign() * neg.sign() > 0) { continue; } - if (v0CosinePA < minv0cospa) { + if (!isSelectedV0Leg(collision, pos) || !isSelectedV0Leg(collision, neg)) { continue; } - float alpha = v0_alpha(pvec0[0], pvec0[1], pvec0[2], pvec1[0], pvec1[1], pvec1[2]); - float qt = v0_qt(pvec0[0], pvec0[1], pvec0[2], pvec1[0], pvec1[1], pvec1[2]); - registry.fill(HIST("hAP"), alpha, qt); - - float mGamma = RecoDecay::m(std::array{std::array{pvec0[0], pvec0[1], pvec0[2]}, std::array{pvec1[0], pvec1[1], pvec1[2]}}, std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassElectron}); - float mK0Short = RecoDecay::m(std::array{std::array{pvec0[0], pvec0[1], pvec0[2]}, std::array{pvec1[0], pvec1[1], pvec1[2]}}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged}); - float mLambda = RecoDecay::m(std::array{std::array{pvec0[0], pvec0[1], pvec0[2]}, std::array{pvec1[0], pvec1[1], pvec1[2]}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); - float mAntiLambda = RecoDecay::m(std::array{std::array{pvec0[0], pvec0[1], pvec0[2]}, std::array{pvec1[0], pvec1[1], pvec1[2]}}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton}); - - EM_V0_Label v0id = checkV0(alpha, qt); - if (v0id == EM_V0_Label::kGamma && (IsElectron(pos) && IsElectron(neg))) { - registry.fill(HIST("hMassGamma"), mGamma); - registry.fill(HIST("hXY_Gamma"), svpos[0], svpos[1]); - float rxy = std::sqrt(std::pow(svpos[0], 2) + std::pow(svpos[1], 2)); - registry.fill(HIST("hMassGamma_Rxy"), rxy, mGamma); - if (mGamma < max_mee_pcm && rxy < 38.f) { - if (dist01(engine) < downscaling_electron) { - fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); + registry.fill(HIST("V0/hPCA"), v0.dcaV0daughters()); + registry.fill(HIST("V0/hCosPA"), v0.v0cosPA()); + registry.fill(HIST("V0/hAP"), v0.alpha(), v0.qtarm()); + + if (v0cuts.cfg_min_qt_strangeness < v0.qtarm()) { + if (!(v0cuts.cfg_min_mass_lambda_veto < v0.mLambda() && v0.mLambda() < v0cuts.cfg_max_mass_lambda_veto) && !(v0cuts.cfg_min_mass_lambda_veto < v0.mAntiLambda() && v0.mAntiLambda() < v0cuts.cfg_max_mass_lambda_veto)) { + if (isPionTight(pos) && isPion(neg)) { + registry.fill(HIST("V0/hMassK0Short"), v0.mK0Short()); + if (v0cuts.cfg_min_mass_k0s < v0.mK0Short() && v0.mK0Short() < v0cuts.cfg_max_mass_k0s) { + registry.fill(HIST("V0/hTPCdEdx_P_Pi"), neg.tpcInnerParam(), neg.tpcSignal()); + registry.fill(HIST("V0/hTOFbeta_P_Pi"), neg.tpcInnerParam(), neg.beta()); + fillTrackTable(collision, neg, static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kPion)); + } } - if (dist01(engine) < downscaling_electron) { - fillTrackTable(collision, neg, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); + if (isPion(pos) && isPionTight(neg)) { + registry.fill(HIST("V0/hMassK0Short"), v0.mK0Short()); + if (v0cuts.cfg_min_mass_k0s < v0.mK0Short() && v0.mK0Short() < v0cuts.cfg_max_mass_k0s) { + registry.fill(HIST("V0/hTPCdEdx_P_Pi"), pos.tpcInnerParam(), pos.tpcSignal()); + registry.fill(HIST("V0/hTOFbeta_P_Pi"), pos.tpcInnerParam(), pos.beta()); + fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kPion)); + } } - registry.fill(HIST("hTPCdEdx_P_El"), neg.p(), neg.tpcSignal()); - registry.fill(HIST("hTOFbeta_P_El"), neg.p(), neg.beta()); - registry.fill(HIST("hTPCdEdx_P_El"), pos.p(), pos.tpcSignal()); - registry.fill(HIST("hTOFbeta_P_El"), pos.p(), pos.beta()); } - } else if (v0id == EM_V0_Label::kK0S && (IsPion(pos) && IsPion(neg))) { - registry.fill(HIST("hMassK0Short"), mK0Short); - if (abs(mK0Short - 0.497) < 0.01) { - registry.fill(HIST("hTPCdEdx_P_Pi"), neg.p(), neg.tpcSignal()); - registry.fill(HIST("hTOFbeta_P_Pi"), neg.p(), neg.beta()); - registry.fill(HIST("hTPCdEdx_P_Pi"), pos.p(), pos.tpcSignal()); - registry.fill(HIST("hTOFbeta_P_Pi"), pos.p(), pos.beta()); - if (dist01(engine) < downscaling_pion) { - fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::PID_Label::kPion), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); - } - if (dist01(engine) < downscaling_pion) { - fillTrackTable(collision, neg, static_cast(o2::aod::pwgem::dilepton::PID_Label::kPion), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); - } - } - } else if (v0id == EM_V0_Label::kLambda && (IsProton(pos) && IsPion(neg))) { - registry.fill(HIST("hMassLambda"), mLambda); - if (abs(mLambda - 1.115) < 0.005) { - if (dist01(engine) < downscaling_proton) { - fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::PID_Label::kProton), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); + + if (!(v0cuts.cfg_min_mass_k0s_veto < v0.mK0Short() && v0.mK0Short() < v0cuts.cfg_max_mass_k0s_veto)) { + if (isProton(pos) && isPionTight(neg)) { + registry.fill(HIST("V0/hMassLambda"), v0.mLambda()); + if (v0cuts.cfg_min_mass_lambda < v0.mLambda() && v0.mLambda() < v0cuts.cfg_max_mass_lambda) { + fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kProton)); + registry.fill(HIST("V0/hTPCdEdx_P_Pr"), pos.tpcInnerParam(), pos.tpcSignal()); + registry.fill(HIST("V0/hTOFbeta_P_Pr"), pos.tpcInnerParam(), pos.beta()); + } } - registry.fill(HIST("hTPCdEdx_P_Pr"), pos.p(), pos.tpcSignal()); - registry.fill(HIST("hTOFbeta_P_Pr"), pos.p(), pos.beta()); - registry.fill(HIST("hTPCdEdx_P_Pi"), neg.p(), neg.tpcSignal()); - registry.fill(HIST("hTOFbeta_P_Pi"), neg.p(), neg.beta()); - if (dist01(engine) < downscaling_pion) { - fillTrackTable(collision, neg, static_cast(o2::aod::pwgem::dilepton::PID_Label::kPion), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); + if (isPionTight(pos) && isProton(neg)) { + registry.fill(HIST("V0/hMassAntiLambda"), v0.mAntiLambda()); + if (v0cuts.cfg_min_mass_lambda < v0.mAntiLambda() && v0.mAntiLambda() < v0cuts.cfg_max_mass_lambda) { + fillTrackTable(collision, neg, static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kProton)); + registry.fill(HIST("V0/hTPCdEdx_P_Pr"), neg.tpcInnerParam(), neg.tpcSignal()); + registry.fill(HIST("V0/hTOFbeta_P_Pr"), neg.tpcInnerParam(), neg.beta()); + } } } - } else if (v0id == EM_V0_Label::kAntiLambda && (IsPion(pos) && IsProton(neg))) { - registry.fill(HIST("hMassAntiLambda"), mAntiLambda); - if (abs(mAntiLambda - 1.115) < 0.005) { - if (dist01(engine) < downscaling_pion) { - fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::PID_Label::kPion), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); - } - if (dist01(engine) < downscaling_proton) { - fillTrackTable(collision, neg, static_cast(o2::aod::pwgem::dilepton::PID_Label::kProton), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); - } - registry.fill(HIST("hTPCdEdx_P_Pr"), neg.p(), neg.tpcSignal()); - registry.fill(HIST("hTOFbeta_P_Pr"), neg.p(), neg.beta()); - registry.fill(HIST("hTPCdEdx_P_Pi"), pos.p(), pos.tpcSignal()); - registry.fill(HIST("hTOFbeta_P_Pi"), pos.p(), pos.beta()); + } // end of stangeness + + if (isElectronTight(pos) && isElectron(neg)) { + registry.fill(HIST("V0/hMassGamma"), v0.mGamma()); + registry.fill(HIST("V0/hMassGamma_Rxy"), v0.v0radius(), v0.mGamma()); + if (v0cuts.cfg_min_mass_photon < v0.mGamma() && v0.mGamma() < v0cuts.cfg_max_mass_photon) { + registry.fill(HIST("V0/hXY_Gamma"), v0.x(), v0.y()); + fillTrackTable(collision, neg, static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kElectron)); + registry.fill(HIST("V0/hTPCdEdx_P_El"), neg.tpcInnerParam(), neg.tpcSignal()); + registry.fill(HIST("V0/hTOFbeta_P_El"), neg.tpcInnerParam(), neg.beta()); } } - } // end of v0 loop - - // extra statistics for electrons tagged by photon conversions - auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { - if (!IsSelected(pos) || !IsSelected(ele)) { - continue; - } - - if (!IsElectron(pos) || !IsElectron(ele)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(ele.pt(), ele.eta(), ele.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - registry.fill(HIST("hMvsPhiV"), phiv, v12.M()); - if (v12.M() < slope * phiv + intercept) { // photon conversion is found. - if (dist01(engine) < downscaling_electron) { - fillTrackTable(collision, ele, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kPrimary)); // secondary in primary electron candidates - } - if (dist01(engine) < downscaling_electron) { - fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kPrimary)); // secondary in primary electron candidates + if (isElectron(pos) && isElectronTight(neg)) { + registry.fill(HIST("V0/hMassGamma"), v0.mGamma()); + registry.fill(HIST("V0/hMassGamma_Rxy"), v0.v0radius(), v0.mGamma()); + if (v0cuts.cfg_min_mass_photon < v0.mGamma() && v0.mGamma() < v0cuts.cfg_max_mass_photon) { + registry.fill(HIST("V0/hXY_Gamma"), v0.x(), v0.y()); + fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kElectron)); + registry.fill(HIST("V0/hTPCdEdx_P_El"), pos.tpcInnerParam(), pos.tpcSignal()); + registry.fill(HIST("V0/hTOFbeta_P_El"), pos.tpcInnerParam(), pos.beta()); } } - if (v12.M() < max_mee_pi0) { // dielectron from pi0 is found. - if (dist01(engine) < downscaling_electron) { - fillTrackTable(collision, ele, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kPrimary)); - } - if (dist01(engine) < downscaling_electron) { - fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kPrimary)); - } - } - } // end of ULS pair loop - - auto tracks_coll = tracks.sliceBy(perCollision_track, collision.globalIndex()); - for (auto& track : tracks_coll) { - if (!IsSelectedTag(track)) { - continue; - } - registry.fill(HIST("hTPCdEdx_P"), track.p(), track.tpcSignal()); - registry.fill(HIST("hTOFbeta_P"), track.p(), track.beta()); - registry.fill(HIST("hTPCNsigmaEl_P"), track.p(), track.tpcNSigmaEl()); - registry.fill(HIST("hTOFNsigmaEl_P"), track.p(), track.tofNSigmaEl()); - registry.fill(HIST("hTPCNsigmaMu_P"), track.p(), track.tpcNSigmaMu()); - registry.fill(HIST("hTOFNsigmaMu_P"), track.p(), track.tofNSigmaMu()); - registry.fill(HIST("hTPCNsigmaPi_P"), track.p(), track.tpcNSigmaPi()); - registry.fill(HIST("hTOFNsigmaPi_P"), track.p(), track.tofNSigmaPi()); - registry.fill(HIST("hTPCNsigmaKa_P"), track.p(), track.tpcNSigmaKa()); - registry.fill(HIST("hTOFNsigmaKa_P"), track.p(), track.tofNSigmaKa()); - registry.fill(HIST("hTPCNsigmaPr_P"), track.p(), track.tpcNSigmaPr()); - registry.fill(HIST("hTOFNsigmaPr_P"), track.p(), track.tofNSigmaPr()); - } // end of track loop + } // end of v0 loop auto cascades_coll = cascades.sliceBy(perCollision_cascade, collision.globalIndex()); - for (auto& cascade : cascades_coll) { + for (const auto& cascade : cascades_coll) { // Track casting auto bachelor = cascade.template bachelor_as(); - auto v0 = cascade.template v0_as(); - auto pos = v0.template posTrack_as(); - auto neg = v0.template negTrack_as(); - if (!IsSelected(pos) || !IsSelected(neg) || !IsSelected(bachelor)) { - continue; - } - + auto pos = cascade.template posTrack_as(); + auto neg = cascade.template negTrack_as(); if (pos.sign() * neg.sign() > 0) { continue; } - if (v0.v0Type() != 0 && v0.v0Type() != 1) { - continue; - } - - // Calculate DCA with respect to the collision associated to the V0, not individual tracks - gpu::gpustd::array dcaInfo_pos; - auto pTrackPar = getTrackPar(pos); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, pTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo_pos); - if (abs(dcaInfo_pos[0]) < mindcaxytopv_v0leg) { - continue; - } - - gpu::gpustd::array dcaInfo_neg; - auto nTrackPar = getTrackPar(neg); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, nTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo_neg); - if (abs(dcaInfo_neg[0]) < mindcaxytopv_v0leg) { - continue; - } - - // Calculate DCA with respect to the collision associated to the Cascade, not individual tracks - gpu::gpustd::array dcaInfo_bach; - auto bachTrackPar = getTrackPar(bachelor); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, bachTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo_bach); - if (abs(dcaInfo_bach[0]) < mindcaxytopv_bach_casc) { - continue; - } - - if (bachelor.sign() < 0) { // omega -> L + K- -> p + pi- + K- - if (abs(pos.tpcNSigmaPr()) > 3.f || abs(neg.tpcNSigmaPi()) > 3.f) { + if (bachelor.sign() < 0) { // Omega- -> L + K- -> p + pi- + K- + if (!isProtonTight(pos) || !isPionTight(neg)) { continue; } - } else { // omegabar -> Lbar + K+ -> pbar + pi+ + K+ - if (abs(pos.tpcNSigmaPi()) > 3.f || abs(neg.tpcNSigmaPr()) > 3.f) { + } else { // Omegabar+ -> Lbar + K+ -> pbar + pi+ + K+ + if (!isProtonTight(neg) || !isPionTight(pos)) { continue; } } - // reconstruct V0s - auto pTrack = getTrackParCov(pos); // positive - auto nTrack = getTrackParCov(neg); // negative - std::array svpos = {0.}; // secondary vertex position - std::array pvec0 = {0.}; - std::array pvec1 = {0.}; - - int nCand = fitter.process(pTrack, nTrack); - if (nCand != 0) { - fitter.propagateTracksToVertex(); - const auto& vtx = fitter.getPCACandidate(); - for (int i = 0; i < 3; i++) { - svpos[i] = vtx[i]; - } - fitter.getTrack(0).getPxPyPzGlo(pvec0); // positive - fitter.getTrack(1).getPxPyPzGlo(pvec1); // negative - } else { - continue; - } - std::array pvxyz{pvec0[0] + pvec1[0], pvec0[1] + pvec1[1], pvec0[2] + pvec1[2]}; - float v0_rxy = std::sqrt(std::pow(svpos[0], 2) + std::pow(svpos[1], 2)); - if (v0_rxy < min_v0rxy_in_cascade) { + if (!(cascadecuts.cfg_min_mass_lambda < cascade.mLambda() && cascade.mLambda() < cascadecuts.cfg_max_mass_lambda)) { continue; } - float dcav0topv = CalculateDCAStraightToPV(svpos[0], svpos[1], svpos[2], pvxyz[0], pvxyz[1], pvxyz[2], collision.posX(), collision.posY(), collision.posZ()); - if (dcav0topv < min_dcav0topv_casc) { + if (cascade.cascradius() > cascade.v0radius()) { continue; } - float mLambda = RecoDecay::m(std::array{std::array{pvec0[0], pvec0[1], pvec0[2]}, std::array{pvec1[0], pvec1[1], pvec1[2]}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); - float mAntiLambda = RecoDecay::m(std::array{std::array{pvec0[0], pvec0[1], pvec0[2]}, std::array{pvec1[0], pvec1[1], pvec1[2]}}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton}); - float v0dca_casc = std::sqrt(fitter.getChi2AtPCACandidate()); // distance between 2 legs. - float v0CosinePA_casc = RecoDecay::cpa(pVtx, svpos, pvxyz); - registry.fill(HIST("Cascade/hV0PCA"), v0dca_casc); - registry.fill(HIST("Cascade/hV0CosPA"), v0CosinePA_casc); - registry.fill(HIST("Cascade/hMassLambda"), mLambda); - registry.fill(HIST("Cascade/hMassAntiLambda"), mAntiLambda); - - if (v0dca_casc > maxdcav0dau_casc) { - continue; - } - if (v0CosinePA_casc < minv0cospa_casc) { - continue; - } - if (bachelor.sign() < 0 && abs(mLambda - 1.115) > 0.005) { - continue; - } - if (bachelor.sign() > 0 && abs(mAntiLambda - 1.115) > 0.005) { + if (cascade.dcaV0daughters() > cascadecuts.cfg_max_dcadau_v0) { continue; } - float alpha = v0_alpha(pvec0[0], pvec0[1], pvec0[2], pvec1[0], pvec1[1], pvec1[2]); - float qt = v0_qt(pvec0[0], pvec0[1], pvec0[2], pvec1[0], pvec1[1], pvec1[2]); - registry.fill(HIST("Cascade/hAP_V0"), alpha, qt); - - // after V0 is found. - pTrack = fitter.getTrack(0); - nTrack = fitter.getTrack(1); - - // Calculate position covariance matrix - auto covVtxV = fitter.calcPCACovMatrix(0); - float positionCovariance[6] = {0.f}; - positionCovariance[0] = covVtxV(0, 0); - positionCovariance[1] = covVtxV(1, 0); - positionCovariance[2] = covVtxV(1, 1); - positionCovariance[3] = covVtxV(2, 0); - positionCovariance[4] = covVtxV(2, 1); - positionCovariance[5] = covVtxV(2, 2); - std::array covTpositive = {0.}; - std::array covTnegative = {0.}; - float momentumCovariance[6] = {0.f}; - pTrack.getCovXYZPxPyPzGlo(covTpositive); - nTrack.getCovXYZPxPyPzGlo(covTnegative); - constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component - for (int i = 0; i < 6; i++) { - momentumCovariance[i] = covTpositive[MomInd[i]] + covTnegative[MomInd[i]]; - } - - std::array covV = {0.}; - for (int i = 0; i < 6; i++) { - covV[MomInd[i]] = momentumCovariance[i]; - covV[i] = positionCovariance[i]; - } - auto lV0Track = o2::track::TrackParCov({svpos[0], svpos[1], svpos[2]}, {pvxyz[0], pvxyz[1], pvxyz[2]}, covV, 0, true); - lV0Track.setAbsCharge(0); - lV0Track.setPID(o2::track::PID::Lambda); - auto lBachelorTrack = getTrackParCov(bachelor); - - nCand = fitter.process(lV0Track, lBachelorTrack); - if (nCand != 0) { - fitter.propagateTracksToVertex(); - const auto& vtx = fitter.getPCACandidate(); - for (int i = 0; i < 3; i++) { - svpos[i] = vtx[i]; - } - fitter.getTrack(0).getPxPyPzGlo(pvec0); // v0 - fitter.getTrack(1).getPxPyPzGlo(pvec1); // bachelor - } else { + if (cascade.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadecuts.cfg_min_cospa_v0) { continue; } - std::array pvxyz_casc{pvec0[0] + pvec1[0], pvec0[1] + pvec1[1], pvec0[2] + pvec1[2]}; - float casc_rxy = std::sqrt(std::pow(svpos[0], 2) + std::pow(svpos[1], 2)); - if (casc_rxy < min_cascade_rxy) { + if (cascade.v0radius() < cascadecuts.cfg_min_rxy_v0) { continue; } - if (casc_rxy > v0_rxy) { + if (cascade.cascradius() < cascadecuts.cfg_min_rxy) { continue; } - float casc_dca = std::sqrt(fitter.getChi2AtPCACandidate()); // distance between bachelor and V0. - float casc_cpa = RecoDecay::cpa(pVtx, svpos, pvxyz_casc); - registry.fill(HIST("Cascade/hPCA"), casc_dca); - registry.fill(HIST("Cascade/hCosPA"), casc_cpa); - registry.fill(HIST("Cascade/hRxy"), v0_rxy, casc_rxy); - - alpha = v0_alpha(pvec0[0], pvec0[1], pvec0[2], pvec1[0], pvec1[1], pvec1[2]); - qt = v0_qt(pvec0[0], pvec0[1], pvec0[2], pvec1[0], pvec1[1], pvec1[2]); - registry.fill(HIST("Cascade/hAP"), alpha, qt); - - if (casc_dca > max_casc_dcadau) { + if (cascade.dcacascdaughters() > cascadecuts.cfg_max_dcadau) { continue; } - if (casc_cpa < min_casc_cospa) { + if (cascade.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadecuts.cfg_min_cospa) { continue; } - float length = std::sqrt(std::pow(svpos[0] - collision.posX(), 2) + std::pow(svpos[1] - collision.posY(), 2) + std::pow(svpos[2] - collision.posZ(), 2)); - float mom = RecoDecay::sqrtSumOfSquares(pvxyz_casc[0], pvxyz_casc[1], pvxyz_casc[2]); - float ctauXi = length / mom * o2::constants::physics::MassXiMinus; - float ctauOmega = length / mom * o2::constants::physics::MassOmegaMinus; - float pt = RecoDecay::sqrtSumOfSquares(pvxyz_casc[0], pvxyz_casc[1]); - - // after DCAFitter - lV0Track = fitter.getTrack(0); - lBachelorTrack = fitter.getTrack(1); - float mXi = RecoDecay::m(std::array{std::array{pvec0[0], pvec0[1], pvec0[2]}, std::array{pvec1[0], pvec1[1], pvec1[2]}}, std::array{o2::constants::physics::MassLambda, o2::constants::physics::MassPionCharged}); // ctau = 4.91 cm - float mOmega = RecoDecay::m(std::array{std::array{pvec0[0], pvec0[1], pvec0[2]}, std::array{pvec1[0], pvec1[1], pvec1[2]}}, std::array{o2::constants::physics::MassLambda, o2::constants::physics::MassKaonCharged}); // ctau 2.46 cm - - if (IsPion(bachelor)) { - registry.fill(HIST("Cascade/hMassXi"), mXi); - registry.fill(HIST("Cascade/hMassPt_Xi"), mXi, pt); - registry.fill(HIST("Cascade/hMassPt_Xi_bachelor"), mXi, bachelor.p()); - registry.fill(HIST("Cascade/hRxy_Xi"), mXi, casc_rxy); - registry.fill(HIST("Cascade/hCTau_Xi"), mXi, ctauXi); - // if (abs(mXi - 1.321) < 0.005) { // select Xi candidates - // if (dist01(engine) < downscaling_pion) { - // fillTrackTable(collision, bachelor, static_cast(o2::aod::pwgem::dilepton::PID_Label::kPion), static_cast(o2::aod::pwgem::dilepton::Track_Type::kPrimary)); - // } - // } - } - if (abs(mXi - 1.322) > 0.01 && IsKaon(bachelor)) { // reject Xi candidates - registry.fill(HIST("Cascade/hMassOmega"), mOmega); - registry.fill(HIST("Cascade/hMassPt_Omega"), mOmega, pt); - registry.fill(HIST("Cascade/hMassPt_Omega_bachelor"), mOmega, bachelor.p()); - registry.fill(HIST("Cascade/hRxy_Omega"), mOmega, casc_rxy); - registry.fill(HIST("Cascade/hCTau_Omega"), mOmega, ctauOmega); - if (abs(mOmega - 1.672) < 0.004) { // select Omega candidates - if (dist01(engine) < downscaling_kaon) { - fillTrackTable(collision, bachelor, static_cast(o2::aod::pwgem::dilepton::PID_Label::kKaon), static_cast(o2::aod::pwgem::dilepton::Track_Type::kPrimary)); - } - } - } - - } // end of cascade loop - - } // end of collision loop - stored_trackIds.clear(); - stored_trackIds.shrink_to_fit(); - } // end of process - - Partition positrons = o2::aod::track::signed1Pt > 0.f && o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::tpcChi2NCl < maxchi2tpc&& o2::aod::track::itsChi2NCl < maxchi2its&& nabs(o2::aod::track::dcaXY) < maxdcaXY&& nabs(o2::aod::track::dcaZ) < maxdcaZ&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true && (minTPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < maxTPCNsigmaEl); - Partition electrons = o2::aod::track::signed1Pt < 0.f && o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::tpcChi2NCl < maxchi2tpc&& o2::aod::track::itsChi2NCl < maxchi2its&& nabs(o2::aod::track::dcaXY) < maxdcaXY&& nabs(o2::aod::track::dcaZ) < maxdcaZ&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true && (minTPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < maxTPCNsigmaEl); - std::vector stored_secondary_electronIds; - void processPrimary(filteredMyCollisions const& collisions, aod::BCsWithTimestamps const&, aod::V0s const&, MyTracks const&) - { - stored_trackIds.reserve(positrons.size() + electrons.size()); - stored_secondary_electronIds.reserve(positrons.size() + electrons.size()); - - for (auto& collision : collisions) { - registry.fill(HIST("hEventCounter"), 1.0); // all - - auto bc = collision.template bc_as(); - initCCDB(bc); - - if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { - continue; - } - - auto positrons_per_coll = positrons->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - auto electrons_per_coll = electrons->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - - for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(positrons_per_coll, electrons_per_coll))) { // electron is tag, positron is probe. - if (!IsSelectedTag(ele) || !IsElectronTag(ele)) { // require tight global track selection + if (!isSelectedV0Leg(collision, pos) || !isSelectedV0Leg(collision, neg) || !isSelectedV0Leg(collision, bachelor)) { continue; } - if (!IsSelected(pos) || !IsElectron(pos)) { - continue; + registry.fill(HIST("Cascade/hMassLambda"), cascade.mLambda()); + registry.fill(HIST("Cascade/hV0PCA"), cascade.dcaV0daughters()); + registry.fill(HIST("Cascade/hV0CosPA"), cascade.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("Cascade/hPCA"), cascade.dcacascdaughters()); // distance between bachelor and V0. + registry.fill(HIST("Cascade/hCosPA"), cascade.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + + float length = std::sqrt(std::pow(cascade.x() - collision.posX(), 2) + std::pow(cascade.y() - collision.posY(), 2) + std::pow(cascade.z() - collision.posZ(), 2)); + float mom = cascade.p(); + float ctauXi = length / mom * o2::constants::physics::MassXiMinus; // 4.91 cm in PDG + float ctauOmega = length / mom * o2::constants::physics::MassOmegaMinus; // 2.46 cm in PDG + + if (isPion(bachelor)) { + registry.fill(HIST("Cascade/hMassXi"), cascade.mXi()); + registry.fill(HIST("Cascade/hMassPt_Xi"), cascade.mXi(), cascade.pt()); + registry.fill(HIST("Cascade/hRxy_Xi"), cascade.mXi(), cascade.cascradius()); + registry.fill(HIST("Cascade/hCTau_Xi"), cascade.mXi(), ctauXi); } - - ROOT::Math::PtEtaPhiMVector v1(ele.pt(), ele.eta(), ele.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - registry.fill(HIST("hMvsPhiV"), phiv, v12.M()); - if (v12.M() < slope * phiv + intercept) { // photon conversion is found. - stored_secondary_electronIds.emplace_back(pos.globalIndex()); - if (dist01(engine) < downscaling_secondary_electron) { - fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); + if (!(cascadecuts.cfg_min_mass_Xi_veto < cascade.mXi() && cascade.mXi() < cascadecuts.cfg_max_mass_Xi_veto) && isKaon(bachelor)) { // reject Xi candidates + registry.fill(HIST("Cascade/hMassOmega"), cascade.mOmega()); + registry.fill(HIST("Cascade/hMassPt_Omega"), cascade.mOmega(), cascade.pt()); + registry.fill(HIST("Cascade/hRxy_Omega"), cascade.mOmega(), cascade.cascradius()); + registry.fill(HIST("Cascade/hCTau_Omega"), cascade.mOmega(), ctauOmega); + if (cascadecuts.cfg_min_mass_Omega < cascade.mOmega() && cascade.mOmega() < cascadecuts.cfg_max_mass_Omega) { // select Omega candidates + registry.fill(HIST("V0/hTPCdEdx_P_Ka"), bachelor.tpcInnerParam(), bachelor.tpcSignal()); + registry.fill(HIST("V0/hTOFbeta_P_Ka"), bachelor.tpcInnerParam(), bachelor.beta()); + fillTrackTable(collision, bachelor, static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kKaon)); } } - } // end of pairing loop - - for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(positrons_per_coll, electrons_per_coll))) { // electron is probe, positron is tag. - if (!IsSelectedTag(pos) || !IsElectronTag(pos)) { // require tight global track selection - continue; - } - - if (!IsSelected(ele) || !IsElectron(ele)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(ele.pt(), ele.eta(), ele.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - registry.fill(HIST("hMvsPhiV"), phiv, v12.M()); - if (v12.M() < slope * phiv + intercept) { // photon conversion is found. - stored_secondary_electronIds.emplace_back(ele.globalIndex()); - if (dist01(engine) < downscaling_secondary_electron) { - fillTrackTable(collision, ele, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kSecondary)); - } - } - } // end of pairing loop - - // apply prefilter to reject photon conversion - for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(positrons_per_coll, electrons_per_coll))) { // electron is tag, positron is probe. - if (!IsSelectedTag(ele) || !IsElectronTag(ele)) { // require tight global track selection - continue; - } - - if (!IsSelected(pos) || !IsElectron(pos)) { - continue; - } - - if (std::find(stored_secondary_electronIds.begin(), stored_secondary_electronIds.end(), pos.globalIndex()) != stored_secondary_electronIds.end()) { - continue; // apply pre-filter to reject secondary electrons - } - - ROOT::Math::PtEtaPhiMVector v1(ele.pt(), ele.eta(), ele.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - registry.fill(HIST("hMvsPhiV_primary"), phiv, v12.M()); - if (v12.M() < max_mee_pi0 && dist01(engine) < downscaling_primary_electron) { // e from pi0 dalitz decay is found. - fillTrackTable(collision, pos, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kPrimary)); - } - } // end of pairing loop - - for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(positrons_per_coll, electrons_per_coll))) { // electron is probe, positron is tag. - if (!IsSelectedTag(pos) || !IsElectronTag(pos)) { // require tight global track selection - continue; - } - - if (!IsSelected(ele) || !IsElectron(ele)) { - continue; - } - - if (std::find(stored_secondary_electronIds.begin(), stored_secondary_electronIds.end(), ele.globalIndex()) != stored_secondary_electronIds.end()) { - continue; // apply pre-filter to reject secondary electrons - } - - ROOT::Math::PtEtaPhiMVector v1(ele.pt(), ele.eta(), ele.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(pos.pt(), pos.eta(), pos.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos.px(), pos.py(), pos.pz(), ele.px(), ele.py(), ele.pz(), pos.sign(), ele.sign(), d_bz); - registry.fill(HIST("hMvsPhiV_primary"), phiv, v12.M()); - if (v12.M() < max_mee_pi0 && dist01(engine) < downscaling_primary_electron) { // e from pi0 dalitz decay is found. - fillTrackTable(collision, ele, static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron), static_cast(o2::aod::pwgem::dilepton::Track_Type::kPrimary)); - } - } // end of pairing loop - + } // end of cascade loop } // end of collision loop stored_trackIds.clear(); stored_trackIds.shrink_to_fit(); - stored_secondary_electronIds.clear(); - stored_secondary_electronIds.shrink_to_fit(); } // end of process // please choose only 1 process function. void processDummy(filteredMyCollisions const&) {} - PROCESS_SWITCH(TreeCreatorElectronMLDDA, processPID, "produce ML input for single track level", false); // this is for eID with ITSsa. e/pi/k/p are selected by TOF, and these can be used for ITS-TPC PID. - PROCESS_SWITCH(TreeCreatorElectronMLDDA, processPrimary, "produce ML input for single track level", false); // this is for selecting electrons from primary or secondary. + PROCESS_SWITCH(TreeCreatorElectronMLDDA, processPID, "produce ML input for single track level", false); // this is for eID with ITSsa. e/pi/k/p are selected by TOF, and these can be used for ITS-TPC PID. PROCESS_SWITCH(TreeCreatorElectronMLDDA, processDummy, "process dummy", true); }; @@ -1046,66 +954,70 @@ struct MLTrackQC { HistogramRegistry registry{ "registry", { - {"hTPCdEdx_P_All", "TPC dE/dx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, - {"hTOFbeta_P_All", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, - {"hITSClusterSize_P_All", "mean ITS cluster size vs. p;p^{ITS-TPC} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {64, 0.0, 16}}}}, - {"hTPCdEdx_P_Electron", "TPC dE/dx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, - {"hTOFbeta_P_Electron", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, - {"hITSClusterSize_P_Electron", "mean ITS cluster size vs. p;p^{ITS-TPC} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {64, 0.0, 16}}}}, - {"hTPCdEdx_P_Pion", "TPC dE/dx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, - {"hTOFbeta_P_Pion", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, - {"hITSClusterSize_P_Pion", "mean ITS cluster size vs. p;p^{ITS-TPC} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {64, 0.0, 16}}}}, - {"hTPCdEdx_P_Kaon", "TPC dE/dx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, - {"hTOFbeta_P_Kaon", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, - {"hITSClusterSize_P_Kaon", "mean ITS cluster size vs. p;p^{ITS-TPC} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {64, 0.0, 16}}}}, - {"hTPCdEdx_P_Proton", "TPC dE/dx vs. p;p^{ITS-TPC} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, - {"hTOFbeta_P_Proton", "TOF beta vs. p;p^{ITS-TPC} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, - {"hITSClusterSize_P_Proton", "mean ITS cluster size vs. p;p^{ITS-TPC} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {64, 0.0, 16}}}}, - - {"hTPCNsigmaEl_P", "TPC n#sigma_{e} vs. p;p^{ITS-TPC} (GeV/c);n #sigma_{e}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTPCNsigmaPi_P", "TPC n#sigma_{#pi} vs. p;p^{ITS-TPC} (GeV/c);n #sigma_{#pi}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTPCNsigmaKa_P", "TPC n#sigma_{K} vs. p;p^{ITS-TPC} (GeV/c);n #sigma_{K}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTPCNsigmaPr_P", "TPC n#sigma_{p} vs. p;p^{ITS-TPC} (GeV/c);n #sigma_{p}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTOFNsigmaEl_P", "TOF n#sigma_{e} vs. p;p^{ITS-TOF} (GeV/c);n #sigma_{e}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTOFNsigmaPi_P", "TOF n#sigma_{#pi} vs. p;p^{ITS-TOF} (GeV/c);n #sigma_{#pi}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTOFNsigmaKa_P", "TOF n#sigma_{K} vs. p;p^{ITS-TOF} (GeV/c);n #sigma_{K}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, - {"hTOFNsigmaPr_P", "TOF n#sigma_{p} vs. p;p^{ITS-TOF} (GeV/c);n #sigma_{p}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, + {"hTPCdEdx_P_All", "TPC dE/dx vs. p;p_{pv} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, + {"hTOFbeta_P_All", "TOF beta vs. p;p_{pv} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, + {"hITSobClusterSize_P_All", "mean ITSob cluster size vs. p;p_{pv} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {150, 0.0, 15}}}}, + {"hTPCdEdx_P_Electron", "TPC dE/dx vs. p;p_{pv} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, + {"hTOFbeta_P_Electron", "TOF beta vs. p;p_{pv} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, + {"hITSobClusterSize_P_Electron", "mean ITSob cluster size vs. p;p_{pv} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {150, 0.0, 15}}}}, + {"hTPCdEdx_P_Pion", "TPC dE/dx vs. p;p_{pv} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, + {"hTOFbeta_P_Pion", "TOF beta vs. p;p_{pv} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, + {"hITSobClusterSize_P_Pion", "mean ITSob cluster size vs. p;p_{pv} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {150, 0.0, 15}}}}, + {"hTPCdEdx_P_Kaon", "TPC dE/dx vs. p;p_{pv} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, + {"hTOFbeta_P_Kaon", "TOF beta vs. p;p_{pv} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, + {"hITSobClusterSize_P_Kaon", "mean ITSob cluster size vs. p;p_{pv} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {150, 0.0, 15}}}}, + {"hTPCdEdx_P_Proton", "TPC dE/dx vs. p;p_{pv} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{500, 0.f, 5.f}, {200, 0, 200}}}}, + {"hTOFbeta_P_Proton", "TOF beta vs. p;p_{pv} (GeV/c);TOF #beta", {HistType::kTH2F, {{500, 0.f, 5.f}, {220, 0.0, 1.1}}}}, + {"hITSobClusterSize_P_Proton", "mean ITSob cluster size vs. p;p_{pv} (GeV/c); #times cos(#lambda)", {HistType::kTH2F, {{500, 0.f, 5.f}, {150, 0.0, 15}}}}, + + {"hTPCNsigmaEl_P", "TPC n#sigma_{e} vs. p;p_{pv} (GeV/c);n #sigma_{e}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, + {"hTPCNsigmaPi_P", "TPC n#sigma_{#pi} vs. p;p_{pv} (GeV/c);n #sigma_{#pi}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, + {"hTPCNsigmaKa_P", "TPC n#sigma_{K} vs. p;p_{pv} (GeV/c);n #sigma_{K}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, + {"hTPCNsigmaPr_P", "TPC n#sigma_{p} vs. p;p_{pv} (GeV/c);n #sigma_{p}^{TPC}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, + {"hTOFNsigmaEl_P", "TOF n#sigma_{e} vs. p;p_{pv} (GeV/c);n #sigma_{e}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, + {"hTOFNsigmaPi_P", "TOF n#sigma_{#pi} vs. p;p_{pv} (GeV/c);n #sigma_{#pi}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, + {"hTOFNsigmaKa_P", "TOF n#sigma_{K} vs. p;p_{pv} (GeV/c);n #sigma_{K}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, + {"hTOFNsigmaPr_P", "TOF n#sigma_{p} vs. p;p_{pv} (GeV/c);n #sigma_{p}^{TOF}", {HistType::kTH2F, {{500, 0.f, 5.f}, {100, -5, +5}}}}, }, }; - void process(aod::EMPrimaryTracks const& tracks) + void processQC(aod::EMTracksForMLPID const& tracks) { - for (auto& track : tracks) { + for (const auto& track : tracks) { registry.fill(HIST("hTPCdEdx_P_All"), track.p(), track.tpcSignal()); registry.fill(HIST("hTOFbeta_P_All"), track.p(), track.beta()); - registry.fill(HIST("hITSClusterSize_P_All"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); - if (track.pidlabel() == static_cast(o2::aod::pwgem::dilepton::PID_Label::kElectron)) { + registry.fill(HIST("hITSobClusterSize_P_All"), track.p(), track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))); + if (track.pidlabel() == static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kElectron)) { registry.fill(HIST("hTPCdEdx_P_Electron"), track.p(), track.tpcSignal()); registry.fill(HIST("hTOFbeta_P_Electron"), track.p(), track.beta()); - registry.fill(HIST("hITSClusterSize_P_Electron"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); + registry.fill(HIST("hITSobClusterSize_P_Electron"), track.p(), track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))); registry.fill(HIST("hTPCNsigmaEl_P"), track.p(), track.tpcNSigmaEl()); registry.fill(HIST("hTOFNsigmaEl_P"), track.p(), track.tofNSigmaEl()); - } else if (track.pidlabel() == static_cast(o2::aod::pwgem::dilepton::PID_Label::kPion)) { + } else if (track.pidlabel() == static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kPion)) { registry.fill(HIST("hTPCdEdx_P_Pion"), track.p(), track.tpcSignal()); registry.fill(HIST("hTOFbeta_P_Pion"), track.p(), track.beta()); - registry.fill(HIST("hITSClusterSize_P_Pion"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); + registry.fill(HIST("hITSobClusterSize_P_Pion"), track.p(), track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))); registry.fill(HIST("hTPCNsigmaPi_P"), track.p(), track.tpcNSigmaPi()); registry.fill(HIST("hTOFNsigmaPi_P"), track.p(), track.tofNSigmaPi()); - } else if (track.pidlabel() == static_cast(o2::aod::pwgem::dilepton::PID_Label::kKaon)) { + } else if (track.pidlabel() == static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kKaon)) { registry.fill(HIST("hTPCdEdx_P_Kaon"), track.p(), track.tpcSignal()); registry.fill(HIST("hTOFbeta_P_Kaon"), track.p(), track.beta()); - registry.fill(HIST("hITSClusterSize_P_Kaon"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); + registry.fill(HIST("hITSobClusterSize_P_Kaon"), track.p(), track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))); registry.fill(HIST("hTPCNsigmaKa_P"), track.p(), track.tpcNSigmaKa()); registry.fill(HIST("hTOFNsigmaKa_P"), track.p(), track.tofNSigmaKa()); - } else if (track.pidlabel() == static_cast(o2::aod::pwgem::dilepton::PID_Label::kProton)) { + } else if (track.pidlabel() == static_cast(o2::aod::pwgem::dilepton::ml::PID_Label::kProton)) { registry.fill(HIST("hTPCdEdx_P_Proton"), track.p(), track.tpcSignal()); registry.fill(HIST("hTOFbeta_P_Proton"), track.p(), track.beta()); - registry.fill(HIST("hITSClusterSize_P_Proton"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); + registry.fill(HIST("hITSobClusterSize_P_Proton"), track.p(), track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))); registry.fill(HIST("hTPCNsigmaPr_P"), track.p(), track.tpcNSigmaPr()); registry.fill(HIST("hTOFNsigmaPr_P"), track.p(), track.tofNSigmaPr()); } } // end of track loop } + PROCESS_SWITCH(MLTrackQC, processQC, "process QC for single track level", false); + + void processDummy(aod::EMTracksForMLPID const&) {} + PROCESS_SWITCH(MLTrackQC, processDummy, "process dummy", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGEM/Dilepton/Tasks/CMakeLists.txt b/PWGEM/Dilepton/Tasks/CMakeLists.txt index 28653d96eb3..94ccb5f2ea4 100644 --- a/PWGEM/Dilepton/Tasks/CMakeLists.txt +++ b/PWGEM/Dilepton/Tasks/CMakeLists.txt @@ -46,9 +46,14 @@ o2physics_add_dpl_workflow(table-reader-barrel PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2Physics::PWGDQCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(bc-counter + SOURCES bcCounter.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(event-qc SOURCES eventQC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(single-electron-qc @@ -83,22 +88,22 @@ o2physics_add_dpl_workflow(single-muon-qc-mc o2physics_add_dpl_workflow(dielectron SOURCES dielectron.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2::DCAFitter O2Physics::PWGEMDileptonCore + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2Physics::PWGEMDileptonCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(dielectron-mc SOURCES dielectronMC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2::DCAFitter O2Physics::PWGEMDileptonCore + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2Physics::PWGEMDileptonCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(dimuon SOURCES dimuon.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::DCAFitter O2Physics::PWGEMDileptonCore + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMDileptonCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(dimuon-mc SOURCES dimuonMC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::DCAFitter O2Physics::PWGEMDileptonCore + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMDileptonCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(photon-hbt-pcmpcm @@ -126,3 +131,33 @@ o2physics_add_dpl_workflow(associate-mccollision-to-collision PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(study-mc-truth + SOURCES studyMCTruth.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(matching-mft + SOURCES matchingMFT.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::GlobalTracking + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(tagging-hfe + SOURCES taggingHFE.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DCAFitter O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(qvector-dummy-otf + SOURCES qVectorDummyOTF.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(dielectron-hadron-mpc + SOURCES dielectronHadronMPC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2Physics::PWGEMDileptonCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(dimuon-hadron-mpc + SOURCES dimuonHadronMPC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2Physics::PWGEMDileptonCore + COMPONENT_NAME Analysis) + diff --git a/PWGEM/Dilepton/Tasks/Converters/CMakeLists.txt b/PWGEM/Dilepton/Tasks/Converters/CMakeLists.txt index 4ba93844b6c..31985d9d2d3 100644 --- a/PWGEM/Dilepton/Tasks/Converters/CMakeLists.txt +++ b/PWGEM/Dilepton/Tasks/Converters/CMakeLists.txt @@ -10,8 +10,13 @@ # or submit itself to any jurisdiction. -o2physics_add_dpl_workflow(event-converter1 - SOURCES eventConverter1.cxx +o2physics_add_dpl_workflow(event-converter2 + SOURCES eventConverter2.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(event-converter3 + SOURCES eventConverter3.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -20,3 +25,13 @@ o2physics_add_dpl_workflow(electron-converter2 PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(electron-converter3 + SOURCES electronConverter3.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(electron-converter4 + SOURCES electronConverter4.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + diff --git a/PWGEM/Dilepton/Tasks/Converters/electronConverter3.cxx b/PWGEM/Dilepton/Tasks/Converters/electronConverter3.cxx new file mode 100644 index 00000000000..f4101ab2a51 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/Converters/electronConverter3.cxx @@ -0,0 +1,85 @@ +// 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. +// +// ======================== +// +// This code runs loop over ULS ee pars for virtual photon QC. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct electronConverter3 { + Produces track_003; + + void process(aod::EMPrimaryElectrons_002 const& tracks) + { + for (auto& track : tracks) { + track_003(track.collisionId(), + track.trackId(), + track.sign(), + track.pt(), + track.eta(), + track.phi(), + track.dcaXY(), + track.dcaZ(), + track.tpcNClsFindable(), + track.tpcNClsFindableMinusFound(), + track.tpcNClsFindableMinusCrossedRows(), + track.tpcNClsShared(), + track.tpcChi2NCl(), + track.tpcInnerParam(), + track.tpcSignal(), + track.tpcNSigmaEl(), + // track.tpcNSigmaMu(), + track.tpcNSigmaPi(), + track.tpcNSigmaKa(), + track.tpcNSigmaPr(), + track.beta(), + track.tofNSigmaEl(), + // track.tofNSigmaMu(), + track.tofNSigmaPi(), + track.tofNSigmaKa(), + track.tofNSigmaPr(), + track.itsClusterSizes(), + // track.itsNSigmaEl(), + // track.itsNSigmaMu(), + // track.itsNSigmaPi(), + // track.itsNSigmaKa(), + // track.itsNSigmaPr(), + track.itsChi2NCl(), + track.tofChi2(), + track.detectorMap(), + track.x(), + track.alpha(), + track.y(), + track.z(), + track.snp(), + track.tgl(), + track.isAssociatedToMPC(), + -1); + } // end of track loop + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"electron-converter3"})}; +} diff --git a/PWGEM/Dilepton/Tasks/Converters/electronConverter4.cxx b/PWGEM/Dilepton/Tasks/Converters/electronConverter4.cxx new file mode 100644 index 00000000000..37186075fe9 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/Converters/electronConverter4.cxx @@ -0,0 +1,157 @@ +// 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. +// +// ======================== +// +// This code runs loop over ULS ee pars for virtual photon QC. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct electronConverter4 { + Produces track_004; + + using MyElectrons002 = soa::Join; + void process002to004(MyElectrons002 const& tracks) + { + for (const auto& track : tracks) { + float itsChi2NCl = (track.hasITS() && track.itsChi2NCl() > 0.f) ? track.itsChi2NCl() : -299.f; + float tpcChi2NCl = (track.hasTPC() && track.tpcChi2NCl() > 0.f) ? track.tpcChi2NCl() : -299.f; + float beta = track.hasTOF() ? track.beta() : -29.f; + float tofNSigmaEl = track.hasTOF() ? track.tofNSigmaEl() : -299.f; + float tofNSigmaPi = track.hasTOF() ? track.tofNSigmaPi() : -299.f; + float tofNSigmaKa = track.hasTOF() ? track.tofNSigmaKa() : -299.f; + float tofNSigmaPr = track.hasTOF() ? track.tofNSigmaPr() : -299.f; + float tofChi2 = track.hasTOF() ? track.tofChi2() : -299.f; + + float tpcSignal = track.hasTPC() ? track.tpcSignal() : -299.f; + float tpcNSigmaEl = track.hasTPC() ? track.tpcNSigmaEl() : -299.f; + float tpcNSigmaPi = track.hasTPC() ? track.tpcNSigmaPi() : -299.f; + float tpcNSigmaKa = track.hasTPC() ? track.tpcNSigmaKa() : -299.f; + float tpcNSigmaPr = track.hasTPC() ? track.tpcNSigmaPr() : -299.f; + + track_004(track.collisionId(), + track.trackId(), + track.sign(), + track.pt(), + track.eta(), + track.phi(), + track.dcaXY(), + track.dcaZ(), + track.cYY(), + track.cZY(), + track.cZZ(), + track.tpcNClsFindable(), + track.tpcNClsFindableMinusFound(), + track.tpcNClsFindableMinusCrossedRows(), + track.tpcNClsShared(), + + static_cast(tpcChi2NCl * 1e+2), + track.tpcInnerParam(), + static_cast(tpcSignal * 1e+2), + static_cast(tpcNSigmaEl * 1e+2), + static_cast(tpcNSigmaPi * 1e+2), + static_cast(tpcNSigmaKa * 1e+2), + static_cast(tpcNSigmaPr * 1e+2), + static_cast(beta * 1e+3), + static_cast(tofNSigmaEl * 1e+2), + static_cast(tofNSigmaPi * 1e+2), + static_cast(tofNSigmaKa * 1e+2), + static_cast(tofNSigmaPr * 1e+2), + track.itsClusterSizes(), + static_cast(itsChi2NCl * 1e+2), + static_cast(tofChi2 * 1e+2), + track.detectorMap(), + track.tgl(), + track.isAssociatedToMPC(), + false, + 0.f, + static_cast(0)); + } // end of track loop + } + PROCESS_SWITCH(electronConverter4, process002to004, "convert from 002 into 004", false); + + using MyElectrons003 = soa::Join; + void process003to004(MyElectrons003 const& tracks) + { + for (const auto& track : tracks) { + float itsChi2NCl = track.itsChi2NCl() > 0.f ? track.itsChi2NCl() : -299.f; + float tpcChi2NCl = track.tpcChi2NCl() > 0.f ? track.tpcChi2NCl() : -299.f; + float beta = track.hasTOF() ? track.beta() : -29.f; + float tofNSigmaEl = track.hasTOF() ? track.tofNSigmaEl() : -299.f; + float tofNSigmaPi = track.hasTOF() ? track.tofNSigmaPi() : -299.f; + float tofNSigmaKa = track.hasTOF() ? track.tofNSigmaKa() : -299.f; + float tofNSigmaPr = track.hasTOF() ? track.tofNSigmaPr() : -299.f; + float tofChi2 = track.hasTOF() ? track.tofChi2() : -299.f; + + float tpcSignal = track.hasTPC() ? track.tpcSignal() : 0.f; + float mcTunedTPCSignal = track.hasTPC() ? track.mcTunedTPCSignal() : 0.f; + float tpcNSigmaEl = track.hasTPC() ? track.tpcNSigmaEl() : -299.f; + float tpcNSigmaPi = track.hasTPC() ? track.tpcNSigmaPi() : -299.f; + float tpcNSigmaKa = track.hasTPC() ? track.tpcNSigmaKa() : -299.f; + float tpcNSigmaPr = track.hasTPC() ? track.tpcNSigmaPr() : -299.f; + + track_004(track.collisionId(), + track.trackId(), + track.sign(), + track.pt(), + track.eta(), + track.phi(), + track.dcaXY(), + track.dcaZ(), + track.cYY(), + track.cZY(), + track.cZZ(), + track.tpcNClsFindable(), + track.tpcNClsFindableMinusFound(), + track.tpcNClsFindableMinusCrossedRows(), + track.tpcNClsShared(), + + static_cast(tpcChi2NCl * 1e+2), + track.tpcInnerParam(), + static_cast(tpcSignal * 1e+2), + static_cast(tpcNSigmaEl * 1e+2), + static_cast(tpcNSigmaPi * 1e+2), + static_cast(tpcNSigmaKa * 1e+2), + static_cast(tpcNSigmaPr * 1e+2), + static_cast(beta * 1e+3), + static_cast(tofNSigmaEl * 1e+2), + static_cast(tofNSigmaPi * 1e+2), + static_cast(tofNSigmaKa * 1e+2), + static_cast(tofNSigmaPr * 1e+2), + track.itsClusterSizes(), + static_cast(itsChi2NCl * 1e+2), + static_cast(tofChi2 * 1e+2), + track.detectorMap(), + track.tgl(), + track.isAssociatedToMPC(), + false, + 0.f, + static_cast(mcTunedTPCSignal)); + } // end of track loop + } + PROCESS_SWITCH(electronConverter4, process003to004, "convert from 003 into 004", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"electron-converter4"})}; +} diff --git a/PWGEM/Dilepton/Tasks/Converters/eventConverter1.cxx b/PWGEM/Dilepton/Tasks/Converters/eventConverter2.cxx similarity index 83% rename from PWGEM/Dilepton/Tasks/Converters/eventConverter1.cxx rename to PWGEM/Dilepton/Tasks/Converters/eventConverter2.cxx index 148ff43bd88..568cb741d08 100644 --- a/PWGEM/Dilepton/Tasks/Converters/eventConverter1.cxx +++ b/PWGEM/Dilepton/Tasks/Converters/eventConverter2.cxx @@ -25,30 +25,31 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -struct eventConverter1 { - Produces event_001; +struct eventConverter2 { + Produces event_002; - void process(aod::EMEvents_000 const& collisions) + void process(aod::EMEvents_001 const& collisions) { for (auto& collision : collisions) { - event_001( + event_002( collision.globalIndex(), collision.runNumber(), collision.globalBC(), collision.alias_raw(), collision.selection_raw(), + 0, collision.timestamp(), collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), collision.trackOccupancyInTimeRange(), - -1.f); + collision.ft0cOccupancyInTimeRange()); } // end of collision loop } }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"event-converter1"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"event-converter2"})}; } diff --git a/PWGEM/Dilepton/Tasks/Converters/eventConverter3.cxx b/PWGEM/Dilepton/Tasks/Converters/eventConverter3.cxx new file mode 100644 index 00000000000..fe22e18f859 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/Converters/eventConverter3.cxx @@ -0,0 +1,54 @@ +// 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. +// +// ======================== +// +// This code runs loop over ULS ee pars for virtual photon QC. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct eventConverter3 { + Produces event_003; + + void process(aod::EMEvents_002 const& collisions) + { + for (auto& collision : collisions) { + event_003( + collision.globalIndex(), + collision.runNumber(), + collision.globalBC(), + collision.alias_raw(), + collision.selection_raw(), + collision.rct_raw(), + collision.timestamp(), + collision.posZ(), + collision.numContrib(), + collision.trackOccupancyInTimeRange(), + collision.ft0cOccupancyInTimeRange()); + } // end of collision loop + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"event-converter3"})}; +} diff --git a/PWGEM/Dilepton/Tasks/MCtemplates.cxx b/PWGEM/Dilepton/Tasks/MCtemplates.cxx index 30b60856cb5..3288bd2745e 100644 --- a/PWGEM/Dilepton/Tasks/MCtemplates.cxx +++ b/PWGEM/Dilepton/Tasks/MCtemplates.cxx @@ -604,7 +604,7 @@ struct AnalysisSameEventPairing { checked = sig.CheckSignal(true, t1, t2); } if (checked) { - VarManager::FillPairMC(t1, t2); + VarManager::FillPairMC(t1, t2); fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig.GetName()), VarManager::fgValues); } } diff --git a/PWGEM/Dilepton/Tasks/associateMCcollision.cxx b/PWGEM/Dilepton/Tasks/associateMCcollision.cxx index 5a3caf45ef1..eb0e7d3bf5c 100644 --- a/PWGEM/Dilepton/Tasks/associateMCcollision.cxx +++ b/PWGEM/Dilepton/Tasks/associateMCcollision.cxx @@ -17,7 +17,6 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/ASoAHelpers.h" - #include "PWGEM/Dilepton/DataModel/dileptonTables.h" using namespace o2; @@ -33,6 +32,9 @@ struct associateMCcollision { void init(InitContext&) { + if (doprocessNcontrib && doprocessNcontrib_Derived) { + LOGF(fatal, "Please select only 1 process function."); + } addhistograms(); } @@ -40,17 +42,15 @@ struct associateMCcollision { void addhistograms() { - fRegistry.add("hReccollsPerMCcoll", "Rec. colls per MC coll;Rec. colls per MC coll;Number of MC collisions", kTH1F, {{21, -0.5, 20.5}}, false); + fRegistry.add("hReccollsPerMCcoll", "Rec. colls per MC coll;Rec. colls per MC coll;Number of MC collisions", kTH1D, {{21, -0.5, 20.5}}, false); } - using MyCollisions = soa::Join; - using MyCollision = MyCollisions::iterator; - PresliceUnsorted recColperMcCollision = aod::emmceventlabel::emmceventId; - - void processNcontrib(aod::EMMCEvents const& mccollisions, MyCollisions const& collisions) + template + void runMC(TMCCollisions const& mcCollisions, TCollisions const& collisions, TPreslice const& perMCCollision) { - for (auto& mccollision : mccollisions) { - auto rec_colls_per_mccoll = collisions.sliceBy(recColperMcCollision, mccollision.globalIndex()); + + for (auto& mcCollision : mcCollisions) { + auto rec_colls_per_mccoll = collisions.sliceBy(perMCCollision, mcCollision.globalIndex()); fRegistry.fill(HIST("hReccollsPerMCcoll"), rec_colls_per_mccoll.size()); uint32_t maxNumContrib = 0; int rec_col_globalIndex = -999; @@ -63,8 +63,28 @@ struct associateMCcollision { // LOGF(info, "rec_col_globalIndex = %d", rec_col_globalIndex); mpemeventIds(rec_col_globalIndex); } // end of mc collision - } // end of process - PROCESS_SWITCH(associateMCcollision, processNcontrib, "produce most probable emeventId based on Ncontrib to PV", true); + + } // end of runMC + + using MyCollisions = soa::Join; + using MyCollision = MyCollisions::iterator; + PresliceUnsorted recColperMcCollision = aod::mccollisionlabel::mcCollisionId; + + using MyEMCollisions = soa::Join; + using MyEMCollision = MyEMCollisions::iterator; + PresliceUnsorted recColperMcCollision_derived = aod::emmceventlabel::emmceventId; + + void processNcontrib_Derived(aod::EMMCEvents const& mcCollisions, MyEMCollisions const& collisions) + { + runMC(mcCollisions, collisions, recColperMcCollision_derived); + } + PROCESS_SWITCH(associateMCcollision, processNcontrib_Derived, "produce most probable emeventId based on Ncontrib to PV for derived AOD", true); + + void processNcontrib(aod::McCollisions const& mcCollisions, MyCollisions const& collisions) + { + runMC(mcCollisions, collisions, recColperMcCollision); + } + PROCESS_SWITCH(associateMCcollision, processNcontrib, "produce most probable emeventId based on Ncontrib to PV for original AOD", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGEM/Dilepton/Tasks/bcCounter.cxx b/PWGEM/Dilepton/Tasks/bcCounter.cxx new file mode 100644 index 00000000000..1b16c88e89b --- /dev/null +++ b/PWGEM/Dilepton/Tasks/bcCounter.cxx @@ -0,0 +1,142 @@ +// 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. +// +// ======================== +// +// This code is for bc counter. +// Please write to: daiki.sekihata@cern.ch + +#include +#include +#include +#include +#include + +#include "TString.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Common/Core/RecoDecay.h" +#include "MathUtils/Utils.h" +#include "Framework/AnalysisDataModel.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "CCDB/BasicCCDBManager.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +using MyBCs = soa::Join; +using MyCollisions = soa::Join; +using MyMCCollisions = soa::Join; + +struct bcCounter { + // Configurables + // Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + // Service ccdb; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + void init(InitContext&) + { + // ccdb->setURL(ccdburl); + // ccdb->setCaching(true); + // ccdb->setLocalObjectValidityChecking(); + // ccdb->setFatalWhenNull(false); + addhistograms(); + } + + ~bcCounter() {} + + void addhistograms() + { + // event info + + const int nbin_ev = 3; + auto hBCCounter = fRegistry.add("Data/hBCCounter", "bc counter;;Number of bcs", kTH1D, {{nbin_ev, 0.5, nbin_ev + 0.5}}, false); + hBCCounter->GetXaxis()->SetBinLabel(1, "all"); + hBCCounter->GetXaxis()->SetBinLabel(2, "FT0AND"); + hBCCounter->GetXaxis()->SetBinLabel(3, "FT0AND && vertex found"); + fRegistry.add("Data/hNcollsPerBC", "Number of rec. collisions per BC", kTH1D, {{21, -0.5, 20.5}}, false); + + fRegistry.addClone("Data/", "MC/"); + } + + SliceCache cache; + PresliceUnsorted preslice_collisions_per_bc = o2::aod::evsel::foundBCId; + // std::unordered_map map_ncolls_per_bc; + + void processData(MyBCs const& bcs, MyCollisions const& collisions) + { + // first count the number of collisions per bc + for (const auto& bc : bcs) { + auto collisions_per_bc = collisions.sliceBy(preslice_collisions_per_bc, bc.globalIndex()); + // map_ncolls_per_bc[bc.globalIndex()] = collisions_per_bc.size(); + fRegistry.fill(HIST("Data/hNcollsPerBC"), collisions_per_bc.size()); + // LOGF(info, "bc-loop | bc.globalIndex() = %d , collisions_per_bc.size() = %d", bc.globalIndex(), collisions_per_bc.size()); + + fRegistry.fill(HIST("Data/hBCCounter"), 1.0); + if (bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + fRegistry.fill(HIST("Data/hBCCounter"), 2.0); + + if (collisions_per_bc.size() > 0) { // at least 1 reconstructed vertex exists. + fRegistry.fill(HIST("Data/hBCCounter"), 3.0); + } + } + } // end of bc loop + + // for (const auto& collision : collisions) { + // auto bc = collision.template foundBC_as(); + // // LOGF(info, "collision-loop | bc.globalIndex() = %d, ncolls_per_bc = %d", bc.globalIndex(), map_ncolls_per_bc[bc.globalIndex()]); + // } // end of collision loop + + // map_ncolls_per_bc.clear(); + } + PROCESS_SWITCH(bcCounter, processData, "process Data", true); + + // void processMC(MyBCs const& bcs, MyMCCollisions const& collisions, aod::McCollisions const& mccollisions) + // { + + // // first count the number of collisions per bc + // for (const auto& bc : bcs) { + // auto collisions_per_bc = collisions.sliceBy(preslice_collisions_per_bc, bc.globalIndex()); + // // map_ncolls_per_bc[bc.globalIndex()] = collisions_per_bc.size(); + // fRegistry.fill(HIST("hNcollsPerBC"), collisions_per_bc.size()); + // // LOGF(info, "bc-loop | bc.globalIndex() = %d , collisions_per_bc.size() = %d", bc.globalIndex(), collisions_per_bc.size()); + + // fRegistry.fill(HIST("hBCCounter"), 1.0); + // if (bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + // fRegistry.fill(HIST("hBCCounter"), 2.0); + + // if (collisions_per_bc.size() > 0) { // at least 1 reconstructed vertex exists. + // fRegistry.fill(HIST("hBCCounter"), 3.0); + // } + // } + // } // end of bc loop + // } + // PROCESS_SWITCH(bcCounter, processMC, "process MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"bc-counter"})}; +} diff --git a/PWGEM/Dilepton/Tasks/createResolutionMap.cxx b/PWGEM/Dilepton/Tasks/createResolutionMap.cxx index 06c3b4c4a54..323d82e7728 100644 --- a/PWGEM/Dilepton/Tasks/createResolutionMap.cxx +++ b/PWGEM/Dilepton/Tasks/createResolutionMap.cxx @@ -13,71 +13,68 @@ // Analysis task to produce resolution mapfor electrons/muons in dilepton analysis // Please write to: daiki.sekihata@cern.ch -#include -#include -#include -#include -#include -#include +#include "PWGEM/Dilepton/Utils/MCUtilities.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/ASoA.h" -#include "Framework/DataTypes.h" -#include "Framework/HistogramRegistry.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" +#include "Common/CCDB/RCTSelectionFlags.h" +#include "Common/Core/fwdtrackUtilities.h" +#include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" #include "CCDB/BasicCCDBManager.h" +#include "DataFormatsCalibration/MeanVertexObject.h" #include "DataFormatsParameters/GRPMagField.h" -#include "TGeoGlobalMagField.h" -#include "Field/MagneticField.h" - #include "DetectorsBase/Propagator.h" +#include "Field/MagneticField.h" +#include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/DataTypes.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" #include "GlobalTracking/MatchGlobalFwd.h" #include "MCHTracking/TrackExtrap.h" #include "MCHTracking/TrackParam.h" #include "ReconstructionDataFormats/TrackFwd.h" +#include "TGeoGlobalMagField.h" + +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::aod; using namespace o2::soa; - -using MyCollisions = Join; -using MyCollision = MyCollisions::iterator; - -using MyCollisionsCent = soa::Join; -using MyCollisionCent = MyCollisionsCent::iterator; - -using MyMCTracks = soa::Join; -using MyMCTrack = MyMCTracks::iterator; - -using MyMCFwdTracks = soa::Join; -using MyMCFwdTrack = MyMCFwdTracks::iterator; +using namespace o2::aod::pwgem::dilepton::utils::mcutil; +using namespace o2::aod::fwdtrackutils; struct CreateResolutionMap { - // Index used to set different options for Muon propagation - enum class MuonExtrapolation : int { - kToVertex = 0, // propagtion to vertex by default - kToDCA = 1, - kToRabs = 2, - }; - using SMatrix55 = ROOT::Math::SMatrix>; - using SMatrix5 = ROOT::Math::SVector; - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; + Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; + Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; + Configurable cfgEventGeneratorType{"cfgEventGeneratorType", -1, "if positive, select event generator type. i.e. gap or signal"}; Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfg_require_true_mc_collision_association{"cfg_require_true_mc_collision_association", false, "flag to require true mc collision association"}; + Configurable cfg_reject_fake_match_its_tpc{"cfg_reject_fake_match_its_tpc", false, "flag to reject fake match between ITS-TPC"}; + // Configurable cfg_reject_fake_match_its_tpc_tof{"cfg_reject_fake_match_its_tpc_tof", false, "flag to reject fake match between ITS-TPC-TOF"}; + Configurable cfg_reject_fake_match_mft_mch{"cfg_reject_fake_match_mft_mch", false, "flag to reject fake match between MFT-MCH"}; - ConfigurableAxis ConfPtGenBins{"ConfPtGenBins", {VARIABLE_WIDTH, 0.00, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.40, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.60, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.70, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.80, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.90, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.80, 2.90, 3.00, 3.10, 3.20, 3.30, 3.40, 3.50, 3.60, 3.70, 3.80, 3.90, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50, 4.60, 4.70, 4.80, 4.90, 5.00, 5.50, 6.00, 6.50, 7.00, 7.50, 8.00, 8.50, 9.00, 9.50, 10.00, 11.00, 12.00, 13.00, 14.00, 15.00, 16.00, 17.00, 18.00, 19.00, 20.00}, "gen. pT bins for output histograms"}; + ConfigurableAxis ConfPtGenBins{"ConfPtGenBins", {VARIABLE_WIDTH, 0.00, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.40, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.60, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.70, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.80, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.90, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.80, 2.90, 3.00, 3.10, 3.20, 3.30, 3.40, 3.50, 3.60, 3.70, 3.80, 3.90, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50, 4.60, 4.70, 4.80, 4.90, 5.00, 5.50, 6.00, 6.50, 7.00, 7.50, 8.00, 8.50, 9.00, 9.50, 10.00, 11.00, 12.00, 13.00, 14.00, 15.00, 16.00, 17.00, 18.00, 19.00, 20.00}, "gen. pT bins for output histograms"}; ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0, 10, 30, 50, 110}, "centrality (%) bins for output histograms"}; ConfigurableAxis ConfEtaCBGenBins{"ConfEtaCBGenBins", {30, -1.5, +1.5}, "gen. eta bins at midrapidity for output histograms"}; @@ -85,8 +82,42 @@ struct CreateResolutionMap { ConfigurableAxis ConfPhiGenBins{"ConfPhiGenBins", {72, 0, 2.f * M_PI}, "gen. eta bins at forward rapidity for output histograms"}; ConfigurableAxis ConfRelDeltaPtBins{"ConfRelDeltaPtBins", {200, -1.f, +1.f}, "rel. dpt for output histograms"}; - ConfigurableAxis ConfDeltaEtaBins{"ConfDeltaEtaBins", {100, -0.1f, +0.1f}, "deta bins for output histograms"}; - ConfigurableAxis ConfDeltaPhiBins{"ConfDeltaPhiBins", {100, -0.1f, +0.1f}, "dphi bins for output histograms"}; + ConfigurableAxis ConfDeltaEtaBins{"ConfDeltaEtaBins", {200, -0.2f, +0.2f}, "deta bins for output histograms"}; + ConfigurableAxis ConfDeltaPhiBins{"ConfDeltaPhiBins", {200, -0.2f, +0.2f}, "dphi bins for output histograms"}; + + Configurable cfgFillTHnSparse{"cfgFillTHnSparse", true, "fill THnSparse for output"}; + Configurable cfgFillTH2{"cfgFillTH2", false, "fill TH2 for output"}; + + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabelCB{"cfgRCTLabelCB", "CBT_hadronPID", "select 1 [CBT, CBT_hadron] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgRCTLabelFWDSA{"cfgRCTLabelFWDSA", "CBT_muon", "select 1 [CBT_muon] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgRCTLabelFWDGL{"cfgRCTLabelFWDGL", "CBT_muon_glo", "select 1 [CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; + + struct : ConfigurableGroup { + std::string prefix = "eventcut_group"; + Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; + Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + Configurable cfgRequireSel8{"cfgRequireSel8", false, "require sel8 in event cut"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; + Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. track occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. track occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; + // Configurable cfgRequireNoCollInTimeRangeStandard{"cfgRequireNoCollInTimeRangeStandard", false, "require no collision in time range standard"}; + // Configurable cfgRequireNoCollInTimeRangeStrict{"cfgRequireNoCollInTimeRangeStrict", false, "require no collision in time range strict"}; + // Configurable cfgRequirekNoCollInRofStandard{"cfgRequirekNoCollInRofStandard", false, "require no other collisions in this Readout Frame with per-collision multiplicity above threshold"}; + // Configurable cfgRequirekNoCollInRofStrict{"cfgRequirekNoCollInRofStrict", false, "require no other collisions in this Readout Frame"}; + // Configurable cfgRequirekNoHighMultCollInPrevRof{"cfgRequirekNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + // Configurable cfgRequireGoodITSLayer3{"cfgRequireGoodITSLayer3", false, "number of inactive chips on ITS layer 3 are below threshold "}; + // Configurable cfgRequireGoodITSLayer0123{"cfgRequireGoodITSLayer0123", false, "number of inactive chips on ITS layers 0-3 are below threshold "}; + // Configurable cfgRequireGoodITSLayersAll{"cfgRequireGoodITSLayersAll", false, "number of inactive chips on all ITS layers are below threshold "}; + } eventcuts; struct : ConfigurableGroup { std::string prefix = "electroncut_group"; @@ -94,48 +125,86 @@ struct CreateResolutionMap { Configurable cfg_min_eta_track{"cfg_min_eta_track", -1.5, "min eta for single track"}; Configurable cfg_max_eta_track{"cfg_max_eta_track", +1.5, "max eta for single track"}; Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; - Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 4, "min ncluster its"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; Configurable cfg_min_ncluster_itsib{"cfg_min_ncluster_itsib", 1, "min ncluster itsib"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 80, "min ncrossed rows"}; Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; Configurable cfg_min_tpc_cr_findable_ratio{"cfg_min_tpc_cr_findable_ratio", 0.8, "min. TPC Ncr/Nf ratio"}; Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; - Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.3, "max dca XY for single track in cm"}; - Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.3, "max dca Z for single track in cm"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1.0, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.0, "max dca Z for single track in cm"}; Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", false, "flag to require ITS ib 1st hit"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to include ITSsa tracks"}; + Configurable maxpt_itssa{"maxpt_itssa", 0.15, "max pt for ITSsa track"}; + Configurable maxMeanITSClusterSize{"maxMeanITSClusterSize", 16, "max x cos(lambda)"}; } electroncuts; struct : ConfigurableGroup { std::string prefix = "muoncut_group"; - Configurable cfg_track_type{"cfg_track_type", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.01, "min pT for single track"}; - Configurable cfg_min_eta_track{"cfg_min_eta_track", -5.5, "min eta for single track"}; - Configurable cfg_max_eta_track{"cfg_max_eta_track", -1.5, "max eta for single track"}; + Configurable cfg_min_eta_track_sa{"cfg_min_eta_track_sa", -5.5, "min eta for standalone muon track"}; + Configurable cfg_max_eta_track_sa{"cfg_max_eta_track_sa", -1.5, "max eta for standalone muon track"}; + Configurable cfg_min_eta_track_gl{"cfg_min_eta_track_gl", -5.5, "min eta for global muon track"}; + Configurable cfg_max_eta_track_gl{"cfg_max_eta_track_gl", -1.5, "max eta for global muon track"}; Configurable cfg_min_ncluster_mft{"cfg_min_ncluster_mft", 5, "min ncluster MFT"}; Configurable cfg_min_ncluster_mch{"cfg_min_ncluster_mch", 5, "min ncluster MCH"}; - Configurable cfg_max_chi2{"cfg_max_chi2", 1e+10, "max chi2/NclsTPC"}; - Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 1e+10, "max chi2 for MFT-MCH matching"}; + Configurable cfg_max_chi2_sa{"cfg_max_chi2_sa", 1e+10, "max chi2 for standalone muon track"}; + Configurable cfg_max_chi2_gl{"cfg_max_chi2_gl", 40, "max chi2 for standalone muon track"}; + Configurable cfg_max_matching_chi2_mftmch{"cfg_max_matching_chi2_mftmch", 40, "max chi2 for MFT-MCH matching"}; Configurable cfg_max_matching_chi2_mchmid{"cfg_max_matching_chi2_mchmid", 1e+10, "max chi2 for MCH-MID matching"}; - Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1e+10, "max dca XY for single track in cm"}; - Configurable cfg_min_rabs{"cfg_min_rabs", 17.6, "min Radius at the absorber end"}; - Configurable cfg_max_rabs{"cfg_max_rabs", 89.5, "max Radius at the absorber end"}; + Configurable cfg_max_dcaxy_gl{"cfg_max_dcaxy_gl", 0.1, "max dca XY for single track in cm"}; + Configurable cfg_min_rabs_sa{"cfg_min_rabs_sa", 17.6, "min Radius at the absorber end for standalone muon track"}; + Configurable cfg_max_rabs_sa{"cfg_max_rabs_sa", 89.5, "max Radius at the absorber end for standalone muon track"}; + Configurable cfg_min_rabs_gl{"cfg_min_rabs_gl", 27.6, "min Radius at the absorber end for global muon track"}; + Configurable cfg_max_rabs_gl{"cfg_max_rabs_gl", 89.5, "max Radius at the absorber end for global muon track"}; + Configurable cfg_mid_rabs{"cfg_mid_rabs", 26.5, "middle R at absorber end for pDCA cut"}; + Configurable cfg_max_pdca_forLargeR{"cfg_max_pdca_forLargeR", 324.f, "max. pDCA for large R at absorber end"}; + Configurable cfg_max_pdca_forSmallR{"cfg_max_pdca_forSmallR", 594.f, "max. pDCA for small R at absorber end"}; + Configurable cfg_max_reldpt{"cfg_max_reldpt", 1e+10f, "max. relative dpt between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_deta{"cfg_max_deta", 1e+10f, "max. deta between MFT-MCH-MID and MCH-MID"}; + Configurable cfg_max_dphi{"cfg_max_dphi", 1e+10f, "max. dphi between MFT-MCH-MID and MCH-MID"}; + Configurable refitGlobalMuon{"refitGlobalMuon", true, "flag to refit global muon"}; + Configurable requireMFTHitMap{"requireMFTHitMap", false, "flag to require MFT hit map"}; + Configurable> requiredMFTDisks{"requiredMFTDisks", std::vector{4}, "hit map on MFT disks [0,1,2,3,4]. logical-OR of each double-sided disk"}; } muoncuts; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + o2::aod::rctsel::RCTFlagsChecker rctCheckerCB; + o2::aod::rctsel::RCTFlagsChecker rctCheckerFWDSA; + o2::aod::rctsel::RCTFlagsChecker rctCheckerFWDGL; o2::ccdb::CcdbApi ccdbApi; Service ccdb; - o2::globaltracking::MatchGlobalFwd mMatching; int mRunNumber = 0; + float d_bz; + // o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + o2::dataformats::VertexBase mVtx; + const o2::dataformats::MeanVertexObject* mMeanVtx = nullptr; + o2::base::MatLayerCylSet* lut = nullptr; void init(o2::framework::InitContext&) { + if (doprocessElectronSA && doprocessElectronTTCA) { + LOGF(fatal, "Cannot enable processElectronSA and processElectronTTCA at the same time. Please choose one."); + } + + if (doprocessMuonSA && doprocessMuonTTCA) { + LOGF(fatal, "Cannot enable processMuonSA and processMuonTTCA at the same time. Please choose one."); + } + ccdb->setURL(ccdburl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); ccdbApi.init(ccdburl); + rctCheckerCB.init(cfgRCTLabelCB.value, cfgCheckZDC.value, cfgTreatLimitedAcceptanceAsBad.value); + rctCheckerFWDSA.init(cfgRCTLabelFWDSA.value, cfgCheckZDC.value, cfgTreatLimitedAcceptanceAsBad.value); + rctCheckerFWDGL.init(cfgRCTLabelFWDGL.value, cfgCheckZDC.value, cfgTreatLimitedAcceptanceAsBad.value); + + mRunNumber = 0; + d_bz = 0; const AxisSpec axis_cent{ConfCentBins, "centrality (%)"}; const AxisSpec axis_pt_gen{ConfPtGenBins, "p_{T,l}^{gen} (GeV/c)"}; @@ -147,17 +216,27 @@ struct CreateResolutionMap { const AxisSpec axis_dphi{ConfDeltaPhiBins, "#varphi_{l}^{gen} - #varphi_{l}^{rec} (rad.)"}; const AxisSpec axis_charge_gen{3, -1.5, +1.5, "true sign"}; - registry.add("Event/hImpPar_Centrality", "true imapact parameter vs. estimated centrality;impact parameter (fm);centrality (%)", kTH2F, {{200, 0, 20}, {110, 0, 110}}, true); - registry.add("Electron/Ptgen_RelDeltaPt", "resolution", kTH2F, {{axis_pt_gen}, {axis_dpt}}, true); - registry.add("Electron/Ptgen_DeltaEta", "resolution", kTH2F, {{axis_pt_gen}, {axis_deta}}, true); - registry.add("Electron/Ptgen_DeltaPhi_Pos", "resolution", kTH2F, {{axis_pt_gen}, {axis_dphi}}, true); - registry.add("Electron/Ptgen_DeltaPhi_Neg", "resolution", kTH2F, {{axis_pt_gen}, {axis_dphi}}, true); - registry.addClone("Electron/", "StandaloneMuon/"); - registry.addClone("Electron/", "GlobalMuon/"); - - registry.add("Electron/hs_reso", "8D resolution positive", kTHnSparseF, {axis_cent, axis_pt_gen, axis_eta_cb_gen, axis_phi_gen, axis_charge_gen, axis_dpt, axis_deta, axis_dphi}, true); - registry.add("StandaloneMuon/hs_reso", "8D resolution positive", kTHnSparseF, {axis_cent, axis_pt_gen, axis_eta_fwd_gen, axis_phi_gen, axis_charge_gen, axis_dpt, axis_deta, axis_dphi}, true); - registry.add("GlobalMuon/hs_reso", "8D resolution positive", kTHnSparseF, {axis_cent, axis_pt_gen, axis_eta_fwd_gen, axis_phi_gen, axis_charge_gen, axis_dpt, axis_deta, axis_dphi}, true); + // registry.add("Event/Electron/hImpPar_Centrality", "true imapact parameter vs. estimated centrality;impact parameter (fm);centrality (%)", kTH2F, {{200, 0, 20}, {110, 0, 110}}, true); + // registry.add("Event/Electron/hImpPar_Centrality", "true imapact parameter vs. estimated centrality;impact parameter (fm);centrality (%)", kTH2F, {{200, 0, 20}, {110, 0, 110}}, true); + if (doprocessGen) { + registry.add("Event/hGenID", "generator ID;generator ID;Number of mc collisions", kTH1F, {{7, -1.5, 5.5}}, true); + } + if (cfgFillTH2) { + registry.add("Electron/hPt", "rec. p_{T,l};p_{T,l} (GeV/c)", kTH1F, {{1000, 0, 10}}, false); + registry.add("Electron/hEtaPhi", "rec. #eta vs. #varphi;#varphi_{l} (rad.);#eta_{l}", kTH2F, {{90, 0, 2 * M_PI}, {100, -5, +5}}, false); + registry.add("Electron/Ptgen_RelDeltaPt", "resolution", kTH2F, {{axis_pt_gen}, {axis_dpt}}, true); + registry.add("Electron/Ptgen_DeltaEta", "resolution", kTH2F, {{axis_pt_gen}, {axis_deta}}, true); + registry.add("Electron/Ptgen_DeltaPhi_Pos", "resolution", kTH2F, {{axis_pt_gen}, {axis_dphi}}, true); + registry.add("Electron/Ptgen_DeltaPhi_Neg", "resolution", kTH2F, {{axis_pt_gen}, {axis_dphi}}, true); + registry.addClone("Electron/", "StandaloneMuon/"); + registry.addClone("Electron/", "GlobalMuon/"); + } + + if (cfgFillTHnSparse) { + registry.add("Electron/hs_reso", "8D resolution", kTHnSparseF, {axis_cent, axis_pt_gen, axis_eta_cb_gen, axis_phi_gen, axis_charge_gen, axis_dpt, axis_deta, axis_dphi}, true); + registry.add("StandaloneMuon/hs_reso", "8D resolution", kTHnSparseF, {axis_cent, axis_pt_gen, axis_eta_fwd_gen, axis_phi_gen, axis_charge_gen, axis_dpt, axis_deta, axis_dphi}, true); + registry.add("GlobalMuon/hs_reso", "8D resolution", kTHnSparseF, {axis_cent, axis_pt_gen, axis_eta_fwd_gen, axis_phi_gen, axis_charge_gen, axis_dpt, axis_deta, axis_dphi}, true); + } } void initCCDB(aod::BCsWithTimestamps::iterator const& bc) @@ -166,25 +245,154 @@ struct CreateResolutionMap { return; } + // load matLUT for this timestamp + if (!lut) { + LOG(info) << "Loading material look-up table for timestamp: " << bc.timestamp(); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(lutPath, bc.timestamp())); + } else { + LOG(info) << "Material look-up table already in place. Not reloading."; + } + + // In case override, don't proceed, please - no CCDB access required + if (d_bz_input > -990) { + d_bz = d_bz_input; + o2::parameters::GRPMagField grpmag; + if (std::fabs(d_bz) > 1e-5) { + grpmag.setL3Current(30000.f / (d_bz / 5.0f)); + } + o2::base::Propagator::initFieldFromGRP(&grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + mRunNumber = bc.runNumber(); + + if (!o2::base::GeometryManager::isGeometryLoaded()) { + ccdb->get(geoPath); + } + o2::mch::TrackExtrap::setField(); + return; + } + + auto run3grp_timestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = 0x0; + o2::parameters::GRPMagField* grpmag = 0x0; + if (!skipGRPOquery) { + grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + } + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + // Fetch magnetic field from ccdb for current collision + d_bz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + + // Fetch magnetic field from ccdb for current collision + d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } mRunNumber = bc.runNumber(); - std::map metadata; - auto soreor = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, mRunNumber); - auto ts = soreor.first; - auto grpmag = ccdbApi.retrieveFromTFileAny(grpmagPath, metadata, ts); - o2::base::Propagator::initFieldFromGRP(grpmag); + + // std::map metadata; + // auto soreor = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, mRunNumber); + // auto ts = soreor.first; + // auto grpmag = ccdbApi.retrieveFromTFileAny(grpmagPath, metadata, ts); + // o2::base::Propagator::initFieldFromGRP(grpmag); + if (!o2::base::GeometryManager::isGeometryLoaded()) { ccdb->get(geoPath); } o2::mch::TrackExtrap::setField(); } + template + bool isSelectedEvent(TCollision const& collision) + { + if (eventcuts.cfgRequireSel8 && !collision.sel8()) { + return false; + } + + if (collision.posZ() < eventcuts.cfgZvtxMin || eventcuts.cfgZvtxMax < collision.posZ()) { + return false; + } + + if (eventcuts.cfgRequireFT0AND && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + return false; + } + + if (eventcuts.cfgRequireNoTFB && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + + if (eventcuts.cfgRequireNoITSROFB && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + + if (eventcuts.cfgRequireNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + + if (eventcuts.cfgRequireGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + + if (!(eventcuts.cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { + return false; + } + + if (!(eventcuts.cfgFT0COccupancyMin <= collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) { + return false; + } + + // if (eventcuts.cfgRequireNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // return false; + // } + + // if (eventcuts.cfgRequireNoCollInTimeRangeStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + // return false; + // } + + // if (eventcuts.cfgRequirekNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + // return false; + // } + + // if (eventcuts.cfgRequirekNoCollInRofStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + // return false; + // } + + // if (eventcuts.cfgRequirekNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + // return false; + // } + + // if (eventcuts.cfgRequireGoodITSLayer3 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { + // return false; + // } + + // if (eventcuts.cfgRequireGoodITSLayer0123 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + // return false; + // } + + // if (eventcuts.cfgRequireGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // return false; + // } + + return true; + } + std::pair> itsRequirement_ibany = {1, {0, 1, 2}}; // any hits on 3 ITS ib layers. std::pair> itsRequirement_ib1st = {1, {0}}; // first hit on ITS ib layers. template - bool checkTrack(TTrack const& track) + bool isSelectedTrack(TTrack const& track) { - if (track.tpcChi2NCl() > electroncuts.cfg_max_chi2tpc) { + if (!track.hasITS()) { return false; } @@ -210,250 +418,519 @@ struct CreateResolutionMap { } } - if (track.tpcNClsFound() < electroncuts.cfg_min_ncluster_tpc) { + if (!electroncuts.includeITSsa && (!track.hasITS() || !track.hasTPC())) { return false; } - if (track.tpcNClsCrossedRows() < electroncuts.cfg_min_ncrossedrows) { + if (track.hasTPC()) { + if (track.tpcChi2NCl() > electroncuts.cfg_max_chi2tpc) { + return false; + } + + if (track.tpcNClsFound() < electroncuts.cfg_min_ncluster_tpc) { + return false; + } + + if (track.tpcNClsCrossedRows() < electroncuts.cfg_min_ncrossedrows) { + return false; + } + + if (track.tpcCrossedRowsOverFindableCls() < electroncuts.cfg_min_tpc_cr_findable_ratio) { + return false; + } + + if (track.tpcFractionSharedCls() > electroncuts.cfg_max_frac_shared_clusters_tpc) { + return false; + } + } + + return true; + } + + template + bool isSelectedTrackWithKine(TTrack const& track, const float pt, const float eta, const float tgl, const float dcaXY, const float dcaZ) + { + if (!isSelectedTrack(track)) { + return false; + } + + if (std::fabs(dcaXY) > electroncuts.cfg_max_dcaxy || std::fabs(dcaZ) > electroncuts.cfg_max_dcaz) { return false; } - if (track.tpcCrossedRowsOverFindableCls() < electroncuts.cfg_min_tpc_cr_findable_ratio) { + if (pt < electroncuts.cfg_min_pt_track || std::fabs(eta) > electroncuts.cfg_max_eta_track) { return false; } - if (track.tpcFractionSharedCls() > electroncuts.cfg_max_frac_shared_clusters_tpc) { + if ((track.hasITS() && !track.hasTPC() && !track.hasTOF() && !track.hasTRD()) && electroncuts.maxpt_itssa < pt) { return false; } + if (track.hasITS() && !track.hasTPC() && !track.hasTOF() && !track.hasTRD()) { // only for ITSsa + int total_cluster_size = 0, nl = 0; + for (unsigned int layer = 0; layer < 7; layer++) { + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); + if (cluster_size_per_layer > 0) { + nl++; + } + total_cluster_size += cluster_size_per_layer; + } + + if (electroncuts.maxMeanITSClusterSize < static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(tgl))) { + return false; + } + } + return true; } - template - o2::dataformats::GlobalFwdTrack PropagateMuon(T const& muon, C const& collision, const CreateResolutionMap::MuonExtrapolation endPoint) + template + void fillMuon(TCollision const& collision, TMuon const& muon, const float centrality) { - double chi2 = muon.chi2(); - SMatrix5 tpars(muon.x(), muon.y(), muon.phi(), muon.tgl(), muon.signed1Pt()); - std::vector v1{muon.cXX(), muon.cXY(), muon.cYY(), muon.cPhiX(), muon.cPhiY(), - muon.cPhiPhi(), muon.cTglX(), muon.cTglY(), muon.cTglPhi(), muon.cTglTgl(), - muon.c1PtX(), muon.c1PtY(), muon.c1PtPhi(), muon.c1PtTgl(), muon.c1Pt21Pt2()}; - SMatrix55 tcovs(v1.begin(), v1.end()); - o2::track::TrackParCovFwd fwdtrack{muon.z(), tpars, tcovs, chi2}; - o2::dataformats::GlobalFwdTrack propmuon; - - if (static_cast(muon.trackType()) > 2) { // MCH-MID or MCH standalone - o2::dataformats::GlobalFwdTrack track; - track.setParameters(tpars); - track.setZ(fwdtrack.getZ()); - track.setCovariances(tcovs); - auto mchTrack = mMatching.FwdtoMCH(track); - - if (endPoint == CreateResolutionMap::MuonExtrapolation::kToVertex) { - o2::mch::TrackExtrap::extrapToVertex(mchTrack, collision.posX(), collision.posY(), collision.posZ(), collision.covXX(), collision.covYY()); - } - if (endPoint == CreateResolutionMap::MuonExtrapolation::kToDCA) { - o2::mch::TrackExtrap::extrapToVertexWithoutBranson(mchTrack, collision.posZ()); - } - if (endPoint == CreateResolutionMap::MuonExtrapolation::kToRabs) { - o2::mch::TrackExtrap::extrapToZ(mchTrack, -505.); - } - - auto proptrack = mMatching.MCHtoFwd(mchTrack); - propmuon.setParameters(proptrack.getParameters()); - propmuon.setZ(proptrack.getZ()); - propmuon.setCovariances(proptrack.getCovariances()); - } else if (static_cast(muon.trackType()) < 2) { // MFT-MCH-MID - double centerMFT[3] = {0, 0, -61.4}; - o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); - auto Bz = field->getBz(centerMFT); // Get field at centre of MFT - auto geoMan = o2::base::GeometryManager::meanMaterialBudget(muon.x(), muon.y(), muon.z(), collision.posX(), collision.posY(), collision.posZ()); - auto x2x0 = static_cast(geoMan.meanX2X0); - fwdtrack.propagateToVtxhelixWithMCS(collision.posZ(), {collision.posX(), collision.posY()}, {collision.covXX(), collision.covYY()}, Bz, x2x0); - propmuon.setParameters(fwdtrack.getParameters()); - propmuon.setZ(fwdtrack.getZ()); - propmuon.setCovariances(fwdtrack.getCovariances()); - } - - v1.clear(); - v1.shrink_to_fit(); - - return propmuon; - } + auto mcparticle = muon.template mcParticle_as(); + if (std::abs(mcparticle.pdgCode()) != 13 || !(mcparticle.isPhysicalPrimary() || mcparticle.producedByGenerator())) { + return; + } + if (cfg_require_true_mc_collision_association && mcparticle.mcCollisionId() != collision.mcCollisionId()) { + return; + } + if (muon.trackType() != static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) && muon.trackType() != static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + return; + } + + if (muon.chi2MatchMCHMID() < 0.f) { // this should never happen. only for protection. + return; + } + o2::dataformats::GlobalFwdTrack propmuonAtPV = propagateMuon(muon, collision, propagationPoint::kToVertex); + o2::dataformats::GlobalFwdTrack propmuonAtDCA = propagateMuon(muon, collision, propagationPoint::kToDCA); - template - bool checkFwdTrack(TMuon const& muon, TCollision const& collision, const float centrality) - { - o2::dataformats::GlobalFwdTrack propmuonAtPV = PropagateMuon(muon, collision, CreateResolutionMap::MuonExtrapolation::kToVertex); float pt = propmuonAtPV.getPt(); float eta = propmuonAtPV.getEta(); float phi = propmuonAtPV.getPhi(); + o2::math_utils::bringTo02Pi(phi); - if (pt < muoncuts.cfg_min_pt_track) { - return false; - } + float dcaX = propmuonAtDCA.getX() - collision.posX(); + float dcaY = propmuonAtDCA.getY() - collision.posY(); + float dcaXY = std::sqrt(dcaX * dcaX + dcaY * dcaY); + + float rAtAbsorberEnd = muon.rAtAbsorberEnd(); // this works only for GlobalMuonTrack + float pDCA = muon.p() * dcaXY; + int nClustersMFT = 0; + float ptMatchedMCHMID = propmuonAtPV.getPt(); + float etaMatchedMCHMID = propmuonAtPV.getEta(); + float phiMatchedMCHMID = propmuonAtPV.getPhi(); + o2::math_utils::bringTo02Pi(phiMatchedMCHMID); + + if (muon.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) { + // mcparticle for global MFT-MCH-MID is identical to mcparticle of MCH-MID track. If not, mismatch. + const auto& mchtrack = muon.template matchMCHTrack_as(); // MCH-MID + const auto& mfttrack = muon.template matchMFTTrack_as(); // MFTsa + if (!mchtrack.has_mcParticle() || !mfttrack.has_mcParticle()) { + return; + } + auto mcparticle_MCHMID = mchtrack.template mcParticle_as(); + auto mcparticle_MFT = mfttrack.template mcParticle_as(); + if (mcparticle.globalIndex() != mcparticle_MCHMID.globalIndex()) { // this should not happen. this is only for protection. + return; + } + if (cfg_reject_fake_match_mft_mch && mcparticle.globalIndex() != mcparticle_MFT.globalIndex()) { // evaluate mismatch + return; + } - if (eta < muoncuts.cfg_min_eta_track || muoncuts.cfg_max_eta_track < eta) { - return false; - } + o2::dataformats::GlobalFwdTrack propmuonAtPV_Matched = propagateMuon(mchtrack, collision, propagationPoint::kToVertex); + ptMatchedMCHMID = propmuonAtPV_Matched.getPt(); + etaMatchedMCHMID = propmuonAtPV_Matched.getEta(); + phiMatchedMCHMID = propmuonAtPV_Matched.getPhi(); + o2::math_utils::bringTo02Pi(phiMatchedMCHMID); + o2::dataformats::GlobalFwdTrack propmuonAtDCA_Matched = propagateMuon(mchtrack, collision, propagationPoint::kToDCA); + float dcaX_Matched = propmuonAtDCA_Matched.getX() - collision.posX(); + float dcaY_Matched = propmuonAtDCA_Matched.getY() - collision.posY(); + float dcaXY_Matched = std::sqrt(dcaX_Matched * dcaX_Matched + dcaY_Matched * dcaY_Matched); + pDCA = mchtrack.p() * dcaXY_Matched; + nClustersMFT = mfttrack.nClusters(); + + if (nClustersMFT < muoncuts.cfg_min_ncluster_mft) { + return; + } + if (muon.chi2MatchMCHMFT() > muoncuts.cfg_max_matching_chi2_mftmch) { + return; + } + if (muoncuts.refitGlobalMuon) { + eta = mfttrack.eta(); + phi = mfttrack.phi(); + o2::math_utils::bringTo02Pi(phi); + pt = propmuonAtPV_Matched.getP() * std::sin(2.f * std::atan(std::exp(-eta))); + } - o2::math_utils::bringTo02Pi(phi); - if (phi < 0.f || 2.f * M_PI < phi) { - return false; - } + float dpt = (ptMatchedMCHMID - pt) / pt; + float deta = etaMatchedMCHMID - eta; + float dphi = phiMatchedMCHMID - phi; + o2::math_utils::bringToPMPi(dphi); + if (std::sqrt(std::pow(deta / muoncuts.cfg_max_deta, 2) + std::pow(dphi / muoncuts.cfg_max_dphi, 2)) > 1.f || std::fabs(dpt) > muoncuts.cfg_max_reldpt) { + return; + } - float rAtAbsorberEnd = muon.rAtAbsorberEnd(); - if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - o2::dataformats::GlobalFwdTrack propmuonAtRabs = PropagateMuon(muon, collision, CreateResolutionMap::MuonExtrapolation::kToRabs); + if (muoncuts.requireMFTHitMap) { + std::vector hasMFTs{hasMFT<0, 1>(mfttrack), hasMFT<2, 3>(mfttrack), hasMFT<4, 5>(mfttrack), hasMFT<6, 7>(mfttrack), hasMFT<8, 9>(mfttrack)}; + for (int i = 0; i < static_cast(muoncuts.requiredMFTDisks->size()); i++) { + if (!hasMFTs[muoncuts.requiredMFTDisks->at(i)]) { + return; + } + } + } + + } else if (muon.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) { + o2::dataformats::GlobalFwdTrack propmuonAtRabs = propagateMuon(muon, collision, propagationPoint::kToRabs); // this is necessary only for MuonStandaloneTrack float xAbs = propmuonAtRabs.getX(); float yAbs = propmuonAtRabs.getY(); rAtAbsorberEnd = std::sqrt(xAbs * xAbs + yAbs * yAbs); // Redo propagation only for muon tracks // propagation of MFT tracks alredy done in reconstruction + } else { + return; } - if (rAtAbsorberEnd < muoncuts.cfg_min_rabs || muoncuts.cfg_max_rabs < rAtAbsorberEnd) { - return false; + if (muon.nClusters() < muoncuts.cfg_min_ncluster_mch) { + return; } - if (rAtAbsorberEnd < 26.5) { - if (muon.pDca() > 594.f) { - return false; + if (!isSelectedMuon(pt, eta, rAtAbsorberEnd, pDCA, muon.chi2(), muon.trackType(), dcaXY)) { + return; + } + + if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + if (cfgRequireGoodRCT && !rctCheckerFWDSA.checkTable(collision)) { + return; } - } else { - if (muon.pDca() > 324.f) { - return false; + if (cfgFillTHnSparse) { + registry.fill(HIST("StandaloneMuon/hs_reso"), centrality, mcparticle.pt(), mcparticle.eta(), mcparticle.phi(), -mcparticle.pdgCode() / 13, (mcparticle.pt() - pt) / mcparticle.pt(), mcparticle.eta() - eta, mcparticle.phi() - phi); + } + + if (cfgFillTH2) { + registry.fill(HIST("StandaloneMuon/hPt"), pt); + registry.fill(HIST("StandaloneMuon/hEtaPhi"), phi, eta); + registry.fill(HIST("StandaloneMuon/Ptgen_RelDeltaPt"), mcparticle.pt(), (mcparticle.pt() - pt) / mcparticle.pt()); + registry.fill(HIST("StandaloneMuon/Ptgen_DeltaEta"), mcparticle.pt(), mcparticle.eta() - eta); + if (mcparticle.pdgCode() == -13) { // positive muon + registry.fill(HIST("StandaloneMuon/Ptgen_DeltaPhi_Pos"), mcparticle.pt(), mcparticle.phi() - phi); + } else if (mcparticle.pdgCode() == 13) { // negative muon + registry.fill(HIST("StandaloneMuon/Ptgen_DeltaPhi_Neg"), mcparticle.pt(), mcparticle.phi() - phi); + } + } + } else if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + if (cfgRequireGoodRCT && !rctCheckerFWDGL.checkTable(collision)) { + return; + } + if (cfgFillTHnSparse) { + registry.fill(HIST("GlobalMuon/hs_reso"), centrality, mcparticle.pt(), mcparticle.eta(), mcparticle.phi(), -mcparticle.pdgCode() / 13, (mcparticle.pt() - pt) / mcparticle.pt(), mcparticle.eta() - eta, mcparticle.phi() - phi); + } + if (cfgFillTH2) { + registry.fill(HIST("GlobalMuon/hPt"), pt); + registry.fill(HIST("GlobalMuon/hEtaPhi"), phi, eta); + registry.fill(HIST("GlobalMuon/Ptgen_RelDeltaPt"), mcparticle.pt(), (mcparticle.pt() - pt) / mcparticle.pt()); + registry.fill(HIST("GlobalMuon/Ptgen_DeltaEta"), mcparticle.pt(), mcparticle.eta() - eta); + if (mcparticle.pdgCode() == -13) { // positive muon + registry.fill(HIST("GlobalMuon/Ptgen_DeltaPhi_Pos"), mcparticle.pt(), mcparticle.phi() - phi); + } else if (mcparticle.pdgCode() == 13) { // negative muon + registry.fill(HIST("GlobalMuon/Ptgen_DeltaPhi_Neg"), mcparticle.pt(), mcparticle.phi() - phi); + } } } + return; + } - if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && muon.chi2MatchMCHMFT() > muoncuts.cfg_max_matching_chi2_mftmch) { + bool isSelectedMuon(const float pt, const float eta, const float rAtAbsorberEnd, const float pDCA, const float chi2, const uint8_t trackType, const float dcaXY) + { + if (pt < muoncuts.cfg_min_pt_track) { + return false; + } + if (rAtAbsorberEnd < muoncuts.cfg_min_rabs_sa || muoncuts.cfg_max_rabs_sa < rAtAbsorberEnd) { + return false; + } + if (rAtAbsorberEnd < muoncuts.cfg_mid_rabs ? pDCA > muoncuts.cfg_max_pdca_forSmallR : pDCA > muoncuts.cfg_max_pdca_forLargeR) { return false; } - auto mctrack = muon.template mcParticle_as(); - if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - registry.fill(HIST("StandaloneMuon/hs_reso"), centrality, mctrack.pt(), mctrack.eta(), mctrack.phi(), -mctrack.pdgCode() / 13, (mctrack.pt() - pt) / mctrack.pt(), mctrack.eta() - eta, mctrack.phi() - phi); - registry.fill(HIST("StandaloneMuon/Ptgen_RelDeltaPt"), mctrack.pt(), (mctrack.pt() - pt) / mctrack.pt()); - registry.fill(HIST("StandaloneMuon/Ptgen_DeltaEta"), mctrack.pt(), mctrack.eta() - eta); - if (mctrack.pdgCode() == -13) { // positive muon - registry.fill(HIST("StandaloneMuon/Ptgen_DeltaPhi_Pos"), mctrack.pt(), mctrack.phi() - phi); - } else if (mctrack.pdgCode() == 13) { // negative muon - registry.fill(HIST("StandaloneMuon/Ptgen_DeltaPhi_Neg"), mctrack.pt(), mctrack.phi() - phi); + if (trackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + if (eta < muoncuts.cfg_min_eta_track_gl || muoncuts.cfg_max_eta_track_gl < eta) { + return false; } - } else if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - registry.fill(HIST("GlobalMuon/hs_reso"), centrality, mctrack.pt(), mctrack.eta(), mctrack.phi(), -mctrack.pdgCode() / 13, (mctrack.pt() - pt) / mctrack.pt(), mctrack.eta() - eta, mctrack.phi() - phi); - registry.fill(HIST("GlobalMuon/Ptgen_RelDeltaPt"), mctrack.pt(), (mctrack.pt() - pt) / mctrack.pt()); - registry.fill(HIST("GlobalMuon/Ptgen_DeltaEta"), mctrack.pt(), mctrack.eta() - eta); - if (mctrack.pdgCode() == -13) { // positive muon - registry.fill(HIST("GlobalMuon/Ptgen_DeltaPhi_Pos"), mctrack.pt(), mctrack.phi() - phi); - } else if (mctrack.pdgCode() == 13) { // negative muon - registry.fill(HIST("GlobalMuon/Ptgen_DeltaPhi_Neg"), mctrack.pt(), mctrack.phi() - phi); + if (muoncuts.cfg_max_dcaxy_gl < dcaXY) { + return false; + } + if (chi2 < 0.f || muoncuts.cfg_max_chi2_gl < chi2) { + return false; + } + if (rAtAbsorberEnd < muoncuts.cfg_min_rabs_gl || muoncuts.cfg_max_rabs_gl < rAtAbsorberEnd) { + return false; + } + } else if (trackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + if (eta < muoncuts.cfg_min_eta_track_sa || muoncuts.cfg_max_eta_track_sa < eta) { + return false; + } + if (chi2 < 0.f || muoncuts.cfg_max_chi2_sa < chi2) { + return false; } + } else { + return false; } + return true; } + template + bool hasMFT(T const& track) + { + // logical-OR + uint64_t mftClusterSizesAndTrackFlags = track.mftClusterSizesAndTrackFlags(); + uint16_t clmap = 0; + for (unsigned int layer = begin; layer <= end; layer++) { + if ((mftClusterSizesAndTrackFlags >> (layer * 6)) & 0x3f) { + clmap |= (1 << layer); + } + } + return (clmap > 0); + } + SliceCache cache; Preslice perCollision_mid = o2::aod::track::collisionId; Preslice perCollision_fwd = o2::aod::fwdtrack::collisionId; - Filter collisionFilter = o2::aod::evsel::sel8 == true && nabs(o2::aod::collision::posZ) < 10.f; - using MyFilteredCollisions = soa::Filtered; - using MyFilteredCollisionsCent = soa::Filtered; + using MyCollisions = Join; + using MyCollision = MyCollisions::iterator; + + using MyTracks = soa::Join; + using MyTrack = MyTracks::iterator; - Filter trackFilter_mid = o2::aod::track::pt > electroncuts.cfg_min_pt_track&& electroncuts.cfg_min_eta_track < o2::aod::track::eta&& o2::aod::track::eta < electroncuts.cfg_max_eta_track&& o2::aod::track::tpcChi2NCl < electroncuts.cfg_max_chi2tpc&& o2::aod::track::itsChi2NCl < electroncuts.cfg_max_chi2its&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true && nabs(o2::aod::track::dcaXY) < electroncuts.cfg_max_dcaxy&& nabs(o2::aod::track::dcaZ) < electroncuts.cfg_max_dcaz; - using MyFilteredMCTracks = soa::Filtered; + using MyFwdTracks = soa::Join; + using MyFwdTrack = MyFwdTracks::iterator; - Partition sa_muons = o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack); // MCH-MID - Partition global_muons = o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack); // MFT-MCH-MID + using MyMFTTracks = soa::Join; + using MyMFTTrack = MyMFTTracks::iterator; - template - void process(TCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredMCTracks const& tracks, MyMCFwdTracks const&, aod::McCollisions const&, aod::McParticles const&) + template + void fillElectron(TCollision const& collision, TTrack const& track, const float centrality) { - for (auto& collision : collisions) { + if (cfgRequireGoodRCT && !rctCheckerCB.checkTable(collision)) { + return; + } + auto mcparticle = track.template mcParticle_as(); + + if (std::abs(mcparticle.pdgCode()) != 11 || !(mcparticle.isPhysicalPrimary() || mcparticle.producedByGenerator())) { + return; + } + if (cfg_reject_fake_match_its_tpc && o2::aod::pwgem::dilepton::utils::mcutil::hasFakeMatchITSTPC(track)) { + return; + } + if (cfg_require_true_mc_collision_association && mcparticle.mcCollisionId() != collision.mcCollisionId()) { + return; + } + + if (!isSelectedTrack(track)) { + return; + } + + o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(o2::track::PID::Electron); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + float pt = trackParCov.getPt(); + float eta = trackParCov.getEta(); + float phi = trackParCov.getPhi(); + o2::math_utils::bringTo02Pi(phi); + + if (!isSelectedTrackWithKine(track, pt, eta, trackParCov.getTgl(), dcaXY, dcaZ)) { + return; + } + + if (cfgFillTHnSparse) { + registry.fill(HIST("Electron/hs_reso"), centrality, mcparticle.pt(), mcparticle.eta(), mcparticle.phi(), -mcparticle.pdgCode() / 11, (mcparticle.pt() - pt) / mcparticle.pt(), mcparticle.eta() - eta, mcparticle.phi() - phi); + } + if (cfgFillTH2) { + registry.fill(HIST("Electron/hPt"), pt); + registry.fill(HIST("Electron/hEtaPhi"), phi, eta); + registry.fill(HIST("Electron/Ptgen_RelDeltaPt"), mcparticle.pt(), (mcparticle.pt() - pt) / mcparticle.pt()); + registry.fill(HIST("Electron/Ptgen_DeltaEta"), mcparticle.pt(), mcparticle.eta() - eta); + if (mcparticle.pdgCode() == -11) { // positron + registry.fill(HIST("Electron/Ptgen_DeltaPhi_Pos"), mcparticle.pt(), mcparticle.phi() - phi); + } else if (mcparticle.pdgCode() == 11) { // electron + registry.fill(HIST("Electron/Ptgen_DeltaPhi_Neg"), mcparticle.pt(), mcparticle.phi() - phi); + } + } + } + + void processElectronSA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::McCollisions const&, aod::McParticles const&) + { + for (const auto& collision : collisions) { auto bc = collision.template foundBC_as(); initCCDB(bc); - if (!collision.has_mcCollision()) { + if (!isSelectedEvent(collision)) { continue; } - auto mccollision = collision.template mcCollision_as(); - if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { + if (!collision.has_mcCollision()) { continue; } - float centrality = 105.f; - if constexpr (std::is_same_v, MyFilteredCollisionsCent>) { - centrality = std::array{collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}[cfgCentEstimator]; - } - - registry.fill(HIST("Event/hImpPar_Centrality"), mccollision.impactParameter(), centrality); + float centrality = std::array{collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}[cfgCentEstimator]; + // auto mccollision = collision.template mcCollision_as(); + // registry.fill(HIST("Event/Electron/hImpPar_Centrality"), mccollision.impactParameter(), centrality); auto tracks_per_coll = tracks.sliceBy(perCollision_mid, collision.globalIndex()); - for (auto& track : tracks_per_coll) { + for (const auto& track : tracks_per_coll) { if (!track.has_mcParticle()) { continue; } + auto mctrack = track.template mcParticle_as(); - if (mctrack.mcCollisionId() != collision.mcCollisionId()) { + auto mccollision_from_mctrack = mctrack.template mcCollision_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_mctrack.getSubGeneratorId() != cfgEventGeneratorType) { continue; } - if (abs(mctrack.pdgCode()) != 11 || !(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { + + fillElectron(collision, track, centrality); + } // end of track loop + } // end of collision loop + } + PROCESS_SWITCH(CreateResolutionMap, processElectronSA, "create resolution map for electron at midrapidity", true); + + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + void processElectronTTCA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const&, aod::TrackAssoc const& trackIndices, aod::McCollisions const&, aod::McParticles const&) + { + for (const auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + + if (!isSelectedEvent(collision)) { + continue; + } + + if (!collision.has_mcCollision()) { + continue; + } + + float centrality = std::array{collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}[cfgCentEstimator]; + // auto mccollision = collision.template mcCollision_as(); + // registry.fill(HIST("Event/Electron/hImpPar_Centrality"), mccollision.impactParameter(), centrality); + + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); + for (const auto& trackId : trackIdsThisCollision) { + auto track = trackId.template track_as(); + if (!track.has_mcParticle()) { continue; } - if (!checkTrack(track)) { + auto mctrack = track.template mcParticle_as(); + auto mccollision_from_mctrack = mctrack.template mcCollision_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_mctrack.getSubGeneratorId() != cfgEventGeneratorType) { continue; } + fillElectron(collision, track, centrality); + } // end of track loop + } // end of collision loop + } + PROCESS_SWITCH(CreateResolutionMap, processElectronTTCA, "create resolution map for electron at midrapidity", false); - registry.fill(HIST("Electron/hs_reso"), centrality, mctrack.pt(), mctrack.eta(), mctrack.phi(), -mctrack.pdgCode() / 11, (mctrack.pt() - track.pt()) / mctrack.pt(), mctrack.eta() - track.eta(), mctrack.phi() - track.phi()); - registry.fill(HIST("Electron/Ptgen_RelDeltaPt"), mctrack.pt(), (mctrack.pt() - track.pt()) / mctrack.pt()); - registry.fill(HIST("Electron/Ptgen_DeltaEta"), mctrack.pt(), mctrack.eta() - track.eta()); - if (mctrack.pdgCode() == -11) { // positron - registry.fill(HIST("Electron/Ptgen_DeltaPhi_Pos"), mctrack.pt(), mctrack.phi() - track.phi()); - } else if (mctrack.pdgCode() == 11) { // electron - registry.fill(HIST("Electron/Ptgen_DeltaPhi_Neg"), mctrack.pt(), mctrack.phi() - track.phi()); - } + Partition sa_muons = o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack); // MCH-MID + Partition global_muons = o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack); // MFT-MCH-MID - } // end of track loop + void processMuonSA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyFwdTracks const&, MyMFTTracks const&, aod::McCollisions const&, aod::McParticles const&) + { + for (const auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + + if (!isSelectedEvent(collision)) { + continue; + } + + if (!collision.has_mcCollision()) { + continue; + } + + float centrality = std::array{collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}[cfgCentEstimator]; + // auto mccollision = collision.template mcCollision_as(); + // registry.fill(HIST("Event/Muon/hImpPar_Centrality"), mccollision.impactParameter(), centrality); auto sa_muons_per_coll = sa_muons->sliceByCached(o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); auto global_muons_per_coll = global_muons->sliceByCached(o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); - for (auto& muon : sa_muons_per_coll) { + for (const auto& muon : sa_muons_per_coll) { if (!muon.has_mcParticle()) { continue; } + auto mctrack = muon.template mcParticle_as(); - if (mctrack.mcCollisionId() != collision.mcCollisionId()) { - continue; - } - if (abs(mctrack.pdgCode()) != 13 || !(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { - continue; - } - if (!checkFwdTrack(muon, collision, centrality)) { + auto mccollision_from_mctrack = mctrack.template mcCollision_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_mctrack.getSubGeneratorId() != cfgEventGeneratorType) { continue; } + fillMuon(collision, muon, centrality); } // end of standalone muon loop - for (auto& muon : global_muons_per_coll) { + for (const auto& muon : global_muons_per_coll) { if (!muon.has_mcParticle()) { continue; } auto mctrack = muon.template mcParticle_as(); - if (mctrack.mcCollisionId() != collision.mcCollisionId()) { + auto mccollision_from_mctrack = mctrack.template mcCollision_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_mctrack.getSubGeneratorId() != cfgEventGeneratorType) { continue; } - if (abs(mctrack.pdgCode()) != 13 || !(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { + fillMuon(collision, muon, centrality); + } // end of global muon loop + + } // end of collision loop + } + PROCESS_SWITCH(CreateResolutionMap, processMuonSA, "create resolution map for muon at forward rapidity", true); + + Preslice fwdtrackIndicesPerCollision = aod::track_association::collisionId; + void processMuonTTCA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyFwdTracks const&, MyMFTTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices, aod::McCollisions const&, aod::McParticles const&) + { + for (const auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + + if (!isSelectedEvent(collision)) { + continue; + } + + if (!collision.has_mcCollision()) { + continue; + } + + float centrality = std::array{collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}[cfgCentEstimator]; + // auto mccollision = collision.template mcCollision_as(); + // registry.fill(HIST("Event/Muon/hImpPar_Centrality"), mccollision.impactParameter(), centrality); + + auto fwdtrackIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); + for (const auto& fwdtrackId : fwdtrackIdsThisCollision) { + auto muon = fwdtrackId.template fwdtrack_as(); + if (!muon.has_mcParticle()) { continue; } - if (!checkFwdTrack(muon, collision, centrality)) { + auto mctrack = muon.template mcParticle_as(); + auto mccollision_from_mctrack = mctrack.template mcCollision_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_mctrack.getSubGeneratorId() != cfgEventGeneratorType) { continue; } - - } // end of global muon loop - + fillMuon(collision, muon, centrality); + } // end of fwdtrack loop } // end of collision loop } - PROCESS_SWITCH_FULL(CreateResolutionMap, process, processWithCent, "create resolution map wit centrality", true); - PROCESS_SWITCH_FULL(CreateResolutionMap, process, processWithoutCent, "create resolution map without centrality", false); + PROCESS_SWITCH(CreateResolutionMap, processMuonTTCA, "create resolution map for muon at forward rapidity", false); + + void processGen(aod::McCollisions const& mcCollisions) + { + for (const auto& mccollision : mcCollisions) { + registry.fill(HIST("Event/hGenID"), mccollision.getSubGeneratorId()); + } + } + PROCESS_SWITCH(CreateResolutionMap, processGen, "process generated info", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGEM/Dilepton/Tasks/dielectronHadronMPC.cxx b/PWGEM/Dilepton/Tasks/dielectronHadronMPC.cxx new file mode 100644 index 00000000000..42cfa2eac28 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/dielectronHadronMPC.cxx @@ -0,0 +1,27 @@ +// 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. +// +// ======================== +// +// This code is for dielectron analyses. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/Dilepton/Core/DileptonHadronMPC.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"dielectron-hadron-2pc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/dimuonHadronMPC.cxx b/PWGEM/Dilepton/Tasks/dimuonHadronMPC.cxx new file mode 100644 index 00000000000..2e0cf5f5e59 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/dimuonHadronMPC.cxx @@ -0,0 +1,27 @@ +// 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. +// +// ======================== +// +// This code is for dimuon analyses. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/Dilepton/Core/DileptonHadronMPC.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"dimuon-hadron-mpc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/eventQC.cxx b/PWGEM/Dilepton/Tasks/eventQC.cxx index 4708941587d..60ff83b2da1 100644 --- a/PWGEM/Dilepton/Tasks/eventQC.cxx +++ b/PWGEM/Dilepton/Tasks/eventQC.cxx @@ -14,29 +14,32 @@ // This code is for event QC for PWG-EM. // Please write to: daiki.sekihata@cern.ch -#include -#include -#include -#include -#include +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "TString.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" #include "Common/Core/RecoDecay.h" -#include "MathUtils/Utils.h" -#include "Framework/AnalysisDataModel.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Qvectors.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/Qvectors.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/Zorro.h" + #include "CCDB/BasicCCDBManager.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "MathUtils/Utils.h" + +#include "TString.h" + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -44,38 +47,46 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -using MyBCs = soa::Join; -using MyQvectors = soa::Join; +struct eventQC { + using MyBCs = soa::Join; + using MyQvectors = soa::Join; -using MyCollisions = soa::Join; -using MyCollisions_Qvec = soa::Join; + using MyCollisions = soa::Join; + using MyCollisions_Qvec = soa::Join; -using MyTracks = soa::Join; -using MyTrack = MyTracks::iterator; + using MyTracks = soa::Join; + using MyTrack = MyTracks::iterator; -struct eventQC { // Configurables Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable cfg_swt_name{"cfg_swt_name", "fHighTrackMult", "desired software trigger name"}; + Configurable cfgFillEvent{"cfgFillEvent", false, "fill event histograms"}; + Configurable cfgFillTrack{"cfgFillTrack", false, "fill track histograms"}; Configurable cfgFillPID{"cfgFillPID", false, "fill PID histograms"}; Configurable> cfgnMods{"cfgnMods", {2, 3}, "Modulation of interest. Please keep increasing order"}; Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; Configurable cfgQvecEstimator{"cfgQvecEstimator", 0, "FT0M:0, FT0A:1, FT0C:2, BTot:3, BPos:4, BNeg:5"}; Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; + Configurable cfgNtracksPV08Min{"cfgNtracksPV08Min", -1, "min. multNTracksPV"}; + Configurable cfgNtracksPV08Max{"cfgNtracksPV08Max", 1000000000, "max. multNTracksPV"}; ConfigurableAxis ConfPtBins{"ConfPtBins", {VARIABLE_WIDTH, 0.00, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.50, 3.00, 3.50, 4.00, 4.50, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00}, "pT bins for output histograms"}; Configurable cfgNbinsEta{"cfgNbinsEta", 20, "number of eta bins for output histograms"}; Configurable cfgNbinsPhi{"cfgNbinsPhi", 36, "number of phi bins for output histograms"}; struct : ConfigurableGroup { std::string prefix = "eventcut_group"; + Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; Configurable cfgRequireNoTFB{"cfgRequireNoTFB", true, "require No time frame border in event cut"}; Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", true, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireVertexTOFmatched{"cfgRequireVertexTOFmatched", false, "require Vertex TOFmatched in event cut"}; // ITS-TPC-TOF matched track contributes PV. Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. track occupancy"}; @@ -87,6 +98,9 @@ struct eventQC { Configurable cfgRequirekNoCollInRofStandard{"cfgRequirekNoCollInRofStandard", false, "require no other collisions in this Readout Frame with per-collision multiplicity above threshold"}; Configurable cfgRequirekNoCollInRofStrict{"cfgRequirekNoCollInRofStrict", false, "require no other collisions in this Readout Frame"}; Configurable cfgRequirekNoHighMultCollInPrevRof{"cfgRequirekNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + Configurable cfgRequireGoodITSLayer3{"cfgRequireGoodITSLayer3", false, "number of inactive chips on ITS layer 3 are below threshold "}; + Configurable cfgRequireGoodITSLayer0123{"cfgRequireGoodITSLayer0123", false, "number of inactive chips on ITS layers 0-3 are below threshold "}; + Configurable cfgRequireGoodITSLayersAll{"cfgRequireGoodITSLayersAll", false, "number of inactive chips on all ITS layers are below threshold "}; } eventcuts; struct : ConfigurableGroup { @@ -115,24 +129,19 @@ struct eventQC { Configurable cfg_requireTOF{"cfg_requireTOF", false, "require TOF hit"}; } trackcuts; - struct : ConfigurableGroup { - std::string prefix = "v0cut_group"; - Configurable cfg_min_mass_k0s{"cfg_min_mass_k0s", 0.49, "min mass for K0S"}; - Configurable cfg_max_mass_k0s{"cfg_max_mass_k0s", 0.50, "max mass for K0S"}; - Configurable cfg_min_cospa_k0s{"cfg_min_cospa_k0s", 0.999, "min mass for K0S"}; - Configurable cfg_max_v0dau_k0s{"cfg_max_v0dau_k0s", 1.0, "max mass for K0S"}; - Configurable cfg_min_cr2findable_ratio_tpc{"cfg_min_cr2findable_ratio_tpc", 0.8, "min. TPC Ncr/Nf ratio"}; - Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; - Configurable cfg_min_ncrossedrows_tpc{"cfg_min_ncrossedrows_tpc", 40, "min ncrossed rows"}; - Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; - Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; - Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; - Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -1e+10, "min n sigma e in TPC"}; - Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +1e+10, "max n sigma e in TPC"}; - Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -1e+10, "min n sigma pi in TPC"}; - Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +1e+10, "max n sigma pi in TPC"}; - } v0cuts; + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; + o2::aod::rctsel::RCTFlagsChecker rctChecker; + Zorro zorro; + std::vector mTOIidx; + uint64_t mNinspectedTVX{0}; + std::vector swt_names; + + int mRunNumber; Service ccdb; HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; @@ -140,23 +149,41 @@ struct eventQC { void init(InitContext&) { + mRunNumber = 0; ccdb->setURL(ccdburl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); + rctChecker.init(cfgRCTLabel.value, cfgCheckZDC.value, cfgTreatLimitedAcceptanceAsBad.value); + addhistograms(); - if (doprocessEventQC_V0_PID) { - addV0histograms(); - } } ~eventQC() {} + template + void initCCDB(TBC const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + + mTOIidx = zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), cfg_swt_name.value); + for (auto& idx : mTOIidx) { + LOGF(info, "Trigger of Interest : index = %d", idx); + } + mNinspectedTVX = zorro.getInspectedTVX()->GetBinContent(1); + LOGF(info, "total inspected TVX events = %d in run number %d", mNinspectedTVX, bc.runNumber()); + fRegistry.fill(HIST("hNInspectedTVX"), bc.runNumber(), mNinspectedTVX); + + mRunNumber = bc.runNumber(); + } + void addhistograms() { // event info - const int nbin_ev = 17; + const int nbin_ev = 20; auto hCollisionCounter = fRegistry.add("Event/before/hCollisionCounter", "collision counter;;Number of events", kTH1F, {{nbin_ev, 0.5, nbin_ev + 0.5}}, false); hCollisionCounter->GetXaxis()->SetBinLabel(1, "all"); hCollisionCounter->GetXaxis()->SetBinLabel(2, "FT0AND"); @@ -174,30 +201,60 @@ struct eventQC { hCollisionCounter->GetXaxis()->SetBinLabel(14, "NoCollInRofStandard"); hCollisionCounter->GetXaxis()->SetBinLabel(15, "NoCollInRofStrict"); hCollisionCounter->GetXaxis()->SetBinLabel(16, "NoHighMultCollInPrevRof"); - hCollisionCounter->GetXaxis()->SetBinLabel(17, "accepted"); - - fRegistry.add("Event/before/hZvtx", "vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); - fRegistry.add("Event/before/hMultNTracksPV", "hMultNTracksPV; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); - fRegistry.add("Event/before/hMultNTracksPVeta1", "hMultNTracksPVeta1; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); - fRegistry.add("Event/before/hMultFT0", "hMultFT0;mult. FT0A;mult. FT0C", kTH2F, {{200, 0, 200000}, {60, 0, 60000}}, false); - fRegistry.add("Event/before/hCentFT0A", "hCentFT0A;centrality FT0A (%)", kTH1F, {{110, 0, 110}}, false); - fRegistry.add("Event/before/hCentFT0C", "hCentFT0C;centrality FT0C (%)", kTH1F, {{110, 0, 110}}, false); - fRegistry.add("Event/before/hCentFT0M", "hCentFT0M;centrality FT0M (%)", kTH1F, {{110, 0, 110}}, false); - fRegistry.add("Event/before/hCentFT0CvsMultNTracksPV", "hCentFT0CvsMultNTracksPV;centrality FT0C (%);N_{track} to PV", kTH2F, {{100, 0, 100}, {600, 0, 6000}}, false); - fRegistry.add("Event/before/hMultFT0CvsMultNTracksPV", "hMultFT0CvsMultNTracksPV;mult. FT0C;N_{track} to PV", kTH2F, {{60, 0, 60000}, {600, 0, 6000}}, false); - fRegistry.add("Event/before/hMultFT0CvsOccupancy", "hMultFT0CvsOccupancy;mult. FT0C;N_{track} in time range", kTH2F, {{60, 0, 60000}, {200, 0, 20000}}, false); - fRegistry.add("Event/before/hNTracksPVvsOccupancy", "hNTracksPVvsOccupancy;N_{track} to PV;N_{track} in time range", kTH2F, {{600, 0, 6000}, {200, 0, 20000}}, false); - fRegistry.add("Event/before/hNGlobalTracksvsOccupancy", "hNGlobalTracksvsOccupancy;N_{track}^{global};N_{track} in time range", kTH2F, {{600, 0, 6000}, {200, 0, 20000}}, false); - fRegistry.add("Event/before/hNGlobalTracksPVvsOccupancy", "hNGlobalTracksPVvsOccupancy;N_{track}^{global} to PV;N_{track} in time range", kTH2F, {{600, 0, 6000}, {200, 0, 20000}}, false); - fRegistry.add("Event/before/hCorrOccupancy", "occupancy correlation;FT0C occupancy;track-based occupancy", kTH2F, {{200, 0, 200000}, {200, 0, 20000}}, false); + hCollisionCounter->GetXaxis()->SetBinLabel(17, "GoodITSLayer3"); + hCollisionCounter->GetXaxis()->SetBinLabel(18, "GoodITSLayer0123"); + hCollisionCounter->GetXaxis()->SetBinLabel(19, "GoodITSLayersAll"); + hCollisionCounter->GetXaxis()->SetBinLabel(nbin_ev, "accepted"); + + fRegistry.add("hNInspectedTVX", "N inspected TVX;run number;N_{TVX}", kTProfile, {{80000, 520000.5, 600000.5}}, true); + + const AxisSpec axis_cent_ft0m{{0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}, + "centrality FT0M (%)"}; + + const AxisSpec axis_cent_ft0a{{0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}, + "centrality FT0A (%)"}; + + const AxisSpec axis_cent_ft0c{{0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}, + "centrality FT0C (%)"}; + + if (cfgFillEvent) { + fRegistry.add("Event/before/hZvtx", "vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); + fRegistry.add("Event/before/hMultNTracksPV", "hMultNTracksPV; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); + fRegistry.add("Event/before/hMultNTracksPVeta1", "hMultNTracksPVeta1; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); + fRegistry.add("Event/before/hMultFT0", "hMultFT0;mult. FT0A;mult. FT0C", kTH2F, {{200, 0, 200000}, {60, 0, 60000}}, false); + fRegistry.add("Event/before/hCentFT0A", "hCentFT0A;centrality FT0A (%)", kTH1F, {{axis_cent_ft0a}}, false); + fRegistry.add("Event/before/hCentFT0C", "hCentFT0C;centrality FT0C (%)", kTH1F, {{axis_cent_ft0c}}, false); + fRegistry.add("Event/before/hCentFT0M", "hCentFT0M;centrality FT0M (%)", kTH1F, {{axis_cent_ft0m}}, false); + fRegistry.add("Event/before/hCentFT0CvsMultNTracksPV", "hCentFT0CvsMultNTracksPV;centrality FT0C (%);N_{track} to PV", kTH2F, {{100, 0, 100}, {600, 0, 6000}}, false); + fRegistry.add("Event/before/hMultFT0CvsMultNTracksPV", "hMultFT0CvsMultNTracksPV;mult. FT0C;N_{track} to PV", kTH2F, {{60, 0, 60000}, {600, 0, 6000}}, false); + fRegistry.add("Event/before/hMultFT0CvsOccupancy", "hMultFT0CvsOccupancy;mult. FT0C;N_{track} in time range", kTH2F, {{60, 0, 60000}, {200, 0, 20000}}, false); + fRegistry.add("Event/before/hNTracksPVvsOccupancy", "hNTracksPVvsOccupancy;N_{track} to PV;N_{track} in time range", kTH2F, {{600, 0, 6000}, {200, 0, 20000}}, false); + fRegistry.add("Event/before/hNGlobalTracksvsOccupancy", "hNGlobalTracksvsOccupancy;N_{track}^{global};N_{track} in time range", kTH2F, {{600, 0, 6000}, {200, 0, 20000}}, false); + fRegistry.add("Event/before/hNGlobalTracksPVvsOccupancy", "hNGlobalTracksPVvsOccupancy;N_{track}^{global} to PV;N_{track} in time range", kTH2F, {{600, 0, 6000}, {200, 0, 20000}}, false); + fRegistry.add("Event/before/hCorrOccupancy", "occupancy correlation;FT0C occupancy;track-based occupancy", kTH2F, {{200, 0, 200000}, {200, 0, 20000}}, false); + } fRegistry.addClone("Event/before/", "Event/after/"); - fRegistry.add("Event/after/hMultNGlobalTracks", "hMultNGlobalTracks; N_{track}^{global}", kTH1F, {{6001, -0.5, 6000.5}}, false); - fRegistry.add("Event/after/hCentFT0CvsMultNGlobalTracks", "hCentFT0CvsMultNGlobalTracks;centrality FT0C (%);N_{track}^{global}", kTH2F, {{100, 0, 100}, {600, 0, 6000}}, false); - fRegistry.add("Event/after/hMultFT0CvsMultNGlobalTracks", "hMultFT0CvsMultNGlobalTracks;mult. FT0C;N_{track}^{global}", kTH2F, {{60, 0, 60000}, {600, 0, 6000}}, false); - fRegistry.add("Event/after/hMultNGlobalTracksPV", "hMultNGlobalTracksPV; N_{track}^{global} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); - fRegistry.add("Event/after/hCentFT0CvsMultNGlobalTracksPV", "hCentFT0CvsMultNGlobalTracksPV;centrality FT0C (%);N_{track}^{global} to PV", kTH2F, {{100, 0, 100}, {600, 0, 6000}}, false); - fRegistry.add("Event/after/hMultFT0CvsMultNGlobalTracksPV", "hMultFT0CvsMultNGlobalTracksPV;mult. FT0C;N_{track}^{global} to PV", kTH2F, {{60, 0, 60000}, {600, 0, 6000}}, false); + if (cfgFillEvent) { + fRegistry.add("Event/after/hMultNGlobalTracks", "hMultNGlobalTracks; N_{track}^{global}", kTH1F, {{6001, -0.5, 6000.5}}, false); + fRegistry.add("Event/after/hCentFT0CvsMultNGlobalTracks", "hCentFT0CvsMultNGlobalTracks;centrality FT0C (%);N_{track}^{global}", kTH2F, {{100, 0, 100}, {600, 0, 6000}}, false); + fRegistry.add("Event/after/hMultFT0CvsMultNGlobalTracks", "hMultFT0CvsMultNGlobalTracks;mult. FT0C;N_{track}^{global}", kTH2F, {{60, 0, 60000}, {600, 0, 6000}}, false); + fRegistry.add("Event/after/hMultNGlobalTracksPV", "hMultNGlobalTracksPV; N_{track}^{global} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); + fRegistry.add("Event/after/hCentFT0CvsMultNGlobalTracksPV", "hCentFT0CvsMultNGlobalTracksPV;centrality FT0C (%);N_{track}^{global} to PV", kTH2F, {{100, 0, 100}, {600, 0, 6000}}, false); + fRegistry.add("Event/after/hMultFT0CvsMultNGlobalTracksPV", "hMultFT0CvsMultNGlobalTracksPV;mult. FT0C;N_{track}^{global} to PV", kTH2F, {{60, 0, 60000}, {600, 0, 6000}}, false); + } std::vector tmp_ptbins; for (int i = 0; i < 100; i++) { @@ -209,7 +266,7 @@ struct eventQC { const AxisSpec axis_pt_tmp{tmp_ptbins, "p_{T} (GeV/c)"}; const AxisSpec axis_pt{ConfPtBins, "p_{T} (GeV/c)"}; - const AxisSpec axis_eta{cfgNbinsEta, -1.0, +1.0, "#eta"}; + const AxisSpec axis_eta{cfgNbinsEta, -2.0, +2.0, "#eta"}; const AxisSpec axis_phi{cfgNbinsPhi, 0.0, 2 * M_PI, "#varphi (rad.)"}; const AxisSpec axis_sign{3, -1.5, +1.5, "sign"}; const AxisSpec axis_cent{20, 0, 100, "centrality FT0C (%)"}; @@ -268,33 +325,34 @@ struct eventQC { } } - fRegistry.add("Track/hs", "rec. single electron", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_sign}, false); - fRegistry.add("Track/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/hRelSigma1Pt", "relative p_{T} resolution;p_{T} (GeV/c);#sigma_{1/p_{T}} #times p_{T}", kTH2F, {axis_pt_tmp, {100, 0, 0.1}}, false); - fRegistry.add("Track/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); - fRegistry.add("Track/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); - fRegistry.add("Track/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {axis_pt_tmp, {500, 0., 500}}, false); - fRegistry.add("Track/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {axis_pt_tmp, {500, 0., 500}}, false); - fRegistry.add("Track/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/hDeltaPin", "p_{in} vs. p_{pv};p_{pv} (GeV/c);(p_{in} - p_{pv})/p_{pv}", kTH2F, {{1000, 0, 10}, {200, -1, +1}}, false); - fRegistry.add("Track/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/hTPCNclsShared", "TPC Ncls shared/Ncls;p_{T} (GeV/c);N_{cls}^{shared}/N_{cls} in TPC", kTH2F, {{1000, 0, 10}, {100, 0, 1}}, false); - fRegistry.add("Track/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("Track/hChi2TOF", "chi2 of TOF", kTH2F, {{1000, 0, 10}, {100, 0, 10}}, false); + if (cfgFillTrack) { + fRegistry.add("Track/hs", "rec. single electron", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_sign}, false); + fRegistry.add("Track/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{1000, -50, 50}}, false); + fRegistry.add("Track/hRelSigma1Pt", "relative p_{T} resolution;p_{T} (GeV/c);#sigma_{1/p_{T}} #times p_{T}", kTH2F, {axis_pt_tmp, {100, 0, 0.1}}, false); + fRegistry.add("Track/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); + fRegistry.add("Track/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); + fRegistry.add("Track/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {axis_pt_tmp, {500, 0., 500}}, false); + fRegistry.add("Track/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {axis_pt_tmp, {500, 0., 500}}, false); + fRegistry.add("Track/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); + fRegistry.add("Track/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); + fRegistry.add("Track/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/hDeltaPin", "p_{in} vs. p_{pv};p_{pv} (GeV/c);(p_{in} - p_{pv})/p_{pv}", kTH2F, {{1000, 0, 10}, {200, -1, +1}}, false); + fRegistry.add("Track/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/hTPCNclsShared", "TPC Ncls shared/Ncls;p_{T} (GeV/c);N_{cls}^{shared}/N_{cls} in TPC", kTH2F, {{1000, 0, 10}, {100, 0, 1}}, false); + fRegistry.add("Track/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); + fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); + fRegistry.add("Track/hChi2TOF", "chi2 of TOF", kTH2F, {{1000, 0, 10}, {100, 0, 10}}, false); + } if (cfgFillPID) { fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - + fRegistry.add("Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5.f, +5.f}}, false); + fRegistry.add("Track/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5.f, +5.f}}, false); + fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5.f, +5.f}}, false); + fRegistry.add("Track/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5.f, +5.f}}, false); + fRegistry.add("Track/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5.f, +5.f}}, false); fRegistry.add("Track/hTOFbeta", "TOF #beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, false); fRegistry.add("Track/hTOFNsigmaEl", "TOF n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/hTOFNsigmaMu", "TOF n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); @@ -303,67 +361,33 @@ struct eventQC { fRegistry.add("Track/hTOFNsigmaPr", "TOF n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); on ITS #times cos(#lambda);", kTH2F, {{1000, 0.f, 10.f}, {150, 0, 15}}, false); - fRegistry.add("Track/hITSNsigmaEl", "ITS n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hITSNsigmaMu", "ITS n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hITSNsigmaPi", "ITS n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hITSNsigmaKa", "ITS n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hITSNsigmaPr", "ITS n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{ITS}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - - fRegistry.add("Track/hTPCNsigmaKa_ITSNsigmaKa", "ITS vs. TPC n sigma ka in 0.4 < p_{in} < 0.7 (GeV/c);n #sigma_{K}^{TPC};n #sigma_{K}^{ITS}", kTH2F, {{100, -5, +5}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaPr_ITSNsigmaPr", "ITS vs. TPC n sigma pr in 0.8 < p_{in} < 1.4 (GeV/c);n #sigma_{p}^{TPC};n #sigma_{p}^{ITS}", kTH2F, {{100, -5, +5}, {100, -5, +5}}, false); } } - void addV0histograms() - { - fRegistry.add("V0/hAP", "AP plot", kTH2F, {{200, -1, +1}, {250, 0, 0.25}}, false); - fRegistry.add("V0/hPCA", "distance between 2 legs", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("V0/hCosPA", "cos pointing angle", kTH1F, {{100, 0.99, 1}}, false); - - fRegistry.add("V0/K0S/hMass", "mass vs. p_{T}", kTH2F, {{200, 0.4, 0.6}, {100, 0, 10}}, false); - fRegistry.add("V0/K0S/Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("V0/K0S/Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {200, -10, +10}}, false); - fRegistry.add("V0/K0S/Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {200, -10, +10}}, false); - - fRegistry.add("V0/Photon/hMass", "mass vs. p_{T}", kTH2F, {{100, 0, 0.1}, {100, 0, 10}}, false); - fRegistry.add("V0/Photon/hXY", "photon conversion point;X (cm);Y(cm)", kTH2F, {{400, -100, +100}, {400, -100, 100}}, false); - fRegistry.add("V0/Photon/Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("V0/Photon/Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {200, -10, +10}}, false); - fRegistry.add("V0/Photon/Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {200, -10, +10}}, false); - - // // extra info. Not important - // fRegistry.add("V0/Lambda/hMass", "mass vs. p_{T}", kTH2F, {{100, 1.08, 1.18}, {100, 0, 10}}, false); - // fRegistry.add("V0/AntiLambda/hMass", "mass vs. p_{T}", kTH2F, {{100, 1.08, 1.18}, {100, 0, 10}}, false); - } - template void fillTrackInfo(TTrack const& track) { - fRegistry.fill(HIST("Track/hs"), track.pt(), track.eta(), track.phi(), track.sign()); - fRegistry.fill(HIST("Track/hQoverPt"), track.signed1Pt()); - fRegistry.fill(HIST("Track/hRelSigma1Pt"), track.pt(), track.sigma1Pt() * track.pt()); - fRegistry.fill(HIST("Track/hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); - fRegistry.fill(HIST("Track/hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); - fRegistry.fill(HIST("Track/hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/hDeltaPin"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); - fRegistry.fill(HIST("Track/hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/hChi2TOF"), track.p(), track.tofChi2()); - + if (cfgFillTrack) { + fRegistry.fill(HIST("Track/hs"), track.pt(), track.eta(), track.phi(), track.sign()); + fRegistry.fill(HIST("Track/hQoverPt"), track.signed1Pt()); + fRegistry.fill(HIST("Track/hRelSigma1Pt"), track.pt(), track.sigma1Pt() * track.pt()); + fRegistry.fill(HIST("Track/hDCAxyz"), track.dcaXY(), track.dcaZ()); + fRegistry.fill(HIST("Track/hDCAxyzSigma"), track.dcaXY() / std::sqrt(track.cYY()), track.dcaZ() / std::sqrt(track.cZZ())); + fRegistry.fill(HIST("Track/hDCAxyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/hDCAzRes_Pt"), track.pt(), std::sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); + fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); + fRegistry.fill(HIST("Track/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); + fRegistry.fill(HIST("Track/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); + fRegistry.fill(HIST("Track/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); + fRegistry.fill(HIST("Track/hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/hDeltaPin"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + fRegistry.fill(HIST("Track/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); + fRegistry.fill(HIST("Track/hChi2TOF"), track.p(), track.tofChi2()); + } if (cfgFillPID) { - int nsize = 0; - for (int il = 0; il < 7; il++) { - nsize += track.itsClsSizeInLayer(il); - } - fRegistry.fill(HIST("Track/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); fRegistry.fill(HIST("Track/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); fRegistry.fill(HIST("Track/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); @@ -378,18 +402,11 @@ struct eventQC { fRegistry.fill(HIST("Track/hTOFNsigmaKa"), track.p(), track.tofNSigmaKa()); fRegistry.fill(HIST("Track/hTOFNsigmaPr"), track.p(), track.tofNSigmaPr()); - fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), track.p(), static_cast(nsize) / static_cast(track.itsNCls()) * std::cos(std::atan(track.tgl()))); - fRegistry.fill(HIST("Track/hITSNsigmaEl"), track.p(), track.itsNSigmaEl()); - fRegistry.fill(HIST("Track/hITSNsigmaMu"), track.p(), track.itsNSigmaMu()); - fRegistry.fill(HIST("Track/hITSNsigmaPi"), track.p(), track.itsNSigmaPi()); - fRegistry.fill(HIST("Track/hITSNsigmaKa"), track.p(), track.itsNSigmaKa()); - fRegistry.fill(HIST("Track/hITSNsigmaPr"), track.p(), track.itsNSigmaPr()); - - if (0.4 < track.tpcInnerParam() && track.tpcInnerParam() < 0.7) { - fRegistry.fill(HIST("Track/hTPCNsigmaKa_ITSNsigmaKa"), track.tpcNSigmaKa(), track.itsNSigmaKa()); - } else if (0.8 < track.tpcInnerParam() && track.tpcInnerParam() < 1.4) { - fRegistry.fill(HIST("Track/hTPCNsigmaPr_ITSNsigmaPr"), track.tpcNSigmaPr(), track.itsNSigmaPr()); + int nsize = 0; + for (int il = 0; il < 7; il++) { + nsize += track.itsClsSizeInLayer(il); } + fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), track.p(), static_cast(nsize) / static_cast(track.itsNCls()) * std::cos(std::atan(track.tgl()))); } } @@ -424,7 +441,7 @@ struct eventQC { if (collision.sel8()) { fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 10.0); } - if (fabs(collision.posZ()) < 10.0) { + if (std::fabs(collision.posZ()) < 10.0) { fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 11.0); } if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { @@ -442,6 +459,15 @@ struct eventQC { if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 16.0); } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 17.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 18.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 19.0); + } fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hZvtx"), collision.posZ()); fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultNTracksPV"), collision.multNTracksPV()); @@ -614,7 +640,7 @@ struct eventQC { { bool is_good = true; for (auto& qvec : qvectors) { - if (fabs(qvec[0]) > 20.f || fabs(qvec[1]) > 20.f) { + if (std::fabs(qvec[0]) > 20.f || std::fabs(qvec[1]) > 20.f) { is_good = false; break; } @@ -625,83 +651,77 @@ struct eventQC { template bool isSelectedTrack(TTrack const& track) { - if (track.itsNCls() < trackcuts.cfg_min_ncluster_its) { + if (!track.hasITS() || !track.hasTPC()) { return false; } - if (track.itsNClsInnerBarrel() < trackcuts.cfg_min_ncluster_itsib) { + if (track.pt() < trackcuts.cfg_min_pt_track || trackcuts.cfg_max_pt_track < track.pt()) { return false; } - if (track.tpcNClsFound() < trackcuts.cfg_min_ncluster_tpc) { + if (track.eta() < trackcuts.cfg_min_eta_track || trackcuts.cfg_max_eta_track < track.eta()) { return false; } - if (track.tpcNClsCrossedRows() < trackcuts.cfg_min_ncrossedrows_tpc) { + if (std::fabs(track.dcaXY()) > trackcuts.cfg_max_dcaxy) { return false; } - if (track.tpcCrossedRowsOverFindableCls() < trackcuts.cfg_min_cr2findable_ratio_tpc) { + if (std::fabs(track.dcaZ()) > trackcuts.cfg_max_dcaz) { return false; } - if (track.tpcFractionSharedCls() > trackcuts.cfg_max_frac_shared_clusters_tpc) { + if (track.itsChi2NCl() > trackcuts.cfg_max_chi2its) { return false; } - return true; - } - - template - bool isElectron(TTrack const& track) - { - if (track.tpcNSigmaEl() < trackcuts.cfg_min_TPCNsigmaEl || trackcuts.cfg_max_TPCNsigmaEl < track.tpcNSigmaEl()) { + if (track.itsNCls() < trackcuts.cfg_min_ncluster_its) { return false; } - if (trackcuts.cfg_min_TPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < trackcuts.cfg_max_TPCNsigmaPi) { + if (track.itsNClsInnerBarrel() < trackcuts.cfg_min_ncluster_itsib) { return false; } - if (trackcuts.cfg_requireTOF && !(track.hasTOF() && track.tofChi2() < trackcuts.cfg_max_chi2tof)) { + if (track.tpcChi2NCl() > trackcuts.cfg_max_chi2tpc) { return false; } - if (track.hasTOF() && ((track.tofNSigmaEl() < trackcuts.cfg_min_TOFNsigmaEl || trackcuts.cfg_max_TOFNsigmaEl < track.tofNSigmaEl()) || trackcuts.cfg_max_chi2tof < track.tofChi2())) { + if (track.tpcNClsFound() < trackcuts.cfg_min_ncluster_tpc) { return false; } - return true; - } - - template - bool isSelectedV0Leg(TTrack const& track) - { - if (!track.hasTPC()) { + if (track.tpcNClsCrossedRows() < trackcuts.cfg_min_ncrossedrows_tpc) { return false; } - if (track.hasITS() && track.itsChi2NCl() > v0cuts.cfg_max_chi2its) { + if (track.tpcCrossedRowsOverFindableCls() < trackcuts.cfg_min_cr2findable_ratio_tpc) { return false; } - if (track.tpcChi2NCl() > v0cuts.cfg_max_chi2tpc) { + if (track.tpcFractionSharedCls() > trackcuts.cfg_max_frac_shared_clusters_tpc) { return false; } - if (track.tpcNClsFound() < v0cuts.cfg_min_ncluster_tpc) { + return true; + } + + template + bool isElectron(TTrack const& track) + { + if (track.tpcNSigmaEl() < trackcuts.cfg_min_TPCNsigmaEl || trackcuts.cfg_max_TPCNsigmaEl < track.tpcNSigmaEl()) { return false; } - if (track.tpcNClsCrossedRows() < v0cuts.cfg_min_ncrossedrows_tpc) { + if (trackcuts.cfg_min_TPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < trackcuts.cfg_max_TPCNsigmaPi) { return false; } - if (track.tpcCrossedRowsOverFindableCls() < v0cuts.cfg_min_cr2findable_ratio_tpc) { + if (trackcuts.cfg_requireTOF && !(track.hasTOF() && track.tofChi2() < trackcuts.cfg_max_chi2tof)) { return false; } - if (track.tpcFractionSharedCls() > v0cuts.cfg_max_frac_shared_clusters_tpc) { + if (track.hasTOF() && ((track.tofNSigmaEl() < trackcuts.cfg_min_TOFNsigmaEl || trackcuts.cfg_max_TOFNsigmaEl < track.tofNSigmaEl()) || trackcuts.cfg_max_chi2tof < track.tofChi2())) { return false; } @@ -711,11 +731,11 @@ struct eventQC { template bool isSelectedEvent(TCollision const& collision) { - if (!collision.sel8()) { + if (eventcuts.cfgRequireSel8 && !collision.sel8()) { return false; } - if (fabs(collision.posZ()) > eventcuts.cfgZvtxMax) { + if (collision.posZ() < eventcuts.cfgZvtxMin || eventcuts.cfgZvtxMax < collision.posZ()) { return false; } @@ -731,6 +751,14 @@ struct eventQC { return false; } + if (eventcuts.cfgRequireVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + + if (eventcuts.cfgRequireVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if (eventcuts.cfgRequireNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { return false; } @@ -759,21 +787,34 @@ struct eventQC { return false; } + if (eventcuts.cfgRequireGoodITSLayer3 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { + return false; + } + + if (eventcuts.cfgRequireGoodITSLayer0123 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + return false; + } + + if (eventcuts.cfgRequireGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return false; + } + if (!(eventcuts.cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { return false; } - if (!(eventcuts.cfgFT0COccupancyMin < collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) { + if (!(eventcuts.cfgFT0COccupancyMin <= collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) { return false; } return true; } - Filter collisionFilter_evsel = o2::aod::evsel::sel8 == true && nabs(o2::aod::collision::posZ) < eventcuts.cfgZvtxMax; + Filter collisionFilter_evsel = o2::aod::evsel::sel8 == true && (eventcuts.cfgZvtxMin < o2::aod::collision::posZ && o2::aod::collision::posZ < eventcuts.cfgZvtxMax); Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); + Filter collisionFilter_multiplicity = cfgNtracksPV08Min <= o2::aod::mult::multNTracksPV && o2::aod::mult::multNTracksPV < cfgNtracksPV08Max; Filter collisionFilter_track_occupancy = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; - Filter collisionFilter_ft0c_occupancy = eventcuts.cfgFT0COccupancyMin < o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_ft0c_occupancy = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; using FilteredMyCollisions = soa::Filtered; using FilteredMyCollisions_Qvec = soa::Filtered; @@ -785,24 +826,39 @@ struct eventQC { SliceCache cache; Preslice perCol = o2::aod::track::collisionId; - Preslice perCol_pcm = o2::aod::v0photonkf::collisionId; - Preslice perCol_v0 = o2::aod::v0data::collisionId; - template - void runQC(TCollisions const& collisions, TTracks const& tracks, TV0Photons const& v0photons, TV0Legs const&, TV0StrHadrons const& v0strhadrons) + template + void runQC(TBCs const&, TCollisions const& collisions, TTracks const& tracks) { for (auto& collision : collisions) { + if constexpr (isTriggerAnalysis) { + const auto& bc = collision.template bc_as(); // don't use foundBC for CEFP. + initCCDB(bc); + if (!zorro.isSelected(bc.globalBC())) { // triggered event + continue; + } + } + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { continue; } - fillEventInfo<0>(collision); + + if (cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } + + if (cfgFillEvent) { + fillEventInfo<0>(collision); + } if (!isSelectedEvent(collision)) { continue; } - fillEventInfo<1>(collision); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 17); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 17); // accepted + if (cfgFillEvent) { + fillEventInfo<1>(collision); + } + fRegistry.fill(HIST("Event/before/hCollisionCounter"), 20); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), 20); // accepted int nGlobalTracks = 0, nGlobalTracksPV = 0; auto tracks_per_coll = tracks.sliceBy(perCol, collision.globalIndex()); @@ -813,7 +869,7 @@ struct eventQC { if (isElectron(track)) { fillTrackInfo(track); } - if (fabs(track.eta()) < 0.8) { + if (std::fabs(track.eta()) < 0.8) { nGlobalTracks++; if constexpr (std::is_same_v, FilteredMyCollisions_Qvec>) { @@ -830,105 +886,39 @@ struct eventQC { nGlobalTracksPV++; } } - } - - fRegistry.fill(HIST("Event/after/hMultNGlobalTracks"), nGlobalTracks); - fRegistry.fill(HIST("Event/after/hMultNGlobalTracksPV"), nGlobalTracksPV); - fRegistry.fill(HIST("Event/after/hMultFT0CvsMultNGlobalTracks"), collision.multFT0C(), nGlobalTracks); - fRegistry.fill(HIST("Event/after/hMultFT0CvsMultNGlobalTracksPV"), collision.multFT0C(), nGlobalTracksPV); - fRegistry.fill(HIST("Event/after/hNGlobalTracksvsOccupancy"), nGlobalTracks, collision.trackOccupancyInTimeRange()); - fRegistry.fill(HIST("Event/after/hNGlobalTracksPVvsOccupancy"), nGlobalTracksPV, collision.trackOccupancyInTimeRange()); - if constexpr (std::is_same_v, FilteredMyCollisions_Qvec>) { + } // end of track loop + + if (cfgFillEvent) { + fRegistry.fill(HIST("Event/after/hMultNGlobalTracks"), nGlobalTracks); + fRegistry.fill(HIST("Event/after/hMultNGlobalTracksPV"), nGlobalTracksPV); + fRegistry.fill(HIST("Event/after/hMultFT0CvsMultNGlobalTracks"), collision.multFT0C(), nGlobalTracks); + fRegistry.fill(HIST("Event/after/hMultFT0CvsMultNGlobalTracksPV"), collision.multFT0C(), nGlobalTracksPV); + fRegistry.fill(HIST("Event/after/hNGlobalTracksvsOccupancy"), nGlobalTracks, collision.trackOccupancyInTimeRange()); + fRegistry.fill(HIST("Event/after/hNGlobalTracksPVvsOccupancy"), nGlobalTracksPV, collision.trackOccupancyInTimeRange()); fRegistry.fill(HIST("Event/after/hCentFT0CvsMultNGlobalTracks"), collision.centFT0C(), nGlobalTracks); fRegistry.fill(HIST("Event/after/hCentFT0CvsMultNGlobalTracksPV"), collision.centFT0C(), nGlobalTracksPV); } - // for V0 PID - if constexpr (doV0s) { - auto v0hadrons_per_coll = v0strhadrons.sliceBy(perCol_v0, collision.globalIndex()); - for (auto& v0hadron : v0hadrons_per_coll) { - fRegistry.fill(HIST("V0/hAP"), v0hadron.alpha(), v0hadron.qtarm()); - fRegistry.fill(HIST("V0/hPCA"), v0hadron.dcaV0daughters()); - fRegistry.fill(HIST("V0/hCosPA"), v0hadron.v0cosPA()); - - fRegistry.fill(HIST("V0/K0S/hMass"), v0hadron.mK0Short(), v0hadron.pt()); - if (v0cuts.cfg_min_mass_k0s < v0hadron.mK0Short() && v0hadron.mK0Short() < v0cuts.cfg_max_mass_k0s) { - if (v0hadron.dcaV0daughters() > v0cuts.cfg_max_v0dau_k0s || v0hadron.v0cosPA() < v0cuts.cfg_min_cospa_k0s) { - continue; - } - - auto pos = v0hadron.template posTrack_as(); - auto neg = v0hadron.template negTrack_as(); - if (!isSelectedV0Leg(pos) || !isSelectedV0Leg(neg)) { - continue; - } - if (pos.tpcNSigmaPi() < v0cuts.cfg_min_TPCNsigmaPi || v0cuts.cfg_max_TPCNsigmaPi < pos.tpcNSigmaPi()) { - continue; - } - if (neg.tpcNSigmaPi() < v0cuts.cfg_min_TPCNsigmaPi || v0cuts.cfg_max_TPCNsigmaPi < neg.tpcNSigmaPi()) { - continue; - } - - fRegistry.fill(HIST("V0/K0S/Track/hTPCdEdx"), pos.tpcInnerParam(), pos.tpcSignal()); - fRegistry.fill(HIST("V0/K0S/Track/hTPCdEdx"), neg.tpcInnerParam(), neg.tpcSignal()); - fRegistry.fill(HIST("V0/K0S/Track/hTPCNsigmaEl"), pos.tpcInnerParam(), pos.tpcNSigmaEl()); - fRegistry.fill(HIST("V0/K0S/Track/hTPCNsigmaPi"), pos.tpcInnerParam(), pos.tpcNSigmaPi()); - fRegistry.fill(HIST("V0/K0S/Track/hTPCNsigmaEl"), neg.tpcInnerParam(), neg.tpcNSigmaEl()); - fRegistry.fill(HIST("V0/K0S/Track/hTPCNsigmaPi"), neg.tpcInnerParam(), neg.tpcNSigmaPi()); - } - } // end of v0hadron loop - - auto v0photons_per_coll = v0photons.sliceBy(perCol_pcm, collision.globalIndex()); - for (auto& v0photon : v0photons_per_coll) { - fRegistry.fill(HIST("V0/Photon/hMass"), v0photon.mGamma(), v0photon.pt()); - fRegistry.fill(HIST("V0/Photon/hXY"), v0photon.vx(), v0photon.vy()); - auto pos = v0photon.template posTrack_as(); - auto neg = v0photon.template negTrack_as(); - if (!isSelectedV0Leg(pos) || !isSelectedV0Leg(neg)) { - continue; - } - if (pos.tpcNSigmaEl() < v0cuts.cfg_min_TPCNsigmaEl || v0cuts.cfg_max_TPCNsigmaEl < pos.tpcNSigmaEl()) { - continue; - } - if (neg.tpcNSigmaEl() < v0cuts.cfg_min_TPCNsigmaEl || v0cuts.cfg_max_TPCNsigmaEl < neg.tpcNSigmaEl()) { - continue; - } - fRegistry.fill(HIST("V0/Photon/Track/hTPCdEdx"), pos.tpcInnerParam(), pos.tpcSignal()); - fRegistry.fill(HIST("V0/Photon/Track/hTPCdEdx"), neg.tpcInnerParam(), neg.tpcSignal()); - fRegistry.fill(HIST("V0/Photon/Track/hTPCNsigmaEl"), pos.tpcInnerParam(), pos.tpcNSigmaEl()); - fRegistry.fill(HIST("V0/Photon/Track/hTPCNsigmaPi"), pos.tpcInnerParam(), pos.tpcNSigmaPi()); - fRegistry.fill(HIST("V0/Photon/Track/hTPCNsigmaEl"), neg.tpcInnerParam(), neg.tpcNSigmaEl()); - fRegistry.fill(HIST("V0/Photon/Track/hTPCNsigmaPi"), neg.tpcInnerParam(), neg.tpcNSigmaPi()); - } // end of v0photon loop - - } // end of V0 PID } // end of collision loop } // end of process - void processEventQC(FilteredMyCollisions const& collisions, FilteredMyTracks const& tracks) + void processEventQC(MyBCs const& bcs, FilteredMyCollisions const& collisions, FilteredMyTracks const& tracks) { - auto tracksWithITSPid = soa::Attach(tracks); - runQC(collisions, tracksWithITSPid, nullptr, nullptr, nullptr); + runQC(bcs, collisions, tracks); } PROCESS_SWITCH(eventQC, processEventQC, "event QC", true); - void processEventQC_Cent_Qvec(FilteredMyCollisions_Qvec const& collisions, FilteredMyTracks const& tracks) + void processEventQC_SWT(MyBCs const& bcs, FilteredMyCollisions const& collisions, FilteredMyTracks const& tracks) { - auto tracksWithITSPid = soa::Attach(tracks); - runQC(collisions, tracksWithITSPid, nullptr, nullptr, nullptr); + runQC(bcs, collisions, tracks); } - PROCESS_SWITCH(eventQC, processEventQC_Cent_Qvec, "event QC + q vector", false); + PROCESS_SWITCH(eventQC, processEventQC_SWT, "event QC", false); - //! type of V0. 0: built solely for cascades (does not pass standard V0 cuts), 1: standard 2, 3: photon-like with TPC-only use. Regular analysis should always use type 1. - Filter v0Filter = o2::aod::v0data::v0Type == uint8_t(1); - using filteredV0s = soa::Filtered; - - void processEventQC_V0_PID(FilteredMyCollisions const& collisions, FilteredMyTracks const& tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, filteredV0s const& v0strhadrons) + void processEventQC_Cent_Qvec(MyBCs const& bcs, FilteredMyCollisions_Qvec const& collisions, FilteredMyTracks const& tracks) { - auto tracksWithITSPid = soa::Attach(tracks); - runQC(collisions, tracksWithITSPid, v0photons, v0legs, v0strhadrons); + runQC(bcs, collisions, tracks); } - PROCESS_SWITCH(eventQC, processEventQC_V0_PID, "event QC + V0 PID", false); + PROCESS_SWITCH(eventQC, processEventQC_Cent_Qvec, "event QC + q vector", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGEM/Dilepton/Tasks/lmeeHFCocktail.cxx b/PWGEM/Dilepton/Tasks/lmeeHFCocktail.cxx index 8e11295c810..d3bb410813f 100644 --- a/PWGEM/Dilepton/Tasks/lmeeHFCocktail.cxx +++ b/PWGEM/Dilepton/Tasks/lmeeHFCocktail.cxx @@ -76,7 +76,6 @@ const char* stageNames[Nstages] = {"gen", "meas", "meas_and_acc"}; template void doQuark(T& p, std::vector> hRapQuark, float ptMin, float etaMax, int pdg) { - float weight[Nstages] = {p.weight(), p.efficiency() * p.weight(), p.efficiency() * p.weight()}; float pt[Nstages] = {p.pt(), p.ptSmeared(), p.ptSmeared()}; float eta[Nstages] = {p.eta(), p.etaSmeared(), p.etaSmeared()}; float cut_pt[Nstages] = {0., 0., ptMin}; @@ -84,11 +83,11 @@ void doQuark(T& p, std::vector> hRapQuark, float ptMin, flo for (int i = 0; i < Nstages; i++) { if (pt[i] > cut_pt[i] && fabs(eta[i]) < cut_eta[i]) { if (pdg == 4) - hRapQuark[i]->Fill(p.cQuarkRap(), weight[i]); + hRapQuark[i]->Fill(p.cQuarkRap()); else if (pdg == 5) - hRapQuark[i]->Fill(p.bQuarkRap(), weight[i]); + hRapQuark[i]->Fill(p.bQuarkRap()); else - hRapQuark[i]->Fill(999., weight[i]); + hRapQuark[i]->Fill(999.); } } } @@ -161,26 +160,63 @@ struct MyConfigs : ConfigurableGroup { struct lmeehfcocktailprefilter { + HistogramRegistry registry{"registry", {}}; + std::vector> hRapQuark; Produces hfTable; + ConfigurableAxis fConfigRapBins{"cfgRapBins", {200, -10.f, 10.f}, "Quark rapidity binning"}; + + void init(o2::framework::InitContext&) + { + const int Nchannels = 2; + const char* typeNamesSingle[Nchannels] = {"b", "c"}; + const char* typeTitlesSingle[Nchannels] = {"b", "c"}; + + AxisSpec rap_axis = {fConfigRapBins, "y_{b}"}; + + // quark histograms + for (int i = 0; i < Nchannels; i++) { + hRapQuark.push_back(registry.add(Form("Quark_Rap_%s", typeNamesSingle[i]), Form("Rap Quark %s", typeTitlesSingle[i]), HistType::kTH1F, {rap_axis}, true)); + } + } + void process(aod::McParticles const& mcParticles) { for (auto const& p : mcParticles) { + // Look at quarks which fragment + if (abs(p.pdgCode()) == 5 || abs(p.pdgCode()) == 4) { + bool foundhadrons = kFALSE; + if (p.has_daughters()) { + const auto& daughtersSlice = p.daughters_as(); + for (auto& d : daughtersSlice) { + int pdgfragment = d.pdgCode(); + if (static_cast(abs(pdgfragment) / 100.) == abs(p.pdgCode()) || static_cast(abs(pdgfragment) / 1000.) == abs(p.pdgCode())) { + foundhadrons = kTRUE; + } + } + } + if (foundhadrons) { + if (abs(p.pdgCode()) == 4) + hRapQuark[1]->Fill(p.y()); + else if (abs(p.pdgCode()) == 5) + hRapQuark[0]->Fill(p.y()); + } + } + // Look at electrons if (abs(p.pdgCode()) != 11 || o2::mcgenstatus::getHepMCStatusCode(p.statusCode()) != 1 || !p.has_mothers()) { hfTable(EFromHFType::kNoE, -1, -1, -1, -1, -1, -1, -999., -999.); continue; } int mother_pdg = mcParticles.iteratorAt(p.mothersIds()[0]).pdgCode(); - bool direct_charm_mother = abs(mother_pdg) < 1e+9 && (std::to_string(mother_pdg)[std::to_string(mother_pdg).length() - 3] == '4' || std::to_string(mother_pdg)[std::to_string(mother_pdg).length() - 4] == '4'); - if (abs(mother_pdg) == 443) { - direct_charm_mother = false; // we don't want JPsi here - } + // Mother is an open-charm hadon (meson or baryon) expected to decay semi-leptonicly + bool direct_charm_mother = ((std::abs(mother_pdg) >= 400) && (std::abs(mother_pdg) <= 439)) || ((std::abs(mother_pdg) >= 4000) && (std::abs(mother_pdg) <= 4399)); int cHadronId = -1; if (direct_charm_mother) { cHadronId = p.mothersIds()[0]; } - bool direct_beauty_mother = abs(mother_pdg) < 1e+9 && (std::to_string(mother_pdg)[std::to_string(mother_pdg).length() - 3] == '5' || std::to_string(mother_pdg)[std::to_string(mother_pdg).length() - 4] == '5'); + // Mother is an open-beuaty hadron (meson or baryon) expected to decay semi-leptonicly + bool direct_beauty_mother = ((std::abs(mother_pdg) >= 500) && (std::abs(mother_pdg) <= 549)) || ((std::abs(mother_pdg) >= 5000) && (std::abs(mother_pdg) <= 5499)); int bHadronId = IsFromBeauty(p, mcParticles); int bQuarkId = -1; diff --git a/PWGEM/Dilepton/Tasks/matchingMFT.cxx b/PWGEM/Dilepton/Tasks/matchingMFT.cxx new file mode 100644 index 00000000000..c1deb69e52a --- /dev/null +++ b/PWGEM/Dilepton/Tasks/matchingMFT.cxx @@ -0,0 +1,666 @@ +// 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. + +/// \file matchingMFT.cxx +/// \brief a task to study matching MFT-[MCH-MID] in MC +/// \author daiki.sekihata@cern.ch + +#include "TableHelper.h" + +#include "Common/CCDB/RCTSelectionFlags.h" +#include "Common/Core/fwdtrackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/Propagator.h" +#include "Field/MagneticField.h" +#include "Framework/AnalysisTask.h" +#include "Framework/DataTypes.h" +#include "Framework/runDataProcessing.h" +#include "GlobalTracking/MatchGlobalFwd.h" +#include "MCHTracking/TrackExtrap.h" +#include "MCHTracking/TrackParam.h" +#include "ReconstructionDataFormats/TrackFwd.h" + +#include "TGeoGlobalMagField.h" + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::soa; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +using namespace o2::aod::fwdtrackutils; + +struct matchingMFT { + using MyCollisions = soa::Join; + using MyFwdTracks = soa::Join; + using MyMFTTracks = soa::Join; + + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable minPt{"minPt", 0.01, "min pt for muon"}; + Configurable maxPt{"maxPt", 1e+10, "max pt for muon"}; + Configurable minEtaSA{"minEtaSA", -4.0, "min. eta acceptance for MCH-MID"}; + Configurable maxEtaSA{"maxEtaSA", -2.5, "max. eta acceptance for MCH-MID"}; + Configurable minEtaGL{"minEtaGL", -3.6, "min. eta acceptance for MFT-MCH-MID"}; + Configurable maxEtaGL{"maxEtaGL", -2.5, "max. eta acceptance for MFT-MCH-MID"}; + Configurable minRabs{"minRabs", 17.6, "min. R at absorber end"}; + Configurable midRabs{"midRabs", 26.5, "middle R at absorber end for pDCA cut"}; + Configurable maxRabs{"maxRabs", 89.5, "max. R at absorber end"}; + Configurable maxDCAxy{"maxDCAxy", 1e+10, "max. DCAxy for global muons"}; + Configurable maxPDCAforLargeR{"maxPDCAforLargeR", 324.f, "max. pDCA for large R at absorber end"}; + Configurable maxPDCAforSmallR{"maxPDCAforSmallR", 594.f, "max. pDCA for small R at absorber end"}; + Configurable maxMatchingChi2MCHMFT{"maxMatchingChi2MCHMFT", 1e+10, "max. chi2 for MCH-MFT matching"}; + Configurable maxChi2SA{"maxChi2SA", 1e+6f, "max. chi2 for standalone muon"}; + Configurable maxChi2GL{"maxChi2GL", 1e+6f, "max. chi2 for global muon"}; + Configurable maxChi2MFT{"maxChi2MFT", 1e+6f, "max. chi2/ndf for MFT track in global muon"}; + Configurable minNclustersMFT{"minNclustersMFT", 5, "min nclusters MFT"}; + Configurable refitGlobalMuon{"refitGlobalMuon", true, "flag to refit global muon"}; + Configurable requireTrueAssociation{"requireTrueAssociation", false, "flag to require true mc collision association"}; + Configurable maxRelDPt{"maxRelDPt", 1e+10f, "max. relative dpt between MFT-MCH-MID and MCH-MID"}; + Configurable maxDEta{"maxDEta", 1e+10f, "max. deta between MFT-MCH-MID and MCH-MID"}; + Configurable maxDPhi{"maxDPhi", 1e+10f, "max. dphi between MFT-MCH-MID and MCH-MID"}; + Configurable requireMFTHitMap{"requireMFTHitMap", false, "flag to require MFT hit map"}; + Configurable> requiredMFTDisks{"requiredMFTDisks", std::vector{0}, "hit map on MFT disks [0,1,2,3,4]. logical-OR of each double-sided disk"}; + + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgCentMin{"cfgCentMin", -1.f, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; + Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; + Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_muon_glo", "select 1 [CBT_muon, CBT_muon_glo] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; + + o2::aod::rctsel::RCTFlagsChecker rctChecker; + + HistogramRegistry fRegistry{"fRegistry"}; + static constexpr std::string_view muon_types[5] = {"MFTMCHMID/", "MFTMCHMIDOtherMatch/", "MFTMCH/", "MCHMID/", "MCH/"}; + + void init(o2::framework::InitContext&) + { + if (doprocessWithoutFTTCA && doprocessWithFTTCA) { + LOGF(fatal, "Cannot enable doprocessWithoutFTTCA and doprocessWithFTTCA at the same time. Please choose one."); + } + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + ccdbApi.init(ccdburl); + rctChecker.init(cfgRCTLabel.value, cfgCheckZDC.value, cfgTreatLimitedAcceptanceAsBad.value); + + addHistograms(); + } + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber = -1; + + template + void initCCDB(TBC const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + LOGF(info, "mRunNumber = %d", mRunNumber); + std::map metadata; + auto soreor = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, mRunNumber); + auto ts = soreor.first; + auto grpmag = ccdbApi.retrieveFromTFileAny(grpmagPath, metadata, ts); + o2::base::Propagator::initFieldFromGRP(grpmag); + if (!o2::base::GeometryManager::isGeometryLoaded()) { + ccdb->get(geoPath); + } + o2::mch::TrackExtrap::setField(); + } + + void addHistograms() + { + auto hCollisionCounter = fRegistry.add("Event/hCollisionCounter", "collision counter", kTH1F, {{5, -0.5f, 4.5f}}, false); + hCollisionCounter->GetXaxis()->SetBinLabel(1, "all"); + hCollisionCounter->GetXaxis()->SetBinLabel(2, "accepted"); + + fRegistry.add("Event/hZvtx", "vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); + fRegistry.add("Event/hMultNTracksPV", "hMultNTracksPV; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); + fRegistry.add("Event/hMultNTracksPVeta1", "hMultNTracksPVeta1; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); + fRegistry.add("Event/hMultFT0", "hMultFT0;mult. FT0A;mult. FT0C", kTH2F, {{200, 0, 200000}, {60, 0, 60000}}, false); + fRegistry.add("Event/hCentFT0A", "hCentFT0A;centrality FT0A (%)", kTH1F, {{110, 0, 110}}, false); + fRegistry.add("Event/hCentFT0C", "hCentFT0C;centrality FT0C (%)", kTH1F, {{110, 0, 110}}, false); + fRegistry.add("Event/hCentFT0M", "hCentFT0M;centrality FT0M (%)", kTH1F, {{110, 0, 110}}, false); + fRegistry.add("Event/hCentFT0CvsMultNTracksPV", "hCentFT0CvsMultNTracksPV;centrality FT0C (%);N_{track} to PV", kTH2F, {{110, 0, 110}, {600, 0, 6000}}, false); + fRegistry.add("Event/hMultFT0CvsMultNTracksPV", "hMultFT0CvsMultNTracksPV;mult. FT0C;N_{track} to PV", kTH2F, {{60, 0, 60000}, {600, 0, 6000}}, false); + + auto hMuonType = fRegistry.add("hMuonType", "muon type", kTH1F, {{5, -0.5f, 4.5f}}, false); + hMuonType->GetXaxis()->SetBinLabel(1, "MFT-MCH-MID (global muon)"); + hMuonType->GetXaxis()->SetBinLabel(2, "MFT-MCH-MID (global muon other match)"); + hMuonType->GetXaxis()->SetBinLabel(3, "MFT-MCH"); + hMuonType->GetXaxis()->SetBinLabel(4, "MCH-MID"); + hMuonType->GetXaxis()->SetBinLabel(5, "MCH standalone"); + + const AxisSpec axis_pt{{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 3, 4, 5, 6, 7, 8, 9, 10}, "p_{T}^{gl} (GeV/c)"}; + + fRegistry.add("MFTMCHMID/primary/correct/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{100, 0.0f, 10}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {80, -5.f, -1.f}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hEtaPhi_MatchedMCHMID", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {80, -5.f, -1.f}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hsDelta", "diff. between GL and associated SA;p_{T}^{gl} (GeV/c);(p_{T}^{sa} - p_{T}^{gl})/p_{T}^{gl};#Delta#eta;#Delta#varphi (rad.);", kTHnSparseF, {axis_pt, {100, -0.5, +0.5}, {100, -0.5, +0.5}, {90, -M_PI / 4, M_PI / 4}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDiffCollId", "difference in collision index;collisionId_{TTCA} - collisionId_{MP}", kTH1F, {{41, -20.5, +20.5}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hSign", "sign;sign", kTH1F, {{3, -1.5, +1.5}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hNclusters", "Nclusters;Nclusters", kTH1F, {{21, -0.5f, 20.5}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hNclustersMFT", "NclustersMFT;Nclusters MFT", kTH1F, {{11, -0.5f, 10.5}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hMFTClusterMap", "MFT cluster map", kTH1F, {{1024, -0.5, 1023.5}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hRatAbsorberEnd", "R at absorber end;R at absorber end (cm)", kTH1F, {{100, 0.0f, 100}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hPDCA_Rabs", "pDCA vs. Rabs;R at absorber end (cm);p #times DCA (GeV/c #upoint cm)", kTH2F, {{100, 0, 100}, {100, 0.0f, 1000}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hChi2", "chi2;chi2/ndf", kTH1F, {{100, 0.0f, 10}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hChi2MFT", "chi2 MFT/ndf;chi2 MFT/ndf", kTH1F, {{100, 0.0f, 10}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hChi2MatchMCHMID", "chi2 match MCH-MID;chi2", kTH1F, {{100, 0.0f, 100}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hChi2MatchMCHMFT", "chi2 match MCH-MFT;chi2", kTH1F, {{100, 0.0f, 100}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDCAxy2D", "DCA x vs. y;DCA_{x} (cm);DCA_{y} (cm)", kTH2F, {{200, -0.5, 0.5}, {200, -0.5, +0.5}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDCAz", "DCA z;DCA_{z} (cm);", kTH1F, {{1000, 0, 10}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDCAxy2DinSigma", "DCA x vs. y in sigma;DCA_{x} (#sigma);DCA_{y} (#sigma)", kTH2F, {{200, -10, 10}, {200, -10, +10}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDCAxy", "DCAxy;DCA_{xy} (cm);", kTH1F, {{100, 0, 1}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDCAxyinSigma", "DCAxy in sigma;DCA_{xy} (#sigma);", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDCAxResolutionvsPt", "DCA_{x} resolution vs. p_{T};p_{T} (GeV/c);DCA_{x} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {500, 0, 500}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDCAyResolutionvsPt", "DCA_{y} resolution vs. p_{T};p_{T} (GeV/c);DCA_{y} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {500, 0, 500}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDCAxyResolutionvsPt", "DCA_{xy} resolution vs. p_{T};p_{T} (GeV/c);DCA_{xy} resolution (#mum);", kTH2F, {{100, 0, 10.f}, {500, 0, 500}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hMCHBitMap", "MCH bit map;MCH bit map", kTH1F, {{1024, -0.5, 1023.5}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hMIDBitMap", "MID bit map;MID bit map", kTH1F, {{256, -0.5, 255.5}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hMeanMFTClusterSize", "mean MFT cluster size vs. p;p (GeV/c); #times cos(#lambda)", kTH2F, {{100, 0, 100}, {100, 0, 1}}, false); + + fRegistry.add("MFTMCHMID/primary/correct/hProdVtxZ", "prod. vtx Z of muon;V_{z} (cm)", kTH1F, {{200, -100, 100}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hRelDeltaPt", "pT resolution;p_{T}^{gen} (GeV/c);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{100, 0, 10}, {400, -1, +1}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDeltaEta_Pos", "#eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{100, 0, 10}, {400, -0.2, +0.2}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDeltaEta_Neg", "#eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{100, 0, 10}, {400, -0.2, +0.2}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDeltaPhi_Pos", "#varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{100, 0, 10}, {400, -0.2, +0.2}}, false); + fRegistry.add("MFTMCHMID/primary/correct/hDeltaPhi_Neg", "#varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{100, 0, 10}, {400, -0.2, +0.2}}, false); + fRegistry.addClone("MFTMCHMID/primary/correct/", "MFTMCHMID/primary/wrong/"); + fRegistry.addClone("MFTMCHMID/primary/", "MFTMCHMID/secondary/"); + } + + bool isSelected(const float pt, const float eta, const float rAtAbsorberEnd, const float pDCA, const float chi2_per_ndf, const uint8_t trackType, const float dcaXY) + { + if (pt < minPt || maxPt < pt) { + return false; + } + if (rAtAbsorberEnd < minRabs || maxRabs < rAtAbsorberEnd) { + return false; + } + if (rAtAbsorberEnd < midRabs ? pDCA > maxPDCAforSmallR : pDCA > maxPDCAforLargeR) { + return false; + } + + if (trackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + if (eta < minEtaGL || maxEtaGL < eta) { + return false; + } + if (maxDCAxy < dcaXY) { + return false; + } + if (chi2_per_ndf < 0.f || maxChi2GL < chi2_per_ndf) { + return false; + } + } else if (trackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + if (eta < minEtaSA || maxEtaSA < eta) { + return false; + } + if (chi2_per_ndf < 0.f || maxChi2SA < chi2_per_ndf) { + return false; + } + } else { + return false; + } + + return true; + } + + template + uint16_t mftClusterMap(T const& track) + { + uint64_t mftClusterSizesAndTrackFlags = track.mftClusterSizesAndTrackFlags(); + uint16_t clmap = 0; + for (unsigned int layer = 0; layer < 10; layer++) { + if ((mftClusterSizesAndTrackFlags >> (layer * 6)) & 0x3f) { + clmap |= (1 << layer); + } + } + return clmap; + } + + template + bool hasMFT(T const& track) + { + // logical-OR + uint64_t mftClusterSizesAndTrackFlags = track.mftClusterSizesAndTrackFlags(); + uint16_t clmap = 0; + for (unsigned int layer = begin; layer <= end; layer++) { + if ((mftClusterSizesAndTrackFlags >> (layer * 6)) & 0x3f) { + clmap |= (1 << layer); + } + } + return (clmap > 0); + } + + template + float meanClusterSizeMFT(T const& track) + { + uint64_t mftClusterSizesAndTrackFlags = track.mftClusterSizesAndTrackFlags(); + uint16_t clsSize = 0; + uint16_t n = 0; + for (unsigned int layer = 0; layer < 10; layer++) { + uint16_t size_per_layer = (mftClusterSizesAndTrackFlags >> (layer * 6)) & 0x3f; + clsSize += size_per_layer; + if (size_per_layer > 0) { + n++; + } + // LOGF(info, "track.globalIndex() = %d, layer = %d, size_per_layer = %d", track.globalIndex(), layer, size_per_layer); + } + + if (n > 0) { + return static_cast(clsSize) / static_cast(n) * std::cos(std::atan(track.tgl())); + } else { + return 0.f; + } + } + + template + void fillHistograms(TCollision const& collision, TFwdTrack fwdtrack, TFwdTracks const&, TMFTTracks const&) + { + const auto& mchtrack = fwdtrack.template matchMCHTrack_as(); // MCH-MID + const auto& mfttrack = fwdtrack.template matchMFTTrack_as(); + + if (!fwdtrack.has_mcParticle() || !mchtrack.has_mcParticle() || !mfttrack.has_mcParticle()) { + return; + } + + const auto& mcParticle_MFTMCHMID = fwdtrack.template mcParticle_as(); // this is identical to mcParticle_MCHMID + const auto& mcParticle_MCHMID = mchtrack.template mcParticle_as(); // this is identical to mcParticle_MFTMCHMID + const auto& mcParticle_MFT = mfttrack.template mcParticle_as(); + // LOGF(info, "mcParticle_MFTMCHMID.pdgCode() = %d, mcParticle_MCHMID.pdgCode() = %d, mcParticle_MFT.pdgCode() = %d", mcParticle_MFTMCHMID.pdgCode(), mcParticle_MCHMID.pdgCode(), mcParticle_MFT.pdgCode()); + // LOGF(info, "mcParticle_MFTMCHMID.globalIndex() = %d, mcParticle_MCHMID.globalIndex() = %d, mcParticle_MFT.globalIndex() = %d", mcParticle_MFTMCHMID.globalIndex(), mcParticle_MCHMID.globalIndex(), mcParticle_MFT.globalIndex()); + + int nClustersMFT = mfttrack.nClusters(); + float chi2mft = mfttrack.chi2() / (2.f * nClustersMFT - 5.f); + if (chi2mft < 0.f || maxChi2MFT < chi2mft) { + return; + } + + if (fwdtrack.chi2MatchMCHMFT() > maxMatchingChi2MCHMFT) { + return; + } + + if (fwdtrack.chi2() < 0.f || maxChi2GL < fwdtrack.chi2() / (2.f * (mchtrack.nClusters() + nClustersMFT) - 5.f)) { + return; + } + + if (fwdtrack.rAtAbsorberEnd() < minRabs || maxRabs < fwdtrack.rAtAbsorberEnd()) { + return; + } + + if (nClustersMFT < minNclustersMFT) { + return; + } + + if (std::abs(mcParticle_MCHMID.pdgCode()) != 13) { // select true muon + return; + } + + if (requireTrueAssociation && (mcParticle_MCHMID.mcCollisionId() != collision.mcCollisionId())) { + return; + } + + bool isPrimary = mcParticle_MCHMID.isPhysicalPrimary() || mcParticle_MCHMID.producedByGenerator(); + bool isMatched = (mcParticle_MFT.globalIndex() == mcParticle_MCHMID.globalIndex()) && (mcParticle_MFT.mcCollisionId() == mcParticle_MCHMID.mcCollisionId()); + + o2::dataformats::GlobalFwdTrack propmuonAtPV = propagateMuon(fwdtrack, collision, propagationPoint::kToVertex); + o2::dataformats::GlobalFwdTrack propmuonAtDCA = propagateMuon(fwdtrack, collision, propagationPoint::kToDCA); + + float p = propmuonAtPV.getP(); + float pt = propmuonAtPV.getPt(); + float eta = propmuonAtPV.getEta(); + float phi = propmuonAtPV.getPhi(); + o2::math_utils::bringTo02Pi(phi); + + float cXXatDCA = propmuonAtDCA.getSigma2X(); + float cYYatDCA = propmuonAtDCA.getSigma2Y(); + float cXYatDCA = propmuonAtDCA.getSigmaXY(); + + float dcaX = propmuonAtDCA.getX() - collision.posX(); + float dcaY = propmuonAtDCA.getY() - collision.posY(); + float rAtAbsorberEnd = fwdtrack.rAtAbsorberEnd(); // this works only for GlobalMuonTrack + float dcaXY = std::sqrt(dcaX * dcaX + dcaY * dcaY); + float dcaZ = -dcaXY * std::sinh(eta); + float det = cXXatDCA * cYYatDCA - cXYatDCA * cXYatDCA; // determinanat + + float dcaXYinSigma = 999.f; + if (det < 0) { + dcaXYinSigma = 999.f; + } else { + dcaXYinSigma = std::sqrt(std::fabs((dcaX * dcaX * cYYatDCA + dcaY * dcaY * cXXatDCA - 2. * dcaX * dcaY * cXYatDCA) / det / 2.)); // dca xy in sigma + } + float sigma_dcaXY = dcaXY / dcaXYinSigma; + + o2::dataformats::GlobalFwdTrack propmuonAtDCA_Matched = propagateMuon(mchtrack, collision, propagationPoint::kToDCA); + float dcaX_Matched = propmuonAtDCA_Matched.getX() - collision.posX(); + float dcaY_Matched = propmuonAtDCA_Matched.getY() - collision.posY(); + float dcaXY_Matched = std::sqrt(dcaX_Matched * dcaX_Matched + dcaY_Matched * dcaY_Matched); + float pDCA = mchtrack.p() * dcaXY_Matched; + + o2::dataformats::GlobalFwdTrack propmuonAtPV_Matched = propagateMuon(mchtrack, collision, propagationPoint::kToVertex); + if (refitGlobalMuon) { + eta = mfttrack.eta(); + phi = mfttrack.phi(); + o2::math_utils::bringTo02Pi(phi); + pt = propmuonAtPV_Matched.getP() * std::sin(2.f * std::atan(std::exp(-eta))); + p = propmuonAtPV_Matched.getP(); + } + + float ptMatchedMCHMID = propmuonAtPV_Matched.getPt(); + float etaMatchedMCHMID = propmuonAtPV_Matched.getEta(); + float phiMatchedMCHMID = propmuonAtPV_Matched.getPhi(); + o2::math_utils::bringTo02Pi(phiMatchedMCHMID); + float dpt = (ptMatchedMCHMID - pt) / pt; + float deta = etaMatchedMCHMID - eta; + float dphi = phiMatchedMCHMID - phi; + o2::math_utils::bringToPMPi(dphi); + if (std::sqrt(std::pow(deta / maxDEta, 2) + std::pow(dphi / maxDPhi, 2)) > 1.f || std::fabs(dpt) > maxRelDPt) { + return; + } + + if (!isSelected(pt, eta, rAtAbsorberEnd, pDCA, fwdtrack.chi2() / (2.f * (mchtrack.nClusters() + nClustersMFT) - 5.f), fwdtrack.trackType(), dcaXY)) { + return; + } + + if (requireMFTHitMap) { + std::vector hasMFTs{hasMFT<0, 1>(mfttrack), hasMFT<2, 3>(mfttrack), hasMFT<4, 5>(mfttrack), hasMFT<6, 7>(mfttrack), hasMFT<8, 9>(mfttrack)}; + for (int i = 0; i < static_cast(requiredMFTDisks->size()); i++) { + if (!hasMFTs[requiredMFTDisks->at(i)]) { + return; + } + } + } + + fRegistry.fill(HIST("hMuonType"), fwdtrack.trackType()); + if (isPrimary) { + if (isMatched) { + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hPt"), pt); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hEtaPhi"), phi, eta); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hEtaPhi_MatchedMCHMID"), phiMatchedMCHMID, etaMatchedMCHMID); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hsDelta"), pt, dpt, deta, dphi); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDiffCollId"), collision.globalIndex() - fwdtrack.collisionId()); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hSign"), fwdtrack.sign()); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hNclusters"), fwdtrack.nClusters()); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hNclustersMFT"), nClustersMFT); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hMFTClusterMap"), mftClusterMap(mfttrack)); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hPDCA_Rabs"), rAtAbsorberEnd, pDCA); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hRatAbsorberEnd"), rAtAbsorberEnd); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hChi2"), fwdtrack.chi2() / (2.f * (fwdtrack.nClusters() + nClustersMFT) - 5.f)); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hChi2MFT"), chi2mft); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hChi2MatchMCHMID"), fwdtrack.chi2MatchMCHMID()); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hChi2MatchMCHMFT"), fwdtrack.chi2MatchMCHMFT()); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDCAxy2D"), dcaX, dcaY); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDCAz"), dcaZ); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDCAxy2DinSigma"), dcaX / std::sqrt(cXXatDCA), dcaY / std::sqrt(cYYatDCA)); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDCAxy"), dcaXY); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDCAxyinSigma"), dcaXYinSigma); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hMCHBitMap"), fwdtrack.mchBitMap()); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hMIDBitMap"), fwdtrack.midBitMap()); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hMeanMFTClusterSize"), p, meanClusterSizeMFT(mfttrack)); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDCAxResolutionvsPt"), pt, std::sqrt(cXXatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDCAyResolutionvsPt"), pt, std::sqrt(cYYatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDCAxyResolutionvsPt"), pt, sigma_dcaXY * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hProdVtxZ"), mcParticle_MFTMCHMID.vz()); + + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hRelDeltaPt"), mcParticle_MFTMCHMID.pt(), (pt - mcParticle_MFTMCHMID.pt()) / mcParticle_MFTMCHMID.pt()); + if (mcParticle_MFTMCHMID.pdgCode() > 0) { + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDeltaEta_Neg"), mcParticle_MFTMCHMID.pt(), eta - mcParticle_MFTMCHMID.eta()); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDeltaPhi_Neg"), mcParticle_MFTMCHMID.pt(), phi - mcParticle_MFTMCHMID.phi()); + } else { + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDeltaEta_Pos"), mcParticle_MFTMCHMID.pt(), eta - mcParticle_MFTMCHMID.eta()); + fRegistry.fill(HIST("MFTMCHMID/primary/correct/hDeltaPhi_Pos"), mcParticle_MFTMCHMID.pt(), phi - mcParticle_MFTMCHMID.phi()); + } + } else { + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hPt"), pt); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hEtaPhi"), phi, eta); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hEtaPhi_MatchedMCHMID"), phiMatchedMCHMID, etaMatchedMCHMID); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hsDelta"), pt, dpt, deta, dphi); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDiffCollId"), collision.globalIndex() - fwdtrack.collisionId()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hSign"), fwdtrack.sign()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hNclusters"), fwdtrack.nClusters()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hNclustersMFT"), nClustersMFT); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hMFTClusterMap"), mftClusterMap(mfttrack)); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hPDCA_Rabs"), rAtAbsorberEnd, pDCA); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hRatAbsorberEnd"), rAtAbsorberEnd); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hChi2"), fwdtrack.chi2() / (2.f * (fwdtrack.nClusters() + nClustersMFT) - 5.f)); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hChi2MFT"), chi2mft); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hChi2MatchMCHMID"), fwdtrack.chi2MatchMCHMID()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hChi2MatchMCHMFT"), fwdtrack.chi2MatchMCHMFT()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDCAxy2D"), dcaX, dcaY); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDCAz"), dcaZ); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDCAxy2DinSigma"), dcaX / std::sqrt(cXXatDCA), dcaY / std::sqrt(cYYatDCA)); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDCAxy"), dcaXY); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDCAxyinSigma"), dcaXYinSigma); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hMCHBitMap"), fwdtrack.mchBitMap()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hMIDBitMap"), fwdtrack.midBitMap()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hMeanMFTClusterSize"), p, meanClusterSizeMFT(mfttrack)); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDCAxResolutionvsPt"), pt, std::sqrt(cXXatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDCAyResolutionvsPt"), pt, std::sqrt(cYYatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDCAxyResolutionvsPt"), pt, sigma_dcaXY * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hProdVtxZ"), mcParticle_MFTMCHMID.vz()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hRelDeltaPt"), mcParticle_MFTMCHMID.pt(), (pt - mcParticle_MFTMCHMID.pt()) / mcParticle_MFTMCHMID.pt()); + if (mcParticle_MFTMCHMID.pdgCode() > 0) { + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDeltaEta_Neg"), mcParticle_MFTMCHMID.pt(), eta - mcParticle_MFTMCHMID.eta()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDeltaPhi_Neg"), mcParticle_MFTMCHMID.pt(), phi - mcParticle_MFTMCHMID.phi()); + } else { + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDeltaEta_Pos"), mcParticle_MFTMCHMID.pt(), eta - mcParticle_MFTMCHMID.eta()); + fRegistry.fill(HIST("MFTMCHMID/primary/wrong/hDeltaPhi_Pos"), mcParticle_MFTMCHMID.pt(), phi - mcParticle_MFTMCHMID.phi()); + } + } + } else { // secondary + if (isMatched) { + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hPt"), pt); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hEtaPhi"), phi, eta); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hEtaPhi_MatchedMCHMID"), phiMatchedMCHMID, etaMatchedMCHMID); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hsDelta"), pt, dpt, deta, dphi); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDiffCollId"), collision.globalIndex() - fwdtrack.collisionId()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hSign"), fwdtrack.sign()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hNclusters"), fwdtrack.nClusters()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hNclustersMFT"), nClustersMFT); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hMFTClusterMap"), mftClusterMap(mfttrack)); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hPDCA_Rabs"), rAtAbsorberEnd, pDCA); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hRatAbsorberEnd"), rAtAbsorberEnd); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hChi2"), fwdtrack.chi2() / (2.f * (fwdtrack.nClusters() + nClustersMFT) - 5.f)); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hChi2MFT"), chi2mft); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hChi2MatchMCHMID"), fwdtrack.chi2MatchMCHMID()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hChi2MatchMCHMFT"), fwdtrack.chi2MatchMCHMFT()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDCAxy2D"), dcaX, dcaY); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDCAz"), dcaZ); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDCAxy2DinSigma"), dcaX / std::sqrt(cXXatDCA), dcaY / std::sqrt(cYYatDCA)); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDCAxy"), dcaXY); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDCAxyinSigma"), dcaXYinSigma); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hMCHBitMap"), fwdtrack.mchBitMap()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hMIDBitMap"), fwdtrack.midBitMap()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hMeanMFTClusterSize"), p, meanClusterSizeMFT(mfttrack)); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDCAxResolutionvsPt"), pt, std::sqrt(cXXatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDCAyResolutionvsPt"), pt, std::sqrt(cYYatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDCAxyResolutionvsPt"), pt, sigma_dcaXY * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hProdVtxZ"), mcParticle_MFTMCHMID.vz()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hRelDeltaPt"), mcParticle_MFTMCHMID.pt(), (pt - mcParticle_MFTMCHMID.pt()) / mcParticle_MFTMCHMID.pt()); + if (mcParticle_MFTMCHMID.pdgCode() > 0) { + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDeltaEta_Neg"), mcParticle_MFTMCHMID.pt(), eta - mcParticle_MFTMCHMID.eta()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDeltaPhi_Neg"), mcParticle_MFTMCHMID.pt(), phi - mcParticle_MFTMCHMID.phi()); + } else { + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDeltaEta_Pos"), mcParticle_MFTMCHMID.pt(), eta - mcParticle_MFTMCHMID.eta()); + fRegistry.fill(HIST("MFTMCHMID/secondary/correct/hDeltaPhi_Pos"), mcParticle_MFTMCHMID.pt(), phi - mcParticle_MFTMCHMID.phi()); + } + } else { + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hPt"), pt); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hEtaPhi"), phi, eta); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hEtaPhi_MatchedMCHMID"), phiMatchedMCHMID, etaMatchedMCHMID); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hsDelta"), pt, dpt, deta, dphi); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDiffCollId"), collision.globalIndex() - fwdtrack.collisionId()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hSign"), fwdtrack.sign()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hNclusters"), fwdtrack.nClusters()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hNclustersMFT"), nClustersMFT); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hMFTClusterMap"), mftClusterMap(mfttrack)); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hPDCA_Rabs"), rAtAbsorberEnd, pDCA); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hRatAbsorberEnd"), rAtAbsorberEnd); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hChi2"), fwdtrack.chi2() / (2.f * (fwdtrack.nClusters() + nClustersMFT) - 5.f)); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hChi2MFT"), chi2mft); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hChi2MatchMCHMID"), fwdtrack.chi2MatchMCHMID()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hChi2MatchMCHMFT"), fwdtrack.chi2MatchMCHMFT()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDCAxy2D"), dcaX, dcaY); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDCAz"), dcaZ); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDCAxy2DinSigma"), dcaX / std::sqrt(cXXatDCA), dcaY / std::sqrt(cYYatDCA)); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDCAxy"), dcaXY); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDCAxyinSigma"), dcaXYinSigma); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hMCHBitMap"), fwdtrack.mchBitMap()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hMIDBitMap"), fwdtrack.midBitMap()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hMeanMFTClusterSize"), p, meanClusterSizeMFT(mfttrack)); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDCAxResolutionvsPt"), pt, std::sqrt(cXXatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDCAyResolutionvsPt"), pt, std::sqrt(cYYatDCA) * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDCAxyResolutionvsPt"), pt, sigma_dcaXY * 1e+4); // convert cm to um + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hProdVtxZ"), mcParticle_MFTMCHMID.vz()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hRelDeltaPt"), mcParticle_MFTMCHMID.pt(), (pt - mcParticle_MFTMCHMID.pt()) / mcParticle_MFTMCHMID.pt()); + if (mcParticle_MFTMCHMID.pdgCode() > 0) { + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDeltaEta_Neg"), mcParticle_MFTMCHMID.pt(), eta - mcParticle_MFTMCHMID.eta()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDeltaPhi_Neg"), mcParticle_MFTMCHMID.pt(), phi - mcParticle_MFTMCHMID.phi()); + } else { + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDeltaEta_Pos"), mcParticle_MFTMCHMID.pt(), eta - mcParticle_MFTMCHMID.eta()); + fRegistry.fill(HIST("MFTMCHMID/secondary/wrong/hDeltaPhi_Pos"), mcParticle_MFTMCHMID.pt(), phi - mcParticle_MFTMCHMID.phi()); + } + } + } + } + + template + void fillEventHistograms(TCollision const& collision) + { + fRegistry.fill(HIST("Event/hZvtx"), collision.posZ()); + fRegistry.fill(HIST("Event/hMultNTracksPV"), collision.multNTracksPV()); + fRegistry.fill(HIST("Event/hMultNTracksPVeta1"), collision.multNTracksPVeta1()); + fRegistry.fill(HIST("Event/hMultFT0"), collision.multFT0A(), collision.multFT0C()); + fRegistry.fill(HIST("Event/hCentFT0A"), collision.centFT0A()); + fRegistry.fill(HIST("Event/hCentFT0C"), collision.centFT0C()); + fRegistry.fill(HIST("Event/hCentFT0M"), collision.centFT0M()); + fRegistry.fill(HIST("Event/hCentFT0CvsMultNTracksPV"), collision.centFT0C(), collision.multNTracksPV()); + fRegistry.fill(HIST("Event/hMultFT0CvsMultNTracksPV"), collision.multFT0C(), collision.multNTracksPV()); + } + + // template + // void runGen(TMCParticles const& mcParticles) + // { + // for (const auto& mcParticle : mcParticles) { + // if (std::abs(mcParticle.pdgCode()) != 13) { // select true muon + // continue; + // } + // if (!(mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator())) { + // continue; + // } + // if (mcParticle.eta() < minEtaGL || maxEtaGL < mcParticle.eta()) { + // continue; + // } + + // fRegistry.fill(HIST("Generated/primary/hs"), mcParticle.pt(), mcParticle.eta(), mcParticle.phi()); + + // } // end of mc particles + // } + + SliceCache cache; + PresliceUnsorted perMFTTrack = o2::aod::fwdtrack::matchMFTTrackId; + Preslice perCollision = o2::aod::fwdtrack::collisionId; + Preslice fwdtrackIndicesPerCollision = aod::track_association::collisionId; + PresliceUnsorted fwdtrackIndicesPerFwdTrack = aod::track_association::fwdtrackId; + + Filter collisionFilter_evsel = o2::aod::evsel::sel8 == true && (cfgZvtxMin < o2::aod::collision::posZ && o2::aod::collision::posZ < cfgZvtxMax); + Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); + using FilteredMyCollisions = soa::Filtered; + + void processWithoutFTTCA(FilteredMyCollisions const& collisions, MyFwdTracks const& fwdtracks, MyMFTTracks const& mfttracks, aod::BCsWithTimestamps const&, aod::McParticles const&) + { + for (const auto& collision : collisions) { + const auto& bc = collision.template bc_as(); + initCCDB(bc); + fRegistry.fill(HIST("Event/hCollisionCounter"), 0); + if (!collision.has_mcCollision()) { + continue; + } + if (cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + fRegistry.fill(HIST("Event/hCollisionCounter"), 1); + fillEventHistograms(collision); + + const auto& fwdtracks_per_coll = fwdtracks.sliceBy(perCollision, collision.globalIndex()); + for (const auto& fwdtrack : fwdtracks_per_coll) { + if (fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) { + continue; + } + fillHistograms(collision, fwdtrack, fwdtracks, mfttracks); + } // end of fwdtrack loop + } // end of collision loop + // runGen(mcParticles); + } + PROCESS_SWITCH(matchingMFT, processWithoutFTTCA, "process without FTTCA", false); + + void processWithFTTCA(FilteredMyCollisions const& collisions, MyFwdTracks const& fwdtracks, MyMFTTracks const& mfttracks, aod::BCsWithTimestamps const&, aod::FwdTrackAssoc const& fwdtrackIndices, aod::McParticles const&) + { + for (const auto& collision : collisions) { + const auto& bc = collision.template bc_as(); + initCCDB(bc); + fRegistry.fill(HIST("Event/hCollisionCounter"), 0); + if (!collision.has_mcCollision()) { + continue; + } + if (cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + fRegistry.fill(HIST("Event/hCollisionCounter"), 1); + fillEventHistograms(collision); + + const auto& fwdtrackIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); + for (const auto& fwdtrackId : fwdtrackIdsThisCollision) { + const auto& fwdtrack = fwdtrackId.template fwdtrack_as(); + if (fwdtrack.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack && fwdtrack.trackType()) { + continue; + } + fillHistograms(collision, fwdtrack, fwdtracks, mfttracks); + } // end of fwdtrack loop + } // end of collision loop + // runGen(mcParticles); + } + PROCESS_SWITCH(matchingMFT, processWithFTTCA, "process with FTTCA", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"matching-mft"})}; +} diff --git a/PWGEM/Dilepton/Tasks/prefilterDielectron.cxx b/PWGEM/Dilepton/Tasks/prefilterDielectron.cxx index 59d9d0ac002..d3a12ec6481 100644 --- a/PWGEM/Dilepton/Tasks/prefilterDielectron.cxx +++ b/PWGEM/Dilepton/Tasks/prefilterDielectron.cxx @@ -14,32 +14,33 @@ // This code produces information on prefilter for dielectron. // Please write to: daiki.sekihata@cern.ch -#include -#include -#include -#include -#include +#include "PWGEM/Dilepton/Core/DielectronCut.h" +#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/EMTrack.h" +#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" -#include "PWGEM/Dilepton/Core/DielectronCut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.h" -#include "PWGEM/Dilepton/Utils/EMTrack.h" -#include "PWGEM/Dilepton/Utils/EventHistograms.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "Math/Vector4D.h" +#include "TString.h" + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -52,7 +53,7 @@ using namespace o2::aod::pwgem::dilepton::utils::pairutil; using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; -using MyTracks = soa::Join; +using MyTracks = soa::Join; using MyTrack = MyTracks::iterator; struct prefilterDielectron { @@ -101,12 +102,14 @@ struct prefilterDielectron { Configurable cfg_max_phiv{"cfg_max_phiv", 3.2, "max phiv"}; // region to be rejected // for deta-dphi prefilter - Configurable cfg_apply_detadphi_uls{"cfg_apply_detadphi_uls", false, "flag to apply generator deta-dphi elliptic cut in ULS"}; // region to be rejected - Configurable cfg_apply_detadphi_ls{"cfg_apply_detadphi_ls", false, "flag to apply generator deta-dphi elliptic cut in LS"}; // region to be rejected - Configurable cfg_min_deta_ls{"cfg_min_deta_ls", 0.04, "deta between 2 electrons (elliptic cut)"}; // region to be rejected - Configurable cfg_min_dphi_ls{"cfg_min_dphi_ls", 0.2, "dphi between 2 electrons (elliptic cut)"}; // region to be rejected - Configurable cfg_min_deta_uls{"cfg_min_deta_uls", 0.04, "deta between 2 electrons (elliptic cut)"}; // region to be rejected - Configurable cfg_min_dphi_uls{"cfg_min_dphi_uls", 0.2, "dphi between 2 electrons (elliptic cut)"}; // region to be rejected + Configurable cfg_apply_detadphi_uls{"cfg_apply_detadphi_uls", false, "flag to apply generator deta-dphi elliptic cut in ULS"}; // region to be rejected + Configurable cfg_apply_detadphi_ls{"cfg_apply_detadphi_ls", false, "flag to apply generator deta-dphi elliptic cut in LS"}; // region to be rejected + Configurable cfg_apply_detadphiposition_uls{"cfg_apply_detadphiposition_uls", false, "flag to apply generator deta-dphi elliptic cut in ULS"}; // region to be rejected + Configurable cfg_apply_detadphiposition_ls{"cfg_apply_detadphiposition_ls", false, "flag to apply generator deta-dphi elliptic cut in LS"}; // region to be rejected + Configurable cfg_min_deta_ls{"cfg_min_deta_ls", 0.04, "deta between 2 electrons (elliptic cut)"}; // region to be rejected + Configurable cfg_min_dphi_ls{"cfg_min_dphi_ls", 0.2, "dphi between 2 electrons (elliptic cut)"}; // region to be rejected + Configurable cfg_min_deta_uls{"cfg_min_deta_uls", 0.04, "deta between 2 electrons (elliptic cut)"}; // region to be rejected + Configurable cfg_min_dphi_uls{"cfg_min_dphi_uls", 0.2, "dphi between 2 electrons (elliptic cut)"}; // region to be rejected Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; @@ -127,16 +130,15 @@ struct prefilterDielectron { Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", false, "flag to require ITS ib 1st hit"}; Configurable cfg_min_its_cluster_size{"cfg_min_its_cluster_size", 0.f, "min ITS cluster size"}; Configurable cfg_max_its_cluster_size{"cfg_max_its_cluster_size", 16.f, "max ITS cluster size"}; - Configurable cfg_min_p_its_cluster_size{"cfg_min_p_its_cluster_size", 0.0, "min p to apply ITS cluster size cut"}; - Configurable cfg_max_p_its_cluster_size{"cfg_max_p_its_cluster_size", 0.0, "max p to apply ITS cluster size cut"}; Configurable cfg_min_rel_diff_pin{"cfg_min_rel_diff_pin", -1e+10, "min rel. diff. between pin and ppv"}; Configurable cfg_max_rel_diff_pin{"cfg_max_rel_diff_pin", +1e+10, "max rel. diff. between pin and ppv"}; + Configurable cfgRefR{"cfgRefR", 1.2, "reference R (in m) for extrapolation"}; // https://cds.cern.ch/record/1419204 Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3, kTOFif : 4, kPIDML : 5, kTPChadrejORTOFreq_woTOFif : 6]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; - Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; + // Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; + // Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -3.0, "min. TPC n sigma for kaon exclusion"}; @@ -146,6 +148,8 @@ struct prefilterDielectron { Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; // configuration for PID ML Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; @@ -169,6 +173,19 @@ struct prefilterDielectron { void init(InitContext& /*context*/) { + if (dielectroncuts.cfg_apply_detadphi_ls && dielectroncuts.cfg_apply_detadphiposition_ls) { + LOG(fatal) << "Please choose deta-dphi prefiter either at PV or certain radius"; + } + if (dielectroncuts.cfg_apply_detadphi_uls && dielectroncuts.cfg_apply_detadphiposition_uls) { + LOG(fatal) << "Please choose deta-dphi prefiter either at PV or certain radius"; + } + if (dielectroncuts.cfg_apply_detadphi_uls && dielectroncuts.cfg_apply_detadphiposition_ls) { + LOG(fatal) << "Please choose deta-dphi prefiter either at PV or certain radius"; + } + if (dielectroncuts.cfg_apply_detadphi_ls && dielectroncuts.cfg_apply_detadphiposition_uls) { + LOG(fatal) << "Please choose deta-dphi prefiter either at PV or certain radius"; + } + DefineEMEventCut(); DefineDielectronCut(); addhistograms(); @@ -236,6 +253,7 @@ struct prefilterDielectron { fRegistry.add("Pair/before/uls/hMvsPt", "m_{ee} vs. p_{T,ee}", kTH2D, {axis_mass, axis_pair_pt}, true); fRegistry.add("Pair/before/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi_{V} (rad.);m_{ee} (GeV/c^{2})", kTH2D, {axis_phiv, {200, 0, 1}}, true); fRegistry.add("Pair/before/uls/hDeltaEtaDeltaPhi", "#Delta#eta-#Delta#varphi between 2 tracks;#Delta#varphi (rad.);#Delta#eta;", kTH2D, {{180, -M_PI, M_PI}, {200, -1, +1}}, true); + fRegistry.add("Pair/before/uls/hDeltaEtaDeltaPhiPosition", "#Delta#eta-#Delta#varphi^{*} between 2 tracks;#Delta#varphi^{*} (rad.);#Delta#eta;", kTH2D, {{180, -M_PI, M_PI}, {200, -1, +1}}, true); fRegistry.addClone("Pair/before/uls/", "Pair/before/lspp/"); fRegistry.addClone("Pair/before/uls/", "Pair/before/lsmm/"); fRegistry.addClone("Pair/before/", "Pair/after/"); @@ -265,7 +283,7 @@ struct prefilterDielectron { fDielectronCut.SetPairDCARange(0.f, 1e+10); // in sigma fDielectronCut.ApplyPhiV(false); fDielectronCut.ApplyPrefilter(false); - fDielectronCut.SetMindEtadPhi(false, 1.f, 1.f); + fDielectronCut.SetMindEtadPhi(false, false, 1.f, 1.f); fDielectronCut.SetPairOpAng(0.f, 3.2f); fDielectronCut.SetRequireDifferentSides(false); @@ -280,18 +298,19 @@ struct prefilterDielectron { fDielectronCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); fDielectronCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); fDielectronCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size, dielectroncuts.cfg_min_p_its_cluster_size, dielectroncuts.cfg_max_p_its_cluster_size); + fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size); fDielectronCut.SetTrackMaxDcaXY(dielectroncuts.cfg_max_dcaxy); fDielectronCut.SetTrackMaxDcaZ(dielectroncuts.cfg_max_dcaz); fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); fDielectronCut.SetChi2TOF(0, dielectroncuts.cfg_max_chi2tof); fDielectronCut.SetRelDiffPin(dielectroncuts.cfg_min_rel_diff_pin, dielectroncuts.cfg_max_rel_diff_pin); + fDielectronCut.IncludeITSsa(dielectroncuts.includeITSsa, dielectroncuts.cfg_max_pt_track_ITSsa); // for eID fDielectronCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); fDielectronCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); + // fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); fDielectronCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); fDielectronCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); fDielectronCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); @@ -334,7 +353,7 @@ struct prefilterDielectron { Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; - Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin < o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; using FilteredMyCollisions = soa::Filtered; int ndf = 0; @@ -381,9 +400,18 @@ struct prefilterDielectron { float dphi = pos.sign() * v1.Pt() > ele.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); o2::math_utils::bringToPMPi(dphi); + float phiPosition1 = pos.phi() + std::asin(pos.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * pos.pt())); + float phiPosition2 = ele.phi() + std::asin(ele.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * ele.pt())); + + phiPosition1 = RecoDecay::constrainAngle(phiPosition1, 0, 1); // 0-2pi + phiPosition2 = RecoDecay::constrainAngle(phiPosition2, 0, 1); // 0-2pi + float dphiPosition = pos.sign() * v1.Pt() > ele.sign() * v2.Pt() ? phiPosition1 - phiPosition2 : phiPosition2 - phiPosition1; + o2::math_utils::bringToPMPi(dphiPosition); + fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/before/uls/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST("Pair/before/uls/hDeltaEtaDeltaPhiPosition"), dphiPosition, deta); if (dielectroncuts.cfg_min_mass < v12.M() && v12.M() < dielectroncuts.cfg_max_mass) { map_pfb[pos.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kMee); @@ -395,11 +423,18 @@ struct prefilterDielectron { map_pfb[ele.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kPhiV); } - if (dielectroncuts.cfg_apply_detadphi_uls && std::pow(deta / dielectroncuts.cfg_min_deta_uls, 2) + std::pow(dphi / dielectroncuts.cfg_min_dphi_uls, 2) < 1.f) { - map_pfb[pos.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackULS); - map_pfb[ele.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackULS); + if (dielectroncuts.cfg_apply_detadphiposition_uls) { + if (std::pow(deta / dielectroncuts.cfg_min_deta_uls, 2) + std::pow(dphiPosition / dielectroncuts.cfg_min_dphi_uls, 2) < 1.f) { + map_pfb[pos.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackULS); + map_pfb[ele.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackULS); + } + } else if (dielectroncuts.cfg_apply_detadphi_uls) { + if (std::pow(deta / dielectroncuts.cfg_min_deta_uls, 2) + std::pow(dphi / dielectroncuts.cfg_min_dphi_uls, 2) < 1.f) { + map_pfb[pos.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackULS); + map_pfb[ele.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackULS); + } } - } + } // end of ULS pairing for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ if (!fDielectronCut.IsSelectedTrack(pos1) || !fDielectronCut.IsSelectedTrack(pos2)) { @@ -415,15 +450,31 @@ struct prefilterDielectron { float dphi = pos1.sign() * v1.Pt() > pos2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); o2::math_utils::bringToPMPi(dphi); + float phiPosition1 = pos1.phi() + std::asin(pos1.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * pos1.pt())); + float phiPosition2 = pos2.phi() + std::asin(pos2.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * pos2.pt())); + + phiPosition1 = RecoDecay::constrainAngle(phiPosition1, 0, 1); // 0-2pi + phiPosition2 = RecoDecay::constrainAngle(phiPosition2, 0, 1); // 0-2pi + float dphiPosition = pos1.sign() * v1.Pt() > pos2.sign() * v2.Pt() ? phiPosition1 - phiPosition2 : phiPosition2 - phiPosition1; + o2::math_utils::bringToPMPi(dphiPosition); + fRegistry.fill(HIST("Pair/before/lspp/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/before/lspp/hMvsPhiV"), phiv, v12.M()); fRegistry.fill(HIST("Pair/before/lspp/hDeltaEtaDeltaPhi"), dphi, deta); - - if (dielectroncuts.cfg_apply_detadphi_ls && std::pow(deta / dielectroncuts.cfg_min_deta_ls, 2) + std::pow(dphi / dielectroncuts.cfg_min_dphi_ls, 2) < 1.f) { - map_pfb[pos1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); - map_pfb[pos2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + fRegistry.fill(HIST("Pair/before/lspp/hDeltaEtaDeltaPhiPosition"), dphiPosition, deta); + + if (dielectroncuts.cfg_apply_detadphiposition_ls) { + if (std::pow(deta / dielectroncuts.cfg_min_deta_ls, 2) + std::pow(dphiPosition / dielectroncuts.cfg_min_dphi_ls, 2) < 1.f) { + map_pfb[pos1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + map_pfb[pos2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + } + } else if (dielectroncuts.cfg_apply_detadphi_ls) { + if (std::pow(deta / dielectroncuts.cfg_min_deta_ls, 2) + std::pow(dphi / dielectroncuts.cfg_min_dphi_ls, 2) < 1.f) { + map_pfb[pos1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + map_pfb[pos2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + } } - } + } // end of LS++ pairing for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- if (!fDielectronCut.IsSelectedTrack(ele1) || !fDielectronCut.IsSelectedTrack(ele2)) { @@ -439,15 +490,31 @@ struct prefilterDielectron { float dphi = ele1.sign() * v1.Pt() > ele2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); o2::math_utils::bringToPMPi(dphi); + float phiPosition1 = ele1.phi() + std::asin(ele1.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * ele1.pt())); + float phiPosition2 = ele2.phi() + std::asin(ele2.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * ele2.pt())); + + phiPosition1 = RecoDecay::constrainAngle(phiPosition1, 0, 1); // 0-2pi + phiPosition2 = RecoDecay::constrainAngle(phiPosition2, 0, 1); // 0-2pi + float dphiPosition = ele1.sign() * v1.Pt() > ele2.sign() * v2.Pt() ? phiPosition1 - phiPosition2 : phiPosition2 - phiPosition1; + o2::math_utils::bringToPMPi(dphiPosition); + fRegistry.fill(HIST("Pair/before/lsmm/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/before/lsmm/hMvsPhiV"), phiv, v12.M()); fRegistry.fill(HIST("Pair/before/lsmm/hDeltaEtaDeltaPhi"), dphi, deta); - - if (dielectroncuts.cfg_apply_detadphi_ls && std::pow(deta / dielectroncuts.cfg_min_deta_ls, 2) + std::pow(dphi / dielectroncuts.cfg_min_dphi_ls, 2) < 1.f) { - map_pfb[ele1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); - map_pfb[ele2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + fRegistry.fill(HIST("Pair/before/lsmm/hDeltaEtaDeltaPhiPosition"), dphiPosition, deta); + + if (dielectroncuts.cfg_apply_detadphiposition_ls) { + if (std::pow(deta / dielectroncuts.cfg_min_deta_ls, 2) + std::pow(dphiPosition / dielectroncuts.cfg_min_dphi_ls, 2) < 1.f) { + map_pfb[ele1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + map_pfb[ele2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + } + } else if (dielectroncuts.cfg_apply_detadphi_ls) { + if (std::pow(deta / dielectroncuts.cfg_min_deta_ls, 2) + std::pow(dphi / dielectroncuts.cfg_min_dphi_ls, 2) < 1.f) { + map_pfb[ele1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + map_pfb[ele2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBitDerived::kSplitOrMergedTrackLS); + } } - } + } // end of LS-- pairing } // end of collision loop @@ -486,9 +553,18 @@ struct prefilterDielectron { float dphi = pos.sign() * v1.Pt() > ele.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); o2::math_utils::bringToPMPi(dphi); + float phiPosition1 = pos.phi() + std::asin(pos.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * pos.pt())); + float phiPosition2 = ele.phi() + std::asin(ele.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * ele.pt())); + + phiPosition1 = RecoDecay::constrainAngle(phiPosition1, 0, 1); // 0-2pi + phiPosition2 = RecoDecay::constrainAngle(phiPosition2, 0, 1); // 0-2pi + float dphiPosition = pos.sign() * v1.Pt() > ele.sign() * v2.Pt() ? phiPosition1 - phiPosition2 : phiPosition2 - phiPosition1; + o2::math_utils::bringToPMPi(dphiPosition); + fRegistry.fill(HIST("Pair/after/uls/hMvsPhiV"), phiv, v12.M()); fRegistry.fill(HIST("Pair/after/uls/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/after/uls/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST("Pair/after/uls/hDeltaEtaDeltaPhiPosition"), dphiPosition, deta); } for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ @@ -507,9 +583,18 @@ struct prefilterDielectron { float dphi = pos1.sign() * v1.Pt() > pos2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); o2::math_utils::bringToPMPi(dphi); + float phiPosition1 = pos1.phi() + std::asin(pos1.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * pos1.pt())); + float phiPosition2 = pos2.phi() + std::asin(pos2.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * pos2.pt())); + + phiPosition1 = RecoDecay::constrainAngle(phiPosition1, 0, 1); // 0-2pi + phiPosition2 = RecoDecay::constrainAngle(phiPosition2, 0, 1); // 0-2pi + float dphiPosition = pos1.sign() * v1.Pt() > pos2.sign() * v2.Pt() ? phiPosition1 - phiPosition2 : phiPosition2 - phiPosition1; + o2::math_utils::bringToPMPi(dphiPosition); + fRegistry.fill(HIST("Pair/after/lspp/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/after/lspp/hMvsPhiV"), phiv, v12.M()); fRegistry.fill(HIST("Pair/after/lspp/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST("Pair/after/lspp/hDeltaEtaDeltaPhiPosition"), dphiPosition, deta); } for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- @@ -528,9 +613,18 @@ struct prefilterDielectron { float dphi = ele1.sign() * v1.Pt() > ele2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); o2::math_utils::bringToPMPi(dphi); + float phiPosition1 = ele1.phi() + std::asin(ele1.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * ele1.pt())); + float phiPosition2 = ele2.phi() + std::asin(ele2.sign() * 0.30282 * (d_bz * 0.1) * dielectroncuts.cfgRefR / (2.f * ele2.pt())); + + phiPosition1 = RecoDecay::constrainAngle(phiPosition1, 0, 1); // 0-2pi + phiPosition2 = RecoDecay::constrainAngle(phiPosition2, 0, 1); // 0-2pi + float dphiPosition = ele1.sign() * v1.Pt() > ele2.sign() * v2.Pt() ? phiPosition1 - phiPosition2 : phiPosition2 - phiPosition1; + o2::math_utils::bringToPMPi(dphiPosition); + fRegistry.fill(HIST("Pair/after/lsmm/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/after/lsmm/hMvsPhiV"), phiv, v12.M()); fRegistry.fill(HIST("Pair/after/lsmm/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST("Pair/after/lsmm/hDeltaEtaDeltaPhiPosition"), dphiPosition, deta); } } // end of collision loop diff --git a/PWGEM/Dilepton/Tasks/qVectorDummyOTF.cxx b/PWGEM/Dilepton/Tasks/qVectorDummyOTF.cxx new file mode 100644 index 00000000000..d499a790a71 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/qVectorDummyOTF.cxx @@ -0,0 +1,48 @@ +// 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. +// +// ======================== +// +// This code produces on-the-fly dummy qvector table. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::soa; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct qVectorDummyOTF { + Produces event_qvec; + + void init(InitContext&) {} + ~qVectorDummyOTF() {} + + void process(aod::EMEvents const& collisions) + { + for (int i = 0; i < collisions.size(); i++) { + event_qvec( + 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, + 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f, 999.f); + } // end of collision loop + } // end of process +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"qvector-dummy-otf"})}; +} diff --git a/PWGEM/Dilepton/Tasks/smearing.cxx b/PWGEM/Dilepton/Tasks/smearing.cxx index bcd8cbeffa1..03d0b272f46 100644 --- a/PWGEM/Dilepton/Tasks/smearing.cxx +++ b/PWGEM/Dilepton/Tasks/smearing.cxx @@ -13,21 +13,21 @@ // Analysis task to produce smeared pt, eta, phi for electrons/muons in dilepton analysis // Please write to: daiki.sekihata@cern.ch -#include -#include -#include +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/MomentumSmearer.h" #include "CCDB/BasicCCDBManager.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" #include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/DataTypes.h" #include "Framework/HistogramRegistry.h" -// #include "PWGDQ/DataModel/ReducedInfoTables.h" // remove this later, because 2 data tables (covariant matrix) in this header confilict against EM tables. -#include "PWGEM/Dilepton/Utils/MomentumSmearer.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "Framework/runDataProcessing.h" + +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -218,7 +218,7 @@ struct ApplySmearing { } int pdgCode = mctrack.pdgCode(); - if (abs(pdgCode) == 11) { + if (std::abs(pdgCode) == 11) { int ch = -1; if (pdgCode < 0) { ch = 1; @@ -232,7 +232,7 @@ struct ApplySmearing { // fill the table smearedelectron(ptsmeared, etasmeared, phismeared, efficiency, dca); smearedmuon(ptgen, etagen, phigen, 1.f, 0.f, ptgen, etagen, phigen, 1.f, 0.f); - } else if (abs(pdgCode) == 13) { + } else if (std::abs(pdgCode) == 13) { int ch = -1; if (pdgCode < 0) { ch = 1; @@ -249,7 +249,6 @@ struct ApplySmearing { efficiency_gl = smearer_GlobalMuon.getEfficiency(ptgen, etagen, phigen); dca_gl = smearer_GlobalMuon.getDCA(ptsmeared_gl); smearedmuon(ptsmeared_sa, etasmeared_sa, phismeared_sa, efficiency_sa, dca_sa, ptsmeared_gl, etasmeared_gl, phismeared_gl, efficiency_gl, dca_gl); - smearedelectron(ptgen, etagen, phigen, 1.f, 0.f); } else { // don't apply smearing @@ -279,32 +278,30 @@ struct ApplySmearing { // don't apply smearing for (auto& mctrack : tracksMC) { int pdgCode = mctrack.pdgCode(); - if (abs(pdgCode) == 11) { + if (std::abs(pdgCode) == 11) { + smearedelectron(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0); + smearedmuon(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0, mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0); + } else if (std::abs(pdgCode) == 13) { smearedelectron(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0); - } else if (abs(pdgCode) == 13) { smearedmuon(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0, mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0); } else { - smearedelectron(mctrack.pt(), mctrack.eta(), mctrack.eta(), 1.0, 0.0); + smearedelectron(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0); smearedmuon(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0, mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0); } } } void processDummyMCanalysisEM(aod::EMMCParticles const&) {} - // void processDummyMCanalysisDQ(ReducedMCTracks const&) {} PROCESS_SWITCH(ApplySmearing, processMCanalysisEM, "Run for MC analysis which uses skimmed EM data format", false); - // PROCESS_SWITCH(ApplySmearing, processMCanalysisDQ, "Run for MC analysis which uses skimmed DQ data format", false); PROCESS_SWITCH(ApplySmearing, processCocktail, "Run for cocktail analysis", false); PROCESS_SWITCH(ApplySmearing, processDummyMCanalysisEM, "Dummy process function", false); - // PROCESS_SWITCH(ApplySmearing, processDummyMCanalysisDQ, "Dummy process function", false); PROCESS_SWITCH(ApplySmearing, processDummyCocktail, "Dummy process function", true); }; struct CheckSmearing { - using EMMCParticlesWithSmearing = soa::Join; // this is only for electrons - // using MyReducedTracks = soa::Join; // this is only for electrons - using MyCocktailTracks = soa::Join; // this is only for electrons + using EMMCParticlesWithSmearing = soa::Join; + using MyCocktailTracks = soa::Join; // Run for electrons or muons Configurable fPdgCode{"cfgPdgCode", 11, "Set the type of particle to be checked"}; @@ -321,9 +318,9 @@ struct CheckSmearing { void init(o2::framework::InitContext&) { - registry.add("hCorrelation_Pt", "pT correlation;p_{T,l}^{gen} (GeV/c);p_{T,l}^{smeared} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 10.0f}, {1000, 0.0f, 10.0f}}}); - registry.add("hCorrelation_Eta", "eta correlation;#eta_{l}^{gen};#eta_{l}^{smeared}", {HistType::kTH2F, {{200, -1.0f, +1.0f}, {200, -1.0f, +1.0f}}}); - registry.add("hCorrelation_Phi", "phi correlation;#varphi_{l}^{gen} (rad.);#varphi_{l}^{smeared} (rad.)", {HistType::kTH2F, {{100, 0.0f, TMath::TwoPi()}, {100, 0.0f, TMath::TwoPi()}}}); + registry.add("Electron/hCorrelation_Pt", "pT correlation;p_{T,l}^{gen} (GeV/c);p_{T,l}^{smeared} (GeV/c)", {HistType::kTH2F, {{1000, 0.0f, 10.0f}, {1000, 0.0f, 10.0f}}}); + registry.add("Electron/hCorrelation_Eta", "eta correlation;#eta_{l}^{gen};#eta_{l}^{smeared}", {HistType::kTH2F, {{200, -1.0f, +1.0f}, {200, -1.0f, +1.0f}}}); + registry.add("Electron/hCorrelation_Phi", "phi correlation;#varphi_{l}^{gen} (rad.);#varphi_{l}^{smeared} (rad.)", {HistType::kTH2F, {{100, 0.0f, TMath::TwoPi()}, {100, 0.0f, TMath::TwoPi()}}}); // Binning for resolution AxisSpec axisPtRes{ptResBins, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}; @@ -332,23 +329,26 @@ struct CheckSmearing { AxisSpec axisDeltaphiRes{deltaphiResBins, "#varphi^{gen} - #varphi^{rec} (rad.)"}; if (!fConfigUsePtVecRes) { - registry.add("PtGen_DeltaPtOverPtGen", "", HistType::kTH2D, {axisPtRes, axisDeltaptRes}, true); - registry.add("PtGen_DeltaEta", "", HistType::kTH2D, {axisPtRes, axisDeltaetaRes}, true); - registry.add("PtGen_DeltaPhi_Neg", "", HistType::kTH2D, {axisPtRes, axisDeltaphiRes}, true); - registry.add("PtGen_DeltaPhi_Pos", "", HistType::kTH2D, {axisPtRes, axisDeltaphiRes}, true); + registry.add("Electron/PtGen_DeltaPtOverPtGen", "", HistType::kTH2D, {axisPtRes, axisDeltaptRes}, true); + registry.add("Electron/PtGen_DeltaEta", "", HistType::kTH2D, {axisPtRes, axisDeltaetaRes}, true); + registry.add("Electron/PtGen_DeltaPhi_Neg", "", HistType::kTH2D, {axisPtRes, axisDeltaphiRes}, true); + registry.add("Electron/PtGen_DeltaPhi_Pos", "", HistType::kTH2D, {axisPtRes, axisDeltaphiRes}, true); } else { - registry.add("PtGen_DeltaPtOverPtGen", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}, axisDeltaptRes}, true); - registry.add("PtGen_DeltaEta", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}, axisDeltaetaRes}, true); - registry.add("PtGen_DeltaPhi_Neg", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}, axisDeltaphiRes}, true); - registry.add("PtGen_DeltaPhi_Pos", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}, axisDeltaphiRes}, true); + registry.add("Electron/PtGen_DeltaPtOverPtGen", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}, axisDeltaptRes}, true); + registry.add("Electron/PtGen_DeltaEta", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}, axisDeltaetaRes}, true); + registry.add("Electron/PtGen_DeltaPhi_Neg", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}, axisDeltaphiRes}, true); + registry.add("Electron/PtGen_DeltaPhi_Pos", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}, axisDeltaphiRes}, true); } + + registry.addClone("Electron/", "GlobalMuon/"); + registry.addClone("Electron/", "StandaloneMuon/"); } template void Check(TTracksMC const& tracksMC, TMCCollisions const&) { for (auto& mctrack : tracksMC) { - if (abs(mctrack.pdgCode()) != fPdgCode) { + if (std::abs(mctrack.pdgCode()) != fPdgCode) { continue; } @@ -359,21 +359,59 @@ struct CheckSmearing { } } - float deltaptoverpt = -1000.; - if (mctrack.pt() > 0.) - deltaptoverpt = (mctrack.pt() - mctrack.ptSmeared()) / mctrack.pt(); - float deltaeta = mctrack.eta() - mctrack.etaSmeared(); - float deltaphi = mctrack.phi() - mctrack.phiSmeared(); - registry.fill(HIST("PtGen_DeltaPtOverPtGen"), mctrack.pt(), deltaptoverpt); - registry.fill(HIST("PtGen_DeltaEta"), mctrack.pt(), deltaeta); - if (mctrack.pdgCode() < 0) { - registry.fill(HIST("PtGen_DeltaPhi_Neg"), mctrack.pt(), deltaphi); - } else { - registry.fill(HIST("PtGen_DeltaPhi_Pos"), mctrack.pt(), deltaphi); + if (std::abs(mctrack.pdgCode()) == 11) { // for electrons + float deltaptoverpt = -1000.f; + if (mctrack.pt() > 0.f) { + deltaptoverpt = (mctrack.pt() - mctrack.ptSmeared()) / mctrack.pt(); + } + float deltaeta = mctrack.eta() - mctrack.etaSmeared(); + float deltaphi = mctrack.phi() - mctrack.phiSmeared(); + registry.fill(HIST("Electron/PtGen_DeltaPtOverPtGen"), mctrack.pt(), deltaptoverpt); + registry.fill(HIST("Electron/PtGen_DeltaEta"), mctrack.pt(), deltaeta); + if (mctrack.pdgCode() < 0) { // e+ + registry.fill(HIST("Electron/PtGen_DeltaPhi_Pos"), mctrack.pt(), deltaphi); + } else { // e- + registry.fill(HIST("Electron/PtGen_DeltaPhi_Neg"), mctrack.pt(), deltaphi); + } + registry.fill(HIST("Electron/hCorrelation_Pt"), mctrack.pt(), mctrack.ptSmeared()); + registry.fill(HIST("Electron/hCorrelation_Eta"), mctrack.eta(), mctrack.etaSmeared()); + registry.fill(HIST("Electron/hCorrelation_Phi"), mctrack.phi(), mctrack.phiSmeared()); + } else if (std::abs(mctrack.pdgCode()) == 13) { // for muons + float deltaptoverpt = -1000.f; + // for standalone muons + if (mctrack.pt() > 0.f) { + deltaptoverpt = (mctrack.pt() - mctrack.ptSmeared_sa_muon()) / mctrack.pt(); + } + float deltaeta = mctrack.eta() - mctrack.etaSmeared_sa_muon(); + float deltaphi = mctrack.phi() - mctrack.phiSmeared_sa_muon(); + registry.fill(HIST("StandaloneMuon/PtGen_DeltaPtOverPtGen"), mctrack.pt(), deltaptoverpt); + registry.fill(HIST("StandaloneMuon/PtGen_DeltaEta"), mctrack.pt(), deltaeta); + if (mctrack.pdgCode() < 0) { // mu+ + registry.fill(HIST("StandaloneMuon/PtGen_DeltaPhi_Pos"), mctrack.pt(), deltaphi); + } else { // mu- + registry.fill(HIST("StandaloneMuon/PtGen_DeltaPhi_Neg"), mctrack.pt(), deltaphi); + } + registry.fill(HIST("StandaloneMuon/hCorrelation_Pt"), mctrack.pt(), mctrack.ptSmeared_sa_muon()); + registry.fill(HIST("StandaloneMuon/hCorrelation_Eta"), mctrack.eta(), mctrack.etaSmeared_sa_muon()); + registry.fill(HIST("StandaloneMuon/hCorrelation_Phi"), mctrack.phi(), mctrack.phiSmeared_sa_muon()); + + // for global muons + if (mctrack.pt() > 0.f) { + deltaptoverpt = (mctrack.pt() - mctrack.ptSmeared_gl_muon()) / mctrack.pt(); + } + deltaeta = mctrack.eta() - mctrack.etaSmeared_gl_muon(); + deltaphi = mctrack.phi() - mctrack.phiSmeared_gl_muon(); + registry.fill(HIST("GlobalMuon/PtGen_DeltaPtOverPtGen"), mctrack.pt(), deltaptoverpt); + registry.fill(HIST("GlobalMuon/PtGen_DeltaEta"), mctrack.pt(), deltaeta); + if (mctrack.pdgCode() < 0) { // mu+ + registry.fill(HIST("GlobalMuon/PtGen_DeltaPhi_Pos"), mctrack.pt(), deltaphi); + } else { // mu- + registry.fill(HIST("GlobalMuon/PtGen_DeltaPhi_Neg"), mctrack.pt(), deltaphi); + } + registry.fill(HIST("GlobalMuon/hCorrelation_Pt"), mctrack.pt(), mctrack.ptSmeared_gl_muon()); + registry.fill(HIST("GlobalMuon/hCorrelation_Eta"), mctrack.eta(), mctrack.etaSmeared_gl_muon()); + registry.fill(HIST("GlobalMuon/hCorrelation_Phi"), mctrack.phi(), mctrack.phiSmeared_gl_muon()); } - registry.fill(HIST("hCorrelation_Pt"), mctrack.pt(), mctrack.ptSmeared()); - registry.fill(HIST("hCorrelation_Eta"), mctrack.eta(), mctrack.etaSmeared()); - registry.fill(HIST("hCorrelation_Phi"), mctrack.phi(), mctrack.phiSmeared()); } // end of mctrack loop } @@ -382,25 +420,17 @@ struct CheckSmearing { Check(tracksMC, mccollisions); } - // void processCheckMCanalysisDQ(MyReducedTracks const& tracksMC) - // { - // Check(tracksMC); - // } - void processCheckCocktail(MyCocktailTracks const& tracksMC) { Check(tracksMC, nullptr); } void processDummyMCanalysisEM(aod::EMMCParticles const&) {} - // void processDummyMCanalysisDQ(ReducedMCTracks const&) {} void processDummyCocktail(aod::McParticles const&) {} PROCESS_SWITCH(CheckSmearing, processCheckMCanalysisEM, "Run for MC analysis", false); - // PROCESS_SWITCH(CheckSmearing, processCheckMCanalysisDQ, "Run for MC analysis", false); PROCESS_SWITCH(CheckSmearing, processCheckCocktail, "Run for cocktail analysis", false); PROCESS_SWITCH(CheckSmearing, processDummyMCanalysisEM, "Dummy process function", false); - // PROCESS_SWITCH(CheckSmearing, processDummyMCanalysisDQ, "Dummy process function", false); PROCESS_SWITCH(CheckSmearing, processDummyCocktail, "Dummy process function", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGEM/Dilepton/Tasks/studyMCTruth.cxx b/PWGEM/Dilepton/Tasks/studyMCTruth.cxx new file mode 100644 index 00000000000..4204a95a9c4 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/studyMCTruth.cxx @@ -0,0 +1,449 @@ +// 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. +// +// ======================== +// +// This code is to study MC truth. e.g. evet selection bias +// Please write to: daiki.sekihata@cern.ch + +#include +#include "Math/Vector4D.h" + +#include "Framework/StaticFor.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "ReconstructionDataFormats/Track.h" +#include "Common/Core/TableHelper.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/MCUtilities.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::aod::pwgem::dilepton::utils::mcutil; + +struct studyMCTruth { + + struct : ConfigurableGroup { + std::string prefix = "mccut_group"; + Configurable cfgEventGeneratorType{"cfgEventGeneratorType", -1, "if positive, select event generator type. i.e. gap or signal"}; + Configurable cfgPdgCodeLepton{"cfgPdgCodeLepton", 11, "pdg code for desired lepton"}; + Configurable cfgMinPtGen{"cfgMinPtGen", 0.2, "min. pT of single lepton"}; + Configurable cfgMaxPtGen{"cfgMaxPtGen", 1e+10f, "max. pT of single lepton"}; + Configurable cfgMinEtaGen{"cfgMinEtaGen", -0.8, "min. eta of for single lepton"}; + Configurable cfgMaxEtaGen{"cfgMaxEtaGen", +0.8, "max. eta of for single lepton"}; + Configurable cfgMuonTrackType{"cfgMuonTrackType", 3, "muon track type [0: MFT-MCH-MID, 3: MCH-MID]"}; + } mccuts; + + struct : ConfigurableGroup { + std::string prefix = "eventcut_group"; + Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; + Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; + Configurable cfgMinImpPar{"cfgMinImpPar", -1.f, "min. impact parameter in fm"}; // [0, 4] fm for centrality FT0C 0-10%, [8, 10] fm for centrality FT0C 30-50% in PbPb + Configurable cfgMaxImpPar{"cfgMaxImpPar", 999.f, "max. impact parameter in fm"}; + } eventcuts; + + ConfigurableAxis ConfMllBins{"ConfMllBins", {400, 0.f, 4.f}, "mll bins for output histograms"}; + ConfigurableAxis ConfPtllBins{"ConfPtllBins", {100, 0.f, 10.f}, "pTll bins for output histograms"}; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + float leptonMass = o2::constants::physics::MassElectron; + void init(o2::framework::InitContext&) + { + if (std::abs(mccuts.cfgPdgCodeLepton.value) == 11) { + leptonMass = o2::constants::physics::MassElectron; + } else if (std::abs(mccuts.cfgPdgCodeLepton.value) == 13) { + leptonMass = o2::constants::physics::MassMuon; + } else { + LOGF(fatal, "pdg code must be 11 or 13."); + } + addHistograms(); + } + + static constexpr std::string_view dileptonSigns[3] = {"uls/", "lspp/", "lsmm/"}; + static constexpr std::string_view evNames[4] = {"allMC/", "selectedMC/", "selectedMC_and_Rec/", "selectedMC_and_selectedRec/"}; + + void addHistograms() + { + const AxisSpec axis_mll{ConfMllBins, "m_{ll} (GeV/c^{2})"}; + const AxisSpec axis_ptll{ConfPtllBins, "p_{T,ll} (GeV/c)"}; + + fRegistry.add("Event/hDiffBC", "diffrence in BC;BC_{rec. coll.} - BC_{mc coll.}", kTH1D, {{101, -50.5, +50.5}}, false); + fRegistry.add("Event/allMC/hReccollsPerMCcoll", "Rec. colls per MC coll;Rec. colls per MC coll;Number of MC collisions", kTH1D, {{21, -0.5, 20.5}}, false); + fRegistry.add("Event/allMC/hSelReccollsPerMCcoll", "Selected Rec. colls per MC coll;Selected Rec. colls per MC coll;Number of MC collisions", kTH1D, {{21, -0.5, 20.5}}, false); + fRegistry.add("Event/allMC/hZvtx", "MC Zvtx;Z_{vtx} (cm)", kTH1D, {{100, -50, +50}}, false); + fRegistry.add("Event/allMC/hImpactParameter", "impact parameter;impact parameter b (fm)", kTH1D, {{200, 0, 20}}, false); + fRegistry.addClone("Event/allMC/", "Event/selectedMC/"); + fRegistry.addClone("Event/allMC/", "Event/selectedMC_and_Rec/"); + fRegistry.addClone("Event/allMC/", "Event/selectedMC_and_selectedRec/"); + + fRegistry.add("Pair/allMC/Pi0/uls/hMvsPt", "m_{ll} vs. p_{T,ll}", kTH2D, {axis_mll, axis_ptll}, true); + fRegistry.addClone("Pair/allMC/Pi0/uls/", "Pair/allMC/Pi0/lspp/"); + fRegistry.addClone("Pair/allMC/Pi0/uls/", "Pair/allMC/Pi0/lsmm/"); + fRegistry.addClone("Pair/allMC/Pi0/", "Pair/allMC/Eta/"); + fRegistry.addClone("Pair/allMC/Pi0/", "Pair/allMC/EtaPrime/"); + fRegistry.addClone("Pair/allMC/Pi0/", "Pair/allMC/Rho/"); + fRegistry.addClone("Pair/allMC/Pi0/", "Pair/allMC/Omega/"); + fRegistry.addClone("Pair/allMC/Pi0/", "Pair/allMC/Phi/"); + fRegistry.addClone("Pair/allMC/Pi0/", "Pair/allMC/JPsi/"); + fRegistry.addClone("Pair/allMC/Pi0/", "Pair/allMC/ccbar/"); + fRegistry.addClone("Pair/allMC/Pi0/", "Pair/allMC/bbbar/"); + fRegistry.addClone("Pair/allMC/", "Pair/selectedMC/"); + fRegistry.addClone("Pair/allMC/", "Pair/selectedMC_and_Rec/"); + fRegistry.addClone("Pair/allMC/", "Pair/selectedMC_and_selectedRec/"); + + // allMC = all mc collisions + // selectedMC = mc collisions selected by your event cuts + // selectedMC_and_Rec = mc collisions selected by your event cuts and at least 1 reconstructed collision is associated. + // selectedMC_and_selectedRec = mc collisions selected by your event cuts and at least 1 reconstructed collision is associated, and the associated rec. collision is selected by your cuts. + } + + template + int FindLF(TTrack const& posmc, TTrack const& negmc, TMCParticles const& mcparticles) + { + int arr[] = { + FindCommonMotherFrom2Prongs(posmc, negmc, -mccuts.cfgPdgCodeLepton, mccuts.cfgPdgCodeLepton, 111, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -mccuts.cfgPdgCodeLepton, mccuts.cfgPdgCodeLepton, 221, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -mccuts.cfgPdgCodeLepton, mccuts.cfgPdgCodeLepton, 331, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -mccuts.cfgPdgCodeLepton, mccuts.cfgPdgCodeLepton, 113, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -mccuts.cfgPdgCodeLepton, mccuts.cfgPdgCodeLepton, 223, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -mccuts.cfgPdgCodeLepton, mccuts.cfgPdgCodeLepton, 333, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -mccuts.cfgPdgCodeLepton, mccuts.cfgPdgCodeLepton, 443, mcparticles)}; + int size = sizeof(arr) / sizeof(*arr); + int max = *std::max_element(arr, arr + size); + return max; + } + + template + bool isSelectedMCParticle(TMCParticle const& mcparticle) + { + if (std::abs(mcparticle.pdgCode()) != mccuts.cfgPdgCodeLepton) { + return false; + } + if (!mcparticle.has_mothers()) { + return false; + } + if (!(mcparticle.isPhysicalPrimary() || mcparticle.producedByGenerator())) { + return false; + } + + if constexpr (isSmeared) { + if (std::abs(mccuts.cfgPdgCodeLepton) == 11) { + if (mcparticle.ptSmeared() < mccuts.cfgMinPtGen || mccuts.cfgMaxPtGen < mcparticle.ptSmeared()) { + return false; + } + if (mcparticle.etaSmeared() < mccuts.cfgMinEtaGen || mccuts.cfgMaxEtaGen < mcparticle.etaSmeared()) { + return false; + } + } else if (std::abs(mccuts.cfgPdgCodeLepton) == 13) { + if (mccuts.cfgMuonTrackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + if (mcparticle.ptSmeared_sa_muon() < mccuts.cfgMinPtGen || mccuts.cfgMaxPtGen < mcparticle.ptSmeared_sa_muon()) { + return false; + } + if (mcparticle.etaSmeared_sa_muon() < mccuts.cfgMinEtaGen || mccuts.cfgMaxEtaGen < mcparticle.etaSmeared_sa_muon()) { + return false; + } + } else if (mccuts.cfgMuonTrackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + if (mcparticle.ptSmeared_gl_muon() < mccuts.cfgMinPtGen || mccuts.cfgMaxPtGen < mcparticle.ptSmeared_gl_muon()) { + return false; + } + if (mcparticle.etaSmeared_gl_muon() < mccuts.cfgMinEtaGen || mccuts.cfgMaxEtaGen < mcparticle.etaSmeared_gl_muon()) { + return false; + } + } + } + } else { + if (mcparticle.pt() < mccuts.cfgMinPtGen || mccuts.cfgMaxPtGen < mcparticle.pt()) { + return false; + } + if (mcparticle.eta() < mccuts.cfgMinEtaGen || mccuts.cfgMaxEtaGen < mcparticle.eta()) { + return false; + } + } + + return true; + } + + template + bool isSelectedCollision(TCollision const& collision, TBC const& bc) + { + if (collision.posZ() < eventcuts.cfgZvtxMin || eventcuts.cfgZvtxMax < collision.posZ()) { + return false; + } + + if (eventcuts.cfgRequireFT0AND && !bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + return false; + } + if (eventcuts.cfgRequireNoTFB && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (eventcuts.cfgRequireNoITSROFB && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + return true; + } + + template + void fillTrueInfo(TMCLepton const& t1, TMCLepton const& t2, TMCParticles const& mcParticles) + { + if (!isSelectedMCParticle(t1) || !isSelectedMCParticle(t2)) { + return; + } + + float pt1 = 0.f, eta1 = 0.f, phi1 = 0.f, pt2 = 0.f, eta2 = 0.f, phi2 = 0.f; + if constexpr (isSmeared) { + if (std::abs(mccuts.cfgPdgCodeLepton) == 11) { + pt1 = t1.ptSmeared(); + eta1 = t1.etaSmeared(); + phi1 = t1.phiSmeared(); + pt2 = t2.ptSmeared(); + eta2 = t2.etaSmeared(); + phi2 = t2.phiSmeared(); + } else if (std::abs(mccuts.cfgPdgCodeLepton) == 13) { + if (mccuts.cfgMuonTrackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + pt1 = t1.ptSmeared_sa_muon(); + eta1 = t1.etaSmeared_sa_muon(); + phi1 = t1.phiSmeared_sa_muon(); + pt2 = t2.ptSmeared_sa_muon(); + eta2 = t2.etaSmeared_sa_muon(); + phi2 = t2.phiSmeared_sa_muon(); + } else if (mccuts.cfgMuonTrackType == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + pt1 = t1.ptSmeared_gl_muon(); + eta1 = t1.etaSmeared_gl_muon(); + phi1 = t1.phiSmeared_gl_muon(); + pt2 = t2.ptSmeared_gl_muon(); + eta2 = t2.etaSmeared_gl_muon(); + phi2 = t2.phiSmeared_gl_muon(); + } else { + pt1 = t1.pt(); + eta1 = t1.eta(); + phi1 = t1.phi(); + pt2 = t2.pt(); + eta2 = t2.eta(); + phi2 = t2.phi(); + } + } + } else { + pt1 = t1.pt(); + eta1 = t1.eta(); + phi1 = t1.phi(); + pt2 = t2.pt(); + eta2 = t2.eta(); + phi2 = t2.phi(); + } + + ROOT::Math::PtEtaPhiMVector v1(pt1, eta1, phi1, leptonMass); + ROOT::Math::PtEtaPhiMVector v2(pt2, eta2, phi2, leptonMass); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + + if (v12.Rapidity() < mccuts.cfgMinEtaGen || mccuts.cfgMaxEtaGen < v12.Rapidity()) { + return; + } + + int mother_id = FindLF(t1, t2, mcParticles); + int hfll_type = IsHF(t1, t2, mcParticles); + + if (mother_id > 0) { // same mother (photon, LF, Quarkonia) + const auto& mp = mcParticles.iteratorAt(mother_id); + if (!(mp.isPhysicalPrimary() || mp.producedByGenerator())) { + return; + } + switch (std::abs(mp.pdgCode())) { + case 111: + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("Pi0/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case 221: + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("Eta/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case 331: + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("EtaPrime/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case 113: + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("Rho/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case 223: + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("Omega/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case 333: + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("Phi/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case 443: + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("JPsi/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + default: + break; + } + } else if (hfll_type > -1) { // HFll + switch (hfll_type) { + case static_cast(EM_HFeeType::kCe_Ce): // ULS + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("ccbar/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case static_cast(EM_HFeeType::kBe_Be): // ULS + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("bbbar/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case static_cast(EM_HFeeType::kBCe_BCe): // ULS + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("bbbar/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("bbbar/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + break; + case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS + fRegistry.fill(HIST("Pair/") + HIST(evNames[evtype]) + HIST("bbbar/") + HIST(dileptonSigns[signtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + default: + break; + } + } + } + + template + void runMC(TMCCollisions const& mcCollisions, TMCParticles const& mcParticles, TBCs const&, TCollisions const& collisions, TMCPosLeptons const& mcPosLeptons, TMCNegLeptons const& mcNegLeptons) + { + for (const auto& mcCollision : mcCollisions) { + + if (mccuts.cfgEventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != mccuts.cfgEventGeneratorType) { + continue; + } + + const auto& bc_from_mcCollision = mcCollision.template bc_as(); + bool isSelectedMC = isSelectedCollision(mcCollision, bc_from_mcCollision); + + const auto& reccolls_per_mccoll = collisions.sliceBy(recColperMcCollision, mcCollision.globalIndex()); + int nselreccolls_per_mccoll = 0; + for (const auto& rec_col : reccolls_per_mccoll) { + if (isSelectedCollision(rec_col, rec_col.template foundBC_as())) { + nselreccolls_per_mccoll++; + } + } // end of reconstructed collision + fRegistry.fill(HIST("Event/allMC/hReccollsPerMCcoll"), reccolls_per_mccoll.size()); + fRegistry.fill(HIST("Event/allMC/hSelReccollsPerMCcoll"), nselreccolls_per_mccoll); + + bool isSelectedRec = false; + bool hasRecCollision = false; + if (mcCollision.mpemeventId() >= 0) { + hasRecCollision = true; + const auto& collision = collisions.rawIteratorAt(mcCollision.mpemeventId()); // most probable reconstructed collision + const auto& bc_from_collision = collision.template foundBC_as(); + isSelectedRec = isSelectedCollision(collision, bc_from_collision); + fRegistry.fill(HIST("Event/hDiffBC"), bc_from_collision.globalBC() - bc_from_mcCollision.globalBC()); + } + fRegistry.fill(HIST("Event/allMC/hZvtx"), mcCollision.posZ()); + fRegistry.fill(HIST("Event/allMC/hImpactParameter"), mcCollision.impactParameter()); + + if (isSelectedMC) { + fRegistry.fill(HIST("Event/selectedMC/hReccollsPerMCcoll"), reccolls_per_mccoll.size()); + fRegistry.fill(HIST("Event/selectedMC/hSelReccollsPerMCcoll"), nselreccolls_per_mccoll); + fRegistry.fill(HIST("Event/selectedMC/hZvtx"), mcCollision.posZ()); + fRegistry.fill(HIST("Event/selectedMC/hImpactParameter"), mcCollision.impactParameter()); + if (hasRecCollision) { + fRegistry.fill(HIST("Event/selectedMC_and_Rec/hReccollsPerMCcoll"), reccolls_per_mccoll.size()); + fRegistry.fill(HIST("Event/selectedMC_and_Rec/hSelReccollsPerMCcoll"), nselreccolls_per_mccoll); + fRegistry.fill(HIST("Event/selectedMC_and_Rec/hZvtx"), mcCollision.posZ()); + fRegistry.fill(HIST("Event/selectedMC_and_Rec/hImpactParameter"), mcCollision.impactParameter()); + if (isSelectedRec) { + fRegistry.fill(HIST("Event/selectedMC_and_selectedRec/hReccollsPerMCcoll"), reccolls_per_mccoll.size()); + fRegistry.fill(HIST("Event/selectedMC_and_selectedRec/hSelReccollsPerMCcoll"), nselreccolls_per_mccoll); + fRegistry.fill(HIST("Event/selectedMC_and_selectedRec/hZvtx"), mcCollision.posZ()); + fRegistry.fill(HIST("Event/selectedMC_and_selectedRec/hImpactParameter"), mcCollision.impactParameter()); + } + } + } + + // store MC true information + const auto& posLeptons_per_mccollision = mcPosLeptons.sliceBy(perMcCollision, mcCollision.globalIndex()); + const auto& negLeptons_per_mccollision = mcNegLeptons.sliceBy(perMcCollision, mcCollision.globalIndex()); + + for (const auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posLeptons_per_mccollision, negLeptons_per_mccollision))) { // ULS + fillTrueInfo<0, 0, isSmeared>(pos, neg, mcParticles); + if (isSelectedMC) { + fillTrueInfo<1, 0, isSmeared>(pos, neg, mcParticles); + if (hasRecCollision) { + fillTrueInfo<2, 0, isSmeared>(pos, neg, mcParticles); + if (isSelectedRec) { + fillTrueInfo<3, 0, isSmeared>(pos, neg, mcParticles); + } + } + } + } // end of ULS pair loop + + for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posLeptons_per_mccollision, posLeptons_per_mccollision))) { // LS++ + fillTrueInfo<0, 1, isSmeared>(pos1, pos2, mcParticles); + if (isSelectedMC) { + fillTrueInfo<1, 1, isSmeared>(pos1, pos2, mcParticles); + if (hasRecCollision) { + fillTrueInfo<2, 1, isSmeared>(pos1, pos2, mcParticles); + if (isSelectedRec) { + fillTrueInfo<3, 1, isSmeared>(pos1, pos2, mcParticles); + } + } + } + } // end of LS++ pair loop + + for (auto& [neg1, neg2] : combinations(CombinationsStrictlyUpperIndexPolicy(negLeptons_per_mccollision, negLeptons_per_mccollision))) { // LS-- + fillTrueInfo<0, 2, isSmeared>(neg1, neg2, mcParticles); + if (isSelectedMC) { + fillTrueInfo<1, 2, isSmeared>(neg1, neg2, mcParticles); + if (hasRecCollision) { + fillTrueInfo<2, 2, isSmeared>(neg1, neg2, mcParticles); + if (isSelectedRec) { + fillTrueInfo<3, 2, isSmeared>(neg1, neg2, mcParticles); + } + } + } + } // end of LS-- pair loop + + } // end of mc collision loop + + } // end of skimmingMC + + SliceCache cache; + Preslice perMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted recColperMcCollision = aod::mccollisionlabel::mcCollisionId; + + using MyMcCollisions = soa::Join; + + Filter collisionFilter = eventcuts.cfgMinImpPar < o2::aod::mccollision::impactParameter && o2::aod::mccollision::impactParameter < eventcuts.cfgMaxImpPar; + using FilteredMyMcCollisions = soa::Filtered; + + Partition McPosLeptons = o2::aod::mcparticle::pdgCode == -mccuts.cfgPdgCodeLepton && (mccuts.cfgMinPtGen < o2::aod::mcparticle::pt && o2::aod::mcparticle::pt < mccuts.cfgMaxPtGen) && (mccuts.cfgMinEtaGen < o2::aod::mcparticle::eta && o2::aod::mcparticle::eta < mccuts.cfgMaxEtaGen); + Partition McNegLeptons = o2::aod::mcparticle::pdgCode == mccuts.cfgPdgCodeLepton && (mccuts.cfgMinPtGen < o2::aod::mcparticle::pt && o2::aod::mcparticle::pt < mccuts.cfgMaxPtGen) && (mccuts.cfgMinEtaGen < o2::aod::mcparticle::eta && o2::aod::mcparticle::eta < mccuts.cfgMaxEtaGen); + + using SmearedMcParticles = soa::Join; + Partition McPosLeptonsSmeared = o2::aod::mcparticle::pdgCode == -mccuts.cfgPdgCodeLepton && ifnode(mccuts.cfgPdgCodeLepton.node() == 11, (mccuts.cfgMinPtGen.node() < o2::aod::smearedtrack::ptSmeared && o2::aod::smearedtrack::ptSmeared < mccuts.cfgMaxPtGen.node()) && (mccuts.cfgMinEtaGen.node() < o2::aod::smearedtrack::etaSmeared && o2::aod::smearedtrack::etaSmeared < mccuts.cfgMaxEtaGen.node()), ifnode(mccuts.cfgMuonTrackType.node() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack), (mccuts.cfgMinPtGen.node() < o2::aod::smearedtrack::ptSmeared_gl_muon && o2::aod::smearedtrack::ptSmeared_gl_muon < mccuts.cfgMaxPtGen.node()) && (mccuts.cfgMinEtaGen.node() < o2::aod::smearedtrack::etaSmeared_gl_muon && o2::aod::smearedtrack::etaSmeared_gl_muon < mccuts.cfgMaxEtaGen.node()), (mccuts.cfgMinPtGen.node() < o2::aod::smearedtrack::ptSmeared_sa_muon && o2::aod::smearedtrack::ptSmeared_sa_muon < mccuts.cfgMaxPtGen.node()) && (mccuts.cfgMinEtaGen.node() < o2::aod::smearedtrack::etaSmeared_sa_muon && o2::aod::smearedtrack::etaSmeared_sa_muon < mccuts.cfgMaxEtaGen.node()))); + Partition McNegLeptonsSmeared = o2::aod::mcparticle::pdgCode == mccuts.cfgPdgCodeLepton && ifnode(mccuts.cfgPdgCodeLepton.node() == 11, (mccuts.cfgMinPtGen.node() < o2::aod::smearedtrack::ptSmeared && o2::aod::smearedtrack::ptSmeared < mccuts.cfgMaxPtGen.node()) && (mccuts.cfgMinEtaGen.node() < o2::aod::smearedtrack::etaSmeared && o2::aod::smearedtrack::etaSmeared < mccuts.cfgMaxEtaGen.node()), ifnode(mccuts.cfgMuonTrackType.node() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack), (mccuts.cfgMinPtGen.node() < o2::aod::smearedtrack::ptSmeared_gl_muon && o2::aod::smearedtrack::ptSmeared_gl_muon < mccuts.cfgMaxPtGen.node()) && (mccuts.cfgMinEtaGen.node() < o2::aod::smearedtrack::etaSmeared_gl_muon && o2::aod::smearedtrack::etaSmeared_gl_muon < mccuts.cfgMaxEtaGen.node()), (mccuts.cfgMinPtGen.node() < o2::aod::smearedtrack::ptSmeared_sa_muon && o2::aod::smearedtrack::ptSmeared_sa_muon < mccuts.cfgMaxPtGen.node()) && (mccuts.cfgMinEtaGen.node() < o2::aod::smearedtrack::etaSmeared_sa_muon && o2::aod::smearedtrack::etaSmeared_sa_muon < mccuts.cfgMaxEtaGen.node()))); + + void processMC(FilteredMyMcCollisions const& mcCollisions, aod::McParticles const& mcParticles, soa::Join const& bcs, soa::Join const& collisions) + { + runMC(mcCollisions, mcParticles, bcs, collisions, McPosLeptons, McNegLeptons); + } + PROCESS_SWITCH(studyMCTruth, processMC, "process MC", true); + + void processMCSmeared(FilteredMyMcCollisions const& mcCollisions, SmearedMcParticles const& mcParticles, soa::Join const& bcs, soa::Join const& collisions) + { + runMC(mcCollisions, mcParticles, bcs, collisions, McPosLeptonsSmeared, McNegLeptonsSmeared); + } + PROCESS_SWITCH(studyMCTruth, processMCSmeared, "processMC with smeared values", false); + + void processDummy(FilteredMyMcCollisions const&) {} + PROCESS_SWITCH(studyMCTruth, processDummy, "process Dummy", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"study-mc-truth"})}; +} diff --git a/PWGEM/Dilepton/Tasks/tableReaderBarrel.cxx b/PWGEM/Dilepton/Tasks/tableReaderBarrel.cxx index d78ef01676c..819a85efe65 100644 --- a/PWGEM/Dilepton/Tasks/tableReaderBarrel.cxx +++ b/PWGEM/Dilepton/Tasks/tableReaderBarrel.cxx @@ -291,8 +291,6 @@ struct AnalysisTrackSelection { Configurable fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; Configurable fConfigComputeTPCpostCalib{"cfgTPCpostCalib", false, "If true, compute TPC post-calibrated n-sigmas"}; Configurable fConfigRunPeriods{"cfgRunPeriods", "LHC22f", "run periods for used data"}; - Configurable fConfigDummyRunlist{"cfgDummyRunlist", false, "If true, use dummy runlist"}; - Configurable fConfigInitRunNumber{"cfgInitRunNumber", 543215, "Initial run number used in run by run checks"}; Configurable fConfigNbTrackCut{"cfgNbTrackCut", 1, "Number of cuts including prefilter cut, need to be below 30"}; std::vector fTrackCuts; @@ -372,9 +370,6 @@ struct AnalysisTrackSelection { VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } - if (fConfigDummyRunlist) { - VarManager::SetDummyRunlist(fConfigInitRunNumber); - } if (fConfigComputeTPCpostCalib) { // CCDB configuration fCCDB->setURL(fConfigCcdbUrl.value); diff --git a/PWGEM/Dilepton/Tasks/taggingHFE.cxx b/PWGEM/Dilepton/Tasks/taggingHFE.cxx new file mode 100644 index 00000000000..f843b20819a --- /dev/null +++ b/PWGEM/Dilepton/Tasks/taggingHFE.cxx @@ -0,0 +1,1415 @@ +// 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. + +/// \file taggingHFE.cxx +/// \brief a task to study tagging e from charm hadron decays in MC +/// \author daiki.sekihata@cern.ch + +#include +#include +#include +#include +#include + +#include "Math/Vector4D.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsBase/GeometryManager.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "CCDB/BasicCCDBManager.h" +#include "Common/Core/trackUtilities.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/TableHelper.h" +#include "Common/Core/RecoDecay.h" +#include "DCAFitter/DCAFitterN.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/PIDResponse.h" +#include "PWGEM/Dilepton/Utils/MCUtilities.h" + +using namespace o2; +using namespace o2::soa; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +struct taggingHFE { + using MyCollisions = soa::Join; + + using MyTracks = soa::Join; + + using MyV0s = soa::Join; + + // Configurables + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; + Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; + Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; + Configurable d_UseAbsDCA{"d_UseAbsDCA", true, "Use Abs DCAs"}; + Configurable d_UseWeightedPCA{"d_UseWeightedPCA", false, "Vertices use cov matrices"}; + + struct : ConfigurableGroup { + std::string prefix = "electroncut_group"; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.05, "min pT for single track"}; + Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.9, "min eta for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.9, "max eta for single track"}; + Configurable cfg_min_cr2findable_ratio_tpc{"cfg_min_cr2findable_ratio_tpc", 0.8, "min. TPC Ncr/Nf ratio"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 0.7, "max fraction of shared clusters in TPC"}; + Configurable cfg_min_ncrossedrows_tpc{"cfg_min_ncrossedrows_tpc", 70, "min ncrossed rows"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; + Configurable cfg_min_ncluster_itsib{"cfg_min_ncluster_itsib", 1, "min ncluster itsib"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_chi2tof{"cfg_max_chi2tof", 1e+10, "max chi2/NclsTOF"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.3, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.3, "max dca Z for single track in cm"}; + } electroncuts; + + struct : ConfigurableGroup { + std::string prefix = "kaoncut_group"; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.05, "min pT for single track"}; + Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -1.2, "min eta for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", +1.2, "max eta for single track"}; + Configurable cfg_min_cr2findable_ratio_tpc{"cfg_min_cr2findable_ratio_tpc", 0.8, "min. TPC Ncr/Nf ratio"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 0.7, "max fraction of shared clusters in TPC"}; + Configurable cfg_min_ncrossedrows_tpc{"cfg_min_ncrossedrows_tpc", 40, "min ncrossed rows"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 4, "min ncluster its"}; + Configurable cfg_min_ncluster_itsib{"cfg_min_ncluster_itsib", 1, "min ncluster itsib"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + Configurable cfg_max_chi2tof{"cfg_max_chi2tof", 1e+10, "max chi2/NclsTOF"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.5, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.5, "max dca Z for single track in cm"}; + Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -3, "min n sigma ka in TPC"}; + Configurable cfg_max_TPCNsigmaKa{"cfg_max_TPCNsigmaKa", +3, "max n sigma ka in TPC"}; + Configurable cfg_min_TOFNsigmaKa{"cfg_min_TOFNsigmaKa", -3, "min n sigma ka in TOF"}; + Configurable cfg_max_TOFNsigmaKa{"cfg_max_TOFNsigmaKa", +3, "max n sigma ka in TOF"}; + } kaoncuts; + + struct : ConfigurableGroup { + std::string prefix = "svcut_group"; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.8, "min cospa"}; + Configurable cfg_min_cospaXY{"cfg_min_cospaXY", 0.8, "min cospaXY"}; + Configurable cfg_max_dca2legs{"cfg_max_dca2legs", 1.0, "max distance between 2 legs"}; + Configurable cfg_min_lxy{"cfg_min_lxy", -1, "min lxy for charm hadron candidate"}; + Configurable cfg_max_mass_eK{"cfg_max_mass_eK", 2.0, "max mass for eK pair"}; + Configurable cfg_max_mass_eL{"cfg_max_mass_eL", 2.3, "max mass for eL pair"}; + } svcuts; + + struct : ConfigurableGroup { + std::string prefix = "v0cut_group"; + Configurable cfg_min_mass_k0s{"cfg_min_mass_k0s", 0.485, "min mass for K0S"}; + Configurable cfg_max_mass_k0s{"cfg_max_mass_k0s", 0.510, "max mass for K0S"}; + Configurable cfg_min_mass_lambda{"cfg_min_mass_lambda", 1.11, "min mass for Lambda rejection"}; + Configurable cfg_max_mass_lambda{"cfg_max_mass_lambda", 1.12, "max mass for Lambda rejection"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.95, "min cospa for v0hadron"}; + Configurable cfg_max_dca2legs{"cfg_max_dca2legs", 0.2, "max distance between 2 legs for v0hadron"}; + // Configurable cfg_min_radius{"cfg_min_radius", 0.1, "min rxy for v0hadron"}; + Configurable cfg_min_cr2findable_ratio_tpc{"cfg_min_cr2findable_ratio_tpc", 0.8, "min. TPC Ncr/Nf ratio"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_min_ncrossedrows_tpc{"cfg_min_ncrossedrows_tpc", 40, "min ncrossed rows"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 2, "min ncluster its"}; + Configurable cfg_min_ncluster_itsib{"cfg_min_ncluster_itsib", 0, "min ncluster itsib"}; + Configurable cfg_max_chi2tof{"cfg_max_chi2tof", 1e+10, "max chi2 for TOF"}; + Configurable cfg_min_dcaxy{"cfg_min_dcaxy", 0.1, "min dca XY for v0 legs in cm"}; + + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -3, "min n sigma pi in TPC"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3, "max n sigma pi in TPC"}; + Configurable cfg_min_TPCNsigmaPr{"cfg_min_TPCNsigmaPr", -3, "min n sigma pr in TPC"}; + Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +3, "max n sigma pr in TPC"}; + Configurable cfg_min_TOFNsigmaPi{"cfg_min_TOFNsigmaPi", -3, "min n sigma pi in TOF"}; + Configurable cfg_max_TOFNsigmaPi{"cfg_max_TOFNsigmaPi", +3, "max n sigma pi in TOF"}; + Configurable cfg_min_TOFNsigmaPr{"cfg_min_TOFNsigmaPr", -3, "min n sigma pr in TOF"}; + Configurable cfg_max_TOFNsigmaPr{"cfg_max_TOFNsigmaPr", +3, "max n sigma pr in TOF"}; + } v0cuts; + + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgCentMin{"cfgCentMin", -1.f, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; + Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; + Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + + Configurable cfgEventGeneratorType{"cfgEventGeneratorType", -1, "if positive, select event generator type. i.e. gap or signal"}; + + HistogramRegistry fRegistry{"fRegistry"}; + static constexpr std::string_view hadron_names[6] = {"LF/", "Jpsi/", "D0/", "Dpm/", "Ds/", "Lc/"}; + static constexpr std::string_view pair_names[3] = {"e_Kpm/", "e_K0S/", "e_Lambda/"}; + static constexpr std::string_view hTypes[4] = {"findable/", "correct/", "fake/", "miss/"}; + static constexpr std::string_view promptTypes[2] = {"prompt/", "nonprompt/"}; + + void init(o2::framework::InitContext&) + { + if (doprocessSA && doprocessTTCA) { + LOGF(fatal, "Cannot enable doprocessWithoutFTTCA and doprocessWithFTTCA at the same time. Please choose one."); + } + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + fitter.setPropagateToPCA(true); + fitter.setMaxR(10.f); + fitter.setMinParamChange(1e-3); + fitter.setMinRelChi2Change(0.9); + fitter.setMaxDZIni(1e9); + fitter.setMaxChi2(1e9); + fitter.setUseAbsDCA(d_UseAbsDCA); + fitter.setWeightedFinalPCA(d_UseWeightedPCA); + fitter.setMatCorrType(matCorr); + + addHistograms(); + } + + int mRunNumber; + float d_bz; + Service ccdb; + // o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + const o2::dataformats::MeanVertexObject* mMeanVtx = nullptr; + o2::base::MatLayerCylSet* lut = nullptr; + o2::vertexing::DCAFitterN<2> fitter; + o2::dataformats::DCA mDcaInfoCov; + o2::dataformats::VertexBase mVtx; + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + + // load matLUT for this timestamp + if (!lut) { + LOG(info) << "Loading material look-up table for timestamp: " << bc.timestamp(); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(lutPath, bc.timestamp())); + } else { + LOG(info) << "Material look-up table already in place. Not reloading."; + } + + // In case override, don't proceed, please - no CCDB access required + if (d_bz_input > -990) { + d_bz = d_bz_input; + o2::parameters::GRPMagField grpmag; + if (std::fabs(d_bz) > 1e-5) { + grpmag.setL3Current(30000.f / (d_bz / 5.0f)); + } + o2::base::Propagator::initFieldFromGRP(&grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + mRunNumber = bc.runNumber(); + return; + } + + auto run3grp_timestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = 0x0; + o2::parameters::GRPMagField* grpmag = 0x0; + if (!skipGRPOquery) { + grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + } + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + // Fetch magnetic field from ccdb for current collision + d_bz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + o2::base::Propagator::Instance()->setMatLUT(lut); + mMeanVtx = ccdb->getForTimeStamp(mVtxPath, bc.timestamp()); + + // Fetch magnetic field from ccdb for current collision + d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } + mRunNumber = bc.runNumber(); + fitter.setBz(d_bz); + } + + void addHistograms() + { + auto hCollisionCounter = fRegistry.add("Event/hCollisionCounter", "collision counter", kTH1D, {{5, -0.5f, 4.5f}}, false); + hCollisionCounter->GetXaxis()->SetBinLabel(1, "all"); + hCollisionCounter->GetXaxis()->SetBinLabel(2, "accepted"); + + fRegistry.add("Event/hZvtx", "vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); + fRegistry.add("Event/hMultNTracksPV", "hMultNTracksPV; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); + fRegistry.add("Event/hMultNTracksPVeta1", "hMultNTracksPVeta1; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); + fRegistry.add("Event/hMultFT0", "hMultFT0;mult. FT0A;mult. FT0C", kTH2F, {{200, 0, 200000}, {60, 0, 60000}}, false); + fRegistry.add("Event/hCentFT0A", "hCentFT0A;centrality FT0A (%)", kTH1F, {{110, 0, 110}}, false); + fRegistry.add("Event/hCentFT0C", "hCentFT0C;centrality FT0C (%)", kTH1F, {{110, 0, 110}}, false); + fRegistry.add("Event/hCentFT0M", "hCentFT0M;centrality FT0M (%)", kTH1F, {{110, 0, 110}}, false); + fRegistry.add("Event/hCentFT0CvsMultNTracksPV", "hCentFT0CvsMultNTracksPV;centrality FT0C (%);N_{track} to PV", kTH2F, {{110, 0, 110}, {600, 0, 6000}}, false); + fRegistry.add("Event/hMultFT0CvsMultNTracksPV", "hMultFT0CvsMultNTracksPV;mult. FT0C;N_{track} to PV", kTH2F, {{60, 0, 60000}, {600, 0, 6000}}, false); + + // for charm hadrons + fRegistry.add("e_Kpm/all/hLxy", "decay length XY from PV;L_{xy} (cm)", kTH1F, {{500, 0, 0.5}}, false); + fRegistry.add("e_Kpm/all/hLz", "decay length Z from PV;L_{z} (cm)", kTH1F, {{500, 0, 0.5}}, false); + fRegistry.add("e_Kpm/all/hCosPA", "cosPA;cosine of pointing angle", kTH1F, {{200, 0.8, 1}}, false); + fRegistry.add("e_Kpm/all/hCosPAXY", "cosPA in XY;cosine of pointing angle in XY", kTH1F, {{200, 0.8, 1}}, false); + fRegistry.add("e_Kpm/all/hDCA2Legs", "distance between 2 legs;distance between 2 legs (cm)", kTH1F, {{500, 0, 0.5}}, false); + fRegistry.add("e_Kpm/all/hMass", "mass;mass (GeV/c^{2})", kTH1F, {{200, 0.5, 2.5}}, false); + fRegistry.add("e_Kpm/all/hMass_CosPA", "mass vs. cosPA;mass (GeV/c^{2});cosine of pointing angle", kTH2F, {{200, 0.5, 2.5}, {200, 0.8, 1.0}}, false); + fRegistry.add("e_Kpm/all/hDeltaEtaDeltaPhi", "#Delta#varphi vs. #Delta#eta;#Delta#varphi = #varphi_{h} - #varphi_{e} (rad.);#Delta#eta = #eta_{h} - #eta_{e}", kTH2F, {{180, -M_PI, M_PI}, {200, -2, +2}}, false); + fRegistry.add("e_Kpm/all/hRelDeltaPt", "rel delta pT;(p_{T,h} - p_{T,e})/p_{T,e}", kTH1F, {{80, -2, +2}}, false); + fRegistry.add("e_Kpm/all/hProdDCAxy", "product of DCAxy;d_{xy}^{e} #times d_{xy}^{h} (#sigma)^{2}", kTH1F, {{200, -100, +100}}, false); + fRegistry.add("e_Kpm/all/hCorrelationDCAxy", "correlation of DCAxy;DCA^{xy}_{e} (#sigma);DCA^{xy}_{h} (#sigma)", kTH2F, {{200, -10, +10}, {200, -10, +10}}, false); + fRegistry.add("e_Kpm/all/hCorrelationDCAz", "correlation of DCAz;DCA^{z}_{e} (#sigma);DCA^{z}_{h} (#sigma)", kTH2F, {{200, -10, +10}, {200, -10, +10}}, false); + + fRegistry.addClone("e_Kpm/all/", "e_Kpm/D0/"); + fRegistry.addClone("e_Kpm/all/", "e_Kpm/Dpm/"); + fRegistry.addClone("e_Kpm/all/", "e_Kpm/Ds/"); + fRegistry.addClone("e_Kpm/all/", "e_Kpm/fake/"); + + fRegistry.addClone("e_Kpm/all/", "e_K0S/all/"); + fRegistry.addClone("e_Kpm/all/", "e_K0S/D0/"); + fRegistry.addClone("e_Kpm/all/", "e_K0S/Dpm/"); + fRegistry.addClone("e_Kpm/all/", "e_K0S/Ds/"); + fRegistry.addClone("e_Kpm/all/", "e_K0S/fake/"); + + fRegistry.addClone("e_Kpm/all/", "e_Lambda/all/"); + fRegistry.addClone("e_Kpm/all/", "e_Lambda/Lc/"); + fRegistry.addClone("e_Kpm/all/", "e_Lambda/fake/"); + + // for V0s + fRegistry.add("V0/K0S/hPt", "pT of V0;p_{T} (GeV/c)", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("V0/K0S/hYPhi", "Y vs. #varphi of V0;#varphi (rad.);rapidity", kTH2F, {{36, 0, 2 * M_PI}, {80, -2, +2}}, false); + fRegistry.add("V0/K0S/hAP", "Ap plot;#alpha;q_{T} (GeV/c)", kTH2F, {{200, -1, 1}, {250, 0, 0.25}}, false); + fRegistry.add("V0/K0S/hLxy", "decay length from PV;L_{xy} (cm)", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("V0/K0S/hCosPA", "cosPA;cosine of pointing angle", kTH1F, {{100, 0.9, 1}}, false); + fRegistry.add("V0/K0S/hDCA2Legs", "distance between 2 legs;distance between 2 legs (cm)", kTH1F, {{100, 0, 1}}, false); + fRegistry.addClone("V0/K0S/", "V0/Lambda/"); + fRegistry.addClone("V0/K0S/", "V0/AntiLambda/"); + fRegistry.add("V0/K0S/hMassK0S", "K0S mass;m_{#pi#pi} (GeV/c^{2})", kTH1F, {{100, 0.45, 0.55}}, false); + fRegistry.add("V0/Lambda/hMassLambda", "Lambda mass;m_{p#pi} (GeV/c^{2})", kTH1F, {{100, 1.08, 1.18}}, false); + fRegistry.add("V0/AntiLambda/hMassAntiLambda", "Anti-Lambda mass;m_{p#pi} (GeV/c^{2})", kTH1F, {{100, 1.08, 1.18}}, false); + + const AxisSpec axis_pt{{0, 0.05, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 6, 7, 8, 9, 10}, "p_{T,e} (GeV/c)"}; + const AxisSpec axis_dca_sigma{{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10}, "DCA_{e}^{3D} (#sigma)"}; + + // for tracks + fRegistry.add("LF/electron/prompt/findable/hs", "electron;p_{T,e} (GeV/c);#eta_{e};#varphi_{e} (rad.);DCA_{e}^{3D} (#sigma)", kTHnSparseF, {{axis_pt}, {80, -2, +2}, {36, 0, 2 * M_PI}, {axis_dca_sigma}}, false); + fRegistry.add("LF/electron/prompt/findable/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); + fRegistry.add("LF/electron/prompt/findable/hTOFbeta", "TOF #beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, false); + + fRegistry.addClone("LF/electron/prompt/findable/", "LF/electron/prompt/correct/"); + fRegistry.addClone("LF/electron/prompt/findable/", "LF/electron/prompt/fake/"); + fRegistry.addClone("LF/electron/prompt/", "LF/electron/nonprompt/"); + fRegistry.addClone("LF/electron/", "Jpsi/electron/"); + + fRegistry.addClone("LF/electron/", "D0/electron/"); // D0 -> K- e+ nu, Br = 0.03549 | D0 -> K- e+ pi0 nu, Br = 0.016 | D0 -> K*(892)- e+ nu, Br = 0.0215 // D0 -> anti-K0S e+ pi- nu, Br = 0.0144 + fRegistry.addClone("LF/electron/", "Dpm/electron/"); // D+ -> K- pi+ e+ nu, Br = 0.0402 | D+ -> anti-K*(892)0 e+ nu, Br = 0.0540 // D+ -> anti-K0S e+ nu, Br = 0.0872 + fRegistry.addClone("LF/electron/", "Ds/electron/"); // Ds+ -> K0S e+ nu, Br = 0.0034 // Ds+ -> phi e+ nu, Br = 0.0239 + fRegistry.addClone("LF/electron/", "Lc/electron/"); // Lc+ -> L e+ nu, Br = 0.0356 + + fRegistry.addClone("D0/electron/", "D0/kaon/"); // D0 -> K- e+ nu, Br = 0.03549 | D0 -> K- e+ pi0 nu, Br = 0.016 | D0 -> K*(892)- e+ nu, Br = 0.0215 // D0 -> anti-K0S e+ pi- nu, Br = 0.0144 + fRegistry.addClone("Dpm/electron/", "Dpm/kaon/"); // D+ -> K- pi+ e+ nu, Br = 0.0402 | D+ -> anti-K*(892)0 e+ nu, Br = 0.0540 // D+ -> anti-K0S e+ nu, Br = 0.0872 + fRegistry.addClone("Ds/electron/", "Ds/kaon/"); // Ds+ -> K0S e+ nu, Br = 0.0034 // Ds+ -> phi e+ nu, Br = 0.0239 + + fRegistry.add("Generated/D0/prompt/hs", "#eta correlation from charm hadron;p_{T,e} (GeV/c);p_{T,K} (GeV/c);#eta_{e};#eta_{K};", kTHnSparseF, {{100, 0, 10}, {100, 0, 10}, {200, -10, +10}, {200, -10, 10}}, false); + fRegistry.addClone("Generated/D0/prompt/", "Generated/D0/nonprompt/"); + } + + template + bool isKaon(TTrack const& track) + { + // TOFif + bool is_ka_included_TPC = kaoncuts.cfg_min_TPCNsigmaKa < track.tpcNSigmaKa() && track.tpcNSigmaKa() < kaoncuts.cfg_max_TPCNsigmaKa; + bool is_ka_included_TOF = track.hasTOF() ? (kaoncuts.cfg_min_TOFNsigmaKa < track.tofNSigmaKa() && track.tofNSigmaKa() < kaoncuts.cfg_max_TOFNsigmaKa && track.tofChi2() < kaoncuts.cfg_max_chi2tof) : true; + return is_ka_included_TPC && is_ka_included_TOF; + } + + template + bool isPion(TTrack const& track) + { + // TOFif + bool is_pi_included_TPC = v0cuts.cfg_min_TPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < v0cuts.cfg_max_TPCNsigmaPi; + bool is_pi_included_TOF = track.hasTOF() ? (v0cuts.cfg_min_TOFNsigmaPi < track.tofNSigmaPi() && track.tofNSigmaPi() < v0cuts.cfg_max_TOFNsigmaPi && track.tofChi2() < v0cuts.cfg_max_chi2tof) : true; + return is_pi_included_TPC && is_pi_included_TOF; + } + + template + bool isProton(TTrack const& track) + { + // TOFif + bool is_pr_included_TPC = v0cuts.cfg_min_TPCNsigmaPr < track.tpcNSigmaPr() && track.tpcNSigmaPr() < v0cuts.cfg_max_TPCNsigmaPr; + bool is_pr_included_TOF = track.hasTOF() ? (v0cuts.cfg_min_TOFNsigmaPr < track.tofNSigmaPr() && track.tofNSigmaPr() < v0cuts.cfg_max_TOFNsigmaPr && track.tofChi2() < v0cuts.cfg_max_chi2tof) : true; + return is_pr_included_TPC && is_pr_included_TOF; + } + + template + bool isSelectedTrackForElectron(TTrack const& track, TTrackParCov const& trackParCov, const float dcaXY, const float dcaZ) + { + if (!track.hasITS() || !track.hasTPC()) { + return false; + } + + if (trackParCov.getPt() < electroncuts.cfg_min_pt_track || electroncuts.cfg_max_pt_track < trackParCov.getPt()) { + return false; + } + + if (trackParCov.getEta() < electroncuts.cfg_min_eta_track || electroncuts.cfg_max_eta_track < trackParCov.getEta()) { + return false; + } + + if (std::fabs(dcaXY) > electroncuts.cfg_max_dcaxy) { + return false; + } + + if (std::fabs(dcaZ) > electroncuts.cfg_max_dcaz) { + return false; + } + + if (track.itsChi2NCl() > electroncuts.cfg_max_chi2its) { + return false; + } + + if (track.itsNCls() < electroncuts.cfg_min_ncluster_its) { + return false; + } + + if (track.itsNClsInnerBarrel() < electroncuts.cfg_min_ncluster_itsib) { + return false; + } + + if (track.tpcChi2NCl() > electroncuts.cfg_max_chi2tpc) { + return false; + } + + if (track.tpcNClsFound() < electroncuts.cfg_min_ncluster_tpc) { + return false; + } + + if (track.tpcNClsCrossedRows() < electroncuts.cfg_min_ncrossedrows_tpc) { + return false; + } + + if (track.tpcCrossedRowsOverFindableCls() < electroncuts.cfg_min_cr2findable_ratio_tpc) { + return false; + } + + if (track.tpcFractionSharedCls() > electroncuts.cfg_max_frac_shared_clusters_tpc) { + return false; + } + + return true; + } + + template + bool isSelectedTrackForKaon(TTrack const& track, TTrackParCov const& trackParCov, const float dcaXY, const float dcaZ) + { + if (!track.hasITS() || !track.hasTPC()) { + return false; + } + + if (trackParCov.getPt() < kaoncuts.cfg_min_pt_track || kaoncuts.cfg_max_pt_track < trackParCov.getPt()) { + return false; + } + + if (trackParCov.getEta() < kaoncuts.cfg_min_eta_track || kaoncuts.cfg_max_eta_track < trackParCov.getEta()) { + return false; + } + + if (std::fabs(dcaXY) > kaoncuts.cfg_max_dcaxy) { + return false; + } + + if (std::fabs(dcaZ) > kaoncuts.cfg_max_dcaz) { + return false; + } + + if (track.itsChi2NCl() > kaoncuts.cfg_max_chi2its) { + return false; + } + + if (track.itsNCls() < kaoncuts.cfg_min_ncluster_its) { + return false; + } + + if (track.itsNClsInnerBarrel() < kaoncuts.cfg_min_ncluster_itsib) { + return false; + } + + if (track.tpcChi2NCl() > kaoncuts.cfg_max_chi2tpc) { + return false; + } + + if (track.tpcNClsFound() < kaoncuts.cfg_min_ncluster_tpc) { + return false; + } + + if (track.tpcNClsCrossedRows() < kaoncuts.cfg_min_ncrossedrows_tpc) { + return false; + } + + if (track.tpcCrossedRowsOverFindableCls() < kaoncuts.cfg_min_cr2findable_ratio_tpc) { + return false; + } + + if (track.tpcFractionSharedCls() > kaoncuts.cfg_max_frac_shared_clusters_tpc) { + return false; + } + + return true; + } + + template + bool isSelectedV0Leg(TTrack const& track, const float dcaXY) + { + if (!track.hasITS() || !track.hasTPC()) { + return false; + } + + if (std::fabs(dcaXY) < v0cuts.cfg_min_dcaxy) { + return false; + } + + if (track.itsChi2NCl() > v0cuts.cfg_max_chi2its) { + return false; + } + + if (track.itsNCls() < v0cuts.cfg_min_ncluster_its) { + return false; + } + + if (track.itsNClsInnerBarrel() < v0cuts.cfg_min_ncluster_itsib) { + return false; + } + + if (track.tpcChi2NCl() > v0cuts.cfg_max_chi2tpc) { + return false; + } + + if (track.tpcNClsFound() < v0cuts.cfg_min_ncluster_tpc) { + return false; + } + + if (track.tpcNClsCrossedRows() < v0cuts.cfg_min_ncrossedrows_tpc) { + return false; + } + + if (track.tpcCrossedRowsOverFindableCls() < v0cuts.cfg_min_cr2findable_ratio_tpc) { + return false; + } + + if (track.tpcFractionSharedCls() > v0cuts.cfg_max_frac_shared_clusters_tpc) { + return false; + } + + return true; + } + + template + void fillEventHistograms(TCollision const& collision) + { + fRegistry.fill(HIST("Event/hZvtx"), collision.posZ()); + fRegistry.fill(HIST("Event/hMultNTracksPV"), collision.multNTracksPV()); + fRegistry.fill(HIST("Event/hMultNTracksPVeta1"), collision.multNTracksPVeta1()); + fRegistry.fill(HIST("Event/hMultFT0"), collision.multFT0A(), collision.multFT0C()); + fRegistry.fill(HIST("Event/hCentFT0A"), collision.centFT0A()); + fRegistry.fill(HIST("Event/hCentFT0C"), collision.centFT0C()); + fRegistry.fill(HIST("Event/hCentFT0M"), collision.centFT0M()); + fRegistry.fill(HIST("Event/hCentFT0CvsMultNTracksPV"), collision.centFT0C(), collision.multNTracksPV()); + fRegistry.fill(HIST("Event/hMultFT0CvsMultNTracksPV"), collision.multFT0C(), collision.multNTracksPV()); + } + + template + void fillElectronHistograms(TTrack const& track, TTrackParCov const& trackParCov, const float dcaXY, const float dcaZ) + { + if (std::find(used_electronIds.begin(), used_electronIds.end(), std::make_pair(findId, track.globalIndex())) == used_electronIds.end()) { + float dca3DinSigma = dca3DinSigmaOTF(dcaXY, dcaZ, trackParCov.getSigmaY2(), trackParCov.getSigmaZ2(), trackParCov.getSigmaZY()); + fRegistry.fill(HIST(hadron_names[charmHadronId]) + HIST("electron/") + HIST(promptTypes[promptId]) + HIST(hTypes[findId]) + HIST("hs"), trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), dca3DinSigma); + fRegistry.fill(HIST(hadron_names[charmHadronId]) + HIST("electron/") + HIST(promptTypes[promptId]) + HIST(hTypes[findId]) + HIST("hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + fRegistry.fill(HIST(hadron_names[charmHadronId]) + HIST("electron/") + HIST(promptTypes[promptId]) + HIST(hTypes[findId]) + HIST("hTOFbeta"), trackParCov.getP(), track.beta()); + used_electronIds.emplace_back(std::make_pair(findId, track.globalIndex())); + } + } + + template + void fillKaonHistograms(TTrack const& track, TTrackParCov const& trackParCov, const float dcaXY, const float dcaZ) + { + float dca3DinSigma = dca3DinSigmaOTF(dcaXY, dcaZ, trackParCov.getSigmaY2(), trackParCov.getSigmaZ2(), trackParCov.getSigmaZY()); + fRegistry.fill(HIST(hadron_names[charmHadronId]) + HIST("kaon/") + HIST(promptTypes[promptId]) + HIST(hTypes[findId]) + HIST("hs"), trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), dca3DinSigma); + fRegistry.fill(HIST(hadron_names[charmHadronId]) + HIST("kaon/") + HIST(promptTypes[promptId]) + HIST(hTypes[findId]) + HIST("hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + fRegistry.fill(HIST(hadron_names[charmHadronId]) + HIST("kaon/") + HIST(promptTypes[promptId]) + HIST(hTypes[findId]) + HIST("hTOFbeta"), trackParCov.getP(), track.beta()); + } + + float dca3DinSigmaOTF(const float dcaXY, const float dcaZ, const float cYY, const float cZZ, const float cZY) + { + float det = cYY * cZZ - cZY * cZY; // determinant + if (det < 0) { + return 999.f; + } else { + return std::sqrt(std::fabs((dcaXY * dcaXY * cZZ + dcaZ * dcaZ * cYY - 2. * dcaXY * dcaZ * cZY) / det / 2.)); // dca 3d in sigma + } + } + + template + void runPairEandTrack(TCollision const& collision, TElectron const& ele, TTrackIds const& trackIds, TTracks const& tracks, TMCParticles const& mcParticles, TMCCollisions const&) + { + std::array pVtx = {collision.posX(), collision.posY(), collision.posZ()}; + const auto& mcele = ele.template mcParticle_as(); + const auto& mcCollision1 = mcele.template mcCollision_as(); + + if (cfgEventGeneratorType >= 0 && mcCollision1.getSubGeneratorId() != cfgEventGeneratorType) { + return; + } + + // o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto eleParCov = getTrackParCov(ele); + eleParCov.setPID(o2::track::PID::Electron); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, eleParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + for (const auto& trackId : trackIds) { + if (trackId == ele.globalIndex()) { + continue; + } + + const auto& track = tracks.rawIteratorAt(trackId); + const auto& mctrack = track.template mcParticle_as(); + const auto& mcCollision2 = mctrack.template mcCollision_as(); + + auto trackParCov = getTrackParCov(track); + trackParCov.setPID(o2::track::PID::Kaon); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, trackParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY_h = mDcaInfoCov.getY(); + float dcaZ_h = mDcaInfoCov.getZ(); + std::array svpos = {0.}; // secondary vertex position + std::array pvec0 = {0.}; + std::array pvec1 = {0.}; + + int nCand = 0; + try { + nCand = fitter.process(eleParCov, trackParCov); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + continue; + } + if (nCand == 0) { + continue; + } + + fitter.propagateTracksToVertex(); // propagate e and K to D vertex + const auto& vtx = fitter.getPCACandidate(); + for (int i = 0; i < 3; i++) { + svpos[i] = vtx[i]; + } + fitter.getTrack(0).getPxPyPzGlo(pvec0); // electron + fitter.getTrack(1).getPxPyPzGlo(pvec1); // strange hadron + std::array pvecSum = {pvec0[0] + pvec1[0], pvec0[1] + pvec1[1], pvec0[2] + pvec1[2]}; + + float dca2legs = std::sqrt(fitter.getChi2AtPCACandidate()); + float lxy = std::sqrt(std::pow(svpos[0] - collision.posX(), 2) + std::pow(svpos[1] - collision.posY(), 2)); + float lz = std::fabs(svpos[2] - collision.posZ()); + float mEK = RecoDecay::m(std::array{pvec0, pvec1}, std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassKaonCharged}); + float cpa = RecoDecay::cpa(pVtx, svpos, pvecSum); + float cpaXY = RecoDecay::cpaXY(pVtx, svpos, pvecSum); + // float ptEK = RecoDecay::sqrtSumOfSquares(pvec0[0] + pvec1[0], pvec0[1] + pvec1[1]); + + float deta = RecoDecay::eta(pvec1) - RecoDecay::eta(pvec0); + float dphi = RecoDecay::phi(pvec1[0], pvec1[1]) - RecoDecay::phi(pvec0[0], pvec0[1]); + o2::math_utils::bringToPMPi(dphi); + float reldpt = (RecoDecay::sqrtSumOfSquares(pvec1[0], pvec1[1]) - RecoDecay::sqrtSumOfSquares(pvec0[0], pvec0[1])) / RecoDecay::sqrtSumOfSquares(pvec0[0], pvec0[1]); + + if (cpa < svcuts.cfg_min_cospa || cpaXY < svcuts.cfg_min_cospaXY || svcuts.cfg_max_mass_eK < mEK || lxy < svcuts.cfg_min_lxy || svcuts.cfg_max_dca2legs < dca2legs) { + continue; + } + + fRegistry.fill(HIST("e_Kpm/all/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST("e_Kpm/all/hLxy"), lxy); + fRegistry.fill(HIST("e_Kpm/all/hLz"), lz); + fRegistry.fill(HIST("e_Kpm/all/hCosPAXY"), cpaXY); + fRegistry.fill(HIST("e_Kpm/all/hCosPA"), cpa); + fRegistry.fill(HIST("e_Kpm/all/hMass"), mEK); + fRegistry.fill(HIST("e_Kpm/all/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST("e_Kpm/all/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST("e_Kpm/all/hRelDeltaPt"), reldpt); + fRegistry.fill(HIST("e_Kpm/all/hProdDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()) * dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/all/hCorrelationDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()), dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/all/hCorrelationDCAz"), dcaZ / std::sqrt(eleParCov.getSigmaZ2()), dcaZ_h / std::sqrt(trackParCov.getSigmaZ2())); + + int commonMotherId = o2::aod::pwgem::dilepton::utils::mcutil::FindCommonMotherFrom2ProngsWithoutPDG(mcele, mctrack); // e and K+/- + if (commonMotherId < 0 && mctrack.has_mothers()) { + const auto& mctrack_mother = mctrack.template mothers_first_as(); // mother particle of Kaon. For example K*(892)+ -> K+ pi0 or K*(892)0 -> K+ pi- and CC, or phi->K+K- + if (std::abs(mctrack_mother.pdgCode()) == 313 || std::abs(mctrack_mother.pdgCode()) == 323 || std::abs(mctrack_mother.pdgCode()) == 333) { + commonMotherId = o2::aod::pwgem::dilepton::utils::mcutil::FindCommonMotherFrom2ProngsWithoutPDG(mcele, mctrack_mother); // e and K*(892)0 or K*(892)+/- or phi(1019) + } + } + if (commonMotherId >= 0) { // common mother is correctly found by DCAFitterN. + if (std::abs(mctrack.pdgCode()) == 321 && mcCollision1.globalIndex() == mcCollision2.globalIndex()) { // common mother is correctly found by DCAFitterN. + const auto& cmp = mcParticles.rawIteratorAt(commonMotherId); + if (std::abs(cmp.pdgCode()) == 421) { // D0 + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(cmp, mcParticles) < 0) { + fillElectronHistograms<2, 1, 0>(ele, eleParCov, dcaXY, dcaZ); // nprompt charm + } else { + fillElectronHistograms<2, 1, 1>(ele, eleParCov, dcaXY, dcaZ); // nonprompt charm + } + + fRegistry.fill(HIST("e_Kpm/D0/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST("e_Kpm/D0/hLxy"), lxy); + fRegistry.fill(HIST("e_Kpm/D0/hLz"), lz); + fRegistry.fill(HIST("e_Kpm/D0/hCosPAXY"), cpaXY); + fRegistry.fill(HIST("e_Kpm/D0/hCosPA"), cpa); + fRegistry.fill(HIST("e_Kpm/D0/hMass"), mEK); + fRegistry.fill(HIST("e_Kpm/D0/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST("e_Kpm/D0/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST("e_Kpm/D0/hRelDeltaPt"), reldpt); + fRegistry.fill(HIST("e_Kpm/D0/hProdDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()) * dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/D0/hCorrelationDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()), dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/D0/hCorrelationDCAz"), dcaZ / std::sqrt(eleParCov.getSigmaZ2()), dcaZ_h / std::sqrt(trackParCov.getSigmaZ2())); + } else if (std::abs(cmp.pdgCode()) == 411) { // Dpm + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(cmp, mcParticles) < 0) { + fillElectronHistograms<3, 1, 0>(ele, eleParCov, dcaXY, dcaZ); // prompt charm + } else { + fillElectronHistograms<3, 1, 1>(ele, eleParCov, dcaXY, dcaZ); // nonprompt charm + } + fRegistry.fill(HIST("e_Kpm/Dpm/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST("e_Kpm/Dpm/hLxy"), lxy); + fRegistry.fill(HIST("e_Kpm/Dpm/hLz"), lz); + fRegistry.fill(HIST("e_Kpm/Dpm/hCosPAXY"), cpaXY); + fRegistry.fill(HIST("e_Kpm/Dpm/hCosPA"), cpa); + fRegistry.fill(HIST("e_Kpm/Dpm/hMass"), mEK); + fRegistry.fill(HIST("e_Kpm/Dpm/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST("e_Kpm/Dpm/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST("e_Kpm/Dpm/hRelDeltaPt"), reldpt); + fRegistry.fill(HIST("e_Kpm/Dpm/hProdDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()) * dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/Dpm/hCorrelationDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()), dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/Dpm/hCorrelationDCAz"), dcaZ / std::sqrt(eleParCov.getSigmaZ2()), dcaZ_h / std::sqrt(trackParCov.getSigmaZ2())); + } else if (std::abs(cmp.pdgCode()) == 431) { // Ds + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(cmp, mcParticles) < 0) { + fillElectronHistograms<4, 1, 0>(ele, eleParCov, dcaXY, dcaZ); // prompt charm + } else { + fillElectronHistograms<4, 1, 1>(ele, eleParCov, dcaXY, dcaZ); // nonprompt charm + } + fRegistry.fill(HIST("e_Kpm/Ds/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST("e_Kpm/Ds/hLxy"), lxy); + fRegistry.fill(HIST("e_Kpm/Ds/hLz"), lz); + fRegistry.fill(HIST("e_Kpm/Ds/hCosPAXY"), cpaXY); + fRegistry.fill(HIST("e_Kpm/Ds/hCosPA"), cpa); + fRegistry.fill(HIST("e_Kpm/Ds/hMass"), mEK); + fRegistry.fill(HIST("e_Kpm/Ds/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST("e_Kpm/Ds/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST("e_Kpm/Ds/hRelDeltaPt"), reldpt); + fRegistry.fill(HIST("e_Kpm/Ds/hProdDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()) * dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/Ds/hCorrelationDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()), dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/Ds/hCorrelationDCAz"), dcaZ / std::sqrt(eleParCov.getSigmaZ2()), dcaZ_h / std::sqrt(trackParCov.getSigmaZ2())); + } + } + } else { // common mother does not exist, but DCAFitterN found something. i.e. fake + const auto& mp = mcele.template mothers_first_as(); + if ((mcele.isPhysicalPrimary() || mcele.producedByGenerator()) && (std::abs(mp.pdgCode()) == 111 || std::abs(mp.pdgCode()) == 221 || std::abs(mp.pdgCode()) == 331 || std::abs(mp.pdgCode()) == 113 || std::abs(mp.pdgCode()) == 223 || std::abs(mp.pdgCode()) == 333)) { // LF + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromCharm(mcele, mcParticles) < 0 && o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mcele, mcParticles) < 0) { + fillElectronHistograms<0, 2, 0>(ele, eleParCov, dcaXY, dcaZ); + } else { + fillElectronHistograms<0, 2, 1>(ele, eleParCov, dcaXY, dcaZ); + } + } + fRegistry.fill(HIST("e_Kpm/fake/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST("e_Kpm/fake/hLxy"), lxy); + fRegistry.fill(HIST("e_Kpm/fake/hLz"), lz); + fRegistry.fill(HIST("e_Kpm/fake/hCosPAXY"), cpaXY); + fRegistry.fill(HIST("e_Kpm/fake/hCosPA"), cpa); + fRegistry.fill(HIST("e_Kpm/fake/hMass"), mEK); + fRegistry.fill(HIST("e_Kpm/fake/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST("e_Kpm/fake/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST("e_Kpm/fake/hRelDeltaPt"), reldpt); + fRegistry.fill(HIST("e_Kpm/fake/hProdDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()) * dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/fake/hCorrelationDCAxy"), dcaXY / std::sqrt(eleParCov.getSigmaY2()), dcaXY_h / std::sqrt(trackParCov.getSigmaY2())); + fRegistry.fill(HIST("e_Kpm/fake/hCorrelationDCAz"), dcaZ / std::sqrt(eleParCov.getSigmaZ2()), dcaZ_h / std::sqrt(trackParCov.getSigmaZ2())); + } + } // end of kaon loop + } + + template + void runPairEandV0(TCollision const& collision, TElectron const& ele, TV0Ids const& v0Ids, TV0s const& v0s, TMCParticles const& mcParticles, TMCCollisions const&) + { + std::array pVtx = {collision.posX(), collision.posY(), collision.posZ()}; + const auto& mcele = ele.template mcParticle_as(); + const auto& mcCollision1 = mcele.template mcCollision_as(); + if (cfgEventGeneratorType >= 0 && mcCollision1.getSubGeneratorId() != cfgEventGeneratorType) { + return; + } + + // o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto eleParCov = getTrackParCov(ele); + eleParCov.setPID(o2::track::PID::Electron); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, eleParCov, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + for (const auto& v0Id : v0Ids) { + const auto& v0 = v0s.rawIteratorAt(v0Id); + auto pos = v0.template posTrack_as(); + // auto neg = v0.template negTrack_as(); + + const auto& mcpos = pos.template mcParticle_as(); + // const auto& mcneg = neg.template mcParticle_as(); + const auto& mcv0 = mcpos.template mothers_first_as(); // check mother of K0S. namely, K0 [311 or -311]. + const auto& mcCollision2 = mcv0.template mcCollision_as(); + + const std::array vertex = {v0.x(), v0.y(), v0.z()}; + const std::array momentum = {v0.px(), v0.py(), v0.pz()}; + std::array covV0 = {0.f}; + + constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int i = 0; i < 6; i++) { + covV0[MomInd[i]] = v0.momentumCovMat()[i]; + covV0[i] = v0.positionCovMat()[i]; + } + + auto tV0 = o2::track::TrackParCov(vertex, momentum, covV0, 0, true); + tV0.setAbsCharge(0); + tV0.setPID(o2::track::PID::K0); + + std::array svpos = {0.}; // secondary vertex position + std::array pvec0 = {0.}; + std::array pvec1 = {0.}; + + int nCand = 0; + try { + nCand = fitter.process(eleParCov, tV0); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + continue; + } + if (nCand == 0) { + continue; + } + + fitter.propagateTracksToVertex(); // propagate e and K to D vertex + const auto& vtx = fitter.getPCACandidate(); + for (int i = 0; i < 3; i++) { + svpos[i] = vtx[i]; + } + fitter.getTrack(0).getPxPyPzGlo(pvec0); // electron + fitter.getTrack(1).getPxPyPzGlo(pvec1); // v0 + std::array pvecSum = {pvec0[0] + pvec1[0], pvec0[1] + pvec1[1], pvec0[2] + pvec1[2]}; + + float dca2legs = std::sqrt(fitter.getChi2AtPCACandidate()); + float lxy = std::sqrt(std::pow(svpos[0] - collision.posX(), 2) + std::pow(svpos[1] - collision.posY(), 2)); + float lz = std::fabs(svpos[2] - collision.posZ()); + // float ptEK = RecoDecay::sqrtSumOfSquares(pvec0[0] + pvec1[0], pvec0[1] + pvec1[1]); + + float deta = RecoDecay::eta(pvec1) - RecoDecay::eta(pvec0); + float dphi = RecoDecay::phi(pvec1[0], pvec1[1]) - RecoDecay::phi(pvec0[0], pvec0[1]); + o2::math_utils::bringToPMPi(dphi); + float reldpt = (RecoDecay::sqrtSumOfSquares(pvec1[0], pvec1[1]) - RecoDecay::sqrtSumOfSquares(pvec0[0], pvec0[1])) / RecoDecay::sqrtSumOfSquares(pvec0[0], pvec0[1]); + + float mEK = 0; + if constexpr (pairId == 1) { + mEK = RecoDecay::m(std::array{pvec0, pvec1}, std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassK0Short}); + if (svcuts.cfg_max_mass_eK < mEK) { + continue; + } + } else if constexpr (pairId == 2) { + mEK = RecoDecay::m(std::array{pvec0, pvec1}, std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassLambda}); + if (svcuts.cfg_max_mass_eL < mEK) { + continue; + } + } + float cpa = RecoDecay::cpa(pVtx, svpos, pvecSum); + float cpaXY = RecoDecay::cpaXY(pVtx, svpos, pvecSum); + + if (cpa < svcuts.cfg_min_cospa || cpaXY < svcuts.cfg_min_cospaXY || lxy < svcuts.cfg_min_lxy || svcuts.cfg_max_dca2legs < dca2legs) { + continue; + } + + fRegistry.fill(HIST(pair_names[pairId]) + HIST("all/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("all/hLxy"), lxy); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("all/hLz"), lz); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("all/hCosPAXY"), cpaXY); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("all/hCosPA"), cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("all/hMass"), mEK); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("all/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("all/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("all/hRelDeltaPt"), reldpt); + + int commonMotherId = -1; + if constexpr (pairId == 1) { + const auto& mcv0_mother = mcv0.template mothers_first_as(); // mother particle of K0S. + commonMotherId = o2::aod::pwgem::dilepton::utils::mcutil::FindCommonMotherFrom2ProngsWithoutPDG(mcele, mcv0_mother); // K0, not K0S + } else if constexpr (pairId == 2) { + commonMotherId = o2::aod::pwgem::dilepton::utils::mcutil::FindCommonMotherFrom2ProngsWithoutPDG(mcele, mcv0); // lambda + } + + if (commonMotherId >= 0) { // common mother is correctly found by DCAFitterN. + const auto& cmp = mcParticles.rawIteratorAt(commonMotherId); + if constexpr (pairId == 1) { + if (std::abs(mcv0.pdgCode()) == 310 && mcCollision1.globalIndex() == mcCollision2.globalIndex()) { + if (std::abs(cmp.pdgCode()) == 421) { // D0 + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(cmp, mcParticles) < 0) { + fillElectronHistograms<2, 1, 0>(ele, eleParCov, dcaXY, dcaZ); // prompt charm + } else { + fillElectronHistograms<2, 1, 1>(ele, eleParCov, dcaXY, dcaZ); // nonprompt charm + } + fRegistry.fill(HIST(pair_names[pairId]) + HIST("D0/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("D0/hLxy"), lxy); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("D0/hLz"), lz); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("D0/hCosPAXY"), cpaXY); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("D0/hCosPA"), cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("D0/hMass"), mEK); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("D0/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("D0/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("D0/hRelDeltaPt"), reldpt); + } else if (std::abs(cmp.pdgCode()) == 411) { // Dpm + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(cmp, mcParticles) < 0) { + fillElectronHistograms<3, 1, 0>(ele, eleParCov, dcaXY, dcaZ); // prompt charm + } else { + fillElectronHistograms<3, 1, 1>(ele, eleParCov, dcaXY, dcaZ); // nonprompt charm + } + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Dpm/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Dpm/hLxy"), lxy); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Dpm/hLz"), lz); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Dpm/hCosPAXY"), cpaXY); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Dpm/hCosPA"), cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Dpm/hMass"), mEK); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Dpm/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Dpm/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Dpm/hRelDeltaPt"), reldpt); + } else if (std::abs(cmp.pdgCode()) == 431) { // Ds + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(cmp, mcParticles) < 0) { + fillElectronHistograms<4, 1, 0>(ele, eleParCov, dcaXY, dcaZ); // prompt charm + } else { + fillElectronHistograms<4, 1, 1>(ele, eleParCov, dcaXY, dcaZ); // nonprompt charm + } + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Ds/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Ds/hLxy"), lxy); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Ds/hLz"), lz); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Ds/hCosPAXY"), cpaXY); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Ds/hCosPA"), cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Ds/hMass"), mEK); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Ds/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Ds/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Ds/hRelDeltaPt"), reldpt); + } + } + } else if constexpr (pairId == 2) { + if (std::abs(mcv0.pdgCode()) == 3122 && mcCollision1.globalIndex() == mcCollision2.globalIndex()) { + if (std::abs(cmp.pdgCode()) == 4122) { // Lc + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(cmp, mcParticles) < 0) { + fillElectronHistograms<5, 1, 0>(ele, eleParCov, dcaXY, dcaZ); // prompt charm + } else { + fillElectronHistograms<5, 1, 1>(ele, eleParCov, dcaXY, dcaZ); // nonprompt charm + } + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Lc/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Lc/hLxy"), lxy); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Lc/hLz"), lz); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Lc/hCosPAXY"), cpaXY); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Lc/hCosPA"), cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Lc/hMass"), mEK); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Lc/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Lc/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("Lc/hRelDeltaPt"), reldpt); + } + } + } + } else { // common mother does not exist, but DCAFitterN found something. i.e. fake + const auto& mp = mcele.template mothers_first_as(); + if ((mcele.isPhysicalPrimary() || mcele.producedByGenerator()) && (std::abs(mp.pdgCode()) == 111 || std::abs(mp.pdgCode()) == 221 || std::abs(mp.pdgCode()) == 331 || std::abs(mp.pdgCode()) == 113 || std::abs(mp.pdgCode()) == 223 || std::abs(mp.pdgCode()) == 333)) { // LF + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromCharm(mcele, mcParticles) < 0 && o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mcele, mcParticles) < 0) { + fillElectronHistograms<0, 2, 0>(ele, eleParCov, dcaXY, dcaZ); + } else { + fillElectronHistograms<0, 2, 1>(ele, eleParCov, dcaXY, dcaZ); + } + } + fRegistry.fill(HIST(pair_names[pairId]) + HIST("fake/hDCA2Legs"), dca2legs); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("fake/hLxy"), lxy); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("fake/hLz"), lz); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("fake/hCosPAXY"), cpaXY); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("fake/hCosPA"), cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("fake/hMass"), mEK); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("fake/hMass_CosPA"), mEK, cpa); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("fake/hDeltaEtaDeltaPhi"), dphi, deta); + fRegistry.fill(HIST(pair_names[pairId]) + HIST("fake/hRelDeltaPt"), reldpt); + } + + } // end of v0 loop + } + + SliceCache cache; + Preslice perCol = o2::aod::track::collisionId; + Preslice perCol_v0 = o2::aod::v0data::collisionId; + + Filter collisionFilter_evsel = o2::aod::evsel::sel8 == true && (cfgZvtxMin < o2::aod::collision::posZ && o2::aod::collision::posZ < cfgZvtxMax); + Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); + using FilteredMyCollisions = soa::Filtered; + + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + std::vector> stored_trackIds; + Filter trackFilter = ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true; + using MyFilteredTracks = soa::Filtered; + + Partition posTracks = o2::aod::track::signed1Pt > 0.f; + Partition negTracks = o2::aod::track::signed1Pt < 0.f; + + //! type of V0. 0: built solely for cascades (does not pass standard V0 cuts), 1: standard 2, 3: photon-like with TPC-only use. Regular analysis should always use type 1. + Filter v0Filter = o2::aod::v0data::v0Type == uint8_t(1) && o2::aod::v0data::v0cosPA > v0cuts.cfg_min_cospa&& o2::aod::v0data::dcaV0daughters < v0cuts.cfg_max_dca2legs; + using filteredV0s = soa::Filtered; + + std::vector electronIds; + std::vector positronIds; + std::vector negKaonIds; + std::vector posKaonIds; + + std::vector k0sIds; + std::vector lambdaIds; + std::vector antilambdaIds; + + std::vector> used_electronIds; // pair of hTypeId and electronId + + void processSA(FilteredMyCollisions const&, aod::BCsWithTimestamps const&, MyTracks const&, filteredV0s const&, aod::McParticles const&, aod::McCollisions const&) {} + PROCESS_SWITCH(taggingHFE, processSA, "process without TTCA", false); + + void processTTCA(FilteredMyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::TrackAssoc const& trackIndices, filteredV0s const& v0s, aod::McParticles const& mcParticles, aod::McCollisions const& mcCollisions) + { + used_electronIds.reserve(tracks.size()); + + for (const auto& collision : collisions) { + const auto& bc = collision.template foundBC_as(); + initCCDB(bc); + fRegistry.fill(HIST("Event/hCollisionCounter"), 0); + if (!collision.has_mcCollision()) { + continue; + } + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + fRegistry.fill(HIST("Event/hCollisionCounter"), 1); + const auto& mcCollision = collision.template mcCollision_as(); + if (cfgEventGeneratorType < 0 || mcCollision.getSubGeneratorId() == cfgEventGeneratorType) { + fillEventHistograms(collision); + } + const auto& trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); + electronIds.reserve(trackIdsThisCollision.size()); + positronIds.reserve(trackIdsThisCollision.size()); + negKaonIds.reserve(trackIdsThisCollision.size()); + posKaonIds.reserve(trackIdsThisCollision.size()); + mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + + for (const auto& trackId : trackIdsThisCollision) { + const auto& track = trackId.template track_as(); + if (!track.hasITS() || !track.hasTPC()) { + continue; + } + if (!track.has_mcParticle()) { + continue; + } + const auto& mctrack = track.template mcParticle_as(); + if (std::abs(mctrack.pdgCode()) != 11) { + continue; + } + const auto& mcCollision1 = mctrack.template mcCollision_as(); + if (cfgEventGeneratorType >= 0 && mcCollision1.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + if (!mctrack.has_mothers() || !(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { + continue; + } + const auto& mp = mctrack.template mothers_first_as(); // mother particle of electron + + // o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto track_par_cov_recalc = getTrackParCov(track); + track_par_cov_recalc.setPID(o2::track::PID::Electron); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, track_par_cov_recalc, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + if (!isSelectedTrackForElectron(track, track_par_cov_recalc, dcaXY, dcaZ)) { + continue; + } + + if (std::abs(mp.pdgCode()) == 111 || std::abs(mp.pdgCode()) == 221 || std::abs(mp.pdgCode()) == 331 || std::abs(mp.pdgCode()) == 113 || std::abs(mp.pdgCode()) == 223 || std::abs(mp.pdgCode()) == 333) { // LF + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromCharm(mp, mcParticles) < 0 && o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mp, mcParticles) < 0) { + fillElectronHistograms<0, 0, 0>(track, track_par_cov_recalc, dcaXY, dcaZ); // prompt LF + } else { + fillElectronHistograms<0, 0, 1>(track, track_par_cov_recalc, dcaXY, dcaZ); // nonprompt LF + } + } else if (std::abs(mp.pdgCode()) == 443) { // Jpsi + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mp, mcParticles) < 0) { + fillElectronHistograms<1, 0, 0>(track, track_par_cov_recalc, dcaXY, dcaZ); // prompt Jpsi + } else { + fillElectronHistograms<1, 0, 1>(track, track_par_cov_recalc, dcaXY, dcaZ); // nonprompt Jpsi + } + } else if (std::abs(mp.pdgCode()) == 421) { // D0 + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mp, mcParticles) < 0) { + fillElectronHistograms<2, 0, 0>(track, track_par_cov_recalc, dcaXY, dcaZ); + } else { + fillElectronHistograms<2, 0, 1>(track, track_par_cov_recalc, dcaXY, dcaZ); + } + + } else if (std::abs(mp.pdgCode()) == 411) { // Dpm + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mp, mcParticles) < 0) { + fillElectronHistograms<3, 0, 0>(track, track_par_cov_recalc, dcaXY, dcaZ); + } else { + fillElectronHistograms<3, 0, 1>(track, track_par_cov_recalc, dcaXY, dcaZ); + } + } else if (std::abs(mp.pdgCode()) == 431) { // Ds + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mp, mcParticles) < 0) { + fillElectronHistograms<4, 0, 0>(track, track_par_cov_recalc, dcaXY, dcaZ); + } else { + fillElectronHistograms<4, 0, 1>(track, track_par_cov_recalc, dcaXY, dcaZ); + } + } else if (std::abs(mp.pdgCode()) == 4122) { // Lc + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mp, mcParticles) < 0) { + fillElectronHistograms<5, 0, 0>(track, track_par_cov_recalc, dcaXY, dcaZ); + } else { + fillElectronHistograms<5, 0, 1>(track, track_par_cov_recalc, dcaXY, dcaZ); + } + } + + if (track.sign() > 0) { // positron + positronIds.emplace_back(trackId.trackId()); + } else { // electron + electronIds.emplace_back(trackId.trackId()); + } + } // end of track loop for electron selection + + for (const auto& trackId : trackIdsThisCollision) { + const auto& track = trackId.template track_as(); + if (!track.hasITS() || !track.hasTPC()) { + continue; + } + if (!track.has_mcParticle()) { + continue; + } + + const auto& mctrack = track.template mcParticle_as(); + const auto& mcCollision1 = mctrack.template mcCollision_as(); + + // o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto track_par_cov_recalc = getTrackParCov(track); + track_par_cov_recalc.setPID(o2::track::PID::Kaon); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, track_par_cov_recalc, 2.f, matCorr, &mDcaInfoCov); + float dcaXY = mDcaInfoCov.getY(); + float dcaZ = mDcaInfoCov.getZ(); + + if (!isSelectedTrackForKaon(track, track_par_cov_recalc, dcaXY, dcaZ)) { + continue; + } + + if (isKaon(track)) { + if (track.sign() > 0) { // positive kaon + posKaonIds.emplace_back(trackId.trackId()); + } else { // negative kaon + negKaonIds.emplace_back(trackId.trackId()); + } + if (std::abs(mctrack.pdgCode()) == 321) { + if (!mctrack.has_mothers() || !(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { + continue; + } + const auto& mp = mctrack.template mothers_first_as(); // mother particle of electron + if (cfgEventGeneratorType < 0 || mcCollision1.getSubGeneratorId() == cfgEventGeneratorType) { + if (std::abs(mp.pdgCode()) == 421) { // D0 + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mp, mcParticles) < 0) { + fillKaonHistograms<2, 0, 0>(track, track_par_cov_recalc, dcaXY, dcaZ); + } else { + fillKaonHistograms<2, 0, 1>(track, track_par_cov_recalc, dcaXY, dcaZ); + } + } else if (std::abs(mp.pdgCode()) == 411) { // Dpm + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mp, mcParticles) < 0) { + fillKaonHistograms<3, 0, 0>(track, track_par_cov_recalc, dcaXY, dcaZ); + } else { + fillKaonHistograms<3, 0, 1>(track, track_par_cov_recalc, dcaXY, dcaZ); + } + } else if (std::abs(mp.pdgCode()) == 431) { // Ds + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(mp, mcParticles) < 0) { + fillKaonHistograms<4, 0, 0>(track, track_par_cov_recalc, dcaXY, dcaZ); + } else { + fillKaonHistograms<4, 0, 1>(track, track_par_cov_recalc, dcaXY, dcaZ); + } + } + } + } + } + } // end of track loop for kaon selection + + const auto& v0s_per_coll = v0s.sliceBy(perCol_v0, collision.globalIndex()); + k0sIds.reserve(v0s_per_coll.size()); + lambdaIds.reserve(v0s_per_coll.size()); + antilambdaIds.reserve(v0s_per_coll.size()); + + for (const auto& v0 : v0s_per_coll) { + if (v0cuts.cfg_min_mass_k0s < v0.mK0Short() && v0.mK0Short() < v0cuts.cfg_max_mass_k0s) { + auto pos = v0.template posTrack_as(); + auto neg = v0.template negTrack_as(); + + if (!isPion(pos) || !isPion(neg)) { + continue; + } + + float dcaXY = 999.f; + // o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto track_par_cov_recalc_pos = getTrackParCov(pos); + track_par_cov_recalc_pos.setPID(o2::track::PID::Pion); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, track_par_cov_recalc_pos, 2.f, matCorr, &mDcaInfoCov); + dcaXY = mDcaInfoCov.getY(); + if (!isSelectedV0Leg(pos, dcaXY)) { + continue; + } + + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto track_par_cov_recalc_neg = getTrackParCov(neg); + track_par_cov_recalc_neg.setPID(o2::track::PID::Pion); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, track_par_cov_recalc_neg, 2.f, matCorr, &mDcaInfoCov); + dcaXY = mDcaInfoCov.getY(); + if (!isSelectedV0Leg(neg, dcaXY)) { + continue; + } + + fRegistry.fill(HIST("V0/K0S/hPt"), v0.pt()); + fRegistry.fill(HIST("V0/K0S/hYPhi"), v0.phi(), v0.yK0Short()); + fRegistry.fill(HIST("V0/K0S/hCosPA"), v0.v0cosPA()); + fRegistry.fill(HIST("V0/K0S/hLxy"), v0.v0radius()); + fRegistry.fill(HIST("V0/K0S/hDCA2Legs"), v0.dcaV0daughters()); + fRegistry.fill(HIST("V0/K0S/hAP"), v0.alpha(), v0.qtarm()); + fRegistry.fill(HIST("V0/K0S/hMassK0S"), v0.mK0Short()); + k0sIds.emplace_back(v0.globalIndex()); + + } else if (v0cuts.cfg_min_mass_lambda < v0.mLambda() && v0.mLambda() < v0cuts.cfg_max_mass_lambda) { + auto pos = v0.template posTrack_as(); + auto neg = v0.template negTrack_as(); + + if (!isProton(pos) || !isPion(neg)) { + continue; + } + + float dcaXY = 999.f; + // o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto track_par_cov_recalc_pos = getTrackParCov(pos); + track_par_cov_recalc_pos.setPID(o2::track::PID::Proton); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, track_par_cov_recalc_pos, 2.f, matCorr, &mDcaInfoCov); + dcaXY = mDcaInfoCov.getY(); + if (!isSelectedV0Leg(pos, dcaXY)) { + continue; + } + + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto track_par_cov_recalc_neg = getTrackParCov(neg); + track_par_cov_recalc_neg.setPID(o2::track::PID::Pion); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, track_par_cov_recalc_neg, 2.f, matCorr, &mDcaInfoCov); + dcaXY = mDcaInfoCov.getY(); + if (!isSelectedV0Leg(neg, dcaXY)) { + continue; + } + + fRegistry.fill(HIST("V0/Lambda/hPt"), v0.pt()); + fRegistry.fill(HIST("V0/Lambda/hYPhi"), v0.phi(), v0.yLambda()); + fRegistry.fill(HIST("V0/Lambda/hCosPA"), v0.v0cosPA()); + fRegistry.fill(HIST("V0/Lambda/hLxy"), v0.v0radius()); + fRegistry.fill(HIST("V0/Lambda/hDCA2Legs"), v0.dcaV0daughters()); + fRegistry.fill(HIST("V0/Lambda/hAP"), v0.alpha(), v0.qtarm()); + fRegistry.fill(HIST("V0/Lambda/hMassLambda"), v0.mLambda()); + lambdaIds.emplace_back(v0.globalIndex()); + } else if (v0cuts.cfg_min_mass_lambda < v0.mAntiLambda() && v0.mAntiLambda() < v0cuts.cfg_max_mass_lambda) { + auto pos = v0.template posTrack_as(); + auto neg = v0.template negTrack_as(); + + if (!isPion(pos) || !isProton(neg)) { + continue; + } + float dcaXY = 999.f; + // o2::dataformats::DCA mDcaInfoCov; + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto track_par_cov_recalc_pos = getTrackParCov(pos); + track_par_cov_recalc_pos.setPID(o2::track::PID::Pion); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, track_par_cov_recalc_pos, 2.f, matCorr, &mDcaInfoCov); + dcaXY = mDcaInfoCov.getY(); + if (!isSelectedV0Leg(pos, dcaXY)) { + continue; + } + + mDcaInfoCov.set(999, 999, 999, 999, 999); + auto track_par_cov_recalc_neg = getTrackParCov(neg); + track_par_cov_recalc_neg.setPID(o2::track::PID::Proton); + // mVtx.setPos({collision.posX(), collision.posY(), collision.posZ()}); + // mVtx.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + o2::base::Propagator::Instance()->propagateToDCABxByBz(mVtx, track_par_cov_recalc_neg, 2.f, matCorr, &mDcaInfoCov); + dcaXY = mDcaInfoCov.getY(); + if (!isSelectedV0Leg(neg, dcaXY)) { + continue; + } + fRegistry.fill(HIST("V0/AntiLambda/hPt"), v0.pt()); + fRegistry.fill(HIST("V0/AntiLambda/hYPhi"), v0.phi(), v0.yLambda()); + fRegistry.fill(HIST("V0/AntiLambda/hCosPA"), v0.v0cosPA()); + fRegistry.fill(HIST("V0/AntiLambda/hLxy"), v0.v0radius()); + fRegistry.fill(HIST("V0/AntiLambda/hDCA2Legs"), v0.dcaV0daughters()); + fRegistry.fill(HIST("V0/AntiLambda/hAP"), v0.alpha(), v0.qtarm()); + fRegistry.fill(HIST("V0/AntiLambda/hMassAntiLambda"), v0.mAntiLambda()); + antilambdaIds.emplace_back(v0.globalIndex()); + } + + } // end of v0 loop + + for (const auto& trackId : electronIds) { + const auto& ele = tracks.rawIteratorAt(trackId); + runPairEandTrack<0>(collision, ele, posKaonIds, tracks, mcParticles, mcCollisions); + runPairEandTrack<0>(collision, ele, negKaonIds, tracks, mcParticles, mcCollisions); // only for Ds + runPairEandV0<1>(collision, ele, k0sIds, v0s, mcParticles, mcCollisions); + runPairEandV0<2>(collision, ele, antilambdaIds, v0s, mcParticles, mcCollisions); + } // end of electron loop + + for (const auto& trackId : positronIds) { + const auto& pos = tracks.rawIteratorAt(trackId); + runPairEandTrack<0>(collision, pos, negKaonIds, tracks, mcParticles, mcCollisions); + runPairEandTrack<0>(collision, pos, posKaonIds, tracks, mcParticles, mcCollisions); // only for Ds + runPairEandV0<1>(collision, pos, k0sIds, v0s, mcParticles, mcCollisions); // only for Ds + runPairEandV0<2>(collision, pos, lambdaIds, v0s, mcParticles, mcCollisions); + } // end of positron loop + + electronIds.clear(); + electronIds.shrink_to_fit(); + positronIds.clear(); + positronIds.shrink_to_fit(); + negKaonIds.clear(); + negKaonIds.shrink_to_fit(); + posKaonIds.clear(); + posKaonIds.shrink_to_fit(); + + k0sIds.clear(); + k0sIds.shrink_to_fit(); + lambdaIds.clear(); + lambdaIds.shrink_to_fit(); + antilambdaIds.clear(); + antilambdaIds.shrink_to_fit(); + } // end of collision loop + + used_electronIds.clear(); + used_electronIds.shrink_to_fit(); + } + PROCESS_SWITCH(taggingHFE, processTTCA, "process with TTCA", true); + + template + bool isSemiLeptonic(TMCParticle const& mcParticle, TMCParticles const& mcParticles) + { + if (!mcParticle.has_daughters()) { + return false; + } + bool is_lepton_involved = false; + bool is_neutrino_involved = false; + for (int d = mcParticle.daughtersIds()[0]; d <= mcParticle.daughtersIds()[1]; ++d) { + if (d < mcParticles.size()) { // protect against bad daughter indices + const auto& daughter = mcParticles.rawIteratorAt(d); + if (daughter.pdgCode() == pdgLepton) { + is_lepton_involved = true; + } else if (daughter.pdgCode() == pdgNeutrino) { + is_neutrino_involved = true; + } + } else { + std::cout << "Daughter label (" << d << ") exceeds the McParticles size (" << mcParticles.size() << ")" << std::endl; + std::cout << " Check the MC generator" << std::endl; + return false; + } + } + + if (is_lepton_involved && is_neutrino_involved) { + return true; + } else { + return false; + } + } + + Partition genDpms = nabs(o2::aod::mcparticle::pdgCode) == 411; + Partition genD0s = nabs(o2::aod::mcparticle::pdgCode) == 421; + Partition genDss = nabs(o2::aod::mcparticle::pdgCode) == 431; + Partition genLcs = nabs(o2::aod::mcparticle::pdgCode) == 4122; + + void processGen(aod::McCollisions const&, aod::McParticles const& mcParticles) + { + for (const auto& genD0 : genD0s) { + const auto& mcCollision = genD0.template mcCollision_as(); + if (cfgEventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + if (!(genD0.isPhysicalPrimary() || genD0.producedByGenerator())) { + continue; + } + if ((isSemiLeptonic<11, -12>(genD0, mcParticles) || isSemiLeptonic<-11, 12>(genD0, mcParticles))) { + float ptE = 999.f, ptK = 999.f; + float etaE = 999.f, etaK = 999.f; + for (int d = genD0.daughtersIds()[0]; d <= genD0.daughtersIds()[1]; ++d) { + const auto& daughter = mcParticles.rawIteratorAt(d); + if (std::abs(daughter.pdgCode()) == 11) { + ptE = daughter.pt(); + etaE = daughter.eta(); + } else if (std::abs(daughter.pdgCode()) == 321) { + ptK = daughter.pt(); + etaK = daughter.eta(); + } + } + if (o2::aod::pwgem::dilepton::utils::mcutil::IsFromBeauty(genD0, mcParticles) < 0) { + fRegistry.fill(HIST("Generated/D0/prompt/hs"), ptE, ptK, etaE, etaK); + } else { + fRegistry.fill(HIST("Generated/D0/nonprompt/hs"), ptE, ptK, etaE, etaK); + } + } + + } // end of gen. D0 loop + } + PROCESS_SWITCH(taggingHFE, processGen, "process gen. info", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"tagging-hfe"})}; +} diff --git a/PWGEM/Dilepton/Tasks/vpPairQC.cxx b/PWGEM/Dilepton/Tasks/vpPairQC.cxx index c3a2aaa06e3..891fa7e333b 100644 --- a/PWGEM/Dilepton/Tasks/vpPairQC.cxx +++ b/PWGEM/Dilepton/Tasks/vpPairQC.cxx @@ -14,30 +14,31 @@ // This code runs loop over ULS ee pars for virtual photon QC. // Please write to: daiki.sekihata@cern.ch -#include -#include -#include - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Common/Core/RecoDecay.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" - -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/Dilepton/Core/DielectronCut.h" #include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/Dilepton/Utils/EMTrack.h" #include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" #include "PWGEM/Dilepton/Utils/EventHistograms.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" #include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" + +#include "Common/Core/RecoDecay.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" +#include "TString.h" + +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -49,7 +50,7 @@ using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; -using MyTracks = soa::Join; +using MyTracks = soa::Join; using MyTrack = MyTracks::iterator; struct vpPairQC { @@ -123,15 +124,15 @@ struct vpPairQC { Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.0, "max dca Z for single track in cm"}; Configurable cfg_min_its_cluster_size{"cfg_min_its_cluster_size", 0.f, "min ITS cluster size"}; Configurable cfg_max_its_cluster_size{"cfg_max_its_cluster_size", 16.f, "max ITS cluster size"}; - Configurable cfg_max_p_its_cluster_size{"cfg_max_p_its_cluster_size", 0.2, "max p to apply ITS cluster size cut"}; Configurable cfg_min_rel_diff_pin{"cfg_min_rel_diff_pin", -1e+10, "min rel. diff. between pin and ppv"}; Configurable cfg_max_rel_diff_pin{"cfg_max_rel_diff_pin", +1e+10, "max rel. diff. between pin and ppv"}; + Configurable cfgRefR{"cfgRefR", 1.2, "reference R (in m) for extrapolation"}; // https://cds.cern.ch/record/1419204 Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTOFif), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3, kTOFif : 4, kPIDML : 5]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; - Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; + // Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; + // Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -0.0, "min. TPC n sigma for pion exclusion"}; Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +0.0, "max. TPC n sigma for pion exclusion"}; Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -0.0, "min. TPC n sigma for kaon exclusion"}; @@ -140,8 +141,11 @@ struct vpPairQC { Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +0.0, "max. TPC n sigma for proton exclusion"}; Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + Configurable cfg_min_pin_pirejTPC{"cfg_min_pin_pirejTPC", 0.5, "min. pin for pion rejection in TPC"}; Configurable cfg_max_pin_pirejTPC{"cfg_max_pin_pirejTPC", 0.5, "max. pin for pion rejection in TPC"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; // configuration for PID ML Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; @@ -254,12 +258,12 @@ struct vpPairQC { fRegistry.add("Track/positive/hChi2TOF", "TOF Chi2;p_{pv} (GeV/c);chi2", kTH2F, {{1000, 0, 10}, {100, 0, 10}}, false); fRegistry.add("Track/positive/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); on ITS #times cos(#lambda);", kTH2F, {{1000, 0.f, 10.f}, {160, 0, 16}}, false); fRegistry.add("Track/positive/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/positive/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTOFNsigmaEl", "TOF n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hTOFNsigmaMu", "TOF n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + // fRegistry.add("Track/positive/hTOFNsigmaMu", "TOF n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTOFNsigmaPi", "TOF n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTOFNsigmaKa", "TOF n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/positive/hTOFNsigmaPr", "TOF n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); @@ -322,21 +326,22 @@ struct vpPairQC { fDielectronCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); fDielectronCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); fDielectronCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size, dielectroncuts.cfg_max_p_its_cluster_size); + fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size); fDielectronCut.SetTrackMaxDcaXY(dielectroncuts.cfg_max_dcaxy); fDielectronCut.SetTrackMaxDcaZ(dielectroncuts.cfg_max_dcaz); fDielectronCut.SetChi2TOF(0.0, dielectroncuts.cfg_max_chi2tof); fDielectronCut.SetRelDiffPin(dielectroncuts.cfg_min_rel_diff_pin, dielectroncuts.cfg_max_rel_diff_pin); + fDielectronCut.IncludeITSsa(dielectroncuts.includeITSsa, dielectroncuts.cfg_max_pt_track_ITSsa); // for eID fDielectronCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); fDielectronCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); + // fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); fDielectronCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); fDielectronCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); fDielectronCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); fDielectronCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); - fDielectronCut.SetMaxPinForPionRejectionTPC(dielectroncuts.cfg_max_pin_pirejTPC); + fDielectronCut.SetPinRangeForPionRejectionTPC(dielectroncuts.cfg_min_pin_pirejTPC, dielectroncuts.cfg_max_pin_pirejTPC); if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut static constexpr int nClassesMl = 2; @@ -377,7 +382,7 @@ struct vpPairQC { return false; } - if (!fDielectronCut.IsSelectedPair(t1, t2, d_bz)) { + if (!fDielectronCut.IsSelectedPair(t1, t2, d_bz, dielectroncuts.cfgRefR)) { return false; } @@ -416,11 +421,6 @@ struct vpPairQC { if (track.sign() > 0) { fRegistry.fill(HIST("Track/positive/hs"), track.pt(), track.eta(), track.phi(), dca_3d, weight); fRegistry.fill(HIST("Track/positive/hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/positive/hPResolution"), track.p(), sigmaP(track) / track.p()); - fRegistry.fill(HIST("Track/positive/hPtResolution"), track.p(), sigmaPt(track) / track.pt()); - fRegistry.fill(HIST("Track/positive/hThetaResolution"), track.p(), sigmaTheta(track)); - fRegistry.fill(HIST("Track/positive/hEtaResolution"), track.p(), sigmaEta(track)); - fRegistry.fill(HIST("Track/positive/hPhiResolution"), track.p(), sigmaPhi(track)); fRegistry.fill(HIST("Track/positive/hDCAxyz"), track.dcaXY(), track.dcaZ()); fRegistry.fill(HIST("Track/positive/hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); fRegistry.fill(HIST("Track/positive/hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um @@ -441,23 +441,18 @@ struct vpPairQC { fRegistry.fill(HIST("Track/positive/hTOFbeta"), track.p(), track.beta()); fRegistry.fill(HIST("Track/positive/hMeanClusterSizeITS"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/positive/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/positive/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); + // fRegistry.fill(HIST("Track/positive/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); fRegistry.fill(HIST("Track/positive/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); fRegistry.fill(HIST("Track/positive/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); fRegistry.fill(HIST("Track/positive/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); fRegistry.fill(HIST("Track/positive/hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/positive/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); + // fRegistry.fill(HIST("Track/positive/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); fRegistry.fill(HIST("Track/positive/hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); fRegistry.fill(HIST("Track/positive/hTOFNsigmaKa"), track.p(), track.tofNSigmaKa()); fRegistry.fill(HIST("Track/positive/hTOFNsigmaPr"), track.p(), track.tofNSigmaPr()); } else { fRegistry.fill(HIST("Track/negative/hs"), track.pt(), track.eta(), track.phi(), dca_3d, weight); fRegistry.fill(HIST("Track/negative/hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/negative/hPResolution"), track.p(), sigmaP(track) / track.p()); - fRegistry.fill(HIST("Track/negative/hPtResolution"), track.p(), sigmaPt(track) / track.pt()); - fRegistry.fill(HIST("Track/negative/hThetaResolution"), track.p(), sigmaTheta(track)); - fRegistry.fill(HIST("Track/negative/hEtaResolution"), track.p(), sigmaEta(track)); - fRegistry.fill(HIST("Track/negative/hPhiResolution"), track.p(), sigmaPhi(track)); fRegistry.fill(HIST("Track/negative/hDCAxyz"), track.dcaXY(), track.dcaZ()); fRegistry.fill(HIST("Track/negative/hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); fRegistry.fill(HIST("Track/negative/hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um @@ -478,12 +473,12 @@ struct vpPairQC { fRegistry.fill(HIST("Track/negative/hTOFbeta"), track.p(), track.beta()); fRegistry.fill(HIST("Track/negative/hMeanClusterSizeITS"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); fRegistry.fill(HIST("Track/negative/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/negative/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); + // fRegistry.fill(HIST("Track/negative/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); fRegistry.fill(HIST("Track/negative/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); fRegistry.fill(HIST("Track/negative/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); fRegistry.fill(HIST("Track/negative/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); fRegistry.fill(HIST("Track/negative/hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/negative/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); + // fRegistry.fill(HIST("Track/negative/hTOFNsigmaMu"), track.p(), track.tofNSigmaMu()); fRegistry.fill(HIST("Track/negative/hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); fRegistry.fill(HIST("Track/negative/hTOFNsigmaKa"), track.p(), track.tofNSigmaKa()); fRegistry.fill(HIST("Track/negative/hTOFNsigmaPr"), track.p(), track.tofNSigmaPr()); diff --git a/PWGEM/Dilepton/Tasks/vpPairQCMC.cxx b/PWGEM/Dilepton/Tasks/vpPairQCMC.cxx index 13bda4c1d87..d470a92afa2 100644 --- a/PWGEM/Dilepton/Tasks/vpPairQCMC.cxx +++ b/PWGEM/Dilepton/Tasks/vpPairQCMC.cxx @@ -14,30 +14,31 @@ // This code runs loop over ULS ee pars for virtual photon QC. // Please write to: daiki.sekihata@cern.ch -#include -#include -#include - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Common/Core/RecoDecay.h" - -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/Dilepton/Core/DielectronCut.h" #include "PWGEM/Dilepton/Core/EMEventCut.h" -#include "PWGEM/Dilepton/Utils/MCUtilities.h" -#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/Utils/MCUtilities.h" #include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" + +#include "Common/Core/RecoDecay.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" +#include "TString.h" + +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -49,7 +50,7 @@ using namespace o2::aod::pwgem::dilepton::utils::mcutil; using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; -using MyMCTracks = soa::Join; +using MyMCTracks = soa::Join; using MyMCTrack = MyMCTracks::iterator; struct vpPairQCMC { @@ -123,15 +124,15 @@ struct vpPairQCMC { Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.0, "max dca Z for single track in cm"}; Configurable cfg_min_its_cluster_size{"cfg_min_its_cluster_size", 0.f, "min ITS cluster size"}; Configurable cfg_max_its_cluster_size{"cfg_max_its_cluster_size", 16.f, "max ITS cluster size"}; - Configurable cfg_max_p_its_cluster_size{"cfg_max_p_its_cluster_size", 0.2, "max p to apply ITS cluster size cut"}; Configurable cfg_min_rel_diff_pin{"cfg_min_rel_diff_pin", -1e+10, "min rel. diff. between pin and ppv"}; Configurable cfg_max_rel_diff_pin{"cfg_max_rel_diff_pin", +1e+10, "max rel. diff. between pin and ppv"}; + Configurable cfgRefR{"cfgRefR", 1.2, "reference R (in m) for extrapolation"}; // https://cds.cern.ch/record/1419204 Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTOFif), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3, kTOFif : 4, kPIDML : 5]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; - Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; + // Configurable cfg_min_TPCNsigmaMu{"cfg_min_TPCNsigmaMu", -0.0, "min. TPC n sigma for muon exclusion"}; + // Configurable cfg_max_TPCNsigmaMu{"cfg_max_TPCNsigmaMu", +0.0, "max. TPC n sigma for muon exclusion"}; Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -0.0, "min. TPC n sigma for pion exclusion"}; Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +0.0, "max. TPC n sigma for pion exclusion"}; Configurable cfg_min_TPCNsigmaKa{"cfg_min_TPCNsigmaKa", -0.0, "min. TPC n sigma for kaon exclusion"}; @@ -140,8 +141,11 @@ struct vpPairQCMC { Configurable cfg_max_TPCNsigmaPr{"cfg_max_TPCNsigmaPr", +0.0, "max. TPC n sigma for proton exclusion"}; Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -0.0, "min. TOF n sigma for electron inclusion"}; Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +0.0, "max. TOF n sigma for electron inclusion"}; + Configurable cfg_min_pin_pirejTPC{"cfg_min_pin_pirejTPC", 0.5, "min. pin for pion rejection in TPC"}; Configurable cfg_max_pin_pirejTPC{"cfg_max_pin_pirejTPC", 0.5, "max. pin for pion rejection in TPC"}; Configurable enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; // configuration for PID ML Configurable> onnxFileNames{"onnxFileNames", std::vector{"filename"}, "ONNX file names for each bin (if not from CCDB full path)"}; @@ -328,21 +332,22 @@ struct vpPairQCMC { fDielectronCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); fDielectronCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); fDielectronCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size, dielectroncuts.cfg_max_p_its_cluster_size); + fDielectronCut.SetMeanClusterSizeITS(dielectroncuts.cfg_min_its_cluster_size, dielectroncuts.cfg_max_its_cluster_size); fDielectronCut.SetTrackMaxDcaXY(dielectroncuts.cfg_max_dcaxy); fDielectronCut.SetTrackMaxDcaZ(dielectroncuts.cfg_max_dcaz); fDielectronCut.SetChi2TOF(0.0, dielectroncuts.cfg_max_chi2tof); fDielectronCut.SetRelDiffPin(dielectroncuts.cfg_min_rel_diff_pin, dielectroncuts.cfg_max_rel_diff_pin); + fDielectronCut.IncludeITSsa(dielectroncuts.includeITSsa, dielectroncuts.cfg_max_pt_track_ITSsa); // for eID fDielectronCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); fDielectronCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); + // fDielectronCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); fDielectronCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); fDielectronCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); fDielectronCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); fDielectronCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); - fDielectronCut.SetMaxPinForPionRejectionTPC(dielectroncuts.cfg_max_pin_pirejTPC); + fDielectronCut.SetPinRangeForPionRejectionTPC(dielectroncuts.cfg_min_pin_pirejTPC, dielectroncuts.cfg_max_pin_pirejTPC); if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut static constexpr int nClassesMl = 2; @@ -407,7 +412,7 @@ struct vpPairQCMC { return false; } - if (!fDielectronCut.IsSelectedPair(t1, t2, d_bz)) { + if (!fDielectronCut.IsSelectedPair(t1, t2, d_bz, dielectroncuts.cfgRefR)) { return false; } diff --git a/PWGEM/Dilepton/Utils/EMFwdTrack.h b/PWGEM/Dilepton/Utils/EMFwdTrack.h index 0aa590c6fb2..760441a08bf 100644 --- a/PWGEM/Dilepton/Utils/EMFwdTrack.h +++ b/PWGEM/Dilepton/Utils/EMFwdTrack.h @@ -22,7 +22,7 @@ namespace o2::aod::pwgem::dilepton::utils class EMFwdTrack { public: - EMFwdTrack(int dfId, int globalId, int collisionId, int trackId, float pt, float eta, float phi, float mass, int8_t charge = 0, float dcaX = 0.f, float dcaY = 0.f, std::vector amb_muon_self_ids = {}) + EMFwdTrack(int dfId, int globalId, int collisionId, int trackId, float pt, float eta, float phi, float mass, int8_t charge, float dcaX, float dcaY, std::vector amb_muon_self_ids, float cXX, float cXY, float cYY) { fDFId = dfId; fGlobalId = globalId; @@ -43,6 +43,10 @@ class EMFwdTrack } else { fIsAmbiguous = false; } + + fCXX = cXX; + fCXY = cXY; + fCYY = cYY; } ~EMFwdTrack() {} @@ -67,6 +71,10 @@ class EMFwdTrack std::vector ambiguousMuonsIds() const { return fAmbMuonSelfIds; } float signed1Pt() const { return fCharge * 1.f / fPt; } + float cXXatDCA() const { return fCXX; } + float cXYatDCA() const { return fCXY; } + float cYYatDCA() const { return fCYY; } + float pairDcaXYinSigmaOTF() const { return fPairDCAXYinSigmaOTF; } void setPairDcaXYinSigmaOTF(float dca) { fPairDCAXYinSigmaOTF = dca; } @@ -85,86 +93,9 @@ class EMFwdTrack float fPairDCAXYinSigmaOTF; bool fIsAmbiguous; std::vector fAmbMuonSelfIds; -}; - -class EMFwdTrackWithCov : public EMFwdTrack -{ - public: - EMFwdTrackWithCov(int dfId, int globalId, int collisionId, int trackId, float pt, float eta, float phi, float mass, int8_t charge = 0, float dcaX = 0.f, float dcaY = 0.f, std::vector amb_muon_self_ids = {}, - float X = 0.f, float Y = 0.f, float Z = 0.f, float Tgl = 0.f, - float CXX = 0.f, float CXY = 0.f, float CYY = 0.f, - float CPhiX = 0.f, float CPhiY = 0.f, float CPhiPhi = 0.f, - float CTglX = 0.f, float CTglY = 0.f, float CTglPhi = 0.f, float CTglTgl = 0.f, - float C1PtX = 0.f, float C1PtY = 0.f, float C1PtPhi = 0.f, float C1PtTgl = 0.f, float C1Pt21Pt2 = 0.f, float chi2 = 0.f) : EMFwdTrack(dfId, globalId, collisionId, trackId, pt, eta, phi, mass, charge, dcaX, dcaY, amb_muon_self_ids) - { - fX = X; - fY = Y; - fZ = Z; - fTgl = Tgl; - fCXX = CXX; - fCXY = CXY; - fCYY = CYY; - fCPhiX = CPhiX; - fCPhiY = CPhiY; - fCPhiPhi = CPhiPhi; - fCTglX = CTglX; - fCTglY = CTglY; - fCTglPhi = CTglPhi; - fCTglTgl = CTglTgl; - fC1PtX = C1PtX; - fC1PtY = C1PtY; - fC1PtPhi = C1PtPhi; - fC1PtTgl = C1PtTgl; - fC1Pt21Pt2 = C1Pt21Pt2; - fChi2 = chi2; - } - - float x() const { return fX; } - float y() const { return fY; } - float z() const { return fZ; } - float tgl() const { return fTgl; } - float cXX() const { return fCXX; } - float cXY() const { return fCXY; } - float cYY() const { return fCYY; } - float cPhiX() const { return fCPhiX; } - float cPhiY() const { return fCPhiY; } - float cPhiPhi() const { return fCPhiPhi; } - float cTglX() const { return fCTglX; } - float cTglY() const { return fCTglY; } - float cTglPhi() const { return fCTglPhi; } - float cTglTgl() const { return fCTglTgl; } - float c1PtX() const { return fC1PtX; } - float c1PtY() const { return fC1PtY; } - float c1PtPhi() const { return fC1PtPhi; } - float c1PtTgl() const { return fC1PtTgl; } - float c1Pt21Pt2() const { return fC1Pt21Pt2; } - float chi2() const { return fChi2; } - - void setCXX(float cXX) { fCXX = cXX; } - void setCXY(float cXY) { fCXY = cXY; } - void setCYY(float cYY) { fCYY = cYY; } - - protected: - float fX; - float fY; - float fZ; - float fTgl; float fCXX; float fCXY; float fCYY; - float fCPhiX; - float fCPhiY; - float fCPhiPhi; - float fCTglX; - float fCTglY; - float fCTglPhi; - float fCTglTgl; - float fC1PtX; - float fC1PtY; - float fC1PtPhi; - float fC1PtTgl; - float fC1Pt21Pt2; - float fChi2; }; } // namespace o2::aod::pwgem::dilepton::utils diff --git a/PWGEM/Dilepton/Utils/EMTrack.h b/PWGEM/Dilepton/Utils/EMTrack.h index 0f894d5b4dc..d7ddae81476 100644 --- a/PWGEM/Dilepton/Utils/EMTrack.h +++ b/PWGEM/Dilepton/Utils/EMTrack.h @@ -15,15 +15,16 @@ #ifndef PWGEM_DILEPTON_UTILS_EMTRACK_H_ #define PWGEM_DILEPTON_UTILS_EMTRACK_H_ -#include #include "Math/Vector4D.h" +#include + namespace o2::aod::pwgem::dilepton::utils { class EMTrack { public: - EMTrack(int dfId, int globalId, int collisionId, int trackId, float pt, float eta, float phi, float mass, int8_t charge = 0, float dcaXY = 0.f, float dcaZ = 0.f, std::vector amb_ele_self_ids = {}) + EMTrack(int dfId, int globalId, int collisionId, int trackId, float pt, float eta, float phi, float mass, int8_t charge = 0, float dcaXY = 0.f, float dcaZ = 0.f, std::vector amb_ele_self_ids = {}, float CYY = 0, float CZY = 0, float CZZ = 0) { fDFId = dfId; fGlobalId = globalId; @@ -36,6 +37,9 @@ class EMTrack fCharge = charge; fDCAxy = dcaXY; fDCAz = dcaZ; + fCYY = CYY; + fCZY = CZY; + fCZZ = CZZ; fPairDCA3DinSigmaOTF = 0; fAmbEleSelfIds = amb_ele_self_ids; @@ -78,6 +82,11 @@ class EMTrack int8_t sign() const { return fCharge; } float dcaXY() const { return fDCAxy; } float dcaZ() const { return fDCAz; } + + float cYY() const { return fCYY; } + float cZY() const { return fCZY; } + float cZZ() const { return fCZZ; } + float p() const { return fPt * std::cosh(fEta); } float px() const { return fPt * std::cos(fPhi); } float py() const { return fPt * std::sin(fPhi); } @@ -130,6 +139,10 @@ class EMTrack std::vector ambiguousPosLegIds() const { return fAmbPosLegSelfIds; } std::vector ambiguousNegLegIds() const { return fAmbNegLegSelfIds; } + void setCYY(float cYY) { fCYY = cYY; } + void setCZY(float cZY) { fCZY = cZY; } + void setCZZ(float cZZ) { fCZZ = cZZ; } + protected: int fDFId; int fGlobalId; @@ -142,6 +155,11 @@ class EMTrack int8_t fCharge; float fDCAxy; float fDCAz; + + float fCYY; + float fCZY; + float fCZZ; + float fPairDCA3DinSigmaOTF; bool fIsAmbiguous; std::vector fAmbEleSelfIds; @@ -199,9 +217,6 @@ class EMTrackWithCov : public EMTrack float snp() const { return fSnp; } float tgl() const { return fTgl; } - float cYY() const { return fCYY; } - float cZY() const { return fCZY; } - float cZZ() const { return fCZZ; } float cSnpY() const { return fCSnpY; } float cSnpZ() const { return fCSnpZ; } float cSnpSnp() const { return fCSnpSnp; } @@ -215,10 +230,6 @@ class EMTrackWithCov : public EMTrack float c1PtTgl() const { return fC1PtTgl; } float c1Pt21Pt2() const { return fC1Pt21Pt2; } - void setCYY(float cYY) { fCYY = cYY; } - void setCZY(float cZY) { fCZY = cZY; } - void setCZZ(float cZZ) { fCZZ = cZZ; } - protected: float fX; float fY; @@ -226,9 +237,6 @@ class EMTrackWithCov : public EMTrack float fAlpha; float fSnp; float fTgl; - float fCYY; - float fCZY; - float fCZZ; float fCSnpY; float fCSnpZ; float fCSnpSnp; diff --git a/PWGEM/Dilepton/Utils/EMTrackUtilities.h b/PWGEM/Dilepton/Utils/EMTrackUtilities.h index e26e9760bab..5c5b21e6ea0 100644 --- a/PWGEM/Dilepton/Utils/EMTrackUtilities.h +++ b/PWGEM/Dilepton/Utils/EMTrackUtilities.h @@ -15,13 +15,36 @@ #ifndef PWGEM_DILEPTON_UTILS_EMTRACKUTILITIES_H_ #define PWGEM_DILEPTON_UTILS_EMTRACKUTILITIES_H_ +#include "Framework/DataTypes.h" +#include "Framework/Logger.h" + +#include +#include #include #include -#include //_______________________________________________________________________ namespace o2::aod::pwgem::dilepton::utils::emtrackutil { + +enum class RefTrackBit : uint16_t { // This is not for leptons, but charged tracks for reference flow. + kNclsITS5 = 1, + kNclsITS6 = 2, + kNcrTPC70 = 4, + kNcrTPC90 = 8, + kNclsTPC50 = 16, // (not necessary, if ncr is used.) + kNclsTPC70 = 32, // (not necessary, if ncr is used.) + kNclsTPC90 = 64, // (not necessary, if ncr is used.) + kChi2TPC4 = 128, + kChi2TPC3 = 256, + kFracSharedTPC07 = 512, + kDCAxy05cm = 1024, // default is 1 cm + kDCAxy03cm = 2048, + kDCAz05cm = 4096, // default is 1cm + kDCAz03cm = 8192, +}; + +//_______________________________________________________________________ template float dca3DinSigma(T const& track) { @@ -35,11 +58,20 @@ float dca3DinSigma(T const& track) if (det < 0) { return 999.f; } else { - return std::sqrt(std::abs((dcaXY * dcaXY * cZZ + dcaZ * dcaZ * cYY - 2. * dcaXY * dcaZ * cZY) / det / 2.)); // dca 3d in sigma + return std::sqrt(std::fabs((dcaXY * dcaXY * cZZ + dcaZ * dcaZ * cYY - 2. * dcaXY * dcaZ * cZY) / det / 2.)); // dca 3d in sigma } } //_______________________________________________________________________ template +float sigmaDca3D(T const& track) +{ + float dcaXY = track.dcaXY(); // in cm + float dcaZ = track.dcaZ(); // in cm + float dca3d = std::sqrt(dcaXY * dcaXY + dcaZ * dcaZ); // in cm + return dca3d / dca3DinSigma(track); +} +//_______________________________________________________________________ +template float dcaXYinSigma(T const& track) { return track.dcaXY() / std::sqrt(track.cYY()); @@ -54,50 +86,100 @@ float dcaZinSigma(T const& track) template float fwdDcaXYinSigma(T const& track) { - float cXX = track.cXX(); - float cYY = track.cYY(); - float cXY = track.cXY(); - float dcaX = track.fwdDcaX(); // in cm - float dcaY = track.fwdDcaY(); // in cm - + float cXX = track.cXXatDCA(); // in cm^2 + float cYY = track.cYYatDCA(); // in cm^2 + float cXY = track.cXYatDCA(); // in cm^2 + float dcaX = track.fwdDcaX(); // in cm + float dcaY = track.fwdDcaY(); // in cm float det = cXX * cYY - cXY * cXY; // determinant + if (det < 0) { return 999.f; } else { - return std::sqrt(std::abs((dcaX * dcaX * cYY + dcaY * dcaY * cXX - 2. * dcaX * dcaY * cXY) / det / 2.)); // dca xy in sigma + return std::sqrt(std::fabs((dcaX * dcaX * cYY + dcaY * dcaY * cXX - 2. * dcaX * dcaY * cXY) / det / 2.)); // dca xy in sigma } } //_______________________________________________________________________ template -float sigmaPt(T const& track) +float sigmaFwdDcaXY(T const& track) { - return std::sqrt(track.c1Pt21Pt2()) / std::pow(track.signed1Pt(), 2); // pT resolution + float dcaX = track.fwdDcaX(); // in cm + float dcaY = track.fwdDcaY(); // in cm + float dcaXY = std::sqrt(dcaX * dcaX + dcaY * dcaY); // in cm + return dcaXY / fwdDcaXYinSigma(track); } //_______________________________________________________________________ -template -float sigmaPhi(T const& track) -{ - return std::sqrt(track.cSnpSnp()) / std::sqrt(1.f - std::pow(track.snp(), 2)); // phi resolution -} -//_______________________________________________________________________ -template -float sigmaTheta(T const& track) +template +bool checkMFTHitMap(T const& track) { - return std::sqrt(track.cTglTgl()) / (1.f + std::pow(track.tgl(), 2)); // theta resolution = lambda resolution. // lambda = pi/2 - theta. theta is polar angle. + // logical-OR + uint64_t mftClusterSizesAndTrackFlags = track.mftClusterSizesAndTrackFlags(); + uint16_t clmap = 0; + for (unsigned int layer = begin; layer <= end; layer++) { + if ((mftClusterSizesAndTrackFlags >> (layer * 6)) & 0x3f) { + clmap |= (1 << layer); + } + } + return (clmap > 0); } //_______________________________________________________________________ -template -float sigmaEta(T const& track) +template +bool isBestMatch(TTrack const& track, TCut const& cut, TTracks const& tracks) { - return std::sqrt(track.cTglTgl()) / std::sqrt(1.f + std::pow(track.tgl(), 2)); + // this is only for muon at forward rapidity + if (track.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) { + std::map map_chi2MCHMFT; + map_chi2MCHMFT[track.globalIndex()] = track.chi2MatchMCHMFT(); // add myself + for (const auto& glmuonId : track.globalMuonsWithSameMFTIds()) { + const auto& candidate = tracks.rawIteratorAt(glmuonId); + if (candidate.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) { + if (cut.template IsSelectedTrack(candidate)) { + map_chi2MCHMFT[candidate.globalIndex()] = candidate.chi2MatchMCHMFT(); + } + } + } + if (map_chi2MCHMFT.begin()->first == track.globalIndex()) { // search for minimum matching-chi2 + map_chi2MCHMFT.clear(); + return true; + } else { + map_chi2MCHMFT.clear(); + return false; + } + } else { + return true; + } } //_______________________________________________________________________ -template -float sigmaP(T const& track) -{ - // p = 1/1/pT x 1/cos(lambda); - return std::sqrt(std::pow(1.f / track.signed1Pt(), 4) * ((1.f + std::pow(track.tgl(), 2)) * track.c1Pt21Pt2() + 1.f / (1.f + std::pow(track.tgl(), 2)) * std::pow(track.signed1Pt() * track.tgl(), 2) * track.cTglTgl() - 2.f * track.signed1Pt() * track.tgl() * track.c1PtTgl())); -} +// template +// float sigmaPt(T const& track) +// { +// return std::sqrt(track.c1Pt21Pt2()) / std::pow(track.signed1Pt(), 2); // pT resolution +// } +// //_______________________________________________________________________ +// template +// float sigmaPhi(T const& track) +// { +// return std::sqrt(track.cSnpSnp()) / std::sqrt(1.f - std::pow(track.snp(), 2)); // phi resolution +// } +// //_______________________________________________________________________ +// template +// float sigmaTheta(T const& track) +// { +// return std::sqrt(track.cTglTgl()) / (1.f + std::pow(track.tgl(), 2)); // theta resolution = lambda resolution. // lambda = pi/2 - theta. theta is polar angle. +// } +// //_______________________________________________________________________ +// template +// float sigmaEta(T const& track) +// { +// return std::sqrt(track.cTglTgl()) / std::sqrt(1.f + std::pow(track.tgl(), 2)); +// } +// //_______________________________________________________________________ +// template +// float sigmaP(T const& track) +// { +// // p = 1/1/pT x 1/cos(lambda); +// return std::sqrt(std::pow(1.f / track.signed1Pt(), 4) * ((1.f + std::pow(track.tgl(), 2)) * track.c1Pt21Pt2() + 1.f / (1.f + std::pow(track.tgl(), 2)) * std::pow(track.signed1Pt() * track.tgl(), 2) * track.cTglTgl() - 2.f * track.signed1Pt() * track.tgl() * track.c1PtTgl())); +// } //_______________________________________________________________________ } // namespace o2::aod::pwgem::dilepton::utils::emtrackutil #endif // PWGEM_DILEPTON_UTILS_EMTRACKUTILITIES_H_ diff --git a/PWGEM/Dilepton/Utils/EventHistograms.h b/PWGEM/Dilepton/Utils/EventHistograms.h index 4526e6c6685..ab448b1dcc6 100644 --- a/PWGEM/Dilepton/Utils/EventHistograms.h +++ b/PWGEM/Dilepton/Utils/EventHistograms.h @@ -14,11 +14,14 @@ #ifndef PWGEM_DILEPTON_UTILS_EVENTHISTOGRAMS_H_ #define PWGEM_DILEPTON_UTILS_EVENTHISTOGRAMS_H_ + +#include "Framework/HistogramRegistry.h" + using namespace o2::framework; namespace o2::aod::pwgem::dilepton::utils::eventhistogram { -const int nbin_ev = 18; +const int nbin_ev = 21; template void addEventHistograms(HistogramRegistry* fRegistry) { @@ -40,19 +43,40 @@ void addEventHistograms(HistogramRegistry* fRegistry) hCollisionCounter->GetXaxis()->SetBinLabel(14, "NoCollInRofStandard"); hCollisionCounter->GetXaxis()->SetBinLabel(15, "NoCollInRofStrict"); hCollisionCounter->GetXaxis()->SetBinLabel(16, "NoHighMultCollInPrevRof"); - hCollisionCounter->GetXaxis()->SetBinLabel(17, "Calibrated Q vector"); - hCollisionCounter->GetXaxis()->SetBinLabel(18, "accepted"); + hCollisionCounter->GetXaxis()->SetBinLabel(17, "IsGoodITSLayer3"); + hCollisionCounter->GetXaxis()->SetBinLabel(18, "IsGoodITSLayer0123"); + hCollisionCounter->GetXaxis()->SetBinLabel(19, "IsGoodITSLayersAll"); + hCollisionCounter->GetXaxis()->SetBinLabel(20, "Calibrated Q vector"); + hCollisionCounter->GetXaxis()->SetBinLabel(21, "accepted"); + + const AxisSpec axis_cent_ft0m{{0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}, + "centrality FT0M (%)"}; + + const AxisSpec axis_cent_ft0a{{0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}, + "centrality FT0A (%)"}; + + const AxisSpec axis_cent_ft0c{{0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}, + "centrality FT0C (%)"}; fRegistry->add("Event/before/hZvtx", "vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); fRegistry->add("Event/before/hMultNTracksPV", "hMultNTracksPV; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); fRegistry->add("Event/before/hMultNTracksPVeta1", "hMultNTracksPVeta1; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); fRegistry->add("Event/before/hMultFT0", "hMultFT0;mult. FT0A;mult. FT0C", kTH2F, {{200, 0, 200000}, {60, 0, 60000}}, false); - fRegistry->add("Event/before/hCentFT0A", "hCentFT0A;centrality FT0A (%)", kTH1F, {{110, 0, 110}}, false); - fRegistry->add("Event/before/hCentFT0C", "hCentFT0C;centrality FT0C (%)", kTH1F, {{110, 0, 110}}, false); - fRegistry->add("Event/before/hCentFT0M", "hCentFT0M;centrality FT0M (%)", kTH1F, {{110, 0, 110}}, false); - fRegistry->add("Event/before/hCentFT0A_HMpp", "hCentFT0A for HM pp;centrality FT0A (%)", kTH1F, {{100, 0, 1}}, false); - fRegistry->add("Event/before/hCentFT0C_HMpp", "hCentFT0C for HM pp;centrality FT0C (%)", kTH1F, {{100, 0, 1}}, false); - fRegistry->add("Event/before/hCentFT0M_HMpp", "hCentFT0M for HM pp;centrality FT0M (%)", kTH1F, {{100, 0, 1}}, false); + fRegistry->add("Event/before/hCentFT0A", "hCentFT0A;centrality FT0A (%)", kTH1F, {{axis_cent_ft0a}}, false); + fRegistry->add("Event/before/hCentFT0C", "hCentFT0C;centrality FT0C (%)", kTH1F, {{axis_cent_ft0c}}, false); + fRegistry->add("Event/before/hCentFT0M", "hCentFT0M;centrality FT0M (%)", kTH1F, {{axis_cent_ft0m}}, false); fRegistry->add("Event/before/hCentFT0CvsMultNTracksPV", "hCentFT0CvsMultNTracksPV;centrality FT0C (%);N_{track} to PV", kTH2F, {{110, 0, 110}, {600, 0, 6000}}, false); fRegistry->add("Event/before/hMultFT0CvsMultNTracksPV", "hMultFT0CvsMultNTracksPV;mult. FT0C;N_{track} to PV", kTH2F, {{60, 0, 60000}, {600, 0, 6000}}, false); fRegistry->add("Event/before/hMultFT0CvsOccupancy", "hMultFT0CvsOccupancy;mult. FT0C;N_{track} in time range", kTH2F, {{60, 0, 60000}, {200, 0, 20000}}, false); @@ -175,6 +199,15 @@ void fillEventInfo(HistogramRegistry* fRegistry, TCollision const& collision, co if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 16.0); } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer3)) { + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 17.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 18.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 19.0); + } fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hZvtx"), collision.posZ()); fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultNTracksPV"), collision.multNTracksPV()); @@ -183,9 +216,6 @@ void fillEventInfo(HistogramRegistry* fRegistry, TCollision const& collision, co fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0A"), collision.centFT0A()); fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0C"), collision.centFT0C()); fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0M"), collision.centFT0M()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0A_HMpp"), collision.centFT0A()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0C_HMpp"), collision.centFT0C()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0M_HMpp"), collision.centFT0M()); fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0CvsMultNTracksPV"), collision.centFT0C(), collision.multNTracksPV()); fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultFT0CvsMultNTracksPV"), collision.multFT0C(), collision.multNTracksPV()); fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultFT0CvsOccupancy"), collision.multFT0C(), collision.trackOccupancyInTimeRange()); diff --git a/PWGEM/Dilepton/Utils/MCUtilities.h b/PWGEM/Dilepton/Utils/MCUtilities.h index 668f1056e75..dd12d2576f2 100644 --- a/PWGEM/Dilepton/Utils/MCUtilities.h +++ b/PWGEM/Dilepton/Utils/MCUtilities.h @@ -15,9 +15,12 @@ #ifndef PWGEM_DILEPTON_UTILS_MCUTILITIES_H_ #define PWGEM_DILEPTON_UTILS_MCUTILITIES_H_ +#include "Framework/AnalysisDataModel.h" +#include "Framework/Logger.h" + +#include #include #include -#include //_______________________________________________________________________ namespace o2::aod::pwgem::dilepton::utils::mcutil @@ -31,6 +34,42 @@ enum class EM_HFeeType : int { kBCe_Be_DiffB = 4, // LS }; +//_______________________________________________________________________ +template +int hasFakeMatchITSTPC(TTrack const& track) +{ + // track and mctracklabel have to be joined. + // bit 13 -- ITS/TPC labels are not equal + + if ((track.mcMask() & 1 << 13)) { + return true; + } else { + return false; + } +} +//_______________________________________________________________________ +template +int hasFakeMatchITSTPCTOF(TTrack const&) +{ + // track and mctracklabel have to be joined. + return false; + // if ((track.mcMask() & 1 << 13) && (track.mcMask() & 1 << 15)) { + // return true; + // } else { + // return false; + // } +} +//_______________________________________________________________________ +template +int hasFakeMatchMFTMCH(TTrack const& track) +{ + // fwdtrack and mcfwdtracklabel have to be joined. + if ((track.mcMask() & 1 << 7)) { + return true; + } else { + return false; + } +} //_______________________________________________________________________ template int FindCommonMotherFrom2ProngsWithoutPDG(TMCParticle1 const& p1, TMCParticle2 const& p2) @@ -186,6 +225,14 @@ int FindCommonMotherFrom3Prongs(TMCParticle1 const& p1, TMCParticle2 const& p2, } //_______________________________________________________________________ template +int getMotherPDGCode(TMCParticle const& p, TMCParticles const& mcparticles) +{ + int motherid = p.mothersIds()[0]; + auto mother = mcparticles.iteratorAt(motherid); + return (mother.pdgCode()); +} +//_______________________________________________________________________ +template int IsFromBeauty(TMCParticle const& p, TMCParticles const& mcparticles) { if (!p.has_mothers()) { @@ -217,6 +264,7 @@ int IsFromBeauty(TMCParticle const& p, TMCParticles const& mcparticles) return -999; } +//_______________________________________________________________________ template int IsFromCharm(TMCParticle const& p, TMCParticles const& mcparticles) { @@ -248,6 +296,7 @@ int IsFromCharm(TMCParticle const& p, TMCParticles const& mcparticles) return -999; } +//_______________________________________________________________________ template int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcparticles) { @@ -359,8 +408,8 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp return static_cast(EM_HFeeType::kBCe_Be_SameB); // b->c->e and b->e, decay type = 3. this should happen only in ULS. } } - } // end of motherid2 - } // end of motherid1 + } // end of motherid2 + } // end of motherid1 } else { // LS bool is_same_mother_found = false; for (auto& mid1 : mothers_id1) { @@ -374,7 +423,7 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp } } } // end of motherid2 - } // end of motherid1 + } // end of motherid1 if (!is_same_mother_found) { mothers_id1.clear(); mothers_pdg1.clear(); @@ -400,6 +449,7 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp return static_cast(EM_HFeeType::kUndef); } +//_______________________________________________________________________ template int searchMothers(T& p, U& mcParticles, int pdg, bool equal) { // find the first ancestor that is equal/not-equal pdg @@ -434,14 +484,16 @@ int searchMothers(T& p, U& mcParticles, int pdg, bool equal) for (int i : allmothersids) { auto mother = mcParticles.iteratorAt(i); int mpdg = mother.pdgCode(); - if (abs(mpdg) == pdg && mpdg * p.pdgCode() > 0) { // check for quark - if (quark_id > -1 || next_mother_id > -1) { // we already found a possible candidate in the list of mothers, so now we have (at least) two + // if (abs(mpdg) == pdg && mpdg * p.pdgCode() > 0) { // check for quark + if (abs(mpdg) == pdg) { // check for quark to allow for beauty and charm + oscillation + if (quark_id > -1 || next_mother_id > -1) { // we already found a possible candidate in the list of mothers, so now we have (at least) two // LOG(warning) << "Flavour tracking is ambiguous. Stopping here."; return -1; } quark_id = i; - } else if ((static_cast(abs(mpdg) / 100) == pdg || static_cast(abs(mpdg) / 1000) == pdg) && mpdg * p.pdgCode() > 0) { // check for other mothers with flavour content - if (quark_id > -1 || next_mother_id > -1) { // we already found a possible candidate in the list of mothers, so now we have (at least) two + //} else if ((static_cast(abs(mpdg) / 100) == pdg || static_cast(abs(mpdg) / 1000) == pdg) && mpdg * p.pdgCode() > 0) { // check for other mothers with flavour content + } else if ((static_cast(abs(mpdg) / 100) == pdg || static_cast(abs(mpdg) / 1000) == pdg)) { // check for other mothers with flavour content to allow for beauty and charm + if (quark_id > -1 || next_mother_id > -1) { // we already found a possible candidate in the list of mothers, so now we have (at least) two // LOG(warning) << "Flavour tracking is ambiguous. Stopping here."; return -1; } @@ -479,6 +531,7 @@ int searchMothers(T& p, U& mcParticles, int pdg, bool equal) return -1; } +//_______________________________________________________________________ template int findHFOrigin(T& p, U& mcParticles, int pdg) { @@ -490,7 +543,7 @@ int findHFOrigin(T& p, U& mcParticles, int pdg) int id = searchMothers(quark, mcParticles, pdg, false); // try to find the first ancestor that is not the hf quark anymore return id; } - +//_______________________________________________________________________ template bool checkFromSameQuarkPair(T& p1, T& p2, U& mcParticles, int pdg) { // check if two particles come from the same hf q-qbar pair diff --git a/PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h b/PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h index ef1c7b33474..2ed0b02fe3c 100644 --- a/PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h +++ b/PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h @@ -17,12 +17,12 @@ #ifndef PWGEM_DILEPTON_UTILS_MLRESPONSEDIELECTRONSINGLETRACK_H_ #define PWGEM_DILEPTON_UTILS_MLRESPONSEDIELECTRONSINGLETRACK_H_ +#include "Tools/ML/MlResponse.h" + #include #include #include -#include "Tools/ML/MlResponse.h" - // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures @@ -76,6 +76,16 @@ break; \ } +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER1 and GETTER2 from track. +#define CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_RELDIFF(FEATURE, GETTER1, GETTER2) \ + case static_cast(InputFeaturesDielectronSingleTrack::FEATURE): { \ + inputFeature = (track.GETTER2() - track.GETTER1()) / track.GETTER1(); \ + break; \ + } + // Check if the index of mCachedIndices (index associated to a FEATURE) // matches the entry in EnumInputFeatures associated to this FEATURE // if so, the inputFeatures vector is filled with the FEATURE's value @@ -104,20 +114,21 @@ enum class InputFeaturesDielectronSingleTrack : uint8_t { tpcNClsShared, tpcChi2NCl, tpcInnerParam, + reldiffp, tpcSignal, tpcNSigmaEl, - tpcNSigmaMu, + // tpcNSigmaMu, tpcNSigmaPi, tpcNSigmaKa, tpcNSigmaPr, beta, tofNSigmaEl, - tofNSigmaMu, + // tofNSigmaMu, tofNSigmaPi, tofNSigmaKa, tofNSigmaPr, tpctofNSigmaEl, - tpctofNSigmaMu, + // tpctofNSigmaMu, tpctofNSigmaPi, tpctofNSigmaKa, tpctofNSigmaPr, @@ -225,20 +236,21 @@ class MlResponseDielectronSingleTrack : public MlResponse CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNClsShared); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcChi2NCl); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcInnerParam); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_RELDIFF(reldiffp, p, tpcInnerParam); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcSignal); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNSigmaEl); - CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNSigmaMu); + // CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNSigmaMu); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNSigmaPi); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNSigmaKa); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNSigmaPr); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(beta); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tofNSigmaEl); - CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tofNSigmaMu); + // CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tofNSigmaMu); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tofNSigmaPi); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tofNSigmaKa); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tofNSigmaPr); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_TPCTOF(tpctofNSigmaEl, tpcNSigmaEl, tofNSigmaEl, hasTOF); - CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_TPCTOF(tpctofNSigmaMu, tpcNSigmaMu, tofNSigmaMu, hasTOF); + // CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_TPCTOF(tpctofNSigmaMu, tpcNSigmaMu, tofNSigmaMu, hasTOF); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_TPCTOF(tpctofNSigmaPi, tpcNSigmaPi, tofNSigmaPi, hasTOF); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_TPCTOF(tpctofNSigmaKa, tpcNSigmaKa, tofNSigmaKa, hasTOF); CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_TPCTOF(tpctofNSigmaPr, tpcNSigmaPr, tofNSigmaPr, hasTOF); @@ -372,20 +384,21 @@ class MlResponseDielectronSingleTrack : public MlResponse FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNClsShared), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcChi2NCl), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcInnerParam), + FILL_MAP_DIELECTRON_SINGLE_TRACK(reldiffp), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcSignal), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNSigmaEl), - FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNSigmaMu), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNSigmaMu), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNSigmaPi), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNSigmaKa), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNSigmaPr), FILL_MAP_DIELECTRON_SINGLE_TRACK(beta), FILL_MAP_DIELECTRON_SINGLE_TRACK(tofNSigmaEl), - FILL_MAP_DIELECTRON_SINGLE_TRACK(tofNSigmaMu), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(tofNSigmaMu), FILL_MAP_DIELECTRON_SINGLE_TRACK(tofNSigmaPi), FILL_MAP_DIELECTRON_SINGLE_TRACK(tofNSigmaKa), FILL_MAP_DIELECTRON_SINGLE_TRACK(tofNSigmaPr), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpctofNSigmaEl), - FILL_MAP_DIELECTRON_SINGLE_TRACK(tpctofNSigmaMu), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(tpctofNSigmaMu), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpctofNSigmaPi), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpctofNSigmaKa), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpctofNSigmaPr), @@ -475,6 +488,7 @@ class MlResponseDielectronSingleTrack : public MlResponse #undef CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_SQRT #undef CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_COS #undef CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_TPCTOF +#undef CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_RELDIFF #undef CHECK_AND_FILL_DIELECTRON_COLLISION #endif // PWGEM_DILEPTON_UTILS_MLRESPONSEDIELECTRONSINGLETRACK_H_ diff --git a/PWGEM/Dilepton/Utils/MlResponseO2Track.h b/PWGEM/Dilepton/Utils/MlResponseO2Track.h new file mode 100644 index 00000000000..cd9be049af6 --- /dev/null +++ b/PWGEM/Dilepton/Utils/MlResponseO2Track.h @@ -0,0 +1,333 @@ +// 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. + +/// \file MlResponseO2Track.h +/// \brief Class to compute the ML response for dielectron analyses at the single track level +/// \author Daniel Samitz , SMI Vienna +/// Elisa Meninno, , SMI Vienna + +#ifndef PWGEM_DILEPTON_UTILS_MLRESPONSEO2TRACK_H_ +#define PWGEM_DILEPTON_UTILS_MLRESPONSEO2TRACK_H_ + +#include "Tools/ML/MlResponse.h" + +#include +#include +#include + +// Fill the map of available input features +// the key is the feature's name (std::string) +// the value is the corresponding value in EnumInputFeatures +#define FILL_MAP_O2_TRACK(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesO2Track::FEATURE) \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER=FEATURE from track +#define CHECK_AND_FILL_O2_TRACK(GETTER) \ + case static_cast(InputFeaturesO2Track::GETTER): { \ + inputFeature = track.GETTER(); \ + break; \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER=FEATURE from track +#define CHECK_AND_FILL_O2_TRACKPARCOV(FEATURE, GETTER) \ + case static_cast(InputFeaturesO2Track::FEATURE): { \ + inputFeature = trackParCov.GETTER(); \ + break; \ + } + +// mean ITS cluster size +#define CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE(FEATURE, v1, v2) \ + case static_cast(InputFeaturesO2Track::FEATURE): { \ + int nsize = 0; \ + int ncls = 0; \ + for (int il = v1; il < v2; il++) { \ + nsize += track.itsClsSizeInLayer(il); \ + if (nsize > 0) { \ + ncls++; \ + } \ + } \ + inputFeature = static_cast(nsize) / static_cast(ncls); \ + break; \ + } + +// mean ITS cluster size x cos(lambda) +#define CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE_COS(FEATURE, v1, v2) \ + case static_cast(InputFeaturesO2Track::FEATURE): { \ + int nsize = 0; \ + int ncls = 0; \ + for (int il = v1; il < v2; il++) { \ + nsize += track.itsClsSizeInLayer(il); \ + if (nsize > 0) { \ + ncls++; \ + } \ + } \ + inputFeature = static_cast(nsize) / static_cast(ncls) * std::cos(std::atan(trackParCov.getTgl())); \ + break; \ + } + +// TPC+TOF combined nSigma +#define CHECK_AND_FILL_O2_TRACK_TPCTOF(FEATURE, GETTER1, GETTER2, GETTER3) \ + case static_cast(InputFeaturesO2Track::FEATURE): { \ + if (!track.GETTER3()) { \ + inputFeature = track.GETTER1(); \ + } else { \ + if (track.GETTER1() > 0) { \ + inputFeature = sqrt((pow(track.GETTER1(), 2) + pow(track.GETTER2(), 2)) / 2.); \ + } else { \ + inputFeature = (-1) * sqrt((pow(track.GETTER1(), 2) + pow(track.GETTER2(), 2)) / 2.); \ + } \ + } \ + break; \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER from track and applying a sqrt +#define CHECK_AND_FILL_O2_TRACK_SQRT(FEATURE, GETTER) \ + case static_cast(InputFeaturesO2Track::FEATURE): { \ + inputFeature = sqrt(track.GETTER()); \ + break; \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER1 from track and multiplying with cos(atan(GETTER2)) +#define CHECK_AND_FILL_O2_TRACK_COS(FEATURE, GETTER1, GETTER2) \ + case static_cast(InputFeaturesO2Track::FEATURE): { \ + inputFeature = track.GETTER1() * std::cos(std::atan(track.GETTER2())); \ + break; \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER1 and GETTER2 from track. +#define CHECK_AND_FILL_O2_TRACK_RELDIFF(FEATURE, GETTER1, GETTER2) \ + case static_cast(InputFeaturesO2Track::FEATURE): { \ + inputFeature = (track.GETTER2() - trackParCov.GETTER1()) / trackParCov.GETTER1(); \ + break; \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER=FEATURE from collision +#define CHECK_AND_FILL_DIELECTRON_COLLISION(GETTER) \ + case static_cast(InputFeaturesO2Track::GETTER): { \ + inputFeature = collision.GETTER(); \ + break; \ + } + +namespace o2::analysis +{ +// possible input features for ML +enum class InputFeaturesO2Track : uint8_t { + tpcInnerParam, + reldiffp, + tpcSignal, + tpcNSigmaEl, + tpcNSigmaMu, + tpcNSigmaPi, + tpcNSigmaKa, + tpcNSigmaPr, + beta, + tofNSigmaEl, + tofNSigmaMu, + tofNSigmaPi, + tofNSigmaKa, + tofNSigmaPr, + tpctofNSigmaEl, + tpctofNSigmaMu, + tpctofNSigmaPi, + tpctofNSigmaKa, + tpctofNSigmaPr, + tpcNClsFound, + tpcNClsCrossedRows, + hasITS, + hasTPC, + hasTRD, + hasTOF, + tgl, + p, + itsClusterSizes, + meanClusterSizeITS, + meanClusterSizeITSib, + meanClusterSizeITSob, + meanClusterSizeITSCos, + meanClusterSizeITSibCos, + meanClusterSizeITSobCos, + posZ, + numContrib, + trackOccupancyInTimeRange, + ft0cOccupancyInTimeRange, +}; + +template +class MlResponseO2Track : public MlResponse +{ + public: + /// Default constructor + MlResponseO2Track() = default; + /// Default destructor + virtual ~MlResponseO2Track() = default; + + template + float return_feature(uint8_t idx, T const& track, U const& trackParCov, V const& collision) + { + float inputFeature = 0.; + switch (idx) { + CHECK_AND_FILL_O2_TRACK(tpcInnerParam); + CHECK_AND_FILL_O2_TRACK_RELDIFF(reldiffp, getP, tpcInnerParam); + CHECK_AND_FILL_O2_TRACK(tpcSignal); + CHECK_AND_FILL_O2_TRACK(tpcNSigmaEl); + CHECK_AND_FILL_O2_TRACK(tpcNSigmaMu); + CHECK_AND_FILL_O2_TRACK(tpcNSigmaPi); + CHECK_AND_FILL_O2_TRACK(tpcNSigmaKa); + CHECK_AND_FILL_O2_TRACK(tpcNSigmaPr); + CHECK_AND_FILL_O2_TRACK(beta); + CHECK_AND_FILL_O2_TRACK(tofNSigmaEl); + CHECK_AND_FILL_O2_TRACK(tofNSigmaMu); + CHECK_AND_FILL_O2_TRACK(tofNSigmaPi); + CHECK_AND_FILL_O2_TRACK(tofNSigmaKa); + CHECK_AND_FILL_O2_TRACK(tofNSigmaPr); + CHECK_AND_FILL_O2_TRACK_TPCTOF(tpctofNSigmaEl, tpcNSigmaEl, tofNSigmaEl, hasTOF); + CHECK_AND_FILL_O2_TRACK_TPCTOF(tpctofNSigmaMu, tpcNSigmaMu, tofNSigmaMu, hasTOF); + CHECK_AND_FILL_O2_TRACK_TPCTOF(tpctofNSigmaPi, tpcNSigmaPi, tofNSigmaPi, hasTOF); + CHECK_AND_FILL_O2_TRACK_TPCTOF(tpctofNSigmaKa, tpcNSigmaKa, tofNSigmaKa, hasTOF); + CHECK_AND_FILL_O2_TRACK_TPCTOF(tpctofNSigmaPr, tpcNSigmaPr, tofNSigmaPr, hasTOF); + CHECK_AND_FILL_O2_TRACK(tpcNClsFound); + CHECK_AND_FILL_O2_TRACK(tpcNClsCrossedRows); + CHECK_AND_FILL_O2_TRACK(hasITS); + CHECK_AND_FILL_O2_TRACK(hasTPC); + CHECK_AND_FILL_O2_TRACK(hasTRD); + CHECK_AND_FILL_O2_TRACK(hasTOF); + CHECK_AND_FILL_O2_TRACKPARCOV(tgl, getTgl); + CHECK_AND_FILL_O2_TRACKPARCOV(p, getP); + CHECK_AND_FILL_O2_TRACK(itsClusterSizes); + CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE(meanClusterSizeITS, 0, 7); + CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE(meanClusterSizeITSib, 0, 3); + CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE(meanClusterSizeITSob, 3, 7); + CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE_COS(meanClusterSizeITSCos, 0, 7); + CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE_COS(meanClusterSizeITSibCos, 0, 3); + CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE_COS(meanClusterSizeITSobCos, 3, 7); + CHECK_AND_FILL_DIELECTRON_COLLISION(posZ); + CHECK_AND_FILL_DIELECTRON_COLLISION(numContrib); + CHECK_AND_FILL_DIELECTRON_COLLISION(trackOccupancyInTimeRange); + CHECK_AND_FILL_DIELECTRON_COLLISION(ft0cOccupancyInTimeRange); + } + return inputFeature; + } + + /// Method to get the input features vector needed for ML inference + /// \param track is the single track, \param collision is the collision + /// \return inputFeatures vector + template + std::vector getInputFeatures(T const& track, U const& trackParCov, V const& collision) + { + std::vector inputFeatures; + for (const auto& idx : MlResponse::mCachedIndices) { + float inputFeature = return_feature(idx, track, trackParCov, collision); + inputFeatures.emplace_back(inputFeature); + } + return inputFeatures; + } + + /// Method to get the value of variable chosen for binning + /// \param track is the single track, \param collision is the collision + /// \return binning variable + template + float getBinningFeature(T const& track, U const& trackParCov, V const& collision) + { + return return_feature(mCachedIndexBinning, track, trackParCov, collision); + } + + void cacheBinningIndex(std::string const& cfgBinningFeature) + { + setAvailableInputFeatures(); + if (MlResponse::mAvailableInputFeatures.count(cfgBinningFeature)) { + mCachedIndexBinning = MlResponse::mAvailableInputFeatures[cfgBinningFeature]; + } else { + LOG(fatal) << "Binning feature " << cfgBinningFeature << " not available! Please check your configurables."; + } + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + FILL_MAP_O2_TRACK(tpcInnerParam), + FILL_MAP_O2_TRACK(reldiffp), + FILL_MAP_O2_TRACK(tpcSignal), + FILL_MAP_O2_TRACK(tpcNSigmaEl), + FILL_MAP_O2_TRACK(tpcNSigmaMu), + FILL_MAP_O2_TRACK(tpcNSigmaPi), + FILL_MAP_O2_TRACK(tpcNSigmaKa), + FILL_MAP_O2_TRACK(tpcNSigmaPr), + FILL_MAP_O2_TRACK(beta), + FILL_MAP_O2_TRACK(tofNSigmaEl), + FILL_MAP_O2_TRACK(tofNSigmaMu), + FILL_MAP_O2_TRACK(tofNSigmaPi), + FILL_MAP_O2_TRACK(tofNSigmaKa), + FILL_MAP_O2_TRACK(tofNSigmaPr), + FILL_MAP_O2_TRACK(tpctofNSigmaEl), + FILL_MAP_O2_TRACK(tpctofNSigmaMu), + FILL_MAP_O2_TRACK(tpctofNSigmaPi), + FILL_MAP_O2_TRACK(tpctofNSigmaKa), + FILL_MAP_O2_TRACK(tpctofNSigmaPr), + FILL_MAP_O2_TRACK(tpcNClsFound), + FILL_MAP_O2_TRACK(tpcNClsCrossedRows), + FILL_MAP_O2_TRACK(hasITS), + FILL_MAP_O2_TRACK(hasTPC), + FILL_MAP_O2_TRACK(hasTRD), + FILL_MAP_O2_TRACK(hasTOF), + FILL_MAP_O2_TRACK(tgl), + FILL_MAP_O2_TRACK(p), + FILL_MAP_O2_TRACK(itsClusterSizes), + FILL_MAP_O2_TRACK(meanClusterSizeITS), + FILL_MAP_O2_TRACK(meanClusterSizeITSib), + FILL_MAP_O2_TRACK(meanClusterSizeITSob), + FILL_MAP_O2_TRACK(meanClusterSizeITSCos), + FILL_MAP_O2_TRACK(meanClusterSizeITSibCos), + FILL_MAP_O2_TRACK(meanClusterSizeITSobCos), + FILL_MAP_O2_TRACK(posZ), + FILL_MAP_O2_TRACK(numContrib), + FILL_MAP_O2_TRACK(trackOccupancyInTimeRange), + FILL_MAP_O2_TRACK(ft0cOccupancyInTimeRange)}; + } + + uint8_t mCachedIndexBinning; // index correspondance between configurable and available input features +}; + +} // namespace o2::analysis + +#undef FILL_MAP_O2_TRACK +#undef CHECK_AND_FILL_O2_TRACK +#undef CHECK_AND_FILL_O2_TRACKPARCOV +#undef CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE +#undef CHECK_AND_FILL_O2_TRACK_MEAN_ITSCLUSTER_SIZE_COS +#undef CHECK_AND_FILL_O2_TRACK_SQRT +#undef CHECK_AND_FILL_O2_TRACK_COS +#undef CHECK_AND_FILL_O2_TRACK_TPCTOF +#undef CHECK_AND_FILL_O2_TRACK_RELDIFF +#undef CHECK_AND_FILL_DIELECTRON_COLLISION + +#endif // PWGEM_DILEPTON_UTILS_MLRESPONSEO2TRACK_H_ diff --git a/PWGEM/Dilepton/Utils/MomentumSmearer.h b/PWGEM/Dilepton/Utils/MomentumSmearer.h index 7e36dcfed0f..10699e4c2a0 100644 --- a/PWGEM/Dilepton/Utils/MomentumSmearer.h +++ b/PWGEM/Dilepton/Utils/MomentumSmearer.h @@ -15,22 +15,27 @@ #ifndef PWGEM_DILEPTON_UTILS_MOMENTUMSMEARER_H_ #define PWGEM_DILEPTON_UTILS_MOMENTUMSMEARER_H_ -#include +#include "CCDB/BasicCCDBManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Logger.h" +#include "Framework/runDataProcessing.h" +#include +#include #include #include #include #include -#include -#include -#include #include +#include -#include "CCDB/BasicCCDBManager.h" -#include "Framework/Logger.h" +#include -using namespace o2::framework; using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; class MomentumSmearer { diff --git a/PWGEM/Dilepton/Utils/PairUtilities.h b/PWGEM/Dilepton/Utils/PairUtilities.h index a1010e76435..1fcede0e14d 100644 --- a/PWGEM/Dilepton/Utils/PairUtilities.h +++ b/PWGEM/Dilepton/Utils/PairUtilities.h @@ -15,14 +15,18 @@ #ifndef PWGEM_DILEPTON_UTILS_PAIRUTILITIES_H_ #define PWGEM_DILEPTON_UTILS_PAIRUTILITIES_H_ -#include -#include +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" + +#include "ReconstructionDataFormats/TrackFwd.h" + +#include "Math/GenVector/Boost.h" #include "Math/SMatrix.h" #include "Math/Vector3D.h" #include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" -#include "Common/Core/RecoDecay.h" -#include "ReconstructionDataFormats/TrackFwd.h" + +#include +#include //_______________________________________________________________________ namespace o2::aod::pwgem::dilepton::utils::pairutil @@ -42,6 +46,11 @@ enum class DileptonAnalysisType : int { kHFll = 6, }; +enum class DileptonHadronAnalysisType : int { + kAzimuthalCorrelation = 0, + kCumulant = 1, +}; + enum class DileptonPrefilterBit : int { kElFromPC = 0, // electron from photon conversion kElFromPi0_1 = 1, // electron from pi0 dalitz decay, threshold 1 diff --git a/PWGEM/PhotonMeson/Core/DalitzEECut.cxx b/PWGEM/PhotonMeson/Core/DalitzEECut.cxx index b82b7460dfc..df6418474a1 100644 --- a/PWGEM/PhotonMeson/Core/DalitzEECut.cxx +++ b/PWGEM/PhotonMeson/Core/DalitzEECut.cxx @@ -13,9 +13,13 @@ // Class for dilepton Cut // -#include "Framework/Logger.h" #include "PWGEM/PhotonMeson/Core/DalitzEECut.h" +#include "Framework/Logger.h" + +#include +#include + ClassImp(DalitzEECut); // const char* DalitzEECut::mCutNames[static_cast(DalitzEECut::DalitzEECuts::kNCuts)] = {"Mee", "PairPtRange", "PairRapidityRange", "PairDCARange", "PhivPair", "TrackPtRange", "TrackEtaRange", "TPCNCls", "TPCCrossedRows", "TPCCrossedRowsOverNCls", "TPCChi2NDF", "TPCNsigmaEl", "TPCNsigmaMu", "TPCNsigmaPi", "TPCNsigmaKa", "TPCNsigmaPr", "TOFNsigmaEl", "TOFNsigmaMu", "TOFNsigmaPi", "TOFNsigmaKa", "TOFNsigmaPr", "DCA3Dsigma", "DCAxy", "DCAz", "ITSNCls", "ITSChi2NDF", "ITSClusterSize", "Prefilter"}; @@ -78,6 +82,11 @@ void DalitzEECut::SetMinNCrossedRowsOverFindableClustersTPC(float minNCrossedRow mMinNCrossedRowsOverFindableClustersTPC = minNCrossedRowsOverFindableClustersTPC; LOG(info) << "DalitzEE Cut, set min N crossed rows over findable clusters TPC: " << mMinNCrossedRowsOverFindableClustersTPC; } +void DalitzEECut::SetMaxFracSharedClustersTPC(float max) +{ + mMaxFracSharedClustersTPC = max; + LOG(info) << "Dalitz EE Cut, set max fraction of shared clusters in TPC: " << mMaxFracSharedClustersTPC; +} void DalitzEECut::SetChi2PerClusterTPC(float min, float max) { mMinChi2PerClusterTPC = min; @@ -103,6 +112,12 @@ void DalitzEECut::SetMeanClusterSizeITS(float min, float max) mMaxMeanClusterSizeITS = max; LOG(info) << "DalitzEE Cut, set mean cluster size ITS range: " << mMinMeanClusterSizeITS << " - " << mMaxMeanClusterSizeITS; } +void DalitzEECut::SetTrackDca3DRange(float min, float max) +{ + mMinDca3D = min; + mMaxDca3D = max; + LOG(info) << "DalitzEE Cut, set DCA 3D range in sigma: " << mMinDca3D << " - " << mMaxDca3D; +} void DalitzEECut::SetMaxDcaXY(float maxDcaXY) { mMaxDcaXY = maxDcaXY; @@ -138,6 +153,12 @@ void DalitzEECut::SetTPCNsigmaPiRange(float min, float max) LOG(info) << "DalitzEE Cut, set TPC n sigma Pi range: " << mMinTPCNsigmaPi << " - " << mMaxTPCNsigmaPi; } +void DalitzEECut::SetTOFNsigmaElRange(float min, float max) +{ + mMinTOFNsigmaEl = min; + mMaxTOFNsigmaEl = max; + LOG(info) << "DalitzEE Cut, set TOF n sigma El range: " << mMinTOFNsigmaEl << " - " << mMaxTOFNsigmaEl; +} void DalitzEECut::RequireITSibAny(bool flag) { mRequireITSibAny = flag; @@ -148,43 +169,20 @@ void DalitzEECut::RequireITSib1st(bool flag) mRequireITSib1st = flag; LOG(info) << "DalitzEE Cut, require ITS ib 1st: " << mRequireITSib1st; } +void DalitzEECut::SetChi2TOF(float min, float max) +{ + mMinChi2TOF = min; + mMaxChi2TOF = max; + LOG(info) << "Dielectron Cut, set chi2 TOF range: " << mMinChi2TOF << " - " << mMaxChi2TOF; +} void DalitzEECut::SetPIDScheme(int scheme) { mPIDScheme = scheme; LOG(info) << "DalitzEE Cut, PID scheme: " << static_cast(mPIDScheme); } - -// void DalitzEECut::print() const -//{ -// LOG(info) << "Dalitz EE Cut:"; -// for (int i = 0; i < static_cast(DalitzEECuts::kNCuts); i++) { -// switch (static_cast(i)) { -// case DalitzEECuts::kTrackPtRange: -// LOG(info) << mCutNames[i] << " in [" << mMinTrackPt << ", " << mMaxTrackPt << "]"; -// break; -// case DalitzEECuts::kTrackEtaRange: -// LOG(info) << mCutNames[i] << " in [" << mMinTrackEta << ", " << mMaxTrackEta << "]"; -// break; -// case DalitzEECuts::kTPCNCls: -// LOG(info) << mCutNames[i] << " > " << mMinNClustersTPC; -// break; -// case DalitzEECuts::kTPCCrossedRows: -// LOG(info) << mCutNames[i] << " > " << mMinNCrossedRowsTPC; -// break; -// case DalitzEECuts::kTPCCrossedRowsOverNCls: -// LOG(info) << mCutNames[i] << " > " << mMinNCrossedRowsOverFindableClustersTPC; -// break; -// case DalitzEECuts::kTPCChi2NDF: -// LOG(info) << mCutNames[i] << " < " << mMaxChi2PerClusterTPC; -// break; -// case DalitzEECuts::kDCAxy: -// LOG(info) << mCutNames[i] << " < " << mMaxDcaXY; -// break; -// case DalitzEECuts::kDCAz: -// LOG(info) << mCutNames[i] << " < " << mMaxDcaZ; -// break; -// default: -// LOG(fatal) << "Cut unknown!"; -// } -// } -// } +void DalitzEECut::IncludeITSsa(bool flag, float max) +{ + mIncludeITSsa = flag; + mMaxPtITSsa = max; + LOG(info) << "DalitzEE Cut, include ITSsa tracks: " << mIncludeITSsa << ", mMaxPtITSsa = " << mMaxPtITSsa; +} diff --git a/PWGEM/PhotonMeson/Core/DalitzEECut.h b/PWGEM/PhotonMeson/Core/DalitzEECut.h index 5ac38396976..ddc1da18340 100644 --- a/PWGEM/PhotonMeson/Core/DalitzEECut.h +++ b/PWGEM/PhotonMeson/Core/DalitzEECut.h @@ -16,22 +16,24 @@ #ifndef PWGEM_PHOTONMESON_CORE_DALITZEECUT_H_ #define PWGEM_PHOTONMESON_CORE_DALITZEECUT_H_ -#include -#include -#include -#include -#include -#include "TNamed.h" -#include "Math/Vector4D.h" +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" #include "Tools/ML/MlResponse.h" #include "Tools/ML/model.h" -#include "Framework/Logger.h" -#include "Framework/DataTypes.h" #include "CommonConstants/PhysicsConstants.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "Framework/DataTypes.h" +#include "Framework/Logger.h" + +#include "Math/Vector4D.h" +#include "TNamed.h" + +#include +#include +#include +#include +#include using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; @@ -53,21 +55,23 @@ class DalitzEECut : public TNamed kTPCNCls, kTPCCrossedRows, kTPCCrossedRowsOverNCls, + kTPCFracSharedClusters, kTPCChi2NDF, kTPCNsigmaEl, kTPCNsigmaPi, + kDCA3Dsigma, kDCAxy, kDCAz, kITSNCls, kITSChi2NDF, - kITSCluserSize, kNCuts }; static const char* mCutNames[static_cast(DalitzEECuts::kNCuts)]; enum class PIDSchemes : int { kUnDef = -1, - kTPConly = 0, + kTOFif = 0, + kTPConly = 1, }; template @@ -113,7 +117,7 @@ class DalitzEECut : public TNamed template bool IsSelectedTrack(TTrack const& track, TCollision const& = 0) const { - if (!track.hasITS() || !track.hasTPC()) { // track has to be ITS-TPC matched track + if (!track.hasITS()) { return false; } @@ -123,6 +127,9 @@ class DalitzEECut : public TNamed if (!IsSelectedTrack(track, DalitzEECuts::kTrackEtaRange)) { return false; } + if (!IsSelectedTrack(track, DalitzEECuts::kDCA3Dsigma)) { + return false; + } if (!IsSelectedTrack(track, DalitzEECuts::kDCAxy)) { return false; } @@ -137,9 +144,6 @@ class DalitzEECut : public TNamed if (!IsSelectedTrack(track, DalitzEECuts::kITSChi2NDF)) { return false; } - if (!IsSelectedTrack(track, DalitzEECuts::kITSCluserSize)) { - return false; - } if (mRequireITSibAny) { auto hits_ib = std::count_if(its_ib_any_Requirement.second.begin(), its_ib_any_Requirement.second.end(), [&](auto&& requiredLayer) { return track.itsClusterMap() & (1 << requiredLayer); }); @@ -155,25 +159,44 @@ class DalitzEECut : public TNamed } } - // TPC cuts - if (!IsSelectedTrack(track, DalitzEECuts::kTPCNCls)) { - return false; - } - if (!IsSelectedTrack(track, DalitzEECuts::kTPCCrossedRows)) { + if (!mIncludeITSsa && (!track.hasITS() || !track.hasTPC())) { // track has to be ITS-TPC matched track return false; } - if (!IsSelectedTrack(track, DalitzEECuts::kTPCCrossedRowsOverNCls)) { + + if ((track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF()) && track.pt() > mMaxPtITSsa) { // ITSsa return false; } - if (!IsSelectedTrack(track, DalitzEECuts::kTPCChi2NDF)) { - return false; + + // TPC cuts + if (track.hasTPC()) { + if (!IsSelectedTrack(track, DalitzEECuts::kTPCNCls)) { + return false; + } + if (!IsSelectedTrack(track, DalitzEECuts::kTPCCrossedRows)) { + return false; + } + if (!IsSelectedTrack(track, DalitzEECuts::kTPCCrossedRowsOverNCls)) { + return false; + } + if (!IsSelectedTrack(track, DalitzEECuts::kTPCFracSharedClusters)) { + return false; + } + if (!IsSelectedTrack(track, DalitzEECuts::kTPCChi2NDF)) { + return false; + } } // PID cuts - if (!PassPID(track)) { - return false; + if (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF()) { // ITSsa + float meanClusterSizeITS = track.meanClusterSizeITS() * std::cos(std::atan(track.tgl())); + if (meanClusterSizeITS < mMinMeanClusterSizeITS || mMaxMeanClusterSizeITS < meanClusterSizeITS) { + return false; + } + } else { + if (!PassPID(track)) { + return false; + } } - return true; } @@ -184,6 +207,9 @@ class DalitzEECut : public TNamed case static_cast(PIDSchemes::kTPConly): return PassTPConly(track); + case static_cast(PIDSchemes::kTOFif): + return PassTOFif(track); + case static_cast(PIDSchemes::kUnDef): return true; @@ -200,15 +226,24 @@ class DalitzEECut : public TNamed return is_el_included_TPC && is_pi_excluded_TPC; } + template + bool PassTOFif(T const& track) const + { + bool is_el_included_TPC = mMinTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < mMaxTPCNsigmaEl; + bool is_pi_excluded_TPC = track.tpcNSigmaPi() < mMinTPCNsigmaPi || mMaxTPCNsigmaPi < track.tpcNSigmaPi(); + bool is_el_included_TOF = track.hasTOF() ? (mMinTOFNsigmaEl < track.tofNSigmaEl() && track.tofNSigmaEl() < mMaxTOFNsigmaEl && track.tofChi2() < mMaxChi2TOF) : true; + return is_el_included_TPC && is_pi_excluded_TPC && is_el_included_TOF; + } + template bool IsSelectedTrack(T const& track, const DalitzEECuts& cut) const { switch (cut) { case DalitzEECuts::kTrackPtRange: - return track.pt() >= mMinTrackPt && track.pt() <= mMaxTrackPt; + return track.pt() > mMinTrackPt && track.pt() < mMaxTrackPt; case DalitzEECuts::kTrackEtaRange: - return track.eta() >= mMinTrackEta && track.eta() <= mMaxTrackEta; + return track.eta() > mMinTrackEta && track.eta() < mMaxTrackEta; case DalitzEECuts::kTPCNCls: return track.tpcNClsFound() >= mMinNClustersTPC; @@ -219,14 +254,20 @@ class DalitzEECut : public TNamed case DalitzEECuts::kTPCCrossedRowsOverNCls: return track.tpcCrossedRowsOverFindableCls() >= mMinNCrossedRowsOverFindableClustersTPC; + case DalitzEECuts::kTPCFracSharedClusters: + return track.tpcFractionSharedCls() < mMaxFracSharedClustersTPC; + case DalitzEECuts::kTPCChi2NDF: return mMinChi2PerClusterTPC < track.tpcChi2NCl() && track.tpcChi2NCl() < mMaxChi2PerClusterTPC; + case DalitzEECuts::kDCA3Dsigma: + return mMinDca3D < dca3DinSigma(track) && dca3DinSigma(track) < mMaxDca3D; // in sigma for single leg + case DalitzEECuts::kDCAxy: - return abs(track.dcaXY()) <= ((mMaxDcaXYPtDep) ? mMaxDcaXYPtDep(track.pt()) : mMaxDcaXY); + return std::fabs(track.dcaXY()) < ((mMaxDcaXYPtDep) ? mMaxDcaXYPtDep(track.pt()) : mMaxDcaXY); case DalitzEECuts::kDCAz: - return abs(track.dcaZ()) <= mMaxDcaZ; + return std::fabs(track.dcaZ()) < mMaxDcaZ; case DalitzEECuts::kITSNCls: return mMinNClustersITS <= track.itsNCls() && track.itsNCls() <= mMaxNClustersITS; @@ -234,9 +275,6 @@ class DalitzEECut : public TNamed case DalitzEECuts::kITSChi2NDF: return mMinChi2PerClusterITS < track.itsChi2NCl() && track.itsChi2NCl() < mMaxChi2PerClusterITS; - case DalitzEECuts::kITSCluserSize: - return mMinMeanClusterSizeITS < track.meanClusterSizeITS() * std::cos(std::atan(track.tgl())) && track.meanClusterSizeITS() * std::cos(std::atan(track.tgl())) < mMaxMeanClusterSizeITS; - default: return false; } @@ -245,7 +283,7 @@ class DalitzEECut : public TNamed // Setters void SetPairPtRange(float minPt = 0.f, float maxPt = 1e10f); void SetPairYRange(float minY = -1e10f, float maxY = 1e10f); - void SetMeeRange(float min = 0.f, float max = 0.5); + void SetMeeRange(float min = 0.f, float max = 0.04); void SetMaxPhivPairMeeDep(std::function meeDepCut); void SelectPhotonConversion(bool flag); @@ -254,29 +292,31 @@ class DalitzEECut : public TNamed void SetMinNClustersTPC(int minNClustersTPC); void SetMinNCrossedRowsTPC(int minNCrossedRowsTPC); void SetMinNCrossedRowsOverFindableClustersTPC(float minNCrossedRowsOverFindableClustersTPC); + void SetMaxFracSharedClustersTPC(float max); void SetChi2PerClusterTPC(float min, float max); void SetNClustersITS(int min, int max); void SetChi2PerClusterITS(float min, float max); void SetMeanClusterSizeITS(float min, float max); + void SetChi2TOF(float min, float max); void SetPIDScheme(int scheme); - void SetTPCNsigmaElRange(float min = -1e+10, float max = 1e+10); - void SetTPCNsigmaPiRange(float min = -1e+10, float max = 1e+10); + void SetTPCNsigmaElRange(float min, float max); + void SetTPCNsigmaPiRange(float min, float max); + void SetTOFNsigmaElRange(float min, float max); void RequireITSibAny(bool flag); void RequireITSib1st(bool flag); - void SetMaxDcaXY(float maxDcaXY); // in cm - void SetMaxDcaZ(float maxDcaZ); // in cm + void SetTrackDca3DRange(float min, float max); // in sigma + void SetMaxDcaXY(float maxDcaXY); // in cm + void SetMaxDcaZ(float maxDcaZ); // in cm void SetMaxDcaXYPtDep(std::function ptDepCut); void ApplyPrefilter(bool flag); void ApplyPhiV(bool flag); + void IncludeITSsa(bool flag, float maxpt); // Getters bool IsPhotonConversionSelected() const { return mSelectPC; } - /// @brief Print the track selection - // void print() const; - private: static const std::pair> its_ib_any_Requirement; static const std::pair> its_ib_1st_Requirement; @@ -297,24 +337,29 @@ class DalitzEECut : public TNamed int mMinNCrossedRowsTPC{0}; // min number of crossed rows in TPC float mMinChi2PerClusterTPC{-1e10f}, mMaxChi2PerClusterTPC{1e10f}; // max tpc fit chi2 per TPC cluster float mMinNCrossedRowsOverFindableClustersTPC{0.f}; // min ratio crossed rows / findable clusters + float mMaxFracSharedClustersTPC{999.f}; // max ratio shared clusters / clusters in TPC int mMinNClustersITS{0}, mMaxNClustersITS{7}; // range in number of ITS clusters float mMinChi2PerClusterITS{-1e10f}, mMaxChi2PerClusterITS{1e10f}; // max its fit chi2 per ITS cluster float mMaxPinMuonTPConly{0.2f}; // max pin cut for muon ID with TPConly bool mRequireITSibAny{true}; bool mRequireITSib1st{false}; + float mMinDca3D{0.0f}; // min dca in 3D in units of sigma + float mMaxDca3D{1e+10}; // max dca in 3D in units of sigma float mMaxDcaXY{1.0f}; // max dca in xy plane float mMaxDcaZ{1.0f}; // max dca in z direction std::function mMaxDcaXYPtDep{}; // max dca in xy plane as function of pT bool mApplyPhiV{true}; - float mMinMeanClusterSizeITS{-1e10f}, mMaxMeanClusterSizeITS{1e10f}; // max x cos(Lmabda) + float mMinMeanClusterSizeITS{-1e10f}, mMaxMeanClusterSizeITS{1e10f}; // x cos(lmabda) + float mMinChi2TOF{-1e10f}, mMaxChi2TOF{1e10f}; // max tof chi2 per + bool mIncludeITSsa{false}; + float mMaxPtITSsa{0.15}; // pid cuts int mPIDScheme{-1}; float mMinTPCNsigmaEl{-1e+10}, mMaxTPCNsigmaEl{+1e+10}; - float mMinTPCNsigmaPi{-1e+10}, mMaxTPCNsigmaPi{+1e+10}; - - o2::ml::OnnxModel* mPIDModel{nullptr}; + float mMinTPCNsigmaPi{0}, mMaxTPCNsigmaPi{0}; + float mMinTOFNsigmaEl{-1e+10}, mMaxTOFNsigmaEl{+1e+10}; ClassDef(DalitzEECut, 1); }; diff --git a/PWGEM/PhotonMeson/Core/DiphotonHadronMPC.h b/PWGEM/PhotonMeson/Core/DiphotonHadronMPC.h new file mode 100644 index 00000000000..a0811629c32 --- /dev/null +++ b/PWGEM/PhotonMeson/Core/DiphotonHadronMPC.h @@ -0,0 +1,1013 @@ +// 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. +// +// ======================== +// +/// \file DiphotonHadronMPC.h +/// \brief This code is to analyze diphoton-hadron correlation. Keep in mind that cumulant method does not require event mixing. +/// +/// \author D. Sekihata, daiki.sekihata@cern.ch + +#ifndef PWGEM_PHOTONMESON_CORE_DIPHOTONHADRONMPC_H_ +#define PWGEM_PHOTONMESON_CORE_DIPHOTONHADRONMPC_H_ + +#include "PWGEM/Dilepton/Core/EMTrackCut.h" +#include "PWGEM/Dilepton/Utils/EMTrack.h" +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/EventMixingHandler.h" +#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" +#include "PWGEM/PhotonMeson/Utils/NMHistograms.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" + +#include "Common/CCDB/RCTSelectionFlags.h" +#include "Common/Core/RecoDecay.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" +#include "TString.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::aod::pwgem::photonmeson::photonpair; +using namespace o2::aod::pwgem::photon; +using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; +using namespace o2::aod::pwgem::dilepton::utils; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyCollisionsWithSWT = soa::Join; +using MyCollisionWithSWT = MyCollisionsWithSWT::iterator; + +using MyV0Photons = soa::Filtered>; +using MyV0Photon = MyV0Photons::iterator; + +using MyPrimaryElectrons = soa::Filtered>; +using MyPrimaryElectron = MyPrimaryElectrons::iterator; + +using MyTracks = soa::Join; +using MyTrack = MyTracks::iterator; + +template +struct DiphotonHadronMPC { + + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; + Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; + Configurable cfg_swt_name{"cfg_swt_name", "fHighTrackMult", "desired software trigger name"}; // 1 trigger name per 1 task. fHighTrackMult, fHighFt0Mult + + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgOccupancyEstimator{"cfgOccupancyEstimator", 0, "FT0C:0, Track:1"}; + Configurable cfgCentMin{"cfgCentMin", -1, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999, "max. centrality"}; + Configurable maxY{"maxY", 0.8, "maximum rapidity for diphoton"}; + Configurable cfgDoMix{"cfgDoMix", true, "flag for event mixing"}; + Configurable ndepth_photon{"ndepth_photon", 100, "depth for event mixing between photon-photon"}; + Configurable ndepth_hadron{"ndepth_hadron", 2, "depth for event mixing between hadron-hadron"}; + Configurable ndiff_bc_mix{"ndiff_bc_mix", 594, "difference in global BC required in mixed events"}; + ConfigurableAxis ConfVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0.0f, 0.1, 1, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.f, 999.f}, "Mixing bins - centrality"}; + ConfigurableAxis ConfOccupancyBins{"ConfOccupancyBins", {VARIABLE_WIDTH, -1, 1e+10}, "Mixing bins - occupancy"}; + + ConfigurableAxis ConfMggBins{"ConfMggBins", {200, 0.0, 0.8}, "mgg bins for output histograms"}; + ConfigurableAxis ConfPtggBins{"ConfPtggBins", {VARIABLE_WIDTH, 0.0, 0.1, 0.2, 0.3, 0.4, 0.50, 1.00, 1.50, 2.00, 2.50, 3.00, 3.50, 4.00, 4.50, 5.00, 6.00, 7.00, 8.00, 9.00, 10.00}, "pTgg bins for output histograms"}; + + ConfigurableAxis ConfPtHadronBins{"ConfPtHadronBins", {VARIABLE_WIDTH, 0.00, 0.15, 0.2, 0.3, 0.4, 0.50, 1.00, 2.00, 3.00, 4.00, 5.00}, "pT,h bins for output histograms"}; + ConfigurableAxis ConfDEtaBins{"ConfDEtaBins", {60, -3, 3}, "deta bins for output histograms"}; + Configurable cfgNbinsDPhi{"cfgNbinsDPhi", 36, "nbins in dphi for output histograms"}; + // Configurable cfgNbinsCosNDPhi{"cfgNbinsCosNDPhi", 100, "nbins in cos(n(dphi)) for output histograms"}; + // Configurable cfgNmod{"cfgNmod", 2, "n-th harmonics"}; + + EMPhotonEventCut fEMEventCut; + struct : ConfigurableGroup { + std::string prefix = "eventcut_group"; + Configurable cfgZvtxMin{"cfgZvtxMin", -10.f, "min. Zvtx"}; + Configurable cfgZvtxMax{"cfgZvtxMax", +10.f, "max. Zvtx"}; + Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; + Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; + // for RCT + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", false, "require good detector flag in run condtion table"}; + Configurable cfgRCTLabel{"cfgRCTLabel", "CBT_hadronPID", "select 1 [CBT, CBT_hadronPID] see O2Physics/Common/CCDB/RCTSelectionFlags.h"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "set ZDC flag for PbPb"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; + } eventcuts; + + V0PhotonCut fV0PhotonCut; + struct : ConfigurableGroup { + std::string prefix = "pcmcut_group"; + Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; + Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; + Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; + Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; + Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; + Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.8, "min eta for v0 photons at PV"}; + Configurable cfg_max_eta_v0{"cfg_max_eta_v0", 0.8, "max eta for v0 photons at PV"}; + Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; + Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; + Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; + Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.997, "min V0 CosPA"}; + Configurable cfg_max_pca{"cfg_max_pca", 3.0, "max distance btween 2 legs"}; + Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; + Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", false, "flag to select V0s with correct xz"}; + Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; + Configurable cfg_apply_cuts_from_prefilter_derived{"cfg_apply_cuts_from_prefilter_derived", false, "flag to apply prefilter to V0"}; + + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; + Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; + } pcmcuts; + + DalitzEECut fDileptonCut; + struct : ConfigurableGroup { + std::string prefix = "dileptoncut_group"; + Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; + Configurable cfg_max_mass{"cfg_max_mass", 0.04, "max mass"}; + Configurable cfg_apply_phiv{"cfg_apply_phiv", true, "flag to apply phiv cut"}; + Configurable cfg_require_itsib_any{"cfg_require_itsib_any", false, "flag to require ITS ib any hits"}; + Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; + Configurable cfg_phiv_slope{"cfg_phiv_slope", 0.0185, "slope for m vs. phiv"}; + Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.1, "min pT for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", 2.0, "max eta for single track"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; + Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 70, "min ncrossed rows"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.1, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.1, "max dca Z for single track in cm"}; + Configurable cfg_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1e+10, "max DCA 3D in sigma"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 0.7, "max fraction of shared clusters in TPC"}; + Configurable cfg_apply_cuts_from_prefilter_derived{"cfg_apply_cuts_from_prefilter_derived", false, "flag to apply prefilter to electron"}; + + Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTOFif), "pid scheme [kTOFif : 0, kTPConly : 1]"}; + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -0.0, "min. TPC n sigma for pion exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +0.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + } dileptoncuts; + + EMTrackCut fEMTrackCut; + struct : ConfigurableGroup { + std::string prefix = "trackcut_group"; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for ref. track"}; + Configurable cfg_max_pt_track{"cfg_max_pt_track", 3.0, "max pT for ref. track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "min eta for ref. track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.8, "max eta for ref. track"}; + Configurable cfg_min_phi_track{"cfg_min_phi_track", 0.0, "min phi for ref. track"}; + Configurable cfg_max_phi_track{"cfg_max_phi_track", 6.3, "max phi for ref. track"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.5, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.5, "max dca Z for single track in cm"}; + Configurable cfg_track_bits{"cfg_track_bits", 645, "required track bits"}; // default:645, loose:0, tight:778 + // Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; + // Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + // Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 70, "min ncrossed rows"}; + // Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 0.7, "max fraction of shared clusters in TPC"}; + // Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + // Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + // Configurable cfg_require_itsib_any{"cfg_require_itsib_any", true, "flag to require ITS ib any hits"}; + // Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", false, "flag to require ITS ib 1st hit"}; + } trackcuts; + + o2::aod::rctsel::RCTFlagsChecker rctChecker; + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + static constexpr std::string_view event_types[2] = {"before/", "after/"}; + static constexpr std::string_view event_pair_types[2] = {"same/", "mix/"}; + + std::vector zvtx_bin_edges; + std::vector cent_bin_edges; + std::vector occ_bin_edges; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber; + float d_bz; + + void init(InitContext&) + { + zvtx_bin_edges = std::vector(ConfVtxBins.value.begin(), ConfVtxBins.value.end()); + zvtx_bin_edges.erase(zvtx_bin_edges.begin()); + + cent_bin_edges = std::vector(ConfCentBins.value.begin(), ConfCentBins.value.end()); + cent_bin_edges.erase(cent_bin_edges.begin()); + + LOGF(info, "cfgOccupancyEstimator = %d", cfgOccupancyEstimator.value); + occ_bin_edges = std::vector(ConfOccupancyBins.value.begin(), ConfOccupancyBins.value.end()); + occ_bin_edges.erase(occ_bin_edges.begin()); + + emh1 = new MyEMH(ndepth_photon); + emh2 = new MyEMH(ndepth_photon); + emh_diphoton = new MyEMH_track(ndepth_photon); + emh_ref = new MyEMH_track(ndepth_hadron); + + o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry); + addHistograms(); + + DefineEMEventCut(); + DefineEMTrackCut(); + DefinePCMCut(); + DefineDileptonCut(); + + fRegistry.add("Diphoton/mix/hDiffBC", "diff. global BC in mixed event;|BC_{current} - BC_{mixed}|", kTH1D, {{10001, -0.5, 10000.5}}, true); + if (doprocessTriggerAnalysis) { + fRegistry.add("Event/hNInspectedTVX", "N inspected TVX;run number;N_{TVX}", kTProfile, {{80000, 520000.5, 600000.5}}, true); + } + + mRunNumber = 0; + d_bz = 0; + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + rctChecker.init(eventcuts.cfgRCTLabel.value, eventcuts.cfgCheckZDC.value, eventcuts.cfgTreatLimitedAcceptanceAsBad.value); + } + + template + void initCCDB(TCollision const& collision) + { + if (mRunNumber == collision.runNumber()) { + return; + } + + // In case override, don't proceed, please - no CCDB access required + if (d_bz_input > -990) { + d_bz = d_bz_input; + o2::parameters::GRPMagField grpmag; + if (std::fabs(d_bz) > 1e-5) { + grpmag.setL3Current(30000.f / (d_bz / 5.0f)); + } + mRunNumber = collision.runNumber(); + return; + } + + auto run3grp_timestamp = collision.timestamp(); + o2::parameters::GRPObject* grpo = 0x0; + o2::parameters::GRPMagField* grpmag = 0x0; + if (!skipGRPOquery) { + grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + } + if (grpo) { + // Fetch magnetic field from ccdb for current collision + d_bz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + // Fetch magnetic field from ccdb for current collision + d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } + mRunNumber = collision.runNumber(); + + if constexpr (isTriggerAnalysis) { + LOGF(info, "Trigger analysis is enabled. Desired trigger name = %s", cfg_swt_name.value); + LOGF(info, "total inspected TVX events = %d in run number %d", collision.nInspectedTVX(), collision.runNumber()); + fRegistry.fill(HIST("Event/hNInspectedTVX"), collision.runNumber(), collision.nInspectedTVX()); + } + } + + ~DiphotonHadronMPC() + { + delete emh1; + emh1 = 0x0; + delete emh2; + emh2 = 0x0; + delete emh_diphoton; + emh_diphoton = 0x0; + delete emh_ref; + emh_ref = 0x0; + + used_photonIds.clear(); + used_photonIds.shrink_to_fit(); + used_dileptonIds.clear(); + used_dileptonIds.shrink_to_fit(); + used_refTrackIds.clear(); + used_refTrackIds.shrink_to_fit(); + + map_mixed_eventId_to_globalBC.clear(); + } + + void addHistograms() + { + std::string mass_axis_title = "m_{#gamma#gamma} (GeV/c^{2})"; + std::string pair_pt_axis_title = "p_{T,#gamma#gamma} (GeV/c)"; + std::string deta_axis_title = "#Delta#eta = #eta_{#gamma#gamma} - #eta_{h}"; + std::string dphi_axis_title = "#Delta#varphi = #varphi_{#gamma#gamma} - #varphi_{h} (rad.)"; + // std::string cosndphi_axis_title = std::format("cos({0:d}(#varphi_{{#gamma#gamma}} - #varphi_{{h}}))", cfgNmod.value); + + if constexpr (pairtype == PairType::kPCMDalitzEE) { + mass_axis_title = "m_{ee#gamma} (GeV/c^{2})"; + pair_pt_axis_title = "p_{T,ee#gamma} (GeV/c)"; + deta_axis_title = "#Delta#eta = #eta_{ee#gamma} - #eta_{h}"; + dphi_axis_title = "#Delta#varphi = #varphi_{ee#gamma} - #varphi_{h} (rad.)"; + // cosndphi_axis_title = std::format("cos({0:d}(#varphi_{{ee#gamma}} - #varphi_{{h}}))", cfgNmod.value); + } + + // photon info + const AxisSpec axis_pt_single{ConfPtggBins, "p_{T,#gamma} (GeV/c)"}; + const AxisSpec axis_eta_single{20, -1, +1, "#eta_{#gamma}"}; + const AxisSpec axis_phi_single{36, 0, 2 * M_PI, "#varphi_{#gamma} (rad.)"}; + const AxisSpec axis_deta_single{ConfDEtaBins, "#Delta#eta = #eta_{#gamma} - #eta_{h}"}; + const AxisSpec axis_dphi_single{cfgNbinsDPhi, -M_PI / 2, +3 * M_PI / 2, "#Delta#varphi = #varphi_{#gamma} - #varphi_{h} (rad.)"}; + // const AxisSpec axis_cos_ndphi_single{cfgNbinsCosNDPhi, -1, +1, std::format("cos({0:d}(#varphi_{{#gamma}} - #varphi_{{h}}))", cfgNmod.value)}; + + // diphoton info + const AxisSpec axis_mass{ConfMggBins, mass_axis_title}; + const AxisSpec axis_pt{ConfPtggBins, pair_pt_axis_title}; + + // diphoton-hadron info + const AxisSpec axis_pt_ref{ConfPtHadronBins, "p_{T,h}^{ref} (GeV/c)"}; + const AxisSpec axis_deta{ConfDEtaBins, deta_axis_title}; + const AxisSpec axis_dphi{cfgNbinsDPhi, -M_PI / 2, +3 * M_PI / 2, dphi_axis_title}; + + const AxisSpec axis_pt_hadron{ConfPtHadronBins, "p_{T,h} (GeV/c)"}; + const AxisSpec axis_eta_hadron{40, -2, +2, "#eta_{h}"}; + const AxisSpec axis_phi_hadron{36, 0, 2 * M_PI, "#varphi_{h} (rad.)"}; + + fRegistry.add("Hadron/hs", "hadron", kTHnSparseD, {axis_pt_hadron, axis_eta_hadron, axis_phi_hadron}, true); + + fRegistry.add("Diphoton/same/hs", "diphoton", kTHnSparseD, {axis_mass, axis_pt}, true); + fRegistry.addClone("Diphoton/same/", "Diphoton/mix/"); + + fRegistry.add("DiphotonHadron/same/hs", "diphoton-hadron 2PC", kTHnSparseD, {axis_mass, axis_pt, axis_pt_ref, axis_deta, axis_dphi}, true); + fRegistry.addClone("DiphotonHadron/same/", "DiphotonHadron/mix/"); + + // hadron-hadron + const AxisSpec axis_deta_hh{ConfDEtaBins, "#Delta#eta = #eta_{h}^{ref1} - #eta_{h}^{ref2}"}; + const AxisSpec axis_dphi_hh{cfgNbinsDPhi, -M_PI / 2, +3 * M_PI / 2, "#Delta#varphi = #varphi_{h}^{ref1} - #varphi_{h}^{ref2} (rad.)"}; + // const AxisSpec axis_cosndphi_hh{cfgNbinsCosNDPhi, -1, +1, std::format("cos({0:d}(#varphi_{{h}}^{{ref1}} - #varphi_{{h}}^{{ref2}}))", cfgNmod.value)}; + fRegistry.add("HadronHadron/same/hs", "hadron-hadron 2PC", kTHnSparseD, {axis_pt_hadron, axis_pt_ref, axis_deta_hh, axis_dphi_hh}, true); + fRegistry.addClone("HadronHadron/same/", "HadronHadron/mix/"); + } + + void DefineEMEventCut() + { + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); + fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); + fEMEventCut.SetZvtxRange(eventcuts.cfgZvtxMin, +eventcuts.cfgZvtxMax); + fEMEventCut.SetRequireNoTFB(eventcuts.cfgRequireNoTFB); + fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); + fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); + fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + } + + void DefinePCMCut() + { + fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); + + // for v0 + fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, pcmcuts.cfg_max_pt_v0); + fV0PhotonCut.SetV0EtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); + fV0PhotonCut.SetMinCosPA(pcmcuts.cfg_min_cospa); + fV0PhotonCut.SetMaxPCA(pcmcuts.cfg_max_pca); + fV0PhotonCut.SetMaxChi2KF(pcmcuts.cfg_max_chi2kf); + fV0PhotonCut.SetRxyRange(pcmcuts.cfg_min_v0radius, pcmcuts.cfg_max_v0radius); + fV0PhotonCut.SetAPRange(pcmcuts.cfg_max_alpha_ap, pcmcuts.cfg_max_qt_ap); + fV0PhotonCut.RejectITSib(pcmcuts.cfg_reject_v0_on_itsib); + + // for track + fV0PhotonCut.SetMinNClustersTPC(pcmcuts.cfg_min_ncluster_tpc); + fV0PhotonCut.SetMinNCrossedRowsTPC(pcmcuts.cfg_min_ncrossedrows); + fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fV0PhotonCut.SetMaxFracSharedClustersTPC(pcmcuts.cfg_max_frac_shared_clusters_tpc); + fV0PhotonCut.SetChi2PerClusterTPC(0.0, pcmcuts.cfg_max_chi2tpc); + fV0PhotonCut.SetTPCNsigmaElRange(pcmcuts.cfg_min_TPCNsigmaEl, pcmcuts.cfg_max_TPCNsigmaEl); + fV0PhotonCut.SetChi2PerClusterITS(-1e+10, pcmcuts.cfg_max_chi2its); + fV0PhotonCut.SetNClustersITS(0, 7); + fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); + fV0PhotonCut.SetIsWithinBeamPipe(pcmcuts.cfg_require_v0_with_correct_xz); + fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); + fV0PhotonCut.SetDisableTPConly(pcmcuts.cfg_disable_tpconly_track); + fV0PhotonCut.SetRequireITSTPC(pcmcuts.cfg_require_v0_with_itstpc); + fV0PhotonCut.SetRequireITSonly(pcmcuts.cfg_require_v0_with_itsonly); + fV0PhotonCut.SetRequireTPConly(pcmcuts.cfg_require_v0_with_tpconly); + } + + void DefineDileptonCut() + { + fDileptonCut = DalitzEECut("fDileptonCut", "fDileptonCut"); + + // for pair + fDileptonCut.SetMeeRange(dileptoncuts.cfg_min_mass, dileptoncuts.cfg_max_mass); + fDileptonCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dileptoncuts.cfg_phiv_intercept) / dileptoncuts.cfg_phiv_slope; }); + fDileptonCut.ApplyPhiV(dileptoncuts.cfg_apply_phiv); + fDileptonCut.RequireITSibAny(dileptoncuts.cfg_require_itsib_any); + fDileptonCut.RequireITSib1st(dileptoncuts.cfg_require_itsib_1st); + + // for track + fDileptonCut.SetTrackPtRange(dileptoncuts.cfg_min_pt_track, 1e+10f); + fDileptonCut.SetTrackEtaRange(-dileptoncuts.cfg_max_eta_track, +dileptoncuts.cfg_max_eta_track); + fDileptonCut.SetMinNClustersTPC(dileptoncuts.cfg_min_ncluster_tpc); + fDileptonCut.SetMinNCrossedRowsTPC(dileptoncuts.cfg_min_ncrossedrows); + fDileptonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fDileptonCut.SetMaxFracSharedClustersTPC(dileptoncuts.cfg_max_frac_shared_clusters_tpc); + fDileptonCut.SetChi2PerClusterTPC(0.0, dileptoncuts.cfg_max_chi2tpc); + fDileptonCut.SetChi2PerClusterITS(0.0, dileptoncuts.cfg_max_chi2its); + fDileptonCut.SetNClustersITS(dileptoncuts.cfg_min_ncluster_its, 7); + fDileptonCut.SetMaxDcaXY(dileptoncuts.cfg_max_dcaxy); + fDileptonCut.SetMaxDcaZ(dileptoncuts.cfg_max_dcaz); + fDileptonCut.SetTrackDca3DRange(0.f, dileptoncuts.cfg_max_dca3dsigma_track); // in sigma + fDileptonCut.IncludeITSsa(false, 0.15); + + // for eID + fDileptonCut.SetPIDScheme(dileptoncuts.cfg_pid_scheme); + fDileptonCut.SetTPCNsigmaElRange(dileptoncuts.cfg_min_TPCNsigmaEl, dileptoncuts.cfg_max_TPCNsigmaEl); + fDileptonCut.SetTPCNsigmaPiRange(dileptoncuts.cfg_min_TPCNsigmaPi, dileptoncuts.cfg_max_TPCNsigmaPi); + fDileptonCut.SetTOFNsigmaElRange(dileptoncuts.cfg_min_TOFNsigmaEl, dileptoncuts.cfg_max_TOFNsigmaEl); + } + + void DefineEMTrackCut() + { + fEMTrackCut = EMTrackCut("fEMTrackCut", "fEMTrackCut"); + fEMTrackCut.SetTrackPtRange(trackcuts.cfg_min_pt_track, trackcuts.cfg_max_pt_track); + fEMTrackCut.SetTrackEtaRange(trackcuts.cfg_min_eta_track, trackcuts.cfg_max_eta_track); + fEMTrackCut.SetTrackPhiRange(trackcuts.cfg_min_phi_track, trackcuts.cfg_max_phi_track); + fEMTrackCut.SetTrackMaxDcaXY(trackcuts.cfg_max_dcaxy); + fEMTrackCut.SetTrackMaxDcaZ(trackcuts.cfg_max_dcaz); + fEMTrackCut.SetTrackBit(trackcuts.cfg_track_bits); + // fEMTrackCut.SetMinNClustersTPC(trackcuts.cfg_min_ncluster_tpc); + // fEMTrackCut.SetMinNCrossedRowsTPC(trackcuts.cfg_min_ncrossedrows); + // fEMTrackCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + // fEMTrackCut.SetMaxFracSharedClustersTPC(trackcuts.cfg_max_frac_shared_clusters_tpc); + // fEMTrackCut.SetChi2PerClusterTPC(0.0, trackcuts.cfg_max_chi2tpc); + // fEMTrackCut.SetChi2PerClusterITS(0.0, trackcuts.cfg_max_chi2its); + // fEMTrackCut.SetNClustersITS(trackcuts.cfg_min_ncluster_its, 7); + // fEMTrackCut.RequireITSibAny(trackcuts.cfg_require_itsib_any); + // fEMTrackCut.RequireITSib1st(trackcuts.cfg_require_itsib_1st); + } + + SliceCache cache; + Preslice perCollision_pcm = aod::v0photonkf::emeventId; + Preslice perCollision_track = aod::emprimarytrack::emeventId; + + Preslice perCollision_electron = aod::emprimaryelectron::emeventId; + Partition positrons = o2::aod::emprimaryelectron::sign > int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt&& nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl&& o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); + Partition electrons = o2::aod::emprimaryelectron::sign < int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt && nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); + + using MyEMH = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrack>; + MyEMH* emh1 = nullptr; + MyEMH* emh2 = nullptr; + using MyEMH_track = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrack>; // for charged track + MyEMH_track* emh_diphoton = nullptr; + MyEMH_track* emh_ref = nullptr; + + std::vector> used_photonIds; // + std::vector> used_dileptonIds; // + std::vector> used_refTrackIds; // + std::vector> used_diphotonIds; // + std::map, uint64_t> map_mixed_eventId_to_globalBC; + + template + void run2PC(TCollisions const& collisions, + TPhotons1 const& photons1, TPhotons2 const& photons2, TSubInfos1 const&, TSubInfos2 const&, TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, TCut1 const& cut1, TCut2 const& cut2, + TRefTracks const& refTracks) + { + for (const auto& collision : collisions) { + initCCDB(collision); + int ndiphoton = 0; + + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + if constexpr (isTriggerAnalysis) { + if (!collision.swtalias_bit(o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value))) { + continue; + } + } + + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, 1.f); + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) { + continue; + } + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, 1.f); + fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, 1.f); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, 1.f); // accepted + + int zbin = lower_bound(zvtx_bin_edges.begin(), zvtx_bin_edges.end(), collision.posZ()) - zvtx_bin_edges.begin() - 1; + if (zbin < 0) { + zbin = 0; + } else if (static_cast(zvtx_bin_edges.size()) - 2 < zbin) { + zbin = static_cast(zvtx_bin_edges.size()) - 2; + } + + float centrality = centralities[cfgCentEstimator]; + int centbin = lower_bound(cent_bin_edges.begin(), cent_bin_edges.end(), centrality) - cent_bin_edges.begin() - 1; + if (centbin < 0) { + centbin = 0; + } else if (static_cast(cent_bin_edges.size()) - 2 < centbin) { + centbin = static_cast(cent_bin_edges.size()) - 2; + } + + int epbin = 0; + + int occbin = -1; + if (cfgOccupancyEstimator == 0) { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.ft0cOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } else if (cfgOccupancyEstimator == 1) { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.trackOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } else { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.ft0cOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } + + if (occbin < 0) { + occbin = 0; + } else if (static_cast(occ_bin_edges.size()) - 2 < occbin) { + occbin = static_cast(occ_bin_edges.size()) - 2; + } + + // LOGF(info, "collision.globalIndex() = %d, collision.posZ() = %f, centrality = %f, ep2 = %f, collision.trackOccupancyInTimeRange() = %d, zbin = %d, centbin = %d, epbin = %d, occbin = %d", collision.globalIndex(), collision.posZ(), centrality, ep2, collision.trackOccupancyInTimeRange(), zbin, centbin, epbin, occbin); + + auto refTracks_per_collision = refTracks.sliceBy(perCollision_track, collision.globalIndex()); + for (const auto& track : refTracks_per_collision) { + if (fEMTrackCut.IsSelected(track)) { + fRegistry.fill(HIST("Hadron/hs"), track.pt(), track.eta(), track.phi()); + } + } + + std::tuple key_bin = std::make_tuple(zbin, centbin, epbin, occbin); + std::pair key_df_collision = std::make_pair(ndf, collision.globalIndex()); + + if constexpr (pairtype == PairType::kPCMPCM) { // same kinds pairing + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); + auto photons2_per_collision = photons2.sliceBy(perCollision2, collision.globalIndex()); + + for (const auto& [g1, g2] : combinations(CombinationsStrictlyUpperIndexPolicy(photons1_per_collision, photons2_per_collision))) { + if (!cut1.template IsSelected(g1) || !cut2.template IsSelected(g2)) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + if (std::fabs(v12.Rapidity()) > maxY) { + continue; + } + fRegistry.fill(HIST("Diphoton/same/hs"), v12.M(), v12.Pt()); + auto pos1 = g1.template posTrack_as(); + auto ele1 = g1.template negTrack_as(); + auto pos2 = g2.template posTrack_as(); + auto ele2 = g2.template negTrack_as(); + + int npair = 0; + for (const auto& track : refTracks_per_collision) { + if (pos1.trackId() == track.trackId() || ele1.trackId() == track.trackId()) { + continue; + } + if (pos2.trackId() == track.trackId() || ele2.trackId() == track.trackId()) { + continue; + } + + if (fEMTrackCut.IsSelected(track)) { + ROOT::Math::PtEtaPhiMVector v3(track.pt(), track.eta(), track.phi(), 0.139); + float deta = v12.Eta() - v3.Eta(); + float dphi = v12.Phi() - v3.Phi(); + // o2::math_utils::bringTo02Pi(dphi); + dphi = RecoDecay::constrainAngle(dphi, -M_PI / 2, 1U); + fRegistry.fill(HIST("DiphotonHadron/same/hs"), v12.M(), v12.Pt(), v3.Pt(), deta, dphi); + npair++; + std::pair pair_tmp_ref = std::make_pair(ndf, track.globalIndex()); + if (std::find(used_refTrackIds.begin(), used_refTrackIds.end(), pair_tmp_ref) == used_refTrackIds.end()) { // add a ref track in mixing pool + emh_ref->AddTrackToEventPool(key_df_collision, EMTrack(ndf, track.globalIndex(), collision.globalIndex(), track.globalIndex(), track.pt(), track.eta(), track.phi(), 0.139)); + used_refTrackIds.emplace_back(pair_tmp_ref); + } + } + } // end of ref track loop + + if (npair > 0) { + std::tuple tuple_tmp_diphoton = std::make_tuple(ndf, g1.globalIndex(), g2.globalIndex(), -1); + if (std::find(used_diphotonIds.begin(), used_diphotonIds.end(), tuple_tmp_diphoton) == used_diphotonIds.end()) { + emh_diphoton->AddTrackToEventPool(key_df_collision, EMTrack(ndf, -1, collision.globalIndex(), -1, v12.Pt(), v12.Eta(), v12.Phi(), v12.M())); + used_diphotonIds.emplace_back(tuple_tmp_diphoton); + } + } + + std::pair pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex()); + std::pair pair_tmp_id2 = std::make_pair(ndf, g2.globalIndex()); + if (std::find(used_photonIds.begin(), used_photonIds.end(), pair_tmp_id1) == used_photonIds.end()) { + emh1->AddTrackToEventPool(key_df_collision, EMTrack(ndf, g1.globalIndex(), collision.globalIndex(), g1.globalIndex(), g1.pt(), g1.eta(), g1.phi(), 0)); + used_photonIds.emplace_back(pair_tmp_id1); + } + if (std::find(used_photonIds.begin(), used_photonIds.end(), pair_tmp_id2) == used_photonIds.end()) { + emh1->AddTrackToEventPool(key_df_collision, EMTrack(ndf, g2.globalIndex(), collision.globalIndex(), g2.globalIndex(), g2.pt(), g2.eta(), g2.phi(), 0)); + used_photonIds.emplace_back(pair_tmp_id2); + } + ndiphoton++; + } // end of pairing loop + } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); + auto positrons_per_collision = positrons->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + auto electrons_per_collision = electrons->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + + for (const auto& g1 : photons1_per_collision) { + if (!cut1.template IsSelected(g1)) { + continue; + } + auto pos1 = g1.template posTrack_as(); + auto ele1 = g1.template negTrack_as(); + ROOT::Math::PtEtaPhiMVector v_gamma(g1.pt(), g1.eta(), g1.phi(), 0.); + + for (const auto& [pos2, ele2] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) { + + if (pos2.trackId() == ele2.trackId()) { // this is protection against pairing identical 2 tracks. + continue; + } + if (pos1.trackId() == pos2.trackId() || ele1.trackId() == ele2.trackId()) { + continue; + } + + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + continue; + } + + if (!cut2.IsSelectedPair(pos2, ele2, d_bz)) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v_pos(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ele(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ee = v_pos + v_ele; + ROOT::Math::PtEtaPhiMVector veeg = v_gamma + v_pos + v_ele; + if (std::fabs(veeg.Rapidity()) > maxY) { + continue; + } + fRegistry.fill(HIST("Diphoton/same/hs"), veeg.M(), veeg.Pt()); + + int npair = 0; + for (const auto& track : refTracks_per_collision) { + if (pos1.trackId() == track.trackId() || ele1.trackId() == track.trackId()) { + continue; + } + if (pos2.trackId() == track.trackId() || ele2.trackId() == track.trackId()) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v3(track.pt(), track.eta(), track.phi(), 0.139); + float deta = veeg.Eta() - v3.Eta(); + float dphi = veeg.Phi() - v3.Phi(); + // o2::math_utils::bringTo02Pi(dphi); + dphi = RecoDecay::constrainAngle(dphi, -M_PI / 2, 1U); + fRegistry.fill(HIST("DiphotonHadron/same/hs"), veeg.M(), veeg.Pt(), v3.Pt(), deta, dphi); + npair++; + + std::pair pair_tmp_ref = std::make_pair(ndf, track.globalIndex()); + if (std::find(used_refTrackIds.begin(), used_refTrackIds.end(), pair_tmp_ref) == used_refTrackIds.end()) { // add a ref track in mixing pool + emh_ref->AddTrackToEventPool(key_df_collision, EMTrack(ndf, track.globalIndex(), collision.globalIndex(), track.globalIndex(), track.pt(), track.eta(), track.phi(), 0.139)); + used_refTrackIds.emplace_back(pair_tmp_ref); + } + } // end of ref track loop + + if (npair > 0) { + std::tuple tuple_tmp_diphoton = std::make_tuple(ndf, g1.globalIndex(), pos2.trackId(), ele2.trackId()); + if (std::find(used_diphotonIds.begin(), used_diphotonIds.end(), tuple_tmp_diphoton) == used_diphotonIds.end()) { + emh_diphoton->AddTrackToEventPool(key_df_collision, EMTrack(ndf, -1, collision.globalIndex(), -1, veeg.Pt(), veeg.Eta(), veeg.Phi(), veeg.M())); + used_diphotonIds.emplace_back(tuple_tmp_diphoton); + } + } + + std::pair pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex()); + std::tuple tuple_tmp_id2 = std::make_tuple(ndf, collision.globalIndex(), pos2.trackId(), ele2.trackId()); + if (std::find(used_photonIds.begin(), used_photonIds.end(), pair_tmp_id1) == used_photonIds.end()) { + emh1->AddTrackToEventPool(key_df_collision, EMTrack(ndf, g1.globalIndex(), collision.globalIndex(), -1, g1.pt(), g1.eta(), g1.phi(), 0)); + used_photonIds.emplace_back(pair_tmp_id1); + } + if (std::find(used_dileptonIds.begin(), used_dileptonIds.end(), tuple_tmp_id2) == used_dileptonIds.end()) { + emh2->AddTrackToEventPool(key_df_collision, EMTrack(ndf, -1, collision.globalIndex(), -1, v_ee.Pt(), v_ee.Eta(), v_ee.Phi(), v_ee.M())); + used_dileptonIds.emplace_back(tuple_tmp_id2); + } + ndiphoton++; + } // end of dielectron loop + } // end of g1 loop + } // end of pairing in same event + + if (ndiphoton > 0) { + for (const auto& [ref1, ref2] : combinations(CombinationsStrictlyUpperIndexPolicy(refTracks_per_collision, refTracks_per_collision))) { + if (fEMTrackCut.IsSelected(ref1) && fEMTrackCut.IsSelected(ref2)) { + float deta = ref1.eta() - ref2.eta(); + float dphi = ref1.phi() - ref2.phi(); + // o2::math_utils::bringTo02Pi(dphi); + dphi = RecoDecay::constrainAngle(dphi, -M_PI / 2, 1U); + fRegistry.fill(HIST("HadronHadron/same/hs"), ref1.pt(), ref2.pt(), deta, dphi); + } + } + } + + // event mixing + if (!cfgDoMix || !(ndiphoton > 0)) { + continue; + } + + // make a vector of selected photons in this collision. + auto selected_photons1_in_this_event = emh1->GetTracksPerCollision(key_df_collision); + auto selected_photons2_in_this_event = emh2->GetTracksPerCollision(key_df_collision); + auto selected_refTracks_in_this_event = emh_ref->GetTracksPerCollision(key_df_collision); + auto selected_diphotons_in_this_event = emh_diphoton->GetTracksPerCollision(key_df_collision); + + auto collisionIds1_in_mixing_pool = emh1->GetCollisionIdsFromEventPool(key_bin); + auto collisionIds2_in_mixing_pool = emh2->GetCollisionIdsFromEventPool(key_bin); + auto collisionIdsRef_in_mixing_pool = emh_ref->GetCollisionIdsFromEventPool(key_bin); + auto collisionIdsDiphoton_in_mixing_pool = emh_diphoton->GetCollisionIdsFromEventPool(key_bin); + + if constexpr (pairtype == PairType::kPCMPCM) { // same kinds pairing + for (const auto& mix_dfId_collisionId : collisionIds1_in_mixing_pool) { + int mix_dfId = mix_dfId_collisionId.first; + int64_t mix_collisionId = mix_dfId_collisionId.second; + + if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. + continue; + } + + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + fRegistry.fill(HIST("Diphoton/mix/hDiffBC"), diffBC); + if (diffBC < ndiff_bc_mix) { + continue; + } + + auto photons1_from_event_pool = emh1->GetTracksPerCollision(mix_dfId_collisionId); + // LOGF(info, "Do event mixing: current event (%d, %d), ngamma = %d | event pool (%d, %d), ngamma = %d", ndf, collision.globalIndex(), selected_photons1_in_this_event.size(), mix_dfId, mix_collisionId, photons1_from_event_pool.size()); + + for (const auto& g1 : selected_photons1_in_this_event) { + for (const auto& g2 : photons1_from_event_pool) { + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + if (std::fabs(v12.Rapidity()) > maxY) { + continue; + } + fRegistry.fill(HIST("Diphoton/mix/hs"), v12.M(), v12.Pt(), 1.f); + } + } + } // end of loop over mixed event pool between photon-photon + + for (const auto& mix_dfId_collisionId : collisionIdsRef_in_mixing_pool) { + int mix_dfId = mix_dfId_collisionId.first; + int64_t mix_collisionId = mix_dfId_collisionId.second; + + if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. + continue; + } + + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + if (diffBC < ndiff_bc_mix) { + continue; + } + + auto refTracks_from_event_pool = emh_ref->GetTracksPerCollision(mix_dfId_collisionId); + for (const auto& trg : selected_diphotons_in_this_event) { + for (const auto& ref : refTracks_from_event_pool) { + float deta = trg.eta() - ref.eta(); + float dphi = trg.phi() - ref.phi(); + // o2::math_utils::bringTo02Pi(dphi); + dphi = RecoDecay::constrainAngle(dphi, -M_PI / 2, 1U); + fRegistry.fill(HIST("DiphotonHadron/mix/hs"), trg.mass(), trg.pt(), ref.pt(), deta, dphi); + } + } + } // end of loop over mixed event pool between diphoton-hadron + + } else { // [photon1 from event1, photon2 from event2] and [photon1 from event2, photon2 from event1] + for (const auto& mix_dfId_collisionId : collisionIds2_in_mixing_pool) { + int mix_dfId = mix_dfId_collisionId.first; + int64_t mix_collisionId = mix_dfId_collisionId.second; + + if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. + continue; + } + + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + fRegistry.fill(HIST("Diphoton/mix/hDiffBC"), diffBC); + if (diffBC < ndiff_bc_mix) { + continue; + } + + auto photons2_from_event_pool = emh2->GetTracksPerCollision(mix_dfId_collisionId); + // LOGF(info, "Do event mixing: current event (%d, %d), ngamma = %d | event pool (%d, %d), nll = %d", ndf, collision.globalIndex(), selected_photons1_in_this_event.size(), mix_dfId, mix_collisionId, photons2_from_event_pool.size()); + + for (const auto& g1 : selected_photons1_in_this_event) { + for (const auto& g2 : photons2_from_event_pool) { + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + if constexpr (pairtype == PairType::kPCMDalitzEE) { //[photon from event1, dilepton from event2] and [photon from event2, dilepton from event1] + v2.SetM(g2.mass()); + } + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + if (std::fabs(v12.Rapidity()) > maxY) { + continue; + } + fRegistry.fill(HIST("Diphoton/mix/hs"), v12.M(), v12.Pt(), 1.f); + } + } + } // end of loop over mixed event pool between photon-photon + + for (const auto& mix_dfId_collisionId : collisionIds1_in_mixing_pool) { + int mix_dfId = mix_dfId_collisionId.first; + int64_t mix_collisionId = mix_dfId_collisionId.second; + + if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. + continue; + } + + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + fRegistry.fill(HIST("Diphoton/mix/hDiffBC"), diffBC); + if (diffBC < ndiff_bc_mix) { + continue; + } + + auto photons1_from_event_pool = emh1->GetTracksPerCollision(mix_dfId_collisionId); + // LOGF(info, "Do event mixing: current event (%d, %d), nll = %d | event pool (%d, %d), ngamma = %d", ndf, collision.globalIndex(), selected_photons2_in_this_event.size(), mix_dfId, mix_collisionId, photons1_from_event_pool.size()); + + for (const auto& g1 : selected_photons2_in_this_event) { + for (const auto& g2 : photons1_from_event_pool) { + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + if constexpr (pairtype == PairType::kPCMDalitzEE) { //[photon from event1, dilepton from event2] and [photon from event2, dilepton from event1] + v1.SetM(g1.mass()); + } + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + if (std::fabs(v12.Rapidity()) > maxY) { + continue; + } + fRegistry.fill(HIST("Diphoton/mix/hs"), v12.M(), v12.Pt(), 1.f); + } + } + } // end of loop over mixed event pool between photon-photon + + for (const auto& mix_dfId_collisionId : collisionIdsRef_in_mixing_pool) { + int mix_dfId = mix_dfId_collisionId.first; + int64_t mix_collisionId = mix_dfId_collisionId.second; + + if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. + continue; + } + + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + if (diffBC < ndiff_bc_mix) { + continue; + } + + auto refTracks_from_event_pool = emh_ref->GetTracksPerCollision(mix_dfId_collisionId); + for (const auto& trg : selected_diphotons_in_this_event) { + for (const auto& ref : refTracks_from_event_pool) { + float deta = trg.eta() - ref.eta(); + float dphi = trg.phi() - ref.phi(); + // o2::math_utils::bringTo02Pi(dphi); + dphi = RecoDecay::constrainAngle(dphi, -M_PI / 2, 1U); + fRegistry.fill(HIST("DiphotonHadron/mix/hs"), trg.mass(), trg.pt(), ref.pt(), deta, dphi); + } + } + } // end of loop over mixed event pool between diphoton-hadron + } + + // hadron-hadron mixed event + for (const auto& mix_dfId_collisionId : collisionIdsRef_in_mixing_pool) { + int mix_dfId = mix_dfId_collisionId.first; + int64_t mix_collisionId = mix_dfId_collisionId.second; + + if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. + continue; + } + + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + if (diffBC < ndiff_bc_mix) { + continue; + } + + auto refTracks_from_event_pool = emh_ref->GetTracksPerCollision(mix_dfId_collisionId); + for (const auto& ref1 : selected_refTracks_in_this_event) { + for (const auto& ref2 : refTracks_from_event_pool) { + float deta = ref1.eta() - ref2.eta(); + float dphi = ref1.phi() - ref2.phi(); + // o2::math_utils::bringTo02Pi(dphi); + dphi = RecoDecay::constrainAngle(dphi, -M_PI / 2, 1U); + fRegistry.fill(HIST("HadronHadron/mix/hs"), ref1.pt(), ref2.pt(), deta, dphi); + } + } + } // end of loop over mixed event pool between hadron-hadron + + if (ndiphoton > 0) { + emh1->AddCollisionIdAtLast(key_bin, key_df_collision); + emh2->AddCollisionIdAtLast(key_bin, key_df_collision); + emh_diphoton->AddCollisionIdAtLast(key_bin, key_df_collision); + emh_ref->AddCollisionIdAtLast(key_bin, key_df_collision); + map_mixed_eventId_to_globalBC[key_df_collision] = collision.globalBC(); + } + + } // end of collision loop + } + + Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); + using FilteredMyCollisions = soa::Filtered; + + Filter prefilter_pcm = ifnode(pcmcuts.cfg_apply_cuts_from_prefilter_derived.node(), o2::aod::v0photonkf::pfbderived == static_cast(0), true); + Filter prefilter_primaryelectron = ifnode(dileptoncuts.cfg_apply_cuts_from_prefilter_derived.node(), o2::aod::emprimaryelectron::pfbderived == static_cast(0), true); + + int ndf = 0; + void processAnalysis(FilteredMyCollisions const& collisions, MyTracks const& refTracks, Types const&... args) + { + // LOGF(info, "ndf = %d", ndf); + if constexpr (pairtype == PairType::kPCMPCM) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + run2PC(collisions, v0photons, v0photons, v0legs, v0legs, perCollision_pcm, perCollision_pcm, fV0PhotonCut, fV0PhotonCut, refTracks); + } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + auto emprimaryelectrons = std::get<2>(std::tie(args...)); + // LOGF(info, "electrons.size() = %d, positrons.size() = %d", electrons.size(), positrons.size()); + run2PC(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDileptonCut, refTracks); + } + ndf++; + } + PROCESS_SWITCH(DiphotonHadronMPC, processAnalysis, "process pair analysis", true); + + using FilteredMyCollisionsWithSWT = soa::Filtered; + void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, MyTracks const& refTracks, Types const&... args) + { + // LOGF(info, "ndf = %d", ndf); + if constexpr (pairtype == PairType::kPCMPCM) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + run2PC(collisions, v0photons, v0photons, v0legs, v0legs, perCollision_pcm, perCollision_pcm, fV0PhotonCut, fV0PhotonCut, refTracks); + } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + auto emprimaryelectrons = std::get<2>(std::tie(args...)); + // LOGF(info, "electrons.size() = %d, positrons.size() = %d", electrons.size(), positrons.size()); + run2PC(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDileptonCut, refTracks); + } + ndf++; + } + PROCESS_SWITCH(DiphotonHadronMPC, processTriggerAnalysis, "process pair analysis with software trigger", false); + + void processDummy(MyCollisions const&) {} + PROCESS_SWITCH(DiphotonHadronMPC, processDummy, "Dummy function", false); +}; +#endif // PWGEM_PHOTONMESON_CORE_DIPHOTONHADRONMPC_H_ diff --git a/PWGEM/PhotonMeson/Core/EMCPhotonCut.cxx b/PWGEM/PhotonMeson/Core/EMCPhotonCut.cxx index 582b9754057..199da171c11 100644 --- a/PWGEM/PhotonMeson/Core/EMCPhotonCut.cxx +++ b/PWGEM/PhotonMeson/Core/EMCPhotonCut.cxx @@ -13,11 +13,17 @@ // Class for EMCal cluster selection // -#include -#include "Framework/Logger.h" #include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" + #include "PWGJE/DataModel/EMCALClusters.h" +#include "Framework/Logger.h" + +#include + +#include +#include + ClassImp(EMCPhotonCut); const char* EMCPhotonCut::mCutNames[static_cast(EMCPhotonCut::EMCPhotonCuts::kNCuts)] = {"Definition", "Energy", "NCell", "M02", "Timing", "TrackMatching", "Exotic"}; diff --git a/PWGEM/PhotonMeson/Core/EMCPhotonCut.h b/PWGEM/PhotonMeson/Core/EMCPhotonCut.h index 8bfd8ca630f..1e3ac74f6cd 100644 --- a/PWGEM/PhotonMeson/Core/EMCPhotonCut.h +++ b/PWGEM/PhotonMeson/Core/EMCPhotonCut.h @@ -9,22 +9,19 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// -// Class for emcal photon selection -// +/// \file EMCPhotonCut.h +/// \brief Header of class for emcal photon selection. +/// \author M. Hemmer, marvin.hemmer@cern.ch; N. Strangmann, nicolas.strangmann@cern.ch #ifndef PWGEM_PHOTONMESON_CORE_EMCPHOTONCUT_H_ #define PWGEM_PHOTONMESON_CORE_EMCPHOTONCUT_H_ -#include -#include -#include +#include + +#include + +#include #include -#include -#include "Framework/Logger.h" -#include "Framework/DataTypes.h" -#include "Rtypes.h" -#include "TNamed.h" class EMCPhotonCut : public TNamed { @@ -95,14 +92,14 @@ class EMCPhotonCut : public TNamed return mMinTime <= cluster.time() && cluster.time() <= mMaxTime; case EMCPhotonCuts::kTM: { - auto trackseta = cluster.tracketa(); // std:vector - auto tracksphi = cluster.trackphi(); // std:vector - auto trackspt = cluster.trackpt(); // std:vector - auto tracksp = cluster.trackp(); // std:vector + auto dEtas = cluster.deltaEta(); // std:vector + auto dPhis = cluster.deltaPhi(); // std:vector + auto trackspt = cluster.trackpt(); // std:vector + auto tracksp = cluster.trackp(); // std:vector int ntrack = tracksp.size(); for (int itr = 0; itr < ntrack; itr++) { - float dEta = fabs(trackseta[itr] - cluster.eta()); - float dPhi = fabs(tracksphi[itr] - cluster.phi()); + float dEta = std::fabs(dEtas[itr]); + float dPhi = std::fabs(dPhis[itr]); bool result = (dEta > mTrackMatchingEta(trackspt[itr])) || (dPhi > mTrackMatchingPhi(trackspt[itr])) || (cluster.e() / tracksp[itr] >= mMinEoverP); if (!result) { return false; diff --git a/PWGEM/PhotonMeson/Core/HistogramsLibrary.cxx b/PWGEM/PhotonMeson/Core/HistogramsLibrary.cxx index 50174ab9e08..e54a462e9dc 100644 --- a/PWGEM/PhotonMeson/Core/HistogramsLibrary.cxx +++ b/PWGEM/PhotonMeson/Core/HistogramsLibrary.cxx @@ -9,28 +9,25 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // -// Contact: daiki.sekihata@cern.ch -// -#include -#include -#include -using namespace std; +/// \file HistogramsLibrary.cxx +/// \brief Small histogram library for photon and meson analysis. +/// \author D. Sekihata, daiki.sekihata@cern.ch + +#include "PWGEM/PhotonMeson/Core/HistogramsLibrary.h" + +#include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include "Framework/Logger.h" -#include "PWGEM/PhotonMeson/Core/HistogramsLibrary.h" +#include + +#include + +#include + +using namespace std; void o2::aod::pwgem::photon::histogram::DefineHistograms(THashList* list, const char* histClass, const char* subGroup) { @@ -184,7 +181,7 @@ void o2::aod::pwgem::photon::histogram::DefineHistograms(THashList* list, const list->Add(new TH2F("hEtaRec_DeltaEta", "photon #eta resolution;#eta^{rec} of conversion point;#eta^{rec} - #eta^{gen}", 400, -2, +2, 400, -1.0f, 1.0f)); list->Add(new TH2F("hEtaRec_DeltaPhi", "photon #varphi resolution;#eta^{rec} of conversion point;#varphi^{rec} - #varphi^{gen} (rad.)", 400, -2, +2, 400, -1.0f, 1.0f)); } // end of mc - } // end of V0 + } // end of V0 if (TString(histClass).Contains("Dalitz")) { THnSparseF* hs_dilepton_uls_same = nullptr; @@ -576,7 +573,7 @@ void o2::aod::pwgem::photon::histogram::DefineHistograms(THashList* list, const hs_conv_point_mix->Sumw2(); list->Add(hs_conv_point_mix); } // end of pair - } // end of material budget study + } // end of material budget study if (TString(histClass) == "Generated") { list->Add(new TH1F("hCollisionCounter", "hCollisionCounter", 5, 0.5f, 5.5f)); diff --git a/PWGEM/PhotonMeson/Core/HistogramsLibrary.h b/PWGEM/PhotonMeson/Core/HistogramsLibrary.h index 324718a663e..368acef59ce 100644 --- a/PWGEM/PhotonMeson/Core/HistogramsLibrary.h +++ b/PWGEM/PhotonMeson/Core/HistogramsLibrary.h @@ -8,34 +8,25 @@ // 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. -// -// Contact: daiki.sekihata@cern.ch -// + +/// \file HistogramsLibrary.h +/// \brief Small histogram library for photon and meson analysis. +/// \author D. Sekihata, daiki.sekihata@cern.ch #ifndef PWGEM_PHOTONMESON_CORE_HISTOGRAMSLIBRARY_H_ #define PWGEM_PHOTONMESON_CORE_HISTOGRAMSLIBRARY_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "Common/CCDB/EventSelectionParams.h" #include "Common/Core/RecoDecay.h" +#include +#include +#include + +#include +#include +#include + enum EMHistType { kEvent = 0, kEvent_Cent = 1, @@ -48,6 +39,8 @@ enum EMHistType { kEMCCluster = 8, }; +const float maxZ = 10.f; + namespace o2::aod { namespace pwgem::photon::histogram @@ -81,7 +74,7 @@ void FillHistClass(THashList* list, const char* subGroup, T1 const& obj1 /*, con if (obj1.sel8()) { reinterpret_cast(list->FindObject("hCollisionCounter"))->Fill("sel8", 1.f); } - if (abs(obj1.posZ()) < 10.0) { + if (std::abs(obj1.posZ()) < maxZ) { reinterpret_cast(list->FindObject("hCollisionCounter"))->Fill("|Z_{vtx}| < 10 cm", 1.f); } @@ -176,9 +169,9 @@ void FillHistClass(THashList* list, const char* subGroup, T1 const& obj1 /*, con reinterpret_cast(list->FindObject("hQoverPt"))->Fill(obj1.sign() / obj1.pt()); reinterpret_cast(list->FindObject("hEtaPhi"))->Fill(obj1.phi(), obj1.eta()); reinterpret_cast(list->FindObject("hDCAxyz"))->Fill(obj1.dcaXY(), obj1.dcaZ()); - reinterpret_cast(list->FindObject("hDCAxyzSigma"))->Fill(obj1.dcaXY() / sqrt(obj1.cYY()), obj1.dcaZ() / sqrt(obj1.cZZ())); - reinterpret_cast(list->FindObject("hDCAxyRes_Pt"))->Fill(obj1.pt(), sqrt(obj1.cYY()) * 1e+4); // convert cm to um - reinterpret_cast(list->FindObject("hDCAzRes_Pt"))->Fill(obj1.pt(), sqrt(obj1.cZZ()) * 1e+4); // convert cm to um + reinterpret_cast(list->FindObject("hDCAxyzSigma"))->Fill(obj1.dcaXY() / std::sqrt(obj1.cYY()), obj1.dcaZ() / std::sqrt(obj1.cZZ())); + reinterpret_cast(list->FindObject("hDCAxyRes_Pt"))->Fill(obj1.pt(), std::sqrt(obj1.cYY()) * 1e+4); // convert cm to um + reinterpret_cast(list->FindObject("hDCAzRes_Pt"))->Fill(obj1.pt(), std::sqrt(obj1.cZZ()) * 1e+4); // convert cm to um reinterpret_cast(list->FindObject("hNclsITS"))->Fill(obj1.itsNCls()); reinterpret_cast(list->FindObject("hNclsTPC"))->Fill(obj1.tpcNClsFound()); reinterpret_cast(list->FindObject("hNcrTPC"))->Fill(obj1.tpcNClsCrossedRows()); @@ -225,8 +218,8 @@ void FillHistClass(THashList* list, const char* subGroup, T1 const& obj1 /*, con reinterpret_cast(list->FindObject("hPt"))->Fill(obj1.pt()); reinterpret_cast(list->FindObject("hE"))->Fill(obj1.e()); reinterpret_cast(list->FindObject("hEtaPhi"))->Fill(obj1.phi(), obj1.eta()); - for (size_t itrack = 0; itrack < obj1.tracketa().size(); itrack++) { // Fill TrackEtaPhi histogram with delta phi and delta eta of all tracks saved in the vectors in skimmerGammaCalo.cxx - reinterpret_cast(list->FindObject("hTrackEtaPhi"))->Fill(obj1.trackphi()[itrack] - obj1.phi(), obj1.tracketa()[itrack] - obj1.eta()); + for (size_t itrack = 0; itrack < obj1.deltaEta().size(); itrack++) { // Fill TrackEtaPhi histogram with delta phi and delta eta of all tracks saved in the vectors in skimmerGammaCalo.cxx + reinterpret_cast(list->FindObject("hTrackEtaPhi"))->Fill(obj1.deltaPhi()[itrack], obj1.deltaEta()[itrack]); } } } diff --git a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h index 4520198ed2a..3a1b99b4ed8 100644 --- a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h +++ b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h @@ -19,45 +19,47 @@ #ifndef PWGEM_PHOTONMESON_CORE_PI0ETATOGAMMAGAMMA_H_ #define PWGEM_PHOTONMESON_CORE_PI0ETATOGAMMAGAMMA_H_ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Math/Vector3D.h" -#include "Math/LorentzRotation.h" -#include "Math/Rotation3D.h" -#include "Math/AxisAngle.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" - -#include "DetectorsBase/GeometryManager.h" -#include "EMCALBase/Geometry.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" - -#include "Common/Core/RecoDecay.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/Dilepton/Utils/EMTrack.h" +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/EventMixingHandler.h" #include "PWGEM/PhotonMeson/Core/DalitzEECut.h" -#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" #include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" #include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" -#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" -#include "PWGEM/Dilepton/Utils/EMTrack.h" -#include "PWGEM/Dilepton/Utils/EventMixingHandler.h" +#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/PhotonMeson/Utils/EventHistograms.h" #include "PWGEM/PhotonMeson/Utils/NMHistograms.h" -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" + +#include "Common/Core/RecoDecay.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "EMCALBase/Geometry.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/AxisAngle.h" +#include "Math/LorentzRotation.h" +#include "Math/Rotation3D.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TString.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -69,13 +71,16 @@ using namespace o2::aod::pwgem::photon; using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; using namespace o2::aod::pwgem::dilepton::utils; -using MyCollisions = soa::Join; +using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; -using MyV0Photons = soa::Join; +using MyCollisionsWithJJMC = soa::Join; +using MyCollisionWithJJMC = MyCollisionsWithJJMC::iterator; + +using MyV0Photons = soa::Filtered>; using MyV0Photon = MyV0Photons::iterator; -using MyPrimaryElectrons = soa::Join; +using MyPrimaryElectrons = soa::Filtered>; using MyPrimaryElectron = MyPrimaryElectrons::iterator; using MyEMCClusters = soa::Join; @@ -91,9 +96,11 @@ struct Pi0EtaToGammaGamma { Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; + Configurable ndiff_bc_mix{"ndiff_bc_mix", 198, "difference in global BC required in mixed events"}; Configurable cfgQvecEstimator{"cfgQvecEstimator", 0, "FT0M:0, FT0A:1, FT0C:2"}; Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgOccupancyEstimator{"cfgOccupancyEstimator", 0, "FT0C:0, Track:1"}; Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; Configurable cfgCentMax{"cfgCentMax", 999, "max. centrality"}; Configurable maxY{"maxY", 0.8, "maximum rapidity for reconstructed particles"}; @@ -117,8 +124,10 @@ struct Pi0EtaToGammaGamma { Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; Configurable cfgRequireEMCReadoutInMB{"cfgRequireEMCReadoutInMB", false, "require the EMC to be read out in an MB collision (kTVXinEMC)"}; Configurable cfgRequireEMCHardwareTriggered{"cfgRequireEMCHardwareTriggered", false, "require the EMC to be hardware triggered (kEMC7 or kDMC7)"}; - Configurable cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; Configurable onlyKeepWeightedEvents{"onlyKeepWeightedEvents", false, "flag to keep only weighted events (for JJ MCs) and remove all MB events (with weight = 1)"}; } eventcuts; @@ -128,25 +137,30 @@ struct Pi0EtaToGammaGamma { Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; - Configurable cfg_require_v0_on_wwire_ib{"cfg_require_v0_on_wwire_ib", false, "flag to select V0s on W wires ITSib"}; Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; + Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; + Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.8, "min eta for v0 photons at PV"}; Configurable cfg_max_eta_v0{"cfg_max_eta_v0", 0.8, "max eta for v0 photons at PV"}; Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; - Configurable cfg_min_cospa{"cfg_min_cospa", 0.997, "min V0 CosPA"}; - Configurable cfg_max_pca{"cfg_max_pca", 3.0, "max distance btween 2 legs"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.999, "min V0 CosPA"}; + Configurable cfg_max_pca{"cfg_max_pca", 1.5, "max distance btween 2 legs"}; Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; - Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", true, "flag to select V0s with correct xz"}; + Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", false, "flag to select V0s with correct xz"}; Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; + Configurable cfg_apply_cuts_from_prefilter_derived{"cfg_apply_cuts_from_prefilter_derived", false, "flag to apply prefilter to V0"}; - Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 10, "min ncluster tpc"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; - Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; + Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; } pcmcuts; DalitzEECut fDileptonCut; @@ -155,7 +169,6 @@ struct Pi0EtaToGammaGamma { Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; Configurable cfg_max_mass{"cfg_max_mass", 0.1, "max mass"}; Configurable cfg_apply_phiv{"cfg_apply_phiv", true, "flag to apply phiv cut"}; - Configurable cfg_apply_pf{"cfg_apply_pf", false, "flag to apply phiv prefilter"}; Configurable cfg_require_itsib_any{"cfg_require_itsib_any", false, "flag to require ITS ib any hits"}; Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; Configurable cfg_phiv_slope{"cfg_phiv_slope", 0.0185, "slope for m vs. phiv"}; @@ -167,15 +180,22 @@ struct Pi0EtaToGammaGamma { Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 70, "min ncrossed rows"}; Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; - Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; - Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1.0, "max dca XY for single track in cm"}; - Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.0, "max dca Z for single track in cm"}; - - Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTPConly), "pid scheme [kTPConly : 0]"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.05, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.05, "max dca Z for single track in cm"}; + Configurable cfg_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1.5, "max DCA 3D in sigma"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_apply_cuts_from_prefilter_derived{"cfg_apply_cuts_from_prefilter_derived", false, "flag to apply prefilter to electron"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; + + Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTOFif), "pid scheme [kTOFif : 0, kTPConly : 1]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -3.0, "min. TPC n sigma for pion exclusion"}; - Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -0.0, "min. TPC n sigma for pion exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +0.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; } dileptoncuts; EMCPhotonCut fEMCCut; @@ -228,6 +248,7 @@ struct Pi0EtaToGammaGamma { ep_bin_edges = std::vector(ConfEPBins.value.begin(), ConfEPBins.value.end()); ep_bin_edges.erase(ep_bin_edges.begin()); + LOGF(info, "cfgOccupancyEstimator = %d", cfgOccupancyEstimator.value); occ_bin_edges = std::vector(ConfOccupancyBins.value.begin(), ConfOccupancyBins.value.end()); occ_bin_edges.erase(occ_bin_edges.begin()); @@ -237,8 +258,6 @@ struct Pi0EtaToGammaGamma { o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry); if constexpr (pairtype == PairType::kPCMDalitzEE) { o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, false, "ee#gamma"); - } else if constexpr (pairtype == PairType::kPCMDalitzMuMu) { - o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, false, "#mu#mu#gamma"); } else { o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, false, "#gamma#gamma"); } @@ -252,6 +271,7 @@ struct Pi0EtaToGammaGamma { fRegistry.addClone("Pair/same/", "Pair/rotation/"); emcalGeom = o2::emcal::Geometry::GetInstanceFromRunNumber(300000); } + fRegistry.add("Pair/mix/hDiffBC", "diff. global BC in mixed event;|BC_{current} - BC_{mixed}|", kTH1D, {{10001, -0.5, 10000.5}}, true); mRunNumber = 0; d_bz = 0; @@ -312,6 +332,7 @@ struct Pi0EtaToGammaGamma { used_photonIds.shrink_to_fit(); used_dileptonIds.clear(); used_dileptonIds.shrink_to_fit(); + map_mixed_eventId_to_globalBC.clear(); } void DefineEMEventCut() @@ -334,8 +355,8 @@ struct Pi0EtaToGammaGamma { fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); // for v0 - fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, 1e10f); - fV0PhotonCut.SetV0EtaRange(-pcmcuts.cfg_max_eta_v0, +pcmcuts.cfg_max_eta_v0); + fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, pcmcuts.cfg_max_pt_v0); + fV0PhotonCut.SetV0EtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); fV0PhotonCut.SetMinCosPA(pcmcuts.cfg_min_cospa); fV0PhotonCut.SetMaxPCA(pcmcuts.cfg_max_pca); fV0PhotonCut.SetMaxChi2KF(pcmcuts.cfg_max_chi2kf); @@ -344,43 +365,21 @@ struct Pi0EtaToGammaGamma { fV0PhotonCut.RejectITSib(pcmcuts.cfg_reject_v0_on_itsib); // for track - fV0PhotonCut.SetTrackPtRange(pcmcuts.cfg_min_pt_v0 * 0.5, 1e+10f); - fV0PhotonCut.SetTrackEtaRange(-pcmcuts.cfg_max_eta_v0, +pcmcuts.cfg_max_eta_v0); fV0PhotonCut.SetMinNClustersTPC(pcmcuts.cfg_min_ncluster_tpc); fV0PhotonCut.SetMinNCrossedRowsTPC(pcmcuts.cfg_min_ncrossedrows); fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fV0PhotonCut.SetMaxFracSharedClustersTPC(pcmcuts.cfg_max_frac_shared_clusters_tpc); fV0PhotonCut.SetChi2PerClusterTPC(0.0, pcmcuts.cfg_max_chi2tpc); fV0PhotonCut.SetTPCNsigmaElRange(pcmcuts.cfg_min_TPCNsigmaEl, pcmcuts.cfg_max_TPCNsigmaEl); fV0PhotonCut.SetChi2PerClusterITS(-1e+10, pcmcuts.cfg_max_chi2its); - if (pcmcuts.cfg_reject_v0_on_itsib) { - fV0PhotonCut.SetNClustersITS(2, 4); - } else { - fV0PhotonCut.SetNClustersITS(0, 7); - } + fV0PhotonCut.SetNClustersITS(0, 7); fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); fV0PhotonCut.SetIsWithinBeamPipe(pcmcuts.cfg_require_v0_with_correct_xz); - - if (pcmcuts.cfg_require_v0_with_itstpc) { - fV0PhotonCut.SetRequireITSTPC(true); - fV0PhotonCut.SetMaxPCA(1.0); - fV0PhotonCut.SetRxyRange(4, 40); - } - if (pcmcuts.cfg_require_v0_with_itsonly) { - fV0PhotonCut.SetRequireITSonly(true); - fV0PhotonCut.SetMaxPCA(1.0); - fV0PhotonCut.SetRxyRange(4, 24); - } - if (pcmcuts.cfg_require_v0_with_tpconly) { - fV0PhotonCut.SetRequireTPConly(true); - fV0PhotonCut.SetMaxPCA(3.0); - fV0PhotonCut.SetRxyRange(36, 90); - } - if (pcmcuts.cfg_require_v0_on_wwire_ib) { - fV0PhotonCut.SetMaxPCA(0.3); - fV0PhotonCut.SetOnWwireIB(true); - fV0PhotonCut.SetOnWwireOB(false); - fV0PhotonCut.SetRxyRange(7, 14); - } + fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); + fV0PhotonCut.SetDisableTPConly(pcmcuts.cfg_disable_tpconly_track); + fV0PhotonCut.SetRequireITSTPC(pcmcuts.cfg_require_v0_with_itstpc); + fV0PhotonCut.SetRequireITSonly(pcmcuts.cfg_require_v0_with_itsonly); + fV0PhotonCut.SetRequireTPConly(pcmcuts.cfg_require_v0_with_tpconly); } void DefineDileptonCut() @@ -400,16 +399,20 @@ struct Pi0EtaToGammaGamma { fDileptonCut.SetMinNClustersTPC(dileptoncuts.cfg_min_ncluster_tpc); fDileptonCut.SetMinNCrossedRowsTPC(dileptoncuts.cfg_min_ncrossedrows); fDileptonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fDileptonCut.SetMaxFracSharedClustersTPC(dileptoncuts.cfg_max_frac_shared_clusters_tpc); fDileptonCut.SetChi2PerClusterTPC(0.0, dileptoncuts.cfg_max_chi2tpc); fDileptonCut.SetChi2PerClusterITS(0.0, dileptoncuts.cfg_max_chi2its); fDileptonCut.SetNClustersITS(dileptoncuts.cfg_min_ncluster_its, 7); fDileptonCut.SetMaxDcaXY(dileptoncuts.cfg_max_dcaxy); fDileptonCut.SetMaxDcaZ(dileptoncuts.cfg_max_dcaz); + fDileptonCut.SetTrackDca3DRange(0.f, dileptoncuts.cfg_max_dca3dsigma_track); // in sigma + fDileptonCut.IncludeITSsa(dileptoncuts.includeITSsa, dileptoncuts.cfg_max_pt_track_ITSsa); // for eID fDileptonCut.SetPIDScheme(dileptoncuts.cfg_pid_scheme); fDileptonCut.SetTPCNsigmaElRange(dileptoncuts.cfg_min_TPCNsigmaEl, dileptoncuts.cfg_max_TPCNsigmaEl); fDileptonCut.SetTPCNsigmaPiRange(dileptoncuts.cfg_min_TPCNsigmaPi, dileptoncuts.cfg_max_TPCNsigmaPi); + fDileptonCut.SetTOFNsigmaElRange(dileptoncuts.cfg_min_TOFNsigmaEl, dileptoncuts.cfg_max_TOFNsigmaEl); } void DefineEMCCut() @@ -532,10 +535,10 @@ struct Pi0EtaToGammaGamma { float openingAngle1 = std::acos(photon1.Vect().Dot(photon3.Vect()) / (photon1.P() * photon3.P())); float openingAngle2 = std::acos(photon2.Vect().Dot(photon3.Vect()) / (photon2.P() * photon3.P())); - if (openingAngle1 > emccuts.minOpenAngle && std::abs(mother1.Rapidity()) < maxY && iCellID_photon1 > 0) { + if (openingAngle1 > emccuts.minOpenAngle && std::fabs(mother1.Rapidity()) < maxY && iCellID_photon1 > 0) { fRegistry.fill(HIST("Pair/rotation/hs"), mother1.M(), mother1.Pt(), eventWeight); } - if (openingAngle2 > emccuts.minOpenAngle && std::abs(mother2.Rapidity()) < maxY && iCellID_photon2 > 0) { + if (openingAngle2 > emccuts.minOpenAngle && std::fabs(mother2.Rapidity()) < maxY && iCellID_photon2 > 0) { fRegistry.fill(HIST("Pair/rotation/hs"), mother2.M(), mother2.Pt(), eventWeight); } } @@ -548,14 +551,15 @@ struct Pi0EtaToGammaGamma { Preslice perCollision_phos = aod::phoscluster::emeventId; Preslice perCollision_electron = aod::emprimaryelectron::emeventId; - Partition positrons = o2::aod::emprimaryelectron::sign > int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt&& nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl&& o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); - Partition electrons = o2::aod::emprimaryelectron::sign < int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt && nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); + Partition positrons = o2::aod::emprimaryelectron::sign > int8_t(0) && dileptoncuts.cfg_min_pt_track < o2::aod::track::pt&& nabs(o2::aod::track::eta) < dileptoncuts.cfg_max_eta_track; + Partition electrons = o2::aod::emprimaryelectron::sign < int8_t(0) && dileptoncuts.cfg_min_pt_track < o2::aod::track::pt && nabs(o2::aod::track::eta) < dileptoncuts.cfg_max_eta_track; using MyEMH = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrack>; MyEMH* emh1 = nullptr; MyEMH* emh2 = nullptr; std::vector> used_photonIds; // std::vector> used_dileptonIds; // + std::map, uint64_t> map_mixed_eventId_to_globalBC; template void runPairing(TCollisions const& collisions, @@ -571,7 +575,12 @@ struct Pi0EtaToGammaGamma { continue; } - if (eventcuts.onlyKeepWeightedEvents && std::fabs(collision.weight() - 1.) < 1E-10) { + float weight = 1.f; + if constexpr (std::is_same_v, FilteredMyCollisionsWithJJMC>) { + weight = collision.weight(); + } + + if (eventcuts.onlyKeepWeightedEvents && std::fabs(weight - 1.f) < 1E-10) { continue; } @@ -580,13 +589,13 @@ struct Pi0EtaToGammaGamma { continue; } - o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision); + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, weight); if (!fEMEventCut.IsSelected(collision)) { continue; } - o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0); // accepted + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, weight); + fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, weight); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, weight); // accepted int zbin = lower_bound(zvtx_bin_edges.begin(), zvtx_bin_edges.end(), collision.posZ()) - zvtx_bin_edges.begin() - 1; if (zbin < 0) { @@ -611,7 +620,15 @@ struct Pi0EtaToGammaGamma { epbin = static_cast(ep_bin_edges.size()) - 2; } - int occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.trackOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + int occbin = -1; + if (cfgOccupancyEstimator == 0) { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.ft0cOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } else if (cfgOccupancyEstimator == 1) { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.trackOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } else { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.ft0cOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } + if (occbin < 0) { occbin = 0; } else if (static_cast(occ_bin_edges.size()) - 2 < occbin) { @@ -635,14 +652,21 @@ struct Pi0EtaToGammaGamma { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (std::abs(v12.Rapidity()) > maxY) { + if (std::fabs(v12.Rapidity()) > maxY) { continue; } - fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), collision.weight()); + if (pairtype == PairType::kEMCEMC) { + float openingAngle = std::acos(v1.Vect().Dot(v2.Vect()) / (v1.P() * v2.P())); + if (openingAngle < emccuts.minOpenAngle) { + continue; + } + } + + fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), weight); if constexpr (pairtype == PairType::kEMCEMC) { - RotationBackground(v12, v1, v2, photons2_per_collision, g1.globalIndex(), g2.globalIndex(), collision.weight()); + RotationBackground(v12, v1, v2, photons2_per_collision, g1.globalIndex(), g2.globalIndex(), weight); } std::pair pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex()); @@ -692,11 +716,11 @@ struct Pi0EtaToGammaGamma { ROOT::Math::PtEtaPhiMVector v_ele(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v_ee = v_pos + v_ele; ROOT::Math::PtEtaPhiMVector veeg = v_gamma + v_pos + v_ele; - if (std::abs(veeg.Rapidity()) > maxY) { + if (std::fabs(veeg.Rapidity()) > maxY) { continue; } - fRegistry.fill(HIST("Pair/same/hs"), veeg.M(), veeg.Pt(), collision.weight()); + fRegistry.fill(HIST("Pair/same/hs"), veeg.M(), veeg.Pt(), weight); std::pair pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex()); std::tuple tuple_tmp_id2 = std::make_tuple(ndf, collision.globalIndex(), pos2.trackId(), ele2.trackId()); @@ -722,11 +746,11 @@ struct Pi0EtaToGammaGamma { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (std::abs(v12.Rapidity()) > maxY) { + if (std::fabs(v12.Rapidity()) > maxY) { continue; } - fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), collision.weight()); + fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), weight); std::pair pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex()); std::pair pair_tmp_id2 = std::make_pair(ndf, g2.globalIndex()); @@ -764,6 +788,13 @@ struct Pi0EtaToGammaGamma { continue; } + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + fRegistry.fill(HIST("Pair/mix/hDiffBC"), diffBC); + if (diffBC < ndiff_bc_mix) { + continue; + } + auto photons1_from_event_pool = emh1->GetTracksPerCollision(mix_dfId_collisionId); // LOGF(info, "Do event mixing: current event (%d, %d), ngamma = %d | event pool (%d, %d), ngamma = %d", ndf, collision.globalIndex(), selected_photons1_in_this_event.size(), mix_dfId, mix_collisionId, photons1_from_event_pool.size()); @@ -772,11 +803,11 @@ struct Pi0EtaToGammaGamma { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (std::abs(v12.Rapidity()) > maxY) { + if (std::fabs(v12.Rapidity()) > maxY) { continue; } - fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt(), collision.weight()); + fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt(), weight); } } } // end of loop over mixed event pool @@ -790,6 +821,13 @@ struct Pi0EtaToGammaGamma { continue; } + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + fRegistry.fill(HIST("Pair/mix/hDiffBC"), diffBC); + if (diffBC < ndiff_bc_mix) { + continue; + } + auto photons2_from_event_pool = emh2->GetTracksPerCollision(mix_dfId_collisionId); // LOGF(info, "Do event mixing: current event (%d, %d), ngamma = %d | event pool (%d, %d), nll = %d", ndf, collision.globalIndex(), selected_photons1_in_this_event.size(), mix_dfId, mix_collisionId, photons2_from_event_pool.size()); @@ -797,14 +835,14 @@ struct Pi0EtaToGammaGamma { for (const auto& g2 : photons2_from_event_pool) { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); - if constexpr (pairtype == PairType::kPCMDalitzEE || pairtype == PairType::kPCMDalitzMuMu) { //[photon from event1, dilepton from event2] and [photon from event2, dilepton from event1] + if constexpr (pairtype == PairType::kPCMDalitzEE) { //[photon from event1, dilepton from event2] and [photon from event2, dilepton from event1] v2.SetM(g2.mass()); } ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (std::abs(v12.Rapidity()) > maxY) { + if (std::fabs(v12.Rapidity()) > maxY) { continue; } - fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt(), collision.weight()); + fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt(), weight); } } } // end of loop over mixed event pool @@ -816,6 +854,13 @@ struct Pi0EtaToGammaGamma { continue; } + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + fRegistry.fill(HIST("Pair/mix/hDiffBC"), diffBC); + if (diffBC < ndiff_bc_mix) { + continue; + } + auto photons1_from_event_pool = emh1->GetTracksPerCollision(mix_dfId_collisionId); // LOGF(info, "Do event mixing: current event (%d, %d), nll = %d | event pool (%d, %d), ngamma = %d", ndf, collision.globalIndex(), selected_photons2_in_this_event.size(), mix_dfId, mix_collisionId, photons1_from_event_pool.size()); @@ -823,14 +868,14 @@ struct Pi0EtaToGammaGamma { for (const auto& g2 : photons1_from_event_pool) { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); - if constexpr (pairtype == PairType::kPCMDalitzEE || pairtype == PairType::kPCMDalitzMuMu) { //[photon from event1, dilepton from event2] and [photon from event2, dilepton from event1] + if constexpr (pairtype == PairType::kPCMDalitzEE) { //[photon from event1, dilepton from event2] and [photon from event2, dilepton from event1] v1.SetM(g1.mass()); } ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (std::abs(v12.Rapidity()) > maxY) { + if (std::fabs(v12.Rapidity()) > maxY) { continue; } - fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt(), collision.weight()); + fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt(), weight); } } } // end of loop over mixed event pool @@ -839,15 +884,20 @@ struct Pi0EtaToGammaGamma { if (ndiphoton > 0) { emh1->AddCollisionIdAtLast(key_bin, key_df_collision); emh2->AddCollisionIdAtLast(key_bin, key_df_collision); + map_mixed_eventId_to_globalBC[key_df_collision] = collision.globalBC(); } } // end of collision loop } - Filter collisionFilter_occupancy = eventcuts.cfgOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgOccupancyMax; + Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); using FilteredMyCollisions = soa::Filtered; + Filter prefilter_pcm = ifnode(pcmcuts.cfg_apply_cuts_from_prefilter_derived.node(), o2::aod::v0photonkf::pfbderived == static_cast(0), true); + Filter prefilter_primaryelectron = ifnode(dileptoncuts.cfg_apply_cuts_from_prefilter_derived.node(), o2::aod::emprimaryelectron::pfbderived == static_cast(0), true); + int ndf = 0; void processAnalysis(FilteredMyCollisions const& collisions, Types const&... args) { @@ -883,9 +933,46 @@ struct Pi0EtaToGammaGamma { // } ndf++; } - PROCESS_SWITCH(Pi0EtaToGammaGamma, processAnalysis, "process pair analysis", false); + PROCESS_SWITCH(Pi0EtaToGammaGamma, processAnalysis, "process pair analysis", true); + + using FilteredMyCollisionsWithJJMC = soa::Filtered; + void processAnalysisJJMC(FilteredMyCollisionsWithJJMC const& collisions, Types const&... args) + { + // LOGF(info, "ndf = %d", ndf); + if constexpr (pairtype == PairType::kPCMPCM) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + runPairing(collisions, v0photons, v0photons, v0legs, v0legs, perCollision_pcm, perCollision_pcm, fV0PhotonCut, fV0PhotonCut); + } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + auto emprimaryelectrons = std::get<2>(std::tie(args...)); + // LOGF(info, "electrons.size() = %d, positrons.size() = %d", electrons.size(), positrons.size()); + runPairing(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDileptonCut); + } else if constexpr (pairtype == PairType::kEMCEMC) { + auto emcclusters = std::get<0>(std::tie(args...)); + runPairing(collisions, emcclusters, emcclusters, nullptr, nullptr, perCollision_emc, perCollision_emc, fEMCCut, fEMCCut); + } else if constexpr (pairtype == PairType::kPHOSPHOS) { + auto phosclusters = std::get<0>(std::tie(args...)); + runPairing(collisions, phosclusters, phosclusters, nullptr, nullptr, perCollision_phos, perCollision_phos, fPHOSCut, fPHOSCut); + } + // else if constexpr (pairtype == PairType::kPCMEMC) { + // auto v0photons = std::get<0>(std::tie(args...)); + // auto v0legs = std::get<1>(std::tie(args...)); + // auto emcclusters = std::get<2>(std::tie(args...)); + // auto emcmatchedtracks = std::get<3>(std::tie(args...)); + // runPairing(collisions, v0photons, emcclusters, v0legs, nullptr, perCollision_pcm, perCollision_emc, fV0PhotonCut, fEMCCut, emcmatchedtracks, nullptr); + // } else if constexpr (pairtype == PairType::kPCMPHOS) { + // auto v0photons = std::get<0>(std::tie(args...)); + // auto v0legs = std::get<1>(std::tie(args...)); + // auto phosclusters = std::get<2>(std::tie(args...)); + // runPairing(collisions, v0photons, phosclusters, v0legs, nullptr, perCollision_pcm, perCollision_phos, fV0PhotonCut, fPHOSCut, nullptr, nullptr); + // } + ndf++; + } + PROCESS_SWITCH(Pi0EtaToGammaGamma, processAnalysisJJMC, "process pair analysis", false); void processDummy(MyCollisions const&) {} - PROCESS_SWITCH(Pi0EtaToGammaGamma, processDummy, "Dummy function", true); + PROCESS_SWITCH(Pi0EtaToGammaGamma, processDummy, "Dummy function", false); }; #endif // PWGEM_PHOTONMESON_CORE_PI0ETATOGAMMAGAMMA_H_ diff --git a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h index ca3e2766bb0..2a0abf941f2 100644 --- a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h +++ b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h @@ -17,35 +17,36 @@ #ifndef PWGEM_PHOTONMESON_CORE_PI0ETATOGAMMAGAMMAMC_H_ #define PWGEM_PHOTONMESON_CORE_PI0ETATOGAMMAGAMMAMC_H_ -#include -#include -#include +#include "PWGEM/Dilepton/Utils/MCUtilities.h" +#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" +#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" +#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" +#include "PWGEM/PhotonMeson/Utils/NMHistograms.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" -#include "TF1.h" -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" +#include "Common/Core/RecoDecay.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" -#include "Common/Core/RecoDecay.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" -#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" -#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" -#include "PWGEM/PhotonMeson/Utils/NMHistograms.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" -#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" -#include "PWGEM/Dilepton/Utils/MCUtilities.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TString.h" + +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -56,13 +57,16 @@ using namespace o2::aod::pwgem::photonmeson::photonpair; using namespace o2::aod::pwgem::photonmeson::utils::mcutil; using namespace o2::aod::pwgem::dilepton::utils::mcutil; -using MyCollisions = soa::Join; +using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; +using MyCollisionsWithJJMC = soa::Join; +using MyCollisionWithJJMC = MyCollisionsWithJJMC::iterator; + using MyMCCollisions = soa::Join; using MyMCCollision = MyMCCollisions::iterator; -using MyV0Photons = soa::Join; +using MyV0Photons = soa::Filtered>; using MyV0Photon = MyV0Photons::iterator; using MyEMCClusters = soa::Join; @@ -74,7 +78,7 @@ using MyPHOSCluster = MyEMCClusters::iterator; using MyMCV0Legs = soa::Join; using MyMCV0Leg = MyMCV0Legs::iterator; -using MyMCElectrons = soa::Join; +using MyMCElectrons = soa::Filtered>; using MyMCElectron = MyMCElectrons::iterator; template @@ -91,6 +95,7 @@ struct Pi0EtaToGammaGammaMC { Configurable cfgCentMax{"cfgCentMax", 999, "max. centrality"}; Configurable maxY_rec{"maxY_rec", 0.9, "maximum rapidity for reconstructed particles"}; Configurable fd_k0s_to_pi0{"fd_k0s_pi0", "1.0", "feed down correction to pi0"}; + Configurable cfgRequireTrueAssociation{"cfgRequireTrueAssociation", false, "flag to require true mc collision association"}; EMPhotonEventCut fEMEventCut; struct : ConfigurableGroup { @@ -105,8 +110,10 @@ struct Pi0EtaToGammaGammaMC { Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; Configurable cfgRequireEMCReadoutInMB{"cfgRequireEMCReadoutInMB", false, "require the EMC to be read out in an MB collision (kTVXinEMC)"}; Configurable cfgRequireEMCHardwareTriggered{"cfgRequireEMCHardwareTriggered", false, "require the EMC to be hardware triggered (kEMC7 or kDMC7)"}; - Configurable cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; Configurable onlyKeepWeightedEvents{"onlyKeepWeightedEvents", false, "flag to keep only weighted events (for JJ MCs) and remove all MB events (with weight = 1)"}; } eventcuts; @@ -116,25 +123,30 @@ struct Pi0EtaToGammaGammaMC { Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; - Configurable cfg_require_v0_on_wwire_ib{"cfg_require_v0_on_wwire_ib", false, "flag to select V0s on W wires ITSib"}; Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; + Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; + Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.8, "min eta for v0 photons at PV"}; Configurable cfg_max_eta_v0{"cfg_max_eta_v0", 0.8, "max eta for v0 photons at PV"}; Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; - Configurable cfg_min_cospa{"cfg_min_cospa", 0.997, "min V0 CosPA"}; - Configurable cfg_max_pca{"cfg_max_pca", 3.0, "max distance btween 2 legs"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.999, "min V0 CosPA"}; + Configurable cfg_max_pca{"cfg_max_pca", 1.5, "max distance btween 2 legs"}; Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; - Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", true, "flag to select V0s with correct xz"}; + Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", false, "flag to select V0s with correct xz"}; Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; + Configurable cfg_apply_cuts_from_prefilter_derived{"cfg_apply_cuts_from_prefilter_derived", false, "flag to apply prefilter to V0"}; - Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 10, "min ncluster tpc"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; - Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; + Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; } pcmcuts; DalitzEECut fDileptonCut; @@ -143,7 +155,6 @@ struct Pi0EtaToGammaGammaMC { Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; Configurable cfg_max_mass{"cfg_max_mass", 0.1, "max mass"}; Configurable cfg_apply_phiv{"cfg_apply_phiv", true, "flag to apply phiv cut"}; - Configurable cfg_apply_pf{"cfg_apply_pf", false, "flag to apply phiv prefilter"}; Configurable cfg_require_itsib_any{"cfg_require_itsib_any", false, "flag to require ITS ib any hits"}; Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; Configurable cfg_phiv_slope{"cfg_phiv_slope", 0.0185, "slope for m vs. phiv"}; @@ -154,16 +165,23 @@ struct Pi0EtaToGammaGammaMC { Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 70, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; - Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; - Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1.0, "max dca XY for single track in cm"}; - Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.0, "max dca Z for single track in cm"}; - - Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTPConly), "pid scheme [kTPConly : 0]"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.05, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.05, "max dca Z for single track in cm"}; + Configurable cfg_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1.5, "max DCA 3D in sigma"}; + Configurable cfg_apply_cuts_from_prefilter_derived{"cfg_apply_cuts_from_prefilter_derived", false, "flag to apply prefilter to electron"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; + + Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTOFif), "pid scheme [kTOFif : 0, kTPConly : 1]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -3.0, "min. TPC n sigma for pion exclusion"}; - Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -0.0, "min. TPC n sigma for pion exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +0.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; } dileptoncuts; EMCPhotonCut fEMCCut; @@ -209,8 +227,6 @@ struct Pi0EtaToGammaGammaMC { o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry); if constexpr (pairtype == PairType::kPCMDalitzEE) { o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, true, "ee#gamma"); - } else if constexpr (pairtype == PairType::kPCMDalitzMuMu) { - o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, true, "#mu#mu#gamma"); } else { o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, true, "#gamma#gamma"); } @@ -244,7 +260,7 @@ struct Pi0EtaToGammaGammaMC { if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } mRunNumber = collision.runNumber(); @@ -298,8 +314,8 @@ struct Pi0EtaToGammaGammaMC { fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); // for v0 - fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, 1e10f); - fV0PhotonCut.SetV0EtaRange(-pcmcuts.cfg_max_eta_v0, +pcmcuts.cfg_max_eta_v0); + fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, pcmcuts.cfg_max_pt_v0); + fV0PhotonCut.SetV0EtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); fV0PhotonCut.SetMinCosPA(pcmcuts.cfg_min_cospa); fV0PhotonCut.SetMaxPCA(pcmcuts.cfg_max_pca); fV0PhotonCut.SetMaxChi2KF(pcmcuts.cfg_max_chi2kf); @@ -308,42 +324,21 @@ struct Pi0EtaToGammaGammaMC { fV0PhotonCut.RejectITSib(pcmcuts.cfg_reject_v0_on_itsib); // for track - fV0PhotonCut.SetTrackPtRange(pcmcuts.cfg_min_pt_v0 * 0.4, 1e+10f); - fV0PhotonCut.SetTrackEtaRange(-pcmcuts.cfg_max_eta_v0, +pcmcuts.cfg_max_eta_v0); + fV0PhotonCut.SetMinNClustersTPC(pcmcuts.cfg_min_ncluster_tpc); fV0PhotonCut.SetMinNCrossedRowsTPC(pcmcuts.cfg_min_ncrossedrows); fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fV0PhotonCut.SetMaxFracSharedClustersTPC(pcmcuts.cfg_max_frac_shared_clusters_tpc); fV0PhotonCut.SetChi2PerClusterTPC(0.0, pcmcuts.cfg_max_chi2tpc); fV0PhotonCut.SetTPCNsigmaElRange(pcmcuts.cfg_min_TPCNsigmaEl, pcmcuts.cfg_max_TPCNsigmaEl); fV0PhotonCut.SetChi2PerClusterITS(-1e+10, pcmcuts.cfg_max_chi2its); - if (pcmcuts.cfg_reject_v0_on_itsib) { - fV0PhotonCut.SetNClustersITS(2, 4); - } else { - fV0PhotonCut.SetNClustersITS(0, 7); - } + fV0PhotonCut.SetNClustersITS(0, 7); fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); fV0PhotonCut.SetIsWithinBeamPipe(pcmcuts.cfg_require_v0_with_correct_xz); - - if (pcmcuts.cfg_require_v0_with_itstpc) { - fV0PhotonCut.SetRequireITSTPC(true); - fV0PhotonCut.SetMaxPCA(1.0); - fV0PhotonCut.SetRxyRange(4, 40); - } - if (pcmcuts.cfg_require_v0_with_itsonly) { - fV0PhotonCut.SetRequireITSonly(true); - fV0PhotonCut.SetMaxPCA(1.0); - fV0PhotonCut.SetRxyRange(4, 24); - } - if (pcmcuts.cfg_require_v0_with_tpconly) { - fV0PhotonCut.SetRequireTPConly(true); - fV0PhotonCut.SetMaxPCA(3.0); - fV0PhotonCut.SetRxyRange(36, 90); - } - if (pcmcuts.cfg_require_v0_on_wwire_ib) { - fV0PhotonCut.SetMaxPCA(0.3); - fV0PhotonCut.SetOnWwireIB(true); - fV0PhotonCut.SetOnWwireOB(false); - fV0PhotonCut.SetRxyRange(7, 14); - } + fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); + fV0PhotonCut.SetDisableTPConly(pcmcuts.cfg_disable_tpconly_track); + fV0PhotonCut.SetRequireITSTPC(pcmcuts.cfg_require_v0_with_itstpc); + fV0PhotonCut.SetRequireITSonly(pcmcuts.cfg_require_v0_with_itsonly); + fV0PhotonCut.SetRequireTPConly(pcmcuts.cfg_require_v0_with_tpconly); } void DefineDileptonCut() @@ -363,16 +358,20 @@ struct Pi0EtaToGammaGammaMC { fDileptonCut.SetMinNClustersTPC(dileptoncuts.cfg_min_ncluster_tpc); fDileptonCut.SetMinNCrossedRowsTPC(dileptoncuts.cfg_min_ncrossedrows); fDileptonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fDileptonCut.SetMaxFracSharedClustersTPC(dileptoncuts.cfg_max_frac_shared_clusters_tpc); fDileptonCut.SetChi2PerClusterTPC(0.0, dileptoncuts.cfg_max_chi2tpc); fDileptonCut.SetChi2PerClusterITS(0.0, dileptoncuts.cfg_max_chi2its); fDileptonCut.SetNClustersITS(dileptoncuts.cfg_min_ncluster_its, 7); fDileptonCut.SetMaxDcaXY(dileptoncuts.cfg_max_dcaxy); fDileptonCut.SetMaxDcaZ(dileptoncuts.cfg_max_dcaz); + fDileptonCut.SetTrackDca3DRange(0.f, dileptoncuts.cfg_max_dca3dsigma_track); // in sigma + fDileptonCut.IncludeITSsa(dileptoncuts.includeITSsa, dileptoncuts.cfg_max_pt_track_ITSsa); // for eID fDileptonCut.SetPIDScheme(dileptoncuts.cfg_pid_scheme); fDileptonCut.SetTPCNsigmaElRange(dileptoncuts.cfg_min_TPCNsigmaEl, dileptoncuts.cfg_max_TPCNsigmaEl); fDileptonCut.SetTPCNsigmaPiRange(dileptoncuts.cfg_min_TPCNsigmaPi, dileptoncuts.cfg_max_TPCNsigmaPi); + fDileptonCut.SetTOFNsigmaElRange(dileptoncuts.cfg_min_TOFNsigmaEl, dileptoncuts.cfg_max_TOFNsigmaEl); } void DefineEMCCut() @@ -394,8 +393,8 @@ struct Pi0EtaToGammaGammaMC { fEMCCut.SetM02Range(emccuts.EMC_minM02, emccuts.EMC_maxM02); fEMCCut.SetTimeRange(emccuts.EMC_minTime, emccuts.EMC_maxTime); - fEMCCut.SetTrackMatchingEta([a, b, c](float pT) { return a + pow(pT + b, c); }); - fEMCCut.SetTrackMatchingPhi([d, e, f](float pT) { return d + pow(pT + e, f); }); + fEMCCut.SetTrackMatchingEta([a, b, c](float pT) { return a + std::pow(pT + b, c); }); + fEMCCut.SetTrackMatchingPhi([d, e, f](float pT) { return d + std::pow(pT + e, f); }); fEMCCut.SetMinEoverP(emccuts.EMC_Eoverp); fEMCCut.SetUseExoticCut(emccuts.EMC_UseExoticCut); @@ -412,12 +411,8 @@ struct Pi0EtaToGammaGammaMC { Preslice perCollision_phos = aod::phoscluster::emeventId; Preslice perCollision_electron = aod::emprimaryelectron::emeventId; - Partition positrons = o2::aod::emprimaryelectron::sign > int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt&& nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl&& o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); - Partition electrons = o2::aod::emprimaryelectron::sign < int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt && nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); - - // Preslice perCollision_muon = aod::emprimarymuon::emeventId; - // Partition muons_pos = o2::aod::emprimarymuon::sign > int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt&& nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaMu) < o2::aod::pidtpc::tpcNSigmaMu&& o2::aod::pidtpc::tpcNSigmaMu < static_cast(dileptoncuts.cfg_max_TPCNsigmaMu); - // Partition muons_neg = o2::aod::emprimarymuon::sign < int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt && nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaMu) < o2::aod::pidtpc::tpcNSigmaMu && o2::aod::pidtpc::tpcNSigmaMu < static_cast(dileptoncuts.cfg_max_TPCNsigmaMu); + Partition positrons = o2::aod::emprimaryelectron::sign > int8_t(0) && dileptoncuts.cfg_min_pt_track < o2::aod::track::pt&& nabs(o2::aod::track::eta) < dileptoncuts.cfg_max_eta_track; + Partition electrons = o2::aod::emprimaryelectron::sign < int8_t(0) && dileptoncuts.cfg_min_pt_track < o2::aod::track::pt && nabs(o2::aod::track::eta) < dileptoncuts.cfg_max_eta_track; template void runTruePairing(TCollisions const& collisions, @@ -434,7 +429,12 @@ struct Pi0EtaToGammaGammaMC { continue; } - if (eventcuts.onlyKeepWeightedEvents && fabs(collision.weight() - 1.) < 1E-10) { + float weight = 1.f; + if constexpr (std::is_same_v, FilteredMyCollisionsWithJJMC>) { + weight = collision.weight(); + } + + if (eventcuts.onlyKeepWeightedEvents && std::fabs(weight - 1.0) < 1e-10) { continue; } @@ -443,13 +443,13 @@ struct Pi0EtaToGammaGammaMC { continue; } - o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision); + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, weight); if (!fEMEventCut.IsSelected(collision)) { continue; } - o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0); // accepted + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, weight); + fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, weight); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, weight); // accepted int photonid1 = -1, photonid2 = -1, pi0id = -1, etaid = -1; if constexpr (pairtype == PairType::kPCMPCM || pairtype == PairType::kPHOSPHOS || pairtype == PairType::kEMCEMC) { // same kinds pairing @@ -500,23 +500,44 @@ struct Pi0EtaToGammaGammaMC { pi0id = FindCommonMotherFrom2Prongs(g1mc, g2mc, 22, 22, 111, mcparticles); etaid = FindCommonMotherFrom2Prongs(g1mc, g2mc, 22, 22, 221, mcparticles); - if (pi0id < 0 && etaid < 0) { + if (g1mc.globalIndex() != g2mc.globalIndex() && pi0id < 0 && etaid < 0) { // for same gamma no pi0/eta will be found, but we still want to fill the FromSameGamma hist continue; } ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (abs(v12.Rapidity()) > maxY_rec) { + if (std::fabs(v12.Rapidity()) > maxY_rec) { + continue; + } + + if (pairtype == PairType::kEMCEMC) { + float openingAngle = std::acos(v1.Vect().Dot(v2.Vect()) / (v1.P() * v2.P())); + if (openingAngle < emccuts.minOpenAngle) { + continue; + } + } + + if (g1mc.globalIndex() == g2mc.globalIndex()) { + if (getMotherPDGCode(g1mc, mcparticles) == 111) + fRegistry.fill(HIST("Pair/Pi0/hs_FromSameGamma"), v12.M(), v12.Pt(), weight); + else if (getMotherPDGCode(g1mc, mcparticles) == 221) + fRegistry.fill(HIST("Pair/Eta/hs_FromSameGamma"), v12.M(), v12.Pt(), weight); continue; } if (pi0id > 0) { auto pi0mc = mcparticles.iteratorAt(pi0id); - o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); + if (cfgRequireTrueAssociation && (pi0mc.emmceventId() != collision.emmceventId())) { + continue; + } + o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight); } else if (etaid > 0) { auto etamc = mcparticles.iteratorAt(etaid); - o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); + if (cfgRequireTrueAssociation && (etamc.emmceventId() != collision.emmceventId())) { + continue; + } + o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight); } } // end of pairing loop } else if constexpr (pairtype == PairType::kPCMDalitzEE) { @@ -554,7 +575,7 @@ struct Pi0EtaToGammaGammaMC { continue; } - if (!cut2.template IsSelectedPair(pos2, ele2, d_bz)) { + if (!cut2.IsSelectedPair(pos2, ele2, d_bz)) { continue; } @@ -568,15 +589,21 @@ struct Pi0EtaToGammaGammaMC { ROOT::Math::PtEtaPhiMVector v_pos(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v_ele(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector veeg = v_gamma + v_pos + v_ele; - if (abs(veeg.Rapidity()) > maxY_rec) { + if (std::fabs(veeg.Rapidity()) > maxY_rec) { continue; } if (pi0id > 0) { auto pi0mc = mcparticles.iteratorAt(pi0id); - o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, veeg, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); + if (cfgRequireTrueAssociation && (pi0mc.emmceventId() != collision.emmceventId())) { + continue; + } + o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, veeg, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight); } else if (etaid > 0) { auto etamc = mcparticles.iteratorAt(etaid); - o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, veeg, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); + if (cfgRequireTrueAssociation && (etamc.emmceventId() != collision.emmceventId())) { + continue; + } + o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, veeg, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight); } } // end of dielectron loop } // end of pcm loop @@ -591,15 +618,15 @@ struct Pi0EtaToGammaGammaMC { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (abs(v12.Rapidity()) > maxY_rec) { + if (std::fabs(v12.Rapidity()) > maxY_rec) { continue; } // if (pi0id > 0) { // auto pi0mc = mcparticles.iteratorAt(pi0id); - // o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); + // o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight); // } else if (etaid > 0) { // auto etamc = mcparticles.iteratorAt(etaid); - // o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); + // o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight); // } } // end of pairing loop } // end of pairing in same event @@ -649,6 +676,15 @@ struct Pi0EtaToGammaGammaMC { continue; // I don't know why this is necessary in simulation. } + float weight = 1.f; + if constexpr (std::is_same_v, FilteredMyCollisionsWithJJMC>) { + weight = collision.weight(); + } + + if (eventcuts.onlyKeepWeightedEvents && std::fabs(weight - 1.0) < 1e-10) { + continue; + } + float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { continue; @@ -661,15 +697,19 @@ struct Pi0EtaToGammaGammaMC { auto mccollision = collision.template emmcevent_as(); auto binned_data_pi0_gen = mccollision.generatedPi0(); auto binned_data_eta_gen = mccollision.generatedEta(); - fillBinnedData<0>(binned_data_pi0_gen, collision.weight()); - fillBinnedData<1>(binned_data_eta_gen, collision.weight()); + fillBinnedData<0>(binned_data_pi0_gen, weight); + fillBinnedData<1>(binned_data_eta_gen, weight); } // end of collision loop } - Filter collisionFilter_occupancy = eventcuts.cfgOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgOccupancyMax; + Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); using FilteredMyCollisions = soa::Filtered; + Filter prefilter_pcm = ifnode(pcmcuts.cfg_apply_cuts_from_prefilter_derived.node(), o2::aod::v0photonkf::pfbderived == static_cast(0), true); + Filter prefilter_primaryelectron = ifnode(dileptoncuts.cfg_apply_cuts_from_prefilter_derived.node(), o2::aod::emprimaryelectron::pfbderived == static_cast(0), true); + void processAnalysis(FilteredMyCollisions const& collisions, MyMCCollisions const& mccollisions, aod::EMMCParticles const& mcparticles, Types const&... args) { if constexpr (pairtype == PairType::kPCMPCM) { @@ -707,9 +747,49 @@ struct Pi0EtaToGammaGammaMC { // runPairing(collisions, v0photons, phosclusters, v0legs, nullptr, perCollision_pcm, perCollision_phos, fV0PhotonCut, fPHOSCut, nullptr, nullptr); // } } - PROCESS_SWITCH(Pi0EtaToGammaGammaMC, processAnalysis, "process pair analysis", false); + PROCESS_SWITCH(Pi0EtaToGammaGammaMC, processAnalysis, "process pair analysis", true); + + using FilteredMyCollisionsWithJJMC = soa::Filtered; + void processAnalysisJJMC(FilteredMyCollisionsWithJJMC const& collisions, MyMCCollisions const& mccollisions, aod::EMMCParticles const& mcparticles, Types const&... args) + { + if constexpr (pairtype == PairType::kPCMPCM) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + runTruePairing(collisions, v0photons, v0photons, v0legs, v0legs, perCollision_pcm, perCollision_pcm, fV0PhotonCut, fV0PhotonCut, mccollisions, mcparticles); + runGenInfo(collisions, mccollisions, mcparticles); + } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + auto emprimaryelectrons = std::get<2>(std::tie(args...)); + // LOGF(info, "electrons.size() = %d, positrons.size() = %d", electrons.size(), positrons.size()); + runTruePairing(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDileptonCut, mccollisions, mcparticles); + runGenInfo(collisions, mccollisions, mcparticles); + } else if constexpr (pairtype == PairType::kEMCEMC) { + auto emcclusters = std::get<0>(std::tie(args...)); + runTruePairing(collisions, emcclusters, emcclusters, nullptr, nullptr, perCollision_emc, perCollision_emc, fEMCCut, fEMCCut, mccollisions, mcparticles); + runGenInfo(collisions, mccollisions, mcparticles); + } + + // else if constexpr (pairtype == PairType::kPHOSPHOS) { + // auto phosclusters = std::get<0>(std::tie(args...)); + // runPairing(collisions, phosclusters, phosclusters, nullptr, nullptr, perCollision_phos, perCollision_phos, fPHOSCut, fPHOSCut, nullptr, nullptr); + // } + // else if constexpr (pairtype == PairType::kPCMEMC) { + // auto v0photons = std::get<0>(std::tie(args...)); + // auto v0legs = std::get<1>(std::tie(args...)); + // auto emcclusters = std::get<2>(std::tie(args...)); + // auto emcmatchedtracks = std::get<3>(std::tie(args...)); + // runPairing(collisions, v0photons, emcclusters, v0legs, nullptr, perCollision_pcm, perCollision_emc, fV0PhotonCut, fEMCCut, emcmatchedtracks, nullptr); + // } else if constexpr (pairtype == PairType::kPCMPHOS) { + // auto v0photons = std::get<0>(std::tie(args...)); + // auto v0legs = std::get<1>(std::tie(args...)); + // auto phosclusters = std::get<2>(std::tie(args...)); + // runPairing(collisions, v0photons, phosclusters, v0legs, nullptr, perCollision_pcm, perCollision_phos, fV0PhotonCut, fPHOSCut, nullptr, nullptr); + // } + } + PROCESS_SWITCH(Pi0EtaToGammaGammaMC, processAnalysisJJMC, "process pair analysis", false); void processDummy(MyCollisions const&) {} - PROCESS_SWITCH(Pi0EtaToGammaGammaMC, processDummy, "Dummy function", true); + PROCESS_SWITCH(Pi0EtaToGammaGammaMC, processDummy, "Dummy function", false); }; #endif // PWGEM_PHOTONMESON_CORE_PI0ETATOGAMMAGAMMAMC_H_ diff --git a/PWGEM/PhotonMeson/Core/TaggingPi0.h b/PWGEM/PhotonMeson/Core/TaggingPi0.h new file mode 100644 index 00000000000..d74af2ceb0c --- /dev/null +++ b/PWGEM/PhotonMeson/Core/TaggingPi0.h @@ -0,0 +1,697 @@ +// 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. +// +// ======================== +// +/// \file TaggingPi0.h +/// \brief This code loops over photons and makes pairs for direct photon analysis. +/// +/// \author D. Sekihata, daiki.sekihata@cern.ch + +#ifndef PWGEM_PHOTONMESON_CORE_TAGGINGPI0_H_ +#define PWGEM_PHOTONMESON_CORE_TAGGINGPI0_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "TString.h" +#include "Math/Vector4D.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" + +#include "DetectorsBase/GeometryManager.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/BasicCCDBManager.h" + +#include "Common/Core/RecoDecay.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" +#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" +#include "PWGEM/Dilepton/Utils/EMTrack.h" +#include "PWGEM/Dilepton/Utils/EventMixingHandler.h" +#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::aod::pwgem::photonmeson::photonpair; +using namespace o2::aod::pwgem::photon; +using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; +using namespace o2::aod::pwgem::dilepton::utils; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyV0Photons = soa::Join; +using MyV0Photon = MyV0Photons::iterator; + +using MyPrimaryElectrons = soa::Join; +using MyPrimaryElectron = MyPrimaryElectrons::iterator; + +using MyEMCClusters = soa::Join; +using MyEMCCluster = MyEMCClusters::iterator; + +using MyPHOSClusters = soa::Join; +using MyPHOSCluster = MyPHOSClusters::iterator; + +template +struct TaggingPi0 { + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; + Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; + Configurable ndiff_bc_mix{"ndiff_bc_mix", 198, "difference in global BC required in mixed events"}; + + Configurable cfgQvecEstimator{"cfgQvecEstimator", 0, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgOccupancyEstimator{"cfgOccupancyEstimator", 0, "FT0C:0, Track:1"}; + Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999, "max. centrality"}; + Configurable cfgDoMix{"cfgDoMix", true, "flag for event mixing"}; + Configurable ndepth{"ndepth", 100, "depth for event mixing"}; + ConfigurableAxis ConfVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.f, 999.f}, "Mixing bins - centrality"}; + ConfigurableAxis ConfEPBins{"ConfEPBins", {VARIABLE_WIDTH, -M_PI / 2, -M_PI / 4, 0.0f, +M_PI / 4, +M_PI / 2}, "Mixing bins - event plane angle"}; + ConfigurableAxis ConfOccupancyBins{"ConfOccupancyBins", {VARIABLE_WIDTH, -1, 1e+10}, "Mixing bins - occupancy"}; + ConfigurableAxis ConfPtBins{"ConfPtBins", {100, 0, 10}, "pT bins for output histograms"}; + + EMPhotonEventCut fEMEventCut; + struct : ConfigurableGroup { + std::string prefix = "eventcut_group"; + Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; + Configurable cfgRequireEMCReadoutInMB{"cfgRequireEMCReadoutInMB", false, "require the EMC to be read out in an MB collision (kTVXinEMC)"}; + Configurable cfgRequireEMCHardwareTriggered{"cfgRequireEMCHardwareTriggered", false, "require the EMC to be hardware triggered (kEMC7 or kDMC7)"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; + Configurable onlyKeepWeightedEvents{"onlyKeepWeightedEvents", false, "flag to keep only weighted events (for JJ MCs) and remove all MB events (with weight = 1)"}; + } eventcuts; + + V0PhotonCut fV0PhotonCut; + struct : ConfigurableGroup { + std::string prefix = "pcmcut_group"; + Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; + Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; + Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; + Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; + Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; + Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.8, "min eta for v0 photons at PV"}; + Configurable cfg_max_eta_v0{"cfg_max_eta_v0", 0.8, "max eta for v0 photons at PV"}; + Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; + Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; + Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; + Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.997, "min V0 CosPA"}; + Configurable cfg_max_pca{"cfg_max_pca", 3.0, "max distance btween 2 legs"}; + Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; + Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", true, "flag to select V0s with correct xz"}; + Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; + + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 10, "min ncluster tpc"}; + Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; + Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; + } pcmcuts; + + DalitzEECut fDileptonCut; + struct : ConfigurableGroup { + std::string prefix = "dileptoncut_group"; + Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; + Configurable cfg_max_mass{"cfg_max_mass", 0.1, "max mass"}; + Configurable cfg_apply_phiv{"cfg_apply_phiv", true, "flag to apply phiv cut"}; + Configurable cfg_require_itsib_any{"cfg_require_itsib_any", false, "flag to require ITS ib any hits"}; + Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; + Configurable cfg_phiv_slope{"cfg_phiv_slope", 0.0185, "slope for m vs. phiv"}; + Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.1, "min pT for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", 0.8, "max eta for single track"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; + Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 70, "min ncrossed rows"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.05, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.05, "max dca Z for single track in cm"}; + Configurable cfg_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1.5, "max DCA 3D in sigma"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + + Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTOFif), "pid scheme [kTOFif : 0, kTPConly : 1]"}; + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -0.0, "min. TPC n sigma for pion exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +0.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + } dileptoncuts; + + EMCPhotonCut fEMCCut; + struct : ConfigurableGroup { + std::string prefix = "emccut_group"; + Configurable clusterDefinition{"clusterDefinition", "kV3Default", "Clusterizer to be selected, e.g. V3Default"}; + Configurable minOpenAngle{"minOpenAngle", 0.0202, "apply min opening angle"}; + Configurable EMC_minTime{"EMC_minTime", -20., "Minimum cluster time for EMCal time cut"}; + Configurable EMC_maxTime{"EMC_maxTime", +25., "Maximum cluster time for EMCal time cut"}; + Configurable EMC_minM02{"EMC_minM02", 0.1, "Minimum M02 for EMCal M02 cut"}; + Configurable EMC_maxM02{"EMC_maxM02", 0.7, "Maximum M02 for EMCal M02 cut"}; + Configurable EMC_minE{"EMC_minE", 0.7, "Minimum cluster energy for EMCal energy cut"}; + Configurable EMC_minNCell{"EMC_minNCell", 1, "Minimum number of cells per cluster for EMCal NCell cut"}; + Configurable> EMC_TM_Eta{"EMC_TM_Eta", {0.01f, 4.07f, -2.5f}, "|eta| <= [0]+(pT+[1])^[2] for EMCal track matching"}; + Configurable> EMC_TM_Phi{"EMC_TM_Phi", {0.015f, 3.65f, -2.f}, "|phi| <= [0]+(pT+[1])^[2] for EMCal track matching"}; + Configurable EMC_Eoverp{"EMC_Eoverp", 1.75, "Minimum cluster energy over track momentum for EMCal track matching"}; + Configurable EMC_UseExoticCut{"EMC_UseExoticCut", true, "FLag to use the EMCal exotic cluster cut"}; + Configurable cfgDistanceToEdge{"cfgDistanceToEdge", 1, "Distance to edge in cells required for rotated cluster to be accepted"}; + } emccuts; + + PHOSPhotonCut fPHOSCut; + struct : ConfigurableGroup { + std::string prefix = "phoscut_group"; + Configurable cfg_min_Ecluster{"cfg_min_Ecluster", 0.3, "Minimum cluster energy for PHOS in GeV"}; + } phoscuts; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + static constexpr std::string_view event_types[2] = {"before/", "after/"}; + static constexpr std::string_view event_pair_types[2] = {"same/", "mix/"}; + + std::vector zvtx_bin_edges; + std::vector cent_bin_edges; + std::vector ep_bin_edges; + std::vector occ_bin_edges; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber; + float d_bz; + + void init(InitContext&) + { + zvtx_bin_edges = std::vector(ConfVtxBins.value.begin(), ConfVtxBins.value.end()); + zvtx_bin_edges.erase(zvtx_bin_edges.begin()); + + cent_bin_edges = std::vector(ConfCentBins.value.begin(), ConfCentBins.value.end()); + cent_bin_edges.erase(cent_bin_edges.begin()); + + ep_bin_edges = std::vector(ConfEPBins.value.begin(), ConfEPBins.value.end()); + ep_bin_edges.erase(ep_bin_edges.begin()); + + LOGF(info, "cfgOccupancyEstimator = %d", cfgOccupancyEstimator.value); + occ_bin_edges = std::vector(ConfOccupancyBins.value.begin(), ConfOccupancyBins.value.end()); + occ_bin_edges.erase(occ_bin_edges.begin()); + + emh1 = new MyEMH(ndepth); + emh2 = new MyEMH(ndepth); + + o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry); + + addHistogrms(); + DefineEMEventCut(); + DefinePCMCut(); + DefineDileptonCut(); + DefineEMCCut(); + DefinePHOSCut(); + + mRunNumber = 0; + d_bz = 0; + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + } + + template + void initCCDB(TCollision const& collision) + { + if (mRunNumber == collision.runNumber()) { + return; + } + + // In case override, don't proceed, please - no CCDB access required + if (d_bz_input > -990) { + d_bz = d_bz_input; + o2::parameters::GRPMagField grpmag; + if (std::fabs(d_bz) > 1e-5) { + grpmag.setL3Current(30000.f / (d_bz / 5.0f)); + } + mRunNumber = collision.runNumber(); + return; + } + + auto run3grp_timestamp = collision.timestamp(); + o2::parameters::GRPObject* grpo = 0x0; + o2::parameters::GRPMagField* grpmag = 0x0; + if (!skipGRPOquery) + grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + if (grpo) { + // Fetch magnetic field from ccdb for current collision + d_bz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + // Fetch magnetic field from ccdb for current collision + d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } + mRunNumber = collision.runNumber(); + } + + ~TaggingPi0() + { + delete emh1; + emh1 = 0x0; + delete emh2; + emh2 = 0x0; + + used_photonIds.clear(); + used_photonIds.shrink_to_fit(); + used_dileptonIds.clear(); + used_dileptonIds.shrink_to_fit(); + map_mixed_eventId_to_globalBC.clear(); + } + + void addHistogrms() + { + TString mggTitle = "ee#gamma"; + if constexpr (pairtype == PairType::kPCMDalitzEE) { + mggTitle = "ee#gamma"; + } else { + mggTitle = "#gamma#gamma"; + } + + const AxisSpec axis_m{200, 0, 0.4, Form("m_{%s} (GeV/c^{2})", mggTitle.Data())}; + const AxisSpec axis_pt{ConfPtBins, "p_{T,#gamma} (GeV/c)"}; + + fRegistry.add("Photon/hPt", "p_{T,#gamma};p_{T,#gamma} (GeV/c)", kTH1D, {axis_pt}, true); + fRegistry.add("Photon/hEtaPhi", "#varphi vs. #eta;#varphi_{#gamma} (rad.);#eta_{#gamma}", kTH2D, {{90, 0, 2 * M_PI}, {40, -1, +1}}, true); + fRegistry.add("Pair/same/hMvsPt", "mass vs. p_{T,#gamma}", kTH2D, {axis_m, axis_pt}, true); + fRegistry.addClone("Pair/same/", "Pair/mix/"); + fRegistry.add("Pair/mix/hDiffBC", "diff. global BC in mixed event;|BC_{current} - BC_{mixed}|", kTH1D, {{10001, -0.5, 10000.5}}, true); + } + + void DefineEMEventCut() + { + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); + fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); + fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); + fEMEventCut.SetRequireNoTFB(eventcuts.cfgRequireNoTFB); + fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); + fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); + fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); + fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + fEMEventCut.SetRequireEMCReadoutInMB(eventcuts.cfgRequireEMCReadoutInMB); + fEMEventCut.SetRequireEMCHardwareTriggered(eventcuts.cfgRequireEMCHardwareTriggered); + } + + void DefinePCMCut() + { + fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); + + // for v0 + fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, pcmcuts.cfg_max_pt_v0); + fV0PhotonCut.SetV0EtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); + fV0PhotonCut.SetMinCosPA(pcmcuts.cfg_min_cospa); + fV0PhotonCut.SetMaxPCA(pcmcuts.cfg_max_pca); + fV0PhotonCut.SetMaxChi2KF(pcmcuts.cfg_max_chi2kf); + fV0PhotonCut.SetRxyRange(pcmcuts.cfg_min_v0radius, pcmcuts.cfg_max_v0radius); + fV0PhotonCut.SetAPRange(pcmcuts.cfg_max_alpha_ap, pcmcuts.cfg_max_qt_ap); + fV0PhotonCut.RejectITSib(pcmcuts.cfg_reject_v0_on_itsib); + + // for track + fV0PhotonCut.SetMinNClustersTPC(pcmcuts.cfg_min_ncluster_tpc); + fV0PhotonCut.SetMinNCrossedRowsTPC(pcmcuts.cfg_min_ncrossedrows); + fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fV0PhotonCut.SetMaxFracSharedClustersTPC(pcmcuts.cfg_max_frac_shared_clusters_tpc); + fV0PhotonCut.SetChi2PerClusterTPC(0.0, pcmcuts.cfg_max_chi2tpc); + fV0PhotonCut.SetTPCNsigmaElRange(pcmcuts.cfg_min_TPCNsigmaEl, pcmcuts.cfg_max_TPCNsigmaEl); + fV0PhotonCut.SetChi2PerClusterITS(-1e+10, pcmcuts.cfg_max_chi2its); + fV0PhotonCut.SetNClustersITS(0, 7); + fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); + fV0PhotonCut.SetIsWithinBeamPipe(pcmcuts.cfg_require_v0_with_correct_xz); + fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); + fV0PhotonCut.SetDisableTPConly(pcmcuts.cfg_disable_tpconly_track); + fV0PhotonCut.SetRequireITSTPC(pcmcuts.cfg_require_v0_with_itstpc); + fV0PhotonCut.SetRequireITSonly(pcmcuts.cfg_require_v0_with_itsonly); + fV0PhotonCut.SetRequireTPConly(pcmcuts.cfg_require_v0_with_tpconly); + } + + void DefineDileptonCut() + { + fDileptonCut = DalitzEECut("fDileptonCut", "fDileptonCut"); + + // for pair + fDileptonCut.SetMeeRange(dileptoncuts.cfg_min_mass, dileptoncuts.cfg_max_mass); + fDileptonCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dileptoncuts.cfg_phiv_intercept) / dileptoncuts.cfg_phiv_slope; }); + fDileptonCut.ApplyPhiV(dileptoncuts.cfg_apply_phiv); + fDileptonCut.RequireITSibAny(dileptoncuts.cfg_require_itsib_any); + fDileptonCut.RequireITSib1st(dileptoncuts.cfg_require_itsib_1st); + + // for track + fDileptonCut.SetTrackPtRange(dileptoncuts.cfg_min_pt_track, 1e+10f); + fDileptonCut.SetTrackEtaRange(-dileptoncuts.cfg_max_eta_track, +dileptoncuts.cfg_max_eta_track); + fDileptonCut.SetMinNClustersTPC(dileptoncuts.cfg_min_ncluster_tpc); + fDileptonCut.SetMinNCrossedRowsTPC(dileptoncuts.cfg_min_ncrossedrows); + fDileptonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fDileptonCut.SetMaxFracSharedClustersTPC(dileptoncuts.cfg_max_frac_shared_clusters_tpc); + fDileptonCut.SetChi2PerClusterTPC(0.0, dileptoncuts.cfg_max_chi2tpc); + fDileptonCut.SetChi2PerClusterITS(0.0, dileptoncuts.cfg_max_chi2its); + fDileptonCut.SetNClustersITS(dileptoncuts.cfg_min_ncluster_its, 7); + fDileptonCut.SetMaxDcaXY(dileptoncuts.cfg_max_dcaxy); + fDileptonCut.SetMaxDcaZ(dileptoncuts.cfg_max_dcaz); + fDileptonCut.SetTrackDca3DRange(0.f, dileptoncuts.cfg_max_dca3dsigma_track); // in sigma + + // for eID + fDileptonCut.SetPIDScheme(dileptoncuts.cfg_pid_scheme); + fDileptonCut.SetTPCNsigmaElRange(dileptoncuts.cfg_min_TPCNsigmaEl, dileptoncuts.cfg_max_TPCNsigmaEl); + fDileptonCut.SetTPCNsigmaPiRange(dileptoncuts.cfg_min_TPCNsigmaPi, dileptoncuts.cfg_max_TPCNsigmaPi); + fDileptonCut.SetTOFNsigmaElRange(dileptoncuts.cfg_min_TOFNsigmaEl, dileptoncuts.cfg_max_TOFNsigmaEl); + } + + void DefineEMCCut() + { + const float a = emccuts.EMC_TM_Eta->at(0); + const float b = emccuts.EMC_TM_Eta->at(1); + const float c = emccuts.EMC_TM_Eta->at(2); + + const float d = emccuts.EMC_TM_Phi->at(0); + const float e = emccuts.EMC_TM_Phi->at(1); + const float f = emccuts.EMC_TM_Phi->at(2); + LOGF(info, "EMCal track matching parameters : a = %f, b = %f, c = %f, d = %f, e = %f, f = %f", a, b, c, d, e, f); + + fEMCCut = EMCPhotonCut("fEMCCut", "fEMCCut"); + + fEMCCut.SetClusterizer(emccuts.clusterDefinition); + fEMCCut.SetMinE(emccuts.EMC_minE); + fEMCCut.SetMinNCell(emccuts.EMC_minNCell); + fEMCCut.SetM02Range(emccuts.EMC_minM02, emccuts.EMC_maxM02); + fEMCCut.SetTimeRange(emccuts.EMC_minTime, emccuts.EMC_maxTime); + + fEMCCut.SetTrackMatchingEta([a, b, c](float pT) { return a + std::pow(pT + b, c); }); + fEMCCut.SetTrackMatchingPhi([d, e, f](float pT) { return d + std::pow(pT + e, f); }); + + fEMCCut.SetMinEoverP(emccuts.EMC_Eoverp); + fEMCCut.SetUseExoticCut(emccuts.EMC_UseExoticCut); + } + + void DefinePHOSCut() + { + fPHOSCut.SetEnergyRange(phoscuts.cfg_min_Ecluster, 1e+10); + } + + SliceCache cache; + Preslice perCollision_pcm = aod::v0photonkf::emeventId; + Preslice perCollision_emc = aod::emccluster::emeventId; + Preslice perCollision_phos = aod::phoscluster::emeventId; + + Preslice perCollision_electron = aod::emprimaryelectron::emeventId; + Partition positrons = o2::aod::emprimaryelectron::sign > int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt&& nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl&& o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); + Partition electrons = o2::aod::emprimaryelectron::sign < int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt && nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); + + using MyEMH = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrack>; + MyEMH* emh1 = nullptr; + MyEMH* emh2 = nullptr; + std::vector> used_photonIds; // + std::vector> used_dileptonIds; // + std::map, uint64_t> map_mixed_eventId_to_globalBC; + + template + void runPairing(TCollisions const& collisions, + TPhotons1 const& photons1, TPhotons2 const& photons2, + TSubInfos1 const& /*subinfos1*/, TSubInfos2 const& /*subinfos2*/, + TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, + TCut1 const& cut1, TCut2 const& cut2) + { + for (const auto& collision : collisions) { + initCCDB(collision); + int ndiphoton = 0; + + if (eventcuts.onlyKeepWeightedEvents && std::fabs(collision.weight() - 1.f) < 1e-10) { + continue; + } + + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, collision.weight()); + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, collision.weight()); + fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, collision.weight()); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, collision.weight()); // accepted + + int zbin = lower_bound(zvtx_bin_edges.begin(), zvtx_bin_edges.end(), collision.posZ()) - zvtx_bin_edges.begin() - 1; + if (zbin < 0) { + zbin = 0; + } else if (static_cast(zvtx_bin_edges.size()) - 2 < zbin) { + zbin = static_cast(zvtx_bin_edges.size()) - 2; + } + + float centrality = centralities[cfgCentEstimator]; + int centbin = lower_bound(cent_bin_edges.begin(), cent_bin_edges.end(), centrality) - cent_bin_edges.begin() - 1; + if (centbin < 0) { + centbin = 0; + } else if (static_cast(cent_bin_edges.size()) - 2 < centbin) { + centbin = static_cast(cent_bin_edges.size()) - 2; + } + + float ep2 = collision.ep2btot(); + int epbin = lower_bound(ep_bin_edges.begin(), ep_bin_edges.end(), ep2) - ep_bin_edges.begin() - 1; + if (epbin < 0) { + epbin = 0; + } else if (static_cast(ep_bin_edges.size()) - 2 < epbin) { + epbin = static_cast(ep_bin_edges.size()) - 2; + } + + int occbin = -1; + if (cfgOccupancyEstimator == 0) { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.ft0cOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } else if (cfgOccupancyEstimator == 1) { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.trackOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } else { + occbin = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.ft0cOccupancyInTimeRange()) - occ_bin_edges.begin() - 1; + } + + if (occbin < 0) { + occbin = 0; + } else if (static_cast(occ_bin_edges.size()) - 2 < occbin) { + occbin = static_cast(occ_bin_edges.size()) - 2; + } + + // LOGF(info, "collision.globalIndex() = %d, collision.posZ() = %f, centrality = %f, ep2 = %f, collision.trackOccupancyInTimeRange() = %d, zbin = %d, centbin = %d, epbin = %d, occbin = %d", collision.globalIndex(), collision.posZ(), centrality, ep2, collision.trackOccupancyInTimeRange(), zbin, centbin, epbin, occbin); + + std::tuple key_bin = std::make_tuple(zbin, centbin, epbin, occbin); + std::pair key_df_collision = std::make_pair(ndf, collision.globalIndex()); + + if constexpr (pairtype == PairType::kPCMDalitzEE) { + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); // PCM + auto positrons_per_collision = positrons->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); // positrons + auto electrons_per_collision = electrons->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); // electrons + + for (const auto& g1 : photons1_per_collision) { + if (!cut1.template IsSelected(g1)) { + continue; + } + auto pos1 = g1.template posTrack_as(); + auto ele1 = g1.template negTrack_as(); + ROOT::Math::PtEtaPhiMVector v_gamma(g1.pt(), g1.eta(), g1.phi(), 0.); + fRegistry.fill(HIST("Photon/hPt"), v_gamma.Pt(), collision.weight()); + fRegistry.fill(HIST("Photon/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight()); + + for (const auto& [pos2, ele2] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) { + + if (pos2.trackId() == ele2.trackId()) { // this is protection against pairing identical 2 tracks. + continue; + } + if (pos1.trackId() == pos2.trackId() || ele1.trackId() == ele2.trackId()) { + continue; + } + + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + continue; + } + + if (!cut2.IsSelectedPair(pos2, ele2, d_bz)) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v_pos(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ele(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ee = v_pos + v_ele; + ROOT::Math::PtEtaPhiMVector veeg = v_gamma + v_pos + v_ele; + fRegistry.fill(HIST("Pair/same/hMvsPt"), veeg.M(), v_gamma.Pt(), collision.weight()); + + std::pair pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex()); + std::tuple tuple_tmp_id2 = std::make_tuple(ndf, collision.globalIndex(), pos2.trackId(), ele2.trackId()); + if (std::find(used_photonIds.begin(), used_photonIds.end(), pair_tmp_id1) == used_photonIds.end()) { + emh1->AddTrackToEventPool(key_df_collision, EMTrack(-1, g1.globalIndex(), collision.globalIndex(), -1, g1.pt(), g1.eta(), g1.phi(), 0)); + used_photonIds.emplace_back(pair_tmp_id1); + } + if (std::find(used_dileptonIds.begin(), used_dileptonIds.end(), tuple_tmp_id2) == used_dileptonIds.end()) { + emh2->AddTrackToEventPool(key_df_collision, EMTrack(-1, -1, collision.globalIndex(), -1, v_ee.Pt(), v_ee.Eta(), v_ee.Phi(), v_ee.M())); + used_dileptonIds.emplace_back(tuple_tmp_id2); + } + ndiphoton++; + } // end of dielectron loop + } // end of g1 loop + } else { // PCM-EMC, PCM-PHOS. Not supported. + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); // PCM + auto photons2_per_collision = photons2.sliceBy(perCollision2, collision.globalIndex()); // EMC or PHOS + + for (const auto& [g1, g2] : combinations(CombinationsFullIndexPolicy(photons1_per_collision, photons2_per_collision))) { + if (!cut1.template IsSelected(g1) || !cut2.template IsSelected(g2)) { + continue; + } + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + + fRegistry.fill(HIST("Pair/same/hMvsPt"), v12.M(), v1.Pt(), collision.weight()); + + std::pair pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex()); + std::pair pair_tmp_id2 = std::make_pair(ndf, g2.globalIndex()); + + if (std::find(used_photonIds.begin(), used_photonIds.end(), pair_tmp_id1) == used_photonIds.end()) { + emh1->AddTrackToEventPool(key_df_collision, EMTrack(-1, g1.globalIndex(), collision.globalIndex(), -1, g1.pt(), g1.eta(), g1.phi(), 0)); + used_photonIds.emplace_back(pair_tmp_id1); + } + if (std::find(used_photonIds.begin(), used_photonIds.end(), pair_tmp_id2) == used_photonIds.end()) { + emh2->AddTrackToEventPool(key_df_collision, EMTrack(-1, g2.globalIndex(), collision.globalIndex(), -1, g2.pt(), g2.eta(), g2.phi(), 0)); + used_photonIds.emplace_back(pair_tmp_id2); + } + ndiphoton++; + } // end of pairing loop + } // end of pairing in same event + + // event mixing + if (!cfgDoMix || !(ndiphoton > 0)) { + continue; + } + + // make a vector of selected photons in this collision. + auto selected_photons1_in_this_event = emh1->GetTracksPerCollision(key_df_collision); + // auto selected_photons2_in_this_event = emh2->GetTracksPerCollision(key_df_collision); + + // auto collisionIds1_in_mixing_pool = emh1->GetCollisionIdsFromEventPool(key_bin); + auto collisionIds2_in_mixing_pool = emh2->GetCollisionIdsFromEventPool(key_bin); + + for (const auto& mix_dfId_collisionId : collisionIds2_in_mixing_pool) { + int mix_dfId = mix_dfId_collisionId.first; + int64_t mix_collisionId = mix_dfId_collisionId.second; + + if (collision.globalIndex() == mix_collisionId && ndf == mix_dfId) { // this never happens. only protection. + continue; + } + + auto globalBC_mix = map_mixed_eventId_to_globalBC[mix_dfId_collisionId]; + uint64_t diffBC = std::max(collision.globalBC(), globalBC_mix) - std::min(collision.globalBC(), globalBC_mix); + fRegistry.fill(HIST("Pair/mix/hDiffBC"), diffBC); + if (diffBC < ndiff_bc_mix) { + continue; + } + + auto photons2_from_event_pool = emh2->GetTracksPerCollision(mix_dfId_collisionId); + // LOGF(info, "Do event mixing: current event (%d, %d), ngamma = %d | event pool (%d, %d), nll = %d", ndf, collision.globalIndex(), selected_photons1_in_this_event.size(), mix_dfId, mix_collisionId, photons2_from_event_pool.size()); + + for (const auto& g1 : selected_photons1_in_this_event) { // [photon from event1, dilepton from event2] + for (const auto& g2 : photons2_from_event_pool) { + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + if constexpr (pairtype == PairType::kPCMDalitzEE) { + v2.SetM(g2.mass()); + } + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + fRegistry.fill(HIST("Pair/mix/hMvsPt"), v12.M(), v1.Pt(), collision.weight()); + } + } + } // end of loop over mixed event pool + + if (ndiphoton > 0) { + emh1->AddCollisionIdAtLast(key_bin, key_df_collision); + emh2->AddCollisionIdAtLast(key_bin, key_df_collision); + map_mixed_eventId_to_globalBC[key_df_collision] = collision.globalBC(); + } + + } // end of collision loop + } + + Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); + using FilteredMyCollisions = soa::Filtered; + + int ndf = 0; + void processAnalysis(FilteredMyCollisions const& collisions, Types const&... args) + { + // LOGF(info, "ndf = %d", ndf); + if constexpr (pairtype == PairType::kPCMDalitzEE) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + auto emprimaryelectrons = std::get<2>(std::tie(args...)); + // LOGF(info, "electrons.size() = %d, positrons.size() = %d", electrons.size(), positrons.size()); + runPairing(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDileptonCut); + } + // else if constexpr (pairtype == PairType::kPCMEMC) { + // auto v0photons = std::get<0>(std::tie(args...)); + // auto v0legs = std::get<1>(std::tie(args...)); + // auto emcclusters = std::get<2>(std::tie(args...)); + // auto emcmatchedtracks = std::get<3>(std::tie(args...)); + // runPairing(collisions, v0photons, emcclusters, v0legs, nullptr, perCollision_pcm, perCollision_emc, fV0PhotonCut, fEMCCut, emcmatchedtracks, nullptr); + // } else if constexpr (pairtype == PairType::kPCMPHOS) { + // auto v0photons = std::get<0>(std::tie(args...)); + // auto v0legs = std::get<1>(std::tie(args...)); + // auto phosclusters = std::get<2>(std::tie(args...)); + // runPairing(collisions, v0photons, phosclusters, v0legs, nullptr, perCollision_pcm, perCollision_phos, fV0PhotonCut, fPHOSCut, nullptr, nullptr); + // } + ndf++; + } + PROCESS_SWITCH(TaggingPi0, processAnalysis, "process pair analysis", false); + + void processDummy(MyCollisions const&) {} + PROCESS_SWITCH(TaggingPi0, processDummy, "Dummy function", true); +}; +#endif // PWGEM_PHOTONMESON_CORE_TAGGINGPI0_H_ diff --git a/PWGEM/PhotonMeson/Core/TaggingPi0MC.h b/PWGEM/PhotonMeson/Core/TaggingPi0MC.h new file mode 100644 index 00000000000..56c6274a141 --- /dev/null +++ b/PWGEM/PhotonMeson/Core/TaggingPi0MC.h @@ -0,0 +1,600 @@ +// 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. +// +// ======================== +// +// This code loops over photons and makes pairs for neutral mesons analyses. +// Please write to: daiki.sekihata@cern.ch + +#ifndef PWGEM_PHOTONMESON_CORE_TAGGINGPI0MC_H_ +#define PWGEM_PHOTONMESON_CORE_TAGGINGPI0MC_H_ + +#include +#include +#include + +#include "TF1.h" +#include "TString.h" +#include "Math/Vector4D.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" + +#include "DetectorsBase/GeometryManager.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/BasicCCDBManager.h" + +#include "Common/Core/RecoDecay.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" +#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" +#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" +#include "PWGEM/PhotonMeson/Utils/NMHistograms.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" +#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/Dilepton/Utils/MCUtilities.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::aod::pwgem::photonmeson::photonpair; +using namespace o2::aod::pwgem::photonmeson::utils::mcutil; +using namespace o2::aod::pwgem::dilepton::utils::mcutil; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyMCCollisions = soa::Join; +using MyMCCollision = MyMCCollisions::iterator; + +using MyV0Photons = soa::Join; +using MyV0Photon = MyV0Photons::iterator; + +using MyEMCClusters = soa::Join; +using MyEMCCluster = MyEMCClusters::iterator; + +using MyPHOSClusters = soa::Join; +using MyPHOSCluster = MyEMCClusters::iterator; + +using MyMCV0Legs = soa::Join; +using MyMCV0Leg = MyMCV0Legs::iterator; + +using MyMCElectrons = soa::Join; +using MyMCElectron = MyMCElectrons::iterator; + +template +struct TaggingPi0MC { + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; + Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; + + Configurable cfgQvecEstimator{"cfgQvecEstimator", 0, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999, "max. centrality"}; + Configurable fd_k0s_to_pi0{"fd_k0s_pi0", "1.0", "feed down correction to pi0"}; + Configurable cfgRequireTrueAssociation{"cfgRequireTrueAssociation", false, "flag to require true mc collision association"}; + ConfigurableAxis ConfPtBins{"ConfPtBins", {100, 0, 10}, "pT bins for output histograms"}; + + EMPhotonEventCut fEMEventCut; + struct : ConfigurableGroup { + std::string prefix = "eventcut_group"; + Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; + Configurable cfgRequireEMCReadoutInMB{"cfgRequireEMCReadoutInMB", false, "require the EMC to be read out in an MB collision (kTVXinEMC)"}; + Configurable cfgRequireEMCHardwareTriggered{"cfgRequireEMCHardwareTriggered", false, "require the EMC to be hardware triggered (kEMC7 or kDMC7)"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; + Configurable onlyKeepWeightedEvents{"onlyKeepWeightedEvents", false, "flag to keep only weighted events (for JJ MCs) and remove all MB events (with weight = 1)"}; + } eventcuts; + + V0PhotonCut fV0PhotonCut; + struct : ConfigurableGroup { + std::string prefix = "pcmcut_group"; + Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; + Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; + Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; + Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; + Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; + Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.8, "min eta for v0 photons at PV"}; + Configurable cfg_max_eta_v0{"cfg_max_eta_v0", 0.8, "max eta for v0 photons at PV"}; + Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; + Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; + Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; + Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.997, "min V0 CosPA"}; + Configurable cfg_max_pca{"cfg_max_pca", 3.0, "max distance btween 2 legs"}; + Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; + Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", true, "flag to select V0s with correct xz"}; + Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; + + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 10, "min ncluster tpc"}; + Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; + Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; + } pcmcuts; + + DalitzEECut fDileptonCut; + struct : ConfigurableGroup { + std::string prefix = "dileptoncut_group"; + Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; + Configurable cfg_max_mass{"cfg_max_mass", 0.1, "max mass"}; + Configurable cfg_apply_phiv{"cfg_apply_phiv", true, "flag to apply phiv cut"}; + Configurable cfg_require_itsib_any{"cfg_require_itsib_any", false, "flag to require ITS ib any hits"}; + Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; + Configurable cfg_phiv_slope{"cfg_phiv_slope", 0.0185, "slope for m vs. phiv"}; + Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.1, "min pT for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", 0.8, "max eta for single track"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; + Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 70, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 0.05, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.05, "max dca Z for single track in cm"}; + Configurable cfg_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1.5, "max DCA 3D in sigma"}; + + Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTOFif), "pid scheme [kTOFif : 0, kTPConly : 1]"}; + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -0.0, "min. TPC n sigma for pion exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +0.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + } dileptoncuts; + + EMCPhotonCut fEMCCut; + struct : ConfigurableGroup { + std::string prefix = "emccut_group"; + Configurable clusterDefinition{"clusterDefinition", "kV3Default", "Clusterizer to be selected, e.g. V3Default"}; + Configurable minOpenAngle{"minOpenAngle", 0.0202, "apply min opening angle"}; + Configurable EMC_minTime{"EMC_minTime", -20., "Minimum cluster time for EMCal time cut"}; + Configurable EMC_maxTime{"EMC_maxTime", +25., "Maximum cluster time for EMCal time cut"}; + Configurable EMC_minM02{"EMC_minM02", 0.1, "Minimum M02 for EMCal M02 cut"}; + Configurable EMC_maxM02{"EMC_maxM02", 0.7, "Maximum M02 for EMCal M02 cut"}; + Configurable EMC_minE{"EMC_minE", 0.7, "Minimum cluster energy for EMCal energy cut"}; + Configurable EMC_minNCell{"EMC_minNCell", 1, "Minimum number of cells per cluster for EMCal NCell cut"}; + Configurable> EMC_TM_Eta{"EMC_TM_Eta", {0.01f, 4.07f, -2.5f}, "|eta| <= [0]+(pT+[1])^[2] for EMCal track matching"}; + Configurable> EMC_TM_Phi{"EMC_TM_Phi", {0.015f, 3.65f, -2.f}, "|phi| <= [0]+(pT+[1])^[2] for EMCal track matching"}; + Configurable EMC_Eoverp{"EMC_Eoverp", 1.75, "Minimum cluster energy over track momentum for EMCal track matching"}; + Configurable EMC_UseExoticCut{"EMC_UseExoticCut", true, "FLag to use the EMCal exotic cluster cut"}; + } emccuts; + + PHOSPhotonCut fPHOSCut; + struct : ConfigurableGroup { + std::string prefix = "phoscut_group"; + Configurable cfg_min_Ecluster{"cfg_min_Ecluster", 0.3, "Minimum cluster energy for PHOS in GeV"}; + } phoscuts; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + static constexpr std::string_view event_types[2] = {"before/", "after/"}; + static constexpr std::string_view event_pair_types[2] = {"same/", "mix/"}; + static constexpr std::string_view parnames[2] = {"Pi0/", "Eta/"}; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber; + float d_bz; + TF1* f1fd_k0s_to_pi0; + + void init(InitContext&) + { + o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry); + addHistogrms(); + DefineEMEventCut(); + DefinePCMCut(); + DefineDileptonCut(); + DefineEMCCut(); + DefinePHOSCut(); + + mRunNumber = 0; + d_bz = 0; + f1fd_k0s_to_pi0 = new TF1("f1fd_k0s_to_pi0", TString(fd_k0s_to_pi0), 0.f, 100.f); + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + } + + template + void initCCDB(TCollision const& collision) + { + if (mRunNumber == collision.runNumber()) { + return; + } + + // In case override, don't proceed, please - no CCDB access required + if (d_bz_input > -990) { + d_bz = d_bz_input; + o2::parameters::GRPMagField grpmag; + if (std::fabs(d_bz) > 1e-5) { + grpmag.setL3Current(30000.f / (d_bz / 5.0f)); + } + mRunNumber = collision.runNumber(); + return; + } + + auto run3grp_timestamp = collision.timestamp(); + o2::parameters::GRPObject* grpo = 0x0; + o2::parameters::GRPMagField* grpmag = 0x0; + if (!skipGRPOquery) + grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + if (grpo) { + // Fetch magnetic field from ccdb for current collision + d_bz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + // Fetch magnetic field from ccdb for current collision + d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } + mRunNumber = collision.runNumber(); + } + + ~TaggingPi0MC() + { + delete f1fd_k0s_to_pi0; + f1fd_k0s_to_pi0 = 0x0; + } + + void addHistogrms() + { + TString mggTitle = "ee#gamma"; + if constexpr (pairtype == PairType::kPCMDalitzEE) { + mggTitle = "ee#gamma"; + } else { + mggTitle = "#gamma#gamma"; + } + + const AxisSpec axis_m{200, 0, 0.4, Form("m_{%s} (GeV/c^{2})", mggTitle.Data())}; + const AxisSpec axis_pt{ConfPtBins, "p_{T,#gamma} (GeV/c)"}; + + fRegistry.add("Photon/candidate/hPt", "photon candidates;p_{T,#gamma} (GeV/c)", kTH1D, {axis_pt}, true); // for purity + fRegistry.add("Photon/candidate/hEtaPhi", "#varphi vs. #eta;#varphi_{#gamma} (rad.);#eta_{#gamma}", kTH2D, {{90, 0, 2 * M_PI}, {40, -1, +1}}, true); // for purity + fRegistry.add("Photon/primary/hPt", "photon;p_{T,#gamma} (GeV/c)", kTH1D, {axis_pt}, true); // for purity + fRegistry.add("Photon/primary/hEtaPhi", "#varphi vs. #eta;#varphi_{#gamma} (rad.);#eta_{#gamma}", kTH2D, {{90, 0, 2 * M_PI}, {40, -1, +1}}, true); // for purity + fRegistry.addClone("Photon/primary/", "Photon/fromWD/"); // only for completeness + fRegistry.addClone("Photon/primary/", "Photon/fromHS/"); // only for completeness + fRegistry.addClone("Photon/primary/", "Photon/fromPi0/"); // for conditional acceptance, denominator + + fRegistry.add("Pair/primary/hMvsPt", "mass vs. p_{T,#gamma} from #pi^{0}", kTH2D, {axis_m, axis_pt}, true); // for conditional acceptance, numerator + fRegistry.addClone("Pair/primary/", "Pair/fromWD/"); // only for completeness + fRegistry.addClone("Pair/primary/", "Pair/fromHS/"); // only for completeness + } + + void DefineEMEventCut() + { + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); + fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); + fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); + fEMEventCut.SetRequireNoTFB(eventcuts.cfgRequireNoTFB); + fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); + fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); + fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); + fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + fEMEventCut.SetRequireEMCReadoutInMB(eventcuts.cfgRequireEMCReadoutInMB); + fEMEventCut.SetRequireEMCHardwareTriggered(eventcuts.cfgRequireEMCHardwareTriggered); + } + + void DefinePCMCut() + { + fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); + + // for v0 + fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, pcmcuts.cfg_max_pt_v0); + fV0PhotonCut.SetV0EtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); + fV0PhotonCut.SetMinCosPA(pcmcuts.cfg_min_cospa); + fV0PhotonCut.SetMaxPCA(pcmcuts.cfg_max_pca); + fV0PhotonCut.SetMaxChi2KF(pcmcuts.cfg_max_chi2kf); + fV0PhotonCut.SetRxyRange(pcmcuts.cfg_min_v0radius, pcmcuts.cfg_max_v0radius); + fV0PhotonCut.SetAPRange(pcmcuts.cfg_max_alpha_ap, pcmcuts.cfg_max_qt_ap); + fV0PhotonCut.RejectITSib(pcmcuts.cfg_reject_v0_on_itsib); + + // for track + fV0PhotonCut.SetMinNClustersTPC(pcmcuts.cfg_min_ncluster_tpc); + fV0PhotonCut.SetMinNCrossedRowsTPC(pcmcuts.cfg_min_ncrossedrows); + fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fV0PhotonCut.SetMaxFracSharedClustersTPC(pcmcuts.cfg_max_frac_shared_clusters_tpc); + fV0PhotonCut.SetChi2PerClusterTPC(0.0, pcmcuts.cfg_max_chi2tpc); + fV0PhotonCut.SetTPCNsigmaElRange(pcmcuts.cfg_min_TPCNsigmaEl, pcmcuts.cfg_max_TPCNsigmaEl); + fV0PhotonCut.SetChi2PerClusterITS(-1e+10, pcmcuts.cfg_max_chi2its); + fV0PhotonCut.SetNClustersITS(0, 7); + fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); + fV0PhotonCut.SetIsWithinBeamPipe(pcmcuts.cfg_require_v0_with_correct_xz); + fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); + fV0PhotonCut.SetDisableTPConly(pcmcuts.cfg_disable_tpconly_track); + fV0PhotonCut.SetRequireITSTPC(pcmcuts.cfg_require_v0_with_itstpc); + fV0PhotonCut.SetRequireITSonly(pcmcuts.cfg_require_v0_with_itsonly); + fV0PhotonCut.SetRequireTPConly(pcmcuts.cfg_require_v0_with_tpconly); + } + + void DefineDileptonCut() + { + fDileptonCut = DalitzEECut("fDileptonCut", "fDileptonCut"); + + // for pair + fDileptonCut.SetMeeRange(dileptoncuts.cfg_min_mass, dileptoncuts.cfg_max_mass); + fDileptonCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dileptoncuts.cfg_phiv_intercept) / dileptoncuts.cfg_phiv_slope; }); + fDileptonCut.ApplyPhiV(dileptoncuts.cfg_apply_phiv); + fDileptonCut.RequireITSibAny(dileptoncuts.cfg_require_itsib_any); + fDileptonCut.RequireITSib1st(dileptoncuts.cfg_require_itsib_1st); + + // for track + fDileptonCut.SetTrackPtRange(dileptoncuts.cfg_min_pt_track, 1e+10f); + fDileptonCut.SetTrackEtaRange(-dileptoncuts.cfg_max_eta_track, +dileptoncuts.cfg_max_eta_track); + fDileptonCut.SetMinNClustersTPC(dileptoncuts.cfg_min_ncluster_tpc); + fDileptonCut.SetMinNCrossedRowsTPC(dileptoncuts.cfg_min_ncrossedrows); + fDileptonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fDileptonCut.SetMaxFracSharedClustersTPC(dileptoncuts.cfg_max_frac_shared_clusters_tpc); + fDileptonCut.SetChi2PerClusterTPC(0.0, dileptoncuts.cfg_max_chi2tpc); + fDileptonCut.SetChi2PerClusterITS(0.0, dileptoncuts.cfg_max_chi2its); + fDileptonCut.SetNClustersITS(dileptoncuts.cfg_min_ncluster_its, 7); + fDileptonCut.SetMaxDcaXY(dileptoncuts.cfg_max_dcaxy); + fDileptonCut.SetMaxDcaZ(dileptoncuts.cfg_max_dcaz); + fDileptonCut.SetTrackDca3DRange(0.f, dileptoncuts.cfg_max_dca3dsigma_track); // in sigma + + // for eID + fDileptonCut.SetPIDScheme(dileptoncuts.cfg_pid_scheme); + fDileptonCut.SetTPCNsigmaElRange(dileptoncuts.cfg_min_TPCNsigmaEl, dileptoncuts.cfg_max_TPCNsigmaEl); + fDileptonCut.SetTPCNsigmaPiRange(dileptoncuts.cfg_min_TPCNsigmaPi, dileptoncuts.cfg_max_TPCNsigmaPi); + fDileptonCut.SetTOFNsigmaElRange(dileptoncuts.cfg_min_TOFNsigmaEl, dileptoncuts.cfg_max_TOFNsigmaEl); + } + + void DefineEMCCut() + { + const float a = emccuts.EMC_TM_Eta->at(0); + const float b = emccuts.EMC_TM_Eta->at(1); + const float c = emccuts.EMC_TM_Eta->at(2); + + const float d = emccuts.EMC_TM_Phi->at(0); + const float e = emccuts.EMC_TM_Phi->at(1); + const float f = emccuts.EMC_TM_Phi->at(2); + LOGF(info, "EMCal track matching parameters : a = %f, b = %f, c = %f, d = %f, e = %f, f = %f", a, b, c, d, e, f); + + fEMCCut = EMCPhotonCut("fEMCCut", "fEMCCut"); + + fEMCCut.SetClusterizer(emccuts.clusterDefinition); + fEMCCut.SetMinE(emccuts.EMC_minE); + fEMCCut.SetMinNCell(emccuts.EMC_minNCell); + fEMCCut.SetM02Range(emccuts.EMC_minM02, emccuts.EMC_maxM02); + fEMCCut.SetTimeRange(emccuts.EMC_minTime, emccuts.EMC_maxTime); + + fEMCCut.SetTrackMatchingEta([a, b, c](float pT) { return a + std::pow(pT + b, c); }); + fEMCCut.SetTrackMatchingPhi([d, e, f](float pT) { return d + std::pow(pT + e, f); }); + + fEMCCut.SetMinEoverP(emccuts.EMC_Eoverp); + fEMCCut.SetUseExoticCut(emccuts.EMC_UseExoticCut); + } + + void DefinePHOSCut() + { + fPHOSCut.SetEnergyRange(phoscuts.cfg_min_Ecluster, 1e+10); + } + + SliceCache cache; + Preslice perCollision_pcm = aod::v0photonkf::emeventId; + Preslice perCollision_emc = aod::emccluster::emeventId; + Preslice perCollision_phos = aod::phoscluster::emeventId; + + Preslice perCollision_electron = aod::emprimaryelectron::emeventId; + Partition positrons = o2::aod::emprimaryelectron::sign > int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt&& nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl&& o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); + Partition electrons = o2::aod::emprimaryelectron::sign < int8_t(0) && static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt && nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl); + + template + void runTruePairing(TCollisions const& collisions, + TPhotons1 const& photons1, TPhotons2 const& photons2, + TSubInfos1 const&, TSubInfos2 const&, + TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, + TCut1 const& cut1, TCut2 const& cut2, + TMCCollisions const&, TMCParticles const& mcparticles) + { + for (const auto& collision : collisions) { + initCCDB(collision); + + if (eventcuts.onlyKeepWeightedEvents && std::fabs(collision.weight() - 1.f) < 1e-10) { + continue; + } + + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, collision.weight()); + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, collision.weight()); + fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, collision.weight()); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, collision.weight()); // accepted + + if constexpr (pairtype == PairType::kPCMDalitzEE) { + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); + auto positrons_per_collision = positrons->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + auto electrons_per_collision = electrons->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + + for (const auto& g1 : photons1_per_collision) { + if (!cut1.template IsSelected(g1)) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v_gamma(g1.pt(), g1.eta(), g1.phi(), 0.f); + fRegistry.fill(HIST("Photon/candidate/hPt"), v_gamma.Pt(), collision.weight()); + fRegistry.fill(HIST("Photon/candidate/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight()); + + auto pos1 = g1.template posTrack_as(); + auto ele1 = g1.template negTrack_as(); + auto pos1mc = pos1.template emmcparticle_as(); + auto ele1mc = ele1.template emmcparticle_as(); + int photonid1 = FindCommonMotherFrom2Prongs(pos1mc, ele1mc, -11, 11, 22, mcparticles); + if (photonid1 < 0) { + continue; + } + auto g1mc = mcparticles.iteratorAt(photonid1); + + if (cfgRequireTrueAssociation && (g1mc.emmceventId() != collision.emmceventId())) { + continue; + } + + if (g1mc.isPhysicalPrimary() || g1mc.producedByGenerator()) { + fRegistry.fill(HIST("Photon/primary/hPt"), v_gamma.Pt(), collision.weight()); + fRegistry.fill(HIST("Photon/primary/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight()); + if (g1mc.has_mothers()) { + auto mp = g1mc.template mothers_first_as(); + if (std::abs(mp.pdgCode()) == 111) { + fRegistry.fill(HIST("Photon/fromPi0/hPt"), v_gamma.Pt(), collision.weight()); + fRegistry.fill(HIST("Photon/fromPi0/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight()); + } + } + } else if (IsFromWD(g1mc.template emmcevent_as(), g1mc, mcparticles) > 0) { + int motherid_strhad = IsFromWD(g1mc.template emmcevent_as(), g1mc, mcparticles); + auto str_had = mcparticles.iteratorAt(motherid_strhad); + float weight = 1.f; + if (std::abs(str_had.pdgCode()) == 310 && f1fd_k0s_to_pi0 != nullptr) { + weight = f1fd_k0s_to_pi0->Eval(str_had.pt()); + } + fRegistry.fill(HIST("Photon/fromWD/hPt"), v_gamma.Pt(), collision.weight() * weight); + fRegistry.fill(HIST("Photon/fromWD/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight() * weight); + } else { + fRegistry.fill(HIST("Photon/fromHS/hPt"), v_gamma.Pt(), collision.weight()); + fRegistry.fill(HIST("Photon/fromHS/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight()); + } + + for (const auto& [pos2, ele2] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) { // ULS + if (pos2.trackId() == ele2.trackId()) { // this is protection against pairing identical 2 tracks. + continue; + } + if (pos1.trackId() == pos2.trackId() || ele1.trackId() == ele2.trackId()) { + continue; + } + + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + continue; + } + + if (!cut2.IsSelectedPair(pos2, ele2, d_bz)) { + continue; + } + + auto pos2mc = mcparticles.iteratorAt(pos2.emmcparticleId()); + auto ele2mc = mcparticles.iteratorAt(ele2.emmcparticleId()); + int pi0id = FindCommonMotherFrom3Prongs(g1mc, pos2mc, ele2mc, 22, -11, 11, 111, mcparticles); + if (pi0id < 0) { + continue; + } + auto pi0mc = mcparticles.iteratorAt(pi0id); + if (cfgRequireTrueAssociation && (pi0mc.emmceventId() != collision.emmceventId())) { + continue; + } + ROOT::Math::PtEtaPhiMVector v_pos(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ele(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector veeg = v_gamma + v_pos + v_ele; + + if (pi0mc.isPhysicalPrimary() || pi0mc.producedByGenerator()) { + fRegistry.fill(HIST("Pair/primary/hMvsPt"), veeg.M(), v_gamma.Pt(), collision.weight()); + } else if (IsFromWD(pi0mc.template emmcevent_as(), pi0mc, mcparticles) > 0) { + int motherid_strhad = IsFromWD(pi0mc.template emmcevent_as(), pi0mc, mcparticles); + auto str_had = mcparticles.iteratorAt(motherid_strhad); + float weight = 1.f; + if (std::abs(str_had.pdgCode()) == 310 && f1fd_k0s_to_pi0 != nullptr) { + weight = f1fd_k0s_to_pi0->Eval(str_had.pt()); + } + fRegistry.fill(HIST("Pair/fromWD/hMvsPt"), veeg.M(), v_gamma.Pt(), collision.weight() * weight); + } else { + fRegistry.fill(HIST("Pair/fromHS/hMvsPt"), veeg.M(), v_gamma.Pt(), collision.weight()); + } + + } // end of dielectron loop + } // end of pcm loop + } else { // PCM-EMC, PCM-PHOS. Not supported. + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); + auto photons2_per_collision = photons2.sliceBy(perCollision2, collision.globalIndex()); + + for (const auto& [g1, g2] : combinations(CombinationsFullIndexPolicy(photons1_per_collision, photons2_per_collision))) { + if (!cut1.template IsSelected(g1) || !cut2.template IsSelected(g2)) { + continue; + } + // ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); + // ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + // ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + // if (pi0id > 0) { + // auto pi0mc = mcparticles.iteratorAt(pi0id); + // o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); + // } + } // end of pairing loop + } // end of pairing in same event + } // end of collision loop + } + + Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); + using FilteredMyCollisions = soa::Filtered; + + void processAnalysis(FilteredMyCollisions const& collisions, MyMCCollisions const& mccollisions, aod::EMMCParticles const& mcparticles, Types const&... args) + { + if constexpr (pairtype == PairType::kPCMDalitzEE) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + auto emprimaryelectrons = std::get<2>(std::tie(args...)); + // LOGF(info, "electrons.size() = %d, positrons.size() = %d", electrons.size(), positrons.size()); + runTruePairing(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDileptonCut, mccollisions, mcparticles); + } + // else if constexpr (pairtype == PairType::kPCMEMC) { + // auto v0photons = std::get<0>(std::tie(args...)); + // auto v0legs = std::get<1>(std::tie(args...)); + // auto emcclusters = std::get<2>(std::tie(args...)); + // auto emcmatchedtracks = std::get<3>(std::tie(args...)); + // runPairing(collisions, v0photons, emcclusters, v0legs, nullptr, perCollision_pcm, perCollision_emc, fV0PhotonCut, fEMCCut, emcmatchedtracks, nullptr); + // } else if constexpr (pairtype == PairType::kPCMPHOS) { + // auto v0photons = std::get<0>(std::tie(args...)); + // auto v0legs = std::get<1>(std::tie(args...)); + // auto phosclusters = std::get<2>(std::tie(args...)); + // runPairing(collisions, v0photons, phosclusters, v0legs, nullptr, perCollision_pcm, perCollision_phos, fV0PhotonCut, fPHOSCut, nullptr, nullptr); + // } + } + PROCESS_SWITCH(TaggingPi0MC, processAnalysis, "process pair analysis", false); + + void processDummy(MyCollisions const&) {} + PROCESS_SWITCH(TaggingPi0MC, processDummy, "Dummy function", true); +}; +#endif // PWGEM_PHOTONMESON_CORE_TAGGINGPI0MC_H_ diff --git a/PWGEM/PhotonMeson/Core/V0PhotonCut.cxx b/PWGEM/PhotonMeson/Core/V0PhotonCut.cxx index 94343e0104d..07d805fa291 100644 --- a/PWGEM/PhotonMeson/Core/V0PhotonCut.cxx +++ b/PWGEM/PhotonMeson/Core/V0PhotonCut.cxx @@ -229,14 +229,14 @@ void V0PhotonCut::SetRequireTPCTOF(bool flag) LOG(info) << "V0 Photon Cut, require TPC-TOF track: " << mRequireTPCTOF; } -void V0PhotonCut::SetRequireTPCTRDTOF(bool flag) -{ - mRequireTPCTRDTOF = flag; - LOG(info) << "V0 Photon Cut, require TPC-TOF track: " << mRequireTPCTRDTOF; -} - void V0PhotonCut::SetDisableITSonly(bool flag) { mDisableITSonly = flag; LOG(info) << "V0 Photon Cut, disable ITS only track: " << mDisableITSonly; } + +void V0PhotonCut::SetDisableTPConly(bool flag) +{ + mDisableTPConly = flag; + LOG(info) << "V0 Photon Cut, disable TPC only track: " << mDisableTPConly; +} diff --git a/PWGEM/PhotonMeson/Core/V0PhotonCut.h b/PWGEM/PhotonMeson/Core/V0PhotonCut.h index 345b388c3df..ac4ff278e4a 100644 --- a/PWGEM/PhotonMeson/Core/V0PhotonCut.h +++ b/PWGEM/PhotonMeson/Core/V0PhotonCut.h @@ -16,16 +16,18 @@ #ifndef PWGEM_PHOTONMESON_CORE_V0PHOTONCUT_H_ #define PWGEM_PHOTONMESON_CORE_V0PHOTONCUT_H_ -#include -#include -#include -#include -#include #include "Rtypes.h" -#include "TNamed.h" -#include "TMath.h" #include "PWGEM/PhotonMeson/Utils/TrackSelection.h" + +#include "TMath.h" +#include "TNamed.h" + +#include +#include +#include +#include +#include using namespace o2::pwgem::photonmeson; class V0PhotonCut : public TNamed @@ -70,7 +72,6 @@ class V0PhotonCut : public TNamed kRequireTPConly, kRequireTPCTRD, kRequireTPCTOF, - kRequireTPCTRDTOF, kNCuts }; @@ -150,6 +151,9 @@ class V0PhotonCut : public TNamed if (mDisableITSonly && isITSonlyTrack(track)) { return false; } + if (mDisableTPConly && isTPConlyTrack(track)) { + return false; + } if (mRejectITSib) { auto hits_ib = std::count_if(its_ib_Requirement.second.begin(), its_ib_Requirement.second.end(), [&](auto&& requiredLayer) { return track.itsClusterMap() & (1 << requiredLayer); }); @@ -195,9 +199,6 @@ class V0PhotonCut : public TNamed if (mRequireTPCTOF && !IsSelectedTrack(track, V0PhotonCuts::kRequireTPCTOF)) { return false; } - if (mRequireTPCTRDTOF && !IsSelectedTrack(track, V0PhotonCuts::kRequireTPCTRDTOF)) { - return false; - } } return true; } @@ -288,7 +289,7 @@ class V0PhotonCut : public TNamed return v0.chiSquareNDF() <= mMaxChi2KF; case V0PhotonCuts::kRZLine: - return v0.v0radius() > abs(v0.vz()) * std::tan(2 * std::atan(std::exp(-mMaxV0Eta))) - mMaxMarginZ; + return v0.v0radius() > std::fabs(v0.vz()) * std::tan(2 * std::atan(std::exp(-mMaxV0Eta))) - mMaxMarginZ; case V0PhotonCuts::kOnWwireIB: { const float margin_xy = 1.0; // cm @@ -297,9 +298,9 @@ class V0PhotonCut : public TNamed // const float rxy_max = 14.846; // cm // const float z_min = -17.56; // cm // const float z_max = +31.15; // cm - float x = abs(v0.vx()); // cm, measured secondary vertex of gamma->ee - float y = v0.vy(); // cm, measured secondary vertex of gamma->ee - float z = v0.vz(); // cm, measured secondary vertex of gamma->ee + float x = std::fabs(v0.vx()); // cm, measured secondary vertex of gamma->ee + float y = v0.vy(); // cm, measured secondary vertex of gamma->ee + float z = v0.vz(); // cm, measured secondary vertex of gamma->ee float rxy = sqrt(x * x + y * y); if (rxy < 7.0 || 14.0 < rxy) { @@ -311,7 +312,7 @@ class V0PhotonCut : public TNamed return false; } - float dxy = abs(1.0 * y - x * std::tan(-8.52 * TMath::DegToRad())) / sqrt(pow(1.0, 2) + pow(std::tan(-8.52 * TMath::DegToRad()), 2)); + float dxy = std::fabs(1.0 * y - x * std::tan(-8.52 * TMath::DegToRad())) / sqrt(pow(1.0, 2) + pow(std::tan(-8.52 * TMath::DegToRad()), 2)); return !(dxy > margin_xy); } case V0PhotonCuts::kOnWwireOB: { @@ -344,10 +345,10 @@ class V0PhotonCut : public TNamed { switch (cut) { case V0PhotonCuts::kTrackPtRange: - return track.pt() >= mMinTrackPt && track.pt() <= mMaxTrackPt; + return track.pt() > mMinTrackPt && track.pt() < mMaxTrackPt; case V0PhotonCuts::kTrackEtaRange: - return track.eta() >= mMinTrackEta && track.eta() <= mMaxTrackEta; + return track.eta() > mMinTrackEta && track.eta() < mMaxTrackEta; case V0PhotonCuts::kTPCNCls: return track.tpcNClsFound() >= mMinNClustersTPC; @@ -359,22 +360,22 @@ class V0PhotonCut : public TNamed return track.tpcCrossedRowsOverFindableCls() >= mMinNCrossedRowsOverFindableClustersTPC; case V0PhotonCuts::kTPCFracSharedClusters: - return track.tpcFractionSharedCls() <= mMaxFracSharedClustersTPC; + return track.tpcFractionSharedCls() < mMaxFracSharedClustersTPC; case V0PhotonCuts::kTPCChi2NDF: return mMinChi2PerClusterTPC < track.tpcChi2NCl() && track.tpcChi2NCl() < mMaxChi2PerClusterTPC; case V0PhotonCuts::kTPCNsigmaEl: - return track.tpcNSigmaEl() >= mMinTPCNsigmaEl && track.tpcNSigmaEl() <= mMaxTPCNsigmaEl; + return track.tpcNSigmaEl() > mMinTPCNsigmaEl && track.tpcNSigmaEl() < mMaxTPCNsigmaEl; case V0PhotonCuts::kTPCNsigmaPi: - return track.tpcNSigmaPi() >= mMinTPCNsigmaPi && track.tpcNSigmaPi() <= mMaxTPCNsigmaPi; + return track.tpcNSigmaPi() > mMinTPCNsigmaPi && track.tpcNSigmaPi() < mMaxTPCNsigmaPi; case V0PhotonCuts::kDCAxy: - return abs(track.dcaXY()) <= ((mMaxDcaXYPtDep) ? mMaxDcaXYPtDep(track.pt()) : mMaxDcaXY); + return std::fabs(track.dcaXY()) < ((mMaxDcaXYPtDep) ? mMaxDcaXYPtDep(track.pt()) : mMaxDcaXY); case V0PhotonCuts::kDCAz: - return abs(track.dcaZ()) <= mMaxDcaZ; + return std::fabs(track.dcaZ()) < mMaxDcaZ; case V0PhotonCuts::kITSNCls: return mMinNClustersITS <= track.itsNCls() && track.itsNCls() <= mMaxNClustersITS; @@ -397,13 +398,13 @@ class V0PhotonCut : public TNamed // if (abs(track.y()) > abs(track.x() * TMath::Tan(10.f * TMath::DegToRad())) + 15.f) { // return false; // } - if (track.x() < 0.1 && abs(track.y()) > 15.f) { + if (track.x() < 0.1 && std::fabs(track.y()) > 15.f) { return false; } - if (track.x() > 82.9 && abs(track.y()) > abs(track.x() * std::tan(10.f * TMath::DegToRad())) + 5.f) { + if (track.x() > 82.9 && std::fabs(track.y()) > std::fabs(track.x() * std::tan(10.f * TMath::DegToRad())) + 5.f) { return false; } - if (track.x() > 82.9 && abs(track.y()) < 15.0 && abs(abs(track.z()) - 44.5) < 2.5) { + if (track.x() > 82.9 && std::fabs(track.y()) < 15.0 && abs(abs(track.z()) - 44.5) < 2.5) { return false; } return true; @@ -426,9 +427,6 @@ class V0PhotonCut : public TNamed case V0PhotonCuts::kRequireTPCTOF: return isTPCTOFTrack(track); - case V0PhotonCuts::kRequireTPCTRDTOF: - return isTPCTRDTOFTrack(track); - default: return false; } @@ -474,8 +472,8 @@ class V0PhotonCut : public TNamed void SetRequireTPConly(bool flag); void SetRequireTPCTRD(bool flag); void SetRequireTPCTOF(bool flag); - void SetRequireTPCTRDTOF(bool flag); void SetDisableITSonly(bool flag); + void SetDisableTPConly(bool flag); private: static const std::pair> its_ib_Requirement; @@ -525,8 +523,8 @@ class V0PhotonCut : public TNamed bool mRequireTPConly{false}; bool mRequireTPCTRD{false}; bool mRequireTPCTOF{false}; - bool mRequireTPCTRDTOF{false}; bool mDisableITSonly{false}; + bool mDisableTPConly{false}; ClassDef(V0PhotonCut, 1); }; diff --git a/PWGEM/PhotonMeson/DataModel/bcWiseTables.h b/PWGEM/PhotonMeson/DataModel/bcWiseTables.h new file mode 100644 index 00000000000..a306d5645ce --- /dev/null +++ b/PWGEM/PhotonMeson/DataModel/bcWiseTables.h @@ -0,0 +1,159 @@ +// 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. +/// +/// \file bcWiseTables.h +/// +/// \brief This header provides the table definitions to store very lightweight EMCal clusters per BC +/// +/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) - Goethe University Frankfurt +/// + +#ifndef PWGEM_PHOTONMESON_DATAMODEL_BCWISETABLES_H_ +#define PWGEM_PHOTONMESON_DATAMODEL_BCWISETABLES_H_ + +#include "Framework/AnalysisDataModel.h" + +#include + +namespace o2::aod +{ + +namespace emdownscaling +{ +enum Observable { + kDefinition, + kEnergy, + kEta, + kPhi, + kNCells, + kM02, + kTime, + kFT0MCent, + kZVtx, + kFT0Amp, + kpT, + kMu, + kTimeSinceSOF, + nObservables +}; + +// Values in tables are stored in downscaled format to save disk space +const float downscalingFactors[nObservables]{ + 1E0, // Cluster definition + 1E3, // Cluster energy + 1E4, // Cluster eta + 1E4, // Cluster phi + 1E0, // Number of cells + 1E4, // M02 + 1E2, // Cluster time + 2E0, // FT0M centrality + 1E3, // Z-vertex position + 1E-1, // FT0M amplitude + 1E3, // MC pi0 pt + 1E5, // Mu + 5E-1}; // Time since start of fill (since ADJUST decleration) +} // namespace emdownscaling + +namespace bcwisebc +{ +DECLARE_SOA_COLUMN(HasFT0, hasFT0, bool); //! has_foundFT0() +DECLARE_SOA_COLUMN(HasTVX, hasTVX, bool); //! has the TVX trigger flag +DECLARE_SOA_COLUMN(HaskTVXinEMC, haskTVXinEMC, bool); //! kTVXinEMC +DECLARE_SOA_COLUMN(HasEMCCell, hasEMCCell, bool); //! at least one EMCal cell in the BC +DECLARE_SOA_COLUMN(StoredCentrality, storedCentrality, uint8_t); //! FT0M centrality (0-100) (x2) +DECLARE_SOA_COLUMN(StoredFT0MAmplitude, storedFT0MAmplitude, uint16_t); //! ft0a+c amplitude +DECLARE_SOA_COLUMN(StoredMu, storedMu, uint16_t); //! probability of TVX collision per BC (x1000) +DECLARE_SOA_COLUMN(StoredTimeSinceSOF, storedTimeSinceSOF, uint16_t); //! time since decreation of ADJUST in seconds (x2) + +DECLARE_SOA_DYNAMIC_COLUMN(Centrality, centrality, [](uint8_t storedcentrality) -> float { return std::nextafter(storedcentrality / emdownscaling::downscalingFactors[emdownscaling::kFT0MCent], std::numeric_limits::infinity()); }); //! Centrality (0-100) +DECLARE_SOA_DYNAMIC_COLUMN(FT0MAmplitude, ft0Amplitude, [](uint16_t storedFT0MAmplitude) -> float { return std::nextafter(storedFT0MAmplitude / emdownscaling::downscalingFactors[emdownscaling::kFT0Amp], std::numeric_limits::infinity()); }); //! FT0M amplitude +DECLARE_SOA_DYNAMIC_COLUMN(Mu, mu, [](uint16_t storedMu) -> float { return std::nextafter(storedMu / emdownscaling::downscalingFactors[emdownscaling::kMu], std::numeric_limits::infinity()); }); //! probability of TVX collision per BC +DECLARE_SOA_DYNAMIC_COLUMN(TimeSinceSOF, timeSinceSOF, [](uint16_t storedTimeSinceSOF) -> float { return std::nextafter(storedTimeSinceSOF / emdownscaling::downscalingFactors[emdownscaling::kTimeSinceSOF], std::numeric_limits::infinity()); }); //! probability of TVX collision per BC +} // namespace bcwisebc +DECLARE_SOA_TABLE(BCWiseBCs, "AOD", "BCWISEBC", //! table of bc wise centrality estimation and event selection input + o2::soa::Index<>, bcwisebc::HasFT0, bcwisebc::HasTVX, bcwisebc::HaskTVXinEMC, bcwisebc::HasEMCCell, bcwisebc::StoredCentrality, + bcwisebc::StoredFT0MAmplitude, bcwisebc::StoredMu, bcwisebc::StoredTimeSinceSOF, bcwisebc::Centrality, bcwisebc::FT0MAmplitude, bcwisebc::Mu, bcwisebc::TimeSinceSOF); + +DECLARE_SOA_INDEX_COLUMN(BCWiseBC, bcWiseBC); //! bunch crossing ID used as index + +namespace bcwisecollision +{ +DECLARE_SOA_COLUMN(StoredCentrality, storedCentrality, uint8_t); //! FT0M centrality (0-100) (x2) +DECLARE_SOA_COLUMN(StoredZVtx, storedZVtx, int16_t); //! Z-vertex position (x1000) + +DECLARE_SOA_DYNAMIC_COLUMN(Centrality, centrality, [](uint8_t storedcentrality) -> float { return std::nextafter(storedcentrality / emdownscaling::downscalingFactors[emdownscaling::kFT0MCent], std::numeric_limits::infinity()); }); //! Centrality (0-100) +DECLARE_SOA_DYNAMIC_COLUMN(ZVtx, zVtx, [](int16_t storedzvtx) -> float { return storedzvtx / emdownscaling::downscalingFactors[emdownscaling::kZVtx]; }); //! Centrality (0-100) +} // namespace bcwisecollision +DECLARE_SOA_TABLE(BCWiseCollisions, "AOD", "BCWISECOLL", //! table of skimmed EMCal clusters + o2::soa::Index<>, BCWiseBCId, bcwisecollision::StoredCentrality, bcwisecollision::StoredZVtx, + bcwisecollision::Centrality, bcwisecollision::ZVtx); + +namespace bcwisecluster +{ +DECLARE_SOA_COLUMN(StoredDefinition, storedDefinition, int8_t); //! cluster definition, see EMCALClusterDefinition.h +DECLARE_SOA_COLUMN(StoredE, storedE, int16_t); //! cluster energy (1 MeV -> Maximum cluster energy of ~32 GeV) +DECLARE_SOA_COLUMN(StoredEta, storedEta, int16_t); //! cluster pseudorapidity (x10,000) +DECLARE_SOA_COLUMN(StoredPhi, storedPhi, uint16_t); //! cluster azimuthal angle (x10 000) from 0 to 2pi +DECLARE_SOA_COLUMN(StoredNCells, storedNCells, int8_t); //! number of cells in cluster +DECLARE_SOA_COLUMN(StoredM02, storedM02, int16_t); //! shower shape long axis (x10 000) +DECLARE_SOA_COLUMN(StoredTime, storedTime, int16_t); //! cluster time (10 ps resolution) +DECLARE_SOA_COLUMN(StoredIsExotic, storedIsExotic, bool); //! flag to mark cluster as exotic + +DECLARE_SOA_DYNAMIC_COLUMN(Definition, definition, [](int8_t storedDefinition) -> int8_t { return storedDefinition; }); //! cluster definition, see EMCALClusterDefinition.h +DECLARE_SOA_DYNAMIC_COLUMN(E, e, [](int16_t storedE) -> float { return std::nextafter(storedE / emdownscaling::downscalingFactors[emdownscaling::kEnergy], std::numeric_limits::infinity()); }); //! cluster energy (GeV) +DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](int16_t storedEta) -> float { return std::nextafter(storedEta / emdownscaling::downscalingFactors[emdownscaling::kEta], std::numeric_limits::infinity()); }); //! cluster pseudorapidity +DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, [](uint16_t storedPhi) -> float { return std::nextafter(storedPhi / emdownscaling::downscalingFactors[emdownscaling::kPhi], std::numeric_limits::infinity()); }); //! cluster azimuthal angle (0 to 2pi) +DECLARE_SOA_DYNAMIC_COLUMN(NCells, nCells, [](int16_t storedNCells) -> int16_t { return storedNCells; }); //! number of cells in cluster +DECLARE_SOA_DYNAMIC_COLUMN(M02, m02, [](int16_t storedM02) -> float { return std::nextafter(storedM02 / emdownscaling::downscalingFactors[emdownscaling::kM02], std::numeric_limits::infinity()); }); //! shower shape long axis +DECLARE_SOA_DYNAMIC_COLUMN(Time, time, [](int16_t storedTime) -> float { return std::nextafter(storedTime / emdownscaling::downscalingFactors[emdownscaling::kTime], std::numeric_limits::infinity()); }); //! cluster time (ns) +DECLARE_SOA_DYNAMIC_COLUMN(IsExotic, isExotic, [](bool storedIsExotic) -> bool { return storedIsExotic; }); //! flag to mark cluster as exotic + +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float storedE, float storedEta) -> float { return storedE / emdownscaling::downscalingFactors[emdownscaling::kEnergy] / std::cosh(storedEta / emdownscaling::downscalingFactors[emdownscaling::kEta]); }); //! cluster pt, assuming m=0 (photons) +} // namespace bcwisecluster + +DECLARE_SOA_TABLE(BCWiseClusters, "AOD", "BCWISECLUSTER", //! table of skimmed EMCal clusters + o2::soa::Index<>, BCWiseBCId, bcwisecluster::StoredDefinition, bcwisecluster::StoredE, bcwisecluster::StoredEta, bcwisecluster::StoredPhi, bcwisecluster::StoredNCells, bcwisecluster::StoredM02, bcwisecluster::StoredTime, bcwisecluster::StoredIsExotic, + bcwisecluster::Definition, bcwisecluster::E, bcwisecluster::Eta, bcwisecluster::Phi, bcwisecluster::NCells, bcwisecluster::M02, bcwisecluster::Time, bcwisecluster::IsExotic, + bcwisecluster::Pt); + +namespace bcwisemcmesons +{ +DECLARE_SOA_COLUMN(StoredPt, storedPt, uint16_t); //! Transverse momentum of generated pi0 (1 MeV -> Maximum pi0 pT of ~65 GeV) +DECLARE_SOA_COLUMN(IsAccepted, isAccepted, bool); //! Both decay photons are within the EMCal acceptance +DECLARE_SOA_COLUMN(IsPrimary, isPrimary, bool); //! mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator() +DECLARE_SOA_COLUMN(IsFromWD, isFromWD, bool); //! Pi0 from a weak decay according to pwgem::photonmeson::utils::mcutil::IsFromWD + +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](uint16_t storedpt) -> float { return std::nextafter(storedpt / emdownscaling::downscalingFactors[emdownscaling::kpT], std::numeric_limits::infinity()); }); //! pT of pi0 (GeV) +} // namespace bcwisemcmesons + +DECLARE_SOA_TABLE(BCWiseMCPi0s, "AOD", "BCWISEMCPI0", //! table of pi0s on MC level + o2::soa::Index<>, BCWiseBCId, bcwisemcmesons::StoredPt, bcwisemcmesons::IsAccepted, bcwisemcmesons::IsPrimary, bcwisemcmesons::IsFromWD, + bcwisemcmesons::Pt); +DECLARE_SOA_TABLE(BCWiseMCEtas, "AOD", "BCWISEMCETA", //! table of eta mesons on MC level + o2::soa::Index<>, BCWiseBCId, bcwisemcmesons::StoredPt, bcwisemcmesons::IsAccepted, bcwisemcmesons::IsPrimary, bcwisemcmesons::IsFromWD, + bcwisemcmesons::Pt); + +namespace bcwisemccluster +{ +DECLARE_SOA_COLUMN(MesonID, mesonID, int32_t); //! Index of the mother mesom (-1 if not from a pi0 or eta) +DECLARE_SOA_COLUMN(IsEta, isEta, bool); //! Boolean flag to indicate if the cluster is from an eta meson, otherwise it is from a pi0 +DECLARE_SOA_COLUMN(StoredTrueE, storedTrueE, uint16_t); //! energy of cluster inducing particle (1 MeV -> Maximum cluster energy of ~65 GeV) + +DECLARE_SOA_DYNAMIC_COLUMN(TrueE, trueE, [](uint16_t storedTrueE) -> float { return std::nextafter(storedTrueE / emdownscaling::downscalingFactors[emdownscaling::kEnergy], std::numeric_limits::infinity()); }); //! energy of cluster inducing particle (GeV) +} // namespace bcwisemccluster + +DECLARE_SOA_TABLE(BCWiseMCClusters, "AOD", "BCWISEMCCLS", //! table of MC information for clusters -> To be joined with the cluster table + o2::soa::Index<>, BCWiseBCId, bcwisemccluster::MesonID, bcwisemccluster::IsEta, bcwisemccluster::StoredTrueE, + bcwisemccluster::TrueE); + +} // namespace o2::aod + +#endif // PWGEM_PHOTONMESON_DATAMODEL_BCWISETABLES_H_ diff --git a/PWGEM/PhotonMeson/DataModel/gammaTables.h b/PWGEM/PhotonMeson/DataModel/gammaTables.h index d81902b234f..308e27acd10 100644 --- a/PWGEM/PhotonMeson/DataModel/gammaTables.h +++ b/PWGEM/PhotonMeson/DataModel/gammaTables.h @@ -9,15 +9,21 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "Common/Core/RecoDecay.h" #include "Common/DataModel/CaloClusters.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include +#include -#include "PWGJE/DataModel/EMCALClusters.h" +#include +#include +#include +#include #ifndef PWGEM_PHOTONMESON_DATAMODEL_GAMMATABLES_H_ #define PWGEM_PHOTONMESON_DATAMODEL_GAMMATABLES_H_ @@ -117,6 +123,34 @@ DECLARE_SOA_COLUMN(IsMoved, isMoved, bool); //! moved by drift manager. r DECLARE_SOA_COLUMN(Px, px, float); //! Px at SV DECLARE_SOA_COLUMN(Py, py, float); //! Py at SV DECLARE_SOA_COLUMN(Pz, pz, float); //! Pz at SV + +DECLARE_SOA_COLUMN(DcaXYINT16, dcaXYINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(DcaZINT16, dcaZINT16, int16_t); //! -32768 - +32767 + +DECLARE_SOA_COLUMN(XUINT16, xUINT16, uint16_t); //! 0 - +65535 +DECLARE_SOA_COLUMN(YINT16, yINT16, int16_t); //! 0 - +65535 +DECLARE_SOA_COLUMN(ZINT16, zINT16, int16_t); //! -32768 - +32767 + +DECLARE_SOA_COLUMN(TPCSignalUINT16, tpcSignalUINT16, uint16_t); //! 0 - +65535 +DECLARE_SOA_COLUMN(DeDxTunedMcUINT16, mcTunedTPCSignalUINT16, uint16_t); //! 0 - +65535 +DECLARE_SOA_COLUMN(TPCChi2NClINT16, tpcChi2NClINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(ITSChi2NClINT16, itsChi2NClINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TPCNSigmaElINT16, tpcNSigmaElINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_COLUMN(TPCNSigmaPiINT16, tpcNSigmaPiINT16, int16_t); //! -32768 - +32767 +DECLARE_SOA_DYNAMIC_COLUMN(TPCSignal, tpcSignal, [](uint16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(DeDxTunedMc, mcTunedTPCSignal, [](uint16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCChi2NCl, tpcChi2NCl, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(ITSChi2NCl, itsChi2NCl, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaEl, tpcNSigmaEl, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPi, tpcNSigmaPi, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); + +DECLARE_SOA_DYNAMIC_COLUMN(X, x, [](uint16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(Y, y, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(Z, z, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); + +DECLARE_SOA_DYNAMIC_COLUMN(DcaXY, dcaXY, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(DcaZ, dcaZ, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); + DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float px, float py, float pz) -> float { return RecoDecay::sqrtSumOfSquares(px, py, pz); }); DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float px, float py) -> float { return RecoDecay::sqrtSumOfSquares(px, py); }); DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](float px, float py, float pz) -> float { return RecoDecay::eta(std::array{px, py, pz}); }); @@ -167,7 +201,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITSob, meanClusterSizeITSob, [](uint32 } }); } // namespace v0leg -DECLARE_SOA_TABLE(V0Legs, "AOD", "V0LEG", //! +DECLARE_SOA_TABLE(V0Legs_000, "AOD", "V0LEG", //! o2::soa::Index<>, v0leg::CollisionId, v0leg::TrackId, v0leg::Sign, v0leg::Px, v0leg::Py, v0leg::Pz, track::DcaXY, track::DcaZ, @@ -188,12 +222,51 @@ DECLARE_SOA_TABLE(V0Legs, "AOD", "V0LEG", //! track::TPCFoundOverFindableCls, track::TPCFractionSharedCls, track::v001::ITSClusterMap, track::v001::ITSNCls, track::v001::ITSNClsInnerBarrel, - track::HasITS, track::HasTPC, - track::HasTRD, track::HasTOF, + track::HasITS, track::HasTPC, track::HasTRD, track::HasTOF, v0leg::MeanClusterSizeITS, v0leg::MeanClusterSizeITSib, v0leg::MeanClusterSizeITSob); +DECLARE_SOA_TABLE_VERSIONED(V0Legs_001, "AOD", "V0LEG", 1, //! + o2::soa::Index<>, v0leg::CollisionId, v0leg::TrackId, v0leg::Sign, + v0leg::Px, v0leg::Py, v0leg::Pz, + v0leg::DcaXYINT16, v0leg::DcaZINT16, + track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, track::TPCNClsShared, + v0leg::TPCChi2NClINT16, track::TPCInnerParam, + v0leg::TPCSignalUINT16, v0leg::TPCNSigmaElINT16, v0leg::TPCNSigmaPiINT16, + track::ITSClusterSizes, v0leg::ITSChi2NClINT16, track::DetectorMap, v0leg::DeDxTunedMcUINT16, + v0leg::XUINT16, v0leg::YINT16, v0leg::ZINT16, track::Tgl, + + // dynamic column + v0leg::P, + v0leg::Pt, + v0leg::Eta, + v0leg::Phi, + v0leg::DcaXY, + v0leg::DcaZ, + + track::TPCNClsFound, + track::TPCNClsCrossedRows, + track::TPCCrossedRowsOverFindableCls, + track::TPCFoundOverFindableCls, + track::TPCFractionSharedCls, + track::v001::ITSClusterMap, track::v001::ITSNCls, track::v001::ITSNClsInnerBarrel, + track::HasITS, track::HasTPC, track::HasTRD, track::HasTOF, + v0leg::MeanClusterSizeITS, + v0leg::MeanClusterSizeITSib, + v0leg::MeanClusterSizeITSob, + v0leg::TPCSignal, + v0leg::DeDxTunedMc, + v0leg::TPCChi2NCl, + v0leg::ITSChi2NCl, + v0leg::TPCNSigmaEl, + v0leg::TPCNSigmaPi, + v0leg::X, + v0leg::Y, + v0leg::Z); + +using V0Legs = V0Legs_001; + // iterators using V0Leg = V0Legs::iterator; @@ -210,6 +283,20 @@ DECLARE_SOA_TABLE(EMEventsWeight, "AOD", "EMEVENTWEIGHT", //! table contanint th emevent::Weight); using EMEventWeight = EMEventsWeight::iterator; +namespace oldv0photonkf +{ +DECLARE_SOA_COLUMN(MGamma, mGamma, float); //! invariant mass of dielectron at SV +DECLARE_SOA_COLUMN(DCAxyToPV, dcaXYtopv, float); //! DCAxy of V0 to PV +DECLARE_SOA_COLUMN(DCAzToPV, dcaZtopv, float); //! DCAz of V0 to PV +DECLARE_SOA_COLUMN(CosPA, cospa, float); //! +DECLARE_SOA_COLUMN(CosPAXY, cospaXY, float); //! +DECLARE_SOA_COLUMN(CosPARZ, cospaRZ, float); //! +DECLARE_SOA_COLUMN(PCA, pca, float); //! +DECLARE_SOA_COLUMN(Alpha, alpha, float); //! +DECLARE_SOA_COLUMN(QtArm, qtarm, float); //! +DECLARE_SOA_COLUMN(ChiSquareNDF, chiSquareNDF, float); //! Chi2 / NDF of the reconstructed V0 +} // namespace oldv0photonkf + namespace v0photonkf { DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! @@ -223,20 +310,37 @@ DECLARE_SOA_COLUMN(Vz, vz, float); //! seco DECLARE_SOA_COLUMN(Px, px, float); //! px for photon kf DECLARE_SOA_COLUMN(Py, py, float); //! py for photon kf DECLARE_SOA_COLUMN(Pz, pz, float); //! pz for photon kf -DECLARE_SOA_COLUMN(MGamma, mGamma, float); //! invariant mass of dielectron at SV -DECLARE_SOA_COLUMN(DCAxyToPV, dcaXYtopv, float); //! DCAxy of V0 to PV -DECLARE_SOA_COLUMN(DCAzToPV, dcaZtopv, float); //! DCAz of V0 to PV -DECLARE_SOA_COLUMN(CosPA, cospa, float); //! -DECLARE_SOA_COLUMN(PCA, pca, float); //! -DECLARE_SOA_COLUMN(Alpha, alpha, float); //! -DECLARE_SOA_COLUMN(QtArm, qtarm, float); //! -DECLARE_SOA_COLUMN(ChiSquareNDF, chiSquareNDF, float); //! Chi2 / NDF of the reconstructed V0 -DECLARE_SOA_COLUMN(SigmaPx2, sigmaPx2, float); //! error^2 of px in covariant matrix -DECLARE_SOA_COLUMN(SigmaPy2, sigmaPy2, float); //! error^2 of py in covariant matrix -DECLARE_SOA_COLUMN(SigmaPz2, sigmaPz2, float); //! error^2 of pz in covariant matrix -DECLARE_SOA_COLUMN(SigmaPxPy, sigmaPxPy, float); //! error of px x py in covariant matrix -DECLARE_SOA_COLUMN(SigmaPyPz, sigmaPyPz, float); //! error of py x pz in covariant matrix -DECLARE_SOA_COLUMN(SigmaPzPx, sigmaPzPx, float); //! error of pz x px in covariant matrix +DECLARE_SOA_COLUMN(MGammaUINT16, mGammaUINT16, uint16_t); //! invariant mass of dielectron at SV + +DECLARE_SOA_COLUMN(DCAxyToPVINT16, dcaXYtopvINT16, int16_t); //! DCAxy of V0 to PV +DECLARE_SOA_COLUMN(DCAzToPVINT16, dcaZtopvINT16, int16_t); //! DCAz of V0 to PV +DECLARE_SOA_COLUMN(CosPAUINT16, cospaUINT16, uint16_t); //! cosine of pointing angle in 3D +DECLARE_SOA_COLUMN(CosPAXYUINT16, cospaXYUINT16, uint16_t); //! cosine of pointing angle in XY +DECLARE_SOA_COLUMN(CosPARZUINT16, cospaRZUINT16, uint16_t); //! cosine of pointing angle in RZ +DECLARE_SOA_COLUMN(PCAUINT16, pcaUINT16, uint16_t); //! distance between 2 legs at point of closest approach +DECLARE_SOA_COLUMN(AlphaINT16, alphaINT16, int16_t); //! longitudinal momentum asymmetry +DECLARE_SOA_COLUMN(QtArmUINT16, qtarmUINT16, uint16_t); //! qT +DECLARE_SOA_COLUMN(ChiSquareNDFUINT16, chiSquareNDFUINT16, uint16_t); //! Chi2 / NDF of the reconstructed V0 + +DECLARE_SOA_COLUMN(SigmaPx2, sigmaPx2, float); //! error^2 of px in covariant matrix +DECLARE_SOA_COLUMN(SigmaPy2, sigmaPy2, float); //! error^2 of py in covariant matrix +DECLARE_SOA_COLUMN(SigmaPz2, sigmaPz2, float); //! error^2 of pz in covariant matrix +DECLARE_SOA_COLUMN(SigmaPxPy, sigmaPxPy, float); //! error of px x py in covariant matrix +DECLARE_SOA_COLUMN(SigmaPyPz, sigmaPyPz, float); //! error of py x pz in covariant matrix +DECLARE_SOA_COLUMN(SigmaPzPx, sigmaPzPx, float); //! error of pz x px in covariant matrix +DECLARE_SOA_COLUMN(PrefilterBitDerived, pfbderived, uint16_t); //! + +DECLARE_SOA_DYNAMIC_COLUMN(DCAxyToPV, dcaXYtopv, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); +DECLARE_SOA_DYNAMIC_COLUMN(DCAzToPV, dcaZtopv, [](int16_t x) -> float { return static_cast(x) * 1e-2; }); + +DECLARE_SOA_DYNAMIC_COLUMN(MGamma, mGamma, [](uint16_t x) -> float { return static_cast(x) * 1e-5; }); +DECLARE_SOA_DYNAMIC_COLUMN(CosPA, cospa, [](uint16_t x) -> float { return static_cast(x) * 2e-5; }); +DECLARE_SOA_DYNAMIC_COLUMN(CosPAXY, cospaXY, [](uint16_t x) -> float { return static_cast(x) * 2e-5; }); +DECLARE_SOA_DYNAMIC_COLUMN(CosPARZ, cospaRZ, [](uint16_t x) -> float { return static_cast(x) * 2e-5; }); +DECLARE_SOA_DYNAMIC_COLUMN(PCA, pca, [](uint16_t x) -> float { return static_cast(x) * 1e-4; }); +DECLARE_SOA_DYNAMIC_COLUMN(Alpha, alpha, [](int16_t x) -> float { return static_cast(x) * 1e-4; }); +DECLARE_SOA_DYNAMIC_COLUMN(QtArm, qtarm, [](uint16_t x) -> float { return static_cast(x) * 1e-5; }); +DECLARE_SOA_DYNAMIC_COLUMN(ChiSquareNDF, chiSquareNDF, [](uint16_t x) -> float { return static_cast(x) * 1e-1; }); DECLARE_SOA_DYNAMIC_COLUMN(E, e, [](float px, float py, float pz, float m = 0) -> float { return RecoDecay::sqrtSumOfSquares(px, py, pz, m); }); //! energy of v0 photn, mass to be given as argument when getter is called! DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float px, float py) -> float { return RecoDecay::sqrtSumOfSquares(px, py); }); @@ -245,15 +349,15 @@ DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, [](float px, float py) -> float { return Re DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float px, float py, float pz) -> float { return RecoDecay::sqrtSumOfSquares(px, py, pz); }); DECLARE_SOA_DYNAMIC_COLUMN(V0Radius, v0radius, [](float vx, float vy) -> float { return RecoDecay::sqrtSumOfSquares(vx, vy); }); } // namespace v0photonkf -DECLARE_SOA_TABLE(V0PhotonsKF, "AOD", "V0PHOTONKF", //! +DECLARE_SOA_TABLE(V0PhotonsKF_000, "AOD", "V0PHOTONKF", //! o2::soa::Index<>, v0photonkf::CollisionId, v0photonkf::V0Id, v0photonkf::PosTrackId, v0photonkf::NegTrackId, v0photonkf::Vx, v0photonkf::Vy, v0photonkf::Vz, v0photonkf::Px, v0photonkf::Py, v0photonkf::Pz, - v0photonkf::MGamma, - v0photonkf::DCAxyToPV, v0photonkf::DCAzToPV, - v0photonkf::CosPA, v0photonkf::PCA, - v0photonkf::Alpha, v0photonkf::QtArm, - v0photonkf::ChiSquareNDF, + oldv0photonkf::MGamma, + oldv0photonkf::DCAxyToPV, oldv0photonkf::DCAzToPV, + oldv0photonkf::CosPA, oldv0photonkf::CosPAXY, oldv0photonkf::CosPARZ, oldv0photonkf::PCA, + oldv0photonkf::Alpha, oldv0photonkf::QtArm, + oldv0photonkf::ChiSquareNDF, // dynamic column v0photonkf::E, @@ -262,6 +366,38 @@ DECLARE_SOA_TABLE(V0PhotonsKF, "AOD", "V0PHOTONKF", //! v0photonkf::Phi, v0photonkf::P, v0photonkf::V0Radius); + +DECLARE_SOA_TABLE_VERSIONED(V0PhotonsKF_001, "AOD", "V0PHOTONKF", 1, //! + o2::soa::Index<>, v0photonkf::CollisionId, v0photonkf::V0Id, v0photonkf::PosTrackId, v0photonkf::NegTrackId, + v0photonkf::Vx, v0photonkf::Vy, v0photonkf::Vz, + v0photonkf::Px, v0photonkf::Py, v0photonkf::Pz, + v0photonkf::MGammaUINT16, + v0photonkf::DCAxyToPVINT16, v0photonkf::DCAzToPVINT16, + v0photonkf::CosPAUINT16, v0photonkf::CosPAXYUINT16, v0photonkf::CosPARZUINT16, v0photonkf::PCAUINT16, + v0photonkf::AlphaINT16, v0photonkf::QtArmUINT16, + v0photonkf::ChiSquareNDFUINT16, + + // dynamic column + v0photonkf::E, + v0photonkf::Pt, + v0photonkf::Eta, + v0photonkf::Phi, + v0photonkf::P, + v0photonkf::V0Radius, + + v0photonkf::MGamma, + v0photonkf::DCAxyToPV, + v0photonkf::DCAzToPV, + v0photonkf::CosPA, + v0photonkf::CosPAXY, + v0photonkf::CosPARZ, + v0photonkf::PCA, + v0photonkf::Alpha, + v0photonkf::QtArm, + v0photonkf::ChiSquareNDF); + +using V0PhotonsKF = V0PhotonsKF_001; + // iterators using V0PhotonKF = V0PhotonsKF::iterator; @@ -274,14 +410,19 @@ DECLARE_SOA_TABLE(V0PhotonsKFCov, "AOD", "V0PHOTONKFCOV", //! To be joined with // iterators using V0PhotonKFCov = V0PhotonsKFCov::iterator; -DECLARE_SOA_TABLE(EMPrimaryElectronsFromDalitz, "AOD", "EMPRIMARYELDA", //! +DECLARE_SOA_TABLE(V0PhotonsKFPrefilterBitDerived, "AOD", "V0PHOTONKFPFBPI0", v0photonkf::PrefilterBitDerived); // To be joined with V0PhotonsKF table at analysis level. +// iterators +using V0PhotonKFPrefilterBitDerived = V0PhotonsKFPrefilterBitDerived::iterator; + +DECLARE_SOA_TABLE(EMPrimaryElectronsFromDalitz_000, "AOD", "EMPRIMARYELDA", //! o2::soa::Index<>, emprimaryelectron::CollisionId, emprimaryelectron::TrackId, emprimaryelectron::Sign, - track::Pt, track::Eta, track::Phi, track::DcaXY, track::DcaZ, - track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, + track::Pt, track::Eta, track::Phi, track::DcaXY, track::DcaZ, track::CYY, track::CZY, track::CZZ, + track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, track::TPCNClsShared, track::TPCChi2NCl, track::TPCInnerParam, track::TPCSignal, pidtpc::TPCNSigmaEl, pidtpc::TPCNSigmaPi, - track::ITSClusterSizes, track::ITSChi2NCl, track::DetectorMap, track::Tgl, + pidtofbeta::Beta, pidtof::TOFNSigmaEl, pidtof::TOFNSigmaPi, + track::ITSClusterSizes, track::ITSChi2NCl, track::TOFChi2, track::DetectorMap, track::Tgl, // dynamic column track::TPCNClsFound, @@ -289,6 +430,7 @@ DECLARE_SOA_TABLE(EMPrimaryElectronsFromDalitz, "AOD", "EMPRIMARYELDA", //! track::TPCCrossedRowsOverFindableCls, track::TPCFoundOverFindableCls, track::v001::ITSClusterMap, track::v001::ITSNCls, track::v001::ITSNClsInnerBarrel, + track::TPCFractionSharedCls, track::HasITS, track::HasTPC, track::HasTRD, track::HasTOF, emprimaryelectron::Signed1Pt, @@ -299,6 +441,59 @@ DECLARE_SOA_TABLE(EMPrimaryElectronsFromDalitz, "AOD", "EMPRIMARYELDA", //! emprimaryelectron::MeanClusterSizeITS, emprimaryelectron::MeanClusterSizeITSib, emprimaryelectron::MeanClusterSizeITSob); + +DECLARE_SOA_TABLE_VERSIONED(EMPrimaryElectronsFromDalitz_001, "AOD", "EMPRIMARYELDA", 1, //! + o2::soa::Index<>, emprimaryelectron::CollisionId, + emprimaryelectron::TrackId, emprimaryelectron::Sign, + track::Pt, track::Eta, track::Phi, track::DcaXY, track::DcaZ, track::CYY, track::CZY, track::CZZ, + + // track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, track::TPCNClsShared, + // track::TPCChi2NCl, track::TPCInnerParam, + // track::TPCSignal, pidtpc::TPCNSigmaEl, pidtpc::TPCNSigmaPi, + // pidtofbeta::Beta, pidtof::TOFNSigmaEl, pidtof::TOFNSigmaPi, + // track::ITSClusterSizes, track::ITSChi2NCl, track::TOFChi2, track::DetectorMap, track::Tgl, + + track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, track::TPCNClsShared, + emprimaryelectron::TPCChi2NClINT16, track::TPCInnerParam, + emprimaryelectron::TPCSignalUINT16, emprimaryelectron::TPCNSigmaElINT16, emprimaryelectron::TPCNSigmaPiINT16, + emprimaryelectron::BetaINT16, emprimaryelectron::TOFNSigmaElINT16, emprimaryelectron::TOFNSigmaPiINT16, + track::ITSClusterSizes, + emprimaryelectron::ITSChi2NClINT16, emprimaryelectron::TOFChi2INT16, track::DetectorMap, track::Tgl, + emprimaryelectron::DeDxTunedMcUINT16, + + // dynamic column + track::TPCNClsFound, + track::TPCNClsCrossedRows, + track::TPCCrossedRowsOverFindableCls, + track::TPCFoundOverFindableCls, + track::v001::ITSClusterMap, track::v001::ITSNCls, track::v001::ITSNClsInnerBarrel, + track::TPCFractionSharedCls, + track::HasITS, track::HasTPC, + track::HasTRD, track::HasTOF, + + emprimaryelectron::TPCSignal, + emprimaryelectron::TPCChi2NCl, + emprimaryelectron::ITSChi2NCl, + emprimaryelectron::DeDxTunedMc, + emprimaryelectron::Beta, + emprimaryelectron::TOFChi2, + + emprimaryelectron::TPCNSigmaEl, + emprimaryelectron::TPCNSigmaPi, + emprimaryelectron::TOFNSigmaEl, + emprimaryelectron::TOFNSigmaPi, + + emprimaryelectron::Signed1Pt, + emprimaryelectron::P, + emprimaryelectron::Px, + emprimaryelectron::Py, + emprimaryelectron::Pz, + emprimaryelectron::MeanClusterSizeITS, + emprimaryelectron::MeanClusterSizeITSib, + emprimaryelectron::MeanClusterSizeITSob); + +using EMPrimaryElectronsFromDalitz = EMPrimaryElectronsFromDalitz_001; + // iterators using EMPrimaryElectronFromDalitz = EMPrimaryElectronsFromDalitz::iterator; @@ -453,16 +648,16 @@ DECLARE_SOA_COLUMN(Time, time, float); DECLARE_SOA_COLUMN(IsExotic, isExotic, bool); //! flag to mark cluster as exotic DECLARE_SOA_COLUMN(Definition, definition, int); //! cluster definition, see EMCALClusterDefinition.h DECLARE_SOA_ARRAY_INDEX_COLUMN(Track, track); //! TrackIds -DECLARE_SOA_COLUMN(TrackEta, tracketa, std::vector); //! eta values of the matched tracks -DECLARE_SOA_COLUMN(TrackPhi, trackphi, std::vector); //! phi values of the matched tracks +DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, std::vector); //! phi values of the matched tracks +DECLARE_SOA_COLUMN(DeltaEta, deltaEta, std::vector); //! eta values of the matched tracks DECLARE_SOA_COLUMN(TrackP, trackp, std::vector); //! momentum values of the matched tracks DECLARE_SOA_COLUMN(TrackPt, trackpt, std::vector); //! pt values of the matched tracks DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float e, float eta, float m = 0) -> float { return sqrt(e * e - m * m) / cosh(eta); }); //! cluster pt, mass to be given as argument when getter is called! } // namespace emccluster -DECLARE_SOA_TABLE(SkimEMCClusters, "AOD", "SKIMEMCCLUSTERS", //! table of skimmed EMCal clusters +DECLARE_SOA_TABLE(SkimEMCClusters, "AOD", "SKIMEMCCLUSTER", //! table of skimmed EMCal clusters o2::soa::Index<>, skimmedcluster::CollisionId, emccluster::Definition, skimmedcluster::E, skimmedcluster::Eta, skimmedcluster::Phi, - skimmedcluster::M02, skimmedcluster::NCells, skimmedcluster::Time, emccluster::IsExotic, emccluster::TrackEta, - emccluster::TrackPhi, emccluster::TrackP, emccluster::TrackPt, emccluster::Pt); + skimmedcluster::M02, skimmedcluster::NCells, skimmedcluster::Time, emccluster::IsExotic, emccluster::DeltaPhi, + emccluster::DeltaEta, emccluster::TrackP, emccluster::TrackPt, emccluster::Pt); using SkimEMCCluster = SkimEMCClusters::iterator; DECLARE_SOA_TABLE(EMCEMEventIds, "AOD", "EMCEMEVENTID", emccluster::EMEventId); // To be joined with SkimEMCClusters table at analysis level. @@ -514,42 +709,11 @@ namespace caloextra { DECLARE_SOA_INDEX_COLUMN_FULL(Cluster, cluster, int, SkimEMCClusters, ""); //! reference to the gamma in the skimmed EMCal table DECLARE_SOA_INDEX_COLUMN_FULL(Cell, cell, int, Calos, ""); //! reference to the gamma in the skimmed EMCal table -// DECLARE_SOA_INDEX_COLUMN(Track, track); //! TrackID -DECLARE_SOA_COLUMN(TrackEta, tracketa, float); //! eta of the matched track -DECLARE_SOA_COLUMN(TrackPhi, trackphi, float); //! phi of the matched track -DECLARE_SOA_COLUMN(TrackP, trackp, float); //! momentum of the matched track -DECLARE_SOA_COLUMN(TrackPt, trackpt, float); //! pt of the matched track } // namespace caloextra DECLARE_SOA_TABLE(SkimEMCCells, "AOD", "SKIMEMCCELLS", //! table of link between skimmed EMCal clusters and their cells o2::soa::Index<>, caloextra::ClusterId, caloextra::CellId); //! using SkimEMCCell = SkimEMCCells::iterator; - -DECLARE_SOA_TABLE(SkimEMCMTs, "AOD", "SKIMEMCMTS", //! table of link between skimmed EMCal clusters and their matched tracks - o2::soa::Index<>, caloextra::ClusterId, caloextra::TrackEta, - caloextra::TrackPhi, caloextra::TrackP, caloextra::TrackPt); -using SkimEMCMT = SkimEMCMTs::iterator; - -namespace gammareco -{ -DECLARE_SOA_COLUMN(Method, method, int); //! cut bit for PCM photon candidates -DECLARE_SOA_INDEX_COLUMN_FULL(SkimmedPCM, skimmedPCM, int, V0PhotonsKF, ""); //! reference to the gamma in the skimmed PCM table -DECLARE_SOA_INDEX_COLUMN_FULL(SkimmedPHOS, skimmedPHOS, int, PHOSClusters, ""); //! reference to the gamma in the skimmed PHOS table -DECLARE_SOA_INDEX_COLUMN_FULL(SkimmedEMC, skimmedEMC, int, SkimEMCClusters, ""); //! reference to the gamma in the skimmed EMCal table -DECLARE_SOA_COLUMN(PCMCutBit, pcmcutbit, uint64_t); //! cut bit for PCM photon candidates -DECLARE_SOA_COLUMN(PHOSCutBit, phoscutbit, uint64_t); //! cut bit for PHOS photon candidates -DECLARE_SOA_COLUMN(EMCCutBit, emccutbit, uint64_t); //! cut bit for EMCal photon candidates -} // namespace gammareco -DECLARE_SOA_TABLE(SkimGammas, "AOD", "SKIMGAMMAS", //! table of all gamma candidates (PCM, EMCal and PHOS) after cuts - o2::soa::Index<>, skimmedcluster::CollisionId, gammareco::Method, - skimmedcluster::E, skimmedcluster::Eta, skimmedcluster::Phi, - gammareco::SkimmedEMCId, gammareco::SkimmedPHOSId); -DECLARE_SOA_TABLE(SkimPCMCuts, "AOD", "SKIMPCMCUTS", //! table of link between skimmed PCM photon candidates and their cuts - o2::soa::Index<>, gammareco::SkimmedPCMId, gammareco::PCMCutBit); //! -DECLARE_SOA_TABLE(SkimPHOSCuts, "AOD", "SKIMPHOSCUTS", //! table of link between skimmed PHOS photon candidates and their cuts - o2::soa::Index<>, gammareco::SkimmedPHOSId, gammareco::PHOSCutBit); //! -DECLARE_SOA_TABLE(SkimEMCCuts, "AOD", "SKIMEMCCUTS", //! table of link between skimmed EMCal photon candidates and their cuts - o2::soa::Index<>, gammareco::SkimmedEMCId, gammareco::EMCCutBit); //! } // namespace o2::aod #endif // PWGEM_PHOTONMESON_DATAMODEL_GAMMATABLES_H_ diff --git a/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt b/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt index 7d58cb0cb7c..a4cf2e6b566 100644 --- a/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt +++ b/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt @@ -31,7 +31,7 @@ o2physics_add_dpl_workflow(create-pcm o2physics_add_dpl_workflow(create-emevent-photon SOURCES createEMEventPhoton.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGJECore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(associate-mc-info-photon @@ -44,6 +44,11 @@ o2physics_add_dpl_workflow(skimmer-gamma-calo PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(bc-wise-cluster-skimmer + SOURCES bcWiseClusterSkimmer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2Physics::AnalysisCCDB O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(skimmer-phos SOURCES skimmerPHOS.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::PHOSBase @@ -58,13 +63,3 @@ o2physics_add_dpl_workflow(skimmer-dalitz-ee SOURCES skimmerDalitzEE.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(gamma-table-producer - SOURCES gammaSelection.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(produce-meson-calo - SOURCES produceMesonCalo.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore - COMPONENT_NAME Analysis) diff --git a/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx b/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx index 257450cce99..2fafc5118e3 100644 --- a/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx +++ b/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx @@ -8,11 +8,16 @@ // 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. -// -// ======================== -// -// This code produces reduced events for photon analyses. -// Please write to: daiki.sekihata@cern.ch +/// +/// \file associateMCinfoPhoton.cxx +/// +/// \brief This code produces reduced events for photon analyses +/// +/// \author Daiki Sekihata (daiki.sekihata@cern.ch) +/// + +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -28,7 +33,7 @@ using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::aod::pwgem::photonmeson::utils::mcutil; -using MyCollisionsMC = soa::Join; +using MyCollisionsMC = soa::Join; using TracksMC = soa::Join; using FwdTracksMC = soa::Join; using MyEMCClusters = soa::Join; @@ -48,18 +53,18 @@ struct AssociateMCInfoPhoton { Produces emprimaryelectronmclabels; Produces ememcclustermclabels; - Produces binned_gen_pt; + Produces binnedGenPt; - Configurable applyEveSel_at_skimming{"applyEveSel_at_skimming", false, "flag to apply minimal event selection at the skimming level"}; Configurable max_eta_gen_secondary{"max_eta_gen_secondary", 0.9, "max eta to store generated information"}; Configurable margin_z_gen{"margin_z_gen", 15.f, "margin for Z of true photon conversion point to store generated information"}; Configurable max_rxy_gen{"max_rxy_gen", 100, "max rxy to store generated information"}; + Configurable requireGammaGammaDecay{"requireGammaGammaDecay", false, "require gamma gamma decay for generated pi0 and eta meson"}; HistogramRegistry registry{"EMMCEvent"}; void init(o2::framework::InitContext&) { - auto hEventCounter = registry.add("hEventCounter", "hEventCounter", kTH1I, {{6, 0.5f, 6.5f}}); + auto hEventCounter = registry.add("hEventCounter", "hEventCounter", kTH1F, {{6, 0.5f, 6.5f}}); hEventCounter->GetXaxis()->SetBinLabel(1, "all"); hEventCounter->GetXaxis()->SetBinLabel(2, "has mc collision"); @@ -77,15 +82,15 @@ struct AssociateMCInfoPhoton { for (int i = 61; i < 72; i++) { ptbins.emplace_back(1.0 * (i - 61) + 10.0); // from 10 to 20 GeV/c, every 1 GeV/c } - const AxisSpec axis_pt{ptbins, "p_{T} (GeV/c)"}; - const AxisSpec axis_rapidity{{0.0, +0.8, +0.9}, "rapidity |y|"}; + const AxisSpec axisPt{ptbins, "p_{T} (GeV/c)"}; + const AxisSpec axisRapidity{{0.0, +0.8, +0.9}, "rapidity |y|"}; - static constexpr std::string_view parnames[9] = { + static constexpr std::string_view ParticleNames[9] = { "Gamma", "Pi0", "Eta", "Omega", "Phi", "ChargedPion", "ChargedKaon", "K0S", "Lambda"}; for (int i = 0; i < 9; i++) { - registry.add(Form("Generated/h2PtY_%s", parnames[i].data()), Form("Generated %s", parnames[i].data()), kTH2F, {axis_pt, axis_rapidity}, true); + registry.add(Form("Generated/h2PtY_%s", ParticleNames[i].data()), Form("Generated %s", ParticleNames[i].data()), kTH2F, {axisPt, axisRapidity}, true); } // reserve space for generated vectors if that process enabled @@ -97,17 +102,17 @@ struct AssociateMCInfoPhoton { } Preslice perMcCollision = aod::mcparticle::mcCollisionId; - Preslice perCollision_pcm = aod::v0photonkf::collisionId; - Preslice perCollision_el = aod::emprimaryelectron::collisionId; - Preslice perCollision_phos = aod::skimmedcluster::collisionId; - Preslice perCollision_emc = aod::skimmedcluster::collisionId; + Preslice perCollisionPCM = aod::v0photonkf::collisionId; + Preslice perCollisionEl = aod::emprimaryelectron::collisionId; + Preslice perCollisionPHOS = aod::skimmedcluster::collisionId; + Preslice perCollisionEMC = aod::skimmedcluster::collisionId; std::vector genGamma; // primary, pt, y std::vector genPi0; // primary, pt, y std::vector genEta; // primary, pt, y template - void skimmingMC(MyCollisionsMC const& collisions, aod::BCs const&, aod::McCollisions const&, aod::McParticles const& mcTracks, TTracks const& o2tracks, TFwdTracks const&, TPCMs const& v0photons, TPCMLegs const& /*v0legs*/, TPHOSs const& /*phosclusters*/, TEMCs const& emcclusters, TEMPrimaryElectrons const& emprimaryelectrons) + void skimmingMC(MyCollisionsMC const& collisions, aod::BCs const&, aod::McCollisions const&, aod::McParticles const& mcParticles, TTracks const& o2tracks, TFwdTracks const&, TPCMs const& v0photons, TPCMLegs const&, TPHOSs const&, TEMCs const& emcclusters, TEMPrimaryElectrons const& emprimaryelectrons) { // temporary variables used for the indexing of the skimmed MC stack std::map fNewLabels; @@ -118,7 +123,7 @@ struct AssociateMCInfoPhoton { int fCounters[2] = {0, 0}; //! [0] - particle counter, [1] - event counter auto hBinFinder = registry.get(HIST("Generated/h2PtY_Gamma")); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { registry.fill(HIST("hEventCounter"), 1); // TODO: investigate the collisions without corresponding mcCollision @@ -126,7 +131,7 @@ struct AssociateMCInfoPhoton { continue; } - if (applyEveSel_at_skimming && (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + if (!collision.isSelected()) { continue; } @@ -138,22 +143,26 @@ struct AssociateMCInfoPhoton { auto mcCollision = collision.mcCollision(); // store mc particles - auto groupedMcTracks = mcTracks.sliceBy(perMcCollision, mcCollision.globalIndex()); + auto groupedMcParticles = mcParticles.sliceBy(perMcCollision, mcCollision.globalIndex()); - for (auto& mctrack : groupedMcTracks) { // store necessary information for denominator of efficiency - if ((mctrack.isPhysicalPrimary() || mctrack.producedByGenerator()) && abs(mctrack.y()) < 0.9f && mctrack.pt() < 20.f) { - auto binNumber = hBinFinder->FindBin(mctrack.pt(), abs(mctrack.y())); // caution: pack - switch (abs(mctrack.pdgCode())) { + for (const auto& mcParticle : groupedMcParticles) { // store necessary information for denominator of efficiency + if ((mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator()) && std::fabs(mcParticle.y()) < 0.9f && mcParticle.pt() < 20.f) { + auto binNumber = hBinFinder->FindBin(mcParticle.pt(), std::fabs(mcParticle.y())); // caution: pack + switch (std::abs(mcParticle.pdgCode())) { case 22: - registry.fill(HIST("Generated/h2PtY_Gamma"), mctrack.pt(), abs(mctrack.y())); + registry.fill(HIST("Generated/h2PtY_Gamma"), mcParticle.pt(), std::fabs(mcParticle.y())); genGamma[binNumber]++; break; case 111: - registry.fill(HIST("Generated/h2PtY_Pi0"), mctrack.pt(), abs(mctrack.y())); + if (requireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles)) + continue; + registry.fill(HIST("Generated/h2PtY_Pi0"), mcParticle.pt(), std::fabs(mcParticle.y())); genPi0[binNumber]++; break; case 221: - registry.fill(HIST("Generated/h2PtY_Eta"), mctrack.pt(), abs(mctrack.y())); + if (requireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles)) + continue; + registry.fill(HIST("Generated/h2PtY_Eta"), mcParticle.pt(), std::fabs(mcParticle.y())); genEta[binNumber]++; break; default: @@ -167,38 +176,39 @@ struct AssociateMCInfoPhoton { mcevents(mcCollision.globalIndex(), mcCollision.generatorsID(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.impactParameter(), mcCollision.eventPlaneAngle()); fEventLabels[mcCollision.globalIndex()] = fCounters[1]; fCounters[1]++; - binned_gen_pt(genGamma, genPi0, genEta); + binnedGenPt(genGamma, genPi0, genEta); } + // LOGF(info, "collision.globalIndex() = %d , mceventlabels.lastIndex() = %d", collision.globalIndex(), mceventlabels.lastIndex()); mceventlabels(fEventLabels.find(mcCollision.globalIndex())->second, collision.mcMask()); - for (auto& mctrack : groupedMcTracks) { // store necessary information for denominator of efficiency - if (mctrack.pt() < 1e-3 || abs(mctrack.vz()) > 250 || sqrt(pow(mctrack.vx(), 2) + pow(mctrack.vy(), 2)) > max_rxy_gen) { + for (const auto& mcParticle : groupedMcParticles) { // store necessary information for denominator of efficiency + if (mcParticle.pt() < 1e-3 || std::fabs(mcParticle.vz()) > 250 || std::sqrt(std::pow(mcParticle.vx(), 2) + std::pow(mcParticle.vy(), 2)) > max_rxy_gen) { continue; } - int pdg = mctrack.pdgCode(); - if (abs(pdg) > 1e+9) { + int pdg = mcParticle.pdgCode(); + if (std::abs(pdg) > 1e+9) { continue; } // Note that pi0 from weak decay gives producedByGenerator() = false - // LOGF(info,"index = %d , mc track pdg = %d , producedByGenerator = %d , isPhysicalPrimary = %d", mctrack.index(), mctrack.pdgCode(), mctrack.producedByGenerator(), mctrack.isPhysicalPrimary()); + // LOGF(info,"index = %d , mc track pdg = %d , producedByGenerator = %d , isPhysicalPrimary = %d", mcParticle.index(), mcParticle.pdgCode(), mcParticle.producedByGenerator(), mcParticle.isPhysicalPrimary()); - if (abs(pdg) == 11 && mctrack.has_mothers() && !(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { // secondary electrons. i.e. ele/pos from photon conversions. - int motherid = mctrack.mothersIds()[0]; // first mother index - auto mp = mcTracks.iteratorAt(motherid); + if (std::abs(pdg) == 11 && mcParticle.has_mothers() && !(mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator())) { // secondary electrons. i.e. ele/pos from photon conversions. + int motherid = mcParticle.mothersIds()[0]; // first mother index + auto mp = mcParticles.iteratorAt(motherid); - if (sqrt(pow(mctrack.vx(), 2) + pow(mctrack.vy(), 2)) < abs(mctrack.vz()) * std::tan(2 * std::atan(std::exp(-max_eta_gen_secondary))) - margin_z_gen) { + if (std::sqrt(std::pow(mcParticle.vx(), 2) + std::pow(mcParticle.vy(), 2)) < std::fabs(mcParticle.vz()) * std::tan(2 * std::atan(std::exp(-max_eta_gen_secondary))) - margin_z_gen) { continue; } - if (mp.pdgCode() == 22 && (mp.isPhysicalPrimary() || mp.producedByGenerator()) && abs(mp.eta()) < max_eta_gen_secondary) { + if (mp.pdgCode() == 22 && (mp.isPhysicalPrimary() || mp.producedByGenerator()) && std::fabs(mp.eta()) < max_eta_gen_secondary) { // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack - if (!(fNewLabels.find(mctrack.globalIndex()) != fNewLabels.end())) { // store electron information. !!Not photon!! - fNewLabels[mctrack.globalIndex()] = fCounters[0]; - fNewLabelsReversed[fCounters[0]] = mctrack.globalIndex(); - // fMCFlags[mctrack.globalIndex()] = mcflags; - fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mcCollision.globalIndex())->second; + if (!(fNewLabels.find(mcParticle.globalIndex()) != fNewLabels.end())) { // store electron information. !!Not photon!! + fNewLabels[mcParticle.globalIndex()] = fCounters[0]; + fNewLabelsReversed[fCounters[0]] = mcParticle.globalIndex(); + // fMCFlags[mcParticle.globalIndex()] = mcflags; + fEventIdx[mcParticle.globalIndex()] = fEventLabels.find(mcCollision.globalIndex())->second; fCounters[0]++; } @@ -217,53 +227,53 @@ struct AssociateMCInfoPhoton { } // end of rec. collision loop if constexpr (static_cast(system & kPCM)) { - for (auto& v0 : v0photons) { - auto collision_from_v0 = collisions.iteratorAt(v0.collisionId()); - if (!collision_from_v0.has_mcCollision()) { + for (const auto& v0 : v0photons) { + auto collisionFromV0 = collisions.iteratorAt(v0.collisionId()); + if (!collisionFromV0.has_mcCollision()) { continue; } - auto mcCollision_from_v0 = collision_from_v0.mcCollision(); + auto mcCollisionFromV0 = collisionFromV0.mcCollision(); auto ele = v0.template negTrack_as(); auto pos = v0.template posTrack_as(); - auto o2track_ele = o2tracks.iteratorAt(pos.trackId()); - auto o2track_pos = o2tracks.iteratorAt(ele.trackId()); + auto o2TrackEle = o2tracks.iteratorAt(pos.trackId()); + auto o2TrackPos = o2tracks.iteratorAt(ele.trackId()); - if (!o2track_ele.has_mcParticle() || !o2track_pos.has_mcParticle()) { + if (!o2TrackEle.has_mcParticle() || !o2TrackPos.has_mcParticle()) { continue; // If no MC particle is found, skip the v0 } - for (auto& leg : {pos, ele}) { // be carefull of order {pos, ele}! + for (const auto& leg : {pos, ele}) { // be carefull of order {pos, ele}! auto o2track = o2tracks.iteratorAt(leg.trackId()); - auto mctrack = o2track.template mcParticle_as(); - // LOGF(info, "mctrack.globalIndex() = %d, mctrack.index() = %d", mctrack.globalIndex(), mctrack.index()); // these are exactly the same. + auto mcParticle = o2track.template mcParticle_as(); + // LOGF(info, "mcParticle.globalIndex() = %d, mcParticle.index() = %d", mcParticle.globalIndex(), mcParticle.index()); // these are exactly the same. // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack - if (!(fNewLabels.find(mctrack.globalIndex()) != fNewLabels.end())) { - fNewLabels[mctrack.globalIndex()] = fCounters[0]; - fNewLabelsReversed[fCounters[0]] = mctrack.globalIndex(); - // fMCFlags[mctrack.globalIndex()] = mcflags; - fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mcCollision_from_v0.globalIndex())->second; + if (!(fNewLabels.find(mcParticle.globalIndex()) != fNewLabels.end())) { + fNewLabels[mcParticle.globalIndex()] = fCounters[0]; + fNewLabelsReversed[fCounters[0]] = mcParticle.globalIndex(); + // fMCFlags[mcParticle.globalIndex()] = mcflags; + fEventIdx[mcParticle.globalIndex()] = fEventLabels.find(mcCollisionFromV0.globalIndex())->second; fCounters[0]++; } - v0legmclabels(fNewLabels.find(mctrack.index())->second, o2track.mcMask()); + v0legmclabels(fNewLabels.find(mcParticle.index())->second, o2track.mcMask()); // Next, store mother-chain of this reconstructed track. int motherid = -999; // first mother index - if (mctrack.has_mothers()) { - motherid = mctrack.mothersIds()[0]; // first mother index + if (mcParticle.has_mothers()) { + motherid = mcParticle.mothersIds()[0]; // first mother index } while (motherid > -1) { - if (motherid < mcTracks.size()) { // protect against bad mother indices. why is this needed? - auto mp = mcTracks.iteratorAt(motherid); + if (motherid < mcParticles.size()) { // protect against bad mother indices. why is this needed? + auto mp = mcParticles.iteratorAt(motherid); // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack if (!(fNewLabels.find(mp.globalIndex()) != fNewLabels.end())) { fNewLabels[mp.globalIndex()] = fCounters[0]; fNewLabelsReversed[fCounters[0]] = mp.globalIndex(); // fMCFlags[mp.globalIndex()] = mcflags; - fEventIdx[mp.globalIndex()] = fEventLabels.find(mcCollision_from_v0.globalIndex())->second; + fEventIdx[mp.globalIndex()] = fEventLabels.find(mcCollisionFromV0.globalIndex())->second; fCounters[0]++; } @@ -276,50 +286,50 @@ struct AssociateMCInfoPhoton { motherid = -999; } } // end of mother chain loop - } // end of leg loop - } // end of v0 loop + } // end of leg loop + } // end of v0 loop } if constexpr (static_cast(system & kElectron)) { - // auto emprimaryelectrons_coll = emprimaryelectrons.sliceBy(perCollision_el, collision.globalIndex()); - for (auto& emprimaryelectron : emprimaryelectrons) { - auto collision_from_el = collisions.iteratorAt(emprimaryelectron.collisionId()); - if (!collision_from_el.has_mcCollision()) { + // auto emprimaryelectrons_coll = emprimaryelectrons.sliceBy(perCollisionEl, collision.globalIndex()); + for (const auto& emprimaryelectron : emprimaryelectrons) { + auto collisionFromEl = collisions.iteratorAt(emprimaryelectron.collisionId()); + if (!collisionFromEl.has_mcCollision()) { continue; } - auto mcCollision_from_el = collision_from_el.mcCollision(); + auto mcCollisionFromEl = collisionFromEl.mcCollision(); auto o2track = o2tracks.iteratorAt(emprimaryelectron.trackId()); if (!o2track.has_mcParticle()) { continue; // If no MC particle is found, skip the dilepton } - auto mctrack = o2track.template mcParticle_as(); + auto mcParticle = o2track.template mcParticle_as(); // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack - if (!(fNewLabels.find(mctrack.globalIndex()) != fNewLabels.end())) { - fNewLabels[mctrack.globalIndex()] = fCounters[0]; - fNewLabelsReversed[fCounters[0]] = mctrack.globalIndex(); - // fMCFlags[mctrack.globalIndex()] = mcflags; - fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mcCollision_from_el.globalIndex())->second; + if (!(fNewLabels.find(mcParticle.globalIndex()) != fNewLabels.end())) { + fNewLabels[mcParticle.globalIndex()] = fCounters[0]; + fNewLabelsReversed[fCounters[0]] = mcParticle.globalIndex(); + // fMCFlags[mcParticle.globalIndex()] = mcflags; + fEventIdx[mcParticle.globalIndex()] = fEventLabels.find(mcCollisionFromEl.globalIndex())->second; fCounters[0]++; } - emprimaryelectronmclabels(fNewLabels.find(mctrack.index())->second, o2track.mcMask()); + emprimaryelectronmclabels(fNewLabels.find(mcParticle.index())->second, o2track.mcMask()); // Next, store mother-chain of this reconstructed track. int motherid = -999; // first mother index - if (mctrack.has_mothers()) { - motherid = mctrack.mothersIds()[0]; // first mother index + if (mcParticle.has_mothers()) { + motherid = mcParticle.mothersIds()[0]; // first mother index } while (motherid > -1) { - if (motherid < mcTracks.size()) { // protect against bad mother indices. why is this needed? - auto mp = mcTracks.iteratorAt(motherid); + if (motherid < mcParticles.size()) { // protect against bad mother indices. why is this needed? + auto mp = mcParticles.iteratorAt(motherid); // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack if (!(fNewLabels.find(mp.globalIndex()) != fNewLabels.end())) { fNewLabels[mp.globalIndex()] = fCounters[0]; fNewLabelsReversed[fCounters[0]] = mp.globalIndex(); // fMCFlags[mp.globalIndex()] = mcflags; - fEventIdx[mp.globalIndex()] = fEventLabels.find(mcCollision_from_el.globalIndex())->second; + fEventIdx[mp.globalIndex()] = fEventLabels.find(mcCollisionFromEl.globalIndex())->second; fCounters[0]++; } @@ -337,21 +347,21 @@ struct AssociateMCInfoPhoton { } if constexpr (static_cast(system & kEMC)) { // for emc photons - // auto ememcclusters_coll = emcclusters.sliceBy(perCollision_emc, collision.globalIndex()); - for (auto& emccluster : emcclusters) { - auto collision_from_emc = collisions.iteratorAt(emccluster.collisionId()); - if (!collision_from_emc.has_mcCollision()) { + // auto ememcclusters_coll = emcclusters.sliceBy(perCollisionEMC, collision.globalIndex()); + for (const auto& emccluster : emcclusters) { + auto collisionFromEMC = collisions.iteratorAt(emccluster.collisionId()); + if (!collisionFromEMC.has_mcCollision()) { continue; } - auto mcCollision_from_emc = collision_from_emc.mcCollision(); + auto mcCollisionFromEMC = collisionFromEMC.mcCollision(); - auto mcphoton = mcTracks.iteratorAt(emccluster.emmcparticleIds()[0]); + auto mcphoton = mcParticles.iteratorAt(emccluster.emmcparticleIds()[0]); // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack if (!(fNewLabels.find(mcphoton.globalIndex()) != fNewLabels.end())) { fNewLabels[mcphoton.globalIndex()] = fCounters[0]; fNewLabelsReversed[fCounters[0]] = mcphoton.globalIndex(); - fEventIdx[mcphoton.globalIndex()] = fEventLabels.find(mcCollision_from_emc.globalIndex())->second; + fEventIdx[mcphoton.globalIndex()] = fEventLabels.find(mcCollisionFromEMC.globalIndex())->second; fCounters[0]++; } ememcclustermclabels(fNewLabels.find(mcphoton.index())->second); @@ -362,14 +372,14 @@ struct AssociateMCInfoPhoton { motherid = mcphoton.mothersIds()[0]; // first mother index } while (motherid > -1) { - if (motherid < mcTracks.size()) { // protect against bad mother indices. why is this needed? - auto mp = mcTracks.iteratorAt(motherid); + if (motherid < mcParticles.size()) { // protect against bad mother indices. why is this needed? + auto mp = mcParticles.iteratorAt(motherid); // if the MC truth particle corresponding to this reconstructed track which is not already written, add it to the skimmed MC stack if (!(fNewLabels.find(mp.globalIndex()) != fNewLabels.end())) { fNewLabels[mp.globalIndex()] = fCounters[0]; fNewLabelsReversed[fCounters[0]] = mp.globalIndex(); - fEventIdx[mp.globalIndex()] = fEventLabels.find(mcCollision_from_emc.globalIndex())->second; + fEventIdx[mp.globalIndex()] = fEventLabels.find(mcCollisionFromEMC.globalIndex())->second; fCounters[0]++; } @@ -388,46 +398,46 @@ struct AssociateMCInfoPhoton { // Loop over the label map, create the mother/daughter relationships if these exist and write the skimmed MC stack for (const auto& [newLabel, oldLabel] : fNewLabelsReversed) { - auto mctrack = mcTracks.iteratorAt(oldLabel); + auto mcParticle = mcParticles.iteratorAt(oldLabel); // uint16_t mcflags = fMCFlags.find(oldLabel)->second; std::vector mothers; - if (mctrack.has_mothers()) { - for (auto& m : mctrack.mothersIds()) { - if (m < mcTracks.size()) { // protect against bad mother indices + if (mcParticle.has_mothers()) { + for (const auto& m : mcParticle.mothersIds()) { + if (m < mcParticles.size()) { // protect against bad mother indices if (fNewLabels.find(m) != fNewLabels.end()) { mothers.push_back(fNewLabels.find(m)->second); } } else { - std::cout << "Mother label (" << m << ") exceeds the McParticles size (" << mcTracks.size() << ")" << std::endl; - std::cout << " Check the MC generator" << std::endl; + LOG(info) << "Mother label (" << m << ") exceeds the McParticles size (" << mcParticles.size() << ")"; + LOG(info) << " Check the MC generator"; } } } // Note that not all daughters from the original table are preserved in the skimmed MC stack std::vector daughters; - if (mctrack.has_daughters()) { - // LOGF(info, "daughter range in original MC stack pdg = %d | %d - %d , n dau = %d", mctrack.pdgCode(), mctrack.daughtersIds()[0], mctrack.daughtersIds()[1], mctrack.daughtersIds()[1] -mctrack.daughtersIds()[0] +1); - for (int d = mctrack.daughtersIds()[0]; d <= mctrack.daughtersIds()[1]; ++d) { + if (mcParticle.has_daughters()) { + // LOGF(info, "daughter range in original MC stack pdg = %d | %d - %d , n dau = %d", mcParticle.pdgCode(), mcParticle.daughtersIds()[0], mcParticle.daughtersIds()[1], mcParticle.daughtersIds()[1] -mcParticle.daughtersIds()[0] +1); + for (int d = mcParticle.daughtersIds()[0]; d <= mcParticle.daughtersIds()[1]; ++d) { // TODO: remove this check as soon as issues with MC production are fixed - if (d < mcTracks.size()) { // protect against bad daughter indices - // auto dau_tmp = mcTracks.iteratorAt(d); + if (d < mcParticles.size()) { // protect against bad daughter indices + // auto dau_tmp = mcParticles.iteratorAt(d); // LOGF(info, "daughter pdg = %d", dau_tmp.pdgCode()); if (fNewLabels.find(d) != fNewLabels.end()) { daughters.push_back(fNewLabels.find(d)->second); } } else { - std::cout << "Daughter label (" << d << ") exceeds the McParticles size (" << mcTracks.size() << ")" << std::endl; - std::cout << " Check the MC generator" << std::endl; + LOG(info) << "Daughter label (" << d << ") exceeds the McParticles size (" << mcParticles.size() << ")"; + LOG(info) << " Check the MC generator"; } } } - emmcparticles(fEventIdx.find(oldLabel)->second, mctrack.pdgCode(), mctrack.flags(), + emmcparticles(fEventIdx.find(oldLabel)->second, mcParticle.pdgCode(), mcParticle.flags(), mothers, daughters, - mctrack.px(), mctrack.py(), mctrack.pz(), mctrack.e(), - mctrack.vx(), mctrack.vy(), mctrack.vz()); + mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e(), + mcParticle.vx(), mcParticle.vy(), mcParticle.vz()); } // end loop over labels fNewLabels.clear(); @@ -437,80 +447,90 @@ struct AssociateMCInfoPhoton { fEventLabels.clear(); fCounters[0] = 0; fCounters[1] = 0; - } // end of skimmingMC + } // end of skimmingMC - void processMC_PCM(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs) + void processMC_PCM(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs) { - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, nullptr, nullptr, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, v0photons, v0legs, nullptr, nullptr, nullptr); } - void processMC_PCM_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM, "create em mc event table for PCM", false); + + void processMC_PCM_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) { const uint8_t sysflag = kPCM | kElectron; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, nullptr, nullptr, emprimaryelectrons); + skimmingMC(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, v0photons, v0legs, nullptr, nullptr, emprimaryelectrons); } - void processMC_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_Electron, "create em mc event table for PCM, Electron", false); + + void processMC_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) { const uint8_t sysflag = kElectron; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, nullptr, nullptr, nullptr, nullptr, emprimaryelectrons); + skimmingMC(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, nullptr, nullptr, nullptr, nullptr, emprimaryelectrons); } - void processMC_PHOS(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, aod::PHOSClusters const& phosclusters) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_Electron, "create em mc event table for Electron", false); + + void processMC_PHOS(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, aod::PHOSClusters const& phosclusters) { - skimmingMC(collisions, bcs, mccollisions, mcTracks, nullptr, nullptr, nullptr, nullptr, phosclusters, nullptr, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcParticles, nullptr, nullptr, nullptr, nullptr, phosclusters, nullptr, nullptr); } - void processMC_EMC(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, MyEMCClusters const& emcclusters) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PHOS, "create em mc event table for PHOS", false); + + void processMC_EMC(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, MyEMCClusters const& emcclusters) { - skimmingMC(collisions, bcs, mccollisions, mcTracks, nullptr, nullptr, nullptr, nullptr, nullptr, emcclusters, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcParticles, nullptr, nullptr, nullptr, nullptr, nullptr, emcclusters, nullptr); } - void processMC_PCM_PHOS(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::PHOSClusters const& phosclusters) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_EMC, "create em mc event table for EMCal", false); + + void processMC_PCM_PHOS(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::PHOSClusters const& phosclusters) { const uint8_t sysflag = kPCM | kPHOS; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, phosclusters, nullptr, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, v0photons, v0legs, phosclusters, nullptr, nullptr); } - void processMC_PCM_PHOS_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::PHOSClusters const& phosclusters, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_PHOS, "create em mc event table for PCM, PHOS", false); + + void processMC_PCM_PHOS_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::PHOSClusters const& phosclusters, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) { const uint8_t sysflag = kPCM | kPHOS | kElectron; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, phosclusters, nullptr, emprimaryelectrons); + skimmingMC(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, v0photons, v0legs, phosclusters, nullptr, emprimaryelectrons); } - void processMC_PCM_EMC(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, MyEMCClusters const& emcclusters) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_PHOS_Electron, "create em mc event table for PCM, PHOS, Electron", false); + + void processMC_PCM_EMC(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, MyEMCClusters const& emcclusters) { const uint8_t sysflag = kPCM | kEMC; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, nullptr, emcclusters, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, v0photons, v0legs, nullptr, emcclusters, nullptr); } - void processMC_PCM_EMC_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, MyEMCClusters const& emcclusters, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_EMC, "create em mc event table for PCM, EMCal", false); + + void processMC_PCM_EMC_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, MyEMCClusters const& emcclusters, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) { const uint8_t sysflag = kPCM | kEMC | kElectron; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, nullptr, emcclusters, emprimaryelectrons); + skimmingMC(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, v0photons, v0legs, nullptr, emcclusters, emprimaryelectrons); } - void processMC_PHOS_EMC(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, aod::PHOSClusters const& phosclusters, MyEMCClusters const& emcclusters) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_EMC_Electron, "create em mc event table for PCM, EMCal, Electron", false); + + void processMC_PHOS_EMC(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, aod::PHOSClusters const& phosclusters, MyEMCClusters const& emcclusters) { const uint8_t sysflag = kPHOS | kEMC; - skimmingMC(collisions, bcs, mccollisions, mcTracks, nullptr, nullptr, nullptr, nullptr, phosclusters, emcclusters, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcParticles, nullptr, nullptr, nullptr, nullptr, phosclusters, emcclusters, nullptr); } - void processMC_PCM_PHOS_EMC(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::PHOSClusters const& phosclusters, MyEMCClusters const& emcclusters) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PHOS_EMC, "create em mc event table for PHOS, EMCal", false); + + void processMC_PCM_PHOS_EMC(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::PHOSClusters const& phosclusters, MyEMCClusters const& emcclusters) { const uint8_t sysflag = kPCM | kPHOS | kEMC; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, phosclusters, emcclusters, nullptr); + skimmingMC(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, v0photons, v0legs, phosclusters, emcclusters, nullptr); } - void processMC_PCM_PHOS_EMC_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcTracks, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::PHOSClusters const& phosclusters, MyEMCClusters const& emcclusters, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_PHOS_EMC, "create em mc event table for PCM, PHOS, EMCal", false); + + void processMC_PCM_PHOS_EMC_Electron(MyCollisionsMC const& collisions, aod::BCs const& bcs, aod::McCollisions const& mccollisions, aod::McParticles const& mcParticles, TracksMC const& o2tracks, aod::V0PhotonsKF const& v0photons, aod::V0Legs const& v0legs, aod::PHOSClusters const& phosclusters, MyEMCClusters const& emcclusters, aod::EMPrimaryElectronsFromDalitz const& emprimaryelectrons) { const uint8_t sysflag = kPCM | kPHOS | kEMC | kElectron; - skimmingMC(collisions, bcs, mccollisions, mcTracks, o2tracks, nullptr, v0photons, v0legs, phosclusters, emcclusters, emprimaryelectrons); + skimmingMC(collisions, bcs, mccollisions, mcParticles, o2tracks, nullptr, v0photons, v0legs, phosclusters, emcclusters, emprimaryelectrons); } + PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_PHOS_EMC_Electron, "create em mc event table for PCM, PHOS, EMCal, Electron", false); void processDummy(MyCollisionsMC const&) {} - - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM, "create em mc event table for PCM", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_Electron, "create em mc event table for PCM, Electron", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_Electron, "create em mc event table for Electron", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PHOS, "create em mc event table for PHOS", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_EMC, "create em mc event table for EMCal", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_PHOS, "create em mc event table for PCM, PHOS", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_PHOS_Electron, "create em mc event table for PCM, PHOS, Electron", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_EMC, "create em mc event table for PCM, EMCal", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_EMC_Electron, "create em mc event table for PCM, EMCal, Electron", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PHOS_EMC, "create em mc event table for PHOS, EMCal", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_PHOS_EMC, "create em mc event table for PCM, PHOS, EMCal", false); - PROCESS_SWITCH(AssociateMCInfoPhoton, processMC_PCM_PHOS_EMC_Electron, "create em mc event table for PCM, PHOS, EMCal, Electron", false); PROCESS_SWITCH(AssociateMCInfoPhoton, processDummy, "processDummy", true); }; diff --git a/PWGEM/PhotonMeson/TableProducer/bcWiseClusterSkimmer.cxx b/PWGEM/PhotonMeson/TableProducer/bcWiseClusterSkimmer.cxx new file mode 100644 index 00000000000..ab6bba76b3e --- /dev/null +++ b/PWGEM/PhotonMeson/TableProducer/bcWiseClusterSkimmer.cxx @@ -0,0 +1,374 @@ +// 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. +/// +/// \file bcWiseClusterSkimmer.cxx +/// +/// \brief This task creates minimalistic skimmed tables containing EMC clusters and centrality information +/// +/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) - Goethe University Frankfurt +/// + +#include "PWGEM/PhotonMeson/DataModel/bcWiseTables.h" +#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" +#include "PWGJE/DataModel/EMCALClusters.h" + +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DetectorsBase/GeometryManager.h" +#include "EMCALBase/Geometry.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::aod::emdownscaling; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using MyCollisions = soa::Join; +using MyMCCollisions = soa::Join; +using MyBCs = soa::Join; + +using SelectedUniqueClusters = soa::Filtered; // Clusters from collisions with only one collision in the BC +using SelectedUniqueMCClusters = soa::Filtered>; // Clusters from collisions with only one collision in the BC +using SelectedAmbiguousClusters = soa::Filtered; // Clusters from BCs with multiple collisions (no vertex assignment possible) +using SelectedAmbiguousMCClusters = soa::Filtered>; // Clusters from BCs with multiple collisions (no vertex assignment possible) +using SelectedCells = o2::soa::Filtered; + +struct bcWiseClusterSkimmer { + Produces bcTable; + Produces clusterTable; + Produces collisionTable; + Produces mcpi0Table; + Produces mcetaTable; + Produces mcclusterTable; + + PresliceUnsorted perFoundBC = aod::evsel::foundBCId; + Preslice perCol = aod::emcalcluster::collisionId; + Preslice perBC = aod::emcalcluster::bcId; + Preslice cellsPerBC = aod::calo::bcId; + + Configurable cfgMinClusterEnergy{"cfgMinClusterEnergy", 0.5, "Minimum energy of selected clusters (GeV)"}; + Configurable cfgMaxClusterEnergy{"cfgMaxClusterEnergy", 30., "Maximum energy of selected clusters (GeV)"}; + Configurable cfgMinM02{"cfgMinM02", -1., "Minimum M02 of selected clusters"}; + Configurable cfgMaxM02{"cfgMaxM02", 5., "Maximum M02 of selected clusters"}; + Configurable cfgMinTime{"cfgMinTime", -25, "Minimum time of selected clusters (ns)"}; + Configurable cfgMaxTime{"cfgMaxTime", 25, "Maximum time of selected clusters (ns)"}; + Configurable cfgRapidityCut{"cfgRapidityCut", 0.8f, "Maximum absolute rapidity of counted generated particles"}; + Configurable cfgMinPtGen{"cfgMinPtGen", 0., "Minimum pT for stored generated mesons (reduce disk space of derived data)"}; + + Configurable cfgRequirekTVXinEMC{"cfgRequirekTVXinEMC", false, "Only store kTVXinEMC triggered BCs"}; + Configurable cfgRequireGoodRCTQuality{"cfgRequireGoodRCTQuality", false, "Only store BCs with good quality of T0 and EMC in RCT"}; + Configurable cfgStoreMu{"cfgStoreMu", false, "Calculate and store mu (probablity of a TVX collision in the BC) per BC. Otherwise fill with 0"}; + Configurable cfgStoreTime{"cfgStoreTime", false, "Calculate and store time since the start of fill. Otherwise fill with 0"}; + ConfigurableAxis cfgMultiplicityBinning{"cfgMultiplicityBinning", {1000, 0, 10000}, "Binning used for the binning of the number of particles in the event"}; + + aod::rctsel::RCTFlagsChecker isFT0EMCGoodRCTChecker{aod::rctsel::kFT0Bad, aod::rctsel::kEMCBad}; + parameters::GRPLHCIFData* mLHCIFdata = nullptr; + int mRunNumber = -1; + ctpRateFetcher mRateFetcher; + + Filter energyFilter = (aod::emcalcluster::energy > cfgMinClusterEnergy && aod::emcalcluster::energy < cfgMaxClusterEnergy); + Filter m02Filter = (aod::emcalcluster::nCells == 1 || (aod::emcalcluster::m02 > cfgMinM02 && aod::emcalcluster::m02 < cfgMaxM02)); + Filter timeFilter = (aod::emcalcluster::time > cfgMinTime && aod::emcalcluster::time < cfgMaxTime); + Filter emccellFilter = aod::calo::caloType == 1; + + HistogramRegistry mHistManager{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + std::map fMapPi0Index; // Map to connect the MC index of the pi0 to the one saved in the derived table + std::map fMapEtaIndex; // Map to connect the MC index of the eta to the one saved in the derived table + + void init(o2::framework::InitContext&) + { + const int nEventBins = 6; + mHistManager.add("nBCs", "Number of BCs;;#bf{#it{N}_{BCs}}", HistType::kTH1F, {{nEventBins, -0.5, 5.5}}); + const TString binLabels[nEventBins] = {"All", "FT0", "TVX", "kTVXinEMC", "Cell", "NoBorder"}; + for (int iBin = 0; iBin < nEventBins; iBin++) + mHistManager.get(HIST("nBCs"))->GetXaxis()->SetBinLabel(iBin + 1, binLabels[iBin]); + + mHistManager.add("CentralityVsGenMultiplicity", "Centrality vs number of generated MC particles;Centrality;#bf{#it{N}_{gen}}", HistType::kTH2F, {{102, 0., 102}, cfgMultiplicityBinning}); + mHistManager.add("BCCentVsCollCent", "Centrality of the BC vs Centrality of the collision;BC Centrality;Collision Centrality", HistType::kTH2F, {{102, 0., 102}, {102, 0., 102}}); + + LOG(info) << "BC wise cluster skimmer cuts:"; + LOG(info) << "------------------------------------"; + LOG(info) << "| Timing cut: " << cfgMinTime << " < t < " << cfgMaxTime; + LOG(info) << "| Shape cut: " << cfgMinM02 << " < M02 < " << cfgMaxM02; + LOG(info) << "| Energy cut: " << cfgMinClusterEnergy << " < E < " << cfgMaxClusterEnergy; + LOG(info) << "| Rapidity cut: |y| < " << cfgRapidityCut; + LOG(info) << "| Min gen pt: pT > " << cfgMinPtGen; + + o2::emcal::Geometry::GetInstanceFromRunNumber(300000); + if (cfgRequireGoodRCTQuality) + isFT0EMCGoodRCTChecker.init({aod::rctsel::kFT0Bad, aod::rctsel::kEMCBad}); + } + + /// \brief Process EMCAL clusters (either ambigous or unique) + template + OutputType convertForStorage(InputType const& valueIn, Observable observable) + { + double valueToBeChecked = valueIn * downscalingFactors[observable]; + if (valueToBeChecked < std::numeric_limits::lowest()) { + LOG(warning) << "Value " << valueToBeChecked << " of observable " << observable << " below lowest possible value of " << typeid(OutputType).name() << ": " << static_cast(std::numeric_limits::lowest()); + valueToBeChecked = static_cast(std::numeric_limits::lowest()); + } + if (valueToBeChecked > std::numeric_limits::max()) { + LOG(warning) << "Value " << valueToBeChecked << " of observable " << observable << " obove highest possible value of " << typeid(OutputType).name() << ": " << static_cast(std::numeric_limits::max()); + valueToBeChecked = static_cast(std::numeric_limits::max()); + } + + return static_cast(valueToBeChecked); + } + + /// \brief Process EMCAL clusters (either ambigous or unique) + template + void processClusters(Clusters const& clusters, const int bcID) + { + for (const auto& cluster : clusters) { + clusterTable(bcID, + convertForStorage(cluster.definition(), kDefinition), + convertForStorage(cluster.energy(), kEnergy), + convertForStorage(cluster.eta(), kEta), + convertForStorage(cluster.phi(), kPhi), + convertForStorage(cluster.nCells(), kNCells), + convertForStorage(cluster.m02(), kM02), + convertForStorage(cluster.time(), kTime), + cluster.isExotic()); + } + } + + template + void processClusterMCInfo(Clusters const& clusters, const int bcID, aod::McParticles const& mcParticles) + { + for (const auto& cluster : clusters) { + float clusterInducerEnergy = 0.; + int32_t mesonMCIndex = -1; + if (cluster.amplitudeA().size() > 0) { + int clusterInducerId = cluster.mcParticleIds()[0]; + auto clusterInducer = mcParticles.iteratorAt(clusterInducerId); + clusterInducerEnergy = clusterInducer.e(); + int daughterId = aod::pwgem::photonmeson::utils::mcutil::FindMotherInChain(clusterInducer, mcParticles, std::vector{111, 221}); + if (daughterId > 0) { + mesonMCIndex = mcParticles.iteratorAt(daughterId).mothersIds()[0]; + if (mcParticles.iteratorAt(mesonMCIndex).pt() < cfgMinPtGen) + mesonMCIndex = -1; + } + } + bool isEta = false; + if (mesonMCIndex >= 0) { + if (mcParticles.iteratorAt(mesonMCIndex).pdgCode() == 111) { + if (fMapPi0Index.find(mesonMCIndex) != fMapPi0Index.end()) // Some pi0s might not be found (not gg decay or too large y) + mesonMCIndex = fMapPi0Index[mesonMCIndex]; // If pi0 was stored in table, change index from the MC index to the pi0 index from this task + else // If pi0 was not stored, treat photon as if not from pi0 + mesonMCIndex = -1; + } else if (mcParticles.iteratorAt(mesonMCIndex).pdgCode() == 221) { + isEta = true; + if (fMapEtaIndex.find(mesonMCIndex) != fMapEtaIndex.end()) // Some etas might not be found (not gg decay or too large y) + mesonMCIndex = fMapEtaIndex[mesonMCIndex]; // If eta was stored in table, change index from the MC index to the eta index from this task + else // If eta was not stored, treat photon as if not from eta + mesonMCIndex = -1; + } else { + mesonMCIndex = -1; // Not a pi0 or eta + } + } + mcclusterTable(bcID, mesonMCIndex, isEta, convertForStorage(clusterInducerEnergy, kEnergy)); + } + } + + bool isBCSelected(const auto& bc) + { + if (cfgRequirekTVXinEMC && !bc.alias_bit(kTVXinEMC)) + return false; + if (cfgRequireGoodRCTQuality && !isFT0EMCGoodRCTChecker(bc)) + return false; + return true; + } + + void setLHCIFData(const auto& bc) + { + if (mRunNumber == bc.runNumber()) + return; + + auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance(); + uint64_t timeStamp = bc.timestamp(); + + std::map metadata; + mLHCIFdata = ccdbMgr.getSpecific("GLO/Config/GRPLHCIF", timeStamp, metadata); + if (mLHCIFdata == nullptr) + LOG(fatal) << "GRPLHCIFData not in database, timestamp:" << timeStamp; + mRunNumber = bc.runNumber(); + LOG(info) << "LHCIF data fetched for run " << mRunNumber << " and timestamp " << timeStamp; + + return; + } + + double calculateMu(const auto& bc) + { + auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance(); + uint64_t timeStamp = bc.timestamp(); + + auto bfilling = mLHCIFdata->getBunchFilling(); + double nbc = bfilling.getFilledBCs().size(); + double tvxRate = mRateFetcher.fetch(&ccdbMgr, timeStamp, bc.runNumber(), "T0VTX"); + double nTriggersPerFilledBC = tvxRate / nbc / o2::constants::lhc::LHCRevFreq; + double mu = -std::log(1 - nTriggersPerFilledBC); + + // LOG(info) << "Time stamp: " << timeStamp << " Run number: " << bc.runNumber() << " Number of filled BCs: " << nbc << " Trigger rate: " << tvxRate << " Mu: " << mu; + + return mu; + } + + void processEventProperties(const auto& bc, const auto& collisionsInBC, const auto& cellsInBC) + { + bool hasFT0 = bc.has_foundFT0(); + bool hasTVX = bc.selection_bit(aod::evsel::kIsTriggerTVX); + bool haskTVXinEMC = bc.alias_bit(kTVXinEMC); + bool hasEMCCell = cellsInBC.size() > 0; + mHistManager.fill(HIST("nBCs"), 0); + if (hasFT0) + mHistManager.fill(HIST("nBCs"), 1); + if (hasTVX) + mHistManager.fill(HIST("nBCs"), 2); + if (haskTVXinEMC) + mHistManager.fill(HIST("nBCs"), 3); + if (hasEMCCell) + mHistManager.fill(HIST("nBCs"), 4); + + if (cfgStoreMu || cfgStoreTime) + setLHCIFData(bc); + double mu = cfgStoreMu ? calculateMu(bc) : 0.; + float timeSinceSOF = cfgStoreTime ? (bc.timestamp() - mLHCIFdata->getFillNumberTime()) / 1e3 : 0.; // Convert to seconds + float ft0Amp = hasFT0 ? bc.foundFT0().sumAmpA() + bc.foundFT0().sumAmpC() : 0.; + double centralityOfCollision = 101.5; + if (collisionsInBC.size() > 0) + centralityOfCollision = collisionsInBC.iteratorAt(0).centFT0M(); + double centralityOfBC = bc.centFT0M(); + + mHistManager.fill(HIST("BCCentVsCollCent"), centralityOfBC, centralityOfCollision); + + bcTable(hasFT0, hasTVX, haskTVXinEMC, hasEMCCell, convertForStorage(centralityOfBC, kFT0MCent), convertForStorage(ft0Amp, kFT0Amp), convertForStorage(mu, kMu), convertForStorage(timeSinceSOF, kTimeSinceSOF)); + + for (const auto& collision : collisionsInBC) + collisionTable(bcTable.lastIndex(), convertForStorage(collision.centFT0M(), kFT0MCent), convertForStorage(collision.posZ(), kZVtx)); + } + + template + bool isGammaGammaDecay(TMCParticle mcParticle, TMCParticles mcParticles) + { + auto daughtersIds = mcParticle.daughtersIds(); + if (daughtersIds.size() != 2) + return false; + for (const auto& daughterId : daughtersIds) { + if (mcParticles.iteratorAt(daughterId).pdgCode() != 22) + return false; + } + return true; + } + + template + bool isAccepted(TMCParticle mcParticle, TMCParticles mcParticles) + { + auto daughtersIds = mcParticle.daughtersIds(); + if (daughtersIds.size() != 2) + return false; + for (const auto& daughterId : daughtersIds) { + if (mcParticles.iteratorAt(daughterId).pdgCode() != 22) + return false; + int iCellID = -1; + try { + iCellID = emcal::Geometry::GetInstance()->GetAbsCellIdFromEtaPhi(mcParticles.iteratorAt(daughterId).eta(), mcParticles.iteratorAt(daughterId).phi()); + } catch (emcal::InvalidPositionException& e) { + iCellID = -1; + } + if (iCellID == -1) + return false; + } + return true; + } + + void processData(MyBCs const& bcs, MyCollisions const& collisions, aod::FT0s const&, SelectedCells const& cells, SelectedUniqueClusters const& uClusters, SelectedAmbiguousClusters const& aClusters) + { + for (const auto& bc : bcs) { + if (!isBCSelected(bc)) + continue; + auto collisionsInBC = collisions.sliceBy(perFoundBC, bc.globalIndex()); + auto cellsInBC = cells.sliceBy(cellsPerBC, bc.globalIndex()); + + processEventProperties(bc, collisionsInBC, cellsInBC); + + if (collisionsInBC.size() == 1) { + auto clustersInBC = uClusters.sliceBy(perCol, collisionsInBC.begin().globalIndex()); + processClusters(clustersInBC, bcTable.lastIndex()); + } else { + auto clustersInBC = aClusters.sliceBy(perBC, bc.globalIndex()); + processClusters(clustersInBC, bcTable.lastIndex()); + } + } + } + PROCESS_SWITCH(bcWiseClusterSkimmer, processData, "Run skimming for data", true); + + Preslice mcCollperBC = aod::mccollision::bcId; + Preslice perMcCollision = aod::mcparticle::mcCollisionId; + + void processMC(MyBCs const& bcs, MyMCCollisions const& collisions, aod::McCollisions const& mcCollisions, aod::FT0s const&, SelectedCells const& cells, SelectedUniqueMCClusters const& uClusters, SelectedAmbiguousMCClusters const& aClusters, aod::McParticles const& mcParticles) + { + for (const auto& bc : bcs) { + if (!isBCSelected(bc)) + continue; + auto collisionsInBC = collisions.sliceBy(perFoundBC, bc.globalIndex()); + auto cellsInBC = cells.sliceBy(cellsPerBC, bc.globalIndex()); + + processEventProperties(bc, collisionsInBC, cellsInBC); + + auto mcCollisionsBC = mcCollisions.sliceBy(mcCollperBC, bc.globalIndex()); + for (const auto& mcCollision : mcCollisionsBC) { + auto mcParticlesInColl = mcParticles.sliceBy(perMcCollision, mcCollision.globalIndex()); + mHistManager.fill(HIST("CentralityVsGenMultiplicity"), bc.centFT0M(), mcParticlesInColl.size()); + for (const auto& mcParticle : mcParticlesInColl) { + if (std::abs(mcParticle.y()) > cfgRapidityCut || !isGammaGammaDecay(mcParticle, mcParticles) || mcParticle.pt() < cfgMinPtGen) + continue; + bool isPrimary = mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator(); + bool isFromWD = (aod::pwgem::photonmeson::utils::mcutil::IsFromWD(mcCollision, mcParticle, mcParticles)) > 0; + + if (mcParticle.pdgCode() == 111) { + mcpi0Table(bc.globalIndex(), convertForStorage(mcParticle.pt(), kpT), isAccepted(mcParticle, mcParticles), isPrimary, isFromWD); + fMapPi0Index[mcParticle.globalIndex()] = static_cast(mcpi0Table.lastIndex()); + } else if (mcParticle.pdgCode() == 221) { + mcetaTable(bc.globalIndex(), convertForStorage(mcParticle.pt(), kpT), isAccepted(mcParticle, mcParticles), isPrimary, isFromWD); + fMapEtaIndex[mcParticle.globalIndex()] = static_cast(mcetaTable.lastIndex()); + } + } + } + + if (collisionsInBC.size() == 1) { + auto clustersInBC = uClusters.sliceBy(perCol, collisionsInBC.begin().globalIndex()); + processClusters(clustersInBC, bcTable.lastIndex()); + processClusterMCInfo(clustersInBC, bc.globalIndex(), mcParticles); + } else { + auto clustersInBC = aClusters.sliceBy(perBC, bc.globalIndex()); + processClusters(clustersInBC, bcTable.lastIndex()); + processClusterMCInfo(clustersInBC, bc.globalIndex(), mcParticles); + } + fMapPi0Index.clear(); + fMapEtaIndex.clear(); + } + } + PROCESS_SWITCH(bcWiseClusterSkimmer, processMC, "Run skimming for MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGEM/PhotonMeson/TableProducer/createEMEventPhoton.cxx b/PWGEM/PhotonMeson/TableProducer/createEMEventPhoton.cxx index a8ee8209a51..724b6347fa6 100644 --- a/PWGEM/PhotonMeson/TableProducer/createEMEventPhoton.cxx +++ b/PWGEM/PhotonMeson/TableProducer/createEMEventPhoton.cxx @@ -14,21 +14,22 @@ /// /// \author Daiki Sekihata, daiki.sekihata@cern.ch -#include +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGJE/DataModel/Jet.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" +#include "Common/CCDB/TriggerAliases.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" -#include "Common/CCDB/TriggerAliases.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include using namespace o2; using namespace o2::framework; @@ -38,26 +39,33 @@ using namespace o2::soa; using MyBCs = soa::Join; using MyQvectors = soa::Join; -using MyCollisions = soa::Join; +using MyCollisions = soa::Join; using MyCollisionsCent = soa::Join; // centrality table has dependency on multiplicity table. using MyCollisionsCentQvec = soa::Join; +using MyCollisionsWithSWT = soa::Join; +using MyCollisionsWithSWT_Cent = soa::Join; // centrality table has dependency on multiplicity table. +using MyCollisionsWithSWT_Cent_Qvec = soa::Join; + using MyCollisionsMC = soa::Join; using MyCollisionsMCCent = soa::Join; // centrality table has dependency on multiplicity table. using MyCollisionsMCCentQvec = soa::Join; -struct CreateEMEvent { +struct CreateEMEventPhoton { + Produces embc; Produces event; - Produces eventCov; + // Produces eventCov; Produces eventMult; Produces eventCent; Produces eventQvec; + Produces emswtbit; + Produces event_norm_info; Produces eventWeights; enum class EMEventType : int { kEvent = 0, - keventCent = 1, - keventCent_Qvec = 2, + kEvent_Cent = 1, + kEvent_Cent_Qvec = 2, kEvent_JJ = 3, }; @@ -67,9 +75,10 @@ struct CreateEMEvent { Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; Configurable dBzInput{"d_bz", -999, "bz field, -999 is automatic"}; - Configurable applyEveSelAtSkimming{"applyEveSel_at_skimming", false, "flag to apply minimal event selection at the skimming level"}; Configurable needEMCTrigger{"needEMCTrigger", false, "flag to only save events which have kTVXinEMC trigger bit. To reduce PbPb derived data size"}; Configurable needPHSTrigger{"needPHSTrigger", false, "flag to only save events which have kTVXinPHOS trigger bit. To reduce PbPb derived data size"}; + Configurable enableJJHistograms{"enableJJHistograms", false, "flag to fill JJ QA histograms for outlier rejection"}; + Configurable maxpTJetOverpTHard{"maxpTJetOverpTHard", 2., "set weight to 0 for JJ events with larger pTJet/pTHard"}; HistogramRegistry registry{"registry"}; void init(o2::framework::InitContext&) @@ -77,6 +86,10 @@ struct CreateEMEvent { auto hEventCounter = registry.add("hEventCounter", "hEventCounter", kTH1I, {{7, 0.5f, 7.5f}}); hEventCounter->GetXaxis()->SetBinLabel(1, "all"); hEventCounter->GetXaxis()->SetBinLabel(2, "sel8"); + + if (enableJJHistograms) { + auto hJJ_pTHardVsJetpT = registry.add("hJJ_pTHardVsJetpT", "hJJ_pTHardVsJetpT;#bf{#it{p}_{T}^{hard}};#bf{#it{p}_{T}^{leading jet}}", kTH2F, {{500, 0, 1000}, {500, 0, 1000}}); + } } int mRunNumber; @@ -122,18 +135,14 @@ struct CreateEMEvent { mRunNumber = bc.runNumber(); } - // PresliceUnsorted preslice_collisions_per_bc = o2::aod::evsel::foundBCId; - // std::unordered_map map_ncolls_per_bc; - - template - void skimEvent(TCollisions const& collisions, TBCs const&) + template + void skimEvent(TCollisions const& collisions, TBCs const& bcs) { - // first count the number of collisions per bc - // for (const auto& bc : bcs) { - // auto collisions_per_bc = collisions.sliceBy(preslice_collisions_per_bc, bc.globalIndex()); - // map_ncolls_per_bc[bc.globalIndex()] = collisions_per_bc.size(); - // // LOGF(info, "bc-loop | bc.globalIndex() = %d , collisions_per_bc.size() = %d", bc.globalIndex(), collisions_per_bc.size()); - // } + for (const auto& bc : bcs) { + if (bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + embc(bc.alias_raw(), bc.selection_raw(), bc.rct_raw()); // TVX is fired. + } + } // end of bc loop for (const auto& collision : collisions) { if constexpr (isMC) { @@ -145,7 +154,7 @@ struct CreateEMEvent { auto bc = collision.template foundBC_as(); initCCDB(bc); - if (applyEveSelAtSkimming && (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + if (!collision.isSelected()) { continue; } if (needEMCTrigger && !collision.alias_bit(kTVXinEMC)) { @@ -155,37 +164,55 @@ struct CreateEMEvent { continue; } - float qDefault = 999.f; // default value for q vectors if not obtained + if constexpr (eventtype == EMEventType::kEvent) { + event_norm_info(collision.alias_raw(), collision.selection_raw(), collision.rct_raw(), static_cast(10.f * collision.posZ()), 105.f); + } else if constexpr (eventtype == EMEventType::kEvent_Cent || eventtype == EMEventType::kEvent_Cent_Qvec) { + event_norm_info(collision.alias_raw(), collision.selection_raw(), collision.rct_raw(), static_cast(10.f * collision.posZ()), collision.centFT0C()); + } else { + event_norm_info(collision.alias_raw(), collision.selection_raw(), collision.rct_raw(), static_cast(10.f * collision.posZ()), 105.f); + } + + if (!collision.isEoI()) { // events with at least 1 photon for data reduction. + continue; + } + + if constexpr (isTriggerAnalysis) { + if (collision.swtaliastmp_raw() == 0) { + continue; + } else { + emswtbit(collision.swtaliastmp_raw(), collision.nInspectedTVX()); + } + } + + const float qDefault = 999.f; // default value for q vectors if not obtained - // LOGF(info, "collision-loop | bc.globalIndex() = %d, ncolls_per_bc = %d", bc.globalIndex(), map_ncolls_per_bc[bc.globalIndex()]); registry.fill(HIST("hEventCounter"), 1); if (collision.sel8()) { registry.fill(HIST("hEventCounter"), 2); } - // uint64_t tag = collision.selection_raw(); - event(collision.globalIndex(), bc.runNumber(), bc.globalBC(), collision.alias_raw(), collision.selection_raw(), bc.timestamp(), - collision.posX(), collision.posY(), collision.posZ(), + event(collision.globalIndex(), bc.runNumber(), bc.globalBC(), collision.alias_raw(), collision.selection_raw(), collision.rct_raw(), bc.timestamp(), + collision.posZ(), collision.numContrib(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); - eventCov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); + // eventCov(collision.covXX(), collision.covXY(), collision.covXZ(), collision.covYY(), collision.covYZ(), collision.covZZ(), collision.chi2()); eventMult(collision.multFT0A(), collision.multFT0C(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); - if constexpr (eventype != EMEventType::kEvent_JJ) { + if constexpr (eventtype != EMEventType::kEvent_JJ) { eventWeights(1.f); } - if constexpr (eventype == EMEventType::kEvent) { + if constexpr (eventtype == EMEventType::kEvent) { eventCent(105.f, 105.f, 105.f); eventQvec(qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault); - } else if constexpr (eventype == EMEventType::keventCent) { + } else if constexpr (eventtype == EMEventType::kEvent_Cent) { eventCent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C()); eventQvec(qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault); - } else if constexpr (eventype == EMEventType::keventCent_Qvec) { + } else if constexpr (eventtype == EMEventType::kEvent_Cent_Qvec) { eventCent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C()); const size_t qvecSize = collision.qvecFT0CReVec().size(); if (qvecSize >= 2) { // harmonics 2,3 @@ -201,84 +228,120 @@ struct CreateEMEvent { qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault, qDefault); } } // end of collision loop - // map_ncolls_per_bc.clear(); + } // end of skimEvent - void fillEventWeights(MyCollisionsMC const& collisions, aod::McCollisions const&, MyBCs const&) + Preslice perCollision_jet = aod::jet::mcCollisionId; + + using MyJJCollisions = soa::Join; + + void fillEventWeights(MyCollisionsMC const& collisions, MyJJCollisions const&, MyBCs const&, aod::FullMCParticleLevelJets const& jets) { for (const auto& collision : collisions) { if (!collision.has_mcCollision()) { continue; } + if (!collision.isSelected()) { + continue; + } auto bc = collision.template foundBC_as(); initCCDB(bc); - if (applyEveSelAtSkimming && (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { - continue; + auto mcCollision = collision.mcCollision_as(); + + // Outlier rejection: Set weight to 0 for events with large pTJet/pTHard + // ---------------------------------------------------------------------- + auto jetsInThisCollision = jets.sliceBy(perCollision_jet, mcCollision.globalIndex()); + float collisionWeight = mcCollision.weight(); + for (const auto& jet : jetsInThisCollision) { + if (jet.pt() > maxpTJetOverpTHard * mcCollision.ptHard()) + collisionWeight = 0.f; + registry.fill(HIST("hJJ_pTHardVsJetpT"), mcCollision.ptHard(), jet.pt()); } - auto mcCollision = collision.mcCollision(); - eventWeights(mcCollision.weight()); + + eventWeights(collisionWeight); } } + // for data void processEvent(MyCollisions const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } - PROCESS_SWITCH(CreateEMEvent, processEvent, "process event info", false); + PROCESS_SWITCH(CreateEMEventPhoton, processEvent, "process event info", false); - void processEventMC(MyCollisionsMC const& collisions, MyBCs const& bcs) + void processEvent_Cent(MyCollisionsCent const& collisions, MyBCs const& bcs) + { + skimEvent(collisions, bcs); + } + PROCESS_SWITCH(CreateEMEventPhoton, processEvent_Cent, "process event info", false); + + void processEvent_Cent_Qvec(MyCollisionsCentQvec const& collisions, MyBCs const& bcs) + { + skimEvent(collisions, bcs); + } + PROCESS_SWITCH(CreateEMEventPhoton, processEvent_Cent_Qvec, "process event info", false); + + void processEvent_SWT(MyCollisionsWithSWT const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } - PROCESS_SWITCH(CreateEMEvent, processEventMC, "process event info", false); + PROCESS_SWITCH(CreateEMEventPhoton, processEvent_SWT, "process event info", false); - void processEventJJMC(MyCollisionsMC const& collisions, aod::McCollisions const& mcCollisions, MyBCs const& bcs) + void processEvent_SWT_Cent(MyCollisionsWithSWT_Cent const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); - fillEventWeights(collisions, mcCollisions, bcs); + skimEvent(collisions, bcs); } - PROCESS_SWITCH(CreateEMEvent, processEventJJMC, "process event info", false); + PROCESS_SWITCH(CreateEMEventPhoton, processEvent_SWT_Cent, "process event info", false); - void processeventCent(MyCollisionsCent const& collisions, MyBCs const& bcs) + void processEvent_SWT_Cent_Qvec(MyCollisionsWithSWT_Cent_Qvec const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } - PROCESS_SWITCH(CreateEMEvent, processeventCent, "process event info", false); + PROCESS_SWITCH(CreateEMEventPhoton, processEvent_SWT_Cent_Qvec, "process event info", false); - void processeventCent_Qvec(MyCollisionsCentQvec const& collisions, MyBCs const& bcs) + // for MC + void processEventMC(MyCollisionsMC const& collisions, MyBCs const& bcs) + { + skimEvent(collisions, bcs); + } + PROCESS_SWITCH(CreateEMEventPhoton, processEventMC, "process event info", false); + + void processEventJJMC(MyCollisionsMC const& collisions, MyJJCollisions const& mcCollisions, MyBCs const& bcs, aod::FullMCParticleLevelJets const& jets) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); + fillEventWeights(collisions, mcCollisions, bcs, jets); } - PROCESS_SWITCH(CreateEMEvent, processeventCent_Qvec, "process event info", false); + PROCESS_SWITCH(CreateEMEventPhoton, processEventJJMC, "process event info", false); void processEventMC_Cent(MyCollisionsMCCent const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } - PROCESS_SWITCH(CreateEMEvent, processEventMC_Cent, "process event info", false); + PROCESS_SWITCH(CreateEMEventPhoton, processEventMC_Cent, "process event info", false); void processEventMC_Cent_Qvec(MyCollisionsMCCentQvec const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } - PROCESS_SWITCH(CreateEMEvent, processEventMC_Cent_Qvec, "process event info", false); + PROCESS_SWITCH(CreateEMEventPhoton, processEventMC_Cent_Qvec, "process event info", false); void processDummy(aod::Collisions const&) {} - PROCESS_SWITCH(CreateEMEvent, processDummy, "processDummy", true); + PROCESS_SWITCH(CreateEMEventPhoton, processDummy, "processDummy", true); }; struct AssociatePhotonToEMEvent { Produces v0kfeventid; Produces prmeleventid; - Produces prmmueventid; Produces phoseventid; Produces emceventid; + Produces prmtrackeventid; Preslice perCollisionPCM = aod::v0photonkf::collisionId; PresliceUnsorted perCollisionEl = aod::emprimaryelectron::collisionId; Preslice perCollisionPHOS = aod::skimmedcluster::collisionId; Preslice perCollisionEMC = aod::skimmedcluster::collisionId; + Preslice perCollision_track = aod::emprimarytrack::collisionId; void init(o2::framework::InitContext&) {} @@ -295,7 +358,7 @@ struct AssociatePhotonToEMEvent { } // This struct is for both data and MC. - // Note that reconstructed collisions without mc collisions are already rejected in CreateEMEvent in MC. + // Note that reconstructed collisions without mc collisions are already rejected in CreateEMEventPhoton in MC. void processPCM(aod::EMEvents const& collisions, aod::V0PhotonsKF const& photons) { @@ -317,18 +380,24 @@ struct AssociatePhotonToEMEvent { fillEventId(collisions, photons, emceventid, perCollisionEMC); } + void processChargedTrack(aod::EMEvents const& collisions, aod::EMPrimaryTracks const& tracks) + { + fillEventId(collisions, tracks, prmtrackeventid, perCollision_track); + } + void processDummy(aod::EMEvents const&) {} PROCESS_SWITCH(AssociatePhotonToEMEvent, processPCM, "process pcm-event indexing", false); PROCESS_SWITCH(AssociatePhotonToEMEvent, processElectronFromDalitz, "process dalitzee-event indexing", false); PROCESS_SWITCH(AssociatePhotonToEMEvent, processPHOS, "process phos-event indexing", false); PROCESS_SWITCH(AssociatePhotonToEMEvent, processEMC, "process emc-event indexing", false); + PROCESS_SWITCH(AssociatePhotonToEMEvent, processChargedTrack, "process indexing for charged tracks", false); PROCESS_SWITCH(AssociatePhotonToEMEvent, processDummy, "process dummy", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"create-emevent-photon"}), + adaptAnalysisTask(cfgc, TaskName{"create-emevent-photon"}), adaptAnalysisTask(cfgc, TaskName{"associate-photon-to-emevent"}), }; } diff --git a/PWGEM/PhotonMeson/TableProducer/createPCM.cxx b/PWGEM/PhotonMeson/TableProducer/createPCM.cxx index f8ba87d2cbc..4ca74633e1b 100644 --- a/PWGEM/PhotonMeson/TableProducer/createPCM.cxx +++ b/PWGEM/PhotonMeson/TableProducer/createPCM.cxx @@ -554,15 +554,8 @@ struct createPCM { PROCESS_SWITCH(createPCM, processTrkCollAsso, "create V0s with track-to-collision associator", false); }; -// Extends the v0data table with expression columns -struct v0Initializer { - Spawns v0cores; - void init(InitContext const&) {} -}; - WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"v0-finder"}), - adaptAnalysisTask(cfgc, TaskName{"v0-initializer"})}; + adaptAnalysisTask(cfgc, TaskName{"v0-finder"})}; } diff --git a/PWGEM/PhotonMeson/TableProducer/gammaSelection.cxx b/PWGEM/PhotonMeson/TableProducer/gammaSelection.cxx deleted file mode 100644 index 7a3708d480b..00000000000 --- a/PWGEM/PhotonMeson/TableProducer/gammaSelection.cxx +++ /dev/null @@ -1,193 +0,0 @@ -// 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. - -/// \brief skim cluster information to write photon cluster table in AO2D.root -/// dependencies: skimmergammacalo, skimmergammaconversions, skimmer-phos -/// \author marvin.hemmer@cern.ch - -// TODO: add PCM table -#include - -#include "PWGEM/PhotonMeson/Utils/gammaSelectionCuts.h" - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" - -// includes for the R recalculation -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "CCDB/BasicCCDBManager.h" - -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct gammaSelection { - - uint64_t EMC_CutModeBit; - - Preslice perEMCClusterMT = o2::aod::caloextra::clusterId; - - Produces tableGammaReco; - Produces tableEMCCuts; - - // Configurable for filter/cuts - Configurable EMC_minTime{"EMC_minTime", -20., "Minimum cluster time for EMCal time cut"}; - Configurable EMC_maxTime{"EMC_maxTime", +25., "Maximum cluster time for EMCal time cut"}; - Configurable EMC_minM02{"EMC_minM02", 0.1, "Minimum M02 for EMCal M02 cut"}; - Configurable EMC_maxM02{"EMC_maxM02", 0.7, "Maximum M02 for EMCal M02 cut"}; - Configurable EMC_minE{"EMC_minE", 0.7, "Minimum cluster energy for EMCal energy cut"}; - Configurable EMC_minNCell{"EMC_minNCell", 1, "Minimum number of cells per cluster for EMCal NCell cut"}; - Configurable> EMC_TM_Eta{"EMC_TM_Eta", {0.01f, 4.07f, -2.5f}, "|eta| <= [0]+(pT+[1])^[2] for EMCal track matching"}; - Configurable> EMC_TM_Phi{"EMC_TM_Phi", {0.015f, 3.65f, -2.f}, "|phi| <= [0]+(pT+[1])^[2] for EMCal track matching"}; - Configurable EMC_Eoverp{"EMC_Eoverp", 1.75, "Minimum cluster energy over track momentum for EMCal track matching"}; - Configurable EMC_CutMode{"EMC_CutMode", "0", "Cut Mode that is run. Each bit is a different setting. The first bit will use the cuts from the configurables."}; - - Configurable PHOS_minTime{"PHOS_minTime", -30., "Minimum cluster time for PHOS time cut"}; - Configurable PHOS_maxTime{"PHOS_maxTime", +30., "Maximum cluster time for PHOS time cut"}; - Configurable PHOS_minM02{"PHOS_minM02", 0.1, "Minimum M02 for PHOS M02 cut"}; - Configurable PHOS_minE{"PHOS_minE", 0.3, "Minimum cluster energy for PHOS energy cut"}; - Configurable PHOS_minENCell{"PHOS_minENCell", 0.1, "Threshold cluster energy for switch for PHOS NCell and M02 cut"}; - Configurable PHOS_minNCell{"PHOS_minNCell", 1, "Minimum number of cells per cluster for PHOS NCell cut"}; - Configurable PHOS_TM_Eta{"PHOS_TM_Eta", 0.02f, "|eta| <= value for PHOS track matching"}; - Configurable PHOS_TM_Phi{"PHOS_TM_Phi", 0.08f, "|phi| <= value for PHOS track matching"}; - - Configurable PHOS_QA{"PHOS_QA", 0b0, "Flag to enable PHOS related QA plots. 1st bit for TM QA."}; - - HistogramRegistry EMCHistos{ - "EMCHistos", - {}, - OutputObjHandlingPolicy::QAObject, - true, - true}; - - HistogramRegistry PHOSHistos{ - "PHOSHistos", - {}, - OutputObjHandlingPolicy::QAObject, - true, - true}; - - void init(o2::framework::InitContext&) - { - EMC_CutModeBit = stoi(EMC_CutMode, 0, 2); - std::bitset<64> EMC_CutModeBitSet(EMC_CutModeBit); - // EMCal - EMCHistos.add("hClusterEIn", "hClusterEIn", gHistoSpec_clusterECuts); - EMCHistos.add("hClusterEOut", "hClusterEOut", gHistoSpec_clusterECuts); - auto hCaloCuts_EMC = EMCHistos.add("hCaloCuts_EMC", "hCaloCuts_EMC", kTH2I, {{7, -0.5, 6.5}, {64, -0.5, 63.5}}); - hCaloCuts_EMC->GetXaxis()->SetBinLabel(1, "in"); - hCaloCuts_EMC->GetXaxis()->SetBinLabel(2, "#it{t}_{cluster} cut"); - hCaloCuts_EMC->GetXaxis()->SetBinLabel(3, "#it{M}_{02} cut"); - hCaloCuts_EMC->GetXaxis()->SetBinLabel(4, "#it{E} cut"); - hCaloCuts_EMC->GetXaxis()->SetBinLabel(5, "#it{N}_{cell} cut"); - hCaloCuts_EMC->GetXaxis()->SetBinLabel(6, "TM"); - hCaloCuts_EMC->GetXaxis()->SetBinLabel(7, "out"); - - LOG(info) << "| ECMal cluster cut settings:"; - LOG(info) << "|\t Timing cut: " << EMC_minTime << " < t < " << EMC_maxTime; - LOG(info) << "|\t M02 cut: " << EMC_minM02 << " < M02 < " << EMC_maxM02; - LOG(info) << "|\t E_min cut: E_cluster > " << EMC_minE; - LOG(info) << "|\t N_cell cut: N_cell > " << EMC_minNCell; - LOG(info) << "|\t TM |eta|: |eta| <= " << EMC_TM_Eta->at(0) << " + (pT + " << EMC_TM_Eta->at(1) << ")^" << EMC_TM_Eta->at(2); - LOG(info) << "|\t TM |phi|: |phi| <= " << EMC_TM_Phi->at(0) << " + (pT + " << EMC_TM_Phi->at(1) << ")^" << EMC_TM_Phi->at(2); - LOG(info) << "|\t TM E/p: E/p < " << EMC_Eoverp; - LOG(info) << "|\t Cut bit is set to: " << EMC_CutModeBitSet << std::endl; - - gatherCutsEMC(EMC_minTime, EMC_maxTime, EMC_minM02, EMC_maxM02, EMC_minE, EMC_minNCell, EMC_TM_Eta, EMC_TM_Phi, EMC_Eoverp); - - // PHOS - PHOSHistos.add("hClusterEIn", "hClusterEIn", gHistoSpec_clusterECuts); - PHOSHistos.add("hClusterEOut", "hClusterEOut", gHistoSpec_clusterECuts); - auto hCaloCuts_PHOS = PHOSHistos.add("hCaloCuts_PHOS", "hCaloCuts_PHOS", kTH1I, {{7, -0.5, 6.5}}); - hCaloCuts_PHOS->GetXaxis()->SetBinLabel(1, "in"); - hCaloCuts_PHOS->GetXaxis()->SetBinLabel(2, "#it{t}_{cluster} cut"); - hCaloCuts_PHOS->GetXaxis()->SetBinLabel(3, "#it{M}_{02} cut"); - hCaloCuts_PHOS->GetXaxis()->SetBinLabel(4, "#it{E} cut"); - hCaloCuts_PHOS->GetXaxis()->SetBinLabel(5, "#it{N}_{cell} cut"); - hCaloCuts_PHOS->GetXaxis()->SetBinLabel(6, "TM"); - hCaloCuts_PHOS->GetXaxis()->SetBinLabel(7, "out"); - if (PHOS_QA & 0b1) { - PHOSHistos.add("clusterTM_dEtadPhi", "cluster trackmatching dEta/dPhi;d#it{#eta};d#it{#varphi} (rad)", kTH2F, {{100, -0.2, 0.2}, {100, -0.2, 0.2}}); // dEta dPhi map of matched tracks - } - - LOG(info) << "| PHOS cluster cut settings:"; - LOG(info) << "|\t Timing cut: " << PHOS_minTime << " < t < " << PHOS_maxTime; - LOG(info) << "|\t NCell cut: " << PHOS_minNCell << " <= NCell for E >= " << PHOS_minENCell; - LOG(info) << "|\t M02 cut: " << PHOS_minM02 << " < M02 for E >= " << PHOS_minENCell; - LOG(info) << "|\t E_min cut: E_cluster > " << PHOS_minE; - LOG(info) << "|\t TM |eta|: |eta| <= " << PHOS_TM_Eta; - LOG(info) << "|\t TM |phi|: |phi| <= " << PHOS_TM_Phi << std::endl; - } - - void processRec(aod::EMEvents const&, aod::SkimEMCClusters const& emcclusters, aod::SkimEMCMTs const& matchedtracks, aod::PHOSClusters const& phosclusters) - { - for (const auto& emccluster : emcclusters) { // loop of EMC clusters - uint64_t EMC_CutBit = doPhotonCutsEMC(EMC_CutModeBit, emccluster, matchedtracks, perEMCClusterMT, EMCHistos); - tableEMCCuts(emccluster.globalIndex(), EMC_CutBit); - } // end loop of EMC clusters - - for (const auto& phoscluster : phosclusters) { // loop over PHOS clusters - PHOSHistos.fill(HIST("hClusterEIn"), phoscluster.e(), 0); - PHOSHistos.fill(HIST("hCaloCuts_PHOS"), 0); - - if (phoscluster.time() > PHOS_maxTime || phoscluster.time() < PHOS_minTime) { - PHOSHistos.fill(HIST("hCaloCuts_PHOS"), 1); - continue; - } - if (!(phoscluster.e() >= PHOS_minENCell && phoscluster.m02() > PHOS_minM02)) { - PHOSHistos.fill(HIST("hCaloCuts_PHOS"), 2); - continue; - } - if (phoscluster.e() <= PHOS_minE) { - PHOSHistos.fill(HIST("hCaloCuts_PHOS"), 3); - continue; - } - if (!(phoscluster.e() >= PHOS_minENCell && phoscluster.nCells() > PHOS_minNCell)) { - PHOSHistos.fill(HIST("hCaloCuts_PHOS"), 4); - continue; - } - - // TODO: add track matching for PHOS when available! - // track matching - bool hasMatchedTrack_PHOS = false; - // double dEta_PHOS, dPhi_PHOS; - // // only consider closest match - // dEta_PHOS = phoscluster.tracketa() - phoscluster.eta(); - // dPhi_PHOS = phoscluster.trackphi() - phoscluster.phi(); - // if ((fabs(dEta_PHOS) < PHOS_TM_Eta) && (fabs(dPhi_PHOS) < PHOS_TM_Phi)) { - // hasMatchedTrack_PHOS = true; - // if (PHOS_QA & 0b1) { - // EMCHistos.fill(HIST("clusterTM_dEtadPhi"), dEta_PHOS, dPhi_PHOS); - // } - // } - if (hasMatchedTrack_PHOS) { - PHOSHistos.fill(HIST("hCaloCuts_PHOS"), 5); - } else { - PHOSHistos.fill(HIST("hClusterEOut"), phoscluster.e(), 0); - PHOSHistos.fill(HIST("hCaloCuts_PHOS"), 6); - tableGammaReco(phoscluster.collisionId(), 2, - phoscluster.e(), phoscluster.eta(), phoscluster.phi(), 0, phoscluster.globalIndex()); - } - } // end loop of PHOS clusters - } - PROCESS_SWITCH(gammaSelection, processRec, "process only reconstructed info", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; - return workflow; -} diff --git a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx index b667eadb549..0a62a60af1b 100644 --- a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx +++ b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2023 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -15,43 +15,43 @@ // // \author Daiki Sekihata , Tokyo -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Math/Vector4D.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" +#include "PWGEM/PhotonMeson/Utils/TrackSelection.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" #include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" +#include "Common/Core/TPCVDriftManager.h" +#include "Common/Core/TableHelper.h" #include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" +#include "Tools/KFparticle/KFUtilities.h" + #include "CCDB/BasicCCDBManager.h" -#include "Common/Core/TableHelper.h" -#include "Common/Core/TPCVDriftManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" -#include "Tools/KFparticle/KFUtilities.h" +#include "Math/Vector4D.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" -#include "PWGEM/PhotonMeson/Utils/TrackSelection.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::soa; @@ -61,18 +61,18 @@ using namespace o2::constants::physics; using namespace o2::pwgem::photonmeson; using std::array; -using MyCollisions = soa::Join; +using MyCollisions = soa::Join; using MyCollisionsWithSWT = soa::Join; using MyCollisionsMC = soa::Join; using MyTracksIU = soa::Join; -using MyTracksIUMC = soa::Join; +using MyTracksIUMC = soa::Join; struct PhotonConversionBuilder { Produces v0photonskf; - Produces v0photonskfcov; Produces v0legs; - Produces events_ngpcm; + // Produces v0photonskfcov; + // Produces events_ngpcm; // CCDB options Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -81,18 +81,18 @@ struct PhotonConversionBuilder { Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; - Configurable inherit_from_emevent_photon{"inherit_from_emevent_photon", false, "flag to inherit task options from emevent-photon"}; // Operation and minimisation criteria Configurable d_bz_input{"d_bz", -999, "bz field, -999 is automatic"}; Configurable useMatCorrType{"useMatCorrType", 0, "0: none, 1: TGeo, 2: LUT"}; - Configurable applyEveSel_at_skimming{"applyEveSel_at_skimming", false, "flag to apply minimal event selection at the skimming level"}; // single track cuts Configurable min_ncluster_tpc{"min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable mincrossedrows{"mincrossedrows", 40, "min crossed rows"}; Configurable moveTPCTracks{"moveTPCTracks", true, "Move TPC-only tracks under the collision assumption"}; Configurable disableITSonlyTracks{"disableITSonlyTracks", false, "disable ITSonly tracks in V0 legs"}; + Configurable disableTPConlyTracks{"disableTPConlyTracks", false, "disable TPConly tracks in V0 legs"}; + Configurable requireITShit{"requireITShit", false, "require ITS hit to V0 legs"}; Configurable maxchi2tpc{"maxchi2tpc", 5.0, "max chi2/NclsTPC"}; // default 4.0 + 1.0 Configurable maxchi2its{"maxchi2its", 6.0, "max chi2/NclsITS"}; // default 5.0 + 1.0 @@ -102,8 +102,6 @@ struct PhotonConversionBuilder { Configurable max_frac_shared_clusters_tpc{"max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; Configurable dcanegtopv{"dcanegtopv", 0.1, "DCA Neg To PV"}; Configurable dcapostopv{"dcapostopv", 0.1, "DCA Pos To PV"}; - Configurable min_pt_leg_at_sv{"min_pt_leg_at_sv", 0.0, "min pT for v0 legs at SV"}; // this is obsolete. - Configurable max_mean_its_cluster_size{"max_mean_its_cluster_size", 16.f, "max. x cos(lambda) for ITSonly tracks"}; // this is to suppress random combination for V0s with ITSonly tracks. default 3 + 1 for skimming. Configurable maxX{"maxX", 83.1, "max X for track IU"}; Configurable min_pt_trackiu{"min_pt_trackiu", 0.05, "min pT for trackiu"}; // this comes from online processing. pT of track seed is above 50 MeV/c in B = 0.5 T, 20 MeV/c in B = 0.2 T. @@ -115,6 +113,7 @@ struct PhotonConversionBuilder { Configurable max_dcav0dau_itsibss{"max_dcav0dau_itsibss", 1.0, "max distance btween 2 legs to V0s with ITS hits on ITSib SS"}; Configurable max_dcav0dau_tpc_inner_fc{"max_dcav0dau_tpc_inner_fc", 1.5, "max distance btween 2 legs to V0s with ITS hits on TPC inner FC"}; Configurable min_v0radius{"min_v0radius", 1.0, "min v0 radius"}; + Configurable max_v0radius{"max_v0radius", 90.0, "max v0 radius"}; Configurable margin_r_its{"margin_r_its", 3.0, "margin for r cut in cm"}; Configurable margin_r_tpc{"margin_r_tpc", 7.0, "margin for r cut in cm"}; Configurable margin_r_itstpc_tpc{"margin_r_itstpc_tpc", 7.0, "margin for r cut in cm"}; @@ -156,7 +155,7 @@ struct PhotonConversionBuilder { {"V0/hCosPARZ_Rxy", "cosine of pointing angle;r_{xy} (cm);cosine of pointing angle", {HistType::kTH2F, {{200, 0, 100}, {100, 0.99f, 1.f}}}}, {"V0/hPCA", "distance between 2 legs at SV;PCA (cm)", {HistType::kTH1F, {{500, 0.0f, 5.f}}}}, {"V0/hPCA_Rxy", "distance between 2 legs at SV;R_{xy} (cm);PCA (cm)", {HistType::kTH2F, {{200, 0, 100}, {500, 0.0f, 5.f}}}}, - {"V0/hPCA_CosPA", "distance between 2 legs at SV vs. cosPA;cosine of pointing angle;PCA (cm)", {HistType::kTH2F, {{100, 0.9, 1}, {500, 0.0f, 5.f}}}}, + {"V0/hPCA_CosPA", "distance between 2 legs at SV vs. cosPA;cosine of pointing angle;PCA (cm)", {HistType::kTH2F, {{100, 0.99, 1}, {500, 0.0f, 5.f}}}}, {"V0/hDCAxyz", "DCA to PV;DCA_{xy} (cm);DCA_{z} (cm)", {HistType::kTH2F, {{200, -5.f, +5.f}, {200, -5.f, +5.f}}}}, {"V0/hMeeSV_Rxy", "mee at SV vs. R_{xy};R_{xy} (cm);m_{ee} at SV (GeV/c^{2})", {HistType::kTH2F, {{200, 0.0f, 100.f}, {100, 0, 0.1f}}}}, {"V0/hRxy_minX_ITSonly_ITSonly", "min trackiu X vs. R_{xy};trackiu X (cm);min trackiu X - R_{xy} (cm)", {HistType::kTH2F, {{100, 0.0f, 100.f}, {100, -50.0, 50.0f}}}}, @@ -167,13 +166,14 @@ struct PhotonConversionBuilder { {"V0/hPCA_diffX", "PCA vs. trackiu X - R_{xy};distance btween 2 legs (cm);min trackiu X - R_{xy} (cm)", {HistType::kTH2F, {{500, 0.0f, 5.f}, {100, -50.0, 50.0f}}}}, {"V0Leg/hPt", "pT of leg at SV;p_{T,e} (GeV/c)", {HistType::kTH1F, {{1000, 0.0f, 10.0f}}}}, {"V0Leg/hEtaPhi", "#eta vs. #varphi of leg at SV;#varphi (rad.);#eta", {HistType::kTH2F, {{72, 0.0f, 2 * M_PI}, {200, -1, +1}}}}, + {"V0Leg/hRelDeltaPt", "pT resolution;p_{T} (GeV/c);#Deltap_{T}/p_{T}", {HistType::kTH2F, {{1000, 0.f, 10.f}, {100, 0, 1}}}}, {"V0Leg/hDCAxyz", "DCA xy vs. z to PV;DCA_{xy} (cm);DCA_{z} (cm)", {HistType::kTH2F, {{200, -50.f, 50.f}, {200, -50.f, +50.f}}}}, {"V0Leg/hdEdx_Pin", "TPC dE/dx vs. p_{in};p_{in} (GeV/c);TPC dE/dx", {HistType::kTH2F, {{1000, 0.f, 10.f}, {200, 0.f, 200.f}}}}, {"V0Leg/hTPCNsigmaEl", "TPC dE/dx vs. p_{in};p_{in} (GeV/c);n #sigma_{e}^{TPC}", {HistType::kTH2F, {{1000, 0.f, 10.f}, {100, -5.f, +5.f}}}}, {"V0Leg/hXZ", "track iu x vs. z;z (cm);x (cm)", {HistType::kTH2F, {{200, -100.f, 100.f}, {200, 0.f, 100.f}}}}, }}; - void init(InitContext& initContext) + void init(InitContext&) { mRunNumber = 0; d_bz = 0; @@ -185,10 +185,6 @@ struct PhotonConversionBuilder { ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); - if (inherit_from_emevent_photon) { - getTaskOptionValue(initContext, "create-emevent-photon", "applyEveSel_at_skimming", applyEveSel_at_skimming.value, true); - } - if (useMatCorrType == 1) { LOGF(info, "TGeo correction requested, loading geometry"); if (!o2::base::GeometryManager::isGeometryLoaded()) { @@ -218,7 +214,7 @@ struct PhotonConversionBuilder { if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } o2::base::Propagator::initFieldFromGRP(&grpmag); @@ -281,6 +277,14 @@ struct PhotonConversionBuilder { return false; } + if (disableTPConlyTracks && isTPConlyTrack(track)) { + return false; + } + + if (requireITShit && !track.hasITS()) { + return false; + } + if (track.x() > maxX) { return false; } @@ -320,21 +324,6 @@ struct PhotonConversionBuilder { return false; } } - - if (isITSonlyTrack(track)) { - uint32_t itsClusterSizes = track.itsClusterSizes(); - int total_cluster_size = 0, nl = 0; - for (unsigned int layer = 0; layer < 7; layer++) { - int cluster_size_per_layer = (itsClusterSizes >> (layer * 4)) & 0xf; - if (cluster_size_per_layer > 0) { - nl++; - } - total_cluster_size += cluster_size_per_layer; - } - if (static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(track.tgl())) > max_mean_its_cluster_size) { - return false; - } - } } return true; @@ -348,10 +337,10 @@ struct PhotonConversionBuilder { float px = kfp.GetPx(); float py = kfp.GetPy(); float cospaXY = RecoDecay::dotProd(std::array{lx, ly}, std::array{px, py}) / (RecoDecay::sqrtSumOfSquares(lx, ly) * RecoDecay::sqrtSumOfSquares(px, py)); - if (cospaXY < -1.) { - return -1.; - } else if (cospaXY > 1.) { - return 1.; + if (cospaXY < -1.f) { + return -1.f; + } else if (cospaXY > 1.f) { + return 1.f; } return cospaXY; } @@ -367,24 +356,38 @@ struct PhotonConversionBuilder { float pz = kfp.GetPz(); float cospaRZ = RecoDecay::dotProd(std::array{lt, lz}, std::array{pt, pz}) / (RecoDecay::sqrtSumOfSquares(lt, lz) * RecoDecay::sqrtSumOfSquares(pt, pz)); - if (cospaRZ < -1.) { - return -1.; - } else if (cospaRZ > 1.) { - return 1.; + if (cospaRZ < -1.f) { + return -1.f; + } else if (cospaRZ > 1.f) { + return 1.f; } return cospaRZ; } - template - void fillTrackTable(TTrack const& track, TShiftedTrack const& shiftedtrack, TKFParticle const& kfp, float dcaXY, float dcaZ) + template + void fillTrackTable(TTrack const& track, TShiftedTrack const& shiftedtrack, TKFParticle const& kfp, const float dcaXY, const float dcaZ) { + float itsChi2NCl = (track.hasITS() && track.itsChi2NCl() > 0.f) ? track.itsChi2NCl() : -299.f; + float tpcChi2NCl = (track.hasTPC() && track.tpcChi2NCl() > 0.f) ? track.tpcChi2NCl() : -299.f; + float tpcSignal = track.hasTPC() ? track.tpcSignal() : 0.f; + float tpcNSigmaEl = track.hasTPC() ? track.tpcNSigmaEl() : -299.f; + float tpcNSigmaPi = track.hasTPC() ? track.tpcNSigmaPi() : -299.f; + + float mcTunedTPCSignal = 0.f; + if constexpr (isMC) { + mcTunedTPCSignal = track.mcTunedTPCSignal(); + if (track.hasTPC()) { + mcTunedTPCSignal = track.mcTunedTPCSignal(); + } + } + v0legs(track.collisionId(), track.globalIndex(), track.sign(), - kfp.GetPx(), kfp.GetPy(), kfp.GetPz(), dcaXY, dcaZ, + kfp.GetPx(), kfp.GetPy(), kfp.GetPz(), static_cast(dcaXY * 1e+2), static_cast(dcaZ * 1e+2), track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), track.tpcNClsShared(), - track.tpcChi2NCl(), track.tpcInnerParam(), track.tpcSignal(), - track.tpcNSigmaEl(), track.tpcNSigmaPi(), - track.itsClusterSizes(), track.itsChi2NCl(), track.detectorMap(), - shiftedtrack.getX(), shiftedtrack.getY(), shiftedtrack.getZ(), shiftedtrack.getTgl()); + static_cast(tpcChi2NCl * 1e+2), track.tpcInnerParam(), static_cast(tpcSignal * 1e+2), + static_cast(tpcNSigmaEl * 1e+2), static_cast(tpcNSigmaPi * 1e+2), + track.itsClusterSizes(), static_cast(itsChi2NCl * 1e+2), track.detectorMap(), static_cast(mcTunedTPCSignal * 1e+2), + static_cast(shiftedtrack.getX() * 1e+2), static_cast(shiftedtrack.getY() * 1e+2), static_cast(shiftedtrack.getZ() * 1e+2), shiftedtrack.getTgl()); } template @@ -394,6 +397,7 @@ struct PhotonConversionBuilder { const auto& pos = v0.template posTrack_as(); const auto& ele = v0.template negTrack_as(); const auto& collision = v0.template collision_as(); // collision where this v0 belongs to. + // LOGF(info, "v0.collisionId() = %d, pos.collisionId() = %d, ele.collisionId() = %d", v0.collisionId(), pos.collisionId(), ele.collisionId()); if (pos.sign() * ele.sign() > 0) { // reject same sign pair return; @@ -421,8 +425,13 @@ struct PhotonConversionBuilder { // LOGF(info, "v0.collisionId() = %d , v0.posTrackId() = %d , v0.negTrackId() = %d", v0.collisionId(), v0.posTrackId(), v0.negTrackId()); + // if(isTPConlyTrack(ele)){ + // // LOGF(info, "TPConly: ele.globalIndex() = %d, ele.x() = %f, ele.y() = %f, ele.z() = %f, ele.tgl() = %f, ele.alpha() = %f, ele.snp() = %f, ele.signed1Pt() = %f", ele.globalIndex(), ele.x(), ele.y(), ele.z(), ele.tgl(), ele.alpha(), ele.snp(), ele.signed1Pt()); + // // LOGF(info, "TPConly: ele.globalIndex() = %d, ele.cYY() = %f, ele.cZY() = %f, ele.cZZ() = %f, ele.cSnpY() = %f, ele.cSnpZ() = %f, ele.cSnpSnp() = %f, ele.cTglY() = %f, ele.cTglZ() = %f, ele.cTglSnp() = %f, ele.cTglTgl() = %f, ele.c1PtY() = %f, ele.c1PtZ() = %f, ele.c1PtSnp() = %f, ele.c1PtTgl() = %f, ele.c1Pt21Pt2() = %f", ele.globalIndex(), ele.cYY(), ele.cZY(), ele.cZZ(), ele.cSnpY(), ele.cSnpZ(), ele.cSnpSnp(), ele.cTglY(), ele.cTglZ(), ele.cTglSnp(), ele.cTglTgl(), ele.c1PtY(), ele.c1PtZ(), ele.c1PtSnp(), ele.c1PtTgl(), ele.c1Pt21Pt2()); + // } + // Calculate DCA with respect to the collision associated to the v0, not individual tracks - gpu::gpustd::array dcaInfo; + std::array dcaInfo; auto pTrack = getTrackParCov(pos); if (moveTPCTracks && isTPConlyTrack(pos) && !mVDriftMgr.moveTPCTrack(collision, pos, pTrack)) { @@ -446,7 +455,7 @@ struct PhotonConversionBuilder { auto eledcaXY = dcaInfo[0]; auto eledcaZ = dcaInfo[1]; - if (fabs(posdcaXY) < dcapostopv || fabs(eledcaXY) < dcanegtopv) { + if (std::fabs(posdcaXY) < dcapostopv || std::fabs(eledcaXY) < dcanegtopv) { return; } @@ -456,7 +465,7 @@ struct PhotonConversionBuilder { if (rxy_tmp > maxX + margin_r_tpc) { return; } - if (rxy_tmp < fabs(xyz[2]) * std::tan(2 * std::atan(std::exp(-max_eta_v0))) - margin_z) { + if (rxy_tmp < std::fabs(xyz[2]) * std::tan(2 * std::atan(std::exp(-max_eta_v0))) - margin_z) { return; // RZ line cut } @@ -494,10 +503,10 @@ struct PhotonConversionBuilder { if (rxy > maxX + margin_r_tpc) { return; } - if (rxy < fabs(gammaKF_DecayVtx.GetZ()) * std::tan(2 * std::atan(std::exp(-max_eta_v0))) - margin_z) { + if (rxy < std::fabs(gammaKF_DecayVtx.GetZ()) * std::tan(2 * std::atan(std::exp(-max_eta_v0))) - margin_z) { return; // RZ line cut } - if (rxy < min_v0radius) { + if (rxy < min_v0radius || max_v0radius < rxy) { return; } @@ -557,7 +566,7 @@ struct PhotonConversionBuilder { // LOGF(info, "gammaKF_PV.GetPy() = %f, gammaKF_DecayVtx.GetPy() = %f, gammaKF_DecayVtx2.GetPy() = %f", gammaKF_PV.GetPy(), gammaKF_DecayVtx.GetPy(), gammaKF_DecayVtx2.GetPy()); // LOGF(info, "gammaKF_PV.GetPz() = %f, gammaKF_DecayVtx.GetPz() = %f, gammaKF_DecayVtx2.GetPz() = %f", gammaKF_PV.GetPz(), gammaKF_DecayVtx.GetPz(), gammaKF_DecayVtx2.GetPz()); - if (fabs(v0eta) > max_eta_v0 || v0pt < min_pt_v0) { + if (std::fabs(v0eta) > max_eta_v0 || v0pt < min_pt_v0) { return; } @@ -595,9 +604,6 @@ struct PhotonConversionBuilder { float pos_pt = RecoDecay::sqrtSumOfSquares(kfp_pos_DecayVtx.GetPx(), kfp_pos_DecayVtx.GetPy()); float ele_pt = RecoDecay::sqrtSumOfSquares(kfp_ele_DecayVtx.GetPx(), kfp_ele_DecayVtx.GetPy()); - if (pos_pt < min_pt_leg_at_sv || ele_pt < min_pt_leg_at_sv) { - return; - } if (isITSonlyTrack(pos) && pos_pt > maxpt_itsonly) { return; @@ -607,6 +613,11 @@ struct PhotonConversionBuilder { return; } + float chi2kf = gammaKF_DecayVtx.GetChi2() / gammaKF_DecayVtx.GetNDF(); + if (chi2kf > 6e+3) { // protection for uint16. + return; + } + // calculate DCAxy,z to PV float v0mom = RecoDecay::sqrtSumOfSquares(gammaKF_DecayVtx.GetPx(), gammaKF_DecayVtx.GetPy(), gammaKF_DecayVtx.GetPz()); float length = RecoDecay::sqrtSumOfSquares(gammaKF_DecayVtx.GetX() - collision.posX(), gammaKF_DecayVtx.GetY() - collision.posY(), gammaKF_DecayVtx.GetZ() - collision.posZ()); @@ -615,7 +626,7 @@ struct PhotonConversionBuilder { float dca_z_v0_to_pv = (gammaKF_DecayVtx.GetZ() - gammaKF_DecayVtx.GetPz() * cospa_kf * length / v0mom) - collision.posZ(); float sign_tmp = dca_x_v0_to_pv * dca_y_v0_to_pv > 0 ? +1.f : -1.f; float dca_xy_v0_to_pv = RecoDecay::sqrtSumOfSquares(dca_x_v0_to_pv, dca_y_v0_to_pv) * sign_tmp; - if (abs(dca_xy_v0_to_pv) > max_dcatopv_xy_v0 || abs(dca_z_v0_to_pv) > max_dcatopv_z_v0) { + if (std::fabs(dca_xy_v0_to_pv) > max_dcatopv_xy_v0 || std::fabs(dca_z_v0_to_pv) > max_dcatopv_z_v0) { return; } @@ -647,8 +658,6 @@ struct PhotonConversionBuilder { registry.fill(HIST("V0/hCosPAXY_Rxy"), rxy, cospaXY_kf); registry.fill(HIST("V0/hCosPARZ_Rxy"), rxy, cospaRZ_kf); - float chi2kf = gammaKF_DecayVtx.GetChi2() / gammaKF_DecayVtx.GetNDF(); - for (auto& leg : {kfp_pos_DecayVtx, kfp_ele_DecayVtx}) { float legpt = RecoDecay::sqrtSumOfSquares(leg.GetPx(), leg.GetPy()); float legeta = RecoDecay::eta(std::array{leg.GetPx(), leg.GetPy(), leg.GetPz()}); @@ -660,8 +669,10 @@ struct PhotonConversionBuilder { registry.fill(HIST("V0Leg/hdEdx_Pin"), leg.tpcInnerParam(), leg.tpcSignal()); registry.fill(HIST("V0Leg/hTPCNsigmaEl"), leg.tpcInnerParam(), leg.tpcNSigmaEl()); } // end of leg loop - registry.fill(HIST("V0Leg/hXZ"), pTrack.getZ(), pTrack.getX()); - registry.fill(HIST("V0Leg/hXZ"), nTrack.getZ(), nTrack.getX()); + for (auto& leg : {pTrack, nTrack}) { + registry.fill(HIST("V0Leg/hXZ"), leg.getZ(), leg.getX()); + registry.fill(HIST("V0Leg/hRelDeltaPt"), leg.getPt(), leg.getPt() * std::sqrt(leg.getSigma1Pt2())); + } // end of leg loop registry.fill(HIST("V0Leg/hDCAxyz"), posdcaXY, posdcaZ); registry.fill(HIST("V0Leg/hDCAxyz"), eledcaXY, eledcaZ); @@ -673,13 +684,14 @@ struct PhotonConversionBuilder { v0photonskf(collision.globalIndex(), v0.globalIndex(), v0legs.lastIndex() + 1, v0legs.lastIndex() + 2, gammaKF_DecayVtx.GetX(), gammaKF_DecayVtx.GetY(), gammaKF_DecayVtx.GetZ(), gammaKF_PV.GetPx(), gammaKF_PV.GetPy(), gammaKF_PV.GetPz(), - v0_sv.M(), dca_xy_v0_to_pv, dca_z_v0_to_pv, - cospa_kf, pca_kf, alpha, qt, chi2kf); + static_cast(v0_sv.M() * 1e+5), static_cast(dca_xy_v0_to_pv * 1e+2), static_cast(dca_z_v0_to_pv * 1e+2), + static_cast(cospa_kf * 5e+4), static_cast(cospaXY_kf * 5e+4), static_cast(cospaRZ_kf * 5e+4), + static_cast(pca_kf * 1e+4), static_cast(alpha * 1e+4), static_cast(qt * 1e+5), static_cast(chi2kf * 1e+1)); - v0photonskfcov(gammaKF_PV.GetCovariance(9), gammaKF_PV.GetCovariance(14), gammaKF_PV.GetCovariance(20), gammaKF_PV.GetCovariance(13), gammaKF_PV.GetCovariance(19), gammaKF_PV.GetCovariance(18)); + // v0photonskfcov(gammaKF_PV.GetCovariance(9), gammaKF_PV.GetCovariance(14), gammaKF_PV.GetCovariance(20), gammaKF_PV.GetCovariance(13), gammaKF_PV.GetCovariance(19), gammaKF_PV.GetCovariance(18)); - fillTrackTable(pos, pTrack, kfp_pos_DecayVtx, posdcaXY, posdcaZ); // positive leg first - fillTrackTable(ele, nTrack, kfp_ele_DecayVtx, eledcaXY, eledcaZ); // negative leg second + fillTrackTable(pos, pTrack, kfp_pos_DecayVtx, posdcaXY, posdcaZ); // positive leg first + fillTrackTable(ele, nTrack, kfp_ele_DecayVtx, eledcaXY, eledcaZ); // negative leg second } // end of fill table } @@ -700,10 +712,8 @@ struct PhotonConversionBuilder { } } - if constexpr (enableFilter) { - if (!collision.isSelected()) { - continue; - } + if (!collision.isSelected()) { + continue; } if constexpr (isTriggerAnalysis) { @@ -714,14 +724,10 @@ struct PhotonConversionBuilder { nv0_map[collision.globalIndex()] = 0; - const auto& bc = collision.template bc_as(); + const auto& bc = collision.template foundBC_as(); initCCDB(bc); registry.fill(HIST("hCollisionCounter"), 1); - if (applyEveSel_at_skimming && (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { - continue; - } - updateCCDB(bc); // delay update until is needed const auto& v0s_per_coll = v0s.sliceBy(perCollision, collision.globalIndex()); @@ -812,7 +818,7 @@ struct PhotonConversionBuilder { continue; } } - events_ngpcm(nv0_map[collision.globalIndex()]); + // events_ngpcm(nv0_map[collision.globalIndex()]); } // end of collision loop pca_map.clear(); @@ -846,13 +852,13 @@ struct PhotonConversionBuilder { } PROCESS_SWITCH(PhotonConversionBuilder, processMC, "process reconstructed info for MC", false); - void processRec_OnlyIfDielectron(soa::Join const& collisions, filteredV0s const& v0s, MyTracksIU const& tracks, aod::BCsWithTimestamps const& bcs) + void processRec_OnlyIfDielectron(soa::Join const& collisions, filteredV0s const& v0s, MyTracksIU const& tracks, aod::BCsWithTimestamps const& bcs) { build(collisions, v0s, tracks, bcs); } PROCESS_SWITCH(PhotonConversionBuilder, processRec_OnlyIfDielectron, "process reconstructed info for data", false); - void processRec_SWT_OnlyIfDielectron(soa::Join const& collisions, filteredV0s const& v0s, MyTracksIU const& tracks, aod::BCsWithTimestamps const& bcs) + void processRec_SWT_OnlyIfDielectron(soa::Join const& collisions, filteredV0s const& v0s, MyTracksIU const& tracks, aod::BCsWithTimestamps const& bcs) { build(collisions, v0s, tracks, bcs); } diff --git a/PWGEM/PhotonMeson/TableProducer/produceMesonCalo.cxx b/PWGEM/PhotonMeson/TableProducer/produceMesonCalo.cxx deleted file mode 100644 index 7fd19416d3d..00000000000 --- a/PWGEM/PhotonMeson/TableProducer/produceMesonCalo.cxx +++ /dev/null @@ -1,151 +0,0 @@ -// 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. - -/// \brief perform calo photon analysis on calo photons from skimmergammacalo task -/// dependencies: skimmergammacalo -/// \author marvin.hemmer@cern.ch - -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/DataModel/mesonTables.h" - -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -// includes for the R recalculation -#include "DataFormatsParameters/GRPObject.h" -#include "DetectorsBase/GeometryManager.h" -#include "CCDB/BasicCCDBManager.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct produceMesonCalo { - - Produces tableCaloMeson; - - HistogramRegistry spectra = { - "spectra", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - - // Configurable for histograms - Configurable nBinsMinv{"nBinsMinv", 800, "N bins for minv axis"}; - Configurable minMinv{"minMinv", 0.0, "Minimum value for minv axis"}; - Configurable maxMinv{"maxMinv", 0.8, "Maximum value for minv axis"}; - Configurable nBinsPt{"nBinsPt", 180, "N bins for pT axis"}; - Configurable minPt{"minPt", 0., "Minimum value for pT axis"}; - Configurable maxPt{"maxPt", 60., "Maximum value for pT axis"}; - - void init(o2::framework::InitContext&) - { - std::vector ptBinning(nBinsPt, 0); - - for (int i = 0; i < nBinsPt; i++) { - if (i < 100) { - ptBinning.at(i) = 0.10 * i; - } else if (i < 140) { - ptBinning.at(i) = 10. + 0.25 * (i - 100); - } else if (i < 180) { - ptBinning.at(i) = 20. + 1.00 * (i - 140); - } else { - ptBinning.at(i) = maxPt; - } - } - - AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec minvAxis = {nBinsMinv, minMinv, maxMinv, - "#it{m}_{inv} (GeV/#it{c}^{2})"}; - AxisSpec etaAxis = {100, -0.8, 0.8, "#eta"}; - AxisSpec phiAxis = {360, 0, 2 * M_PI, "#varphi (rad)"}; - AxisSpec alphaAxis = {200, -1, +1, "#alpha"}; - AxisSpec oaAxis = {180, 0, M_PI, "#vartheta_{#gamma#gamma} (rad)"}; - - HistogramConfigSpec defaultPtMinvHist( - {HistType::kTH2F, {minvAxis, ptAxis}}); - - HistogramConfigSpec defaultEtaPhiHist( - {HistType::kTH2F, {etaAxis, phiAxis}}); - - HistogramConfigSpec defaultPtMotherPtGammaHist( - {HistType::kTH2F, {ptAxis, ptAxis}}); - - HistogramConfigSpec defaultPtAlpha( - {HistType::kTH2F, {ptAxis, alphaAxis}}); - - HistogramConfigSpec defaultPtOA( - {HistType::kTH2F, {ptAxis, oaAxis}}); - - spectra.add("SameEvent_Minv_Pt", "SameEvent_Minv_Pt", defaultPtMinvHist, true); - spectra.add("SameEvent_Eta_Phi", "SameEvent_Eta_Phi", defaultEtaPhiHist, true); - spectra.add("SameEvent_Pt_Alpha", "SameEvent_Pt_Alpha", defaultPtAlpha, true); - spectra.add("SameEvent_Pt_OA", "SameEvent_Pt_OA", defaultPtOA, true); - spectra.add("SameEvent_PtMother_PtGamma", "SameEvent_PtMother_PtGamma", defaultPtMotherPtGammaHist, true); - - spectra.add("Photon_Eta_Phi", "Photon_Eta_Phi", defaultEtaPhiHist, true); - } - - void - processRec(aod::Collision const&, - aod::SkimGammas const& skimgammas) - { - for (auto& [gamma0, gamma1] : // EMC-EMC - combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(skimgammas, - skimgammas))) { - float openingAngle = acos((cos(gamma0.phi() - gamma1.phi()) + - sinh(gamma0.eta()) * sinh(gamma1.eta())) / - (cosh(gamma0.eta()) * cosh(gamma1.eta()))); - float E = gamma0.e() + gamma1.e(); - float pt0 = gamma0.e() / cosh(gamma0.eta()); - float pt1 = gamma1.e() / cosh(gamma1.eta()); - float px = - pt0 * cos(gamma0.phi()) + pt1 * cos(gamma1.phi()); - float py = - pt0 * sin(gamma0.phi()) + pt1 * sin(gamma1.phi()); - float pz = - pt0 * sinh(gamma0.eta()) + pt1 * sinh(gamma1.eta()); - float alpha = (gamma0.e() - gamma1.e()) != 0. - ? (gamma0.e() - gamma1.e()) / (gamma0.e() + gamma1.e()) - : 0.; - float Pt = sqrt(pt0 * pt0 + pt1 * pt1 + - 2. * pt0 * pt1 * - cos(gamma0.phi() - gamma1.phi())); - float minv = - sqrt(2. * gamma0.e() * gamma1.e() * (1. - cos(openingAngle))); - float eta = asinh(pz / Pt); - float phi = atan2(py, px); - phi = (phi < 0) ? phi + 2. * M_PI : phi; - tableCaloMeson(gamma0.collisionId(), gamma0.globalIndex(), gamma1.globalIndex(), - openingAngle, px, py, pz, E, alpha, minv, eta, phi, - Pt); - spectra.get(HIST("SameEvent_Minv_Pt"))->Fill(minv, Pt); - spectra.get(HIST("SameEvent_Eta_Phi"))->Fill(eta, phi); - spectra.get(HIST("SameEvent_Pt_Alpha"))->Fill(Pt, alpha); - spectra.get(HIST("SameEvent_Pt_OA"))->Fill(Pt, openingAngle); - spectra.get(HIST("SameEvent_PtMother_PtGamma"))->Fill(Pt, pt0); - spectra.get(HIST("SameEvent_PtMother_PtGamma"))->Fill(Pt, pt1); - - spectra.get(HIST("Photon_Eta_Phi"))->Fill(gamma0.eta(), gamma0.phi()); - spectra.get(HIST("Photon_Eta_Phi"))->Fill(gamma1.eta(), gamma1.phi()); - } - } - PROCESS_SWITCH(produceMesonCalo, processRec, - "process only reconstructed info", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; - return workflow; -} diff --git a/PWGEM/PhotonMeson/TableProducer/skimmerGammaCalo.cxx b/PWGEM/PhotonMeson/TableProducer/skimmerGammaCalo.cxx index c7da3fa270f..0de9fee8f62 100644 --- a/PWGEM/PhotonMeson/TableProducer/skimmerGammaCalo.cxx +++ b/PWGEM/PhotonMeson/TableProducer/skimmerGammaCalo.cxx @@ -9,40 +9,48 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file skimmerGammaCalo.cxx /// \brief skim cluster information to write photon cluster table in AO2D.root /// dependencies: emcal-correction-task /// \author marvin.hemmer@cern.ch -#include -#include +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h" +#include "PWGJE/DataModel/EMCALClusters.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/EventSelection.h" -#include "Common/Core/TableHelper.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include -// includes for the R recalculation -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "CCDB/BasicCCDBManager.h" +#include -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h" +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -struct skimmerGammaCalo { +struct SkimmerGammaCalo { - Preslice CellperCluster = o2::aod::emcalclustercell::emcalclusterId; - Preslice MTperCluster = o2::aod::emcalclustercell::emcalclusterId; + Preslice psCellperCluster = o2::aod::emcalclustercell::emcalclusterId; + Preslice psMTperCluster = o2::aod::emcalclustercell::emcalclusterId; Produces tableGammaEMCReco; Produces tableEMCClusterMCLabels; Produces tableCellEMCReco; - Produces tableTrackEMCReco; // Configurable for filter/cuts Configurable minTime{"minTime", -200., "Minimum cluster time for time cut"}; @@ -50,61 +58,85 @@ struct skimmerGammaCalo { Configurable minM02{"minM02", 0.0, "Minimum M02 for M02 cut"}; Configurable maxM02{"maxM02", 1.0, "Maximum M02 for M02 cut"}; Configurable minE{"minE", 0.5, "Minimum energy for energy cut"}; + Configurable> clusterDefinitions{"clusterDefinitions", {0, 1, 2, 10, 11, 12, 13, 20, 21, 22, 30, 40, 41, 42, 43, 44, 45}, "Cluster definitions to be accepted (e.g. 13 for kV3MostSplitLowSeed)"}; Configurable maxdEta{"maxdEta", 0.1, "Set a maximum difference in eta for tracks and cluster to still count as matched"}; Configurable maxdPhi{"maxdPhi", 0.1, "Set a maximum difference in phi for tracks and cluster to still count as matched"}; - Configurable applyEveSel_at_skimming{"applyEveSel_at_skimming", false, "flag to apply minimal event selection at the skimming level"}; - Configurable inherit_from_emevent_photon{"inherit_from_emevent_photon", false, "flag to inherit task options from emevent-photon"}; + Configurable needEMCTrigger{"needEMCTrigger", false, "flag to only save events which have kTVXinEMC trigger bit. To reduce PbPb derived data size"}; HistogramRegistry historeg{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - void init(o2::framework::InitContext& initContext) + void init(o2::framework::InitContext&) { - historeg.add("hCaloClusterEIn", "hCaloClusterEIn", gHistoSpec_clusterE); - historeg.add("hCaloClusterEOut", "hCaloClusterEOut", gHistoSpec_clusterE); - historeg.add("hMTEtaPhi", "hMTEtaPhi", gHistoSpec_clusterTM_dEtadPhi); - auto hCaloClusterFilter = historeg.add("hCaloClusterFilter", "hCaloClusterFilter", kTH1I, {{5, 0, 5}}); + historeg.add("DefinitionIn", "Cluster definitions before cuts;#bf{Cluster definition};#bf{#it{N}_{clusters}}", HistType::kTH1F, {{51, -0.5, 50.5}}); + historeg.add("DefinitionOut", "Cluster definitions after cuts;#bf{Cluster definition};#bf{#it{N}_{clusters}}", HistType::kTH1F, {{51, -0.5, 50.5}}); + historeg.add("EIn", "Energy of clusters before cuts", gHistoSpec_clusterE); + historeg.add("EOut", "Energy of clusters after cuts", gHistoSpec_clusterE); + historeg.add("MTEtaPhi", "Eta phi of matched tracks", gHistoSpec_clusterTM_dEtadPhi); + historeg.add("M02In", "Shape of cluster before cuts;#bf{#it{M}_{02}};#bf{#it{N}_{clusters}}", HistType::kTH1F, {{200, 0, 2}}); + historeg.add("M02Out", "Shape of cluster after cuts;#bf{#it{M}_{02}};#bf{#it{N}_{clusters}}", HistType::kTH1F, {{200, 0, 2}}); + historeg.add("TimeIn", "Time of cluster before cuts;#bf{#it{t} (ns)};#bf{#it{N}_{clusters}}", HistType::kTH1F, {{200, -100, 100}}); + historeg.add("TimeOut", "Time of cluster after cuts;#bf{#it{t} (ns)};#bf{#it{N}_{clusters}}", HistType::kTH1F, {{200, -100, 100}}); + + auto hCaloClusterFilter = historeg.add("hCaloClusterFilter", "hCaloClusterFilter", kTH1I, {{6, 0, 6}}); hCaloClusterFilter->GetXaxis()->SetBinLabel(1, "in"); - hCaloClusterFilter->GetXaxis()->SetBinLabel(2, "E cut"); - hCaloClusterFilter->GetXaxis()->SetBinLabel(3, "time cut"); - hCaloClusterFilter->GetXaxis()->SetBinLabel(4, "M02 cut"); - hCaloClusterFilter->GetXaxis()->SetBinLabel(5, "out"); - - if (inherit_from_emevent_photon) { - getTaskOptionValue(initContext, "create-emevent-photon", "applyEveSel_at_skimming", applyEveSel_at_skimming.value, true); // for EM users. - } + hCaloClusterFilter->GetXaxis()->SetBinLabel(2, "Definition cut"); + hCaloClusterFilter->GetXaxis()->SetBinLabel(3, "E cut"); + hCaloClusterFilter->GetXaxis()->SetBinLabel(4, "time cut"); + hCaloClusterFilter->GetXaxis()->SetBinLabel(5, "M02 cut"); + hCaloClusterFilter->GetXaxis()->SetBinLabel(6, "out"); LOG(info) << "| Timing cut: " << minTime << " < t < " << maxTime; LOG(info) << "| M02 cut: " << minM02 << " < M02 < " << maxM02; LOG(info) << "| E cut: E > " << minE; } - void processRec(soa::Join::iterator const& collision, aod::EMCALClusters const& emcclusters, aod::EMCALClusterCells const& emcclustercells, aod::EMCALMatchedTracks const& emcmatchedtracks, aod::FullTracks const&) + void processRec(soa::Join::iterator const& collision, aod::EMCALClusters const& emcclusters, aod::EMCALClusterCells const& emcclustercells, aod::EMCALMatchedTracks const& emcmatchedtracks, aod::FullTracks const&) { - if (applyEveSel_at_skimming && (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + if (!collision.isSelected()) { return; } + if (needEMCTrigger.value && !collision.alias_bit(kTVXinEMC)) { + return; + } + for (const auto& emccluster : emcclusters) { - historeg.fill(HIST("hCaloClusterEIn"), emccluster.energy()); historeg.fill(HIST("hCaloClusterFilter"), 0); + historeg.fill(HIST("DefinitionIn"), emccluster.definition()); + historeg.fill(HIST("EIn"), emccluster.energy()); + historeg.fill(HIST("M02In"), emccluster.m02()); + historeg.fill(HIST("TimeIn"), emccluster.time()); + + // Definition cut + if (!(std::find(clusterDefinitions.value.begin(), clusterDefinitions.value.end(), emccluster.definition()) != clusterDefinitions.value.end())) { + historeg.fill(HIST("hCaloClusterFilter"), 1); + continue; + } + historeg.fill(HIST("EIn"), emccluster.energy()); // Energy cut if (emccluster.energy() < minE) { - historeg.fill(HIST("hCaloClusterFilter"), 1); + historeg.fill(HIST("hCaloClusterFilter"), 2); continue; } // timing cut if (emccluster.time() > maxTime || emccluster.time() < minTime) { - historeg.fill(HIST("hCaloClusterFilter"), 2); + historeg.fill(HIST("hCaloClusterFilter"), 3); continue; } // M02 cut if (emccluster.nCells() > 1 && (emccluster.m02() > maxM02 || emccluster.m02() < minM02)) { - historeg.fill(HIST("hCaloClusterFilter"), 3); + historeg.fill(HIST("hCaloClusterFilter"), 4); continue; } + historeg.fill(HIST("hCaloClusterFilter"), 5); + + historeg.fill(HIST("DefinitionOut"), emccluster.definition()); + historeg.fill(HIST("EOut"), emccluster.energy()); + historeg.fill(HIST("M02Out"), emccluster.m02()); + historeg.fill(HIST("TimeOut"), emccluster.time()); // Skimmed cell table - auto groupedCells = emcclustercells.sliceBy(CellperCluster, emccluster.globalIndex()); + auto groupedCells = emcclustercells.sliceBy(psCellperCluster, emccluster.globalIndex()); for (const auto& emcclustercell : groupedCells) { tableCellEMCReco(emcclustercell.emcalclusterId(), emcclustercell.caloId()); } @@ -115,40 +147,40 @@ struct skimmerGammaCalo { std::vector vPhi; std::vector vP; std::vector vPt; - auto groupedMTs = emcmatchedtracks.sliceBy(MTperCluster, emccluster.globalIndex()); + auto groupedMTs = emcmatchedtracks.sliceBy(psMTperCluster, emccluster.globalIndex()); vTrackIds.reserve(groupedMTs.size()); vEta.reserve(groupedMTs.size()); vPhi.reserve(groupedMTs.size()); vP.reserve(groupedMTs.size()); vPt.reserve(groupedMTs.size()); for (const auto& emcmatchedtrack : groupedMTs) { - if (std::abs(emccluster.eta() - emcmatchedtrack.track_as().trackEtaEmcal()) >= maxdEta || std::abs(emccluster.phi() - emcmatchedtrack.track_as().trackPhiEmcal()) >= maxdPhi) { + if (std::abs(emcmatchedtrack.deltaEta()) >= maxdEta || std::abs(emcmatchedtrack.deltaPhi()) >= maxdPhi) { continue; } - historeg.fill(HIST("hMTEtaPhi"), emccluster.eta() - emcmatchedtrack.track_as().trackEtaEmcal(), emccluster.phi() - emcmatchedtrack.track_as().trackPhiEmcal()); + historeg.fill(HIST("MTEtaPhi"), emccluster.eta() - emcmatchedtrack.track_as().trackEtaEmcal(), emccluster.phi() - emcmatchedtrack.track_as().trackPhiEmcal()); vTrackIds.emplace_back(emcmatchedtrack.trackId()); - vEta.emplace_back(emcmatchedtrack.track_as().trackEtaEmcal()); - vPhi.emplace_back(emcmatchedtrack.track_as().trackPhiEmcal()); + vEta.emplace_back(emcmatchedtrack.deltaEta()); + vPhi.emplace_back(emcmatchedtrack.deltaPhi()); vP.emplace_back(emcmatchedtrack.track_as().p()); vPt.emplace_back(emcmatchedtrack.track_as().pt()); - tableTrackEMCReco(emcmatchedtrack.emcalclusterId(), emcmatchedtrack.track_as().trackEtaEmcal(), emcmatchedtrack.track_as().trackPhiEmcal(), - emcmatchedtrack.track_as().p(), emcmatchedtrack.track_as().pt()); } - historeg.fill(HIST("hCaloClusterEOut"), emccluster.energy()); - historeg.fill(HIST("hCaloClusterFilter"), 4); - tableGammaEMCReco(emccluster.collisionId(), emccluster.definition(), emccluster.energy(), emccluster.eta(), emccluster.phi(), emccluster.m02(), - emccluster.nCells(), emccluster.time(), emccluster.isExotic(), vEta, vPhi, vP, vPt); + emccluster.nCells(), emccluster.time(), emccluster.isExotic(), vPhi, vEta, vP, vPt); } } - void processMC(soa::Join::iterator const& collision, soa::Join const& emcclusters, aod::McParticles const&) + void processMC(soa::Join::iterator const& collision, soa::Join const& emcclusters, aod::McParticles const&) { - if (applyEveSel_at_skimming && (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + if (!collision.isSelected()) { return; } + for (const auto& emccluster : emcclusters) { + // Definition cut + if (!(std::find(clusterDefinitions.value.begin(), clusterDefinitions.value.end(), emccluster.definition()) != clusterDefinitions.value.end())) { + continue; + } // Energy cut if (emccluster.energy() < minE) { continue; @@ -173,18 +205,18 @@ struct skimmerGammaCalo { mcLabels.clear(); } } - PROCESS_SWITCH(skimmerGammaCalo, processRec, "process only reconstructed info", true); - PROCESS_SWITCH(skimmerGammaCalo, processMC, "process MC info", false); // Run this in addition to processRec for MCs to copy the cluster mc labels from the EMCALMCClusters to the skimmed EMCClusterMCLabels table + PROCESS_SWITCH(SkimmerGammaCalo, processRec, "process only reconstructed info", true); + PROCESS_SWITCH(SkimmerGammaCalo, processMC, "process MC info", false); // Run this in addition to processRec for MCs to copy the cluster mc labels from the EMCALMCClusters to the skimmed EMCClusterMCLabels table void processDummy(aod::Collision const&) { // do nothing } - PROCESS_SWITCH(skimmerGammaCalo, processDummy, "Dummy function", false); + PROCESS_SWITCH(SkimmerGammaCalo, processDummy, "Dummy function", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - WorkflowSpec workflow{adaptAnalysisTask(cfgc, TaskName{"skimmer-gamma-calo"})}; + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; return workflow; } diff --git a/PWGEM/PhotonMeson/TableProducer/skimmerGammaConversion.cxx b/PWGEM/PhotonMeson/TableProducer/skimmerGammaConversion.cxx index 8c8e2c8a109..90726fb34de 100644 --- a/PWGEM/PhotonMeson/TableProducer/skimmerGammaConversion.cxx +++ b/PWGEM/PhotonMeson/TableProducer/skimmerGammaConversion.cxx @@ -23,38 +23,37 @@ // runme like: o2-analysis-trackselection -b --aod-file ${sourceFile} --aod-writer-json ${writerFile} | o2-analysis-timestamp -b | o2-analysis-trackextension -b | o2-analysis-lf-lambdakzerobuilder -b | o2-analysis-pid-tpc -b | o2-analysis-em-skimmermc -b -#include #include +#include #include #include // todo: remove reduantant information in GammaConversionsInfoTrue #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/gammaConvDefinitions.h" #include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" +#include "PWGEM/PhotonMeson/Utils/gammaConvDefinitions.h" #include "PWGLF/DataModel/LFStrangenessTables.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" // includes for the R recalculation -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" +#include "Common/Core/trackUtilities.h" +#include "Tools/KFparticle/KFUtilities.h" +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" #include "DCAFitter/HelixHelper.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" #include "ReconstructionDataFormats/TrackFwd.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" +#include "Math/Vector4D.h" #include #include -#include "Math/Vector4D.h" - -#include "Tools/KFparticle/KFUtilities.h" using namespace o2; using namespace o2::framework; @@ -189,7 +188,7 @@ struct skimmerGammaConversion { theTrack.tpcNClsFindable(), theTrack.tpcNClsFindableMinusFound(), theTrack.tpcNClsFindableMinusCrossedRows(), theTrack.tpcNClsShared(), theTrack.tpcChi2NCl(), theTrack.tpcInnerParam(), theTrack.tpcSignal(), theTrack.tpcNSigmaEl(), theTrack.tpcNSigmaPi(), - theTrack.itsClusterSizes(), theTrack.itsChi2NCl(), theTrack.detectorMap(), + theTrack.itsClusterSizes(), theTrack.itsChi2NCl(), theTrack.detectorMap(), 0, theTrack.x(), theTrack.y(), theTrack.z(), theTrack.tgl()); } @@ -313,7 +312,7 @@ struct skimmerGammaConversion { gammaKF_DecayVtx.GetX(), gammaKF_DecayVtx.GetY(), gammaKF_DecayVtx.GetZ(), gammaKF_DecayVtx.GetPx(), gammaKF_DecayVtx.GetPy(), gammaKF_DecayVtx.GetPz(), v0_sv.M(), dca_xy_v0_to_pv, dca_z_v0_to_pv, - cospa_kf, pca_kf, alpha, qt, chi2kf); + cospa_kf, 1.f, 1.f, pca_kf, alpha, qt, chi2kf); fillTrackTable(pos, kfp_pos_DecayVtx); fillTrackTable(ele, kfp_ele_DecayVtx); diff --git a/PWGEM/PhotonMeson/TableProducer/skimmerPrimaryElectronFromDalitzEE.cxx b/PWGEM/PhotonMeson/TableProducer/skimmerPrimaryElectronFromDalitzEE.cxx index a42f00e0374..5f814376546 100644 --- a/PWGEM/PhotonMeson/TableProducer/skimmerPrimaryElectronFromDalitzEE.cxx +++ b/PWGEM/PhotonMeson/TableProducer/skimmerPrimaryElectronFromDalitzEE.cxx @@ -12,22 +12,29 @@ /// \brief write relevant information about primary electrons. /// \author daiki.sekihata@cern.ch -#include -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/DataModel/CollisionAssociationTables.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/PhotonMeson/Utils/TrackSelection.h" +#include "Common/Core/trackUtilities.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" + +#include +#include +#include +#include + using namespace o2; using namespace o2::soa; using namespace o2::framework; @@ -35,15 +42,19 @@ using namespace o2::framework::expressions; using namespace o2::constants::physics; using namespace o2::pwgem::photonmeson; -using MyTracks = soa::Join; +using MyCollisions = soa::Join; +using MyCollisionsWithSWT = soa::Join; + +using MyCollisionsMC = soa::Join; +using MyTracks = soa::Join; using MyTrack = MyTracks::iterator; -using MyTracksMC = soa::Join; +using MyTracksMC = soa::Join; using MyTrackMC = MyTracksMC::iterator; struct skimmerPrimaryElectronFromDalitzEE { - SliceCache cache; Preslice perCol = o2::aod::track::collisionId; + Preslice perCol_pcm = o2::aod::v0photonkf::collisionId; Produces emprimaryelectrons; // Configurables @@ -53,28 +64,36 @@ struct skimmerPrimaryElectronFromDalitzEE { Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; // Operation and minimisation criteria - Configurable applyEveSel_at_skimming{"applyEveSel_at_skimming", false, "flag to apply minimal event selection at the skimming level"}; Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; Configurable min_ncluster_tpc{"min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable mincrossedrows{"mincrossedrows", 70, "min. crossed rows"}; Configurable min_tpc_cr_findable_ratio{"min_tpc_cr_findable_ratio", 0.8, "min. TPC Ncr/Nf ratio"}; - Configurable minitsncls{"minitsncls", 4, "min. number of ITS clusters"}; + Configurable max_frac_shared_clusters_tpc{"max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable min_ncluster_its{"min_ncluster_its", 4, "min ncluster its"}; + Configurable min_ncluster_itsib{"min_ncluster_itsib", 1, "min ncluster itsib"}; Configurable maxchi2tpc{"maxchi2tpc", 5.0, "max. chi2/NclsTPC"}; - Configurable maxchi2its{"maxchi2its", 6.0, "max. chi2/NclsITS"}; - Configurable minpt{"minpt", 0.15, "min pt for track"}; - Configurable maxeta{"maxeta", 0.8, "eta acceptance"}; - Configurable dca_xy_max{"dca_xy_max", 0.1, "max DCAxy in cm"}; - Configurable dca_z_max{"dca_z_max", 0.1, "max DCAz in cm"}; + Configurable maxchi2its{"maxchi2its", 36.0, "max. chi2/NclsITS"}; + Configurable minpt{"minpt", 0.05, "min pt for ITS-TPC track"}; + Configurable maxeta{"maxeta", 2.0, "max eta acceptance"}; + Configurable dca_xy_max{"dca_xy_max", 1, "max DCAxy in cm"}; + Configurable dca_z_max{"dca_z_max", 1, "max DCAz in cm"}; + Configurable dca_3d_sigma_max{"dca_3d_sigma_max", 2, "max DCA 3D in sigma"}; Configurable minTPCNsigmaEl{"minTPCNsigmaEl", -2.5, "min. TPC n sigma for electron inclusion"}; - Configurable maxTPCNsigmaEl{"maxTPCNsigmaEl", 3.5, "max. TPC n sigma for electron inclusion"}; - Configurable maxTPCNsigmaPi{"maxTPCNsigmaPi", 2.5, "max. TPC n sigma for pion exclusion"}; - Configurable minTPCNsigmaPi{"minTPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; - Configurable maxMee_lowPtee{"maxMee_lowPtee", 0.02, "max. mee to store dalitz ee pairs for recovery"}; - Configurable maxMee_highPtee{"maxMee_highPtee", 0.04, "max. mee to store dalitz ee pairs for recovery"}; + Configurable maxTPCNsigmaEl{"maxTPCNsigmaEl", +3.5, "max. TPC n sigma for electron inclusion"}; + Configurable maxTPCNsigmaPi{"maxTPCNsigmaPi", 0.0, "max. TPC n sigma for pion exclusion"}; + Configurable minTPCNsigmaPi{"minTPCNsigmaPi", 0.0, "min. TPC n sigma for pion exclusion"}; + Configurable minTOFNsigmaEl{"minTOFNsigmaEl", -3.5, "min. TOF n sigma for electron inclusion"}; + Configurable maxTOFNsigmaEl{"maxTOFNsigmaEl", +3.5, "max. TOF n sigma for electron inclusion"}; + Configurable maxMee{"maxMee", 0.04, "max. mee to store dalitz ee pairs"}; + Configurable fillLS{"fillLS", true, "flag to fill LS histograms for QA"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to include ITSsa tracks"}; + Configurable maxpt_itssa{"maxpt_itssa", 0.15, "max pt for ITSsa track"}; + Configurable maxMeanITSClusterSize{"maxMeanITSClusterSize", 16, "max x cos(lambda)"}; + Configurable slope{"slope", 0.0185, "slope for m vs. phiv"}; + Configurable intercept{"intercept", -0.0380, "intercept for m vs. phiv"}; HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - - std::pair> itsRequirement = {1, {0, 1, 2}}; // any hits on 3 ITS ib layers. + static constexpr std::string_view dileptonSigns[3] = {"uls/", "lspp/", "lsmm/"}; int mRunNumber; float d_bz; @@ -83,6 +102,10 @@ struct skimmerPrimaryElectronFromDalitzEE { void init(InitContext&) { + if (doprocessRec && doprocessRec_SWT) { + LOGF(fatal, "Cannot enable doprocessRec and doprocessRec_SWT at the same time. Please choose one."); + } + mRunNumber = 0; d_bz = 0; @@ -92,23 +115,47 @@ struct skimmerPrimaryElectronFromDalitzEE { ccdb->setFatalWhenNull(false); fRegistry.add("Track/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); + fRegistry.add("Track/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {400, -2.0f, 2.0f}}, false); fRegistry.add("Track/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {20, -1.0f, 1.0f}}, false); + fRegistry.add("Track/hRelDeltaPt", "pT resolution;p_{T} (GeV/c);#Deltap_{T}/p_{T}", kTH2F, {{1000, 0, 10}, {100, 0, 0.1}}, false); fRegistry.add("Track/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); - fRegistry.add("Track/hDCAxy_Pt", "DCA_{xy} vs. pT;p_{T} (GeV/c);DCA_{xy} (cm)", kTH2F, {{1000, 0, 10}, {200, -1, 1}}, false); - fRegistry.add("Track/hDCAz_Pt", "DCA_{z} vs. pT;p_{T} (GeV/c);DCA_{z} (cm)", kTH2F, {{1000, 0, 10}, {200, -1, 1}}, false); + fRegistry.add("Track/hDCAxy_Pt", "DCA_{xy} vs. pT;p_{T} (GeV/c);DCA_{xy} (cm)", kTH2F, {{200, 0, 10}, {200, -1, 1}}, false); + fRegistry.add("Track/hDCAz_Pt", "DCA_{z} vs. pT;p_{T} (GeV/c);DCA_{z} (cm)", kTH2F, {{200, 0, 10}, {200, -1, 1}}, false); + fRegistry.add("Track/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); + fRegistry.add("Track/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + + // TPC fRegistry.add("Track/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); fRegistry.add("Track/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); fRegistry.add("Track/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/hTPCNclsShared", "TPC Ncls shared/Ncls;p_{T} (GeV/c);N_{cls}^{shared}/N_{cls} in TPC", kTH2F, {{1000, 0, 10}, {100, 0, 1}}, false); fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); + fRegistry.add("Track/hTPCdEdxMC", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); fRegistry.add("Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); + + // ITS fRegistry.add("Track/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{400, 0, 40}}, false); fRegistry.add("Track/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("Pair/hMeePtee_ULS", "mee vs. pTee for dalitz ee ULS;m_{ee} (GeV/c^{2});p_{T,ee} (GeV/c)", kTH2F, {{100, 0, 0.1}, {100, 0, 10}}, false); + fRegistry.add("Track/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {150, 0, 15}}, false); + fRegistry.add("Track/hMeanClusterSizeITSib", "mean cluster size ITSib;p_{pv} (GeV/c); #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {150, 0, 15}}, false); + fRegistry.add("Track/hMeanClusterSizeITSob", "mean cluster size ITSob;p_{pv} (GeV/c); #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {150, 0, 15}}, false); + + // TOF + fRegistry.add("Track/hChi2TOF", "chi2 of TOF", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/hTOFbeta", "TOF beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, false); + fRegistry.add("Track/hTOFNsigmaEl", "TOF n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/hTOFNsigmaPi", "TOF n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + + // pair + fRegistry.add("Pair/uls/hMvsPt", "m_{ee} vs. p_{T,ee};m_{ee} (GeV/c^{2});p_{T,ee} (GeV/c)", kTH2F, {{100, 0, 0.1}, {200, 0, 2}}, false); + fRegistry.add("Pair/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi_{V} (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{180, 0, M_PI}, {100, 0, 0.1}}, false); + fRegistry.addClone("Pair/uls/", "Pair/lspp/"); + fRegistry.addClone("Pair/uls/", "Pair/lsmm/"); } void initCCDB(aod::BCsWithTimestamps::iterator const& bc) @@ -121,7 +168,7 @@ struct skimmerPrimaryElectronFromDalitzEE { if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } o2::base::Propagator::initFieldFromGRP(&grpmag); @@ -161,43 +208,70 @@ struct skimmerPrimaryElectronFromDalitzEE { } } - if (track.tpcChi2NCl() > maxchi2tpc) { + if (!track.hasITS()) { return false; } - if (track.itsChi2NCl() > maxchi2its) { + if (track.itsChi2NCl() < 0.f || maxchi2its < track.itsChi2NCl()) { return false; } - if (!track.hasITS() || !track.hasTPC()) { + if (track.itsNCls() < min_ncluster_its) { return false; } - if (track.itsNCls() < minitsncls) { + if (track.itsNClsInnerBarrel() < min_ncluster_itsib) { return false; } - auto hits = std::count_if(itsRequirement.second.begin(), itsRequirement.second.end(), [&](auto&& requiredLayer) { return track.itsClusterMap() & (1 << requiredLayer); }); - if (hits < itsRequirement.first) { + if (!includeITSsa && (!track.hasITS() || !track.hasTPC())) { return false; } - if (track.tpcNClsFound() < min_ncluster_tpc) { - return false; + if (track.hasTPC()) { + if (track.tpcChi2NCl() < 0.f || maxchi2tpc < track.tpcChi2NCl()) { + return false; + } + + if (track.tpcNClsFound() < min_ncluster_tpc) { + return false; + } + + if (track.tpcNClsCrossedRows() < mincrossedrows) { + return false; + } + + if (track.tpcCrossedRowsOverFindableCls() < min_tpc_cr_findable_ratio) { + return false; + } + + if (track.tpcFractionSharedCls() > max_frac_shared_clusters_tpc) { + return false; + } } - if (track.tpcNClsCrossedRows() < mincrossedrows) { + if (std::fabs(track.dcaXY()) > dca_xy_max || std::fabs(track.dcaZ()) > dca_z_max) { return false; } - if (track.tpcCrossedRowsOverFindableCls() < min_tpc_cr_findable_ratio) { + float dca_3d = 999.f; + float det = track.cYY() * track.cZZ() - track.cZY() * track.cZY(); + if (det < 0) { + dca_3d = 999.f; + } else { + float chi2 = (track.dcaXY() * track.dcaXY() * track.cZZ() + track.dcaZ() * track.dcaZ() * track.cYY() - 2. * track.dcaXY() * track.dcaZ() * track.cZY()) / det; + dca_3d = std::sqrt(std::fabs(chi2) / 2.); + } + if (dca_3d > dca_3d_sigma_max) { return false; } - if (abs(track.dcaXY()) > dca_xy_max || abs(track.dcaZ()) > dca_z_max) { + if (std::fabs(track.eta()) > maxeta) { return false; } - - if (track.pt() < minpt || abs(track.eta()) > maxeta) { + if ((track.hasITS() && track.hasTPC()) && track.pt() < minpt) { + return false; + } + if ((track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF()) && maxpt_itssa < track.pt()) { return false; } @@ -207,53 +281,145 @@ struct skimmerPrimaryElectronFromDalitzEE { template bool isElectron(TTrack const& track) { + if (includeITSsa && (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF())) { + int total_cluster_size = 0, nl = 0; + for (unsigned int layer = 0; layer < 7; layer++) { + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); + if (cluster_size_per_layer > 0) { + nl++; + } + total_cluster_size += cluster_size_per_layer; + } + + if (maxMeanITSClusterSize > static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(track.tgl()))) { + return true; + } else { + return false; + } + } + if (track.tpcNSigmaEl() < minTPCNsigmaEl || maxTPCNsigmaEl < track.tpcNSigmaEl()) { return false; } if (minTPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < maxTPCNsigmaPi) { return false; } + if (track.hasTOF() && (track.tofNSigmaEl() < minTOFNsigmaEl || maxTOFNsigmaEl < track.tofNSigmaEl())) { // TOFif + return false; + } return true; } - template + template void fillTrackTable(TCollision const& collision, TTrack const& track) { - if (std::find(stored_trackIds.begin(), stored_trackIds.end(), std::make_pair(collision.globalIndex(), track.globalIndex())) == stored_trackIds.end()) { - emprimaryelectrons(collision.globalIndex(), track.globalIndex(), track.sign(), - track.pt(), track.eta(), track.phi(), track.dcaXY(), track.dcaZ(), - track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), - track.tpcChi2NCl(), track.tpcInnerParam(), - track.tpcSignal(), track.tpcNSigmaEl(), track.tpcNSigmaPi(), - track.itsClusterSizes(), track.itsChi2NCl(), track.detectorMap(), track.tgl()); - - fRegistry.fill(HIST("Track/hPt"), track.pt()); - fRegistry.fill(HIST("Track/hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/hDCAxy_Pt"), track.pt(), track.dcaXY()); - fRegistry.fill(HIST("Track/hDCAz_Pt"), track.pt(), track.dcaZ()); - fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); - fRegistry.fill(HIST("Track/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); - - stored_trackIds.emplace_back(std::make_pair(collision.globalIndex(), track.globalIndex())); + float mcTunedTPCSignal = 0.f; + if constexpr (isMC) { + mcTunedTPCSignal = track.mcTunedTPCSignal(); + if (track.hasTPC()) { + mcTunedTPCSignal = track.mcTunedTPCSignal(); + } + } + + float itsChi2NCl = (track.hasITS() && track.itsChi2NCl() > 0.f) ? track.itsChi2NCl() : -299.f; + float tpcChi2NCl = (track.hasTPC() && track.tpcChi2NCl() > 0.f) ? track.tpcChi2NCl() : -299.f; + float beta = track.hasTOF() ? track.beta() : -29.f; + float tofNSigmaEl = track.hasTOF() ? track.tofNSigmaEl() : -299.f; + float tofNSigmaPi = track.hasTOF() ? track.tofNSigmaPi() : -299.f; + float tofChi2 = track.hasTOF() ? track.tofChi2() : -299.f; + + float tpcSignal = track.hasTPC() ? track.tpcSignal() : 0.f; + float tpcNSigmaEl = track.hasTPC() ? track.tpcNSigmaEl() : -299.f; + float tpcNSigmaPi = track.hasTPC() ? track.tpcNSigmaPi() : -299.f; + + emprimaryelectrons(collision.globalIndex(), track.globalIndex(), track.sign(), + track.pt(), track.eta(), track.phi(), track.dcaXY(), track.dcaZ(), track.cYY(), track.cZY(), track.cZZ(), + track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), track.tpcNClsShared(), + + static_cast(tpcChi2NCl * 1e+2), track.tpcInnerParam(), + static_cast(tpcSignal * 1e+2), static_cast(tpcNSigmaEl * 1e+2), static_cast(tpcNSigmaPi * 1e+2), + static_cast(beta * 1e+3), static_cast(tofNSigmaEl * 1e+2), static_cast(tofNSigmaPi * 1e+2), + track.itsClusterSizes(), static_cast(itsChi2NCl * 1e+2), static_cast(tofChi2 * 1e+2), track.detectorMap(), track.tgl(), static_cast(mcTunedTPCSignal * 1e+2)); + } + + template + void fillTrackHistograms(TTrack const& track) + { + float mcTunedTPCSignal = 0.f; + if constexpr (isMC) { + mcTunedTPCSignal = track.mcTunedTPCSignal(); + if (track.hasTPC()) { + mcTunedTPCSignal = track.mcTunedTPCSignal(); + } } + + fRegistry.fill(HIST("Track/hPt"), track.pt()); + fRegistry.fill(HIST("Track/hEtaPhi"), track.phi(), track.eta()); + fRegistry.fill(HIST("Track/hQoverPt"), track.sign() / track.pt()); + fRegistry.fill(HIST("Track/hRelDeltaPt"), track.pt(), track.sigma1Pt() * track.pt()); + fRegistry.fill(HIST("Track/hDCAxyz"), track.dcaXY(), track.dcaZ()); + fRegistry.fill(HIST("Track/hDCAxy_Pt"), track.pt(), track.dcaXY()); + fRegistry.fill(HIST("Track/hDCAz_Pt"), track.pt(), track.dcaZ()); + fRegistry.fill(HIST("Track/hDCAxyzSigma"), track.dcaXY() / std::sqrt(track.cYY()), track.dcaZ() / std::sqrt(track.cZZ())); + fRegistry.fill(HIST("Track/hDCAxyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/hDCAzRes_Pt"), track.pt(), std::sqrt(track.cZZ()) * 1e+4); // convert cm to um + + fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); + fRegistry.fill(HIST("Track/hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); + fRegistry.fill(HIST("Track/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); + fRegistry.fill(HIST("Track/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); + fRegistry.fill(HIST("Track/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + fRegistry.fill(HIST("Track/hTPCdEdxMC"), track.tpcInnerParam(), mcTunedTPCSignal); + fRegistry.fill(HIST("Track/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); + fRegistry.fill(HIST("Track/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); + + fRegistry.fill(HIST("Track/hChi2TOF"), track.tofChi2()); + fRegistry.fill(HIST("Track/hTOFbeta"), track.p(), track.beta()); + fRegistry.fill(HIST("Track/hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); + fRegistry.fill(HIST("Track/hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); + + fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); + fRegistry.fill(HIST("Track/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); + + int total_cluster_size = 0, nl = 0; + for (unsigned int layer = 0; layer < 7; layer++) { + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); + if (cluster_size_per_layer > 0) { + nl++; + } + total_cluster_size += cluster_size_per_layer; + } + + int total_cluster_size_ib = 0, nl_ib = 0; + for (unsigned int layer = 0; layer < 3; layer++) { + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); + if (cluster_size_per_layer > 0) { + nl_ib++; + } + total_cluster_size_ib += cluster_size_per_layer; + } + + int total_cluster_size_ob = 0, nl_ob = 0; + for (unsigned int layer = 3; layer < 7; layer++) { + int cluster_size_per_layer = track.itsClsSizeInLayer(layer); + if (cluster_size_per_layer > 0) { + nl_ob++; + } + total_cluster_size_ob += cluster_size_per_layer; + } + fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), track.p(), static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(track.tgl()))); + fRegistry.fill(HIST("Track/hMeanClusterSizeITSib"), track.p(), static_cast(total_cluster_size_ib) / static_cast(nl_ib) * std::cos(std::atan(track.tgl()))); + fRegistry.fill(HIST("Track/hMeanClusterSizeITSob"), track.p(), static_cast(total_cluster_size_ob) / static_cast(nl_ob) * std::cos(std::atan(track.tgl()))); } - template + template void fillPairInfo(TCollision const& collision, TTracks1 const& tracks1, TTracks2 const& tracks2) { - for (auto& t1 : tracks1) { - for (auto& t2 : tracks2) { + if constexpr (pairtype == 0) { // ULS + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { if (!checkTrack(collision, t1) || !checkTrack(collision, t2)) { continue; } @@ -264,77 +430,212 @@ struct skimmerPrimaryElectronFromDalitzEE { ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz(), t1.sign(), t2.sign(), d_bz); + fRegistry.fill(HIST("Pair/") + HIST(dileptonSigns[pairtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/") + HIST(dileptonSigns[pairtype]) + HIST("hMvsPhiV"), phiv, v12.M()); - if (v12.Pt() < 1.0) { // don't store - if (v12.M() > maxMee_lowPtee) { // don't store - continue; + if (v12.M() > maxMee) { // don't store + continue; + } + + if (v12.M() < slope * phiv + intercept) { + continue; + } + + if (t1.sign() > 0) { // for positron + if (std::find(acceptedPosTrackIds_per_collision.begin(), acceptedPosTrackIds_per_collision.end(), t1.globalIndex()) == acceptedPosTrackIds_per_collision.end()) { + fillTrackHistograms(t1); + acceptedPosTrackIds_per_collision.emplace_back(t1.globalIndex()); + } + } else { // for electron + if (std::find(acceptedNegTrackIds_per_collision.begin(), acceptedNegTrackIds_per_collision.end(), t1.globalIndex()) == acceptedNegTrackIds_per_collision.end()) { + fillTrackHistograms(t1); + acceptedNegTrackIds_per_collision.emplace_back(t1.globalIndex()); + } + } + + if (t2.sign() > 0) { // for positron + if (std::find(acceptedPosTrackIds_per_collision.begin(), acceptedPosTrackIds_per_collision.end(), t2.globalIndex()) == acceptedPosTrackIds_per_collision.end()) { + fillTrackHistograms(t2); + acceptedPosTrackIds_per_collision.emplace_back(t2.globalIndex()); } - } else { - if (v12.M() > maxMee_highPtee) { // don't store - continue; + } else { // for electron + if (std::find(acceptedNegTrackIds_per_collision.begin(), acceptedNegTrackIds_per_collision.end(), t2.globalIndex()) == acceptedNegTrackIds_per_collision.end()) { + fillTrackHistograms(t2); + acceptedNegTrackIds_per_collision.emplace_back(t2.globalIndex()); } } - fRegistry.fill(HIST("Pair/hMeePtee_ULS"), v12.M(), v12.Pt()); - fillTrackTable(collision, t1); - fillTrackTable(collision, t2); - } // end of t2 - } // end of t1 + } // end of ULS pairing + } else { // LS + for (auto& [t1, t2] : combinations(CombinationsStrictlyUpperIndexPolicy(tracks1, tracks2))) { + if (!checkTrack(collision, t1) || !checkTrack(collision, t2)) { + continue; + } + if (!isElectron(t1) || !isElectron(t2)) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz(), t1.sign(), t2.sign(), d_bz); + fRegistry.fill(HIST("Pair/") + HIST(dileptonSigns[pairtype]) + HIST("hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/") + HIST(dileptonSigns[pairtype]) + HIST("hMvsPhiV"), phiv, v12.M()); + } // end of LS pairing + } } - std::vector> stored_trackIds; - Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::tpcChi2NCl < maxchi2tpc&& o2::aod::track::itsChi2NCl < maxchi2its&& ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true; - Filter pidFilter = minTPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < maxTPCNsigmaEl; + std::vector acceptedPosTrackIds_per_collision; + std::vector acceptedNegTrackIds_per_collision; + std::vector> stored_trackIds; + Filter trackFilter = minpt < o2::aod::track::pt && nabs(o2::aod::track::eta) < maxeta && o2::aod::track::itsChi2NCl < maxchi2its && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && nabs(o2::aod::track::dcaXY) < dca_xy_max && nabs(o2::aod::track::dcaZ) < dca_z_max; using MyFilteredTracks = soa::Filtered; Partition posTracks = o2::aod::track::signed1Pt > 0.f; Partition negTracks = o2::aod::track::signed1Pt < 0.f; // ---------- for data ---------- - void processRec(Join const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks) + void processRec(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks, aod::V0PhotonsKF const& v0photons) { stored_trackIds.reserve(tracks.size()); - for (auto& collision : collisions) { - auto bc = collision.bc_as(); + for (const auto& collision : collisions) { + auto bc = collision.template foundBC_as(); initCCDB(bc); - - if (applyEveSel_at_skimming && (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + if (!collision.isSelected()) { continue; } - auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); + const auto& v0photons_per_coll = v0photons.sliceBy(perCol_pcm, collision.globalIndex()); + const auto& posTracks_per_coll = posTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); + const auto& negTracks_per_coll = negTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); + acceptedPosTrackIds_per_collision.reserve(posTracks_per_coll.size()); + acceptedNegTrackIds_per_collision.reserve(negTracks_per_coll.size()); - fillPairInfo(collision, posTracks_per_coll, negTracks_per_coll); // ULS - } // end of collision loop + fillPairInfo(collision, posTracks_per_coll, negTracks_per_coll); // ULS + if (fillLS) { + fillPairInfo(collision, posTracks_per_coll, posTracks_per_coll); // LS++ + fillPairInfo(collision, negTracks_per_coll, negTracks_per_coll); // LS-- + } + + if ((v0photons_per_coll.size() >= 1 && acceptedPosTrackIds_per_collision.size() >= 1 && acceptedNegTrackIds_per_collision.size() >= 1) || (acceptedPosTrackIds_per_collision.size() >= 2 && acceptedNegTrackIds_per_collision.size() >= 2)) { + // LOGF(info, "v0photons_per_coll.size() = %d, acceptedPosTrackIds_per_collision.size() = %d, acceptedNegTrackIds_per_collision.size() = %d", v0photons_per_coll.size(), acceptedPosTrackIds_per_collision.size(), acceptedNegTrackIds_per_collision.size()); + for (const auto& posId : acceptedPosTrackIds_per_collision) { + const auto& pos = tracks.rawIteratorAt(posId); + fillTrackTable(collision, pos); + } + for (const auto& eleId : acceptedNegTrackIds_per_collision) { + const auto& ele = tracks.rawIteratorAt(eleId); + fillTrackTable(collision, ele); + } + } + + acceptedPosTrackIds_per_collision.clear(); + acceptedPosTrackIds_per_collision.shrink_to_fit(); + acceptedNegTrackIds_per_collision.clear(); + acceptedNegTrackIds_per_collision.shrink_to_fit(); + } // end of collision loop stored_trackIds.clear(); stored_trackIds.shrink_to_fit(); } PROCESS_SWITCH(skimmerPrimaryElectronFromDalitzEE, processRec, "process reconstructed info only", true); // standalone + void processRec_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks, aod::V0PhotonsKF const& v0photons) + { + stored_trackIds.reserve(tracks.size()); + + for (const auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + if (!collision.isSelected()) { + continue; + } + + if (collision.swtaliastmp_raw() == 0) { + continue; + } + + const auto& v0photons_per_coll = v0photons.sliceBy(perCol_pcm, collision.globalIndex()); + const auto& posTracks_per_coll = posTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); + const auto& negTracks_per_coll = negTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); + acceptedPosTrackIds_per_collision.reserve(posTracks_per_coll.size()); + acceptedNegTrackIds_per_collision.reserve(negTracks_per_coll.size()); + + fillPairInfo(collision, posTracks_per_coll, negTracks_per_coll); // ULS + if (fillLS) { + fillPairInfo(collision, posTracks_per_coll, posTracks_per_coll); // LS++ + fillPairInfo(collision, negTracks_per_coll, negTracks_per_coll); // LS-- + } + + if ((v0photons_per_coll.size() >= 1 && acceptedPosTrackIds_per_collision.size() >= 1 && acceptedNegTrackIds_per_collision.size() >= 1) || (acceptedPosTrackIds_per_collision.size() >= 2 && acceptedNegTrackIds_per_collision.size() >= 2)) { + // LOGF(info, "v0photons_per_coll.size() = %d, acceptedPosTrackIds_per_collision.size() = %d, acceptedNegTrackIds_per_collision.size() = %d", v0photons_per_coll.size(), acceptedPosTrackIds_per_collision.size(), acceptedNegTrackIds_per_collision.size()); + for (const auto& posId : acceptedPosTrackIds_per_collision) { + const auto& pos = tracks.rawIteratorAt(posId); + fillTrackTable(collision, pos); + } + for (const auto& eleId : acceptedNegTrackIds_per_collision) { + const auto& ele = tracks.rawIteratorAt(eleId); + fillTrackTable(collision, ele); + } + } + + acceptedPosTrackIds_per_collision.clear(); + acceptedPosTrackIds_per_collision.shrink_to_fit(); + acceptedNegTrackIds_per_collision.clear(); + acceptedNegTrackIds_per_collision.shrink_to_fit(); + } // end of collision loop + + stored_trackIds.clear(); + stored_trackIds.shrink_to_fit(); + } + PROCESS_SWITCH(skimmerPrimaryElectronFromDalitzEE, processRec_SWT, "process reconstructed info with CEFP", false); // with cefp + using MyFilteredTracksMC = soa::Filtered; Partition posTracksMC = o2::aod::track::signed1Pt > 0.f; Partition negTracksMC = o2::aod::track::signed1Pt < 0.f; // ---------- for MC ---------- - void processMC(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks) + void processMC(MyCollisionsMC const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks, aod::V0PhotonsKF const& v0photons) { stored_trackIds.reserve(tracks.size()); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); if (!collision.has_mcCollision()) { continue; } - auto bc = collision.bc_as(); - initCCDB(bc); - if (applyEveSel_at_skimming && (!collision.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { + if (!collision.isSelected()) { continue; } - auto posTracks_per_coll = posTracksMC->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracksMC->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); + const auto& v0photons_per_coll = v0photons.sliceBy(perCol_pcm, collision.globalIndex()); + const auto& posTracks_per_coll = posTracksMC->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); + const auto& negTracks_per_coll = negTracksMC->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); + acceptedPosTrackIds_per_collision.reserve(posTracks_per_coll.size()); + acceptedNegTrackIds_per_collision.reserve(negTracks_per_coll.size()); - fillPairInfo(collision, posTracks_per_coll, negTracks_per_coll); // ULS - } // end of collision loop + fillPairInfo(collision, posTracks_per_coll, negTracks_per_coll); // ULS + if (fillLS) { + fillPairInfo(collision, posTracks_per_coll, posTracks_per_coll); // LS++ + fillPairInfo(collision, negTracks_per_coll, negTracks_per_coll); // LS-- + } + if ((v0photons_per_coll.size() >= 1 && acceptedPosTrackIds_per_collision.size() >= 1 && acceptedNegTrackIds_per_collision.size() >= 1) || (acceptedPosTrackIds_per_collision.size() >= 2 && acceptedNegTrackIds_per_collision.size() >= 2)) { + // LOGF(info, "v0photons_per_coll.size() = %d, acceptedPosTrackIds_per_collision.size() = %d, acceptedNegTrackIds_per_collision.size() = %d", v0photons_per_coll.size(), acceptedPosTrackIds_per_collision.size(), acceptedNegTrackIds_per_collision.size()); + for (const auto& posId : acceptedPosTrackIds_per_collision) { + const auto& pos = tracks.rawIteratorAt(posId); + fillTrackTable(collision, pos); + } + for (const auto& eleId : acceptedNegTrackIds_per_collision) { + const auto& ele = tracks.rawIteratorAt(eleId); + fillTrackTable(collision, ele); + } + } + + acceptedPosTrackIds_per_collision.clear(); + acceptedPosTrackIds_per_collision.shrink_to_fit(); + acceptedNegTrackIds_per_collision.clear(); + acceptedNegTrackIds_per_collision.shrink_to_fit(); + } // end of collision loop stored_trackIds.clear(); stored_trackIds.shrink_to_fit(); @@ -342,34 +643,7 @@ struct skimmerPrimaryElectronFromDalitzEE { PROCESS_SWITCH(skimmerPrimaryElectronFromDalitzEE, processMC, "process reconstructed and MC info ", false); }; -// struct associateAmbiguousElectron { -// Produces em_amb_ele_ids; -// -// SliceCache cache; -// PresliceUnsorted perTrack = o2::aod::emprimaryelectron::trackId; -// std::vector ambele_self_Ids; -// -// void process(aod::EMPrimaryElectrons const& electrons) -// { -// for (auto& electron : electrons) { -// auto electrons_with_same_trackId = electrons.sliceBy(perTrack, electron.trackId()); -// ambele_self_Ids.reserve(electrons_with_same_trackId.size()); -// for (auto& amp_ele : electrons_with_same_trackId) { -// if (amp_ele.globalIndex() == electron.globalIndex()) { // don't store myself. -// continue; -// } -// ambele_self_Ids.emplace_back(amp_ele.globalIndex()); -// } -// em_amb_ele_ids(ambele_self_Ids); -// ambele_self_Ids.clear(); -// ambele_self_Ids.shrink_to_fit(); -// } -// } -// }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"skimmer-primary-electron-from-dalitzee"}), - // adaptAnalysisTask(cfgc, TaskName{"associate-ambiguous-electron"}) - }; + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"skimmer-primary-electron-from-dalitzee"})}; } diff --git a/PWGEM/PhotonMeson/Tasks/CMakeLists.txt b/PWGEM/PhotonMeson/Tasks/CMakeLists.txt index 82dd5775d75..332cafc0795 100644 --- a/PWGEM/PhotonMeson/Tasks/CMakeLists.txt +++ b/PWGEM/PhotonMeson/Tasks/CMakeLists.txt @@ -9,6 +9,8 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. +add_subdirectory(Converters) + o2physics_add_dpl_workflow(gammaconversions SOURCES gammaConversions.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore @@ -24,6 +26,16 @@ o2physics_add_dpl_workflow(emc-pi0-qc PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(emc-bc-wise-gammagamma + SOURCES emcalBcWiseGammaGamma.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(mc-generator-studies + SOURCES mcGeneratorStudies.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(pcm-qc SOURCES pcmQC.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore @@ -49,6 +61,16 @@ o2physics_add_dpl_workflow(emcal-qc PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(heavy-neutral-meson + SOURCES HeavyNeutralMeson.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(omega-meson-emc + SOURCES OmegaMesonEMC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(phos-qc SOURCES phosQC.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore @@ -94,16 +116,6 @@ o2physics_add_dpl_workflow(pi0eta-to-gammagamma-mc-emcemc PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(tagging-pi0 - SOURCES TaggingPi0.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore O2Physics::MLCore - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(tagging-pi0-mc - SOURCES TaggingPi0MC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore O2Physics::MLCore - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(tag-and-probe SOURCES TagAndProbe.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore O2Physics::MLCore @@ -128,3 +140,35 @@ o2physics_add_dpl_workflow(pi0-flow-emc SOURCES taskPi0FlowEMC.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(prefilter-photon + SOURCES prefilterPhoton.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(tagging-pi0-pcmdalitzee + SOURCES TaggingPi0PCMDalitzEE.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(tagging-pi0-mc-pcmdalitzee + SOURCES TaggingPi0MCPCMDalitzEE.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(diphoton-hadron-mpc-pcmpcm + SOURCES diphotonHadronMPCPCMPCM.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore + COMPONENT_NAME Analysis) + + +o2physics_add_dpl_workflow(compconvbuilder + SOURCES compconvbuilder.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(diphoton-hadron-mpc-pcmdalitzee + SOURCES diphotonHadronMPCPCMDalitzEE.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore + COMPONENT_NAME Analysis) + diff --git a/PWGEM/PhotonMeson/Tasks/Converters/CMakeLists.txt b/PWGEM/PhotonMeson/Tasks/Converters/CMakeLists.txt new file mode 100644 index 00000000000..89aceb70f98 --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/Converters/CMakeLists.txt @@ -0,0 +1,20 @@ +# 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. + +o2physics_add_dpl_workflow(pcm-converter1 + SOURCES pcmConverter1.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(electron-from-dalitz-converter1 + SOURCES electronFromDalitzConverter1.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGEM/PhotonMeson/Tasks/Converters/electronFromDalitzConverter1.cxx b/PWGEM/PhotonMeson/Tasks/Converters/electronFromDalitzConverter1.cxx new file mode 100644 index 00000000000..629fab67530 --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/Converters/electronFromDalitzConverter1.cxx @@ -0,0 +1,84 @@ +// 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. +// +// ======================== +// +// This code runs loop over ULS ee pars for virtual photon QC. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct electronFromDalitzConverter1 { + Produces electron_001; + + void process(aod::EMPrimaryElectronsFromDalitz_000 const& tracks) + { + for (const auto& track : tracks) { + float itsChi2NCl = track.itsChi2NCl() > 0.f ? track.itsChi2NCl() : -299.f; + float tpcChi2NCl = track.tpcChi2NCl() > 0.f ? track.tpcChi2NCl() : -299.f; + float beta = track.hasTOF() ? track.beta() : -29.f; + float tofNSigmaEl = track.hasTOF() ? track.tofNSigmaEl() : -299.f; + float tofNSigmaPi = track.hasTOF() ? track.tofNSigmaPi() : -299.f; + float tofChi2 = track.hasTOF() ? track.tofChi2() : -299.f; + + float tpcSignal = track.hasTPC() ? track.tpcSignal() : 0.f; + float tpcNSigmaEl = track.hasTPC() ? track.tpcNSigmaEl() : -299.f; + float tpcNSigmaPi = track.hasTPC() ? track.tpcNSigmaPi() : -299.f; + + electron_001(track.collisionId(), + track.trackId(), + track.sign(), + track.pt(), + track.eta(), + track.phi(), + track.dcaXY(), + track.dcaZ(), + track.cYY(), + track.cZY(), + track.cZZ(), + track.tpcNClsFindable(), + track.tpcNClsFindableMinusFound(), + track.tpcNClsFindableMinusCrossedRows(), + track.tpcNClsShared(), + + static_cast(tpcChi2NCl * 1e+2), + track.tpcInnerParam(), + static_cast(tpcSignal * 1e+2), + static_cast(tpcNSigmaEl * 1e+2), + static_cast(tpcNSigmaPi * 1e+2), + static_cast(beta * 1e+3), + static_cast(tofNSigmaEl * 1e+2), + static_cast(tofNSigmaPi * 1e+2), + track.itsClusterSizes(), + static_cast(itsChi2NCl * 1e+2), + static_cast(tofChi2 * 1e+2), + track.detectorMap(), + track.tgl(), + 0); + + } // end of track loop + } // end of process +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"electronFromDalitz-converter1"})}; +} diff --git a/PWGEM/PhotonMeson/Tasks/Converters/pcmConverter1.cxx b/PWGEM/PhotonMeson/Tasks/Converters/pcmConverter1.cxx new file mode 100644 index 00000000000..e9d7af43acd --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/Converters/pcmConverter1.cxx @@ -0,0 +1,100 @@ +// 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. +// +// ======================== +// +// This code runs loop over ULS ee pars for virtual photon QC. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct pcmConverter1 { + Produces v0photon_001; + Produces v0leg_001; + + void process(aod::V0PhotonsKF_000 const& v0s, aod::V0Legs_000 const& v0legs) + { + for (auto& v0 : v0s) { + v0photon_001( + v0.collisionId(), + v0.v0Id(), + v0.posTrackId(), + v0.negTrackId(), + v0.vx(), + v0.vy(), + v0.vz(), + v0.px(), + v0.py(), + v0.pz(), + static_cast(v0.mGamma() * 1e+5), + static_cast(v0.dcaXYtopv() * 1e+2), + static_cast(v0.dcaZtopv() * 1e+2), + static_cast(v0.cospa() * 1e+4), + static_cast(v0.cospaXY() * 1e+4), + static_cast(v0.cospaRZ() * 1e+4), + static_cast(v0.pca() * 1e+4), + static_cast(v0.alpha() * 1e+4), + static_cast(v0.qtarm() * 1e+5), + static_cast(v0.chiSquareNDF() * 1e+2)); + } // end of v0 loop + + for (auto& v0leg : v0legs) { + + float itsChi2NCl = (v0leg.hasITS() && v0leg.itsChi2NCl() > 0.f) ? v0leg.itsChi2NCl() : -299.f; + float tpcChi2NCl = (v0leg.hasTPC() && v0leg.tpcChi2NCl() > 0.f) ? v0leg.tpcChi2NCl() : -299.f; + float tpcSignal = v0leg.hasTPC() ? v0leg.tpcSignal() : 0.f; + float tpcNSigmaEl = v0leg.hasTPC() ? v0leg.tpcNSigmaEl() : -299.f; + float tpcNSigmaPi = v0leg.hasTPC() ? v0leg.tpcNSigmaPi() : -299.f; + + v0leg_001( + v0leg.collisionId(), + v0leg.trackId(), + v0leg.sign(), + v0leg.px(), + v0leg.py(), + v0leg.pz(), + static_cast(v0leg.dcaXY() * 1e+2), + static_cast(v0leg.dcaZ() * 1e+2), + v0leg.tpcNClsFindable(), + v0leg.tpcNClsFindableMinusFound(), + v0leg.tpcNClsFindableMinusCrossedRows(), + v0leg.tpcNClsShared(), + static_cast(tpcChi2NCl * 1e+2), + v0leg.tpcInnerParam(), + static_cast(tpcSignal * 1e+2), + static_cast(tpcNSigmaEl * 1e+2), + static_cast(tpcNSigmaPi * 1e+2), + v0leg.itsClusterSizes(), + static_cast(itsChi2NCl * 1e+2), + v0leg.detectorMap(), + static_cast(0), + static_cast(v0leg.x() * 1e+2), + static_cast(v0leg.y() * 1e+2), + static_cast(v0leg.z() * 1e+2), + v0leg.tgl()); + } // end of v0leg loop + } // end of process +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"pcm-converter1"})}; +} diff --git a/PWGEM/PhotonMeson/Tasks/HeavyNeutralMeson.cxx b/PWGEM/PhotonMeson/Tasks/HeavyNeutralMeson.cxx new file mode 100644 index 00000000000..b416f173480 --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/HeavyNeutralMeson.cxx @@ -0,0 +1,597 @@ +// 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. +/// +/// \file HeavyNeutralMeson.cxx +/// +/// \brief This code loops over collisions to reconstruct heavy mesons (omega or eta') using EMCal clusters and V0s (PCM) +/// +/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) - Goethe University Frankfurt +/// + +#include +#include +#include + +#include "Math/GenVector/Boost.h" +#include "Math/Vector4D.h" +#include "TMath.h" +#include "TRandom3.h" + +#include "PWGEM/PhotonMeson/Utils/HNMUtilities.h" +#include "PWGJE/DataModel/EMCALMatchedCollisions.h" + +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "fairlogger/Logger.h" +#include "Framework/Configurable.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "CommonConstants/MathConstants.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::pwgem::photonmeson; + +namespace o2::aod +{ +using MyBCs = soa::Join; +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; +using SelectedTracks = soa::Join; +} // namespace o2::aod + +namespace hnm +{ + +enum TracksPID { + kPion, + kNTracksPID +}; + +enum PIDLimits { kTPCMin, + kTPCMax, + kTPCTOF, + kITSmin, + kITSmax, + kNPIDLimits +}; + +const std::vector speciesName{"pion"}; // ToDo include charged pions +const std::vector pTCutsName{"Pt min", "Pt max", "P TOF thres"}; +const std::vector pidCutsName{"TPC min", "TPC max", "TPCTOF max", "ITS min", "ITS max"}; +const float pidcutsTable[kNTracksPID][kNPIDLimits]{{-4.f, 4.f, 4.f, -99.f, 99.f}}; +const float ptcutsTable[kNTracksPID][3]{{0.35f, 6.f, 0.75f}}; +const float nClusterMinTPC[1][kNTracksPID]{{80.0f}}; +const float nClusterMinITS[1][kNTracksPID]{{4}}; + +} // namespace hnm + +struct HeavyNeutralMeson { + + // --------------------------------> Configurables <------------------------------------ + // - Event selection cuts + // - Track selection cuts + // - Cluster shifts + // - HNM mass selection windows + // ------------------------------------------------------------------------------------- + // ---> Event selection + Configurable confEvtSelectZvtx{"confEvtSelectZvtx", true, "Event selection includes max. z-Vertex"}; + Configurable confEvtZvtx{"confEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable confEvtRequireSel8{"confEvtRequireSel8", false, "Evt sel: check for offline selection (sel8)"}; + + // ---> Track selection + Configurable> cfgPtCuts{"cfgPtCuts", {hnm::ptcutsTable[0], 1, 3, hnm::speciesName, hnm::pTCutsName}, "Track pT selections"}; + Configurable cfgTrkEta{"cfgTrkEta", 0.9, "Eta"}; + Configurable> cfgTPCNClustersMin{"cfgTPCNClustersMin", {hnm::nClusterMinTPC[0], 1, 1, std::vector{"TPCNClusMin"}, hnm::speciesName}, "Mininum of TPC Clusters"}; + Configurable cfgTrkTPCfCls{"cfgTrkTPCfCls", 0.83, "Minimum fraction of crossed rows over findable clusters"}; + Configurable cfgTrkTPCcRowsMin{"cfgTrkTPCcRowsMin", 70, "Minimum number of crossed TPC rows"}; + Configurable cfgTrkTPCsClsSharedFrac{"cfgTrkTPCsClsSharedFrac", 1.f, "Fraction of shared TPC clusters"}; + Configurable> cfgTrkITSnclsMin{"cfgTrkITSnclsMin", {hnm::nClusterMinITS[0], 1, 1, std::vector{"Cut"}, hnm::speciesName}, "Minimum number of ITS clusters"}; + Configurable cfgTrkDCAxyMax{"cfgTrkDCAxyMax", 0.15, "Maximum DCA_xy"}; + Configurable cfgTrkDCAzMax{"cfgTrkDCAzMax", 0.3, "Maximum DCA_z"}; + Configurable cfgTrkMaxChi2PerClusterTPC{"cfgTrkMaxChi2PerClusterTPC", 4.0f, "Minimal track selection: max allowed chi2 per TPC cluster"}; // 4.0 is default of global tracks on 20.01.2023 + Configurable cfgTrkMaxChi2PerClusterITS{"cfgTrkMaxChi2PerClusterITS", 36.0f, "Minimal track selection: max allowed chi2 per ITS cluster"}; // 36.0 is default of global tracks on 20.01.2023 + + Configurable> cfgPIDCuts{"cfgPIDCuts", {hnm::pidcutsTable[0], 1, hnm::kNPIDLimits, hnm::speciesName, hnm::pidCutsName}, "Femtopartner PID nsigma selections"}; // PID selections + + // ---> Configurables to allow for a shift in eta/phi of EMCal clusters to better align with extrapolated TPC tracks + Configurable cfgDoEMCShift{"cfgDoEMCShift", false, "Apply SM-wise shift in eta and phi to EMCal clusters to align with TPC tracks"}; + Configurable> cfgEMCEtaShift{"cfgEMCEtaShift", {0.f}, "values for SM-wise shift in eta to be added to EMCal clusters to align with TPC tracks"}; + Configurable> cfgEMCPhiShift{"cfgEMCPhiShift", {0.f}, "values for SM-wise shift in phi to be added to EMCal clusters to align with TPC tracks"}; + static const int nSMs = 20; + std::array emcEtaShift = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + std::array emcPhiShift = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + // ---> Shift the omega/eta' mass based on the difference of the reconstructed mass of the pi0/eta to its PDG mass to reduce smearing caused by EMCal/PCM in photon measurement + Configurable cfgHNMMassCorrection{"cfgHNMMassCorrection", 1, "Use GG PDG mass to correct HNM mass (0 = off, 1 = subDeltaPi0, 2 = subLambda)"}; + + // ---> Mass windows for the selection of heavy neutral mesons (also based on mass of their light neutral meson decay daughter) + static constexpr float DefaultMassWindows[2][4] = {{0., 0.4, 0.6, 1.}, {0.4, 0.8, 0.8, 1.2}}; + Configurable> cfgMassWindowOmega{"cfgMassWindowOmega", {DefaultMassWindows[0], 4, {"pi0_min", "pi0_max", "omega_min", "omega_max"}}, "Mass window for selected omegas and their decay pi0"}; + Configurable> cfgMassWindowEtaPrime{"cfgMassWindowEtaPrime", {DefaultMassWindows[1], 4, {"eta_min", "eta_max", "etaprime_min", "etaprime_max"}}, "Mass window for selected eta' and their decay eta"}; + + Configurable cfgMaxMultiplicity{"cfgMaxMultiplicity", 5000, "Maximum number of tracks in a collision (can be used to increase the S/B -> Very experimental)"}; + Configurable cfgMinGGPtOverHNMPt{"cfgMinGGPtOverHNMPt", 0., "Minimum ratio of the pT of the gamma gamma pair over the pT of the HNM (can be used to increase the S/B)"}; + + HistogramRegistry mHistManager{"HeavyNeutralMesonHistograms", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Prepare vectors for different species + std::vector vGGs; + std::vector vHNMs; + std::vector etaPrimeEMC, etaPrimePCM, omegaEMC, omegaPCM, proton, antiproton, deuteron, antideuteron, pion, antipion; + float mMassProton = constants::physics::MassProton; + float mMassDeuteron = constants::physics::MassDeuteron; + float mMassOmega = 0.782; + float mMassEtaPrime = 0.957; + float mMassPionCharged = constants::physics::MassPionCharged; + + Preslice perCollisionPCM = aod::v0photonkf::collisionId; + Preslice perCollisionEMC = aod::skimmedcluster::collisionId; + + template + bool isSelectedTrack(T const& track, hnm::TracksPID partSpecies) + { + if (track.pt() < cfgPtCuts->get(partSpecies, "Pt min")) + return false; + if (track.pt() > cfgPtCuts->get(partSpecies, "Pt max")) + return false; + if (std::abs(track.eta()) > cfgTrkEta) + return false; + if (track.tpcNClsFound() < cfgTPCNClustersMin->get("TPCNClusMin", partSpecies)) + return false; + if (track.tpcCrossedRowsOverFindableCls() < cfgTrkTPCfCls) + return false; + if (track.tpcNClsCrossedRows() < cfgTrkTPCcRowsMin) + return false; + if (track.tpcFractionSharedCls() > cfgTrkTPCsClsSharedFrac) + return false; + if (track.itsNCls() < cfgTrkITSnclsMin->get(static_cast(0), partSpecies)) + return false; + if (std::abs(track.dcaXY()) > cfgTrkDCAxyMax) + return false; + if (std::abs(track.dcaZ()) > cfgTrkDCAzMax) + return false; + if (track.tpcChi2NCl() > cfgTrkMaxChi2PerClusterTPC) + return false; + if (track.itsChi2NCl() > cfgTrkMaxChi2PerClusterITS) + return false; + return true; + } + + template + bool isSelectedTrackPID(T const& track, hnm::TracksPID partSpecies) + { + bool isSelected = false; + + float nSigmaTrackTPC = track.tpcNSigmaPi(); + float nSigmaTrackTOF = track.tofNSigmaPi(); + float nSigmaTrackITS = track.itsNSigmaPi(); + + float nSigmaTrackTPCTOF = std::sqrt(std::pow(nSigmaTrackTPC, 2) + std::pow(nSigmaTrackTOF, 2)); + + if (track.p() <= cfgPtCuts->get(partSpecies, "P TOF thres")) { + if (nSigmaTrackTPC > cfgPIDCuts->get(partSpecies, hnm::kTPCMin) && + nSigmaTrackTPC < cfgPIDCuts->get(partSpecies, hnm::kTPCMax) && + nSigmaTrackITS > cfgPIDCuts->get(partSpecies, hnm::kITSmin) && + nSigmaTrackITS < cfgPIDCuts->get(partSpecies, hnm::kITSmax)) { + isSelected = true; + } + } else { + if (nSigmaTrackTPCTOF < cfgPIDCuts->get(partSpecies, hnm::kTPCTOF)) { + isSelected = true; + } + } + return isSelected; + } + + template + bool isSelectedEvent(T const& col) + { + if (confEvtSelectZvtx && std::abs(col.posZ()) > confEvtZvtx) { + return false; + } + if (confEvtRequireSel8 && !col.sel8()) { + return false; + } + if (col.multNTracksPV() > cfgMaxMultiplicity) { + return false; + } + return true; + } + + void init(InitContext const&) + { + mHistManager.add("Event/nGGs", "Number of (selected) #gamma#gamma paris;#bf{#it{N}_{#gamma#gamma}};#bf{#it{N}_{#gamma#gamma}^{selected}}", HistType::kTH2F, {{51, -0.5, 50.5}, {51, -0.5, 50.5}}); + mHistManager.add("Event/nHeavyNeutralMesons", "Number of (selected) HNM candidates;#bf{#it{N}_{HNM}};#bf{#it{N}_{HNM}^{selected}}", HistType::kTH2F, {{51, -0.5, 50.5}, {51, -0.5, 50.5}}); + mHistManager.add("Event/nClustersVsV0s", "Number of clusters and V0s in the collision;#bf{#it{N}_{clusters}};#bf{#it{N}_{V0s}}", HistType::kTH2F, {{26, -0.5, 25.5}, {26, -0.5, 25.5}}); + mHistManager.add("Event/nEMCalEvents", "Number of collisions with a certain combination of EMCal triggers;;#bf{#it{N}_{collisions}}", HistType::kTH1F, {{5, -0.5, 4.5}}); + std::vector nEventTitles = {"Cells & kTVXinEMC", "Cells & L0", "Cells & !kTVXinEMC & !L0", "!Cells & kTVXinEMC", "!Cells & L0"}; + for (size_t iBin = 0; iBin < nEventTitles.size(); iBin++) + mHistManager.get(HIST("Event/nEMCalEvents"))->GetXaxis()->SetBinLabel(iBin + 1, nEventTitles[iBin].data()); + mHistManager.add("Event/fMultiplicityBefore", "Multiplicity of all processed events;#bf{#it{N}_{tracks}};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, 0, 500}}); + mHistManager.add("Event/fMultiplicityAfter", "Multiplicity after event cuts;#bf{#it{N}_{tracks}};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, 0, 500}}); + mHistManager.add("Event/fZvtxBefore", "Zvtx of all processed events;#bf{z_{vtx} (cm)};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, -15, 15}}); + mHistManager.add("Event/fZvtxAfter", "Zvtx after event cuts;#bf{z_{vtx} (cm)};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, -15, 15}}); + + mHistManager.add("GG/invMassVsPt_PCM", "Invariant mass and pT of gg candidates;#bf{#it{M}_{#gamma#gamma}};#bf{#it{pT}_{#gamma#gamma}}", HistType::kTH2F, {{400, 0., 0.8}, {250, 0., 25.}}); + mHistManager.add("GG/invMassVsPt_PCMEMC", "Invariant mass and pT of gg candidates;#bf{#it{M}_{#gamma#gamma}};#bf{#it{pT}_{#gamma#gamma}}", HistType::kTH2F, {{400, 0., 0.8}, {250, 0., 25.}}); + mHistManager.add("GG/invMassVsPt_EMC", "Invariant mass and pT of gg candidates;#bf{#it{M}_{#gamma#gamma}};#bf{#it{pT}_{#gamma#gamma}}", HistType::kTH2F, {{400, 0., 0.8}, {250, 0., 25.}}); + + // Momentum correlations p vs p_TPC + mHistManager.add("TrackCuts/TracksBefore/fMomCorrelationPos", "fMomCorrelation;#bf{#it{p} (GeV/#it{c})};#bf{#it{p}_{TPC} (GeV/#it{c})}", {HistType::kTH2F, {{500, 0.0f, 20.0f}, {500, 0.0f, 20.0f}}}); + mHistManager.add("TrackCuts/TracksBefore/fMomCorrelationNeg", "fMomCorrelation;#bf{#it{p} (GeV/#it{c})};#bf{#it{p}_{TPC} (GeV/#it{c})}", {HistType::kTH2F, {{500, 0.0f, 20.0f}, {500, 0.0f, 20.0f}}}); + + // All tracks + mHistManager.add("TrackCuts/TracksBefore/fPtTrackBefore", "Transverse momentum of all processed tracks;#bf{#it{p}_{T} (GeV/#it{c})};#bf{#it{N}_{tracks}}", HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add("TrackCuts/TracksBefore/fEtaTrackBefore", "Pseudorapidity of all processed tracks;#eta;#bf{#it{N}_{tracks}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("TrackCuts/TracksBefore/fPhiTrackBefore", "Azimuthal angle of all processed tracks;#phi;#bf{#it{N}_{tracks}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + // TPC signal + mHistManager.add("TrackCuts/TPCSignal/fTPCSignalTPCP", "TPCSignal;#bf{#it{p}_{TPC} (GeV/#it{c})};dE/dx", {HistType::kTH2F, {{500, 0.0f, 6.0f}, {2000, -100.f, 500.f}}}); + mHistManager.add("TrackCuts/TPCSignal/fTPCSignal", "TPCSignalP;#bf{#it{p} (GeV/#it{c})};dE/dx", {HistType::kTH2F, {{500, 0.0f, 6.0f}, {2000, -100.f, 500.f}}}); + // TPC signal antiparticles (negative charge) + mHistManager.add("TrackCuts/TPCSignal/fTPCSignalAntiTPCP", "TPCSignal;#bf{#it{p}_{TPC} (GeV/#it{c})};dE/dx", {HistType::kTH2F, {{500, 0.0f, 6.0f}, {2000, -100.f, 500.f}}}); + mHistManager.add("TrackCuts/TPCSignal/fTPCSignalAnti", "TPCSignalP;#bf{#it{p} (GeV/#it{c})};dE/dx", {HistType::kTH2F, {{500, 0.0f, 6.0f}, {2000, -100.f, 500.f}}}); + + const int nTrackSpecies = 2; // x2 because of anti particles + const char* particleSpecies[nTrackSpecies] = {"Pion", "AntiPion"}; + const char* particleSpeciesLatex[nTrackSpecies] = {"#pi^{+}", "#pi^{-}"}; + + for (int iParticle = 0; iParticle < nTrackSpecies; iParticle++) { + mHistManager.add(Form("TrackCuts/TracksBefore/fMomCorrelationAfterCuts%s", particleSpecies[iParticle]), "fMomCorrelation;#bf{#it{p} (GeV/#it{c})};#bf{#it{p}_{TPC} (GeV/#it{c})}", {HistType::kTH2F, {{500, 0.0f, 20.0f}, {500, 0.0f, 20.0f}}}); + mHistManager.add(Form("TrackCuts/TPCSignal/fTPCSignal%s", particleSpecies[iParticle]), Form("%s TPC energy loss;#bf{#it{p}_{TPC}^{%s} (GeV/#it{c})};dE/dx", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{500, 0.0f, 6.0f}, {10000, -100.f, 500.f}}}); + + mHistManager.add(Form("TrackCuts/%s/fP", particleSpecies[iParticle]), Form("%s momentum at PV;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add(Form("TrackCuts/%s/fPt", particleSpecies[iParticle]), Form("%s transverse momentum;#bf{#it{p}_{T}^{%s} (GeV/#it{c})};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add(Form("TrackCuts/%s/fMomCorDif", particleSpecies[iParticle]), Form("Momentum correlation;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{#it{p}_{TPC}^{%s} - #it{p}^{%s} (GeV/#it{c})}", particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{500, 0, 10}, {600, -3, 3}}}); + mHistManager.add(Form("TrackCuts/%s/fMomCorRatio", particleSpecies[iParticle]), Form("Relative momentum correlation;#bf{#it{p}^{%s} (GeV/#it{c})};#bf{#it{p}_{TPC}^{%s} - #it{p}^{%s} / #it{p}^{%s}}", particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{500, 0, 10}, {200, -1, 1}}}); + mHistManager.add(Form("TrackCuts/%s/fEta", particleSpecies[iParticle]), Form("%s pseudorapidity distribution;#eta;#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add(Form("TrackCuts/%s/fPhi", particleSpecies[iParticle]), Form("%s azimuthal angle distribution;#phi;#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + mHistManager.add(Form("TrackCuts/%s/fNsigmaTPCvsTPCP", particleSpecies[iParticle]), Form("NSigmaTPC %s;#bf{#it{p}_{TPC}^{%s} (GeV/#it{c})};n#sigma_{TPC}^{%s}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTOFvsTPCP", particleSpecies[iParticle]), Form("NSigmaTOF %s;#bf{#it{p}_{TPC}^{%s} (GeV/#it{c})};n#sigma_{TOF}^{%s}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTPCTOFvsTPCP", particleSpecies[iParticle]), Form("NSigmaTPCTOF %s;#bf{#it{p}_{TPC}^{%s} (GeV/#it{c})};n#sigma_{comb}^{%s}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaITSvsP", particleSpecies[iParticle]), Form("NSigmaITS %s;#bf{#it{p}^{%s} (GeV/#it{c})};n#sigma_{ITS}^{%s}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTPCvsP", particleSpecies[iParticle]), Form("NSigmaTPC %s P;#bf{#it{p}^{%s} (GeV/#it{c})};n#sigma_{TPC}^{%s}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTOFvsP", particleSpecies[iParticle]), Form("NSigmaTOF %s P;#bf{#it{p}^{%s} (GeV/#it{c})};n#sigma_{TOF}^{%s}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + mHistManager.add(Form("TrackCuts/%s/fNsigmaTPCTOFvsP", particleSpecies[iParticle]), Form("NSigmaTPCTOF %s P;#bf{#it{p}^{%s} (GeV/#it{c})};n#sigma_{comb}^{%s}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, 0.f, 10.f}}}); + + mHistManager.add(Form("TrackCuts/%s/fDCAxy", particleSpecies[iParticle]), Form("fDCAxy %s;#bf{DCA_{xy}};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, -0.5f, 0.5f}}); + mHistManager.add(Form("TrackCuts/%s/fDCAz", particleSpecies[iParticle]), Form("fDCAz %s;#bf{DCA_{z}};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, -0.5f, 0.5f}}); + mHistManager.add(Form("TrackCuts/%s/fTPCsCls", particleSpecies[iParticle]), Form("fTPCsCls %s;#bf{TPC Shared Clusters};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{163, -1.0f, 162.0f}}); + mHistManager.add(Form("TrackCuts/%s/fTPCcRows", particleSpecies[iParticle]), Form("fTPCcRows %s;#bf{TPC Crossed Rows};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{163, -1.0f, 162.0f}}); + mHistManager.add(Form("TrackCuts/%s/fTrkTPCfCls", particleSpecies[iParticle]), Form("fTrkTPCfCls %s;#bf{TPC Findable/CrossedRows};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, 0.0f, 3.0f}}); + mHistManager.add(Form("TrackCuts/%s/fTPCncls", particleSpecies[iParticle]), Form("fTPCncls %s;#bf{TPC Clusters};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{163, -1.0f, 162.0f}}); + } + + // --> HNM QA + // pi+ daughter + mHistManager.add("HNM/Before/PosDaughter/fInvMass", "Invariant mass HMN Pos Daugh;#bf{#it{M}^{#pi^{+}} (GeV/#it{c}^{2})};#bf{#it{N}^{#pi^{+}}}", HistType::kTH1F, {{200, 0, 0.2}}); + mHistManager.add("HNM/Before/PosDaughter/fPt", "Transverse momentum HMN Pos Daugh tracks;#bf{#it{p}_{T} (GeV/#it{c})};#bf{#it{N}^{#pi^{+}}}", HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add("HNM/Before/PosDaughter/fEta", "HMN Pos Daugh Eta;#eta;#bf{#it{N}^{#pi^{+}}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/PosDaughter/fPhi", "Azimuthal angle of HMN Pos Daugh tracks;#phi;#bf{#it{N}^{#pi^{+}}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + // pi- daughter + mHistManager.add("HNM/Before/NegDaughter/fInvMass", "Invariant mass HMN Neg Daugh;#bf{#it{M}^{#pi^{-}} (GeV/#it{c}^{2})};#bf{#it{N}^{#pi^{-}}}", HistType::kTH1F, {{200, 0, 0.2}}); + mHistManager.add("HNM/Before/NegDaughter/fPt", "Transverse momentum HMN Neg Daugh tracks;#bf{#it{p}_{T} (GeV/#it{c})};#bf{#it{N}^{#pi^{-}}}", HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add("HNM/Before/NegDaughter/fEta", "HMN Neg Daugh Eta;#eta;#bf{#it{N}^{#pi^{-}}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/NegDaughter/fPhi", "Azimuthal angle of HMN Neg Daugh tracks;#phi;#bf{#it{N}^{#pi^{-}}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + // Properties of the pi+pi- pair + mHistManager.add("HNM/Before/PiPlPiMi/fInvMassVsPt", "Invariant mass and pT of #pi^+pi^- pairs;#bf{#it{M}^{#pi^{+}#pi^{-}} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}} (GeV/#it{c})}", HistType::kTH2F, {{400, 0.2, 1.}, {250, 0., 25.}}); + mHistManager.add("HNM/Before/PiPlPiMi/fEta", "Pseudorapidity of HMNCand;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/PiPlPiMi/fPhi", "Azimuthal angle of HMNCand;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + for (const auto& BeforeAfterString : {"Before", "After"}) { + for (const auto& iHNM : {"Omega", "EtaPrime"}) { + for (const auto& MethodString : {"PCM", "EMC"}) { + mHistManager.add(Form("HNM/%s/%s/%s/fInvMassVsPt", BeforeAfterString, iHNM, MethodString), "Invariant mass and pT of heavy neutral meson candidates;#bf{#it{M}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{600, 0.6, 1.2}, {250, 0., 25.}}); + mHistManager.add(Form("HNM/%s/%s/%s/fEta", BeforeAfterString, iHNM, MethodString), "Pseudorapidity of HNM candidate;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add(Form("HNM/%s/%s/%s/fPhi", BeforeAfterString, iHNM, MethodString), "Azimuthal angle of HNM candidate;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + } + } + } + mHistManager.add("HNM/Before/Omega/PCMEMC/fInvMassVsPt", "Invariant mass and pT of omega meson candidates;#bf{#it{M}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{600, 0.6, 1.2}, {250, 0., 25.}}); + mHistManager.add("HNM/Before/Omega/PCMEMC/fEta", "Pseudorapidity of HMNCand;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/Omega/PCMEMC/fPhi", "Azimuthal angle of HMNCand;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + mHistManager.add("HNM/Before/EtaPrime/PCMEMC/fInvMassVsPt", "Invariant mass and pT of eta' meson candidates;#bf{#it{M}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{600, 0.8, 1.2}, {250, 0., 25.}}); + mHistManager.add("HNM/Before/EtaPrime/PCMEMC/fEta", "Pseudorapidity of HMNCand;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("HNM/Before/EtaPrime/PCMEMC/fPhi", "Azimuthal angle of HMNCand;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + if (cfgDoEMCShift.value) { + for (int iSM = 0; iSM < nSMs; iSM++) { + emcEtaShift[iSM] = cfgEMCEtaShift.value[iSM]; + emcPhiShift[iSM] = cfgEMCPhiShift.value[iSM]; + LOG(info) << "SM-wise shift in eta/phi for SM " << iSM << ": " << emcEtaShift[iSM] << " / " << emcPhiShift[iSM]; + } + } + } + + void process(aod::MyCollision const& collision, aod::MyBCs const&, aod::SkimEMCClusters const& clusters, aod::V0PhotonsKF const& v0s, aod::SelectedTracks const& tracks) + { + // inlcude ITS PID information + auto tracksWithItsPid = soa::Attach(tracks); + + // QA all evts + mHistManager.fill(HIST("Event/fMultiplicityBefore"), collision.multNTracksPV()); + mHistManager.fill(HIST("Event/fZvtxBefore"), collision.posZ()); + + // Ensure evts are consistent with Sel8 and Vtx-z selection + if (!isSelectedEvent(collision)) + return; + + // QA accepted evts + mHistManager.fill(HIST("Event/fMultiplicityAfter"), collision.multNTracksPV()); + mHistManager.fill(HIST("Event/fZvtxAfter"), collision.posZ()); + + // clean vecs + pion.clear(); + antipion.clear(); + vHNMs.clear(); + // vGGs vector is cleared in reconstructGGs. + + // ---------------------------------> EMCal event QA <---------------------------------- + // - Fill Event/nEMCalEvents histogram for EMCal event QA + // ------------------------------------------------------------------------------------- + bool bcHasEMCCells = collision.isemcreadout(); + bool iskTVXinEMC = collision.foundBC_as().alias_bit(kTVXinEMC); + bool isL0Triggered = collision.foundBC_as().alias_bit(kEMC7) || collision.foundBC_as().alias_bit(kEG1) || collision.foundBC_as().alias_bit(kEG2); + + if (bcHasEMCCells && iskTVXinEMC) + mHistManager.fill(HIST("Event/nEMCalEvents"), 0); + if (bcHasEMCCells && isL0Triggered) + mHistManager.fill(HIST("Event/nEMCalEvents"), 1); + if (bcHasEMCCells && !iskTVXinEMC && !isL0Triggered) + mHistManager.fill(HIST("Event/nEMCalEvents"), 2); + if (!bcHasEMCCells && iskTVXinEMC) + mHistManager.fill(HIST("Event/nEMCalEvents"), 3); + if (!bcHasEMCCells && isL0Triggered) + mHistManager.fill(HIST("Event/nEMCalEvents"), 4); + + // --------------------------------> Process Photons <---------------------------------- + // - Slice clusters and V0s by collision ID to get the ones in this collision + // - Store the clusters and V0s in the vGammas vector + // - Reconstruct gamma-gamma pairs + // ------------------------------------------------------------------------------------- + auto v0sInThisCollision = v0s.sliceBy(perCollisionPCM, collision.globalIndex()); + auto clustersInThisCollision = clusters.sliceBy(perCollisionEMC, collision.globalIndex()); + mHistManager.fill(HIST("Event/nClustersVsV0s"), clustersInThisCollision.size(), v0sInThisCollision.size()); + + std::vector vGammas; + hnmutilities::storeGammasInVector(clustersInThisCollision, v0sInThisCollision, vGammas, emcEtaShift, emcPhiShift); + hnmutilities::reconstructGGs(vGammas, vGGs); + vGammas.clear(); + processGGs(vGGs); + + // ------------------------------> Loop over all tracks <------------------------------- + // - Sort them into vectors based on PID ((anti)protons, (anti)deuterons, (anti)pions) + // - Fill QA histograms for all tracks and per particle species + // ------------------------------------------------------------------------------------- + for (const auto& track : tracksWithItsPid) { + mHistManager.fill(HIST("TrackCuts/TracksBefore/fPtTrackBefore"), track.pt()); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fEtaTrackBefore"), track.eta()); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fPhiTrackBefore"), track.phi()); + if (track.sign() > 0) { // All particles (positive electric charge) + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalTPCP"), track.tpcInnerParam(), track.tpcSignal()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignal"), track.p(), track.tpcSignal()); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationPos"), track.p(), track.tpcInnerParam()); + } + if (track.sign() < 0) { // All anti-particles (negative electric charge) + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiTPCP"), track.tpcInnerParam(), track.tpcSignal()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAnti"), track.p(), track.tpcSignal()); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationNeg"), track.p(), track.tpcInnerParam()); + } + + // For each track, check if it fulfills track and PID criteria to be identified as a proton, deuteron or pion + bool isPion = (isSelectedTrackPID(track, hnm::kPion) && isSelectedTrack(track, hnm::kPion)); + + if (track.sign() > 0) { // Positive charge -> Particles + if (isPion) { + pion.emplace_back(track.pt(), track.eta(), track.phi(), mMassPionCharged); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsPion"), track.p(), track.tpcInnerParam()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalPion"), track.tpcInnerParam(), track.tpcSignal()); + + mHistManager.fill(HIST("TrackCuts/Pion/fP"), track.p()); + mHistManager.fill(HIST("TrackCuts/Pion/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/Pion/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); + mHistManager.fill(HIST("TrackCuts/Pion/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + mHistManager.fill(HIST("TrackCuts/Pion/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/Pion/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTPCvsTPCP"), track.tpcInnerParam(), track.tpcNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTOFvsTPCP"), track.tpcInnerParam(), track.tofNSigmaPi()); + auto nSigmaTrackTPCTOF = std::sqrt(std::pow(track.tpcNSigmaPi(), 2) + std::pow(track.tofNSigmaPi(), 2)); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTPCTOFvsTPCP"), track.tpcInnerParam(), std::sqrt(std::pow(track.tpcNSigmaPi() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPi() - nSigmaTrackTPCTOF, 2))); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaITSvsP"), track.p(), track.itsNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTOFvsP"), track.p(), track.tofNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTPCTOFvsP"), track.p(), std::sqrt(std::pow(track.tpcNSigmaPi() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPi() - nSigmaTrackTPCTOF, 2))); + + mHistManager.fill(HIST("TrackCuts/Pion/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/Pion/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/Pion/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/Pion/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/Pion/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/Pion/fTPCncls"), track.tpcNClsFound()); + } + } else { // Negative charge -> Anti-particles + if (isPion) { + antipion.emplace_back(track.pt(), track.eta(), track.phi(), mMassPionCharged); + mHistManager.fill(HIST("TrackCuts/TracksBefore/fMomCorrelationAfterCutsAntiPion"), track.p(), track.tpcInnerParam()); + mHistManager.fill(HIST("TrackCuts/TPCSignal/fTPCSignalAntiPion"), track.tpcInnerParam(), track.tpcSignal()); + + mHistManager.fill(HIST("TrackCuts/AntiPion/fP"), track.p()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fMomCorDif"), track.p(), track.tpcInnerParam() - track.p()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fMomCorRatio"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTPCvsTPCP"), track.tpcInnerParam(), track.tpcNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTOFvsTPCP"), track.tpcInnerParam(), track.tofNSigmaPi()); + auto nSigmaTrackTPCTOF = std::sqrt(std::pow(track.tpcNSigmaPi(), 2) + std::pow(track.tofNSigmaPi(), 2)); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTPCTOFvsTPCP"), track.tpcInnerParam(), std::sqrt(std::pow(track.tpcNSigmaPi() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPi() - nSigmaTrackTPCTOF, 2))); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaITSvsP"), track.p(), track.itsNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTOFvsP"), track.p(), track.tofNSigmaPi()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTPCTOFvsP"), track.p(), std::sqrt(std::pow(track.tpcNSigmaPi() - nSigmaTrackTPCTOF, 2) + std::pow(track.tofNSigmaPi() - nSigmaTrackTPCTOF, 2))); + + mHistManager.fill(HIST("TrackCuts/AntiPion/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTPCncls"), track.tpcNClsFound()); + } + } + } + + // -------------------------> Reconstruct HNM candidates <------------------------------ + // - Based on the previously filled (anti)pion vectors + // - Fill QA histograms for kinematics of the pions and their combinations + // ------------------------------------------------------------------------------------- + for (const auto& posPion : pion) { + for (const auto& negPion : antipion) { + ROOT::Math::PtEtaPhiMVector vecPiPlPiMi = posPion + negPion; + hnmutilities::reconstructHeavyNeutralMesons(vecPiPlPiMi, vGGs, vHNMs); + + mHistManager.fill(HIST("HNM/Before/PiPlPiMi/fInvMassVsPt"), vecPiPlPiMi.M(), vecPiPlPiMi.pt()); + mHistManager.fill(HIST("HNM/Before/PiPlPiMi/fEta"), vecPiPlPiMi.eta()); + mHistManager.fill(HIST("HNM/Before/PiPlPiMi/fPhi"), RecoDecay::constrainAngle(vecPiPlPiMi.phi())); + + mHistManager.fill(HIST("HNM/Before/PosDaughter/fInvMass"), posPion.M()); + mHistManager.fill(HIST("HNM/Before/PosDaughter/fPt"), posPion.pt()); + mHistManager.fill(HIST("HNM/Before/PosDaughter/fEta"), posPion.eta()); + mHistManager.fill(HIST("HNM/Before/PosDaughter/fPhi"), RecoDecay::constrainAngle(posPion.phi())); + + mHistManager.fill(HIST("HNM/Before/NegDaughter/fInvMass"), negPion.M()); + mHistManager.fill(HIST("HNM/Before/NegDaughter/fPt"), negPion.pt()); + mHistManager.fill(HIST("HNM/Before/NegDaughter/fEta"), negPion.eta()); + mHistManager.fill(HIST("HNM/Before/NegDaughter/fPhi"), RecoDecay::constrainAngle(negPion.phi())); + } + } + + // ---------------------------> Process HNM candidates <-------------------------------- + // - Fill invMassVsPt histograms separated into HNM types (based on GG mass) and gamma reco method + // ------------------------------------------------------------------------------------- + processHNMs(vHNMs); + } + + /// \brief Loop over the GG candidates, fill the mass/pt histograms and set the isPi0/isEta flags based on the reconstructed mass + void processGGs(std::vector& vGGs) + { + int nGGsBeforeMassCuts = vGGs.size(); + for (unsigned int iGG = 0; iGG < vGGs.size(); iGG++) { + auto lightMeson = &vGGs.at(iGG); + + if (lightMeson->reconstructionType == photonpair::kPCMPCM) { + mHistManager.fill(HIST("GG/invMassVsPt_PCM"), lightMeson->m(), lightMeson->pT()); + } else if (lightMeson->reconstructionType == photonpair::kEMCEMC) { + mHistManager.fill(HIST("GG/invMassVsPt_EMC"), lightMeson->m(), lightMeson->pT()); + } else { + mHistManager.fill(HIST("GG/invMassVsPt_PCMEMC"), lightMeson->m(), lightMeson->pT()); + } + + if (lightMeson->m() > cfgMassWindowOmega->get("pi0_min") && lightMeson->m() < cfgMassWindowOmega->get("pi0_max")) { + lightMeson->isPi0 = true; + } else if (lightMeson->m() > cfgMassWindowEtaPrime->get("eta_min") && lightMeson->m() < cfgMassWindowEtaPrime->get("eta_max")) { + lightMeson->isEta = true; + } else { + vGGs.erase(vGGs.begin() + iGG); + iGG--; + } + } + mHistManager.fill(HIST("Event/nGGs"), nGGsBeforeMassCuts, vGGs.size()); + } + + /// \brief Loop over the heavy neutral meson candidates, fill the mass/pt histograms and set the trigger flags based on the reconstructed mass + void processHNMs(std::vector& vHNMs) + { + int nHNMsBeforeMassCuts = vHNMs.size(); + + for (unsigned int iHNM = 0; iHNM < vHNMs.size(); iHNM++) { + auto heavyNeutralMeson = vHNMs.at(iHNM); + float massHNM = heavyNeutralMeson.m(cfgHNMMassCorrection); + + if (heavyNeutralMeson.gg->reconstructionType == photonpair::kPCMPCM) { + if (heavyNeutralMeson.gg->isPi0) { + mHistManager.fill(HIST("HNM/Before/Omega/PCM/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/Omega/PCM/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/Omega/PCM/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } else if (heavyNeutralMeson.gg->isEta) { + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCM/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCM/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCM/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + } else if (heavyNeutralMeson.gg->reconstructionType == photonpair::kEMCEMC) { + if (heavyNeutralMeson.gg->isPi0) { + mHistManager.fill(HIST("HNM/Before/Omega/EMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/Omega/EMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/Omega/EMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } else if (heavyNeutralMeson.gg->isEta) { + mHistManager.fill(HIST("HNM/Before/EtaPrime/EMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/EMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/EMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + } else { + if (heavyNeutralMeson.gg->isPi0) { + mHistManager.fill(HIST("HNM/Before/Omega/PCMEMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/Omega/PCMEMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/Omega/PCMEMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } else if (heavyNeutralMeson.gg->isEta) { + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCMEMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCMEMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/Before/EtaPrime/PCMEMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + } + + if (heavyNeutralMeson.gg->isPi0 && massHNM > cfgMassWindowOmega->get("omega_min") && massHNM < cfgMassWindowOmega->get("omega_max") && heavyNeutralMeson.gg->pT() / heavyNeutralMeson.pT() > cfgMinGGPtOverHNMPt) { + if (heavyNeutralMeson.gg->reconstructionType == photonpair::kPCMPCM) { + omegaPCM.emplace_back(heavyNeutralMeson.pT(), heavyNeutralMeson.eta(), RecoDecay::constrainAngle(heavyNeutralMeson.phi()), mMassOmega); + mHistManager.fill(HIST("HNM/After/Omega/PCM/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/After/Omega/PCM/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/After/Omega/PCM/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } else if (heavyNeutralMeson.gg->reconstructionType == photonpair::kEMCEMC) { + omegaEMC.emplace_back(heavyNeutralMeson.pT(), heavyNeutralMeson.eta(), RecoDecay::constrainAngle(heavyNeutralMeson.phi()), mMassOmega); + mHistManager.fill(HIST("HNM/After/Omega/EMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/After/Omega/EMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/After/Omega/EMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + } else if (heavyNeutralMeson.gg->isEta && massHNM > cfgMassWindowEtaPrime->get("etaprime_min") && massHNM < cfgMassWindowEtaPrime->get("etaprime_max") && heavyNeutralMeson.gg->pT() / heavyNeutralMeson.pT() > cfgMinGGPtOverHNMPt) { + if (heavyNeutralMeson.gg->reconstructionType == photonpair::kPCMPCM) { + etaPrimePCM.emplace_back(heavyNeutralMeson.pT(), heavyNeutralMeson.eta(), RecoDecay::constrainAngle(heavyNeutralMeson.phi()), mMassEtaPrime); + mHistManager.fill(HIST("HNM/After/EtaPrime/PCM/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/After/EtaPrime/PCM/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/After/EtaPrime/PCM/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } else if (heavyNeutralMeson.gg->reconstructionType == photonpair::kEMCEMC) { + etaPrimeEMC.emplace_back(heavyNeutralMeson.pT(), heavyNeutralMeson.eta(), RecoDecay::constrainAngle(heavyNeutralMeson.phi()), mMassEtaPrime); + mHistManager.fill(HIST("HNM/After/EtaPrime/EMC/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("HNM/After/EtaPrime/EMC/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("HNM/After/EtaPrime/EMC/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + } else { + vHNMs.erase(vHNMs.begin() + iHNM); + iHNM--; + } + } + mHistManager.fill(HIST("Event/nHeavyNeutralMesons"), nHNMsBeforeMassCuts, vHNMs.size()); + } +}; + +WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGEM/PhotonMeson/Tasks/OmegaMesonEMC.cxx b/PWGEM/PhotonMeson/Tasks/OmegaMesonEMC.cxx new file mode 100644 index 00000000000..6ac2788f549 --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/OmegaMesonEMC.cxx @@ -0,0 +1,342 @@ +// 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. +/// +/// \file OmegaMesonEMC.cxx +/// +/// \brief This code loops over collisions to reconstruct heavy mesons (omega or eta') using EMCal clusters +/// +/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) - Goethe University Frankfurt +/// + +#include "PWGEM/PhotonMeson/Utils/HNMUtilities.h" +#include "PWGJE/DataModel/EMCALMatchedCollisions.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/MathConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector4D.h" +#include "TMath.h" +#include "TRandom3.h" + +#include "fairlogger/Logger.h" + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::pwgem::photonmeson; + +namespace o2::aod +{ +using MyBCs = soa::Join; +using MyCollisions = soa::Filtered>; +using MyCollision = MyCollisions::iterator; +using SelectedTracks = soa::Filtered>; +} // namespace o2::aod + +namespace hnm +{ + +enum TrackCuts { kpT, + kEta, + kTPCSigma, + kTrackCuts +}; + +const std::vector chargedPionMinMaxName{"Min", "Max"}; +const std::vector chargedPionCutsName{"pT", "eta", "TPC sigma"}; +const float chargedPionCutsTable[kTrackCuts][2]{{0.35f, 20.f}, {-.8f, .8f}, {-4.f, 4.f}}; + +} // namespace hnm + +struct OmegaMesonEMC { + + // --------------------------------> Configurables <------------------------------------ + // - Event selection cuts + // - Track selection cuts + // - Cluster shifts + // - HNM mass selection windows + // ------------------------------------------------------------------------------------- + // ---> Event selection + Configurable confEvtSelectZvtx{"confEvtSelectZvtx", true, "Event selection includes max. z-Vertex"}; + Configurable confEvtZvtx{"confEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable confEvtRequireSel8{"confEvtRequireSel8", true, "Evt sel: check for sel8 trigger bit"}; + Configurable confEvtRequirekTVXinEMC{"confEvtRequirekTVXinEMC", false, "Evt sel: check for EMCal MB trigger kTVXinEMC"}; + + // ---> Track selection + Configurable> cfgChargedPionCuts{"cfgChargedPionCuts", {hnm::chargedPionCutsTable[0], 3, 2, hnm::chargedPionCutsName, hnm::chargedPionMinMaxName}, "Charged pion track cuts"}; + Configurable cfgTPCNClustersMin{"cfgTPCNClustersMin", 80, "Mininum of TPC Clusters"}; + Configurable cfgTrkTPCfCls{"cfgTrkTPCfCls", 0.83, "Minimum fraction of crossed rows over findable clusters"}; + Configurable cfgTrkTPCcRowsMin{"cfgTrkTPCcRowsMin", 70, "Minimum number of crossed TPC rows"}; + Configurable cfgTrkTPCsClsSharedFrac{"cfgTrkTPCsClsSharedFrac", 1.f, "Fraction of shared TPC clusters"}; + Configurable cfgTrkITSnclsMin{"cfgTrkITSnclsMin", 4, "Minimum number of ITS clusters"}; + Configurable cfgTrkDCAxyMax{"cfgTrkDCAxyMax", 0.15, "Maximum DCA_xy"}; + Configurable cfgTrkDCAzMax{"cfgTrkDCAzMax", 0.3, "Maximum DCA_z"}; + Configurable cfgTrkMaxChi2PerClusterTPC{"cfgTrkMaxChi2PerClusterTPC", 4.0f, "Minimal track selection: max allowed chi2 per TPC cluster"}; // 4.0 is default of global tracks on 20.01.2023 + Configurable cfgTrkMaxChi2PerClusterITS{"cfgTrkMaxChi2PerClusterITS", 36.0f, "Minimal track selection: max allowed chi2 per ITS cluster"}; // 36.0 is default of global tracks on 20.01.2023 + + // ---> Configurables to allow for a shift in eta/phi of EMCal clusters to better align with extrapolated TPC tracks + Configurable cfgDoEMCShift{"cfgDoEMCShift", false, "Apply SM-wise shift in eta and phi to EMCal clusters to align with TPC tracks"}; + Configurable> cfgEMCEtaShift{"cfgEMCEtaShift", {0.f}, "values for SM-wise shift in eta to be added to EMCal clusters to align with TPC tracks"}; + Configurable> cfgEMCPhiShift{"cfgEMCPhiShift", {0.f}, "values for SM-wise shift in phi to be added to EMCal clusters to align with TPC tracks"}; + static const int nSMs = 20; + std::array emcEtaShift = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + std::array emcPhiShift = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + // ---> Shift the omega/eta' mass based on the difference of the reconstructed mass of the pi0/eta to its PDG mass to reduce smearing caused by EMCal/PCM in photon measurement + Configurable cfgHNMMassCorrection{"cfgHNMMassCorrection", 1, "Use GG PDG mass to correct HNM mass (0 = off, 1 = subDeltaPi0, 2 = subLambda)"}; + + // ---> Mass windows for the selection of heavy neutral mesons (also based on mass of their light neutral meson decay daughter) + static constexpr float DefaultMassWindows[2] = {0.11, 0.16}; + Configurable> cfgMassWindowPi0{"cfgMassWindowPi0", {DefaultMassWindows, 2, {"min", "max"}}, "Mass window for selected decay pi0"}; + + Configurable cfgMaxMultiplicity{"cfgMaxMultiplicity", 5000, "Maximum number of tracks in a collision (can be used to increase the S/B -> Very experimental)"}; + Configurable cfgMinGGPtOverHNMPt{"cfgMinGGPtOverHNMPt", 0., "Minimum ratio of the pT of the gamma gamma pair over the pT of the HNM (can be used to increase the S/B)"}; + + Filter collisionZVtxFilter = nabs(aod::collision::posZ) < confEvtZvtx; + Filter collisionMultFilter = (o2::aod::mult::multNTracksPV <= cfgMaxMultiplicity); + + Filter trackPtFilter = (o2::aod::track::pt > cfgChargedPionCuts->get(hnm::kpT, "Min")) && (o2::aod::track::pt < cfgChargedPionCuts->get(hnm::kpT, "Max")); + Filter trackEtaFilter = (o2::aod::track::eta > cfgChargedPionCuts->get(hnm::kEta, "Min")) && (o2::aod::track::eta < cfgChargedPionCuts->get(hnm::kEta, "Max")); + Filter trackDCAXYFilter = nabs(o2::aod::track::dcaXY) < cfgTrkDCAxyMax; + Filter trackDCAZFilter = nabs(o2::aod::track::dcaZ) < cfgTrkDCAzMax; + + Filter trackTPCChi2Filter = o2::aod::track::tpcChi2NCl < cfgTrkMaxChi2PerClusterTPC; + Filter trackITSChi2Filter = o2::aod::track::itsChi2NCl < cfgTrkMaxChi2PerClusterITS; + + Filter trackTPCSigmaFilterTPC = (o2::aod::pidtpc::tpcNSigmaPi > cfgChargedPionCuts->get(hnm::kTPCSigma, "Min")) && (o2::aod::pidtpc::tpcNSigmaPi < cfgChargedPionCuts->get(hnm::kTPCSigma, "Max")); + + template + bool isSelectedTrack(T const& track) + { + if (track.tpcNClsFound() < cfgTPCNClustersMin) + return false; + if (track.tpcCrossedRowsOverFindableCls() < cfgTrkTPCfCls) + return false; + if (track.tpcNClsCrossedRows() < cfgTrkTPCcRowsMin) + return false; + if (track.tpcFractionSharedCls() > cfgTrkTPCsClsSharedFrac) + return false; + if (track.itsNCls() < cfgTrkITSnclsMin) + return false; + return true; + } + + HistogramRegistry mHistManager{"HeavyNeutralMesonHistograms", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Prepare vectors for different species + std::vector vGGs; + std::vector vHNMs; + std::vector pion, antipion; + + Preslice perCollisionEMC = aod::skimmedcluster::collisionId; + + void init(InitContext const&) + { + mHistManager.add("Event/nEMCalEvents", "Number of collisions with a certain combination of EMCal triggers;;#bf{#it{N}_{collisions}}", HistType::kTH1F, {{5, -0.5, 4.5}}); + std::vector nEventTitles = {"Cells & kTVXinEMC", "Cells & L0", "Cells & !kTVXinEMC & !L0", "!Cells & kTVXinEMC", "!Cells & L0"}; + for (size_t iBin = 0; iBin < nEventTitles.size(); iBin++) + mHistManager.get(HIST("Event/nEMCalEvents"))->GetXaxis()->SetBinLabel(iBin + 1, nEventTitles[iBin].data()); + mHistManager.add("Event/fMultiplicity", "Multiplicity after event cuts;#bf{#it{N}_{tracks}};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{500, 0, 500}}); + mHistManager.add("Event/fZvtx", "Zvtx after event cuts;#bf{z_{vtx} (cm)};#bf{#it{N}_{collisions}}", HistType::kTH1F, {{300, -15, 15}}); + + mHistManager.add("GG/invMassVsPt", "Invariant mass and pT of gg candidates;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{400, 0., 0.8}, {250, 0., 25.}}); + mHistManager.add("GG/invMassVsPt_selected", "Invariant mass and pT of gg candidates;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{400, 0., 0.8}, {250, 0., 25.}}); + + const int nTrackSpecies = 2; // x2 because of anti particles + const char* particleSpecies[nTrackSpecies] = {"Pion", "AntiPion"}; + const char* particleSpeciesLatex[nTrackSpecies] = {"#pi^{+}", "#pi^{-}"}; + + for (int iParticle = 0; iParticle < nTrackSpecies; iParticle++) { + mHistManager.add(Form("TrackCuts/%s/fPt", particleSpecies[iParticle]), Form("%s transverse momentum;#bf{#it{p}_{T}^{%s} (GeV/#it{c})};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, 0, 10}}); + mHistManager.add(Form("TrackCuts/%s/fEta", particleSpecies[iParticle]), Form("%s pseudorapidity distribution;#eta;#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add(Form("TrackCuts/%s/fPhi", particleSpecies[iParticle]), Form("%s azimuthal angle distribution;#phi;#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + mHistManager.add(Form("TrackCuts/%s/fNsigmaTPCvsP", particleSpecies[iParticle]), Form("NSigmaTPC %s P;#bf{#it{p}^{%s} (GeV/#it{c})};n#sigma_{TPC}^{%s}", particleSpecies[iParticle], particleSpeciesLatex[iParticle], particleSpeciesLatex[iParticle]), {HistType::kTH2F, {{100, 0.0f, 10.0f}, {100, -10.f, 10.f}}}); + + mHistManager.add(Form("TrackCuts/%s/fDCAxy", particleSpecies[iParticle]), Form("fDCAxy %s;#bf{DCA_{xy}};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, -0.5f, 0.5f}}); + mHistManager.add(Form("TrackCuts/%s/fDCAz", particleSpecies[iParticle]), Form("fDCAz %s;#bf{DCA_{z}};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, -0.5f, 0.5f}}); + mHistManager.add(Form("TrackCuts/%s/fTPCsCls", particleSpecies[iParticle]), Form("fTPCsCls %s;#bf{TPC Shared Clusters};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{163, -1.0f, 162.0f}}); + mHistManager.add(Form("TrackCuts/%s/fTPCcRows", particleSpecies[iParticle]), Form("fTPCcRows %s;#bf{TPC Crossed Rows};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{163, -1.0f, 162.0f}}); + mHistManager.add(Form("TrackCuts/%s/fTrkTPCfCls", particleSpecies[iParticle]), Form("fTrkTPCfCls %s;#bf{TPC Findable/CrossedRows};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{500, 0.0f, 3.0f}}); + mHistManager.add(Form("TrackCuts/%s/fTPCncls", particleSpecies[iParticle]), Form("fTPCncls %s;#bf{TPC Clusters};#bf{#it{N}^{%s}}", particleSpecies[iParticle], particleSpeciesLatex[iParticle]), HistType::kTH1F, {{163, -1.0f, 162.0f}}); + } + + // --> HNM QA + // Properties of the pi+pi- pair + mHistManager.add("Omega/Before/PiPlPiMi/fInvMassVsPt", "Invariant mass and pT of #pi^+pi^- pairs;#bf{#it{M}^{#pi^{+}#pi^{-}} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}} (GeV/#it{c})}", HistType::kTH2F, {{400, 0.2, 1.}, {250, 0., 25.}}); + mHistManager.add("Omega/Before/PiPlPiMi/fEta", "Pseudorapidity of HMNCand;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add("Omega/Before/PiPlPiMi/fPhi", "Azimuthal angle of HMNCand;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + + for (const auto& BeforeAfterString : {"Before", "After"}) { + mHistManager.add(Form("Omega/%s/fInvMassVsPt", BeforeAfterString), "Invariant mass and pT of heavy neutral meson candidates;#bf{#it{M}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#pi^{+}#pi^{-}#gamma#gamma} (GeV/#it{c})}", HistType::kTH2F, {{800, 0.4, 1.2}, {250, 0., 25.}}); + mHistManager.add(Form("Omega/%s/fEta", BeforeAfterString), "Pseudorapidity of HNM candidate;#eta;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{500, -2, 2}}); + mHistManager.add(Form("Omega/%s/fPhi", BeforeAfterString), "Azimuthal angle of HNM candidate;#phi;#bf{#it{N}^{#pi^{+}#pi^{-}#gamma#gamma}}", HistType::kTH1F, {{720, 0, constants::math::TwoPI}}); + } + if (cfgDoEMCShift.value) { + for (int iSM = 0; iSM < nSMs; iSM++) { + emcEtaShift[iSM] = cfgEMCEtaShift.value[iSM]; + emcPhiShift[iSM] = cfgEMCPhiShift.value[iSM]; + LOG(info) << "SM-wise shift in eta/phi for SM " << iSM << ": " << emcEtaShift[iSM] << " / " << emcPhiShift[iSM]; + } + } + } + + void process(aod::MyCollision const& collision, aod::MyBCs const&, aod::SkimEMCClusters const& clusters, aod::SelectedTracks const& tracks) + { + // clean vecs + pion.clear(); + antipion.clear(); + vHNMs.clear(); + + // ---------------------------------> EMCal event QA <---------------------------------- + // - Fill Event/nEMCalEvents histogram for EMCal event QA + // ------------------------------------------------------------------------------------- + bool bcHasEMCCells = collision.isemcreadout(); + auto foundBC = collision.foundBC_as(); + bool iskTVXinEMC = foundBC.alias_bit(kTVXinEMC); + bool isL0Triggered = foundBC.alias_bit(kEMC7) || foundBC.alias_bit(kDMC7) || foundBC.alias_bit(kEG1) || foundBC.alias_bit(kEG2); + + if (confEvtRequireSel8 && !collision.sel8()) + return; // Skip this collision if sel8 trigger bit is not set + if (confEvtRequirekTVXinEMC && !iskTVXinEMC) + return; // Skip this collision if kTVXinEMC trigger bit is not set + + if (bcHasEMCCells && iskTVXinEMC) + mHistManager.fill(HIST("Event/nEMCalEvents"), 0); + if (bcHasEMCCells && isL0Triggered) + mHistManager.fill(HIST("Event/nEMCalEvents"), 1); + if (bcHasEMCCells && !iskTVXinEMC && !isL0Triggered) + mHistManager.fill(HIST("Event/nEMCalEvents"), 2); + if (!bcHasEMCCells && iskTVXinEMC) + mHistManager.fill(HIST("Event/nEMCalEvents"), 3); + if (!bcHasEMCCells && isL0Triggered) + mHistManager.fill(HIST("Event/nEMCalEvents"), 4); + + mHistManager.fill(HIST("Event/fMultiplicity"), collision.multNTracksPV()); + mHistManager.fill(HIST("Event/fZvtx"), collision.posZ()); + + // --------------------------------> Process Photons <---------------------------------- + // - Slice clusters and V0s by collision ID to get the ones in this collision + // - Store the clusters and V0s in the vGammas vector + // - Reconstruct gamma-gamma pairs + // ------------------------------------------------------------------------------------- + auto clustersInThisCollision = clusters.sliceBy(perCollisionEMC, collision.globalIndex()); + + std::vector vGammas; + hnmutilities::storeGammasInVector(clustersInThisCollision, vGammas, emcEtaShift, emcPhiShift); + hnmutilities::reconstructGGs(vGammas, vGGs); + vGammas.clear(); + + for (unsigned int iGG = 0; iGG < vGGs.size(); iGG++) { + auto lightMeson = &vGGs.at(iGG); + + mHistManager.fill(HIST("GG/invMassVsPt"), lightMeson->m(), lightMeson->pT()); + + if (lightMeson->m() > cfgMassWindowPi0->get("min") && lightMeson->m() < cfgMassWindowPi0->get("max")) { + lightMeson->isPi0 = true; + mHistManager.fill(HIST("GG/invMassVsPt_selected"), lightMeson->m(), lightMeson->pT()); + } else { + vGGs.erase(vGGs.begin() + iGG); + iGG--; + } + } + + // ------------------------------> Loop over all tracks <------------------------------- + // - Fill QA histograms for all tracks and per particle species + // ------------------------------------------------------------------------------------- + for (const auto& track : tracks) { + if (!isSelectedTrack(track)) + continue; // Skip tracks that do not pass the selection criteria + if (track.sign() > 0) { // Positive charge -> Particles + pion.emplace_back(track.pt(), track.eta(), track.phi(), constants::physics::MassPionCharged); + + mHistManager.fill(HIST("TrackCuts/Pion/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/Pion/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/Pion/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/Pion/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaPi()); + + mHistManager.fill(HIST("TrackCuts/Pion/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/Pion/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/Pion/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/Pion/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/Pion/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/Pion/fTPCncls"), track.tpcNClsFound()); + } else { // Negative charge -> Anti-particles + antipion.emplace_back(track.pt(), track.eta(), track.phi(), constants::physics::MassPionCharged); + + mHistManager.fill(HIST("TrackCuts/AntiPion/fPt"), track.pt()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fEta"), track.eta()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fPhi"), track.phi()); + + mHistManager.fill(HIST("TrackCuts/AntiPion/fNsigmaTPCvsP"), track.p(), track.tpcNSigmaPi()); + + mHistManager.fill(HIST("TrackCuts/AntiPion/fDCAxy"), track.dcaXY()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fDCAz"), track.dcaZ()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTPCsCls"), track.tpcNClsShared()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTPCcRows"), track.tpcNClsCrossedRows()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTrkTPCfCls"), track.tpcCrossedRowsOverFindableCls()); + mHistManager.fill(HIST("TrackCuts/AntiPion/fTPCncls"), track.tpcNClsFound()); + } + } + + // -------------------------> Reconstruct HNM candidates <------------------------------ + // - Based on the previously filled (anti)pion vectors + // - Fill QA histograms for kinematics of the pions and their combinations + // ------------------------------------------------------------------------------------- + for (const auto& posPion : pion) { + for (const auto& negPion : antipion) { + ROOT::Math::PtEtaPhiMVector vecPiPlPiMi = posPion + negPion; + hnmutilities::reconstructHeavyNeutralMesons(vecPiPlPiMi, vGGs, vHNMs); + + mHistManager.fill(HIST("Omega/Before/PiPlPiMi/fInvMassVsPt"), vecPiPlPiMi.M(), vecPiPlPiMi.pt()); + mHistManager.fill(HIST("Omega/Before/PiPlPiMi/fEta"), vecPiPlPiMi.eta()); + mHistManager.fill(HIST("Omega/Before/PiPlPiMi/fPhi"), RecoDecay::constrainAngle(vecPiPlPiMi.phi())); + } + } + + // ---------------------------> Process HNM candidates <-------------------------------- + // - Fill invMassVsPt histograms separated into HNM types (based on GG mass) and gamma reco method + // ------------------------------------------------------------------------------------- + for (unsigned int iHNM = 0; iHNM < vHNMs.size(); iHNM++) { + auto heavyNeutralMeson = vHNMs.at(iHNM); + float massHNM = heavyNeutralMeson.m(cfgHNMMassCorrection); + + mHistManager.fill(HIST("Omega/Before/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("Omega/Before/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("Omega/Before/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + + if (heavyNeutralMeson.gg->pT() / heavyNeutralMeson.pT() > cfgMinGGPtOverHNMPt) { + mHistManager.fill(HIST("Omega/After/fInvMassVsPt"), massHNM, heavyNeutralMeson.pT()); + mHistManager.fill(HIST("Omega/After/fEta"), heavyNeutralMeson.eta()); + mHistManager.fill(HIST("Omega/After/fPhi"), RecoDecay::constrainAngle(heavyNeutralMeson.phi())); + } + } + } +}; + +WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"omega-meson-emc"})}; } diff --git a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaMCPCMPCM.cxx b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaMCPCMPCM.cxx index df8877d3ae8..9b79891739c 100644 --- a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaMCPCMPCM.cxx +++ b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaMCPCMPCM.cxx @@ -26,11 +26,11 @@ using namespace o2; using namespace o2::aod; -using MyV0Photons = soa::Join; -using MyV0Photon = MyV0Photons::iterator; +// using MyV0Photons = soa::Join; +// using MyV0Photon = MyV0Photons::iterator; -using MyMCV0Legs = soa::Join; -using MyMCV0Leg = MyMCV0Legs::iterator; +// using MyMCV0Legs = soa::Join; +// using MyMCV0Leg = MyMCV0Legs::iterator; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGEM/PhotonMeson/Tasks/SinglePhoton.cxx b/PWGEM/PhotonMeson/Tasks/SinglePhoton.cxx index 9c82fa7b09a..d00c2e9732f 100644 --- a/PWGEM/PhotonMeson/Tasks/SinglePhoton.cxx +++ b/PWGEM/PhotonMeson/Tasks/SinglePhoton.cxx @@ -14,29 +14,37 @@ // This code loops over photon candidate and fill histograms // Please write to: daiki.sekihata@cern.ch -#include -#include - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/Core/RecoDecay.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" +#include "EMPhotonEventCut.h" + #include "PWGEM/PhotonMeson/Core/CutsLibrary.h" +#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" #include "PWGEM/PhotonMeson/Core/HistogramsLibrary.h" +#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" + +#include "Common/CCDB/TriggerAliases.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -266,8 +274,8 @@ struct SinglePhoton { return is_selected; } - template - void FillPhoton(TEvents const& collisions, TPhotons1 const& photons1, TPreslice1 const& perCollision1, TCuts1 const& cuts1, TV0Legs const&, TEMCMatchedTracks const&) + template + void FillPhoton(TEvents const& collisions, TPhotons1 const& photons1, TPreslice1 const& perCollision1, TCuts1 const& cuts1, TV0Legs const&) { THashList* list_ev_before = static_cast(fMainList->FindObject("Event")->FindObject(detnames[photontype].data())->FindObject(event_types[0].data())); THashList* list_ev_after = static_cast(fMainList->FindObject("Event")->FindObject(detnames[photontype].data())->FindObject(event_types[1].data())); @@ -339,17 +347,17 @@ struct SinglePhoton { void processPCM(MyCollisions const&, MyV0Photons const& v0photons, aod::V0Legs const& legs) { - FillPhoton(grouped_collisions, v0photons, perCollision, fPCMCuts, legs, nullptr); + FillPhoton(grouped_collisions, v0photons, perCollision, fPCMCuts, legs); } // void processPHOS(MyCollisions const& collisions, aod::PHOSClusters const& phosclusters) // { - // FillPhoton(grouped_collisions, phosclusters, perCollision_phos, fPHOSCuts, nullptr, nullptr); + // FillPhoton(grouped_collisions, phosclusters, perCollision_phos, fPHOSCuts, nullptr); // } - // void processEMC(MyCollisions const& collisions, aod::SkimEMCClusters const& emcclusters, aod::SkimEMCMTs const& emcmatchedtracks) + // void processEMC(MyCollisions const& collisions, aod::SkimEMCClusters const& emcclusters) // { - // FillPhoton(grouped_collisions, emcclusters, perCollision_emc, fEMCCuts, nullptr, emcmatchedtracks); + // FillPhoton(grouped_collisions, emcclusters, perCollision_emc, fEMCCuts, nullptr); // } void processDummy(MyCollisions::iterator const&) {} diff --git a/PWGEM/PhotonMeson/Tasks/SinglePhotonMC.cxx b/PWGEM/PhotonMeson/Tasks/SinglePhotonMC.cxx index ccb33db7f3a..dd09bc17c4a 100644 --- a/PWGEM/PhotonMeson/Tasks/SinglePhotonMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/SinglePhotonMC.cxx @@ -14,32 +14,35 @@ // This code loops over photon candidate and fill histograms // Please write to: daiki.sekihata@cern.ch -#include -#include - -#include "TString.h" -#include "TMath.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/Core/RecoDecay.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" +#include "EMPhotonEventCut.h" + +#include "PWGEM/Dilepton/Utils/MCUtilities.h" #include "PWGEM/PhotonMeson/Core/CutsLibrary.h" +#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" #include "PWGEM/PhotonMeson/Core/HistogramsLibrary.h" -#include "PWGEM/Dilepton/Utils/MCUtilities.h" +#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" + +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/Centrality.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -272,8 +275,8 @@ struct SinglePhotonMC { return is_selected; } - template - void FillTruePhoton(TEvents const& collisions, TPhotons1 const& photons1, TPreslice1 const& perCollision1, TCuts1 const& cuts1, TV0Legs const&, TEMCMatchedTracks const&, TMCParticles const& mcparticles, TMCEvents const&) + template + void FillTruePhoton(TEvents const& collisions, TPhotons1 const& photons1, TPreslice1 const& perCollision1, TCuts1 const& cuts1, TV0Legs const&, TMCParticles const& mcparticles, TMCEvents const&) { THashList* list_ev_before = static_cast(fMainList->FindObject("Event")->FindObject(detnames[photontype].data())->FindObject(event_types[0].data())); THashList* list_ev_after = static_cast(fMainList->FindObject("Event")->FindObject(detnames[photontype].data())->FindObject(event_types[1].data())); @@ -351,25 +354,25 @@ struct SinglePhotonMC { } } // end of photon loop - } // end of cut loop - } // end of collision loop + } // end of cut loop + } // end of collision loop } Partition grouped_collisions = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); // this goes to same event. void processPCM(MyCollisions const&, MyV0Photons const& v0photons, MyMCV0Legs const& legs, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const& mccollisions) { - FillTruePhoton(grouped_collisions, v0photons, perCollision, fPCMCuts, legs, nullptr, mcparticles, mccollisions); + FillTruePhoton(grouped_collisions, v0photons, perCollision, fPCMCuts, legs, mcparticles, mccollisions); } // void processPHOS(MyCollisions const& collisions, aod::PHOSClusters const& phosclusters, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const& mccollisions) // { - // FillTruePhoton(grouped_collisions, phosclusters, perCollision_phos, fPHOSCuts, nullptr, nullptr, mcparticles, mccollisions); + // FillTruePhoton(grouped_collisions, phosclusters, perCollision_phos, fPHOSCuts, nullptr, mcparticles, mccollisions); // } - // void processEMC(MyCollisions const& collisions, aod::SkimEMCClusters const& emcclusters, aod::SkimEMCMTs const& emcmatchedtracks, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const& mccollisions) + // void processEMC(MyCollisions const& collisions, aod::SkimEMCClusters const& emcclusters, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const& mccollisions) // { - // FillTruePhoton(grouped_collisions, emcclusters, perCollision_emc, fEMCCuts, nullptr, emcmatchedtracks, mcparticles, mccollisions); + // FillTruePhoton(grouped_collisions, emcclusters, perCollision_emc, fEMCCuts, nullptr, mcparticles, mccollisions); // } PresliceUnsorted perMcCollision = aod::emmcparticle::emmceventId; diff --git a/PWGEM/PhotonMeson/Tasks/TagAndProbe.cxx b/PWGEM/PhotonMeson/Tasks/TagAndProbe.cxx index 2f91a62dc43..17989065391 100644 --- a/PWGEM/PhotonMeson/Tasks/TagAndProbe.cxx +++ b/PWGEM/PhotonMeson/Tasks/TagAndProbe.cxx @@ -14,28 +14,47 @@ // This code is for data-driven efficiency for photon analyses. tag and probe method // Please write to: daiki.sekihata@cern.ch -#include -#include - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Math/Vector3D.h" -#include "Math/LorentzRotation.h" -#include "Math/Rotation3D.h" -#include "Math/AxisAngle.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "Common/Core/RecoDecay.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/PairCut.h" +#include "EMPhotonEventCut.h" + #include "PWGEM/PhotonMeson/Core/CutsLibrary.h" +#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" #include "PWGEM/PhotonMeson/Core/HistogramsLibrary.h" +#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" +#include "PWGEM/PhotonMeson/Core/PairCut.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" + +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include using namespace o2; using namespace o2::aod; @@ -126,7 +145,7 @@ struct TagAndProbe { THashList* list_pair_subsys_paircut = reinterpret_cast(list_pair_subsys_photoncut->FindObject(pair_cut_name.data())); o2::aod::pwgem::photon::histogram::DefineHistograms(list_pair_subsys_paircut, "tag_and_probe", pairname.data()); } // end of cut3 loop pair cut - } // end of cut2 loop + } // end of cut2 loop } static constexpr std::string_view pairnames[6] = {"PCMPCM", "PHOSPHOS", "EMCEMC", "PCMPHOS", "PCMEMC", "PHOSEMC"}; @@ -232,8 +251,8 @@ struct TagAndProbe { Preslice perCollision_phos = aod::skimmedcluster::collisionId; Preslice perCollision_emc = aod::skimmedcluster::collisionId; - template - void SameEventPairing(TEvents const& collisions, TPhotons1 const& photons1, TPhotons2 const& photons2, TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, TTagCut const& tagcut, TProbeCuts const& probecuts, TPairCuts const& paircuts, TLegs const& /*legs*/, TEMCMTs const& emcmatchedtracks) + template + void SameEventPairing(TEvents const& collisions, TPhotons1 const& photons1, TPhotons2 const& photons2, TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, TTagCut const& tagcut, TProbeCuts const& probecuts, TPairCuts const& paircuts, TLegs const& /*legs*/) { THashList* list_ev_pair_before = static_cast(fMainList->FindObject("Event")->FindObject(pairnames[pairtype].data())->FindObject(event_types[0].data())); THashList* list_ev_pair_after = static_cast(fMainList->FindObject("Event")->FindObject(pairnames[pairtype].data())->FindObject(event_types[1].data())); @@ -315,13 +334,13 @@ struct TagAndProbe { reinterpret_cast(list_pair_ss->FindObject(Form("%s_%s", tagcut.GetName(), probecut.GetName()))->FindObject(paircut.GetName())->FindObject("hMggPt_PassingProbe_Same"))->Fill(v12.M(), v2.Pt()); if constexpr (pairtype == PairType::kEMCEMC) { - RotationBackground(v12, v1, v2, photons2_coll, g1.globalIndex(), g2.globalIndex(), probecut, paircut, emcmatchedtracks); + RotationBackground(v12, v1, v2, photons2_coll, g1.globalIndex(), g2.globalIndex(), probecut, paircut); } } // end of probe cut loop - } // end of pair cut loop - } // end of g2 loop - } // end of g1 loop - } // end of collision loop + } // end of pair cut loop + } // end of g2 loop + } // end of g1 loop + } // end of collision loop } Configurable ndepth{"ndepth", 10, "depth for event mixing"}; @@ -334,8 +353,8 @@ struct TagAndProbe { BinningType_A colBinning_A{{ConfVtxBins, ConfCentBins}, true}; BinningType_C colBinning_C{{ConfVtxBins, ConfCentBins}, true}; - template - void MixedEventPairing(TEvents const& collisions, TPhotons1 const& photons1, TPhotons2 const& photons2, TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, TTagCut const& tagcut, TProbeCuts const& probecuts, TPairCuts const& paircuts, TLegs const& /*legs*/, TEMCMTs const& /*emcmatchedtracks*/, TMixedBinning const& colBinning) + template + void MixedEventPairing(TEvents const& collisions, TPhotons1 const& photons1, TPhotons2 const& photons2, TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, TTagCut const& tagcut, TProbeCuts const& probecuts, TPairCuts const& paircuts, TLegs const& /*legs*/, TMixedBinning const& colBinning) { THashList* list_pair_ss = static_cast(fMainList->FindObject("Pair")->FindObject(pairnames[pairtype].data())); @@ -406,15 +425,15 @@ struct TagAndProbe { reinterpret_cast(list_pair_ss->FindObject(Form("%s_%s", tagcut.GetName(), probecut.GetName()))->FindObject(paircut.GetName())->FindObject("hMggPt_PassingProbe_Mixed"))->Fill(v12.M(), v2.Pt()); } // end of probe cut loop - } // end of pair cut loop - } // end of g2 loop - } // end of g1 loop - } // end of different collision combinations + } // end of pair cut loop + } // end of g2 loop + } // end of g1 loop + } // end of different collision combinations } /// \brief Calculate background (using rotation background method only for EMCal!) template - void RotationBackground(const ROOT::Math::PtEtaPhiMVector& meson, ROOT::Math::PtEtaPhiMVector photon1, ROOT::Math::PtEtaPhiMVector photon2, TPhotons const& photons_coll, unsigned int ig1, unsigned int ig2, EMCPhotonCut const& cut, PairCut const& paircut, SkimEMCMTs const& /*emcmatchedtracks*/) + void RotationBackground(const ROOT::Math::PtEtaPhiMVector& meson, ROOT::Math::PtEtaPhiMVector photon1, ROOT::Math::PtEtaPhiMVector photon2, TPhotons const& photons_coll, unsigned int ig1, unsigned int ig2, EMCPhotonCut const& cut, PairCut const& paircut) { // if less than 3 clusters are present skip event since we need at least 3 clusters if (photons_coll.size() < 3) { @@ -442,7 +461,7 @@ struct TagAndProbe { // only combine rotated photons with other photons continue; } - if (!cut.template IsSelected(photon)) { + if (!cut.template IsSelected(photon)) { continue; } @@ -474,32 +493,32 @@ struct TagAndProbe { } Partition grouped_collisions = cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax; // this goes to same event. - Filter collisionFilter_common = nabs(o2::aod::collision::posZ) < 10.f && o2::aod::collision::numContrib > (uint16_t)0 && o2::aod::evsel::sel8 == true; + Filter collisionFilter_common = nabs(o2::aod::collision::posZ) < 10.f && o2::aod::collision::numContrib > static_cast(0) && o2::aod::evsel::sel8 == true; Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); using MyFilteredCollisions = soa::Filtered; // this goes to mixed event. void processPCMPCM(MyCollisions const&, MyFilteredCollisions const& filtered_collisions, MyV0Photons const& v0photons, aod::V0Legs const& legs) { - SameEventPairing(grouped_collisions, v0photons, v0photons, perCollision, perCollision, fTagPCMCut, fProbePCMCuts, fPairCuts, legs, nullptr); + SameEventPairing(grouped_collisions, v0photons, v0photons, perCollision, perCollision, fTagPCMCut, fProbePCMCuts, fPairCuts, legs); if (cfgCentEstimator == 0) { - MixedEventPairing(filtered_collisions, v0photons, v0photons, perCollision, perCollision, fTagPCMCut, fProbePCMCuts, fPairCuts, legs, nullptr, colBinning_M); + MixedEventPairing(filtered_collisions, v0photons, v0photons, perCollision, perCollision, fTagPCMCut, fProbePCMCuts, fPairCuts, legs, colBinning_M); } else if (cfgCentEstimator == 1) { - MixedEventPairing(filtered_collisions, v0photons, v0photons, perCollision, perCollision, fTagPCMCut, fProbePCMCuts, fPairCuts, legs, nullptr, colBinning_A); + MixedEventPairing(filtered_collisions, v0photons, v0photons, perCollision, perCollision, fTagPCMCut, fProbePCMCuts, fPairCuts, legs, colBinning_A); } else if (cfgCentEstimator == 2) { - MixedEventPairing(filtered_collisions, v0photons, v0photons, perCollision, perCollision, fTagPCMCut, fProbePCMCuts, fPairCuts, legs, nullptr, colBinning_C); + MixedEventPairing(filtered_collisions, v0photons, v0photons, perCollision, perCollision, fTagPCMCut, fProbePCMCuts, fPairCuts, legs, colBinning_C); } } void processPHOSPHOS(MyCollisions const&, MyFilteredCollisions const& filtered_collisions, aod::PHOSClusters const& phosclusters) { - SameEventPairing(grouped_collisions, phosclusters, phosclusters, perCollision_phos, perCollision_phos, fTagPHOSCut, fProbePHOSCuts, fPairCuts, nullptr, nullptr); - MixedEventPairing(filtered_collisions, phosclusters, phosclusters, perCollision_phos, perCollision_phos, fTagPHOSCut, fProbePHOSCuts, fPairCuts, nullptr, nullptr, colBinning_C); + SameEventPairing(grouped_collisions, phosclusters, phosclusters, perCollision_phos, perCollision_phos, fTagPHOSCut, fProbePHOSCuts, fPairCuts, nullptr); + MixedEventPairing(filtered_collisions, phosclusters, phosclusters, perCollision_phos, perCollision_phos, fTagPHOSCut, fProbePHOSCuts, fPairCuts, nullptr, colBinning_C); } - void processEMCEMC(MyCollisions const&, MyFilteredCollisions const& filtered_collisions, aod::SkimEMCClusters const& emcclusters, aod::SkimEMCMTs const& emcmatchedtracks) + void processEMCEMC(MyCollisions const&, MyFilteredCollisions const& filtered_collisions, aod::SkimEMCClusters const& emcclusters) { - SameEventPairing(grouped_collisions, emcclusters, emcclusters, perCollision_emc, perCollision_emc, fTagEMCCut, fProbeEMCCuts, fPairCuts, nullptr, emcmatchedtracks); - MixedEventPairing(filtered_collisions, emcclusters, emcclusters, perCollision_emc, perCollision_emc, fTagEMCCut, fProbeEMCCuts, fPairCuts, nullptr, emcmatchedtracks, colBinning_C); + SameEventPairing(grouped_collisions, emcclusters, emcclusters, perCollision_emc, perCollision_emc, fTagEMCCut, fProbeEMCCuts, fPairCuts, nullptr); + MixedEventPairing(filtered_collisions, emcclusters, emcclusters, perCollision_emc, perCollision_emc, fTagEMCCut, fProbeEMCCuts, fPairCuts, nullptr, colBinning_C); } void processDummy(MyCollisions const&) {} diff --git a/PWGEM/PhotonMeson/Tasks/TaggingPi0.cxx b/PWGEM/PhotonMeson/Tasks/TaggingPi0.cxx deleted file mode 100644 index 4d00ddb1a21..00000000000 --- a/PWGEM/PhotonMeson/Tasks/TaggingPi0.cxx +++ /dev/null @@ -1,585 +0,0 @@ -// 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. -// -// ======================== -// -// This code runs loop over photons with PCM and PHOS for direct photon analysis. -// Please write to: daiki.sekihata@cern.ch - -#include -#include - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "Common/Core/RecoDecay.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" - -#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" -#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/PairCut.h" -#include "PWGEM/PhotonMeson/Core/CutsLibrary.h" -#include "PWGEM/PhotonMeson/Core/HistogramsLibrary.h" - -using namespace o2; -using namespace o2::aod; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::soa; -using namespace o2::aod::pwgem::photonmeson::photonpair; -using namespace o2::aod::pwgem::photon; - -using MyCollisions = soa::Join; -using MyCollision = MyCollisions::iterator; - -using MyV0Photons = soa::Join; -using MyV0Photon = MyV0Photons::iterator; - -using MyDalitzEEs = soa::Join; -using MyDalitzEE = MyDalitzEEs::iterator; - -using MyPrimaryElectrons = soa::Join; -using MyPrimaryElectron = MyPrimaryElectrons::iterator; - -struct TaggingPi0 { - - // Configurables - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; - Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; - - Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; - Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; - Configurable cfgCentMax{"cfgCentMax", 999, "max. centrality"}; - - // Configurable maxY{"maxY", 0.9, "maximum rapidity for reconstructed particles"}; - Configurable fConfigPCMCuts{"cfgPCMCuts", "qc", "Comma separated list of V0 photon cuts"}; - Configurable fConfigDalitzEECuts{"cfgDalitzEECuts", "mee_0_120_tpchadrejortofreq,mee_0_120_tpchadrejortofreq_lowB", "Comma separated list of Dalitz ee cuts"}; - Configurable fConfigPHOSCuts{"cfgPHOSCuts", "test02,test03", "Comma separated list of PHOS photon cuts"}; - Configurable fConfigEMCCuts{"cfgEMCCuts", "standard", "Comma separated list of EMCal photon cuts"}; - Configurable fConfigPairCuts{"cfgPairCuts", "nocut", "Comma separated list of pair cuts"}; - - // Configurable for EMCal cuts - Configurable EMC_minTime{"EMC_minTime", -20., "Minimum cluster time for EMCal time cut"}; - Configurable EMC_maxTime{"EMC_maxTime", +25., "Maximum cluster time for EMCal time cut"}; - Configurable EMC_minM02{"EMC_minM02", 0.1, "Minimum M02 for EMCal M02 cut"}; - Configurable EMC_maxM02{"EMC_maxM02", 0.7, "Maximum M02 for EMCal M02 cut"}; - Configurable EMC_minE{"EMC_minE", 0.7, "Minimum cluster energy for EMCal energy cut"}; - Configurable EMC_minNCell{"EMC_minNCell", 1, "Minimum number of cells per cluster for EMCal NCell cut"}; - Configurable> EMC_TM_Eta{"EMC_TM_Eta", {0.01f, 4.07f, -2.5f}, "|eta| <= [0]+(pT+[1])^[2] for EMCal track matching"}; - Configurable> EMC_TM_Phi{"EMC_TM_Phi", {0.015f, 3.65f, -2.f}, "|phi| <= [0]+(pT+[1])^[2] for EMCal track matching"}; - Configurable EMC_Eoverp{"EMC_Eoverp", 1.75, "Minimum cluster energy over track momentum for EMCal track matching"}; - Configurable EMC_UseExoticCut{"EMC_UseExoticCut", true, "FLag to use the EMCal exotic cluster cut"}; - - Configurable fConfigEMEventCut{"cfgEMEventCut", "minbias", "em event cut"}; // only 1 event cut per wagon - EMPhotonEventCut fEMEventCut; - static constexpr std::string_view event_types[2] = {"before", "after"}; - - OutputObj fOutputEvent{"Event"}; - OutputObj fOutputPair{"Pair"}; // 2-photon pair - THashList* fMainList = new THashList(); - - std::vector fPCMCuts; - std::vector fDalitzEECuts; - std::vector fPHOSCuts; - std::vector fEMCCuts; - std::vector fPairCuts; - - std::vector fPairNames; - - Service ccdb; - int mRunNumber; - float d_bz; - - void init(InitContext& context) - { - if (context.mOptions.get("processPCMDalitzEE")) { - fPairNames.push_back("PCMDalitzEE"); - } - if (context.mOptions.get("processPCMPHOS")) { - fPairNames.push_back("PCMPHOS"); - } - if (context.mOptions.get("processPCMEMC")) { - fPairNames.push_back("PCMEMC"); - } - - DefinePCMCuts(); - DefineDalitzEECuts(); - DefinePHOSCuts(); - DefineEMCCuts(); - DefinePairCuts(); - addhistograms(); - TString ev_cut_name = fConfigEMEventCut.value; - fEMEventCut = *eventcuts::GetCut(ev_cut_name.Data()); - - fOutputEvent.setObject(reinterpret_cast(fMainList->FindObject("Event"))); - fOutputPair.setObject(reinterpret_cast(fMainList->FindObject("Pair"))); - - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - } - - template - void initCCDB(TCollision const& collision) - { - if (mRunNumber == collision.runNumber()) { - return; - } - - // In case override, don't proceed, please - no CCDB access required - if (d_bz_input > -990) { - d_bz = d_bz_input; - o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { - grpmag.setL3Current(30000.f / (d_bz / 5.0f)); - } - mRunNumber = collision.runNumber(); - return; - } - - auto run3grp_timestamp = collision.timestamp(); - o2::parameters::GRPObject* grpo = 0x0; - o2::parameters::GRPMagField* grpmag = 0x0; - if (!skipGRPOquery) - grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); - if (grpo) { - // Fetch magnetic field from ccdb for current collision - d_bz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); - if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; - } - // Fetch magnetic field from ccdb for current collision - d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } - mRunNumber = collision.runNumber(); - } - - template - void add_pair_histograms(THashList* list_pair, const std::string pairname, TCuts1 const& cuts1, TCuts2 const& cuts2, TCuts3 const& cuts3) - { - for (auto& cut1 : cuts1) { - for (auto& cut2 : cuts2) { - std::string cutname1 = cut1.GetName(); - std::string cutname2 = cut2.GetName(); - - if ((pairname == "PCMPCM" || pairname == "PHOSPHOS" || pairname == "EMCEMC") && (cutname1 != cutname2)) - continue; - - THashList* list_pair_subsys = reinterpret_cast(list_pair->FindObject(pairname.data())); - std::string photon_cut_name = cutname1 + "_" + cutname2; - o2::aod::pwgem::photon::histogram::AddHistClass(list_pair_subsys, photon_cut_name.data()); - THashList* list_pair_subsys_photoncut = reinterpret_cast(list_pair_subsys->FindObject(photon_cut_name.data())); - - for (auto& cut3 : cuts3) { - std::string pair_cut_name = cut3.GetName(); - o2::aod::pwgem::photon::histogram::AddHistClass(list_pair_subsys_photoncut, pair_cut_name.data()); - THashList* list_pair_subsys_paircut = reinterpret_cast(list_pair_subsys_photoncut->FindObject(pair_cut_name.data())); - o2::aod::pwgem::photon::histogram::DefineHistograms(list_pair_subsys_paircut, "tagging_pi0"); - } // end of cut3 loop - } // end of cut2 loop - } // end of cut1 loop - } - - static constexpr std::string_view pairnames[9] = {"PCMPCM", "PHOSPHOS", "EMCEMC", "PCMPHOS", "PCMEMC", "PCMDalitzEE", "PCMDalitzMuMu", "PHOSEMC", "DalitzEEDalitzEE"}; - void addhistograms() - { - fMainList->SetOwner(true); - fMainList->SetName("fMainList"); - - // create sub lists first. - o2::aod::pwgem::photon::histogram::AddHistClass(fMainList, "Event"); - THashList* list_ev = reinterpret_cast(fMainList->FindObject("Event")); - - o2::aod::pwgem::photon::histogram::AddHistClass(fMainList, "Pair"); - THashList* list_pair = reinterpret_cast(fMainList->FindObject("Pair")); - - for (auto& pairname : fPairNames) { - LOGF(info, "Enabled pairs = %s", pairname.data()); - - THashList* list_ev_pair = reinterpret_cast(o2::aod::pwgem::photon::histogram::AddHistClass(list_ev, pairname.data())); - for (const auto& evtype : event_types) { - THashList* list_ev_type = reinterpret_cast(o2::aod::pwgem::photon::histogram::AddHistClass(list_ev_pair, evtype.data())); - o2::aod::pwgem::photon::histogram::DefineHistograms(list_ev_type, "Event", evtype.data()); - } - - o2::aod::pwgem::photon::histogram::AddHistClass(list_pair, pairname.data()); - - if (pairname == "PCMPHOS") { - add_pair_histograms(list_pair, pairname, fPCMCuts, fPHOSCuts, fPairCuts); - } - if (pairname == "PCMEMC") { - add_pair_histograms(list_pair, pairname, fPCMCuts, fEMCCuts, fPairCuts); - } - if (pairname == "PCMDalitzEE") { - add_pair_histograms(list_pair, pairname, fPCMCuts, fDalitzEECuts, fPairCuts); - } - - } // end of pair name loop - } - - void DefinePCMCuts() - { - TString cutNamesStr = fConfigPCMCuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - fPCMCuts.push_back(*pcmcuts::GetCut(cutname)); - } - } - LOGF(info, "Number of PCM cuts = %d", fPCMCuts.size()); - } - - void DefineDalitzEECuts() - { - TString cutNamesStr = fConfigDalitzEECuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - fDalitzEECuts.push_back(*dalitzeecuts::GetCut(cutname)); - } - } - LOGF(info, "Number of DalitzEE cuts = %d", fDalitzEECuts.size()); - } - - void DefinePHOSCuts() - { - TString cutNamesStr = fConfigPHOSCuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - fPHOSCuts.push_back(*phoscuts::GetCut(cutname)); - } - } - LOGF(info, "Number of PHOS cuts = %d", fPHOSCuts.size()); - } - - void DefineEMCCuts() - { - const float a = EMC_TM_Eta->at(0); - const float b = EMC_TM_Eta->at(1); - const float c = EMC_TM_Eta->at(2); - - const float d = EMC_TM_Phi->at(0); - const float e = EMC_TM_Phi->at(1); - const float f = EMC_TM_Phi->at(2); - LOGF(info, "EMCal track matching parameters : a = %f, b = %f, c = %f, d = %f, e = %f, f = %f", a, b, c, d, e, f); - - TString cutNamesStr = fConfigEMCCuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - if (std::strcmp(cutname, "custom") == 0) { - EMCPhotonCut* custom_cut = new EMCPhotonCut(cutname, cutname); - custom_cut->SetMinE(EMC_minE); - custom_cut->SetMinNCell(EMC_minNCell); - custom_cut->SetM02Range(EMC_minM02, EMC_maxM02); - custom_cut->SetTimeRange(EMC_minTime, EMC_maxTime); - - custom_cut->SetTrackMatchingEta([a, b, c](float pT) { - return a + pow(pT + b, c); - }); - custom_cut->SetTrackMatchingPhi([d, e, f](float pT) { - return d + pow(pT + e, f); - }); - - custom_cut->SetMinEoverP(EMC_Eoverp); - custom_cut->SetUseExoticCut(EMC_UseExoticCut); - fEMCCuts.push_back(*custom_cut); - } else { - fEMCCuts.push_back(*emccuts::GetCut(cutname)); - } - } - } - LOGF(info, "Number of EMCal cuts = %d", fEMCCuts.size()); - } - - void DefinePairCuts() - { - TString cutNamesStr = fConfigPairCuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - fPairCuts.push_back(*paircuts::GetCut(cutname)); - } - } - LOGF(info, "Number of Pair cuts = %d", fPairCuts.size()); - } - - template - bool IsSelectedPair(TG1 const& g1, TG2 const& g2, TCut1 const& cut1, TCut2 const& cut2) - { - bool is_selected_pair = false; - if constexpr (pairtype == PairType::kPCMPHOS) { - is_selected_pair = o2::aod::pwgem::photonmeson::photonpair::IsSelectedPair(g1, g2, cut1, cut2); - } else if constexpr (pairtype == PairType::kPCMEMC) { - is_selected_pair = o2::aod::pwgem::photonmeson::photonpair::IsSelectedPair(g1, g2, cut1, cut2); - } else if constexpr (pairtype == PairType::kPCMDalitzEE) { - is_selected_pair = o2::aod::pwgem::photonmeson::photonpair::IsSelectedPair(g1, g2, cut1, cut2); - } else { - is_selected_pair = true; - } - return is_selected_pair; - } - - template - void SameEventPairing(TEvents const& collisions, TPhotons1 const& photons1, TPhotons2 const& photons2, TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, TCuts1 const& cuts1, TCuts2 const& cuts2, TPairCuts const& paircuts, TLegs const& /*legs*/, TEMPrimaryElectrons const& /*emprimaryelectrons*/) - { - THashList* list_ev_pair_before = static_cast(fMainList->FindObject("Event")->FindObject(pairnames[pairtype].data())->FindObject(event_types[0].data())); - THashList* list_ev_pair_after = static_cast(fMainList->FindObject("Event")->FindObject(pairnames[pairtype].data())->FindObject(event_types[1].data())); - THashList* list_pair_ss = static_cast(fMainList->FindObject("Pair")->FindObject(pairnames[pairtype].data())); - - for (auto& collision : collisions) { - initCCDB(collision); - if ((pairtype == kPHOSPHOS || pairtype == kPCMPHOS) && !collision.alias_bit(triggerAliases::kTVXinPHOS)) { - continue; - } - if ((pairtype == kEMCEMC || pairtype == kPCMEMC) && !collision.alias_bit(triggerAliases::kTVXinEMC)) { - continue; - } - - const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - o2::aod::pwgem::photon::histogram::FillHistClass(list_ev_pair_before, "", collision); - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - o2::aod::pwgem::photon::histogram::FillHistClass(list_ev_pair_after, "", collision); - reinterpret_cast(list_ev_pair_before->FindObject("hCollisionCounter"))->Fill("accepted", 1.f); - reinterpret_cast(list_ev_pair_after->FindObject("hCollisionCounter"))->Fill("accepted", 1.f); - - auto photons1_coll = photons1.sliceBy(perCollision1, collision.globalIndex()); - auto photons2_coll = photons2.sliceBy(perCollision2, collision.globalIndex()); - - for (auto& cut1 : cuts1) { - for (auto& cut2 : cuts2) { - for (auto& paircut : paircuts) { - for (auto& [g1, g2] : combinations(CombinationsFullIndexPolicy(photons1_coll, photons2_coll))) { - - if constexpr (pairtype == PairType::kPCMDalitzEE) { - auto pos_pv = g2.template posTrack_as(); - auto ele_pv = g2.template negTrack_as(); - std::tuple pair2 = std::make_tuple(pos_pv, ele_pv, d_bz); - if (!IsSelectedPair(g1, pair2, cut1, cut2)) { - continue; - } - } else { - if (!IsSelectedPair(g1, g2, cut1, cut2)) { - continue; - } - } - - if (!paircut.IsSelected(g1, g2)) { - continue; - } - - if constexpr (pairtype == PairType::kPCMPHOS || pairtype == PairType::kPCMEMC) { - auto pos = g1.template posTrack_as(); - auto ele = g1.template negTrack_as(); - if constexpr (pairtype == PairType::kPCMPHOS) { - if (o2::aod::pwgem::photonmeson::photonpair::DoesV0LegMatchWithCluster(pos, g2, 0.02, 0.4, 0.2) || o2::aod::pwgem::photonmeson::photonpair::DoesV0LegMatchWithCluster(ele, g2, 0.02, 0.4, 0.2)) { - continue; - } - } else if constexpr (pairtype == PairType::kPCMEMC) { - if (o2::aod::pwgem::photonmeson::photonpair::DoesV0LegMatchWithCluster(pos, g2, 0.02, 0.4, 0.5) || o2::aod::pwgem::photonmeson::photonpair::DoesV0LegMatchWithCluster(ele, g2, 0.02, 0.4, 0.5)) { - continue; - } - } - } - ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); // pcm - ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); // phos or emc or dalitzee - if constexpr (pairtype == PairType::kPCMDalitzEE) { - v2.SetM(g2.mass()); - } - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - // if (abs(v12.Rapidity()) > maxY) { - // continue; - // } - reinterpret_cast(list_pair_ss->FindObject(Form("%s_%s", cut1.GetName(), cut2.GetName()))->FindObject(paircut.GetName())->FindObject("hMggPt_Same"))->Fill(v12.M(), v1.Pt()); - } // end of combination - } // end of pair cut loop - } // end of cut2 loop - } // end of cut1 loop - } // end of collision loop - } - - Configurable ndepth{"ndepth", 10, "depth for event mixing"}; - ConfigurableAxis ConfVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; - ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 999.f}, "Mixing bins - centrality"}; - using BinningType_M = ColumnBinningPolicy; - using BinningType_A = ColumnBinningPolicy; - using BinningType_C = ColumnBinningPolicy; - BinningType_M colBinning_M{{ConfVtxBins, ConfCentBins}, true}; - BinningType_A colBinning_A{{ConfVtxBins, ConfCentBins}, true}; - BinningType_C colBinning_C{{ConfVtxBins, ConfCentBins}, true}; - - template - void MixedEventPairing(TEvents const& collisions, TPhotons1 const& photons1, TPhotons2 const& photons2, TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, TCuts1 const& cuts1, TCuts2 const& cuts2, TPairCuts const& paircuts, TLegs const& /*legs*/, TEMPrimaryElectrons const& /*emprimaryelectrons*/, TMixedBinning const& colBinning) - { - THashList* list_pair_ss = static_cast(fMainList->FindObject("Pair")->FindObject(pairnames[pairtype].data())); - - // LOGF(info, "Number of collisions after filtering: %d", collisions.size()); - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, ndepth, -1, collisions, collisions)) { // internally, CombinationsStrictlyUpperIndexPolicy(collisions, collisions) is called. - - const float centralities1[3] = {collision1.centFT0M(), collision1.centFT0A(), collision1.centFT0C()}; - const float centralities2[3] = {collision2.centFT0M(), collision2.centFT0A(), collision2.centFT0C()}; - - if (centralities1[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities1[cfgCentEstimator]) { - continue; - } - if (centralities2[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities2[cfgCentEstimator]) { - continue; - } - if (!fEMEventCut.IsSelected(collision1) || !fEMEventCut.IsSelected(collision2)) { - continue; - } - - auto photons_coll1 = photons1.sliceBy(perCollision1, collision1.globalIndex()); - auto photons_coll2 = photons2.sliceBy(perCollision2, collision2.globalIndex()); - // LOGF(info, "collision1: posZ = %f, numContrib = %d , sel8 = %d | collision2: posZ = %f, numContrib = %d , sel8 = %d", - // collision1.posZ(), collision1.numContrib(), collision1.sel8(), collision2.posZ(), collision2.numContrib(), collision2.sel8()); - - for (auto& cut1 : cuts1) { - for (auto& cut2 : cuts2) { - for (auto& paircut : paircuts) { - for (auto& [g1, g2] : combinations(soa::CombinationsFullIndexPolicy(photons_coll1, photons_coll2))) { - // LOGF(info, "Mixed event photon pair: (%d, %d) from events (%d, %d), photon event: (%d, %d)", g1.index(), g2.index(), collision1.index(), collision2.index(), g1.globalIndex(), g2.globalIndex()); - - if ((pairtype == PairType::kPCMPCM || pairtype == PairType::kPHOSPHOS || pairtype == PairType::kEMCEMC) && (TString(cut1.GetName()) != TString(cut2.GetName()))) { - continue; - } - - if constexpr (pairtype == PairType::kPCMDalitzEE) { - auto pos_pv = g2.template posTrack_as(); - auto ele_pv = g2.template negTrack_as(); - std::tuple pair2 = std::make_tuple(pos_pv, ele_pv, d_bz); - if (!IsSelectedPair(g1, pair2, cut1, cut2)) { - continue; - } - } else { - if (!IsSelectedPair(g1, g2, cut1, cut2)) { - continue; - } - } - - if (!paircut.IsSelected(g1, g2)) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); // pcm - ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); // phos or emc or dalitzee - if constexpr (pairtype == PairType::kPCMDalitzEE) { - v2.SetM(g2.mass()); - auto pos_sv = g1.template posTrack_as(); - auto ele_sv = g1.template negTrack_as(); - auto pos_pv = g2.template posTrack_as(); - auto ele_pv = g2.template negTrack_as(); - if (pos_sv.trackId() == pos_pv.trackId() || ele_sv.trackId() == ele_pv.trackId()) { - continue; - } - } - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - // if (abs(v12.Rapidity()) > maxY) { - // continue; - // } - reinterpret_cast(list_pair_ss->FindObject(Form("%s_%s", cut1.GetName(), cut2.GetName()))->FindObject(paircut.GetName())->FindObject("hMggPt_Mixed"))->Fill(v12.M(), v1.Pt()); - - } // end of different photon combinations - } // end of pair cut loop - } // end of cut2 loop - } // end of cut1 loop - } // end of different collision combinations - } - - Partition grouped_collisions = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); // this goes to same event. - Filter collisionFilter_common = nabs(o2::aod::collision::posZ) < 10.f && o2::aod::collision::numContrib > (uint16_t)0 && o2::aod::evsel::sel8 == true; - Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); - using MyFilteredCollisions = soa::Filtered; - - Filter DalitzEEFilter = o2::aod::dalitzee::sign == 0; // analyze only uls - using MyFilteredDalitzEEs = soa::Filtered; - - Preslice perCollision_pcm = aod::v0photonkf::emeventId; - Preslice perCollision_dalitz = aod::dalitzee::emeventId; - Preslice perCollision_phos = aod::skimmedcluster::collisionId; - Preslice perCollision_emc = aod::skimmedcluster::collisionId; - - void processPCMDalitzEE(MyCollisions const&, MyFilteredCollisions const& filtered_collisions, MyV0Photons const& v0photons, aod::V0Legs const& legs, MyFilteredDalitzEEs const& dielectrons, MyPrimaryElectrons const& emprimaryelectrons) - { - SameEventPairing(grouped_collisions, v0photons, dielectrons, perCollision_pcm, perCollision_dalitz, fPCMCuts, fDalitzEECuts, fPairCuts, legs, emprimaryelectrons); - if (cfgCentEstimator == 0) { - MixedEventPairing(filtered_collisions, v0photons, dielectrons, perCollision_pcm, perCollision_dalitz, fPCMCuts, fDalitzEECuts, fPairCuts, legs, emprimaryelectrons, colBinning_M); - } else if (cfgCentEstimator == 1) { - MixedEventPairing(filtered_collisions, v0photons, dielectrons, perCollision_pcm, perCollision_dalitz, fPCMCuts, fDalitzEECuts, fPairCuts, legs, emprimaryelectrons, colBinning_A); - } else if (cfgCentEstimator == 2) { - MixedEventPairing(filtered_collisions, v0photons, dielectrons, perCollision_pcm, perCollision_dalitz, fPCMCuts, fDalitzEECuts, fPairCuts, legs, emprimaryelectrons, colBinning_C); - } - } - - void processPCMPHOS(MyCollisions const&, MyFilteredCollisions const& filtered_collisions, MyV0Photons const& v0photons, aod::PHOSClusters const& phosclusters, aod::V0Legs const& legs) - { - SameEventPairing(grouped_collisions, v0photons, phosclusters, perCollision_pcm, perCollision_phos, fPCMCuts, fPHOSCuts, fPairCuts, legs, nullptr); - MixedEventPairing(filtered_collisions, v0photons, phosclusters, perCollision_pcm, perCollision_phos, fPCMCuts, fPHOSCuts, fPairCuts, legs, nullptr, colBinning_C); - } - - void processPCMEMC(MyCollisions const&, MyFilteredCollisions const& filtered_collisions, MyV0Photons const& v0photons, aod::SkimEMCClusters const& emcclusters, aod::V0Legs const& legs) - { - SameEventPairing(grouped_collisions, v0photons, emcclusters, perCollision_pcm, perCollision_emc, fPCMCuts, fEMCCuts, fPairCuts, legs, nullptr); - MixedEventPairing(filtered_collisions, v0photons, emcclusters, perCollision_pcm, perCollision_emc, fPCMCuts, fEMCCuts, fPairCuts, legs, nullptr, colBinning_C); - } - - void processDummy(MyCollisions const&) {} - - PROCESS_SWITCH(TaggingPi0, processPCMDalitzEE, "pairing PCM-Dalitz", false); - PROCESS_SWITCH(TaggingPi0, processPCMPHOS, "pairing PCM-PHOS", false); - PROCESS_SWITCH(TaggingPi0, processPCMEMC, "pairing PCM-EMCal", false); - PROCESS_SWITCH(TaggingPi0, processDummy, "Dummy function", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"tagging-pi0"})}; -} diff --git a/PWGEM/PhotonMeson/Tasks/TaggingPi0MC.cxx b/PWGEM/PhotonMeson/Tasks/TaggingPi0MC.cxx deleted file mode 100644 index 335e8195d8b..00000000000 --- a/PWGEM/PhotonMeson/Tasks/TaggingPi0MC.cxx +++ /dev/null @@ -1,589 +0,0 @@ -// 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. -// -// ======================== -// -// This code runs loop over photons with PCM and PHOS for direct photon analysis. -// Please write to: daiki.sekihata@cern.ch - -#include -#include - -#include "TString.h" -#include "Math/Vector4D.h" - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" - -#include "Common/Core/RecoDecay.h" -#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" -#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" -#include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/PairCut.h" -#include "PWGEM/PhotonMeson/Core/CutsLibrary.h" -#include "PWGEM/PhotonMeson/Core/HistogramsLibrary.h" -#include "PWGEM/Dilepton/Utils/MCUtilities.h" - -using namespace o2; -using namespace o2::aod; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::soa; -using namespace o2::aod::pwgem::photonmeson::photonpair; -using namespace o2::aod::pwgem::photonmeson::utils::mcutil; -using namespace o2::aod::pwgem::dilepton::utils::mcutil; -using namespace o2::aod::pwgem::photon; - -using MyCollisions = soa::Join; -using MyCollision = MyCollisions::iterator; - -using MyV0Photons = soa::Join; -using MyV0Photon = MyV0Photons::iterator; - -using MyDalitzEEs = soa::Join; -using MyDalitzEE = MyDalitzEEs::iterator; - -struct TaggingPi0MC { - using MyMCV0Legs = soa::Join; - using MyMCTracks = soa::Join; - using MyMCTrack = MyMCTracks::iterator; - - // Configurables - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; - Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; - - Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; - Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; - Configurable cfgCentMax{"cfgCentMax", 999, "max. centrality"}; - - Configurable maxY{"maxY", 0.9, "maximum rapidity for reconstructed particles"}; - Configurable maxRgen{"maxRgen", 90.f, "maximum radius for generated particles"}; - Configurable margin_z_mc{"margin_z_mc", 7.0, "margin for z cut in cm for MC"}; - - Configurable fConfigPCMCuts{"cfgPCMCuts", "qc", "Comma separated list of V0 photon cuts"}; - Configurable fConfigDalitzEECuts{"cfgDalitzEECuts", "mee_0_120_tpchadrejortofreq,mee_0_120_tpchadrejortofreq_lowB", "Comma separated list of Dalitz ee cuts"}; - Configurable fConfigPHOSCuts{"cfgPHOSCuts", "test02,test03", "Comma separated list of PHOS photon cuts"}; - Configurable fConfigEMCCuts{"fConfigEMCCuts", "standard", "Comma separated list of EMCal photon cuts"}; - Configurable fConfigPairCuts{"cfgPairCuts", "nocut", "Comma separated list of pair cuts"}; - - // Configurable for EMCal cuts - Configurable EMC_minTime{"EMC_minTime", -20., "Minimum cluster time for EMCal time cut"}; - Configurable EMC_maxTime{"EMC_maxTime", +25., "Maximum cluster time for EMCal time cut"}; - Configurable EMC_minM02{"EMC_minM02", 0.1, "Minimum M02 for EMCal M02 cut"}; - Configurable EMC_maxM02{"EMC_maxM02", 0.7, "Maximum M02 for EMCal M02 cut"}; - Configurable EMC_minE{"EMC_minE", 0.7, "Minimum cluster energy for EMCal energy cut"}; - Configurable EMC_minNCell{"EMC_minNCell", 1, "Minimum number of cells per cluster for EMCal NCell cut"}; - Configurable> EMC_TM_Eta{"EMC_TM_Eta", {0.01f, 4.07f, -2.5f}, "|eta| <= [0]+(pT+[1])^[2] for EMCal track matching"}; - Configurable> EMC_TM_Phi{"EMC_TM_Phi", {0.015f, 3.65f, -2.f}, "|phi| <= [0]+(pT+[1])^[2] for EMCal track matching"}; - Configurable EMC_Eoverp{"EMC_Eoverp", 1.75, "Minimum cluster energy over track momentum for EMCal track matching"}; - Configurable EMC_UseExoticCut{"EMC_UseExoticCut", true, "FLag to use the EMCal exotic cluster cut"}; - - Configurable fConfigEMEventCut{"cfgEMEventCut", "minbias", "em event cut"}; // only 1 event cut per wagon - EMPhotonEventCut fEMEventCut; - static constexpr std::string_view event_types[2] = {"before", "after"}; - - OutputObj fOutputEvent{"Event"}; - OutputObj fOutputPair{"Pair"}; // 2-photon pair - OutputObj fOutputPCM{"PCM"}; // v0-photon - THashList* fMainList = new THashList(); - - std::vector fPCMCuts; - std::vector fDalitzEECuts; - std::vector fPHOSCuts; - std::vector fEMCCuts; - std::vector fPairCuts; - - std::vector fPairNames; - - Service ccdb; - int mRunNumber; - float d_bz; - - void init(InitContext& context) - { - if (context.mOptions.get("processPCMDalitzEE")) { - fPairNames.push_back("PCMDalitzEE"); - } - if (context.mOptions.get("processPCMPHOS")) { - fPairNames.push_back("PCMPHOS"); - } - if (context.mOptions.get("processPCMEMC")) { - fPairNames.push_back("PCMEMC"); - } - - DefinePCMCuts(); - DefineDalitzEECuts(); - DefinePHOSCuts(); - DefineEMCCuts(); - DefinePairCuts(); - addhistograms(); - TString ev_cut_name = fConfigEMEventCut.value; - fEMEventCut = *eventcuts::GetCut(ev_cut_name.Data()); - - fOutputEvent.setObject(reinterpret_cast(fMainList->FindObject("Event"))); - fOutputPair.setObject(reinterpret_cast(fMainList->FindObject("Pair"))); - fOutputPCM.setObject(reinterpret_cast(fMainList->FindObject("PCM"))); - - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - } - - template - void initCCDB(TCollision const& collision) - { - if (mRunNumber == collision.runNumber()) { - return; - } - - // In case override, don't proceed, please - no CCDB access required - if (d_bz_input > -990) { - d_bz = d_bz_input; - o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { - grpmag.setL3Current(30000.f / (d_bz / 5.0f)); - } - mRunNumber = collision.runNumber(); - return; - } - - auto run3grp_timestamp = collision.timestamp(); - o2::parameters::GRPObject* grpo = 0x0; - o2::parameters::GRPMagField* grpmag = 0x0; - if (!skipGRPOquery) - grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); - if (grpo) { - // Fetch magnetic field from ccdb for current collision - d_bz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); - if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; - } - // Fetch magnetic field from ccdb for current collision - d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } - mRunNumber = collision.runNumber(); - } - - template - void add_pair_histograms(THashList* list_pair, const std::string pairname, TCuts1 const& cuts1, TCuts2 const& cuts2, TCuts3 const& cuts3) - { - for (auto& cut1 : cuts1) { - for (auto& cut2 : cuts2) { - std::string cutname1 = cut1.GetName(); - std::string cutname2 = cut2.GetName(); - - if ((pairname == "PCMPCM" || pairname == "PHOSPHOS" || pairname == "EMCEMC") && (cutname1 != cutname2)) - continue; - - THashList* list_pair_subsys = reinterpret_cast(list_pair->FindObject(pairname.data())); - std::string photon_cut_name = cutname1 + "_" + cutname2; - o2::aod::pwgem::photon::histogram::AddHistClass(list_pair_subsys, photon_cut_name.data()); - THashList* list_pair_subsys_photoncut = reinterpret_cast(list_pair_subsys->FindObject(photon_cut_name.data())); - - for (auto& cut3 : cuts3) { - std::string pair_cut_name = cut3.GetName(); - o2::aod::pwgem::photon::histogram::AddHistClass(list_pair_subsys_photoncut, pair_cut_name.data()); - THashList* list_pair_subsys_paircut = reinterpret_cast(list_pair_subsys_photoncut->FindObject(pair_cut_name.data())); - o2::aod::pwgem::photon::histogram::DefineHistograms(list_pair_subsys_paircut, "tagging_pi0_mc", "pair"); - } // end of pair cut loop - } // end of cut2 loop - } // end of cut1 loop - } - - static constexpr std::string_view pairnames[9] = {"PCMPCM", "PHOSPHOS", "EMCEMC", "PCMPHOS", "PCMEMC", "PCMDalitzEE", "PCMDalitzMuMu", "PHOSEMC", "DalitzEEDalitzEE"}; - void addhistograms() - { - fMainList->SetOwner(true); - fMainList->SetName("fMainList"); - - // create sub lists first. - o2::aod::pwgem::photon::histogram::AddHistClass(fMainList, "Event"); - THashList* list_ev = reinterpret_cast(fMainList->FindObject("Event")); - - o2::aod::pwgem::photon::histogram::AddHistClass(fMainList, "PCM"); - THashList* list_pcm = reinterpret_cast(fMainList->FindObject("PCM")); - for (auto& cut : fPCMCuts) { - THashList* list_pcm_cut = o2::aod::pwgem::photon::histogram::AddHistClass(list_pcm, cut.GetName()); - o2::aod::pwgem::photon::histogram::DefineHistograms(list_pcm_cut, "tagging_pi0_mc", "pcm"); - } - - o2::aod::pwgem::photon::histogram::AddHistClass(fMainList, "Pair"); - THashList* list_pair = reinterpret_cast(fMainList->FindObject("Pair")); - - for (auto& pairname : fPairNames) { - LOGF(info, "Enabled pairs = %s", pairname.data()); - - THashList* list_ev_pair = reinterpret_cast(o2::aod::pwgem::photon::histogram::AddHistClass(list_ev, pairname.data())); - for (const auto& evtype : event_types) { - THashList* list_ev_type = reinterpret_cast(o2::aod::pwgem::photon::histogram::AddHistClass(list_ev_pair, evtype.data())); - o2::aod::pwgem::photon::histogram::DefineHistograms(list_ev_type, "Event", evtype.data()); - } - - o2::aod::pwgem::photon::histogram::AddHistClass(list_pair, pairname.data()); - - if (pairname == "PCMDalitzEE") { - add_pair_histograms(list_pair, pairname, fPCMCuts, fDalitzEECuts, fPairCuts); - } - if (pairname == "PCMPHOS") { - add_pair_histograms(list_pair, pairname, fPCMCuts, fPHOSCuts, fPairCuts); - } - if (pairname == "PCMEMC") { - add_pair_histograms(list_pair, pairname, fPCMCuts, fEMCCuts, fPairCuts); - } - - } // end of pair name loop - } - - void DefinePCMCuts() - { - TString cutNamesStr = fConfigPCMCuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - fPCMCuts.push_back(*pcmcuts::GetCut(cutname)); - } - } - LOGF(info, "Number of PCM cuts = %d", fPCMCuts.size()); - } - - void DefineDalitzEECuts() - { - TString cutNamesStr = fConfigDalitzEECuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - fDalitzEECuts.push_back(*dalitzeecuts::GetCut(cutname)); - } - } - LOGF(info, "Number of DalitzEE cuts = %d", fDalitzEECuts.size()); - } - - void DefinePHOSCuts() - { - TString cutNamesStr = fConfigPHOSCuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - fPHOSCuts.push_back(*phoscuts::GetCut(cutname)); - } - } - LOGF(info, "Number of PHOS cuts = %d", fPHOSCuts.size()); - } - - void DefineEMCCuts() - { - const float a = EMC_TM_Eta->at(0); - const float b = EMC_TM_Eta->at(1); - const float c = EMC_TM_Eta->at(2); - - const float d = EMC_TM_Phi->at(0); - const float e = EMC_TM_Phi->at(1); - const float f = EMC_TM_Phi->at(2); - LOGF(info, "EMCal track matching parameters : a = %f, b = %f, c = %f, d = %f, e = %f, f = %f", a, b, c, d, e, f); - - TString cutNamesStr = fConfigEMCCuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - if (std::strcmp(cutname, "custom") == 0) { - EMCPhotonCut* custom_cut = new EMCPhotonCut(cutname, cutname); - custom_cut->SetMinE(EMC_minE); - custom_cut->SetMinNCell(EMC_minNCell); - custom_cut->SetM02Range(EMC_minM02, EMC_maxM02); - custom_cut->SetTimeRange(EMC_minTime, EMC_maxTime); - - custom_cut->SetTrackMatchingEta([a, b, c](float pT) { - return a + pow(pT + b, c); - }); - custom_cut->SetTrackMatchingPhi([d, e, f](float pT) { - return d + pow(pT + e, f); - }); - - custom_cut->SetMinEoverP(EMC_Eoverp); - custom_cut->SetUseExoticCut(EMC_UseExoticCut); - fEMCCuts.push_back(*custom_cut); - } else { - fEMCCuts.push_back(*emccuts::GetCut(cutname)); - } - } - } - LOGF(info, "Number of EMCal cuts = %d", fEMCCuts.size()); - } - - void DefinePairCuts() - { - TString cutNamesStr = fConfigPairCuts.value; - if (!cutNamesStr.IsNull()) { - std::unique_ptr objArray(cutNamesStr.Tokenize(",")); - for (int icut = 0; icut < objArray->GetEntries(); ++icut) { - const char* cutname = objArray->At(icut)->GetName(); - LOGF(info, "add cut : %s", cutname); - fPairCuts.push_back(*paircuts::GetCut(cutname)); - } - } - LOGF(info, "Number of Pair cuts = %d", fPairCuts.size()); - } - - template - bool IsSelectedPair(TG1 const& g1, TG2 const& g2, TCut1 const& cut1, TCut2 const& cut2) - { - bool is_selected_pair = false; - if constexpr (pairtype == PairType::kPCMPHOS) { - is_selected_pair = o2::aod::pwgem::photonmeson::photonpair::IsSelectedPair(g1, g2, cut1, cut2); - } else if constexpr (pairtype == PairType::kPCMEMC) { - is_selected_pair = o2::aod::pwgem::photonmeson::photonpair::IsSelectedPair(g1, g2, cut1, cut2); - } else if constexpr (pairtype == PairType::kPCMDalitzEE) { - is_selected_pair = o2::aod::pwgem::photonmeson::photonpair::IsSelectedPair(g1, g2, cut1, cut2); - } else { - is_selected_pair = true; - } - return is_selected_pair; - } - - template - void TruePairing(TEvents const& collisions, TPhotons1 const& photons1, TPhotons2 const& photons2, TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, TCuts1 const& cuts1, TCuts2 const& cuts2, TPairCuts const& paircuts, TLegs const& /*legs*/, TEMPrimaryElectrons const& /*emprimaryelectrons*/, TMCParticles const& mcparticles, TMCEvents const& /*mcevents*/) - { - THashList* list_ev_pair_before = static_cast(fMainList->FindObject("Event")->FindObject(pairnames[pairtype].data())->FindObject(event_types[0].data())); - THashList* list_ev_pair_after = static_cast(fMainList->FindObject("Event")->FindObject(pairnames[pairtype].data())->FindObject(event_types[1].data())); - THashList* list_pair_ss = static_cast(fMainList->FindObject("Pair")->FindObject(pairnames[pairtype].data())); - THashList* list_pcm = static_cast(fMainList->FindObject("PCM")); - - for (auto& collision : collisions) { - initCCDB(collision); - if ((pairtype == kPHOSPHOS || pairtype == kPCMPHOS) && !collision.alias_bit(triggerAliases::kTVXinPHOS)) { - continue; - } - if ((pairtype == kEMCEMC || pairtype == kPCMEMC) && !collision.alias_bit(triggerAliases::kTVXinEMC)) { - continue; - } - - const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - o2::aod::pwgem::photon::histogram::FillHistClass(list_ev_pair_before, "", collision); - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - o2::aod::pwgem::photon::histogram::FillHistClass(list_ev_pair_after, "", collision); - reinterpret_cast(list_ev_pair_before->FindObject("hCollisionCounter"))->Fill("accepted", 1.f); - reinterpret_cast(list_ev_pair_after->FindObject("hCollisionCounter"))->Fill("accepted", 1.f); - - auto photons1_coll = photons1.sliceBy(perCollision1, collision.globalIndex()); - auto photons2_coll = photons2.sliceBy(perCollision2, collision.globalIndex()); - - for (auto& cut1 : cuts1) { - for (auto& g1 : photons1_coll) { - - if (!cut1.template IsSelected(g1)) { - continue; - } - if (abs(g1.eta()) > maxY) { // photon is massless particle. rapidity = pseudo-rapidity - continue; - } - - auto pos1 = g1.template posTrack_as(); - auto ele1 = g1.template negTrack_as(); - auto pos1mc = pos1.template emmcparticle_as(); - auto ele1mc = ele1.template emmcparticle_as(); - - int photonid1 = FindCommonMotherFrom2Prongs(pos1mc, ele1mc, -11, 11, 22, mcparticles); - if (photonid1 < 0) { - continue; - } - auto mcphoton1 = mcparticles.iteratorAt(photonid1); - - int pi0id1 = IsXFromY(mcphoton1, mcparticles, 22, 111); - if (pi0id1 < 0) { // photon from pi0 decay - continue; - } - auto mcpi01 = mcparticles.iteratorAt(pi0id1); - - // // check if pi0 is physical primary or produced by generator, photon should be physical primary or produced by generator. - // LOGF(info, "mcphoton1.isPhysicalPrimary() = %d, mcphoton1.producedByGenerator() = %d, mcpi01.isPhysicalPrimary() = %d, mcpi01.producedByGenerator() = %d", - // mcphoton1.isPhysicalPrimary(), mcphoton1.producedByGenerator(), mcpi01.isPhysicalPrimary(), mcpi01.producedByGenerator()); - - if (mcpi01.isPhysicalPrimary() || mcpi01.producedByGenerator()) { - if (!IsConversionPointInAcceptance(mcphoton1, maxRgen, maxY, margin_z_mc, mcparticles)) { - continue; - } - reinterpret_cast(list_pcm->FindObject(cut1.GetName())->FindObject("hPt_v0photon_Pi0_Primary"))->Fill(g1.pt()); - } else if (IsFromWD(mcpi01.emmcevent(), mcpi01, mcparticles) > 0) { - reinterpret_cast(list_pcm->FindObject(cut1.GetName())->FindObject("hPt_v0photon_Pi0_FromWD"))->Fill(g1.pt()); - } else { - reinterpret_cast(list_pcm->FindObject(cut1.GetName())->FindObject("hPt_v0photon_Pi0_hs"))->Fill(g1.pt()); - } - - } // end of pcm photon loop - } // end of cut loop - - for (auto& cut1 : cuts1) { - for (auto& cut2 : cuts2) { - for (auto& paircut : paircuts) { - for (auto& [g1, g2] : combinations(CombinationsFullIndexPolicy(photons1_coll, photons2_coll))) { - - if constexpr (pairtype == PairType::kPCMDalitzEE) { - auto pos_pv = g2.template posTrack_as(); - auto ele_pv = g2.template negTrack_as(); - std::tuple pair2 = std::make_tuple(pos_pv, ele_pv, d_bz); - if (!IsSelectedPair(g1, pair2, cut1, cut2)) { - continue; - } - } else { - if (!IsSelectedPair(g1, g2, cut1, cut2)) { - continue; - } - } - - if (!paircut.IsSelected(g1, g2)) { - continue; - } - - auto pos1 = g1.template posTrack_as(); - auto ele1 = g1.template negTrack_as(); - auto pos1mc = pos1.template emmcparticle_as(); - auto ele1mc = ele1.template emmcparticle_as(); - - int photonid1 = FindCommonMotherFrom2Prongs(pos1mc, ele1mc, -11, 11, 22, mcparticles); - if (photonid1 < 0) { // check swap, true electron is reconstructed as positron and vice versa. - photonid1 = FindCommonMotherFrom2Prongs(pos1mc, ele1mc, 11, -11, 22, mcparticles); - } - if (photonid1 < 0) { - continue; - } - - if constexpr (pairtype == PairType::kPCMPHOS || pairtype == PairType::kPCMEMC) { - if constexpr (pairtype == PairType::kPCMPHOS) { - if (o2::aod::pwgem::photonmeson::photonpair::DoesV0LegMatchWithCluster(pos1, g2, 0.02, 0.4, 0.2) || o2::aod::pwgem::photonmeson::photonpair::DoesV0LegMatchWithCluster(ele1, g2, 0.02, 0.4, 0.2)) { - continue; - } - } else if constexpr (pairtype == PairType::kPCMEMC) { - if (o2::aod::pwgem::photonmeson::photonpair::DoesV0LegMatchWithCluster(pos1, g2, 0.02, 0.4, 0.5) || o2::aod::pwgem::photonmeson::photonpair::DoesV0LegMatchWithCluster(ele1, g2, 0.02, 0.4, 0.5)) { - continue; - } - } - } - - auto g1mc = mcparticles.iteratorAt(photonid1); - - int pi0id = -1; - if constexpr (pairtype == PairType::kPCMDalitzEE) { - auto pos2 = g2.template posTrack_as(); - auto ele2 = g2.template negTrack_as(); - if (pos1.trackId() == pos2.trackId() || ele1.trackId() == ele2.trackId()) { - continue; - } - auto pos2mc = pos2.template emmcparticle_as(); - auto ele2mc = ele2.template emmcparticle_as(); - pi0id = FindCommonMotherFrom3Prongs(g1mc, pos2mc, ele2mc, 22, -11, 11, 111, mcparticles); - } - if (pi0id < 0) { - continue; - } - - ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); // pcm - ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); // phos or emc or dalitzee - if constexpr (pairtype == PairType::kPCMDalitzEE) { - v2.SetM(g2.mass()); - } - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - // if (abs(v12.Rapidity()) > maxY) { - // continue; - // } - - if (pi0id > 0) { - auto mcpi0 = mcparticles.iteratorAt(pi0id); - if (mcpi0.isPhysicalPrimary() || mcpi0.producedByGenerator()) { - if (!IsConversionPointInAcceptance(g1mc, maxRgen, maxY, margin_z_mc, mcparticles)) { - continue; - } - reinterpret_cast(list_pair_ss->FindObject(Form("%s_%s", cut1.GetName(), cut2.GetName()))->FindObject(paircut.GetName())->FindObject("hMggPt_Pi0_Primary"))->Fill(v12.M(), v1.Pt()); - } else if (IsFromWD(mcpi0.emmcevent(), mcpi0, mcparticles)) { - reinterpret_cast(list_pair_ss->FindObject(Form("%s_%s", cut1.GetName(), cut2.GetName()))->FindObject(paircut.GetName())->FindObject("hMggPt_Pi0_FromWD"))->Fill(v12.M(), v1.Pt()); - } else { - reinterpret_cast(list_pair_ss->FindObject(Form("%s_%s", cut1.GetName(), cut2.GetName()))->FindObject(paircut.GetName())->FindObject("hMggPt_Pi0_hs"))->Fill(v12.M(), v1.Pt()); - } - } - } // end of combination - } // end of pair cut loop - } // end of cut2 loop - } // end of cut1 loop - } // end of collision loop - } - - Filter DalitzEEFilter = o2::aod::dalitzee::sign == 0; // analyze only uls - using MyFilteredDalitzEEs = soa::Filtered; - - Preslice perCollision_pcm = aod::v0photonkf::emeventId; - Preslice perCollision_dalitz = aod::dalitzee::emeventId; - Preslice perCollision_phos = aod::skimmedcluster::collisionId; - Preslice perCollision_emc = aod::skimmedcluster::collisionId; - Partition grouped_collisions = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); // this goes to same event. - - void processPCMDalitzEE(MyCollisions const&, MyV0Photons const& v0photons, MyMCV0Legs const& legs, MyFilteredDalitzEEs const& dielectrons, MyMCTracks const& emprimaryelectrons, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const& mccollisions) - { - TruePairing(grouped_collisions, v0photons, dielectrons, perCollision_pcm, perCollision_dalitz, fPCMCuts, fDalitzEECuts, fPairCuts, legs, emprimaryelectrons, mcparticles, mccollisions); - } - - void processPCMPHOS(MyCollisions const&, MyV0Photons const& v0photons, aod::PHOSClusters const& phosclusters, MyMCV0Legs const& legs, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const& mccollisions) - { - TruePairing(grouped_collisions, v0photons, phosclusters, perCollision_pcm, perCollision_phos, fPCMCuts, fPHOSCuts, fPairCuts, legs, nullptr, mcparticles, mccollisions); - } - - void processPCMEMC(MyCollisions const&, MyV0Photons const& v0photons, aod::SkimEMCClusters const& emcclusters, MyMCV0Legs const& legs, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const& mccollisions) - { - TruePairing(grouped_collisions, v0photons, emcclusters, perCollision_pcm, perCollision_emc, fPCMCuts, fEMCCuts, fPairCuts, legs, nullptr, mcparticles, mccollisions); - } - - void processDummy(MyCollisions const&) {} - - PROCESS_SWITCH(TaggingPi0MC, processPCMDalitzEE, "pairing PCM-Dalitz", false); - PROCESS_SWITCH(TaggingPi0MC, processPCMPHOS, "pairing PCM-PHOS", false); - PROCESS_SWITCH(TaggingPi0MC, processPCMEMC, "pairing PCM-EMCal", false); - PROCESS_SWITCH(TaggingPi0MC, processDummy, "Dummy function", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"tagging-pi0-mc"})}; -} diff --git a/PWGEM/PhotonMeson/Tasks/TaggingPi0MCPCMDalitzEE.cxx b/PWGEM/PhotonMeson/Tasks/TaggingPi0MCPCMDalitzEE.cxx new file mode 100644 index 00000000000..ccdc4184568 --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/TaggingPi0MCPCMDalitzEE.cxx @@ -0,0 +1,29 @@ +// 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. +// +// ======================== +// +// This code loops over photons and makes pairs for neutral mesons analyses. +// Please write to: daiki.sekihata@cern.ch + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "PWGEM/PhotonMeson/Core/TaggingPi0MC.h" + +using namespace o2; +using namespace o2::aod; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"tagging-pi0-mc-pcmdalitzee"}), + }; +} diff --git a/PWGEM/PhotonMeson/Tasks/TaggingPi0PCMDalitzEE.cxx b/PWGEM/PhotonMeson/Tasks/TaggingPi0PCMDalitzEE.cxx new file mode 100644 index 00000000000..2292faef120 --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/TaggingPi0PCMDalitzEE.cxx @@ -0,0 +1,29 @@ +// 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. +// +// ======================== +// +// This code loops over photons and makes pairs for neutral mesons analyses. +// Please write to: daiki.sekihata@cern.ch + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "PWGEM/PhotonMeson/Core/TaggingPi0.h" + +using namespace o2; +using namespace o2::aod; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"tagging-pi0-pcmdalitzee"}), + }; +} diff --git a/PWGEM/PhotonMeson/Tasks/compconvbuilder.cxx b/PWGEM/PhotonMeson/Tasks/compconvbuilder.cxx new file mode 100644 index 00000000000..5512191322c --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/compconvbuilder.cxx @@ -0,0 +1,889 @@ +// 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. + +/// \file compconvbuilder.cxx +/// \brief QA task for photons in the EM and LF builder +/// +/// \author S. Mrozinski, smrozins@cern.ch + +#include "PWGEM/Dilepton/Utils/MCUtilities.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" +#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "PWGLF/DataModel/LFStrangenessMLTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TPCVDriftManager.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/McCollisionExtra.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod; +using namespace o2::soa; + +using namespace o2::aod::pwgem::photon; +using namespace o2::aod::pwgem::dilepton::utils::mcutil; +using namespace o2::aod::pwgem::photonmeson::utils::mcutil; + +using MyV0Photons = soa::Join; +using MyMCV0Legs = soa::Join; +using MyMCV0Leg = MyMCV0Legs::iterator; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyMCCollisions = soa::Join; +using MyMCCollision = MyMCCollisions::iterator; + +using MyStraCollisions = soa::Join; +using MyStraCollision = MyStraCollisions::iterator; + +using MyTracksIUMC = soa::Join; +using MyMCParticles = aod::McParticles; + +using V0DerivedMCDatas = soa::Join; + +using dauTracks = soa::Join; + +struct Convbuildercomp { + HistogramRegistry registry{"Convbuildercomp"}; + + enum conversionBuilderID { + EMBuilder = 0, + LFBuilder = 1, + EMOnly = 2, + LFOnly = 3, + Common = 4 + }; + + static constexpr std::string_view conversionBuilder[5] = {"EMBuilder/", "LFBuilder/", "EMOnly/", "LFOnly/", "Common/"}; + static constexpr std::string_view event_types[2] = {"before/", "after/"}; + + EMPhotonEventCut fEMEventCut; + struct : ConfigurableGroup { + std::string prefix = "eventcut_group"; + Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + Configurable cfgRequireSel8{"cfgRequireSel8", true, "require sel8 in event cut"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", true, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", true, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; + Configurable cfgRequireVertexITSTPC{"cfgRequireVertexITSTPC", false, "require Vertex ITSTPC in event cut"}; // ITS-TPC matched track contributes PV. + Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; + Configurable cfgRequireNoCollInTimeRangeStandard{"cfgRequireNoCollInTimeRangeStandard", false, "require no collision in time range standard"}; + Configurable cfgRequireNoCollInTimeRangeStrict{"cfgRequireNoCollInTimeRangeStrict", false, "require no collision in time range strict"}; + Configurable cfgRequireNoCollInITSROFStandard{"cfgRequireNoCollInITSROFStandard", false, "require no collision in time range standard"}; + Configurable cfgRequireNoCollInITSROFStrict{"cfgRequireNoCollInITSROFStrict", false, "require no collision in time range strict"}; + Configurable cfgRequireNoHighMultCollInPrevRof{"cfgRequireNoHighMultCollInPrevRof", false, "require no HM collision in previous ITS ROF"}; + } eventcuts; + + void DefineEMEventCut() + { + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); + fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); + fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); + fEMEventCut.SetRequireNoTFB(eventcuts.cfgRequireNoTFB); + fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); + fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); + fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); + fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); + fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); + fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); + fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); + fEMEventCut.SetRequireNoHighMultCollInPrevRof(eventcuts.cfgRequireNoHighMultCollInPrevRof); + } + + // Link V0-photons to their collision + Preslice perV0PhotonCollision = aod::v0photonkf::emeventId; + + void init(InitContext const& /*ctx*/) + { + + DefineEMEventCut(); + + for (int i = 0; i < 5; ++i) { + + registry.add(string(conversionBuilder[i]) + "hPt", ";p_{T} (GeV/c); Counts", kTH1F, {{1000, 0., 10.}}); + registry.add(string(conversionBuilder[i]) + "hR", ";R_{conv} (cm); Counts", kTH1F, {{100, 0., 100.}}); + + registry.add(string(conversionBuilder[i]) + "hEta", ";#eta; Counts", kTH1F, {{200, -1.0f, 1.0f}}); + + registry.add(string(conversionBuilder[i]) + "hcosPA", ";R_{conv} (cm); Counts", kTH1F, {{100, 0.99f, 1.0f}}); + + registry.add(string(conversionBuilder[i]) + "MatchedDeltaRec", ";#Delta colID_{rec};Counts", kTH1F, {{21, -10.5, 10.5}}); + + registry.add(string(conversionBuilder[i]) + "hZ", ";z (cm);Counts", kTH1F, {{200, -100, 100}}); + + registry.add(string(conversionBuilder[i]) + "hZR", "conversion point in RZ;Z (cm);R_{xy} (cm)", kTH2F, {{200, -100, 100}, {200, 0.0f, 100.0f}}); + + registry.add(string(conversionBuilder[i]) + "hAP", "AP plot;#alpha;q_{T} (GeV/c)", kTH2F, {{200, -1.0f, +1.0f}, {250, 0.0f, 0.25f}}); + + registry.add(string(conversionBuilder[i]) + "ResolutionGen/Z_res", "Conversion radius resolution;z_{conv, gen} (cm);R_{conv, gen} (cm);#varphi_{gen} (rad.);#eta_{gen};p_{T, gen};z_{conv, rec} - z_{conv, gen} (cm);", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {120, -30, 30} + + }, + false); + + registry.add(string(conversionBuilder[i]) + "ResolutionGen/R_res", "Conversion radius resolution;z_{conv, gen} (cm);R_{conv, gen} (cm);#varphi_{gen} (rad.);#eta_{gen};p_{T, gen};R_{conv, rec} - R_{conv, gen} (cm);", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {120, -30, 30} + + }, + false); + + registry.add(string(conversionBuilder[i]) + "ResolutionGen/Phi_res", "#varphi resolution;z_{conv, gen} (cm);R_{conv, gen} (cm);#varphi_{gen} (rad.);#eta_{gen};p_{T, gen};#varphi_{conv, rec} - #varphi_{conv, gen} (cm);", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {100, -0.2f, 0.2f} + + }, + false); + + registry.add(string(conversionBuilder[i]) + "ResolutionGen/Pt_res", "Conversion radius resolution;z_{conv, gen} (cm);R_{conv, gen} (cm);#varphi_{gen} (rad.);#eta_{gen};p_{T, gen};p_{T, rec} - p_{T, gen}/p_{T, gen};", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {200, -1.0f, 1.0f} + + }, + false); + + registry.add(string(conversionBuilder[i]) + "ResolutionGen/Eta_res", "Conversion radius resolution;z_{conv, gen} (cm);R_{conv, gen} (cm);#varphi_{gen} (rad.);#eta_{gen};p_{T, gen};#eta_{conv, rec} - #eta_{conv, gen} (cm);", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {100, -0.5f, 0.5f} + + }, + false); + + registry.add(string(conversionBuilder[i]) + "ResolutionRec/Z_res", "Conversion radius resolution;z_{conv, rec} (cm);R_{conv, rec} (cm);#varphi_{rec} (rad.);#eta_{rec};p_{T, rec};z_{conv, rec} - z_{conv, gen} (cm);", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {120, -30, 30} + + }, + false); + + registry.add(string(conversionBuilder[i]) + "ResolutionRec/R_res", "Conversion radius resolution;z_{conv, rec} (cm);R_{conv, rec} (cm);#varphi_{rec} (rad.);#eta_{rec};p_{T, rec};R_{conv, rec} - R_{conv, gen} (cm);", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {120, -30, 30} + + }, + false); + + registry.add(string(conversionBuilder[i]) + "ResolutionRec/Phi_res", "#varphi resolution;z_{conv, rec} (cm);R_{conv, rec} (cm);#varphi_{rec} (rad.);#eta_{rec};p_{T, rec};#varphi_{conv, rec} - #varphi_{conv, gen} (cm);", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {100, -0.2f, 0.2f} + + }, + false); + + registry.add(string(conversionBuilder[i]) + "ResolutionRec/Pt_res", "Conversion radius resolution;z_{conv, rec} (cm);R_{conv, rec} (cm);#varphi_{rec} (rad.);#eta_{rec};p_{T, rec};p_{T, rec} - p_{T, gen}/p_{T, gen};", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {200, -1.0f, 1.0f} + + }, + false); + + registry.add(string(conversionBuilder[i]) + "ResolutionRec/Eta_res", "Conversion radius resolution;z_{conv, rec} (cm);R_{conv, rec} (cm);#varphi_{rec} (rad.);#eta_{rec};p_{T, rec};#eta_{conv, rec} - #eta_{conv, gen} (cm);", + kTHnSparseF, + {{200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + {100, -0.5f, 0.5f} + + }, + false); + registry.add(string(conversionBuilder[i]) + "ConvInfo", "Conversion radius resolution;x_{conv} (cm);y_{conv} (cm);z_{conv} (cm);R_{conv} (cm);#varphi (rad.);#eta;p_{T, gen};", + kTHnSparseF, + { + {200, -100, 100}, + {200, -100, 100}, + {200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}, + + }, + false); + + registry.add(string(conversionBuilder[i]) + "V0Leg/Asymmetry", "", kTH1F, {{100, 0, 1}}); + + auto hCollisionCounter = registry.add(string(conversionBuilder[i]) + "Event/before/hCollisionCounter", "collision counter;;Number of events", kTH1F, {{10, 0.5, 10.5}}, false); + hCollisionCounter->GetXaxis()->SetBinLabel(1, "all"); + hCollisionCounter->GetXaxis()->SetBinLabel(2, "No TF border"); + hCollisionCounter->GetXaxis()->SetBinLabel(3, "No ITS ROF border"); + hCollisionCounter->GetXaxis()->SetBinLabel(4, "No Same Bunch Pileup"); + hCollisionCounter->GetXaxis()->SetBinLabel(5, "Is Vertex ITSTPC"); + hCollisionCounter->GetXaxis()->SetBinLabel(6, "Is Good Zvtx FT0vsPV"); + hCollisionCounter->GetXaxis()->SetBinLabel(7, "FT0AND"); + hCollisionCounter->GetXaxis()->SetBinLabel(8, "sel8"); + hCollisionCounter->GetXaxis()->SetBinLabel(9, "|Z_{vtx}| < 10 cm"); + hCollisionCounter->GetXaxis()->SetBinLabel(10, "accepted"); + + registry.add(string(conversionBuilder[i]) + "Event/before/hZvtx", "vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); + registry.add(string(conversionBuilder[i]) + "Event/before/hMultNTracksPV", "hMultNTracksPV; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); + registry.add(string(conversionBuilder[i]) + "Event/before/hMultNTracksPVeta1", "hMultNTracksPVeta1; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); + registry.add(string(conversionBuilder[i]) + "Event/before/hMultFT0", "hMultFT0;mult. FT0A;mult. FT0C", kTH2F, {{300, 0, 6000}, {300, 0, 6000}}, false); + registry.add(string(conversionBuilder[i]) + "Event/before/hCentFT0A", "hCentFT0A;centrality FT0A (%)", kTH1F, {{110, 0, 110}}, false); + registry.add(string(conversionBuilder[i]) + "Event/before/hCentFT0C", "hCentFT0C;centrality FT0C (%)", kTH1F, {{110, 0, 110}}, false); + registry.add(string(conversionBuilder[i]) + "Event/before/hCentFT0M", "hCentFT0M;centrality FT0M (%)", kTH1F, {{110, 0, 110}}, false); + registry.add(string(conversionBuilder[i]) + "Event/before/hCentFT0MvsMultNTracksPV", "hCentFT0MvsMultNTracksPV;centrality FT0M (%);N_{track} to PV", kTH2F, {{110, 0, 110}, {600, 0, 6000}}, false); + registry.add(string(conversionBuilder[i]) + "Event/before/hMultFT0MvsMultNTracksPV", "hMultFT0MvsMultNTracksPV;mult. FT0M;N_{track} to PV", kTH2F, {{600, 0, 6000}, {600, 0, 6000}}, false); + registry.addClone(string(conversionBuilder[i]) + "Event/before/", string(conversionBuilder[i]) + "Event/after/"); + } + + registry.add("truePhotons/hPt_Converted", "Converted Photons; p_{T} (GeV/c); Counts", kTH1F, {{100, 0., 10.}}); + registry.add("truePhotons/hR_Converted", "Converted Photons; R (cm); Counts", kTH1F, {{100, 0., 100.}}); + + registry.add("truePhotons/Sparse_Converted", "Conversion radius resolution;x_{conv} (cm);z_{conv} (cm);y_{conv} (cm);R_{conv} (cm);#varphi (rad.);#eta;p_{T, gen};", + kTHnSparseF, + {{200, -100, 100}, + {200, -100, 100}, + {200, -100, 100}, + {200, 0, 100}, + {90, 0, 2 * M_PI}, + {200, -1.0f, 1.0f}, + {500, 0, 10}}, + false); + + auto h = registry.add("EMBuilder/hV0SignType", "Crosscheck", kTH1F, {{3, 0.5, 4.5}}, false); + h->GetXaxis()->SetBinLabel(1, "Same-sign"); + h->GetXaxis()->SetBinLabel(2, "Opposite-sign"); + h->GetXaxis()->SetBinLabel(3, "Zero-sign"); + + auto h2 = registry.add("EMBuilder/hV0ElectronPositronTrue", "pair in MC truth;;counts", kTH1F, {{2, -0.5, 1.5}}); + h2->GetXaxis()->SetBinLabel(1, "Mismatch"); + h2->GetXaxis()->SetBinLabel(2, "Good"); + } + + template + void fillEventInfo(TCollision const& collision, const float /*weight*/ = 1.f) + { + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 1.0); + + if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 2.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 3.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 4.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 5.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 6.0); + } + + if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 7.0); + } + + if (collision.sel8()) { + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 8.0); + } + if (std::fabs(collision.posZ()) < 10.0) { + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 9.0); + } + + registry.fill(HIST(conversionBuilder[type]) + HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultNTracksPVeta1"), collision.multNTracksPVeta1()); + } + + template + void fillLegInfo(auto& v0, auto& posleg, auto& negleg) + { + if constexpr (type == 0) { + + float ptPos = posleg.pt(); + float ptNeg = negleg.pt(); + float asym = (ptPos - ptNeg) / (ptPos + ptNeg); + + registry.fill(HIST(conversionBuilder[type]) + HIST("V0Leg/Asymmetry"), asym); + + } else { + + float ptPos = v0.postrackpt(); + float ptNeg = negleg.negtrackpt(); + float asym = (ptPos - ptNeg) / (ptPos + ptNeg); + + registry.fill(HIST(conversionBuilder[type]) + HIST("V0Leg/Asymmetry"), asym); + } + } + + template + void fillV0Info(auto& v0, auto& v0MC, auto& mcleg) + { + registry.fill(HIST(conversionBuilder[type]) + HIST("hPt"), v0.pt()); + registry.fill(HIST(conversionBuilder[type]) + HIST("hEta"), v0.eta()); + registry.fill(HIST(conversionBuilder[type]) + HIST("hAP"), v0.alpha(), v0.qtarm()); + + if constexpr (type == 0 || type == 2) { + registry.fill(HIST(conversionBuilder[type]) + HIST("hZ"), v0.vz()); + registry.fill(HIST(conversionBuilder[type]) + HIST("hcosPA"), v0.cospa()); + registry.fill(HIST(conversionBuilder[type]) + HIST("hZR"), v0.vz(), v0.v0radius()); + + float deltapT = v0.pt() - v0MC.pt(); + float deltaZ = v0.vz() - mcleg.vz(); + float deltaPhi = v0.phi() - v0MC.phi(); + float deltaEta = v0.eta() - v0MC.eta(); + float deltaR = v0.v0radius() - std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/Z_res"), + mcleg.vz(), + std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), + v0MC.phi(), + v0MC.eta(), + v0MC.pt(), + deltaZ); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/R_res"), + mcleg.vz(), + std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), + v0MC.phi(), + v0MC.eta(), + v0MC.pt(), + deltaR); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/Phi_res"), + mcleg.vz(), + std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), + v0MC.phi(), + v0MC.eta(), + v0MC.pt(), + deltaPhi); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/Pt_res"), + mcleg.vz(), + std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), + v0MC.phi(), + v0MC.eta(), + v0MC.pt(), + deltapT); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/Eta_res"), + mcleg.vz(), + std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), + v0MC.phi(), + v0MC.eta(), + v0MC.pt(), + deltaEta); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/Z_res"), + v0.vz(), + v0.v0radius(), + v0.phi(), + v0.eta(), + v0.pt(), + deltaZ); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/R_res"), + v0.vz(), + v0.v0radius(), + v0.phi(), + v0.eta(), + v0.pt(), + deltaR); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/Phi_res"), + v0.vz(), + v0.v0radius(), + v0.phi(), + v0.eta(), + v0.pt(), + deltaPhi); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/Pt_res"), + v0.vz(), + v0.v0radius(), + v0.phi(), + v0.eta(), + v0.pt(), + deltapT); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/Eta_res"), + v0.vz(), + v0.v0radius(), + v0.phi(), + v0.eta(), + v0.pt(), + deltaEta); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ConvInfo"), + v0.vx(), // 0 + v0.vy(), // 1 + v0.vz(), // 2 + v0.v0radius(), // 3 + v0.phi(), // 4 + v0.eta(), // 5 + v0.pt()); // 6 + + } else { + registry.fill(HIST(conversionBuilder[type]) + HIST("hZ"), v0.z()); + registry.fill(HIST(conversionBuilder[type]) + HIST("hcosPA"), v0.v0cosPA()); + registry.fill(HIST(conversionBuilder[type]) + HIST("hZR"), v0.z(), v0.v0radius()); + + float deltaR = v0.v0radius() - std::hypot(v0MC.xMC(), v0MC.yMC()); + + float phiRec = v0.phi(); + if (phiRec < 0) { + phiRec += 2.0f * static_cast(M_PI); + } + + float phiMC = std::atan2(v0MC.pyMC(), v0MC.pxMC()); + if (phiMC < 0) { + phiMC += 2.0f * static_cast(M_PI); + } + + float deltaPhi = phiRec - phiMC; + if (deltaPhi < 0) { + deltaPhi += 2.0f * static_cast(M_PI); + } + + float etaGen = 0.5f * std::log((std::hypot(v0MC.pxMC(), v0MC.pyMC(), v0MC.pzMC()) + v0MC.pzMC()) / (std::hypot(v0MC.pxMC(), v0MC.pyMC(), v0MC.pzMC()) - v0MC.pzMC())); + + float etaRec = 0.5f * std::log((std::hypot(v0.px(), v0.py(), v0.pz()) + v0.pz()) / (std::hypot(v0.px(), v0.py(), v0.pz()) - v0.pz())); + + float deltapT = v0.pt() - v0MC.ptMC(); + float deltaEta = etaRec - etaGen; + float deltaZ = v0.z() - v0MC.zMC(); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/Z_res"), + v0MC.zMC(), + std::hypot(v0MC.xMC(), v0MC.yMC()), + phiMC, + etaGen, + v0MC.ptMC(), + deltaZ); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/R_res"), + v0MC.zMC(), + std::hypot(v0MC.xMC(), v0MC.yMC()), + phiMC, + etaGen, + v0MC.ptMC(), + deltaR); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/Phi_res"), + v0MC.zMC(), + std::hypot(v0MC.xMC(), v0MC.yMC()), + phiMC, + etaGen, + v0MC.ptMC(), + deltaPhi); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/Pt_res"), + v0MC.zMC(), + std::hypot(v0MC.xMC(), v0MC.yMC()), + phiMC, + etaGen, + v0MC.ptMC(), + deltapT); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionGen/Eta_res"), + v0MC.zMC(), + std::hypot(v0MC.xMC(), v0MC.yMC()), + phiMC, + etaGen, + v0MC.ptMC(), + deltaEta); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/Z_res"), + v0.z(), + v0.v0radius(), + phiRec, + v0.eta(), + v0.pt(), + deltaZ); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/R_res"), + v0.z(), + v0.v0radius(), + phiRec, + v0.eta(), + v0.pt(), + deltaR); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/Phi_res"), + v0.z(), + v0.v0radius(), + phiRec, + v0.eta(), + v0.pt(), + deltaPhi); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/Eta_res"), + v0.z(), + v0.v0radius(), + phiRec, + v0.eta(), + v0.pt(), + deltaEta); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ResolutionRec/Pt_res"), + v0.z(), + v0.v0radius(), + phiRec, + v0.eta(), + v0.pt(), + deltapT); + + registry.fill(HIST(conversionBuilder[type]) + HIST("ConvInfo"), + v0.x(), + v0.y(), + v0.z(), + v0.v0radius(), + phiRec, + v0.eta(), + v0.pt()); + } + + registry.fill(HIST(conversionBuilder[type]) + HIST("hR"), v0.v0radius()); + } + + Preslice perCollisionMCDerived = o2::aod::v0data::straCollisionId; + + void processLFV0sMC(MyStraCollisions const& stracollisions, + soa::Join const&, + V0DerivedMCDatas const& strangeV0s) + { + + for (auto& collision : stracollisions) { + + fillEventInfo<0, LFBuilder>(collision); + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + fillEventInfo<1, LFBuilder>(collision); + + registry.fill(HIST((conversionBuilder[1])) + HIST("Event/before/hCollisionCounter"), 10.0); + registry.fill(HIST((conversionBuilder[1])) + HIST("Event/after/hCollisionCounter"), 10.0); // accepted + + auto myV0s = strangeV0s.sliceBy(perCollisionMCDerived, collision.globalIndex()); + + for (auto const& v0 : myV0s) { + if (!v0.has_v0MCCore()) { + continue; + } + + auto v0MC = v0.v0MCCore_as>(); + + if (v0MC.pdgCode() != 22 || !v0MC.isPhysicalPrimary()) { + continue; + } + + auto posTrack = v0.template posTrackExtra_as(); + + fillV0Info(v0, v0MC, posTrack); + } + } + } + + Preslice perCollision = aod::v0photonkf::emeventId; + + void processEMV0sMC(MyV0Photons const& v0s, aod::EMMCParticles const& mcparticles, MyMCV0Legs const&, MyCollisions const& collisions) + { + + for (auto& collision : collisions) { + + fillEventInfo<0, EMBuilder>(collision); + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + fillEventInfo<1, EMBuilder>(collision); + + registry.fill(HIST((conversionBuilder[0])) + HIST("Event/before/hCollisionCounter"), 10.0); // accepted + registry.fill(HIST((conversionBuilder[0])) + HIST("Event/after/hCollisionCounter"), 10.0); // accepted + + auto V0Photons_coll = v0s.sliceBy(perCollision, collision.globalIndex()); + + for (auto const& v0 : V0Photons_coll) { + + auto pos = v0.posTrack_as(); + auto ele = v0.negTrack_as(); + auto posmc = pos.template emmcparticle_as(); + auto elemc = ele.template emmcparticle_as(); + + int photonid = FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 22, mcparticles); + + auto mcphoton = mcparticles.iteratorAt(photonid); + + if (mcphoton.isPhysicalPrimary()) { + + fillV0Info(v0, mcphoton, elemc); + } + + if (pos.sign() * ele.sign() > 0) { + registry.fill(HIST("EMBuilder/hV0SignType"), 1); // same-sign + } else if (pos.sign() * ele.sign() < 0) { + registry.fill(HIST("EMBuilder/hV0SignType"), 2); // opposite-sign + } else { + registry.fill(HIST("EMBuilder/hV0SignType"), 3); // zero or undefined + } + + if ((posmc.pdgCode() == 11 && elemc.pdgCode() == -11) || (posmc.pdgCode() == -11 && elemc.pdgCode() == 11)) { + registry.fill(HIST("EMBuilder/hV0ElectronPositronTrue"), 1); // good + } else { + registry.fill(HIST("EMBuilder/hV0ElectronPositronTrue"), 0); // mismatch + } + } + } + } + + PresliceUnsorted perMcCollision = aod::emmcparticle::emmceventId; + + void processConvV0s(MyCollisions const& collisions, + aod::EMMCParticles const& mcparticles, + MyTracksIUMC const& tracks) + { + for (auto& collision : collisions) { + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + auto mccollision = collision.template emmcevent_as(); + + auto mcstack = mcparticles.sliceBy(perMcCollision, mccollision.globalIndex()); + auto mctracks_coll = mcparticles.sliceBy(perMcCollision, mccollision.globalIndex()); + + std::unordered_map mc2trk; + for (auto& trk : tracks) { + if (trk.mcParticleId() >= 0) { + mc2trk[trk.mcParticleId()] = trk.globalIndex(); + } + } + + for (auto& mc : mctracks_coll) { + if (mc.pdgCode() != 22 || !mc.isPhysicalPrimary()) { + continue; + } + + auto daughters = mc.daughtersIds(); + if (daughters.size() != 2) { + continue; + } + + auto d1 = mcparticles.iteratorAt(daughters[0]); + auto d2 = mcparticles.iteratorAt(daughters[1]); + + if (std::abs(d1.pdgCode()) != 11 || std::abs(d2.pdgCode()) != 11) { + continue; + } + + float r = std::hypot(d1.vx(), d1.vy()); + if (r < 5.0f || r > 90.0f) { + continue; + } + + registry.fill(HIST("truePhotons/hPt_Converted"), mc.pt()); + registry.fill(HIST("truePhotons/hR_Converted"), r); + + registry.fill(HIST("truePhotons/Sparse_Converted"), d1.vx(), mc.y(), d1.vz(), r, mc.phi(), mc.eta(), mc.pt()); + + int id1 = mc2trk.count(d1.globalIndex()) ? mc2trk[d1.globalIndex()] : -1; + int id2 = mc2trk.count(d2.globalIndex()) ? mc2trk[d2.globalIndex()] : -1; + if (id1 < 0 || id2 < 0) { + continue; + } + } + } + } + + Preslice perEMCollision = aod::v0photonkf::emeventId; + + void processMatchCategories( + MyCollisions const& collisions, + MyTracksIUMC const& tracksgen, + MyV0Photons const& emV0s, + soa::Join const&, + V0DerivedMCDatas const& lfV0s, + MyMCV0Legs const&, + aod::McParticles const& mcparticles, + dauTracks const&) + { + std::unordered_map trackToMcLabel; + for (auto const& t : tracksgen) { + int label = t.mcParticleId(); + if (label >= 0) { + trackToMcLabel[t.globalIndex()] = label; + } + } + + for (auto& collision : collisions) { + if (!fEMEventCut.IsSelected(collision)) + continue; + + fillEventInfo<1, EMBuilder>(collision); + + auto emSlice = emV0s.sliceBy(perEMCollision, collision.globalIndex()); + auto lfSlice = lfV0s.sliceBy(perCollisionMCDerived, collision.globalIndex()); + + using EMIt = decltype(emSlice.begin()); + using LFIt = decltype(lfSlice.begin()); + struct Entry { + std::optional emIt; + std::optional lfIt; + }; + std::unordered_map table; + + for (EMIt it = emSlice.begin(); it != emSlice.end(); ++it) { + auto posmc = it.posTrack_as() + .emmcparticle_as(); + auto negmc = it.negTrack_as() + .emmcparticle_as(); + int pid = FindCommonMotherFrom2Prongs(posmc, negmc, + -11, 11, 22, mcparticles); + if (pid >= 0) + table[pid].emIt = it; + } + + for (LFIt it = lfSlice.begin(); it != lfSlice.end(); ++it) { + int posTrackIndex = it.posTrackId(); + auto negTrackIndex = it.negTrackId(); + + if (!trackToMcLabel.count(posTrackIndex) || !trackToMcLabel.count(negTrackIndex)) + continue; + auto posmc = mcparticles.iteratorAt(trackToMcLabel[posTrackIndex]); + auto negmc = mcparticles.iteratorAt(trackToMcLabel[negTrackIndex]); + int pid = FindCommonMotherFrom2Prongs(posmc, negmc, + -11, 11, 22, mcparticles); + if (pid >= 0) + table[pid].lfIt = it; + } + + for (auto const& [pid, entry] : table) { + auto mcphoton = mcparticles.iteratorAt(pid); + + if (entry.emIt.has_value() && entry.lfIt.has_value()) { + // --- Common V0 --- + auto& lfV0 = *entry.lfIt.value(); + auto v0MC = lfV0.template v0MCCore_as< + soa::Join>(); + auto posTrack = lfV0.template posTrackExtra_as(); + fillV0Info(lfV0, v0MC, posTrack); + + } else if (entry.emIt.has_value()) { + // --- EM-only V0 --- + auto& emV0 = *entry.emIt.value(); + auto negmc = emV0.negTrack_as() + .emmcparticle_as(); + fillV0Info(emV0, mcphoton, negmc); + + } else if (entry.lfIt.has_value()) { + // --- LF-only V0 --- + auto& lfV0 = *entry.lfIt.value(); + auto v0MC = lfV0.template v0MCCore_as< + soa::Join>(); + auto posTrack = lfV0.template posTrackExtra_as(); + fillV0Info(lfV0, v0MC, posTrack); + } + } + } + } + + PROCESS_SWITCH(Convbuildercomp, processMatchCategories, "Process V0s matched via MC photon", false); + PROCESS_SWITCH(Convbuildercomp, processLFV0sMC, "Process LF Builder V0s", true); + PROCESS_SWITCH(Convbuildercomp, processEMV0sMC, "Process EM Builder V0s", false); + PROCESS_SWITCH(Convbuildercomp, processConvV0s, "Process generated converted V0s", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfg) +{ + return WorkflowSpec{adaptAnalysisTask(cfg)}; +} diff --git a/PWGEM/PhotonMeson/Tasks/dalitzEEQC.cxx b/PWGEM/PhotonMeson/Tasks/dalitzEEQC.cxx index 5def3ca8e03..552d5b711d4 100644 --- a/PWGEM/PhotonMeson/Tasks/dalitzEEQC.cxx +++ b/PWGEM/PhotonMeson/Tasks/dalitzEEQC.cxx @@ -14,26 +14,27 @@ // This code runs loop over dalitz ee table for dalitz QC. // Please write to: daiki.sekihata@cern.ch -#include -#include +#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" #include "Common/Core/RecoDecay.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" -#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" -#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" +#include "Math/Vector4D.h" +#include "TString.h" + +#include +#include using namespace o2; using namespace o2::aod; @@ -42,7 +43,7 @@ using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; -using MyCollisions = soa::Join; +using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; using MyTracks = soa::Join; @@ -80,9 +81,8 @@ struct DalitzEEQC { struct : ConfigurableGroup { std::string prefix = "dileptoncut_group"; Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; - Configurable cfg_max_mass{"cfg_max_mass", 0.5, "max mass"}; + Configurable cfg_max_mass{"cfg_max_mass", 0.02, "max mass"}; Configurable cfg_apply_phiv{"cfg_apply_phiv", true, "flag to apply phiv cut"}; - Configurable cfg_apply_pf{"cfg_apply_pf", false, "flag to apply phiv prefilter"}; Configurable cfg_require_itsib_any{"cfg_require_itsib_any", true, "flag to require ITS ib any hits"}; Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", false, "flag to require ITS ib 1st hit"}; Configurable cfg_phiv_slope{"cfg_phiv_slope", 0.0185, "slope for m vs. phiv"}; @@ -93,16 +93,22 @@ struct DalitzEEQC { Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 70, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1.0, "max dca XY for single track in cm"}; Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.0, "max dca Z for single track in cm"}; + Configurable cfg_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1.5, "max DCA 3D in sigma"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; - Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTPConly), "pid scheme [kTPConly : 0]"}; + Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTOFif), "pid scheme [kTOFif : 0, kTPConly : 1]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; - Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -0.0, "min. TPC n sigma for pion exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +0.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; } dileptoncuts; o2::ccdb::CcdbApi ccdbApi; @@ -139,7 +145,7 @@ struct DalitzEEQC { if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } mRunNumber = collision.runNumber(); @@ -175,21 +181,8 @@ struct DalitzEEQC { o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry); // pair info - std::vector ptbins; - std::vector massbins; - - for (int i = 0; i < 51; i++) { - massbins.emplace_back(0.01 * (i - 0) + 0.0); // every 0.01 GeV/c2 from 0.0 to 0.5 GeV/c2 - } - const AxisSpec axis_mass{massbins, "m_{ee} (GeV/c^{2})"}; - - for (int i = 0; i < 50; i++) { - ptbins.emplace_back(0.1 * (i - 0) + 0.0); // every 0.1 GeV/c from 0.0 to 5.0 GeV/c - } - for (int i = 50; i < 61; i++) { - ptbins.emplace_back(0.5 * (i - 50) + 5.0); // every 0.5 GeV/c from 5.0 to 10 GeV/c - } - const AxisSpec axis_pt{ptbins, "p_{T,ee} (GeV/c)"}; + const AxisSpec axis_mass{200, 0, 0.2, "m_{ee} (GeV/c^{2})"}; + const AxisSpec axis_pt{200, 0, 2, "p_{T,ee} (GeV/c)"}; fRegistry.add("Pair/same/hMvsPt", "m_{ee} vs. p_{T,ee};m_{ee} (GeV/c^{2});p_{T,ee} (GeV/c)", kTH2F, {axis_mass, axis_pt}, true); fRegistry.add("Pair/same/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2F, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); @@ -197,18 +190,30 @@ struct DalitzEEQC { fRegistry.add("Track/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); fRegistry.add("Track/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); fRegistry.add("Track/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, false); - fRegistry.add("Track/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); + fRegistry.add("Track/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -0.1f, 0.1f}, {200, -0.1f, 0.1f}}, false); + fRegistry.add("Track/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); + fRegistry.add("Track/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); fRegistry.add("Track/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); fRegistry.add("Track/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); fRegistry.add("Track/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("Track/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); fRegistry.add("Track/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/hTPCNclsShared", "TPC Ncls shared/Ncls;p_{T} (GeV/c);N_{cls}^{shared}/N_{cls} in TPC", kTH2F, {{1000, 0, 10}, {100, 0, 1}}, false); + fRegistry.add("Track/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); fRegistry.add("Track/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); + fRegistry.add("Track/hMeanClusterSizeITS", "mean cluster size ITS;p_{pv} (GeV/c); on ITS #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {150, 0, 15}}, false); + + fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); + fRegistry.add("Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + + fRegistry.add("Track/hChi2TOF", "chi2 of TOF", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/hTOFbeta", "TOF beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, false); + fRegistry.add("Track/hTOFNsigmaEl", "TOF n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/hTOFNsigmaPi", "TOF n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); } void DefineEMEventCut() @@ -241,16 +246,20 @@ struct DalitzEEQC { fDileptonCut.SetMinNClustersTPC(dileptoncuts.cfg_min_ncluster_tpc); fDileptonCut.SetMinNCrossedRowsTPC(dileptoncuts.cfg_min_ncrossedrows); fDileptonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fDileptonCut.SetMaxFracSharedClustersTPC(dileptoncuts.cfg_max_frac_shared_clusters_tpc); fDileptonCut.SetChi2PerClusterTPC(0.0, dileptoncuts.cfg_max_chi2tpc); fDileptonCut.SetChi2PerClusterITS(0.0, dileptoncuts.cfg_max_chi2its); fDileptonCut.SetNClustersITS(dileptoncuts.cfg_min_ncluster_its, 7); fDileptonCut.SetMaxDcaXY(dileptoncuts.cfg_max_dcaxy); fDileptonCut.SetMaxDcaZ(dileptoncuts.cfg_max_dcaz); + fDileptonCut.SetTrackDca3DRange(0.f, dileptoncuts.cfg_max_dca3dsigma_track); // in sigma + fDileptonCut.IncludeITSsa(dileptoncuts.includeITSsa, dileptoncuts.cfg_max_pt_track_ITSsa); // for eID fDileptonCut.SetPIDScheme(dileptoncuts.cfg_pid_scheme); fDileptonCut.SetTPCNsigmaElRange(dileptoncuts.cfg_min_TPCNsigmaEl, dileptoncuts.cfg_max_TPCNsigmaEl); fDileptonCut.SetTPCNsigmaPiRange(dileptoncuts.cfg_min_TPCNsigmaPi, dileptoncuts.cfg_max_TPCNsigmaPi); + fDileptonCut.SetTOFNsigmaElRange(dileptoncuts.cfg_min_TOFNsigmaEl, dileptoncuts.cfg_max_TOFNsigmaEl); } template @@ -271,7 +280,7 @@ struct DalitzEEQC { ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (abs(v12.Rapidity()) > maxY) { + if (std::fabs(v12.Rapidity()) > maxY) { return false; } float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz(), t1.sign(), t2.sign(), d_bz); @@ -281,27 +290,13 @@ struct DalitzEEQC { fRegistry.fill(HIST("Pair/same/hMvsPhiV"), phiv, v12.M()); } - if (t1.sign() > 0) { - if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { - used_trackIds.emplace_back(t1.globalIndex()); - fillTrackInfo(t1); - } - } else { - if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { - used_trackIds.emplace_back(t1.globalIndex()); - fillTrackInfo(t1); - } + if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t1.globalIndex()); + fillTrackInfo(t1); } - if (t2.sign() > 0) { - if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { - used_trackIds.emplace_back(t2.globalIndex()); - fillTrackInfo(t2); - } - } else { - if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { - used_trackIds.emplace_back(t2.globalIndex()); - fillTrackInfo(t2); - } + if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t2.globalIndex()); + fillTrackInfo(t2); } return true; } @@ -313,17 +308,26 @@ struct DalitzEEQC { fRegistry.fill(HIST("Track/hQoverPt"), track.sign() / track.pt()); fRegistry.fill(HIST("Track/hEtaPhi"), track.phi(), track.eta()); fRegistry.fill(HIST("Track/hDCAxyz"), track.dcaXY(), track.dcaZ()); + fRegistry.fill(HIST("Track/hDCAxyzSigma"), track.dcaXY() / std::sqrt(track.cYY()), track.dcaZ() / std::sqrt(track.cZZ())); + fRegistry.fill(HIST("Track/hDCAxyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/hDCAzRes_Pt"), track.pt(), std::sqrt(track.cZZ()) * 1e+4); // convert cm to um fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); fRegistry.fill(HIST("Track/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); fRegistry.fill(HIST("Track/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); + fRegistry.fill(HIST("Track/hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); fRegistry.fill(HIST("Track/hChi2TPC"), track.tpcChi2NCl()); fRegistry.fill(HIST("Track/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/hChi2TOF"), track.tofChi2()); fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); fRegistry.fill(HIST("Track/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); fRegistry.fill(HIST("Track/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); fRegistry.fill(HIST("Track/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); + fRegistry.fill(HIST("Track/hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); + fRegistry.fill(HIST("Track/hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); + fRegistry.fill(HIST("Track/hTOFbeta"), track.p(), track.beta()); + fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); } Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); @@ -331,8 +335,8 @@ struct DalitzEEQC { SliceCache cache; Preslice perCollision_track = aod::emprimaryelectron::emeventId; - Filter trackFilter = static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt && nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && o2::aod::track::tpcChi2NCl < static_cast(dileptoncuts.cfg_max_chi2tpc) && o2::aod::track::itsChi2NCl < static_cast(dileptoncuts.cfg_max_chi2its) && nabs(o2::aod::track::dcaXY) < static_cast(dileptoncuts.cfg_max_dcaxy) && nabs(o2::aod::track::dcaZ) < static_cast(dileptoncuts.cfg_max_dcaz); - Filter pidFilter = (static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl)) && (o2::aod::pidtpc::tpcNSigmaPi < static_cast(dileptoncuts.cfg_min_TPCNsigmaPi) || static_cast(dileptoncuts.cfg_max_TPCNsigmaPi) < o2::aod::pidtpc::tpcNSigmaPi); + Filter trackFilter = dileptoncuts.cfg_min_pt_track < o2::aod::track::pt && nabs(o2::aod::track::eta) < dileptoncuts.cfg_max_eta_track && o2::aod::track::tpcChi2NCl < dileptoncuts.cfg_max_chi2tpc && o2::aod::track::itsChi2NCl < dileptoncuts.cfg_max_chi2its && nabs(o2::aod::track::dcaXY) < dileptoncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dileptoncuts.cfg_max_dcaz; + Filter pidFilter = dileptoncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dileptoncuts.cfg_max_TPCNsigmaEl && (o2::aod::pidtpc::tpcNSigmaPi < dileptoncuts.cfg_min_TPCNsigmaPi || dileptoncuts.cfg_max_TPCNsigmaPi < o2::aod::pidtpc::tpcNSigmaPi); using FilteredMyTracks = soa::Filtered; Partition posTracks = o2::aod::emprimaryelectron::sign > int8_t(0); Partition negTracks = o2::aod::emprimaryelectron::sign < int8_t(0); diff --git a/PWGEM/PhotonMeson/Tasks/dalitzEEQCMC.cxx b/PWGEM/PhotonMeson/Tasks/dalitzEEQCMC.cxx index 0f8e539f323..adc556bf78d 100644 --- a/PWGEM/PhotonMeson/Tasks/dalitzEEQCMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/dalitzEEQCMC.cxx @@ -14,28 +14,29 @@ // This code runs loop over dalitz ee table for dalitz QC. // Please write to: daiki.sekihata@cern.ch -#include -#include +#include "PWGEM/Dilepton/Utils/MCUtilities.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" +#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" +#include "Common/Core/RecoDecay.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" -#include "Common/Core/RecoDecay.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" -#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" -#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" -#include "PWGEM/Dilepton/Utils/MCUtilities.h" -#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "Math/Vector4D.h" +#include "TString.h" + +#include +#include using namespace o2; using namespace o2::aod; @@ -45,7 +46,7 @@ using namespace o2::soa; using namespace o2::aod::pwgem::photonmeson::utils::mcutil; using namespace o2::aod::pwgem::dilepton::utils::mcutil; -using MyCollisions = soa::Join; +using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; using MyMCTracks = soa::Join; @@ -64,6 +65,7 @@ struct DalitzEEQCMC { Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; Configurable maxY{"maxY", 0.9, "maximum rapidity for reconstructed particles"}; + Configurable cfgRequireTrueAssociation{"cfgRequireTrueAssociation", false, "flag to require true mc collision association"}; EMPhotonEventCut fEMEventCut; struct : ConfigurableGroup { @@ -84,9 +86,8 @@ struct DalitzEEQCMC { struct : ConfigurableGroup { std::string prefix = "dileptoncut_group"; Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; - Configurable cfg_max_mass{"cfg_max_mass", 1e+10, "max mass"}; + Configurable cfg_max_mass{"cfg_max_mass", 0.02, "max mass"}; Configurable cfg_apply_phiv{"cfg_apply_phiv", true, "flag to apply phiv cut"}; - Configurable cfg_apply_pf{"cfg_apply_pf", false, "flag to apply phiv prefilter"}; Configurable cfg_require_itsib_any{"cfg_require_itsib_any", true, "flag to require ITS ib any hits"}; Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", false, "flag to require ITS ib 1st hit"}; Configurable cfg_phiv_slope{"cfg_phiv_slope", 0.0185, "slope for m vs. phiv"}; @@ -97,16 +98,22 @@ struct DalitzEEQCMC { Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 70, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1.0, "max dca XY for single track in cm"}; Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.0, "max dca Z for single track in cm"}; + Configurable cfg_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1.5, "max DCA 3D in sigma"}; + Configurable includeITSsa{"includeITSsa", false, "Flag to enable ITSsa tracks"}; + Configurable cfg_max_pt_track_ITSsa{"cfg_max_pt_track_ITSsa", 0.15, "max pt for ITSsa tracks"}; - Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTPConly), "pid scheme [kTPConly : 0]"}; + Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTOFif), "pid scheme [kTOFif : 0, kTPConly : 1]"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; - Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -1e+10, "min. TPC n sigma for pion exclusion"}; - Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +3.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", -0.0, "min. TPC n sigma for pion exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", +0.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; } dileptoncuts; o2::ccdb::CcdbApi ccdbApi; @@ -123,6 +130,7 @@ struct DalitzEEQCMC { HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; static constexpr std::string_view event_cut_types[2] = {"before/", "after/"}; + static constexpr std::string_view track_types[2] = {"primary/", "secondary/"}; ~DalitzEEQCMC() {} @@ -131,21 +139,8 @@ struct DalitzEEQCMC { // event info o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry); - std::vector ptbins; - std::vector massbins; - - for (int i = 0; i < 51; i++) { - massbins.emplace_back(0.01 * (i - 0) + 0.0); // every 0.01 GeV/c2 from 0.0 to 0.5 GeV/c2 - } - const AxisSpec axis_mass{massbins, "m_{ee} (GeV/c^{2})"}; - - for (int i = 0; i < 50; i++) { - ptbins.emplace_back(0.1 * (i - 0) + 0.0); // every 0.1 GeV/c from 0.0 to 5.0 GeV/c - } - for (int i = 50; i < 61; i++) { - ptbins.emplace_back(0.5 * (i - 50) + 5.0); // every 0.5 GeV/c from 5.0 to 10 GeV/c - } - const AxisSpec axis_pt{ptbins, "p_{T,ee} (GeV/c)"}; + const AxisSpec axis_mass{200, 0, 0.2, "m_{ee} (GeV/c^{2})"}; + const AxisSpec axis_pt{200, 0, 2, "p_{T,ee} (GeV/c)"}; // generated info fRegistry.add("Generated/sm/Pi0/hMvsPt", "m_{ee} vs. p_{T,ee} ULS", kTH2F, {axis_mass, axis_pt}, true); @@ -166,22 +161,37 @@ struct DalitzEEQCMC { fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Phi/"); // track info - fRegistry.add("Track/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, false); - fRegistry.add("Track/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -1.0f, 1.0f}, {200, -1.0f, 1.0f}}, false); - fRegistry.add("Track/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("Track/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("Track/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("Track/hMeanClusterSizeITS", "mean cluster size ITS; on ITS #times cos(#lambda)", kTH1F, {{32, 0, 16}}, false); + fRegistry.add("Track/primary/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); + fRegistry.add("Track/primary/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); + fRegistry.add("Track/primary/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, false); + fRegistry.add("Track/primary/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -0.1f, 0.1f}, {200, -0.1f, 0.1f}}, false); + fRegistry.add("Track/primary/hDCAxyzSigma", "DCA xy vs. z;DCA_{xy} (#sigma);DCA_{z} (#sigma)", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}, false); + fRegistry.add("Track/primary/hDCAxyRes_Pt", "DCA_{xy} resolution vs. pT;p_{T} (GeV/c);DCA_{xy} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/primary/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{200, 0, 10}, {500, 0., 500}}, false); + fRegistry.add("Track/primary/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); + fRegistry.add("Track/primary/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); + fRegistry.add("Track/primary/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/primary/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/primary/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("Track/primary/hTPCNclsShared", "TPC Ncls shared/Ncls;p_{T} (GeV/c);N_{cls}^{shared}/N_{cls} in TPC", kTH2F, {{1000, 0, 10}, {100, 0, 1}}, false); + + fRegistry.add("Track/primary/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); + fRegistry.add("Track/primary/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/primary/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + + fRegistry.add("Track/primary/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); + fRegistry.add("Track/primary/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/primary/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); + fRegistry.add("Track/primary/hMeanClusterSizeITS", "mean cluster size ITS; on ITS #times cos(#lambda)", kTH1F, {{32, 0, 16}}, false); + + fRegistry.add("Track/primary/hChi2TOF", "chi2 of TOF", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/primary/hTOFbeta", "TOF beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, false); + fRegistry.add("Track/primary/hTOFNsigmaEl", "TOF n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/primary/hTOFNsigmaPi", "TOF n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/primary/hPtGen_DeltaPtOverPtGen", "electron p_{T} resolution;p_{T}^{gen} (GeV/c);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{1000, 0, 10}, {200, -1.0f, 1.0f}}, true); + fRegistry.add("Track/primary/hPtGen_DeltaEta", "electron #eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{1000, 0, 10}, {100, -0.5f, 0.5f}}, true); + fRegistry.add("Track/primary/hPtGen_DeltaPhi", "electron #varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{1000, 0, 10}, {100, -0.5f, 0.5f}}, true); + fRegistry.addClone("Track/primary/", "Track/secondary/"); } void init(InitContext&) @@ -210,7 +220,7 @@ struct DalitzEEQCMC { if (d_bz_input > -990) { d_bz = d_bz_input; o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { + if (std::fabs(d_bz) > 1e-5) { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } mRunNumber = collision.runNumber(); @@ -268,16 +278,20 @@ struct DalitzEEQCMC { fDileptonCut.SetMinNClustersTPC(dileptoncuts.cfg_min_ncluster_tpc); fDileptonCut.SetMinNCrossedRowsTPC(dileptoncuts.cfg_min_ncrossedrows); fDileptonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fDileptonCut.SetMaxFracSharedClustersTPC(dileptoncuts.cfg_max_frac_shared_clusters_tpc); fDileptonCut.SetChi2PerClusterTPC(0.0, dileptoncuts.cfg_max_chi2tpc); fDileptonCut.SetChi2PerClusterITS(0.0, dileptoncuts.cfg_max_chi2its); fDileptonCut.SetNClustersITS(dileptoncuts.cfg_min_ncluster_its, 7); fDileptonCut.SetMaxDcaXY(dileptoncuts.cfg_max_dcaxy); fDileptonCut.SetMaxDcaZ(dileptoncuts.cfg_max_dcaz); + fDileptonCut.SetTrackDca3DRange(0.f, dileptoncuts.cfg_max_dca3dsigma_track); // in sigma + fDileptonCut.IncludeITSsa(dileptoncuts.includeITSsa, dileptoncuts.cfg_max_pt_track_ITSsa); // for eID fDileptonCut.SetPIDScheme(dileptoncuts.cfg_pid_scheme); fDileptonCut.SetTPCNsigmaElRange(dileptoncuts.cfg_min_TPCNsigmaEl, dileptoncuts.cfg_max_TPCNsigmaEl); fDileptonCut.SetTPCNsigmaPiRange(dileptoncuts.cfg_min_TPCNsigmaPi, dileptoncuts.cfg_max_TPCNsigmaPi); + fDileptonCut.SetTOFNsigmaElRange(dileptoncuts.cfg_min_TOFNsigmaEl, dileptoncuts.cfg_max_TOFNsigmaEl); } template @@ -301,7 +315,7 @@ struct DalitzEEQCMC { template bool isInAcceptance(T const& t1) { - if ((mctrackcuts.min_mcPt < t1.pt() && t1.pt() < mctrackcuts.max_mcPt) && abs(t1.eta()) < mctrackcuts.max_mcEta) { + if ((mctrackcuts.min_mcPt < t1.pt() && t1.pt() < mctrackcuts.max_mcPt) && std::fabs(t1.eta()) < mctrackcuts.max_mcEta) { return true; } else { return false; @@ -309,7 +323,7 @@ struct DalitzEEQCMC { } template - bool fillTruePairInfo(TCollision const&, TTrack1 const& t1, TTrack2 const& t2, TMCParticles const& mcparticles) + bool fillTruePairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TMCParticles const& mcparticles) { if (!fDileptonCut.IsSelectedTrack(t1) || !fDileptonCut.IsSelectedTrack(t2)) { return false; @@ -323,55 +337,114 @@ struct DalitzEEQCMC { auto t2mc = t2.template emmcparticle_as(); int mother_id = FindLF(t1mc, t2mc, mcparticles); - int hfee_type = IsHF(t1mc, t2mc, mcparticles); - if (mother_id < 0 && hfee_type < 0) { + if (mother_id < 0) { return false; } ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (abs(v12.Rapidity()) > maxY) { + if (std::fabs(v12.Rapidity()) > maxY) { return false; } float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz(), t1.sign(), t2.sign(), d_bz); if (mother_id > -1 && t1mc.pdgCode() * t2mc.pdgCode() < 0) { auto mcmother = mcparticles.iteratorAt(mother_id); + if (cfgRequireTrueAssociation && (mcmother.emmceventId() != collision.emmceventId())) { + return false; + } + if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { if ((t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && (t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { - switch (abs(mcmother.pdgCode())) { + switch (std::abs(mcmother.pdgCode())) { case 111: fRegistry.fill(HIST("Pair/sm/Pi0/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/sm/Pi0/hMvsPhiV"), phiv, v12.M()); + if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t1.globalIndex()); + fillTrackInfo<0>(t1); + } + if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t2.globalIndex()); + fillTrackInfo<0>(t2); + } break; case 221: fRegistry.fill(HIST("Pair/sm/Eta/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/sm/Eta/hMvsPhiV"), phiv, v12.M()); + if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t1.globalIndex()); + fillTrackInfo<0>(t1); + } + if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t2.globalIndex()); + fillTrackInfo<0>(t2); + } break; case 331: fRegistry.fill(HIST("Pair/sm/EtaPrime/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/sm/EtaPrime/hMvsPhiV"), phiv, v12.M()); + if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t1.globalIndex()); + fillTrackInfo<0>(t1); + } + if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t2.globalIndex()); + fillTrackInfo<0>(t2); + } break; case 113: fRegistry.fill(HIST("Pair/sm/Rho/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/sm/Rho/hMvsPhiV"), phiv, v12.M()); + if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t1.globalIndex()); + fillTrackInfo<0>(t1); + } + if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t2.globalIndex()); + fillTrackInfo<0>(t2); + } break; case 223: fRegistry.fill(HIST("Pair/sm/Omega/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/sm/Omega/hMvsPhiV"), phiv, v12.M()); + if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t1.globalIndex()); + fillTrackInfo<0>(t1); + } + if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t2.globalIndex()); + fillTrackInfo<0>(t2); + } break; case 333: fRegistry.fill(HIST("Pair/sm/Phi/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/sm/Phi/hMvsPhiV"), phiv, v12.M()); + if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t1.globalIndex()); + fillTrackInfo<0>(t1); + } + if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t2.globalIndex()); + fillTrackInfo<0>(t2); + } break; default: break; } } else if (!(t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && !(t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { - switch (abs(mcmother.pdgCode())) { + switch (std::abs(mcmother.pdgCode())) { case 22: fRegistry.fill(HIST("Pair/sm/Photon/hMvsPt"), v12.M(), v12.Pt()); fRegistry.fill(HIST("Pair/sm/Photon/hMvsPhiV"), phiv, v12.M()); + if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t1.globalIndex()); + fillTrackInfo<1>(t1); + } + if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t2.globalIndex()); + fillTrackInfo<1>(t2); + } break; default: break; @@ -379,60 +452,46 @@ struct DalitzEEQCMC { } // end of primary/secondary selection } // end of primary selection for same mother } - - // fill track info that belong to true pairs. - if (t1.sign() > 0) { - if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { - used_trackIds.emplace_back(t1.globalIndex()); - fillTrackInfo(t1); - } - } else { - if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { - used_trackIds.emplace_back(t1.globalIndex()); - fillTrackInfo(t1); - } - } - if (t2.sign() > 0) { - if (std::find(used_trackIds.begin(), used_trackIds.end(), t1.globalIndex()) == used_trackIds.end()) { - used_trackIds.emplace_back(t1.globalIndex()); - fillTrackInfo(t2); - } - } else { - if (std::find(used_trackIds.begin(), used_trackIds.end(), t2.globalIndex()) == used_trackIds.end()) { - used_trackIds.emplace_back(t2.globalIndex()); - fillTrackInfo(t2); - } - } - return true; } - template + template void fillTrackInfo(TTrack const& track) { - fRegistry.fill(HIST("Track/hPt"), track.pt()); - fRegistry.fill(HIST("Track/hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); - fRegistry.fill(HIST("Track/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); - fRegistry.fill(HIST("Track/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); + auto mctrack = track.template emmcparticle_as(); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hPt"), track.pt()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hQoverPt"), track.sign() / track.pt()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hEtaPhi"), track.phi(), track.eta()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hDCAxyz"), track.dcaXY(), track.dcaZ()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hDCAxyzSigma"), track.dcaXY() / std::sqrt(track.cYY()), track.dcaZ() / std::sqrt(track.cZZ())); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hDCAxyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hDCAzRes_Pt"), track.pt(), std::sqrt(track.cZZ()) * 1e+4); // convert cm to um + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hNclsITS"), track.itsNCls()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hNclsTPC"), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hNcrTPC"), track.tpcNClsCrossedRows()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hTPCNclsShared"), track.pt(), track.tpcFractionSharedCls()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hITSClusterMap"), track.itsClusterMap()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hMeanClusterSizeITS"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hTOFNsigmaEl"), track.p(), track.tofNSigmaEl()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hTOFNsigmaPi"), track.p(), track.tofNSigmaPi()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hTOFbeta"), track.p(), track.beta()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hPtGen_DeltaPtOverPtGen"), mctrack.pt(), (track.pt() - mctrack.pt()) / mctrack.pt()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hPtGen_DeltaEta"), mctrack.pt(), track.eta() - mctrack.eta()); + fRegistry.fill(HIST("Track/") + HIST(track_types[tracktype]) + HIST("hPtGen_DeltaPhi"), mctrack.pt(), track.phi() - mctrack.phi()); } std::vector used_trackIds; SliceCache cache; Preslice perCollision_track = aod::emprimaryelectron::emeventId; - Filter trackFilter = static_cast(dileptoncuts.cfg_min_pt_track) < o2::aod::track::pt && nabs(o2::aod::track::eta) < static_cast(dileptoncuts.cfg_max_eta_track) && o2::aod::track::tpcChi2NCl < static_cast(dileptoncuts.cfg_max_chi2tpc) && o2::aod::track::itsChi2NCl < static_cast(dileptoncuts.cfg_max_chi2its) && nabs(o2::aod::track::dcaXY) < static_cast(dileptoncuts.cfg_max_dcaxy) && nabs(o2::aod::track::dcaZ) < static_cast(dileptoncuts.cfg_max_dcaz); - Filter pidFilter = (static_cast(dileptoncuts.cfg_min_TPCNsigmaEl) < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < static_cast(dileptoncuts.cfg_max_TPCNsigmaEl)) && (o2::aod::pidtpc::tpcNSigmaPi < static_cast(dileptoncuts.cfg_min_TPCNsigmaPi) || static_cast(dileptoncuts.cfg_max_TPCNsigmaPi) < o2::aod::pidtpc::tpcNSigmaPi); + Filter trackFilter = dileptoncuts.cfg_min_pt_track < o2::aod::track::pt && nabs(o2::aod::track::eta) < dileptoncuts.cfg_max_eta_track && o2::aod::track::tpcChi2NCl < dileptoncuts.cfg_max_chi2tpc && o2::aod::track::itsChi2NCl < dileptoncuts.cfg_max_chi2its && nabs(o2::aod::track::dcaXY) < dileptoncuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < dileptoncuts.cfg_max_dcaz; + Filter pidFilter = dileptoncuts.cfg_min_TPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < dileptoncuts.cfg_max_TPCNsigmaEl && (o2::aod::pidtpc::tpcNSigmaPi < dileptoncuts.cfg_min_TPCNsigmaPi || dileptoncuts.cfg_max_TPCNsigmaPi < o2::aod::pidtpc::tpcNSigmaPi); using FilteredMyMCTracks = soa::Filtered; Partition posTracks = o2::aod::emprimaryelectron::sign > int8_t(0); Partition negTracks = o2::aod::emprimaryelectron::sign < int8_t(0); @@ -518,15 +577,14 @@ struct DalitzEEQCMC { } int mother_id = FindLF(t1, t2, mcparticles); - int hfee_type = IsHF(t1, t2, mcparticles); - if (mother_id < 0 && hfee_type < 0) { + if (mother_id < 0) { continue; } ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (abs(v12.Rapidity()) > maxY) { + if (std::fabs(v12.Rapidity()) > maxY) { continue; } @@ -534,7 +592,7 @@ struct DalitzEEQCMC { auto mcmother = mcparticles.iteratorAt(mother_id); if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { - switch (abs(mcmother.pdgCode())) { + switch (std::abs(mcmother.pdgCode())) { case 111: fRegistry.fill(HIST("Generated/sm/Pi0/hMvsPt"), v12.M(), v12.Pt()); break; diff --git a/PWGEM/PhotonMeson/Tasks/diphotonHadronMPCPCMDalitzEE.cxx b/PWGEM/PhotonMeson/Tasks/diphotonHadronMPCPCMDalitzEE.cxx new file mode 100644 index 00000000000..a3a7b548894 --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/diphotonHadronMPCPCMDalitzEE.cxx @@ -0,0 +1,36 @@ +// 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. +// +// ======================== +// +// This code loops over photons and makes pairs for neutral mesons analyses. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/PhotonMeson/Core/DiphotonHadronMPC.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" + +#include "Common/Core/RecoDecay.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::aod; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"diphoton-hadron-mpc-pcmdalitzee"}), + }; +} diff --git a/PWGEM/PhotonMeson/Tasks/diphotonHadronMPCPCMPCM.cxx b/PWGEM/PhotonMeson/Tasks/diphotonHadronMPCPCMPCM.cxx new file mode 100644 index 00000000000..6f0dfff7c2f --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/diphotonHadronMPCPCMPCM.cxx @@ -0,0 +1,34 @@ +// 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. +// +// ======================== +// +// This code loops over photons and makes pairs for neutral mesons analyses. +// Please write to: daiki.sekihata@cern.ch + +#include "PWGEM/PhotonMeson/Core/DiphotonHadronMPC.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::aod; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"diphoton-hadron-mpc-pcmpcm"}), + }; +} diff --git a/PWGEM/PhotonMeson/Tasks/emcalBcWiseGammaGamma.cxx b/PWGEM/PhotonMeson/Tasks/emcalBcWiseGammaGamma.cxx new file mode 100644 index 00000000000..0aacd233324 --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/emcalBcWiseGammaGamma.cxx @@ -0,0 +1,366 @@ +// Copyright 2019-2025 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. +// +/// +/// \file emcalBcWiseGammaGamma.cxx +/// +/// \brief Task that extracts pi0s and eta mesons from BC wise derived data of EMCal clusters +/// +/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) Goethe University Frankfurt +/// + +#include "PWGEM/PhotonMeson/DataModel/bcWiseTables.h" + +#include "CommonConstants/MathConstants.h" +#include "EMCALBase/Geometry.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "Math/AxisAngle.h" +#include "Math/LorentzRotation.h" +#include "Math/Rotation3D.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TString.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using SelectedClusters = soa::Filtered; +using SelectedMCClusters = soa::Filtered>; + +struct EmcalBcWiseGammaGamma { + HistogramRegistry mHistManager{"EmcalGammaGammaBcWiseHistograms"}; + + Configurable cfgRequirekTVXinEMC{"cfgRequirekTVXinEMC", true, "Reconstruct mesons only in kTVXinEMC triggered BCs"}; + Configurable cfgRequireEMCCell{"cfgRequireEMCCell", true, "Reconstruct mesons only in BCs containing at least one EMCal cell (workaround for kTVXinEMC trigger)"}; + Configurable cfgSelectOnlyUniqueAmbiguous{"cfgSelectOnlyUniqueAmbiguous", 0, "0: all clusters, 1: only unique clusters, 2: only ambiguous clusters"}; + + Configurable cfgClusterDefinition{"cfgClusterDefinition", 13, "Clusterizer to be selected, e.g. 13 for kV3MostSplitLowSeed"}; + Configurable cfgMinClusterEnergy{"cfgMinClusterEnergy", 700, "Minimum energy of selected clusters (MeV)"}; + Configurable cfgMinM02{"cfgMinM02", 1000, "Minimum M02 of selected clusters (x1000)"}; + Configurable cfgMaxM02{"cfgMaxM02", 7000, "Maximum M02 of selected clusters (x1000)"}; + Configurable cfgMinTime{"cfgMinTime", -1500, "Minimum time of selected clusters (10 ps)"}; + Configurable cfgMaxTime{"cfgMaxTime", 1500, "Maximum time of selected clusters (10 ps)"}; + Configurable cfgRapidityCut{"cfgRapidityCut", 0.8f, "Maximum absolute rapidity of counted particles"}; + Configurable cfgMinOpenAngle{"cfgMinOpenAngle", 0.0202, "Minimum opening angle between photons"}; + Configurable cfgDistanceToEdge{"cfgDistanceToEdge", 1, "Distance to edge in cells required for rotated cluster to be accepted"}; + Configurable cfgBGEventDownsampling{"cfgBGEventDownsampling", 1, "Only calculate background for every n-th event (performance reasons in PbPb)"}; + Configurable cfgMinTimeSinceSOF{"cfgMinTimeSinceSOF", -1, "Only analyze events with a time since start of fill larger than this value (in minutes)"}; + Configurable cfgMaxTimeSinceSOF{"cfgMaxTimeSinceSOF", 100000, "Only analyze events with a time since start of fill smaller than this value (in minutes)"}; + + ConfigurableAxis cfgCentralityBinning{"cfgCentralityBinning", {VARIABLE_WIDTH, 0.f, 5.f, 10.f, 20.f, 30.f, 40.f, 50.f, 60.f, 70.f, 80.f, 90.f, 100.f, 101.f, 102.f}, "FT0M centrality (%)"}; + + Configurable cfgIsMC{"cfgIsMC", false, "Flag to indicate if the task is running on MC data and should fill MC histograms"}; + + Filter clusterDefinitionFilter = aod::bcwisecluster::storedDefinition == cfgClusterDefinition; + Filter energyFilter = aod::bcwisecluster::storedE > cfgMinClusterEnergy; + Filter m02Filter = (aod::bcwisecluster::storedNCells == 1 || (aod::bcwisecluster::storedM02 > cfgMinM02 && aod::bcwisecluster::storedM02 < cfgMaxM02)); + Filter timeFilter = (aod::bcwisecluster::storedTime > cfgMinTime && aod::bcwisecluster::storedTime < cfgMaxTime); + + emcal::Geometry* emcalGeom; + + void init(InitContext const&) + { + emcalGeom = emcal::Geometry::GetInstanceFromRunNumber(300000); + const int nEventBins = 6; + mHistManager.add("Event/nBCs", "Number of BCs;;#bf{FT0M centrality (%)};#bf{#it{N}_{BC}}", HistType::kTH2F, {{nEventBins, -0.5, 5.5}, cfgCentralityBinning}); + mHistManager.add("Event/nCollisions", "Number of Collisions (BCs x P(mu));;#bf{FT0M centrality (%)};#bf{#it{N}_{coll}}", HistType::kTH2F, {{nEventBins, -0.5, 5.5}, cfgCentralityBinning}); + const TString binLabels[nEventBins] = {"All", "FT0", "TVX", "kTVXinEMC", "Cell", "Cluster"}; + for (int iBin = 0; iBin < nEventBins; iBin++) { + mHistManager.get(HIST("Event/nBCs"))->GetXaxis()->SetBinLabel(iBin + 1, binLabels[iBin]); + mHistManager.get(HIST("Event/nCollisions"))->GetXaxis()->SetBinLabel(iBin + 1, binLabels[iBin]); + } + + mHistManager.add("Event/nCollPerBC", "Number of collisions per BC;#bf{#it{N}_{coll}};#bf{FT0M centrality (%)};#bf{#it{N}_{BC}}", HistType::kTH2F, {{5, -0.5, 4.5}, cfgCentralityBinning}); + mHistManager.add("Event/Z1VsZ2", "Z vertex positions for BCs with two collisions;#bf{#it{z}_{vtx}^{1} (cm)};#bf{#it{z}_{vtx}^{2} (cm)}", HistType::kTH2F, {{150, -15, 15}, {150, -15, 15}}); + mHistManager.add("Event/dZ", "Distance between vertices for BCs with two collisions;#bf{#Delta #it{z}_{vtx} (cm)};#bf{#it{N}_{BC}}", HistType::kTH1F, {{600, -30, 30}}); + mHistManager.add("Event/Mu", "Probablity of a collision in the BC;#bf{#mu};#bf{#it{N}_{BC}}", HistType::kTH1F, {{2000, 0., 0.4}}); + mHistManager.add("Event/TimeSinceSOF", "Time of BC since the start of fill;#bf{t-t_{SOF} (min)};#bf{#it{N}_{BC}}", HistType::kTH1F, {{2400, 0., 1200}}); + + mHistManager.add("Event/Centrality", "FT0M centrality;FT0M centrality (%);#bf{#it{N}_{BC}}", HistType::kTH1F, {cfgCentralityBinning}); + mHistManager.add("Event/CentralityVsAmplitude", "FT0M AmplitudeVsCentrality;FT0M Centrality;FT0M Amplitude", HistType::kTH2F, {cfgCentralityBinning, {600, 0, 300000}}); + + mHistManager.add("Cluster/E", "Energy of cluster;#bf{#it{E} (GeV)};#bf{FT0M centrality (%)};#bf{#it{N}_{clusters}}", HistType::kTH2F, {{200, 0, 20}, cfgCentralityBinning}); + mHistManager.add("Cluster/M02", "Shape of cluster;#bf{#it{M}_{02}};#bf{FT0M centrality (%)};#bf{#it{N}_{clusters}}", HistType::kTH2F, {{200, 0, 2}, cfgCentralityBinning}); + mHistManager.add("Cluster/Time", "Time of cluster;#bf{#it{t} (ns)};#bf{FT0M centrality (%)};#bf{#it{N}_{clusters}}", HistType::kTH2F, {{200, -100, 100}, cfgCentralityBinning}); + mHistManager.add("Cluster/NCells", "Number of cells per cluster;#bf{#it{N}_{cells}};#bf{FT0M centrality (%)};#bf{#it{N}_{clusters}}", HistType::kTH2F, {{51, 0., 50.5}, cfgCentralityBinning}); + mHistManager.add("Cluster/Exotic", "Is cluster exotic?;#bf{Exotic?};#bf{FT0M centrality (%)};#bf{#it{N}_{clusters}}", HistType::kTH2F, {{2, -0.5, 1.5}, cfgCentralityBinning}); + mHistManager.add("Cluster/EtaPhi", "Eta/Phi distribution of clusters;#eta;#phi;#bf{FT0M centrality (%)};#bf{#it{N}_{clusters}}", HistType::kTH3F, {{400, -0.8, 0.8}, {400, 0, constants::math::TwoPI}, cfgCentralityBinning}); + + mHistManager.add("GG/invMassVsPt", "Invariant mass and pT of meson candidates;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{400, 0., 0.8}, {300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("GG/invMassVsPtBackground", "Invariant mass and pT of background meson candidates;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{400, 0., 0.8}, {300, 0, 30}, cfgCentralityBinning}); + + if (cfgIsMC) { + mHistManager.add("True/clusterERecVsETrue", "True vs reconstructed energy of cluster inducing particle;#bf{#it{E}_{rec} (GeV)};#bf{#it{E}_{true}^{cls inducing part} (GeV)};#bf{FT0M centrality (%)}", HistType::kTH3F, {{200, 0, 20}, {200, 0, 20}, cfgCentralityBinning}); + mHistManager.add("True/pi0_PtRecVsPtTrue", "True vs reconstructed pT of true pi0s;#bf{#it{p}_{T}^{rec} (GeV/#it{c})};#bf{#it{p}_{T}^{true} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{300, 0, 30}, {300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("True/pi0_invMassVsPt_Primary", "Reconstructed validated primary pi0;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{400, 0., 0.8}, {300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("True/pi0_invMassVsPt_Secondary", "Reconstructed validated pi0 from secondary decay;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{400, 0., 0.8}, {300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("True/pi0_invMassVsPt_HadronicShower", "Reconstructed validated pi0 from hadronic shower;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{400, 0., 0.8}, {300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("True/eta_PtRecVsPtTrue", "True vs reconstructed pT of true eta meson;#bf{#it{p}_{T}^{rec} (GeV/#it{c})};#bf{#it{p}_{T}^{true} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{300, 0, 30}, {300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("True/eta_invMassVsPt_Primary", "Reconstructed validated primary eta meson;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{400, 0., 0.8}, {300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("True/eta_invMassVsPt_Secondary", "Reconstructed validated eta meson from secondary decay;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{400, 0., 0.8}, {300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("True/eta_invMassVsPt_HadronicShower", "Reconstructed validated eta meson from hadronic shower;#bf{#it{M}^{#gamma#gamma} (GeV/#it{c}^{2})};#bf{#it{p}_{T}^{#gamma#gamma} (GeV/#it{c})};#bf{FT0M centrality (%)}", HistType::kTH3F, {{400, 0., 0.8}, {300, 0, 30}, cfgCentralityBinning}); + + mHistManager.add("Generated/pi0_AllBCs", "pT spectrum of generated pi0s in all BCs;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#pi^{0}}^{gen}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("Generated/pi0_FT0", "pT spectrum of generated pi0s in BCs with found FT0;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#pi^{0}}^{gen}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("Generated/pi0_TVX", "pT spectrum of generated pi0s in TVX triggered BCs;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#pi^{0}}^{gen}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("Generated/pi0_kTVXinEMC", "pT spectrum of generated pi0s in kTVXinEMC triggered BCs;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#pi^{0}}^{gen}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("Accepted/pi0_kTVXinEMC", "pT spectrum of accepted pi0s in kTVXinEMC triggered BCs;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#pi^{0}}^{acc}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("Generated/eta_AllBCs", "pT spectrum of generated eta mesons in all BCs;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#eta}^{gen}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("Generated/eta_FT0", "pT spectrum of generated eta mesons in BCs with found FT0;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#eta}^{gen}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("Generated/eta_TVX", "pT spectrum of generated eta mesons in TVX triggered BCs;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#eta}^{gen}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("Generated/eta_kTVXinEMC", "pT spectrum of generated eta mesons in kTVXinEMC triggered BCs;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#eta}^{gen}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + mHistManager.add("Accepted/eta_kTVXinEMC", "pT spectrum of accepted eta mesons in kTVXinEMC triggered BCs;#bf{#it{p}_{T} (GeV/#it{c})};#bf{FT0M centrality (%)};#bf{#it{N}_{#eta}^{acc}}", HistType::kTH2F, {{300, 0, 30}, cfgCentralityBinning}); + } + } + + /// \brief returns if cluster is too close to edge of EMCal + bool isTooCloseToEdge(const int cellID, const int DistanceToBorder = 1) + { + if (DistanceToBorder <= 0) + return false; + if (cellID < 0) + return true; + + // check distance to border in case the cell is okay + auto [iSupMod, iMod, iPhi, iEta] = emcalGeom->GetCellIndex(cellID); + auto [irow, icol] = emcalGeom->GetCellPhiEtaIndexInSModule(iSupMod, iMod, iPhi, iEta); + int iRowLast = (emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::EMCAL_THIRD || emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::DCAL_EXT) ? 8 : 24; + + return (irow < DistanceToBorder || (iRowLast - irow) <= DistanceToBorder); + } + + void fillEventHists(const auto& bc, const auto& collisions, const auto& clusters) + { + mHistManager.fill(HIST("Event/nBCs"), 0, bc.centrality()); + float mu = bc.mu(); + mHistManager.fill(HIST("Event/Mu"), mu); + mHistManager.fill(HIST("Event/TimeSinceSOF"), bc.timeSinceSOF() / 60.); + double p = mu > 0.001 ? mu / (1 - std::exp(-mu)) : 1.; // No pile-up for small mu (protection against division by zero) + mHistManager.fill(HIST("Event/nCollisions"), 0, bc.centrality(), p); + if (bc.hasFT0()) { + mHistManager.fill(HIST("Event/nBCs"), 1, bc.centrality()); + mHistManager.fill(HIST("Event/nCollisions"), 1, bc.centrality(), p); + } + if (bc.hasTVX()) { + mHistManager.fill(HIST("Event/nBCs"), 2, bc.centrality()); + mHistManager.fill(HIST("Event/nCollisions"), 2, bc.centrality(), p); + } + if (bc.haskTVXinEMC()) { + mHistManager.fill(HIST("Event/nBCs"), 3, bc.centrality()); + mHistManager.fill(HIST("Event/nCollisions"), 3, bc.centrality(), p); + } + if (bc.hasEMCCell()) { + mHistManager.fill(HIST("Event/nBCs"), 4, bc.centrality()); + mHistManager.fill(HIST("Event/nCollisions"), 4, bc.centrality(), p); + } + if (clusters.size() > 0) { + mHistManager.fill(HIST("Event/nBCs"), 5, bc.centrality()); + mHistManager.fill(HIST("Event/nCollisions"), 5, bc.centrality(), p); + } + + mHistManager.fill(HIST("Event/Centrality"), bc.centrality()); + mHistManager.fill(HIST("Event/CentralityVsAmplitude"), bc.centrality(), bc.ft0Amplitude()); + + mHistManager.fill(HIST("Event/nCollPerBC"), collisions.size(), bc.centrality()); + if (collisions.size() == 2) { + mHistManager.fill(HIST("Event/Z1VsZ2"), collisions.iteratorAt(0).zVtx(), collisions.iteratorAt(1).zVtx()); + mHistManager.fill(HIST("Event/dZ"), collisions.iteratorAt(0).zVtx() - collisions.iteratorAt(1).zVtx()); + } + } + + void fillClusterHists(const auto& clusters, float centrality) + { + for (const auto& cluster : clusters) { + mHistManager.fill(HIST("Cluster/E"), cluster.e(), centrality); + mHistManager.fill(HIST("Cluster/M02"), cluster.m02(), centrality); + mHistManager.fill(HIST("Cluster/Time"), cluster.time(), centrality); + mHistManager.fill(HIST("Cluster/NCells"), cluster.nCells(), centrality); + mHistManager.fill(HIST("Cluster/EtaPhi"), cluster.eta(), cluster.phi(), centrality); + mHistManager.fill(HIST("Cluster/Exotic"), cluster.isExotic(), centrality); + } + } + + void reconstructMesons(const auto& clusters, const auto& bc) + { + for (const auto& [g1, g2] : soa::combinations(soa::CombinationsStrictlyUpperIndexPolicy(clusters, clusters))) { + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + if (std::fabs(v12.Rapidity()) > cfgRapidityCut) + continue; + + float openingAngle12 = std::acos(v1.Vect().Dot(v2.Vect()) / (v1.P() * v2.P())); + if (openingAngle12 < cfgMinOpenAngle) + continue; + + mHistManager.fill(HIST("GG/invMassVsPt"), v12.M(), v12.Pt(), bc.centrality()); + + if (clusters.size() < 3) + continue; + + if (bc.globalIndex() % cfgBGEventDownsampling != 0) + continue; + + // "else: Calculate background" + + ROOT::Math::AxisAngle rotationAxis(v12.Vect(), constants::math::PIHalf); + ROOT::Math::Rotation3D rotationMatrix(rotationAxis); + for (ROOT::Math::PtEtaPhiMVector vi : {v1, v2}) { + + vi = rotationMatrix * vi; + + try { + int iCellID = emcalGeom->GetAbsCellIdFromEtaPhi(vi.Eta(), vi.Phi()); + if (isTooCloseToEdge(iCellID, cfgDistanceToEdge)) + continue; + } catch (o2::emcal::InvalidPositionException& e) { + continue; + } + + for (const auto& g3 : clusters) { + if (g3.globalIndex() == g1.globalIndex() || g3.globalIndex() == g2.globalIndex()) + continue; + + ROOT::Math::PtEtaPhiMVector v3(g3.pt(), g3.eta(), g3.phi(), 0.); + + float openingAnglei3 = std::acos(vi.Vect().Dot(v3.Vect()) / (vi.P() * v3.P())); + if (openingAnglei3 < cfgMinOpenAngle) + continue; + + ROOT::Math::PtEtaPhiMVector vBG = v3 + vi; + + mHistManager.fill(HIST("GG/invMassVsPtBackground"), vBG.M(), vBG.Pt(), bc.centrality()); + } + } + } + } + void reconstructTrueMesons(const auto& clusters, const auto& mcPi0s, const auto& mcEtas, const auto& bc) + { + for (const auto& [g1, g2] : soa::combinations(soa::CombinationsStrictlyUpperIndexPolicy(clusters, clusters))) { + if (g1.mesonID() != g2.mesonID() || g1.mesonID() == -1) + continue; + + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + if (std::fabs(v12.Rapidity()) > cfgRapidityCut) + continue; + + float openingAngle12 = std::acos(v1.Vect().Dot(v2.Vect()) / (v1.P() * v2.P())); + if (openingAngle12 < cfgMinOpenAngle) + continue; + + if (!g1.isEta()) { + const auto& mcPi0 = mcPi0s.iteratorAt(g1.mesonID() - mcPi0s.offset()); + + mHistManager.fill(HIST("True/pi0_PtRecVsPtTrue"), v12.Pt(), mcPi0.pt(), bc.centrality()); + + if (mcPi0.isPrimary()) + mHistManager.fill(HIST("True/pi0_invMassVsPt_Primary"), v12.M(), v12.Pt(), bc.centrality()); + else if (mcPi0.isFromWD()) + mHistManager.fill(HIST("True/pi0_invMassVsPt_Secondary"), v12.M(), v12.Pt(), bc.centrality()); + else + mHistManager.fill(HIST("True/pi0_invMassVsPt_HadronicShower"), v12.M(), v12.Pt(), bc.centrality()); + } else { + const auto& mcEta = mcEtas.iteratorAt(g1.mesonID() - mcEtas.offset()); + + mHistManager.fill(HIST("True/eta_PtRecVsPtTrue"), v12.Pt(), mcEta.pt(), bc.centrality()); + + if (mcEta.isPrimary()) + mHistManager.fill(HIST("True/eta_invMassVsPt_Primary"), v12.M(), v12.Pt(), bc.centrality()); + else if (mcEta.isFromWD()) + mHistManager.fill(HIST("True/eta_invMassVsPt_Secondary"), v12.M(), v12.Pt(), bc.centrality()); + else + mHistManager.fill(HIST("True/eta_invMassVsPt_HadronicShower"), v12.M(), v12.Pt(), bc.centrality()); + } + } + } + + bool isBCSelected(const auto& bc, const auto& collisions) + { + if (cfgRequirekTVXinEMC && !bc.haskTVXinEMC()) + return false; + if (cfgRequireEMCCell && !bc.hasEMCCell()) + return false; + if (cfgSelectOnlyUniqueAmbiguous == 1 && collisions.size() != 1) + return false; + if (cfgSelectOnlyUniqueAmbiguous == 2 && collisions.size() == 1) + return false; + if (cfgMinTimeSinceSOF > bc.timeSinceSOF() / 60 || cfgMaxTimeSinceSOF < bc.timeSinceSOF() / 60) + return false; + return true; + } + + void fillGeneratedMesonHists(const auto& mcPi0s, const auto& mcEtas, const auto& bc) + { + for (const auto& mcPi0 : mcPi0s) { + if (mcPi0.isPrimary()) { + mHistManager.fill(HIST("Generated/pi0_AllBCs"), mcPi0.pt(), bc.centrality()); + if (bc.hasFT0()) + mHistManager.fill(HIST("Generated/pi0_FT0"), mcPi0.pt(), bc.centrality()); + if (bc.hasTVX()) + mHistManager.fill(HIST("Generated/pi0_TVX"), mcPi0.pt(), bc.centrality()); + if (bc.haskTVXinEMC()) + mHistManager.fill(HIST("Generated/pi0_kTVXinEMC"), mcPi0.pt(), bc.centrality()); + if (mcPi0.isAccepted() && bc.haskTVXinEMC()) + mHistManager.fill(HIST("Accepted/pi0_kTVXinEMC"), mcPi0.pt(), bc.centrality()); + } + } + for (const auto& mcEta : mcEtas) { + if (mcEta.isPrimary()) { + mHistManager.fill(HIST("Generated/eta_AllBCs"), mcEta.pt(), bc.centrality()); + if (bc.hasFT0()) + mHistManager.fill(HIST("Generated/eta_FT0"), mcEta.pt(), bc.centrality()); + if (bc.hasTVX()) + mHistManager.fill(HIST("Generated/eta_TVX"), mcEta.pt(), bc.centrality()); + if (bc.haskTVXinEMC()) + mHistManager.fill(HIST("Generated/eta_kTVXinEMC"), mcEta.pt(), bc.centrality()); + if (mcEta.isAccepted() && bc.haskTVXinEMC()) + mHistManager.fill(HIST("Accepted/eta_kTVXinEMC"), mcEta.pt(), bc.centrality()); + } + } + } + + void process(aod::BCWiseBCs::iterator const& bc, aod::BCWiseCollisions const& collisions, SelectedClusters const& clusters) + { + if (!isBCSelected(bc, collisions)) + return; + + fillEventHists(bc, collisions, clusters); + + fillClusterHists(clusters, bc.centrality()); + + reconstructMesons(clusters, bc); + } + + void processMCInfo(aod::BCWiseBCs::iterator const& bc, aod::BCWiseCollisions const& collisions, SelectedMCClusters const& clusters, aod::BCWiseMCPi0s const& mcPi0s, aod::BCWiseMCEtas const& mcEtas) + { + if (!cfgIsMC) + LOG(fatal) << "MC processing is not enabled, but the task is running on MC data. Please set cfgIsMC to true."; + + fillGeneratedMesonHists(mcPi0s, mcEtas, bc); // Fill before BC selection to also store pi0s and eta mesons in BCs that were not triggered + + if (!isBCSelected(bc, collisions)) + return; + + for (const auto& cluster : clusters) + mHistManager.fill(HIST("True/clusterERecVsETrue"), cluster.e(), cluster.trueE(), bc.centrality()); + + reconstructTrueMesons(clusters, mcPi0s, mcEtas, bc); + } + PROCESS_SWITCH(EmcalBcWiseGammaGamma, processMCInfo, "Run true and gen", false); +}; + +WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGEM/PhotonMeson/Tasks/emcalQC.cxx b/PWGEM/PhotonMeson/Tasks/emcalQC.cxx index e7a414b452a..6f298546c30 100644 --- a/PWGEM/PhotonMeson/Tasks/emcalQC.cxx +++ b/PWGEM/PhotonMeson/Tasks/emcalQC.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -18,28 +18,31 @@ /// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) Goethe University Frankfurt /// -#include -#include -#include -#include "TString.h" -#include "THashList.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/Core/RecoDecay.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "EMPhotonEventCut.h" + #include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" -#include "PWGEM/PhotonMeson/Core/CutsLibrary.h" -#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/PhotonMeson/Utils/ClusterHistograms.h" +#include "PWGEM/PhotonMeson/Utils/EventHistograms.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -166,26 +169,26 @@ struct EmcalQC { continue; } - fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 1); - if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { - fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 2); + fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 1, collision.weight()); + if (!eventcuts.cfgRequireFT0AND || collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 2, collision.weight()); if (std::abs(collision.posZ()) < eventcuts.cfgZvtxMax) { - fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 3); - if (collision.sel8()) { - fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 4); - if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 5); - if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 6); - if (collision.alias_bit(kTVXinEMC)) - fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 7); + fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 3, collision.weight()); + if (!eventcuts.cfgRequireSel8 || collision.sel8()) { + fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 4, collision.weight()); + if (!eventcuts.cfgRequireGoodZvtxFT0vsPV || collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 5, collision.weight()); + if (!eventcuts.cfgRequireNoSameBunchPileup || collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 6, collision.weight()); + if (!eventcuts.cfgRequireEMCReadoutInMB || collision.alias_bit(kTVXinEMC)) + fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 7, collision.weight()); } } } } } - o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision); + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, collision.weight()); if (!fEMEventCut.IsSelected(collision)) { continue; } @@ -193,19 +196,17 @@ struct EmcalQC { continue; } - o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0); // accepted + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, collision.weight()); + fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, collision.weight()); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, collision.weight()); // accepted auto clustersPerColl = clusters.sliceBy(perCollision, collision.collisionId()); fRegistry.fill(HIST("Cluster/before/hNgamma"), clustersPerColl.size(), collision.weight()); - int ngBefore = 0; int ngAfter = 0; for (const auto& cluster : clustersPerColl) { // Fill the cluster properties before applying any cuts if (!fEMCCut.IsSelectedEMCal(EMCPhotonCut::EMCPhotonCuts::kDefinition, cluster)) continue; - ngBefore++; o2::aod::pwgem::photonmeson::utils::clusterhistogram::fillClusterHistograms<0>(&fRegistry, cluster, cfgDo2DQA, collision.weight()); // Apply cuts one by one and fill in hClusterQualityCuts histogram @@ -233,7 +234,6 @@ struct EmcalQC { ngAfter++; } } - fRegistry.fill(HIST("Cluster/before/hNgamma"), ngBefore, collision.weight()); fRegistry.fill(HIST("Cluster/after/hNgamma"), ngAfter, collision.weight()); } // end of collision loop } // end of process diff --git a/PWGEM/PhotonMeson/Tasks/mcGeneratorStudies.cxx b/PWGEM/PhotonMeson/Tasks/mcGeneratorStudies.cxx new file mode 100644 index 00000000000..889858359ed --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/mcGeneratorStudies.cxx @@ -0,0 +1,55 @@ +// Copyright 2019-2025 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. +/// +/// \file mcGeneratorStudies.cxx +/// +/// \brief Task that produces the generated pT spectrum of a given particle for MC studies based on on the fly MC simulations +/// +/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) - Goethe University Frankfurt +/// + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" +#include "Framework/HistogramRegistry.h" + +#include "TDatabasePDG.h" + +using namespace o2; +using namespace o2::framework; + +struct MCGeneratorStudies { + HistogramRegistry mHistManager{"MCGeneratorStudyHistograms"}; + Configurable cfgSelectedParticleCode{"cfgSelectedParticleCode", 111, "PDG code of the particle to be investigated"}; + Configurable cfgMaxZVertex{"cfgMaxZVertex", 10, "Maximum absolute z-vertex distance (cm)"}; + Configurable cfgRapidityCut{"cfgRapidityCut", 0.8, "Maximum absolute rapditity of selected generated particles"}; + ConfigurableAxis cfgMultiplicityBinning{"cfgMultiplicityBinning", {1000, 0, 10000}, "Binning used for the binning of the number of particles in the event"}; + expressions::Filter zVertexFilter = aod::mccollision::posZ < cfgMaxZVertex && aod::mccollision::posZ > -cfgMaxZVertex; + + void init(InitContext const&) + { + mHistManager.add("Multiplicity", "Number of generated particles per MC collision;#bf{#it{N} (Multiplicity)};#bf{#it{N}_{MC collisions}}", HistType::kTH1F, {cfgMultiplicityBinning}); + mHistManager.add("YieldVsMultiplicity", "pT of selected particles in all MC collisions vs number of all generated particles in event;#bf{#it{p}_{T} (GeV/#it{c})};#bf{#it{N} (Multiplicity)};#bf{#it{N}}", HistType::kTH2F, {{200, 0, 20}, cfgMultiplicityBinning}); + } + + void process(soa::Filtered::iterator const&, aod::McParticles const& mcParticles) + { + int nParticles = mcParticles.size(); + mHistManager.fill(HIST("Multiplicity"), nParticles); + for (auto& mcParticle : mcParticles) { + if (mcParticle.pdgCode() == cfgSelectedParticleCode && std::abs(mcParticle.y()) < cfgRapidityCut) + mHistManager.fill(HIST("YieldVsMultiplicity"), mcParticle.pt(), nParticles); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"mc-generator-studies"})}; } diff --git a/PWGEM/PhotonMeson/Tasks/pcmQC.cxx b/PWGEM/PhotonMeson/Tasks/pcmQC.cxx index e593e69e52f..eaba34cec81 100644 --- a/PWGEM/PhotonMeson/Tasks/pcmQC.cxx +++ b/PWGEM/PhotonMeson/Tasks/pcmQC.cxx @@ -14,18 +14,18 @@ // This code runs loop over v0 photons for PCM QC. // Please write to: daiki.sekihata@cern.ch -#include -#include +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" -#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include +#include using namespace o2; using namespace o2::aod; @@ -37,7 +37,7 @@ using namespace o2::aod::pwgem::photon; using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; -using MyV0Photons = soa::Join; +using MyV0Photons = soa::Join; using MyV0Photon = MyV0Photons::iterator; struct PCMQC { @@ -73,27 +73,28 @@ struct PCMQC { Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; - Configurable cfg_require_v0_on_wwire_ib{"cfg_require_v0_on_wwire_ib", false, "flag to select V0s on W wires ITSib"}; Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; + Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.8, "min eta for v0 photons at PV"}; Configurable cfg_max_eta_v0{"cfg_max_eta_v0", +0.8, "max eta for v0 photons at PV"}; Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; - Configurable cfg_min_cospa{"cfg_min_cospa", 0.997, "min V0 CosPA"}; - Configurable cfg_max_pca{"cfg_max_pca", 3.0, "max distance btween 2 legs"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.999, "min V0 CosPA"}; + Configurable cfg_max_pca{"cfg_max_pca", 1.5, "max distance btween 2 legs"}; Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; - Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", true, "flag to select V0s with correct xz"}; + Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", false, "flag to select V0s with correct xz"}; Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; - Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; } pcmcuts; static constexpr std::string_view event_types[2] = {"before/", "after/"}; @@ -134,33 +135,29 @@ struct PCMQC { // v0 info fRegistry.add("V0/hPt", "pT;p_{T,#gamma} (GeV/c)", kTH1F, {{2000, 0.0f, 20}}, false); - fRegistry.add("V0/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {40, -1.0f, 1.0f}}, false); - fRegistry.add("V0/hRadius", "V0Radius; radius in Z (cm);radius in XY (cm)", kTH2F, {{200, -100, 100}, {200, 0.0f, 100.0f}}, false); - fRegistry.add("V0/hCosPA", "V0CosPA;cosine pointing angle", kTH1F, {{100, 0.99f, 1.0f}}, false); - fRegistry.add("V0/hCosPA_Rxy", "cos PA vs. R_{xy};R_{xy} (cm);cosine pointing angle", kTH2F, {{200, 0.f, 100.f}, {100, 0.99f, 1.0f}}, false); + fRegistry.add("V0/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {200, -1.0f, 1.0f}}, false); + fRegistry.add("V0/hXY", "conversion point in XY;V_{x} (cm);V_{y} (cm)", kTH2F, {{400, -100.0f, 100.0f}, {400, -100.0f, 100.0f}}, false); + fRegistry.add("V0/hRZ", "conversion point in RZ;Z (cm);R_{xy} (cm)", kTH2F, {{200, -100, 100}, {200, 0.0f, 100.0f}}, false); + fRegistry.add("V0/hCosPA", "V0CosPA;cosine pointing angle in 3D", kTH1F, {{100, 0.99f, 1.0f}}, false); + fRegistry.add("V0/hCosPAXY", "V0CosPA;cosine pointing angle in XY", kTH1F, {{100, 0.99f, 1.0f}}, false); + fRegistry.add("V0/hCosPARZ", "V0CosPA;cosine pointing angle in RZ", kTH1F, {{100, 0.99f, 1.0f}}, false); fRegistry.add("V0/hPCA", "distance between 2 legs;PCA (cm)", kTH1F, {{500, 0.0f, 5.0f}}, false); - fRegistry.add("V0/hPCA_Rxy", "distance between 2 legs vs. R_{xy};R_{xy} (cm);PCA (cm)", kTH2F, {{200, 0.f, 100.f}, {500, 0.0f, 5.0f}}, false); - fRegistry.add("V0/hPCA_CosPA", "distance between 2 legs vs. cosPA;cosine of pointing angle;PCA (cm)", kTH2F, {{100, 0.99f, 1.f}, {500, 0.0f, 5.0f}}, false); fRegistry.add("V0/hDCAxyz", "DCA to PV;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -5.f, +5.f}, {200, -5.f, +5.f}}, false); + fRegistry.add("V0/hDCAz_Pt", "DCA_{z} to PV vs. p_{T};DCA_{z} (cm);p_{T} (GeV/c)", kTH2F, {{200, -5.f, +5.f}, {2000, 0.0f, 20}}, false); fRegistry.add("V0/hAPplot", "AP plot;#alpha;q_{T} (GeV/c)", kTH2F, {{200, -1.0f, +1.0f}, {250, 0.0f, 0.25f}}, false); fRegistry.add("V0/hMassGamma", "hMassGamma;R_{xy} (cm);m_{ee} (GeV/c^{2})", kTH2F, {{200, 0.0f, 100.0f}, {100, 0.0f, 0.1f}}, false); - fRegistry.add("V0/hGammaRxy", "conversion point in XY;V_{x} (cm);V_{y} (cm)", kTH2F, {{400, -100.0f, 100.0f}, {400, -100.0f, 100.0f}}, false); fRegistry.add("V0/hKFChi2vsM", "KF chi2 vs. m_{ee};m_{ee} (GeV/c^{2});KF chi2/NDF", kTH2F, {{100, 0.0f, 0.1f}, {100, 0.f, 100.0f}}, false); fRegistry.add("V0/hKFChi2vsR", "KF chi2 vs. conversion point in XY;R_{xy} (cm);KF chi2/NDF", kTH2F, {{200, 0.0f, 100.0f}, {100, 0.f, 100.0f}}, false); fRegistry.add("V0/hKFChi2vsX", "KF chi2 vs. conversion point in X;X (cm);KF chi2/NDF", kTH2F, {{200, -100.0f, 100.0f}, {100, 0.f, 100.0f}}, false); fRegistry.add("V0/hKFChi2vsY", "KF chi2 vs. conversion point in Y;Y (cm);KF chi2/NDF", kTH2F, {{200, -100.0f, 100.0f}, {100, 0.f, 100.0f}}, false); fRegistry.add("V0/hKFChi2vsZ", "KF chi2 vs. conversion point in Z;Z (cm);KF chi2/NDF", kTH2F, {{200, -100.0f, 100.0f}, {100, 0.f, 100.0f}}, false); - fRegistry.add("V0/hPResolution", "p resolution;p_{#gamma} (GeV/c);#Deltap/p", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.1}}, false); - fRegistry.add("V0/hPtResolution", "p_{T} resolution;p_{#gamma} (GeV/c);#Deltap_{T}/p_{T}", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.1}}, false); - fRegistry.add("V0/hEtaResolution", "#eta resolution;p_{#gamma} (GeV/c);#Delta#eta", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.01}}, false); - fRegistry.add("V0/hThetaResolution", "#theta resolution;p_{#gamma} (GeV/c);#Delta#theta (rad.)", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.01}}, false); - fRegistry.add("V0/hPhiResolution", "#varphi resolution;p_{#gamma} (GeV/c);#Delta#varphi (rad.)", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.01}}, false); + fRegistry.add("V0/hsConvPoint", "photon conversion point;r_{xy} (cm);#varphi (rad.);#eta;", kTHnSparseF, {{100, 0.0f, 100}, {90, 0, 2 * M_PI}, {80, -2, +2}}, false); fRegistry.add("V0/hNgamma", "Number of #gamma candidates per collision", kTH1F, {{101, -0.5f, 100.5f}}); // v0leg info fRegistry.add("V0Leg/hPt", "pT;p_{T,e} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); fRegistry.add("V0Leg/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{1000, -50, 50}}, false); - fRegistry.add("V0Leg/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {40, -1.0f, 1.0f}}, false); + fRegistry.add("V0Leg/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {200, -1.0f, 1.0f}}, false); fRegistry.add("V0Leg/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -50.0f, 50.0f}, {200, -50.0f, 50.0f}}, false); fRegistry.add("V0Leg/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); fRegistry.add("V0Leg/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); @@ -203,7 +200,7 @@ struct PCMQC { fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); // for v0 - fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, 1e10f); + fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, pcmcuts.cfg_max_pt_v0); fV0PhotonCut.SetV0EtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); fV0PhotonCut.SetMinCosPA(pcmcuts.cfg_min_cospa); fV0PhotonCut.SetMaxPCA(pcmcuts.cfg_max_pca); @@ -213,8 +210,6 @@ struct PCMQC { fV0PhotonCut.RejectITSib(pcmcuts.cfg_reject_v0_on_itsib); // for track - fV0PhotonCut.SetTrackPtRange(pcmcuts.cfg_min_pt_v0 * 0.4, 1e+10f); - fV0PhotonCut.SetTrackEtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); fV0PhotonCut.SetMinNClustersTPC(pcmcuts.cfg_min_ncluster_tpc); fV0PhotonCut.SetMinNCrossedRowsTPC(pcmcuts.cfg_min_ncrossedrows); fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); @@ -222,33 +217,14 @@ struct PCMQC { fV0PhotonCut.SetChi2PerClusterTPC(0.0, pcmcuts.cfg_max_chi2tpc); fV0PhotonCut.SetTPCNsigmaElRange(pcmcuts.cfg_min_TPCNsigmaEl, pcmcuts.cfg_max_TPCNsigmaEl); fV0PhotonCut.SetChi2PerClusterITS(-1e+10, pcmcuts.cfg_max_chi2its); - fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); - - if (pcmcuts.cfg_reject_v0_on_itsib) { - fV0PhotonCut.SetNClustersITS(2, 4); - } else { - fV0PhotonCut.SetNClustersITS(0, 7); - } + fV0PhotonCut.SetNClustersITS(0, 7); fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); fV0PhotonCut.SetIsWithinBeamPipe(pcmcuts.cfg_require_v0_with_correct_xz); - - if (pcmcuts.cfg_require_v0_with_itstpc) { - fV0PhotonCut.SetRequireITSTPC(true); - fV0PhotonCut.SetRxyRange(4, 40); - } - if (pcmcuts.cfg_require_v0_with_itsonly) { - fV0PhotonCut.SetRequireITSonly(true); - fV0PhotonCut.SetRxyRange(4, 24); - } - if (pcmcuts.cfg_require_v0_with_tpconly) { - fV0PhotonCut.SetRequireTPConly(true); - fV0PhotonCut.SetRxyRange(32, 90); - } - if (pcmcuts.cfg_require_v0_on_wwire_ib) { - fV0PhotonCut.SetOnWwireIB(true); - fV0PhotonCut.SetOnWwireOB(false); - fV0PhotonCut.SetRxyRange(7, 14); - } + fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); + fV0PhotonCut.SetDisableTPConly(pcmcuts.cfg_disable_tpconly_track); + fV0PhotonCut.SetRequireITSTPC(pcmcuts.cfg_require_v0_with_itstpc); + fV0PhotonCut.SetRequireITSonly(pcmcuts.cfg_require_v0_with_itsonly); + fV0PhotonCut.SetRequireTPConly(pcmcuts.cfg_require_v0_with_tpconly); } template @@ -276,7 +252,7 @@ struct PCMQC { if (collision.sel8()) { fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 8.0); } - if (abs(collision.posZ()) < 10.0) { + if (std::fabs(collision.posZ()) < 10.0) { fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 9.0); } fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hZvtx"), collision.posZ()); @@ -296,26 +272,26 @@ struct PCMQC { { fRegistry.fill(HIST("V0/hPt"), v0.pt()); fRegistry.fill(HIST("V0/hEtaPhi"), v0.phi(), v0.eta()); - fRegistry.fill(HIST("V0/hRadius"), v0.vz(), v0.v0radius()); + fRegistry.fill(HIST("V0/hXY"), v0.vx(), v0.vy()); + fRegistry.fill(HIST("V0/hRZ"), v0.vz(), v0.v0radius()); fRegistry.fill(HIST("V0/hCosPA"), v0.cospa()); - fRegistry.fill(HIST("V0/hCosPA_Rxy"), v0.v0radius(), v0.cospa()); + fRegistry.fill(HIST("V0/hCosPAXY"), v0.cospaXY()); + fRegistry.fill(HIST("V0/hCosPARZ"), v0.cospaRZ()); fRegistry.fill(HIST("V0/hPCA"), v0.pca()); - fRegistry.fill(HIST("V0/hPCA_CosPA"), v0.cospa(), v0.pca()); - fRegistry.fill(HIST("V0/hPCA_Rxy"), v0.v0radius(), v0.pca()); fRegistry.fill(HIST("V0/hDCAxyz"), v0.dcaXYtopv(), v0.dcaZtopv()); + fRegistry.fill(HIST("V0/hDCAz_Pt"), v0.dcaZtopv(), v0.pt()); fRegistry.fill(HIST("V0/hAPplot"), v0.alpha(), v0.qtarm()); fRegistry.fill(HIST("V0/hMassGamma"), v0.v0radius(), v0.mGamma()); - fRegistry.fill(HIST("V0/hGammaRxy"), v0.vx(), v0.vy()); fRegistry.fill(HIST("V0/hKFChi2vsM"), v0.mGamma(), v0.chiSquareNDF()); fRegistry.fill(HIST("V0/hKFChi2vsR"), v0.v0radius(), v0.chiSquareNDF()); fRegistry.fill(HIST("V0/hKFChi2vsX"), v0.vx(), v0.chiSquareNDF()); fRegistry.fill(HIST("V0/hKFChi2vsY"), v0.vy(), v0.chiSquareNDF()); fRegistry.fill(HIST("V0/hKFChi2vsZ"), v0.vz(), v0.chiSquareNDF()); - fRegistry.fill(HIST("V0/hPResolution"), v0.p(), getPResolution(v0) / v0.p()); - fRegistry.fill(HIST("V0/hPtResolution"), v0.p(), getPtResolution(v0) / v0.pt()); - fRegistry.fill(HIST("V0/hEtaResolution"), v0.p(), getEtaResolution(v0)); - fRegistry.fill(HIST("V0/hThetaResolution"), v0.p(), getThetaResolution(v0)); - fRegistry.fill(HIST("V0/hPhiResolution"), v0.p(), getPhiResolution(v0)); + + float phi_cp = std::atan2(v0.vy(), v0.vx()); + o2::math_utils::bringTo02Pi(phi_cp); + float eta_cp = std::atanh(v0.vz() / std::sqrt(std::pow(v0.vx(), 2) + std::pow(v0.vy(), 2) + std::pow(v0.vz(), 2))); + fRegistry.fill(HIST("V0/hsConvPoint"), v0.v0radius(), phi_cp, eta_cp); } template @@ -348,7 +324,7 @@ struct PCMQC { Preslice perCollision = aod::v0photonkf::emeventId; Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; - Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin < o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; using FilteredMyCollisions = soa::Filtered; void processQC(FilteredMyCollisions const& collisions, MyV0Photons const& v0photons, aod::V0Legs const&) diff --git a/PWGEM/PhotonMeson/Tasks/pcmQCMC.cxx b/PWGEM/PhotonMeson/Tasks/pcmQCMC.cxx index 6005a6afbdc..d2ea5619072 100644 --- a/PWGEM/PhotonMeson/Tasks/pcmQCMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/pcmQCMC.cxx @@ -14,20 +14,20 @@ // This code runs loop over v0 photons for PCM QC. // Please write to: daiki.sekihata@cern.ch -#include -#include +#include "PWGEM/Dilepton/Utils/MCUtilities.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" +#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" -#include "PWGEM/PhotonMeson/Utils/MCUtilities.h" -#include "PWGEM/Dilepton/Utils/MCUtilities.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include +#include using namespace o2; using namespace o2::aod; @@ -44,7 +44,7 @@ using MyCollision = MyCollisions::iterator; using MyMCCollisions = soa::Join; using MyMCCollision = MyMCCollisions::iterator; -using MyV0Photons = soa::Join; +using MyV0Photons = soa::Join; using MyV0Photon = MyV0Photons::iterator; using MyMCV0Legs = soa::Join; @@ -58,6 +58,8 @@ struct PCMQCMC { Configurable maxRgen{"maxRgen", 90.f, "maximum radius for generated particles"}; Configurable margin_z_mc{"margin_z_mc", 7.0, "margin for z cut in cm for MC"}; + Configurable cfgRequireTrueAssociation{"cfgRequireTrueAssociation", false, "flag to require true mc collision association"}; + Configurable cfg_fill_resolution{"cfg_fill_resoltion", false, "flag to fill resolution histogram"}; EMPhotonEventCut fEMEventCut; struct : ConfigurableGroup { @@ -87,32 +89,33 @@ struct PCMQCMC { Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; - Configurable cfg_require_v0_on_wwire_ib{"cfg_require_v0_on_wwire_ib", false, "flag to select V0s on W wires ITSib"}; Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; + Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.8, "min eta for v0 photons at PV"}; Configurable cfg_max_eta_v0{"cfg_max_eta_v0", +0.8, "max eta for v0 photons at PV"}; Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; - Configurable cfg_min_cospa{"cfg_min_cospa", 0.997, "min V0 CosPA"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.999, "min V0 CosPA"}; Configurable cfg_max_pca{"cfg_max_pca", 3.0, "max distance btween 2 legs"}; Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; - Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", true, "flag to select V0s with correct xz"}; + Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", false, "flag to select V0s with correct xz"}; Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; - Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; } pcmcuts; HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; static constexpr std::string_view event_types[2] = {"before/", "after/"}; - static constexpr std::string_view mcphoton_types[3] = {"primary/", "fromWD/", "fromHS/"}; + static constexpr std::string_view mcphoton_types[5] = {"primary/", "fromWD/", "fromHS/", "fromPi0Dalitz/", "fromEtaDalitz/"}; void init(InitContext&) { @@ -142,12 +145,13 @@ struct PCMQCMC { if (doprocessGen) { fRegistry.add("Generated/hPt", "pT;p_{T} (GeV/c)", kTH1F, {axis_pt}, true); fRegistry.add("Generated/hPtY", "Generated info", kTH2F, {axis_pt, axis_rapidity}, true); - fRegistry.add("Generated/hPt_ConvertedPhoton", "converted photon pT;p_{T} (GeV/c)", kTH1F, {axis_pt}, true); - fRegistry.add("Generated/hY_ConvertedPhoton", "converted photon y;rapidity y", kTH1F, {{40, -2.0f, 2.0f}}, true); - fRegistry.add("Generated/hPhi_ConvertedPhoton", "converted photon #varphi;#varphi (rad.)", kTH1F, {{180, 0, 2 * M_PI}}, true); - fRegistry.add("Generated/hPhotonRxy", "conversion point in XY MC;V_{x} (cm);V_{y} (cm)", kTH2F, {{800, -100.0f, 100.0f}, {800, -100.0f, 100.0f}}, true); - fRegistry.add("Generated/hPhotonRZ", "conversion point in RZ MC;V_{z} (cm);R_{xy} (cm)", kTH2F, {{400, -100.0f, 100.0f}, {400, 0.f, 100.0f}}, true); - fRegistry.add("Generated/hPhotonPhivsRxy", "conversion point of #varphi vs. R_{xy} MC;#varphi (rad.);R_{xy} (cm);N_{e}", kTH2F, {{360, 0.0f, 2 * M_PI}, {400, 0, 100}}, true); + fRegistry.add("Generated/hPt_ConversionPhoton", "converted photon pT;p_{T} (GeV/c)", kTH1F, {axis_pt}, true); + fRegistry.add("Generated/hY_ConversionPhoton", "converted photon y;rapidity y", kTH1F, {{40, -2.0f, 2.0f}}, true); + fRegistry.add("Generated/hPhi_ConversionPhoton", "converted photon #varphi;#varphi (rad.)", kTH1F, {{180, 0, 2 * M_PI}}, true); + fRegistry.add("Generated/hXY", "conversion point in XY MC;V_{x} (cm);V_{y} (cm)", kTH2F, {{800, -100.0f, 100.0f}, {800, -100.0f, 100.0f}}, true); + fRegistry.add("Generated/hRZ", "conversion point in RZ MC;V_{z} (cm);R_{xy} (cm)", kTH2F, {{400, -100.0f, 100.0f}, {400, 0.f, 100.0f}}, true); + fRegistry.add("Generated/hRPhi", "conversion point of #varphi vs. R_{xy} MC;#varphi (rad.);R_{xy} (cm);N_{e}", kTH2F, {{360, 0.0f, 2 * M_PI}, {400, 0, 100}}, true); + fRegistry.add("Generated/hsConvPoint", "photon conversion point;r_{xy} (cm);#varphi (rad.);#eta;", kTHnSparseF, {{100, 0.0f, 100}, {90, 0, 2 * M_PI}, {80, -2, +2}}, true); } // event info @@ -176,43 +180,60 @@ struct PCMQCMC { // v0 info fRegistry.add("V0/primary/hPt", "pT;p_{T,#gamma} (GeV/c)", kTH1F, {{2000, 0.0f, 20}}, false); - fRegistry.add("V0/primary/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {40, -1.0f, 1.0f}}, false); - fRegistry.add("V0/primary/hRadius", "V0Radius; radius in Z (cm);radius in XY (cm)", kTH2F, {{200, -100, 100}, {200, 0.0f, 100.0f}}, false); - fRegistry.add("V0/primary/hCosPA", "V0CosPA;cosine pointing angle", kTH1F, {{100, 0.99f, 1.0f}}, false); - fRegistry.add("V0/primary/hCosPA_Rxy", "cos PA vs. R_{xy};R_{xy} (cm);cosine pointing angle", kTH2F, {{200, 0.f, 100.f}, {100, 0.99f, 1.0f}}, false); + fRegistry.add("V0/primary/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {200, -1.0f, 1.0f}}, false); + fRegistry.add("V0/primary/hXY", "conversion point in XY;V_{x} (cm);V_{y} (cm)", kTH2F, {{400, -100.0f, 100.0f}, {400, -100.0f, 100.0f}}, false); + fRegistry.add("V0/primary/hRZ", "conversion point in RZ;Z (cm);R_{xy} (cm)", kTH2F, {{200, -100, 100}, {200, 0.0f, 100.0f}}, false); + fRegistry.add("V0/primary/hCosPA", "V0CosPA;cosine pointing angle in 3D", kTH1F, {{100, 0.99f, 1.0f}}, false); + fRegistry.add("V0/primary/hCosPAXY", "V0CosPA;cosine pointing angle in XY", kTH1F, {{100, 0.99f, 1.0f}}, false); + fRegistry.add("V0/primary/hCosPARZ", "V0CosPA;cosine pointing angle in RZ", kTH1F, {{100, 0.99f, 1.0f}}, false); fRegistry.add("V0/primary/hPCA", "distance between 2 legs;PCA (cm)", kTH1F, {{500, 0.0f, 5.0f}}, false); - fRegistry.add("V0/primary/hPCA_Rxy", "distance between 2 legs vs. R_{xy};R_{xy} (cm);PCA (cm)", kTH2F, {{200, 0.f, 100.f}, {500, 0.0f, 5.0f}}, false); - fRegistry.add("V0/primary/hPCA_CosPA", "distance between 2 legs vs. cosPA;cosine of pointing angle;PCA (cm)", kTH2F, {{100, 0.99f, 1.f}, {500, 0.0f, 5.0f}}, false); fRegistry.add("V0/primary/hDCAxyz", "DCA to PV;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -5.f, +5.f}, {200, -5.f, +5.f}}, false); + fRegistry.add("V0/primary/hDCAz_Pt", "DCA_{z} to PV vs. p_{T};DCA_{z} (cm);p_{T} (GeV/c)", kTH2F, {{200, -5.f, +5.f}, {2000, 0.0f, 20}}, false); fRegistry.add("V0/primary/hAPplot", "AP plot;#alpha;q_{T} (GeV/c)", kTH2F, {{200, -1.0f, +1.0f}, {250, 0.0f, 0.25f}}, false); fRegistry.add("V0/primary/hMassGamma", "hMassGamma;R_{xy} (cm);m_{ee} (GeV/c^{2})", kTH2F, {{200, 0.0f, 100.0f}, {100, 0.0f, 0.1f}}, false); - fRegistry.add("V0/primary/hGammaRxy", "conversion point in XY;V_{x} (cm);V_{y} (cm)", kTH2F, {{400, -100.0f, 100.0f}, {400, -100.0f, 100.0f}}, false); fRegistry.add("V0/primary/hKFChi2vsM", "KF chi2 vs. m_{ee};m_{ee} (GeV/c^{2});KF chi2/NDF", kTH2F, {{100, 0.0f, 0.1f}, {100, 0.f, 100.0f}}, false); fRegistry.add("V0/primary/hKFChi2vsR", "KF chi2 vs. conversion point in XY;R_{xy} (cm);KF chi2/NDF", kTH2F, {{200, 0.0f, 100.0f}, {100, 0.f, 100.0f}}, false); fRegistry.add("V0/primary/hKFChi2vsX", "KF chi2 vs. conversion point in X;X (cm);KF chi2/NDF", kTH2F, {{200, -100.0f, 100.0f}, {100, 0.f, 100.0f}}, false); fRegistry.add("V0/primary/hKFChi2vsY", "KF chi2 vs. conversion point in Y;Y (cm);KF chi2/NDF", kTH2F, {{200, -100.0f, 100.0f}, {100, 0.f, 100.0f}}, false); fRegistry.add("V0/primary/hKFChi2vsZ", "KF chi2 vs. conversion point in Z;Z (cm);KF chi2/NDF", kTH2F, {{200, -100.0f, 100.0f}, {100, 0.f, 100.0f}}, false); - fRegistry.add("V0/primary/hPResolution", "p resolution;p_{#gamma} (GeV/c);#Deltap/p", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.1}}, false); - fRegistry.add("V0/primary/hPtResolution", "p_{T} resolution;p_{#gamma} (GeV/c);#Deltap_{T}/p_{T}", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.1}}, false); - fRegistry.add("V0/primary/hEtaResolution", "#eta resolution;p_{#gamma} (GeV/c);#Delta#eta", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.01}}, false); - fRegistry.add("V0/primary/hThetaResolution", "#theta resolution;p_{#gamma} (GeV/c);#Delta#theta (rad.)", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.01}}, false); - fRegistry.add("V0/primary/hPhiResolution", "#varphi resolution;p_{#gamma} (GeV/c);#Delta#varphi (rad.)", kTH2F, {{1000, 0.0f, 10}, {100, 0, 0.01}}, false); - fRegistry.add("V0/primary/hNgamma", "Number of true #gamma per collision", kTH1F, {{101, -0.5f, 100.5f}}); + fRegistry.add("V0/primary/hNgamma", "Number of true #gamma per collision;N_{#gamma} per event;Number of events", kTH1F, {{101, -0.5f, 100.5f}}); fRegistry.add("V0/primary/hConvPoint_diffX", "conversion point diff X MC;X_{MC} (cm);X_{rec} - X_{MC} (cm)", kTH2F, {{200, -100, +100}, {100, -50.0f, 50.0f}}, true); fRegistry.add("V0/primary/hConvPoint_diffY", "conversion point diff Y MC;Y_{MC} (cm);Y_{rec} - Y_{MC} (cm)", kTH2F, {{200, -100, +100}, {100, -50.0f, 50.0f}}, true); fRegistry.add("V0/primary/hConvPoint_diffZ", "conversion point diff Z MC;Z_{MC} (cm);Z_{rec} - Z_{MC} (cm)", kTH2F, {{200, -100, +100}, {100, -50.0f, 50.0f}}, true); - fRegistry.add("V0/primary/hPtGen_DeltaPtOverPtGen", "photon p_{T} resolution;p_{T}^{gen} (GeV/c);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("V0/primary/hPtGen_DeltaEta", "photon #eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("V0/primary/hPtGen_DeltaPhi", "photon #varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("V0/primary/hXY_Photon_MC", "X vs. Y of true photon conversion point.;X (cm);Y (cm)", kTH2F, {{400, -100.0f, +100}, {400, -100, +100}}, true); - fRegistry.add("V0/primary/hRZ_Photon_MC", "R vs. Z of true photon conversion point;Z (cm);R_{xy} (cm)", kTH2F, {{200, -100.0f, +100}, {200, 0, 100}}, true); - fRegistry.addClone("V0/primary/", "V0/fromWD/"); // from weak decay - fRegistry.addClone("V0/primary/", "V0/fromHS/"); // from hadronic shower in detector materials + fRegistry.add("V0/primary/hPtGen_DeltaPtOverPtGen", "photon p_{T} resolution;p_{T}^{gen} (GeV/c);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{1000, 0, 10}, {200, -1.0f, 1.0f}}, true); + fRegistry.add("V0/primary/hPtGen_DeltaEta", "photon #eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{1000, 0, 10}, {100, -0.5f, 0.5f}}, true); + fRegistry.add("V0/primary/hPtGen_DeltaPhi", "photon #varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{1000, 0, 10}, {100, -0.5f, 0.5f}}, true); + fRegistry.add("V0/primary/hRxyGen_DeltaPtOverPtGen", "photon p_{T} resolution; R_{xy}^{gen} (cm);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{100, 0, 100}, {200, -1.0f, 1.0f}}, true); + fRegistry.add("V0/primary/hsPhotonResolution", + "Photon resolution;p_{T};#eta;R_{xy};Z_{conv};Z_{vtx};#Deltap_{T}/p_{T};#Delta#eta;#Delta#phi", + kTHnSparseF, + {{100, 0, 10}, + {80, -1.6, 1.6}, + {100, 0, 100}, + {100, -50, 50}, + {100, -50, 50}, + {200, -1, 1}, + {100, -0.5, 0.5}, + {100, -0.5, 0.5}}, + false); + fRegistry.add("V0/primary/hRxyGen_DeltaEta", "photon #eta resolution;R_{xy}^{gen} (cm);#eta^{rec} - #eta^{gen}", kTH2F, {{100, 0, 100}, {100, -0.5f, 0.5f}}, true); + fRegistry.add("V0/primary/hRxyGen_DeltaPhi", "photon #varphi resolution;R_{xy}^{gen} (cm);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{100, 0, 100}, {100, -0.5f, 0.5f}}, true); + fRegistry.add("V0/primary/hRxyGen_DeltaR", "photon #varphi resolution;R_{xy}^{gen} (cm);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{100, 0, 100}, {100, 0, 100}}, true); + fRegistry.add("V0/primary/hsConvVtxZPtR", "z_{vtx} vs p_{T} vs R_{xy};z_{vtx} (cm);p_{T} (GeV/c);R_{xy} (cm)", kTHnSparseF, {{100, -20.0f, +20.0f}, {100, 0.0f, 10.0f}, {100, 0, 100}}, false); + fRegistry.add("V0/primary/hXY_MC", "X vs. Y of true photon conversion point.;X (cm);Y (cm)", kTH2F, {{400, -100.0f, +100}, {400, -100, +100}}, true); + fRegistry.add("V0/primary/hRZ_MC", "R vs. Z of true photon conversion point;Z (cm);R_{xy} (cm)", kTH2F, {{200, -100.0f, +100}, {200, 0, 100}}, true); + fRegistry.add("V0/primary/hsConvPoint", "photon conversion point;r_{xy} (cm);#varphi (rad.);#eta;", kTHnSparseF, {{100, 0.0f, 100}, {90, 0, 2 * M_PI}, {80, -2, +2}}, false); + fRegistry.addClone("V0/primary/", "V0/fromWD/"); // from weak decay + fRegistry.addClone("V0/primary/", "V0/fromHS/"); // from hadronic shower in detector materials + fRegistry.addClone("V0/primary/", "V0/fromPi0Dalitz/"); // misidentified dielectron from pi0 dalitz decay + fRegistry.addClone("V0/primary/", "V0/fromEtaDalitz/"); // misidentified dielectron from eta dalitz decay + fRegistry.addClone("V0/primary/hPt", "V0/candidate/hPt"); // only for purity + fRegistry.addClone("V0/primary/hEtaPhi", "V0/candidate/hEtaPhi"); // only for purity // v0leg info fRegistry.add("V0Leg/primary/hPt", "pT;p_{T,e} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); fRegistry.add("V0Leg/primary/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{1000, -50, 50}}, false); - fRegistry.add("V0Leg/primary/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {40, -3.0f, 1.0f}}, false); + fRegistry.add("V0Leg/primary/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{90, 0, 2 * M_PI}, {200, -1.0f, 1.0f}}, false); fRegistry.add("V0Leg/primary/hDCAxyz", "DCA xy vs. z;DCA_{xy} (cm);DCA_{z} (cm)", kTH2F, {{200, -50.0f, 50.0f}, {200, -50.0f, 50.0f}}, false); fRegistry.add("V0Leg/primary/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); fRegistry.add("V0Leg/primary/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); @@ -230,11 +251,36 @@ struct PCMQCMC { fRegistry.add("V0Leg/primary/hXY", "X vs. Y;X (cm);Y (cm)", kTH2F, {{100, 0, 100}, {40, -20, 20}}, false); fRegistry.add("V0Leg/primary/hZX", "Z vs. X;Z (cm);X (cm)", kTH2F, {{200, -100, 100}, {100, 0, 100}}, false); fRegistry.add("V0Leg/primary/hZY", "Z vs. Y;Z (cm);Y (cm)", kTH2F, {{200, -100, 100}, {40, -20, 20}}, false); - fRegistry.add("V0Leg/primary/hPtGen_DeltaPtOverPtGen", "electron p_{T} resolution;p_{T}^{gen} (GeV/c);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("V0Leg/primary/hPtGen_DeltaEta", "electron #eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("V0Leg/primary/hPtGen_DeltaPhi", "electron #varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.addClone("V0Leg/primary/", "V0Leg/fromWD/"); // from weak decay - fRegistry.addClone("V0Leg/primary/", "V0Leg/fromHS/"); // from hadronic shower in detector materials + fRegistry.add("V0Leg/primary/hPtGen_DeltaPtOverPtGen", "electron p_{T} resolution;p_{T}^{gen} (GeV/c);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{1000, 0, 10}, {200, -1.0f, 1.0f}}, true); + fRegistry.add("V0Leg/primary/hPtGen_DeltaEta", "electron #eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{1000, 0, 10}, {100, -0.5f, 0.5f}}, true); + if (cfg_fill_resolution) { + fRegistry.add("V0Leg/primary/hsPhotonResolution", + "Photon resolution;p_{T};#eta;R_{xy};Z_{conv};Z_{vtx};#Deltap_{T}/p_{T};#Delta#eta;#Delta#phi", + kTHnSparseF, + {{100, 0, 10}, + {80, -1.6, 1.6}, + {100, 0, 100}, + {100, -50, 50}, + {100, -50, 50}, + {200, -1, 1}, + {100, -0.5, 0.5}, + {100, -0.5, 0.5}}, + false); + } + + fRegistry.add("V0Leg/primary/hPtGen_DeltaPhi", "electron #varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{1000, 0, 10}, {100, -0.5f, 0.5f}}, true); + fRegistry.add("V0Leg/primary/hRxyGen_DeltaPtOverPtGen", "photon p_{T} resolution; R_{xy}^{gen} (cm);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{100, 0, 100}, {200, -1.0f, 1.0f}}, true); + fRegistry.add("V0Leg/primary/hRxyGen_DeltaEta", "photon #eta resolution;R_{xy}^{gen} (cm);#eta^{rec} - #eta^{gen}", kTH2F, {{100, 0, 100}, {100, -0.5f, 0.5f}}, true); + fRegistry.add("V0Leg/primary/hRxyGen_DeltaPhi", "photon #varphi resolution;R_{xy}^{gen} (cm);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{100, 0, 100}, {100, 0, 100}}, true); + fRegistry.add("V0Leg/primary/hRxyGen_DeltaR", "photon p_{T} resolution; R_{xy}^{gen} (cm);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{100, 0, 100}, {200, -1.0f, 1.0f}}, true); + + fRegistry.addClone("V0Leg/primary/", "V0Leg/fromWD/"); // from weak decay + fRegistry.addClone("V0Leg/primary/", "V0Leg/fromHS/"); // from hadronic shower in detector materials + fRegistry.addClone("V0Leg/primary/", "V0Leg/fromPi0Dalitz/"); // misidentified dielectron from pi0 dalitz decay + fRegistry.addClone("V0Leg/primary/", "V0Leg/fromEtaDalitz/"); // misidentified dielectron from eta dalitz decay + + fRegistry.addClone("V0Leg/primary/hPt", "V0Leg/candidate/hPt"); // only for purity + fRegistry.addClone("V0Leg/primary/hEtaPhi", "V0Leg/candidate/hEtaPhi"); // only for purity } void DefineEMEventCut() @@ -260,7 +306,7 @@ struct PCMQCMC { fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); // for v0 - fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, 1e10f); + fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, pcmcuts.cfg_max_pt_v0); fV0PhotonCut.SetV0EtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); fV0PhotonCut.SetMinCosPA(pcmcuts.cfg_min_cospa); fV0PhotonCut.SetMaxPCA(pcmcuts.cfg_max_pca); @@ -270,8 +316,6 @@ struct PCMQCMC { fV0PhotonCut.RejectITSib(pcmcuts.cfg_reject_v0_on_itsib); // for track - fV0PhotonCut.SetTrackPtRange(pcmcuts.cfg_min_pt_v0 * 0.4, 1e+10f); - fV0PhotonCut.SetTrackEtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); fV0PhotonCut.SetMinNClustersTPC(pcmcuts.cfg_min_ncluster_tpc); fV0PhotonCut.SetMinNCrossedRowsTPC(pcmcuts.cfg_min_ncrossedrows); fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); @@ -279,33 +323,14 @@ struct PCMQCMC { fV0PhotonCut.SetChi2PerClusterTPC(0.0, pcmcuts.cfg_max_chi2tpc); fV0PhotonCut.SetTPCNsigmaElRange(pcmcuts.cfg_min_TPCNsigmaEl, pcmcuts.cfg_max_TPCNsigmaEl); fV0PhotonCut.SetChi2PerClusterITS(-1e+10, pcmcuts.cfg_max_chi2its); - fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); - - if (pcmcuts.cfg_reject_v0_on_itsib) { - fV0PhotonCut.SetNClustersITS(2, 4); - } else { - fV0PhotonCut.SetNClustersITS(0, 7); - } + fV0PhotonCut.SetNClustersITS(0, 7); fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); fV0PhotonCut.SetIsWithinBeamPipe(pcmcuts.cfg_require_v0_with_correct_xz); - - if (pcmcuts.cfg_require_v0_with_itstpc) { - fV0PhotonCut.SetRequireITSTPC(true); - fV0PhotonCut.SetRxyRange(4, 40); - } - if (pcmcuts.cfg_require_v0_with_itsonly) { - fV0PhotonCut.SetRequireITSonly(true); - fV0PhotonCut.SetRxyRange(4, 24); - } - if (pcmcuts.cfg_require_v0_with_tpconly) { - fV0PhotonCut.SetRequireTPConly(true); - fV0PhotonCut.SetRxyRange(32, 90); - } - if (pcmcuts.cfg_require_v0_on_wwire_ib) { - fV0PhotonCut.SetOnWwireIB(true); - fV0PhotonCut.SetOnWwireOB(false); - fV0PhotonCut.SetRxyRange(7, 14); - } + fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); + fV0PhotonCut.SetDisableTPConly(pcmcuts.cfg_disable_tpconly_track); + fV0PhotonCut.SetRequireITSTPC(pcmcuts.cfg_require_v0_with_itstpc); + fV0PhotonCut.SetRequireITSonly(pcmcuts.cfg_require_v0_with_itsonly); + fV0PhotonCut.SetRequireTPConly(pcmcuts.cfg_require_v0_with_tpconly); } template @@ -333,9 +358,10 @@ struct PCMQCMC { if (collision.sel8()) { fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 8.0); } - if (abs(collision.posZ()) < 10.0) { + if (std::fabs(collision.posZ()) < 10.0) { fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 9.0); } + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hZvtx"), collision.posZ()); fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultNTracksPV"), collision.multNTracksPV()); @@ -353,34 +379,52 @@ struct PCMQCMC { { fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPt"), v0.pt()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hEtaPhi"), v0.phi(), v0.eta()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hRadius"), v0.vz(), v0.v0radius()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hXY"), v0.vx(), v0.vy()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hRZ"), v0.vz(), v0.v0radius()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hCosPA"), v0.cospa()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hCosPA_Rxy"), v0.v0radius(), v0.cospa()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hCosPAXY"), v0.cospaXY()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hCosPARZ"), v0.cospaRZ()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPCA"), v0.pca()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPCA_CosPA"), v0.cospa(), v0.pca()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPCA_Rxy"), v0.v0radius(), v0.pca()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hDCAxyz"), v0.dcaXYtopv(), v0.dcaZtopv()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hDCAz_Pt"), v0.dcaZtopv(), v0.pt()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hAPplot"), v0.alpha(), v0.qtarm()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hMassGamma"), v0.v0radius(), v0.mGamma()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hGammaRxy"), v0.vx(), v0.vy()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hKFChi2vsM"), v0.mGamma(), v0.chiSquareNDF()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hKFChi2vsR"), v0.v0radius(), v0.chiSquareNDF()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hsConvVtxZPtR"), + v0.vz(), v0.pt(), v0.v0radius()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hKFChi2vsX"), v0.vx(), v0.chiSquareNDF()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hKFChi2vsY"), v0.vy(), v0.chiSquareNDF()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hKFChi2vsZ"), v0.vz(), v0.chiSquareNDF()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPResolution"), v0.p(), getPResolution(v0) / v0.p()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPtResolution"), v0.p(), getPtResolution(v0) / v0.pt()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hEtaResolution"), v0.p(), getEtaResolution(v0)); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hThetaResolution"), v0.p(), getThetaResolution(v0)); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPhiResolution"), v0.p(), getPhiResolution(v0)); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPtGen_DeltaPtOverPtGen"), mcphoton.pt(), (v0.pt() - mcphoton.pt()) / mcphoton.pt()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPtGen_DeltaEta"), mcphoton.pt(), v0.eta() - mcphoton.eta()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hPtGen_DeltaPhi"), mcphoton.pt(), v0.phi() - mcphoton.phi()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hRxyGen_DeltaPtOverPtGen"), std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), (v0.pt() - mcphoton.pt()) / mcphoton.pt()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hRxyGen_DeltaEta"), std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), v0.eta() - mcphoton.eta()); + if (cfg_fill_resolution) { + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hsPhotonResolution"), + mcphoton.pt(), + mcphoton.eta(), + std::sqrt(mcleg.vx() * mcleg.vx() + mcleg.vy() * mcleg.vy()), + mcleg.vz(), + v0.vz(), + (v0.pt() - mcphoton.pt()) / mcphoton.pt(), + v0.eta() - mcphoton.eta(), + TVector2::Phi_mpi_pi(v0.phi() - mcphoton.phi())); + } + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hRxyGen_DeltaPhi"), std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), v0.phi() - mcphoton.phi()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hRxyGen_DeltaR"), std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), v0.v0radius() - std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2))); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hConvPoint_diffX"), mcleg.vx(), v0.vx() - mcleg.vx()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hConvPoint_diffY"), mcleg.vy(), v0.vy() - mcleg.vy()); fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hConvPoint_diffZ"), mcleg.vz(), v0.vz() - mcleg.vz()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hXY_Photon_MC"), mcleg.vx(), mcleg.vy()); - fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hRZ_Photon_MC"), mcleg.vz(), std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2))); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hXY_MC"), mcleg.vx(), mcleg.vy()); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hRZ_MC"), mcleg.vz(), std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2))); + + float phi_cp = std::atan2(v0.vy(), v0.vx()); + o2::math_utils::bringTo02Pi(phi_cp); + float eta_cp = std::atanh(v0.vz() / std::sqrt(std::pow(v0.vx(), 2) + std::pow(v0.vy(), 2) + std::pow(v0.vz(), 2))); + fRegistry.fill(HIST("V0/") + HIST(mcphoton_types[mctype]) + HIST("hsConvPoint"), v0.v0radius(), phi_cp, eta_cp); } template @@ -412,11 +456,25 @@ struct PCMQCMC { fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hPtGen_DeltaPtOverPtGen"), mcleg.pt(), (leg.pt() - mcleg.pt()) / mcleg.pt()); fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hPtGen_DeltaEta"), mcleg.pt(), leg.eta() - mcleg.eta()); fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hPtGen_DeltaPhi"), mcleg.pt(), leg.phi() - mcleg.phi()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hRxyGen_DeltaPtOverPtGen"), std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), (leg.pt() - mcleg.pt()) / mcleg.pt()); + if (cfg_fill_resolution) { + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hsPhotonResolution"), + mcleg.pt(), + mcleg.eta(), + std::sqrt(mcleg.vx() * mcleg.vx() + mcleg.vy() * mcleg.vy()), + mcleg.vz(), + leg.z(), + (leg.pt() - mcleg.pt()) / mcleg.pt(), + leg.eta() - mcleg.eta(), + TVector2::Phi_mpi_pi(leg.phi() - mcleg.phi())); + } + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hRxyGen_DeltaEta"), std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), leg.eta() - mcleg.eta()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hRxyGen_DeltaPhi"), std::sqrt(std::pow(mcleg.vx(), 2) + std::pow(mcleg.vy(), 2)), leg.phi() - mcleg.phi()); } Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; - Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin < o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; using FilteredMyCollisions = soa::Filtered; Preslice perCollision = aod::v0photonkf::emeventId; @@ -437,7 +495,7 @@ struct PCMQCMC { fRegistry.fill(HIST("Event/after/hCollisionCounter"), 10.0); // accepted auto V0Photons_coll = v0photons.sliceBy(perCollision, collision.globalIndex()); - int ng_primary = 0, ng_wd = 0, ng_hs = 0; + int ng_primary = 0, ng_wd = 0, ng_hs = 0, nee_pi0 = 0, nee_eta = 0; for (auto& v0 : V0Photons_coll) { auto pos = v0.posTrack_as(); auto ele = v0.negTrack_as(); @@ -449,36 +507,78 @@ struct PCMQCMC { if (!fV0PhotonCut.IsSelected(v0)) { continue; } + + fRegistry.fill(HIST("V0/candidate/hPt"), v0.pt()); + fRegistry.fill(HIST("V0/candidate/hEtaPhi"), v0.phi(), v0.eta()); + for (auto& leg : {pos, ele}) { + fRegistry.fill(HIST("V0Leg/candidate/hPt"), leg.pt()); + fRegistry.fill(HIST("V0Leg/candidate/hEtaPhi"), leg.phi(), leg.eta()); + } + int photonid = FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 22, mcparticles); - if (photonid < 0) { + int pi0id = FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 111, mcparticles); // pi0 dalitz decay + int etaid = FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 221, mcparticles); // eta dalitz decay + if (photonid < 0 && pi0id < 0 && etaid < 0) { continue; } - auto mcphoton = mcparticles.iteratorAt(photonid); - if (mcphoton.isPhysicalPrimary() || mcphoton.producedByGenerator()) { - fillV0Info<0>(v0, mcphoton, elemc); - for (auto& leg : {pos, ele}) { - fillV0LegInfo<0>(leg); + if (photonid > 0) { + auto mcphoton = mcparticles.iteratorAt(photonid); + if (cfgRequireTrueAssociation && (mcphoton.emmceventId() != collision.emmceventId())) { + continue; + } + + if (mcphoton.isPhysicalPrimary() || mcphoton.producedByGenerator()) { + fillV0Info<0>(v0, mcphoton, elemc); + for (auto& leg : {pos, ele}) { + fillV0LegInfo<0>(leg); + } + ng_primary++; + } else if (IsFromWD(mcphoton.template emmcevent_as(), mcphoton, mcparticles) > 0) { + fillV0Info<1>(v0, mcphoton, elemc); + for (auto& leg : {pos, ele}) { + fillV0LegInfo<1>(leg); + } + ng_wd++; + } else { + fillV0Info<2>(v0, mcphoton, elemc); + for (auto& leg : {pos, ele}) { + fillV0LegInfo<2>(leg); + } + ng_hs++; + // LOGF(info, "mcphoton.vx() = %f, mcphoton.vy() = %f, mcphoton.vz() = %f, mother_pdg = %d", mcphoton.vx(), mcphoton.vy(), mcphoton.vz(), mother_pdg); } - ng_primary++; - } else if (IsFromWD(mcphoton.template emmcevent_as(), mcphoton, mcparticles) > 0) { - fillV0Info<1>(v0, mcphoton, elemc); - for (auto& leg : {pos, ele}) { - fillV0LegInfo<1>(leg); + } else if (pi0id > 0) { + auto mcpi0 = mcparticles.iteratorAt(pi0id); + if (cfgRequireTrueAssociation && (mcpi0.emmceventId() != collision.emmceventId())) { + continue; } - ng_wd++; - } else { - fillV0Info<2>(v0, mcphoton, elemc); - for (auto& leg : {pos, ele}) { - fillV0LegInfo<2>(leg); + if (mcpi0.isPhysicalPrimary() || mcpi0.producedByGenerator()) { + fillV0Info<3>(v0, mcpi0, elemc); + for (auto& leg : {pos, ele}) { + fillV0LegInfo<3>(leg); + } + nee_pi0++; + } + } else if (etaid > 0) { + auto mceta = mcparticles.iteratorAt(etaid); + if (cfgRequireTrueAssociation && (mceta.emmceventId() != collision.emmceventId())) { + continue; + } + if (mceta.isPhysicalPrimary() || mceta.producedByGenerator()) { + fillV0Info<4>(v0, mceta, elemc); + for (auto& leg : {pos, ele}) { + fillV0LegInfo<4>(leg); + } + nee_eta++; } - ng_hs++; - // LOGF(info, "mcphoton.vx() = %f, mcphoton.vy() = %f, mcphoton.vz() = %f, mother_pdg = %d", mcphoton.vx(), mcphoton.vy(), mcphoton.vz(), mother_pdg); } } // end of v0 loop fRegistry.fill(HIST("V0/primary/hNgamma"), ng_primary); fRegistry.fill(HIST("V0/fromWD/hNgamma"), ng_wd); fRegistry.fill(HIST("V0/fromHS/hNgamma"), ng_hs); + fRegistry.fill(HIST("V0/fromPi0Dalitz/hNgamma"), nee_pi0); + fRegistry.fill(HIST("V0/fromEtaDalitz/hNgamma"), nee_eta); } // end of collision loop } // end of process @@ -529,19 +629,31 @@ struct PCMQCMC { auto mctracks_coll = mcparticles.sliceBy(perMcCollision, mccollision.globalIndex()); for (auto& mctrack : mctracks_coll) { - if (abs(mctrack.y()) > pcmcuts.cfg_max_eta_v0) { + if (std::fabs(mctrack.y()) > pcmcuts.cfg_max_eta_v0) { continue; } - if (abs(mctrack.pdgCode()) == 22 && (mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { - fRegistry.fill(HIST("Generated/hPt_ConvertedPhoton"), mctrack.pt()); - fRegistry.fill(HIST("Generated/hY_ConvertedPhoton"), mctrack.y()); - fRegistry.fill(HIST("Generated/hPhi_ConvertedPhoton"), mctrack.phi()); + if (std::abs(mctrack.pdgCode()) == 22 && (mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { auto daughter = mcparticles.iteratorAt(mctrack.daughtersIds()[0]); // choose ele or pos. - float rxy_gen_e = sqrt(pow(daughter.vx(), 2) + pow(daughter.vy(), 2)); - fRegistry.fill(HIST("Generated/hPhotonRZ"), daughter.vz(), rxy_gen_e); - fRegistry.fill(HIST("Generated/hPhotonRxy"), daughter.vx(), daughter.vy()); - fRegistry.fill(HIST("Generated/hPhotonPhivsRxy"), daughter.phi(), rxy_gen_e); + float rxy_gen_e = std::sqrt(std::pow(daughter.vx(), 2) + std::pow(daughter.vy(), 2)); + float phi_cp = std::atan2(daughter.vy(), daughter.vx()); + o2::math_utils::bringTo02Pi(phi_cp); + float eta_cp = std::atanh(daughter.vz() / std::sqrt(std::pow(daughter.vx(), 2) + std::pow(daughter.vy(), 2) + std::pow(daughter.vz(), 2))); + + if (rxy_gen_e < std::fabs(daughter.vz()) * std::tan(2 * std::atan(std::exp(-pcmcuts.cfg_max_eta_v0))) - margin_z_mc) { + continue; + } + if (rxy_gen_e > maxRgen) { + continue; + } + + fRegistry.fill(HIST("Generated/hPt_ConversionPhoton"), mctrack.pt()); + fRegistry.fill(HIST("Generated/hY_ConversionPhoton"), mctrack.y()); + fRegistry.fill(HIST("Generated/hPhi_ConversionPhoton"), mctrack.phi()); + fRegistry.fill(HIST("Generated/hsConvPoint"), rxy_gen_e, phi_cp, eta_cp); + fRegistry.fill(HIST("Generated/hXY"), daughter.vx(), daughter.vy()); + fRegistry.fill(HIST("Generated/hRZ"), daughter.vz(), rxy_gen_e); + fRegistry.fill(HIST("Generated/hRPhi"), phi_cp, rxy_gen_e); } } // end of mctrack loop per collision } // end of collision loop diff --git a/PWGEM/PhotonMeson/Tasks/prefilterPhoton.cxx b/PWGEM/PhotonMeson/Tasks/prefilterPhoton.cxx new file mode 100644 index 00000000000..ecc1eb34329 --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/prefilterPhoton.cxx @@ -0,0 +1,638 @@ +// 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. +// +// ======================== +// +// This code produces information on prefilter for photon. +// Please write to: daiki.sekihata@cern.ch + +#include +#include +#include +#include +#include + +// #include "TString.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" +// #include "Common/Core/RecoDecay.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/PhotonMeson/Core/DalitzEECut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" + +#include "Common/Core/trackUtilities.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::aod::pwgem::photonmeson::photonpair; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyV0Photons = soa::Join; +using MyV0Photon = MyV0Photons::iterator; + +using MyPrimaryElectrons = soa::Join; +using MyPrimaryElectron = MyPrimaryElectrons::iterator; + +struct prefilterPhoton { + Produces pfb_v0_derived; + Produces pfb_ele_derived; + + // Configurables + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; + Configurable d_bz_input{"d_bz_input", -999, "bz field in kG, -999 is automatic"}; + + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgCentMin{"cfgCentMin", -1, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; + + EMPhotonEventCut fEMEventCut; + struct : ConfigurableGroup { + std::string prefix = "eventcut_group"; + Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + Configurable cfgRequireSel8{"cfgRequireSel8", false, "require sel8 in event cut"}; + Configurable cfgRequireFT0AND{"cfgRequireFT0AND", true, "require FT0AND in event cut"}; + Configurable cfgRequireNoTFB{"cfgRequireNoTFB", false, "require No time frame border in event cut"}; + Configurable cfgRequireNoITSROFB{"cfgRequireNoITSROFB", false, "require no ITS readout frame border in event cut"}; + Configurable cfgRequireNoSameBunchPileup{"cfgRequireNoSameBunchPileup", false, "require no same bunch pileup in event cut"}; + Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -2, "min. occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -2, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; + } eventcuts; + + V0PhotonCut fV0PhotonCut; + struct : ConfigurableGroup { + std::string prefix = "pcmcut_group"; + + Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; + Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; + Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.9, "min eta for v0 photons at PV"}; + Configurable cfg_max_eta_v0{"cfg_max_eta_v0", +0.9, "max eta for v0 photons at PV"}; + Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; + Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; + Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; + Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; + Configurable cfg_min_cospa{"cfg_min_cospa", 0.99, "min V0 CosPA"}; + Configurable cfg_max_pca{"cfg_max_pca", 1.5, "max distance btween 2 legs"}; + Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; + Configurable cfg_require_v0_with_correct_xz{"cfg_require_v0_with_correct_xz", false, "flag to select V0s with correct xz"}; + Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; + Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; + } pcmcuts; + + DalitzEECut fDileptonCut; + struct : ConfigurableGroup { + std::string prefix = "dileptoncut_group"; + + Configurable cfg_min_mee{"cfg_min_mee", 0.0, "min mass"}; + Configurable cfg_max_mee{"cfg_max_mee", 0.02, "max mass"}; + // Configurable cfg_apply_phiv{"cfg_apply_phiv", false, "flag to apply phiv cut"}; + Configurable cfg_apply_pf{"cfg_apply_pf", false, "flag to apply phiv prefilter"}; + Configurable cfg_require_itsib_any{"cfg_require_itsib_any", false, "flag to require ITS ib any hits"}; + Configurable cfg_require_itsib_1st{"cfg_require_itsib_1st", true, "flag to require ITS ib 1st hit"}; + Configurable cfg_phiv_slope{"cfg_phiv_slope", 0.0185, "slope for m vs. phiv"}; + Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.05, "min pT for single track"}; + Configurable cfg_max_pt_track{"cfg_max_pt_track", 1e+10, "max pT for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -2.0, "min eta for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", 2.0, "max eta for single track"}; + Configurable cfg_min_ncluster_its{"cfg_min_ncluster_its", 5, "min ncluster its"}; + Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 40, "min ncluster tpc"}; + Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 0, "min ncrossed rows"}; + Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + Configurable cfg_max_chi2its{"cfg_max_chi2its", 5.0, "max chi2/NclsITS"}; + Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 1.f, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 1.f, "max dca Z for single track in cm"}; + Configurable cfg_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1.5, "max DCA 3D in sigma"}; + + Configurable cfg_pid_scheme{"cfg_pid_scheme", static_cast(DalitzEECut::PIDSchemes::kTOFif), "pid scheme [kTOFif : 0, kTPConly : 1]"}; + Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -2.0, "min. TPC n sigma for electron inclusion"}; + Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron inclusion"}; + Configurable cfg_min_TPCNsigmaPi{"cfg_min_TPCNsigmaPi", 0.0, "min. TPC n sigma for pion exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", 0.0, "max. TPC n sigma for pion exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -3.0, "min. TOF n sigma for electron inclusion"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +3.0, "max. TOF n sigma for electron inclusion"}; + } dileptoncuts; + + struct : ConfigurableGroup { + std::string prefix = "ggcut_group"; + Configurable cfg_min_mass{"cfg_min_mass", 0.10, "min mass for prefilter"}; // region to be rejected + Configurable cfg_max_mass{"cfg_max_mass", 0.15, "max mass for prefilter"}; // region to be rejected + } ggcuts; + + struct : ConfigurableGroup { + std::string prefix = "eegcut_group"; + Configurable cfg_min_mass{"cfg_min_mass", 0.10, "min mass for prefilter"}; // region to be rejected + Configurable cfg_max_mass{"cfg_max_mass", 0.15, "max mass for prefilter"}; // region to be rejected + } eegcuts; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber; + float d_bz; + + void init(InitContext& /*context*/) + { + DefineEMEventCut(); + DefinePCMCut(); + addhistograms(); + + mRunNumber = 0; + d_bz = 0; + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + } + + ~prefilterPhoton() {} + + template + void initCCDB(TCollision const& collision) + { + if (mRunNumber == collision.runNumber()) { + return; + } + + // In case override, don't proceed, please - no CCDB access required + if (d_bz_input > -990) { + d_bz = d_bz_input; + o2::parameters::GRPMagField grpmag; + if (fabs(d_bz) > 1e-5) { + grpmag.setL3Current(30000.f / (d_bz / 5.0f)); + } + mRunNumber = collision.runNumber(); + return; + } + + auto run3grp_timestamp = collision.timestamp(); + o2::parameters::GRPObject* grpo = 0x0; + o2::parameters::GRPMagField* grpmag = 0x0; + if (!skipGRPOquery) + grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + if (grpo) { + // Fetch magnetic field from ccdb for current collision + d_bz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + // Fetch magnetic field from ccdb for current collision + d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } + mRunNumber = collision.runNumber(); + } + + void addhistograms() + { + const AxisSpec axis_mass{200, 0, 0.8, "m_{#gamma#gamma} (GeV/c^{2})"}; + const AxisSpec axis_pair_pt{100, 0, 10, "p_{T,#gamma#gamma} (GeV/c)"}; + const AxisSpec axis_phiv{180, 0, M_PI, "#varphi_{V} (rad.)"}; + + // for pair + fRegistry.add("Pair/PCMPCM/before/hMvsPt", "m_{#gamma#gamma} vs. p_{T,#gamma#gamma}", kTH2D, {axis_mass, axis_pair_pt}, true); + fRegistry.add("Pair/PCMDalitzEE/before/hMvsPt", "m_{ee#gamma} vs. p_{T,ee#gamma}", kTH2D, {axis_mass, axis_pair_pt}, true); + fRegistry.add("Pair/PCMDalitzEE/before/hMvsPhiV", "m_{ee} vs. #varphi_{V}", kTH2D, {{180, 0, M_PI}, {100, 0, 0.1}}, true); + fRegistry.addClone("Pair/PCMPCM/before/", "Pair/PCMPCM/after/"); + fRegistry.addClone("Pair/PCMDalitzEE/before/", "Pair/PCMDalitzEE/after/"); + } + + void DefineEMEventCut() + { + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); + fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); + fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); + fEMEventCut.SetRequireNoTFB(eventcuts.cfgRequireNoTFB); + fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); + fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); + fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + } + + void DefinePCMCut() + { + fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); + + // for v0 + fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, pcmcuts.cfg_max_pt_v0); + fV0PhotonCut.SetV0EtaRange(pcmcuts.cfg_min_eta_v0, pcmcuts.cfg_max_eta_v0); + fV0PhotonCut.SetMinCosPA(pcmcuts.cfg_min_cospa); + fV0PhotonCut.SetMaxPCA(pcmcuts.cfg_max_pca); + fV0PhotonCut.SetMaxChi2KF(pcmcuts.cfg_max_chi2kf); + fV0PhotonCut.SetRxyRange(pcmcuts.cfg_min_v0radius, pcmcuts.cfg_max_v0radius); + fV0PhotonCut.SetAPRange(pcmcuts.cfg_max_alpha_ap, pcmcuts.cfg_max_qt_ap); + fV0PhotonCut.RejectITSib(pcmcuts.cfg_reject_v0_on_itsib); + + // for track + fV0PhotonCut.SetMinNClustersTPC(pcmcuts.cfg_min_ncluster_tpc); + fV0PhotonCut.SetMinNCrossedRowsTPC(pcmcuts.cfg_min_ncrossedrows); + fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fV0PhotonCut.SetMaxFracSharedClustersTPC(pcmcuts.cfg_max_frac_shared_clusters_tpc); + fV0PhotonCut.SetChi2PerClusterTPC(0.0, pcmcuts.cfg_max_chi2tpc); + fV0PhotonCut.SetTPCNsigmaElRange(pcmcuts.cfg_min_TPCNsigmaEl, pcmcuts.cfg_max_TPCNsigmaEl); + fV0PhotonCut.SetChi2PerClusterITS(-1e+10, pcmcuts.cfg_max_chi2its); + fV0PhotonCut.SetDisableITSonly(pcmcuts.cfg_disable_itsonly_track); + fV0PhotonCut.SetDisableTPConly(pcmcuts.cfg_disable_tpconly_track); + + fV0PhotonCut.SetNClustersITS(0, 7); + fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); + fV0PhotonCut.SetIsWithinBeamPipe(pcmcuts.cfg_require_v0_with_correct_xz); + } + + void DefineDileptonCut() + { + fDileptonCut = DalitzEECut("fDileptonCut", "fDileptonCut"); + + // for pair + fDileptonCut.SetMeeRange(dileptoncuts.cfg_min_mee, dileptoncuts.cfg_max_mee); + fDileptonCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dileptoncuts.cfg_phiv_intercept) / dileptoncuts.cfg_phiv_slope; }); + fDileptonCut.ApplyPhiV(false); + fDileptonCut.RequireITSibAny(dileptoncuts.cfg_require_itsib_any); + fDileptonCut.RequireITSib1st(dileptoncuts.cfg_require_itsib_1st); + + // for track + fDileptonCut.SetTrackPtRange(dileptoncuts.cfg_min_pt_track, dileptoncuts.cfg_max_pt_track); + fDileptonCut.SetTrackEtaRange(-dileptoncuts.cfg_min_eta_track, +dileptoncuts.cfg_max_eta_track); + fDileptonCut.SetMinNClustersTPC(dileptoncuts.cfg_min_ncluster_tpc); + fDileptonCut.SetMinNCrossedRowsTPC(dileptoncuts.cfg_min_ncrossedrows); + fDileptonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fDileptonCut.SetMaxFracSharedClustersTPC(dileptoncuts.cfg_max_frac_shared_clusters_tpc); + fDileptonCut.SetChi2PerClusterTPC(0.0, dileptoncuts.cfg_max_chi2tpc); + fDileptonCut.SetChi2PerClusterITS(0.0, dileptoncuts.cfg_max_chi2its); + fDileptonCut.SetNClustersITS(dileptoncuts.cfg_min_ncluster_its, 7); + fDileptonCut.SetMaxDcaXY(dileptoncuts.cfg_max_dcaxy); + fDileptonCut.SetMaxDcaZ(dileptoncuts.cfg_max_dcaz); + fDileptonCut.SetTrackDca3DRange(0.f, dileptoncuts.cfg_max_dca3dsigma_track); // in sigma + + // for eID + fDileptonCut.SetPIDScheme(dileptoncuts.cfg_pid_scheme); + fDileptonCut.SetTPCNsigmaElRange(dileptoncuts.cfg_min_TPCNsigmaEl, dileptoncuts.cfg_max_TPCNsigmaEl); + fDileptonCut.SetTPCNsigmaPiRange(dileptoncuts.cfg_min_TPCNsigmaPi, dileptoncuts.cfg_max_TPCNsigmaPi); + fDileptonCut.SetTOFNsigmaElRange(dileptoncuts.cfg_min_TOFNsigmaEl, dileptoncuts.cfg_max_TOFNsigmaEl); + } + + template + void runPairing(TCollisions const& collisions, + TPhotons1 const& photons1, TPhotons2 const& photons2, + TSubInfos1 const&, TSubInfos2 const&, + TPreslice1 const& perCollision1, TPreslice2 const& perCollision2, + TCut1 const& cut1, TCut2 const& cut2) + { + if constexpr (pairtype == PairType::kPCMPCM) { + for (const auto& photon1 : photons1) { + map_pfb_v0[photon1.globalIndex()] = 0; + } // end of v0 loop + } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + for (const auto& photon1 : photons1) { + map_pfb_v0[photon1.globalIndex()] = 0; + } // end of v0 loop + for (const auto& photon2 : photons2) { + map_pfb_ele[photon2.globalIndex()] = 0; + } // end of electron loop + } + + if constexpr (pairtype == PairType::kPCMPCM) { + for (const auto& collision : collisions) { + initCCDB(collision); + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + bool is_cent_ok = true; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + is_cent_ok = false; + } + + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); + auto photons2_per_collision = photons2.sliceBy(perCollision2, collision.globalIndex()); + + if (!fEMEventCut.IsSelected(collision) || !is_cent_ok) { + for (const auto& photon1 : photons1_per_collision) { + map_pfb_v0[photon1.globalIndex()] = 0; + } + continue; + } + for (const auto& [g1, g2] : combinations(CombinationsStrictlyUpperIndexPolicy(photons1_per_collision, photons2_per_collision))) { + if (!cut1.template IsSelected(g1) || !cut2.template IsSelected(g2)) { + continue; + } + // don't apply pair cut when you produce prefilter bit. + + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.f); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.f); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + fRegistry.fill(HIST("Pair/PCMPCM/before/hMvsPt"), v12.M(), v12.Pt()); + + if (ggcuts.cfg_min_mass < v12.M() && v12.M() < ggcuts.cfg_max_mass) { + map_pfb_v0[g1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::photonmeson::utils::pairutil::PhotonPrefilterBitDerived::kPhotonFromPi0gg); + map_pfb_v0[g2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::photonmeson::utils::pairutil::PhotonPrefilterBitDerived::kPhotonFromPi0gg); + } + } // end of 2photon pairing loop + } // end of collision loop + } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + for (const auto& collision : collisions) { + initCCDB(collision); + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + bool is_cent_ok = true; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + is_cent_ok = false; + } + + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); + auto positrons_per_collision = posTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + auto electrons_per_collision = negTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + + if (!fEMEventCut.IsSelected(collision) || !is_cent_ok) { + for (const auto& photon1 : photons1_per_collision) { + map_pfb_v0[photon1.globalIndex()] = 0; + } + for (const auto& pos : positrons_per_collision) { + map_pfb_ele[pos.globalIndex()] = 0; + } + for (const auto& ele : electrons_per_collision) { + map_pfb_ele[ele.globalIndex()] = 0; + } + continue; + } + + for (const auto& [g1, g2] : combinations(CombinationsStrictlyUpperIndexPolicy(photons1_per_collision, photons1_per_collision))) { // PCM-PCM // cut, and subinfo is different from kPCMPCM + if (!cut1.template IsSelected(g1) || !cut1.template IsSelected(g2)) { + continue; + } + // don't apply pair cut when you produce prefilter bit. + + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.f); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.f); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + fRegistry.fill(HIST("Pair/PCMPCM/before/hMvsPt"), v12.M(), v12.Pt()); + + if (ggcuts.cfg_min_mass < v12.M() && v12.M() < ggcuts.cfg_max_mass) { + map_pfb_v0[g1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::photonmeson::utils::pairutil::PhotonPrefilterBitDerived::kPhotonFromPi0gg); + map_pfb_v0[g2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::photonmeson::utils::pairutil::PhotonPrefilterBitDerived::kPhotonFromPi0gg); + } + } // end of 2photon pairing loop + + for (const auto& g1 : photons1_per_collision) { // PCM-DalitzEE + if (!cut1.template IsSelected(g1)) { + continue; + } + auto pos1 = g1.template posTrack_as(); + auto ele1 = g1.template negTrack_as(); + ROOT::Math::PtEtaPhiMVector v_gamma(g1.pt(), g1.eta(), g1.phi(), 0.); + + for (const auto& [pos2, ele2] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) { + if (pos2.trackId() == ele2.trackId()) { // this is protection against pairing identical 2 tracks. + continue; + } + if (pos1.trackId() == pos2.trackId() || ele1.trackId() == ele2.trackId()) { + continue; + } + + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v_pos(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ele(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ee = v_pos + v_ele; + if (!(dileptoncuts.cfg_min_mee < v_ee.M() && v_ee.M() < dileptoncuts.cfg_max_mee)) { + continue; + } + ROOT::Math::PtEtaPhiMVector veeg = v_gamma + v_pos + v_ele; + fRegistry.fill(HIST("Pair/PCMDalitzEE/before/hMvsPt"), veeg.M(), veeg.Pt()); + + if (eegcuts.cfg_min_mass < veeg.M() && veeg.M() < eegcuts.cfg_max_mass) { + map_pfb_v0[g1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::photonmeson::utils::pairutil::PhotonPrefilterBitDerived::kPhotonFromPi0eeg); + map_pfb_ele[pos2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::photonmeson::utils::pairutil::ElectronPrefilterBitDerived::kElectronFromPi0eeg); + map_pfb_ele[ele2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::photonmeson::utils::pairutil::ElectronPrefilterBitDerived::kElectronFromPi0eeg); + } + } // end of dielectron loop + } // end of g1 loop + + for (const auto& [pos2, ele2] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) { + if (pos2.trackId() == ele2.trackId()) { // this is protection against pairing identical 2 tracks. + continue; + } + + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v_pos(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ele(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ee = v_pos + v_ele; + float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos2.px(), pos2.py(), pos2.pz(), ele2.px(), ele2.py(), ele2.pz(), pos2.sign(), ele2.sign(), d_bz); + fRegistry.fill(HIST("Pair/PCMDalitzEE/before/hMvsPhiV"), phiv, v_ee.M()); + + if (v_ee.M() < phiv * dileptoncuts.cfg_phiv_slope + dileptoncuts.cfg_phiv_intercept) { + map_pfb_ele[pos2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::photonmeson::utils::pairutil::ElectronPrefilterBitDerived::kElectronFromFakePC); + map_pfb_ele[ele2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::photonmeson::utils::pairutil::ElectronPrefilterBitDerived::kElectronFromFakePC); + } + } // end of dielectron loop to reject photon conversion + } // end of collision loop + } + + if constexpr (pairtype == PairType::kPCMPCM) { + for (const auto& photon1 : photons1) { + pfb_v0_derived(map_pfb_v0[photon1.globalIndex()]); + } // end of v0 loop + } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + for (const auto& photon1 : photons1) { + pfb_v0_derived(map_pfb_v0[photon1.globalIndex()]); + } // end of v0 loop + for (const auto& photon2 : photons2) { + pfb_ele_derived(map_pfb_ele[photon2.globalIndex()]); + } // end of electron loop + } + + // check pfb. + if constexpr (pairtype == PairType::kPCMPCM) { + for (auto& collision : collisions) { + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); + auto photons2_per_collision = photons2.sliceBy(perCollision2, collision.globalIndex()); + + for (const auto& [g1, g2] : combinations(CombinationsStrictlyUpperIndexPolicy(photons1_per_collision, photons2_per_collision))) { + if (!cut1.template IsSelected(g1) || !cut2.template IsSelected(g2)) { + continue; + } + if (map_pfb_v0[g1.globalIndex()] != 0 || map_pfb_v0[g2.globalIndex()] != 0) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.f); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.f); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + fRegistry.fill(HIST("Pair/PCMPCM/after/hMvsPt"), v12.M(), v12.Pt()); + } + } // end of collision loop + } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + for (auto& collision : collisions) { + initCCDB(collision); + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); + auto positrons_per_collision = posTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + auto electrons_per_collision = negTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + + for (const auto& [g1, g2] : combinations(CombinationsStrictlyUpperIndexPolicy(photons1_per_collision, photons1_per_collision))) { + if (!cut1.template IsSelected(g1) || !cut1.template IsSelected(g2)) { + continue; + } + if (map_pfb_v0[g1.globalIndex()] != 0 || map_pfb_v0[g2.globalIndex()] != 0) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.f); + ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.f); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + fRegistry.fill(HIST("Pair/PCMPCM/after/hMvsPt"), v12.M(), v12.Pt()); + } + + for (const auto& g1 : photons1_per_collision) { + if (!cut1.template IsSelected(g1)) { + continue; + } + auto pos1 = g1.template posTrack_as(); + auto ele1 = g1.template negTrack_as(); + ROOT::Math::PtEtaPhiMVector v_gamma(g1.pt(), g1.eta(), g1.phi(), 0.); + + for (const auto& [pos2, ele2] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) { + if (pos2.trackId() == ele2.trackId()) { // this is protection against pairing identical 2 tracks. + continue; + } + if (pos1.trackId() == pos2.trackId() || ele1.trackId() == ele2.trackId()) { + continue; + } + + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + continue; + } + if (map_pfb_v0[g1.globalIndex()] != 0 || map_pfb_ele[pos2.globalIndex()] != 0 || map_pfb_ele[ele2.globalIndex()] != 0) { + continue; + } + + ROOT::Math::PtEtaPhiMVector v_pos(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ele(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v_ee = v_pos + v_ele; + float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pos2.px(), pos2.py(), pos2.pz(), ele2.px(), ele2.py(), ele2.pz(), pos2.sign(), ele2.sign(), d_bz); + if (!(dileptoncuts.cfg_min_mee < v_ee.M() && v_ee.M() < dileptoncuts.cfg_max_mee)) { + continue; + } + ROOT::Math::PtEtaPhiMVector veeg = v_gamma + v_pos + v_ele; + fRegistry.fill(HIST("Pair/PCMDalitzEE/after/hMvsPt"), veeg.M(), veeg.Pt()); + fRegistry.fill(HIST("Pair/PCMDalitzEE/after/hMvsPhiV"), phiv, v_ee.M()); + } // end of dielectron loop + } // end of g1 loop + } // end of collision loop + } + + map_pfb_v0.clear(); + map_pfb_ele.clear(); + } + + std::unordered_map map_pfb_v0; // map v0.globalIndex -> prefilter bit + std::unordered_map map_pfb_ele; // map ele.globalIndex -> prefilter bit + + SliceCache cache; + Preslice perCollision_v0 = aod::v0photonkf::emeventId; + Preslice perCollision_electron = aod::emprimaryelectron::emeventId; + + Filter collisionFilter_centrality = (cfgCentMin < o2::aod::cent::centFT0M && o2::aod::cent::centFT0M < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0A && o2::aod::cent::centFT0A < cfgCentMax) || (cfgCentMin < o2::aod::cent::centFT0C && o2::aod::cent::centFT0C < cfgCentMax); + Filter collisionFilter_occupancy_track = eventcuts.cfgTrackOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgTrackOccupancyMax; + Filter collisionFilter_occupancy_ft0c = eventcuts.cfgFT0COccupancyMin <= o2::aod::evsel::ft0cOccupancyInTimeRange && o2::aod::evsel::ft0cOccupancyInTimeRange < eventcuts.cfgFT0COccupancyMax; + using FilteredMyCollisions = soa::Filtered; + + Partition posTracks = o2::aod::emprimaryelectron::sign > int8_t(0); + Partition negTracks = o2::aod::emprimaryelectron::sign < int8_t(0); + + void processPCMPCM(FilteredMyCollisions const& collisions, MyV0Photons const& v0s, aod::V0Legs const& v0legs) + { + runPairing(collisions, v0s, v0s, v0legs, v0legs, perCollision_v0, perCollision_v0, fV0PhotonCut, fV0PhotonCut); // produces filter bit for both photons + } + PROCESS_SWITCH(prefilterPhoton, processPCMPCM, "produce prefilter bit for PCM-PCM", false); + + void processPCMDalitzEE(FilteredMyCollisions const& collisions, MyV0Photons const& v0s, aod::V0Legs const& v0legs, MyPrimaryElectrons const& primaryelectrons) + { + runPairing(collisions, v0s, primaryelectrons, v0legs, primaryelectrons, perCollision_v0, perCollision_electron, fV0PhotonCut, fDileptonCut); // produces filter bit for both photons and electrons + } + PROCESS_SWITCH(prefilterPhoton, processPCMDalitzEE, "produce prefilter bit for PCM-DalitzEE", false); + + void processDummyV0(MyV0Photons const& v0s) + { + for (int i = 0; i < v0s.size(); i++) { + pfb_v0_derived(0); + } + } + PROCESS_SWITCH(prefilterPhoton, processDummyV0, "dummy for v0s", true); + + void processDummyElectron(MyPrimaryElectrons const& primaryelectrons) + { + for (int i = 0; i < primaryelectrons.size(); i++) { + pfb_ele_derived(0); + } + } + PROCESS_SWITCH(prefilterPhoton, processDummyElectron, "dummy for electrons", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"prefilter-photon"})}; +} diff --git a/PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.cxx b/PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.cxx index 1e2eeee94b1..3f019289988 100644 --- a/PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.cxx @@ -14,68 +14,89 @@ /// /// \author M. Hemmer, marvin.hemmer@cern.ch -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Math/Vector4D.h" -#include "Math/Vector3D.h" -#include "Math/LorentzRotation.h" -#include "Math/Rotation3D.h" -#include "Math/AxisAngle.h" - -#include "CCDB/BasicCCDBManager.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/EventPlaneHelper.h" -#include "Common/Core/RecoDecay.h" -#include "Common/DataModel/Qvectors.h" -#include "CommonConstants/MathConstants.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsEMCAL/Constants.h" -#include "EMCALBase/Geometry.h" -#include "EMCALCalib/BadChannelMap.h" - -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" #include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" #include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h" -#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" #include "PWGEM/PhotonMeson/Utils/EventHistograms.h" -#include "PWGEM/PhotonMeson/Utils/NMHistograms.h" +#include "PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h" + +#include "Common/CCDB/TriggerAliases.h" +#include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include // IWYU pragma: keep +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -using namespace o2::aod::pwgem::photonmeson::photonpair; using namespace o2::aod::pwgem::photon; -using namespace o2::aod::pwgem::dilepton::utils; - -enum QvecEstimator { FT0M = 0, - FT0A = 1, - FT0C, - TPCPos, - TPCNeg, - TPCTot }; - -enum CentralityEstimator { None = 0, - CFT0A = 1, - CFT0C, - CFT0M, - NCentralityEstimators + +enum QvecEstimator { + FT0M = 0, + FT0A = 1, + FT0C, + TPCPos, + TPCNeg, + TPCTot +}; + +enum CentralityEstimator { + None = 0, + CFT0A = 1, + CFT0C, + CFT0M, + NCentralityEstimators +}; + +enum Harmonics { + kNone = 0, + kDirect = 1, + kElliptic = 2, + kTriangluar = 3, + kQuadrangular = 4, + kPentagonal = 5, + kHexagonal = 6, + kHeptagonal = 7, + kOctagonal = 8 }; struct TaskPi0FlowEMC { @@ -90,16 +111,24 @@ struct TaskPi0FlowEMC { Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable cfgDoRotation{"cfgDoRotation", true, "Flag to enable rotation background method"}; Configurable cfgDownsampling{"cfgDownsampling", 1, "Calculate rotation background only for every collision"}; - Configurable cfgRotAngle{"cfgRotAngle", M_PI / 2., "Angle used for the rotation method"}; + Configurable cfgEMCalMapLevelBackground{"cfgEMCalMapLevelBackground", 2, "Different levels of correction for the background, the smaller number includes the level of the higher number (4: none, 3: only inside EMCal, 2: exclude bad channels, 1: remove edges)"}; + Configurable cfgEMCalMapLevelSameEvent{"cfgEMCalMapLevelSameEvent", 1, "Different levels of correction for the same event, the smaller number includes the level of the higher number (4: none, 3: only inside EMCal, 2: exclude bad channels, 1: remove edges)"}; + Configurable cfgRotAngle{"cfgRotAngle", std::move(const_cast(o2::constants::math::PIHalf)), "Angle used for the rotation method"}; Configurable cfgDistanceToEdge{"cfgDistanceToEdge", 1, "Distance to edge in cells required for rotated cluster to be accepted"}; + Configurable cfgDoM02{"cfgDoM02", false, "Flag to enable flow vs M02 for single photons"}; + Configurable cfgDoReverseScaling{"cfgDoReverseScaling", false, "Flag to reverse the scaling that is possibly applied during NonLin"}; + Configurable cfgDoPlaneQA{"cfgDoPlaneQA", false, "Flag to enable QA plots comparing in and out of plane"}; + Configurable cfgMaxQVector{"cfgMaxQVector", 20.f, "Maximum allowed absolute QVector value."}; + Configurable cfgMaxAsymmetry{"cfgMaxAsymmetry", 0.1f, "Maximum allowed asymmetry for photon pairs used in calibration."}; // configurable axis - ConfigurableAxis thnConfigAxisInvMass{"thnConfigAxisInvMass", {200, 0.0, 0.4}, ""}; + ConfigurableAxis thnConfigAxisInvMass{"thnConfigAxisInvMass", {400, 0.0, 0.8}, ""}; ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {100, 0., 20.}, ""}; ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {20, 0., 100.}, ""}; ConfigurableAxis thnConfigAxisCosNPhi{"thnConfigAxisCosNPhi", {100, -1., 1.}, ""}; - ConfigurableAxis thnConfigAxisCosDeltaPhi{"thnConfigAxisCosDeltaPhi", {100, -1., 1.}, ""}; + ConfigurableAxis thnConfigAxisCosDeltaPhi{"thnConfigAxisCosDeltaPhi", {8, -1., 1.}, ""}; ConfigurableAxis thnConfigAxisScalarProd{"thnConfigAxisScalarProd", {100, -5., 5.}, ""}; + ConfigurableAxis thnConfigAxisM02{"thnConfigAxisM02", {200, 0., 5.}, ""}; EMPhotonEventCut fEMEventCut; struct : ConfigurableGroup { @@ -116,8 +145,8 @@ struct TaskPi0FlowEMC { Configurable cfgRequireEMCHardwareTriggered{"cfgRequireEMCHardwareTriggered", false, "require the EMC to be hardware triggered (kEMC7 or kDMC7)"}; Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -1, "min. track occupancy"}; Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. track occupancy"}; - Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -1, "min. FT0C occupancy"}; - Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; + Configurable cfgFT0COccupancyMin{"cfgFT0COccupancyMin", -1, "min. FT0C occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. FT0C occupancy"}; Configurable cfgMinCent{"cfgMinCent", 0, "min. centrality (%)"}; Configurable cfgMaxCent{"cfgMaxCent", 90, "max. centrality (%)"}; Configurable onlyKeepWeightedEvents{"onlyKeepWeightedEvents", false, "flag to keep only weighted events (for JJ MCs) and remove all MB events (with weight = 1)"}; @@ -127,6 +156,7 @@ struct TaskPi0FlowEMC { EMCPhotonCut fEMCCut; struct : ConfigurableGroup { std::string prefix = "emccuts"; + Configurable clusterDefinition{"clusterDefinition", "kV3Default", "Clusterizer to be selected, e.g. V3Default"}; Configurable cfgEMCminTime{"cfgEMCminTime", -25., "Minimum cluster time for EMCal time cut"}; Configurable cfgEMCmaxTime{"cfgEMCmaxTime", +30., "Maximum cluster time for EMCal time cut"}; Configurable cfgEMCminM02{"cfgEMCminM02", 0.1, "Minimum M02 for EMCal M02 cut"}; @@ -170,23 +200,56 @@ struct TaskPi0FlowEMC { SliceCache cache; EventPlaneHelper epHelper; o2::framework::Service ccdb; + int runNow = 0; + int runBefore = -1; Filter clusterFilter = aod::skimmedcluster::time >= emccuts.cfgEMCminTime && aod::skimmedcluster::time <= emccuts.cfgEMCmaxTime && aod::skimmedcluster::m02 >= emccuts.cfgEMCminM02 && aod::skimmedcluster::m02 <= emccuts.cfgEMCmaxM02 && skimmedcluster::e >= emccuts.cfgEMCminE; - Filter collisionFilter = aod::evsel::sel8 && nabs(aod::collision::posZ) <= eventcuts.cfgZvtxMax && aod::evsel::trackOccupancyInTimeRange <= eventcuts.cfgTrackOccupancyMax && aod::evsel::trackOccupancyInTimeRange >= eventcuts.cfgTrackOccupancyMin && aod::evsel::ft0cOccupancyInTimeRange <= eventcuts.cfgFT0COccupancyMax && aod::evsel::ft0cOccupancyInTimeRange >= eventcuts.cfgFT0COccupancyMin; + Filter collisionFilter = (nabs(aod::collision::posZ) <= eventcuts.cfgZvtxMax) && (aod::evsel::ft0cOccupancyInTimeRange <= eventcuts.cfgFT0COccupancyMax) && (aod::evsel::ft0cOccupancyInTimeRange >= eventcuts.cfgFT0COccupancyMin); using FilteredEMCalPhotons = soa::Filtered>; using EMCalPhotons = soa::Join; using FilteredCollsWithQvecs = soa::Filtered>; using CollsWithQvecs = soa::Join; Preslice perCollisionEMC = aod::emccluster::emeventId; - Preslice perCollisionEMCFiltered = aod::emccluster::emeventId; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; o2::emcal::Geometry* emcalGeom; + o2::emcal::BadChannelMap* mBadChannels; TH1D* h1SPResolution = nullptr; + // Constants for eta and phi ranges + double etaMin = -0.75, etaMax = 0.75; + int nBinsEta = 150; // 150 bins for eta + + double phiMin = 1.35, phiMax = 5.75; + int nBinsPhi = 440; // (440 bins = 0.01 step size covering most regions) + + std::vector lookupTable1D; float epsilon = 1.e-8; + // static constexpr + static constexpr int64_t NMinPhotonRotBkg = 3; + + // To access the 1D array + inline int getIndex(int iEta, int iPhi) + { + return iEta * nBinsPhi + iPhi; + } + + // Function to access the lookup table + inline int8_t checkEtaPhi1D(double eta, double phi) + { + if (eta < etaMin || eta > etaMax || phi < phiMin || phi > phiMax) { + return 3; // Out of bounds + } + + // Compute indices directly + int iEta = static_cast((eta - etaMin) / ((etaMax - etaMin) / nBinsEta)); + int iPhi = static_cast((phi - phiMin) / ((phiMax - phiMin) / nBinsPhi)); + + return lookupTable1D[getIndex(iEta, iPhi)]; + } + void defineEMEventCut() { fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); @@ -222,11 +285,12 @@ struct TaskPi0FlowEMC { fEMCCut.SetM02Range(emccuts.cfgEMCminM02, emccuts.cfgEMCmaxM02); fEMCCut.SetTimeRange(emccuts.cfgEMCminTime, emccuts.cfgEMCmaxTime); fEMCCut.SetUseExoticCut(emccuts.cfgEMCUseExoticCut); + fEMCCut.SetClusterizer(emccuts.clusterDefinition); } void init(InitContext&) { - if (harmonic != 2 && harmonic != 3) { + if (harmonic != kElliptic && harmonic != kTriangluar) { LOG(info) << "Harmonic was set to " << harmonic << " but can only be 2 or 3!"; } @@ -235,15 +299,13 @@ struct TaskPi0FlowEMC { fEMCCut.SetUseTM(emccuts.cfgEMCUseTM); // disables TM o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(®istry); - // Load EMCal geometry - emcalGeom = o2::emcal::Geometry::GetInstanceFromRunNumber(300000); - const AxisSpec thnAxisInvMass{thnConfigAxisInvMass, "#it{M}_{#gamma#gamma} (GeV/#it{c}^{2})"}; const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"}; const AxisSpec thnAxisCent{thnConfigAxisCent, "Centrality (%)"}; const AxisSpec thnAxisCosNPhi{thnConfigAxisCosNPhi, Form("cos(%d#varphi)", harmonic.value)}; const AxisSpec thnAxisCosDeltaPhi{thnConfigAxisCosDeltaPhi, Form("cos(%d(#varphi - #Psi_{sub}))", harmonic.value)}; const AxisSpec thnAxisScalarProd{thnConfigAxisScalarProd, "SP"}; + const AxisSpec thnAxisM02{thnConfigAxisM02, "M_{02}"}; const AxisSpec thAxisTanThetaPhi{mesonConfig.thConfigAxisTanThetaPhi, "atan(#Delta#theta/#Delta#varphi)"}; const AxisSpec thAxisClusterEnergy{thnConfigAxisPt, "#it{E} (GeV)"}; const AxisSpec thAxisAlpha{100, -1., +1, "#alpha"}; @@ -251,15 +313,25 @@ struct TaskPi0FlowEMC { const AxisSpec thAxisEnergy{1000, 0., 100., "#it{E}_{clus} (GeV)"}; const AxisSpec thAxisEnergyCalib{100, 0., 20., "#it{E}_{clus} (GeV)"}; const AxisSpec thAxisTime{1500, -600, 900, "#it{t}_{cl} (ns)"}; - const AxisSpec thAxisEta{160, -0.8, 0.8, "#eta"}; - const AxisSpec thAxisPhi{72, 0, 2 * 3.14159, "phi"}; + const AxisSpec thAxisEta{320, -0.8, 0.8, "#eta"}; + const AxisSpec thAxisPhi{500, 0, 2 * 3.14159, "phi"}; const AxisSpec thAxisNCell{17664, 0.5, +17664.5, "#it{N}_{cell}"}; const AxisSpec thAxisPsi{360 / harmonic.value, -(1. / static_cast(harmonic.value)) * std::numbers::pi_v, (1. / static_cast(harmonic.value)) * std::numbers::pi_v, Form("#Psi_{%d}", harmonic.value)}; const AxisSpec thAxisCN{8, 0.5, 8.5, "#it{c}_{n}"}; const AxisSpec thAxisSN{8, 0.5, 8.5, "#it{s}_{n}"}; + const AxisSpec thAxisCPUTime{1000, 0, 10000, "#it{t} (#mus)"}; + + const AxisSpec thnAxisMixingVtx{mixingConfig.cfgVtxBins, "#it{z} (cm)"}; + const AxisSpec thnAxisMixingCent{mixingConfig.cfgCentBins, "Centrality (%)"}; + const AxisSpec thnAxisMixingEP{mixingConfig.cfgEPBins, Form("cos(%d#varphi)", harmonic.value)}; registry.add("hSparsePi0Flow", "THn for SP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisScalarProd}); - registry.add("hSparseBkgFlow", "THn for SP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisScalarProd}); + registry.add("hSparseBkgRotFlow", "THn for SP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisScalarProd}); + registry.add("hSparseBkgMixFlow", "THn for SP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisScalarProd}); + registry.add("h3DMixingCount", "THn Event Mixing QA", HistType::kTH3D, {thnAxisMixingVtx, thnAxisMixingCent, thnAxisMixingEP}); + if (cfgDoPlaneQA.value) { + registry.add("hSparsePi0FlowPlane", "THn for SP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisCosDeltaPhi}); + } auto hClusterCuts = registry.add("hClusterCuts", "hClusterCuts;;Counts", kTH1D, {{6, 0.5, 6.5}}, false); hClusterCuts->GetXaxis()->SetBinLabel(1, "in"); hClusterCuts->GetXaxis()->SetBinLabel(2, "opening angle"); @@ -268,6 +340,14 @@ struct TaskPi0FlowEMC { hClusterCuts->GetXaxis()->SetBinLabel(5, "conversion cut"); hClusterCuts->GetXaxis()->SetBinLabel(6, "out"); + auto hClusterCutsMixed = registry.add("hClusterCutsMixed", "hClusterCutsMixed;;Counts", kTH1D, {{6, 0.5, 6.5}}, false); + hClusterCutsMixed->GetXaxis()->SetBinLabel(1, "in"); + hClusterCutsMixed->GetXaxis()->SetBinLabel(2, "opening angle"); + hClusterCutsMixed->GetXaxis()->SetBinLabel(3, "#it{M}_{#gamma#gamma}"); + hClusterCutsMixed->GetXaxis()->SetBinLabel(4, "#it{p}_{T}"); + hClusterCutsMixed->GetXaxis()->SetBinLabel(5, "conversion cut"); + hClusterCutsMixed->GetXaxis()->SetBinLabel(6, "out"); + if (saveSPResoHist) { registry.add("spReso/hSpResoFT0cFT0a", "hSpResoFT0cFT0a; centrality; Q_{FT0c} #bullet Q_{FT0a}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); registry.add("spReso/hSpResoFT0cTPCpos", "hSpResoFT0cTPCpos; centrality; Q_{FT0c} #bullet Q_{TPCpos}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); @@ -319,10 +399,6 @@ struct TaskPi0FlowEMC { hCollisionEMCCheck->GetXaxis()->SetBinLabel(5, "EMC MB Readout but no clusters"); hCollisionEMCCheck->GetXaxis()->SetBinLabel(6, "No EMC MB Readout but has clusters"); hCollisionEMCCheck->GetXaxis()->SetBinLabel(7, "No EMC MB Readout and no clusters"); - registry.add("LED/hMult", "multiplicity in LED events", HistType::kTH1D, {thAxisMult}); - registry.add("LED/hClusterEtaPhi", "hClusterEtaPhi", HistType::kTH2D, {thAxisPhi, thAxisEta}); - registry.add("LED/clusterTimeVsE", "Cluster time vs energy", HistType::kTH2D, {thAxisTime, thAxisEnergy}); - registry.add("LED/hNCell", "hNCell", HistType::kTH1D, {thAxisNCell}); } if (emccuts.cfgEnableQA) { @@ -334,11 +410,26 @@ struct TaskPi0FlowEMC { registry.add("hInvMassPt", "Histo for inv pair mass vs pt", HistType::kTH2D, {thnAxisInvMass, thnAxisPt}); registry.add("hTanThetaPhi", "Histo for identification of conversion cluster", HistType::kTH2D, {thnAxisInvMass, thAxisTanThetaPhi}); registry.add("hAlphaPt", "Histo of meson asymmetry vs pT", HistType::kTH2D, {thAxisAlpha, thnAxisPt}); + registry.add("mesonQA/hClusterEtaPhiBefore", "hClusterEtaPhiBefore", HistType::kTH2D, {thAxisPhi, thAxisEta}); + registry.add("mesonQA/hClusterEtaPhiAfter", "hClusterEtaPhiAfter", HistType::kTH2D, {thAxisPhi, thAxisEta}); + registry.add("hInvMassPtMixed", "Histo for inv pair mass vs pt for mixed event", HistType::kTH2D, {thnAxisInvMass, thnAxisPt}); + registry.add("hTanThetaPhiMixed", "Histo for identification of conversion cluster for mixed event", HistType::kTH2D, {thnAxisInvMass, thAxisTanThetaPhi}); + registry.add("hAlphaPtMixed", "Histo of meson asymmetry vs pT for mixed event", HistType::kTH2D, {thAxisAlpha, thnAxisPt}); + registry.add("mesonQA/hClusterEtaPhiBeforeMixed", "hClusterEtaPhiBefore for mixed event", HistType::kTH2D, {thAxisPhi, thAxisEta}); + registry.add("mesonQA/hClusterEtaPhiAfterMixed", "hClusterEtaPhiAfter for mixed event", HistType::kTH2D, {thAxisPhi, thAxisEta}); + if (cfgDoRotation) { + registry.add("mesonQA/hClusterBackEtaPhiBefore", "hClusterBackEtaPhiBefore", HistType::kTH2D, {thAxisPhi, thAxisEta}); + registry.add("mesonQA/hClusterBackEtaPhiAfter", "hClusterBackEtaPhiAfter", HistType::kTH2D, {thAxisPhi, thAxisEta}); + } } if (correctionConfig.doEMCalCalib) { registry.add("hSparseCalibSE", "THn for Calib same event", HistType::kTHnSparseF, {thnAxisInvMass, thAxisEnergyCalib, thnAxisCent}); - registry.add("hSparseCalibBack", "THn for Calib background", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisScalarProd}); + registry.add("hSparseCalibBack", "THn for Calib background", HistType::kTHnSparseF, {thnAxisInvMass, thAxisEnergyCalib, thnAxisCent}); + } + + if (cfgDoM02.value) { + registry.add("hSparseFlow", "THn for SP", HistType::kTHnSparseF, {thnAxisM02, thnAxisPt, thnAxisCent, thnAxisScalarProd}); } ccdb->setURL(ccdbUrl); @@ -350,14 +441,6 @@ struct TaskPi0FlowEMC { LOG(info) << "thnConfigAxisPt.value[1] = " << thnConfigAxisPt.value[1] << " thnConfigAxisPt.value.back() = " << thnConfigAxisPt.value.back(); }; // end init - template - void initCCDB(TCollision const& collision) - { - if (correctionConfig.cfgApplySPresolution.value) { - h1SPResolution = ccdb->getForTimeStamp(correctionConfig.cfgSpresoPath.value, collision.timestamp()); - } - } - /// Change radians to degree /// \param angle in radians /// \return angle in degree @@ -372,13 +455,7 @@ struct TaskPi0FlowEMC { float getDeltaPsiInRange(float psi1, float psi2) { float deltaPsi = psi1 - psi2; - if (std::abs(deltaPsi) > constants::math::PI / harmonic) { - if (deltaPsi > 0.) - deltaPsi -= constants::math::TwoPI / harmonic; - else - deltaPsi += constants::math::TwoPI / harmonic; - } - return deltaPsi; + return RecoDecay::constrainAngle(deltaPsi, 0.f, harmonic); } /// Fill THnSparse @@ -386,12 +463,14 @@ struct TaskPi0FlowEMC { /// \param pt is the transverse momentum of the candidate /// \param cent is the centrality of the collision /// \param sp is the scalar product + template void fillThn(float& mass, float& pt, float& cent, float& sp) { - registry.fill(HIST("hSparsePi0Flow"), mass, pt, cent, sp); + static constexpr std::string_view HistTypes[3] = {"hSparsePi0Flow", "hSparseBkgRotFlow", "hSparseBkgMixFlow"}; + registry.fill(HIST(HistTypes[histType]), mass, pt, cent, sp); } /// Get the centrality @@ -438,65 +517,65 @@ struct TaskPi0FlowEMC { switch (detector) { case QvecEstimator::FT0M: - if (harmonic == 2) { + if (harmonic == kElliptic) { xQVec = collision.q2xft0m(); yQVec = collision.q2yft0m(); - } else if (harmonic == 3) { + } else if (harmonic == kTriangluar) { xQVec = collision.q3xft0m(); yQVec = collision.q3yft0m(); } break; case QvecEstimator::FT0A: - if (harmonic == 2) { + if (harmonic == kElliptic) { xQVec = collision.q2xft0a(); yQVec = collision.q2yft0a(); - } else if (harmonic == 3) { + } else if (harmonic == kTriangluar) { xQVec = collision.q3xft0a(); yQVec = collision.q3yft0a(); } break; case QvecEstimator::FT0C: - if (harmonic == 2) { + if (harmonic == kElliptic) { xQVec = collision.q2xft0c(); yQVec = collision.q2yft0c(); - } else if (harmonic == 3) { + } else if (harmonic == kTriangluar) { xQVec = collision.q3xft0c(); yQVec = collision.q3yft0c(); } break; case QvecEstimator::TPCPos: - if (harmonic == 2) { + if (harmonic == kElliptic) { xQVec = collision.q2xbpos(); yQVec = collision.q2ybpos(); - } else if (harmonic == 3) { + } else if (harmonic == kTriangluar) { xQVec = collision.q3xbpos(); yQVec = collision.q3ybpos(); } break; case QvecEstimator::TPCNeg: - if (harmonic == 2) { + if (harmonic == kElliptic) { xQVec = collision.q2xbneg(); yQVec = collision.q2ybneg(); - } else if (harmonic == 3) { + } else if (harmonic == kTriangluar) { xQVec = collision.q3xbneg(); yQVec = collision.q3ybneg(); } break; case QvecEstimator::TPCTot: - if (harmonic == 2) { + if (harmonic == kElliptic) { xQVec = collision.q2xbtot(); yQVec = collision.q2ybtot(); - } else if (harmonic == 3) { + } else if (harmonic == kTriangluar) { xQVec = collision.q3xbtot(); yQVec = collision.q3ybtot(); } break; default: LOG(warning) << "Q vector estimator not valid. Falling back to FT0M"; - if (harmonic == 2) { + if (harmonic == kElliptic) { xQVec = collision.q2xft0m(); yQVec = collision.q2yft0m(); - } else if (harmonic == 3) { + } else if (harmonic == kTriangluar) { xQVec = collision.q3xft0m(); yQVec = collision.q3yft0m(); } @@ -511,7 +590,7 @@ struct TaskPi0FlowEMC { { bool isgood = true; for (const auto& QVec : QVecs) { - if (std::fabs(QVec) > 20.f) { + if (std::fabs(QVec) > cfgMaxQVector) { isgood = false; break; } @@ -554,12 +633,59 @@ struct TaskPi0FlowEMC { return false; } + bool isCellMasked(int cellID) + { + bool masked = false; + if (mBadChannels) { + auto maskStatus = mBadChannels->getChannelStatus(cellID); + masked = (maskStatus != o2::emcal::BadChannelMap::MaskType_t::GOOD_CELL); + } + return masked; + } + + template + void initCCDB(TCollision const& collision) + { + // Load EMCal geometry + emcalGeom = o2::emcal::Geometry::GetInstanceFromRunNumber(collision.runNumber()); + // Load Bad Channel map + mBadChannels = ccdb->getForTimeStamp("EMC/Calib/BadChannelMap", collision.timestamp()); + lookupTable1D = std::vector(nBinsEta * nBinsPhi, -1); + double binWidthEta = (etaMax - etaMin) / nBinsEta; + double binWidthPhi = (phiMax - phiMin) / nBinsPhi; + + for (int iEta = 0; iEta < nBinsEta; ++iEta) { + double etaCenter = etaMin + (iEta + 0.5) * binWidthEta; + for (int iPhi = 0; iPhi < nBinsPhi; ++iPhi) { + double phiCenter = phiMin + (iPhi + 0.5) * binWidthPhi; + try { + // Get the cell ID + int cellID = emcalGeom->GetAbsCellIdFromEtaPhi(etaCenter, phiCenter); + + // Check conditions for the cell + if (isTooCloseToEdge(cellID, 1)) { + lookupTable1D[getIndex(iEta, iPhi)] = 2; // Edge + } else if (isCellMasked(cellID)) { + lookupTable1D[getIndex(iEta, iPhi)] = 1; // Bad + } else { + lookupTable1D[getIndex(iEta, iPhi)] = 0; // Good + } + } catch (o2::emcal::InvalidPositionException& e) { + lookupTable1D[getIndex(iEta, iPhi)] = 3; // Outside geometry + } + } + } + if (correctionConfig.cfgApplySPresolution.value) { + h1SPResolution = ccdb->getForTimeStamp(correctionConfig.cfgSpresoPath.value, collision.timestamp()); + } + } + /// \brief Calculate background using rotation background method template void rotationBackground(const ROOT::Math::PtEtaPhiMVector& meson, ROOT::Math::PtEtaPhiMVector photon1, ROOT::Math::PtEtaPhiMVector photon2, TPhotons const& photons_coll, unsigned int ig1, unsigned int ig2, CollsWithQvecs::iterator const& collision) { // if less than 3 clusters are present skip event since we need at least 3 clusters - if (photons_coll.size() < 3) { + if (photons_coll.size() < NMinPhotonRotBkg) { return; } @@ -573,23 +699,21 @@ struct TaskPi0FlowEMC { photon1 = rotationMatrix * photon1; photon2 = rotationMatrix * photon2; - try { - iCellIDPhoton1 = emcalGeom->GetAbsCellIdFromEtaPhi(photon1.Eta(), photon1.Phi()); - if (isTooCloseToEdge(iCellIDPhoton1, cfgDistanceToEdge.value)) { - iCellIDPhoton1 = -1; - } - } catch (o2::emcal::InvalidPositionException& e) { + if (emccuts.cfgEnableQA) { + registry.fill(HIST("mesonQA/hClusterBackEtaPhiBefore"), RecoDecay::constrainAngle(photon1.Phi()), photon1.Eta()); // before check but after rotation + registry.fill(HIST("mesonQA/hClusterBackEtaPhiBefore"), RecoDecay::constrainAngle(photon2.Phi()), photon2.Eta()); // before check but after rotation + } + + if (checkEtaPhi1D(photon1.Eta(), RecoDecay::constrainAngle(photon1.Phi())) >= cfgEMCalMapLevelBackground.value) { iCellIDPhoton1 = -1; + } else if (emccuts.cfgEnableQA) { + registry.fill(HIST("mesonQA/hClusterBackEtaPhiAfter"), RecoDecay::constrainAngle(photon1.Phi()), photon1.Eta()); // after check } - try { - iCellIDPhoton2 = emcalGeom->GetAbsCellIdFromEtaPhi(photon2.Eta(), photon2.Phi()); - if (isTooCloseToEdge(iCellIDPhoton2, cfgDistanceToEdge.value)) { - iCellIDPhoton2 = -1; - } - } catch (o2::emcal::InvalidPositionException& e) { + if (checkEtaPhi1D(photon2.Eta(), RecoDecay::constrainAngle(photon2.Phi())) >= cfgEMCalMapLevelBackground.value) { iCellIDPhoton2 = -1; + } else if (emccuts.cfgEnableQA) { + registry.fill(HIST("mesonQA/hClusterBackEtaPhiAfter"), RecoDecay::constrainAngle(photon2.Phi()), photon2.Eta()); // after check } - if (iCellIDPhoton1 == -1 && iCellIDPhoton2 == -1) { return; } @@ -601,8 +725,11 @@ struct TaskPi0FlowEMC { if (!(fEMCCut.IsSelected(photon))) { continue; } + if (checkEtaPhi1D(photon.eta(), RecoDecay::constrainAngle(photon.phi())) >= cfgEMCalMapLevelBackground.value) { + continue; + } ROOT::Math::PtEtaPhiMVector photon3(photon.pt(), photon.eta(), photon.phi(), 0.); - if (iCellIDPhoton1 > 0) { + if (iCellIDPhoton1 >= 0) { ROOT::Math::PtEtaPhiMVector mother1 = photon1 + photon3; float openingAngle1 = std::acos(photon1.Vect().Dot(photon3.Vect()) / (photon1.P() * photon3.P())); float cosNPhi1 = std::cos(harmonic * mother1.Phi()); @@ -617,15 +744,15 @@ struct TaskPi0FlowEMC { if (mesonConfig.enableTanThetadPhi) { float dTheta = photon1.Theta() - photon3.Theta(); float dPhi = photon1.Phi() - photon3.Phi(); - if (mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { - registry.fill(HIST("hSparseBkgFlow"), mother1.M(), mother1.Pt(), cent, scalprodCand1); + if (mesonConfig.enableTanThetadPhi && mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { + registry.fill(HIST("hSparseBkgRotFlow"), mother1.M(), mother1.Pt(), cent, scalprodCand1); } } else { - registry.fill(HIST("hSparseBkgFlow"), mother1.M(), mother1.Pt(), cent, scalprodCand1); + registry.fill(HIST("hSparseBkgRotFlow"), mother1.M(), mother1.Pt(), cent, scalprodCand1); } } } - if (iCellIDPhoton2 > 0) { + if (iCellIDPhoton2 >= 0) { ROOT::Math::PtEtaPhiMVector mother2 = photon2 + photon3; float openingAngle2 = std::acos(photon2.Vect().Dot(photon3.Vect()) / (photon2.P() * photon3.P())); float cosNPhi2 = std::cos(harmonic * mother2.Phi()); @@ -640,11 +767,11 @@ struct TaskPi0FlowEMC { if (mesonConfig.enableTanThetadPhi) { float dTheta = photon2.Theta() - photon3.Theta(); float dPhi = photon2.Phi() - photon3.Phi(); - if (mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { - registry.fill(HIST("hSparseBkgFlow"), mother2.M(), mother2.Pt(), cent, scalprodCand2); + if (mesonConfig.enableTanThetadPhi && mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { + registry.fill(HIST("hSparseBkgRotFlow"), mother2.M(), mother2.Pt(), cent, scalprodCand2); } } else { - registry.fill(HIST("hSparseBkgFlow"), mother2.M(), mother2.Pt(), cent, scalprodCand2); + registry.fill(HIST("hSparseBkgRotFlow"), mother2.M(), mother2.Pt(), cent, scalprodCand2); } } } @@ -657,7 +784,7 @@ struct TaskPi0FlowEMC { void rotationBackgroundCalib(const ROOT::Math::PtEtaPhiMVector& meson, ROOT::Math::PtEtaPhiMVector photon1, ROOT::Math::PtEtaPhiMVector photon2, TPhotons const& photons_coll, unsigned int ig1, unsigned int ig2, CollsWithQvecs::iterator const& collision) { // if less than 3 clusters are present skip event since we need at least 3 clusters - if (photons_coll.size() < 3) { + if (photons_coll.size() < NMinPhotonRotBkg) { return; } float cent = getCentrality(collision); @@ -669,20 +796,10 @@ struct TaskPi0FlowEMC { photon1 = rotationMatrix * photon1; photon2 = rotationMatrix * photon2; - try { - iCellIDPhoton1 = emcalGeom->GetAbsCellIdFromEtaPhi(photon1.Eta(), photon1.Phi()); - if (isTooCloseToEdge(iCellIDPhoton1, cfgDistanceToEdge.value)) { - iCellIDPhoton1 = -1; - } - } catch (o2::emcal::InvalidPositionException& e) { + if (checkEtaPhi1D(photon1.Eta(), RecoDecay::constrainAngle(photon1.Phi())) >= cfgEMCalMapLevelBackground.value) { iCellIDPhoton1 = -1; } - try { - iCellIDPhoton2 = emcalGeom->GetAbsCellIdFromEtaPhi(photon2.Eta(), photon2.Phi()); - if (isTooCloseToEdge(iCellIDPhoton2, cfgDistanceToEdge.value)) { - iCellIDPhoton2 = -1; - } - } catch (o2::emcal::InvalidPositionException& e) { + if (checkEtaPhi1D(photon2.Eta(), RecoDecay::constrainAngle(photon2.Phi())) >= cfgEMCalMapLevelBackground.value) { iCellIDPhoton2 = -1; } @@ -697,9 +814,12 @@ struct TaskPi0FlowEMC { if (!(fEMCCut.IsSelected(photon))) { continue; } + if (checkEtaPhi1D(photon.eta(), RecoDecay::constrainAngle(photon.phi())) >= cfgEMCalMapLevelBackground.value) { + continue; + } ROOT::Math::PtEtaPhiMVector photon3(photon.pt(), photon.eta(), photon.phi(), 0.); - if (iCellIDPhoton1 > 0) { - if ((photon1.E() - photon3.E()) / (photon1.E() + photon3.E()) > 0.9) { // only use symmetric decays + if (iCellIDPhoton1 >= 0) { + if (std::fabs((photon1.E() - photon3.E()) / (photon1.E() + photon3.E()) < cfgMaxAsymmetry)) { // only use symmetric decays ROOT::Math::PtEtaPhiMVector mother1 = photon1 + photon3; float openingAngle1 = std::acos(photon1.Vect().Dot(photon3.Vect()) / (photon1.P() * photon3.P())); @@ -707,7 +827,7 @@ struct TaskPi0FlowEMC { if (mesonConfig.enableTanThetadPhi) { float dTheta = photon1.Theta() - photon3.Theta(); float dPhi = photon1.Phi() - photon3.Phi(); - if (mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { + if (mesonConfig.enableTanThetadPhi && mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { registry.fill(HIST("hSparseCalibBack"), mother1.M(), mother1.E() / 2., cent); } } else { @@ -716,8 +836,8 @@ struct TaskPi0FlowEMC { } } } - if (iCellIDPhoton2 > 0) { - if ((photon2.E() - photon3.E()) / (photon2.E() + photon3.E()) > 0.9) { // only use symmetric decays + if (iCellIDPhoton2 >= 0) { + if (std::fabs((photon2.E() - photon3.E()) / (photon2.E() + photon3.E()) < cfgMaxAsymmetry)) { // only use symmetric decays ROOT::Math::PtEtaPhiMVector mother2 = photon2 + photon3; float openingAngle2 = std::acos(photon2.Vect().Dot(photon3.Vect()) / (photon2.P() * photon3.P())); @@ -725,7 +845,7 @@ struct TaskPi0FlowEMC { if (mesonConfig.enableTanThetadPhi) { float dTheta = photon2.Theta() - photon3.Theta(); float dPhi = photon2.Phi() - photon3.Phi(); - if (mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { + if (mesonConfig.enableTanThetadPhi && mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { registry.fill(HIST("hSparseCalibBack"), mother2.M(), mother2.E() / 2., cent); } } else { @@ -741,6 +861,7 @@ struct TaskPi0FlowEMC { /// Compute the scalar product /// \param collision is the collision with the Q vector information and event plane /// \param meson are the selected candidates + template void runFlowAnalysis(CollsWithQvecs::iterator const& collision, ROOT::Math::PtEtaPhiMVector const& meson) { auto [xQVec, yQVec] = getQvec(collision, qvecDetector); @@ -758,7 +879,13 @@ struct TaskPi0FlowEMC { scalprodCand = scalprodCand / h1SPResolution->GetBinContent(h1SPResolution->FindBin(cent + epsilon)); } - fillThn(massCand, ptCand, cent, scalprodCand); + if (cfgDoPlaneQA.value && histType == 0) { + float epAngle = epHelper.GetEventPlane(xQVec, yQVec, harmonic); + float cosDeltaPhi = std::cos(harmonic * getDeltaPsiInRange(phiCand, epAngle)); + registry.fill(HIST("hSparsePi0FlowPlane"), massCand, ptCand, cent, cosDeltaPhi); + } + + fillThn(massCand, ptCand, cent, scalprodCand); return; } @@ -784,12 +911,6 @@ struct TaskPi0FlowEMC { if (photonsPerCollision.size() > 0) { registry.fill(HIST("hCollisionEMCCheck"), 3.); // has EMC cluster registry.fill(HIST("hCollisionEMCCheck"), 6.); // has no EMC read out and clusters - registry.fill(HIST("LED/hMult"), collision.multFT0C()); - for (const auto& photon : photonsPerCollision) { - registry.fill(HIST("LED/hClusterEtaPhi"), photon.phi(), photon.eta()); - registry.fill(HIST("LED/clusterTimeVsE"), photon.time(), photon.e()); - registry.fill(HIST("LED/hNCell"), photon.nCells()); - } } else { registry.fill(HIST("hCollisionEMCCheck"), 7.); // has no EMC read out and no clusters } @@ -800,7 +921,7 @@ struct TaskPi0FlowEMC { // general event selection continue; } - if (!(eventcuts.cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { + if (!(eventcuts.cfgFT0COccupancyMin <= collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) { // occupancy selection continue; } @@ -813,18 +934,27 @@ struct TaskPi0FlowEMC { // selection based on QVector continue; } - initCCDB(collision); + runNow = collision.runNumber(); + if (runNow != runBefore) { + initCCDB(collision); + runBefore = runNow; + } o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(®istry, collision); registry.fill(HIST("Event/before/hCollisionCounter"), 12.0); // accepted registry.fill(HIST("Event/after/hCollisionCounter"), 12.0); // accepted if (emccuts.cfgEnableQA) { for (const auto& photon : photonsPerCollision) { - registry.fill(HIST("hEClusterBefore"), photon.e()); // before cuts + registry.fill(HIST("hEClusterBefore"), photon.e()); // before cuts + registry.fill(HIST("mesonQA/hClusterEtaPhiBefore"), photon.phi(), photon.eta()); // before cuts if (!(fEMCCut.IsSelected(photon))) { continue; } - registry.fill(HIST("hEClusterAfter"), photon.e()); // accepted after cuts + if (cfgDistanceToEdge.value && (checkEtaPhi1D(photon.eta(), RecoDecay::constrainAngle(photon.phi())) >= cfgEMCalMapLevelSameEvent.value)) { + continue; + } + registry.fill(HIST("hEClusterAfter"), photon.e()); // accepted after cuts + registry.fill(HIST("mesonQA/hClusterEtaPhiAfter"), photon.phi(), photon.eta()); // before cuts } } for (const auto& [g1, g2] : combinations(CombinationsStrictlyUpperIndexPolicy(photonsPerCollision, photonsPerCollision))) { @@ -834,28 +964,25 @@ struct TaskPi0FlowEMC { // Cut edge clusters away, similar to rotation method to ensure same acceptance is used if (cfgDistanceToEdge.value) { - int iCellIDPhoton1 = -1; - int iCellIDPhoton2 = -1; - try { - iCellIDPhoton1 = emcalGeom->GetAbsCellIdFromEtaPhi(g1.eta(), g1.phi()); - if (isTooCloseToEdge(iCellIDPhoton1, cfgDistanceToEdge.value)) { - continue; - } - } catch (o2::emcal::InvalidPositionException& e) { + if (checkEtaPhi1D(g1.eta(), RecoDecay::constrainAngle(g1.phi())) >= cfgEMCalMapLevelSameEvent.value) { continue; } - try { - iCellIDPhoton2 = emcalGeom->GetAbsCellIdFromEtaPhi(g2.eta(), g2.phi()); - if (isTooCloseToEdge(iCellIDPhoton2, cfgDistanceToEdge.value)) { - continue; - } - } catch (o2::emcal::InvalidPositionException& e) { + if (checkEtaPhi1D(g2.eta(), RecoDecay::constrainAngle(g2.phi())) >= cfgEMCalMapLevelSameEvent.value) { continue; } } ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + if (cfgDoReverseScaling.value) { + // Convert to PxPyPzEVector to modify energy + ROOT::Math::PxPyPzEVector v1Mod(v1); + v1Mod.SetE(v1Mod.E() * 1.0505); + v1 = ROOT::Math::PtEtaPhiMVector(v1Mod.Pt(), v1Mod.Eta(), v1Mod.Phi(), 0.); + ROOT::Math::PxPyPzEVector v2Mod(v2); + v2Mod.SetE(v2Mod.E() * 1.0505); + v2 = ROOT::Math::PtEtaPhiMVector(v2Mod.Pt(), v2Mod.Eta(), v2Mod.Phi(), 0.); + } ROOT::Math::PtEtaPhiMVector vMeson = v1 + v2; float dTheta = v1.Theta() - v2.Theta(); float dPhi = v1.Phi() - v2.Phi(); @@ -888,7 +1015,7 @@ struct TaskPi0FlowEMC { continue; } registry.fill(HIST("hClusterCuts"), 6); - runFlowAnalysis(collision, vMeson); + runFlowAnalysis<0>(collision, vMeson); } if (cfgDoRotation) { if (nColl % cfgDownsampling.value == 0) { @@ -921,7 +1048,7 @@ struct TaskPi0FlowEMC { // general event selection continue; } - if (!(eventcuts.cfgTrackOccupancyMin <= c1.trackOccupancyInTimeRange() && c1.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax) || !(eventcuts.cfgTrackOccupancyMin <= c2.trackOccupancyInTimeRange() && c2.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { + if (!(eventcuts.cfgFT0COccupancyMin <= c1.ft0cOccupancyInTimeRange() && c1.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax) || !(eventcuts.cfgFT0COccupancyMin <= c2.ft0cOccupancyInTimeRange() && c2.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) { // occupancy selection continue; } @@ -933,43 +1060,67 @@ struct TaskPi0FlowEMC { // selection based on QVector continue; } - initCCDB(c1); + runNow = c1.runNumber(); + if (runNow != runBefore) { + initCCDB(c1); + runBefore = runNow; + } + registry.fill(HIST("h3DMixingCount"), c1.posZ(), getCentrality(c1), c1.ep2ft0m()); for (const auto& [g1, g2] : combinations(CombinationsFullIndexPolicy(clusters1, clusters2))) { if (!(fEMCCut.IsSelected(g1)) || !(fEMCCut.IsSelected(g2))) { continue; } + // Cut edge clusters away, similar to rotation method to ensure same acceptance is used + if (cfgDistanceToEdge.value) { + if (checkEtaPhi1D(g1.eta(), RecoDecay::constrainAngle(g1.phi())) >= cfgEMCalMapLevelBackground.value) { + continue; + } + if (checkEtaPhi1D(g2.eta(), RecoDecay::constrainAngle(g2.phi())) >= cfgEMCalMapLevelBackground.value) { + continue; + } + } ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + + if (cfgDoReverseScaling.value) { + // Convert to PxPyPzEVector to modify energy + ROOT::Math::PxPyPzEVector v1Mod(v1); + v1Mod.SetE(v1Mod.E() * 1.0505); + v1 = ROOT::Math::PtEtaPhiMVector(v1Mod.Pt(), v1Mod.Eta(), v1Mod.Phi(), 0.); + ROOT::Math::PxPyPzEVector v2Mod(v2); + v2Mod.SetE(v2Mod.E() * 1.0505); + v2 = ROOT::Math::PtEtaPhiMVector(v2Mod.Pt(), v2Mod.Eta(), v2Mod.Phi(), 0.); + } ROOT::Math::PtEtaPhiMVector vMeson = v1 + v2; float dTheta = v1.Theta() - v2.Theta(); float dPhi = v1.Phi() - v2.Phi(); float openingAngle = std::acos(v1.Vect().Dot(v2.Vect()) / (v1.P() * v2.P())); - registry.fill(HIST("hClusterCuts"), 1); + registry.fill(HIST("hClusterCutsMixed"), 1); if (openingAngle <= mesonConfig.minOpenAngle) { - registry.fill(HIST("hClusterCuts"), 2); + registry.fill(HIST("hClusterCutsMixed"), 2); continue; } if (thnConfigAxisInvMass.value[1] > vMeson.M() || thnConfigAxisInvMass.value.back() < vMeson.M()) { - registry.fill(HIST("hClusterCuts"), 3); + registry.fill(HIST("hClusterCutsMixed"), 3); continue; } if (thnConfigAxisPt.value[1] > vMeson.Pt() || thnConfigAxisPt.value.back() < vMeson.Pt()) { - registry.fill(HIST("hClusterCuts"), 4); + registry.fill(HIST("hClusterCutsMixed"), 4); continue; } if (mesonConfig.cfgEnableQA) { - registry.fill(HIST("hInvMassPt"), vMeson.M(), vMeson.Pt()); - registry.fill(HIST("hTanThetaPhi"), vMeson.M(), getAngleDegree(std::atan(dTheta / dPhi))); - registry.fill(HIST("hAlphaPt"), (v1.E() - v2.E()) / (v1.E() + v2.E()), vMeson.Pt()); + registry.fill(HIST("hInvMassPtMixed"), vMeson.M(), vMeson.Pt()); + registry.fill(HIST("hTanThetaPhiMixed"), vMeson.M(), getAngleDegree(std::atan(dTheta / dPhi))); + registry.fill(HIST("hAlphaPtMixed"), (v1.E() - v2.E()) / (v1.E() + v2.E()), vMeson.Pt()); } - if (mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { - registry.fill(HIST("hClusterCuts"), 5); + if (mesonConfig.enableTanThetadPhi && mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(std::atan(dTheta / dPhi)))) { + registry.fill(HIST("hClusterCutsMixed"), 5); continue; } - registry.fill(HIST("hClusterCuts"), 6); - runFlowAnalysis(c1, vMeson); + registry.fill(HIST("hClusterCutsMixed"), 6); + runFlowAnalysis<2>(c1, vMeson); } } } @@ -983,7 +1134,7 @@ struct TaskPi0FlowEMC { // no selection on the centrality is applied on purpose to allow for the resolution study in post-processing return; } - if (!(eventcuts.cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { + if (!(eventcuts.cfgFT0COccupancyMin <= collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) { return; } float cent = getCentrality(collision); @@ -1012,7 +1163,7 @@ struct TaskPi0FlowEMC { float yQVecBNeg = -999.f; float xQVecBTot = -999.f; float yQVecBTot = -999.f; - if (harmonic == 2) { + if (harmonic == kElliptic) { xQVecFT0a = collision.q2xft0a(); yQVecFT0a = collision.q2yft0a(); xQVecFT0c = collision.q2xft0c(); @@ -1025,7 +1176,7 @@ struct TaskPi0FlowEMC { yQVecBNeg = collision.q2ybneg(); xQVecBTot = collision.q2xbtot(); yQVecBTot = collision.q2ybtot(); - } else if (harmonic == 3) { + } else if (harmonic == kTriangluar) { xQVecFT0a = collision.q3xft0a(); yQVecFT0a = collision.q3yft0a(); xQVecFT0c = collision.q3xft0c(); @@ -1077,7 +1228,7 @@ struct TaskPi0FlowEMC { registry.fill(HIST("epReso/hEpResoFT0mTPCneg"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0m, epBNegs))); registry.fill(HIST("epReso/hEpResoFT0mTPCtot"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0m, epBTots))); registry.fill(HIST("epReso/hEpResoTPCposTPCneg"), centrality, std::cos(harmonic * getDeltaPsiInRange(epBPoss, epBNegs))); - for (int n = 1; n <= 8; n++) { + for (int n = 1; n <= kOctagonal; n++) { registry.fill(HIST("epReso/hEpCosCoefficientsFT0c"), centrality, n, std::cos(n * epFT0c)); registry.fill(HIST("epReso/hEpSinCoefficientsFT0c"), centrality, n, std::sin(n * epFT0c)); registry.fill(HIST("epReso/hEpCosCoefficientsFT0a"), centrality, n, std::cos(n * epFT0a)); @@ -1109,7 +1260,7 @@ struct TaskPi0FlowEMC { // general event selection continue; } - if (!(eventcuts.cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { + if (!(eventcuts.cfgFT0COccupancyMin <= collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) { // occupancy selection continue; } @@ -1122,7 +1273,11 @@ struct TaskPi0FlowEMC { // selection based on QVector continue; } - initCCDB(collision); + runNow = collision.runNumber(); + if (runNow != runBefore) { + initCCDB(collision); + runBefore = runNow; + } o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(®istry, collision); registry.fill(HIST("Event/before/hCollisionCounter"), 12.0); // accepted registry.fill(HIST("Event/after/hCollisionCounter"), 12.0); // accepted @@ -1143,28 +1298,25 @@ struct TaskPi0FlowEMC { // Cut edge clusters away, similar to rotation method to ensure same acceptance is used if (cfgDistanceToEdge.value) { - int iCellIDPhoton1 = -1; - int iCellIDPhoton2 = -1; - try { - iCellIDPhoton1 = emcalGeom->GetAbsCellIdFromEtaPhi(g1.eta(), g1.phi()); - if (isTooCloseToEdge(iCellIDPhoton1, cfgDistanceToEdge.value)) { - continue; - } - } catch (o2::emcal::InvalidPositionException& e) { + if (checkEtaPhi1D(g1.eta(), RecoDecay::constrainAngle(g1.phi())) >= cfgEMCalMapLevelSameEvent.value) { continue; } - try { - iCellIDPhoton2 = emcalGeom->GetAbsCellIdFromEtaPhi(g2.eta(), g2.phi()); - if (isTooCloseToEdge(iCellIDPhoton2, cfgDistanceToEdge.value)) { - continue; - } - } catch (o2::emcal::InvalidPositionException& e) { + if (checkEtaPhi1D(g2.eta(), RecoDecay::constrainAngle(g2.phi())) >= cfgEMCalMapLevelSameEvent.value) { continue; } } ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); + if (cfgDoReverseScaling.value) { + // Convert to PxPyPzEVector to modify energy + ROOT::Math::PxPyPzEVector v1Mod(v1); + v1Mod.SetE(v1Mod.E() * 1.0505); + v1 = ROOT::Math::PtEtaPhiMVector(v1Mod.Pt(), v1Mod.Eta(), v1Mod.Phi(), 0.); + ROOT::Math::PxPyPzEVector v2Mod(v2); + v2Mod.SetE(v2Mod.E() * 1.0505); + v2 = ROOT::Math::PtEtaPhiMVector(v2Mod.Pt(), v2Mod.Eta(), v2Mod.Phi(), 0.); + } ROOT::Math::PtEtaPhiMVector vMeson = v1 + v2; float dTheta = v1.Theta() - v2.Theta(); float dPhi = v1.Phi() - v2.Phi(); @@ -1196,7 +1348,7 @@ struct TaskPi0FlowEMC { registry.fill(HIST("hClusterCuts"), 5); continue; } - if ((v1.E() - v2.E()) / (v1.E() + v2.E()) > 0.9) { // only use symmetric decays + if (std::fabs((v1.E() - v2.E()) / (v1.E() + v2.E()) < cfgMaxAsymmetry)) { // only use symmetric decays registry.fill(HIST("hClusterCuts"), 6); registry.fill(HIST("hSparseCalibSE"), vMeson.M(), vMeson.E() / 2., getCentrality(collision)); } @@ -1212,6 +1364,95 @@ struct TaskPi0FlowEMC { } PROCESS_SWITCH(TaskPi0FlowEMC, processEMCalCalib, "Process EMCal calibration", false); + // Pi0 from EMCal + void processM02(CollsWithQvecs const& collisions, EMCalPhotons const& clusters) + { + for (const auto& collision : collisions) { + auto photonsPerCollision = clusters.sliceBy(perCollisionEMC, collision.globalIndex()); + + if (eventcuts.cfgEnableQA) { + registry.fill(HIST("hCollisionEMCCheck"), 1.); // all + if (collision.alias_bit(kTVXinEMC) == true) { + registry.fill(HIST("hCollisionEMCCheck"), 2.); // has EMC read out + if (photonsPerCollision.size() > 0) { + registry.fill(HIST("hCollisionEMCCheck"), 3.); // has EMC cluster + registry.fill(HIST("hCollisionEMCCheck"), 4.); // has EMC read out and clusters + } else { + registry.fill(HIST("hCollisionEMCCheck"), 5.); // has EMC read out but no clusters + } + } else { + if (photonsPerCollision.size() > 0) { + registry.fill(HIST("hCollisionEMCCheck"), 3.); // has EMC cluster + registry.fill(HIST("hCollisionEMCCheck"), 6.); // has no EMC read out and clusters + } else { + registry.fill(HIST("hCollisionEMCCheck"), 7.); // has no EMC read out and no clusters + } + } + } + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(®istry, collision); + if (!(fEMEventCut.IsSelected(collision))) { + // general event selection + continue; + } + if (!(eventcuts.cfgFT0COccupancyMin <= collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < eventcuts.cfgFT0COccupancyMax)) { + // occupancy selection + continue; + } + float cent = getCentrality(collision); + if (cent < eventcuts.cfgMinCent || cent > eventcuts.cfgMaxCent) { + // event selection + continue; + } + if (!isQvecGood(getAllQvec(collision))) { + // selection based on QVector + continue; + } + runNow = collision.runNumber(); + if (runNow != runBefore) { + initCCDB(collision); + runBefore = runNow; + } + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(®istry, collision); + registry.fill(HIST("Event/before/hCollisionCounter"), 12.0); // accepted + registry.fill(HIST("Event/after/hCollisionCounter"), 12.0); // accepted + + for (const auto& photon : photonsPerCollision) { + if (mesonConfig.cfgEnableQA) { + registry.fill(HIST("hEClusterBefore"), photon.e()); // before cuts + registry.fill(HIST("mesonQA/hClusterEtaPhiBefore"), photon.phi(), photon.eta()); // before cuts + } + if (!(fEMCCut.IsSelected(photon))) { + continue; + } + if (cfgDistanceToEdge.value && (checkEtaPhi1D(photon.eta(), RecoDecay::constrainAngle(photon.phi())) >= cfgEMCalMapLevelSameEvent.value)) { + continue; + } + if (mesonConfig.cfgEnableQA) { + registry.fill(HIST("hEClusterAfter"), photon.e()); // accepted after cuts + registry.fill(HIST("mesonQA/hClusterEtaPhiAfter"), photon.phi(), photon.eta()); // before cuts + } + + auto [xQVec, yQVec] = getQvec(collision, qvecDetector); + float cent = getCentrality(collision); + + float phiCand = photon.phi(); + + float cosNPhi = std::cos(harmonic * phiCand); + float sinNPhi = std::sin(harmonic * phiCand); + float scalprodCand = cosNPhi * xQVec + sinNPhi * yQVec; + + if (correctionConfig.cfgApplySPresolution.value) { + scalprodCand = scalprodCand / h1SPResolution->GetBinContent(h1SPResolution->FindBin(cent + epsilon)); + } + if (cfgDoM02.value) { + registry.fill(HIST("hSparseFlow"), photon.m02(), photon.pt(), cent, scalprodCand); + } + return; + } // end of loop over single cluster + } // end of loop over collisions + } // processM02 + PROCESS_SWITCH(TaskPi0FlowEMC, processM02, "Process single EMCal clusters as function of M02", false); + }; // End struct TaskPi0FlowEMC WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGEM/PhotonMeson/Utils/ClusterHistograms.h b/PWGEM/PhotonMeson/Utils/ClusterHistograms.h index 677dfa00902..b5f0eb6db85 100644 --- a/PWGEM/PhotonMeson/Utils/ClusterHistograms.h +++ b/PWGEM/PhotonMeson/Utils/ClusterHistograms.h @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -9,40 +9,51 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// Header file for histograms used in EMC cluster QA -/// \author nicolas.strangmann@cern.ch +/// \file ClusterHistograms.h +/// \brief Header file for histograms used in EMC cluster QA +/// \author N. Strangmann, nicolas.strangmann@cern.ch #ifndef PWGEM_PHOTONMESON_UTILS_CLUSTERHISTOGRAMS_H_ #define PWGEM_PHOTONMESON_UTILS_CLUSTERHISTOGRAMS_H_ +#include +#include + +#include + +#include +#include + +#include + using namespace o2::framework; namespace o2::aod::pwgem::photonmeson::utils::clusterhistogram { -void addClusterHistograms(HistogramRegistry* fRegistry, bool do2DQA) +inline void addClusterHistograms(HistogramRegistry* fRegistry, bool do2DQA) { - fRegistry->add("Cluster/before/hE", "E_{cluster};#it{E}_{cluster} (GeV);#it{N}_{cluster}", kTH1F, {{500, 0.0f, 50}}, true); - fRegistry->add("Cluster/before/hPt", "Transverse momenta of clusters;#it{p}_{T} (GeV/c);#it{N}_{cluster}", kTH1F, {{500, 0.0f, 50}}, true); - fRegistry->add("Cluster/before/hNgamma", "Number of #gamma candidates per collision;#it{N}_{#gamma} per collision;#it{N}_{collisions}", kTH1F, {{51, -0.5f, 50.5f}}, true); - fRegistry->add("Cluster/before/hEtaPhi", "#eta vs #varphi;#eta;#varphi (rad.)", kTH2F, {{280, -0.7f, 0.7f}, {180, 0, 2 * M_PI}}, true); - fRegistry->add("Cluster/before/hNTracks", "Number of tracks considered for TM;#it{N}_{tracks};#it{N}_{cluster}", kTH1F, {{20, -0.5f, 19.5}}, true); - fRegistry->add("Cluster/before/hTrackdEtadPhi", "d#eta vs. d#varphi of matched tracks;d#eta;d#varphi (rad.)", kTH2F, {{200, -0.2f, 0.2f}, {200, -0.2f, 0.2f}}, true); + fRegistry->add("Cluster/before/hE", "E_{cluster};#it{E}_{cluster} (GeV);#it{N}_{cluster}", o2::framework::kTH1F, {{500, 0.0f, 50}}, true); + fRegistry->add("Cluster/before/hPt", "Transverse momenta of clusters;#it{p}_{T} (GeV/c);#it{N}_{cluster}", o2::framework::kTH1F, {{500, 0.0f, 50}}, true); + fRegistry->add("Cluster/before/hNgamma", "Number of #gamma candidates per collision;#it{N}_{#gamma} per collision;#it{N}_{collisions}", o2::framework::kTH1F, {{51, -0.5f, 50.5f}}, true); + fRegistry->add("Cluster/before/hEtaPhi", "#eta vs #varphi;#eta;#varphi (rad.)", o2::framework::kTH2F, {{280, -0.7f, 0.7f}, {180, 0, 2 * M_PI}}, true); + fRegistry->add("Cluster/before/hNTracks", "Number of tracks considered for TM;#it{N}_{tracks};#it{N}_{cluster}", o2::framework::kTH1F, {{20, -0.5f, 19.5}}, true); + fRegistry->add("Cluster/before/hTrackdEtadPhi", "d#eta vs. d#varphi of matched tracks;d#eta;d#varphi (rad.)", o2::framework::kTH2F, {{200, -0.2f, 0.2f}, {200, -0.2f, 0.2f}}, true); if (do2DQA) { // Check if 2D QA histograms were selected in em-qc task - fRegistry->add("Cluster/before/hNCell", "#it{N}_{cells};N_{cells} (GeV);#it{E}_{cluster} (GeV)", kTH2F, {{26, -0.5, 25.5}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hM02", "Long ellipse axis;#it{M}_{02} (cm);#it{E}_{cluster} (GeV)", kTH2F, {{200, 0, 2}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hTime", "Cluster time;#it{t}_{cls} (ns);#it{E}_{cluster} (GeV)", kTH2F, {{300, -150, 150}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hTrackdEta", "d#eta vs. E of matched tracks;d#eta;#it{E}_{cluster} (GeV)", kTH2F, {{200, -0.2f, 0.2f}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hTrackdPhi", "d#phi vs. E of matched tracks;d#varphi (rad.);#it{E}_{cluster} (GeV)", kTH2F, {{200, -0.2f, 0.2f}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hTrackEOverP", "Energy of cluster divided by momentum of matched tracks;#it{E}_{cluster}/#it{p}_{track} (#it{c});#it{E}_{cluster} (GeV)", kTH2F, {{200, 0., 5.}, {200, 0, 20}}, true); + fRegistry->add("Cluster/before/hNCell", "#it{N}_{cells};N_{cells} (GeV);#it{E}_{cluster} (GeV)", o2::framework::kTH2F, {{26, -0.5, 25.5}, {200, 0, 20}}, true); + fRegistry->add("Cluster/before/hM02", "Long ellipse axis;#it{M}_{02} (cm);#it{E}_{cluster} (GeV)", o2::framework::kTH2F, {{200, 0, 2}, {200, 0, 20}}, true); + fRegistry->add("Cluster/before/hTime", "Cluster time;#it{t}_{cls} (ns);#it{E}_{cluster} (GeV)", o2::framework::kTH2F, {{300, -150, 150}, {200, 0, 20}}, true); + fRegistry->add("Cluster/before/hTrackdEta", "d#eta vs. E of matched tracks;d#eta;#it{E}_{cluster} (GeV)", o2::framework::kTH2F, {{200, -0.2f, 0.2f}, {200, 0, 20}}, true); + fRegistry->add("Cluster/before/hTrackdPhi", "d#phi vs. E of matched tracks;d#varphi (rad.);#it{E}_{cluster} (GeV)", o2::framework::kTH2F, {{200, -0.2f, 0.2f}, {200, 0, 20}}, true); + fRegistry->add("Cluster/before/hTrackEOverP", "Energy of cluster divided by momentum of matched tracks;#it{E}_{cluster}/#it{p}_{track} (#it{c});#it{E}_{cluster} (GeV)", o2::framework::kTH2F, {{200, 0., 5.}, {200, 0, 20}}, true); } else { - fRegistry->add("Cluster/before/hNCell", "#it{N}_{cells};N_{cells} (GeV);#it{N}_{cluster}", kTH1F, {{26, -0.5, 25.5}}, true); - fRegistry->add("Cluster/before/hM02", "Long ellipse axis;#it{M}_{02} (cm);#it{N}_{cluster}", kTH1F, {{400, 0, 2}}, true); - fRegistry->add("Cluster/before/hTime", "Cluster time;#it{t}_{cls} (ns);#it{N}_{cluster}", kTH1F, {{600, -150, 150}}, true); - fRegistry->add("Cluster/before/hTrackEOverP", "Energy of cluster divided by momentum of matched tracks;#it{E}_{cluster}/#it{p}_{track} (#it{c})", kTH1F, {{200, 0., 5.}}, true); + fRegistry->add("Cluster/before/hNCell", "#it{N}_{cells};N_{cells} (GeV);#it{N}_{cluster}", o2::framework::kTH1F, {{26, -0.5, 25.5}}, true); + fRegistry->add("Cluster/before/hM02", "Long ellipse axis;#it{M}_{02} (cm);#it{N}_{cluster}", o2::framework::kTH1F, {{400, 0, 2}}, true); + fRegistry->add("Cluster/before/hTime", "Cluster time;#it{t}_{cls} (ns);#it{N}_{cluster}", o2::framework::kTH1F, {{600, -150, 150}}, true); + fRegistry->add("Cluster/before/hTrackEOverP", "Energy of cluster divided by momentum of matched tracks;#it{E}_{cluster}/#it{p}_{track} (#it{c})", o2::framework::kTH1F, {{200, 0., 5.}}, true); } - auto hClusterQualityCuts = fRegistry->add("Cluster/hClusterQualityCuts", "Energy at which clusters are removed by a given cut;;#it{E} (GeV)", kTH2F, {{8, -0.5, 7.5}, {500, 0, 50}}, true); + auto hClusterQualityCuts = fRegistry->add("Cluster/hClusterQualityCuts", "Energy at which clusters are removed by a given cut;;#it{E} (GeV)", o2::framework::kTH2F, {{8, -0.5, 7.5}, {500, 0, 50}}, true); hClusterQualityCuts->GetXaxis()->SetBinLabel(1, "In"); hClusterQualityCuts->GetXaxis()->SetBinLabel(2, "Energy"); hClusterQualityCuts->GetXaxis()->SetBinLabel(3, "NCell"); @@ -56,30 +67,30 @@ void addClusterHistograms(HistogramRegistry* fRegistry, bool do2DQA) } template -void fillClusterHistograms(HistogramRegistry* fRegistry, TCluster cluster, bool do2DQA, float weight = 1.f) +inline void fillClusterHistograms(HistogramRegistry* fRegistry, TCluster cluster, bool do2DQA, float weight = 1.f) { static constexpr std::string_view cluster_types[2] = {"before/", "after/"}; fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hE"), cluster.e(), weight); fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hPt"), cluster.pt(), weight); fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hEtaPhi"), cluster.eta(), cluster.phi(), weight); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hNTracks"), cluster.tracketa().size(), weight); - for (size_t itrack = 0; itrack < cluster.tracketa().size(); itrack++) { // Fill TrackEtaPhi histogram with delta phi and delta eta of all tracks saved in the vectors in skimmerGammaCalo.cxx - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackdEtadPhi"), cluster.tracketa()[itrack] - cluster.eta(), cluster.trackphi()[itrack] - cluster.phi(), weight); + fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hNTracks"), cluster.deltaEta().size(), weight); + for (size_t itrack = 0; itrack < cluster.deltaEta().size(); itrack++) { // Fill TrackEtaPhi histogram with delta phi and delta eta of all tracks saved in the vectors in skimmerGammaCalo.cxx + fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackdEtadPhi"), cluster.deltaEta()[itrack], cluster.deltaPhi()[itrack], weight); } if (do2DQA) { fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hNCell"), cluster.nCells(), cluster.e(), weight); fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hM02"), cluster.m02(), cluster.e(), weight); fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTime"), cluster.time(), cluster.e(), weight); - for (size_t itrack = 0; itrack < cluster.tracketa().size(); itrack++) { + for (size_t itrack = 0; itrack < cluster.deltaEta().size(); itrack++) { fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackEOverP"), cluster.e() / cluster.trackp()[itrack], cluster.e(), weight); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackdEta"), cluster.tracketa()[itrack] - cluster.eta(), cluster.e(), weight); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackdPhi"), cluster.trackphi()[itrack] - cluster.phi(), cluster.e(), weight); + fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackdEta"), cluster.deltaEta()[itrack], cluster.e(), weight); + fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackdPhi"), cluster.deltaPhi()[itrack], cluster.e(), weight); } } else { fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hNCell"), cluster.nCells(), weight); fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hM02"), cluster.m02(), weight); fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTime"), cluster.time(), weight); - for (size_t itrack = 0; itrack < cluster.tracketa().size(); itrack++) { + for (size_t itrack = 0; itrack < cluster.deltaEta().size(); itrack++) { fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackEOverP"), cluster.e() / cluster.trackp()[itrack], weight); } } diff --git a/PWGEM/PhotonMeson/Utils/EventHistograms.h b/PWGEM/PhotonMeson/Utils/EventHistograms.h index 9003bd8c3ff..ef5f115e216 100644 --- a/PWGEM/PhotonMeson/Utils/EventHistograms.h +++ b/PWGEM/PhotonMeson/Utils/EventHistograms.h @@ -14,6 +14,9 @@ #ifndef PWGEM_PHOTONMESON_UTILS_EVENTHISTOGRAMS_H_ #define PWGEM_PHOTONMESON_UTILS_EVENTHISTOGRAMS_H_ + +#include "Framework/HistogramRegistry.h" + using namespace o2::framework; namespace o2::aod::pwgem::photonmeson::utils::eventhistogram @@ -35,13 +38,34 @@ void addEventHistograms(HistogramRegistry* fRegistry) hCollisionCounter->GetXaxis()->SetBinLabel(11, "EMC L0 Triggered"); hCollisionCounter->GetXaxis()->SetBinLabel(12, "accepted"); + const AxisSpec axis_cent_ft0m{{0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}, + "centrality FT0M (%)"}; + + const AxisSpec axis_cent_ft0a{{0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}, + "centrality FT0A (%)"}; + + const AxisSpec axis_cent_ft0c{{0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}, + "centrality FT0C (%)"}; + fRegistry->add("Event/before/hZvtx", "vertex z; Z_{vtx} (cm)", kTH1F, {{100, -50, +50}}, false); fRegistry->add("Event/before/hMultNTracksPV", "hMultNTracksPV; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); fRegistry->add("Event/before/hMultNTracksPVeta1", "hMultNTracksPVeta1; N_{track} to PV", kTH1F, {{6001, -0.5, 6000.5}}, false); fRegistry->add("Event/before/hMultFT0", "hMultFT0;mult. FT0A;mult. FT0C", kTH2F, {{200, 0, 200000}, {60, 0, 60000}}, false); - fRegistry->add("Event/before/hCentFT0A", "hCentFT0A;centrality FT0A (%)", kTH1F, {{110, 0, 110}}, false); - fRegistry->add("Event/before/hCentFT0C", "hCentFT0C;centrality FT0C (%)", kTH1F, {{110, 0, 110}}, false); - fRegistry->add("Event/before/hCentFT0M", "hCentFT0M;centrality FT0M (%)", kTH1F, {{110, 0, 110}}, false); + fRegistry->add("Event/before/hCentFT0A", "hCentFT0A;centrality FT0A (%)", kTH1F, {{axis_cent_ft0a}}, false); + fRegistry->add("Event/before/hCentFT0C", "hCentFT0C;centrality FT0C (%)", kTH1F, {{axis_cent_ft0c}}, false); + fRegistry->add("Event/before/hCentFT0M", "hCentFT0M;centrality FT0M (%)", kTH1F, {{axis_cent_ft0m}}, false); fRegistry->add("Event/before/hCentFT0CvsMultNTracksPV", "hCentFT0CvsMultNTracksPV;centrality FT0C (%);N_{track} to PV", kTH2F, {{110, 0, 110}, {500, 0, 5000}}, false); fRegistry->add("Event/before/hMultFT0CvsMultNTracksPV", "hMultFT0CvsMultNTracksPV;mult. FT0C;N_{track} to PV", kTH2F, {{60, 0, 60000}, {500, 0, 5000}}, false); fRegistry->add("Event/before/hMultFT0CvsOccupancy", "hMultFT0CvsOccupancy;mult. FT0C;N_{track} in time range", kTH2F, {{60, 0, 60000}, {2000, 0, 20000}}, false); @@ -49,51 +73,51 @@ void addEventHistograms(HistogramRegistry* fRegistry) } template -void fillEventInfo(HistogramRegistry* fRegistry, TCollision const& collision) +void fillEventInfo(HistogramRegistry* fRegistry, TCollision const& collision, float weight = 1.) { static constexpr std::string_view event_types[2] = {"before/", "after/"}; - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 1.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 1.0, weight); if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 2.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 2.0, weight); } if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 3.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 3.0, weight); } if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 4.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 4.0, weight); } if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 5.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 5.0, weight); } if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 6.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 6.0, weight); } if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 7.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 7.0, weight); } if (collision.sel8()) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 8.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 8.0, weight); } - if (abs(collision.posZ()) < 10.0) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 9.0); + if (std::abs(collision.posZ()) < 10.0) { + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 9.0, weight); } - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hZvtx"), collision.posZ()); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hZvtx"), collision.posZ(), weight); if (collision.alias_bit(kTVXinEMC)) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 10.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 10.0, weight); } if (collision.alias_bit(kEMC7) || collision.alias_bit(kDMC7)) { - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 11.0); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 11.0, weight); } - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultNTracksPV"), collision.multNTracksPV()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultNTracksPVeta1"), collision.multNTracksPVeta1()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultFT0"), collision.multFT0A(), collision.multFT0C()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0A"), collision.centFT0A()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0C"), collision.centFT0C()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0M"), collision.centFT0M()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0CvsMultNTracksPV"), collision.centFT0C(), collision.multNTracksPV()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultFT0CvsMultNTracksPV"), collision.multFT0C(), collision.multNTracksPV()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultFT0CvsOccupancy"), collision.multFT0C(), collision.trackOccupancyInTimeRange()); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultNTracksPV"), collision.multNTracksPV(), weight); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultNTracksPVeta1"), collision.multNTracksPVeta1(), weight); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultFT0"), collision.multFT0A(), collision.multFT0C(), weight); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0A"), collision.centFT0A(), weight); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0C"), collision.centFT0C(), weight); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0M"), collision.centFT0M(), weight); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCentFT0CvsMultNTracksPV"), collision.centFT0C(), collision.multNTracksPV(), weight); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultFT0CvsMultNTracksPV"), collision.multFT0C(), collision.multNTracksPV(), weight); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultFT0CvsOccupancy"), collision.multFT0C(), collision.trackOccupancyInTimeRange(), weight); } } // namespace o2::aod::pwgem::photonmeson::utils::eventhistogram diff --git a/PWGEM/PhotonMeson/Utils/HNMUtilities.h b/PWGEM/PhotonMeson/Utils/HNMUtilities.h new file mode 100644 index 00000000000..80101807641 --- /dev/null +++ b/PWGEM/PhotonMeson/Utils/HNMUtilities.h @@ -0,0 +1,208 @@ +// 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. +/// +/// \file HNMUtilities.h +/// +/// \brief This code provides helper functions for the reconstruction of heavy neutral mesons (omega and eta meson) via their three pion decay +/// +/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) - Goethe University Frankfurt +/// + +#ifndef PWGEM_PHOTONMESON_UTILS_HNMUTILITIES_H_ +#define PWGEM_PHOTONMESON_UTILS_HNMUTILITIES_H_ + +#include +#include +#include +#include "TVector3.h" + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Common/DataModel/EventSelection.h" +#include "EMCALBase/Geometry.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/filterTables.h" + +namespace o2::aod::pwgem::photonmeson::hnmutilities +{ +// -------> Struct to store photons from EMC clusters or V0s +struct Photon { + Photon(float px, float py, float pz, bool isFromConversion) : px(px), py(py), pz(pz), pt(std::sqrt(px * px + py * py)), isFromConversion(isFromConversion) + { + photon.SetPxPyPzE(px, py, pz, std::sqrt(px * px + py * py + pz * pz)); + } + + static Photon fromPxPyPz(float px, float py, float pz) + { + Photon photon(px, py, pz, true); + return photon; + } + + static Photon fromEtaPhiEnergy(float eta, float phi, float energy) + { + float theta = 2 * std::atan2(std::exp(-eta), 1); + float px = energy * std::sin(theta) * std::cos(phi); + float py = energy * std::sin(theta) * std::sin(phi); + float pz = energy * std::cos(theta); + Photon photon(px, py, pz, false); + return photon; + } + + ROOT::Math::PxPyPzEVector photon; + float px, py, pz, pt; + bool isFromConversion; +}; + +// -------> Struct to store gamma gamma pairs (pi0 or eta meson candidates) +struct GammaGammaPair { + GammaGammaPair(Photon p1, Photon p2) : p1(p1), p2(p2) + { + vGG = p1.photon + p2.photon; + } + Photon p1, p2; + ROOT::Math::PxPyPzEVector vGG; + + bool isPi0 = false; + bool isEta = false; + ushort reconstructionType; + void setReconstructionType(ushort type) { reconstructionType = type; } + + float m() const { return vGG.M(); } + float pT() const { return vGG.Pt(); } +}; + +// -------> Enum to specify how the heavy neutral meson mass should be corrected based on the PDG mass of its light neutral meson decay daughter +enum MassCorrectionType { + kNoHNMMassCorrection = 0, + kSubDeltaPi0 = 1, + kSubLambda = 2 +}; + +struct HeavyNeutralMeson { + HeavyNeutralMeson(GammaGammaPair* gg, float eTracks, float pxTracks, float pyTracks, float pzTracks) : gg(gg) + { + vHeavyNeutralMeson.SetPxPyPzE(gg->vGG.Px() + pxTracks, gg->vGG.Py() + pyTracks, gg->vGG.Pz() + pzTracks, gg->vGG.e() + eTracks); + } + + GammaGammaPair* gg = nullptr; + ROOT::Math::PxPyPzEVector vHeavyNeutralMeson; + + float m(int massCorrectionType) const + { + float massHNM = vHeavyNeutralMeson.M(); + switch (massCorrectionType) { + case kNoHNMMassCorrection: // No mass correction + break; + case kSubDeltaPi0: // Subtract the mass difference of the reconstructed light neutral meson mass to the PDG mass + massHNM -= gg->m(); + massHNM += (gg->isPi0 ? constants::physics::MassPi0 : 0.547862); + break; + case kSubLambda: // Subtract an opening angle dependent mass correction (see https://arxiv.org/abs/2502.19956 for details) + LOGF(warning, "SubLambdaMassCorrection not yet implemented!"); + break; + default: + LOGF(fatal, "Unknown mass correction type %d", massCorrectionType); + } + return massHNM; + } + float pT() const { return vHeavyNeutralMeson.Pt(); } + float eta() const { return vHeavyNeutralMeson.Eta(); } + float phi() const { return vHeavyNeutralMeson.Phi(); } +}; + +const int nSMEdges = 9; +float smPhiEdges[nSMEdges] = {1.75, 2.1, 2.45, 2.8, 3.14, 4., 4.89, 5.24, 5.58}; + +int getSMNumber(float eta, float phi) +{ + int smNumber = 0; + for (int iPhiInterval = 0; iPhiInterval < nSMEdges; iPhiInterval++) { + if (phi > smPhiEdges[iPhiInterval]) + smNumber = 2 * (iPhiInterval + 1); + } + if (eta < 0) + smNumber += 1; + + return smNumber; +} + +/// \brief Store photons from EMC clusters and V0s in a vector and possibly add a eta and phi offset for alignment of EMCal clusters +template +void storeGammasInVector(C clusters, V v0s, std::vector& vPhotons, std::array EMCEtaShift, std::array EMCPhiShift) +{ + vPhotons.clear(); + for (const auto& cluster : clusters) { + float eta = cluster.eta(); + float phi = cluster.phi(); + int smNumber = getSMNumber(eta, phi); + // LOG(info) << "Shifting in sm " << smNumber << ", eta/phi = " << eta << " / " << phi << " to eta/phi = " << eta + EMCEtaShift[getSMNumber(eta, phi)] << " / " << phi + EMCPhiShift[getSMNumber(eta, phi)]; + eta += EMCEtaShift[smNumber]; + phi += EMCPhiShift[smNumber]; + vPhotons.push_back(Photon::fromEtaPhiEnergy(eta, phi, cluster.e())); + } + + for (const auto& v0 : v0s) + vPhotons.push_back(Photon::fromPxPyPz(v0.px(), v0.py(), v0.pz())); +} + +/// \brief Store photons from EMC clusters in a vector and possibly add a eta and phi offset for alignment of EMCal clusters +template +void storeGammasInVector(C clusters, std::vector& vPhotons, std::array EMCEtaShift, std::array EMCPhiShift) +{ + vPhotons.clear(); + for (const auto& cluster : clusters) { + float eta = cluster.eta(); + float phi = cluster.phi(); + int smNumber = getSMNumber(eta, phi); + // LOG(info) << "Shifting in sm " << smNumber << ", eta/phi = " << eta << " / " << phi << " to eta/phi = " << eta + EMCEtaShift[getSMNumber(eta, phi)] << " / " << phi + EMCPhiShift[getSMNumber(eta, phi)]; + eta += EMCEtaShift[smNumber]; + phi += EMCPhiShift[smNumber]; + vPhotons.push_back(Photon::fromEtaPhiEnergy(eta, phi, cluster.e())); + } +} + +/// \brief Reconstruct light neutral mesons from photons and fill them into the vGGs vector +void reconstructGGs(std::vector vPhotons, std::vector& vGGs) +{ + vGGs.clear(); + // loop over all photon combinations and build meson candidates + for (unsigned int ig1 = 0; ig1 < vPhotons.size(); ++ig1) { + for (unsigned int ig2 = ig1 + 1; ig2 < vPhotons.size(); ++ig2) { + GammaGammaPair lightMeson(vPhotons[ig1], vPhotons[ig2]); // build lightMeson from photons + if (vPhotons[ig1].isFromConversion && vPhotons[ig2].isFromConversion) + lightMeson.setReconstructionType(photonpair::kPCMPCM); + else if (!vPhotons[ig1].isFromConversion && !vPhotons[ig2].isFromConversion) + lightMeson.setReconstructionType(photonpair::kEMCEMC); + else + lightMeson.setReconstructionType(photonpair::kPCMEMC); + + vGGs.push_back(lightMeson); + } + } +} + +/// \brief Reconstruct heavy neutral mesons from the given pion, antipion and the GG candidates and add them to the vHNMs vector +void reconstructHeavyNeutralMesons(ROOT::Math::PtEtaPhiMVector const& vecPiPlPiMi, std::vector& vGGs, std::vector& vHNMs) +{ + for (size_t iGG = 0; iGG < vGGs.size(); iGG++) { + HeavyNeutralMeson heavyNeutralMeson(&vGGs.at(iGG), vecPiPlPiMi.E(), vecPiPlPiMi.Px(), vecPiPlPiMi.Py(), vecPiPlPiMi.Pz()); + vHNMs.push_back(heavyNeutralMeson); + } +} + +} // namespace o2::aod::pwgem::photonmeson::hnmutilities + +#endif // PWGEM_PHOTONMESON_UTILS_HNMUTILITIES_H_ diff --git a/PWGEM/PhotonMeson/Utils/MCUtilities.h b/PWGEM/PhotonMeson/Utils/MCUtilities.h index 0d9fe36920c..c72a8a0b06d 100644 --- a/PWGEM/PhotonMeson/Utils/MCUtilities.h +++ b/PWGEM/PhotonMeson/Utils/MCUtilities.h @@ -15,9 +15,11 @@ #ifndef PWGEM_PHOTONMESON_UTILS_MCUTILITIES_H_ #define PWGEM_PHOTONMESON_UTILS_MCUTILITIES_H_ -#include -#include #include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" + +#include +#include //_______________________________________________________________________ namespace o2::aod::pwgem::photonmeson::utils::mcutil @@ -224,7 +226,7 @@ bool IsInAcceptance(TMCParticle const& mcparticle, TMCParticles const& mcparticl template bool IsConversionPointInAcceptance(TMCPhoton const& mcphoton, const float max_r_gen, const float max_eta_gen, const float margin_z_mc, TMCParticles const& mcparticles) { - if (abs(mcphoton.pdgCode()) != 22) { + if (std::abs(mcphoton.pdgCode()) != 22) { return false; } @@ -238,7 +240,7 @@ bool IsConversionPointInAcceptance(TMCPhoton const& mcphoton, const float max_r_ return false; } auto daughter = mcparticles.iteratorAt(daughterId); - if (abs(daughter.pdgCode()) != 11) { + if (std::abs(daughter.pdgCode()) != 11) { return false; } @@ -246,7 +248,7 @@ bool IsConversionPointInAcceptance(TMCPhoton const& mcphoton, const float max_r_ return false; } - float rxy_gen_e = sqrt(pow(daughter.vx(), 2) + pow(daughter.vy(), 2)); + float rxy_gen_e = std::sqrt(std::pow(daughter.vx(), 2) + pow(daughter.vy(), 2)); // LOGF(info, "daughterId = %d , pdg = %d , vx = %f , vy = %f , vz = %f, rxy = %f", daughterId, daughter.pdgCode(), daughter.vx(), daughter.vy(), daughter.vz(), rxy_gen_e); if (rxy_gen_e > max_r_gen || rxy_gen_e < abs(daughter.vz()) * std::tan(2 * std::atan(std::exp(-max_eta_gen))) - margin_z_mc) { return false; @@ -256,6 +258,19 @@ bool IsConversionPointInAcceptance(TMCPhoton const& mcphoton, const float max_r_ return true; } //_______________________________________________________________________ +template +bool isGammaGammaDecay(TMCParticle mcParticle, TMCParticles mcParticles) +{ + auto daughtersIds = mcParticle.daughtersIds(); + if (daughtersIds.size() != 2) + return false; + for (auto& daughterId : daughtersIds) { + if (mcParticles.iteratorAt(daughterId).pdgCode() != 22) + return false; + } + return true; +} +//_______________________________________________________________________ } // namespace o2::aod::pwgem::photonmeson::utils::mcutil //_______________________________________________________________________ //_______________________________________________________________________ diff --git a/PWGEM/PhotonMeson/Utils/NMHistograms.h b/PWGEM/PhotonMeson/Utils/NMHistograms.h index 95abaf92292..8915c6624b5 100644 --- a/PWGEM/PhotonMeson/Utils/NMHistograms.h +++ b/PWGEM/PhotonMeson/Utils/NMHistograms.h @@ -15,10 +15,14 @@ #ifndef PWGEM_PHOTONMESON_UTILS_NMHISTOGRAMS_H_ #define PWGEM_PHOTONMESON_UTILS_NMHISTOGRAMS_H_ -#include -#include "TF1.h" -#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" #include "PWGEM/PhotonMeson/Utils/MCUtilities.h" +#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" + +#include "Framework/HistogramRegistry.h" + +#include "TF1.h" + +#include using namespace o2::framework; using namespace o2::aod::pwgem::photonmeson::utils::mcutil; @@ -48,7 +52,11 @@ void addNMHistograms(HistogramRegistry* fRegistry, bool isMC, const char* pairna fRegistry->add("Pair/Pi0/hs_Primary", "rec. true pi0", kTHnSparseD, {axis_mass, axis_pt}, true); fRegistry->add("Pair/Pi0/hs_FromWD", "rec. true pi0 from weak decay", kTHnSparseD, {axis_mass, axis_pt}, true); fRegistry->add("Pair/Pi0/hs_FromHS", "rec. true pi0 from hadronic shower in material", kTHnSparseD, {axis_mass, axis_pt}, true); + fRegistry->add("Pair/Pi0/hs_FromSameGamma", "Two clusters from same gamma that is a pi0 daughter (conversion)", kTHnSparseD, {axis_mass, axis_pt}, true); + fRegistry->add("Pair/Eta/hs_FromSameGamma", "Two clusters from same gamma that is a eta daughter (conversion)", kTHnSparseD, {axis_mass, axis_pt}, true); fRegistry->add("Pair/Eta/hs_Primary", "rec. true eta", kTHnSparseD, {axis_mass, axis_pt}, true); + fRegistry->add("Pair/Eta/hs_FromWD", "rec. true eta from weak decay", kTHnSparseD, {axis_mass, axis_pt}, true); + fRegistry->add("Pair/Eta/hs_FromHS", "rec. true eta from hadronic shower in material", kTHnSparseD, {axis_mass, axis_pt}, true); const AxisSpec axis_rapidity{{0.0, +0.8, +0.9}, "rapidity |y|"}; fRegistry->add("Generated/Pi0/hPt", "pT;p_{T} (GeV/c)", kTH1F, {axis_pt}, true); @@ -70,16 +78,16 @@ void addNMHistograms(HistogramRegistry* fRegistry, bool isMC, const char* pairna template void fillTruePairInfo(HistogramRegistry* fRegistry, TDiphoton const& v12, TMCParitlce const& mcparticle, TMCParticles const& mcparticles, TMCCollisions const&, const TF1* f1fd_k0s_to_pi0 = nullptr, float eventWeight = 1.f) { - int pdg = abs(mcparticle.pdgCode()); + int pdg = std::abs(mcparticle.pdgCode()); float weight = eventWeight; + int motherid_strhad = IsFromWD(mcparticle.template emmcevent_as(), mcparticle, mcparticles); switch (pdg) { case 111: { - int motherid_strhad = IsFromWD(mcparticle.template emmcevent_as(), mcparticle, mcparticles); if (mcparticle.isPhysicalPrimary() || mcparticle.producedByGenerator()) { fRegistry->fill(HIST("Pair/Pi0/hs_Primary"), v12.M(), v12.Pt(), weight); } else if (motherid_strhad > 0) { auto str_had = mcparticles.iteratorAt(motherid_strhad); - if (abs(str_had.pdgCode()) == 310 && f1fd_k0s_to_pi0 != nullptr) { + if (std::abs(str_had.pdgCode()) == 310 && f1fd_k0s_to_pi0 != nullptr) { weight *= f1fd_k0s_to_pi0->Eval(str_had.pt()); } fRegistry->fill(HIST("Pair/Pi0/hs_FromWD"), v12.M(), v12.Pt(), weight); @@ -91,6 +99,10 @@ void fillTruePairInfo(HistogramRegistry* fRegistry, TDiphoton const& v12, TMCPar case 221: { if (mcparticle.isPhysicalPrimary() || mcparticle.producedByGenerator()) { fRegistry->fill(HIST("Pair/Eta/hs_Primary"), v12.M(), v12.Pt(), weight); + } else if (motherid_strhad > 0) { + fRegistry->fill(HIST("Pair/Eta/hs_FromWD"), v12.M(), v12.Pt(), weight); + } else { + fRegistry->fill(HIST("Pair/Eta/hs_FromHS"), v12.M(), v12.Pt(), weight); } break; } diff --git a/PWGEM/PhotonMeson/Utils/PCMUtilities.h b/PWGEM/PhotonMeson/Utils/PCMUtilities.h index 63101c41418..e82d580cfcd 100644 --- a/PWGEM/PhotonMeson/Utils/PCMUtilities.h +++ b/PWGEM/PhotonMeson/Utils/PCMUtilities.h @@ -24,7 +24,7 @@ //_______________________________________________________________________ inline bool checkAP(const float alpha, const float qt, const float alpha_max = 0.95, const float qt_max = 0.05) { - float ellipse = pow(alpha / alpha_max, 2) + pow(qt / qt_max, 2); + float ellipse = std::pow(alpha / alpha_max, 2) + std::pow(qt / qt_max, 2); if (ellipse < 1.0) { return true; } else { @@ -105,79 +105,79 @@ inline void Vtx_recalculation(o2::base::Propagator* prop, T1 lTrackPos, T2 lTrac Vtx_recalculationParCov(prop, trackPosInformation, trackNegInformation, xyz, matCorr); } //_______________________________________________________________________ -template -float getPtResolution(TV0 const& v0) -{ - float px = v0.px(); - float py = v0.py(); - float pt = v0.pt(); - float px_err = std::sqrt(fabs(v0.sigmaPx2())); - float py_err = std::sqrt(fabs(v0.sigmaPy2())); - float pxy_err = v0.sigmaPxPy(); - return std::sqrt(std::pow(px / pt * px_err, 2) + std::pow(py / pt * py_err, 2) + 2.f * px / pt * py / pt * pxy_err); -} -//_______________________________________________________________________ -template -float getPhiResolution(TV0 const& v0) -{ - float px = v0.px(); - float py = v0.py(); - float pt = v0.pt(); - float px_err = std::sqrt(fabs(v0.sigmaPx2())); - float py_err = std::sqrt(fabs(v0.sigmaPy2())); - float pxy_err = v0.sigmaPxPy(); - return std::sqrt(std::pow(px / pt / pt * py_err, 2) + std::pow(py / pt / pt * px_err, 2) - 2.f * px / pt / pt * py / pt / pt * pxy_err); -} -//_______________________________________________________________________ -template -float getThetaResolution(TV0 const& v0) -{ - float px = v0.px(); - float py = v0.py(); - float pz = v0.pz(); - float pt = v0.pt(); - float p = v0.p(); - float px_err = std::sqrt(fabs(v0.sigmaPx2())); - float py_err = std::sqrt(fabs(v0.sigmaPy2())); - float pz_err = std::sqrt(fabs(v0.sigmaPz2())); - float pxy_err = v0.sigmaPxPy(); - float pyz_err = v0.sigmaPyPz(); - float pzx_err = v0.sigmaPzPx(); - return std::sqrt(std::pow(pz * pz / p / p, 2) * (std::pow(px / pz / pt * px_err, 2) + std::pow(py / pz / pt * py_err, 2) + std::pow(pt / pz / pz * pz_err, 2) + 2.f * (px * py / pz / pz / pt / pt * pxy_err - py / pz / pz / pz * pyz_err - px / pz / pz / pz * pzx_err))); -} -//_______________________________________________________________________ -template -float getEtaResolution(TV0 const& v0) -{ - float px = v0.px(); - float py = v0.py(); - float pz = v0.pz(); - float pt = v0.pt(); - float p = v0.p(); - float px_err = std::sqrt(fabs(v0.sigmaPx2())); - float py_err = std::sqrt(fabs(v0.sigmaPy2())); - float pz_err = std::sqrt(fabs(v0.sigmaPz2())); - float pxy_err = v0.sigmaPxPy(); - float pyz_err = v0.sigmaPyPz(); - float pzx_err = v0.sigmaPzPx(); - return std::sqrt(std::pow(1.f / p / pt / pt, 2) * (std::pow(pz * px * px_err, 2) + std::pow(pz * py * py_err, 2) + std::pow(pt * pt * pz_err, 2) + 2.f * (pz * pz * px * py * pxy_err - pt * pt * py * pz * pyz_err - pt * pt * pz * px * pzx_err))); -} -//_______________________________________________________________________ -template -float getPResolution(TV0 const& v0) -{ - float px = v0.px(); - float py = v0.py(); - float pz = v0.pz(); - float p = v0.p(); - float px_err = std::sqrt(fabs(v0.sigmaPx2())); - float py_err = std::sqrt(fabs(v0.sigmaPy2())); - float pz_err = std::sqrt(fabs(v0.sigmaPz2())); - float pxy_err = v0.sigmaPxPy(); - float pyz_err = v0.sigmaPyPz(); - float pzx_err = v0.sigmaPzPx(); - return std::sqrt(std::pow(1.f / p, 2) * (std::pow(px * px_err, 2) + std::pow(py * py_err, 2) + std::pow(pz * pz_err, 2) + 2.f * (px * py * pxy_err + py * pz * pyz_err + pz * px * pzx_err))); -} +// template +// float getPtResolution(TV0 const& v0) +// { +// float px = v0.px(); +// float py = v0.py(); +// float pt = v0.pt(); +// float px_err = std::sqrt(std::fabs(v0.sigmaPx2())); +// float py_err = std::sqrt(std::fabs(v0.sigmaPy2())); +// float pxy_err = v0.sigmaPxPy(); +// return std::sqrt(std::pow(px / pt * px_err, 2) + std::pow(py / pt * py_err, 2) + 2.f * px / pt * py / pt * pxy_err); +// } +// //_______________________________________________________________________ +// template +// float getPhiResolution(TV0 const& v0) +// { +// float px = v0.px(); +// float py = v0.py(); +// float pt = v0.pt(); +// float px_err = std::sqrt(std::fabs(v0.sigmaPx2())); +// float py_err = std::sqrt(std::fabs(v0.sigmaPy2())); +// float pxy_err = v0.sigmaPxPy(); +// return std::sqrt(std::pow(px / pt / pt * py_err, 2) + std::pow(py / pt / pt * px_err, 2) - 2.f * px / pt / pt * py / pt / pt * pxy_err); +// } +// //_______________________________________________________________________ +// template +// float getThetaResolution(TV0 const& v0) +// { +// float px = v0.px(); +// float py = v0.py(); +// float pz = v0.pz(); +// float pt = v0.pt(); +// float p = v0.p(); +// float px_err = std::sqrt(std::fabs(v0.sigmaPx2())); +// float py_err = std::sqrt(std::fabs(v0.sigmaPy2())); +// float pz_err = std::sqrt(std::fabs(v0.sigmaPz2())); +// float pxy_err = v0.sigmaPxPy(); +// float pyz_err = v0.sigmaPyPz(); +// float pzx_err = v0.sigmaPzPx(); +// return std::sqrt(std::pow(pz * pz / p / p, 2) * (std::pow(px / pz / pt * px_err, 2) + std::pow(py / pz / pt * py_err, 2) + std::pow(pt / pz / pz * pz_err, 2) + 2.f * (px * py / pz / pz / pt / pt * pxy_err - py / pz / pz / pz * pyz_err - px / pz / pz / pz * pzx_err))); +// } +// //_______________________________________________________________________ +// template +// float getEtaResolution(TV0 const& v0) +// { +// float px = v0.px(); +// float py = v0.py(); +// float pz = v0.pz(); +// float pt = v0.pt(); +// float p = v0.p(); +// float px_err = std::sqrt(std::fabs(v0.sigmaPx2())); +// float py_err = std::sqrt(std::fabs(v0.sigmaPy2())); +// float pz_err = std::sqrt(std::fabs(v0.sigmaPz2())); +// float pxy_err = v0.sigmaPxPy(); +// float pyz_err = v0.sigmaPyPz(); +// float pzx_err = v0.sigmaPzPx(); +// return std::sqrt(std::pow(1.f / p / pt / pt, 2) * (std::pow(pz * px * px_err, 2) + std::pow(pz * py * py_err, 2) + std::pow(pt * pt * pz_err, 2) + 2.f * (pz * pz * px * py * pxy_err - pt * pt * py * pz * pyz_err - pt * pt * pz * px * pzx_err))); +// } +// //_______________________________________________________________________ +// template +// float getPResolution(TV0 const& v0) +// { +// float px = v0.px(); +// float py = v0.py(); +// float pz = v0.pz(); +// float p = v0.p(); +// float px_err = std::sqrt(std::fabs(v0.sigmaPx2())); +// float py_err = std::sqrt(std::fabs(v0.sigmaPy2())); +// float pz_err = std::sqrt(std::fabs(v0.sigmaPz2())); +// float pxy_err = v0.sigmaPxPy(); +// float pyz_err = v0.sigmaPyPz(); +// float pzx_err = v0.sigmaPzPx(); +// return std::sqrt(std::pow(1.f / p, 2) * (std::pow(px * px_err, 2) + std::pow(py * py_err, 2) + std::pow(pz * pz_err, 2) + 2.f * (px * py * pxy_err + py * pz * pyz_err + pz * px * pzx_err))); +// } //_______________________________________________________________________ //_______________________________________________________________________ #endif // PWGEM_PHOTONMESON_UTILS_PCMUTILITIES_H_ diff --git a/PWGEM/PhotonMeson/Utils/PairUtilities.h b/PWGEM/PhotonMeson/Utils/PairUtilities.h index 2277caea505..86ac4f0eb16 100644 --- a/PWGEM/PhotonMeson/Utils/PairUtilities.h +++ b/PWGEM/PhotonMeson/Utils/PairUtilities.h @@ -18,6 +18,17 @@ #include #include +namespace o2::aod::pwgem::photonmeson::utils::pairutil +{ +enum class PhotonPrefilterBitDerived : int { + kPhotonFromPi0gg = 0, // photon from pi0->gg + kPhotonFromPi0eeg = 1, // photon from pi0->eeg +}; +enum class ElectronPrefilterBitDerived : int { + kElectronFromPi0eeg = 0, // electron from pi0->eeg + kElectronFromFakePC = 1, // electron from photon->ee, misidentified photon conversion as virtual photon +}; +} // namespace o2::aod::pwgem::photonmeson::utils::pairutil namespace o2::aod::pwgem::photonmeson::photonpair { enum PairType { diff --git a/PWGEM/PhotonMeson/Utils/TrackSelection.h b/PWGEM/PhotonMeson/Utils/TrackSelection.h index d7c4df97d2c..bdc2f5be533 100644 --- a/PWGEM/PhotonMeson/Utils/TrackSelection.h +++ b/PWGEM/PhotonMeson/Utils/TrackSelection.h @@ -43,7 +43,7 @@ inline bool isITSTPCTrack(TTrack const& track) template inline bool isTPCTRDTrack(TTrack const& track) { - return !track.hasITS() && track.hasTPC() && track.hasTRD(); + return !track.hasITS() && track.hasTPC() && track.hasTRD() && !track.hasTOF(); } /** @@ -56,7 +56,7 @@ inline bool isTPCTRDTrack(TTrack const& track) template inline bool isITSTPCTRDTrack(TTrack const& track) { - return track.hasITS() && track.hasTPC() && track.hasTRD(); + return track.hasITS() && track.hasTPC() && track.hasTRD() && !track.hasTOF(); } /** @@ -215,7 +215,7 @@ inline bool isTPConly_ITSonly(TTrack const& track0, TTrack const& track1) template inline bool checkMCParticles(T const& mc1, T const& mc2) { - if (abs(mc1.pdgCode()) != kElectron || abs(mc2.pdgCode()) != kElectron) { + if (std::abs(mc1.pdgCode()) != kElectron || std::abs(mc2.pdgCode()) != kElectron) { return false; } if (!mc1.has_mothers() || !mc2.has_mothers()) { diff --git a/PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h b/PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h index 6ce678e9c35..f3eac77ca04 100644 --- a/PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h +++ b/PWGEM/PhotonMeson/Utils/emcalHistoDefinitions.h @@ -12,9 +12,9 @@ /// \brief commonly used histogram (axis) definitions for emcal in PWGEM /// \author marvin.hemmer@cern.ch -#include +#include -#include "Framework/AnalysisTask.h" +#include #ifndef PWGEM_PHOTONMESON_UTILS_EMCALHISTODEFINITIONS_H_ #define PWGEM_PHOTONMESON_UTILS_EMCALHISTODEFINITIONS_H_ diff --git a/PWGEM/PhotonMeson/Utils/gammaSelectionCuts.h b/PWGEM/PhotonMeson/Utils/gammaSelectionCuts.h deleted file mode 100644 index 341a6c95e38..00000000000 --- a/PWGEM/PhotonMeson/Utils/gammaSelectionCuts.h +++ /dev/null @@ -1,165 +0,0 @@ -// 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. - -/// \brief cut selection and cut functions for photon candidates -/// \author marvin.hemmer@cern.ch - -#include - -#include "Framework/AnalysisTask.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" - -#ifndef PWGEM_PHOTONMESON_UTILS_GAMMASELECTIONCUTS_H_ -#define PWGEM_PHOTONMESON_UTILS_GAMMASELECTIONCUTS_H_ - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -namespace emccuts -{ -// set the standard cuts -std::vector EMC_minTime = {-20.f}; -std::vector EMC_maxTime = {+25.f}; -std::vector EMC_minM02 = {0.1f}; -std::vector EMC_maxM02 = {0.7f}; -std::vector EMC_minE = {0.7f}; -std::vector EMC_minNCell = {1}; -std::vector> EMC_TM_Eta = {{0.01f, 4.07f, -2.5f}}; -std::vector> EMC_TM_Phi = {{0.015f, 3.65f, -2.f}}; -std::vector EMC_Eoverp = {1.75f}; -} // namespace emccuts -void gatherCutsEMC(float minTime, float maxTime, float minM02, float maxM02, float minE, int minNCell, std::vector TM_Eta, std::vector TM_Phi, float Eoverp) -{ - // insert the configurable values in first position - emccuts::EMC_minTime.insert(emccuts::EMC_minTime.begin(), minTime); - emccuts::EMC_maxTime.insert(emccuts::EMC_maxTime.begin(), maxTime); - emccuts::EMC_minM02.insert(emccuts::EMC_minM02.begin(), minM02); - emccuts::EMC_maxM02.insert(emccuts::EMC_maxM02.begin(), maxM02); - emccuts::EMC_minE.insert(emccuts::EMC_minE.begin(), minE); - emccuts::EMC_minNCell.insert(emccuts::EMC_minNCell.begin(), minNCell); - emccuts::EMC_TM_Eta.insert(emccuts::EMC_TM_Eta.begin(), TM_Eta); - emccuts::EMC_TM_Phi.insert(emccuts::EMC_TM_Phi.begin(), TM_Phi); - emccuts::EMC_Eoverp.insert(emccuts::EMC_Eoverp.begin(), Eoverp); - - // fill up the rest of the vectors to size 64 to ensure no crashes can happen - emccuts::EMC_minTime.resize(64, 0); - emccuts::EMC_maxTime.resize(64, 0); - emccuts::EMC_minM02.resize(64, 0); - emccuts::EMC_maxM02.resize(64, 0); - emccuts::EMC_minE.resize(64, 0); - emccuts::EMC_minNCell.resize(64, 0); - emccuts::EMC_TM_Eta.resize(64, {0, 0, 0}); - emccuts::EMC_TM_Phi.resize(64, {0, 0, 0}); - emccuts::EMC_Eoverp.resize(64, 0); -} - -uint64_t doTimeCutEMC(int iCut, uint64_t cutbit, aod::SkimEMCCluster const& cluster, HistogramRegistry& registry) -{ - uint64_t cut_return = 0; - if (cutbit & ((uint64_t)1 << (uint64_t)iCut)) { // check if current cut should be applied - if (cluster.time() <= emccuts::EMC_maxTime.at(iCut) && cluster.time() >= emccuts::EMC_minTime.at(iCut)) { // check cut itself - cut_return |= (1 << iCut); // set bit of current cut to 1 for passing the cut - } else { - registry.fill(HIST("hCaloCuts_EMC"), 1, iCut); - } - } - return cut_return; -} - -uint64_t doM02CutEMC(int iCut, uint64_t cutbit, aod::SkimEMCCluster const& cluster, HistogramRegistry& registry) -{ - uint64_t cut_return = 0; - if (cutbit & ((uint64_t)1 << (uint64_t)iCut)) { // check if current cut should be applied - if (cluster.m02() <= emccuts::EMC_maxM02.at(iCut) && cluster.m02() >= emccuts::EMC_minM02.at(iCut)) { // check cut itself - cut_return |= (1 << iCut); // set bit of current cut to 1 for passing the cut - } else { - registry.fill(HIST("hCaloCuts_EMC"), 2, iCut); - } - } - return cut_return; -} - -uint64_t doMinECutEMC(int iCut, uint64_t cutbit, aod::SkimEMCCluster const& cluster, HistogramRegistry& registry) -{ - uint64_t cut_return = 0; - if (cutbit & ((uint64_t)1 << (uint64_t)iCut)) { // check if current cut should be applied - if (cluster.e() > emccuts::EMC_minE.at(iCut)) { // check cut itself - cut_return |= (1 << iCut); // set bit of current cut to 1 for passing the cut - } else { - registry.fill(HIST("hCaloCuts_EMC"), 3, iCut); - } - } - return cut_return; -} - -uint64_t doNCellCutEMC(int iCut, uint64_t cutbit, aod::SkimEMCCluster const& cluster, HistogramRegistry& registry) -{ - uint64_t cut_return = 0; - if (cutbit & ((uint64_t)1 << (uint64_t)iCut)) { // check if current cut should be applied - if (cluster.nCells() >= emccuts::EMC_minNCell.at(iCut)) { // check cut itself - cut_return |= (1 << iCut); // set bit of current cut to 1 for passing the cut - } else { - registry.fill(HIST("hCaloCuts_EMC"), 4, iCut); - } - } - return cut_return; -} - -uint64_t doTrackMatchingEMC(int iCut, uint64_t cutbit, aod::SkimEMCCluster const& cluster, aod::SkimEMCMTs const& tracks, HistogramRegistry& registry) -{ - uint64_t cut_return = 0; - double dEta, dPhi; - if (cutbit & ((uint64_t)1 << (uint64_t)iCut)) { // check if current cut should be applied - bool hasMatchedTrack_EMC = false; - for (const auto& track : tracks) { - dEta = track.tracketa() - cluster.eta(); - dPhi = track.trackphi() - cluster.phi(); - if ((fabs(dEta) <= emccuts::EMC_TM_Eta.at(iCut).at(0) + pow(track.trackpt() + emccuts::EMC_TM_Eta.at(iCut).at(1), emccuts::EMC_TM_Eta.at(iCut).at(2))) && - (fabs(dPhi) <= emccuts::EMC_TM_Phi.at(iCut).at(0) + pow(track.trackpt() + emccuts::EMC_TM_Phi.at(iCut).at(1), emccuts::EMC_TM_Phi.at(iCut).at(2))) && - cluster.e() / track.trackp() < emccuts::EMC_Eoverp.at(iCut)) { // check cut itself - hasMatchedTrack_EMC = true; // set bit of current cut to 1 for passing the cut - } - } - if (hasMatchedTrack_EMC) { - registry.fill(HIST("hCaloCuts_EMC"), 5, iCut); - } else { - cut_return |= (1 << iCut); - } - } - return cut_return; -} - -uint64_t doPhotonCutsEMC(uint64_t cutbit, aod::SkimEMCCluster const& cluster, aod::SkimEMCMTs const& tracks, Preslice perEMCClusterMT, HistogramRegistry& registry) -{ - uint64_t cut_return = 0; - auto tracksMatchedEMC = tracks.sliceBy(perEMCClusterMT, cluster.globalIndex()); - for (int iCut = 0; iCut < 64; iCut++) { // loop over max number of cut settings - if (cutbit & ((uint64_t)1 << (uint64_t)iCut)) { // check each cut setting if it is selected - registry.fill(HIST("hClusterEIn"), cluster.e(), iCut); - cut_return = doTimeCutEMC(iCut, cutbit, cluster, registry); - // use cut_return instead of cutbit from here on to only check cut settings that we want to look at - // where the cluster did not fail in the previous cut(s) - cut_return = doM02CutEMC(iCut, cut_return, cluster, registry); - cut_return = doMinECutEMC(iCut, cut_return, cluster, registry); - cut_return = doNCellCutEMC(iCut, cut_return, cluster, registry); - cut_return = doTrackMatchingEMC(iCut, cut_return, cluster, tracksMatchedEMC, registry); - - registry.fill(HIST("hCaloCuts_EMC"), 0, iCut); - if (cut_return & ((uint64_t)1 << (uint64_t)iCut)) { - registry.fill(HIST("hClusterEOut"), cluster.e(), iCut); - registry.fill(HIST("hCaloCuts_EMC"), 6, iCut); - } - } - } - return cut_return; -} - -#endif // PWGEM_PHOTONMESON_UTILS_GAMMASELECTIONCUTS_H_ diff --git a/PWGEM/Tasks/CMakeLists.txt b/PWGEM/Tasks/CMakeLists.txt index 4f0a92bd6f2..ef263b02e2e 100644 --- a/PWGEM/Tasks/CMakeLists.txt +++ b/PWGEM/Tasks/CMakeLists.txt @@ -9,47 +9,47 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2physics_add_dpl_workflow(phoscellqa +o2physics_add_dpl_workflow(phos-cell-q-a SOURCES phosCellQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(phoscluqa +o2physics_add_dpl_workflow(phos-clu-q-a SOURCES phosCluQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(phostrigqa +o2physics_add_dpl_workflow(phos-trig-q-a SOURCES phosTrigQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(phospi0 +o2physics_add_dpl_workflow(phos-pi0 SOURCES phosPi0.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(phoscalib +o2physics_add_dpl_workflow(phos-calibration SOURCES phosCalibration.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase O2::PHOSReconstruction COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(phosalign +o2physics_add_dpl_workflow(phos-align SOURCES phosAlign.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase O2::PHOSReconstruction COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(phosnbar +o2physics_add_dpl_workflow(phos-nbar SOURCES phosNbar.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(phosnonlin +o2physics_add_dpl_workflow(phos-nonlin SOURCES phosNonlin.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase O2::PHOSReconstruction + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase O2::PHOSReconstruction O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(phoselid +o2physics_add_dpl_workflow(phos-el-id SOURCES phosElId.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::PHOSBase COMPONENT_NAME Analysis) diff --git a/PWGEM/Tasks/phosElId.cxx b/PWGEM/Tasks/phosElId.cxx index 304a31d5de1..23e09da288f 100644 --- a/PWGEM/Tasks/phosElId.cxx +++ b/PWGEM/Tasks/phosElId.cxx @@ -26,6 +26,8 @@ #include "Common/Core/TrackSelectionDefaults.h" #include "Common/DataModel/CaloClusters.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -44,7 +46,6 @@ #include "DataFormatsParameters/GRPLHCIFData.h" #include "DetectorsBase/Propagator.h" #include "TF1.h" -#include "TLorentzVector.h" using namespace o2; using namespace o2::soa; @@ -72,48 +73,90 @@ DECLARE_SOA_TABLE(PHOSMatchindexTable, "AOD", "PHSMTCH", } // namespace o2::aod +// globalized estimator names for centrality +enum CentEstimators { FV0A, + FT0M, + FT0A, + FT0C, + FDDM, + NTPV }; + +bool testLambda(float pt, float l1, float l2, float cutThreshold, bool useNegativeCrossTerm) +{ + float l2Mean = 1.53126f + 9.50835e+06f / (1.f + 1.08728e+07f * pt + 1.73420e+06f * pt * pt); + float l1Mean = 1.12365f + 0.123770f * std::exp(-pt * 0.246551f) + 5.30000e-03f * pt; + float l2Sigma = 6.48260e-02f + 7.60261e+10f / (1.f + 1.53012e+11f * pt + 5.01265e+05f * pt * pt) + 9.00000e-03f * pt; + float l1Sigma = 4.44719e-04f + 6.99839e-01f / (1.f + 1.22497e+00f * pt + 6.78604e-07f * pt * pt) + 9.00000e-03f * pt; + float c = -0.35f - 0.550f * std::exp(-0.390730f * pt); + if (l1Sigma == 0.f || l2Sigma == 0.f) + return false; + + float term1 = 0.5f * (l1 - l1Mean) * (l1 - l1Mean) / (l1Sigma * l1Sigma); + float term2 = 0.5f * (l2 - l2Mean) * (l2 - l2Mean) / (l2Sigma * l2Sigma); + float crossTerm = 0.5f * c * (l1 - l1Mean) * (l2 - l2Mean) / (l1Sigma * l2Sigma); + + float rSquared; + if (useNegativeCrossTerm) { + rSquared = term1 + term2 - crossTerm; + } else { + rSquared = term1 + term2 + crossTerm; + } + + return rSquared < cutThreshold; +} + struct PhosElId { - Produces hosMatch; + Produces phosMatch; using SelCollisions = soa::Join; - using MyTracks = soa::Join; - - Configurable mMinCluE{"mMinCluE", 0.3, "Minimum cluster energy for analysis"}, + using MyTracks = soa::Join; + Configurable isSel8{"isSel8", 1, "check if event is Single Event Latch-up 8"}, + mSwapM20M02ForTestLambda{"mSwapM20M02ForTestLambda", false, "Swap m20 and m02 arguments for testLambda (false for note's correct order, true for swapped/original incorrect order)"}, + mUseNegativeCrossTerm{"mUseNegativeCrossTerm", true, "Use negative sign for the cross-term in testLambda (true for analysis note version, false for old version)"}; + + Configurable mColMaxZ{"mColMaxZ", 10.f, "maximum z accepted in analysis"}, + mMinCluE{"mMinCluE", 0.3, "Minimum cluster energy for analysis"}, mMinCluTime{"minCluTime", -25.e-9, "Min. cluster time"}, mMaxCluTime{"mMaxCluTime", 25.e-9, "Max. cluster time"}, + mCluTimeAxisMin{"mCluTimeAxisMin", -100, "lower axis limit for cluster time in nanoseconds"}, + mCluTimeAxisMax{"mCluTimeAxisMax", 100, "upper axis limit for cluster time in nanoseconds"}, mDeltaXmin{"mDeltaXmin", -100., "Min for track and cluster coordinate delta"}, mDeltaXmax{"mDeltaXmax", 100., "Max for track and cluster coordinate delta"}, mDeltaZmin{"mDeltaZmin", -100., "Min for track and cluster coordinate delta"}, mDeltaZmax{"mDeltaZmax", 100., "Max for track and cluster coordinate delta"}, mEpmin{"mEpmin", -1., "Min for E/p histograms"}, mEpmax{"mEpmax", 3., "Max for E/p histograms"}, - cfgEtaMax{"cfgEtaMax", {0.8f}, "eta ranges"}, - cfgPtMin{"cfgPtMin", {0.2f}, "pt min"}, - cfgPtMax{"cfgPtMax", {20.f}, "pt max"}, - cfgDCAxyMax{"cfgDCAxyMax", {3.f}, "dcaxy max"}, - cfgDCAzMax{"cfgDCAzMax", {3.f}, "dcaz max"}, - cfgITSchi2Max{"cfgITSchi2Max", {5.f}, "its chi2 max"}, - cfgITSnclsMin{"cfgITSnclsMin", {4.5f}, "min number of ITS clusters"}, - cfgITSnclsMax{"cfgITSnclsMax", {7.5f}, "max number of ITS clusters"}, - cfgTPCchi2Max{"cfgTPCchi2Max", {4.f}, "tpc chi2 max"}, - cfgTPCnclsMin{"cfgTPCnclsMin", {90.f}, "min number of TPC clusters"}, - cfgTPCnclsMax{"cfgTPCnclsMax", {170.f}, "max number of TPC clusters"}, - cfgTPCnclsCRMin{"cfgTPCnclsCRMin", {80.f}, "min number of TPC crossed rows"}, - cfgTPCnclsCRMax{"cfgTPCnclsCRMax", {161.f}, "max number of TPC crossed rows"}, - cfgTPCNSigmaElMin{"cfgTPCNSigmaElMin", {-3.f}, "min TPC nsigma e for inclusion"}, - cfgTPCNSigmaElMax{"cfgTPCNSigmaElMax", {2.f}, "max TPC nsigma e for inclusion"}, - cfgTPCNSigmaPiMin{"cfgTPCNSigmaPiMin", {-3.f}, "min TPC nsigma pion for exclusion"}, - cfgTPCNSigmaPiMax{"cfgTPCNSigmaPiMax", {3.5f}, "max TPC nsigma pion for exclusion"}, - cfgTPCNSigmaPrMin{"cfgTPCNSigmaPrMin", {-3.f}, "min TPC nsigma proton for exclusion"}, - cfgTPCNSigmaPrMax{"cfgTPCNSigmaPrMax", {4.f}, "max TPC nsigma proton for exclusion"}, - cfgTPCNSigmaKaMin{"cfgTPCNSigmaKaMin", {-3.f}, "min TPC nsigma kaon for exclusion"}, - cfgTPCNSigmaKaMax{"cfgTPCNSigmaKaMax", {4.f}, "max TPC nsigma kaon for exclusion"}, - cfgTOFNSigmaElMin{"cfgTOFNSigmaElMin", {-3.f}, "min TOF nsigma e for inclusion"}, - cfgTOFNSigmaElMax{"cfgTOFNSigmaElMax", {3.f}, "max TOF nsigma e for inclusion"}, - cfgNsigmaTrackMatch{"cfgNsigmaTrackMatch", {2.f}, "PHOS Track Matching Nsigma for inclusion"}; + EtaMax{"EtaMax", {0.8f}, "eta ranges"}, + PtMin{"PtMin", {0.2f}, "pt min"}, + PtMax{"PtMax", {20.f}, "pt max"}, + DCAxyMax{"DCAxyMax", {3.f}, "dcaxy max"}, + DCAzMax{"DCAzMax", {3.f}, "dcaz max"}, + ITSchi2Max{"ITSchi2Max", {5.f}, "its chi2 max"}, + ITSnclsMin{"ITSnclsMin", {4.5f}, "min number of ITS clusters"}, + ITSnclsMax{"ITSnclsMax", {7.5f}, "max number of ITS clusters"}, + TPCchi2Max{"TPCchi2Max", {4.f}, "tpc chi2 max"}, + TPCnclsMin{"TPCnclsMin", {90.f}, "min number of TPC clusters"}, + TPCnclsMax{"TPCnclsMax", {170.f}, "max number of TPC clusters"}, + TPCnclsCRMin{"TPCnclsCRMin", {80.f}, "min number of TPC crossed rows"}, + TPCnclsCRMax{"TPCnclsCRMax", {161.f}, "max number of TPC crossed rows"}, + TPCNSigmaElMin{"TPCNSigmaElMin", {-3.f}, "min TPC nsigma e for inclusion"}, + TPCNSigmaElMax{"TPCNSigmaElMax", {2.f}, "max TPC nsigma e for inclusion"}, + TPCNSigmaPiMin{"TPCNSigmaPiMin", {-3.f}, "min TPC nsigma pion for exclusion"}, + TPCNSigmaPiMax{"TPCNSigmaPiMax", {3.5f}, "max TPC nsigma pion for exclusion"}, + TPCNSigmaPrMin{"TPCNSigmaPrMin", {-3.f}, "min TPC nsigma proton for exclusion"}, + TPCNSigmaPrMax{"TPCNSigmaPrMax", {4.f}, "max TPC nsigma proton for exclusion"}, + TPCNSigmaKaMin{"TPCNSigmaKaMin", {-3.f}, "min TPC nsigma kaon for exclusion"}, + TPCNSigmaKaMax{"TPCNSigmaKaMax", {4.f}, "max TPC nsigma kaon for exclusion"}, + TOFNSigmaElMin{"TOFNSigmaElMin", {-3.f}, "min TOF nsigma e for inclusion"}, + TOFNSigmaElMax{"TOFNSigmaElMax", {3.f}, "max TOF nsigma e for inclusion"}, + NsigmaTrackMatch{"NsigmaTrackMatch", {2.f}, "PHOS Track Matching Nsigma for inclusion"}, + mShowerShapeCutValue{"mShowerShapeCutValue", 4.f, "Cut threshold for testLambda shower shape"}; Configurable mEvSelTrig{"mEvSelTrig", kTVXinPHOS, "Select events with this trigger"}, + mAmountOfModules{"mAmountOfModules", 4, "amount of modules for PHOS"}, mMinCluNcell{"minCluNcell", 3, "min cells in cluster"}, nBinsDeltaX{"nBinsDeltaX", 500, "N bins for track and cluster coordinate delta"}, nBinsDeltaZ{"nBinsDeltaZ", 500, "N bins for track and cluster coordinate delta"}, @@ -123,22 +166,16 @@ struct PhosElId { pSigmadX{"pSigmadX", {2.17769, 1.60275, 2.24136}, "parameters for sigma dx function"}, pPhosShiftZ{"pPhosShiftZ", {4.78838, 2.75138, 1.40825, 2.28735}, "Phos coordinate centering Z per module"}, pPhosShiftX{"pPhosShiftX", {2.158702, -1.526772, -0.814658, -1.852678}, "Phos coordinate centering X per module"}, - pMeandXPosMod1{"pMeandXPosMod1", {-10.57, -0.42, 1.06}, "parameters for mean dx function on module 1 for positive tracks"}, - pMeandXPosMod2{"pMeandXPosMod2", {-8.1, -0.42, 1.14}, "parameters for mean dx function on module 2 for positive tracks"}, - pMeandXPosMod3{"pMeandXPosMod3", {-8.34, -0.42, 1.04}, "parameters for mean dx function on module 3 for positive tracks"}, - pMeandXPosMod4{"pMeandXPosMod4", {-7.38, -0.42, 1.17}, "parameters for mean dx function on module 4 for positive tracks"}, - pMeandXNegMod1{"pMeandXNegMod1", {9.92, -0.42, 1.29}, "parameters for mean dx function on module 1 for negative tracks"}, - pMeandXNegMod2{"pMeandXNegMod2", {7.82, -0.4, 1.34}, "parameters for mean dx function on module 2 for negative tracks"}, - pMeandXNegMod3{"pMeandXNegMod3", {8.45, -0.33, 1.5}, "parameters for mean dx function on module 3 for negative tracks"}, - pMeandXNegMod4{"pMeandXNegMod4", {7.5, -0.42, 1.25}, "parameters for mean dx function on module 4 for negative tracks"}; - - Filter ptFilter = (aod::track::pt > cfgPtMin) && (aod::track::pt < cfgPtMax); - Filter etafilter = nabs(aod::track::eta) < cfgEtaMax; - Filter dcaxyfilter = nabs(aod::track::dcaXY) < cfgDCAxyMax; - Filter dcazfilter = nabs(aod::track::dcaZ) < cfgDCAzMax; - Filter itschi2filter = aod::track::itsChi2NCl < cfgITSchi2Max; - Filter tpcchi2filter = aod::track::tpcChi2NCl < cfgTPCchi2Max; - Filter mapfilter = (aod::track::itsClusterMap & uint8_t(1)) > 0; + pMeandXPosMod{"pMeandXPosMod", {-10.57, -0.42, 1.06, -8.1, -0.42, 1.14, -8.34, -0.42, 1.04, -7.38, -0.42, 1.17}, "parameters for mean dx function for positive tracks"}, + pMeandXNegMod{"pMeandXNegMod", {9.92, -0.42, 1.29, 7.82, -0.4, 1.34, 8.45, -0.33, 1.5, 7.5, -0.42, 1.25}, "parameters for mean dx function for negative tracks"}; + + Filter ptFilter = (aod::track::pt > PtMin) && (aod::track::pt < PtMax), + etafilter = nabs(aod::track::eta) < EtaMax, + dcaxyfilter = nabs(aod::track::dcaXY) < DCAxyMax, + dcazfilter = nabs(aod::track::dcaZ) < DCAzMax, + itschi2filter = aod::track::itsChi2NCl < ITSchi2Max, + tpcchi2filter = aod::track::tpcChi2NCl < TPCchi2Max, + mapfilter = (aod::track::itsClusterMap & uint8_t(1)) > 0; Service ccdb; std::unique_ptr geomPHOS; @@ -147,16 +184,7 @@ struct PhosElId { HistogramRegistry mHistManager{"PhosElIdHistograms"}; TF1 *fSigma_dz, *fSigma_dx; - float *PhosShiftX, *PhosShiftZ; - - TF1* fMeandXPosMod1; - TF1* fMeandXNegMod1; - TF1* fMeandXPosMod2; - TF1* fMeandXNegMod2; - TF1* fMeandXPosMod3; - TF1* fMeandXNegMod3; - TF1* fMeandXPosMod4; - TF1* fMeandXNegMod4; + std::array fMeandXPosMod, fMeandXNegMod; void init(InitContext const&) { @@ -165,32 +193,8 @@ struct PhosElId { std::vector momentumBinning = {0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 10.}; - std::vector parametersSigmadZ = pSigmadZ; - std::vector parametersSigmadX = pSigmadX; - std::vector vPhosShiftX = pPhosShiftX; - std::vector vPhosShiftZ = pPhosShiftZ; - std::vector meandXPosMod1 = pMeandXPosMod1; - std::vector meandXPosMod2 = pMeandXPosMod2; - std::vector meandXPosMod3 = pMeandXPosMod3; - std::vector meandXPosMod4 = pMeandXPosMod4; - std::vector meandXNegMod1 = pMeandXNegMod1; - std::vector meandXNegMod2 = pMeandXNegMod2; - std::vector meandXNegMod3 = pMeandXNegMod3; - std::vector meandXNegMod4 = pMeandXNegMod4; - - PhosShiftX = new float[4]; - PhosShiftX[0] = vPhosShiftX.at(0); - PhosShiftX[1] = vPhosShiftX.at(1); - PhosShiftX[2] = vPhosShiftX.at(2); - PhosShiftX[3] = vPhosShiftX.at(3); - - PhosShiftZ = new float[4]; - PhosShiftZ[0] = vPhosShiftZ.at(0); - PhosShiftZ[1] = vPhosShiftZ.at(1); - PhosShiftZ[2] = vPhosShiftZ.at(2); - PhosShiftZ[3] = vPhosShiftZ.at(3); - - const AxisSpec axisCounter{1, 0, +1, ""}, + + const AxisSpec axisCounter{3, 0, +3, ""}, axisP{momentumBinning, "p (GeV/c)"}, axisPt{momentumBinning, "p_{T} (GeV/c)"}, axisEta{200, -0.2, 0.2, "#eta"}, @@ -201,7 +205,7 @@ struct PhosElId { axisdX{nBinsDeltaX, mDeltaXmin, mDeltaXmax, "x_{tr}-x_{clu} (cm)", "x_{tr}-x_{clu} (cm)"}, axisdZ{nBinsDeltaZ, mDeltaZmin, mDeltaZmax, "z_{tr}-z_{clu} (cm)", "z_{tr}-z_{clu} (cm)"}, axisCells{20, 0., 20., "number of cells", "number of cells"}, - axisTime{100, 2e9 * mMinCluTime, 2e9 * mMaxCluTime, "time (ns)", "time (nanoseconds)"}, + axisTime{200, mCluTimeAxisMin, mCluTimeAxisMax, "time (ns)", "time (nanoseconds)"}, axisModes{4, 1., 5., "module", "module"}, axisX{150, -75., 75., "x (cm)", "x (cm)"}, axisZ{150, -75., 75., "z (cm)", "z (cm)"}, @@ -215,87 +219,99 @@ struct PhosElId { axisVTrackZ{400, -10., 10., "track vertex z (cm)", "track vertex z (cm)"}; mHistManager.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); - mHistManager.add("TVXinPHOSCounter", "TVXinPHOSCounter", kTH1F, {axisCounter}); - - mHistManager.add("hTrackPtEtaPhi", "Track pt vs eta vs phi", HistType::kTH3F, {axisPt, axisEta, axisPhi}); - mHistManager.add("hTrackPtEtaPhi_Phos", "Track pt vs eta vs phi on Phos surface", HistType::kTH3F, {axisPt, axisEta, axisPhi}); - mHistManager.add("hTrackDCA", "Track DCA info", HistType::kTH2F, {axisDCATrackXY, axisDCATrackZ}); - mHistManager.add("hTrackVX", "Track vertex coordinate X", HistType::kTH1F, {axisVTrackX}); - mHistManager.add("hTrackVY", "Track vertex coordinate Y", HistType::kTH1F, {axisVTrackY}); - mHistManager.add("hTrackVZ", "Track vertex coordinate Z", HistType::kTH1F, {axisVTrackZ}); - mHistManager.add("hColVX", "Collision vertex coordinate X", HistType::kTH1F, {axisVColX}); - mHistManager.add("hColVY", "Collision vertex coordinate Y", HistType::kTH1F, {axisVColY}); - mHistManager.add("hColVZ", "Collision vertex coordinate Z", HistType::kTH1F, {axisVColZ}); - mHistManager.add("hTrackPhosProjMod", "Track projection coordinates on PHOS modules", HistType::kTH3F, {axisX, axisZ, axisModes}); - mHistManager.add("hCluE_v_mod_v_time", "Cluster energy spectrum (E > 0.3 GeV) vs time per module", HistType::kTH3F, {axisE, axisTime, axisModes}); - - mHistManager.add("hCluE_mod_energy_cut", "Cluster energy spectrum (E > 0.3 GeV) per module", HistType::kTH2F, {axisE, axisModes}); - mHistManager.add("hCluE_mod_time_cut", "Cluster energy spectrum (E > 0.3 GeV)(time +-25 ns) per module", HistType::kTH2F, {axisE, axisModes}); - mHistManager.add("hCluE_mod_cell_cut", "Cluster energy spectrum (E > 0.3 GeV)(time +-25 ns)(ncells > 3) per module", HistType::kTH2F, {axisE, axisModes}); - mHistManager.add("hCluE_mod_disp", "Cluster energy spectrum OK dispersion and (E > 0.3 GeV)(time +-25 ns)(ncells > 3) per module", HistType::kTH2F, {axisE, axisModes}); - - mHistManager.add("hCluE_ncells_mod", "Cluster energy spectrum per module", HistType::kTH3F, {axisE, axisCells, axisModes}); - mHistManager.add("hCluXZ_mod", "Local cluster X Z per module", HistType::kTH3F, {axisX, axisZ, axisModes}); - - mHistManager.add("hdZpmod", "dz,p_{tr},module", HistType::kTH3F, {axisdZ, axisPt, axisModes}); - mHistManager.add("hdZpmod_pos", "dz,p_{tr},module positive tracks", HistType::kTH3F, {axisdZ, axisPt, axisModes}); - mHistManager.add("hdZpmod_neg", "dz,p_{tr},module negative tracks", HistType::kTH3F, {axisdZ, axisPt, axisModes}); - mHistManager.add("hdXpmod", "dx,p_{tr},module", HistType::kTH3F, {axisdX, axisPt, axisModes}); - mHistManager.add("hdXpmod_pos", "dx,p_{tr},module positive tracks", HistType::kTH3F, {axisdX, axisPt, axisModes}); - mHistManager.add("hdXpmod_neg", "dx,p_{tr},module negative tracks", HistType::kTH3F, {axisdX, axisPt, axisModes}); - - mHistManager.add("hCluE_v_pt_disp", "Cluster energy vs p | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); - mHistManager.add("hCluE_v_pt_Nsigma", "Cluster energy vs p within trackmatch Nsigma", HistType::kTH3F, {axisE, axisPt, axisModes}); - mHistManager.add("hCluE_v_pt_Nsigma_disp", "Cluster energy vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); - - mHistManager.add("hCluE_v_pt_disp_TPC", "Cluster energy vs p | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); - mHistManager.add("hCluE_v_pt_Nsigma_TPC", "Cluster energy vs p within trackmatch Nsigma", HistType::kTH3F, {axisE, axisPt, axisModes}); - mHistManager.add("hCluE_v_pt_Nsigma_disp_TPC", "Cluster energy vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); - - mHistManager.add("hEp_v_pt_disp", "E/p ratio vs p | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); - mHistManager.add("hEp_v_pt_Nsigma", "E/p ratio vs p within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); - mHistManager.add("hEp_v_pt_Nsigma_disp", "E/p ratio vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); - - mHistManager.add("hEp_v_E_disp", "E/p ratio vs cluster E | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); - mHistManager.add("hEp_v_E_Nsigma", "E/p ratio vs cluster E within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisE, axisModes}); - mHistManager.add("hEp_v_E_Nsigma_disp", "E/p ratio vs cluster E within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); - - mHistManager.add("hEp_v_pt_disp_TPC", "E/p ratio vs p | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); - mHistManager.add("hEp_v_pt_Nsigma_TPC", "E/p ratio vs p within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); - mHistManager.add("hEp_v_pt_Nsigma_disp_TPC", "E/p ratio vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); - - mHistManager.add("hEp_v_E_disp_TPC", "E/p ratio vs cluster E | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); - mHistManager.add("hEp_v_E_Nsigma_TPC", "E/p ratio vs cluster E within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisE, axisModes}); - mHistManager.add("hEp_v_E_Nsigma_disp_TPC", "E/p ratio vs cluster E within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("tracks/hTrackPtEtaPhi", "Track pt vs eta vs phi", HistType::kTH3F, {axisPt, axisEta, axisPhi}); + mHistManager.add("tracks/hTrackPtEtaPhi_Phos", "Track pt vs eta vs phi on Phos surface", HistType::kTH3F, {axisPt, axisEta, axisPhi}); + mHistManager.add("tracks/hTrackDCA", "Track DCA info", HistType::kTH2F, {axisDCATrackXY, axisDCATrackZ}); + mHistManager.add("tracks/hTrackVX", "Track vertex coordinate X", HistType::kTH1F, {axisVTrackX}); + mHistManager.add("tracks/hTrackVY", "Track vertex coordinate Y", HistType::kTH1F, {axisVTrackY}); + mHistManager.add("tracks/hTrackVZ", "Track vertex coordinate Z", HistType::kTH1F, {axisVTrackZ}); + mHistManager.add("collision/hColVX", "Collision vertex coordinate X", HistType::kTH1F, {axisVColX}); + mHistManager.add("collision/hColVY", "Collision vertex coordinate Y", HistType::kTH1F, {axisVColY}); + mHistManager.add("collision/hColVZ", "Collision vertex coordinate Z", HistType::kTH1F, {axisVColZ}); + mHistManager.add("tracks/hTrackPhosProjMod", "Track projection coordinates on PHOS modules", HistType::kTH3F, {axisX, axisZ, axisModes}); + + mHistManager.add("clusterSpectra/hCluE_v_mod_v_time", "Cluster energy spectrum (E > 0.3 GeV) vs time per module", HistType::kTH3F, {axisE, axisTime, axisModes}); + mHistManager.add("clusterSpectra/hCluE_mod_energy_cut", "Cluster energy spectrum (E > 0.3 GeV) per module", HistType::kTH2F, {axisE, axisModes}); + mHistManager.add("clusterSpectra/hCluE_mod_time_cut", "Cluster energy spectrum (E > 0.3 GeV)(time +-25 ns) per module", HistType::kTH2F, {axisE, axisModes}); + mHistManager.add("clusterSpectra/hCluE_mod_cell_cut", "Cluster energy spectrum (E > 0.3 GeV)(time +-25 ns)(ncells > 3) per module", HistType::kTH2F, {axisE, axisModes}); + mHistManager.add("clusterSpectra/hCluE_mod_disp", "Cluster energy spectrum OK dispersion and (E > 0.3 GeV)(time +-25 ns)(ncells > 3) per module", HistType::kTH2F, {axisE, axisModes}); + mHistManager.add("clusterSpectra/hCluE_ncells_mod", "Cluster energy spectrum vs cell ammount per module", HistType::kTH3F, {axisE, axisCells, axisModes}); + + mHistManager.add("coordinateMatching/hCluXZ_mod", "Local cluster X Z per module", HistType::kTH3F, {axisX, axisZ, axisModes}); + mHistManager.add("coordinateMatching/hdZpmod", "dz,p_{tr},module", HistType::kTH3F, {axisdZ, axisPt, axisModes}); + mHistManager.add("coordinateMatching/hdZpmod_pos", "dz,p_{tr},module positive tracks", HistType::kTH3F, {axisdZ, axisPt, axisModes}); + mHistManager.add("coordinateMatching/hdZpmod_neg", "dz,p_{tr},module negative tracks", HistType::kTH3F, {axisdZ, axisPt, axisModes}); + mHistManager.add("coordinateMatching/hdXpmod", "dx,p_{tr},module", HistType::kTH3F, {axisdX, axisPt, axisModes}); + mHistManager.add("coordinateMatching/hdXpmod_pos", "dx,p_{tr},module positive tracks", HistType::kTH3F, {axisdX, axisPt, axisModes}); + mHistManager.add("coordinateMatching/hdXpmod_neg", "dx,p_{tr},module negative tracks", HistType::kTH3F, {axisdX, axisPt, axisModes}); + + mHistManager.add("clusterSpectra/hCluE_v_pt_disp", "Cluster energy vs p | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("clusterSpectra/hCluE_v_pt_Nsigma", "Cluster energy vs p within trackmatch Nsigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("clusterSpectra/hCluE_v_pt_Nsigma_disp", "Cluster energy vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("clusterSpectra/hCluE_v_pt_disp_TPCel", "Cluster energy vs p | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("clusterSpectra/hCluE_v_pt_Nsigma_TPCel", "Cluster energy vs p within trackmatch Nsigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("clusterSpectra/hCluE_v_pt_Nsigma_disp_TPCel", "Cluster energy vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + + mHistManager.add("energyMomentumRatio/hEp_v_pt_disp", "E/p ratio vs p | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("energyMomentumRatio/hEp_v_pt_Nsigma", "E/p ratio vs p within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("energyMomentumRatio/hEp_v_pt_Nsigma_disp", "E/p ratio vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + + mHistManager.add("energyMomentumRatio/hEp_v_E_disp", "E/p ratio vs cluster E | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("energyMomentumRatio/hEp_v_E_Nsigma", "E/p ratio vs cluster E within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("energyMomentumRatio/hEp_v_E_Nsigma_disp", "E/p ratio vs cluster E within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + + mHistManager.add("energyMomentumRatio/hEp_v_pt_disp_TPCel", "E/p ratio vs p | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("energyMomentumRatio/hEp_v_pt_Nsigma_TPCel", "E/p ratio vs p within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("energyMomentumRatio/hEp_v_pt_Nsigma_disp_TPCel", "E/p ratio vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + + mHistManager.add("energyMomentumRatio/hEp_v_E_disp_TPCel", "E/p ratio vs cluster E | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("energyMomentumRatio/hEp_v_E_Nsigma_TPCel", "E/p ratio vs cluster E within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("energyMomentumRatio/hEp_v_E_Nsigma_disp_TPCel", "E/p ratio vs cluster E within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + + mHistManager.add("doubleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma", "Cluster energy vs p within trackmatch Nsigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("doubleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_disp", "Cluster energy vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("doubleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_TPCel", "Cluster energy vs p within trackmatch Nsigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("doubleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_disp_TPCel", "Cluster energy vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("doubleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma", "E/p ratio vs p within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("doubleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_disp", "E/p ratio vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("doubleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_TPCel", "E/p ratio vs p within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("doubleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_disp_TPCel", "E/p ratio vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("doubleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma", "E/p ratio vs cluster E within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("doubleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_disp", "E/p ratio vs cluster E within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("doubleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_TPCel", "E/p ratio vs cluster E within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("doubleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_disp_TPCel", "E/p ratio vs cluster E within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + + mHistManager.add("singleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma", "Cluster energy vs p within trackmatch Nsigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("singleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_disp", "Cluster energy vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("singleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_TPCel", "Cluster energy vs p within trackmatch Nsigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("singleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_disp_TPCel", "Cluster energy vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("singleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma", "E/p ratio vs p within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("singleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_disp", "E/p ratio vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("singleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_TPCel", "E/p ratio vs p within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("singleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_disp_TPCel", "E/p ratio vs p within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("singleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma", "E/p ratio vs cluster E within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("singleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_disp", "E/p ratio vs cluster E within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("singleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_TPCel", "E/p ratio vs cluster E within trackmatch Nsigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("singleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_disp_TPCel", "E/p ratio vs cluster E within trackmatch Nsigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); geomPHOS = std::make_unique("PHOS"); + fSigma_dz = new TF1("fSigma_dz", "[0]/(x+[1])^[2]+pol1(3)", 0.3, 10); - fSigma_dz->SetParameters(parametersSigmadZ.at(0), parametersSigmadZ.at(1), parametersSigmadZ.at(2), parametersSigmadZ.at(3), parametersSigmadZ.at(4)); + fSigma_dz->SetParameters(((std::vector)pSigmadZ).at(0), ((std::vector)pSigmadZ).at(1), ((std::vector)pSigmadZ).at(2), ((std::vector)pSigmadZ).at(3), ((std::vector)pSigmadZ).at(4)); fSigma_dx = new TF1("fSigma_dx", "[0]/x^[1]+[2]", 0.1, 10); - fSigma_dx->SetParameters(parametersSigmadX.at(0), parametersSigmadX.at(1), parametersSigmadX.at(2)); - - fMeandXPosMod1 = new TF1("funcMeandx_pos_mod1", "[0]/(x+[1])^[2]", 0.1, 10); - fMeandXNegMod1 = new TF1("funcMeandx_neg_mod1", "[0]/(x+[1])^[2]", 0.1, 10); - fMeandXPosMod2 = new TF1("funcMeandx_pos_mod2", "[0]/(x+[1])^[2]", 0.1, 10); - fMeandXNegMod2 = new TF1("funcMeandx_neg_mod2", "[0]/(x+[1])^[2]", 0.1, 10); - fMeandXPosMod3 = new TF1("funcMeandx_pos_mod3", "[0]/(x+[1])^[2]", 0.1, 10); - fMeandXNegMod3 = new TF1("funcMeandx_neg_mod3", "[0]/(x+[1])^[2]", 0.1, 10); - fMeandXPosMod4 = new TF1("funcMeandx_pos_mod4", "[0]/(x+[1])^[2]", 0.1, 10); - fMeandXNegMod4 = new TF1("funcMeandx_neg_mod4", "[0]/(x+[1])^[2]", 0.1, 10); - - fMeandXPosMod1->SetParameters(meandXPosMod1.at(0), meandXPosMod1.at(1), meandXPosMod1.at(2)); - fMeandXPosMod2->SetParameters(meandXPosMod2.at(0), meandXPosMod2.at(1), meandXPosMod2.at(2)); - fMeandXPosMod3->SetParameters(meandXPosMod3.at(0), meandXPosMod3.at(1), meandXPosMod3.at(2)); - fMeandXPosMod4->SetParameters(meandXPosMod4.at(0), meandXPosMod4.at(1), meandXPosMod4.at(2)); - - fMeandXNegMod1->SetParameters(meandXNegMod1.at(0), meandXNegMod1.at(1), meandXNegMod1.at(2)); - fMeandXNegMod2->SetParameters(meandXNegMod2.at(0), meandXNegMod2.at(1), meandXNegMod2.at(2)); - fMeandXNegMod3->SetParameters(meandXNegMod3.at(0), meandXNegMod3.at(1), meandXNegMod3.at(2)); - fMeandXNegMod4->SetParameters(meandXNegMod4.at(0), meandXNegMod4.at(1), meandXNegMod4.at(2)); + fSigma_dx->SetParameters(((std::vector)pSigmadX).at(0), ((std::vector)pSigmadX).at(1), ((std::vector)pSigmadX).at(2)); + + for (int i = 0; i < mAmountOfModules; i++) { + fMeandXPosMod[i] = new TF1(Form("funcMeandx_pos_mod%i", i + 1), "[0]/(x+[1])^[2]", 0.1, 10); + fMeandXPosMod[i]->SetParameters(pMeandXPosMod->at(3 * i), pMeandXPosMod->at(3 * i + 1), pMeandXPosMod->at(3 * i + 2)); + + fMeandXNegMod[i] = new TF1(Form("funcMeandx_neg_mod%i", i + 1), "[0]/(x+[1])^[2]", 0.1, 10); + fMeandXNegMod[i]->SetParameters(pMeandXNegMod->at(3 * i), pMeandXNegMod->at(3 * i + 1), pMeandXNegMod->at(3 * i + 2)); + } } - void process(soa::Join::iterator const& collision, + void process(SelCollisions::iterator const& collision, aod::CaloClusters const& clusters, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) @@ -312,39 +328,37 @@ struct PhosElId { LOG(info) << ">>>>>>>>>>>> Magnetic field: " << bz; runNumber = bc.runNumber(); } - if (std::fabs(collision.posZ()) > 10.f) + if (std::fabs(collision.posZ()) > mColMaxZ) return; mHistManager.fill(HIST("eventCounter"), 0.5); if (!collision.alias_bit(mEvSelTrig)) return; - mHistManager.fill(HIST("TVXinPHOSCounter"), 0.5); - + mHistManager.fill(HIST("eventCounter"), 1.5); + if (isSel8) { + if (!collision.sel8()) + return; + mHistManager.fill(HIST("eventCounter"), 2.5); + } if (clusters.size() == 0) return; // Nothing to process - mHistManager.fill(HIST("hColVX"), collision.posX()); - mHistManager.fill(HIST("hColVY"), collision.posY()); - mHistManager.fill(HIST("hColVZ"), collision.posZ()); + mHistManager.fill(HIST("collision/hColVX"), collision.posX()); + mHistManager.fill(HIST("collision/hColVY"), collision.posY()); + mHistManager.fill(HIST("collision/hColVZ"), collision.posZ()); for (auto const& track : tracks) { - if (!track.has_collision() || std::fabs(track.dcaXY()) > cfgDCAxyMax || std::fabs(track.dcaZ()) > cfgDCAzMax || !track.hasTPC() || std::fabs(track.eta()) > 0.15) - continue; - if (track.pt() < cfgPtMin || track.pt() > cfgPtMax) - continue; - if (track.itsChi2NCl() > cfgITSchi2Max) + if (!track.has_collision() || !track.hasTPC()) continue; - if (track.itsNCls() < cfgITSnclsMin || track.itsNCls() > cfgITSnclsMax || !((track.itsClusterMap() & uint8_t(1)) > 0)) + if (track.itsNCls() < ITSnclsMin || track.itsNCls() > ITSnclsMax || !((track.itsClusterMap() & uint8_t(1)) > 0)) continue; - if (track.tpcChi2NCl() > cfgTPCchi2Max) + if (track.tpcNClsFound() < TPCnclsMin || track.tpcNClsFound() > TPCnclsMax) continue; - if (track.tpcNClsFound() < cfgTPCnclsMin || track.tpcNClsFound() > cfgTPCnclsMax) - continue; - if (track.tpcNClsCrossedRows() < cfgTPCnclsCRMin || track.tpcNClsCrossedRows() > cfgTPCnclsCRMax) + if (track.tpcNClsCrossedRows() < TPCnclsCRMin || track.tpcNClsCrossedRows() > TPCnclsCRMax) continue; - mHistManager.fill(HIST("hTrackVX"), track.x()); - mHistManager.fill(HIST("hTrackVY"), track.y()); - mHistManager.fill(HIST("hTrackVZ"), track.z()); + mHistManager.fill(HIST("tracks/hTrackVX"), track.x()); + mHistManager.fill(HIST("tracks/hTrackVY"), track.y()); + mHistManager.fill(HIST("tracks/hTrackVZ"), track.z()); int16_t module; float trackX = 999., trackZ = 999.; @@ -360,16 +374,16 @@ struct PhosElId { if (track.hasTPC()) { float nsigmaTPCEl = track.tpcNSigmaEl(); float nsigmaTOFEl = track.tofNSigmaEl(); - bool isTPCElectron = nsigmaTPCEl > cfgTPCNSigmaElMin && nsigmaTPCEl < cfgTPCNSigmaElMax; - bool isTOFElectron = nsigmaTOFEl > cfgTOFNSigmaElMin && nsigmaTOFEl < cfgTOFNSigmaElMax; + bool isTPCElectron = nsigmaTPCEl > TPCNSigmaElMin && nsigmaTPCEl < TPCNSigmaElMax; + bool isTOFElectron = nsigmaTOFEl > TOFNSigmaElMin && nsigmaTOFEl < TOFNSigmaElMax; isElectron = isTPCElectron || isTOFElectron; float nsigmaTPCPi = track.tpcNSigmaPi(); float nsigmaTPCKa = track.tpcNSigmaKa(); float nsigmaTPCPr = track.tpcNSigmaPr(); - bool isPion = nsigmaTPCPi > cfgTPCNSigmaPiMin && nsigmaTPCPi < cfgTPCNSigmaPiMax; - bool isKaon = nsigmaTPCKa > cfgTPCNSigmaKaMin && nsigmaTPCKa < cfgTPCNSigmaKaMax; - bool isProton = nsigmaTPCPr > cfgTPCNSigmaPrMin && nsigmaTPCPr < cfgTPCNSigmaPrMax; + bool isPion = nsigmaTPCPi > TPCNSigmaPiMin && nsigmaTPCPi < TPCNSigmaPiMax; + bool isKaon = nsigmaTPCKa > TPCNSigmaKaMin && nsigmaTPCKa < TPCNSigmaKaMax; + bool isProton = nsigmaTPCPr > TPCNSigmaPrMin && nsigmaTPCPr < TPCNSigmaPrMax; if (isElectron && !(isPion || isKaon || isProton)) isElectron = true; } @@ -379,113 +393,181 @@ struct PhosElId { if (module != clu.mod()) continue; double cluE = clu.e(); - mHistManager.fill(HIST("hCluE_ncells_mod"), cluE, clu.ncell(), module); if (cluE < mMinCluE || clu.ncell() < mMinCluNcell || clu.time() > mMaxCluTime || clu.time() < mMinCluTime) continue; - bool isDispOK = testLambda(cluE, clu.m02(), clu.m20()); - + bool isDispOK = false; + if (mSwapM20M02ForTestLambda) + isDispOK = testLambda(cluE, clu.m02(), clu.m20(), mShowerShapeCutValue, mUseNegativeCrossTerm); + else + isDispOK = testLambda(cluE, clu.m20(), clu.m02(), mShowerShapeCutValue, mUseNegativeCrossTerm); float posX = clu.x(), posZ = clu.z(), dX = trackX - posX, dZ = trackZ - posZ, Ep = cluE / trackMom; - mHistManager.fill(HIST("hCluXZ_mod"), posX, posZ, module); - - mHistManager.fill(HIST("hdZpmod"), dZ, trackPT, module); - mHistManager.fill(HIST("hdXpmod"), dX, trackPT, module); + mHistManager.fill(HIST("coordinateMatching/hdZpmod"), dZ, trackPT, module); + mHistManager.fill(HIST("coordinateMatching/hdXpmod"), dX, trackPT, module); if (posTrack) { - mHistManager.fill(HIST("hdZpmod_pos"), dZ, trackPT, module); - mHistManager.fill(HIST("hdXpmod_pos"), dX, trackPT, module); + mHistManager.fill(HIST("coordinateMatching/hdZpmod_pos"), dZ, trackPT, module); + mHistManager.fill(HIST("coordinateMatching/hdXpmod_pos"), dX, trackPT, module); } else { - mHistManager.fill(HIST("hdZpmod_neg"), dZ, trackPT, module); - mHistManager.fill(HIST("hdXpmod_neg"), dX, trackPT, module); + mHistManager.fill(HIST("coordinateMatching/hdZpmod_neg"), dZ, trackPT, module); + mHistManager.fill(HIST("coordinateMatching/hdXpmod_neg"), dX, trackPT, module); } if (isDispOK) { - mHistManager.fill(HIST("hCluE_v_pt_disp"), cluE, trackPT, module); - mHistManager.fill(HIST("hEp_v_pt_disp"), Ep, trackPT, module); - mHistManager.fill(HIST("hEp_v_E_disp"), Ep, cluE, module); + mHistManager.fill(HIST("clusterSpectra/hCluE_v_pt_disp"), cluE, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_pt_disp"), Ep, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_E_disp"), Ep, cluE, module); if (isElectron) { - mHistManager.fill(HIST("hCluE_v_pt_disp_TPC"), cluE, trackPT, module); - mHistManager.fill(HIST("hEp_v_pt_disp_TPC"), Ep, trackPT, module); - mHistManager.fill(HIST("hEp_v_E_disp_TPC"), Ep, cluE, module); + mHistManager.fill(HIST("clusterSpectra/hCluE_v_pt_disp_TPCel"), cluE, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_pt_disp_TPCel"), Ep, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_E_disp_TPCel"), Ep, cluE, module); } } - if (!isWithinNSigma(module, trackPT, dZ, dX)) + if (clu.trackdist() < NsigmaTrackMatch) { + mHistManager.fill(HIST("doubleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma"), cluE, trackPT, module); + mHistManager.fill(HIST("doubleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma"), Ep, trackPT, module); + mHistManager.fill(HIST("doubleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma"), Ep, cluE, module); + if (isElectron) { + mHistManager.fill(HIST("doubleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_TPCel"), cluE, trackPT, module); + mHistManager.fill(HIST("doubleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_TPCel"), Ep, trackPT, module); + mHistManager.fill(HIST("doubleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_TPCel"), Ep, cluE, module); + } + if (isDispOK) { + mHistManager.fill(HIST("doubleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_disp"), cluE, trackPT, module); + mHistManager.fill(HIST("doubleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_disp"), Ep, trackPT, module); + mHistManager.fill(HIST("doubleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_disp"), Ep, cluE, module); + if (isElectron) { + mHistManager.fill(HIST("doubleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_disp_TPCel"), cluE, trackPT, module); + mHistManager.fill(HIST("doubleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_disp_TPCel"), Ep, trackPT, module); + mHistManager.fill(HIST("doubleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_disp_TPCel"), Ep, cluE, module); + } + } + } + if (!isWithinNSigma(module, trackPT, dZ, dX, posTrack)) continue; - mHistManager.fill(HIST("hCluE_v_pt_Nsigma"), cluE, trackPT, module); - mHistManager.fill(HIST("hEp_v_pt_Nsigma"), Ep, trackPT, module); - mHistManager.fill(HIST("hEp_v_E_Nsigma"), Ep, cluE, module); + mHistManager.fill(HIST("clusterSpectra/hCluE_v_pt_Nsigma"), cluE, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_pt_Nsigma"), Ep, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_E_Nsigma"), Ep, cluE, module); if (isElectron) { - mHistManager.fill(HIST("hCluE_v_pt_Nsigma_TPC"), cluE, trackPT, module); - mHistManager.fill(HIST("hEp_v_pt_Nsigma_TPC"), Ep, trackPT, module); - mHistManager.fill(HIST("hEp_v_E_Nsigma_TPC"), Ep, cluE, module); + mHistManager.fill(HIST("clusterSpectra/hCluE_v_pt_Nsigma_TPCel"), cluE, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_pt_Nsigma_TPCel"), Ep, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_E_Nsigma_TPCel"), Ep, cluE, module); } if (isDispOK) { - mHistManager.fill(HIST("hCluE_v_pt_Nsigma_disp"), cluE, trackPT, module); - mHistManager.fill(HIST("hEp_v_pt_Nsigma_disp"), Ep, trackPT, module); - mHistManager.fill(HIST("hEp_v_E_Nsigma_disp"), Ep, cluE, module); + mHistManager.fill(HIST("clusterSpectra/hCluE_v_pt_Nsigma_disp"), cluE, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_pt_Nsigma_disp"), Ep, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_E_Nsigma_disp"), Ep, cluE, module); if (isElectron) { - mHistManager.fill(HIST("hCluE_v_pt_Nsigma_disp_TPC"), cluE, trackPT, module); - mHistManager.fill(HIST("hEp_v_pt_Nsigma_disp_TPC"), Ep, trackPT, module); - mHistManager.fill(HIST("hEp_v_E_Nsigma_disp_TPC"), Ep, cluE, module); + mHistManager.fill(HIST("clusterSpectra/hCluE_v_pt_Nsigma_disp_TPCel"), cluE, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_pt_Nsigma_disp_TPCel"), Ep, trackPT, module); + mHistManager.fill(HIST("energyMomentumRatio/hEp_v_E_Nsigma_disp_TPCel"), Ep, cluE, module); } - hosMatch(collision.index(), clu.index(), track.index()); + phosMatch(collision.index(), clu.index(), track.index()); } } - mHistManager.fill(HIST("hTrackPtEtaPhi"), track.pt(), track.eta(), track.phi() * TMath::RadToDeg()); - mHistManager.fill(HIST("hTrackPtEtaPhi_Phos"), track.pt(), track.trackEtaEmcal(), track.trackPhiEmcal() * TMath::RadToDeg()); - mHistManager.fill(HIST("hTrackDCA"), track.dcaXY(), track.dcaZ()); - mHistManager.fill(HIST("hTrackPhosProjMod"), trackX, trackZ, module); + mHistManager.fill(HIST("tracks/hTrackPtEtaPhi"), track.pt(), track.eta(), track.phi() * TMath::RadToDeg()); + mHistManager.fill(HIST("tracks/hTrackPtEtaPhi_Phos"), track.pt(), track.trackEtaEmcal(), track.trackPhiEmcal() * TMath::RadToDeg()); + mHistManager.fill(HIST("tracks/hTrackDCA"), track.dcaXY(), track.dcaZ()); + mHistManager.fill(HIST("tracks/hTrackPhosProjMod"), trackX, trackZ, module); } // end of double loop for (auto const& clu : clusters) { double cluE = clu.e(), cluTime = clu.time(); int mod = clu.mod(); + bool isDispOK = false; + if (mSwapM20M02ForTestLambda) + isDispOK = testLambda(cluE, clu.m02(), clu.m20(), mShowerShapeCutValue, mUseNegativeCrossTerm); + else + isDispOK = testLambda(cluE, clu.m20(), clu.m02(), mShowerShapeCutValue, mUseNegativeCrossTerm); if (cluE > mMinCluE) { - mHistManager.fill(HIST("hCluE_mod_energy_cut"), cluE, mod); - mHistManager.fill(HIST("hCluE_v_mod_v_time"), cluE, cluTime * 1e9, mod); + mHistManager.fill(HIST("clusterSpectra/hCluE_mod_energy_cut"), cluE, mod); + mHistManager.fill(HIST("clusterSpectra/hCluE_v_mod_v_time"), cluE, cluTime * 1e9, mod); if (cluTime < mMaxCluTime && cluTime > mMinCluTime) { - mHistManager.fill(HIST("hCluE_mod_time_cut"), cluE, mod); + mHistManager.fill(HIST("clusterSpectra/hCluE_mod_time_cut"), cluE, mod); if (clu.ncell() >= mMinCluNcell) { - mHistManager.fill(HIST("hCluE_mod_cell_cut"), cluE, mod); - if (testLambda(cluE, clu.m02(), clu.m20())) - mHistManager.fill(HIST("hCluE_mod_disp"), cluE, mod); + mHistManager.fill(HIST("clusterSpectra/hCluE_mod_cell_cut"), cluE, mod); + mHistManager.fill(HIST("coordinateMatching/hCluXZ_mod"), clu.x(), clu.z(), mod); + mHistManager.fill(HIST("clusterSpectra/hCluE_ncells_mod"), cluE, clu.ncell(), mod); + if (isDispOK) + mHistManager.fill(HIST("clusterSpectra/hCluE_mod_disp"), cluE, mod); } } } + + if (cluE < mMinCluE || + clu.ncell() < mMinCluNcell || + clu.time() > mMaxCluTime || clu.time() < mMinCluTime) + continue; + + if (clu.trackdist() > NsigmaTrackMatch) + continue; + auto matchedTrack = tracks.iteratorAt(clu.trackIndex()); + if (!matchedTrack.has_collision() || !matchedTrack.hasTPC()) + continue; + + if (matchedTrack.itsNCls() < ITSnclsMin || matchedTrack.itsNCls() > ITSnclsMax || !((matchedTrack.itsClusterMap() & uint8_t(1)) > 0)) + continue; + if (matchedTrack.tpcNClsFound() < TPCnclsMin || matchedTrack.tpcNClsFound() > TPCnclsMax) + continue; + if (matchedTrack.tpcNClsCrossedRows() < TPCnclsCRMin || matchedTrack.tpcNClsCrossedRows() > TPCnclsCRMax) + continue; + + mHistManager.fill(HIST("singleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma"), cluE, matchedTrack.pt(), mod); + mHistManager.fill(HIST("singleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma"), cluE / matchedTrack.p(), matchedTrack.pt(), mod); + mHistManager.fill(HIST("singleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma"), cluE / matchedTrack.p(), cluE, mod); + if (isDispOK) { + mHistManager.fill(HIST("singleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_disp"), cluE, matchedTrack.pt(), mod); + mHistManager.fill(HIST("singleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_disp"), cluE / matchedTrack.p(), matchedTrack.pt(), mod); + mHistManager.fill(HIST("singleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_disp"), cluE / matchedTrack.p(), cluE, mod); + } + bool isElectron = false; + if (matchedTrack.hasTPC()) { + float nsigmaTPCEl = matchedTrack.tpcNSigmaEl(); + float nsigmaTOFEl = matchedTrack.tofNSigmaEl(); + bool isTPCElectron = nsigmaTPCEl > TPCNSigmaElMin && nsigmaTPCEl < TPCNSigmaElMax; + bool isTOFElectron = nsigmaTOFEl > TOFNSigmaElMin && nsigmaTOFEl < TOFNSigmaElMax; + isElectron = isTPCElectron || isTOFElectron; + + float nsigmaTPCPi = matchedTrack.tpcNSigmaPi(); + float nsigmaTPCKa = matchedTrack.tpcNSigmaKa(); + float nsigmaTPCPr = matchedTrack.tpcNSigmaPr(); + bool isPion = nsigmaTPCPi > TPCNSigmaPiMin && nsigmaTPCPi < TPCNSigmaPiMax; + bool isKaon = nsigmaTPCKa > TPCNSigmaKaMin && nsigmaTPCKa < TPCNSigmaKaMax; + bool isProton = nsigmaTPCPr > TPCNSigmaPrMin && nsigmaTPCPr < TPCNSigmaPrMax; + if (isElectron && !(isPion || isKaon || isProton)) + isElectron = true; + } + if (isElectron) { + mHistManager.fill(HIST("singleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_TPCel"), cluE, matchedTrack.pt(), mod); + mHistManager.fill(HIST("singleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_TPCel"), cluE / matchedTrack.p(), matchedTrack.pt(), mod); + mHistManager.fill(HIST("singleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_TPCel"), cluE / matchedTrack.p(), cluE, mod); + if (isDispOK) { + mHistManager.fill(HIST("singleLoop/trackdist/clusterSpectra/hCluE_v_pt_Nsigma_disp_TPCel"), cluE, matchedTrack.pt(), mod); + mHistManager.fill(HIST("singleLoop/trackdist/energyMomentumRatio/hEp_v_pt_Nsigma_disp_TPCel"), cluE / matchedTrack.p(), matchedTrack.pt(), mod); + mHistManager.fill(HIST("singleLoop/trackdist/energyMomentumRatio/hEp_v_E_Nsigma_disp_TPCel"), cluE / matchedTrack.p(), cluE, mod); + } + } } // end of cluster loop } - - bool isWithinNSigma(int16_t& mod, float p, float deltaZ, float deltaX) + bool isWithinNSigma(int16_t& mod, float p, float deltaZ, float deltaX, bool positiveCharge) { - if (mod == 1) { - if (std::fabs(deltaZ - PhosShiftZ[0]) > cfgNsigmaTrackMatch * fSigma_dz->Eval(p)) - return false; - if (std::fabs(deltaX - fMeandXPosMod1->Eval(p) + PhosShiftX[0]) > cfgNsigmaTrackMatch * fSigma_dx->Eval(p)) - return false; - } else if (mod == 2) { - if (std::fabs(deltaZ - PhosShiftZ[1]) > cfgNsigmaTrackMatch * fSigma_dz->Eval(p)) - return false; - if (std::fabs(deltaX - fMeandXPosMod2->Eval(p) + PhosShiftX[1]) > cfgNsigmaTrackMatch * fSigma_dx->Eval(p)) - return false; - } else if (mod == 3) { - if (std::fabs(deltaZ - PhosShiftZ[2]) > cfgNsigmaTrackMatch * fSigma_dz->Eval(p)) - return false; - if (std::fabs(deltaX - fMeandXPosMod3->Eval(p) + PhosShiftX[2]) > cfgNsigmaTrackMatch * fSigma_dx->Eval(p)) - return false; - } else if (mod == 4) { - if (std::fabs(deltaZ - PhosShiftZ[3]) > cfgNsigmaTrackMatch * fSigma_dz->Eval(p)) + int modMinus1 = mod - 1; + if (std::fabs(deltaZ - ((std::vector)pPhosShiftZ).at(modMinus1)) > NsigmaTrackMatch * fSigma_dz->Eval(p)) + return false; + if (positiveCharge) { + if (std::fabs(deltaX - fMeandXPosMod[modMinus1]->Eval(p) - ((std::vector)pPhosShiftX).at(modMinus1)) > NsigmaTrackMatch * fSigma_dx->Eval(p)) return false; - if (std::fabs(deltaX - fMeandXPosMod4->Eval(p) + PhosShiftX[3]) > cfgNsigmaTrackMatch * fSigma_dx->Eval(p)) + } else { + if (std::fabs(deltaX - fMeandXNegMod[modMinus1]->Eval(p) - ((std::vector)pPhosShiftX).at(modMinus1)) > NsigmaTrackMatch * fSigma_dx->Eval(p)) return false; } return true; } - - /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// taken from PHOSAlign bool impactOnPHOS(o2::track::TrackParametrization& trackPar, float trackEta, float trackPhi, float /*zvtx*/, int16_t& module, float& trackX, float& trackZ) { // eta,phi was calculated at EMCAL radius. @@ -498,12 +580,14 @@ struct PhosElId { return false; } const float dphi = 20. * 0.017453293; + trackPhi = RecoDecay::constrainAngle(trackPhi); + module = 1 + static_cast((trackPhi - phiMin) / dphi); if (module < 1) { module = 1; } - if (module > 4) { - module = 4; + if (module > mAmountOfModules) { // > 4 + module = mAmountOfModules; // = 4 } // get PHOS radius @@ -546,59 +630,56 @@ struct PhosElId { trackZ = posL[1]; return true; } - //_____________________________________________________________________________ - bool testLambda(float pt, float l1, float l2) - { - // Parameterization for full dispersion - float l2Mean = 1.53126 + 9.50835e+06 / (1. + 1.08728e+07 * pt + 1.73420e+06 * pt * pt); - float l1Mean = 1.12365 + 0.123770 * std::exp(-pt * 0.246551) + 5.30000e-03 * pt; - float l2Sigma = 6.48260e-02 + 7.60261e+10 / (1. + 1.53012e+11 * pt + 5.01265e+05 * pt * pt) + 9.00000e-03 * pt; - float l1Sigma = 4.44719e-04 + 6.99839e-01 / (1. + 1.22497e+00 * pt + 6.78604e-07 * pt * pt) + 9.00000e-03 * pt; - float c = -0.35 - 0.550 * std::exp(-0.390730 * pt); - - return 0.5 * (l1 - l1Mean) * (l1 - l1Mean) / l1Sigma / l1Sigma + - 0.5 * (l2 - l2Mean) * (l2 - l2Mean) / l2Sigma / l2Sigma + - 0.5 * c * (l1 - l1Mean) * (l2 - l2Mean) / l1Sigma / l2Sigma < - 4.; - } }; struct MassSpectra { - using SelCollisions = soa::Join; - using MyTracks = soa::Join; - - Configurable mEvSelTrig{"mEvSelTrig", kTVXinPHOS, "Select events with this trigger"}; - - Configurable cfgEtaMax{"cfgEtaMax", {0.8f}, "eta ranges"}; - Configurable cfgPtMin{"cfgPtMin", {0.2f}, "pt min"}; - Configurable cfgPtMax{"cfgPtMax", {20.f}, "pt max"}; - Configurable cfgDCAxyMax{"cfgDCAxyMax", {3.f}, "dcaxy max"}; - Configurable cfgDCAzMax{"cfgDCAzMax", {3.f}, "dcaz max"}; - Configurable cfgITSchi2Max{"cfgITSchi2Max", {5.f}, "its chi2 max"}; - Configurable cfgITSnclsMin{"cfgITSnclsMin", {4.5f}, "min number of ITS clusters"}; - Configurable cfgITSnclsMax{"cfgITSnclsMax", {7.5f}, "max number of ITS clusters"}; - Configurable cfgTPCchi2Max{"cfgTPCchi2Max", {4.f}, "tpc chi2 max"}; - Configurable cfgTPCnclsMin{"cfgTPCnclsMin", {90.f}, "min number of TPC clusters"}; - Configurable cfgTPCnclsMax{"cfgTPCnclsMax", {170.f}, "max number of TPC clusters"}; - Configurable cfgTPCnclsCRMin{"cfgTPCnclsCRMin", {80.f}, "min number of TPC crossed rows"}; - Configurable cfgTPCnclsCRMax{"cfgTPCnclsCRMax", {161.f}, "max number of TPC crossed rows"}; - - Configurable cfgTPCNSigmaElMin{"cfgTPCNSigmaElMin", {-3.f}, "min TPC nsigma e for inclusion"}; - Configurable cfgTPCNSigmaElMax{"cfgTPCNSigmaElMax", {2.f}, "max TPC nsigma e for inclusion"}; - Configurable cfgTPCNSigmaPiMin{"cfgTPCNSigmaPiMin", {-3.f}, "min TPC nsigma pion for exclusion"}; - Configurable cfgTPCNSigmaPiMax{"cfgTPCNSigmaPiMax", {3.5f}, "max TPC nsigma pion for exclusion"}; - Configurable cfgTPCNSigmaPrMin{"cfgTPCNSigmaPrMin", {-3.f}, "min TPC nsigma proton for exclusion"}; - Configurable cfgTPCNSigmaPrMax{"cfgTPCNSigmaPrMax", {4.f}, "max TPC nsigma proton for exclusion"}; - Configurable cfgTPCNSigmaKaMin{"cfgTPCNSigmaKaMin", {-3.f}, "min TPC nsigma kaon for exclusion"}; - Configurable cfgTPCNSigmaKaMax{"cfgTPCNSigmaKaMax", {4.f}, "max TPC nsigma kaon for exclusion"}; - Configurable cfgTOFNSigmaElMin{"cfgTOFNSigmaElMin", {-3.f}, "min TOF nsigma e for inclusion"}; - Configurable cfgTOFNSigmaElMax{"cfgTOFNSigmaElMax", {3.f}, "max TOF nsigma e for inclusion"}; - - Configurable cfgShiftEp{"cfgShiftEp", {0.055f}, "PHOS E/p shift for electrons"}; - Configurable cfgNsigmaEp{"cfgNsigmaEp", {2.f}, "PHOS E/p nsigma for inclusion"}; - - Configurable> cfgEpSigmaPars{"cfgEpSigmaPars", {1.3e-02, 1.9e-02, 1.1e-02, 3.e-02}, "E/p sigma function parameters (from alice 3 mc tests + const)"}; + using SelCollisions = soa::Join; + using MyTracks = soa::Join; + Configurable isSel8{"isSel8", 1, "check if event is Single Event Latch-up 8"}; + Configurable mEvSelTrig{"mEvSelTrig", kTVXinPHOS, "Select events with this trigger"}, + MassBinning{"MassBinning", 1000, "Binning for mass"}, + EnergyBinning{"EnergyBinning", 100, "Binning for energy"}, + EpRatioBinning{"EpRatioBinning", 200, "Binning for energy to momentum ratio"}, + CentBinning{"CentBinning", 10, "Binning for centrality"}, + CentEst{"CentEst", 1, "Centrality estimator, 0: FV0A, 1: FT0M, 2: FT0A, 3: FT0C, 4: FDDM, 5: NTPV"}; + + Configurable mColMaxZ{"mColMaxZ", 10.f, "maximum z accepted in analysis"}, + fEtaMax{"fEtaMax", {0.8f}, "eta ranges"}, + fEtaMaxPhos{"fEtaMaxPhos", {0.15f}, "eta ranges of phos"}, + fPtMin{"fPtMin", {0.2f}, "pt min"}, + fPtMax{"fPtMax", {20.f}, "pt max"}, + fMassSpectraMin{"fMassSpectraMin", {2.5f}, "mass spectra min for e+e-"}, + fMassSpectraMax{"fMassSpectraMax", {3.5f}, "mass spcetra max for e+e-"}, + fDCAxyMax{"fDCAxyMax", {3.f}, "dcaxy max"}, + fDCAzMax{"fDCAzMax", {3.f}, "dcaz max"}, + fITSchi2Max{"fITSchi2Max", {5.f}, "its chi2 max"}, + fITSnclsMin{"fITSnclsMin", {4.5f}, "min number of ITS clusters"}, + fITSnclsMax{"fITSnclsMax", {7.5f}, "max number of ITS clusters"}, + fTPCchi2Max{"fTPCchi2Max", {4.f}, "tpc chi2 max"}, + fTPCnclsMin{"fTPCnclsMin", {90.f}, "min number of TPC clusters"}, + fTPCnclsMax{"fTPCnclsMax", {170.f}, "max number of TPC clusters"}, + fTPCnclsCRMin{"fTPCnclsCRMin", {80.f}, "min number of TPC crossed rows"}, + fTPCnclsCRMax{"fTPCnclsCRMax", {161.f}, "max number of TPC crossed rows"}, + fTPCNSigmaElMin{"fTPCNSigmaElMin", {-3.f}, "min TPC nsigma e for inclusion"}, + fTPCNSigmaElMax{"fTPCNSigmaElMax", {2.f}, "max TPC nsigma e for inclusion"}, + fTPCNSigmaPiMin{"fTPCNSigmaPiMin", {-3.f}, "min TPC nsigma pion for exclusion"}, + fTPCNSigmaPiMax{"fTPCNSigmaPiMax", {3.5f}, "max TPC nsigma pion for exclusion"}, + fTPCNSigmaPrMin{"fTPCNSigmaPrMin", {-3.f}, "min TPC nsigma proton for exclusion"}, + fTPCNSigmaPrMax{"fTPCNSigmaPrMax", {4.f}, "max TPC nsigma proton for exclusion"}, + fTPCNSigmaKaMin{"fTPCNSigmaKaMin", {-3.f}, "min TPC nsigma kaon for exclusion"}, + fTPCNSigmaKaMax{"fTPCNSigmaKaMax", {4.f}, "max TPC nsigma kaon for exclusion"}, + fTOFNSigmaElMin{"fTOFNSigmaElMin", {-3.f}, "min TOF nsigma e for inclusion"}, + fTOFNSigmaElMax{"fTOFNSigmaElMax", {3.f}, "max TOF nsigma e for inclusion"}, + fShiftEp{"fShiftEp", {0.055f}, "PHOS E/p shift for electrons"}, + fNsigmaEp{"fNsigmaEp", {2.f}, "PHOS E/p nsigma for inclusion"}; + + Configurable> fEpSigmaPars{"fEpSigmaPars", {1.3e-02, 1.9e-02, 1.1e-02, 3.e-02}, "E/p sigma function parameters (from alice 3 mc tests + const)"}; Service ccdb; std::unique_ptr geomPHOS; @@ -615,42 +696,41 @@ struct MassSpectra { std::vector momentumBinning = {0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 10.}; - - const AxisSpec axisCounter{1, 0, +1, ""}, + const AxisSpec axisCounter{3, 0, +3, ""}, + axisCent{CentBinning, 0, 100, "centrality percentage"}, axisPt{momentumBinning, "p_{T} (GeV/c)"}, - axisEp{200, 0., 2., "E/p", "E_{cluster}/p_{track}"}, - axisE{200, 0, 10, "E (GeV)", "E (GeV)"}, - axisMassSpectrum{4000, 0, 4, "M (GeV/c^{2})", "Mass e^{+}e^{-} (GeV/c^{2})"}; + axisEp{EpRatioBinning, 0., 2., "E/p", "E_{cluster}/p_{track}"}, + axisE{EnergyBinning, 0, 10, "E (GeV)", "E (GeV)"}, + axisMassSpectrum{MassBinning, fMassSpectraMin, fMassSpectraMax, "M (GeV/c^{2})", "Mass e^{+}e^{-} (GeV/c^{2})"}; mHistManager.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); - mHistManager.add("TVXinPHOSCounter", "TVXinPHOSCounter", kTH1F, {axisCounter}); - mHistManager.add("h_eh_pp_mass_spectra_v_Pt", "Mass e^{+}h^{+} vs momentum e^{+}h^{+}", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_ee_pp_mass_spectra_v_Pt", "Mass e^{+}e^{+} vs momentum e^{+}e^{+}", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_eh_mm_mass_spectra_v_Pt", "Mass e^{-}h^{-} vs momentum e^{-}h^{-}", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_ee_mm_mass_spectra_v_Pt", "Mass e^{-}e^{-} vs momentum e^{-}e^{-}", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("h_eh_pp_mass_spectra_v_pt_v_cent", "Mass e^{+}h^{+} vs momentum e^{+}h^{+}", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("h_ee_pp_mass_spectra_v_pt_v_cent", "Mass e^{+}e^{+} vs momentum e^{+}e^{+}", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("h_eh_mm_mass_spectra_v_pt_v_cent", "Mass e^{-}h^{-} vs momentum e^{-}h^{-}", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("h_ee_mm_mass_spectra_v_pt_v_cent", "Mass e^{-}e^{-} vs momentum e^{-}e^{-}", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); - mHistManager.add("h_eh_pp_mass_spectra_v_E", "Mass e^{+}h^{+} vs cluster E e^{+}h^{+}", HistType::kTH2F, {axisMassSpectrum, axisE}); - mHistManager.add("h_ee_pp_mass_spectra_v_E", "Mass e^{+}e^{+} vs cluster E e^{+}e^{+}", HistType::kTH2F, {axisMassSpectrum, axisE}); - mHistManager.add("h_eh_mm_mass_spectra_v_E", "Mass e^{-}h^{-} vs cluster E e^{-}h^{-}", HistType::kTH2F, {axisMassSpectrum, axisE}); - mHistManager.add("h_ee_mm_mass_spectra_v_E", "Mass e^{-}e^{-} vs cluster E e^{-}e^{-}", HistType::kTH2F, {axisMassSpectrum, axisE}); + mHistManager.add("h_eh_pp_mass_spectra_v_E_v_cent", "Mass e^{+}h^{+} vs cluster E e^{+}h^{+}", HistType::kTH3F, {axisMassSpectrum, axisE, axisCent}); + mHistManager.add("h_ee_pp_mass_spectra_v_E_v_cent", "Mass e^{+}e^{+} vs cluster E e^{+}e^{+}", HistType::kTH3F, {axisMassSpectrum, axisE, axisCent}); + mHistManager.add("h_eh_mm_mass_spectra_v_E_v_cent", "Mass e^{-}h^{-} vs cluster E e^{-}h^{-}", HistType::kTH3F, {axisMassSpectrum, axisE, axisCent}); + mHistManager.add("h_ee_mm_mass_spectra_v_E_v_cent", "Mass e^{-}e^{-} vs cluster E e^{-}e^{-}", HistType::kTH3F, {axisMassSpectrum, axisE, axisCent}); - mHistManager.add("h_eh_mp_mass_spectra_v_Pt", "Mass e^{#pm}h^{#mp} vs momentum e^{#pm}h^{#mp}", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_ee_mp_mass_spectra_v_Pt", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp}", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_eh_mp_mass_spectra_v_E", "Mass e^{#pm}h^{#mp} vs cluster E e^{#pm}h^{#mp}", HistType::kTH2F, {axisMassSpectrum, axisE}); - mHistManager.add("h_ee_mp_mass_spectra_v_E", "Mass e^{#pm}e^{#mp} vs cluster E e^{#pm}e^{#mp}", HistType::kTH2F, {axisMassSpectrum, axisE}); + mHistManager.add("h_eh_mp_mass_spectra_v_pt_v_cent", "Mass e^{#pm}h^{#mp} vs momentum e^{#pm}h^{#mp}", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("h_ee_mp_mass_spectra_v_pt_v_cent", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp}", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("h_eh_mp_mass_spectra_v_E_v_cent", "Mass e^{#pm}h^{#mp} vs cluster E e^{#pm}h^{#mp}", HistType::kTH3F, {axisMassSpectrum, axisE, axisCent}); + mHistManager.add("h_ee_mp_mass_spectra_v_E_v_cent", "Mass e^{#pm}e^{#mp} vs cluster E e^{#pm}e^{#mp}", HistType::kTH3F, {axisMassSpectrum, axisE, axisCent}); - mHistManager.add("hEp_v_E", "E/p ratio vs cluster E", HistType::kTH2F, {axisEp, axisE}); - mHistManager.add("hEp_v_E_cutEp", "E/p ratio vs cluster E within nSigma corridor", HistType::kTH2F, {axisEp, axisE}); + mHistManager.add("hEp_v_E_v_cent", "E/p ratio vs cluster E", HistType::kTH3F, {axisEp, axisE, axisCent}); + mHistManager.add("hEp_v_E_v_cent_cutEp", "E/p ratio vs cluster E within nSigma corridor", HistType::kTH3F, {axisEp, axisE, axisCent}); geomPHOS = std::make_unique("PHOS"); - std::vector epSigmaPars = cfgEpSigmaPars; + std::vector epSigmaPars = fEpSigmaPars; fEpSigmaPhos = new TF1("fEpSigmaPhos", "sqrt([0]*[0]/x/x+[1]*[1]/x+[2]*[2])+[3]", 0.01, 10); fEpSigmaPhos->SetParameters(epSigmaPars.at(0), epSigmaPars.at(1), epSigmaPars.at(2), epSigmaPars.at(3)); } - void process(soa::Join::iterator const& collision, + void process(SelCollisions::iterator const& collision, aod::CaloClusters const& clusters, MyTracks const& tracks, o2::aod::PHOSMatchindexTable const& matches, @@ -668,46 +748,72 @@ struct MassSpectra { LOG(info) << ">>>>>>>>>>>> Magnetic field: " << bz; runNumber = bc.runNumber(); } - if (std::fabs(collision.posZ()) > 10.f) + if (std::fabs(collision.posZ()) > mColMaxZ) return; mHistManager.fill(HIST("eventCounter"), 0.5); if (!collision.alias_bit(mEvSelTrig)) return; - mHistManager.fill(HIST("TVXinPHOSCounter"), 0.5); + mHistManager.fill(HIST("eventCounter"), 1.5); + if (isSel8) { + if (!collision.sel8()) + return; + mHistManager.fill(HIST("eventCounter"), 2.5); + } if (clusters.size() == 0) return; // Nothing to process - for (auto const& TPCel : tracks) { + float cent = -1.; + switch (CentEst) { + case FV0A: + cent = collision.centFV0A(); + break; + case FT0M: + cent = collision.centFT0M(); + break; + case FT0A: + cent = collision.centFT0A(); + break; + case FT0C: + cent = collision.centFT0C(); + break; + case FDDM: + cent = collision.centFDDM(); + break; + case NTPV: + cent = collision.centNTPV(); + break; + } - if (!TPCel.has_collision() || std::fabs(TPCel.dcaXY()) > cfgDCAxyMax || std::fabs(TPCel.dcaZ()) > cfgDCAzMax || !TPCel.hasTPC() || std::fabs(TPCel.eta()) > 0.15) + for (auto const& TPCel : tracks) { + if (!TPCel.has_collision() || std::fabs(TPCel.dcaXY()) > fDCAxyMax || std::fabs(TPCel.dcaZ()) > fDCAzMax || !TPCel.hasTPC() || std::fabs(TPCel.eta()) > fEtaMaxPhos) continue; - if (TPCel.pt() < cfgPtMin || TPCel.pt() > cfgPtMax) + if (TPCel.pt() < fPtMin || TPCel.pt() > fPtMax) continue; - if (TPCel.itsChi2NCl() > cfgITSchi2Max) + if (TPCel.itsChi2NCl() > fITSchi2Max) continue; - if (TPCel.itsNCls() < cfgITSnclsMin || TPCel.itsNCls() > cfgITSnclsMax || !((TPCel.itsClusterMap() & uint8_t(1)) > 0)) + if (TPCel.itsNCls() < fITSnclsMin || TPCel.itsNCls() > fITSnclsMax || !((TPCel.itsClusterMap() & uint8_t(1)) > 0)) continue; - if (TPCel.tpcChi2NCl() > cfgTPCchi2Max) + if (TPCel.tpcChi2NCl() > fTPCchi2Max) continue; - if (TPCel.tpcNClsFound() < cfgTPCnclsMin || TPCel.tpcNClsFound() > cfgTPCnclsMax) + if (TPCel.tpcNClsFound() < fTPCnclsMin || TPCel.tpcNClsFound() > fTPCnclsMax) continue; - if (TPCel.tpcNClsCrossedRows() < cfgTPCnclsCRMin || TPCel.tpcNClsCrossedRows() > cfgTPCnclsCRMax) + if (TPCel.tpcNClsCrossedRows() < fTPCnclsCRMin || TPCel.tpcNClsCrossedRows() > fTPCnclsCRMax) continue; bool isElectron = false; float nsigmaTPCEl = TPCel.tpcNSigmaEl(); float nsigmaTOFEl = TPCel.tofNSigmaEl(); - bool isTPCElectron = nsigmaTPCEl > cfgTPCNSigmaElMin && nsigmaTPCEl < cfgTPCNSigmaElMax; - bool isTOFElectron = nsigmaTOFEl > cfgTOFNSigmaElMin && nsigmaTOFEl < cfgTOFNSigmaElMax; + bool isTPCElectron = nsigmaTPCEl > fTPCNSigmaElMin && nsigmaTPCEl < fTPCNSigmaElMax; + bool isTOFElectron = nsigmaTOFEl > fTOFNSigmaElMin && nsigmaTOFEl < fTOFNSigmaElMax; isElectron = isTPCElectron || isTOFElectron; float nsigmaTPCPi = TPCel.tpcNSigmaPi(); float nsigmaTPCKa = TPCel.tpcNSigmaKa(); float nsigmaTPCPr = TPCel.tpcNSigmaPr(); - bool isPion = nsigmaTPCPi > cfgTPCNSigmaPiMin && nsigmaTPCPi < cfgTPCNSigmaPiMax; - bool isKaon = nsigmaTPCKa > cfgTPCNSigmaKaMin && nsigmaTPCKa < cfgTPCNSigmaKaMax; - bool isProton = nsigmaTPCPr > cfgTPCNSigmaPrMin && nsigmaTPCPr < cfgTPCNSigmaPrMax; + bool isPion = nsigmaTPCPi > fTPCNSigmaPiMin && nsigmaTPCPi < fTPCNSigmaPiMax; + bool isKaon = nsigmaTPCKa > fTPCNSigmaKaMin && nsigmaTPCKa < fTPCNSigmaKaMax; + bool isProton = nsigmaTPCPr > fTPCNSigmaPrMin && nsigmaTPCPr < fTPCNSigmaPrMax; if (isElectron && !(isPion || isKaon || isProton)) isElectron = true; if (!isElectron) @@ -723,36 +829,35 @@ struct MassSpectra { if (TPCel.index() >= track2.index()) break; - float mass2Tracks = 0, mom2Tracks = 0, cluE = clust2.e(); - TLorentzVector fourVectorP1, fourVectorP2; + float mass2Tracks = 0, momProbeTrack = track2.pt(), cluE = clust2.e(); + ROOT::Math::LorentzVector> fourVectorP1, fourVectorP2; fourVectorP1.SetPxPyPzE(TPCel.px(), TPCel.py(), TPCel.pz(), TPCel.energy(0)); fourVectorP2.SetPxPyPzE(track2.px(), track2.py(), track2.pz(), track2.energy(0)); - mom2Tracks = (fourVectorP1 + fourVectorP2).Pt(); mass2Tracks = (fourVectorP1 + fourVectorP2).M(); - bool elCandidate = (std::fabs(cluE / track2.p() - cfgShiftEp - 1) < cfgNsigmaEp * fEpSigmaPhos->Eval(cluE)); + bool elCandidate = (std::fabs(cluE / track2.p() - fShiftEp - 1) < fNsigmaEp * fEpSigmaPhos->Eval(cluE)); if (TPCel.sign() == track2.sign()) { if (posTrack) { - mHistManager.fill(HIST("h_eh_pp_mass_spectra_v_Pt"), mass2Tracks, mom2Tracks); - mHistManager.fill(HIST("h_eh_pp_mass_spectra_v_E"), mass2Tracks, cluE); + mHistManager.fill(HIST("h_eh_pp_mass_spectra_v_pt_v_cent"), mass2Tracks, momProbeTrack, cent); + mHistManager.fill(HIST("h_eh_pp_mass_spectra_v_E_v_cent"), mass2Tracks, cluE, cent); if (elCandidate) { - mHistManager.fill(HIST("h_ee_pp_mass_spectra_v_Pt"), mass2Tracks, mom2Tracks); - mHistManager.fill(HIST("h_ee_pp_mass_spectra_v_E"), mass2Tracks, cluE); + mHistManager.fill(HIST("h_ee_pp_mass_spectra_v_pt_v_cent"), mass2Tracks, momProbeTrack, cent); + mHistManager.fill(HIST("h_ee_pp_mass_spectra_v_E_v_cent"), mass2Tracks, cluE, cent); } } else { - mHistManager.fill(HIST("h_eh_mm_mass_spectra_v_Pt"), mass2Tracks, mom2Tracks); - mHistManager.fill(HIST("h_eh_mm_mass_spectra_v_E"), mass2Tracks, cluE); + mHistManager.fill(HIST("h_eh_mm_mass_spectra_v_pt_v_cent"), mass2Tracks, momProbeTrack, cent); + mHistManager.fill(HIST("h_eh_mm_mass_spectra_v_E_v_cent"), mass2Tracks, cluE, cent); if (elCandidate) { - mHistManager.fill(HIST("h_ee_mm_mass_spectra_v_Pt"), mass2Tracks, mom2Tracks); - mHistManager.fill(HIST("h_ee_mm_mass_spectra_v_E"), mass2Tracks, cluE); + mHistManager.fill(HIST("h_ee_mm_mass_spectra_v_pt_v_cent"), mass2Tracks, momProbeTrack, cent); + mHistManager.fill(HIST("h_ee_mm_mass_spectra_v_E_v_cent"), mass2Tracks, cluE, cent); } } } else { - mHistManager.fill(HIST("h_eh_mp_mass_spectra_v_Pt"), mass2Tracks, mom2Tracks); - mHistManager.fill(HIST("h_eh_mp_mass_spectra_v_E"), mass2Tracks, cluE); + mHistManager.fill(HIST("h_eh_mp_mass_spectra_v_pt_v_cent"), mass2Tracks, momProbeTrack, cent); + mHistManager.fill(HIST("h_eh_mp_mass_spectra_v_E_v_cent"), mass2Tracks, cluE, cent); if (elCandidate) { - mHistManager.fill(HIST("h_ee_mp_mass_spectra_v_Pt"), mass2Tracks, mom2Tracks); - mHistManager.fill(HIST("h_ee_mp_mass_spectra_v_E"), mass2Tracks, cluE); + mHistManager.fill(HIST("h_ee_mp_mass_spectra_v_pt_v_cent"), mass2Tracks, momProbeTrack, cent); + mHistManager.fill(HIST("h_ee_mp_mass_spectra_v_E_v_cent"), mass2Tracks, cluE, cent); } } } @@ -763,57 +868,78 @@ struct MassSpectra { auto track = tracks.iteratorAt(match.trackId()); float cluE = clust.e(); float epRatio = cluE / track.p(); - mHistManager.fill(HIST("hEp_v_E"), epRatio, cluE); - bool elCandidate = (std::fabs(epRatio - cfgShiftEp - 1) < cfgNsigmaEp * fEpSigmaPhos->Eval(cluE)); + mHistManager.fill(HIST("hEp_v_E_v_cent"), epRatio, cluE, cent); + bool elCandidate = (std::fabs(epRatio - fShiftEp - 1) < fNsigmaEp * fEpSigmaPhos->Eval(cluE)); if (elCandidate) - mHistManager.fill(HIST("hEp_v_E_cutEp"), epRatio, cluE); + mHistManager.fill(HIST("hEp_v_E_v_cent_cutEp"), epRatio, cluE, cent); } } }; struct TpcElIdMassSpectrum { - using SelCollisions = soa::Join; - using MyTracks = soa::Join; - - Configurable cfgEtaMax{"cfgEtaMax", {0.8f}, "eta ranges"}; - Configurable cfgPtMin{"cfgPtMin", {0.2f}, "pt min"}; - Configurable cfgPtMax{"cfgPtMax", {20.f}, "pt max"}; - Configurable cfgDCAxyMax{"cfgDCAxyMax", {3.f}, "dcaxy max"}; - Configurable cfgDCAzMax{"cfgDCAzMax", {3.f}, "dcaz max"}; - Configurable cfgITSchi2Max{"cfgITSchi2Max", {5.f}, "its chi2 max"}; - Configurable cfgITSnclsMin{"cfgITSnclsMin", {4.5f}, "min number of ITS clusters"}; - Configurable cfgITSnclsMax{"cfgITSnclsMax", {7.5f}, "max number of ITS clusters"}; - Configurable cfgTPCchi2Max{"cfgTPCchi2Max", {4.f}, "tpc chi2 max"}; - Configurable cfgTPCnclsMin{"cfgTPCnclsMin", {90.f}, "min number of TPC clusters"}; - Configurable cfgTPCnclsMax{"cfgTPCnclsMax", {170.f}, "max number of TPC clusters"}; - Configurable cfgTPCnclsCRMin{"cfgTPCnclsCRMin", {80.f}, "min number of TPC crossed rows"}; - Configurable cfgTPCnclsCRMax{"cfgTPCnclsCRMax", {161.f}, "max number of TPC crossed rows"}; - Configurable cfgTPCNSigmaElMin{"cfgTPCNSigmaElMin", {-3.f}, "min TPC nsigma e for inclusion"}; - Configurable cfgTPCNSigmaElMax{"cfgTPCNSigmaElMax", {2.f}, "max TPC nsigma e for inclusion"}; - Configurable cfgTPCNSigmaPiMin{"cfgTPCNSigmaPiMin", {-3.f}, "min TPC nsigma pion for exclusion"}; - Configurable cfgTPCNSigmaPiMax{"cfgTPCNSigmaPiMax", {3.5f}, "max TPC nsigma pion for exclusion"}; - Configurable cfgTPCNSigmaPrMin{"cfgTPCNSigmaPrMin", {-3.f}, "min TPC nsigma proton for exclusion"}; - Configurable cfgTPCNSigmaPrMax{"cfgTPCNSigmaPrMax", {4.f}, "max TPC nsigma proton for exclusion"}; - Configurable cfgTPCNSigmaKaMin{"cfgTPCNSigmaKaMin", {-3.f}, "min TPC nsigma kaon for exclusion"}; - Configurable cfgTPCNSigmaKaMax{"cfgTPCNSigmaKaMax", {4.f}, "max TPC nsigma kaon for exclusion"}; - Configurable cfgTOFNSigmaElMin{"cfgTOFNSigmaElMin", {-3.f}, "min TOF nsigma e for inclusion"}; - Configurable cfgTOFNSigmaElMax{"cfgTOFNSigmaElMax", {3.f}, "max TOF nsigma e for inclusion"}; - - Configurable cfgJpsiMass{"cfgJpsiMass", {3.097f}, "eta ranges"}; - - Filter ptFilter = (aod::track::pt > cfgPtMin) && (aod::track::pt < cfgPtMax); - Filter etafilter = nabs(aod::track::eta) < cfgEtaMax; - Filter dcaxyfilter = nabs(aod::track::dcaXY) < cfgDCAxyMax; - Filter dcazfilter = nabs(aod::track::dcaZ) < cfgDCAzMax; - - Filter tpcEl = ((aod::pidtpc::tpcNSigmaEl > cfgTPCNSigmaElMin) && (aod::pidtpc::tpcNSigmaEl < cfgTPCNSigmaElMax)) || ((aod::pidtof::tofNSigmaEl > cfgTOFNSigmaElMin) && (aod::pidtof::tofNSigmaEl < cfgTOFNSigmaElMax)); - Filter tpcPiRej = (aod::pidtpc::tpcNSigmaPi < cfgTPCNSigmaPiMin) || (aod::pidtpc::tpcNSigmaPi > cfgTPCNSigmaPiMax); - Filter tpcKaRej = (aod::pidtpc::tpcNSigmaKa < cfgTPCNSigmaKaMin) || (aod::pidtpc::tpcNSigmaKa > cfgTPCNSigmaPrMax); - Filter tpcPrRej = (aod::pidtpc::tpcNSigmaPr < cfgTPCNSigmaPrMin) || (aod::pidtpc::tpcNSigmaPr > cfgTPCNSigmaPrMax); + using SelCollisions = soa::Join; + using MyTracks = soa::Join; + Configurable isSel8{"isSel8", 1, "check if event is Single Event Latch-up 8"}, + mSwapM20M02ForTestLambda{"mSwapM20M02ForTestLambda", false, "Swap m20 and m02 arguments for testLambda (false for note's correct order, true for swapped/original incorrect order)"}, + mUseNegativeCrossTerm{"mUseNegativeCrossTerm", true, "Use negative sign for the cross-term in testLambda (true for analysis note version, false for old version)"}; + + Configurable mColMaxZ{"mColMaxZ", 10.f, "maximum z accepted in analysis"}, + mMinCluE{"mMinCluE", 0.1, "Minimum cluster energy for photons in the analysis"}, + mCutMIPCluE{"mCutMIPCluE", 0.3, "Min cluster energy to reject MIPs in the analysis"}, + mMaxCluE{"mMaxCluE", 1., "Maximum cluster energy for photons in the analysis"}, + mMinCluTime{"minCluTime", -25.e-9, "Min. cluster time"}, + mMaxCluTime{"mMaxCluTime", 25.e-9, "Max. cluster time"}, + EtaMax{"EtaMax", {0.8f}, "eta ranges"}, + PtMin{"PtMin", {0.2f}, "pt min"}, + PtMax{"PtMax", {20.f}, "pt max"}, + MassSpectraJpsiMin{"MassSpectraJpsiMin", {0.5f}, "mass spectra min for Jpsi region"}, + MassSpectraJpsiMax{"MassSpectraJpsiMax", {3.5f}, "mass spcetra max for Jpsi region"}, + MassSpectraChicMin{"MassSpectraChicMin", {3.f}, "mass spectra min Chic region"}, + MassSpectraChicMax{"MassSpectraChicMax", {4.f}, "mass spcetra max Chic region"}, + DCAxyMax{"DCAxyMax", {3.f}, "dcaxy max"}, + DCAzMax{"DCAzMax", {3.f}, "dcaz max"}, + ITSchi2Max{"ITSchi2Max", {5.f}, "its chi2 max"}, + ITSnclsMin{"ITSnclsMin", {4.5f}, "min number of ITS clusters"}, + ITSnclsMax{"ITSnclsMax", {7.5f}, "max number of ITS clusters"}, + TPCchi2Max{"TPCchi2Max", {4.f}, "tpc chi2 max"}, + TPCnclsMin{"TPCnclsMin", {90.f}, "min number of TPC clusters"}, + TPCnclsMax{"TPCnclsMax", {170.f}, "max number of TPC clusters"}, + TPCnclsCRMin{"TPCnclsCRMin", {80.f}, "min number of TPC crossed rows"}, + TPCnclsCRMax{"TPCnclsCRMax", {161.f}, "max number of TPC crossed rows"}, + TPCNSigmaElMin{"TPCNSigmaElMin", {-3.f}, "min TPC nsigma e for inclusion"}, + TPCNSigmaElMax{"TPCNSigmaElMax", {2.f}, "max TPC nsigma e for inclusion"}, + TPCNSigmaPiMin{"TPCNSigmaPiMin", {-3.f}, "min TPC nsigma pion for exclusion"}, + TPCNSigmaPiMax{"TPCNSigmaPiMax", {3.5f}, "max TPC nsigma pion for exclusion"}, + TPCNSigmaPrMin{"TPCNSigmaPrMin", {-3.f}, "min TPC nsigma proton for exclusion"}, + TPCNSigmaPrMax{"TPCNSigmaPrMax", {4.f}, "max TPC nsigma proton for exclusion"}, + TPCNSigmaKaMin{"TPCNSigmaKaMin", {-3.f}, "min TPC nsigma kaon for exclusion"}, + TPCNSigmaKaMax{"TPCNSigmaKaMax", {4.f}, "max TPC nsigma kaon for exclusion"}, + TOFNSigmaElMin{"TOFNSigmaElMin", {-3.f}, "min TOF nsigma e for inclusion"}, + TOFNSigmaElMax{"TOFNSigmaElMax", {3.f}, "max TOF nsigma e for inclusion"}, + PhosRangeEta{"PhosRangeEta", {0.12f}, "Phos range definition plus minus eta"}, + PhosRangePhiMin{"PhosRangePhiMin", {230.f}, "Phos range angle phi min"}, + PhosRangePhiMax{"PhosRangePhiMax", {330.f}, "Phos range angle phi max"}, + eeMassMin{"eeMassMin", {2.9f}, "J/psi(e+e-) Mass corridor lower limit (for Chic selection)"}, + eeMassMax{"eeMassMax", {3.3f}, "J/psi(e+e-) Mass corridor upper limit (for Chic selection)"}, + JpsiMass{"JpsiMass", {3.097f}, "J/psi Mass constant"}, + mMassSpectrumLowerCutoff{"mMassSpectrumLowerCutoff", {0.01f}, "Used to exclude 0+0 masses"}, + mShowerShapeCutValue{"mShowerShapeCutValue", 4.f, "Cut threshold for testLambda shower shape"}; + + Configurable mEvSelTrig{"mEvSelTrig", kTVXinPHOS, "Select events with this trigger"}, + CentBinning{"CentBinning", 10, "Binning for centrality"}, + CentEst{"CentEst", 1, "Centrality estimator, 0: FV0A, 1: FT0M, 2: FT0A, 3: FT0C, 4: FDDM, 5: NTPV"}, + MassBinning{"MassBinning", 1000, "Binning for mass"}, + EnergyBinning{"EnergyBinning", 100, "Binning for energy"}, + mMinCluNcell{"minCluNcell", 3, "min cells in cluster"}; Service ccdb; - double bz{0.}; // magnetic field + double bz{0.}; int runNumber{0}; HistogramRegistry mHistManager{"tpcElIdHistograms"}; @@ -825,38 +951,72 @@ struct TpcElIdMassSpectrum { std::vector momentumBinning = {0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 10.}; - const AxisSpec axisCounter{1, 0, +1, ""}, + const AxisSpec axisCounter{3, 0, +3, ""}, + axisCent{CentBinning, 0, 100, "centrality percentage"}, axisVTrackX{400, -5., 5., "track vertex x (cm)", "track vertex x (cm)"}, axisVTrackY{400, -5., 5., "track vertex y (cm)", "track vertex y (cm)"}, axisVTrackZ{400, -20., 20., "track vertex z (cm)", "track vertex z (cm)"}, - axisE{200, 0, 10, "E (GeV)", "E (GeV)"}, - axisMassSpectrum{4000, 0, 4, "M (GeV/c^{2})", "Mass e^{+}e^{-} (GeV/c^{2})"}, - axisMassSpectrumChiC{4000, 0, 4, "M (GeV/c^{2})", "Mass e^{+}e^{-}#gamma (GeV/c^{2})"}, - axisMassSpectrumChiCNoJpsiErrors{4000, 0, 4, "M (GeV/c^{2})", "Mass e^{+}e^{-}#gamma - Mass e^{+}e^{-} + Mass J/#psi (GeV/c^{2})"}, + axisE{EnergyBinning, 0, 10, "E (GeV)", "E (GeV)"}, + axisMassSpectrum{MassBinning, MassSpectraJpsiMin, MassSpectraJpsiMax, "M (GeV/c^{2})", "Mass e^{+}e^{-} (GeV/c^{2})"}, + axisMassSpectrumChiC{MassBinning, MassSpectraChicMin, MassSpectraChicMax, "M (GeV/c^{2})", "Mass e^{+}e^{-}#gamma (GeV/c^{2})"}, + axisMassSpectrumChiCNoJpsiErrors{MassBinning, MassSpectraChicMin, MassSpectraChicMax, "M (GeV/c^{2})", "Mass e^{+}e^{-}#gamma - Mass e^{+}e^{-} + Mass J/#psi (GeV/c^{2})"}, + axisMassSpectrumgammagamma{MassBinning, 0, 0.3, "M (GeV/c^{2})", "Mass #gamma#gamma (GeV/c^{2})"}, axisTPC{1000, 0, 200, "TPC signal (dE/dx)"}, axisPt{momentumBinning, "p_{T} (GeV/c)"}, + axisPtProbe{momentumBinning, "Probe p_{T} (GeV/c)"}, axisPtBig{2000, 0, 20, "p_{T} (GeV/c)"}, axisEta{600, -3., 3., "#eta"}; mHistManager.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); + mHistManager.add("centCounter", "centCounter", kTH1F, {axisCent}); + mHistManager.add("hTPCspectra", "TPC dE/dx spectra", HistType::kTH2F, {axisPt, axisTPC}); mHistManager.add("hTPCspectra_isElectronRej", "isElectron with rejection | TPC dE/dx spectra", HistType::kTH2F, {axisPt, axisTPC}); - mHistManager.add("h_TPCee_MS_mp_v_pt", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates)", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_TPCee_MS_mm_v_pt", "Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates)", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_TPCee_MS_pp_v_pt", "Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates)", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("TPCee/h_MS_mp_v_pt_v_cent", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates)", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("TPCee/h_MS_mm_v_pt_v_cent", "Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates)", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("TPCee/h_MS_pp_v_pt_v_cent", "Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates)", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + + mHistManager.add("TPCee/h_MS_mp_kTVXinPHOS_v_pt_v_cent", "TVXinPHOS | Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates)", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("TPCee/h_MS_mm_kTVXinPHOS_v_pt_v_cent", "TVXinPHOS | Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates)", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("TPCee/h_MS_pp_kTVXinPHOS_v_pt_v_cent", "TVXinPHOS | Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates)", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + + mHistManager.add("TPCee/h_MS_mp_phosRange_v_pt_v_cent", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates) with one e in phos acceptance range", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("TPCee/h_MS_mm_phosRange_v_pt_v_cent", "Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates) with one e in phos acceptance range", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("TPCee/h_MS_pp_phosRange_v_pt_v_cent", "Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates) with one e in phos acceptance range", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + + mHistManager.add("TPCee/h_MS_mp_phosRange_kTVXinPHOS_v_pt_v_cent", "TVXinPHOS | Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates) with one e in phos acceptance range", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("TPCee/h_MS_mm_phosRange_kTVXinPHOS_v_pt_v_cent", "TVXinPHOS | Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates) with one e in phos acceptance range", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + mHistManager.add("TPCee/h_MS_pp_phosRange_kTVXinPHOS_v_pt_v_cent", "TVXinPHOS | Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates) with one e in phos acceptance range", HistType::kTH3F, {axisMassSpectrum, axisPt, axisCent}); + + mHistManager.add("TPCeePhosGamma/h_MS_noMatches_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma vs momentum e^{#pm}e^{#mp}#gamma", HistType::kTH3F, {axisMassSpectrumChiC, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_MS_noMatches_aroundJpsi_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma (around J/#psi) vs momentum e^{#pm}e^{#mp}#gamma", HistType::kTH3F, {axisMassSpectrumChiC, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_MS_noMatches_aroundJpsi_DispOK_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma (around J/#psi) vs momentum e^{#pm}e^{#mp}#gamma | DispOK", HistType::kTH3F, {axisMassSpectrumChiC, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_MS_noMatches_DispOK_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma vs momentum e^{#pm}e^{#mp}#gamma | DispOK", HistType::kTH3F, {axisMassSpectrumChiC, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_MS_aroundJpsi_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma (around J/#psi) vs momentum e^{#pm}e^{#mp}#gamma", HistType::kTH3F, {axisMassSpectrumChiC, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_MS_DispOK_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma vs momentum e^{#pm}e^{#mp}#gamma | DispOK", HistType::kTH3F, {axisMassSpectrumChiC, axisPt, axisCent}); + + mHistManager.add("TPCeePhosGamma/h_MS_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma vs momentum e^{#pm}e^{#mp}#gamma (TPC candidates + Phos cluster)", HistType::kTH3F, {axisMassSpectrumChiC, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_MS_v_cluE_v_cent", "Mass e^{#pm}e^{#mp}#gamma vs cluster Energy left by the photon", HistType::kTH3F, {axisMassSpectrumChiC, axisE, axisCent}); - mHistManager.add("h_TPCeePhosGamma_MS_v_3pt", "Mass e^{#pm}e^{#mp}#gamma vs momentum e^{#pm}e^{#mp}#gamma (TPC candidates + Phos photon)", HistType::kTH2F, {axisMassSpectrumChiC, axisPt}); - mHistManager.add("h_TPCeePhosGamma_minusee_MS_v_3pt", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} + Mass J/#psi vs momentum e^{#pm}e^{#mp}#gamma (TPC candidates + Phos photon)", HistType::kTH2F, {axisMassSpectrumChiCNoJpsiErrors, axisPt}); - mHistManager.add("h_TPCeePhosGamma_MS_v_cluE", "Mass e^{#pm}e^{#mp}#gamma vs cluster Energy left by the photon", HistType::kTH2F, {axisMassSpectrumChiC, axisE}); - mHistManager.add("h_TPCeePhosGamma_minusee_MS_v_cluE", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} + Mass J/#psi vs cluster Energy left by the photon", HistType::kTH2F, {axisMassSpectrumChiCNoJpsiErrors, axisE}); + mHistManager.add("TPCeePhosGamma/h_minusee_MS_noMatches_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp}#gamma", HistType::kTH3F, {axisMassSpectrumChiCNoJpsiErrors, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_minusee_MS_noMatches_aroundJpsi_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} (around J/#psi) vs momentum e^{#pm}e^{#mp}#gamma", HistType::kTH3F, {axisMassSpectrumChiCNoJpsiErrors, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_minusee_MS_noMatches_aroundJpsi_DispOK_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} (around J/#psi) vs momentum e^{#pm}e^{#mp}#gamma | DispOK", HistType::kTH3F, {axisMassSpectrumChiCNoJpsiErrors, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_minusee_MS_noMatches_DispOK_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp}#gamma | DispOK", HistType::kTH3F, {axisMassSpectrumChiCNoJpsiErrors, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_minusee_MS_aroundJpsi_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} (around J/#psi) vs momentum e^{#pm}e^{#mp}#gamma", HistType::kTH3F, {axisMassSpectrumChiCNoJpsiErrors, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_minusee_MS_DispOK_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp}#gamma | DispOK", HistType::kTH3F, {axisMassSpectrumChiCNoJpsiErrors, axisPt, axisCent}); - mHistManager.add("h_TPCee_MS_mp_phosRange_v_pt", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates) with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_TPCee_MS_mm_phosRange_v_pt", "Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates) with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_TPCee_MS_pp_phosRange_v_pt", "Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates) with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("TPCeePhosGamma/h_minusee_MS_v_3pt_v_cent", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} - Mass e^{#pm}e^{#mp} + Mass J/#psi vs momentum e^{#pm}e^{#mp}#gamma (TPC candidates + Phos cluster)", HistType::kTH3F, {axisMassSpectrumChiCNoJpsiErrors, axisPt, axisCent}); + mHistManager.add("TPCeePhosGamma/h_minusee_MS_v_cluE_v_cent", "Mass e^{#pm}e^{#mp}#gamma - Mass e^{#pm}e^{#mp} - Mass e^{#pm}e^{#mp} + Mass J/#psi vs cluster Energy left by the photon", HistType::kTH3F, {axisMassSpectrumChiCNoJpsiErrors, axisE, axisCent}); - mHistManager.add("h_TPCee_MS_mp_phosRange_kTVXinPHOS_v_pt", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates) with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_TPCee_MS_mm_phosRange_kTVXinPHOS_v_pt", "Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates) with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); - mHistManager.add("h_TPCee_MS_pp_phosRange_kTVXinPHOS_v_pt", "Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates) with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("twoPhoton/MS_noCuts", "Mass vs Transverse Momentum for #gamma#gamma", HistType::kTH3F, {axisMassSpectrumgammagamma, axisPt, axisCent}); + mHistManager.add("twoPhoton/MS_noMatches", "Mass vs Transverse Momentum for #gamma#gamma excluding trackmatched clusters", HistType::kTH3F, {axisMassSpectrumgammagamma, axisPt, axisCent}); + + mHistManager.add("TPCeff/h_eh_pp_mass_spectra_v_pt_v_cent", "Mass e^{+}h^{+} vs momentum e^{+}h^{+}", HistType::kTH3F, {axisMassSpectrum, axisPtProbe, axisCent}); + mHistManager.add("TPCeff/h_ee_pp_mass_spectra_v_pt_v_cent", "Mass e^{+}e^{+} vs momentum e^{+}e^{+}", HistType::kTH3F, {axisMassSpectrum, axisPtProbe, axisCent}); + mHistManager.add("TPCeff/h_eh_mm_mass_spectra_v_pt_v_cent", "Mass e^{-}h^{-} vs momentum e^{-}h^{-}", HistType::kTH3F, {axisMassSpectrum, axisPtProbe, axisCent}); + mHistManager.add("TPCeff/h_ee_mm_mass_spectra_v_pt_v_cent", "Mass e^{-}e^{-} vs momentum e^{-}e^{-}", HistType::kTH3F, {axisMassSpectrum, axisPtProbe, axisCent}); + mHistManager.add("TPCeff/h_eh_mp_mass_spectra_v_pt_v_cent", "Mass e^{#pm}h^{#mp} vs momentum e^{#pm}h^{#mp}", HistType::kTH3F, {axisMassSpectrum, axisPtProbe, axisCent}); + mHistManager.add("TPCeff/h_ee_mp_mass_spectra_v_pt_v_cent", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp}", HistType::kTH3F, {axisMassSpectrum, axisPtProbe, axisCent}); mHistManager.add("hTrackVX", "Track vertex coordinate X", HistType::kTH1F, {axisVTrackX}); mHistManager.add("hTrackVY", "Track vertex coordinate Y", HistType::kTH1F, {axisVTrackY}); @@ -870,9 +1030,10 @@ struct TpcElIdMassSpectrum { mHistManager.add("hTrackEta", "Track eta", HistType::kTH1F, {axisEta}); mHistManager.add("hTrackEta_Cut", "Track eta after cut", HistType::kTH1F, {axisEta}); } - void process(soa::Join::iterator const& collision, + + void process(SelCollisions::iterator const& collision, aod::CaloClusters const& clusters, - soa::Filtered const& tracks, + MyTracks const& tracks, o2::aod::PHOSMatchindexTable const& matches, aod::BCsWithTimestamps const&) { @@ -888,123 +1049,391 @@ struct TpcElIdMassSpectrum { LOG(info) << ">>>>>>>>>>>> Magnetic field: " << bz; runNumber = bc.runNumber(); } - mHistManager.fill(HIST("eventCounter"), 0.5); - if (std::fabs(collision.posZ()) > 10.f) + if (std::fabs(collision.posZ()) > mColMaxZ) return; - for (auto const& [track1, track2] : combinations(CombinationsStrictlyUpperIndexPolicy(tracks, tracks))) { - if (!track1.has_collision() || !track1.hasTPC()) - continue; - if (!track2.has_collision() || !track2.hasTPC()) - continue; - if (track1.collisionId() != track2.collisionId()) - continue; - if (!((track1.itsClusterMap() & uint8_t(1)) > 0) || !((track2.itsClusterMap() & uint8_t(1)) > 0)) - continue; - if (track1.itsChi2NCl() > cfgITSchi2Max || track2.itsChi2NCl() > cfgITSchi2Max) - continue; - if (track1.tpcChi2NCl() > cfgTPCchi2Max || track2.tpcChi2NCl() > cfgTPCchi2Max) - continue; - if (track1.itsNCls() < cfgITSnclsMin || track2.itsNCls() < cfgITSnclsMin) - continue; - if (track1.itsNCls() > cfgITSnclsMax || track2.itsNCls() > cfgITSnclsMax) - continue; - if (track1.tpcNClsFound() < cfgTPCnclsMin || track2.tpcNClsFound() < cfgTPCnclsMin) - continue; - if (track1.tpcNClsFound() > cfgTPCnclsMax || track2.tpcNClsFound() > cfgTPCnclsMax) - continue; - if (track1.tpcNClsCrossedRows() < cfgTPCnclsCRMin || track2.tpcNClsCrossedRows() < cfgTPCnclsCRMin) - continue; - if (track1.tpcNClsCrossedRows() > cfgTPCnclsCRMax || track2.tpcNClsCrossedRows() > cfgTPCnclsCRMax) - continue; + float cent = -1.; + switch (CentEst) { + case FV0A: + cent = collision.centFV0A(); + break; + case FT0M: + cent = collision.centFT0M(); + break; + case FT0A: + cent = collision.centFT0A(); + break; + case FT0C: + cent = collision.centFT0C(); + break; + case FDDM: + cent = collision.centFDDM(); + break; + case NTPV: + cent = collision.centNTPV(); + break; + } + mHistManager.fill(HIST("eventCounter"), 0.5); + mHistManager.fill(HIST("centCounter"), cent); + if (collision.alias_bit(mEvSelTrig)) { + mHistManager.fill(HIST("eventCounter"), 1.5); + } + if (isSel8) { + if (!collision.sel8()) + return; + mHistManager.fill(HIST("eventCounter"), 2.5); + } - TLorentzVector fourVectorP1, fourVectorP2; - fourVectorP1.SetPxPyPzE(track1.px(), track1.py(), track1.pz(), track1.energy(0)); - fourVectorP2.SetPxPyPzE(track2.px(), track2.py(), track2.pz(), track2.energy(0)); + auto isGoodElectronForSignal = [&](const MyTracks::iterator& track) -> bool { + if (!track.has_collision() || !track.hasTPC()) + return false; + if (track.pt() <= PtMin || track.pt() >= PtMax) + return false; + if (std::fabs(track.eta()) >= EtaMax) + return false; + if (std::fabs(track.dcaXY()) >= DCAxyMax) + return false; + if (std::fabs(track.dcaZ()) >= DCAzMax) + return false; + if (track.itsChi2NCl() >= ITSchi2Max) + return false; + if (track.tpcChi2NCl() >= TPCchi2Max) + return false; + if (!((track.itsClusterMap() & uint8_t(1)) > 0)) + return false; + if (track.itsNCls() < ITSnclsMin || track.itsNCls() > ITSnclsMax) + return false; + if (track.tpcNClsFound() < TPCnclsMin || track.tpcNClsFound() > TPCnclsMax) + return false; + if (track.tpcNClsCrossedRows() < TPCnclsCRMin || track.tpcNClsCrossedRows() > TPCnclsCRMax) + return false; - bool inPhosEtaRange1 = std::fabs(track1.eta()) < 0.12; - bool inPhosEtaRange2 = std::fabs(track2.eta()) < 0.12; - bool inPhosPhiRange1 = (track1.phi() * TMath::RadToDeg() > 250 && track1.phi() * TMath::RadToDeg() < 320); - bool inPhosPhiRange2 = (track2.phi() * TMath::RadToDeg() > 250 && track2.phi() * TMath::RadToDeg() < 320); - bool inPhosRange = (inPhosEtaRange1 && inPhosPhiRange1) || (inPhosEtaRange2 && inPhosPhiRange2); - bool posTrack = track1.sign() * bz > 0; + bool isTPCElectron = (track.tpcNSigmaEl() > TPCNSigmaElMin) && (track.tpcNSigmaEl() < TPCNSigmaElMax); + bool isTOFElectron = (track.tofNSigmaEl() > TOFNSigmaElMin) && (track.tofNSigmaEl() < TOFNSigmaElMax); + if (!isTPCElectron && !isTOFElectron) + return false; - double pairMass = (fourVectorP1 + fourVectorP2).M(), pairPt = (fourVectorP1 + fourVectorP2).Pt(); + bool isPion = (track.tpcNSigmaPi() >= TPCNSigmaPiMin && track.tpcNSigmaPi() <= TPCNSigmaPiMax); + bool isKaon = (track.tpcNSigmaKa() >= TPCNSigmaKaMin && track.tpcNSigmaKa() <= TPCNSigmaKaMax); + bool isProton = (track.tpcNSigmaPr() >= TPCNSigmaPrMin && track.tpcNSigmaPr() <= TPCNSigmaPrMax); + if (isPion || isKaon || isProton) + return false; + return true; + }; - if (track1.sign() == track2.sign()) { - if (posTrack) { - mHistManager.fill(HIST("h_TPCee_MS_pp_v_pt"), pairMass, pairPt); - if (inPhosRange) { - mHistManager.fill(HIST("h_TPCee_MS_pp_phosRange_v_pt"), pairMass, pairPt); - if (collision.alias_bit(kTVXinPHOS)) - mHistManager.fill(HIST("h_TPCee_MS_pp_phosRange_kTVXinPHOS_v_pt"), pairMass, pairPt); + auto isGoodTagElectron = [&](const MyTracks::iterator& track) -> bool { + if (!track.has_collision() || !track.hasTPC()) + return false; + if (!((track.itsClusterMap() & uint8_t(1)) > 0)) + return false; + if (track.itsChi2NCl() > ITSchi2Max || track.tpcChi2NCl() > TPCchi2Max) + return false; + if (track.itsNCls() < ITSnclsMin || track.itsNCls() > ITSnclsMax) + return false; + if (track.tpcNClsFound() < TPCnclsMin || track.tpcNClsFound() > TPCnclsMax) + return false; + if (track.tpcNClsCrossedRows() < TPCnclsCRMin || track.tpcNClsCrossedRows() > TPCnclsCRMax) + return false; + if (std::fabs(track.eta()) >= EtaMax) + return false; + if (std::fabs(track.dcaXY()) >= DCAxyMax) + return false; + if (std::fabs(track.dcaZ()) >= DCAzMax) + return false; + + bool isTPCElectron = (track.tpcNSigmaEl() > TPCNSigmaElMin) && (track.tpcNSigmaEl() < TPCNSigmaElMax); + bool isTOFElectron = (track.tofNSigmaEl() > TOFNSigmaElMin) && (track.tofNSigmaEl() < TOFNSigmaElMax); + if (!isTPCElectron && !isTOFElectron) + return false; + + bool isPionSignal = (track.tpcNSigmaPi() >= TPCNSigmaPiMin && track.tpcNSigmaPi() <= TPCNSigmaPiMax); + bool isKaonSignal = (track.tpcNSigmaKa() >= TPCNSigmaKaMin && track.tpcNSigmaKa() <= TPCNSigmaKaMax); + bool isProtonSignal = (track.tpcNSigmaPr() >= TPCNSigmaPrMin && track.tpcNSigmaPr() <= TPCNSigmaPrMax); + if (isPionSignal || isKaonSignal || isProtonSignal) + return false; + return true; + }; + + auto isGoodProbeBaseTrack = [&](const MyTracks::iterator& track) -> bool { + if (!track.has_collision() || !track.hasTPC()) + return false; + if (!((track.itsClusterMap() & uint8_t(1)) > 0)) + return false; + if (track.itsChi2NCl() > ITSchi2Max || track.tpcChi2NCl() > TPCchi2Max) + return false; + if (track.itsNCls() < ITSnclsMin || track.itsNCls() > ITSnclsMax) + return false; + if (track.tpcNClsFound() < TPCnclsMin || track.tpcNClsFound() > TPCnclsMax) + return false; + if (track.tpcNClsCrossedRows() < TPCnclsCRMin || track.tpcNClsCrossedRows() > TPCnclsCRMax) + return false; + if (std::fabs(track.dcaXY()) > DCAxyMax || std::fabs(track.dcaZ()) > DCAzMax) + return false; + if (std::fabs(track.eta()) >= EtaMax) + return false; + return true; + }; + + auto isProbeIdentifiedAsElectron = [&](const MyTracks::iterator& track) -> bool { + if (!track.hasTPC()) + return false; + bool isTPCElectron = (track.tpcNSigmaEl() > TPCNSigmaElMin) && (track.tpcNSigmaEl() < TPCNSigmaElMax); + bool isTOFElectron = (track.tofNSigmaEl() > TOFNSigmaElMin) && (track.tofNSigmaEl() < TOFNSigmaElMax); + if (!isTPCElectron && !isTOFElectron) + return false; + + bool isPionSignal = (track.tpcNSigmaPi() >= TPCNSigmaPiMin && track.tpcNSigmaPi() <= TPCNSigmaPiMax); + bool isKaonSignal = (track.tpcNSigmaKa() >= TPCNSigmaKaMin && track.tpcNSigmaKa() <= TPCNSigmaKaMax); + bool isProtonSignal = (track.tpcNSigmaPr() >= TPCNSigmaPrMin && track.tpcNSigmaPr() <= TPCNSigmaPrMax); + if (isPionSignal || isKaonSignal || isProtonSignal) + return false; + return true; + }; + + for (auto const& [track1_iterator, track2_iterator] : combinations(CombinationsStrictlyUpperIndexPolicy(tracks, tracks))) { + if (track1_iterator.collisionId() != track2_iterator.collisionId()) { + continue; + } + + bool track1IsSignalE = isGoodElectronForSignal(track1_iterator); + bool track2IsSignalE = isGoodElectronForSignal(track2_iterator); + + if (track1IsSignalE && track2IsSignalE) { + ROOT::Math::LorentzVector> fourVectorP1, fourVectorP2; + fourVectorP1.SetPxPyPzE(track1_iterator.px(), track1_iterator.py(), track1_iterator.pz(), track1_iterator.energy(0)); + fourVectorP2.SetPxPyPzE(track2_iterator.px(), track2_iterator.py(), track2_iterator.pz(), track2_iterator.energy(0)); + + bool inPhosEtaRange1 = std::fabs(track1_iterator.eta()) < PhosRangeEta; + bool inPhosEtaRange2 = std::fabs(track2_iterator.eta()) < PhosRangeEta; + bool inPhosPhiRange1 = (track1_iterator.phi() * TMath::RadToDeg() > PhosRangePhiMin && track1_iterator.phi() * TMath::RadToDeg() < PhosRangePhiMax); + bool inPhosPhiRange2 = (track2_iterator.phi() * TMath::RadToDeg() > PhosRangePhiMin && track2_iterator.phi() * TMath::RadToDeg() < PhosRangePhiMax); + bool inPhosRange = (inPhosEtaRange1 && inPhosPhiRange1) || (inPhosEtaRange2 && inPhosPhiRange2); + + double pairMass = (fourVectorP1 + fourVectorP2).M(), pairPt = (fourVectorP1 + fourVectorP2).Pt(); + + if (track1_iterator.sign() == track2_iterator.sign()) { + bool track1IsPositive = track1_iterator.sign() * bz > 0; + if (track1IsPositive) { + mHistManager.fill(HIST("TPCee/h_MS_pp_v_pt_v_cent"), pairMass, pairPt, cent); + if (collision.alias_bit(mEvSelTrig)) + mHistManager.fill(HIST("TPCee/h_MS_pp_kTVXinPHOS_v_pt_v_cent"), pairMass, pairPt, cent); + if (inPhosRange) { + mHistManager.fill(HIST("TPCee/h_MS_pp_phosRange_v_pt_v_cent"), pairMass, pairPt, cent); + if (collision.alias_bit(mEvSelTrig)) + mHistManager.fill(HIST("TPCee/h_MS_pp_phosRange_kTVXinPHOS_v_pt_v_cent"), pairMass, pairPt, cent); + } + } else { + mHistManager.fill(HIST("TPCee/h_MS_mm_v_pt_v_cent"), pairMass, pairPt, cent); + if (collision.alias_bit(mEvSelTrig)) + mHistManager.fill(HIST("TPCee/h_MS_mm_kTVXinPHOS_v_pt_v_cent"), pairMass, pairPt, cent); + if (inPhosRange) { + mHistManager.fill(HIST("TPCee/h_MS_mm_phosRange_v_pt_v_cent"), pairMass, pairPt, cent); + if (collision.alias_bit(mEvSelTrig)) + mHistManager.fill(HIST("TPCee/h_MS_mm_phosRange_kTVXinPHOS_v_pt_v_cent"), pairMass, pairPt, cent); + } } } else { - mHistManager.fill(HIST("h_TPCee_MS_mm_v_pt"), pairMass, pairPt); + mHistManager.fill(HIST("TPCee/h_MS_mp_v_pt_v_cent"), pairMass, pairPt, cent); + if (collision.alias_bit(mEvSelTrig)) + mHistManager.fill(HIST("TPCee/h_MS_mp_kTVXinPHOS_v_pt_v_cent"), pairMass, pairPt, cent); if (inPhosRange) { - mHistManager.fill(HIST("h_TPCee_MS_mm_phosRange_v_pt"), pairMass, pairPt); - if (collision.alias_bit(kTVXinPHOS)) - mHistManager.fill(HIST("h_TPCee_MS_mm_phosRange_kTVXinPHOS_v_pt"), pairMass, pairPt); + mHistManager.fill(HIST("TPCee/h_MS_mp_phosRange_v_pt_v_cent"), pairMass, pairPt, cent); + if (collision.alias_bit(mEvSelTrig)) + mHistManager.fill(HIST("TPCee/h_MS_mp_phosRange_kTVXinPHOS_v_pt_v_cent"), pairMass, pairPt, cent); + } + + if (collision.alias_bit(mEvSelTrig) && clusters.size() != 0) { + for (auto const& gamma : clusters) { + float cluE = gamma.e(); + if (cluE < mMinCluE || cluE > mMaxCluE || gamma.ncell() < mMinCluNcell || gamma.time() > mMaxCluTime || gamma.time() < mMinCluTime) + continue; + bool matchFlag = false; + bool isJpsi = (pairMass > eeMassMin && pairMass < eeMassMax); + bool isDispOK = false; + if (mSwapM20M02ForTestLambda) + isDispOK = testLambda(cluE, gamma.m02(), gamma.m20(), mShowerShapeCutValue, mUseNegativeCrossTerm); + else + isDispOK = testLambda(cluE, gamma.m20(), gamma.m02(), mShowerShapeCutValue, mUseNegativeCrossTerm); + for (auto const& match : matches) { + if (gamma.index() == match.caloClusterId()) { + matchFlag = true; + break; + } + } + ROOT::Math::LorentzVector> fourVectorP3; + fourVectorP3.SetPxPyPzE(gamma.px(), gamma.py(), gamma.pz(), cluE); + double tripletMass = (fourVectorP1 + fourVectorP2 + fourVectorP3).M(); + double tripletPt = (fourVectorP1 + fourVectorP2 + fourVectorP3).Pt(); + double tripletMinusPairPlusJpsiMass = tripletMass - pairMass + JpsiMass; + + mHistManager.fill(HIST("TPCeePhosGamma/h_MS_v_3pt_v_cent"), tripletMass, tripletPt, cent); + mHistManager.fill(HIST("TPCeePhosGamma/h_minusee_MS_v_3pt_v_cent"), tripletMinusPairPlusJpsiMass, tripletPt, cent); + mHistManager.fill(HIST("TPCeePhosGamma/h_MS_v_cluE_v_cent"), tripletMass, cluE, cent); + mHistManager.fill(HIST("TPCeePhosGamma/h_minusee_MS_v_cluE_v_cent"), tripletMinusPairPlusJpsiMass, cluE, cent); + + if (!matchFlag) { + mHistManager.fill(HIST("TPCeePhosGamma/h_MS_noMatches_v_3pt_v_cent"), tripletMass, tripletPt, cent); + mHistManager.fill(HIST("TPCeePhosGamma/h_minusee_MS_noMatches_v_3pt_v_cent"), tripletMinusPairPlusJpsiMass, tripletPt, cent); + if (isJpsi) { + mHistManager.fill(HIST("TPCeePhosGamma/h_MS_noMatches_aroundJpsi_v_3pt_v_cent"), tripletMass, tripletPt, cent); + mHistManager.fill(HIST("TPCeePhosGamma/h_minusee_MS_noMatches_aroundJpsi_v_3pt_v_cent"), tripletMinusPairPlusJpsiMass, tripletPt, cent); + if (isDispOK) { + mHistManager.fill(HIST("TPCeePhosGamma/h_MS_noMatches_aroundJpsi_DispOK_v_3pt_v_cent"), tripletMass, tripletPt, cent); + mHistManager.fill(HIST("TPCeePhosGamma/h_minusee_MS_noMatches_aroundJpsi_DispOK_v_3pt_v_cent"), tripletMinusPairPlusJpsiMass, tripletPt, cent); + } + } + if (isDispOK) { + mHistManager.fill(HIST("TPCeePhosGamma/h_MS_noMatches_DispOK_v_3pt_v_cent"), tripletMass, tripletPt, cent); + mHistManager.fill(HIST("TPCeePhosGamma/h_minusee_MS_noMatches_DispOK_v_3pt_v_cent"), tripletMinusPairPlusJpsiMass, tripletPt, cent); + } + } + if (isJpsi) { + mHistManager.fill(HIST("TPCeePhosGamma/h_MS_aroundJpsi_v_3pt_v_cent"), tripletMass, tripletPt, cent); + mHistManager.fill(HIST("TPCeePhosGamma/h_minusee_MS_aroundJpsi_v_3pt_v_cent"), tripletMinusPairPlusJpsiMass, tripletPt, cent); + } + if (isDispOK) { + mHistManager.fill(HIST("TPCeePhosGamma/h_MS_DispOK_v_3pt_v_cent"), tripletMass, tripletPt, cent); + mHistManager.fill(HIST("TPCeePhosGamma/h_minusee_MS_DispOK_v_3pt_v_cent"), tripletMinusPairPlusJpsiMass, tripletPt, cent); + } + } } } - } else { - mHistManager.fill(HIST("h_TPCee_MS_mp_v_pt"), pairMass, pairPt); - if (inPhosRange) { - mHistManager.fill(HIST("h_TPCee_MS_mp_phosRange_v_pt"), pairMass, pairPt); - if (collision.alias_bit(kTVXinPHOS)) - mHistManager.fill(HIST("h_TPCee_MS_mp_phosRange_kTVXinPHOS_v_pt"), pairMass, pairPt); + } + + if (isGoodTagElectron(track1_iterator) && isGoodProbeBaseTrack(track2_iterator)) { + ROOT::Math::LorentzVector> pTag1, pProbe2; + pTag1.SetPxPyPzE(track1_iterator.px(), track1_iterator.py(), track1_iterator.pz(), track1_iterator.energy(0)); + pProbe2.SetPxPyPzE(track2_iterator.px(), track2_iterator.py(), track2_iterator.pz(), track2_iterator.energy(0)); + float massTag1Probe2 = (pTag1 + pProbe2).M(); + float ptProbe2 = track2_iterator.pt(); + bool tag1IsPositive = track1_iterator.sign() * bz > 0; + + if (track1_iterator.sign() == track2_iterator.sign()) { + if (tag1IsPositive) { + mHistManager.fill(HIST("TPCeff/h_eh_pp_mass_spectra_v_pt_v_cent"), massTag1Probe2, ptProbe2, cent); + } else { + mHistManager.fill(HIST("TPCeff/h_eh_mm_mass_spectra_v_pt_v_cent"), massTag1Probe2, ptProbe2, cent); + } + } else { + mHistManager.fill(HIST("TPCeff/h_eh_mp_mass_spectra_v_pt_v_cent"), massTag1Probe2, ptProbe2, cent); } - if (pairMass < 2.8 && pairMass > 3.3) - continue; - if (collision.alias_bit(kTVXinPHOS) && clusters.size() != 0) { - for (auto const& gamma : clusters) { - bool matchFlag = 0; - for (auto const& match : matches) { - if (gamma.index() == match.caloClusterId()) { - matchFlag = 1; - break; - } + if (isProbeIdentifiedAsElectron(track2_iterator)) { + if (track1_iterator.sign() == track2_iterator.sign()) { + if (tag1IsPositive) { + mHistManager.fill(HIST("TPCeff/h_ee_pp_mass_spectra_v_pt_v_cent"), massTag1Probe2, ptProbe2, cent); + } else { + mHistManager.fill(HIST("TPCeff/h_ee_mm_mass_spectra_v_pt_v_cent"), massTag1Probe2, ptProbe2, cent); } - if (matchFlag == 1) - continue; - TLorentzVector fourVectorP3; - fourVectorP3.SetPxPyPzE(gamma.px(), gamma.py(), gamma.pz(), gamma.e()); - double tripletMass = (fourVectorP1 + fourVectorP2 + fourVectorP3).M(), tripletPt = (fourVectorP1 + fourVectorP2 + fourVectorP3).Pt(); - - mHistManager.fill(HIST("h_TPCeePhosGamma_MS_v_3pt"), tripletMass, tripletPt); - mHistManager.fill(HIST("h_TPCeePhosGamma_minusee_MS_v_3pt"), tripletMass - pairMass + cfgJpsiMass, tripletPt); - mHistManager.fill(HIST("h_TPCeePhosGamma_MS_v_cluE"), tripletMass, gamma.e()); - mHistManager.fill(HIST("h_TPCeePhosGamma_minusee_MS_v_cluE"), tripletMass - pairMass + cfgJpsiMass, gamma.e()); + } else { + mHistManager.fill(HIST("TPCeff/h_ee_mp_mass_spectra_v_pt_v_cent"), massTag1Probe2, ptProbe2, cent); } } } - } - for (auto const& track1 : tracks) { - mHistManager.fill(HIST("hTrackPt"), track1.pt()); - mHistManager.fill(HIST("hTrackEta"), track1.eta()); - mHistManager.fill(HIST("hTrackVX"), track1.x()); - mHistManager.fill(HIST("hTrackVY"), track1.y()); - mHistManager.fill(HIST("hTrackVZ"), track1.z()); + if (isGoodTagElectron(track2_iterator) && isGoodProbeBaseTrack(track1_iterator)) { + ROOT::Math::LorentzVector> pTag2, pProbe1; + pTag2.SetPxPyPzE(track2_iterator.px(), track2_iterator.py(), track2_iterator.pz(), track2_iterator.energy(0)); + pProbe1.SetPxPyPzE(track1_iterator.px(), track1_iterator.py(), track1_iterator.pz(), track1_iterator.energy(0)); + float massTag2Probe1 = (pTag2 + pProbe1).M(); + float ptProbe1 = track1_iterator.pt(); + bool tag2IsPositive = track2_iterator.sign() * bz > 0; + + if (track2_iterator.sign() == track1_iterator.sign()) { + if (tag2IsPositive) { + mHistManager.fill(HIST("TPCeff/h_eh_pp_mass_spectra_v_pt_v_cent"), massTag2Probe1, ptProbe1, cent); + } else { + mHistManager.fill(HIST("TPCeff/h_eh_mm_mass_spectra_v_pt_v_cent"), massTag2Probe1, ptProbe1, cent); + } + } else { + mHistManager.fill(HIST("TPCeff/h_eh_mp_mass_spectra_v_pt_v_cent"), massTag2Probe1, ptProbe1, cent); + } + if (isProbeIdentifiedAsElectron(track1_iterator)) { + if (track2_iterator.sign() == track1_iterator.sign()) { + if (tag2IsPositive) { + mHistManager.fill(HIST("TPCeff/h_ee_pp_mass_spectra_v_pt_v_cent"), massTag2Probe1, ptProbe1, cent); + } else { + mHistManager.fill(HIST("TPCeff/h_ee_mm_mass_spectra_v_pt_v_cent"), massTag2Probe1, ptProbe1, cent); + } + } else { + mHistManager.fill(HIST("TPCeff/h_ee_mp_mass_spectra_v_pt_v_cent"), massTag2Probe1, ptProbe1, cent); + } + } + } + } - if (!track1.has_collision() || !track1.hasTPC()) - continue; - if (track1.itsChi2NCl() > cfgITSchi2Max || track1.tpcChi2NCl() > cfgTPCchi2Max) - continue; - if (track1.itsNCls() < cfgITSnclsMin || track1.itsNCls() > cfgITSnclsMax || !((track1.itsClusterMap() & uint8_t(1)) > 0)) + for (auto const& gamma1 : clusters) { + float cluE1 = gamma1.e(); + if (cluE1 < mMinCluE || gamma1.ncell() < mMinCluNcell || gamma1.time() > mMaxCluTime || gamma1.time() < mMinCluTime) continue; - if (track1.tpcNClsFound() < cfgTPCnclsMin || track1.tpcNClsFound() > cfgTPCnclsMax) - continue; - if (track1.tpcNClsCrossedRows() < cfgTPCnclsCRMin || track1.tpcNClsCrossedRows() > cfgTPCnclsCRMax) + bool matchFlag1 = false; + + bool isDispOKClu1 = false; + if (mSwapM20M02ForTestLambda) + isDispOKClu1 = testLambda(cluE1, gamma1.m02(), gamma1.m20(), mShowerShapeCutValue, mUseNegativeCrossTerm); + else + isDispOKClu1 = testLambda(cluE1, gamma1.m20(), gamma1.m02(), mShowerShapeCutValue, mUseNegativeCrossTerm); + if (!isDispOKClu1) continue; + for (auto const& match : matches) { + if (gamma1.index() == match.caloClusterId()) { + matchFlag1 = true; + break; + } + } + for (auto const& gamma2 : clusters) { + if (gamma1.index() >= gamma2.index()) + continue; + float cluE2 = gamma2.e(); + if (cluE2 < mMinCluE || gamma2.ncell() < mMinCluNcell || gamma2.time() > mMaxCluTime || gamma2.time() < mMinCluTime) + continue; + bool isDispOKClu2 = false; + if (mSwapM20M02ForTestLambda) + isDispOKClu2 = testLambda(cluE2, gamma2.m02(), gamma2.m20(), mShowerShapeCutValue, mUseNegativeCrossTerm); + else + isDispOKClu2 = testLambda(cluE2, gamma2.m20(), gamma2.m02(), mShowerShapeCutValue, mUseNegativeCrossTerm); + if (!isDispOKClu2) + continue; + bool matchFlag2 = false; + for (auto const& match : matches) { + if (gamma2.index() == match.caloClusterId()) { + matchFlag2 = true; + break; + } + } + ROOT::Math::LorentzVector> fourVectorG1, fourVectorG2; + fourVectorG1.SetPxPyPzE(gamma1.px(), gamma1.py(), gamma1.pz(), cluE1); + fourVectorG2.SetPxPyPzE(gamma2.px(), gamma2.py(), gamma2.pz(), cluE2); + double pairMassGG = (fourVectorG1 + fourVectorG2).M(); + double pairPtGG = (fourVectorG1 + fourVectorG2).Pt(); - mHistManager.fill(HIST("hTPCspectra_isElectronRej"), track1.pt(), track1.tpcSignal()); + if (pairMassGG < mMassSpectrumLowerCutoff) + continue; - mHistManager.fill(HIST("hTrackPt_Cut"), track1.pt()); - mHistManager.fill(HIST("hTrackEta_Cut"), track1.eta()); - mHistManager.fill(HIST("hTrackVX_Cut"), track1.x()); - mHistManager.fill(HIST("hTrackVY_Cut"), track1.y()); - mHistManager.fill(HIST("hTrackVZ_Cut"), track1.z()); + mHistManager.fill(HIST("twoPhoton/MS_noCuts"), pairMassGG, pairPtGG, cent); + if (matchFlag1 || matchFlag2) + continue; + mHistManager.fill(HIST("twoPhoton/MS_noMatches"), pairMassGG, pairPtGG, cent); + } + } + + for (auto const& track : tracks) { + mHistManager.fill(HIST("hTrackPt"), track.pt()); + mHistManager.fill(HIST("hTrackEta"), track.eta()); + mHistManager.fill(HIST("hTrackVX"), track.x()); + mHistManager.fill(HIST("hTrackVY"), track.y()); + mHistManager.fill(HIST("hTrackVZ"), track.z()); + mHistManager.fill(HIST("hTPCspectra"), track.pt(), track.tpcSignal()); + } + + for (auto const& track : tracks) { + if (isGoodElectronForSignal(track)) { + mHistManager.fill(HIST("hTPCspectra_isElectronRej"), track.pt(), track.tpcSignal()); + mHistManager.fill(HIST("hTrackPt_Cut"), track.pt()); + mHistManager.fill(HIST("hTrackEta_Cut"), track.eta()); + mHistManager.fill(HIST("hTrackVX_Cut"), track.x()); + mHistManager.fill(HIST("hTrackVY_Cut"), track.y()); + mHistManager.fill(HIST("hTrackVZ_Cut"), track.z()); + } } } }; diff --git a/PWGEM/Tasks/phosNonlin.cxx b/PWGEM/Tasks/phosNonlin.cxx index 9115fa432c8..f25043c5f0c 100644 --- a/PWGEM/Tasks/phosNonlin.cxx +++ b/PWGEM/Tasks/phosNonlin.cxx @@ -9,17 +9,26 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file phosNonlin.cxx +/// \brief task to calculate PHOS non-lienarity based on pi0 peak position +/// \author Dmitri Peresunko +/// + +#include #include #include #include #include +#include #include -#include + #include #include "Common/DataModel/CaloClusters.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" #include "Framework/ConfigParamSpec.h" #include "Framework/runDataProcessing.h" @@ -34,27 +43,23 @@ #include "CCDB/BasicCCDBManager.h" #include "DataFormatsParameters/GRPLHCIFData.h" -/// \struct PHOS pi0 analysis -/// \brief Monitoring task for PHOS related quantities -/// \author Dmitri Peresunko, NRC "Kurchatov institute" -/// \since Nov, 2022 -/// - using namespace o2; using namespace o2::aod::evsel; using namespace o2::framework; using namespace o2::framework::expressions; -struct phosNonlin { - Configurable mEvSelTrig{"mEvSelTrig", kTVXinPHOS, "Select events with this trigger"}; - Configurable mParamType{"mParamType", 0, "Functional form 0: a-la data, 1: a-la MC"}; - Configurable mMinCluE{"mMinCluE", 0.1, "Minimum cluster energy for analysis"}; - Configurable mMinCluTime{"minCluTime", -25.e-9, "Min. cluster time"}; - Configurable mMaxCluTime{"maxCluTime", 25.e-9, "Max. cluster time"}; - Configurable mMinCluNcell{"minCluNcell", 1, "min cells in cluster"}; - Configurable mMinM02{"minM02", 0.2, "Min disp M02 cut"}; - Configurable mNMixedEvents{"nMixedEvents", 2, "number of events to mix"}; - Configurable mSelectOneCollPerBC{"selectOneColPerBC", true, "skip multiple coll. per bc"}; +struct PhosNonlin { + Configurable skimmedProcessing{"skimmedProcessing", true, "Skimmed dataset processing"}; + Configurable trigName{"trigName", "fPHOSPhoton", "name of offline trigger"}; + Configurable zorroCCDBpath{"zorroCCDBpath", "/Users/m/mpuccio/EventFiltering/OTS/", "path to the zorro ccdb objects"}; + Configurable evSelTrig{"evSelTrig", kTVXinPHOS, "Select events with this trigger"}; + Configurable paramType{"paramType", 0, "Functional form 0: a-la data, 1: a-la MC"}; + Configurable minCluE{"minCluE", 0.1, "Minimum cluster energy for analysis"}; + Configurable minCluTime{"minCluTime", -25.e-9, "Min. cluster time"}; + Configurable maxCluTime{"maxCluTime", 25.e-9, "Max. cluster time"}; + Configurable minCluNcell{"minCluNcell", 1, "min cells in cluster"}; + Configurable minM02{"minM02", 0.2, "Min disp M02 cut"}; + Configurable nMixedEvents{"nMixedEvents", 2, "number of events to mix"}; Configurable mA{"mA", 9.34913e-01, "A"}; Configurable mdAi{"mdAi", 0., "A var. vs i"}; Configurable mdAj{"mdAj", 0., "A var. vs j"}; @@ -82,29 +87,34 @@ struct phosNonlin { using SelCollisions = soa::Join; using BCsWithBcSels = soa::Join; + o2::framework::Service ccdb; HistogramRegistry mHistManager1{"phosNonlinHistograms"}; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + // class to keep photon candidate parameters - class photon : public TLorentzVector + class Photon : public TLorentzVector { public: - photon() = default; - photon(const photon& p) = default; - photon(double px, double py, double pz, double e, int m) : TLorentzVector(px, py, pz, e), mod(m) {} + Photon() = default; + Photon(const Photon& p) = default; + Photon(double px, double py, double pz, double e, int m) : TLorentzVector(px, py, pz, e), mod(m) {} public: int mod; }; + int mRunNumber = -1; // Current run number int mixedEventBin = 0; // Which list of Mixed use for mixing - std::vector mCurEvent; - static constexpr int nMaxMixBins = 10; // maximal number of kinds of events for mixing - std::array>, nMaxMixBins> mMixedEvents; + std::vector mCurEvent; + static constexpr int kMaxMixBins = 10; // maximal number of kinds of events for mixing + std::array>, kMaxMixBins> mMixedEvents; // fast access to histos - static constexpr int mNp = 10; - std::array hReIJ, hReKL, hReMIJ, hReMKL; + static constexpr int kNp = 10; + std::array hReIJ, hReKL, hReMIJ, hReMKL; TH2* hMi; std::vector pt = {0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, @@ -116,21 +126,26 @@ struct phosNonlin { { LOG(info) << "Initializing PHOS nonlin analysis task ..."; - const AxisSpec - ptAxis{pt, "p_{T} (GeV/c)"}, + zorroSummary.setObject(zorro.getZorroSummary()); + zorro.setBaseCCDBPath(zorroCCDBpath.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + const AxisSpec ptAxis{pt, "p_{T} (GeV/c)"}, mggAxis{150, 0., 0.3, "m_{#gamma#gamma} (GeV/c^{2})"}; - for (int i = 0; i < mNp; i++) { - for (int j = 0; j < mNp; j++) { - hReIJ[i * mNp + j] = std::get>(mHistManager1.add(Form("hRe_a%d_b%d", i, j), "inv mass", + for (int i = 0; i < kNp; i++) { + for (int j = 0; j < kNp; j++) { + hReIJ[i * kNp + j] = std::get>(mHistManager1.add(Form("hRe_a%d_b%d", i, j), "inv mass", HistType::kTH2F, {mggAxis, ptAxis})) .get(); - hReKL[i * mNp + j] = std::get>(mHistManager1.add(Form("hRe_c%d_d%d", i, j), "inv mass", + hReKL[i * kNp + j] = std::get>(mHistManager1.add(Form("hRe_c%d_d%d", i, j), "inv mass", HistType::kTH2F, {mggAxis, ptAxis})) .get(); - // hReMIJ[i*mNp+j] = std::get>(mHistManager2.add(Form("hReM_a%d_b%d",i,j), "inv mass", + // hReMIJ[i*kNp+j] = std::get>(mHistManager2.add(Form("hReM_a%d_b%d",i,j), "inv mass", // HistType::kTH2F, {mggAxis, ptAxis})).get(); - // hReMKL[i*mNp+j] = std::get>(mHistManager2.add(Form("hReM_c%d_d%d",i,j), "inv mass", + // hReMKL[i*kNp+j] = std::get>(mHistManager2.add(Form("hReM_c%d_d%d",i,j), "inv mass", // HistType::kTH2F, {mggAxis, ptAxis})).get(); } } @@ -141,57 +156,71 @@ struct phosNonlin { /// \brief Process PHOS data void process(SelCollisions::iterator const& col, - aod::CaloClusters const& clusters) + aod::CaloClusters const& clusters, + aod::BCsWithTimestamps const&) { // Fill number of events of different kind - if (!col.alias_bit(mEvSelTrig)) { - return; + if (skimmedProcessing) { + auto bc = col.template bc_as(); + if (mRunNumber != bc.runNumber()) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), trigName); + zorro.populateHistRegistry(mHistManager1, bc.runNumber()); + mRunNumber = bc.runNumber(); + } + + if (!zorro.isSelected(bc.globalBC())) { + return; /// + } + } else { + if (!col.selection_bit(evSelTrig)) { + return; + } } mixedEventBin = findMixedEventBin(col.posZ()); mCurEvent.clear(); int i, j, k, l; - for (const auto& clu : clusters) { - if (clu.e() < mMinCluE || - clu.ncell() < mMinCluNcell || - clu.time() > mMaxCluTime || clu.time() < mMinCluTime || - clu.m02() < mMinM02) { + for (auto const& clu : clusters) { + if (clu.e() < minCluE || + clu.ncell() < minCluNcell || + clu.time() > maxCluTime || clu.time() < minCluTime || + clu.m02() < minM02) { continue; } - photon ph1(clu.px(), clu.py(), clu.pz(), clu.e(), clu.mod()); + Photon ph1(clu.px(), clu.py(), clu.pz(), clu.e(), clu.mod()); // Mix with other photons added to stack - for (auto ph2 : mCurEvent) { + for (auto const& ph2 : mCurEvent) { double m = (ph1 + ph2).M(); double pt1 = ph1.Pt(); double pt2 = ph2.Pt(); - k = mNp / 2; - l = mNp / 2; - for (i = 0; i < mNp; i++) { - for (j = 0; j < mNp; j++) { - if (ph1.E() * NonLin(ph1.E(), i, j, k, l) > mMinCluE && ph2.E() * NonLin(ph2.E(), i, j, k, l) > mMinCluE) { - Double_t m12 = m * TMath::Sqrt(NonLin(ph1.E(), i, j, k, l) * NonLin(ph2.E(), i, j, k, l)); - hReIJ[i * mNp + j]->Fill(m12, pt1); - hReIJ[i * mNp + j]->Fill(m12, pt2); + k = kNp / 2; + l = kNp / 2; + for (i = 0; i < kNp; i++) { + for (j = 0; j < kNp; j++) { + if (ph1.E() * nonLin(ph1.E(), i, j, k, l) > minCluE && ph2.E() * nonLin(ph2.E(), i, j, k, l) > minCluE) { + double m12 = m * std::sqrt(nonLin(ph1.E(), i, j, k, l) * nonLin(ph2.E(), i, j, k, l)); + hReIJ[i * kNp + j]->Fill(m12, pt1); + hReIJ[i * kNp + j]->Fill(m12, pt2); // if(ph1.mod==ph2.mod){ - // hReMIJ[i*mNp + j]->Fill(m12,pt1); - // hReMIJ[i*mNp + j]->Fill(m12,pt2); + // hReMIJ[i*kNp + j]->Fill(m12,pt1); + // hReMIJ[i*kNp + j]->Fill(m12,pt2); // } } } } - i = mNp / 2; - j = mNp / 2; - for (k = 0; k < mNp; k++) { - for (l = 0; l < mNp; l++) { - if (ph1.E() * NonLin(ph1.E(), i, j, k, l) > mMinCluE && ph2.E() * NonLin(ph2.E(), i, j, k, l) > mMinCluE) { - Double_t m12 = m * TMath::Sqrt(NonLin(ph1.E(), i, j, k, l) * NonLin(ph2.E(), i, j, k, l)); - hReKL[k * mNp + l]->Fill(m12, pt1); - hReKL[k * mNp + l]->Fill(m12, pt2); + i = kNp / 2; + j = kNp / 2; + for (k = 0; k < kNp; k++) { + for (l = 0; l < kNp; l++) { + if (ph1.E() * nonLin(ph1.E(), i, j, k, l) > minCluE && ph2.E() * nonLin(ph2.E(), i, j, k, l) > minCluE) { + double m12 = m * std::sqrt(nonLin(ph1.E(), i, j, k, l) * nonLin(ph2.E(), i, j, k, l)); + hReKL[k * kNp + l]->Fill(m12, pt1); + hReKL[k * kNp + l]->Fill(m12, pt2); // if(ph1.mod==ph2.mod){ - // hReMKL[k*mNp + l]->Fill(m12,pt1); - // hReMKL[k*mNp + l]->Fill(m12,pt2); + // hReMKL[k*kNp + l]->Fill(m12,pt1); + // hReMKL[k*kNp + l]->Fill(m12,pt2); // } } } @@ -202,19 +231,19 @@ struct phosNonlin { } // Mixed - for (auto ph1 : mCurEvent) { - for (auto mixEvent : mMixedEvents[mixedEventBin]) { - for (auto ph2 : mixEvent) { + for (const auto& ph1 : mCurEvent) { + for (const auto& mixEvent : mMixedEvents[mixedEventBin]) { + for (const auto& ph2 : mixEvent) { double m = (ph1 + ph2).M(); double pt1 = ph1.Pt(); double pt2 = ph2.Pt(); - i = mNp / 2; - j = mNp / 2; - k = mNp / 2; - l = mNp / 2; - if (ph1.E() * NonLin(ph1.E(), i, j, k, l) > mMinCluE && ph2.E() * NonLin(ph2.E(), i, j, k, l) > mMinCluE) { - Double_t m12 = m * TMath::Sqrt(NonLin(ph1.E(), i, j, k, l) * NonLin(ph2.E(), i, j, k, l)); + i = kNp / 2; + j = kNp / 2; + k = kNp / 2; + l = kNp / 2; + if (ph1.E() * nonLin(ph1.E(), i, j, k, l) > minCluE && ph2.E() * nonLin(ph2.E(), i, j, k, l) > minCluE) { + double m12 = m * std::sqrt(nonLin(ph1.E(), i, j, k, l) * nonLin(ph2.E(), i, j, k, l)); hMi->Fill(m12, pt1); hMi->Fill(m12, pt2); } @@ -225,7 +254,7 @@ struct phosNonlin { // Fill events to store and remove oldest to keep buffer size if (mCurEvent.size() > 0) { mMixedEvents[mixedEventBin].emplace_back(mCurEvent); - if (mMixedEvents[mixedEventBin].size() > static_cast(mNMixedEvents)) { + if (mMixedEvents[mixedEventBin].size() > static_cast(nMixedEvents)) { mMixedEvents[mixedEventBin].pop_front(); } } @@ -240,33 +269,33 @@ struct phosNonlin { if (res < 0) return 0; - if (res >= nMaxMixBins) - return nMaxMixBins - 1; + if (res >= kMaxMixBins) + return kMaxMixBins - 1; return res; } //_____________________________________________________________________________ - double NonLin(double en, int i, int j, int k, int l) + double nonLin(double en, int i, int j, int k, int l) { if (en <= 0.) return 0.; - if (mParamType == 0) { - const Double_t a = mA + mdAi * (i - mNp / 2) + mdAj * (j - mNp / 2); - const Double_t b = mB + mdBi * (i - mNp / 2) + mdBj * (j - mNp / 2); - const Double_t c = mC + mdCi * (i - mNp / 2) + mdCj * (j - mNp / 2); - const Double_t d = mD + mdDk * (k - mNp / 2) + mdDl * (l - mNp / 2); - const Double_t e = mE + mdEk * (k - mNp / 2) + mdEl * (l - mNp / 2); - const Double_t f = mF + mdFk * (k - mNp / 2) + mdFl * (l - mNp / 2); - const Double_t g = mG + mdGk * (k - mNp / 2) + mdGl * (l - mNp / 2); - const Double_t s = mS + mdSi * (i - mNp / 2) + mdSj * (j - mNp / 2); + if (paramType == 0) { + const double a = mA + mdAi * (i - kNp / 2) + mdAj * (j - kNp / 2); + const double b = mB + mdBi * (i - kNp / 2) + mdBj * (j - kNp / 2); + const double c = mC + mdCi * (i - kNp / 2) + mdCj * (j - kNp / 2); + const double d = mD + mdDk * (k - kNp / 2) + mdDl * (l - kNp / 2); + const double e = mE + mdEk * (k - kNp / 2) + mdEl * (l - kNp / 2); + const double f = mF + mdFk * (k - kNp / 2) + mdFl * (l - kNp / 2); + const double g = mG + mdGk * (k - kNp / 2) + mdGl * (l - kNp / 2); + const double s = mS + mdSi * (i - kNp / 2) + mdSj * (j - kNp / 2); return a + b / en + c / (en * en) + d / ((en - e) * (en - e) + f * f) + g * en + s / (en * en * en * en); } - if (mParamType == 1) { - const Double_t a = mA + mdAi * (i - mNp / 2) + mdAj * (j - mNp / 2); - const Double_t b = mB + mdBi * (i - mNp / 2) + mdBj * (j - mNp / 2); - const Double_t c = mC + mdCi * (i - mNp / 2) + mdCj * (j - mNp / 2); - const Double_t d = mD + mdDk * (k - mNp / 2) + mdDl * (l - mNp / 2); - const Double_t e = mE + mdEk * (k - mNp / 2) + mdEl * (l - mNp / 2); - return a + b / TMath::Sqrt(en) + c / en + d / (en * TMath::Sqrt(en)) + e / (en * en); + if (paramType == 1) { + const double a = mA + mdAi * (i - kNp / 2) + mdAj * (j - kNp / 2); + const double b = mB + mdBi * (i - kNp / 2) + mdBj * (j - kNp / 2); + const double c = mC + mdCi * (i - kNp / 2) + mdCj * (j - kNp / 2); + const double d = mD + mdDk * (k - kNp / 2) + mdDl * (l - kNp / 2); + const double e = mE + mdEk * (k - kNp / 2) + mdEl * (l - kNp / 2); + return a + b / std::sqrt(en) + c / en + d / (en * std::sqrt(en)) + e / (en * en); } return 0.; } @@ -275,5 +304,5 @@ struct phosNonlin { o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& cfgc) { return o2::framework::WorkflowSpec{ - o2::framework::adaptAnalysisTask(cfgc)}; + o2::framework::adaptAnalysisTask(cfgc)}; } diff --git a/PWGEM/Tasks/phosPi0.cxx b/PWGEM/Tasks/phosPi0.cxx index fe248dbeaa6..a47aaa0d485 100644 --- a/PWGEM/Tasks/phosPi0.cxx +++ b/PWGEM/Tasks/phosPi0.cxx @@ -9,11 +9,19 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file phosPi0.cxx +/// \brief PHOS pi0/eta analysis +/// \author Dmitri Peresunko +/// + +#include #include #include #include #include +#include #include + #include "Common/DataModel/CaloClusters.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" @@ -27,72 +35,81 @@ #include "Framework/ASoAHelpers.h" #include "Framework/HistogramRegistry.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + #include "PHOSBase/Geometry.h" #include "CommonDataFormat/InteractionRecord.h" #include "CCDB/BasicCCDBManager.h" #include "DataFormatsParameters/GRPLHCIFData.h" -/// \struct PHOS pi0 analysis -/// \brief Monitoring task for PHOS related quantities -/// \author Dmitri Peresunko, NRC "Kurchatov institute" -/// \since Nov, 2022 -/// - using namespace o2; using namespace o2::aod::evsel; using namespace o2::framework; using namespace o2::framework::expressions; -struct phosPi0 { - Configurable mIsMC{"isMC", false, "to fill MC histograms"}; - Configurable mEvSelTrig{"mEvSelTrig", kTVXinPHOS, "Select events with this trigger"}; - Configurable mMinCluE{"mMinCluE", 0.3, "Minimum cluster energy for analysis"}; - Configurable mMinCluTime{"minCluTime", -25.e-9, "Min. cluster time"}; - Configurable mMaxCluTime{"maxCluTime", 25.e-9, "Max. cluster time"}; - Configurable mMinCluNcell{"minCluNcell", 2, "min cells in cluster"}; - Configurable mMinM02{"minM02", 0.2, "Min disp M02 cut"}; - Configurable mCPVCut{"CPVCut", 2., "Min distance to track"}; - Configurable mNMixedEvents{"nMixedEvents", 10, "number of events to mix"}; - Configurable mSelectOneCollPerBC{"selectOneColPerBC", true, "skip multiple coll. per bc"}; - Configurable mFillQC{"fillQC", true, "Fill QC histos"}; - Configurable mOccE{"minOccE", 0.5, "Min. cluster energy of occupancy plots"}; +struct PhosPi0 { + Configurable skimmedProcessing{"skimmedProcessing", false, "Skimmed dataset processing"}; + Configurable trigName{"trigName", "fPHOSPhoton", "name of offline trigger"}; + Configurable zorroCCDBpath{"zorroCCDBpath", "/Users/m/mpuccio/EventFiltering/OTS/", "path to the zorro ccdb objects"}; + Configurable evSelTrig{"evSelTrig", aod::evsel::kIsTriggerTVX, "Select events with this trigger"}; + Configurable isMC{"isMC", false, "to fill MC histograms"}; + Configurable minCluE{"minCluE", 0.3, "Minimum cluster energy for analysis"}; + Configurable minCluTime{"minCluTime", -25.e-9, "Min. cluster time"}; + Configurable maxCluTime{"maxCluTime", 25.e-9, "Max. cluster time"}; + Configurable minCluNcell{"minCluNcell", 2, "min cells in cluster"}; + Configurable minM02{"minM02", 0.2, "Min disp M02 cut"}; + Configurable cpvCut{"cpvCut", 2., "Min distance to track"}; + Configurable nMixedEvents{"nMixedEvents", 10, "number of events to mix"}; + Configurable fillQC{"fillQC", true, "Fill QC histos"}; + Configurable minOccE{"minOccE", 0.5, "Min. cluster energy of occupancy plots"}; + Configurable nonlinA{"nonlinA", 1., "nonlinsrity param A (scale)"}; + Configurable nonlinB{"nonlinB", 0., "nonlinsrity param B (a+b*exp(-e/c))"}; + Configurable nonlinC{"nonlinC", 1., "nonlinsrity param C (a+b*exp(-e/c))"}; + Configurable tofEffParam{"tofEffParam", 0, "parameterization of TOF cut efficiency"}; + Configurable timeOffset{"timeOffset", 0., "time offset to compensate imperfection of time calibration"}; using SelCollisions = soa::Join; using SelCollisionsMC = soa::Join; using BCsWithBcSels = soa::Join; - using mcClusters = soa::Join; - using mcAmbClusters = soa::Join; + using McClusters = soa::Join; + using McAmbClusters = soa::Join; o2::framework::Service ccdb; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; - HistogramRegistry mHistManager{"phosPi0Histograms"}; + HistogramRegistry mHistManager{"PHOSPi0Histograms"}; // class to keep photon candidate parameters - class photon + class Photon { public: - photon() = default; - photon(double x, double y, double z, double ee, int m, bool isDispOK, bool isCPVOK, int mcLabel) : px(x), py(y), pz(z), e(ee), mod(m), mPID(isDispOK << 1 | isCPVOK << 2), label(mcLabel) {} - ~photon() = default; + Photon() = default; + Photon(double x, double y, double z, double ee, double t, int m, bool isDispOK, bool isCPVOK, int mcLabel) : px(x), py(y), pz(z), e(ee), time(t), mod(m), mPID(isDispOK << 1 | isCPVOK << 2), label(mcLabel) {} + ~Photon() = default; - bool isCPVOK() { return (mPID >> 2) & 1; } - bool isDispOK() { return (mPID >> 1) & 1; } + bool isCPVOK() const { return (mPID >> 2) & 1; } + bool isDispOK() const { return (mPID >> 1) & 1; } + double pt() const { return std::sqrt(px * px + py * py); } public: - double px = 0.; // px - double py = 0.; // py - double pz = 0.; // pz - double e = 0.; // energy - int mod = 0; // module - int mPID = 0; // store PID bits - int label = -1; // label of MC particle + double px = 0.; // px + double py = 0.; // py + double pz = 0.; // pz + double e = 0.; // energy + double time = 0.; // time + int mod = 0; // module + int mPID = 0; // store PID bits + int label = -1; // label of MC particle }; + int mRunNumber = 0; // Current run number int mixedEventBin = 0; // Which list of Mixed use for mixing - std::vector mCurEvent; - static constexpr int nMaxMixBins = 20; // maximal number of kinds of events for mixing - std::array>, nMaxMixBins> mMixedEvents; - std::array>, nMaxMixBins> mAmbMixedEvents; + std::vector mCurEvent; + static constexpr int kMaxMixBins = 20; // maximal number of kinds of events for mixing + std::array>, kMaxMixBins> mMixedEvents; + std::array>, kMaxMixBins> mAmbMixedEvents; int mPrevMCColId = -1; // mark MC collissions already scanned // fast access to histos @@ -100,23 +117,26 @@ struct phosPi0 { TH3 *hReMod, *hMiMod; TH2 *hReAll, *hReDisp, *hReCPV, *hReBoth, *hSignalAll, *hPi0SignalAll, *hPi0SignalCPV, *hPi0SignalDisp, *hPi0SignalBoth, *hMiAll, *hMiDisp, *hMiCPV, *hMiBoth; + TH2 *hReOneAll, *hReOneDisp, *hReOneCPV, *hReOneBoth, *hMiOneAll, *hMiOneDisp, *hMiOneCPV, *hMiOneBoth; + TH2 *hReTime12, *hReTime30, *hReTime50, *hReTime100; - std::vector pt = {0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, - 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, - 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 10., 11., 12., 13., 14., 15., 16., 18., 20., 22., 24., 26., 28., - 30., 34., 38., 42., 46., 50., 55., 60., 70., 80., 90., 100., 110., 120., 150.}; + std::vector pt = {0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, + 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.5, 4.6, 4.8, 5.0, + 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 22., 24., 26., 28., + 30., 34., 38., 42., 46., 50., 55., 60., 70., 75., 80., 85., 90., 95., 100., 110., 120., 130., 140., 150., 160., 180., 200.}; /// \brief Create output histograms void init(InitContext const&) { LOG(info) << "Initializing PHOS pi0 analysis task ..."; + zorroSummary.setObject(zorro.getZorroSummary()); + zorro.setBaseCCDBPath(zorroCCDBpath.value); - const AxisSpec - ptAxis{pt, "p_{T} (GeV/c)"}, + const AxisSpec ptAxis{pt, "p_{T} (GeV/c)"}, mggAxis{625, 0., 1.25, "m_{#gamma#gamma} (GeV/c^{2})"}, timeAxis{100, -500.e-9, 500.e-9, "t (s)"}, - M02Axis{100, 0., 20., "M02 (cm^{2})"}, - M20Axis{100, 0., 20., "M20 (cm^{2})"}, + m02Axis{100, 0., 20., "M02 (cm^{2})"}, + m20Axis{100, 0., 20., "M20 (cm^{2})"}, nCellsAxis{100, 0., 100., "N_{cell}"}, zAxis{56, -63., 63., "z", "z (cm)"}, phiAxis{64, -72., 72., "x", "x (cm)"}, @@ -127,15 +147,16 @@ struct phosPi0 { centAxis{10, 0., 10.}, centralityAxis{100, 0., 100., "centrality", "centrality"}; - hColl = std::get>(mHistManager.add("eventsCol", "Number of events", HistType::kTH1F, {{9, 0., 9.}})).get(); + hColl = std::get>(mHistManager.add("eventsCol", "Number of events", HistType::kTH1F, {{10, 0., 10.}})).get(); hColl->GetXaxis()->SetBinLabel(1, "All"); - hColl->GetXaxis()->SetBinLabel(2, "T0a||T0c"); - hColl->GetXaxis()->SetBinLabel(3, "T0a&&T0c"); - hColl->GetXaxis()->SetBinLabel(4, "kTVXinPHOS"); - hColl->GetXaxis()->SetBinLabel(5, "kIsTriggerTVX"); - hColl->GetXaxis()->SetBinLabel(6, "PHOSClu"); - hColl->GetXaxis()->SetBinLabel(7, "PHOSClu&&kTVXinPHOS"); - hColl->GetXaxis()->SetBinLabel(8, "Accepted"); + hColl->GetXaxis()->SetBinLabel(2, "SwTr"); + hColl->GetXaxis()->SetBinLabel(3, "T0a||T0c"); + hColl->GetXaxis()->SetBinLabel(4, "T0a&&T0c"); + hColl->GetXaxis()->SetBinLabel(5, "kTVXinPHOS"); + hColl->GetXaxis()->SetBinLabel(6, "kIsTriggerTVX"); + hColl->GetXaxis()->SetBinLabel(7, "PHOSClu"); + hColl->GetXaxis()->SetBinLabel(8, "PHOSClu&&kTVXinPHOS"); + hColl->GetXaxis()->SetBinLabel(9, "Accepted"); auto h2{std::get>(mHistManager.add("eventsBC", "Number of events per trigger", HistType::kTH1F, {{8, 0., 8.}}))}; h2->GetXaxis()->SetBinLabel(1, "All"); @@ -150,14 +171,14 @@ struct phosPi0 { mHistManager.add("contributors", "Contributors per collision", HistType::kTH2F, {{10, 0., 10.}, {10, 0., 100.}}); mHistManager.add("vertex", "vertex", HistType::kTH1F, {vertexAxis}); - if (mFillQC) { + if (fillQC) { // QC histograms for normal collisions mHistManager.add("cluSp", "Cluster spectrum per module", HistType::kTH2F, {ptAxis, modAxis}); mHistManager.add("cluSpDisp", "Cluster spectrum per module", HistType::kTH2F, {ptAxis, modAxis}); mHistManager.add("cluSpCPV", "Cluster spectrum per module", HistType::kTH2F, {ptAxis, modAxis}); mHistManager.add("cluSpBoth", "Cluster spectrum per module", HistType::kTH2F, {ptAxis, modAxis}); - mHistManager.add("hM02Clu", "(M02,M20) in clusters", HistType::kTH2F, {ptAxis, M02Axis}); - mHistManager.add("hM20Clu", "(M02,M20) in clusters", HistType::kTH2F, {ptAxis, M20Axis}); + mHistManager.add("hM02Clu", "(M02,M20) in clusters", HistType::kTH2F, {ptAxis, m02Axis}); + mHistManager.add("hM20Clu", "(M02,M20) in clusters", HistType::kTH2F, {ptAxis, m20Axis}); mHistManager.add("hNcellClu", "Number of cells in clusters", HistType::kTH3F, {ptAxis, nCellsAxis, modAxis}); mHistManager.add("cluETime", "Cluster time vs E", HistType::kTH3F, {ptAxis, timeAxis, modAxis}); @@ -182,8 +203,33 @@ struct phosPi0 { hReBoth = std::get>(mHistManager.add("mggReBoth", "inv mass for centrality", HistType::kTH2F, {mggAxis, ptAxis})) .get(); - - if (mIsMC) { + hReOneAll = std::get>(mHistManager.add("mggReOneAll", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + hReOneCPV = std::get>(mHistManager.add("mggReOneCPV", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + hReOneDisp = std::get>(mHistManager.add("mggReOneDisp", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + hReOneBoth = std::get>(mHistManager.add("mggReOneBoth", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + + hReTime12 = std::get>(mHistManager.add("mggReTime12", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + hReTime30 = std::get>(mHistManager.add("mggReTime30", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + hReTime50 = std::get>(mHistManager.add("mggReTime50", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + hReTime100 = std::get>(mHistManager.add("mggReTime100", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + + if (isMC) { hSignalAll = std::get>(mHistManager.add("mggSignal", "inv mass for correlated pairs", HistType::kTH2F, {mggAxis, ptAxis})) .get(); @@ -216,74 +262,159 @@ struct phosPi0 { hMiBoth = std::get>(mHistManager.add("mggMiBoth", "inv mass for centrality", HistType::kTH2F, {mggAxis, ptAxis})) .get(); - if (mIsMC) { + hMiOneAll = std::get>(mHistManager.add("mggMiOneAll", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + hMiOneCPV = std::get>(mHistManager.add("mggMiOneCPV", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + hMiOneDisp = std::get>(mHistManager.add("mggMiOneDisp", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + hMiOneBoth = std::get>(mHistManager.add("mggMiOneBoth", "inv mass for centrality", + HistType::kTH2F, {mggAxis, ptAxis})) + .get(); + if (isMC) { mHistManager.add("hMCPi0SpAll", "pi0 spectrum inclusive", HistType::kTH1F, {ptAxis}); mHistManager.add("hMCPi0SpPrim", "pi0 spectrum Primary", HistType::kTH1F, {ptAxis}); mHistManager.add("hMCPi0RapPrim", "pi0 rapidity primary", HistType::kTH1F, {{100, -1., 1., "Rapidity"}}); - mHistManager.add("hMCPi0PhiPrim", "pi0 phi primary", HistType::kTH1F, {{100, 0., TMath::TwoPi(), "#phi (rad)"}}); - mHistManager.add("hMCPi0SecVtx", "pi0 secondary", HistType::kTH2F, {{100, 0., 500., "R (cm)"}, {100, -TMath::Pi(), TMath::Pi(), "#phi (rad)"}}); + mHistManager.add("hMCPi0PhiPrim", "pi0 phi primary", HistType::kTH1F, {{100, 0., o2::constants::math::TwoPI, "#phi (rad)"}}); + mHistManager.add("hMCPi0SecVtx", "pi0 secondary", HistType::kTH2F, {{100, 0., 500., "R (cm)"}, {100, -o2::constants::math::PI, o2::constants::math::PI, "#phi (rad)"}}); } } + // template + // float getCentrality(Tcoll const& collision) + // { + // float centrality = 1.; + // if constexpr (std::is_same::value || std::is_same::value || std::is_same::value) { + // if (cfgCentralityEstimator == nuclei::centDetectors::kFV0A) { + // centrality = collision.centFV0A(); + // } else if (cfgCentralityEstimator == nuclei::centDetectors::kFT0M) { + // centrality = collision.centFT0M(); + // } else if (cfgCentralityEstimator == nuclei::centDetectors::kFT0A) { + // centrality = collision.centFT0A(); + // } else if (cfgCentralityEstimator == nuclei::centDetectors::kFT0C) { + // centrality = collision.centFT0C(); + // } else { + // LOG(warning) << "Centrality estimator not valid. Possible values: (FV0A: 0, FT0M: 1, FT0A: 2, FT0C: 3). Centrality set to 1."; + // } + // } + // return centrality; + // } + /// \brief Process PHOS data void processData(SelCollisions::iterator const& col, - aod::CaloClusters const& clusters) + aod::CaloClusters const& clusters, + aod::BCsWithTimestamps const&) { aod::McParticles const* mcPart = nullptr; scanAll(col, clusters, mcPart); } - PROCESS_SWITCH(phosPi0, processData, "processData", true); + PROCESS_SWITCH(PhosPi0, processData, "processData", true); void processMC(SelCollisionsMC::iterator const& col, - mcClusters const& clusters, + McClusters const& clusters, aod::McParticles const& mcPart, - aod::McCollisions const& /*mcCol*/) + aod::McCollisions const& /*mcCol*/, + aod::BCsWithTimestamps const&) { scanAll(col, clusters, &mcPart); } - PROCESS_SWITCH(phosPi0, processMC, "processMC", false); + PROCESS_SWITCH(PhosPi0, processMC, "processMC", false); template void scanAll(TCollision& col, TClusters& clusters, aod::McParticles const* mcPart) { - bool isColSelected = false; mixedEventBin = 0; - hColl->Fill(0.5); + if (skimmedProcessing) { + auto bc = col.template bc_as(); + if (mRunNumber != bc.runNumber()) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), trigName); + zorro.populateHistRegistry(mHistManager, bc.runNumber()); + mRunNumber = bc.runNumber(); + } + + if (!zorro.isSelected(bc.globalBC())) { + return; /// + } + } else { + if (!col.selection_bit(evSelTrig)) { + return; + } + } + + hColl->Fill(1.5); + const double vtxCut = 10.; + double vtxZ = col.posZ(); + mHistManager.fill(HIST("vertex"), vtxZ); + bool isColSelected = false; + if constexpr (isMC) { + isColSelected = (col.selection_bit(kIsTriggerTVX) && (clusters.size() > 0)); + } else { + isColSelected = col.selection_bit(evSelTrig) && std::abs(vtxZ) < vtxCut; // col.alias_bit(evSelTrig) + // collision.selection_bit(aod::evsel::kNoTimeFrameBorder); + } + if (col.selection_bit(kIsBBT0A) || col.selection_bit(kIsBBT0C)) { - hColl->Fill(1.5); + hColl->Fill(2.5); } if (col.selection_bit(kIsBBT0A) && col.selection_bit(kIsBBT0C)) { - hColl->Fill(2.5); + hColl->Fill(3.5); } if (col.alias_bit(kTVXinPHOS)) { - hColl->Fill(3.5); + hColl->Fill(4.5); } if (col.selection_bit(kIsTriggerTVX)) { - hColl->Fill(4.5); + hColl->Fill(5.5); } if (clusters.size() > 0) { - hColl->Fill(5.5); + hColl->Fill(6.5); if (col.alias_bit(kTVXinPHOS)) { - hColl->Fill(6.5); + hColl->Fill(7.5); } } - isColSelected = false; - if constexpr (isMC) { - isColSelected = (col.selection_bit(kIsTriggerTVX) && (clusters.size() > 0)); - } else { - isColSelected = col.alias_bit(mEvSelTrig); - } - double vtxZ = col.posZ(); - mHistManager.fill(HIST("vertex"), vtxZ); + // //Event Plane| jet orientation + // if (flag & (kProton | kDeuteron | kTriton | kHe3 | kHe4) || doprocessMC) { /// ignore PID pre-selections for the MC + // if constexpr (std::is_same::value) { + // nuclei::candidates_flow.emplace_back(NucleusCandidateFlow{ + // collision.centFV0A(), + // collision.centFT0M(), + // collision.centFT0A(), + // collision.centFT0C(), + // collision.psiFT0A(), + // collision.multFT0A(), + // collision.psiFT0C(), + // collision.multFT0C(), + // collision.psiTPC(), + // collision.psiTPCL(), + // collision.psiTPCR(), + // collision.multTPC()}); + // } else if constexpr (std::is_same::value) { + // nuclei::candidates_flow.emplace_back(NucleusCandidateFlow{ + // collision.centFV0A(), + // collision.centFT0M(), + // collision.centFT0A(), + // collision.centFT0C(), + // 0.5 * std::atan2(collision.qvecFT0AIm(), collision.qvecFT0ARe()), + // collision.multFT0A(), + // 0.5 * std::atan2(collision.qvecFT0CIm(), collision.qvecFT0CRe()), + // collision.multFT0C(), + // -999., + // 0.5 * std::atan2(collision.qvecBNegIm(), collision.qvecBNegRe()), + // 0.5 * std::atan2(collision.qvecBPosIm(), collision.qvecBPosRe()), + // collision.multTPC()}); + // } + int mult = 1.; // multiplicity TODO!!! mixedEventBin = findMixedEventBin(vtxZ, mult); if (!isColSelected) { return; } - hColl->Fill(7.5); + hColl->Fill(8.5); // Fill MC distributions // pion rapidity, pt, phi @@ -291,7 +422,7 @@ struct phosPi0 { if constexpr (isMC) { // check current collision Id for clusters int cluMcBCId = -1; - for (auto clu : clusters) { + for (const auto& clu : clusters) { auto mcList = clu.labels(); // const std::vector int nParents = mcList.size(); for (int iParent = 0; iParent < nParents; iParent++) { // Not found nbar parent yiet @@ -309,19 +440,19 @@ struct phosPi0 { if (mcPart->begin() != mcPart->end()) { if (mcPart->begin().mcCollisionId() != mPrevMCColId) { mPrevMCColId = mcPart->begin().mcCollisionId(); // to avoid scanning full MC table each BC - for (auto part : *mcPart) { - if (part.mcCollision().bcId() != cluMcBCId) { + for (const auto& part : *mcPart) { + if (part.mcCollision().bcId() != col.bcId()) { continue; } if (part.pdgCode() == 111) { - double r = sqrt(pow(part.vx(), 2) + pow(part.vy(), 2)); + double r = std::sqrt(std::pow(part.vx(), 2) + std::pow(part.vy(), 2)); if (r < 0.5) { mHistManager.fill(HIST("hMCPi0RapPrim"), part.y()); } - if (abs(part.y()) < .5) { + if (std::abs(part.y()) < .5) { double pt = part.pt(); mHistManager.fill(HIST("hMCPi0SpAll"), pt); - double phiVtx = atan2(part.vy(), part.vx()); + double phiVtx = std::atan2(part.vy(), part.vx()); if (r > 0.5) { mHistManager.fill(HIST("hMCPi0SecVtx"), r, phiVtx); } else { @@ -339,31 +470,31 @@ struct phosPi0 { mCurEvent.clear(); for (const auto& clu : clusters) { // Fill QC histos - if (mFillQC) { + if (fillQC) { mHistManager.fill(HIST("hM02Clu"), clu.e(), clu.m02()); mHistManager.fill(HIST("hM20Clu"), clu.e(), clu.m20()); mHistManager.fill(HIST("hNcellClu"), clu.e(), clu.ncell(), clu.mod()); mHistManager.fill(HIST("cluETime"), clu.e(), clu.time(), clu.mod()); } - if (clu.e() < mMinCluE || - clu.ncell() < mMinCluNcell || - clu.time() > mMaxCluTime || clu.time() < mMinCluTime || - clu.m02() < mMinM02) { + if (clu.e() < minCluE || + clu.ncell() < minCluNcell || + clu.time() > maxCluTime || clu.time() < minCluTime || + clu.m02() < minM02) { continue; } - if (mFillQC) { + if (fillQC) { mHistManager.fill(HIST("cluSp"), clu.e(), clu.mod()); - if (clu.e() > mOccE) { + if (clu.e() > minOccE) { mHistManager.fill(HIST("cluOcc"), clu.x(), clu.z(), clu.mod()); if (clu.trackdist() > 2.) { mHistManager.fill(HIST("cluCPVOcc"), clu.x(), clu.z(), clu.mod()); mHistManager.fill(HIST("cluSpCPV"), clu.e(), clu.mod()); - if (TestLambda(clu.e(), clu.m02(), clu.m20())) { + if (testLambda(clu.e(), clu.m02(), clu.m20())) { mHistManager.fill(HIST("cluBothOcc"), clu.x(), clu.z(), clu.mod()); mHistManager.fill(HIST("cluSpBoth"), clu.e(), clu.mod()); } } - if (TestLambda(clu.e(), clu.m02(), clu.m20())) { + if (testLambda(clu.e(), clu.m02(), clu.m20())) { mHistManager.fill(HIST("cluDispOcc"), clu.x(), clu.z(), clu.mod()); mHistManager.fill(HIST("cluSpDisp"), clu.e(), clu.mod()); } @@ -377,46 +508,104 @@ struct phosPi0 { mcLabel = mcList[0]; } } - photon ph1(clu.px(), clu.py(), clu.pz(), clu.e(), clu.mod(), TestLambda(clu.e(), clu.m02(), clu.m20()), clu.trackdist() > mCPVCut, mcLabel); + double enCorr = 1; + if constexpr (isMC) { // correct MC energy + enCorr = nonlinearity(clu.e()); + } + Photon ph1(clu.px() * enCorr, clu.py() * enCorr, clu.pz() * enCorr, clu.e() * enCorr, clu.time(), clu.mod(), testLambda(clu.e(), clu.m02(), clu.m20()), clu.trackdist() > cpvCut, mcLabel); // Mix with other photons added to stack - for (auto ph2 : mCurEvent) { - double m = pow(ph1.e + ph2.e, 2) - pow(ph1.px + ph2.px, 2) - - pow(ph1.py + ph2.py, 2) - pow(ph1.pz + ph2.pz, 2); + for (const auto& ph2 : mCurEvent) { + double m = std::pow(ph1.e + ph2.e, 2) - std::pow(ph1.px + ph2.px, 2) - + std::pow(ph1.py + ph2.py, 2) - std::pow(ph1.pz + ph2.pz, 2); if (m > 0) { - m = sqrt(m); + m = std::sqrt(m); } - double pt = sqrt(pow(ph1.px + ph2.px, 2) + - pow(ph1.py + ph2.py, 2)); - int modComb = ModuleCombination(ph1.mod, ph2.mod); - hReMod->Fill(m, pt, modComb); - hReAll->Fill(m, pt); + double pt = std::sqrt(std::pow(ph1.px + ph2.px, 2) + + std::pow(ph1.py + ph2.py, 2)); + int modComb = moduleCombination(ph1.mod, ph2.mod); + double w = 1.; + if constexpr (isMC) { // correct MC energy + w = tofCutEff(ph1.e) * tofCutEff(ph2.e); + } + hReMod->Fill(m, pt, modComb, w); + hReAll->Fill(m, pt, w); + hReOneAll->Fill(m, ph1.pt(), w); + hReOneAll->Fill(m, ph2.pt(), w); + if (ph1.isCPVOK()) { + hReOneCPV->Fill(m, ph1.pt(), w); + } + if (ph2.isCPVOK()) { + hReOneCPV->Fill(m, ph2.pt(), w); + } + if (ph1.isDispOK()) { + hReOneDisp->Fill(m, ph1.pt(), w); + if (ph1.isCPVOK()) { + hReOneBoth->Fill(m, ph1.pt(), w); + } + } + if (ph2.isDispOK()) { + hReOneDisp->Fill(m, ph2.pt(), w); + if (ph2.isCPVOK()) { + hReOneBoth->Fill(m, ph2.pt(), w); + } + } + // Test time eff + if (std::abs(ph1.time - timeOffset) < 12.5e-9) { // strict cut on first photon + if (std::abs(ph2.time - timeOffset) < 100.e-9) { + hReTime100->Fill(m, ph2.pt()); + if (std::abs(ph2.time - timeOffset) < 50.e-9) { + hReTime50->Fill(m, ph2.pt()); + if (std::abs(ph2.time - timeOffset) < 30.e-9) { + hReTime30->Fill(m, ph2.pt()); + if (std::abs(ph2.time - timeOffset) < 12.5e-9) { + hReTime12->Fill(m, ph2.pt()); + } + } + } + } + } + if (std::abs(ph2.time - timeOffset) < 12.5e-9) { // strict cut on first photon + if (std::abs(ph1.time - timeOffset) < 100.e-9) { + hReTime100->Fill(m, ph1.pt()); + if (std::abs(ph1.time - timeOffset) < 50.e-9) { + hReTime50->Fill(m, ph1.pt()); + if (std::abs(ph1.time - timeOffset) < 30.e-9) { + hReTime30->Fill(m, ph1.pt()); + if (std::abs(ph1.time - timeOffset) < 12.5e-9) { + hReTime12->Fill(m, ph1.pt()); + } + } + } + } + } + bool isPi0 = false; if constexpr (isMC) { // test parent int cp = commonParentPDG(ph1.label, ph2.label, mcPart); if (cp != 0) { - hSignalAll->Fill(m, pt); + hSignalAll->Fill(m, pt, w); if (cp == 111) { isPi0 = true; - hPi0SignalAll->Fill(m, pt); + hPi0SignalAll->Fill(m, pt, w); } } } if (ph1.isCPVOK() && ph2.isCPVOK()) { - hReCPV->Fill(m, pt); + hReCPV->Fill(m, pt, w); if (isPi0) { - hPi0SignalCPV->Fill(m, pt); + hPi0SignalCPV->Fill(m, pt, w); } } if (ph1.isDispOK() && ph2.isDispOK()) { - hReDisp->Fill(m, pt); + hReDisp->Fill(m, pt, w); if (isPi0) { - hPi0SignalDisp->Fill(m, pt); + hPi0SignalDisp->Fill(m, pt, w); } if (ph1.isCPVOK() && ph2.isCPVOK()) { - hReBoth->Fill(m, pt); + hReBoth->Fill(m, pt, w); if (isPi0) { - hPi0SignalBoth->Fill(m, pt); + hPi0SignalBoth->Fill(m, pt, w); } } } @@ -427,26 +616,50 @@ struct phosPi0 { } // Mixed - for (auto ph1 : mCurEvent) { - for (auto mixEvent : mMixedEvents[mixedEventBin]) { - for (auto ph2 : mixEvent) { - double m = pow(ph1.e + ph2.e, 2) - pow(ph1.px + ph2.px, 2) - - pow(ph1.py + ph2.py, 2) - pow(ph1.pz + ph2.pz, 2); + for (const auto& ph1 : mCurEvent) { + for (const auto& mixEvent : mMixedEvents[mixedEventBin]) { + for (const auto& ph2 : mixEvent) { + double m = std::pow(ph1.e + ph2.e, 2) - std::pow(ph1.px + ph2.px, 2) - + std::pow(ph1.py + ph2.py, 2) - std::pow(ph1.pz + ph2.pz, 2); if (m > 0) { - m = sqrt(m); + m = std::sqrt(m); + } + double pt = std::sqrt(std::pow(ph1.px + ph2.px, 2) + + std::pow(ph1.py + ph2.py, 2)); + int modComb = moduleCombination(ph1.mod, ph2.mod); + double w = 1.; + if constexpr (isMC) { // correct MC energy + w = tofCutEff(ph1.e) * tofCutEff(ph2.e); + } + hMiMod->Fill(m, pt, modComb, w); + hMiAll->Fill(m, pt, w); + hMiOneAll->Fill(m, ph1.pt(), w); + hMiOneAll->Fill(m, ph2.pt(), w); + if (ph1.isCPVOK()) { + hMiOneCPV->Fill(m, ph1.pt(), w); + } + if (ph2.isCPVOK()) { + hMiOneCPV->Fill(m, ph2.pt(), w); + } + if (ph1.isDispOK()) { + hMiOneDisp->Fill(m, ph1.pt(), w); + if (ph1.isCPVOK()) { + hMiOneBoth->Fill(m, ph1.pt(), w); + } + } + if (ph2.isDispOK()) { + hMiOneDisp->Fill(m, ph2.pt(), w); + if (ph2.isCPVOK()) { + hMiOneBoth->Fill(m, ph2.pt(), w); + } } - double pt = sqrt(pow(ph1.px + ph2.px, 2) + - pow(ph1.py + ph2.py, 2)); - int modComb = ModuleCombination(ph1.mod, ph2.mod); - hMiMod->Fill(m, pt, modComb); - hMiAll->Fill(m, pt); if (ph1.isCPVOK() && ph2.isCPVOK()) { - hMiCPV->Fill(m, pt); + hMiCPV->Fill(m, pt, w); } if (ph1.isDispOK() && ph2.isDispOK()) { - hMiDisp->Fill(m, pt); + hMiDisp->Fill(m, pt, w); if (ph1.isCPVOK() && ph2.isCPVOK()) { - hMiBoth->Fill(m, pt); + hMiBoth->Fill(m, pt, w); } } } @@ -456,7 +669,7 @@ struct phosPi0 { // Fill events to store and remove oldest to keep buffer size if (mCurEvent.size() > 0) { mMixedEvents[mixedEventBin].emplace_back(mCurEvent); - if (mMixedEvents[mixedEventBin].size() > static_cast(mNMixedEvents)) { + if (mMixedEvents[mixedEventBin].size() > static_cast(nMixedEvents)) { mMixedEvents[mixedEventBin].pop_front(); } } @@ -480,31 +693,31 @@ struct phosPi0 { mCurEvent.clear(); for (const auto& clu : clusters) { // Fill QC histos - if (mFillQC) { + if (fillQC) { mHistManager.fill(HIST("hM02Clu"), clu.e(), clu.m02()); mHistManager.fill(HIST("hM20Clu"), clu.e(), clu.m20()); mHistManager.fill(HIST("hNcellClu"), clu.e(), clu.ncell(), clu.mod()); mHistManager.fill(HIST("cluETime"), clu.e(), clu.time(), clu.mod()); } - if (clu.e() < mMinCluE || - clu.ncell() < mMinCluNcell || - clu.time() > mMaxCluTime || clu.time() < mMinCluTime || - clu.m02() < mMinM02) { + if (clu.e() < minCluE || + clu.ncell() < minCluNcell || + clu.time() > maxCluTime || clu.time() < minCluTime || + clu.m02() < minM02) { continue; } - if (mFillQC) { + if (fillQC) { mHistManager.fill(HIST("cluSp"), clu.e(), clu.mod()); - if (clu.e() > mOccE) { + if (clu.e() > minOccE) { mHistManager.fill(HIST("cluOcc"), clu.x(), clu.z(), clu.mod()); if (clu.trackdist() > 2.) { mHistManager.fill(HIST("cluCPVOcc"), clu.x(), clu.z(), clu.mod()); mHistManager.fill(HIST("cluSpCPV"), clu.e(), clu.mod()); - if (TestLambda(clu.e(), clu.m02(), clu.m20())) { + if (testLambda(clu.e(), clu.m02(), clu.m20())) { mHistManager.fill(HIST("cluBothOcc"), clu.x(), clu.z(), clu.mod()); mHistManager.fill(HIST("cluSpBoth"), clu.e(), clu.mod()); } } - if (TestLambda(clu.e(), clu.m02(), clu.m20())) { + if (testLambda(clu.e(), clu.m02(), clu.m20())) { mHistManager.fill(HIST("cluDispOcc"), clu.x(), clu.z(), clu.mod()); mHistManager.fill(HIST("cluSpDisp"), clu.e(), clu.mod()); } @@ -512,17 +725,22 @@ struct phosPi0 { } int mcLabel = -1; - photon ph1(clu.px(), clu.py(), clu.pz(), clu.e(), clu.mod(), TestLambda(clu.e(), clu.m02(), clu.m20()), clu.trackdist() > mCPVCut, mcLabel); + double enCorr = 1; + if (isMC) { // correct MC energy + enCorr = nonlinearity(clu.e()); + } + Photon ph1(clu.px() * enCorr, clu.py() * enCorr, clu.pz() * enCorr, clu.e() * enCorr, clu.time(), clu.mod(), testLambda(clu.e(), clu.m02(), clu.m20()), clu.trackdist() > cpvCut, mcLabel); + // Mix with other photons added to stack - for (auto ph2 : mCurEvent) { - double m = pow(ph1.e + ph2.e, 2) - pow(ph1.px + ph2.px, 2) - - pow(ph1.py + ph2.py, 2) - pow(ph1.pz + ph2.pz, 2); + for (const auto& ph2 : mCurEvent) { + double m = std::pow(ph1.e + ph2.e, 2) - std::pow(ph1.px + ph2.px, 2) - + std::pow(ph1.py + ph2.py, 2) - std::pow(ph1.pz + ph2.pz, 2); if (m > 0) { - m = sqrt(m); + m = std::sqrt(m); } - double pt = sqrt(pow(ph1.px + ph2.px, 2) + - pow(ph1.py + ph2.py, 2)); - int modComb = ModuleCombination(ph1.mod, ph2.mod); + double pt = std::sqrt(std::pow(ph1.px + ph2.px, 2) + + std::pow(ph1.py + ph2.py, 2)); + int modComb = moduleCombination(ph1.mod, ph2.mod); hReMod->Fill(m, pt, modComb); hReAll->Fill(m, pt); @@ -542,17 +760,17 @@ struct phosPi0 { } // Mixed - for (auto ph1 : mCurEvent) { - for (auto mixEvent : mMixedEvents[mixedEventBin]) { - for (auto ph2 : mixEvent) { - double m = pow(ph1.e + ph2.e, 2) - pow(ph1.px + ph2.px, 2) - - pow(ph1.py + ph2.py, 2) - pow(ph1.pz + ph2.pz, 2); + for (const auto& ph1 : mCurEvent) { + for (const auto& mixEvent : mMixedEvents[mixedEventBin]) { + for (const auto& ph2 : mixEvent) { + double m = std::pow(ph1.e + ph2.e, 2) - std::pow(ph1.px + ph2.px, 2) - + std::pow(ph1.py + ph2.py, 2) - std::pow(ph1.pz + ph2.pz, 2); if (m > 0) { - m = sqrt(m); + m = std::sqrt(m); } - double pt = sqrt(pow(ph1.px + ph2.px, 2) + - pow(ph1.py + ph2.py, 2)); - int modComb = ModuleCombination(ph1.mod, ph2.mod); + double pt = std::sqrt(std::pow(ph1.px + ph2.px, 2) + + std::pow(ph1.py + ph2.py, 2)); + int modComb = moduleCombination(ph1.mod, ph2.mod); hMiMod->Fill(m, pt, modComb); hMiAll->Fill(m, pt); if (ph1.isCPVOK() && ph2.isCPVOK()) { @@ -571,41 +789,41 @@ struct phosPi0 { // Fill events to store and remove oldest to keep buffer size if (mCurEvent.size() > 0) { mMixedEvents[mixedEventBin].emplace_back(mCurEvent); - if (mMixedEvents[mixedEventBin].size() > static_cast(mNMixedEvents)) { + if (mMixedEvents[mixedEventBin].size() > static_cast(nMixedEvents)) { mMixedEvents[mixedEventBin].pop_front(); } } } - PROCESS_SWITCH(phosPi0, processBC, "processBC", false); + PROCESS_SWITCH(PhosPi0, processBC, "processBC", false); //_____________________________________________________________________________ - int ModuleCombination(int m1, int m2) + int moduleCombination(int m1, int m2) { // enumerates possible module combinations // (1,1)=0, (2,2)=1, (3,3)=2, (4,4)=3, (1,2)=(2,1)=4, (2,3)=(3,2)=5, (3,4)=(4,3)=6, (1,3)=(3,1)=7, // (2,4)=(4,2)=8, (1,4)=(4,1)=9 - int d = TMath::Abs(m1 - m2); + int d = std::abs(m1 - m2); if (d == 0) { return m1 - 1; } if (d == 1) { - return 3 + TMath::Min(m1, m2); + return 3 + std::min(m1, m2); } if (d == 2) { - return 6 + TMath::Min(m1, m2); + return 6 + std::min(m1, m2); } return 9; } //_____________________________________________________________________________ - bool TestLambda(float pt, float l1, float l2) + bool testLambda(float pt, float l1, float l2) { // Parameterization for full dispersion // Parameterizatino for full dispersion float l2Mean = 1.53126 + 9.50835e+06 / (1. + 1.08728e+07 * pt + 1.73420e+06 * pt * pt); - float l1Mean = 1.12365 + 0.123770 * TMath::Exp(-pt * 0.246551) + 5.30000e-03 * pt; + float l1Mean = 1.12365 + 0.123770 * std::exp(-pt * 0.246551) + 5.30000e-03 * pt; float l2Sigma = 6.48260e-02 + 7.60261e+10 / (1. + 1.53012e+11 * pt + 5.01265e+05 * pt * pt) + 9.00000e-03 * pt; float l1Sigma = 4.44719e-04 + 6.99839e-01 / (1. + 1.22497e+00 * pt + 6.78604e-07 * pt * pt) + 9.00000e-03 * pt; - float c = -0.35 - 0.550 * TMath::Exp(-0.390730 * pt); + float c = -0.35 - 0.550 * std::exp(-0.390730 * pt); return 0.5 * (l1 - l1Mean) * (l1 - l1Mean) / l1Sigma / l1Sigma + 0.5 * (l2 - l2Mean) * (l2 - l2Mean) / l2Sigma / l2Sigma + @@ -621,8 +839,8 @@ struct phosPi0 { if (res < 0) return 0; - if (res >= nMaxMixBins) - return nMaxMixBins - 1; + if (res >= kMaxMixBins) + return kMaxMixBins - 1; return res; } //---------------------------------------- @@ -639,23 +857,60 @@ struct phosPi0 { return mcParticles->iteratorAt(iparent1).pdgCode(); } auto parent2 = mcParticles->iteratorAt(iparent2); - if (parent2.mothersIds().size() == 0 || parent2.pdgCode() == 21 || abs(parent2.pdgCode()) < 11 || abs(parent2.pdgCode()) > 5000) { // no parents, parent not quark/gluon, strings + if (parent2.mothersIds().size() == 0 || parent2.pdgCode() == 21 || std::abs(parent2.pdgCode()) < 11 || std::abs(parent2.pdgCode()) > 5000) { // no parents, parent not quark/gluon, strings break; } iparent2 = parent2.mothersIds()[0]; } auto parent1 = mcParticles->iteratorAt(iparent1); - if (parent1.mothersIds().size() == 0 || parent1.pdgCode() == 21 || abs(parent1.pdgCode()) < 11 || abs(parent1.pdgCode()) > 5000) { // no parents, parent not quark/gluon, strings + if (parent1.mothersIds().size() == 0 || parent1.pdgCode() == 21 || std::abs(parent1.pdgCode()) < 11 || std::abs(parent1.pdgCode()) > 5000) { // no parents, parent not quark/gluon, strings return 0; } iparent1 = parent1.mothersIds()[0]; } return 0; // nothing found } + double nonlinearity(double e) + { + return nonlinA + nonlinB * std::exp(-e / nonlinC); + } + double tofCutEff(double en) + { + if (tofEffParam == 0) { + return 1.; + } + if (tofEffParam == 1) { // Run2 100 ns + // parameterization 01.08.2020 + if (en > 1.1) + en = 1.1; + if (en < 0.11) + en = 0.11; + return std::exp((-1.15295e+05 + 2.26754e+05 * en - 1.26063e+05 * en * en + en * en * en) / + (1. - 3.16443e+05 * en + 3.68044e+06 * en * en + en * en * en)); + } + if (tofEffParam == 2) { // Run2 30 ns + if (en > 1.6) + en = 1.6; + return 1. / (1. + std::exp((4.83230e+01 - 8.89758e+01 * en + 1.10897e+03 * en * en - 5.73755e+03 * en * en * en - + 1.43777e+03 * en * en * en * en) / + (1. - 1.23667e+02 * en + 1.07255e+03 * en * en + 5.87221e+02 * en * en * en))); + } + if (tofEffParam == 2) { // Run2 12.5 ns + if (en < 4.6) { + return std::exp(3.64952e-03 * + (-5.80032e+01 - 1.53442e+02 * en + 1.30994e+02 * en * en + -3.53094e+01 * en * en * en + en * en * en * en) / + (-7.75638e-02 + 8.64761e-01 * en + 1.22320e+00 * en * en - 1.00177e+00 * en * en * en + en * en * en * en)); + } else { + return 0.63922783 * (1. - 1.63273e-01 * std::tanh((en - 7.94528e+00) / 1.28997e+00)) * + (-4.39257e+00 * en + 2.25503e+00 * en * en + en * en * en) / (2.37160e+00 * en - 6.93786e-01 * en * en + en * en * en); + } + } + return 1.; + } }; o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& cfgc) { return o2::framework::WorkflowSpec{ - o2::framework::adaptAnalysisTask(cfgc)}; + o2::framework::adaptAnalysisTask(cfgc)}; } diff --git a/PWGHF/ALICE3/TableProducer/candidateCreatorChic.cxx b/PWGHF/ALICE3/TableProducer/candidateCreatorChic.cxx index af643fe92e9..e01b4fe0a6a 100644 --- a/PWGHF/ALICE3/TableProducer/candidateCreatorChic.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateCreatorChic.cxx @@ -15,6 +15,9 @@ /// /// \author Alessandro De Falco , Cagliari University +#include +#include + #include "CommonConstants/PhysicsConstants.h" #include "DCAFitter/DCAFitterN.h" #include "Framework/AnalysisTask.h" diff --git a/PWGHF/ALICE3/TableProducer/candidateCreatorX.cxx b/PWGHF/ALICE3/TableProducer/candidateCreatorX.cxx index 9f58eb93a75..2e3477dab99 100644 --- a/PWGHF/ALICE3/TableProducer/candidateCreatorX.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateCreatorX.cxx @@ -16,6 +16,9 @@ /// \author Rik Spijkers , Utrecht University /// \author Luca Micheletti , INFN +#include +#include + #include "CommonConstants/PhysicsConstants.h" #include "DCAFitter/DCAFitterN.h" #include "Framework/AnalysisTask.h" diff --git a/PWGHF/ALICE3/TableProducer/candidateSelectorChicToJpsiGamma.cxx b/PWGHF/ALICE3/TableProducer/candidateSelectorChicToJpsiGamma.cxx index affa3a6df99..5160a2ba99c 100644 --- a/PWGHF/ALICE3/TableProducer/candidateSelectorChicToJpsiGamma.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateSelectorChicToJpsiGamma.cxx @@ -15,6 +15,8 @@ /// /// \author Alessandro De Falco , Università/INFN Cagliari +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -46,7 +48,7 @@ struct HfCandidateSelectorChicToJpsiGamma { Configurable nSigmaTofMax{"nSigmaTofMax", 3., "Nsigma cut on TOF only"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_chic_to_jpsi_gamma::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_chic_to_jpsi_gamma::cuts[0], hf_cuts_chic_to_jpsi_gamma::nBinsPt, hf_cuts_chic_to_jpsi_gamma::nCutVars, hf_cuts_chic_to_jpsi_gamma::labelsPt, hf_cuts_chic_to_jpsi_gamma::labelsCutVar}, "Jpsi candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_chic_to_jpsi_gamma::Cuts[0], hf_cuts_chic_to_jpsi_gamma::NBinsPt, hf_cuts_chic_to_jpsi_gamma::NCutVars, hf_cuts_chic_to_jpsi_gamma::labelsPt, hf_cuts_chic_to_jpsi_gamma::labelsCutVar}, "Jpsi candidate selection per pT bin"}; HfHelper hfHelper; @@ -95,8 +97,8 @@ struct HfCandidateSelectorChicToJpsiGamma { return false; // CPA check } - if ((std::abs(hfCandChic.impactParameter0()) > cuts->get(pTBin, "d0 Jpsi"))) { // adf: Warning: no cut on photon - return false; // DCA check on daughters + if ((std::abs(hfCandChic.impactParameter0()) > cuts->get(pTBin, "d0 Jpsi"))) { // adf: Warning: no cut on photon + return false; // DCA check on daughters } // add more cuts: d0 product? PCA? diff --git a/PWGHF/ALICE3/TableProducer/candidateSelectorD0Alice3Barrel.cxx b/PWGHF/ALICE3/TableProducer/candidateSelectorD0Alice3Barrel.cxx index ebf4e98b930..705deeeaff2 100644 --- a/PWGHF/ALICE3/TableProducer/candidateSelectorD0Alice3Barrel.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateSelectorD0Alice3Barrel.cxx @@ -15,6 +15,9 @@ /// \author Nima Zardoshti , CERN /// \author Vít Kučera , CERN +#include +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -65,7 +68,7 @@ struct HfCandidateSelectorD0Alice3Barrel { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_d0_to_pi_k::cuts[0], hf_cuts_d0_to_pi_k::nBinsPt, hf_cuts_d0_to_pi_k::nCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_d0_to_pi_k::Cuts[0], hf_cuts_d0_to_pi_k::NBinsPt, hf_cuts_d0_to_pi_k::NCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; HfHelper hfHelper; diff --git a/PWGHF/ALICE3/TableProducer/candidateSelectorD0Alice3Forward.cxx b/PWGHF/ALICE3/TableProducer/candidateSelectorD0Alice3Forward.cxx index 5dadba32b98..a213c3edd04 100644 --- a/PWGHF/ALICE3/TableProducer/candidateSelectorD0Alice3Forward.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateSelectorD0Alice3Forward.cxx @@ -15,6 +15,9 @@ /// \author Nima Zardoshti , CERN /// \author Vít Kučera , CERN +#include +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -65,7 +68,7 @@ struct HfCandidateSelectorD0Alice3Forward { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_d0_to_pi_k::cuts[0], hf_cuts_d0_to_pi_k::nBinsPt, hf_cuts_d0_to_pi_k::nCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_d0_to_pi_k::Cuts[0], hf_cuts_d0_to_pi_k::NBinsPt, hf_cuts_d0_to_pi_k::NCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; HfHelper hfHelper; diff --git a/PWGHF/ALICE3/TableProducer/candidateSelectorD0ParametrizedPid.cxx b/PWGHF/ALICE3/TableProducer/candidateSelectorD0ParametrizedPid.cxx index b429b08cf10..6a46231b0c2 100644 --- a/PWGHF/ALICE3/TableProducer/candidateSelectorD0ParametrizedPid.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateSelectorD0ParametrizedPid.cxx @@ -15,6 +15,9 @@ /// \author Nima Zardoshti , CERN /// \author Vít Kučera , CERN +#include +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -65,7 +68,7 @@ struct HfCandidateSelectorD0ParametrizedPid { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_d0_to_pi_k::cuts[0], hf_cuts_d0_to_pi_k::nBinsPt, hf_cuts_d0_to_pi_k::nCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_d0_to_pi_k::Cuts[0], hf_cuts_d0_to_pi_k::NBinsPt, hf_cuts_d0_to_pi_k::NCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; HfHelper hfHelper; diff --git a/PWGHF/ALICE3/TableProducer/candidateSelectorJpsi.cxx b/PWGHF/ALICE3/TableProducer/candidateSelectorJpsi.cxx index 74690e954c3..391aba49da0 100644 --- a/PWGHF/ALICE3/TableProducer/candidateSelectorJpsi.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateSelectorJpsi.cxx @@ -16,6 +16,8 @@ /// \author Nima Zardoshti , CERN /// \author Vít Kučera , CERN +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" @@ -82,7 +84,7 @@ struct HfCandidateSelectorJpsi { Configurable nSigmaRichCombinedTofMax{"nSigmaRichCombinedTofMax", 5., "Nsigma cut on RICH combined with TOF"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_jpsi_to_e_e::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_jpsi_to_e_e::cuts[0], hf_cuts_jpsi_to_e_e::nBinsPt, hf_cuts_jpsi_to_e_e::nCutVars, hf_cuts_jpsi_to_e_e::labelsPt, hf_cuts_jpsi_to_e_e::labelsCutVar}, "Jpsi candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_jpsi_to_e_e::Cuts[0], hf_cuts_jpsi_to_e_e::NBinsPt, hf_cuts_jpsi_to_e_e::NCutVars, hf_cuts_jpsi_to_e_e::labelsPt, hf_cuts_jpsi_to_e_e::labelsCutVar}, "Jpsi candidate selection per pT bin"}; HfHelper hfHelper; TrackSelectorEl selectorElectron; diff --git a/PWGHF/ALICE3/TableProducer/candidateSelectorLcAlice3.cxx b/PWGHF/ALICE3/TableProducer/candidateSelectorLcAlice3.cxx index 8fae8fe6e6f..c9abeedad39 100644 --- a/PWGHF/ALICE3/TableProducer/candidateSelectorLcAlice3.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateSelectorLcAlice3.cxx @@ -16,6 +16,8 @@ /// \author Nima Zardoshti , CERN /// \author Vít Kučera , CERN +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -67,7 +69,7 @@ struct HfCandidateSelectorLcAlice3 { // topological cuts Configurable decayLengthXYNormalisedMin{"decayLengthXYNormalisedMin", 3., "Min. normalised decay length"}; Configurable> binsPt{"binsPt", std::vector{hf_cuts_lc_to_p_k_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_lc_to_p_k_pi::cuts[0], hf_cuts_lc_to_p_k_pi::nBinsPt, hf_cuts_lc_to_p_k_pi::nCutVars, hf_cuts_lc_to_p_k_pi::labelsPt, hf_cuts_lc_to_p_k_pi::labelsCutVar}, "Lc candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_lc_to_p_k_pi::Cuts[0], hf_cuts_lc_to_p_k_pi::NBinsPt, hf_cuts_lc_to_p_k_pi::NCutVars, hf_cuts_lc_to_p_k_pi::labelsPt, hf_cuts_lc_to_p_k_pi::labelsCutVar}, "Lc candidate selection per pT bin"}; HfHelper hfHelper; diff --git a/PWGHF/ALICE3/TableProducer/candidateSelectorLcParametrizedPid.cxx b/PWGHF/ALICE3/TableProducer/candidateSelectorLcParametrizedPid.cxx index 491b15a04d2..0a3210a63f6 100644 --- a/PWGHF/ALICE3/TableProducer/candidateSelectorLcParametrizedPid.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateSelectorLcParametrizedPid.cxx @@ -16,6 +16,8 @@ /// \author Nima Zardoshti , CERN /// \author Vít Kučera , CERN +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -68,7 +70,7 @@ struct HfCandidateSelectorLcParametrizedPid { // topological cuts Configurable decayLengthXYNormalisedMin{"decayLengthXYNormalisedMin", 3., "Normalised decay length"}; Configurable> binsPt{"binsPt", std::vector{hf_cuts_lc_to_p_k_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_lc_to_p_k_pi::cuts[0], hf_cuts_lc_to_p_k_pi::nBinsPt, hf_cuts_lc_to_p_k_pi::nCutVars, hf_cuts_lc_to_p_k_pi::labelsPt, hf_cuts_lc_to_p_k_pi::labelsCutVar}, "Lc candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_lc_to_p_k_pi::Cuts[0], hf_cuts_lc_to_p_k_pi::NBinsPt, hf_cuts_lc_to_p_k_pi::NCutVars, hf_cuts_lc_to_p_k_pi::labelsPt, hf_cuts_lc_to_p_k_pi::labelsCutVar}, "Lc candidate selection per pT bin"}; HfHelper hfHelper; diff --git a/PWGHF/ALICE3/TableProducer/candidateSelectorXToJpsiPiPi.cxx b/PWGHF/ALICE3/TableProducer/candidateSelectorXToJpsiPiPi.cxx index 62a542d94f9..bff87d84e70 100644 --- a/PWGHF/ALICE3/TableProducer/candidateSelectorXToJpsiPiPi.cxx +++ b/PWGHF/ALICE3/TableProducer/candidateSelectorXToJpsiPiPi.cxx @@ -16,6 +16,8 @@ /// \author Rik Spijkers , Utrecht University /// \author Luca Micheletti , INFN +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -47,7 +49,7 @@ struct HfCandidateSelectorXToJpsiPiPi { Configurable nSigmaTofMax{"nSigmaTofMax", 3., "Nsigma cut on TOF only"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_x_to_jpsi_pi_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_x_to_jpsi_pi_pi::cuts[0], hf_cuts_x_to_jpsi_pi_pi::nBinsPt, hf_cuts_x_to_jpsi_pi_pi::nCutVars, hf_cuts_x_to_jpsi_pi_pi::labelsPt, hf_cuts_x_to_jpsi_pi_pi::labelsCutVar}, "Jpsi candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_x_to_jpsi_pi_pi::Cuts[0], hf_cuts_x_to_jpsi_pi_pi::NBinsPt, hf_cuts_x_to_jpsi_pi_pi::NCutVars, hf_cuts_x_to_jpsi_pi_pi::labelsPt, hf_cuts_x_to_jpsi_pi_pi::labelsCutVar}, "Jpsi candidate selection per pT bin"}; HfHelper hfHelper; diff --git a/PWGHF/ALICE3/Tasks/taskChic.cxx b/PWGHF/ALICE3/Tasks/taskChic.cxx index 026f781f6f4..f8cb85454a1 100644 --- a/PWGHF/ALICE3/Tasks/taskChic.cxx +++ b/PWGHF/ALICE3/Tasks/taskChic.cxx @@ -15,6 +15,8 @@ /// \author Gian Michele Innocenti , CERN /// \author Alessandro De Falco , Cagliari University +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" diff --git a/PWGHF/ALICE3/Tasks/taskJpsi.cxx b/PWGHF/ALICE3/Tasks/taskJpsi.cxx index f3bcbd8dcb2..a9210ccca86 100644 --- a/PWGHF/ALICE3/Tasks/taskJpsi.cxx +++ b/PWGHF/ALICE3/Tasks/taskJpsi.cxx @@ -16,6 +16,8 @@ /// \author Vít Kučera , CERN /// \author Biao Zhang , CCNU +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" diff --git a/PWGHF/ALICE3/Tasks/taskQaPidRejection.cxx b/PWGHF/ALICE3/Tasks/taskQaPidRejection.cxx index e3fcba65268..f0e819e3086 100644 --- a/PWGHF/ALICE3/Tasks/taskQaPidRejection.cxx +++ b/PWGHF/ALICE3/Tasks/taskQaPidRejection.cxx @@ -16,6 +16,9 @@ /// \author Henrique J C Zanoli , Utrecht University /// \author Nicolo' Jacazio , CERN +#include +#include + #include #include #include diff --git a/PWGHF/ALICE3/Tasks/taskX.cxx b/PWGHF/ALICE3/Tasks/taskX.cxx index 610f9f94a33..f090eb57876 100644 --- a/PWGHF/ALICE3/Tasks/taskX.cxx +++ b/PWGHF/ALICE3/Tasks/taskX.cxx @@ -16,6 +16,8 @@ /// \author Rik Spijkers , Utrecht University /// \author Luca Micheletti , INFN +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" diff --git a/PWGHF/Core/CentralityEstimation.h b/PWGHF/Core/CentralityEstimation.h index 203cc4680c8..bd1746c4604 100644 --- a/PWGHF/Core/CentralityEstimation.h +++ b/PWGHF/Core/CentralityEstimation.h @@ -16,6 +16,8 @@ #ifndef PWGHF_CORE_CENTRALITYESTIMATION_H_ #define PWGHF_CORE_CENTRALITYESTIMATION_H_ +#include + namespace o2::hf_centrality { // centrality selection estimators @@ -30,32 +32,27 @@ enum CentralityEstimator { }; template -concept hasFT0ACent = requires(T collision) -{ +concept hasFT0ACent = requires(T collision) { collision.centFT0A(); }; template -concept hasFT0CCent = requires(T collision) -{ +concept hasFT0CCent = requires(T collision) { collision.centFT0C(); }; template -concept hasFT0MCent = requires(T collision) -{ +concept hasFT0MCent = requires(T collision) { collision.centFT0M(); }; template -concept hasFV0ACent = requires(T collision) -{ +concept hasFV0ACent = requires(T collision) { collision.centFV0A(); }; template -concept hasNTracksPVCent = requires(T collision) -{ +concept hasNTracksPVCent = requires(T collision) { collision.centNTPV(); }; diff --git a/PWGHF/Core/DecayChannels.h b/PWGHF/Core/DecayChannels.h new file mode 100644 index 00000000000..abc8ac291a6 --- /dev/null +++ b/PWGHF/Core/DecayChannels.h @@ -0,0 +1,258 @@ +// 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. + +/// \file DecayChannels.h +/// \brief Definitions of constants for MC flagging of HF decay channels. +/// \author Vít Kučera , Inha University +/// \note DecayChannelMain enums define unique combinations of the mother and the daughters for main channels. +/// \note DecayChannelResonant enums define unique combinations of the mother and the daughters for resonant channels. +/// \note Value 0 is reserved to indicate no match. +/// \note Daughter ordering convention: (charm|strange|π±|K±|π0), (baryon|meson), (+|−) + +#ifndef PWGHF_CORE_DECAYCHANNELS_H_ +#define PWGHF_CORE_DECAYCHANNELS_H_ + +#include + +namespace o2::hf_decay +{ + +// TODO +// - HF cascades (Λc+ → p K0short) +// - HF cascades to LF cascades (Ωc0/Ξc0 → Ξ+ π−, Ξc+ → Ξ+ π− π+) +// - Σc + +namespace hf_cand_2prong +{ +/// @brief 2-prong candidates: main channels +enum DecayChannelMain : int8_t { + // D0 + D0ToPiK = 1, // π+ K− + D0ToPiKPi0 = 2, // π+ K− π0 + D0ToPiPi = 3, // π+ π− + D0ToPiPiPi0 = 4, // π+ π− π0 + D0ToKK = 5, // K+ K− + // J/ψ + JpsiToEE = 6, // e+ e− + JpsiToMuMu = 7, // μ+ μ− + // + NChannelsMain = JpsiToMuMu // last channel +}; +/// @brief 2-prong candidates: resonant channels +enum DecayChannelResonant : int8_t { + // D0 + D0ToRhoplusPi = 1, // ρ+ π− + D0ToRhoplusK = 2, // ρ+ K− + D0ToKstar0Pi0 = 3, // anti-K*0 π0 + D0ToKstarPi = 4, // K*− π+ + // + NChannelsResonant = D0ToKstarPi // last channel +}; +} // namespace hf_cand_2prong + +namespace hf_cand_3prong +{ +/// @brief 3-prong candidates: main channels +enum DecayChannelMain : int8_t { + // D+ + DplusToPiKPi = 1, // π+ K− π+ + DplusToPiKPiPi0 = 2, // π+ K− π+ π0 + DplusToPiPiPi = 3, // π+ π− π+ + DplusToPiKK = 4, // π+ K− K+ + // Ds+ + DsToPiKK = 5, // π+ K− K+ + DsToPiKKPi0 = 6, // π+ K− K+ π0 + DsToPiPiK = 7, // π+ π− K+ + DsToPiPiPi = 8, // π+ π− π+ + DsToPiPiPiPi0 = 9, // π+ π− π+ π0 + // D*+ + DstarToPiKPi = 10, // π+ K− π+ (from [(D0 → π+ K−) π+]) + DstarToPiKPiPi0 = 11, // π+ K− π+ π0 + DstarToPiKPiPi0Pi0 = 12, // π+ K− π+ π0 π0 + DstarToPiKK = 13, // π+ K− K+ + DstarToPiKKPi0 = 14, // π+ K− K+ π0 + DstarToPiPiPi = 15, // π+ π− π+ + DstarToPiPiPiPi0 = 16, // π+ π− π+ π0 + // Λc+ + LcToPKPi = 17, // p K− π+ + LcToPKPiPi0 = 18, // p K− π+ π0 + LcToPPiPi = 19, // p π− π+ + LcToPKK = 20, // p K− K+ + // Ξc+ + XicToPKPi = 21, // p K− π+ + XicToPKK = 22, // p K− K+ + XicToSPiPi = 23, // Σ+ π− π+ + // + NChannelsMain = XicToSPiPi // last channel +}; +/// @brief 3-prong candidates: resonant channels +enum DecayChannelResonant : int8_t { + // D+ + DplusToPhiPi = 1, // φ π+ + DplusToKstar0K = 2, // anti-K*0 K+ + DplusToKstar1430_0K = 3, // anti-K*0(1430) K+ + DplusToRho0Pi = 4, // ρ0 π+ + DplusToF2_1270Pi = 5, // f2(1270) π+ + // Ds+ + DsToPhiPi = 6, // φ π+ + DsToPhiRhoplus = 7, // φ ρ+ + DsToKstar0K = 8, // anti-K*0 K+ + DsToKstar0Pi = 9, // anti-K*0 π+ + DsToRho0Pi = 10, // ρ0 π+ + DsToRho0K = 11, // ρ0 K+ + DsToF2_1270Pi = 12, // f2(1270) π+ + DsToF0_1370K = 13, // f0(1370) K+ + DsToEtaPi = 14, // η π+ + // D*+ + DstarToD0ToRhoplusPi = 15, // ρ+ π− + DstarToD0ToRhoplusK = 16, // ρ+ K− + DstarToD0ToKstar0Pi0 = 17, // anti-K*0 π0 + DstarToD0ToKstarPi = 18, // K*− π+ + DstarToDplusToPhiPi = 19, // φ π+ + DstarToDplusToKstar0K = 20, // anti-K*0 K+ + DstarToDplusToKstar1430_0K = 21, // anti-K*0(1430) K+ + DstarToDplusToRho0Pi = 22, // ρ0 π+ + DstarToDplusToF2_1270Pi = 23, // f2(1270) π+ + // Λc+ + LcToPKstar0 = 24, // p anti-K*0(892) + LcToDeltaplusplusK = 25, // Δ++ K− + LcToL1520Pi = 26, // Λ(1520) π+ + // Ξc+ + XicToPKstar0 = 27, // p anti-K*0(892) + XicToPPhi = 28, // p φ + // + NChannelsResonant = XicToPPhi // last channel +}; +} // namespace hf_cand_3prong + +namespace hf_cand_dstar +{ +/// @brief D*+ candidates: main channels +enum DecayChannelMain : int8_t { + // D*+ + DstarToPiKPi = 1, // π+ K− π+ (from [(D0 → π+ K−) π+]) + DstarToPiKPiPi0 = 2, // π+ K− π+ π0 (from [(D0 → π+ K− π0) π+] or [(D+ → π+ K− π+) π0]) + // + NChannelsMain = DstarToPiKPiPi0 // last channel +}; +} // namespace hf_cand_dstar + +namespace hf_cand_beauty +{ +/// @brief beauty candidates: main channels +enum DecayChannelMain : int8_t { + // B0 + B0ToDminusPi = 1, // D− π+ + B0ToDminusPiPi0 = 2, // D− π+ π0 + B0ToDminusPiGamma = 3, // D− π+ γ0 + B0ToDminusK = 4, // D− K+ + B0ToD0PiPi = 5, // anti-D0 π+ π− + B0ToDsPi = 19, // Ds− π+ + // Bs0 + BsToDsPi = 6, // Ds− π+ + BsToDsPiPi0 = 7, // Ds− π+ π0 + BsToDsPiGamma = 8, // Ds− π+ γ0 + BsToDsK = 9, // Ds− K+ + // Λb0 + LbToLcPi = 10, // Λc+ π− + LbToLcPiPi0 = 11, // Λc+ π− π0 + LbToLcPiGamma = 12, // Λc+ π− γ0 + LbToLcK = 13, // Λc+ K− + LbToLcKPi0 = 14, // Λc+ K− π0 + // B+ + BplusToD0Pi = 15, // anti-D0 π+ + BplusToD0PiPi0 = 16, // anti-D0 π+ π0 + BplusToD0PiGamma = 17, // anti-D0 π+ γ0 + BplusToD0K = 18, // anti-D0 K+ + // + NChannelsMain = B0ToDsPi // last channel +}; +/// @brief beauty candidates: resonant channels +enum DecayChannelResonant : int8_t { + // B0 + B0ToDminusRhoplus = 1, // D− ρ+ + B0ToDstarminusPi = 2, // D*− π+ + // Bs0 + BsToDsRhoplus = 3, // Ds− ρ+ + BsToDsstarPi = 4, // Ds*− π+ + // Λb0 + LbToLcRhoplus = 5, // Λc+ ρ− + LbToScPi = 6, // Σc+ π− + LbToScK = 7, // Σc+ K− + LbToSc0Pi0 = 8, // Σc0 π0 + // B+ + BplusToD0Rhoplus = 9, // anti-D0 ρ+ + BplusToDstar0Pi = 10, // anti-D*0 π+ + // + NChannelsResonant = BplusToDstar0Pi // last channel +}; +/// @brief beauty candidates: beauty to J/ψ decay channels +enum DecayChannelToJpsiMain : int8_t { + // B0 + B0ToJpsiPiK = 1, // J/ψ π− K+ + // Bs0 + BsToJpsiKK = 2, // J/ψ K+ K− + // Λb0 + LbToJpsiPK = 3, // J/ψ p K− + // B+ + BplusToJpsiK = 4, // J/ψ K+ + // Bc+ + BcToJpsiPi = 5, // J/ψ π+ + // + NChannelsToJpsiMain = BcToJpsiPi // last channel +}; +/// @brief beauty candidates: beauty to J/ψ resonant decay channels +enum DecayChannelToJpsiResonant : int8_t { + // B0 + B0ToJpsiKstar0 = 1, // J/ψ K*0(892) + // Bs0 + BsToJpsiPhi = 2, // J/ψ φ + // + NChannelsToJpsiResonant = BsToJpsiPhi // last channel +}; +} // namespace hf_cand_beauty + +namespace hf_cand_reso +{ +/// @brief resonance candidates: main channels +enum DecayChannelMain : int8_t { + // D1(2420)0 + D1zeroToDstarPi = 1, // D*+ π- + // D2*(2460)0 + D2starzeroToDplusPi = 2, // D+ π− + D2starzeroToDstarPi = 3, // D*+ π- + // D2*(2460)+ + D2starplusToD0Pi = 4, // D0 π+ + // Ds1(2536)+ + Ds1ToDstarK0s = 5, // D*+ K0s + // Ds2*(2573)+ + Ds2starToD0Kplus = 6, // D0 K+ + Ds2starToDplusK0s = 7, // D+ K0s + Ds2starToDstarK0s = 8, // D*+ K0s + // Ds1*(2700)+ + Ds1star2700ToDstarK0s = 9, // D*+ K0s + // Ds1*(2860)+ + Ds1star2860ToDstarK0s = 10, // D*+ K0s + // Ds3*(2860)+ + Ds3star2860ToDstarK0s = 11, // D*+ K0s + // Xic(3055)0 + Xic3055zeroToD0Lambda = 12, // D0 Λ + // Xic(3055)+ + Xic3055plusToDplusLambda = 13, // D+ Λ + // Xic(3080)0 + Xic3080zeroToD0Lambda = 14, // D0 Λ + // Xic(3080)+ + Xic3080plusToDplusLambda = 15 // D+ Λ +}; +} // namespace hf_cand_reso +} // namespace o2::hf_decay + +#endif // PWGHF_CORE_DECAYCHANNELS_H_ diff --git a/PWGHF/Core/HfHelper.h b/PWGHF/Core/HfHelper.h index 9419ebaa8c6..41239c48179 100644 --- a/PWGHF/Core/HfHelper.h +++ b/PWGHF/Core/HfHelper.h @@ -17,16 +17,21 @@ #ifndef PWGHF_CORE_HFHELPER_H_ #define PWGHF_CORE_HFHELPER_H_ -#include -#include -#include - -#include "CommonConstants/PhysicsConstants.h" +#include "PWGHF/Utils/utilsAnalysis.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelectorPID.h" -#include "PWGHF/Utils/utilsAnalysis.h" +#include +#include + +#include +#include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) +#include + +#include +#include +#include class HfHelper { @@ -169,6 +174,12 @@ class HfHelper return candidate.m(std::array{o2::constants::physics::MassD0, o2::constants::physics::MassPiPlus}); } + template + auto invMassBplusToJpsiK(const T& candidate) + { + return candidate.m(std::array{o2::constants::physics::MassMuon, o2::constants::physics::MassMuon, o2::constants::physics::MassKPlus}); + } + template auto cosThetaStarBplus(const T& candidate) { @@ -655,6 +666,12 @@ class HfHelper return candidate.m(std::array{o2::constants::physics::MassDSBar, o2::constants::physics::MassPiPlus}); } + template + auto invMassBsToJpsiPhi(const T& candidate) + { + return candidate.m(std::array{o2::constants::physics::MassMuon, o2::constants::physics::MassMuon, o2::constants::physics::MassKPlus, o2::constants::physics::MassKPlus}); + } + template auto cosThetaStarBs(const T& candidate) { @@ -780,8 +797,7 @@ class HfHelper /// \param pidTrackPi PID status of trackPi (prong1 of B0 candidate) /// \param acceptPIDNotApplicable switch to accept Status::NotApplicable /// \return true if prong1 of B0 candidate passes all selections - template - bool selectionB0ToDPiPid(const T1& pidTrackPi, const T2& acceptPIDNotApplicable) + bool selectionB0ToDPiPid(const int pidTrackPi, const bool acceptPIDNotApplicable) { if (!acceptPIDNotApplicable && pidTrackPi != TrackSelectorPID::Accepted) { return false; @@ -801,10 +817,10 @@ class HfHelper template bool selectionBplusToD0PiTopol(const T1& candBp, const T2& cuts, const T3& binsPt) { - auto ptcandBp = candBp.pt(); + auto ptCandBp = candBp.pt(); auto ptPi = RecoDecay::pt(candBp.pxProng1(), candBp.pyProng1()); - int pTBin = o2::analysis::findBin(binsPt, ptcandBp); + int pTBin = o2::analysis::findBin(binsPt, ptCandBp); if (pTBin == -1) { return false; } @@ -856,8 +872,7 @@ class HfHelper /// \param pidTrackPi PID status of trackPi (prong1 of B+ candidate) /// \param acceptPIDNotApplicable switch to accept Status::NotApplicable /// \return true if prong1 of B+ candidate passes all selections - template - bool selectionBplusToD0PiPid(const T1& pidTrackPi, const T2& acceptPIDNotApplicable) + bool selectionBplusToD0PiPid(const int pidTrackPi, const bool acceptPIDNotApplicable) { if (!acceptPIDNotApplicable && pidTrackPi != TrackSelectorPID::Accepted) { return false; @@ -869,6 +884,105 @@ class HfHelper return true; } + // Apply topological cuts as defined in SelectorCuts.h + /// \param candBp B+ candidate + /// \param cuts B+ candidate selection per pT bin + /// \param binsPt pT bin limits + /// \return true if candidate passes all selections + template + bool selectionBplusToJpsiKTopol(const T1& candBp, const T2& cuts, const T3& binsPt) + { + auto ptCandBp = candBp.pt(); + auto mCandBp = invMassBplusToJpsiK(candBp); + auto ptJpsi = RecoDecay::pt(candBp.pxProng0(), candBp.pyProng0()); + auto ptKa = RecoDecay::pt(candBp.pxProng1(), candBp.pyProng1()); + auto candJpsi = candBp.jpsi(); + float pseudoPropDecLen = candBp.decayLengthXY() * mCandBp / ptCandBp; + + int binPt = o2::analysis::findBin(binsPt, ptCandBp); + if (binPt == -1) { + return false; + } + + // B+ mass cut + if (std::abs(mCandBp - o2::constants::physics::MassBPlus) > cuts->get(binPt, "m")) { + return false; + } + + // kaon pt + if (ptKa < cuts->get(binPt, "pT K")) { + return false; + } + + // J/Psi pt + if (ptJpsi < cuts->get(binPt, "pT J/Psi")) { + return false; + } + + // J/Psi mass + if (std::abs(candJpsi.m() - o2::constants::physics::MassJPsi) < cuts->get(binPt, "DeltaM J/Psi")) { + return false; + } + + // d0(J/Psi)xd0(K) + if (candBp.impactParameterProduct() > cuts->get(binPt, "B Imp. Par. Product")) { + return false; + } + + // B+ Decay length + if (candBp.decayLength() < cuts->get(binPt, "B decLen")) { + return false; + } + + // B+ Decay length XY + if (candBp.decayLengthXY() < cuts->get(binPt, "B decLenXY")) { + return false; + } + + // B+ CPA cut + if (candBp.cpa() < cuts->get(binPt, "CPA")) { + return false; + } + + // B+ CPAXY cut + if (candBp.cpaXY() < cuts->get(binPt, "CPAXY")) { + return false; + } + + // d0 of K + if (std::abs(candBp.impactParameter1()) < cuts->get(binPt, "d0 K")) { + return false; + } + + // d0 of J/Psi + if (std::abs(candBp.impactParameter0()) < cuts->get(binPt, "d0 J/Psi")) { + return false; + } + + // B pseudoproper decay length + if (pseudoPropDecLen < cuts->get(binPt, "B pseudoprop. decLen")) { + return false; + } + + return true; + } + + /// Apply PID selection + /// \param pidTrackKa PID status of trackKa (prong1 of B+ candidate) + /// \param acceptPIDNotApplicable switch to accept Status::NotApplicable + /// \return true if prong1 of B+ candidate passes all selections + bool selectionBplusToJpsiKPid(const int pidTrackKa, const bool acceptPIDNotApplicable) + { + if (!acceptPIDNotApplicable && pidTrackKa != TrackSelectorPID::Accepted) { + return false; + } + if (acceptPIDNotApplicable && pidTrackKa == TrackSelectorPID::Rejected) { + return false; + } + + return true; + } + /// Apply topological cuts as defined in SelectorCuts.h /// \param candBs Bs candidate /// \param cuts Bs candidate selections @@ -943,8 +1057,196 @@ class HfHelper /// \param pidTrackPi PID status of trackPi (prong1 of Bs candidate) /// \param acceptPIDNotApplicable switch to accept Status::NotApplicable /// \return true if prong1 of Bs candidate passes all selections - template - bool selectionBsToDsPiPid(const T1& pidTrackPi, const T2& acceptPIDNotApplicable) + bool selectionBsToDsPiPid(const int pidTrackPi, const bool acceptPIDNotApplicable) + { + if (!acceptPIDNotApplicable && pidTrackPi != TrackSelectorPID::Accepted) { + return false; + } + if (acceptPIDNotApplicable && pidTrackPi == TrackSelectorPID::Rejected) { + return false; + } + + return true; + } + + // Apply topological cuts as defined in SelectorCuts.h + /// \param candBs Bs candidate + /// \param candKa0 kaon candidate 0 (phi daughter) + /// \param candKa1 kaon candidate 1 (phi daughter) + /// \param cuts Bs candidate selection per pT bin + /// \param binsPt pT bin limits + /// \return true if candidate passes all selections + template + bool selectionBsToJpsiPhiTopol(const T1& candBs, const T2& candKa0, const T3& candKa1, const T4& cuts, const T5& binsPt) + { + auto ptCandBs = candBs.pt(); + auto mCandBs = invMassBsToJpsiPhi(candBs); + std::array pVecKa0 = candKa0.pVector(); + std::array pVecKa1 = candKa1.pVector(); + auto mCandPhi = RecoDecay::m(std::array{pVecKa0, pVecKa1}, std::array{o2::constants::physics::MassKPlus, o2::constants::physics::MassKPlus}); + auto ptJpsi = RecoDecay::pt(candBs.pxProng0(), candBs.pyProng0()); + auto candJpsi = candBs.jpsi(); + float pseudoPropDecLen = candBs.decayLengthXY() * mCandBs / ptCandBs; + + int binPt = o2::analysis::findBin(binsPt, ptCandBs); + if (binPt == -1) { + return false; + } + + // Bs mass cut + if (std::abs(mCandBs - o2::constants::physics::MassBPlus) > cuts->get(binPt, "m")) { + return false; + } + + // kaon pt + if (candKa0.pt() < cuts->get(binPt, "pT K") && + candKa1.pt() < cuts->get(binPt, "pT K")) { + return false; + } + + // J/Psi pt + if (ptJpsi < cuts->get(binPt, "pT J/Psi")) { + return false; + } + + // phi mass + if (std::abs(mCandPhi - o2::constants::physics::MassPhi) < cuts->get(binPt, "DeltaM phi")) { + return false; + } + + // J/Psi mass + if (std::abs(candJpsi.m() - o2::constants::physics::MassJPsi) < cuts->get(binPt, "DeltaM J/Psi")) { + return false; + } + + // d0(J/Psi)xd0(phi) + if (candBs.impactParameterProduct() > cuts->get(binPt, "B Imp. Par. Product")) { + return false; + } + + // Bs Decay length + if (candBs.decayLength() < cuts->get(binPt, "B decLen")) { + return false; + } + + // Bs Decay length XY + if (candBs.decayLengthXY() < cuts->get(binPt, "B decLenXY")) { + return false; + } + + // Bs CPA cut + if (candBs.cpa() < cuts->get(binPt, "CPA")) { + return false; + } + + // Bs CPAXY cut + if (candBs.cpaXY() < cuts->get(binPt, "CPAXY")) { + return false; + } + + // d0 of phi + if (std::abs(candBs.impactParameter1()) < cuts->get(binPt, "d0 phi")) { + return false; + } + + // d0 of J/Psi + if (std::abs(candBs.impactParameter0()) < cuts->get(binPt, "d0 J/Psi")) { + return false; + } + + // B pseudoproper decay length + if (pseudoPropDecLen < cuts->get(binPt, "B pseudoprop. decLen")) { + return false; + } + + return true; + } + + /// Apply PID selection + /// \param pidTrackKa PID status of trackKa (prong1 of B+ candidate) + /// \param acceptPIDNotApplicable switch to accept Status::NotApplicable + /// \return true if prong1 of B+ candidate passes all selections + bool selectionBsToJpsiPhiPid(const int pidTrackKa, const bool acceptPIDNotApplicable) + { + if (!acceptPIDNotApplicable && pidTrackKa != TrackSelectorPID::Accepted) { + return false; + } + if (acceptPIDNotApplicable && pidTrackKa == TrackSelectorPID::Rejected) { + return false; + } + + return true; + } + + /// Apply topological cuts as defined in SelectorCuts.h + /// \param candLb Lb candidate + /// \param cuts Lb candidate selection per pT bin" + /// \param binsPt pT bin limits + /// \return true if candidate passes all selections + template + bool selectionLbToLcPiTopol(const T1& candLb, const T2& cuts, const T3& binsPt) + { + auto ptCandLb = candLb.pt(); + auto ptLc = candLb.ptProng0(); + auto ptPi = candLb.ptProng1(); + + int pTBin = o2::analysis::findBin(binsPt, ptCandLb); + if (pTBin == -1) { + return false; + } + + // Lb mass cut + if (std::abs(invMassLbToLcPi(candLb) - o2::constants::physics::MassLambdaB0) > cuts->get(pTBin, "m")) { + return false; + } + + // pion pt + if (ptPi < cuts->get(pTBin, "pT Pi")) { + return false; + } + + // Lc pt + if (ptLc < cuts->get(pTBin, "pT Lc+")) { + return false; + } + + // Lb Decay length + if (candLb.decayLength() < cuts->get(pTBin, "Lb decLen")) { + return false; + } + + // Lb Decay length XY + if (candLb.decayLengthXY() < cuts->get(pTBin, "Lb decLenXY")) { + return false; + } + + // Lb chi2PCA cut + if (candLb.chi2PCA() > cuts->get(pTBin, "Chi2PCA")) { + return false; + } + + // Lb CPA cut + if (candLb.cpa() < cuts->get(pTBin, "CPA")) { + return false; + } + + // d0 of pi + if (std::abs(candLb.impactParameter1()) < cuts->get(pTBin, "d0 Pi")) { + return false; + } + + // d0 of Lc + if (std::abs(candLb.impactParameter0()) < cuts->get(pTBin, "d0 Lc+")) { + return false; + } + + return true; + } + + /// \param pidTrackPi PID status of trackPi (prong1 of Lb candidate) + /// \param acceptPIDNotApplicable switch to accept Status::NotApplicable + /// \return true if prong1 of Lb candidate passes all selections + bool selectionLbToLcPiPid(const int pidTrackPi, const bool acceptPIDNotApplicable) { if (!acceptPIDNotApplicable && pidTrackPi != TrackSelectorPID::Accepted) { return false; @@ -962,7 +1264,7 @@ class HfHelper /// \param mlScores vector with ml scores of charm hadron (position 0:bkg 1:prompt 2:nonprompt) /// \return true if b-hadron candidate passes all selections template - bool applySelectionDmesMlScoresForB(const T1& cuts, const T2& binsPtC, float ptC, std::vector mlScores) + bool applySelectionDmesMlScoresForB(const T1& cuts, const T2& binsPtC, float ptC, const std::vector& mlScores) { int pTBin = o2::analysis::findBin(binsPtC, ptC); if (pTBin == -1) { diff --git a/PWGHF/Core/HfMlResponseB0ToDPi.h b/PWGHF/Core/HfMlResponseB0ToDPi.h index 18584ae5258..1f6d4940b7f 100644 --- a/PWGHF/Core/HfMlResponseB0ToDPi.h +++ b/PWGHF/Core/HfMlResponseB0ToDPi.h @@ -9,26 +9,28 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file HfMlResponsB0ToDPi.h +/// \file HfMlResponseB0ToDPi.h /// \brief Class to compute the ML response for B0 → D∓ π± analysis selections /// \author Alexandre Bigot , IPHC Strasbourg +/// \author Vít Kučera , Inha University #ifndef PWGHF_CORE_HFMLRESPONSEB0TODPI_H_ #define PWGHF_CORE_HFMLRESPONSEB0TODPI_H_ -#include -#include -#include - #include "PWGHF/Core/HfMlResponse.h" #include "PWGHF/D2H/Utils/utilsRedDataFormat.h" +#include "Tools/ML/MlResponse.h" + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures -#define FILL_MAP_B0(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesB0ToDPi::FEATURE) \ +#define FILL_MAP_B0(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesB0ToDPi::FEATURE) \ } // Check if the index of mCachedIndices (index associated to a FEATURE) @@ -59,6 +61,14 @@ break; \ } +// +// Make FEATURE from an element of VECTOR at INDEX. +#define CHECK_AND_FILL_VEC_B0_INDEX(FEATURE, VECTOR, INDEX) \ + case static_cast(InputFeaturesB0ToDPi::FEATURE): { \ + inputFeatures.emplace_back((VECTOR)[INDEX]); \ + break; \ + } + namespace o2::analysis { @@ -84,7 +94,7 @@ enum class InputFeaturesB0ToDPi : uint8_t { tpcTofNSigmaPi1 }; -template +template class HfMlResponseB0ToDPi : public HfMlResponse { public: @@ -99,57 +109,50 @@ class HfMlResponseB0ToDPi : public HfMlResponse /// \return inputFeatures vector template std::vector getInputFeatures(T1 const& candidate, - T2 const& prong1) + T2 const& prong1, + const std::vector* mlScoresD = nullptr) { std::vector inputFeatures; for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_B0(ptProng0); + CHECK_AND_FILL_VEC_B0(ptProng1); + CHECK_AND_FILL_VEC_B0(impactParameter0); + CHECK_AND_FILL_VEC_B0(impactParameter1); + CHECK_AND_FILL_VEC_B0(impactParameterProduct); + CHECK_AND_FILL_VEC_B0(chi2PCA); + CHECK_AND_FILL_VEC_B0(decayLength); + CHECK_AND_FILL_VEC_B0(decayLengthXY); + CHECK_AND_FILL_VEC_B0(decayLengthNormalised); + CHECK_AND_FILL_VEC_B0(decayLengthXYNormalised); + CHECK_AND_FILL_VEC_B0(cpa); + CHECK_AND_FILL_VEC_B0(cpaXY); + CHECK_AND_FILL_VEC_B0(maxNormalisedDeltaIP); + // TPC PID variable + CHECK_AND_FILL_VEC_B0_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); + // TOF PID variable + CHECK_AND_FILL_VEC_B0_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); + // Combined PID variables + CHECK_AND_FILL_VEC_B0_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1); + } if constexpr (withDmesMl) { - switch (idx) { - CHECK_AND_FILL_VEC_B0(ptProng0); - CHECK_AND_FILL_VEC_B0(ptProng1); - CHECK_AND_FILL_VEC_B0(impactParameter0); - CHECK_AND_FILL_VEC_B0(impactParameter1); - CHECK_AND_FILL_VEC_B0(impactParameterProduct); - CHECK_AND_FILL_VEC_B0(chi2PCA); - CHECK_AND_FILL_VEC_B0(decayLength); - CHECK_AND_FILL_VEC_B0(decayLengthXY); - CHECK_AND_FILL_VEC_B0(decayLengthNormalised); - CHECK_AND_FILL_VEC_B0(decayLengthXYNormalised); - CHECK_AND_FILL_VEC_B0(cpa); - CHECK_AND_FILL_VEC_B0(cpaXY); - CHECK_AND_FILL_VEC_B0(maxNormalisedDeltaIP); - CHECK_AND_FILL_VEC_B0(prong0MlScoreBkg); - CHECK_AND_FILL_VEC_B0(prong0MlScorePrompt); - CHECK_AND_FILL_VEC_B0(prong0MlScoreNonprompt); - // TPC PID variable - CHECK_AND_FILL_VEC_B0_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); - // TOF PID variable - CHECK_AND_FILL_VEC_B0_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); - // Combined PID variables - CHECK_AND_FILL_VEC_B0_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1); - } - } else { - switch (idx) { - CHECK_AND_FILL_VEC_B0(ptProng0); - CHECK_AND_FILL_VEC_B0(ptProng1); - CHECK_AND_FILL_VEC_B0(impactParameter0); - CHECK_AND_FILL_VEC_B0(impactParameter1); - CHECK_AND_FILL_VEC_B0(impactParameterProduct); - CHECK_AND_FILL_VEC_B0(chi2PCA); - CHECK_AND_FILL_VEC_B0(decayLength); - CHECK_AND_FILL_VEC_B0(decayLengthXY); - CHECK_AND_FILL_VEC_B0(decayLengthNormalised); - CHECK_AND_FILL_VEC_B0(decayLengthXYNormalised); - CHECK_AND_FILL_VEC_B0(cpa); - CHECK_AND_FILL_VEC_B0(cpaXY); - CHECK_AND_FILL_VEC_B0(maxNormalisedDeltaIP); - // TPC PID variable - CHECK_AND_FILL_VEC_B0_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); - // TOF PID variable - CHECK_AND_FILL_VEC_B0_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); - // Combined PID variables - CHECK_AND_FILL_VEC_B0_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1); + if constexpr (reduced) { + switch (idx) { + CHECK_AND_FILL_VEC_B0(prong0MlScoreBkg); + CHECK_AND_FILL_VEC_B0(prong0MlScorePrompt); + CHECK_AND_FILL_VEC_B0(prong0MlScoreNonprompt); + } + } else { + if (mlScoresD) { + switch (idx) { + CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScoreBkg, *mlScoresD, 0); + CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScorePrompt, *mlScoresD, 1); + CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScoreNonprompt, *mlScoresD, 2); + } + } else { + LOG(fatal) << "ML scores of D not provided"; + } } } } diff --git a/PWGHF/Core/HfMlResponseBplusToD0Pi.h b/PWGHF/Core/HfMlResponseBplusToD0Pi.h index 90fb0669675..427e90fd16d 100644 --- a/PWGHF/Core/HfMlResponseBplusToD0Pi.h +++ b/PWGHF/Core/HfMlResponseBplusToD0Pi.h @@ -16,13 +16,14 @@ #ifndef PWGHF_CORE_HFMLRESPONSEBPLUSTOD0PI_H_ #define PWGHF_CORE_HFMLRESPONSEBPLUSTOD0PI_H_ -#include -#include -#include - #include "PWGHF/Core/HfMlResponse.h" #include "PWGHF/D2H/Utils/utilsRedDataFormat.h" +#include "Tools/ML/MlResponse.h" + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures diff --git a/PWGHF/Core/HfMlResponseBplusToD0PiReduced.h b/PWGHF/Core/HfMlResponseBplusToD0PiReduced.h index 6f56cbce245..93e2ea67eb4 100644 --- a/PWGHF/Core/HfMlResponseBplusToD0PiReduced.h +++ b/PWGHF/Core/HfMlResponseBplusToD0PiReduced.h @@ -16,13 +16,14 @@ #ifndef PWGHF_CORE_HFMLRESPONSEBPLUSTOD0PIREDUCED_H_ #define PWGHF_CORE_HFMLRESPONSEBPLUSTOD0PIREDUCED_H_ -#include -#include -#include - #include "PWGHF/Core/HfMlResponse.h" #include "PWGHF/D2H/Utils/utilsRedDataFormat.h" +#include "Tools/ML/MlResponse.h" + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures diff --git a/PWGHF/Core/HfMlResponseBplusToJpsiKReduced.h b/PWGHF/Core/HfMlResponseBplusToJpsiKReduced.h new file mode 100644 index 00000000000..ebf77e7effe --- /dev/null +++ b/PWGHF/Core/HfMlResponseBplusToJpsiKReduced.h @@ -0,0 +1,182 @@ +// 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. + +/// \file HfMlResponseBplusToJpsiKReduced.h +/// \brief Class to compute the ML response for B± → J/Psi K± analysis selections in the reduced format +/// \author Fabrizio Chinu , Università degli Studi and INFN Torino + +#ifndef PWGHF_CORE_HFMLRESPONSEBPLUSTOJPSIKREDUCED_H_ +#define PWGHF_CORE_HFMLRESPONSEBPLUSTOJPSIKREDUCED_H_ + +#include "PWGHF/Core/HfMlResponse.h" +#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" + +#include "Tools/ML/MlResponse.h" + +#include +#include + +// Fill the map of available input features +// the key is the feature's name (std::string) +// the value is the corresponding value in EnumInputFeatures +#define FILL_MAP_BPLUS(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesBplusToJpsiKReduced::FEATURE) \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER from OBJECT +#define CHECK_AND_FILL_VEC_BPLUS_FULL(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesBplusToJpsiKReduced::FEATURE): { \ + inputFeatures.emplace_back(OBJECT.GETTER()); \ + break; \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the GETTER function taking OBJECT in argument +#define CHECK_AND_FILL_VEC_BPLUS_FUNC(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesBplusToJpsiKReduced::FEATURE): { \ + inputFeatures.emplace_back(GETTER(OBJECT)); \ + break; \ + } + +// Specific case of CHECK_AND_FILL_VEC_BPLUS_FULL(OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate and FEATURE = GETTER +#define CHECK_AND_FILL_VEC_BPLUS(GETTER) \ + case static_cast(InputFeaturesBplusToJpsiKReduced::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + +// Specific case of CHECK_AND_FILL_VEC_BPLUS_FULL(OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate, FEATURE = GETTER, and args are needed +#define CHECK_AND_FILL_VEC_BPLUS_WITH_ARGS(GETTER, ARGS...) \ + case static_cast(InputFeaturesBplusToJpsiKReduced::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER(ARGS)); \ + break; \ + } + +namespace o2::analysis +{ + +enum class InputFeaturesBplusToJpsiKReduced : uint8_t { + ptProng0 = 0, + ptProng1, + impactParameter0, + impactParameter1, + impactParameter2, + impactParameterProduct, + impactParameterProductJpsi, + chi2PCA, + decayLength, + decayLengthXY, + decayLengthNormalised, + decayLengthXYNormalised, + cpa, + cpaXY, + maxNormalisedDeltaIP, + ctXY, + tpcNSigmaKa1, + tofNSigmaKa1, + tpcTofNSigmaKa1 +}; + +template +class HfMlResponseBplusToJpsiKReduced : public HfMlResponse +{ + public: + /// Default constructor + HfMlResponseBplusToJpsiKReduced() = default; + /// Default destructor + virtual ~HfMlResponseBplusToJpsiKReduced() = default; + + /// Method to get the input features vector needed for ML inference + /// \param candidate is the B+ candidate + /// \param prong1 is the candidate's prong1 + /// \return inputFeatures vector + template + std::vector getInputFeatures(T1 const& candidate, + T2 const& prong1) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_BPLUS(ptProng0); + CHECK_AND_FILL_VEC_BPLUS(ptProng1); + CHECK_AND_FILL_VEC_BPLUS(impactParameter0); + CHECK_AND_FILL_VEC_BPLUS(impactParameter1); + CHECK_AND_FILL_VEC_BPLUS(impactParameter2); + CHECK_AND_FILL_VEC_BPLUS(impactParameterProduct); + CHECK_AND_FILL_VEC_BPLUS(impactParameterProductJpsi); + CHECK_AND_FILL_VEC_BPLUS(chi2PCA); + CHECK_AND_FILL_VEC_BPLUS(decayLength); + CHECK_AND_FILL_VEC_BPLUS(decayLengthXY); + CHECK_AND_FILL_VEC_BPLUS(decayLengthNormalised); + CHECK_AND_FILL_VEC_BPLUS(decayLengthXYNormalised); + CHECK_AND_FILL_VEC_BPLUS(cpa); + CHECK_AND_FILL_VEC_BPLUS(cpaXY); + CHECK_AND_FILL_VEC_BPLUS(maxNormalisedDeltaIP); + CHECK_AND_FILL_VEC_BPLUS_WITH_ARGS(ctXY, std::array{o2::constants::physics::MassMuon, o2::constants::physics::MassMuon, o2::constants::physics::MassKPlus}); + // TPC PID variable + CHECK_AND_FILL_VEC_BPLUS_FULL(prong1, tpcNSigmaKa1, tpcNSigmaKa); + // TOF PID variable + CHECK_AND_FILL_VEC_BPLUS_FULL(prong1, tofNSigmaKa1, tofNSigmaKa); + // Combined PID variables + CHECK_AND_FILL_VEC_BPLUS_FUNC(prong1, tpcTofNSigmaKa1, o2::pid_tpc_tof_utils::getTpcTofNSigmaKa1); + } + } + + return inputFeatures; + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + FILL_MAP_BPLUS(ptProng0), + FILL_MAP_BPLUS(ptProng1), + FILL_MAP_BPLUS(impactParameter0), + FILL_MAP_BPLUS(impactParameter1), + FILL_MAP_BPLUS(impactParameter2), + FILL_MAP_BPLUS(impactParameterProduct), + FILL_MAP_BPLUS(impactParameterProductJpsi), + FILL_MAP_BPLUS(chi2PCA), + FILL_MAP_BPLUS(decayLength), + FILL_MAP_BPLUS(decayLengthXY), + FILL_MAP_BPLUS(decayLengthNormalised), + FILL_MAP_BPLUS(decayLengthXYNormalised), + FILL_MAP_BPLUS(cpa), + FILL_MAP_BPLUS(cpaXY), + FILL_MAP_BPLUS(maxNormalisedDeltaIP), + FILL_MAP_BPLUS(ctXY), + // TPC PID variable + FILL_MAP_BPLUS(tpcNSigmaKa1), + // TOF PID variable + FILL_MAP_BPLUS(tofNSigmaKa1), + // Combined PID variable + FILL_MAP_BPLUS(tpcTofNSigmaKa1)}; + } +}; + +} // namespace o2::analysis + +#undef FILL_MAP_BPLUS +#undef CHECK_AND_FILL_VEC_BPLUS_FULL +#undef CHECK_AND_FILL_VEC_BPLUS_FUNC +#undef CHECK_AND_FILL_VEC_BPLUS + +#endif // PWGHF_CORE_HFMLRESPONSEBPLUSTOJPSIKREDUCED_H_ diff --git a/PWGHF/Core/HfMlResponseBsToDsPi.h b/PWGHF/Core/HfMlResponseBsToDsPi.h index 821463e0ec8..4c472034f71 100644 --- a/PWGHF/Core/HfMlResponseBsToDsPi.h +++ b/PWGHF/Core/HfMlResponseBsToDsPi.h @@ -9,20 +9,21 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file HfMlResponsBsToDsPi.h +/// \file HfMlResponseBsToDsPi.h /// \brief Class to compute the ML response for Bs → Ds∓ π± analysis selections /// \author Fabio Catalano , CERN #ifndef PWGHF_CORE_HFMLRESPONSEBSTODSPI_H_ #define PWGHF_CORE_HFMLRESPONSEBSTODSPI_H_ -#include -#include -#include - #include "PWGHF/Core/HfMlResponse.h" #include "PWGHF/D2H/Utils/utilsRedDataFormat.h" +#include "Tools/ML/MlResponse.h" + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures diff --git a/PWGHF/Core/HfMlResponseBsToJpsiPhiReduced.h b/PWGHF/Core/HfMlResponseBsToJpsiPhiReduced.h new file mode 100644 index 00000000000..2af47921132 --- /dev/null +++ b/PWGHF/Core/HfMlResponseBsToJpsiPhiReduced.h @@ -0,0 +1,204 @@ +// 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. + +/// \file HfMlResponseBsToJpsiPhiReduced.h +/// \brief Class to compute the ML response for Bs0 → J/Psi phi analysis selections in the reduced format +/// \author Fabrizio Chinu , Università degli Studi and INFN Torino + +#ifndef PWGHF_CORE_HFMLRESPONSEBSTOJPSIPHIREDUCED_H_ +#define PWGHF_CORE_HFMLRESPONSEBSTOJPSIPHIREDUCED_H_ + +#include "PWGHF/Core/HfMlResponse.h" +#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" + +#include "Tools/ML/MlResponse.h" + +#include +#include + +// Fill the map of available input features +// the key is the feature's name (std::string) +// the value is the corresponding value in EnumInputFeatures +#define FILL_MAP_BS(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesBsToJpsiPhiReduced::FEATURE) \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER from OBJECT +#define CHECK_AND_FILL_VEC_BS_FULL(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesBsToJpsiPhiReduced::FEATURE): { \ + inputFeatures.emplace_back(OBJECT.GETTER()); \ + break; \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the GETTER function taking OBJECT in argument +#define CHECK_AND_FILL_VEC_BS_FUNC(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesBsToJpsiPhiReduced::FEATURE): { \ + inputFeatures.emplace_back(GETTER(OBJECT)); \ + break; \ + } + +// Specific case of CHECK_AND_FILL_VEC_BS_FULL(OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate and FEATURE = GETTER +#define CHECK_AND_FILL_VEC_BS(GETTER) \ + case static_cast(InputFeaturesBsToJpsiPhiReduced::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + +// Specific case of CHECK_AND_FILL_VEC_BPLUS_FULL(OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate and FEATURE = GETTER and args are needed +#define CHECK_AND_FILL_VEC_BS_WITH_ARGS(GETTER, ARGS...) \ + case static_cast(InputFeaturesBsToJpsiPhiReduced::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER(ARGS)); \ + break; \ + } + +namespace o2::analysis +{ + +enum class InputFeaturesBsToJpsiPhiReduced : uint8_t { + ptProng0 = 0, + ptProng1, + impactParameter0, + impactParameter1, + impactParameter2, + impactParameter3, + impactParameterProduct, + impactParameterProductJpsi, + impactParameterProductPhi, + chi2PCA, + decayLength, + decayLengthXY, + decayLengthNormalised, + decayLengthXYNormalised, + cpa, + cpaXY, + maxNormalisedDeltaIP, + ctXY, + tpcNSigmaKa0, + tofNSigmaKa0, + tpcTofNSigmaKa0, + tpcNSigmaKa1, + tofNSigmaKa1, + tpcTofNSigmaKa1 +}; + +template +class HfMlResponseBsToJpsiPhiReduced : public HfMlResponse +{ + public: + /// Default constructor + HfMlResponseBsToJpsiPhiReduced() = default; + /// Default destructor + virtual ~HfMlResponseBsToJpsiPhiReduced() = default; + + /// Method to get the input features vector needed for ML inference + /// \param candidate is the Bs candidate + /// \param prong1 is the candidate's prong1 + /// \return inputFeatures vector + template + std::vector getInputFeatures(T1 const& candidate, + T2 const& prong1, + T3 const& prong2) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_BS(ptProng0); + CHECK_AND_FILL_VEC_BS(ptProng1); + CHECK_AND_FILL_VEC_BS(impactParameter0); + CHECK_AND_FILL_VEC_BS(impactParameter1); + CHECK_AND_FILL_VEC_BS(impactParameter2); + CHECK_AND_FILL_VEC_BS(impactParameter3); + CHECK_AND_FILL_VEC_BS(impactParameterProduct); + CHECK_AND_FILL_VEC_BS(impactParameterProductJpsi); + CHECK_AND_FILL_VEC_BS(impactParameterProductPhi); + CHECK_AND_FILL_VEC_BS(chi2PCA); + CHECK_AND_FILL_VEC_BS(decayLength); + CHECK_AND_FILL_VEC_BS(decayLengthXY); + CHECK_AND_FILL_VEC_BS(decayLengthNormalised); + CHECK_AND_FILL_VEC_BS(decayLengthXYNormalised); + CHECK_AND_FILL_VEC_BS(cpa); + CHECK_AND_FILL_VEC_BS(cpaXY); + CHECK_AND_FILL_VEC_BS(maxNormalisedDeltaIP); + CHECK_AND_FILL_VEC_BS_WITH_ARGS(ctXY, std::array{o2::constants::physics::MassMuon, o2::constants::physics::MassMuon, o2::constants::physics::MassKPlus, o2::constants::physics::MassKPlus}); + // TPC PID variable + CHECK_AND_FILL_VEC_BS_FULL(prong1, tpcNSigmaKa0, tpcNSigmaKa); + // TOF PID variable + CHECK_AND_FILL_VEC_BS_FULL(prong1, tofNSigmaKa0, tofNSigmaKa); + // Combined PID variables + CHECK_AND_FILL_VEC_BS_FUNC(prong1, tpcTofNSigmaKa0, o2::pid_tpc_tof_utils::getTpcTofNSigmaKa1); + // TPC PID variable + CHECK_AND_FILL_VEC_BS_FULL(prong2, tpcNSigmaKa1, tpcNSigmaKa); + // TOF PID variable + CHECK_AND_FILL_VEC_BS_FULL(prong2, tofNSigmaKa1, tofNSigmaKa); + // Combined PID variables + CHECK_AND_FILL_VEC_BS_FUNC(prong2, tpcTofNSigmaKa1, o2::pid_tpc_tof_utils::getTpcTofNSigmaKa1); + } + } + + return inputFeatures; + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + FILL_MAP_BS(ptProng0), + FILL_MAP_BS(ptProng1), + FILL_MAP_BS(impactParameter0), + FILL_MAP_BS(impactParameter1), + FILL_MAP_BS(impactParameter2), + FILL_MAP_BS(impactParameter3), + FILL_MAP_BS(impactParameterProduct), + FILL_MAP_BS(impactParameterProductJpsi), + FILL_MAP_BS(impactParameterProductPhi), + FILL_MAP_BS(chi2PCA), + FILL_MAP_BS(decayLength), + FILL_MAP_BS(decayLengthXY), + FILL_MAP_BS(decayLengthNormalised), + FILL_MAP_BS(decayLengthXYNormalised), + FILL_MAP_BS(cpa), + FILL_MAP_BS(cpaXY), + FILL_MAP_BS(maxNormalisedDeltaIP), + FILL_MAP_BS(ctXY), + // TPC PID variable + FILL_MAP_BS(tpcNSigmaKa0), + // TOF PID variable + FILL_MAP_BS(tofNSigmaKa0), + // Combined PID variable + FILL_MAP_BS(tpcTofNSigmaKa0), + // TPC PID variable + FILL_MAP_BS(tpcNSigmaKa1), + // TOF PID variable + FILL_MAP_BS(tofNSigmaKa1), + // Combined PID variable + FILL_MAP_BS(tpcTofNSigmaKa1)}; + } +}; + +} // namespace o2::analysis + +#undef FILL_MAP_BS +#undef CHECK_AND_FILL_VEC_BS_FULL +#undef CHECK_AND_FILL_VEC_BS_FUNC +#undef CHECK_AND_FILL_VEC_BS + +#endif // PWGHF_CORE_HFMLRESPONSEBSTOJPSIPHIREDUCED_H_ diff --git a/PWGHF/Core/HfMlResponseD0ToKPi.h b/PWGHF/Core/HfMlResponseD0ToKPi.h index 71ed542b269..8a1128bd65f 100644 --- a/PWGHF/Core/HfMlResponseD0ToKPi.h +++ b/PWGHF/Core/HfMlResponseD0ToKPi.h @@ -17,15 +17,16 @@ #ifndef PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ #define PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ -#include -#include -#include - -#include "CommonConstants/PhysicsConstants.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponse.h" +#include "Tools/ML/MlResponse.h" + +#include + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures @@ -99,6 +100,22 @@ break; \ } +// Variation of CHECK_AND_FILL_VEC_D0_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) +// where GETTER1 and GETTER2 are methods of the OBJECT, the variable +// is filled depending on whether it is a D0 or a D0bar +// and INDEX is the index of the vector +#define CHECK_AND_FILL_VEC_D0_ML(OBJECT, FEATURE, GETTER1, GETTER2, INDEX) \ + case static_cast(InputFeaturesD0ToKPi::FEATURE): { \ + if constexpr (usingMl) { \ + if (pdgCode == o2::constants::physics::kD0) { \ + inputFeatures.emplace_back(OBJECT.GETTER1()[INDEX]); \ + } else { \ + inputFeatures.emplace_back(OBJECT.GETTER2()[INDEX]); \ + } \ + } \ + break; \ + } + namespace o2::analysis { enum class InputFeaturesD0ToKPi : uint8_t { @@ -140,6 +157,9 @@ enum class InputFeaturesD0ToKPi : uint8_t { nSigTpcTofKaExpKa, maxNormalisedDeltaIP, impactParameterProduct, + bdtOutputBkg, + bdtOutputNonPrompt, + bdtOutputPrompt, cosThetaStar, cpa, cpaXY, @@ -160,7 +180,7 @@ class HfMlResponseD0ToKPi : public HfMlResponse /// Method to get the input features vector needed for ML inference /// \param candidate is the D0 candidate /// \return inputFeatures vector - template + template std::vector getInputFeatures(T1 const& candidate, int const& pdgCode) { std::vector inputFeatures; @@ -183,10 +203,6 @@ class HfMlResponseD0ToKPi : public HfMlResponse CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTpcKa0, /*getter*/ nSigTpcKa0); CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTpcPi1, /*getter*/ nSigTpcPi1); CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTpcKa1, /*getter*/ nSigTpcKa1); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong0, prong1, nSigTpcPiExpPi, tpcNSigmaPi); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong0, prong1, nSigTpcKaExpPi, tpcNSigmaKa); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong1, prong0, nSigTpcPiExpKa, tpcNSigmaPi); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong1, prong0, nSigTpcKaExpKa, tpcNSigmaKa); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTpcPiExpPi, nSigTpcPi0, nSigTpcPi1); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTpcKaExpPi, nSigTpcKa0, nSigTpcKa1); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTpcPiExpKa, nSigTpcPi1, nSigTpcPi0); @@ -196,10 +212,6 @@ class HfMlResponseD0ToKPi : public HfMlResponse CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTofKa0, /*getter*/ nSigTofKa0); CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTofPi1, /*getter*/ nSigTofPi1); CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTofKa1, /*getter*/ nSigTofKa1); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong0, prong1, nSigTofPiExpPi, tofNSigmaPi); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong0, prong1, nSigTofKaExpPi, tofNSigmaKa); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong1, prong0, nSigTofPiExpKa, tofNSigmaPi); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong1, prong0, nSigTofKaExpKa, tofNSigmaKa); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTofPiExpPi, nSigTofPi0, nSigTofPi1); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTofKaExpPi, nSigTofKa0, nSigTofKa1); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTofPiExpKa, nSigTofPi1, nSigTofPi0); @@ -209,15 +221,15 @@ class HfMlResponseD0ToKPi : public HfMlResponse CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTpcTofKa0, tpcTofNSigmaKa0); CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTpcTofPi1, tpcTofNSigmaPi1); CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTpcTofKa1, tpcTofNSigmaKa1); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong0, prong1, nSigTpcTofPiExpPi, tpcTofNSigmaPi); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong0, prong1, nSigTpcTofKaExpPi, tpcTofNSigmaKa); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong1, prong0, nSigTpcTofPiExpKa, tpcTofNSigmaPi); - // CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(prong1, prong0, nSigTpcTofKaExpKa, tpcTofNSigmaKa); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTpcTofPiExpPi, tpcTofNSigmaPi0, tpcTofNSigmaPi1); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTpcTofKaExpPi, tpcTofNSigmaKa0, tpcTofNSigmaKa1); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTpcTofPiExpKa, tpcTofNSigmaPi1, tpcTofNSigmaPi0); CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTpcTofKaExpKa, tpcTofNSigmaKa1, tpcTofNSigmaKa0); + CHECK_AND_FILL_VEC_D0_ML(candidate, bdtOutputBkg, mlProbD0, mlProbD0bar, 0); + CHECK_AND_FILL_VEC_D0_ML(candidate, bdtOutputNonPrompt, mlProbD0, mlProbD0bar, 1); + CHECK_AND_FILL_VEC_D0_ML(candidate, bdtOutputPrompt, mlProbD0, mlProbD0bar, 2); + CHECK_AND_FILL_VEC_D0(maxNormalisedDeltaIP); CHECK_AND_FILL_VEC_D0_FULL(candidate, impactParameterProduct, impactParameterProduct); CHECK_AND_FILL_VEC_D0_HFHELPER_SIGNED(candidate, cosThetaStar, cosThetaStarD0, cosThetaStarD0bar); @@ -273,6 +285,10 @@ class HfMlResponseD0ToKPi : public HfMlResponse FILL_MAP_D0(nSigTpcTofKaExpPi), FILL_MAP_D0(nSigTpcTofPiExpKa), FILL_MAP_D0(nSigTpcTofKaExpKa), + // ML variables + FILL_MAP_D0(bdtOutputBkg), + FILL_MAP_D0(bdtOutputNonPrompt), + FILL_MAP_D0(bdtOutputPrompt), FILL_MAP_D0(maxNormalisedDeltaIP), FILL_MAP_D0(impactParameterProduct), @@ -291,5 +307,6 @@ class HfMlResponseD0ToKPi : public HfMlResponse #undef CHECK_AND_FILL_VEC_D0_HFHELPER #undef CHECK_AND_FILL_VEC_D0_HFHELPER_SIGNED #undef CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED +#undef CHECK_AND_FILL_VEC_D0_ML #endif // PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ diff --git a/PWGHF/Core/HfMlResponseDplusToPiKPi.h b/PWGHF/Core/HfMlResponseDplusToPiKPi.h index 292ddcccb95..fd6085b5ce9 100644 --- a/PWGHF/Core/HfMlResponseDplusToPiKPi.h +++ b/PWGHF/Core/HfMlResponseDplusToPiKPi.h @@ -16,18 +16,19 @@ #ifndef PWGHF_CORE_HFMLRESPONSEDPLUSTOPIKPI_H_ #define PWGHF_CORE_HFMLRESPONSEDPLUSTOPIKPI_H_ -#include -#include -#include - #include "PWGHF/Core/HfMlResponse.h" +#include "Tools/ML/MlResponse.h" + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures -#define FILL_MAP_DPLUS(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesDplusToPiKPi::FEATURE) \ +#define FILL_MAP_DPLUS(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesDplusToPiKPi::FEATURE) \ } // Check if the index of mCachedIndices (index associated to a FEATURE) @@ -104,9 +105,8 @@ class HfMlResponseDplusToPiKPi : public HfMlResponse /// \param prong1 is the candidate's prong1 /// \param prong2 is the candidate's prong2 /// \return inputFeatures vector - template - std::vector getInputFeatures(T1 const& candidate, - T2 const& prong0, T2 const& prong1, T2 const& prong2) + template + std::vector getInputFeatures(T1 const& candidate) { std::vector inputFeatures; @@ -130,26 +130,26 @@ class HfMlResponseDplusToPiKPi : public HfMlResponse CHECK_AND_FILL_VEC_DPLUS(maxNormalisedDeltaIP); CHECK_AND_FILL_VEC_DPLUS(chi2PCA); // TPC PID variables - CHECK_AND_FILL_VEC_DPLUS_FULL(prong0, tpcNSigmaPi0, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong0, tpcNSigmaKa0, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong1, tpcNSigmaKa1, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong2, tpcNSigmaPi2, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong2, tpcNSigmaKa2, tpcNSigmaKa); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcNSigmaPi0, nSigTpcPi0); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcNSigmaKa0, nSigTpcKa0); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcNSigmaPi1, nSigTpcPi1); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcNSigmaKa1, nSigTpcKa1); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcNSigmaPi2, nSigTpcPi2); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcNSigmaKa2, nSigTpcKa2); // TOF PID variables - CHECK_AND_FILL_VEC_DPLUS_FULL(prong0, tofNSigmaPi0, tofNSigmaPi); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong0, tofNSigmaKa0, tofNSigmaKa); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong1, tofNSigmaKa1, tofNSigmaKa); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong2, tofNSigmaPi2, tofNSigmaPi); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong2, tofNSigmaKa2, tofNSigmaKa); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tofNSigmaPi0, nSigTofPi0); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tofNSigmaKa0, nSigTofKa0); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tofNSigmaPi1, nSigTofPi1); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tofNSigmaKa1, nSigTofKa1); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tofNSigmaPi2, nSigTofPi2); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tofNSigmaKa2, nSigTofKa2); // Combined PID variables - CHECK_AND_FILL_VEC_DPLUS_FULL(prong0, tpcTofNSigmaPi0, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong1, tpcTofNSigmaPi1, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong2, tpcTofNSigmaPi2, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong0, tpcTofNSigmaKa0, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong1, tpcTofNSigmaKa1, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_DPLUS_FULL(prong2, tpcTofNSigmaKa2, tpcTofNSigmaKa); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcTofNSigmaPi0, tpcTofNSigmaPi0); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcTofNSigmaPi1, tpcTofNSigmaPi1); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcTofNSigmaPi2, tpcTofNSigmaPi2); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcTofNSigmaKa0, tpcTofNSigmaKa0); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcTofNSigmaKa1, tpcTofNSigmaKa1); + CHECK_AND_FILL_VEC_DPLUS_FULL(candidate, tpcTofNSigmaKa2, tpcTofNSigmaKa2); } } diff --git a/PWGHF/Core/HfMlResponseDsToKKPi.h b/PWGHF/Core/HfMlResponseDsToKKPi.h index 1b27d52adde..0c166e55e51 100644 --- a/PWGHF/Core/HfMlResponseDsToKKPi.h +++ b/PWGHF/Core/HfMlResponseDsToKKPi.h @@ -16,17 +16,20 @@ #ifndef PWGHF_CORE_HFMLRESPONSEDSTOKKPI_H_ #define PWGHF_CORE_HFMLRESPONSEDSTOKKPI_H_ -#include - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponse.h" +#include "Tools/ML/MlResponse.h" + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures -#define FILL_MAP_DS(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesDsToKKPi::FEATURE) \ +#define FILL_MAP_DS(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesDsToKKPi::FEATURE) \ } // Check if the index of mCachedIndices (index associated to a FEATURE) @@ -81,6 +84,18 @@ break; \ } +// Variation of CHECK_AND_FILL_VEC_DS_OBJECT_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) +// where GETTER1 and GETTER2 are methods of the OBJECT +#define CHECK_AND_FILL_VEC_DS_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) \ + case static_cast(InputFeaturesDsToKKPi::FEATURE): { \ + if (caseDsToKKPi) { \ + inputFeatures.emplace_back(OBJECT.GETTER1()); \ + } else { \ + inputFeatures.emplace_back(OBJECT.GETTER2()); \ + } \ + break; \ + } + namespace o2::analysis { enum class InputFeaturesDsToKKPi : uint8_t { @@ -148,9 +163,8 @@ class HfMlResponseDsToKKPi : public HfMlResponse /// \param prong2 is the candidate's prong2 /// \param caseDsToKKPi used to divide the case DsToKKPi from DsToPiKK /// \return inputFeatures vector - template - std::vector getInputFeatures(T1 const& candidate, - T2 const& prong0, T2 const& prong1, T2 const& prong2, bool const& caseDsToKKPi) + template + std::vector getInputFeatures(T1 const& candidate, bool const caseDsToKKPi) { std::vector inputFeatures; @@ -174,33 +188,33 @@ class HfMlResponseDsToKKPi : public HfMlResponse CHECK_AND_FILL_VEC_DS(impactParameterZ0); CHECK_AND_FILL_VEC_DS(impactParameterZ1); CHECK_AND_FILL_VEC_DS(impactParameterZ2); - // TPC PID variables - CHECK_AND_FILL_VEC_DS_FULL(prong0, nSigTpcPi0, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DS_FULL(prong1, nSigTpcPi1, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DS_FULL(prong2, nSigTpcPi2, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DS_FULL(prong0, nSigTpcKa0, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DS_FULL(prong1, nSigTpcKa1, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DS_FULL(prong2, nSigTpcKa2, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DS_FULL(prong0, nSigTofPi0, tofNSigmaPi); - CHECK_AND_FILL_VEC_DS_FULL(prong1, nSigTofPi1, tofNSigmaPi); - CHECK_AND_FILL_VEC_DS_FULL(prong2, nSigTofPi2, tofNSigmaPi); - CHECK_AND_FILL_VEC_DS_FULL(prong0, nSigTofKa0, tofNSigmaKa); - CHECK_AND_FILL_VEC_DS_FULL(prong1, nSigTofKa1, tofNSigmaKa); - CHECK_AND_FILL_VEC_DS_FULL(prong2, nSigTofKa2, tofNSigmaKa); - CHECK_AND_FILL_VEC_DS_OBJECT_SIGNED(prong0, prong2, nSigTpcKaExpKa0, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DS_OBJECT_SIGNED(prong2, prong0, nSigTpcPiExpPi2, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DS_OBJECT_SIGNED(prong0, prong2, nSigTofKaExpKa0, tofNSigmaKa); - CHECK_AND_FILL_VEC_DS_OBJECT_SIGNED(prong2, prong0, nSigTofPiExpPi2, tofNSigmaPi); + // TPC and TOF PID variables + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcPi0, nSigTpcPi0); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcPi1, nSigTpcPi1); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcPi2, nSigTpcPi2); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcKa0, nSigTpcKa0); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcKa1, nSigTpcKa1); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcKa2, nSigTpcKa2); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTofPi0, nSigTofPi0); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTofPi1, nSigTofPi1); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTofPi2, nSigTofPi2); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTofKa0, nSigTofKa0); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTofKa1, nSigTofKa1); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTofKa2, nSigTofKa2); + CHECK_AND_FILL_VEC_DS_SIGNED(candidate, nSigTpcKaExpKa0, nSigTpcKa0, nSigTpcKa2); + CHECK_AND_FILL_VEC_DS_SIGNED(candidate, nSigTpcPiExpPi2, nSigTpcPi2, nSigTpcPi0); + CHECK_AND_FILL_VEC_DS_SIGNED(candidate, nSigTofKaExpKa0, nSigTofKa0, nSigTofKa2); + CHECK_AND_FILL_VEC_DS_SIGNED(candidate, nSigTofPiExpPi2, nSigTofPi2, nSigTofPi0); // Combined PID variables - CHECK_AND_FILL_VEC_DS_FULL(prong0, nSigTpcTofPi0, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DS_FULL(prong1, nSigTpcTofPi1, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DS_FULL(prong2, nSigTpcTofPi2, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DS_FULL(prong0, nSigTpcTofKa0, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_DS_FULL(prong1, nSigTpcTofKa1, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_DS_FULL(prong2, nSigTpcTofKa2, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_DS_OBJECT_SIGNED(prong0, prong2, nSigTpcTofKaExpKa0, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_DS_OBJECT_SIGNED(prong2, prong0, nSigTpcTofPiExpPi2, tpcTofNSigmaPi); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcTofPi0, tpcTofNSigmaPi0); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcTofPi1, tpcTofNSigmaPi1); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcTofPi2, tpcTofNSigmaPi2); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcTofKa0, tpcTofNSigmaKa0); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcTofKa1, tpcTofNSigmaKa1); + CHECK_AND_FILL_VEC_DS_FULL(candidate, nSigTpcTofKa2, tpcTofNSigmaKa2); + CHECK_AND_FILL_VEC_DS_SIGNED(candidate, nSigTpcTofKaExpKa0, tpcTofNSigmaKa0, tpcTofNSigmaKa2); + CHECK_AND_FILL_VEC_DS_SIGNED(candidate, nSigTpcTofPiExpPi2, tpcTofNSigmaPi2, tpcTofNSigmaPi0); // Ds specific variables CHECK_AND_FILL_VEC_DS_HFHELPER_SIGNED(candidate, absCos3PiK, absCos3PiKDsToKKPi, absCos3PiKDsToPiKK); diff --git a/PWGHF/Core/HfMlResponseDstarToD0Pi.h b/PWGHF/Core/HfMlResponseDstarToD0Pi.h index 66fc3a712d4..af0351b2a73 100644 --- a/PWGHF/Core/HfMlResponseDstarToD0Pi.h +++ b/PWGHF/Core/HfMlResponseDstarToD0Pi.h @@ -16,19 +16,21 @@ #ifndef PWGHF_CORE_HFMLRESPONSEDSTARTOD0PI_H_ #define PWGHF_CORE_HFMLRESPONSEDSTARTOD0PI_H_ -#include -#include -#include - #include "PWGHF/Core/HfMlResponse.h" -#include "CommonConstants/PhysicsConstants.h" + +#include "Tools/ML/MlResponse.h" + +#include + +#include +#include // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures -#define FILL_MAP_DSTAR(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesDstarToD0Pi::FEATURE) \ +#define FILL_MAP_DSTAR(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesDstarToD0Pi::FEATURE) \ } // Check if the index of mCachedIndices (index associated to a FEATURE) @@ -49,6 +51,14 @@ break; \ } +// Specific case of CHECK_AND_FILL_VEC_DSTAR_FULL(OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate and FEATURE != GETTER +#define CHECK_AND_FILL_VEC_DSTAR_GETTER(FEATURE, GETTER) \ + case static_cast(InputFeaturesDstarToD0Pi::FEATURE): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + // Very specific case of CHECK_AND_FILL_VEC_DSTAR_FULL(OBJECT, FEATURE, GETTER) // Use for push back different value for D*+ or D*- candidate #define CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(POSGETTER, NEGGETTER, FEATURENAME) \ @@ -103,6 +113,8 @@ enum class InputFeaturesDstarToD0Pi : uint8_t { ptSoftPi, impactParameter0, impactParameter1, + impactParameterXY0, + impactParameterXY1, impactParameterZ0, impactParameterZ1, impParamSoftPi, @@ -151,9 +163,8 @@ class HfMlResponseDstarToD0Pi : public HfMlResponse /// \param prong1 is the candidate's prong1 /// \param prongSoftPi is the candidate's prongSoftPi /// \return inputFeatures vector - template - std::vector getInputFeatures(T1 const& candidate, - T2 const& prong0, T2 const& prong1, T2 const& prongSoftPi) + template + std::vector getInputFeatures(T1 const& candidate) { std::vector inputFeatures; @@ -186,24 +197,46 @@ class HfMlResponseDstarToD0Pi : public HfMlResponse CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(cosThetaStarD0, cosThetaStarD0Bar, cosThetaStarD0); CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(invMassD0, invMassD0Bar, massD0); CHECK_AND_FILL_VEC_DSTAR_DELTA_MASS_D0(deltaMassD0); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTPCPiPr0, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTPCKaPr0, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTOFPiPr0, tofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTOFKaPr0, tofNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTPCTOFPiPr0, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTPCTOFKaPr0, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTPCPiPr1, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTPCKaPr1, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTOFPiPr1, tofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTOFKaPr1, tofNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTPCTOFPiPr1, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTPCTOFKaPr1, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTPCPiPrSoftPi, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTPCKaPrSoftPi, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTOFPiPrSoftPi, tofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTOFKaPrSoftPi, tofNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTPCTOFPiPrSoftPi, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTPCTOFKaPrSoftPi, tpcTofNSigmaKa); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTpcPi0, nSigTpcPi1, nSigmaTPCPiPr0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTpcKa0, nSigTpcKa1, nSigmaTPCKaPr0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTofPi0, nSigTofPi1, nSigmaTOFPiPr0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTofKa0, nSigTofKa1, nSigmaTOFKaPr0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(tpcTofNSigmaPi0, tpcTofNSigmaPi1, nSigmaTPCTOFPiPr0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(tpcTofNSigmaKa0, tpcTofNSigmaKa1, nSigmaTPCTOFKaPr0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTpcPi1, nSigTpcPi0, nSigmaTPCPiPr1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTpcKa1, nSigTpcKa0, nSigmaTPCKaPr1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTofPi1, nSigTofPi0, nSigmaTOFPiPr1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTofKa1, nSigTofKa0, nSigmaTOFKaPr1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(tpcTofNSigmaPi1, tpcTofNSigmaPi0, nSigmaTPCTOFPiPr1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(tpcTofNSigmaKa1, tpcTofNSigmaKa0, nSigmaTPCTOFKaPr1); + CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTPCPiPrSoftPi, nSigTpcPi2); + CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTPCKaPrSoftPi, nSigTpcKa2); + CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTOFPiPrSoftPi, nSigTofPi2); + CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTOFKaPrSoftPi, nSigTofKa2); + CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTPCTOFPiPrSoftPi, tpcTofNSigmaPi2); + CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTPCTOFKaPrSoftPi, tpcTofNSigmaKa2); + } + } + + return inputFeatures; + } + + /// Method to get the input features used for D0 in HF triggers + /// \param candidate is the D* candidate + /// \return inputFeatures vector + template + std::vector getInputFeaturesTrigger(T1 const& candidate) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_DSTAR(ptProng0); + CHECK_AND_FILL_VEC_DSTAR_GETTER(impactParameterXY0, impactParameter0); + CHECK_AND_FILL_VEC_DSTAR(impactParameterZ0); + CHECK_AND_FILL_VEC_DSTAR(ptProng1); + CHECK_AND_FILL_VEC_DSTAR_GETTER(impactParameterXY1, impactParameter1); + CHECK_AND_FILL_VEC_DSTAR(impactParameterZ1); } } @@ -229,6 +262,8 @@ class HfMlResponseDstarToD0Pi : public HfMlResponse FILL_MAP_DSTAR(ptSoftPi), FILL_MAP_DSTAR(impactParameter0), FILL_MAP_DSTAR(impactParameter1), + FILL_MAP_DSTAR(impactParameterXY0), + FILL_MAP_DSTAR(impactParameterXY1), FILL_MAP_DSTAR(impactParameterZ0), FILL_MAP_DSTAR(impactParameterZ1), FILL_MAP_DSTAR(impParamSoftPi), @@ -270,5 +305,6 @@ class HfMlResponseDstarToD0Pi : public HfMlResponse #undef CHECK_AND_FILL_VEC_DSTAR #undef CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE #undef CHECK_AND_FILL_VEC_DSTAR_DELTA_MASS_D0 +#undef CHECK_AND_FILL_VEC_DSTAR_GETTER #endif // PWGHF_CORE_HFMLRESPONSEDSTARTOD0PI_H_ diff --git a/PWGHF/Core/HfMlResponseLbToLcPi.h b/PWGHF/Core/HfMlResponseLbToLcPi.h new file mode 100644 index 00000000000..8375e8cf5ea --- /dev/null +++ b/PWGHF/Core/HfMlResponseLbToLcPi.h @@ -0,0 +1,198 @@ +// 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. + +/// \file HfMlResponseLbToLcPi.h +/// \brief Class to compute the ML response for Lb → Lc∓ π± analysis selections +/// \author Biao Zhang , Heidelberg University + +#ifndef PWGHF_CORE_HFMLRESPONSELBTOLCPI_H_ +#define PWGHF_CORE_HFMLRESPONSELBTOLCPI_H_ + +#include "PWGHF/Core/HfMlResponse.h" +#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" + +#include "Tools/ML/MlResponse.h" + +#include +#include + +// Fill the map of available input features +// the key is the feature's name (std::string) +// the value is the corresponding value in EnumInputFeatures +#define FILL_MAP_LB(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesLbToLcPi::FEATURE) \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER from OBJECT +#define CHECK_AND_FILL_VEC_LB_FULL(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesLbToLcPi::FEATURE): { \ + inputFeatures.emplace_back(OBJECT.GETTER()); \ + break; \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the GETTER function taking OBJECT in argument +#define CHECK_AND_FILL_VEC_LB_FUNC(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesLbToLcPi::FEATURE): { \ + inputFeatures.emplace_back(GETTER(OBJECT)); \ + break; \ + } + +// Specific case of (OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate and FEATURE = GETTER +#define CHECK_AND_FILL_VEC_LB(GETTER) \ + case static_cast(InputFeaturesLbToLcPi::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + +namespace o2::analysis +{ + +enum class InputFeaturesLbToLcPi : uint8_t { + ptProng0 = 0, + ptProng1, + impactParameter0, + impactParameter1, + impactParameterProduct, + chi2PCA, + decayLength, + decayLengthXY, + decayLengthNormalised, + decayLengthXYNormalised, + cpa, + cpaXY, + maxNormalisedDeltaIP, + prong0MlScoreBkg, + prong0MlScorePrompt, + prong0MlScoreNonprompt, + tpcNSigmaPi1, + tofNSigmaPi1, + tpcTofNSigmaPi1 +}; + +template +class HfMlResponseLbToLcPi : public HfMlResponse +{ + public: + /// Default constructor + HfMlResponseLbToLcPi() = default; + /// Default destructor + virtual ~HfMlResponseLbToLcPi() = default; + + /// Method to get the input features vector needed for ML inference + /// \param candidate is the Lb candidate + /// \param prong1 is the candidate's prong1 + /// \return inputFeatures vector + template + std::vector getInputFeatures(T1 const& candidate, + T2 const& prong1) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + if constexpr (withDmesMl) { + switch (idx) { + CHECK_AND_FILL_VEC_LB(ptProng0); + CHECK_AND_FILL_VEC_LB(ptProng1); + CHECK_AND_FILL_VEC_LB(impactParameter0); + CHECK_AND_FILL_VEC_LB(impactParameter1); + CHECK_AND_FILL_VEC_LB(impactParameterProduct); + CHECK_AND_FILL_VEC_LB(chi2PCA); + CHECK_AND_FILL_VEC_LB(decayLength); + CHECK_AND_FILL_VEC_LB(decayLengthXY); + CHECK_AND_FILL_VEC_LB(decayLengthNormalised); + CHECK_AND_FILL_VEC_LB(decayLengthXYNormalised); + CHECK_AND_FILL_VEC_LB(cpa); + CHECK_AND_FILL_VEC_LB(cpaXY); + CHECK_AND_FILL_VEC_LB(maxNormalisedDeltaIP); + CHECK_AND_FILL_VEC_LB(prong0MlScoreBkg); + CHECK_AND_FILL_VEC_LB(prong0MlScorePrompt); + CHECK_AND_FILL_VEC_LB(prong0MlScoreNonprompt); + // TPC PID variable + CHECK_AND_FILL_VEC_LB_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); + // TOF PID variable + CHECK_AND_FILL_VEC_LB_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); + // Combined PID variables + CHECK_AND_FILL_VEC_LB_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1); + } + } else { + switch (idx) { + CHECK_AND_FILL_VEC_LB(ptProng0); + CHECK_AND_FILL_VEC_LB(ptProng1); + CHECK_AND_FILL_VEC_LB(impactParameter0); + CHECK_AND_FILL_VEC_LB(impactParameter1); + CHECK_AND_FILL_VEC_LB(impactParameterProduct); + CHECK_AND_FILL_VEC_LB(chi2PCA); + CHECK_AND_FILL_VEC_LB(decayLength); + CHECK_AND_FILL_VEC_LB(decayLengthXY); + CHECK_AND_FILL_VEC_LB(decayLengthNormalised); + CHECK_AND_FILL_VEC_LB(decayLengthXYNormalised); + CHECK_AND_FILL_VEC_LB(cpa); + CHECK_AND_FILL_VEC_LB(cpaXY); + CHECK_AND_FILL_VEC_LB(maxNormalisedDeltaIP); + // TPC PID variable + CHECK_AND_FILL_VEC_LB_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); + // TOF PID variable + CHECK_AND_FILL_VEC_LB_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); + // Combined PID variables + CHECK_AND_FILL_VEC_LB_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1); + } + } + } + + return inputFeatures; + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + FILL_MAP_LB(ptProng0), + FILL_MAP_LB(ptProng1), + FILL_MAP_LB(impactParameter0), + FILL_MAP_LB(impactParameter1), + FILL_MAP_LB(impactParameterProduct), + FILL_MAP_LB(chi2PCA), + FILL_MAP_LB(decayLength), + FILL_MAP_LB(decayLengthXY), + FILL_MAP_LB(decayLengthNormalised), + FILL_MAP_LB(decayLengthXYNormalised), + FILL_MAP_LB(cpa), + FILL_MAP_LB(cpaXY), + FILL_MAP_LB(maxNormalisedDeltaIP), + FILL_MAP_LB(prong0MlScoreBkg), + FILL_MAP_LB(prong0MlScorePrompt), + FILL_MAP_LB(prong0MlScoreNonprompt), + // TPC PID variable + FILL_MAP_LB(tpcNSigmaPi1), + // TOF PID variable + FILL_MAP_LB(tofNSigmaPi1), + // Combined PID variable + FILL_MAP_LB(tpcTofNSigmaPi1)}; + } +}; + +} // namespace o2::analysis + +#undef FILL_MAP_LB +#undef CHECK_AND_FILL_VEC_LB_FULL +#undef CHECK_AND_FILL_VEC_LB_FUNC +#undef CHECK_AND_FILL_VEC_LB + +#endif // PWGHF_CORE_HFMLRESPONSELBTOLCPI_H_ diff --git a/PWGHF/Core/HfMlResponseLcToK0sP.h b/PWGHF/Core/HfMlResponseLcToK0sP.h index 2dc78cb19d1..a3484c029cb 100644 --- a/PWGHF/Core/HfMlResponseLcToK0sP.h +++ b/PWGHF/Core/HfMlResponseLcToK0sP.h @@ -17,19 +17,20 @@ #ifndef PWGHF_CORE_HFMLRESPONSELCTOK0SP_H_ #define PWGHF_CORE_HFMLRESPONSELCTOK0SP_H_ -#include -#include -#include - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponse.h" +#include "Tools/ML/MlResponse.h" + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures -#define FILL_MAP_LC(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesLcToK0sP::FEATURE) \ +#define FILL_MAP_LC(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesLcToK0sP::FEATURE) \ } // Check if the index of mCachedIndices (index associated to a FEATURE) diff --git a/PWGHF/Core/HfMlResponseLcToPKPi.h b/PWGHF/Core/HfMlResponseLcToPKPi.h index ea4767b85c6..6c09afdbe8f 100644 --- a/PWGHF/Core/HfMlResponseLcToPKPi.h +++ b/PWGHF/Core/HfMlResponseLcToPKPi.h @@ -16,16 +16,22 @@ #ifndef PWGHF_CORE_HFMLRESPONSELCTOPKPI_H_ #define PWGHF_CORE_HFMLRESPONSELCTOPKPI_H_ -#include - #include "PWGHF/Core/HfMlResponse.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" + +#include "Tools/ML/MlResponse.h" + +#include +#include +#include +#include // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures -#define FILL_MAP_LCTOPKPI(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesLcToPKPi::FEATURE) \ +#define FILL_MAP_LCTOPKPI(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesLcToPKPi::FEATURE) \ } // Check if the index of mCachedIndices (index associated to a FEATURE) @@ -67,6 +73,18 @@ break; \ } +// Variation of CHECK_AND_FILL_VEC_LCTOPKPI_HFHELPER_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) +// where GETTER1 and GETTER2 are methods of the OBJECT +#define CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) \ + case static_cast(InputFeaturesLcToPKPi::FEATURE): { \ + if (caseLcToPKPi) { \ + inputFeatures.emplace_back(OBJECT.GETTER1()); \ + } else { \ + inputFeatures.emplace_back(OBJECT.GETTER2()); \ + } \ + break; \ + } + namespace o2::analysis { enum class InputFeaturesLcToPKPi : uint8_t { @@ -85,22 +103,22 @@ enum class InputFeaturesLcToPKPi : uint8_t { cpa, cpaXY, chi2PCA, - tpcNSigmaP0, // 0 + tpcNSigmaPr0, // 0 tpcNSigmaKa0, // 0 tpcNSigmaPi0, // 0 - tpcNSigmaP1, // 1 + tpcNSigmaPr1, // 1 tpcNSigmaKa1, // 1 tpcNSigmaPi1, // 1 - tpcNSigmaP2, // 2 + tpcNSigmaPr2, // 2 tpcNSigmaKa2, // 2 tpcNSigmaPi2, // 2 - tofNSigmaP0, // + tofNSigmaPr0, // tofNSigmaKa0, // tofNSigmaPi0, // - tofNSigmaP1, + tofNSigmaPr1, tofNSigmaKa1, tofNSigmaPi1, - tofNSigmaP2, + tofNSigmaPr2, tofNSigmaKa2, tofNSigmaPi2, tpcTofNSigmaPi0, @@ -117,10 +135,22 @@ enum class InputFeaturesLcToPKPi : uint8_t { tofNSigmaPrExpPr0, tofNSigmaPiExpPi2, tpcTofNSigmaPrExpPr0, - tpcTofNSigmaPiExpPi2 + tpcTofNSigmaPiExpPi2, + kfChi2PrimProton, + kfChi2PrimKaon, + kfChi2PrimPion, + kfChi2GeoKaonPion, + kfChi2GeoProtonPion, + kfChi2GeoProtonKaon, + kfDcaKaonPion, + kfDcaProtonPion, + kfDcaProtonKaon, + kfChi2Geo, + kfChi2Topo, + kfDecayLengthNormalised }; -template +template class HfMlResponseLcToPKPi : public HfMlResponse { public: @@ -135,9 +165,8 @@ class HfMlResponseLcToPKPi : public HfMlResponse /// \param prong1 is the candidate's prong1 /// \param prong2 is the candidate's prong2 /// \return inputFeatures vector - template - std::vector getInputFeatures(T1 const& candidate, - T2 const& prong0, T2 const& prong1, T2 const& prong2, bool const& caseLcToPKPi) + template + std::vector getInputFeatures(T1 const& candidate, bool const caseLcToPKPi) { std::vector inputFeatures; @@ -159,44 +188,62 @@ class HfMlResponseLcToPKPi : public HfMlResponse CHECK_AND_FILL_VEC_LCTOPKPI(cpaXY); CHECK_AND_FILL_VEC_LCTOPKPI(chi2PCA); // TPC PID variables - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tpcNSigmaP0, tpcNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tpcNSigmaKa0, tpcNSigmaKa); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tpcNSigmaPi0, tpcNSigmaPi); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tpcNSigmaP1, tpcNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tpcNSigmaKa1, tpcNSigmaKa); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong2, tpcNSigmaP2, tpcNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong2, tpcNSigmaKa2, tpcNSigmaKa); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong2, tpcNSigmaPi2, tpcNSigmaPi); - CHECK_AND_FILL_VEC_LCTOPKPI_OBJECT_SIGNED(prong0, prong2, tpcNSigmaPrExpPr0, tpcNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_OBJECT_SIGNED(prong2, prong0, tpcNSigmaPiExpPi2, tpcNSigmaPi); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcNSigmaPr0, nSigTpcPr0); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcNSigmaKa0, nSigTpcKa0); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcNSigmaPi0, nSigTpcPi0); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcNSigmaPr1, nSigTpcPr1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcNSigmaKa1, nSigTpcKa1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcNSigmaPi1, nSigTpcPi1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcNSigmaPr2, nSigTpcPr2); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcNSigmaKa2, nSigTpcKa2); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcNSigmaPi2, nSigTpcPi2); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, tpcNSigmaPrExpPr0, nSigTpcPr0, nSigTpcPr2); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, tpcNSigmaPiExpPi2, nSigTpcPi2, nSigTpcPi0); // TOF PID variables - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tofNSigmaP0, tofNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tofNSigmaKa0, tofNSigmaKa); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tofNSigmaPi0, tofNSigmaPi); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tofNSigmaP1, tofNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tofNSigmaKa1, tofNSigmaKa); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong2, tofNSigmaP2, tofNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong2, tofNSigmaKa2, tofNSigmaKa); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong2, tofNSigmaPi2, tofNSigmaPi); - CHECK_AND_FILL_VEC_LCTOPKPI_OBJECT_SIGNED(prong0, prong2, tofNSigmaPrExpPr0, tofNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_OBJECT_SIGNED(prong2, prong0, tofNSigmaPiExpPi2, tofNSigmaPi); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tofNSigmaPr0, nSigTofPr0); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tofNSigmaKa0, nSigTofKa0); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tofNSigmaPi0, nSigTofPi0); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tofNSigmaPr1, nSigTofPr1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tofNSigmaKa1, nSigTofKa1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tofNSigmaPi1, nSigTofPi1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tofNSigmaPr2, nSigTofPr2); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tofNSigmaKa2, nSigTofKa2); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tofNSigmaPi2, nSigTofPi2); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, tofNSigmaPrExpPr0, nSigTofPr0, nSigTofPr2); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, tofNSigmaPiExpPi2, nSigTofPi2, nSigTofPi0); // Combined PID variables - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tpcTofNSigmaPi0, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tpcTofNSigmaPi1, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong2, tpcTofNSigmaPi2, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tpcTofNSigmaKa0, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tpcTofNSigmaKa1, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong2, tpcTofNSigmaKa2, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tpcTofNSigmaPr0, tpcTofNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tpcTofNSigmaPr1, tpcTofNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong2, tpcTofNSigmaPr2, tpcTofNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_OBJECT_SIGNED(prong0, prong2, tpcTofNSigmaPrExpPr0, tpcTofNSigmaPr); - CHECK_AND_FILL_VEC_LCTOPKPI_OBJECT_SIGNED(prong2, prong0, tpcTofNSigmaPiExpPi2, tpcTofNSigmaPi); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcTofNSigmaPi0, tpcTofNSigmaPi0); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcTofNSigmaPi1, tpcTofNSigmaPi1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcTofNSigmaPi2, tpcTofNSigmaPi2); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcTofNSigmaKa0, tpcTofNSigmaKa0); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcTofNSigmaKa1, tpcTofNSigmaKa1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcTofNSigmaKa2, tpcTofNSigmaKa2); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcTofNSigmaPr0, tpcTofNSigmaPr0); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcTofNSigmaPr1, tpcTofNSigmaPr1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, tpcTofNSigmaPr2, tpcTofNSigmaPr2); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, tpcTofNSigmaPrExpPr0, tpcTofNSigmaPr0, tpcTofNSigmaPr2); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, tpcTofNSigmaPiExpPi2, tpcTofNSigmaPi2, tpcTofNSigmaPi0); + } + if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { + switch (idx) { + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, kfChi2PrimProton, kfChi2PrimProng0, kfChi2PrimProng2); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, kfChi2PrimKaon, kfChi2PrimProng1); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, kfChi2PrimPion, kfChi2PrimProng2, kfChi2PrimProng0); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, kfChi2GeoKaonPion, kfChi2GeoProng1Prong2, kfChi2GeoProng0Prong1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, kfChi2GeoProtonPion, kfChi2GeoProng0Prong2); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, kfChi2GeoProtonKaon, kfChi2GeoProng0Prong1, kfChi2GeoProng1Prong2); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, kfDcaKaonPion, kfDcaProng1Prong2, kfDcaProng0Prong1); + CHECK_AND_FILL_VEC_LCTOPKPI_FULL(candidate, kfDcaProtonPion, kfDcaProng0Prong2); + CHECK_AND_FILL_VEC_LCTOPKPI_SIGNED(candidate, kfDcaProtonKaon, kfDcaProng0Prong1, kfDcaProng1Prong2); + CHECK_AND_FILL_VEC_LCTOPKPI(kfChi2Geo); + CHECK_AND_FILL_VEC_LCTOPKPI(kfChi2Topo); + case static_cast(InputFeaturesLcToPKPi::kfDecayLengthNormalised): { + inputFeatures.emplace_back(candidate.kfDecayLength() / candidate.kfDecayLengthError()); + break; + } + } } } - return inputFeatures; } @@ -221,25 +268,25 @@ class HfMlResponseLcToPKPi : public HfMlResponse FILL_MAP_LCTOPKPI(cpaXY), FILL_MAP_LCTOPKPI(chi2PCA), // TPC PID variables - FILL_MAP_LCTOPKPI(tpcNSigmaP0), + FILL_MAP_LCTOPKPI(tpcNSigmaPr0), FILL_MAP_LCTOPKPI(tpcNSigmaKa0), FILL_MAP_LCTOPKPI(tpcNSigmaPi0), - FILL_MAP_LCTOPKPI(tpcNSigmaP1), + FILL_MAP_LCTOPKPI(tpcNSigmaPr1), FILL_MAP_LCTOPKPI(tpcNSigmaKa1), FILL_MAP_LCTOPKPI(tpcNSigmaPi1), - FILL_MAP_LCTOPKPI(tpcNSigmaP2), + FILL_MAP_LCTOPKPI(tpcNSigmaPr2), FILL_MAP_LCTOPKPI(tpcNSigmaKa2), FILL_MAP_LCTOPKPI(tpcNSigmaPi2), FILL_MAP_LCTOPKPI(tpcNSigmaPrExpPr0), FILL_MAP_LCTOPKPI(tpcNSigmaPiExpPi2), // TOF PID variables - FILL_MAP_LCTOPKPI(tofNSigmaP0), + FILL_MAP_LCTOPKPI(tofNSigmaPr0), FILL_MAP_LCTOPKPI(tofNSigmaKa0), FILL_MAP_LCTOPKPI(tofNSigmaPi0), - FILL_MAP_LCTOPKPI(tofNSigmaP1), + FILL_MAP_LCTOPKPI(tofNSigmaPr1), FILL_MAP_LCTOPKPI(tofNSigmaKa1), FILL_MAP_LCTOPKPI(tofNSigmaPi1), - FILL_MAP_LCTOPKPI(tofNSigmaP2), + FILL_MAP_LCTOPKPI(tofNSigmaPr2), FILL_MAP_LCTOPKPI(tofNSigmaKa2), FILL_MAP_LCTOPKPI(tofNSigmaPi2), FILL_MAP_LCTOPKPI(tofNSigmaPrExpPr0), @@ -256,6 +303,23 @@ class HfMlResponseLcToPKPi : public HfMlResponse FILL_MAP_LCTOPKPI(tpcTofNSigmaPr2), FILL_MAP_LCTOPKPI(tpcTofNSigmaPrExpPr0), FILL_MAP_LCTOPKPI(tpcTofNSigmaPiExpPi2)}; + if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { + std::map mapKfFeatures{ + // KFParticle variables + FILL_MAP_LCTOPKPI(kfChi2PrimProton), + FILL_MAP_LCTOPKPI(kfChi2PrimKaon), + FILL_MAP_LCTOPKPI(kfChi2PrimPion), + FILL_MAP_LCTOPKPI(kfChi2GeoKaonPion), + FILL_MAP_LCTOPKPI(kfChi2GeoProtonPion), + FILL_MAP_LCTOPKPI(kfChi2GeoProtonKaon), + FILL_MAP_LCTOPKPI(kfDcaKaonPion), + FILL_MAP_LCTOPKPI(kfDcaProtonPion), + FILL_MAP_LCTOPKPI(kfDcaProtonKaon), + FILL_MAP_LCTOPKPI(kfChi2Geo), + FILL_MAP_LCTOPKPI(kfChi2Topo), + FILL_MAP_LCTOPKPI(kfDecayLengthNormalised)}; + MlResponse::mAvailableInputFeatures.insert(mapKfFeatures.begin(), mapKfFeatures.end()); + } } }; diff --git a/PWGHF/Core/HfMlResponseOmegacToOmegaPi.h b/PWGHF/Core/HfMlResponseOmegacToOmegaPi.h new file mode 100644 index 00000000000..c61616cc9d4 --- /dev/null +++ b/PWGHF/Core/HfMlResponseOmegacToOmegaPi.h @@ -0,0 +1,182 @@ +// 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. + +/// \file HfMlResponseOmegacToOmegaPi.h +/// \brief Class to compute the ML response for Ωc± → Ω∓ π± analysis selections +/// \author Yunfan Liu , China University of Geosciences + +#ifndef PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPI_H_ +#define PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPI_H_ + +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponse.h" + +#include "Tools/ML/MlResponse.h" + +#include +#include + +// Fill the map of available input features +// the key is the feature's name (std::string) +// the value is the corresponding value in EnumInputFeatures +#define FILL_MAP_OMEGAC0(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesOmegacToOmegaPi::FEATURE) \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER from OBJECT +#define CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesOmegacToOmegaPi::FEATURE): { \ + inputFeatures.emplace_back(OBJECT.GETTER()); \ + break; \ + } + +// Specific case of CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate and FEATURE = GETTER +#define CHECK_AND_FILL_VEC_OMEGAC0(GETTER) \ + case static_cast(InputFeaturesOmegacToOmegaPi::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + +// Variation of CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER) +// where GETTER is a method of hfHelper +#define CHECK_AND_FILL_VEC_OMEGAC0_HFHELPER(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesOmegacToOmegaPi::FEATURE): { \ + inputFeatures.emplace_back(hfHelper.GETTER(OBJECT)); \ + break; \ + } +namespace o2::analysis +{ +enum class InputFeaturesOmegacToOmegaPi : uint8_t { + + cosPaOmegacToPv = 0, + kfDcaXYPiFromOmegac, + chi2TopoPiFromOmegacToPv, + dcaCharmBaryonDau, + invMassCascade, + massCascChi2OverNdf, + kfDcaXYCascToPv, + cosPaCascToPv, + cosThetaStarPiFromOmegac, + chi2NdfTopoOmegacToPv, + ldlCasc, + dcaCascDau, + cosPaCascToOmegac, + decayLenXYCasc, + ldlOmegac, + chi2NdfTopoCascToOmegac, + chi2NdfTopoCascToPv, + chi2GeoOmegac, + chi2GeoCasc, + + nSigmaTPCPiFromV0, + nSigmaTPCPiFromOmegac, + nSigmaTPCKaFromCasc + +}; + +template +class HfMlResponseOmegacToOmegaPi : public HfMlResponse +{ + public: + /// Default constructor + HfMlResponseOmegacToOmegaPi() = default; + /// Default destructor + virtual ~HfMlResponseOmegacToOmegaPi() = default; + + HfHelper hfHelper; + + /// Method to get the input features vector needed for ML inference + /// \param candidate is the OMEGAC0 candidate + /// \param lamProngPi is the candidate's lamProngPi + /// \return inputFeatures vector + template + std::vector getInputFeatures(T1 const& candidate, T2 const& lamProngPi, T2 const& cascProng, T3 const& charmBaryonProng) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, cosPaOmegacToPv, cosPACharmBaryon); + CHECK_AND_FILL_VEC_OMEGAC0(kfDcaXYPiFromOmegac); + CHECK_AND_FILL_VEC_OMEGAC0(chi2TopoPiFromOmegacToPv); + CHECK_AND_FILL_VEC_OMEGAC0(dcaCharmBaryonDau); + CHECK_AND_FILL_VEC_OMEGAC0(invMassCascade); + CHECK_AND_FILL_VEC_OMEGAC0(massCascChi2OverNdf); + CHECK_AND_FILL_VEC_OMEGAC0(kfDcaXYCascToPv); + CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, cosPaCascToPv, cosPACasc); + CHECK_AND_FILL_VEC_OMEGAC0(cosThetaStarPiFromOmegac); + CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, chi2NdfTopoOmegacToPv, chi2TopoOmegacToPv); + CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, ldlCasc, cascldl); + CHECK_AND_FILL_VEC_OMEGAC0(dcaCascDau); + CHECK_AND_FILL_VEC_OMEGAC0(cosPaCascToOmegac); + CHECK_AND_FILL_VEC_OMEGAC0(decayLenXYCasc); + CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, ldlOmegac, omegacldl); + CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, chi2NdfTopoCascToOmegac, chi2TopoCascToOmegac); + CHECK_AND_FILL_VEC_OMEGAC0_FULL(candidate, chi2NdfTopoCascToPv, chi2TopoCascToPv); + CHECK_AND_FILL_VEC_OMEGAC0(chi2GeoOmegac); + CHECK_AND_FILL_VEC_OMEGAC0(chi2GeoCasc); + + // TPC PID variables + CHECK_AND_FILL_VEC_OMEGAC0_FULL(lamProngPi, nSigmaTPCPiFromV0, tpcNSigmaPi); + CHECK_AND_FILL_VEC_OMEGAC0_FULL(cascProng, nSigmaTPCKaFromCasc, tpcNSigmaKa); + CHECK_AND_FILL_VEC_OMEGAC0_FULL(charmBaryonProng, nSigmaTPCPiFromOmegac, tpcNSigmaPi); + } + } + + return inputFeatures; + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + + FILL_MAP_OMEGAC0(cosPaOmegacToPv), + FILL_MAP_OMEGAC0(kfDcaXYPiFromOmegac), + FILL_MAP_OMEGAC0(chi2TopoPiFromOmegacToPv), + FILL_MAP_OMEGAC0(dcaCharmBaryonDau), + FILL_MAP_OMEGAC0(invMassCascade), + FILL_MAP_OMEGAC0(massCascChi2OverNdf), + FILL_MAP_OMEGAC0(kfDcaXYCascToPv), + FILL_MAP_OMEGAC0(cosPaCascToPv), + FILL_MAP_OMEGAC0(cosThetaStarPiFromOmegac), + FILL_MAP_OMEGAC0(chi2NdfTopoOmegacToPv), + FILL_MAP_OMEGAC0(ldlCasc), + FILL_MAP_OMEGAC0(dcaCascDau), + FILL_MAP_OMEGAC0(cosPaCascToOmegac), + FILL_MAP_OMEGAC0(decayLenXYCasc), + FILL_MAP_OMEGAC0(ldlOmegac), + FILL_MAP_OMEGAC0(chi2NdfTopoCascToOmegac), + FILL_MAP_OMEGAC0(chi2NdfTopoCascToPv), + FILL_MAP_OMEGAC0(chi2GeoOmegac), + FILL_MAP_OMEGAC0(chi2GeoCasc), + + FILL_MAP_OMEGAC0(nSigmaTPCPiFromV0), + FILL_MAP_OMEGAC0(nSigmaTPCKaFromCasc), + FILL_MAP_OMEGAC0(nSigmaTPCPiFromOmegac), + + }; + } +}; + +} // namespace o2::analysis + +#undef FILL_MAP_OMEGAC0 +#undef CHECK_AND_FILL_VEC_OMEGAC0_FULL +#undef CHECK_AND_FILL_VEC_OMEGAC0 +#undef CHECK_AND_FILL_VEC_OMEGAC0_HFHELPER +#endif // PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPI_H_ diff --git a/PWGHF/Core/HfMlResponseXic0ToXiPiKf.h b/PWGHF/Core/HfMlResponseXic0ToXiPiKf.h new file mode 100644 index 00000000000..3fbb6cf4052 --- /dev/null +++ b/PWGHF/Core/HfMlResponseXic0ToXiPiKf.h @@ -0,0 +1,147 @@ +// 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. + +/// \file HfMlResponseXic0ToXiPiKf.h +/// \brief Class to compute the ML response for Ξc^0 → Ξ∓ π± kf analysis selections +/// \author Tao Fang , Central China Normal University + +#ifndef PWGHF_CORE_HFMLRESPONSEXIC0TOXIPIKF_H_ +#define PWGHF_CORE_HFMLRESPONSEXIC0TOXIPIKF_H_ + +#include "PWGHF/Core/HfMlResponse.h" + +#include "Tools/ML/MlResponse.h" + +#include +#include + +// Fill the map of available input features +// the key is the feature's name (std::string) +// the value is the corresponding value in EnumInputFeatures +#define FILL_MAP_XIC0TOXIPIKF(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesXic0ToXiPiKf::FEATURE) \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER from OBJECT +#define CHECK_AND_FILL_VEC_XIC0TOXIPIKF_FULL(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesXic0ToXiPiKf::FEATURE): { \ + inputFeatures.emplace_back(OBJECT.GETTER()); \ + break; \ + } + +// where OBJECT is named candidate and FEATURE = GETTER +#define CHECK_AND_FILL_VEC_XIC0TOXIPIKF(GETTER) \ + case static_cast(InputFeaturesXic0ToXiPiKf::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + +namespace o2::analysis +{ + +enum class InputFeaturesXic0ToXiPiKf : uint8_t { + tpcNSigmaPiFromLambda, + tpcNSigmaPiFromCasc, + tpcNSigmaPiFromCharmBaryon, + dcaCascDau, + dcaCharmBaryonDau, + kfDcaXYPiFromXic, + kfDcaXYCascToPv, + cascChi2OverNdf, + xicChi2OverNdf, + cascldl, + chi2TopoCascToPv, + chi2TopoCascToXic, + cosPaCascToXic, + decayLenXYCasc +}; + +template +class HfMlResponseXic0ToXiPiKf : public HfMlResponse +{ + public: + /// Default constructor + HfMlResponseXic0ToXiPiKf() = default; + /// Default destructor + virtual ~HfMlResponseXic0ToXiPiKf() = default; + + /// Method to get the input features vector needed for ML inference + /// \param candidate is the Xic0 candidate + /// \return inputFeatures vector + template + // std::vector getInputFeatures(T1 const& candidate) + std::vector getInputFeatures(T1 const& candidate, T2 const& lamProngPi, T2 const& cascProngPi, T3 const& charmBaryonProngPi) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + // PID variables + CHECK_AND_FILL_VEC_XIC0TOXIPIKF_FULL(lamProngPi, tpcNSigmaPiFromLambda, tpcNSigmaPi); + CHECK_AND_FILL_VEC_XIC0TOXIPIKF_FULL(cascProngPi, tpcNSigmaPiFromCasc, tpcNSigmaPi); + CHECK_AND_FILL_VEC_XIC0TOXIPIKF_FULL(charmBaryonProngPi, tpcNSigmaPiFromCharmBaryon, tpcNSigmaPi); + // DCA + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(dcaCascDau); + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(dcaCharmBaryonDau); + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(kfDcaXYPiFromXic); + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(kfDcaXYCascToPv); + // Chi2Geo + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(cascChi2OverNdf); + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(xicChi2OverNdf); + // ldl + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(cascldl); + // Chi2Topo + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(chi2TopoCascToPv); + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(chi2TopoCascToXic); + // CosPa + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(cosPaCascToXic); + // Decay length + CHECK_AND_FILL_VEC_XIC0TOXIPIKF(decayLenXYCasc); + } + } + + return inputFeatures; + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + FILL_MAP_XIC0TOXIPIKF(tpcNSigmaPiFromLambda), + FILL_MAP_XIC0TOXIPIKF(tpcNSigmaPiFromCasc), + FILL_MAP_XIC0TOXIPIKF(tpcNSigmaPiFromCharmBaryon), + FILL_MAP_XIC0TOXIPIKF(dcaCascDau), + FILL_MAP_XIC0TOXIPIKF(dcaCharmBaryonDau), + FILL_MAP_XIC0TOXIPIKF(kfDcaXYPiFromXic), + FILL_MAP_XIC0TOXIPIKF(kfDcaXYCascToPv), + FILL_MAP_XIC0TOXIPIKF(cascChi2OverNdf), + FILL_MAP_XIC0TOXIPIKF(xicChi2OverNdf), + FILL_MAP_XIC0TOXIPIKF(cascldl), + FILL_MAP_XIC0TOXIPIKF(chi2TopoCascToPv), + FILL_MAP_XIC0TOXIPIKF(chi2TopoCascToXic), + FILL_MAP_XIC0TOXIPIKF(cosPaCascToXic), + FILL_MAP_XIC0TOXIPIKF(decayLenXYCasc), + }; + } +}; + +} // namespace o2::analysis + +#undef FILL_MAP_XIC0TOXIPIKF +#undef CHECK_AND_FILL_VEC_XIC0TOXIPIKF_FULL +#undef CHECK_AND_FILL_VEC_XIC0TOXIPIKF + +#endif // PWGHF_CORE_HFMLRESPONSEXIC0TOXIPIKF_H_ diff --git a/PWGHF/Core/HfMlResponseXicToPKPi.h b/PWGHF/Core/HfMlResponseXicToPKPi.h index 94542745772..f433d29bd5d 100644 --- a/PWGHF/Core/HfMlResponseXicToPKPi.h +++ b/PWGHF/Core/HfMlResponseXicToPKPi.h @@ -16,18 +16,19 @@ #ifndef PWGHF_CORE_HFMLRESPONSEXICTOPKPI_H_ #define PWGHF_CORE_HFMLRESPONSEXICTOPKPI_H_ -#include -#include -#include - #include "PWGHF/Core/HfMlResponse.h" +#include "Tools/ML/MlResponse.h" + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures -#define FILL_MAP_XIC(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesXicToPKPi::FEATURE) \ +#define FILL_MAP_XIC(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesXicToPKPi::FEATURE) \ } // Check if the index of mCachedIndices (index associated to a FEATURE) @@ -61,6 +62,19 @@ break; \ } +// Variation of CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) +// where GETTER1 and GETTER2 are methods of the OBJECT, and used +// depending on whether the candidate is a XicToPKPi or a XicToPiKP +#define CHECK_AND_FILL_VEC_XIC_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) \ + case static_cast(InputFeaturesXicToPKPi::FEATURE): { \ + if (caseXicToPKPi) { \ + inputFeatures.emplace_back(OBJECT.GETTER1()); \ + } else { \ + inputFeatures.emplace_back(OBJECT.GETTER2()); \ + } \ + break; \ + } + namespace o2::analysis { enum class InputFeaturesXicToPKPi : uint8_t { @@ -79,22 +93,22 @@ enum class InputFeaturesXicToPKPi : uint8_t { cpa, cpaXY, chi2PCA, - tpcNSigmaP0, // 0 + tpcNSigmaPr0, // 0 tpcNSigmaKa0, // 0 tpcNSigmaPi0, // 0 - tpcNSigmaP1, // 1 + tpcNSigmaPr1, // 1 tpcNSigmaKa1, // 1 tpcNSigmaPi1, // 1 - tpcNSigmaP2, // 2 + tpcNSigmaPr2, // 2 tpcNSigmaKa2, // 2 tpcNSigmaPi2, // 2 - tofNSigmaP0, // + tofNSigmaPr0, // tofNSigmaKa0, // tofNSigmaPi0, // - tofNSigmaP1, + tofNSigmaPr1, tofNSigmaKa1, tofNSigmaPi1, - tofNSigmaP2, + tofNSigmaPr2, tofNSigmaKa2, tofNSigmaPi2, tpcTofNSigmaPi0, @@ -129,9 +143,8 @@ class HfMlResponseXicToPKPi : public HfMlResponse /// \param prong1 is the candidate's prong1 /// \param prong2 is the candidate's prong2 /// \return inputFeatures vector - template - std::vector getInputFeatures(T1 const& candidate, - T2 const& prong0, T2 const& prong1, T2 const& prong2, bool const& caseXicToPKPi) + template + std::vector getInputFeatures(T1 const& candidate, bool const caseXicToPKPi) { std::vector inputFeatures; @@ -153,41 +166,41 @@ class HfMlResponseXicToPKPi : public HfMlResponse CHECK_AND_FILL_VEC_XIC(cpaXY); CHECK_AND_FILL_VEC_XIC(chi2PCA); // TPC PID variables - CHECK_AND_FILL_VEC_XIC_FULL(prong0, tpcNSigmaP0, tpcNSigmaPr); - CHECK_AND_FILL_VEC_XIC_FULL(prong0, tpcNSigmaKa0, tpcNSigmaKa); - CHECK_AND_FILL_VEC_XIC_FULL(prong0, tpcNSigmaPi0, tpcNSigmaPi); - CHECK_AND_FILL_VEC_XIC_FULL(prong1, tpcNSigmaP1, tpcNSigmaPr); - CHECK_AND_FILL_VEC_XIC_FULL(prong1, tpcNSigmaKa1, tpcNSigmaKa); - CHECK_AND_FILL_VEC_XIC_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); - CHECK_AND_FILL_VEC_XIC_FULL(prong2, tpcNSigmaP2, tpcNSigmaPr); - CHECK_AND_FILL_VEC_XIC_FULL(prong2, tpcNSigmaKa2, tpcNSigmaKa); - CHECK_AND_FILL_VEC_XIC_FULL(prong2, tpcNSigmaPi2, tpcNSigmaPi); - CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED(prong0, prong2, tpcNSigmaPrExpPr0, tpcNSigmaPr); - CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED(prong2, prong0, tpcNSigmaPiExpPi2, tpcNSigmaPi); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcNSigmaPr0, nSigTpcPr0); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcNSigmaKa0, nSigTpcKa0); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcNSigmaPi0, nSigTpcPi0); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcNSigmaPr1, nSigTpcPr1); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcNSigmaKa1, nSigTpcKa1); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcNSigmaPi1, nSigTpcPi1); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcNSigmaPr2, nSigTpcPr2); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcNSigmaKa2, nSigTpcKa2); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcNSigmaPi2, nSigTpcPi2); + CHECK_AND_FILL_VEC_XIC_SIGNED(candidate, tpcNSigmaPrExpPr0, nSigTpcPr0, nSigTpcPr2); + CHECK_AND_FILL_VEC_XIC_SIGNED(candidate, tpcNSigmaPiExpPi2, nSigTpcPi2, nSigTpcPi0); // TOF PID variables - CHECK_AND_FILL_VEC_XIC_FULL(prong0, tofNSigmaP0, tofNSigmaPr); - CHECK_AND_FILL_VEC_XIC_FULL(prong0, tofNSigmaKa0, tofNSigmaKa); - CHECK_AND_FILL_VEC_XIC_FULL(prong0, tofNSigmaPi0, tofNSigmaPi); - CHECK_AND_FILL_VEC_XIC_FULL(prong1, tofNSigmaP1, tofNSigmaPr); - CHECK_AND_FILL_VEC_XIC_FULL(prong1, tofNSigmaKa1, tofNSigmaKa); - CHECK_AND_FILL_VEC_XIC_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); - CHECK_AND_FILL_VEC_XIC_FULL(prong2, tofNSigmaP2, tofNSigmaPr); - CHECK_AND_FILL_VEC_XIC_FULL(prong2, tofNSigmaKa2, tofNSigmaKa); - CHECK_AND_FILL_VEC_XIC_FULL(prong2, tofNSigmaPi2, tofNSigmaPi); - CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED(prong0, prong2, tofNSigmaPrExpPr0, tofNSigmaPr); - CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED(prong2, prong0, tofNSigmaPiExpPi2, tofNSigmaPi); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tofNSigmaPr0, nSigTofPr0); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tofNSigmaKa0, nSigTofKa0); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tofNSigmaPi0, nSigTofPi0); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tofNSigmaPr1, nSigTofPr1); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tofNSigmaKa1, nSigTofKa1); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tofNSigmaPi1, nSigTofPi1); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tofNSigmaPr2, nSigTofPr2); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tofNSigmaKa2, nSigTofKa2); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tofNSigmaPi2, nSigTofPi2); + CHECK_AND_FILL_VEC_XIC_SIGNED(candidate, tofNSigmaPrExpPr0, nSigTofPr0, nSigTofPr2); + CHECK_AND_FILL_VEC_XIC_SIGNED(candidate, tofNSigmaPiExpPi2, nSigTofPi2, nSigTofPi0); // Combined PID variables - CHECK_AND_FILL_VEC_XIC_FULL(prong0, tpcTofNSigmaPi0, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_XIC_FULL(prong1, tpcTofNSigmaPi1, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_XIC_FULL(prong2, tpcTofNSigmaPi2, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_XIC_FULL(prong0, tpcTofNSigmaKa0, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_XIC_FULL(prong1, tpcTofNSigmaKa1, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_XIC_FULL(prong2, tpcTofNSigmaKa2, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_XIC_FULL(prong0, tpcTofNSigmaPr0, tpcTofNSigmaPr); - CHECK_AND_FILL_VEC_XIC_FULL(prong1, tpcTofNSigmaPr1, tpcTofNSigmaPr); - CHECK_AND_FILL_VEC_XIC_FULL(prong2, tpcTofNSigmaPr2, tpcTofNSigmaPr); - CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED(prong0, prong2, tpcTofNSigmaPrExpPr0, tpcTofNSigmaPr); - CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED(prong2, prong0, tpcTofNSigmaPiExpPi2, tpcTofNSigmaPi); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcTofNSigmaPi0, tpcTofNSigmaPi0); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcTofNSigmaPi1, tpcTofNSigmaPi1); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcTofNSigmaPi2, tpcTofNSigmaPi2); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcTofNSigmaKa0, tpcTofNSigmaKa0); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcTofNSigmaKa1, tpcTofNSigmaKa1); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcTofNSigmaKa2, tpcTofNSigmaKa2); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcTofNSigmaPr0, tpcTofNSigmaPr0); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcTofNSigmaPr1, tpcTofNSigmaPr1); + CHECK_AND_FILL_VEC_XIC_FULL(candidate, tpcTofNSigmaPr2, tpcTofNSigmaPr2); + CHECK_AND_FILL_VEC_XIC_SIGNED(candidate, tpcTofNSigmaPrExpPr0, tpcTofNSigmaPr0, tpcTofNSigmaPr2); + CHECK_AND_FILL_VEC_XIC_SIGNED(candidate, tpcTofNSigmaPiExpPi2, tpcTofNSigmaPi2, tpcTofNSigmaPi0); } } @@ -215,25 +228,25 @@ class HfMlResponseXicToPKPi : public HfMlResponse FILL_MAP_XIC(cpaXY), FILL_MAP_XIC(chi2PCA), // TPC PID variables - FILL_MAP_XIC(tpcNSigmaP0), + FILL_MAP_XIC(tpcNSigmaPr0), FILL_MAP_XIC(tpcNSigmaKa0), FILL_MAP_XIC(tpcNSigmaPi0), - FILL_MAP_XIC(tpcNSigmaP1), + FILL_MAP_XIC(tpcNSigmaPr1), FILL_MAP_XIC(tpcNSigmaKa1), FILL_MAP_XIC(tpcNSigmaPi1), - FILL_MAP_XIC(tpcNSigmaP2), + FILL_MAP_XIC(tpcNSigmaPr2), FILL_MAP_XIC(tpcNSigmaKa2), FILL_MAP_XIC(tpcNSigmaPi2), FILL_MAP_XIC(tpcNSigmaPrExpPr0), FILL_MAP_XIC(tpcNSigmaPiExpPi2), // TOF PID variables - FILL_MAP_XIC(tofNSigmaP0), + FILL_MAP_XIC(tofNSigmaPr0), FILL_MAP_XIC(tofNSigmaKa0), FILL_MAP_XIC(tofNSigmaPi0), - FILL_MAP_XIC(tofNSigmaP1), + FILL_MAP_XIC(tofNSigmaPr1), FILL_MAP_XIC(tofNSigmaKa1), FILL_MAP_XIC(tofNSigmaPi1), - FILL_MAP_XIC(tofNSigmaP2), + FILL_MAP_XIC(tofNSigmaPr2), FILL_MAP_XIC(tofNSigmaKa2), FILL_MAP_XIC(tofNSigmaPi2), FILL_MAP_XIC(tofNSigmaPrExpPr0), diff --git a/PWGHF/Core/HfMlResponseXicToXiPiPi.h b/PWGHF/Core/HfMlResponseXicToXiPiPi.h index 0a290e14d1d..4bb4a4d023f 100644 --- a/PWGHF/Core/HfMlResponseXicToXiPiPi.h +++ b/PWGHF/Core/HfMlResponseXicToXiPiPi.h @@ -16,12 +16,13 @@ #ifndef PWGHF_CORE_HFMLRESPONSEXICTOXIPIPI_H_ #define PWGHF_CORE_HFMLRESPONSEXICTOXIPIPI_H_ -#include -#include -#include - #include "PWGHF/Core/HfMlResponse.h" +#include "Tools/ML/MlResponse.h" + +#include +#include + // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures @@ -62,13 +63,32 @@ enum class InputFeaturesXicToXiPiPi : uint8_t { decayLengthXYNormalised, cpa, cpaXY, - cosPaXi, - cosPaXYXi, - cosPaLambda, - cosPaXYLambda, - impactParameterXY0, - impactParameterXY1, - impactParameterXY2 + cpaXi, + cpaXYXi, + cpaLambda, + cpaXYLambda, + impactParameterXi, + impactParameterPi0, + impactParameterPi1, + invMassXi, + invMassLambda, + dcaXiDaughters, + dcaV0Daughters, + dcaPosToPV, + dcaNegToPV, + dcaBachelorToPV, + dcaXYCascToPV, + dcaZCascToPV, + nSigTpcPiFromXicPlus0, + nSigTpcPiFromXicPlus1, + nSigTpcBachelorPi, + nSigTpcPiFromLambda, + nSigTpcPrFromLambda, + nSigTofPiFromXicPlus0, + nSigTofPiFromXicPlus1, + nSigTofBachelorPi, + nSigTofPiFromLambda, + nSigTofPrFromLambda }; template @@ -100,13 +120,32 @@ class HfMlResponseXicToXiPiPi : public HfMlResponse CHECK_AND_FILL_VEC_XICTOXIPIPI(decayLengthXYNormalised); CHECK_AND_FILL_VEC_XICTOXIPIPI(cpa); CHECK_AND_FILL_VEC_XICTOXIPIPI(cpaXY); - CHECK_AND_FILL_VEC_XICTOXIPIPI(cosPaXi); - CHECK_AND_FILL_VEC_XICTOXIPIPI(cosPaXYXi); - CHECK_AND_FILL_VEC_XICTOXIPIPI(cosPaLambda); - CHECK_AND_FILL_VEC_XICTOXIPIPI(cosPaXYLambda); - CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(candidate, impactParameterXY0, impactParameter0); - CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(candidate, impactParameterXY1, impactParameter1); - CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(candidate, impactParameterXY2, impactParameter2); + CHECK_AND_FILL_VEC_XICTOXIPIPI(cpaXi); + CHECK_AND_FILL_VEC_XICTOXIPIPI(cpaXYXi); + CHECK_AND_FILL_VEC_XICTOXIPIPI(cpaLambda); + CHECK_AND_FILL_VEC_XICTOXIPIPI(cpaXYLambda); + CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(candidate, impactParameterXi, impactParameter0); + CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(candidate, impactParameterPi0, impactParameter1); + CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(candidate, impactParameterPi1, impactParameter2); + CHECK_AND_FILL_VEC_XICTOXIPIPI(invMassXi); + CHECK_AND_FILL_VEC_XICTOXIPIPI(invMassLambda); + CHECK_AND_FILL_VEC_XICTOXIPIPI(dcaXiDaughters); + CHECK_AND_FILL_VEC_XICTOXIPIPI(dcaV0Daughters); + CHECK_AND_FILL_VEC_XICTOXIPIPI(dcaPosToPV); + CHECK_AND_FILL_VEC_XICTOXIPIPI(dcaNegToPV); + CHECK_AND_FILL_VEC_XICTOXIPIPI(dcaBachelorToPV); + CHECK_AND_FILL_VEC_XICTOXIPIPI(dcaXYCascToPV); + CHECK_AND_FILL_VEC_XICTOXIPIPI(dcaZCascToPV); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTpcPiFromXicPlus0); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTpcPiFromXicPlus1); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTpcBachelorPi); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTpcPiFromLambda); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTpcPrFromLambda); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTofPiFromXicPlus0); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTofPiFromXicPlus1); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTofBachelorPi); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTofPiFromLambda); + CHECK_AND_FILL_VEC_XICTOXIPIPI(nSigTofPrFromLambda); } } @@ -128,13 +167,32 @@ class HfMlResponseXicToXiPiPi : public HfMlResponse FILL_MAP_XICTOXIPIPI(decayLengthXYNormalised), FILL_MAP_XICTOXIPIPI(cpa), FILL_MAP_XICTOXIPIPI(cpaXY), - FILL_MAP_XICTOXIPIPI(cosPaXi), - FILL_MAP_XICTOXIPIPI(cosPaXYXi), - FILL_MAP_XICTOXIPIPI(cosPaLambda), - FILL_MAP_XICTOXIPIPI(cosPaXYLambda), - FILL_MAP_XICTOXIPIPI(impactParameterXY0), - FILL_MAP_XICTOXIPIPI(impactParameterXY1), - FILL_MAP_XICTOXIPIPI(impactParameterXY2)}; + FILL_MAP_XICTOXIPIPI(cpaXi), + FILL_MAP_XICTOXIPIPI(cpaXYXi), + FILL_MAP_XICTOXIPIPI(cpaLambda), + FILL_MAP_XICTOXIPIPI(cpaXYLambda), + FILL_MAP_XICTOXIPIPI(impactParameterXi), + FILL_MAP_XICTOXIPIPI(impactParameterPi0), + FILL_MAP_XICTOXIPIPI(impactParameterPi1), + FILL_MAP_XICTOXIPIPI(invMassXi), + FILL_MAP_XICTOXIPIPI(invMassLambda), + FILL_MAP_XICTOXIPIPI(dcaXiDaughters), + FILL_MAP_XICTOXIPIPI(dcaV0Daughters), + FILL_MAP_XICTOXIPIPI(dcaPosToPV), + FILL_MAP_XICTOXIPIPI(dcaNegToPV), + FILL_MAP_XICTOXIPIPI(dcaBachelorToPV), + FILL_MAP_XICTOXIPIPI(dcaXYCascToPV), + FILL_MAP_XICTOXIPIPI(dcaZCascToPV), + FILL_MAP_XICTOXIPIPI(nSigTpcPiFromXicPlus0), + FILL_MAP_XICTOXIPIPI(nSigTpcPiFromXicPlus1), + FILL_MAP_XICTOXIPIPI(nSigTpcBachelorPi), + FILL_MAP_XICTOXIPIPI(nSigTpcPiFromLambda), + FILL_MAP_XICTOXIPIPI(nSigTpcPrFromLambda), + FILL_MAP_XICTOXIPIPI(nSigTofPiFromXicPlus0), + FILL_MAP_XICTOXIPIPI(nSigTofPiFromXicPlus1), + FILL_MAP_XICTOXIPIPI(nSigTofBachelorPi), + FILL_MAP_XICTOXIPIPI(nSigTofPiFromLambda), + FILL_MAP_XICTOXIPIPI(nSigTofPrFromLambda)}; } }; diff --git a/PWGHF/Core/SelectorCuts.h b/PWGHF/Core/SelectorCuts.h index 014547d927d..a3df78aee0f 100644 --- a/PWGHF/Core/SelectorCuts.h +++ b/PWGHF/Core/SelectorCuts.h @@ -11,6 +11,8 @@ /// \file SelectorCuts.h /// \brief Default pT bins and cut arrays for heavy-flavour selectors and analysis tasks +/// +/// \author Anton Alkin , CERN #ifndef PWGHF_CORE_SELECTORCUTS_H_ #define PWGHF_CORE_SELECTORCUTS_H_ @@ -25,12 +27,12 @@ namespace o2::analysis namespace hf_cuts_single_track { -static constexpr int nBinsPtTrack = 6; -static constexpr int nCutVarsTrack = 4; +static constexpr int NBinsPtTrack = 6; +static constexpr int NCutVarsTrack = 4; // default values for the pT bin edges (can be used to configure histogram axis) // common for any candidate type (2-prong, 3-prong) // offset by 1 from the bin numbers in cuts array -constexpr double binsPtTrack[nBinsPtTrack + 1] = { +constexpr double BinsPtTrack[NBinsPtTrack + 1] = { 0, 0.5, 1.0, @@ -38,10 +40,10 @@ constexpr double binsPtTrack[nBinsPtTrack + 1] = { 2.0, 3.0, 1000.0}; -auto vecBinsPtTrack = std::vector{binsPtTrack, binsPtTrack + nBinsPtTrack + 1}; +auto vecBinsPtTrack = std::vector{BinsPtTrack, BinsPtTrack + NBinsPtTrack + 1}; // default values for the dca_xy and dca_z cuts of displaced tracks -constexpr double cutsTrack[nBinsPtTrack][nCutVarsTrack] = {{0.0000, 10., 0.0000, 100.}, /* 0 < pt < 0.5 */ +constexpr double CutsTrack[NBinsPtTrack][NCutVarsTrack] = {{0.0000, 10., 0.0000, 100.}, /* 0 < pt < 0.5 */ {0.0000, 10., 0.0000, 100.}, /* 0.5 < pt < 1 */ {0.0000, 10., 0.0000, 100.}, /* 1 < pt < 1.5 */ {0.0000, 10., 0.0000, 100.}, /* 1.5 < pt < 2 */ @@ -49,7 +51,7 @@ constexpr double cutsTrack[nBinsPtTrack][nCutVarsTrack] = {{0.0000, 10., 0.0000, {0.0000, 10., 0.0000, 100.}}; /* 3 < pt < 1000 */ // default values for the dca_xy and dca_z cuts of primary tracks (e.g. D* soft pions) -constexpr double cutsTrackPrimary[nBinsPtTrack][nCutVarsTrack] = {{0.0000, 2., 0.0000, 100.}, /* 0 < pt < 0.5 */ +constexpr double CutsTrackPrimary[NBinsPtTrack][NCutVarsTrack] = {{0.0000, 2., 0.0000, 100.}, /* 0 < pt < 0.5 */ {0.0000, 2., 0.0000, 100.}, /* 0.5 < pt < 1 */ {0.0000, 2., 0.0000, 100.}, /* 1 < pt < 1.5 */ {0.0000, 2., 0.0000, 100.}, /* 1.5 < pt < 2 */ @@ -66,7 +68,7 @@ static const std::vector labelsCutVarTrack = {"min_dcaxytoprimary", namespace hf_presel_pid { // default values for the PID cuts for protons in the track-index-skim-creator -constexpr float cutsPid[4][6] = {{0.f, 1000.f, 5.f, 0.f, 1000.f, 5.f}, +constexpr float CutsPid[4][6] = {{0.f, 1000.f, 5.f, 0.f, 1000.f, 5.f}, {0.f, 1000.f, 5.f, 0.f, 1000.f, 5.f}, {0.f, 1000.f, 5.f, 0.f, 1000.f, 5.f}, {0.f, 1000.f, 5.f, 0.f, 1000.f, 5.f}}; @@ -76,18 +78,18 @@ static const std::vector labelsRowsPid = {"ProtonInLcToPKPi", "Prot namespace hf_cuts_bdt_multiclass { -static constexpr int nBinsPt = 1; -static constexpr int nCutBdtScores = 3; +static constexpr int NBinsPt = 1; +static constexpr int NCutBdtScores = 3; // default values for the pT bin edges (can be used to configure histogram axis) // common for any charm candidate // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0., 1000.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutBdtScores] = {{0.1, 0.5, 0.5}}; +constexpr double Cuts[NBinsPt][NCutBdtScores] = {{0.1, 0.5, 0.5}}; // row labels static const std::vector labelsPt{}; @@ -115,10 +117,10 @@ enum CutDirection { CutNot // do not cut on score }; -static constexpr int nBinsPt = 12; -static constexpr int nCutScores = 3; +static constexpr int NBinsPt = 12; +static constexpr int NCutScores = 3; // default values for the pT bin edges, offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0., 1., 2., @@ -132,18 +134,18 @@ constexpr double binsPt[nBinsPt + 1] = { 16., 24., 50.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the ML model paths, one model per pT bin static const std::vector modelPaths = { ""}; // default values for the cut directions -constexpr int cutDir[nCutScores] = {CutGreater, CutSmaller, CutSmaller}; -auto vecCutDir = std::vector{cutDir, cutDir + nCutScores}; +constexpr int CutDir[NCutScores] = {CutGreater, CutSmaller, CutSmaller}; +auto vecCutDir = std::vector{CutDir, CutDir + NCutScores}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutScores] = { +constexpr double Cuts[NBinsPt][NCutScores] = { {0.5, 0.5, 0.5}, {0.5, 0.5, 0.5}, {0.5, 0.5, 0.5}, @@ -179,19 +181,19 @@ static const std::vector labelsDmesCutScore = {"ML score charm bkg" namespace hf_cuts_presel_2prong { -static constexpr int nBinsPt = 2; -static constexpr int nCutVars = 4; +static constexpr int NBinsPt = 2; +static constexpr int NCutVars = 4; // default values for the pT bin edges (can be used to configure histogram axis) // common for any 2-prong candidate // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 1., 5., 1000.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{1.65, 2.15, 0.5, 100.}, /* 1 < pt < 5 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{1.65, 2.15, 0.5, 100.}, /* 1 < pt < 5 */ {1.65, 2.15, 0.5, 100.}}; /* 5 < pt < 1000 */ // row labels @@ -203,19 +205,19 @@ static const std::vector labelsCutVar = {"massMin", "massMax", "cos namespace hf_cuts_presel_3prong { -static constexpr int nBinsPt = 2; -static constexpr int nCutVars = 4; +static constexpr int NBinsPt = 2; +static constexpr int NCutVars = 4; // default values for the pT bin edges (can be used to configure histogram axis) // common for any 3-prong candidate // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 1., 5., 1000.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{1.75, 2.05, 0.7, 0.02}, /* 1 < pt < 5 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{1.75, 2.05, 0.7, 0.02}, /* 1 < pt < 5 */ {1.75, 2.05, 0.5, 0.02}}; /* 5 < pt < 1000 */ // row labels @@ -227,18 +229,18 @@ static const std::vector labelsCutVar = {"massMin", "massMax", "cos namespace hf_cuts_presel_ds { -static constexpr int nBinsPt = 2; -static constexpr int nCutVars = 5; +static constexpr int NBinsPt = 2; +static constexpr int NCutVars = 5; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 1., 5., 1000.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{1.70, 2.15, 0.7, 0.02, 0.02}, /* 1 < pt < 5 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{1.70, 2.15, 0.7, 0.02, 0.02}, /* 1 < pt < 5 */ {1.70, 2.15, 0.5, 0.02, 0.02}}; /* 5 < pt < 1000 */ // row labels @@ -250,18 +252,18 @@ static const std::vector labelsCutVar = {"massMin", "massMax", "cos namespace hf_cuts_presel_dstar { -static constexpr int nBinsPt = 2; -static constexpr int nCutVars = 2; +static constexpr int NBinsPt = 2; +static constexpr int NCutVars = 2; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 1., 5., 1000.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{0.17, 0.05}, /* 1 < pt < 5 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.17, 0.05}, /* 1 < pt < 5 */ {0.17, 0.08}}; /* 5 < pt < 1000 */ // row labels @@ -273,11 +275,11 @@ static const std::vector labelsCutVar = {"deltaMassMax", "deltaMass namespace hf_cuts_d0_to_pi_k { -static constexpr int nBinsPt = 25; -static constexpr int nCutVars = 15; +static constexpr int NBinsPt = 25; +static constexpr int NCutVars = 15; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0, 0.5, 1.0, @@ -304,10 +306,10 @@ constexpr double binsPt[nBinsPt + 1] = { 36.0, 50.0, 100.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{0.400, 350. * 1E-4, 0.8, 0.5, 0.5, 1000. * 1E-4, 1000. * 1E-4, -5000. * 1E-8, 0.80, 0., 0., 10., 10., 0.06, 0.5}, /* 0 < pT < 0.5 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.400, 350. * 1E-4, 0.8, 0.5, 0.5, 1000. * 1E-4, 1000. * 1E-4, -5000. * 1E-8, 0.80, 0., 0., 10., 10., 0.06, 0.5}, /* 0 < pT < 0.5 */ {0.400, 350. * 1E-4, 0.8, 0.5, 0.5, 1000. * 1E-4, 1000. * 1E-4, -5000. * 1E-8, 0.80, 0., 0., 10., 10., 0.06, 0.5}, /* 0.5 < pT < 1 */ {0.400, 300. * 1E-4, 0.8, 0.4, 0.4, 1000. * 1E-4, 1000. * 1E-4, -25000. * 1E-8, 0.80, 0., 0., 10., 10., 0.06, 0.5}, /* 1 < pT < 1.5 */ {0.400, 300. * 1E-4, 0.8, 0.4, 0.4, 1000. * 1E-4, 1000. * 1E-4, -25000. * 1E-8, 0.80, 0., 0., 10., 10., 0.06, 0.5}, /* 1.5 < pT < 2 */ @@ -367,11 +369,11 @@ static const std::vector labelsCutVar = {"m", "DCA", "cos theta*", namespace hf_cuts_dstar_to_d0_pi { -static constexpr int nBinsPt = 25; -static constexpr int nCutVars = 8; +static constexpr int NBinsPt = 25; +static constexpr int NCutVars = 8; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0., 0.5, 1.0, @@ -398,7 +400,7 @@ constexpr double binsPt[nBinsPt + 1] = { 36.0, 50.0, 100.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // row labels static const std::vector labelsPt = { @@ -432,7 +434,7 @@ static const std::vector labelsPt = { static const std::vector labelsCutVar = {"ptSoftPiMin", "ptSoftPiMax", "d0SoftPi", "d0SoftPiNormalised", "deltaMInvDstar", "chi2PCA", "d0Prong0Normalised", "d0Prong1Normalised"}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{0.05, 0.2, 0.1, 1000.0, 0.2, 300.0, 0.0, 0.0}, +constexpr double Cuts[NBinsPt][NCutVars] = {{0.05, 0.2, 0.1, 1000.0, 0.2, 300.0, 0.0, 0.0}, {0.05, 0.2, 0.1, 1000.0, 0.2, 300.0, 0.0, 0.0}, {0.05, 0.3, 0.1, 1000.0, 0.2, 300.0, 0.0, 0.0}, {0.05, 0.3, 0.1, 1000.0, 0.2, 300.0, 0.0, 0.0}, @@ -461,11 +463,12 @@ constexpr double cuts[nBinsPt][nCutVars] = {{0.05, 0.2, 0.1, 1000.0, 0.2, 300.0, namespace hf_cuts_lc_to_p_k_pi { -static constexpr int nBinsPt = 10; -static constexpr int nCutVars = 11; +static constexpr int NBinsPt = 10; +static constexpr int NCutVars = 11; +static constexpr int NCutKfVars = 12; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0., 1., 2., @@ -477,10 +480,10 @@ constexpr double binsPt[nBinsPt + 1] = { 12., 24., 36.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts m, ptP, ptK, ptPi, chi2PCA, dL, cosp, dLXY, NdLXY, ImpParXY, mass(Kpi) -constexpr double cuts[nBinsPt][nCutVars] = {{0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 0 < pT < 1 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 0 < pT < 1 */ {0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 1 < pT < 2 */ {0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 2 < pT < 3 */ {0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 3 < pT < 4 */ @@ -491,6 +494,19 @@ constexpr double cuts[nBinsPt][nCutVars] = {{0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., {0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 12 < pT < 24 */ {0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}}; /* 24 < pT < 36 */ +// default value for the cuts Chi2Prim Chi2Geo DCA, cm Chi2Geo Chi2Topo +// P K Pi KPi PPi PK KPi PPi PK ↓ LdL ↓ +constexpr double CutsKf[NBinsPt][NCutKfVars] = {{3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}, /* 0 < pT < 1 */ + {3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}, /* 1 < pT < 2 */ + {3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}, /* 2 < pT < 3 */ + {3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}, /* 3 < pT < 4 */ + {3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}, /* 4 < pT < 5 */ + {3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}, /* 5 < pT < 6 */ + {3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}, /* 6 < pT < 8 */ + {3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}, /* 8 < pT < 12 */ + {3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}, /* 12 < pT < 24 */ + {3., 3., 3., 3., 3., 3., 0.01, 0.01, 0.01, 3., 5., 5.}}; /* 24 < pT < 36 */ + // row labels static const std::vector labelsPt = { "pT bin 0", @@ -506,15 +522,16 @@ static const std::vector labelsPt = { // column labels static const std::vector labelsCutVar = {"m", "pT p", "pT K", "pT Pi", "Chi2PCA", "decay length", "cos pointing angle", "decLengthXY", "normDecLXY", "impParXY", "mass (Kpi)"}; +static const std::vector labelsCutKfVar = {"kfChi2PrimPr", "kfChi2PrimKa", "kfChi2PrimPi", "kfChi2GeoKaPi", "kfChi2GeoPrPi", "kfChi2GeoPrKa", "kfDcaKaPi", "kfDcaPrPi", "kfDcaPrKa", "kfChi2Geo", "kfLdL", "kfChi2Topo"}; } // namespace hf_cuts_lc_to_p_k_pi namespace hf_cuts_lc_to_k0s_p { -static constexpr int nBinsPt = 8; -static constexpr int nCutVars = 8; +static constexpr int NBinsPt = 8; +static constexpr int NCutVars = 9; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 1., 2., 3., @@ -524,18 +541,18 @@ constexpr double binsPt[nBinsPt + 1] = { 8., 12., 24.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -// mK0s(GeV) mLambdas(GeV) mGammas(GeV) ptp ptK0sdau ptK0s d0p d0K0 -constexpr double cuts[nBinsPt][nCutVars] = {{0.008, 0.005, 0.1, 0.5, 0.3, 0.6, 0.05, 999999.}, // 1 < pt < 2 - {0.008, 0.005, 0.1, 0.5, 0.4, 1.3, 0.05, 999999.}, // 2 < pt < 3 - {0.009, 0.005, 0.1, 0.6, 0.4, 1.3, 0.05, 999999.}, // 3 < pt < 4 - {0.011, 0.005, 0.1, 0.6, 0.4, 1.4, 0.05, 999999.}, // 4 < pt < 5 - {0.013, 0.005, 0.1, 0.6, 0.4, 1.4, 0.06, 999999.}, // 5 < pt < 6 - {0.013, 0.005, 0.1, 0.9, 0.4, 1.6, 0.09, 999999.}, // 6 < pt < 8 - {0.016, 0.005, 0.1, 0.9, 0.4, 1.7, 0.10, 999999.}, // 8 < pt < 12 - {0.019, 0.005, 0.1, 1.0, 0.4, 1.9, 0.20, 999999.}}; // 12 < pt < 24 +// mLc(GeV) mK0s(GeV) mLambdas(GeV) mGammas(GeV) ptp ptK0sdau ptK0s d0p d0K0 +constexpr double Cuts[NBinsPt][NCutVars] = {{0.4, 0.008, 0.005, 0.1, 0.5, 0.3, 0.6, 0.05, 999999.}, // 1 < pt < 2 + {0.4, 0.008, 0.005, 0.1, 0.5, 0.4, 1.3, 0.05, 999999.}, // 2 < pt < 3 + {0.4, 0.009, 0.005, 0.1, 0.6, 0.4, 1.3, 0.05, 999999.}, // 3 < pt < 4 + {0.4, 0.011, 0.005, 0.1, 0.6, 0.4, 1.4, 0.05, 999999.}, // 4 < pt < 5 + {0.4, 0.013, 0.005, 0.1, 0.6, 0.4, 1.4, 0.06, 999999.}, // 5 < pt < 6 + {0.4, 0.013, 0.005, 0.1, 0.9, 0.4, 1.6, 0.09, 999999.}, // 6 < pt < 8 + {0.4, 0.016, 0.005, 0.1, 0.9, 0.4, 1.7, 0.10, 999999.}, // 8 < pt < 12 + {0.4, 0.019, 0.005, 0.1, 1.0, 0.4, 1.9, 0.20, 999999.}}; // 12 < pt < 24 // row labels static const std::vector labelsPt = { @@ -549,16 +566,16 @@ static const std::vector labelsPt = { "pT bin 7"}; // column labels -static const std::vector labelsCutVar = {"mK0s", "mLambda", "mGamma", "ptBach", "ptV0Dau", "ptV0", "d0Bach", "d0V0"}; +static const std::vector labelsCutVar = {"mLc", "mK0s", "mLambda", "mGamma", "ptBach", "ptV0Dau", "ptV0", "d0Bach", "d0V0"}; } // namespace hf_cuts_lc_to_k0s_p namespace hf_cuts_dplus_to_pi_k_pi { -static const int nBinsPt = 12; -static const int nCutVars = 8; +static constexpr int NBinsPt = 12; +static constexpr int NCutVars = 8; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 1., 2., 3., @@ -572,11 +589,11 @@ constexpr double binsPt[nBinsPt + 1] = { 16., 24., 36.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts // selections from pp at 5 TeV 2017 analysis https://alice-notes.web.cern.ch/node/808 -constexpr double cuts[nBinsPt][nCutVars] = {{0.2, 0.3, 0.3, 0.07, 6., 0.96, 0.985, 2.5}, /* 1 < pT < 2 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.2, 0.3, 0.3, 0.07, 6., 0.96, 0.985, 2.5}, /* 1 < pT < 2 */ {0.2, 0.3, 0.3, 0.07, 5., 0.96, 0.985, 2.5}, /* 2 < pT < 3 */ {0.2, 0.3, 0.3, 0.10, 5., 0.96, 0.980, 2.5}, /* 3 < pT < 4 */ {0.2, 0.3, 0.3, 0.10, 5., 0.96, 0.000, 2.5}, /* 4 < pT < 5 */ @@ -610,10 +627,10 @@ static const std::vector labelsCutVar = {"deltaM", "pT Pi", "pT K", namespace hf_cuts_ds_to_k_k_pi { -static const int nBinsPt = 8; -static const int nCutVars = 11; +static constexpr int NBinsPt = 8; +static constexpr int NCutVars = 11; // momentary cuts -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 2., 3., 4., @@ -623,11 +640,11 @@ constexpr double binsPt[nBinsPt + 1] = { 12., 16., 24.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts // selections from pp at 5 TeV 2017 analysis https://alice-notes.web.cern.ch/node/808 -constexpr double cuts[nBinsPt][nCutVars] = {{0.2, 0.3, 0.3, 0.02, 4., 0.92, 0.92, 0.014, 0.010, 0.10, 5}, /* 2 < pT < 3 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.2, 0.3, 0.3, 0.02, 4., 0.92, 0.92, 0.014, 0.010, 0.10, 5}, /* 2 < pT < 3 */ {0.2, 0.3, 0.3, 0.02, 4., 0.92, 0.92, 0.014, 0.010, 0.10, 5}, /* 3 < pT < 4 */ {0.2, 0.3, 0.3, 0.03, 4., 0.90, 0.90, 0.012, 0.010, 0.05, 5}, /* 4 < pT < 5 */ {0.2, 0.3, 0.3, 0.03, 4., 0.90, 0.90, 0.012, 0.010, 0.05, 5}, /* 5 < pT < 6 */ @@ -651,13 +668,138 @@ static const std::vector labelsPt = { static const std::vector labelsCutVar = {"deltaM", "pT Pi", "pT K", "decay length", "normalized decay length XY", "cos pointing angle", "cos pointing angle XY", "impact parameter XY", "deltaM Phi", "cos^3 theta_PiK", "chi2PCA"}; } // namespace hf_cuts_ds_to_k_k_pi +namespace hf_cuts_omegac_to_omega_pi +{ +static constexpr int NBinsPt = 4; +static constexpr int NCutVars = 1; +// default values for the pT bin edges (can be used to configure histogram axis) +// offset by 1 from the bin numbers in cuts array +constexpr double BinsPt[NBinsPt + 1] = { + + 1.0, + 2.0, + 4.0, + 6.0, + 12.0}; + +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; + +// default values for the cuts +// pi_pT +constexpr double Cuts[NBinsPt][NCutVars] = {{0.2}, /* 1 < pt < 2 */ + {0.2}, /* 2 < pt < 4 */ + {0.6}, /* 4 < pt < 6 */ + {0.8}}; /* 6 < pt < 12 */ + +// row labels +static const std::vector labelsPt = { + "pT bin 0", + "pT bin 1", + "pT bin 2", + "pT bin 3"}; + +// column labels +static const std::vector labelsCutVar = {"pT pi from Omegac"}; +} // namespace hf_cuts_omegac_to_omega_pi + +namespace hf_cuts_omegacxic_to_omega_ka +{ +static constexpr int NBinsPt = 4; +static constexpr int NCutVars = 1; +// default values for the pT bin edges (can be used to configure histogram axis) +// offset by 1 from the bin numbers in cuts array +constexpr double BinsPt[NBinsPt + 1] = { + + 1.0, + 2.0, + 4.0, + 6.0, + 12.0}; + +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; + +// default values for the cuts +// pi_pT +constexpr double Cuts[NBinsPt][NCutVars] = {{0.2}, /* 1 < pt < 2 */ + {0.2}, /* 2 < pt < 4 */ + {0.6}, /* 4 < pt < 6 */ + {0.8}}; /* 6 < pt < 12 */ + +// row labels +static const std::vector labelsPt = { + "pT bin 0", + "pT bin 1", + "pT bin 2", + "pT bin 3"}; + +// column labels +static const std::vector labelsCutVar = {"pT Ka from Omegac"}; +} // namespace hf_cuts_omegacxic_to_omega_ka + +namespace hf_cuts_xic_to_xi_pi +{ +static constexpr int NBinsPt = 11; +static constexpr int NCutVars = 28; +// default values for the pT bin edges (can be used to configure histogram axis) +// offset by 1 from the bin numbers in cuts array +constexpr double BinsPt[NBinsPt + 1] = { + 0.0, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 8.0, + 10.0, + 12.0, + 16.0, + 24.0}; + +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; + +// default values for the cuts +constexpr double Cuts[NBinsPt][NCutVars] = {{0.2, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 0 < pt < 1 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 1 < pt < 2 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 2 < pt < 3 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 3 < pt < 4 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 4 < pt < 5 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 5 < pt < 6 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 6 < pt < 8 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 8 < pt < 10 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 10 < pt < 12 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}, /* 12 < pt < 16 */ + {0.5, 0.99, 0.97, 0.99, 0.99, 0.1, 0.2, 1.0, 0.04, 0.06, 0.06, 0.05, 0.3, 70, 60, 100, 120, 250, 250, 0.4, 100, 300, 0., 0., 1.5, 0., 0., 0.4}}; /* 16 < pt < 24 */ + +// row labels +static const std::vector labelsPt = { + "pT bin 0", + "pT bin 1", + "pT bin 2", + "pT bin 3", + "pT bin 4", + "pT bin 5", + "pT bin 6", + "pT bin 7", + "pT bin 8", + "pT bin 9", + "pT bin 10"}; + +// column labels +static const std::vector labelsCutVar = {"ptPiFromCharmBaryon", "cosPACasc", "cosPAV0", "cosPaCascToXic", "cosPaV0ToCasc", + "dcaCharmBaryonDau", "dcaCascDau", "dcaV0Dau", "dcaXYToPvCascDau", "dcaXYToPvV0Dau0", "dcaXYToPvV0Dau1", "kfDcaXYPiFromXic", "kfDcaXYCascToPv", + "chi2GeoXic", "chi2GeoCasc", "chi2GeoV0", + "chi2TopoXicToPv", "chi2TopoPiFromXicToPv", "chi2TopoCascToPv", "chi2TopoV0ToPv", "chi2TopoV0ToCasc", "chi2TopoCascToXic", + "cascldl", "v0ldl", "decayLenXYXic", "decayLenXYCasc", "decayLenXYLambda", "cTauXic"}; +} // namespace hf_cuts_xic_to_xi_pi + namespace hf_cuts_xic_to_p_k_pi { -static const int nBinsPt = 10; -static const int nCutVars = 11; +static constexpr int NBinsPt = 10; +static constexpr int NCutVars = 11; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0., 1., 2., @@ -669,10 +811,10 @@ constexpr double binsPt[nBinsPt + 1] = { 12., 24., 36.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts m ptP ptK ptPi chi2PCA dL cosp, dLXY, NdL, ct, ImpParXY -constexpr double cuts[nBinsPt][nCutVars] = {{0.400, 0.4, 0.4, 0.4, 1e-5, 0.005, 0.8, 0.005, 4., 2., 0.}, /* 0 < pT < 1 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.400, 0.4, 0.4, 0.4, 1e-5, 0.005, 0.8, 0.005, 4., 2., 0.}, /* 0 < pT < 1 */ {0.400, 0.4, 0.4, 0.4, 1e-5, 0.005, 0.8, 0.005, 4., 2., 0.}, /* 1 < pT < 2 */ {0.400, 0.4, 0.4, 0.4, 1e-5, 0.005, 0.8, 0.005, 4., 2., 0.}, /* 2 < pT < 3 */ {0.400, 0.4, 0.4, 0.4, 1e-5, 0.005, 0.8, 0.005, 4., 2., 0.}, /* 3 < pT < 4 */ @@ -702,11 +844,11 @@ static const std::vector labelsCutVar = {"m", "pT p", "pT K", "pT P namespace hf_cuts_xic_to_xi_pi_pi { -static const int nBinsPt = 10; -static const int nCutVars = 12; +static constexpr int NBinsPt = 13; +static constexpr int NCutVars = 13; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0., 1., 2., @@ -714,23 +856,29 @@ constexpr double binsPt[nBinsPt + 1] = { 4., 5., 6., + 7., 8., + 9., + 10., + 11., 12., - 24., - 36.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; - -// default values for the cuts m ptXi ptPi0 ptPi1 chi2PCA dL dLXY cosp cospXY impParXY Xi Pi0 Pi1 -constexpr double cuts[nBinsPt][nCutVars] = {{0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}, /* 0 < pT < 1 */ - {0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}, /* 1 < pT < 2 */ - {0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}, /* 2 < pT < 3 */ - {0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}, /* 3 < pT < 4 */ - {0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}, /* 4 < pT < 5 */ - {0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}, /* 5 < pT < 6 */ - {0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}, /* 6 < pT < 8 */ - {0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}, /* 8 < pT < 10 */ - {0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}, /* 12 < pT < 24 */ - {0.4, 0.4, 0.4, 0.4, 1e-5, 0.5, 0.5, 0.9, 0.9, 0.1, 0.1, 0.1}}; /* 24 < pT < 36 */ + 20.}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; + +// default values for the cuts m Y Eta EtaPi EtaXi pT Pi0 Pi1 Sum chi2SV dL dLXY invMass Xi-Pi pairs +constexpr double Cuts[NBinsPt][NCutVars] = {{0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 0 < pT < 1 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 1 < pT < 2 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 2 < pT < 3 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 3 < pT < 4 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 4 < pT < 5 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 5 < pT < 6 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 6 < pT < 7 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 7 < pT < 8 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 8 < pT < 9 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 9 < pT < 10 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 10 < pT < 11 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}, /* 11 < pT < 12 */ + {0.4, 0.8, 0.8, 0.8, 1.0, 0.1, 0.1, 0.2, 100, 0.0, 0.0, 2.4, 2.4}}; /* 12 < pT < 20 */ // row labels static const std::vector labelsPt = { @@ -743,19 +891,22 @@ static const std::vector labelsPt = { "pT bin 6", "pT bin 7", "pT bin 8", - "pT bin 9"}; + "pT bin 9", + "pT bin 10", + "pT bin 11", + "pT bin 12"}; // column labels -static const std::vector labelsCutVar = {"m", "pT Xi", "pT Pi0", "pT Pi1", "chi2PCA", "max decay length", "max decay length XY", "cos pointing angle", "cos pointing angle XY", "max impParXY Xi", "max impParXY Pi0", "max impParXY Pi1"}; +static const std::vector labelsCutVar = {"m", "y", "eta", "eta Pi from XicPlus", "eta Xi Daughters", "pT Pi0", "pT Pi1", "pT Pi0 + Pi1", "chi2SV", "min decay length", "min decay length XY", "max inv mass Xi-Pi0", "max inv mass Xi-Pi1"}; } // namespace hf_cuts_xic_to_xi_pi_pi namespace hf_cuts_xicc_to_p_k_pi_pi { -static const int nBinsPt = 10; -static const int nCutVars = 14; +static constexpr int NBinsPt = 10; +static constexpr int NCutVars = 14; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0., 1., 2., @@ -767,10 +918,10 @@ constexpr double binsPt[nBinsPt + 1] = { 12., 24., 36.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{0.400, 0.5, 0.2, 1.e-3, 10.0, 1.e-3, 10.0, 9999., 1.e-3, 0.0, 50.0, 50.0, 0.8, 0.8}, /* 0 < pT < 1 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.400, 0.5, 0.2, 1.e-3, 10.0, 1.e-3, 10.0, 9999., 1.e-3, 0.0, 50.0, 50.0, 0.8, 0.8}, /* 0 < pT < 1 */ {0.400, 0.5, 0.2, 1.e-3, 10.0, 1.e-3, 10.0, 9999., 1.e-3, 0.0, 50.0, 50.0, 0.8, 0.8}, /* 1 < pT < 2 */ {0.400, 0.5, 0.2, 1.e-3, 10.0, 1.e-3, 10.0, 9999., 1.e-3, 0.0, 50.0, 50.0, 0.8, 0.8}, /* 2 < pT < 3 */ {0.400, 0.5, 0.2, 1.e-3, 10.0, 1.e-3, 10.0, 9999., 1.e-3, 0.0, 50.0, 50.0, 0.8, 0.8}, /* 3 < pT < 4 */ @@ -800,11 +951,11 @@ static const std::vector labelsCutVar = {"m", "pT Xic", "pT Pi", "m namespace hf_cuts_jpsi_to_e_e { -static constexpr int nBinsPt = 9; -static constexpr int nCutVars = 5; +static constexpr int NBinsPt = 9; +static constexpr int NCutVars = 5; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0, 0.5, 1.0, @@ -816,10 +967,10 @@ constexpr double binsPt[nBinsPt + 1] = { 10.0, 15.0, }; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{0.5, 0.2, 0.4, 1, 1.}, /* 0 < pT < 0.5 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.5, 0.2, 0.4, 1, 1.}, /* 0 < pT < 0.5 */ {0.5, 0.2, 0.4, 1, 1.}, /* 0.5 < pT < 1 */ {0.5, 0.2, 0.4, 1, 1.}, /* 1 < pT < 2 */ {0.5, 0.2, 0.4, 1, 1.}, /* 2 < pT < 3 */ @@ -845,13 +996,60 @@ static const std::vector labelsPt = { static const std::vector labelsCutVar = {"m", "DCA_xy", "DCA_z", "pT El", "chi2PCA"}; } // namespace hf_cuts_jpsi_to_e_e +namespace hf_cuts_jpsi_to_mu_mu +{ +static constexpr int NBinsPt = 9; +static constexpr int NCutVars = 8; +// default values for the pT bin edges (can be used to configure histogram axis) +// offset by 1 from the bin numbers in cuts array +constexpr double BinsPt[NBinsPt + 1] = { + 0, + 0.5, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 10.0, + 16.0, +}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; + +// default values for the cuts +constexpr double Cuts[NBinsPt][NCutVars] = {{0.6, 1.0, 0.2, 0.2, 0.9, 0.9, 0., 0.}, /* 0 < pT < 0.5 */ + {0.6, 1.0, 0.2, 0.2, 0.9, 0.9, 0., 0.}, /* 0.5 < pT < 1 */ + {0.6, 1.0, 0.2, 0.2, 0.9, 0.9, 0., 0.}, /* 1 < pT < 2 */ + {0.6, 1.0, 0.2, 0.2, 0.9, 0.9, 0., 0.}, /* 2 < pT < 3 */ + {0.6, 1.0, 0.2, 0.2, 0.9, 0.9, 0., 0.}, /* 3 < pT < 4 */ + {0.6, 1.0, 0.2, 0.2, 0.9, 0.9, 0., 0.}, /* 4 < pT < 5 */ + {0.8, 1.0, 0.3, 0.3, 0.9, 0.9, 0., 0.}, /* 5 < pT < 6 */ + {0.8, 1.0, 0.3, 0.3, 0.9, 0.9, 1., 0.}, /* 6 < pT < 10 */ + {0.8, 1.0, 0.3, 0.3, 0.9, 0.9, 1., 0.}}; /* 10 < pT < 16 */ + +// row labels +static const std::vector labelsPt = { + "pT bin 0", + "pT bin 1", + "pT bin 2", + "pT bin 3", + "pT bin 4", + "pT bin 5", + "pT bin 6", + "pT bin 7", + "pT bin 8"}; + +// column labels +static const std::vector labelsCutVar = {"m", "pT mu", "decay length", "decay length xy", "cpa", "cpa xy", "d0xd0", "pseudoprop. decay length"}; +} // namespace hf_cuts_jpsi_to_mu_mu + namespace hf_cuts_b0_to_d_pi { -static constexpr int nBinsPt = 12; -static constexpr int nCutVars = 12; +static constexpr int NBinsPt = 12; +static constexpr int NCutVars = 12; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0, 0.5, 1.0, @@ -866,11 +1064,11 @@ constexpr double binsPt[nBinsPt + 1] = { 20.0, 24.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts // DeltaM CPA chi2PCA d0D d0Pi pTD pTPi B0DecayLength B0DecayLengthXY IPProd DeltaMD CthetaStr -constexpr double cuts[nBinsPt][nCutVars] = {{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 0 < pt < 0.5 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 0 < pt < 0.5 */ {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 0.5 < pt < 1 */ {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 1 < pt < 2 */ {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 2 < pt < 3 */ @@ -903,11 +1101,11 @@ static const std::vector labelsCutVar = {"m", "CPA", "Chi2PCA", "d0 namespace hf_cuts_bs_to_ds_pi { -static constexpr int nBinsPt = 10; -static constexpr int nCutVars = 10; +static constexpr int NBinsPt = 10; +static constexpr int NCutVars = 10; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0, 1.0, 2.0, @@ -920,11 +1118,11 @@ constexpr double binsPt[nBinsPt + 1] = { 16.0, 24.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts // DeltaM CPA chi2PCA d0Ds d0Pi pTDs pTPi BsDecayLength BsDecayLengthXY IPProd -constexpr double cuts[nBinsPt][nCutVars] = {{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 0 < pt < 1 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 0 < pt < 1 */ {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 1 < pt < 2 */ {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 2 < pt < 3 */ {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 3 < pt < 4 */ @@ -952,13 +1150,69 @@ static const std::vector labelsPt = { static const std::vector labelsCutVar = {"m", "CPA", "Chi2PCA", "d0 Ds", "d0 Pi", "pT Ds", "pT Pi", "Bs decLen", "Bs decLenXY", "Imp. Par. Product"}; } // namespace hf_cuts_bs_to_ds_pi +namespace hf_cuts_bs_to_jpsi_phi +{ +static constexpr int NBinsPt = 12; +static constexpr int NCutVars = 13; +// default values for the pT bin edges (can be used to configure histogram axis) +// offset by 1 from the bin numbers in cuts array +constexpr double BinsPt[NBinsPt + 1] = { + 0, + 0.5, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 7.0, + 10.0, + 13.0, + 16.0, + 20.0, + 24.0}; + +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; + +// default values for the cuts +// DeltaM CPA d0Jpsi d0K pTJpsi pTK BDecayLength BDecayLengthXY BIPProd DeltaMJpsi JpsiIPProd +constexpr double Cuts[NBinsPt][NCutVars] = {{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 0 < pt < 0.5 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 0.5 < pt < 1 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 1 < pt < 2 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 2 < pt < 3 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 3 < pt < 4 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 4 < pt < 5 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 5 < pt < 7 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 7 < pt < 10 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 10 < pt < 13 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 13 < pt < 16 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}, /* 16 < pt < 20 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.02, 0.}}; /* 20 < pt < 24 */ +// row labels +static const std::vector labelsPt = { + "pT bin 0", + "pT bin 1", + "pT bin 2", + "pT bin 3", + "pT bin 4", + "pT bin 5", + "pT bin 6", + "pT bin 7", + "pT bin 8", + "pT bin 9", + "pT bin 10", + "pT bin 11"}; + +// column labels +static const std::vector labelsCutVar = {"m", "CPA", "CPAXY", "d0 J/Psi", "d0 phi", "pT J/Psi", "pT K", "B decLen", "B decLenXY", "B Imp. Par. Product", "DeltaM J/Psi", "DeltaM phi", "B pseudoprop. decLen"}; +} // namespace hf_cuts_bs_to_jpsi_phi + namespace hf_cuts_bplus_to_d0_pi { -static constexpr int nBinsPt = 12; -static constexpr int nCutVars = 11; +static constexpr int NBinsPt = 12; +static constexpr int NCutVars = 11; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0, 0.5, 1.0, @@ -973,11 +1227,11 @@ constexpr double binsPt[nBinsPt + 1] = { 20.0, 24.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts // DeltaM CPA d0D0 d0Pi pTD0 pTPi BDecayLength BDecayLengthXY IPProd DeltaMD0 CthetaStr -constexpr double cuts[nBinsPt][nCutVars] = {{1., 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 0 < pt < 0.5 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{1., 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 0 < pt < 0.5 */ {1., 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 0.5 < pt < 1 */ {1., 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 1 < pt < 2 */ {1., 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 2 < pt < 3 */ @@ -1008,13 +1262,69 @@ static const std::vector labelsPt = { static const std::vector labelsCutVar = {"m", "CPA", "d0 D0", "d0 Pi", "pT D0", "pT Pi", "B decLen", "B decLenXY", "Imp. Par. Product", "DeltaMD0", "Cos ThetaStar"}; } // namespace hf_cuts_bplus_to_d0_pi +namespace hf_cuts_bplus_to_jpsi_k +{ +static constexpr int NBinsPt = 12; +static constexpr int NCutVars = 12; +// default values for the pT bin edges (can be used to configure histogram axis) +// offset by 1 from the bin numbers in cuts array +constexpr double BinsPt[NBinsPt + 1] = { + 0, + 0.5, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 7.0, + 10.0, + 13.0, + 16.0, + 20.0, + 24.0}; + +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; + +// default values for the cuts +// DeltaM CPA d0Jpsi d0K pTJpsi pTK BDecayLength BDecayLengthXY BIPProd DeltaMJpsi JpsiIPProd +constexpr double Cuts[NBinsPt][NCutVars] = {{1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 0 < pt < 0.5 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 0.5 < pt < 1 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 1 < pt < 2 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 2 < pt < 3 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 3 < pt < 4 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 4 < pt < 5 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 5 < pt < 7 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 7 < pt < 10 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 10 < pt < 13 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 13 < pt < 16 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}, /* 16 < pt < 20 */ + {1., 0.8, 0.8, 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.}}; /* 20 < pt < 24 */ +// row labels +static const std::vector labelsPt = { + "pT bin 0", + "pT bin 1", + "pT bin 2", + "pT bin 3", + "pT bin 4", + "pT bin 5", + "pT bin 6", + "pT bin 7", + "pT bin 8", + "pT bin 9", + "pT bin 10", + "pT bin 11"}; + +// column labels +static const std::vector labelsCutVar = {"m", "CPA", "CPAXY", "d0 J/Psi", "d0 K", "pT J/Psi", "pT K", "B decLen", "B decLenXY", "B Imp. Par. Product", "DeltaM J/Psi", "B pseudoprop. decLen"}; +} // namespace hf_cuts_bplus_to_jpsi_k + namespace hf_cuts_lb_to_lc_pi { -static constexpr int nBinsPt = 12; -static constexpr int nCutVars = 12; +static constexpr int NBinsPt = 12; +static constexpr int NCutVars = 12; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0, 0.5, 1.0, @@ -1029,11 +1339,11 @@ constexpr double binsPt[nBinsPt + 1] = { 20.0, 24.0}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts // DeltaM CPA chi2PCA d0Lc d0Pi pTLc pTPi LbDecayLength LbDecayLengthXY IPProd DeltaMLc CthetaStr -constexpr double cuts[nBinsPt][nCutVars] = {{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 0 < pt < 0.5 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 0 < pt < 0.5 */ {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 0.5 < pt < 1 */ {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 1 < pt < 2 */ {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0., 0.1, 0.8}, /* 2 < pt < 3 */ @@ -1066,11 +1376,11 @@ static const std::vector labelsCutVar = {"m", "CPA", "Chi2PCA", "d0 namespace hf_cuts_x_to_jpsi_pi_pi { -static constexpr int nBinsPt = 9; -static constexpr int nCutVars = 7; +static constexpr int NBinsPt = 9; +static constexpr int NCutVars = 7; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0, 0.5, 1.0, @@ -1082,11 +1392,11 @@ constexpr double binsPt[nBinsPt + 1] = { 10.0, 15.0, }; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts // m CPA d0Jpsi d0Pi pTJpsi pTPi chi2PCA -constexpr double cuts[nBinsPt][nCutVars] = {{0.5, 0.80, 0.001, 0.001, 3.0, 0.15, 1.}, /* 0 labelsCutVar = {"m", "CPA", "d0 Jpsi", "d0 namespace hf_cuts_chic_to_jpsi_gamma { // dummy selections for chic --> TO BE IMPLEMENTED -static constexpr int nBinsPt = 9; -static constexpr int nCutVars = 7; +static constexpr int NBinsPt = 9; +static constexpr int NCutVars = 7; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0, 0.5, 1.0, @@ -1129,11 +1439,11 @@ constexpr double binsPt[nBinsPt + 1] = { 10.0, 15.0, }; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts // m CPA d0Jpsi d0gamma pTJpsi pTgamma chi2PCA -constexpr double cuts[nBinsPt][nCutVars] = {{3.0, -1., 0.001, 0.001, 0.5, 0.15, 1.}, /* 0 labelsCutVar = {"m", "CPA", "d0 Jpsi", "d0 namespace hf_cuts_sigmac_to_p_k_pi { -static constexpr int nBinsPt = 10; -static constexpr int nCutVars = 2; +static constexpr int NBinsPt = 10; +static constexpr int NCutVars = 2; // default values for the pT bin edges (can be used to configure histogram axis) // offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { +constexpr double BinsPt[NBinsPt + 1] = { 0., 1., 2., @@ -1175,10 +1485,10 @@ constexpr double binsPt[nBinsPt + 1] = { 12., 24., 36.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{0.03, 0.03}, /* 0 < pT < 1 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.03, 0.03}, /* 0 < pT < 1 */ {0.03, 0.03}, /* 1 < pT < 2 */ {0.03, 0.03}, /* 2 < pT < 3 */ {0.03, 0.03}, /* 3 < pT < 4 */ diff --git a/PWGHF/D2H/Core/SelectorCutsRedDataFormat.h b/PWGHF/D2H/Core/SelectorCutsRedDataFormat.h index daa642f1601..4373ded905c 100644 --- a/PWGHF/D2H/Core/SelectorCutsRedDataFormat.h +++ b/PWGHF/D2H/Core/SelectorCutsRedDataFormat.h @@ -26,10 +26,10 @@ namespace o2::analysis { namespace hf_cuts_d_daughter { -static constexpr int nBinsPt = 7; -static constexpr int nCutVars = 6; -constexpr double binsPt[nBinsPt + 1] = { - 1., +static constexpr int NBinsPt = 7; +static constexpr int NCutVars = 6; +constexpr double BinsPt[NBinsPt + 1] = { + 0., 2., 4., 6., @@ -37,9 +37,9 @@ constexpr double binsPt[nBinsPt + 1] = { 12., 24., 1000.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 1 < pt < 2 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 1 < pt < 2 */ {1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 2 < pt < 4 */ {1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 4 < pt < 6 */ {1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 6 < pt < 8 */ @@ -62,9 +62,9 @@ static const std::vector labelsCutVar = {"invMassSignalLow", "invMa // namespace with v0 selections for reduced charmed-resonances analysis namespace hf_cuts_v0_daughter { -static constexpr int nBinsPt = 7; -static constexpr int nCutVars = 5; -constexpr double binsPt[nBinsPt + 1] = { +static constexpr int NBinsPt = 7; +static constexpr int NCutVars = 5; +constexpr double BinsPt[NBinsPt + 1] = { 0., 1., 2., @@ -73,9 +73,9 @@ constexpr double binsPt[nBinsPt + 1] = { 12., 24., 1000.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; +auto vecBinsPt = std::vector{BinsPt, BinsPt + NBinsPt + 1}; // default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{0.48, 0.52, 0.99, 1., 0.9}, /* 1 < pt < 2 */ +constexpr double Cuts[NBinsPt][NCutVars] = {{0.48, 0.52, 0.99, 1., 0.9}, /* 1 < pt < 2 */ {0.48, 0.52, 0.99, 1., 0.9}, /* 2 < pt < 4 */ {0.48, 0.52, 0.99, 1., 0.9}, /* 4 < pt < 6 */ {0.48, 0.52, 0.99, 1., 0.9}, /* 6 < pt < 8 */ @@ -87,5 +87,15 @@ static const std::vector labelsPt{}; // column labels static const std::vector labelsCutVar = {"invMassLow", "invMassHigh", "cpaMin", "dcaMax", "radiusMin"}; } // namespace hf_cuts_v0_daughter + +namespace hf_cuts_track_daughter +{ +static constexpr int NCutVars = 7; +// default values for the cuts +constexpr double Cuts[1][NCutVars] = {{0.1, 3, 40, 4, 3, -1, -1}}; // nSigmaTpc, nSigmaTof, nSigmaCombined +// row labels +static const std::vector labelsCutVar = {"ptMin", "itsNClsMin", "tpcNCrossedRowsMin", "tpcChi2Max", "nSigmaTpc", "nSigmaTof", "nSigmaComb"}; +} // namespace hf_cuts_track_daughter + } // namespace o2::analysis #endif // PWGHF_D2H_CORE_SELECTORCUTSREDDATAFORMAT_H_ diff --git a/PWGHF/D2H/DataModel/ReducedDataModel.h b/PWGHF/D2H/DataModel/ReducedDataModel.h index d8c06e0d26f..06b219be522 100644 --- a/PWGHF/D2H/DataModel/ReducedDataModel.h +++ b/PWGHF/D2H/DataModel/ReducedDataModel.h @@ -11,39 +11,49 @@ /// \file ReducedDataModel.h /// \brief Header file with definition of methods and tables -// used to fold (unfold) track and primary vertex information by writing (reading) AO2Ds -/// \note +/// \note used to fold (unfold) track and primary vertex information by writing (reading) AO2Ds /// /// \author Alexandre Bigot , IPHC Strasbourg /// \author Antonio Palasciano , Università degli Studi di Bari & INFN, Bari /// \author Fabio Catalano , CERN /// \author Fabrizio Grosa , CERN /// \author Luca Aglietta , Università degli Studi di Torino (UniTO) +/// \author Biao Zhang , Heidelberg University +/// \author Fabrizio Chinu , Università degli Studi di Torino (UniTO) #ifndef PWGHF_D2H_DATAMODEL_REDUCEDDATAMODEL_H_ #define PWGHF_D2H_DATAMODEL_REDUCEDDATAMODEL_H_ -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "ReconstructionDataFormats/Track.h" -#include "ReconstructionDataFormats/Vertex.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/DataModel/PIDResponse.h" - #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/Utils/utilsPid.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/Qvectors.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + namespace o2 { namespace aod { namespace hf_reduced_collision { -DECLARE_SOA_COLUMN(Bz, bz, float); //! Magnetic field in z-direction -DECLARE_SOA_COLUMN(HfCollisionRejectionMap, hfCollisionRejectionMap, uint16_t); //! Bitmask with failed selection criteria +DECLARE_SOA_COLUMN(Bz, bz, float); //! Magnetic field in z-direction +DECLARE_SOA_COLUMN(HfCollisionRejectionMap, hfCollisionRejectionMap, uint32_t); //! Bitmask with failed selection criteria // keep track of the number of studied events (for normalization purposes) -DECLARE_SOA_COLUMN(OriginalCollisionCount, originalCollisionCount, int); //! Size of COLLISION table processed +DECLARE_SOA_COLUMN(OriginalCollisionCount, originalCollisionCount, int); //! Size of COLLISION table processed DECLARE_SOA_COLUMN(ZvtxSelectedCollisionCount, zvtxSelectedCollisionCount, int); //! Number of COLLISIONS with |zvtx| < zvtxMax DECLARE_SOA_COLUMN(TriggerSelectedCollisionCount, triggerSelectedCollisionCount, int); //! Number of COLLISIONS with sel8 DECLARE_SOA_COLUMN(ZvtxAndTriggerSelectedCollisionCount, zvtxAndTriggerSelectedCollisionCount, int); //! Number of COLLISIONS with |zvtx| < zvtxMax and sel8 @@ -61,6 +71,32 @@ DECLARE_SOA_TABLE(HfRedCollisions, "AOD", "HFREDCOLLISION", //! Table with colli hf_reduced_collision::Bz, o2::soa::Marker<1>); +DECLARE_SOA_TABLE(HfRedCollCents, "AOD", "HFREDCOLLCENT", //! Table with collision centrality for reduced workflow + cent::CentFT0C, + cent::CentFT0M, + evsel::NumTracksInTimeRange, + evsel::SumAmpFT0CInTimeRange); + +DECLARE_SOA_TABLE(HfRedQvectors, "AOD", "HFREDQVECTOR", //! Table with collision centrality for reduced workflow + qvec::QvecFT0CRe, + qvec::QvecFT0CIm, + qvec::SumAmplFT0C, + qvec::QvecFT0ARe, + qvec::QvecFT0AIm, + qvec::SumAmplFT0A, + qvec::QvecFT0MRe, + qvec::QvecFT0MIm, + qvec::SumAmplFT0M, + qvec::QvecTPCposRe, + qvec::QvecTPCposIm, + qvec::NTrkTPCpos, + qvec::QvecTPCnegRe, + qvec::QvecTPCnegIm, + qvec::NTrkTPCneg, + qvec::QvecTPCallRe, + qvec::QvecTPCallIm, + qvec::NTrkTPCall); + DECLARE_SOA_TABLE(HfRedCollExtras, "AOD", "HFREDCOLLEXTRA", //! Table with collision extras for reduced workflow collision::CovXX, collision::CovXY, @@ -153,6 +189,7 @@ DECLARE_SOA_COLUMN(HasTOFProng2, hasTOFProng2, bool); DECLARE_SOA_COLUMN(ItsNCls, itsNCls, int); //! Number of clusters in ITS DECLARE_SOA_COLUMN(TpcNClsCrossedRows, tpcNClsCrossedRows, int); //! Number of TPC crossed rows DECLARE_SOA_COLUMN(TpcChi2NCl, tpcChi2NCl, float); //! TPC chi2 +DECLARE_SOA_COLUMN(ItsChi2NCl, itsChi2NCl, float); //! ITS chi2 DECLARE_SOA_COLUMN(ItsNClsProngMin, itsNClsProngMin, int); //! minimum value of number of ITS clusters for the decay daughter tracks DECLARE_SOA_COLUMN(TpcNClsCrossedRowsProngMin, tpcNClsCrossedRowsProngMin, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks DECLARE_SOA_COLUMN(TpcChi2NClProngMax, tpcChi2NClProngMax, float); //! maximum value of TPC chi2 for the decay daughter tracks @@ -178,41 +215,61 @@ DECLARE_SOA_DYNAMIC_COLUMN(EtaProng1, etaProng1, //! [](float pxProng1, float pyProng1, float pzProng1) -> float { return RecoDecay::eta(std::array{pxProng1, pyProng1, pzProng1}); }); DECLARE_SOA_DYNAMIC_COLUMN(EtaProng2, etaProng2, //! [](float pxProng2, float pyProng2, float pzProng2) -> float { return RecoDecay::eta(std::array{pxProng2, pyProng2, pzProng2}); }); +DECLARE_SOA_DYNAMIC_COLUMN(PVector, pVector, //! 3-momentum vector + [](float px, float py, float pz) -> std::array { return {px, py, pz}; }); } // namespace hf_track_vars_reduced +namespace hf_b_to_jpsi_track_vars_reduced +{ +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! transverse momentum + [](float signed1Pt) -> float { return std::abs(signed1Pt) <= o2::constants::math::Almost0 ? o2::constants::math::VeryBig : 1.f / std::abs(signed1Pt); }); +} // namespace hf_b_to_jpsi_track_vars_reduced + namespace hf_track_pid_reduced { -DECLARE_SOA_COLUMN(TPCNSigmaPiProng0, tpcNSigmaPiProng0, float); //! NsigmaTPCPi for prong0 -DECLARE_SOA_COLUMN(TPCNSigmaPiProng1, tpcNSigmaPiProng1, float); //! NsigmaTPCPi for prong1 -DECLARE_SOA_COLUMN(TPCNSigmaPiProng2, tpcNSigmaPiProng2, float); //! NsigmaTPCPi for prong2 -DECLARE_SOA_COLUMN(TPCNSigmaKaProng0, tpcNSigmaKaProng0, float); //! NsigmaTPCKa for prong0 -DECLARE_SOA_COLUMN(TPCNSigmaKaProng1, tpcNSigmaKaProng1, float); //! NsigmaTPCKa for prong1 -DECLARE_SOA_COLUMN(TPCNSigmaKaProng2, tpcNSigmaKaProng2, float); //! NsigmaTPCKa for prong2 -DECLARE_SOA_COLUMN(TOFNSigmaPiProng0, tofNSigmaPiProng0, float); //! NsigmaTOFPi for prong0 -DECLARE_SOA_COLUMN(TOFNSigmaPiProng1, tofNSigmaPiProng1, float); //! NsigmaTOFPi for prong1 -DECLARE_SOA_COLUMN(TOFNSigmaPiProng2, tofNSigmaPiProng2, float); //! NsigmaTOFPi for prong2 -DECLARE_SOA_COLUMN(TOFNSigmaKaProng0, tofNSigmaKaProng0, float); //! NsigmaTOFKa for prong0 -DECLARE_SOA_COLUMN(TOFNSigmaKaProng1, tofNSigmaKaProng1, float); //! NsigmaTOFKa for prong1 -DECLARE_SOA_COLUMN(TOFNSigmaKaProng2, tofNSigmaKaProng2, float); //! NsigmaTOFKa for prong2 +DECLARE_SOA_COLUMN(TPCNSigmaPiProng0, tpcNSigmaPiProng0, float); //! NsigmaTPCPi for prong0, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TPCNSigmaPiProng1, tpcNSigmaPiProng1, float); //! NsigmaTPCPi for prong1, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TPCNSigmaPiProng2, tpcNSigmaPiProng2, float); //! NsigmaTPCPi for prong2, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TPCNSigmaKaProng0, tpcNSigmaKaProng0, float); //! NsigmaTPCKa for prong0, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TPCNSigmaKaProng1, tpcNSigmaKaProng1, float); //! NsigmaTPCKa for prong1, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TPCNSigmaKaProng2, tpcNSigmaKaProng2, float); //! NsigmaTPCKa for prong2, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TPCNSigmaPrProng0, tpcNSigmaPrProng0, float); //! NsigmaTPCPr for prong0, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TPCNSigmaPrProng1, tpcNSigmaPrProng1, float); //! NsigmaTPCPr for prong1, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TPCNSigmaPrProng2, tpcNSigmaPrProng2, float); //! NsigmaTPCPr for prong2, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TOFNSigmaPiProng0, tofNSigmaPiProng0, float); //! NsigmaTOFPi for prong0, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TOFNSigmaPiProng1, tofNSigmaPiProng1, float); //! NsigmaTOFPi for prong1, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TOFNSigmaPiProng2, tofNSigmaPiProng2, float); //! NsigmaTOFPi for prong2, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TOFNSigmaKaProng0, tofNSigmaKaProng0, float); //! NsigmaTOFKa for prong0, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TOFNSigmaKaProng1, tofNSigmaKaProng1, float); //! NsigmaTOFKa for prong1, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TOFNSigmaKaProng2, tofNSigmaKaProng2, float); //! NsigmaTOFKa for prong2, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TOFNSigmaPrProng0, tofNSigmaPrProng0, float); //! NsigmaTOFPr for prong0, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TOFNSigmaPrProng1, tofNSigmaPrProng1, float); //! NsigmaTOFPr for prong1, o2-linter: disable=name/o2-column (written to disk) +DECLARE_SOA_COLUMN(TOFNSigmaPrProng2, tofNSigmaPrProng2, float); //! NsigmaTOFPr for prong2, o2-linter: disable=name/o2-column (written to disk) // dynamic columns -DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPi, tpcTofNSigmaPi, //! Combination of NsigmaTPC and NsigmaTOF +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPi, tpcTofNSigmaPi, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKa, tpcTofNSigmaKa, //! Combination of NsigmaTPC and NsigmaTOF +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKa, tpcTofNSigmaKa, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPr, tpcTofNSigmaPr, //! Combination of NsigmaTPC and NsigmaTOF +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPr, tpcTofNSigmaPr, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPiProng0, tpcTofNSigmaPiProng0, //! Combination of NsigmaTPC and NsigmaTOF +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPiProng0, tpcTofNSigmaPiProng0, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPiProng1, tpcTofNSigmaPiProng1, //! Combination of NsigmaTPC and NsigmaTOF +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPiProng1, tpcTofNSigmaPiProng1, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPiProng2, tpcTofNSigmaPiProng2, //! Combination of NsigmaTPC and NsigmaTOF +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPiProng2, tpcTofNSigmaPiProng2, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKaProng0, tpcTofNSigmaKaProng0, //! Combination of NsigmaTPC and NsigmaTOF +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKaProng0, tpcTofNSigmaKaProng0, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) [](float tpcNSigmaKa, float tofNSigmaKa) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa, tofNSigmaKa); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKaProng1, tpcTofNSigmaKaProng1, //! Combination of NsigmaTPC and NsigmaTOF +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKaProng1, tpcTofNSigmaKaProng1, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) [](float tpcNSigmaKa, float tofNSigmaKa) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa, tofNSigmaKa); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKaProng2, tpcTofNSigmaKaProng2, //! Combination of NsigmaTPC and NsigmaTOF +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKaProng2, tpcTofNSigmaKaProng2, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) [](float tpcNSigmaKa, float tofNSigmaKa) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa, tofNSigmaKa); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPrProng0, tpcTofNSigmaPrProng0, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) + [](float tpcNSigmaPr, float tofNSigmaPr) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPr, tofNSigmaPr); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPrProng1, tpcTofNSigmaPrProng1, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) + [](float tpcNSigmaPr, float tofNSigmaPr) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPr, tofNSigmaPr); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPrProng2, tpcTofNSigmaPrProng2, //! Combination of NsigmaTPC and NsigmaTOF, o2-linter: disable=name/o2-column (written to disk) + [](float tpcNSigmaPr, float tofNSigmaPr) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPr, tofNSigmaPr); }); } // namespace hf_track_pid_reduced // CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description) @@ -228,9 +285,94 @@ DECLARE_SOA_TABLE(HfRedTrackBases, "AOD", "HFREDTRACKBASE", //! Table with track aod::track::Px, aod::track::Py, aod::track::Pz, - aod::track::PVector); + aod::track::PVector, + o2::soa::Marker<1>); DECLARE_SOA_TABLE(HfRedTracksCov, "AOD", "HFREDTRACKCOV", //! Table with track covariance information for reduced workflow + soa::Index<>, + HFTRACKPARCOV_COLUMNS, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(HfRedSoftPiBases, "AOD", "HFREDSOFTPIBASE", //! Table with track information for reduced workflow + soa::Index<>, + hf_track_index_reduced::TrackId, + hf_track_index_reduced::HfRedCollisionId, + HFTRACKPAR_COLUMNS, + hf_track_vars_reduced::ItsNCls, + hf_track_vars_reduced::TpcNClsCrossedRows, + hf_track_vars_reduced::TpcChi2NCl, + aod::track::Px, + aod::track::Py, + aod::track::Pz, + aod::track::PVector, + o2::soa::Marker<2>); + +DECLARE_SOA_TABLE(HfRedSoftPiCov, "AOD", "HFREDSOFTPICOV", //! Table with track covariance information for reduced workflow + soa::Index<>, + HFTRACKPARCOV_COLUMNS, + o2::soa::Marker<2>); + +// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description) +// to call DECLARE_SOA_INDEX_COLUMN_FULL later on +DECLARE_SOA_TABLE(HfRedBach0Bases, "AOD", "HFREDBACH0BASE", //! Table with track information for reduced workflow + soa::Index<>, + hf_track_index_reduced::TrackId, + hf_track_index_reduced::HfRedCollisionId, + HFTRACKPAR_COLUMNS, + hf_b_to_jpsi_track_vars_reduced::Pt, + hf_track_vars_reduced::ItsNCls, + hf_track_vars_reduced::TpcNClsCrossedRows, + hf_track_vars_reduced::TpcChi2NCl, + hf_track_vars_reduced::ItsChi2NCl, + hf_track_vars_reduced::HasTPC, + hf_track_vars_reduced::HasTOF, + pidtpc::TPCNSigmaPi, + pidtof::TOFNSigmaPi, + pidtpc::TPCNSigmaKa, + pidtof::TOFNSigmaKa, + pidtpc::TPCNSigmaPr, + pidtof::TOFNSigmaPr, + hf_track_pid_reduced::TPCTOFNSigmaPi, + hf_track_pid_reduced::TPCTOFNSigmaKa, + hf_track_pid_reduced::TPCTOFNSigmaPr, + aod::track::Px, + aod::track::Py, + aod::track::Pz, + aod::track::PVector); + +DECLARE_SOA_TABLE(HfRedBach0Cov, "AOD", "HFREDBACH0COV", //! Table with track covariance information for reduced workflow + soa::Index<>, + HFTRACKPARCOV_COLUMNS); + +// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description) +// to call DECLARE_SOA_INDEX_COLUMN_FULL later on +DECLARE_SOA_TABLE(HfRedBach1Bases, "AOD", "HFREDBACH1BASE", //! Table with track information for reduced workflow + soa::Index<>, + hf_track_index_reduced::TrackId, + hf_track_index_reduced::HfRedCollisionId, + HFTRACKPAR_COLUMNS, + hf_b_to_jpsi_track_vars_reduced::Pt, + hf_track_vars_reduced::ItsNCls, + hf_track_vars_reduced::TpcNClsCrossedRows, + hf_track_vars_reduced::TpcChi2NCl, + hf_track_vars_reduced::ItsChi2NCl, + hf_track_vars_reduced::HasTPC, + hf_track_vars_reduced::HasTOF, + pidtpc::TPCNSigmaPi, + pidtof::TOFNSigmaPi, + pidtpc::TPCNSigmaKa, + pidtof::TOFNSigmaKa, + pidtpc::TPCNSigmaPr, + pidtof::TOFNSigmaPr, + hf_track_pid_reduced::TPCTOFNSigmaPi, + hf_track_pid_reduced::TPCTOFNSigmaKa, + hf_track_pid_reduced::TPCTOFNSigmaPr, + aod::track::Px, + aod::track::Py, + aod::track::Pz, + aod::track::PVector); + +DECLARE_SOA_TABLE(HfRedBach1Cov, "AOD", "HFREDBACH1COV", //! Table with track covariance information for reduced workflow soa::Index<>, HFTRACKPARCOV_COLUMNS); @@ -245,8 +387,14 @@ DECLARE_SOA_TABLE(HfRedTracksPid, "AOD", "HFREDTRACKPID", //! Table with PID tra DECLARE_SOA_EXTENDED_TABLE_USER(HfRedTracksExt, HfRedTrackBases, "HFREDTRACKEXT", //! Track parameters at collision vertex aod::track::Pt); +DECLARE_SOA_EXTENDED_TABLE_USER(HfRedBach0Ext, HfRedBach0Bases, "HFREDBACH0EXT", //! Track parameters at collision vertex + aod::track::Pt); +DECLARE_SOA_EXTENDED_TABLE_USER(HfRedBach1Ext, HfRedBach1Bases, "HFREDBACH1EXT", //! Track parameters at collision vertex + aod::track::Pt); using HfRedTracks = HfRedTracksExt; +using HfRedBach0Tracks = HfRedBach0Bases; +using HfRedBach1Tracks = HfRedBach1Bases; namespace hf_charm_cand_reduced { @@ -260,6 +408,115 @@ DECLARE_SOA_COLUMN(MlScorePromptMassHypo1, mlScorePromptMassHypo1, float); DECLARE_SOA_COLUMN(MlScoreNonpromptMassHypo1, mlScoreNonpromptMassHypo1, float); //! ML score for non-prompt class (mass hypothesis 1) } // namespace hf_charm_cand_reduced +namespace hf_jpsi_cand_reduced +{ +DECLARE_SOA_COLUMN(ProngPosId, prongPosId, int); //! Original track index +DECLARE_SOA_COLUMN(ProngNegId, prongNegId, int); //! Original track index +DECLARE_SOA_COLUMN(HfRedCollisionId, hfRedCollisionId, int); //! Collision index +DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate in GeV/c2 + +DECLARE_SOA_COLUMN(ItsNClsDauPos, itsNClsDauPos, int); //! Number of clusters in ITS +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsDauPos, tpcNClsCrossedRowsDauPos, int); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(TpcChi2NClDauPos, tpcChi2NClDauPos, float); //! TPC chi2 / Number of clusters +DECLARE_SOA_COLUMN(ItsChi2NClDauPos, itsChi2NClDauPos, float); //! ITS chi2 / Number of clusters +DECLARE_SOA_COLUMN(ItsNClsDauNeg, itsNClsDauNeg, int); //! Number of clusters in ITS +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsDauNeg, tpcNClsCrossedRowsDauNeg, int); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(TpcChi2NClDauNeg, tpcChi2NClDauNeg, float); //! TPC chi2 / Number of clusters +DECLARE_SOA_COLUMN(ItsChi2NClDauNeg, itsChi2NClDauNeg, float); //! ITS chi2 / Number of clusters + +DECLARE_SOA_COLUMN(XDauPos, xDauPos, float); //! x +DECLARE_SOA_COLUMN(XDauNeg, xDauNeg, float); //! x +DECLARE_SOA_COLUMN(YDauPos, yDauPos, float); //! y +DECLARE_SOA_COLUMN(YDauNeg, yDauNeg, float); //! y +DECLARE_SOA_COLUMN(ZDauPos, zDauPos, float); //! z +DECLARE_SOA_COLUMN(ZDauNeg, zDauNeg, float); //! z +DECLARE_SOA_COLUMN(AlphaDauPos, alphaDauPos, float); //! alpha of the J/Psi positive decay daughter +DECLARE_SOA_COLUMN(AlphaDauNeg, alphaDauNeg, float); //! alpha of the J/Psi negative decay daughter +DECLARE_SOA_COLUMN(SnpDauPos, snpDauPos, float); //! snp of the J/Psi positive decay daughter +DECLARE_SOA_COLUMN(SnpDauNeg, snpDauNeg, float); //! snp of the J/Psi negative decay daughter +DECLARE_SOA_COLUMN(TglDauPos, tglDauPos, float); //! tgl of the J/Psi positive decay daughter +DECLARE_SOA_COLUMN(TglDauNeg, tglDauNeg, float); //! tgl of the J/Psi negative decay daughter +DECLARE_SOA_COLUMN(Signed1PtDauPos, signed1PtDauPos, float); //! signed1Pt of the J/Psi positive decay daughter +DECLARE_SOA_COLUMN(Signed1PtDauNeg, signed1PtDauNeg, float); //! signed1Pt of the J/Psi negative decay daughter + +DECLARE_SOA_DYNAMIC_COLUMN(PxDauPos, pxDauPos, //! Momentum in x-direction in GeV/c + [](float signed1Pt, float snp, float alpha) -> float { + auto pt = 1.f / std::abs(signed1Pt); + // FIXME: GCC & clang should optimize to sincosf + float cs = cosf(alpha), sn = sinf(alpha); + auto r = std::sqrt((1.f - snp) * (1.f + snp)); + return pt * (r * cs - snp * sn); + }); +DECLARE_SOA_DYNAMIC_COLUMN(PyDauPos, pyDauPos, //! Momentum in y-direction in GeV/c + [](float signed1Pt, float snp, float alpha) -> float { + auto pt = 1.f / std::abs(signed1Pt); + // FIXME: GCC & clang should optimize to sincosf + float cs = cosf(alpha), sn = sinf(alpha); + auto r = std::sqrt((1.f - snp) * (1.f + snp)); + return pt * (snp * cs + r * sn); + }); +DECLARE_SOA_DYNAMIC_COLUMN(PzDauPos, pzDauPos, //! Momentum in z-direction in GeV/c + [](float signed1Pt, float tgl) -> float { + auto pt = 1.f / std::abs(signed1Pt); + return pt * tgl; + }); +DECLARE_SOA_DYNAMIC_COLUMN(PxDauNeg, pxDauNeg, //! Momentum in x-direction in GeV/c + [](float signed1Pt, float snp, float alpha) -> float { + auto pt = 1.f / std::abs(signed1Pt); + // FIXME: GCC & clang should optimize to sincosf + float cs = cosf(alpha), sn = sinf(alpha); + auto r = std::sqrt((1.f - snp) * (1.f + snp)); + return pt * (r * cs - snp * sn); + }); +DECLARE_SOA_DYNAMIC_COLUMN(PyDauNeg, pyDauNeg, //! Momentum in y-direction in GeV/c + [](float signed1Pt, float snp, float alpha) -> float { + auto pt = 1.f / std::abs(signed1Pt); + // FIXME: GCC & clang should optimize to sincosf + float cs = cosf(alpha), sn = sinf(alpha); + auto r = std::sqrt((1.f - snp) * (1.f + snp)); + return pt * (snp * cs + r * sn); + }); +DECLARE_SOA_DYNAMIC_COLUMN(PzDauNeg, pzDauNeg, //! Momentum in z-direction in GeV/c + [](float signed1Pt, float tgl) -> float { + auto pt = 1.f / std::abs(signed1Pt); + return pt * tgl; + }); + +// Covariance matrix of the J/Psi positive decay daughter +DECLARE_SOA_COLUMN(CYYDauPos, cYYDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CZYDauPos, cZYDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CZZDauPos, cZZDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CSnpYDauPos, cSnpYDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CSnpZDauPos, cSnpZDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CSnpSnpDauPos, cSnpSnpDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CTglYDauPos, cTglYDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CTglZDauPos, cTglZDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CTglSnpDauPos, cTglSnpDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CTglTglDauPos, cTglTglDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1PtYDauPos, c1PtYDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1PtZDauPos, c1PtZDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1PtSnpDauPos, c1PtSnpDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1PtTglDauPos, c1PtTglDauPos, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1Pt21Pt2DauPos, c1Pt21Pt2DauPos, float); //! Covariance matrix + +// Covariance matrix of the J/Psi negative decay daughter +DECLARE_SOA_COLUMN(CYYDauNeg, cYYDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CZYDauNeg, cZYDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CZZDauNeg, cZZDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CSnpYDauNeg, cSnpYDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CSnpZDauNeg, cSnpZDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CSnpSnpDauNeg, cSnpSnpDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CTglYDauNeg, cTglYDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CTglZDauNeg, cTglZDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CTglSnpDauNeg, cTglSnpDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(CTglTglDauNeg, cTglTglDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1PtYDauNeg, c1PtYDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1PtZDauNeg, c1PtZDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1PtSnpDauNeg, c1PtSnpDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1PtTglDauNeg, c1PtTglDauNeg, float); //! Covariance matrix +DECLARE_SOA_COLUMN(C1Pt21Pt2DauNeg, c1Pt21Pt2DauNeg, float); //! Covariance matrix +} // namespace hf_jpsi_cand_reduced + // CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description) // to call DECLARE_SOA_INDEX_COLUMN_FULL later on DECLARE_SOA_TABLE(HfRed2Prongs, "AOD", "HFRED2PRONG", //! Table with 2prong candidate information for reduced workflow @@ -326,7 +583,56 @@ DECLARE_SOA_TABLE_VERSIONED(HfRed3ProngsMl_001, "AOD", "HFRED3PRONGML", 1, //! T using HfRed3ProngsMl = HfRed3ProngsMl_001; -DECLARE_SOA_TABLE(HfRedPidDau0s, "AOD", "HFREDPIDDAU0", //! +// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description) +// to call DECLARE_SOA_INDEX_COLUMN_FULL later on +DECLARE_SOA_TABLE(HfRedJpsis, "AOD", "HFREDJPSI", //! Table with J/Psi candidate information for reduced workflow + o2::soa::Index<>, + hf_jpsi_cand_reduced::ProngPosId, + hf_jpsi_cand_reduced::ProngNegId, + hf_track_index_reduced::HfRedCollisionId, + hf_cand::XSecondaryVertex, hf_cand::YSecondaryVertex, hf_cand::ZSecondaryVertex, + hf_jpsi_cand_reduced::M, + hf_jpsi_cand_reduced::ItsNClsDauPos, + hf_jpsi_cand_reduced::TpcNClsCrossedRowsDauPos, + hf_jpsi_cand_reduced::TpcChi2NClDauPos, + hf_jpsi_cand_reduced::ItsChi2NClDauPos, + hf_jpsi_cand_reduced::ItsNClsDauNeg, + hf_jpsi_cand_reduced::TpcNClsCrossedRowsDauNeg, + hf_jpsi_cand_reduced::TpcChi2NClDauNeg, + hf_jpsi_cand_reduced::ItsChi2NClDauNeg, + hf_jpsi_cand_reduced::XDauPos, hf_jpsi_cand_reduced::XDauNeg, + hf_jpsi_cand_reduced::YDauPos, hf_jpsi_cand_reduced::YDauNeg, + hf_jpsi_cand_reduced::ZDauPos, hf_jpsi_cand_reduced::ZDauNeg, + hf_jpsi_cand_reduced::AlphaDauPos, hf_jpsi_cand_reduced::AlphaDauNeg, + hf_jpsi_cand_reduced::SnpDauPos, hf_jpsi_cand_reduced::SnpDauNeg, + hf_jpsi_cand_reduced::TglDauPos, hf_jpsi_cand_reduced::TglDauNeg, + hf_jpsi_cand_reduced::Signed1PtDauPos, hf_jpsi_cand_reduced::Signed1PtDauNeg, + hf_jpsi_cand_reduced::PxDauPos, + hf_jpsi_cand_reduced::PxDauNeg, + hf_jpsi_cand_reduced::PyDauPos, + hf_jpsi_cand_reduced::PyDauNeg, + hf_jpsi_cand_reduced::PzDauPos, + hf_jpsi_cand_reduced::PzDauNeg); + +DECLARE_SOA_TABLE(HfRedJpsiCov, "AOD", "HFREDJPSICOV", //! Table with J/Psi candidate covariance for reduced workflow + o2::soa::Index<>, + hf_jpsi_cand_reduced::CYYDauPos, hf_jpsi_cand_reduced::CYYDauNeg, + hf_jpsi_cand_reduced::CZYDauPos, hf_jpsi_cand_reduced::CZYDauNeg, + hf_jpsi_cand_reduced::CZZDauPos, hf_jpsi_cand_reduced::CZZDauNeg, + hf_jpsi_cand_reduced::CSnpYDauPos, hf_jpsi_cand_reduced::CSnpYDauNeg, + hf_jpsi_cand_reduced::CSnpZDauPos, hf_jpsi_cand_reduced::CSnpZDauNeg, + hf_jpsi_cand_reduced::CSnpSnpDauPos, hf_jpsi_cand_reduced::CSnpSnpDauNeg, + hf_jpsi_cand_reduced::CTglYDauPos, hf_jpsi_cand_reduced::CTglYDauNeg, + hf_jpsi_cand_reduced::CTglZDauPos, hf_jpsi_cand_reduced::CTglZDauNeg, + hf_jpsi_cand_reduced::CTglSnpDauPos, hf_jpsi_cand_reduced::CTglSnpDauNeg, + hf_jpsi_cand_reduced::CTglTglDauPos, hf_jpsi_cand_reduced::CTglTglDauNeg, + hf_jpsi_cand_reduced::C1PtYDauPos, hf_jpsi_cand_reduced::C1PtYDauNeg, + hf_jpsi_cand_reduced::C1PtZDauPos, hf_jpsi_cand_reduced::C1PtZDauNeg, + hf_jpsi_cand_reduced::C1PtSnpDauPos, hf_jpsi_cand_reduced::C1PtSnpDauNeg, + hf_jpsi_cand_reduced::C1PtTglDauPos, hf_jpsi_cand_reduced::C1PtTglDauNeg, + hf_jpsi_cand_reduced::C1Pt21Pt2DauPos, hf_jpsi_cand_reduced::C1Pt21Pt2DauNeg); + +DECLARE_SOA_TABLE(HfRedPidDau0s_000, "AOD", "HFREDPIDDAU0", //! hf_track_pid_reduced::TPCNSigmaPiProng0, hf_track_pid_reduced::TOFNSigmaPiProng0, hf_track_pid_reduced::TPCNSigmaKaProng0, @@ -336,7 +642,7 @@ DECLARE_SOA_TABLE(HfRedPidDau0s, "AOD", "HFREDPIDDAU0", //! hf_track_pid_reduced::TPCTOFNSigmaPiProng0, hf_track_pid_reduced::TPCTOFNSigmaKaProng0); -DECLARE_SOA_TABLE(HfRedPidDau1s, "AOD", "HFREDPIDDAU1", //! +DECLARE_SOA_TABLE(HfRedPidDau1s_000, "AOD", "HFREDPIDDAU1", //! hf_track_pid_reduced::TPCNSigmaPiProng1, hf_track_pid_reduced::TOFNSigmaPiProng1, hf_track_pid_reduced::TPCNSigmaKaProng1, @@ -346,7 +652,7 @@ DECLARE_SOA_TABLE(HfRedPidDau1s, "AOD", "HFREDPIDDAU1", //! hf_track_pid_reduced::TPCTOFNSigmaPiProng1, hf_track_pid_reduced::TPCTOFNSigmaKaProng1); -DECLARE_SOA_TABLE(HfRedPidDau2s, "AOD", "HFREDPIDDAU2", //! +DECLARE_SOA_TABLE(HfRedPidDau2s_000, "AOD", "HFREDPIDDAU2", //! hf_track_pid_reduced::TPCNSigmaPiProng2, hf_track_pid_reduced::TOFNSigmaPiProng2, hf_track_pid_reduced::TPCNSigmaKaProng2, @@ -356,6 +662,55 @@ DECLARE_SOA_TABLE(HfRedPidDau2s, "AOD", "HFREDPIDDAU2", //! hf_track_pid_reduced::TPCTOFNSigmaPiProng2, hf_track_pid_reduced::TPCTOFNSigmaKaProng2); +DECLARE_SOA_TABLE_VERSIONED(HfRedPidDau0s_001, "AOD", "HFREDPIDDAU0", 1, //! + hf_track_pid_reduced::TPCNSigmaPiProng0, + hf_track_pid_reduced::TOFNSigmaPiProng0, + hf_track_pid_reduced::TPCNSigmaKaProng0, + hf_track_pid_reduced::TOFNSigmaKaProng0, + hf_track_pid_reduced::TPCNSigmaPrProng0, + hf_track_pid_reduced::TOFNSigmaPrProng0, + hf_track_vars_reduced::HasTOFProng0, + hf_track_vars_reduced::HasTPCProng0, + hf_track_pid_reduced::TPCTOFNSigmaPiProng0, + hf_track_pid_reduced::TPCTOFNSigmaKaProng0, + hf_track_pid_reduced::TPCTOFNSigmaPrProng0, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE_VERSIONED(HfRedPidDau1s_001, "AOD", "HFREDPIDDAU1", 1, //! + hf_track_pid_reduced::TPCNSigmaPiProng1, + hf_track_pid_reduced::TOFNSigmaPiProng1, + hf_track_pid_reduced::TPCNSigmaKaProng1, + hf_track_pid_reduced::TOFNSigmaKaProng1, + hf_track_pid_reduced::TPCNSigmaPrProng1, + hf_track_pid_reduced::TOFNSigmaPrProng1, + hf_track_vars_reduced::HasTOFProng1, + hf_track_vars_reduced::HasTPCProng1, + hf_track_pid_reduced::TPCTOFNSigmaPiProng1, + hf_track_pid_reduced::TPCTOFNSigmaKaProng1, + hf_track_pid_reduced::TPCTOFNSigmaPrProng1, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE_VERSIONED(HfRedPidDau2s_001, "AOD", "HFREDPIDDAU2", 1, //! + hf_track_pid_reduced::TPCNSigmaPiProng2, + hf_track_pid_reduced::TOFNSigmaPiProng2, + hf_track_pid_reduced::TPCNSigmaKaProng2, + hf_track_pid_reduced::TOFNSigmaKaProng2, + hf_track_pid_reduced::TPCNSigmaPrProng2, + hf_track_pid_reduced::TOFNSigmaPrProng2, + hf_track_vars_reduced::HasTOFProng2, + hf_track_vars_reduced::HasTPCProng2, + hf_track_pid_reduced::TPCTOFNSigmaPiProng2, + hf_track_pid_reduced::TPCTOFNSigmaKaProng2, + hf_track_pid_reduced::TPCTOFNSigmaPrProng2, + o2::soa::Marker<1>); + +using HfRedPidDau0s = HfRedPidDau0s_001; +using HfRedPidDau1s = HfRedPidDau1s_001; +using HfRedPidDau2s = HfRedPidDau2s_001; + +using HfRedPidDau0 = HfRedPidDau0s::iterator; +using HfRedPidDau1 = HfRedPidDau1s::iterator; +using HfRedPidDau2 = HfRedPidDau2s::iterator; // Beauty candidates prongs namespace hf_cand_b0_reduced { @@ -381,6 +736,8 @@ namespace hf_cand_bplus_reduced { DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed2Prongs, "_0"); //! Prong0 index DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrackBases, "_1"); //! Prong1 index +DECLARE_SOA_INDEX_COLUMN_FULL(Jpsi, jpsi, int, HfRedJpsis, "_0"); //! J/Psi index +DECLARE_SOA_INDEX_COLUMN_FULL(BachKa, bachKa, int, HfRedBach0Bases, "_0"); //! J/Psi index DECLARE_SOA_COLUMN(Prong0MlScoreBkg, prong0MlScoreBkg, float); //! Bkg ML score of the D daughter DECLARE_SOA_COLUMN(Prong0MlScorePrompt, prong0MlScorePrompt, float); //! Prompt ML score of the D daughter DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! Nonprompt ML score of the D daughter @@ -389,6 +746,9 @@ DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! N DECLARE_SOA_TABLE(HfRedBplusProngs, "AOD", "HFREDBPPRONG", hf_cand_bplus_reduced::Prong0Id, hf_cand_bplus_reduced::Prong1Id); +DECLARE_SOA_TABLE(HfRedBplus2JpsiDaus, "AOD", "HFREDBP2JPSIDAU", + hf_cand_bplus_reduced::JpsiId, hf_cand_bplus_reduced::BachKaId); + DECLARE_SOA_TABLE(HfRedBplusD0Mls, "AOD", "HFREDBPLUSD0ML", //! Table with ML scores for the D0 daughter hf_cand_bplus_reduced::Prong0MlScoreBkg, hf_cand_bplus_reduced::Prong0MlScorePrompt, @@ -396,19 +756,26 @@ DECLARE_SOA_TABLE(HfRedBplusD0Mls, "AOD", "HFREDBPLUSD0ML", //! Table with ML sc o2::soa::Marker<1>); using HfRedCandBplus = soa::Join; +using HfRedCandBplusToJpsiK = soa::Join; namespace hf_cand_bs_reduced { -DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed3Prongs, "_0"); //! Prong0 index -DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrackBases, "_1"); //! Prong1 index -DECLARE_SOA_COLUMN(Prong0MlScoreBkg, prong0MlScoreBkg, float); //! Bkg ML score of the D daughter -DECLARE_SOA_COLUMN(Prong0MlScorePrompt, prong0MlScorePrompt, float); //! Prompt ML score of the D daughter -DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! Nonprompt ML score of the D daughter +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed3Prongs, "_0"); //! Prong0 index +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrackBases, "_1"); //! Prong1 index +DECLARE_SOA_INDEX_COLUMN_FULL(Jpsi, jpsi, int, HfRedJpsis, "_0"); //! J/Psi index +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0Phi, prong0Phi, int, HfRedBach0Bases, "_0"); //! J/Psi index +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1Phi, prong1Phi, int, HfRedBach1Bases, "_0"); //! J/Psi index +DECLARE_SOA_COLUMN(Prong0MlScoreBkg, prong0MlScoreBkg, float); //! Bkg ML score of the D daughter +DECLARE_SOA_COLUMN(Prong0MlScorePrompt, prong0MlScorePrompt, float); //! Prompt ML score of the D daughter +DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! Nonprompt ML score of the D daughter } // namespace hf_cand_bs_reduced DECLARE_SOA_TABLE(HfRedBsProngs, "AOD", "HFREDBSPRONG", //! Table with Bs daughter indices hf_cand_bs_reduced::Prong0Id, hf_cand_bs_reduced::Prong1Id); +DECLARE_SOA_TABLE(HfRedBs2JpsiDaus, "AOD", "HFREDBS2JPSIDAU", + hf_cand_bs_reduced::JpsiId, hf_cand_bs_reduced::Prong0PhiId, hf_cand_bs_reduced::Prong1PhiId); + DECLARE_SOA_TABLE(HfRedBsDsMls, "AOD", "HFREDBSDSML", //! Table with ML scores for the Ds daughter hf_cand_bs_reduced::Prong0MlScoreBkg, hf_cand_bs_reduced::Prong0MlScorePrompt, @@ -416,6 +783,27 @@ DECLARE_SOA_TABLE(HfRedBsDsMls, "AOD", "HFREDBSDSML", //! Table with ML scores f o2::soa::Marker<1>); using HfRedCandBs = soa::Join; +using HfRedCandBsToJpsiPhi = soa::Join; + +namespace hf_cand_lb_reduced +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed3Prongs, "_0"); //! Prong0 index +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrackBases, "_1"); //! Prong1 index +DECLARE_SOA_COLUMN(Prong0MlScoreBkg, prong0MlScoreBkg, float); //! Bkg ML score of the Lc daughter +DECLARE_SOA_COLUMN(Prong0MlScorePrompt, prong0MlScorePrompt, float); //! Prompt ML score of the Lc daughter +DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! Nonprompt ML score of the Lc daughter +} // namespace hf_cand_lb_reduced + +DECLARE_SOA_TABLE(HfRedLbProngs, "AOD", "HFREDLBPRONG", //! Table with Lb daughter indices + hf_cand_lb_reduced::Prong0Id, hf_cand_lb_reduced::Prong1Id); + +DECLARE_SOA_TABLE(HfRedLbLcMls, "AOD", "HFREDLBLCML", //! Table with ML scores for the Lc daughter + hf_cand_lb_reduced::Prong0MlScoreBkg, + hf_cand_lb_reduced::Prong0MlScorePrompt, + hf_cand_lb_reduced::Prong0MlScoreNonprompt, + o2::soa::Marker<1>); + +using HfRedCandLb = soa::Join; namespace hf_b0_mc { @@ -463,6 +851,7 @@ DECLARE_SOA_TABLE(HfMcCheckDpPis, "AOD", "HFMCCHECKDPPI", //! Table with reconst // Table with same size as HFCANDB0 DECLARE_SOA_TABLE(HfMcRecRedB0s, "AOD", "HFMCRECREDB0", //! Reconstruction-level MC information on B0 candidates for reduced workflow hf_cand_b0::FlagMcMatchRec, + hf_cand_b0::FlagMcDecayChanRec, hf_cand_b0::FlagWrongCollision, hf_cand_b0::DebugMcRec, hf_b0_mc::PtMother); @@ -478,6 +867,7 @@ DECLARE_SOA_TABLE(HfMcCheckB0s, "AOD", "HFMCCHECKB0", //! Table with reconstruct DECLARE_SOA_TABLE(HfMcGenRedB0s, "AOD", "HFMCGENREDB0", //! Generation-level MC information on B0 candidates for reduced workflow hf_cand_b0::FlagMcMatchGen, + hf_cand_b0::FlagMcDecayChanRec, hf_b0_mc::PtTrack, hf_b0_mc::YTrack, hf_b0_mc::EtaTrack, @@ -486,7 +876,10 @@ DECLARE_SOA_TABLE(HfMcGenRedB0s, "AOD", "HFMCGENREDB0", //! Generation-level MC hf_b0_mc::EtaProng0, hf_b0_mc::PtProng1, hf_b0_mc::YProng1, - hf_b0_mc::EtaProng1); + hf_b0_mc::EtaProng1, + hf_reduced_collision::HfCollisionRejectionMap, + cent::CentFT0C, + cent::CentFT0M); // store all configurables values used in the first part of the workflow // so we can use them in the B0 part @@ -516,6 +909,7 @@ DECLARE_SOA_COLUMN(YProng1, yProng1, float); //! Rapidity of the track's pro DECLARE_SOA_COLUMN(EtaProng1, etaProng1, float); //! Pseudorapidity of the track's prong1 DECLARE_SOA_COLUMN(PdgCodeBeautyMother, pdgCodeBeautyMother, int); //! Pdg code of beauty mother +DECLARE_SOA_COLUMN(PdgCodeCharmMother, pdgCodeCharmMother, int); //! Pdg code of charm mother DECLARE_SOA_COLUMN(PdgCodeProng0, pdgCodeProng0, int); //! Pdg code of prong0 DECLARE_SOA_COLUMN(PdgCodeProng1, pdgCodeProng1, int); //! Pdg code of prong1 DECLARE_SOA_COLUMN(PdgCodeProng2, pdgCodeProng2, int); //! Pdg code of prong2 @@ -530,9 +924,20 @@ DECLARE_SOA_TABLE(HfMcRecRedD0Pis, "AOD", "HFMCRECREDD0PI", //! Table with recon hf_cand_bplus::DebugMcRec, hf_bplus_mc::PtMother); +// table with results of reconstruction level MC matching +DECLARE_SOA_TABLE(HfMcRecRedJPKs, "AOD", "HFMCRECREDJPK", //! Table with reconstructed MC information on J/PsiK(<-B+) pairs for reduced workflow + hf_cand_bplus_reduced::JpsiId, + hf_cand_bplus_reduced::BachKaId, + hf_cand_bplus::FlagMcMatchRec, + hf_cand_bplus::FlagMcDecayChanRec, + hf_cand_bplus::FlagWrongCollision, + hf_cand_bplus::DebugMcRec, + hf_bplus_mc::PtMother); + // DECLARE_SOA_EXTENDED_TABLE_USER(ExTable, Tracks, "EXTABLE", DECLARE_SOA_TABLE(HfMcCheckD0Pis, "AOD", "HFMCCHECKD0PI", //! Table with reconstructed MC information on D0Pi(<-B0) pairs for MC checks in reduced workflow hf_bplus_mc::PdgCodeBeautyMother, + hf_bplus_mc::PdgCodeCharmMother, hf_bplus_mc::PdgCodeProng0, hf_bplus_mc::PdgCodeProng1, hf_bplus_mc::PdgCodeProng2, @@ -541,12 +946,14 @@ DECLARE_SOA_TABLE(HfMcCheckD0Pis, "AOD", "HFMCCHECKD0PI", //! Table with reconst // Table with same size as HFCANDBPLUS DECLARE_SOA_TABLE(HfMcRecRedBps, "AOD", "HFMCRECREDBP", //! Reconstruction-level MC information on B+ candidates for reduced workflow hf_cand_bplus::FlagMcMatchRec, + hf_cand_bplus::FlagMcDecayChanRec, hf_cand_bplus::FlagWrongCollision, hf_cand_bplus::DebugMcRec, hf_bplus_mc::PtMother); DECLARE_SOA_TABLE(HfMcCheckBps, "AOD", "HFMCCHECKBP", //! Table with reconstructed MC information on B+ candidates for MC checks in reduced workflow hf_bplus_mc::PdgCodeBeautyMother, + hf_bplus_mc::PdgCodeCharmMother, hf_bplus_mc::PdgCodeProng0, hf_bplus_mc::PdgCodeProng1, hf_bplus_mc::PdgCodeProng2, @@ -554,6 +961,7 @@ DECLARE_SOA_TABLE(HfMcCheckBps, "AOD", "HFMCCHECKBP", //! Table with reconstruct DECLARE_SOA_TABLE(HfMcGenRedBps, "AOD", "HFMCGENREDBP", //! Generation-level MC information on B+ candidates for reduced workflow hf_cand_bplus::FlagMcMatchGen, + hf_cand_bplus::FlagMcDecayChanRec, hf_bplus_mc::PtTrack, hf_bplus_mc::YTrack, hf_bplus_mc::EtaTrack, @@ -562,7 +970,10 @@ DECLARE_SOA_TABLE(HfMcGenRedBps, "AOD", "HFMCGENREDBP", //! Generation-level MC hf_bplus_mc::EtaProng0, hf_bplus_mc::PtProng1, hf_bplus_mc::YProng1, - hf_bplus_mc::EtaProng1); + hf_bplus_mc::EtaProng1, + hf_reduced_collision::HfCollisionRejectionMap, + cent::CentFT0C, + cent::CentFT0M); // store all configurables values used in the first part of the workflow // so we can use them in the Bplus part @@ -571,6 +982,7 @@ namespace hf_cand_bplus_config DECLARE_SOA_COLUMN(MySelectionFlagD0, mySelectionFlagD0, int8_t); //! Flag to filter selected D0 mesons DECLARE_SOA_COLUMN(MySelectionFlagD0bar, mySelectionFlagD0bar, int8_t); //! Flag to filter selected D0 mesons DECLARE_SOA_COLUMN(MyInvMassWindowD0Pi, myInvMassWindowD0Pi, float); //! Half-width of the Bplus invariant-mass window in GeV/c2 +DECLARE_SOA_COLUMN(MyInvMassWindowJpsiK, myInvMassWindowJpsiK, float); //! Half-width of the Bplus invariant-mass window in GeV/c2 } // namespace hf_cand_bplus_config DECLARE_SOA_TABLE(HfCandBpConfigs, "AOD", "HFCANDBPCONFIG", //! Table with configurables information for reduced workflow @@ -578,6 +990,9 @@ DECLARE_SOA_TABLE(HfCandBpConfigs, "AOD", "HFCANDBPCONFIG", //! Table with confi hf_cand_bplus_config::MySelectionFlagD0bar, hf_cand_bplus_config::MyInvMassWindowD0Pi); +DECLARE_SOA_TABLE(HfCfgBpToJpsi, "AOD", "HFCFGBPTOJPSI", //! Table with configurables information for reduced workflow + hf_cand_bplus_config::MyInvMassWindowJpsiK); + namespace hf_bs_mc { // MC Rec @@ -610,6 +1025,17 @@ DECLARE_SOA_TABLE(HfMcRecRedDsPis, "AOD", "HFMCRECREDDSPI", //! Table with recon hf_cand_bs::DebugMcRec, hf_bs_mc::PtMother); +// table with results of reconstruction level MC matching +DECLARE_SOA_TABLE(HfMcRecRedJPPhis, "AOD", "HFMCRECREDJPPHI", //! Table with reconstructed MC information on DsPi(<-Bs) pairs for reduced workflow + hf_cand_bs_reduced::JpsiId, + hf_cand_bs_reduced::Prong0PhiId, + hf_cand_bs_reduced::Prong1PhiId, + hf_cand_bs::FlagMcMatchRec, + hf_cand_bs::FlagMcDecayChanRec, + hf_cand_bs::FlagWrongCollision, + hf_cand_bs::DebugMcRec, + hf_bs_mc::PtMother); + // try with extended table ? // DECLARE_SOA_EXTENDED_TABLE_USER(ExTable, Tracks, "EXTABLE", DECLARE_SOA_TABLE(HfMcCheckDsPis, "AOD", "HFMCCHECKDSPI", //! Table with reconstructed MC information on DsPi(<-Bs) pairs for MC checks in reduced workflow @@ -624,6 +1050,7 @@ DECLARE_SOA_TABLE(HfMcCheckDsPis, "AOD", "HFMCCHECKDSPI", //! Table with reconst // Table with same size as HFCANDBS DECLARE_SOA_TABLE(HfMcRecRedBss, "AOD", "HFMCRECREDBS", //! Reconstruction-level MC information on Bs candidates for reduced workflow hf_cand_bs::FlagMcMatchRec, + hf_cand_bs::FlagMcDecayChanRec, hf_cand_bs::FlagWrongCollision, hf_cand_bs::DebugMcRec, hf_bs_mc::PtMother); @@ -639,6 +1066,7 @@ DECLARE_SOA_TABLE(HfMcCheckBss, "AOD", "HFMCCHECKBS", //! Table with reconstruct DECLARE_SOA_TABLE(HfMcGenRedBss, "AOD", "HFMCGENREDBS", //! Generation-level MC information on Bs candidates for reduced workflow hf_cand_bs::FlagMcMatchGen, + hf_cand_bs::FlagMcDecayChanRec, hf_bs_mc::PtTrack, hf_bs_mc::YTrack, hf_bs_mc::EtaTrack, @@ -647,25 +1075,117 @@ DECLARE_SOA_TABLE(HfMcGenRedBss, "AOD", "HFMCGENREDBS", //! Generation-level MC hf_bs_mc::EtaProng0, hf_bs_mc::PtProng1, hf_bs_mc::YProng1, - hf_bs_mc::EtaProng1); + hf_bs_mc::EtaProng1, + hf_reduced_collision::HfCollisionRejectionMap, + cent::CentFT0C, + cent::CentFT0M); // store all configurables values used in the first part of the workflow // so we can use them in the Bs part namespace hf_cand_bs_config { -DECLARE_SOA_COLUMN(MySelectionFlagD, mySelectionFlagD, int8_t); //! Flag to filter selected Ds mesons -DECLARE_SOA_COLUMN(MyInvMassWindowDPi, myInvMassWindowDPi, float); //! Half-width of the Bs invariant-mass window in GeV/c2 +DECLARE_SOA_COLUMN(MySelectionFlagD, mySelectionFlagD, int8_t); //! Flag to filter selected Ds mesons +DECLARE_SOA_COLUMN(MyInvMassWindowDPi, myInvMassWindowDPi, float); //! Half-width of the Bs invariant-mass window in GeV/c2 +DECLARE_SOA_COLUMN(MyInvMassWindowJpsiPhi, myInvMassWindowJpsiPhi, float); //! Half-width of the Bs invariant-mass window in GeV/c2 } // namespace hf_cand_bs_config DECLARE_SOA_TABLE(HfCandBsConfigs, "AOD", "HFCANDBSCONFIG", //! Table with configurables information for reduced workflow hf_cand_bs_config::MySelectionFlagD, hf_cand_bs_config::MyInvMassWindowDPi); +DECLARE_SOA_TABLE(HfCfgBsToJpsis, "AOD", "HFCFGBSTOJPSI", //! Table with configurables information for reduced workflow + hf_cand_bs_config::MyInvMassWindowJpsiPhi); +namespace hf_lb_mc +{ +// MC Rec +DECLARE_SOA_COLUMN(PtMother, ptMother, float); //! Transverse momentum of the mother in GeV/c +// MC Gen +DECLARE_SOA_COLUMN(PtTrack, ptTrack, float); //! Transverse momentum of the track in GeV/c +DECLARE_SOA_COLUMN(YTrack, yTrack, float); //! Rapidity of the track +DECLARE_SOA_COLUMN(EtaTrack, etaTrack, float); //! Pseudorapidity of the track +DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); //! Transverse momentum of the track's prong0 in GeV/c +DECLARE_SOA_COLUMN(YProng0, yProng0, float); //! Rapidity of the track's prong0 +DECLARE_SOA_COLUMN(EtaProng0, etaProng0, float); //! Pseudorapidity of the track's prong0 +DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); //! Transverse momentum of the track's prong1 in GeV/c +DECLARE_SOA_COLUMN(YProng1, yProng1, float); //! Rapidity of the track's prong1 +DECLARE_SOA_COLUMN(EtaProng1, etaProng1, float); //! Pseudorapidity of the track's prong1 + +DECLARE_SOA_COLUMN(PdgCodeBeautyMother, pdgCodeBeautyMother, int); //! Pdg code of beauty mother +DECLARE_SOA_COLUMN(PdgCodeCharmMother, pdgCodeCharmMother, int); //! Pdg code of charm mother +DECLARE_SOA_COLUMN(PdgCodeProng0, pdgCodeProng0, int); //! Pdg code of prong0 +DECLARE_SOA_COLUMN(PdgCodeProng1, pdgCodeProng1, int); //! Pdg code of prong1 +DECLARE_SOA_COLUMN(PdgCodeProng2, pdgCodeProng2, int); //! Pdg code of prong2 +DECLARE_SOA_COLUMN(PdgCodeProng3, pdgCodeProng3, int); //! Pdg code of prong3 +} // namespace hf_lb_mc + +// table with results of reconstruction level MC matching +DECLARE_SOA_TABLE(HfMcRecRedLcPis, "AOD", "HFMCRECREDLCPI", //! Table with reconstructed MC information on LcPi(<-Lb) pairs for reduced workflow + hf_cand_lb_reduced::Prong0Id, + hf_cand_lb_reduced::Prong1Id, + hf_cand_lb::FlagMcMatchRec, + hf_cand_lb::FlagWrongCollision, + hf_cand_lb::DebugMcRec, + hf_lb_mc::PtMother); + +DECLARE_SOA_TABLE(HfMcCheckLcPis, "AOD", "HFMCCHECKLCPI", //! Table with reconstructed MC information on LcPi(<-Lb) pairs for MC checks in reduced workflow + hf_lb_mc::PdgCodeBeautyMother, + hf_lb_mc::PdgCodeCharmMother, + hf_lb_mc::PdgCodeProng0, + hf_lb_mc::PdgCodeProng1, + hf_lb_mc::PdgCodeProng2, + hf_lb_mc::PdgCodeProng3, + o2::soa::Marker<1>); + +// Table with same size as HFCANDLc +DECLARE_SOA_TABLE(HfMcRecRedLbs, "AOD", "HFMCRECREDLB", //! Reconstruction-level MC information on Lb candidates for reduced workflow + hf_cand_lb::FlagMcMatchRec, + hf_cand_lb::FlagWrongCollision, + hf_cand_lb::DebugMcRec, + hf_lb_mc::PtMother); + +DECLARE_SOA_TABLE(HfMcCheckLbs, "AOD", "HFMCCHECKLB", //! Table with reconstructed MC information on Lb candidates for MC checks in reduced workflow + hf_lb_mc::PdgCodeBeautyMother, + hf_lb_mc::PdgCodeCharmMother, + hf_lb_mc::PdgCodeProng0, + hf_lb_mc::PdgCodeProng1, + hf_lb_mc::PdgCodeProng2, + hf_lb_mc::PdgCodeProng3, + o2::soa::Marker<2>); + +DECLARE_SOA_TABLE(HfMcGenRedLbs, "AOD", "HFMCGENREDLB", //! Generation-level MC information on Lb candidates for reduced workflow + hf_cand_lb::FlagMcMatchGen, + hf_lb_mc::PtTrack, + hf_lb_mc::YTrack, + hf_lb_mc::EtaTrack, + hf_lb_mc::PtProng0, + hf_lb_mc::YProng0, + hf_lb_mc::EtaProng0, + hf_lb_mc::PtProng1, + hf_lb_mc::YProng1, + hf_lb_mc::EtaProng1, + hf_reduced_collision::HfCollisionRejectionMap, + cent::CentFT0C, + cent::CentFT0M); + +// store all configurables values used in the first part of the workflow +// so we can use them in the B0 part +namespace hf_cand_lb_config +{ +DECLARE_SOA_COLUMN(MySelectionFlagLc, mySelectionFlagLc, int8_t); //! Flag to filter selected Lc baryons +DECLARE_SOA_COLUMN(MyInvMassWindowLcPi, myInvMassWindowLcPi, float); //! Half-width of the Lb invariant-mass window in GeV/c2 +} // namespace hf_cand_lb_config + +DECLARE_SOA_TABLE(HfCandLbConfigs, "AOD", "HFCANDLBCONFIG", //! Table with configurables information for reduced workflow + hf_cand_lb_config::MySelectionFlagLc, + hf_cand_lb_config::MyInvMassWindowLcPi); + // Charm resonances analysis namespace hf_reso_3_prong { -DECLARE_SOA_COLUMN(DType, dType, int8_t); //! Integer with selected D candidate type: 1 = Dplus, -1 = Dminus, 2 = DstarPlus, -2 = DstarMinus - +DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Integer with selected D candidate sign +DECLARE_SOA_COLUMN(ItsNClsSoftPi, itsNClsSoftPi, int); //! minimum value of number of ITS clusters for the decay daughter tracks +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsSoftPi, tpcNClsCrossedRowsSoftPi, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks +DECLARE_SOA_COLUMN(TpcChi2NClSoftPi, tpcChi2NClSoftPi, float); //! maximum value of TPC chi2 for the decay daughter tracks DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! [](float pxProng0, float pxProng1, float pxProng2) -> float { return 1.f * pxProng0 + 1.f * pxProng1 + 1.f * pxProng2; }); DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! @@ -680,6 +1200,21 @@ DECLARE_SOA_DYNAMIC_COLUMN(PVector, pVector, [](float px0, float py0, float pz0, float px1, float py1, float pz1, float px2, float py2, float pz2) -> std::array { return std::array{px0 + px1 + px2, py0 + py1 + py2, pz0 + pz1 + pz2}; }); } // namespace hf_reso_3_prong +namespace hf_reso_2_prong +{ +DECLARE_SOA_COLUMN(SelFlagD0, selFlagD0, uint8_t); //! Integer with D0 selection flag: 1 = selected as D0, 2 = selected as D0bar, 3 = selected as D0 and D0bar +DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! + [](float pxProng0, float pxProng1) -> float { return 1.f * pxProng0 + 1.f * pxProng1; }); +DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! + [](float pyProng0, float pyProng1) -> float { return 1.f * pyProng0 + 1.f * pyProng1; }); +DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //! + [](float pzProng0, float pzProng1) -> float { return 1.f * pzProng0 + 1.f * pzProng1; }); +DECLARE_SOA_DYNAMIC_COLUMN(PVector, pVector, + [](float pxProng0, float pyProng0, float pzProng0, float pxProng1, float pyProng1, float pzProng1) -> std::array { return std::array{pxProng0 + pxProng1, pyProng0 + pyProng1, pzProng0 + pzProng1}; }); +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! + [](float pxProng0, float pxProng1, float pyProng0, float pyProng1) -> float { return RecoDecay::pt((1.f * pxProng0 + 1.f * pxProng1), (1.f * pyProng0 + 1.f * pyProng1)); }); +} // namespace hf_reso_2_prong + namespace hf_reso_v0 { DECLARE_SOA_COLUMN(Cpa, cpa, float); //! Cosine of Pointing Angle of V0 candidate @@ -687,7 +1222,7 @@ DECLARE_SOA_COLUMN(Dca, dca, float); //! DCA of V0 candidate DECLARE_SOA_COLUMN(Radius, radius, float); //! Radius of V0 candidate DECLARE_SOA_COLUMN(V0Type, v0Type, uint8_t); //! Bitmap with mass hypothesis of the V0 -DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! +DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! [](float pxProng0, float pxProng1) -> float { return 1.f * pxProng0 + 1.f * pxProng1; }); DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! [](float pyProng0, float pyProng1) -> float { return 1.f * pyProng0 + 1.f * pyProng1; }); @@ -739,6 +1274,7 @@ DECLARE_SOA_TABLE(HfRedVzeros, "AOD", "HFREDVZERO", //! Table with V0 candidate DECLARE_SOA_TABLE(HfRedTrkNoParams, "AOD", "HFREDTRKNOPARAM", //! Table with tracks without track parameters for resonances reduced workflow o2::soa::Index<>, // Indices + hf_track_index_reduced::TrackId, hf_track_index_reduced::HfRedCollisionId, // Static hf_track_vars_reduced::Px, @@ -762,7 +1298,8 @@ DECLARE_SOA_TABLE(HfRedTrkNoParams, "AOD", "HFREDTRKNOPARAM", //! Table with tra hf_track_vars_reduced::Phi, hf_track_pid_reduced::TPCTOFNSigmaPi, hf_track_pid_reduced::TPCTOFNSigmaKa, - hf_track_pid_reduced::TPCTOFNSigmaPr); + hf_track_pid_reduced::TPCTOFNSigmaPr, + hf_track_vars_reduced::PVector); DECLARE_SOA_TABLE(HfRed3PrNoTrks, "AOD", "HFRED3PRNOTRK", //! Table with 3 prong candidate information for resonances reduced workflow o2::soa::Index<>, @@ -775,7 +1312,7 @@ DECLARE_SOA_TABLE(HfRed3PrNoTrks, "AOD", "HFRED3PRNOTRK", //! Table with 3 prong hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, hf_cand::PxProng2, hf_cand::PyProng2, hf_cand::PzProng2, hf_track_vars_reduced::ItsNClsProngMin, hf_track_vars_reduced::TpcNClsCrossedRowsProngMin, hf_track_vars_reduced::TpcChi2NClProngMax, - hf_reso_3_prong::DType, + hf_reso_3_prong::Sign, // Dynamic hf_reso_3_prong::Px, hf_reso_3_prong::Py, @@ -787,6 +1324,62 @@ DECLARE_SOA_TABLE(HfRed3PrNoTrks, "AOD", "HFRED3PRNOTRK", //! Table with 3 prong hf_track_vars_reduced::EtaProng1, hf_track_vars_reduced::EtaProng2, hf_reso_3_prong::InvMassDplus, + hf_reso_3_prong::Pt, + hf_cand::PVectorProng0, + hf_cand::PVectorProng1, + hf_cand::PVectorProng2, + hf_reso_3_prong::PVector); + +DECLARE_SOA_TABLE(HfRed2PrNoTrks, "AOD", "HFRED2PRNOTRK", //! Table with 2 prong candidate information for resonances reduced workflow + o2::soa::Index<>, + // Indices + hf_track_index_reduced::Prong0Id, hf_track_index_reduced::Prong1Id, + hf_track_index_reduced::HfRedCollisionId, + // Static + hf_cand::XSecondaryVertex, hf_cand::YSecondaryVertex, hf_cand::ZSecondaryVertex, + hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, + hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, + hf_track_vars_reduced::ItsNClsProngMin, hf_track_vars_reduced::TpcNClsCrossedRowsProngMin, hf_track_vars_reduced::TpcChi2NClProngMax, + hf_reso_2_prong::SelFlagD0, + // Dynamic + hf_reso_2_prong::Px, + hf_reso_2_prong::Py, + hf_reso_2_prong::Pz, + hf_track_vars_reduced::PtProng0, + hf_track_vars_reduced::PtProng1, + hf_track_vars_reduced::EtaProng0, + hf_track_vars_reduced::EtaProng1, + hf_reso_2_prong::PVector, + hf_cand::PVectorProng0, + hf_cand::PVectorProng1, + hf_reso_2_prong::Pt, + // InvMasses + hf_cand_dstar::InvMassD0, + hf_cand_dstar::InvMassD0Bar); + +DECLARE_SOA_TABLE(HfRedDstarNoTrks, "AOD", "HFREDDSTARNOTRK", //! Table with 3 prong candidate information for resonances reduced workflow + o2::soa::Index<>, + // Indices + hf_track_index_reduced::Prong0Id, hf_track_index_reduced::Prong1Id, hf_track_index_reduced::Prong2Id, + hf_track_index_reduced::HfRedCollisionId, + // Static + hf_cand::XSecondaryVertex, hf_cand::YSecondaryVertex, hf_cand::ZSecondaryVertex, + hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, + hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, + hf_cand::PxProng2, hf_cand::PyProng2, hf_cand::PzProng2, + hf_track_vars_reduced::ItsNClsProngMin, hf_track_vars_reduced::TpcNClsCrossedRowsProngMin, hf_track_vars_reduced::TpcChi2NClProngMax, + hf_reso_3_prong::ItsNClsSoftPi, hf_reso_3_prong::TpcNClsCrossedRowsSoftPi, hf_reso_3_prong::TpcChi2NClSoftPi, + hf_reso_3_prong::Sign, + // Dynamic + hf_reso_3_prong::Px, + hf_reso_3_prong::Py, + hf_reso_3_prong::Pz, + hf_track_vars_reduced::PtProng0, + hf_track_vars_reduced::PtProng1, + hf_track_vars_reduced::PtProng2, + hf_track_vars_reduced::EtaProng0, + hf_track_vars_reduced::EtaProng1, + hf_track_vars_reduced::EtaProng2, hf_cand_dstar::InvMassDstar, hf_cand_dstar::InvMassAntiDstar, hf_cand_dstar::InvMassD0, @@ -799,37 +1392,60 @@ DECLARE_SOA_TABLE(HfRed3PrNoTrks, "AOD", "HFRED3PRNOTRK", //! Table with 3 prong namespace hf_reso_cand_reduced { -DECLARE_SOA_COLUMN(InvMass, invMass, float); //! Invariant mass in GeV/c2 -DECLARE_SOA_COLUMN(InvMassProng0, invMassProng0, float); //! Invariant Mass of D daughter in GeV/c -DECLARE_SOA_COLUMN(InvMassProng1, invMassProng1, float); //! Invariant Mass of V0 daughter in GeV/c -DECLARE_SOA_COLUMN(InvMassD0, invMassD0, float); //! Invariant Mass of potential D0 daughter - -DECLARE_SOA_COLUMN(MlScoreBkgProng0, mlScoreBkgProng0, float); //! Bkg ML score of the D daughter -DECLARE_SOA_COLUMN(MlScorePromptProng0, mlScorePromptProng0, float); //! Prompt ML score of the D daughter -DECLARE_SOA_COLUMN(MlScoreNonpromptProng0, mlScoreNonpromptProng0, float); //! Nonprompt ML score of the D daughter - -DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed3PrNoTrks, "_0"); //! Prong0 index (D daughter) -DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedVzeros, "_1"); //! Prong1 index (V0 daughter) -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // flag for decay channel classification reconstruction level +DECLARE_SOA_COLUMN(InvMass, invMass, float); //! Invariant mass in GeV/c2 +DECLARE_SOA_COLUMN(InvMassProng0, invMassProng0, float); //! Invariant Mass of D daughter in GeV/c +DECLARE_SOA_COLUMN(InvMassProng1, invMassProng1, float); //! Invariant Mass of V0/Tr daughter in GeV/c +DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of the Resonance candidate +DECLARE_SOA_COLUMN(IsWrongSign, isWrongSign, int8_t); //! Flag for wrong sign of the Resonance candidate, 1 = wrong sign, 0 = right sign + +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // flag for resonance decay channel classification reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchRecD, flagMcMatchRecD, int8_t); // flag for D meson bachelor decay channel classification reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchChanD, flagMcMatchChanD, int8_t); // flag for D meson resonant channel classification reconstruction level DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // flag for decay channel classification generator level -DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association at reconstruction level +DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, uint16_t); // debug flag for mis-association at reconstruction level DECLARE_SOA_COLUMN(Origin, origin, int8_t); // Flag for origin of MC particle 1=promt, 2=FD DECLARE_SOA_COLUMN(SignD0, signD0, int8_t); // Sign of the D0 in the channels with D* -> D0 pi, needed in case of non-matched D* - -DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! +DECLARE_SOA_COLUMN(PtGen, ptGen, float); // Pt at generation level in GeV/c +DECLARE_SOA_COLUMN(InvMassGen, invMassGen, float); //! Invariant mass at generation level in GeV/c2 +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! [](float pxProng0, float pxProng1, float pyProng0, float pyProng1) -> float { return RecoDecay::pt((1.f * pxProng0 + 1.f * pxProng1), (1.f * pyProng0 + 1.f * pyProng1)); }); DECLARE_SOA_DYNAMIC_COLUMN(PtProng0, ptProng0, //! [](float pxProng0, float pyProng0) -> float { return RecoDecay::pt(pxProng0, pyProng0); }); DECLARE_SOA_DYNAMIC_COLUMN(PtProng1, ptProng1, //! [](float pxProng1, float pyProng1) -> float { return RecoDecay::pt(pxProng1, pyProng1); }); -DECLARE_SOA_DYNAMIC_COLUMN(CosThetaStarDs1, cosThetaStarDs1, //! costhetastar under Ds1 hypothesis - [](float px0, float py0, float pz0, float px1, float py1, float pz1, float invMass) -> float { return RecoDecay::cosThetaStar(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, std::array{o2::constants::physics::MassDStar, o2::constants::physics::MassK0}, invMass, 1); }); -DECLARE_SOA_DYNAMIC_COLUMN(CosThetaStarDs2Star, cosThetaStarDs2Star, //! costhetastar under Ds2Star hypothesis - [](float px0, float py0, float pz0, float px1, float py1, float pz1, float invMass) -> float { return RecoDecay::cosThetaStar(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, std::array{o2::constants::physics::MassDPlus, o2::constants::physics::MassK0}, invMass, 1); }); -DECLARE_SOA_DYNAMIC_COLUMN(CosThetaStarXiC3055, cosThetaStarXiC3055, //! costhetastar under XiC3055 hypothesis - [](float px0, float py0, float pz0, float px1, float py1, float pz1, float invMass) -> float { return RecoDecay::cosThetaStar(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, std::array{o2::constants::physics::MassDPlus, o2::constants::physics::MassLambda0}, invMass, 1); }); } // namespace hf_reso_cand_reduced +namespace hf_reso_3pr_v0 +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed3PrNoTrks, "_0"); //! Prong0 index (D daughter) +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedVzeros, "_1"); //! Prong1 index (V0 daughter) +} // namespace hf_reso_3pr_v0 +namespace hf_reso_dstar_v0 +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRedDstarNoTrks, "_0"); //! Prong0 index (D daughter) +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedVzeros, "_1"); //! Prong1 index (V0 daughter) +} // namespace hf_reso_dstar_v0 +namespace hf_reso_2pr_v0 +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed2PrNoTrks, "_0"); //! Prong0 index (D daughter) +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedVzeros, "_1"); //! Prong1 index (V0 daughter) +} // namespace hf_reso_2pr_v0 +namespace hf_reso_3pr_trk +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed3PrNoTrks, "_0"); //! Prong0 index (D daughter) +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrkNoParams, "_1"); //! Prong1 index (Track daughter) +} // namespace hf_reso_3pr_trk +namespace hf_reso_dstar_trk +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRedDstarNoTrks, "_0"); //! Prong0 index (D daughter) +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrkNoParams, "_1"); //! Prong1 index (Track daughter) +} // namespace hf_reso_dstar_trk +namespace hf_reso_2pr_trk +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed2PrNoTrks, "_0"); //! Prong0 index (D daughter) +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrkNoParams, "_1"); //! Prong1 index (Track daughter) +} // namespace hf_reso_2pr_trk + DECLARE_SOA_TABLE(HfCandCharmReso, "AOD", "HFCANDCHARMRESO", //! Table with Resonance candidate information for resonances reduced workflow o2::soa::Index<>, // Static @@ -838,10 +1454,8 @@ DECLARE_SOA_TABLE(HfCandCharmReso, "AOD", "HFCANDCHARMRESO", //! Table with Reso hf_reso_cand_reduced::InvMass, hf_reso_cand_reduced::InvMassProng0, hf_reso_cand_reduced::InvMassProng1, - hf_reso_v0::Cpa, - hf_reso_v0::Dca, - hf_reso_v0::Radius, - hf_reso_cand_reduced::InvMassD0, + hf_reso_cand_reduced::Sign, + hf_reso_cand_reduced::IsWrongSign, // Dynamic hf_reso_cand_reduced::Pt, hf_reso_cand_reduced::PtProng0, @@ -850,32 +1464,111 @@ DECLARE_SOA_TABLE(HfCandCharmReso, "AOD", "HFCANDCHARMRESO", //! Table with Reso hf_reso_v0::Py, hf_reso_v0::Pz, hf_cand::PVectorProng0, - hf_cand::PVectorProng1, - hf_reso_cand_reduced::CosThetaStarDs1, - hf_reso_cand_reduced::CosThetaStarDs2Star, - hf_reso_cand_reduced::CosThetaStarXiC3055); + hf_cand::PVectorProng1); -DECLARE_SOA_TABLE(HfResoIndices, "AOD", "HFRESOINDICES", //! Table with Indices of resonance daughters for MC matching +DECLARE_SOA_TABLE(Hf3PrV0Ids, "AOD", "HF3PRV0ID", hf_track_index_reduced::HfRedCollisionId, - hf_reso_cand_reduced::Prong0Id, - hf_reso_cand_reduced::Prong1Id); - -DECLARE_SOA_TABLE(HfCharmResoMLs, "AOD", "HFCHARMRESOML", //! Table with ML scores for the D daughter - hf_reso_cand_reduced::MlScoreBkgProng0, - hf_reso_cand_reduced::MlScorePromptProng0, - hf_reso_cand_reduced::MlScoreNonpromptProng0, - o2::soa::Marker<1>); + hf_reso_3pr_v0::Prong0Id, + hf_reso_3pr_v0::Prong1Id); +DECLARE_SOA_TABLE(HfDstarV0Ids, "AOD", "HFDSTARV0ID", + hf_track_index_reduced::HfRedCollisionId, + hf_reso_dstar_v0::Prong0Id, + hf_reso_dstar_v0::Prong1Id); +DECLARE_SOA_TABLE(Hf2PrV0Ids, "AOD", "HF2PRV0ID", + hf_track_index_reduced::HfRedCollisionId, + hf_reso_2pr_v0::Prong0Id, + hf_reso_2pr_v0::Prong1Id); +DECLARE_SOA_TABLE(Hf3PrTrkIds, "AOD", "HF3PRTRKID", + hf_track_index_reduced::HfRedCollisionId, + hf_reso_3pr_trk::Prong0Id, + hf_reso_3pr_trk::Prong1Id); +DECLARE_SOA_TABLE(HfDstarTrkIds, "AOD", "HFDSTARTRKID", + hf_track_index_reduced::HfRedCollisionId, + hf_reso_dstar_trk::Prong0Id, + hf_reso_dstar_trk::Prong1Id); +DECLARE_SOA_TABLE(Hf2PrTrkIds, "AOD", "HF2PRTRKID", + hf_track_index_reduced::HfRedCollisionId, + hf_reso_2pr_trk::Prong0Id, + hf_reso_2pr_trk::Prong1Id); // Tables for MC Resonance analysis // table with results of reconstruction level MC matching -DECLARE_SOA_TABLE(HfMcRecRedDV0s, "AOD", "HFMCRECREDDV0", //! Table with reconstructed MC information on DV0(<-Ds*) pairs for reduced workflow - hf_reso_cand_reduced::Prong0Id, - hf_reso_cand_reduced::Prong1Id, +DECLARE_SOA_TABLE(Hf3PrV0McRec, "AOD", "HF3PRV0MCREC", + hf_reso_3pr_v0::Prong0Id, + hf_reso_3pr_v0::Prong1Id, + hf_reso_cand_reduced::FlagMcMatchRec, + hf_reso_cand_reduced::FlagMcMatchRecD, + hf_reso_cand_reduced::FlagMcMatchChanD, + hf_reso_cand_reduced::DebugMcRec, + hf_reso_cand_reduced::Origin, + hf_reso_cand_reduced::PtGen, + hf_reso_cand_reduced::InvMassGen, + hf_cand::NTracksDecayed, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(HfDstarV0McRec, "AOD", "HFDSTARV0MCREC", + hf_reso_dstar_v0::Prong0Id, + hf_reso_dstar_v0::Prong1Id, + hf_reso_cand_reduced::FlagMcMatchRec, + hf_reso_cand_reduced::FlagMcMatchRecD, + hf_reso_cand_reduced::FlagMcMatchChanD, + hf_reso_cand_reduced::DebugMcRec, + hf_reso_cand_reduced::Origin, + hf_reso_cand_reduced::PtGen, + hf_reso_cand_reduced::InvMassGen, + hf_cand::NTracksDecayed, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(Hf2PrV0McRec, "AOD", "HF2PRV0MCREC", + hf_reso_2pr_v0::Prong0Id, + hf_reso_2pr_v0::Prong1Id, + hf_reso_cand_reduced::FlagMcMatchRec, + hf_reso_cand_reduced::FlagMcMatchRecD, + hf_reso_cand_reduced::FlagMcMatchChanD, + hf_reso_cand_reduced::DebugMcRec, + hf_reso_cand_reduced::Origin, + hf_reso_cand_reduced::PtGen, + hf_reso_cand_reduced::InvMassGen, + hf_cand::NTracksDecayed, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(Hf3PrTrkMcRec, "AOD", "HF3PRTRKMCREC", + hf_reso_3pr_trk::Prong0Id, + hf_reso_3pr_trk::Prong1Id, hf_reso_cand_reduced::FlagMcMatchRec, + hf_reso_cand_reduced::FlagMcMatchRecD, + hf_reso_cand_reduced::FlagMcMatchChanD, hf_reso_cand_reduced::DebugMcRec, hf_reso_cand_reduced::Origin, - hf_reso_cand_reduced::SignD0, - hf_b0_mc::PtMother, + hf_reso_cand_reduced::PtGen, + hf_reso_cand_reduced::InvMassGen, + hf_cand::NTracksDecayed, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(HfDstarTrkMcRec, "AOD", "HFDSTARTRKMCREC", + hf_reso_dstar_trk::Prong0Id, + hf_reso_dstar_trk::Prong1Id, + hf_reso_cand_reduced::FlagMcMatchRec, + hf_reso_cand_reduced::FlagMcMatchRecD, + hf_reso_cand_reduced::FlagMcMatchChanD, + hf_reso_cand_reduced::DebugMcRec, + hf_reso_cand_reduced::Origin, + hf_reso_cand_reduced::PtGen, + hf_reso_cand_reduced::InvMassGen, + hf_cand::NTracksDecayed, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(Hf2PrTrkMcRec, "AOD", "HF2PRTRKMCREC", + hf_reso_2pr_trk::Prong0Id, + hf_reso_2pr_trk::Prong1Id, + hf_reso_cand_reduced::FlagMcMatchRec, + hf_reso_cand_reduced::FlagMcMatchRecD, + hf_reso_cand_reduced::FlagMcMatchChanD, + hf_reso_cand_reduced::DebugMcRec, + hf_reso_cand_reduced::Origin, + hf_reso_cand_reduced::PtGen, + hf_reso_cand_reduced::InvMassGen, + hf_cand::NTracksDecayed, o2::soa::Marker<1>); DECLARE_SOA_TABLE(HfMcGenRedResos, "AOD", "HFMCGENREDRESO", //! Generation-level MC information on Ds-Resonances candidates for reduced workflow @@ -890,23 +1583,19 @@ DECLARE_SOA_TABLE(HfMcGenRedResos, "AOD", "HFMCGENREDRESO", //! Generation-level hf_b0_mc::PtProng1, hf_b0_mc::YProng1, hf_b0_mc::EtaProng1, + hf_reso_cand_reduced::InvMassGen, + hf_reduced_collision::HfCollisionRejectionMap, o2::soa::Marker<1>); -DECLARE_SOA_TABLE(HfCandChaResTr, "AOD", "HFCANDCHARESTR", //! Table with Resonance candidate information for resonances plus tracks reduced workflow - // Static - hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, - hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, - hf_reso_cand_reduced::InvMass, - hf_reso_cand_reduced::InvMassProng0, - // Dynamic - hf_reso_cand_reduced::PtProng0); - // Table with same size as HfCandCharmReso DECLARE_SOA_TABLE(HfMcRecRedResos, "AOD", "HFMCRECREDRESO", //! Reconstruction-level MC information on Ds-Resonances candidates for reduced workflow hf_reso_cand_reduced::FlagMcMatchRec, + hf_reso_cand_reduced::FlagMcMatchRecD, + hf_reso_cand_reduced::FlagMcMatchChanD, hf_reso_cand_reduced::DebugMcRec, hf_reso_cand_reduced::Origin, - hf_b0_mc::PtMother, + hf_reso_cand_reduced::PtGen, + hf_reso_cand_reduced::InvMassGen, o2::soa::Marker<1>); } // namespace aod diff --git a/PWGHF/D2H/Macros/CMakeLists_HFInvMassFitter.txt b/PWGHF/D2H/Macros/CMakeLists_HFInvMassFitter.txt new file mode 100644 index 00000000000..5a74cec1768 --- /dev/null +++ b/PWGHF/D2H/Macros/CMakeLists_HFInvMassFitter.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.10) + +project(HFInvMassFitter) + +set(HFFITTER_RAPIDJSON_INCLUDE_DIRS "" CACHE STRING "Location of rapidjson include directories") + +find_package(ROOT REQUIRED COMPONENTS RooFit RooFitCore) + +include_directories(${ROOT_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${HFFITTER_RAPIDJSON_INCLUDE_DIRS}) + +set(SOURCES + HFInvMassFitter.cxx + runMassFitter.C +) + +add_executable(runMassFitter ${SOURCES} "HFInvMassFitter.h") + +ROOT_GENERATE_DICTIONARY(G__HFInvMassFitter + HFInvMassFitter.h LINKDEF HFInvMassFitterLinkDef.h + MODULE runMassFitter +) + +target_link_libraries(runMassFitter PRIVATE ${ROOT_LIBRARIES} ROOT::EG ROOT::RooFit ROOT::RooFitCore) diff --git a/PWGHF/D2H/Macros/HFInvMassFitter.cxx b/PWGHF/D2H/Macros/HFInvMassFitter.cxx index 9b1ac55cd31..fba3d7c67a1 100644 --- a/PWGHF/D2H/Macros/HFInvMassFitter.cxx +++ b/PWGHF/D2H/Macros/HFInvMassFitter.cxx @@ -16,35 +16,61 @@ /// \author Mingyu Zhang /// \author Xinye Peng /// \author Biao Zhang +/// \author Oleksii Lubynets #include "HFInvMassFitter.h" -#include -#include -#include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include using namespace RooFit; -using namespace std; ClassImp(HFInvMassFitter); HFInvMassFitter::HFInvMassFitter() : TNamed(), - mHistoInvMass(0x0), + mHistoInvMass(nullptr), mFitOption("L,E"), mMinMass(0), mMaxMass(5), mTypeOfBkgPdf(Expo), - mMassParticle(1.864), mTypeOfSgnPdf(SingleGaus), mTypeOfReflPdf(1), + mMassParticle(TDatabasePDG::Instance()->GetParticle("D0")->Mass()), mMass(1.865), + mMassLowLimit(0), + mMassUpLimit(0), + mMassReflLowLimit(0), + mMassReflUpLimit(0), mSecMass(1.969), - mMassErr(0.), mSigmaSgn(0.012), mSecSigma(0.006), mNSigmaForSidebands(4.), @@ -54,12 +80,6 @@ HFInvMassFitter::HFInvMassFitter() : TNamed(), mFixedMean(kFALSE), mBoundMean(kFALSE), mBoundReflMean(kFALSE), - mRooMeanSgn(0x0), - mRooSigmaSgn(0x0), - mMassLowLimit(0), - mMassUpLimit(0), - mMassReflLowLimit(0), - mMassReflUpLimit(0), mFixedSigma(kFALSE), mFixedSigmaDoubleGaus(kFALSE), mBoundSigma(kFALSE), @@ -74,97 +94,112 @@ HFInvMassFitter::HFInvMassFitter() : TNamed(), mEnableReflections(kFALSE), mRawYield(0), mRawYieldErr(0), + mRawYieldCounted(0), + mRawYieldCountedErr(0), mBkgYield(0), mBkgYieldErr(0), mSignificance(0), mSignificanceErr(0), - mChiSquareOverNdf(0), - mSgnPdf(0x0), - mBkgPdf(0x0), - mReflPdf(0x0), + mChiSquareOverNdfTotal(0), + mChiSquareOverNdfBkg(0), + mFixReflOverSgn(kFALSE), + mRooMeanSgn(nullptr), + mRooSigmaSgn(nullptr), + mSgnPdf(nullptr), + mBkgPdf(nullptr), + mReflPdf(nullptr), + mRooNSgn(nullptr), + mRooNBkg(nullptr), + mRooNRefl(nullptr), + mTotalPdf(nullptr), + mInvMassFrame(nullptr), + mReflFrame(nullptr), + mReflOnlyFrame(nullptr), + mResidualFrame(nullptr), + mResidualFrameForCalculation(nullptr), + mWorkspace(nullptr), mIntegralHisto(0), mIntegralBkg(0), mIntegralSgn(0), - mRooNSgn(0x0), - mRooNBkg(0x0), - mRooNRefl(0x0), - mTotalPdf(0x0), - mInvMassFrame(0x0), - mReflFrame(0x0), - mReflOnlyFrame(0x0), - mResidualFrame(0x0), - mWorkspace(0x0), - mHistoTemplateRefl(0x0) + mHistoTemplateRefl(nullptr), + mDrawBgPrefit(kFALSE), + mHighlightPeakRegion(kFALSE) { // default constructor } -HFInvMassFitter::HFInvMassFitter(const TH1F* histoToFit, Double_t minValue, Double_t maxValue, Int_t fitTypeBkg, Int_t fitTypeSgn) : TNamed(), - mHistoInvMass(0x0), - mFitOption("L,E"), - mMinMass(minValue), - mMaxMass(maxValue), - mTypeOfBkgPdf(fitTypeBkg), - mMassParticle(1.864), - mTypeOfSgnPdf(fitTypeSgn), - mTypeOfReflPdf(1), - mMass(1.865), - mSecMass(1.969), - mMassErr(0.), - mSigmaSgn(0.012), - mSecSigma(0.006), - mNSigmaForSidebands(3.), - mNSigmaForSgn(3.), - mSigmaSgnErr(0.), - mSigmaSgnDoubleGaus(0.012), - mFixedMean(kFALSE), - mBoundMean(kFALSE), - mBoundReflMean(kFALSE), - mRooMeanSgn(0x0), - mRooSigmaSgn(0x0), - mMassLowLimit(0), - mMassUpLimit(0), - mMassReflLowLimit(0), - mMassReflUpLimit(0), - mFixedSigma(kFALSE), - mFixedSigmaDoubleGaus(kFALSE), - mBoundSigma(kFALSE), - mSigmaValue(0.012), - mParamSgn(0.1), - mFracDoubleGaus(0.2), - mFixedRawYield(-1.), - mFixedFracDoubleGaus(kFALSE), - mRatioDoubleGausSigma(0.), - mFixedRatioDoubleGausSigma(kFALSE), - mReflOverSgn(0), - mEnableReflections(kFALSE), - mRawYield(0), - mRawYieldErr(0), - mBkgYield(0), - mBkgYieldErr(0), - mSignificance(0), - mSignificanceErr(0), - mChiSquareOverNdf(0), - mSgnPdf(0x0), - mBkgPdf(0x0), - mReflPdf(0x0), - mIntegralHisto(0), - mIntegralBkg(0), - mIntegralSgn(0), - mRooNSgn(0x0), - mRooNBkg(0x0), - mRooNRefl(0x0), - mTotalPdf(0x0), - mInvMassFrame(0x0), - mReflFrame(0x0), - mReflOnlyFrame(0x0), - mResidualFrame(0x0), - mWorkspace(0x0), - mHistoTemplateRefl(0x0) +HFInvMassFitter::HFInvMassFitter(const TH1* histoToFit, Double_t minValue, Double_t maxValue, Int_t fitTypeBkg, Int_t fitTypeSgn) : TNamed(), + mHistoInvMass(nullptr), + mFitOption("L,E"), + mMinMass(minValue), + mMaxMass(maxValue), + mTypeOfBkgPdf(fitTypeBkg), + mTypeOfSgnPdf(fitTypeSgn), + mTypeOfReflPdf(1), + mMassParticle(TDatabasePDG::Instance()->GetParticle("D0")->Mass()), + mMass(1.865), + mMassLowLimit(0), + mMassUpLimit(0), + mMassReflLowLimit(0), + mMassReflUpLimit(0), + mSecMass(1.969), + mSigmaSgn(0.012), + mSecSigma(0.006), + mNSigmaForSidebands(3.), + mNSigmaForSgn(3.), + mSigmaSgnErr(0.), + mSigmaSgnDoubleGaus(0.012), + mFixedMean(kFALSE), + mBoundMean(kFALSE), + mBoundReflMean(kFALSE), + mFixedSigma(kFALSE), + mFixedSigmaDoubleGaus(kFALSE), + mBoundSigma(kFALSE), + mSigmaValue(0.012), + mParamSgn(0.1), + mFracDoubleGaus(0.2), + mFixedRawYield(-1.), + mFixedFracDoubleGaus(kFALSE), + mRatioDoubleGausSigma(0.), + mFixedRatioDoubleGausSigma(kFALSE), + mReflOverSgn(0), + mEnableReflections(kFALSE), + mRawYield(0), + mRawYieldErr(0), + mRawYieldCounted(0), + mRawYieldCountedErr(0), + mBkgYield(0), + mBkgYieldErr(0), + mSignificance(0), + mSignificanceErr(0), + mChiSquareOverNdfTotal(0), + mChiSquareOverNdfBkg(0), + mFixReflOverSgn(kFALSE), + mRooMeanSgn(nullptr), + mRooSigmaSgn(nullptr), + mSgnPdf(nullptr), + mBkgPdf(nullptr), + mReflPdf(nullptr), + mRooNSgn(nullptr), + mRooNBkg(nullptr), + mRooNRefl(nullptr), + mTotalPdf(nullptr), + mInvMassFrame(nullptr), + mReflFrame(nullptr), + mReflOnlyFrame(nullptr), + mResidualFrame(nullptr), + mResidualFrameForCalculation(nullptr), + mWorkspace(nullptr), + mIntegralHisto(0), + mIntegralBkg(0), + mIntegralSgn(0), + mHistoTemplateRefl(nullptr), + mDrawBgPrefit(kFALSE), + mHighlightPeakRegion(kFALSE) { // standard constructor - mHistoInvMass = reinterpret_cast(histoToFit->Clone(histoToFit->GetTitle())); - mHistoInvMass->SetDirectory(0); + mHistoInvMass = dynamic_cast(histoToFit->Clone(histoToFit->GetTitle())); + mHistoInvMass->SetDirectory(nullptr); } HFInvMassFitter::~HFInvMassFitter() @@ -189,7 +224,7 @@ HFInvMassFitter::~HFInvMassFitter() delete mWorkspace; } -void HFInvMassFitter::doFit(Bool_t draw) +void HFInvMassFitter::doFit() { mIntegralHisto = mHistoInvMass->Integral(mHistoInvMass->FindBin(mMinMass), mHistoInvMass->FindBin(mMaxMass)); mWorkspace = new RooWorkspace("mWorkspace"); @@ -197,10 +232,10 @@ void HFInvMassFitter::doFit(Bool_t draw) RooRealVar* mass = mWorkspace->var("mass"); RooDataHist dataHistogram("dataHistogram", "data", *mass, Import(*mHistoInvMass)); - if (mTypeOfBkgPdf == 6) { // MC + if (mTypeOfBkgPdf == NoBkg) { // MC mass->setRange("signal", mMass - 3. * mSigmaSgn, mMass + 3. * mSigmaSgn); } else { - if (mTypeOfSgnPdf == 3) { // Second Peak fit range + if (mTypeOfSgnPdf == GausSec) { // Second Peak fit range mass->setRange("SBL", mMinMass, mMass - mNSigmaForSidebands * mSigmaSgn); mass->setRange("SBR", mMass + mNSigmaForSidebands * mSigmaSgn, mSecMass - mNSigmaForSidebands * mSecSigma); mass->setRange("SEC", mSecMass + mNSigmaForSidebands * mSecSigma, mMaxMass); @@ -221,8 +256,8 @@ void HFInvMassFitter::doFit(Bool_t draw) RooAbsPdf* bkgPdf = createBackgroundFitFunction(mWorkspace); // Create background pdf RooAbsPdf* sgnPdf = createSignalFitFunction(mWorkspace); // Create signal pdf - // fir MC or Data - if (mTypeOfBkgPdf == 6) { // MC + // fit MC or Data + if (mTypeOfBkgPdf == NoBkg) { // MC mRooNSgn = new RooRealVar("mRooNSig", "number of signal", 0.3 * mIntegralHisto, 0., 1.2 * mIntegralHisto); // signal yield mTotalPdf = new RooAddPdf("mMCFunc", "MC fit function", RooArgList(*sgnPdf), RooArgList(*mRooNSgn)); // create total pdf if (!strcmp(mFitOption.Data(), "Chi2")) { @@ -230,13 +265,13 @@ void HFInvMassFitter::doFit(Bool_t draw) } else { mTotalPdf->fitTo(dataHistogram, Range("signal")); } - RooAbsReal* signalIntergralMc = mTotalPdf->createIntegral(*mass, NormSet(*mass), Range("signal")); // sig yield from fit - mIntegralSgn = signalIntergralMc->getValV(); + RooAbsReal* signalIntegralMc = mTotalPdf->createIntegral(*mass, NormSet(*mass), Range("signal")); // sig yield from fit + mIntegralSgn = signalIntegralMc->getValV(); calculateSignal(mRawYield, mRawYieldErr); // calculate signal and signal error mTotalPdf->plotOn(mInvMassFrame, Name("Tot_c")); // plot total function } else { // data mBkgPdf = new RooAddPdf("mBkgPdf", "background fit function", RooArgList(*bkgPdf), RooArgList(*mRooNBkg)); - if (mTypeOfSgnPdf == 3) { // two peak fit + if (mTypeOfSgnPdf == GausSec) { // two peak fit if (!strcmp(mFitOption.Data(), "Chi2")) { mBkgPdf->chi2FitTo(dataHistogram, Range("SBL,SBR,SEC"), Save()); } else { @@ -249,13 +284,25 @@ void HFInvMassFitter::doFit(Bool_t draw) mBkgPdf->fitTo(dataHistogram, Range("SBL,SBR"), Save()); } } + // define the frame to evaluate background sidebands chi2 (bg pdf needs to be plotted within sideband ranges) + RooPlot* frameTemporary = mass->frame(Title(Form("%s_temp", mHistoInvMass->GetTitle()))); + dataHistogram.plotOn(frameTemporary, Name("data_for_bkgchi2")); + mBkgPdf->plotOn(frameTemporary, Range("SBL", "SBR"), Name("Bkg_sidebands")); + mChiSquareOverNdfBkg = frameTemporary->chiSquare("Bkg_sidebands", "data_for_bkgchi2"); // calculate reduced chi2 / NDF of background sidebands (pre-fit) + delete frameTemporary; + RooAbsPdf* mBkgPdfPrefit{nullptr}; + if (mDrawBgPrefit) { + mBkgPdfPrefit = dynamic_cast(mBkgPdf->Clone()); + mBkgPdfPrefit->plotOn(mInvMassFrame, Range("full"), Name("Bkg_c_prefit"), LineColor(kGray)); + delete mBkgPdfPrefit; + } // estimate signal yield RooAbsReal* bkgIntegral = mBkgPdf->createIntegral(*mass, NormSet(*mass), Range("bkg")); // bkg integral - mIntegralBkg = bkgIntegral->getValV(); + mIntegralBkg = bkgIntegral->getValV(); // fraction of BG's integral in "bkg" range out of that in "full" range (which is 1 by construction). Not an absolute value. Double_t estimatedSignal; - checkForSignal(estimatedSignal); - calculateBackground(mBkgYield, mBkgYieldErr); + checkForSignal(estimatedSignal); // SIG's absolute integral in "bkg" range + calculateBackground(mBkgYield, mBkgYieldErr); // BG's absolute integral in "bkg" range mRooNSgn = new RooRealVar("mNSgn", "number of signal", 0.3 * estimatedSignal, 0., 1.2 * estimatedSignal); // estimated signal yield if (mFixedRawYield > 0) { @@ -292,9 +339,9 @@ void HFInvMassFitter::doFit(Bool_t draw) mReflPdf = new RooAddPdf("mReflPdf", "reflection fit function", RooArgList(*reflPdf), RooArgList(*mRooNRefl)); RooAddPdf reflBkgPdf("reflBkgPdf", "reflBkgPdf", RooArgList(*bkgPdf, *reflPdf), RooArgList(*mRooNBkg, *mRooNRefl)); reflBkgPdf.plotOn(mInvMassFrame, Normalization(1.0, RooAbsReal::RelativeExpected), LineStyle(7), LineColor(kRed + 1), Name("ReflBkg_c")); - plotBkg(mTotalPdf); // plot bkg pdf in total pdf - plotRefl(mTotalPdf); // plot reflection in total pdf - mChiSquareOverNdf = mInvMassFrame->chiSquare("Tot_c", "data_c"); // calculate reduced chi2 / NDF + plotBkg(mTotalPdf); // plot bkg pdf in total pdf + plotRefl(mTotalPdf); // plot reflection in total pdf + mChiSquareOverNdfTotal = mInvMassFrame->chiSquare("Tot_c", "data_c"); // calculate reduced chi2 / NDF // plot residual distribution RooHist* residualHistogram = mInvMassFrame->residHist("data_c", "ReflBkg_c"); @@ -309,15 +356,14 @@ void HFInvMassFitter::doFit(Bool_t draw) mTotalPdf->fitTo(dataHistogram); } plotBkg(mTotalPdf); - mTotalPdf->plotOn(mInvMassFrame, Components("mReflFuncDoubleGaus"), Name("refl_c"), LineColor(kGreen)); mTotalPdf->plotOn(mInvMassFrame, Name("Tot_c"), LineColor(kBlue)); - mChiSquareOverNdf = mInvMassFrame->chiSquare("Tot_c", "data_c"); // calculate refuced chi2 / DNF + mSgnPdf->plotOn(mInvMassFrame, Normalization(1.0, RooAbsReal::RelativeExpected), DrawOption("F"), FillColor(TColor::GetColorTransparent(kBlue, 0.2)), VLines()); + mChiSquareOverNdfTotal = mInvMassFrame->chiSquare("Tot_c", "data_c"); // calculate reduced chi2 / DNF // plot residual distribution mResidualFrame = mass->frame(Title("Residual Distribution")); RooHist* residualHistogram = mInvMassFrame->residHist("data_c", "Bkg_c"); mResidualFrame->addPlotable(residualHistogram, "P"); mSgnPdf->plotOn(mResidualFrame, Normalization(1.0, RooAbsReal::RelativeExpected), LineColor(kBlue)); - mTotalPdf->plotOn(mResidualFrame, Components(*mSgnPdf), Normalization(1.0, RooAbsReal::RelativeExpected), LineColor(kBlue)); } mass->setRange("bkgForSignificance", mRooMeanSgn->getVal() - mNSigmaForSgn * mRooSigmaSgn->getVal(), mRooMeanSgn->getVal() + mNSigmaForSgn * mRooSigmaSgn->getVal()); bkgIntegral = mBkgPdf->createIntegral(*mass, NormSet(*mass), Range("bkgForSignificance")); @@ -327,51 +373,59 @@ void HFInvMassFitter::doFit(Bool_t draw) RooAbsReal* sgnIntegral = mSgnPdf->createIntegral(*mass, NormSet(*mass), Range("signal")); mIntegralSgn = sgnIntegral->getValV(); calculateSignal(mRawYield, mRawYieldErr); + countSignal(mRawYieldCounted, mRawYieldCountedErr); calculateSignificance(mSignificance, mSignificanceErr); } } -void HFInvMassFitter::fillWorkspace(RooWorkspace& workspace) +void HFInvMassFitter::fillWorkspace(RooWorkspace& workspace) const { // Declare observable variable - RooRealVar mass("mass", "mass", mMinMass, mMaxMass, "GeV/c"); + RooRealVar mass("mass", "mass", mMinMass, mMaxMass, "GeV/c^{2}"); // bkg expo RooRealVar tau("tau", "tau", -1, -5., 5.); RooAbsPdf* bkgFuncExpo = new RooExponential("bkgFuncExpo", "background fit function", mass, tau); workspace.import(*bkgFuncExpo); + delete bkgFuncExpo; // bkg poly1 - RooRealVar PolyParam0("PolyParam0", "Parameter of Poly function", 0.5, -5., 5.); - RooRealVar PolyParam1("PolyParam1", "Parameter of Poly function", 0.2, -5., 5.); - RooAbsPdf* bkgFuncPoly1 = new RooPolynomial("bkgFuncPoly1", "background fit function", mass, RooArgSet(PolyParam0, PolyParam1)); + RooRealVar polyParam0("polyParam0", "Parameter of Poly function", 0.5, -5., 5.); + RooRealVar polyParam1("polyParam1", "Parameter of Poly function", 0.2, -5., 5.); + RooAbsPdf* bkgFuncPoly1 = new RooPolynomial("bkgFuncPoly1", "background fit function", mass, RooArgSet(polyParam0, polyParam1)); workspace.import(*bkgFuncPoly1); + delete bkgFuncPoly1; // bkg poly2 - RooRealVar PolyParam2("PolyParam2", "Parameter of Poly function", 0.2, -5., 5.); - RooAbsPdf* bkgFuncPoly2 = new RooPolynomial("bkgFuncPoly2", "background fit function", mass, RooArgSet(PolyParam0, PolyParam1, PolyParam2)); + RooRealVar polyParam2("polyParam2", "Parameter of Poly function", 0.2, -5., 5.); + RooAbsPdf* bkgFuncPoly2 = new RooPolynomial("bkgFuncPoly2", "background fit function", mass, RooArgSet(polyParam0, polyParam1, polyParam2)); workspace.import(*bkgFuncPoly2); + delete bkgFuncPoly2; // bkg poly3 - RooRealVar PolyParam3("PolyParam3", "Parameter of Poly function", 0.2, -1., 1.); - RooAbsPdf* bkgFuncPoly3 = new RooPolynomial("bkgFuncPoly3", "background pdf", mass, RooArgSet(PolyParam0, PolyParam1, PolyParam2, PolyParam3)); + RooRealVar polyParam3("polyParam3", "Parameter of Poly function", 0.2, -1., 1.); + RooAbsPdf* bkgFuncPoly3 = new RooPolynomial("bkgFuncPoly3", "background pdf", mass, RooArgSet(polyParam0, polyParam1, polyParam2, polyParam3)); workspace.import(*bkgFuncPoly3); + delete bkgFuncPoly3; // bkg power law - RooRealVar PowParam1("PowParam1", "Parameter of Pow function", 0.13957); - RooRealVar PowParam2("PowParam2", "Parameter of Pow function", 1., -10, 10); - RooAbsPdf* bkgFuncPow = new RooGenericPdf("bkgFuncPow", "bkgFuncPow", "(mass-PowParam1)^PowParam2", RooArgSet(mass, PowParam1, PowParam2)); + RooRealVar powParam1("powParam1", "Parameter of Pow function", TDatabasePDG::Instance()->GetParticle("pi+")->Mass()); + RooRealVar powParam2("powParam2", "Parameter of Pow function", 1., -10, 10); + RooAbsPdf* bkgFuncPow = new RooGenericPdf("bkgFuncPow", "bkgFuncPow", "(mass-powParam1)^powParam2", RooArgSet(mass, powParam1, powParam2)); workspace.import(*bkgFuncPow); + delete bkgFuncPow; // pow * exp - RooRealVar PowExpoParam1("PowExpoParam1", "Parameter of PowExpo function", 1 / 2); - RooRealVar PowExpoParam2("PowExpoParam2", "Parameter of PowExpo function", 1, -10, 10); - RooRealVar massPi("massPi", "mass of pion", 0.13957); - RooFormulaVar PowExpoParam3("PowExpoParam3", "PowExpoParam1 + 1", RooArgList(PowExpoParam1)); - RooFormulaVar PowExpoParam4("PowExpoParam4", "1./PowExpoParam2", RooArgList(PowExpoParam2)); - RooAbsPdf* bkgFuncPowExpo = new RooGamma("bkgFuncPowExpo", "background pdf", mass, PowExpoParam3, PowExpoParam4, massPi); + RooRealVar powExpoParam1("powExpoParam1", "Parameter of PowExpo function", 1 / 2); + RooRealVar powExpoParam2("powExpoParam2", "Parameter of PowExpo function", 1, -10, 10); + RooRealVar massPi("massPi", "mass of pion", TDatabasePDG::Instance()->GetParticle("pi+")->Mass()); + RooFormulaVar powExpoParam3("powExpoParam3", "powExpoParam1 + 1", RooArgList(powExpoParam1)); + RooFormulaVar powExpoParam4("powExpoParam4", "1./powExpoParam2", RooArgList(powExpoParam2)); + RooAbsPdf* bkgFuncPowExpo = new RooGamma("bkgFuncPowExpo", "background pdf", mass, powExpoParam3, powExpoParam4, massPi); workspace.import(*bkgFuncPowExpo); + delete bkgFuncPowExpo; + // signal pdf - RooRealVar mean("mean", "mean for signal fit", mMass, 1.86, 1.87); + RooRealVar mean("mean", "mean for signal fit", mMass, 0, 5); if (mBoundMean) { mean.setMax(mMassUpLimit); mean.setMin(mMassLowLimit); } - // signal Guassian + // signal Gaussian if (mFixedMean) { mean.setVal(mMass); mean.setConstant(kTRUE); @@ -387,7 +441,8 @@ void HFInvMassFitter::fillWorkspace(RooWorkspace& workspace) } RooAbsPdf* sgnFuncGaus = new RooGaussian("sgnFuncGaus", "signal pdf", mass, mean, sigma); workspace.import(*sgnFuncGaus); - // signal double Gaussianaa + delete sgnFuncGaus; + // signal double Gaussian RooRealVar sigmaDoubleGaus("sigmaDoubleGaus", "sigma2Gaus", mSigmaSgn, mSigmaSgn - 0.01, mSigmaSgn + 0.01); if (mBoundSigma) { sigmaDoubleGaus.setMax(mSigmaSgn * (1 + mParamSgn)); @@ -410,6 +465,7 @@ void HFInvMassFitter::fillWorkspace(RooWorkspace& workspace) } RooAbsPdf* sgnFuncDoubleGaus = new RooAddPdf("sgnFuncDoubleGaus", "signal pdf", RooArgList(gaus1, gaus2), fracDoubleGaus); workspace.import(*sgnFuncDoubleGaus); + delete sgnFuncDoubleGaus; // double Gaussian ratio RooRealVar ratio("ratio", "ratio of sigma12", mRatioDoubleGausSigma, 0, 10); if (mFixedSigma) { @@ -434,6 +490,7 @@ void HFInvMassFitter::fillWorkspace(RooWorkspace& workspace) } RooAbsPdf* sgnFuncGausRatio = new RooAddPdf("sgnFuncGausRatio", "signal pdf", RooArgList(gausRatio1, gausRatio2), fracDoubleGausRatio); workspace.import(*sgnFuncGausRatio); + delete sgnFuncGausRatio; // double peak for Ds RooRealVar meanSec("meanSec", "mean for second peak fit", mSecMass, mMinMass, mMaxMass); RooRealVar sigmaSec("sigmaSec", "sigmaSec", mSecSigma, mSecSigma - 0.005, mSecSigma + 0.01); @@ -458,6 +515,7 @@ void HFInvMassFitter::fillWorkspace(RooWorkspace& workspace) RooRealVar fracSec("fracSec", "frac of two peak", 0.5, 0, 1.); RooAbsPdf* sgnFuncDoublePeak = new RooAddPdf("sgnFuncDoublePeak", "signal pdf", RooArgList(gausSec1, gausSec2), fracSec); workspace.import(*sgnFuncDoublePeak); + delete sgnFuncDoublePeak; // reflection Gaussian RooRealVar meanRefl("meanRefl", "mean for reflection", mMass, 0.0, mMass + 0.05); if (mBoundReflMean) { @@ -467,6 +525,7 @@ void HFInvMassFitter::fillWorkspace(RooWorkspace& workspace) RooRealVar sigmaRefl("sigmaRefl", "sigma for reflection", 0.012, 0, 0.25); RooAbsPdf* reflFuncGaus = new RooGaussian("reflFuncGaus", "reflection pdf", mass, meanRefl, sigmaRefl); workspace.import(*reflFuncGaus); + delete reflFuncGaus; // reflection double Gaussian RooRealVar meanReflDoubleGaus("meanReflDoubleGaus", "mean for reflection double gaussian", mMass, 0.0, mMass + 0.05); if (mBoundReflMean) { @@ -479,19 +538,22 @@ void HFInvMassFitter::fillWorkspace(RooWorkspace& workspace) RooRealVar fracRefl("fracRefl", "frac of two gauss", 0.5, 0, 1.); RooAbsPdf* reflFuncDoubleGaus = new RooAddPdf("reflFuncDoubleGaus", "reflection pdf", RooArgList(gausRefl1, gausRefl2), fracRefl); workspace.import(*reflFuncDoubleGaus); + delete reflFuncDoubleGaus; // reflection poly3 - RooRealVar PolyReflParam0("PolyReflParam0", "PolyReflParam0", 0.5, -1., 1.); - RooRealVar PolyReflParam1("PolyReflParam1", "PolyReflParam1", 0.2, -1., 1.); - RooRealVar PolyReflParam2("PolyReflParam2", "PolyReflParam2", 0.2, -1., 1.); - RooRealVar PolyReflParam3("PolyReflParam3", "PolyReflParam3", 0.2, -1., 1.); - RooAbsPdf* reflFuncPoly3 = new RooPolynomial("reflFuncPoly3", "reflection PDF", mass, RooArgSet(PolyReflParam0, PolyReflParam1, PolyReflParam2, PolyReflParam3)); + RooRealVar polyReflParam0("polyReflParam0", "polyReflParam0", 0.5, -1., 1.); + RooRealVar polyReflParam1("polyReflParam1", "polyReflParam1", 0.2, -1., 1.); + RooRealVar polyReflParam2("polyReflParam2", "polyReflParam2", 0.2, -1., 1.); + RooRealVar polyReflParam3("polyReflParam3", "polyReflParam3", 0.2, -1., 1.); + RooAbsPdf* reflFuncPoly3 = new RooPolynomial("reflFuncPoly3", "reflection PDF", mass, RooArgSet(polyReflParam0, polyReflParam1, polyReflParam2, polyReflParam3)); workspace.import(*reflFuncPoly3); + delete reflFuncPoly3; // reflection poly6 - RooRealVar PolyReflParam4("PolyReflParam4", "PolyReflParam4", 0.2, -1., 1.); - RooRealVar PolyReflParam5("PolyReflParam5", "PolyReflParam5", 0.2, -1., 1.); - RooRealVar PolyReflParam6("PolyReflParam6", "PolyReflParam6", 0.2, -1., 1.); - RooAbsPdf* reflFuncPoly6 = new RooPolynomial("reflFuncPoly6", "reflection pdf", mass, RooArgSet(PolyReflParam0, PolyReflParam1, PolyReflParam2, PolyReflParam3, PolyReflParam4, PolyReflParam5, PolyReflParam6)); + RooRealVar polyReflParam4("polyReflParam4", "polyReflParam4", 0.2, -1., 1.); + RooRealVar polyReflParam5("polyReflParam5", "polyReflParam5", 0.2, -1., 1.); + RooRealVar polyReflParam6("polyReflParam6", "polyReflParam6", 0.2, -1., 1.); + RooAbsPdf* reflFuncPoly6 = new RooPolynomial("reflFuncPoly6", "reflection pdf", mass, RooArgSet(polyReflParam0, polyReflParam1, polyReflParam2, polyReflParam3, polyReflParam4, polyReflParam5, polyReflParam6)); workspace.import(*reflFuncPoly6); + delete reflFuncPoly6; } // draw fit output void HFInvMassFitter::drawFit(TVirtualPad* pad, Int_t writeFitInfo) @@ -509,23 +571,33 @@ void HFInvMassFitter::drawFit(TVirtualPad* pad, Int_t writeFitInfo) textInfoRight->SetFillStyle(0); textInfoRight->SetTextColor(kBlue); textInfoLeft->AddText(Form("S = %.0f #pm %.0f ", mRawYield, mRawYieldErr)); - if (mTypeOfBkgPdf != 6) { + textInfoLeft->AddText(Form("S_{count} = %.0f #pm %.0f ", mRawYieldCounted, mRawYieldCountedErr)); + if (mTypeOfBkgPdf != NoBkg) { textInfoLeft->AddText(Form("B (%d#sigma) = %.0f #pm %.0f", mNSigmaForSidebands, mBkgYield, mBkgYieldErr)); textInfoLeft->AddText(Form("S/B (%d#sigma) = %.4g ", mNSigmaForSidebands, mRawYield / mBkgYield)); } if (mReflPdf) { textInfoLeft->AddText(Form("Refl/Sig = %.3f #pm %.3f ", mReflOverSgn, 0.0)); } - if (mTypeOfBkgPdf != 6) { + if (mTypeOfBkgPdf != NoBkg) { textInfoLeft->AddText(Form("Signif (%d#sigma) = %.1f #pm %.1f ", mNSigmaForSidebands, mSignificance, mSignificanceErr)); - textInfoLeft->AddText(Form("#chi^{2} / ndf = %.3f", mChiSquareOverNdf)); + textInfoLeft->AddText(Form("#chi^{2} / ndf = %.3f", mChiSquareOverNdfTotal)); } if (mFixedMean) { textInfoRight->AddText(Form("mean(fixed) = %.3f #pm %.3f", mRooMeanSgn->getVal(), mRooMeanSgn->getError())); } else { textInfoRight->AddText(Form("mean(free) = %.3f #pm %.3f", mRooMeanSgn->getVal(), mRooMeanSgn->getError())); } - if (mFixedSigma) { + if (mTypeOfSgnPdf == DoubleGaus) { + auto const& baseSigmaSgn = mWorkspace->var("sigma"); + if (mFixedSigmaDoubleGaus) { + textInfoRight->AddText(Form("sigma(fixed) = %.3f #pm %.3f", baseSigmaSgn->getVal(), baseSigmaSgn->getError())); + textInfoRight->AddText(Form("sigma 2(fixed) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); + } else { + textInfoRight->AddText(Form("sigma(free) = %.3f #pm %.3f", baseSigmaSgn->getVal(), baseSigmaSgn->getError())); + textInfoRight->AddText(Form("sigma 2(free) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); + } + } else if (mFixedSigma) { textInfoRight->AddText(Form("sigma(fixed) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); } else { textInfoRight->AddText(Form("sigma(free) = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); @@ -537,13 +609,14 @@ void HFInvMassFitter::drawFit(TVirtualPad* pad, Int_t writeFitInfo) mInvMassFrame->GetYaxis()->SetTitle(Form("%s", mHistoInvMass->GetYaxis()->GetTitle())); mInvMassFrame->GetXaxis()->SetTitle(Form("%s", mHistoInvMass->GetXaxis()->GetTitle())); mInvMassFrame->Draw(); + highlightPeakRegion(mInvMassFrame); if (mHistoTemplateRefl) { mReflFrame->Draw("same"); } } } -// draw redisual distribution on canvas +// draw residual distribution on canvas void HFInvMassFitter::drawResidual(TVirtualPad* pad) { pad->cd(); @@ -553,10 +626,39 @@ void HFInvMassFitter::drawResidual(TVirtualPad* pad) textInfo->SetFillStyle(0); textInfo->SetTextColor(kBlue); textInfo->AddText(Form("S = %.0f #pm %.0f ", mRawYield, mRawYieldErr)); + textInfo->AddText(Form("S_{count} = %.0f #pm %.0f ", mRawYieldCounted, mRawYieldCountedErr)); textInfo->AddText(Form("mean = %.3f #pm %.3f", mRooMeanSgn->getVal(), mRooMeanSgn->getError())); - textInfo->AddText(Form("sigma = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); + if (mTypeOfSgnPdf == DoubleGaus) { + auto const& baseSigmaSgn = mWorkspace->var("sigma"); + textInfo->AddText(Form("sigma = %.3f #pm %.3f", baseSigmaSgn->getVal(), baseSigmaSgn->getError())); + textInfo->AddText(Form("sigma 2 = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); + } else { + textInfo->AddText(Form("sigma = %.3f #pm %.3f", mRooSigmaSgn->getVal(), mRooSigmaSgn->getError())); + } mResidualFrame->addObject(textInfo); mResidualFrame->Draw(); + highlightPeakRegion(mResidualFrame); +} + +// draw peak region with vertical lines +void HFInvMassFitter::highlightPeakRegion(const RooPlot* plot, Color_t color, Width_t width, Style_t style) const +{ + if (!mHighlightPeakRegion) + return; + double yMin = plot->GetMinimum(); + double yMax = plot->GetMaximum(); + const Double_t mean = mRooMeanSgn->getVal(); + const Double_t sigma = mRooSigmaSgn->getVal(); + const Double_t minForSgn = mean - mNSigmaForSidebands * sigma; + const Double_t maxForSgn = mean + mNSigmaForSidebands * sigma; + TLine* leftLine = new TLine(minForSgn, yMin, minForSgn, yMax); + TLine* rightLine = new TLine(maxForSgn, yMin, maxForSgn, yMax); + for (const auto& line : std::array{leftLine, rightLine}) { + line->SetLineColor(color); + line->SetLineWidth(width); + line->SetLineStyle(style); + line->Draw(); + } } // draw reflection distribution on canvas @@ -567,6 +669,34 @@ void HFInvMassFitter::drawReflection(TVirtualPad* pad) mReflOnlyFrame->Draw(); } +// calculate signal yield via bin counting +void HFInvMassFitter::countSignal(Double_t& signal, Double_t& signalErr) const +{ + const Double_t mean = mRooMeanSgn->getVal(); + const Double_t sigma = mRooSigmaSgn->getVal(); + const Double_t minForSgn = mean - mNSigmaForSidebands * sigma; + const Double_t maxForSgn = mean + mNSigmaForSidebands * sigma; + const Int_t binForMinSgn = mHistoInvMass->FindBin(minForSgn); + const Int_t binForMaxSgn = mHistoInvMass->FindBin(maxForSgn); + const Double_t binForMinSgnUpperEdge = mHistoInvMass->GetBinLowEdge(binForMinSgn + 1); + const Double_t binForMaxSgnLowerEdge = mHistoInvMass->GetBinLowEdge(binForMaxSgn); + const Double_t binForMinSgnFraction = (binForMinSgnUpperEdge - minForSgn) / mHistoInvMass->GetBinWidth(binForMinSgn); + const Double_t binForMaxSgnFraction = (maxForSgn - binForMaxSgnLowerEdge) / mHistoInvMass->GetBinWidth(binForMaxSgn); + + Double_t sum = 0; + sum += mHistoInvMass->GetBinContent(binForMinSgn) * binForMinSgnFraction; + for (Int_t iBin = binForMinSgn + 1; iBin <= binForMaxSgn - 1; iBin++) { + sum += mHistoInvMass->GetBinContent(iBin); + } + sum += mHistoInvMass->GetBinContent(binForMaxSgn) * binForMaxSgnFraction; + + Double_t bkg, errBkg; + calculateBackground(bkg, errBkg); + + signal = sum - bkg; + signalErr = std::sqrt(sum + errBkg * errBkg); // sum error squared is equal to sum +} + // calculate signal yield void HFInvMassFitter::calculateSignal(Double_t& signal, Double_t& errSignal) const { @@ -591,11 +721,11 @@ void HFInvMassFitter::calculateSignificance(Double_t& significance, Double_t& er Double_t sgnErrSquare = errSignal * errSignal; Double_t bkgErrSquare = errBkg * errBkg; Double_t totalSgnBkg = signal + bkg; - significance = signal / sqrt(signal + bkg); - errSignificance = significance * sqrt((sgnErrSquare + bkgErrSquare) / (mNSigmaForSidebands * totalSgnBkg * totalSgnBkg) + (bkg / totalSgnBkg) * (sgnErrSquare / signal / signal)); + significance = signal / std::sqrt(signal + bkg); + errSignificance = significance * std::sqrt((sgnErrSquare + bkgErrSquare) / (mNSigmaForSidebands * totalSgnBkg * totalSgnBkg) + (bkg / totalSgnBkg) * (sgnErrSquare / signal / signal)); } -// estimate Signnal +// estimate Signal void HFInvMassFitter::checkForSignal(Double_t& estimatedSignal) { Double_t minForSgn = mMass - 4 * mSigmaSgn; @@ -613,42 +743,24 @@ void HFInvMassFitter::checkForSignal(Double_t& estimatedSignal) } // Create Background Fit Function -RooAbsPdf* HFInvMassFitter::createBackgroundFitFunction(RooWorkspace* workspace) +RooAbsPdf* HFInvMassFitter::createBackgroundFitFunction(RooWorkspace* workspace) const { - RooAbsPdf* bkgPdf; - switch (mTypeOfBkgPdf) { - case 0: // exponential - { - bkgPdf = workspace->pdf("bkgFuncExpo"); - } break; - case 1: // poly1 - { - bkgPdf = workspace->pdf("bkgFuncPoly1"); - } break; - case 2: { - bkgPdf = workspace->pdf("bkgFuncPoly2"); - } break; - case 3: { - bkgPdf = workspace->pdf("bkgFuncPow"); - } break; - case 4: { - bkgPdf = workspace->pdf("bkgFuncPowExpo"); - } break; - case 5: { - bkgPdf = workspace->pdf("bkgFuncPoly3"); - } break; - case 6: // MC - break; - default: - break; + RooAbsPdf* bkgPdf{nullptr}; + if (mTypeOfBkgPdf == NoBkg) { + return bkgPdf; } + if (mTypeOfBkgPdf < 0 || mTypeOfBkgPdf >= NTypesOfBkgPdf) { + throw std::runtime_error("createBackgroundFitFunction(): mTypeOfBkgPdf must be within [0; " + std::to_string(NTypesOfBkgPdf) + ") range"); + } + bkgPdf = workspace->pdf(namesOfBkgPdf.at(mTypeOfBkgPdf)); + return bkgPdf; } // Create Signal Fit Function RooAbsPdf* HFInvMassFitter::createSignalFitFunction(RooWorkspace* workspace) { - RooAbsPdf* sgnPdf; + RooAbsPdf* sgnPdf{nullptr}; switch (mTypeOfSgnPdf) { case 0: { sgnPdf = workspace->pdf("sgnFuncGaus"); @@ -677,76 +789,35 @@ RooAbsPdf* HFInvMassFitter::createSignalFitFunction(RooWorkspace* workspace) } // Create Reflection Fit Function -RooAbsPdf* HFInvMassFitter::createReflectionFitFunction(RooWorkspace* workspace) +RooAbsPdf* HFInvMassFitter::createReflectionFitFunction(RooWorkspace* workspace) const { - RooAbsPdf* reflPdf; - switch (mTypeOfReflPdf) { - case 0: { - reflPdf = workspace->pdf("reflFuncGaus"); - } break; - case 1: { - reflPdf = workspace->pdf("reflFuncDoubleGaus"); - } break; - case 2: { - reflPdf = workspace->pdf("reflFuncPoly3"); - } break; - case 3: { - reflPdf = workspace->pdf("reflFuncPoly6"); - } break; - default: - break; + if (mTypeOfReflPdf < 0 || mTypeOfReflPdf >= NTypesOfReflPdf) { + throw std::runtime_error("createReflectionFitFunction(): mTypeOfReflPdf must be within [0; " + std::to_string(NTypesOfReflPdf) + ") range"); } + RooAbsPdf* reflPdf = workspace->pdf(namesOfReflPdf.at(mTypeOfReflPdf)); + return reflPdf; } // Plot Bkg components of fTotFunction -void HFInvMassFitter::plotBkg(RooAbsPdf* pdf) +void HFInvMassFitter::plotBkg(RooAbsPdf* pdf, Color_t color) { - switch (mTypeOfBkgPdf) { - case 0: - pdf->plotOn(mInvMassFrame, Components("bkgFuncExpo"), Name("Bkg_c"), LineColor(kRed)); - break; - case 1: - pdf->plotOn(mInvMassFrame, Components("bkgFuncPoly1"), Name("Bkg_c"), LineColor(kRed)); - break; - case 2: - pdf->plotOn(mInvMassFrame, Components("bkgFuncPoly2"), Name("Bkg_c"), LineColor(kRed)); - break; - case 3: - pdf->plotOn(mInvMassFrame, Components("bkgFuncPow"), Name("Bkg_c"), LineColor(kRed)); - break; - case 4: - pdf->plotOn(mInvMassFrame, Components("bkgFuncPowExp"), Name("Bkg_c"), LineColor(kRed)); - break; - case 5: - pdf->plotOn(mInvMassFrame, Components("bkgFuncPoly3"), Name("Bkg_c"), LineColor(kRed)); - break; - case 6: - break; - default: - break; + if (mTypeOfBkgPdf == NoBkg) { + return; + } + if (mTypeOfBkgPdf < 0 || mTypeOfBkgPdf >= NTypesOfBkgPdf) { + throw std::runtime_error("plotBkg(): mTypeOfBkgPdf must be within [0; " + std::to_string(NTypesOfBkgPdf) + ") range"); } + pdf->plotOn(mInvMassFrame, Components(namesOfBkgPdf.at(mTypeOfBkgPdf).c_str()), Name("Bkg_c"), LineColor(color)); } // Plot Refl distribution on canvas void HFInvMassFitter::plotRefl(RooAbsPdf* pdf) { - switch (mTypeOfReflPdf) { - case 0: - pdf->plotOn(mInvMassFrame, Components("reflFuncGaus"), Name("Refl_c"), LineColor(kGreen)); - break; - case 1: - pdf->plotOn(mInvMassFrame, Components("reflFuncDoubleGaus"), Name("Refl_c"), LineColor(kGreen)); - break; - case 2: - pdf->plotOn(mInvMassFrame, Components("reflFuncPoly3"), Name("Refl_c"), LineColor(kGreen)); - break; - case 3: - pdf->plotOn(mInvMassFrame, Components("reflFuncPoly6"), Name("Refl_c"), LineColor(kGreen)); - break; - default: - break; + if (mTypeOfReflPdf < 0 || mTypeOfReflPdf >= NTypesOfReflPdf) { + throw std::runtime_error("plotRefl(): mTypeOfReflPdf must be within [0; " + std::to_string(NTypesOfReflPdf) + ") range"); } + pdf->plotOn(mInvMassFrame, Components(namesOfReflPdf.at(mTypeOfReflPdf).c_str()), Name("Refl_c"), LineColor(kGreen)); } // Fix reflection pdf @@ -774,30 +845,30 @@ void HFInvMassFitter::setReflFuncFixed() fracRefl->setConstant(kTRUE); } break; case 2: { - RooRealVar* PolyReflParam0 = mWorkspace->var("PolyReflParam0"); - RooRealVar* PolyReflParam1 = mWorkspace->var("PolyReflParam1"); - RooRealVar* PolyReflParam2 = mWorkspace->var("PolyReflParam2"); - RooRealVar* PolyReflParam3 = mWorkspace->var("PolyReflParam3"); - PolyReflParam0->setConstant(kTRUE); - PolyReflParam1->setConstant(kTRUE); - PolyReflParam2->setConstant(kTRUE); - PolyReflParam3->setConstant(kTRUE); + RooRealVar* polyReflParam0 = mWorkspace->var("polyReflParam0"); + RooRealVar* polyReflParam1 = mWorkspace->var("polyReflParam1"); + RooRealVar* polyReflParam2 = mWorkspace->var("polyReflParam2"); + RooRealVar* polyReflParam3 = mWorkspace->var("polyReflParam3"); + polyReflParam0->setConstant(kTRUE); + polyReflParam1->setConstant(kTRUE); + polyReflParam2->setConstant(kTRUE); + polyReflParam3->setConstant(kTRUE); } break; case 3: { - RooRealVar* PolyReflParam0 = mWorkspace->var("PolyReflParam0"); - RooRealVar* PolyReflParam1 = mWorkspace->var("PolyReflParam1"); - RooRealVar* PolyReflParam2 = mWorkspace->var("PolyReflParam2"); - RooRealVar* PolyReflParam3 = mWorkspace->var("PolyReflParam3"); - RooRealVar* PolyReflParam4 = mWorkspace->var("PolyReflParam4"); - RooRealVar* PolyReflParam5 = mWorkspace->var("PolyReflParam5"); - RooRealVar* PolyReflParam6 = mWorkspace->var("PolyReflParam6"); - PolyReflParam0->setConstant(kTRUE); - PolyReflParam1->setConstant(kTRUE); - PolyReflParam2->setConstant(kTRUE); - PolyReflParam3->setConstant(kTRUE); - PolyReflParam4->setConstant(kTRUE); - PolyReflParam5->setConstant(kTRUE); - PolyReflParam6->setConstant(kTRUE); + RooRealVar* polyReflParam0 = mWorkspace->var("polyReflParam0"); + RooRealVar* polyReflParam1 = mWorkspace->var("polyReflParam1"); + RooRealVar* polyReflParam2 = mWorkspace->var("polyReflParam2"); + RooRealVar* polyReflParam3 = mWorkspace->var("polyReflParam3"); + RooRealVar* polyReflParam4 = mWorkspace->var("polyReflParam4"); + RooRealVar* polyReflParam5 = mWorkspace->var("polyReflParam5"); + RooRealVar* polyReflParam6 = mWorkspace->var("polyReflParam6"); + polyReflParam0->setConstant(kTRUE); + polyReflParam1->setConstant(kTRUE); + polyReflParam2->setConstant(kTRUE); + polyReflParam3->setConstant(kTRUE); + polyReflParam4->setConstant(kTRUE); + polyReflParam5->setConstant(kTRUE); + polyReflParam6->setConstant(kTRUE); } break; default: break; diff --git a/PWGHF/D2H/Macros/HFInvMassFitter.h b/PWGHF/D2H/Macros/HFInvMassFitter.h index 410450de273..5ec95ebd473 100644 --- a/PWGHF/D2H/Macros/HFInvMassFitter.h +++ b/PWGHF/D2H/Macros/HFInvMassFitter.h @@ -16,30 +16,25 @@ /// \author Mingyu Zhang /// \author Xinye Peng /// \author Biao Zhang +/// \author Oleksii Lubynets #ifndef PWGHF_D2H_MACROS_HFINVMASSFITTER_H_ #define PWGHF_D2H_MACROS_HFINVMASSFITTER_H_ -#include // std::cout -#include // std::string - +#include +#include #include -#include -#include -#include #include -#include #include -#include #include -#include -#include -#include +#include -using namespace RooFit; +#include +#include -class TF1; -class TH1F; +#include +#include +#include class HFInvMassFitter : public TNamed { @@ -51,37 +46,42 @@ class HFInvMassFitter : public TNamed Pow = 3, PowExpo = 4, Poly3 = 5, - NoBkg = 6 + NoBkg = 6, + NTypesOfBkgPdf }; + std::vector namesOfBkgPdf{"bkgFuncExpo", "bkgFuncPoly1", "bkgFuncPoly2", "bkgFuncPow", "bkgFuncPowExpo", "bkgFuncPoly3"}; enum TypeOfSgnPdf { SingleGaus = 0, DoubleGaus = 1, DoubleGausSigmaRatioPar = 2, - GausSec = 3 + GausSec = 3, + NTypesOfSgnPdf }; enum TypeOfReflPdf { SingleGausRefl = 0, DoubleGausRefl = 1, Poly3Refl = 2, - Poly6Refl = 3 + Poly6Refl = 3, + NTypesOfReflPdf }; + std::vector namesOfReflPdf{"reflFuncGaus", "reflFuncDoubleGaus", "reflFuncPoly3", "reflFuncPoly6"}; HFInvMassFitter(); - HFInvMassFitter(const TH1F* histoToFit, Double_t minValue, Double_t maxValue, Int_t fitTypeBkg = Expo, Int_t fitTypeSgn = SingleGaus); + HFInvMassFitter(const TH1* histoToFit, Double_t minValue, Double_t maxValue, Int_t fitTypeBkg = Expo, Int_t fitTypeSgn = SingleGaus); ~HFInvMassFitter(); - void setHistogramForFit(const TH1F* histoToFit) + void setHistogramForFit(const TH1* histoToFit) { if (mHistoInvMass) { delete mHistoInvMass; } - mHistoInvMass = reinterpret_cast(histoToFit->Clone("mHistoInvMass")); + mHistoInvMass = static_cast(histoToFit->Clone("mHistoInvMass")); mHistoInvMass->SetDirectory(0); } void setUseLikelihoodFit() { mFitOption = "L,E"; } void setUseChi2Fit() { mFitOption = "Chi2"; } void setFitOption(TString opt) { mFitOption = opt.Data(); } - RooAbsPdf* createBackgroundFitFunction(RooWorkspace* w1); + RooAbsPdf* createBackgroundFitFunction(RooWorkspace* w1) const; RooAbsPdf* createSignalFitFunction(RooWorkspace* w1); - RooAbsPdf* createReflectionFitFunction(RooWorkspace* w1); + RooAbsPdf* createReflectionFitFunction(RooWorkspace* w1) const; void setFitRange(Double_t minValue, Double_t maxValue) { @@ -122,7 +122,7 @@ class HFInvMassFitter : public TNamed { if (mean < meanLowLimit || mean > meanUpLimit) { - std::cout << "Invalid Gaussian mean limmit!" << std::endl; + printf("Invalid Gaussian mean limit!\n"); } setInitialGaussianMean(mean); mMassLowLimit = meanLowLimit; @@ -133,7 +133,7 @@ class HFInvMassFitter : public TNamed { if (mean < meanLowLimit || mean > meanUpLimit) { - std::cout << "Invalid Gaussian mean limmit for reflection!" << std::endl; + printf("Invalid Gaussian mean limit for reflection!\n"); } setInitialGaussianMean(mean); mMassReflLowLimit = meanLowLimit; @@ -154,7 +154,7 @@ class HFInvMassFitter : public TNamed void setFixSecondGaussianSigma(Double_t sigma) { if (mTypeOfSgnPdf != DoubleGaus) { - std::cout << "Fit type should be 2Gaus!" << std::endl; + printf("Fit type should be 2Gaus!\n"); } setInitialSecondGaussianSigma(sigma); mFixedSigmaDoubleGaus = kTRUE; @@ -163,7 +163,7 @@ class HFInvMassFitter : public TNamed { if (mTypeOfSgnPdf != DoubleGaus && mTypeOfSgnPdf != DoubleGausSigmaRatioPar) { - std::cout << "Fit type should be 2Gaus or 2GausSigmaRatio!" << std::endl; + printf("Fit type should be 2Gaus or 2GausSigmaRatio!\n"); } setInitialFracDoubleGaus(frac); mFixedFracDoubleGaus = kTRUE; @@ -171,17 +171,17 @@ class HFInvMassFitter : public TNamed void setFixRatioToGausSigma(Double_t sigmaFrac) { if (mTypeOfSgnPdf != DoubleGausSigmaRatioPar) { - std::cout << "Fit type should be set to k2GausSigmaRatioPar!" << std::endl; + printf("Fit type should be set to k2GausSigmaRatioPar!\n"); } setInitialRatioDoubleGausSigma(sigmaFrac); mFixedRatioDoubleGausSigma = kTRUE; } void setFixSignalYield(Double_t yield) { mFixedRawYield = yield; } void setNumberOfSigmaForSidebands(Double_t numberOfSigma) { mNSigmaForSidebands = numberOfSigma; } - void plotBkg(RooAbsPdf* mFunc); + void plotBkg(RooAbsPdf* mFunc, Color_t color = kRed); void plotRefl(RooAbsPdf* mFunc); void setReflFuncFixed(); - void doFit(Bool_t draw = kTRUE); + void doFit(); void setInitialReflOverSgn(Double_t reflOverSgn) { mReflOverSgn = reflOverSgn; } void setFixReflOverSgn(Double_t reflOverSgn) { @@ -193,11 +193,16 @@ class HFInvMassFitter : public TNamed if (!histoRefl) { mEnableReflections = kFALSE; } - mHistoTemplateRefl = reinterpret_cast(histoRefl->Clone("mHistoTemplateRefl")); + mHistoTemplateRefl = static_cast(histoRefl->Clone("mHistoTemplateRefl")); } - Double_t getChiSquareOverNDF() const { return mChiSquareOverNdf; } + void setDrawBgPrefit(Bool_t value = true) { mDrawBgPrefit = value; } + void setHighlightPeakRegion(Bool_t value = true) { mHighlightPeakRegion = value; } + Double_t getChiSquareOverNDFTotal() const { return mChiSquareOverNdfTotal; } + Double_t getChiSquareOverNDFBkg() const { return mChiSquareOverNdfBkg; } Double_t getRawYield() const { return mRawYield; } Double_t getRawYieldError() const { return mRawYieldErr; } + Double_t getRawYieldCounted() const { return mRawYieldCounted; } + Double_t getRawYieldCountedError() const { return mRawYieldCountedErr; } Double_t getBkgYield() const { return mBkgYield; } Double_t getBkgYieldError() const { return mBkgYieldErr; } Double_t getSignificance() const { return mSignificance; } @@ -215,6 +220,7 @@ class HFInvMassFitter : public TNamed } } void calculateSignal(Double_t& signal, Double_t& signalErr) const; + void countSignal(Double_t& signal, Double_t& signalErr) const; void calculateBackground(Double_t& bkg, Double_t& bkgErr) const; void calculateSignificance(Double_t& significance, Double_t& significanceErr) const; void checkForSignal(Double_t& estimatedSignal); @@ -225,9 +231,10 @@ class HFInvMassFitter : public TNamed private: HFInvMassFitter(const HFInvMassFitter& source); HFInvMassFitter& operator=(const HFInvMassFitter& source); - void fillWorkspace(RooWorkspace& w); + void fillWorkspace(RooWorkspace& w) const; + void highlightPeakRegion(const RooPlot* plot, Color_t color = kGray + 1, Width_t width = 1, Style_t style = 2) const; - TH1F* mHistoInvMass; // histogram to fit + TH1* mHistoInvMass; // histogram to fit TString mFitOption; Double_t mMinMass; // lower mass limit Double_t mMaxMass; // upper mass limit @@ -241,14 +248,13 @@ class HFInvMassFitter : public TNamed Double_t mMassReflLowLimit; /// lower limit of the allowed mass range for reflection Double_t mMassReflUpLimit; /// upper limit of the allowed mass range for reflection Double_t mSecMass; /// Second peak mean value - Double_t mMassErr; /// uncertainty on signal gaussian mean value Double_t mSigmaSgn; /// signal gaussian sigma Double_t mSecSigma; /// Second peak gaussian sigma Int_t mNSigmaForSidebands; /// number of sigmas to veto the signal peak Int_t mNSigmaForSgn; /// number of sigmas to veto the signal peak Double_t mSigmaSgnErr; /// uncertainty on signal gaussian sigma Double_t mSigmaSgnDoubleGaus; /// signal 2gaussian sigma - Double_t mFixedMean; /// switch for fix mean of gaussian + Bool_t mFixedMean; /// switch for fix mean of gaussian Bool_t mBoundMean; /// switch for bound mean of guassian Bool_t mBoundReflMean; /// switch for bound mean of guassian for reflection Bool_t mFixedSigma; /// fix sigma or not @@ -265,11 +271,14 @@ class HFInvMassFitter : public TNamed Bool_t mEnableReflections; /// flag use/not use reflections Double_t mRawYield; /// signal gaussian integral Double_t mRawYieldErr; /// err on signal gaussian integral + Double_t mRawYieldCounted; /// signal gaussian integral evaluated via bin counting + Double_t mRawYieldCountedErr; /// err on signal gaussian integral evaluated via bin counting Double_t mBkgYield; /// background Double_t mBkgYieldErr; /// err on background Double_t mSignificance; /// significance Double_t mSignificanceErr; /// err on significance - Double_t mChiSquareOverNdf; /// chi2/ndf + Double_t mChiSquareOverNdfTotal; /// chi2/ndf of the total fit + Double_t mChiSquareOverNdfBkg; /// chi2/ndf of the background (sidebands) pre-fit Bool_t mFixReflOverSgn; /// switch for fix refl/signal RooRealVar* mRooMeanSgn; /// mean for gaussian of signal RooRealVar* mRooSigmaSgn; /// sigma for gaussian of signal @@ -284,13 +293,14 @@ class HFInvMassFitter : public TNamed RooPlot* mReflFrame; /// reflection frame RooPlot* mReflOnlyFrame; /// reflection frame plot on reflection only RooPlot* mResidualFrame; /// residual frame - RooPlot* mResidualFrameForCalulation; - RooRealVar* mass; /// mass - RooWorkspace* mWorkspace; /// workspace - Double_t mIntegralHisto; /// integral of histogram to fit - Double_t mIntegralBkg; /// integral of background fit function - Double_t mIntegralSgn; /// integral of signal fit function - TH1F* mHistoTemplateRefl; /// reflection histogram + RooPlot* mResidualFrameForCalculation; + RooWorkspace* mWorkspace; /// workspace + Double_t mIntegralHisto; /// integral of histogram to fit + Double_t mIntegralBkg; /// integral of background fit function + Double_t mIntegralSgn; /// integral of signal fit function + TH1* mHistoTemplateRefl; /// reflection histogram + Bool_t mDrawBgPrefit; /// draw background after fitting the sidebands + Bool_t mHighlightPeakRegion; /// draw vertical lines showing the peak region (usually +- 3 sigma) ClassDef(HFInvMassFitter, 1); }; diff --git a/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h b/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h new file mode 100644 index 00000000000..cc755de478f --- /dev/null +++ b/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h @@ -0,0 +1,31 @@ +// 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. + +/// \file HFInvMassFitterLinkDef.h +/// \brief HFInvMassFitter dictionary definition file +/// +/// \author Zhen Zhang +/// \author Mingyu Zhang +/// \author Xinye Peng +/// \author Biao Zhang +/// \author Oleksii Lubynets + +#ifndef PWGHF_D2H_MACROS_HFINVMASSFITTERLINKDEF_H_ +#define PWGHF_D2H_MACROS_HFINVMASSFITTERLINKDEF_H_ + +#ifdef __CINT__ +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ class HFInvMassFitter + ; +#endif + +#endif // PWGHF_D2H_MACROS_HFINVMASSFITTERLINKDEF_H_ diff --git a/PWGHF/D2H/Macros/README.md b/PWGHF/D2H/Macros/README.md new file mode 100644 index 00000000000..f65de110419 --- /dev/null +++ b/PWGHF/D2H/Macros/README.md @@ -0,0 +1,59 @@ +# Invariant-mass fitter +Invariant-mass fitter is implemented in the class `HFInvMassFitter` (`HFInvMassFitter.cxx/h` files), and its run is executed via `runMassFitter.C` macro. +Fitter is configured in `config_massfitter.json`.\ +The fitter is **not** a part of O2Physics source code. + +## Dependencies +1. ROOT +2. RapidJSON. Download the header-only (no compilation needed) RapidJSON library, see the link . + +If you have O2Physics compilation you do not need to fulfill these dependencies explicitly. + +## How to run +### As a ROOT macro +The `runMassFitter.C` can be compiled as ROOT macro. +```bash +cd path-to-o2physics-src/PWGHF/D2H/Macros +source path-to-root-install/bin/thisroot.sh +export ROOT_INCLUDE_PATH=$ROOT_INCLUDE_PATH:path-to-json-include +root -l -x -b -q "HFInvMassFitter.cxx" "runMassFitter.C(\"config_massfitter.json\")" +``` +If you have O2Physics compilation and enter into its environment there is no need to set environment variables (skip lines 2-3 above). + +### As a CMake project +It is also possible to compile the fitter as a CMake project or insert it into existing one if any. +Use the `CMakeLists_HFInvMassFitter.txt` (rename it into `CMakeLists.txt` before usage).\ +Compile the fitter with the following steps: +```bash +cd path-to-o2physics-src/PWGHF/D2H/Macros +mkdir build +cd build +source path-to-root-install/bin/thisroot.sh +cmake -DHFFITTER_RAPIDJSON_INCLUDE_DIRS=path-to-json-include ../ +make +``` +and run the fitter: +```bash +./runMassFitter ../config_massfitter.json +``` +### Directly from the terminal +Compile the fitter with the following steps: +```bash +cd path-to-o2physics-src/PWGHF/D2H/Macros +mkdir build +cd build +source path-to-root-install/bin/thisroot.sh + +# Generate ROOT dictionary: +rootcling -f G__HFInvMassFitter.cxx -c ../HFInvMassFitter.h ../HFInvMassFitterLinkDef.h + +# Compile source code: +g++ -fPIC -I$(root-config --incdir) -I path-to-json-include -c ../HFInvMassFitter.cxx ../runMassFitter.C G__HFInvMassFitter.cxx + +# Link the executable: +g++ -o runMassFitter HFInvMassFitter.o runMassFitter.o G__HFInvMassFitter.o $(root-config --libs) -lRooFit -lRooFitCore -lEG +``` +and run the fitter: +```bash +./runMassFitter ../config_massfitter.json +``` diff --git a/PWGHF/D2H/Macros/compute_fraction_cutvar.py b/PWGHF/D2H/Macros/compute_fraction_cutvar.py index 57182744893..35f751419fd 100644 --- a/PWGHF/D2H/Macros/compute_fraction_cutvar.py +++ b/PWGHF/D2H/Macros/compute_fraction_cutvar.py @@ -10,9 +10,11 @@ import argparse import json import os +import sys import numpy as np # pylint: disable=import-error import ROOT # pylint: disable=import-error +sys.path.insert(0, '..') from cut_variation import CutVarMinimiser from style_formatter import set_object_style @@ -25,6 +27,7 @@ def main(config): """ ROOT.gROOT.SetBatch(True) + ROOT.TH1.AddDirectory(False) with open(config, encoding="utf8") as fil: cfg = json.load(fil) @@ -32,22 +35,43 @@ def main(config): hist_rawy, hist_effp, hist_effnp = ([] for _ in range(3)) for filename_rawy, filename_eff in zip(cfg["rawyields"]["inputfiles"], cfg["efficiencies"]["inputfiles"]): infile_rawy = ROOT.TFile.Open(os.path.join(cfg["rawyields"]["inputdir"], filename_rawy)) - hist_rawy.append(infile_rawy.Get(cfg["rawyields"]["histoname"])) + hist_rawy_name = cfg["rawyields"]["histoname"] + hist_rawy.append(infile_rawy.Get(hist_rawy_name)) + if(hist_rawy[-1] is None): + sys.exit(f"Fatal error: Histogram with raw yield \"{hist_rawy_name}\" is absent. Exit.") hist_rawy[-1].SetDirectory(0) infile_rawy.Close() infile_eff = ROOT.TFile.Open(os.path.join(cfg["efficiencies"]["inputdir"], filename_eff)) - hist_effp.append(infile_eff.Get(cfg["efficiencies"]["histonames"]["prompt"])) - hist_effnp.append(infile_eff.Get(cfg["efficiencies"]["histonames"]["nonprompt"])) + hist_effp_name = cfg["efficiencies"]["histonames"]["prompt"] + hist_effnp_name = cfg["efficiencies"]["histonames"]["nonprompt"] + hist_effp.append(infile_eff.Get(hist_effp_name)) + hist_effnp.append(infile_eff.Get(hist_effnp_name)) + if(hist_effp[-1] is None): + sys.exit(f"Fatal error: Histogram with efficiency for prompt \"{hist_effp_name}\" is absent. Exit.") + if(hist_effnp[-1] is None): + sys.exit(f"Fatal error: Histogram with efficiency for nonprompt \"{hist_effnp}\" is absent. Exit.") hist_effp[-1].SetDirectory(0) hist_effnp[-1].SetDirectory(0) infile_eff.Close() + pt_bin_to_process = cfg.get("pt_bin_to_process", -1) + if not isinstance(pt_bin_to_process, int): + sys.exit("Fatal error: pt_bin_to_process must be an integer value. Exit.") + if (pt_bin_to_process != -1 and pt_bin_to_process < 1) or pt_bin_to_process > hist_rawy[0].GetNbinsX(): + sys.exit("Fatal error: pt_bin_to_process must be a positive value up to number of bins in raw yield histogram. Exit.") + if cfg["central_efficiency"]["computerawfrac"]: infile_name = os.path.join(cfg["central_efficiency"]["inputdir"], cfg["central_efficiency"]["inputfile"]) infile_central_eff = ROOT.TFile.Open(infile_name) - hist_central_effp = infile_central_eff.Get(cfg["central_efficiency"]["histonames"]["prompt"]) - hist_central_effnp = infile_central_eff.Get(cfg["central_efficiency"]["histonames"]["nonprompt"]) + hist_central_effp_name = cfg["central_efficiency"]["histonames"]["prompt"] + hist_central_effp = infile_central_eff.Get(hist_central_effp_name) + if(hist_central_effp is None): + sys.exit(f"Fatal error: Histogram with central efficiency for prompt \"{hist_central_effp_name}\" is absent. Exit.") + hist_central_effnp_name = cfg["central_efficiency"]["histonames"]["nonprompt"] + hist_central_effnp = infile_central_eff.Get(hist_central_effnp_name) + if(hist_central_effnp is None): + sys.exit(f"Fatal error: Histogram with central efficiency for nonprompt \"{hist_central_effnp_name}\" is absent. Exit.") hist_central_effp.SetDirectory(0) hist_central_effnp.SetDirectory(0) infile_central_eff.Close() @@ -59,12 +83,18 @@ def main(config): hist_corry_prompt = hist_rawy[0].Clone("hCorrYieldsPrompt") hist_corry_nonprompt = hist_rawy[0].Clone("hCorrYieldsNonPrompt") - hist_covariance = hist_rawy[0].Clone("hCovPromptNonPrompt") + hist_covariance_pnp = hist_rawy[0].Clone("hCovPromptNonPrompt") + hist_covariance_pp = hist_rawy[0].Clone("hCovPromptPrompt") + hist_covariance_npnp = hist_rawy[0].Clone("hCovNonPromptNonPrompt") hist_corrfrac_prompt = hist_rawy[0].Clone("hCorrFracPrompt") hist_corrfrac_nonprompt = hist_rawy[0].Clone("hCorrFracNonPrompt") + for histo in hist_corry_prompt, hist_corry_nonprompt, hist_covariance_pnp, hist_covariance_pp, hist_covariance_npnp, hist_corrfrac_prompt, hist_corrfrac_nonprompt: + histo.Reset() hist_corry_prompt.GetYaxis().SetTitle("corrected yields prompt") hist_corry_nonprompt.GetYaxis().SetTitle("corrected yields non-prompt") - hist_covariance.GetYaxis().SetTitle("#sigma(prompt, non-prompt)") + hist_covariance_pnp.GetYaxis().SetTitle("#sigma(prompt, non-prompt)") + hist_covariance_pp.GetYaxis().SetTitle("#sigma(prompt, prompt)") + hist_covariance_npnp.GetYaxis().SetTitle("#sigma(non-prompt, non-prompt)") hist_corrfrac_prompt.GetYaxis().SetTitle("corrected fraction prompt") hist_corrfrac_nonprompt.GetYaxis().SetTitle("corrected fraction non-prompt") set_object_style( @@ -79,7 +109,9 @@ def main(config): fillstyle=0, markerstyle=ROOT.kFullSquare, ) - set_object_style(hist_covariance) + set_object_style(hist_covariance_pnp) + set_object_style(hist_covariance_pp) + set_object_style(hist_covariance_npnp) set_object_style( hist_corrfrac_prompt, color=ROOT.kRed + 1, @@ -95,6 +127,8 @@ def main(config): if cfg["central_efficiency"]["computerawfrac"]: hist_frac_raw_prompt = hist_rawy[0].Clone("hRawFracPrompt") hist_frac_raw_nonprompt = hist_rawy[0].Clone("hRawFracNonPrompt") + for histo in hist_frac_raw_prompt, hist_frac_raw_nonprompt: + histo.Reset() hist_frac_raw_prompt.GetYaxis().SetTitle("raw fraction prompt") hist_frac_raw_nonprompt.GetYaxis().SetTitle("raw fraction non-prompt") set_object_style( @@ -111,94 +145,148 @@ def main(config): markerstyle=ROOT.kFullSquare, ) - output = ROOT.TFile(os.path.join(cfg["output"]["directory"], cfg["output"]["file"]), "recreate") + pt_bin_to_process_name_suffix = "" + if pt_bin_to_process != -1: + pt_bin_to_process_name_suffix = "_bin_" + str(pt_bin_to_process) + + output_name_template = cfg['output']['file'].replace(".root", "") + pt_bin_to_process_name_suffix + ".root" + output = ROOT.TFile(os.path.join(cfg["output"]["directory"], output_name_template), "recreate") n_sets = len(hist_rawy) + pt_axis_title = hist_rawy[0].GetXaxis().GetTitle() for ipt in range(hist_rawy[0].GetNbinsX()): + if pt_bin_to_process !=-1 and ipt+1 != pt_bin_to_process: + continue pt_min = hist_rawy[0].GetXaxis().GetBinLowEdge(ipt + 1) pt_max = hist_rawy[0].GetXaxis().GetBinUpEdge(ipt + 1) + print(f"\n\nINFO: processing pt range {ipt+1} from {pt_min} to {pt_max} {pt_axis_title}") rawy, effp, effnp, unc_rawy, unc_effp, unc_effnp = (np.zeros(n_sets) for _ in range(6)) for iset, (hrawy, heffp, heffnp) in enumerate(zip(hist_rawy, hist_effp, hist_effnp)): - rawy.itemset(iset, hrawy.GetBinContent(ipt + 1)) - effp.itemset(iset, heffp.GetBinContent(ipt + 1)) - effnp.itemset(iset, heffnp.GetBinContent(ipt + 1)) - unc_rawy.itemset(iset, hrawy.GetBinError(ipt + 1)) - unc_effp.itemset(iset, heffp.GetBinError(ipt + 1)) - unc_effnp.itemset(iset, heffnp.GetBinError(ipt + 1)) + rawy[iset] = hrawy.GetBinContent(ipt + 1) + effp[iset] = heffp.GetBinContent(ipt + 1) + effnp[iset] = heffnp.GetBinContent(ipt + 1) + unc_rawy[iset] = hrawy.GetBinError(ipt + 1) + unc_effp[iset] = heffp.GetBinError(ipt + 1) + unc_effnp[iset] = heffnp.GetBinError(ipt + 1) + + if cfg["minimisation"]["correlated"]: + if not (np.all(rawy[1:] > rawy[:-1]) or np.all(rawy[1:] < rawy[:-1])): + print("WARNING! main(): the raw yield vector is not monotonous. Check the input for stability.") + print(f"raw yield vector elements = {rawy}\n") + if not (np.all(unc_rawy[1:] > unc_rawy[:-1]) or np.all(unc_rawy[1:] < unc_rawy[:-1])): + print("WARNING! main(): the raw yield uncertainties vector is not monotonous. Check the input for stability.") + print(f"raw yield uncertainties vector elements = {unc_rawy}\n") minimiser = CutVarMinimiser(rawy, effp, effnp, unc_rawy, unc_effp, unc_effnp) - minimiser.minimise_system(cfg["minimisation"]["correlated"]) - - hist_corry_prompt.SetBinContent(ipt + 1, minimiser.get_prompt_yield_and_error()[0]) - hist_corry_prompt.SetBinError(ipt + 1, minimiser.get_prompt_yield_and_error()[1]) - hist_corry_nonprompt.SetBinContent(ipt + 1, minimiser.get_nonprompt_yield_and_error()[0]) - hist_corry_nonprompt.SetBinError(ipt + 1, minimiser.get_nonprompt_yield_and_error()[1]) - hist_covariance.SetBinContent(ipt + 1, minimiser.get_prompt_nonprompt_cov()) - hist_covariance.SetBinError(ipt + 1, 0) - corr_frac_prompt = minimiser.get_corr_prompt_fraction() - corr_frac_nonprompt = minimiser.get_corr_nonprompt_fraction() - hist_corrfrac_prompt.SetBinContent(ipt + 1, corr_frac_prompt[0]) - hist_corrfrac_prompt.SetBinError(ipt + 1, corr_frac_prompt[1]) - hist_corrfrac_nonprompt.SetBinContent(ipt + 1, corr_frac_nonprompt[0]) - hist_corrfrac_nonprompt.SetBinError(ipt + 1, corr_frac_nonprompt[1]) - if cfg["central_efficiency"]["computerawfrac"]: - raw_frac_prompt = minimiser.get_raw_prompt_fraction( - hist_central_effp.GetBinContent(ipt + 1), hist_central_effnp.GetBinContent(ipt + 1) - ) - raw_frac_nonprompt = minimiser.get_raw_nonprompt_fraction( - hist_central_effp.GetBinContent(ipt + 1), hist_central_effnp.GetBinContent(ipt + 1) - ) - hist_frac_raw_prompt.SetBinContent(ipt + 1, raw_frac_prompt[0]) - hist_frac_raw_prompt.SetBinError(ipt + 1, raw_frac_prompt[1]) - hist_frac_raw_nonprompt.SetBinContent(ipt + 1, raw_frac_nonprompt[0]) - hist_frac_raw_nonprompt.SetBinError(ipt + 1, raw_frac_nonprompt[1]) - - canv_rawy, histos_rawy, leg_r = minimiser.plot_result(f"_pt{pt_min:.0f}_{pt_max:.0f}") - output.cd() - canv_rawy.Write() - for _, hist in histos_rawy.items(): - hist.Write() - - canv_eff, histos_eff, leg_e = minimiser.plot_efficiencies(f"_pt{pt_min:.0f}_{pt_max:.0f}") - output.cd() - canv_eff.Write() - for _, hist in histos_eff.items(): - hist.Write() - - canv_frac, histos_frac, leg_f = minimiser.plot_fractions(f"_pt{pt_min:.0f}_{pt_max:.0f}") - output.cd() - canv_frac.Write() - for _, hist in histos_frac.items(): - hist.Write() - - canv_cov, histo_cov = minimiser.plot_cov_matrix(True, f"_pt{pt_min:.0f}_{pt_max:.0f}") - output.cd() - canv_cov.Write() - histo_cov.Write() - - output_name_rawy_pdf = f"Distr_{cfg['output']['file'].replace('.root', '.pdf')}" - output_name_eff_pdf = f"Eff_{cfg['output']['file'].replace('.root', '.pdf')}" - output_name_frac_pdf = f"Frac_{cfg['output']['file'].replace('.root', '.pdf')}" - output_name_covmat_pdf = f"CovMatrix_{cfg['output']['file'].replace('.root', '.pdf')}" - if ipt == 0: - canv_rawy.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_rawy_pdf)}[") - canv_eff.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_eff_pdf)}[") - canv_frac.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_frac_pdf)}[") - canv_cov.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_covmat_pdf)}[") - canv_rawy.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_rawy_pdf)}") - canv_eff.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_eff_pdf)}") - canv_frac.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_frac_pdf)}") - canv_cov.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_covmat_pdf)}") - if ipt == hist_rawy[0].GetNbinsX() - 1: - canv_rawy.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_rawy_pdf)}]") - canv_eff.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_eff_pdf)}]") - canv_frac.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_frac_pdf)}]") - canv_cov.SaveAs(f"{os.path.join(cfg['output']['directory'], output_name_covmat_pdf)}]") + status = minimiser.minimise_system(cfg["minimisation"]["correlated"]) + + if status: + hist_corry_prompt.SetBinContent(ipt + 1, minimiser.get_prompt_yield_and_error()[0]) + hist_corry_prompt.SetBinError(ipt + 1, minimiser.get_prompt_yield_and_error()[1]) + hist_corry_nonprompt.SetBinContent(ipt + 1, minimiser.get_nonprompt_yield_and_error()[0]) + hist_corry_nonprompt.SetBinError(ipt + 1, minimiser.get_nonprompt_yield_and_error()[1]) + hist_covariance_pnp.SetBinContent(ipt + 1, minimiser.get_prompt_nonprompt_cov()) + hist_covariance_pnp.SetBinError(ipt + 1, 0) + hist_covariance_pp.SetBinContent(ipt + 1, minimiser.get_prompt_prompt_cov()) + hist_covariance_pp.SetBinError(ipt + 1, 0) + hist_covariance_npnp.SetBinContent(ipt + 1, minimiser.get_nonprompt_nonprompt_cov()) + hist_covariance_npnp.SetBinError(ipt + 1, 0) + corr_frac_prompt = minimiser.get_corr_prompt_fraction() + corr_frac_nonprompt = minimiser.get_corr_nonprompt_fraction() + hist_corrfrac_prompt.SetBinContent(ipt + 1, corr_frac_prompt[0]) + hist_corrfrac_prompt.SetBinError(ipt + 1, corr_frac_prompt[1]) + hist_corrfrac_nonprompt.SetBinContent(ipt + 1, corr_frac_nonprompt[0]) + hist_corrfrac_nonprompt.SetBinError(ipt + 1, corr_frac_nonprompt[1]) + if cfg["central_efficiency"]["computerawfrac"]: + raw_frac_prompt = minimiser.get_raw_prompt_fraction( + hist_central_effp.GetBinContent(ipt + 1), hist_central_effnp.GetBinContent(ipt + 1) + ) + raw_frac_nonprompt = minimiser.get_raw_nonprompt_fraction( + hist_central_effp.GetBinContent(ipt + 1), hist_central_effnp.GetBinContent(ipt + 1) + ) + hist_frac_raw_prompt.SetBinContent(ipt + 1, raw_frac_prompt[0]) + hist_frac_raw_prompt.SetBinError(ipt + 1, raw_frac_prompt[1]) + hist_frac_raw_nonprompt.SetBinContent(ipt + 1, raw_frac_nonprompt[0]) + hist_frac_raw_nonprompt.SetBinError(ipt + 1, raw_frac_nonprompt[1]) + + hist_bin_title = f"bin # {ipt+1}; {pt_axis_title}#in ({pt_min}; {pt_max})" + + canv_rawy, histos_rawy, leg_r = minimiser.plot_result(f"_pt{pt_min}_{pt_max}", hist_bin_title) + output.cd() + canv_rawy.Write() + for _, hist in histos_rawy.items(): + hist.Write() + + canv_unc, histos_unc, leg_unc = minimiser.plot_uncertainties(f"_pt{pt_min}_{pt_max}", hist_bin_title) + output.cd() + canv_unc.Write() + for _, hist in histos_unc.items(): + hist.Write() + + canv_eff, histos_eff, leg_e = minimiser.plot_efficiencies(f"_pt{pt_min}_{pt_max}", hist_bin_title) + output.cd() + canv_eff.Write() + for _, hist in histos_eff.items(): + hist.Write() + + canv_frac, histos_frac, leg_f = minimiser.plot_fractions(f"_pt{pt_min}_{pt_max}", hist_bin_title) + output.cd() + canv_frac.Write() + for _, hist in histos_frac.items(): + hist.Write() + + canv_cov, histo_cov = minimiser.plot_cov_matrix(True, f"_pt{pt_min}_{pt_max}", hist_bin_title) + output.cd() + canv_cov.Write() + histo_cov.Write() + else: + print(f"Minimization for pT {pt_min}, {pt_max} not successful") + canv_rawy = ROOT.TCanvas("c_rawy_minimization_error", "Minimization error", 500, 500) + canv_eff = ROOT.TCanvas("c_eff_minimization_error", "Minimization error", 500, 500) + canv_frac = ROOT.TCanvas("c_frac_minimization_error", "Minimization error", 500, 500) + canv_cov = ROOT.TCanvas("c_conv_minimization_error", "Minimization error", 500, 500) + + canv_combined = ROOT.TCanvas(f"canv_combined_{ipt}", "", 1000, 1000) + canv_combined.Divide(2, 2) + canv_combined.cd(1) + canv_rawy.DrawClonePad() + canv_combined.cd(2) + canv_eff.DrawClonePad() + canv_combined.cd(3) + canv_frac.DrawClonePad() + canv_combined.cd(4) + canv_cov.DrawClonePad() + + output_name_template = output_name_template.replace('.root', '.pdf') + + output_name_rawy_pdf = f"Distr_{output_name_template}" + output_name_eff_pdf = f"Eff_{output_name_template}" + output_name_frac_pdf = f"Frac_{output_name_template}" + output_name_covmat_pdf = f"CovMatrix_{output_name_template}" + output_name_unc_pdf = f"Unc_{output_name_template}" + output_name_pdf = f"{output_name_template}" + + if hist_rawy[0].GetNbinsX() == 1 or pt_bin_to_process != -1: + print_bracket = "" + elif ipt == 0: + print_bracket = "(" + elif ipt == hist_rawy[0].GetNbinsX() - 1: + print_bracket = ")" + else: + print_bracket = "" + canv_rawy.Print(f"{os.path.join(cfg['output']['directory'], output_name_rawy_pdf)}{print_bracket}") + canv_eff.Print(f"{os.path.join(cfg['output']['directory'], output_name_eff_pdf)}{print_bracket}") + canv_frac.Print(f"{os.path.join(cfg['output']['directory'], output_name_frac_pdf)}{print_bracket}") + canv_cov.Print(f"{os.path.join(cfg['output']['directory'], output_name_covmat_pdf)}{print_bracket}") + canv_combined.Print(f"{os.path.join(cfg['output']['directory'], output_name_pdf)}{print_bracket}") + canv_unc.Print(f"{os.path.join(cfg['output']['directory'], output_name_unc_pdf)}{print_bracket}") output.cd() hist_corry_prompt.Write() hist_corry_nonprompt.Write() - hist_covariance.Write() + hist_covariance_pnp.Write() + hist_covariance_pp.Write() + hist_covariance_npnp.Write() hist_corrfrac_prompt.Write() hist_corrfrac_nonprompt.Write() if cfg["central_efficiency"]["computerawfrac"]: diff --git a/PWGHF/D2H/Macros/config_cutvar_example.json b/PWGHF/D2H/Macros/config_cutvar_example.json index 6ac80c747ad..20466b37044 100644 --- a/PWGHF/D2H/Macros/config_cutvar_example.json +++ b/PWGHF/D2H/Macros/config_cutvar_example.json @@ -70,4 +70,4 @@ "directory": ".", "file": "CutVarDplus_pp13TeV_MB.root" } -} \ No newline at end of file +} diff --git a/PWGHF/D2H/Macros/config_massfitter.json b/PWGHF/D2H/Macros/config_massfitter.json index 34404095510..43e67b76f5d 100644 --- a/PWGHF/D2H/Macros/config_massfitter.json +++ b/PWGHF/D2H/Macros/config_massfitter.json @@ -1,136 +1,147 @@ { - "IsMC": false, - "InFileName": "input file directory ", - "ReflFileName": "input reflection file directory", - "OutFileName": "output file directory", - "InputHistoName": [ - "name array of the input data histogram for fit", - "once the projection macro is ready", - "these names will no longer need to be input manually" - ], - "PromptHistoName": [ - "MC prompt histogram name array" - ], - "FDHistoName": [ - "MC FD histogram name array" - ], - "ReflHistoName": [ - "MC reflection histogram name array" - ], - "PromptSecPeakHistoName": [ - "MC prompt second peak histogram name array" - ], - "FDSecPeakHistoName": [ - "MC FD second peak histogram name array" - ], - "Particle": "D0", - "_Particles": [ - "Dplus", - "Ds", - "LcToPKPi", - "LcToPK0s", - "Dstar" - ], - "EnableRefl": true, - "FixSigma": false, - "SigmaFile": "", - "_SigmaFile": "fix sigma from file", - "FixSigmaManual": [ - 0.012, - 0.012, - 0.013, - 0.015, - 0.017, - 0.02 - ], - "_FixSigmaManual": "fix sigma mannually", - "FixMean": false, - "MeanFile": "", - "_MeanFile": "fix mean from file", - "PtMin": [ - 1.0, - 2.0, - 4.0, - 6.0, - 8.0, - 12.0 - ], - "PtMax": [ - 2.0, - 4.0, - 6.0, - 8.0, - 12.0, - 24.0 - ], - "MassMin": [ - 1.72, - 1.72, - 1.72, - 1.72, - 1.72, - 1.72 - ], - "MassMax": [ - 2.03, - 2.03, - 2.03, - 2.03, - 2.03, - 2.03 - ], - "Rebin": [ - 6, - 6, - 6, - 6, - 6, - 6 - ], - "InclSecPeak": false, - "SigmaSecPeak": "", - "SigmaFileSecPeak": "", - "SigmaMultFactorSecPeak": 1.0, - "FixSigmaToFirstPeak": false, - "UseLikelihood": true, - "_UseLikelihood": [ - "true: likelihood fit", - "false: chi2 fit" - ], - "BkgFunc": [ - 0, - 0, - 0, - 0, - 0, - 0 - ], - "_BkgFuncs": [ - "0 for Expo", - "1 for Poly1", - "2 for Poly2", - "3 for Pow", - "4 for PowEx", - "5 for Poly3", - "6 for NoBkg" - ], - "SgnFunc": [ - 0, - 0, - 0, - 0, - 0, - 0 - ], - "_SgnFuncs": [ - "0 for SingleGaus", - "1 for DoubleGaus", - "2 for DoubleGausSigmaRatioPar", - "3 for GausSec" - ], - "BoundMean": false, - "_BoundMean": [ - "false: Do not set limits on mean range", - "true: the mean is set to be between MassMin[i] and MassMax[i]" - ] + "IsMC": false, + "InFileName": "hMasses.root", + "_InFileName": "download example file here https://cernbox.cern.ch/s/uoWicuRAVGArDsV", + "ReflFileName": "", + "OutFileName": "mInvFits.root", + "InputHistoName": [ + "hMass_T_0.20_0.35", + "hMass_T_0.35_0.50", + "hMass_T_0.50_0.70", + "hMass_T_0.70_0.90", + "hMass_T_0.90_1.60" + ], + "PromptHistoName": [ + "MC prompt histogram name array" + ], + "FDHistoName": [ + "MC FD histogram name array" + ], + "ReflHistoName": [ + "MC reflection histogram name array" + ], + "PromptSecPeakHistoName": [ + "MC prompt second peak histogram name array" + ], + "FDSecPeakHistoName": [ + "MC FD second peak histogram name array" + ], + "Particle": "LcToPKPi", + "_Particles": [ + "Dplus", + "Ds", + "LcToPKPi", + "LcToPK0s", + "Dstar", + "XicToXiPiPi" + ], + "EnableRefl": false, + "FixSigma": false, + "SigmaFile": "", + "_SigmaFile": "fix sigma from file", + "FixSigmaManual": [ + 0, + 0, + 0, + 0, + 0 + ], + "_FixSigmaManual": "fix sigma manually", + "FixMean": false, + "MeanFile": "", + "_MeanFile": "fix mean from file", + "FixMeanManual": [ + 0, + 0, + 0, + 0, + 0 + ], + "_FixMeanManual": "fix mean mannually", + "FixSecondSigma": false, + "SecondSigmaFile": "", + "_SecondSigmaFile": "fix second sigma for double gauss from file", + "FixSecondSigmaManual": [ + 0, + 0, + 0, + 0, + 0 + ], + "_FixSecondSigmaManual": "fix second sigma for double gauss manually", + "SliceVarName": "T", + "SliceVarUnit": "ps", + "_SliceVarName, _SliceVarUnit": "e.g. pT, GeV/c or something else depending on user's needs", + "SliceVarMin": [ + 0.2, + 0.35, + 0.5, + 0.7, + 0.9 + ], + "SliceVarMax": [ + 0.35, + 0.5, + 0.7, + 0.9, + 1.6 + ], + "MassMin": [ + 2.12, + 2.12, + 2.12, + 2.12, + 2.12 + ], + "MassMax": [ + 2.42, + 2.42, + 2.42, + 2.42, + 2.42 + ], + "Rebin": [ + 4, + 4, + 4, + 4, + 4 + ], + "InclSecPeak": false, + "UseLikelihood": false, + "_UseLikelihood": [ + "true: likelihood fit", + "false: chi2 fit" + ], + "BkgFunc": [ + 2, + 2, + 2, + 2, + 2 + ], + "_BkgFuncs": [ + "0 for Expo", + "1 for Poly1", + "2 for Poly2", + "3 for Pow", + "4 for PowEx", + "5 for Poly3", + "6 for NoBkg" + ], + "SgnFunc": [ + 0, + 0, + 0, + 0, + 0 + ], + "_SgnFuncs": [ + "0 for SingleGaus", + "1 for DoubleGaus", + "2 for DoubleGausSigmaRatioPar", + "3 for GausSec" + ], + "drawBgPrefit": true, + "highlightPeakRegion": true } diff --git a/PWGHF/D2H/Macros/cut_variation.py b/PWGHF/D2H/Macros/cut_variation.py index 74292f5acd5..3d862589836 100644 --- a/PWGHF/D2H/Macros/cut_variation.py +++ b/PWGHF/D2H/Macros/cut_variation.py @@ -11,6 +11,7 @@ import numpy as np # pylint: disable=import-error import ROOT # pylint: disable=import-error +sys.path.insert(0, '..') from style_formatter import set_global_style, set_object_style @@ -109,9 +110,9 @@ def __initialise_objects(self): self.unc_frac_nonprompt = np.zeros(shape=self.n_sets) for i_set, (rawy, effp, effnp) in enumerate(zip(self.raw_yields, self.eff_prompt, self.eff_nonprompt)): - self.m_rawy.itemset(i_set, rawy) - self.m_eff.itemset((i_set, 0), effp) - self.m_eff.itemset((i_set, 1), effnp) + self.m_rawy[i_set] = rawy + self.m_eff[(i_set, 0)] = effp + self.m_eff[(i_set, 1)] = effnp # pylint: disable=too-many-locals def minimise_system(self, correlated=True, precision=1.0e-8, max_iterations=100): @@ -135,7 +136,7 @@ def minimise_system(self, correlated=True, precision=1.0e-8, max_iterations=100) self.m_eff = np.matrix(self.m_eff) m_corr_yields_old = np.zeros(shape=(2, 1)) - for _ in range(max_iterations): + for iteration in range(max_iterations): for i_row, (rw_unc_row, effp_unc_row, effnp_unc_row) in enumerate( zip(self.unc_raw_yields, self.unc_eff_prompt, self.unc_eff_nonprompt) ): @@ -164,15 +165,21 @@ def minimise_system(self, correlated=True, precision=1.0e-8, max_iterations=100) else: rho = 0.0 cov_row_col = rho * unc_row * unc_col - self.m_cov_sets.itemset((i_row, i_col), cov_row_col) + self.m_cov_sets[i_row, i_col] = cov_row_col self.m_cov_sets = np.matrix(self.m_cov_sets) - self.m_weights = np.linalg.inv(np.linalg.cholesky(self.m_cov_sets)) + try: + self.m_weights = np.linalg.inv(np.linalg.cholesky(self.m_cov_sets)) + except np.linalg.LinAlgError: + return False self.m_weights = self.m_weights.T * self.m_weights m_eff_tr = self.m_eff.T self.m_covariance = (m_eff_tr * self.m_weights) * self.m_eff - self.m_covariance = np.linalg.inv(np.linalg.cholesky(self.m_covariance)) + try: + self.m_covariance = np.linalg.inv(np.linalg.cholesky(self.m_covariance)) + except np.linalg.LinAlgError: + return False self.m_covariance = self.m_covariance.T * self.m_covariance self.m_corr_yields = self.m_covariance * (m_eff_tr * self.m_weights) * self.m_rawy @@ -188,6 +195,13 @@ def minimise_system(self, correlated=True, precision=1.0e-8, max_iterations=100) m_corr_yields_old = np.copy(self.m_corr_yields) + print(f"INFO: number of processed iterations = {iteration+1}\n") + if correlated: + m_cov_sets_diag = np.diag(self.m_cov_sets) + if not (np.all(m_cov_sets_diag[1:] > m_cov_sets_diag[:-1]) or np.all(m_cov_sets_diag[1:] < m_cov_sets_diag[:-1])): + print("WARNING! minimise_system(): the residual vector uncertainties elements are not monotonous. Check the input for stability.") + print(f"residual vector uncertainties elements = {np.sqrt(m_cov_sets_diag)}\n") + # chi2 self.chi_2 = float(np.transpose(self.m_res) * self.m_weights * self.m_res) @@ -210,10 +224,12 @@ def minimise_system(self, correlated=True, precision=1.0e-8, max_iterations=100) + der_fnp_np**2 * self.m_covariance.item(1, 1) + 2 * der_fnp_p * der_fnp_np * self.m_covariance.item(1, 0) ) - self.frac_prompt.itemset(i_set, rawyp / (rawyp + rawynp)) - self.frac_nonprompt.itemset(i_set, rawynp / (rawyp + rawynp)) - self.unc_frac_prompt.itemset(i_set, unc_fp) - self.unc_frac_nonprompt.itemset(i_set, unc_fnp) + self.frac_prompt[i_set] = rawyp / (rawyp + rawynp) + self.frac_nonprompt[i_set] = rawynp / (rawyp + rawynp) + self.unc_frac_prompt[i_set] = unc_fp + self.unc_frac_nonprompt[i_set] = unc_fnp + + return True def get_red_chi2(self): """ @@ -263,6 +279,30 @@ def get_prompt_nonprompt_cov(self): return self.m_covariance.item(1, 0) + def get_prompt_prompt_cov(self): + """ + Helper function to get covariance between prompt and prompt corrected yields + + Returns + ----------------------------------------------------- + - cov_p_np: float + covariance between prompt and prompt corrected yields + """ + + return self.m_covariance.item(0, 0) + + def get_nonprompt_nonprompt_cov(self): + """ + Helper function to get covariance between non-prompt and non-prompt corrected yields + + Returns + ----------------------------------------------------- + - cov_p_np: float + covariance between non-prompt and non-prompt corrected yields + """ + + return self.m_covariance.item(1, 1) + def get_raw_prompt_fraction(self, effacc_p, effacc_np): """ Helper function to get the raw prompt fraction given the efficiencies @@ -295,6 +335,49 @@ def get_raw_prompt_fraction(self, effacc_p, effacc_np): return f_p, f_p_unc + def get_raw_prompt_fraction_ext(self, corry_p, corry_np, unc_corry_p, + unc_corry_np, cov_p_np, effacc_p, effacc_np): + """ + Helper function to get the raw prompt fraction given the efficiencies + + Parameters + ----------------------------------------------------- + - corry_p: float + corrected yield for prompt signal + - corry_np: float + corrected yield for non-prompt signal + - unc_corry_np: float + uncertainty on corrected yield for prompt signal + - unc_corry_np: float + uncertainty on corrected yield for non-prompt signal + - cov_p_np: float + covariance between prompt and non-prompt signal + - effacc_p: float + eff x acc for prompt signal + - effacc_np: float + eff x acc for non-prompt signal + + Returns + ----------------------------------------------------- + - f_p, f_p_unc: (float, float) + raw prompt fraction with its uncertainty + """ + + rawy_p = effacc_p * corry_p + rawy_np = effacc_np * corry_np + f_p = rawy_p / (rawy_p + rawy_np) + + # derivatives of prompt fraction wrt corr yields + d_p = (effacc_p * (rawy_p + rawy_np) - effacc_p**2 * corry_p) / (rawy_p + rawy_np) ** 2 + d_np = -effacc_np * rawy_p / (rawy_p + rawy_np) ** 2 + f_p_unc = np.sqrt( + d_p**2 * unc_corry_p**2 + + d_np**2 * unc_corry_np**2 + + 2 * d_p * d_np * cov_p_np + ) + + return f_p, f_p_unc + def get_raw_nonprompt_fraction(self, effacc_p, effacc_np): """ Helper function to get the raw non-prompt fraction given the efficiencies @@ -318,6 +401,41 @@ def get_raw_nonprompt_fraction(self, effacc_p, effacc_np): return f_np, f_np_unc + def get_raw_nonprompt_fraction_ext(self, corry_p, corry_np, unc_corry_p, + unc_corry_np, cov_p_np, effacc_p, effacc_np): + """ + Helper function to get the raw non-prompt fraction given the efficiencies + + Parameters + ----------------------------------------------------- + - corry_p: float + corrected yield for prompt signal + - corry_np: float + corrected yield for non-prompt signal + - unc_corry_np: float + uncertainty on corrected yield for prompt signal + - unc_corry_np: float + uncertainty on corrected yield for non-prompt signal + - cov_p_np: float + covariance between prompt and non-prompt signal + - effacc_p: float + eff x acc for prompt signal + - effacc_np: float + eff x acc for non-prompt signal + + Returns + ----------------------------------------------------- + - f_np, f_np_unc: (float, float) + raw non-prompt fraction with its uncertainty + + """ + + f_p, f_np_unc = self.get_raw_prompt_fraction_ext(corry_p, corry_np, unc_corry_p, + unc_corry_np, cov_p_np, effacc_p, effacc_np) + f_np = 1 - f_p + + return f_np, f_np_unc + def get_corr_prompt_fraction(self): """ Helper function to get the corrected prompt fraction @@ -345,7 +463,7 @@ def get_corr_nonprompt_fraction(self): return self.get_raw_nonprompt_fraction(1.0, 1.0) # pylint: disable=no-member - def plot_result(self, suffix=""): + def plot_result(self, suffix="", title=""): """ Helper function to plot minimisation result as a function of cut set @@ -353,6 +471,8 @@ def plot_result(self, suffix=""): ----------------------------------------------------- - suffix: str suffix to be added in the name of the output objects + - title: str + title to be written at the top margin of the output objects Returns ----------------------------------------------------- @@ -365,7 +485,7 @@ def plot_result(self, suffix=""): needed otherwise it is destroyed """ - set_global_style(padleftmargin=0.16, padbottommargin=0.12, titleoffsety=1.6) + set_global_style(padleftmargin=0.16, padbottommargin=0.12, padtopmargin=0.075, titleoffsety=1.6) hist_raw_yield = ROOT.TH1F( f"hRawYieldVsCut{suffix}", @@ -435,7 +555,7 @@ def plot_result(self, suffix=""): hist_raw_yield.GetMaximum() * 1.2, ";cut set;raw yield", ) - leg = ROOT.TLegend(0.6, 0.65, 0.8, 0.9) + leg = ROOT.TLegend(0.6, 0.65, 0.8, 0.85) leg.SetBorderSize(0) leg.SetFillStyle(0) leg.SetTextSize(0.04) @@ -449,6 +569,9 @@ def plot_result(self, suffix=""): hist_raw_yield_prompt.Draw("histsame") hist_raw_yield_nonprompt.Draw("histsame") hist_raw_yield_sum.Draw("histsame") + tex = ROOT.TLatex() + tex.SetTextSize(0.04) + tex.DrawLatexNDC(0.05, 0.95, title) canvas.Modified() canvas.Update() @@ -461,7 +584,7 @@ def plot_result(self, suffix=""): return canvas, histos, leg - def plot_cov_matrix(self, correlated=True, suffix=""): + def plot_cov_matrix(self, correlated=True, suffix="", title=""): """ Helper function to plot covariance matrix @@ -471,6 +594,8 @@ def plot_cov_matrix(self, correlated=True, suffix=""): correlation between cut sets - suffix: str suffix to be added in the name of the output objects + - title: str + title to be written at the top margin of the output objects Returns ----------------------------------------------------- @@ -484,6 +609,7 @@ def plot_cov_matrix(self, correlated=True, suffix=""): padleftmargin=0.14, padbottommargin=0.12, padrightmargin=0.12, + padtopmargin = 0.075, palette=ROOT.kRainBow, ) @@ -513,12 +639,15 @@ def plot_cov_matrix(self, correlated=True, suffix=""): canvas = ROOT.TCanvas(f"cCorrMatrixCutSets{suffix}", "", 500, 500) hist_corr_matrix.Draw("colz") + tex = ROOT.TLatex() + tex.SetTextSize(0.04) + tex.DrawLatexNDC(0.05, 0.95, title) canvas.Modified() canvas.Update() return canvas, hist_corr_matrix - def plot_efficiencies(self, suffix=""): + def plot_efficiencies(self, suffix="", title=""): """ Helper function to plot efficiencies as a function of cut set @@ -526,6 +655,8 @@ def plot_efficiencies(self, suffix=""): ----------------------------------------------------- - suffix: str suffix to be added in the name of the output objects + - title: str + title to be written at the top margin of the output objects Returns ----------------------------------------------------- @@ -537,7 +668,7 @@ def plot_efficiencies(self, suffix=""): needed otherwise it is destroyed """ - set_global_style(padleftmargin=0.14, padbottommargin=0.12, titleoffset=1.2) + set_global_style(padleftmargin=0.14, padbottommargin=0.12, titleoffset=1.2, padtopmargin = 0.075) hist_eff_prompt = ROOT.TH1F( f"hEffPromptVsCut{suffix}", @@ -599,12 +730,15 @@ def plot_efficiencies(self, suffix=""): leg.AddEntry(hist_eff_prompt, "prompt", "pl") leg.AddEntry(hist_eff_nonprompt, "non-prompt", "pl") leg.Draw() + tex = ROOT.TLatex() + tex.SetTextSize(0.04) + tex.DrawLatexNDC(0.05, 0.95, title) canvas.Modified() canvas.Update() return canvas, histos, leg - def plot_fractions(self, suffix=""): + def plot_fractions(self, suffix="", title=""): """ Helper function to plot fractions as a function of cut set @@ -612,6 +746,8 @@ def plot_fractions(self, suffix=""): ----------------------------------------------------- - suffix: str suffix to be added in the name of the output objects + - title: str + title to be written at the top margin of the output objects Returns ----------------------------------------------------- @@ -623,7 +759,7 @@ def plot_fractions(self, suffix=""): needed otherwise it is destroyed """ - set_global_style(padleftmargin=0.14, padbottommargin=0.12, titleoffset=1.2) + set_global_style(padleftmargin=0.14, padbottommargin=0.12, titleoffset=1.2, padtopmargin = 0.075) hist_f_prompt = ROOT.TH1F( f"hFracPromptVsCut{suffix}", @@ -678,7 +814,91 @@ def plot_fractions(self, suffix=""): leg.AddEntry(hist_f_prompt, "prompt", "pl") leg.AddEntry(hist_f_nonprompt, "non-prompt", "pl") leg.Draw() + tex = ROOT.TLatex() + tex.SetTextSize(0.04) + tex.DrawLatexNDC(0.05, 0.95, title) canvas.Modified() canvas.Update() return canvas, histos, leg + + # pylint: disable=no-member + def plot_uncertainties(self, suffix="", title=""): + """ + Helper function to plot uncertainties as a function of cut set + + Parameters + ----------------------------------------------------- + - suffix: str + suffix to be added in the name of the output objects + - title: str + title to be written at the top margin of the output objects + + Returns + ----------------------------------------------------- + - canvas: ROOT.TCanvas + canvas with plot + - histos: dict + dictionary of ROOT.TH1F with uncertainties distributions for + raw yield and residual vector + - leg: ROOT.TLegend + needed otherwise it is destroyed + """ + + set_global_style(padleftmargin=0.16, padbottommargin=0.12, padtopmargin=0.075, titleoffsety=1.6) + + hist_raw_yield_unc = ROOT.TH1F( + f"hRawYieldUncVsCut{suffix}", + ";cut set;runc.", + self.n_sets, + -0.5, + self.n_sets - 0.5, + ) + + hist_residual_unc = ROOT.TH1F( + f"hResidualUncVsCut{suffix}", + ";cut set;unc.", + self.n_sets, + -0.5, + self.n_sets - 0.5, + ) + + m_cov_sets_diag = np.diag(self.m_cov_sets) + m_cov_sets_diag = np.sqrt(m_cov_sets_diag) + + for i_bin, (unc_rawy, unc_res) in enumerate(zip(self.unc_raw_yields, m_cov_sets_diag)): + hist_raw_yield_unc.SetBinContent(i_bin + 1, unc_rawy) + hist_residual_unc.SetBinContent(i_bin+1, unc_res) + + set_object_style(hist_raw_yield_unc, color=ROOT.kRed + 1, fillstyle=0) + set_object_style(hist_residual_unc, color=ROOT.kAzure + 4, fillstyle=0) + + canvas = ROOT.TCanvas(f"cUncVsCut{suffix}", "", 500, 500) + canvas.DrawFrame( + -0.5, + 0.0, + self.n_sets - 0.5, + hist_residual_unc.GetMaximum() * 1.2, + ";cut set;unc.", + ) + leg = ROOT.TLegend(0.6, 0.75, 0.8, 0.85) + leg.SetBorderSize(0) + leg.SetFillStyle(0) + leg.SetTextSize(0.04) + leg.AddEntry(hist_raw_yield_unc, "raw yield", "l") + leg.AddEntry(hist_residual_unc, "residual vector", "l") + leg.Draw() + hist_raw_yield_unc.Draw("histsame") + hist_residual_unc.Draw("histsame") + tex = ROOT.TLatex() + tex.SetTextSize(0.04) + tex.DrawLatexNDC(0.05, 0.95, title) + canvas.Modified() + canvas.Update() + + histos = { + "rawy": hist_raw_yield_unc, + "residual": hist_residual_unc, + } + + return canvas, histos, leg diff --git a/PWGHF/D2H/Macros/runMassFitter.C b/PWGHF/D2H/Macros/runMassFitter.C index 0c4c44f9ff7..e6cb569f4b0 100644 --- a/PWGHF/D2H/Macros/runMassFitter.C +++ b/PWGHF/D2H/Macros/runMassFitter.C @@ -16,31 +16,36 @@ /// \author Mingyu Zhang /// \author Xinye Peng /// \author Biao Zhang +/// \author Oleksii Lubynets #if !defined(__CINT__) || defined(__CLING__) #include "HFInvMassFitter.h" -#include // std::cout -#include // std::string -#include // std::vector - -#include -#include - // if .h file not found, please include your local rapidjson/document.h and rapidjson/filereadstream.h here +#include +#include +#include +#include + #include #include +#include // for fclose +#include +#include +#include // std::string +#include +#include // std::vector + #endif -using namespace std; using namespace rapidjson; -int runMassFitter(TString configFileName = "config_massfitter.json"); +int runMassFitter(const TString& configFileName = "config_massfitter.json"); template -void readArray(const Value& jsonArray, vector& output) +void readArray(const Value& jsonArray, std::vector& output) { for (auto it = jsonArray.Begin(); it != jsonArray.End(); it++) { auto value = it->template Get(); @@ -48,7 +53,7 @@ void readArray(const Value& jsonArray, vector& output) } } -void parseStringArray(const Value& jsonArray, vector& output) +void parseStringArray(const Value& jsonArray, std::vector& output) { size_t arrayLength = jsonArray.Size(); for (size_t i = 0; i < arrayLength; i++) { @@ -58,16 +63,15 @@ void parseStringArray(const Value& jsonArray, vector& output) } } -void divideCanvas(TCanvas* c, int nPtBins); -void setHistoStyle(TH1* histo, int color = kBlack, double markerSize = 1.); +void divideCanvas(TCanvas* c, int nSliceVarBins); +void setHistoStyle(TH1* histo, Color_t color = kBlack, Size_t markerSize = 1); -int runMassFitter(TString configFileName) +int runMassFitter(const TString& configFileName) { // load config FILE* configFile = fopen(configFileName.Data(), "r"); if (!configFile) { - cerr << "ERROR: Missing configuration json file: " << configFileName << endl; - return -1; + throw std::runtime_error("ERROR: Missing configuration json file: " + configFileName); } Document config; @@ -82,20 +86,24 @@ int runMassFitter(TString configFileName) TString outputFileName = config["OutFileName"].GetString(); TString particleName = config["Particle"].GetString(); - vector inputHistoName; - vector promptHistoName; - vector fdHistoName; - vector reflHistoName; - vector promptSecPeakHistoName; - vector fdSecPeakHistoName; - vector ptMin; - vector ptMax; - vector massMin; - vector massMax; - vector fixSigmaManual; - vector nRebin; - vector bkgFuncConfig; - vector sgnFuncConfig; + std::vector inputHistoName; + std::vector promptHistoName; + std::vector fdHistoName; + std::vector reflHistoName; + std::vector promptSecPeakHistoName; + std::vector fdSecPeakHistoName; + TString sliceVarName; + TString sliceVarUnit; + std::vector sliceVarMin; + std::vector sliceVarMax; + std::vector massMin; + std::vector massMax; + std::vector fixSigmaManual; + std::vector fixSecondSigmaManual; + std::vector fixMeanManual; + std::vector nRebin; + std::vector bkgFuncConfig; + std::vector sgnFuncConfig; const Value& inputHistoNameValue = config["InputHistoName"]; parseStringArray(inputHistoNameValue, inputHistoName); @@ -113,23 +121,34 @@ int runMassFitter(TString configFileName) parseStringArray(promptSecPeakHistoNameValue, promptSecPeakHistoName); const Value& fdSecPeakHistoNameValue = config["FDSecPeakHistoName"]; - parseStringArray(promptSecPeakHistoNameValue, promptSecPeakHistoName); + parseStringArray(fdSecPeakHistoNameValue, fdSecPeakHistoName); + + const bool fixSigma = config["FixSigma"].GetBool(); + const std::string sigmaFile = config["SigmaFile"].GetString(); - bool fixSigma = config["FixSigma"].GetBool(); - string sigmaFile = config["SigmaFile"].GetString(); - double sigmaMultFactor = - config["SigmaMultFactor"].GetDouble(); - bool fixMean = config["FixMean"].GetBool(); - string meanFile = config["MeanFile"].GetString(); + const bool fixMean = config["FixMean"].GetBool(); + const std::string meanFile = config["MeanFile"].GetString(); const Value& fixSigmaManualValue = config["FixSigmaManual"]; readArray(fixSigmaManualValue, fixSigmaManual); - const Value& ptMinValue = config["PtMin"]; - readArray(ptMinValue, ptMin); + const bool fixSecondSigma = config["FixSecondSigma"].GetBool(); + const std::string secondSigmaFile = config["SecondSigmaFile"].GetString(); - const Value& ptMaxValue = config["PtMax"]; - readArray(ptMaxValue, ptMax); + const Value& fixSecondSigmaManualValue = config["FixSecondSigmaManual"]; + readArray(fixSecondSigmaManualValue, fixSecondSigmaManual); + + const Value& fixMeanManualValue = config["FixMeanManual"]; + readArray(fixMeanManualValue, fixMeanManual); + + sliceVarName = config["SliceVarName"].GetString(); + sliceVarUnit = config["SliceVarUnit"].GetString(); + + const Value& sliceVarMinValue = config["SliceVarMin"]; + readArray(sliceVarMinValue, sliceVarMin); + + const Value& sliceVarMaxValue = config["SliceVarMax"]; + readArray(sliceVarMaxValue, sliceVarMax); const Value& massMinValue = config["MassMin"]; readArray(massMinValue, massMin); @@ -141,13 +160,6 @@ int runMassFitter(TString configFileName) readArray(rebinValue, nRebin); bool includeSecPeak = config["InclSecPeak"].GetBool(); - string sigmaSecPeak = config["SigmaSecPeak"].GetString(); - string sigmaFileSecPeak = - config["SigmaFileSecPeak"].GetString(); - double sigmaMultFactorSecPeak = - config["SigmaMultFactorSecPeak"].GetDouble(); - bool fixSigmaToFirstPeak = - config["FixSigmaToFirstPeak"].GetBool(); bool useLikelihood = config["UseLikelihood"].GetBool(); const Value& bkgFuncValue = config["BkgFunc"]; @@ -156,71 +168,44 @@ int runMassFitter(TString configFileName) const Value& sgnFuncValue = config["SgnFunc"]; readArray(sgnFuncValue, sgnFuncConfig); - bool fixSigmaRatio = config["FixSigmaRatio"].GetBool(); - TString sigmaRatioFile = config["SigmaRatioFile"].GetString(); - bool boundMean = config["BoundMean"].GetBool(); - bool enableRefl = config["EnableRefl"].GetBool(); - - const unsigned int nPtBins = ptMin.size(); - int bkgFunc[nPtBins], sgnFunc[nPtBins]; - double ptLimits[nPtBins + 1]; - - for (unsigned int iPt = 0; iPt < nPtBins; iPt++) { - ptLimits[iPt] = ptMin[iPt]; - ptLimits[iPt + 1] = ptMax[iPt]; - - if (bkgFuncConfig[iPt] == 0) { - bkgFunc[iPt] = HFInvMassFitter::Expo; - } else if (bkgFuncConfig[iPt] == 1) { - bkgFunc[iPt] = HFInvMassFitter::Poly1; - } else if (bkgFuncConfig[iPt] == 2) { - bkgFunc[iPt] = HFInvMassFitter::Poly2; - } else if (bkgFuncConfig[iPt] == 3) { - bkgFunc[iPt] = HFInvMassFitter::Pow; - } else if (bkgFuncConfig[iPt] == 4) { - bkgFunc[iPt] = HFInvMassFitter::PowExpo; - } else if (bkgFuncConfig[iPt] == 5) { - bkgFunc[iPt] = HFInvMassFitter::Poly3; - } else if (bkgFuncConfig[iPt] == 6) { - bkgFunc[iPt] = HFInvMassFitter::NoBkg; - } else { - cerr << "ERROR: only Expo, Poly1, Poly2, Pow and PowEx background " - "functions supported! Exit" - << endl; - return -1; + const bool enableRefl = config["EnableRefl"].GetBool(); + + const bool drawBgPrefit = config["drawBgPrefit"].GetBool(); + const bool highlightPeakRegion = config["highlightPeakRegion"].GetBool(); + + const unsigned int nSliceVarBins = sliceVarMin.size(); + std::vector bkgFunc(nSliceVarBins); + std::vector sgnFunc(nSliceVarBins); + std::vector sliceVarLimits(nSliceVarBins + 1); + + for (unsigned int iSliceVar = 0; iSliceVar < nSliceVarBins; iSliceVar++) { + sliceVarLimits[iSliceVar] = sliceVarMin[iSliceVar]; + sliceVarLimits[iSliceVar + 1] = sliceVarMax[iSliceVar]; + + if (bkgFuncConfig[iSliceVar] < 0 || bkgFuncConfig[iSliceVar] >= HFInvMassFitter::NTypesOfBkgPdf) { + throw std::runtime_error("ERROR: only Expo, Poly1, Poly2, Pow and PowEx background functions supported! Exit"); } + bkgFunc[iSliceVar] = bkgFuncConfig[iSliceVar]; - if (sgnFuncConfig[iPt] == 0) { - sgnFunc[iPt] = HFInvMassFitter::SingleGaus; - } else if (sgnFuncConfig[iPt] == 1) { - sgnFunc[iPt] = HFInvMassFitter::DoubleGaus; - } else if (sgnFuncConfig[iPt] == 2) { - sgnFunc[iPt] = HFInvMassFitter::DoubleGausSigmaRatioPar; - } else { - cerr << "ERROR: only SingleGaus, DoubleGaus and DoubleGausSigmaRatioPar signal " - "functions supported! Exit" - << endl; - return -1; + if (sgnFuncConfig[iSliceVar] < 0 || sgnFuncConfig[iSliceVar] >= HFInvMassFitter::NTypesOfSgnPdf) { + throw std::runtime_error("ERROR: only SingleGaus, DoubleGaus and DoubleGausSigmaRatioPar signal functions supported! Exit"); } + sgnFunc[iSliceVar] = sgnFuncConfig[iSliceVar]; } - TString massAxisTitle = ""; - if (particleName == "Dplus") { - massAxisTitle = "#it{M}(K#pi#pi) (GeV/#it{c}^{2})"; - } else if (particleName == "D0") { - massAxisTitle = "#it{M}(K#pi) (GeV/#it{c}^{2})"; - } else if (particleName == "Ds") { - massAxisTitle = "#it{M}(KK#pi) (GeV/#it{c}^{2})"; - } else if (particleName == "LcToPKPi") { - massAxisTitle = "#it{M}(pK#pi) (GeV/#it{c}^{2})"; - } else if (particleName == "LcToPK0s") { - massAxisTitle = "#it{M}(pK^{0}_{s}) (GeV/#it{c}^{2})"; - } else if (particleName == "Dstar") { - massAxisTitle = "#it{M}(pi^{+}) (GeV/#it{c}^{2})"; - } else { - cerr << "ERROR: only Dplus, D0, Ds, LcToPKPi, LcToPK0s and Dstar particles supported! Exit" << endl; - return -1; + std::map> particles{ + {"Dplus", {"K#pi#pi", "D+"}}, + {"D0", {"K#pi", "D0"}}, + {"Ds", {"KK#pi", "D_s+"}}, + {"LcToPKPi", {"pK#pi", "Lambda_c+"}}, + {"LcToPK0s", {"pK^{0}_{s}", "Lambda_c+"}}, + {"Dstar", {"D^{0}pi^{+}", "D*+"}}, + {"XicToXiPiPi", {"#Xi#pi#pi", "Xi_c+"}}}; + if (particles.find(particleName.Data()) == particles.end()) { + throw std::runtime_error("ERROR: only Dplus, D0, Ds, LcToPKPi, LcToPK0s, Dstar and XicToXiPiPi particles supported! Exit"); } + const TString massAxisTitle = "#it{M}(" + particles[particleName.Data()].first + ") (GeV/#it{c}^{2})"; + const double massPDG = TDatabasePDG::Instance()->GetParticle(particles[particleName.Data()].second.c_str())->Mass(); // load inv-mass histograms auto inputFile = TFile::Open(inputFileName.Data()); @@ -228,7 +213,7 @@ int runMassFitter(TString configFileName) return -1; } - TFile* inputFileRefl = NULL; + TFile* inputFileRefl = nullptr; if (enableRefl) { inputFileRefl = TFile::Open(reflFileName.Data()); if (!inputFileRefl || !inputFileRefl->IsOpen()) { @@ -236,110 +221,71 @@ int runMassFitter(TString configFileName) } } - TH1F* hMassSgn[nPtBins]; - TH1F* hMassRefl[nPtBins]; - TH1F* hMass[nPtBins]; + std::vector hMassSgn(nSliceVarBins); + std::vector hMassRefl(nSliceVarBins); + std::vector hMass(nSliceVarBins); - for (unsigned int iPt = 0; iPt < nPtBins; iPt++) { + for (unsigned int iSliceVar = 0; iSliceVar < nSliceVarBins; iSliceVar++) { if (!isMc) { - hMass[iPt] = static_cast(inputFile->Get(inputHistoName[iPt].data())); + hMass[iSliceVar] = inputFile->Get(inputHistoName[iSliceVar].data()); if (enableRefl) { - hMassRefl[iPt] = static_cast(inputFileRefl->Get(reflHistoName[iPt].data())); - hMassSgn[iPt] = static_cast(inputFileRefl->Get(fdHistoName[iPt].data())); - hMassSgn[iPt]->Add(static_cast(inputFileRefl->Get(promptHistoName[iPt].data()))); - if (!hMassRefl[iPt]) { - cerr << "ERROR: MC reflection histogram not found! Exit!" << endl; - return -1; + hMassRefl[iSliceVar] = inputFileRefl->Get(reflHistoName[iSliceVar].data()); + hMassSgn[iSliceVar] = inputFileRefl->Get(fdHistoName[iSliceVar].data()); + hMassSgn[iSliceVar]->Add(inputFileRefl->Get(promptHistoName[iSliceVar].data())); + if (!hMassRefl[iSliceVar]) { + throw std::runtime_error("ERROR: MC reflection histogram not found! Exit!"); } - if (!hMassSgn[iPt]) { - cerr << "ERROR: MC prompt or FD histogram not found! Exit!" << endl; - return -1; + if (!hMassSgn[iSliceVar]) { + throw std::runtime_error("ERROR: MC prompt or FD histogram not found! Exit!"); } } } else { - hMass[iPt] = static_cast(inputFile->Get(promptHistoName[iPt].data())); - hMass[iPt]->Add(static_cast(inputFile->Get(fdHistoName[iPt].data()))); + hMass[iSliceVar] = inputFile->Get(promptHistoName[iSliceVar].data()); + hMass[iSliceVar]->Add(inputFile->Get(fdHistoName[iSliceVar].data())); if (includeSecPeak) { - hMass[iPt]->Add(static_cast(inputFile->Get(promptSecPeakHistoName[iPt].data()))); - hMass[iPt]->Add(static_cast(inputFile->Get(fdSecPeakHistoName[iPt].data()))); + hMass[iSliceVar]->Add(inputFile->Get(promptSecPeakHistoName[iSliceVar].data())); + hMass[iSliceVar]->Add(inputFile->Get(fdSecPeakHistoName[iSliceVar].data())); } } - if (!hMass[iPt]) { - cerr << "ERROR: input histogram for fit not found! Exit!" << endl; - return -1; + if (!hMass[iSliceVar]) { + throw std::runtime_error("ERROR: input histogram for fit not found! Exit!"); } - hMass[iPt]->SetDirectory(0); + hMass[iSliceVar]->SetDirectory(nullptr); } inputFile->Close(); // define output histos - auto hRawYields = new TH1D("hRawYields", ";#it{p}_{T} (GeV/#it{c});raw yield", - nPtBins, ptLimits); + auto hRawYieldsSignal = new TH1D("hRawYieldsSignal", ";" + sliceVarName + "(" + sliceVarUnit + ");raw yield", + nSliceVarBins, sliceVarLimits.data()); + auto hRawYieldsSignalCounted = new TH1D("hRawYieldsSignalCounted", ";" + sliceVarName + "(" + sliceVarUnit + ");raw yield via bin count", + nSliceVarBins, sliceVarLimits.data()); auto hRawYieldsSigma = new TH1D( - "hRawYieldsSigma", ";#it{p}_{T} (GeV/#it{c});width (GeV/#it{c}^{2})", - nPtBins, ptLimits); - auto hRawYieldsSigmaRatio = new TH1D( - "hRawYieldsSigmaRatio", - ";#it{p}_{T} (GeV/#it{c});ratio #sigma_{1}/#sigma_{2}", nPtBins, ptLimits); - auto hRawYieldsSigma2 = new TH1D( - "hRawYieldsSigma2", ";#it{p}_{T} (GeV/#it{c});width (GeV/#it{c}^{2})", - nPtBins, ptLimits); + "hRawYieldsSigma", ";" + sliceVarName + "(" + sliceVarUnit + ");width (GeV/#it{c}^{2})", + nSliceVarBins, sliceVarLimits.data()); auto hRawYieldsMean = new TH1D( - "hRawYieldsMean", ";#it{p}_{T} (GeV/#it{c});mean (GeV/#it{c}^{2})", - nPtBins, ptLimits); - auto hRawYieldsFracGaus2 = new TH1D( - "hRawYieldsFracGaus2", - ";#it{p}_{T} (GeV/#it{c});second-gaussian fraction", nPtBins, ptLimits); + "hRawYieldsMean", ";" + sliceVarName + "(" + sliceVarUnit + ");mean (GeV/#it{c}^{2})", + nSliceVarBins, sliceVarLimits.data()); auto hRawYieldsSignificance = new TH1D( "hRawYieldsSignificance", - ";#it{p}_{T} (GeV/#it{c});significance (3#sigma)", nPtBins, ptLimits); + ";" + sliceVarName + "(" + sliceVarUnit + ");significance (3#sigma)", nSliceVarBins, sliceVarLimits.data()); auto hRawYieldsSgnOverBkg = - new TH1D("hRawYieldsSgnOverBkg", ";#it{p}_{T} (GeV/#it{c});S/B (3#sigma)", - nPtBins, ptLimits); - auto hRawYieldsSignal = - new TH1D("hRawYieldsSignal", ";#it{p}_{T} (GeV/#it{c});Signal (3#sigma)", - nPtBins, ptLimits); + new TH1D("hRawYieldsSgnOverBkg", ";" + sliceVarName + "(" + sliceVarUnit + ");S/B (3#sigma)", + nSliceVarBins, sliceVarLimits.data()); auto hRawYieldsBkg = - new TH1D("hRawYieldsBkg", ";#it{p}_{T} (GeV/#it{c});Background (3#sigma)", - nPtBins, ptLimits); - auto hRawYieldsChiSquare = - new TH1D("hRawYieldsChiSquare", - ";#it{p}_{T} (GeV/#it{c});#chi^{2}/#it{ndf}", nPtBins, ptLimits); - auto hRawYieldsSecondPeak = new TH1D( - "hRawYieldsSecondPeak", ";#it{p}_{T} (GeV/#it{c});raw yield second peak", - nPtBins, ptLimits); - auto hRawYieldsMeanSecondPeak = - new TH1D("hRawYieldsMeanSecondPeak", - ";#it{p}_{T} (GeV/#it{c});mean second peak (GeV/#it{c}^{2})", - nPtBins, ptLimits); - auto hRawYieldsSigmaSecondPeak = - new TH1D("hRawYieldsSigmaSecondPeak", - ";#it{p}_{T} (GeV/#it{c});width second peak (GeV/#it{c}^{2})", - nPtBins, ptLimits); - auto hRawYieldsSignificanceSecondPeak = - new TH1D("hRawYieldsSignificanceSecondPeak", - ";#it{p}_{T} (GeV/#it{c});signficance second peak (3#sigma)", - nPtBins, ptLimits); - auto hRawYieldsSigmaRatioSecondFirstPeak = - new TH1D("hRawYieldsSigmaRatioSecondFirstPeak", - ";#it{p}_{T} (GeV/#it{c});width second peak / width first peak", - nPtBins, ptLimits); - auto hRawYieldsSoverBSecondPeak = new TH1D( - "hRawYieldsSoverBSecondPeak", - ";#it{p}_{T} (GeV/#it{c});S/B second peak (3#sigma)", nPtBins, ptLimits); - auto hRawYieldsSignalSecondPeak = new TH1D( - "hRawYieldsSignalSecondPeak", - ";#it{p}_{T} (GeV/#it{c});Signal second peak (3#sigma)", nPtBins, ptLimits); - auto hRawYieldsBkgSecondPeak = - new TH1D("hRawYieldsBkgSecondPeak", - ";#it{p}_{T} (GeV/#it{c});Background second peak (3#sigma)", - nPtBins, ptLimits); + new TH1D("hRawYieldsBkg", ";" + sliceVarName + "(" + sliceVarUnit + ");Background (3#sigma)", + nSliceVarBins, sliceVarLimits.data()); + auto hRawYieldsChiSquareBkg = + new TH1D("hRawYieldsChiSquareBkg", + ";" + sliceVarName + "(" + sliceVarUnit + ");#chi^{2}/#it{ndf}", nSliceVarBins, sliceVarLimits.data()); + auto hRawYieldsChiSquareTotal = + new TH1D("hRawYieldsChiSquareTotal", + ";" + sliceVarName + "(" + sliceVarUnit + ");#chi^{2}/#it{ndf}", nSliceVarBins, sliceVarLimits.data()); auto hReflectionOverSignal = - new TH1D("hReflectionOverSignal", ";#it{p}_{T} (GeV/#it{c});Refl/Signal", - nPtBins, ptLimits); + new TH1D("hReflectionOverSignal", ";" + sliceVarName + "(" + sliceVarUnit + ");Refl/Signal", + nSliceVarBins, sliceVarLimits.data()); const Int_t nConfigsToSave = 6; - auto hFitConfig = new TH2F("hfitConfig", "Fit Configurations", nConfigsToSave, 0, 6, nPtBins, ptLimits); + auto hFitConfig = new TH2F("hfitConfig", "Fit Configurations", nConfigsToSave, 0, 6, nSliceVarBins, sliceVarLimits.data()); const char* hFitConfigXLabel[nConfigsToSave] = {"mass min", "mass max", "rebin num", "fix sigma", "bkg func", "sgn func"}; hFitConfig->SetStats(0); hFitConfig->LabelsDeflate("X"); @@ -349,73 +295,60 @@ int runMassFitter(TString configFileName) hFitConfig->GetXaxis()->SetBinLabel(i + 1, hFitConfigXLabel[i]); } - setHistoStyle(hRawYields); + setHistoStyle(hRawYieldsSignal); + setHistoStyle(hRawYieldsSignalCounted); setHistoStyle(hRawYieldsSigma); - setHistoStyle(hRawYieldsSigma2); setHistoStyle(hRawYieldsMean); - setHistoStyle(hRawYieldsFracGaus2); setHistoStyle(hRawYieldsSignificance); setHistoStyle(hRawYieldsSgnOverBkg); - setHistoStyle(hRawYieldsSignal); setHistoStyle(hRawYieldsBkg); - setHistoStyle(hRawYieldsChiSquare); - setHistoStyle(hRawYieldsSecondPeak, kRed + 1); - setHistoStyle(hRawYieldsMeanSecondPeak, kRed + 1); - setHistoStyle(hRawYieldsSigmaSecondPeak, kRed + 1); - setHistoStyle(hRawYieldsSignificanceSecondPeak, kRed + 1); - setHistoStyle(hRawYieldsSigmaRatioSecondFirstPeak, kRed + 1); - setHistoStyle(hRawYieldsSoverBSecondPeak, kRed + 1); - setHistoStyle(hRawYieldsSignalSecondPeak, kRed + 1); - setHistoStyle(hRawYieldsBkgSecondPeak, kRed + 1); + setHistoStyle(hRawYieldsChiSquareBkg); + setHistoStyle(hRawYieldsChiSquareTotal); setHistoStyle(hReflectionOverSignal, kRed + 1); - TH1D* hSigmaToFix = NULL; - if (fixSigma) { - if (fixSigmaManual.empty()) { - auto inputFileSigma = TFile::Open(sigmaFile.data()); - if (!inputFileSigma) { - return -2; - } - hSigmaToFix = static_cast(inputFileSigma->Get("hRawYieldsSigma")); - hSigmaToFix->SetDirectory(0); - if (static_cast(hSigmaToFix->GetNbinsX()) != nPtBins) { - cout << "WARNING: Different number of bins for this analysis and histo for fix sigma!" << endl; + auto getHistToFix = [&nSliceVarBins](bool const& isFix, std::vector const& fixManual, std::string const& fixFileName, std::string const& var) -> TH1* { + TH1* histToFix = nullptr; + if (isFix) { + if (fixManual.empty()) { + auto fixInputFile = TFile::Open(fixFileName.data()); + if (!fixInputFile) { + throw std::runtime_error("Cannot open file for fixed " + var); + } + const std::string histName = "hRawYields" + var; + histToFix = fixInputFile->Get(histName.data()); + histToFix->SetDirectory(nullptr); + if (static_cast(histToFix->GetNbinsX()) != nSliceVarBins) { + throw std::runtime_error("Different number of bins for this analysis and histo for fixed " + var); + } + fixInputFile->Close(); } - inputFileSigma->Close(); } - } + return histToFix; + }; - TH1D* hMeanToFix = NULL; - if (fixMean) { - auto inputFileMean = TFile::Open(meanFile.data()); - if (!inputFileMean) { - return -3; - } - hMeanToFix = static_cast(inputFileMean->Get("hRawYieldsMean")); - hMeanToFix->SetDirectory(0); - if (static_cast(hMeanToFix->GetNbinsX()) != nPtBins) { - cout << "WARNING: Different number of bins for this analysis and histo for fix mean" << endl; - } - inputFileMean->Close(); - } + TH1* hSigmaToFix = getHistToFix(fixSigma, fixSigmaManual, sigmaFile, "Sigma"); + TH1* hMeanToFix = getHistToFix(fixMean, fixMeanManual, meanFile, "Mean"); + TH1* hSecondSigmaToFix = getHistToFix(fixSecondSigma, fixSecondSigmaManual, secondSigmaFile, "Sigma"); // fit histograms - TH1F* hMassForFit[nPtBins]; - TH1F* hMassForRefl[nPtBins]; - TH1F* hMassForSgn[nPtBins]; + std::vector hMassForFit(nSliceVarBins); + std::vector hMassForRefl(nSliceVarBins); + std::vector hMassForSgn(nSliceVarBins); Int_t canvasSize[2] = {1920, 1080}; - if (nPtBins == 1) { + if (nSliceVarBins == 1) { canvasSize[0] = 500; canvasSize[1] = 500; } Int_t nCanvasesMax = 20; // do not put more than 20 bins per canvas to make them visible - const Int_t nCanvases = ceil((float)nPtBins / nCanvasesMax); - TCanvas *canvasMass[nCanvases], *canvasResiduals[nCanvases], *canvasRefl[nCanvases]; + const Int_t nCanvases = std::ceil(static_cast(nSliceVarBins) / nCanvasesMax); + std::vector canvasMass(nCanvases); + std::vector canvasResiduals(nCanvases); + std::vector canvasRefl(nCanvases); for (int iCanvas = 0; iCanvas < nCanvases; iCanvas++) { - int nPads = (nCanvases == 1) ? nPtBins : nCanvasesMax; + const int nPads = (nCanvases == 1) ? nSliceVarBins : nCanvasesMax; canvasMass[iCanvas] = new TCanvas(Form("canvasMass%d", iCanvas), Form("canvasMass%d", iCanvas), canvasSize[0], canvasSize[1]); divideCanvas(canvasMass[iCanvas], nPads); @@ -428,132 +361,153 @@ int runMassFitter(TString configFileName) divideCanvas(canvasRefl[iCanvas], nPads); } - for (unsigned int iPt = 0; iPt < nPtBins; iPt++) { - Int_t iCanvas = floor((float)iPt / nCanvasesMax); + for (unsigned int iSliceVar = 0; iSliceVar < nSliceVarBins; iSliceVar++) { + const Int_t iCanvas = std::floor(static_cast(iSliceVar) / nCanvasesMax); - hMassForFit[iPt] = reinterpret_cast(hMass[iPt]->Rebin(nRebin[iPt])); + hMassForFit[iSliceVar] = static_cast(hMass[iSliceVar]->Rebin(nRebin[iSliceVar])); TString ptTitle = - Form("%0.1f < #it{p}_{T} < %0.1f GeV/#it{c}", ptMin[iPt], ptMax[iPt]); - hMassForFit[iPt]->SetTitle(Form("%s;%s;Counts per %0.f MeV/#it{c}^{2}", - ptTitle.Data(), massAxisTitle.Data(), - hMassForFit[iPt]->GetBinWidth(1) * 1000)); - hMassForFit[iPt]->SetName(Form("MassForFit%d", iPt)); + Form("%0.2f < " + sliceVarName + " < %0.2f " + sliceVarUnit, sliceVarMin[iSliceVar], sliceVarMax[iSliceVar]); + hMassForFit[iSliceVar]->SetTitle(Form("%s;%s;Counts per %0.1f MeV/#it{c}^{2}", + ptTitle.Data(), massAxisTitle.Data(), + hMassForFit[iSliceVar]->GetBinWidth(1) * 1000)); + hMassForFit[iSliceVar]->SetName(Form("MassForFit%d", iSliceVar)); if (enableRefl) { - hMassForRefl[iPt] = - reinterpret_cast(hMassRefl[iPt]->Rebin(nRebin[iPt])); - hMassForSgn[iPt] = - reinterpret_cast(hMassSgn[iPt]->Rebin(nRebin[iPt])); + hMassForRefl[iSliceVar] = static_cast(hMassRefl[iSliceVar]->Rebin(nRebin[iSliceVar])); + hMassForSgn[iSliceVar] = static_cast(hMassSgn[iSliceVar]->Rebin(nRebin[iSliceVar])); } Double_t reflOverSgn = 0; double markerSize = 1.; - if (nPtBins > 15) { + constexpr int NSliceVarBinsLarge = 15; + if (nSliceVarBins > NSliceVarBinsLarge) { markerSize = 0.5; } if (isMc) { HFInvMassFitter* massFitter; - massFitter = new HFInvMassFitter(hMassForFit[iPt], massMin[iPt], massMax[iPt], HFInvMassFitter::NoBkg, sgnFunc[iPt]); - massFitter->doFit(false); - - if (nPtBins > 1) { - canvasMass[iCanvas]->cd(iPt - nCanvasesMax * iCanvas + 1); + massFitter = new HFInvMassFitter(hMassForFit[iSliceVar], massMin[iSliceVar], massMax[iSliceVar], HFInvMassFitter::NoBkg, sgnFunc[iSliceVar]); + massFitter->setDrawBgPrefit(drawBgPrefit); + massFitter->setHighlightPeakRegion(highlightPeakRegion); + massFitter->setInitialGaussianMean(massPDG); + massFitter->setParticlePdgMass(massPDG); + massFitter->setBoundGaussianMean(massPDG, 0.8 * massPDG, 1.2 * massPDG); + massFitter->doFit(); + + if (nSliceVarBins > 1) { + canvasMass[iCanvas]->cd(iSliceVar - nCanvasesMax * iCanvas + 1); } else { canvasMass[iCanvas]->cd(); } massFitter->drawFit(gPad); - Double_t rawYield = massFitter->getRawYield(); - Double_t rawYieldErr = massFitter->getRawYieldError(); - - Double_t sigma = massFitter->getSigma(); - Double_t sigmaErr = massFitter->getSigmaUncertainty(); - Double_t mean = massFitter->getMean(); - Double_t meanErr = massFitter->getMeanUncertainty(); - Double_t reducedChiSquare = massFitter->getChiSquareOverNDF(); - - hRawYields->SetBinContent(iPt + 1, rawYield); - hRawYields->SetBinError(iPt + 1, rawYieldErr); - hRawYieldsSigma->SetBinContent(iPt + 1, sigma); - hRawYieldsSigma->SetBinError(iPt + 1, sigmaErr); - hRawYieldsMean->SetBinContent(iPt + 1, mean); - hRawYieldsMean->SetBinError(iPt + 1, meanErr); - hRawYieldsChiSquare->SetBinContent(iPt + 1, reducedChiSquare); - hRawYieldsChiSquare->SetBinError(iPt + 1, 0.); + const Double_t rawYield = massFitter->getRawYield(); + const Double_t rawYieldErr = massFitter->getRawYieldError(); + const Double_t rawYieldCounted = massFitter->getRawYieldCounted(); + const Double_t rawYieldCountedErr = massFitter->getRawYieldCountedError(); + + const Double_t sigma = massFitter->getSigma(); + const Double_t sigmaErr = massFitter->getSigmaUncertainty(); + const Double_t mean = massFitter->getMean(); + const Double_t meanErr = massFitter->getMeanUncertainty(); + const Double_t reducedChiSquareBkg = massFitter->getChiSquareOverNDFBkg(); + const Double_t reducedChiSquareTotal = massFitter->getChiSquareOverNDFTotal(); + + hRawYieldsSignal->SetBinContent(iSliceVar + 1, rawYield); + hRawYieldsSignal->SetBinError(iSliceVar + 1, rawYieldErr); + hRawYieldsSignalCounted->SetBinContent(iSliceVar + 1, rawYieldCounted); + hRawYieldsSignalCounted->SetBinError(iSliceVar + 1, rawYieldCountedErr); + hRawYieldsSigma->SetBinContent(iSliceVar + 1, sigma); + hRawYieldsSigma->SetBinError(iSliceVar + 1, sigmaErr); + hRawYieldsMean->SetBinContent(iSliceVar + 1, mean); + hRawYieldsMean->SetBinError(iSliceVar + 1, meanErr); + hRawYieldsChiSquareBkg->SetBinContent(iSliceVar + 1, reducedChiSquareBkg); + hRawYieldsChiSquareBkg->SetBinError(iSliceVar + 1, 0.); + hRawYieldsChiSquareTotal->SetBinContent(iSliceVar + 1, reducedChiSquareTotal); + hRawYieldsChiSquareTotal->SetBinError(iSliceVar + 1, 0.); } else { HFInvMassFitter* massFitter; - massFitter = new HFInvMassFitter(hMassForFit[iPt], massMin[iPt], massMax[iPt], - bkgFunc[iPt], sgnFunc[iPt]); + massFitter = new HFInvMassFitter(hMassForFit[iSliceVar], massMin[iSliceVar], massMax[iSliceVar], + bkgFunc[iSliceVar], sgnFunc[iSliceVar]); + massFitter->setDrawBgPrefit(drawBgPrefit); + massFitter->setHighlightPeakRegion(highlightPeakRegion); + massFitter->setInitialGaussianMean(massPDG); + massFitter->setParticlePdgMass(massPDG); + massFitter->setBoundGaussianMean(massPDG, 0.8 * massPDG, 1.2 * massPDG); if (useLikelihood) { massFitter->setUseLikelihoodFit(); } - if (fixMean) { - massFitter->setFixGaussianMean(hMeanToFix->GetBinContent(iPt + 1)); - } - if (fixSigma) { - if (fixSigmaManual.empty()) { - massFitter->setFixGaussianSigma(hSigmaToFix->GetBinContent(iPt + 1)); - cout << "*****************************" - << "\n" - << "FIXED SIGMA: " << hSigmaToFix->GetBinContent(iPt + 1) << "\n" - << "*****************************" << endl; - } else if (!fixSigmaManual.empty()) { - massFitter->setFixGaussianSigma(fixSigmaManual[iPt]); - cout << "*****************************" - << "\n" - << "FIXED SIGMA: " << fixSigmaManual[iPt] << "\n" - << "*****************************" << endl; - } else { - cout << "WARNING: impossible to fix sigma! Wrong fix sigma file or value!" << endl; + + auto setFixedValue = [&massFitter, &iSliceVar](bool const& isFix, std::vector const& fixManual, const TH1* histToFix, std::function setFunc, std::string const& var) -> void { + if (isFix) { + if (fixManual.empty()) { + setFunc(histToFix->GetBinContent(iSliceVar + 1)); + printf("*****************************\n"); + printf("FIXED %s: %f\n", var.data(), histToFix->GetBinContent(iSliceVar + 1)); + printf("*****************************\n"); + } else { + setFunc(fixManual[iSliceVar]); + printf("*****************************\n"); + printf("FIXED %s: %f\n", var.data(), fixManual[iSliceVar]); + printf("*****************************\n"); + } } - } + }; + + setFixedValue(fixMean, fixMeanManual, hMeanToFix, std::bind(&HFInvMassFitter::setFixGaussianMean, massFitter, std::placeholders::_1), "MEAN"); + setFixedValue(fixSigma, fixSigmaManual, hSigmaToFix, std::bind(&HFInvMassFitter::setFixGaussianSigma, massFitter, std::placeholders::_1), "SIGMA"); + setFixedValue(fixSecondSigma, fixSecondSigmaManual, hSecondSigmaToFix, std::bind(&HFInvMassFitter::setFixSecondGaussianSigma, massFitter, std::placeholders::_1), "SECOND SIGMA"); if (enableRefl) { - reflOverSgn = hMassForSgn[iPt]->Integral(hMassForSgn[iPt]->FindBin(massMin[iPt] * 1.0001), hMassForSgn[iPt]->FindBin(massMax[iPt] * 0.999)); - reflOverSgn = hMassForRefl[iPt]->Integral(hMassForRefl[iPt]->FindBin(massMin[iPt] * 1.0001), hMassForRefl[iPt]->FindBin(massMax[iPt] * 0.999)) / reflOverSgn; + reflOverSgn = hMassForSgn[iSliceVar]->Integral(hMassForSgn[iSliceVar]->FindBin(massMin[iSliceVar] * 1.0001), hMassForSgn[iSliceVar]->FindBin(massMax[iSliceVar] * 0.999)); + reflOverSgn = hMassForRefl[iSliceVar]->Integral(hMassForRefl[iSliceVar]->FindBin(massMin[iSliceVar] * 1.0001), hMassForRefl[iSliceVar]->FindBin(massMax[iSliceVar] * 0.999)) / reflOverSgn; massFitter->setFixReflOverSgn(reflOverSgn); - massFitter->setTemplateReflections(hMassRefl[iPt], HFInvMassFitter::DoubleGaus); + massFitter->setTemplateReflections(hMassRefl[iSliceVar], HFInvMassFitter::DoubleGaus); } - massFitter->doFit(false); - - double rawYield = massFitter->getRawYield(); - double rawYieldErr = massFitter->getRawYieldError(); - double sigma = massFitter->getSigma(); - double sigmaErr = massFitter->getSigmaUncertainty(); - double mean = massFitter->getMean(); - double meanErr = massFitter->getMeanUncertainty(); - double reducedChiSquare = massFitter->getChiSquareOverNDF(); - double significance = massFitter->getSignificance(); - double significanceErr = massFitter->getSignificanceError(); - double bkg = massFitter->getBkgYield(); - double bkgErr = massFitter->getBkgYieldError(); - - hRawYields->SetBinContent(iPt + 1, rawYield); - hRawYields->SetBinError(iPt + 1, rawYieldErr); - hRawYieldsSigma->SetBinContent(iPt + 1, sigma); - hRawYieldsSigma->SetBinError(iPt + 1, sigmaErr); - hRawYieldsMean->SetBinContent(iPt + 1, mean); - hRawYieldsMean->SetBinError(iPt + 1, meanErr); - hRawYieldsSignificance->SetBinContent(iPt + 1, significance); - hRawYieldsSignificance->SetBinError(iPt + 1, significanceErr); - hRawYieldsSgnOverBkg->SetBinContent(iPt + 1, rawYield / bkg); - hRawYieldsSgnOverBkg->SetBinError(iPt + 1, rawYield / bkg * std::sqrt(rawYieldErr / rawYield * rawYieldErr / rawYield + bkgErr / bkg * bkgErr / bkg)); - hRawYieldsSignal->SetBinContent(iPt + 1, rawYield); - hRawYieldsSignal->SetBinError(iPt + 1, rawYieldErr); - hRawYieldsBkg->SetBinContent(iPt + 1, bkg); - hRawYieldsBkg->SetBinError(iPt + 1, bkgErr); - hRawYieldsChiSquare->SetBinContent(iPt + 1, reducedChiSquare); - hRawYieldsChiSquare->SetBinError(iPt + 1, 1.e-20); + massFitter->doFit(); + + const double rawYield = massFitter->getRawYield(); + const double rawYieldErr = massFitter->getRawYieldError(); + const double rawYieldCounted = massFitter->getRawYieldCounted(); + const double rawYieldCountedErr = massFitter->getRawYieldCountedError(); + const double sigma = massFitter->getSigma(); + const double sigmaErr = massFitter->getSigmaUncertainty(); + const double mean = massFitter->getMean(); + const double meanErr = massFitter->getMeanUncertainty(); + const double reducedChiSquareBkg = massFitter->getChiSquareOverNDFBkg(); + const double reducedChiSquareTotal = massFitter->getChiSquareOverNDFTotal(); + const double significance = massFitter->getSignificance(); + const double significanceErr = massFitter->getSignificanceError(); + const double bkg = massFitter->getBkgYield(); + const double bkgErr = massFitter->getBkgYieldError(); + + hRawYieldsSignal->SetBinContent(iSliceVar + 1, rawYield); + hRawYieldsSignal->SetBinError(iSliceVar + 1, rawYieldErr); + hRawYieldsSignalCounted->SetBinContent(iSliceVar + 1, rawYieldCounted); + hRawYieldsSignalCounted->SetBinError(iSliceVar + 1, rawYieldCountedErr); + hRawYieldsSigma->SetBinContent(iSliceVar + 1, sigma); + hRawYieldsSigma->SetBinError(iSliceVar + 1, sigmaErr); + hRawYieldsMean->SetBinContent(iSliceVar + 1, mean); + hRawYieldsMean->SetBinError(iSliceVar + 1, meanErr); + hRawYieldsSignificance->SetBinContent(iSliceVar + 1, significance); + hRawYieldsSignificance->SetBinError(iSliceVar + 1, significanceErr); + hRawYieldsSgnOverBkg->SetBinContent(iSliceVar + 1, rawYield / bkg); + hRawYieldsSgnOverBkg->SetBinError(iSliceVar + 1, rawYield / bkg * std::sqrt(rawYieldErr / rawYield * rawYieldErr / rawYield + bkgErr / bkg * bkgErr / bkg)); + hRawYieldsBkg->SetBinContent(iSliceVar + 1, bkg); + hRawYieldsBkg->SetBinError(iSliceVar + 1, bkgErr); + hRawYieldsChiSquareBkg->SetBinContent(iSliceVar + 1, reducedChiSquareBkg); + hRawYieldsChiSquareBkg->SetBinError(iSliceVar + 1, 1.e-20); + hRawYieldsChiSquareTotal->SetBinContent(iSliceVar + 1, reducedChiSquareTotal); + hRawYieldsChiSquareTotal->SetBinError(iSliceVar + 1, 1.e-20); if (enableRefl) { - hReflectionOverSignal->SetBinContent(iPt + 1, reflOverSgn); + hReflectionOverSignal->SetBinContent(iSliceVar + 1, reflOverSgn); } if (enableRefl) { - if (nPtBins > 1) { - canvasRefl[iCanvas]->cd(iPt - nCanvasesMax * iCanvas + 1); + if (nSliceVarBins > 1) { + canvasRefl[iCanvas]->cd(iSliceVar - nCanvasesMax * iCanvas + 1); } else { canvasRefl[iCanvas]->cd(); } @@ -562,8 +516,8 @@ int runMassFitter(TString configFileName) canvasRefl[iCanvas]->Update(); } - if (nPtBins > 1) { - canvasMass[iCanvas]->cd(iPt - nCanvasesMax * iCanvas + 1); + if (nSliceVarBins > 1) { + canvasMass[iCanvas]->cd(iSliceVar - nCanvasesMax * iCanvas + 1); } else { canvasMass[iCanvas]->cd(); } @@ -571,8 +525,8 @@ int runMassFitter(TString configFileName) canvasMass[iCanvas]->Modified(); canvasMass[iCanvas]->Update(); - if (nPtBins > 1) { - canvasResiduals[iCanvas]->cd(iPt - nCanvasesMax * iCanvas + 1); + if (nSliceVarBins > 1) { + canvasResiduals[iCanvas]->cd(iSliceVar - nCanvasesMax * iCanvas + 1); } else { canvasResiduals[iCanvas]->cd(); } @@ -581,18 +535,18 @@ int runMassFitter(TString configFileName) canvasResiduals[iCanvas]->Update(); } - hFitConfig->SetBinContent(1, iPt + 1, massMin[iPt]); - hFitConfig->SetBinContent(2, iPt + 1, massMax[iPt]); - hFitConfig->SetBinContent(3, iPt + 1, nRebin[iPt]); + hFitConfig->SetBinContent(1, iSliceVar + 1, massMin[iSliceVar]); + hFitConfig->SetBinContent(2, iSliceVar + 1, massMax[iSliceVar]); + hFitConfig->SetBinContent(3, iSliceVar + 1, nRebin[iSliceVar]); if (fixSigma) { if (fixSigmaManual.empty()) { - hFitConfig->SetBinContent(4, iPt + 1, hSigmaToFix->GetBinContent(iPt + 1)); + hFitConfig->SetBinContent(4, iSliceVar + 1, hSigmaToFix->GetBinContent(iSliceVar + 1)); } else { - hFitConfig->SetBinContent(4, iPt + 1, fixSigmaManual[iPt]); + hFitConfig->SetBinContent(4, iSliceVar + 1, fixSigmaManual[iSliceVar]); } } - hFitConfig->SetBinContent(5, iPt + 1, bkgFuncConfig[iPt]); - hFitConfig->SetBinContent(6, iPt + 1, sgnFuncConfig[iPt]); + hFitConfig->SetBinContent(5, iSliceVar + 1, bkgFuncConfig[iSliceVar]); + hFitConfig->SetBinContent(6, iSliceVar + 1, sgnFuncConfig[iSliceVar]); } // save output histograms @@ -605,27 +559,21 @@ int runMassFitter(TString configFileName) } } - for (unsigned int iPt = 0; iPt < nPtBins; iPt++) { - hMass[iPt]->Write(); + for (unsigned int iSliceVar = 0; iSliceVar < nSliceVarBins; iSliceVar++) { + hMass[iSliceVar]->Write(); } - hRawYields->Write(); + hRawYieldsSignal->Write(); + hRawYieldsSignalCounted->Write(); hRawYieldsSigma->Write(); hRawYieldsMean->Write(); hRawYieldsSignificance->Write(); hRawYieldsSgnOverBkg->Write(); - hRawYieldsSignal->Write(); hRawYieldsBkg->Write(); - hRawYieldsChiSquare->Write(); - hRawYieldsSigma2->Write(); - hRawYieldsFracGaus2->Write(); - hRawYieldsSecondPeak->Write(); - hRawYieldsMeanSecondPeak->Write(); - hRawYieldsSigmaSecondPeak->Write(); - hRawYieldsSignificanceSecondPeak->Write(); - hRawYieldsSigmaRatioSecondFirstPeak->Write(); - hRawYieldsSoverBSecondPeak->Write(); - hRawYieldsSignalSecondPeak->Write(); - hRawYieldsBkgSecondPeak->Write(); + hRawYieldsChiSquareBkg->Write(); + hRawYieldsChiSquareTotal->Write(); + if (enableRefl) { + hReflectionOverSignal->Write(); + } hFitConfig->Write(); outputFile.Close(); @@ -654,7 +602,7 @@ int runMassFitter(TString configFileName) return 0; } -void setHistoStyle(TH1* histo, int color, double markerSize) +void setHistoStyle(TH1* histo, Color_t color, Size_t markerSize) { histo->SetStats(kFALSE); histo->SetMarkerSize(markerSize); @@ -664,33 +612,26 @@ void setHistoStyle(TH1* histo, int color, double markerSize) histo->SetLineColor(color); } -void divideCanvas(TCanvas* canvas, int nPtBins) +void divideCanvas(TCanvas* canvas, int nSliceVarBins) +{ + const int rectangularSideMin = std::floor(std::sqrt(nSliceVarBins)); + constexpr int RectangularSidesDiffMax = 2; + for (int rectangularSidesDiff = 0; rectangularSidesDiff < RectangularSidesDiffMax; ++rectangularSidesDiff) { + if (rectangularSideMin * (rectangularSideMin + rectangularSidesDiff) >= nSliceVarBins) { + canvas->Divide(rectangularSideMin + rectangularSidesDiff, rectangularSideMin); + } + } +} + +int main(int argc, char* argv[]) { - if (nPtBins < 2) { - canvas->cd(); - } else if (nPtBins == 2 || nPtBins == 3) { - canvas->Divide(nPtBins, 1); - } else if (nPtBins == 4 || nPtBins == 6 || nPtBins == 8) { - canvas->Divide(nPtBins / 2, 2); - } else if (nPtBins == 5 || nPtBins == 7) { - canvas->Divide((nPtBins + 1) / 2, 2); - } else if (nPtBins == 9 || nPtBins == 12 || nPtBins == 15) { - canvas->Divide(nPtBins / 3, 3); - } else if (nPtBins == 10 || nPtBins == 11) { - canvas->Divide(4, 3); - } else if (nPtBins == 13 || nPtBins == 14) { - canvas->Divide(5, 3); - } else if (nPtBins > 15 && nPtBins <= 20 && nPtBins % 4 == 0) { - canvas->Divide(nPtBins / 4, 4); - } else if (nPtBins > 15 && nPtBins <= 20 && nPtBins % 4 != 0) { - canvas->Divide(5, 4); - } else if (nPtBins == 21) { - canvas->Divide(7, 3); - } else if (nPtBins > 21 && nPtBins <= 25) { - canvas->Divide(5, 5); - } else if (nPtBins > 25 && nPtBins % 2 == 0) { - canvas->Divide(nPtBins / 2, 2); - } else { - canvas->Divide((nPtBins + 1) / 2, 2); + if (argc == 1) { + throw std::runtime_error("Not enough arguments. Please use\n./runMassFitter configFileName"); } + + const std::string configFileName = argv[1]; + + runMassFitter(configFileName); + + return 0; } diff --git a/PWGHF/D2H/TableProducer/CMakeLists.txt b/PWGHF/D2H/TableProducer/CMakeLists.txt index 92eeda51051..a60ab1d78ab 100644 --- a/PWGHF/D2H/TableProducer/CMakeLists.txt +++ b/PWGHF/D2H/TableProducer/CMakeLists.txt @@ -11,6 +11,11 @@ # Candidate creators +o2physics_add_dpl_workflow(candidate-creator-b-to-jpsi-reduced + SOURCES candidateCreatorBToJpsiReduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(candidate-creator-b0-reduced SOURCES candidateCreatorB0Reduced.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter @@ -31,6 +36,11 @@ o2physics_add_dpl_workflow(candidate-creator-charm-reso-reduced PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(candidate-creator-lb-reduced + SOURCES candidateCreatorLbReduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter + COMPONENT_NAME Analysis) + # Candidate selectors o2physics_add_dpl_workflow(candidate-selector-b0-to-d-pi-reduced @@ -48,6 +58,11 @@ o2physics_add_dpl_workflow(candidate-selector-bs-to-ds-pi-reduced PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(candidate-selector-lb-to-lc-pi-reduced + SOURCES candidateSelectorLbToLcPiReduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore + COMPONENT_NAME Analysis) + # Data creators o2physics_add_dpl_workflow(data-creator-charm-had-pi-reduced @@ -60,9 +75,19 @@ o2physics_add_dpl_workflow(data-creator-charm-reso-reduced PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(data-creator-jpsi-had-reduced + SOURCES dataCreatorJpsiHadReduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) + # Converters o2physics_add_dpl_workflow(converter-reduced-3-prongs-ml SOURCES converterReduced3ProngsMl.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) \ No newline at end of file + COMPONENT_NAME Analysis) + + o2physics_add_dpl_workflow(converter-reduced-hadron-daus-pid + SOURCES converterReducedHadronDausPid.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx index 3e354c266ea..a5815359f4b 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx @@ -15,19 +15,33 @@ /// \author Alexandre Bigot , IPHC Strasbourg /// \author Fabrizio Grosa , CERN -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" -#include "PWGHF/Utils/utilsTrkCandHf.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -201,7 +215,7 @@ struct HfCandidateCreatorB0Reduced { rowCandidateDmesMlScores(candD.mlScoreBkgMassHypo0(), candD.mlScorePromptMassHypo0(), candD.mlScoreNonpromptMassHypo0()); } } // pi loop - } // D loop + } // D loop } void processData(HfRedCollisionsWithExtras const& collisions, @@ -293,7 +307,7 @@ struct HfCandidateCreatorB0ReducedExpressions { if ((rowDPiMcRec.prong0Id() != candB0.prong0Id()) || (rowDPiMcRec.prong1Id() != candB0.prong1Id())) { continue; } - rowB0McRec(rowDPiMcRec.flagMcMatchRec(), rowDPiMcRec.flagWrongCollision(), rowDPiMcRec.debugMcRec(), rowDPiMcRec.ptMother()); + rowB0McRec(rowDPiMcRec.flagMcMatchRec(), -1 /*channel*/, rowDPiMcRec.flagWrongCollision(), rowDPiMcRec.debugMcRec(), rowDPiMcRec.ptMother()); filledMcInfo = true; if constexpr (checkDecayTypeMc) { rowB0McCheck(rowDPiMcRec.pdgCodeBeautyMother(), @@ -306,7 +320,7 @@ struct HfCandidateCreatorB0ReducedExpressions { break; } if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the D-Pi creator - rowB0McRec(0, -1, -1, -1.f); + rowB0McRec(0, -1, -1, -1, -1.f); if constexpr (checkDecayTypeMc) { rowB0McCheck(-1, -1, -1, -1, -1, -1); } diff --git a/PWGHF/D2H/TableProducer/candidateCreatorBToJpsiReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorBToJpsiReduced.cxx new file mode 100644 index 00000000000..d96365a6b47 --- /dev/null +++ b/PWGHF/D2H/TableProducer/candidateCreatorBToJpsiReduced.cxx @@ -0,0 +1,479 @@ +// 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. + +/// \file candidateCreatorBToJpsiReduced.cxx +/// \brief Reconstruction of B->J/Psi hadron candidates +/// +/// \author Fabrizio Chinu , Università degli Studi and INFN Torino +/// \author Fabrizio Grosa , CERN + +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; + +enum DecayChannel : uint8_t { + B0ToJpsiK0Star = 0, + BplusToJpsiK, + BsToJpsiPhi +}; + +/// Reconstruction of B+ candidates +struct HfCandidateCreatorBToJpsiReduced { + Produces rowCandidateBpBase; // table defined in CandidateReconstructionTables.h + Produces rowCandidateBpProngs; // table defined in ReducedDataModel.h + Produces rowCandidateBsBase; // table defined in CandidateReconstructionTables.h + Produces rowCandidateBsProngs; // table defined in ReducedDataModel.h + + // vertexing + Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; + Configurable useAbsDCA{"useAbsDCA", true, "Minimise abs. distance rather than chi2"}; + Configurable useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; + Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; + Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; + Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any B+ is smaller than this"}; + Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; + + Configurable runJpsiToee{"runJpsiToee", false, "Run analysis for J/Psi to ee (debug)"}; + // selection + Configurable invMassWindowJpsiHadTolerance{"invMassWindowJpsiHadTolerance", 0.01, "invariant-mass window tolerance for J/Psi K pair preselections (GeV/c2)"}; + + float myInvMassWindowJpsiK{1.}, myInvMassWindowJpsiPhi{1.}; // variable that will store the value of invMassWindowJpsiK (defined in dataCreatorJpsiKReduced.cxx) + double massBplus{0.}, massBs{0.}; + double bz{0.}; + o2::vertexing::DCAFitterN<2> df2; // fitter for B vertex (2-prong vertex fitter) + o2::vertexing::DCAFitterN<3> df3; // fitter for B vertex (3-prong vertex fitter) + o2::vertexing::DCAFitterN<4> df4; // fitter for B vertex (4-prong vertex fitter) + + using HfRedCollisionsWithExtras = soa::Join; + + Preslice> candsJpsiPerCollision = hf_track_index_reduced::hfRedCollisionId; + Preslice> tracksLf0PerCollision = hf_track_index_reduced::hfRedCollisionId; + Preslice> tracksLf1PerCollision = hf_track_index_reduced::hfRedCollisionId; + + std::shared_ptr hCandidatesB, hCandidatesPhi; + o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + HistogramRegistry registry{"registry"}; + + void init(InitContext const&) + { + // invariant-mass window cut + massBplus = o2::constants::physics::MassBPlus; + massBs = o2::constants::physics::MassBS; + + // Initialize fitters + df2.setPropagateToPCA(propagateToPCA); + df2.setMaxR(maxR); + df2.setMaxDZIni(maxDZIni); + df2.setMinParamChange(minParamChange); + df2.setMinRelChi2Change(minRelChi2Change); + df2.setUseAbsDCA(useAbsDCA); + df2.setWeightedFinalPCA(useWeightedFinalPCA); + df2.setMatCorrType(noMatCorr); + + df3.setPropagateToPCA(propagateToPCA); + df3.setMaxR(maxR); + df3.setMaxDZIni(maxDZIni); + df3.setMinParamChange(minParamChange); + df3.setMinRelChi2Change(minRelChi2Change); + df3.setUseAbsDCA(useAbsDCA); + df3.setWeightedFinalPCA(useWeightedFinalPCA); + df3.setMatCorrType(noMatCorr); + + df4.setPropagateToPCA(propagateToPCA); + df4.setMaxR(maxR); + df4.setMaxDZIni(maxDZIni); + df4.setMinParamChange(minParamChange); + df4.setMinRelChi2Change(minRelChi2Change); + df4.setUseAbsDCA(useAbsDCA); + df4.setWeightedFinalPCA(useWeightedFinalPCA); + df4.setMatCorrType(noMatCorr); + + // histograms + registry.add("hMassJpsi", "J/Psi mass;#it{M}_{#mu#mu} (GeV/#it{c}^{2});Counts", {HistType::kTH1F, {{600, 2.5, 3.7, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hMassBplusToJpsiK", "2-prong candidates;inv. mass (B^{+} #rightarrow #overline{D^{0}}#pi^{#plus} #rightarrow #pi^{#minus}K^{#plus}#pi^{#plus}) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 3., 8.}}}); + registry.add("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}); + registry.add("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 0.2}}}); + registry.add("hEvents", "Events;;entries", HistType::kTH1F, {{1, 0.5, 1.5}}); + + /// candidate monitoring + hCandidatesB = registry.add("hFitCandidatesJpsi", "candidates counter", {HistType::kTH1D, {axisCands}}); + hCandidatesPhi = registry.add("hFitCandidatesPhi", "candidates counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidatesB); + setLabelHistoCands(hCandidatesPhi); + } + + /// Main function to perform B+ candidate creation + /// \param collision the collision + /// \param candsJpsiThisColl J/Psi candidates in this collision + /// \param tracksLfThisCollisionArr LF tracks in this collision + /// \param invMass2JpsiHadMin minimum B invariant-mass + /// \param invMass2JpsiHadMax maximum B invariant-mass + template + void runCandidateCreation(Coll const& collision, + Cands const& candsJpsiThisColl, + TTracks0 const& tracksLfDau0ThisCollision, + TTracks1 const& tracksLfDau1ThisCollision, + const float invMass2JpsiHadMin, + const float invMass2JpsiHadMax) + { + auto primaryVertex = getPrimaryVertex(collision); + auto covMatrixPV = primaryVertex.getCov(); + + // Set the magnetic field from ccdb + bz = collision.bz(); + df2.setBz(bz); + df3.setBz(bz); + df4.setBz(bz); + + for (const auto& candJpsi : candsJpsiThisColl) { + o2::track::TrackParametrizationWithError trackPosParCov( + candJpsi.xDauPos(), candJpsi.alphaDauPos(), {candJpsi.yDauPos(), candJpsi.zDauPos(), candJpsi.snpDauPos(), candJpsi.tglDauPos(), candJpsi.signed1PtDauPos()}, 1 /*Charge*/, 1 /*Muon*/); + o2::track::TrackParametrizationWithError trackNegParCov( + candJpsi.xDauNeg(), candJpsi.alphaDauNeg(), {candJpsi.yDauNeg(), candJpsi.zDauNeg(), candJpsi.snpDauNeg(), candJpsi.tglDauNeg(), candJpsi.signed1PtDauNeg()}, -1 /*Charge*/, 1 /*Muon*/); + + // --------------------------------- + // reconstruct J/Psi candidate + o2::track::TrackParCov trackParCovJpsi{}; + std::array pVecJpsi{}; + registry.fill(HIST("hFitCandidatesJpsi"), SVFitting::BeforeFit); + try { + if (df2.process(trackPosParCov, trackNegParCov) == 0) { + LOG(info) << "DCAFitterN failed to reconstruct J/Psi candidate, skipping the candidate."; + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + registry.fill(HIST("hFitCandidatesJpsi"), SVFitting::Fail); + continue; + } + registry.fill(HIST("hFitCandidatesJpsi"), SVFitting::FitOk); + + std::array pVecDauPos{candJpsi.pxDauPos(), candJpsi.pyDauPos(), candJpsi.pzDauPos()}; + std::array pVecDauNeg{candJpsi.pxDauNeg(), candJpsi.pyDauNeg(), candJpsi.pzDauNeg()}; + + df2.getTrack(0).getPxPyPzGlo(pVecDauPos); + df2.getTrack(1).getPxPyPzGlo(pVecDauNeg); + pVecJpsi = RecoDecay::pVec(pVecDauPos, pVecDauNeg); + trackParCovJpsi = df2.createParentTrackParCov(); + trackParCovJpsi.setAbsCharge(0); // to be sure + + float invMassJpsi{0.f}; + if (runJpsiToee) { + invMassJpsi = RecoDecay::m2(std::array{pVecDauPos, pVecDauNeg}, std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassElectron}); + } else { + invMassJpsi = RecoDecay::m2(std::array{pVecDauPos, pVecDauNeg}, std::array{o2::constants::physics::MassMuon, o2::constants::physics::MassMuon}); + } + invMassJpsi = std::sqrt(invMassJpsi); + registry.fill(HIST("hMassJpsi"), invMassJpsi); + + for (const auto& trackLf0 : tracksLfDau0ThisCollision) { + // this track is among daughters + if (trackLf0.trackId() == candJpsi.prongPosId() || trackLf0.trackId() == candJpsi.prongNegId()) { + continue; + } + auto trackParCovLf0 = getTrackParCov(trackLf0); + std::array pVecTrackLf0{}; + if constexpr (decChannel == DecayChannel::BplusToJpsiK) { + // --------------------------------- + // reconstruct the 3-prong B+ vertex + hCandidatesB->Fill(SVFitting::BeforeFit); + try { + if (df3.process(trackPosParCov, trackNegParCov, trackParCovLf0) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + hCandidatesB->Fill(SVFitting::Fail); + continue; + } + hCandidatesB->Fill(SVFitting::FitOk); + // JpsiK passed B+ reconstruction + + // calculate relevant properties + const auto& secondaryVertexBplus = df3.getPCACandidate(); + auto chi2PCA = df3.getChi2AtPCACandidate(); + auto covMatrixPCA = df3.calcPCACovMatrixFlat(); + registry.fill(HIST("hCovSVXX"), covMatrixPCA[0]); + registry.fill(HIST("hCovPVXX"), covMatrixPV[0]); + + // propagate Jpsi daugthers and K to the B+ vertex + df3.propagateTracksToVertex(); + // track.getPxPyPzGlo(pVec) modifies pVec of track + df3.getTrack(0).getPxPyPzGlo(pVecDauPos); // momentum of positive Jpsi daughter at the B+ vertex + df3.getTrack(1).getPxPyPzGlo(pVecDauNeg); // momentum of negative Jpsi daughter at the B+ vertex + df3.getTrack(2).getPxPyPzGlo(pVecTrackLf0); // momentum of K at the B+ vertex + + // compute invariant mass square and apply selection + auto invMass2JpsiK = RecoDecay::m2(std::array{pVecDauPos, pVecDauNeg, pVecTrackLf0}, std::array{o2::constants::physics::MassMuon, o2::constants::physics::MassMuon, o2::constants::physics::MassKPlus}); + if ((invMass2JpsiK < invMass2JpsiHadMin) || (invMass2JpsiK > invMass2JpsiHadMax)) { + continue; + } + registry.fill(HIST("hMassBplusToJpsiK"), std::sqrt(invMass2JpsiK)); + + // compute impact parameters of Jpsi and K + o2::dataformats::DCA dcaDauPos, dcaDauNeg, dcaKaon; + trackPosParCov.propagateToDCA(primaryVertex, bz, &dcaDauPos); + trackNegParCov.propagateToDCA(primaryVertex, bz, &dcaDauNeg); + trackParCovLf0.propagateToDCA(primaryVertex, bz, &dcaKaon); + + // get uncertainty of the decay length + double phi, theta; + // getPointDirection modifies phi and theta + getPointDirection(std::array{collision.posX(), collision.posY(), collision.posZ()}, secondaryVertexBplus, phi, theta); + auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta)); + auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); + + // fill the candidate table for the B+ here: + rowCandidateBpBase(collision.globalIndex(), + collision.posX(), collision.posY(), collision.posZ(), + secondaryVertexBplus[0], secondaryVertexBplus[1], secondaryVertexBplus[2], + errorDecayLength, errorDecayLengthXY, + chi2PCA, + pVecDauPos[0], pVecDauPos[1], pVecDauPos[2], + pVecDauNeg[0], pVecDauNeg[1], pVecDauNeg[2], + pVecTrackLf0[0], pVecTrackLf0[1], pVecTrackLf0[2], + dcaDauPos.getY(), dcaDauNeg.getY(), dcaKaon.getY(), + std::sqrt(dcaDauPos.getSigmaY2()), std::sqrt(dcaDauNeg.getSigmaY2()), std::sqrt(dcaKaon.getSigmaY2())); + + rowCandidateBpProngs(candJpsi.globalIndex(), trackLf0.globalIndex()); + } else if constexpr (decChannel == DecayChannel::BsToJpsiPhi) { + for (const auto& trackLf1 : tracksLfDau1ThisCollision) { + // this track is among daughters + if (trackLf1.trackId() == candJpsi.prongPosId() || trackLf1.trackId() == candJpsi.prongNegId()) { + continue; + } + auto trackParCovLf1 = getTrackParCov(trackLf1); + std::array pVecTrackLf1 = trackLf1.pVector(); + + // --------------------------------- + // reconstruct the 4-prong Bs vertex + hCandidatesB->Fill(SVFitting::BeforeFit); + try { + if (df4.process(trackPosParCov, trackNegParCov, trackParCovLf0, trackParCovLf1) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + hCandidatesB->Fill(SVFitting::Fail); + continue; + } + hCandidatesB->Fill(SVFitting::FitOk); + // passed Bs reconstruction + + // calculate relevant properties + const auto& secondaryVertexBs = df4.getPCACandidate(); + auto chi2PCA = df4.getChi2AtPCACandidate(); + auto covMatrixPCA = df4.calcPCACovMatrixFlat(); + registry.fill(HIST("hCovSVXX"), covMatrixPCA[0]); + registry.fill(HIST("hCovPVXX"), covMatrixPV[0]); + + // propagate Jpsi and phi to the Bs vertex + df4.propagateTracksToVertex(); + // track.getPxPyPzGlo(pVec) modifies pVec of track + df4.getTrack(0).getPxPyPzGlo(pVecDauPos); // momentum of Jpsi at the B+ vertex + df4.getTrack(1).getPxPyPzGlo(pVecDauNeg); // momentum of Jpsi at the B+ vertex + df4.getTrack(2).getPxPyPzGlo(pVecTrackLf0); // momentum of K at the B+ vertex + df4.getTrack(3).getPxPyPzGlo(pVecTrackLf1); // momentum of K at the B+ vertex + + // compute invariant mass square and apply selection + auto invMass2JpsiPhi = RecoDecay::m2(std::array{pVecDauPos, pVecDauNeg, pVecTrackLf0, pVecTrackLf1}, std::array{o2::constants::physics::MassMuon, o2::constants::physics::MassMuon, o2::constants::physics::MassKPlus, o2::constants::physics::MassKPlus}); + if ((invMass2JpsiPhi < invMass2JpsiHadMin) || (invMass2JpsiPhi > invMass2JpsiHadMax)) { + continue; + } + registry.fill(HIST("hMassBplusToJpsiK"), std::sqrt(invMass2JpsiPhi)); + + // compute impact parameters of Jpsi and K + o2::dataformats::DCA dcaDauPos, dcaDauNeg, dcaTrackLf0, dcaTrackLf1; + trackPosParCov.propagateToDCA(primaryVertex, bz, &dcaDauPos); + trackNegParCov.propagateToDCA(primaryVertex, bz, &dcaDauNeg); + trackParCovLf0.propagateToDCA(primaryVertex, bz, &dcaTrackLf0); + trackParCovLf1.propagateToDCA(primaryVertex, bz, &dcaTrackLf1); + + // get uncertainty of the decay length + double phi, theta; + // getPointDirection modifies phi and theta + getPointDirection(std::array{collision.posX(), collision.posY(), collision.posZ()}, secondaryVertexBs, phi, theta); + auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta)); + auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); + + // fill the candidate table for the Bs here: + rowCandidateBsBase(collision.globalIndex(), + collision.posX(), collision.posY(), collision.posZ(), + secondaryVertexBs[0], secondaryVertexBs[1], secondaryVertexBs[2], + errorDecayLength, errorDecayLengthXY, + chi2PCA, + pVecDauPos[0], pVecDauPos[1], pVecDauPos[2], + pVecDauNeg[0], pVecDauNeg[1], pVecDauPos[2], + pVecTrackLf0[0], pVecTrackLf0[1], pVecTrackLf0[2], + pVecTrackLf1[0], pVecTrackLf1[1], pVecTrackLf0[2], + dcaDauPos.getY(), dcaDauNeg.getY(), dcaTrackLf0.getY(), dcaTrackLf1.getY(), + std::sqrt(dcaDauPos.getSigmaY2()), std::sqrt(dcaDauNeg.getSigmaY2()), std::sqrt(dcaTrackLf0.getSigmaY2()), std::sqrt(dcaTrackLf1.getSigmaY2())); + rowCandidateBsProngs(candJpsi.globalIndex(), trackLf0.globalIndex(), trackLf1.globalIndex()); + } + } + } // TrackLf0 loop + } // J/Psi loop + } // end runCandidateCreation + + void processDataBplus(HfRedCollisionsWithExtras const& collisions, + soa::Join const& candsJpsi, + soa::Join const& tracksKaon, + aod::HfOrigColCounts const& collisionsCounter, + aod::HfCfgBpToJpsi const& configs) + { + // Jpsi K invariant-mass window cut + for (const auto& config : configs) { + myInvMassWindowJpsiK = config.myInvMassWindowJpsiK(); + } + // invMassWindowJpsiHadTolerance is used to apply a slightly tighter cut than in JpsiK pair preselection + // to avoid accepting JpsiK pairs that were not formed in JpsiK pair creator + double invMass2JpsiKMin = (massBplus - myInvMassWindowJpsiK + invMassWindowJpsiHadTolerance) * (massBplus - myInvMassWindowJpsiK + invMassWindowJpsiHadTolerance); + double invMass2JpsiKMax = (massBplus + myInvMassWindowJpsiK - invMassWindowJpsiHadTolerance) * (massBplus + myInvMassWindowJpsiK - invMassWindowJpsiHadTolerance); + + for (const auto& collisionCounter : collisionsCounter) { + registry.fill(HIST("hEvents"), 1, collisionCounter.originalCollisionCount()); + } + + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candsJpsiThisColl = candsJpsi.sliceBy(candsJpsiPerCollision, thisCollId); + auto tracksKaonThisCollision = tracksKaon.sliceBy(tracksLf0PerCollision, thisCollId); + runCandidateCreation(collision, candsJpsiThisColl, tracksKaonThisCollision, tracksKaonThisCollision, invMass2JpsiKMin, invMass2JpsiKMax); + } + } // processDataBplus + PROCESS_SWITCH(HfCandidateCreatorBToJpsiReduced, processDataBplus, "Process data for B+", true); + + void processDataBs(HfRedCollisionsWithExtras const& collisions, + soa::Join const& candsJpsi, + soa::Join const& tracksLfDau0, + soa::Join const& tracksLfDau1, + aod::HfOrigColCounts const& collisionsCounter, + aod::HfCfgBsToJpsis const& configs) + { + // Jpsi K invariant-mass window cut + for (const auto& config : configs) { + myInvMassWindowJpsiPhi = config.myInvMassWindowJpsiPhi(); + } + // invMassWindowJpsiHadTolerance is used to apply a slightly tighter cut than in JpsiK pair preselection + // to avoid accepting JpsiK pairs that were not formed in JpsiK pair creator + double invMass2JpsiKMin = (massBs - myInvMassWindowJpsiPhi + invMassWindowJpsiHadTolerance) * (massBs - myInvMassWindowJpsiPhi + invMassWindowJpsiHadTolerance); + double invMass2JpsiKMax = (massBs + myInvMassWindowJpsiPhi - invMassWindowJpsiHadTolerance) * (massBs + myInvMassWindowJpsiPhi - invMassWindowJpsiHadTolerance); + + for (const auto& collisionCounter : collisionsCounter) { + registry.fill(HIST("hEvents"), 1, collisionCounter.originalCollisionCount()); + } + + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candsJpsiThisColl = candsJpsi.sliceBy(candsJpsiPerCollision, thisCollId); + auto tracksLf0ThisCollision = tracksLfDau0.sliceBy(tracksLf0PerCollision, thisCollId); + auto tracksLf1ThisCollision = tracksLfDau1.sliceBy(tracksLf1PerCollision, thisCollId); + runCandidateCreation(collision, candsJpsiThisColl, tracksLf0ThisCollision, tracksLf1ThisCollision, invMass2JpsiKMin, invMass2JpsiKMax); + } + } // processDataBs + PROCESS_SWITCH(HfCandidateCreatorBToJpsiReduced, processDataBs, "Process data for Bs", false); +}; // struct + +/// Extends the table base with expression columns and performs MC matching. +struct HfCandidateCreatorBToJpsiReducedExpressions { + Spawns rowCandidateBPlus; + Spawns rowCandidateBs; + Produces rowBplusMcRec; + Produces rowBsMcRec; + + /// Fill candidate information at MC reconstruction level + /// \param rowsJpsiHadMcRec MC reco information on Jpsi hadron pairs + /// \param candsBIds prong global indices of B candidates + template + void fillMcRec(McRec const& rowsJpsiHadMcRec, CCands const& candsBIds) + { + for (const auto& candB : candsBIds) { + bool filledMcInfo{false}; + if constexpr (decChannel == DecayChannel::BplusToJpsiK) { + for (const auto& rowJpsiHadMcRec : rowsJpsiHadMcRec) { + if ((rowJpsiHadMcRec.jpsiId() != candB.jpsiId()) || (rowJpsiHadMcRec.bachKaId() != candB.bachKaId())) { + continue; + } + rowBplusMcRec(rowJpsiHadMcRec.flagMcMatchRec(), rowJpsiHadMcRec.flagMcDecayChanRec(), rowJpsiHadMcRec.flagWrongCollision(), rowJpsiHadMcRec.debugMcRec(), rowJpsiHadMcRec.ptMother()); + filledMcInfo = true; + break; + } + if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the Jpsi-K creator + rowBplusMcRec(0, -1, -1, -1, -1.f); + } + } else if constexpr (decChannel == DecayChannel::BsToJpsiPhi) { + for (const auto& rowJpsiHadMcRec : rowsJpsiHadMcRec) { + if ((rowJpsiHadMcRec.jpsiId() != candB.jpsiId()) || (rowJpsiHadMcRec.prong0PhiId() != candB.prong0PhiId()) || (rowJpsiHadMcRec.prong1PhiId() != candB.prong1PhiId())) { + continue; + } + rowBsMcRec(rowJpsiHadMcRec.flagMcMatchRec(), rowJpsiHadMcRec.flagMcDecayChanRec(), rowJpsiHadMcRec.flagWrongCollision(), rowJpsiHadMcRec.debugMcRec(), rowJpsiHadMcRec.ptMother()); + filledMcInfo = true; + break; + } + if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the Jpsi-K creator + rowBsMcRec(0, -1, -1, -1, -1.f); + } + } + } + } + + void processMcBPlus(HfMcRecRedJPKs const& rowsJpsiKMcRec, HfRedBplus2JpsiDaus const& candsBplus) + { + fillMcRec(rowsJpsiKMcRec, candsBplus); + } + PROCESS_SWITCH(HfCandidateCreatorBToJpsiReducedExpressions, processMcBPlus, "Process MC", false); + + void processMcBs(HfMcRecRedJPPhis const& rowsJpsiPhiMcRec, HfRedBs2JpsiDaus const& Bs) + { + fillMcRec(rowsJpsiPhiMcRec, Bs); + } + PROCESS_SWITCH(HfCandidateCreatorBToJpsiReducedExpressions, processMcBs, "Process MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx index 34edf46cba4..1bcff8ae7ae 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx @@ -14,20 +14,33 @@ /// /// \author Antonio Palasciano , Università degli Studi di Bari -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/V0.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" -#include "PWGHF/Utils/utilsTrkCandHf.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -198,8 +211,8 @@ struct HfCandidateCreatorBplusReduced { } } } // pi loop - } // D0 loop - } // end runCandidateCreation + } // D0 loop + } // end runCandidateCreation void processData(HfRedCollisionsWithExtras const& collisions, soa::Join const& candsD, @@ -291,10 +304,11 @@ struct HfCandidateCreatorBplusReducedExpressions { if ((rowD0PiMcRec.prong0Id() != candBplus.prong0Id()) || (rowD0PiMcRec.prong1Id() != candBplus.prong1Id())) { continue; } - rowBplusMcRec(rowD0PiMcRec.flagMcMatchRec(), rowD0PiMcRec.flagWrongCollision(), rowD0PiMcRec.debugMcRec(), rowD0PiMcRec.ptMother()); + rowBplusMcRec(rowD0PiMcRec.flagMcMatchRec(), -1 /*channel*/, rowD0PiMcRec.flagWrongCollision(), rowD0PiMcRec.debugMcRec(), rowD0PiMcRec.ptMother()); filledMcInfo = true; if constexpr (checkDecayTypeMc) { rowBplusMcCheck(rowD0PiMcRec.pdgCodeBeautyMother(), + rowD0PiMcRec.pdgCodeCharmMother(), rowD0PiMcRec.pdgCodeProng0(), rowD0PiMcRec.pdgCodeProng1(), rowD0PiMcRec.pdgCodeProng2()); @@ -302,9 +316,9 @@ struct HfCandidateCreatorBplusReducedExpressions { break; } if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the D0-Pi creator - rowBplusMcRec(0, -1, -1, -1.f); + rowBplusMcRec(0, -1, -1, -1, -1.f); if constexpr (checkDecayTypeMc) { - rowBplusMcCheck(-1, -1, -1, -1); + rowBplusMcCheck(-1, -1, -1, -1, -1); } } } diff --git a/PWGHF/D2H/TableProducer/candidateCreatorBsReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorBsReduced.cxx index f75b5608ca1..4a9ee3a9c57 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorBsReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorBsReduced.cxx @@ -14,19 +14,33 @@ /// /// \author Fabio Catalano , CERN -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" -#include "PWGHF/Utils/utilsTrkCandHf.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -290,7 +304,7 @@ struct HfCandidateCreatorBsReducedExpressions { if ((rowDPiMcRec.prong0Id() != candB.prong0Id()) || (rowDPiMcRec.prong1Id() != candB.prong1Id())) { continue; } - rowBsMcRec(rowDPiMcRec.flagMcMatchRec(), rowDPiMcRec.flagWrongCollision(), rowDPiMcRec.debugMcRec(), rowDPiMcRec.ptMother()); + rowBsMcRec(rowDPiMcRec.flagMcMatchRec(), -1 /*channel*/, rowDPiMcRec.flagWrongCollision(), rowDPiMcRec.debugMcRec(), rowDPiMcRec.ptMother()); filledMcInfo = true; if constexpr (checkDecayTypeMc) { rowBsMcCheck(rowDPiMcRec.pdgCodeBeautyMother(), @@ -303,7 +317,7 @@ struct HfCandidateCreatorBsReducedExpressions { break; } if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the DsPi creator - rowBsMcRec(0, -1, -1, -1.f); + rowBsMcRec(0, -1, -1, -1, -1.f); if constexpr (checkDecayTypeMc) { rowBsMcCheck(-1, -1, -1, -1, -1, -1); } diff --git a/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx index 062fb658128..f5f8734c652 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx @@ -13,22 +13,40 @@ /// \brief Reconstruction of Resonance candidates /// /// \author Luca Aglietta , Università degli Studi di Torino -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/V0.h" +/// \author Antonio Palasciano , INFN Bari -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" -#include "EventFiltering/PWGHF/HFFilterHelpers.h" - -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" #include "PWGHF/D2H/Core/SelectorCutsRedDataFormat.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "PWGHF/Utils/utilsMcMatching.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -40,16 +58,24 @@ using namespace o2::constants::physics; enum Selections : uint8_t { NoSel = 0, DSel, - V0Sel, - TrackSel, + BachSel, NSelSteps }; -enum DecayChannel : uint8_t { - Ds1ToDstarK0s = 0, - Ds2StarToDplusK0s, - XcToDplusLambda, - LambdaDminus, - DstarTrack + +enum D0Sel : uint8_t { + selectedD0 = 0, + selectedD0Bar +}; + +enum DType : uint8_t { + Dplus = 1, + Dstar, + D0 +}; + +enum BachelorType : uint8_t { + V0 = 1, + Track }; enum V0Type : uint8_t { @@ -58,574 +84,811 @@ enum V0Type : uint8_t { AntiLambda }; -enum DecayTypeMc : uint8_t { - Ds1ToDStarK0ToD0PiK0s = 1, - Ds2StarToDplusK0sToPiKaPiPiPi, - Ds1ToDStarK0ToDPlusPi0K0s, - Ds1ToDStarK0ToD0PiK0sPart, - Ds1ToDStarK0ToD0NoPiK0sPart, - Ds1ToDStarK0ToD0PiK0sOneMu, - Ds2StarToDplusK0sOneMu +enum TrackType : uint8_t { + Pion = 0, + Kaon, + Proton }; -const int nBinsPt = 7; -constexpr double binsPt[nBinsPt + 1] = { - 1., - 2., - 4., - 6., - 8., - 12., - 24., - 1000.}; -auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; - struct HfCandidateCreatorCharmResoReduced { // Produces: Tables with resonance info Produces rowCandidateReso; - Produces rowCandidateResoTrack; - // Optional daughter ML scores table - Produces mlScores; - // Table with candidate indices for MC matching - Produces rowCandidateResoIndices; - - // Configurables - Configurable rejectDV0PairsWithCommonDaughter{"rejectDV0PairsWithCommonDaughter", true, "flag to reject the pairs that share a daughter track if not done in the derived data creation"}; - Configurable keepSideBands{"keepSideBands", false, "flag to keep events from D meson sidebands for backgorund estimation"}; - // QA switch - Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; - Configurable> binsPt{"binsPt", std::vector{vecBinsPt}, "Histogram pT bin limits"}; - // Daughters selection cuts - Configurable> cutsD{"cutsDdaughter", {hf_cuts_d_daughter::cuts[0], hf_cuts_d_daughter::nBinsPt, hf_cuts_d_daughter::nCutVars, hf_cuts_d_daughter::labelsPt, hf_cuts_d_daughter::labelsCutVar}, "D daughter selections"}; - Configurable> binsPtD{"binsPtD", std::vector{hf_cuts_d_daughter::vecBinsPt}, "pT bin limits for D daughter cuts"}; - Configurable> cutsV0{"cutsV0daughter", {hf_cuts_v0_daughter::cuts[0], hf_cuts_v0_daughter::nBinsPt, hf_cuts_v0_daughter::nCutVars, hf_cuts_v0_daughter::labelsPt, hf_cuts_v0_daughter::labelsCutVar}, "V0 daughter selections"}; - Configurable> binsPtV0{"binsPtV0", std::vector{hf_cuts_v0_daughter::vecBinsPt}, "pT bin limits for V0 daughter cuts"}; - - // Configurables for ME - Configurable numberEventsMixed{"numberEventsMixed", 5, "Number of events mixed in ME process"}; - Configurable numberEventsToSkip{"numberEventsToSkip", -1, "Number of events to Skip in ME process"}; - ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0., 45., 60., 75., 95, 250}, "event multiplicity pools (PV contributors for now)"}; - ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0, -4, -1, 1, 4, 10.0}, "z vertex position pools"}; - - using HfRed3PrNoTrksWithMl = soa::Join; - - // Partition of V0 candidates based on v0Type - Partition candidatesK0s = aod::hf_reso_v0::v0Type == (uint8_t)1 || aod::hf_reso_v0::v0Type == (uint8_t)3 || aod::hf_reso_v0::v0Type == (uint8_t)5; - Partition candidatesLambda = aod::hf_reso_v0::v0Type == (uint8_t)2 || aod::hf_reso_v0::v0Type == (uint8_t)4; + // Tables with bachelors indices for MC matching and Task + Produces rowCandidateResoIndices3PrV0s; + Produces rowCandidateResoIndicesDstarV0s; + Produces rowCandidateResoIndices2PrV0s; + Produces rowCandidateResoIndices3PrTrks; + Produces rowCandidateResoIndicesDstarTrks; + Produces rowCandidateResoIndices2PrTrks; + // D Configurables + struct : ConfigurableGroup { + std::string prefix = "dmesonsCuts"; + Configurable> binsPtD{"binsPtD", std::vector{hf_cuts_d_daughter::vecBinsPt}, "pT bin limits for D daughter cuts"}; + Configurable> cutsD{"cutsD", {hf_cuts_d_daughter::Cuts[0], hf_cuts_d_daughter::NBinsPt, hf_cuts_d_daughter::NCutVars, hf_cuts_d_daughter::labelsPt, hf_cuts_d_daughter::labelsCutVar}, "D daughter selections"}; + Configurable keepSideBands{"keepSideBands", false, "flag to keep events from D meson sidebands for backgorund estimation"}; + } cfgDmesCuts; + // V0 cuts configurables + struct : ConfigurableGroup { + std::string prefix = "v0Cuts"; + Configurable> cutsV0{"cutsV0", {hf_cuts_v0_daughter::Cuts[0], hf_cuts_v0_daughter::NBinsPt, hf_cuts_v0_daughter::NCutVars, hf_cuts_v0_daughter::labelsPt, hf_cuts_v0_daughter::labelsCutVar}, "V0 daughter selections"}; + Configurable> binsPtV0{"binsPtV0", std::vector{hf_cuts_v0_daughter::vecBinsPt}, "pT bin limits for V0 daughter cuts"}; + Configurable v0Type{"v0Type", 0, "V0 type to be selected (0: K0s, 1: Lambda"}; + } cfgV0Cuts; + // Track cuts configurables + struct : ConfigurableGroup { + std::string prefix = "trackCuts"; + Configurable> cutsTrk{"cutsTrk", {hf_cuts_track_daughter::Cuts[0], hf_cuts_track_daughter::NCutVars, hf_cuts_track_daughter::labelsCutVar}, "Track daughter selections, set to -1 to disable cuts"}; + Configurable massHypo{"massHypo", 1, "Mass Hypothesis for the track daughters (0: pion, 1: kaon, 2: proton)"}; + } cfgTrackCuts; + // Mixed Event configurables + struct : ConfigurableGroup { + std::string prefix = "mixedEvent"; + Configurable numberEventsMixed{"numberEventsMixed", 5, "Number of events mixed in ME process"}; + Configurable numberEventsToSkip{"numberEventsToSkip", -1, "Number of events to Skip in ME process"}; + ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0., 45., 60., 75., 95, 250}, "event multiplicity pools (PV contributors for now)"}; + ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0, -4, -1, 1, 4, 10.0}, "z vertex position pools"}; + } cfgMixedEvent; + // Histogram axes configurables + struct : ConfigurableGroup { + std::string prefix = "histAxes"; + ConfigurableAxis axisPtD{"axisPtD", {100, 0., 50}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisPtV0{"axisPtV0", {100, 0., 50}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisPtReso{"axisPtReso", {100, 0., 50}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisMassD{"axisMassD", {100, 1.7f, 2.1f}, "inv. mass (D) (GeV/#it{c}^{2})"}; + ConfigurableAxis axisMassV0{"axisMassV0", {100, 0.45f, 0.55f}, "inv. mass (V_{0}) (GeV/#it{c}^{2})"}; + ConfigurableAxis axisMassDsj{"axisMassDsj", {400, 0.49f, 0.89f}, "inv. mass (DV_{0}) (GeV/#it{c}^{2})"}; + } cfgHistAxes; + // Other Configurables + Configurable rejectPairsWithCommonDaughter{"rejectPairsWithCommonDaughter", true, "flag to reject the pairs that share a daughter track if not done in the derived data creation"}; + Configurable useDeltaMass{"useDeltaMass", true, "Use Delta Mass for resonance invariant Mass calculation"}; SliceCache cache; Preslice candsV0PerCollision = aod::hf_track_index_reduced::hfRedCollisionId; Preslice candsTrackPerCollision = aod::hf_track_index_reduced::hfRedCollisionId; - Preslice candsDPerCollision = hf_track_index_reduced::hfRedCollisionId; - Preslice candsDPerCollisionWithMl = hf_track_index_reduced::hfRedCollisionId; + Preslice cands3PrPerCollision = hf_track_index_reduced::hfRedCollisionId; + Preslice candsDstarPerCollision = hf_track_index_reduced::hfRedCollisionId; + Preslice cands2PrPerCollision = hf_track_index_reduced::hfRedCollisionId; HistogramRegistry registry{"registry"}; void init(InitContext const&) { - // check that only one process function is enabled - std::array doprocess{doprocessDs2StarToDplusK0s, doprocessDs2StarToDplusK0sWithMl, doprocessDs1ToDstarK0s, doprocessDs1ToDstarK0sWithMl, doprocessDs1ToDstarK0sMixedEvent, doprocessDs1ToDstarK0sMixedEventWithMl, doprocessDs2StarToDplusK0sMixedEventWithMl, - doprocessXcToDplusLambda, doprocessXcToDplusLambdaWithMl, doprocessLambdaDminus, doprocessLambdaDminusWithMl, doprocessDstarTrack, doprocessDstarTrackWithMl}; - if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { - LOGP(fatal, "Only one process function should be enabled! Please check your configuration!"); - } // histograms - const AxisSpec axisPt{(std::vector)vecBinsPt, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec axisMassDsj{400, 0.49f, 0.89f, ""}; - registry.add("hMassDs1", "Ds1 candidates;m_{Ds1} (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisMassDsj, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hMassDs2Star", "Ds^{*}2 candidates; m_Ds^{*}2 (GeV/#it{c}^{2}) ;entries", {HistType::kTH2F, {axisMassDsj, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hMassXcRes", "XcRes candidates; m_XcRes (GeV/#it{c}^{2}) ;entries", {HistType::kTH2F, {{300, 1.1, 1.4}, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hMassLambdaDminus", "LambdaDminus candidates; m_LambdaDminus (GeV/#it{c}^{2}) ;entries", {HistType::kTH2F, {{300, 1.1, 1.4}, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hMassDstarTrack", "DstarTrack candidates; m_DstarTrack (GeV/#it{c}^{2}) ;entries", {HistType::kTH2F, {{100, 0.9, 1.4}, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); - if (doprocessDs1ToDstarK0sMixedEvent) { - registry.add("hNPvContCorr", "Collision number of PV contributors ; N contrib ; N contrib", {HistType::kTH2F, {{100, 0, 250}, {100, 0, 250}}}); - registry.add("hZvertCorr", "Collision Z Vtx ; z PV [cm] ; z PV [cm]", {HistType::kTH2F, {{120, -12., 12.}, {120, -12., 12.}}}); + registry.add("hMassDmesDauVsPt", "D daughter candidates inv. mass", {HistType::kTH2F, {cfgHistAxes.axisMassD, cfgHistAxes.axisPtD}}); + registry.add("hMassV0DauVsPt", "V0 daughter candidates inv. mass", {HistType::kTH2F, {cfgHistAxes.axisMassV0, cfgHistAxes.axisPtV0}}); + registry.add("hMassResoVsPt", "Resonance candidates inv. mass", {HistType::kTH2F, {cfgHistAxes.axisMassDsj, cfgHistAxes.axisPtReso}}); + registry.add("hNPvContCorr", "Collision number of PV contributors ; N contrib ; N contrib", {HistType::kTH2F, {{100, 0, 250}, {100, 0, 250}}}); + registry.add("hZvertCorr", "Collision Z Vtx ; z PV [cm] ; z PV [cm]", {HistType::kTH2F, {{120, -12., 12.}, {120, -12., 12.}}}); + constexpr int kNBinsSelections = Selections::NSelSteps; + std::string labels[kNBinsSelections]; + labels[Selections::NoSel] = "No selection"; + labels[Selections::DSel] = "D Candidates Selection"; + labels[Selections::BachSel] = "D & other bach. Selection"; + static const AxisSpec axisSelections = {kNBinsSelections, 0.5, kNBinsSelections + 0.5, ""}; + registry.add("hSelections", "Selections", {HistType::kTH1F, {axisSelections}}); + for (int iBin = 0; iBin < kNBinsSelections; ++iBin) { + registry.get(HIST("hSelections"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); } + } - if (activateQA) { - constexpr int kNBinsSelections = Selections::NSelSteps; - std::string labels[kNBinsSelections]; - labels[Selections::NoSel] = "No selection"; - labels[Selections::DSel] = "D Candidates Selection"; - labels[Selections::V0Sel] = "D & V0 candidate Selection"; - labels[Selections::TrackSel] = "D & Track candidate Selection"; - static const AxisSpec axisSelections = {kNBinsSelections, 0.5, kNBinsSelections + 0.5, ""}; - registry.add("hSelections", "Selections", {HistType::kTH1F, {axisSelections}}); - for (int iBin = 0; iBin < kNBinsSelections; ++iBin) { - registry.get(HIST("hSelections"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); - } + bool isInMassInterval(float invMass, int ptBin) + { + if (!cfgDmesCuts.keepSideBands) { + return (invMass >= cfgDmesCuts.cutsD->get(ptBin, "invMassSignalLow") && invMass <= cfgDmesCuts.cutsD->get(ptBin, "invMassSignalHigh")); + } else { + return ((invMass >= cfgDmesCuts.cutsD->get(ptBin, "invMassLeftSBLow") && invMass <= cfgDmesCuts.cutsD->get(ptBin, "invMassLeftSBHigh")) || + (invMass >= cfgDmesCuts.cutsD->get(ptBin, "invMassRightSBLow") && invMass <= cfgDmesCuts.cutsD->get(ptBin, "invMassRightSBHigh")) || + (invMass >= cfgDmesCuts.cutsD->get(ptBin, "invMassSignalLow") && invMass <= cfgDmesCuts.cutsD->get(ptBin, "invMassSignalHigh"))); } } /// Basic selection of D candidates /// \param candD is the reduced D meson candidate /// \return true if selections are passed - template - bool isDSelected(DRedTable const& candD) + template + uint8_t selctionFlagBachD(DRedTable const& candD) { + uint8_t selection = {BIT(D0Sel::selectedD0) | BIT(D0Sel::selectedD0Bar)}; float invMassD{0.}; float ptD = candD.pt(); - int ptBin = findBin(binsPtD, ptD); + int ptBin = findBin(cfgDmesCuts.binsPtD, ptD); if (ptBin == -1) { - return false; + return 0; } - if (channel == DecayChannel::Ds2StarToDplusK0s || channel == DecayChannel::XcToDplusLambda || channel == DecayChannel::LambdaDminus) { + if constexpr (dType == DType::Dplus) { invMassD = candD.invMassDplus(); - } else if (channel == DecayChannel::Ds1ToDstarK0s || channel == DecayChannel::DstarTrack) { - if (candD.dType() > 0) + if (!isInMassInterval(invMassD, ptBin)) { + return 0; + } + } else if constexpr (dType == DType::Dstar) { + if (candD.sign() > 0) { invMassD = candD.invMassDstar() - candD.invMassD0(); - else + } else { invMassD = candD.invMassAntiDstar() - candD.invMassD0Bar(); - } - // invariant mass selection - if (!keepSideBands) { - if (invMassD < cutsD->get(ptBin, "invMassSignalLow") || invMassD > cutsD->get(ptBin, "invMassSignalHigh")) { - return false; } - } else { - if ((invMassD < cutsD->get(ptBin, "invMassLeftSBLow")) || - (invMassD > cutsD->get(ptBin, "invMassLeftSBHigh") && invMassD < cutsD->get(ptBin, "invMassSignalLow")) || - (invMassD > cutsD->get(ptBin, "invMassSignalHigh") && invMassD < cutsD->get(ptBin, "invMassRightSBLow")) || - (invMassD > cutsD->get(ptBin, "invMassRightSBHigh"))) { - return false; + if (!isInMassInterval(invMassD, ptBin)) { + return 0; + } + } else if constexpr (dType == DType::D0) { + if (TESTBIT(candD.selFlagD0(), D0Sel::selectedD0)) { + invMassD = candD.invMassD0(); + if (!isInMassInterval(invMassD, ptBin)) { + CLRBIT(selection, D0Sel::selectedD0); + } + } else { + CLRBIT(selection, D0Sel::selectedD0); + } + if (TESTBIT(candD.selFlagD0(), D0Sel::selectedD0Bar)) { + invMassD = candD.invMassD0Bar(); + if (!isInMassInterval(invMassD, ptBin)) { + CLRBIT(selection, D0Sel::selectedD0Bar); + } + } else { + CLRBIT(selection, D0Sel::selectedD0Bar); } } - return true; + return selection; } /// Basic selection of V0 and track candidates /// \param candV0 is the reduced V0 candidate - /// \param candD is the reduced D meson candidate /// \return true if selections are passed - template - bool isV0Selected(V0RedTable const& candV0, DRedTable const& candD) + template + bool isV0Selected(V0RedTable const& candV0) { - float massV0{0.}; - float invMassV0{0.}; - float ptV0 = candV0.pt(); - int ptBin = findBin(binsPtV0, ptV0); + int ptBin = findBin(cfgV0Cuts.binsPtV0, candV0.pt()); if (ptBin == -1) { return false; } - if (channel == DecayChannel::Ds2StarToDplusK0s || channel == DecayChannel::Ds1ToDstarK0s) { - massV0 = MassK0Short; - invMassV0 = candV0.invMassK0s(); - } else if (channel == DecayChannel::XcToDplusLambda || channel == DecayChannel::LambdaDminus) { - massV0 = MassLambda; - int wsFact{1}; - if (channel == DecayChannel::LambdaDminus) - wsFact = -1; - uint8_t targetV0Type{0}; - if (wsFact * candD.dType() > 0) { - invMassV0 = candV0.invMassLambda(); - targetV0Type = V0Type::Lambda; - } else { - invMassV0 = candV0.invMassAntiLambda(); - targetV0Type = V0Type::AntiLambda; + if (cfgV0Cuts.v0Type == V0Type::K0s) { // K0s + if (!TESTBIT(candV0.v0Type(), V0Type::K0s)) { + return false; } - // check skimming cuts - if (!TESTBIT(candV0.v0Type(), targetV0Type)) { + if ((candV0.invMassK0s() - MassK0Short) > cfgV0Cuts.cutsV0->get(ptBin, "invMassLow") && (MassK0Short - candV0.invMassK0s()) < cfgV0Cuts.cutsV0->get(ptBin, "invMassLow")) { return false; } - } - // selection on V0 candidate mass - if ((invMassV0 - massV0) > cutsV0->get(ptBin, "invMassLow") && (massV0 - invMassV0) < cutsV0->get(ptBin, "invMassLow")) { + } else if (cfgV0Cuts.v0Type == V0Type::Lambda) { // Lambda + if (!TESTBIT(candV0.v0Type(), V0Type::Lambda) && !TESTBIT(candV0.v0Type(), V0Type::AntiLambda)) { + return false; + } + if ((candV0.invMassLambda() - MassLambda) > cfgV0Cuts.cutsV0->get(ptBin, "invMassLow") && (MassLambda - candV0.invMassLambda()) < cfgV0Cuts.cutsV0->get(ptBin, "invMassLow")) { + return false; + } + if ((candV0.invMassAntiLambda() - MassLambda) > cfgV0Cuts.cutsV0->get(ptBin, "invMassLow") && (MassLambda - candV0.invMassAntiLambda()) < cfgV0Cuts.cutsV0->get(ptBin, "invMassLow")) { + return false; + } + } else { + LOG(error) << "Unsupported V0 type for selection: " << cfgV0Cuts.v0Type; return false; } // selection on kinematics and topology - if (candV0.dca() > cutsV0->get(ptBin, "dcaMax") || candV0.cpa() < cutsV0->get(ptBin, "cpaMin") || candV0.v0Radius() < cutsV0->get(ptBin, "radiusMin")) { + if (candV0.dca() > cfgV0Cuts.cutsV0->get(ptBin, "dcaMax") || candV0.cpa() < cfgV0Cuts.cutsV0->get(ptBin, "cpaMin") || candV0.v0Radius() < cfgV0Cuts.cutsV0->get(ptBin, "radiusMin")) { return false; } return true; } - template - void runCandidateCreation(Coll const& collision, - DRedTable const& candsD, - V0TrRedTable const& candsV0Tr) + // Basic selection of track candidates + /// \param candTr is the reduced track candidate + /// \return true if selections are passed + template + bool isTrackSelected(TrkRedTable const& candTr) { - // loop on D candidates - for (const auto& candD : candsD) { - // selection of D candidates - if (activateQA) { - registry.fill(HIST("hSelections"), 1); + // pT selection + if (cfgTrackCuts.cutsTrk->get("ptMin") > 0 && candTr.pt() < cfgTrackCuts.cutsTrk->get("ptMin")) { + return false; + } + // ITS quality selection + if (cfgTrackCuts.cutsTrk->get("itsNClsMin") > 0 && candTr.itsNCls() < cfgTrackCuts.cutsTrk->get("itsNClsMin")) { + return false; + } + // TPC quality selection + if (cfgTrackCuts.cutsTrk->get("tpcNCrossedRowsMin") > 0 && candTr.tpcNClsCrossedRows() < cfgTrackCuts.cutsTrk->get("tpcNCrossedRowsMin")) { + return false; + } + if (cfgTrackCuts.cutsTrk->get("tpcChi2Max") > 0 && candTr.tpcChi2NCl() > cfgTrackCuts.cutsTrk->get("tpcChi2Max")) { + return false; + } + // PID selection + if (cfgTrackCuts.massHypo == TrackType::Pion) { // Pion + if (cfgTrackCuts.cutsTrk->get("nSigmaTpc") > 0 && candTr.tpcNSigmaPi() > cfgTrackCuts.cutsTrk->get("nSigmaTpc")) { + return false; } - if (!isDSelected(candD)) { - continue; + if (cfgTrackCuts.cutsTrk->get("nSigmaTof") > 0 && candTr.tofNSigmaPi() > cfgTrackCuts.cutsTrk->get("nSigmaTof")) { + return false; + } + if (cfgTrackCuts.cutsTrk->get("nSigmaComb") > 0 && candTr.tpcTofNSigmaPi() > cfgTrackCuts.cutsTrk->get("nSigmaComb")) { + return false; + } + } else if (cfgTrackCuts.massHypo == TrackType::Kaon) { // Kaon + if (cfgTrackCuts.cutsTrk->get("nSigmaTpc") > 0 && candTr.tpcNSigmaKa() > cfgTrackCuts.cutsTrk->get("nSigmaTpc")) { + return false; + } + if (cfgTrackCuts.cutsTrk->get("nSigmaTof") > 0 && candTr.tofNSigmaKa() > cfgTrackCuts.cutsTrk->get("nSigmaTof")) { + return false; + } + if (cfgTrackCuts.cutsTrk->get("nSigmaComb") > 0 && candTr.tpcTofNSigmaKa() > cfgTrackCuts.cutsTrk->get("nSigmaComb")) { + return false; + } + } else if (cfgTrackCuts.massHypo == TrackType::Proton) { // Proton + if (cfgTrackCuts.cutsTrk->get("nSigmaTpc") > 0 && candTr.tpcNSigmaPr() > cfgTrackCuts.cutsTrk->get("nSigmaTpc")) { + return false; } - if (activateQA) { - registry.fill(HIST("hSelections"), 1 + Selections::DSel); + if (cfgTrackCuts.cutsTrk->get("nSigmaTof") > 0 && candTr.tofNSigmaPr() > cfgTrackCuts.cutsTrk->get("nSigmaTof")) { + return false; } - float invMassD{0.}; - float invMassD0{0.}; - if (std::abs(candD.dType()) == 1) - invMassD = candD.invMassDplus(); - if (candD.dType() == 2) { + if (cfgTrackCuts.cutsTrk->get("nSigmaComb") > 0 && candTr.tpcTofNSigmaPr() > cfgTrackCuts.cutsTrk->get("nSigmaComb")) { + return false; + } + } else { + LOG(error) << "Unsupported mass hypothesis for track selection: " << cfgTrackCuts.massHypo; + return false; + } + return true; + } + + /// Fill the output tables with the resonance candidates + /// \param collision is the collision information + /// \param candD is the reduced D meson candidate + /// \param candV0Tr is the reduced V0 or track candidate + /// \tparam dType is the type of D meson (Dplus, Dstar, D0) + /// \tparam bachType is the type of bachelor (V0 or Track) + template + void fillOutputTables(Coll const& collision, + DRedTable const& candD, + V0TrRedTable const& candV0Tr, + int selectionFlag) + { + std::vector> pVectorCharmProngs = {candD.pVectorProng0(), candD.pVectorProng1()}; + std::array pVecD = candD.pVector(); + std::array pVecV0Tr = candV0Tr.pVector(); + float invMassReso{-1}, invMassV0Tr{-1}, invMassD{-1}; + int8_t signReso{0}, isWrongSign{0}; + double ptReso = RecoDecay::pt(RecoDecay::sumOfVec(pVecV0Tr, pVecD)); + + if constexpr (dType == DType::Dplus) { + invMassD = candD.invMassDplus(); + pVectorCharmProngs.push_back(candD.pVectorProng2()); + if constexpr (bachType == BachelorType::V0) { + if (cfgV0Cuts.v0Type == V0Type::K0s) { // K0s + invMassV0Tr = candV0Tr.invMassK0s(); + signReso = candD.sign(); + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0Short}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassK0Short}); + } + } else if (cfgV0Cuts.v0Type == V0Type::Lambda) { // Lambda + if (candV0Tr.v0Type() == V0Type::Lambda) { + invMassV0Tr = candV0Tr.invMassLambda(); + signReso = candD.sign(); + } else if (candV0Tr.v0Type() == V0Type::AntiLambda) { + invMassV0Tr = candV0Tr.invMassAntiLambda(); + signReso = candD.sign(); + isWrongSign = 1; + } + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassLambda}); + } + } + rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], + pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], + invMassReso, + invMassD, + invMassV0Tr, + signReso, + isWrongSign); + rowCandidateResoIndices3PrV0s(collision.globalIndex(), candD.globalIndex(), candV0Tr.globalIndex()); + registry.fill(HIST("hMassResoVsPt"), invMassReso, ptReso); + registry.fill(HIST("hMassDmesDauVsPt"), invMassD, candD.pt()); + registry.fill(HIST("hMassV0DauVsPt"), invMassV0Tr, candV0Tr.pt()); + } else if constexpr (bachType == BachelorType::Track) { + signReso = candD.sign() + candV0Tr.sign(); + isWrongSign = candD.sign() * candV0Tr.sign() > 0 ? 1 : 0; + if (cfgTrackCuts.massHypo == TrackType::Pion) { // Pion + invMassV0Tr = MassPiPlus; + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassPiPlus}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassPiPlus}); + } + } else if (cfgTrackCuts.massHypo == TrackType::Kaon) { // Kaon + invMassV0Tr = MassKPlus; + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassKPlus}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassKPlus}); + } + } else if (cfgTrackCuts.massHypo == TrackType::Proton) { // Proton + invMassV0Tr = MassProton; + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassProton}); + } + } + rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], + pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], + invMassReso, + invMassD, + invMassV0Tr, + signReso, + isWrongSign); + rowCandidateResoIndices3PrTrks(collision.globalIndex(), candD.globalIndex(), candV0Tr.globalIndex()); + registry.fill(HIST("hMassResoVsPt"), invMassReso, ptReso); + registry.fill(HIST("hMassDmesDauVsPt"), invMassD, candD.pt()); + registry.fill(HIST("hMassV0DauVsPt"), invMassV0Tr, candV0Tr.pt()); + } + } else if constexpr (dType == DType::Dstar) { + float invMassD0; + if (candD.sign() > 0) { invMassD = candD.invMassDstar(); invMassD0 = candD.invMassD0(); - } - if (candD.dType() == -2) { + } else { invMassD = candD.invMassAntiDstar(); invMassD0 = candD.invMassD0Bar(); } - std::array pVecD = {candD.px(), candD.py(), candD.pz()}; - - // loop on V0 or track candidates - bool alreadyCounted{false}; - for (const auto& candV0Tr : candsV0Tr) { - if (rejectDV0PairsWithCommonDaughter) { - const std::array dDaughtersIDs = {candD.prong0Id(), candD.prong1Id(), candD.prong2Id()}; - if constexpr (channel == DecayChannel::DstarTrack) { - if (std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0Tr.globalIndex()) != dDaughtersIDs.end()) { - continue; + pVectorCharmProngs.push_back(candD.pVectorProng2()); + if constexpr (bachType == BachelorType::V0) { + signReso = candD.sign(); + if (cfgV0Cuts.v0Type == V0Type::K0s) { // K0s + invMassV0Tr = candV0Tr.invMassK0s(); + if (useDeltaMass) { + if (candD.sign() > 0) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0Short}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[1], pVectorCharmProngs[0], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0Short}) - invMassD; } } else { - if (std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0Tr.prong0Id()) != dDaughtersIDs.end() || std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0Tr.prong1Id()) != dDaughtersIDs.end()) { - continue; - } + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDStar, MassK0Short}); } - } - if constexpr (channel != DecayChannel::DstarTrack) { - if (!isV0Selected(candV0Tr, candD)) { - continue; + } else if (cfgV0Cuts.v0Type == V0Type::Lambda) { // Lambda + if (candV0Tr.v0Type() == V0Type::Lambda) { + invMassV0Tr = candV0Tr.invMassLambda(); + } else if (candV0Tr.v0Type() == V0Type::AntiLambda) { + invMassV0Tr = candV0Tr.invMassAntiLambda(); + isWrongSign = 1; } - if (activateQA && !alreadyCounted) { - registry.fill(HIST("hSelections"), 1 + Selections::V0Sel); - alreadyCounted = true; + if (useDeltaMass) { + if (candD.sign() > 0) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[1], pVectorCharmProngs[0], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}) - invMassD; + } + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDStar, MassLambda}); } } - - float invMassReso{0.}; - float invMassV0{0.}; - std::array pVecV0Tr = {candV0Tr.px(), candV0Tr.py(), candV0Tr.pz()}; - std::array, 3> pVectorCharmProngs = {candD.pVectorProng0(), candD.pVectorProng1(), candD.pVectorProng2()}; - float ptReso = RecoDecay::pt(RecoDecay::sumOfVec(pVecV0Tr, pVecD)); - - if constexpr (channel == DecayChannel::DstarTrack) { - if (candD.dType() > 0) { - invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); + rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], + pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], + invMassReso, + invMassD - invMassD0, + invMassV0Tr, + signReso, + isWrongSign); + rowCandidateResoIndicesDstarV0s(collision.globalIndex(), candD.globalIndex(), candV0Tr.globalIndex()); + registry.fill(HIST("hMassResoVsPt"), invMassReso, ptReso); + registry.fill(HIST("hMassDmesDauVsPt"), invMassD - invMassD0, candD.pt()); + registry.fill(HIST("hMassV0DauVsPt"), invMassV0Tr, candV0Tr.pt()); + } else if constexpr (bachType == BachelorType::Track) { + signReso = candD.sign() + candV0Tr.sign(); + isWrongSign = candD.sign() * candV0Tr.sign() > 0 ? 1 : 0; + if (cfgTrackCuts.massHypo == TrackType::Pion) { // Pion + invMassV0Tr = MassPiPlus; + if (useDeltaMass) { + if (candD.sign() > 0) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassPiPlus}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[1], pVectorCharmProngs[0], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassPiPlus}) - invMassD; + } } else { - invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[1], pVectorCharmProngs[0], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDStar, MassPiPlus}); } - registry.fill(HIST("hMassDstarTrack"), invMassReso - invMassD, ptReso); - } else { - switch (channel) { - case DecayChannel::Ds1ToDstarK0s: - invMassV0 = candV0Tr.invMassK0s(); - if (candD.dType() > 0) { - invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0Short}) - invMassD; - } else { - invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[1], pVectorCharmProngs[0], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0Short}) - invMassD; - } - registry.fill(HIST("hMassDs1"), invMassReso, ptReso); - break; - case DecayChannel::Ds2StarToDplusK0s: - invMassV0 = candV0Tr.invMassK0s(); - invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0Short}) - invMassD; - registry.fill(HIST("hMassDs2Star"), invMassReso, ptReso); - break; - case DecayChannel::XcToDplusLambda: - if (candD.dType() > 0) { - invMassV0 = candV0Tr.invMassLambda(); - } else { - invMassV0 = candV0Tr.invMassAntiLambda(); - } - invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}) - invMassD; - registry.fill(HIST("hMassXcRes"), invMassReso, ptReso); - break; - case DecayChannel::LambdaDminus: - if (candD.dType() < 0) { - invMassV0 = candV0Tr.invMassLambda(); - } else { - invMassV0 = candV0Tr.invMassAntiLambda(); - } - invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}) - invMassD; - registry.fill(HIST("hMassLambdaDminus"), invMassReso, ptReso); - break; - default: - break; + } else if (cfgTrackCuts.massHypo == TrackType::Kaon) { // Kaon + invMassV0Tr = MassKPlus; + if (useDeltaMass) { + if (candD.sign() > 0) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassKPlus}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[1], pVectorCharmProngs[0], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassKPlus}) - invMassD; + } + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDStar, MassKPlus}); + } + } else if (cfgTrackCuts.massHypo == TrackType::Proton) { // Proton + invMassV0Tr = MassProton; + if (useDeltaMass) { + if (candD.sign() > 0) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[1], pVectorCharmProngs[0], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}) - invMassD; + } + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDStar, MassProton}); } } - // Filling Output table - if constexpr (channel == DecayChannel::DstarTrack) { - rowCandidateResoTrack(pVecD[0], pVecD[1], pVecD[2], - candV0Tr.px(), candV0Tr.py(), candV0Tr.pz(), - invMassReso, - invMassD - invMassD0); - } else { + rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], + pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], + invMassReso, + invMassD - invMassD0, + invMassV0Tr, + signReso, + isWrongSign); + rowCandidateResoIndicesDstarTrks(collision.globalIndex(), candD.globalIndex(), candV0Tr.globalIndex()); + registry.fill(HIST("hMassResoVsPt"), invMassReso, ptReso); + registry.fill(HIST("hMassDmesDauVsPt"), invMassD, candD.pt()); + registry.fill(HIST("hMassV0DauVsPt"), invMassV0Tr, candV0Tr.pt()); + } + } else if constexpr (dType == DType::D0) { + // D0 + if (TESTBIT(selectionFlag, D0Sel::selectedD0)) { + invMassD = candD.invMassD0(); + if constexpr (bachType == BachelorType::V0) { + signReso = 0; + if (cfgV0Cuts.v0Type == V0Type::K0s) { // K0s + invMassV0Tr = candV0Tr.invMassK0s(); + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassK0Short}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0, MassK0Short}); + } + } else if (cfgV0Cuts.v0Type == V0Type::Lambda) { // Lambda + if (candV0Tr.v0Type() == V0Type::Lambda) { + invMassV0Tr = candV0Tr.invMassLambda(); + } else if (candV0Tr.v0Type() == V0Type::AntiLambda) { + invMassV0Tr = candV0Tr.invMassAntiLambda(); + isWrongSign = 1; + } + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassLambda}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0, MassLambda}); + } + } + rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], + pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], + invMassReso, + invMassD, + invMassV0Tr, + signReso, + isWrongSign); + rowCandidateResoIndices2PrV0s(collision.globalIndex(), candD.globalIndex(), candV0Tr.globalIndex()); + registry.fill(HIST("hMassResoVsPt"), invMassReso, ptReso); + registry.fill(HIST("hMassDmesDauVsPt"), invMassD, candD.pt()); + registry.fill(HIST("hMassV0DauVsPt"), invMassV0Tr, candV0Tr.pt()); + } else if constexpr (bachType == BachelorType::Track) { + signReso = candV0Tr.sign(); + isWrongSign = candV0Tr.sign() > 0 ? 0 : 1; + if (cfgTrackCuts.massHypo == TrackType::Pion) { // Pion + invMassV0Tr = MassPiPlus; + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0, MassPiPlus}); + } + } else if (cfgTrackCuts.massHypo == TrackType::Kaon) { // Kaon + invMassV0Tr = MassKPlus; + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassKPlus}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0, MassKPlus}); + } + } else if (cfgTrackCuts.massHypo == TrackType::Proton) { // Proton + invMassV0Tr = MassProton; + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassProton}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0, MassProton}); + } + } rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], invMassReso, invMassD, - invMassV0, - candV0Tr.cpa(), - candV0Tr.dca(), - candV0Tr.v0Radius(), - invMassD0); - rowCandidateResoIndices(collision.globalIndex(), - candD.globalIndex(), - candV0Tr.globalIndex()); + invMassV0Tr, + signReso, + isWrongSign); + rowCandidateResoIndices2PrTrks(collision.globalIndex(), candD.globalIndex(), candV0Tr.globalIndex()); + registry.fill(HIST("hMassResoVsPt"), invMassReso, ptReso); + registry.fill(HIST("hMassDmesDauVsPt"), invMassD, candD.pt()); + registry.fill(HIST("hMassV0DauVsPt"), invMassV0Tr, candV0Tr.pt()); } - if constexpr (fillMl) { - mlScores(candD.mlScoreBkgMassHypo0(), candD.mlScorePromptMassHypo0(), candD.mlScoreNonpromptMassHypo0()); + } + // D0bar + if (TESTBIT(selectionFlag, D0Sel::selectedD0Bar)) { + invMassD = candD.invMassD0Bar(); + if constexpr (bachType == BachelorType::V0) { + signReso = 0; + if (cfgV0Cuts.v0Type == V0Type::K0s) { // K0s + invMassV0Tr = candV0Tr.invMassK0s(); + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassKPlus, MassPiPlus, MassK0Short}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0Bar, MassK0Short}); + } + } else if (cfgV0Cuts.v0Type == V0Type::Lambda) { // Lambda + if (candV0Tr.v0Type() == V0Type::Lambda) { + invMassV0Tr = candV0Tr.invMassLambda(); + isWrongSign = 1; + } else if (candV0Tr.v0Type() == V0Type::AntiLambda) { + invMassV0Tr = candV0Tr.invMassAntiLambda(); + } + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassKPlus, MassPiPlus, MassLambda}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0Bar, MassLambda}); + } + } + rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], + pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], + invMassReso, + invMassD, + invMassV0Tr, + signReso, + isWrongSign); + rowCandidateResoIndices2PrV0s(collision.globalIndex(), candD.globalIndex(), candV0Tr.globalIndex()); + registry.fill(HIST("hMassResoVsPt"), invMassReso, ptReso); + registry.fill(HIST("hMassDmesDauVsPt"), invMassD, candD.pt()); + registry.fill(HIST("hMassV0DauVsPt"), invMassV0Tr, candV0Tr.pt()); + } else if constexpr (bachType == BachelorType::Track) { + signReso = candV0Tr.sign(); + isWrongSign = candV0Tr.sign() > 0 ? 1 : 0; + if (cfgTrackCuts.massHypo == TrackType::Pion) { // Pion + invMassV0Tr = MassPiPlus; + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassKPlus, MassPiPlus, MassPiPlus}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0Bar, MassPiPlus}); + } + } else if (cfgTrackCuts.massHypo == TrackType::Kaon) { // Kaon + invMassV0Tr = MassKPlus; + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassKPlus, MassPiPlus, MassKPlus}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0Bar, MassKPlus}); + } + } else if (cfgTrackCuts.massHypo == TrackType::Proton) { // Proton + invMassV0Tr = MassProton; + if (useDeltaMass) { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[0], pVectorCharmProngs[1], pVecV0Tr}, std::array{MassKPlus, MassPiPlus, MassProton}) - invMassD; + } else { + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassD0Bar, MassProton}); + } + } + rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], + pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], + invMassReso, + invMassD, + invMassV0Tr, + signReso, + isWrongSign); + rowCandidateResoIndices2PrTrks(collision.globalIndex(), candD.globalIndex(), candV0Tr.globalIndex()); + registry.fill(HIST("hMassResoVsPt"), invMassReso, ptReso); + registry.fill(HIST("hMassDmesDauVsPt"), invMassD, candD.pt()); + registry.fill(HIST("hMassV0DauVsPt"), invMassV0Tr, candV0Tr.pt()); } } } - } // main function + } + + template + void runCandidateCreation(Coll const& collision, + DRedTable const& candsD, + V0TrRedTable const& candsV0Tr) + { + // loop on D candidates + // LOG(info) << "Number of D candidates: " << candsD.size() << ", Number of V0/Track candidates: " << candsV0Tr.size(); + for (const auto& candD : candsD) { + // selection of D candidates + registry.fill(HIST("hSelections"), 1); + uint8_t selFlagD = selctionFlagBachD(candD); + if (selFlagD == 0) { + continue; + } + registry.fill(HIST("hSelections"), 1 + Selections::DSel); + std::vector dDaughtersIDs = {candD.prong0Id(), candD.prong1Id()}; + if constexpr (dType == DType::Dstar || dType == DType::Dplus) { + dDaughtersIDs.push_back(candD.prong2Id()); + } + // loop on V0 or track candidates + bool alreadyCounted{false}; + for (const auto& candV0Tr : candsV0Tr) { + if constexpr (bachType == BachelorType::V0) { // Case: V0 + if (rejectPairsWithCommonDaughter && (std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0Tr.prong0Id()) != dDaughtersIDs.end() || std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0Tr.prong1Id()) != dDaughtersIDs.end())) { + continue; + } + if (!isV0Selected(candV0Tr)) { + continue; + } + if (!alreadyCounted) { + registry.fill(HIST("hSelections"), 1 + Selections::BachSel); + alreadyCounted = true; + } + } else if constexpr (bachType == BachelorType::Track) { // Case: Track + if (rejectPairsWithCommonDaughter && std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0Tr.trackId()) != dDaughtersIDs.end()) { + continue; + } + if (!isTrackSelected(candV0Tr)) { + continue; + } + if (!alreadyCounted) { + registry.fill(HIST("hSelections"), 1 + Selections::BachSel); + alreadyCounted = true; + } + } + // Filling of tables and histograms + fillOutputTables(collision, candD, candV0Tr, selFlagD); + } // end of loop on V0/Track candidates + } // end of loop on D candidates + } // end of function + // Process data with Mixed Event /// \tparam fillMl is a flag to Fill ML scores if present /// \tparam channel is the decay channel of the Resonance /// \param Coll is the reduced collisions table /// \param DRedTable is the D bachelors table /// \param V0TrRedTable is the V0/Track bachelors table - template + template void runCandidateCreationMixedEvent(Coll const& collisions, DRedTable const& candsD, V0TrRedTable const& candsV0Tr) { using BinningType = ColumnBinningPolicy; - BinningType corrBinning{{zPoolBins, multPoolBins}, true}; + BinningType corrBinning{{cfgMixedEvent.zPoolBins, cfgMixedEvent.multPoolBins}, true}; auto bachTuple = std::make_tuple(candsD, candsV0Tr); - Pair pairs{corrBinning, numberEventsMixed, numberEventsToSkip, collisions, bachTuple, &cache}; + Pair pairs{corrBinning, cfgMixedEvent.numberEventsMixed, cfgMixedEvent.numberEventsToSkip, collisions, bachTuple, &cache}; for (const auto& [collision1, bachDs, collision2, bachV0Trs] : pairs) { registry.fill(HIST("hNPvContCorr"), collision1.numContrib(), collision2.numContrib()); registry.fill(HIST("hZvertCorr"), collision1.posZ(), collision2.posZ()); for (const auto& [bachD, bachV0Tr] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(bachDs, bachV0Trs))) { // Apply analysis selections on D and V0 bachelors - if (!isDSelected(bachD) || !isV0Selected(bachV0Tr, bachD)) { + uint8_t selFlagD = selctionFlagBachD(bachD); + if (selFlagD == 0) { continue; } - // Retrieve D and V0 informations - float invMassD{0.}; - float invMassD0{0.}; - if (std::abs(bachD.dType()) == 1) - invMassD = bachD.invMassDplus(); - if (bachD.dType() == 2) { - invMassD = bachD.invMassDstar(); - invMassD0 = bachD.invMassD0(); - } - if (bachD.dType() == -2) { - invMassD = bachD.invMassAntiDstar(); - invMassD0 = bachD.invMassD0Bar(); - } - std::array pVecD = {bachD.px(), bachD.py(), bachD.pz()}; - float invMassReso{0.}; - float invMassV0{0.}; - std::array pVecV0Tr = {bachV0Tr.px(), bachV0Tr.py(), bachV0Tr.pz()}; - float ptReso = RecoDecay::pt(RecoDecay::sumOfVec(pVecV0Tr, pVecD)); - switch (channel) { - case DecayChannel::Ds1ToDstarK0s: - invMassV0 = bachV0Tr.invMassK0s(); - invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDStar, MassK0Short}); - registry.fill(HIST("hMassDs1"), invMassReso, ptReso); - break; - case DecayChannel::Ds2StarToDplusK0s: - invMassV0 = bachV0Tr.invMassK0s(); - invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassK0Short}); - registry.fill(HIST("hMassDs2Star"), invMassReso, ptReso); - break; - case DecayChannel::XcToDplusLambda: - if (bachD.dType() > 0) { - invMassV0 = bachV0Tr.invMassLambda(); - } else { - invMassV0 = bachV0Tr.invMassAntiLambda(); - } - invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassLambda}); - registry.fill(HIST("hMassXcRes"), invMassReso, ptReso); - break; - case DecayChannel::LambdaDminus: - if (bachD.dType() < 0) { - invMassV0 = bachV0Tr.invMassLambda(); - } else { - invMassV0 = bachV0Tr.invMassAntiLambda(); - } - invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassLambda}); - registry.fill(HIST("hMassLambdaDminus"), invMassReso, ptReso); - break; - default: - break; - } - // Fill output table - rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], - pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], - invMassReso, - invMassD, - invMassV0, - bachV0Tr.cpa(), - bachV0Tr.dca(), - bachV0Tr.v0Radius(), - invMassD0); - rowCandidateResoIndices(collision1.globalIndex(), - bachD.globalIndex(), - bachV0Tr.globalIndex()); - if constexpr (fillMl) { - mlScores(bachD.mlScoreBkgMassHypo0(), bachD.mlScorePromptMassHypo0(), bachD.mlScoreNonpromptMassHypo0()); + if constexpr (bachType == BachelorType::V0) { + if (!isV0Selected(bachV0Tr)) { + continue; + } + } else if constexpr (bachType == BachelorType::Track) { + if (!isTrackSelected(bachV0Tr)) { + continue; + } } + fillOutputTables(collision1, bachD, bachV0Tr, selFlagD); } } } // runCandidateCreationMixedEvent // List of Process Functions - void processDs2StarToDplusK0s(aod::HfRedCollisions const& collisions, - aod::HfRed3PrNoTrks const& candsD, - aod::HfRedVzeros const&) + void process3ProngV0s(aod::HfRedCollisions const& collisions, + aod::HfRed3PrNoTrks const& candsD, + aod::HfRedVzeros const& candsV0) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); - auto k0sThisColl = candidatesK0s.sliceBy(candsV0PerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, k0sThisColl); + auto candsDThisColl = candsD.sliceBy(cands3PrPerCollision, thisCollId); + auto v0sThisColl = candsV0.sliceBy(candsV0PerCollision, thisCollId); + runCandidateCreation(collision, candsDThisColl, v0sThisColl); } } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs2StarToDplusK0s, "Process Ds2* candidates without ML info", true); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, process3ProngV0s, "Process resonances decaying in a 3 prong D meson and a V0", true); - void processDs2StarToDplusK0sWithMl(aod::HfRedCollisions const& collisions, - soa::Join const& candsD, - aod::HfRedVzeros const&) + void processDstarV0s(aod::HfRedCollisions const& collisions, + aod::HfRedDstarNoTrks const& candsD, + aod::HfRedVzeros const& candsV0) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollisionWithMl, thisCollId); - auto k0sThisColl = candidatesK0s.sliceBy(candsV0PerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, k0sThisColl); + auto candsDThisColl = candsD.sliceBy(candsDstarPerCollision, thisCollId); + auto v0sThisColl = candsV0.sliceBy(candsV0PerCollision, thisCollId); + runCandidateCreation(collision, candsDThisColl, v0sThisColl); } } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs2StarToDplusK0sWithMl, "Process Ds2* candidates with Ml info", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDstarV0s, "Process resonances decaying in a Dstar meson and a V0", false); - void processDs2StarToDplusK0sMixedEvent(aod::HfRedCollisions const& collisions, - aod::HfRed3PrNoTrks const& candsD, - aod::HfRedVzeros const& candsV0) + void process2PrV0s(aod::HfRedCollisions const& collisions, + aod::HfRed2PrNoTrks const& candsD, + aod::HfRedVzeros const& candsV0) { - runCandidateCreationMixedEvent(collisions, candsD, candsV0); - } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs2StarToDplusK0sMixedEvent, "Process Ds2Star mixed Event without ML", false); - - void processDs2StarToDplusK0sMixedEventWithMl(aod::HfRedCollisions const& collisions, - HfRed3PrNoTrksWithMl const& candsD, - aod::HfRedVzeros const& candsV0) - { - runCandidateCreationMixedEvent(collisions, candsD, candsV0); + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD.sliceBy(cands2PrPerCollision, thisCollId); + auto v0sThisColl = candsV0.sliceBy(candsV0PerCollision, thisCollId); + runCandidateCreation(collision, candsDThisColl, v0sThisColl); + } } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs2StarToDplusK0sMixedEventWithMl, "Process Ds2Star mixed Event with ML", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, process2PrV0s, "Process resonances decaying in a 2 prong D meson and a V0", false); - void processDs1ToDstarK0s(aod::HfRedCollisions const& collisions, - aod::HfRed3PrNoTrks const& candsD, - aod::HfRedVzeros const&) + void process3ProngTracks(aod::HfRedCollisions const& collisions, + aod::HfRed3PrNoTrks const& candsD, + HfRedTrkNoParams const& candsTr) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); - auto k0sThisColl = candidatesK0s.sliceBy(candsV0PerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, k0sThisColl); + auto candsDThisColl = candsD.sliceBy(cands3PrPerCollision, thisCollId); + auto trksThisColl = candsTr.sliceBy(candsTrackPerCollision, thisCollId); + runCandidateCreation(collision, candsDThisColl, trksThisColl); } } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs1ToDstarK0s, "Process Ds1 candidates without Ml info", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, process3ProngTracks, "Process resonances decaying in a 3 prong D meson and a Track", false); - void processDs1ToDstarK0sWithMl(aod::HfRedCollisions const& collisions, - HfRed3PrNoTrksWithMl const& candsD, - aod::HfRedVzeros const&) + void processDstarTracks(aod::HfRedCollisions const& collisions, + aod::HfRedDstarNoTrks const& candsD, + HfRedTrkNoParams const& candsTr) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollisionWithMl, thisCollId); - auto k0sThisColl = candidatesK0s.sliceBy(candsV0PerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, k0sThisColl); + auto candsDThisColl = candsD.sliceBy(candsDstarPerCollision, thisCollId); + auto trksThisColl = candsTr.sliceBy(candsTrackPerCollision, thisCollId); + runCandidateCreation(collision, candsDThisColl, trksThisColl); } } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs1ToDstarK0sWithMl, "Process Ds1 candidates with Ml info", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDstarTracks, "Process resonances decaying in a Dstar meson and a Track", false); - void processDs1ToDstarK0sMixedEvent(aod::HfRedCollisions const& collisions, - aod::HfRed3PrNoTrks const& candsD, - aod::HfRedVzeros const& candsV0) + void process2PrTracks(aod::HfRedCollisions const& collisions, + aod::HfRed2PrNoTrks const& candsD, + HfRedTrkNoParams const& candsTr) { - runCandidateCreationMixedEvent(collisions, candsD, candsV0); + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD.sliceBy(cands2PrPerCollision, thisCollId); + auto trksThisColl = candsTr.sliceBy(candsTrackPerCollision, thisCollId); + runCandidateCreation(collision, candsDThisColl, trksThisColl); + } } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs1ToDstarK0sMixedEvent, "Process Ds1 mixed Event without ML", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, process2PrTracks, "Process resonances decaying in a 2 prong D meson and a Track", false); - void processDs1ToDstarK0sMixedEventWithMl(aod::HfRedCollisions const& collisions, - HfRed3PrNoTrksWithMl const& candsD, - aod::HfRedVzeros const& candsV0) + // Mixed Event Process Functions + void process3ProngV0sMixedEvent(aod::HfRedCollisions const& collisions, + aod::HfRed3PrNoTrks const& candsD, + aod::HfRedVzeros const& candsV0) { - runCandidateCreationMixedEvent(collisions, candsD, candsV0); + runCandidateCreationMixedEvent(collisions, candsD, candsV0); } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs1ToDstarK0sMixedEventWithMl, "Process Ds1 mixed Event with ML", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, process3ProngV0sMixedEvent, "Process mixed events for resonances decaying in a 3 prong D meson and a V0", false); - void processXcToDplusLambda(aod::HfRedCollisions const& collisions, - aod::HfRed3PrNoTrks const& candsD, - aod::HfRedVzeros const&) + void processDstarV0sMixedEvent(aod::HfRedCollisions const& collisions, + aod::HfRedDstarNoTrks const& candsD, + aod::HfRedVzeros const& candsV0) { - for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); - auto lambdaThisColl = candidatesLambda.sliceBy(candsV0PerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, lambdaThisColl); - } + runCandidateCreationMixedEvent(collisions, candsD, candsV0); } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processXcToDplusLambda, "Process Xc candidates without Ml info", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDstarV0sMixedEvent, "Process mixed events for resonances decaying in a Dstar meson and a V0", false); - void processXcToDplusLambdaWithMl(aod::HfRedCollisions const& collisions, - HfRed3PrNoTrksWithMl const& candsD, - aod::HfRedVzeros const&) + void process2PrV0sMixedEvent(aod::HfRedCollisions const& collisions, + aod::HfRed2PrNoTrks const& candsD, + aod::HfRedVzeros const& candsV0) { - for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollisionWithMl, thisCollId); - auto lambdaThisColl = candidatesLambda.sliceBy(candsV0PerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, lambdaThisColl); - } + runCandidateCreationMixedEvent(collisions, candsD, candsV0); } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processXcToDplusLambdaWithMl, "Process Xc candidates with Ml info", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, process2PrV0sMixedEvent, "Process mixed events for resonances decaying in a 2 prong D meson and a V0", false); - void processLambdaDminus(aod::HfRedCollisions const& collisions, - aod::HfRed3PrNoTrks const& candsD, - aod::HfRedVzeros const&) + void process3ProngTracksMixedEvent(aod::HfRedCollisions const& collisions, + aod::HfRed3PrNoTrks const& candsD, + HfRedTrkNoParams const& candsTr) { - for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); - auto lambdaThisColl = candidatesLambda.sliceBy(candsV0PerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, lambdaThisColl); - } + runCandidateCreationMixedEvent(collisions, candsD, candsTr); } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processLambdaDminus, "Process LambdaDminus candidates without Ml info", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, process3ProngTracksMixedEvent, "Process mixed events for resonances decaying in a 3 prong D meson and a Track", false); - void processLambdaDminusWithMl(aod::HfRedCollisions const& collisions, - HfRed3PrNoTrksWithMl const& candsD, - aod::HfRedVzeros const&) - { - for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollisionWithMl, thisCollId); - auto lambdaThisColl = candidatesLambda.sliceBy(candsV0PerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, lambdaThisColl); - } - } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processLambdaDminusWithMl, "Process LambdaDminus candidates with Ml info", false); - void processDstarTrack(aod::HfRedCollisions const& collisions, - aod::HfRed3PrNoTrks const& candsD, - aod::HfRedTrkNoParams const& candidatesTrack) + void processDstarTracksMixedEvent(aod::HfRedCollisions const& collisions, + aod::HfRedDstarNoTrks const& candsD, + HfRedTrkNoParams const& candsTr) { - for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); - auto trackThisColl = candidatesTrack.sliceBy(candsTrackPerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, trackThisColl); - } + runCandidateCreationMixedEvent(collisions, candsD, candsTr); } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDstarTrack, "Process DStar candidates without Ml info", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDstarTracksMixedEvent, "Process mixed events for resonances decaying in a Dstar meson and a Track", false); - void processDstarTrackWithMl(aod::HfRedCollisions const& collisions, - HfRed3PrNoTrksWithMl const& candsD, - aod::HfRedTrkNoParams const& candidatesTrack) + void process2PrTracksMixedEvent(aod::HfRedCollisions const& collisions, + aod::HfRed2PrNoTrks const& candsD, + HfRedTrkNoParams const& candsTr) { - for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollisionWithMl, thisCollId); - auto trackThisColl = candidatesTrack.sliceBy(candsTrackPerCollision, thisCollId); - runCandidateCreation(collision, candsDThisColl, trackThisColl); - } + runCandidateCreationMixedEvent(collisions, candsD, candsTr); } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDstarTrackWithMl, "Process DStar candidates with Ml info", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, process2PrTracksMixedEvent, "Process mixed events for resonances decaying in a 2 prong D meson and a Track", false); }; // struct HfCandidateCreatorCharmResoReduced @@ -633,14 +896,18 @@ struct HfCandidateCreatorCharmResoReducedExpressions { Produces rowResoMcRec; - using CandResoWithIndices = soa::Join; + using CandResoWithIndices2PrV0s = soa::Join; + using CandResoWithIndices2PrTrks = soa::Join; + using CandResoWithIndices3PrV0s = soa::Join; + using CandResoWithIndices3PrTrks = soa::Join; + using CandResoWithIndicesDstarV0s = soa::Join; + using CandResoWithIndicesDstarTrks = soa::Join; // Configurable axis ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "#it{p}_{T} (GeV/#it{c})"}; ConfigurableAxis axisInvMassReso{"axisInvMassReso", {400, 0.49f, 0.89f}, "inv. mass (DV_{0}) (GeV/#it{c}^{2})"}; ConfigurableAxis axisInvMassProng0{"axisInvMassProng0", {200, 0.14, 0.17}, "inv. mass (D) (GeV/#it{c}^{2})"}; ConfigurableAxis axisInvMassProng1{"axisInvMassProng1", {200, 0.47, 0.53}, "inv. mass ({V}_{0}) (GeV/#it{c}^{2})"}; - ConfigurableAxis axisInvMassD0{"axisInvMassD0", {200, 1.65, 2.05}, "inv. mass ({V}_{0}) (GeV/#it{c}^{2})"}; ConfigurableAxis axisDebug{"axisDebug", {16, -0.5, 15.5}, "MC debug flag"}; ConfigurableAxis axisOrigin{"axisOrigin", {3, -0.5, 2.5}, "MC origin flag"}; HistogramRegistry registry{"registry"}; @@ -651,64 +918,83 @@ struct HfCandidateCreatorCharmResoReducedExpressions { registry.add("hMassMcMatchedIncomplete", "Reso MC candidates Matched with generate particle w. Invcomplete decay;m (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisInvMassReso, axisPt}}); registry.add("hMassMcUnmatched", "Reso MC candidates NOT Matched with generate particle;m (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisInvMassReso, axisPt}}); registry.add("hMassMcNoEntry", "Reso MC candidates w.o. entry in MC Reco table;m (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisInvMassReso, axisPt}}); - registry.add("hMassMcMatchedVsBach0Mass", "Reso MC candidates Matched with generate particle;m (GeV/#it{c}^{2}); m (GeV/#it{c}^{2})", {HistType::kTH2F, {axisInvMassReso, axisInvMassProng0}}); - registry.add("hMassMcUnmatchedVsBach0Mass", "Reso MC candidates Matched with generate particle w. Invcomplete decay;m (GeV/#it{c}^{2}); m (GeV/#it{c}^{2})", {HistType::kTH2F, {axisInvMassReso, axisInvMassProng0}}); - registry.add("hMassMcMatchedVsBach1Mass", "Reso MC candidates NOT Matched with generate particle;m (GeV/#it{c}^{2}); m (GeV/#it{c}^{2})", {HistType::kTH2F, {axisInvMassReso, axisInvMassProng1}}); - registry.add("hMassMcUnmatchedVsBach1Mass", "Reso MC candidates Matched with generate particle w. Invcomplete decay;m (GeV/#it{c}^{2}); m (GeV/#it{c}^{2})", {HistType::kTH2F, {axisInvMassReso, axisInvMassProng1}}); - registry.add("hMassMcMatchedVsD0Mass", "Reso MC candidates NOT Matched with generate particle;m (GeV/#it{c}^{2}); m (GeV/#it{c}^{2})", {HistType::kTH2F, {axisInvMassReso, axisInvMassD0}}); - registry.add("hMassMcUnmatchedVsD0Mass", "Reso MC candidates Matched with generate particle w. Invcomplete decay;m (GeV/#it{c}^{2}); m (GeV/#it{c}^{2})", {HistType::kTH2F, {axisInvMassReso, axisInvMassD0}}); - registry.add("hMassMcUnmatchedVsDebug", "Reso MC candidates NOT Matched with generate particle;m (GeV/#it{c}^{2});debug flag", {HistType::kTH2F, {axisInvMassReso, axisDebug}}); - registry.add("hSparseUnmatchedDebug", "THn for debug of MC matching and Correlated BKG study", HistType::kTHnSparseF, {axisInvMassReso, axisPt, axisInvMassProng0, axisInvMassProng1, axisInvMassD0, axisDebug, axisOrigin}); } /// Fill candidate information at MC reconstruction level - /// \param rowsDV0McRec MC reco information on DPi pairs + /// \param rowsMcRec MC reco information on DPi pairs /// \param candsReso prong global indices of B0 candidates - template - void fillResoMcRec(McRec const& rowsDV0McRec, CandResoWithIndices const& candsReso) + template + void fillResoMcRec(McRec const& rowsMcRec, CandResoWithIndices const& candsReso) { for (const auto& candReso : candsReso) { bool filledMcInfo{false}; - for (const auto& rowDV0McRec : rowsDV0McRec) { + for (const auto& rowDV0McRec : rowsMcRec) { if ((rowDV0McRec.prong0Id() != candReso.prong0Id()) || (rowDV0McRec.prong1Id() != candReso.prong1Id())) { continue; } - rowResoMcRec(rowDV0McRec.flagMcMatchRec(), rowDV0McRec.debugMcRec(), rowDV0McRec.origin(), rowDV0McRec.ptMother()); + rowResoMcRec(rowDV0McRec.flagMcMatchRec(), + rowDV0McRec.flagMcMatchRecD(), + rowDV0McRec.flagMcMatchChanD(), + rowDV0McRec.debugMcRec(), + rowDV0McRec.origin(), + rowDV0McRec.ptGen(), + rowDV0McRec.invMassGen()); filledMcInfo = true; - if (std::abs(rowDV0McRec.flagMcMatchRec()) == DecayTypeMc::Ds1ToDStarK0ToD0PiK0s || std::abs(rowDV0McRec.flagMcMatchRec()) == DecayTypeMc::Ds2StarToDplusK0sToPiKaPiPiPi || - std::abs(rowDV0McRec.flagMcMatchRec()) == DecayTypeMc::Ds1ToDStarK0ToD0PiK0sOneMu || std::abs(rowDV0McRec.flagMcMatchRec()) == DecayTypeMc::Ds2StarToDplusK0sOneMu) { + if (std::abs(rowDV0McRec.flagMcMatchRec()) > 0 && + !TESTBIT(rowDV0McRec.debugMcRec(), hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched)) { registry.fill(HIST("hMassMcMatched"), candReso.invMass(), candReso.pt()); - registry.fill(HIST("hMassMcMatchedVsBach0Mass"), candReso.invMass(), candReso.invMassProng0() - candReso.invMassD0()); - registry.fill(HIST("hMassMcMatchedVsBach1Mass"), candReso.invMass(), candReso.invMassProng1()); - registry.fill(HIST("hMassMcMatchedVsD0Mass"), candReso.invMass(), candReso.invMassD0()); - - } else if (std::abs(rowDV0McRec.flagMcMatchRec()) == DecayTypeMc::Ds1ToDStarK0ToD0NoPiK0sPart || std::abs(rowDV0McRec.flagMcMatchRec()) == DecayTypeMc::Ds1ToDStarK0ToDPlusPi0K0s) { + } else if (std::abs(rowDV0McRec.flagMcMatchRec()) > 0 && + TESTBIT(rowDV0McRec.debugMcRec(), hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched)) { registry.fill(HIST("hMassMcMatchedIncomplete"), candReso.invMass(), candReso.pt()); } else { registry.fill(HIST("hMassMcUnmatched"), candReso.invMass(), candReso.pt()); - registry.fill(HIST("hMassMcUnmatchedVsBach0Mass"), candReso.invMass(), candReso.invMassProng0() - candReso.invMassD0()); - registry.fill(HIST("hMassMcUnmatchedVsBach1Mass"), candReso.invMass(), candReso.invMassProng1()); - registry.fill(HIST("hMassMcUnmatchedVsD0Mass"), candReso.invMass(), candReso.invMassD0()); - registry.fill(HIST("hMassMcUnmatchedVsDebug"), candReso.invMass(), rowDV0McRec.debugMcRec()); - registry.fill(HIST("hSparseUnmatchedDebug"), candReso.invMass(), candReso.pt(), candReso.invMassProng0() - candReso.invMassD0(), candReso.invMassProng1(), candReso.invMassD0(), rowDV0McRec.debugMcRec(), rowDV0McRec.origin()); } - break; } if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the D-Pi creator - rowResoMcRec(0, -1, -1, -1.f); + rowResoMcRec(0, 0, 0, 0, 0, -1.f, -1.f); registry.fill(HIST("hMassMcNoEntry"), candReso.invMass(), candReso.pt()); } } } - void processMc(aod::HfMcRecRedDV0s const& rowsDV0McRec, CandResoWithIndices const& candsReso) + void processDstarV0Mc(aod::HfDstarV0McRec const& rowsMcRec, CandResoWithIndicesDstarV0s const& candsReso) + { + fillResoMcRec(rowsMcRec, candsReso); + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, processDstarV0Mc, "Process resonances to Dstar V0 MC", false); + + void processDstarTrackMc(aod::HfDstarTrkMcRec const& rowsMcRec, CandResoWithIndicesDstarTrks const& candsReso) + { + fillResoMcRec(rowsMcRec, candsReso); + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, processDstarTrackMc, "Process resonances to Dstar track MC", false); + + void process2PrV0Mc(aod::Hf2PrV0McRec const& rowsMcRec, CandResoWithIndices2PrV0s const& candsReso) + { + fillResoMcRec(rowsMcRec, candsReso); + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, process2PrV0Mc, "Process resonances to D0 V0 MC", false); + + void process2PrTrackMc(aod::Hf2PrTrkMcRec const& rowsMcRec, CandResoWithIndices2PrTrks const& candsReso) + { + fillResoMcRec(rowsMcRec, candsReso); + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, process2PrTrackMc, "Process resonances to D0 track MC", false); + + void process3PrV0Mc(aod::Hf3PrV0McRec const& rowsMcRec, CandResoWithIndices3PrV0s const& candsReso) + { + fillResoMcRec(rowsMcRec, candsReso); + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, process3PrV0Mc, "Process resonances to Dplus V0 MC", false); + + void process3PrTrackMc(aod::Hf3PrTrkMcRec const& rowsMcRec, CandResoWithIndices3PrTrks const& candsReso) { - fillResoMcRec(rowsDV0McRec, candsReso); + fillResoMcRec(rowsMcRec, candsReso); } - PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, processMc, "Process MC", false); + PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, process3PrTrackMc, "Process resonances to Dplus track MC", false); - void processDummy(CandResoWithIndices const&) {} + void processDummy(aod::HfCandCharmReso const&) {} PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, processDummy, "Process dummy", true); }; diff --git a/PWGHF/D2H/TableProducer/candidateCreatorLbReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorLbReduced.cxx new file mode 100644 index 00000000000..3246cedb03f --- /dev/null +++ b/PWGHF/D2H/TableProducer/candidateCreatorLbReduced.cxx @@ -0,0 +1,358 @@ +// 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. + +/// \file candidateCreatorLbReduced.cxx +/// \brief Reconstruction of Lb candidates +/// +/// \author Biao Zhang , Heidelberg University + +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::constants::physics; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; + +/// Reconstruction of Lb candidates +struct HfCandidateCreatorLbReduced { + Produces rowCandidateBase; // table defined in CandidateReconstructionTables.h + Produces rowCandidateProngs; // table defined in ReducedDataModel.h + Produces rowCandidateLcMlScores; // table defined in ReducedDataModel.h + + // vertexing + Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; + Configurable useAbsDCA{"useAbsDCA", true, "Minimise abs. distance rather than chi2"}; + Configurable useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; + Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; + Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; + Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any Lb is smaller than this"}; + Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; + // selection + Configurable invMassWindowLcPiTolerance{"invMassWindowLcPiTolerance", 0.01, "invariant-mass window tolerance for LcPi pair preselections (GeV/c2)"}; + + float myInvMassWindowLcPi{1.}; // variable that will store the value of invMassWindowLcPi + float bz{0.}; + + o2::vertexing::DCAFitterN<2> df2; // fitter for B vertex (2-prong vertex fitter) + + using HfRedCollisionsWithExtras = soa::Join; + + Preslice> candsLcPerCollision = hf_track_index_reduced::hfRedCollisionId; + Preslice> candsDWithMlPerCollision = hf_track_index_reduced::hfRedCollisionId; + Preslice> tracksPionPerCollision = hf_track_index_reduced::hfRedCollisionId; + + std::shared_ptr hCandidates; + HistogramRegistry registry{"registry"}; + + void init(InitContext const&) + { + std::array doprocess{doprocessData, doprocessDataWithLcMl}; + if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { + LOGP(fatal, "Only one process function for data should be enabled at a time."); + } + + // Initialize fitter + df2.setPropagateToPCA(propagateToPCA); + df2.setMaxR(maxR); + df2.setMaxDZIni(maxDZIni); + df2.setMinParamChange(minParamChange); + df2.setMinRelChi2Change(minRelChi2Change); + df2.setUseAbsDCA(useAbsDCA); + df2.setWeightedFinalPCA(useWeightedFinalPCA); + + // histograms + registry.add("hMassLambdaB0ToLcPi", "2-prong candidates;inv. mass (#Lambda_{b}^{0} #rightarrow #Lambda_{c}^{#plus}#pi^{#minus} #rightarrow pK^{#minus}#pi^{#plus}#pi^{#minus}) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 3., 8.}}}); + registry.add("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}); + registry.add("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 0.2}}}); + registry.add("hEvents", "Events;;entries", HistType::kTH1F, {{1, 0.5, 1.5}}); + + /// candidate monitoring + hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidates); + } + + template + inline std::pair computeInvMass2LcPiWindow(Config const& configs, + float invMassWindowLcPiTolerance) + { + + myInvMassWindowLcPi = 0.0f; + for (const auto& config : configs) { + myInvMassWindowLcPi = config.myInvMassWindowLcPi(); + } + + float deltaMin = MassLambdaB0 - myInvMassWindowLcPi + invMassWindowLcPiTolerance; + float deltaMax = MassLambdaB0 + myInvMassWindowLcPi - invMassWindowLcPiTolerance; + + float invMass2LcPiMin = deltaMin * deltaMin; + float invMass2LcPiMax = deltaMax * deltaMax; + + return {invMass2LcPiMin, invMass2LcPiMax}; + } + + /// Main function to perform Lb candidate creation + /// \param withLcMl is the flag to use the table with ML scores for the Lc daughter (only possible if present in the derived data) + /// \param collision the collision + /// \param candsLcThisColl Lc candidates in this collision + /// \param tracksPionThisCollision pion tracks in this collision + /// \param invMass2LcPiMin minimum Lb invariant-mass + /// \param invMass2LcPiMax maximum Lb invariant-mass + template + void runCandidateCreation(Coll const& collision, + Cands const& candsLcThisColl, + Pions const& tracksPionThisCollision, + float invMass2LcPiMin, + float invMass2LcPiMax) + { + auto primaryVertex = getPrimaryVertex(collision); + auto covMatrixPV = primaryVertex.getCov(); + + // Set the magnetic field from ccdb + bz = collision.bz(); + df2.setBz(bz); + + for (const auto& candLc : candsLcThisColl) { + auto trackParCovD = getTrackParCov(candLc); + std::array pVecLc = candLc.pVector(); + + for (const auto& trackPion : tracksPionThisCollision) { + // this track is among daughters + if (trackPion.trackId() == candLc.prong0Id() || trackPion.trackId() == candLc.prong1Id() || trackPion.trackId() == candLc.prong2Id()) { + continue; + } + + auto trackParCovPi = getTrackParCov(trackPion); + std::array pVecPion = trackPion.pVector(); + + // compute invariant mass square and apply selection + auto invMass2LcPi = RecoDecay::m2(std::array{pVecLc, pVecPion}, std::array{MassLambdaCPlus, MassPiPlus}); + if ((invMass2LcPi < invMass2LcPiMin) || (invMass2LcPi > invMass2LcPiMax)) { + continue; + } + // --------------------------------- + // reconstruct the 2-prong Lb vertex + hCandidates->Fill(SVFitting::BeforeFit); + try { + if (df2.process(trackParCovD, trackParCovPi) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + hCandidates->Fill(SVFitting::Fail); + continue; + } + hCandidates->Fill(SVFitting::FitOk); + + // LcPi passed Lb reconstruction + + // calculate relevant properties + const auto& secondaryVertexLb = df2.getPCACandidate(); + auto chi2PCA = df2.getChi2AtPCACandidate(); + auto covMatrixPCA = df2.calcPCACovMatrixFlat(); + registry.fill(HIST("hCovSVXX"), covMatrixPCA[0]); + registry.fill(HIST("hCovPVXX"), covMatrixPV[0]); + + // propagate Lc and Pi to the Lb vertex + df2.propagateTracksToVertex(); + // track.getPxPyPzGlo(pVec) modifies pVec of track + df2.getTrack(0).getPxPyPzGlo(pVecLc); // momentum of Lc at the Lb vertex + df2.getTrack(1).getPxPyPzGlo(pVecPion); // momentum of Pi at the Lb vertex + + registry.fill(HIST("hMassLambdaB0ToLcPi"), std::sqrt(invMass2LcPi)); + + // compute impact parameters of D and Pi + o2::dataformats::DCA dcaLc; + o2::dataformats::DCA dcaPion; + trackParCovD.propagateToDCA(primaryVertex, bz, &dcaLc); + trackParCovPi.propagateToDCA(primaryVertex, bz, &dcaPion); + + // get uncertainty of the decay length + float phi, theta; + // getPointDirection modifies phi and theta + getPointDirection(std::array{collision.posX(), collision.posY(), collision.posZ()}, secondaryVertexLb, phi, theta); + auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta)); + auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); + + // fill the candidate table for the Lb here: + rowCandidateBase(collision.globalIndex(), + collision.posX(), collision.posY(), collision.posZ(), + secondaryVertexLb[0], secondaryVertexLb[1], secondaryVertexLb[2], + errorDecayLength, errorDecayLengthXY, + chi2PCA, + pVecLc[0], pVecLc[1], pVecLc[2], + pVecPion[0], pVecPion[1], pVecPion[2], + dcaLc.getY(), dcaPion.getY(), + std::sqrt(dcaLc.getSigmaY2()), std::sqrt(dcaPion.getSigmaY2())); + + rowCandidateProngs(candLc.globalIndex(), trackPion.globalIndex()); + + if constexpr (withLcMl) { + if (candLc.invMassHypo0() > 0) { + rowCandidateLcMlScores(candLc.mlScoreBkgMassHypo0(), candLc.mlScorePromptMassHypo0(), candLc.mlScoreNonpromptMassHypo0()); + } else { + rowCandidateLcMlScores(candLc.mlScoreBkgMassHypo1(), candLc.mlScorePromptMassHypo1(), candLc.mlScoreNonpromptMassHypo1()); + } + } // pi loop + } // Lc loop + } + } + + void processData(HfRedCollisionsWithExtras const& collisions, + soa::Join const& candsLc, + soa::Join const& tracksPion, + aod::HfOrigColCounts const& collisionsCounter, + aod::HfCandLbConfigs const& configs) + { + // LcPi invariant-mass window cut + // invMassWindowLcPiTolerance is used to apply a slightly tighter cut than in LcPi pair preselection + // to avoid accepting LcPi pairs that were not formed in LcPi pair creator + auto [invMass2LcPiMin, invMass2LcPiMax] = computeInvMass2LcPiWindow(configs, invMassWindowLcPiTolerance); + + for (const auto& collisionCounter : collisionsCounter) { + registry.fill(HIST("hEvents"), 1, collisionCounter.originalCollisionCount()); + } + + static int ncol = 0; + static constexpr int PrintFrequency = 10000; + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candsLcThisColl = candsLc.sliceBy(candsLcPerCollision, thisCollId); + auto tracksPionThisCollision = tracksPion.sliceBy(tracksPionPerCollision, thisCollId); + runCandidateCreation(collision, candsLcThisColl, tracksPionThisCollision, invMass2LcPiMin, invMass2LcPiMax); + if (ncol % PrintFrequency == 0) { + LOGP(debug, "collisions parsed {}", ncol); + } + ncol++; + } + } // processData + + PROCESS_SWITCH(HfCandidateCreatorLbReduced, processData, "Process data without any ML score", true); + + void processDataWithLcMl(HfRedCollisionsWithExtras const& collisions, + soa::Join const& candsLc, + soa::Join const& tracksPion, + aod::HfOrigColCounts const& collisionsCounter, + aod::HfCandLbConfigs const& configs) + { + // LcPi invariant-mass window cut + // invMassWindowLcPiTolerance is used to apply a slightly tighter cut than in LcPi pair preselection + // to avoid accepting LcPi pairs that were not formed in LcPi pair creator + auto [invMass2LcPiMin, invMass2LcPiMax] = computeInvMass2LcPiWindow(configs, invMassWindowLcPiTolerance); + + for (const auto& collisionCounter : collisionsCounter) { + registry.fill(HIST("hEvents"), 1, collisionCounter.originalCollisionCount()); + } + + static int ncol = 0; + static constexpr int PrintFrequency = 10000; + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candsLcThisColl = candsLc.sliceBy(candsLcPerCollision, thisCollId); + auto tracksPionThisCollision = tracksPion.sliceBy(tracksPionPerCollision, thisCollId); + runCandidateCreation(collision, candsLcThisColl, tracksPionThisCollision, invMass2LcPiMin, invMass2LcPiMax); + if (ncol % PrintFrequency == 0) { + LOGP(debug, "collisions parsed {}", ncol); + } + ncol++; + } + } // processDataWithLcMl + + PROCESS_SWITCH(HfCandidateCreatorLbReduced, processDataWithLcMl, "Process data with ML scores of Lc", false); +}; // struct + +/// Extends the table base with expression columns and performs MC matching. +struct HfCandidateCreatorLbReducedExpressions { + Spawns rowCandidateLb; + Spawns rowTracksExt; + Produces rowLbMcRec; + Produces rowLbMcCheck; + + /// Fill candidate information at MC reconstruction level + /// \param checkDecayTypeMc + /// \param rowsLcPiMcRec MC reco information on LcPi pairs + /// \param candsLb prong global indices of Lb candidates + template + void fillLbMcRec(McRec const& rowsLcPiMcRec, HfRedLbProngs const& candsLb) + { + for (const auto& candLb : candsLb) { + bool filledMcInfo{false}; + for (const auto& rowLcPiMcRec : rowsLcPiMcRec) { + if ((rowLcPiMcRec.prong0Id() != candLb.prong0Id()) || (rowLcPiMcRec.prong1Id() != candLb.prong1Id())) { + continue; + } + rowLbMcRec(rowLcPiMcRec.flagMcMatchRec(), rowLcPiMcRec.flagWrongCollision(), rowLcPiMcRec.debugMcRec(), rowLcPiMcRec.ptMother()); + filledMcInfo = true; + if constexpr (checkDecayTypeMc) { + rowLbMcCheck(rowLcPiMcRec.pdgCodeBeautyMother(), + rowLcPiMcRec.pdgCodeCharmMother(), + rowLcPiMcRec.pdgCodeProng0(), + rowLcPiMcRec.pdgCodeProng1(), + rowLcPiMcRec.pdgCodeProng2(), + rowLcPiMcRec.pdgCodeProng3()); + } + break; + } + if (!filledMcInfo) { // protection to get same size tables in case something went wrong: we created a candidate that was not preselected in the LcPi creator + rowLbMcRec(0, -1, -1, -1.f); + if constexpr (checkDecayTypeMc) { + rowLbMcCheck(-1, -1, -1, -1, -1, -1); + } + } + } + } + + void processMc(HfMcRecRedLcPis const& rowsLcPiMcRec, HfRedLbProngs const& candsLb) + { + fillLbMcRec(rowsLcPiMcRec, candsLb); + } + PROCESS_SWITCH(HfCandidateCreatorLbReducedExpressions, processMc, "Process MC", false); + + void processMcWithDecayTypeCheck(soa::Join const& rowsLcPiMcRec, HfRedLbProngs const& candsLb) + { + fillLbMcRec(rowsLcPiMcRec, candsLb); + } + PROCESS_SWITCH(HfCandidateCreatorLbReducedExpressions, processMcWithDecayTypeCheck, "Process MC with decay type checks", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx index c5ed599c244..53609fc66c9 100644 --- a/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx @@ -15,25 +15,42 @@ /// \author Alexandre Bigot , IPHC Strasbourg /// \author Fabrizio Grosa , CERN -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponseB0ToDPi.h" #include "PWGHF/Core/SelectorCuts.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsPid.h" + +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::analysis; +using namespace o2::aod::pid_tpc_tof_utils; struct HfCandidateSelectorB0ToDPiReduced { Produces hfSelB0ToDPiCandidate; // table defined in CandidateSelectionTables.h @@ -42,7 +59,7 @@ struct HfCandidateSelectorB0ToDPiReduced { Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; // Enable PID - Configurable pionPidMethod{"pionPidMethod", 1, "PID selection method for the bachelor pion (0: none, 1: TPC or TOF, 2: TPC and TOF)"}; + Configurable pionPidMethod{"pionPidMethod", PidMethod::TpcOrTof, "PID selection method for the bachelor pion (PidMethod::NoPid: none, PidMethod::TpcOrTof: TPC or TOF, PidMethod::TpcAndTof: TPC and TOF)"}; Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; // TPC PID Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; @@ -56,18 +73,18 @@ struct HfCandidateSelectorB0ToDPiReduced { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_b0_to_d_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_b0_to_d_pi::cuts[0], hf_cuts_b0_to_d_pi::nBinsPt, hf_cuts_b0_to_d_pi::nCutVars, hf_cuts_b0_to_d_pi::labelsPt, hf_cuts_b0_to_d_pi::labelsCutVar}, "B0 candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_b0_to_d_pi::Cuts[0], hf_cuts_b0_to_d_pi::NBinsPt, hf_cuts_b0_to_d_pi::NCutVars, hf_cuts_b0_to_d_pi::labelsPt, hf_cuts_b0_to_d_pi::labelsCutVar}, "B0 candidate selection per pT bin"}; // D-meson ML cuts Configurable> binsPtDmesMl{"binsPtDmesMl", std::vector{hf_cuts_ml::vecBinsPt}, "D-meson pT bin limits for ML cuts"}; - Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D-meson ML cuts per pT bin"}; + Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D-meson ML cuts per pT bin"}; // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; // B0 ML inference Configurable applyB0Ml{"applyB0Ml", false, "Flag to apply ML selections"}; Configurable> binsPtB0Ml{"binsPtB0Ml", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirB0Ml{"cutDirB0Ml", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsB0Ml{"cutsB0Ml", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesB0Ml{"nClassesB0Ml", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsB0Ml{"cutsB0Ml", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesB0Ml{"nClassesB0Ml", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -78,7 +95,7 @@ struct HfCandidateSelectorB0ToDPiReduced { // variable that will store the value of selectionFlagD (defined in dataCreatorDplusPiReduced.cxx) int mySelectionFlagD = -1; - o2::analysis::HfMlResponseB0ToDPi hfMlResponse; + o2::analysis::HfMlResponseB0ToDPi hfMlResponse; float outputMlNotPreselected = -1.; std::vector outputMl = {}; o2::ccdb::CcdbApi ccdbApi; @@ -97,11 +114,11 @@ struct HfCandidateSelectorB0ToDPiReduced { LOGP(fatal, "Only one process function for data should be enabled at a time."); } - if (pionPidMethod < 0 || pionPidMethod > 2) { + if (pionPidMethod < 0 || pionPidMethod >= PidMethod::NPidMethods) { LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); } - if (pionPidMethod) { + if (pionPidMethod != PidMethod::NoPid) { selectorPion.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); selectorPion.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax); selectorPion.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedMax, nSigmaTpcCombinedMax); @@ -190,11 +207,11 @@ struct HfCandidateSelectorB0ToDPiReduced { // track-level PID selection auto trackPi = hfCandB0.template prong1_as(); - if (pionPidMethod) { + if (pionPidMethod == PidMethod::TpcOrTof || pionPidMethod == PidMethod::TpcAndTof) { int pidTrackPi{TrackSelectorPID::Status::NotApplicable}; - if (pionPidMethod == 1) { + if (pionPidMethod == PidMethod::TpcOrTof) { pidTrackPi = selectorPion.statusTpcOrTof(trackPi); - } else { + } else if (pionPidMethod == PidMethod::TpcAndTof) { pidTrackPi = selectorPion.statusTpcAndTof(trackPi); } if (!hfHelper.selectionB0ToDPiPid(pidTrackPi, acceptPIDNotApplicable.value)) { diff --git a/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx index 60649b57fdd..3e1554fdb2e 100644 --- a/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx @@ -14,25 +14,42 @@ /// /// \author Antonio Palasciano , Università degli Studi di Bari -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponseBplusToD0PiReduced.h" #include "PWGHF/Core/SelectorCuts.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsPid.h" + +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::analysis; +using namespace o2::aod::pid_tpc_tof_utils; struct HfCandidateSelectorBplusToD0PiReduced { Produces hfSelBplusToD0PiCandidate; // table defined in CandidateSelectionTables.h @@ -41,7 +58,7 @@ struct HfCandidateSelectorBplusToD0PiReduced { Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; // Enable PID - Configurable pionPidMethod{"pionPidMethod", 1, "PID selection method for the bachelor pion (0: none, 1: TPC or TOF, 2: TPC and TOF)"}; + Configurable pionPidMethod{"pionPidMethod", PidMethod::TpcOrTof, "PID selection method for the bachelor pion (PidMethod::NoPid: none, PidMethod::TpcOrTof: TPC or TOF, PidMethod::TpcAndTof: TPC and TOF)"}; Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; // TPC PID Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; @@ -55,18 +72,18 @@ struct HfCandidateSelectorBplusToD0PiReduced { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_bplus_to_d0_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_bplus_to_d0_pi::cuts[0], hf_cuts_bplus_to_d0_pi::nBinsPt, hf_cuts_bplus_to_d0_pi::nCutVars, hf_cuts_bplus_to_d0_pi::labelsPt, hf_cuts_bplus_to_d0_pi::labelsCutVar}, "B+ candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_bplus_to_d0_pi::Cuts[0], hf_cuts_bplus_to_d0_pi::NBinsPt, hf_cuts_bplus_to_d0_pi::NCutVars, hf_cuts_bplus_to_d0_pi::labelsPt, hf_cuts_bplus_to_d0_pi::labelsCutVar}, "B+ candidate selection per pT bin"}; // D0-meson ML cuts Configurable> binsPtDmesMl{"binsPtDmesMl", std::vector{hf_cuts_ml::vecBinsPt}, "D0-meson pT bin limits for ML cuts"}; - Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D0-meson ML cuts per pT bin"}; + Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D0-meson ML cuts per pT bin"}; // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; // B+ ML inference Configurable applyBplusMl{"applyBplusMl", false, "Flag to apply ML selections"}; Configurable> binsPtBpMl{"binsPtBpMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirBpMl{"cutDirBpMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsBpMl{"cutsBpMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesBpMl{"nClassesBpMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsBpMl{"cutsBpMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesBpMl{"nClassesBpMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -86,10 +103,10 @@ struct HfCandidateSelectorBplusToD0PiReduced { HfHelper hfHelper; TrackSelectorPi selectorPion; - HistogramRegistry registry{"registry"}; - using TracksPion = soa::Join; + HistogramRegistry registry{"registry"}; + void init(InitContext const&) { std::array doprocess{doprocessSelection, doprocessSelectionWithDmesMl}; @@ -97,11 +114,11 @@ struct HfCandidateSelectorBplusToD0PiReduced { LOGP(fatal, "Only one process function for data should be enabled at a time."); } - if (pionPidMethod < 0 || pionPidMethod > 2) { + if (pionPidMethod < 0 || pionPidMethod >= PidMethod::NPidMethods) { LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); } - if (pionPidMethod) { + if (pionPidMethod != PidMethod::NoPid) { selectorPion.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); selectorPion.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax); selectorPion.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedMax, nSigmaTpcCombinedMax); @@ -191,11 +208,11 @@ struct HfCandidateSelectorBplusToD0PiReduced { // track-level PID selection auto trackPi = hfCandBp.template prong1_as(); - if (pionPidMethod) { + if (pionPidMethod == PidMethod::TpcOrTof || pionPidMethod == PidMethod::TpcAndTof) { int pidTrackPi{TrackSelectorPID::Status::NotApplicable}; - if (pionPidMethod == 1) { + if (pionPidMethod == PidMethod::TpcOrTof) { pidTrackPi = selectorPion.statusTpcOrTof(trackPi); - } else { + } else if (pionPidMethod == PidMethod::TpcAndTof) { pidTrackPi = selectorPion.statusTpcAndTof(trackPi); } if (!hfHelper.selectionBplusToD0PiPid(pidTrackPi, acceptPIDNotApplicable.value)) { diff --git a/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx index 9a6c47fce58..99e71e34acd 100644 --- a/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx @@ -14,25 +14,42 @@ /// /// \author Fabio Catalano , CERN -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponseBsToDsPi.h" #include "PWGHF/Core/SelectorCuts.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsPid.h" + +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::analysis; +using namespace o2::aod::pid_tpc_tof_utils; struct HfCandidateSelectorBsToDsPiReduced { Produces hfSelBsToDsPiCandidate; // table defined in CandidateSelectionTables.h @@ -41,7 +58,7 @@ struct HfCandidateSelectorBsToDsPiReduced { Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; // Enable PID - Configurable pionPidMethod{"pionPidMethod", 1, "PID selection method for the bachelor pion (0: none, 1: TPC or TOF, 2: TPC and TOF)"}; + Configurable pionPidMethod{"pionPidMethod", PidMethod::TpcOrTof, "PID selection method for the bachelor pion (PidMethod::NoPid: none, PidMethod::TpcOrTof: TPC or TOF, PidMethod::TpcAndTof: TPC and TOF)"}; Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; // TPC PID Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; @@ -55,18 +72,18 @@ struct HfCandidateSelectorBsToDsPiReduced { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_bs_to_ds_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_bs_to_ds_pi::cuts[0], hf_cuts_bs_to_ds_pi::nBinsPt, hf_cuts_bs_to_ds_pi::nCutVars, hf_cuts_bs_to_ds_pi::labelsPt, hf_cuts_bs_to_ds_pi::labelsCutVar}, "Bs candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_bs_to_ds_pi::Cuts[0], hf_cuts_bs_to_ds_pi::NBinsPt, hf_cuts_bs_to_ds_pi::NCutVars, hf_cuts_bs_to_ds_pi::labelsPt, hf_cuts_bs_to_ds_pi::labelsCutVar}, "Bs candidate selection per pT bin"}; // D-meson ML cuts Configurable> binsPtDmesMl{"binsPtDmesMl", std::vector{hf_cuts_ml::vecBinsPt}, "D-meson pT bin limits for ML cuts"}; - Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D-meson ML cuts per pT bin"}; + Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D-meson ML cuts per pT bin"}; // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; // B0 ML inference Configurable applyBsMl{"applyBsMl", false, "Flag to apply ML selections"}; Configurable> binsPtBsMl{"binsPtBsMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirBsMl{"cutDirBsMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsBsMl{"cutsBsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesBsMl{"nClassesBsMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsBsMl{"cutsBsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesBsMl{"nClassesBsMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -93,11 +110,11 @@ struct HfCandidateSelectorBsToDsPiReduced { LOGP(fatal, "Only one process function for data should be enabled at a time."); } - if (pionPidMethod < 0 || pionPidMethod > 2) { + if (pionPidMethod < 0 || pionPidMethod >= PidMethod::NPidMethods) { LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); } - if (pionPidMethod) { + if (pionPidMethod != PidMethod::NoPid) { selectorPion.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); selectorPion.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax); selectorPion.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedMax, nSigmaTpcCombinedMax); @@ -180,11 +197,11 @@ struct HfCandidateSelectorBsToDsPiReduced { // track-level PID selection auto trackPi = hfCandBs.template prong1_as(); - if (pionPidMethod) { + if (pionPidMethod == PidMethod::TpcOrTof || pionPidMethod == PidMethod::TpcAndTof) { int pidTrackPi{TrackSelectorPID::Status::NotApplicable}; - if (pionPidMethod == 1) { + if (pionPidMethod == PidMethod::TpcOrTof) { pidTrackPi = selectorPion.statusTpcOrTof(trackPi); - } else { + } else if (pionPidMethod == PidMethod::TpcAndTof) { pidTrackPi = selectorPion.statusTpcAndTof(trackPi); } if (!hfHelper.selectionBsToDsPiPid(pidTrackPi, acceptPIDNotApplicable.value)) { diff --git a/PWGHF/D2H/TableProducer/candidateSelectorLbToLcPiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorLbToLcPiReduced.cxx new file mode 100644 index 00000000000..dbe86c4905d --- /dev/null +++ b/PWGHF/D2H/TableProducer/candidateSelectorLbToLcPiReduced.cxx @@ -0,0 +1,263 @@ +// 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. + +/// \file candidateSelectorLbToLcPiReduced.cxx +/// \brief Lb → Lc+ π- candidate selector +/// +/// \author Biao Zhang , Heidelberg University + +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponseLbToLcPi.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsPid.h" + +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::analysis; +using namespace o2::aod::pid_tpc_tof_utils; + +struct HfCandidateSelectorLbToLcPiReduced { + Produces hfSelLbToLcPiCandidate; // table defined in CandidateSelectionTables.h + Produces hfMlLbToLcPiCandidate; // table defined in CandidateSelectionTables.h + + Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; + Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; + // Enable PID + Configurable pionPidMethod{"pionPidMethod", PidMethod::TpcOrTof, "PID selection method for the bachelor pion (PidMethod::NoPid: none, PidMethod::TpcOrTof: TPC or TOF, PidMethod::TpcAndTof: TPC and TOF)"}; + Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; + // TPC PID + Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; + Configurable ptPidTpcMax{"ptPidTpcMax", 20., "Upper bound of track pT for TPC PID"}; + Configurable nSigmaTpcMax{"nSigmaTpcMax", 5., "Nsigma cut on TPC only"}; + Configurable nSigmaTpcCombinedMax{"nSigmaTpcCombinedMax", 5., "Nsigma cut on TPC combined with TOF"}; + // TOF PID + Configurable ptPidTofMin{"ptPidTofMin", 0.15, "Lower bound of track pT for TOF PID"}; + Configurable ptPidTofMax{"ptPidTofMax", 20., "Upper bound of track pT for TOF PID"}; + Configurable nSigmaTofMax{"nSigmaTofMax", 5., "Nsigma cut on TOF only"}; + Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; + // topological cuts + Configurable> binsPt{"binsPt", std::vector{hf_cuts_lb_to_lc_pi::vecBinsPt}, "pT bin limits"}; + Configurable> cuts{"cuts", {hf_cuts_lb_to_lc_pi::Cuts[0], hf_cuts_lb_to_lc_pi::NBinsPt, hf_cuts_lb_to_lc_pi::NCutVars, hf_cuts_lb_to_lc_pi::labelsPt, hf_cuts_lb_to_lc_pi::labelsCutVar}, "Lb candidate selection per pT bin"}; + // Lc ML cuts + Configurable> binsPtLcMl{"binsPtLcMl", std::vector{hf_cuts_ml::vecBinsPt}, "Lc pT bin limits for ML cuts"}; + Configurable> cutsLcMl{"cutsLcMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "Lc ML cuts per pT bin"}; + // QA switch + Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; + // Lb ML inference + Configurable applyLbMl{"applyLbMl", false, "Flag to apply ML selections"}; + Configurable> binsPtLbMl{"binsPtLbMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; + Configurable> cutDirLbMl{"cutDirLbMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsLbMl{"cutsLbMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesLbMl{"nClassesLbMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; + // CCDB configuration + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"path_ccdb/BDT_Lb/"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_LbToLcPi.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + + o2::analysis::HfMlResponseLbToLcPi hfMlResponse; + float outputMlNotPreselected = -1.; + std::vector outputMl = {}; + o2::ccdb::CcdbApi ccdbApi; + + TrackSelectorPi selectorPion; + HfHelper hfHelper; + + using TracksPion = soa::Join; + + HistogramRegistry registry{"registry"}; + + void init(InitContext const&) + { + std::array doprocess{doprocessSelection, doprocessSelectionWithLcMl}; + if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { + LOGP(fatal, "Only one process function for data should be enabled at a time."); + } + + if (pionPidMethod < 0 || pionPidMethod >= PidMethod::NPidMethods) { + LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); + } + + if (pionPidMethod != PidMethod::NoPid) { + selectorPion.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); + selectorPion.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax); + selectorPion.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedMax, nSigmaTpcCombinedMax); + selectorPion.setRangePtTof(ptPidTofMin, ptPidTofMax); + selectorPion.setRangeNSigmaTof(-nSigmaTofMax, nSigmaTofMax); + selectorPion.setRangeNSigmaTofCondTpc(-nSigmaTofCombinedMax, nSigmaTofCombinedMax); + } + + if (activateQA) { + constexpr int kNBinsSelections = 1 + SelectionStep::NSelectionSteps; + std::string labels[kNBinsSelections]; + labels[0] = "No selection"; + labels[1 + SelectionStep::RecoSkims] = "Skims selection"; + labels[1 + SelectionStep::RecoTopol] = "Skims & Topological selections"; + labels[1 + SelectionStep::RecoPID] = "Skims & Topological & PID selections"; + labels[1 + aod::SelectionStep::RecoMl] = "ML selection"; + static const AxisSpec axisSelections = {kNBinsSelections, 0.5, kNBinsSelections + 0.5, ""}; + registry.add("hSelections", "Selections;;#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisSelections, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); + for (int iBin = 0; iBin < kNBinsSelections; ++iBin) { + registry.get(HIST("hSelections"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); + } + } + + if (applyLbMl) { + hfMlResponse.configure(binsPtLbMl, cutsLbMl, cutDirLbMl, nClassesLbMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponse.setModelPathsLocal(onnxFileNames); + } + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponse.init(); + } + } + + /// Main function to perform Lb candidate selection + /// \param withLcMl is the flag to use the table with ML scores for the Ds- daughter (only possible if present in the derived data) + /// \param hfCandsLb Lb candidates + /// \param pionTracks pion tracks + /// \param configs config inherited from the charm-hadron data creator + template + void runSelection(Cands const& hfCandsLb, + TracksPion const&, + HfCandLbConfigs const&) + { + for (const auto& hfCandLb : hfCandsLb) { + int statusLbToLcPi = 0; + outputMl.clear(); + auto ptCandLb = hfCandLb.pt(); + + SETBIT(statusLbToLcPi, SelectionStep::RecoSkims); // RecoSkims = 0 --> statusLbToLcPi = 1 + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoSkims, ptCandLb); + } + + // topological cuts + if (!hfHelper.selectionLbToLcPiTopol(hfCandLb, cuts, binsPt)) { + hfSelLbToLcPiCandidate(statusLbToLcPi); + if (applyLbMl) { + hfMlLbToLcPiCandidate(outputMlNotPreselected); + } + continue; + } + + if constexpr (withLcMl) { // we include it in the topological selections + if (!hfHelper.selectionDmesMlScoresForBReduced(hfCandLb, cutsLcMl, binsPtLcMl)) { + hfSelLbToLcPiCandidate(statusLbToLcPi); + if (applyLbMl) { + hfMlLbToLcPiCandidate(outputMlNotPreselected); + } + continue; + } + } + + SETBIT(statusLbToLcPi, SelectionStep::RecoTopol); // RecoTopol = 1 --> statusLbToLcPi = 3 + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoTopol, ptCandLb); + } + + // track-level PID selection + auto trackPi = hfCandLb.template prong1_as(); + if (pionPidMethod == PidMethod::TpcOrTof || pionPidMethod == PidMethod::TpcAndTof) { + int pidTrackPi{TrackSelectorPID::Status::NotApplicable}; + if (pionPidMethod == PidMethod::TpcOrTof) { + pidTrackPi = selectorPion.statusTpcOrTof(trackPi); + } else if (pionPidMethod == PidMethod::TpcAndTof) { + pidTrackPi = selectorPion.statusTpcAndTof(trackPi); + } + if (!hfHelper.selectionLbToLcPiPid(pidTrackPi, acceptPIDNotApplicable.value)) { + hfSelLbToLcPiCandidate(statusLbToLcPi); + if (applyLbMl) { + hfMlLbToLcPiCandidate(outputMlNotPreselected); + } + continue; + } + SETBIT(statusLbToLcPi, SelectionStep::RecoPID); // RecoPID = 2 --> statusLbToLcPi = 7 + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoPID, ptCandLb); + } + } + + if (applyLbMl) { + // Lb ML selections + std::vector inputFeatures = hfMlResponse.getInputFeatures(hfCandLb, trackPi); + bool isSelectedMl = hfMlResponse.isSelectedMl(inputFeatures, ptCandLb, outputMl); + hfMlLbToLcPiCandidate(outputMl[1]); + + if (!isSelectedMl) { + hfSelLbToLcPiCandidate(statusLbToLcPi); + continue; + } + SETBIT(statusLbToLcPi, SelectionStep::RecoMl); // RecoML = 3 --> statusLbToLcPi = 15 if PidMethod, 11 otherwise + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoMl, ptCandLb); + } + } + + hfSelLbToLcPiCandidate(statusLbToLcPi); + } + } + + void processSelection(HfRedCandLb const& hfCandsLb, + TracksPion const& pionTracks, + HfCandLbConfigs const& configs) + { + runSelection(hfCandsLb, pionTracks, configs); + } // processSelection + + PROCESS_SWITCH(HfCandidateSelectorLbToLcPiReduced, processSelection, "Process selection without ML scores of Lc", true); + + void processSelectionWithLcMl(soa::Join const& hfCandsLb, + TracksPion const& pionTracks, + HfCandLbConfigs const& configs) + { + runSelection(hfCandsLb, pionTracks, configs); + } // processSelectionwithLcMl + + PROCESS_SWITCH(HfCandidateSelectorLbToLcPiReduced, processSelectionWithLcMl, "Process selection with ML scores of Lc", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/TableProducer/converterReduced3ProngsMl.cxx b/PWGHF/D2H/TableProducer/converterReduced3ProngsMl.cxx index ea9450eca08..90360a29cc0 100644 --- a/PWGHF/D2H/TableProducer/converterReduced3ProngsMl.cxx +++ b/PWGHF/D2H/TableProducer/converterReduced3ProngsMl.cxx @@ -14,12 +14,12 @@ /// /// \author Fabrizio Grosa , CERN -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" - #include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include +#include +#include + using namespace o2; using namespace o2::framework; diff --git a/PWGHF/D2H/TableProducer/converterReducedHadronDausPid.cxx b/PWGHF/D2H/TableProducer/converterReducedHadronDausPid.cxx new file mode 100644 index 00000000000..d1bf2d4e47c --- /dev/null +++ b/PWGHF/D2H/TableProducer/converterReducedHadronDausPid.cxx @@ -0,0 +1,54 @@ +// 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. + +/// \file converterReducedHadronDausPid.cxx +/// \brief Task for conversion of daughters pid to version 001 +/// +/// \author Biao Zhang , Heidelberg University + +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" + +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; + +struct HfConverterReducedHadronDausPid { + Produces hfRedPidDau0s; + Produces hfRedPidDau1s; + Produces hfRedPidDau2s; + + using HfRedPidDaus2Prong = soa::Join; + using HfRedPidDaus3Prong = soa::Join; + + void process2Prongs(HfRedPidDaus2Prong::iterator const& hfCandPidProngs) + { + hfRedPidDau0s(hfCandPidProngs.tpcNSigmaPiProng0(), hfCandPidProngs.tofNSigmaPiProng0(), hfCandPidProngs.tpcNSigmaKaProng0(), hfCandPidProngs.tofNSigmaKaProng0(), -999.f, -999.f, hfCandPidProngs.hasTOFProng0(), hfCandPidProngs.hasTPCProng0()); + hfRedPidDau1s(hfCandPidProngs.tpcNSigmaPiProng1(), hfCandPidProngs.tofNSigmaPiProng1(), hfCandPidProngs.tpcNSigmaKaProng1(), hfCandPidProngs.tofNSigmaKaProng1(), -999.f, -999.f, hfCandPidProngs.hasTOFProng1(), hfCandPidProngs.hasTPCProng1()); + } + PROCESS_SWITCH(HfConverterReducedHadronDausPid, process2Prongs, "Produce PID tables for 2-prong candidates", false); + + void process3Prongs(HfRedPidDaus3Prong::iterator const& hfCandPidProngs) + { + hfRedPidDau0s(hfCandPidProngs.tpcNSigmaPiProng0(), hfCandPidProngs.tofNSigmaPiProng0(), hfCandPidProngs.tpcNSigmaKaProng0(), hfCandPidProngs.tofNSigmaKaProng0(), -999.f, -999.f, hfCandPidProngs.hasTOFProng0(), hfCandPidProngs.hasTPCProng0()); + hfRedPidDau1s(hfCandPidProngs.tpcNSigmaPiProng1(), hfCandPidProngs.tofNSigmaPiProng1(), hfCandPidProngs.tpcNSigmaKaProng1(), hfCandPidProngs.tofNSigmaKaProng1(), -999.f, -999.f, hfCandPidProngs.hasTOFProng1(), hfCandPidProngs.hasTPCProng1()); + hfRedPidDau2s(hfCandPidProngs.tpcNSigmaPiProng2(), hfCandPidProngs.tofNSigmaPiProng2(), hfCandPidProngs.tpcNSigmaKaProng2(), hfCandPidProngs.tofNSigmaKaProng2(), -999.f, -999.f, hfCandPidProngs.hasTOFProng2(), hfCandPidProngs.hasTPCProng2()); + } + PROCESS_SWITCH(HfConverterReducedHadronDausPid, process3Prongs, "Produce PID tables for 3-prong candidates", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx index 3a52b39387f..0b73b385893 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx @@ -16,27 +16,67 @@ /// \author Antonio Palasciano , Università degli Studi di Bari /// \author Fabrizio Grosa , CERN /// \author Fabio Catalano , CERN +/// \author Biao Zhang , Heidelberg University -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" - -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" - +#include "PWGHF/Core/CentralityEstimation.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/Utils/utilsMcMatching.h" #include "PWGHF/Utils/utilsTrkCandHf.h" -#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -44,6 +84,7 @@ using namespace o2::aod; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_decay; using namespace o2::hf_trkcandsel; enum Event : uint8_t { @@ -56,7 +97,9 @@ enum Event : uint8_t { enum DecayChannel : uint8_t { B0ToDminusPi = 0, BplusToD0barPi, - BsToDsminusPi + BsToDsminusPi, + LbToLcplusPi, + B0ToDstarPi }; enum WrongCollisionType : uint8_t { @@ -69,70 +112,96 @@ enum WrongCollisionType : uint8_t { struct HfDataCreatorCharmHadPiReduced { // Produces AOD tables to store track information // collision related tables - Produces hfReducedCollision; - Produces hfReducedCollExtra; - Produces hfCollisionCounter; - // Pi bachelor related tables - Produces hfTrackPion; - Produces hfTrackCovPion; - Produces hfTrackPidPion; - // charm hadron related tables - Produces hfCand2Prong; - Produces hfCand2ProngCov; - Produces hfCand2ProngMl; - Produces hfCand3Prong; - Produces hfCand3ProngCov; - Produces hfCand3ProngMl; - // PID tables for charm-hadron candidate daughter tracks - Produces hfCandPidProng0; - Produces hfCandPidProng1; - Produces hfCandPidProng2; - - // B-hadron config and MC related tables - Produces rowCandidateConfigB0; - Produces rowHfDPiMcRecReduced; - Produces rowHfDPiMcCheckReduced; - Produces rowHfB0McGenReduced; - - Produces rowCandidateConfigBplus; - Produces rowHfD0PiMcRecReduced; - Produces rowHfD0PiMcCheckReduced; - Produces rowHfBpMcGenReduced; - - Produces rowCandidateConfigBs; - Produces rowHfDsPiMcRecReduced; - Produces rowHfDsPiMcCheckReduced; - Produces rowHfBsMcGenReduced; - + struct : ProducesGroup { + Produces hfReducedCollision; + Produces hfReducedCollCentrality; + Produces hfReducedQvector; + Produces hfReducedCollExtra; + Produces hfCollisionCounter; + // Pi bachelor related tables + Produces hfTrackPion; + Produces hfTrackCovPion; + Produces hfTrackPidPion; + // charm hadron related tables + Produces hfCand2Prong; + Produces hfCand2ProngCov; + Produces hfCand2ProngMl; + Produces hfCand3Prong; + Produces hfCand3ProngCov; + Produces hfCand3ProngMl; + // D* soft pion related tables + Produces hfTrackSoftPion; + Produces hfTrackCovSoftPion; + // PID tables for charm-hadron candidate daughter tracks + Produces hfCandPidProng0; + Produces hfCandPidProng1; + Produces hfCandPidProng2; + + // B-hadron config and MC related tables + Produces rowCandidateConfigB0; + Produces rowHfDPiMcRecReduced; + Produces rowHfDPiMcCheckReduced; + Produces rowHfB0McGenReduced; + + Produces rowCandidateConfigBplus; + Produces rowHfD0PiMcRecReduced; + Produces rowHfD0PiMcCheckReduced; + Produces rowHfBpMcGenReduced; + + Produces rowCandidateConfigBs; + Produces rowHfDsPiMcRecReduced; + Produces rowHfDsPiMcCheckReduced; + Produces rowHfBsMcGenReduced; + + Produces rowCandidateConfigLb; + Produces rowHfLcPiMcRecReduced; + Produces rowHfLcPiMcCheckReduced; + Produces rowHfLbMcGenReduced; + } tables; + + // generic configurables + struct : o2::framework::ConfigurableGroup { + // event selection + Configurable skipRejectedCollisions{"skipRejectedCollisions", true, "skips collisions rejected by the event selection, instead of flagging only"}; + // magnetic field setting from CCDB + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; + // pair selection + Configurable invMassWindowCharmHadPi{"invMassWindowCharmHadPi", 0.3, "invariant-mass window for CharmHad-Pi pair preselections (GeV/c2)"}; + // MC extra + Configurable checkDecayTypeMc{"checkDecayTypeMc", false, "flag to enable MC checks on decay type"}; + } configs; // vertexing - // Configurable bz{"bz", 5., "magnetic field"}; - Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; - Configurable useAbsDCA{"useAbsDCA", false, "Minimise abs. distance rather than chi2"}; - Configurable useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; - Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; - Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; - Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any B0 is smaller than this"}; - Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; + struct : o2::framework::ConfigurableGroup { + Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; + Configurable useAbsDCA{"useAbsDCA", false, "Minimise abs. distance rather than chi2"}; + Configurable useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; + Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; + Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; + Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any B0 is smaller than this"}; + Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; + } vertexConfigurations; // selection - Configurable usePionIsGlobalTrackWoDCA{"usePionIsGlobalTrackWoDCA", true, "check isGlobalTrackWoDCA status for pions, for Run3 studies"}; - Configurable ptPionMin{"ptPionMin", 0.5, "minimum pion pT threshold (GeV/c)"}; - Configurable> binsPtPion{"binsPtPion", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for pion DCA XY pT-dependent cut"}; - Configurable> cutsTrackPionDCA{"cutsTrackPionDCA", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for pions"}; - Configurable invMassWindowCharmHadPi{"invMassWindowCharmHadPi", 0.3, "invariant-mass window for CharmHad-Pi pair preselections (GeV/c2)"}; - Configurable selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for D+"}; - Configurable selectionFlagDs{"selectionFlagDs", 7, "Selection Flag for Ds"}; - Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; - Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection Flag for D0bar"}; - - // magnetic field setting from CCDB - Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; - - // MC extra - Configurable checkDecayTypeMc{"checkDecayTypeMc", false, "flag to enable MC checks on decay type"}; + struct : o2::framework::ConfigurableGroup { + Configurable usePionIsGlobalTrackWoDCA{"usePionIsGlobalTrackWoDCA", true, "check isGlobalTrackWoDCA status for pions, for Run3 studies"}; + Configurable ptPionMin{"ptPionMin", 0.5, "minimum pion pT threshold (GeV/c)"}; + Configurable etaPionMax{"etaPionMax", 0.8, "maximum pion absolute eta threshold"}; + Configurable> binsPtPion{"binsPtPion", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for pion DCA XY pT-dependent cut"}; + Configurable> cutsTrackPionDCA{"cutsTrackPionDCA", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for pions"}; + } trackPionConfigurations; + // HF flags + struct : o2::framework::ConfigurableGroup { + Configurable selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for D+"}; + Configurable selectionFlagDs{"selectionFlagDs", 7, "Selection Flag for Ds"}; + Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; + Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection Flag for D0bar"}; + Configurable selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc"}; + Configurable selectionFlagDstar{"selectionFlagDstar", true, "Selection Flag for D* decay to D0 Pi"}; + } hfflagConfigurations; HfHelper hfHelper; o2::hf_evsel::HfEventSelection hfEvSel; + o2::hf_evsel::HfEventSelectionMc hfEvSelMc; // CCDB service Service ccdb; @@ -142,99 +211,124 @@ struct HfDataCreatorCharmHadPiReduced { // O2DatabasePDG service Service pdg; - double massPi{0.}; double massC{0.}; double massB{0.}; double invMass2ChHadPiMin{0.}; double invMass2ChHadPiMax{0.}; double bz{0.}; - + static constexpr std::size_t NDaughtersDs{2u}; + static constexpr std::size_t NDaughtersDstar{2u}; bool isHfCandBhadConfigFilled = false; // Fitter to redo D-vertex to get extrapolated daughter tracks (2/3-prong vertex filter) o2::vertexing::DCAFitterN<3> df3; o2::vertexing::DCAFitterN<2> df2; - using TracksPid = soa::Join; // TODO: revert to pion only once the Nsigma variables for the charm-hadron candidate daughters are in the candidate table for 3 prongs too + using TracksPid = soa::Join; // TODO: revert to pion only once the Nsigma variables for the charm-hadron candidate daughters are in the candidate table for 3 prongs too using TracksPidWithSel = soa::Join; using TracksPidWithSelAndMc = soa::Join; - using CandsDplusFiltered = soa::Filtered>; - using CandsDplusFilteredWithMl = soa::Filtered>; - using CandsDsFiltered = soa::Filtered>; - using CandsDsFilteredWithMl = soa::Filtered>; + using CandsDplusFiltered = soa::Filtered>; + using CandsDplusFilteredWithMl = soa::Filtered>; + using CandsDsFiltered = soa::Filtered>; + using CandsDsFilteredWithMl = soa::Filtered>; using CandsD0Filtered = soa::Filtered>; using CandsD0FilteredWithMl = soa::Filtered>; - - using CollisionsWMcLabels = soa::Join; - - Filter filterSelectDplusCandidates = (aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus); - Filter filterSelectDsCandidates = (aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlagDs || aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlagDs); - Filter filterSelectDzeroCandidates = (aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar); - - Preslice candsDplusPerCollision = aod::track_association::collisionId; - Preslice candsDplusPerCollisionWithMl = aod::track_association::collisionId; - Preslice candsDsPerCollision = aod::track_association::collisionId; - Preslice candsDsPerCollisionWithMl = aod::track_association::collisionId; - Preslice candsD0PerCollision = aod::track_association::collisionId; - Preslice candsD0PerCollisionWithMl = aod::track_association::collisionId; - Preslice trackIndicesPerCollision = aod::track_association::collisionId; - PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; - - std::shared_ptr hCandidatesD0, hCandidatesDPlus, hCandidatesDs; + using CandsLcFiltered = soa::Filtered>; + using CandsLcFilteredWithMl = soa::Filtered>; + using CandsDstarFiltered = soa::Filtered>; + using CandsDstarFilteredWithMl = soa::Filtered>; + + using CollisionsWCent = soa::Join; + using CollisionsWCentAndMcLabels = soa::Join; + using CollisionsWCentAndQvectors = soa::Join; + using BCsInfo = soa::Join; + + Filter filterSelectDplusCandidates = (aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= hfflagConfigurations.selectionFlagDplus); + Filter filterSelectDsCandidates = (aod::hf_sel_candidate_ds::isSelDsToKKPi >= hfflagConfigurations.selectionFlagDs || aod::hf_sel_candidate_ds::isSelDsToPiKK >= hfflagConfigurations.selectionFlagDs); + Filter filterSelectDzeroCandidates = (aod::hf_sel_candidate_d0::isSelD0 >= hfflagConfigurations.selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= hfflagConfigurations.selectionFlagD0bar); + Filter filterSelectLcCandidates = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= hfflagConfigurations.selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= hfflagConfigurations.selectionFlagLc); + Filter filterSelectDstarCandidates = (aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == hfflagConfigurations.selectionFlagDstar); + + struct : PresliceGroup { + Preslice candsDplusPerCollision = aod::track_association::collisionId; + Preslice candsDplusPerCollisionWithMl = aod::track_association::collisionId; + Preslice candsDsPerCollision = aod::track_association::collisionId; + Preslice candsDsPerCollisionWithMl = aod::track_association::collisionId; + Preslice candsD0PerCollision = aod::track_association::collisionId; + Preslice candsD0PerCollisionWithMl = aod::track_association::collisionId; + Preslice candsLcPerCollision = aod::track_association::collisionId; + Preslice candsLcPerCollisionWithMl = aod::track_association::collisionId; + Preslice candsDstarPerCollision = aod::track_association::collisionId; + Preslice candsDstarPerCollisionWithMl = aod::track_association::collisionId; + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + } preslices; + + std::shared_ptr hCandidatesD0, hCandidatesDPlus, hCandidatesDs, hCandidatesLc, hCandidatesDstar; HistogramRegistry registry{"registry"}; std::array arrPDGResonantDsPhiPi = {kPhi, kPiPlus}; // Ds± → Phi π± std::array arrPDGResonantDKstarK = {kK0Star892, kKPlus}; // Ds± → K*(892)0bar K± and D± → K*(892)0bar K± - void init(InitContext const&) + void init(InitContext& initContext) { - std::array doProcess = {doprocessDplusPiData, doprocessDplusPiDataWithMl, doprocessDplusPiMc, doprocessDplusPiMcWithMl, - doprocessDsPiData, doprocessDsPiDataWithMl, doprocessDsPiMc, doprocessDsPiMcWithMl, - doprocessD0PiData, doprocessD0PiDataWithMl, doprocessD0PiMc, doprocessD0PiMcWithMl}; + std::array doProcess = {doprocessDplusPiData, doprocessDplusPiDataWithMl, doprocessDplusPiDataWithQvec, doprocessDplusPiDataWithMlAndQvec, doprocessDplusPiMc, doprocessDplusPiMcWithMl, + doprocessDsPiData, doprocessDsPiDataWithMl, doprocessDsPiDataWithQvec, doprocessDsPiDataWithMlAndQvec, doprocessDsPiMc, doprocessDsPiMcWithMl, + doprocessD0PiData, doprocessD0PiDataWithMl, doprocessD0PiDataWithQvec, doprocessD0PiDataWithMlAndQvec, doprocessD0PiMc, doprocessD0PiMcWithMl, + doprocessLcPiData, doprocessLcPiDataWithMl, doprocessLcPiMc, doprocessLcPiMcWithMl, + doprocessDstarPiData, doprocessDstarPiDataWithMl, doprocessDstarPiDataWithQvec, doprocessDstarPiDataWithMlAndQvec, doprocessDstarPiMc, doprocessDstarPiMcWithMl}; if (std::accumulate(doProcess.begin(), doProcess.end(), 0) != 1) { LOGP(fatal, "One and only one process function can be enabled at a time, please fix your configuration!"); } // invariant-mass window cut - massPi = MassPiPlus; - if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiMc || doprocessDplusPiMcWithMl) { + if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiDataWithQvec || doprocessDplusPiDataWithMlAndQvec || doprocessDplusPiMc || doprocessDplusPiMcWithMl) { massC = MassDMinus; massB = MassB0; - } else if (doprocessDsPiData || doprocessDsPiDataWithMl || doprocessDsPiMc || doprocessDsPiMcWithMl) { + } else if (doprocessDsPiData || doprocessDsPiDataWithMl || doprocessDsPiDataWithQvec || doprocessDsPiDataWithMlAndQvec || doprocessDsPiMc || doprocessDsPiMcWithMl) { massC = MassDS; massB = MassBS; - } else if (doprocessD0PiData || doprocessD0PiDataWithMl || doprocessD0PiMc || doprocessD0PiMcWithMl) { + } else if (doprocessD0PiData || doprocessD0PiDataWithMl || doprocessD0PiDataWithQvec || doprocessD0PiDataWithMlAndQvec || doprocessD0PiMc || doprocessD0PiMcWithMl) { massC = MassD0; massB = MassBPlus; + } else if (doprocessLcPiData || doprocessLcPiDataWithMl || doprocessLcPiMc || doprocessLcPiMcWithMl) { + massC = MassLambdaCPlus; + massB = MassLambdaB0; + } else if (doprocessDstarPiData || doprocessDstarPiDataWithMl || doprocessDstarPiDataWithQvec || doprocessDstarPiDataWithMlAndQvec || doprocessDstarPiMc || doprocessDstarPiMcWithMl) { + massC = MassDStar; + massB = MassB0; } - invMass2ChHadPiMin = (massB - invMassWindowCharmHadPi) * (massB - invMassWindowCharmHadPi); - invMass2ChHadPiMax = (massB + invMassWindowCharmHadPi) * (massB + invMassWindowCharmHadPi); + invMass2ChHadPiMin = (massB - configs.invMassWindowCharmHadPi) * (massB - configs.invMassWindowCharmHadPi); + invMass2ChHadPiMax = (massB + configs.invMassWindowCharmHadPi) * (massB + configs.invMassWindowCharmHadPi); // Initialize fitter - if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiMc || doprocessDplusPiMcWithMl || - doprocessDsPiData || doprocessDsPiDataWithMl || doprocessDsPiMc || doprocessDsPiMcWithMl) { - df3.setPropagateToPCA(propagateToPCA); - df3.setMaxR(maxR); - df3.setMaxDZIni(maxDZIni); - df3.setMinParamChange(minParamChange); - df3.setMinRelChi2Change(minRelChi2Change); - df3.setUseAbsDCA(useAbsDCA); - df3.setWeightedFinalPCA(useWeightedFinalPCA); + if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiDataWithQvec || doprocessDplusPiDataWithMlAndQvec || doprocessDplusPiMc || doprocessDplusPiMcWithMl || + doprocessDsPiData || doprocessDsPiDataWithMl || doprocessDsPiDataWithQvec || doprocessDsPiDataWithMlAndQvec || doprocessDsPiMc || doprocessDsPiMcWithMl || + doprocessLcPiData || doprocessLcPiDataWithMl || doprocessLcPiMc || doprocessLcPiMcWithMl || + doprocessDstarPiData || doprocessDstarPiDataWithMl || doprocessDstarPiDataWithQvec || doprocessDstarPiDataWithMlAndQvec || doprocessDstarPiMc || doprocessDstarPiMcWithMl) { + df3.setPropagateToPCA(vertexConfigurations.propagateToPCA); + df3.setMaxR(vertexConfigurations.maxR); + df3.setMaxDZIni(vertexConfigurations.maxDZIni); + df3.setMinParamChange(vertexConfigurations.minParamChange); + df3.setMinRelChi2Change(vertexConfigurations.minRelChi2Change); + df3.setUseAbsDCA(vertexConfigurations.useAbsDCA); + df3.setWeightedFinalPCA(vertexConfigurations.useWeightedFinalPCA); df3.setMatCorrType(noMatCorr); - } else if (doprocessD0PiData || doprocessD0PiDataWithMl || doprocessD0PiMc || doprocessD0PiMcWithMl) { - df2.setPropagateToPCA(propagateToPCA); - df2.setMaxR(maxR); - df2.setMaxDZIni(maxDZIni); - df2.setMinParamChange(minParamChange); - df2.setMinRelChi2Change(minRelChi2Change); - df2.setUseAbsDCA(useAbsDCA); - df2.setWeightedFinalPCA(useWeightedFinalPCA); + } else if (doprocessD0PiData || doprocessD0PiDataWithMl || doprocessD0PiDataWithQvec || doprocessD0PiDataWithMlAndQvec || doprocessD0PiMc || doprocessD0PiMcWithMl) { + df2.setPropagateToPCA(vertexConfigurations.propagateToPCA); + df2.setMaxR(vertexConfigurations.maxR); + df2.setMaxDZIni(vertexConfigurations.maxDZIni); + df2.setMinParamChange(vertexConfigurations.minParamChange); + df2.setMinRelChi2Change(vertexConfigurations.minRelChi2Change); + df2.setUseAbsDCA(vertexConfigurations.useAbsDCA); + df2.setWeightedFinalPCA(vertexConfigurations.useWeightedFinalPCA); df2.setMatCorrType(noMatCorr); } // Configure CCDB access - ccdb->setURL(ccdbUrl); + ccdb->setURL(configs.ccdbUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); runNumber = 0; @@ -253,33 +347,64 @@ struct HfDataCreatorCharmHadPiReduced { std::string charmHadTitle = ""; std::string histMassTitle = ""; - if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiMc || doprocessDplusPiMcWithMl) { + if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiDataWithQvec || doprocessDplusPiDataWithMlAndQvec || doprocessDplusPiMc || doprocessDplusPiMcWithMl) { charmHadTitle = "D^{#plus}"; histMassTitle = "Dplus"; - registry.add("hMassDplus", "D^{#plus} candidates; #it{M}(K#pi#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 0., 5.}}}); - } else if (doprocessDsPiData || doprocessDsPiDataWithMl || doprocessDsPiMc || doprocessDsPiMcWithMl) { + registry.add("hMassDplus", "D^{#plus} candidates; #it{M}(K#pi#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0., 5.}}}); + } else if (doprocessDsPiData || doprocessDsPiDataWithMl || doprocessDsPiDataWithQvec || doprocessDsPiDataWithMlAndQvec || doprocessDsPiMc || doprocessDsPiMcWithMl) { charmHadTitle = "D_{s}^{#plus}"; histMassTitle = "Ds"; - registry.add("hMassDsToKKPi", "D_{s}^{#plus} to KKpi candidates; #it{M}(KK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 0., 5.}}}); - registry.add("hMassDsToPiKK", "D_{s}^{#plus} to piKK candidates; #it{M}(KK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 0., 5.}}}); - } else if (doprocessD0PiData || doprocessD0PiDataWithMl || doprocessD0PiMc || doprocessD0PiMcWithMl) { + registry.add("hMassDsToKKPi", "D_{s}^{#plus} to KKpi candidates; #it{M}(KK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0., 5.}}}); + registry.add("hMassDsToPiKK", "D_{s}^{#plus} to piKK candidates; #it{M}(KK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0., 5.}}}); + } else if (doprocessD0PiData || doprocessD0PiDataWithMl || doprocessD0PiDataWithQvec || doprocessD0PiDataWithMlAndQvec || doprocessD0PiMc || doprocessD0PiMcWithMl) { charmHadTitle = "D^{0}"; histMassTitle = "D0"; - registry.add("hMassD0", "D^{0} candidates; #it{M}(K#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 0., 5.}}}); - registry.add("hMassD0bar", "#overline{D}^{0} candidates; #it{M}(K#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 0., 5.}}}); + registry.add("hMassD0", "D^{0} candidates; #it{M}(K#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0., 5.}}}); + registry.add("hMassD0bar", "#overline{D}^{0} candidates; #it{M}(K#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0., 5.}}}); + } else if (doprocessLcPiData || doprocessLcPiDataWithMl || doprocessLcPiMc || doprocessLcPiMcWithMl) { + charmHadTitle = "#Lambda_{c}^{+}"; + histMassTitle = "Lc"; + registry.add("hMassLcToPKPi", "#Lambda_{c}^{+} to KKpi candidates; #it{M}(pK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0., 5.}}}); + registry.add("hMassLcToPiKP", "#Lambda_{c}^{+} to piKK candidates; #it{M}(#piKp) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0., 5.}}}); + } else if (doprocessDstarPiData || doprocessDstarPiDataWithMl || doprocessDstarPiDataWithQvec || doprocessDstarPiDataWithMlAndQvec || doprocessDstarPiMc || doprocessDstarPiMcWithMl) { + charmHadTitle = "D^{*}"; + histMassTitle = "Dstar"; + registry.add("hMassDstarToD0Pi", "D^{*} candidates; #it{M}(K#pi#pi) - #it{M}(K#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0., 1.}}}); } - registry.add(Form("hPt%s", histMassTitle.data()), Form("%s candidates candidates;%s candidate #it{p}_{T} (GeV/#it{c});entries", charmHadTitle.data(), charmHadTitle.data()), {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("hPtPion", "#pi^{#plus} candidates;#pi^{#plus} candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add(Form("hCpa%s", histMassTitle.data()), Form("%s candidates;%s cosine of pointing angle;entries", charmHadTitle.data(), charmHadTitle.data()), {HistType::kTH1F, {{110, -1.1, 1.1}}}); + registry.add(Form("hPt%s", histMassTitle.data()), Form("%s candidates candidates;%s candidate #it{p}_{T} (GeV/#it{c});entries", charmHadTitle.data(), charmHadTitle.data()), {HistType::kTH1D, {{100, 0., 10.}}}); + registry.add("hPtPion", "#pi^{#plus} candidates;#pi^{#plus} candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{100, 0., 10.}}}); + registry.add(Form("hCpa%s", histMassTitle.data()), Form("%s candidates;%s cosine of pointing angle;entries", charmHadTitle.data(), charmHadTitle.data()), {HistType::kTH1D, {{110, -1.1, 1.1}}}); /// candidate monitoring hCandidatesD0 = registry.add("hCandidatesD0", "D0 candidate counter", {HistType::kTH1D, {axisCands}}); hCandidatesDPlus = registry.add("hCandidatesDPlus", "Dplus candidate counter", {HistType::kTH1D, {axisCands}}); hCandidatesDs = registry.add("hCandidatesDs", "Ds candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesLc = registry.add("hCandidatesLc", "Lc candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesDstar = registry.add("hCandidatesDstar", "Dstar candidate counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidatesD0); setLabelHistoCands(hCandidatesDPlus); setLabelHistoCands(hCandidatesDs); + setLabelHistoCands(hCandidatesLc); + setLabelHistoCands(hCandidatesDstar); + + // init HF event selection helper + hfEvSel.init(registry); + if (doprocessDplusPiMc || doprocessDplusPiMcWithMl || + doprocessDsPiMc || doprocessDsPiMcWithMl || + doprocessD0PiMc || doprocessD0PiMcWithMl || + doprocessLcPiMc || doprocessLcPiMcWithMl || + doprocessDstarPiMc || doprocessDstarPiMcWithMl) { + const auto& workflows = initContext.services().get(); + for (const DeviceSpec& device : workflows.devices) { + if (device.name.compare("hf-data-creator-charm-had-pi-reduced") == 0) { + // init HF event selection helper + hfEvSelMc.init(device, registry); + break; + } + } + } } /// Pion selection (D Pi <-- B0) @@ -292,11 +417,11 @@ struct HfDataCreatorCharmHadPiReduced { bool isPionSelected(const T1& trackPion, const T2& trackParCovPion, const T3& dcaPion, const std::vector& charmDautracks) { // check isGlobalTrackWoDCA status for pions if wanted - if (usePionIsGlobalTrackWoDCA && !trackPion.isGlobalTrackWoDCA()) { + if (trackPionConfigurations.usePionIsGlobalTrackWoDCA && !trackPion.isGlobalTrackWoDCA()) { return false; } - // minimum pT selection - if (trackParCovPion.getPt() < ptPionMin || !isSelectedTrackDCA(trackParCovPion, dcaPion)) { + // minimum pT and eta selection + if (trackParCovPion.getPt() < trackPionConfigurations.ptPionMin || std::abs(trackParCovPion.getEta()) > trackPionConfigurations.etaPionMax || !isSelectedTrackDCA(trackParCovPion, dcaPion, trackPionConfigurations.binsPtPion, trackPionConfigurations.cutsTrackPionDCA)) { return false; } // reject pions that are charm-hadron daughters @@ -309,27 +434,6 @@ struct HfDataCreatorCharmHadPiReduced { return true; } - /// Single-track cuts for pions on dcaXY - /// \param trackPar is the track parametrisation - /// \param dca is the 2-D array with track DCAs - /// \return true if track passes all cuts - template - bool isSelectedTrackDCA(const T1& trackPar, const T2& dca) - { - auto pTBinTrack = findBin(binsPtPion, trackPar.getPt()); - if (pTBinTrack == -1) { - return false; - } - - if (std::abs(dca[0]) < cutsTrackPionDCA->get(pTBinTrack, "min_dcaxytoprimary")) { - return false; // minimum DCAxy - } - if (std::abs(dca[0]) > cutsTrackPionDCA->get(pTBinTrack, "max_dcaxytoprimary")) { - return false; // maximum DCAxy - } - return true; - } - /// Calculates the index of the collision with the maximum number of contributions. ///\param collisions are the collisions to search through. ///\return The index of the collision with the maximum number of contributions. @@ -384,6 +488,7 @@ struct HfDataCreatorCharmHadPiReduced { // we check the MC matching to be stored int8_t sign{0}; + int8_t signD{0}; int8_t flag{0}; int8_t flagWrongCollision{WrongCollisionType::None}; int8_t debug{0}; @@ -397,11 +502,11 @@ struct HfDataCreatorCharmHadPiReduced { if constexpr (decChannel == DecayChannel::B0ToDminusPi) { // B0 → D- π+ → (π- K+ π-) π+ - auto indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kPiPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); + auto indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kPiPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); if (indexRec > -1) { // D- → π- K+ π- // Printf("Checking D- → π- K+ π-"); - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kDMinus, std::array{-kPiPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kDMinus, std::array{-kPiPlus, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { flag = sign * BIT(hf_cand_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi); } else { @@ -418,13 +523,13 @@ struct HfDataCreatorCharmHadPiReduced { } // additional checks for correlated backgrounds - if (checkDecayTypeMc) { + if (configs.checkDecayTypeMc) { // B0 → Ds- π+ → (K- K+ π-) π+ if (!flag) { - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kKPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kKPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); if (indexRec > -1) { // Ds- → K- K+ π- - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { flag = sign * BIT(hf_cand_b0::DecayTypeMc::B0ToDsPiToKKPiPi); } @@ -432,15 +537,26 @@ struct HfDataCreatorCharmHadPiReduced { } // Bs → Ds- π+ → (K- K+ π-) π+ if (!flag) { - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kKPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kKPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); if (indexRec > -1) { // Ds- → K- K+ π- - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { flag = sign * BIT(hf_cand_b0::DecayTypeMc::BsToDsPiToKKPiPi); } } } + // B0 → D- K+ → (π- K+ π-) K+ + if (!flag) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kPiPlus, +kKPlus, -kPiPlus, +kKPlus}, true, &sign, 3); + if (indexRec > -1) { + // D- → π- K+ π- + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kDMinus, std::array{-kPiPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + if (indexRec > -1) { + flag = sign * BIT(hf_cand_b0::DecayTypeMc::B0ToDplusKToPiKPiK); + } + } + } // Partly reconstructed decays, i.e. the 4 prongs have a common b-hadron ancestor // convention: final state particles are prong0,1,2,3 if (!flag) { @@ -495,20 +611,20 @@ struct HfDataCreatorCharmHadPiReduced { } } } - rowHfDPiMcCheckReduced(pdgCodeBeautyMother, pdgCodeCharmMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2, pdgCodeProng3); + tables.rowHfDPiMcCheckReduced(pdgCodeBeautyMother, pdgCodeCharmMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2, pdgCodeProng3); } - rowHfDPiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt); + tables.rowHfDPiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt); } else if constexpr (decChannel == DecayChannel::BsToDsminusPi) { // Bs → Ds- π+ → (K- K+ π-) π+ - auto indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kKPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); + auto indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kKPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); if (indexRec > -1) { // Ds- → K- K+ π- - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { std::vector arrDaughDsIndex; std::array arrPDGDaughDs; RecoDecay::getDaughters(particlesMc.rawIteratorAt(indexRec), &arrDaughDsIndex, std::array{0}, 1); - if (arrDaughDsIndex.size() == 2) { + if (arrDaughDsIndex.size() == NDaughtersDs) { for (auto iProng = 0u; iProng < arrDaughDsIndex.size(); ++iProng) { auto daughI = particlesMc.rawIteratorAt(arrDaughDsIndex[iProng]); arrPDGDaughDs[iProng] = std::abs(daughI.pdgCode()); @@ -534,18 +650,18 @@ struct HfDataCreatorCharmHadPiReduced { } // additional checks for correlated backgrounds - if (checkDecayTypeMc) { + if (configs.checkDecayTypeMc) { // B0 → Ds- π+ → (K- K+ π-) π+ if (!flag) { - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kKPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kKPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); if (indexRec > -1) { // Ds- → K- K+ π- - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { std::vector arrDaughDsIndex; std::array arrPDGDaughDs; RecoDecay::getDaughters(particlesMc.rawIteratorAt(indexRec), &arrDaughDsIndex, std::array{0}, 1); - if (arrDaughDsIndex.size() == 2) { + if (arrDaughDsIndex.size() == NDaughtersDs) { for (auto iProng = 0u; iProng < arrDaughDsIndex.size(); ++iProng) { auto daughI = particlesMc.rawIteratorAt(arrDaughDsIndex[iProng]); arrPDGDaughDs[iProng] = std::abs(daughI.pdgCode()); @@ -560,6 +676,41 @@ struct HfDataCreatorCharmHadPiReduced { } } } + // Bs → Ds- K+ → (K- K+ π-) K+ + if (!flag) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kKPlus, +kKPlus, -kPiPlus, +kKPlus}, true, &sign, 3); + if (indexRec > -1) { + // Ds- → K- K+ π- + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + if (indexRec > -1) { + std::vector arrDaughDsIndex; + std::array arrPDGDaughDs; + RecoDecay::getDaughters(particlesMc.rawIteratorAt(indexRec), &arrDaughDsIndex, std::array{0}, 1); + if (arrDaughDsIndex.size() == NDaughtersDs) { + for (auto iProng = 0u; iProng < arrDaughDsIndex.size(); ++iProng) { + auto daughI = particlesMc.rawIteratorAt(arrDaughDsIndex[iProng]); + arrPDGDaughDs[iProng] = std::abs(daughI.pdgCode()); + } + // Ds- → Phi π- → K- K+ π- and Ds- → K0* K- → K- K+ π- + if ((arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[0] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[1]) || (arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[1] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[0])) { + flag = sign * BIT(hf_cand_bs::DecayTypeMc::BsToDsKToPhiPiKToKKPiK); + } else if ((arrPDGDaughDs[0] == arrPDGResonantDKstarK[0] && arrPDGDaughDs[1] == arrPDGResonantDKstarK[1]) || (arrPDGDaughDs[0] == arrPDGResonantDKstarK[1] && arrPDGDaughDs[1] == arrPDGResonantDKstarK[0])) { + flag = sign * BIT(hf_cand_bs::DecayTypeMc::BsToDsKToK0starKKToKKPiK); + } + } + } else { + debug = 1; + LOGF(debug, "Bs decays in the expected final state but the condition on the intermediate state is not fulfilled"); + } + + auto indexMother = RecoDecay::getMother(particlesMc, vecDaughtersB.back().template mcParticle_as(), Pdg::kBS, true); + if (indexMother >= 0) { + auto particleMother = particlesMc.rawIteratorAt(indexMother); + motherPt = particleMother.pt(); + checkWrongCollision(particleMother, collision, indexCollisionMaxNumContrib, flagWrongCollision); + } + } + } // Partly reconstructed decays, i.e. the 4 prongs have a common b-hadron ancestor // convention: final state particles are prong0,1,2,3 if (!flag) { @@ -615,17 +766,17 @@ struct HfDataCreatorCharmHadPiReduced { } } } - rowHfDsPiMcCheckReduced(pdgCodeBeautyMother, pdgCodeCharmMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2, pdgCodeProng3); + tables.rowHfDsPiMcCheckReduced(pdgCodeBeautyMother, pdgCodeCharmMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2, pdgCodeProng3); } - rowHfDsPiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt); + tables.rowHfDsPiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt); } else if constexpr (decChannel == DecayChannel::BplusToD0barPi) { // B+ → D0(bar) π+ → (K+ π-) π+ - auto indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kBPlus, std::array{+kPiPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + auto indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kBPlus, std::array{+kPiPlus, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { // D0(bar) → K+ π-; - indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1]}, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign, 1); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1]}, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign, 1); if (indexRec > -1) { - flag = sign * BIT(hf_cand_bplus::DecayType::BplusToD0Pi); + flag = sign * BIT(hf_cand_bplus::DecayTypeMc::BplusToD0PiToKPiPi); } else { debug = 1; LOGF(debug, "B+ decays in the expected final state but the condition on the intermediate state is not fulfilled"); @@ -639,7 +790,28 @@ struct HfDataCreatorCharmHadPiReduced { } } // additional checks for correlated backgrounds - if (checkDecayTypeMc) { + if (configs.checkDecayTypeMc) { + if (!flag) { + // B+ → D0(bar) K+ → (K+ π-) K+ + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kBPlus, std::array{+kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + if (indexRec > -1) { + // D0(bar) → K+ π-; + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1]}, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign, 1); + if (indexRec > -1) { + flag = sign * BIT(hf_cand_bplus::DecayTypeMc::BplusToD0KToKPiK); + } else { + debug = 1; + LOGF(debug, "B+ decays in the expected final state but the condition on the intermediate state is not fulfilled"); + } + + auto indexMother = RecoDecay::getMother(particlesMc, vecDaughtersB.back().template mcParticle_as(), Pdg::kBPlus, true); + if (indexMother >= 0) { + auto particleMother = particlesMc.rawIteratorAt(indexMother); + motherPt = particleMother.pt(); + checkWrongCollision(particleMother, collision, indexCollisionMaxNumContrib, flagWrongCollision); + } + } + } // Partly reconstructed decays, i.e. the 3 prongs have a common b-hadron ancestor // convention: final state particles are prong0,1,2 if (!flag) { @@ -647,7 +819,9 @@ struct HfDataCreatorCharmHadPiReduced { auto particleProng1 = vecDaughtersB[1].mcParticle(); auto particleProng2 = vecDaughtersB[2].mcParticle(); // b-hadron hypothesis - std::array bHadronMotherHypos = {Pdg::kBPlus, Pdg::kB0, Pdg::kBS}; + std::array bHadronMotherHypos = {Pdg::kBPlus, Pdg::kB0, Pdg::kBS, Pdg::kLambdaB0}; + // c-hadron hypothesis + std::array cHadronMotherHypos = {Pdg::kD0, Pdg::kDPlus, Pdg::kDS, Pdg::kDStar, 423, Pdg::kDSStar, Pdg::kLambdaCPlus}; for (const auto& bHadronMotherHypo : bHadronMotherHypos) { int index0Mother = RecoDecay::getMother(particlesMc, particleProng0, bHadronMotherHypo, true); @@ -663,28 +837,197 @@ struct HfDataCreatorCharmHadPiReduced { pdgCodeProng0 = particleProng0.pdgCode(); pdgCodeProng1 = particleProng1.pdgCode(); pdgCodeProng2 = particleProng2.pdgCode(); + // look for common c-hadron mother among prongs 0, 1 and 2 + for (const auto& cHadronMotherHypo : cHadronMotherHypos) { + int8_t depthMax = 2; + if (cHadronMotherHypo == Pdg::kDStar || cHadronMotherHypo == Pdg::kDStar0 || cHadronMotherHypo == Pdg::kDSStar) { // to include D* -> D π0/γ, D* -> D0 π, and Ds* -> Ds π0/γ + depthMax += 1; + } + int index0CharmMother = RecoDecay::getMother(particlesMc, particleProng0, cHadronMotherHypo, true, &sign, depthMax); + int index1CharmMother = RecoDecay::getMother(particlesMc, particleProng1, cHadronMotherHypo, true, &sign, depthMax); + if (index0CharmMother > -1 && index1CharmMother > -1) { + if (index0CharmMother == index1CharmMother) { + // pdgCodeCharmMother = + // Pdg::kDPlus (if D+ is the mother and does not come from D*+) + // Pdg::kDPlus + Pdg::kDStar (if D+ is the mother and D*+ -> D+ π0/γ) + // Pdg::kDStar (if D*+ is the mother and D*+ -> D0 π+) + // Pdg::kDS (if Ds is the mother and does not come from Ds*) + // Pdg::kDS + Pdg::kDSStar (if Ds is the mother and Ds* -> Ds π0/γ) + // Pdg::kLambdaCPlus (if Λc+ is the mother) + pdgCodeCharmMother += std::abs(particlesMc.rawIteratorAt(index0CharmMother).pdgCode()); + } + } + } break; } } } } - rowHfD0PiMcCheckReduced(pdgCodeBeautyMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2); + tables.rowHfD0PiMcCheckReduced(pdgCodeBeautyMother, pdgCodeCharmMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2); + } + tables.rowHfD0PiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt); + } else if constexpr (decChannel == DecayChannel::LbToLcplusPi) { + // Lb → Lc+ π- → (p K- π+) π- + auto indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kLambdaB0, std::array{+kProton, -kKPlus, +kPiPlus, -kPiPlus}, true, &sign, 3); + if (indexRec > -1) { + // Lc+ → p K- π+ + // Printf("Checking Lc+ → p K- π+"); + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2); + if (indexRec > -1) { + flag = sign * BIT(hf_cand_lb::DecayTypeMc::LbToLcPiToPKPiPi); + } else { + debug = 1; + LOGF(debug, "Lb decays in the expected final state but the condition on the intermediate state is not fulfilled"); + } + + auto indexMother = RecoDecay::getMother(particlesMc, vecDaughtersB.back().template mcParticle_as(), Pdg::kLambdaB0, true); + if (indexMother >= 0) { + auto particleMother = particlesMc.rawIteratorAt(indexMother); + motherPt = particleMother.pt(); + checkWrongCollision(particleMother, collision, indexCollisionMaxNumContrib, flagWrongCollision); + } + } + + // additional checks for correlated backgrounds + if (configs.checkDecayTypeMc) { + // Lb → Lc+ K- → (p K- π+) K- + if (!flag) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kLambdaB0, std::array{+kProton, -kKPlus, +kPiPlus, -kKPlus}, true, &sign, 3); + if (indexRec > -1) { + // Lc+ → p K- π+ + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2); + if (indexRec > -1) { + flag = sign * BIT(hf_cand_lb::DecayTypeMc::LbToLcKToPKPiK); + } + } + } + // B0 → D- π+ → (π- K+ π-) π+ + if (!flag) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{-kPiPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); + if (indexRec > -1) { + // D- → (π- K+ π- + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, -Pdg::kDMinus, std::array{-kPiPlus, +kKPlus, -kPiPlus}, true, &sign, 2); + if (indexRec > -1) { + flag = sign * BIT(hf_cand_lb::DecayTypeMc::B0ToDplusPiToPiKPiPi); + } + } + } + + // Partly reconstructed decays, i.e. the 4 prongs have a common b-hadron ancestor + // convention: final state particles are prong0,1,2,3 + if (!flag) { + auto particleProng0 = vecDaughtersB[0].mcParticle(); + auto particleProng1 = vecDaughtersB[1].mcParticle(); + auto particleProng2 = vecDaughtersB[2].mcParticle(); + auto particleProng3 = vecDaughtersB[3].mcParticle(); + // b-hadron hypothesis + std::array bHadronMotherHypos = {Pdg::kB0, Pdg::kBS, Pdg::kLambdaB0}; + // c-hadron hypothesis + std::array cHadronMotherHypos = {Pdg::kDPlus, Pdg::kDS, Pdg::kDStar, Pdg::kLambdaCPlus}; + + for (const auto& bHadronMotherHypo : bHadronMotherHypos) { + int index0Mother = RecoDecay::getMother(particlesMc, particleProng0, bHadronMotherHypo, true); + int index1Mother = RecoDecay::getMother(particlesMc, particleProng1, bHadronMotherHypo, true); + int index2Mother = RecoDecay::getMother(particlesMc, particleProng2, bHadronMotherHypo, true); + int index3Mother = RecoDecay::getMother(particlesMc, particleProng3, bHadronMotherHypo, true); + + // look for common b-hadron ancestor + if (index0Mother > -1 && index1Mother > -1 && index2Mother > -1 && index3Mother > -1) { + if (index0Mother == index1Mother && index1Mother == index2Mother && index2Mother == index3Mother) { + flag = BIT(hf_cand_b0::DecayTypeMc::PartlyRecoDecay); + pdgCodeBeautyMother = particlesMc.rawIteratorAt(index0Mother).pdgCode(); + pdgCodeCharmMother = 0; + pdgCodeProng0 = particleProng0.pdgCode(); + pdgCodeProng1 = particleProng1.pdgCode(); + pdgCodeProng2 = particleProng2.pdgCode(); + pdgCodeProng3 = particleProng3.pdgCode(); + // look for common c-hadron mother among prongs 0, 1 and 2 + for (const auto& cHadronMotherHypo : cHadronMotherHypos) { + int8_t depthMax = 2; + if (cHadronMotherHypo == Pdg::kDStar) { // to include D* -> D π0/γ and D* -> D0 π + depthMax += 1; + } + int index0CharmMother = RecoDecay::getMother(particlesMc, particleProng0, cHadronMotherHypo, true, &sign, depthMax); + int index1CharmMother = RecoDecay::getMother(particlesMc, particleProng1, cHadronMotherHypo, true, &sign, depthMax); + int index2CharmMother = RecoDecay::getMother(particlesMc, particleProng2, cHadronMotherHypo, true, &sign, depthMax); + if (index0CharmMother > -1 && index1CharmMother > -1 && index2CharmMother > -1) { + if (index0CharmMother == index1CharmMother && index1CharmMother == index2CharmMother) { + // pdgCodeCharmMother = + // Pdg::kDPlus (if D+ is the mother and does not come from D*+) + // Pdg::kDPlus + Pdg::kDStar (if D+ is the mother and D*+ -> D+ π0/γ) + // Pdg::kDStar (if D*+ is the mother and D*+ -> D0 π+) + // Pdg::kDS (if Ds is the mother) + // Pdg::kLambdaCPlus (if Λc+ is the mother) + pdgCodeCharmMother += std::abs(particlesMc.rawIteratorAt(index0CharmMother).pdgCode()); + } + } + } + break; // Early exit: found a valid decay chain with common b-hadron mother + } + } + } + } + tables.rowHfLcPiMcCheckReduced(pdgCodeBeautyMother, pdgCodeCharmMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2, pdgCodeProng3); + } + tables.rowHfLcPiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt); + } else if constexpr (decChannel == DecayChannel::B0ToDstarPi) { + // B0 → D*+ π- → (D0 π+) π- → (K- π+ π+) π- + auto indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kB0, std::array{+kKPlus, -kPiPlus, -kPiPlus, +kPiPlus}, true, &sign, 4); + if (indexRec > -1) { + // D*+ → (D0 π+) → K- π+ π+ + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, +Pdg::kDStar, std::array{-kKPlus, +kPiPlus, +kPiPlus}, true, &signD, 3); + if (indexRec > -1) { + std::vector arrDaughDstarIndex; + RecoDecay::getDaughters(particlesMc.rawIteratorAt(indexRec), &arrDaughDstarIndex, std::array{0}, 1); + if (arrDaughDstarIndex.size() == NDaughtersDstar) { + bool matchD0{0}; + for (auto iProng = 0u; iProng < arrDaughDstarIndex.size(); ++iProng) { + auto daughI = particlesMc.rawIteratorAt(arrDaughDstarIndex[iProng]); + if (std::abs(daughI.pdgCode()) == Pdg::kD0) { + matchD0 = RecoDecay::isMatchedMCGen(particlesMc, daughI, +Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD, 2); + } + } + if (matchD0) { + flag = sign * BIT(hf_cand_b0::DecayTypeMc::B0ToDstarPiToD0PiPiToKPiPiPi); + } else { + debug = 1; + LOGF(debug, "B0 decays in the expected final state but the condition on D* intermediate state is not fulfilled"); + } + } + } else { + debug = 1; + LOGF(debug, "B0 decays in the expected final state but the condition on the intermediate state is not fulfilled"); + } + + auto indexMother = RecoDecay::getMother(particlesMc, vecDaughtersB.back().template mcParticle_as(), Pdg::kB0, true); + if (indexMother >= 0) { + auto particleMother = particlesMc.rawIteratorAt(indexMother); + motherPt = particleMother.pt(); + checkWrongCollision(particleMother, collision, indexCollisionMaxNumContrib, flagWrongCollision); + } } - rowHfD0PiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt); + tables.rowHfDPiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt); } } - template + template void runDataCreation(Coll const& collision, CCharmCands const& candsC, aod::TrackAssoc const& trackIndices, TTracks const&, PParticles const& particlesMc, uint64_t const& indexCollisionMaxNumContrib, - aod::BCsWithTimestamps const&) + BBCs const&) { + registry.fill(HIST("hEvents"), 1 + Event::Processed); + float centrality = -1.f; + auto hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + if (configs.skipRejectedCollisions && hfRejMap != 0) { + return; + } + // helpers for ReducedTables filling - int indexHfReducedCollision = hfReducedCollision.lastIndex() + 1; + int indexHfReducedCollision = tables.hfReducedCollision.lastIndex() + 1; // std::map where the key is the track.globalIndex() and // the value is the track index in the table of the selected pions std::map selectedTracksPion; @@ -695,10 +1038,10 @@ struct HfDataCreatorCharmHadPiReduced { // Set the magnetic field from ccdb. // The static instance of the propagator was already modified in the HFTrackIndexSkimCreator, // but this is not true when running on Run2 data/MC already converted into AO2Ds. - auto bc = collision.template bc_as(); + auto bc = collision.template bc_as(); if (runNumber != bc.runNumber()) { LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; - o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(ccdbPathGrpMag, bc.timestamp()); + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(configs.ccdbPathGrpMag, bc.timestamp()); if (grpo == nullptr) { LOGF(fatal, "Run 3 GRP object (type o2::parameters::GRPMagField) is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp()); } @@ -714,37 +1057,58 @@ struct HfDataCreatorCharmHadPiReduced { int indexHfCandCharm{-1}; float invMassC0{-1.f}, invMassC1{-1.f}; if constexpr (decChannel == DecayChannel::B0ToDminusPi) { - indexHfCandCharm = hfCand3Prong.lastIndex() + 1; + indexHfCandCharm = tables.hfCand3Prong.lastIndex() + 1; invMassC0 = hfHelper.invMassDplusToPiKPi(candC); registry.fill(HIST("hMassDplus"), invMassC0); registry.fill(HIST("hPtDplus"), candC.pt()); registry.fill(HIST("hCpaDplus"), candC.cpa()); } else if constexpr (decChannel == DecayChannel::BsToDsminusPi) { - indexHfCandCharm = hfCand3Prong.lastIndex() + 1; - if (candC.isSelDsToKKPi() >= selectionFlagDs) { + indexHfCandCharm = tables.hfCand3Prong.lastIndex() + 1; + if (candC.isSelDsToKKPi() >= hfflagConfigurations.selectionFlagDs) { invMassC0 = hfHelper.invMassDsToKKPi(candC); registry.fill(HIST("hMassDsToKKPi"), invMassC0); } - if (candC.isSelDsToPiKK() >= selectionFlagDs) { + if (candC.isSelDsToPiKK() >= hfflagConfigurations.selectionFlagDs) { invMassC1 = hfHelper.invMassDsToPiKK(candC); registry.fill(HIST("hMassDsToPiKK"), invMassC1); } registry.fill(HIST("hPtDs"), candC.pt()); registry.fill(HIST("hCpaDs"), candC.cpa()); } else if constexpr (decChannel == DecayChannel::BplusToD0barPi) { - indexHfCandCharm = hfCand2Prong.lastIndex() + 1; - if (candC.isSelD0() >= selectionFlagD0) { + indexHfCandCharm = tables.hfCand2Prong.lastIndex() + 1; + if (candC.isSelD0() >= hfflagConfigurations.selectionFlagD0) { invMassC0 = hfHelper.invMassD0ToPiK(candC); registry.fill(HIST("hMassD0"), invMassC0); } - if (candC.isSelD0bar() >= selectionFlagD0bar) { + if (candC.isSelD0bar() >= hfflagConfigurations.selectionFlagD0bar) { invMassC1 = hfHelper.invMassD0barToKPi(candC); registry.fill(HIST("hMassD0bar"), invMassC1); } registry.fill(HIST("hPtD0"), candC.pt()); registry.fill(HIST("hCpaD0"), candC.cpa()); + } else if constexpr (decChannel == DecayChannel::LbToLcplusPi) { + indexHfCandCharm = tables.hfCand3Prong.lastIndex() + 1; + if (candC.isSelLcToPKPi() >= hfflagConfigurations.selectionFlagLc) { + invMassC0 = hfHelper.invMassLcToPKPi(candC); + registry.fill(HIST("hMassLcToPKPi"), invMassC0); + } + if (candC.isSelLcToPiKP() >= hfflagConfigurations.selectionFlagLc) { + invMassC1 = hfHelper.invMassLcToPiKP(candC); + registry.fill(HIST("hMassLcToPiKP"), invMassC1); + } + registry.fill(HIST("hPtLc"), candC.pt()); + registry.fill(HIST("hCpaLc"), candC.cpa()); + } else if constexpr (decChannel == DecayChannel::B0ToDstarPi) { + indexHfCandCharm = tables.hfCand3Prong.lastIndex() + 1; + if (candC.signSoftPi() > 0) { + invMassC0 = candC.invMassDstar() - candC.invMassD0(); + } else { + invMassC0 = candC.invMassAntiDstar() - candC.invMassD0Bar(); + } + registry.fill(HIST("hMassDstarToD0Pi"), invMassC0); + registry.fill(HIST("hPtDstar"), candC.pt()); + registry.fill(HIST("hCpaDstar"), candC.cpaD0()); } - bool fillHfCandCharm = false; std::vector charmHadDauTracks{candC.template prong0_as(), candC.template prong1_as()}; @@ -769,8 +1133,12 @@ struct HfDataCreatorCharmHadPiReduced { } // third track, if it's a 3-prong - if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi) { - charmHadDauTracks.push_back(candC.template prong2_as()); + if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi || decChannel == DecayChannel::LbToLcplusPi || decChannel == DecayChannel::B0ToDstarPi) { + if constexpr (decChannel == DecayChannel::B0ToDstarPi) { + charmHadDauTracks.push_back(candC.template prongPi_as()); // Soft pion from D* decay + } else { + charmHadDauTracks.push_back(candC.template prong2_as()); + } trackParCov2 = getTrackParCov(charmHadDauTracks[2]); pVec2 = charmHadDauTracks[2].pVector(); auto dca2 = o2::dataformats::DCA(charmHadDauTracks[2].dcaXY(), charmHadDauTracks[2].dcaZ(), charmHadDauTracks[2].cYY(), charmHadDauTracks[2].cZY(), charmHadDauTracks[2].cZZ()); @@ -784,12 +1152,14 @@ struct HfDataCreatorCharmHadPiReduced { // reconstruct charm candidate secondary vertex o2::track::TrackParCov trackParCovCharmHad{}; std::array pVecCharm{}; - if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi) { // D∓ → π∓ K± π∓ and Ds∓ → K∓ K± π∓ + if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi || decChannel == DecayChannel::LbToLcplusPi) { // D∓ → π∓ K± π∓ and Ds∓ → K∓ K± π∓ and Lc∓ → p∓ K± π∓ if constexpr (decChannel == DecayChannel::B0ToDminusPi) { hCandidatesDPlus->Fill(SVFitting::BeforeFit); - } else { + } else if constexpr (decChannel == DecayChannel::BsToDsminusPi) { hCandidatesDs->Fill(SVFitting::BeforeFit); + } else if constexpr (decChannel == DecayChannel::LbToLcplusPi) { + hCandidatesLc->Fill(SVFitting::BeforeFit); } try { @@ -800,15 +1170,19 @@ struct HfDataCreatorCharmHadPiReduced { LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; if constexpr (decChannel == DecayChannel::B0ToDminusPi) { hCandidatesDPlus->Fill(SVFitting::Fail); - } else { + } else if constexpr (decChannel == DecayChannel::BsToDsminusPi) { hCandidatesDs->Fill(SVFitting::Fail); + } else if constexpr (decChannel == DecayChannel::LbToLcplusPi) { + hCandidatesLc->Fill(SVFitting::Fail); } continue; } if constexpr (decChannel == DecayChannel::B0ToDminusPi) { hCandidatesDPlus->Fill(SVFitting::FitOk); - } else { + } else if constexpr (decChannel == DecayChannel::BsToDsminusPi) { hCandidatesDs->Fill(SVFitting::FitOk); + } else if constexpr (decChannel == DecayChannel::LbToLcplusPi) { + hCandidatesLc->Fill(SVFitting::FitOk); } auto secondaryVertexCharm = df3.getPCACandidate(); @@ -835,6 +1209,28 @@ struct HfDataCreatorCharmHadPiReduced { } hCandidatesD0->Fill(SVFitting::FitOk); + auto secondaryVertexCharm = df2.getPCACandidate(); + trackParCov0.propagateTo(secondaryVertexCharm[0], bz); + trackParCov1.propagateTo(secondaryVertexCharm[0], bz); + df2.getTrack(0).getPxPyPzGlo(pVec0); + df2.getTrack(1).getPxPyPzGlo(pVec1); + pVecCharm = RecoDecay::pVec(pVec0, pVec1); + trackParCovCharmHad = df2.createParentTrackParCov(); + trackParCovCharmHad.setAbsCharge(0); // to be sure + } else if constexpr (decChannel == DecayChannel::B0ToDstarPi) { + + hCandidatesDstar->Fill(SVFitting::BeforeFit); + try { + // D0 vertex + if (df2.process(trackParCov0, trackParCov1) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + hCandidatesDstar->Fill(SVFitting::Fail); + continue; + } + hCandidatesDstar->Fill(SVFitting::FitOk); auto secondaryVertexCharm = df2.getPCACandidate(); trackParCov0.propagateTo(secondaryVertexCharm[0], bz); trackParCov1.propagateTo(secondaryVertexCharm[0], bz); @@ -870,7 +1266,7 @@ struct HfDataCreatorCharmHadPiReduced { // apply selections on pion tracks auto trackParCovPion = getTrackParCov(trackPion); - o2::gpu::gpustd::array dcaPion{trackPion.dcaXY(), trackPion.dcaZ()}; + std::array dcaPion{trackPion.dcaXY(), trackPion.dcaZ()}; std::array pVecPion = trackPion.pVector(); if (trackPion.collisionId() != thisCollId) { o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovPion, 2.f, noMatCorr, &dcaPion); @@ -878,12 +1274,12 @@ struct HfDataCreatorCharmHadPiReduced { } // reject pi D with same sign as D - if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi) { // D∓ → π∓ K± π∓ and Ds∓ → K∓ K± π∓ + if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi || decChannel == DecayChannel::LbToLcplusPi || decChannel == DecayChannel::B0ToDstarPi) { // D∓ → π∓ K± π∓ and Ds∓ → K∓ K± π∓ and Lc∓ → p∓ K± π∓ and D*+ → D0 π+ if (trackPion.sign() * charmHadDauTracks[0].sign() > 0) { continue; } } else if constexpr (decChannel == DecayChannel::BplusToD0barPi) { // D0(bar) → K± π∓ - if (!((candC.isSelD0() >= selectionFlagD0 && trackPion.sign() < 0) || (candC.isSelD0bar() >= selectionFlagD0bar && trackPion.sign() > 0))) { + if (!((candC.isSelD0() >= hfflagConfigurations.selectionFlagD0 && trackPion.sign() < 0) || (candC.isSelD0bar() >= hfflagConfigurations.selectionFlagD0bar && trackPion.sign() > 0))) { continue; } } @@ -895,7 +1291,7 @@ struct HfDataCreatorCharmHadPiReduced { registry.fill(HIST("hPtPion"), trackParCovPion.getPt()); // compute invariant mass square and apply selection - auto invMass2DPi = RecoDecay::m2(std::array{pVecCharm, pVecPion}, std::array{massC, massPi}); + auto invMass2DPi = RecoDecay::m2(std::array{pVecCharm, pVecPion}, std::array{massC, MassPiPlus}); if ((invMass2DPi < invMass2ChHadPiMin) || (invMass2DPi > invMass2ChHadPiMax)) { continue; } @@ -903,23 +1299,23 @@ struct HfDataCreatorCharmHadPiReduced { // fill Pion tracks table // if information on track already stored, go to next track if (!selectedTracksPion.count(trackPion.globalIndex())) { - hfTrackPion(trackPion.globalIndex(), indexHfReducedCollision, - trackParCovPion.getX(), trackParCovPion.getAlpha(), - trackParCovPion.getY(), trackParCovPion.getZ(), trackParCovPion.getSnp(), - trackParCovPion.getTgl(), trackParCovPion.getQ2Pt(), - trackPion.itsNCls(), trackPion.tpcNClsCrossedRows(), trackPion.tpcChi2NCl()); - hfTrackCovPion(trackParCovPion.getSigmaY2(), trackParCovPion.getSigmaZY(), trackParCovPion.getSigmaZ2(), - trackParCovPion.getSigmaSnpY(), trackParCovPion.getSigmaSnpZ(), - trackParCovPion.getSigmaSnp2(), trackParCovPion.getSigmaTglY(), trackParCovPion.getSigmaTglZ(), - trackParCovPion.getSigmaTglSnp(), trackParCovPion.getSigmaTgl2(), - trackParCovPion.getSigma1PtY(), trackParCovPion.getSigma1PtZ(), trackParCovPion.getSigma1PtSnp(), - trackParCovPion.getSigma1PtTgl(), trackParCovPion.getSigma1Pt2()); - hfTrackPidPion(trackPion.hasTPC(), trackPion.hasTOF(), - trackPion.tpcNSigmaPi(), trackPion.tofNSigmaPi()); + tables.hfTrackPion(trackPion.globalIndex(), indexHfReducedCollision, + trackParCovPion.getX(), trackParCovPion.getAlpha(), + trackParCovPion.getY(), trackParCovPion.getZ(), trackParCovPion.getSnp(), + trackParCovPion.getTgl(), trackParCovPion.getQ2Pt(), + trackPion.itsNCls(), trackPion.tpcNClsCrossedRows(), trackPion.tpcChi2NCl()); + tables.hfTrackCovPion(trackParCovPion.getSigmaY2(), trackParCovPion.getSigmaZY(), trackParCovPion.getSigmaZ2(), + trackParCovPion.getSigmaSnpY(), trackParCovPion.getSigmaSnpZ(), + trackParCovPion.getSigmaSnp2(), trackParCovPion.getSigmaTglY(), trackParCovPion.getSigmaTglZ(), + trackParCovPion.getSigmaTglSnp(), trackParCovPion.getSigmaTgl2(), + trackParCovPion.getSigma1PtY(), trackParCovPion.getSigma1PtZ(), trackParCovPion.getSigma1PtSnp(), + trackParCovPion.getSigma1PtTgl(), trackParCovPion.getSigma1Pt2()); + tables.hfTrackPidPion(trackPion.hasTPC(), trackPion.hasTOF(), + trackPion.tpcNSigmaPi(), trackPion.tofNSigmaPi()); // add trackPion.globalIndex() to a list // to keep memory of the pions filled in the table and avoid refilling them if they are paired to another D candidate - // and keep track of their index in hfTrackPion for McRec purposes - selectedTracksPion[trackPion.globalIndex()] = hfTrackPion.lastIndex(); + // and keep track of their index in tables.hfTrackPion for McRec purposes + selectedTracksPion[trackPion.globalIndex()] = tables.hfTrackPion.lastIndex(); } if constexpr (doMc) { @@ -931,89 +1327,186 @@ struct HfDataCreatorCharmHadPiReduced { fillMcRecoInfo(collision, particlesMc, beautyHadDauTracks, indexHfCandCharm, selectedTracksPion, indexCollisionMaxNumContrib); } fillHfCandCharm = true; - } // pion loop - if (fillHfCandCharm) { // fill candCplus table only once per D candidate - if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi) { // D∓ → π∓ K± π∓ and Ds∓ → K∓ K± π∓ - hfCand3Prong(charmHadDauTracks[0].globalIndex(), charmHadDauTracks[1].globalIndex(), charmHadDauTracks[2].globalIndex(), - indexHfReducedCollision, - trackParCovCharmHad.getX(), trackParCovCharmHad.getAlpha(), - trackParCovCharmHad.getY(), trackParCovCharmHad.getZ(), trackParCovCharmHad.getSnp(), - trackParCovCharmHad.getTgl(), trackParCovCharmHad.getQ2Pt(), - candC.xSecondaryVertex(), candC.ySecondaryVertex(), candC.zSecondaryVertex(), invMassC0, invMassC1, - ptDauMin, etaDauMin, nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax); - hfCand3ProngCov(trackParCovCharmHad.getSigmaY2(), trackParCovCharmHad.getSigmaZY(), trackParCovCharmHad.getSigmaZ2(), - trackParCovCharmHad.getSigmaSnpY(), trackParCovCharmHad.getSigmaSnpZ(), - trackParCovCharmHad.getSigmaSnp2(), trackParCovCharmHad.getSigmaTglY(), trackParCovCharmHad.getSigmaTglZ(), - trackParCovCharmHad.getSigmaTglSnp(), trackParCovCharmHad.getSigmaTgl2(), - trackParCovCharmHad.getSigma1PtY(), trackParCovCharmHad.getSigma1PtZ(), trackParCovCharmHad.getSigma1PtSnp(), - trackParCovCharmHad.getSigma1PtTgl(), trackParCovCharmHad.getSigma1Pt2()); - hfCandPidProng0(charmHadDauTracks[0].tpcNSigmaPi(), charmHadDauTracks[0].tofNSigmaPi(), charmHadDauTracks[0].tpcNSigmaKa(), charmHadDauTracks[0].tofNSigmaKa(), charmHadDauTracks[0].hasTOF(), charmHadDauTracks[0].hasTPC()); - hfCandPidProng1(charmHadDauTracks[1].tpcNSigmaPi(), charmHadDauTracks[1].tofNSigmaPi(), charmHadDauTracks[1].tpcNSigmaKa(), charmHadDauTracks[1].tofNSigmaKa(), charmHadDauTracks[1].hasTOF(), charmHadDauTracks[1].hasTPC()); - hfCandPidProng2(charmHadDauTracks[2].tpcNSigmaPi(), charmHadDauTracks[2].tofNSigmaPi(), charmHadDauTracks[2].tpcNSigmaKa(), charmHadDauTracks[2].tofNSigmaKa(), charmHadDauTracks[2].hasTOF(), charmHadDauTracks[2].hasTPC()); + } // pion loop + if (fillHfCandCharm) { // fill candCplus table only once per D candidate + constexpr std::size_t NSizeMLScore{3u}; + if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi || decChannel == DecayChannel::LbToLcplusPi) { // D∓ → π∓ K± π∓ and Ds∓ → K∓ K± π∓ and Lc∓ → p∓ K± π∓ + tables.hfCand3Prong(charmHadDauTracks[0].globalIndex(), charmHadDauTracks[1].globalIndex(), charmHadDauTracks[2].globalIndex(), + indexHfReducedCollision, + trackParCovCharmHad.getX(), trackParCovCharmHad.getAlpha(), + trackParCovCharmHad.getY(), trackParCovCharmHad.getZ(), trackParCovCharmHad.getSnp(), + trackParCovCharmHad.getTgl(), trackParCovCharmHad.getQ2Pt(), + candC.xSecondaryVertex(), candC.ySecondaryVertex(), candC.zSecondaryVertex(), invMassC0, invMassC1, + ptDauMin, etaDauMin, nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax); + tables.hfCand3ProngCov(trackParCovCharmHad.getSigmaY2(), trackParCovCharmHad.getSigmaZY(), trackParCovCharmHad.getSigmaZ2(), + trackParCovCharmHad.getSigmaSnpY(), trackParCovCharmHad.getSigmaSnpZ(), + trackParCovCharmHad.getSigmaSnp2(), trackParCovCharmHad.getSigmaTglY(), trackParCovCharmHad.getSigmaTglZ(), + trackParCovCharmHad.getSigmaTglSnp(), trackParCovCharmHad.getSigmaTgl2(), + trackParCovCharmHad.getSigma1PtY(), trackParCovCharmHad.getSigma1PtZ(), trackParCovCharmHad.getSigma1PtSnp(), + trackParCovCharmHad.getSigma1PtTgl(), trackParCovCharmHad.getSigma1Pt2()); + float nSigmaTpcPr0{-999.f}, nSigmaTpcPr1{-999.f}, nSigmaTpcPr2{-999.f}; + float nSigmaTofPr0{-999.f}, nSigmaTofPr1{-999.f}, nSigmaTofPr2{-999.f}; + if constexpr (decChannel == DecayChannel::LbToLcplusPi) { + /// assign non-dummy values only for Lb->LcPi analysis + nSigmaTpcPr0 = candC.nSigTpcPr0(); + nSigmaTpcPr1 = candC.nSigTpcPr1(); + nSigmaTpcPr2 = candC.nSigTpcPr2(); + nSigmaTofPr0 = candC.nSigTofPr0(); + nSigmaTofPr1 = candC.nSigTofPr1(); + nSigmaTofPr2 = candC.nSigTofPr2(); + } + tables.hfCandPidProng0(candC.nSigTpcPi0(), candC.nSigTofPi0(), candC.nSigTpcKa0(), candC.nSigTofKa0(), nSigmaTpcPr0, nSigmaTofPr0, charmHadDauTracks[0].hasTOF(), charmHadDauTracks[0].hasTPC()); + tables.hfCandPidProng1(candC.nSigTpcPi1(), candC.nSigTofPi1(), candC.nSigTpcKa1(), candC.nSigTofKa1(), nSigmaTpcPr1, nSigmaTofPr1, charmHadDauTracks[1].hasTOF(), charmHadDauTracks[1].hasTPC()); + tables.hfCandPidProng2(candC.nSigTpcPi2(), candC.nSigTofPi2(), candC.nSigTpcKa2(), candC.nSigTofKa2(), nSigmaTpcPr2, nSigmaTofPr2, charmHadDauTracks[2].hasTOF(), charmHadDauTracks[2].hasTPC()); if constexpr (withMl) { + std::array mlScores = {-1.f, -1.f, -1.f, -1.f, -1.f, -1.f}; if constexpr (decChannel == DecayChannel::B0ToDminusPi) { - hfCand3ProngMl(candC.mlProbDplusToPiKPi()[0], candC.mlProbDplusToPiKPi()[1], candC.mlProbDplusToPiKPi()[2], -1., -1., -1.); - } else { - std::array mlScores = {-1.f, -1.f, -1.f, -1.f, -1.f, -1.f}; - if (candC.mlProbDsToKKPi().size() == 3) { + tables.hfCand3ProngMl(candC.mlProbDplusToPiKPi()[0], candC.mlProbDplusToPiKPi()[1], candC.mlProbDplusToPiKPi()[2], -1., -1., -1.); + } else if constexpr (decChannel == DecayChannel::BsToDsminusPi) { + if (candC.mlProbDsToKKPi().size() == NSizeMLScore) { std::copy(candC.mlProbDsToKKPi().begin(), candC.mlProbDsToKKPi().end(), mlScores.begin()); } - if (candC.mlProbDsToPiKK().size() == 3) { + if (candC.mlProbDsToPiKK().size() == NSizeMLScore) { std::copy(candC.mlProbDsToPiKK().begin(), candC.mlProbDsToPiKK().end(), mlScores.begin() + 3); } - hfCand3ProngMl(mlScores[0], mlScores[1], mlScores[2], mlScores[3], mlScores[4], mlScores[5]); + tables.hfCand3ProngMl(mlScores[0], mlScores[1], mlScores[2], mlScores[3], mlScores[4], mlScores[5]); + } else if constexpr (decChannel == DecayChannel::LbToLcplusPi) { + if (candC.mlProbLcToPKPi().size() == NSizeMLScore) { + std::copy(candC.mlProbLcToPKPi().begin(), candC.mlProbLcToPKPi().end(), mlScores.begin()); + } + if (candC.mlProbLcToPiKP().size() == NSizeMLScore) { + std::copy(candC.mlProbLcToPiKP().begin(), candC.mlProbLcToPiKP().end(), mlScores.begin() + 3); + } + tables.hfCand3ProngMl(mlScores[0], mlScores[1], mlScores[2], mlScores[3], mlScores[4], mlScores[5]); } } } else if constexpr (decChannel == DecayChannel::BplusToD0barPi) { // D0(bar) → K± π∓ - hfCand2Prong(charmHadDauTracks[0].globalIndex(), charmHadDauTracks[1].globalIndex(), - indexHfReducedCollision, - trackParCovCharmHad.getX(), trackParCovCharmHad.getAlpha(), - trackParCovCharmHad.getY(), trackParCovCharmHad.getZ(), trackParCovCharmHad.getSnp(), - trackParCovCharmHad.getTgl(), trackParCovCharmHad.getQ2Pt(), - candC.xSecondaryVertex(), candC.ySecondaryVertex(), candC.zSecondaryVertex(), invMassC0, invMassC1, - ptDauMin, etaDauMin, nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax); - hfCand2ProngCov(trackParCovCharmHad.getSigmaY2(), trackParCovCharmHad.getSigmaZY(), trackParCovCharmHad.getSigmaZ2(), - trackParCovCharmHad.getSigmaSnpY(), trackParCovCharmHad.getSigmaSnpZ(), - trackParCovCharmHad.getSigmaSnp2(), trackParCovCharmHad.getSigmaTglY(), trackParCovCharmHad.getSigmaTglZ(), - trackParCovCharmHad.getSigmaTglSnp(), trackParCovCharmHad.getSigmaTgl2(), - trackParCovCharmHad.getSigma1PtY(), trackParCovCharmHad.getSigma1PtZ(), trackParCovCharmHad.getSigma1PtSnp(), - trackParCovCharmHad.getSigma1PtTgl(), trackParCovCharmHad.getSigma1Pt2()); - hfCandPidProng0(candC.nSigTpcPi0(), candC.nSigTofPi0(), candC.nSigTpcKa0(), candC.nSigTofKa0(), charmHadDauTracks[0].hasTOF(), charmHadDauTracks[0].hasTPC()); - hfCandPidProng1(candC.nSigTpcPi1(), candC.nSigTofPi1(), candC.nSigTpcKa1(), candC.nSigTofKa1(), charmHadDauTracks[1].hasTOF(), charmHadDauTracks[1].hasTPC()); + tables.hfCand2Prong(charmHadDauTracks[0].globalIndex(), charmHadDauTracks[1].globalIndex(), + indexHfReducedCollision, + trackParCovCharmHad.getX(), trackParCovCharmHad.getAlpha(), + trackParCovCharmHad.getY(), trackParCovCharmHad.getZ(), trackParCovCharmHad.getSnp(), + trackParCovCharmHad.getTgl(), trackParCovCharmHad.getQ2Pt(), + candC.xSecondaryVertex(), candC.ySecondaryVertex(), candC.zSecondaryVertex(), invMassC0, invMassC1, + ptDauMin, etaDauMin, nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax); + tables.hfCand2ProngCov(trackParCovCharmHad.getSigmaY2(), trackParCovCharmHad.getSigmaZY(), trackParCovCharmHad.getSigmaZ2(), + trackParCovCharmHad.getSigmaSnpY(), trackParCovCharmHad.getSigmaSnpZ(), + trackParCovCharmHad.getSigmaSnp2(), trackParCovCharmHad.getSigmaTglY(), trackParCovCharmHad.getSigmaTglZ(), + trackParCovCharmHad.getSigmaTglSnp(), trackParCovCharmHad.getSigmaTgl2(), + trackParCovCharmHad.getSigma1PtY(), trackParCovCharmHad.getSigma1PtZ(), trackParCovCharmHad.getSigma1PtSnp(), + trackParCovCharmHad.getSigma1PtTgl(), trackParCovCharmHad.getSigma1Pt2()); + tables.hfCandPidProng0(candC.nSigTpcPi0(), candC.nSigTofPi0(), candC.nSigTpcKa0(), candC.nSigTofKa0(), 0., 0., charmHadDauTracks[0].hasTOF(), charmHadDauTracks[0].hasTPC()); + tables.hfCandPidProng1(candC.nSigTpcPi1(), candC.nSigTofPi1(), candC.nSigTpcKa1(), candC.nSigTofKa1(), 0., 0., charmHadDauTracks[1].hasTOF(), charmHadDauTracks[1].hasTPC()); if constexpr (withMl) { std::array mlScores = {-1.f, -1.f, -1.f, -1.f, -1.f, -1.f}; - if (candC.mlProbD0().size() == 3) { + if (candC.mlProbD0().size() == NSizeMLScore) { std::copy(candC.mlProbD0().begin(), candC.mlProbD0().end(), mlScores.begin()); } - if (candC.mlProbD0bar().size() == 3) { + if (candC.mlProbD0bar().size() == NSizeMLScore) { std::copy(candC.mlProbD0bar().begin(), candC.mlProbD0bar().end(), mlScores.begin() + 3); } - hfCand2ProngMl(mlScores[0], mlScores[1], mlScores[2], mlScores[3], mlScores[4], mlScores[5]); + tables.hfCand2ProngMl(mlScores[0], mlScores[1], mlScores[2], mlScores[3], mlScores[4], mlScores[5]); + } + } else if constexpr (decChannel == DecayChannel::B0ToDstarPi) { + tables.hfCand2Prong(charmHadDauTracks[0].globalIndex(), charmHadDauTracks[1].globalIndex(), + indexHfReducedCollision, + trackParCovCharmHad.getX(), trackParCovCharmHad.getAlpha(), + trackParCovCharmHad.getY(), trackParCovCharmHad.getZ(), trackParCovCharmHad.getSnp(), + trackParCovCharmHad.getTgl(), trackParCovCharmHad.getQ2Pt(), + candC.xSecondaryVertexD0(), candC.ySecondaryVertexD0(), candC.zSecondaryVertexD0(), invMassC0, invMassC1, + ptDauMin, etaDauMin, nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax); + tables.hfCand2ProngCov(trackParCovCharmHad.getSigmaY2(), trackParCovCharmHad.getSigmaZY(), trackParCovCharmHad.getSigmaZ2(), + trackParCovCharmHad.getSigmaSnpY(), trackParCovCharmHad.getSigmaSnpZ(), + trackParCovCharmHad.getSigmaSnp2(), trackParCovCharmHad.getSigmaTglY(), trackParCovCharmHad.getSigmaTglZ(), + trackParCovCharmHad.getSigmaTglSnp(), trackParCovCharmHad.getSigmaTgl2(), + trackParCovCharmHad.getSigma1PtY(), trackParCovCharmHad.getSigma1PtZ(), trackParCovCharmHad.getSigma1PtSnp(), + trackParCovCharmHad.getSigma1PtTgl(), trackParCovCharmHad.getSigma1Pt2()); + float nSigmaTpcPr0{-999.f}, nSigmaTpcPr1{-999.f}; + float nSigmaTofPr0{-999.f}, nSigmaTofPr1{-999.f}; + tables.hfCandPidProng0(candC.nSigTpcPi0(), candC.nSigTofPi0(), candC.nSigTpcKa0(), candC.nSigTofKa0(), nSigmaTpcPr0, nSigmaTofPr0, charmHadDauTracks[0].hasTOF(), charmHadDauTracks[0].hasTPC()); + tables.hfCandPidProng1(candC.nSigTpcPi1(), candC.nSigTofPi1(), candC.nSigTpcKa1(), candC.nSigTofKa1(), nSigmaTpcPr1, nSigmaTofPr1, charmHadDauTracks[1].hasTOF(), charmHadDauTracks[1].hasTPC()); + + // Soft pion tables + auto trackSoftPion = charmHadDauTracks.back(); + auto trackParCovSoftPion = getTrackParCov(trackSoftPion); + std::array dcaSoftPion{trackSoftPion.dcaXY(), trackSoftPion.dcaZ()}; + std::array pVecSoftPion = trackSoftPion.pVector(); + if (trackSoftPion.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovSoftPion, 2.f, noMatCorr, &dcaSoftPion); + getPxPyPz(trackParCovSoftPion, pVecSoftPion); + } + tables.hfTrackSoftPion(trackSoftPion.globalIndex(), indexHfReducedCollision, + trackParCovSoftPion.getX(), trackParCovSoftPion.getAlpha(), + trackParCovSoftPion.getY(), trackParCovSoftPion.getZ(), trackParCovSoftPion.getSnp(), + trackParCovSoftPion.getTgl(), trackParCovSoftPion.getQ2Pt(), + trackSoftPion.itsNCls(), trackSoftPion.tpcNClsCrossedRows(), trackSoftPion.tpcChi2NCl()); + tables.hfTrackCovSoftPion(trackParCovSoftPion.getSigmaY2(), trackParCovSoftPion.getSigmaZY(), trackParCovSoftPion.getSigmaZ2(), + trackParCovSoftPion.getSigmaSnpY(), trackParCovSoftPion.getSigmaSnpZ(), + trackParCovSoftPion.getSigmaSnp2(), trackParCovSoftPion.getSigmaTglY(), trackParCovSoftPion.getSigmaTglZ(), + trackParCovSoftPion.getSigmaTglSnp(), trackParCovSoftPion.getSigmaTgl2(), + trackParCovSoftPion.getSigma1PtY(), trackParCovSoftPion.getSigma1PtZ(), trackParCovSoftPion.getSigma1PtSnp(), + trackParCovSoftPion.getSigma1PtTgl(), trackParCovSoftPion.getSigma1Pt2()); + if constexpr (withMl) { + std::array mlScores = {-1.f, -1.f, -1.f, -1.f, -1.f, -1.f}; + if (candC.mlProbDstarToD0Pi().size() == NSizeMLScore) { + std::copy(candC.mlProbDstarToD0Pi().begin(), candC.mlProbDstarToD0Pi().end(), mlScores.begin()); + } + tables.hfCand3ProngMl(mlScores[0], mlScores[1], mlScores[2], -1.f, -1.f, -1.f); } } fillHfReducedCollision = true; } } // candsC loop - registry.fill(HIST("hEvents"), 1 + Event::Processed); if (!fillHfReducedCollision) { registry.fill(HIST("hEvents"), 1 + Event::NoCharmHadPiSelected); return; } registry.fill(HIST("hEvents"), 1 + Event::CharmHadPiSelected); - float centrality = -1.f; - uint16_t hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + // fill collision table if it contains a DPi pair a minima - hfReducedCollision(collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), hfRejMap, bz); - hfReducedCollExtra(collision.covXX(), collision.covXY(), collision.covYY(), - collision.covXZ(), collision.covYZ(), collision.covZZ()); + tables.hfReducedCollision(collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), hfRejMap, bz); + tables.hfReducedCollExtra(collision.covXX(), collision.covXY(), collision.covYY(), + collision.covXZ(), collision.covYZ(), collision.covZZ()); + tables.hfReducedCollCentrality(collision.centFT0C(), collision.centFT0M(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); + if constexpr (withQvec) { + tables.hfReducedQvector(collision.qvecFT0CRe(), collision.qvecFT0CIm(), collision.sumAmplFT0C(), + collision.qvecFT0ARe(), collision.qvecFT0AIm(), collision.sumAmplFT0A(), + collision.qvecFT0MRe(), collision.qvecFT0MIm(), collision.sumAmplFT0M(), + collision.qvecTPCposRe(), collision.qvecTPCposIm(), collision.nTrkTPCpos(), + collision.qvecTPCnegRe(), collision.qvecTPCnegIm(), collision.nTrkTPCneg(), + collision.qvecTPCallRe(), collision.qvecTPCallIm(), collision.nTrkTPCall()); + } } template - void runMcGen(aod::McParticles const& particlesMc) + void runMcGen(aod::McCollision const& mcCollision, + aod::McParticles const& particlesMc, + CollisionsWCentAndMcLabels const& collisions, + BCsInfo const&) { + // Check event selection + float centDummy{-1.f}, centFT0C{-1.f}, centFT0M{-1.f}; + const auto collSlice = collisions.sliceBy(preslices.colPerMcCollision, mcCollision.globalIndex()); + auto hfRejMap = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centDummy); + if (configs.skipRejectedCollisions && hfRejMap != 0) { + return; + } + + // get centrality + float multiplicity{0.f}; + for (const auto& collision : collSlice) { + float collMult = collision.numContrib(); + if (collMult > multiplicity) { + centFT0C = collision.centFT0C(); + centFT0M = collision.centFT0M(); + multiplicity = collMult; + } + } + + const auto mcParticlesPerMcColl = particlesMc.sliceBy(preslices.mcParticlesPerMcCollision, mcCollision.globalIndex()); + // Match generated particles. - for (const auto& particle : particlesMc) { + for (const auto& particle : mcParticlesPerMcColl) { int8_t sign{0}; int8_t flag{0}; if constexpr (decayChannel == DecayChannel::B0ToDminusPi) { @@ -1046,9 +1539,9 @@ struct HfDataCreatorCharmHadPiReduced { yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); counter++; } - rowHfB0McGenReduced(flag, ptParticle, yParticle, etaParticle, - ptProngs[0], yProngs[0], etaProngs[0], - ptProngs[1], yProngs[1], etaProngs[1]); + tables.rowHfB0McGenReduced(flag, -1 /*channel*/, ptParticle, yParticle, etaParticle, + ptProngs[0], yProngs[0], etaProngs[0], + ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M); } else if constexpr (decayChannel == DecayChannel::BsToDsminusPi) { // Bs → Ds- π+ if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kBS, std::array{-static_cast(Pdg::kDS), +kPiPlus}, true)) { @@ -1058,7 +1551,7 @@ struct HfDataCreatorCharmHadPiReduced { std::vector arrDaughDsIndex; std::array arrPDGDaughDs; RecoDecay::getDaughters(candCMC, &arrDaughDsIndex, std::array{0}, 1); - if (arrDaughDsIndex.size() == 2) { + if (arrDaughDsIndex.size() == NDaughtersDs) { for (auto jProng = 0u; jProng < arrDaughDsIndex.size(); ++jProng) { auto daughJ = particlesMc.rawIteratorAt(arrDaughDsIndex[jProng]); arrPDGDaughDs[jProng] = std::abs(daughJ.pdgCode()); @@ -1074,7 +1567,7 @@ struct HfDataCreatorCharmHadPiReduced { } // additional checks for correlated backgrounds - if (checkDecayTypeMc) { + if (configs.checkDecayTypeMc) { // B0 → Ds- π+ if (!flag) { if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kB0, std::array{-static_cast(Pdg::kDS), +kPiPlus}, true)) { @@ -1084,7 +1577,7 @@ struct HfDataCreatorCharmHadPiReduced { std::vector arrDaughDsIndex; std::array arrPDGDaughDs; RecoDecay::getDaughters(candCMC, &arrDaughDsIndex, std::array{0}, 1); - if (arrDaughDsIndex.size() == 2) { + if (arrDaughDsIndex.size() == NDaughtersDs) { for (auto jProng = 0u; jProng < arrDaughDsIndex.size(); ++jProng) { auto daughJ = particlesMc.rawIteratorAt(arrDaughDsIndex[jProng]); arrPDGDaughDs[jProng] = std::abs(daughJ.pdgCode()); @@ -1121,9 +1614,9 @@ struct HfDataCreatorCharmHadPiReduced { yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); counter++; } - rowHfBsMcGenReduced(flag, ptParticle, yParticle, etaParticle, - ptProngs[0], yProngs[0], etaProngs[0], - ptProngs[1], yProngs[1], etaProngs[1]); + tables.rowHfBsMcGenReduced(flag, -1 /*channel*/, ptParticle, yParticle, etaParticle, + ptProngs[0], yProngs[0], etaProngs[0], + ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M); } else if constexpr (decayChannel == DecayChannel::BplusToD0barPi) { // B+ → D0bar π+ if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kBPlus, std::array{-static_cast(Pdg::kD0), +kPiPlus}, true)) { @@ -1154,25 +1647,91 @@ struct HfDataCreatorCharmHadPiReduced { yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); counter++; } - rowHfBpMcGenReduced(flag, ptParticle, yParticle, etaParticle, - ptProngs[0], yProngs[0], etaProngs[0], - ptProngs[1], yProngs[1], etaProngs[1]); - } - } // gen - } + tables.rowHfBpMcGenReduced(flag, -1 /*channel*/, ptParticle, yParticle, etaParticle, + ptProngs[0], yProngs[0], etaProngs[0], + ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M); + } else if constexpr (decayChannel == DecayChannel::LbToLcplusPi) { + // Lb → Lc+ π- + if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kLambdaB0, std::array{static_cast(Pdg::kLambdaCPlus), -kPiPlus}, true)) { + // Match Lc+ → p K- π+ + auto candCMC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); + // Printf("Checking Lc+ → p K- π+"); + if (RecoDecay::isMatchedMCGen(particlesMc, candCMC, static_cast(Pdg::kLambdaCPlus), std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2)) { + flag = sign * BIT(hf_cand_lb::DecayType::LbToLcPi); + } + } - //////////////////////////////////////////////////////////////////////////////////////////////////// - // PROCESS FUNCTIONS FOR DATA + // save information for Lc task + if (!TESTBIT(std::abs(flag), hf_cand_lb::DecayType::LbToLcPi)) { + continue; + } - void processDplusPiData(soa::Join const& collisions, - CandsDplusFiltered const& candsC, - aod::TrackAssoc const& trackIndices, - TracksPidWithSel const& tracks, - aod::BCsWithTimestamps const& bcs) + auto ptParticle = particle.pt(); + auto yParticle = RecoDecay::y(particle.pVector(), massB); + auto etaParticle = particle.eta(); + + std::array ptProngs; + std::array yProngs; + std::array etaProngs; + int counter = 0; + for (const auto& daught : particle.daughters_as()) { + ptProngs[counter] = daught.pt(); + etaProngs[counter] = daught.eta(); + yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); + counter++; + } + tables.rowHfLbMcGenReduced(flag, ptParticle, yParticle, etaParticle, + ptProngs[0], yProngs[0], etaProngs[0], + ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M); + } else if constexpr (decayChannel == DecayChannel::B0ToDstarPi) { + // B0 → D* π+ + if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kB0, std::array{-static_cast(Pdg::kDStar), +kPiPlus}, true)) { + // Match D- -> π- K+ π- + auto candCMC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); + // Printf("Checking D- -> π- K+ π-"); + if (RecoDecay::isMatchedMCGen(particlesMc, candCMC, +static_cast(Pdg::kDStar), std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 3)) { + flag = sign * BIT(hf_cand_b0::DecayType::B0ToDstarPi); + } + } + + // save information for B0 task + if (!TESTBIT(std::abs(flag), hf_cand_b0::DecayType::B0ToDstarPi)) { + continue; + } + + auto ptParticle = particle.pt(); + auto yParticle = RecoDecay::y(particle.pVector(), massB); + auto etaParticle = particle.eta(); + + std::array ptProngs; + std::array yProngs; + std::array etaProngs; + int counter = 0; + for (const auto& daught : particle.daughters_as()) { + ptProngs[counter] = daught.pt(); + etaProngs[counter] = daught.eta(); + yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); + counter++; + } + tables.rowHfB0McGenReduced(flag, -1 /*channel*/, ptParticle, yParticle, etaParticle, + ptProngs[0], yProngs[0], etaProngs[0], + ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M); + } + } // gen + } + + //////////////////////////////////////////////////////////////////////////////////////////////////// + // PROCESS FUNCTIONS FOR DATA + + void processDplusPiData(CollisionsWCent const& collisions, + CandsDplusFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) { // store configurables needed for B0 workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigB0(selectionFlagDplus.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDplus.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1185,16 +1744,16 @@ struct HfDataCreatorCharmHadPiReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsDplusPerCollision, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + auto candsCThisColl = candsC.sliceBy(preslices.candsDplusPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDplusPiData, "Process DplusPi without MC info and without ML info", true); - void processDplusPiDataWithMl(soa::Join const& collisions, + void processDplusPiDataWithMl(CollisionsWCent const& collisions, CandsDplusFilteredWithMl const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSel const& tracks, @@ -1202,7 +1761,7 @@ struct HfDataCreatorCharmHadPiReduced { { // store configurables needed for B0 workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigB0(selectionFlagDplus.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDplus.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1215,16 +1774,200 @@ struct HfDataCreatorCharmHadPiReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsDplusPerCollisionWithMl, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + auto candsCThisColl = candsC.sliceBy(preslices.candsDplusPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDplusPiDataWithMl, "Process DplusPi without MC info and with ML info", false); - void processDsPiData(soa::Join const& collisions, + void processDplusPiDataWithQvec(CollisionsWCentAndQvectors const& collisions, + CandsDplusFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDplus.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDplusPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDplusPiDataWithQvec, "Process DplusPi without MC info, without ML info and with Q-vectors", false); + + void processDplusPiDataWithMlAndQvec(CollisionsWCentAndQvectors const& collisions, + CandsDplusFilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDplus.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDplusPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDplusPiDataWithMlAndQvec, "Process DplusPi without MC info, with ML info and with Q-vectors", false); + + void processDstarPiData(CollisionsWCent const& collisions, + CandsDstarFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs, + aod::Hf2Prongs const&) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDstar.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDstarPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDstarPiData, "Process DstarPi without MC info and without ML info", false); + + void processDstarPiDataWithMl(CollisionsWCent const& collisions, + CandsDstarFilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs, + aod::Hf2Prongs const&) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDstar.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDstarPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDstarPiDataWithMl, "Process DstarPi without MC info and with ML info", false); + + void processDstarPiDataWithQvec(CollisionsWCentAndQvectors const& collisions, + CandsDstarFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs, + aod::Hf2Prongs const&) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDstar.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDstarPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDstarPiDataWithQvec, "Process DstarPi without MC info, without ML info and with Q-vectors", false); + + void processDstarPiDataWithMlAndQvec(CollisionsWCentAndQvectors const& collisions, + CandsDstarFilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs, + aod::Hf2Prongs const&) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDstar.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDstarPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDstarPiDataWithMlAndQvec, "Process DstarPi without MC info, with ML info and with Q-vectors", false); + + void processDsPiData(CollisionsWCent const& collisions, CandsDsFiltered const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSel const& tracks, @@ -1232,7 +1975,7 @@ struct HfDataCreatorCharmHadPiReduced { { // store configurables needed for Bs workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigBs(selectionFlagDs.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigBs(hfflagConfigurations.selectionFlagDs.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1245,16 +1988,16 @@ struct HfDataCreatorCharmHadPiReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsDplusPerCollision, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + auto candsCThisColl = candsC.sliceBy(preslices.candsDsPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiData, "Process DsPi without MC info and without ML info", true); + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiData, "Process DsPi without MC info and without ML info", false); - void processDsPiDataWithMl(soa::Join const& collisions, + void processDsPiDataWithMl(CollisionsWCent const& collisions, CandsDsFilteredWithMl const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSel const& tracks, @@ -1262,7 +2005,7 @@ struct HfDataCreatorCharmHadPiReduced { { // store configurables needed for Bs workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigBs(selectionFlagDs.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigBs(hfflagConfigurations.selectionFlagDs.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1275,16 +2018,76 @@ struct HfDataCreatorCharmHadPiReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsDplusPerCollisionWithMl, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + auto candsCThisColl = candsC.sliceBy(preslices.candsDsPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiDataWithMl, "Process DsPi without MC info and with ML info", false); - void processD0PiData(soa::Join const& collisions, + void processDsPiDataWithQvec(CollisionsWCentAndQvectors const& collisions, + CandsDsFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for Bs workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigBs(hfflagConfigurations.selectionFlagDs.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDsPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiDataWithQvec, "Process DsPi without MC info, without ML info and with Q-vectors", false); + + void processDsPiDataWithMlAndQvec(CollisionsWCentAndQvectors const& collisions, + CandsDsFilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for Bs workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigBs(hfflagConfigurations.selectionFlagDs.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDsPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiDataWithMlAndQvec, "Process DsPi without MC info, with ML info and Q-vectors", false); + + void processD0PiData(CollisionsWCent const& collisions, CandsD0Filtered const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSel const& tracks, @@ -1292,7 +2095,7 @@ struct HfDataCreatorCharmHadPiReduced { { // store configurables needed for B+ workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigBplus(selectionFlagD0.value, selectionFlagD0bar.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigBplus(hfflagConfigurations.selectionFlagD0.value, hfflagConfigurations.selectionFlagD0bar.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1305,16 +2108,16 @@ struct HfDataCreatorCharmHadPiReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsD0PerCollision, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + auto candsCThisColl = candsC.sliceBy(preslices.candsD0PerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processD0PiData, "Process D0Pi without MC info and without ML info", false); - void processD0PiDataWithMl(soa::Join const& collisions, + void processD0PiDataWithMl(CollisionsWCent const& collisions, CandsD0FilteredWithMl const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSel const& tracks, @@ -1322,7 +2125,7 @@ struct HfDataCreatorCharmHadPiReduced { { // store configurables needed for B+ workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigBplus(selectionFlagD0.value, selectionFlagD0bar.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigBplus(hfflagConfigurations.selectionFlagD0.value, hfflagConfigurations.selectionFlagD0bar.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1335,29 +2138,149 @@ struct HfDataCreatorCharmHadPiReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsD0PerCollisionWithMl, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + auto candsCThisColl = candsC.sliceBy(preslices.candsD0PerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processD0PiDataWithMl, "Process D0Pi without MC info and with ML info", false); + void processD0PiDataWithQvec(CollisionsWCentAndQvectors const& collisions, + CandsD0Filtered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for B+ workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigBplus(hfflagConfigurations.selectionFlagD0.value, hfflagConfigurations.selectionFlagD0bar.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsD0PerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processD0PiDataWithQvec, "Process D0Pi without MC info, without ML info, and with Q-vectors", false); + + void processD0PiDataWithMlAndQvec(CollisionsWCentAndQvectors const& collisions, + CandsD0FilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for B+ workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigBplus(hfflagConfigurations.selectionFlagD0.value, hfflagConfigurations.selectionFlagD0bar.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsD0PerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processD0PiDataWithMlAndQvec, "Process D0Pi without MC info, with ML info, and with Q-vectors", false); + + void processLcPiData(CollisionsWCent const& collisions, + CandsLcFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for Lb workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigLb(hfflagConfigurations.selectionFlagLc.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsLcPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processLcPiData, "Process LcPi without MC info and without ML info", false); + + void processLcPiDataWithMl(CollisionsWCent const& collisions, + CandsLcFilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for Lb workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigLb(hfflagConfigurations.selectionFlagLc.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsLcPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processLcPiDataWithMl, "Process LcPi without MC info and with ML info", false); + //////////////////////////////////////////////////////////////////////////////////////////////////// // PROCESS FUNCTIONS FOR MC - void processDplusPiMc(CollisionsWMcLabels const& collisions, + void processDplusPiMc(CollisionsWCentAndMcLabels const& collisions, CandsDplusFiltered const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs, - McCollisions const&) + BCsInfo const& bcs, + McCollisions const& mcCollisions) { // store configurables needed for B0 workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigB0(selectionFlagDplus.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDplus.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1367,32 +2290,34 @@ struct HfDataCreatorCharmHadPiReduced { int zvtxAndSel8CollAndSoftTrig{0}; int allSelColl{0}; for (const auto& collision : collisions) { - o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsDplusPerCollision, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + auto candsCThisColl = candsC.sliceBy(preslices.candsDplusPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); - runMcGen(particlesMc); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDplusPiMc, "Process DplusPi with MC info and without ML info", false); - void processDplusPiMcWithMl(CollisionsWMcLabels const& collisions, + void processDplusPiMcWithMl(CollisionsWCentAndMcLabels const& collisions, CandsDplusFilteredWithMl const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs, - McCollisions const&) + BCsInfo const& bcs, + McCollisions const& mcCollisions) { // store configurables needed for B0 workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigB0(selectionFlagDplus.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDplus.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1402,32 +2327,110 @@ struct HfDataCreatorCharmHadPiReduced { int zvtxAndSel8CollAndSoftTrig{0}; int allSelColl{0}; for (const auto& collision : collisions) { - o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsDplusPerCollisionWithMl, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + auto candsCThisColl = candsC.sliceBy(preslices.candsDplusPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); - runMcGen(particlesMc); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDplusPiMcWithMl, "Process DplusPi with MC info and with ML info", false); - void processDsPiMc(CollisionsWMcLabels const& collisions, + void processDstarPiMc(CollisionsWCentAndMcLabels const& collisions, + CandsDstarFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSelAndMc const& tracks, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisions const& mcCollisions, + aod::Hf2Prongs const&) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDstar.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDstarPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDstarPiMc, "Process DstarPi with MC info and without ML info", false); + + void processDstarPiMcWithMl(CollisionsWCentAndMcLabels const& collisions, + CandsDstarFilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSelAndMc const& tracks, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisions const& mcCollisions, + aod::Hf2Prongs const&) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigB0(hfflagConfigurations.selectionFlagDstar.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsDstarPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDstarPiMcWithMl, "Process DstarPi with MC info and with ML info", false); + + void processDsPiMc(CollisionsWCentAndMcLabels const& collisions, CandsDsFiltered const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs, - McCollisions const&) + BCsInfo const& bcs, + McCollisions const& mcCollisions) { // store configurables needed for Bs workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigBs(selectionFlagDs.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigBs(hfflagConfigurations.selectionFlagDs.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1437,32 +2440,34 @@ struct HfDataCreatorCharmHadPiReduced { int zvtxAndSel8CollAndSoftTrig{0}; int allSelColl{0}; for (const auto& collision : collisions) { - o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsDplusPerCollision, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + auto candsCThisColl = candsC.sliceBy(preslices.candsDsPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); - runMcGen(particlesMc); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiMc, "Process DsPi with MC info and without ML info", false); - void processDsPiMcWithMl(CollisionsWMcLabels const& collisions, + void processDsPiMcWithMl(CollisionsWCentAndMcLabels const& collisions, CandsDsFilteredWithMl const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs, - McCollisions const&) + BCsInfo const& bcs, + McCollisions const& mcCollisions) { // store configurables needed for Bs workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigBs(selectionFlagDs.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigBs(hfflagConfigurations.selectionFlagDs.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1472,32 +2477,34 @@ struct HfDataCreatorCharmHadPiReduced { int zvtxAndSel8CollAndSoftTrig{0}; int allSelColl{0}; for (const auto& collision : collisions) { - o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsDplusPerCollisionWithMl, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + auto candsCThisColl = candsC.sliceBy(preslices.candsDsPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); - runMcGen(particlesMc); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiMcWithMl, "Process DsPi with MC info and with ML info", false); - void processD0PiMc(CollisionsWMcLabels const& collisions, + void processD0PiMc(CollisionsWCentAndMcLabels const& collisions, CandsD0Filtered const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs, - McCollisions const&) + BCsInfo const& bcs, + McCollisions const& mcCollisions) { // store configurables needed for B+ workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigBplus(selectionFlagD0.value, selectionFlagD0bar.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigBplus(hfflagConfigurations.selectionFlagD0.value, hfflagConfigurations.selectionFlagD0bar.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1507,32 +2514,34 @@ struct HfDataCreatorCharmHadPiReduced { int zvtxAndSel8CollAndSoftTrig{0}; int allSelColl{0}; for (const auto& collision : collisions) { - o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsD0PerCollision, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + auto candsCThisColl = candsC.sliceBy(preslices.candsD0PerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); - runMcGen(particlesMc); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processD0PiMc, "Process D0Pi with MC info and without ML info", false); - void processD0PiMcWithMl(CollisionsWMcLabels const& collisions, + void processD0PiMcWithMl(CollisionsWCentAndMcLabels const& collisions, CandsD0FilteredWithMl const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs, - McCollisions const&) + BCsInfo const& bcs, + McCollisions const& mcCollisions) { // store configurables needed for B+ workflow if (!isHfCandBhadConfigFilled) { - rowCandidateConfigBplus(selectionFlagD0.value, selectionFlagD0bar.value, invMassWindowCharmHadPi.value); + tables.rowCandidateConfigBplus(hfflagConfigurations.selectionFlagD0.value, hfflagConfigurations.selectionFlagD0bar.value, configs.invMassWindowCharmHadPi.value); isHfCandBhadConfigFilled = true; } @@ -1542,20 +2551,97 @@ struct HfDataCreatorCharmHadPiReduced { int zvtxAndSel8CollAndSoftTrig{0}; int allSelColl{0}; for (const auto& collision : collisions) { - o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsCThisColl = candsC.sliceBy(candsD0PerCollisionWithMl, thisCollId); - auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + auto candsCThisColl = candsC.sliceBy(preslices.candsD0PerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); - runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions - hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); - runMcGen(particlesMc); + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processD0PiMcWithMl, "Process D0Pi with MC info and with ML info", false); + + void processLcPiMc(CollisionsWCentAndMcLabels const& collisions, + CandsLcFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSelAndMc const& tracks, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisions const& mcCollisions) + { + // store configurables needed for Lb workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigLb(hfflagConfigurations.selectionFlagDplus.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsLcPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processLcPiMc, "Process LcPi with MC info and without ML info", false); + + void processLcPiMcWithMl(CollisionsWCentAndMcLabels const& collisions, + CandsLcFilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSelAndMc const& tracks, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisions const& mcCollisions) + { + // store configurables needed for Lb workflow + if (!isHfCandBhadConfigFilled) { + tables.rowCandidateConfigLb(hfflagConfigurations.selectionFlagLc.value, configs.invMassWindowCharmHadPi.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsCThisColl = candsC.sliceBy(preslices.candsLcPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(preslices.trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(preslices.colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + } + // handle normalization by the right number of collisions + tables.hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processLcPiMcWithMl, "Process LcPi with MC info and with ML info", false); + }; // struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx index e39e9eab1ff..85dcc0d8b82 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx @@ -15,33 +15,59 @@ /// \author Luca Aglietta , UniTO Turin /// \author Fabrizio Grosa , CERN -#include -#include -#include -#include -#include - -#include "DetectorsBase/Propagator.h" -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsMcMatching.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include -#include "PWGHF/Core/HfHelper.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsBfieldCCDB.h" -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" -#include "PWGHF/Utils/utilsEvSelHf.h" -#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -49,7 +75,6 @@ using namespace o2::aod; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; - // event types enum Event : uint8_t { Processed = 0, @@ -58,12 +83,6 @@ enum Event : uint8_t { kNEvent }; -enum DecayChannel : uint8_t { - DstarV0 = 0, - DplusV0, - DstarTrack -}; - enum BachelorType : uint8_t { K0s = 0, Lambda, @@ -73,26 +92,19 @@ enum BachelorType : uint8_t { enum DType : uint8_t { Dplus = 1, - Dstar + Dstar, + D0 }; -enum DecayTypeMc : uint8_t { - Ds1ToDStarK0ToD0PiK0s = 1, - Ds2StarToDplusK0sToPiKaPiPiPi, - Ds1ToDStarK0ToDPlusPi0K0s, - Ds1ToDStarK0ToD0PiK0sPart, - Ds1ToDStarK0ToD0NoPiK0sPart, - Ds1ToDStarK0ToD0PiK0sOneMu, - Ds2StarToDplusK0sOneMu +enum PairingType : uint8_t { + V0Only, + TrackOnly, + V0AndTrack }; -enum PartialMatchMc : uint8_t { - K0Matched = 0, - D0Matched, - DStarMatched, - DPlusMatched, - K0MuMatched, - DStarMuMatched +enum D0Sel : uint8_t { + selectedD0 = 0, + selectedD0Bar }; /// Creation of D-V0 pairs @@ -102,29 +114,30 @@ struct HfDataCreatorCharmResoReduced { Produces hfReducedCollision; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h Produces hfCollisionCounter; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h // tracks, V0 and D candidates reduced tables - Produces hfCandV0; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h + Produces hfCandV0; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h Produces hfTrackNoParam; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h - Produces hfCandD; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h + Produces hfCandD3Pr; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h + Produces hfCandD2Pr; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h + Produces hfCandDstar; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h // ML optional Tables - Produces hfCandDMl; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h + Produces hfCandD3PrMl; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h + Produces hfCandD2PrMl; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h // MC Tables - Produces rowHfDV0McRecReduced; Produces rowHfResoMcGenReduced; + Produces rowHf3PrV0McRecReduced; + Produces rowHfDstarV0McRecReduced; + Produces rowHf2PrV0McRecReduced; + Produces rowHf3PrTrkMcRecReduced; + Produces rowHfDstarTrkMcRecReduced; + Produces rowHf2PrTrkMcRecReduced; - // CCDB configuration - o2::ccdb::CcdbApi ccdbApi; - Service ccdb; - Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; - Configurable propagateV0toPV{"propagateV0toPV", false, "Enable or disable V0 propagation to V0"}; - Configurable doMcRecQa{"doMcRecQa", true, "Fill QA histograms for Mc matching"}; - - int runNumber{0}; // needed to detect if the run changed and trigger update of calibrations etc. // selection D struct : ConfigurableGroup { std::string prefix = "dmesons"; Configurable selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for D"}; Configurable selectionFlagDstarToD0Pi{"selectionFlagDstarToD0Pi", true, "Selection Flag for D* decay to D0 & Pi"}; + Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; + Configurable selectionFlagD0Bar{"selectionFlagD0Bar", 1, "Selection Flag for D0bar"}; } cfgDmesCuts; // selection V0 @@ -137,6 +150,7 @@ struct HfDataCreatorCharmResoReduced { Configurable trackNclusItsCut{"trackNclusItsCut", 0, "Minimum number of ITS clusters for V0 daughter"}; Configurable trackNCrossedRowsTpc{"trackNCrossedRowsTpc", 50, "Minimum TPC crossed rows"}; Configurable trackNsharedClusTpc{"trackNsharedClusTpc", 1000, "Maximum number of shared TPC clusters for V0 daughter"}; + Configurable trackFracMaxindableTpcCls{"trackFracMaxindableTpcCls", 0.8f, "Maximum fraction of findable TPC clusters for V0 daughter"}; Configurable dcaDau{"dcaDau", 1.f, "DCA V0 daughters"}; Configurable dcaMaxDauToPv{"dcaMaxDauToPv", 0.1f, "Maximum daughter's DCA to PV"}; Configurable dcaPv{"dcaPv", 1.f, "DCA V0 to PV"}; @@ -148,7 +162,7 @@ struct HfDataCreatorCharmResoReduced { // selection single tracks struct : ConfigurableGroup { - std::string prefix = "single_tracks"; + std::string prefix = "singleTracks"; Configurable setTrackSelections{"setTrackSelections", 2, "flag to apply track selections: 0=none; 1=global track w/o DCA selection; 2=global track; 3=only ITS quality"}; Configurable maxEta{"maxEta", 0.8, "maximum pseudorapidity for single tracks to be paired with D mesons"}; Configurable minPt{"minPt", 0.1, "minimum pT for single tracks to be paired with D mesons"}; @@ -157,19 +171,46 @@ struct HfDataCreatorCharmResoReduced { Configurable maxNsigmaTpcPr{"maxNsigmaTpcPr", 3., "maximum proton NSigma in TPC for single tracks to be paired with D mesons; set negative to reject"}; } cfgSingleTrackCuts; + // QA histograms + struct : ConfigurableGroup { + std::string prefix = "qaPlots"; + Configurable applyCutsForQaHistograms{"applyCutsForQaHistograms", true, "flag to apply cuts to QA histograms"}; + Configurable cutMassDstarMin{"cutMassDstarMin", 0.143, "minimum mass for Dstar candidates"}; + Configurable cutMassDstarMax{"cutMassDstarMax", 0.155, "maximum mass for Dstar candidates"}; + Configurable cutMassDMin{"cutMassDMin", 1.83, "minimum mass for D0 and Dplus candidates"}; + Configurable cutMassDMax{"cutMassDMax", 1.92, "maximum mass for D0 and Dplus candidates"}; + Configurable cutMassK0sMin{"cutMassK0sMin", 0.485, "minimum mass for K0s candidates"}; + Configurable cutMassK0sMax{"cutMassK0sMax", 0.509, "maximum mass for K0s candidates"}; + Configurable cutMassLambdaMin{"cutMassLambdaMin", 1.11, "minimum mass for Lambda candidates"}; + Configurable cutMassLambdaMax{"cutMassLambdaMax", 1.12, "maximum mass for Lambda candidates"}; + } cfgQaPlots; // other configurables + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; + Configurable propagateV0toPV{"propagateV0toPV", false, "Enable or disable V0 propagation to V0"}; + Configurable doMcRecQa{"doMcRecQa", true, "Fill QA histograms for Mc matching"}; Configurable rejectPairsWithCommonDaughter{"rejectPairsWithCommonDaughter", true, "flag to reject already at this stage the pairs that share a daughter track"}; + Configurable rejectCollisionsWithBadEvSel{"rejectCollisionsWithBadEvSel", true, "flag to reject collisions with bad event selection"}; - // material correction for track propagation - o2::base::MatLayerCylSet* lut; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; HfHelper hfHelper; o2::hf_evsel::HfEventSelection hfEvSel; - o2::vertexing::DCAFitterN<2> fitter; + o2::hf_evsel::HfEventSelectionMc hfEvSelMc; + + // CCDB service + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; double bz{0.}; + int runNumber{0}; // needed to detect if the run changed and trigger update of calibrations etc. + + // material correction for track propagation + o2::base::MatLayerCylSet* lut; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + + // O2DatabasePDG service Service pdg; - // bool isHfCandResoConfigFilled = false; + // vertex fitter + o2::vertexing::DCAFitterN<2> fitter; // Helper struct to pass V0 informations struct { @@ -192,31 +233,58 @@ struct HfDataCreatorCharmResoReduced { struct { float invMassD; float ptD; - float invMassDdau; - float invMassKPiPiV0; + float invMassD0; + float invMassD0Bar; + float invMassReso; float ptReso; + int8_t signD; + std::array pVectorProng0; + std::array pVectorProng1; + std::array pVectorProng2; } varUtils; + + // Dplus using CandsDplusFiltered = soa::Filtered>; using CandsDplusFilteredWithMl = soa::Filtered>; - using CandDstarFiltered = soa::Filtered>; - using CandDstarFilteredWithMl = soa::Filtered>; + using CandsDplusFilteredWithMc = soa::Filtered>; + using CandsDplusFilteredWithMlAndMc = soa::Filtered>; + // Dstar + using CandsDstarFiltered = soa::Filtered>; + using CandsDstarFilteredWithMl = soa::Filtered>; + using CandsDstarFilteredWithMc = soa::Filtered>; + using CandsDstarFilteredWithMlAndMc = soa::Filtered>; + // D0 + using CandsD0Filtered = soa::Filtered>; + using CandsD0FilteredWithMl = soa::Filtered>; + using CandsD0FilteredWithMc = soa::Filtered>; + using CandsD0FilteredWithMlAndMc = soa::Filtered>; + // Tracks using TracksWithPID = soa::Join; + using TracksWithPIDAndMC = soa::Join; using TracksIUWithPID = soa::Join; using TracksIUWithPIDAndMC = soa::Join; + // Collisions MC + using BCsInfo = soa::Join; + using McCollisionsNoCents = soa::Join; Filter filterSelectDplus = (aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= cfgDmesCuts.selectionFlagDplus); Filter filterSelectedCandDstar = (aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == cfgDmesCuts.selectionFlagDstarToD0Pi); + Filter filterSelectD0Candidates = (aod::hf_sel_candidate_d0::isSelD0 >= cfgDmesCuts.selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= cfgDmesCuts.selectionFlagD0Bar); Preslice candsDplusPerCollision = aod::hf_cand::collisionId; Preslice candsDplusPerCollisionWithMl = aod::hf_cand::collisionId; - Preslice candsDstarPerCollision = aod::hf_cand::collisionId; - Preslice candsDstarPerCollisionWithMl = aod::hf_cand::collisionId; + Preslice candsDstarPerCollision = aod::hf_cand::collisionId; + Preslice candsDstarPerCollisionWithMl = aod::hf_cand::collisionId; + Preslice candsD0PerCollision = aod::hf_cand::collisionId; + Preslice candsD0PerCollisionWithMl = aod::hf_cand::collisionId; Preslice candsV0PerCollision = aod::v0::collisionId; Preslice trackIndicesPerCollision = aod::track_association::collisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; HistogramRegistry registry{"registry"}; - void init(InitContext const&) + void init(InitContext& initContext) { // histograms constexpr int kNBinsEvents = kNEvent; @@ -225,70 +293,78 @@ struct HfDataCreatorCharmResoReduced { labels[Event::NoDV0Selected] = "without DV0 pairs"; labels[Event::DV0Selected] = "with DV0 pairs"; static const AxisSpec axisEvents = {kNBinsEvents, 0.5, kNBinsEvents + 0.5, ""}; - registry.add("hEvents", "Events;;entries", HistType::kTH1F, {axisEvents}); + registry.add("hEvents", "Events;;entries", HistType::kTH1D, {axisEvents}); for (int iBin = 0; iBin < kNBinsEvents; iBin++) { registry.get(HIST("hEvents"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); } - const AxisSpec axisPt{50, 0.f, 50.f, ""}; - const AxisSpec axisP{100, 0.f, 10.f, ""}; + const AxisSpec axisPt{50, 0.f, 50.f, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisP{100, 0.f, 10.f, "#it{p} (GeV/#it{c})"}; const AxisSpec axisDeDx{500, 0.f, 1000.f, ""}; - const AxisSpec axisMassDplus{200, 1.7f, 2.1f, ""}; - const AxisSpec axisMassDstar{200, 0.139f, 0.179f, ""}; - const AxisSpec axisMassLambda{100, 1.05f, 1.35f, ""}; - const AxisSpec axisMassKzero{100, 0.35f, 0.65f, ""}; - const AxisSpec axisMassDsj{400, 0.49f, 0.89f, ""}; - - registry.add("hMassVsPtDplusAll", "Dplus candidates (all, regardless the pairing with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDplus}}); - registry.add("hMassVsPtDstarAll", "Dstar candidates (all, regardless the pairing with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDstar}}); - registry.add("hMassVsPtDplusPaired", "Dplus candidates (paired with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDplus}}); - registry.add("hMassVsPtDstarPaired", "Dstar candidates (paired with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDstar}}); - - registry.add("hMassVsPtK0s", "K0^{s} candidates;#it{p}_{T} (GeV/#it{c});inv. mass (#pi^{#plus}#pi^{#minus}) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassKzero}}); - registry.add("hMassVsPtLambda", "Lambda candidates;#it{p}_{T} (GeV/#it{c});inv. mass (p #pi^{#minus}) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassLambda}}); - registry.add("hdEdxVsP", "Tracks;#it{p} (GeV/#it{c});d#it{E}/d#it{x};entries", {HistType::kTH2F, {axisP, axisDeDx}}); - - registry.add("hMassDs1", "Ds1 candidates;m_{Ds1} - m_{D^{*}} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axisMassDsj}}); - registry.add("hMassDsStar2", "Ds^{*}2 candidates; Ds^{*}2 - m_{D^{#plus}} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axisMassDsj}}); - registry.add("hMassXcRes", "XcRes candidates; XcRes - m_{D^{#plus}} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{300, 1.1, 1.4}}}); - registry.add("hMassDstarProton", "D^{*}-proton candidates;m_{D^{*}p} - m_{D^{*}} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 0.9, 1.4}}}); - registry.add("hDType", "D selection flag", {HistType::kTH1F, {{5, -2.5, 2.5}}}); - - registry.add("hMCRecCounter", "Number of Reconstructed MC Matched candidates per channel", {HistType::kTH1F, {{17, -8.5, 8.5}}}); - registry.add("hMCRecDebug", "Debug of MC Reco", {HistType::kTH1F, {{16, -0.5, 15.5}}}); - registry.add("hMCRecOrigin", "Origin of Matched particles", {HistType::kTH1F, {{3, -0.5, 2.5}}}); - - registry.add("hMCGenCounter", "Number of Generated particles; Decay Channel Flag; pT [GeV/c]", {HistType::kTH2F, {{17, -8.5, 8.5}, {100, 0, 50}}}); - registry.add("hMCSignCounter", "Sign of Generated particles", {HistType::kTH1F, {{3, -1.5, 1.5}}}); - registry.add("hMCGenOrigin", "Origin of Generated particles", {HistType::kTH1F, {{3, -0.5, 2.5}}}); - registry.add("hMCOriginCounterWrongDecay", "Origin of Generated particles in Wrong decay", {HistType::kTH1F, {{3, -0.5, 2.5}}}); - - if (doMcRecQa) { - registry.add("hMassVsPtK0Matched", "K0s candidates Matched ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassKzero}}); - registry.add("hMassVsPtD0Matched", "D0 candidates Matched ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDplus}}); - registry.add("hMassVsPtDstarMatched", "Dstar candidates Matched ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDstar}}); - registry.add("hMassVsPtDplusMatched", "Dplus candidates Matched ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDplus}}); - registry.add("hMassVsPtDs1Matched", "Ds1 candidates Matched ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDsj}}); - registry.add("hMassVsPtDs2StarMatched", "Ds2Star candidates Matched ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDsj}}); - registry.add("hMassVsPtK0MatchedPiToMu", "K0s candidates Matched with PiToMu decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassKzero}}); - registry.add("hMassVsPtD0MatchedPiToMu", "D0 candidates Matched with PiToMu decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDplus}}); - registry.add("hMassVsPtDstarMatchedPiToMu", "Dstar candidates Matched with PiToMu decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDstar}}); - registry.add("hMassVsPtDplusMatchedPiToMu", "Dplus candidates Matched with PiToMu decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDplus}}); - registry.add("hMassVsPtDs1MatchedPiToMu", "Ds1 candidates Matched with PiToMu decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDsj}}); - registry.add("hMassVsPtDs2StarMatchedPiToMu", "Ds2Star candidates Matched with PiToMu decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDsj}}); - registry.add("hMassVsPtD0MatchedKaToPi", "D0 candidates Matched with KaToPi decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDplus}}); - registry.add("hMassVsPtDstarMatchedKaToPi", "Dstar candidates Matched with KaToPi decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDstar}}); - registry.add("hMassVsPtDplusMatchedKaToPi", "Dplus candidates Matched with KaToPi decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDplus}}); - registry.add("hMassVsPtDs1MatchedKaToPi", "Ds1 candidates Matched with KaToPi decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDsj}}); - registry.add("hMassVsPtDs2StarMatchedKaToPi", "Ds2Star candidates Matched with KaToPi decay ;#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPt, axisMassDsj}}); + const AxisSpec axisMassD0{200, 1.7f, 2.1f, "inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec axisMassDplus{200, 1.7f, 2.1f, "inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec axisMassDstar{200, 0.139f, 0.179f, "delta inv. mass (GeV/#it{c}^{2})"}; // o2-linter: disable=pdg/explicit-mass (false positive) + const AxisSpec axisMassLambda{100, 1.05f, 1.35f, "inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec axisMassKzero{100, 0.35f, 0.65f, "inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec axisDeltaMassToK{500, 0.49, 1.49, "inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec axisDeltaMassToPi{500, 0.13, 1.13, "inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec axisDeltaMassToPr{500, 0.93, 1.93, "inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec axisDeltaMassToLambda{500, 1.05, 2.05, "inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec axisMassDsj{400, 0.49f, 0.89f, ""}; // Ds1 and Ds2Star legacy + registry.add("hMassVsPtK0s", "K0^{s} candidates;#it{p}_{T} (GeV/#it{c});inv. mass (#pi^{#plus}#pi^{#minus}) (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassKzero}}); + registry.add("hMassVsPtLambda", "Lambda candidates;#it{p}_{T} (GeV/#it{c});inv. mass (p #pi^{#minus}) (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassLambda}}); + registry.add("hdEdxVsP", "Tracks;#it{p} (GeV/#it{c});d#it{E}/d#it{x};entries", {HistType::kTH2D, {axisP, axisDeDx}}); + + if (doprocessD0V0 || doprocessD0Track || doprocessD0V0AndTrack || doprocessD0V0WithMl || doprocessD0TrackWithMl || doprocessD0V0AndTrackWithMl || + doprocessD0V0MC || doprocessD0TrackMC || doprocessD0V0AndTrackMC || doprocessD0V0MCWithMl || doprocessD0TrackMCWithMl || doprocessD0V0AndTrackMCWithMl) { + registry.add("hMassVsPtD0All", "D0 candidates (all, regardless the pairing with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassD0}}); + registry.add("hMassVsPtD0BarAll", "D0bar candidates (all, regardless the pairing with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassD0}}); + registry.add("hMassVsPtD0Paired", "D0 candidates (paired with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassD0}}); + registry.add("hMassVsPtD0BarPaired", "D0 candidates (paired with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassD0}}); + registry.add("hMassD0Pi", "D0Pi candidates; m_{D^{0}#pi^{+}} - m_{D^{0}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToPi}}); + registry.add("hMassD0K", "D0Kplus candidates; m_{D^{0}K^{+}} - m_{D^{0}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToK}}); + registry.add("hMassD0Proton", "D0Proton candidates; m_{D^{0}p} - m_{D^{0}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToPr}}); + registry.add("hMassD0Lambda", "D0Lambda candidates; m_{D^{0}#Lambda} - m_{D^{0}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToLambda}}); + } + if (doprocessDstarV0 || doprocessDstarTrack || doprocessDstarV0AndTrack || doprocessDstarV0WithMl || doprocessDstarTrackWithMl || doprocessDstarV0AndTrackWithMl || + doprocessDstarV0MC || doprocessDstarTrackMC || doprocessDstarV0AndTrackMC || doprocessDstarV0MCWithMl || doprocessDstarTrackMCWithMl || doprocessDstarV0AndTrackMCWithMl) { + registry.add("hMassVsPtDstarAll", "Dstar candidates (all, regardless the pairing with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassDstar}}); + registry.add("hMassVsPtDstarPaired", "Dstar candidates (paired with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassDstar}}); + registry.add("hMassDstarPi", "DstarPi candidates; m_{D^{*+}#pi^{-}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToPi}}); + registry.add("hMassDstarK", "DstarK candidates; m_{D^{*+}#pi^{-}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToK}}); + registry.add("hMassDstarProton", "DstarProton candidates; m_{D^{*}p} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToPr}}); + registry.add("hMassDstarK0s", "DstarK0s candidates; m_{D^{*}K^{0}_{S}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToK}}); + registry.add("hMassDstarLambda", "DstarLambda candidates; m_{D^{*}#Lambda} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToLambda}}); + } + if (doprocessDplusV0 || doprocessDplusTrack || doprocessDplusV0AndTrack || doprocessDplusV0WithMl || doprocessDplusTrackWithMl || doprocessDplusV0AndTrackWithMl || + doprocessDplusV0MC || doprocessDplusTrackMC || doprocessDplusV0AndTrackMC || doprocessDplusV0MCWithMl || doprocessDplusTrackMCWithMl || doprocessDplusV0AndTrackMCWithMl) { + registry.add("hMassVsPtDplusAll", "Dplus candidates (all, regardless the pairing with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassDplus}}); + registry.add("hMassVsPtDplusPaired", "Dplus candidates (paired with V0s);#it{p}_{T} (GeV/#it{c});inv. mass (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisMassDplus}}); + registry.add("hMassDplusK0s", "DplusK0s candidates; m_{D^{+}K^{0}_{S}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToK}}); + registry.add("hMassDplusPi", "DplusPi candidates; m_{D^{+}#pi^{-}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToPi}}); + registry.add("hMassDplusK", "DplusK candidates; m_{D^{+}#pi^{-}} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToK}}); + registry.add("hMassDplusProton", "DplusProton candidates; m_{D^{+}p} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToPr}}); + registry.add("hMassDplusLambda", "DplusLambda candidates; m_{D^{+}#Lambda} (GeV/#it{c}^{2});entries", {HistType::kTH2D, {axisPt, axisDeltaMassToLambda}}); + } + if (doprocessD0V0MC || doprocessD0TrackMC || doprocessD0V0AndTrackMC || doprocessD0V0MCWithMl || doprocessD0TrackMCWithMl || doprocessD0V0AndTrackMCWithMl || + doprocessDstarV0MC || doprocessDstarTrackMC || doprocessDstarV0AndTrackMC || doprocessDstarV0MCWithMl || doprocessDstarTrackMCWithMl || doprocessDstarV0AndTrackMCWithMl || + doprocessDplusV0MC || doprocessDplusTrackMC || doprocessDplusV0AndTrackMC || doprocessDplusV0MCWithMl || doprocessDplusTrackMCWithMl || doprocessDplusV0AndTrackMCWithMl) { + // MC Rec + registry.add("hMCRecCounter", "Number of Reconstructed MC Matched candidates per channel", {HistType::kTH1D, {{31, -15.5, 15.5}}}); + registry.add("hMCRecDebug", "Debug of MC Reco", {HistType::kTH1D, {{551, -0.5, 550.5}}}); + registry.add("hMCRecOrigin", "Origin of Matched particles", {HistType::kTH1D, {{3, -0.5, 2.5}}}); + registry.add("hMCRecMassGen", "Generated inv. mass of resoncances", {HistType::kTH1D, {{2000, 1.8, 3.8}}}); + registry.add("hMCRecCharmDau", "Charm daughter flag", {HistType::kTH1D, {{57, -28.5, 28.5}}}); + // MC Gen + registry.add("hMCGenCounter", "Number of Generated particles; Decay Channel Flag; pT [GeV/c]", {HistType::kTH2D, {{17, -8.5, 8.5}, {100, 0, 50}}}); + registry.add("hMCGenOrigin", "Origin of Generated particles", {HistType::kTH1D, {{3, -0.5, 2.5}}}); } - // Configure CCDB access - ccdb->setURL(url.value); + ccdb->setURL(ccdbUrl.value); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - ccdbApi.init(url); + ccdbApi.init(ccdbUrl); runNumber = 0; lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); @@ -302,6 +378,18 @@ struct HfDataCreatorCharmResoReduced { fitter.setMaxChi2(1e9); fitter.setUseAbsDCA(true); fitter.setWeightedFinalPCA(false); + + // init HF event selection helper + hfEvSel.init(registry); + + const auto& workflows = initContext.services().get(); + for (const DeviceSpec& device : workflows.devices) { + if (device.name.compare("hf-data-creator-charm-reso-reduced") == 0) { + // init HF event selection helper + hfEvSelMc.init(device, registry); + break; + } + } } /// Basic track quality selections for V0 daughters @@ -322,7 +410,7 @@ struct HfDataCreatorCharmResoReduced { if (track.itsNCls() < cfgV0Cuts.trackNclusItsCut || track.tpcNClsFound() < cfgV0Cuts.trackNCrossedRowsTpc || track.tpcNClsCrossedRows() < cfgV0Cuts.trackNCrossedRowsTpc || - track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || + track.tpcNClsCrossedRows() < cfgV0Cuts.trackFracMaxindableTpcCls * track.tpcNClsFindable() || track.tpcNClsShared() > cfgV0Cuts.trackNsharedClusTpc) { return false; } @@ -356,19 +444,18 @@ struct HfDataCreatorCharmResoReduced { { auto trackPos = dauTracks[0]; auto trackNeg = dauTracks[1]; - // single-tracks selection if (!selectV0Daughter(trackPos, dDaughtersIds) || !selectV0Daughter(trackNeg, dDaughtersIds)) return false; // daughters DCA to V0's collision primary vertex - gpu::gpustd::array dcaInfo; + std::array dcaInfo; auto trackPosPar = getTrackPar(trackPos); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPosPar, 2.f, fitter.getMatCorrType(), &dcaInfo); auto trackPosDcaXY = dcaInfo[0]; auto trackNegPar = getTrackPar(trackNeg); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackNegPar, 2.f, fitter.getMatCorrType(), &dcaInfo); auto trackNegDcaXY = dcaInfo[0]; - if (fabs(trackPosDcaXY) < cfgV0Cuts.dcaMaxDauToPv || fabs(trackNegDcaXY) < cfgV0Cuts.dcaMaxDauToPv) { + if (std::fabs(trackPosDcaXY) < cfgV0Cuts.dcaMaxDauToPv || std::fabs(trackNegDcaXY) < cfgV0Cuts.dcaMaxDauToPv) { return false; } // vertex reconstruction @@ -378,7 +465,6 @@ struct HfDataCreatorCharmResoReduced { try { nCand = fitter.process(trackPosCov, trackNegCov); } catch (...) { - LOG(error) << "Exception caught in DCA fitter process call!"; return false; } if (nCand == 0) { @@ -389,9 +475,9 @@ struct HfDataCreatorCharmResoReduced { auto& trackNegProp = fitter.getTrack(1); trackPosProp.getPxPyPzGlo(candidateV0.momPos); trackNegProp.getPxPyPzGlo(candidateV0.momNeg); - for (int i = 0; i < 3; ++i) { - candidateV0.mom[i] = candidateV0.momPos[i] + candidateV0.momNeg[i]; - } + + candidateV0.mom = RecoDecay::pVec(candidateV0.momPos, candidateV0.momNeg); + candidateV0.pT = std::hypot(candidateV0.mom[0], candidateV0.mom[1]); // topological selections: // v0 eta @@ -410,9 +496,8 @@ struct HfDataCreatorCharmResoReduced { if (candidateV0.radius < cfgV0Cuts.radiusMin) { return false; } - for (int i = 0; i < 3; i++) { - candidateV0.pos[i] = vtx[i]; - } + std::copy(vtx.begin(), vtx.end(), candidateV0.pos.begin()); + // v0 DCA to primary vertex candidateV0.dcaV0ToPv = calculateDCAStraightToPV( vtx[0], vtx[1], vtx[2], @@ -429,42 +514,41 @@ struct HfDataCreatorCharmResoReduced { if (candidateV0.cosPA < cfgV0Cuts.cosPa) { return false; } - // distinguish between K0s, and Lambda hypotesys - candidateV0.v0Type = {BIT(K0s) | BIT(Lambda) | BIT(AntiLambda)}; + candidateV0.v0Type = {BIT(BachelorType::K0s) | BIT(BachelorType::Lambda) | BIT(BachelorType::AntiLambda)}; // for lambda hypotesys define if its lambda or anti-lambda candidateV0.alpha = alphaAP(candidateV0.mom, candidateV0.momPos, candidateV0.momNeg); bool matter = candidateV0.alpha > 0; - CLRBIT(candidateV0.v0Type, matter ? AntiLambda : Lambda); + CLRBIT(candidateV0.v0Type, matter ? BachelorType::AntiLambda : BachelorType::Lambda); auto massPos = matter ? o2::constants::physics::MassProton : o2::constants::physics::MassPionCharged; auto massNeg = matter ? o2::constants::physics::MassPionCharged : o2::constants::physics::MassProton; // mass hypotesis candidateV0.mLambda = RecoDecay::m(std::array{candidateV0.momPos, candidateV0.momNeg}, std::array{massPos, massNeg}); candidateV0.mK0Short = RecoDecay::m(std::array{candidateV0.momPos, candidateV0.momNeg}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged}); if (std::fabs(candidateV0.mK0Short - MassK0) > cfgV0Cuts.deltaMassK0s) { - CLRBIT(candidateV0.v0Type, K0s); + CLRBIT(candidateV0.v0Type, BachelorType::K0s); } if (std::fabs(candidateV0.mLambda - MassLambda0) > cfgV0Cuts.deltaMassLambda) { - CLRBIT(candidateV0.v0Type, Lambda); - CLRBIT(candidateV0.v0Type, AntiLambda); + CLRBIT(candidateV0.v0Type, BachelorType::Lambda); + CLRBIT(candidateV0.v0Type, BachelorType::AntiLambda); } // PID - if (TESTBIT(candidateV0.v0Type, K0s)) { + if (TESTBIT(candidateV0.v0Type, BachelorType::K0s)) { if ((trackPos.hasTPC() && std::fabs(trackPos.tpcNSigmaPi()) > cfgV0Cuts.nSigmaTpc) || (trackNeg.hasTPC() && std::fabs(trackNeg.tpcNSigmaPi()) > cfgV0Cuts.nSigmaTpc)) - CLRBIT(candidateV0.v0Type, K0s); + CLRBIT(candidateV0.v0Type, BachelorType::K0s); } - if (TESTBIT(candidateV0.v0Type, Lambda)) { + if (TESTBIT(candidateV0.v0Type, BachelorType::Lambda)) { if ((trackPos.hasTPC() && std::fabs(trackPos.tpcNSigmaPr()) > cfgV0Cuts.nSigmaTpc) || (trackPos.hasTOF() && std::fabs(trackPos.tofNSigmaPr()) > cfgV0Cuts.nSigmaTofPr) || (trackNeg.hasTPC() && std::fabs(trackNeg.tpcNSigmaPi()) > cfgV0Cuts.nSigmaTpc)) - CLRBIT(candidateV0.v0Type, Lambda); + CLRBIT(candidateV0.v0Type, BachelorType::Lambda); } - if (TESTBIT(candidateV0.v0Type, AntiLambda)) { + if (TESTBIT(candidateV0.v0Type, BachelorType::AntiLambda)) { if ((trackPos.hasTPC() && std::fabs(trackPos.tpcNSigmaPi()) > cfgV0Cuts.nSigmaTpc) || (trackNeg.hasTPC() && std::fabs(trackNeg.tpcNSigmaPr()) > cfgV0Cuts.nSigmaTpc) || (trackNeg.hasTOF() && std::fabs(trackNeg.tofNSigmaPr()) > cfgV0Cuts.nSigmaTofPr)) - CLRBIT(candidateV0.v0Type, AntiLambda); + CLRBIT(candidateV0.v0Type, BachelorType::AntiLambda); } if (candidateV0.v0Type == 0) { return false; @@ -479,11 +563,9 @@ struct HfDataCreatorCharmResoReduced { template bool isTrackSelected(const Tr& track, const std::array& dDaughtersIds) { - if (rejectPairsWithCommonDaughter && std::find(dDaughtersIds.begin(), dDaughtersIds.end(), track.globalIndex()) != dDaughtersIds.end()) { return false; } - switch (cfgSingleTrackCuts.setTrackSelections) { case 1: if (!track.isGlobalTrackWoDCA()) { @@ -501,256 +583,424 @@ struct HfDataCreatorCharmResoReduced { } break; } - if (track.pt() < cfgSingleTrackCuts.minPt) { return false; } - if (std::abs(track.eta()) > cfgSingleTrackCuts.maxEta) { return false; } - if (!track.hasTPC()) { return false; } - bool isPion = std::abs(track.tpcNSigmaPi()) < cfgSingleTrackCuts.maxNsigmaTpcPi; bool isKaon = std::abs(track.tpcNSigmaKa()) < cfgSingleTrackCuts.maxNsigmaTpcKa; bool isProton = std::abs(track.tpcNSigmaPr()) < cfgSingleTrackCuts.maxNsigmaTpcPr; - if (!isPion && !isKaon && !isProton) { // we keep the track if is it compatible with at least one of the PID hypotheses selected return false; } - return true; } - /// Function for filling MC reco information in the tables + template + int8_t getMatchingFlagV0(PParticles const& particlesMc, const std::array& arrDaughtersV0) + { + int8_t signV0{0}; + int indexRec{-1}; + int flagV0{0}; + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersV0, kK0, std::array{+kPiPlus, -kPiPlus}, true, &signV0, 2); + if (indexRec > -1) { + flagV0 = hf_decay::hf_cand_reso::PartialMatchMc::K0Matched; + } else { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersV0, kLambda0, std::array{+kProton, -kPiPlus}, true, &signV0, 2); + if (indexRec > -1) { + flagV0 = signV0 * hf_decay::hf_cand_reso::PartialMatchMc::LambdaMatched; + } + } + return flagV0; // Placeholder, should return the actual flag based on matching logic + } + + /// Function for filling MC reco information of DV0 candidates in the tables + /// \tparam dType is the D meson type (Dstar, Dplus or D0) /// \param particlesMc is the table with MC particles - /// \param vecDaughtersReso is the vector with all daughter tracks (bachelor pion in last position) + /// \param candCharmBach is the D meson candidate + /// \param bachelorV0 is the V0 candidate + /// \param tracks is the table with tracks /// \param indexHfCandCharm is the index of the charm-hadron bachelor in the reduced table - /// \param indexCandV0 is the index of the v0 bachelor in the reduced table - template - void fillMcRecoInfo(const PParticles& particlesMc, - const std::vector& vecDaughtersReso, - int& indexHfCandCharm, - int& indexCandV0) + /// \param indexCandV0TrBach is the index of the v0 bachelor in the reduced table + template + void fillMcRecoInfoDV0(PParticles const& particlesMc, + CCand const& candCharmBach, + BBachV0 const& bachelorV0, + Tr const& tracks, + int& indexHfCandCharm, + int64_t& indexCandV0Bach) { - - // we check the MC matching to be stored - int8_t sign{0}; - int8_t signDStar{0}; - int8_t signDPlus{0}; - int8_t signD0{0}; - int8_t signV0{0}; - int8_t flag{0}; - int8_t debug{0}; - int8_t origin{0}; - int8_t nPiToMuReso{0}, nPiToMuV0, nPiToMuD0{0}, nPiToMuDstar{0}, nPiToMuDplus{0}; - int8_t nKaToPiReso{0}, nKaToPiV0, nKaToPiD0{0}, nKaToPiDstar{0}, nKaToPiDplus{0}; - std::vector idxBhadMothers{}; - float motherPt{-1.f}; - int indexRecReso{-1}, indexRecDstar{-1}, indexRecDplus{-1}, indexRecD0{-1}, indexRecK0{-1}, indexRecResoPartReco{-1}; - - if constexpr (decChannel == DecayChannel::DstarV0) { - // Ds1 → D* K0 → (D0 π+) K0s → ((K-π+) π+)(π+π-) - indexRecD0 = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1]}, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0, 1, &nPiToMuD0, &nKaToPiD0); - indexRecK0 = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[3], vecDaughtersReso[4]}, kK0, std::array{+kPiPlus, -kPiPlus}, true, &signV0, 2, &nPiToMuV0, &nKaToPiV0); - if (indexRecD0 > -1) { - indexRecDstar = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2]}, Pdg::kDStar, std::array{-kKPlus, +kPiPlus, +kPiPlus}, true, &signDStar, 2, &nPiToMuDstar, &nKaToPiDstar); + std::vector vecDaughtersReso{}; + int8_t sign{0}, nKinkedTracks{0}, origin{0}, flagCharmBach{0}, flagCharmBachInterm{0}, flagV0{0}, flagReso{0}; + int indexRec{-1}, debugMcRec{0}; + float ptGen{-1.f}, invMassGen{-1.f}; + if constexpr (dType == DType::Dstar) { + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong0Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong1Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prongPiId())); + // Check if D* is matched + flagCharmBach = candCharmBach.flagMcMatchRec(); + if (std::abs(flagCharmBach) > 0) { + SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::DstarMatched); + origin = candCharmBach.originMcRec(); } - if (indexRecD0 > -1 && indexRecDstar > -1 && indexRecK0 > -1) { - indexRecReso = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3], vecDaughtersReso[4]}, Pdg::kDS1, std::array{+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}, true, &sign, 3, &nPiToMuReso, &nKaToPiReso); - if (indexRecReso > -1 && nPiToMuReso == 0 && nKaToPiReso == 0) { - flag = sign * DecayTypeMc::Ds1ToDStarK0ToD0PiK0s; - } else if (indexRecReso > -1 && nPiToMuReso >= 1 && nKaToPiReso == 0) { - flag = sign * DecayTypeMc::Ds1ToDStarK0ToD0PiK0sOneMu; - } + // Check if D0 is matched + flagCharmBachInterm = candCharmBach.flagMcMatchRecD0(); + if (std::abs(flagCharmBachInterm) > 0) { + SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::D0Matched); } - - // Ds1+ not matched: we check if it is partially reco - if (indexRecReso < 0) { - indexRecResoPartReco = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3], vecDaughtersReso[4]}, Pdg::kDS1, std::array{+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}, true, &sign, 3); - indexRecDplus = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2]}, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &signDPlus, 2); - if (indexRecResoPartReco > -1) { // we look for decays of D* or D0 with more daughters - if (indexRecDstar < 0 && indexRecK0 > -1) { - auto indexRecDstarPartReco = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2]}, Pdg::kDStar, std::array{-kKPlus, +kPiPlus, +kPiPlus}, true, &signDStar, 3); - if (indexRecDstarPartReco > -1) { - if (indexRecDplus > -1) { // Ds1 -> D* K0s -> D+ π0 K0s - flag = sign * DecayTypeMc::Ds1ToDStarK0ToDPlusPi0K0s; - } else { - auto indexRecDzeroPartReco = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1]}, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0, 2); - if (indexRecDzeroPartReco > -1) { // Ds1 -> D* K0s -> D0 π+ K0s -> K- π+ π0 π+ K0s - flag = sign * DecayTypeMc::Ds1ToDStarK0ToD0PiK0sPart; - } - } - } + // Check if V0 is matched + vecDaughtersReso.push_back(tracks.rawIteratorAt(bachelorV0.posTrackId())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(bachelorV0.negTrackId())); + flagV0 = getMatchingFlagV0(particlesMc, std::array{vecDaughtersReso[3], vecDaughtersReso[4]}); + if (std::abs(flagV0) > 0) { + SETBIT(debugMcRec, std::abs(flagV0)); + } + // If both D* and K0s are matched, try to match resonance + if (std::abs(flagCharmBach) > 0 && flagV0 == hf_decay::hf_cand_reso::PartialMatchMc::K0Matched) { + std::array pdgCodesDaughters = {+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}; + auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3], vecDaughtersReso[4]}; + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarK0s) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks); + if (indexRec > -1) { + flagReso = sign * decayChannelFlag; + break; } - } else { // we look for D* not matched, but all the other ones yes, we check if we only lost the soft pion - if (indexRecD0 > -1 && indexRecK0 > -1 && indexRecDstar < 0) { - indexRecResoPartReco = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[3], vecDaughtersReso[4]}, Pdg::kDS1, std::array{+kPiPlus, -kKPlus, +kPiPlus, -kPiPlus}, true, &sign, 3); - if (indexRecResoPartReco > -1) { - flag = sign * DecayTypeMc::Ds1ToDStarK0ToD0NoPiK0sPart; - } + } + } else if (std::abs(flagCharmBachInterm) > 0 && flagV0 == hf_decay::hf_cand_reso::PartialMatchMc::K0Matched) { + std::array pdgCodesDaughters = {+kPiPlus, -kKPlus, +kPiPlus, -kPiPlus}; + auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[3], vecDaughtersReso[4]}; + // Peaking background of D0K0s <- Ds* with spurious soft pion + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarK0s) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks); + if (indexRec > -1) { + flagReso = sign * decayChannelFlag; + SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::ResoPartlyMatched); + break; } } } - if (flag != 0) { - int indexParticle{-1}; - if (indexRecReso > -1) { - indexParticle = indexRecReso; - } else if (indexRecResoPartReco > -1) { - indexParticle = indexRecResoPartReco; - } - auto particleReso = particlesMc.iteratorAt(indexParticle); - origin = RecoDecay::getCharmHadronOrigin(particlesMc, particleReso, false, &idxBhadMothers); - motherPt = particleReso.pt(); + // No physical channel expected in D*Lambda + if (indexRec > -1) { + auto particleReso = particlesMc.iteratorAt(indexRec); + ptGen = particleReso.pt(); + invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); } - if (doMcRecQa) { - if (indexRecReso > -1) { - if (nPiToMuReso == 0 && nKaToPiReso == 0) { - registry.fill(HIST("hMassVsPtDs1Matched"), varUtils.ptD, varUtils.invMassKPiPiV0 - varUtils.invMassD); - } - if (nPiToMuReso >= 1) { - registry.fill(HIST("hMassVsPtDs1MatchedPiToMu"), varUtils.ptD, varUtils.invMassKPiPiV0 - varUtils.invMassD); - } - if (nKaToPiReso >= 1) { - registry.fill(HIST("hMassVsPtDs1MatchedKaToPi"), varUtils.ptD, varUtils.invMassKPiPiV0 - varUtils.invMassD); - } - } - if (indexRecD0 > -1) { - if (nPiToMuD0 == 0 && nKaToPiD0 == 0) { - registry.fill(HIST("hMassVsPtD0Matched"), varUtils.ptD, varUtils.invMassDdau); - } - if (nPiToMuD0 >= 1) { - registry.fill(HIST("hMassVsPtD0MatchedPiToMu"), varUtils.ptD, varUtils.invMassDdau); - } - if (nKaToPiD0 >= 1) { - registry.fill(HIST("hMassVsPtD0MatchedKaToPi"), varUtils.ptD, varUtils.invMassDdau); + rowHfDstarV0McRecReduced(indexHfCandCharm, indexCandV0Bach, + flagReso, flagCharmBach, + flagCharmBachInterm, debugMcRec, + origin, ptGen, invMassGen, + nKinkedTracks); + } else if constexpr (dType == DType::Dplus) { + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong0Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong1Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong2Id())); + // Check if D+ is matched + flagCharmBach = candCharmBach.flagMcMatchRec(); + flagCharmBachInterm = candCharmBach.flagMcDecayChanRec(); + if (std::abs(flagCharmBach) > 0) { + SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::DplusMatched); + origin = candCharmBach.originMcRec(); + } + // Check if V0 is matched + vecDaughtersReso.push_back(tracks.rawIteratorAt(bachelorV0.posTrackId())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(bachelorV0.negTrackId())); + flagV0 = getMatchingFlagV0(particlesMc, std::array{vecDaughtersReso[3], vecDaughtersReso[4]}); + if (std::abs(flagV0) > 0) { + SETBIT(debugMcRec, std::abs(flagV0)); + } + // If both D+ and K0s are matched, try to match resonance + if (hf_decay::hf_cand_3prong::daughtersDplusMain.contains(static_cast(std::abs(flagCharmBach))) && flagV0 == hf_decay::hf_cand_reso::PartialMatchMc::K0Matched) { + auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3], vecDaughtersReso[4]}; + auto pdgCodesDplusDaughters = hf_decay::hf_cand_3prong::daughtersDplusMain.at(static_cast(std::abs(flagCharmBach))); + auto pdgCodesDaughters = std::array{pdgCodesDplusDaughters[0], pdgCodesDplusDaughters[1], pdgCodesDplusDaughters[2], +kPiPlus, -kPiPlus}; + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDplusK0s) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks); + if (indexRec > -1) { + flagReso = sign * decayChannelFlag; + break; } } - if (indexRecDstar > -1) { - if (nPiToMuDstar == 0 && nKaToPiDstar == 0) { - registry.fill(HIST("hMassVsPtDstarMatched"), varUtils.ptD, varUtils.invMassD - varUtils.invMassDdau); - } - if (nPiToMuDstar >= 1) { - registry.fill(HIST("hMassVsPtDstarMatchedPiToMu"), varUtils.ptD, varUtils.invMassD - varUtils.invMassDdau); - } - if (nKaToPiDstar >= 1) { - registry.fill(HIST("hMassVsPtDstarMatchedKaToPi"), varUtils.ptD, varUtils.invMassD - varUtils.invMassDdau); + } else if (hf_decay::hf_cand_3prong::daughtersDplusMain.contains(static_cast(std::abs(flagCharmBach))) && std::abs(flagV0) == hf_decay::hf_cand_reso::PartialMatchMc::LambdaMatched) { + // Peaking background of D+Lambda <- Ds* with spurious soft pion + auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3], vecDaughtersReso[4]}; + auto pdgCodesDplusDaughters = hf_decay::hf_cand_3prong::daughtersDplusMain.at(static_cast(std::abs(flagCharmBach))); + auto pdgCodesDaughters = std::array{pdgCodesDplusDaughters[0], pdgCodesDplusDaughters[1], pdgCodesDplusDaughters[2], +kProton, -kPiPlus}; + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDplusLambda) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks); + if (indexRec > -1) { + flagReso = sign * decayChannelFlag; + break; } } - if (indexRecK0 > -1) { - if (nPiToMuV0 == 0 && nKaToPiV0 == 0) { - registry.fill(HIST("hMassVsPtK0Matched"), candidateV0.pT, candidateV0.mK0Short); - } - if (nPiToMuV0 >= 1) { - registry.fill(HIST("hMassVsPtK0MatchedPiToMu"), candidateV0.pT, candidateV0.mK0Short); - } - if (nKaToPiV0 >= 1) { - registry.fill(HIST("hMassVsPtK0MatchedKaToPi"), candidateV0.pT, candidateV0.mK0Short); + } + if (indexRec > -1) { + auto particleReso = particlesMc.iteratorAt(indexRec); + ptGen = particleReso.pt(); + invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); + } + rowHf3PrV0McRecReduced(indexHfCandCharm, indexCandV0Bach, + flagReso, flagCharmBach, + flagCharmBachInterm, debugMcRec, + origin, ptGen, invMassGen, + nKinkedTracks); + } else if constexpr (dType == DType::D0) { + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong0Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong1Id())); + // Check if D0 is matched + flagCharmBach = candCharmBach.flagMcMatchRec(); + flagCharmBachInterm = candCharmBach.flagMcDecayChanRec(); + if (std::abs(flagCharmBach) > 0) { + SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::D0Matched); + origin = candCharmBach.originMcRec(); + } + // Check if V0 is matched + vecDaughtersReso.push_back(tracks.rawIteratorAt(bachelorV0.posTrackId())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(bachelorV0.negTrackId())); + flagV0 = getMatchingFlagV0(particlesMc, std::array{vecDaughtersReso[2], vecDaughtersReso[3]}); + if (std::abs(flagV0) > 0) { + SETBIT(debugMcRec, std::abs(flagV0)); + } + // No physical channel expected in D0 K0s + // If both D0 and Lambda are matched, try to match resonance + if (hf_decay::hf_cand_2prong::daughtersD0Main.contains(static_cast(std::abs(flagCharmBach))) && std::abs(flagV0) == hf_decay::hf_cand_reso::PartialMatchMc::LambdaMatched) { + auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3]}; + auto pdgCodesDzeroDaughters = hf_decay::hf_cand_2prong::daughtersD0Main.at(static_cast(std::abs(flagCharmBach))); + auto pdgCodesDaughters = std::array{pdgCodesDzeroDaughters[0], pdgCodesDzeroDaughters[1], +kProton, -kPiPlus}; + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToD0Lambda) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks); + if (indexRec > -1) { + flagReso = sign * decayChannelFlag; + break; } } } - } else if constexpr (decChannel == DecayChannel::DplusV0) { - // Ds2Star → D+ K0 → (π+K-π+) K0s → (π+K-π+)(π+π-) - indexRecK0 = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[3], vecDaughtersReso[4]}, kK0, std::array{+kPiPlus, -kPiPlus}, true, &signV0, 2, &nPiToMuV0, &nKaToPiV0); - indexRecDplus = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2]}, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &signDPlus, 2, &nPiToMuDplus, &nKaToPiDplus); - if (indexRecK0 > -1 && indexRecDplus > -1) { - indexRecReso = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3], vecDaughtersReso[4]}, Pdg::kDS2Star, std::array{+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}, true, &sign, 3, &nPiToMuReso, &nKaToPiReso); - if (indexRecReso > -1 && nPiToMuReso == 0 && nKaToPiReso == 0) { - flag = sign * DecayTypeMc::Ds2StarToDplusK0sToPiKaPiPiPi; - } else if (indexRecReso > -1 && nPiToMuReso >= 1 && nKaToPiReso == 0) { - flag = sign * DecayTypeMc::Ds2StarToDplusK0sOneMu; - } else if (indexRecReso < 0) { - // Verify partly reconstructed decay Ds1 -> D* K0s -> D+ π0 K0s - indexRecDstar = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2]}, Pdg::kDStar, std::array{-kKPlus, +kPiPlus, +kPiPlus}, true, &signDStar, 2); - if (indexRecDstar > -1) { - indexRecReso = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], vecDaughtersReso[3], vecDaughtersReso[4]}, Pdg::kDS1, std::array{+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}, true, &sign, 3); - if (indexRecReso > -1) { - flag = sign * DecayTypeMc::Ds1ToDStarK0ToDPlusPi0K0s; - } + if (indexRec > -1) { + auto particleReso = particlesMc.iteratorAt(indexRec); + ptGen = particleReso.pt(); + invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); + } + rowHf2PrV0McRecReduced(indexHfCandCharm, indexCandV0Bach, + flagReso, flagCharmBach, + flagCharmBachInterm, debugMcRec, + origin, ptGen, invMassGen, + nKinkedTracks); + } + registry.fill(HIST("hMCRecDebug"), debugMcRec); + if (indexRec > -1) { + registry.fill(HIST("hMCRecCounter"), flagReso); + registry.fill(HIST("hMCRecOrigin"), origin); + registry.fill(HIST("hMCRecMassGen"), invMassGen); + } + if (std::abs(flagCharmBach) > 0) { + registry.fill(HIST("hMCRecCharmDau"), flagCharmBach); + } + } + + template + int8_t getMatchingFlagTrack(Tr const& bachTrack) + { + auto particle = bachTrack.mcParticle(); + auto pdgCode = std::abs(particle.pdgCode()); + if (pdgCode == kPiPlus) { + return hf_decay::hf_cand_reso::PartialMatchMc::PionMatched; + } else if (pdgCode == kKPlus) { + return hf_decay::hf_cand_reso::PartialMatchMc::KaonMatched; + } else if (pdgCode == kProton) { + return hf_decay::hf_cand_reso::PartialMatchMc::ProtonMatched; + } + return 0; + } + // Function for filling MC reco information of D Track candidates in the tables + /// \tparam dType is the D meson type (Dstar, Dplus or D0) + /// \param particlesMc is the table with MC particles + /// \param candCharmBach is the D meson candidate + /// \param bachelorTrack is the bachelor track + /// \param tracks is the table with tracks + /// \param indexHfCandCharm is the index of the charm-hadron bachelor in the reduced table + /// \param indexCandTrBach is the index of the v0 bachelor in the reduced table + template + void fillMcRecoInfoDTrack(PParticles const& particlesMc, + CCand const& candCharmBach, + BBachTr const& bachelorTrack, + Tr const& tracks, + int& indexHfCandCharm, + int64_t& indexCandTrBach) + { + std::vector vecDaughtersReso{}; + int8_t sign{0}, nKinkedTracks{0}, origin{0}, flagCharmBach{0}, flagCharmBachInterm{0}, flagTrack{0}, flagReso{0}; + int indexRec{-1}; + uint16_t debugMcRec{0}; + float ptGen{-1.f}, invMassGen{-1.f}; + if constexpr (dType == DType::Dstar) { + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong0Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong1Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prongPiId())); + // Check if D* is matched + flagCharmBach = candCharmBach.flagMcMatchRec(); + if (std::abs(flagCharmBach) > 0) { + SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::DstarMatched); + origin = candCharmBach.originMcRec(); + } + // Check if D0 is matched + flagCharmBachInterm = candCharmBach.flagMcMatchRecD0(); + if (std::abs(flagCharmBachInterm) > 0) { + SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::D0Matched); + } + // Check if Track is matched + flagTrack = getMatchingFlagTrack(bachelorTrack); + if (std::abs(flagTrack) > 0) { + SETBIT(debugMcRec, flagTrack); + } + // If both D* and Track are matched, try to match resonance + if (std::abs(flagCharmBach) > 0 && flagTrack == hf_decay::hf_cand_reso::PartialMatchMc::PionMatched) { + auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], bachelorTrack}; + auto pdgCodesDaughters = std::array{+kPiPlus, -kKPlus, +kPiPlus, -kPiPlus}; + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarPi) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks); + if (indexRec > -1) { + flagReso = sign * decayChannelFlag; + break; } } } - if (flag != 0) { - auto particleReso = particlesMc.iteratorAt(indexRecReso); - origin = RecoDecay::getCharmHadronOrigin(particlesMc, particleReso, false, &idxBhadMothers); - motherPt = particleReso.pt(); + // No channels in D*K+ or D*Pr + if (indexRec > -1) { + auto particleReso = particlesMc.iteratorAt(indexRec); + ptGen = particleReso.pt(); + invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); } - if (doMcRecQa) { - if (indexRecReso > -1) { - if (nPiToMuReso == 0 && nKaToPiReso == 0) { - registry.fill(HIST("hMassVsPtDs2StarMatched"), varUtils.ptD, varUtils.invMassKPiPiV0 - varUtils.invMassD); - } - if (nPiToMuReso >= 1) { - registry.fill(HIST("hMassVsPtDs2StarMatchedPiToMu"), varUtils.ptD, varUtils.invMassKPiPiV0 - varUtils.invMassD); - } - if (nKaToPiReso >= 1) { - registry.fill(HIST("hMassVsPtDs2StarMatchedKaToPi"), varUtils.ptD, varUtils.invMassKPiPiV0 - varUtils.invMassD); + rowHfDstarTrkMcRecReduced(indexHfCandCharm, indexCandTrBach, + flagReso, flagCharmBach, + flagCharmBachInterm, debugMcRec, + origin, ptGen, invMassGen, + nKinkedTracks); + } else if constexpr (dType == DType::Dplus) { + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong0Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong1Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong2Id())); + // Check if D+ is matched + flagCharmBach = candCharmBach.flagMcMatchRec(); + flagCharmBachInterm = candCharmBach.flagMcDecayChanRec(); + if (std::abs(flagCharmBach) > 0) { + SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::DplusMatched); + origin = candCharmBach.originMcRec(); + } + // Check if Track is matched + flagTrack = getMatchingFlagTrack(bachelorTrack); + if (std::abs(flagTrack) > 0) { + SETBIT(debugMcRec, flagTrack); + } + // If both D+ and Track are matched, try to match resonance + if (hf_decay::hf_cand_3prong::daughtersDplusMain.contains(static_cast(std::abs(flagCharmBach))) && flagTrack == hf_decay::hf_cand_reso::PartialMatchMc::PionMatched) { + auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], vecDaughtersReso[2], bachelorTrack}; + auto pdgCodesDplusDaughters = hf_decay::hf_cand_3prong::daughtersDplusMain.at(static_cast(std::abs(flagCharmBach))); + auto pdgCodesDaughters = std::array{pdgCodesDplusDaughters[0], pdgCodesDplusDaughters[1], pdgCodesDplusDaughters[2], -kPiPlus}; + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDplusPi) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks); + if (indexRec > -1) { + flagReso = sign * decayChannelFlag; + break; } } - if (indexRecDplus > -1) { - if (nPiToMuDplus == 0 && nKaToPiDplus == 0) { - registry.fill(HIST("hMassVsPtDplusMatched"), varUtils.ptD, varUtils.invMassD); - } - if (nPiToMuDplus >= 1) { - registry.fill(HIST("hMassVsPtDplusMatchedPiToMu"), varUtils.ptD, varUtils.invMassD); - } - if (nKaToPiDplus >= 1) { - registry.fill(HIST("hMassVsPtDplusMatchedKaToPi"), varUtils.ptD, varUtils.invMassD); + } + // No channels in D+K+ or D+Pr + if (indexRec > -1) { + auto particleReso = particlesMc.iteratorAt(indexRec); + ptGen = particleReso.pt(); + invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); + } + rowHf3PrTrkMcRecReduced(indexHfCandCharm, indexCandTrBach, + flagReso, flagCharmBach, + flagCharmBachInterm, debugMcRec, + origin, ptGen, invMassGen, + nKinkedTracks); + } else if constexpr (dType == DType::D0) { + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong0Id())); + vecDaughtersReso.push_back(tracks.rawIteratorAt(candCharmBach.prong1Id())); + // Check if D0 is matched + flagCharmBach = candCharmBach.flagMcMatchRec(); + flagCharmBachInterm = candCharmBach.flagMcDecayChanRec(); + if (std::abs(flagCharmBach) > 0) { + SETBIT(debugMcRec, hf_decay::hf_cand_reso::PartialMatchMc::D0Matched); + origin = candCharmBach.originMcRec(); + } + flagTrack = getMatchingFlagTrack(bachelorTrack); + if (hf_decay::hf_cand_2prong::daughtersD0Main.contains(static_cast(std::abs(flagCharmBach))) && flagTrack == hf_decay::hf_cand_reso::PartialMatchMc::PionMatched) { + auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], bachelorTrack}; + auto pdgCodesDzeroDaughters = hf_decay::hf_cand_2prong::daughtersD0Main.at(static_cast(std::abs(flagCharmBach))); + auto pdgCodesDaughters = std::array{pdgCodesDzeroDaughters[0], pdgCodesDzeroDaughters[1], +kPiPlus}; + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToD0Pi) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks); + if (indexRec > -1) { + flagReso = sign * decayChannelFlag; + break; } } - if (indexRecK0 > -1) { - if (nPiToMuV0 == 0 && nKaToPiV0 == 0) { - registry.fill(HIST("hMassVsPtK0Matched"), candidateV0.pT, candidateV0.mK0Short); - } - if (nPiToMuV0 >= 1) { - registry.fill(HIST("hMassVsPtK0MatchedPiToMu"), candidateV0.pT, candidateV0.mK0Short); - } - if (nKaToPiV0 >= 1) { - registry.fill(HIST("hMassVsPtK0MatchedKaToPi"), candidateV0.pT, candidateV0.mK0Short); + } else if (hf_decay::hf_cand_2prong::daughtersD0Main.contains(static_cast(std::abs(flagCharmBach))) && flagTrack == hf_decay::hf_cand_reso::PartialMatchMc::KaonMatched) { + auto arrDaughtersReso = std::array{vecDaughtersReso[0], vecDaughtersReso[1], bachelorTrack}; + auto pdgCodesDzeroDaughters = hf_decay::hf_cand_2prong::daughtersD0Main.at(static_cast(std::abs(flagCharmBach))); + auto pdgCodesDaughters = std::array{pdgCodesDzeroDaughters[0], pdgCodesDzeroDaughters[1], +kKPlus}; + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToD0Kplus) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, arrDaughtersReso, pdgCodeReso, pdgCodesDaughters, true, &sign, 3, &nKinkedTracks); + if (indexRec > -1) { + flagReso = sign * decayChannelFlag; + break; } } } - } // DecayChannel::DplusV0 - if (flag != 0) { - registry.fill(HIST("hMCRecCounter"), flag); - registry.fill(HIST("hMCRecOrigin"), origin); - } else { - if (indexRecK0 > -1) { - SETBIT(debug, PartialMatchMc::K0Matched); - } - if (indexRecD0 > -1) { - SETBIT(debug, PartialMatchMc::D0Matched); + if (indexRec > -1) { + auto particleReso = particlesMc.iteratorAt(indexRec); + ptGen = particleReso.pt(); + invMassGen = RecoDecay::m(particleReso.p(), particleReso.e()); } - if (indexRecDstar > -1) { - SETBIT(debug, PartialMatchMc::DStarMatched); - } - if (indexRecDplus > -1) { - SETBIT(debug, PartialMatchMc::DPlusMatched); - } - registry.fill(HIST("hMCRecDebug"), debug); + rowHf2PrTrkMcRecReduced(indexHfCandCharm, indexCandTrBach, + flagReso, flagCharmBach, + flagCharmBachInterm, debugMcRec, + origin, ptGen, invMassGen, + nKinkedTracks); } - rowHfDV0McRecReduced(indexHfCandCharm, indexCandV0, flag, debug, origin, signD0, motherPt); - } + registry.fill(HIST("hMCRecDebug"), debugMcRec); + if (indexRec > -1) { + registry.fill(HIST("hMCRecCounter"), flagReso); + registry.fill(HIST("hMCRecOrigin"), origin); + registry.fill(HIST("hMCRecMassGen"), invMassGen); + } + if (std::abs(flagCharmBach) > 0) { + registry.fill(HIST("hMCRecCharmDau"), flagCharmBach); + } + } // fillMcRecoInfoDTrack - template + template void runDataCreation(Coll const& collision, CCands const& candsD, - BBach const& bachelors, - Tr const&, + BBachV0s const& bachelorV0s, + BBachTracks const& bachelorTrks, + Tr const& tracks, + TrIU const& tracksIU, PParticles const& particlesMc, - aod::BCsWithTimestamps const&) + BCs const&) { // helpers for ReducedTables filling + float centrality = -1.f; + uint16_t hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + if (rejectCollisionsWithBadEvSel && hfRejMap != 0) { + return; + } int indexHfReducedCollision = hfReducedCollision.lastIndex() + 1; // std::map where the key is the V0.globalIndex() and // the value is the V0 index in the table of the selected v0s std::map selectedV0s; std::map selectedTracks; bool fillHfReducedCollision = false; - auto bc = collision.template bc_as(); + constexpr bool DoTracks = pairingType == PairingType::TrackOnly || pairingType == PairingType::V0AndTrack; + constexpr bool DoV0s = pairingType == PairingType::V0Only || pairingType == PairingType::V0AndTrack; + auto bc = collision.template bc_as(); if (runNumber != bc.runNumber()) { LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; initCCDB(bc, runNumber, ccdb, ccdbPathGrpMag, lut, false); @@ -760,63 +1010,88 @@ struct HfDataCreatorCharmResoReduced { fitter.setBz(bz); // loop on D candidates for (const auto& candD : candsD) { - // initialize variables depending on decay channel + // initialize variables depending on D meson type bool fillHfCandD = false; - std::array pVecD; - std::array pVecProng2; std::array secondaryVertexD; std::array prongIdsD; - int8_t dtype; - std::array bdtScores; - std::vector charmHadDauTracks{}; + std::array bdtScores = {-1.f, -1.f, -1.f, -1.f, -1.f, -1.f}; + std::vector> charmHadDauTracks{}; varUtils.ptD = candD.pt(); - if constexpr (DecayChannel == DecayChannel::DstarV0 || DecayChannel == DecayChannel::DstarTrack) { - if (candD.signSoftPi() > 0) { + if constexpr (dType == DType::Dstar) { + varUtils.signD = candD.signSoftPi(); + if (varUtils.signD > 0) { varUtils.invMassD = candD.invMassDstar(); - varUtils.invMassDdau = candD.invMassD0(); + varUtils.invMassD0 = candD.invMassD0(); } else { varUtils.invMassD = candD.invMassAntiDstar(); - varUtils.invMassDdau = candD.invMassD0Bar(); + varUtils.invMassD0 = candD.invMassD0Bar(); } - pVecD = candD.pVector(); secondaryVertexD[0] = candD.xSecondaryVertexD0(); secondaryVertexD[1] = candD.ySecondaryVertexD0(); secondaryVertexD[2] = candD.zSecondaryVertexD0(); prongIdsD[0] = candD.prong0Id(); prongIdsD[1] = candD.prong1Id(); prongIdsD[2] = candD.prongPiId(); - pVecProng2 = candD.pVecSoftPi(); - charmHadDauTracks.push_back(candD.template prong0_as
()); - charmHadDauTracks.push_back(candD.template prong1_as
()); - charmHadDauTracks.push_back(candD.template prongPi_as
()); - dtype = candD.signSoftPi() * DType::Dstar; + varUtils.pVectorProng0 = candD.pVectorProng0(); + varUtils.pVectorProng1 = candD.pVectorProng1(); + varUtils.pVectorProng2 = candD.pVecSoftPi(); + charmHadDauTracks.push_back(tracksIU.rawIteratorAt(candD.prong0Id())); + charmHadDauTracks.push_back(tracksIU.rawIteratorAt(candD.prong1Id())); if constexpr (withMl) { std::copy(candD.mlProbDstarToD0Pi().begin(), candD.mlProbDstarToD0Pi().end(), bdtScores.begin()); } - registry.fill(HIST("hMassVsPtDstarAll"), candD.pt(), varUtils.invMassD - varUtils.invMassDdau); - } else if constexpr (DecayChannel == DecayChannel::DplusV0) { - auto prong0 = candD.template prong0_as
(); + registry.fill(HIST("hMassVsPtDstarAll"), varUtils.ptD, varUtils.invMassD - varUtils.invMassD0); + } else if constexpr (dType == DType::Dplus) { + auto prong0 = tracksIU.rawIteratorAt(candD.prong0Id()); varUtils.invMassD = hfHelper.invMassDplusToPiKPi(candD); - pVecD = candD.pVector(); secondaryVertexD[0] = candD.xSecondaryVertex(); secondaryVertexD[1] = candD.ySecondaryVertex(); secondaryVertexD[2] = candD.zSecondaryVertex(); prongIdsD[0] = candD.prong0Id(); prongIdsD[1] = candD.prong1Id(); prongIdsD[2] = candD.prong2Id(); - pVecProng2 = candD.pVectorProng2(); - dtype = static_cast(prong0.sign() * DType::Dplus); - charmHadDauTracks.push_back(candD.template prong0_as
()); - charmHadDauTracks.push_back(candD.template prong1_as
()); - charmHadDauTracks.push_back(candD.template prong2_as
()); + varUtils.signD = prong0.sign(); + varUtils.pVectorProng0 = candD.pVectorProng0(); + varUtils.pVectorProng1 = candD.pVectorProng1(); + varUtils.pVectorProng2 = candD.pVectorProng2(); + charmHadDauTracks.push_back(tracksIU.rawIteratorAt(candD.prong0Id())); + charmHadDauTracks.push_back(tracksIU.rawIteratorAt(candD.prong1Id())); + charmHadDauTracks.push_back(tracksIU.rawIteratorAt(candD.prong2Id())); + if constexpr (withMl) { + std::copy(candD.mlProbDplusToPiKPi().begin(), candD.mlProbDplusToPiKPi().end(), bdtScores.begin()); + } + registry.fill(HIST("hMassVsPtDplusAll"), varUtils.ptD, varUtils.invMassD); + } else if constexpr (dType == DType::D0) { + varUtils.invMassD0 = hfHelper.invMassD0ToPiK(candD); + varUtils.invMassD0Bar = hfHelper.invMassD0barToKPi(candD); + secondaryVertexD[0] = candD.xSecondaryVertex(); + secondaryVertexD[1] = candD.ySecondaryVertex(); + secondaryVertexD[2] = candD.zSecondaryVertex(); + prongIdsD[0] = candD.prong0Id(); + prongIdsD[1] = candD.prong1Id(); + prongIdsD[2] = -1; // D0 does not have a third prong + charmHadDauTracks.push_back(tracksIU.rawIteratorAt(candD.prong0Id())); + charmHadDauTracks.push_back(tracksIU.rawIteratorAt(candD.prong1Id())); + varUtils.pVectorProng0 = candD.pVectorProng0(); + varUtils.pVectorProng1 = candD.pVectorProng1(); + varUtils.pVectorProng2 = {0.f, 0.f, 0.f}; // D0 does not have a third prong if constexpr (withMl) { - registry.fill(HIST("hMassVsPtDplusAll"), candD.pt(), varUtils.invMassD); + std::copy(candD.mlProbD0().begin(), candD.mlProbD0().end(), bdtScores.begin()); + std::copy(candD.mlProbD0bar().begin(), candD.mlProbD0bar().end(), bdtScores.begin() + 3); } - } // else if + if (candD.isSelD0() >= cfgDmesCuts.selectionFlagD0) { + registry.fill(HIST("hMassVsPtD0All"), varUtils.ptD, varUtils.invMassD0); + } + if (candD.isSelD0bar() >= cfgDmesCuts.selectionFlagD0Bar) { + registry.fill(HIST("hMassVsPtD0BarAll"), varUtils.ptD, varUtils.invMassD0Bar); + } + } // end of dType switch // Get single track variables float chi2TpcDauMax = -1.f; int nItsClsDauMin = 8, nTpcCrossRowsDauMin = 200; + float chi2TpcSoftPi = -1.f; + int nItsClsSoftPi = 8, nTpcCrossRowsSoftPi = 200; for (const auto& charmHadTrack : charmHadDauTracks) { if (charmHadTrack.itsNCls() < nItsClsDauMin) { nItsClsDauMin = charmHadTrack.itsNCls(); @@ -828,12 +1103,18 @@ struct HfDataCreatorCharmResoReduced { chi2TpcDauMax = charmHadTrack.tpcChi2NCl(); } } - - if constexpr (DecayChannel == DecayChannel::DplusV0 || DecayChannel == DecayChannel::DstarV0) { - // Loop on V0 candidates - for (const auto& v0 : bachelors) { - auto trackPos = v0.template posTrack_as
(); - auto trackNeg = v0.template negTrack_as
(); + if constexpr (dType == DType::Dstar) { + auto softPi = tracksIU.rawIteratorAt(candD.prongPiId()); + nItsClsSoftPi = softPi.itsNCls(); + nTpcCrossRowsSoftPi = softPi.tpcNClsCrossedRows(); + chi2TpcSoftPi = softPi.tpcChi2NCl(); + charmHadDauTracks.push_back(softPi); + } + // Loop on the bachelor V0s + if constexpr (DoV0s) { + for (const auto& v0 : bachelorV0s) { + auto trackPos = tracksIU.rawIteratorAt(v0.posTrackId()); + auto trackNeg = tracksIU.rawIteratorAt(v0.negTrackId()); // Apply selsection auto v0DauTracks = std::array{trackPos, trackNeg}; if (!buildAndSelectV0(collision, prongIdsD, v0DauTracks)) { @@ -856,51 +1137,101 @@ struct HfDataCreatorCharmResoReduced { // propagate V0 to primary vertex (if enabled) if (propagateV0toPV) { std::array pVecV0Orig = {candidateV0.mom[0], candidateV0.mom[1], candidateV0.mom[2]}; - gpu::gpustd::array dcaInfo; + std::array dcaInfo; auto trackParK0 = o2::track::TrackPar(candidateV0.pos, pVecV0Orig, 0, true); trackParK0.setPID(o2::track::PID::K0); trackParK0.setAbsCharge(0); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParK0, 2.f, matCorr, &dcaInfo); getPxPyPz(trackParK0, candidateV0.mom); } - if (TESTBIT(candidateV0.v0Type, K0s)) { - if constexpr (DecayChannel == DecayChannel::DplusV0) { - varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVectorProng2(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); - // varUtils.ptReso = RecoDecay::pt(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVectorProng2(), candidateV0.mom}); - } else if (DecayChannel == DecayChannel::DstarV0) { - // varUtils.ptReso = RecoDecay::pt(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVecSoftPi(), candidateV0.mom}); - if (candD.signSoftPi() > 0) { - varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVecSoftPi(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); - } else { - varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng1(), candD.pVectorProng0(), candD.pVecSoftPi(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); - } - } + // compute resonance invariant mass and filling of QA histograms + if (TESTBIT(candidateV0.v0Type, BachelorType::K0s)) { registry.fill(HIST("hMassVsPtK0s"), candidateV0.pT, candidateV0.mK0Short); - if constexpr (DecayChannel == DecayChannel::DstarV0) { - registry.fill(HIST("hMassDs1"), varUtils.invMassKPiPiV0 - varUtils.invMassD); - } else if constexpr (DecayChannel == DecayChannel::DplusV0) { - registry.fill(HIST("hMassDsStar2"), varUtils.invMassKPiPiV0 - varUtils.invMassD); - } - } - bool isLambda = TESTBIT(candidateV0.v0Type, Lambda); - bool isAntiLambda = TESTBIT(candidateV0.v0Type, AntiLambda); + switch (dType) { + case DType::Dstar: + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, candidateV0.mom)); + if (varUtils.signD > 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); + } else { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng1, varUtils.pVectorProng0, varUtils.pVectorProng2, candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); + } + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD - varUtils.invMassD0 > cfgQaPlots.cutMassDstarMin && + varUtils.invMassD - varUtils.invMassD0 < cfgQaPlots.cutMassDstarMax && + candidateV0.mK0Short > cfgQaPlots.cutMassK0sMin && + candidateV0.mK0Short < cfgQaPlots.cutMassK0sMax)) { + registry.fill(HIST("hMassDstarK0s"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + break; + case DType::Dplus: + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, candidateV0.mom)); + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD > cfgQaPlots.cutMassDMin && + varUtils.invMassD < cfgQaPlots.cutMassDMax && + candidateV0.mK0Short > cfgQaPlots.cutMassK0sMin && + candidateV0.mK0Short < cfgQaPlots.cutMassK0sMax)) { + registry.fill(HIST("hMassDplusK0s"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + break; + default: + break; // no other D meson types expected + } // end of dType switch + } // matched with K0s + bool isLambda = TESTBIT(candidateV0.v0Type, BachelorType::Lambda); + bool isAntiLambda = TESTBIT(candidateV0.v0Type, BachelorType::AntiLambda); if (isLambda || isAntiLambda) { - if constexpr (DecayChannel == DecayChannel::DplusV0) { - varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVectorProng2(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda0}); - } else if (DecayChannel == DecayChannel::DstarV0) { - if (candD.signSoftPi() > 0) { - varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVecSoftPi(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda0}); - } else { - varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng1(), candD.pVectorProng0(), candD.pVecSoftPi(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda0}); - } - } - if (isLambda || isAntiLambda) { - registry.fill(HIST("hMassVsPtLambda"), candidateV0.pT, candidateV0.mLambda); - } - if constexpr (DecayChannel == DecayChannel::DplusV0) { - registry.fill(HIST("hMassXcRes"), varUtils.invMassKPiPiV0 - varUtils.invMassD); - } - } + registry.fill(HIST("hMassVsPtLambda"), candidateV0.pT, candidateV0.mLambda); + switch (dType) { + case DType::Dstar: + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, candidateV0.mom)); + if (varUtils.signD > 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}); + } else { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng1, varUtils.pVectorProng0, varUtils.pVectorProng2, candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}); + } + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD - varUtils.invMassD0 > cfgQaPlots.cutMassDstarMin && + varUtils.invMassD - varUtils.invMassD0 < cfgQaPlots.cutMassDstarMax && + candidateV0.mLambda > cfgQaPlots.cutMassLambdaMin && + candidateV0.mLambda < cfgQaPlots.cutMassLambdaMax)) { + registry.fill(HIST("hMassDstarLambda"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + break; + case DType::Dplus: + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda}); + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, candidateV0.mom)); + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD > cfgQaPlots.cutMassDMin && + varUtils.invMassD < cfgQaPlots.cutMassDMax && + candidateV0.mLambda > cfgQaPlots.cutMassLambdaMin && + candidateV0.mLambda < cfgQaPlots.cutMassLambdaMax)) { + registry.fill(HIST("hMassDplusLambda"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + break; + case DType::D0: + if (isLambda) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassLambda}); + } else { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng1, varUtils.pVectorProng0, candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassLambda}); + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, candidateV0.mom)); + if (!cfgQaPlots.applyCutsForQaHistograms || + (((varUtils.invMassD0 > cfgQaPlots.cutMassDMin && varUtils.invMassD0 < cfgQaPlots.cutMassDMax) || + (varUtils.invMassD0Bar > cfgQaPlots.cutMassDMin && varUtils.invMassD0Bar < cfgQaPlots.cutMassDMax)) && + candidateV0.mLambda > cfgQaPlots.cutMassLambdaMin && + candidateV0.mLambda < cfgQaPlots.cutMassLambdaMax)) { + if (isLambda) { + registry.fill(HIST("hMassD0Lambda"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD0); + } else { + registry.fill(HIST("hMassD0Lambda"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD0Bar); + } + } + break; + default: + break; + } // end of dType switch + } // matched with Lambda or AntiLambda // fill V0 table // if information on V0 already stored, go to next V0 if (!selectedV0s.count(v0.globalIndex())) { @@ -916,45 +1247,199 @@ struct HfDataCreatorCharmResoReduced { selectedV0s[v0.globalIndex()] = hfCandV0.lastIndex(); } fillHfCandD = true; - // Optional filling of MC Rec table + // Optional filling of MC Rec table, for now only implemented for Ds1->D*K0s and Ds2*->D+K0s if constexpr (doMc) { - std::vector charmResoDauTracks{}; - for (const auto& track : charmHadDauTracks) { - charmResoDauTracks.push_back(track); - } - charmResoDauTracks.push_back(trackPos); - charmResoDauTracks.push_back(trackNeg); - int indexHfCandCharm = hfCandD.lastIndex() + 1; - int indexHfCandV0 = hfCandV0.lastIndex(); - fillMcRecoInfo(particlesMc, charmResoDauTracks, indexHfCandCharm, indexHfCandV0); + int indexHfCandCharm{-1}; + if constexpr (dType == DType::Dstar) + indexHfCandCharm = hfCandDstar.lastIndex() + 1; + else if constexpr (dType == DType::Dplus) + indexHfCandCharm = hfCandD3Pr.lastIndex() + 1; + else if constexpr (dType == DType::D0) + indexHfCandCharm = hfCandD2Pr.lastIndex() + 1; + fillMcRecoInfoDV0(particlesMc, candD, v0, tracksIU, indexHfCandCharm, selectedV0s[v0.globalIndex()]); } - } // V0 loop - } else if constexpr (DecayChannel == DecayChannel::DstarTrack) { - for (const auto& trackIndex : bachelors) { - auto track = trackIndex.template track_as
(); + } // end of loop on V0 candidates + } // end of do V0s + // Loop on the bachelor tracks + if constexpr (DoTracks) { + for (const auto& trackIndex : bachelorTrks) { + auto track = tracks.rawIteratorAt(trackIndex.trackId()); if (!isTrackSelected(track, prongIdsD)) { continue; } - // if the track has been reassociated, re-propagate it to PV (minor difference) auto trackParCovTrack = getTrackParCov(track); - o2::gpu::gpustd::array dcaTrack{track.dcaXY(), track.dcaZ()}; + std::array dcaTrack{track.dcaXY(), track.dcaZ()}; std::array pVecTrack = track.pVector(); if (track.collisionId() != collision.globalIndex()) { o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovTrack, 2.f, matCorr, &dcaTrack); getPxPyPz(trackParCovTrack, pVecTrack); } - registry.fill(HIST("hdEdxVsP"), track.p(), track.tpcSignal()); - float invMassKPiPiP{0.f}; - if (candD.signSoftPi() > 0) { - invMassKPiPiP = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVecSoftPi(), pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); - } else { - invMassKPiPiP = RecoDecay::m(std::array{candD.pVectorProng1(), candD.pVectorProng0(), candD.pVecSoftPi(), pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); - } - registry.fill(HIST("hMassDstarProton"), invMassKPiPiP - varUtils.invMassD); + // compute invariant mass and filling of QA histograms + switch (dType) { + case DType::Dstar: + // D* pi + if (std::abs(track.tpcNSigmaPi()) < cfgSingleTrackCuts.maxNsigmaTpcPi) { + if (varUtils.signD > 0 && track.sign() < 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassPiPlus}); + } else if (varUtils.signD < 0 && track.sign() > 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng1, varUtils.pVectorProng0, varUtils.pVectorProng2, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassPiPlus}); + } else { + varUtils.invMassReso = -1.f; // invalid case + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack)); + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD - varUtils.invMassD0 > cfgQaPlots.cutMassDstarMin && + varUtils.invMassD - varUtils.invMassD0 < cfgQaPlots.cutMassDstarMax)) { + registry.fill(HIST("hMassDstarPi"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + } + if (std::abs(track.tpcNSigmaKa()) < cfgSingleTrackCuts.maxNsigmaTpcKa) { + if (varUtils.signD > 0 && track.sign() < 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassKPlus}); + } else if (varUtils.signD < 0 && track.sign() > 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng1, varUtils.pVectorProng0, varUtils.pVectorProng2, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassKPlus}); + } else { + varUtils.invMassReso = -1.f; // invalid case + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack)); + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD - varUtils.invMassD0 > cfgQaPlots.cutMassDstarMin && + varUtils.invMassD - varUtils.invMassD0 < cfgQaPlots.cutMassDstarMax)) { + registry.fill(HIST("hMassDstarK"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + } + // D* p + if (std::abs(track.tpcNSigmaPr()) < cfgSingleTrackCuts.maxNsigmaTpcPr) { + if (varUtils.signD > 0 && track.sign() > 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); + } else if (varUtils.signD < 0 && track.sign() < 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng1, varUtils.pVectorProng0, varUtils.pVectorProng2, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); + } else { + varUtils.invMassReso = -1.f; // invalid case + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack)); + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD - varUtils.invMassD0 > cfgQaPlots.cutMassDstarMin && + varUtils.invMassD - varUtils.invMassD0 < cfgQaPlots.cutMassDstarMax)) { + registry.fill(HIST("hMassDstarProton"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + } + break; + case DType::Dplus: + // D+ pi + if (std::abs(track.tpcNSigmaPi()) < cfgSingleTrackCuts.maxNsigmaTpcPi) { + if (varUtils.signD * track.sign() < 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassPiPlus}); + } else { + varUtils.invMassReso = -1.f; // invalid case + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack)); + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD > cfgQaPlots.cutMassDMin && + varUtils.invMassD < cfgQaPlots.cutMassDMax)) { + registry.fill(HIST("hMassDplusPi"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + } + // D+ K + if (std::abs(track.tpcNSigmaKa()) < cfgSingleTrackCuts.maxNsigmaTpcKa) { + if (varUtils.signD * track.sign() < 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassKPlus}); + } else { + varUtils.invMassReso = -1.f; // invalid case + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack)); + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD > cfgQaPlots.cutMassDMin && + varUtils.invMassD < cfgQaPlots.cutMassDMax)) { + registry.fill(HIST("hMassDplusK"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + } + // D+ pr + if (std::abs(track.tpcNSigmaPr()) < cfgSingleTrackCuts.maxNsigmaTpcPr) { + if (varUtils.signD * track.sign() < 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); + } else { + varUtils.invMassReso = -1.f; // invalid case + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, varUtils.pVectorProng2, pVecTrack)); + if (!cfgQaPlots.applyCutsForQaHistograms || + (varUtils.invMassD > cfgQaPlots.cutMassDMin && + varUtils.invMassD < cfgQaPlots.cutMassDMax)) { + registry.fill(HIST("hMassDplusProton"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD); + } + } + break; + case DType::D0: + // D0 pi + if (std::abs(track.tpcNSigmaPi()) < cfgSingleTrackCuts.maxNsigmaTpcPi) { + if (track.sign() > 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus}); + } else { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng1, varUtils.pVectorProng0, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus}); + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, pVecTrack)); + if (!cfgQaPlots.applyCutsForQaHistograms || + ((varUtils.invMassD0 > cfgQaPlots.cutMassDMin && + varUtils.invMassD0 < cfgQaPlots.cutMassDMax) || + (varUtils.invMassD0Bar > cfgQaPlots.cutMassDMin && + varUtils.invMassD0Bar < cfgQaPlots.cutMassDMax))) { + if (track.sign() > 0) { + registry.fill(HIST("hMassD0Pi"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD0); + } else { + registry.fill(HIST("hMassD0Pi"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD0Bar); + } + } + } + // D0 K + if (std::abs(track.tpcNSigmaKa()) < cfgSingleTrackCuts.maxNsigmaTpcKa) { + if (track.sign() > 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassKPlus}); + } else { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng1, varUtils.pVectorProng0, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassKPlus}); + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, pVecTrack)); + if (!cfgQaPlots.applyCutsForQaHistograms || + ((varUtils.invMassD0 > cfgQaPlots.cutMassDMin && + varUtils.invMassD0 < cfgQaPlots.cutMassDMax) || + (varUtils.invMassD0Bar > cfgQaPlots.cutMassDMin && + varUtils.invMassD0Bar < cfgQaPlots.cutMassDMax))) { + if (track.sign() > 0) { + registry.fill(HIST("hMassD0K"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD0); + } else { + registry.fill(HIST("hMassD0K"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD0Bar); + } + } + } + // D0 p + if (std::abs(track.tpcNSigmaPr()) < cfgSingleTrackCuts.maxNsigmaTpcPr) { + if (track.sign() > 0) { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng0, varUtils.pVectorProng1, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassProton}); + } else { + varUtils.invMassReso = RecoDecay::m(std::array{varUtils.pVectorProng1, varUtils.pVectorProng0, pVecTrack}, std::array{MassPiPlus, MassKPlus, MassProton}); + } + varUtils.ptReso = RecoDecay::pt(RecoDecay::sumOfVec(varUtils.pVectorProng0, varUtils.pVectorProng1, pVecTrack)); + if (!cfgQaPlots.applyCutsForQaHistograms || + ((varUtils.invMassD0 > cfgQaPlots.cutMassDMin && + varUtils.invMassD0 < cfgQaPlots.cutMassDMax) || + (varUtils.invMassD0Bar > cfgQaPlots.cutMassDMin && + varUtils.invMassD0Bar < cfgQaPlots.cutMassDMax))) { + if (track.sign() > 0) { + registry.fill(HIST("hMassD0Proton"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD0); + } else { + registry.fill(HIST("hMassD0Proton"), varUtils.ptReso, varUtils.invMassReso - varUtils.invMassD0Bar); + } + } + } + break; + default: + break; // no other D meson types expected + } // end of DType switch + // fill track table if (!selectedTracks.count(track.globalIndex())) { - hfTrackNoParam(indexHfReducedCollision, + hfTrackNoParam(track.globalIndex(), + indexHfReducedCollision, track.px(), track.py(), track.pz(), track.sign(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), @@ -962,27 +1447,76 @@ struct HfDataCreatorCharmResoReduced { selectedTracks[track.globalIndex()] = hfTrackNoParam.lastIndex(); } fillHfCandD = true; - } // track loop - } - + if constexpr (doMc) { + int indexHfCandCharm{-1}; + if constexpr (dType == DType::Dstar) + indexHfCandCharm = hfCandDstar.lastIndex() + 1; + else if constexpr (dType == DType::Dplus) + indexHfCandCharm = hfCandD3Pr.lastIndex() + 1; + else if constexpr (dType == DType::D0) + indexHfCandCharm = hfCandD2Pr.lastIndex() + 1; + fillMcRecoInfoDTrack(particlesMc, candD, track, tracks, indexHfCandCharm, selectedTracks[track.globalIndex()]); + } + } // end of loop on bachelor tracks + } // end of do tracks + // fill D candidate table if (fillHfCandD) { // fill candDplus table only once per D candidate, only if at least one V0 is found - hfCandD(prongIdsD[0], prongIdsD[1], prongIdsD[2], - indexHfReducedCollision, - secondaryVertexD[0], secondaryVertexD[1], secondaryVertexD[2], - candD.pxProng0(), candD.pyProng0(), candD.pzProng0(), - candD.pxProng1(), candD.pyProng1(), candD.pzProng1(), - pVecProng2[0], pVecProng2[1], pVecProng2[2], - nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax, dtype); - if constexpr (withMl) { - hfCandDMl(bdtScores[0], bdtScores[1], bdtScores[2], -1., -1., -1.); + if constexpr (dType == DType::Dplus) { + hfCandD3Pr(prongIdsD[0], prongIdsD[1], prongIdsD[2], + indexHfReducedCollision, + secondaryVertexD[0], secondaryVertexD[1], secondaryVertexD[2], + candD.pxProng0(), candD.pyProng0(), candD.pzProng0(), + candD.pxProng1(), candD.pyProng1(), candD.pzProng1(), + varUtils.pVectorProng2[0], varUtils.pVectorProng2[1], varUtils.pVectorProng2[2], + nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax, varUtils.signD); + if constexpr (withMl) { + hfCandD3PrMl(bdtScores[0], bdtScores[1], bdtScores[2], bdtScores[3], bdtScores[4], bdtScores[5]); + } + } else if constexpr (dType == DType::D0) { + uint8_t selFlagD0 = {BIT(D0Sel::selectedD0) | BIT(D0Sel::selectedD0Bar)}; + if (candD.isSelD0() < cfgDmesCuts.selectionFlagD0) { + CLRBIT(selFlagD0, D0Sel::selectedD0); + } + if (candD.isSelD0bar() < cfgDmesCuts.selectionFlagD0Bar) { + CLRBIT(selFlagD0, D0Sel::selectedD0Bar); + } + hfCandD2Pr(prongIdsD[0], prongIdsD[1], + indexHfReducedCollision, + secondaryVertexD[0], secondaryVertexD[1], secondaryVertexD[2], + candD.pxProng0(), candD.pyProng0(), candD.pzProng0(), + candD.pxProng1(), candD.pyProng1(), candD.pzProng1(), + nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax, + selFlagD0); + if constexpr (withMl) { + hfCandD2PrMl(bdtScores[0], bdtScores[1], bdtScores[2], bdtScores[3], bdtScores[4], bdtScores[5]); + } + } else if constexpr (dType == DType::Dstar) { + hfCandDstar(prongIdsD[0], prongIdsD[1], prongIdsD[2], + indexHfReducedCollision, + secondaryVertexD[0], secondaryVertexD[1], secondaryVertexD[2], + candD.pxProng0(), candD.pyProng0(), candD.pzProng0(), + candD.pxProng1(), candD.pyProng1(), candD.pzProng1(), + varUtils.pVectorProng2[0], varUtils.pVectorProng2[1], varUtils.pVectorProng2[2], + nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax, + nItsClsSoftPi, nTpcCrossRowsSoftPi, chi2TpcSoftPi, + varUtils.signD); + if constexpr (withMl) { + hfCandD3PrMl(bdtScores[0], bdtScores[1], bdtScores[2], bdtScores[3], bdtScores[4], bdtScores[5]); + } } fillHfReducedCollision = true; - if constexpr (DecayChannel == DecayChannel::DstarV0 || DecayChannel == DecayChannel::DstarTrack) { - registry.fill(HIST("hMassVsPtDstarPaired"), candD.pt(), varUtils.invMassD - varUtils.invMassDdau); - } else if constexpr (DecayChannel == DecayChannel::DplusV0) { + if constexpr (dType == DType::Dstar) { + registry.fill(HIST("hMassVsPtDstarPaired"), candD.pt(), varUtils.invMassD - varUtils.invMassD0); + } else if constexpr (dType == DType::Dplus) { registry.fill(HIST("hMassVsPtDplusPaired"), candD.pt(), varUtils.invMassD); + } else if constexpr (dType == DType::D0) { + if (candD.isSelD0() >= cfgDmesCuts.selectionFlagD0) { + registry.fill(HIST("hMassVsPtD0Paired"), varUtils.ptD, varUtils.invMassD0); + } + if (candD.isSelD0bar() >= cfgDmesCuts.selectionFlagD0Bar) { + registry.fill(HIST("hMassVsPtD0BarPaired"), varUtils.ptD, varUtils.invMassD0Bar); + } } - registry.fill(HIST("hDType"), dtype); } } // candsD loop registry.fill(HIST("hEvents"), 1 + Event::Processed); @@ -991,149 +1525,262 @@ struct HfDataCreatorCharmResoReduced { return; } registry.fill(HIST("hEvents"), 1 + Event::DV0Selected); - float centrality = -1.f; - uint16_t hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); // fill collision table if it contains a DPi pair a minima hfReducedCollision(collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), hfRejMap, bz); - } // run data creation + } // end of runDataCreation function - template - void runMcGen(aod::McParticles const& particlesMc) + template + void runMcGen(McParticles const& mcParticles, + CCs const& collInfos, + McCollisions const& mcCollisions, + BCsInfo const&) { - // Match generated particles. - for (const auto& particle : particlesMc) { - int8_t sign{0}; - int8_t flag{0}; - int8_t signDStar{0}; - int8_t signDPlus{0}; - int8_t signV0{0}; - int8_t origin = 0; - std::vector idxBhadMothers{}; - - if constexpr (decayChannel == DecayChannel::DstarV0) { - // Ds1 → D* K0 - if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kDS1, std::array{static_cast(Pdg::kDStar), +kK0}, true, &sign, 1)) { - registry.fill(HIST("hMCSignCounter"), sign); - origin = RecoDecay::getCharmHadronOrigin(particlesMc, particle, false, &idxBhadMothers); - registry.fill(HIST("hMCGenOrigin"), origin); - auto candV0MC = particlesMc.rawIteratorAt(particle.daughtersIds().back()); - auto candDStarMC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); - // K0 -> K0s -> π+π- - if (RecoDecay::isMatchedMCGen(particlesMc, candV0MC, kK0, std::array{+kPiPlus, -kPiPlus}, true, &signV0, 2)) { - // D* -> D0 π+ -> K-π+π+ - if (RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{static_cast(Pdg::kD0), +static_cast(kPiPlus)}, true, &signDStar, 1)) { - auto candD0MC = particlesMc.rawIteratorAt(candDStarMC.daughtersIds().front()); - if (RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{-kKPlus, +kPiPlus, +kPiPlus}, true, &signDStar, 2)) { - flag = signDStar * DecayTypeMc::Ds1ToDStarK0ToD0PiK0s; - } else if (RecoDecay::isMatchedMCGen(particlesMc, candD0MC, Pdg::kD0, std::array{-kKPlus, +kPiPlus, +kPiPlus, +kPi0}, true, &signDStar, 2) || - RecoDecay::isMatchedMCGen(particlesMc, candD0MC, Pdg::kD0, std::array{-kKPlus, +kPiPlus, +kPiPlus, -kPi0}, true, &signDStar, 2)) { - flag = signDStar * DecayTypeMc::Ds1ToDStarK0ToD0PiK0sPart; + bool doV0s = (pairingType == PairingType::V0Only || pairingType == PairingType::V0AndTrack); + bool doTracks = (pairingType == PairingType::TrackOnly || pairingType == PairingType::V0AndTrack); + for (const auto& mcCollision : mcCollisions) { + // Slice the particles table to get the particles for the current MC collision + const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); + // Slice the collisions table to get the collision info for the current MC collision + float centrality{-1.f}; + uint16_t rejectionMask{0}; + int nSplitColl = 0; + const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + hfEvSelMc.fillHistograms(mcCollision, rejectionMask, nSplitColl); + if (rejectCollisionsWithBadEvSel && rejectionMask != 0) { + // at least one event selection not satisfied --> reject all gen particles from this collision + continue; + } + for (const auto& particle : mcParticlesPerMcColl) { + int8_t sign{0}; + int8_t flag{0}; + int8_t signD{0}; + int8_t signBach{0}; + int8_t origin{0}; + bool matchedReso{false}, matchedD{false}, matchedV0Tr{false}; + std::vector idxBhadMothers{}; + if constexpr (dType == DType::Dstar) { + if (doV0s) { + // D* K0s + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarK0s) { + matchedReso = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, particle, pdgCodeReso, std::array{static_cast(Pdg::kDStar), +kK0}, true, &sign, 1); + if (matchedReso) { + flag = sign * decayChannelFlag; + auto candV0MC = mcParticles.rawIteratorAt(particle.daughtersIds().back()); + matchedV0Tr = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, candV0MC, kK0, std::array{+kPiPlus, -kPiPlus}, true, &signBach, 2); + break; } - } else if (RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{static_cast(Pdg::kDPlus), static_cast(kGamma)}, true, &signDStar, 1) || - RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{static_cast(Pdg::kDPlus), -static_cast(kGamma)}, true, &signDStar, 1) || - RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{static_cast(Pdg::kDPlus), static_cast(kPi0)}, true, &signDStar, 1) || - RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{static_cast(Pdg::kDPlus), -static_cast(kPi0)}, true, &signDStar, 1)) { - auto candDPlusMC = particlesMc.rawIteratorAt(candDStarMC.daughtersIds().front()); - if (RecoDecay::isMatchedMCGen(particlesMc, candDPlusMC, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &signDPlus, 2)) - flag = sign * DecayTypeMc::Ds1ToDStarK0ToDPlusPi0K0s; } } - } else { - if (std::abs(particle.pdgCode()) == Pdg::kDS1) { - origin = RecoDecay::getCharmHadronOrigin(particlesMc, particle, false, &idxBhadMothers); - registry.fill(HIST("hMCOriginCounterWrongDecay"), origin); + if (doTracks && !matchedReso) { + // D*+ pi- + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDstarPi) { + matchedReso = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, particle, pdgCodeReso, std::array{static_cast(Pdg::kDStar), -static_cast(kPiPlus)}, true, &sign, 1); + if (matchedReso) { + flag = sign * decayChannelFlag; + matchedV0Tr = true; + break; + } + } } - } - // save information for task - if (flag == 0) { - continue; - } - - auto ptParticle = particle.pt(); - auto yParticle = RecoDecay::y(particle.pVector(), MassDS1); - auto etaParticle = particle.eta(); - - std::array ptProngs; - std::array yProngs; - std::array etaProngs; - int counter = 0; - for (const auto& daught : particle.daughters_as()) { - ptProngs[counter] = daught.pt(); - etaProngs[counter] = daught.eta(); - yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); - counter++; - } - registry.fill(HIST("hMCGenCounter"), flag, ptParticle); - rowHfResoMcGenReduced(flag, origin, ptParticle, yParticle, etaParticle, - ptProngs[0], yProngs[0], etaProngs[0], - ptProngs[1], yProngs[1], etaProngs[1]); - } else if constexpr (decayChannel == DecayChannel::DplusV0) { // Ds2Star → D+ K0 - if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kDS2Star, std::array{static_cast(Pdg::kDPlus), +kK0}, true, &sign, 1)) { - registry.fill(HIST("hMCSignCounter"), sign); - origin = RecoDecay::getCharmHadronOrigin(particlesMc, particle, false, &idxBhadMothers); - registry.fill(HIST("hMCGenOrigin"), origin); - auto candV0MC = particlesMc.rawIteratorAt(particle.daughtersIds().back()); - auto candDPlusMC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); - // K0 -> K0s -> π+π- - if (RecoDecay::isMatchedMCGen(particlesMc, candV0MC, kK0, std::array{+kPiPlus, -kPiPlus}, true, &signV0, 2)) { - // D* -> D0 π+ -> K-π+π+ - if (RecoDecay::isMatchedMCGen(particlesMc, candDPlusMC, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &signDPlus, 2)) { - flag = sign * DecayTypeMc::Ds2StarToDplusK0sToPiKaPiPiPi; + if (matchedReso && matchedV0Tr) { + auto candDstarMC = mcParticles.rawIteratorAt(particle.daughtersIds().front()); + matchedD = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, candDstarMC, Pdg::kDStar, std::array{static_cast(Pdg::kD0), +static_cast(kPiPlus)}, true, &signD, 1); + if (matchedD) { + auto candD0MC = mcParticles.rawIteratorAt(candDstarMC.daughtersIds().front()); + matchedD = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, candD0MC, Pdg::kD0, std::array{-kKPlus, +kPiPlus}, true, &signD, 2); + } + } + } else if constexpr (dType == DType::Dplus) { + if (doV0s) { + // D+ K0s + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDplusK0s) { + matchedReso = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, particle, pdgCodeReso, std::array{static_cast(Pdg::kDPlus), +kK0}, true, &sign, 1); + if (matchedReso) { + flag = sign * decayChannelFlag; + auto candV0MC = mcParticles.rawIteratorAt(particle.daughtersIds().back()); + matchedV0Tr = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, candV0MC, kK0, std::array{+kPiPlus, -kPiPlus}, true, &signBach, 2); + break; + } + } + if (!matchedReso) { + // D+ lambda + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDplusLambda) { + matchedReso = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, particle, pdgCodeReso, std::array{static_cast(Pdg::kDPlus), +kLambda0}, true, &sign, 1); + if (matchedReso) { + flag = sign * decayChannelFlag; + auto candV0MC = mcParticles.rawIteratorAt(particle.daughtersIds().back()); + matchedV0Tr = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, candV0MC, kLambda0, std::array{+kProton, -kPiPlus}, true, &signBach, 1); + break; + } + } } } - } else if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kDS1, std::array{static_cast(Pdg::kDStar), +kK0}, true, &sign, 1)) { - auto candV0MC = particlesMc.rawIteratorAt(particle.daughtersIds().back()); - // K0 -> K0s -> π+π- - if (RecoDecay::isMatchedMCGen(particlesMc, candV0MC, kK0, std::array{+kPiPlus, -kPiPlus}, true, &signV0, 2)) { - auto candDStarMC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); - // D* -> D+ π0/γ ->π+K-π+ π0/γ - if (RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{static_cast(Pdg::kDPlus), static_cast(kGamma)}, true, &signDStar, 1) || - RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{static_cast(Pdg::kDPlus), -static_cast(kGamma)}, true, &signDStar, 1) || - RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{static_cast(Pdg::kDPlus), static_cast(kPi0)}, true, &signDStar, 1) || - RecoDecay::isMatchedMCGen(particlesMc, candDStarMC, Pdg::kDStar, std::array{static_cast(Pdg::kDPlus), -static_cast(kPi0)}, true, &signDStar, 1)) { - auto candDPlusMC = particlesMc.rawIteratorAt(candDStarMC.daughtersIds().front()); - if (RecoDecay::isMatchedMCGen(particlesMc, candDPlusMC, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &signDPlus, 2)) - flag = sign * DecayTypeMc::Ds1ToDStarK0ToDPlusPi0K0s; + if (doTracks && !matchedReso) { + // D+ pi- + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToDplusPi) { + matchedReso = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, particle, pdgCodeReso, std::array{static_cast(Pdg::kDPlus), -static_cast(kPiPlus)}, true, &sign, 1); + if (matchedReso) { + flag = sign * decayChannelFlag; + matchedV0Tr = true; + break; + } } } - } else { - if (std::abs(particle.pdgCode()) == Pdg::kDS2Star) { - origin = RecoDecay::getCharmHadronOrigin(particlesMc, particle, false, &idxBhadMothers); - // LOGF(info, "Found DS2Star that decays into %d, %d", particlesMc.rawIteratorAt(particle.daughtersIds().front()).pdgCode(),particlesMc.rawIteratorAt(particle.daughtersIds().back()).pdgCode()); - registry.fill(HIST("hMCOriginCounterWrongDecay"), origin); + if (matchedReso && matchedV0Tr) { + auto candDplusMC = mcParticles.rawIteratorAt(particle.daughtersIds().front()); + matchedD = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, candDplusMC, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &signD, 2); + } + } else if constexpr (dType == DType::D0) { + if (doV0s) { + // D0 Lambda + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToD0Lambda) { + matchedReso = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, particle, pdgCodeReso, std::array{static_cast(Pdg::kD0), +kLambda0}, true, &sign, 1); + if (matchedReso) { + flag = sign * decayChannelFlag; + auto candV0MC = mcParticles.rawIteratorAt(particle.daughtersIds().back()); + matchedV0Tr = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, candV0MC, kLambda0, std::array{+kProton, -kPiPlus}, true, &signBach, 1); + break; + } + } + } + if (doTracks && !matchedReso) { + // D0 pi+ + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToD0Pi) { + matchedReso = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, particle, pdgCodeReso, std::array{static_cast(Pdg::kD0), +static_cast(kPiPlus)}, true, &sign, 1); + if (matchedReso) { + flag = sign * decayChannelFlag; + matchedV0Tr = true; + break; + } + } + // D0 K+ + if (!matchedReso) { + for (const auto& [decayChannelFlag, pdgCodeReso] : hf_decay::hf_cand_reso::particlesToD0Kplus) { + matchedReso = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, particle, pdgCodeReso, std::array{static_cast(Pdg::kD0), +static_cast(kKPlus)}, true, &sign, 1); + if (matchedReso) { + flag = sign * decayChannelFlag; + matchedV0Tr = true; + break; + } + } + } + } + if (matchedReso && matchedV0Tr) { + auto candD0MC = mcParticles.rawIteratorAt(particle.daughtersIds().front()); + matchedD = RecoDecay::isMatchedMCGen(mcParticlesPerMcColl, candD0MC, Pdg::kD0, std::array{-kKPlus, +kPiPlus}, true, &signD, 2); } } - // save information for task - if (flag == 0) { - continue; - } - - auto ptParticle = particle.pt(); - auto yParticle = RecoDecay::y(particle.pVector(), MassDS2Star); - auto etaParticle = particle.eta(); - - std::array ptProngs; - std::array yProngs; - std::array etaProngs; - int counter = 0; - for (const auto& daught : particle.daughters_as()) { - ptProngs[counter] = daught.pt(); - etaProngs[counter] = daught.eta(); - yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); - counter++; + if (matchedReso && matchedD && matchedV0Tr) { + origin = RecoDecay::getCharmHadronOrigin(mcParticlesPerMcColl, particle, false, &idxBhadMothers); + registry.fill(HIST("hMCGenOrigin"), origin); + auto ptParticle = particle.pt(); + auto invMassGen = RecoDecay::m(particle.p(), particle.e()); + auto yParticle = RecoDecay::y(particle.pVector(), invMassGen); + auto etaParticle = particle.eta(); + + std::array ptProngs; + std::array yProngs; + std::array etaProngs; + int counter = 0; + for (const auto& daught : particle.template daughters_as()) { + ptProngs[counter] = daught.pt(); + etaProngs[counter] = daught.eta(); + yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); + counter++; + } + registry.fill(HIST("hMCGenCounter"), flag, ptParticle); + rowHfResoMcGenReduced(flag, origin, ptParticle, yParticle, etaParticle, + ptProngs[0], yProngs[0], etaProngs[0], + ptProngs[1], yProngs[1], etaProngs[1], + invMassGen, rejectionMask); } - registry.fill(HIST("hMCGenCounter"), flag, ptParticle); - rowHfResoMcGenReduced(flag, origin, ptParticle, yParticle, etaParticle, - ptProngs[0], yProngs[0], etaProngs[0], - ptProngs[1], yProngs[1], etaProngs[1]); - } // Dplus V0 - } // for loop - } // gen + } + } + } + + // Process functions + // No ML + // Data + // D* + void processDstarV0(soa::Join const& collisions, + CandsDstarFiltered const& candsDstar, + aod::V0s const& v0s, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, nullptr, tracksIU, tracksIU, nullptr, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0, "Process Dstar candidates paired with V0s", true); + + void processDstarTrack(soa::Join const& collisions, + CandsDstarFiltered const& candsDstar, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, nullptr, trackIdsThisColl, tracks, tracks, nullptr, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarTrack, "Process Dstar candidates paired with Tracks", false); + + void processDstarV0AndTrack(soa::Join const& collisions, + CandsDstarFiltered const& candsDstar, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, tracks, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0AndTrack, "Process Dstar candidates paired with V0s and Tracks", false); + + // Dplus void processDplusV0(soa::Join const& collisions, CandsDplusFiltered const& candsDplus, - aod::V0s const& V0s, - TracksIUWithPID const& tracks, + aod::V0s const& v0s, + TracksIUWithPID const& tracksIU, aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; @@ -1145,20 +1792,45 @@ struct HfDataCreatorCharmResoReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollision, thisCollId); - auto V0sThisColl = V0s.sliceBy(candsV0PerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, tracks, bcs); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, nullptr, tracksIU, tracksIU, nullptr, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0, "Process Dplus candidates paired with V0s without MC info and without ML info", true); + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0, "Process Dplus candidates paired with V0s", false); - void processDplusV0MC(soa::Join const& collisions, - CandsDplusFiltered const& candsDplus, - aod::V0s const& V0s, - TracksIUWithPIDAndMC const& tracks, - aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs) + void processDplusTrack(soa::Join const& collisions, + CandsDplusFiltered const& candsDplus, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, nullptr, trackIdsThisColl, tracks, tracks, nullptr, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusTrack, "Process Dplus candidates paired with Tracks", false); + + void processDplusV0AndTrack(soa::Join const& collisions, + CandsDplusFiltered const& candsDplus, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; int sel8Coll{0}; @@ -1169,19 +1841,170 @@ struct HfDataCreatorCharmResoReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollision, thisCollId); - auto V0sThisColl = V0s.sliceBy(candsV0PerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, particlesMc, bcs); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, tracks, bcs); } - runMcGen(particlesMc); // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0MC, "Process DPlus candidates paired with V0s with MC matching and without ML info", false); + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0AndTrack, "Process Dplus candidates paired with V0s and Tracks", false); + + // D0 + void processD0V0(soa::Join const& collisions, + CandsD0Filtered const& candsD0, + aod::V0s const& v0s, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, nullptr, tracksIU, tracksIU, nullptr, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0V0, "Process D0 candidates paired with V0s", false); + void processD0Track(soa::Join const& collisions, + CandsD0Filtered const& candsD0, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, nullptr, trackIdsThisColl, tracks, tracks, nullptr, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0Track, "Process D0 candidates paired with Tracks", false); + + void processD0V0AndTrack(soa::Join const& collisions, + CandsD0Filtered const& candsD0, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, tracks, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0V0AndTrack, "Process D0 candidates paired with V0s and Tracks", false); + + // ML + // Data + // D* + void processDstarV0WithMl(soa::Join const& collisions, + CandsDstarFilteredWithMl const& candsDstar, + aod::V0s const& v0s, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, nullptr, tracksIU, tracksIU, nullptr, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0WithMl, "Process Dstar candidates paired with V0s with ML info", false); + + void processDstarTrackWithMl(soa::Join const& collisions, + CandsDstarFilteredWithMl const& candsDstar, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollisionWithMl, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, nullptr, trackIdsThisColl, tracks, tracks, nullptr, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarTrackWithMl, "Process Dstar candidates paired with Tracks with ML info", false); + + void processDstarV0AndTrackWithMl(soa::Join const& collisions, + CandsDstarFilteredWithMl const& candsDstar, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, tracks, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0AndTrackWithMl, "Process Dstar candidates paired with V0s and Tracks with ML info", false); + + // Dplus void processDplusV0WithMl(soa::Join const& collisions, CandsDplusFilteredWithMl const& candsDplus, - aod::V0s const& V0s, - TracksIUWithPID const& tracks, + aod::V0s const& v0s, + TracksIUWithPID const& tracksIU, aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; @@ -1193,20 +2016,19 @@ struct HfDataCreatorCharmResoReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollisionWithMl, thisCollId); - auto V0sThisColl = V0s.sliceBy(candsV0PerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, tracks, bcs); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, nullptr, tracksIU, tracksIU, nullptr, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0WithMl, "Process Dplus candidates paired with V0s with ML info", false); - void processDplusV0MCWithMl(soa::Join const& collisions, - CandsDplusFilteredWithMl const& candsDplus, - aod::V0s const& V0s, - TracksIUWithPIDAndMC const& tracks, - aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs) + void processDplusTrackWithMl(soa::Join const& collisions, + CandsDplusFilteredWithMl const& candsDplus, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; int sel8Coll{0}; @@ -1215,22 +2037,24 @@ struct HfDataCreatorCharmResoReduced { int allSelColl{0}; for (const auto& collision : collisions) { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollision, thisCollId); - auto V0sThisColl = V0s.sliceBy(candsV0PerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, particlesMc, bcs); + auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollisionWithMl, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, nullptr, trackIdsThisColl, tracks, tracks, nullptr, bcs); } - runMcGen(particlesMc); // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0MCWithMl, "Process DPlus candidates paired with V0s with MC matching and with ML info", false); - - void processDstarV0(soa::Join const& collisions, - CandDstarFiltered const& candsDstar, - aod::V0s const& V0s, - TracksIUWithPID const& tracks, - aod::BCsWithTimestamps const& bcs) + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusTrackWithMl, "Process Dplus candidates paired with Tracks with ML info", false); + + void processDplusV0AndTrackWithMl(soa::Join const& collisions, + CandsDplusFilteredWithMl const& candsDplus, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; int sel8Coll{0}; @@ -1240,21 +2064,22 @@ struct HfDataCreatorCharmResoReduced { for (const auto& collision : collisions) { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollision, thisCollId); - auto V0sThisColl = V0s.sliceBy(candsV0PerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, tracks, bcs); + auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, tracks, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0, "Process DStar candidates paired with V0s without MC info and without ML info", false); + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0AndTrackWithMl, "Process Dplus candidates paired with V0s and Tracks with ML info", false); - void processDstarV0MC(soa::Join const& collisions, - CandDstarFiltered const& candsDstar, - aod::V0s const& V0s, - TracksIUWithPIDAndMC const& tracks, - aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs) + // D0 + void processD0V0WithMl(soa::Join const& collisions, + CandsD0FilteredWithMl const& candsD0, + aod::V0s const& v0s, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; int sel8Coll{0}; @@ -1264,20 +2089,19 @@ struct HfDataCreatorCharmResoReduced { for (const auto& collision : collisions) { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollision, thisCollId); - auto V0sThisColl = V0s.sliceBy(candsV0PerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, particlesMc, bcs); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, nullptr, tracksIU, tracksIU, nullptr, bcs); } - runMcGen(particlesMc); // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0MC, "Process DStar candidates paired with V0s with MC matching and without ML info", false); + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0V0WithMl, "Process D0 candidates paired with V0s with ML info", false); - void processDstarV0WithMl(soa::Join const& collisions, - CandDstarFilteredWithMl const& candsDstar, - aod::V0s const& V0s, - TracksIUWithPID const& tracks, + void processD0TrackWithMl(soa::Join const& collisions, + CandsD0FilteredWithMl const& candsD0, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; @@ -1289,21 +2113,22 @@ struct HfDataCreatorCharmResoReduced { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollisionWithMl, thisCollId); - auto V0sThisColl = V0s.sliceBy(candsV0PerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, tracks, bcs); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollisionWithMl, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, nullptr, trackIdsThisColl, tracks, tracks, nullptr, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0WithMl, "Process DStar candidates paired with V0s with ML info", false); - - void processDstarV0MCWithMl(soa::Join const& collisions, - CandDstarFilteredWithMl const& candsDstar, - aod::V0s const& V0s, - TracksIUWithPIDAndMC const& tracks, - aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs) + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0TrackWithMl, "Process D0 candidates paired with Tracks with ML info", false); + + void processD0V0AndTrackWithMl(soa::Join const& collisions, + CandsD0FilteredWithMl const& candsD0, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPID const& tracks, + TracksIUWithPID const& tracksIU, + aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; int sel8Coll{0}; @@ -1313,21 +2138,27 @@ struct HfDataCreatorCharmResoReduced { for (const auto& collision : collisions) { o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollision, thisCollId); - auto V0sThisColl = V0s.sliceBy(candsV0PerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, particlesMc, bcs); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, tracks, bcs); } - runMcGen(particlesMc); // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0MCWithMl, "Process MC DStar candidates paired with V0s with ML info", false); + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0V0AndTrackWithMl, "Process D0 candidates paired with V0s and Tracks with ML info", false); - void processDstarTrack(soa::Join const& collisions, - CandDstarFiltered const& candsDstar, - aod::TrackAssoc const& trackIndices, - TracksWithPID const& tracks, - aod::BCsWithTimestamps const& bcs) + // MC + // No ML + // D* + void processDstarV0MC(soa::Join const& collisions, + CandsDstarFilteredWithMc const& candsDstar, + aod::V0s const& v0s, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) { int zvtxColl{0}; int sel8Coll{0}; @@ -1335,22 +2166,84 @@ struct HfDataCreatorCharmResoReduced { int zvtxAndSel8CollAndSoftTrig{0}; int allSelColl{0}; for (const auto& collision : collisions) { - o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, v0sThisColl, tracksIU, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0MC, "Process Dstar candidates paired with V0s with MC matching", false); + + void processDstarTrackMC(soa::Join const& collisions, + CandsDstarFilteredWithMc const& candsDstar, + TracksWithPIDAndMC const& tracks, + aod::TrackAssoc const& trackIndices, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, trackIdsThisColl, trackIdsThisColl, tracks, tracks, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarTrackMC, "Process Dstar candidates paired with tracks with MC matching", false); + + void processDstarV0AndTrackMC(soa::Join const& collisions, + CandsDstarFilteredWithMc const& candsDstar, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPIDAndMC const& tracks, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, trackIdsThisColl, tracks, tracks, bcs); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, particlesMc, bcs); } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarTrack, "Process DStar candidates paired with tracks without MC info and without ML info", false); + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0AndTrackMC, "Process Dstar candidates paired with V0s and tracks with MC matching", false); - void processDstarTrackWithMl(soa::Join const& collisions, - CandDstarFilteredWithMl const& candsDstar, - aod::TrackAssoc const& trackIndices, - TracksWithPID const& tracks, - aod::BCsWithTimestamps const& bcs) + // Dplus + void processDplusV0MC(soa::Join const& collisions, + CandsDplusFilteredWithMc const& candsDplus, + aod::V0s const& v0s, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) { int zvtxColl{0}; int sel8Coll{0}; @@ -1358,18 +2251,414 @@ struct HfDataCreatorCharmResoReduced { int zvtxAndSel8CollAndSoftTrig{0}; int allSelColl{0}; for (const auto& collision : collisions) { - o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, v0sThisColl, tracksIU, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0MC, "Process Dstar candidates paired with V0s with MC matching", false); + + void processDplusTrackMC(soa::Join const& collisions, + CandsDplusFilteredWithMc const& candsDplus, + TracksWithPIDAndMC const& tracks, + aod::TrackAssoc const& trackIndices, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, trackIdsThisColl, trackIdsThisColl, tracks, tracks, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusTrackMC, "Process Dplus candidates paired with tracks with MC matching", false); + + void processDplusV0AndTrackMC(soa::Join const& collisions, + CandsDplusFilteredWithMc const& candsDplus, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPIDAndMC const& tracks, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0AndTrackMC, "Process Dplus candidates paired with V0s and tracks with MC matching", false); + + // D0 + void processD0V0MC(soa::Join const& collisions, + CandsD0FilteredWithMc const& candsD0, + aod::V0s const& v0s, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, v0sThisColl, tracksIU, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0V0MC, "Process D0 candidates paired with V0s with MC matching", false); + void processD0TrackMC(soa::Join const& collisions, + CandsD0FilteredWithMc const& candsD0, + TracksWithPIDAndMC const& tracks, + aod::TrackAssoc const& trackIndices, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, trackIdsThisColl, trackIdsThisColl, tracks, tracks, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0TrackMC, "Process D0 candidates paired with tracks with MC matching", false); + + void processD0V0AndTrackMC(soa::Join const& collisions, + CandsD0FilteredWithMc const& candsD0, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPIDAndMC const& tracks, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollision, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0V0AndTrackMC, "Process D0 candidates paired with V0s and tracks with MC matching", false); + // ML + // D* + void processDstarV0MCWithMl(soa::Join const& collisions, + CandsDstarFilteredWithMlAndMc const& candsDstar, + aod::V0s const& v0s, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); auto thisCollId = collision.globalIndex(); auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, nullptr, tracksIU, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0MCWithMl, "Process Dstar candidates paired with V0s with MC matching and with ML info", false); + + void processDstarTrackMCWithMl(soa::Join const& collisions, + CandsDstarFilteredWithMlAndMc const& candsDstar, + TracksWithPIDAndMC const& tracks, + aod::TrackAssoc const& trackIndices, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollisionWithMl, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, trackIdsThisColl, trackIdsThisColl, tracks, tracks, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarTrackMCWithMl, "Process Dstar candidates paired with tracks with MC matching and with ML info", false); + + void processDstarV0AndTrackMCWithMl(soa::Join const& collisions, + CandsDstarFilteredWithMlAndMc const& candsDstar, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPIDAndMC const& tracks, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDstar.sliceBy(candsDstarPerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarV0AndTrackMCWithMl, "Process Dstar candidates paired with V0s and tracks with MC matching and with ML info", false); + + // Dplus + void processDplusV0MCWithMl(soa::Join const& collisions, + CandsDplusFilteredWithMlAndMc const& candsDplus, + aod::V0s const& v0s, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, nullptr, tracksIU, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0MCWithMl, "Process Dplus candidates paired with V0s with MC matching and with ML info", false); + + void processDplusTrackMCWithMl(soa::Join const& collisions, + CandsDplusFilteredWithMlAndMc const& candsDplus, + TracksWithPIDAndMC const& tracks, + aod::TrackAssoc const& trackIndices, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollisionWithMl, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, trackIdsThisColl, trackIdsThisColl, tracks, tracks, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusTrackMCWithMl, "Process Dplus candidates paired with tracks with MC matching and with ML info", false); + + void processDplusV0AndTrackMCWithMl(soa::Join const& collisions, + CandsDplusFilteredWithMlAndMc const& candsDplus, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPIDAndMC const& tracks, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsDplus.sliceBy(candsDplusPerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - runDataCreation(collision, candsDThisColl, trackIdsThisColl, tracks, tracks, bcs); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDplusV0AndTrackMCWithMl, "Process Dplus candidates paired with V0s and tracks with MC matching and with ML info", false); + + // D0 + void processD0V0MCWithMl(soa::Join const& collisions, + CandsD0FilteredWithMlAndMc const& candsD0, + aod::V0s const& v0s, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, nullptr, tracksIU, tracksIU, particlesMc, bcs); } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); } - PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processDstarTrackWithMl, "Process DStar candidates paired with tracks with ML info", false); + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0V0MCWithMl, "Process D0 candidates paired with V0s with MC matching and with ML info", false); + void processD0TrackMCWithMl(soa::Join const& collisions, + CandsD0FilteredWithMlAndMc const& candsD0, + TracksWithPIDAndMC const& tracks, + aod::TrackAssoc const& trackIndices, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollisionWithMl, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, trackIdsThisColl, trackIdsThisColl, tracks, tracks, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0TrackMCWithMl, "Process D0 candidates paired with tracks with MC matching and with ML info", false); + + void processD0V0AndTrackMCWithMl(soa::Join const& collisions, + CandsD0FilteredWithMlAndMc const& candsD0, + aod::V0s const& v0s, + aod::TrackAssoc const& trackIndices, + TracksWithPIDAndMC const& tracks, + TracksIUWithPIDAndMC const& tracksIU, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions) + { + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD0.sliceBy(candsD0PerCollisionWithMl, thisCollId); + auto v0sThisColl = v0s.sliceBy(candsV0PerCollision, thisCollId); + auto trackIdsThisColl = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, v0sThisColl, trackIdsThisColl, tracks, tracksIU, particlesMc, bcs); + } + runMcGen(particlesMc, collInfos, mcCollisions, bcs); + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorCharmResoReduced, processD0V0AndTrackMCWithMl, "Process D0 candidates paired with V0s and tracks with MC matching and with ML info", false); }; // struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx new file mode 100644 index 00000000000..cf6785d286c --- /dev/null +++ b/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx @@ -0,0 +1,1244 @@ +// 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. + +/// \file dataCreatorJpsiHadReduced.cxx +/// \brief Creation of J/Psi-LF hadron pairs for Beauty hadron analyses +/// +/// \author Fabrizio Chinu , Università degli Studi and INFN Torino +/// \author Fabrizio Grosa , CERN + +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelectorPID.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::analysis; +using namespace o2::aod; +using namespace o2::constants::physics; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; + +enum Event : uint8_t { // TODO: check if needed + Processed = 0, + NoCharmHadPiSelected, + CharmHadPiSelected, + NEvent +}; + +enum DecayChannel : uint8_t { + B0ToJpsiK0Star = 0, + BplusToJpsiK, + BsToJpsiPhi +}; + +enum WrongCollisionType : uint8_t { + None = 0, + WrongAssociation, + SplitCollision, +}; + +/// Creation of Jpsi-Had pairs for Beauty hadrons +struct HfDataCreatorJpsiHadReduced { + // Produces AOD tables to store track information + // collision related tables + Produces hfReducedCollision; + Produces hfReducedCollCentrality; + Produces hfReducedQvector; + Produces hfReducedCollExtra; + Produces hfCollisionCounter; + // J/Psi related tables + Produces hfJpsi; + Produces hfRedJpsiCov; + // Ka bachelor related tables + Produces hfTrackLfDau0; + Produces hfTrackCovLfDau0; + Produces hfTrackLfDau1; + Produces hfTrackCovLfDau1; + // MC related tables + Produces rowHfJpsiKMcRecReduced; + Produces rowHfJpsiPhiMcRecReduced; + Produces rowHfBpMcGenReduced; + Produces rowHfBsMcGenReduced; + + Produces rowCandidateConfigBplus; + Produces rowCandidateConfigBs; + + Configurable skipRejectedCollisions{"skipRejectedCollisions", true, "skips collisions rejected by the event selection, instead of flagging only"}; + Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; + Configurable useAbsDCA{"useAbsDCA", false, "Minimise abs. distance rather than chi2"}; + Configurable useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; + Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; + Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; + Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any B0 is smaller than this"}; + Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; + + Configurable runJpsiToee{"runJpsiToee", false, "Run analysis for J/Psi to ee (debug)"}; + struct : o2::framework::ConfigurableGroup { + // TPC PID + Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; + Configurable ptPidTpcMax{"ptPidTpcMax", 5., "Upper bound of track pT for TPC PID"}; + Configurable nSigmaTpcElMax{"nSigmaTpcElMax", 4., "Electron nsigma cut on TPC only"}; + Configurable nSigmaTpcPiMin{"nSigmaTpcPiMin", 2.5, "Pion nsigma cut on TPC only"}; + Configurable nSigmaTpcPiMax{"nSigmaTpcPiMax", 99., "Pion nsigma cut on TPC only"}; + Configurable nSigmaTpcPrMin{"nSigmaTpcPrMin", -99., "Proton nsigma cut on TPC only"}; + Configurable nSigmaTpcPrMax{"nSigmaTpcPrMax", 99, "Proton nsigma cut on TPC only"}; + Configurable nSigmaTpcElCombinedMax{"nSigmaTpcElCombinedMax", 4., "Electron Nsigma cut on TPC combined with TOF"}; + Configurable nSigmaTpcPiCombinedMin{"nSigmaTpcPiCombinedMin", 2.5, "Pion Nsigma cut on TPC combined with TOF"}; + Configurable nSigmaTpcPiCombinedMax{"nSigmaTpcPiCombinedMax", 99., "Pion Nsigma cut on TPC combined with TOF"}; + Configurable nSigmaTpcPrCombinedMin{"nSigmaTpcPrCombinedMin", -99., "Proton Nsigma cut on TPC combined with TOF"}; + Configurable nSigmaTpcPrCombinedMax{"nSigmaTpcPrCombinedMax", 99, "Proton Nsigma cut on TPC combined with TOF"}; + // TOF PID + Configurable ptPidTofMin{"ptPidTofMin", 0.15, "Lower bound of track pT for TOF PID"}; + Configurable ptPidTofMax{"ptPidTofMax", 5., "Upper bound of track pT for TOF PID"}; + Configurable nSigmaTofElMax{"nSigmaTofElMax", 4., "Electron nsigma cut on TPC only"}; + Configurable nSigmaTofPiMin{"nSigmaTofPiMin", -99, "Pion nsigma cut on TPC only"}; + Configurable nSigmaTofPiMax{"nSigmaTofPiMax", 99., "Pion nsigma cut on TPC only"}; + Configurable nSigmaTofPrMin{"nSigmaTofPrMin", -99, "Proton nsigma cut on TPC only"}; + Configurable nSigmaTofPrMax{"nSigmaTofPrMax", 99., "Proton nsigma cut on TPC only"}; + Configurable nSigmaTofElCombinedMax{"nSigmaTofElCombinedMax", 4., "Electron Nsigma cut on TOF combined with TPC"}; + Configurable nSigmaTofPiCombinedMin{"nSigmaTofPiCombinedMin", 2.5, "Pion Nsigma cut on TOF combined with TPC"}; + Configurable nSigmaTofPiCombinedMax{"nSigmaTofPiCombinedMax", 99., "Pion Nsigma cut on TOF combined with TPC"}; + Configurable nSigmaTofPrCombinedMin{"nSigmaTofPrCombinedMin", -99., "Proton Nsigma cut on TOF combined with TPC"}; + Configurable nSigmaTofPrCombinedMax{"nSigmaTofPrCombinedMax", 99, "Proton Nsigma cut on TOF combined with TPC"}; + // AND logic for TOF+TPC PID (as in Run2) + Configurable usePidTpcAndTof{"usePidTpcAndTof", true, "Use AND logic for TPC and TOF PID"}; + } selectionsPid; + Configurable ptJpsiMin{"ptJpsiMin", 0., "Lower bound of J/Psi pT"}; + Configurable ptJpsiMax{"ptJpsiMax", 50., "Upper bound of J/Psi pT"}; + Configurable useTrackIsGlobalTrackWoDCA{"useTrackIsGlobalTrackWoDCA", true, "check isGlobalTrackWoDCA status for the bachelor tracks"}; + Configurable ptTrackMin{"ptTrackMin", 0.5, "minimum bachelor track pT threshold (GeV/c)"}; + Configurable absEtaTrackMax{"absEtaTrackMax", 0.8, "maximum bachelor track absolute eta threshold"}; + Configurable> binsPtTrack{"binsPtTrack", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for bachelor track DCA XY pT-dependent cut"}; + Configurable> cutsTrackDCA{"cutsTrackDCA", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for bachelor track"}; + // topological/kinematic cuts + Configurable> binsPt{"binsPt", std::vector{hf_cuts_jpsi_to_mu_mu::vecBinsPt}, "J/Psi pT bin limits"}; + Configurable> cuts{"cuts", {hf_cuts_jpsi_to_mu_mu::Cuts[0], hf_cuts_jpsi_to_mu_mu::NBinsPt, hf_cuts_jpsi_to_mu_mu::NCutVars, hf_cuts_jpsi_to_mu_mu::labelsPt, hf_cuts_jpsi_to_mu_mu::labelsCutVar}, "J/Psi candidate selection per pT bin"}; + Configurable invMassWindowJpsiHad{"invMassWindowJpsiHad", 0.3, "invariant-mass window for Jpsi-Had pair preselections (GeV/c2)"}; + Configurable deltaMPhiMax{"deltaMPhiMax", 0.02, "invariant-mass window for phi preselections (GeV/c2) (only for Bs->J/PsiPhi)"}; + Configurable cpaMin{"cpaMin", 0., "Minimum cosine of pointing angle for B candidates"}; + Configurable decLenMin{"decLenMin", 0., "Minimum decay length for B candidates"}; + + // magnetic field setting from CCDB + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; + + HfHelper hfHelper; + + TrackSelectorPi selectorPion; + TrackSelectorPr selectorProton; + TrackSelectorEl selectorElectron; + + // CCDB service + Service ccdb; + // O2DatabasePDG service + Service pdg; + + using TracksPid = soa::Join; + using TracksPidWithSel = soa::Join; + using TracksPidWithSelAndMc = soa::Join; + using CollisionsWCMcLabels = soa::Join; + using BCsInfo = soa::Join; + + Preslice candsJpsiPerCollision = aod::track_association::collisionId; + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + + o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + int runNumber; + double bz{0.}; + double invMass2JpsiHadMin, invMass2JpsiHadMax; + bool isHfCandBhadConfigFilled = false; + + o2::hf_evsel::HfEventSelection hfEvSel; + o2::hf_evsel::HfEventSelectionMc hfEvSelMc; + + o2::vertexing::DCAFitterN<2> df2; + o2::vertexing::DCAFitterN<3> df3; + o2::vertexing::DCAFitterN<4> df4; + + HistogramRegistry registry{"registry"}; + + void init(InitContext& initContext) + { + selectorPion.setRangePtTpc(selectionsPid.ptPidTpcMin, selectionsPid.ptPidTpcMax); + selectorPion.setRangeNSigmaTpc(-selectionsPid.nSigmaTpcPiMax, selectionsPid.nSigmaTpcPiMax); + selectorPion.setRangeNSigmaTpcCondTof(-selectionsPid.nSigmaTpcPiCombinedMax, selectionsPid.nSigmaTpcPiCombinedMax); + selectorPion.setRangePtTof(selectionsPid.ptPidTofMin, selectionsPid.ptPidTofMax); + selectorPion.setRangeNSigmaTof(-selectionsPid.nSigmaTofPiMax, selectionsPid.nSigmaTofPiMax); + selectorPion.setRangeNSigmaTofCondTpc(-selectionsPid.nSigmaTofPiCombinedMax, selectionsPid.nSigmaTofPiCombinedMax); + + selectorProton.setRangePtTpc(selectionsPid.ptPidTpcMin, selectionsPid.ptPidTpcMax); + selectorProton.setRangeNSigmaTpc(-selectionsPid.nSigmaTpcPrMax, selectionsPid.nSigmaTpcPrMax); + selectorProton.setRangeNSigmaTpcCondTof(-selectionsPid.nSigmaTpcPrCombinedMax, selectionsPid.nSigmaTpcPrCombinedMax); + selectorProton.setRangePtTof(selectionsPid.ptPidTofMin, selectionsPid.ptPidTofMax); + selectorProton.setRangeNSigmaTof(-selectionsPid.nSigmaTofPrMax, selectionsPid.nSigmaTofPrMax); + selectorProton.setRangeNSigmaTofCondTpc(-selectionsPid.nSigmaTofPrCombinedMax, selectionsPid.nSigmaTofPrCombinedMax); + + selectorElectron.setRangePtTpc(selectionsPid.ptPidTpcMin, selectionsPid.ptPidTpcMax); + selectorElectron.setRangeNSigmaTpc(-selectionsPid.nSigmaTpcElMax, selectionsPid.nSigmaTpcElMax); + selectorElectron.setRangeNSigmaTpcCondTof(-selectionsPid.nSigmaTofElCombinedMax, selectionsPid.nSigmaTofElCombinedMax); + selectorElectron.setRangePtTof(selectionsPid.ptPidTofMin, selectionsPid.ptPidTofMax); + selectorElectron.setRangeNSigmaTof(-selectionsPid.nSigmaTofElMax, selectionsPid.nSigmaTofElMax); + selectorElectron.setRangeNSigmaTofCondTpc(-selectionsPid.nSigmaTofElCombinedMax, selectionsPid.nSigmaTofElCombinedMax); + + std::array doProcess = {doprocessJpsiKData, doprocessJpsiKMc, doprocessJpsiPhiData, doprocessJpsiPhiMc}; + if (std::accumulate(doProcess.begin(), doProcess.end(), 0) != 1) { + LOGP(fatal, "One and only one process function can be enabled at a time, please fix your configuration!"); + } + + // Set up the histogram registry + constexpr int kNBinsSelections = 2 + aod::SelectionStep::RecoPID; + std::string labels[kNBinsSelections]; + labels[0] = "No selection"; + labels[1 + aod::SelectionStep::RecoSkims] = "Skims selection"; + labels[1 + aod::SelectionStep::RecoTopol] = "Skims & Topological selections"; + labels[1 + aod::SelectionStep::RecoPID] = "Skims & Topological & PID selections"; + static const AxisSpec axisSelections = {kNBinsSelections, 0.5, kNBinsSelections + 0.5, ""}; + registry.add("hSelectionsJpsi", "J/Psi selection;;#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisSelections, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); + for (int iBin = 0; iBin < kNBinsSelections; ++iBin) { + registry.get(HIST("hSelectionsJpsi"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); + } + + constexpr int kNBinsEvents = NEvent; + std::string labelsEvents[kNBinsEvents]; + labelsEvents[Event::Processed] = "processed"; + labelsEvents[Event::NoCharmHadPiSelected] = "without CharmHad-Pi pairs"; + labelsEvents[Event::CharmHadPiSelected] = "with CharmHad-Pi pairs"; + static const AxisSpec axisEvents = {kNBinsEvents, 0.5, kNBinsEvents + 0.5, ""}; + registry.add("hEvents", "Events;;entries", HistType::kTH1F, {axisEvents}); + for (int iBin = 0; iBin < kNBinsEvents; iBin++) { + registry.get(HIST("hEvents"))->GetXaxis()->SetBinLabel(iBin + 1, labelsEvents[iBin].data()); + } + + registry.add("hMassJpsi", "J/Psi mass;#it{M}_{#mu#mu} (GeV/#it{c}^{2});Counts", {HistType::kTH1F, {{600, 2.8, 3.4, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hPtJpsi", "J/Psi #it{p}_{T};#it{p}_{T} (GeV/#it{c});Counts", {HistType::kTH1F, {{(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("hCpaJpsi", "J/Psi cos#theta_{p};J/Psi cos#theta_{p};Counts", {HistType::kTH1F, {{200, -1., 1, "J/Psi cos#theta_{p}"}}}); + std::shared_ptr hFitCandidatesJpsi = registry.add("hFitCandidatesJpsi", "Jpsi candidate counter", {HistType::kTH1D, {axisCands}}); + std::shared_ptr hFitCandidatesBPlus = registry.add("hFitCandidatesBPlus", "hFitCandidatesBPlus candidate counter", {HistType::kTH1D, {axisCands}}); + std::shared_ptr hFitCandidatesBS = registry.add("hFitCandidatesBS", "hFitCandidatesBS candidate counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hFitCandidatesJpsi); + setLabelHistoCands(hFitCandidatesBPlus); + setLabelHistoCands(hFitCandidatesBS); + if (doprocessJpsiKData || doprocessJpsiKMc) { + registry.add("hPtKaon", "Kaon #it{p}_{T};#it{p}_{T} (GeV/#it{c});Counts", {HistType::kTH1F, {{100, 0., 10.}}}); + registry.add("hMassJpsiKaon", "J/Psi Kaon mass;#it{M}_{J/#PsiK} (GeV/#it{c}^{2});Counts", {HistType::kTH1F, {{800, 4.9, 5.7}}}); + } else if (doprocessJpsiPhiData || doprocessJpsiPhiMc) { + registry.add("hPtPhi", "Phi #it{p}_{T};#it{p}_{T} (GeV/#it{c});Counts", {HistType::kTH1F, {{100, 0., 10.}}}); + registry.add("hMassPhi", "Phi mass;#it{M}_{KK} (GeV/#it{c}^{2});Counts", {HistType::kTH1F, {{200, 0.9, 1.2}}}); + registry.add("hMassJpsiPhi", "J/Psi Phi mass;#it{M}_{J/#Psi#phi} (GeV/#it{c}^{2});Counts", {HistType::kTH1F, {{800, 4.9, 5.7}}}); + std::shared_ptr hFitCandidatesPhi = registry.add("hFitCandidatesPhi", "Phi candidate counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hFitCandidatesPhi); + } + + df2.setPropagateToPCA(propagateToPCA); + df2.setMaxR(maxR); + df2.setMaxDZIni(maxDZIni); + df2.setMinParamChange(minParamChange); + df2.setMinRelChi2Change(minRelChi2Change); + df2.setUseAbsDCA(useAbsDCA); + df2.setWeightedFinalPCA(useWeightedFinalPCA); + df2.setMatCorrType(noMatCorr); + + df3.setPropagateToPCA(propagateToPCA); + df3.setMaxR(maxR); + df3.setMaxDZIni(maxDZIni); + df3.setMinParamChange(minParamChange); + df3.setMinRelChi2Change(minRelChi2Change); + df3.setUseAbsDCA(useAbsDCA); + df3.setWeightedFinalPCA(useWeightedFinalPCA); + df3.setMatCorrType(noMatCorr); + + df4.setPropagateToPCA(propagateToPCA); + df4.setMaxR(maxR); + df4.setMaxDZIni(maxDZIni); + df4.setMinParamChange(minParamChange); + df4.setMinRelChi2Change(minRelChi2Change); + df4.setUseAbsDCA(useAbsDCA); + df4.setWeightedFinalPCA(useWeightedFinalPCA); + df4.setMatCorrType(noMatCorr); + + // Configure CCDB access + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + runNumber = 0; + + if (doprocessJpsiKData || doprocessJpsiKMc) { + invMass2JpsiHadMin = (MassBPlus - invMassWindowJpsiHad) * (MassBPlus - invMassWindowJpsiHad); + invMass2JpsiHadMax = (MassBPlus + invMassWindowJpsiHad) * (MassBPlus + invMassWindowJpsiHad); + } else if (doprocessJpsiPhiData || doprocessJpsiPhiMc) { + invMass2JpsiHadMin = (MassBS - invMassWindowJpsiHad) * (MassBS - invMassWindowJpsiHad); + invMass2JpsiHadMax = (MassBS + invMassWindowJpsiHad) * (MassBS + invMassWindowJpsiHad); + } + + // init HF event selection helper + hfEvSel.init(registry); + if (doprocessJpsiKMc || doprocessJpsiPhiMc) { + const auto& workflows = initContext.services().get(); + for (const DeviceSpec& device : workflows.devices) { + if (device.name.compare("hf-data-creator-jpsi-had-reduced") == 0) { + // init HF event selection helper + hfEvSelMc.init(device, registry); + break; + } + } + } + } + + /// Topological cuts + /// \param candidate is candidate + /// \param trackPos is the positive track + /// \param trackNeg is the negative track + /// \return true if candidate passes all cuts + template + bool selectionTopol(const T1& candidate, const T2& trackPos, const T2& trackNeg) + { + auto candpT = candidate.pt(); + auto candInvMass = runJpsiToee ? hfHelper.invMassJpsiToEE(candidate) : hfHelper.invMassJpsiToMuMu(candidate); + auto pseudoPropDecLen = candidate.decayLengthXY() * candInvMass / candpT; + auto pTBin = findBin(binsPt, candpT); + if (pTBin == -1) { + return false; + } + + // check that the candidate pT is within the analysis range + if (candpT < ptJpsiMin || candpT >= ptJpsiMax) { + return false; + } + + // cut on μ+ μ− (e+e−) invariant mass + if (std::abs(candInvMass - o2::constants::physics::MassJPsi) > cuts->get(pTBin, "m")) { + return false; + } + + // cut on daughter pT (same cut used for both channels) + if (trackNeg.pt() < cuts->get(pTBin, "pT mu") || trackPos.pt() < cuts->get(pTBin, "pT mu")) { + return false; + } + + // decay length + if (candidate.decayLength() < cuts->get(pTBin, "decay length")) { + return false; + } + + // decay length in XY plane + if (candidate.decayLengthXY() < cuts->get(pTBin, "decay length xy")) { + return false; + } + + // cosine of pointing angle + if (candidate.cpa() < cuts->get(pTBin, "cpa")) { + return false; + } + + // cosine of pointing angle XY + if (candidate.cpaXY() < cuts->get(pTBin, "cpa xy")) { + return false; + } + + // product of daughter impact parameters + if (candidate.impactParameterProduct() > cuts->get(pTBin, "d0xd0")) { + return false; + } + + // pseudoproper decay length + if (pseudoPropDecLen < cuts->get(pTBin, "pseudoprop. decay length")) { + return false; + } + + return true; + } + + /// Kaon selection (J/Psi K+ <-- B+) + /// \param track is the considered track + /// \param trackParCov is the track parametrisation + /// \param dca is the 2-D array with track DCAs + /// \param jPsiDautracks J/Psi daughter tracks + /// \return true if track passes all cuts + template + bool isTrackSelected(const T1& track, const T2& trackParCov, const T3& dca, const std::vector& jPsiDautracks) + { + // check isGlobalTrackWoDCA status for kaons if wanted + if (useTrackIsGlobalTrackWoDCA && !track.isGlobalTrackWoDCA()) { + return false; + } + // minimum pT, eta, and DCA selection + if (trackParCov.getPt() < ptTrackMin || std::abs(trackParCov.getEta()) > absEtaTrackMax || !isSelectedTrackDCA(trackParCov, dca, binsPtTrack, cutsTrackDCA)) { + return false; + } + // reject kaons that are J/Psi daughters + for (const auto& trackJpsi : jPsiDautracks) { + if (track.globalIndex() == trackJpsi.globalIndex()) { + return false; + } + } + + return true; + } + + template + bool isSelectedJpsiDauPid(const T1& track) + { + int pidPion = -1; + int pidProton = -1; + int pidElectron = -1; + + if (selectionsPid.usePidTpcAndTof) { + pidPion = selectorPion.statusTpcAndTof(track, track.tpcNSigmaPi(), track.tofNSigmaPi()); + pidProton = selectorProton.statusTpcAndTof(track, track.tpcNSigmaPr(), track.tofNSigmaPr()); + pidElectron = selectorElectron.statusTpcAndTof(track, track.tpcNSigmaEl(), track.tofNSigmaEl()); + } else { + pidPion = selectorPion.statusTpcOrTof(track, track.tpcNSigmaPi(), track.tofNSigmaPi()); + pidProton = selectorProton.statusTpcOrTof(track, track.tpcNSigmaPr(), track.tofNSigmaPr()); + pidElectron = selectorElectron.statusTpcOrTof(track, track.tpcNSigmaEl(), track.tofNSigmaEl()); + } + + if (pidPion == TrackSelectorPID::Rejected || + pidProton == TrackSelectorPID::Rejected || + pidElectron == TrackSelectorPID::Rejected) { + return false; + } + return true; + } + + /// B meson preselections + /// \param momentum is the B meson momentum + /// \param secondaryVertex is the reconstructed secondary vertex + /// \param collision is the reconstructed collision + template + bool isBSelected(const T1& momentum, const T2& secondaryVertex, const T3& collision) + { + // B candidate CPA + if (RecoDecay::cpa(std::array{collision.posX(), collision.posY(), collision.posZ()}, secondaryVertex, momentum) < cpaMin) { + return false; + } + + // B candidate decay length + if (RecoDecay::distance(std::array{collision.posX(), collision.posY(), collision.posZ()}, secondaryVertex) < decLenMin) { + return false; + } + + return true; + } + + /// Checks if the B meson is associated with a different collision than the one it was generated in + /// \param particleMother is the mother particle + /// \param collision is the reconstructed collision + /// \param indexCollisionMaxNumContrib is the index of the collision associated with a given MC collision with the largest number of contributors. + /// \param flagWrongCollision is the flag indicating if whether the associated collision is incorrect. + template + void checkWrongCollision(const PParticle& particleMother, + const CColl& collision, + const int64_t& indexCollisionMaxNumContrib, + int8_t& flagWrongCollision) + { + + if (particleMother.mcCollision().globalIndex() != collision.mcCollisionId()) { + flagWrongCollision = WrongCollisionType::WrongAssociation; + } else { + if (collision.globalIndex() != indexCollisionMaxNumContrib) { + flagWrongCollision = WrongCollisionType::SplitCollision; + } + } + } + + /// Function for filling MC reco information in the tables + /// \param particlesMc is the table with MC particles + /// \param vecDaughtersB is the vector with all daughter tracks (Jpsi daughters in first position) + /// \param indexHfCandJpsi is the index of the Jpsi candidate + /// \param selectedTracksBach is the map with the indices of selected bachelor pion tracks + template + void fillMcRecoInfo(const CColl& collision, + const PParticles& particlesMc, + const std::vector& vecDaughtersB, + int& indexHfCandJpsi, + std::array, 2> selectedTracksBach, + const int64_t indexCollisionMaxNumContrib) + { + + // we check the MC matching to be stored + int8_t sign{0}, flag{0}, channel{0}; + int8_t flagWrongCollision{WrongCollisionType::None}; + int8_t debug{0}; + float motherPt{-1.f}; + + if constexpr (decChannel == DecayChannel::BplusToJpsiK) { + // B+ → J/Psi K+ → (µ+µ-) K+ + int indexRec = -1; + if (!runJpsiToee) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kBPlus, std::array{-kMuonMinus, +kMuonMinus, +kKPlus}, true, &sign, 3); + } else { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2]}, Pdg::kBPlus, std::array{-kElectron, +kElectron, +kKPlus}, true, &sign, 3); + } + if (indexRec > -1) { + // J/Psi → µ+µ- + if (!runJpsiToee) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1]}, Pdg::kJPsi, std::array{-kMuonMinus, +kMuonMinus}, true); + } else { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1]}, Pdg::kJPsi, std::array{-kElectron, +kElectron}, true); + } + if (indexRec > -1) { + flag = sign * o2::hf_decay::hf_cand_beauty::BplusToJpsiK; + } else { + debug = 1; + LOGF(debug, "B+ decays in the expected final state but the condition on the intermediate state is not fulfilled"); + } + + auto indexMother = RecoDecay::getMother(particlesMc, vecDaughtersB.back().template mcParticle_as(), Pdg::kBPlus, true); + if (indexMother >= 0) { + auto particleMother = particlesMc.rawIteratorAt(indexMother); + motherPt = particleMother.pt(); + checkWrongCollision(particleMother, collision, indexCollisionMaxNumContrib, flagWrongCollision); + } + } + rowHfJpsiKMcRecReduced(indexHfCandJpsi, selectedTracksBach[0][vecDaughtersB.back().globalIndex()], flag, channel, flagWrongCollision, debug, motherPt); + } else if constexpr (decChannel == DecayChannel::BsToJpsiPhi) { + // Bs → J/Psi phi → (µ+µ-) (K+K-) + int indexRec = -1; + if (!runJpsiToee) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kMuonMinus, +kMuonMinus, +kKPlus, -kKPlus}, true, &sign, 4); + } else { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1], vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kBS, std::array{-kElectron, +kElectron, +kKPlus, -kKPlus}, true, &sign, 4); + } + if (indexRec > -1) { + // J/Psi → µ+µ- + if (!runJpsiToee) { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1]}, Pdg::kJPsi, std::array{-kMuonMinus, +kMuonMinus}, true, &sign, 1); + } else { + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[0], vecDaughtersB[1]}, Pdg::kJPsi, std::array{-kElectron, +kElectron}, true, &sign, 1); + } + if (indexRec > -1) { + flag = sign * o2::hf_decay::hf_cand_beauty::BsToJpsiKK; + indexRec = RecoDecay::getMatchedMCRec(particlesMc, std::array{vecDaughtersB[2], vecDaughtersB[3]}, Pdg::kPhi, std::array{-kKPlus, +kKPlus}, true, &sign, 1); + if (indexRec > -1) { + channel = o2::hf_decay::hf_cand_beauty::BsToJpsiPhi; + } else { + debug = 1; + LOGF(debug, "Bs decays in the expected final state but the condition on the phi intermediate state is not fulfilled"); + } + } else { + debug = 1; + LOGF(debug, "Bs decays in the expected final state but the condition on the J/Psi intermediate state is not fulfilled"); + } + + auto indexMother = RecoDecay::getMother(particlesMc, vecDaughtersB.back().template mcParticle_as(), Pdg::kBS, true); + if (indexMother >= 0) { + auto particleMother = particlesMc.rawIteratorAt(indexMother); + motherPt = particleMother.pt(); + checkWrongCollision(particleMother, collision, indexCollisionMaxNumContrib, flagWrongCollision); + } + } + rowHfJpsiPhiMcRecReduced(indexHfCandJpsi, selectedTracksBach[0][vecDaughtersB.back().globalIndex()], selectedTracksBach[1][vecDaughtersB.back().globalIndex()], flag, channel, flagWrongCollision, debug, motherPt); + } + } + + /// Calculates the index of the collision with the maximum number of contributions. + ///\param collisions are the collisions to search through. + ///\return The index of the collision with the maximum number of contributions. + template + int64_t getIndexCollisionMaxNumContrib(const CColl& collisions) + { + unsigned maxNumContrib = 0; + int64_t indexCollisionMaxNumContrib = -1; + for (const auto& collision : collisions) { + if (collision.numContrib() > maxNumContrib) { + maxNumContrib = collision.numContrib(); + indexCollisionMaxNumContrib = collision.globalIndex(); + } + } + return indexCollisionMaxNumContrib; + } + + template + void runMcGen(aod::McCollision const& mcCollision, + aod::McParticles const& particlesMc, + CollisionsWCMcLabels const& collisions, + BCsInfo const&) + { + // Check event selection + float centDummy{-1.f}, centFT0C{-1.f}, centFT0M{-1.f}; + const auto collSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + auto hfRejMap = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centDummy); + if (skipRejectedCollisions && hfRejMap != 0) { + return; + } + + const auto mcParticlesPerMcColl = particlesMc.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); + + // Match generated particles. + for (const auto& particle : mcParticlesPerMcColl) { + int8_t sign{0}, flag{0}, channel{0}; + if constexpr (decChannel == DecayChannel::BplusToJpsiK) { + // B+ → J/Psi K+ → (µ+µ-) K+ + if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kBPlus, std::array{static_cast(Pdg::kJPsi), +kKPlus}, true, &sign)) { + // Match J/Psi -> µ+µ- + auto candJpsiMC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); + // Printf("Checking J/Psi -> µ+µ-"); + if (!runJpsiToee) { + if (RecoDecay::isMatchedMCGen(particlesMc, candJpsiMC, static_cast(Pdg::kJPsi), std::array{-kMuonMinus, +kMuonMinus}, true)) { + flag = sign * o2::hf_decay::hf_cand_beauty::BplusToJpsiK; + } + } else { // debug + // Printf("Checking J/Psi -> e+e-"); + if (RecoDecay::isMatchedMCGen(particlesMc, candJpsiMC, static_cast(Pdg::kJPsi), std::array{-kElectron, +kElectron}, true)) { + flag = sign * o2::hf_decay::hf_cand_beauty::BplusToJpsiK; + } + } + } + + // save information for B+ task + if (std::abs(flag) != o2::hf_decay::hf_cand_beauty::BplusToJpsiK) { + continue; + } + + auto ptParticle = particle.pt(); + auto yParticle = RecoDecay::y(particle.pVector(), MassBPlus); + auto etaParticle = particle.eta(); + + std::array ptProngs; + std::array yProngs; + std::array etaProngs; + int counter = 0; + for (const auto& daught : particle.daughters_as()) { + ptProngs[counter] = daught.pt(); + etaProngs[counter] = daught.eta(); + yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); + counter++; + } + rowHfBpMcGenReduced(flag, channel, ptParticle, yParticle, etaParticle, + ptProngs[0], yProngs[0], etaProngs[0], + ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M); + } else if constexpr (decChannel == DecayChannel::BsToJpsiPhi) { + // Bs → J/Psi phi → (µ+µ-) (K+K-) + if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kBS, std::array{static_cast(Pdg::kJPsi), +kKPlus, -kKPlus}, true, &sign, 2)) { + // Match J/Psi -> µ+µ- and phi -> K+K- + auto candJpsiMC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); + auto candPhiMC = particlesMc.rawIteratorAt(particle.daughtersIds().back()); + // Printf("Checking J/Psi -> µ+µ- and phi -> K+K-"); + if (runJpsiToee && RecoDecay::isMatchedMCGen(particlesMc, candJpsiMC, static_cast(Pdg::kJPsi), std::array{-kElectron, +kElectron}, true)) { + flag = sign * o2::hf_decay::hf_cand_beauty::BsToJpsiKK; + } else if (!runJpsiToee && RecoDecay::isMatchedMCGen(particlesMc, candJpsiMC, static_cast(Pdg::kJPsi), std::array{-kMuonMinus, +kMuonMinus}, true)) { + flag = sign * o2::hf_decay::hf_cand_beauty::BsToJpsiKK; + } + // Check phi -> K+K- + if (RecoDecay::isMatchedMCGen(particlesMc, candPhiMC, static_cast(Pdg::kPhi), std::array{-kKPlus, +kKPlus}, true)) { + channel = o2::hf_decay::hf_cand_beauty::BsToJpsiPhi; + } + } + + // save information for Bs task + if (std::abs(flag) != o2::hf_decay::hf_cand_beauty::BsToJpsiKK) { + continue; + } + + auto ptParticle = particle.pt(); + auto yParticle = RecoDecay::y(particle.pVector(), MassBPlus); + auto etaParticle = particle.eta(); + + std::array ptProngs; + std::array yProngs; + std::array etaProngs; + int counter = 0; + for (const auto& daught : particle.daughters_as()) { + ptProngs[counter] = daught.pt(); + etaProngs[counter] = daught.eta(); + yProngs[counter] = RecoDecay::y(daught.pVector(), pdg->Mass(daught.pdgCode())); + counter++; + } + rowHfBsMcGenReduced(flag, channel, ptParticle, yParticle, etaParticle, + ptProngs[0], yProngs[0], etaProngs[0], + ptProngs[1], yProngs[1], etaProngs[1], hfRejMap, centFT0C, centFT0M); + } + } // gen + } + + // Jpsi candidate selection + template + void runDataCreation(Coll const& collision, + JpsiCands const& candsJpsi, + aod::TrackAssoc const& trackIndices, + TTracks const&, + PParticles const& particlesMc, + uint64_t const& indexCollisionMaxNumContrib, + BBCs const&) + { + + registry.fill(HIST("hEvents"), 1 + Event::Processed); + float centrality = -1.f; + auto hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + if (skipRejectedCollisions && hfRejMap != 0) { + return; + } + + // helpers for ReducedTables filling + int indexHfReducedCollision = hfReducedCollision.lastIndex() + 1; + // std::map where the key is the track.globalIndex() and + // the value is the track index in the table of the selected tracks + std::map selectedTracksBach; + std::map selectedTracksBach2; // for the second daughter (for B0 and Bs) + + bool fillHfReducedCollision = false; + + auto primaryVertex = getPrimaryVertex(collision); + + // Set the magnetic field from ccdb. + // The static instance of the propagator was already modified in the HFTrackIndexSkimCreator, + // but this is not true when running on Run2 data/MC already converted into AO2Ds. + auto bc = collision.template bc_as(); + if (runNumber != bc.runNumber()) { + LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(ccdbPathGrpMag, bc.timestamp()); + if (grpo == nullptr) { + LOGF(fatal, "Run 3 GRP object (type o2::parameters::GRPMagField) is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp()); + } + o2::base::Propagator::initFieldFromGRP(grpo); + bz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << ">>>>>>>>>>>> Magnetic field: " << bz; + runNumber = bc.runNumber(); + } + df2.setBz(bz); + df3.setBz(bz); + df4.setBz(bz); + + auto thisCollId = collision.globalIndex(); + // looping over 2-prong candidates + for (const auto& candidate : candsJpsi) { + + // Apply the selections on the J/Psi candidates + registry.fill(HIST("hSelectionsJpsi"), 1, candidate.pt()); + + if (!(candidate.hfflag() & (1 << (runJpsiToee ? aod::hf_cand_2prong::DecayType::JpsiToEE : aod::hf_cand_2prong::DecayType::JpsiToMuMu)))) { + continue; + } + registry.fill(HIST("hSelectionsJpsi"), 2 + aod::SelectionStep::RecoSkims, candidate.pt()); + + auto trackPos = candidate.template prong0_as(); // positive daughter + auto trackNeg = candidate.template prong1_as(); // negative daughter + + auto trackPosParCov = getTrackParCov(trackPos); + auto trackNegParCov = getTrackParCov(trackNeg); + + std::vector jPsiDauTracks{trackPos, trackNeg}; + + auto dca0 = o2::dataformats::DCA(jPsiDauTracks[0].dcaXY(), jPsiDauTracks[0].dcaZ(), jPsiDauTracks[0].cYY(), jPsiDauTracks[0].cZY(), jPsiDauTracks[0].cZZ()); + auto dca1 = o2::dataformats::DCA(jPsiDauTracks[1].dcaXY(), jPsiDauTracks[1].dcaZ(), jPsiDauTracks[1].cYY(), jPsiDauTracks[1].cZY(), jPsiDauTracks[1].cZZ()); + + // repropagate tracks to this collision if needed + if (jPsiDauTracks[0].collisionId() != thisCollId) { + trackPosParCov.propagateToDCA(primaryVertex, bz, &dca0); + } + + if (jPsiDauTracks[1].collisionId() != thisCollId) { + trackNegParCov.propagateToDCA(primaryVertex, bz, &dca1); + } + + // --------------------------------- + // reconstruct J/Psi candidate secondary vertex + o2::track::TrackParCov trackParCovJpsi{}; + std::array pVecJpsi{}; + registry.fill(HIST("hFitCandidatesJpsi"), SVFitting::BeforeFit); + try { + if (df2.process(trackPosParCov, trackNegParCov) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + registry.fill(HIST("hFitCandidatesJpsi"), SVFitting::Fail); + continue; + } + registry.fill(HIST("hFitCandidatesJpsi"), SVFitting::FitOk); + + // topological selection + if (!selectionTopol(candidate, trackPos, trackNeg)) { + continue; + } + registry.fill(HIST("hSelectionsJpsi"), 2 + aod::SelectionStep::RecoTopol, candidate.pt()); + + // PID selection + if (!isSelectedJpsiDauPid(trackPos) || !isSelectedJpsiDauPid(trackNeg)) { + continue; + } + registry.fill(HIST("hSelectionsJpsi"), 2 + aod::SelectionStep::RecoPID, candidate.pt()); + + int indexHfCandJpsi = hfJpsi.lastIndex() + 1; + float invMassJpsi = runJpsiToee ? hfHelper.invMassJpsiToEE(candidate) : hfHelper.invMassJpsiToMuMu(candidate); + registry.fill(HIST("hMassJpsi"), invMassJpsi); + registry.fill(HIST("hPtJpsi"), candidate.pt()); + registry.fill(HIST("hCpaJpsi"), candidate.cpa()); + + bool fillHfCandJpsi = false; + + // TODO: add single track information (min eta, min ITS/TPC clusters, etc.) + double invMass2JpsiHad{0.}; + for (const auto& trackId : trackIndices) { + auto trackBach = trackId.template track_as(); + + // apply selections on bachelor tracks + auto trackParCovBach = getTrackParCov(trackBach); + std::array dcaBach{trackBach.dcaXY(), trackBach.dcaZ()}; + std::array pVecBach = trackBach.pVector(); + if (trackBach.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovBach, 2.f, noMatCorr, &dcaBach); + getPxPyPz(trackParCovBach, pVecBach); + } + + // apply selections on bachelor tracks + if (!isTrackSelected(trackBach, trackParCovBach, dcaBach, jPsiDauTracks)) { + continue; + } + + if constexpr (decChannel == DecayChannel::BplusToJpsiK) { + registry.fill(HIST("hPtKaon"), trackParCovBach.getPt()); + // compute invariant mass square and apply selection + invMass2JpsiHad = RecoDecay::m2(std::array{pVecJpsi, pVecBach}, std::array{MassJPsi, MassKPlus}); + if ((invMass2JpsiHad < invMass2JpsiHadMin) || (invMass2JpsiHad > invMass2JpsiHadMax)) { + continue; + } + registry.fill(HIST("hMassJpsiKaon"), std::sqrt(invMass2JpsiHad)); + + registry.fill(HIST("hFitCandidatesBPlus"), SVFitting::BeforeFit); + try { + if (df3.process(trackPosParCov, trackNegParCov, trackParCovBach) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + registry.fill(HIST("hFitCandidatesBPlus"), SVFitting::Fail); + continue; + } + registry.fill(HIST("hFitCandidatesBPlus"), SVFitting::FitOk); + + o2::track::TrackParCov trackParCovBPlus{}; + std::array pVecBPlus{}, pVec0{}, pVec1{}, pVec2{}; + + auto secondaryVertexBPlus = df3.getPCACandidate(); + df3.propagateTracksToVertex(); + df3.getTrack(0).getPxPyPzGlo(pVec0); + df3.getTrack(1).getPxPyPzGlo(pVec1); + df3.getTrack(2).getPxPyPzGlo(pVec2); + pVecBPlus = RecoDecay::pVec(pVec0, pVec1, pVec2); + trackParCovBPlus = df3.createParentTrackParCov(); + trackParCovBPlus.setAbsCharge(0); // to be sure + + if (!isBSelected(pVecBPlus, secondaryVertexBPlus, collision)) { + continue; + } + + // fill Kaon tracks table + // if information on track already stored, go to next track + if (!selectedTracksBach.count(trackBach.globalIndex())) { + hfTrackLfDau0(trackBach.globalIndex(), indexHfReducedCollision, + trackParCovBach.getX(), trackParCovBach.getAlpha(), + trackParCovBach.getY(), trackParCovBach.getZ(), trackParCovBach.getSnp(), + trackParCovBach.getTgl(), trackParCovBach.getQ2Pt(), + trackBach.itsNCls(), trackBach.tpcNClsCrossedRows(), trackBach.tpcChi2NCl(), trackBach.itsChi2NCl(), + trackBach.hasTPC(), trackBach.hasTOF(), + trackBach.tpcNSigmaPi(), trackBach.tofNSigmaPi(), + trackBach.tpcNSigmaKa(), trackBach.tofNSigmaKa(), + trackBach.tpcNSigmaPr(), trackBach.tofNSigmaPr()); + hfTrackCovLfDau0(trackParCovBach.getSigmaY2(), trackParCovBach.getSigmaZY(), trackParCovBach.getSigmaZ2(), + trackParCovBach.getSigmaSnpY(), trackParCovBach.getSigmaSnpZ(), + trackParCovBach.getSigmaSnp2(), trackParCovBach.getSigmaTglY(), trackParCovBach.getSigmaTglZ(), + trackParCovBach.getSigmaTglSnp(), trackParCovBach.getSigmaTgl2(), + trackParCovBach.getSigma1PtY(), trackParCovBach.getSigma1PtZ(), trackParCovBach.getSigma1PtSnp(), + trackParCovBach.getSigma1PtTgl(), trackParCovBach.getSigma1Pt2()); + // add trackBach.globalIndex() to a list + // to keep memory of the pions filled in the table and avoid refilling them if they are paired to another Jpsi candidate + // and keep track of their index in hfTrackLfDau0 for McRec purposes + selectedTracksBach[trackBach.globalIndex()] = hfTrackLfDau0.lastIndex(); + } + + if constexpr (doMc) { + std::vector beautyHadDauTracks{}; + for (const auto& track : jPsiDauTracks) { + beautyHadDauTracks.push_back(track); + } + beautyHadDauTracks.push_back(trackBach); + fillMcRecoInfo(collision, particlesMc, beautyHadDauTracks, indexHfCandJpsi, std::array, 2>{selectedTracksBach}, indexCollisionMaxNumContrib); + } + fillHfCandJpsi = true; + } else if constexpr (decChannel == DecayChannel::BsToJpsiPhi) { + for (auto trackBachId2 = trackId + 1; trackBachId2 != trackIndices.end(); ++trackBachId2) { + auto trackBach2 = trackBachId2.template track_as(); + auto trackBach2ParCov = getTrackParCov(trackBach2); + + std::array dcaBach2{trackBach2.dcaXY(), trackBach2.dcaZ()}; + std::array pVecBach2 = trackBach2.pVector(); + if (trackBach2.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackBach2ParCov, 2.f, noMatCorr, &dcaBach2); + getPxPyPz(trackBach2ParCov, pVecBach2); + } + + // apply selections on bachelor tracks + if (!isTrackSelected(trackBach2, trackBach2ParCov, dcaBach2, jPsiDauTracks)) { + continue; + } + std::array pVec2{trackBach.pVector()}, pVec3{trackBach2.pVector()}; + auto invMassPhi = RecoDecay::m(std::array{pVec2, pVec3}, std::array{MassKPlus, MassKPlus}); + + if (std::abs(invMassPhi - MassPhi) > deltaMPhiMax) { + continue; + } + + // --------------------------------- + // reconstruct Bs candidate secondary vertex + + registry.fill(HIST("hFitCandidatesBS"), SVFitting::BeforeFit); + try { + if (df4.process(trackPosParCov, trackNegParCov, trackParCovBach, trackBach2ParCov) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + registry.fill(HIST("hFitCandidatesBS"), SVFitting::Fail); + continue; + } + registry.fill(HIST("hFitCandidatesBS"), SVFitting::FitOk); + + o2::track::TrackParCov trackParCovBS{}; + std::array pVecBS{}, pVec0{}, pVec1{}, pVecPhi{}; + + auto secondaryVertexBS = df4.getPCACandidate(); + df4.propagateTracksToVertex(); + df4.getTrack(0).getPxPyPzGlo(pVec0); + df4.getTrack(1).getPxPyPzGlo(pVec1); + df4.getTrack(2).getPxPyPzGlo(pVec2); + df4.getTrack(3).getPxPyPzGlo(pVec3); + pVecBS = RecoDecay::pVec(pVec0, pVec1, pVec2, pVec3); + pVecPhi = RecoDecay::pVec(pVec2, pVec3); + trackParCovBS = df4.createParentTrackParCov(); + trackParCovBS.setAbsCharge(0); // to be sure + + if (!isBSelected(pVecBS, secondaryVertexBS, collision)) { + continue; + } + + registry.fill(HIST("hPtPhi"), RecoDecay::pt(pVecBach, pVecBach2)); + registry.fill(HIST("hMassPhi"), RecoDecay::m(std::array{pVecBach, pVecBach2}, std::array{MassKPlus, MassKPlus})); + invMass2JpsiHad = RecoDecay::m2(std::array{pVecJpsi, pVecPhi}, std::array{MassJPsi, MassPhi}); + if ((invMass2JpsiHad < invMass2JpsiHadMin) || (invMass2JpsiHad > invMass2JpsiHadMax)) { + continue; + } + registry.fill(HIST("hMassJpsiPhi"), std::sqrt(invMass2JpsiHad)); + + // fill daughter tracks table + // if information on track already stored, go to next track + if (!selectedTracksBach.count(trackBach.globalIndex())) { + hfTrackLfDau0(trackBach.globalIndex(), indexHfReducedCollision, + trackParCovBach.getX(), trackParCovBach.getAlpha(), + trackParCovBach.getY(), trackParCovBach.getZ(), trackParCovBach.getSnp(), + trackParCovBach.getTgl(), trackParCovBach.getQ2Pt(), + trackBach.itsNCls(), trackBach.tpcNClsCrossedRows(), trackBach.tpcChi2NCl(), trackBach.itsChi2NCl(), + trackBach.hasTPC(), trackBach.hasTOF(), + trackBach.tpcNSigmaPi(), trackBach.tofNSigmaPi(), + trackBach.tpcNSigmaKa(), trackBach.tofNSigmaKa(), + trackBach.tpcNSigmaPr(), trackBach.tofNSigmaPr()); + hfTrackCovLfDau0(trackParCovBach.getSigmaY2(), trackParCovBach.getSigmaZY(), trackParCovBach.getSigmaZ2(), + trackParCovBach.getSigmaSnpY(), trackParCovBach.getSigmaSnpZ(), + trackParCovBach.getSigmaSnp2(), trackParCovBach.getSigmaTglY(), trackParCovBach.getSigmaTglZ(), + trackParCovBach.getSigmaTglSnp(), trackParCovBach.getSigmaTgl2(), + trackParCovBach.getSigma1PtY(), trackParCovBach.getSigma1PtZ(), trackParCovBach.getSigma1PtSnp(), + trackParCovBach.getSigma1PtTgl(), trackParCovBach.getSigma1Pt2()); + // add trackBach.globalIndex() to a list + // to keep memory of the pions filled in the table and avoid refilling them if they are paired to another Jpsi candidate + // and keep track of their index in hfTrackLfDau0 for McRec purposes + selectedTracksBach[trackBach.globalIndex()] = hfTrackLfDau0.lastIndex(); + } + + // fill daughter tracks table + // if information on track already stored, go to next track + if (!selectedTracksBach2.count(trackBach2.globalIndex())) { + hfTrackLfDau1(trackBach2.globalIndex(), indexHfReducedCollision, + trackBach2ParCov.getX(), trackBach2ParCov.getAlpha(), + trackBach2ParCov.getY(), trackBach2ParCov.getZ(), trackBach2ParCov.getSnp(), + trackBach2ParCov.getTgl(), trackBach2ParCov.getQ2Pt(), + trackBach2.itsNCls(), trackBach2.tpcNClsCrossedRows(), trackBach2.tpcChi2NCl(), trackBach2.itsChi2NCl(), + trackBach2.hasTPC(), trackBach2.hasTOF(), + trackBach2.tpcNSigmaPi(), trackBach2.tofNSigmaPi(), + trackBach2.tpcNSigmaKa(), trackBach2.tofNSigmaKa(), + trackBach2.tpcNSigmaPr(), trackBach2.tofNSigmaPr()); + hfTrackCovLfDau1(trackBach2ParCov.getSigmaY2(), trackBach2ParCov.getSigmaZY(), trackBach2ParCov.getSigmaZ2(), + trackBach2ParCov.getSigmaSnpY(), trackBach2ParCov.getSigmaSnpZ(), + trackBach2ParCov.getSigmaSnp2(), trackBach2ParCov.getSigmaTglY(), trackBach2ParCov.getSigmaTglZ(), + trackBach2ParCov.getSigmaTglSnp(), trackBach2ParCov.getSigmaTgl2(), + trackBach2ParCov.getSigma1PtY(), trackBach2ParCov.getSigma1PtZ(), trackBach2ParCov.getSigma1PtSnp(), + trackBach2ParCov.getSigma1PtTgl(), trackBach2ParCov.getSigma1Pt2()); + // add trackBach2.globalIndex() to a list + // to keep memory of the pions filled in the table and avoid refilling them if they are paired to another Jpsi candidate + // and keep track of their index in hfTrackLfDau1 for McRec purposes + selectedTracksBach2[trackBach2.globalIndex()] = hfTrackLfDau1.lastIndex(); + } + + if constexpr (doMc) { + std::vector beautyHadDauTracks{}; + for (const auto& track : jPsiDauTracks) { + beautyHadDauTracks.push_back(track); + } + beautyHadDauTracks.push_back(trackBach); + fillMcRecoInfo(collision, particlesMc, beautyHadDauTracks, indexHfCandJpsi, std::array, 2>{selectedTracksBach, selectedTracksBach2}, indexCollisionMaxNumContrib); + } + fillHfCandJpsi = true; + } + } + } // kaon loop + if (fillHfCandJpsi) { // fill Jpsi table only once per Jpsi candidate + double invMassJpsi{0.}; + if (runJpsiToee) { + invMassJpsi = hfHelper.invMassJpsiToEE(candidate); + } else { + invMassJpsi = hfHelper.invMassJpsiToMuMu(candidate); + } + hfJpsi(trackPos.globalIndex(), trackNeg.globalIndex(), + indexHfReducedCollision, + candidate.xSecondaryVertex(), candidate.ySecondaryVertex(), candidate.zSecondaryVertex(), + invMassJpsi, + trackPos.itsNCls(), trackPos.tpcNClsCrossedRows(), trackPos.tpcChi2NCl(), trackPos.itsChi2NCl(), + trackNeg.itsNCls(), trackNeg.tpcNClsCrossedRows(), trackNeg.tpcChi2NCl(), trackNeg.itsChi2NCl(), + trackPosParCov.getX(), trackNegParCov.getX(), + trackPosParCov.getY(), trackNegParCov.getY(), + trackPosParCov.getZ(), trackNegParCov.getZ(), + trackPosParCov.getAlpha(), trackNegParCov.getAlpha(), + trackPosParCov.getSnp(), trackNegParCov.getSnp(), + trackPosParCov.getTgl(), trackNegParCov.getTgl(), + trackPosParCov.getQ2Pt(), trackNegParCov.getQ2Pt()); // Q/pT + hfRedJpsiCov(trackPosParCov.getSigmaY2(), trackNegParCov.getSigmaY2(), + trackPosParCov.getSigmaZY(), trackNegParCov.getSigmaZY(), + trackPosParCov.getSigmaZ2(), trackNegParCov.getSigmaZ2(), + trackPosParCov.getSigmaSnpY(), trackNegParCov.getSigmaSnpY(), + trackPosParCov.getSigmaSnpZ(), trackNegParCov.getSigmaSnpZ(), + trackPosParCov.getSigmaSnp2(), trackNegParCov.getSigmaSnp2(), + trackPosParCov.getSigmaTglY(), trackNegParCov.getSigmaTglY(), + trackPosParCov.getSigmaTglZ(), trackNegParCov.getSigmaTglZ(), + trackPosParCov.getSigmaTglSnp(), trackNegParCov.getSigmaTglSnp(), + trackPosParCov.getSigmaTgl2(), trackNegParCov.getSigmaTgl2(), + trackPosParCov.getSigma1PtY(), trackNegParCov.getSigma1PtY(), + trackPosParCov.getSigma1PtZ(), trackNegParCov.getSigma1PtZ(), + trackPosParCov.getSigma1PtSnp(), trackNegParCov.getSigma1PtSnp(), + trackPosParCov.getSigma1PtTgl(), trackNegParCov.getSigma1PtTgl(), + trackPosParCov.getSigma1Pt2(), trackNegParCov.getSigma1Pt2()); + fillHfReducedCollision = true; + } + } // candsJpsi loop + + if (!fillHfReducedCollision) { + registry.fill(HIST("hEvents"), 1 + Event::NoCharmHadPiSelected); + return; + } + registry.fill(HIST("hEvents"), 1 + Event::CharmHadPiSelected); + // fill collision table if it contains a J/Psi K pair at minimum + hfReducedCollision(collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), hfRejMap, bz); + hfReducedCollExtra(collision.covXX(), collision.covXY(), collision.covYY(), + collision.covXZ(), collision.covYZ(), collision.covZZ()); + // hfReducedCollCentrality(collision.centFT0C(), collision.centFT0M(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); // TODO: add + // if constexpr (withQvec) { + // hfReducedQvector(collision.qvecFT0CRe(), collision.qvecFT0CIm(), collision.sumAmplFT0C(), + // collision.qvecFT0ARe(), collision.qvecFT0AIm(), collision.sumAmplFT0A(), + // collision.qvecFT0MRe(), collision.qvecFT0MIm(), collision.sumAmplFT0M(), + // collision.qvecTPCposRe(), collision.qvecTPCposIm(), collision.nTrkTPCpos(), + // collision.qvecTPCnegRe(), collision.qvecTPCnegIm(), collision.nTrkTPCneg(), + // collision.qvecTPCallRe(), collision.qvecTPCallIm(), collision.nTrkTPCall()); + // } + } + + void processJpsiKData(soa::Join const& collisions, + aod::HfCand2ProngWPid const& candsJpsi, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + rowCandidateConfigBplus(invMassWindowJpsiHad.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsJpsiThisColl = candsJpsi.sliceBy(candsJpsiPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsJpsiThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorJpsiHadReduced, processJpsiKData, "Process J/Psi K without MC info", true); + + void processJpsiPhiData(soa::Join const& collisions, + aod::HfCand2ProngWPid const& candsJpsi, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for B0 workflow + if (!isHfCandBhadConfigFilled) { + rowCandidateConfigBs(invMassWindowJpsiHad.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsJpsiThisColl = candsJpsi.sliceBy(candsJpsiPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + runDataCreation(collision, candsJpsiThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + } + PROCESS_SWITCH(HfDataCreatorJpsiHadReduced, processJpsiPhiData, "Process J/Psi phi without MC info", false); + + void processJpsiKMc(CollisionsWCMcLabels const& collisions, + aod::HfCand2ProngWPid const& candsJpsi, + aod::TrackAssoc const& trackIndices, + TracksPidWithSelAndMc const& tracks, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisions const& mcCollisions) + { + // store configurables needed for B+ workflow + if (!isHfCandBhadConfigFilled) { + rowCandidateConfigBplus(invMassWindowJpsiHad.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsJpsiThisColl = candsJpsi.sliceBy(candsJpsiPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsJpsiThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } + } + PROCESS_SWITCH(HfDataCreatorJpsiHadReduced, processJpsiKMc, "Process J/Psi K with MC info", false); + + void processJpsiPhiMc(CollisionsWCMcLabels const& collisions, + aod::HfCand2ProngWPid const& candsJpsi, + aod::TrackAssoc const& trackIndices, + TracksPidWithSelAndMc const& tracks, + aod::McParticles const& particlesMc, + BCsInfo const& bcs, + McCollisions const& mcCollisions) + { + // store configurables needed for B+ workflow + if (!isHfCandBhadConfigFilled) { + rowCandidateConfigBs(invMassWindowJpsiHad.value); + isHfCandBhadConfigFilled = true; + } + + int zvtxColl{0}; + int sel8Coll{0}; + int zvtxAndSel8Coll{0}; + int zvtxAndSel8CollAndSoftTrig{0}; + int allSelColl{0}; + for (const auto& collision : collisions) { + o2::hf_evsel::checkEvSel(collision, hfEvSel, zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl, ccdb, registry); + + auto thisCollId = collision.globalIndex(); + auto candsJpsiThisColl = candsJpsi.sliceBy(candsJpsiPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsJpsiThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); + } + // handle normalization by the right number of collisions + hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); + for (const auto& mcCollision : mcCollisions) { + runMcGen(mcCollision, particlesMc, collisions, bcs); + } + } + PROCESS_SWITCH(HfDataCreatorJpsiHadReduced, processJpsiPhiMc, "Process J/Psi phi with MC info", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/Tasks/CMakeLists.txt b/PWGHF/D2H/Tasks/CMakeLists.txt index b2f78f68334..24707fb011b 100644 --- a/PWGHF/D2H/Tasks/CMakeLists.txt +++ b/PWGHF/D2H/Tasks/CMakeLists.txt @@ -29,11 +29,21 @@ o2physics_add_dpl_workflow(task-bplus-reduced PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-bplus-to-jpsi-k-reduced + SOURCES taskBplusToJpsiKReduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-bs-reduced SOURCES taskBsReduced.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-bs-to-jpsi-phi-reduced + SOURCES taskBsToJpsiPhiReduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-bs SOURCES taskBs.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -44,8 +54,13 @@ o2physics_add_dpl_workflow(task-charm-polarisation PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(task-charm-reso-reduced - SOURCES taskCharmResoReduced.cxx +o2physics_add_dpl_workflow(task-charm-reso-to-d-v0-reduced + SOURCES taskCharmResoToDV0Reduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(task-charm-reso-to-d-trk-reduced + SOURCES taskCharmResoToDTrkReduced.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -84,6 +99,11 @@ o2physics_add_dpl_workflow(task-lb PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-lb-reduced + SOURCES taskLbReduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-lc SOURCES taskLc.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -94,6 +114,11 @@ o2physics_add_dpl_workflow(task-lc-to-k0s-p PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-omegac0-to-omega-pi + SOURCES taskOmegac0ToOmegapi.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-sigmac SOURCES taskSigmac.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -118,3 +143,8 @@ o2physics_add_dpl_workflow(task-xicc SOURCES taskXicc.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(task-xic0-to-xi-pi + SOURCES taskXic0ToXiPi.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGHF/D2H/Tasks/taskB0.cxx b/PWGHF/D2H/Tasks/taskB0.cxx index 43025a47f6b..219d9dc50bb 100644 --- a/PWGHF/D2H/Tasks/taskB0.cxx +++ b/PWGHF/D2H/Tasks/taskB0.cxx @@ -14,22 +14,42 @@ /// /// \author Alexandre Bigot , IPHC Strasbourg -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_decay::hf_cand_beauty; /// B0 analysis task struct HfTaskB0 { @@ -128,15 +148,15 @@ struct HfTaskB0 { registry.add("hPtGenWithProngsInAcceptance", "MC particles (generated-daughters in acceptance);candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{300, 0., 30.}}}); if (checkDecayTypeMc) { - constexpr uint8_t kNBinsDecayTypeMc = hf_cand_b0::DecayTypeMc::NDecayTypeMc; - TString labels[kNBinsDecayTypeMc]; + constexpr uint8_t NBinsDecayTypeMc = hf_cand_b0::DecayTypeMc::NDecayTypeMc; // FIXME + TString labels[NBinsDecayTypeMc]; labels[hf_cand_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi] = "B^{0} #rightarrow (D^{#minus} #rightarrow #pi^{#minus} K^{#plus} #pi^{#minus}) #pi^{#plus}"; labels[hf_cand_b0::DecayTypeMc::B0ToDsPiToKKPiPi] = "B^{0} #rightarrow (D^{#minus}_{s} #rightarrow K^{#minus} K^{#plus} #pi^{#minus}) #pi^{#plus}"; labels[hf_cand_b0::DecayTypeMc::PartlyRecoDecay] = "Partly reconstructed decay channel"; labels[hf_cand_b0::DecayTypeMc::OtherDecay] = "Other decays"; - static const AxisSpec axisDecayType = {kNBinsDecayTypeMc, 0.5, kNBinsDecayTypeMc + 0.5, ""}; + static const AxisSpec axisDecayType = {NBinsDecayTypeMc, 0.5, NBinsDecayTypeMc + 0.5, ""}; registry.add("hDecayTypeMc", "DecayType", {HistType::kTH3F, {axisDecayType, axisMassB0, axisPt}}); - for (uint8_t iBin = 0; iBin < kNBinsDecayTypeMc; ++iBin) { + for (uint8_t iBin = 0; iBin < NBinsDecayTypeMc; ++iBin) { registry.get(HIST("hDecayTypeMc"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin]); } } @@ -184,7 +204,7 @@ struct HfTaskB0 { registry.fill(HIST("hDecLenXYErr"), candidate.errorDecayLengthXY(), ptCandB0); registry.fill(HIST("hInvMassD"), hfHelper.invMassDplusToPiKPi(candD), ptCandB0); } // candidate loop - } // process + } // process /// B0 MC analysis and fill histograms void processMc(soa::Filtered> const& candidates, @@ -201,9 +221,9 @@ struct HfTaskB0 { auto ptCandB0 = candidate.pt(); auto candD = candidate.prong0_as>(); auto invMassCandB0 = hfHelper.invMassB0ToDPi(candidate); - int flagMcMatchRecB0 = std::abs(candidate.flagMcMatchRec()); + auto flagMcMatchRecB0 = std::abs(candidate.flagMcMatchRec()); - if (TESTBIT(flagMcMatchRecB0, hf_cand_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi)) { + if (flagMcMatchRecB0 == DecayChannelMain::B0ToDminusPi) { auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong1_as().mcParticle_as>(), o2::constants::physics::Pdg::kB0, true); auto particleMother = mcParticles.rawIteratorAt(indexMother); @@ -249,9 +269,9 @@ struct HfTaskB0 { registry.fill(HIST("hChi2PCARecBg"), candidate.chi2PCA(), ptCandB0); if (checkDecayTypeMc) { - if (TESTBIT(flagMcMatchRecB0, hf_cand_b0::DecayTypeMc::B0ToDsPiToKKPiPi)) { // B0 → Ds- π+ → (K- K+ π-) π+ + if (flagMcMatchRecB0 == DecayChannelMain::B0ToDsPi) { // B0 → Ds- π+ → (K- K+ π-) π+ registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_b0::DecayTypeMc::B0ToDsPiToKKPiPi, invMassCandB0, ptCandB0); - } else if (TESTBIT(flagMcMatchRecB0, hf_cand_b0::DecayTypeMc::PartlyRecoDecay)) { // Partly reconstructed decay channel + } else if (flagMcMatchRecB0 == hf_cand_b0::DecayTypeMc::PartlyRecoDecay) { // FIXME, Partly reconstructed decay channel registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_b0::DecayTypeMc::PartlyRecoDecay, invMassCandB0, ptCandB0); } else { registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_b0::DecayTypeMc::OtherDecay, invMassCandB0, ptCandB0); @@ -262,7 +282,7 @@ struct HfTaskB0 { // MC gen. level for (const auto& particle : mcParticles) { - if (TESTBIT(std::abs(particle.flagMcMatchGen()), hf_cand_b0::DecayType::B0ToDPi)) { + if (std::abs(particle.flagMcMatchGen()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::B0ToDminusPi) { auto ptParticle = particle.pt(); auto yParticle = RecoDecay::y(particle.pVector(), o2::constants::physics::MassB0); @@ -306,7 +326,7 @@ struct HfTaskB0 { registry.fill(HIST("hEtaGenWithProngsInAcceptance"), particle.eta(), ptParticle); } } // gen - } // process + } // process PROCESS_SWITCH(HfTaskB0, processMc, "Process MC", false); }; // struct diff --git a/PWGHF/D2H/Tasks/taskB0Reduced.cxx b/PWGHF/D2H/Tasks/taskB0Reduced.cxx index d3f81aac980..e1e30490f18 100644 --- a/PWGHF/D2H/Tasks/taskB0Reduced.cxx +++ b/PWGHF/D2H/Tasks/taskB0Reduced.cxx @@ -15,16 +15,31 @@ /// \author Alexandre Bigot , IPHC Strasbourg /// \author Fabrizio Grosa , CERN -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Common/Core/RecoDecay.h" - #include "PWGHF/Core/HfHelper.h" -#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -42,8 +57,8 @@ DECLARE_SOA_COLUMN(AbsEtaBach, absEtaBach, float); DECLARE_SOA_COLUMN(ItsNClsBach, itsNClsBach, int); //! Number of ITS clusters of bachelor pion DECLARE_SOA_COLUMN(TpcNClsCrossedRowsBach, tpcNClsCrossedRowsBach, int); //! Number of TPC crossed rows of prongs of bachelor pion DECLARE_SOA_COLUMN(TpcChi2NClBach, tpcChi2NClBach, float); //! Maximum TPC chi2 of prongs of D-meson daughter candidate -DECLARE_SOA_COLUMN(PtDmesProngMin, ptProngDmesMin, float); //! Minimum pT of prongs of D-meson daughter candidate (GeV/c) -DECLARE_SOA_COLUMN(AbsEtaDmesProngMin, absEtaProngDmesMin, float); //! Minimum absolute pseudorapidity of prongs of D-meson daughter candidate +DECLARE_SOA_COLUMN(PtDmesProngMin, ptDmesProngMin, float); //! Minimum pT of prongs of D-meson daughter candidate (GeV/c) +DECLARE_SOA_COLUMN(AbsEtaDmesProngMin, absEtaDmesProngMin, float); //! Minimum absolute pseudorapidity of prongs of D-meson daughter candidate DECLARE_SOA_COLUMN(ItsNClsDmesProngMin, itsNClsDmesProngMin, int); //! Minimum number of ITS clusters of prongs of D-meson daughter candidate DECLARE_SOA_COLUMN(TpcNClsCrossedRowsDmesProngMin, tpcNClsCrossedRowsDmesProngMin, int); //! Minimum number of TPC crossed rows of prongs of D-meson daughter candidate DECLARE_SOA_COLUMN(TpcChi2NClDmesProngMax, tpcChi2NClDmesProngMax, float); //! Maximum TPC chi2 of prongs of D-meson daughter candidate @@ -176,13 +191,13 @@ struct HfTaskB0Reduced { HfHelper hfHelper; + using TracksPion = soa::Join; + using CandsDplus = soa::Join; + Filter filterSelectCandidates = (aod::hf_sel_candidate_b0::isSelB0ToDPi >= selectionFlagB0); HistogramRegistry registry{"registry"}; - using TracksPion = soa::Join; - using CandsDplus = soa::Join; - void init(InitContext&) { std::array processFuncData{doprocessData, doprocessDataWithDmesMl, doprocessDataWithB0Ml}; @@ -310,6 +325,8 @@ struct HfTaskB0Reduced { TString labels[kNBinsDecayTypeMc]; labels[hf_cand_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi] = "B^{0} #rightarrow (D^{#minus} #rightarrow #pi^{#minus} K^{#plus} #pi^{#minus}) #pi^{#plus}"; labels[hf_cand_b0::DecayTypeMc::B0ToDsPiToKKPiPi] = "B^{0} #rightarrow (D^{#minus}_{s} #rightarrow K^{#minus} K^{#plus} #pi^{#minus}) #pi^{#plus}"; + labels[hf_cand_b0::DecayTypeMc::BsToDsPiToKKPiPi] = "B_{s}^{0} #rightarrow (D^{#minus}_{s} #rightarrow K^{#minus} K^{#plus} #pi^{#minus}) #pi^{#plus}"; + labels[hf_cand_b0::DecayTypeMc::B0ToDplusKToPiKPiK] = "B^{0} #rightarrow (D^{#minus} #rightarrow #pi^{#minus} K^{#plus} #pi^{#minus}) K^{#plus}"; labels[hf_cand_b0::DecayTypeMc::PartlyRecoDecay] = "Partly reconstructed decay channel"; labels[hf_cand_b0::DecayTypeMc::OtherDecay] = "Other decays"; static const AxisSpec axisDecayType = {kNBinsDecayTypeMc, 0.5, kNBinsDecayTypeMc + 0.5, ""}; @@ -463,6 +480,10 @@ struct HfTaskB0Reduced { } else if constexpr (withDecayTypeCheck) { if (TESTBIT(flagMcMatchRec, hf_cand_b0::DecayTypeMc::B0ToDsPiToKKPiPi)) { // B0 → Ds- π+ → (K- K+ π-) π+ registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_b0::DecayTypeMc::B0ToDsPiToKKPiPi, invMassB0, ptCandB0); + } else if (TESTBIT(flagMcMatchRec, hf_cand_b0::DecayTypeMc::BsToDsPiToKKPiPi)) { // B0s → Ds- π+ → (K- K+ π-) π+ + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_b0::DecayTypeMc::BsToDsPiToKKPiPi, invMassB0, ptCandB0); + } else if (TESTBIT(flagMcMatchRec, hf_cand_b0::DecayTypeMc::B0ToDplusKToPiKPiK)) { // B0 → D- K+ → (π- K+ π-) K+ + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_b0::DecayTypeMc::B0ToDplusKToPiKPiK, invMassB0, ptCandB0); } else if (TESTBIT(flagMcMatchRec, hf_cand_b0::DecayTypeMc::PartlyRecoDecay)) { // Partly reconstructed decay channel registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_b0::DecayTypeMc::PartlyRecoDecay, invMassB0, ptCandB0); } else { @@ -500,7 +521,7 @@ struct HfTaskB0Reduced { } } if (fillSparses) { - if constexpr (withDmesMl) { + if constexpr (doMc) { if (isSignal) { if constexpr (withDmesMl) { registry.fill(HIST("hMassPtCutVarsRecSig"), invMassB0, ptCandB0, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassD, ptD, candidate.prong0MlScoreBkg(), candidate.prong0MlScoreNonprompt()); diff --git a/PWGHF/D2H/Tasks/taskBplus.cxx b/PWGHF/D2H/Tasks/taskBplus.cxx index b98a2930258..9b619329d25 100644 --- a/PWGHF/D2H/Tasks/taskBplus.cxx +++ b/PWGHF/D2H/Tasks/taskBplus.cxx @@ -18,24 +18,38 @@ /// \author Antonio Palasciano , Università degli Studi di Bari & INFN, Sezione di Bari /// \author Deepa Thomas , UT Austin -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + using namespace o2; using namespace o2::aod; using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_decay::hf_cand_beauty; // string definitions, used for histogram axis labels const TString stringPt = "#it{p}_{T} (GeV/#it{c})"; @@ -198,7 +212,7 @@ struct HfTaskBplus { registry.fill(HIST("hCPAFinerBinning"), candidate.cpa(), ptCandBplus); registry.fill(HIST("hCPAxyFinerBinning"), candidate.cpaXY(), ptCandBplus); } // candidate loop - } // process + } // process void processMc(soa::Join const&, soa::Join const& mcParticles, @@ -212,7 +226,7 @@ struct HfTaskBplus { } auto ptCandBplus = candidate.pt(); // auto candD0 = candidate.prong0_as(); - if (TESTBIT(std::abs(candidate.flagMcMatchRec()), hf_cand_bplus::DecayType::BplusToD0Pi)) { + if (std::abs(candidate.flagMcMatchRec()) == DecayChannelMain::BplusToD0Pi) { auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong1_as().mcParticle_as>(), o2::constants::physics::Pdg::kBPlus, true); auto particleMother = mcParticles.rawIteratorAt(indexMother); @@ -255,7 +269,7 @@ struct HfTaskBplus { // MC gen. level for (const auto& particle : mcParticles) { - if (TESTBIT(std::abs(particle.flagMcMatchGen()), hf_cand_bplus::DecayType::BplusToD0Pi)) { + if (std::abs(particle.flagMcMatchGen()) == DecayChannelMain::BplusToD0Pi) { auto ptParticle = particle.pt(); auto yParticle = RecoDecay::y(particle.pVector(), o2::constants::physics::MassBPlus); @@ -299,7 +313,7 @@ struct HfTaskBplus { registry.fill(HIST("hEtaGenWithProngsInAcceptance"), particle.eta(), ptParticle); } } // gen - } // processMc + } // processMc PROCESS_SWITCH(HfTaskBplus, processMc, "Process MC", false); }; diff --git a/PWGHF/D2H/Tasks/taskBplusReduced.cxx b/PWGHF/D2H/Tasks/taskBplusReduced.cxx index 13544d2c369..e7a9a8f93db 100644 --- a/PWGHF/D2H/Tasks/taskBplusReduced.cxx +++ b/PWGHF/D2H/Tasks/taskBplusReduced.cxx @@ -14,18 +14,33 @@ /// /// \author Antonio Palasciano , Università degli Studi di Bari & INFN, Sezione di Bari -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Common/Core/RecoDecay.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -43,8 +58,8 @@ DECLARE_SOA_COLUMN(AbsEtaBach, absEtaBach, float); DECLARE_SOA_COLUMN(ItsNClsBach, itsNClsBach, int); //! Number of ITS clusters of bachelor pion DECLARE_SOA_COLUMN(TpcNClsCrossedRowsBach, tpcNClsCrossedRowsBach, int); //! Number of TPC crossed rows of prongs of bachelor pion DECLARE_SOA_COLUMN(TpcChi2NClBach, tpcChi2NClBach, float); //! Maximum TPC chi2 of prongs of D0-meson daughter candidate -DECLARE_SOA_COLUMN(PtDmesProngMin, ptProngDmesMin, float); //! Minimum pT of prongs of D-meson daughter candidate (GeV/c) -DECLARE_SOA_COLUMN(AbsEtaDmesProngMin, absEtaProngDmesMin, float); //! Minimum absolute pseudorapidity of prongs of D-meson daughter candidate +DECLARE_SOA_COLUMN(PtDmesProngMin, ptDmesProngMin, float); //! Minimum pT of prongs of D-meson daughter candidate (GeV/c) +DECLARE_SOA_COLUMN(AbsEtaDmesProngMin, absEtaDmesProngMin, float); //! Minimum absolute pseudorapidity of prongs of D-meson daughter candidate DECLARE_SOA_COLUMN(ItsNClsDmesProngMin, itsNClsDmesProngMin, int); //! Minimum number of ITS clusters of prongs of D-meson daughter candidate DECLARE_SOA_COLUMN(TpcNClsCrossedRowsDmesProngMin, tpcNClsCrossedRowsDmesProngMin, int); //! Minimum number of TPC crossed rows of prongs of D-meson daughter candidate DECLARE_SOA_COLUMN(TpcChi2NClDmesProngMax, tpcChi2NClDmesProngMax, float); //! Maximum TPC chi2 of prongs of D-meson daughter candidate @@ -77,6 +92,8 @@ DECLARE_SOA_COLUMN(ImpactParameterBach, impactParameterBach, float); DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float); //! Impact parameter product of daughters DECLARE_SOA_COLUMN(Cpa, cpa, float); //! Cosine pointing angle of candidate DECLARE_SOA_COLUMN(CpaXY, cpaXY, float); //! Cosine pointing angle of candidate in transverse plane +DECLARE_SOA_COLUMN(CpaD, cpaD, float); //! Cosine pointing angle of D-meson daughter candidate +DECLARE_SOA_COLUMN(CpaXYD, cpaXYD, float); //! Cosine pointing angle in transverse plane of D-meson daughter candidate DECLARE_SOA_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float); //! Maximum normalized difference between measured and expected impact parameter of candidate prongs DECLARE_SOA_COLUMN(MlScoreSig, mlScoreSig, float); //! ML score for signal class DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); //! Flag for association with wrong collision @@ -105,6 +122,8 @@ DECLARE_SOA_TABLE(HfRedCandBpLites, "AOD", "HFREDCANDBPLITE", //! Table with som hf_cand_bplus_lite::DecayLengthD, hf_cand_bplus_lite::DecayLengthXYD, hf_cand_bplus_lite::ImpactParameterD, + hf_cand_bplus_lite::CpaD, + hf_cand_bplus_lite::CpaXYD, hf_cand_bplus_lite::PtDmesProngMin, hf_cand_bplus_lite::AbsEtaDmesProngMin, hf_cand_bplus_lite::ItsNClsDmesProngMin, @@ -144,6 +163,7 @@ DECLARE_SOA_TABLE(HfRedBpMcCheck, "AOD", "HFREDBPMCCHECK", //! Table with MC dec hf_cand_bplus_lite::Pt, hf_cand_bplus_lite::MlScoreSig, hf_bplus_mc::PdgCodeBeautyMother, + hf_bplus_mc::PdgCodeCharmMother, hf_bplus_mc::PdgCodeProng0, hf_bplus_mc::PdgCodeProng1, hf_bplus_mc::PdgCodeProng2); @@ -178,13 +198,13 @@ struct HfTaskBplusReduced { HfHelper hfHelper; + using TracksPion = soa::Join; + using CandsD0 = soa::Join; + Filter filterSelectCandidates = (aod::hf_sel_candidate_bplus::isSelBplusToD0Pi >= selectionFlagBplus); HistogramRegistry registry{"registry"}; - using TracksPion = soa::Join; - using CandsD0 = soa::Join; - void init(InitContext&) { std::array processFuncData{doprocessData, doprocessDataWithDmesMl, doprocessDataWithBplusMl}; @@ -317,6 +337,7 @@ struct HfTaskBplusReduced { constexpr uint8_t kNBinsDecayTypeMc = hf_cand_bplus::DecayTypeMc::NDecayTypeMc; TString labels[kNBinsDecayTypeMc]; labels[hf_cand_bplus::DecayTypeMc::BplusToD0PiToKPiPi] = "B^{+} #rightarrow (#overline{D^{0}} #rightarrow K^{#plus} #pi^{#minus}) #pi^{#plus}"; + labels[hf_cand_bplus::DecayTypeMc::BplusToD0KToKPiK] = "B^{+} #rightarrow (#overline{D^{0}} #rightarrow K^{#plus} #pi^{#minus}) #K^{#plus}"; labels[hf_cand_bplus::DecayTypeMc::PartlyRecoDecay] = "Partly reconstructed decay channel"; labels[hf_cand_bplus::DecayTypeMc::OtherDecay] = "Other decays"; static const AxisSpec axisDecayType = {kNBinsDecayTypeMc, 0.5, kNBinsDecayTypeMc + 0.5, ""}; @@ -473,7 +494,9 @@ struct HfTaskBplusReduced { registry.fill(HIST("hMlScoreSigBplusRecBg"), ptCandBplus, candidate.mlProbBplusToD0Pi()); } } else if constexpr (withDecayTypeCheck) { - if (TESTBIT(flagMcMatchRec, hf_cand_bplus::DecayTypeMc::PartlyRecoDecay)) { // Partly reconstructed decay channel + if (TESTBIT(flagMcMatchRec, hf_cand_bplus::DecayTypeMc::BplusToD0KToKPiK)) { // Partly reconstructed decay channel + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bplus::DecayTypeMc::BplusToD0KToKPiK, invMassBplus, ptCandBplus); + } else if (TESTBIT(flagMcMatchRec, hf_cand_bplus::DecayTypeMc::PartlyRecoDecay)) { // Partly reconstructed decay channel registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bplus::DecayTypeMc::PartlyRecoDecay, invMassBplus, ptCandBplus); } else { registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bplus::DecayTypeMc::OtherDecay, invMassBplus, ptCandBplus); @@ -594,6 +617,8 @@ struct HfTaskBplusReduced { decLenD0, decLenXyD0, candidate.impactParameter0(), + cpaD0, + cpaXyD0, candD0.ptProngMin(), candD0.absEtaProngMin(), candD0.itsNClsProngMin(), @@ -634,6 +659,7 @@ struct HfTaskBplusReduced { ptCandBplus, candidateMlScoreSig, candidate.pdgCodeBeautyMother(), + candidate.pdgCodeCharmMother(), candidate.pdgCodeProng0(), candidate.pdgCodeProng1(), candidate.pdgCodeProng2()); diff --git a/PWGHF/D2H/Tasks/taskBplusToJpsiKReduced.cxx b/PWGHF/D2H/Tasks/taskBplusToJpsiKReduced.cxx new file mode 100644 index 00000000000..25bec4a1f6f --- /dev/null +++ b/PWGHF/D2H/Tasks/taskBplusToJpsiKReduced.cxx @@ -0,0 +1,563 @@ +// 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. + +/// \file taskBplusToJpsiKReduced.cxx +/// \brief B+ → Jpsi K+ → (µ+ µ-) K+ analysis task +/// +/// \author Fabrizio Chinu , Università degli Studi and INFN Torino +/// \author Fabrizio Grosa , CERN + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponseBplusToJpsiKReduced.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsPid.h" + +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::analysis; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::pid_tpc_tof_utils; + +namespace o2::aod +{ +namespace hf_cand_bplustojpsik_lite +{ +DECLARE_SOA_COLUMN(PtJpsi, ptJpsi, float); //! Transverse momentum of Jpsi daughter candidate (GeV/c) +DECLARE_SOA_COLUMN(PtBach, ptBach, float); //! Transverse momentum of bachelor kaon (GeV/c) +DECLARE_SOA_COLUMN(ItsNClsJpsiDauPos, itsNClsJpsiDauPos, int); //! Number of clusters in ITS +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsJpsiDauPos, tpcNClsCrossedRowsJpsiDauPos, int); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(ItsChi2NClJpsiDauPos, itsChi2NClJpsiDauPos, float); //! ITS chi2 / Number of clusters +DECLARE_SOA_COLUMN(TpcChi2NClJpsiDauPos, tpcChi2NClJpsiDauPos, float); //! TPC chi2 / Number of clusters +DECLARE_SOA_COLUMN(AbsEtaJpsiDauPos, absEtaJpsiDauPos, float); //! |eta| +DECLARE_SOA_COLUMN(ItsNClsJpsiDauNeg, itsNClsJpsiDauNeg, int); //! Number of clusters in ITS +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsJpsiDauNeg, tpcNClsCrossedRowsJpsiDauNeg, int); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(ItsChi2NClJpsiDauNeg, itsChi2NClJpsiDauNeg, float); //! ITS chi2 / Number of clusters +DECLARE_SOA_COLUMN(TpcChi2NClJpsiDauNeg, tpcChi2NClJpsiDauNeg, float); //! TPC chi2 / Number of clusters +DECLARE_SOA_COLUMN(AbsEtaJpsiDauNeg, absEtaJpsiDauNeg, float); //! |eta| +DECLARE_SOA_COLUMN(ItsNClsLfTrack0, itsNClsLfTrack0, int); //! Number of clusters in ITS +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsLfTrack0, tpcNClsCrossedRowsLfTrack0, int); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(ItsChi2NClLfTrack0, itsChi2NClLfTrack0, float); //! ITS chi2 / Number of clusters +DECLARE_SOA_COLUMN(TpcChi2NClLfTrack0, tpcChi2NClLfTrack0, float); //! TPC chi2 / Number of clusters +DECLARE_SOA_COLUMN(AbsEtaLfTrack0, absEtaLfTrack0, float); //! |eta| +DECLARE_SOA_COLUMN(MJpsi, mJpsi, float); //! Invariant mass of Jpsi daughter candidates (GeV/c) +DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate (GeV/c2) +DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(PtGen, ptGen, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(P, p, float); //! Momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(Y, y, float); //! Rapidity of candidate +DECLARE_SOA_COLUMN(Eta, eta, float); //! Pseudorapidity of candidate +DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuth angle of candidate +DECLARE_SOA_COLUMN(E, e, float); //! Energy of candidate (GeV) +DECLARE_SOA_COLUMN(NSigTpcKaBachelor, nSigTpcKaBachelor, float); //! TPC Nsigma separation for bachelor with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTofKaBachelor, nSigTofKaBachelor, float); //! TOF Nsigma separation for bachelor with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofKaBachelor, nSigTpcTofKaBachelor, float); //! Combined TPC and TOF Nsigma separation for bachelor with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcMuJpsiDauPos, nSigTpcMuJpsiDauPos, float); //! TPC Nsigma separation for Jpsi DauPos with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTofMuJpsiDauPos, nSigTofMuJpsiDauPos, float); //! TOF Nsigma separation for Jpsi DauPos with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofMuJpsiDauPos, nSigTpcTofMuJpsiDauPos, float); //! Combined TPC and TOF Nsigma separation for Jpsi prong0 with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcMuJpsiDauNeg, nSigTpcMuJpsiDauNeg, float); //! TPC Nsigma separation for Jpsi DauNeg with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTofMuJpsiDauNeg, nSigTofMuJpsiDauNeg, float); //! TOF Nsigma separation for Jpsi DauNeg with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofMuJpsiDauNeg, nSigTpcTofMuJpsiDauNeg, float); //! Combined TPC and TOF Nsigma separation for Jpsi prong1 with muon mass hypothesis +DECLARE_SOA_COLUMN(DecayLength, decayLength, float); //! Decay length of candidate (cm) +DECLARE_SOA_COLUMN(DecayLengthXY, decayLengthXY, float); //! Transverse decay length of candidate (cm) +DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float); //! Normalised decay length of candidate +DECLARE_SOA_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, float); //! Normalised transverse decay length of candidate +DECLARE_SOA_COLUMN(CtXY, ctXY, float); //! Pseudo-proper decay length of candidate +DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float); //! Impact parameter product of B daughters +DECLARE_SOA_COLUMN(ImpactParameterProductJpsi, impactParameterProductJpsi, float); //! Impact parameter product of Jpsi daughters +DECLARE_SOA_COLUMN(ImpactParameterJpsiDauPos, impactParameterJpsiDauPos, float); //! Impact parameter of Jpsi daughter candidate +DECLARE_SOA_COLUMN(ImpactParameterJpsiDauNeg, impactParameterJpsiDauNeg, float); //! Impact parameter of Jpsi daughter candidate +DECLARE_SOA_COLUMN(ImpactParameterLfTrack0, impactParameterLfTrack0, float); //! Impact parameter of Phi daughter candidate +DECLARE_SOA_COLUMN(Cpa, cpa, float); //! Cosine pointing angle of candidate +DECLARE_SOA_COLUMN(CpaXY, cpaXY, float); //! Cosine pointing angle of candidate in transverse plane +DECLARE_SOA_COLUMN(CpaJpsi, cpaJpsi, float); //! Cosine pointing angle of Jpsi daughter candidate +DECLARE_SOA_COLUMN(CpaXYJpsi, cpaXYJpsi, float); //! Cosine pointing angle in transverse plane of Jpsi daughter candidate +DECLARE_SOA_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float); //! Maximum normalized difference between measured and expected impact parameter of candidate prongs +DECLARE_SOA_COLUMN(MlScoreSig, mlScoreSig, float); //! ML score for signal class +DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); //! Flag for association with wrong collision +} // namespace hf_cand_bplustojpsik_lite + +DECLARE_SOA_TABLE(HfRedCandBpLites, "AOD", "HFREDCANDBPLITE", //! Table with some B+ properties + hf_cand_bplustojpsik_lite::M, + hf_cand_bplustojpsik_lite::Pt, + hf_cand_bplustojpsik_lite::Eta, + hf_cand_bplustojpsik_lite::Phi, + hf_cand_bplustojpsik_lite::Y, + hf_cand_bplustojpsik_lite::Cpa, + hf_cand_bplustojpsik_lite::CpaXY, + hf_cand::Chi2PCA, + hf_cand_bplustojpsik_lite::DecayLength, + hf_cand_bplustojpsik_lite::DecayLengthXY, + hf_cand_bplustojpsik_lite::DecayLengthNormalised, + hf_cand_bplustojpsik_lite::DecayLengthXYNormalised, + hf_cand_bplustojpsik_lite::CtXY, + hf_cand_bplustojpsik_lite::ImpactParameterProduct, + hf_cand_bplustojpsik_lite::ImpactParameterProductJpsi, + hf_cand_bplustojpsik_lite::MaxNormalisedDeltaIP, + hf_cand_bplustojpsik_lite::MlScoreSig, + // hf_sel_candidate_bplus::IsSelBplusToJpsiPi, + // Jpsi meson features + hf_cand_bplustojpsik_lite::MJpsi, + hf_cand_bplustojpsik_lite::PtJpsi, + hf_cand_bplustojpsik_lite::ImpactParameterJpsiDauPos, + hf_cand_bplustojpsik_lite::ImpactParameterJpsiDauNeg, + hf_cand_bplustojpsik_lite::ImpactParameterLfTrack0, + // Jpsi daughter features + hf_cand_bplustojpsik_lite::ItsNClsJpsiDauPos, + hf_cand_bplustojpsik_lite::TpcNClsCrossedRowsJpsiDauPos, + hf_cand_bplustojpsik_lite::ItsChi2NClJpsiDauPos, + hf_cand_bplustojpsik_lite::TpcChi2NClJpsiDauPos, + hf_cand_bplustojpsik_lite::AbsEtaJpsiDauPos, + hf_cand_bplustojpsik_lite::ItsNClsJpsiDauNeg, + hf_cand_bplustojpsik_lite::TpcNClsCrossedRowsJpsiDauNeg, + hf_cand_bplustojpsik_lite::ItsChi2NClJpsiDauNeg, + hf_cand_bplustojpsik_lite::TpcChi2NClJpsiDauNeg, + hf_cand_bplustojpsik_lite::AbsEtaJpsiDauNeg, + // kaon features + hf_cand_bplustojpsik_lite::PtBach, + hf_cand_bplustojpsik_lite::ItsNClsLfTrack0, + hf_cand_bplustojpsik_lite::TpcNClsCrossedRowsLfTrack0, + hf_cand_bplustojpsik_lite::ItsChi2NClLfTrack0, + hf_cand_bplustojpsik_lite::TpcChi2NClLfTrack0, + hf_cand_bplustojpsik_lite::AbsEtaLfTrack0, + hf_cand_bplustojpsik_lite::NSigTpcKaBachelor, + hf_cand_bplustojpsik_lite::NSigTofKaBachelor, + hf_cand_bplustojpsik_lite::NSigTpcTofKaBachelor, + // MC truth + hf_cand_bplus::FlagMcMatchRec, + hf_cand_bplus::FlagMcDecayChanRec, + hf_cand_bplus::OriginMcRec, + hf_cand_bplustojpsik_lite::FlagWrongCollision, + hf_cand_bplustojpsik_lite::PtGen); + +// DECLARE_SOA_TABLE(HfRedBpMcCheck, "AOD", "HFREDBPMCCHECK", //! Table with MC decay type check +// hf_cand_2prong::FlagMcMatchRec, +// hf_cand_bplustojpsik_lite::FlagWrongCollision, +// hf_cand_bplustojpsik_lite::MJpsi, +// hf_cand_bplustojpsik_lite::PtJpsi, +// hf_cand_bplustojpsik_lite::M, +// hf_cand_bplustojpsik_lite::Pt, +// // hf_cand_bplustojpsik_lite::MlScoreSig, +// hf_bplus_mc::PdgCodeBeautyMother, +// hf_bplus_mc::PdgCodeCharmMother, +// hf_bplus_mc::PdgCodeDauPos, +// hf_bplus_mc::PdgCodeDauNeg, +// hf_bplus_mc::PdgCodeProng2); +} // namespace o2::aod + +// string definitions, used for histogram axis labels +const TString stringPt = "#it{p}_{T} (GeV/#it{c})"; +const TString stringPtJpsi = "#it{p}_{T}(Jpsi) (GeV/#it{c});"; +const TString bPlusCandTitle = "B+ candidates;"; +const TString entries = "entries"; +const TString bPlusCandMatch = "B+ candidates (matched);"; +const TString bPlusCandUnmatch = "B+ candidates (unmatched);"; +const TString mcParticleMatched = "MC particles (matched);"; + +/// B+ analysis task +struct HfTaskBplusToJpsiKReduced { + Produces hfRedCandBpLite; + // Produces hfRedBpMcCheck; + + Configurable selectionFlagBplus{"selectionFlagBplus", 1, "Selection Flag for Bplus"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "max. track pseudo-rapidity"}; + Configurable ptTrackMin{"ptTrackMin", 0.1, "min. track transverse momentum"}; + Configurable fillBackground{"fillBackground", false, "Flag to enable filling of background histograms/sparses/tree (only MC)"}; + Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + // topological cuts + Configurable> binsPt{"binsPt", std::vector{hf_cuts_bplus_to_jpsi_k::vecBinsPt}, "pT bin limits"}; + Configurable> cuts{"cuts", {hf_cuts_bplus_to_jpsi_k::Cuts[0], hf_cuts_bplus_to_jpsi_k::NBinsPt, hf_cuts_bplus_to_jpsi_k::NCutVars, hf_cuts_bplus_to_jpsi_k::labelsPt, hf_cuts_bplus_to_jpsi_k::labelsCutVar}, "B+ candidate selection per pT bin"}; + // Enable PID + Configurable kaonPidMethod{"kaonPidMethod", PidMethod::TpcOrTof, "PID selection method for the bachelor kaon (PidMethod::NoPid: none, PidMethod::TpcOrTof: TPC or TOF, PidMethod::TpcAndTof: TPC and TOF)"}; + Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; + // TPC PID + Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; + Configurable ptPidTpcMax{"ptPidTpcMax", 20., "Upper bound of track pT for TPC PID"}; + Configurable nSigmaTpcMax{"nSigmaTpcMax", 5., "Nsigma cut on TPC only"}; + Configurable nSigmaTpcCombinedMax{"nSigmaTpcCombinedMax", 5., "Nsigma cut on TPC combined with TOF"}; + // TOF PID + Configurable ptPidTofMin{"ptPidTofMin", 0.15, "Lower bound of track pT for TOF PID"}; + Configurable ptPidTofMax{"ptPidTofMax", 20., "Upper bound of track pT for TOF PID"}; + Configurable nSigmaTofMax{"nSigmaTofMax", 5., "Nsigma cut on TOF only"}; + Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; + // B+ ML inference + Configurable> binsPtBpMl{"binsPtBpMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; + Configurable> cutDirBpMl{"cutDirBpMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsBpMl{"cutsBpMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesBpMl{"nClassesBpMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; + // CCDB configuration + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"path_ccdb/BDT_BPLUS/"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_BPLUSToJPSIK.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + + HfHelper hfHelper; + TrackSelectorKa selectorKaon; + o2::analysis::HfMlResponseBplusToJpsiKReduced hfMlResponse; + o2::ccdb::CcdbApi ccdbApi; + + using TracksKaon = soa::Join; + std::vector outputMl = {}; + + // Filter filterSelectCandidates = (aod::hf_sel_candidate_bplus::isSelBplusToJpsiPi >= selectionFlagBplus); + + HistogramRegistry registry{"registry"}; + + void init(InitContext&) + { + std::array processFuncData{doprocessData, doprocessDataWithBplusMl}; + if ((std::accumulate(processFuncData.begin(), processFuncData.end(), 0)) > 1) { + LOGP(fatal, "Only one process function for data can be enabled at a time."); + } + std::array processFuncMc{doprocessMc, doprocessMcWithBplusMl}; + if ((std::accumulate(processFuncMc.begin(), processFuncMc.end(), 0)) > 1) { + LOGP(fatal, "Only one process function for MC can be enabled at a time."); + } + + if (kaonPidMethod < 0 || kaonPidMethod >= PidMethod::NPidMethods) { + LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); + } + + if (kaonPidMethod != PidMethod::NoPid) { + selectorKaon.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); + selectorKaon.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax); + selectorKaon.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedMax, nSigmaTpcCombinedMax); + selectorKaon.setRangePtTof(ptPidTofMin, ptPidTofMax); + selectorKaon.setRangeNSigmaTof(-nSigmaTofMax, nSigmaTofMax); + selectorKaon.setRangeNSigmaTofCondTpc(-nSigmaTofCombinedMax, nSigmaTofCombinedMax); + } + + const AxisSpec axisMassBplus{150, 4.5, 6.0}; + const AxisSpec axisMassJpsi{600, 2.8f, 3.4f}; + const AxisSpec axisPtProng{100, 0., 10.}; + const AxisSpec axisImpactPar{200, -0.05, 0.05}; + const AxisSpec axisPtJpsi{100, 0., 50.}; + const AxisSpec axisRapidity{100, -2., 2.}; + const AxisSpec axisPtB{(std::vector)binsPt, "#it{p}_{T}^{B^{+}} (GeV/#it{c})"}; + const AxisSpec axisPtKa{100, 0.f, 10.f}; + + registry.add("hMass", bPlusCandTitle + "inv. mass J/#Psi K^{+} (GeV/#it{c}^{2});" + stringPt, {HistType::kTH2F, {axisMassBplus, axisPtB}}); + registry.add("hMassJpsi", bPlusCandTitle + "inv. mass #mu^{+}#mu^{#minus} (GeV/#it{c}^{2});" + stringPt, {HistType::kTH2F, {axisMassJpsi, axisPtJpsi}}); + registry.add("hd0K", bPlusCandTitle + "Kaon DCAxy to prim. vertex (cm);" + stringPt, {HistType::kTH2F, {axisImpactPar, axisPtKa}}); + + // histograms processMC + if (doprocessMc || doprocessMcWithBplusMl) { + registry.add("hPtJpsiGen", mcParticleMatched + "J/#Psi #it{p}_{T}^{gen} (GeV/#it{c}); B^{+} " + stringPt, {HistType::kTH2F, {axisPtProng, axisPtB}}); + registry.add("hPtKGen", mcParticleMatched + "Kaon #it{p}_{T}^{gen} (GeV/#it{c}); B^{+} " + stringPt, {HistType::kTH2F, {axisPtProng, axisPtB}}); + registry.add("hYGenWithProngsInAcceptance", mcParticleMatched + "B^{+} #it{p}_{T}^{gen} (GeV/#it{c}); B^{+} #it{y}", {HistType::kTH2F, {axisPtProng, axisRapidity}}); + registry.add("hMassRecSig", bPlusCandMatch + "inv. mass J/#Psi K^{+} (GeV/#it{c}^{2}); B^{+} " + stringPt, {HistType::kTH2F, {axisMassBplus, axisPtB}}); + registry.add("hMassJpsiRecSig", bPlusCandMatch + "inv. mass #mu^{+}#mu^{#minus} (GeV/#it{c}^{2}); J/#Psi " + stringPt, {HistType::kTH2F, {axisMassJpsi, axisPtJpsi}}); + registry.add("hd0KRecSig", bPlusCandMatch + "Kaon DCAxy to prim. vertex (cm); K^{+} " + stringPt, {HistType::kTH2F, {axisImpactPar, axisPtKa}}); + registry.add("hMassRecBg", bPlusCandUnmatch + "inv. mass J/#Psi K^{+} (GeV/#it{c}^{2}); B^{+} " + stringPt, {HistType::kTH2F, {axisMassBplus, axisPtB}}); + registry.add("hMassJpsiRecBg", bPlusCandUnmatch + "inv. mass #mu^{+}#mu^{#minus} (GeV/#it{c}^{2}); J/#Psi " + stringPt, {HistType::kTH2F, {axisMassJpsi, axisPtJpsi}}); + registry.add("hd0KRecBg", bPlusCandMatch + "Kaon DCAxy to prim. vertex (cm); K^{+} " + stringPt, {HistType::kTH2F, {axisImpactPar, axisPtKa}}); + } + + if (doprocessDataWithBplusMl || doprocessMcWithBplusMl) { + hfMlResponse.configure(binsPtBpMl, cutsBpMl, cutDirBpMl, nClassesBpMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponse.setModelPathsLocal(onnxFileNames); + } + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponse.init(); + } + } + + /// Selection of B+ daughter in geometrical acceptance + /// \param etaProng is the pseudorapidity of B+ prong + /// \param ptProng is the pT of B+ prong + /// \return true if prong is in geometrical acceptance + template + bool isProngInAcceptance(const T& etaProng, const T& ptProng) + { + return std::abs(etaProng) <= etaTrackMax && ptProng >= ptTrackMin; + } + + /// Calculate pseudorapidity from track tan(lambda) + /// \param tgl is the track tangent of the dip angle + /// \return pseudorapidity + inline float absEta(float tgl) + { + return std::abs(std::log(std::tan(o2::constants::math::PIQuarter - 0.5f * std::atan(tgl)))); + } + + /// Fill candidate information at reconstruction level + /// \param doMc is the flag to enable the filling with MC information + /// \param withBplusMl is the flag to enable the filling with ML scores for the B+ candidate + /// \param candidate is the B+ candidate + /// \param candidatesJpsi is the table with Jpsi candidates + template + void fillCand(Cand const& candidate, + aod::HfRedJpsis const& /*candidatesJpsi*/, + aod::HfRedBach0Tracks const&) + { + auto ptCandBplus = candidate.pt(); + auto invMassBplus = hfHelper.invMassBplusToJpsiK(candidate); + auto candJpsi = candidate.template jpsi_as(); + auto candKa = candidate.template bachKa_as(); + auto ptJpsi = candidate.ptProng0(); + auto invMassJpsi = candJpsi.m(); + uint8_t statusBplus = 0; + + int8_t flagMcMatchRec{0}, flagMcDecayChanRec{0}, flagWrongCollision{0}; + bool isSignal = false; + if constexpr (doMc) { + flagMcMatchRec = candidate.flagMcMatchRec(); + flagMcDecayChanRec = candidate.flagMcDecayChanRec(); + flagWrongCollision = candidate.flagWrongCollision(); + isSignal = std::abs(flagMcMatchRec) == o2::hf_decay::hf_cand_beauty::BplusToJpsiK; + } + + SETBIT(statusBplus, SelectionStep::RecoSkims); + if (hfHelper.selectionBplusToJpsiKTopol(candidate, cuts, binsPt)) { + SETBIT(statusBplus, SelectionStep::RecoTopol); + } else if (selectionFlagBplus >= BIT(SelectionStep::RecoTopol) * 2 - 1) { + return; + } + // track-level PID selection + // auto trackKa = candidate.template prong1_as(); + if (kaonPidMethod == PidMethod::TpcOrTof || kaonPidMethod == PidMethod::TpcAndTof) { + int pidTrackKa{TrackSelectorPID::Status::NotApplicable}; + if (kaonPidMethod == PidMethod::TpcOrTof) { + pidTrackKa = selectorKaon.statusTpcOrTof(candKa); + } else if (kaonPidMethod == PidMethod::TpcAndTof) { + pidTrackKa = selectorKaon.statusTpcAndTof(candKa); + } + if (hfHelper.selectionBplusToJpsiKPid(pidTrackKa, acceptPIDNotApplicable.value)) { + // LOGF(info, "B+ candidate selection failed at PID selection"); + SETBIT(statusBplus, SelectionStep::RecoPID); + } else if (selectionFlagBplus >= BIT(SelectionStep::RecoPID) * 2 - 1) { + return; + } + } + + float candidateMlScoreSig = -1; + if constexpr (withBplusMl) { + // B+ ML selections + std::vector inputFeatures = hfMlResponse.getInputFeatures(candidate, candKa); + if (hfMlResponse.isSelectedMl(inputFeatures, ptCandBplus, outputMl)) { + SETBIT(statusBplus, SelectionStep::RecoMl); + } else if (selectionFlagBplus >= BIT(SelectionStep::RecoMl) * 2 - 1) { + return; + } + candidateMlScoreSig = outputMl[1]; + } + + registry.fill(HIST("hMass"), invMassBplus, ptCandBplus); + registry.fill(HIST("hMassJpsi"), invMassJpsi, candidate.ptProng0()); + registry.fill(HIST("hd0K"), candidate.impactParameter1(), candidate.ptProng1()); + if constexpr (doMc) { + if (isSignal) { + registry.fill(HIST("hMassRecSig"), invMassBplus, ptCandBplus); + registry.fill(HIST("hMassJpsiRecSig"), invMassJpsi, candidate.ptProng0()); + registry.fill(HIST("hd0KRecSig"), candidate.impactParameter1(), candidate.ptProng1()); + } else if (fillBackground) { + registry.fill(HIST("hMassRecBg"), invMassBplus, ptCandBplus); + registry.fill(HIST("hMassJpsiRecBg"), invMassJpsi, candidate.ptProng0()); + registry.fill(HIST("hd0KRecBg"), candidate.impactParameter1(), candidate.ptProng1()); + } + } + + float pseudoRndm = ptJpsi * 1000. - static_cast(ptJpsi * 1000); + if (ptCandBplus >= ptMaxForDownSample || pseudoRndm < downSampleBkgFactor) { + float ptMother = -1.; + if constexpr (doMc) { + ptMother = candidate.ptMother(); + } + + hfRedCandBpLite( + // B+ - meson features + invMassBplus, + ptCandBplus, + candidate.eta(), + candidate.phi(), + hfHelper.yBplus(candidate), + candidate.cpa(), + candidate.cpaXY(), + candidate.chi2PCA(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + candidate.ctXY(std::array{o2::constants::physics::MassMuon, o2::constants::physics::MassMuon, o2::constants::physics::MassKPlus}), + candidate.impactParameterProduct(), + candidate.impactParameterProductJpsi(), + candidate.maxNormalisedDeltaIP(), + candidateMlScoreSig, + // J/Psi features + invMassJpsi, + ptJpsi, + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameter2(), + candJpsi.itsNClsDauPos(), + candJpsi.tpcNClsCrossedRowsDauPos(), + candJpsi.itsChi2NClDauPos(), + candJpsi.tpcChi2NClDauPos(), + absEta(candJpsi.tglDauPos()), + candJpsi.itsNClsDauNeg(), + candJpsi.tpcNClsCrossedRowsDauNeg(), + candJpsi.itsChi2NClDauNeg(), + candJpsi.tpcChi2NClDauNeg(), + absEta(candJpsi.tglDauNeg()), + // kaon features + candidate.ptProng1(), + candKa.itsNCls(), + candKa.tpcNClsCrossedRows(), + candKa.itsChi2NCl(), + candKa.tpcChi2NCl(), + absEta(candKa.tgl()), + candKa.tpcNSigmaKa(), + candKa.tofNSigmaKa(), + candKa.tpcTofNSigmaKa(), + // MC truth + flagMcMatchRec, + flagMcDecayChanRec, + isSignal, + flagWrongCollision, + ptMother); + } + } + + /// Fill particle histograms (gen MC truth) + void fillCandMcGen(aod::HfMcGenRedBps::iterator const& particle) + { + auto ptParticle = particle.ptTrack(); + auto yParticle = particle.yTrack(); + if (yCandGenMax >= 0. && std::abs(yParticle) > yCandGenMax) { + return; + } + std::array ptProngs = {particle.ptProng0(), particle.ptProng1()}; + std::array etaProngs = {particle.etaProng0(), particle.etaProng1()}; + bool prongsInAcc = isProngInAcceptance(etaProngs[0], ptProngs[0]) && isProngInAcceptance(etaProngs[1], ptProngs[1]); + + registry.fill(HIST("hPtJpsiGen"), ptProngs[0], ptParticle); + registry.fill(HIST("hPtKGen"), ptProngs[1], ptParticle); + + // generated B+ with daughters in geometrical acceptance + if (prongsInAcc) { + registry.fill(HIST("hYGenWithProngsInAcceptance"), ptParticle, yParticle); + } + } + + // Process functions + void processData(aod::HfRedCandBplusToJpsiK const& candidates, + aod::HfRedJpsis const& candidatesJpsi, + aod::HfRedBach0Tracks const& kaonTracks) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesJpsi, kaonTracks); + } // candidate loop + } // processData + PROCESS_SWITCH(HfTaskBplusToJpsiKReduced, processData, "Process data without ML for B+", true); + + void processDataWithBplusMl(aod::HfRedCandBplusToJpsiK const& candidates, + aod::HfRedJpsis const& candidatesJpsi, + aod::HfRedBach0Tracks const& kaonTracks) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesJpsi, kaonTracks); + } // candidate loop + } // processDataWithBplusMl + PROCESS_SWITCH(HfTaskBplusToJpsiKReduced, processDataWithBplusMl, "Process data with ML for B+", false); + + void processMc(soa::Join const& candidates, + aod::HfMcGenRedBps const& mcParticles, + aod::HfRedJpsis const& candidatesJpsi, + aod::HfRedBach0Tracks const& kaonTracks) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesJpsi, kaonTracks); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskBplusToJpsiKReduced, processMc, "Process MC without ML for B+", false); + + void processMcWithBplusMl(soa::Join const& candidates, + aod::HfMcGenRedBps const& mcParticles, + aod::HfRedJpsis const& candidatesJpsi, + aod::HfRedBach0Tracks const& kaonTracks) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesJpsi, kaonTracks); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMcWithBplusMl + PROCESS_SWITCH(HfTaskBplusToJpsiKReduced, processMcWithBplusMl, "Process MC with ML for B+", false); + +}; // struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/Tasks/taskBs.cxx b/PWGHF/D2H/Tasks/taskBs.cxx index e661c8d739b..d1d1e252c7c 100644 --- a/PWGHF/D2H/Tasks/taskBs.cxx +++ b/PWGHF/D2H/Tasks/taskBs.cxx @@ -15,22 +15,42 @@ /// /// \author Phil Stahlhut -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_decay::hf_cand_beauty; /// Bs analysis task struct HfTaskBs { @@ -126,15 +146,15 @@ struct HfTaskBs { registry.add("hYGenWithProngsInAcceptance", "MC particles (generated-daughters in acceptance);B^{0}_{s} candidate #it{y}^{gen};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); if (checkDecayTypeMc) { - constexpr uint8_t kNBinsDecayTypeMc = hf_cand_bs::DecayTypeMc::NDecayTypeMc + 1; - TString labels[kNBinsDecayTypeMc]; + constexpr uint8_t NBinsDecayTypeMc = hf_cand_bs::DecayTypeMc::NDecayTypeMc + 1; + TString labels[NBinsDecayTypeMc]; labels[hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi] = "B^{0}_{s} #rightarrow (D^{#mp}_{s} #rightarrow K^{#minus} K^{#plus} #pi^{#mp}) #pi^{#pm}"; labels[hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi] = "B^{0} #rightarrow (D^{#pm}_{s} #rightarrow K^{#minus} K^{#plus} #pi^{#pm}) #pi^{#mp}"; labels[hf_cand_bs::DecayTypeMc::PartlyRecoDecay] = "Partly reconstructed decay channel"; labels[hf_cand_bs::DecayTypeMc::NDecayTypeMc] = "Other decays"; - static const AxisSpec axisDecayType = {kNBinsDecayTypeMc, 0.5, kNBinsDecayTypeMc + 0.5, ""}; + static const AxisSpec axisDecayType = {NBinsDecayTypeMc, 0.5, NBinsDecayTypeMc + 0.5, ""}; registry.add("hDecayTypeMc", "DecayType", {HistType::kTH3F, {axisDecayType, axisMassBs, axisPt}}); - for (uint8_t iBin = 0; iBin < kNBinsDecayTypeMc; ++iBin) { + for (uint8_t iBin = 0; iBin < NBinsDecayTypeMc; ++iBin) { registry.get(HIST("hDecayTypeMc"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin]); } } @@ -181,7 +201,7 @@ struct HfTaskBs { registry.fill(HIST("hIPProd"), candidate.impactParameterProduct(), ptCandBs); registry.fill(HIST("hInvMassDs"), hfHelper.invMassDsToKKPi(candDs), ptCandBs); } // candidate loop - } // process + } // process /// Bs MC analysis and fill histograms void processMc(soa::Filtered> const& candidates, @@ -198,9 +218,9 @@ struct HfTaskBs { auto ptCandBs = candidate.pt(); auto candDs = candidate.prong0_as>(); auto invMassCandBs = hfHelper.invMassBsToDsPi(candidate); - int flagMcMatchRecBs = std::abs(candidate.flagMcMatchRec()); + auto flagMcMatchRecBs = std::abs(candidate.flagMcMatchRec()); - if (TESTBIT(flagMcMatchRecBs, hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi)) { + if (flagMcMatchRecBs == DecayChannelMain::BsToDsPi) { auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong1_as().mcParticle_as>(), o2::constants::physics::Pdg::kBS, true); auto particleMother = mcParticles.rawIteratorAt(indexMother); @@ -246,9 +266,9 @@ struct HfTaskBs { registry.fill(HIST("hChi2PCARecBg"), candidate.chi2PCA(), ptCandBs); if (checkDecayTypeMc) { - if (TESTBIT(flagMcMatchRecBs, hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi)) { // B0(bar) → Ds± π∓ → (K- K+ π±) π∓ + if (flagMcMatchRecBs == DecayChannelMain::B0ToDsPi) { // B0(bar) → Ds± π∓ → (K- K+ π±) π∓ registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi, invMassCandBs, ptCandBs); - } else if (TESTBIT(flagMcMatchRecBs, hf_cand_bs::DecayTypeMc::PartlyRecoDecay)) { // Partly reconstructed decay channel + } else if (flagMcMatchRecBs == hf_cand_bs::DecayTypeMc::PartlyRecoDecay) { // FIXME, Partly reconstructed decay channel registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bs::DecayTypeMc::PartlyRecoDecay, invMassCandBs, ptCandBs); } else { registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bs::DecayTypeMc::NDecayTypeMc, invMassCandBs, ptCandBs); @@ -259,7 +279,7 @@ struct HfTaskBs { // MC gen. level for (const auto& particle : mcParticles) { - if (TESTBIT(std::abs(particle.flagMcMatchGen()), hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi)) { + if (std::abs(particle.flagMcMatchGen()) == DecayChannelMain::BsToDsPi) { auto ptParticle = particle.pt(); auto yParticle = RecoDecay::y(particle.pVector(), o2::constants::physics::MassBS); @@ -302,7 +322,7 @@ struct HfTaskBs { registry.fill(HIST("hYGenWithProngsInAcceptance"), yParticle, ptParticle); } } // gen - } // process + } // process PROCESS_SWITCH(HfTaskBs, processMc, "Process MC", false); }; // struct diff --git a/PWGHF/D2H/Tasks/taskBsReduced.cxx b/PWGHF/D2H/Tasks/taskBsReduced.cxx index cbe0ddc2fa4..a5a89e241cf 100644 --- a/PWGHF/D2H/Tasks/taskBsReduced.cxx +++ b/PWGHF/D2H/Tasks/taskBsReduced.cxx @@ -14,16 +14,31 @@ /// /// \author Fabio Catalano , CERN -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Common/Core/RecoDecay.h" - #include "PWGHF/Core/HfHelper.h" -#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -127,12 +142,12 @@ struct HfTaskBsReduced { HfHelper hfHelper; + using TracksPion = soa::Join; + Filter filterSelectCandidates = (aod::hf_sel_candidate_bs::isSelBsToDsPi >= selectionFlagBs); HistogramRegistry registry{"registry"}; - using TracksPion = soa::Join; - void init(InitContext&) { std::array processFuncData{doprocessData, doprocessDataWithDmesMl, doprocessDataWithBsMl}; @@ -262,6 +277,8 @@ struct HfTaskBsReduced { labels[hf_cand_bs::DecayTypeMc::BsToDsPiToK0starKPiToKKPiPi] = "B^{0}_{s} #rightarrow (D_{s} #rightarrow K^{0*}K #rightarrow KK#pi) #pi"; labels[hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi] = "B^{0} #rightarrow (D_{s} #rightarrow #Phi#pi #rightarrow KK#pi) #pi"; labels[hf_cand_bs::DecayTypeMc::B0ToDsPiToK0starKPiToKKPiPi] = "B^{0} #rightarrow (D_{s} #rightarrow K^{0*}K #rightarrow KK#pi) #pi"; + labels[hf_cand_bs::DecayTypeMc::BsToDsKToPhiPiKToKKPiK] = "B^{0}_{s} #rightarrow (D_{s} #rightarrow #Phi#pi #rightarrow KK#pi) K"; + labels[hf_cand_bs::DecayTypeMc::BsToDsKToK0starKKToKKPiK] = "B^{0}_{s} #rightarrow (D_{s} #rightarrow K^{0*}K #rightarrow KK#pi) K"; labels[hf_cand_bs::DecayTypeMc::PartlyRecoDecay] = "Partly reconstructed decay channel"; labels[hf_cand_bs::DecayTypeMc::OtherDecay] = "Other decays"; static const AxisSpec axisDecayType = {kNBinsDecayTypeMc, 0.5, kNBinsDecayTypeMc + 0.5, ""}; @@ -451,7 +468,7 @@ struct HfTaskBsReduced { } } if (fillSparses) { - if constexpr (withDmesMl) { + if constexpr (doMc) { if (isSignal) { if constexpr (withDmesMl) { registry.fill(HIST("hMassPtCutVarsRecSig"), invMassBs, ptCandBs, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassDs, ptDs, candidate.prong0MlScoreBkg(), candidate.prong0MlScoreNonprompt()); @@ -474,7 +491,7 @@ struct HfTaskBsReduced { } } if (fillTree) { - float pseudoRndm = ptDs * 1000. - (int64_t)(ptDs * 1000); + float pseudoRndm = ptDs * 1000. - static_cast(ptDs * 1000); if (flagMcMatchRec != 0 || (((doMc && fillBackground) || !doMc) && (ptCandBs >= ptMaxForDownSample || pseudoRndm < downSampleBkgFactor))) { float prong0MlScoreBkg = -1.; float prong0MlScorePrompt = -1.; diff --git a/PWGHF/D2H/Tasks/taskBsToJpsiPhiReduced.cxx b/PWGHF/D2H/Tasks/taskBsToJpsiPhiReduced.cxx new file mode 100644 index 00000000000..bf06d3c7295 --- /dev/null +++ b/PWGHF/D2H/Tasks/taskBsToJpsiPhiReduced.cxx @@ -0,0 +1,622 @@ +// 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. + +/// \file taskBsToJpsiPhiReduced.cxx +/// \brief Bs → Jpsi phi → (µ+ µ-) (K+K-) analysis task +/// +/// \author Fabrizio Chinu , Università degli Studi and INFN Torino +/// \author Fabrizio Grosa , CERN + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponseBsToJpsiPhiReduced.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsPid.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::analysis; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::pid_tpc_tof_utils; + +namespace o2::aod +{ +namespace hf_cand_bstojpsiphi_lite +{ +DECLARE_SOA_COLUMN(PtJpsi, ptJpsi, float); //! Transverse momentum of Jpsi daughter candidate (GeV/c) +DECLARE_SOA_COLUMN(PtBach0, ptBach0, float); //! Transverse momentum of bachelor kaon(<- phi) (GeV/c) +DECLARE_SOA_COLUMN(PtBach1, ptBach1, float); //! Transverse momentum of bachelor kaon(<- phi) (GeV/c) +DECLARE_SOA_COLUMN(ItsNClsJpsiDauPos, itsNClsJpsiDauPos, int); //! Number of clusters in ITS +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsJpsiDauPos, tpcNClsCrossedRowsJpsiDauPos, int); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(ItsChi2NClJpsiDauPos, itsChi2NClJpsiDauPos, float); //! ITS chi2 / Number of clusters +DECLARE_SOA_COLUMN(TpcChi2NClJpsiDauPos, tpcChi2NClJpsiDauPos, float); //! TPC chi2 / Number of clusters +DECLARE_SOA_COLUMN(AbsEtaJpsiDauPos, absEtaJpsiDauPos, float); //! |eta| +DECLARE_SOA_COLUMN(ItsNClsJpsiDauNeg, itsNClsJpsiDauNeg, int); //! Number of clusters in ITS +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsJpsiDauNeg, tpcNClsCrossedRowsJpsiDauNeg, int); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(ItsChi2NClJpsiDauNeg, itsChi2NClJpsiDauNeg, float); //! ITS chi2 / Number of clusters +DECLARE_SOA_COLUMN(TpcChi2NClJpsiDauNeg, tpcChi2NClJpsiDauNeg, float); //! TPC chi2 / Number of clusters +DECLARE_SOA_COLUMN(AbsEtaJpsiDauNeg, absEtaJpsiDauNeg, float); //! |eta| +DECLARE_SOA_COLUMN(ItsNClsLfTrack0, itsNClsLfTrack0, int); //! Number of clusters in ITS +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsLfTrack0, tpcNClsCrossedRowsLfTrack0, int); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(ItsChi2NClLfTrack0, itsChi2NClLfTrack0, float); //! ITS chi2 / Number of clusters +DECLARE_SOA_COLUMN(TpcChi2NClLfTrack0, tpcChi2NClLfTrack0, float); //! TPC chi2 / Number of clusters +DECLARE_SOA_COLUMN(AbsEtaLfTrack0, absEtaLfTrack0, float); //! |eta| +DECLARE_SOA_COLUMN(ItsNClsLfTrack1, itsNClsLfTrack1, int); //! Number of clusters in ITS +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsLfTrack1, tpcNClsCrossedRowsLfTrack1, int); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(ItsChi2NClLfTrack1, itsChi2NClLfTrack1, float); //! ITS chi2 / Number of clusters +DECLARE_SOA_COLUMN(TpcChi2NClLfTrack1, tpcChi2NClLfTrack1, float); //! TPC chi2 / Number of clusters +DECLARE_SOA_COLUMN(AbsEtaLfTrack1, absEtaLfTrack1, float); //! |eta| +DECLARE_SOA_COLUMN(MJpsi, mJpsi, float); //! Invariant mass of Jpsi daughter candidates (GeV/c) +DECLARE_SOA_COLUMN(MPhi, mPhi, float); //! Invariant mass of phi daughter candidates (GeV/c) +DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate (GeV/c2) +DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(PtGen, ptGen, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(P, p, float); //! Momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(Y, y, float); //! Rapidity of candidate +DECLARE_SOA_COLUMN(Eta, eta, float); //! Pseudorapidity of candidate +DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuth angle of candidate +DECLARE_SOA_COLUMN(E, e, float); //! Energy of candidate (GeV) +DECLARE_SOA_COLUMN(NSigTpcKaBachelor0, nSigTpcKaBachelor0, float); //! TPC Nsigma separation for bachelor 0 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTofKaBachelor0, nSigTofKaBachelor0, float); //! TOF Nsigma separation for bachelor 0 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofKaBachelor0, nSigTpcTofKaBachelor0, float); //! Combined TPC and TOF Nsigma separation for bachelor 0 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcKaBachelor1, nSigTpcKaBachelor1, float); //! TPC Nsigma separation for bachelor 1 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTofKaBachelor1, nSigTofKaBachelor1, float); //! TOF Nsigma separation for bachelor 1 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofKaBachelor1, nSigTpcTofKaBachelor1, float); //! Combined TPC and TOF Nsigma separation for bachelor 1 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcMuJpsiDauPos, nSigTpcMuJpsiDauPos, float); //! TPC Nsigma separation for Jpsi DauPos with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTofMuJpsiDauPos, nSigTofMuJpsiDauPos, float); //! TOF Nsigma separation for Jpsi DauPos with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofMuJpsiDauPos, nSigTpcTofMuJpsiDauPos, float); //! Combined TPC and TOF Nsigma separation for Jpsi prong0 with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcMuJpsiDauNeg, nSigTpcMuJpsiDauNeg, float); //! TPC Nsigma separation for Jpsi DauNeg with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTofMuJpsiDauNeg, nSigTofMuJpsiDauNeg, float); //! TOF Nsigma separation for Jpsi DauNeg with muon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofMuJpsiDauNeg, nSigTpcTofMuJpsiDauNeg, float); //! Combined TPC and TOF Nsigma separation for Jpsi prong1 with muon mass hypothesis +DECLARE_SOA_COLUMN(DecayLength, decayLength, float); //! Decay length of candidate (cm) +DECLARE_SOA_COLUMN(DecayLengthXY, decayLengthXY, float); //! Transverse decay length of candidate (cm) +DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float); //! Normalised decay length of candidate +DECLARE_SOA_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, float); //! Normalised transverse decay length of candidate +DECLARE_SOA_COLUMN(CtXY, ctXY, float); //! Pseudo-proper decay length of candidate +DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float); //! Impact parameter product of B daughters +DECLARE_SOA_COLUMN(ImpactParameterProductJpsi, impactParameterProductJpsi, float); //! Impact parameter product of Jpsi daughters +DECLARE_SOA_COLUMN(ImpactParameterProductPhi, impactParameterProductPhi, float); //! Impact parameter product of Phi daughters +DECLARE_SOA_COLUMN(ImpactParameterJpsiDauPos, impactParameterJpsiDauPos, float); //! Impact parameter of Jpsi daughter candidate +DECLARE_SOA_COLUMN(ImpactParameterJpsiDauNeg, impactParameterJpsiDauNeg, float); //! Impact parameter of Jpsi daughter candidate +DECLARE_SOA_COLUMN(ImpactParameterLfTrack0, impactParameterLfTrack0, float); //! Impact parameter of Phi daughter candidate +DECLARE_SOA_COLUMN(ImpactParameterLfTrack1, impactParameterLfTrack1, float); //! Impact parameter of Phi daughter candidate +DECLARE_SOA_COLUMN(Cpa, cpa, float); //! Cosine pointing angle of candidate +DECLARE_SOA_COLUMN(CpaXY, cpaXY, float); //! Cosine pointing angle of candidate in transverse plane +DECLARE_SOA_COLUMN(CpaJpsi, cpaJpsi, float); //! Cosine pointing angle of Jpsi daughter candidate +DECLARE_SOA_COLUMN(CpaXYJpsi, cpaXYJpsi, float); //! Cosine pointing angle in transverse plane of Jpsi daughter candidate +DECLARE_SOA_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float); //! Maximum normalized difference between measured and expected impact parameter of candidate prongs +DECLARE_SOA_COLUMN(MlScoreSig, mlScoreSig, float); //! ML score for signal class +DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); //! Flag for association with wrong collision +} // namespace hf_cand_bstojpsiphi_lite + +DECLARE_SOA_TABLE(HfRedCandBsLites, "AOD", "HFREDCANDBSLITE", //! Table with some Bs properties + hf_cand_bstojpsiphi_lite::M, + hf_cand_bstojpsiphi_lite::Pt, + hf_cand_bstojpsiphi_lite::Eta, + hf_cand_bstojpsiphi_lite::Phi, + hf_cand_bstojpsiphi_lite::Y, + hf_cand_bstojpsiphi_lite::Cpa, + hf_cand_bstojpsiphi_lite::CpaXY, + hf_cand::Chi2PCA, + hf_cand_bstojpsiphi_lite::DecayLength, + hf_cand_bstojpsiphi_lite::DecayLengthXY, + hf_cand_bstojpsiphi_lite::DecayLengthNormalised, + hf_cand_bstojpsiphi_lite::DecayLengthXYNormalised, + hf_cand_bstojpsiphi_lite::CtXY, + hf_cand_bstojpsiphi_lite::ImpactParameterProduct, + hf_cand_bstojpsiphi_lite::ImpactParameterProductJpsi, + hf_cand_bstojpsiphi_lite::ImpactParameterProductPhi, + hf_cand_bstojpsiphi_lite::MaxNormalisedDeltaIP, + hf_cand_bstojpsiphi_lite::MlScoreSig, + // hf_sel_candidate_bplus::IsSelBsToJpsiPi, + // Jpsi meson features + hf_cand_bstojpsiphi_lite::MJpsi, + hf_cand_bstojpsiphi_lite::PtJpsi, + hf_cand_bstojpsiphi_lite::MPhi, + hf_cand_bstojpsiphi_lite::ImpactParameterJpsiDauPos, + hf_cand_bstojpsiphi_lite::ImpactParameterJpsiDauNeg, + hf_cand_bstojpsiphi_lite::ImpactParameterLfTrack0, + hf_cand_bstojpsiphi_lite::ImpactParameterLfTrack1, + // Jpsi daughter features + hf_cand_bstojpsiphi_lite::ItsNClsJpsiDauPos, + hf_cand_bstojpsiphi_lite::TpcNClsCrossedRowsJpsiDauPos, + hf_cand_bstojpsiphi_lite::ItsChi2NClJpsiDauPos, + hf_cand_bstojpsiphi_lite::TpcChi2NClJpsiDauPos, + hf_cand_bstojpsiphi_lite::AbsEtaJpsiDauPos, + hf_cand_bstojpsiphi_lite::ItsNClsJpsiDauNeg, + hf_cand_bstojpsiphi_lite::TpcNClsCrossedRowsJpsiDauNeg, + hf_cand_bstojpsiphi_lite::ItsChi2NClJpsiDauNeg, + hf_cand_bstojpsiphi_lite::TpcChi2NClJpsiDauNeg, + hf_cand_bstojpsiphi_lite::AbsEtaJpsiDauNeg, + // kaon features + hf_cand_bstojpsiphi_lite::PtBach0, + hf_cand_bstojpsiphi_lite::ItsNClsLfTrack0, + hf_cand_bstojpsiphi_lite::TpcNClsCrossedRowsLfTrack0, + hf_cand_bstojpsiphi_lite::ItsChi2NClLfTrack0, + hf_cand_bstojpsiphi_lite::TpcChi2NClLfTrack0, + hf_cand_bstojpsiphi_lite::AbsEtaLfTrack0, + hf_cand_bstojpsiphi_lite::NSigTpcKaBachelor0, + hf_cand_bstojpsiphi_lite::NSigTofKaBachelor0, + hf_cand_bstojpsiphi_lite::NSigTpcTofKaBachelor0, + hf_cand_bstojpsiphi_lite::PtBach1, + hf_cand_bstojpsiphi_lite::ItsNClsLfTrack1, + hf_cand_bstojpsiphi_lite::TpcNClsCrossedRowsLfTrack1, + hf_cand_bstojpsiphi_lite::ItsChi2NClLfTrack1, + hf_cand_bstojpsiphi_lite::TpcChi2NClLfTrack1, + hf_cand_bstojpsiphi_lite::AbsEtaLfTrack1, + hf_cand_bstojpsiphi_lite::NSigTpcKaBachelor1, + hf_cand_bstojpsiphi_lite::NSigTofKaBachelor1, + hf_cand_bstojpsiphi_lite::NSigTpcTofKaBachelor1, + // MC truth + hf_cand_bs::FlagMcMatchRec, + hf_cand_bs::FlagMcDecayChanRec, + hf_cand_bs::OriginMcRec, + hf_cand_bstojpsiphi_lite::FlagWrongCollision, + hf_cand_bstojpsiphi_lite::PtGen); + +// DECLARE_SOA_TABLE(HfRedBsMcCheck, "AOD", "HFREDBPMCCHECK", //! Table with MC decay type check +// hf_cand_2prong::FlagMcMatchRec, +// hf_cand_bstojpsiphi_lite::FlagWrongCollision, +// hf_cand_bstojpsiphi_lite::MJpsi, +// hf_cand_bstojpsiphi_lite::PtJpsi, +// hf_cand_bstojpsiphi_lite::M, +// hf_cand_bstojpsiphi_lite::Pt, +// // hf_cand_bstojpsiphi_lite::MlScoreSig, +// hf_bplus_mc::PdgCodeBeautyMother, +// hf_bplus_mc::PdgCodeCharmMother, +// hf_bplus_mc::PdgCodeDauPos, +// hf_bplus_mc::PdgCodeDauNeg, +// hf_bplus_mc::PdgCodeProng2); +} // namespace o2::aod + +// string definitions, used for histogram axis labels +const TString stringPt = "#it{p}_{T} (GeV/#it{c})"; +const TString stringPtJpsi = "#it{p}_{T}(Jpsi) (GeV/#it{c});"; +const TString bSCandTitle = "B_{s}^{0} candidates;"; +const TString entries = "entries"; +const TString bSCandMatch = "B_{s}^{0} candidates (matched);"; +const TString bSCandUnmatch = "B_{s}^{0} candidates (unmatched);"; +const TString mcParticleMatched = "MC particles (matched);"; + +/// Bs analysis task +struct HfTaskBsToJpsiPhiReduced { + Produces hfRedCandBsLite; + // Produces hfRedBsMcCheck; + + Configurable selectionFlagBs{"selectionFlagBs", 1, "Selection Flag for Bs"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "max. track pseudo-rapidity"}; + Configurable ptTrackMin{"ptTrackMin", 0.1, "min. track transverse momentum"}; + Configurable fillBackground{"fillBackground", false, "Flag to enable filling of background histograms/sparses/tree (only MC)"}; + Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + // topological cuts + Configurable> binsPt{"binsPt", std::vector{hf_cuts_bs_to_jpsi_phi::vecBinsPt}, "pT bin limits"}; + Configurable> cuts{"cuts", {hf_cuts_bs_to_jpsi_phi::Cuts[0], hf_cuts_bs_to_jpsi_phi::NBinsPt, hf_cuts_bs_to_jpsi_phi::NCutVars, hf_cuts_bs_to_jpsi_phi::labelsPt, hf_cuts_bs_to_jpsi_phi::labelsCutVar}, "Bs candidate selection per pT bin"}; + // Enable PID + Configurable kaonPidMethod{"kaonPidMethod", PidMethod::TpcOrTof, "PID selection method for the bachelor kaon (PidMethod::NoPid: none, PidMethod::TpcOrTof: TPC or TOF, PidMethod::TpcAndTof: TPC and TOF)"}; + Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; + // TPC PID + Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; + Configurable ptPidTpcMax{"ptPidTpcMax", 20., "Upper bound of track pT for TPC PID"}; + Configurable nSigmaTpcMax{"nSigmaTpcMax", 5., "Nsigma cut on TPC only"}; + Configurable nSigmaTpcCombinedMax{"nSigmaTpcCombinedMax", 5., "Nsigma cut on TPC combined with TOF"}; + // TOF PID + Configurable ptPidTofMin{"ptPidTofMin", 0.15, "Lower bound of track pT for TOF PID"}; + Configurable ptPidTofMax{"ptPidTofMax", 20., "Upper bound of track pT for TOF PID"}; + Configurable nSigmaTofMax{"nSigmaTofMax", 5., "Nsigma cut on TOF only"}; + Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; + // Bs ML inference + Configurable> binsPtBsMl{"binsPtBsMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; + Configurable> cutDirBsMl{"cutDirBsMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsBsMl{"cutsBsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesBsMl{"nClassesBsMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; + // CCDB configuration + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"path_ccdb/BDT_BS/"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_BSToJpsiPhi.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + + HfHelper hfHelper; + TrackSelectorKa selectorKaon; + o2::analysis::HfMlResponseBsToJpsiPhiReduced hfMlResponse; + o2::ccdb::CcdbApi ccdbApi; + + using TracksKaon = soa::Join; + std::vector outputMl = {}; + + // Filter filterSelectCandidates = (aod::hf_sel_candidate_bplus::isSelBsToJpsiPi >= selectionFlagBs); + + HistogramRegistry registry{"registry"}; + + void init(InitContext&) + { + std::array processFuncData{doprocessData, doprocessDataWithBsMl}; + if ((std::accumulate(processFuncData.begin(), processFuncData.end(), 0)) > 1) { + LOGP(fatal, "Only one process function for data can be enabled at a time."); + } + std::array processFuncMc{doprocessMc, doprocessMcWithBsMl}; + if ((std::accumulate(processFuncMc.begin(), processFuncMc.end(), 0)) > 1) { + LOGP(fatal, "Only one process function for MC can be enabled at a time."); + } + + if (kaonPidMethod < 0 || kaonPidMethod >= PidMethod::NPidMethods) { + LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); + } + + if (kaonPidMethod != PidMethod::NoPid) { + selectorKaon.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); + selectorKaon.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax); + selectorKaon.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedMax, nSigmaTpcCombinedMax); + selectorKaon.setRangePtTof(ptPidTofMin, ptPidTofMax); + selectorKaon.setRangeNSigmaTof(-nSigmaTofMax, nSigmaTofMax); + selectorKaon.setRangeNSigmaTofCondTpc(-nSigmaTofCombinedMax, nSigmaTofCombinedMax); + } + + const AxisSpec axisMassBs{150, 4.5, 6.0}; + const AxisSpec axisMassJpsi{600, 2.8f, 3.4f}; + const AxisSpec axisMassPhi{200, 0.9f, 1.1f}; + const AxisSpec axisPtProng{100, 0., 10.}; + const AxisSpec axisImpactPar{200, -0.05, 0.05}; + const AxisSpec axisPtJpsi{100, 0., 50.}; + const AxisSpec axisRapidity{100, -2., 2.}; + const AxisSpec axisPtB{(std::vector)binsPt, "#it{p}_{T}^{B_{s}^{0}} (GeV/#it{c})"}; + const AxisSpec axisPtKa{100, 0.f, 10.f}; + const AxisSpec axisPtPhi{100, 0.f, 10.f}; + + registry.add("hMass", bSCandTitle + "inv. mass J/#Psi K^{+} (GeV/#it{c}^{2});" + stringPt, {HistType::kTH2F, {axisMassBs, axisPtB}}); + registry.add("hMassJpsi", bSCandTitle + "inv. mass #mu^{+}#mu^{#minus} (GeV/#it{c}^{2});" + stringPt, {HistType::kTH2F, {axisMassJpsi, axisPtJpsi}}); + registry.add("hMassPhi", bSCandTitle + "inv. mass K^{+}K^{#minus} (GeV/#it{c}^{2});" + stringPt, {HistType::kTH2F, {axisMassPhi, axisPtPhi}}); + registry.add("hd0K", bSCandTitle + "Kaon DCAxy to prim. vertex (cm);" + stringPt, {HistType::kTH2F, {axisImpactPar, axisPtKa}}); + + // histograms processMC + if (doprocessMc || doprocessMcWithBsMl) { + registry.add("hPtJpsiGen", mcParticleMatched + "J/#Psi #it{p}_{T}^{gen} (GeV/#it{c}); B_{s}^{0} " + stringPt, {HistType::kTH2F, {axisPtProng, axisPtB}}); + registry.add("hPtPhiGen", mcParticleMatched + "#phi #it{p}_{T}^{gen} (GeV/#it{c}); B_{s}^{0} " + stringPt, {HistType::kTH2F, {axisPtProng, axisPtB}}); + registry.add("hPtKGen", mcParticleMatched + "Kaon #it{p}_{T}^{gen} (GeV/#it{c}); B_{s}^{0} " + stringPt, {HistType::kTH2F, {axisPtProng, axisPtB}}); + registry.add("hYGenWithProngsInAcceptance", mcParticleMatched + "B_{s}^{0} #it{p}_{T}^{gen} (GeV/#it{c}); B_{s}^{0} #it{y}", {HistType::kTH2F, {axisPtProng, axisRapidity}}); + registry.add("hMassRecSig", bSCandMatch + "inv. mass J/#Psi K^{+} (GeV/#it{c}^{2}); B_{s}^{0} " + stringPt, {HistType::kTH2F, {axisMassBs, axisPtB}}); + registry.add("hMassJpsiRecSig", bSCandMatch + "inv. mass #mu^{+}#mu^{#minus} (GeV/#it{c}^{2}); J/#Psi " + stringPt, {HistType::kTH2F, {axisMassJpsi, axisPtJpsi}}); + registry.add("hMassPhiRecSig", bSCandMatch + "inv. mass K^{+}K^{#minus} (GeV/#it{c}^{2}); #phi " + stringPt, {HistType::kTH2F, {axisMassPhi, axisPtPhi}}); + registry.add("hd0KRecSig", bSCandMatch + "Kaon DCAxy to prim. vertex (cm); K^{+} " + stringPt, {HistType::kTH2F, {axisImpactPar, axisPtKa}}); + registry.add("hMassRecBg", bSCandUnmatch + "inv. mass J/#Psi K^{+} (GeV/#it{c}^{2}); B_{s}^{0} " + stringPt, {HistType::kTH2F, {axisMassBs, axisPtB}}); + registry.add("hMassJpsiRecBg", bSCandUnmatch + "inv. mass #mu^{+}#mu^{#minus} (GeV/#it{c}^{2}); J/#Psi " + stringPt, {HistType::kTH2F, {axisMassJpsi, axisPtJpsi}}); + registry.add("hMassPhiRecBg", bSCandMatch + "inv. mass K^{+}K^{#minus} (GeV/#it{c}^{2}); #phi " + stringPt, {HistType::kTH2F, {axisMassPhi, axisPtPhi}}); + registry.add("hd0KRecBg", bSCandMatch + "Kaon DCAxy to prim. vertex (cm); K^{+} " + stringPt, {HistType::kTH2F, {axisImpactPar, axisPtKa}}); + } + + if (doprocessDataWithBsMl || doprocessMcWithBsMl) { + hfMlResponse.configure(binsPtBsMl, cutsBsMl, cutDirBsMl, nClassesBsMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponse.setModelPathsLocal(onnxFileNames); + } + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponse.init(); + } + } + + /// Selection of Bs daughter in geometrical acceptance + /// \param etaProng is the pseudorapidity of Bs prong + /// \param ptProng is the pT of Bs prong + /// \return true if prong is in geometrical acceptance + template + bool isProngInAcceptance(const T& etaProng, const T& ptProng) + { + return std::abs(etaProng) <= etaTrackMax && ptProng >= ptTrackMin; + } + + /// Calculate pseudorapidity from track tan(lambda) + /// \param tgl is the track tangent of the dip angle + /// \return pseudorapidity + inline float absEta(float tgl) + { + return std::abs(std::log(std::tan(o2::constants::math::PIQuarter - 0.5f * std::atan(tgl)))); + } + + /// Fill candidate information at reconstruction level + /// \param doMc is the flag to enable the filling with MC information + /// \param withBsMl is the flag to enable the filling with ML scores for the Bs candidate + /// \param candidate is the Bs candidate + /// \param candidatesJpsi is the table with Jpsi candidates + template + void fillCand(Cand const& candidate, + aod::HfRedJpsis const& /*candidatesJpsi*/, + aod::HfRedBach0Tracks const&, + aod::HfRedBach1Tracks const&) + { + auto ptCandBs = candidate.pt(); + auto invMassBs = hfHelper.invMassBsToJpsiPhi(candidate); + auto candJpsi = candidate.template jpsi_as(); + auto candKa0 = candidate.template prong0Phi_as(); + auto candKa1 = candidate.template prong1Phi_as(); + std::array pVecKa0 = {candKa0.px(), candKa0.py(), candKa0.pz()}; + std::array pVecKa1 = {candKa1.px(), candKa1.py(), candKa1.pz()}; + auto ptJpsi = candidate.ptProng0(); + auto invMassJpsi = candJpsi.m(); + auto invMassPhi = RecoDecay::m(std::array{pVecKa0, pVecKa1}, std::array{o2::constants::physics::MassKPlus, o2::constants::physics::MassKPlus}); + uint8_t statusBs = 0; + + int8_t flagMcMatchRec{0}, flagMcDecayChanRec{0}, flagWrongCollision{0}; + bool isSignal = false; + if constexpr (doMc) { + flagMcMatchRec = candidate.flagMcMatchRec(); + flagMcDecayChanRec = candidate.flagMcDecayChanRec(); + flagWrongCollision = candidate.flagWrongCollision(); + isSignal = flagMcMatchRec == o2::hf_decay::hf_cand_beauty::BsToJpsiKK && + flagMcDecayChanRec == o2::hf_decay::hf_cand_beauty::BsToJpsiPhi; + } + + SETBIT(statusBs, SelectionStep::RecoSkims); + if (hfHelper.selectionBsToJpsiPhiTopol(candidate, candKa0, candKa1, cuts, binsPt)) { + SETBIT(statusBs, SelectionStep::RecoTopol); + } else if (selectionFlagBs >= BIT(SelectionStep::RecoTopol) * 2 - 1) { + return; + } + // track-level PID selection + // auto trackKa = candidate.template prong1_as(); + if (kaonPidMethod == PidMethod::TpcOrTof || kaonPidMethod == PidMethod::TpcAndTof) { + int pidTrackKa0{TrackSelectorPID::Status::NotApplicable}; + int pidTrackKa1{TrackSelectorPID::Status::NotApplicable}; + if (kaonPidMethod == PidMethod::TpcOrTof) { + pidTrackKa0 = selectorKaon.statusTpcOrTof(candKa0); + pidTrackKa1 = selectorKaon.statusTpcOrTof(candKa1); + } else if (kaonPidMethod == PidMethod::TpcAndTof) { + pidTrackKa0 = selectorKaon.statusTpcAndTof(candKa0); + pidTrackKa1 = selectorKaon.statusTpcAndTof(candKa1); + } + if (hfHelper.selectionBsToJpsiPhiPid(pidTrackKa0, acceptPIDNotApplicable.value) && + hfHelper.selectionBsToJpsiPhiPid(pidTrackKa1, acceptPIDNotApplicable.value)) { + // LOGF(info, "Bs candidate selection failed at PID selection"); + SETBIT(statusBs, SelectionStep::RecoPID); + } else if (selectionFlagBs >= BIT(SelectionStep::RecoPID) * 2 - 1) { + return; + } + } + + float candidateMlScoreSig = -1; + if constexpr (withBsMl) { + // Bs ML selections + std::vector inputFeatures = hfMlResponse.getInputFeatures(candidate, candKa0, candKa1); + if (hfMlResponse.isSelectedMl(inputFeatures, ptCandBs, outputMl)) { + SETBIT(statusBs, SelectionStep::RecoMl); + } else if (selectionFlagBs >= BIT(SelectionStep::RecoMl) * 2 - 1) { + return; + } + candidateMlScoreSig = outputMl[1]; + } + + registry.fill(HIST("hMass"), invMassBs, ptCandBs); + registry.fill(HIST("hMassJpsi"), invMassJpsi, candidate.ptProng0()); + registry.fill(HIST("hMassPhi"), invMassPhi, candidate.ptProng0()); + registry.fill(HIST("hd0K"), candidate.impactParameter1(), candidate.ptProng1()); + if constexpr (doMc) { + if (isSignal) { + registry.fill(HIST("hMassRecSig"), invMassBs, ptCandBs); + registry.fill(HIST("hMassJpsiRecSig"), invMassJpsi, candidate.ptProng0()); + registry.fill(HIST("hd0KRecSig"), candidate.impactParameter1(), candidate.ptProng1()); + } else if (fillBackground) { + registry.fill(HIST("hMassRecBg"), invMassBs, ptCandBs); + registry.fill(HIST("hMassJpsiRecBg"), invMassJpsi, candidate.ptProng0()); + registry.fill(HIST("hd0KRecBg"), candidate.impactParameter1(), candidate.ptProng1()); + } + } + + float pseudoRndm = ptJpsi * 1000. - static_cast(ptJpsi * 1000); + if (ptCandBs >= ptMaxForDownSample || pseudoRndm < downSampleBkgFactor) { + float ptMother = -1.; + if constexpr (doMc) { + ptMother = candidate.ptMother(); + } + + hfRedCandBsLite( + // Bs - meson features + invMassBs, + ptCandBs, + candidate.eta(), + candidate.phi(), + hfHelper.yBs(candidate), + candidate.cpa(), + candidate.cpaXY(), + candidate.chi2PCA(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + candidate.ctXY(std::array{o2::constants::physics::MassMuon, o2::constants::physics::MassMuon, o2::constants::physics::MassKPlus, o2::constants::physics::MassKPlus}), + candidate.impactParameterProduct(), + candidate.impactParameterProductJpsi(), + candidate.impactParameterProductPhi(), + candidate.maxNormalisedDeltaIP(), + candidateMlScoreSig, + // J/Psi features + invMassJpsi, + ptJpsi, + invMassPhi, + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameter2(), + candidate.impactParameter3(), + candJpsi.itsNClsDauPos(), + candJpsi.tpcNClsCrossedRowsDauPos(), + candJpsi.itsChi2NClDauPos(), + candJpsi.tpcChi2NClDauPos(), + absEta(candJpsi.tglDauPos()), + candJpsi.itsNClsDauNeg(), + candJpsi.tpcNClsCrossedRowsDauNeg(), + candJpsi.itsChi2NClDauNeg(), + candJpsi.tpcChi2NClDauNeg(), + absEta(candJpsi.tglDauNeg()), + // kaon features + candKa0.pt(), + candKa0.itsNCls(), + candKa0.tpcNClsCrossedRows(), + candKa0.itsChi2NCl(), + candKa0.tpcChi2NCl(), + absEta(candKa0.tgl()), + // candKa.absEtaBach(candKa.tgl()), + candKa0.tpcNSigmaKa(), + candKa0.tofNSigmaKa(), + candKa0.tpcTofNSigmaKa(), + candKa1.pt(), + candKa1.itsNCls(), + candKa1.tpcNClsCrossedRows(), + candKa1.itsChi2NCl(), + candKa1.tpcChi2NCl(), + absEta(candKa1.tgl()), + candKa1.tpcNSigmaKa(), + candKa1.tofNSigmaKa(), + candKa1.tpcTofNSigmaKa(), + // MC truth + flagMcMatchRec, + flagMcDecayChanRec, + isSignal, + flagWrongCollision, + ptMother); + } + } + + /// Fill particle histograms (gen MC truth) + void fillCandMcGen(aod::HfMcGenRedBss::iterator const& particle) + { + auto ptParticle = particle.ptTrack(); + auto yParticle = particle.yTrack(); + if (yCandGenMax >= 0. && std::abs(yParticle) > yCandGenMax) { + return; + } + std::array ptProngs = {particle.ptProng0(), particle.ptProng1()}; + std::array etaProngs = {particle.etaProng0(), particle.etaProng1()}; + bool prongsInAcc = isProngInAcceptance(etaProngs[0], ptProngs[0]) && isProngInAcceptance(etaProngs[1], ptProngs[1]); + + registry.fill(HIST("hPtJpsiGen"), ptProngs[0], ptParticle); + registry.fill(HIST("hPtKGen"), ptProngs[1], ptParticle); + + // generated Bs with daughters in geometrical acceptance + if (prongsInAcc) { + registry.fill(HIST("hYGenWithProngsInAcceptance"), ptParticle, yParticle); + } + } + + // Process functions + void processData(aod::HfRedCandBsToJpsiPhi const& candidates, + aod::HfRedJpsis const& candidatesJpsi, + aod::HfRedBach0Tracks const& kaon0Tracks, + aod::HfRedBach1Tracks const& kaon1Tracks) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesJpsi, kaon0Tracks, kaon1Tracks); + } // candidate loop + } // processData + PROCESS_SWITCH(HfTaskBsToJpsiPhiReduced, processData, "Process data without ML for Bs", true); + + void processDataWithBsMl(aod::HfRedCandBsToJpsiPhi const& candidates, + aod::HfRedJpsis const& candidatesJpsi, + aod::HfRedBach0Tracks const& kaon0Tracks, + aod::HfRedBach1Tracks const& kaon1Tracks) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesJpsi, kaon0Tracks, kaon1Tracks); + } // candidate loop + } // processDataWithBsMl + PROCESS_SWITCH(HfTaskBsToJpsiPhiReduced, processDataWithBsMl, "Process data with ML for Bs", false); + + void processMc(soa::Join const& candidates, + aod::HfMcGenRedBss const& mcParticles, + aod::HfRedJpsis const& candidatesJpsi, + aod::HfRedBach0Tracks const& kaon0Tracks, + aod::HfRedBach1Tracks const& kaon1Tracks) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesJpsi, kaon0Tracks, kaon1Tracks); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskBsToJpsiPhiReduced, processMc, "Process MC without ML for Bs", false); + + void processMcWithBsMl(soa::Join const& candidates, + aod::HfMcGenRedBss const& mcParticles, + aod::HfRedJpsis const& candidatesJpsi, + aod::HfRedBach0Tracks const& kaon0Tracks, + aod::HfRedBach1Tracks const& kaon1Tracks) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesJpsi, kaon0Tracks, kaon1Tracks); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMcWithBsMl + PROCESS_SWITCH(HfTaskBsToJpsiPhiReduced, processMcWithBsMl, "Process MC with ML for Bs", false); + +}; // struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/Tasks/taskCharmPolarisation.cxx b/PWGHF/D2H/Tasks/taskCharmPolarisation.cxx index 8dc690b0be6..16da492051f 100644 --- a/PWGHF/D2H/Tasks/taskCharmPolarisation.cxx +++ b/PWGHF/D2H/Tasks/taskCharmPolarisation.cxx @@ -15,24 +15,48 @@ /// \author F. Grosa (CERN) fabrizio.grosa@cern.ch /// \author S. Kundu (CERN) sourav.kundu@cern.ch /// \author M. Faggin (CERN) mattia.faggin@cern.ch +/// \author M. Li (CCNU) mingze.li@cern.ch -#include - -#include "TRandom3.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" - -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -// #include "Common/Core/EventPlaneHelper.h" -// #include "Common/DataModel/Qvectors.h" - +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" + +#include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Qvectors.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include // IWYU pragma: keep (do not replace with Math/Vector3Dfwd.h) +#include +#include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -48,6 +72,7 @@ enum CosThetaStarType : uint8_t { Production, Beam, Random, + EP, NTypes }; enum DecayChannel : uint8_t { @@ -61,6 +86,11 @@ enum MassHyposLcToPKPi : uint8_t { PiKP, NMassHypoLcToPKPi }; +enum QvecEstimator : uint8_t { + FV0A = 0, + FT0M, + FT0C, +}; /// columns for table to study the Lc->PKPi background DECLARE_SOA_COLUMN(MassLc, massLc, float); @@ -79,6 +109,7 @@ DECLARE_SOA_COLUMN(IsRealPKPi, isRealPKPi, int8_t); DECLARE_SOA_COLUMN(IsRealLcPKPi, isRealLcPKPi, int8_t); DECLARE_SOA_COLUMN(IsReflected, isReflected, int8_t); DECLARE_SOA_COLUMN(Charge, charge, int8_t); +DECLARE_SOA_COLUMN(Origin, origin, int8_t); } // namespace charm_polarisation @@ -99,11 +130,12 @@ DECLARE_SOA_TABLE(HfLcPolBkg, "AOD", "HFLCPOLBKG", charm_polarisation::IsRealPKPi, charm_polarisation::IsRealLcPKPi, charm_polarisation::IsReflected, - charm_polarisation::Charge); + charm_polarisation::Charge, + charm_polarisation::Origin); } // namespace o2::aod -struct TaskPolarisationCharmHadrons { +struct HfTaskCharmPolarisation { Produces rowCandLcBkg; float massPi{0.f}; @@ -118,25 +150,11 @@ struct TaskPolarisationCharmHadrons { Configurable selectionFlagDstarToD0Pi{"selectionFlagDstarToD0Pi", true, "Selection Flag for D* decay to D0 Pi"}; Configurable selectionFlagLcToPKPi{"selectionFlagLcToPKPi", 1, "Selection Flag for Lc decay to P K Pi"}; - ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {200, 0.139f, 0.179f}, "#it{M} (GeV/#it{c}^{2})"}; - ConfigurableAxis configThnAxisPt{"configThnAxisPt", {100, 0.f, 100.f}, "#it{p}_{T} (GeV/#it{c})"}; - ConfigurableAxis configThnAxisY{"configThnAxisY", {20, -1.f, 1.f}, "#it{y}"}; - ConfigurableAxis configThnAxisCosThetaStarHelicity{"configThnAxisCosThetaStarHelicity", {20, -1.f, 1.f}, "cos(#vartheta_{helicity})"}; - ConfigurableAxis configThnAxisCosThetaStarProduction{"configThnAxisCosThetaStarProduction", {20, -1.f, 1.f}, "cos(#vartheta_{production})"}; - ConfigurableAxis configThnAxisCosThetaStarRandom{"configThnAxisCosThetaStarRandom", {20, -1.f, 1.f}, "cos(#vartheta_{random})"}; - ConfigurableAxis configThnAxisCosThetaStarBeam{"configThnAxisCosThetaStarBeam", {20, -1.f, 1.f}, "cos(#vartheta_{beam})"}; - ConfigurableAxis configThnAxisMlBkg{"configThnAxisMlBkg", {100, 0.f, 1.f}, "ML bkg"}; - ConfigurableAxis configThnAxisInvMassD0{"configThnAxisInvMassD0", {250, 1.65f, 2.15f}, "#it{M}(D^{0}) (GeV/#it{c}^{2})"}; // only for D*+ - ConfigurableAxis configThnAxisInvMassKPiLc{"configThnAxisInvMassKPiLc", {120, 0.65f, 1.25f}, "#it{M}(K#pi) from #Lambda_{c}^{+} (GeV/#it{c}^{2})"}; // only for Lc+->pKpi - // ConfigurableAxis configThnAxisMlPrompt{"configThnAxisMlPrompt", {100, 0.f, 1.f}, "ML prompt"}; - ConfigurableAxis configThnAxisMlNonPrompt{"configThnAxisMlNonPrompt", {100, 0.f, 1.f}, "ML non-prompt"}; - // ConfigurableAxis configThnAxisCent{"configThnAxisCent", {102, -1.f, 101.f}, "centrality (%)"}; - ConfigurableAxis configThnAxisNumPvContributors{"configThnAxisNumPvContributors", {300, -0.5f, 299.5f}, "num PV contributors"}; - ConfigurableAxis configThnAxisPtB{"configThnAxisPtB", {3000, 0.f, 300.f}, "#it{p}_{T}(B mother) (GeV/#it{c})"}; - ConfigurableAxis configThnAxisAbsEtaTrackMin{"configThnAxisEtaTrackMin", {3, 0.f, 0.3f}, "min |#it{#eta_{track}}|"}; - ConfigurableAxis configThnAxisNumItsClsMin{"configThnAxisNumItsClsMin", {4, 3.5f, 7.5f}, "min #it{N}_{cls ITS}"}; - ConfigurableAxis configThnAxisNumTpcClsMin{"configThnAxisNumTpcClsMin", {3, 79.5f, 140.5f}, "min #it{N}_{cls TPC}"}; - ConfigurableAxis configThnAxisCharge{"configThnAxisCharge", {2, -2.f, 2.f}, "electric charge"}; + // Configurable harmonic{"harmonic", 2, "harmonic number"}; + Configurable qVecDetector{"qVecDetector", 2, "Detector for Q vector estimation (FV0A: 0, FT0M: 1, FT0C: 2)"}; + Configurable centEstimator{"centEstimator", 2, "Centrality estimator ((None: 0, FT0C: 2, FT0M: 3))"}; + Configurable centralityMin{"centralityMin", 30, "Minimum centrality (0-100) to be considered in the analysis"}; + Configurable centralityMax{"centralityMax", 50, "Maximum centrality (0-100) to be considered in the analysis"}; /// activate rotational background Configurable nBkgRotations{"nBkgRotations", 0, "Number of rotated copies (background) per each original candidate"}; @@ -151,6 +169,8 @@ struct TaskPolarisationCharmHadrons { Configurable activateTHnSparseCosThStarProduction{"activateTHnSparseCosThStarProduction", true, "Activate the THnSparse with cosThStar w.r.t. production axis"}; Configurable activateTHnSparseCosThStarBeam{"activateTHnSparseCosThStarBeam", true, "Activate the THnSparse with cosThStar w.r.t. beam axis"}; Configurable activateTHnSparseCosThStarRandom{"activateTHnSparseCosThStarRandom", true, "Activate the THnSparse with cosThStar w.r.t. random axis"}; + Configurable activateTHnSparseCosThStarEP{"activateTHnSparseCosThStarEP", false, "Activate the THnSparse with cosThStar w.r.t. reaction plane axis"}; + Configurable activatePartRecoDstar{"activatePartRecoDstar", false, "Activate the study of partly reconstructed D*+ -> D0 (-> KPiPi0) Pi decays"}; float minInvMass{0.f}; float maxInvMass{1000.f}; @@ -176,7 +196,7 @@ struct TaskPolarisationCharmHadrons { struct : ConfigurableGroup { /// monitoring histograms (Dalitz plot) Configurable activateTHnLcChannelMonitor{"activateTHnLcChannelMonitor", false, "Flag to switch on the monitoring THnSparse of M2(Kpi), M2(pK), M2(ppi), pt correlation for Lc -> pKpi"}; - ConfigurableAxis configThnAxisInvMass2KPiLcMonitoring{"configThnAxisInvMassKPiLcMonitoring", {200, 0.3f, 2.3f}, "#it{M}^{2}(K#pi) from #Lambda_{c}^{+} (GeV/#it{c}^{2})"}; + ConfigurableAxis configThnAxisInvMass2KPiLcMonitoring{"configThnAxisInvMass2KPiLcMonitoring", {200, 0.3f, 2.3f}, "#it{M}^{2}(K#pi) from #Lambda_{c}^{+} (GeV/#it{c}^{2})"}; ConfigurableAxis configThnAxisInvMass2PKLcMonitoring{"configThnAxisInvMass2PKLcMonitoring", {320, 2.f, 5.2f}, "#it{M}^{2}(pK) from #Lambda_{c}^{+} (GeV/#it{c}^{2})"}; ConfigurableAxis configThnAxisInvMass2PPiLcMonitoring{"configThnAxisInvMass2PPiLcMonitoring", {400, 1.f, 5.f}, "#it{M}^{2}(p#pi) from #Lambda_{c}^{+} (GeV/#it{c}^{2})"}; @@ -189,15 +209,17 @@ struct TaskPolarisationCharmHadrons { /// Monitoring of phi Euler angle Configurable activateTHnEulerPhiMonitor{"activateTHnEulerPhiMonitor", false, "Flag to switch on the monitoring THnSparse vs. Euler angle phi (Lc -> pKpi)"}; - ConfigurableAxis configTHnAxisEulerPhi{"configTHnAxisEulerPhi", {24, -o2::constants::math::PI, o2::constants::math::PI}, "Euler polar angle #phi"}; /// Application of rapidity cut for reconstructed candidates Configurable rapidityCut{"rapidityCut", 999.f, "Max. value of reconstructed candidate rapidity (abs. value)"}; - Filter filterSelectDstarCandidates = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == selectionFlagDstarToD0Pi; - Filter filterSelectLcToPKPiCandidates = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLcToPKPi) || (aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLcToPKPi); + HfHelper hfHelper; + SliceCache cache; + EventPlaneHelper epHelper; using CollisionsWithMcLabels = soa::SmallGroups>; + using CollisionsWithMcLabelsAndCent = soa::SmallGroups>; + using CollsWithQVecs = soa::Join; using TracksWithMcLabels = soa::Join; using TracksWithExtra = soa::Join; @@ -217,7 +239,9 @@ struct TaskPolarisationCharmHadrons { using FilteredCandLcToPKPiWSelFlagAndMc = soa::Filtered>; using FilteredCandLcToPKPiWSelFlagAndMcAndMl = soa::Filtered>; - SliceCache cache; + Filter filterSelectDstarCandidates = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == selectionFlagDstarToD0Pi; + Filter filterSelectLcToPKPiCandidates = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLcToPKPi) || (aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLcToPKPi); + Preslice dstarPerCollision = aod::hf_cand::collisionId; Preslice dstarWithMlPerCollision = aod::hf_cand::collisionId; Preslice dstarWithMcPerCollision = aod::hf_cand::collisionId; @@ -228,13 +252,37 @@ struct TaskPolarisationCharmHadrons { Preslice lcToPKPiWithMcPerCollision = aod::hf_cand::collisionId; Preslice lcToPKPiWithMcAndMlPerCollision = aod::hf_cand::collisionId; - HfHelper hfHelper; + PresliceUnsorted colPerMcCollision = aod::mcparticle::mcCollisionId; + + ConfigurableAxis configTHnAxisEulerPhi{"configTHnAxisEulerPhi", {24, -o2::constants::math::PI, o2::constants::math::PI}, "Euler polar angle #phi"}; + ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {200, 0.139f, 0.179f}, "#it{M} (GeV/#it{c}^{2})"}; // o2-linter: disable=pdg/explicit-mass (false positive) + ConfigurableAxis configThnAxisPt{"configThnAxisPt", {100, 0.f, 100.f}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis configThnAxisY{"configThnAxisY", {20, -1.f, 1.f}, "#it{y}"}; + ConfigurableAxis configThnAxisCosThetaStarHelicity{"configThnAxisCosThetaStarHelicity", {20, -1.f, 1.f}, "cos(#vartheta_{helicity})"}; + ConfigurableAxis configThnAxisCosThetaStarProduction{"configThnAxisCosThetaStarProduction", {20, -1.f, 1.f}, "cos(#vartheta_{production})"}; + ConfigurableAxis configThnAxisCosThetaStarRandom{"configThnAxisCosThetaStarRandom", {20, -1.f, 1.f}, "cos(#vartheta_{random})"}; + ConfigurableAxis configThnAxisCosThetaStarBeam{"configThnAxisCosThetaStarBeam", {20, -1.f, 1.f}, "cos(#vartheta_{beam})"}; + ConfigurableAxis configThnAxisCosThetaStarEP{"configThnAxisCosThetaStarEP", {20, -1.f, 1.f}, "cos(#vartheta_{EP})"}; + ConfigurableAxis configThnAxisMlBkg{"configThnAxisMlBkg", {100, 0.f, 1.f}, "ML bkg"}; + ConfigurableAxis configThnAxisInvMassD0{"configThnAxisInvMassD0", {250, 1.65f, 2.15f}, "#it{M}(D^{0}) (GeV/#it{c}^{2})"}; // only for D*+ + ConfigurableAxis configThnAxisInvMassKPiLc{"configThnAxisInvMassKPiLc", {120, 0.65f, 1.25f}, "#it{M}(K#pi) from #Lambda_{c}^{+} (GeV/#it{c}^{2})"}; // only for Lc+->pKpi + // ConfigurableAxis configThnAxisMlPrompt{"configThnAxisMlPrompt", {100, 0.f, 1.f}, "ML prompt"}; + ConfigurableAxis configThnAxisMlNonPrompt{"configThnAxisMlNonPrompt", {100, 0.f, 1.f}, "ML non-prompt"}; + ConfigurableAxis configThnAxisCent{"configThnAxisCent", {102, -1.f, 101.f}, "centrality (%)"}; + ConfigurableAxis configThnAxisNumPvContributors{"configThnAxisNumPvContributors", {300, -0.5f, 299.5f}, "num PV contributors"}; + ConfigurableAxis configThnAxisPtB{"configThnAxisPtB", {3000, 0.f, 300.f}, "#it{p}_{T}(B mother) (GeV/#it{c})"}; + ConfigurableAxis configThnAxisAbsEtaTrackMin{"configThnAxisAbsEtaTrackMin", {3, 0.f, 0.3f}, "min |#it{#eta_{track}}|"}; + ConfigurableAxis configThnAxisNumItsClsMin{"configThnAxisNumItsClsMin", {4, 3.5f, 7.5f}, "min #it{N}_{cls ITS}"}; + ConfigurableAxis configThnAxisNumTpcClsMin{"configThnAxisNumTpcClsMin", {3, 79.5f, 140.5f}, "min #it{N}_{cls TPC}"}; + ConfigurableAxis configThnAxisCharge{"configThnAxisCharge", {2, -2.f, 2.f}, "electric charge"}; + ConfigurableAxis configThnAxisCentrality{"configThnAxisCentrality", {100, 0.f, 100.f}, "centrality (%)"}; + HistogramRegistry registry{"registry", {}}; void init(InitContext&) { /// check process functions - std::array processes = {doprocessDstar, doprocessDstarWithMl, doprocessLcToPKPi, doprocessLcToPKPiWithMl, doprocessDstarMc, doprocessDstarMcWithMl, doprocessLcToPKPiMc, doprocessLcToPKPiMcWithMl, doprocessLcToPKPiBackgroundMcWithMl}; + std::array processes = {doprocessDstar, doprocessDstarWithMl, doprocessLcToPKPi, doprocessLcToPKPiWithMl, doprocessDstarMc, doprocessDstarMcWithMl, doprocessLcToPKPiMc, doprocessLcToPKPiMcWithMl, doprocessLcToPKPiBackgroundMcWithMl, doprocessDstarInPbPb, doprocessDstarWithMlInPbPb, doprocessDstarMcInPbPb, doprocessDstarMcWithMlInPbPb}; const int nProcesses = std::accumulate(processes.begin(), processes.end(), 0); if (nProcesses > 1) { LOGP(fatal, "Only one process function should be enabled at a time, please check your configuration"); @@ -243,7 +291,7 @@ struct TaskPolarisationCharmHadrons { } /// check output THnSparses - std::array sparses = {activateTHnSparseCosThStarHelicity, activateTHnSparseCosThStarProduction, activateTHnSparseCosThStarBeam, activateTHnSparseCosThStarRandom}; + std::array sparses = {activateTHnSparseCosThStarHelicity, activateTHnSparseCosThStarProduction, activateTHnSparseCosThStarBeam, activateTHnSparseCosThStarRandom, activateTHnSparseCosThStarEP}; if (std::accumulate(sparses.begin(), sparses.end(), 0) == 0) { LOGP(fatal, "No output THnSparses enabled"); } else { @@ -259,10 +307,17 @@ struct TaskPolarisationCharmHadrons { if (activateTHnSparseCosThStarRandom) { LOGP(info, "THnSparse with cosThStar w.r.t. random axis active."); } + if (activateTHnSparseCosThStarEP) { + LOGP(info, "THnSparse with cosThStar w.r.t. event plane axis active."); + } + } + + if (activatePartRecoDstar && !(doprocessDstarMc || doprocessDstarMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb)) { + LOGP(fatal, "Check on partly reconstructed D* mesons only possible for processDstarMc and processDstarMcWithMl"); } // check bkg rotation for MC (not supported currently) - if (nBkgRotations > 0 && (doprocessDstarMc || doprocessDstarMcWithMl || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl)) { + if (nBkgRotations > 0 && (doprocessDstarMc || doprocessDstarMcWithMl || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb)) { LOGP(fatal, "No background rotation supported for MC."); } @@ -282,6 +337,7 @@ struct TaskPolarisationCharmHadrons { const AxisSpec thnAxisCosThetaStarProduction{configThnAxisCosThetaStarProduction, "cos(#vartheta_{production})"}; const AxisSpec thnAxisCosThetaStarRandom{configThnAxisCosThetaStarRandom, "cos(#vartheta_{random})"}; const AxisSpec thnAxisCosThetaStarBeam{configThnAxisCosThetaStarBeam, "cos(#vartheta_{beam})"}; + const AxisSpec thnAxisCosThetaStarEP{configThnAxisCosThetaStarEP, "cos(#vartheta_{EP})"}; // reaction plane const AxisSpec thnAxisMlBkg{configThnAxisMlBkg, "ML bkg"}; const AxisSpec thnAxisMlNonPrompt{configThnAxisMlNonPrompt, "ML non-prompt"}; const AxisSpec thnAxisIsRotatedCandidate{2, -0.5f, 1.5f, "rotated bkg"}; @@ -298,6 +354,7 @@ struct TaskPolarisationCharmHadrons { const AxisSpec thnAxisInvMass2PKLcMonitoring{lcPKPiChannels.configThnAxisInvMass2PKLcMonitoring, "#it{M}^{2}(pK) from #Lambda_{c}^{+} (GeV/#it{c}^{2})"}; const AxisSpec thnAxisInvMass2PPiLcMonitoring{lcPKPiChannels.configThnAxisInvMass2PPiLcMonitoring, "#it{M}^{2}(p#pi) from #Lambda_{c}^{+} (GeV/#it{c}^{2})"}; const AxisSpec thnAxisTHnAxisEulerPhi{configTHnAxisEulerPhi, "Euler polar angle #phi"}; + const AxisSpec thnAxisCentrality{configThnAxisCentrality, "centrality (%)"}; auto invMassBins = thnAxisInvMass.binEdges; minInvMass = invMassBins.front(); @@ -306,200 +363,305 @@ struct TaskPolarisationCharmHadrons { registry.add("hNumPvContributorsAll", "Number of PV contributors for all events ;num. PV contributors; counts", HistType::kTH1F, {thnAxisNumPvContributors}); registry.add("hNumPvContributorsCand", "Number of PV contributors for events with candidates;num. PV contributors; counts", HistType::kTH1F, {thnAxisNumPvContributors}); registry.add("hNumPvContributorsCandInMass", "Number of PV contributors for events with candidates in the signal region;num. PV contributors; counts", HistType::kTH1F, {thnAxisNumPvContributors}); + if (doprocessDstarInPbPb || doprocessDstarMcInPbPb || doprocessDstarWithMlInPbPb || doprocessDstarMcWithMlInPbPb) { + registry.add("hCentrality", "Centrality distribution for D*+ candidates;centrality (%); counts", HistType::kTH1D, {thnAxisCentrality}); + } - if (doprocessDstarWithMl || doprocessDstarMcWithMl) { - /// analysis for D*+ meson with ML, w/o rot. background axis - if (doprocessDstarWithMl) { - if (activateTHnSparseCosThStarHelicity) { - registry.add("hHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarHelicity, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate}); - } - if (activateTHnSparseCosThStarProduction) { - registry.add("hProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarProduction, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate}); - } - if (activateTHnSparseCosThStarBeam) { - registry.add("hBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarBeam, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate}); + if (activateTHnSparseCosThStarHelicity) { + std::vector hHelicityaxes = {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY}; + if (doprocessDstar || doprocessDstarMc || doprocessDstarWithMl || doprocessDstarMcWithMl || doprocessDstarInPbPb || doprocessDstarMcInPbPb || doprocessDstarWithMlInPbPb || doprocessDstarMcWithMlInPbPb) { + hHelicityaxes.insert(hHelicityaxes.end(), {thnAxisInvMassD0, thnAxisCosThetaStarHelicity}); + if (doprocessDstarWithMl || doprocessDstarMcWithMl || doprocessDstarWithMlInPbPb || doprocessDstarMcWithMlInPbPb) { + hHelicityaxes.insert(hHelicityaxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); + } + if (activateTrackingSys) { + hHelicityaxes.insert(hHelicityaxes.end(), {thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin}); + } + if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb) { + std::vector hRecoPromptHelicityAxes(hHelicityaxes); + hRecoPromptHelicityAxes.insert(hRecoPromptHelicityAxes.end(), {thnAxisDauToMuons}); + std::vector hRecoNonPromptHelicityAxes(hHelicityaxes); + hRecoNonPromptHelicityAxes.insert(hRecoNonPromptHelicityAxes.end(), {thnAxisDauToMuons, thnAxisPtB}); + registry.add("hRecoPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for reconstructed prompt D*+ candidates", HistType::kTHnSparseF, hRecoPromptHelicityAxes); + registry.add("hRecoNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for reconstructed non-prompt D*+ candidates", HistType::kTHnSparseF, hRecoNonPromptHelicityAxes); + if (activatePartRecoDstar) { + registry.add("hPartRecoPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for partially reconstructed prompt D*+ candidates", HistType::kTHnSparseF, hRecoPromptHelicityAxes); + registry.add("hPartRecoNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for partially reconstructed non-prompt D*+ candidates", HistType::kTHnSparseF, hRecoNonPromptHelicityAxes); + } + } else { + if (nBkgRotations > 0) { + hHelicityaxes.push_back(thnAxisIsRotatedCandidate); + } + registry.add("hHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores", HistType::kTHnSparseF, hHelicityaxes); } - if (activateTHnSparseCosThStarRandom) { - registry.add("hRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarRandom, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate}); + } else if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPi || doprocessLcToPKPiMc) { // Lc->pKpi + hHelicityaxes.insert(hHelicityaxes.end(), {thnAxisInvMassKPiLc, thnAxisCosThetaStarHelicity}); + if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { // Lc->pKpi with ML + hHelicityaxes.insert(hHelicityaxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); } - } else { - if (activateTHnSparseCosThStarHelicity) { - registry.add("hRecoPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarHelicity, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons}); - registry.add("hRecoNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarHelicity, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons, thnAxisPtB}); - } - if (activateTHnSparseCosThStarProduction) { - registry.add("hRecoPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarProduction, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons}); - registry.add("hRecoNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarProduction, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons, thnAxisPtB}); - } - if (activateTHnSparseCosThStarBeam) { - registry.add("hRecoPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarBeam, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons}); - registry.add("hRecoNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarBeam, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons, thnAxisPtB}); - } - if (activateTHnSparseCosThStarRandom) { - registry.add("hRecoPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarRandom, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons}); - registry.add("hRecoNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarRandom, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons, thnAxisPtB}); - } - } - } else if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { - /// analysis for Lc+ baryon with ML, w/ rot. background axis (for data only) - if (doprocessLcToPKPiWithMl) { - if (activateTHnSparseCosThStarHelicity) { - registry.add("hHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarHelicity, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hEulerPhiHelicity", "THn for polarisation studies with Euler phi w.r.t. helicity axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisCharge}); + if (doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { // Lc->pKpi MC + std::vector hRecoHelicityAxes(hHelicityaxes); + if (doprocessLcToPKPiMc) { // Lc->pKpi MC without ML, have one more axis for rotated candidates + hRecoHelicityAxes.insert(hRecoHelicityAxes.end(), {thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + } else { + hRecoHelicityAxes.insert(hRecoHelicityAxes.end(), {thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); } + registry.add("hRecoPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for reconstructed prompt Lc+ candidates", HistType::kTHnSparseF, hRecoHelicityAxes); + registry.add("hRecoNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for reconstructed non-prompt Lc+ candidates", HistType::kTHnSparseF, hRecoHelicityAxes); } - if (activateTHnSparseCosThStarProduction) { - registry.add("hProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarProduction, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hEulerPhiProduction", "THn for polarisation studies with Euler phi w.r.t. production axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisCharge}); + hHelicityaxes.insert(hHelicityaxes.end(), {thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + registry.add("hHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores", HistType::kTHnSparseF, hHelicityaxes); + + if (activateTHnEulerPhiMonitor) { + std::vector hEulerPhiAxes = {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi}; + if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + hEulerPhiAxes.insert(hEulerPhiAxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); } - } - if (activateTHnSparseCosThStarBeam) { - registry.add("hBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarBeam, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hEulerPhiBeam", "THn for polarisation studies with Euler phi w.r.t. beam axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisCharge}); + if (doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPiMc) { + hEulerPhiAxes.insert(hEulerPhiAxes.end(), {thnAxisResoChannelLc}); + } + hEulerPhiAxes.push_back(thnAxisCharge); + if (doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPiMc) { + registry.add("hRecPromptEulerPhiHelicity", "THn for polarisation studies with Euler phi w.r.t. helicity axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, hEulerPhiAxes); + registry.add("hRecNonPromptEulerPhiHelicity", "THn for polarisation studies with Euler phi w.r.t. helicity axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, hEulerPhiAxes); + } else { + registry.add("hEulerPhiHelicity", "THn for polarisation studies with Euler phi w.r.t. helicity axis", HistType::kTHnSparseF, hEulerPhiAxes); } } - if (activateTHnSparseCosThStarRandom) { - registry.add("hRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarRandom, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + } + if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + std::vector hgenPromptAxes = {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarHelicity, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}; + std::vector hgenNonPromptAxes = {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarHelicity, thnAxisPtB, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}; + registry.add("hGenPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for generated prompt D*+ candidates", HistType::kTHnSparseF, hgenPromptAxes); + registry.add("hGenNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for generated non-prompt D*+ candidates", HistType::kTHnSparseF, hgenNonPromptAxes); + if (activatePartRecoDstar) { + registry.add("hGenPartRecoPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for partially reconstructed generated prompt D*+ candidates", HistType::kTHnSparseF, hgenPromptAxes); + registry.add("hGenPartRecoNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores for partially reconstructed generated non-prompt D*+ candidates", HistType::kTHnSparseF, hgenNonPromptAxes); } - } else { - if (activateTHnSparseCosThStarHelicity) { - registry.add("hRecoPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarHelicity, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); - registry.add("hRecoNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarHelicity, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hRecPromptEulerPhiHelicity", "THn for polarisation studies with Euler phi w.r.t. helicity axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hRecNonPromptEulerPhiHelicity", "THn for polarisation studies with Euler phi w.r.t. helicity axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisCharge}); + } + } + + if (activateTHnSparseCosThStarProduction) { + std::vector hProductionaxes = {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY}; + if (doprocessDstar || doprocessDstarMc || doprocessDstarWithMl || doprocessDstarMcWithMl || doprocessDstarInPbPb || doprocessDstarMcInPbPb || doprocessDstarWithMlInPbPb || doprocessDstarMcWithMlInPbPb) { + + hProductionaxes.insert(hProductionaxes.end(), {thnAxisInvMassD0, thnAxisCosThetaStarProduction}); + if (doprocessDstarWithMl || doprocessDstarMcWithMl || doprocessDstarWithMlInPbPb || doprocessDstarMcWithMlInPbPb) { + hProductionaxes.insert(hProductionaxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); + } + if (activateTrackingSys) { + hProductionaxes.insert(hProductionaxes.end(), {thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin}); + } + if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb) { + std::vector hRecoPromptProductionAxes(hProductionaxes); + hRecoPromptProductionAxes.insert(hRecoPromptProductionAxes.end(), {thnAxisDauToMuons}); + std::vector hRecoNonPromptProductionAxes(hProductionaxes); + hRecoNonPromptProductionAxes.insert(hRecoNonPromptProductionAxes.end(), {thnAxisDauToMuons, thnAxisPtB}); + registry.add("hRecoPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for reconstructed prompt D*+ candidates", HistType::kTHnSparseF, hRecoPromptProductionAxes); + registry.add("hRecoNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for reconstructed non-prompt D*+ candidates", HistType::kTHnSparseF, hRecoNonPromptProductionAxes); + if (activatePartRecoDstar) { + registry.add("hPartRecoPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for partially reconstructed prompt D*+ candidates", HistType::kTHnSparseF, hRecoPromptProductionAxes); + registry.add("hPartRecoNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for partially reconstructed non-prompt D*+ candidates", HistType::kTHnSparseF, hRecoNonPromptProductionAxes); } - } - if (activateTHnSparseCosThStarProduction) { - registry.add("hRecoPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarProduction, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); - registry.add("hRecoNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarProduction, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hRecPromptEulerPhiProduction", "THn for polarisation studies with Euler phi w.r.t. production axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hRecNonPromptEulerPhiProduction", "THn for polarisation studies with Euler phi w.r.t. production axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisCharge}); + } else { + if (nBkgRotations > 0) { + hProductionaxes.push_back(thnAxisIsRotatedCandidate); } + registry.add("hProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores", HistType::kTHnSparseF, hProductionaxes); } - if (activateTHnSparseCosThStarBeam) { - registry.add("hRecoPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarBeam, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); - registry.add("hRecoNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarBeam, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hRecPromptEulerPhiBeam", "THn for polarisation studies with Euler phi w.r.t. beam axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hRecNonPromptEulerPhiBeam", "THn for polarisation studies with Euler phi w.r.t. beam axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisCharge}); - } + } else if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPi || doprocessLcToPKPiMc) { + hProductionaxes.insert(hProductionaxes.end(), {thnAxisInvMassKPiLc, thnAxisCosThetaStarProduction}); + if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + hProductionaxes.insert(hProductionaxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); } - if (activateTHnSparseCosThStarRandom) { - registry.add("hRecoPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarRandom, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); - registry.add("hRecoNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarRandom, thnAxisMlBkg, thnAxisMlNonPrompt, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); + if (doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + std::vector hRecoProductionAxes(hProductionaxes); + if (doprocessLcToPKPiMc) { + hRecoProductionAxes.insert(hRecoProductionAxes.end(), {thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + } else { + hRecoProductionAxes.insert(hRecoProductionAxes.end(), {thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); + } + registry.add("hRecoPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for reconstructed prompt Lc+ candidates", HistType::kTHnSparseF, hRecoProductionAxes); + registry.add("hRecoNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for reconstructed non-prompt Lc+ candidates", HistType::kTHnSparseF, hRecoProductionAxes); + } + hProductionaxes.insert(hProductionaxes.end(), {thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + registry.add("hProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores", HistType::kTHnSparseF, hProductionaxes); + if (activateTHnEulerPhiMonitor) { + std::vector hEulerPhiAxes = {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi}; + if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + hEulerPhiAxes.insert(hEulerPhiAxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); + } + if (doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPiMc) { + hEulerPhiAxes.insert(hEulerPhiAxes.end(), {thnAxisResoChannelLc}); + } + hEulerPhiAxes.push_back(thnAxisCharge); + if (doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPiMc) { + registry.add("hRecPromptEulerPhiProduction", "THn for polarisation studies with Euler phi w.r.t. production axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, hEulerPhiAxes); + registry.add("hRecNonPromptEulerPhiProduction", "THn for polarisation studies with Euler phi w.r.t. production axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, hEulerPhiAxes); + } else { + registry.add("hEulerPhiProduction", "THn for polarisation studies with Euler phi w.r.t. production axis", HistType::kTHnSparseF, hEulerPhiAxes); + } } } - } else if (doprocessDstar || doprocessDstarMc) { - /// analysis for D*+ meson, w/o rot. background axis - if (doprocessDstar) { - if (activateTHnSparseCosThStarHelicity) { - registry.add("hHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarHelicity, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate}); + if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + std::vector hgenPromptAxes = {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarProduction, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}; + std::vector hgenNonPromptAxes = {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarProduction, thnAxisPtB, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}; + registry.add("hGenPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for generated prompt D*+ candidates", HistType::kTHnSparseF, hgenPromptAxes); + registry.add("hGenNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for generated non-prompt D*+ candidates", HistType::kTHnSparseF, hgenNonPromptAxes); + if (activatePartRecoDstar) { + registry.add("hGenPartRecoPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for partially reconstructed generated prompt D*+ candidates", HistType::kTHnSparseF, hgenPromptAxes); + registry.add("hGenPartRecoNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis and BDT scores for partially reconstructed generated non-prompt D*+ candidates", HistType::kTHnSparseF, hgenNonPromptAxes); } - if (activateTHnSparseCosThStarProduction) { - registry.add("hProduction", "THn for polarisation studies with cosThStar w.r.t. production axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarProduction, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate}); - } - if (activateTHnSparseCosThStarBeam) { - registry.add("hBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarBeam, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate}); + } + } + + if (activateTHnSparseCosThStarBeam) { + std::vector hBeamaxes = {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY}; + if (doprocessDstar || doprocessDstarMc || doprocessDstarWithMl || doprocessDstarMcWithMl || doprocessDstarInPbPb || doprocessDstarMcInPbPb || doprocessDstarWithMlInPbPb || doprocessDstarMcWithMlInPbPb) { + hBeamaxes.insert(hBeamaxes.end(), {thnAxisInvMassD0, thnAxisCosThetaStarBeam}); + if (doprocessDstarWithMl || doprocessDstarMcWithMl || doprocessDstarWithMlInPbPb || doprocessDstarMcWithMlInPbPb) { + hBeamaxes.insert(hBeamaxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); + } + if (activateTrackingSys) { + hBeamaxes.insert(hBeamaxes.end(), {thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin}); + } + if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb) { + std::vector hRecoPromptBeamAxes(hBeamaxes); + hRecoPromptBeamAxes.insert(hRecoPromptBeamAxes.end(), {thnAxisDauToMuons}); + std::vector hRecoNonPromptBeamAxes(hBeamaxes); + hRecoNonPromptBeamAxes.insert(hRecoNonPromptBeamAxes.end(), {thnAxisDauToMuons, thnAxisPtB}); + registry.add("hRecoPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for reconstructed prompt D*+ candidates", HistType::kTHnSparseF, hRecoPromptBeamAxes); + registry.add("hRecoNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for reconstructed non-prompt D*+ candidates", HistType::kTHnSparseF, hRecoNonPromptBeamAxes); + if (activatePartRecoDstar) { + registry.add("hPartRecoPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for partially reconstructed prompt D*+ candidates", HistType::kTHnSparseF, hRecoPromptBeamAxes); + registry.add("hPartRecoNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for partially reconstructed non-prompt D*+ candidates", HistType::kTHnSparseF, hRecoNonPromptBeamAxes); + } + } else { + if (nBkgRotations > 0) { + hBeamaxes.push_back(thnAxisIsRotatedCandidate); + } + registry.add("hBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores", HistType::kTHnSparseF, hBeamaxes); } - if (activateTHnSparseCosThStarRandom) { - registry.add("hRandom", "THn for polarisation studies with cosThStar w.r.t. random axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarRandom, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate}); + } else if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPi || doprocessLcToPKPiMc) { + hBeamaxes.insert(hBeamaxes.end(), {thnAxisInvMassKPiLc, thnAxisCosThetaStarBeam}); + if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + hBeamaxes.insert(hBeamaxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); } - } else { - if (activateTHnSparseCosThStarHelicity) { - registry.add("hRecoPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarHelicity, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons}); - registry.add("hRecoNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarHelicity, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons, thnAxisPtB}); - } - if (activateTHnSparseCosThStarProduction) { - registry.add("hRecoPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarProduction, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons}); - registry.add("hRecoNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarProduction, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons, thnAxisPtB}); - } - if (activateTHnSparseCosThStarBeam) { - registry.add("hRecoPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarBeam, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons}); - registry.add("hRecoNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarBeam, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons, thnAxisPtB}); - } - if (activateTHnSparseCosThStarRandom) { - registry.add("hRecoPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarRandom, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons}); - registry.add("hRecoNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarRandom, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisDauToMuons, thnAxisPtB}); - } - } - } else if (doprocessLcToPKPi || doprocessLcToPKPiMc) { - /// analysis for Lc+ baryon, rot. background axis (for data only) - if (doprocessLcToPKPi) { - if (activateTHnSparseCosThStarHelicity) { - registry.add("hHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarHelicity, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hEulerPhiHelicity", "THn for polarisation studies with Euler phi w.r.t. helicity axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisCharge}); + if (doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + std::vector hRecoBeamAxes(hBeamaxes); + if (doprocessLcToPKPiMc) { + hRecoBeamAxes.insert(hRecoBeamAxes.end(), {thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + } else { + hRecoBeamAxes.insert(hRecoBeamAxes.end(), {thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); } - } - if (activateTHnSparseCosThStarProduction) { - registry.add("hProduction", "THn for polarisation studies with cosThStar w.r.t. production axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarProduction, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hEulerPhiProduction", "THn for polarisation studies with Euler phi w.r.t. helicity axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisCharge}); + registry.add("hRecoPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for reconstructed prompt Lc+ candidates", HistType::kTHnSparseF, hRecoBeamAxes); + registry.add("hRecoNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for reconstructed non-prompt Lc+ candidates", HistType::kTHnSparseF, hRecoBeamAxes); + } + hBeamaxes.insert(hBeamaxes.end(), {thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + registry.add("hBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores", HistType::kTHnSparseF, hBeamaxes); + if (activateTHnEulerPhiMonitor) { + std::vector hEulerPhiAxes = {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi}; + if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + hEulerPhiAxes.insert(hEulerPhiAxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); } - } - if (activateTHnSparseCosThStarBeam) { - registry.add("hBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarBeam, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hEulerPhiBeam", "THn for polarisation studies with Euler phi w.r.t. beam axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisCharge}); + if (doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPiMc) { + hEulerPhiAxes.insert(hEulerPhiAxes.end(), {thnAxisResoChannelLc}); + } + hEulerPhiAxes.push_back(thnAxisCharge); + if (doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPiMc) { + registry.add("hRecPromptEulerPhiBeam", "THn for polarisation studies with Euler phi w.r.t. beam axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, hEulerPhiAxes); + registry.add("hRecNonPromptEulerPhiBeam", "THn for polarisation studies with Euler phi w.r.t. beam axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, hEulerPhiAxes); + } else { + registry.add("hEulerPhiBeam", "THn for polarisation studies with Euler phi w.r.t. beam axis", HistType::kTHnSparseF, hEulerPhiAxes); } } - if (activateTHnSparseCosThStarRandom) { - registry.add("hRandom", "THn for polarisation studies with cosThStar w.r.t. random axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarRandom, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + } + if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + std::vector hgenPromptAxes = {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarBeam, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}; + std::vector hgenNonPromptAxes = {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarBeam, thnAxisPtB, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}; + registry.add("hGenPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for generated prompt D*+ candidates", HistType::kTHnSparseF, hgenPromptAxes); + registry.add("hGenNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for generated non-prompt D*+ candidates", HistType::kTHnSparseF, hgenNonPromptAxes); + if (activatePartRecoDstar) { + registry.add("hGenPartRecoPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for partially reconstructed generated prompt D*+ candidates", HistType::kTHnSparseF, hgenPromptAxes); + registry.add("hGenPartRecoNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis and BDT scores for partially reconstructed generated non-prompt D*+ candidates", HistType::kTHnSparseF, hgenNonPromptAxes); } - } else { - if (activateTHnSparseCosThStarHelicity) { - registry.add("hRecoPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarHelicity, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - registry.add("hRecoNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarHelicity, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hRecPromptEulerPhiHelicity", "THn for polarisation studies with Euler phi w.r.t. helicity axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hRecNonPromptEulerPhiHelicity", "THn for polarisation studies with Euler phi w.r.t. helicity axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisResoChannelLc, thnAxisCharge}); + } + } + + if (activateTHnSparseCosThStarRandom) { + std::vector hRandomaxes = {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY}; + if (doprocessDstar || doprocessDstarMc || doprocessDstarWithMl || doprocessDstarMcWithMl || doprocessDstarInPbPb || doprocessDstarMcInPbPb || doprocessDstarWithMlInPbPb || doprocessDstarMcWithMlInPbPb) { + + hRandomaxes.insert(hRandomaxes.end(), {thnAxisInvMassD0, thnAxisCosThetaStarRandom}); + if (doprocessDstarWithMl || doprocessDstarMcWithMl || doprocessDstarWithMlInPbPb || doprocessDstarMcWithMlInPbPb) { + hRandomaxes.insert(hRandomaxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); + } + if (activateTrackingSys) { + hRandomaxes.insert(hRandomaxes.end(), {thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin}); + } + if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb) { + std::vector hRecoPromptRandomAxes(hRandomaxes); + hRecoPromptRandomAxes.insert(hRecoPromptRandomAxes.end(), {thnAxisDauToMuons}); + std::vector hRecoNonPromptRandomAxes(hRandomaxes); + hRecoNonPromptRandomAxes.insert(hRecoNonPromptRandomAxes.end(), {thnAxisDauToMuons, thnAxisPtB}); + registry.add("hRecoPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for reconstructed prompt D*+ candidates", HistType::kTHnSparseF, hRecoPromptRandomAxes); + registry.add("hRecoNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for reconstructed non-prompt D*+ candidates", HistType::kTHnSparseF, hRecoNonPromptRandomAxes); + if (activatePartRecoDstar) { + registry.add("hPartRecoPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for partially reconstructed prompt D*+ candidates", HistType::kTHnSparseF, hRecoPromptRandomAxes); + registry.add("hPartRecoNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for partially reconstructed non-prompt D*+ candidates", HistType::kTHnSparseF, hRecoNonPromptRandomAxes); } - } - if (activateTHnSparseCosThStarProduction) { - registry.add("hRecoPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarProduction, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - registry.add("hRecoNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarProduction, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hRecPromptEulerPhiProduction", "THn for polarisation studies with Euler phi w.r.t. production axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hRecNonPromptEulerPhiProduction", "THn for polarisation studies with Euler phi w.r.t. production axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisResoChannelLc, thnAxisCharge}); + } else { + if (nBkgRotations > 0) { + hRandomaxes.push_back(thnAxisIsRotatedCandidate); } + registry.add("hRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores", HistType::kTHnSparseF, hRandomaxes); + } + } else if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl || doprocessLcToPKPi || doprocessLcToPKPiMc) { + hRandomaxes.insert(hRandomaxes.end(), {thnAxisInvMassKPiLc, thnAxisCosThetaStarRandom}); + if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + hRandomaxes.insert(hRandomaxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); } - if (activateTHnSparseCosThStarBeam) { - registry.add("hRecoPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarBeam, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - registry.add("hRecoNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarBeam, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - if (activateTHnEulerPhiMonitor) { - registry.add("hRecPromptEulerPhiBeam", "THn for polarisation studies with Euler phi w.r.t. beam axis and BDT scores -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hRecNonPromptEulerPhiBeam", "THn for polarisation studies with Euler phi w.r.t. beam axis and BDT scores -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisInvMassKPiLc, thnAxisTHnAxisEulerPhi, thnAxisResoChannelLc, thnAxisCharge}); + if (doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + std::vector hRecoRandomAxes(hRandomaxes); + if (doprocessLcToPKPiMc) { + hRecoRandomAxes.insert(hRecoRandomAxes.end(), {thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + } else { + hRecoRandomAxes.insert(hRecoRandomAxes.end(), {thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisCharge}); } + registry.add("hRecoPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for reconstructed prompt Lc+ candidates", HistType::kTHnSparseF, hRecoRandomAxes); + registry.add("hRecoNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for reconstructed non-prompt Lc+ candidates", HistType::kTHnSparseF, hRecoRandomAxes); } - if (activateTHnSparseCosThStarRandom) { - registry.add("hRecoPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis -- reco prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarRandom, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); - registry.add("hRecoNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis -- reco non-prompt signal", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarRandom, thnAxisResoChannelLc, thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + hRandomaxes.insert(hRandomaxes.end(), {thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin, thnAxisIsRotatedCandidate, thnAxisCharge}); + registry.add("hRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores", HistType::kTHnSparseF, hRandomaxes); + } + if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessDstarMcInPbPb || doprocessDstarMcWithMlInPbPb || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { + std::vector hgenPromptAxes = {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarRandom, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}; + std::vector hgenNonPromptAxes = {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarRandom, thnAxisPtB, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}; + registry.add("hGenPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for generated prompt D*+ candidates", HistType::kTHnSparseF, hgenPromptAxes); + registry.add("hGenNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for generated non-prompt D*+ candidates", HistType::kTHnSparseF, hgenNonPromptAxes); + if (activatePartRecoDstar) { + registry.add("hGenPartRecoPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for partially reconstructed generated prompt D*+ candidates", HistType::kTHnSparseF, hgenPromptAxes); + registry.add("hGenPartRecoNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis and BDT scores for partially reconstructed generated non-prompt D*+ candidates", HistType::kTHnSparseF, hgenNonPromptAxes); } } } - // MC Gen histos - if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl) { - if (activateTHnSparseCosThStarHelicity) { - registry.add("hGenPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis -- gen prompt signal", HistType::kTHnSparseF, {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarHelicity, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hGenNonPromptHelicity", "THn for polarisation studies with cosThStar w.r.t. helicity axis -- gen non-prompt signal", HistType::kTHnSparseF, {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarHelicity, thnAxisPtB, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}); - } - if (activateTHnSparseCosThStarProduction) { - registry.add("hGenPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis -- gen prompt signal", HistType::kTHnSparseF, {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarProduction, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hGenNonPromptProduction", "THn for polarisation studies with cosThStar w.r.t. production axis -- gen non-prompt signal", HistType::kTHnSparseF, {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarProduction, thnAxisPtB, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}); - } - if (activateTHnSparseCosThStarBeam) { - registry.add("hGenPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis -- gen prompt signal", HistType::kTHnSparseF, {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarBeam, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hGenNonPromptBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis -- gen non-prompt signal", HistType::kTHnSparseF, {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarBeam, thnAxisPtB, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}); - } - if (activateTHnSparseCosThStarRandom) { - registry.add("hGenPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis -- gen prompt signal", HistType::kTHnSparseF, {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarRandom, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}); - registry.add("hGenNonPromptRandom", "THn for polarisation studies with cosThStar w.r.t. random axis -- gen non-prompt signal", HistType::kTHnSparseF, {thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisCosThetaStarRandom, thnAxisPtB, thnAxisDausAcc, thnAxisResoChannelLc, thnAxisCharge}); + if (activateTHnSparseCosThStarEP && !(doprocessDstarInPbPb || doprocessDstarWithMlInPbPb)) { + LOGP(fatal, "THnSparse with cosThStar w.r.t. event plane axis is not supported for pp analysis, please check the configuration!"); + } else if (activateTHnSparseCosThStarEP) { + std::vector hEPaxes = {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY}; + if (doprocessDstarInPbPb || doprocessDstarWithMlInPbPb) { + hEPaxes.insert(hEPaxes.end(), {thnAxisInvMassD0, thnAxisCosThetaStarEP}); + if (doprocessDstarWithMlInPbPb) { + hEPaxes.insert(hEPaxes.end(), {thnAxisMlBkg, thnAxisMlNonPrompt}); + } + if (activateTrackingSys) { + hEPaxes.insert(hEPaxes.end(), {thnAxisAbsEtaTrackMin, thnAxisNumItsClsMin, thnAxisNumTpcClsMin}); + } + if (nBkgRotations > 0) { + hEPaxes.push_back(thnAxisIsRotatedCandidate); + } + registry.add("hEP", "THn for polarisation studies with cosThStar w.r.t. event plane axis and BDT scores", HistType::kTHnSparseF, hEPaxes); } } @@ -536,14 +698,29 @@ struct TaskPolarisationCharmHadrons { /// \param absEtaMin is the minimum absolute eta of the daughter tracks /// \param numItsClsMin is the minimum number of ITS clusters of the daughter tracks /// \param numTpcClsMin is the minimum number of TPC clusters of the daughter tracks + /// \param charge is the charge of the hadron + /// \param nMuons is the number of muons from daughter decays + /// \param isPartRecoDstar is a flag indicating if it is a partly reconstructed Dstar meson (MC only) template - void fillRecoHistos(float invMassCharmHad, float ptCharmHad, int numPvContributors, float rapCharmHad, float invMassD0, float invMassKPiLc, float cosThetaStar, float phiEuler, std::array outputMl, int isRotatedCandidate, int8_t origin, float ptBhadMother, int8_t resoChannelLc, float absEtaMin, int numItsClsMin, int numTpcClsMin, int8_t charge, int8_t nMuons) + void fillRecoHistos(float invMassCharmHad, float ptCharmHad, int numPvContributors, float rapCharmHad, float invMassD0, float invMassKPiLc, float cosThetaStar, float phiEuler, std::array outputMl, int isRotatedCandidate, int8_t origin, float ptBhadMother, int8_t resoChannelLc, float absEtaMin, int numItsClsMin, int numTpcClsMin, int8_t charge, int8_t nMuons, bool isPartRecoDstar) { if constexpr (cosThetaStarType == charm_polarisation::CosThetaStarType::Helicity) { // Helicity if constexpr (!doMc) { // data if constexpr (withMl) { // with ML - if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + } else { + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2]); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); if (activateTHnEulerPhiMonitor) { @@ -552,7 +729,19 @@ struct TaskPolarisationCharmHadrons { } } else { // without ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, isRotatedCandidate); + } else { + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); if (activateTHnEulerPhiMonitor) { @@ -564,7 +753,19 @@ struct TaskPolarisationCharmHadrons { if constexpr (withMl) { // with ML if (origin == RecoDecay::OriginType::Prompt) { // prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } else { + registry.fill(HIST("hPartRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -573,7 +774,19 @@ struct TaskPolarisationCharmHadrons { } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -584,7 +797,19 @@ struct TaskPolarisationCharmHadrons { } else { // without ML if (origin == RecoDecay::OriginType::Prompt) { // prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -593,7 +818,19 @@ struct TaskPolarisationCharmHadrons { } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons, ptBhadMother); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -607,7 +844,19 @@ struct TaskPolarisationCharmHadrons { if constexpr (!doMc) { // data if constexpr (withMl) { // with ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + } else { + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2]); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); if (activateTHnEulerPhiMonitor) { @@ -616,7 +865,19 @@ struct TaskPolarisationCharmHadrons { } } else { // without ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, isRotatedCandidate); + } else { + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); if (activateTHnEulerPhiMonitor) { @@ -628,7 +889,19 @@ struct TaskPolarisationCharmHadrons { if constexpr (withMl) { // with ML if (origin == RecoDecay::OriginType::Prompt) { // prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } else { + registry.fill(HIST("hPartRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -637,7 +910,19 @@ struct TaskPolarisationCharmHadrons { } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -648,7 +933,19 @@ struct TaskPolarisationCharmHadrons { } else { // without ML if (origin == RecoDecay::OriginType::Prompt) { // prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -657,7 +954,19 @@ struct TaskPolarisationCharmHadrons { } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons, ptBhadMother); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -671,7 +980,19 @@ struct TaskPolarisationCharmHadrons { if constexpr (!doMc) { // data if constexpr (withMl) { // with ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + } else { + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2]); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); if (activateTHnEulerPhiMonitor) { @@ -680,7 +1001,19 @@ struct TaskPolarisationCharmHadrons { } } else { // without ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, isRotatedCandidate); + } else { + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); if (activateTHnEulerPhiMonitor) { @@ -692,7 +1025,19 @@ struct TaskPolarisationCharmHadrons { if constexpr (withMl) { // with ML if (origin == RecoDecay::OriginType::Prompt) { // prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } else { + registry.fill(HIST("hPartRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -701,7 +1046,19 @@ struct TaskPolarisationCharmHadrons { } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -712,7 +1069,19 @@ struct TaskPolarisationCharmHadrons { } else { // without ML if (origin == RecoDecay::OriginType::Prompt) { // prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -721,7 +1090,19 @@ struct TaskPolarisationCharmHadrons { } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, nMuons, ptBhadMother); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); if (activateTHnEulerPhiMonitor) { @@ -735,13 +1116,37 @@ struct TaskPolarisationCharmHadrons { if constexpr (!doMc) { // data if constexpr (withMl) { // with ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + } else { + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2]); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); } } else { // without ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, isRotatedCandidate); + } else { + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); } @@ -750,13 +1155,37 @@ struct TaskPolarisationCharmHadrons { if constexpr (withMl) { // with ML if (origin == RecoDecay::OriginType::Prompt) { // prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } else { + registry.fill(HIST("hPartRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); } @@ -764,19 +1193,99 @@ struct TaskPolarisationCharmHadrons { } else { // without ML if (origin == RecoDecay::OriginType::Prompt) { // prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); } } } } + } else if constexpr (cosThetaStarType == charm_polarisation::CosThetaStarType::EP) { // EP + if constexpr (!doMc) { // data + if constexpr (withMl) { // with ML + if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hEP"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hEP"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hEP"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + } else { + registry.fill(HIST("hEP"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2]); + } + } + } + } else { + if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ + if (activateTrackingSys) { + if (nBkgRotations > 0) { + registry.fill(HIST("hEP"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); + } else { + registry.fill(HIST("hEP"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin); + } + } else { + if (nBkgRotations > 0) { + registry.fill(HIST("hEP"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, isRotatedCandidate); + } else { + registry.fill(HIST("hEP"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar); + } + } + } + } + } else { + if constexpr (withMl) { // with ML + if (origin == RecoDecay::OriginType::Prompt) { // prompt + if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptEP"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } else { + registry.fill(HIST("hPartRecoPromptEP"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoPromptEP"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } else { + registry.fill(HIST("hPartRecoPromptEP"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons); + } + } + } + } else { // non-prompt + if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ + if (activateTrackingSys) { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptEP"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptEP"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, nMuons, ptBhadMother); + } + } else { + if (!isPartRecoDstar) { + registry.fill(HIST("hRecoNonPromptEP"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } else { + registry.fill(HIST("hPartRecoNonPromptEP"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], nMuons, ptBhadMother); + } + } + } + } + } + } } } @@ -788,32 +1297,79 @@ struct TaskPolarisationCharmHadrons { /// \param ptBhadMother is the pt of the b-hadron mother (only in case of non-prompt) /// \param areDausInAcc is a flag indicating whether the daughters are in acceptance or not /// \param resoChannelLc indicates the Lc decay channel (direct, resonant) + /// \param isPartRecoDstar is a flag indicating if it is a partly reconstructed Dstar->D0pi->Kpipipi0 meson (MC only) template - void fillGenHistos(float ptCharmHad, int numPvContributors, float rapCharmHad, float cosThetaStar, int8_t origin, float ptBhadMother, bool areDausInAcc, uint8_t resoChannelLc, int8_t charge) + void fillGenHistos(float ptCharmHad, int numPvContributors, float rapCharmHad, float cosThetaStar, int8_t origin, float ptBhadMother, bool areDausInAcc, uint8_t resoChannelLc, int8_t charge, bool isPartRecoDstar) { if constexpr (cosThetaStarType == charm_polarisation::CosThetaStarType::Helicity) { // Helicity if (origin == RecoDecay::OriginType::Prompt) { // prompt - registry.fill(HIST("hGenPromptHelicity"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + if (!isPartRecoDstar) { + registry.fill(HIST("hGenPromptHelicity"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoPromptHelicity"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } } else { // non-prompt - registry.fill(HIST("hGenNonPromptHelicity"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + if (!isPartRecoDstar) { + registry.fill(HIST("hGenNonPromptHelicity"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoNonPromptHelicity"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } } } else if constexpr (cosThetaStarType == charm_polarisation::CosThetaStarType::Production) { // Production if (origin == RecoDecay::OriginType::Prompt) { // prompt - registry.fill(HIST("hGenPromptProduction"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + if (!isPartRecoDstar) { + registry.fill(HIST("hGenPromptProduction"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoPromptProduction"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } } else { // non-prompt - registry.fill(HIST("hGenNonPromptProduction"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + if (!isPartRecoDstar) { + registry.fill(HIST("hGenNonPromptProduction"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoNonPromptProduction"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } } } else if constexpr (cosThetaStarType == charm_polarisation::CosThetaStarType::Beam) { // Beam if (origin == RecoDecay::OriginType::Prompt) { // prompt - registry.fill(HIST("hGenPromptBeam"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + if (!isPartRecoDstar) { + registry.fill(HIST("hGenPromptBeam"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoPromptBeam"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } } else { // non-prompt - registry.fill(HIST("hGenNonPromptBeam"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + if (!isPartRecoDstar) { + registry.fill(HIST("hGenNonPromptBeam"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoNonPromptBeam"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } } } else if constexpr (cosThetaStarType == charm_polarisation::CosThetaStarType::Random) { // Random if (origin == RecoDecay::OriginType::Prompt) { // prompt - registry.fill(HIST("hGenPromptRandom"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + if (!isPartRecoDstar) { + registry.fill(HIST("hGenPromptRandom"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoPromptRandom"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } } else { // non-prompt - registry.fill(HIST("hGenNonPromptRandom"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + if (!isPartRecoDstar) { + registry.fill(HIST("hGenNonPromptRandom"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoNonPromptRandom"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } + } + } else if constexpr (cosThetaStarType == charm_polarisation::CosThetaStarType::EP) { // EP + if (origin == RecoDecay::OriginType::Prompt) { // prompt + if (!isPartRecoDstar) { + registry.fill(HIST("hGenPromptEP"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoPromptEP"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); + } + } else { // non-prompt + if (!isPartRecoDstar) { + registry.fill(HIST("hGenNonPromptEP"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } else { + registry.fill(HIST("hGenPartRecoNonPromptEP"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); + } } } } @@ -837,12 +1393,18 @@ struct TaskPolarisationCharmHadrons { template bool isInSignalRegion(float invMass) { + float invMassMin = 0.f; + float invMassMax = 100.f; if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - if (0.142f < invMass && invMass < 0.15f) { + invMassMin = 0.142f; + invMassMax = 0.15f; + if (invMassMin < invMass && invMass < invMassMax) { return true; } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ (to be tuned!) - if (2.25f < invMass && invMass < 2.35f) { + invMassMin = 2.25f; + invMassMax = 2.35f; + if (invMassMin < invMass && invMass < invMassMax) { return true; } } @@ -913,36 +1475,75 @@ struct TaskPolarisationCharmHadrons { } } + /// Get the Q vector + /// \param collision is the collision with the Q vector information + template + std::vector getQVec(Coll const& collision) + { + float xQVec = -999.; + float yQVec = -999.; + float amplQVec = -999.; + switch (qVecDetector) { + case charm_polarisation::QvecEstimator::FV0A: + xQVec = collision.qvecFV0ARe(); + yQVec = collision.qvecFV0AIm(); + break; + case charm_polarisation::QvecEstimator::FT0M: + xQVec = collision.qvecFT0MRe(); + yQVec = collision.qvecFT0MIm(); + break; + case charm_polarisation::QvecEstimator::FT0C: + xQVec = collision.qvecFT0CRe(); + yQVec = collision.qvecFT0CIm(); + break; + default: + LOG(warning) << "Q vector estimator not valid. Please choose between FV0A, FT0M, FT0A, FT0C, TPC Pos, TPC Neg. Fallback to FV0A"; + xQVec = collision.qvecFV0ARe(); + yQVec = collision.qvecFV0AIm(); + break; + } + return {xQVec, yQVec, amplQVec}; + } + /// \param candidates are the selected candidates /// \param bkgRotationId is the id for the background rotation /// \param numPvContributors is the number of PV contributors /// \param particles are the generated particles /// \param tracks are the reconstructed tracks /// \return true if candidate in signal region - template - bool runPolarisationAnalysis(Cand const& candidate, int bkgRotationId, int numPvContributors, Part const& particles, Trk const& /*tracks*/) + template + bool runPolarisationAnalysis(Cand const& candidate, int bkgRotationId, int numPvContributors, Part const& particles, Trk const& /*tracks*/, QVecs const* qVecs = nullptr) { + if constexpr (withEP) { + assert(qVecs && "EP analysis requested but qVecs == nullptr"); + } + + constexpr std::size_t NScores{3u}; + bool isCandidateInSignalRegion{false}; int8_t origin{RecoDecay::OriginType::None}; int8_t massHypoMcTruth{-1}; float ptBhadMother{-1.f}; int8_t resoChannelLc = -1; int8_t charge = -99; + bool partRecoDstar{false}; if constexpr (doMc) { if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { - if (!TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_dstar::DecayType::DstarToD0Pi)) { // this candidate is not signal, skip + partRecoDstar = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPiPi0 && std::abs(candidate.flagMcMatchRecD0()) == hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiKPi0; + bool signalDstar = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi && std::abs(candidate.flagMcMatchRecD0()) == hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; + if (!signalDstar && (!partRecoDstar || !activatePartRecoDstar)) { // this candidate is not signal and not partially reconstructed signal, skip return isCandidateInSignalRegion; } origin = candidate.originMcRec(); ptBhadMother = candidate.ptBhadMotherPart(); int pdgBhadMother = candidate.pdgBhadMotherPart(); // For unknown reasons there are charm hadrons coming directly from beauty diquarks without an intermediate B-hadron which have an unreasonable correlation between the pT of the charm hadron and the beauty mother. We also remove charm hadrons from quarkonia. - if (origin == RecoDecay::OriginType::NonPrompt && (pdgBhadMother == 5101 || pdgBhadMother == 5103 || pdgBhadMother == 5201 || pdgBhadMother == 5203 || pdgBhadMother == 5301 || pdgBhadMother == 5303 || pdgBhadMother == 5401 || pdgBhadMother == 5403 || pdgBhadMother == 5503 || pdgBhadMother == 553 || pdgBhadMother == 555 || pdgBhadMother == 553 || pdgBhadMother == 557)) { + if (origin == RecoDecay::OriginType::NonPrompt && (pdgBhadMother == 5101 || pdgBhadMother == 5103 || pdgBhadMother == 5201 || pdgBhadMother == 5203 || pdgBhadMother == 5301 || pdgBhadMother == 5303 || pdgBhadMother == 5401 || pdgBhadMother == 5403 || pdgBhadMother == 5503 || pdgBhadMother == 553 || pdgBhadMother == 555 || pdgBhadMother == 553 || pdgBhadMother == 557)) { // o2-linter: disable=pdg/explicit-code, magic-number (constants not in the PDG header) return isCandidateInSignalRegion; } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { - if constexpr (!studyLcPKPiBkgMc) { // skip this if studyLcPKPiBkgMc is true, since we are interested in background - if (!TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::LcToPKPi)) { // this candidate is not signal, skip + if constexpr (!studyLcPKPiBkgMc) { // skip this if studyLcPKPiBkgMc is true, since we are interested in background + if (std::abs(candidate.flagMcMatchRec()) != hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { // this candidate is not signal, skip return isCandidateInSignalRegion; } origin = candidate.originMcRec(); @@ -1083,7 +1684,7 @@ struct TaskPolarisationCharmHadrons { invMassCharmHadForSparse = hfHelper.invMassLcToPKPi(candidate); } if constexpr (withMl) { - if (candidate.mlProbLcToPKPi().size() == 3) { + if (candidate.mlProbLcToPKPi().size() == NScores) { // protect from empty vectors // the BDT output score might be empty if no preselections were enabled (selectionFlag null) // !!! NB: each rotated candidates inherits the BDT scores of the original candidate, even if the candidate pt changed after the rotation of the kaon-track pt !!! @@ -1117,7 +1718,7 @@ struct TaskPolarisationCharmHadrons { invMassCharmHadForSparse = hfHelper.invMassLcToPiKP(candidate); } if constexpr (withMl) { - if (candidate.mlProbLcToPiKP().size() == 3) { + if (candidate.mlProbLcToPiKP().size() == NScores) { // protect from empty vectors // the BDT output score might be empty if no preselections were enabled (selectionFlag null) // !!! NB: each rotated candidates inherits the BDT scores of the original candidate, even if the candidate pt changed after the rotation of the kaon-track pt !!! @@ -1228,29 +1829,44 @@ struct TaskPolarisationCharmHadrons { nMuons = candidate.nTracksDecayed(); } + if constexpr (withEP && !doMc) { + /// EP analysis + float xQvec = (*qVecs).at(0); + float yQvec = (*qVecs).at(1); + ROOT::Math::XYZVector qVecNorm = ROOT::Math::XYZVector(yQvec, -xQvec, 0.f); + float cosThetaStarEP = -10.f; + float phiEP = -99.f; + + if (activateTHnSparseCosThStarEP) { + // EP + cosThetaStarEP = qVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(qVecNorm.Mag2()); + fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarEP, phiEP, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge, nMuons, partRecoDstar); + } + } + if (activateTHnSparseCosThStarHelicity) { // helicity cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(helicityVec.Mag2()); phiHelicity = std::atan2(beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()), normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2()))); - fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarHelicity, phiHelicity, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge, nMuons); + fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarHelicity, phiHelicity, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge, nMuons, partRecoDstar); } if (activateTHnSparseCosThStarProduction) { // production cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(normalVec.Mag2()); phiProduction = std::atan2(normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())), helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2()))); - fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarProduction, phiProduction, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge, nMuons); + fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarProduction, phiProduction, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge, nMuons, partRecoDstar); } if (activateTHnSparseCosThStarBeam) { // beam cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); phiBeam = std::atan2(helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())), beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2())); - fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarBeam, phiBeam, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge, nMuons); + fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarBeam, phiBeam, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge, nMuons, partRecoDstar); } if (activateTHnSparseCosThStarRandom) { // random ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarRandom, -99.f, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge, nMuons); + fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarRandom, -99.f, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge, nMuons, partRecoDstar); } /// Table for Lc->pKpi background studies @@ -1281,23 +1897,32 @@ struct TaskPolarisationCharmHadrons { int pdgProng0 = 0; int pdgProng1 = 0; int pdgProng2 = 0; + int8_t originProng0 = -1; + int8_t originProng1 = -1; + int8_t originProng2 = -1; + std::vector idxBhadMothersProng0{}; + std::vector idxBhadMothersProng1{}; + std::vector idxBhadMothersProng2{}; if (trackProng0.has_mcParticle()) { /// BEWARE: even when grouping by mcCollision, mcParticle_as<> gets the mcParticle even if it belongs to a different mcCollision /// because _as<> works with unbound tables. (*) auto particleProng0 = trackProng0.template mcParticle_as(); pdgProng0 = particleProng0.pdgCode(); + originProng0 = RecoDecay::getCharmHadronOrigin(particles, particleProng0, false, &idxBhadMothersProng0); } if (trackProng1.has_mcParticle()) { /// BEWARE: even when grouping by mcCollision, mcParticle_as<> gets the mcParticle even if it belongs to a different mcCollision /// because _as<> works with unbound tables. (*) auto particleProng1 = trackProng1.template mcParticle_as(); pdgProng1 = particleProng1.pdgCode(); + originProng1 = RecoDecay::getCharmHadronOrigin(particles, particleProng1, false, &idxBhadMothersProng1); } if (trackProng2.has_mcParticle()) { /// BEWARE: even when grouping by mcCollision, mcParticle_as<> gets the mcParticle even if it belongs to a different mcCollision /// because _as<> works with unbound tables. (*) auto particleProng2 = trackProng2.template mcParticle_as(); pdgProng2 = particleProng2.pdgCode(); + originProng2 = RecoDecay::getCharmHadronOrigin(particles, particleProng2, false, &idxBhadMothersProng2); } isGenPKPi = std::abs(pdgProng0) == kProton && std::abs(pdgProng1) == kKPlus && std::abs(pdgProng2) == kPiPlus; isGenPiKP = std::abs(pdgProng0) == kPiPlus && std::abs(pdgProng1) == kKPlus && std::abs(pdgProng2) == kProton; @@ -1312,9 +1937,29 @@ struct TaskPolarisationCharmHadrons { isReflected = 1; } + /// check the origin (prompt, non-prompt of the triplet) + /// need to check each prong, since they might come from combinatorial background + /// convention: + /// - all 3 prongs from the same B hadron: non-prompt + /// - all 3 prongs claimed to be prompt: prompt --> check on same charm mother done offline with prong PDG daughters (more difficult for beauty, due to more intermediate resonances) and checking that the distribution peaks somehow (otherwise: combinatorial background) + /// - otherwise: none + int8_t originTriplet = RecoDecay::OriginType::None; + if (originProng0 == RecoDecay::OriginType::Prompt && originProng1 == RecoDecay::OriginType::Prompt && originProng2 == RecoDecay::OriginType::Prompt) { + /// we claim this triplet as prong w/o checking if all triplets have the same mother + originTriplet = RecoDecay::OriginType::Prompt; + } else if (originProng0 == RecoDecay::OriginType::NonPrompt && originProng1 == RecoDecay::OriginType::NonPrompt && originProng2 == RecoDecay::OriginType::NonPrompt) { + /// check if the three particles share the same B-hadron id. If yes: claim the triplet as "non-prompt" + int idBMotherProng0 = idxBhadMothersProng0.at(0); + int idBMotherProng1 = idxBhadMothersProng1.at(0); + int idBMotherProng2 = idxBhadMothersProng2.at(0); + if (idBMotherProng0 == idBMotherProng1 && idBMotherProng1 == idBMotherProng2) { + originTriplet = RecoDecay::OriginType::NonPrompt; + } + } + /// check if the pKpi triplet is a Lc->pKpi int8_t isRealLcPKPi = 0; - if (isRealPKPi && TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::LcToPKPi)) { + if (isRealPKPi && (std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi)) { isRealLcPKPi = 1; } @@ -1396,7 +2041,7 @@ struct TaskPolarisationCharmHadrons { massKPi, massKProton, massPiProton, outputMl.at(0), outputMl.at(2), isRealPKPi, isRealLcPKPi, isReflected, - charge); + charge, originTriplet); } // end studyLcPKPiBkgMc } // end table for Lc->pKpi background studies @@ -1408,9 +2053,18 @@ struct TaskPolarisationCharmHadrons { /// \param mcParticle is the Mc particle /// \param mcParticles is the table of Mc particles /// \param numPvContributors is the number of PV contributors in the associated reco collision - template - void runMcGenPolarisationAnalysis(Part const& mcParticle, Particles const& mcParticles, int numPvContributors) + template + void runMcGenPolarisationAnalysis(Part const& mcParticle, Particles const& mcParticles, int numPvContributors, Cent const* centrality = nullptr) { + if constexpr (withCent) { + assert(qVecs && "Centrality analysis requested but Cent == nullptr"); + } + if constexpr (withCent) { + if (*centrality < centralityMin || *centrality > centralityMax) { + return; // skip this collision if outside of the centrality range + } + } + int8_t origin{RecoDecay::OriginType::None}; std::vector listDaughters{}; float massDau{0.f}, massCharmHad{0.f}; @@ -1418,8 +2072,12 @@ struct TaskPolarisationCharmHadrons { bool areDauInAcc{true}; int8_t resoChannelLc = -1; int8_t charge = -99; + bool partRecoDstar{false}; if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { - if (!TESTBIT(std::abs(mcParticle.flagMcMatchGen()), aod::hf_cand_dstar::DecayType::DstarToD0Pi)) { // this particle is not signal, skip + partRecoDstar = (std::abs(mcParticle.flagMcMatchGen()) == hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPiPi0) && (std::abs(mcParticle.flagMcMatchGenD0()) == hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiKPi0); + bool signalDstar = (std::abs(mcParticle.flagMcMatchGen()) == hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) && (std::abs(mcParticle.flagMcMatchGenD0()) == hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + + if (!signalDstar && (!activatePartRecoDstar || !partRecoDstar)) { // this particle is not signal and not partially reconstructed signal, skip return; } origin = mcParticle.originMcGen(); @@ -1427,7 +2085,7 @@ struct TaskPolarisationCharmHadrons { auto bHadMother = mcParticles.rawIteratorAt(mcParticle.idxBhadMotherPart() - mcParticles.offset()); int pdgBhadMother = std::abs(bHadMother.pdgCode()); // For unknown reasons there are charm hadrons coming directly from beauty diquarks without an intermediate B-hadron which have an unreasonable correlation between the pT of the charm hadron and the beauty mother. We also remove charm hadrons from quarkonia. - if (pdgBhadMother == 5101 || pdgBhadMother == 5103 || pdgBhadMother == 5201 || pdgBhadMother == 5203 || pdgBhadMother == 5301 || pdgBhadMother == 5303 || pdgBhadMother == 5401 || pdgBhadMother == 5403 || pdgBhadMother == 5503 || pdgBhadMother == 553 || pdgBhadMother == 555 || pdgBhadMother == 553 || pdgBhadMother == 557) { + if (pdgBhadMother == 5101 || pdgBhadMother == 5103 || pdgBhadMother == 5201 || pdgBhadMother == 5203 || pdgBhadMother == 5301 || pdgBhadMother == 5303 || pdgBhadMother == 5401 || pdgBhadMother == 5403 || pdgBhadMother == 5503 || pdgBhadMother == 553 || pdgBhadMother == 555 || pdgBhadMother == 553 || pdgBhadMother == 557) { // o2-linter: disable=pdg/explicit-code, magic-number (constants not in the PDG header) return; } ptBhadMother = bHadMother.pt(); @@ -1438,7 +2096,7 @@ struct TaskPolarisationCharmHadrons { massDau = massPi; massCharmHad = massDstar; } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { - if (!TESTBIT(std::abs(mcParticle.flagMcMatchGen()), aod::hf_cand_3prong::DecayType::LcToPKPi)) { // this particle is not signal, skip + if (std::abs(mcParticle.flagMcMatchGen()) != hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { // this particle is not signal, skip return; } origin = mcParticle.originMcGen(); @@ -1508,22 +2166,22 @@ struct TaskPolarisationCharmHadrons { if (activateTHnSparseCosThStarHelicity) { ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); float cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(helicityVec.Mag2()); - fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarHelicity, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge); + fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarHelicity, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge, partRecoDstar); } if (activateTHnSparseCosThStarProduction) { ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(pyCharmHad, -pxCharmHad, 0.f); float cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(normalVec.Mag2()); - fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarProduction, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge); + fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarProduction, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge, partRecoDstar); } if (activateTHnSparseCosThStarBeam) { ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); float cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarBeam, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge); + fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarBeam, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge, partRecoDstar); } if (activateTHnSparseCosThStarRandom) { ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); float cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarRandom, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge); + fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarRandom, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge, partRecoDstar); } } @@ -1555,7 +2213,7 @@ struct TaskPolarisationCharmHadrons { fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); } } - PROCESS_SWITCH(TaskPolarisationCharmHadrons, processDstar, "Process Dstar candidates without ML", true); + PROCESS_SWITCH(HfTaskCharmPolarisation, processDstar, "Process Dstar candidates without ML", true); // Dstar with ML cuts void processDstarWithMl(aod::Collisions const& collisions, @@ -1581,7 +2239,7 @@ struct TaskPolarisationCharmHadrons { fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); } } - PROCESS_SWITCH(TaskPolarisationCharmHadrons, processDstarWithMl, "Process Dstar candidates with ML", false); + PROCESS_SWITCH(HfTaskCharmPolarisation, processDstarWithMl, "Process Dstar candidates with ML", false); // Dstar in MC with rectangular cuts void processDstarMc(aod::McCollisions::iterator const&, @@ -1614,7 +2272,7 @@ struct TaskPolarisationCharmHadrons { runMcGenPolarisationAnalysis(mcParticle, mcParticles, numPvContributorsGen); } } - PROCESS_SWITCH(TaskPolarisationCharmHadrons, processDstarMc, "Process Dstar candidates in MC without ML", false); + PROCESS_SWITCH(HfTaskCharmPolarisation, processDstarMc, "Process Dstar candidates in MC without ML", false); // Dstar in MC with ML cuts void processDstarMcWithMl(aod::McCollisions::iterator const&, @@ -1647,7 +2305,149 @@ struct TaskPolarisationCharmHadrons { runMcGenPolarisationAnalysis(mcParticle, mcParticles, numPvContributorsGen); } } - PROCESS_SWITCH(TaskPolarisationCharmHadrons, processDstarMcWithMl, "Process Dstar candidates in MC with ML", false); + PROCESS_SWITCH(HfTaskCharmPolarisation, processDstarMcWithMl, "Process Dstar candidates in MC with ML", false); + + void processDstarInPbPb(CollsWithQVecs const& collisions, + FilteredCandDstarWSelFlag const& dstarCandidates, + TracksWithExtra const& tracks) + { + for (const auto& collision : collisions) { + float centrality = {-1.f}; + centrality = o2::hf_centrality::getCentralityColl(collision, centEstimator); + if (centrality < centralityMin || centrality > centralityMax) { + return; // skip this collision if outside of the centrality range + } + registry.fill(HIST("hCentrality"), centrality); + + auto thisCollId = collision.globalIndex(); + int numPvContributors = collision.numContrib(); + auto groupedDstarCandidates = dstarCandidates.sliceBy(dstarPerCollision, thisCollId); + int nCands{0}, nCandsInSignalRegion{0}; + + std::vector qVecs = getQVec(collision); + + for (const auto& dstarCandidate : groupedDstarCandidates) { + nCands++; + if (runPolarisationAnalysis(dstarCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks, &qVecs)) { + nCandsInSignalRegion++; + } + } + fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); + } + } + PROCESS_SWITCH(HfTaskCharmPolarisation, processDstarInPbPb, "Process Dstar candidates in PbPb collisions", false); + + void processDstarWithMlInPbPb(CollsWithQVecs const& collisions, + FilteredCandDstarWSelFlagAndMl const& dstarCandidates, + TracksWithExtra const& tracks) + { + for (const auto& collision : collisions) { + float centrality = {-1.f}; + centrality = o2::hf_centrality::getCentralityColl(collision, centEstimator); + if (centrality < centralityMin || centrality > centralityMax) { + return; // skip this collision if outside of the centrality range + } + registry.fill(HIST("hCentrality"), centrality); + + auto thisCollId = collision.globalIndex(); + int numPvContributors = collision.numContrib(); + auto groupedDstarCandidates = dstarCandidates.sliceBy(dstarWithMlPerCollision, thisCollId); + int nCands{0}, nCandsInSignalRegion{0}; + + std::vector qVecs = getQVec(collision); + + for (const auto& dstarCandidate : groupedDstarCandidates) { + nCands++; + if (runPolarisationAnalysis(dstarCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks, &qVecs)) { + nCandsInSignalRegion++; + } + } + fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); + } + } + PROCESS_SWITCH(HfTaskCharmPolarisation, processDstarWithMlInPbPb, "Process Dstar candidates with ML in PbPb collisions", false); + + void processDstarMcInPbPb(aod::McCollisions::iterator const&, + McParticlesDstarMatched const& mcParticles, + CollisionsWithMcLabelsAndCent const& collisions, // this is grouped with SmallGroupsCollisionsWithMcLabels const& collisions, + FilteredCandDstarWSelFlagAndMc const& dstarCandidates, + TracksWithExtra const& tracks) + { + float centrality = {-1.f}; + int numPvContributorsGen{0}; + + for (const auto& collision : collisions) { // loop over reco collisions associated to this gen collision + centrality = o2::hf_centrality::getCentralityColl(collision, centEstimator); + if (centrality < centralityMin || centrality > centralityMax) { + return; // skip this collision if outside of the centrality range + } + registry.fill(HIST("hCentrality"), centrality); + + auto thisCollId = collision.globalIndex(); + int numPvContributors = collision.numContrib(); + auto groupedDstarCandidates = dstarCandidates.sliceBy(dstarWithMcPerCollision, thisCollId); + int nCands{0}, nCandsInSignalRegion{0}; + + if (numPvContributors > numPvContributorsGen) { // we take the associated reconstructed collision with higher number of PV contributors + numPvContributorsGen = numPvContributors; + } + + for (const auto& dstarCandidate : groupedDstarCandidates) { + nCands++; + if (runPolarisationAnalysis(dstarCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { + nCandsInSignalRegion++; + } + } + fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); + } + for (const auto& mcParticle : mcParticles) { + const auto& recoCollsPerMcColl = collisions.sliceBy(colPerMcCollision, mcParticle.mcCollision().globalIndex()); + float cent = o2::hf_centrality::getCentralityGenColl(recoCollsPerMcColl, centEstimator); + runMcGenPolarisationAnalysis(mcParticle, mcParticles, numPvContributorsGen, ¢); + } + } + PROCESS_SWITCH(HfTaskCharmPolarisation, processDstarMcInPbPb, "Process Dstar candidates in PbPb MC without ML", false); + + void processDstarMcWithMlInPbPb(aod::McCollisions::iterator const&, + McParticlesDstarMatched const& mcParticles, + CollisionsWithMcLabelsAndCent const& collisions, // this is grouped with SmallGroupsCollisionsWithMcLabels const& collisions, + FilteredCandDstarWSelFlagAndMcAndMl const& dstarCandidates, + TracksWithExtra const& tracks) + { + float centrality = {-1.f}; + int numPvContributorsGen{0}; + + for (const auto& collision : collisions) { // loop over reco collisions associated to this gen collision + centrality = o2::hf_centrality::getCentralityColl(collision, centEstimator); + if (centrality < centralityMin || centrality > centralityMax) { + return; // skip this collision if outside of the centrality range + } + registry.fill(HIST("hCentrality"), centrality); + + auto thisCollId = collision.globalIndex(); + int numPvContributors = collision.numContrib(); + auto groupedDstarCandidates = dstarCandidates.sliceBy(dstarWithMcAndMlPerCollision, thisCollId); + int nCands{0}, nCandsInSignalRegion{0}; + + if (numPvContributors > numPvContributorsGen) { // we take the associated reconstructed collision with higher number of PV contributors + numPvContributorsGen = numPvContributors; + } + + for (const auto& dstarCandidate : groupedDstarCandidates) { + nCands++; + if (runPolarisationAnalysis(dstarCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { + nCandsInSignalRegion++; + } + } + fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); + } + for (const auto& mcParticle : mcParticles) { + const auto& recoCollsPerMcColl = collisions.sliceBy(colPerMcCollision, mcParticle.mcCollision().globalIndex()); + float cent = o2::hf_centrality::getCentralityGenColl(recoCollsPerMcColl, centEstimator); + runMcGenPolarisationAnalysis(mcParticle, mcParticles, numPvContributorsGen, ¢); + } + } + PROCESS_SWITCH(HfTaskCharmPolarisation, processDstarMcWithMlInPbPb, "Process Dstar candidates in PbPb MC with ML", false); //////////////////////////// // Lc->pKpi analysis /// @@ -1678,7 +2478,7 @@ struct TaskPolarisationCharmHadrons { fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); } } - PROCESS_SWITCH(TaskPolarisationCharmHadrons, processLcToPKPi, "Process Lc candidates without ML", false); + PROCESS_SWITCH(HfTaskCharmPolarisation, processLcToPKPi, "Process Lc candidates without ML", false); // Lc->pKpi with ML cuts void processLcToPKPiWithMl(aod::Collisions const& collisions, @@ -1705,7 +2505,7 @@ struct TaskPolarisationCharmHadrons { fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); } } - PROCESS_SWITCH(TaskPolarisationCharmHadrons, processLcToPKPiWithMl, "Process Lc candidates with ML", false); + PROCESS_SWITCH(HfTaskCharmPolarisation, processLcToPKPiWithMl, "Process Lc candidates with ML", false); // Lc->pKpi in MC with rectangular cuts void processLcToPKPiMc(aod::McCollisions::iterator const&, @@ -1738,7 +2538,7 @@ struct TaskPolarisationCharmHadrons { runMcGenPolarisationAnalysis(mcParticle, mcParticles, numPvContributorsGen); } } - PROCESS_SWITCH(TaskPolarisationCharmHadrons, processLcToPKPiMc, "Process Lc candidates in MC without ML", false); + PROCESS_SWITCH(HfTaskCharmPolarisation, processLcToPKPiMc, "Process Lc candidates in MC without ML", false); // Lc->pKpi in MC with ML cuts void processLcToPKPiMcWithMl(aod::McCollisions::iterator const&, @@ -1771,7 +2571,7 @@ struct TaskPolarisationCharmHadrons { runMcGenPolarisationAnalysis(mcParticle, mcParticles, numPvContributorsGen); } } - PROCESS_SWITCH(TaskPolarisationCharmHadrons, processLcToPKPiMcWithMl, "Process Lc candidates in MC with ML", false); + PROCESS_SWITCH(HfTaskCharmPolarisation, processLcToPKPiMcWithMl, "Process Lc candidates in MC with ML", false); // Lc->pKpi in MC with ML cuts w/o mcCollision grouping (to study Lc background) void processLcToPKPiBackgroundMcWithMl(McParticles3ProngMatched const& mcParticles, @@ -1786,10 +2586,10 @@ struct TaskPolarisationCharmHadrons { runMcGenPolarisationAnalysis(mcParticle, mcParticles, /*numPvContributorsGen*/ -1); } } - PROCESS_SWITCH(TaskPolarisationCharmHadrons, processLcToPKPiBackgroundMcWithMl, "Process Lc candidates in MC with ML w/o mcCollision grouping", false); + PROCESS_SWITCH(HfTaskCharmPolarisation, processLcToPKPiBackgroundMcWithMl, "Process Lc candidates in MC with ML w/o mcCollision grouping", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGHF/D2H/Tasks/taskCharmResoReduced.cxx b/PWGHF/D2H/Tasks/taskCharmResoReduced.cxx deleted file mode 100644 index 7126e02258f..00000000000 --- a/PWGHF/D2H/Tasks/taskCharmResoReduced.cxx +++ /dev/null @@ -1,471 +0,0 @@ -// 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. - -/// \file taskCharmResoReduced.cxx -/// \brief Charmed Resonances analysis task -/// -/// \author Luca Aglietta , University and INFN Torino - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/RecoDecay.h" - -// #include "PWGHF/Core/HfHelper.h" -#include "PWGHF/D2H/DataModel/ReducedDataModel.h" - -using namespace o2; -using namespace o2::soa; -using namespace o2::analysis; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::constants::physics; - -enum DecayTypeMc : uint8_t { - Ds1ToDStarK0ToD0PiK0s = 1, - Ds2StarToDplusK0sToPiKaPiPiPi, - Ds1ToDStarK0ToDPlusPi0K0s, - Ds1ToDStarK0ToD0PiK0sPart, - Ds1ToDStarK0ToD0NoPiK0sPart, - Ds1ToDStarK0ToD0PiK0sOneMu, - Ds2StarToDplusK0sOneMu -}; - -namespace o2::aod -{ -namespace hf_cand_reso_lite -{ -DECLARE_SOA_COLUMN(PtBach0, ptBach0, float); //! Transverse momentum of bachelor 0 (GeV/c) -DECLARE_SOA_COLUMN(PtBach1, ptBach1, float); //! Transverse momentum of bachelor 1 (GeV/c) -DECLARE_SOA_COLUMN(MBach0, mBach0, float); //! Invariant mass of bachelor 0 (GeV/c) -DECLARE_SOA_COLUMN(MBach1, mBach1, float); //! Invariant mass of bachelor 1 (GeV/c) -DECLARE_SOA_COLUMN(MBachD0, mBachD0, float); //! Invariant mass of D0 bachelor (of bachelor 0) (GeV/c) -DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate (GeV/c2) -DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) -DECLARE_SOA_COLUMN(P, p, float); //! Momentum of candidate (GeV/c) -DECLARE_SOA_COLUMN(Y, y, float); //! Rapidity of candidate -DECLARE_SOA_COLUMN(Eta, eta, float); //! Pseudorapidity of candidate -DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuth angle of candidate -DECLARE_SOA_COLUMN(E, e, float); //! Energy of candidate (GeV) -DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of candidate -DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float); //! VosThetaStar of candidate (GeV) -DECLARE_SOA_COLUMN(MlScoreBkgBach0, mlScoreBkgBach0, float); //! ML score for background class of charm daughter -DECLARE_SOA_COLUMN(MlScorePromptBach0, mlScorePromptBach0, float); //! ML score for prompt class of charm daughter -DECLARE_SOA_COLUMN(MlScoreNonPromptBach0, mlScoreNonPromptBach0, float); //! ML score for non-prompt class of charm daughter -DECLARE_SOA_COLUMN(ItsNClsProngMinBach0, itsNClsProngMinBach0, int); //! minimum value of number of ITS clusters for the decay daughter tracks of bachelor 0 -DECLARE_SOA_COLUMN(TpcNClsCrossedRowsProngMinBach0, tpcNClsCrossedRowsProngMinBach0, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks of bachelor 0 -DECLARE_SOA_COLUMN(TpcChi2NClProngMaxBach0, tpcChi2NClProngMaxBach0, float); //! maximum value of TPC chi2 for the decay daughter tracks of bachelor 0 -DECLARE_SOA_COLUMN(ItsNClsProngMinBach1, itsNClsProngMinBach1, int); //! minimum value of number of ITS clusters for the decay daughter tracks of bachelor 1 -DECLARE_SOA_COLUMN(TpcNClsCrossedRowsProngMinBach1, tpcNClsCrossedRowsProngMinBach1, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks of bachelor 1 -DECLARE_SOA_COLUMN(TpcChi2NClProngMaxBach1, tpcChi2NClProngMaxBach1, float); //! maximum value of TPC chi2 for the decay daughter tracks of bachelor 1 -DECLARE_SOA_COLUMN(CpaBach1, cpaBach1, float); //! Cosine of Pointing Angle of bachelor 1 -DECLARE_SOA_COLUMN(DcaBach1, dcaBach1, float); //! DCA of bachelor 1 -DECLARE_SOA_COLUMN(RadiusBach1, radiusBach1, float); //! Radius of bachelor 1 -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! flag for decay channel classification reconstruction level -DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); //! debug flag for mis-association at reconstruction level -DECLARE_SOA_COLUMN(Origin, origin, int8_t); //! Flag for origin of MC particle 1=promt, 2=FD -DECLARE_SOA_COLUMN(PtGen, ptGen, float); //! Transverse momentum of candidate (GeV/c) -DECLARE_SOA_COLUMN(SignD0, signD0, float); //! Flag to distinguish D0 and D0Bar - -} // namespace hf_cand_reso_lite - -DECLARE_SOA_TABLE(HfCandResoLites, "AOD", "HFCANDRESOLITE", //! Table with some B0 properties - // Candidate Properties - hf_cand_reso_lite::M, - hf_cand_reso_lite::Pt, - hf_cand_reso_lite::P, - hf_cand_reso_lite::Y, - hf_cand_reso_lite::Eta, - hf_cand_reso_lite::Phi, - hf_cand_reso_lite::E, - hf_cand_reso_lite::CosThetaStar, - hf_cand_reso_lite::Sign, - // Bachelors Properties - hf_cand_reso_lite::MBach0, - hf_cand_reso_lite::PtBach0, - hf_cand_reso_lite::MlScoreBkgBach0, - hf_cand_reso_lite::MlScorePromptBach0, - hf_cand_reso_lite::MlScoreNonPromptBach0, - hf_cand_reso_lite::ItsNClsProngMinBach0, - hf_cand_reso_lite::TpcNClsCrossedRowsProngMinBach0, - hf_cand_reso_lite::TpcChi2NClProngMaxBach0, - hf_cand_reso_lite::MBach1, - hf_cand_reso_lite::PtBach1, - hf_cand_reso_lite::CpaBach1, - hf_cand_reso_lite::DcaBach1, - hf_cand_reso_lite::RadiusBach1, - hf_cand_reso_lite::ItsNClsProngMinBach1, - hf_cand_reso_lite::TpcNClsCrossedRowsProngMinBach1, - hf_cand_reso_lite::TpcChi2NClProngMaxBach1, - // MC - hf_cand_reso_lite::FlagMcMatchRec, - hf_cand_reso_lite::DebugMcRec, - hf_cand_reso_lite::Origin, - hf_cand_reso_lite::PtGen, - hf_cand_reso_lite::SignD0); - -DECLARE_SOA_TABLE(HfGenResoLites, "AOD", "HFGENRESOLITE", //! Table with some B0 properties - hf_cand_reso_lite::Pt, - hf_cand_reso_lite::Y, - hf_cand_reso_lite::Origin); - -} // namespace o2::aod - -enum DecayChannel : uint8_t { - Ds1ToDstarK0s = 0, - Ds2StarToDplusK0s, - XcToDplusLambda, - LambdaDminus -}; - -struct HfTaskCharmResoReduced { - Produces hfCandResoLite; - Produces hfGenResoLite; - Configurable ptMinReso{"ptMinReso", -1, "Discard events with smaller pT"}; - Configurable fillTrees{"fillTrees", false, "Fill output Trees"}; - Configurable fillSparses{"fillSparses", false, "Fill output Sparses"}; - Configurable useDeltaMass{"useDeltaMass", false, "Use Delta Mass for resonance invariant Mass calculation"}; - Configurable fillOnlySignal{"fillOnlySignal", false, "Flag to Fill only signal candidates (MC only)"}; - Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; - Configurable yCandRecoMax{"yCandRecoMax", -1, "max. cand. rapidity"}; - Configurable etaTrackMax{"etaTrackMax", 0.8, "max. track pseudo-rapidity for acceptance calculation"}; - Configurable ptTrackMin{"ptTrackMin", 0.1, "min. track transverse momentum for acceptance calculation"}; - // Configurables axis for histos - ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "#it{p}_{T} (GeV/#it{c})"}; - ConfigurableAxis axisPtProng0{"axisPtProng0", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "prong0 bach. #it{p}_{T} (GeV/#it{c})"}; - ConfigurableAxis axisPtProng1{"axisPtProng1", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "prong1 bach. #it{p}_{T} (GeV/#it{c})"}; - ConfigurableAxis axisInvMassReso{"axisInvMassReso", {200, 2.34, 2.74}, "inv. mass (DV_{0}) (GeV/#it{c}^{2})"}; - ConfigurableAxis axisInvMassProng0{"axisInvMassProng0", {175, 1.70, 2.05}, "inv. mass (D) (GeV/#it{c}^{2})"}; - ConfigurableAxis axisInvMassProng1{"axisInvMassProng1", {80, 0.46, 0.54}, "inv. mass ({V}_{0}) (GeV/#it{c}^{2})"}; - ConfigurableAxis axisCosThetaStar{"axisCosThetaStar", {40, -1, 1}, "cos(#vartheta*)"}; - ConfigurableAxis axisBkgBdtScore{"axisBkgBdtScore", {100, 0, 1}, "bkg BDT Score"}; - ConfigurableAxis axisNonPromptBdtScore{"axisNonPromptBdtScore", {100, 0, 1}, "non-prompt BDT Score"}; - ConfigurableAxis axisEta{"axisEta", {30, -1.5, 1.5}, "pseudorapidity"}; - ConfigurableAxis axisOrigin{"axisOrigin", {3, -0.5, 2.5}, "origin"}; - ConfigurableAxis axisFlag{"axisFlag", {65, -32.5, 32.5}, "mc flag"}; - - using ReducedReso = soa::Join; - using ReducedResoWithMl = soa::Join; - using ReducedResoMc = soa::Join; - using ReducedResoWithMlMc = soa::Join; - - // Histogram Registry - HistogramRegistry registry; - - // init - void init(InitContext&) - { - registry.add("hMass", "Charm resonance candidates inv. mass", {HistType::kTH1F, {axisInvMassReso}}); - registry.add("hMassProng0", "D daughters inv. mass", {HistType::kTH1F, {axisInvMassProng0}}); - registry.add("hMassProng1", "V0 daughter inv. mass", {HistType::kTH1F, {axisInvMassProng1}}); - registry.add("hPt", "Charm resonance candidates pT", {HistType::kTH1F, {axisPt}}); - registry.add("hPtProng0", "D daughters pT", {HistType::kTH1F, {axisPtProng0}}); - registry.add("hPtProng1", "V0 daughter pT", {HistType::kTH1F, {axisPtProng1}}); - registry.add("hNPvCont", "Collision number of PV contributors ; N contrib ; entries", {HistType::kTH1F, {{125, -0.5, 249.5}}}); - registry.add("hZvert", "Collision Z Vtx ; z PV [cm] ; entries", {HistType::kTH1F, {{120, -12., 12.}}}); - registry.add("hBz", "Collision Bz ; Bz [T] ; entries", {HistType::kTH1F, {{20, -10., 10.}}}); - registry.add("hSparse", "THn for production studies with cosThStar and BDT scores", HistType::kTHnSparseF, {axisPt, axisPtProng0, axisPtProng1, axisInvMassReso, axisInvMassProng0, axisInvMassProng1, axisCosThetaStar, axisBkgBdtScore, axisNonPromptBdtScore}); - - if (doprocessDs1Mc || doprocessDs2StarMc || doprocessDs1McWithMl || doprocessDs2StarMcWithMl) { - // gen histos - registry.add("hYRecPrompt", "Charm resonance candidates pT", {HistType::kTH2F, {axisPt, axisEta}}); - registry.add("hYRecNonPrompt", "Charm resonance candidates pT", {HistType::kTH2F, {axisPt, axisEta}}); - registry.add("hYGenPrompt", "Prompt {D_{S}}^j particles (generated);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2F, {axisPt, axisEta}}); - registry.add("hYGenPromptWithProngsInAcceptance", "Prompt {D_{S}}^j particles (generated-daughters in acceptance);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2F, {axisPt, axisEta}}); - registry.add("hYGenNonPrompt", "NonPrompt {D_{S}}^j particles (generated);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2F, {axisPt, axisEta}}); - registry.add("hYGenNonPromptWithProngsInAcceptance", "NonPrompt {D_{S}}^j particles (generated-daughters in acceptance);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2F, {axisPt, axisEta}}); - if (fillSparses) { - registry.add("hPtYGenSig", "{D_{S}}^j particles (generated);#it{p}_{T}({D_{S}}^j) (GeV/#it{c});#it{y}({D_{S}}^j)", {HistType::kTHnSparseF, {axisPt, axisEta, axisOrigin, axisFlag}}); - registry.add("hPtYWithProngsInAccepanceGenSig", "{D_{S}}^j particles (generated-daughters in acceptance);#it{p}_{T}({D_{S}}^j) (GeV/#it{c});#it{y}({D_{S}}^j)", {HistType::kTHnSparseF, {axisPt, axisEta, axisOrigin, axisFlag}}); - } - } - } - - // Fill histograms - /// \tparam channel is the decay channel of the Resonance - /// \param candidate is a candidate - /// \param coll is a reduced collision - /// \param bach0 is a bachelor of the candidate - /// \param bach1 is a bachelor of the candidate - template - void fillCand(const Cand& candidate, const Coll& collision, const CharmBach& bach0, const V0Bach& bach1) - { - // Compute quantities to be saved - float invMassReso{0}, pdgMassReso, invMassBach0, invMassBach1, pdgMassBach0, pdgMassBach1, sign, invMassD0, cosThetaStar; - if (channel == DecayChannel::Ds1ToDstarK0s) { - pdgMassReso = MassDS1; - pdgMassBach0 = MassDStar; - pdgMassBach1 = MassK0; - invMassBach1 = bach1.invMassK0s(); - cosThetaStar = candidate.cosThetaStarDs1(); - if (bach0.dType() > 0) { - invMassBach0 = bach0.invMassDstar(); - invMassD0 = bach0.invMassD0(); - sign = 1; - if (useDeltaMass) { - invMassReso = RecoDecay::m(std::array{bach0.pVectorProng0(), bach0.pVectorProng1(), bach0.pVectorProng2(), bach1.pVector()}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); - } - } else { - invMassBach0 = bach0.invMassAntiDstar(); - invMassD0 = bach0.invMassD0Bar(); - sign = -1; - if (useDeltaMass) { - invMassReso = RecoDecay::m(std::array{bach0.pVectorProng1(), bach0.pVectorProng0(), bach0.pVectorProng2(), bach1.pVector()}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); - } - } - } else if (channel == DecayChannel::Ds2StarToDplusK0s) { - pdgMassReso = MassDS2Star; - pdgMassBach0 = MassDPlus; - pdgMassBach1 = MassK0; - invMassBach0 = bach0.invMassDplus(); - invMassD0 = 0; - invMassBach1 = bach1.invMassK0s(); - cosThetaStar = candidate.cosThetaStarDs2Star(); - if (useDeltaMass) { - invMassReso = RecoDecay::m(std::array{bach0.pVectorProng0(), bach0.pVectorProng1(), bach0.pVectorProng2(), bach1.pVector()}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); - } - if (bach0.dType() > 0) { - sign = 1; - } else { - sign = -1; - } - } - float y = RecoDecay::y(std::array{candidate.px(), candidate.py(), candidate.pz()}, pdgMassReso); - float eta = RecoDecay::eta(std::array{candidate.px(), candidate.py(), candidate.pz()}); - float phi = RecoDecay::phi(candidate.px(), candidate.py()); - float p = RecoDecay::p(std::array{candidate.px(), candidate.py(), candidate.pz()}); - float e = RecoDecay::e(std::array{candidate.px(), candidate.py(), candidate.pz()}, pdgMassReso); - if (useDeltaMass) { - invMassReso = invMassReso - invMassBach0; - } else { - invMassReso = RecoDecay::m(std::array{bach0.pVector(), bach1.pVector()}, std::array{pdgMassBach0, pdgMassBach1}); - } - invMassBach0 = invMassBach0 - invMassD0; - float ptGen{-1.}; - int8_t origin{-1}, flagMcMatchRec{-1}, debugMcRec{-1}, signD0{0}; - if constexpr (doMc) { - ptGen = candidate.ptMother(); - origin = candidate.origin(); - flagMcMatchRec = candidate.flagMcMatchRec(); - debugMcRec = candidate.debugMcRec(); - if (fillOnlySignal) { - if (channel == DecayChannel::Ds1ToDstarK0s && !(std::abs(flagMcMatchRec) == DecayTypeMc::Ds1ToDStarK0ToD0PiK0s || std::abs(flagMcMatchRec) == DecayTypeMc::Ds1ToDStarK0ToD0PiK0sPart || std::abs(flagMcMatchRec) == DecayTypeMc::Ds1ToDStarK0ToD0NoPiK0sPart || std::abs(flagMcMatchRec) == DecayTypeMc::Ds1ToDStarK0ToD0PiK0sOneMu)) { - return; - } - if (channel == DecayChannel::Ds2StarToDplusK0s && !(std::abs(flagMcMatchRec) == DecayTypeMc::Ds2StarToDplusK0sToPiKaPiPiPi || std::abs(flagMcMatchRec) == DecayTypeMc::Ds2StarToDplusK0sOneMu)) { - return; - } - } - if (origin == 1) { - registry.fill(HIST("hYRecPrompt"), candidate.pt(), y); - } else if (origin == 2) { - registry.fill(HIST("hYRecNonPrompt"), candidate.pt(), y); - } - } - float mlScoreBkg{-1.}, mlScorePrompt{-1.}, mlScoreNonPrompt{-1.}; - if constexpr (withMl) { - mlScoreBkg = bach0.mlScoreBkgMassHypo0(); - mlScorePrompt = bach0.mlScorePromptMassHypo0(); - mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo0(); - } - // Collision properties - registry.fill(HIST("hNPvCont"), collision.numContrib()); - registry.fill(HIST("hZvert"), collision.posZ()); - registry.fill(HIST("hBz"), collision.bz()); - // Candidate properties - registry.fill(HIST("hMass"), invMassReso); - registry.fill(HIST("hMassProng0"), invMassBach0); - registry.fill(HIST("hMassProng1"), invMassBach1); - registry.fill(HIST("hPt"), candidate.pt()); - registry.fill(HIST("hPtProng0"), candidate.ptProng0()); - registry.fill(HIST("hPtProng1"), candidate.ptProng1()); - if (fillSparses) { - registry.fill(HIST("hSparse"), candidate.pt(), candidate.ptProng0(), candidate.ptProng1(), invMassReso, invMassBach0, invMassBach1, cosThetaStar, mlScoreBkg, mlScoreNonPrompt); - } - - if (fillTrees) { - hfCandResoLite( - invMassReso, - candidate.pt(), - p, - y, - eta, - phi, - e, - cosThetaStar, - sign, - // Bachelors Properties - invMassBach0, - bach0.pt(), - mlScoreBkg, - mlScorePrompt, - mlScoreNonPrompt, - bach0.itsNClsProngMin(), - bach0.tpcNClsCrossedRowsProngMin(), - bach0.tpcChi2NClProngMax(), - invMassBach1, - bach1.pt(), - bach1.cpa(), - bach1.dca(), - bach1.v0Radius(), - bach1.itsNClsProngMin(), - bach1.tpcNClsCrossedRowsProngMin(), - bach1.tpcChi2NClProngMax(), - // MC - flagMcMatchRec, - debugMcRec, - origin, - ptGen, - signD0); - } - } // fillCand - - // Process data - /// \tparam channel is the decay channel of the Resonance - /// \param Coll is the reduced collisions table - /// \param CharmBach is the reduced 3 prong table - /// \param V0Bach is the reduced v0 table - /// \param Cand is the candidates table - template - void processData(Coll const&, Candidates const& candidates, CharmBach const&, aod::HfRedVzeros const&) - { - for (const auto& cand : candidates) { - if (ptMinReso >= 0 && cand.pt() < ptMinReso) { - continue; - } - float pdgMassReso{0}; - if (channel == DecayChannel::Ds1ToDstarK0s) { - pdgMassReso = MassDS1; - } else if (channel == DecayChannel::Ds2StarToDplusK0s) { - pdgMassReso = MassDS2Star; - } - if (yCandRecoMax >= 0. && std::abs(RecoDecay::y(std::array{cand.px(), cand.py(), cand.pz()}, pdgMassReso)) > yCandRecoMax) { - continue; - } - auto coll = cand.template hfRedCollision_as(); - auto bach0 = cand.template prong0_as(); - auto bach1 = cand.template prong1_as(); - fillCand(cand, coll, bach0, bach1); - } - } - - /// Selection of resonance daughters in geometrical acceptance - /// \param etaProng is the pseudorapidity of Resonance prong - /// \param ptProng is the pT of Resonance prong - /// \return true if prong is in geometrical acceptance - template - bool isProngInAcceptance(const T& etaProng, const T& ptProng) - { - return std::abs(etaProng) <= etaTrackMax && ptProng >= ptTrackMin; - } - - /// Fill particle histograms (gen MC truth) - template - void fillCandMcGen(aod::HfMcGenRedResos const& mcParticles) - { - for (const auto& particle : mcParticles) { - auto ptParticle = particle.ptTrack(); - auto yParticle = particle.yTrack(); - auto originParticle = particle.origin(); - auto flag = particle.flagMcMatchGen(); - if (yCandGenMax >= 0. && std::abs(yParticle) > yCandGenMax) { - continue; - } - std::array ptProngs = {particle.ptProng0(), particle.ptProng1()}; - std::array etaProngs = {particle.etaProng0(), particle.etaProng1()}; - bool prongsInAcc = isProngInAcceptance(etaProngs[0], ptProngs[0]) && isProngInAcceptance(etaProngs[1], ptProngs[1]); - if ((channel == DecayChannel::Ds1ToDstarK0s && std::abs(flag) == DecayTypeMc::Ds1ToDStarK0ToD0PiK0s) || - (channel == DecayChannel::Ds2StarToDplusK0s && std::abs(flag) == DecayTypeMc::Ds2StarToDplusK0sToPiKaPiPiPi)) { - if (originParticle == 1) { // prompt particles - registry.fill(HIST("hYGenPrompt"), ptParticle, yParticle); - if (prongsInAcc) { - registry.fill(HIST("hYGenPromptWithProngsInAcceptance"), ptParticle, yParticle); - } - } else if (originParticle == 2) { - registry.fill(HIST("hYGenNonPrompt"), ptParticle, yParticle); - if (prongsInAcc) { - registry.fill(HIST("hYGenNonPromptWithProngsInAcceptance"), ptParticle, yParticle); - } - } - } - if (fillSparses) { - registry.fill(HIST("hPtYGenSig"), ptParticle, yParticle, originParticle, flag); - if (prongsInAcc) { - registry.fill(HIST("hPtYWithProngsInAccepanceGenSig"), ptParticle, yParticle, originParticle, flag); - } - } - if (fillTrees) { - hfGenResoLite(ptParticle, yParticle, originParticle); - } - } - } // fillCandMcGen - - // process functions - - void processDs1Data(aod::HfRedCollisions const& collisions, ReducedReso const& candidates, aod::HfRed3PrNoTrks const& charmBachs, aod::HfRedVzeros const& v0Bachs) - { - processData(collisions, candidates, charmBachs, v0Bachs); - } - PROCESS_SWITCH(HfTaskCharmResoReduced, processDs1Data, "Process data for Ds1 analysis without Ml", true); - - void processDs1DataWithMl(aod::HfRedCollisions const& collisions, ReducedResoWithMl const& candidates, soa::Join const& charmBachs, aod::HfRedVzeros const& v0Bachs) - { - processData(collisions, candidates, charmBachs, v0Bachs); - } - PROCESS_SWITCH(HfTaskCharmResoReduced, processDs1DataWithMl, "Process data for Ds1 analysis with Ml", false); - - void processDs2StarData(aod::HfRedCollisions const& collisions, ReducedReso const& candidates, aod::HfRed3PrNoTrks const& charmBachs, aod::HfRedVzeros const& v0Bachs) - { - processData(collisions, candidates, charmBachs, v0Bachs); - } - PROCESS_SWITCH(HfTaskCharmResoReduced, processDs2StarData, "Process data Ds2Star analysis without Ml", false); - - void processDs2StarDataWithMl(aod::HfRedCollisions const& collisions, ReducedResoWithMl const& candidates, soa::Join const& charmBachs, aod::HfRedVzeros const& v0Bachs) - { - processData(collisions, candidates, charmBachs, v0Bachs); - } - PROCESS_SWITCH(HfTaskCharmResoReduced, processDs2StarDataWithMl, "Process data Ds2Star analysis with Ml", false); - - void processDs1Mc(aod::HfRedCollisions const& collisions, ReducedResoMc const& candidates, aod::HfMcGenRedResos const& mcParticles, aod::HfRed3PrNoTrks const& charmBachs, aod::HfRedVzeros const& v0Bachs) - { - processData(collisions, candidates, charmBachs, v0Bachs); - fillCandMcGen(mcParticles); - } - PROCESS_SWITCH(HfTaskCharmResoReduced, processDs1Mc, "Process Mc for Ds1 analysis without Ml", false); - - void processDs1McWithMl(aod::HfRedCollisions const& collisions, ReducedResoWithMlMc const& candidates, aod::HfMcGenRedResos const& mcParticles, soa::Join const& charmBachs, aod::HfRedVzeros const& v0Bachs) - { - processData(collisions, candidates, charmBachs, v0Bachs); - fillCandMcGen(mcParticles); - } - PROCESS_SWITCH(HfTaskCharmResoReduced, processDs1McWithMl, "Process Mc for Ds1 analysis with Ml", false); - - void processDs2StarMc(aod::HfRedCollisions const& collisions, ReducedResoMc const& candidates, aod::HfMcGenRedResos const& mcParticles, aod::HfRed3PrNoTrks const& charmBachs, aod::HfRedVzeros const& v0Bachs) - { - processData(collisions, candidates, charmBachs, v0Bachs); - fillCandMcGen(mcParticles); - } - PROCESS_SWITCH(HfTaskCharmResoReduced, processDs2StarMc, "Process Mc for Ds2Star analysis without Ml", false); - - void processDs2StarMcWithMl(aod::HfRedCollisions const& collisions, ReducedResoWithMlMc const& candidates, aod::HfMcGenRedResos const& mcParticles, soa::Join const& charmBachs, aod::HfRedVzeros const& v0Bachs) - { - processData(collisions, candidates, charmBachs, v0Bachs); - fillCandMcGen(mcParticles); - } - PROCESS_SWITCH(HfTaskCharmResoReduced, processDs2StarMcWithMl, "Process Mc for Ds2Star analysis with Ml", false); - -}; // struct HfTaskCharmResoReduced -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/PWGHF/D2H/Tasks/taskCharmResoToDTrkReduced.cxx b/PWGHF/D2H/Tasks/taskCharmResoToDTrkReduced.cxx new file mode 100644 index 00000000000..362933d9124 --- /dev/null +++ b/PWGHF/D2H/Tasks/taskCharmResoToDTrkReduced.cxx @@ -0,0 +1,477 @@ +// 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. + +/// \file taskCharmResoToDTrkReduced.cxx +/// \brief Charmed Resonances decaying in a D meson and a Track analysis task +/// +/// \author Luca Aglietta , University and INFN Torino + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/Utils/utilsMcMatching.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace o2; +using namespace o2::soa; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +enum BachelorType : uint8_t { + K0s = 0, + Lambda, + AntiLambda +}; + +namespace o2::aod +{ +namespace hf_cand_reso_to_trk_lite +{ +DECLARE_SOA_COLUMN(PtBach0, ptBach0, float); //! Transverse momentum of bachelor 0 (GeV/c) +DECLARE_SOA_COLUMN(PtBach1, ptBach1, float); //! Transverse momentum of bachelor 1 (GeV/c) +DECLARE_SOA_COLUMN(MBach0, mBach0, float); //! Invariant mass of bachelor 0 (GeV/c) +DECLARE_SOA_COLUMN(MBach1, mBach1, float); //! Invariant mass of bachelor 1 (GeV/c) +DECLARE_SOA_COLUMN(MBachD0, mBachD0, float); //! Invariant mass of D0 bachelor (of bachelor 0) (GeV/c) +DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate (GeV/c2) +DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(P, p, float); //! Momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(Y, y, float); //! Rapidity of candidate +DECLARE_SOA_COLUMN(Eta, eta, float); //! Pseudorapidity of candidate +DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuth angle of candidate +DECLARE_SOA_COLUMN(E, e, float); //! Energy of candidate (GeV) +DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of candidate +DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float); //! VosThetaStar of candidate (GeV) +DECLARE_SOA_COLUMN(MlScoreBkgBach0, mlScoreBkgBach0, float); //! ML score for background class of charm daughter +DECLARE_SOA_COLUMN(MlScorePromptBach0, mlScorePromptBach0, float); //! ML score for prompt class of charm daughter +DECLARE_SOA_COLUMN(MlScoreNonPromptBach0, mlScoreNonPromptBach0, float); //! ML score for non-prompt class of charm daughter +DECLARE_SOA_COLUMN(ItsNClsProngMinBach0, itsNClsProngMinBach0, int); //! minimum value of number of ITS clusters for the decay daughter tracks of bachelor 0 +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsProngMinBach0, tpcNClsCrossedRowsProngMinBach0, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks of bachelor 0 +DECLARE_SOA_COLUMN(TpcChi2NClProngMaxBach0, tpcChi2NClProngMaxBach0, float); //! maximum value of TPC chi2 for the decay daughter tracks of bachelor 0 +DECLARE_SOA_COLUMN(ItsNClsBach1, itsNClsBach1, int); //! minimum value of number of ITS clusters for the decay daughter tracks of bachelor 1 +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsBach1, tpcNClsCrossedRowsBach1, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks of bachelor 1 +DECLARE_SOA_COLUMN(TpcChi2NClBach1, tpcChi2NClBach1, float); //! maximum value of TPC chi2 for the decay daughter tracks of bachelor 1 +DECLARE_SOA_COLUMN(TpcNSigmaBach1, tpcNSigmaBach1, float); //! NsigmaTPC for Bach1 for its mass hypothesis +DECLARE_SOA_COLUMN(TofNSigmaBach1, tofNSigmaBach1, float); //! NsigmaTOF for Bach1 for its mass hypothesis +DECLARE_SOA_COLUMN(TpcTofNSigmaBach1, tpcTofNSigmaBach1, float); //! Combined NsigmaTPC-TOF for Bach1 for its mass hypothesis +DECLARE_SOA_COLUMN(FlagMcMatch, flagMcMatch, int8_t); //! flag for decay channel classification reconstruction level +DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int); //! debug flag for mis-association at reconstruction level +DECLARE_SOA_COLUMN(Origin, origin, int8_t); //! Flag for origin of MC particle 1=promt, 2=FD +DECLARE_SOA_COLUMN(PtGen, ptGen, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(InvMassGen, invMassGen, float); //! Invariant mass of candidate (GeV/c2) +DECLARE_SOA_COLUMN(FlagCharmBach, flagCharmBach, int8_t); //! Flag for charm bachelor classification +DECLARE_SOA_COLUMN(FlagCharmBachInterm, flagCharmBachInterm, int8_t); //! Flag for charm bachelor classification intermediate +} // namespace hf_cand_reso_to_trk_lite + +DECLARE_SOA_TABLE(HfCandDTrkLites, "AOD", "HFCANDDTRKLITE", //! Table with some B0 properties + // Candidate Properties + hf_cand_reso_to_trk_lite::M, + hf_cand_reso_to_trk_lite::Pt, + hf_cand_reso_to_trk_lite::P, + hf_cand_reso_to_trk_lite::Y, + hf_cand_reso_to_trk_lite::Eta, + hf_cand_reso_to_trk_lite::Phi, + hf_cand_reso_to_trk_lite::E, + hf_cand_reso_to_trk_lite::CosThetaStar, + hf_cand_reso_to_trk_lite::Sign, + // Bachelors Properties + hf_cand_reso_to_trk_lite::MBach0, + hf_cand_reso_to_trk_lite::PtBach0, + hf_cand_reso_to_trk_lite::MlScoreBkgBach0, + hf_cand_reso_to_trk_lite::MlScorePromptBach0, + hf_cand_reso_to_trk_lite::MlScoreNonPromptBach0, + hf_cand_reso_to_trk_lite::ItsNClsProngMinBach0, + hf_cand_reso_to_trk_lite::TpcNClsCrossedRowsProngMinBach0, + hf_cand_reso_to_trk_lite::TpcChi2NClProngMaxBach0, + hf_cand_reso_to_trk_lite::PtBach1, + hf_cand_reso_to_trk_lite::ItsNClsBach1, + hf_cand_reso_to_trk_lite::TpcNClsCrossedRowsBach1, + hf_cand_reso_to_trk_lite::TpcChi2NClBach1, + hf_cand_reso_to_trk_lite::TpcNSigmaBach1, + hf_cand_reso_to_trk_lite::TofNSigmaBach1, + hf_cand_reso_to_trk_lite::TpcTofNSigmaBach1, + // MC + hf_cand_reso_to_trk_lite::FlagMcMatch, + hf_cand_reso_to_trk_lite::DebugMcRec, + hf_cand_reso_to_trk_lite::Origin, + hf_cand_reso_to_trk_lite::PtGen, + hf_cand_reso_to_trk_lite::InvMassGen, + hf_cand_reso_to_trk_lite::FlagCharmBach, + hf_cand_reso_to_trk_lite::FlagCharmBachInterm); + +DECLARE_SOA_TABLE(HfGenResoLites, "AOD", "HFGENRESOLITE", //! Table with some B0 properties + hf_cand_reso_to_trk_lite::Pt, + hf_cand_reso_to_trk_lite::Y, + hf_cand_reso_to_trk_lite::Origin, + hf_cand_reso_to_trk_lite::FlagMcMatch); + +} // namespace o2::aod + +enum DecayChannel : uint8_t { + D0Kplus = 0 +}; + +struct HfTaskCharmResoToDTrkReduced { + Produces hfCandResoLite; + Produces hfGenResoLite; + + Configurable doWrongSign{"doWrongSign", false, "Flag to enable wrong sign candidates"}; + Configurable ptMinReso{"ptMinReso", -1, "Discard events with smaller pT"}; + Configurable fillTrees{"fillTrees", true, "Fill output Trees"}; + Configurable fillSparses{"fillSparses", false, "Fill output Sparses"}; + Configurable useDeltaMass{"useDeltaMass", true, "Use Delta Mass for resonance invariant Mass calculation"}; + Configurable fillOnlySignal{"fillOnlySignal", false, "Flag to Fill only signal candidates (MC only)"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", -1, "max. cand. rapidity"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "max. track pseudo-rapidity for acceptance calculation"}; + Configurable ptTrackMin{"ptTrackMin", 0.1, "min. track transverse momentum for acceptance calculation"}; + Configurable massResoMin{"massResoMin", 0.2, "min. mass of resonance"}; + Configurable massResoMax{"massResoMax", 1.29, "max. mass of resonance"}; + + using ReducedReso2PrTrk = soa::Join; + using ReducedReso2PrTrkMC = soa::Join; + + // Configurables axis for histos + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisPtProng0{"axisPtProng0", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "prong0 bach. #it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisPtProng1{"axisPtProng1", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "prong1 bach. #it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisInvMassReso{"axisInvMassReso", {200, 2.34, 2.74}, "inv. mass (DV_{0}) (GeV/#it{c}^{2})"}; + ConfigurableAxis axisInvMassProng0{"axisInvMassProng0", {175, 1.70, 2.05}, "inv. mass (D) (GeV/#it{c}^{2})"}; + ConfigurableAxis axisCosThetaStar{"axisCosThetaStar", {40, -1, 1}, "cos(#vartheta*)"}; + ConfigurableAxis axisBkgBdtScore{"axisBkgBdtScore", {100, 0, 1}, "bkg BDT Score"}; + ConfigurableAxis axisNonPromptBdtScore{"axisNonPromptBdtScore", {100, 0, 1}, "non-prompt BDT Score"}; + ConfigurableAxis axisEta{"axisEta", {30, -1.5, 1.5}, "pseudorapidity"}; + ConfigurableAxis axisOrigin{"axisOrigin", {3, -0.5, 2.5}, "origin"}; + ConfigurableAxis axisFlag{"axisFlag", {65, -32.5, 32.5}, "mc flag"}; + + // Histogram Registry + HistogramRegistry registry; + + // init + void init(InitContext&) + { + registry.add("hMass", "Charm resonance candidates inv. mass", {HistType::kTH1D, {axisInvMassReso}}); + registry.add("hMassProng0", "D daughters inv. mass", {HistType::kTH1D, {axisInvMassProng0}}); + registry.add("hPt", "Charm resonance candidates pT", {HistType::kTH1D, {axisPt}}); + registry.add("hPtProng0", "D daughters pT", {HistType::kTH1D, {axisPtProng0}}); + registry.add("hPtProng1", "Track daughter pT", {HistType::kTH1D, {axisPtProng1}}); + registry.add("hNPvCont", "Collision number of PV contributors ; N contrib ; entries", {HistType::kTH1D, {{125, -0.5, 249.5}}}); + registry.add("hZvert", "Collision Z Vtx ; z PV [cm] ; entries", {HistType::kTH1D, {{120, -12., 12.}}}); + registry.add("hBz", "Collision Bz ; Bz [T] ; entries", {HistType::kTH1D, {{20, -10., 10.}}}); + registry.add("hSparse", "THn for production studies with cosThStar and BDT scores", HistType::kTHnSparseF, {axisPt, axisPtProng0, axisPtProng1, axisInvMassReso, axisInvMassProng0, axisCosThetaStar, axisBkgBdtScore, axisNonPromptBdtScore}); + + if (doprocessD0KplusMC || doprocessD0KplusMCWithMl) { + // gen histos + registry.add("hYRecPrompt", "Charm resonance candidates pT", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYRecNonPrompt", "Charm resonance candidates pT", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenAll", "Prompt {D_{S}}^j particles (generated);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenPrompt", "Prompt {D_{S}}^j particles (generated);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenPromptWithProngsInAcceptance", "Prompt {D_{S}}^j particles (generated-daughters in acceptance);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenNonPrompt", "NonPrompt {D_{S}}^j particles (generated);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenNonPromptWithProngsInAcceptance", "NonPrompt {D_{S}}^j particles (generated-daughters in acceptance);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + if (fillSparses) { + registry.add("hPtYGenSig", "{D_{S}}^j particles (generated);#it{p}_{T}({D_{S}}^j) (GeV/#it{c});#it{y}({D_{S}}^j)", {HistType::kTHnSparseF, {axisPt, axisEta, axisOrigin, axisFlag}}); + registry.add("hPtYWithProngsInAccepanceGenSig", "{D_{S}}^j particles (generated-daughters in acceptance);#it{p}_{T}({D_{S}}^j) (GeV/#it{c});#it{y}({D_{S}}^j)", {HistType::kTHnSparseF, {axisPt, axisEta, axisOrigin, axisFlag}}); + } + } + } + + // Fill histograms + /// \tparam channel is the decay channel of the Resonance + /// \param candidate is a candidate + /// \param coll is a reduced collision + /// \param bach0 is a bachelor of the candidate + /// \param bach1 is a bachelor of the candidate + template + void fillCand(const Cand& candidate, const Coll& collision, const CharmBach& bach0, const TrkBach& bach1) + { + // Base + float massReso{0}, cosThetaStar{0}; + int8_t sign{0}; + float tpcNSigmaBach1{0}, tofNSigmaBach1{0}, tpcTofNSigmaBach1{0}; + if constexpr (channel == DecayChannel::D0Kplus) { + massReso = useDeltaMass ? candidate.invMass() + MassD0 : candidate.invMass(); + cosThetaStar = RecoDecay::cosThetaStar(std::array{bach0.pVector(), bach1.pVector()}, std::array{MassD0, MassKPlus}, massReso, 0); + tpcNSigmaBach1 = bach1.tpcNSigmaKa(); + tofNSigmaBach1 = bach1.tofNSigmaKa(); + tpcTofNSigmaBach1 = bach1.tpcTofNSigmaKa(); + sign = bach1.sign(); + } + float y = RecoDecay::y(std::array{candidate.px(), candidate.py(), candidate.pz()}, massReso); + float eta = RecoDecay::eta(std::array{candidate.px(), candidate.py(), candidate.pz()}); + float phi = RecoDecay::phi(candidate.px(), candidate.py()); + float p = RecoDecay::p(std::array{candidate.px(), candidate.py(), candidate.pz()}); + float e = RecoDecay::e(std::array{candidate.px(), candidate.py(), candidate.pz()}, massReso); + + // MC Rec + float ptGen{-1.}, invMassGen{-1}; + int8_t origin{0}, flagMcMatchRec{0}, flagCharmBach{0}, flagCharmBachInterm{0}; + int debugMcRec{-1}; + if constexpr (doMc) { + ptGen = candidate.ptGen(); + origin = candidate.origin(); + flagMcMatchRec = candidate.flagMcMatchRec(); + debugMcRec = candidate.debugMcRec(); + invMassGen = candidate.invMassGen(); + flagCharmBach = candidate.flagMcMatchRecD(); + flagCharmBachInterm = candidate.flagMcMatchChanD(); + if (fillOnlySignal) { + if (channel == DecayChannel::D0Kplus && + !hf_decay::hf_cand_reso::particlesToD0Kplus.contains(static_cast(std::abs(flagMcMatchRec)))) { + return; + } + } + if (origin == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("hYRecPrompt"), candidate.pt(), y); + } else if (origin == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hYRecNonPrompt"), candidate.pt(), y); + } + } + + // Ml + float mlScoreBkg{-1.}, mlScorePrompt{-1.}, mlScoreNonPrompt{-1.}; + if constexpr (withMl) { + if constexpr (channel == DecayChannel::D0Kplus) { + if (bach1.sign() > 0 && !doWrongSign) { + mlScoreBkg = bach0.mlScoreBkgMassHypo0(); + mlScorePrompt = bach0.mlScorePromptMassHypo0(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo0(); + } else if (bach1.sign() < 0 && !doWrongSign) { + mlScoreBkg = bach0.mlScoreBkgMassHypo1(); + mlScorePrompt = bach0.mlScorePromptMassHypo1(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo1(); + } else if (bach1.sign() > 0 && doWrongSign) { + mlScoreBkg = bach0.mlScoreBkgMassHypo1(); + mlScorePrompt = bach0.mlScorePromptMassHypo1(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo1(); + } else if (bach1.sign() < 0 && doWrongSign) { + mlScoreBkg = bach0.mlScoreBkgMassHypo0(); + mlScorePrompt = bach0.mlScorePromptMassHypo0(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo0(); + } + } else { + mlScoreBkg = bach0.mlScoreBkgMassHypo0(); + mlScorePrompt = bach0.mlScorePromptMassHypo0(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo0(); + } + } + // Collision properties + registry.fill(HIST("hNPvCont"), collision.numContrib()); + registry.fill(HIST("hZvert"), collision.posZ()); + registry.fill(HIST("hBz"), collision.bz()); + // Candidate properties + registry.fill(HIST("hMass"), candidate.invMass()); + registry.fill(HIST("hMassProng0"), candidate.invMassProng0()); + registry.fill(HIST("hPt"), candidate.pt()); + registry.fill(HIST("hPtProng0"), candidate.ptProng0()); + registry.fill(HIST("hPtProng1"), candidate.ptProng1()); + if (fillSparses) { + registry.fill(HIST("hSparse"), candidate.pt(), candidate.ptProng0(), candidate.ptProng1(), candidate.invMass(), candidate.invMassProng0(), cosThetaStar, mlScoreBkg, mlScoreNonPrompt); + } + if (fillTrees) { + hfCandResoLite( + candidate.invMass(), + candidate.pt(), + p, + y, + eta, + phi, + e, + cosThetaStar, + sign, + // Bachelors Properties + candidate.invMassProng0(), + bach0.pt(), + mlScoreBkg, + mlScorePrompt, + mlScoreNonPrompt, + bach0.itsNClsProngMin(), + bach0.tpcNClsCrossedRowsProngMin(), + bach0.tpcChi2NClProngMax(), + bach1.pt(), + bach1.itsNCls(), + bach1.tpcNClsCrossedRows(), + bach1.tpcChi2NCl(), + tpcNSigmaBach1, + tofNSigmaBach1, + tpcTofNSigmaBach1, + // MC + flagMcMatchRec, + debugMcRec, + origin, + ptGen, + invMassGen, + flagCharmBach, + flagCharmBachInterm); + } + } // fillCand + + // Process data + /// \tparam channel is the decay channel of the Resonance + /// \param Coll is the reduced collisions table + /// \param CharmBach is the reduced 3 prong table + /// \param TrkBach is the reduced v0 table + /// \param Cand is the candidates table + template + void processData(Coll const&, Candidates const& candidates, CharmBach const&, aod::HfRedTrkNoParams const&) + { + for (const auto& cand : candidates) { + if (ptMinReso >= 0 && cand.pt() < ptMinReso) { + continue; + } + if ((massResoMin >= 0 && cand.invMass() < massResoMin) || + (massResoMax >= 0 && cand.invMass() > massResoMax)) { + continue; + } + if (doWrongSign && cand.isWrongSign() == 0) { + continue; + } else if (!doWrongSign && cand.isWrongSign() != 0) { + continue; + } + + float massReso{0}; + if (useDeltaMass) { + switch (channel) { + case DecayChannel::D0Kplus: + massReso = cand.invMass() + MassD0; + break; + default: + break; + } + } else { + massReso = cand.invMass(); + } + if (yCandRecoMax >= 0. && std::abs(RecoDecay::y(std::array{cand.px(), cand.py(), cand.pz()}, massReso)) > yCandRecoMax) { + continue; + } + auto coll = cand.template hfRedCollision_as(); + auto bach0 = cand.template prong0_as(); + auto bach1 = cand.template prong1_as(); + fillCand(cand, coll, bach0, bach1); + } + } + + /// Selection of resonance daughters in geometrical acceptance + /// \param etaProng is the pseudorapidity of Resonance prong + /// \param ptProng is the pT of Resonance prong + /// \return true if prong is in geometrical acceptance + template + bool isProngInAcceptance(const T& etaProng, const T& ptProng) + { + return std::abs(etaProng) <= etaTrackMax && ptProng >= ptTrackMin; + } + + /// Fill particle histograms (gen MC truth) + template + void fillCandMcGen(aod::HfMcGenRedResos const& mcParticles) + { + for (const auto& particle : mcParticles) { + auto ptParticle = particle.ptTrack(); + auto yParticle = particle.yTrack(); + auto originParticle = particle.origin(); + auto flag = particle.flagMcMatchGen(); + std::array ptProngs = {particle.ptProng0(), particle.ptProng1()}; + std::array etaProngs = {particle.etaProng0(), particle.etaProng1()}; + bool prongsInAcc = isProngInAcceptance(etaProngs[0], ptProngs[0]) && isProngInAcceptance(etaProngs[1], ptProngs[1]); + if (channel == DecayChannel::D0Kplus && + !hf_decay::hf_cand_reso::particlesToD0Kplus.contains(static_cast(std::abs(flag)))) { + continue; + } + registry.fill(HIST("hYGenAll"), ptParticle, yParticle); + if (yCandGenMax >= 0. && std::abs(yParticle) > yCandGenMax) { + continue; + } + if (originParticle == RecoDecay::OriginType::Prompt) { // prompt particles + registry.fill(HIST("hYGenPrompt"), ptParticle, yParticle); + if (prongsInAcc) { + registry.fill(HIST("hYGenPromptWithProngsInAcceptance"), ptParticle, yParticle); + } + } else if (originParticle == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hYGenNonPrompt"), ptParticle, yParticle); + if (prongsInAcc) { + registry.fill(HIST("hYGenNonPromptWithProngsInAcceptance"), ptParticle, yParticle); + } + } + if (fillSparses) { + registry.fill(HIST("hPtYGenSig"), ptParticle, yParticle, originParticle, flag); + if (prongsInAcc) { + registry.fill(HIST("hPtYWithProngsInAccepanceGenSig"), ptParticle, yParticle, originParticle, flag); + } + } + if (fillTrees) { + hfGenResoLite(ptParticle, yParticle, originParticle, flag); + } + } + } // fillCandMcGen + + // process functions + void processD0KplusData(aod::HfRedCollisions const& collisions, + ReducedReso2PrTrk const& candidates, + aod::HfRed2PrNoTrks const& charmBachs, + aod::HfRedTrkNoParams const& trkBachs) + { + processData(collisions, candidates, charmBachs, trkBachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDTrkReduced, processD0KplusData, "Process data for D0Kplus analysis", true); + + // Process data with ML + void processD0KplusDataWithMl(aod::HfRedCollisions const& collisions, + ReducedReso2PrTrk const& candidates, + soa::Join const& charmBachs, + aod::HfRedTrkNoParams const& trkBachs) + { + processData(collisions, candidates, charmBachs, trkBachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDTrkReduced, processD0KplusDataWithMl, "Process data for D0Kplus analysis with Ml", false); + + // MC + void processD0KplusMC(aod::HfRedCollisions const& collisions, + ReducedReso2PrTrkMC const& candidates, + aod::HfRed2PrNoTrks const& charmBachs, + aod::HfRedTrkNoParams const& trkBachs, + aod::HfMcGenRedResos const& mcParticles) + { + processData(collisions, candidates, charmBachs, trkBachs); + fillCandMcGen(mcParticles); + } + PROCESS_SWITCH(HfTaskCharmResoToDTrkReduced, processD0KplusMC, "Process MC for D0Kplus analysis", false); + + // MC with Ml + void processD0KplusMCWithMl(aod::HfRedCollisions const& collisions, + ReducedReso2PrTrkMC const& candidates, + soa::Join const& charmBachs, + aod::HfRedTrkNoParams const& trkBachs, + aod::HfMcGenRedResos const& mcParticles) + { + processData(collisions, candidates, charmBachs, trkBachs); + fillCandMcGen(mcParticles); + } + PROCESS_SWITCH(HfTaskCharmResoToDTrkReduced, processD0KplusMCWithMl, "Process MC for D0Kplus analysis with Ml", false); + +}; // struct HfTaskCharmResoToDTrkReduced +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/Tasks/taskCharmResoToDV0Reduced.cxx b/PWGHF/D2H/Tasks/taskCharmResoToDV0Reduced.cxx new file mode 100644 index 00000000000..360b8a3002f --- /dev/null +++ b/PWGHF/D2H/Tasks/taskCharmResoToDV0Reduced.cxx @@ -0,0 +1,658 @@ +// 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. + +/// \file taskCharmResoToDV0Reduced.cxx +/// \brief Charmed Resonances decaying in a D meson and a V0 analysis task +/// +/// \author Luca Aglietta , University and INFN Torino + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/Utils/utilsMcMatching.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace o2; +using namespace o2::soa; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +enum BachelorType : uint8_t { + K0s = 0, + Lambda, + AntiLambda +}; + +namespace o2::aod +{ +namespace hf_cand_reso_to_v0_lite +{ +DECLARE_SOA_COLUMN(PtBach0, ptBach0, float); //! Transverse momentum of bachelor 0 (GeV/c) +DECLARE_SOA_COLUMN(PtBach1, ptBach1, float); //! Transverse momentum of bachelor 1 (GeV/c) +DECLARE_SOA_COLUMN(MBach0, mBach0, float); //! Invariant mass of bachelor 0 (GeV/c) +DECLARE_SOA_COLUMN(MBach1, mBach1, float); //! Invariant mass of bachelor 1 (GeV/c) +DECLARE_SOA_COLUMN(MBachD0, mBachD0, float); //! Invariant mass of D0 bachelor (of bachelor 0) (GeV/c) +DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate (GeV/c2) +DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(P, p, float); //! Momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(Y, y, float); //! Rapidity of candidate +DECLARE_SOA_COLUMN(Eta, eta, float); //! Pseudorapidity of candidate +DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuth angle of candidate +DECLARE_SOA_COLUMN(E, e, float); //! Energy of candidate (GeV) +DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of candidate +DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float); //! VosThetaStar of candidate (GeV) +DECLARE_SOA_COLUMN(MlScoreBkgBach0, mlScoreBkgBach0, float); //! ML score for background class of charm daughter +DECLARE_SOA_COLUMN(MlScorePromptBach0, mlScorePromptBach0, float); //! ML score for prompt class of charm daughter +DECLARE_SOA_COLUMN(MlScoreNonPromptBach0, mlScoreNonPromptBach0, float); //! ML score for non-prompt class of charm daughter +DECLARE_SOA_COLUMN(ItsNClsProngMinBach0, itsNClsProngMinBach0, int); //! minimum value of number of ITS clusters for the decay daughter tracks of bachelor 0 +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsProngMinBach0, tpcNClsCrossedRowsProngMinBach0, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks of bachelor 0 +DECLARE_SOA_COLUMN(TpcChi2NClProngMaxBach0, tpcChi2NClProngMaxBach0, float); //! maximum value of TPC chi2 for the decay daughter tracks of bachelor 0 +DECLARE_SOA_COLUMN(ItsNClsSoftPi, itsNClsSoftPi, int); //! minimum value of number of ITS clusters for the decay daughter tracks of bachelor 0 +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsSoftPi, tpcNClsCrossedRowsSoftPi, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks of bachelor 0 +DECLARE_SOA_COLUMN(TpcChi2NClSoftPi, tpcChi2NClSoftPi, float); //! maximum value of TPC chi2 for the decay daughter tracks of bachelor 0 +DECLARE_SOA_COLUMN(ItsNClsProngMinBach1, itsNClsProngMinBach1, int); //! minimum value of number of ITS clusters for the decay daughter tracks of bachelor 1 +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsProngMinBach1, tpcNClsCrossedRowsProngMinBach1, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks of bachelor 1 +DECLARE_SOA_COLUMN(TpcChi2NClProngMaxBach1, tpcChi2NClProngMaxBach1, float); //! maximum value of TPC chi2 for the decay daughter tracks of bachelor 1 +DECLARE_SOA_COLUMN(CpaBach1, cpaBach1, float); //! Cosine of Pointing Angle of bachelor 1 +DECLARE_SOA_COLUMN(DcaBach1, dcaBach1, float); //! DCA of bachelor 1 +DECLARE_SOA_COLUMN(RadiusBach1, radiusBach1, float); //! Radius of bachelor 1 +DECLARE_SOA_COLUMN(FlagMcMatch, flagMcMatch, int8_t); //! flag for decay channel classification reconstruction level +DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int); //! debug flag for mis-association at reconstruction level +DECLARE_SOA_COLUMN(Origin, origin, int8_t); //! Flag for origin of MC particle 1=promt, 2=FD +DECLARE_SOA_COLUMN(PtGen, ptGen, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(InvMassGen, invMassGen, float); //! Invariant mass of candidate (GeV/c2) +DECLARE_SOA_COLUMN(FlagCharmBach, flagCharmBach, int8_t); //! Flag for charm bachelor classification +DECLARE_SOA_COLUMN(FlagCharmBachInterm, flagCharmBachInterm, int8_t); //! Flag for charm bachelor classification intermediate +} // namespace hf_cand_reso_to_v0_lite + +DECLARE_SOA_TABLE(HfCandDV0Lites, "AOD", "HFCANDDV0LITE", //! Table with some Resonances properties + // Candidate Properties + hf_cand_reso_to_v0_lite::M, + hf_cand_reso_to_v0_lite::Pt, + hf_cand_reso_to_v0_lite::P, + hf_cand_reso_to_v0_lite::Y, + hf_cand_reso_to_v0_lite::Eta, + hf_cand_reso_to_v0_lite::Phi, + hf_cand_reso_to_v0_lite::E, + hf_cand_reso_to_v0_lite::CosThetaStar, + hf_cand_reso_to_v0_lite::Sign, + // Bachelors Properties + hf_cand_reso_to_v0_lite::MBach0, + hf_cand_reso_to_v0_lite::PtBach0, + hf_cand_reso_to_v0_lite::MlScoreBkgBach0, + hf_cand_reso_to_v0_lite::MlScorePromptBach0, + hf_cand_reso_to_v0_lite::MlScoreNonPromptBach0, + hf_cand_reso_to_v0_lite::ItsNClsProngMinBach0, + hf_cand_reso_to_v0_lite::TpcNClsCrossedRowsProngMinBach0, + hf_cand_reso_to_v0_lite::TpcChi2NClProngMaxBach0, + hf_cand_reso_to_v0_lite::ItsNClsSoftPi, + hf_cand_reso_to_v0_lite::TpcNClsCrossedRowsSoftPi, + hf_cand_reso_to_v0_lite::TpcChi2NClSoftPi, + hf_cand_reso_to_v0_lite::MBach1, + hf_cand_reso_to_v0_lite::PtBach1, + hf_cand_reso_to_v0_lite::CpaBach1, + hf_cand_reso_to_v0_lite::DcaBach1, + hf_cand_reso_to_v0_lite::RadiusBach1, + hf_cand_reso_to_v0_lite::ItsNClsProngMinBach1, + hf_cand_reso_to_v0_lite::TpcNClsCrossedRowsProngMinBach1, + hf_cand_reso_to_v0_lite::TpcChi2NClProngMaxBach1, + // MC + hf_cand_reso_to_v0_lite::FlagMcMatch, + hf_cand_reso_to_v0_lite::DebugMcRec, + hf_cand_reso_to_v0_lite::Origin, + hf_cand_reso_to_v0_lite::PtGen, + hf_cand_reso_to_v0_lite::InvMassGen, + hf_cand_reso_to_v0_lite::FlagCharmBach, + hf_cand_reso_to_v0_lite::FlagCharmBachInterm); + +DECLARE_SOA_TABLE(HfGenResoLites, "AOD", "HFGENRESOLITE", //! Table with some B0 properties + hf_cand_reso_to_v0_lite::Pt, + hf_cand_reso_to_v0_lite::Y, + hf_cand_reso_to_v0_lite::Origin, + hf_cand_reso_to_v0_lite::FlagMcMatch); + +} // namespace o2::aod + +enum DecayChannel : uint8_t { + DstarK0s = 0, + DplusK0s, + DplusLambda, + D0Lambda +}; + +struct HfTaskCharmResoToDV0Reduced { + Produces hfCandResoLite; + Produces hfGenResoLite; + + Configurable doWrongSign{"doWrongSign", false, "Flag to enable wrong sign candidates"}; + Configurable ptMinReso{"ptMinReso", -1, "Discard events with smaller pT"}; + Configurable fillTrees{"fillTrees", true, "Fill output Trees"}; + Configurable fillSparses{"fillSparses", false, "Fill output Sparses"}; + Configurable useDeltaMass{"useDeltaMass", true, "Use Delta Mass for resonance invariant Mass calculation"}; + Configurable fillOnlySignal{"fillOnlySignal", false, "Flag to Fill only signal candidates (MC only)"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", -1, "max. cand. rapidity"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "max. track pseudo-rapidity for acceptance calculation"}; + Configurable ptTrackMin{"ptTrackMin", 0.1, "min. track transverse momentum for acceptance calculation"}; + Configurable massResoMin{"massResoMin", 0.49, "min. mass of resonance"}; + Configurable massResoMax{"massResoMax", 1.29, "max. mass of resonance"}; + + using ReducedReso3PrV0 = soa::Join; + using ReducedResoDstarV0 = soa::Join; + using ReducedReso2PrV0 = soa::Join; + using ReducedReso3PrV0MC = soa::Join; + using ReducedResoDstarV0MC = soa::Join; + using ReducedReso2PrV0MC = soa::Join; + + // Configurables axis for histos + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisPtProng0{"axisPtProng0", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "prong0 bach. #it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisPtProng1{"axisPtProng1", {VARIABLE_WIDTH, 0., 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f, 50.f}, "prong1 bach. #it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisInvMassReso{"axisInvMassReso", {200, 2.34, 2.74}, "inv. mass (DV_{0}) (GeV/#it{c}^{2})"}; + ConfigurableAxis axisInvMassProng0{"axisInvMassProng0", {175, 1.70, 2.05}, "inv. mass (D) (GeV/#it{c}^{2})"}; + ConfigurableAxis axisInvMassProng1{"axisInvMassProng1", {80, 0.46, 0.54}, "inv. mass ({V}_{0}) (GeV/#it{c}^{2})"}; + ConfigurableAxis axisCosThetaStar{"axisCosThetaStar", {40, -1, 1}, "cos(#vartheta*)"}; + ConfigurableAxis axisBkgBdtScore{"axisBkgBdtScore", {100, 0, 1}, "bkg BDT Score"}; + ConfigurableAxis axisNonPromptBdtScore{"axisNonPromptBdtScore", {100, 0, 1}, "non-prompt BDT Score"}; + ConfigurableAxis axisEta{"axisEta", {30, -1.5, 1.5}, "pseudorapidity"}; + ConfigurableAxis axisOrigin{"axisOrigin", {3, -0.5, 2.5}, "origin"}; + ConfigurableAxis axisFlag{"axisFlag", {65, -32.5, 32.5}, "mc flag"}; + + // Histogram Registry + HistogramRegistry registry; + + // init + void init(InitContext&) + { + registry.add("hMass", "Charm resonance candidates inv. mass", {HistType::kTH1D, {axisInvMassReso}}); + registry.add("hMassProng0", "D daughters inv. mass", {HistType::kTH1D, {axisInvMassProng0}}); + registry.add("hMassProng1", "V0 daughter inv. mass", {HistType::kTH1D, {axisInvMassProng1}}); + registry.add("hPt", "Charm resonance candidates pT", {HistType::kTH1D, {axisPt}}); + registry.add("hPtProng0", "D daughters pT", {HistType::kTH1D, {axisPtProng0}}); + registry.add("hPtProng1", "V0 daughter pT", {HistType::kTH1D, {axisPtProng1}}); + registry.add("hNPvCont", "Collision number of PV contributors ; N contrib ; entries", {HistType::kTH1D, {{125, -0.5, 249.5}}}); + registry.add("hZvert", "Collision Z Vtx ; z PV [cm] ; entries", {HistType::kTH1D, {{120, -12., 12.}}}); + registry.add("hBz", "Collision Bz ; Bz [T] ; entries", {HistType::kTH1D, {{20, -10., 10.}}}); + registry.add("hSparse", "THn for production studies with cosThStar and BDT scores", HistType::kTHnSparseF, {axisPt, axisPtProng0, axisPtProng1, axisInvMassReso, axisInvMassProng0, axisInvMassProng1, axisCosThetaStar, axisBkgBdtScore, axisNonPromptBdtScore}); + + if (doprocessDstarK0sMC || doprocessDplusK0sMC || doprocessDstarK0sMCWithMl || doprocessDplusK0sMCWithMl || + doprocessDplusLambdaMC || doprocessD0LambdaMC || doprocessDplusLambdaMCWithMl || doprocessD0LambdaMCWithMl) { + // gen histos + registry.add("hYRecPrompt", "Charm resonance candidates pT", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYRecNonPrompt", "Charm resonance candidates pT", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenAll", "Prompt {D_{S}}^j particles (generated);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenPrompt", "Prompt {D_{S}}^j particles (generated);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenPromptWithProngsInAcceptance", "Prompt {D_{S}}^j particles (generated-daughters in acceptance);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenNonPrompt", "NonPrompt {D_{S}}^j particles (generated);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + registry.add("hYGenNonPromptWithProngsInAcceptance", "NonPrompt {D_{S}}^j particles (generated-daughters in acceptance);#it{p}_{T}^{gen}({D_{S}}^j) (GeV/#it{c});#it{y}^{gen}({D_{S}}^j);entries", {HistType::kTH2D, {axisPt, axisEta}}); + if (fillSparses) { + registry.add("hPtYGenSig", "{D_{S}}^j particles (generated);#it{p}_{T}({D_{S}}^j) (GeV/#it{c});#it{y}({D_{S}}^j)", {HistType::kTHnSparseF, {axisPt, axisEta, axisOrigin, axisFlag}}); + registry.add("hPtYWithProngsInAccepanceGenSig", "{D_{S}}^j particles (generated-daughters in acceptance);#it{p}_{T}({D_{S}}^j) (GeV/#it{c});#it{y}({D_{S}}^j)", {HistType::kTHnSparseF, {axisPt, axisEta, axisOrigin, axisFlag}}); + } + } + } + + // Fill histograms + /// \tparam channel is the decay channel of the Resonance + /// \param candidate is a candidate + /// \param coll is a reduced collision + /// \param bach0 is a bachelor of the candidate + /// \param bach1 is a bachelor of the candidate + template + void fillCand(const Cand& candidate, const Coll& collision, const CharmBach& bach0, const V0Bach& bach1) + { + // Base + float massReso{0}, cosThetaStar{0}; + int8_t sign{0}; + int itsNClsSoftPi{0}, tpcNClsCrossedRowsSoftPi{0}; + float tpcChi2NClSoftPi{0.}; + if constexpr (channel == DecayChannel::DstarK0s) { + sign = bach0.sign(); + massReso = useDeltaMass ? candidate.invMass() + MassDStar : candidate.invMass(); + cosThetaStar = RecoDecay::cosThetaStar(std::array{bach0.pVector(), bach1.pVector()}, std::array{MassDStar, MassK0}, massReso, 0); + itsNClsSoftPi = bach0.itsNClsSoftPi(); + tpcNClsCrossedRowsSoftPi = bach0.tpcNClsCrossedRowsSoftPi(); + tpcChi2NClSoftPi = bach0.tpcChi2NClSoftPi(); + } else if constexpr (channel == DecayChannel::DplusK0s) { + sign = bach0.sign(); + massReso = useDeltaMass ? candidate.invMass() + MassDPlus : candidate.invMass(); + cosThetaStar = RecoDecay::cosThetaStar(std::array{bach0.pVector(), bach1.pVector()}, std::array{MassDPlus, MassK0}, massReso, 0); + } else if constexpr (channel == DecayChannel::DplusLambda) { + sign = bach0.sign(); + massReso = useDeltaMass ? candidate.invMass() + MassDPlus : candidate.invMass(); + cosThetaStar = RecoDecay::cosThetaStar(std::array{bach0.pVector(), bach1.pVector()}, std::array{MassDPlus, MassLambda0}, massReso, 0); + } else if constexpr (channel == DecayChannel::D0Lambda) { + massReso = useDeltaMass ? candidate.invMass() + MassD0 : candidate.invMass(); + cosThetaStar = RecoDecay::cosThetaStar(std::array{bach0.pVector(), bach1.pVector()}, std::array{MassD0, MassLambda0}, massReso, 0); + } + float y = RecoDecay::y(std::array{candidate.px(), candidate.py(), candidate.pz()}, massReso); + float eta = RecoDecay::eta(std::array{candidate.px(), candidate.py(), candidate.pz()}); + float phi = RecoDecay::phi(candidate.px(), candidate.py()); + float p = RecoDecay::p(std::array{candidate.px(), candidate.py(), candidate.pz()}); + float e = RecoDecay::e(std::array{candidate.px(), candidate.py(), candidate.pz()}, massReso); + + // MC Rec + float ptGen{-1.}, invMassGen{-1}; + int8_t origin{0}, flagMcMatchRec{0}, flagCharmBach{0}, flagCharmBachInterm{0}; + int debugMcRec{-1}; + if constexpr (doMc) { + ptGen = candidate.ptGen(); + origin = candidate.origin(); + flagMcMatchRec = candidate.flagMcMatchRec(); + debugMcRec = candidate.debugMcRec(); + invMassGen = candidate.invMassGen(); + flagCharmBach = candidate.flagMcMatchRecD(); + flagCharmBachInterm = candidate.flagMcMatchChanD(); + if (fillOnlySignal) { + if (channel == DecayChannel::DstarK0s && + !hf_decay::hf_cand_reso::particlesToDstarK0s.contains(static_cast(std::abs(flagMcMatchRec)))) { + return; + } else if (channel == DecayChannel::DplusK0s && + !hf_decay::hf_cand_reso::particlesToDplusK0s.contains(static_cast(std::abs(flagMcMatchRec)))) { + return; + } else if (channel == DecayChannel::DplusLambda && + !hf_decay::hf_cand_reso::particlesToDplusLambda.contains(static_cast(std::abs(flagMcMatchRec)))) { + return; + } else if (channel == DecayChannel::D0Lambda && + !hf_decay::hf_cand_reso::particlesToD0Lambda.contains(static_cast(std::abs(flagMcMatchRec)))) { + return; + } + } + if (origin == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("hYRecPrompt"), candidate.pt(), y); + } else if (origin == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hYRecNonPrompt"), candidate.pt(), y); + } + } + + // Ml + float mlScoreBkg{-1.}, mlScorePrompt{-1.}, mlScoreNonPrompt{-1.}; + if constexpr (withMl) { + if constexpr (channel == DecayChannel::D0Lambda) { + if (TESTBIT(bach1.v0Type(), BachelorType::Lambda) && !doWrongSign) { + mlScoreBkg = bach0.mlScoreBkgMassHypo0(); + mlScorePrompt = bach0.mlScorePromptMassHypo0(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo0(); + } else if (TESTBIT(bach1.v0Type(), BachelorType::AntiLambda) && !doWrongSign) { + mlScoreBkg = bach0.mlScoreBkgMassHypo1(); + mlScorePrompt = bach0.mlScorePromptMassHypo1(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo1(); + } else if (TESTBIT(bach1.v0Type(), BachelorType::Lambda) && doWrongSign) { + mlScoreBkg = bach0.mlScoreBkgMassHypo1(); + mlScorePrompt = bach0.mlScorePromptMassHypo1(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo1(); + } else if (TESTBIT(bach1.v0Type(), BachelorType::AntiLambda) && doWrongSign) { + mlScoreBkg = bach0.mlScoreBkgMassHypo0(); + mlScorePrompt = bach0.mlScorePromptMassHypo0(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo0(); + } + } else { + mlScoreBkg = bach0.mlScoreBkgMassHypo0(); + mlScorePrompt = bach0.mlScorePromptMassHypo0(); + mlScoreNonPrompt = bach0.mlScoreNonpromptMassHypo0(); + } + } + // Collision properties + registry.fill(HIST("hNPvCont"), collision.numContrib()); + registry.fill(HIST("hZvert"), collision.posZ()); + registry.fill(HIST("hBz"), collision.bz()); + // Candidate properties + registry.fill(HIST("hMass"), candidate.invMass()); + registry.fill(HIST("hMassProng0"), candidate.invMassProng0()); + registry.fill(HIST("hMassProng1"), candidate.invMassProng1()); + registry.fill(HIST("hPt"), candidate.pt()); + registry.fill(HIST("hPtProng0"), candidate.ptProng0()); + registry.fill(HIST("hPtProng1"), candidate.ptProng1()); + if (fillSparses) { + registry.fill(HIST("hSparse"), candidate.pt(), candidate.ptProng0(), candidate.ptProng1(), candidate.invMass(), candidate.invMassProng0(), candidate.invMassProng1(), cosThetaStar, mlScoreBkg, mlScoreNonPrompt); + } + if (fillTrees) { + hfCandResoLite( + candidate.invMass(), + candidate.pt(), + p, + y, + eta, + phi, + e, + cosThetaStar, + sign, + // Bachelors Properties + candidate.invMassProng0(), + bach0.pt(), + mlScoreBkg, + mlScorePrompt, + mlScoreNonPrompt, + bach0.itsNClsProngMin(), + bach0.tpcNClsCrossedRowsProngMin(), + bach0.tpcChi2NClProngMax(), + itsNClsSoftPi, + tpcNClsCrossedRowsSoftPi, + tpcChi2NClSoftPi, + candidate.invMassProng1(), + bach1.pt(), + bach1.cpa(), + bach1.dca(), + bach1.v0Radius(), + bach1.itsNClsProngMin(), + bach1.tpcNClsCrossedRowsProngMin(), + bach1.tpcChi2NClProngMax(), + // MC + flagMcMatchRec, + debugMcRec, + origin, + ptGen, + invMassGen, + flagCharmBach, + flagCharmBachInterm); + } + } // fillCand + + // Process data + /// \tparam channel is the decay channel of the Resonance + /// \param Coll is the reduced collisions table + /// \param CharmBach is the reduced 3 prong table + /// \param V0Bach is the reduced v0 table + /// \param Cand is the candidates table + template + void processData(Coll const&, Candidates const& candidates, CharmBach const&, aod::HfRedVzeros const&) + { + for (const auto& cand : candidates) { + if (ptMinReso >= 0 && cand.pt() < ptMinReso) { + continue; + } + if ((massResoMin >= 0 && cand.invMass() < massResoMin) || + (massResoMax >= 0 && cand.invMass() > massResoMax)) { + continue; + } + if (doWrongSign && cand.isWrongSign() == 0) { + continue; + } else if (!doWrongSign && cand.isWrongSign() != 0) { + continue; + } + + float massReso{0}; + if (useDeltaMass) { + switch (channel) { + case DecayChannel::DstarK0s: + massReso = cand.invMass() + MassDStar; + break; + case DecayChannel::DplusK0s: + massReso = cand.invMass() + MassDPlus; + break; + case DecayChannel::DplusLambda: + massReso = cand.invMass() + MassDPlus; + break; + case DecayChannel::D0Lambda: + massReso = cand.invMass() + MassD0; + break; + default: + break; + } + } else { + massReso = cand.invMass(); + } + if (yCandRecoMax >= 0. && std::abs(RecoDecay::y(std::array{cand.px(), cand.py(), cand.pz()}, massReso)) > yCandRecoMax) { + continue; + } + auto coll = cand.template hfRedCollision_as(); + auto bach0 = cand.template prong0_as(); + auto bach1 = cand.template prong1_as(); + fillCand(cand, coll, bach0, bach1); + } + } + + /// Selection of resonance daughters in geometrical acceptance + /// \param etaProng is the pseudorapidity of Resonance prong + /// \param ptProng is the pT of Resonance prong + /// \return true if prong is in geometrical acceptance + template + bool isProngInAcceptance(const T& etaProng, const T& ptProng) + { + return std::abs(etaProng) <= etaTrackMax && ptProng >= ptTrackMin; + } + + /// Fill particle histograms (gen MC truth) + template + void fillCandMcGen(aod::HfMcGenRedResos const& mcParticles) + { + for (const auto& particle : mcParticles) { + auto ptParticle = particle.ptTrack(); + auto yParticle = particle.yTrack(); + auto originParticle = particle.origin(); + auto flag = particle.flagMcMatchGen(); + std::array ptProngs = {particle.ptProng0(), particle.ptProng1()}; + std::array etaProngs = {particle.etaProng0(), particle.etaProng1()}; + bool prongsInAcc = isProngInAcceptance(etaProngs[0], ptProngs[0]) && isProngInAcceptance(etaProngs[1], ptProngs[1]); + if (channel == DecayChannel::DstarK0s && + !hf_decay::hf_cand_reso::particlesToDstarK0s.contains(static_cast(std::abs(flag)))) { + continue; + } else if (channel == DecayChannel::DplusK0s && + !hf_decay::hf_cand_reso::particlesToDplusK0s.contains(static_cast(std::abs(flag)))) { + continue; + } else if (channel == DecayChannel::DplusLambda && + !hf_decay::hf_cand_reso::particlesToDplusLambda.contains(static_cast(std::abs(flag)))) { + continue; + } else if (channel == DecayChannel::D0Lambda && + !hf_decay::hf_cand_reso::particlesToD0Lambda.contains(static_cast(std::abs(flag)))) { + continue; + } + registry.fill(HIST("hYGenAll"), ptParticle, yParticle); + if (yCandGenMax >= 0. && std::abs(yParticle) > yCandGenMax) { + continue; + } + if (originParticle == RecoDecay::OriginType::Prompt) { // prompt particles + registry.fill(HIST("hYGenPrompt"), ptParticle, yParticle); + if (prongsInAcc) { + registry.fill(HIST("hYGenPromptWithProngsInAcceptance"), ptParticle, yParticle); + } + } else if (originParticle == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hYGenNonPrompt"), ptParticle, yParticle); + if (prongsInAcc) { + registry.fill(HIST("hYGenNonPromptWithProngsInAcceptance"), ptParticle, yParticle); + } + } + if (fillSparses) { + registry.fill(HIST("hPtYGenSig"), ptParticle, yParticle, originParticle, flag); + if (prongsInAcc) { + registry.fill(HIST("hPtYWithProngsInAccepanceGenSig"), ptParticle, yParticle, originParticle, flag); + } + } + if (fillTrees) { + hfGenResoLite(ptParticle, yParticle, originParticle, flag); + } + } + } // fillCandMcGen + + // process functions + void processDstarK0sData(aod::HfRedCollisions const& collisions, + ReducedResoDstarV0 const& candidates, + aod::HfRedDstarNoTrks const& charmBachs, + aod::HfRedVzeros const& v0Bachs) + { + processData(collisions, candidates, charmBachs, v0Bachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDstarK0sData, "Process data for DstarK0s analysis", true); + + void processDplusK0sData(aod::HfRedCollisions const& collisions, + ReducedReso3PrV0 const& candidates, + aod::HfRed3PrNoTrks const& charmBachs, + aod::HfRedVzeros const& v0Bachs) + { + processData(collisions, candidates, charmBachs, v0Bachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDplusK0sData, "Process data for DplusK0s analysis", false); + + void processDplusLambdaData(aod::HfRedCollisions const& collisions, + ReducedReso3PrV0 const& candidates, + aod::HfRed3PrNoTrks const& charmBachs, + aod::HfRedVzeros const& v0Bachs) + { + processData(collisions, candidates, charmBachs, v0Bachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDplusLambdaData, "Process data for DplusLambda analysis", false); + + void processD0LambdaData(aod::HfRedCollisions const& collisions, + ReducedReso2PrV0 const& candidates, + aod::HfRed2PrNoTrks const& charmBachs, + aod::HfRedVzeros const& v0Bachs) + { + processData(collisions, candidates, charmBachs, v0Bachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processD0LambdaData, "Process data for D0Lambda analysis", false); + + // Process data with ML + void processDstarK0sDataWithMl(aod::HfRedCollisions const& collisions, + ReducedResoDstarV0 const& candidates, + soa::Join const& charmBachs, + aod::HfRedVzeros const& v0Bachs) + { + processData(collisions, candidates, charmBachs, v0Bachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDstarK0sDataWithMl, "Process data for DstarK0s analysis with Ml", false); + + void processDplusK0sDataWithMl(aod::HfRedCollisions const& collisions, + ReducedReso3PrV0 const& candidates, + soa::Join const& charmBachs, + aod::HfRedVzeros const& v0Bachs) + { + processData(collisions, candidates, charmBachs, v0Bachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDplusK0sDataWithMl, "Process data for DplusK0s analysis with Ml", false); + + void processDplusLambdaDataWithMl(aod::HfRedCollisions const& collisions, + ReducedReso3PrV0 const& candidates, + soa::Join const& charmBachs, + aod::HfRedVzeros const& v0Bachs) + { + processData(collisions, candidates, charmBachs, v0Bachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDplusLambdaDataWithMl, "Process data for DplusLambda analysis with Ml", false); + + void processD0LambdaDataWithMl(aod::HfRedCollisions const& collisions, + ReducedReso2PrV0 const& candidates, + soa::Join const& charmBachs, + aod::HfRedVzeros const& v0Bachs) + { + processData(collisions, candidates, charmBachs, v0Bachs); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processD0LambdaDataWithMl, "Process data for D0Lambda analysis with Ml", false); + + // MC + void processDstarK0sMC(aod::HfRedCollisions const& collisions, + ReducedResoDstarV0MC const& candidates, + aod::HfRedDstarNoTrks const& charmBachs, + aod::HfRedVzeros const& v0Bachs, + aod::HfMcGenRedResos const& mcParticles) + { + processData(collisions, candidates, charmBachs, v0Bachs); + fillCandMcGen(mcParticles); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDstarK0sMC, "Process MC for DstarK0s analysis", false); + + void processDplusK0sMC(aod::HfRedCollisions const& collisions, + ReducedReso3PrV0MC const& candidates, + aod::HfRed3PrNoTrks const& charmBachs, + aod::HfRedVzeros const& v0Bachs, + aod::HfMcGenRedResos const& mcParticles) + { + processData(collisions, candidates, charmBachs, v0Bachs); + fillCandMcGen(mcParticles); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDplusK0sMC, "Process MC for DplusK0s analysis", false); + + void processDplusLambdaMC(aod::HfRedCollisions const& collisions, + ReducedReso3PrV0MC const& candidates, + aod::HfRed3PrNoTrks const& charmBachs, + aod::HfRedVzeros const& v0Bachs, + aod::HfMcGenRedResos const& mcParticles) + { + processData(collisions, candidates, charmBachs, v0Bachs); + fillCandMcGen(mcParticles); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDplusLambdaMC, "Process MC for DplusLambda analysis", false); + + void processD0LambdaMC(aod::HfRedCollisions const& collisions, + ReducedReso2PrV0MC const& candidates, + aod::HfRed2PrNoTrks const& charmBachs, + aod::HfRedVzeros const& v0Bachs, + aod::HfMcGenRedResos const& mcParticles) + { + processData(collisions, candidates, charmBachs, v0Bachs); + fillCandMcGen(mcParticles); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processD0LambdaMC, "Process MC for D0Lambda analysis", false); + + // MC with Ml + void processDstarK0sMCWithMl(aod::HfRedCollisions const& collisions, + ReducedResoDstarV0MC const& candidates, + soa::Join const& charmBachs, + aod::HfRedVzeros const& v0Bachs, + aod::HfMcGenRedResos const& charmBachsMc) + { + processData(collisions, candidates, charmBachs, v0Bachs); + fillCandMcGen(charmBachsMc); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDstarK0sMCWithMl, "Process MC for DstarK0s analysis with Ml", false); + + void processDplusK0sMCWithMl(aod::HfRedCollisions const& collisions, + ReducedReso3PrV0MC const& candidates, + soa::Join const& charmBachs, + aod::HfRedVzeros const& v0Bachs, + aod::HfMcGenRedResos const& mcParticles) + { + processData(collisions, candidates, charmBachs, v0Bachs); + fillCandMcGen(mcParticles); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDplusK0sMCWithMl, "Process MC for DplusK0s analysis with Ml", false); + + void processDplusLambdaMCWithMl(aod::HfRedCollisions const& collisions, + ReducedReso3PrV0MC const& candidates, + soa::Join const& charmBachs, + aod::HfRedVzeros const& v0Bachs, + aod::HfMcGenRedResos const& mcParticles) + { + processData(collisions, candidates, charmBachs, v0Bachs); + fillCandMcGen(mcParticles); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processDplusLambdaMCWithMl, "Process MC for DplusLambda analysis with Ml", false); + + void processD0LambdaMCWithMl(aod::HfRedCollisions const& collisions, + ReducedReso2PrV0MC const& candidates, + soa::Join const& charmBachs, + aod::HfRedVzeros const& v0Bachs, + aod::HfMcGenRedResos const& mcParticles) + { + processData(collisions, candidates, charmBachs, v0Bachs); + fillCandMcGen(mcParticles); + } + PROCESS_SWITCH(HfTaskCharmResoToDV0Reduced, processD0LambdaMCWithMl, "Process MC for D0Lambda analysis with Ml", false); + +}; // struct HfTaskCharmResoToDV0Reduced +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/Tasks/taskD0.cxx b/PWGHF/D2H/Tasks/taskD0.cxx index c4870213625..30bc3787e24 100644 --- a/PWGHF/D2H/Tasks/taskD0.cxx +++ b/PWGHF/D2H/Tasks/taskD0.cxx @@ -15,21 +15,44 @@ /// \author Gian Michele Innocenti , CERN /// \author Vít Kučera , CERN -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsEvSelHf.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include // std::min +#include +#include +#include using namespace o2; using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_centrality; +using namespace o2::hf_occupancy; /// D0 analysis task namespace @@ -53,25 +76,17 @@ struct HfTaskD0 { Configurable selectionCand{"selectionCand", 1, "Selection Flag for conj. topol. selected candidates"}; Configurable selectionPid{"selectionPid", 1, "Selection Flag for reco PID candidates"}; Configurable> binsPt{"binsPt", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"}; + Configurable centEstimator{"centEstimator", 0, "Centrality estimation (None: 0, FT0C: 2, FT0M: 3)"}; + Configurable occEstimator{"occEstimator", 0, "Occupancy estimation (None: 0, ITS: 1, FT0C: 2)"}; + Configurable storeCentrality{"storeCentrality", false, "Flag to store centrality information"}; + Configurable storeOccupancy{"storeOccupancy", false, "Flag to store occupancy information"}; + Configurable storeTrackQuality{"storeTrackQuality", false, "Flag to store track quality information"}; // ML inference Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; - // ThnSparse for ML outputScores and Vars - ConfigurableAxis thnConfigAxisBkgScore{"thnConfigAxisBkgScore", {50, 0, 1}, "Bkg score bins"}; - ConfigurableAxis thnConfigAxisNonPromptScore{"thnConfigAxisNonPromptScore", {50, 0, 1}, "Non-prompt score bins"}; - ConfigurableAxis thnConfigAxisPromptScore{"thnConfigAxisPromptScore", {50, 0, 1}, "Prompt score bins"}; - ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {120, 1.5848, 2.1848}, "Cand. inv-mass bins"}; - ConfigurableAxis thnConfigAxisPtB{"thnConfigAxisPtB", {1000, 0, 100}, "Cand. beauty mother pTB bins"}; - ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {500, 0, 50}, "Cand. pT bins"}; - ConfigurableAxis thnConfigAxisY{"thnConfigAxisY", {20, -1, 1}, "Cand. rapidity bins"}; - ConfigurableAxis thnConfigAxisOrigin{"thnConfigAxisOrigin", {3, -0.5, 2.5}, "Cand. origin type"}; - ConfigurableAxis thnConfigAxisCandType{"thnConfigAxisCandType", {6, -0.5, 5.5}, "D0 type"}; - ConfigurableAxis thnConfigAxisGenPtD{"thnConfigAxisGenPtD", {500, 0, 50}, "Gen Pt D"}; - ConfigurableAxis thnConfigAxisGenPtB{"thnConfigAxisGenPtB", {1000, 0, 100}, "Gen Pt B"}; - ConfigurableAxis thnConfigAxisNumPvContr{"thnConfigAxisNumPvContr", {200, -0.5, 199.5}, "Number of PV contributors"}; - HfHelper hfHelper; + SliceCache cache; using D0Candidates = soa::Join; using D0CandidatesMc = soa::Join; using D0CandidatesKF = soa::Join; @@ -82,9 +97,13 @@ struct HfTaskD0 { using D0CandidatesMlKF = soa::Join; using D0CandidatesMlMcKF = soa::Join; - using CollisionsWithMcLabels = soa::Join; + using Collisions = soa::Join; + using CollisionsCent = soa::Join; + using CollisionsWithMcLabels = soa::Join; + using CollisionsWithMcLabelsCent = soa::Join; + using TracksSelQuality = soa::Join; PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; - SliceCache cache; + PresliceUnsorted colPerMcCollisionCent = aod::mccollisionlabel::mcCollisionId; Partition selectedD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar; Partition selectedD0CandidatesKF = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar; @@ -96,6 +115,24 @@ struct HfTaskD0 { Partition selectedD0CandidatesMlMc = aod::hf_sel_candidate_d0::isRecoHfFlag >= selectionFlagHf; Partition selectedD0CandidatesMlMcKF = aod::hf_sel_candidate_d0::isRecoHfFlag >= selectionFlagHf; + // ThnSparse for ML outputScores and Vars + ConfigurableAxis thnConfigAxisBkgScore{"thnConfigAxisBkgScore", {50, 0, 1}, "Bkg score bins"}; + ConfigurableAxis thnConfigAxisNonPromptScore{"thnConfigAxisNonPromptScore", {50, 0, 1}, "Non-prompt score bins"}; + ConfigurableAxis thnConfigAxisPromptScore{"thnConfigAxisPromptScore", {50, 0, 1}, "Prompt score bins"}; + ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {120, 1.5848, 2.1848}, "Cand. inv-mass bins"}; + ConfigurableAxis thnConfigAxisPtB{"thnConfigAxisPtB", {1000, 0, 100}, "Cand. beauty mother pTB bins"}; + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {500, 0, 50}, "Cand. pT bins"}; + ConfigurableAxis thnConfigAxisY{"thnConfigAxisY", {20, -1, 1}, "Cand. rapidity bins"}; + ConfigurableAxis thnConfigAxisOrigin{"thnConfigAxisOrigin", {3, -0.5, 2.5}, "Cand. origin type"}; + ConfigurableAxis thnConfigAxisCandType{"thnConfigAxisCandType", {6, -0.5, 5.5}, "D0 type"}; + ConfigurableAxis thnConfigAxisGenPtD{"thnConfigAxisGenPtD", {500, 0, 50}, "Gen Pt D"}; + ConfigurableAxis thnConfigAxisGenPtB{"thnConfigAxisGenPtB", {1000, 0, 100}, "Gen Pt B"}; + ConfigurableAxis thnConfigAxisNumPvContr{"thnConfigAxisNumPvContr", {200, -0.5, 199.5}, "Number of PV contributors"}; + ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {110, 0., 110.}, ""}; + ConfigurableAxis thnConfigAxisOccupancy{"thnConfigAxisOccupancy", {14, 0, 14000}, "axis for centrality"}; + ConfigurableAxis thnConfigAxisMinItsNCls{"thnConfigAxisMinItsNCls", {5, 3, 8}, "axis for minimum ITS NCls of candidate prongs"}; + ConfigurableAxis thnConfigAxisMinTpcNCrossedRows{"thnConfigAxisMinTpcNCrossedRows", {10, 70, 180}, "axis for minimum TPC NCls crossed rows of candidate prongs"}; + HistogramRegistry registry{ "registry", {{"hPtCand", "2-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}}, @@ -174,14 +211,16 @@ struct HfTaskD0 { void init(InitContext&) { - std::array doprocess{doprocessDataWithDCAFitterN, doprocessDataWithKFParticle, doprocessMcWithDCAFitterN, doprocessMcWithKFParticle, doprocessDataWithDCAFitterNMl, doprocessDataWithKFParticleMl, doprocessMcWithDCAFitterNMl, doprocessMcWithKFParticleMl}; + std::array doprocess{doprocessDataWithDCAFitterN, doprocessDataWithDCAFitterNCent, doprocessDataWithKFParticle, doprocessMcWithDCAFitterN, doprocessMcWithDCAFitterNCent, doprocessMcWithKFParticle, doprocessDataWithDCAFitterNMl, doprocessDataWithDCAFitterNMlCent, doprocessDataWithKFParticleMl, doprocessMcWithDCAFitterNMl, doprocessMcWithDCAFitterNMlCent, doprocessMcWithKFParticleMl}; if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) == 0) { LOGP(fatal, "At least one process function should be enabled at a time."); } - if ((doprocessDataWithDCAFitterN || doprocessMcWithDCAFitterN || doprocessDataWithDCAFitterNMl || doprocessMcWithDCAFitterNMl) && (doprocessDataWithKFParticle || doprocessMcWithKFParticle || doprocessDataWithKFParticleMl || doprocessMcWithKFParticleMl)) { + if ((doprocessDataWithDCAFitterN || doprocessDataWithDCAFitterNCent || doprocessMcWithDCAFitterN || doprocessMcWithDCAFitterNCent || doprocessDataWithDCAFitterNMl || doprocessDataWithDCAFitterNMlCent || doprocessMcWithDCAFitterNMl || doprocessMcWithDCAFitterNMlCent) && (doprocessDataWithKFParticle || doprocessMcWithKFParticle || doprocessDataWithKFParticleMl || doprocessMcWithKFParticleMl)) { LOGP(fatal, "DCAFitterN and KFParticle can not be enabled at a time."); } - + if ((storeCentrality || storeOccupancy) && !(doprocessDataWithDCAFitterNCent || doprocessMcWithDCAFitterNCent || doprocessDataWithDCAFitterNMlCent || doprocessMcWithDCAFitterNMlCent)) { + LOGP(fatal, "Can't enable the storeCentrality and storeOccupancu without cent process"); + } auto vbins = (std::vector)binsPt; registry.add("hMass", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{500, 0., 5.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("hMassVsPhi", "2-prong candidates vs phi;inv. mass (#pi K) (GeV/#it{c}^{2});phi (rad);entries", {HistType::kTH3F, {{120, 1.5848, 2.1848}, {vbins, "#it{p}_{T} (GeV/#it{c})"}, {32, 0, o2::constants::math::TwoPI}}}); @@ -230,35 +269,62 @@ struct HfTaskD0 { const AxisSpec thnAxisGenPtD{thnConfigAxisGenPtD, "#it{p}_{T} (GeV/#it{c})"}; const AxisSpec thnAxisGenPtB{thnConfigAxisGenPtB, "#it{p}_{T}^{B} (GeV/#it{c})"}; const AxisSpec thnAxisNumPvContr{thnConfigAxisNumPvContr, "Number of PV contributors"}; + const AxisSpec thnAxisCent{thnConfigAxisCent, "Centrality"}; + const AxisSpec thnAxisOccupancy{thnConfigAxisOccupancy, "Occupancy"}; + const AxisSpec thnAxisMinItsNCls{thnConfigAxisMinItsNCls, "Minimum ITS cluster found"}; + const AxisSpec thnAxisMinTpcNCrossedRows{thnConfigAxisMinTpcNCrossedRows, "Minimum TPC crossed rows"}; + + if (doprocessMcWithDCAFitterN || doprocessMcWithDCAFitterNCent || doprocessMcWithKFParticle || doprocessMcWithDCAFitterNMl || doprocessMcWithDCAFitterNMlCent || doprocessMcWithKFParticleMl) { + std::vector axesAcc = {thnAxisGenPtD, thnAxisGenPtB, thnAxisY, thnAxisOrigin, thnAxisNumPvContr}; + + if (storeCentrality) { + axesAcc.push_back(thnAxisCent); + } + if (storeOccupancy) { + axesAcc.push_back(thnAxisOccupancy); + } - if (doprocessMcWithDCAFitterN || doprocessMcWithKFParticle || doprocessMcWithDCAFitterNMl || doprocessMcWithKFParticleMl) { - registry.add("hSparseAcc", "Thn for generated D0 from charm and beauty", HistType::kTHnSparseD, {thnAxisGenPtD, thnAxisGenPtB, thnAxisY, thnAxisOrigin, thnAxisNumPvContr}); + registry.add("hSparseAcc", "Thn for generated D0 from charm and beauty", HistType::kTHnSparseD, axesAcc); registry.get(HIST("hSparseAcc"))->Sumw2(); } + std::vector axes = {thnAxisMass, thnAxisPt, thnAxisY, thnAxisCandType}; + if (doprocessMcWithDCAFitterN || doprocessMcWithDCAFitterNCent || doprocessMcWithKFParticle || doprocessMcWithDCAFitterNMl || doprocessMcWithDCAFitterNMlCent || doprocessMcWithKFParticleMl) { + axes.push_back(thnAxisPtB); + axes.push_back(thnAxisOrigin); + axes.push_back(thnAxisNumPvContr); + } + if (storeCentrality) { + axes.push_back(thnAxisCent); + } + if (storeOccupancy) { + axes.push_back(thnAxisOccupancy); + } + if (storeTrackQuality) { + axes.push_back(thnAxisMinItsNCls); + axes.push_back(thnAxisMinTpcNCrossedRows); + } if (applyMl) { const AxisSpec thnAxisBkgScore{thnConfigAxisBkgScore, "BDT score bkg."}; const AxisSpec thnAxisNonPromptScore{thnConfigAxisNonPromptScore, "BDT score non-prompt."}; const AxisSpec thnAxisPromptScore{thnConfigAxisPromptScore, "BDT score prompt."}; - if (doprocessMcWithDCAFitterN || doprocessMcWithKFParticle || doprocessMcWithDCAFitterNMl || doprocessMcWithKFParticleMl) { - registry.add("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type", "Thn for D0 candidates with BDT scores", HistType::kTHnSparseD, {thnAxisBkgScore, thnAxisNonPromptScore, thnAxisPromptScore, thnAxisMass, thnAxisPt, thnAxisY, thnAxisCandType, thnAxisPtB, thnAxisOrigin, thnAxisNumPvContr}); - } else { - registry.add("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type", "Thn for D0 candidates with BDT scores", HistType::kTHnSparseD, {thnAxisBkgScore, thnAxisNonPromptScore, thnAxisPromptScore, thnAxisMass, thnAxisPt, thnAxisY, thnAxisCandType}); - } + axes.insert(axes.begin(), thnAxisPromptScore); + axes.insert(axes.begin(), thnAxisNonPromptScore); + axes.insert(axes.begin(), thnAxisBkgScore); + + registry.add("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type", "Thn for D0 candidates", HistType::kTHnSparseD, axes); registry.get(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"))->Sumw2(); } else { - if (doprocessMcWithDCAFitterN || doprocessMcWithKFParticle || doprocessMcWithDCAFitterNMl || doprocessMcWithKFParticleMl) { - registry.add("hMassVsPtVsPtBVsYVsOriginVsD0Type", "Thn for D0 candidates without BDT scores", HistType::kTHnSparseD, {thnAxisMass, thnAxisPt, thnAxisY, thnAxisCandType, thnAxisPtB, thnAxisOrigin}); - } else { - registry.add("hMassVsPtVsPtBVsYVsOriginVsD0Type", "Thn for D0 candidates without BDT scores", HistType::kTHnSparseD, {thnAxisMass, thnAxisPt, thnAxisY, thnAxisCandType}); - } + registry.add("hMassVsPtVsPtBVsYVsOriginVsD0Type", "Thn for D0 candidates", HistType::kTHnSparseD, axes); registry.get(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"))->Sumw2(); } } - template - void processData(CandType const& candidates) + template + void processData(CandType const& candidates, + CollType const&, + aod::TracksWExtra const&) { for (const auto& candidate : candidates) { if (!(candidate.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { @@ -317,72 +383,162 @@ struct HfTaskD0 { registry.fill(HIST("hCPAFinerBinning"), candidate.cpa(), ptCandidate); registry.fill(HIST("hCPAXYFinerBinning"), candidate.cpaXY(), ptCandidate); + float cent{-1.f}; + float occ{-1.f}; + if (storeCentrality || storeOccupancy) { + auto collision = candidate.template collision_as(); + if (storeCentrality && centEstimator != CentralityEstimator::None) { + cent = getCentralityColl(collision, centEstimator); + } + if (storeOccupancy && occEstimator != OccupancyEstimator::None) { + occ = getOccupancyColl(collision, occEstimator); + } + } + + auto trackPos = candidate.template prong0_as(); // positive daughter + auto trackNeg = candidate.template prong1_as(); // negative daughter + int minItsClustersOfProngs = std::min(trackPos.itsNCls(), trackNeg.itsNCls()); + int minTpcCrossedRowsOfProngs = std::min(trackPos.tpcNClsCrossedRows(), trackNeg.tpcNClsCrossedRows()); if constexpr (applyMl) { - if (candidate.isSelD0() >= selectionFlagD0) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), SigD0); - if (candidate.isSelD0bar()) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), ReflectedD0); - } else if (!candidate.isSelD0bar()) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), PureSigD0); + if (storeCentrality && storeOccupancy) { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), SigD0, cent, occ); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0, cent, occ); } - } - if (candidate.isSelD0bar() >= selectionFlagD0bar) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar); - if (candidate.isSelD0()) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), ReflectedD0bar); - } else if (!candidate.isSelD0()) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), PureSigD0bar); + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar, cent, occ); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar, cent, occ); + } + } else if (storeCentrality && !storeOccupancy) { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), SigD0, cent); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0, cent); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar, cent); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar, cent); + } + } else if (!storeCentrality && storeOccupancy) { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), SigD0, occ); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0, occ); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar, occ); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar, occ); + } + } else if (storeTrackQuality) { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), SigD0, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } + } else { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), SigD0); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar); } } } else { - if (candidate.isSelD0() >= selectionFlagD0) { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), SigD0); - if (candidate.isSelD0bar()) { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), ReflectedD0); - } else if (!candidate.isSelD0bar()) { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), PureSigD0); + if (storeCentrality && storeOccupancy) { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), SigD0, cent, occ); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0, cent, occ); } - } - if (candidate.isSelD0bar() >= selectionFlagD0bar) { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar); - if (candidate.isSelD0()) { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), ReflectedD0bar); - } else if (!candidate.isSelD0()) { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), PureSigD0bar); + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar, cent, occ); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar, cent, occ); + } + } else if (storeCentrality && !storeOccupancy) { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), SigD0, cent); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0, cent); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar, cent); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar, cent); + } + } else if (!storeCentrality && storeOccupancy) { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), SigD0, occ); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0, occ); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar, occ); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar, occ); + } + } else if (storeTrackQuality) { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), SigD0, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar); + } + } else { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), SigD0); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0bar() ? ReflectedD0 : PureSigD0); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), SigD0bar); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, hfHelper.yD0(candidate), candidate.isSelD0() ? ReflectedD0bar : PureSigD0bar); } } } } } - void processDataWithDCAFitterN(D0Candidates const&) + void processDataWithDCAFitterN(D0Candidates const&, Collisions const& collisions, aod::TracksWExtra const& tracks) { - processData(selectedD0Candidates); + processData(selectedD0Candidates, collisions, tracks); } PROCESS_SWITCH(HfTaskD0, processDataWithDCAFitterN, "process taskD0 with DCAFitterN", true); - void processDataWithKFParticle(D0CandidatesKF const&) + void processDataWithDCAFitterNCent(D0Candidates const&, CollisionsCent const& collisions, aod::TracksWExtra const& tracks) { - processData(selectedD0CandidatesKF); + processData(selectedD0Candidates, collisions, tracks); + } + PROCESS_SWITCH(HfTaskD0, processDataWithDCAFitterNCent, "process taskD0 with DCAFitterN and centrality", false); + + void processDataWithKFParticle(D0CandidatesKF const&, Collisions const& collisions, aod::TracksWExtra const& tracks) + { + processData(selectedD0CandidatesKF, collisions, tracks); } PROCESS_SWITCH(HfTaskD0, processDataWithKFParticle, "process taskD0 with KFParticle", false); + // TODO: add processKFParticleCent - void processDataWithDCAFitterNMl(D0CandidatesMl const&) + void processDataWithDCAFitterNMl(D0CandidatesMl const&, Collisions const& collisions, aod::TracksWExtra const& tracks) { - processData(selectedD0CandidatesMl); + processData(selectedD0CandidatesMl, collisions, tracks); } PROCESS_SWITCH(HfTaskD0, processDataWithDCAFitterNMl, "process taskD0 with DCAFitterN and ML selections", false); - void processDataWithKFParticleMl(D0CandidatesMlKF const&) + void processDataWithDCAFitterNMlCent(D0CandidatesMl const&, CollisionsCent const& collisions, aod::TracksWExtra const& tracks) + { + processData(selectedD0CandidatesMl, collisions, tracks); + } + PROCESS_SWITCH(HfTaskD0, processDataWithDCAFitterNMlCent, "process taskD0 with DCAFitterN and ML selections and centrality", false); + + void processDataWithKFParticleMl(D0CandidatesMlKF const&, Collisions const& collisions, aod::TracksWExtra const& tracks) { - processData(selectedD0CandidatesMlKF); + processData(selectedD0CandidatesMlKF, collisions, tracks); } PROCESS_SWITCH(HfTaskD0, processDataWithKFParticleMl, "process taskD0 with KFParticle and ML selections", false); + // TODO: add processKFParticleMlCent - template + template void processMc(CandType const& candidates, soa::Join const& mcParticles, - aod::TracksWMc const&, - CollisionsWithMcLabels const& collisions, + TracksSelQuality const&, + CollType const& collisions, aod::McCollisions const&) { // MC rec. @@ -394,8 +550,16 @@ struct HfTaskD0 { continue; } - auto collision = candidate.template collision_as(); + float cent{-1.f}; + float occ{-1.f}; + auto collision = candidate.template collision_as(); auto numPvContributors = collision.numContrib(); + if (storeCentrality && centEstimator != CentralityEstimator::None) { + cent = getCentralityColl(collision, centEstimator); + } + if (storeOccupancy && occEstimator != OccupancyEstimator::None) { + occ = getOccupancyColl(collision, occEstimator); + } float massD0, massD0bar; if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { massD0 = candidate.kfGeoMassD0(); @@ -404,9 +568,11 @@ struct HfTaskD0 { massD0 = hfHelper.invMassD0ToPiK(candidate); massD0bar = hfHelper.invMassD0barToKPi(candidate); } - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { + auto trackPos = candidate.template prong0_as(); // positive daughter + auto trackNeg = candidate.template prong1_as(); // negative daughter + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // Get the corresponding MC particle. - auto indexMother = RecoDecay::getMother(mcParticles, candidate.template prong0_as().template mcParticle_as>(), o2::constants::physics::Pdg::kD0, true); + auto indexMother = RecoDecay::getMother(mcParticles, trackPos.template mcParticle_as>(), o2::constants::physics::Pdg::kD0, true); auto particleMother = mcParticles.rawIteratorAt(indexMother); auto ptGen = particleMother.pt(); // gen. level pT auto yGen = RecoDecay::y(particleMother.pVector(), o2::constants::physics::MassD0); // gen. level y @@ -494,9 +660,11 @@ struct HfTaskD0 { auto ctCandidate = hfHelper.ctD0(candidate); auto cpaCandidate = candidate.cpa(); auto cpaxyCandidate = candidate.cpaXY(); + int minItsClustersOfProngs = std::min(trackPos.itsNCls(), trackNeg.itsNCls()); + int minTpcCrossedRowsOfProngs = std::min(trackPos.tpcNClsCrossedRows(), trackNeg.tpcNClsCrossedRows()); if (candidate.isSelD0() >= selectionFlagD0) { registry.fill(HIST("hMassSigBkgD0"), massD0, ptCandidate, rapidityCandidate); - if (candidate.flagMcMatchRec() == (1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if (candidate.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hPtProng0Sig"), ptProng0, rapidityCandidate); registry.fill(HIST("hPtProng1Sig"), ptProng1, rapidityCandidate); registry.fill(HIST("hDecLengthSig"), declengthCandidate, rapidityCandidate); @@ -521,9 +689,29 @@ struct HfTaskD0 { registry.fill(HIST("hDecLengthxyVsPtSig"), declengthxyCandidate, ptCandidate); registry.fill(HIST("hMassSigD0"), massD0, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, occ); + } else if (storeTrackQuality) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } else { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + } } else { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, occ); + } else if (storeTrackQuality) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, SigD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + } } } else { registry.fill(HIST("hPtProng0Bkg"), ptProng0, rapidityCandidate); @@ -540,33 +728,93 @@ struct HfTaskD0 { registry.fill(HIST("hCPABkg"), cpaCandidate, rapidityCandidate); registry.fill(HIST("hCPAxyBkg"), cpaxyCandidate, rapidityCandidate); registry.fill(HIST("hMassBkgD0"), massD0, ptCandidate, rapidityCandidate); - if (candidate.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if (candidate.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMassReflBkgD0"), massD0, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, occ); + } else if (storeTrackQuality) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } else { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + } } else { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, occ); + } else if (storeTrackQuality) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, rapidityCandidate, ReflectedD0, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + } } } } } if (candidate.isSelD0bar() >= selectionFlagD0bar) { registry.fill(HIST("hMassSigBkgD0bar"), massD0bar, ptCandidate, rapidityCandidate); - if (candidate.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if (candidate.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMassSigD0bar"), massD0bar, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, occ); + } else if (storeTrackQuality) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } else { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + } } else { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, occ); + } else if (storeTrackQuality) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, SigD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + } } } else { registry.fill(HIST("hMassBkgD0bar"), massD0bar, ptCandidate, rapidityCandidate); - if (candidate.flagMcMatchRec() == (1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if (candidate.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMassReflBkgD0bar"), massD0bar, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, occ); + } else if (storeTrackQuality) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } else { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + } } else { - registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, occ); + } else if (storeTrackQuality) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors, minItsClustersOfProngs, minTpcCrossedRowsOfProngs); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, rapidityCandidate, ReflectedD0bar, candidate.ptBhadMotherPart(), candidate.originMcRec(), numPvContributors); + } } } } @@ -574,7 +822,7 @@ struct HfTaskD0 { } // MC gen. for (const auto& particle : mcParticles) { - if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { + if (std::abs(particle.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { if (yCandGenMax >= 0. && std::abs(RecoDecay::y(particle.pVector(), o2::constants::physics::MassD0)) > yCandGenMax) { continue; } @@ -585,22 +833,53 @@ struct HfTaskD0 { registry.fill(HIST("hPtVsYGen"), ptGen, yGen); unsigned maxNumContrib = 0; - const auto& recoCollsPerMcColl = collisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex()); - for (const auto& recCol : recoCollsPerMcColl) { - maxNumContrib = recCol.numContrib() > maxNumContrib ? recCol.numContrib() : maxNumContrib; + float cent{-1.f}; + float occ{-1.f}; + if constexpr (std::is_same_v) { + const auto& recoCollsPerMcCollCent = collisions.sliceBy(colPerMcCollisionCent, particle.mcCollision().globalIndex()); + for (const auto& recCol : recoCollsPerMcCollCent) { + maxNumContrib = recCol.numContrib() > maxNumContrib ? recCol.numContrib() : maxNumContrib; + } + if (storeCentrality && centEstimator != CentralityEstimator::None) { + cent = getCentralityGenColl(recoCollsPerMcCollCent, centEstimator); + } + if (storeOccupancy && occEstimator != OccupancyEstimator::None) { + occ = getOccupancyGenColl(recoCollsPerMcCollCent, occEstimator); + } + } else { + const auto& recoCollsPerMcColl = collisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex()); + for (const auto& recCol : recoCollsPerMcColl) { + maxNumContrib = recCol.numContrib() > maxNumContrib ? recCol.numContrib() : maxNumContrib; + } } if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { registry.fill(HIST("hPtGenPrompt"), ptGen); registry.fill(HIST("hYGenPrompt"), yGen); registry.fill(HIST("hPtVsYGenPrompt"), ptGen, yGen); - registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 1, maxNumContrib); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 1, maxNumContrib, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 1, maxNumContrib, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 1, maxNumContrib, occ); + } else { + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 1, maxNumContrib); + } } else { ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt(); registry.fill(HIST("hPtGenNonPrompt"), ptGen); registry.fill(HIST("hYGenNonPrompt"), yGen); registry.fill(HIST("hPtVsYGenNonPrompt"), ptGen, yGen); - registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 2, maxNumContrib); + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 2, maxNumContrib, cent, occ); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 2, maxNumContrib, cent); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 2, maxNumContrib, occ); + } else { + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 2, maxNumContrib); + } } registry.fill(HIST("hEtaGen"), particle.eta()); } @@ -609,7 +888,7 @@ struct HfTaskD0 { void processMcWithDCAFitterN(D0CandidatesMc const&, soa::Join const& mcParticles, - aod::TracksWMc const& tracks, + TracksSelQuality const& tracks, CollisionsWithMcLabels const& collisions, aod::McCollisions const& mcCollisions) { @@ -617,19 +896,30 @@ struct HfTaskD0 { } PROCESS_SWITCH(HfTaskD0, processMcWithDCAFitterN, "Process MC with DCAFitterN", false); + void processMcWithDCAFitterNCent(D0CandidatesMc const&, + soa::Join const& mcParticles, + TracksSelQuality const& tracks, + CollisionsWithMcLabelsCent const& collisions, + aod::McCollisions const& mcCollisions) + { + processMc(selectedD0CandidatesMc, mcParticles, tracks, collisions, mcCollisions); + } + PROCESS_SWITCH(HfTaskD0, processMcWithDCAFitterNCent, "Process MC with DCAFitterN and centrality", false); + void processMcWithKFParticle(D0CandidatesMcKF const&, soa::Join const& mcParticles, - aod::TracksWMc const& tracks, + TracksSelQuality const& tracks, CollisionsWithMcLabels const& collisions, aod::McCollisions const& mcCollisions) { processMc(selectedD0CandidatesMcKF, mcParticles, tracks, collisions, mcCollisions); } PROCESS_SWITCH(HfTaskD0, processMcWithKFParticle, "Process MC with KFParticle", false); + // TODO: add the processMcWithKFParticleCent void processMcWithDCAFitterNMl(D0CandidatesMlMc const&, soa::Join const& mcParticles, - aod::TracksWMc const& tracks, + TracksSelQuality const& tracks, CollisionsWithMcLabels const& collisions, aod::McCollisions const& mcCollisions) { @@ -637,15 +927,26 @@ struct HfTaskD0 { } PROCESS_SWITCH(HfTaskD0, processMcWithDCAFitterNMl, "Process MC with DCAFitterN and ML selection", false); + void processMcWithDCAFitterNMlCent(D0CandidatesMlMc const&, + soa::Join const& mcParticles, + TracksSelQuality const& tracks, + CollisionsWithMcLabelsCent const& collisions, + aod::McCollisions const& mcCollisions) + { + processMc(selectedD0CandidatesMlMc, mcParticles, tracks, collisions, mcCollisions); + } + PROCESS_SWITCH(HfTaskD0, processMcWithDCAFitterNMlCent, "Process MC with DCAFitterN and ML selection and centrality", false); + void processMcWithKFParticleMl(D0CandidatesMlMcKF const&, soa::Join const& mcParticles, - aod::TracksWMc const& tracks, + TracksSelQuality const& tracks, CollisionsWithMcLabels const& collisions, aod::McCollisions const& mcCollisions) { processMc(selectedD0CandidatesMlMcKF, mcParticles, tracks, collisions, mcCollisions); } PROCESS_SWITCH(HfTaskD0, processMcWithKFParticleMl, "Process MC with KFParticle and ML selections", false); + // TODO: add the processMcWithKFParticleMlCent }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/D2H/Tasks/taskDirectedFlowCharmHadrons.cxx b/PWGHF/D2H/Tasks/taskDirectedFlowCharmHadrons.cxx index 0ac694501d1..bc4d3308c18 100644 --- a/PWGHF/D2H/Tasks/taskDirectedFlowCharmHadrons.cxx +++ b/PWGHF/D2H/Tasks/taskDirectedFlowCharmHadrons.cxx @@ -15,24 +15,36 @@ /// \author Prottay Das, prottay.das@cern.ch /// \author Biao Zhang, biao.zhanng@cern.ch -#include -#include -#include -#include - -#include "CCDB/BasicCCDBManager.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/EventPlaneHelper.h" -#include "PWGLF/DataModel/SPCalibrationTables.h" - -#include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/CentralityEstimation.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGLF/DataModel/SPCalibrationTables.h" + +#include "Common/Core/EventPlaneHelper.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -54,18 +66,16 @@ struct HfTaskDirectedFlowCharmHadrons { Configurable centralityMax{"centralityMax", 100., "Maximum centrality accepted in SP computation"}; Configurable storeMl{"storeMl", false, "Flag to store ML scores"}; Configurable direct{"direct", false, "Flag to calculate direct v1 odd and even"}; + Configurable correction{"correction", false, "Flag for correction"}; Configurable userap{"userap", false, "Flag to fill rapidity vs eta "}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable> classMl{"classMl", {0, 2}, "Indices of BDT scores to be stored. Two indexes max."}; - ConfigurableAxis thnConfigAxisInvMass{"thnConfigAxisInvMass", {100, 1.78, 2.05}, ""}; - ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0}, ""}; - ConfigurableAxis thnConfigAxisEta{"thnConfigAxisEta", {VARIABLE_WIDTH, -0.8, -0.4, 0, 0.4, 0.8}, ""}; - ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {VARIABLE_WIDTH, 0.0, 10.0, 40.0, 80.0}, ""}; - ConfigurableAxis thnConfigAxisScalarProd{"thnConfigAxisScalarProd", {8000, -2.0, 2.0}, ""}; - ConfigurableAxis thnConfigAxisSign{"thnConfigAxisSign", {2, -2.0, 2.0}, ""}; - ConfigurableAxis thnConfigAxisMlOne{"thnConfigAxisMlOne", {1000, 0., 1.}, ""}; - ConfigurableAxis thnConfigAxisMlTwo{"thnConfigAxisMlTwo", {1000, 0., 1.}, ""}; + HfHelper hfHelper; + EventPlaneHelper epHelper; + SliceCache cache; + HfEventSelection hfEvSel; // event selection and monitoring + o2::framework::Service ccdb; using CandDplusDataWMl = soa::Filtered>; using CandDplusData = soa::Filtered>; @@ -85,11 +95,14 @@ struct HfTaskDirectedFlowCharmHadrons { Partition selectedD0ToPiKWMl = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlag; Partition selectedD0ToKPiWMl = aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlag; - SliceCache cache; - HfHelper hfHelper; - EventPlaneHelper epHelper; - HfEventSelection hfEvSel; // event selection and monitoring - o2::framework::Service ccdb; + ConfigurableAxis thnConfigAxisInvMass{"thnConfigAxisInvMass", {100, 1.78, 2.05}, ""}; + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0}, ""}; + ConfigurableAxis thnConfigAxisEta{"thnConfigAxisEta", {VARIABLE_WIDTH, -0.8, -0.4, 0, 0.4, 0.8}, ""}; + ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {VARIABLE_WIDTH, 0.0, 10.0, 40.0, 80.0}, ""}; + ConfigurableAxis thnConfigAxisScalarProd{"thnConfigAxisScalarProd", {8000, -2.0, 2.0}, ""}; + ConfigurableAxis thnConfigAxisSign{"thnConfigAxisSign", {2, -2.0, 2.0}, ""}; + ConfigurableAxis thnConfigAxisMlOne{"thnConfigAxisMlOne", {1000, 0., 1.}, ""}; + ConfigurableAxis thnConfigAxisMlTwo{"thnConfigAxisMlTwo", {1000, 0., 1.}, ""}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -121,17 +134,19 @@ struct HfTaskDirectedFlowCharmHadrons { if (direct) { registry.add("hpQxytpvscent", "hpQxytpvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); - registry.add("hpuxyQxypvscentpteta", "hpuxyQxypvscentpteta", HistType::kTHnSparseF, axes, true); - registry.add("hpuxyQxytvscentpteta", "hpuxyQxytvscentpteta", HistType::kTHnSparseF, axes, true); registry.add("hpoddvscentpteta", "hpoddvscentpteta", HistType::kTHnSparseF, axes, true); registry.add("hpevenvscentpteta", "hpevenvscentpteta", HistType::kTHnSparseF, axes, true); - - registry.add("hpQxpvscent", "hpQxpvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); - registry.add("hpQypvscent", "hpQypvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); - registry.add("hpQxtvscent", "hpQxtvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); - registry.add("hpQytvscent", "hpQytvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); - registry.add("hpuxvscentpteta", "hpuxvscentpteta", HistType::kTHnSparseF, axes, true); - registry.add("hpuyvscentpteta", "hpuyvscentpteta", HistType::kTHnSparseF, axes, true); + if (correction) { + registry.add("hpuxyQxypvscentpteta", "hpuxyQxypvscentpteta", HistType::kTHnSparseF, axes, true); + registry.add("hpuxyQxytvscentpteta", "hpuxyQxytvscentpteta", HistType::kTHnSparseF, axes, true); + + registry.add("hpQxpvscent", "hpQxpvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); + registry.add("hpQypvscent", "hpQypvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); + registry.add("hpQxtvscent", "hpQxtvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); + registry.add("hpQytvscent", "hpQytvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); + registry.add("hpuxvscentpteta", "hpuxvscentpteta", HistType::kTHnSparseF, axes, true); + registry.add("hpuyvscentpteta", "hpuyvscentpteta", HistType::kTHnSparseF, axes, true); + } } else { registry.add("hpQxtQxpvscent", "hpQxtQxpvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); registry.add("hpQytQypvscent", "hpQytQypvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); @@ -203,24 +218,26 @@ struct HfTaskDirectedFlowCharmHadrons { auto qxZDCC = collision.qxZDCC(); // extracting q vectors of ZDC auto qyZDCC = collision.qyZDCC(); - auto QxtQxp = qxZDCC * qxZDCA; - auto QytQyp = qyZDCC * qyZDCA; - auto Qxytp = QxtQxp + QytQyp; - auto QxpQyt = qxZDCA * qyZDCC; - auto QxtQyp = qxZDCC * qyZDCA; + auto qxtQxp = qxZDCC * qxZDCA; + auto qytQyp = qyZDCC * qyZDCA; + auto qxytp = qxtQxp + qytQyp; + auto qxpQyt = qxZDCA * qyZDCC; + auto qxtQyp = qxZDCC * qyZDCA; // correlations in the denominators for SP calculation if (direct) { - registry.fill(HIST("hpQxytpvscent"), cent, Qxytp); - registry.fill(HIST("hpQxpvscent"), cent, qxZDCA); - registry.fill(HIST("hpQxtvscent"), cent, qxZDCC); - registry.fill(HIST("hpQypvscent"), cent, qyZDCA); - registry.fill(HIST("hpQytvscent"), cent, qyZDCC); + registry.fill(HIST("hpQxytpvscent"), cent, qxytp); + if (correction) { + registry.fill(HIST("hpQxpvscent"), cent, qxZDCA); + registry.fill(HIST("hpQxtvscent"), cent, qxZDCC); + registry.fill(HIST("hpQypvscent"), cent, qyZDCA); + registry.fill(HIST("hpQytvscent"), cent, qyZDCC); + } } else { - registry.fill(HIST("hpQxtQxpvscent"), cent, QxtQxp); - registry.fill(HIST("hpQytQypvscent"), cent, QytQyp); - registry.fill(HIST("hpQxpQytvscent"), cent, QxpQyt); - registry.fill(HIST("hpQxtQypvscent"), cent, QxtQyp); + registry.fill(HIST("hpQxtQxpvscent"), cent, qxtQxp); + registry.fill(HIST("hpQytQypvscent"), cent, qytQyp); + registry.fill(HIST("hpQxpQytvscent"), cent, qxpQyt); + registry.fill(HIST("hpQxtQypvscent"), cent, qxtQyp); registry.fill(HIST("hpQxpvscent"), cent, qxZDCA); registry.fill(HIST("hpQxtvscent"), cent, qxZDCC); registry.fill(HIST("hpQypvscent"), cent, qyZDCA); @@ -305,14 +322,15 @@ struct HfTaskDirectedFlowCharmHadrons { if (storeMl) { if (direct) { - registry.fill(HIST("hpuxyQxypvscentpteta"), massCand, cent, ptCand, etaCand, uxyQxyp, sign, outputMl[0], outputMl[1]); - registry.fill(HIST("hpuxyQxytvscentpteta"), massCand, cent, ptCand, etaCand, uxyQxyt, sign, outputMl[0], outputMl[1]); registry.fill(HIST("hpoddvscentpteta"), massCand, cent, ptCand, etaCand, oddv1, sign, outputMl[0], outputMl[1]); registry.fill(HIST("hpevenvscentpteta"), massCand, cent, ptCand, etaCand, evenv1, sign, outputMl[0], outputMl[1]); + if (correction) { + registry.fill(HIST("hpuxyQxypvscentpteta"), massCand, cent, ptCand, etaCand, uxyQxyp, sign, outputMl[0], outputMl[1]); + registry.fill(HIST("hpuxyQxytvscentpteta"), massCand, cent, ptCand, etaCand, uxyQxyt, sign, outputMl[0], outputMl[1]); - registry.fill(HIST("hpuxvscentpteta"), massCand, cent, ptCand, etaCand, ux, sign, outputMl[0], outputMl[1]); - registry.fill(HIST("hpuyvscentpteta"), massCand, cent, ptCand, etaCand, uy, sign, outputMl[0], outputMl[1]); - + registry.fill(HIST("hpuxvscentpteta"), massCand, cent, ptCand, etaCand, ux, sign, outputMl[0], outputMl[1]); + registry.fill(HIST("hpuyvscentpteta"), massCand, cent, ptCand, etaCand, uy, sign, outputMl[0], outputMl[1]); + } } else { registry.fill(HIST("hpuxQxpvscentpteta"), massCand, cent, ptCand, etaCand, uxQxp, sign, outputMl[0], outputMl[1]); registry.fill(HIST("hpuyQypvscentpteta"), massCand, cent, ptCand, etaCand, uyQyp, sign, outputMl[0], outputMl[1]); @@ -324,13 +342,16 @@ struct HfTaskDirectedFlowCharmHadrons { } } else { if (direct) { - registry.fill(HIST("hpuxyQxypvscentpteta"), massCand, cent, ptCand, etaCand, uxyQxyp, sign); - registry.fill(HIST("hpuxyQxytvscentpteta"), massCand, cent, ptCand, etaCand, uxyQxyt, sign); registry.fill(HIST("hpoddvscentpteta"), massCand, cent, ptCand, etaCand, oddv1, sign); registry.fill(HIST("hpevenvscentpteta"), massCand, cent, ptCand, etaCand, evenv1, sign); - registry.fill(HIST("hpuxvscentpteta"), massCand, cent, ptCand, etaCand, ux, sign); - registry.fill(HIST("hpuyvscentpteta"), massCand, cent, ptCand, etaCand, uy, sign); + if (correction) { + registry.fill(HIST("hpuxyQxypvscentpteta"), massCand, cent, ptCand, etaCand, uxyQxyp, sign); + registry.fill(HIST("hpuxyQxytvscentpteta"), massCand, cent, ptCand, etaCand, uxyQxyt, sign); + + registry.fill(HIST("hpuxvscentpteta"), massCand, cent, ptCand, etaCand, ux, sign); + registry.fill(HIST("hpuyvscentpteta"), massCand, cent, ptCand, etaCand, uy, sign); + } } else { registry.fill(HIST("hpuxQxpvscentpteta"), massCand, cent, ptCand, etaCand, uxQxp, sign); registry.fill(HIST("hpuyQypvscentpteta"), massCand, cent, ptCand, etaCand, uyQyp, sign); diff --git a/PWGHF/D2H/Tasks/taskDplus.cxx b/PWGHF/D2H/Tasks/taskDplus.cxx index 9026e4c97d6..921d39364e6 100644 --- a/PWGHF/D2H/Tasks/taskDplus.cxx +++ b/PWGHF/D2H/Tasks/taskDplus.cxx @@ -17,19 +17,39 @@ /// \author Vít Kučera , CERN /// \author Luca Aglietta , University and INFN Torino -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - #include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsEvSelHf.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "PWGHF/Utils/utilsEvSelHf.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -50,6 +70,8 @@ struct HfTaskDplus { Configurable> classMl{"classMl", {0, 1, 2}, "Indexes of ML scores to be stored. Three indexes max."}; Configurable storeCentrality{"storeCentrality", false, "Flag to store centrality information"}; Configurable storeOccupancy{"storeOccupancy", false, "Flag to store occupancy information"}; + Configurable storePvContributors{"storePvContributors", false, "Flag to store number of PV contributors information"}; + Configurable fillMcBkgHistos{"fillMcBkgHistos", false, "Flag to fill and store histograms for MC background"}; HfHelper hfHelper; @@ -72,16 +94,17 @@ struct HfTaskDplus { Partition selectedDPlusCandidatesWithMl = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; // Matched MC - Partition recoDPlusCandidates = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; - Partition recoDPlusCandidatesWithMl = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; + Partition recoDPlusCandidates = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; + Partition recoDPlusCandidatesWithMl = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; // MC Bkg - Partition recoBkgCandidates = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; - Partition recoBkgCandidatesWithMl = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; + Partition recoBkgCandidates = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; + Partition recoBkgCandidatesWithMl = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; ConfigurableAxis thnConfigAxisY{"thnConfigAxisY", {40, -1, 1}, "Cand. rapidity bins"}; - ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {110, 0., 110.}, ""}; - ConfigurableAxis thnConfigAxisOccupancy{"thnConfigAxisOccupancy", {14, 0, 14000}, "axis for centrality"}; + ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {110, 0., 110.}, "axis for centrality"}; + ConfigurableAxis thnConfigAxisOccupancy{"thnConfigAxisOccupancy", {14, 0, 14000}, "axis for occupancy"}; + ConfigurableAxis thnConfigAxisPvContributors{"thnConfigAxisPvContributors", {100, 0., 100.}, "axis for PV contributors"}; ConfigurableAxis thnConfigAxisPtBHad{"thnConfigAxisPtBHad", {25, 0., 50}, "axis for pt of B hadron decayed into D candidate"}; ConfigurableAxis thnConfigAxisFlagBHad{"thnConfigAxisFlagBHad", {5, 0., 5}, "axis for PDG of B hadron"}; ConfigurableAxis thnConfigAxisMlScore0{"thnConfigAxisMlScore0", {100, 0., 1.}, "axis for ML output score 0"}; @@ -117,6 +140,7 @@ struct HfTaskDplus { AxisSpec thnAxisFlagBHad{thnConfigAxisFlagBHad, "B Hadron flag"}; AxisSpec thnAxisCent{thnConfigAxisCent, "Centrality"}; AxisSpec thnAxisOccupancy{thnConfigAxisOccupancy, "Occupancy"}; + AxisSpec thnAxisPvContributors{thnConfigAxisPvContributors, "PV contributors"}; registry.add("hMass", "3-prong candidates;inv. mass (#pi K #pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{350, 1.7, 2.05}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("hEta", "3-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); @@ -160,13 +184,15 @@ struct HfTaskDplus { std::vector axes = {thnAxisMass, thnAxisPt}; if (doprocessDataWithMl) { - axes.insert(axes.end(), {thnAxisMlScore0, thnAxisMlScore1, thnAxisMlScore2}); + axes.push_back(thnAxisMlScore0); + axes.push_back(thnAxisMlScore1); + axes.push_back(thnAxisMlScore2); } if (storeCentrality) { - axes.insert(axes.end(), {thnAxisCent}); + axes.push_back(thnAxisCent); } if (storeOccupancy) { - axes.insert(axes.end(), {thnAxisOccupancy}); + axes.push_back(thnAxisOccupancy); } registry.add("hSparseMass", "THn for Dplus", HistType::kTHnSparseF, axes); @@ -177,30 +203,39 @@ struct HfTaskDplus { std::vector axesGenPrompt = {thnAxisPt, thnAxisY}; std::vector axesGenFD = {thnAxisPt, thnAxisY}; - axesFD.insert(axesFD.end(), {thnAxisPtBHad}); - axesFD.insert(axesFD.end(), {thnAxisFlagBHad}); - axesGenFD.insert(axesGenFD.end(), {thnAxisPtBHad}); - axesGenFD.insert(axesGenFD.end(), {thnAxisFlagBHad}); - if (doprocessMcWithMl) { axes.insert(axes.end(), {thnAxisMlScore0, thnAxisMlScore1, thnAxisMlScore2}); axesFD.insert(axesFD.end(), {thnAxisMlScore0, thnAxisMlScore1, thnAxisMlScore2}); } if (storeCentrality) { - axes.insert(axes.end(), {thnAxisCent}); - axesFD.insert(axesFD.end(), {thnAxisCent}); - axesGenPrompt.insert(axesGenPrompt.end(), {thnAxisCent}); - axesGenFD.insert(axesGenFD.end(), {thnAxisCent}); + axes.push_back(thnAxisCent); + axesFD.push_back(thnAxisCent); + axesGenPrompt.push_back(thnAxisCent); + axesGenFD.push_back(thnAxisCent); } if (storeOccupancy) { - axes.insert(axes.end(), {thnAxisOccupancy}); - axesFD.insert(axesFD.end(), {thnAxisOccupancy}); - axesGenPrompt.insert(axesGenPrompt.end(), {thnAxisOccupancy}); - axesGenFD.insert(axesGenFD.end(), {thnAxisOccupancy}); + axes.push_back(thnAxisOccupancy); + axesFD.push_back(thnAxisOccupancy); + axesGenPrompt.push_back(thnAxisOccupancy); + axesGenFD.push_back(thnAxisOccupancy); + } + if (storePvContributors) { + axes.push_back(thnAxisPvContributors); + axesFD.push_back(thnAxisPvContributors); + axesGenPrompt.push_back(thnAxisPvContributors); + axesGenFD.push_back(thnAxisPvContributors); } + + axesFD.push_back(thnAxisPtBHad); + axesFD.push_back(thnAxisFlagBHad); + axesGenFD.push_back(thnAxisPtBHad); + axesGenFD.push_back(thnAxisFlagBHad); + registry.add("hSparseMassPrompt", "THn for Dplus Prompt", HistType::kTHnSparseF, axes); registry.add("hSparseMassFD", "THn for Dplus FD", HistType::kTHnSparseF, axesFD); - registry.add("hSparseMassBkg", "THn for Dplus Bkg", HistType::kTHnSparseF, axes); + if (fillMcBkgHistos) { + registry.add("hSparseMassBkg", "THn for Dplus Bkg", HistType::kTHnSparseF, axes); + } registry.add("hSparseMassNotMatched", "THn for Dplus not matched", HistType::kTHnSparseF, axes); registry.add("hSparseMassGenPrompt", "THn for gen Prompt Dplus", HistType::kTHnSparseF, axesGenPrompt); registry.add("hSparseMassGenFD", "THn for gen FD Dplus", HistType::kTHnSparseF, axesGenFD); @@ -244,12 +279,14 @@ struct HfTaskDplus { /// \param flagBHad transverse momentum of beauty mother for nonprompt candidates /// \param centrality collision centrality /// \param occupancy collision occupancy + /// \param numPvContributors contributors to the PV template void fillSparseML(const T1& candidate, float ptbhad, int flagBHad, float centrality, - float occupancy) + float occupancy, + float numPvContributors) { std::vector outputMl = {-999., -999., -999.}; for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { @@ -265,6 +302,8 @@ struct HfTaskDplus { registry.fill(HIST("hSparseMassPrompt"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], centrality); } else if (!storeCentrality && storeOccupancy) { registry.fill(HIST("hSparseMassPrompt"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], occupancy); + } else if (!storeCentrality && !storeOccupancy && storePvContributors) { + registry.fill(HIST("hSparseMassPrompt"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], numPvContributors); } else { registry.fill(HIST("hSparseMassPrompt"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2]); } @@ -272,25 +311,30 @@ struct HfTaskDplus { } else if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { // FD if (storeCentrality && storeOccupancy) { - registry.fill(HIST("hSparseMassFD"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), ptbhad, flagBHad, outputMl[0], outputMl[1], outputMl[2], centrality, occupancy); + registry.fill(HIST("hSparseMassFD"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], centrality, occupancy, ptbhad, flagBHad); } else if (storeCentrality && !storeOccupancy) { - registry.fill(HIST("hSparseMassFD"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), ptbhad, flagBHad, outputMl[0], outputMl[1], outputMl[2], centrality); + registry.fill(HIST("hSparseMassFD"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], centrality, ptbhad, flagBHad); } else if (!storeCentrality && storeOccupancy) { - registry.fill(HIST("hSparseMassFD"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), ptbhad, flagBHad, outputMl[0], outputMl[1], outputMl[2], occupancy); + registry.fill(HIST("hSparseMassFD"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], occupancy, ptbhad, flagBHad); + } else if (!storeCentrality && !storeOccupancy && storePvContributors) { + registry.fill(HIST("hSparseMassFD"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], numPvContributors); } else { - registry.fill(HIST("hSparseMassFD"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), ptbhad, flagBHad, outputMl[0], outputMl[1], outputMl[2]); + registry.fill(HIST("hSparseMassFD"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], ptbhad, flagBHad); } } else { // Bkg - - if (storeCentrality && storeOccupancy) { - registry.fill(HIST("hSparseMassBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], centrality, occupancy); - } else if (storeCentrality && !storeOccupancy) { - registry.fill(HIST("hSparseMassBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], centrality); - } else if (!storeCentrality && storeOccupancy) { - registry.fill(HIST("hSparseMassBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], occupancy); - } else { - registry.fill(HIST("hSparseMassBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2]); + if (fillMcBkgHistos) { + if (storeCentrality && storeOccupancy) { + registry.fill(HIST("hSparseMassBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], centrality, occupancy); + } else if (storeCentrality && !storeOccupancy) { + registry.fill(HIST("hSparseMassBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], centrality); + } else if (!storeCentrality && storeOccupancy) { + registry.fill(HIST("hSparseMassBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], occupancy); + } else if (!storeCentrality && !storeOccupancy && storePvContributors) { + registry.fill(HIST("hSparseMassBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], numPvContributors); + } else { + registry.fill(HIST("hSparseMassBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2]); + } } } } else { @@ -300,6 +344,8 @@ struct HfTaskDplus { registry.fill(HIST("hSparseMassNotMatched"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], centrality); } else if (!storeCentrality && storeOccupancy) { registry.fill(HIST("hSparseMassNotMatched"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], occupancy); + } else if (!storeCentrality && !storeOccupancy && storePvContributors) { + registry.fill(HIST("hSparseMassNotMatched"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], numPvContributors); } else { registry.fill(HIST("hSparseMassNotMatched"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2]); } @@ -311,6 +357,8 @@ struct HfTaskDplus { registry.fill(HIST("hSparseMass"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], centrality); } else if (!storeCentrality && storeOccupancy) { registry.fill(HIST("hSparseMass"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], occupancy); + } else if (!storeCentrality && !storeOccupancy && storePvContributors) { + registry.fill(HIST("hSparseMass"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], numPvContributors); } else { registry.fill(HIST("hSparseMass"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2]); } @@ -392,12 +440,14 @@ struct HfTaskDplus { /// \param flagGenB transverse momentum of beauty mother for nonprompt candidates /// \param centrality collision centrality /// \param occupancy collision occupancy + /// \param numPvContributors contributors to the PV template void fillSparseMcGen(const T1& particle, float ptGenB, int flagGenB, float centrality, - float occupancy) + float occupancy, + float numPvContributors) { auto yGen = RecoDecay::y(particle.pVector(), o2::constants::physics::MassDPlus); if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { @@ -407,16 +457,20 @@ struct HfTaskDplus { registry.fill(HIST("hSparseMassGenPrompt"), particle.pt(), yGen, centrality); } else if (!storeCentrality && storeOccupancy) { registry.fill(HIST("hSparseMassGenPrompt"), particle.pt(), yGen, occupancy); + } else if (!storeCentrality && !storeOccupancy && storePvContributors) { + registry.fill(HIST("hSparseMassGenPrompt"), particle.pt(), yGen, numPvContributors); } else { registry.fill(HIST("hSparseMassGenPrompt"), particle.pt(), yGen); } } else { if (storeCentrality && storeOccupancy) { - registry.fill(HIST("hSparseMassGenFD"), particle.pt(), yGen, ptGenB, flagGenB, centrality, occupancy); + registry.fill(HIST("hSparseMassGenFD"), particle.pt(), yGen, centrality, occupancy, ptGenB, flagGenB); } else if (storeCentrality && !storeOccupancy) { - registry.fill(HIST("hSparseMassGenFD"), particle.pt(), yGen, ptGenB, flagGenB, centrality); + registry.fill(HIST("hSparseMassGenFD"), particle.pt(), yGen, centrality, ptGenB, flagGenB); } else if (!storeCentrality && storeOccupancy) { - registry.fill(HIST("hSparseMassGenFD"), particle.pt(), yGen, ptGenB, flagGenB, occupancy); + registry.fill(HIST("hSparseMassGenFD"), particle.pt(), yGen, occupancy, ptGenB, flagGenB); + } else if (!storeCentrality && !storeOccupancy && storePvContributors) { + registry.fill(HIST("hSparseMassGenFD"), particle.pt(), yGen, numPvContributors, ptGenB, flagGenB); } else { registry.fill(HIST("hSparseMassGenFD"), particle.pt(), yGen, ptGenB, flagGenB); } @@ -430,6 +484,7 @@ struct HfTaskDplus { { float cent{-1.f}; float occ{-1.f}; + float numPvContr{-1.f}; float ptBhad{-1.f}; int flagBHad{-1}; if constexpr (!fillMl) { @@ -453,10 +508,13 @@ struct HfTaskDplus { if (storeOccupancy && occEstimator != OccupancyEstimator::None) { occ = getOccupancyColl(collision, occEstimator); } + if (storePvContributors) { + numPvContr = collision.numContrib(); + } } fillHisto(candidate); - fillSparseML(candidate, ptBhad, flagBHad, cent, occ); + fillSparseML(candidate, ptBhad, flagBHad, cent, occ, numPvContr); } } } @@ -469,6 +527,7 @@ struct HfTaskDplus { { float cent{-1}; float occ{-1}; + float numPvContr{-1}; float ptBhad{-1}; int flagBHad{-1}; @@ -482,11 +541,13 @@ struct HfTaskDplus { fillHistoMCRec(candidate); } // Bkg - for (const auto& candidate : recoBkgCandidates) { - if ((yCandRecoMax >= 0. && std::abs(hfHelper.yDplus(candidate)) > yCandRecoMax)) { - continue; + if (fillMcBkgHistos) { + for (const auto& candidate : recoBkgCandidates) { + if ((yCandRecoMax >= 0. && std::abs(hfHelper.yDplus(candidate)) > yCandRecoMax)) { + continue; + } + fillHistoMCRec(candidate); } - fillHistoMCRec(candidate); } } else { for (const auto& candidate : recoDPlusCandidatesWithMl) { @@ -504,28 +565,36 @@ struct HfTaskDplus { if (storeOccupancy && occEstimator != OccupancyEstimator::None) { occ = getOccupancyColl(collision, occEstimator); } + if (storePvContributors) { + numPvContr = collision.numContrib(); + } } fillHisto(candidate); fillHistoMCRec(candidate); - fillSparseML(candidate, ptBhad, flagBHad, cent, occ); + fillSparseML(candidate, ptBhad, flagBHad, cent, occ, numPvContr); } // Bkg ptBhad = -1; flagBHad = -1; - for (const auto& candidate : recoBkgCandidatesWithMl) { - if ((yCandRecoMax >= 0. && std::abs(hfHelper.yDplus(candidate)) > yCandRecoMax)) { - continue; - } - auto collision = candidate.template collision_as(); - if (storeCentrality && centEstimator != CentralityEstimator::None) { - cent = getCentralityColl(collision, centEstimator); - } - if (storeOccupancy && occEstimator != OccupancyEstimator::None) { - occ = getOccupancyColl(collision, occEstimator); + if (fillMcBkgHistos) { + for (const auto& candidate : recoBkgCandidatesWithMl) { + if ((yCandRecoMax >= 0. && std::abs(hfHelper.yDplus(candidate)) > yCandRecoMax)) { + continue; + } + auto collision = candidate.template collision_as(); + if (storeCentrality && centEstimator != CentralityEstimator::None) { + cent = getCentralityColl(collision, centEstimator); + } + if (storeOccupancy && occEstimator != OccupancyEstimator::None) { + occ = getOccupancyColl(collision, occEstimator); + } + if (storePvContributors) { + numPvContr = collision.numContrib(); + } + fillHistoMCRec(candidate); + fillSparseML(candidate, ptBhad, flagBHad, cent, occ, numPvContr); } - fillHistoMCRec(candidate); - fillSparseML(candidate, ptBhad, flagBHad, cent, occ); } } } @@ -542,6 +611,7 @@ struct HfTaskDplus { // MC gen. float cent{-1.}; float occ{-1.}; + float numPvContr{-1.}; float ptGenB{-1.}; int flagGenB{-1}; @@ -558,8 +628,9 @@ struct HfTaskDplus { for (const auto& particle : mcParticlesPerGenMcColl) { ptGenB = -1; flagGenB = -1; + numPvContr = -1; auto yGen = RecoDecay::y(particle.pVector(), o2::constants::physics::MassDPlus); - if ((yCandGenMax >= 0. && std::abs(yGen) > yCandGenMax) || (std::abs(particle.flagMcMatchGen()) != 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi)) { + if ((yCandGenMax >= 0. && std::abs(yGen) > yCandGenMax) || (std::abs(particle.flagMcMatchGen()) != hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi)) { continue; } if (particle.originMcGen() == RecoDecay::OriginType::NonPrompt) { @@ -567,9 +638,12 @@ struct HfTaskDplus { flagGenB = getBHadMotherFlag(bHadMother.pdgCode()); ptGenB = bHadMother.pt(); } + for (const auto& recCol : mcRecoCollisions) { + numPvContr = std::max(numPvContr, recCol.numContrib()); + } fillHistoMCGen(particle); if constexpr (fillMl) { - fillSparseMcGen(particle, ptGenB, flagGenB, cent, occ); + fillSparseMcGen(particle, ptGenB, flagGenB, cent, occ, numPvContr); } } } diff --git a/PWGHF/D2H/Tasks/taskDs.cxx b/PWGHF/D2H/Tasks/taskDs.cxx index 4c9a966e6b9..2621b1e1163 100644 --- a/PWGHF/D2H/Tasks/taskDs.cxx +++ b/PWGHF/D2H/Tasks/taskDs.cxx @@ -17,32 +17,56 @@ /// \author Stefano Politanò , Politecnico & INFN Torino /// \author Fabrizio Chinu , Universita and INFN Torino -#include -#include -#include -#include -#include - -#include "CCDB/BasicCCDBManager.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "MetadataHelper.h" - -#include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsEvSelHf.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "PWGHF/Utils/utilsEvSelHf.h" + +#include "Common/Core/MetadataHelper.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; -MetadataHelper metadataInfo; // Metadata helper +o2::common::core::MetadataHelper metadataInfo; // Metadata helper enum FinalState { KKPi = 0, PiKK }; @@ -57,9 +81,21 @@ enum DataType { Data = 0, McBkg, kDataTypes }; +enum Mother : int8_t { + Ds, + Dplus +}; + +enum ResonantChannel : int8_t { + PhiPi = 1, + Kstar0K = 2 +}; + +static std::unordered_map> channelsResonant = {{{Mother::Ds, {{ResonantChannel::PhiPi, hf_decay::hf_cand_3prong::DecayChannelResonant::DsToPhiPi}, {ResonantChannel::Kstar0K, hf_decay::hf_cand_3prong::DecayChannelResonant::DsToKstar0K}}}, + {Mother::Dplus, {{ResonantChannel::PhiPi, hf_decay::hf_cand_3prong::DecayChannelResonant::DplusToPhiPi}, {ResonantChannel::Kstar0K, hf_decay::hf_cand_3prong::DecayChannelResonant::DplusToKstar0K}}}}}; + template -concept hasDsMlInfo = requires(T candidate) -{ +concept HasDsMlInfo = requires(T candidate) { candidate.mlProbDsToKKPi(); candidate.mlProbDsToPiKK(); }; @@ -67,7 +103,7 @@ concept hasDsMlInfo = requires(T candidate) /// Ds± analysis task struct HfTaskDs { - Configurable decayChannel{"decayChannel", 1, "Switch between decay channels: 1 for Ds/Dplus->PhiPi->KKpi, 2 for Ds/Dplus->K0*K->KKPi"}; + Configurable decayChannel{"decayChannel", 1, "Switch between resonant decay channels: 1 for Ds/Dplus->PhiPi->KKpi, 2 for Ds/Dplus->K0*K->KKPi"}; Configurable fillDplusMc{"fillDplusMc", true, "Switch to fill Dplus MC information"}; Configurable selectionFlagDs{"selectionFlagDs", 7, "Selection Flag for Ds"}; Configurable> classMl{"classMl", {0, 2, 3}, "Indexes of ML scores to be stored. Three indexes max."}; @@ -80,6 +116,7 @@ struct HfTaskDs { Configurable fillPercentiles{"fillPercentiles", true, "Wheter to fill multiplicity axis with percentiles or raw information"}; Configurable storeOccupancy{"storeOccupancy", false, "Flag to store occupancy information"}; Configurable occEstimator{"occEstimator", 0, "Occupancy estimation (None: 0, ITS: 1, FT0C: 2)"}; + Configurable fillMcBkgHistos{"fillMcBkgHistos", false, "Flag to fill and store histograms for MC background"}; struct : ConfigurableGroup { Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "The CCDB endpoint url address"}; @@ -125,10 +162,9 @@ struct HfTaskDs { ConfigurableAxis axisMlScore0{"axisMlScore0", {100, 0., 1.}, "axis for ML output score 0"}; ConfigurableAxis axisMlScore1{"axisMlScore1", {100, 0., 1.}, "axis for ML output score 1"}; ConfigurableAxis axisMlScore2{"axisMlScore2", {100, 0., 1.}, "axis for ML output score 2"}; - ConfigurableAxis axisCentrality{"axisCentrality", {100, 0., 1.}, "axis for centrality/multiplicity"}; + ConfigurableAxis axisCentrality{"axisCentrality", {100, 0, 100}, "axis for centrality/multiplicity"}; ConfigurableAxis axisOccupancy{"axisOccupancy", {14, 0., 14000.}, "axis for occupancy"}; - int offsetDplusDecayChannel = aod::hf_cand_3prong::DecayChannelDToKKPi::DplusToPhiPi - aod::hf_cand_3prong::DecayChannelDToKKPi::DsToPhiPi; // Offset between Dplus and Ds to use the same decay channel. See aod::hf_cand_3prong::DecayChannelDToKKPi int mRunNumber{0}; bool lCalibLoaded; TList* lCalibObjects; @@ -162,12 +198,16 @@ struct HfTaskDs { LOGP(fatal, "No process function enabled"); } + if (decayChannel != ResonantChannel::PhiPi && decayChannel != ResonantChannel::Kstar0K) { + LOGP(fatal, "Invalid value of decayChannel"); + } + AxisSpec ptbins{axisPt, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec ptBHad{axisPtBHad, "#it{p}_{T}(B) (GeV/#it{c})"}; AxisSpec flagBHad{axisFlagBHad, "B Hadron flag"}; AxisSpec ybins = {100, -5., 5, "#it{y}"}; AxisSpec massbins = {600, 1.67, 2.27, "inv. mass (KK#pi) (GeV/#it{c}^{2})"}; - AxisSpec centralitybins = {100, 0., 100., "Centrality"}; + AxisSpec centralitybins = {axisCentrality, "Centrality"}; AxisSpec npvcontributorsbins = {axisNPvContributors, "NPvContributors"}; AxisSpec mlscore0bins = {axisMlScore0, "Score 0"}; AxisSpec mlscore1bins = {axisMlScore1, "Score 1"}; @@ -178,40 +218,42 @@ struct HfTaskDs { std::vector axes = {massbins, ptbins, centralitybins}; std::vector axesMl = {massbins, ptbins, centralitybins, mlscore0bins, mlscore1bins, mlscore2bins}; - std::vector axesFd = {massbins, ptbins, centralitybins, ptBHad, flagBHad}; - std::vector axesFdMl = {massbins, ptbins, centralitybins, mlscore0bins, mlscore1bins, mlscore2bins, ptBHad, flagBHad}; + std::vector axesFdWithNpv = {massbins, ptbins, centralitybins, npvcontributorsbins, ptBHad, flagBHad}; + std::vector axesFdWithNpvMl = {massbins, ptbins, centralitybins, mlscore0bins, mlscore1bins, mlscore2bins, npvcontributorsbins, ptBHad, flagBHad}; std::vector axesWithNpv = {massbins, ptbins, centralitybins, npvcontributorsbins}; - std::vector axesWithNpvMl = {massbins, ptbins, centralitybins, npvcontributorsbins, mlscore0bins, mlscore1bins, mlscore2bins}; + std::vector axesWithNpvMl = {massbins, ptbins, centralitybins, mlscore0bins, mlscore1bins, mlscore2bins, npvcontributorsbins}; std::vector axesGenPrompt = {ptbins, ybins, npvcontributorsbins, centralitybins}; - std::vector axesGenFd = {ptbins, ybins, npvcontributorsbins, ptBHad, flagBHad, centralitybins}; - std::vector axesGenBkg = {ptbins, ybins, npvcontributorsbins, centralitybins}; + std::vector axesGenFd = {ptbins, ybins, npvcontributorsbins, centralitybins, ptBHad, flagBHad}; if (storeOccupancy) { axes.insert(axes.end(), {occupancybins}); axesMl.insert(axesMl.end(), {occupancybins}); - axesFd.insert(axesFd.end(), {occupancybins}); - axesFdMl.insert(axesFdMl.end(), {occupancybins}); + axesFdWithNpv.insert(axesFdWithNpv.end(), {occupancybins}); + axesFdWithNpvMl.insert(axesFdWithNpvMl.end(), {occupancybins}); axesWithNpv.insert(axesWithNpv.end(), {occupancybins}); axesWithNpvMl.insert(axesWithNpvMl.end(), {occupancybins}); axesGenPrompt.insert(axesGenPrompt.end(), {occupancybins}); axesGenFd.insert(axesGenFd.end(), {occupancybins}); - axesGenBkg.insert(axesGenBkg.end(), {occupancybins}); } for (auto i = 0; i < DataType::kDataTypes; ++i) { if (doprocessDataWithCentFT0C || doprocessDataWithCentFT0M || doprocessDataWithCentNTracksPV || doprocessData || doprocessMcWithCentFT0C || doprocessMcWithCentFT0M || doprocessMcWithCentNTracksPV || doprocessMc) { if (i == DataType::Data) { // If data do not fill PV contributors in sparse histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, axes); - } else if (i == DataType::McDsNonPrompt) { // If data do not fill PV contributors in sparse - histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, axesFd); + } else if (i == DataType::McDsNonPrompt || i == DataType::McDplusNonPrompt) { + histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, axesFdWithNpv); } else { histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, axesWithNpv); } } else if (doprocessDataWithMlAndCentFT0C || doprocessDataWithMlAndCentFT0M || doprocessDataWithMlAndCentNTracksPV || doprocessDataWithMl || doprocessMcWithMlAndCentFT0C || doprocessMcWithMlAndCentFT0M || doprocessMcWithMlAndCentNTracksPV || doprocessMcWithMl) { + if (i == DataType::McBkg && !fillMcBkgHistos) { + continue; + } + if (i == DataType::Data) { // If data do not fill PV contributors in sparse histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, axesMl); - } else if (i == DataType::McDsNonPrompt) { // If data do not fill PV contributors in sparse - histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, axesFdMl); + } else if (i == DataType::McDsNonPrompt || i == DataType::McDplusNonPrompt) { + histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, axesFdWithNpvMl); } else { histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, axesWithNpvMl); } @@ -263,9 +305,6 @@ struct HfTaskDs { if (i == DataType::McDsNonPrompt || i == DataType::McDplusNonPrompt) { histosPtr[i]["hSparseGen"] = registry.add((folders[i] + "hSparseGen").c_str(), "Thn for generated nonprompt candidates", HistType::kTHnSparseF, axesGenFd); } - if (i == DataType::McBkg) { - histosPtr[i]["hSparseGen"] = registry.add((folders[i] + "hSparseGen").c_str(), "Thn for non-matched generated candidates", HistType::kTHnSparseF, axesGenBkg); - } } } } @@ -273,37 +312,37 @@ struct HfTaskDs { template bool isDsPrompt(const CandDs& candidate) { - return std::abs(candidate.flagMcMatchRec()) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && candidate.flagMcDecayChanRec() == decayChannel && candidate.originMcRec() == RecoDecay::OriginType::Prompt; + return std::abs(candidate.flagMcMatchRec()) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && candidate.flagMcDecayChanRec() == channelsResonant[Mother::Ds][decayChannel] && candidate.originMcRec() == RecoDecay::OriginType::Prompt; } template bool isDplusPrompt(const CandDs& candidate) { - return std::abs(candidate.flagMcMatchRec()) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && candidate.flagMcDecayChanRec() == decayChannel + offsetDplusDecayChannel && candidate.originMcRec() == RecoDecay::OriginType::Prompt; + return std::abs(candidate.flagMcMatchRec()) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKK) && candidate.flagMcDecayChanRec() == channelsResonant[Mother::Dplus][decayChannel] && candidate.originMcRec() == RecoDecay::OriginType::Prompt; } template bool isDsNonPrompt(const CandDs& candidate) { - return std::abs(candidate.flagMcMatchRec()) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && candidate.flagMcDecayChanRec() == decayChannel && candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; + return std::abs(candidate.flagMcMatchRec()) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && candidate.flagMcDecayChanRec() == channelsResonant[Mother::Ds][decayChannel] && candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; } template bool isDplusNonPrompt(const CandDs& candidate) { - return std::abs(candidate.flagMcMatchRec()) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && candidate.flagMcDecayChanRec() == decayChannel + offsetDplusDecayChannel && candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; + return std::abs(candidate.flagMcMatchRec()) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKK) && candidate.flagMcDecayChanRec() == channelsResonant[Mother::Dplus][decayChannel] && candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; } template bool isDplusBkg(const CandDs& candidate) { - return std::abs(candidate.flagMcMatchRec()) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)); + return std::abs(candidate.flagMcMatchRec()) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi); } template bool isLcBkg(const CandDs& candidate) { - return std::abs(candidate.flagMcMatchRec()) == static_cast(BIT(aod::hf_cand_3prong::DecayType::LcToPKPi)); + return std::abs(candidate.flagMcMatchRec()) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi); } /// Checks whether the candidate is in the signal region of either the Ds or D+ decay @@ -429,7 +468,7 @@ struct HfTaskDs { /// \param candidate is candidate /// \param dataType is data class, as defined in DataType enum /// \param finalState is either KKPi or PiKK, as defined in FinalState enum - template + template void fillSparse(const Cand& candidate, DataType dataType, FinalState finalState) { auto mass = finalState == FinalState::KKPi ? hfHelper.invMassDsToKKPi(candidate) : hfHelper.invMassDsToPiKK(candidate); @@ -454,20 +493,20 @@ struct HfTaskDs { } } if constexpr (isMc) { - if (dataType == DataType::McDsNonPrompt) { // If data do not fill PV contributors in sparse + if (dataType == DataType::McDsNonPrompt || dataType == DataType::McDplusNonPrompt) { if (storeOccupancy) { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), outputMl[0], outputMl[1], outputMl[2], candidate.ptBhadMotherPart(), getBHadMotherFlag(candidate.pdgBhadMotherPart()), o2::hf_occupancy::getOccupancyColl(candidate.template collision_as(), occEstimator)); + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), outputMl[0], outputMl[1], outputMl[2], candidate.template collision_as().numContrib(), candidate.ptBhadMotherPart(), getBHadMotherFlag(candidate.pdgBhadMotherPart()), o2::hf_occupancy::getOccupancyColl(candidate.template collision_as(), occEstimator)); return; } else { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), outputMl[0], outputMl[1], outputMl[2], candidate.ptBhadMotherPart(), getBHadMotherFlag(candidate.pdgBhadMotherPart())); + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), outputMl[0], outputMl[1], outputMl[2], candidate.template collision_as().numContrib(), candidate.ptBhadMotherPart(), getBHadMotherFlag(candidate.pdgBhadMotherPart())); return; } } else { if (storeOccupancy) { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), candidate.template collision_as().numContrib(), outputMl[0], outputMl[1], outputMl[2], o2::hf_occupancy::getOccupancyColl(candidate.template collision_as(), occEstimator)); + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), outputMl[0], outputMl[1], outputMl[2], candidate.template collision_as().numContrib(), o2::hf_occupancy::getOccupancyColl(candidate.template collision_as(), occEstimator)); return; } else { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), candidate.template collision_as().numContrib(), outputMl[0], outputMl[1], outputMl[2]); + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), outputMl[0], outputMl[1], outputMl[2], candidate.template collision_as().numContrib()); return; } } @@ -494,12 +533,12 @@ struct HfTaskDs { } } if constexpr (isMc) { - if (dataType == DataType::McDsNonPrompt) { // If data do not fill PV contributors in sparse + if (dataType == DataType::McDsNonPrompt || dataType == DataType::McDplusNonPrompt) { if (storeOccupancy) { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), candidate.ptBhadMotherPart(), getBHadMotherFlag(candidate.pdgBhadMotherPart()), o2::hf_occupancy::getOccupancyColl(candidate.template collision_as(), occEstimator)); + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), candidate.template collision_as().numContrib(), candidate.ptBhadMotherPart(), getBHadMotherFlag(candidate.pdgBhadMotherPart()), o2::hf_occupancy::getOccupancyColl(candidate.template collision_as(), occEstimator)); return; } else { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), candidate.ptBhadMotherPart(), getBHadMotherFlag(candidate.pdgBhadMotherPart())); + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), candidate.template collision_as().numContrib(), candidate.ptBhadMotherPart(), getBHadMotherFlag(candidate.pdgBhadMotherPart())); return; } } else { @@ -557,13 +596,10 @@ struct HfTaskDs { { int id = o2::constants::physics::Pdg::kDS; - auto yCand = hfHelper.yDs(candidate); if (dataType == DataType::McDplusPrompt || dataType == DataType::McDplusNonPrompt || dataType == DataType::McDplusBkg) { id = o2::constants::physics::Pdg::kDPlus; - yCand = hfHelper.yDplus(candidate); } else if (dataType == DataType::McLcBkg) { id = o2::constants::physics::Pdg::kLambdaCPlus; - yCand = hfHelper.yLc(candidate); } auto indexMother = RecoDecay::getMother(mcParticles, @@ -571,13 +607,14 @@ struct HfTaskDs { id, true); if (indexMother != -1) { - if (yCandRecoMax >= 0. && std::abs(yCand) > yCandRecoMax) { - return; - } auto pt = candidate.pt(); // rec. level pT if (candidate.isSelDsToKKPi() >= selectionFlagDs) { // KKPi + auto yCand = candidate.y(hfHelper.invMassDsToKKPi(candidate)); + if (yCandRecoMax >= 0. && std::abs(yCand) > yCandRecoMax) { + return; + } fillHisto(candidate, dataType); fillHistoKKPi(candidate, dataType); @@ -592,6 +629,10 @@ struct HfTaskDs { } } if (candidate.isSelDsToPiKK() >= selectionFlagDs) { // PiKK + auto yCand = candidate.y(hfHelper.invMassDsToPiKK(candidate)); + if (yCandRecoMax >= 0. && std::abs(yCand) > yCandRecoMax) { + return; + } fillHisto(candidate, dataType); fillHistoPiKK(candidate, dataType); @@ -612,15 +653,17 @@ struct HfTaskDs { template void runDataAnalysisPerCandidate(CandDs const& candidate) { - if (yCandRecoMax >= 0. && std::abs(hfHelper.yDs(candidate)) > yCandRecoMax) { - return; - } - if (candidate.isSelDsToKKPi() >= selectionFlagDs) { // KKPi + if (yCandRecoMax >= 0. && std::abs(candidate.y(hfHelper.invMassDsToKKPi(candidate))) > yCandRecoMax) { + return; + } fillHisto(candidate, DataType::Data); fillHistoKKPi(candidate, DataType::Data); } if (candidate.isSelDsToPiKK() >= selectionFlagDs) { // PiKK + if (yCandRecoMax >= 0. && std::abs(candidate.y(hfHelper.invMassDsToPiKK(candidate))) > yCandRecoMax) { + return; + } fillHisto(candidate, DataType::Data); fillHistoPiKK(candidate, DataType::Data); } @@ -647,17 +690,20 @@ struct HfTaskDs { break; } } - if (isBkg) { - if (yCandRecoMax >= 0. && std::abs(hfHelper.yDs(candidate)) > yCandRecoMax) { - return; - } + if (isBkg && fillMcBkgHistos) { if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) { if (candidate.isSelDsToKKPi() >= selectionFlagDs) { // KKPi + if (yCandRecoMax >= 0. && std::abs(candidate.y(hfHelper.invMassDsToKKPi(candidate))) > yCandRecoMax) { + return; + } fillHisto(candidate, DataType::McBkg); fillHistoKKPi(candidate, DataType::McBkg); } if (candidate.isSelDsToPiKK() >= selectionFlagDs) { // PiKK + if (yCandRecoMax >= 0. && std::abs(candidate.y(hfHelper.invMassDsToPiKK(candidate))) > yCandRecoMax) { + return; + } fillHisto(candidate, DataType::McBkg); fillHistoPiKK(candidate, DataType::McBkg); } @@ -671,13 +717,12 @@ struct HfTaskDs { void fillMcGenHistosSparse(CandDsMcGen const& mcParticles, Coll const& recoCollisions) { - // MC gen. for (const auto& particle : mcParticles) { - const auto& recoCollsPerMcColl = recoCollisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex()); - if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) { - if (particle.flagMcDecayChanGen() == decayChannel || (fillDplusMc && particle.flagMcDecayChanGen() == (decayChannel + offsetDplusDecayChannel))) { + if (std::abs(particle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK || std::abs(particle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKK) { + const auto& recoCollsPerMcColl = recoCollisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex()); + if (particle.flagMcDecayChanGen() == channelsResonant[Mother::Ds][decayChannel] || (fillDplusMc && particle.flagMcDecayChanGen() == channelsResonant[Mother::Dplus][decayChannel])) { auto pt = particle.pt(); double y{0.f}; @@ -691,7 +736,7 @@ struct HfTaskDs { occ = o2::hf_occupancy::getOccupancyGenColl(recoCollsPerMcColl, occEstimator); } - if (particle.flagMcDecayChanGen() == decayChannel) { + if (particle.flagMcDecayChanGen() == channelsResonant[Mother::Ds][decayChannel]) { y = RecoDecay::y(particle.pVector(), o2::constants::physics::MassDS); if (yCandGenMax >= 0. && std::abs(y) > yCandGenMax) { continue; @@ -713,9 +758,9 @@ struct HfTaskDs { int flagGenB = getBHadMotherFlag(bHadMother.pdgCode()); float ptGenB = bHadMother.pt(); if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { - std::get(histosPtr[DataType::McDsNonPrompt]["hSparseGen"])->Fill(pt, y, maxNumContrib, ptGenB, flagGenB, cent, occ); + std::get(histosPtr[DataType::McDsNonPrompt]["hSparseGen"])->Fill(pt, y, maxNumContrib, cent, occ, ptGenB, flagGenB); } else { - std::get(histosPtr[DataType::McDsNonPrompt]["hSparseGen"])->Fill(pt, y, maxNumContrib, ptGenB, flagGenB, cent); + std::get(histosPtr[DataType::McDsNonPrompt]["hSparseGen"])->Fill(pt, y, maxNumContrib, cent, ptGenB, flagGenB); } } } else if (fillDplusMc) { @@ -739,30 +784,13 @@ struct HfTaskDs { int flagGenB = getBHadMotherFlag(bHadMother.pdgCode()); float ptGenB = bHadMother.pt(); if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { - std::get(histosPtr[DataType::McDplusNonPrompt]["hSparseGen"])->Fill(pt, y, maxNumContrib, ptGenB, flagGenB, cent, occ); + std::get(histosPtr[DataType::McDplusNonPrompt]["hSparseGen"])->Fill(pt, y, maxNumContrib, cent, occ, ptGenB, flagGenB); } else { - std::get(histosPtr[DataType::McDplusNonPrompt]["hSparseGen"])->Fill(pt, y, maxNumContrib, ptGenB, flagGenB, cent); + std::get(histosPtr[DataType::McDplusNonPrompt]["hSparseGen"])->Fill(pt, y, maxNumContrib, cent, ptGenB, flagGenB); } } } } - } else { // not matched candidates - auto pt = particle.pt(); - double y = RecoDecay::y(particle.pVector(), o2::constants::physics::MassDS); - unsigned maxNumContrib = 0; - for (const auto& recCol : recoCollsPerMcColl) { - maxNumContrib = recCol.numContrib() > maxNumContrib ? recCol.numContrib() : maxNumContrib; - } - float cent = o2::hf_centrality::getCentralityGenColl(recoCollsPerMcColl); - float occ{-1.}; - if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { - occ = o2::hf_occupancy::getOccupancyGenColl(recoCollsPerMcColl, occEstimator); - } - if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { - std::get(histosPtr[DataType::McBkg]["hSparseGen"])->Fill(pt, y, maxNumContrib, cent, occ); - } else { - std::get(histosPtr[DataType::McBkg]["hSparseGen"])->Fill(pt, y, maxNumContrib, cent); - } } } } @@ -777,6 +805,9 @@ struct HfTaskDs { float centrality = evaluateCentralityColl(collision); std::get(histosPtr[DataType::Data]["hNPvContribAll"])->Fill(numPvContributors, centrality); for (int i = 0; i < DataType::kDataTypes; i++) { + if (i == DataType::McBkg && !fillMcBkgHistos) { + continue; + } if (nCandsPerType[i]) { std::get(histosPtr[i]["hNPvContribCands"])->Fill(numPvContributors, centrality); } diff --git a/PWGHF/D2H/Tasks/taskDstarToD0Pi.cxx b/PWGHF/D2H/Tasks/taskDstarToD0Pi.cxx index e67a35c0f45..3175b472a0c 100644 --- a/PWGHF/D2H/Tasks/taskDstarToD0Pi.cxx +++ b/PWGHF/D2H/Tasks/taskDstarToD0Pi.cxx @@ -17,19 +17,32 @@ /// \brief Dstar production analysis task (With and Without ML) -#include -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -174,6 +187,7 @@ struct HfTaskDstarToD0Pi { registry.add("Yield/hDeltaInvMassVsPtVsCentVsBDTScore", "#Delta #it{M}_{inv} Vs Pt Vs Cent Vs BDTScore", {HistType::kTHnSparseF, {{axisDeltaInvMass}, {vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}, {axisBDTScoreBackground}, {axisBDTScorePrompt}, {axisBDTScoreNonPrompt}}}); } if (doprocessMcWML) { + registry.add("Efficiency/hPtVsCentVsBDTScore", "Pt Vs Cent Vs BDTScore", {HistType::kTHnSparseF, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}, {axisBDTScoreBackground}, {axisBDTScorePrompt}, {axisBDTScoreNonPrompt}}}); registry.add("Efficiency/hPtPromptVsCentVsBDTScore", "Pt Vs Cent Vs BDTScore", {HistType::kTHnSparseF, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}, {axisBDTScoreBackground}, {axisBDTScorePrompt}, {axisBDTScoreNonPrompt}}}); registry.add("Efficiency/hPtNonPromptVsCentVsBDTScore", "Pt Vs Cent Vs BDTScore", {HistType::kTHnSparseF, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}, {axisBDTScoreBackground}, {axisBDTScorePrompt}, {axisBDTScoreNonPrompt}}}); // registry.add("Efficiency/hPtBkgVsCentVsBDTScore", "Pt Vs Cent Vs BDTScore", {HistType::kTHnSparseF, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}, {axisBDTScoreBackground}, {axisBDTScorePrompt}, {axisBDTScoreNonPrompt}}}); @@ -270,6 +284,12 @@ struct HfTaskDstarToD0Pi { if (0.142f < deltaMAntiDstar && deltaMAntiDstar < 0.15f) { nCandsSignalRegion++; } + + if constexpr (applyMl) { + auto mlBdtScore = candDstar.mlProbDstarToD0Pi(); + registry.fill(HIST("Yield/hDeltaInvMassVsPtVsCentVsBDTScore"), deltaMAntiDstar, candDstar.pt(), centrality, mlBdtScore[0], mlBdtScore[1], mlBdtScore[2]); + } + registry.fill(HIST("Yield/hDeltaInvMassDstar3D"), deltaMAntiDstar, candDstar.pt(), centrality); registry.fill(HIST("Yield/hDeltaInvMassDstar2D"), deltaMAntiDstar, candDstar.pt()); registry.fill(HIST("Yield/hInvMassD0"), invD0Bar, candDstar.ptD0()); @@ -306,8 +326,8 @@ struct HfTaskDstarToD0Pi { continue; } auto collision = candDstarMcRec.template collision_as(); - auto centrality = collision.centFT0M(); // 0-100% - if (TESTBIT(std::abs(candDstarMcRec.flagMcMatchRec()), aod::hf_cand_dstar::DecayType::DstarToD0Pi)) { // if MC matching is successful at Reconstruction Level + auto centrality = collision.centFT0M(); // 0-100% + if (std::abs(candDstarMcRec.flagMcMatchRec()) == hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { // if MC matching is successful at Reconstruction Level // LOGF(info, "MC Rec Dstar loop MC Matched"); // get MC Mother particle auto prong0 = candDstarMcRec.template prong0_as(); @@ -326,6 +346,10 @@ struct HfTaskDstarToD0Pi { if (candDstarMcRec.isSelDstarToD0Pi()) { // if all selection passed registry.fill(HIST("QA/hPtFullRecoDstarRecSig"), ptDstarRecSig); registry.fill(HIST("Efficiency/hPtVsCentFullRecoDstarRecSig"), ptDstarRecSig, centrality); + if constexpr (applyMl) { + auto bdtScore = candDstarMcRec.mlProbDstarToD0Pi(); + registry.fill(HIST("Efficiency/hPtVsCentVsBDTScore"), ptDstarRecSig, centrality, bdtScore[0], bdtScore[1], bdtScore[2]); + } } registry.fill(HIST("QA/hCPASkimD0RecSig"), candDstarMcRec.cpaD0()); registry.fill(HIST("QA/hEtaSkimD0RecSig"), candDstarMcRec.etaD0()); @@ -343,10 +367,8 @@ struct HfTaskDstarToD0Pi { if (candDstarMcRec.isSelDstarToD0Pi()) { // if all selection passed registry.fill(HIST("QA/hPtFullRecoPromptDstarRecSig"), ptDstarRecSig); if constexpr (applyMl) { - // LOGF(info, "Deep: Prompt MC Rec Task Dstar: ML applied"); auto bdtScore = candDstarMcRec.mlProbDstarToD0Pi(); registry.fill(HIST("Efficiency/hPtPromptVsCentVsBDTScore"), ptDstarRecSig, centrality, bdtScore[0], bdtScore[1], bdtScore[2]); - // LOGF(info, "Deep: Prompt MC Rec Task Dstar: ML applied, Efficiency filled"); } } } else if (candDstarMcRec.originMcRec() == RecoDecay::OriginType::NonPrompt) { // only non-prompt signal at reconstruction level @@ -374,7 +396,6 @@ struct HfTaskDstarToD0Pi { } } } // candidate loop ends - // LOGF(info, "Deep: MC Rec Task Dstar finished"); } /// @brief This function runs over MC at gen level to obatin efficiency @@ -384,7 +405,7 @@ struct HfTaskDstarToD0Pi { { // MC Gen level for (auto const& mcParticle : rowsMcPartilces) { - if (TESTBIT(std::abs(mcParticle.flagMcMatchGen()), aod::hf_cand_dstar::DecayType::DstarToD0Pi)) { // MC Matching is successful at Generator Level + if (std::abs(mcParticle.flagMcMatchGen()) == hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { // MC Matching is successful at Generator Level auto ptGen = mcParticle.pt(); auto yGen = RecoDecay::y(mcParticle.pVector(), o2::constants::physics::MassDStar); if (yCandDstarGenMax >= 0. && std::abs(yGen) > yCandDstarGenMax) { diff --git a/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx b/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx index a154b416b2b..7960aeb7f4f 100644 --- a/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx +++ b/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx @@ -14,23 +14,43 @@ /// /// \author S. Politanò, INFN Torino, Italy /// \author Wu Chuntai, CUG, China +/// \author Ran Tu, Fudan University, China +/// \author Marcello Di Costanzo , Polytechnic University of Turin and INFN -#include -#include - -#include "CCDB/BasicCCDBManager.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsEvSelHf.h" #include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Qvectors.h" -#include "PWGHF/Core/HfHelper.h" -#include "PWGHF/Core/CentralityEstimation.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/Utils/utilsEvSelHf.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -40,13 +60,34 @@ using namespace o2::hf_centrality; using namespace o2::hf_occupancy; using namespace o2::hf_evsel; +namespace o2::aod +{ +namespace full +{ +DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate (GeV/c2) +DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) +// ML scores +DECLARE_SOA_COLUMN(MlScore0, mlScore0, float); //! ML score of the first configured index +DECLARE_SOA_COLUMN(MlScore1, mlScore1, float); //! ML score of the second configured index +} // namespace full +DECLARE_SOA_TABLE(HfCandPtCent, "AOD", "HFCANDPTCENT", + full::M, + full::Pt, + full::MlScore0, + full::MlScore1); +} // namespace o2::aod + enum DecayChannel { DplusToPiKPi = 0, DsToKKPi, DsToPiKK, D0ToPiK, D0ToKPi, LcToPKPi, - LcToPiKP }; + LcToPiKP, + XicToPKPi, + XicToPiKP, + Xic0ToXiPi +}; enum QvecEstimator { FV0A = 0, FT0M, @@ -57,6 +98,8 @@ enum QvecEstimator { FV0A = 0, TPCTot }; struct HfTaskFlowCharmHadrons { + Produces rowCandidateMassPtMlScores; + Configurable harmonic{"harmonic", 2, "harmonic number"}; Configurable qvecDetector{"qvecDetector", 3, "Detector for Q vector estimation (FV0A: 0, FT0M: 1, FT0A: 2, FT0C: 3, TPC Pos: 4, TPC Neg: 5, TPC Tot: 6)"}; Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3, FV0A: 4)"}; @@ -65,26 +108,21 @@ struct HfTaskFlowCharmHadrons { Configurable centralityMax{"centralityMax", 100., "Maximum centrality accepted in SP/EP computation (not applied in resolution process)"}; Configurable storeEP{"storeEP", false, "Flag to store EP-related axis"}; Configurable storeMl{"storeMl", false, "Flag to store ML scores"}; + Configurable fillMassPtMlTree{"fillMassPtMlTree", false, "Flag to fill mass and pt tree"}; + Configurable downSampleFactor{"downSampleFactor", 1., "Fraction of candidates to keep in TTree"}; + Configurable ptDownSampleMax{"ptDownSampleMax", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable storeResoOccu{"storeResoOccu", false, "Flag to store Occupancy in resolution ThnSparse"}; + Configurable storeEpCosSin{"storeEpCosSin", false, "Flag to store cos and sin of EP angle in ThnSparse"}; Configurable occEstimator{"occEstimator", 0, "Occupancy estimation (0: None, 1: ITS, 2: FT0C)"}; Configurable saveEpResoHisto{"saveEpResoHisto", false, "Flag to save event plane resolution histogram"}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable> classMl{"classMl", {0, 2}, "Indexes of BDT scores to be stored. Two indexes max."}; - ConfigurableAxis thnConfigAxisInvMass{"thnConfigAxisInvMass", {100, 1.78, 2.05}, ""}; - ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {10, 0., 10.}, ""}; - ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {10000, 0., 100.}, ""}; - ConfigurableAxis thnConfigAxisCosNPhi{"thnConfigAxisCosNPhi", {100, -1., 1.}, ""}; - ConfigurableAxis thnConfigAxisCosDeltaPhi{"thnConfigAxisCosDeltaPhi", {100, -1., 1.}, ""}; - ConfigurableAxis thnConfigAxisScalarProd{"thnConfigAxisScalarProd", {100, 0., 1.}, ""}; - ConfigurableAxis thnConfigAxisMlOne{"thnConfigAxisMlOne", {1000, 0., 1.}, ""}; - ConfigurableAxis thnConfigAxisMlTwo{"thnConfigAxisMlTwo", {1000, 0., 1.}, ""}; - ConfigurableAxis thnConfigAxisOccupancyITS{"thnConfigAxisOccupancyITS", {14, 0, 14000}, ""}; - ConfigurableAxis thnConfigAxisOccupancyFT0C{"thnConfigAxisOccupancyFT0C", {14, 0, 140000}, ""}; - ConfigurableAxis thnConfigAxisNoSameBunchPileup{"thnConfigAxisNoSameBunchPileup", {2, 0, 2}, ""}; - ConfigurableAxis thnConfigAxisOccupancy{"thnConfigAxisOccupancy", {2, 0, 2}, ""}; - ConfigurableAxis thnConfigAxisNoCollInTimeRangeNarrow{"thnConfigAxisNoCollInTimeRangeNarrow", {2, 0, 2}, ""}; - ConfigurableAxis thnConfigAxisNoCollInTimeRangeStandard{"thnConfigAxisNoCollInTimeRangeStandard", {2, 0, 2}, ""}; - ConfigurableAxis thnConfigAxisNoCollInRofStandard{"thnConfigAxisNoCollInRofStandard", {2, 0, 2}, ""}; + HfHelper hfHelper; + EventPlaneHelper epHelper; + HfEventSelection hfEvSel; // event selection and monitoring + o2::framework::Service ccdb; + SliceCache cache; using CandDsDataWMl = soa::Filtered>; using CandDsData = soa::Filtered>; @@ -92,6 +130,10 @@ struct HfTaskFlowCharmHadrons { using CandDplusData = soa::Filtered>; using CandLcData = soa::Filtered>; using CandLcDataWMl = soa::Filtered>; + using CandXicData = soa::Filtered>; + using CandXicDataWMl = soa::Filtered>; + using CandXic0Data = soa::Filtered>; + using CandXic0DataWMl = soa::Filtered>; using CandD0DataWMl = soa::Filtered>; using CandD0Data = soa::Filtered>; using CollsWithQvecs = soa::Join; @@ -100,6 +142,8 @@ struct HfTaskFlowCharmHadrons { Filter filterSelectDplusCandidates = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlag; Filter filterSelectD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlag || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlag; Filter filterSelectLcCandidates = aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlag || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlag; + Filter filterSelectXicCandidates = aod::hf_sel_candidate_xic::isSelXicToPKPi >= selectionFlag || aod::hf_sel_candidate_xic::isSelXicToPiKP >= selectionFlag; + Filter filterSelectXic0Candidates = aod::hf_sel_toxipi::resultSelections == true; Partition selectedDsToKKPi = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlag; Partition selectedDsToPiKK = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlag; @@ -113,21 +157,46 @@ struct HfTaskFlowCharmHadrons { Partition selectedLcToPiKP = aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlag; Partition selectedLcToPKPiWMl = aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlag; Partition selectedLcToPiKPWMl = aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlag; + Partition selectedXicToPKPi = aod::hf_sel_candidate_xic::isSelXicToPKPi >= selectionFlag; + Partition selectedXicToPiKP = aod::hf_sel_candidate_xic::isSelXicToPiKP >= selectionFlag; + Partition selectedXicToPKPiWMl = aod::hf_sel_candidate_xic::isSelXicToPKPi >= selectionFlag; + Partition selectedXicToPiKPWMl = aod::hf_sel_candidate_xic::isSelXicToPiKP >= selectionFlag; + Partition selectedXic0 = aod::hf_sel_toxipi::resultSelections == true; + Partition selectedXic0WMl = aod::hf_sel_toxipi::resultSelections == true; - SliceCache cache; - HfHelper hfHelper; - EventPlaneHelper epHelper; - HfEventSelection hfEvSel; // event selection and monitoring - o2::framework::Service ccdb; + ConfigurableAxis thnConfigAxisInvMass{"thnConfigAxisInvMass", {100, 1.78, 2.05}, ""}; + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {10, 0., 10.}, ""}; + ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {10000, 0., 100.}, ""}; + ConfigurableAxis thnConfigAxisCosNPhi{"thnConfigAxisCosNPhi", {100, -1., 1.}, ""}; + ConfigurableAxis thnConfigAxisPsi{"thnConfigAxisPsi", {6000, 0, constants::math::TwoPI}, ""}; + ConfigurableAxis thnConfigAxisCosDeltaPhi{"thnConfigAxisCosDeltaPhi", {100, -1., 1.}, ""}; + ConfigurableAxis thnConfigAxisScalarProd{"thnConfigAxisScalarProd", {100, 0., 1.}, ""}; + ConfigurableAxis thnConfigAxisMlOne{"thnConfigAxisMlOne", {1000, 0., 1.}, ""}; + ConfigurableAxis thnConfigAxisMlTwo{"thnConfigAxisMlTwo", {1000, 0., 1.}, ""}; + ConfigurableAxis thnConfigAxisOccupancyITS{"thnConfigAxisOccupancyITS", {14, 0, 14000}, ""}; + ConfigurableAxis thnConfigAxisOccupancyFT0C{"thnConfigAxisOccupancyFT0C", {14, 0, 140000}, ""}; + ConfigurableAxis thnConfigAxisNoSameBunchPileup{"thnConfigAxisNoSameBunchPileup", {2, 0, 2}, ""}; + ConfigurableAxis thnConfigAxisOccupancy{"thnConfigAxisOccupancy", {2, 0, 2}, ""}; + ConfigurableAxis thnConfigAxisNoCollInTimeRangeNarrow{"thnConfigAxisNoCollInTimeRangeNarrow", {2, 0, 2}, ""}; + ConfigurableAxis thnConfigAxisNoCollInTimeRangeStandard{"thnConfigAxisNoCollInTimeRangeStandard", {2, 0, 2}, ""}; + ConfigurableAxis thnConfigAxisNoCollInRofStandard{"thnConfigAxisNoCollInRofStandard", {2, 0, 2}, ""}; + ConfigurableAxis thnConfigAxisResoFT0cFV0a{"thnConfigAxisResoFT0cFV0a", {160, -8, 8}, ""}; + ConfigurableAxis thnConfigAxisResoFT0cTPCtot{"thnConfigAxisResoFT0cTPCtot", {160, -8, 8}, ""}; + ConfigurableAxis thnConfigAxisResoFV0aTPCtot{"thnConfigAxisResoFV0aTPCtot", {160, -8, 8}, ""}; HistogramRegistry registry{"registry", {}}; void init(InitContext&) { + if (storeResoOccu && occEstimator == 0) { + LOGP(fatal, "Occupancy estimation must be enabled to store resolution THnSparse! Please check your configuration!"); + } const AxisSpec thnAxisInvMass{thnConfigAxisInvMass, "Inv. mass (GeV/#it{c}^{2})"}; const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"}; const AxisSpec thnAxisCent{thnConfigAxisCent, "Centrality"}; const AxisSpec thnAxisCosNPhi{thnConfigAxisCosNPhi, Form("cos(%d#varphi)", harmonic.value)}; + const AxisSpec thnAxisSinNPhi{thnConfigAxisCosNPhi, Form("sin(%d#varphi)", harmonic.value)}; + const AxisSpec thnAxisPsi{thnConfigAxisPsi, Form("#Psi_{%d}", harmonic.value)}; const AxisSpec thnAxisCosDeltaPhi{thnConfigAxisCosDeltaPhi, Form("cos(%d(#varphi - #Psi_{sub}))", harmonic.value)}; const AxisSpec thnAxisScalarProd{thnConfigAxisScalarProd, "SP"}; const AxisSpec thnAxisMlOne{thnConfigAxisMlOne, "Bkg score"}; @@ -139,10 +208,14 @@ struct HfTaskFlowCharmHadrons { const AxisSpec thnAxisNoCollInTimeRangeNarrow{thnConfigAxisNoCollInTimeRangeNarrow, "NoCollInTimeRangeNarrow"}; const AxisSpec thnAxisNoCollInTimeRangeStandard{thnConfigAxisNoCollInTimeRangeStandard, "NoCollInTimeRangeStandard"}; const AxisSpec thnAxisNoCollInRofStandard{thnConfigAxisNoCollInRofStandard, "NoCollInRofStandard"}; + // TODO: currently only the Q vector of FT0c FV0a and TPCtot are considered + const AxisSpec thnAxisResoFT0cFV0a{thnConfigAxisResoFT0cFV0a, "Q_{FT0c} #bullet Q_{FV0a}"}; + const AxisSpec thnAxisResoFT0cTPCtot{thnConfigAxisResoFT0cTPCtot, "Q_{FT0c} #bullet Q_{TPCtot}"}; + const AxisSpec thnAxisResoFV0aTPCtot{thnConfigAxisResoFV0aTPCtot, "Q_{FV0a} #bullet Q_{TPCtot}"}; std::vector axes = {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisScalarProd}; if (storeEP) { - axes.insert(axes.end(), {thnAxisCosNPhi, thnAxisCosDeltaPhi}); + axes.insert(axes.end(), {thnAxisCosNPhi, thnAxisSinNPhi, thnAxisCosDeltaPhi}); } if (storeMl) { axes.insert(axes.end(), {thnAxisMlOne, thnAxisMlTwo}); @@ -162,6 +235,10 @@ struct HfTaskFlowCharmHadrons { registry.add("trackOccVsFT0COcc", "trackOccVsFT0COcc; trackOcc; FT0COcc", {HistType::kTH2F, {thnAxisOccupancyITS, thnAxisOccupancyFT0C}}); } + if (storeEpCosSin) { + registry.add("ep/hSparseEp", "THn for Event Plane distirbution", {HistType::kTHnSparseF, {thnAxisCent, thnAxisPsi, thnAxisCosNPhi, thnAxisSinNPhi}}); + } + if (doprocessResolution) { // enable resolution histograms only for resolution process registry.add("spReso/hSpResoFT0cFT0a", "hSpResoFT0cFT0a; centrality; Q_{FT0c} #bullet Q_{FT0a}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); registry.add("spReso/hSpResoFT0cFV0a", "hSpResoFT0cFV0a; centrality; Q_{FT0c} #bullet Q_{FV0a}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); @@ -201,6 +278,18 @@ struct HfTaskFlowCharmHadrons { registry.add("epReso/hEpResoTPCposTPCneg", "hEpResoTPCposTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); } + if (storeResoOccu) { + std::vector axesReso = {thnAxisCent, thnAxisResoFT0cFV0a, thnAxisResoFT0cTPCtot, thnAxisResoFV0aTPCtot}; + if (occEstimator == 1) { + axesReso.insert(axesReso.end(), {thnAxisOccupancyITS, thnAxisNoSameBunchPileup, thnAxisOccupancy, + thnAxisNoCollInTimeRangeNarrow, thnAxisNoCollInTimeRangeStandard, thnAxisNoCollInRofStandard}); + } else { + axesReso.insert(axesReso.end(), {thnAxisOccupancyFT0C, thnAxisNoSameBunchPileup, thnAxisOccupancy, + thnAxisNoCollInTimeRangeNarrow, thnAxisNoCollInTimeRangeStandard, thnAxisNoCollInRofStandard}); + } + registry.add("spReso/hSparseReso", "THn for resolution with occupancy", HistType::kTHnSparseF, axesReso); + } + hfEvSel.addHistograms(registry); // collision monitoring ccdb->setURL(ccdbUrl); ccdb->setCaching(true); @@ -208,6 +297,20 @@ struct HfTaskFlowCharmHadrons { } }; // end init + /// Fill the mass, pt and ML scores of a candidate + /// \param mass is the candidate mass + /// \param pt is the candidate transverse momentum + /// \param mlscore0 is the first ML score + /// \param mlscore1 is the second ML score + void fillMassPt(const float mass, const float pt, const float mlscore0, const float mlscore1) + { + rowCandidateMassPtMlScores( + mass, + pt, + mlscore0, + mlscore1); + } + /// Compute the Q vector for the candidate's tracks /// \param cand is the candidate /// \param tracksQx is the X component of the Q vector for the tracks @@ -244,6 +347,44 @@ struct HfTaskFlowCharmHadrons { } } + /// Compute the Q vector for the candidate's tracks + /// \param cand is the candidate + /// \param tracksQx is the X component of the Q vector for the tracks + /// \param tracksQy is the Y component of the Q vector for the tracks + /// \param channel is the decay channel + template + void getQvecXic0Tracks(const T1& cand, + std::vector& tracksQx, + std::vector& tracksQy, + float ampl) + { + // add possibility to consider different weights for the tracks, at the moment only pT is considered; + float pXTrack0 = cand.pxPosV0Dau(); + float pYTrack0 = cand.pyPosV0Dau(); + float pTTrack0 = std::hypot(pXTrack0, pYTrack0); + float phiTrack0 = std::atan2(pXTrack0, pYTrack0); + float pXTrack1 = cand.pxNegV0Dau(); + float pYTrack1 = cand.pyNegV0Dau(); + float pTTrack1 = std::hypot(pXTrack1, pYTrack1); + float phiTrack1 = std::atan2(pXTrack1, pYTrack1); + float pYTrack2 = cand.pxBachFromCasc(); + float pXTrack2 = cand.pyBachFromCasc(); + float pTTrack2 = std::hypot(pXTrack2, pYTrack2); + float phiTrack2 = std::atan2(pXTrack2, pYTrack2); + float pXTrack3 = cand.pxBachFromCharmBaryon(); + float pYTrack3 = cand.pyBachFromCharmBaryon(); + float pTTrack3 = std::hypot(pXTrack3, pYTrack3); + float phiTrack3 = std::atan2(pXTrack3, pYTrack3); + + tracksQx.push_back(std::cos(harmonic * phiTrack0) * pTTrack0 / ampl); + tracksQy.push_back(std::sin(harmonic * phiTrack0) * pTTrack0 / ampl); + tracksQx.push_back(std::cos(harmonic * phiTrack1) * pTTrack1 / ampl); + tracksQy.push_back(std::sin(harmonic * phiTrack1) * pTTrack1 / ampl); + tracksQx.push_back(std::cos(harmonic * phiTrack2) * pTTrack2 / ampl); + tracksQy.push_back(std::sin(harmonic * phiTrack2) * pTTrack2 / ampl); + tracksQx.push_back(std::cos(harmonic * phiTrack3) * pTTrack3 / ampl); + tracksQy.push_back(std::sin(harmonic * phiTrack3) * pTTrack3 / ampl); + } /// Compute the delta psi in the range [0, pi/harmonic] /// \param psi1 is the first angle /// \param psi2 is the second angle @@ -251,20 +392,28 @@ struct HfTaskFlowCharmHadrons { float getDeltaPsiInRange(float psi1, float psi2) { float deltaPsi = psi1 - psi2; - if (std::abs(deltaPsi) > constants::math::PI / harmonic) { - if (deltaPsi > 0.) - deltaPsi -= constants::math::TwoPI / harmonic; - else - deltaPsi += constants::math::TwoPI / harmonic; - } + deltaPsi = RecoDecay::constrainAngle(deltaPsi, -o2::constants::math::PI / harmonic, harmonic); return deltaPsi; } + /// Get the event selection flags + /// \param hfevselflag is the event selection flag + std::vector getEventSelectionFlags(uint32_t hfevselflag) + { + return { + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoSameBunchPileup), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::Occupancy), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeNarrow), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeStandard), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInRofStandard)}; + } + /// Fill THnSparse /// \param mass is the invariant mass of the candidate /// \param pt is the transverse momentum of the candidate /// \param cent is the centrality of the collision /// \param cosNPhi is the cosine of the n*phi angle + /// \param sinNPhi is the sine of the n*phi angle /// \param cosDeltaPhi is the cosine of the n*(phi - evtPl) angle /// \param sp is the scalar product /// \param outputMl are the ML scores @@ -274,56 +423,42 @@ struct HfTaskFlowCharmHadrons { float& pt, float& cent, float& cosNPhi, + float& sinNPhi, float& cosDeltaPhi, float& sp, std::vector& outputMl, float& occupancy, - uint16_t& hfevselflag) + uint32_t& hfevselflag) { if (occEstimator != 0) { + std::vector evtSelFlags = getEventSelectionFlags(hfevselflag); if (storeMl) { if (storeEP) { - registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, cosNPhi, cosDeltaPhi, outputMl[0], outputMl[1], occupancy, - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoSameBunchPileup), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::Occupancy), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeNarrow), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeStandard), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInRofStandard)); + registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, cosNPhi, sinNPhi, cosDeltaPhi, outputMl[0], outputMl[1], occupancy, + evtSelFlags[0], evtSelFlags[1], evtSelFlags[2], evtSelFlags[3], evtSelFlags[4]); } else { registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, outputMl[0], outputMl[1], occupancy, - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoSameBunchPileup), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::Occupancy), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeNarrow), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeStandard), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInRofStandard)); + evtSelFlags[0], evtSelFlags[1], evtSelFlags[2], evtSelFlags[3], evtSelFlags[4]); } } else { if (storeEP) { - registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, cosNPhi, cosDeltaPhi, occupancy, - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoSameBunchPileup), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::Occupancy), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeNarrow), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeStandard), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInRofStandard)); + registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, cosNPhi, sinNPhi, cosDeltaPhi, occupancy, + evtSelFlags[0], evtSelFlags[1], evtSelFlags[2], evtSelFlags[3], evtSelFlags[4]); } else { registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, occupancy, - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoSameBunchPileup), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::Occupancy), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeNarrow), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeStandard), - TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInRofStandard)); + evtSelFlags[0], evtSelFlags[1], evtSelFlags[2], evtSelFlags[3], evtSelFlags[4]); } } } else { if (storeMl) { if (storeEP) { - registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, cosNPhi, cosDeltaPhi, outputMl[0], outputMl[1]); + registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, cosNPhi, sinNPhi, cosDeltaPhi, outputMl[0], outputMl[1]); } else { registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, outputMl[0], outputMl[1]); } } else { if (storeEP) { - registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, cosNPhi, cosDeltaPhi); + registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, cosNPhi, sinNPhi, cosDeltaPhi); } else { registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp); } @@ -411,7 +546,7 @@ struct HfTaskFlowCharmHadrons { return; } float occupancy = 0.; - uint16_t hfevflag{}; + uint32_t hfevflag{}; if (occEstimator != 0) { occupancy = getOccupancyColl(collision, occEstimator); registry.fill(HIST("trackOccVsFT0COcc"), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); @@ -493,18 +628,55 @@ struct HfTaskFlowCharmHadrons { default: break; } + } else if constexpr (std::is_same_v || std::is_same_v) { + switch (channel) { + case DecayChannel::XicToPKPi: + massCand = hfHelper.invMassXicToPKPi(candidate); + if constexpr (std::is_same_v) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) + outputMl[iclass] = candidate.mlProbXicToPKPi()[classMl->at(iclass)]; + } + break; + case DecayChannel::XicToPiKP: + massCand = hfHelper.invMassXicToPiKP(candidate); + if constexpr (std::is_same_v) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) + outputMl[iclass] = candidate.mlProbXicToPiKP()[classMl->at(iclass)]; + } + break; + default: + break; + } + } else if constexpr (std::is_same_v || std::is_same_v) { + massCand = candidate.invMassCharmBaryon(); + if constexpr (std::is_same_v) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) + outputMl[iclass] = candidate.mlProbToXiPi()[classMl->at(iclass)]; + } } - float ptCand = candidate.pt(); - float phiCand = candidate.phi(); + float ptCand = 0.; + float phiCand = 0.; + + if constexpr (std::is_same_v || std::is_same_v) { + ptCand = RecoDecay::sqrtSumOfSquares(candidate.pxCharmBaryon(), candidate.pyCharmBaryon()); + phiCand = std::atan2(candidate.pxCharmBaryon(), candidate.pyCharmBaryon()); + } else { + ptCand = candidate.pt(); + phiCand = candidate.phi(); + } // If TPC is used for the SP estimation, the tracks of the hadron candidate must be removed from the TPC Q vector to avoid double counting if (qvecDetector == QvecEstimator::TPCNeg || qvecDetector == QvecEstimator::TPCPos) { float ampl = amplQVec - static_cast(nProngs); std::vector tracksQx = {}; std::vector tracksQy = {}; - - getQvecDtracks(candidate, tracksQx, tracksQy, ampl); + if constexpr (std::is_same_v || std::is_same_v) { + // std::cout<(candidate, tracksQx, tracksQy, ampl); + } for (auto iTrack{0u}; iTrack < tracksQx.size(); ++iTrack) { xQVec -= tracksQx[iTrack]; yQVec -= tracksQy[iTrack]; @@ -516,7 +688,17 @@ struct HfTaskFlowCharmHadrons { float scalprodCand = cosNPhi * xQVec + sinNPhi * yQVec; float cosDeltaPhi = std::cos(harmonic * (phiCand - evtPl)); - fillThn(massCand, ptCand, cent, cosNPhi, cosDeltaPhi, scalprodCand, outputMl, occupancy, hfevflag); + if (fillMassPtMlTree && storeMl) { + if (downSampleFactor < 1.) { + float pseudoRndm = ptCand * 1000. - static_cast(ptCand * 1000); + if (ptCand < ptDownSampleMax && pseudoRndm >= downSampleFactor) { + continue; + } + } + fillMassPt(massCand, ptCand, outputMl[0], outputMl[1]); + } else { + fillThn(massCand, ptCand, cent, cosNPhi, sinNPhi, cosDeltaPhi, scalprodCand, outputMl, occupancy, hfevflag); + } } } @@ -602,16 +784,51 @@ struct HfTaskFlowCharmHadrons { } PROCESS_SWITCH(HfTaskFlowCharmHadrons, processLc, "Process Lc candidates", false); + // Xic with ML + void processXicMl(CollsWithQvecs::iterator const& collision, + CandXicDataWMl const&) + { + auto candsXicToPKPiWMl = selectedXicToPKPiWMl->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + auto candsXicToPiKPWMl = selectedXicToPiKPWMl->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + runFlowAnalysis(collision, candsXicToPKPiWMl); + runFlowAnalysis(collision, candsXicToPiKPWMl); + } + PROCESS_SWITCH(HfTaskFlowCharmHadrons, processXicMl, "Process Xic candidates with ML", false); + + // Xic with rectangular cuts + void processXic(CollsWithQvecs::iterator const& collision, + CandXicData const&) + { + auto candsXicToPKPi = selectedXicToPKPi->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + auto candsXicToPiKP = selectedXicToPiKP->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + runFlowAnalysis(collision, candsXicToPKPi); + runFlowAnalysis(collision, candsXicToPiKP); + } + PROCESS_SWITCH(HfTaskFlowCharmHadrons, processXic, "Process Xic candidates", false); + + // Xic0 with ML + void processXic0Ml(CollsWithQvecs::iterator const& collision, + CandXic0DataWMl const&) + { + auto candsXic0WMl = selectedXic0WMl->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + runFlowAnalysis(collision, candsXic0WMl); + } + PROCESS_SWITCH(HfTaskFlowCharmHadrons, processXic0Ml, "Process Xic0 candidates with ML", false); + + // Xic0 + void processXic0(CollsWithQvecs::iterator const& collision, + CandXic0Data const&) + { + auto candsXic0 = selectedXic0->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + runFlowAnalysis(collision, candsXic0); + } + PROCESS_SWITCH(HfTaskFlowCharmHadrons, processXic0, "Process Xic0 candidates", false); + // Resolution void processResolution(CollsWithQvecs::iterator const& collision, aod::BCsWithTimestamps const& bcs) { float centrality{-1.f}; - if (!isCollSelected(collision, bcs, centrality)) { - // no selection on the centrality is applied on purpose to allow for the resolution study in post-processing - return; - } - float xQVecFT0a = collision.qvecFT0ARe(); float yQVecFT0a = collision.qvecFT0AIm(); float xQVecFT0c = collision.qvecFT0CRe(); @@ -627,6 +844,24 @@ struct HfTaskFlowCharmHadrons { float xQVecBTot = collision.qvecBTotRe(); float yQVecBTot = collision.qvecBTotIm(); + centrality = o2::hf_centrality::getCentralityColl(collision, o2::hf_centrality::CentralityEstimator::FT0C); + if (storeResoOccu) { + float occupancy{-1.f}; + occupancy = getOccupancyColl(collision, occEstimator); + registry.fill(HIST("trackOccVsFT0COcc"), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); + uint32_t hfevflag = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + std::vector evtSelFlags = getEventSelectionFlags(hfevflag); + registry.fill(HIST("spReso/hSparseReso"), centrality, xQVecFT0c * xQVecFV0a + yQVecFT0c * yQVecFV0a, + xQVecFT0c * xQVecBTot + yQVecFT0c * yQVecBTot, + xQVecFV0a * xQVecBTot + yQVecFV0a * yQVecBTot, + occupancy, evtSelFlags[0], evtSelFlags[1], evtSelFlags[2], evtSelFlags[3], evtSelFlags[4]); + } + + if (!isCollSelected(collision, bcs, centrality)) { + // no selection on the centrality is applied, but on event selection flags + return; + } + registry.fill(HIST("spReso/hSpResoFT0cFT0a"), centrality, xQVecFT0c * xQVecFT0a + yQVecFT0c * yQVecFT0a); registry.fill(HIST("spReso/hSpResoFT0cFV0a"), centrality, xQVecFT0c * xQVecFV0a + yQVecFT0c * yQVecFV0a); registry.fill(HIST("spReso/hSpResoFT0cTPCpos"), centrality, xQVecFT0c * xQVecBPos + yQVecFT0c * yQVecBPos); @@ -672,6 +907,13 @@ struct HfTaskFlowCharmHadrons { registry.fill(HIST("epReso/hEpResoFV0aTPCtot"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFV0a, epBTots))); registry.fill(HIST("epReso/hEpResoTPCposTPCneg"), centrality, std::cos(harmonic * getDeltaPsiInRange(epBPoss, epBNegs))); } + + if (storeEpCosSin) { + registry.fill(HIST("ep/hSparseEp"), centrality, + epHelper.GetEventPlane(xQVecFT0c, yQVecFT0c, harmonic), + std::cos(harmonic * epHelper.GetEventPlane(xQVecFT0c, yQVecFT0c, harmonic)), + std::sin(harmonic * epHelper.GetEventPlane(xQVecFT0c, yQVecFT0c, harmonic))); + } } PROCESS_SWITCH(HfTaskFlowCharmHadrons, processResolution, "Process resolution", false); diff --git a/PWGHF/D2H/Tasks/taskLb.cxx b/PWGHF/D2H/Tasks/taskLb.cxx index 025c525b35c..3272db196b3 100644 --- a/PWGHF/D2H/Tasks/taskLb.cxx +++ b/PWGHF/D2H/Tasks/taskLb.cxx @@ -15,32 +15,51 @@ /// \author Panos Christakoglou , Nikhef /// \author Martin Voelkl , University of Birmingham -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include "Common/DataModel/Centrality.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; - -#include "Framework/runDataProcessing.h" +using namespace o2::hf_decay::hf_cand_beauty; /// Λb0 analysis task struct HfTaskLb { Configurable selectionFlagLb{"selectionFlagLb", 0, "Selection Flag for Lb"}; Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; - Configurable DCALengthParameter{"DCALengthParameter", 0.02, "decay length for DCA"}; + Configurable lengthDCAParameter{"lengthDCAParameter", 0.02, "decay length for DCA"}; Configurable minLikelihoodRatio{"minLikelihoodRatio", 10., "min. likelihood ratio for combined DCAs"}; Configurable minLikelihoodRatioLc{"minLikelihoodRatioLc", 10., "min. likelihood ratio for Lc cross check"}; Configurable mDiffKStar892Max{"mDiffKStar892Max", 0.0473, "Accepted range around KStar mass peak"}; @@ -55,24 +74,24 @@ struct HfTaskLb { HfHelper hfHelper; Service pdg; - Filter filterSelectCandidates = (aod::hf_sel_candidate_lb::isSelLbToLcPi >= selectionFlagLb); - using TracksWExt = soa::Join; using TracksWExtMc = soa::Join; - PresliceUnsorted McPartID = aod::mctracklabel::mcParticleId; + Filter filterSelectCandidates = (aod::hf_sel_candidate_lb::isSelLbToLcPi >= selectionFlagLb); + + PresliceUnsorted mcPartID = aod::mctracklabel::mcParticleId; bool passesImpactParameterResolution(float pT, float d0Resolution) { - float expectedResolution(0.001 + 0.0052 * exp(-0.655 * pT)); + float expectedResolution(0.001 + 0.0052 * std::exp(-0.655 * pT)); return (d0Resolution <= expectedResolution * 1.5); } // Compares to pT dependent cut on impact parameter resolution - float logLikelihoodRatioSingleTrackDCA(float DCA, float reso, float lengthParameter) + float logLikelihoodRatioSingleTrackDCA(float dca, float reso, float lengthParameter) { reso *= resoCorrectionFactor; // In case real resolution is worse - float numerator = 1. / lengthParameter * std::exp(-DCA / lengthParameter); - float denominator = (1. - largeLifetimeBG) * TMath::Gaus(DCA, 0., reso, true) + largeLifetimeBG / 0.2; // flat distribution to 2 mm + float numerator = 1. / lengthParameter * std::exp(-dca / lengthParameter); + float denominator = (1. - largeLifetimeBG) * TMath::Gaus(dca, 0., reso, true) + largeLifetimeBG / 0.2; // flat distribution to 2 mm return std::log(numerator / denominator); } // Creates the single track log likelihood assuming an exonential law for the secondaries @@ -170,6 +189,8 @@ struct HfTaskLb { { float massKStar892 = 0.892; float massDelta1232 = 1.232; + std::array dca = {0.f, 0.f, 0.f}; + std::array dcaResolution = {0.f, 0.f, 0.f}; for (const auto& candidateLc : candidatesLc) { if (!candidateLc.isSelLcToPKPi() && !candidateLc.isSelLcToPiKP()) @@ -192,12 +213,26 @@ struct HfTaskLb { continue; if (!passesImpactParameterResolution(track2.pt(), reso2)) continue; - float DCA0 = candidateLc.impactParameter0(); - float DCA1 = candidateLc.impactParameter1(); - float DCA2 = candidateLc.impactParameter2(); - if (DCA0 > maximumImpactParameterForLambdaCCrossChecks || DCA1 > maximumImpactParameterForLambdaCCrossChecks || DCA2 > maximumImpactParameterForLambdaCCrossChecks) + + dca = { + candidateLc.impactParameter0(), + candidateLc.impactParameter1(), + candidateLc.impactParameter2()}; + + bool exceedsMaxDca = std::any_of(dca.begin(), dca.end(), [&](float val) { + return val > maximumImpactParameterForLambdaCCrossChecks; + }); + + if (exceedsMaxDca) { continue; - float likelihoodRatio = logLikelihoodRatioSingleTrackDCA(DCA0, reso0, DCALengthParameter) + logLikelihoodRatioSingleTrackDCA(DCA1, reso1, DCALengthParameter) + logLikelihoodRatioSingleTrackDCA(DCA2, reso2, DCALengthParameter); + } + dcaResolution = {reso0, reso1, reso2}; + + float likelihoodRatio = 0.0f; + for (size_t i = 0; i < dca.size(); ++i) { + likelihoodRatio += logLikelihoodRatioSingleTrackDCA(dca[i], dcaResolution[i], lengthDCAParameter); + } + registry.get(HIST("hPtlogLikelihood"))->Fill(candidateLc.pt(), likelihoodRatio); if (likelihoodRatio < minLikelihoodRatioLc) continue; @@ -253,24 +288,31 @@ struct HfTaskLb { } // Lambda_c candidates loop for cross checks for (const auto& candidate : candidates) { - if (!(candidate.hfflag() & 1 << hf_cand_lb::DecayType::LbToLcPi)) { // This should never be true as the loop is over Lb candidates - continue; - } + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { continue; } registry.get(HIST("hZVertex"))->Fill(collision.posZ()); auto candLc = candidate.prong0_as>(); - float d0resolution0 = candLc.errorImpactParameter0(); - float d0resolution1 = candLc.errorImpactParameter1(); - float d0resolution2 = candLc.errorImpactParameter2(); - float DCA0 = candLc.impactParameter0(); - float DCA1 = candLc.impactParameter1(); - float DCA2 = candLc.impactParameter2(); - float likelihoodRatio = logLikelihoodRatioSingleTrackDCA(DCA0, d0resolution0, DCALengthParameter) + logLikelihoodRatioSingleTrackDCA(DCA1, d0resolution1, DCALengthParameter) + logLikelihoodRatioSingleTrackDCA(DCA2, d0resolution2, DCALengthParameter); - if (likelihoodRatio < minLikelihoodRatio) + dca = { + candLc.impactParameter0(), + candLc.impactParameter1(), + candLc.impactParameter2()}; + + dcaResolution = { + candLc.errorImpactParameter0(), + candLc.errorImpactParameter1(), + candLc.errorImpactParameter2()}; + + float likelihoodRatio = 0.0f; + for (size_t i = 0; i < dca.size(); ++i) { + likelihoodRatio += logLikelihoodRatioSingleTrackDCA(dca[i], dcaResolution[i], lengthDCAParameter); + } + + if (likelihoodRatio < minLikelihoodRatio) { continue; // Larger likelihood means more likely to be signal + } float lbMass = hfHelper.invMassLbToLcPi(candidate); registry.get(HIST("hPtinvMassLb"))->Fill(candidate.pt(), lbMass); @@ -302,15 +344,14 @@ struct HfTaskLb { { // MC rec for (const auto& candidate : candidates) { - if (!(candidate.hfflag() & 1 << hf_cand_lb::DecayType::LbToLcPi)) { - continue; - } + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { continue; } - auto candLc = candidate.prong0_as(); + auto candLc = candidate.prong0_as>(); + auto flagMcMatchRecLb = std::abs(candidate.flagMcMatchRec()); - if (std::abs(candidate.flagMcMatchRec()) == 1 << hf_cand_lb::DecayType::LbToLcPi) { + if (flagMcMatchRecLb == DecayChannelMain::LbToLcPi) { auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong1_as().mcParticle_as>(), o2::constants::physics::Pdg::kLambdaB0, true); auto particleMother = mcParticles.rawIteratorAt(indexMother); @@ -357,7 +398,7 @@ struct HfTaskLb { // MC gen. level for (const auto& particle : mcParticles) { - if (std::abs(particle.flagMcMatchGen()) == 1 << hf_cand_lb::DecayType::LbToLcPi) { + if (std::abs(particle.flagMcMatchGen()) == DecayChannelMain::LbToLcPi) { auto yParticle = RecoDecay::y(particle.pVector(), o2::constants::physics::MassLambdaB0); if (yCandGenMax >= 0. && std::abs(yParticle) > yCandGenMax) { diff --git a/PWGHF/D2H/Tasks/taskLbReduced.cxx b/PWGHF/D2H/Tasks/taskLbReduced.cxx new file mode 100644 index 00000000000..f756d9abc62 --- /dev/null +++ b/PWGHF/D2H/Tasks/taskLbReduced.cxx @@ -0,0 +1,842 @@ +// 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. + +/// \file taskLbReduced.cxx +/// \brief Lb → Lc+ π- → (pK- π+) π- analysis task +/// +/// \author Biao Zhang , Heidelberg University + +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::analysis; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace hf_cand_lb_lite +{ +DECLARE_SOA_COLUMN(PtLc, ptLc, float); //! Transverse momentum of Lc-baryon daughter candidate (GeV/c) +DECLARE_SOA_COLUMN(PtBach, ptBach, float); //! Transverse momentum of bachelor pion (GeV/c) +DECLARE_SOA_COLUMN(AbsEtaBach, absEtaBach, float); //! Absolute pseudorapidity of bachelor pion +DECLARE_SOA_COLUMN(ItsNClsBach, itsNClsBach, int); //! Number of ITS clusters of bachelor pion +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsBach, tpcNClsCrossedRowsBach, int); //! Number of TPC crossed rows of prongs of bachelor pion +DECLARE_SOA_COLUMN(TpcChi2NClBach, tpcChi2NClBach, float); //! Maximum TPC chi2 of prongs of Lc-baryon daughter candidate +DECLARE_SOA_COLUMN(PtLcProngMin, ptLcProngMin, float); //! Minimum pT of prongs of Lc-baryon daughter candidate (GeV/c) +DECLARE_SOA_COLUMN(EtaLcProngMin, etaLcProngMin, float); //! Minimum absolute pseudorapidity of prongs of Lc-baryon daughter candidate +DECLARE_SOA_COLUMN(ItsNClsLcProngMin, itsNClsLcProngMin, int); //! Minimum number of ITS clusters of prongs of Lc-baryon daughter candidate +DECLARE_SOA_COLUMN(TpcNClsCrossedRowsLcProngMin, tpcNClsCrossedRowsLcProngMin, int); //! Minimum number of TPC crossed rows of prongs of Lc-baryon daughter candidate +DECLARE_SOA_COLUMN(TpcChi2NClLcProngMax, tpcChi2NClLcProngMax, float); //! Maximum TPC chi2 of prongs of Lc-baryon daughter candidate +DECLARE_SOA_COLUMN(MLc, mLc, float); //! Invariant mass of Lc-baryon daughter candidates (GeV/c) +DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate (GeV/c2) +DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(PtGen, ptGen, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(P, p, float); //! Momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(Y, y, float); //! Rapidity of candidate +DECLARE_SOA_COLUMN(Eta, eta, float); //! Pseudorapidity of candidate +DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuth angle of candidate +DECLARE_SOA_COLUMN(E, e, float); //! Energy of candidate (GeV) +DECLARE_SOA_COLUMN(NSigTpcPiBachelor, nSigTpcPiBachelor, float); //! TPC Nsigma separation for bachelor with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTofPiBachelor, nSigTofPiBachelor, float); //! TOF Nsigma separation for bachelor with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofPiBachelor, nSigTpcTofPiBachelor, float); //! Combined TPC and TOF Nsigma separation for bachelor with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcPrLcProng0, nSigTpcPrLcProng0, float); //! TPC Nsigma separation for Lc-baryon prong0 with proton mass hypothesis +DECLARE_SOA_COLUMN(NSigTofPrLcProng0, nSigTofPrLcProng0, float); //! TOF Nsigma separation for Lc-baryon prong0 with proton mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofPrLcProng0, nSigTpcTofPrLcProng0, float); //! Combined TPC and TOF Nsigma separation for Lc-baryon prong0 with proton mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcKaLcProng1, nSigTpcKaLcProng1, float); //! TPC Nsigma separation for Lc-baryon prong1 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTofKaLcProng1, nSigTofKaLcProng1, float); //! TOF Nsigma separation for Lc-baryon prong1 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofKaLcProng1, nSigTpcTofKaLcProng1, float); //! Combined TPC and TOF Nsigma separation for Lc-baryon prong1 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcPiLcProng2, nSigTpcPiLcProng2, float); //! TPC Nsigma separation for Lc-baryon prong2 with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTofPiLcProng2, nSigTofPiLcProng2, float); //! TOF Nsigma separation for Lc-baryon prong2 with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofPiLcProng2, nSigTpcTofPiLcProng2, float); //! Combined TPC and TOF Nsigma separation for Lc-baryon prong0 with pion mass hypothesis +DECLARE_SOA_COLUMN(DecayLength, decayLength, float); //! Decay length of candidate (cm) +DECLARE_SOA_COLUMN(DecayLengthXY, decayLengthXY, float); //! Transverse decay length of candidate (cm) +DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float); //! Normalised decay length of candidate +DECLARE_SOA_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, float); //! Normalised transverse decay length of candidate +DECLARE_SOA_COLUMN(DecayLengthLc, decayLengthLc, float); //! Decay length of Lc-baryon daughter candidate (cm) +DECLARE_SOA_COLUMN(DecayLengthXYLc, decayLengthXYLc, float); //! Transverse decay length of Lc-baryon daughter candidate (cm) +DECLARE_SOA_COLUMN(ImpactParameterLc, impactParameterLc, float); //! Impact parameter product of Lc-baryon daughter candidate +DECLARE_SOA_COLUMN(ImpactParameterBach, impactParameterBach, float); //! Impact parameter product of bachelor pion +DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float); //! Impact parameter product of daughters +DECLARE_SOA_COLUMN(Cpa, cpa, float); //! Cosine pointing angle of candidate +DECLARE_SOA_COLUMN(CpaXY, cpaXY, float); //! Cosine pointing angle of candidate in transverse plane +DECLARE_SOA_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float); //! Maximum normalized difference between measured and expected impact parameter of candidate prongs +DECLARE_SOA_COLUMN(MlScoreSig, mlScoreSig, float); //! ML score for signal class +DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); //! Flag for association with wrong collision +} // namespace hf_cand_lb_lite + +DECLARE_SOA_TABLE(HfRedCandLbLites, "AOD", "HFREDCANDLBLITE", //! Table with some Lb properties + // B meson features hf_cand_lb_lite::M, + hf_cand_lb_lite::M, + hf_cand_lb_lite::Pt, + hf_cand_lb_lite::Eta, + hf_cand_lb_lite::Phi, + hf_cand_lb_lite::Y, + hf_cand_lb_lite::Cpa, + hf_cand_lb_lite::CpaXY, + hf_cand::Chi2PCA, + hf_cand_lb_lite::DecayLength, + hf_cand_lb_lite::DecayLengthXY, + hf_cand_lb_lite::DecayLengthNormalised, + hf_cand_lb_lite::DecayLengthXYNormalised, + hf_cand_lb_lite::ImpactParameterProduct, + hf_cand_lb_lite::MaxNormalisedDeltaIP, + hf_cand_lb_lite::MlScoreSig, + hf_sel_candidate_lb::IsSelLbToLcPi, + // Lc baryon features + hf_cand_lb_lite::MLc, + hf_cand_lb_lite::PtLc, + hf_cand_lb_lite::DecayLengthLc, + hf_cand_lb_lite::DecayLengthXYLc, + hf_cand_lb_lite::ImpactParameterLc, + hf_cand_lb_lite::PtLcProngMin, + hf_cand_lb_lite::EtaLcProngMin, + hf_cand_lb_lite::ItsNClsLcProngMin, + hf_cand_lb_lite::TpcNClsCrossedRowsLcProngMin, + hf_cand_lb_lite::TpcChi2NClLcProngMax, + hf_cand_lb_lite::NSigTpcPrLcProng0, + hf_cand_lb_lite::NSigTofPrLcProng0, + hf_cand_lb_lite::NSigTpcTofPrLcProng0, + hf_cand_lb_lite::NSigTpcKaLcProng1, + hf_cand_lb_lite::NSigTofKaLcProng1, + hf_cand_lb_lite::NSigTpcTofKaLcProng1, + hf_cand_lb_lite::NSigTpcPiLcProng2, + hf_cand_lb_lite::NSigTofPiLcProng2, + hf_cand_lb_lite::NSigTpcTofPiLcProng2, + hf_cand_lb_reduced::Prong0MlScoreBkg, + hf_cand_lb_reduced::Prong0MlScorePrompt, + hf_cand_lb_reduced::Prong0MlScoreNonprompt, + // pion features + hf_cand_lb_lite::PtBach, + hf_cand_lb_lite::AbsEtaBach, + hf_cand_lb_lite::ItsNClsBach, + hf_cand_lb_lite::TpcNClsCrossedRowsBach, + hf_cand_lb_lite::TpcChi2NClBach, + hf_cand_lb_lite::ImpactParameterBach, + hf_cand_lb_lite::NSigTpcPiBachelor, + hf_cand_lb_lite::NSigTofPiBachelor, + hf_cand_lb_lite::NSigTpcTofPiBachelor, + // MC truth + hf_cand_3prong::FlagMcMatchRec, + hf_cand_3prong::OriginMcRec, + hf_cand_lb_lite::FlagWrongCollision, + hf_cand_lb_lite::PtGen); + +DECLARE_SOA_TABLE(HfRedLbMcCheck, "AOD", "HFREDLBMCCHECK", //! Table with MC decay type check + hf_cand_3prong::FlagMcMatchRec, + hf_cand_lb_lite::FlagWrongCollision, + hf_cand_lb_lite::MLc, + hf_cand_lb_lite::PtLc, + hf_cand_lb_lite::M, + hf_cand_lb_lite::Pt, + hf_cand_lb_lite::MlScoreSig, + hf_lb_mc::PdgCodeBeautyMother, + hf_lb_mc::PdgCodeCharmMother, + hf_lb_mc::PdgCodeProng0, + hf_lb_mc::PdgCodeProng1, + hf_lb_mc::PdgCodeProng2, + hf_lb_mc::PdgCodeProng3); +} // namespace o2::aod + +/// Lb analysis task +struct HfTaskLbReduced { + Produces hfRedCandLbLite; + Produces hfRedLbMcCheck; + + Configurable selectionFlagLb{"selectionFlagLb", 1, "Selection Flag for Lb"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "max. track pseudo-rapidity for acceptance calculation"}; + Configurable ptTrackMin{"ptTrackMin", 0.1, "min. track transverse momentum for acceptance calculation"}; + Configurable fillHistograms{"fillHistograms", true, "Flag to enable histogram filling"}; + Configurable fillSparses{"fillSparses", false, "Flag to enable sparse filling"}; + Configurable fillTree{"fillTree", false, "Flag to enable tree filling"}; + Configurable fillBackground{"fillBackground", false, "Flag to enable filling of background histograms/sparses/tree (only MC)"}; + Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + + HfHelper hfHelper; + + using TracksPion = soa::Join; + using CandsLc = soa::Join; + Filter filterSelectCandidates = (aod::hf_sel_candidate_lb::isSelLbToLcPi >= selectionFlagLb); + HistogramRegistry registry{"registry"}; + + void init(InitContext&) + { + std::array processFuncData{doprocessData, doprocessDataWithLcMl, doprocessDataWithLbMl}; + if ((std::accumulate(processFuncData.begin(), processFuncData.end(), 0)) > 1) { + LOGP(fatal, "Only one process function for data can be enabled at a time."); + } + std::array processFuncMc{doprocessMc, doprocessMcWithDecayTypeCheck, doprocessMcWithLcMl, doprocessMcWithLcMlAndDecayTypeCheck, doprocessMcWithLbMl, doprocessMcWithLbMlAndDecayTypeCheck}; + if ((std::accumulate(processFuncMc.begin(), processFuncMc.end(), 0)) > 1) { + LOGP(fatal, "Only one process function for MC can be enabled at a time."); + } + + const AxisSpec axisMlScore{100, 0.f, 1.f}; + const AxisSpec axisMassLb{300, 4.5f, 6.0f}; + const AxisSpec axisMassLc{300, 2.15f, 2.45f}; + const AxisSpec axisDecayLength{200, 0.f, 0.4f}; + const AxisSpec axisNormDecayLength{100, 0.f, 50.f}; + const AxisSpec axisDca{100, -0.05f, 0.05f}; + const AxisSpec axisCosp{110, 0.f, 1.1f}; + const AxisSpec axisEta{30, -1.5f, 1.5f}; + const AxisSpec axisError{100, 0.f, 1.f}; + const AxisSpec axisImpParProd{100, -1.e-3, 1.e-3}; + const AxisSpec axisPtLb{100, 0.f, 50.f}; + const AxisSpec axisPtLc{100, 0.f, 50.f}; + const AxisSpec axisPtPi{100, 0.f, 10.f}; + + if (doprocessData || doprocessDataWithLcMl || doprocessDataWithLbMl) { + if (fillHistograms) { + registry.add("hMass", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{M} (D#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtLb, axisMassLb}}); + registry.add("hDecLength", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtLb, axisDecayLength}}); + registry.add("hDecLengthXy", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});decay length XY (cm);entries", {HistType::kTH2F, {axisPtLb, axisDecayLength}}); + registry.add("hNormDecLengthXy", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate norm. decay length XY (cm);entries", {HistType::kTH2F, {axisPtLb, axisNormDecayLength}}); + registry.add("hDcaProng0", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});prong 0 (#Lambda_{c}^{+}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtLb, axisDca}}); + registry.add("hDcaProng1", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});prong 1 (#pi^{#plus}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtLb, axisDca}}); + registry.add("hPtProng0", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtLb, axisPtLc}}); + registry.add("hPtProng1", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{p}_{T}(#pi^{#plus}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtLb, axisPtPi}}); + registry.add("hCosp", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtLb, axisCosp}}); + registry.add("hCospXy", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtLb, axisCosp}}); + registry.add("hEta", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate #it{#eta};entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hRapidity", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate #it{y};entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hImpParProd", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate impact parameter product;entries", {HistType::kTH2F, {axisPtLb, axisImpParProd}}); + registry.add("hinvMassLc", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #it{M}(pK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtLc, axisMassLc}}); + registry.add("hDecLengthLc", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtLc, axisDecayLength}}); + registry.add("hDecLengthXyLc", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});decay length XY (cm);entries", {HistType::kTH2F, {axisPtLc, axisDecayLength}}); + registry.add("hCospLc", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtLc, axisCosp}}); + registry.add("hCospXyLc", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtLc, axisCosp}}); + + // ML scores of Lc daughter + if (doprocessDataWithLcMl) { + registry.add("hMlScoreBkgLc", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #Lambda_{c}^{+} ML background score;entries", {HistType::kTH2F, {axisPtLc, axisMlScore}}); + registry.add("hMlScorePromptLc", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #Lambda_{c}^{+} ML prompt score;entries", {HistType::kTH2F, {axisPtLc, axisMlScore}}); + registry.add("hMlScoreNonPromptLc", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #Lambda_{c}^{+} ML nonprompt score;entries", {HistType::kTH2F, {axisPtLc, axisMlScore}}); + } + + // ML scores of Lb candidate + if (doprocessDataWithLbMl) { + registry.add("hMlScoreSigLb", "#Lambda_{b}^{0} candidates;#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});prong0, #Lambda_{b}^{0} ML signal score;entries", {HistType::kTH2F, {axisPtLb, axisMlScore}}); + } + } + if (fillSparses) { + if (!(doprocessDataWithLcMl || doprocessDataWithLbMl)) { + registry.add("hMassPtCutVars", "#Lambda_{b}^{0} candidates;#it{M} (D#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate decay length (cm);#Lambda_{b}^{0} candidate norm. decay length XY (cm);#Lambda_{b}^{0} candidate impact parameter product (cm);#Lambda_{b}^{0} candidate cos(#vartheta_{P});#it{M} (pK#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate decay length (cm);#Lambda_{c}^{+} candidate cos(#vartheta_{P})", {HistType::kTHnSparseF, {axisMassLb, axisPtLb, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassLc, axisPtLc, axisDecayLength, axisCosp}}); + } else { + registry.add("hMassPtCutVars", "#Lambda_{b}^{0} candidates;#it{M} (D#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate decay length (cm);#Lambda_{b}^{0} candidate norm. decay length XY (cm);#Lambda_{b}^{0} candidate impact parameter product (cm);#Lambda_{b}^{0} candidate cos(#vartheta_{P});#it{M} (pK#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate ML score bkg;#Lambda_{c}^{+} candidate ML score nonprompt", {HistType::kTHnSparseF, {axisMassLb, axisPtLb, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassLc, axisPtLc, axisMlScore, axisMlScore}}); + } + } + } + + if (doprocessMc || doprocessMcWithDecayTypeCheck || doprocessMcWithLcMl || doprocessMcWithLcMlAndDecayTypeCheck || doprocessMcWithLbMl || doprocessMcWithLbMlAndDecayTypeCheck) { + if (fillHistograms) { + // gen histos + registry.add("hEtaGen", "#Lambda_{b}^{0} particles (generated);#it{p}_{T}^{gen}(#Lambda_{b}^{0}) (GeV/#it{c});#it{#eta}^{gen}(#Lambda_{b}^{0});entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hYGen", "#Lambda_{b}^{0} particles (generated);#it{p}_{T}^{gen}(#Lambda_{b}^{0}) (GeV/#it{c});#it{y}^{gen}(#Lambda_{b}^{0});entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hYGenWithProngsInAcceptance", "MC particles (generated-daughters in acceptance);#it{p}_{T}^{gen}(#Lambda_{b}^{0}) (GeV/#it{c});#it{y}^{gen}(#Lambda_{b}^{0});entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hPtProng0Gen", "#Lambda_{b}^{0} particles (generated);#it{p}_{T}^{gen}(#Lambda_{b}^{0}) (GeV/#it{c});#it{p}_{T}^{gen}(#Lambda_{c}^{+}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtLb, axisPtLc}}); + registry.add("hPtProng1Gen", "#Lambda_{b}^{0} particles (generated);#it{p}_{T}^{gen}(#Lambda_{b}^{0}) (GeV/#it{c});#it{p}_{T}^{gen}(#pi^{#plus}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtLb, axisPtPi}}); + registry.add("hYProng0Gen", "#Lambda_{b}^{0} particles (generated);#it{p}_{T}^{gen}(#Lambda_{b}^{0}) (GeV/#it{c});#it{y}^{gen}(#Lambda_{c}^{+});entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hYProng1Gen", "#Lambda_{b}^{0} particles (generated);#it{p}_{T}^{gen}(#Lambda_{b}^{0}) (GeV/#it{c});#it{y}^{gen}(#pi^{#plus});entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hEtaProng0Gen", "#Lambda_{b}^{0} particles (generated);#it{p}_{T}^{gen}(#Lambda_{b}^{0}) (GeV/#it{c});#it{#eta}^{gen}(#Lambda_{c}^{+});entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hEtaProng1Gen", "#Lambda_{b}^{0} particles (generated);#it{p}_{T}^{gen}(#Lambda_{b}^{0}) (GeV/#it{c});#it{#eta}^{gen}(#pi^{#plus});entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + + // reco histos + // signal + registry.add("hMassRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{M} (D#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtLb, axisMassLb}}); + registry.add("hDecLengthRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtLb, axisDecayLength}}); + registry.add("hDecLengthXyRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});decay length XY (cm);entries", {HistType::kTH2F, {axisPtLb, axisDecayLength}}); + registry.add("hNormDecLengthXyRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate norm. decay length XY (cm);entries", {HistType::kTH2F, {axisPtLb, axisNormDecayLength}}); + registry.add("hDcaProng0RecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});prong 0 (#Lambda_{c}^{+}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtLb, axisDca}}); + registry.add("hDcaProng1RecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});prong 1 (#pi^{#plus}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtLb, axisDca}}); + registry.add("hPtProng0RecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtLb, axisPtLc}}); + registry.add("hPtProng1RecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{p}_{T}(#pi^{#plus}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtLb, axisPtPi}}); + registry.add("hCospRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtLb, axisCosp}}); + registry.add("hCospXyRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtLb, axisCosp}}); + registry.add("hEtaRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate #it{#eta};entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hRapidityRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate #it{y};entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hImpParProdRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate impact parameter product;entries", {HistType::kTH2F, {axisPtLb, axisImpParProd}}); + registry.add("hinvMassLcRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #it{M}(pK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtLc, axisMassLc}}); + registry.add("hDecLengthLcRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtLc, axisDecayLength}}); + registry.add("hDecLengthXyLcRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});decay length XY (cm);entries", {HistType::kTH2F, {axisPtLc, axisDecayLength}}); + registry.add("hCospLcRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtLc, axisCosp}}); + registry.add("hCospXyLcRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtLc, axisCosp}}); + // background + if (fillBackground) { + registry.add("hMassRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{M} (D#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtLb, axisMassLb}}); + registry.add("hDecLengthRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtLb, axisDecayLength}}); + registry.add("hDecLengthXyRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});decay length XY (cm);entries", {HistType::kTH2F, {axisPtLb, axisDecayLength}}); + registry.add("hNormDecLengthXyRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate norm. decay length XY (cm);entries", {HistType::kTH2F, {axisPtLb, axisNormDecayLength}}); + registry.add("hDcaProng0RecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});prong 0 (#Lambda_{c}^{+}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtLb, axisDca}}); + registry.add("hDcaProng1RecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});prong 1 (#pi^{#plus}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtLb, axisDca}}); + registry.add("hPtProng0RecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtLb, axisPtLc}}); + registry.add("hPtProng1RecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{p}_{T}(#pi^{#plus}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtLb, axisPtPi}}); + registry.add("hCospRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtLb, axisCosp}}); + registry.add("hCospXyRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtLb, axisCosp}}); + registry.add("hEtaRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate #it{#eta};entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hRapidityRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate #it{y};entries", {HistType::kTH2F, {axisPtLb, axisEta}}); + registry.add("hImpParProdRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate impact parameter product;entries", {HistType::kTH2F, {axisPtLb, axisImpParProd}}); + registry.add("hinvMassLcRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #it{M}(pK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtLc, axisMassLc}}); + registry.add("hDecLengthLcRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtLc, axisDecayLength}}); + registry.add("hDecLengthXyLcRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});decay length XY (cm);entries", {HistType::kTH2F, {axisPtLc, axisDecayLength}}); + registry.add("hCospLcRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtLc, axisCosp}}); + registry.add("hCospXyLcRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtLc, axisCosp}}); + } + // MC checks + if (doprocessMcWithDecayTypeCheck || doprocessMcWithLbMlAndDecayTypeCheck || doprocessMcWithLcMlAndDecayTypeCheck) { + constexpr uint8_t kNBinsDecayTypeMc = hf_cand_lb::DecayTypeMc::NDecayTypeMc; + TString labels[kNBinsDecayTypeMc]; + labels[hf_cand_lb::DecayTypeMc::LbToLcPiToPKPiPi] = "#Lambda_{b}^{0} #rightarrow (#Lambda_{c}^{#plus} #rightarrow p K^{#minus} #pi^{#plus}) #pi^{#minus}"; + labels[hf_cand_lb::DecayTypeMc::B0ToDplusPiToPiKPiPi] = "B^{0} #rightarrow (D^{#minus} #rightarrow #pi^{#minus} K^{#plus} #pi^{#minus}) #pi^{#plus}"; + labels[hf_cand_lb::DecayTypeMc::LbToLcKToPKPiK] = "#Lambda_{b}^{0} #rightarrow (#Lambda_{c}^{#plus} #rightarrow p K^{#minus} #pi^{#plus}) K^{#minus}"; + labels[hf_cand_lb::DecayTypeMc::PartlyRecoDecay] = "Partly reconstructed decay channel"; + labels[hf_cand_lb::DecayTypeMc::OtherDecay] = "Other decays"; + static const AxisSpec axisDecayType = {kNBinsDecayTypeMc, 0.5, kNBinsDecayTypeMc + 0.5, ""}; + registry.add("hDecayTypeMc", "DecayType", {HistType::kTH3F, {axisDecayType, axisMassLb, axisPtLb}}); + for (uint8_t iBin = 0; iBin < kNBinsDecayTypeMc; ++iBin) { + registry.get(HIST("hDecayTypeMc"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin]); + } + } + // ML scores of Lc daughter + if (doprocessMcWithLcMl || doprocessMcWithLcMlAndDecayTypeCheck) { + // signal + registry.add("hMlScoreBkgLcRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #Lambda_{c}^{+} ML background score;entries", {HistType::kTH2F, {axisPtLc, axisMlScore}}); + registry.add("hMlScorePromptLcRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #Lambda_{c}^{+} ML prompt score;entries", {HistType::kTH2F, {axisPtLc, axisMlScore}}); + registry.add("hMlScoreNonPromptLcRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #Lambda_{c}^{+} ML nonprompt score;entries", {HistType::kTH2F, {axisPtLc, axisMlScore}}); + // background + registry.add("hMlScoreBkgLcRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #Lambda_{c}^{+} ML background score;entries", {HistType::kTH2F, {axisPtLc, axisMlScore}}); + registry.add("hMlScorePromptLcRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #Lambda_{c}^{+} ML prompt score;entries", {HistType::kTH2F, {axisPtLc, axisMlScore}}); + registry.add("hMlScoreNonPromptLcRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});prong0, #Lambda_{c}^{+} ML nonprompt score;entries", {HistType::kTH2F, {axisPtLc, axisMlScore}}); + } + // ML scores of Lb candidate + if (doprocessMcWithLbMl || doprocessMcWithLbMlAndDecayTypeCheck) { + // signal + registry.add("hMlScoreSigLbRecSig", "#Lambda_{b}^{0} candidates (matched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});prong0, #Lambda_{b}^{0} ML signal score;entries", {HistType::kTH2F, {axisPtLb, axisMlScore}}); + // background + registry.add("hMlScoreSigLbRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});prong0, #Lambda_{b}^{0} ML signal score;entries", {HistType::kTH2F, {axisPtLb, axisMlScore}}); + } + } + if (fillSparses) { + // gen sparses + registry.add("hPtYGenSig", "#Lambda_{b}^{0} particles (generated);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{y}(#Lambda_{b}^{0})", {HistType::kTHnSparseF, {axisPtLb, axisEta}}); + registry.add("hPtYWithProngsInAccepanceGenSig", "#Lambda_{b}^{0} particles (generated-daughters in acceptance);#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#it{y}(#Lambda_{b}^{0})", {HistType::kTHnSparseF, {axisPtLb, axisEta}}); + + // reco sparses + if (!(doprocessDataWithLcMl || doprocessDataWithLbMl)) { + registry.add("hMassPtCutVarsRecSig", "#Lambda_{b}^{0} candidates (matched);#it{M} (D#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate decay length (cm);#Lambda_{b}^{0} candidate norm. decay length XY (cm);#Lambda_{b}^{0} candidate impact parameter product (cm);#Lambda_{b}^{0} candidate cos(#vartheta_{P});#it{M} (pK#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate decay length (cm);#Lambda_{c}^{+} candidate cos(#vartheta_{P})", {HistType::kTHnSparseF, {axisMassLb, axisPtLb, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassLc, axisPtLc, axisDecayLength, axisCosp}}); + if (fillBackground) { + registry.add("hMassPtCutVarsRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{M} (D#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate decay length (cm);#Lambda_{b}^{0} candidate norm. decay length XY (cm);#Lambda_{b}^{0} candidate impact parameter product (cm);#Lambda_{b}^{0} candidate cos(#vartheta_{P});#it{M} (pK#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate decay length (cm);#Lambda_{c}^{+} candidate cos(#vartheta_{P})", {HistType::kTHnSparseF, {axisMassLb, axisPtLb, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassLc, axisPtLc, axisDecayLength, axisCosp}}); + } + } else { + registry.add("hMassPtCutVarsRecSig", "#Lambda_{b}^{0} candidates (matched);#it{M} (D#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate decay length (cm);#Lambda_{b}^{0} candidate norm. decay length XY (cm);#Lambda_{b}^{0} candidate impact parameter product (cm);#Lambda_{b}^{0} candidate cos(#vartheta_{P});#it{M} (pK#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate ML score bkg;#Lambda_{c}^{+} candidate ML score nonprompt", {HistType::kTHnSparseF, {axisMassLb, axisPtLb, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassLc, axisPtLc, axisMlScore, axisMlScore}}); + if (fillBackground) { + registry.add("hMassPtCutVarsRecBg", "#Lambda_{b}^{0} candidates (unmatched);#it{M} (D#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{b}^{0}) (GeV/#it{c});#Lambda_{b}^{0} candidate decay length (cm);#Lambda_{b}^{0} candidate norm. decay length XY (cm);#Lambda_{b}^{0} candidate impact parameter product (cm);#Lambda_{b}^{0} candidate cos(#vartheta_{P});#it{M} (pK#pi) (GeV/#it{c}^{2});#it{p}_{T}(#Lambda_{c}^{#plus}) (GeV/#it{c});#Lambda_{c}^{+} candidate ML score bkg;#Lambda_{c}^{+} candidate ML score nonprompt", {HistType::kTHnSparseF, {axisMassLb, axisPtLb, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassLc, axisPtLc, axisMlScore, axisMlScore}}); + } + } + } + } + } + + /// Selection of Lb daughter in geometrical acceptance + /// \param etaProng is the pseudorapidity of Lb prong + /// \param ptProng is the pT of Lb prong + /// \return true if prong is in geometrical acceptance + template + bool isProngInAcceptance(const T& etaProng, const T& ptProng) + { + return std::abs(etaProng) <= etaTrackMax && ptProng >= ptTrackMin; + } + + /// Fill candidate information at reconstruction level + /// \param doMc is the flag to enable the filling with MC information + /// \param withDecayTypeCheck is the flag to enable MC with decay type check + /// \param withLcMl is the flag to enable the filling with ML scores for the Lc daughter + /// \param withLbMl is the flag to enable the filling with ML scores for the Lb candidate + /// \param candidate is the Lb candidate + /// \param candidatesLc is the table with Lc candidates + template + void fillCand(Cand const& candidate, + CandsLc const&) + { + auto ptCandLb = candidate.pt(); + auto invMassLb = hfHelper.invMassLbToLcPi(candidate); + auto candLc = candidate.template prong0_as(); + auto ptLc = candidate.ptProng0(); + auto invMassLc = candLc.invMassHypo0() > 0 ? candLc.invMassHypo0() : candLc.invMassHypo1(); + // TODO: here we are assuming that only one of the two hypotheses is filled, to be checked + std::array posPv{candidate.posX(), candidate.posY(), candidate.posZ()}; + std::array posSvLc{candLc.xSecondaryVertex(), candLc.ySecondaryVertex(), candLc.zSecondaryVertex()}; + std::array momLc{candLc.pVector()}; + auto cospLc = RecoDecay::cpa(posPv, posSvLc, momLc); + auto cospXyLc = RecoDecay::cpaXY(posPv, posSvLc, momLc); + auto decLenLc = RecoDecay::distance(posPv, posSvLc); + auto decLenXyLc = RecoDecay::distanceXY(posPv, posSvLc); + + int8_t flagMcMatchRec = 0; + int8_t flagWrongCollision = 0; + bool isSignal = false; + if constexpr (doMc) { + flagMcMatchRec = candidate.flagMcMatchRec(); + flagWrongCollision = candidate.flagWrongCollision(); + isSignal = TESTBIT(std::abs(flagMcMatchRec), hf_cand_lb::DecayTypeMc::LbToLcPiToPKPiPi); + } + + if (fillHistograms) { + if constexpr (doMc) { + if (isSignal) { + registry.fill(HIST("hMassRecSig"), ptCandLb, hfHelper.invMassLbToLcPi(candidate)); + registry.fill(HIST("hPtProng0RecSig"), ptCandLb, candidate.ptProng0()); + registry.fill(HIST("hPtProng1RecSig"), ptCandLb, candidate.ptProng1()); + registry.fill(HIST("hImpParProdRecSig"), ptCandLb, candidate.impactParameterProduct()); + registry.fill(HIST("hDecLengthRecSig"), ptCandLb, candidate.decayLength()); + registry.fill(HIST("hDecLengthXyRecSig"), ptCandLb, candidate.decayLengthXY()); + registry.fill(HIST("hNormDecLengthXyRecSig"), ptCandLb, candidate.decayLengthXY() / candidate.errorDecayLengthXY()); + registry.fill(HIST("hDcaProng0RecSig"), ptCandLb, candidate.impactParameter0()); + registry.fill(HIST("hDcaProng1RecSig"), ptCandLb, candidate.impactParameter1()); + registry.fill(HIST("hCospRecSig"), ptCandLb, candidate.cpa()); + registry.fill(HIST("hCospXyRecSig"), ptCandLb, candidate.cpaXY()); + registry.fill(HIST("hEtaRecSig"), ptCandLb, candidate.eta()); + registry.fill(HIST("hRapidityRecSig"), ptCandLb, hfHelper.yLb(candidate)); + registry.fill(HIST("hinvMassLcRecSig"), ptLc, invMassLc); + registry.fill(HIST("hDecLengthLcRecSig"), ptLc, decLenLc); + registry.fill(HIST("hDecLengthXyLcRecSig"), ptLc, decLenXyLc); + registry.fill(HIST("hCospLcRecSig"), ptLc, cospLc); + registry.fill(HIST("hCospXyLcRecSig"), ptLc, cospXyLc); + if constexpr (withDecayTypeCheck) { + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_lb::DecayTypeMc::LbToLcPiToPKPiPi, invMassLb, ptCandLb); + } + if constexpr (withLcMl) { + registry.fill(HIST("hMlScoreBkgLcRecSig"), ptLc, candidate.prong0MlScoreBkg()); + registry.fill(HIST("hMlScorePromptLcRecSig"), ptLc, candidate.prong0MlScorePrompt()); + registry.fill(HIST("hMlScoreNonPromptLcRecSig"), ptLc, candidate.prong0MlScoreNonprompt()); + } + if constexpr (withLbMl) { + registry.fill(HIST("hMlScoreSigLbRecSig"), ptCandLb, candidate.mlProbLbToLcPi()); + } + } else if (fillBackground) { + registry.fill(HIST("hMassRecBg"), ptCandLb, hfHelper.invMassLbToLcPi(candidate)); + registry.fill(HIST("hPtProng0RecBg"), ptCandLb, candidate.ptProng0()); + registry.fill(HIST("hPtProng1RecBg"), ptCandLb, candidate.ptProng1()); + registry.fill(HIST("hImpParProdRecBg"), ptCandLb, candidate.impactParameterProduct()); + registry.fill(HIST("hDecLengthRecBg"), ptCandLb, candidate.decayLength()); + registry.fill(HIST("hDecLengthXyRecBg"), ptCandLb, candidate.decayLengthXY()); + registry.fill(HIST("hNormDecLengthXyRecBg"), ptCandLb, candidate.decayLengthXY() / candidate.errorDecayLengthXY()); + registry.fill(HIST("hDcaProng0RecBg"), ptCandLb, candidate.impactParameter0()); + registry.fill(HIST("hDcaProng1RecBg"), ptCandLb, candidate.impactParameter1()); + registry.fill(HIST("hCospRecBg"), ptCandLb, candidate.cpa()); + registry.fill(HIST("hCospXyRecBg"), ptCandLb, candidate.cpaXY()); + registry.fill(HIST("hEtaRecBg"), ptCandLb, candidate.eta()); + registry.fill(HIST("hRapidityRecBg"), ptCandLb, hfHelper.yLb(candidate)); + registry.fill(HIST("hinvMassLcRecBg"), ptLc, invMassLc); + registry.fill(HIST("hDecLengthLcRecBg"), ptLc, decLenLc); + registry.fill(HIST("hDecLengthXyLcRecBg"), ptLc, decLenXyLc); + registry.fill(HIST("hCospLcRecBg"), ptLc, cospLc); + registry.fill(HIST("hCospXyLcRecBg"), ptLc, cospXyLc); + if constexpr (withLcMl) { + registry.fill(HIST("hMlScoreBkgLcRecBg"), ptLc, candidate.prong0MlScoreBkg()); + registry.fill(HIST("hMlScorePromptLcRecBg"), ptLc, candidate.prong0MlScorePrompt()); + registry.fill(HIST("hMlScoreNonPromptLcRecBg"), ptLc, candidate.prong0MlScoreNonprompt()); + } + if constexpr (withLbMl) { + registry.fill(HIST("hMlScoreSigLbRecBg"), ptCandLb, candidate.mlProbLbToLcPi()); + } + } else if constexpr (withDecayTypeCheck) { + if (TESTBIT(flagMcMatchRec, hf_cand_lb::DecayTypeMc::LbToLcKToPKPiK)) { // Lb → Lc+ K- → (pK-π+) K- + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_lb::DecayTypeMc::LbToLcKToPKPiK, invMassLb, ptCandLb); + } else if (TESTBIT(flagMcMatchRec, hf_cand_lb::DecayTypeMc::B0ToDplusPiToPiKPiPi)) { // // B0 → D- π+ → (π- K+ π-) π+ + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_lb::DecayTypeMc::B0ToDplusPiToPiKPiPi, invMassLb, ptCandLb); + } else if (TESTBIT(flagMcMatchRec, hf_cand_lb::DecayTypeMc::PartlyRecoDecay)) { // Partly reconstructed decay channel + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_lb::DecayTypeMc::PartlyRecoDecay, invMassLb, ptCandLb); + } else { + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_lb::DecayTypeMc::OtherDecay, invMassLb, ptCandLb); + } + } + } else { + registry.fill(HIST("hMass"), ptCandLb, invMassLb); + registry.fill(HIST("hPtProng0"), ptCandLb, candidate.ptProng0()); + registry.fill(HIST("hPtProng1"), ptCandLb, candidate.ptProng1()); + registry.fill(HIST("hImpParProd"), ptCandLb, candidate.impactParameterProduct()); + registry.fill(HIST("hDecLength"), ptCandLb, candidate.decayLength()); + registry.fill(HIST("hDecLengthXy"), ptCandLb, candidate.decayLengthXY()); + registry.fill(HIST("hNormDecLengthXy"), ptCandLb, candidate.decayLengthXY() / candidate.errorDecayLengthXY()); + registry.fill(HIST("hDcaProng0"), ptCandLb, candidate.impactParameter0()); + registry.fill(HIST("hDcaProng1"), ptCandLb, candidate.impactParameter1()); + registry.fill(HIST("hCosp"), ptCandLb, candidate.cpa()); + registry.fill(HIST("hCospXy"), ptCandLb, candidate.cpaXY()); + registry.fill(HIST("hEta"), ptCandLb, candidate.eta()); + registry.fill(HIST("hRapidity"), ptCandLb, hfHelper.yLb(candidate)); + registry.fill(HIST("hinvMassLc"), ptLc, invMassLc); + registry.fill(HIST("hDecLengthLc"), ptLc, decLenLc); + registry.fill(HIST("hDecLengthXyLc"), ptLc, decLenXyLc); + registry.fill(HIST("hCospLc"), ptLc, cospLc); + registry.fill(HIST("hCospXyLc"), ptLc, cospXyLc); + + if constexpr (withLcMl) { + registry.fill(HIST("hMlScoreBkgLc"), ptLc, candidate.prong0MlScoreBkg()); + registry.fill(HIST("hMlScorePromptLc"), ptLc, candidate.prong0MlScorePrompt()); + registry.fill(HIST("hMlScoreNonPromptLc"), ptLc, candidate.prong0MlScoreNonprompt()); + } + if constexpr (withLbMl) { + registry.fill(HIST("hMlScoreSigLb"), ptCandLb, candidate.mlProbLbToLcPi()); + } + } + } + if (fillSparses) { + if constexpr (withLcMl) { + if (isSignal) { + if constexpr (withLcMl) { + registry.fill(HIST("hMassPtCutVarsRecSig"), invMassLb, ptCandLb, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassLc, ptLc, candidate.prong0MlScoreBkg(), candidate.prong0MlScoreNonprompt()); + } else { + registry.fill(HIST("hMassPtCutVarsRecSig"), invMassLb, ptCandLb, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassLc, ptLc, decLenLc, cospLc); + } + } else if (fillBackground) { + if constexpr (withLcMl) { + registry.fill(HIST("hMassPtCutVarsRecBg"), invMassLb, ptCandLb, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassLc, ptLc, candidate.prong0MlScoreBkg(), candidate.prong0MlScoreNonprompt()); + } else { + registry.fill(HIST("hMassPtCutVarsRecBg"), invMassLb, ptCandLb, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassLc, ptLc, decLenLc, cospLc); + } + } + } else { + if constexpr (withLcMl) { + registry.fill(HIST("hMassPtCutVars"), invMassLb, ptCandLb, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassLc, ptLc, candidate.prong0MlScoreBkg(), candidate.prong0MlScoreNonprompt()); + } else { + registry.fill(HIST("hMassPtCutVars"), invMassLb, ptCandLb, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassLc, ptLc, decLenLc, cospLc); + } + } + } + if (fillTree) { + float pseudoRndm = ptLc * 1000. - static_cast(ptLc * 1000); + if (flagMcMatchRec != 0 || (((doMc && fillBackground) || !doMc) && (ptCandLb >= ptMaxForDownSample || pseudoRndm < downSampleBkgFactor))) { + float prong0MlScoreBkg = -1.; + float prong0MlScorePrompt = -1.; + float prong0MlScoreNonprompt = -1.; + float candidateMlScoreSig = -1; + if constexpr (withLcMl) { + prong0MlScoreBkg = candidate.prong0MlScoreBkg(); + prong0MlScorePrompt = candidate.prong0MlScorePrompt(); + prong0MlScoreNonprompt = candidate.prong0MlScoreNonprompt(); + } + if constexpr (withLbMl) { + candidateMlScoreSig = candidate.mlProbLbToLcPi(); + } + auto prong1 = candidate.template prong1_as(); + + float ptMother = -1.; + if constexpr (doMc) { + ptMother = candidate.ptMother(); + } + + hfRedCandLbLite( + // Lb features + invMassLb, + ptCandLb, + candidate.eta(), + candidate.phi(), + hfHelper.yLb(candidate), + candidate.cpa(), + candidate.cpaXY(), + candidate.chi2PCA(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + candidate.impactParameterProduct(), + candidate.maxNormalisedDeltaIP(), + candidateMlScoreSig, + candidate.isSelLbToLcPi(), + // Lc-baryon features + invMassLc, + ptLc, + decLenLc, + decLenXyLc, + candidate.impactParameter0(), + candLc.ptProngMin(), + candLc.absEtaProngMin(), + candLc.itsNClsProngMin(), + candLc.tpcNClsCrossedRowsProngMin(), + candLc.tpcChi2NClProngMax(), + candLc.tpcNSigmaPrProng0(), + candLc.tofNSigmaPrProng0(), + candLc.tpcTofNSigmaPrProng0(), + candLc.tpcNSigmaKaProng1(), + candLc.tofNSigmaKaProng1(), + candLc.tpcTofNSigmaKaProng1(), + candLc.tpcNSigmaPiProng2(), + candLc.tofNSigmaPiProng2(), + candLc.tpcTofNSigmaPiProng2(), + prong0MlScoreBkg, + prong0MlScorePrompt, + prong0MlScoreNonprompt, + // pion features + candidate.ptProng1(), + std::abs(RecoDecay::eta(prong1.pVector())), + prong1.itsNCls(), + prong1.tpcNClsCrossedRows(), + prong1.tpcChi2NCl(), + candidate.impactParameter1(), + prong1.tpcNSigmaPi(), + prong1.tofNSigmaPi(), + prong1.tpcTofNSigmaPi(), + // MC truth + flagMcMatchRec, + isSignal, + flagWrongCollision, + ptMother); + + if constexpr (withDecayTypeCheck) { + hfRedLbMcCheck( + flagMcMatchRec, + flagWrongCollision, + invMassLc, + ptLc, + invMassLb, + ptCandLb, + candidateMlScoreSig, + candidate.pdgCodeBeautyMother(), + candidate.pdgCodeCharmMother(), + candidate.pdgCodeProng0(), + candidate.pdgCodeProng1(), + candidate.pdgCodeProng2(), + candidate.pdgCodeProng3()); + } + } + } + } + + /// Fill particle histograms (gen MC truth) + void fillCandMcGen(aod::HfMcGenRedLbs::iterator const& particle) + { + auto ptParticle = particle.ptTrack(); + auto yParticle = particle.yTrack(); + auto etaParticle = particle.etaTrack(); + if (yCandGenMax >= 0. && std::abs(yParticle) > yCandGenMax) { + return; + } + std::array ptProngs = {particle.ptProng0(), particle.ptProng1()}; + std::array yProngs = {particle.yProng0(), particle.yProng1()}; + std::array etaProngs = {particle.etaProng0(), particle.etaProng1()}; + bool prongsInAcc = isProngInAcceptance(etaProngs[0], ptProngs[0]) && isProngInAcceptance(etaProngs[1], ptProngs[1]); + + if (fillHistograms) { + registry.fill(HIST("hPtProng0Gen"), ptParticle, ptProngs[0]); + registry.fill(HIST("hPtProng1Gen"), ptParticle, ptProngs[1]); + registry.fill(HIST("hYProng0Gen"), ptParticle, yProngs[0]); + registry.fill(HIST("hYProng1Gen"), ptParticle, yProngs[1]); + registry.fill(HIST("hEtaProng0Gen"), ptParticle, etaProngs[0]); + registry.fill(HIST("hEtaProng1Gen"), ptParticle, etaProngs[1]); + + registry.fill(HIST("hYGen"), ptParticle, yParticle); + registry.fill(HIST("hEtaGen"), ptParticle, etaParticle); + + // generated Lb with daughters in geometrical acceptance + if (prongsInAcc) { + registry.fill(HIST("hYGenWithProngsInAcceptance"), ptParticle, yParticle); + } + } + if (fillSparses) { + registry.fill(HIST("hPtYGenSig"), ptParticle, yParticle); + if (prongsInAcc) { + registry.fill(HIST("hPtYWithProngsInAccepanceGenSig"), ptParticle, yParticle); + } + } + } + + // Process functions + void processData(soa::Filtered> const& candidates, + CandsLc const& candidatesLc, + TracksPion const&) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesLc); + } // candidate loop + } // processData + PROCESS_SWITCH(HfTaskLbReduced, processData, "Process data without ML scores for Lb and Lc daughter", true); + + void processDataWithLcMl(soa::Filtered> const& candidates, + CandsLc const& candidatesLc, + TracksPion const&) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesLc); + } // candidate loop + } // processDataWithLcMl + PROCESS_SWITCH(HfTaskLbReduced, processDataWithLcMl, "Process data with(out) ML scores for Lc daughter (Lb)", false); + + void processDataWithLbMl(soa::Filtered> const& candidates, + CandsLc const& candidatesLc, + TracksPion const&) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesLc); + } // candidate loop + } // processDataWithLbMl + PROCESS_SWITCH(HfTaskLbReduced, processDataWithLbMl, "Process data with(out) ML scores for Lb (Lc daughter)", false); + + void processMc(soa::Filtered> const& candidates, + aod::HfMcGenRedLbs const& mcParticles, + CandsLc const& candidatesLc, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesLc); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskLbReduced, processMc, "Process MC without ML scores for Lb and Lc daughter", false); + + void processMcWithDecayTypeCheck(soa::Filtered> const& candidates, + aod::HfMcGenRedLbs const& mcParticles, + CandsLc const& candidatesLc, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesLc); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskLbReduced, processMcWithDecayTypeCheck, "Process MC with decay type check and without ML scores for Lb and D daughter", false); + + void processMcWithLcMl(soa::Filtered> const& candidates, + aod::HfMcGenRedLbs const& mcParticles, + CandsLc const& candidatesLc, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesLc); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMcWithLcMl + PROCESS_SWITCH(HfTaskLbReduced, processMcWithLcMl, "Process MC with(out) ML scores for Lc daughter (Lb)", false); + + void processMcWithLcMlAndDecayTypeCheck(soa::Filtered> const& candidates, + aod::HfMcGenRedLbs const& mcParticles, + CandsLc const& candidatesLc, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesLc); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskLbReduced, processMcWithLcMlAndDecayTypeCheck, "Process MC with decay type check and with(out) ML scores for Lb (Lc daughter)", false); + + void processMcWithLbMl(soa::Filtered> const& candidates, + aod::HfMcGenRedLbs const& mcParticles, + CandsLc const& candidatesLc, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesLc); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMcWithLbMl + PROCESS_SWITCH(HfTaskLbReduced, processMcWithLbMl, "Process MC with(out) ML scores for Lb (Lc daughter)", false); + + void processMcWithLbMlAndDecayTypeCheck(soa::Filtered> const& candidates, + aod::HfMcGenRedLbs const& mcParticles, + CandsLc const& candidatesLc, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesLc); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskLbReduced, processMcWithLbMlAndDecayTypeCheck, "Process MC with decay type check and with(out) ML scores for Lb (Lc daughter)", false); +}; // struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/Tasks/taskLc.cxx b/PWGHF/D2H/Tasks/taskLc.cxx index e844b07e7c2..85eee1bb213 100644 --- a/PWGHF/D2H/Tasks/taskLc.cxx +++ b/PWGHF/D2H/Tasks/taskLc.cxx @@ -18,22 +18,42 @@ /// \author Annalena Kalteyer , GSI Darmstadt /// \author Biao Zhang , Heidelberg University -#include // std::vector - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsEvSelHf.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include // std::vector using namespace o2; using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_centrality; +using namespace o2::hf_occupancy; /// Λc± → p± K∓ π± analysis task struct HfTaskLc { @@ -43,21 +63,11 @@ struct HfTaskLc { Configurable> binsPt{"binsPt", std::vector{hf_cuts_lc_to_p_k_pi::vecBinsPt}, "pT bin limits"}; // ThnSparse for ML outputScores and Vars Configurable fillTHn{"fillTHn", false, "fill THn"}; - ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {72, 0, 36}, ""}; - ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {300, 1.98, 2.58}, ""}; - ConfigurableAxis thnConfigAxisPtProng{"thnConfigAxisPtProng", {100, 0, 20}, ""}; - ConfigurableAxis thnConfigAxisCentrality{"thnConfigAxisCentrality", {100, 0, 100}, ""}; - ConfigurableAxis thnConfigAxisChi2PCA{"thnConfigAxisChi2PCA", {100, 0, 20}, ""}; - ConfigurableAxis thnConfigAxisDecLength{"thnConfigAxisDecLength", {10, 0, 0.05}, ""}; - ConfigurableAxis thnConfigAxisCPA{"thnConfigAxisCPA", {20, 0.8, 1}, ""}; - ConfigurableAxis thnConfigAxisBdtScoreBkg{"thnConfigAxisBdtScoreBkg", {1000, 0., 1.}, ""}; - ConfigurableAxis thnConfigAxisBdtScoreSignal{"thnConfigAxisBdtScoreSignal", {100, 0., 1.}, ""}; - ConfigurableAxis thnConfigAxisCanType{"thnConfigAxisCanType", {5, 0., 5.}, ""}; - ConfigurableAxis thnAxisRapidity{"thnAxisRapidity", {20, -1, 1}, "Cand. rapidity bins"}; - ConfigurableAxis thnConfigAxisGenPtB{"thnConfigAxisGenPtB", {1000, 0, 100}, "Gen Pt B"}; - ConfigurableAxis thnConfigAxisNumPvContr{"thnConfigAxisNumPvContr", {200, -0.5, 199.5}, "Number of PV contributors"}; + Configurable storeOccupancy{"storeOccupancy", true, "Flag to store occupancy information"}; + Configurable occEstimator{"occEstimator", 2, "Occupancy estimation (None: 0, ITS: 1, FT0C: 2)"}; HfHelper hfHelper; + SliceCache cache; using Collisions = soa::Join; using CollisionsMc = soa::Join; @@ -73,9 +83,23 @@ struct HfTaskLc { using LcCandidatesMlMc = soa::Filtered>; using McParticles3ProngMatched = soa::Join; Filter filterSelectCandidates = aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc; - PresliceUnsorted colPerMcCollision = aod::mcparticle::mcCollisionId; Preslice candLcPerCollision = aod::hf_cand::collisionId; - SliceCache cache; + PresliceUnsorted colPerMcCollision = aod::mcparticle::mcCollisionId; + + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {72, 0, 36}, ""}; + ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {300, 1.98, 2.58}, ""}; + ConfigurableAxis thnConfigAxisPtProng{"thnConfigAxisPtProng", {100, 0, 20}, ""}; + ConfigurableAxis thnConfigAxisCentrality{"thnConfigAxisCentrality", {100, 0, 100}, ""}; + ConfigurableAxis thnConfigAxisChi2PCA{"thnConfigAxisChi2PCA", {100, 0, 20}, ""}; + ConfigurableAxis thnConfigAxisDecLength{"thnConfigAxisDecLength", {10, 0, 0.05}, ""}; + ConfigurableAxis thnConfigAxisCPA{"thnConfigAxisCPA", {20, 0.8, 1}, ""}; + ConfigurableAxis thnConfigAxisBdtScoreBkg{"thnConfigAxisBdtScoreBkg", {1000, 0., 1.}, ""}; + ConfigurableAxis thnConfigAxisBdtScoreSignal{"thnConfigAxisBdtScoreSignal", {100, 0., 1.}, ""}; + ConfigurableAxis thnConfigAxisCanType{"thnConfigAxisCanType", {5, 0., 5.}, ""}; + ConfigurableAxis thnAxisRapidity{"thnAxisRapidity", {20, -1, 1}, "Cand. rapidity bins"}; + ConfigurableAxis thnConfigAxisGenPtB{"thnConfigAxisGenPtB", {1000, 0, 100}, "Gen Pt B"}; + ConfigurableAxis thnConfigAxisNumPvContr{"thnConfigAxisNumPvContr", {200, -0.5, 199.5}, "Number of PV contributors"}; + ConfigurableAxis thnConfigAxisOccupancy{"thnConfigAxisOccupancy", {14, 0, 14000}, "axis for centrality"}; HistogramRegistry registry{ "registry", @@ -292,22 +316,50 @@ struct HfTaskLc { const AxisSpec thnAxisY{thnAxisRapidity, "rapidity"}; const AxisSpec thnAxisPtB{thnConfigAxisGenPtB, "#it{p}_{T}^{B} (GeV/#it{c})"}; const AxisSpec thnAxisTracklets{thnConfigAxisNumPvContr, "Number of PV contributors"}; + const AxisSpec thnAxisOccupancy{thnConfigAxisOccupancy, "Occupancy"}; - if (doprocessDataWithMl || doprocessDataWithMlWithFT0C || doprocessDataWithMlWithFT0M) { - - registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for data with ML", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets}); + bool isDataWithMl = doprocessDataWithMl || doprocessDataWithMlWithFT0C || doprocessDataWithMlWithFT0M; + bool isMcWithMl = doprocessMcWithMl || doprocessMcWithMlWithFT0C || doprocessMcWithMlWithFT0M; + bool isDataStd = doprocessDataStd || doprocessDataStdWithFT0C || doprocessDataStdWithFT0M; + bool isMcStd = doprocessMcStd || doprocessMcStdWithFT0C || doprocessMcStdWithFT0M; - } else if (doprocessMcWithMl || doprocessMcWithMlWithFT0C || doprocessMcWithMlWithFT0M) { + std::vector axesStd, axesWithBdt, axesGen; - registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for mc with ML", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisPtB, thnAxisCanType}); - registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, {thnAxisPt, thnAxisY, thnAxisTracklets, thnAxisPtB, thnAxisCanType}); + if (isDataStd) { + axesStd = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets}; + } + if (isMcStd) { + axesStd = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets, thnAxisPtB, thnAxisCanType}; + } + if (isMcStd || isMcWithMl) { + axesGen = {thnAxisPt, thnAxisCentrality, thnAxisY, thnAxisTracklets, thnAxisPtB, thnAxisCanType}; + } + if (isDataWithMl) { + axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets}; + } + if (isMcWithMl) { + axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisPtB, thnAxisCanType}; + } - } else if (doprocessDataStd || doprocessDataStdWithFT0C || doprocessDataStdWithFT0M) { - registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for data without ML", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets}); + if (storeOccupancy) { + if (!axesWithBdt.empty()) + axesWithBdt.push_back(thnAxisOccupancy); + if (!axesStd.empty()) + axesStd.push_back(thnAxisOccupancy); + if (!axesGen.empty()) + axesGen.push_back(thnAxisOccupancy); + } + if (isDataWithMl) { + registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for data with ML", HistType::kTHnSparseF, axesWithBdt); + } else if (isMcWithMl) { + registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for mc with ML", HistType::kTHnSparseF, axesWithBdt); + registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen); + } else if (isDataStd) { + registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for data without ML", HistType::kTHnSparseF, axesStd); } else { - registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for mc without ML", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets, thnAxisPtB, thnAxisCanType}); - registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, {thnAxisPt, thnAxisY, thnAxisTracklets, thnAxisPtB, thnAxisCanType}); + registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for mc without ML", HistType::kTHnSparseF, axesStd); + registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen); } } } @@ -340,7 +392,7 @@ struct HfTaskLc { continue; } - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { // Get the corresponding MC particle. auto mcParticleProng0 = candidate.template prong0_as().template mcParticle_as>(); auto pdgCodeProng0 = std::abs(mcParticleProng0.pdgCode()); @@ -484,6 +536,10 @@ struct HfTaskLc { } if (fillTHn) { float cent = evaluateCentralityColl(collision); + float occ{-1.}; + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); + } double massLc(-1); double outputBkg(-1), outputPrompt(-1), outputFD(-1); if ((candidate.isSelLcToPKPi() >= selectionFlagLc) && pdgCodeProng0 == kProton) { @@ -496,9 +552,21 @@ struct HfTaskLc { outputFD = candidate.mlProbLcToPKPi()[2]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate - registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType); + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType, occ); + } else { + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType); + } + } else { - registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType); + + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType, occ); + + } else { + + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType); + } } } if ((candidate.isSelLcToPiKP() >= selectionFlagLc) && pdgCodeProng0 == kPiPlus) { @@ -511,9 +579,18 @@ struct HfTaskLc { outputFD = candidate.mlProbLcToPiKP()[2]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate (todo: add multiplicity) - registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType); + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType, occ); + + } else { + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, ptRecB, originType); + } } else { - registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType); + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType, occ); + } else { + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, ptRecB, originType); + } } } } @@ -528,19 +605,24 @@ struct HfTaskLc { { // MC gen. for (const auto& particle : mcParticles) { - if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(particle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { auto yGen = RecoDecay::y(particle.pVector(), o2::constants::physics::MassLambdaCPlus); if (yCandGenMax >= 0. && std::abs(yGen) > yCandGenMax) { continue; } auto ptGen = particle.pt(); auto originType = particle.originMcGen(); - auto ptGenB = -1; + float ptGenB = -1.; unsigned int numPvContributors = 0; const auto& recoCollsPerMcColl = recoCollisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex()); for (const auto& recCol : recoCollsPerMcColl) { numPvContributors = recCol.numContrib() > numPvContributors ? recCol.numContrib() : numPvContributors; } + float cent = o2::hf_centrality::getCentralityGenColl(recoCollsPerMcColl); + float occ{-1.}; + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + occ = o2::hf_occupancy::getOccupancyGenColl(recoCollsPerMcColl, occEstimator); + } registry.fill(HIST("MC/generated/signal/hPtGen"), ptGen); registry.fill(HIST("MC/generated/signal/hEtaGen"), particle.eta()); @@ -551,7 +633,14 @@ struct HfTaskLc { registry.fill(HIST("MC/generated/signal/hPhiVsPtGenSig"), particle.phi(), ptGen); if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { - registry.get(HIST("hnLcVarsGen"))->Fill(ptGen, yGen, numPvContributors, ptGenB, originType); + if (fillTHn) { + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + registry.get(HIST("hnLcVarsGen"))->Fill(ptGen, cent, yGen, numPvContributors, ptGenB, originType, occ); + + } else { + registry.get(HIST("hnLcVarsGen"))->Fill(ptGen, cent, yGen, numPvContributors, ptGenB, originType); + } + } registry.fill(HIST("MC/generated/prompt/hPtGenPrompt"), ptGen); registry.fill(HIST("MC/generated/prompt/hEtaGenPrompt"), particle.eta()); registry.fill(HIST("MC/generated/prompt/hYGenPrompt"), yGen); @@ -562,7 +651,14 @@ struct HfTaskLc { } if (particle.originMcGen() == RecoDecay::OriginType::NonPrompt) { ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt(); - registry.get(HIST("hnLcVarsGen"))->Fill(ptGen, yGen, numPvContributors, ptGenB, originType); + if (fillTHn) { + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + registry.get(HIST("hnLcVarsGen"))->Fill(ptGen, cent, yGen, numPvContributors, ptGenB, originType, occ); + + } else { + registry.get(HIST("hnLcVarsGen"))->Fill(ptGen, cent, yGen, numPvContributors, ptGenB, originType); + } + } registry.fill(HIST("MC/generated/nonprompt/hPtGenNonPrompt"), ptGen); registry.fill(HIST("MC/generated/nonprompt/hEtaGenNonPrompt"), particle.eta()); registry.fill(HIST("MC/generated/nonprompt/hYGenNonPrompt"), yGen); @@ -646,6 +742,10 @@ struct HfTaskLc { if (fillTHn) { float cent = evaluateCentralityColl(collision); + float occ{-1.}; + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); + } double massLc(-1); double outputBkg(-1), outputPrompt(-1), outputFD(-1); if (candidate.isSelLcToPKPi() >= selectionFlagLc) { @@ -658,9 +758,20 @@ struct HfTaskLc { outputFD = candidate.mlProbLcToPKPi()[2]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate - registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors); + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, occ); + + } else { + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors); + } } else { - registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors); + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, occ); + } else { + + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors); + } } } if (candidate.isSelLcToPiKP() >= selectionFlagLc) { @@ -673,15 +784,22 @@ struct HfTaskLc { outputFD = candidate.mlProbLcToPiKP()[2]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate - registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors); + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors, occ); + } else { + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, numPvContributors); + } } else { - registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors); + if (storeOccupancy && occEstimator != o2::hf_occupancy::OccupancyEstimator::None) { + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors, occ); + } else { + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, numPvContributors); + } } } } } } - /// Run the analysis on real data /// \tparam fillMl switch to fill ML histograms template diff --git a/PWGHF/D2H/Tasks/taskLcToK0sP.cxx b/PWGHF/D2H/Tasks/taskLcToK0sP.cxx index c8a9d1c2128..f107452344a 100644 --- a/PWGHF/D2H/Tasks/taskLcToK0sP.cxx +++ b/PWGHF/D2H/Tasks/taskLcToK0sP.cxx @@ -17,14 +17,26 @@ /// /// \note based on taskD0.cxx, taskLc.cxx -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -35,14 +47,16 @@ struct HfTaskLcToK0sP { Configurable selectionFlagLcToK0sP{"selectionFlagLcToK0sP", 1, "Selection Flag for Lc"}; Configurable selectionFlagLcbarToK0sP{"selectionFlagLcbarToK0sP", 1, "Selection Flag for Lcbar"}; Configurable etaCandMax{"etaCandMax", -1., "max. cand. pseudorapidity"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; Configurable> binsPt{"binsPt", std::vector{hf_cuts_lc_to_k0s_p::vecBinsPt}, "pT bin limits"}; HfHelper hfHelper; - Filter filterSelectCandidates = (aod::hf_sel_candidate_lc_to_k0s_p::isSelLcToK0sP >= selectionFlagLcToK0sP || aod::hf_sel_candidate_lc_to_k0s_p::isSelLcToK0sP >= selectionFlagLcbarToK0sP); - using TracksWPid = soa::Join; + Filter filterSelectCandidates = (aod::hf_sel_candidate_lc_to_k0s_p::isSelLcToK0sP >= selectionFlagLcToK0sP || aod::hf_sel_candidate_lc_to_k0s_p::isSelLcToK0sP >= selectionFlagLcbarToK0sP); + HistogramRegistry registry{"registry"}; void init(InitContext& context) @@ -127,6 +141,8 @@ struct HfTaskLcToK0sP { // add MC histograms if (context.mOptions.get("processMc")) { registry.add("MC/Rec/hPtCandRecSig", "cascade candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("MC/Rec/hPtCandRecSigPrompt", "cascade candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("MC/Rec/hPtCandRecSigNonPrompt", "cascade candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); registry.add("MC/Rec/hPtCandRecBg", "cascade candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); registry.add("MC/Rec/hEtaCandRecSig", "cascade candidates;candidate #it{#eta};entries", {HistType::kTH1F, {axisEta}}); registry.add("MC/Rec/hEtaCandVsPtCandRecSig", "cascade candidates;candidate #it{#eta};p_{T}", {HistType::kTH2F, {axisEta, axisBinsPt}}); @@ -137,6 +153,8 @@ struct HfTaskLcToK0sP { registry.add("MC/Rec/hPhiCandRecBg", "cascade candidates;candidate #it{#phi};entries", {HistType::kTH1F, {axisPhi}}); registry.add("MC/Rec/hPhiCandVsPtCandRecBg", "cascade candidates;candidate #it{#phi};p_{T}", {HistType::kTH2F, {axisPhi, axisBinsPt}}); registry.add("MC/Gen/hPtCandGen", "cascade candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("MC/Gen/hPtCandGenPrompt", "cascade candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("MC/Gen/hPtCandGenNonPrompt", "cascade candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); registry.add("MC/Gen/hEtaCandGen", "cascade candidates;candidate #it{#eta};entries", {HistType::kTH1F, {axisEta}}); registry.add("MC/Gen/hEtaCandVsPtCandGen", "cascade candidates;candidate #it{#eta};p_{T}", {HistType::kTH2F, {axisEta, axisBinsPt}}); registry.add("MC/Gen/hPhiCandGen", "cascade candidates;candidate #it{#phi};entries", {HistType::kTH1F, {axisPhi}}); @@ -248,14 +266,10 @@ struct HfTaskLcToK0sP { TracksWPid const&) { for (const auto& candidate : candidates) { - /* - // no such selection for LcK0sp for now - it is the only cascade - if (!(candidate.hfflag() & 1 << D0ToPiK)) { + if (etaCandMax >= 0. && std::abs(candidate.eta()) > etaCandMax) { continue; } - */ - - if (etaCandMax >= 0. && std::abs(candidate.eta()) > etaCandMax) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLc(candidate)) > yCandRecoMax) { continue; } @@ -362,6 +376,10 @@ struct HfTaskLcToK0sP { continue; } + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLc(candidate)) > yCandRecoMax) { + continue; + } + auto ptCand = candidate.pt(); auto eta = candidate.eta(); auto phi = candidate.phi(); @@ -394,6 +412,11 @@ struct HfTaskLcToK0sP { auto pBach = bach.p(); if (std::abs(candidate.flagMcMatchRec()) == 1) { + if (candidate.originMcRec() == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("MC/Rec/hPtCandRecSigPrompt"), ptCand); + } else if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("MC/Rec/hPtCandRecSigNonPrompt"), ptCand); + } registry.fill(HIST("MC/Rec/hPtCandRecSig"), ptCand); registry.fill(HIST("MC/Rec/hEtaCandRecSig"), eta); registry.fill(HIST("MC/Rec/hEtaCandVsPtCandRecSig"), eta, ptCand); @@ -520,6 +543,11 @@ struct HfTaskLcToK0sP { } if (std::abs(particle.flagMcMatchGen()) == 1) { + + auto yGen = RecoDecay::y(particle.pVector(), o2::constants::physics::MassLambdaCPlus); + if (yCandGenMax >= 0. && std::abs(yGen) > yCandGenMax) { + continue; + } auto ptCand = particle.pt(); auto eta = particle.eta(); auto phi = particle.phi(); @@ -528,6 +556,12 @@ struct HfTaskLcToK0sP { registry.fill(HIST("MC/Gen/hEtaCandVsPtCandGen"), eta, ptCand); registry.fill(HIST("MC/Gen/hPhiCandGen"), phi); registry.fill(HIST("MC/Gen/hPhiCandVsPtCandGen"), phi, ptCand); + + if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("MC/Gen/hPtCandGenPrompt"), ptCand); + } else if (particle.originMcGen() == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("MC/Gen/hPtCandGenNonPrompt"), ptCand); + } } } } diff --git a/PWGHF/D2H/Tasks/taskOmegac0ToOmegapi.cxx b/PWGHF/D2H/Tasks/taskOmegac0ToOmegapi.cxx new file mode 100644 index 00000000000..a611d7e166a --- /dev/null +++ b/PWGHF/D2H/Tasks/taskOmegac0ToOmegapi.cxx @@ -0,0 +1,376 @@ +// 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. + +/// \file taskOmegac0ToOmegapi.cxx +/// \brief OmegaC0 analysis task +/// \author Yunfan Liu , China University of Geosciences +/// \author Fabio Catalano , University of Houston + +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::analysis; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace ml +{ +// collision info +DECLARE_SOA_COLUMN(KfptPiFromOmegac, kfptPiFromOmegac, float); +DECLARE_SOA_COLUMN(KfptOmegac, kfptOmegac, float); +DECLARE_SOA_COLUMN(InvMassCharmBaryon, invMassCharmBaryon, float); +DECLARE_SOA_COLUMN(MlProbOmegac, mlProbOmegac, float); +DECLARE_SOA_COLUMN(Cent, cent, float); +} // namespace ml +DECLARE_SOA_TABLE(HfKfOmegacML, "AOD", "HFKFOMEGACML", + ml::InvMassCharmBaryon, ml::KfptOmegac, ml::KfptPiFromOmegac, ml::MlProbOmegac, ml::Cent); +} // namespace o2::aod + +/// Omegac0 analysis task + +struct HfTaskOmegac0ToOmegapi { + + Produces kfCandMl; + // ML inference + Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; + Configurable fillCent{"fillCent", false, "Flag to fill centrality information"}; + Configurable fillTree{"fillTree", false, "Fill TTree for local analysis.(Enabled only with ML)"}; + Configurable selectionFlagOmegac0{"selectionFlagOmegac0", true, "Select Omegac0 candidates"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; + + HfHelper hfHelper; + SliceCache cache; + + using TracksMc = soa::Join; + + using Omegac0Cands = soa::Filtered>; + using Omegac0CandsKF = soa::Filtered>; + using OmegaC0CandsMcKF = soa::Filtered>; + + using Omegac0CandsMl = soa::Filtered>; + using Omegac0CandsMlKF = soa::Filtered>; + using Omegac0CandsMlMcKF = soa::Filtered>; + + using Omegac0Gen = soa::Filtered>; + + using Collisions = soa::Join; + using CollisionsWithFT0C = soa::Join; + using CollisionsWithFT0M = soa::Join; + using CollisionsWithMcLabels = soa::Join; + + Filter filterOmegaCToOmegaPiFlag = (aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaPi))) != static_cast(0); + Filter filterOmegaCMatchedRec = nabs(aod::hf_cand_xic0_omegac0::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi)); + Filter filterOmegaCMatchedGen = nabs(aod::hf_cand_xic0_omegac0::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi)); + Preslice candOmegacKFPerCollision = aod::hf_cand_xic0_omegac0::collisionId; + Preslice candOmegacKFMlPerCollision = aod::hf_cand_xic0_omegac0::collisionId; + + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + + // ThnSparse for ML outputScores and Vars + ConfigurableAxis thnConfigAxisPromptScore{"thnConfigAxisPromptScore", {100, 0, 1}, "Prompt score bins"}; + ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {120, 2.4, 3.1}, "Cand. inv-mass bins"}; + ConfigurableAxis thnConfigAxisPtB{"thnConfigAxisPtB", {1000, 0, 100}, "Cand. beauty mother pTB bins"}; + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {100, 0, 20}, "Cand. pT bins"}; + ConfigurableAxis thnConfigAxisY{"thnConfigAxisY", {20, -1, 1}, "Cand. rapidity bins"}; + ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {100, 0, 100}, "Centrality bins"}; + ConfigurableAxis thnConfigAxisPtPion{"thnConfigAxisPtPion", {100, 0, 10}, "PtPion from Omegac0 bins"}; + ConfigurableAxis thnConfigAxisOrigin{"thnConfigAxisOrigin", {3, -0.5, 2.5}, "Cand. origin type"}; + ConfigurableAxis thnConfigAxisMatchFlag{"thnConfigAxisMatchFlag", {15, -7.5, 7.5}, "Cand. MC Match Flag type"}; + ConfigurableAxis thnConfigAxisGenPtD{"thnConfigAxisGenPtD", {500, 0, 50}, "Gen Pt D"}; + ConfigurableAxis thnConfigAxisGenPtB{"thnConfigAxisGenPtB", {1000, 0, 100}, "Gen Pt B"}; + ConfigurableAxis thnConfigAxisNumPvContr{"thnConfigAxisNumPvContr", {200, -0.5, 199.5}, "Number of PV contributors"}; + HistogramRegistry registry{"registry", {}}; + + void init(InitContext&) + { + std::array doprocess{doprocessDataWithKFParticle, doprocessDataWithKFParticleMl, doprocessDataWithKFParticleFT0C, doprocessDataWithKFParticleMlFT0C, doprocessDataWithKFParticleFT0M, doprocessDataWithKFParticleMlFT0M}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) > 1) { + LOGP(fatal, "At most one data process function should be enabled at a time."); + } + + std::array doprocessMc{doprocessMcWithKFParticle, doprocessMcWithKFParticleMl}; + if (std::accumulate(doprocessMc.begin(), doprocessMc.end(), 0) > 1) { + LOGP(fatal, "At most one MC process function should be enabled at a time."); + } + + if ((std::accumulate(doprocess.begin(), doprocess.end(), 0) + std::accumulate(doprocessMc.begin(), doprocessMc.end(), 0)) == 0) { + LOGP(fatal, "At least one process function should be enabled."); + } + + const AxisSpec thnAxisMass{thnConfigAxisMass, "inv. mass (#Omega#pi) (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisPtB{thnConfigAxisPtB, "#it{p}_{T}^{B} (GeV/#it{c})"}; + const AxisSpec thnAxisY{thnConfigAxisY, "y"}; + const AxisSpec thnAxisOrigin{thnConfigAxisOrigin, "Origin"}; + const AxisSpec thnAxisMatchFlag{thnConfigAxisMatchFlag, "MatchFlag"}; + const AxisSpec thnAxisGenPtD{thnConfigAxisGenPtD, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisGenPtB{thnConfigAxisGenPtB, "#it{p}_{T}^{B} (GeV/#it{c})"}; + const AxisSpec thnAxisNumPvContr{thnConfigAxisNumPvContr, "Number of PV contributors"}; + + if (doprocessMcWithKFParticle || doprocessMcWithKFParticleMl) { + std::vector axesAcc = {thnAxisGenPtD, thnAxisGenPtB, thnAxisY, thnAxisOrigin, thnAxisNumPvContr}; + registry.add("hSparseAcc", "Thn for generated Omega0 from charm and beauty", HistType::kTHnSparseD, axesAcc); + registry.get(HIST("hSparseAcc"))->Sumw2(); + } + + std::vector axes = {thnAxisMass, thnAxisPt, thnAxisY}; + if (doprocessMcWithKFParticle || doprocessMcWithKFParticleMl) { + axes.push_back(thnAxisPtB); + axes.push_back(thnAxisOrigin); + axes.push_back(thnAxisMatchFlag); + axes.push_back(thnAxisNumPvContr); + } + if (applyMl) { + const AxisSpec thnAxisPromptScore{thnConfigAxisPromptScore, "BDT score prompt."}; + axes.insert(axes.begin(), thnAxisPromptScore); + registry.add("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsOmegac0Type", "Thn for Omegac0 candidates", HistType::kTHnSparseD, axes); + registry.get(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsOmegac0Type"))->Sumw2(); + } else { + registry.add("hMassVsPtVsPtBVsYVsOriginVsOmegac0Type", "Thn for Omegac0 candidates", HistType::kTHnSparseF, axes); + registry.get(HIST("hMassVsPtVsPtBVsYVsOriginVsOmegac0Type"))->Sumw2(); + } + if (fillCent) { + const AxisSpec thnAxisPromptScore{thnConfigAxisPromptScore, "BDT score prompt."}; + const AxisSpec thnAxisCent{thnConfigAxisCent, "Centrality."}; + const AxisSpec thnAxisPtPion{thnConfigAxisPtPion, "Pt of Pion from Omegac0."}; + std::vector axesWithBdtCent = {thnAxisPromptScore, thnAxisMass, thnAxisPt, thnAxisY, thnAxisCent, thnAxisPtPion, thnConfigAxisNumPvContr}; + std::vector axesWithCent = {thnAxisMass, thnAxisPt, thnAxisY, thnAxisCent, thnAxisPtPion, thnConfigAxisNumPvContr}; + registry.add("hBdtScoreVsMassVsPtVsYVsCentVsPtPion", "Thn for Omegac0 candidates with BDT&Cent&pTpi", HistType::kTHnSparseD, axesWithBdtCent); + registry.add("hMassVsPtVsYVsCentVsPtPion", "Thn for Omegac0 candidates with Cent&pTpi", HistType::kTHnSparseD, axesWithCent); + registry.get(HIST("hBdtScoreVsMassVsPtVsYVsCentVsPtPion"))->Sumw2(); + registry.get(HIST("hMassVsPtVsYVsCentVsPtPion"))->Sumw2(); + } + } + + /// Evaluate centrality/multiplicity percentile (centrality estimator is automatically selected based on the used table) + /// \param candidate is candidate + /// \return centrality/multiplicity percentile of the collision + template + float evaluateCentralityColl(const Coll& collision) + { + return o2::hf_centrality::getCentralityColl(collision); + } + + template + void processData(const CandType& candidates, CollType const&) + { + for (const auto& candidate : candidates) { + if (!(candidate.resultSelections() == true || (candidate.resultSelections() == false && !selectionFlagOmegac0))) { + continue; + } + if (yCandRecoMax >= 0. && std::abs(candidate.kfRapOmegac()) > yCandRecoMax) { + continue; + } + + if constexpr (applyMl) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsOmegac0Type"), candidate.mlProbOmegac()[0], candidate.invMassCharmBaryon(), candidate.ptCharmBaryon(), candidate.kfRapOmegac()); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsOmegac0Type"), candidate.invMassCharmBaryon(), candidate.ptCharmBaryon(), candidate.kfRapOmegac()); + } + } + } + + template + void processDataCent(const CandType& candidates, CollType const& collisions) + { + for (const auto& collision : collisions) { + + auto thisCollId = collision.globalIndex(); + auto groupedOmegacCandidates = applyMl + ? candidates.sliceBy(candOmegacKFMlPerCollision, thisCollId) + : candidates.sliceBy(candOmegacKFPerCollision, thisCollId); + auto numPvContributors = collision.numContrib(); + + for (const auto& candidate : groupedOmegacCandidates) { + if (!(candidate.resultSelections() == true || (candidate.resultSelections() == false && !selectionFlagOmegac0))) { + continue; + } + if (yCandRecoMax >= 0. && std::abs(candidate.kfRapOmegac()) > yCandRecoMax) { + continue; + } + float cent = evaluateCentralityColl(collision); + if constexpr (applyMl) { + if (fillTree) { + kfCandMl(candidate.invMassCharmBaryon(), + candidate.ptCharmBaryon(), + candidate.kfptPiFromOmegac(), + candidate.mlProbOmegac()[0], + cent); + } else { + registry.fill(HIST("hBdtScoreVsMassVsPtVsYVsCentVsPtPion"), + candidate.mlProbOmegac()[0], + candidate.invMassCharmBaryon(), + candidate.ptCharmBaryon(), + candidate.kfRapOmegac(), + cent, + candidate.kfptPiFromOmegac(), + numPvContributors); + } + } else { + registry.fill(HIST("hMassVsPtVsYVsCentVsPtPion"), + candidate.invMassCharmBaryon(), + candidate.ptCharmBaryon(), + candidate.kfRapOmegac(), + cent, + candidate.kfptPiFromOmegac(), + numPvContributors); + } + } + } + } + + template + void processMc(const CandType& candidates, + Omegac0Gen const& mcParticles, + TracksMc const&, + CollType const& collisions, + aod::McCollisions const&) + { + // MC rec. + for (const auto& candidate : candidates) { + if (!(candidate.resultSelections() == true || (candidate.resultSelections() == false && !selectionFlagOmegac0))) { + continue; + } + if (yCandRecoMax >= 0. && std::abs(candidate.kfRapOmegac()) > yCandRecoMax) { + continue; + } + + auto numPvContributors = candidate.template collision_as().numContrib(); + + if constexpr (applyMl) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsOmegac0Type"), candidate.mlProbOmegac()[0], candidate.invMassCharmBaryon(), candidate.ptCharmBaryon(), candidate.kfRapOmegac(), candidate.ptBhadMotherPart(), candidate.originMcRec(), candidate.flagMcMatchRec(), numPvContributors); + + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsOmegac0Type"), candidate.invMassCharmBaryon(), candidate.ptCharmBaryon(), candidate.kfRapOmegac(), candidate.ptBhadMotherPart(), candidate.originMcRec(), candidate.flagMcMatchRec(), numPvContributors); + } + } + + // MC gen. + for (const auto& particle : mcParticles) { + if (yCandGenMax >= 0. && std::abs(particle.rapidityCharmBaryonGen()) > yCandGenMax) { + continue; + } + + auto ptGen = particle.pt(); + auto yGen = particle.rapidityCharmBaryonGen(); + + unsigned maxNumContrib = 0; + const auto& recoCollsPerMcColl = collisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex()); + for (const auto& recCol : recoCollsPerMcColl) { + maxNumContrib = recCol.numContrib() > maxNumContrib ? recCol.numContrib() : maxNumContrib; + } + + if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("hSparseAcc"), ptGen, -1., yGen, RecoDecay::OriginType::Prompt, maxNumContrib); + } else { + float ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt(); + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, RecoDecay::OriginType::NonPrompt, maxNumContrib); + } + } + } + + void processDataWithKFParticle(Omegac0CandsKF const& candidates, + Collisions const& collisions) + { + processData(candidates, collisions); + } + PROCESS_SWITCH(HfTaskOmegac0ToOmegapi, processDataWithKFParticle, "process HfTaskOmegac0ToOmegapi with KFParticle", false); + + void processDataWithKFParticleMl(Omegac0CandsMlKF const& candidates, + Collisions const& collisions) + { + processData(candidates, collisions); + } + PROCESS_SWITCH(HfTaskOmegac0ToOmegapi, processDataWithKFParticleMl, "process HfTaskOmegac0ToOmegapi with KFParticle and ML selections", false); + + void processDataWithKFParticleFT0C(Omegac0CandsKF const& candidates, + CollisionsWithFT0C const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskOmegac0ToOmegapi, processDataWithKFParticleFT0C, "process HfTaskOmegac0ToOmegapi with KFParticle and with FT0C centrality", false); + + void processDataWithKFParticleMlFT0C(Omegac0CandsMlKF const& candidates, + CollisionsWithFT0C const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskOmegac0ToOmegapi, processDataWithKFParticleMlFT0C, "process HfTaskOmegac0ToOmegapi with KFParticle and ML selections and with FT0C centrality", false); + + void processDataWithKFParticleFT0M(Omegac0CandsKF const& candidates, + CollisionsWithFT0M const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskOmegac0ToOmegapi, processDataWithKFParticleFT0M, "process HfTaskOmegac0ToOmegapi with KFParticle and with FT0M centrality", false); + + void processDataWithKFParticleMlFT0M(Omegac0CandsMlKF const& candidates, + CollisionsWithFT0M const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskOmegac0ToOmegapi, processDataWithKFParticleMlFT0M, "process HfTaskOmegac0ToOmegapi with KFParticle and ML selections and with FT0M centrality", false); + + void processMcWithKFParticle(OmegaC0CandsMcKF const& omegaC0CandidatesMcKF, + Omegac0Gen const& mcParticles, + TracksMc const& tracks, + CollisionsWithMcLabels const& collisions, + aod::McCollisions const& mcCollisions) + { + processMc(omegaC0CandidatesMcKF, mcParticles, tracks, collisions, mcCollisions); + } + PROCESS_SWITCH(HfTaskOmegac0ToOmegapi, processMcWithKFParticle, "Process MC with KFParticle", false); + + void processMcWithKFParticleMl(Omegac0CandsMlMcKF const& omegac0CandidatesMlMcKF, + Omegac0Gen const& mcParticles, + TracksMc const& tracks, + CollisionsWithMcLabels const& collisions, + aod::McCollisions const& mcCollisions) + { + processMc(omegac0CandidatesMlMcKF, mcParticles, tracks, collisions, mcCollisions); + } + PROCESS_SWITCH(HfTaskOmegac0ToOmegapi, processMcWithKFParticleMl, "Process MC with KFParticle and ML selections", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/Tasks/taskSigmac.cxx b/PWGHF/D2H/Tasks/taskSigmac.cxx index 72cdb981776..b14d0640c88 100644 --- a/PWGHF/D2H/Tasks/taskSigmac.cxx +++ b/PWGHF/D2H/Tasks/taskSigmac.cxx @@ -15,15 +15,36 @@ /// /// \author Mattia Faggin , University and INFN PADOVA -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -37,11 +58,21 @@ struct HfTaskSigmac { /// Properly normalize your results to provide a cross section /// OR /// consider the new parametrization of the fiducial acceptance (to be seen for reco signal in MC) - Configurable yCandMax{"yCandMax", -1, "Sc rapidity"}; + Configurable yCandGenMax{"yCandGenMax", -1, "Maximum generated Sc rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", -1, "Maximum Sc candidate rapidity"}; + Configurable enableTHn{"enableTHn", false, "enable the usage of THn for Λc+ and Σc0,++"}; + Configurable addSoftPiDcaToSigmacSparse{"addSoftPiDcaToSigmacSparse", false, "enable the filling of sof-pion dcaXY, dcaZ in the Σc0,++ THnSparse"}; + + HfHelper hfHelper; + bool isMc; + static constexpr std::size_t NDaughters{2u}; + + using RecoLc = soa::Join; /// THn for candidate Λc+ and Σc0,++ cut variation - Configurable enableTHn{"enableTHn", false, "enable the usage of THn for Λc+ and Σc0,++"}; ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {16, 0, 16}, ""}; + ConfigurableAxis thnConfigAxisGenPt{"thnConfigAxisGenPt", {240, 0, 24}, "Gen pt prompt"}; + ConfigurableAxis thnConfigAxisGenPtB{"thnConfigAxisGenPtB", {800, 0, 80}, "Gen pt non-prompt"}; ConfigurableAxis thnConfigAxisDecLength{"thnConfigAxisDecLength", {10, 0, 0.05}, ""}; ConfigurableAxis thnConfigAxisDecLengthXY{"thnConfigAxisDecLengthXY", {10, 0, 0.05}, ""}; ConfigurableAxis thnConfigAxisCPA{"thnConfigAxisCPA", {20, 0.8, 1}, ""}; @@ -50,8 +81,7 @@ struct HfTaskSigmac { ConfigurableAxis configAxisDeltaMassSigmaC{"configAxisDeltaMassSigmaC", {200, 0.13, 0.23}, ""}; ConfigurableAxis thnConfigAxisBdtScoreLcBkg{"thnConfigAxisBdtScoreLcBkg", {100, 0., 1.}, ""}; ConfigurableAxis thnConfigAxisBdtScoreLcNonPrompt{"thnConfigAxisBdtScoreLcNonPrompt", {100, 0., 1.}, ""}; - - HfHelper hfHelper; + ConfigurableAxis thnConfigAxisSoftPiAbsDca{"thnConfigAxisSoftPiAbsDca", {14, 0., 0.07}, ""}; /// analysis histograms HistogramRegistry registry{ @@ -96,10 +126,6 @@ struct HfTaskSigmac { {"Data/hPhiLcFromSc0PlusPlus", "#Lambda_{c}^{+} #leftarrow #Sigma_{c}^{0,++} candidates; #varphi(#Lambda_{c}^{+} #leftarrow #Sigma_{c}^{0,++}); entries;", {HistType::kTH1D, {{72, 0, constants::math::TwoPI}}}}}}; //{"Data/hDeltaMassLcFromSc0PlusPlus", "#Lambda_{c}^{+} #leftarrow #Sigma_{c}^{0,++} candidates; #it{M}(pK#pi#pi) - #it{M}(pK#pi) (GeV/#it{c}^{2}); #it{p}_{T}(#Lambda_{c}^{+} #leftarrow #Sigma_{c}^{0,++}) (GeV/#it{c});", {HistType::kTH2D, {axisDeltaMassSigmaC, {36, 0., 36.}}}}}}; - using RecoLc = soa::Join; - - bool isMc; - /// @brief init function, to define the additional analysis histograms /// @param void init(InitContext&) @@ -131,6 +157,26 @@ struct HfTaskSigmac { isMc = false; } + const AxisSpec thnAxisMassLambdaC{configAxisMassLambdaC, "inv. mass (p K #pi) (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisPtLambdaC{thnConfigAxisPt, "#it{p}_{T}(#Lambda_{c}^{+}) (GeV/#it{c})"}; + const AxisSpec thnAxisPtSigmaC{thnConfigAxisPt, "#it{p}_{T}(#Sigma_{c}^{0,++}) (GeV/#it{c})"}; + const AxisSpec thnAxisDecLength{thnConfigAxisDecLength, "decay length #Lambda_{c}^{+} (cm)"}; + const AxisSpec thnAxisDecLengthXY{thnConfigAxisDecLengthXY, "decay length XY #Lambda_{c}^{+} (cm)"}; + const AxisSpec thnAxisCPA{thnConfigAxisCPA, "cosine of pointing angle #Lambda_{c}^{+}"}; + const AxisSpec thnAxisCPAXY{thnConfigAxisCPAXY, "cosine of pointing angle XY #Lambda_{c}^{+}"}; + const AxisSpec thnAxisOriginMc{3, -0.5, 2.5, "0: none, 1: prompt, 2: non-prompt"}; + const AxisSpec thnAxisChargeSigmaC{3, -0.5, 2.5, "#Sigma_{c}-baryon charge"}; + const AxisSpec thnAxisChannel{4, -0.5, 3.5, "0: direct 1,2,3: resonant"}; + const AxisSpec thnAxisBdtScoreLcBkg{thnConfigAxisBdtScoreLcBkg, "BDT bkg score (Lc)"}; + const AxisSpec thnAxisBdtScoreLcNonPrompt{thnConfigAxisBdtScoreLcNonPrompt, "BDT non-prompt score (Lc)"}; + const AxisSpec thnAxisGenPtLambdaC{thnConfigAxisGenPt, "#it{p}_{T}^{gen}(#Lambda_{c}^{+}) (GeV/#it{c})"}; + const AxisSpec thnAxisGenPtSigmaC{thnConfigAxisGenPt, "#it{p}_{T}^{gen}(#Sigma_{c}^{0,++}) (GeV/#it{c})"}; + const AxisSpec thnAxisGenPtLambdaCBMother{thnConfigAxisGenPtB, "#it{p}_{T}^{gen}(#Lambda_{c}^{+} B mother) (GeV/#it{c})"}; + const AxisSpec thnAxisGenPtSigmaCBMother{thnConfigAxisGenPtB, "#it{p}_{T}^{gen}(#Sigma_{c}^{0,++} B mother) (GeV/#it{c})"}; + const AxisSpec thnAxisSoftPiAbsDcaXY{thnConfigAxisSoftPiAbsDca, "|dca_{xy}|(#pi^{-,+} #leftarrow #Sigma_{c}^{0,++}) (cm)"}; + const AxisSpec thnAxisSoftPiAbsDcaZ{thnConfigAxisSoftPiAbsDca, "|dca_{z}|(#pi^{-,+} #leftarrow #Sigma_{c}^{0,++}) (cm)"}; + const AxisSpec thnAxisGenSigmaCSpecies = {o2::aod::hf_cand_sigmac::Species::NSpecies, -0.5f, +o2::aod::hf_cand_sigmac::Species::NSpecies - 0.5f, "bin 1: #Sigma_{c}(2455), bin 2: #Sigma_{c}(2520)"}; + const AxisSpec thnAxisSigmaCParticleAntiparticle = {o2::aod::hf_cand_sigmac::Conjugated::NConjugated, -0.5f, +o2::aod::hf_cand_sigmac::Conjugated::NConjugated - 0.5f, "bin 1: particle, bin 2: antiparticle"}; const AxisSpec axisDeltaMassSigmaC{configAxisDeltaMassSigmaC, "#it{M}(pK#pi#pi) - #it{M}(pK#pi) (GeV/#it{c}^{2})"}; registry.add("Data/hDeltaMassSc0", "#Sigma_{c}^{0} candidates; #it{M}(pK#pi#pi) - #it{M}(pK#pi) (GeV/#it{c}^{2}); #it{p}_{T}(#Sigma_{c}^{0}) (GeV/#it{c});", {HistType::kTH2D, {axisDeltaMassSigmaC, {36, 0., 36.}}}); registry.add("Data/hDeltaMassScPlusPlus", "#Sigma_{c}^{++} candidates; #it{M}(pK#pi#pi) - #it{M}(pK#pi) (GeV/#it{c}^{2}); #it{p}_{T}(#Sigma_{c}^{++}) (GeV/#it{c});", {HistType::kTH2D, {axisDeltaMassSigmaC, {36, 0., 36.}}}); @@ -243,24 +289,52 @@ struct HfTaskSigmac { /// THn for candidate Λc+ and Σc0,++ cut variation if (enableTHn) { - const AxisSpec thnAxisMassLambdaC{configAxisMassLambdaC, "inv. mass (p K #pi) (GeV/#it{c}^{2})"}; - const AxisSpec thnAxisPtLambdaC{thnConfigAxisPt, "#it{p}_{T}(#Lambda_{c}^{+}) (GeV/#it{c})"}; - const AxisSpec thnAxisPtSigmaC{thnConfigAxisPt, "#it{p}_{T}(#Sigma_{c}^{0,++}) (GeV/#it{c})"}; - const AxisSpec thnAxisDecLength{thnConfigAxisDecLength, "decay length #Lambda_{c}^{+} (cm)"}; - const AxisSpec thnAxisDecLengthXY{thnConfigAxisDecLengthXY, "decay length XY #Lambda_{c}^{+} (cm)"}; - const AxisSpec thnAxisCPA{thnConfigAxisCPA, "cosine of pointing angle #Lambda_{c}^{+}"}; - const AxisSpec thnAxisCPAXY{thnConfigAxisCPAXY, "cosine of pointing angle XY #Lambda_{c}^{+}"}; - const AxisSpec thnAxisOriginMc{3, -0.5, 2.5, "0: none, 1: prompt, 2: non-prompt"}; - const AxisSpec thnAxisChargeSigmaC{3, -0.5, 2.5, "#Sigma_{c}-baryon charge"}; - const AxisSpec thnAxisChannel{4, -0.5, 3.5, "0: direct 1,2,3: resonant"}; - const AxisSpec thnAxisBdtScoreLcBkg{thnConfigAxisBdtScoreLcBkg, "BDT bkg score (Lc)"}; - const AxisSpec thnAxisBdtScoreLcNonPrompt{thnConfigAxisBdtScoreLcNonPrompt, "BDT non-prompt score (Lc)"}; - if (doprocessDataWithMl || doprocessMcWithMl) { - registry.add("hnLambdaC", "THn for Lambdac", HistType::kTHnSparseF, {thnAxisPtLambdaC, thnAxisMassLambdaC, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcNonPrompt, thnAxisOriginMc, thnAxisChannel}); - registry.add("hnSigmaC", "THn for Sigmac", HistType::kTHnSparseF, {thnAxisPtLambdaC, axisDeltaMassSigmaC, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcNonPrompt, thnAxisOriginMc, thnAxisChannel, thnAxisPtSigmaC, thnAxisChargeSigmaC}); + std::vector axesLambdaCWithMl = {thnAxisPtLambdaC, thnAxisMassLambdaC, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcNonPrompt, thnAxisOriginMc, thnAxisChannel}; + std::vector axesSigmaCWithMl = {thnAxisPtLambdaC, axisDeltaMassSigmaC, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcNonPrompt, thnAxisOriginMc, thnAxisChannel, thnAxisPtSigmaC, thnAxisChargeSigmaC}; + std::vector axesLambdaCWoMl = {thnAxisPtLambdaC, thnAxisMassLambdaC, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisCPAXY, thnAxisOriginMc, thnAxisChannel}; + std::vector axesSigmaCWoMl = {thnAxisPtLambdaC, axisDeltaMassSigmaC, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisCPAXY, thnAxisOriginMc, thnAxisChannel, thnAxisPtSigmaC, thnAxisChargeSigmaC}; + if (isMc) { + registry.add("MC/generated/hnLambdaCGen", "THn for Lambdac gen", HistType::kTHnSparseF, {thnAxisGenPtLambdaC, thnAxisGenPtLambdaCBMother, thnAxisOriginMc, thnAxisChannel}); + registry.add("MC/generated/hnSigmaCGen", "THn for Sigmac gen", HistType::kTHnSparseF, {thnAxisGenPtSigmaC, thnAxisGenPtSigmaCBMother, thnAxisOriginMc, thnAxisChannel, thnAxisGenPtLambdaC, thnAxisChargeSigmaC, thnAxisGenSigmaCSpecies, thnAxisSigmaCParticleAntiparticle}); + if (doprocessMcWithMl) { + axesLambdaCWithMl.push_back(thnAxisGenPtLambdaCBMother); + axesSigmaCWithMl.push_back(thnAxisGenPtSigmaCBMother); + axesSigmaCWithMl.push_back(thnAxisGenSigmaCSpecies); + axesSigmaCWithMl.push_back(thnAxisSigmaCParticleAntiparticle); + if (addSoftPiDcaToSigmacSparse) { + axesSigmaCWithMl.push_back(thnAxisSoftPiAbsDcaXY); + axesSigmaCWithMl.push_back(thnAxisSoftPiAbsDcaZ); + } + registry.add("hnLambdaC", "THn for Lambdac", HistType::kTHnSparseF, axesLambdaCWithMl); + registry.add("hnSigmaC", "THn for Sigmac", HistType::kTHnSparseF, axesSigmaCWithMl); + } else { + axesLambdaCWoMl.push_back(thnAxisGenPtLambdaCBMother); + axesSigmaCWoMl.push_back(thnAxisGenPtSigmaCBMother); + axesSigmaCWoMl.push_back(thnAxisGenSigmaCSpecies); + axesSigmaCWoMl.push_back(thnAxisSigmaCParticleAntiparticle); + if (addSoftPiDcaToSigmacSparse) { + axesSigmaCWoMl.push_back(thnAxisSoftPiAbsDcaXY); + axesSigmaCWoMl.push_back(thnAxisSoftPiAbsDcaZ); + } + registry.add("hnLambdaC", "THn for Lambdac", HistType::kTHnSparseF, axesLambdaCWoMl); + registry.add("hnSigmaC", "THn for Sigmac", HistType::kTHnSparseF, axesSigmaCWoMl); + } } else { - registry.add("hnLambdaC", "THn for Lambdac", HistType::kTHnSparseF, {thnAxisPtLambdaC, thnAxisMassLambdaC, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisCPAXY, thnAxisOriginMc, thnAxisChannel}); - registry.add("hnSigmaC", "THn for Sigmac", HistType::kTHnSparseF, {thnAxisPtLambdaC, axisDeltaMassSigmaC, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisCPAXY, thnAxisOriginMc, thnAxisChannel, thnAxisPtSigmaC, thnAxisChargeSigmaC}); + if (doprocessDataWithMl) { + if (addSoftPiDcaToSigmacSparse) { + axesSigmaCWithMl.push_back(thnAxisSoftPiAbsDcaXY); + axesSigmaCWithMl.push_back(thnAxisSoftPiAbsDcaZ); + } + registry.add("hnLambdaC", "THn for Lambdac", HistType::kTHnSparseF, axesLambdaCWithMl); + registry.add("hnSigmaC", "THn for Sigmac", HistType::kTHnSparseF, axesSigmaCWithMl); + } else { + if (addSoftPiDcaToSigmacSparse) { + axesSigmaCWoMl.push_back(thnAxisSoftPiAbsDcaXY); + axesSigmaCWoMl.push_back(thnAxisSoftPiAbsDcaZ); + } + registry.add("hnLambdaC", "THn for Lambdac", HistType::kTHnSparseF, axesLambdaCWoMl); + registry.add("hnSigmaC", "THn for Sigmac", HistType::kTHnSparseF, axesSigmaCWoMl); + } } } @@ -273,16 +347,16 @@ struct HfTaskSigmac { /// @param candSc Sc candidate /// @return 0: none; 1: only Λc+ → pK-π+ possible; 2: Λc+ → π+K-p possible; 3: both possible template - int isDecayToPKPiToPiKP(L& candidateLc, S& candSc) + int8_t isDecayToPKPiToPiKP(L& candidateLc, S& candSc) { - int channel = 0; + int8_t channel = 0; if ((candidateLc.isSelLcToPKPi() >= 1) && candSc.statusSpreadLcMinvPKPiFromPDG()) { // Λc+ → pK-π+ and within the requested mass to build the Σc0,++ - channel += 1; + SETBIT(channel, o2::aod::hf_cand_sigmac::Decays::PKPi); } if ((candidateLc.isSelLcToPiKP() >= 1) && candSc.statusSpreadLcMinvPiKPFromPDG()) { // Λc+ → π+K-p and within the requested mass to build the Σc0,++ - channel += 2; + SETBIT(channel, o2::aod::hf_cand_sigmac::Decays::PiKP); } return channel; /// 0: none; 1: pK-π+ only; 2: π+K-p only; 3: both possible } @@ -299,6 +373,12 @@ struct HfTaskSigmac { /// loop over the candidate Σc0,++ for (const auto& candSc : candidatesSc) { + /// rapidity selection on Σc0,++ + /// NB: since in data we cannot tag Sc(2455) and Sc(2520), then we use only Sc(2455) for y selection on reconstructed signal + if (yCandRecoMax >= 0. && std::abs(hfHelper.ySc0(candSc)) > yCandRecoMax && std::abs(hfHelper.yScPlusPlus(candSc)) > yCandRecoMax) { + continue; + } + const int8_t chargeSc = candSc.charge(); // either Σc0 or Σc++ /// get the candidate Λc+ used to build the candidate Σc0,++ @@ -306,7 +386,7 @@ struct HfTaskSigmac { const auto& candidateLc = candSc.prongLc_as(); // const int iscandidateLcpKpi = (candidateLc.isSelLcToPKPi() >= 1) && candSc.statusSpreadLcMinvPKPiFromPDG(); // Λc+ → pK-π+ and within the requested mass to build the Σc0,++ // const int iscandidateLcpiKp = (candidateLc.isSelLcToPiKP() >= 1) && candSc.statusSpreadLcMinvPiKPFromPDG(); // Λc+ → π+K-p and within the requested mass to build the Σc0,++ - const int isCandPKPiPiKP = isDecayToPKPiToPiKP(candidateLc, candSc); + const int8_t isCandPKPiPiKP = isDecayToPKPiToPiKP(candidateLc, candSc); double massSc(-1.), massLc(-1.), deltaMass(-1.); double ptSc(candSc.pt()), ptLc(candidateLc.pt()); double etaSc(candSc.eta()), etaLc(candidateLc.eta()); @@ -315,12 +395,12 @@ struct HfTaskSigmac { double decLengthLc(candidateLc.decayLength()), decLengthXYLc(candidateLc.decayLengthXY()); double cpaLc(candidateLc.cpa()), cpaXYLc(candidateLc.cpaXY()); /// candidate Λc+ → pK-π+ (and charge conjugate) within the range of M(pK-π+) chosen in the Σc0,++ builder - if (isCandPKPiPiKP == 1 || isCandPKPiPiKP == 3) { + if (TESTBIT(isCandPKPiPiKP, o2::aod::hf_cand_sigmac::Decays::PKPi)) { massSc = hfHelper.invMassScRecoLcToPKPi(candSc, candidateLc); massLc = hfHelper.invMassLcToPKPi(candidateLc); deltaMass = massSc - massLc; /// fill the histograms - if (chargeSc == 0) { + if (chargeSc == o2::aod::hf_cand_sigmac::ChargeNull) { registry.fill(HIST("Data/hPtSc0"), ptSc); registry.fill(HIST("Data/hEtaSc0"), etaSc); registry.fill(HIST("Data/hPhiSc0"), phiSc); @@ -371,6 +451,8 @@ struct HfTaskSigmac { if (enableTHn) { if (!isMc) { /// fill it only if no MC operations are enabled, otherwise fill it in the processMC with the right origin and channel! + const float softPiAbsDcaXY = std::abs(candSc.softPiDcaXY()); + const float softPiAbsDcaZ = std::abs(candSc.softPiDcaZ()); if constexpr (useMl) { /// fill with ML information /// BDT index 0: bkg score; BDT index 2: non-prompt score @@ -379,21 +461,29 @@ struct HfTaskSigmac { outputMl.at(0) = candidateLc.mlProbLcToPKPi()[0]; /// bkg score outputMl.at(1) = candidateLc.mlProbLcToPKPi()[2]; /// non-prompt score } - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), 0, 0, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), 0, 0, ptSc, std::abs(chargeSc), softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), 0, 0, ptSc, std::abs(chargeSc)); + } } else { /// fill w/o BDT information - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, 0, 0, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, 0, 0, ptSc, std::abs(chargeSc), softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, 0, 0, ptSc, std::abs(chargeSc)); + } } } } } /// end candidate Λc+ → pK-π+ (and charge conjugate) /// candidate Λc+ → π+K-p (and charge conjugate) within the range of M(π+K-p) chosen in the Σc0,++ builder - if (isCandPKPiPiKP == 2 || isCandPKPiPiKP == 3) { + if (TESTBIT(isCandPKPiPiKP, o2::aod::hf_cand_sigmac::Decays::PiKP)) { massSc = hfHelper.invMassScRecoLcToPiKP(candSc, candidateLc); massLc = hfHelper.invMassLcToPiKP(candidateLc); deltaMass = massSc - massLc; /// fill the histograms - if (chargeSc == 0) { + if (chargeSc == o2::aod::hf_cand_sigmac::ChargeNull) { registry.fill(HIST("Data/hPtSc0"), ptSc); registry.fill(HIST("Data/hEtaSc0"), etaSc); registry.fill(HIST("Data/hPhiSc0"), phiSc); @@ -444,6 +534,8 @@ struct HfTaskSigmac { if (enableTHn) { if (!isMc) { /// fill it only if no MC operations are enabled, otherwise fill it in the processMC with the right origin and channel! + const float softPiAbsDcaXY = std::abs(candSc.softPiDcaXY()); + const float softPiAbsDcaZ = std::abs(candSc.softPiDcaZ()); if constexpr (useMl) { /// fill with ML information /// BDT index 0: bkg score; BDT index 2: non-prompt score @@ -452,15 +544,23 @@ struct HfTaskSigmac { outputMl.at(0) = candidateLc.mlProbLcToPiKP()[0]; /// bkg score outputMl.at(1) = candidateLc.mlProbLcToPiKP()[2]; /// non-prompt score } - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), 0, 0, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), 0, 0, ptSc, std::abs(chargeSc), softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), 0, 0, ptSc, std::abs(chargeSc)); + } } else { /// fill w/o BDT information - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, 0, 0, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, 0, 0, ptSc, std::abs(chargeSc), softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, 0, 0, ptSc, std::abs(chargeSc)); + } } } } } /// end candidate Λc+ → π+K-p (and charge conjugate) - } /// end loop over the candidate Σc0,++ + } /// end loop over the candidate Σc0,++ /// THn for candidate Λc+ cut variation w/o Σc0,++ mass-window cut if (enableTHn) { @@ -507,7 +607,7 @@ struct HfTaskSigmac { } } } /// end THn for candidate Λc+ cut variation w/o Σc0,++ mass-window cut - }; /// end fillHistosData + }; /// end fillHistosData /// @brief function to fill the histograms needed in analysis (MC) /// @param candidatesSc are the reconstructed candidate Σc0,++ with MC info @@ -522,13 +622,15 @@ struct HfTaskSigmac { aod::TracksWMc const&) { - /// MC generated particles + /// loop over Sc generated particles for (const auto& particle : mcParticlesSc) { /// reject immediately particles different from Σc0,++ - bool isSc0Gen = (std::abs(particle.flagMcMatchGen()) == (1 << aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi)); - bool isScPlusPlusGen = (std::abs(particle.flagMcMatchGen()) == (1 << aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi)); - if (!isSc0Gen && !isScPlusPlusGen) + bool isSc0Gen = (std::abs(particle.flagMcMatchGen()) == BIT(aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi)); + bool isScStar0Gen = (std::abs(particle.flagMcMatchGen()) == BIT(aod::hf_cand_sigmac::DecayType::ScStar0ToPKPiPi)); + bool isScPlusPlusGen = (std::abs(particle.flagMcMatchGen()) == BIT(aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi)); + bool isScStarPlusPlusGen = (std::abs(particle.flagMcMatchGen()) == BIT(aod::hf_cand_sigmac::DecayType::ScStarPlusPlusToPKPiPi)); + if (!isSc0Gen && !isScPlusPlusGen && !isScStar0Gen && !isScStarPlusPlusGen) continue; /// look for generated particles in acceptance @@ -542,16 +644,29 @@ struct HfTaskSigmac { OR consider the new parametrization of the fiducial acceptance (to be seen for reco signal in MC) */ - if (yCandMax >= 0. && std::abs(RecoDecay::y(particle.pVector(), o2::constants::physics::MassSigmaC0)) > yCandMax) { - continue; + if (yCandGenMax >= 0.) { + double mass = -1; + if (isSc0Gen) { + mass = o2::constants::physics::MassSigmaC0; + } else if (isScPlusPlusGen) { + mass = o2::constants::physics::MassSigmaCPlusPlus; + } else if (isScStar0Gen) { + mass = o2::constants::physics::MassSigmaCStar0; + } else if (isScStarPlusPlusGen) { + mass = o2::constants::physics::MassSigmaCStarPlusPlus; + } + if (mass > -1. && std::abs(RecoDecay::y(particle.pVector(), mass)) > yCandGenMax) { + continue; + } } /// Get the kinematic information of Σc0,++ and the daughters /// Get information about origin (prompt, non-prompt) /// Get information about decay Λc+ channel (direct, resonant) double ptGenSc(particle.pt()), etaGenSc(particle.eta()), phiGenSc(particle.phi()); + double ptGenScBMother(-1.); auto arrayDaughtersIds = particle.daughtersIds(); - if (arrayDaughtersIds.size() != 2) { + if (arrayDaughtersIds.size() != NDaughters) { /// This should never happen LOG(fatal) << "generated Σc0,++ has a number of daughter particles different than 2"; continue; @@ -561,7 +676,8 @@ struct HfTaskSigmac { double phiGenLc(-1.), phiGenSoftPi(-1.); int origin = -1; int8_t channel = -1; - if (std::abs(arrayDaughtersIds[0]) == o2::constants::physics::Pdg::kLambdaCPlus) { + auto daughter0 = mcParticles.rawIteratorAt(arrayDaughtersIds[0]); + if (std::abs(daughter0.pdgCode()) == o2::constants::physics::Pdg::kLambdaCPlus) { /// daughter 0 is the Λc+, daughter 1 the soft π auto daugLc = mcParticlesLc.rawIteratorAt(arrayDaughtersIds[0]); auto daugSoftPi = mcParticles.rawIteratorAt(arrayDaughtersIds[1]); @@ -573,7 +689,7 @@ struct HfTaskSigmac { ptGenSoftPi = daugSoftPi.pt(); etaGenSoftPi = daugSoftPi.eta(); phiGenSoftPi = daugSoftPi.phi(); - } else if (std::abs(arrayDaughtersIds[0]) == kPiPlus) { + } else if (std::abs(daughter0.pdgCode()) == kPiPlus) { /// daughter 0 is the soft π, daughter 1 the Λc+ auto daugLc = mcParticlesLc.rawIteratorAt(arrayDaughtersIds[1]); auto daugSoftPi = mcParticles.rawIteratorAt(arrayDaughtersIds[0]); @@ -588,7 +704,13 @@ struct HfTaskSigmac { } /// Fill histograms - if (isSc0Gen) { + int sigmacSpecies = -1; + if (isSc0Gen || isScPlusPlusGen) { + sigmacSpecies = o2::aod::hf_cand_sigmac::Sc2455; + } else if (isScStar0Gen || isScStarPlusPlusGen) { + sigmacSpecies = o2::aod::hf_cand_sigmac::Sc2520; + } + if (isSc0Gen || isScStar0Gen) { /// Generated Σc0 and Λc+ ← Σc0 signals registry.fill(HIST("MC/generated/hPtGenSc0Sig"), ptGenSc, origin, channel); registry.fill(HIST("MC/generated/hEtaGenSc0Sig"), etaGenSc, origin, channel); @@ -609,7 +731,21 @@ struct HfTaskSigmac { registry.fill(HIST("MC/generated/hPtGenLcFromSc0PlusPlusSig"), ptGenLc, origin, channel); registry.fill(HIST("MC/generated/hEtaGenLcFromSc0PlusPlusSig"), etaGenLc, origin, channel); registry.fill(HIST("MC/generated/hPhiGenLcFromSc0PlusPlusSig"), phiGenLc, origin, channel); /// Generated Λc+ ← Σc0,++ signal - } else if (isScPlusPlusGen) { + int8_t particleAntiparticle = particle.particleAntiparticle(); + if (origin == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("MC/generated/hnSigmaCGen"), ptGenSc, ptGenScBMother, origin, channel, ptGenLc, 0, sigmacSpecies, particleAntiparticle); + } else { + ptGenScBMother = mcParticlesSc.rawIteratorAt(particle.idxBhadMotherPart()).pt(); + registry.fill(HIST("MC/generated/hnSigmaCGen"), ptGenSc, ptGenScBMother, origin, channel, ptGenLc, 0, sigmacSpecies, particleAntiparticle); + } + + // debug -- uncomment if needed + // it should be solved after the implementation of ev. selection for generated SigmaC particles + // if(origin != RecoDecay::OriginType::Prompt && origin != RecoDecay::OriginType::NonPrompt) { + // LOG(info) << " --> (Sc0 gen) origin " << static_cast(origin) << ", particle.originMcGen() " << static_cast(particle.originMcGen()) << ", particle.flagMcMatchGen() " << static_cast(particle.flagMcMatchGen()) << ", pdg " << particle.pdgCode(); + //} + + } else if (isScPlusPlusGen || isScStarPlusPlusGen) { /// Generated Σc++ and Λc+ ← Σc++ signals registry.fill(HIST("MC/generated/hPtGenScPlusPlusSig"), ptGenSc, origin, channel); registry.fill(HIST("MC/generated/hEtaGenScPlusPlusSig"), etaGenSc, origin, channel); @@ -630,19 +766,53 @@ struct HfTaskSigmac { registry.fill(HIST("MC/generated/hPtGenLcFromSc0PlusPlusSig"), ptGenLc, origin, channel); registry.fill(HIST("MC/generated/hEtaGenLcFromSc0PlusPlusSig"), etaGenLc, origin, channel); registry.fill(HIST("MC/generated/hPhiGenLcFromSc0PlusPlusSig"), phiGenLc, origin, channel); /// Generated Λc+ ← Σc0,++ signal + int8_t particleAntiparticle = particle.particleAntiparticle(); + if (origin == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("MC/generated/hnSigmaCGen"), ptGenSc, ptGenScBMother, origin, channel, ptGenLc, 2, sigmacSpecies, particleAntiparticle); + } else { + ptGenScBMother = mcParticlesSc.rawIteratorAt(particle.idxBhadMotherPart()).pt(); + registry.fill(HIST("MC/generated/hnSigmaCGen"), ptGenSc, ptGenScBMother, origin, channel, ptGenLc, 2, sigmacSpecies, particleAntiparticle); + } + + // debug -- uncomment if needed + // it should be solved after the implementation of ev. selection for generated SigmaC particles + // if(origin != RecoDecay::OriginType::Prompt && origin != RecoDecay::OriginType::NonPrompt) { + // LOG(info) << " --> (Sc++ gen) origin " << static_cast(origin) << ", particle.originMcGen() " << static_cast(particle.originMcGen()) << ", particle.flagMcMatchGen() " << static_cast(particle.flagMcMatchGen()) << ", pdg " << particle.pdgCode(); + //} } - } /// end loop over generated particles + } /// end loop over Sc generated particles + + /// loop over Lc generated particles + for (const auto& particle : mcParticlesLc) { + if (std::abs(particle.flagMcMatchGen()) != hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + continue; + } + if (yCandGenMax >= 0. && std::abs(RecoDecay::y(particle.pVector(), o2::constants::physics::MassLambdaCPlus)) > yCandGenMax) { + continue; + } + double ptGenLc(particle.pt()), ptGenLcBMother(-1.); + int origin = particle.originMcGen(); + int channel = particle.flagMcDecayChanGen(); + if (origin == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("MC/generated/hnLambdaCGen"), ptGenLc, ptGenLcBMother, origin, channel); + } else { + ptGenLcBMother = mcParticlesLc.rawIteratorAt(particle.idxBhadMotherPart()).pt(); + registry.fill(HIST("MC/generated/hnLambdaCGen"), ptGenLc, ptGenLcBMother, origin, channel); + } + } /// end loop over Lc generated particles /// reconstructed Σc0,++ matched to MC for (const auto& candSc : candidatesSc) { /// Candidate selected as Σc0 and/or Σc++ - if (!(candSc.hfflag() & 1 << aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi) && !(candSc.hfflag() & 1 << aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi)) { + if (!(candSc.hfflag() & BIT(aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi)) && !(candSc.hfflag() & BIT(aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi)) && // Σc0,++(2455) + !(candSc.hfflag() & BIT(aod::hf_cand_sigmac::DecayType::ScStar0ToPKPiPi)) && !(candSc.hfflag() & BIT(aod::hf_cand_sigmac::DecayType::ScStarPlusPlusToPKPiPi))) { // Σc0,++(2520) continue; } /// rapidity selection on Σc0,++ - if (yCandMax >= 0. && std::abs(hfHelper.ySc0(candSc)) > yCandMax && std::abs(hfHelper.yScPlusPlus(candSc)) > yCandMax) { + /// NB: since in data we cannot tag Sc(2455) and Sc(2520), then we use only Sc(2455) for y selection on reconstructed signal + if (yCandRecoMax >= 0. && std::abs(hfHelper.ySc0(candSc)) > yCandRecoMax && std::abs(hfHelper.yScPlusPlus(candSc)) > yCandRecoMax) { continue; } @@ -652,14 +822,28 @@ struct HfTaskSigmac { /// get the candidate Λc+ used to build the Σc0 /// and understand which mass hypotheses are possible const auto& candidateLc = candSc.prongLc_as(); - const int isCandPKPiPiKP = isDecayToPKPiToPiKP(candidateLc, candSc); + const int8_t isCandPKPiPiKP = isDecayToPKPiToPiKP(candidateLc, candSc); // candidateLc.flagMcDecayChanRec(); - /// Reconstructed Σc0 signal - if (std::abs(candSc.flagMcMatchRec()) == 1 << aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi && (chargeSc == 0)) { + bool isTrueSc0Reco = std::abs(candSc.flagMcMatchRec()) == BIT(aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi); + bool isTrueScStar0Reco = std::abs(candSc.flagMcMatchRec()) == BIT(aod::hf_cand_sigmac::DecayType::ScStar0ToPKPiPi); + bool isTrueScPlusPlusReco = std::abs(candSc.flagMcMatchRec()) == BIT(aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi); + bool isTrueScStarPlusPlusReco = std::abs(candSc.flagMcMatchRec()) == BIT(aod::hf_cand_sigmac::DecayType::ScStarPlusPlusToPKPiPi); + int sigmacSpecies = -1; + if ((isTrueSc0Reco || isTrueScStar0Reco) && (chargeSc == o2::aod::hf_cand_sigmac::ChargeNull)) { + /// Reconstructed Σc0 signal // Get the corresponding MC particle for Sc, found as the mother of the soft pion - auto indexMcScRec = RecoDecay::getMother(mcParticles, candSc.prong1_as().mcParticle(), o2::constants::physics::Pdg::kSigmaC0, true); + int indexMcScRec = -1; + if (isTrueSc0Reco) { + // Σc0(2455) + indexMcScRec = RecoDecay::getMother(mcParticles, candSc.prong1_as().mcParticle(), o2::constants::physics::Pdg::kSigmaC0, true); + sigmacSpecies = o2::aod::hf_cand_sigmac::Sc2455; + } else if (isTrueScStar0Reco) { + // Σc0(2520) + indexMcScRec = RecoDecay::getMother(mcParticles, candSc.prong1_as().mcParticle(), o2::constants::physics::Pdg::kSigmaCStar0, true); + sigmacSpecies = o2::aod::hf_cand_sigmac::Sc2520; + } auto particleSc = mcParticles.rawIteratorAt(indexMcScRec); // Get the corresponding MC particle for Lc auto arrayDaughtersLc = std::array{candidateLc.template prong0_as(), candidateLc.template prong1_as(), candidateLc.template prong2_as()}; @@ -683,7 +867,7 @@ struct HfTaskSigmac { auto channel = candidateLc.flagMcDecayChanRec(); /// 0: direct; 1: Λc± → p± K*; 2: Λc± → Δ(1232)±± K∓; 3: Λc± → Λ(1520) π± /// candidate Λc+ → pK-π+ (and charge conjugate) within the range of M(pK-π+) chosen in the Σc0,++ builder - if ((isCandPKPiPiKP == 1 || isCandPKPiPiKP == 3) && std::abs(candidateLc.template prong0_as().mcParticle().pdgCode()) == kProton) { + if ((TESTBIT(isCandPKPiPiKP, o2::aod::hf_cand_sigmac::Decays::PKPi)) && std::abs(candidateLc.template prong0_as().mcParticle().pdgCode()) == kProton) { massSc = hfHelper.invMassScRecoLcToPKPi(candSc, candidateLc); massLc = hfHelper.invMassLcToPKPi(candidateLc); deltaMass = massSc - massLc; @@ -740,6 +924,9 @@ struct HfTaskSigmac { /// THn for candidate Σc0,++ cut variation if (enableTHn) { + int8_t particleAntiparticle = candSc.particleAntiparticle(); + const float softPiAbsDcaXY = std::abs(candSc.softPiDcaXY()); + const float softPiAbsDcaZ = std::abs(candSc.softPiDcaZ()); if constexpr (useMl) { /// fill with ML information /// BDT index 0: bkg score; BDT index 2: non-prompt score @@ -748,16 +935,24 @@ struct HfTaskSigmac { outputMl.at(0) = candidateLc.mlProbLcToPKPi()[0]; /// bkg score outputMl.at(1) = candidateLc.mlProbLcToPKPi()[2]; /// non-prompt score } - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle, softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle); + } } else { /// fill w/o BDT information - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle, softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle); + } } } } /// end candidate Λc+ → pK-π+ (and charge conjugate) /// candidate Λc+ → π+K-p (and charge conjugate) within the range of M(π+K-p) chosen in the Σc0,++ builder - if ((isCandPKPiPiKP == 2 || isCandPKPiPiKP == 3) && std::abs(candidateLc.template prong0_as().mcParticle().pdgCode()) == kPiPlus) { + if ((TESTBIT(isCandPKPiPiKP, o2::aod::hf_cand_sigmac::Decays::PiKP)) && std::abs(candidateLc.template prong0_as().mcParticle().pdgCode()) == kPiPlus) { massSc = hfHelper.invMassScRecoLcToPiKP(candSc, candidateLc); massLc = hfHelper.invMassLcToPiKP(candidateLc); deltaMass = massSc - massLc; @@ -814,6 +1009,9 @@ struct HfTaskSigmac { /// THn for candidate Σc0,++ cut variation if (enableTHn) { + int8_t particleAntiparticle = candSc.particleAntiparticle(); + const float softPiAbsDcaXY = std::abs(candSc.softPiDcaXY()); + const float softPiAbsDcaZ = std::abs(candSc.softPiDcaZ()); if constexpr (useMl) { /// fill with ML information /// BDT index 0: bkg score; BDT index 2: non-prompt score @@ -822,19 +1020,36 @@ struct HfTaskSigmac { outputMl.at(0) = candidateLc.mlProbLcToPiKP()[0]; /// bkg score outputMl.at(1) = candidateLc.mlProbLcToPiKP()[2]; /// non-prompt score } - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle, softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle); + } } else { /// fill w/o BDT information - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle, softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle); + } } } } /// end candidate Λc+ → π+K-p (and charge conjugate) /// end reconstructed Σc0 signal - } else if (std::abs(candSc.flagMcMatchRec()) == 1 << aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi && (std::abs(chargeSc) == 2)) { + } else if ((isTrueScPlusPlusReco || isTrueScStarPlusPlusReco) && (std::abs(chargeSc) == o2::aod::hf_cand_sigmac::ChargePlusPlus)) { /// Reconstructed Σc++ signal // Get the corresponding MC particle for Sc, found as the mother of the soft pion - auto indexMcScRec = RecoDecay::getMother(mcParticles, candSc.prong1_as().mcParticle(), o2::constants::physics::Pdg::kSigmaCPlusPlus, true); + int indexMcScRec = -1; + if (isTrueScPlusPlusReco) { + // Σc0(2455) + indexMcScRec = RecoDecay::getMother(mcParticles, candSc.prong1_as().mcParticle(), o2::constants::physics::Pdg::kSigmaCPlusPlus, true); + sigmacSpecies = o2::aod::hf_cand_sigmac::Sc2455; + } else if (isTrueScStarPlusPlusReco) { + // Σc0(2520) + indexMcScRec = RecoDecay::getMother(mcParticles, candSc.prong1_as().mcParticle(), o2::constants::physics::Pdg::kSigmaCStarPlusPlus, true); + sigmacSpecies = o2::aod::hf_cand_sigmac::Sc2520; + } auto particleSc = mcParticles.rawIteratorAt(indexMcScRec); // Get the corresponding MC particle for Lc auto arrayDaughtersLc = std::array{candidateLc.template prong0_as(), candidateLc.template prong1_as(), candidateLc.template prong2_as()}; @@ -855,10 +1070,10 @@ struct HfTaskSigmac { double decLengthLc(candidateLc.decayLength()), decLengthXYLc(candidateLc.decayLengthXY()); double cpaLc(candidateLc.cpa()), cpaXYLc(candidateLc.cpaXY()); int origin = candSc.originMcRec(); - auto channel = candidateLc.flagMcDecayChanRec(); /// 0: direct; 1: Λc± → p± K*; 2: Λc± → Δ(1232)±± K∓; 3: Λc± → Λ(1520) π± + auto channel = candidateLc.flagMcDecayChanRec(); /// 0: direct; 1: Λc± → p± K*; 2: Λc± → Δ(1232)±± K∓; 3: Λc± → Λ(1520) π±; FIXME: DecayChannelResonant /// candidate Λc+ → pK-π+ (and charge conjugate) within the range of M(pK-π+) chosen in the Σc0,++ builder - if ((isCandPKPiPiKP == 1 || isCandPKPiPiKP == 3) && std::abs(candidateLc.template prong0_as().mcParticle().pdgCode()) == kProton) { + if ((TESTBIT(isCandPKPiPiKP, o2::aod::hf_cand_sigmac::Decays::PKPi)) && std::abs(candidateLc.template prong0_as().mcParticle().pdgCode()) == kProton) { massSc = hfHelper.invMassScRecoLcToPKPi(candSc, candidateLc); massLc = hfHelper.invMassLcToPKPi(candidateLc); deltaMass = massSc - massLc; @@ -915,6 +1130,9 @@ struct HfTaskSigmac { /// THn for candidate Σc0,++ cut variation if (enableTHn) { + int8_t particleAntiparticle = candSc.particleAntiparticle(); + const float softPiAbsDcaXY = std::abs(candSc.softPiDcaXY()); + const float softPiAbsDcaZ = std::abs(candSc.softPiDcaZ()); if constexpr (useMl) { /// fill with ML information /// BDT index 0: bkg score; BDT index 2: non-prompt score @@ -923,16 +1141,24 @@ struct HfTaskSigmac { outputMl.at(0) = candidateLc.mlProbLcToPKPi()[0]; /// bkg score outputMl.at(1) = candidateLc.mlProbLcToPKPi()[2]; /// non-prompt score } - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle, softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle); + } } else { /// fill w/o BDT information - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle, softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle); + } } } } /// end candidate Λc+ → pK-π+ (and charge conjugate) /// candidate Λc+ → π+K-p (and charge conjugate) within the range of M(π+K-p) chosen in the Σc0,++ builder - if ((isCandPKPiPiKP == 2 || isCandPKPiPiKP == 3) && std::abs(candidateLc.template prong0_as().mcParticle().pdgCode()) == kPiPlus) { + if ((TESTBIT(isCandPKPiPiKP, o2::aod::hf_cand_sigmac::Decays::PiKP)) && std::abs(candidateLc.template prong0_as().mcParticle().pdgCode()) == kPiPlus) { massSc = hfHelper.invMassScRecoLcToPiKP(candSc, candidateLc); massLc = hfHelper.invMassLcToPiKP(candidateLc); deltaMass = massSc - massLc; @@ -987,6 +1213,9 @@ struct HfTaskSigmac { /// THn for candidate Σc0,++ cut variation if (enableTHn) { + int8_t particleAntiparticle = candSc.particleAntiparticle(); + const float softPiAbsDcaXY = std::abs(candSc.softPiDcaXY()); + const float softPiAbsDcaZ = std::abs(candSc.softPiDcaZ()); if constexpr (useMl) { /// fill with ML information /// BDT index 0: bkg score; BDT index 2: non-prompt score @@ -995,15 +1224,23 @@ struct HfTaskSigmac { outputMl.at(0) = candidateLc.mlProbLcToPiKP()[0]; /// bkg score outputMl.at(1) = candidateLc.mlProbLcToPiKP()[2]; /// non-prompt score } - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle, softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, outputMl.at(0), outputMl.at(1), origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle); + } } else { /// fill w/o BDT information - registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc)); + if (addSoftPiDcaToSigmacSparse) { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle, softPiAbsDcaXY, softPiAbsDcaZ); + } else { + registry.get(HIST("hnSigmaC"))->Fill(ptLc, deltaMass, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, ptSc, std::abs(chargeSc), candSc.ptBhadMotherPart(), sigmacSpecies, particleAntiparticle); + } } } } /// end candidate Λc+ → π+K-p (and charge conjugate) - } /// end reconstructed Σc++ signal + } /// end reconstructed Σc++ signal } /// end loop on reconstructed Σc0,++ @@ -1011,7 +1248,7 @@ struct HfTaskSigmac { if (enableTHn) { /// loop over Λc+ candidates w/o Σc0,++ mass-window cut for (const auto& candidateLc : candidatesLc) { - if (!TESTBIT(std::abs(candidateLc.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::LcToPKPi)) { + if (std::abs(candidateLc.flagMcMatchRec()) != hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { continue; } double massLc(-1.); @@ -1034,10 +1271,10 @@ struct HfTaskSigmac { outputMl.at(0) = candidateLc.mlProbLcToPKPi()[0]; /// bkg score outputMl.at(1) = candidateLc.mlProbLcToPKPi()[2]; /// non-prompt score } - registry.get(HIST("hnLambdaC"))->Fill(ptLc, massLc, outputMl.at(0), outputMl.at(1), origin, channel); + registry.get(HIST("hnLambdaC"))->Fill(ptLc, massLc, outputMl.at(0), outputMl.at(1), origin, channel, candidateLc.ptBhadMotherPart()); } else { /// fill w/o BDT information - registry.get(HIST("hnLambdaC"))->Fill(ptLc, massLc, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel); + registry.get(HIST("hnLambdaC"))->Fill(ptLc, massLc, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, candidateLc.ptBhadMotherPart()); } } if (candidateLc.isSelLcToPiKP() >= 1 && pdgAbs == kPiPlus) { @@ -1050,10 +1287,10 @@ struct HfTaskSigmac { outputMl.at(0) = candidateLc.mlProbLcToPiKP()[0]; /// bkg score outputMl.at(1) = candidateLc.mlProbLcToPiKP()[2]; /// non-prompt score } - registry.get(HIST("hnLambdaC"))->Fill(ptLc, massLc, outputMl.at(0), outputMl.at(1), origin, channel); + registry.get(HIST("hnLambdaC"))->Fill(ptLc, massLc, outputMl.at(0), outputMl.at(1), origin, channel, candidateLc.ptBhadMotherPart()); } else { /// fill w/o BDT information - registry.get(HIST("hnLambdaC"))->Fill(ptLc, massLc, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel); + registry.get(HIST("hnLambdaC"))->Fill(ptLc, massLc, decLengthLc, decLengthXYLc, cpaLc, cpaXYLc, origin, channel, candidateLc.ptBhadMotherPart()); } } } diff --git a/PWGHF/D2H/Tasks/taskSigmacToCascade.cxx b/PWGHF/D2H/Tasks/taskSigmacToCascade.cxx index 821379003d7..fc527254dac 100644 --- a/PWGHF/D2H/Tasks/taskSigmacToCascade.cxx +++ b/PWGHF/D2H/Tasks/taskSigmacToCascade.cxx @@ -15,18 +15,24 @@ /// \author Rutuparna Rath , INFN BOLOGNA and GSI Darmstadt /// In collaboration with Andrea Alici , INFN BOLOGNA -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" - #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; diff --git a/PWGHF/D2H/Tasks/taskXic.cxx b/PWGHF/D2H/Tasks/taskXic.cxx index 613112f3279..8a07bfbe3bd 100644 --- a/PWGHF/D2H/Tasks/taskXic.cxx +++ b/PWGHF/D2H/Tasks/taskXic.cxx @@ -19,16 +19,35 @@ /// \author Himanshu Sharma , University and INFN Padova /// \author Cristina Terrevoli , INFN Bari -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -45,8 +64,13 @@ struct HfTaskXic { Configurable dcaZTrackMax{"dcaZTrackMax", 0.0025, "max. DCAz for track"}; Configurable> binsPt{"binsPt", std::vector{hf_cuts_xic_to_p_k_pi::vecBinsPt}, "pT bin limits"}; - // THnSparse for ML outputScores and Vars Configurable enableTHn{"enableTHn", false, "enable THn for Xic"}; + HfHelper hfHelper; + Service pdg; + + Filter filterSelectCandidates = (aod::hf_sel_candidate_xic::isSelXicToPKPi >= selectionFlagXic || aod::hf_sel_candidate_xic::isSelXicToPiKP >= selectionFlagXic); + + // THnSparse for ML outputScores and Vars ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {36, 0, 36}, ""}; ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {300, 1.98, 2.58}, ""}; ConfigurableAxis thnConfigAxisPtProng{"thnConfigAxisPtProng", {100, 0, 20}, ""}; @@ -58,26 +82,17 @@ struct HfTaskXic { ConfigurableAxis thnConfigAxisBdtScoreSignal{"thnConfigAxisBdtScoreSignal", {100, 0., 1.}, ""}; ConfigurableAxis thnConfigAxisYMC{"thnConfigAxisYMC", {100, -2., 2.}, ""}; // - Service pdg; - HfHelper hfHelper; float etaMaxAcceptance = 0.8; float ptMinAcceptance = 0.1; - using TracksWPid = soa::Join; - - Filter filterSelectCandidates = (aod::hf_sel_candidate_xic::isSelXicToPKPi >= selectionFlagXic || aod::hf_sel_candidate_xic::isSelXicToPiKP >= selectionFlagXic); - - Partition> selectedMCXicCandidates = (aod::hf_sel_candidate_xic::isSelXicToPKPi >= selectionFlagXic || aod::hf_sel_candidate_xic::isSelXicToPiKP >= selectionFlagXic); - HistogramRegistry registry{ "registry", // histo not in pt bins { {"Data/hPt", "3-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{360, 0., 36.}}}}, // pt Xic - {"Data/hEta", "3-prong candidates;candidate #it{eta};entries", {HistType::kTH1D, {{100, -5., 5.}}}}, // eta Xic + {"Data/hEta", "3-prong candidates;candidate #it{eta};entries", {HistType::kTH1D, {{100, -2., 2.}}}}, // eta Xic {"Data/hPhi", "3-prong candidates;candidate #varphi;entries", {HistType::kTH1D, {{72, 0., constants::math::TwoPI}}}}, // phi Xic - {"Data/hMass", "3-prong candidates; inv. mass (p K #pi) (GeV/#it{c}^{2})", {HistType::kTH1D, {{600, 2.18, 2.58}}}}, // mass Xic + {"Data/hMass", "3-prong candidates; inv. mass (p K #pi) (GeV/#it{c}^{2})", {HistType::kTH1D, {{600, 1.98, 2.58}}}}, // mass Xic {"Data/hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1D, {{1000, 0., 1000.}}}}, {"MC/generated/signal/hPtGenSig", "3-prong candidates (matched);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1D, {{360, 0., 36.}}}}, {"MC/generated/signal/hPtGen", "MC particles (matched);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1D, {{360, 0., 36.}}}}, @@ -235,9 +250,9 @@ struct HfTaskXic { const AxisSpec thnAxisMCAllProngAccepted{2, -0.5, 1.5, "All MC prongs accepted"}; if (doprocessDataWithMl || doprocessMcWithMl) { // with ML - registry.add("hnXicVarsWithBdt", "THn for Xic candidates with BDT scores", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisBdtScoreXicBkg, thnAxisBdtScoreXicPrompt, thnAxisBdtScoreXicNonPrompt, thnAxisMcOrigin, thnAxisPtMC, thnAxisYMC, thnAxisMCAllProngAccepted}); + registry.add("hnXicVarsWithBdt", "THn for Xic candidates with BDT scores", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisBdtScoreXicBkg, thnAxisBdtScoreXicPrompt, thnAxisBdtScoreXicNonPrompt, thnAxisMcOrigin}); } else { - registry.add("hnXicVars", "THn for Xic candidates", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisMcOrigin, thnAxisPtMC, thnAxisYMC, thnAxisMCAllProngAccepted}); + registry.add("hnXicVars", "THn for Xic candidates", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisMcOrigin}); } } } // end init @@ -254,7 +269,7 @@ struct HfTaskXic { template void analysisData(aod::Collision const& collision, Cands const& candidates, - TracksWPid const& tracks) + aod::TracksWDca const& tracks) { int nTracks = 0; @@ -314,86 +329,87 @@ struct HfTaskXic { registry.fill(HIST("Data/hChi2PCA"), candidate.chi2PCA(), ptCandidate); // PID histos - auto trackProng0 = candidate.template prong0_as(); - auto trackProng1 = candidate.template prong1_as(); - auto trackProng2 = candidate.template prong2_as(); + auto trackProng0 = candidate.template prong0_as(); + auto trackProng1 = candidate.template prong1_as(); + auto trackProng2 = candidate.template prong2_as(); auto momentumProng0 = trackProng0.p(); auto momentumProng1 = trackProng1.p(); auto momentumProng2 = trackProng2.p(); // TPC nSigma histograms - registry.fill(HIST("Data/hPVsTPCNSigmaPr_Prong0"), momentumProng0, trackProng0.tpcNSigmaPr()); - registry.fill(HIST("Data/hPVsTPCNSigmaPi_Prong0"), momentumProng0, trackProng0.tpcNSigmaPi()); - registry.fill(HIST("Data/hPVsTPCNSigmaKa_Prong0"), momentumProng0, trackProng0.tpcNSigmaKa()); + registry.fill(HIST("Data/hPVsTPCNSigmaPr_Prong0"), momentumProng0, candidate.nSigTpcPr0()); + registry.fill(HIST("Data/hPVsTPCNSigmaPi_Prong0"), momentumProng0, candidate.nSigTpcPi0()); + registry.fill(HIST("Data/hPVsTPCNSigmaKa_Prong0"), momentumProng0, candidate.nSigTpcKa0()); - registry.fill(HIST("Data/hPVsTPCNSigmaPr_Prong1"), momentumProng1, trackProng1.tpcNSigmaPr()); - registry.fill(HIST("Data/hPVsTPCNSigmaPi_Prong1"), momentumProng1, trackProng1.tpcNSigmaPi()); - registry.fill(HIST("Data/hPVsTPCNSigmaKa_Prong1"), momentumProng1, trackProng1.tpcNSigmaKa()); + registry.fill(HIST("Data/hPVsTPCNSigmaPr_Prong1"), momentumProng1, candidate.nSigTpcPr1()); + registry.fill(HIST("Data/hPVsTPCNSigmaPi_Prong1"), momentumProng1, candidate.nSigTpcPi1()); + registry.fill(HIST("Data/hPVsTPCNSigmaKa_Prong1"), momentumProng1, candidate.nSigTpcKa1()); - registry.fill(HIST("Data/hPVsTPCNSigmaPr_Prong2"), momentumProng2, trackProng2.tpcNSigmaPr()); - registry.fill(HIST("Data/hPVsTPCNSigmaPi_Prong2"), momentumProng2, trackProng2.tpcNSigmaPi()); - registry.fill(HIST("Data/hPVsTPCNSigmaKa_Prong2"), momentumProng2, trackProng2.tpcNSigmaKa()); + registry.fill(HIST("Data/hPVsTPCNSigmaPr_Prong2"), momentumProng2, candidate.nSigTpcPr2()); + registry.fill(HIST("Data/hPVsTPCNSigmaPi_Prong2"), momentumProng2, candidate.nSigTpcPi2()); + registry.fill(HIST("Data/hPVsTPCNSigmaKa_Prong2"), momentumProng2, candidate.nSigTpcKa2()); // TOF nSigma histograms - registry.fill(HIST("Data/hPVsTOFNSigmaPr_Prong0"), momentumProng0, trackProng0.tofNSigmaPr()); - registry.fill(HIST("Data/hPVsTOFNSigmaPi_Prong0"), momentumProng0, trackProng0.tofNSigmaPi()); - registry.fill(HIST("Data/hPVsTOFNSigmaKa_Prong0"), momentumProng0, trackProng0.tofNSigmaKa()); + registry.fill(HIST("Data/hPVsTOFNSigmaPr_Prong0"), momentumProng0, candidate.nSigTofPr0()); + registry.fill(HIST("Data/hPVsTOFNSigmaPi_Prong0"), momentumProng0, candidate.nSigTofPi0()); + registry.fill(HIST("Data/hPVsTOFNSigmaKa_Prong0"), momentumProng0, candidate.nSigTofKa0()); - registry.fill(HIST("Data/hPVsTOFNSigmaPr_Prong1"), momentumProng1, trackProng1.tofNSigmaPr()); - registry.fill(HIST("Data/hPVsTOFNSigmaPi_Prong1"), momentumProng1, trackProng1.tofNSigmaPi()); - registry.fill(HIST("Data/hPVsTOFNSigmaKa_Prong1"), momentumProng1, trackProng1.tofNSigmaKa()); + registry.fill(HIST("Data/hPVsTOFNSigmaPr_Prong1"), momentumProng1, candidate.nSigTofPr1()); + registry.fill(HIST("Data/hPVsTOFNSigmaPi_Prong1"), momentumProng1, candidate.nSigTofPi1()); + registry.fill(HIST("Data/hPVsTOFNSigmaKa_Prong1"), momentumProng1, candidate.nSigTofKa1()); - registry.fill(HIST("Data/hPVsTOFNSigmaPr_Prong2"), momentumProng2, trackProng2.tofNSigmaPr()); - registry.fill(HIST("Data/hPVsTOFNSigmaPi_Prong2"), momentumProng2, trackProng2.tofNSigmaPi()); - registry.fill(HIST("Data/hPVsTOFNSigmaKa_Prong2"), momentumProng2, trackProng2.tofNSigmaKa()); + registry.fill(HIST("Data/hPVsTOFNSigmaPr_Prong2"), momentumProng2, candidate.nSigTofPr2()); + registry.fill(HIST("Data/hPVsTOFNSigmaPi_Prong2"), momentumProng2, candidate.nSigTofPi2()); + registry.fill(HIST("Data/hPVsTOFNSigmaKa_Prong2"), momentumProng2, candidate.nSigTofKa2()); // THnSparse if (enableTHn) { double massXic(-1); double outputBkg(-1), outputPrompt(-1), outputFD(-1); + const int ternaryCl = 3; if (candidate.isSelXicToPKPi() >= selectionFlagXic) { massXic = hfHelper.invMassXicToPKPi(candidate); if constexpr (useMl) { - if (candidate.mlProbXicToPKPi().size() == 3) { + if (candidate.mlProbXicToPKPi().size() == ternaryCl) { outputBkg = candidate.mlProbXicToPKPi()[0]; /// bkg score outputPrompt = candidate.mlProbXicToPKPi()[1]; /// prompt score outputFD = candidate.mlProbXicToPKPi()[2]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate Xic - registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXic, ptCandidate, outputBkg, outputPrompt, outputFD, 0, 0.0, 0.0, false); + registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXic, ptCandidate, outputBkg, outputPrompt, outputFD, false); } else { - registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), 0, 0.0, 0.0, false); + registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), false); } } if (candidate.isSelXicToPiKP() >= selectionFlagXic) { massXic = hfHelper.invMassXicToPiKP(candidate); if constexpr (useMl) { - if (candidate.mlProbXicToPiKP().size() == 3) { + if (candidate.mlProbXicToPiKP().size() == ternaryCl) { outputBkg = candidate.mlProbXicToPiKP()[0]; /// bkg score outputPrompt = candidate.mlProbXicToPiKP()[1]; /// prompt score outputFD = candidate.mlProbXicToPiKP()[2]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate - registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXic, ptCandidate, outputBkg, outputPrompt, outputFD, 0, 0.0, 0.0, false); + registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXic, ptCandidate, outputBkg, outputPrompt, outputFD, false); } else { - registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), 0, 0.0, 0.0, false); + registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), false); } } } // thn for Xic - } // loop candidates - } // end process data + } // loop candidates + } // end process data void processDataStd(aod::Collision const& collision, - soa::Filtered> const& candidates, - TracksWPid const& tracks) + soa::Filtered> const& candidates, + aod::TracksWDca const& tracks) { analysisData(collision, candidates, tracks); } PROCESS_SWITCH(HfTaskXic, processDataStd, "Process Data with the standard method", true); void processDataWithMl(aod::Collision const& collision, - soa::Filtered> const& candidatesMl, TracksWPid const& tracks) + soa::Filtered> const& candidatesMl, aod::TracksWDca const& tracks) { analysisData(collision, candidatesMl, tracks); } @@ -426,13 +442,10 @@ struct HfTaskXic { massXicToPiKP = hfHelper.invMassXicToPiKP(candidate); // mass conjugate } - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::XicToPKPi) { + if (std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::XicToPKPi) { // Get the corresponding MC particle. auto mcParticleProng0 = candidate.template prong0_as().template mcParticle_as>(); auto pdgCodeProng0 = std::abs(mcParticleProng0.pdgCode()); - auto yProng0 = RecoDecay::y(mcParticleProng0.pVector(), o2::constants::physics::MassXiCPlus); - std::array ptProngs; - std::array etaProngs; // Signal registry.fill(HIST("MC/reconstructed/signal/hPtRecSig"), ptCandidate); // rec. level pT @@ -464,7 +477,8 @@ struct HfTaskXic { registry.fill(HIST("MC/reconstructed/signal/hEtaVsPtRecSig"), candidate.eta(), ptCandidate); /// reconstructed signal prompt - if (candidate.originMcRec() == RecoDecay::OriginType::Prompt) { + int origin = candidate.originMcRec(); + if (origin == RecoDecay::OriginType::Prompt) { if ((candidate.isSelXicToPKPi() >= selectionFlagXic) && pdgCodeProng0 == kProton) { registry.fill(HIST("MC/reconstructed/prompt/hMassRecSigPrompt"), massXicToPKPi); registry.fill(HIST("MC/reconstructed/prompt/hMassVsPtRecSigPrompt"), massXicToPKPi, ptCandidate); @@ -489,50 +503,33 @@ struct HfTaskXic { } if (enableTHn) { - double massXic(-1); double outputBkg(-1), outputPrompt(-1), outputFD(-1); - bool allProngsInAcceptance = false; + const int ternaryCl = 3; if ((candidate.isSelXicToPKPi() >= selectionFlagXic) && pdgCodeProng0 == kProton) { - massXic = hfHelper.invMassXicToPKPi(candidate); - int counter = 0; - for (const auto& daught : mcParticleProng0.template daughters_as>()) { - ptProngs[counter] = daught.pt(); - etaProngs[counter] = daught.eta(); - counter++; - } - allProngsInAcceptance = isProngInAcceptance(etaProngs[0], ptProngs[0]) && isProngInAcceptance(etaProngs[1], ptProngs[1]) && isProngInAcceptance(etaProngs[2], ptProngs[2]); if constexpr (useMl) { - if (candidate.mlProbXicToPKPi().size() == 3) { + if (candidate.mlProbXicToPKPi().size() == ternaryCl) { outputBkg = candidate.mlProbXicToPKPi()[0]; /// bkg score outputPrompt = candidate.mlProbXicToPKPi()[1]; /// prompt score outputFD = candidate.mlProbXicToPKPi()[2]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate (todo: add multiplicity) - registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXic, ptCandidate, outputBkg, outputPrompt, outputFD, candidate.originMcRec(), mcParticleProng0.pt(), yProng0, allProngsInAcceptance); + registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXicToPKPi, ptCandidate, outputBkg, outputPrompt, outputFD, origin); } else { - registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), candidate.originMcRec(), mcParticleProng0.pt(), yProng0, allProngsInAcceptance); + registry.get(HIST("hnXicVars"))->Fill(massXicToPKPi, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), origin); } } if ((candidate.isSelXicToPiKP() >= selectionFlagXic) && pdgCodeProng0 == kPiPlus) { - massXic = hfHelper.invMassXicToPiKP(candidate); - int counter = 0; - for (const auto& daught : mcParticleProng0.template daughters_as>()) { - ptProngs[counter] = daught.pt(); - etaProngs[counter] = daught.eta(); - counter++; - } - allProngsInAcceptance = isProngInAcceptance(etaProngs[0], ptProngs[0]) && isProngInAcceptance(etaProngs[1], ptProngs[1]) && isProngInAcceptance(etaProngs[2], ptProngs[2]); if constexpr (useMl) { - if (candidate.mlProbXicToPiKP().size() == 3) { + if (candidate.mlProbXicToPiKP().size() == ternaryCl) { outputBkg = candidate.mlProbXicToPiKP()[0]; /// bkg score outputPrompt = candidate.mlProbXicToPiKP()[1]; /// prompt score outputFD = candidate.mlProbXicToPiKP()[2]; /// non-prompt score } /// Fill the ML outputScores and variables of candidate (todo: add multiplicity) // add here the pT_Mother, y_Mother, level (reco, Gen, Gen + Acc) - registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXic, ptCandidate, outputBkg, outputPrompt, outputFD, candidate.originMcRec(), mcParticleProng0.pt(), yProng0, allProngsInAcceptance); + registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXicToPiKP, ptCandidate, outputBkg, outputPrompt, outputFD, origin); } else { - registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), candidate.originMcRec(), mcParticleProng0.pt(), yProng0, allProngsInAcceptance); + registry.get(HIST("hnXicVars"))->Fill(massXicToPiKP, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), origin); } } } // enable THn @@ -565,11 +562,11 @@ struct HfTaskXic { registry.fill(HIST("MC/reconstructed/background/hDecLenErrBg"), candidate.errorDecayLength(), ptCandidate); registry.fill(HIST("MC/reconstructed/background/hChi2PCARecBg"), candidate.chi2PCA(), ptCandidate); } // Xic background - } // candidate loop + } // candidate loop // MC gen. for (const auto& particle : mcParticles) { - if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::XicToPKPi) { + if (std::abs(particle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::XicToPKPi) { auto yGen = RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus); if (yCandGenMax >= 0. && std::abs(yGen) > yCandGenMax) { continue; @@ -598,7 +595,7 @@ struct HfTaskXic { } } } - void processMcStd(soa::Filtered> const& selectedCandidatesMc, + void processMcStd(soa::Filtered> const& selectedCandidatesMc, soa::Join const& mcParticles, aod::TracksWMc const& tracksWithMc) { @@ -606,7 +603,7 @@ struct HfTaskXic { } PROCESS_SWITCH(HfTaskXic, processMcStd, "Process MC with the standard method", false); - void processMcWithMl(soa::Filtered> const& selectedCandidatesMlMc, + void processMcWithMl(soa::Filtered> const& selectedCandidatesMlMc, soa::Join const& mcParticles, aod::TracksWMc const& tracksWithMc) { diff --git a/PWGHF/D2H/Tasks/taskXic0ToXiPi.cxx b/PWGHF/D2H/Tasks/taskXic0ToXiPi.cxx new file mode 100644 index 00000000000..40efcbbcc31 --- /dev/null +++ b/PWGHF/D2H/Tasks/taskXic0ToXiPi.cxx @@ -0,0 +1,361 @@ +// 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. + +/// \file taskXic0ToXiPi.cxx +/// \brief Task for Ξc^0 → Ξ∓ π± Kf analysis +/// \author Tao Fang , Central China Normal University +/// \author Ran Tu , Fudan University + +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::analysis; +using namespace o2::framework; +using namespace o2::framework::expressions; + +/// Xic0 analysis task + +struct HfTaskXic0ToXiPi { + // ML inference + Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; + Configurable fillCent{"fillCent", false, "Flag to fill centrality information"}; + Configurable yCandGenMax{"yCandGenMax", 0.8, "max. gen particle rapidity"}; + Configurable yCandRecMax{"yCandRecMax", 0.8, "max. cand. rapidity"}; + + HfHelper hfHelper; + SliceCache cache; + + using TracksMc = soa::Join; + + using Xic0CandsKF = soa::Filtered>; + using Xic0CandsMcKF = soa::Filtered>; + + using Xic0CandsMlKF = soa::Filtered>; + using Xic0CandsMlMcKF = soa::Filtered>; + + using Xic0Gen = soa::Filtered>; + + using CollisionsWithEvSels = soa::Join; + using CollisionsWithFT0C = soa::Join; + using CollisionsWithFT0M = soa::Join; + using CollisionsWithMcLabels = soa::Join; + + Filter filterSelectXic0Candidates = aod::hf_sel_toxipi::resultSelections == true; + Filter filterXicMatchedRec = nabs(aod::hf_cand_xic0_omegac0::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi)); + Filter filterXicMatchedGen = nabs(aod::hf_cand_xic0_omegac0::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi)); + Preslice candXicKFPerCollision = aod::hf_cand_xic0_omegac0::collisionId; + Preslice candXicKFMlPerCollision = aod::hf_cand_xic0_omegac0::collisionId; + + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + + // ThnSparse for ML outputScores and Vars + ConfigurableAxis thnConfigAxisPromptScore{"thnConfigAxisPromptScore", {100, 0, 1}, "Prompt score bins"}; + ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {120, 2.4, 3.1}, "Cand. inv-mass bins"}; + ConfigurableAxis thnConfigAxisPtB{"thnConfigAxisPtB", {1000, 0, 100}, "Cand. beauty mother pTB bins"}; + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {100, 0, 20}, "Cand. pT bins"}; + ConfigurableAxis thnConfigAxisY{"thnConfigAxisY", {20, -1, 1}, "Cand. rapidity bins"}; + ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {100, 0, 100}, "Centrality bins"}; + ConfigurableAxis thnConfigAxisPtPion{"thnConfigAxisPtPion", {100, 0, 10}, "PtPion from Xic0 bins"}; + ConfigurableAxis thnConfigAxisOrigin{"thnConfigAxisOrigin", {3, -0.5, 2.5}, "Cand. origin type"}; + ConfigurableAxis thnConfigAxisMatchFlag{"thnConfigAxisMatchFlag", {15, -7.5, 7.5}, "Cand. MC Match Flag type"}; + ConfigurableAxis thnConfigAxisGenPtD{"thnConfigAxisGenPtD", {500, 0, 50}, "Gen Pt D"}; + ConfigurableAxis thnConfigAxisGenPtB{"thnConfigAxisGenPtB", {1000, 0, 100}, "Gen Pt B"}; + ConfigurableAxis thnConfigAxisNumPvContr{"thnConfigAxisNumPvContr", {200, -0.5, 199.5}, "Number of PV contributors"}; + HistogramRegistry registry{"registry", {}}; + + void init(InitContext&) + { + std::array doprocess{doprocessDataWithKFParticle, doprocessMcWithKFParticle, doprocessDataWithKFParticleMl, doprocessMcWithKFParticleMl, doprocessDataWithKFParticleFT0C, doprocessDataWithKFParticleMlFT0C, doprocessDataWithKFParticleFT0M, doprocessDataWithKFParticleMlFT0M}; + if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { + LOGP(fatal, "One and only one process function should be enabled at a time."); + } + + const AxisSpec thnAxisMass{thnConfigAxisMass, "inv. mass (#Xi#pi) (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisPtB{thnConfigAxisPtB, "#it{p}_{T}^{B} (GeV/#it{c})"}; + const AxisSpec thnAxisY{thnConfigAxisY, "y"}; + const AxisSpec thnAxisOrigin{thnConfigAxisOrigin, "Origin"}; + const AxisSpec thnAxisMatchFlag{thnConfigAxisMatchFlag, "MatchFlag"}; + const AxisSpec thnAxisGenPtD{thnConfigAxisGenPtD, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisGenPtB{thnConfigAxisGenPtB, "#it{p}_{T}^{B} (GeV/#it{c})"}; + const AxisSpec thnAxisNumPvContr{thnConfigAxisNumPvContr, "Number of PV contributors"}; + + if (doprocessMcWithKFParticle || doprocessMcWithKFParticleMl) { + std::vector axesAcc = {thnAxisGenPtD, thnAxisGenPtB, thnAxisY, thnAxisOrigin, thnAxisNumPvContr}; + registry.add("hSparseAcc", "Thn for generated Xic0 from charm and beauty", HistType::kTHnSparseD, axesAcc); + registry.get(HIST("hSparseAcc"))->Sumw2(); + } + + std::vector axes = {thnAxisMass, thnAxisPt, thnAxisY}; + if (doprocessMcWithKFParticle || doprocessMcWithKFParticleMl) { + axes.push_back(thnAxisPtB); + axes.push_back(thnAxisOrigin); + axes.push_back(thnAxisMatchFlag); + axes.push_back(thnAxisNumPvContr); + } + if (applyMl) { + const AxisSpec thnAxisPromptScore{thnConfigAxisPromptScore, "BDT score prompt."}; + axes.insert(axes.begin(), thnAxisPromptScore); + registry.add("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsXic0Type", "Thn for Xic0 candidates", HistType::kTHnSparseD, axes); + registry.get(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsXic0Type"))->Sumw2(); + } else { + registry.add("hMassVsPtVsPtBVsYVsOriginVsXic0Type", "Thn for Xic0 candidates", HistType::kTHnSparseF, axes); + registry.get(HIST("hMassVsPtVsPtBVsYVsOriginVsXic0Type"))->Sumw2(); + } + if (fillCent) { + const AxisSpec thnAxisPromptScore{thnConfigAxisPromptScore, "BDT score prompt."}; + const AxisSpec thnAxisCent{thnConfigAxisCent, "Centrality."}; + const AxisSpec thnAxisPtPion{thnConfigAxisPtPion, "Pt of Pion from Xic0."}; + std::vector axesWithBdtCent = {thnAxisPromptScore, thnAxisMass, thnAxisPt, thnAxisY, thnAxisCent, thnAxisPtPion, thnConfigAxisNumPvContr}; + std::vector axesWithCent = {thnAxisMass, thnAxisPt, thnAxisY, thnAxisCent, thnAxisPtPion, thnConfigAxisNumPvContr}; + registry.add("hBdtScoreVsMassVsPtVsYVsCentVsPtPion", "Thn for Xic0 candidates with BDT&Cent&pTpi", HistType::kTHnSparseD, axesWithBdtCent); + registry.add("hMassVsPtVsYVsCentVsPtPion", "Thn for Xic0 candidates with Cent&pTpi", HistType::kTHnSparseD, axesWithCent); + registry.get(HIST("hBdtScoreVsMassVsPtVsYVsCentVsPtPion"))->Sumw2(); + registry.get(HIST("hMassVsPtVsYVsCentVsPtPion"))->Sumw2(); + } + } + + template + void processData(const CandType& candidates, CollType const&) + { + for (const auto& candidate : candidates) { + if (candidate.resultSelections() != true) { + continue; + } + if (yCandRecMax >= 0. && std::abs(candidate.kfRapXic()) > yCandRecMax) { + continue; + } + + if constexpr (applyMl) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsXic0Type"), candidate.mlProbToXiPi()[0], candidate.invMassCharmBaryon(), candidate.kfptXic(), candidate.kfRapXic()); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsXic0Type"), candidate.invMassCharmBaryon(), candidate.kfptXic(), candidate.kfRapXic()); + } + } + } + + template + void processDataCent(const CandType& candidates, CollType const& collisions) + { + for (const auto& collision : collisions) { + + auto thisCollId = collision.globalIndex(); + auto groupedXicCandidates = applyMl + ? candidates.sliceBy(candXicKFMlPerCollision, thisCollId) + : candidates.sliceBy(candXicKFPerCollision, thisCollId); + // auto numPvContributors = collision.numContrib(); + + for (const auto& candidate : groupedXicCandidates) { + if (candidate.resultSelections() != true) { + continue; + } + if (yCandRecMax >= 0. && std::abs(candidate.kfRapXic()) > yCandRecMax) { + continue; + } + + auto numPvContributors = candidate.template collision_as().numContrib(); + float centrality = -999.f; + if constexpr (useCentrality) { + auto const& collision = candidate.template collision_as(); + centrality = o2::hf_centrality::getCentralityColl(collision); + } + double kfptXic = RecoDecay::sqrtSumOfSquares(candidate.pxCharmBaryon(), candidate.pyCharmBaryon()); + double kfptPiFromXic = RecoDecay::sqrtSumOfSquares(candidate.pxBachFromCharmBaryon(), candidate.pyBachFromCharmBaryon()); + if constexpr (applyMl) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsYVsCentVsPtPion"), + candidate.mlProbToXiPi()[0], + candidate.invMassCharmBaryon(), + kfptXic, + candidate.kfRapXic(), + centrality, + kfptPiFromXic, + numPvContributors); + } else { + registry.fill(HIST("hMassVsPtVsYVsCentVsPtPion"), + candidate.invMassCharmBaryon(), + kfptXic, + candidate.kfRapXic(), + centrality, + kfptPiFromXic, + numPvContributors); + } + } + } + } + + template + void processMc(const CandType& candidates, + Xic0Gen const& mcParticles, + TracksMc const&, + CollType const& collisions, + aod::McCollisions const&) + { + // MC rec. + for (const auto& candidate : candidates) { + if (candidate.resultSelections() != true) { + continue; + } + if (yCandRecMax >= 0. && std::abs(candidate.kfRapXic()) > yCandRecMax) { + continue; + } + + auto numPvContributors = candidate.template collision_as().numContrib(); + double kfptXic = RecoDecay::sqrtSumOfSquares(candidate.pxCharmBaryon(), candidate.pyCharmBaryon()); + if constexpr (applyMl) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsXic0Type"), + candidate.mlProbToXiPi()[0], + candidate.invMassCharmBaryon(), + kfptXic, + candidate.kfRapXic(), + candidate.ptBhadMotherPart(), + candidate.originMcRec(), + candidate.flagMcMatchRec(), + numPvContributors); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsXic0Type"), + candidate.invMassCharmBaryon(), + kfptXic, + candidate.kfRapXic(), + candidate.ptBhadMotherPart(), + candidate.originMcRec(), + candidate.flagMcMatchRec(), + numPvContributors); + } + } + + // MC gen. + for (const auto& particle : mcParticles) { + if (yCandGenMax >= 0. && std::abs(particle.rapidityCharmBaryonGen()) > yCandGenMax) { + continue; + } + + auto ptGen = particle.pt(); + auto yGen = particle.rapidityCharmBaryonGen(); + + unsigned maxNumContrib = 0; + const auto& recoCollsPerMcColl = collisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex()); + for (const auto& recCol : recoCollsPerMcColl) { + maxNumContrib = recCol.numContrib() > maxNumContrib ? recCol.numContrib() : maxNumContrib; + } + + if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("hSparseAcc"), + ptGen, + -1., + yGen, + RecoDecay::OriginType::Prompt, + maxNumContrib); + } else { + float ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt(); + registry.fill(HIST("hSparseAcc"), + ptGen, + ptGenB, + yGen, + RecoDecay::OriginType::NonPrompt, + maxNumContrib); + } + } + } + + void processDataWithKFParticle(Xic0CandsKF const& candidates, + CollisionsWithEvSels const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskXic0ToXiPi, processDataWithKFParticle, "process HfTaskXic0ToXiPi with KFParticle", true); + + void processDataWithKFParticleMl(Xic0CandsMlKF const& candidates, + CollisionsWithEvSels const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskXic0ToXiPi, processDataWithKFParticleMl, "process HfTaskXic0ToXiPi with KFParticle and ML selections", false); + + void processDataWithKFParticleFT0C(Xic0CandsKF const& candidates, + CollisionsWithFT0C const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskXic0ToXiPi, processDataWithKFParticleFT0C, "process HfTaskXic0ToXiPi with KFParticle and with FT0C centrality", false); + + void processDataWithKFParticleFT0M(Xic0CandsKF const& candidates, + CollisionsWithFT0M const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskXic0ToXiPi, processDataWithKFParticleFT0M, "process HfTaskXic0ToXiPi with KFParticle and with FT0M centrality", false); + + void processDataWithKFParticleMlFT0C(Xic0CandsMlKF const& candidates, + CollisionsWithFT0C const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskXic0ToXiPi, processDataWithKFParticleMlFT0C, "process HfTaskXic0ToXiPi with KFParticle and ML selections and with FT0C centrality", false); + + void processDataWithKFParticleMlFT0M(Xic0CandsMlKF const& candidates, + CollisionsWithFT0M const& collisions) + { + processDataCent(candidates, collisions); + } + PROCESS_SWITCH(HfTaskXic0ToXiPi, processDataWithKFParticleMlFT0M, "process HfTaskXic0ToXiPi with KFParticle and ML selections and with FT0M centrality", false); + + void processMcWithKFParticle(Xic0CandsMcKF const& Xic0CandidatesMcKF, + Xic0Gen const& mcParticles, + TracksMc const& tracks, + CollisionsWithMcLabels const& collisions, + aod::McCollisions const& mcCollisions) + { + processMc(Xic0CandidatesMcKF, mcParticles, tracks, collisions, mcCollisions); + } + PROCESS_SWITCH(HfTaskXic0ToXiPi, processMcWithKFParticle, "Process MC with KFParticle", false); + + void processMcWithKFParticleMl(Xic0CandsMlMcKF const& Xic0CandidatesMlMcKF, + Xic0Gen const& mcParticles, + TracksMc const& tracks, + CollisionsWithMcLabels const& collisions, + aod::McCollisions const& mcCollisions) + { + processMc(Xic0CandidatesMlMcKF, mcParticles, tracks, collisions, mcCollisions); + } + PROCESS_SWITCH(HfTaskXic0ToXiPi, processMcWithKFParticleMl, "Process MC with KFParticle and ML selections", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/Tasks/taskXicToXiPiPi.cxx b/PWGHF/D2H/Tasks/taskXicToXiPiPi.cxx index 58341c78b3d..cc3459eba4a 100644 --- a/PWGHF/D2H/Tasks/taskXicToXiPiPi.cxx +++ b/PWGHF/D2H/Tasks/taskXicToXiPiPi.cxx @@ -17,18 +17,37 @@ /// \author Carolina Reetz , Heidelberg University /// \author Jaeyoon Cho , Inha University -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" - #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::analysis; @@ -47,6 +66,14 @@ struct HfTaskXicToXiPiPi { Configurable checkDecayTypeMc{"checkDecayTypeMc", false, "Flag to enable DecayType histogram"}; // THnSparese for ML selection check Configurable enableTHn{"enableTHn", false, "Fill THnSparse for Xic"}; + + const int nVarsMultiClass = 3; + + Service pdg; + + Filter filterSelectCandidates = (aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= selectionFlagXic); + + // Axis ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {400, 0., 40.}, ""}; ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {300, 1.8, 3.0}, ""}; ConfigurableAxis thnConfigAxisPtProng{"thnConfigAxisPtProng", {300, 0., 30.}, ""}; @@ -55,8 +82,8 @@ struct HfTaskXicToXiPiPi { ConfigurableAxis thnConfigAxisDecLengthXY{"thnConfigAxisDecLengthXY", {200, 0., 0.5}, ""}; ConfigurableAxis thnConfigAxisCPA{"thnConfigAxisCPA", {110, -1.1, 1.1}, ""}; ConfigurableAxis thnConfigAxisBdtScoreBkg{"thnConfigAxisBdtScoreBkg", {100, 0., 1.}, ""}; - ConfigurableAxis thnConfigAxisBdtScoreSignal{"thnConfigAxisBdtScoreSignal", {100, 0., 1.}, ""}; - // Axis + ConfigurableAxis thnConfigAxisBdtScorePrompt{"thnConfigAxisBdtScorePrompt", {100, 0., 1.}, ""}; + ConfigurableAxis thnConfigAxisBdtScoreNonPrompt{"thnConfigAxisBdtScoreNonPrompt", {100, 0., 1.}, ""}; ConfigurableAxis binsDecLength{"binsDecLength", {200, 0., 0.5}, ""}; ConfigurableAxis binsErrDecLength{"binsErrDecLength", {100, 0., 1.}, ""}; ConfigurableAxis binsDCA{"binsDCA", {100, -0.05, 0.05}, ""}; @@ -64,10 +91,6 @@ struct HfTaskXicToXiPiPi { ConfigurableAxis binsSV{"binsSV", {200, -5., 5.}, ""}; ConfigurableAxis binsChi2{"binsChi2", {200, 0., 0.1}, ""}; - Service pdg; - - Filter filterSelectCandidates = (aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= selectionFlagXic); - HistogramRegistry registry{"registry"}; void init(InitContext const&) @@ -128,10 +151,9 @@ struct HfTaskXicToXiPiPi { registry.add("hMassXiPi2", "#Xi^{#plus}_{c} candidates;inv. mass #Xi^{#mp} #pi^{#pm} (prong 2) (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisMassXiRes, axisPt}}); // KFParticle if (doprocessWithKFParticle || doprocessWithKFParticleAndML) { - registry.add("hChi2geoXi", "#Xi^{#plus}_{c} candidates;#Xi^{#mp} #chi^{2}_{geo};entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2geoLam", "#Xi^{#plus}_{c} candidates;#Lambda #chi^{2}_{geo};entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2topoToPV", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate #chi^{2}_{topo} to PV;entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2topoXiToXicPlus", "#Xi^{#plus}_{c} candidates;#Xi^{#mp} candidate #chi^{2}_{topo} to #Xi^{#plus}_{c};entries", {HistType::kTH2F, {axisChi2, axisPt}}); + registry.add("hChi2GeoXi", "#Xi^{#plus}_{c} candidates;#chi^{2}_{geo} (#Xi^{#mp});entries", {HistType::kTH2F, {axisChi2, axisPt}}); + registry.add("hChi2GeoLam", "#Xi^{#plus}_{c} candidates;#chi^{2}_{geo} (#Lambda);entries", {HistType::kTH2F, {axisChi2, axisPt}}); + registry.add("hChi2TopoXicPlusToPV", "#Xi^{#plus}_{c} candidates;#chi^{2}_{topo} (#Xi^{#plus}_{c} #rightarrow PV);entries", {HistType::kTH2F, {axisChi2, axisPt}}); } } @@ -200,14 +222,12 @@ struct HfTaskXicToXiPiPi { registry.add("hMassXiPi2RecBg", "#Xi^{#plus}_{c} candidates (unmatched);inv. mass #Xi^{#mp} #pi^{#pm} (prong 2) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{300, 1.0, 2.0}, axisPt}}); // MC reconstructed with KFParticle if (doprocessMcWithKFParticle || doprocessMcWithKFParticleAndML) { - registry.add("hChi2topoToPVRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate #chi^{2}_{topo} to PV;entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2topoToPVRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate #chi^{2}_{topo} to PV;entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2geoXiRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#mp} #chi^{2}_{geo};entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2geoXiRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#mp} #chi^{2}_{geo};entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2geoLamRecSig", "#Xi^{#plus}_{c} candidates (matched);#Lambda #chi^{2}_{geo};entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2geoLamRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Lambda #chi^{2}_{geo};entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2topoXiToXicPlusRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#mp} candidate #chi^{2}_{topo} to #Xi^{#plus}_{c};entries", {HistType::kTH2F, {axisChi2, axisPt}}); - registry.add("hChi2topoXiToXicPlusRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#mp} candidate #chi^{2}_{topo} to #Xi^{#plus}_{c};entries", {HistType::kTH2F, {axisChi2, axisPt}}); + registry.add("hChi2GeoXiRecSig", "#Xi^{#plus}_{c} candidates (matched);#chi^{2}_{geo} (#Xi^{#mp});entries", {HistType::kTH2F, {axisChi2, axisPt}}); + registry.add("hChi2GeoXiRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#chi^{2}_{geo} (#Xi^{#mp});entries", {HistType::kTH2F, {axisChi2, axisPt}}); + registry.add("hChi2GeoLamRecSig", "#Xi^{#plus}_{c} candidates (matched);#chi^{2}_{geo} (#Lambda);entries", {HistType::kTH2F, {axisChi2, axisPt}}); + registry.add("hChi2GeoLamRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#chi^{2}_{geo} (#Lambda);entries", {HistType::kTH2F, {axisChi2, axisPt}}); + registry.add("hChi2TopoXicPlusToPVRecSig", "#Xi^{#plus}_{c} candidates (matched);#chi^{2}_{topo} (#Xi^{#plus}_{c} #rightarrow PV);entries", {HistType::kTH2F, {axisChi2, axisPt}}); + registry.add("hChi2TopoXicPlusToPVRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#chi^{2}_{topo} (#Xi^{#plus}_{c} #rightarrow PV);entries", {HistType::kTH2F, {axisChi2, axisPt}}); } // MC generated registry.add("hPtProng0Gen", "MC particles (generated);prong 0 (#Xi^{#mp}) #it{p}_{T}^{gen} (GeV/#it{c});entries", {HistType::kTH2F, {{300, 0., 30.}, axisPt}}); @@ -251,11 +271,12 @@ struct HfTaskXicToXiPiPi { const AxisSpec thnAxisDecLengthXY{thnConfigAxisDecLengthXY, "decay length xy (cm)"}; const AxisSpec thnAxisCPA{thnConfigAxisCPA, "#Xi^{#plus}_{c} candidate cosine of pointing angle"}; const AxisSpec thnAxisBdtScoreBkg{thnConfigAxisBdtScoreBkg, "BDT score of background"}; - const AxisSpec thnAxisBdtScoreSignal{thnConfigAxisBdtScoreSignal, "BDT score of prompt Xic"}; + const AxisSpec thnAxisBdtScorePrompt{thnConfigAxisBdtScorePrompt, "BDT score of prompt #Xi^{#plus}_{c}"}; + const AxisSpec thnAxisBdtScoreNonPrompt{thnConfigAxisBdtScoreNonPrompt, "BDT score of non-prompt #Xi^{#plus}_{c}"}; if (doprocessWithKFParticleAndML || doprocessWithDCAFitterAndML || doprocessMcWithKFParticleAndML || doprocessMcWithDCAFitterAndML) { // with ML information - registry.add("hXicToXiPiPiVarsWithML", "THnSparse for Xic with ML", HistType::kTHnSparseF, {thnAxisPt, thnAxisMass, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisBdtScoreBkg, thnAxisBdtScoreSignal}); + registry.add("hXicToXiPiPiVarsWithML", "THnSparse for Xic with ML", HistType::kTHnSparseF, {thnAxisPt, thnAxisMass, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisBdtScoreBkg, thnAxisBdtScorePrompt, thnAxisBdtScoreNonPrompt}); } else { // without ML information registry.add("hXicToXiPiPiVars", "THnSparse for Xic", HistType::kTHnSparseF, {thnAxisPt, thnAxisMass, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA}); @@ -274,13 +295,18 @@ struct HfTaskXicToXiPiPi { if constexpr (useMl) { // with ML information - double outputBkg = -99.; - double outputPrompt = -99.; - if (candidate.mlProbXicToXiPiPi().size() > 0) { + double outputBkg = -99.; // bkg score + double outputPrompt = -99.; // prompt score + double outputFD = -99.; // non-prompt score + int scoreSize = candidate.mlProbXicToXiPiPi().size(); + if (scoreSize > 0) { outputBkg = candidate.mlProbXicToXiPiPi()[0]; outputPrompt = candidate.mlProbXicToXiPiPi()[1]; + if (scoreSize == nVarsMultiClass) { + outputFD = candidate.mlProbXicToXiPiPi()[2]; + } } - registry.get(HIST("hXicToXiPiPiVarsWithML"))->Fill(candidate.pt(), candidate.invMassXicPlus(), candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), outputBkg, outputPrompt); + registry.get(HIST("hXicToXiPiPiVarsWithML"))->Fill(candidate.pt(), candidate.invMassXicPlus(), candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), outputBkg, outputPrompt, outputFD); } else { // without ML information registry.get(HIST("hXicToXiPiPiVars"))->Fill(candidate.pt(), candidate.invMassXicPlus(), candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa()); @@ -335,19 +361,18 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter1(), ptCandXic); registry.fill(HIST("hImpParErr"), candidate.errorImpactParameter2(), ptCandXic); registry.fill(HIST("hChi2PCA"), candidate.chi2PCA(), ptCandXic); - registry.fill(HIST("hCPAXi"), candidate.cosPaXi(), ptCandXic); - registry.fill(HIST("hCPAxyXi"), candidate.cosPaXYXi(), ptCandXic); - registry.fill(HIST("hCPALambda"), candidate.cosPaLambda(), ptCandXic); - registry.fill(HIST("hCPAxyLambda"), candidate.cosPaLambda(), ptCandXic); + registry.fill(HIST("hCPAXi"), candidate.cpaXi(), ptCandXic); + registry.fill(HIST("hCPAxyXi"), candidate.cpaXYXi(), ptCandXic); + registry.fill(HIST("hCPALambda"), candidate.cpaLambda(), ptCandXic); + registry.fill(HIST("hCPAxyLambda"), candidate.cpaLambda(), ptCandXic); registry.fill(HIST("hMassXiPi1"), candidate.invMassXiPi0(), ptCandXic); registry.fill(HIST("hMassXiPi2"), candidate.invMassXiPi1(), ptCandXic); // fill KFParticle specific histograms if constexpr (useKfParticle) { - registry.fill(HIST("hChi2topoToPV"), candidate.chi2TopoXicPlusToPV(), ptCandXic); - registry.fill(HIST("hChi2topoXiToXicPlus"), candidate.chi2TopoXiToXicPlus(), ptCandXic); - registry.fill(HIST("hChi2geoXi"), candidate.kfCascadeChi2(), ptCandXic); - registry.fill(HIST("hChi2geoLam"), candidate.kfV0Chi2(), ptCandXic); + registry.fill(HIST("hChi2GeoXi"), candidate.kfCascadeChi2(), ptCandXic); + registry.fill(HIST("hChi2GeoLam"), candidate.kfV0Chi2(), ptCandXic); + registry.fill(HIST("hChi2TopoXicPlusToPV"), candidate.chi2TopoXicPlusToPV(), ptCandXic); } // fill THnSparse @@ -377,7 +402,7 @@ struct HfTaskXicToXiPiPi { } auto ptCandXic = candidate.pt(); - int flagMcMatchRecXic = std::abs(candidate.flagMcMatchRec()); + auto flagMcMatchRecXic = std::abs(candidate.flagMcMatchRec()); if (TESTBIT(flagMcMatchRecXic, hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) || TESTBIT(flagMcMatchRecXic, hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi)) { auto indexMother = RecoDecay::getMother(mcParticles, candidate.template pi0_as().template mcParticle_as>(), o2::constants::physics::Pdg::kXiCPlus, true); @@ -410,17 +435,16 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hImpParErrRecSig"), candidate.errorImpactParameter1(), ptCandXic); registry.fill(HIST("hImpParErrRecSig"), candidate.errorImpactParameter2(), ptCandXic); registry.fill(HIST("hChi2PCARecSig"), candidate.chi2PCA(), ptCandXic); - registry.fill(HIST("hCPAXiRecSig"), candidate.cosPaXi(), ptCandXic); - registry.fill(HIST("hCPAxyXiRecSig"), candidate.cosPaXYXi(), ptCandXic); - registry.fill(HIST("hCPALambdaRecSig"), candidate.cosPaLambda(), ptCandXic); - registry.fill(HIST("hCPAxyLambdaRecSig"), candidate.cosPaLambda(), ptCandXic); + registry.fill(HIST("hCPAXiRecSig"), candidate.cpaXi(), ptCandXic); + registry.fill(HIST("hCPAxyXiRecSig"), candidate.cpaXYXi(), ptCandXic); + registry.fill(HIST("hCPALambdaRecSig"), candidate.cpaLambda(), ptCandXic); + registry.fill(HIST("hCPAxyLambdaRecSig"), candidate.cpaLambda(), ptCandXic); // fill KFParticle specific histograms if constexpr (useKfParticle) { - registry.fill(HIST("hChi2topoToPVRecSig"), candidate.chi2TopoXicPlusToPV(), ptCandXic); - registry.fill(HIST("hChi2topoXiToXicPlusRecSig"), candidate.chi2TopoXiToXicPlus(), ptCandXic); registry.fill(HIST("hChi2geoXiRecSig"), candidate.kfCascadeChi2(), ptCandXic); registry.fill(HIST("hChi2geoLamRecSig"), candidate.kfV0Chi2(), ptCandXic); + registry.fill(HIST("hChi2TopoXicPlusToPVRecSig"), candidate.chi2TopoXicPlusToPV(), ptCandXic); } } else { registry.fill(HIST("hPtRecBg"), ptCandXic); @@ -449,17 +473,16 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hImpParErrRecBg"), candidate.errorImpactParameter1(), ptCandXic); registry.fill(HIST("hImpParErrRecBg"), candidate.errorImpactParameter2(), ptCandXic); registry.fill(HIST("hChi2PCARecBg"), candidate.chi2PCA(), ptCandXic); - registry.fill(HIST("hCPAXiRecBg"), candidate.cosPaXi(), ptCandXic); - registry.fill(HIST("hCPAxyXiRecBg"), candidate.cosPaXYXi(), ptCandXic); - registry.fill(HIST("hCPALambdaRecBg"), candidate.cosPaLambda(), ptCandXic); - registry.fill(HIST("hCPAxyLambdaRecBg"), candidate.cosPaLambda(), ptCandXic); + registry.fill(HIST("hCPAXiRecBg"), candidate.cpaXi(), ptCandXic); + registry.fill(HIST("hCPAxyXiRecBg"), candidate.cpaXYXi(), ptCandXic); + registry.fill(HIST("hCPALambdaRecBg"), candidate.cpaLambda(), ptCandXic); + registry.fill(HIST("hCPAxyLambdaRecBg"), candidate.cpaLambda(), ptCandXic); // fill KFParticle specific histograms if constexpr (useKfParticle) { - registry.fill(HIST("hChi2topoToPVRecBg"), candidate.chi2TopoXicPlusToPV(), ptCandXic); - registry.fill(HIST("hChi2topoXiToXicPlusRecBg"), candidate.chi2TopoXiToXicPlus(), ptCandXic); registry.fill(HIST("hChi2geoXiRecBg"), candidate.kfCascadeChi2(), ptCandXic); registry.fill(HIST("hChi2geoLamRecBg"), candidate.kfV0Chi2(), ptCandXic); + registry.fill(HIST("hChi2TopoXicPlusToPVRecBg"), candidate.chi2TopoXicPlusToPV(), ptCandXic); } } diff --git a/PWGHF/D2H/Tasks/taskXicc.cxx b/PWGHF/D2H/Tasks/taskXicc.cxx index 0e3f116081a..90f4c5da24d 100644 --- a/PWGHF/D2H/Tasks/taskXicc.cxx +++ b/PWGHF/D2H/Tasks/taskXicc.cxx @@ -16,14 +16,26 @@ /// \author Gian Michele Innocenti , CERN /// \author Jinjoo Seo , Inha University -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" - #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -35,7 +47,7 @@ void customize(std::vector& workflowOptions) workflowOptions.push_back(optionDoMC); } -#include "Framework/runDataProcessing.h" +#include /// Ξcc±± analysis task struct HfTaskXicc { @@ -273,8 +285,8 @@ struct HfTaskXiccMc { registry.fill(HIST("hPtvsEtavsYGen"), particle.pt(), particle.eta(), RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCCPlusPlus)); } } // end of loop of MC particles - } // end of process function -}; // end of struct + } // end of process function +}; // end of struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGHF/D2H/Utils/utilsRedDataFormat.h b/PWGHF/D2H/Utils/utilsRedDataFormat.h index 9740e55d372..4e4bc2b9b3c 100644 --- a/PWGHF/D2H/Utils/utilsRedDataFormat.h +++ b/PWGHF/D2H/Utils/utilsRedDataFormat.h @@ -16,12 +16,17 @@ #ifndef PWGHF_D2H_UTILS_UTILSREDDATAFORMAT_H_ #define PWGHF_D2H_UTILS_UTILSREDDATAFORMAT_H_ -#include "Framework/HistogramRegistry.h" - -#include "CCDB/BasicCCDBManager.h" #include "PWGHF/Core/CentralityEstimation.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include +#include +#include + +#include + +#include + namespace o2::hf_evsel { /// Helper function to count collisions at different event selection stages @@ -76,6 +81,31 @@ float getTpcTofNSigmaPi1(const T1& prong1) } return defaultNSigma; } + +/// Helper function to retrive PID information of bachelor kaon from b-hadron decay +/// \param prong1 kaon track from reduced data format, aod::HfRedBachProng0Tracks +/// \return the combined TPC and TOF n-sigma for kaon +template +float getTpcTofNSigmaKa1(const T1& prong1) +{ + float defaultNSigma = -999.f; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h + + bool hasTpc = prong1.hasTPC(); + bool hasTof = prong1.hasTOF(); + + if (hasTpc && hasTof) { + float tpcNSigma = prong1.tpcNSigmaKa(); + float tofNSigma = prong1.tofNSigmaKa(); + return std::sqrt(.5f * tpcNSigma * tpcNSigma + .5f * tofNSigma * tofNSigma); + } + if (hasTpc) { + return std::abs(prong1.tpcNSigmaKa()); + } + if (hasTof) { + return std::abs(prong1.tofNSigmaKa()); + } + return defaultNSigma; +} } // namespace o2::pid_tpc_tof_utils #endif // PWGHF_D2H_UTILS_UTILSREDDATAFORMAT_H_ diff --git a/PWGHF/DataModel/CandidateReconstructionTables.h b/PWGHF/DataModel/CandidateReconstructionTables.h index f826d3ff620..8af9f18162d 100644 --- a/PWGHF/DataModel/CandidateReconstructionTables.h +++ b/PWGHF/DataModel/CandidateReconstructionTables.h @@ -18,27 +18,28 @@ #ifndef PWGHF_DATAMODEL_CANDIDATERECONSTRUCTIONTABLES_H_ #define PWGHF_DATAMODEL_CANDIDATERECONSTRUCTIONTABLES_H_ -#include - -#include "Math/GenVector/Boost.h" -#include "Math/Vector4D.h" - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGHF/Utils/utilsPid.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" #include "ALICE3/DataModel/ECAL.h" #include "Common/Core/RecoDecay.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" +#include +#include +#include -#include "PWGHF/Core/SelectorCuts.h" -#include "PWGHF/Utils/utilsPid.h" +#include +#include +#include namespace o2::aod { // Table aliases +using BcFullInfos = soa::Join; using TracksWCov = soa::Join; using TracksWDca = soa::Join; @@ -191,7 +192,7 @@ DECLARE_SOA_TABLE(PidTpcTofTinyPr, "AOD", "PIDTPCTOFTINYPR", //! Table of the TP namespace hf_sel_collision { -DECLARE_SOA_COLUMN(WhyRejectColl, whyRejectColl, uint16_t); //! +DECLARE_SOA_COLUMN(WhyRejectColl, whyRejectColl, uint32_t); //! } // namespace hf_sel_collision DECLARE_SOA_TABLE(HfSelCollision, "AOD", "HFSELCOLLISION", //! @@ -243,9 +244,11 @@ DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! Collision DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, Tracks, "_0"); //! Index to first prong DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, Tracks, "_1"); //! Index to second prong DECLARE_SOA_INDEX_COLUMN_FULL(Prong2, prong2, int, Tracks, "_2"); //! Index to third prong +DECLARE_SOA_INDEX_COLUMN_FULL(Prong3, prong3, int, Tracks, "_3"); //! Index to fourth prong +DECLARE_SOA_INDEX_COLUMN_FULL(Prong4, prong4, int, Tracks, "_4"); //! Index to fifth prong DECLARE_SOA_INDEX_COLUMN(V0, v0); //! Index to V0 prong DECLARE_SOA_INDEX_COLUMN(Cascade, cascade); //! Index to cascade prong -DECLARE_SOA_COLUMN(HFflag, hfflag, uint8_t); //! +DECLARE_SOA_COLUMN(HFflag, hfflag, uint8_t); //! Bitmap to store selection results, o2-linter: disable=name/o2-column (written to disk) DECLARE_SOA_COLUMN(FlagD0ToKPi, flagD0ToKPi, uint8_t); //! DECLARE_SOA_COLUMN(FlagJpsiToEE, flagJpsiToEE, uint8_t); //! @@ -483,28 +486,45 @@ DECLARE_SOA_COLUMN(ImpactParameterZ2, impactParameterZ2, float); DECLARE_SOA_COLUMN(ErrorImpactParameterZ2, errorImpactParameterZ2, float); //! DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterZNormalised2, impactParameterZNormalised2, //! [](float dca, float err) -> float { return dca / err; }); -/// prong PID nsigma +DECLARE_SOA_COLUMN(PxProng3, pxProng3, float); //! +DECLARE_SOA_COLUMN(PyProng3, pyProng3, float); //! +DECLARE_SOA_COLUMN(PzProng3, pzProng3, float); //! +DECLARE_SOA_DYNAMIC_COLUMN(PtProng3, ptProng3, //! + [](float px, float py) -> float { return RecoDecay::pt(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(Pt2Prong3, pt2Prong3, //! + [](float px, float py) -> float { return RecoDecay::pt2(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(PVectorProng3, pVectorProng3, //! + [](float px, float py, float pz) -> std::array { return std::array{px, py, pz}; }); +DECLARE_SOA_COLUMN(ImpactParameter3, impactParameter3, float); //! +DECLARE_SOA_COLUMN(ErrorImpactParameter3, errorImpactParameter3, float); //! +DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterNormalised3, impactParameterNormalised3, //! + [](float dca, float err) -> float { return dca / err; }); +DECLARE_SOA_COLUMN(ImpactParameterZ3, impactParameterZ3, float); //! +DECLARE_SOA_COLUMN(ErrorImpactParameterZ3, errorImpactParameterZ3, float); //! +DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterZNormalised3, impactParameterZNormalised3, //! + [](float dca, float err) -> float { return dca / err; }); DECLARE_SOA_COLUMN(NProngsContributorsPV, nProngsContributorsPV, uint8_t); //! number of prongs contributing to the primary-vertex reconstruction DECLARE_SOA_COLUMN(BitmapProngsContributorsPV, bitmapProngsContributorsPV, uint8_t); //! bitmap with booleans indicating prongs contributing to the primary-vertex reconstruction -DECLARE_SOA_COLUMN(NSigTpcPi0, nSigTpcPi0, float); //! TPC nSigma for pion hypothesis - prong 0 -DECLARE_SOA_COLUMN(NSigTpcPi1, nSigTpcPi1, float); //! TPC nSigma for pion hypothesis - prong 1 -DECLARE_SOA_COLUMN(NSigTpcPi2, nSigTpcPi2, float); //! TPC nSigma for pion hypothesis - prong 2 -DECLARE_SOA_COLUMN(NSigTpcKa0, nSigTpcKa0, float); //! TPC nSigma for kaon hypothesis - prong 0 -DECLARE_SOA_COLUMN(NSigTpcKa1, nSigTpcKa1, float); //! TPC nSigma for kaon hypothesis - prong 1 -DECLARE_SOA_COLUMN(NSigTpcKa2, nSigTpcKa2, float); //! TPC nSigma for kaon hypothesis - prong 2 -DECLARE_SOA_COLUMN(NSigTpcPr0, nSigTpcPr0, float); //! TPC nSigma for proton hypothesis - prong 0 -DECLARE_SOA_COLUMN(NSigTpcPr1, nSigTpcPr1, float); //! TPC nSigma for proton hypothesis - prong 1 -DECLARE_SOA_COLUMN(NSigTpcPr2, nSigTpcPr2, float); //! TPC nSigma for proton hypothesis - prong 2 -DECLARE_SOA_COLUMN(NSigTofPi0, nSigTofPi0, float); //! TOF nSigma for pion hypothesis - prong 0 -DECLARE_SOA_COLUMN(NSigTofPi1, nSigTofPi1, float); //! TOF nSigma for pion hypothesis - prong 1 -DECLARE_SOA_COLUMN(NSigTofPi2, nSigTofPi2, float); //! TOF nSigma for pion hypothesis - prong 2 -DECLARE_SOA_COLUMN(NSigTofKa0, nSigTofKa0, float); //! TOF nSigma for kaon hypothesis - prong 0 -DECLARE_SOA_COLUMN(NSigTofKa1, nSigTofKa1, float); //! TOF nSigma for kaon hypothesis - prong 1 -DECLARE_SOA_COLUMN(NSigTofKa2, nSigTofKa2, float); //! TOF nSigma for kaon hypothesis - prong 2 -DECLARE_SOA_COLUMN(NSigTofPr0, nSigTofPr0, float); //! TOF nSigma for proton hypothesis - prong 0 -DECLARE_SOA_COLUMN(NSigTofPr1, nSigTofPr1, float); //! TOF nSigma for proton hypothesis - prong 1 -DECLARE_SOA_COLUMN(NSigTofPr2, nSigTofPr2, float); //! TOF nSigma for proton hypothesis - prong 2 -DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPi0, tpcTofNSigmaPi0, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 0 +/// prong PID nsigma +DECLARE_SOA_COLUMN(NSigTpcPi0, nSigTpcPi0, float); //! TPC nSigma for pion hypothesis - prong 0 +DECLARE_SOA_COLUMN(NSigTpcPi1, nSigTpcPi1, float); //! TPC nSigma for pion hypothesis - prong 1 +DECLARE_SOA_COLUMN(NSigTpcPi2, nSigTpcPi2, float); //! TPC nSigma for pion hypothesis - prong 2 +DECLARE_SOA_COLUMN(NSigTpcKa0, nSigTpcKa0, float); //! TPC nSigma for kaon hypothesis - prong 0 +DECLARE_SOA_COLUMN(NSigTpcKa1, nSigTpcKa1, float); //! TPC nSigma for kaon hypothesis - prong 1 +DECLARE_SOA_COLUMN(NSigTpcKa2, nSigTpcKa2, float); //! TPC nSigma for kaon hypothesis - prong 2 +DECLARE_SOA_COLUMN(NSigTpcPr0, nSigTpcPr0, float); //! TPC nSigma for proton hypothesis - prong 0 +DECLARE_SOA_COLUMN(NSigTpcPr1, nSigTpcPr1, float); //! TPC nSigma for proton hypothesis - prong 1 +DECLARE_SOA_COLUMN(NSigTpcPr2, nSigTpcPr2, float); //! TPC nSigma for proton hypothesis - prong 2 +DECLARE_SOA_COLUMN(NSigTofPi0, nSigTofPi0, float); //! TOF nSigma for pion hypothesis - prong 0 +DECLARE_SOA_COLUMN(NSigTofPi1, nSigTofPi1, float); //! TOF nSigma for pion hypothesis - prong 1 +DECLARE_SOA_COLUMN(NSigTofPi2, nSigTofPi2, float); //! TOF nSigma for pion hypothesis - prong 2 +DECLARE_SOA_COLUMN(NSigTofKa0, nSigTofKa0, float); //! TOF nSigma for kaon hypothesis - prong 0 +DECLARE_SOA_COLUMN(NSigTofKa1, nSigTofKa1, float); //! TOF nSigma for kaon hypothesis - prong 1 +DECLARE_SOA_COLUMN(NSigTofKa2, nSigTofKa2, float); //! TOF nSigma for kaon hypothesis - prong 2 +DECLARE_SOA_COLUMN(NSigTofPr0, nSigTofPr0, float); //! TOF nSigma for proton hypothesis - prong 0 +DECLARE_SOA_COLUMN(NSigTofPr1, nSigTofPr1, float); //! TOF nSigma for proton hypothesis - prong 1 +DECLARE_SOA_COLUMN(NSigTofPr2, nSigTofPr2, float); //! TOF nSigma for proton hypothesis - prong 2 +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPi0, tpcTofNSigmaPi0, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 0 [](float tpcNSigmaPi0, float tofNSigmaPi0) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi0, tofNSigmaPi0); }); DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPi1, tpcTofNSigmaPi1, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 1 [](float tpcNSigmaPi1, float tofNSigmaPi1) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi1, tofNSigmaPi1); }); @@ -573,9 +593,9 @@ DECLARE_SOA_DYNAMIC_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, //! [](float xVtxP, float yVtxP, float xVtxS, float yVtxS, float err) -> float { return RecoDecay::distanceXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}) / err; }); DECLARE_SOA_COLUMN(ErrorDecayLength, errorDecayLength, float); //! DECLARE_SOA_COLUMN(ErrorDecayLengthXY, errorDecayLengthXY, float); //! -DECLARE_SOA_DYNAMIC_COLUMN(CPA, cpa, //! +DECLARE_SOA_DYNAMIC_COLUMN(Cpa, cpa, //! [](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz) -> float { return RecoDecay::cpa(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); }); -DECLARE_SOA_DYNAMIC_COLUMN(CPAXY, cpaXY, //! +DECLARE_SOA_DYNAMIC_COLUMN(CpaXY, cpaXY, //! [](float xVtxP, float yVtxP, float xVtxS, float yVtxS, float px, float py) -> float { return RecoDecay::cpaXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, std::array{px, py}); }); DECLARE_SOA_DYNAMIC_COLUMN(Ct, ct, //! [](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz, double m) -> float { return RecoDecay::ct(std::array{px, py, pz}, RecoDecay::distance(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}), m); }); @@ -586,8 +606,9 @@ DECLARE_SOA_COLUMN(KfTopolChi2OverNdf, kfTopolChi2OverNdf, float); //! chi2overn DECLARE_SOA_COLUMN(PtBhadMotherPart, ptBhadMotherPart, float); //! pt of the first B-hadron mother particle (only in case of non-prompt) DECLARE_SOA_COLUMN(PdgBhadMotherPart, pdgBhadMotherPart, int); //! pdg of the first B-hadron mother particle (only in case of non-prompt) DECLARE_SOA_COLUMN(IdxBhadMotherPart, idxBhadMotherPart, int); //! index of the first B-hadron mother particle (only in case of non-prompt) -// Kink topology mc flag -DECLARE_SOA_COLUMN(NTracksDecayed, nTracksDecayed, int8_t); //! number of tracks matched with kinked decay topology +// Kink topology and material interaction mc flags +DECLARE_SOA_COLUMN(NTracksDecayed, nTracksDecayed, int8_t); //! number of tracks matched with kinked decay topology +DECLARE_SOA_COLUMN(NInteractionsWithMaterial, nInteractionsWithMaterial, int8_t); //! number of tracks matched after interaction with material // method of secondary-vertex reconstruction enum VertexerType { DCAFitter = 0, @@ -615,11 +636,16 @@ DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterProngSqSum, impactParameterProngSqSum, [](float impParProng0, float impParProng1) -> float { return RecoDecay::sumOfSquares(impParProng0, impParProng1); }); DECLARE_SOA_DYNAMIC_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, //! [](float xVtxP, float yVtxP, float xVtxS, float yVtxS, float errDlxy, float pxM, float pyM, float ip0, float errIp0, float ip1, float errIp1, float px0, float py0, float px1, float py1) -> float { return RecoDecay::maxNormalisedDeltaIP(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, errDlxy, std::array{pxM, pyM}, std::array{ip0, ip1}, std::array{errIp0, errIp1}, std::array{std::array{px0, py0}, std::array{px1, py1}}); }); +DECLARE_SOA_DYNAMIC_COLUMN(CtXY, ctXY, //! + [](float px0, float py0, float pz0, float px1, float py1, float pz1, float xVtxP, float yVtxP, float xVtxS, float yVtxS, const std::array& m) -> float { return RecoDecay::ctXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, m); }); // MC matching result: -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level -DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! particle origin, reconstruction level -DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, generator level +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! particle origin, reconstruction level +DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, generator level +DECLARE_SOA_COLUMN(FlagMcDecayChanRec, flagMcDecayChanRec, int8_t); //! resonant decay channel flag, reconstruction level +DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); //! resonant decay channel flag, reconstruction level + // KF related properties DECLARE_SOA_COLUMN(KfGeoMassD0, kfGeoMassD0, float); //! mass of the D0 candidate from the KFParticle geometric fit DECLARE_SOA_COLUMN(KfGeoMassD0bar, kfGeoMassD0bar, float); //! mass of the D0bar candidate from the KFParticle geometric fit @@ -679,8 +705,8 @@ DECLARE_SOA_TABLE(HfCand2ProngBase, "AOD", "HFCAND2PBASE", //! hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_2prong::MaxNormalisedDeltaIP, @@ -733,14 +759,17 @@ DECLARE_SOA_TABLE(HfCand2ProngKF, "AOD", "HFCAND2PKF", DECLARE_SOA_TABLE(HfCand2ProngMcRec, "AOD", "HFCAND2PMCREC", //! hf_cand_2prong::FlagMcMatchRec, hf_cand_2prong::OriginMcRec, + hf_cand_2prong::FlagMcDecayChanRec, hf_cand::PtBhadMotherPart, hf_cand::PdgBhadMotherPart, - hf_cand::NTracksDecayed); + hf_cand::NTracksDecayed, + hf_cand::NInteractionsWithMaterial); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCand2ProngMcGen, "AOD", "HFCAND2PMCGEN", //! hf_cand_2prong::FlagMcMatchGen, hf_cand_2prong::OriginMcGen, + hf_cand_2prong::FlagMcDecayChanGen, hf_cand::IdxBhadMotherPart); // cascade decay candidate table @@ -764,9 +793,9 @@ DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction l DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! particle origin, reconstruction level DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, generator level -DECLARE_SOA_COLUMN(V0X, v0x, float); //! X position of V0 decay -DECLARE_SOA_COLUMN(V0Y, v0y, float); //! Y position of V0 decay -DECLARE_SOA_COLUMN(V0Z, v0z, float); //! Z position of V0 decay +DECLARE_SOA_COLUMN(V0X, v0X, float); //! X position of V0 decay +DECLARE_SOA_COLUMN(V0Y, v0Y, float); //! Y position of V0 decay +DECLARE_SOA_COLUMN(V0Z, v0Z, float); //! Z position of V0 decay } // namespace hf_cand_casc DECLARE_SOA_TABLE(HfCandCascBase, "AOD", "HFCANDCASCBASE", //! @@ -799,8 +828,8 @@ DECLARE_SOA_TABLE(HfCandCascBase, "AOD", "HFCANDCASCBASE", //! hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_2prong::MaxNormalisedDeltaIP, @@ -847,19 +876,31 @@ namespace hf_cand_bplus { DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfCand2Prong, "_0"); // D0 index // MC matching result: -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level -DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); // reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // generator level -DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); // particle origin, reconstruction level -DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); // particle origin, generator level -DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // main decay channel, reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // main decay channel, generator level +DECLARE_SOA_COLUMN(FlagMcDecayChanRec, flagMcDecayChanRec, int8_t); // resonant decay channel, reconstruction level +DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); // resonant decay channel, generator level +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); // particle origin, reconstruction level +DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); // particle origin, generator level +DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); // reconstruction level +DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level +DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterProduct, impactParameterProduct, // Impact parameter product for B+ -> J/Psi K + [](float px0, float py0, float pz0, float px1, float py1, float pz1, float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float impParK) -> float { return impParK * RecoDecay::impParXY(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, RecoDecay::pVec(std::array{px0, py0, pz0}, std::array{px1, py1, pz1})); }); +DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterProductJpsi, impactParameterProductJpsi, // J/Psi impact parameter for B+ -> J/Psi K + [](float dcaDauPos, float dcaDauNeg) -> float { return dcaDauPos * dcaDauNeg; }); enum DecayType { BplusToD0Pi = 0 }; enum DecayTypeMc : uint8_t { BplusToD0PiToKPiPi = 0, + BplusToD0KToKPiK, PartlyRecoDecay, OtherDecay, NDecayTypeMc }; + +enum class DecayTypeBToJpsiMc : uint8_t { BplusToJpsiKToMuMuK = 0, + PartlyRecoDecay, + OtherDecay, + NDecayTypeMc }; } // namespace hf_cand_bplus // declare dedicated BPlus decay candidate table @@ -884,8 +925,8 @@ DECLARE_SOA_TABLE(HfCandBplusBase, "AOD", "HFCANDBPLUSBASE", hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_2prong::MaxNormalisedDeltaIP, @@ -893,7 +934,8 @@ DECLARE_SOA_TABLE(HfCandBplusBase, "AOD", "HFCANDBPLUSBASE", hf_cand::Phi, hf_cand::Y, hf_cand::E, - hf_cand::E2); + hf_cand::E2, + hf_cand_2prong::CtXY); // extended table with expression columns that can be used as arguments of dynamic columns DECLARE_SOA_EXTENDED_TABLE_USER(HfCandBplusExt, HfCandBplusBase, "HFCANDBPLUSEXT", @@ -907,11 +949,13 @@ using HfCandBplus = soa::Join; // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCandBplusMcRec, "AOD", "HFCANDBPMCREC", hf_cand_bplus::FlagMcMatchRec, + hf_cand_bplus::FlagMcDecayChanRec, hf_cand_bplus::OriginMcRec); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCandBplusMcGen, "AOD", "HFCANDBPMCGEN", hf_cand_bplus::FlagMcMatchGen, + hf_cand_bplus::FlagMcDecayChanGen, hf_cand_bplus::OriginMcGen); // specific 3-prong decay properties @@ -931,6 +975,10 @@ DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterProngSqSum, impactParameterProngSqSum, [](float impParProng0, float impParProng1, float impParProng2) -> float { return RecoDecay::sumOfSquares(impParProng0, impParProng1, impParProng2); }); DECLARE_SOA_DYNAMIC_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, //! [](float xVtxP, float yVtxP, float xVtxS, float yVtxS, float errDlxy, float pxM, float pyM, float ip0, float errIp0, float ip1, float errIp1, float ip2, float errIp2, float px0, float py0, float px1, float py1, float px2, float py2) -> float { return RecoDecay::maxNormalisedDeltaIP(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, errDlxy, std::array{pxM, pyM}, std::array{ip0, ip1, ip2}, std::array{errIp0, errIp1, errIp2}, std::array{std::array{px0, py0}, std::array{px1, py1}, std::array{px2, py2}}); }); +DECLARE_SOA_DYNAMIC_COLUMN(CtXY, ctXY, //! + [](float px0, float py0, float pz0, float px1, float py1, float pz1, float px2, float py2, float pz2, float xVtxP, float yVtxP, float xVtxS, float yVtxS, const std::array& m) -> float { + return RecoDecay::ctXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}, std::array{px2, py2, pz2}}, m); + }); // MC matching result: DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction level DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level @@ -947,6 +995,8 @@ enum DecayType { DplusToPiKPi = 0, XicToPKPi, N3ProngDecays }; // always keep N3ProngDecays at the end +static constexpr int DstarToPiKPiBkg = DecayType::N3ProngDecays; + // Ds± → K± K∓ π± or D± → K± K∓ π± enum DecayChannelDToKKPi { @@ -956,6 +1006,40 @@ enum DecayChannelDToKKPi { DplusToK0starK // used to describe D+ in MC production for Ds analysis }; +// KF related properties +DECLARE_SOA_COLUMN(KfXPVError, kfXPVError, float); //! error of X coordinate of the event's primary vertex +DECLARE_SOA_COLUMN(KfYPVError, kfYPVError, float); //! error of Y coordinate of the event's primary vertex +DECLARE_SOA_COLUMN(KfZPVError, kfZPVError, float); //! error of Z coordinate of the event's primary vertex +DECLARE_SOA_COLUMN(KfXError, kfXError, float); //! error of candidate's decay point X coordinate from the KFParticle fit +DECLARE_SOA_COLUMN(KfYError, kfYError, float); //! error of candidate's decay point Y coordinate from the KFParticle fit +DECLARE_SOA_COLUMN(KfZError, kfZError, float); //! error of candidate's decay point Z coordinate from the KFParticle fit +DECLARE_SOA_COLUMN(KfMassPKPi, kfMassPKPi, float); //! mass of the PKPi candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfMassPiKP, kfMassPiKP, float); //! mass of the PiKP candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfMassPiKPi, kfMassPiKPi, float); //! mass of the PiKPi candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfMassKKPi, kfMassKKPi, float); //! mass of the KKPi candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfMassPiKK, kfMassPiKK, float); //! mass of the PiKK candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfMassKPi, kfMassKPi, float); //! mass of the KPi pair from the KFParticle fit +DECLARE_SOA_COLUMN(KfMassPiK, kfMassPiK, float); //! mass of the PiK pair from the KFParticle fit +DECLARE_SOA_COLUMN(KfPx, kfPx, float); //! Px of the candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfPy, kfPy, float); //! Py of the candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfPz, kfPz, float); //! Pz of the candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfErrorPx, kfErrorPx, float); //! Px error of the candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfErrorPy, kfErrorPy, float); //! Py error of the candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfErrorPz, kfErrorPz, float); //! Pz error of the candidate from the KFParticle fit +DECLARE_SOA_COLUMN(KfChi2PrimProng0, kfChi2PrimProng0, float); //! chi2 primary of the first prong +DECLARE_SOA_COLUMN(KfChi2PrimProng1, kfChi2PrimProng1, float); //! chi2 primary of the second prong +DECLARE_SOA_COLUMN(KfChi2PrimProng2, kfChi2PrimProng2, float); //! chi2 primary of the third prong +DECLARE_SOA_COLUMN(KfDcaProng0Prong1, kfDcaProng0Prong1, float); //! DCA between first and second prongs +DECLARE_SOA_COLUMN(KfDcaProng0Prong2, kfDcaProng0Prong2, float); //! DCA between first and third prongs +DECLARE_SOA_COLUMN(KfDcaProng1Prong2, kfDcaProng1Prong2, float); //! DCA between second and third prongs +DECLARE_SOA_COLUMN(KfChi2GeoProng0Prong1, kfChi2GeoProng0Prong1, float); //! chi2 geo between first and second prongs +DECLARE_SOA_COLUMN(KfChi2GeoProng0Prong2, kfChi2GeoProng0Prong2, float); //! chi2 geo between first and third prongs +DECLARE_SOA_COLUMN(KfChi2GeoProng1Prong2, kfChi2GeoProng1Prong2, float); //! chi2 geo between second and third prongs +DECLARE_SOA_COLUMN(KfChi2Geo, kfChi2Geo, float); //! chi2 geo of the full candidate +DECLARE_SOA_COLUMN(KfChi2Topo, kfChi2Topo, float); //! chi2 topo of the full candidate (chi2prim of candidate to PV) +DECLARE_SOA_COLUMN(KfDecayLength, kfDecayLength, float); //! decay length +DECLARE_SOA_COLUMN(KfDecayLengthError, kfDecayLengthError, float); //! decay length error + } // namespace hf_cand_3prong // 3-prong decay candidate table @@ -988,8 +1072,8 @@ DECLARE_SOA_TABLE(HfCand3ProngBase, "AOD", "HFCAND3PBASE", //! hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_3prong::MaxNormalisedDeltaIP, @@ -1004,6 +1088,19 @@ DECLARE_SOA_EXTENDED_TABLE_USER(HfCand3ProngExt, HfCand3ProngBase, "HFCAND3PEXT" hf_cand_3prong::Px, hf_cand_3prong::Py, hf_cand_3prong::Pz); using HfCand3Prong = HfCand3ProngExt; +using HfCand3ProngWPidPiKaPr = soa::Join; +using HfCand3ProngWPidPiKa = soa::Join; + +DECLARE_SOA_TABLE(HfCand3ProngKF, "AOD", "HFCAND3PKF", + hf_cand_3prong::KfXError, hf_cand_3prong::KfYError, hf_cand_3prong::KfZError, + hf_cand_3prong::KfXPVError, hf_cand_3prong::KfYPVError, hf_cand_3prong::KfZPVError, + hf_cand_3prong::KfMassPKPi, hf_cand_3prong::KfMassPiKP, hf_cand_3prong::KfMassPiKPi, hf_cand_3prong::KfMassKKPi, hf_cand_3prong::KfMassPiKK, hf_cand_3prong::KfMassKPi, hf_cand_3prong::KfMassPiK, + hf_cand_3prong::KfPx, hf_cand_3prong::KfPy, hf_cand_3prong::KfPz, + hf_cand_3prong::KfErrorPx, hf_cand_3prong::KfErrorPy, hf_cand_3prong::KfErrorPz, + hf_cand_3prong::KfChi2PrimProng0, hf_cand_3prong::KfChi2PrimProng1, hf_cand_3prong::KfChi2PrimProng2, + hf_cand_3prong::KfDcaProng1Prong2, hf_cand_3prong::KfDcaProng0Prong2, hf_cand_3prong::KfDcaProng0Prong1, + hf_cand_3prong::KfChi2GeoProng1Prong2, hf_cand_3prong::KfChi2GeoProng0Prong2, hf_cand_3prong::KfChi2GeoProng0Prong1, + hf_cand_3prong::KfChi2Geo, hf_cand_3prong::KfDecayLength, hf_cand_3prong::KfDecayLengthError, hf_cand_3prong::KfChi2Topo); // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCand3ProngMcRec, "AOD", "HFCAND3PMCREC", //! @@ -1013,7 +1110,8 @@ DECLARE_SOA_TABLE(HfCand3ProngMcRec, "AOD", "HFCAND3PMCREC", //! hf_cand_3prong::FlagMcDecayChanRec, hf_cand::PtBhadMotherPart, hf_cand::PdgBhadMotherPart, - hf_cand::NTracksDecayed); + hf_cand::NTracksDecayed, + hf_cand::NInteractionsWithMaterial); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCand3ProngMcGen, "AOD", "HFCAND3PMCGEN", //! @@ -1022,6 +1120,55 @@ DECLARE_SOA_TABLE(HfCand3ProngMcGen, "AOD", "HFCAND3PMCGEN", //! hf_cand_3prong::FlagMcDecayChanGen, hf_cand::IdxBhadMotherPart); +// declare dedicated BPlus -> J/Psi K decay candidate table +// convention: prongs 0 and 1 should be J/Psi decay products +DECLARE_SOA_TABLE(HfCandBpJPBase, "AOD", "HFCANDBPJPBASE", + // general columns + HFCAND_COLUMNS, + /* prong 2 */ hf_cand::ImpactParameterNormalised2, + hf_cand::PtProng2, + hf_cand::Pt2Prong2, + hf_cand::PVectorProng2, + // 3-prong specific columns + o2::soa::Index<>, + hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, + hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, + hf_cand::PxProng2, hf_cand::PyProng2, hf_cand::PzProng2, + hf_cand::ImpactParameter0, hf_cand::ImpactParameter1, hf_cand::ImpactParameter2, + hf_cand::ErrorImpactParameter0, hf_cand::ErrorImpactParameter1, hf_cand::ErrorImpactParameter2, + /* dynamic columns */ + hf_cand_3prong::M, + hf_cand_3prong::M2, + hf_cand_3prong::ImpactParameterProngSqSum, + hf_cand_bplus::ImpactParameterProduct, + hf_cand_bplus::ImpactParameterProductJpsi, + /* dynamic columns that use candidate momentum components */ + hf_cand::Pt, + hf_cand::Pt2, + hf_cand::P, + hf_cand::P2, + hf_cand::PVector, + hf_cand::Cpa, + hf_cand::CpaXY, + hf_cand::Ct, + hf_cand::ImpactParameterXY, + hf_cand_3prong::MaxNormalisedDeltaIP, + hf_cand::Eta, + hf_cand::Phi, + hf_cand::Y, + hf_cand::E, + hf_cand::E2, + hf_cand_3prong::CtXY); + +// extended table with expression columns that can be used as arguments of dynamic columns +DECLARE_SOA_EXTENDED_TABLE_USER(HfCandBpJPExt, HfCandBpJPBase, "HFCANDBPJPEXT", + hf_cand_3prong::Px, hf_cand_3prong::Py, hf_cand_3prong::Pz); + +DECLARE_SOA_TABLE(HfCandBpJPDaus, "AOD", "HFCANDBPJPDAUS", + hf_track_index::Prong0Id, hf_track_index::Prong1Id, hf_track_index::Prong2Id); + +using HfCandBplusToJpsi = soa::Join; + namespace hf_cand_casc_lf { // mapping of decay types @@ -1029,7 +1176,9 @@ enum DecayType2Prong { XiczeroOmegaczeroToXiPi = 0, OmegaczeroToOmegaPi, OmegaczeroToOmegaK, N2ProngDecays }; // always keep N2ProngDecays at the end - +// mapping of construct method +enum ConstructMethod { DcaFitter = 0, + KfParticle }; // mapping of decay types enum DecayType3Prong { XicplusToXiPiPi = 0, N3ProngDecays }; // always keep N3ProngDecays at the end @@ -1076,8 +1225,8 @@ DECLARE_SOA_TABLE(HfCandXBase, "AOD", "HFCANDXBASE", hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_3prong::MaxNormalisedDeltaIP, @@ -1140,8 +1289,8 @@ DECLARE_SOA_TABLE(HfCandXiccBase, "AOD", "HFCANDXICCBASE", hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_2prong::MaxNormalisedDeltaIP, @@ -1231,10 +1380,10 @@ DECLARE_SOA_COLUMN(CosPACasc, cosPACasc, float); DECLARE_SOA_COLUMN(CosPAXYV0, cosPAXYV0, float); DECLARE_SOA_COLUMN(CosPAXYCharmBaryon, cosPAXYCharmBaryon, float); DECLARE_SOA_COLUMN(CosPAXYCasc, cosPAXYCasc, float); -DECLARE_SOA_COLUMN(CTauOmegac, ctauOmegac, float); -DECLARE_SOA_COLUMN(CTauCascade, ctauCascade, float); -DECLARE_SOA_COLUMN(CTauV0, ctauV0, float); -DECLARE_SOA_COLUMN(CTauXic, ctauXic, float); +DECLARE_SOA_COLUMN(CTauOmegac, cTauOmegac, float); +DECLARE_SOA_COLUMN(CTauCascade, cTauCascade, float); +DECLARE_SOA_COLUMN(CTauV0, cTauV0, float); +DECLARE_SOA_COLUMN(CTauXic, cTauXic, float); DECLARE_SOA_COLUMN(EtaV0PosDau, etaV0PosDau, float); DECLARE_SOA_COLUMN(EtaV0NegDau, etaV0NegDau, float); DECLARE_SOA_COLUMN(EtaBachFromCasc, etaBachFromCasc, float); @@ -1258,6 +1407,50 @@ DECLARE_SOA_COLUMN(ErrorDecayLengthCharmBaryon, errorDecayLengthCharmBaryon, flo DECLARE_SOA_COLUMN(ErrorDecayLengthXYCharmBaryon, errorDecayLengthXYCharmBaryon, float); // KFParticle results +DECLARE_SOA_COLUMN(XPvKf, xPvKf, float); +DECLARE_SOA_COLUMN(YPvKf, yPvKf, float); +DECLARE_SOA_COLUMN(ZPvKf, zPvKf, float); +DECLARE_SOA_COLUMN(XDecayVtxV0Kf, xDecayVtxV0Kf, float); +DECLARE_SOA_COLUMN(YDecayVtxV0Kf, yDecayVtxV0Kf, float); +DECLARE_SOA_COLUMN(ZDecayVtxV0Kf, zDecayVtxV0Kf, float); +DECLARE_SOA_COLUMN(XDecayVtxCascadeKf, xDecayVtxCascadeKf, float); +DECLARE_SOA_COLUMN(YDecayVtxCascadeKf, yDecayVtxCascadeKf, float); +DECLARE_SOA_COLUMN(ZDecayVtxCascadeKf, zDecayVtxCascadeKf, float); +DECLARE_SOA_COLUMN(PxLambdaKf, pxLambdaKf, float); +DECLARE_SOA_COLUMN(PyLambdaKf, pyLambdaKf, float); +DECLARE_SOA_COLUMN(PzLambdaKf, pzLambdaKf, float); +DECLARE_SOA_COLUMN(PxCascKf, pxCascKf, float); +DECLARE_SOA_COLUMN(PyCascKf, pyCascKf, float); +DECLARE_SOA_COLUMN(PzCascKf, pzCascKf, float); +DECLARE_SOA_COLUMN(XDecayVtxOmegaKaKf, xDecayVtxOmegaKaKf, float); +DECLARE_SOA_COLUMN(YDecayVtxOmegaKaKf, yDecayVtxOmegaKaKf, float); +DECLARE_SOA_COLUMN(ZDecayVtxOmegaKaKf, zDecayVtxOmegaKaKf, float); +DECLARE_SOA_COLUMN(PxOmegaKaKf, pxOmegaKaKf, float); +DECLARE_SOA_COLUMN(PyOmegaKaKf, pyOmegaKaKf, float); +DECLARE_SOA_COLUMN(PzOmegaKaKf, pzOmegaKaKf, float); +DECLARE_SOA_COLUMN(EtaV0DauPr, etaV0DauPr, float); +DECLARE_SOA_COLUMN(EtaV0DauPi, etaV0DauPi, float); +DECLARE_SOA_COLUMN(InvMassCascadeRej, invMassCascadeRej, float); +DECLARE_SOA_COLUMN(InvMassLambdaErr, invMassLambdaErr, float); +DECLARE_SOA_COLUMN(InvMassCascadeErr, invMassCascadeErr, float); +DECLARE_SOA_COLUMN(InvMassCascadeRejErr, invMassCascadeRejErr, float); +DECLARE_SOA_COLUMN(InvMassCharmBaryonErr, invMassCharmBaryonErr, float); +DECLARE_SOA_COLUMN(CTauOmegaKa, cTauOmegaKa, float); +DECLARE_SOA_COLUMN(Chi2GeoOmegaKa, chi2GeoOmegaKa, float); +DECLARE_SOA_COLUMN(OmegaKaldl, omegaKaldl, float); +DECLARE_SOA_COLUMN(Chi2TopoKaFromOmegaKaToPv, chi2TopoKaFromOmegaKaToPv, float); +DECLARE_SOA_COLUMN(Chi2TopoOmegaKaToPv, chi2TopoOmegaKaToPv, float); +DECLARE_SOA_COLUMN(Chi2TopoKaToCasc, chi2TopoKaToCasc, float); +DECLARE_SOA_COLUMN(Chi2TopoCascToOmegaKa, chi2TopoCascToOmegaKa, float); +DECLARE_SOA_COLUMN(Chi2TopoKaToOmegaKa, chi2TopoKaToOmegaKa, float); +DECLARE_SOA_COLUMN(CosPaCascToOmegaKa, cosPaCascToOmegaKa, float); +DECLARE_SOA_COLUMN(CosPaXYCascToOmegaKa, cosPaXYCascToOmegaKa, float); +DECLARE_SOA_COLUMN(KfRapOmegaKa, kfRapOmegaKa, float); +DECLARE_SOA_COLUMN(KfPtKaFromOmegaKa, kfPtKaFromOmegaKa, float); +DECLARE_SOA_COLUMN(KfPtOmega, kfPtOmega, float); +DECLARE_SOA_COLUMN(KfPtOmegaKa, kfPtOmegaKa, float); +DECLARE_SOA_COLUMN(CosThetaStarKaFromOmegac, cosThetaStarKaFromOmegac, float); +DECLARE_SOA_COLUMN(CosThetaStarKaFromXic, cosThetaStarKaFromXic, float); DECLARE_SOA_COLUMN(KfDcaXYPiFromOmegac, kfDcaXYPiFromOmegac, float); DECLARE_SOA_COLUMN(KfDcaXYPiFromXic, kfDcaXYPiFromXic, float); DECLARE_SOA_COLUMN(KfDcaXYCascToPv, kfDcaXYCascToPv, float); @@ -1276,6 +1469,7 @@ DECLARE_SOA_COLUMN(Chi2TopoCascToPv, chi2TopoCascToPv, float); DECLARE_SOA_COLUMN(Chi2TopoPiFromOmegacToPv, chi2TopoPiFromOmegacToPv, float); DECLARE_SOA_COLUMN(Chi2TopoPiFromXicToPv, chi2TopoPiFromXicToPv, float); DECLARE_SOA_COLUMN(Chi2TopoOmegacToPv, chi2TopoOmegacToPv, float); +DECLARE_SOA_COLUMN(DeviationPiFromOmegacToPv, deviationPiFromOmegacToPv, float); DECLARE_SOA_COLUMN(Chi2TopoXicToPv, chi2TopoXicToPv, float); DECLARE_SOA_COLUMN(Chi2TopoV0ToCasc, chi2TopoV0ToCasc, float); DECLARE_SOA_COLUMN(Chi2TopoCascToOmegac, chi2TopoCascToOmegac, float); @@ -1296,9 +1490,7 @@ DECLARE_SOA_COLUMN(KfMassOmegac, kfMassOmegac, float); DECLARE_SOA_COLUMN(KfRapOmegac, kfRapOmegac, float); DECLARE_SOA_COLUMN(KfRapXic, kfRapXic, float); DECLARE_SOA_COLUMN(KfptPiFromOmegac, kfptPiFromOmegac, float); -DECLARE_SOA_COLUMN(KfptPiFromXic, kfptPiFromXic, float); DECLARE_SOA_COLUMN(KfptOmegac, kfptOmegac, float); -DECLARE_SOA_COLUMN(KfptXic, kfptXic, float); DECLARE_SOA_COLUMN(CosThetaStarPiFromOmegac, cosThetaStarPiFromOmegac, float); DECLARE_SOA_COLUMN(CosThetaStarPiFromXic, cosThetaStarPiFromXic, float); DECLARE_SOA_COLUMN(V0Ndf, v0Ndf, float); @@ -1313,6 +1505,59 @@ DECLARE_SOA_COLUMN(OmegacChi2OverNdf, omegacChi2OverNdf, float); DECLARE_SOA_COLUMN(XicChi2OverNdf, xicChi2OverNdf, float); DECLARE_SOA_COLUMN(MassV0Chi2OverNdf, massV0Chi2OverNdf, float); DECLARE_SOA_COLUMN(MassCascChi2OverNdf, massCascChi2OverNdf, float); +DECLARE_SOA_COLUMN(CascRejectInvmass, cascRejectInvmass, float); + +// Kf QA results: +DECLARE_SOA_COLUMN(InvMassV0Err, invMassV0Err, float); +DECLARE_SOA_COLUMN(InvMassXiErr, invMassXiErr, float); +DECLARE_SOA_COLUMN(InvMassXic0Err, invMassXic0Err, float); +DECLARE_SOA_COLUMN(V0DauPosX, v0DauPosX, float); +DECLARE_SOA_COLUMN(V0DauPosY, v0DauPosY, float); +DECLARE_SOA_COLUMN(V0DauPosZ, v0DauPosZ, float); +DECLARE_SOA_COLUMN(V0DauPosXError, v0DauPosXError, float); +DECLARE_SOA_COLUMN(V0DauPosYError, v0DauPosYError, float); +DECLARE_SOA_COLUMN(V0DauPosZError, v0DauPosZError, float); +DECLARE_SOA_COLUMN(V0DauPosPt, v0DauPosPt, float); +DECLARE_SOA_COLUMN(V0DauNegX, v0DauNegX, float); +DECLARE_SOA_COLUMN(V0DauNegY, v0DauNegY, float); +DECLARE_SOA_COLUMN(V0DauNegZ, v0DauNegZ, float); +DECLARE_SOA_COLUMN(V0DauNegXError, v0DauNegXError, float); +DECLARE_SOA_COLUMN(V0DauNegYError, v0DauNegYError, float); +DECLARE_SOA_COLUMN(V0DauNegZError, v0DauNegZError, float); +DECLARE_SOA_COLUMN(V0DauNegPt, v0DauNegPt, float); + +DECLARE_SOA_COLUMN(V0VtxX, v0VtxX, float); +DECLARE_SOA_COLUMN(V0VtxY, v0VtxY, float); +DECLARE_SOA_COLUMN(V0VtxZ, v0VtxZ, float); +DECLARE_SOA_COLUMN(V0XError, v0XError, float); +DECLARE_SOA_COLUMN(V0YError, v0YError, float); +DECLARE_SOA_COLUMN(V0ZError, v0ZError, float); +DECLARE_SOA_COLUMN(V0Pt, v0Pt, float); +DECLARE_SOA_COLUMN(XiBachelorX, xiBachelorX, float); +DECLARE_SOA_COLUMN(XiBachelorY, xiBachelorY, float); +DECLARE_SOA_COLUMN(XiBachelorZ, xiBachelorZ, float); +DECLARE_SOA_COLUMN(XiBachelorPt, xiBachelorPt, float); +DECLARE_SOA_COLUMN(XiBachelorXError, xiBachelorXError, float); +DECLARE_SOA_COLUMN(XiBachelorYError, xiBachelorYError, float); +DECLARE_SOA_COLUMN(XiBachelorZError, xiBachelorZError, float); +DECLARE_SOA_COLUMN(XiX, xiX, float); +DECLARE_SOA_COLUMN(XiY, xiY, float); +DECLARE_SOA_COLUMN(XiZ, xiZ, float); +DECLARE_SOA_COLUMN(XiXError, xiXError, float); +DECLARE_SOA_COLUMN(XiYError, xiYError, float); +DECLARE_SOA_COLUMN(XiZError, xiZError, float); +DECLARE_SOA_COLUMN(XiPt, xiPt, float); +DECLARE_SOA_COLUMN(Xic0BachelorX, xic0BachelorX, float); +DECLARE_SOA_COLUMN(Xic0BachelorY, xic0BachelorY, float); +DECLARE_SOA_COLUMN(Xic0BachelorZ, xic0BachelorZ, float); +DECLARE_SOA_COLUMN(Xic0BachelorPt, xic0BachelorPt, float); +DECLARE_SOA_COLUMN(Xic0BachelorXError, xic0BachelorXError, float); +DECLARE_SOA_COLUMN(Xic0BachelorYError, xic0BachelorYError, float); +DECLARE_SOA_COLUMN(Xic0BachelorZError, xic0BachelorZError, float); +DECLARE_SOA_COLUMN(Xic0Pt, xic0Pt, float); +DECLARE_SOA_COLUMN(Xic0XError, xic0XError, float); +DECLARE_SOA_COLUMN(Xic0YError, xic0YError, float); +DECLARE_SOA_COLUMN(Xic0ZError, xic0ZError, float); // MC matching result: DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level @@ -1322,8 +1567,8 @@ DECLARE_SOA_COLUMN(CollisionMatched, collisionMatched, bool); DECLARE_SOA_COLUMN(DebugGenCharmBar, debugGenCharmBar, int8_t); DECLARE_SOA_COLUMN(DebugGenCasc, debugGenCasc, int8_t); DECLARE_SOA_COLUMN(DebugGenLambda, debugGenLambda, int8_t); -DECLARE_SOA_COLUMN(OriginRec, originRec, int8_t); -DECLARE_SOA_COLUMN(OriginGen, originGen, int8_t); +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); +DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); DECLARE_SOA_COLUMN(PtCharmBaryonGen, ptCharmBaryonGen, float); DECLARE_SOA_COLUMN(RapidityCharmBaryonGen, rapidityCharmBaryonGen, float); @@ -1343,7 +1588,8 @@ DECLARE_SOA_DYNAMIC_COLUMN(PtKaFromCasc, ptKaFromCasc, enum DecayType { XiczeroToXiPi = 0, OmegaczeroToXiPi, OmegaczeroToOmegaPi, - OmegaczeroToOmegaK }; + OmegaczeroToOmegaK, + OmegaczeroToOmegaPiOneMu }; } // end of namespace hf_cand_xic0_omegac0 @@ -1409,7 +1655,7 @@ DECLARE_SOA_TABLE(HfCandToOmegaPi, "AOD", "HFCANDTOOMEGAPI", hf_cand_xic0_omegac0::DcaXYToPvV0Dau0, hf_cand_xic0_omegac0::DcaXYToPvV0Dau1, hf_cand_xic0_omegac0::DcaXYToPvCascDau, hf_cand_xic0_omegac0::DcaZToPvV0Dau0, hf_cand_xic0_omegac0::DcaZToPvV0Dau1, hf_cand_xic0_omegac0::DcaZToPvCascDau, hf_cand_xic0_omegac0::DcaCascDau, hf_cand_xic0_omegac0::DcaV0Dau, hf_cand_xic0_omegac0::DcaCharmBaryonDau, - hf_cand_xic0_omegac0::DecLenCharmBaryon, hf_cand_xic0_omegac0::DecLenCascade, hf_cand_xic0_omegac0::DecLenV0, hf_cand_xic0_omegac0::ErrorDecayLengthCharmBaryon, hf_cand_xic0_omegac0::ErrorDecayLengthXYCharmBaryon, + hf_cand_xic0_omegac0::DecLenCharmBaryon, hf_cand_xic0_omegac0::DecLenCascade, hf_cand_xic0_omegac0::DecLenV0, hf_cand_xic0_omegac0::ErrorDecayLengthCharmBaryon, hf_cand_xic0_omegac0::ErrorDecayLengthXYCharmBaryon, hf_track_index::HFflag, o2::soa::Marker<1>); DECLARE_SOA_TABLE(HfCandToOmegaK, "AOD", "HFCANDTOOMEGAK", @@ -1447,7 +1693,7 @@ DECLARE_SOA_TABLE(HfOmegacKf, "AOD", "HFOMEGACKF", //! hf_cand_xic0_omegac0::Chi2GeoV0, hf_cand_xic0_omegac0::Chi2GeoCasc, hf_cand_xic0_omegac0::Chi2GeoOmegac, hf_cand_xic0_omegac0::Chi2MassV0, hf_cand_xic0_omegac0::Chi2MassCasc, hf_cand_xic0_omegac0::V0ldl, hf_cand_xic0_omegac0::Cascldl, hf_cand_xic0_omegac0::Omegacldl, - hf_cand_xic0_omegac0::Chi2TopoV0ToPv, hf_cand_xic0_omegac0::Chi2TopoCascToPv, hf_cand_xic0_omegac0::Chi2TopoPiFromOmegacToPv, hf_cand_xic0_omegac0::Chi2TopoOmegacToPv, + hf_cand_xic0_omegac0::Chi2TopoV0ToPv, hf_cand_xic0_omegac0::Chi2TopoCascToPv, hf_cand_xic0_omegac0::Chi2TopoPiFromOmegacToPv, hf_cand_xic0_omegac0::Chi2TopoOmegacToPv, hf_cand_xic0_omegac0::DeviationPiFromOmegacToPv, hf_cand_xic0_omegac0::Chi2TopoV0ToCasc, hf_cand_xic0_omegac0::Chi2TopoCascToOmegac, hf_cand_xic0_omegac0::DecayLenXYLambda, hf_cand_xic0_omegac0::DecayLenXYCasc, hf_cand_xic0_omegac0::DecayLenXYOmegac, hf_cand_xic0_omegac0::CosPaV0ToCasc, hf_cand_xic0_omegac0::CosPaCascToOmegac, hf_cand_xic0_omegac0::CosPaXYV0ToCasc, hf_cand_xic0_omegac0::CosPaXYCascToOmegac, @@ -1457,12 +1703,43 @@ DECLARE_SOA_TABLE(HfOmegacKf, "AOD", "HFOMEGACKF", //! hf_cand_xic0_omegac0::V0Ndf, hf_cand_xic0_omegac0::CascNdf, hf_cand_xic0_omegac0::OmegacNdf, hf_cand_xic0_omegac0::MassV0Ndf, hf_cand_xic0_omegac0::MassCascNdf, hf_cand_xic0_omegac0::V0Chi2OverNdf, hf_cand_xic0_omegac0::CascChi2OverNdf, hf_cand_xic0_omegac0::OmegacChi2OverNdf, - hf_cand_xic0_omegac0::MassV0Chi2OverNdf, hf_cand_xic0_omegac0::MassCascChi2OverNdf); + hf_cand_xic0_omegac0::MassV0Chi2OverNdf, hf_cand_xic0_omegac0::MassCascChi2OverNdf, hf_cand_xic0_omegac0::CascRejectInvmass); + +// OmegaKa reconstruct by KFParticle +DECLARE_SOA_TABLE(HfCandToOmegaKaKf, "AOD", "HFCANDTOOMEGAKAKF", + o2::soa::Index<>, + hf_cand_xic0_omegac0::CollisionId, hf_cand_xic0_omegac0::XPv, hf_cand_xic0_omegac0::YPv, hf_cand_xic0_omegac0::ZPv, + hf_cand_xic0_omegac0::XPvKf, hf_cand_xic0_omegac0::YPvKf, hf_cand_xic0_omegac0::ZPvKf, + hf_cand_xic0_omegac0::XDecayVtxV0, hf_cand_xic0_omegac0::YDecayVtxV0, hf_cand_xic0_omegac0::ZDecayVtxV0, + hf_cand_xic0_omegac0::PxLambda, hf_cand_xic0_omegac0::PyLambda, hf_cand_xic0_omegac0::PzLambda, + hf_cand_xic0_omegac0::XDecayVtxCascade, hf_cand_xic0_omegac0::YDecayVtxCascade, hf_cand_xic0_omegac0::ZDecayVtxCascade, + hf_cand_xic0_omegac0::PxCasc, hf_cand_xic0_omegac0::PyCasc, hf_cand_xic0_omegac0::PzCasc, + hf_cand_xic0_omegac0::XDecayVtxV0Kf, hf_cand_xic0_omegac0::YDecayVtxV0Kf, hf_cand_xic0_omegac0::ZDecayVtxV0Kf, + hf_cand_xic0_omegac0::PxLambdaKf, hf_cand_xic0_omegac0::PyLambdaKf, hf_cand_xic0_omegac0::PzLambdaKf, + hf_cand_xic0_omegac0::XDecayVtxCascadeKf, hf_cand_xic0_omegac0::YDecayVtxCascadeKf, hf_cand_xic0_omegac0::ZDecayVtxCascadeKf, + hf_cand_xic0_omegac0::PxCascKf, hf_cand_xic0_omegac0::PyCascKf, hf_cand_xic0_omegac0::PzCascKf, + hf_cand_xic0_omegac0::XDecayVtxOmegaKaKf, hf_cand_xic0_omegac0::YDecayVtxOmegaKaKf, hf_cand_xic0_omegac0::ZDecayVtxOmegaKaKf, + hf_cand_xic0_omegac0::PxOmegaKaKf, hf_cand_xic0_omegac0::PyOmegaKaKf, hf_cand_xic0_omegac0::PzOmegaKaKf, + hf_cand_xic0_omegac0::SignDecay, hf_cand_xic0_omegac0::EtaV0DauPr, hf_cand_xic0_omegac0::EtaV0DauPi, hf_cand_xic0_omegac0::EtaBachFromCasc, + hf_cand_xic0_omegac0::EtaBachFromCharmBaryon, hf_cand_xic0_omegac0::EtaV0, hf_cand_xic0_omegac0::EtaCascade, hf_cand_xic0_omegac0::EtaCharmBaryon, + hf_cand_xic0_omegac0::KfRapOmegaKa, hf_cand_xic0_omegac0::ImpactParBachFromCharmBaryonXY, hf_cand_xic0_omegac0::ErrImpactParBachFromCharmBaryonXY, hf_cand_xic0_omegac0::ImpactParCascXY, hf_cand_xic0_omegac0::ErrImpactParCascXY, + hf_cand_xic0_omegac0::DcaV0Dau, hf_cand_xic0_omegac0::DcaCascDau, hf_cand_xic0_omegac0::DcaCharmBaryonDau, + hf_cand_xic0_omegac0::CosPAV0, hf_cand_xic0_omegac0::CosPACasc, hf_cand_xic0_omegac0::CosPACharmBaryon, hf_cand_xic0_omegac0::CosPAXYV0, hf_cand_xic0_omegac0::CosPAXYCasc, hf_cand_xic0_omegac0::CosPAXYCharmBaryon, + hf_cand_xic0_omegac0::CosPaV0ToCasc, hf_cand_xic0_omegac0::CosPaCascToOmegaKa, hf_cand_xic0_omegac0::CosPaXYV0ToCasc, hf_cand_xic0_omegac0::CosPaXYCascToOmegaKa, + hf_cand_xic0_omegac0::Chi2GeoV0, hf_cand_xic0_omegac0::Chi2GeoCasc, hf_cand_xic0_omegac0::Chi2GeoOmegaKa, + hf_cand_xic0_omegac0::MassV0Chi2OverNdf, hf_cand_xic0_omegac0::MassCascChi2OverNdf, + hf_cand_xic0_omegac0::Chi2TopoV0ToCasc, hf_cand_xic0_omegac0::Chi2TopoKaToCasc, hf_cand_xic0_omegac0::Chi2TopoKaToOmegaKa, hf_cand_xic0_omegac0::Chi2TopoCascToOmegaKa, + hf_cand_xic0_omegac0::Chi2TopoV0ToPv, hf_cand_xic0_omegac0::Chi2TopoCascToPv, hf_cand_xic0_omegac0::Chi2TopoKaFromOmegaKaToPv, hf_cand_xic0_omegac0::Chi2TopoOmegaKaToPv, + hf_cand_xic0_omegac0::V0ldl, hf_cand_xic0_omegac0::Cascldl, hf_cand_xic0_omegac0::OmegaKaldl, + hf_cand_xic0_omegac0::DecLenV0, hf_cand_xic0_omegac0::DecLenCascade, hf_cand_xic0_omegac0::DecLenCharmBaryon, + hf_cand_xic0_omegac0::InvMassLambda, hf_cand_xic0_omegac0::InvMassLambdaErr, hf_cand_xic0_omegac0::InvMassCascade, hf_cand_xic0_omegac0::InvMassCascadeErr, hf_cand_xic0_omegac0::InvMassCascadeRej, hf_cand_xic0_omegac0::InvMassCascadeRejErr, hf_cand_xic0_omegac0::InvMassCharmBaryon, hf_cand_xic0_omegac0::InvMassCharmBaryonErr, + hf_cand_xic0_omegac0::KfPtOmegaKa, hf_cand_xic0_omegac0::KfPtKaFromOmegaKa, hf_cand_xic0_omegac0::KfPtOmega, + hf_cand_xic0_omegac0::CosThetaStarKaFromOmegac, hf_cand_xic0_omegac0::CosThetaStarKaFromXic, hf_cand_xic0_omegac0::CTauV0, hf_cand_xic0_omegac0::CTauCascade, hf_cand_xic0_omegac0::CTauOmegaKa, + hf_cand_xic0_omegac0::V0Id, v0data::PosTrackId, v0data::NegTrackId, hf_cand_xic0_omegac0::CascadeId, cascdata::BachelorId, hf_cand_xic0_omegac0::BachelorFromCharmBaryonId); DECLARE_SOA_TABLE(HfCandToXiPiKf, "AOD", "HFCANDTOXIPIKF", //! o2::soa::Index<>, hf_cand_xic0_omegac0::CollisionId, hf_cand_xic0_omegac0::XPv, hf_cand_xic0_omegac0::YPv, hf_cand_xic0_omegac0::ZPv, - hf_cand_xic0_omegac0::XDecayVtxCharmBaryon, hf_cand_xic0_omegac0::YDecayVtxCharmBaryon, hf_cand_xic0_omegac0::ZDecayVtxCharmBaryon, hf_cand_xic0_omegac0::XDecayVtxCascade, hf_cand_xic0_omegac0::YDecayVtxCascade, hf_cand_xic0_omegac0::ZDecayVtxCascade, hf_cand_xic0_omegac0::XDecayVtxV0, hf_cand_xic0_omegac0::YDecayVtxV0, hf_cand_xic0_omegac0::ZDecayVtxV0, hf_cand_xic0_omegac0::SignDecay, @@ -1474,39 +1751,47 @@ DECLARE_SOA_TABLE(HfCandToXiPiKf, "AOD", "HFCANDTOXIPIKF", //! hf_cand_xic0_omegac0::PxBachFromCasc, hf_cand_xic0_omegac0::PyBachFromCasc, hf_cand_xic0_omegac0::PzBachFromCasc, hf_cand_xic0_omegac0::PxPosV0Dau, hf_cand_xic0_omegac0::PyPosV0Dau, hf_cand_xic0_omegac0::PzPosV0Dau, hf_cand_xic0_omegac0::PxNegV0Dau, hf_cand_xic0_omegac0::PyNegV0Dau, hf_cand_xic0_omegac0::PzNegV0Dau, - hf_cand_xic0_omegac0::ImpactParCascXY, hf_cand_xic0_omegac0::ImpactParBachFromCharmBaryonXY, hf_cand_xic0_omegac0::ImpactParCascZ, hf_cand_xic0_omegac0::ImpactParBachFromCharmBaryonZ, - hf_cand_xic0_omegac0::ErrImpactParCascXY, hf_cand_xic0_omegac0::ErrImpactParBachFromCharmBaryonXY, hf_cand_xic0_omegac0::V0Id, v0data::PosTrackId, v0data::NegTrackId, hf_cand_xic0_omegac0::CascadeId, hf_cand_xic0_omegac0::BachelorFromCharmBaryonId, cascdata::BachelorId, hf_cand_xic0_omegac0::InvMassLambda, hf_cand_xic0_omegac0::InvMassCascade, hf_cand_xic0_omegac0::InvMassCharmBaryon, - hf_cand_xic0_omegac0::CosPAV0, hf_cand_xic0_omegac0::CosPACharmBaryon, hf_cand_xic0_omegac0::CosPACasc, hf_cand_xic0_omegac0::CosPAXYV0, hf_cand_xic0_omegac0::CosPAXYCharmBaryon, hf_cand_xic0_omegac0::CosPAXYCasc, - hf_cand_xic0_omegac0::CTauOmegac, hf_cand_xic0_omegac0::CTauCascade, hf_cand_xic0_omegac0::CTauV0, hf_cand_xic0_omegac0::CTauXic, + hf_cand_xic0_omegac0::CosPAV0, hf_cand_xic0_omegac0::CosPACasc, + hf_cand_xic0_omegac0::CTauCascade, hf_cand_xic0_omegac0::CTauV0, hf_cand_xic0_omegac0::CTauXic, hf_cand_xic0_omegac0::EtaV0PosDau, hf_cand_xic0_omegac0::EtaV0NegDau, hf_cand_xic0_omegac0::EtaBachFromCasc, hf_cand_xic0_omegac0::EtaBachFromCharmBaryon, hf_cand_xic0_omegac0::EtaCharmBaryon, hf_cand_xic0_omegac0::EtaCascade, hf_cand_xic0_omegac0::EtaV0, hf_cand_xic0_omegac0::DcaXYToPvV0Dau0, hf_cand_xic0_omegac0::DcaXYToPvV0Dau1, hf_cand_xic0_omegac0::DcaXYToPvCascDau, - hf_cand_xic0_omegac0::DcaZToPvV0Dau0, hf_cand_xic0_omegac0::DcaZToPvV0Dau1, hf_cand_xic0_omegac0::DcaZToPvCascDau, hf_cand_xic0_omegac0::DcaCascDau, hf_cand_xic0_omegac0::DcaV0Dau, hf_cand_xic0_omegac0::DcaCharmBaryonDau, - hf_cand_xic0_omegac0::DecLenCharmBaryon, hf_cand_xic0_omegac0::DecLenCascade, hf_cand_xic0_omegac0::DecLenV0, hf_cand_xic0_omegac0::ErrorDecayLengthCharmBaryon, hf_cand_xic0_omegac0::ErrorDecayLengthXYCharmBaryon, hf_cand_xic0_omegac0::KfDcaXYPiFromXic, hf_cand_xic0_omegac0::KfDcaXYCascToPv, hf_cand_xic0_omegac0::Chi2GeoV0, hf_cand_xic0_omegac0::Chi2GeoCasc, hf_cand_xic0_omegac0::Chi2GeoXic, hf_cand_xic0_omegac0::Chi2MassV0, hf_cand_xic0_omegac0::Chi2MassCasc, - hf_cand_xic0_omegac0::V0ldl, hf_cand_xic0_omegac0::Cascldl, hf_cand_xic0_omegac0::Xicldl, + hf_cand_xic0_omegac0::V0ldl, hf_cand_xic0_omegac0::Cascldl, hf_cand_xic0_omegac0::Chi2TopoV0ToPv, hf_cand_xic0_omegac0::Chi2TopoCascToPv, hf_cand_xic0_omegac0::Chi2TopoPiFromXicToPv, hf_cand_xic0_omegac0::Chi2TopoXicToPv, hf_cand_xic0_omegac0::Chi2TopoV0ToCasc, hf_cand_xic0_omegac0::Chi2TopoCascToXic, hf_cand_xic0_omegac0::DecayLenXYLambda, hf_cand_xic0_omegac0::DecayLenXYCasc, hf_cand_xic0_omegac0::DecayLenXYXic, - hf_cand_xic0_omegac0::CosPaV0ToCasc, hf_cand_xic0_omegac0::CosPaCascToXic, hf_cand_xic0_omegac0::CosPaXYV0ToCasc, hf_cand_xic0_omegac0::CosPaXYCascToXic, + hf_cand_xic0_omegac0::CosPaV0ToCasc, hf_cand_xic0_omegac0::CosPaCascToXic, hf_cand_xic0_omegac0::KfRapXic, - hf_cand_xic0_omegac0::KfptPiFromXic, hf_cand_xic0_omegac0::KfptXic, hf_cand_xic0_omegac0::CosThetaStarPiFromXic, hf_cand_xic0_omegac0::V0Ndf, hf_cand_xic0_omegac0::CascNdf, hf_cand_xic0_omegac0::XicNdf, hf_cand_xic0_omegac0::MassV0Ndf, hf_cand_xic0_omegac0::MassCascNdf, hf_cand_xic0_omegac0::V0Chi2OverNdf, hf_cand_xic0_omegac0::CascChi2OverNdf, hf_cand_xic0_omegac0::XicChi2OverNdf, hf_cand_xic0_omegac0::MassV0Chi2OverNdf, hf_cand_xic0_omegac0::MassCascChi2OverNdf); +DECLARE_SOA_TABLE(HfCandToXiPiKfQa, "AOD", "HFCANDTOXIPIKFQA", + o2::soa::Index<>, + hf_cand_xic0_omegac0::InvMassLambda, hf_cand_xic0_omegac0::InvMassCascade, hf_cand_xic0_omegac0::InvMassCharmBaryon, hf_cand_xic0_omegac0::InvMassV0Err, hf_cand_xic0_omegac0::InvMassXiErr, hf_cand_xic0_omegac0::InvMassXic0Err, + hf_cand_xic0_omegac0::CollisionId, hf_track_index::V0Id, v0data::PosTrackId, v0data::NegTrackId, hf_cand_xic0_omegac0::CascadeId, hf_cand_xic0_omegac0::BachelorFromCharmBaryonId, cascdata::BachelorId, + hf_cand_xic0_omegac0::V0DauPosX, hf_cand_xic0_omegac0::V0DauPosY, hf_cand_xic0_omegac0::V0DauPosZ, hf_cand_xic0_omegac0::V0DauPosXError, hf_cand_xic0_omegac0::V0DauPosYError, hf_cand_xic0_omegac0::V0DauPosZError, hf_cand_xic0_omegac0::V0DauPosPt, + hf_cand_xic0_omegac0::V0DauNegX, hf_cand_xic0_omegac0::V0DauNegY, hf_cand_xic0_omegac0::V0DauNegZ, hf_cand_xic0_omegac0::V0DauNegXError, hf_cand_xic0_omegac0::V0DauNegYError, hf_cand_xic0_omegac0::V0DauNegZError, hf_cand_xic0_omegac0::V0DauNegPt, + hf_cand_xic0_omegac0::V0VtxX, hf_cand_xic0_omegac0::V0VtxY, hf_cand_xic0_omegac0::V0VtxZ, hf_cand_xic0_omegac0::V0XError, hf_cand_xic0_omegac0::V0YError, hf_cand_xic0_omegac0::V0ZError, hf_cand_xic0_omegac0::V0Pt, + hf_cand_xic0_omegac0::XiBachelorX, hf_cand_xic0_omegac0::XiBachelorY, hf_cand_xic0_omegac0::XiBachelorZ, hf_cand_xic0_omegac0::XiBachelorXError, hf_cand_xic0_omegac0::XiBachelorYError, hf_cand_xic0_omegac0::XiBachelorZError, hf_cand_xic0_omegac0::XiBachelorPt, + hf_cand_xic0_omegac0::XiX, hf_cand_xic0_omegac0::XiY, hf_cand_xic0_omegac0::XiZ, hf_cand_xic0_omegac0::XiXError, hf_cand_xic0_omegac0::XiYError, hf_cand_xic0_omegac0::XiZError, hf_cand_xic0_omegac0::XiPt, + hf_cand_xic0_omegac0::Xic0BachelorX, hf_cand_xic0_omegac0::Xic0BachelorY, hf_cand_xic0_omegac0::Xic0BachelorZ, hf_cand_xic0_omegac0::Xic0BachelorXError, hf_cand_xic0_omegac0::Xic0BachelorYError, hf_cand_xic0_omegac0::Xic0BachelorZError, hf_cand_xic0_omegac0::Xic0BachelorPt, + hf_cand_xic0_omegac0::XDecayVtxCharmBaryon, hf_cand_xic0_omegac0::YDecayVtxCharmBaryon, hf_cand_xic0_omegac0::ZDecayVtxCharmBaryon, hf_cand_xic0_omegac0::Xic0XError, hf_cand_xic0_omegac0::Xic0YError, hf_cand_xic0_omegac0::Xic0ZError, hf_cand_xic0_omegac0::Xic0Pt, + hf_cand_casc::V0X, hf_cand_casc::V0Y, hf_cand_casc::V0Z, hf_cand_xic0_omegac0::XDecayVtxCascade, hf_cand_xic0_omegac0::YDecayVtxCascade, hf_cand_xic0_omegac0::ZDecayVtxCascade); + // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfXicToXiPiMCRec, "AOD", "HFXICXIPIMCREC", //! hf_cand_xic0_omegac0::FlagMcMatchRec, hf_cand_xic0_omegac0::DebugMcRec, - hf_cand_xic0_omegac0::OriginRec, + hf_cand_xic0_omegac0::OriginMcRec, hf_cand_xic0_omegac0::CollisionMatched, hf_cand::PtBhadMotherPart, hf_cand::PdgBhadMotherPart, @@ -1514,7 +1799,7 @@ DECLARE_SOA_TABLE(HfXicToXiPiMCRec, "AOD", "HFXICXIPIMCREC", //! DECLARE_SOA_TABLE(HfOmegacToXiPiMCRec, "AOD", "HFOMCXIPIMCREC", //! hf_cand_xic0_omegac0::FlagMcMatchRec, hf_cand_xic0_omegac0::DebugMcRec, - hf_cand_xic0_omegac0::OriginRec, + hf_cand_xic0_omegac0::OriginMcRec, hf_cand_xic0_omegac0::CollisionMatched, hf_cand::PtBhadMotherPart, hf_cand::PdgBhadMotherPart, @@ -1522,7 +1807,7 @@ DECLARE_SOA_TABLE(HfOmegacToXiPiMCRec, "AOD", "HFOMCXIPIMCREC", //! DECLARE_SOA_TABLE(HfToOmegaPiMCRec, "AOD", "HFTOOMEPIMCREC", //! hf_cand_xic0_omegac0::FlagMcMatchRec, hf_cand_xic0_omegac0::DebugMcRec, - hf_cand_xic0_omegac0::OriginRec, + hf_cand_xic0_omegac0::OriginMcRec, hf_cand_xic0_omegac0::CollisionMatched, hf_cand::PtBhadMotherPart, hf_cand::PdgBhadMotherPart, @@ -1530,7 +1815,7 @@ DECLARE_SOA_TABLE(HfToOmegaPiMCRec, "AOD", "HFTOOMEPIMCREC", //! DECLARE_SOA_TABLE(HfToOmegaKMCRec, "AOD", "HFTOOMEKMCREC", //! hf_cand_xic0_omegac0::FlagMcMatchRec, hf_cand_xic0_omegac0::DebugMcRec, - hf_cand_xic0_omegac0::OriginRec, + hf_cand_xic0_omegac0::OriginMcRec, hf_cand_xic0_omegac0::CollisionMatched, hf_cand::PtBhadMotherPart, hf_cand::PdgBhadMotherPart, @@ -1539,40 +1824,40 @@ DECLARE_SOA_TABLE(HfToOmegaKMCRec, "AOD", "HFTOOMEKMCREC", //! // table with results of generator level MC matching DECLARE_SOA_TABLE(HfXicToXiPiMCGen, "AOD", "HFXICXIPIMCGEN", //! hf_cand_xic0_omegac0::FlagMcMatchGen, hf_cand_xic0_omegac0::DebugGenCharmBar, hf_cand_xic0_omegac0::DebugGenCasc, hf_cand_xic0_omegac0::DebugGenLambda, - hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::RapidityCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<1>); + hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::RapidityCharmBaryonGen, hf_cand_xic0_omegac0::OriginMcGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<1>); DECLARE_SOA_TABLE(HfOmegacToXiPiMCGen, "AOD", "HFOMECXIPIMCGEN", //! hf_cand_xic0_omegac0::FlagMcMatchGen, hf_cand_xic0_omegac0::DebugGenCharmBar, hf_cand_xic0_omegac0::DebugGenCasc, hf_cand_xic0_omegac0::DebugGenLambda, - hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::RapidityCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<2>); + hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::RapidityCharmBaryonGen, hf_cand_xic0_omegac0::OriginMcGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<2>); DECLARE_SOA_TABLE(HfToOmegaPiMCGen, "AOD", "HFTOOMEPIMCGEN", //! hf_cand_xic0_omegac0::FlagMcMatchGen, hf_cand_xic0_omegac0::DebugGenCharmBar, hf_cand_xic0_omegac0::DebugGenCasc, hf_cand_xic0_omegac0::DebugGenLambda, - hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::RapidityCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<3>); + hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::RapidityCharmBaryonGen, hf_cand_xic0_omegac0::OriginMcGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<3>); DECLARE_SOA_TABLE(HfToOmegaKMCGen, "AOD", "HFTOOMEKMCGEN", //! hf_cand_xic0_omegac0::FlagMcMatchGen, hf_cand_xic0_omegac0::DebugGenCharmBar, hf_cand_xic0_omegac0::DebugGenCasc, hf_cand_xic0_omegac0::DebugGenLambda, - hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::RapidityCharmBaryonGen, hf_cand_xic0_omegac0::OriginGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<4>); + hf_cand_xic0_omegac0::PtCharmBaryonGen, hf_cand_xic0_omegac0::RapidityCharmBaryonGen, hf_cand_xic0_omegac0::OriginMcGen, hf_cand::IdxBhadMotherPart, o2::soa::Marker<4>); // specific Xic to Xi Pi Pi candidate properties namespace hf_cand_xic_to_xi_pi_pi { DECLARE_SOA_INDEX_COLUMN_FULL(Pi0, pi0, int, Tracks, "_pi0"); DECLARE_SOA_INDEX_COLUMN_FULL(Pi1, pi1, int, Tracks, "_pi1"); +DECLARE_SOA_COLUMN(Sign, sign, int8_t); +DECLARE_SOA_COLUMN(InvMassXicPlus, invMassXicPlus, float); +DECLARE_SOA_COLUMN(InvMassXi, invMassXi, float); +DECLARE_SOA_COLUMN(InvMassLambda, invMassLambda, float); +DECLARE_SOA_COLUMN(InvMassXiPi0, invMassXiPi0, float); +DECLARE_SOA_COLUMN(InvMassXiPi1, invMassXiPi1, float); DECLARE_SOA_COLUMN(XPvErr, xPvErr, float); DECLARE_SOA_COLUMN(YPvErr, yPvErr, float); DECLARE_SOA_COLUMN(ZPvErr, zPvErr, float); DECLARE_SOA_COLUMN(XSvErr, xSvErr, float); DECLARE_SOA_COLUMN(YSvErr, ySvErr, float); DECLARE_SOA_COLUMN(ZSvErr, zSvErr, float); -DECLARE_SOA_COLUMN(CosPaXi, cosPaXi, float); -DECLARE_SOA_COLUMN(CosPaXYXi, cosPaXYXi, float); -DECLARE_SOA_COLUMN(CosPaLambda, cosPaLambda, float); -DECLARE_SOA_COLUMN(CosPaXYLambda, cosPaXYLambda, float); -DECLARE_SOA_COLUMN(CosPaLambdaToXi, cosPaLambdaToXi, float); -DECLARE_SOA_COLUMN(CosPaXYLambdaToXi, cosPaXYLambdaToXi, float); -DECLARE_SOA_COLUMN(InvMassXicPlus, invMassXicPlus, float); -DECLARE_SOA_COLUMN(InvMassXi, invMassXi, float); -DECLARE_SOA_COLUMN(InvMassLambda, invMassLambda, float); -DECLARE_SOA_COLUMN(Sign, sign, float); -DECLARE_SOA_COLUMN(InvMassXiPi0, invMassXiPi0, float); -DECLARE_SOA_COLUMN(InvMassXiPi1, invMassXiPi1, float); +DECLARE_SOA_COLUMN(CpaXi, cpaXi, float); +DECLARE_SOA_COLUMN(CpaXYXi, cpaXYXi, float); +DECLARE_SOA_COLUMN(CpaLambda, cpaLambda, float); +DECLARE_SOA_COLUMN(CpaXYLambda, cpaXYLambda, float); +DECLARE_SOA_COLUMN(CpaLambdaToXi, cpaLambdaToXi, float); +DECLARE_SOA_COLUMN(CpaXYLambdaToXi, cpaXYLambdaToXi, float); DECLARE_SOA_COLUMN(PBachelorPi, pBachelorPi, float); DECLARE_SOA_COLUMN(PPiFromLambda, pPiFromLambda, float); DECLARE_SOA_COLUMN(PPrFromLambda, pPrFromLambda, float); @@ -1582,18 +1867,26 @@ DECLARE_SOA_COLUMN(DcaPosToPV, dcaPosToPV, float); DECLARE_SOA_COLUMN(DcaNegToPV, dcaNegToPV, float); DECLARE_SOA_COLUMN(DcaBachelorToPV, dcaBachelorToPV, float); DECLARE_SOA_COLUMN(DcaXYCascToPV, dcaXYCascToPV, float); -DECLARE_SOA_COLUMN(DcaZCascToPV, dcaXCascToPV, float); +DECLARE_SOA_COLUMN(DcaZCascToPV, dcaZCascToPV, float); // KF specific columns -DECLARE_SOA_COLUMN(DcaXYPi0Pi1, dcaXYPi0Pi1, float); -DECLARE_SOA_COLUMN(DcaXYPi0Xi, dcaXYPi0Xi, float); -DECLARE_SOA_COLUMN(DcaXYPi1Xi, dcaXYPi1Xi, float); +DECLARE_SOA_COLUMN(Chi2TopoXicPlusToPV, chi2TopoXicPlusToPV, float); +DECLARE_SOA_COLUMN(Chi2TopoXicPlusToPVBefConst, chi2TopoXicPlusToPVBefConst, float); +DECLARE_SOA_COLUMN(Chi2PrimXi, chi2PrimXi, float); +DECLARE_SOA_COLUMN(Chi2PrimPi0, chi2PrimPi0, float); +DECLARE_SOA_COLUMN(Chi2PrimPi1, chi2PrimPi1, float); +DECLARE_SOA_COLUMN(Chi2DevPi0Pi1, chi2DevPi0Pi1, float); +DECLARE_SOA_COLUMN(Chi2DevPi0Xi, chi2DevPi0Xi, float); +DECLARE_SOA_COLUMN(Chi2DevPi1Xi, chi2DevPi1Xi, float); DECLARE_SOA_COLUMN(DcaPi0Pi1, dcaPi0Pi1, float); DECLARE_SOA_COLUMN(DcaPi0Xi, dcaPi0Xi, float); DECLARE_SOA_COLUMN(DcaPi1Xi, dcaPi1Xi, float); -DECLARE_SOA_COLUMN(Chi2TopoXicPlusToPV, chi2TopoXicPlusToPV, float); -DECLARE_SOA_COLUMN(Chi2TopoXicPlusToPVBeforeConstraint, chi2TopoXicPlusToPVBeforeConstraint, float); -DECLARE_SOA_COLUMN(Chi2TopoXiToXicPlus, chi2TopoXiToXicPlus, float); -DECLARE_SOA_COLUMN(Chi2TopoXiToXicPlusBeforeConstraint, chi2TopoXiToXicPlusBeforeConstraint, float); +DECLARE_SOA_COLUMN(DcaXYPi0Pi1, dcaXYPi0Pi1, float); +DECLARE_SOA_COLUMN(DcaXYPi0Xi, dcaXYPi0Xi, float); +DECLARE_SOA_COLUMN(DcaXYPi1Xi, dcaXYPi1Xi, float); +DECLARE_SOA_COLUMN(KfDecayLength, kfDecayLength, float); +DECLARE_SOA_COLUMN(KfDecayLengthNormalised, kfDecayLengthNormalised, float); +DECLARE_SOA_COLUMN(KfDecayLengthXY, kfDecayLengthXY, float); +DECLARE_SOA_COLUMN(KfDecayLengthXYNormalised, kfDecayLengthXYNormalised, float); // PID DECLARE_SOA_COLUMN(NSigTpcPiFromXicPlus0, nSigTpcPiFromXicPlus0, float); DECLARE_SOA_COLUMN(NSigTpcPiFromXicPlus1, nSigTpcPiFromXicPlus1, float); @@ -1608,10 +1901,23 @@ DECLARE_SOA_COLUMN(NSigTofPrFromLambda, nSigTofPrFromLambda, float); // MC matching result: DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // generator level -DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level -DECLARE_SOA_COLUMN(DebugMcGen, debugMcGen, int8_t); -DECLARE_SOA_COLUMN(OriginRec, originRec, int8_t); -DECLARE_SOA_COLUMN(OriginGen, originGen, int8_t); +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); +DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); +// Residuals and pulls +DECLARE_SOA_COLUMN(PtResidual, ptResidual, float); +DECLARE_SOA_COLUMN(PResidual, pResidual, float); +DECLARE_SOA_COLUMN(XPvResidual, xPvResidual, float); +DECLARE_SOA_COLUMN(YPvResidual, yPvResidual, float); +DECLARE_SOA_COLUMN(ZPvResidual, zPvResidual, float); +DECLARE_SOA_COLUMN(XPvPull, xPvPull, float); +DECLARE_SOA_COLUMN(YPvPull, yPvPull, float); +DECLARE_SOA_COLUMN(ZPvPull, zPvPull, float); +DECLARE_SOA_COLUMN(XSvResidual, xSvResidual, float); +DECLARE_SOA_COLUMN(YSvResidual, ySvResidual, float); +DECLARE_SOA_COLUMN(ZSvResidual, zSvResidual, float); +DECLARE_SOA_COLUMN(XSvPull, xSvPull, float); +DECLARE_SOA_COLUMN(YSvPull, ySvPull, float); +DECLARE_SOA_COLUMN(ZSvPull, zSvPull, float); // Dynamic columns DECLARE_SOA_DYNAMIC_COLUMN(PProng0, pProng0, //! [](float px, float py, float pz) -> float { return RecoDecay::p(px, py, pz); }); @@ -1645,7 +1951,7 @@ DECLARE_SOA_TABLE(HfCandXicBase, "AOD", "HFCANDXICBASE", hf_cand::ErrorImpactParameter0, hf_cand::ErrorImpactParameter1, hf_cand::ErrorImpactParameter2, // cascade specific columns hf_cand_xic_to_xi_pi_pi::PBachelorPi, hf_cand_xic_to_xi_pi_pi::PPiFromLambda, hf_cand_xic_to_xi_pi_pi::PPrFromLambda, - hf_cand_xic_to_xi_pi_pi::CosPaXi, hf_cand_xic_to_xi_pi_pi::CosPaXYXi, hf_cand_xic_to_xi_pi_pi::CosPaLambda, hf_cand_xic_to_xi_pi_pi::CosPaXYLambda, hf_cand_xic_to_xi_pi_pi::CosPaLambdaToXi, hf_cand_xic_to_xi_pi_pi::CosPaXYLambdaToXi, + hf_cand_xic_to_xi_pi_pi::CpaXi, hf_cand_xic_to_xi_pi_pi::CpaXYXi, hf_cand_xic_to_xi_pi_pi::CpaLambda, hf_cand_xic_to_xi_pi_pi::CpaXYLambda, hf_cand_xic_to_xi_pi_pi::CpaLambdaToXi, hf_cand_xic_to_xi_pi_pi::CpaXYLambdaToXi, hf_cand_xic_to_xi_pi_pi::InvMassXi, hf_cand_xic_to_xi_pi_pi::InvMassLambda, hf_cand_xic_to_xi_pi_pi::InvMassXiPi0, hf_cand_xic_to_xi_pi_pi::InvMassXiPi1, // DCA hf_cand_xic_to_xi_pi_pi::DcaXiDaughters, hf_cand_xic_to_xi_pi_pi::DcaV0Daughters, hf_cand_xic_to_xi_pi_pi::DcaPosToPV, hf_cand_xic_to_xi_pi_pi::DcaNegToPV, hf_cand_xic_to_xi_pi_pi::DcaBachelorToPV, hf_cand_xic_to_xi_pi_pi::DcaXYCascToPV, hf_cand_xic_to_xi_pi_pi::DcaZCascToPV, @@ -1671,8 +1977,8 @@ DECLARE_SOA_TABLE(HfCandXicBase, "AOD", "HFCANDXICBASE", hf_cand::Pt, hf_cand::P, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_3prong::MaxNormalisedDeltaIP, @@ -1683,27 +1989,46 @@ DECLARE_SOA_TABLE(HfCandXicBase, "AOD", "HFCANDXICBASE", // extended table with expression columns that can be used as arguments of dynamic columns DECLARE_SOA_EXTENDED_TABLE_USER(HfCandXicExt, HfCandXicBase, "HFCANDXICEXT", hf_cand_3prong::Px, hf_cand_3prong::Py, hf_cand_3prong::Pz); - using HfCandXic = HfCandXicExt; +// table with KF-specific variables DECLARE_SOA_TABLE(HfCandXicKF, "AOD", "HFCANDXICKF", + hf_cand_xic_to_xi_pi_pi::KfDecayLength, hf_cand_xic_to_xi_pi_pi::KfDecayLengthNormalised, hf_cand_xic_to_xi_pi_pi::KfDecayLengthXY, hf_cand_xic_to_xi_pi_pi::KfDecayLengthXYNormalised, cascdata::KFCascadeChi2, cascdata::KFV0Chi2, - hf_cand_xic_to_xi_pi_pi::Chi2TopoXicPlusToPVBeforeConstraint, hf_cand_xic_to_xi_pi_pi::Chi2TopoXicPlusToPV, hf_cand_xic_to_xi_pi_pi::Chi2TopoXiToXicPlusBeforeConstraint, hf_cand_xic_to_xi_pi_pi::Chi2TopoXiToXicPlus, - hf_cand_xic_to_xi_pi_pi::DcaXYPi0Pi1, hf_cand_xic_to_xi_pi_pi::DcaXYPi0Xi, hf_cand_xic_to_xi_pi_pi::DcaXYPi1Xi, + hf_cand_xic_to_xi_pi_pi::Chi2TopoXicPlusToPVBefConst, hf_cand_xic_to_xi_pi_pi::Chi2TopoXicPlusToPV, + hf_cand_xic_to_xi_pi_pi::Chi2PrimXi, hf_cand_xic_to_xi_pi_pi::Chi2PrimPi0, hf_cand_xic_to_xi_pi_pi::Chi2PrimPi1, + hf_cand_xic_to_xi_pi_pi::Chi2DevPi0Pi1, hf_cand_xic_to_xi_pi_pi::Chi2DevPi0Xi, hf_cand_xic_to_xi_pi_pi::Chi2DevPi1Xi, hf_cand_xic_to_xi_pi_pi::DcaPi0Pi1, hf_cand_xic_to_xi_pi_pi::DcaPi0Xi, hf_cand_xic_to_xi_pi_pi::DcaPi1Xi, - cascdata::DCACascDaughters); + hf_cand_xic_to_xi_pi_pi::DcaXYPi0Pi1, hf_cand_xic_to_xi_pi_pi::DcaXYPi0Xi, hf_cand_xic_to_xi_pi_pi::DcaXYPi1Xi); // table with results of reconstruction level MC matching -DECLARE_SOA_TABLE(HfCandXicMcRec, "AOD", "HFCANDXICMCREC", //! +DECLARE_SOA_TABLE(HfCandXicMcRec, "AOD", "HFCANDXICMCREC", hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec, - hf_cand_xic_to_xi_pi_pi::DebugMcRec, - hf_cand_xic_to_xi_pi_pi::OriginRec); + hf_cand_xic_to_xi_pi_pi::OriginMcRec); // table with results of generator level MC matching -DECLARE_SOA_TABLE(HfCandXicMcGen, "AOD", "HFCANDXICMCGEN", //! +DECLARE_SOA_TABLE(HfCandXicMcGen, "AOD", "HFCANDXICMCGEN", hf_cand_xic_to_xi_pi_pi::FlagMcMatchGen, - hf_cand_xic_to_xi_pi_pi::DebugMcGen, - hf_cand_xic_to_xi_pi_pi::OriginGen); + hf_cand_xic_to_xi_pi_pi::OriginMcGen, + hf_cand::PdgBhadMotherPart); + +// table with residuals and pulls of PV +DECLARE_SOA_TABLE(HfCandXicResid, "AOD", "HFCANDXICRESID", + hf_cand_xic_to_xi_pi_pi::OriginMcGen, + hf_cand_xic_to_xi_pi_pi::PResidual, + hf_cand_xic_to_xi_pi_pi::PtResidual, + hf_cand_xic_to_xi_pi_pi::XPvResidual, + hf_cand_xic_to_xi_pi_pi::YPvResidual, + hf_cand_xic_to_xi_pi_pi::ZPvResidual, + hf_cand_xic_to_xi_pi_pi::XPvPull, + hf_cand_xic_to_xi_pi_pi::YPvPull, + hf_cand_xic_to_xi_pi_pi::ZPvPull, + hf_cand_xic_to_xi_pi_pi::XSvResidual, + hf_cand_xic_to_xi_pi_pi::YSvResidual, + hf_cand_xic_to_xi_pi_pi::ZSvResidual, + hf_cand_xic_to_xi_pi_pi::XSvPull, + hf_cand_xic_to_xi_pi_pi::YSvPull, + hf_cand_xic_to_xi_pi_pi::ZSvPull); // specific chic candidate properties namespace hf_cand_chic @@ -1747,8 +2072,8 @@ DECLARE_SOA_TABLE(HfCandChicBase, "AOD", "HFCANDCHICBASE", hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_2prong::MaxNormalisedDeltaIP, @@ -1781,13 +2106,23 @@ namespace hf_cand_lb { DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfCand3Prong, "_0"); // Lb index // MC matching result: -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // generator level -DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); // particle origin, reconstruction level -DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); // particle origin, generator level -DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // main decay channel, reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // main decay channel, generator level +DECLARE_SOA_COLUMN(FlagMcDecayChanRec, flagMcDecayChanRec, int8_t); // resonant decay channel, reconstruction level +DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); // resonant decay channel, generator level +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); // particle origin, reconstruction level +DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); // particle origin, generator level +DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); // reconstruction level +DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level // mapping of decay types enum DecayType { LbToLcPi }; // move this to a dedicated cascade namespace in the future? + +enum DecayTypeMc : uint8_t { LbToLcPiToPKPiPi = 0, + LbToLcKToPKPiK, + B0ToDplusPiToPiKPiPi, + PartlyRecoDecay, + OtherDecay, + NDecayTypeMc }; } // namespace hf_cand_lb // declare dedicated Lb candidate table @@ -1799,8 +2134,6 @@ DECLARE_SOA_TABLE(HfCandLbBase, "AOD", "HFCANDLBBASE", hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, hf_cand::ImpactParameter0, hf_cand::ImpactParameter1, hf_cand::ErrorImpactParameter0, hf_cand::ErrorImpactParameter1, - hf_cand_lb::Prong0Id, hf_track_index::Prong1Id, - hf_track_index::HFflag, /* dynamic columns */ hf_cand_2prong::M, hf_cand_2prong::M2, @@ -1811,8 +2144,8 @@ DECLARE_SOA_TABLE(HfCandLbBase, "AOD", "HFCANDLBBASE", hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_2prong::MaxNormalisedDeltaIP, @@ -1826,17 +2159,22 @@ DECLARE_SOA_TABLE(HfCandLbBase, "AOD", "HFCANDLBBASE", DECLARE_SOA_EXTENDED_TABLE_USER(HfCandLbExt, HfCandLbBase, "HFCANDLBEXT", hf_cand_2prong::Px, hf_cand_2prong::Py, hf_cand_2prong::Pz); -using HfCandLb = HfCandLbExt; +DECLARE_SOA_TABLE(HfCandLbProngs, "AOD", "HFCANDLBPRONGS", + hf_cand_lb::Prong0Id, hf_track_index::Prong1Id); + +using HfCandLb = soa::Join; // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCandLbMcRec, "AOD", "HFCANDLBMCREC", //! hf_cand_lb::FlagMcMatchRec, + hf_cand_lb::FlagMcDecayChanRec, hf_cand_lb::OriginMcRec, hf_cand_lb::DebugMcRec); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCandLbMcGen, "AOD", "HFCANDLBMCGEN", //! hf_cand_lb::FlagMcMatchGen, + hf_cand_lb::FlagMcDecayChanGen, hf_cand_lb::OriginMcGen); // specific B0 candidate properties @@ -1844,19 +2182,24 @@ namespace hf_cand_b0 { DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfCand3Prong, "_0"); // D index // MC matching result: -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level -DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); // reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // generator level +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // main decay channel, reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // main decay channel, generator level +DECLARE_SOA_COLUMN(FlagMcDecayChanRec, flagMcDecayChanRec, int8_t); // resonant decay channel, reconstruction level +DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); // resonant decay channel, generator level DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); // particle origin, reconstruction level DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); // particle origin, generator level +DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); // reconstruction level DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level // mapping of decay types -enum DecayType { B0ToDPi }; +enum DecayType { B0ToDPi = 0, + B0ToDstarPi }; enum DecayTypeMc : uint8_t { B0ToDplusPiToPiKPiPi = 0, B0ToDsPiToKKPiPi, BsToDsPiToKKPiPi, + B0ToDplusKToPiKPiK, + B0ToDstarPiToD0PiPiToKPiPiPi, PartlyRecoDecay, OtherDecay, NDecayTypeMc }; @@ -1883,8 +2226,8 @@ DECLARE_SOA_TABLE(HfCandB0Base, "AOD", "HFCANDB0BASE", hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_2prong::MaxNormalisedDeltaIP, @@ -1906,12 +2249,14 @@ using HfCandB0 = soa::Join; // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCandB0McRec, "AOD", "HFCANDB0MCREC", hf_cand_b0::FlagMcMatchRec, + hf_cand_b0::FlagMcDecayChanRec, hf_cand_b0::OriginMcRec, hf_cand_b0::DebugMcRec); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCandB0McGen, "AOD", "HFCANDB0MCGEN", hf_cand_b0::FlagMcMatchGen, + hf_cand_b0::FlagMcDecayChanGen, hf_cand_b0::OriginMcGen); // specific Bs candidate properties @@ -1919,24 +2264,43 @@ namespace hf_cand_bs { DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfCand3Prong, "_0"); // Ds index // MC matching result: -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level -DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); // reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // generator level -DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); // particle origin, reconstruction level -DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); // particle origin, generator level -DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // main decay channel, reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // main decay channel, generator level +DECLARE_SOA_COLUMN(FlagMcDecayChanRec, flagMcDecayChanRec, int8_t); // resonant decay channel, reconstruction level +DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); // resonant decay channel, generator level +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); // particle origin, reconstruction level +DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); // particle origin, generator level +DECLARE_SOA_COLUMN(FlagWrongCollision, flagWrongCollision, int8_t); // reconstruction level +DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level +DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterProduct, impactParameterProduct, // Impact parameter product for Bs -> J/Psi phi + [](float pxJpsiDauPos, float pyJpsiDauPos, float pzJpsiDauPos, float pxJpsiDauNeg, float pyJpsiDauNeg, float pzJpsiDauNeg, float pxLfTrack0, float pyLfTrack0, float pzLfTrack0, float pxLfTrack1, float pyLfTrack1, float pzLfTrack1, float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS) -> float { + float impParJpsi = RecoDecay::impParXY(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, RecoDecay::pVec(std::array{pxJpsiDauPos, pyJpsiDauPos, pzJpsiDauPos}, std::array{pxJpsiDauNeg, pyJpsiDauNeg, pzJpsiDauNeg})); + float impParPhi = RecoDecay::impParXY(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, RecoDecay::pVec(std::array{pxLfTrack0, pyLfTrack0, pzLfTrack0}, std::array{pxLfTrack1, pyLfTrack1, pzLfTrack1})); + return impParJpsi * impParPhi; + }); +DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterProductJpsi, impactParameterProductJpsi, // J/Psi impact parameter for Bs -> J/Psi phi + [](float dcaDauPos, float dcaDauNeg) -> float { return dcaDauPos * dcaDauNeg; }); +DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterProductPhi, impactParameterProductPhi, // J/Psi impact parameter for Bs -> J/Psi phi + [](float dcaLfTrack0, float dcaLfTrack1) -> float { return dcaLfTrack0 * dcaLfTrack1; }); // mapping of decay types -enum DecayType { BsToDsPi }; +enum DecayType { BsToDsPi = 0 }; enum DecayTypeMc : uint8_t { BsToDsPiToPhiPiPiToKKPiPi = 0, // Bs(bar) → Ds∓ π± → (Phi π∓) π± → (K- K+ π∓) π± BsToDsPiToK0starKPiToKKPiPi, // Bs(bar) → Ds∓ π± → (K0* K∓) π± → (K- K+ π∓) π± B0ToDsPiToPhiPiPiToKKPiPi, // B0(bar) → Ds± π∓ → (Phi π±) π∓ → (K- K+ π±) π∓ B0ToDsPiToK0starKPiToKKPiPi, // B0(bar) → Ds± π∓ → (K0* K±) π∓ → (K- K+ π±) π∓ + BsToDsKToPhiPiKToKKPiK, // Bs(bar) → Ds± K∓ → (Phi π∓) K∓ → (K- K+ π±) K∓ + BsToDsKToK0starKKToKKPiK, // Bs(bar) → Ds± K∓ → (K0* K±) K∓ → (K- K+ π±) K∓ PartlyRecoDecay, // 4 final state particles have another common b-hadron ancestor OtherDecay, NDecayTypeMc }; // counter of differentiated MC decay types +enum class DecayTypeBToJpsiMc : uint8_t { BsToJpsiPhiToMuMuKK = 0, // Bs(bar) → J/Psi Phi → (µ+ µ-) (K- K+) + PartlyRecoDecay, // 4 final state particles have another common b-hadron ancestor + OtherDecay, + NDecayTypeMc }; // counter of differentiated MC decay types + } // namespace hf_cand_bs // declare dedicated Bs decay candidate table @@ -1960,8 +2324,8 @@ DECLARE_SOA_TABLE(HfCandBsBase, "AOD", "HFCANDBSBASE", hf_cand::P, hf_cand::P2, hf_cand::PVector, - hf_cand::CPA, - hf_cand::CPAXY, + hf_cand::Cpa, + hf_cand::CpaXY, hf_cand::Ct, hf_cand::ImpactParameterXY, hf_cand_2prong::MaxNormalisedDeltaIP, @@ -1970,6 +2334,7 @@ DECLARE_SOA_TABLE(HfCandBsBase, "AOD", "HFCANDBSBASE", hf_cand::Y, hf_cand::E, hf_cand::E2, + hf_cand_2prong::CtXY, o2::soa::Marker<1>); // extended table with expression columns that can be used as arguments of dynamic columns @@ -1983,11 +2348,89 @@ using HfCandBs = soa::Join; // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCandBsMcRec, "AOD", "HFCANDBSMCREC", - hf_cand_bs::FlagMcMatchRec); + hf_cand_bs::FlagMcMatchRec, + hf_cand_bs::FlagMcDecayChanRec); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCandBsMcGen, "AOD", "HFCANDBSMCGEN", - hf_cand_bs::FlagMcMatchGen); + hf_cand_bs::FlagMcMatchGen, + hf_cand_bs::FlagMcDecayChanGen); + +namespace hf_cand_4prong +{ +DECLARE_SOA_EXPRESSION_COLUMN(Px, px, //! + float, 1.f * aod::hf_cand::pxProng0 + 1.f * aod::hf_cand::pxProng1 + 1.f * aod::hf_cand::pxProng2 + 1.f * aod::hf_cand::pxProng3); +DECLARE_SOA_EXPRESSION_COLUMN(Py, py, //! + float, 1.f * aod::hf_cand::pyProng0 + 1.f * aod::hf_cand::pyProng1 + 1.f * aod::hf_cand::pyProng2 + 1.f * aod::hf_cand::pyProng3); +DECLARE_SOA_EXPRESSION_COLUMN(Pz, pz, //! + float, 1.f * aod::hf_cand::pzProng0 + 1.f * aod::hf_cand::pzProng1 + 1.f * aod::hf_cand::pzProng2 + 1.f * aod::hf_cand::pzProng3); +DECLARE_SOA_DYNAMIC_COLUMN(M, m, //! + [](float px0, float py0, float pz0, float px1, float py1, float pz1, float px2, float py2, float pz2, float px3, float py3, float pz3, const std::array& m) -> float { return RecoDecay::m(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}, std::array{px2, py2, pz2}, std::array{px3, py3, pz3}}, m); }); +DECLARE_SOA_DYNAMIC_COLUMN(M2, m2, //! + [](float px0, float py0, float pz0, float px1, float py1, float pz1, float px2, float py2, float pz2, float px3, float py3, float pz3, const std::array& m) -> float { return RecoDecay::m2(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}, std::array{px2, py2, pz2}, std::array{px3, py3, pz3}}, m); }); +DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterProngSqSum, impactParameterProngSqSum, //! + [](float impParProng0, float impParProng1, float impParProng2, float impParProng3) -> float { return RecoDecay::sumOfSquares(impParProng0, impParProng1, impParProng2, impParProng3); }); +DECLARE_SOA_DYNAMIC_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, //! + [](float xVtxP, float yVtxP, float xVtxS, float yVtxS, float errDlxy, float pxM, float pyM, float ip0, float errIp0, float ip1, float errIp1, float ip2, float errIp2, float ip3, float errIp3, float px0, float py0, float px1, float py1, float px2, float py2, float px3, float py3) -> float { return RecoDecay::maxNormalisedDeltaIP(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, errDlxy, std::array{pxM, pyM}, std::array{ip0, ip1, ip2, ip3}, std::array{errIp0, errIp1, errIp2, errIp3}, std::array{std::array{px0, py0}, std::array{px1, py1}, std::array{px2, py2}, std::array{px3, py3}}); }); +DECLARE_SOA_DYNAMIC_COLUMN(CtXY, ctXY, //! + [](float px0, float py0, float pz0, float px1, float py1, float pz1, float px2, float py2, float pz2, float px3, float py3, float pz3, float xVtxP, float yVtxP, float xVtxS, float yVtxS, const std::array& m) -> float { return RecoDecay::ctXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}, std::array{px2, py2, pz2}, std::array{px3, py3, pz3}}, m); }); +} // namespace hf_cand_4prong + +// declare dedicated Bs -> J/Psi phi decay candidate table +// convention: prongs 0 and 1 should be J/Psi decay products, 2 and 3 should be phi decay products +DECLARE_SOA_TABLE(HfCandBsJPBase, "AOD", "HFCANDBSJPBASE", + // general columns + HFCAND_COLUMNS, + /* prong 2 */ hf_cand::ImpactParameterNormalised2, + hf_cand::PtProng2, + hf_cand::Pt2Prong2, + hf_cand::PVectorProng2, + /* prong 3 */ hf_cand::ImpactParameterNormalised3, + hf_cand::PtProng3, + hf_cand::Pt2Prong3, + hf_cand::PVectorProng3, + // 4-prong specific columns + o2::soa::Index<>, + hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, + hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, + hf_cand::PxProng2, hf_cand::PyProng2, hf_cand::PzProng2, + hf_cand::PxProng3, hf_cand::PyProng3, hf_cand::PzProng3, + hf_cand::ImpactParameter0, hf_cand::ImpactParameter1, hf_cand::ImpactParameter2, hf_cand::ImpactParameter3, + hf_cand::ErrorImpactParameter0, hf_cand::ErrorImpactParameter1, hf_cand::ErrorImpactParameter2, hf_cand::ErrorImpactParameter3, + /* dynamic columns */ + hf_cand_4prong::M, + hf_cand_4prong::M2, + hf_cand_4prong::ImpactParameterProngSqSum, + hf_cand_bs::ImpactParameterProduct, + hf_cand_bs::ImpactParameterProductJpsi, + hf_cand_bs::ImpactParameterProductPhi, + /* dynamic columns that use candidate momentum components */ + hf_cand::Pt, + hf_cand::Pt2, + hf_cand::P, + hf_cand::P2, + hf_cand::PVector, + hf_cand::Cpa, + hf_cand::CpaXY, + hf_cand::Ct, + hf_cand::ImpactParameterXY, + hf_cand_4prong::MaxNormalisedDeltaIP, + hf_cand::Eta, + hf_cand::Phi, + hf_cand::Y, + hf_cand::E, + hf_cand::E2, + hf_cand_4prong::CtXY, + o2::soa::Marker<1>); + +// extended table with expression columns that can be used as arguments of dynamic columns +DECLARE_SOA_EXTENDED_TABLE_USER(HfCandBsJPExt, HfCandBsJPBase, "HFCANDBSJPEXT", + hf_cand_4prong::Px, hf_cand_4prong::Py, hf_cand_4prong::Pz); + +DECLARE_SOA_TABLE(HfCandBsJPDaus, "AOD", "HFCANDBSJPDAUS", + hf_cand_bs::Prong0Id, hf_track_index::Prong1Id, hf_track_index::Prong2Id, hf_track_index::Prong3Id); + +using HfCandBsToJpsi = soa::Join; // specific Σc0,++ candidate properties namespace hf_cand_sigmac @@ -1996,16 +2439,32 @@ DECLARE_SOA_INDEX_COLUMN_FULL(ProngLc, prongLc, int, HfCand3Prong, ""); DECLARE_SOA_COLUMN(Charge, charge, int8_t); //! // Σc charge(either 0 or ++) DECLARE_SOA_COLUMN(StatusSpreadLcMinvPKPiFromPDG, statusSpreadLcMinvPKPiFromPDG, int); //! // Λc Minv(pKpi) spread from PDG Λc mass DECLARE_SOA_COLUMN(StatusSpreadLcMinvPiKPFromPDG, statusSpreadLcMinvPiKPFromPDG, int); //! // Λc Minv(piKp) spread from PDG Λc mass +DECLARE_SOA_COLUMN(SoftPiDcaXY, softPiDcaXY, float); //! soft-pion impact parameter in xy +DECLARE_SOA_COLUMN(SoftPiDcaZ, softPiDcaZ, float); //! soft-pion impact parameter in z DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfCand3Prong, "_0"); //! Λc index // MC matching result: -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level -DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! particle origin, reconstruction level -DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, generator level +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! particle origin, reconstruction level +DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, generator level +DECLARE_SOA_COLUMN(ParticleAntiparticle, particleAntiparticle, int8_t); //! particle or antiparticle // mapping of decay types enum DecayType { Sc0ToPKPiPi = 0, - ScplusplusToPKPiPi }; + ScplusplusToPKPiPi, + ScStar0ToPKPiPi, + ScStarPlusPlusToPKPiPi }; +enum Species : int { Sc2455 = 0, + Sc2520, + NSpecies }; +enum Decays : int { PKPi = 0, + PiKP, + NDecays }; +enum Conjugated : int { Particle = 0, + Antiparticle, + NConjugated }; +constexpr int ChargeNull = 0; +constexpr int ChargePlusPlus = 2; } // namespace hf_cand_sigmac // declare dedicated Σc0,++ decay candidate table @@ -2025,6 +2484,7 @@ DECLARE_SOA_TABLE(HfCandScBase, "AOD", "HFCANDSCBASE", /* Σc0,++ specific columns */ hf_cand_sigmac::Charge, hf_cand_sigmac::StatusSpreadLcMinvPKPiFromPDG, hf_cand_sigmac::StatusSpreadLcMinvPiKPFromPDG, + hf_cand_sigmac::SoftPiDcaXY, hf_cand_sigmac::SoftPiDcaZ, /* prong 0 */ // hf_cand::ImpactParameterNormalised0, hf_cand::PtProng0, @@ -2060,21 +2520,23 @@ DECLARE_SOA_TABLE(HfCandScMcRec, "AOD", "HFCANDSCMCREC", //! hf_cand_sigmac::FlagMcMatchRec, hf_cand_sigmac::OriginMcRec, hf_cand::PtBhadMotherPart, - hf_cand::PdgBhadMotherPart); + hf_cand::PdgBhadMotherPart, + hf_cand_sigmac::ParticleAntiparticle); // table with results of generation level MC matching DECLARE_SOA_TABLE(HfCandScMcGen, "AOD", "HFCANDSCMCGEN", //! hf_cand_sigmac::FlagMcMatchGen, hf_cand_sigmac::OriginMcGen, - hf_cand::IdxBhadMotherPart); + hf_cand::IdxBhadMotherPart, + hf_cand_sigmac::ParticleAntiparticle); // specific Σc0,++ candidate properties in cascade channel namespace hf_cand_sigmac_to_cascade { DECLARE_SOA_INDEX_COLUMN_FULL(ProngLc, prongLc, int, HfCandCascade, ""); //! Index to a Lc prong DECLARE_SOA_COLUMN(Charge, charge, int8_t); //! // Σc charge(either 0 or ++) -DECLARE_SOA_COLUMN(ChargeLc, chargelc, int8_t); //! // Λc charge(+) -DECLARE_SOA_COLUMN(ChargeSoftPi, chargesoftpi, int8_t); //! // pion charge(either - or +) +DECLARE_SOA_COLUMN(ChargeLc, chargeLc, int8_t); //! // Λc charge(+) +DECLARE_SOA_COLUMN(ChargeSoftPi, chargeSoftPi, int8_t); //! // pion charge(either - or +) DECLARE_SOA_COLUMN(StatusSpreadLcMinvKs0PFromPDG, statusSpreadLcMinvKs0PFromPDG, int); //! // Λc Minv spread from PDG Λc mass DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfCandCascade, "_0"); //! Λc index // MC matching result: @@ -2192,9 +2654,9 @@ DECLARE_SOA_DYNAMIC_COLUMN(DecayLengthXYNormalisedD0, decayLengthXYNormalisedD0, [](float xVtxP, float yVtxP, float xVtxS, float yVtxS, float err) -> float { return RecoDecay::distanceXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}) / err; }); DECLARE_SOA_COLUMN(ErrorDecayLengthD0, errorDecayLengthD0, float); DECLARE_SOA_COLUMN(ErrorDecayLengthXYD0, errorDecayLengthXYD0, float); -DECLARE_SOA_DYNAMIC_COLUMN(CPAD0, cpaD0, +DECLARE_SOA_DYNAMIC_COLUMN(CpaD0, cpaD0, [](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz) -> float { return RecoDecay::cpa(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); }); -DECLARE_SOA_DYNAMIC_COLUMN(CPAXYD0, cpaXYD0, +DECLARE_SOA_DYNAMIC_COLUMN(CpaXYD0, cpaXYD0, [](float xVtxP, float yVtxP, float xVtxS, float yVtxS, float px, float py) -> float { return RecoDecay::cpaXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}, std::array{px, py}); }); DECLARE_SOA_DYNAMIC_COLUMN(CtD0, ctD0, [](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz) -> float { return RecoDecay::ct(std::array{px, py, pz}, RecoDecay::distance(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}), constants::physics::MassD0); }); @@ -2234,8 +2696,10 @@ DECLARE_SOA_DYNAMIC_COLUMN(PtSoftPi, ptSoftPi, [](float pxSoftPi, float pySoftPi DECLARE_SOA_DYNAMIC_COLUMN(PVecSoftPi, pVecSoftPi, [](float px, float py, float pz) -> std::array { return std::array{px, py, pz}; }); // MC matching result: -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); //! generator level +DECLARE_SOA_COLUMN(FlagMcMatchRecD0, flagMcMatchRecD0, int8_t); //! reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchGenD0, flagMcMatchGenD0, int8_t); //! generator level DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! particle origin, reconstruction level DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, generator level @@ -2243,6 +2707,8 @@ DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle origin, gener enum DecayType { DstarToD0Pi = 0, D0ToPiK, + DstarToD0PiPi0, + D0ToPiKPi0, NDstarDecayType }; @@ -2286,8 +2752,8 @@ DECLARE_SOA_TABLE(HfD0FromDstarBase, "AOD", "HFD0FRMDSTR", hf_cand_dstar::PD0, hf_cand_dstar::P2D0, hf_cand_dstar::PVectorD0, - hf_cand_dstar::CPAD0, - hf_cand_dstar::CPAXYD0, + hf_cand_dstar::CpaD0, + hf_cand_dstar::CpaXYD0, hf_cand_dstar::CtD0, hf_cand_dstar::ImpactParameterXYD0, hf_cand_dstar::DeltaIPNormalisedMaxD0, @@ -2302,6 +2768,7 @@ DECLARE_SOA_EXTENDED_TABLE_USER(HfD0FromDstarExt, HfD0FromDstarBase, "HFD0FRMDST hf_cand_dstar::PxD0, hf_cand_dstar::PyD0, hf_cand_dstar::PzD0); using HfD0FromDstar = HfD0FromDstarExt; +using HfD0FromDstarWPid = soa::Join; DECLARE_SOA_TABLE(HfCandDstarBase, "AOD", "HFCANDDSTRBASE", o2::soa::Index<>, @@ -2352,18 +2819,22 @@ DECLARE_SOA_EXTENDED_TABLE_USER(HfCandDstarExt, HfCandDstarBase, "HFCANDDSTREXT" using HfCandDstars = HfCandDstarExt; using HfCandDstar = HfCandDstars::iterator; +using HfCandDstarsWPid = soa::Join; // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCandDstarMcRec, "AOD", "HFCANDDSTRMCREC", hf_cand_dstar::FlagMcMatchRec, + hf_cand_dstar::FlagMcMatchRecD0, hf_cand_dstar::OriginMcRec, hf_cand::PtBhadMotherPart, hf_cand::PdgBhadMotherPart, - hf_cand::NTracksDecayed); + hf_cand::NTracksDecayed, + hf_cand::NInteractionsWithMaterial); // table with results of generator level MC matching DECLARE_SOA_TABLE(HfCandDstarMcGen, "AOD", "HFCANDDSTRMCGEN", hf_cand_dstar::FlagMcMatchGen, + hf_cand_dstar::FlagMcMatchGenD0, hf_cand_dstar::OriginMcGen, hf_cand::IdxBhadMotherPart); diff --git a/PWGHF/DataModel/CandidateSelectionTables.h b/PWGHF/DataModel/CandidateSelectionTables.h index 60ba4850953..7f5786ee1f6 100644 --- a/PWGHF/DataModel/CandidateSelectionTables.h +++ b/PWGHF/DataModel/CandidateSelectionTables.h @@ -11,17 +11,15 @@ /// \file CandidateSelectionTables.h /// \brief Definitions of tables produced by candidate selectors +/// +/// \author Nima Zardoshti , CERN #ifndef PWGHF_DATAMODEL_CANDIDATESELECTIONTABLES_H_ #define PWGHF_DATAMODEL_CANDIDATESELECTIONTABLES_H_ -#include - -#include "Common/Core/RecoDecay.h" -#include "Common/Core/TrackSelectorPID.h" +#include -#include "PWGHF/Core/SelectorCuts.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include namespace o2::aod { @@ -252,19 +250,23 @@ DECLARE_SOA_TABLE(HfMlB0ToDPi, "AOD", "HFMLB0", //! namespace hf_sel_candidate_bs { -DECLARE_SOA_COLUMN(IsSelBsToDsPi, isSelBsToDsPi, int); //! -DECLARE_SOA_COLUMN(MlProbBsToDsPi, mlProbBsToDsPi, std::vector); //! +DECLARE_SOA_COLUMN(IsSelBsToDsPi, isSelBsToDsPi, int); //! +DECLARE_SOA_COLUMN(MlProbBsToDsPi, mlProbBsToDsPi, std::vector); //! +DECLARE_SOA_COLUMN(MlProbBsToJpsiPhi, mlProbBsToJpsiPhi, std::vector); //! } // namespace hf_sel_candidate_bs DECLARE_SOA_TABLE(HfSelBsToDsPi, "AOD", "HFSELBS", //! hf_sel_candidate_bs::IsSelBsToDsPi); DECLARE_SOA_TABLE(HfMlBsToDsPi, "AOD", "HFMLBS", //! hf_sel_candidate_bs::MlProbBsToDsPi); +DECLARE_SOA_TABLE(HfMlBsToJpsiPhi, "AOD", "HFMLBSTOJPSIPHI", //! + hf_sel_candidate_bs::MlProbBsToDsPi); namespace hf_sel_candidate_bplus { -DECLARE_SOA_COLUMN(IsSelBplusToD0Pi, isSelBplusToD0Pi, int); //! selection flag on B+ candidate -DECLARE_SOA_COLUMN(MlProbBplusToD0Pi, mlProbBplusToD0Pi, float); //! ML score of B+ candidate for signal class +DECLARE_SOA_COLUMN(IsSelBplusToD0Pi, isSelBplusToD0Pi, int); //! selection flag on B+ candidate +DECLARE_SOA_COLUMN(MlProbBplusToD0Pi, mlProbBplusToD0Pi, float); //! ML score of B+ candidate for signal class +DECLARE_SOA_COLUMN(MlProbBplusToJpsiK, mlProbBplusToJpsiK, float); //! ML score of B+ candidate for signal class } // namespace hf_sel_candidate_bplus DECLARE_SOA_TABLE(HfSelBplusToD0Pi, "AOD", "HFSELBPLUS", //! @@ -273,13 +275,19 @@ DECLARE_SOA_TABLE(HfSelBplusToD0Pi, "AOD", "HFSELBPLUS", //! DECLARE_SOA_TABLE(HfMlBplusToD0Pi, "AOD", "HFMLBPLUS", //! hf_sel_candidate_bplus::MlProbBplusToD0Pi); +DECLARE_SOA_TABLE(HfMlBplusToJpsiK, "AOD", "HFMLBPLUSTOJPSIK", //! + hf_sel_candidate_bplus::MlProbBplusToJpsiK); namespace hf_sel_candidate_lb { -DECLARE_SOA_COLUMN(IsSelLbToLcPi, isSelLbToLcPi, int); //! +DECLARE_SOA_COLUMN(IsSelLbToLcPi, isSelLbToLcPi, int); //! selection flag on Lb candidate +DECLARE_SOA_COLUMN(MlProbLbToLcPi, mlProbLbToLcPi, float); //! ML score of Lb candidate for signal class + } // namespace hf_sel_candidate_lb DECLARE_SOA_TABLE(HfSelLbToLcPi, "AOD", "HFSELLB", //! hf_sel_candidate_lb::IsSelLbToLcPi); +DECLARE_SOA_TABLE(HfMlLbToLcPi, "AOD", "HFMLLB", //! + hf_sel_candidate_lb::MlProbLbToLcPi); namespace hf_sel_candidate_x { @@ -309,6 +317,14 @@ DECLARE_SOA_COLUMN(MlProbXicToPiKP, mlProbXicToPiKP, std::vector); //! // XicPlus to Xi Pi Pi DECLARE_SOA_COLUMN(IsSelXicToXiPiPi, isSelXicToXiPiPi, int); //! DECLARE_SOA_COLUMN(MlProbXicToXiPiPi, mlProbXicToXiPiPi, std::vector); //! +enum XicToXiPiPiSelectionStep { + RecoTotal = 0, + RecoKinTopol, + RecoTrackQuality, + RecoPID, + RecoMl, + NSelectionSteps +}; } // namespace hf_sel_candidate_xic DECLARE_SOA_TABLE(HfSelXicToPKPi, "AOD", "HFSELXIC", //! @@ -348,6 +364,7 @@ DECLARE_SOA_COLUMN(TofNSigmaPiFromLambda, tofNSigmaPiFromLambda, float); DECLARE_SOA_COLUMN(TofNSigmaPrFromLambda, tofNSigmaPrFromLambda, float); DECLARE_SOA_COLUMN(PidTpcInfoStored, pidTpcInfoStored, int); DECLARE_SOA_COLUMN(PidTofInfoStored, pidTofInfoStored, int); +DECLARE_SOA_COLUMN(MlProbToXiPi, mlProbToXiPi, std::vector); } // namespace hf_sel_toxipi DECLARE_SOA_TABLE(HfSelToXiPi, "AOD", "HFSELTOXIPI", @@ -358,12 +375,13 @@ DECLARE_SOA_TABLE(HfSelToXiPi, "AOD", "HFSELTOXIPI", hf_sel_toxipi::TofNSigmaPiFromCharmBaryon, hf_sel_toxipi::TofNSigmaPiFromCasc, hf_sel_toxipi::TofNSigmaPiFromLambda, hf_sel_toxipi::TofNSigmaPrFromLambda); DECLARE_SOA_TABLE(HfSelToXiPiKf, "AOD", "HFSELTOXIPIKF", - hf_sel_toxipi::StatusPidCharmBaryon, hf_sel_toxipi::StatusPidCascade, hf_sel_toxipi::StatusPidLambda, - hf_sel_toxipi::StatusInvMassCharmBaryon, hf_sel_toxipi::StatusInvMassCascade, hf_sel_toxipi::StatusInvMassLambda, - hf_sel_toxipi::ResultSelections, hf_sel_toxipi::PidTpcInfoStored, hf_sel_toxipi::PidTofInfoStored, + hf_sel_toxipi::ResultSelections, hf_sel_toxipi::TpcNSigmaPiFromCharmBaryon, hf_sel_toxipi::TpcNSigmaPiFromCasc, hf_sel_toxipi::TpcNSigmaPiFromLambda, hf_sel_toxipi::TpcNSigmaPrFromLambda, hf_sel_toxipi::TofNSigmaPiFromCharmBaryon, hf_sel_toxipi::TofNSigmaPiFromCasc, hf_sel_toxipi::TofNSigmaPiFromLambda, hf_sel_toxipi::TofNSigmaPrFromLambda); +DECLARE_SOA_TABLE(HfMlToXiPiKf, "AOD", "HFMLSELTOXIPIKF", + hf_sel_toxipi::MlProbToXiPi); + namespace hf_sel_toomegapi { DECLARE_SOA_COLUMN(StatusPidLambda, statusPidLambda, bool); @@ -374,12 +392,12 @@ DECLARE_SOA_COLUMN(StatusInvMassCascade, statusInvMassCascade, bool); DECLARE_SOA_COLUMN(StatusInvMassCharmBaryon, statusInvMassCharmBaryon, bool); DECLARE_SOA_COLUMN(ResultSelections, resultSelections, bool); DECLARE_SOA_COLUMN(TpcNSigmaPiFromCharmBaryon, tpcNSigmaPiFromCharmBaryon, float); -// DECLARE_SOA_COLUMN(TpcNSigmaKaFromCharmBaryon, tpcNSigmaKaFromCharmBaryon, float); +DECLARE_SOA_COLUMN(TpcNSigmaKaFromCharmBaryon, tpcNSigmaKaFromCharmBaryon, float); DECLARE_SOA_COLUMN(TpcNSigmaKaFromCasc, tpcNSigmaKaFromCasc, float); DECLARE_SOA_COLUMN(TpcNSigmaPiFromLambda, tpcNSigmaPiFromLambda, float); DECLARE_SOA_COLUMN(TpcNSigmaPrFromLambda, tpcNSigmaPrFromLambda, float); DECLARE_SOA_COLUMN(TofNSigmaPiFromCharmBaryon, tofNSigmaPiFromCharmBaryon, float); -// DECLARE_SOA_COLUMN(TofNSigmaKaFromCharmBaryon, tofNSigmaKaFromCharmBaryon, float); +DECLARE_SOA_COLUMN(TofNSigmaKaFromCharmBaryon, tofNSigmaKaFromCharmBaryon, float); DECLARE_SOA_COLUMN(TofNSigmaKaFromCasc, tofNSigmaKaFromCasc, float); DECLARE_SOA_COLUMN(TofNSigmaPiFromLambda, tofNSigmaPiFromLambda, float); DECLARE_SOA_COLUMN(TofNSigmaPrFromLambda, tofNSigmaPrFromLambda, float); @@ -387,7 +405,6 @@ DECLARE_SOA_COLUMN(PidTpcInfoStored, pidTpcInfoStored, int); DECLARE_SOA_COLUMN(PidTofInfoStored, pidTofInfoStored, int); // Machine learning column for omegac0 to omega pi DECLARE_SOA_COLUMN(MlProbOmegac, mlProbOmegac, std::vector); -DECLARE_SOA_COLUMN(MlProbOmegacBar, mlProbOmegacBar, std::vector); } // namespace hf_sel_toomegapi DECLARE_SOA_TABLE(HfSelToOmegaPi, "AOD", "HFSELTOOMEPI", @@ -397,8 +414,15 @@ DECLARE_SOA_TABLE(HfSelToOmegaPi, "AOD", "HFSELTOOMEPI", hf_sel_toomegapi::TpcNSigmaPiFromCharmBaryon, hf_sel_toomegapi::TpcNSigmaKaFromCasc, hf_sel_toomegapi::TpcNSigmaPiFromLambda, hf_sel_toomegapi::TpcNSigmaPrFromLambda, hf_sel_toomegapi::TofNSigmaPiFromCharmBaryon, hf_sel_toomegapi::TofNSigmaKaFromCasc, hf_sel_toomegapi::TofNSigmaPiFromLambda, hf_sel_toomegapi::TofNSigmaPrFromLambda); +DECLARE_SOA_TABLE(HfSelToOmegaKaKf, "AOD", "HFSELTOOMEGAKAKF", + hf_sel_toomegapi::StatusPidLambda, hf_sel_toomegapi::StatusPidCascade, hf_sel_toomegapi::StatusPidCharmBaryon, + hf_sel_toomegapi::StatusInvMassLambda, hf_sel_toomegapi::StatusInvMassCascade, hf_sel_toomegapi::StatusInvMassCharmBaryon, + hf_sel_toomegapi::ResultSelections, hf_sel_toomegapi::PidTpcInfoStored, hf_sel_toomegapi::PidTofInfoStored, + hf_sel_toomegapi::TpcNSigmaKaFromCharmBaryon, hf_sel_toomegapi::TpcNSigmaKaFromCasc, hf_sel_toomegapi::TpcNSigmaPiFromLambda, hf_sel_toomegapi::TpcNSigmaPrFromLambda, + hf_sel_toomegapi::TofNSigmaKaFromCharmBaryon, hf_sel_toomegapi::TofNSigmaKaFromCasc, hf_sel_toomegapi::TofNSigmaPiFromLambda, hf_sel_toomegapi::TofNSigmaPrFromLambda); + DECLARE_SOA_TABLE(HfMlSelOmegacToOmegaPi, "AOD", "HFMLOMEGAC", //! - hf_sel_toomegapi::MlProbOmegac, hf_sel_toomegapi::MlProbOmegacBar); + hf_sel_toomegapi::MlProbOmegac); namespace hf_sel_toomegaka { DECLARE_SOA_COLUMN(StatusPidLambda, statusPidLambda, bool); diff --git a/PWGHF/DataModel/DerivedTables.h b/PWGHF/DataModel/DerivedTables.h index ad4f787fd19..e3602a0ba63 100644 --- a/PWGHF/DataModel/DerivedTables.h +++ b/PWGHF/DataModel/DerivedTables.h @@ -16,29 +16,32 @@ #ifndef PWGHF_DATAMODEL_DERIVEDTABLES_H_ #define PWGHF_DATAMODEL_DERIVEDTABLES_H_ -#include - -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" -#include "PWGLF/DataModel/mcCentrality.h" +#include +#include -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include + +#include +#include namespace o2::aod { // basic species: -// D0 -> K- + pi+ (done) -// Lc -> pi+ K- p -// D+ -> K- + pi+ + pi+ (3P table with adapted PID columns) -// Ds+ -> K- + K+ + pi+ (3P table with adapted PID columns) +// D0 → K− π+ +// Λc → p K− π+ +// D+ → K− π+ π+ +// Ds+ → K− K+ π+ + // composite species -// B0 -> D- + pi+ -// B+ -> D0 + pi+ (in progress) -// D*+ -> D0 + pi+ +// B0 → D− π+ +// B+ → D0 π+ +// D*+ → D0 π+ +// Ξc± → (Ξ∓ → (Λ → p π∓) π∓) π± π± // ================ // Collision tables @@ -62,8 +65,8 @@ namespace hf_mc_coll DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); //! original global index of the MC collision } // namespace hf_mc_coll -// Defines the collision table -#define DECLARE_COLL_TABLE(_hf_type_, _hf_description_) \ +// Declares the base table with reconstructed collisions (CollBases) and joinable tables (CollIds). +#define DECLARE_TABLES_COLL(_hf_type_, _hf_description_) \ DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##CollBases, "HF" _hf_description_ "COLLBASE", \ o2::soa::Index<>, \ collision::PosX, \ @@ -84,36 +87,36 @@ DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); //! original global index of hf_cand::CollisionId, \ o2::soa::Marker); -// Defines the mc collision table -#define DECLARE_MCCOLL_TABLE(_hf_type_, _hf_description_, _hf_namespace_) \ - namespace hf_mc_coll \ - { \ - namespace der_##_hf_namespace_ \ - { \ - DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(Hf##_hf_type_##CollBase, hfCollBases, "HF" _hf_description_ "COLLBASES"); \ - } \ - } \ - DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##McCollBases, "HF" _hf_description_ "MCCOLLBASE", \ - o2::soa::Index<>, \ - mccollision::PosX, \ - mccollision::PosY, \ - mccollision::PosZ, \ - cent::CentFT0M, \ - o2::soa::Marker); \ - \ - using Hf##_hf_type_##McCollBase = Hf##_hf_type_##McCollBases::iterator; \ - using StoredHf##_hf_type_##McCollBase = StoredHf##_hf_type_##McCollBases::iterator; \ - \ - DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##McCollIds, "HF" _hf_description_ "MCCOLLID", \ - hf_mc_coll::McCollisionId, \ - o2::soa::Marker); \ - \ - DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##McRCollIds, "HF" _hf_description_ "MCRCOLLID", \ +// Declares the base table with MC collisions (McCollBases) and joinable tables (McCollIds, McRCollIds). +#define DECLARE_TABLES_MCCOLL(_hf_type_, _hf_description_, _hf_namespace_) \ + namespace hf_mc_coll \ + { \ + namespace der_##_hf_namespace_ \ + { \ + DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(Hf##_hf_type_##CollBase, hfCollBases, "HF" _hf_description_ "COLLBASES"); /* o2-linter: disable=name/o2-column (unified getter) */ \ + } \ + } \ + DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##McCollBases, "HF" _hf_description_ "MCCOLLBASE", \ + o2::soa::Index<>, \ + mccollision::PosX, \ + mccollision::PosY, \ + mccollision::PosZ, \ + cent::CentFT0M, \ + o2::soa::Marker); \ + \ + using Hf##_hf_type_##McCollBase = Hf##_hf_type_##McCollBases::iterator; \ + using StoredHf##_hf_type_##McCollBase = StoredHf##_hf_type_##McCollBases::iterator; \ + \ + DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##McCollIds, "HF" _hf_description_ "MCCOLLID", \ + hf_mc_coll::McCollisionId, \ + o2::soa::Marker); \ + \ + DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##McRCollIds, "HF" _hf_description_ "MCRCOLLID", \ hf_mc_coll::der_##_hf_namespace_::Hf##_hf_type_##CollBaseIds); -#define DECLARE_COLL_TABLES(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_COLL_TABLE(_hf_type_, _hf_description_) \ - DECLARE_MCCOLL_TABLE(_hf_type_, _hf_description_, _hf_namespace_) +// ================ +// Candidate tables +// ================ namespace hf_cand_base { @@ -161,37 +164,40 @@ DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); //! particle DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); //! resonant decay channel flag, generator level } // namespace hf_mc_particle -#define DECLARE_CAND_BASE_TABLE(_hf_type_, _hf_description_, _hf_namespace_) \ - namespace hf_cand_base \ - { \ - namespace der_##_hf_namespace_ \ - { \ - DECLARE_SOA_INDEX_COLUMN_CUSTOM(Hf##_hf_type_##CollBase, hfCollBase, "HF" _hf_description_ "COLLBASES"); \ - } \ - } \ - \ - DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##Bases, "HF" _hf_description_ "BASE", \ - o2::soa::Index<>, \ - hf_cand_base::der_##_hf_namespace_::Hf##_hf_type_##CollBaseId, \ - hf_cand_base::Pt, \ - hf_cand_base::Eta, \ - hf_cand_base::Phi, \ - hf_cand_base::M, \ - hf_cand_base::Y, \ - hf_cand_base::Px, \ - hf_cand_base::Py, \ - hf_cand_base::Pz, \ - hf_cand_base::P, \ +// Declares the base table with candidates (Bases). +#define DECLARE_TABLE_CAND_BASE(_hf_type_, _hf_description_, _hf_namespace_) \ + namespace hf_cand_base \ + { \ + namespace der_##_hf_namespace_ \ + { \ + DECLARE_SOA_INDEX_COLUMN_CUSTOM(Hf##_hf_type_##CollBase, hfCollBase, "HF" _hf_description_ "COLLBASES"); /* o2-linter: disable=name/o2-column (unified getter) */ \ + } \ + } \ + \ + DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##Bases, "HF" _hf_description_ "BASE", \ + o2::soa::Index<>, \ + hf_cand_base::der_##_hf_namespace_::Hf##_hf_type_##CollBaseId, \ + hf_cand_base::Pt, \ + hf_cand_base::Eta, \ + hf_cand_base::Phi, \ + hf_cand_base::M, \ + hf_cand_base::Y, \ + hf_cand_base::Px, \ + hf_cand_base::Py, \ + hf_cand_base::Pz, \ + hf_cand_base::P, \ o2::soa::Marker); -#define DECLARE_CAND_2P_ID_TABLE(_hf_type_, _hf_description_) \ +// Declares the table with global indices for 2-prong candidates (Ids). +#define DECLARE_TABLE_CAND_ID_2P(_hf_type_, _hf_description_) \ DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##Ids, "HF" _hf_description_ "ID", \ hf_cand::CollisionId, \ hf_track_index::Prong0Id, \ hf_track_index::Prong1Id, \ o2::soa::Marker); -#define DECLARE_CAND_3P_ID_TABLE(_hf_type_, _hf_description_) \ +// Declares the table with global indices for 3-prong candidates (Ids). +#define DECLARE_TABLE_CAND_ID_3P(_hf_type_, _hf_description_) \ DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##Ids, "HF" _hf_description_ "ID", \ hf_cand::CollisionId, \ hf_track_index::Prong0Id, \ @@ -199,95 +205,157 @@ DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); //! resonant hf_track_index::Prong2Id, \ o2::soa::Marker); -#define DECLARE_CAND_SEL_TABLE(_hf_type_, _hf_description_) \ +// Declares the table with global indices for 4-prong candidates (Ids). +#define DECLARE_TABLE_CAND_ID_4P(_hf_type_, _hf_description_) \ + DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##Ids, "HF" _hf_description_ "ID", \ + hf_cand::CollisionId, \ + hf_track_index::Prong0Id, \ + hf_track_index::Prong1Id, \ + hf_track_index::Prong2Id, \ + hf_track_index::Prong3Id, \ + o2::soa::Marker); + +// Declares the table with global indices for 5-prong candidates (Ids). +#define DECLARE_TABLE_CAND_ID_5P(_hf_type_, _hf_description_) \ + DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##Ids, "HF" _hf_description_ "ID", \ + hf_cand::CollisionId, \ + hf_track_index::Prong0Id, \ + hf_track_index::Prong1Id, \ + hf_track_index::Prong2Id, \ + hf_track_index::Prong3Id, \ + hf_track_index::Prong4Id, \ + o2::soa::Marker); + +// Declares the table with candidate selection flags (Sels). +#define DECLARE_TABLE_CAND_SEL(_hf_type_, _hf_description_) \ DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##Sels, "HF" _hf_description_ "SEL", \ hf_cand_sel::CandidateSelFlag, \ o2::soa::Marker); -#define DECLARE_MCCAND_BASE_TABLE(_hf_type_, _hf_description_, _hf_namespace_) \ - namespace hf_mc_particle \ - { \ - namespace der_##_hf_namespace_ \ - { \ - DECLARE_SOA_INDEX_COLUMN_CUSTOM(Hf##_hf_type_##McCollBase, hfMcCollBase, "HF" _hf_description_ "MCCOLLBASES"); \ - } \ - } \ - DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##PBases, "HF" _hf_description_ "PBASE", \ - o2::soa::Index<>, \ - hf_mc_particle::der_##_hf_namespace_::Hf##_hf_type_##McCollBaseId, \ - hf_cand_base::Pt, \ - hf_cand_base::Eta, \ - hf_cand_base::Phi, \ - hf_cand_base::Y, \ - hf_mc_particle::FlagMcMatchGen, \ - hf_mc_particle::OriginMcGen, \ - hf_cand_base::Px, \ - hf_cand_base::Py, \ - hf_cand_base::Pz, \ - hf_cand_base::P, \ +// ================ +// MC particle tables +// ================ + +// Declares the base table with MC particles (PBases). +#define DECLARE_TABLE_MCPARTICLE_BASE(_hf_type_, _hf_description_, _hf_namespace_) \ + namespace hf_mc_particle \ + { \ + namespace der_##_hf_namespace_ \ + { \ + DECLARE_SOA_INDEX_COLUMN_CUSTOM(Hf##_hf_type_##McCollBase, hfMcCollBase, "HF" _hf_description_ "MCCOLLBASES"); /* o2-linter: disable=name/o2-column (unified getter) */ \ + } \ + } \ + DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##PBases, "HF" _hf_description_ "PBASE", \ + o2::soa::Index<>, \ + hf_mc_particle::der_##_hf_namespace_::Hf##_hf_type_##McCollBaseId, \ + hf_cand_base::Pt, \ + hf_cand_base::Eta, \ + hf_cand_base::Phi, \ + hf_cand_base::Y, \ + hf_mc_particle::FlagMcMatchGen, \ + hf_mc_particle::OriginMcGen, \ + hf_cand_base::Px, \ + hf_cand_base::Py, \ + hf_cand_base::Pz, \ + hf_cand_base::P, \ o2::soa::Marker); -#define DECLARE_MCCAND_ID_TABLE(_hf_type_, _hf_description_) \ +// Declares the table with global indices for MC particles (PIds). +#define DECLARE_TABLE_MCPARTICLE_ID(_hf_type_, _hf_description_) \ DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##PIds, "HF" _hf_description_ "PID", \ hf_mc_particle::McCollisionId, \ hf_mc_particle::McParticleId, \ o2::soa::Marker); -#define DECLARE_CAND_TABLES(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_CAND_BASE_TABLE(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_CAND_SEL_TABLE(_hf_type_, _hf_description_) \ - DECLARE_MCCAND_BASE_TABLE(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_MCCAND_ID_TABLE(_hf_type_, _hf_description_) +// ================ +// Helper macros for combinations +// ================ -#define DECLARE_CAND_2P_TABLES(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_CAND_TABLES(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_CAND_2P_ID_TABLE(_hf_type_, _hf_description_) +#define DECLARE_TABLES_COMMON(_hf_type_, _hf_description_, _hf_namespace_) \ + DECLARE_TABLES_COLL(_hf_type_, _hf_description_) \ + DECLARE_TABLES_MCCOLL(_hf_type_, _hf_description_, _hf_namespace_) \ + DECLARE_TABLE_CAND_BASE(_hf_type_, _hf_description_, _hf_namespace_) \ + DECLARE_TABLE_CAND_SEL(_hf_type_, _hf_description_) \ + DECLARE_TABLE_MCPARTICLE_BASE(_hf_type_, _hf_description_, _hf_namespace_) \ + DECLARE_TABLE_MCPARTICLE_ID(_hf_type_, _hf_description_) -#define DECLARE_CAND_3P_TABLES(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_CAND_TABLES(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_CAND_3P_ID_TABLE(_hf_type_, _hf_description_) +#define DECLARE_TABLES_2P(_hf_type_, _hf_description_, _hf_namespace_, _marker_number_) \ + constexpr uint Marker##_hf_type_ = _marker_number_; \ + DECLARE_TABLES_COMMON(_hf_type_, _hf_description_, _hf_namespace_) \ + DECLARE_TABLE_CAND_ID_2P(_hf_type_, _hf_description_) -#define DECLARE_2P_TABLES(_hf_type_, _hf_description_, _hf_namespace_, _marker_number_) \ +#define DECLARE_TABLES_3P(_hf_type_, _hf_description_, _hf_namespace_, _marker_number_) \ constexpr uint Marker##_hf_type_ = _marker_number_; \ - DECLARE_COLL_TABLES(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_CAND_2P_TABLES(_hf_type_, _hf_description_, _hf_namespace_) + DECLARE_TABLES_COMMON(_hf_type_, _hf_description_, _hf_namespace_) \ + DECLARE_TABLE_CAND_ID_3P(_hf_type_, _hf_description_) -#define DECLARE_3P_TABLES(_hf_type_, _hf_description_, _hf_namespace_, _marker_number_) \ +#define DECLARE_TABLES_4P(_hf_type_, _hf_description_, _hf_namespace_, _marker_number_) \ constexpr uint Marker##_hf_type_ = _marker_number_; \ - DECLARE_COLL_TABLES(_hf_type_, _hf_description_, _hf_namespace_) \ - DECLARE_CAND_3P_TABLES(_hf_type_, _hf_description_, _hf_namespace_) + DECLARE_TABLES_COMMON(_hf_type_, _hf_description_, _hf_namespace_) \ + DECLARE_TABLE_CAND_ID_4P(_hf_type_, _hf_description_) -DECLARE_2P_TABLES(D0, "D0", d0, 2); -DECLARE_3P_TABLES(Lc, "LC", lc, 3); -DECLARE_3P_TABLES(Bplus, "BP", bplus, 4); +#define DECLARE_TABLES_5P(_hf_type_, _hf_description_, _hf_namespace_, _marker_number_) \ + constexpr uint Marker##_hf_type_ = _marker_number_; \ + DECLARE_TABLES_COMMON(_hf_type_, _hf_description_, _hf_namespace_) \ + DECLARE_TABLE_CAND_ID_5P(_hf_type_, _hf_description_) // ================ -// Candidate tables +// Declarations of common tables for individual species +// ================ + +DECLARE_TABLES_2P(D0, "D0", d0, 2); +DECLARE_TABLES_3P(Lc, "LC", lc, 3); +DECLARE_TABLES_3P(Dplus, "DP", dplus, 4); +DECLARE_TABLES_3P(Ds, "DS", ds, 9); +DECLARE_TABLES_3P(Bplus, "BP", bplus, 5); +DECLARE_TABLES_3P(Dstar, "DST", dstar, 6); +// Workaround for the existing B0 macro in termios.h +#pragma push_macro("B0") +#undef B0 +DECLARE_TABLES_4P(B0, "B0", b0, 7); +#pragma pop_macro("B0") +DECLARE_TABLES_5P(XicToXiPiPi, "XICXPP", xic_to_xi_pi_pi, 8); + +// ================ +// Additional species-specific candidate tables // ================ // Candidate properties used for selection namespace hf_cand_par { -DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float); //! cosine of theta star -DECLARE_SOA_COLUMN(Cpa, cpa, float); //! cosine of pointing angle -DECLARE_SOA_COLUMN(CpaXY, cpaXY, float); //! cosine of pointing angle in the transverse plane -DECLARE_SOA_COLUMN(Ct, ct, float); //! proper lifetime times c -DECLARE_SOA_COLUMN(DecayLength, decayLength, float); //! decay length -DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float); //! decay length divided by its uncertainty -DECLARE_SOA_COLUMN(DecayLengthXY, decayLengthXY, float); //! decay length in the transverse plane -DECLARE_SOA_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, float); //! decay length in the transverse plane divided by its uncertainty -DECLARE_SOA_COLUMN(ImpactParameterNormalised0, impactParameterNormalised0, float); //! impact parameter of prong 0 divided by its uncertainty -DECLARE_SOA_COLUMN(ImpactParameterNormalised1, impactParameterNormalised1, float); //! impact parameter of prong 1 divided by its uncertainty -DECLARE_SOA_COLUMN(ImpactParameterNormalised2, impactParameterNormalised2, float); //! impact parameter of prong 2 divided by its uncertainty -DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float); //! product of impact parameters of prong 0 and prong 1 -DECLARE_SOA_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float); //! see RecoDecay::maxNormalisedDeltaIP -DECLARE_SOA_COLUMN(PProng0, pProng0, float); //! momentum magnitude of prong 0 -DECLARE_SOA_COLUMN(PProng1, pProng1, float); //! momentum magnitude of prong 1 -DECLARE_SOA_COLUMN(PProng2, pProng2, float); //! momentum magnitude of prong 2 -DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); //! transverse momentum of prong 0 -DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); //! transverse momentum of prong 1 -DECLARE_SOA_COLUMN(PtProng2, ptProng2, float); //! transverse momentum of prong 2 -DECLARE_SOA_COLUMN(RSecondaryVertex, rSecondaryVertex, float); //! distance of the secondary vertex from the z axis +DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float); //! cosine of theta star +DECLARE_SOA_COLUMN(Cpa, cpa, float); //! cosine of pointing angle +DECLARE_SOA_COLUMN(CpaXY, cpaXY, float); //! cosine of pointing angle in the transverse plane +DECLARE_SOA_COLUMN(Ct, ct, float); //! proper lifetime times c +DECLARE_SOA_COLUMN(DecayLength, decayLength, float); //! decay length +DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float); //! decay length divided by its uncertainty +DECLARE_SOA_COLUMN(DecayLengthXY, decayLengthXY, float); //! decay length in the transverse plane +DECLARE_SOA_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, float); //! decay length in the transverse plane divided by its uncertainty +DECLARE_SOA_COLUMN(ImpactParameterXi, impactParameterXi, float); //! impact parameter of the Xi prong +DECLARE_SOA_COLUMN(ImpactParameterPi0, impactParameterPi0, float); //! impact parameter of the first pion prong +DECLARE_SOA_COLUMN(ImpactParameterPi1, impactParameterPi1, float); //! impact parameter of the second pion prong +DECLARE_SOA_COLUMN(ImpactParameterNormalised0, impactParameterNormalised0, float); //! impact parameter of prong 0 divided by its uncertainty +DECLARE_SOA_COLUMN(ImpactParameterNormalised1, impactParameterNormalised1, float); //! impact parameter of prong 1 divided by its uncertainty +DECLARE_SOA_COLUMN(ImpactParameterNormalised2, impactParameterNormalised2, float); //! impact parameter of prong 2 divided by its uncertainty +DECLARE_SOA_COLUMN(ImpactParameterNormalisedXi, impactParameterNormalisedXi, float); //! impact parameter of the Xi prong divided by its uncertainty +DECLARE_SOA_COLUMN(ImpactParameterNormalisedPi0, impactParameterNormalisedPi0, float); //! impact parameter of the first pion prong divided by its uncertainty +DECLARE_SOA_COLUMN(ImpactParameterNormalisedPi1, impactParameterNormalisedPi1, float); //! impact parameter of the second pion prong divided by its uncertainty +DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float); //! product of impact parameters of prong 0 and prong 1 +DECLARE_SOA_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float); //! see RecoDecay::maxNormalisedDeltaIP +DECLARE_SOA_COLUMN(PProng0, pProng0, float); //! momentum magnitude of prong 0 +DECLARE_SOA_COLUMN(PProng1, pProng1, float); //! momentum magnitude of prong 1 +DECLARE_SOA_COLUMN(PProng2, pProng2, float); //! momentum magnitude of prong 2 +DECLARE_SOA_COLUMN(PProngPi0, pProngPi0, float); //! momentum magnitude of the first pion prong +DECLARE_SOA_COLUMN(PProngPi1, pProngPi1, float); //! momentum magnitude of the second pion prong +DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); //! transverse momentum of prong 0 +DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); //! transverse momentum of prong 1 +DECLARE_SOA_COLUMN(PtProng2, ptProng2, float); //! transverse momentum of prong 2 +DECLARE_SOA_COLUMN(PtProngXi, ptProngXi, float); //! transverse momentum of the Xi prong +DECLARE_SOA_COLUMN(PtProngPi0, ptProngPi0, float); //! transverse momentum of the first pion prong +DECLARE_SOA_COLUMN(PtProngPi1, ptProngPi1, float); //! transverse momentum of the second pion prong +DECLARE_SOA_COLUMN(RSecondaryVertex, rSecondaryVertex, float); //! distance of the secondary vertex from the z axis +// D*± → D0(bar) π± +DECLARE_SOA_COLUMN(SignProng1, signProng1, int8_t); // TOF DECLARE_SOA_COLUMN(NSigTofKa0, nSigTofKa0, float); DECLARE_SOA_COLUMN(NSigTofKa1, nSigTofKa1, float); @@ -337,6 +405,8 @@ DECLARE_SOA_COLUMN(NSigTpcTofPr2, nSigTpcTofPr2, float); // We don't want to link the charm candidate table because we want to avoid producing it. namespace hf_cand_par_charm { +DECLARE_SOA_COLUMN(Chi2PCACharm, chi2PCACharm, float); //! sum of (non-weighted) distances of the secondary vertex to its prongs +DECLARE_SOA_COLUMN(NProngsContributorsPVCharm, nProngsContributorsPVCharm, uint8_t); //! number of prongs contributing to the primary-vertex reconstruction DECLARE_SOA_COLUMN(CosThetaStarCharm, cosThetaStarCharm, float); //! cosine of theta star DECLARE_SOA_COLUMN(CpaCharm, cpaCharm, float); //! cosine of pointing angle DECLARE_SOA_COLUMN(CpaXYCharm, cpaXYCharm, float); //! cosine of pointing angle in the transverse plane @@ -347,11 +417,18 @@ DECLARE_SOA_COLUMN(DecayLengthXYCharm, decayLengthXYCharm, float); DECLARE_SOA_COLUMN(DecayLengthXYNormalisedCharm, decayLengthXYNormalisedCharm, float); //! decay length in the transverse plane divided by its uncertainty DECLARE_SOA_COLUMN(ImpactParameter0Charm, impactParameter0Charm, float); //! impact parameter of prong 0 DECLARE_SOA_COLUMN(ImpactParameter1Charm, impactParameter1Charm, float); //! impact parameter of prong 1 +DECLARE_SOA_COLUMN(ImpactParameter2Charm, impactParameter2Charm, float); //! impact parameter of prong 2 DECLARE_SOA_COLUMN(ImpactParameterNormalised0Charm, impactParameterNormalised0Charm, float); //! impact parameter of prong 0 divided by its uncertainty DECLARE_SOA_COLUMN(ImpactParameterNormalised1Charm, impactParameterNormalised1Charm, float); //! impact parameter of prong 1 divided by its uncertainty DECLARE_SOA_COLUMN(ImpactParameterNormalised2Charm, impactParameterNormalised2Charm, float); //! impact parameter of prong 2 divided by its uncertainty DECLARE_SOA_COLUMN(ImpactParameterProductCharm, impactParameterProductCharm, float); //! product of impact parameters of prong 0 and prong 1 DECLARE_SOA_COLUMN(MaxNormalisedDeltaIPCharm, maxNormalisedDeltaIPCharm, float); //! see RecoDecay::maxNormalisedDeltaIP +DECLARE_SOA_COLUMN(PxProng0Charm, pxProng0Charm, float); //! x-component of momentum of prong 0 +DECLARE_SOA_COLUMN(PyProng0Charm, pyProng0Charm, float); //! y-component of momentum of prong 0 +DECLARE_SOA_COLUMN(PzProng0Charm, pzProng0Charm, float); //! z-component of momentum of prong 0 +DECLARE_SOA_COLUMN(PxProng1Charm, pxProng1Charm, float); //! x-component of momentum of prong 1 +DECLARE_SOA_COLUMN(PyProng1Charm, pyProng1Charm, float); //! y-component of momentum of prong 1 +DECLARE_SOA_COLUMN(PzProng1Charm, pzProng1Charm, float); //! z-component of momentum of prong 1 DECLARE_SOA_COLUMN(PProng0Charm, pProng0Charm, float); //! momentum magnitude of prong 0 DECLARE_SOA_COLUMN(PProng1Charm, pProng1Charm, float); //! momentum magnitude of prong 1 DECLARE_SOA_COLUMN(PProng2Charm, pProng2Charm, float); //! momentum magnitude of prong 2 @@ -359,6 +436,7 @@ DECLARE_SOA_COLUMN(PtProng0Charm, ptProng0Charm, float); DECLARE_SOA_COLUMN(PtProng1Charm, ptProng1Charm, float); //! transverse momentum of prong 1 DECLARE_SOA_COLUMN(PtProng2Charm, ptProng2Charm, float); //! transverse momentum of prong 2 DECLARE_SOA_COLUMN(RSecondaryVertexCharm, rSecondaryVertexCharm, float); //! distance of the secondary vertex from the z axis +DECLARE_SOA_COLUMN(InvMassCharm, invMassCharm, float); //! mass of the charm daughter // TOF DECLARE_SOA_COLUMN(NSigTofKa0Charm, nSigTofKa0Charm, float); DECLARE_SOA_COLUMN(NSigTofKa1Charm, nSigTofKa1Charm, float); @@ -417,6 +495,10 @@ DECLARE_SOA_COLUMN(MlScoreNonPromptCharm, mlScoreNonPromptCharm, float); // DECLARE_SOA_COLUMN(MlScoresCharm, mlScoresCharm, std::vector); //! vector of ML scores } // namespace hf_cand_mc_charm +// ---------------- +// D0 +// ---------------- + // candidates for removal: // PxProng0, PyProng0, PzProng0,... (same for 1, 2), we can keep Pt, Eta, Phi instead // XY: CpaXY, DecayLengthXY, ErrorDecayLengthXY @@ -482,10 +564,10 @@ DECLARE_SOA_TABLE_STAGED(HfD0Mcs, "HFD0MC", //! Table with MC candidate info hf_cand_mc::OriginMcRec, o2::soa::Marker); -// candidates for removal: -// PxProng0, PyProng0, PzProng0,... (same for 1, 2), we can keep Pt, Eta, Phi instead -// XY: CpaXY, DecayLengthXY, ErrorDecayLengthXY -// normalised: DecayLengthNormalised, DecayLengthXYNormalised, ImpactParameterNormalised0 +// ---------------- +// B+ +// ---------------- + DECLARE_SOA_TABLE_STAGED(HfBplusPars, "HFBPPAR", //! Table with candidate properties used for selection hf_cand::Chi2PCA, hf_cand_par::Cpa, @@ -558,10 +640,96 @@ DECLARE_SOA_TABLE_STAGED(HfBplusMcs, "HFBPMC", //! Table with MC candidate info hf_cand_mc::OriginMcRec, o2::soa::Marker); -// candidates for removal: -// PxProng0, PyProng0, PzProng0,... (same for 1, 2), we can keep Pt, Eta, Phi instead -// XY: CpaXY, DecayLengthXY, ErrorDecayLengthXY -// normalised: DecayLengthNormalised, DecayLengthXYNormalised, ImpactParameterNormalised0 +// ---------------- +// B0 +// ---------------- + +DECLARE_SOA_TABLE_STAGED(HfB0Pars, "HFB0PAR", //! Table with candidate properties used for selection + hf_cand::Chi2PCA, + hf_cand_par::Cpa, + hf_cand_par::CpaXY, + hf_cand_par::DecayLength, + hf_cand_par::DecayLengthXY, + hf_cand_par::DecayLengthNormalised, + hf_cand_par::DecayLengthXYNormalised, + hf_cand_par::PtProng0, + hf_cand_par::PtProng1, + hf_cand::ImpactParameter0, + hf_cand::ImpactParameter1, + hf_cand_par::ImpactParameterNormalised0, + hf_cand_par::ImpactParameterNormalised1, + hf_cand_par::NSigTpcPiExpPi, + hf_cand_par::NSigTofPiExpPi, + hf_cand_par::NSigTpcTofPiExpPi, + hf_cand_par::NSigTpcKaExpPi, + hf_cand_par::NSigTofKaExpPi, + hf_cand_par::NSigTpcTofKaExpPi, + hf_cand_par::MaxNormalisedDeltaIP, + hf_cand_par::ImpactParameterProduct, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfB0ParDpluss, "HFB0PARDP", //! Table with D+ candidate properties used for selection of B0 + hf_cand_par_charm::Chi2PCACharm, + hf_cand_par_charm::NProngsContributorsPVCharm, + hf_cand_par_charm::CpaCharm, + hf_cand_par_charm::CpaXYCharm, + hf_cand_par_charm::DecayLengthCharm, + hf_cand_par_charm::DecayLengthXYCharm, + hf_cand_par_charm::DecayLengthNormalisedCharm, + hf_cand_par_charm::DecayLengthXYNormalisedCharm, + hf_cand_par_charm::PtProng0Charm, + hf_cand_par_charm::PtProng1Charm, + hf_cand_par_charm::PtProng2Charm, + hf_cand_par_charm::ImpactParameter0Charm, + hf_cand_par_charm::ImpactParameter1Charm, + hf_cand_par_charm::ImpactParameter2Charm, + hf_cand_par_charm::ImpactParameterNormalised0Charm, + hf_cand_par_charm::ImpactParameterNormalised1Charm, + hf_cand_par_charm::ImpactParameterNormalised2Charm, + hf_cand_par_charm::NSigTpcPi0Charm, + hf_cand_par_charm::NSigTofPi0Charm, + hf_cand_par_charm::NSigTpcTofPi0Charm, + hf_cand_par_charm::NSigTpcKa1Charm, + hf_cand_par_charm::NSigTofKa1Charm, + hf_cand_par_charm::NSigTpcTofKa1Charm, + hf_cand_par_charm::NSigTpcPi2Charm, + hf_cand_par_charm::NSigTofPi2Charm, + hf_cand_par_charm::NSigTpcTofPi2Charm, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfB0ParEs, "HFB0PARE", //! Table with additional candidate properties used for selection + hf_cand::XSecondaryVertex, + hf_cand::YSecondaryVertex, + hf_cand::ZSecondaryVertex, + hf_cand::ErrorDecayLength, + hf_cand::ErrorDecayLengthXY, + hf_cand_par::RSecondaryVertex, + hf_cand_par::PProng1, + hf_cand::PxProng1, + hf_cand::PyProng1, + hf_cand::PzProng1, + hf_cand::ErrorImpactParameter1, + hf_cand_par::CosThetaStar, + hf_cand_par::Ct, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfB0Mls, "HFB0ML", //! Table with candidate selection ML scores + hf_cand_mc::MlScoreSig, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfB0MlDpluss, "HFB0MLDP", //! Table with D+ candidate selection ML scores + hf_cand_mc_charm::MlScoresCharm, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfB0Mcs, "HFB0MC", //! Table with MC candidate info + hf_cand_mc::FlagMcMatchRec, + hf_cand_mc::OriginMcRec, + o2::soa::Marker); + +// ---------------- +// Lc +// ---------------- + DECLARE_SOA_TABLE_STAGED(HfLcPars, "HFLCPAR", //! Table with candidate properties used for selection hf_cand::Chi2PCA, hf_cand::NProngsContributorsPV, @@ -632,6 +800,286 @@ DECLARE_SOA_TABLE_STAGED(HfLcMcs, "HFLCMC", //! Table with MC candidate info hf_cand_mc::IsCandidateSwapped, o2::soa::Marker); +// ---------------- +// D+ +// ---------------- + +DECLARE_SOA_TABLE_STAGED(HfDplusPars, "HFDPPAR", //! Table with candidate properties used for selection + hf_cand::Chi2PCA, + hf_cand::NProngsContributorsPV, + hf_cand_par::Cpa, + hf_cand_par::CpaXY, + hf_cand_par::DecayLength, + hf_cand_par::DecayLengthXY, + hf_cand_par::DecayLengthNormalised, + hf_cand_par::DecayLengthXYNormalised, + hf_cand_par::PtProng0, + hf_cand_par::PtProng1, + hf_cand_par::PtProng2, + hf_cand::ImpactParameter0, + hf_cand::ImpactParameter1, + hf_cand::ImpactParameter2, + hf_cand_par::ImpactParameterNormalised0, + hf_cand_par::ImpactParameterNormalised1, + hf_cand_par::ImpactParameterNormalised2, + hf_cand_par::NSigTpcPi0, + hf_cand_par::NSigTofPi0, + hf_cand_par::NSigTpcTofPi0, + hf_cand_par::NSigTpcKa1, + hf_cand_par::NSigTofKa1, + hf_cand_par::NSigTpcTofKa1, + hf_cand_par::NSigTpcPi2, + hf_cand_par::NSigTofPi2, + hf_cand_par::NSigTpcTofPi2, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfDplusParEs, "HFDPPARE", //! Table with additional candidate properties used for selection + hf_cand::XSecondaryVertex, + hf_cand::YSecondaryVertex, + hf_cand::ZSecondaryVertex, + hf_cand::ErrorDecayLength, + hf_cand::ErrorDecayLengthXY, + hf_cand_par::RSecondaryVertex, + hf_cand_par::PProng0, + hf_cand_par::PProng1, + hf_cand_par::PProng2, + hf_cand::PxProng0, + hf_cand::PyProng0, + hf_cand::PzProng0, + hf_cand::PxProng1, + hf_cand::PyProng1, + hf_cand::PzProng1, + hf_cand::PxProng2, + hf_cand::PyProng2, + hf_cand::PzProng2, + hf_cand::ErrorImpactParameter0, + hf_cand::ErrorImpactParameter1, + hf_cand::ErrorImpactParameter2, + hf_cand_par::Ct, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfDplusMls, "HFDPML", //! Table with candidate selection ML scores + hf_cand_mc::MlScores, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfDplusMcs, "HFDPMC", //! Table with MC candidate info + hf_cand_mc::FlagMcMatchRec, + hf_cand_mc::OriginMcRec, + hf_cand_mc::IsCandidateSwapped, // useless + hf_cand_mc::FlagMcDecayChanRec, + o2::soa::Marker); + +// ---------------- +// Ds+ +// ---------------- + +DECLARE_SOA_TABLE_STAGED(HfDsPars, "HFDSPAR", //! Table with candidate properties used for selection + hf_cand::Chi2PCA, + hf_cand::NProngsContributorsPV, + hf_cand_par::Cpa, + hf_cand_par::CpaXY, + hf_cand_par::DecayLength, + hf_cand_par::DecayLengthXY, + hf_cand_par::DecayLengthNormalised, + hf_cand_par::DecayLengthXYNormalised, + hf_cand_par::PtProng0, + hf_cand_par::PtProng1, + hf_cand_par::PtProng2, + hf_cand::ImpactParameter0, + hf_cand::ImpactParameter1, + hf_cand::ImpactParameter2, + hf_cand_par::ImpactParameterNormalised0, + hf_cand_par::ImpactParameterNormalised1, + hf_cand_par::ImpactParameterNormalised2, + hf_cand_par::NSigTpcPi0, + hf_cand_par::NSigTpcKa0, + hf_cand_par::NSigTofPi0, + hf_cand_par::NSigTofKa0, + hf_cand_par::NSigTpcTofPi0, + hf_cand_par::NSigTpcTofKa0, + hf_cand_par::NSigTpcKa1, + hf_cand_par::NSigTofKa1, + hf_cand_par::NSigTpcTofKa1, + hf_cand_par::NSigTpcPi2, + hf_cand_par::NSigTpcKa2, + hf_cand_par::NSigTofPi2, + hf_cand_par::NSigTofKa2, + hf_cand_par::NSigTpcTofPi2, + hf_cand_par::NSigTpcTofKa2, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfDsParEs, "HFDSPARE", //! Table with additional candidate properties used for selection + hf_cand::XSecondaryVertex, + hf_cand::YSecondaryVertex, + hf_cand::ZSecondaryVertex, + hf_cand::ErrorDecayLength, + hf_cand::ErrorDecayLengthXY, + hf_cand_par::RSecondaryVertex, + hf_cand_par::PProng0, + hf_cand_par::PProng1, + hf_cand_par::PProng2, + hf_cand::PxProng0, + hf_cand::PyProng0, + hf_cand::PzProng0, + hf_cand::PxProng1, + hf_cand::PyProng1, + hf_cand::PzProng1, + hf_cand::PxProng2, + hf_cand::PyProng2, + hf_cand::PzProng2, + hf_cand::ErrorImpactParameter0, + hf_cand::ErrorImpactParameter1, + hf_cand::ErrorImpactParameter2, + hf_cand_par::Ct, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfDsMls, "HFDSML", //! Table with candidate selection ML scores + hf_cand_mc::MlScores, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfDsMcs, "HFDSMC", //! Table with MC candidate info + hf_cand_mc::FlagMcMatchRec, + hf_cand_mc::OriginMcRec, + hf_cand_mc::IsCandidateSwapped, + hf_cand_mc::FlagMcDecayChanRec, + o2::soa::Marker); + +// ---------------- +// D*+ +// ---------------- + +DECLARE_SOA_TABLE_STAGED(HfDstarPars, "HFDSTPAR", //! Table with candidate properties used for selection + hf_cand::PxProng0, // Prong0 is the D0 + hf_cand::PyProng0, + hf_cand::PzProng0, + hf_cand::PxProng1, // Prong1 is the soft pion + hf_cand::PyProng1, + hf_cand::PzProng1, + hf_cand::PtProng1, + hf_cand_par::SignProng1, + hf_cand::PtProng0, + hf_cand::ImpactParameter1, + hf_cand_par::ImpactParameterNormalised1, + hf_cand_par::NSigTpcPi1, + hf_cand_par::NSigTofPi1, + hf_cand_par::NSigTpcTofPi1, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfDstarParD0s, "HFDSTPARD0", //! Table with candidate properties used for selection + hf_cand_par_charm::Chi2PCACharm, + hf_cand_par_charm::CpaCharm, + hf_cand_par_charm::CpaXYCharm, + hf_cand_par_charm::DecayLengthCharm, + hf_cand_par_charm::DecayLengthXYCharm, + hf_cand_par_charm::DecayLengthNormalisedCharm, + hf_cand_par_charm::DecayLengthXYNormalisedCharm, + hf_cand_par_charm::PxProng0Charm, // prong0 is the first D0 daughter + hf_cand_par_charm::PyProng0Charm, + hf_cand_par_charm::PzProng0Charm, + hf_cand_par_charm::PxProng1Charm, // prong 1 is the second D0 daughter + hf_cand_par_charm::PyProng1Charm, + hf_cand_par_charm::PzProng1Charm, + hf_cand_par_charm::InvMassCharm, + hf_cand_par_charm::ImpactParameter0Charm, + hf_cand_par_charm::ImpactParameter1Charm, + hf_cand_par_charm::ImpactParameterNormalised0Charm, + hf_cand_par_charm::ImpactParameterNormalised1Charm, + hf_cand_par_charm::NSigTpcPi0Charm, + hf_cand_par_charm::NSigTofPi0Charm, + hf_cand_par_charm::NSigTpcTofPi0Charm, + hf_cand_par_charm::NSigTpcKa0Charm, + hf_cand_par_charm::NSigTofKa0Charm, + hf_cand_par_charm::NSigTpcTofKa0Charm, + hf_cand_par_charm::NSigTpcPi1Charm, + hf_cand_par_charm::NSigTofPi1Charm, + hf_cand_par_charm::NSigTpcTofPi1Charm, + hf_cand_par_charm::NSigTpcKa1Charm, + hf_cand_par_charm::NSigTofKa1Charm, + hf_cand_par_charm::NSigTpcTofKa1Charm, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfDstarMls, "HFDSTML", //! Table with candidate selection ML scores + hf_cand_mc::MlScores, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfDstarMcs, "HFDSTMC", //! Table with MC candidate info + hf_cand_mc::FlagMcMatchRec, + hf_cand_mc_charm::FlagMcMatchRecCharm, + hf_cand_mc::OriginMcRec, + hf_cand::PtBhadMotherPart, + hf_cand::PdgBhadMotherPart, + hf_cand::NTracksDecayed, + o2::soa::Marker); + +// ---------------- +// Ξc± → (Ξ∓ → (Λ → p π∓) π∓) π± π± +// ---------------- + +DECLARE_SOA_TABLE_STAGED(HfXicToXiPiPiPars, "HFXICXPPPAR", //! Table with candidate properties used for selection + hf_cand_xic_to_xi_pi_pi::Sign, + hf_cand_par::PtProngXi, + hf_cand_par::PtProngPi0, + hf_cand_par::PtProngPi1, + hf_cand_xic_to_xi_pi_pi::InvMassXi, + hf_cand_xic_to_xi_pi_pi::InvMassLambda, + hf_cand_xic_to_xi_pi_pi::InvMassXiPi0, + hf_cand_xic_to_xi_pi_pi::InvMassXiPi1, + hf_cand::Chi2PCA, + hf_cand_par::Ct, + hf_cand_par::DecayLength, + hf_cand_par::DecayLengthNormalised, + hf_cand_par::DecayLengthXY, + hf_cand_par::DecayLengthXYNormalised, + hf_cand_par::Cpa, + hf_cand_par::CpaXY, + hf_cand_xic_to_xi_pi_pi::CpaXi, + hf_cand_xic_to_xi_pi_pi::CpaXYXi, + hf_cand_xic_to_xi_pi_pi::CpaLambda, + hf_cand_xic_to_xi_pi_pi::CpaXYLambda, + hf_cand_par::ImpactParameterXi, + hf_cand_par::ImpactParameterNormalisedXi, + hf_cand_par::ImpactParameterPi0, + hf_cand_par::ImpactParameterNormalisedPi0, + hf_cand_par::ImpactParameterPi1, + hf_cand_par::ImpactParameterNormalisedPi1, + hf_cand_par::MaxNormalisedDeltaIP, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfXicToXiPiPiParEs, "HFXICXPPPARE", //! Table with additional candidate properties used for selection + hf_cand_xic_to_xi_pi_pi::CpaLambdaToXi, + hf_cand_xic_to_xi_pi_pi::CpaXYLambdaToXi, + hf_cand_par::PProngPi0, + hf_cand_par::PProngPi1, + hf_cand_xic_to_xi_pi_pi::PBachelorPi, + hf_cand_xic_to_xi_pi_pi::PPiFromLambda, + hf_cand_xic_to_xi_pi_pi::PPrFromLambda, + hf_cand_xic_to_xi_pi_pi::DcaXiDaughters, + hf_cand_xic_to_xi_pi_pi::DcaV0Daughters, + hf_cand_xic_to_xi_pi_pi::DcaPosToPV, + hf_cand_xic_to_xi_pi_pi::DcaNegToPV, + hf_cand_xic_to_xi_pi_pi::DcaBachelorToPV, + hf_cand_xic_to_xi_pi_pi::DcaXYCascToPV, + hf_cand_xic_to_xi_pi_pi::DcaZCascToPV, + hf_cand_xic_to_xi_pi_pi::NSigTpcPiFromXicPlus0, + hf_cand_xic_to_xi_pi_pi::NSigTpcPiFromXicPlus1, + hf_cand_xic_to_xi_pi_pi::NSigTpcBachelorPi, + hf_cand_xic_to_xi_pi_pi::NSigTpcPiFromLambda, + hf_cand_xic_to_xi_pi_pi::NSigTpcPrFromLambda, + hf_cand_xic_to_xi_pi_pi::NSigTofPiFromXicPlus0, + hf_cand_xic_to_xi_pi_pi::NSigTofPiFromXicPlus1, + hf_cand_xic_to_xi_pi_pi::NSigTofBachelorPi, + hf_cand_xic_to_xi_pi_pi::NSigTofPiFromLambda, + hf_cand_xic_to_xi_pi_pi::NSigTofPrFromLambda, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfXicToXiPiPiMls, "HFXICXPPML", //! Table with candidate selection ML scores + hf_cand_mc::MlScores, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfXicToXiPiPiMcs, "HFXICXPPMC", //! Table with MC candidate info + hf_cand_mc::FlagMcMatchRec, + hf_cand_mc::OriginMcRec, + o2::soa::Marker); } // namespace o2::aod #endif // PWGHF_DATAMODEL_DERIVEDTABLES_H_ diff --git a/PWGHF/HFC/DataModel/CorrelationTables.h b/PWGHF/HFC/DataModel/CorrelationTables.h index da784114ce9..a77035b7f3f 100644 --- a/PWGHF/HFC/DataModel/CorrelationTables.h +++ b/PWGHF/HFC/DataModel/CorrelationTables.h @@ -16,12 +16,15 @@ #ifndef PWGHF_HFC_DATAMODEL_CORRELATIONTABLES_H_ #define PWGHF_HFC_DATAMODEL_CORRELATIONTABLES_H_ -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" // IWYU pragma: keep #include "Common/Core/RecoDecay.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include +#include +#include + +#include namespace o2::aod { @@ -51,21 +54,27 @@ DECLARE_SOA_TABLE(DDbarRecoInfo, "AOD", "DDBARRECOINFO", // definition of columns and tables for D0-Hadron correlation pairs namespace hf_correlation_d0_hadron { -DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between D0 and Hadrons -DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between D0 and Hadrons -DECLARE_SOA_COLUMN(PtD, ptD, float); //! Transverse momentum of D0 -DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! Transverse momentum of Hadron -DECLARE_SOA_COLUMN(MD, mD, float); //! Invariant mass of D0 -DECLARE_SOA_COLUMN(MDbar, mDbar, float); //! Invariant mass of D0bar -DECLARE_SOA_COLUMN(MlScoreBkgD0, mlScoreBkgD0, float); //! ML background score for D0 selection -DECLARE_SOA_COLUMN(MlScoreNonPromptD0, mlScoreNonPromptD0, float); //! ML prompt score for D0 selection -DECLARE_SOA_COLUMN(MlScorePromptD0, mlScorePromptD0, float); //! ML prompt score for D0 selection -DECLARE_SOA_COLUMN(MlScoreBkgD0bar, mlScoreBkgD0bar, float); //! ML background score for D0 selection -DECLARE_SOA_COLUMN(MlScoreNonPromptD0bar, mlScoreNonPromptD0bar, float); //! ML prompt score for D0 selection -DECLARE_SOA_COLUMN(MlScorePromptD0bar, mlScorePromptD0bar, float); //! ML prompt score for D0 selection -DECLARE_SOA_COLUMN(SignalStatus, signalStatus, int); //! Tag for D0,D0bar -DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent -DECLARE_SOA_COLUMN(IsAutoCorrelated, isAutoCorrelated, bool); //! Correlation Status +DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between D0 and Hadrons +DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between D0 and Hadrons +DECLARE_SOA_COLUMN(PtD, ptD, float); //! Transverse momentum of D0 +DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! Transverse momentum of Hadron +DECLARE_SOA_COLUMN(MD, mD, float); //! Invariant mass of D0 +DECLARE_SOA_COLUMN(MDbar, mDbar, float); //! Invariant mass of D0bar +DECLARE_SOA_COLUMN(MlScoreBkgD0, mlScoreBkgD0, float); //! ML background score for D0 selection +DECLARE_SOA_COLUMN(MlScoreNonPromptD0, mlScoreNonPromptD0, float); //! ML prompt score for D0 selection +DECLARE_SOA_COLUMN(MlScorePromptD0, mlScorePromptD0, float); //! ML prompt score for D0 selection +DECLARE_SOA_COLUMN(MlScoreBkgD0bar, mlScoreBkgD0bar, float); //! ML background score for D0 selection +DECLARE_SOA_COLUMN(MlScoreNonPromptD0bar, mlScoreNonPromptD0bar, float); //! ML prompt score for D0 selection +DECLARE_SOA_COLUMN(MlScorePromptD0bar, mlScorePromptD0bar, float); //! ML prompt score for D0 selection +DECLARE_SOA_COLUMN(SignalStatus, signalStatus, int); //! Tag for D0,D0bar +DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent +DECLARE_SOA_COLUMN(TrackDcaXY, trackDcaXY, float); //! DCA xy of the track +DECLARE_SOA_COLUMN(TrackDcaZ, trackDcaZ, float); //! DCA z of the track +DECLARE_SOA_COLUMN(TrackTPCNClsCrossedRows, trackTPCNClsCrossedRows, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(IsAutoCorrelated, isAutoCorrelated, bool); //! Correlation Status +DECLARE_SOA_COLUMN(TrackOrigin, trackOrigin, int); //! Check track origin +DECLARE_SOA_COLUMN(IsPrompt, isPrompt, bool); //! Used in MC-Rec, D0 Prompt or Non-Prompt +DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); //! Used in MC-Rec, primary associated particles enum ParticleTypeData { D0Only = 1, // Identified as D0 @@ -100,6 +109,11 @@ DECLARE_SOA_TABLE(D0HadronRecoInfo, "AOD", "D0HRECOINFO", //! D0-Hadrons pairs R aod::hf_correlation_d0_hadron::MDbar, aod::hf_correlation_d0_hadron::SignalStatus); +DECLARE_SOA_TABLE(D0HadronGenInfo, "AOD", "D0HGENINFO", //! D0-Hadrons pairs Generated Information + aod::hf_correlation_d0_hadron::IsPrompt, + aod::hf_correlation_d0_hadron::IsPhysicalPrimary, + aod::hf_correlation_d0_hadron::TrackOrigin); + DECLARE_SOA_TABLE(D0HadronMlInfo, "AOD", "D0HMLINFO", //! D0-Hadrons pairs Machine Learning Information aod::hf_correlation_d0_hadron::MlScoreBkgD0, aod::hf_correlation_d0_hadron::MlScoreNonPromptD0, @@ -117,13 +131,23 @@ DECLARE_SOA_TABLE(D0CandRecoInfo, "AOD", "D0CANDRECOINFO", //! Ds candidates Rec aod::hf_correlation_d0_hadron::MlScoreBkgD0bar, aod::hf_correlation_d0_hadron::MlScorePromptD0bar); +DECLARE_SOA_TABLE(D0CandGenInfo, "AOD", "D0CANDGENOINFO", //! Ds candidates Generated Information + aod::hf_correlation_d0_hadron::IsPrompt); + +DECLARE_SOA_TABLE(D0TrackRecoInfo, "AOD", "D0TRACKRECOINFO", //! Tracks Reconstructed Information + aod::hf_correlation_d0_hadron::TrackDcaXY, + aod::hf_correlation_d0_hadron::TrackDcaZ, + aod::hf_correlation_d0_hadron::TrackTPCNClsCrossedRows); + // Note: definition of columns and tables for Lc-Hadron correlation pairs namespace hf_correlation_lc_hadron { DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between Lc and Hadrons DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between Lc and Hadrons +DECLARE_SOA_COLUMN(DeltaY, deltaY, float); //! DeltaY between Lc and Hadrons DECLARE_SOA_COLUMN(PtLc, ptLc, float); //! Transverse momentum of Lc DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! Transverse momentum of Hadron +DECLARE_SOA_COLUMN(ChargeCand, chargeCand, int); //! store charge of Lc and Sc DECLARE_SOA_COLUMN(MLc, mLc, float); //! Invariant mass of Lc DECLARE_SOA_COLUMN(MlScoreBkg, mlScoreBkg, float); //! ML background score for Lc selection DECLARE_SOA_COLUMN(MlScorePrompt, mlScorePrompt, float); //! ML prompt score for Lc selection @@ -163,6 +187,13 @@ DECLARE_SOA_TABLE(LcHadronPairTrkPID, "AOD", "LCHPAIRPID", //! Lc-proton details aod::hf_correlation_lc_hadron::PrNsigmTOF, aod::hf_correlation_lc_hadron::KaNsigmTOF, aod::hf_correlation_lc_hadron::PiNsigmTOF); +DECLARE_SOA_TABLE(LcHadronTrkPID, "AOD", "LCHTRKPID", //! Lc-proton details + aod::hf_correlation_lc_hadron::PrNsigmTPC, + aod::hf_correlation_lc_hadron::KaNsigmTPC, + aod::hf_correlation_lc_hadron::PiNsigmTPC, + aod::hf_correlation_lc_hadron::PrNsigmTOF, + aod::hf_correlation_lc_hadron::KaNsigmTOF, + aod::hf_correlation_lc_hadron::PiNsigmTOF); DECLARE_SOA_TABLE(LcHadronGenInfo, "AOD", "LCHGENINFO", //! Lc-Hadrons pairs Generated Information aod::hf_correlation_lc_hadron::IsPrompt, @@ -187,6 +218,13 @@ DECLARE_SOA_TABLE(TrkRecInfoLc, "AOD", "TRKRECINFOLC", //! Tracks Reconstructed aod::hf_correlation_lc_hadron::TrackDcaZ, aod::hf_correlation_lc_hadron::TrackTPCNClsCrossedRows); +DECLARE_SOA_TABLE(LcHadronPairY, "AOD", "LCHPAIRY", + aod::hf_correlation_lc_hadron::DeltaY); +DECLARE_SOA_TABLE(CandChargePair, "AOD", "CANDCHARGEPAIR", + aod::hf_correlation_lc_hadron::ChargeCand); +DECLARE_SOA_TABLE(CandCharge, "AOD", "CANDCHARGE", + aod::hf_correlation_lc_hadron::ChargeCand); + // definition of columns and tables for Ds-Hadron correlation pairs namespace hf_correlation_ds_hadron { @@ -314,6 +352,7 @@ DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! T DECLARE_SOA_COLUMN(MD, mD, float); //! Invariant mass of D+ DECLARE_SOA_COLUMN(MlScoreBkg, mlScoreBkg, float); //! ML background score for D+ selection DECLARE_SOA_COLUMN(MlScorePrompt, mlScorePrompt, float); //! ML prompt score for D+ selection +DECLARE_SOA_COLUMN(MlScoreNonPrompt, mlScoreNonPrompt, float); //! ML non-prompt score for D+ selection DECLARE_SOA_COLUMN(SignalStatus, signalStatus, bool); //! Used in MC-Rec, D+ Signal DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin of event defined using zvtx and multiplicity DECLARE_SOA_COLUMN(TrackDcaXY, trackDcaXY, float); //! DCA xy of the track @@ -344,13 +383,15 @@ DECLARE_SOA_TABLE(DplusHadronGenInfo, "AOD", "DPLUSHGENINFO", //! Ds-Hadrons pai DECLARE_SOA_TABLE(DplusHadronMlInfo, "AOD", "DPLUSHMLINFO", //! D+-Hadrons pairs Machine Learning Information aod::hf_correlation_dplus_hadron::MlScoreBkg, - aod::hf_correlation_dplus_hadron::MlScorePrompt); + aod::hf_correlation_dplus_hadron::MlScorePrompt, + aod::hf_correlation_dplus_hadron::MlScoreNonPrompt); DECLARE_SOA_TABLE(DplusRecoInfo, "AOD", "DPLUSRECOINFO", //! D+ candidates Reconstructed Information aod::hf_correlation_dplus_hadron::MD, aod::hf_correlation_dplus_hadron::PtD, aod::hf_correlation_dplus_hadron::MlScoreBkg, - aod::hf_correlation_dplus_hadron::MlScorePrompt); + aod::hf_correlation_dplus_hadron::MlScorePrompt, + aod::hf_correlation_dplus_hadron::MlScoreNonPrompt); DECLARE_SOA_TABLE(DplusGenInfo, "AOD", "DPLUSGENOINFO", //! D+ candidates Generated Information aod::hf_correlation_dplus_hadron::IsPrompt); @@ -442,6 +483,29 @@ DECLARE_SOA_TABLE(DmesonSelection, "AOD", "DINCOLL", // Selection of D meson in aod::hf_selection_dmeson_collision::DmesonSel); // Note: definition of columns and tables for Electron Hadron correlation pairs +namespace hf_electron +{ +DECLARE_SOA_COLUMN(PhiElectron, phiElectron, float); //! Phi of electron +DECLARE_SOA_COLUMN(EtaElectron, etaElectron, float); //! Eta of electron +DECLARE_SOA_COLUMN(PtElectron, ptElectron, float); //! Transverse momentum of electron +DECLARE_SOA_COLUMN(NElectronsLS, nElectronsLS, int); //! number of like-sign +DECLARE_SOA_COLUMN(NElectronsUS, nElectronsUS, int); //! number of Unlike-sign +DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin of event defined using zvtx and multiplicit +DECLARE_SOA_COLUMN(GIndexCol, gIndexCol, int); //! Global index for the collision +DECLARE_SOA_COLUMN(TimeStamp, timeStamp, int64_t); //! Timestamp for the collision + +} // namespace hf_electron + +DECLARE_SOA_TABLE(HfElectron, "AOD", "HFELECTRON", //! Hf Electron properties + aod::hf_electron::PhiElectron, + aod::hf_electron::EtaElectron, + aod::hf_electron::PtElectron, + aod::hf_electron::NElectronsLS, + aod::hf_electron::NElectronsUS, + aod::hf_electron::PoolBin, + aod::hf_electron::GIndexCol, + aod::hf_electron::TimeStamp); + namespace hf_correlation_electron_hadron { DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between Electron and Hadrons @@ -449,13 +513,36 @@ DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between Electron DECLARE_SOA_COLUMN(PtElectron, ptElectron, float); //! Transverse momentum of Electron DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! Transverse momentum of Hadron; DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin of event defined using zvtx and multiplicity +DECLARE_SOA_COLUMN(NPairsLS, nPairsLS, int); //! number of like-sign electron-hadron pairs +DECLARE_SOA_COLUMN(NPairsUS, nPairsUS, int); //! number of unlike-sign electron-hadron pairs } // namespace hf_correlation_electron_hadron DECLARE_SOA_TABLE(HfEHadronPair, "AOD", "HFEHADRONPAIR", //! Hfe-Hadrons pairs Informations hf_correlation_electron_hadron::DeltaPhi, hf_correlation_electron_hadron::DeltaEta, hf_correlation_electron_hadron::PtElectron, hf_correlation_electron_hadron::PtHadron, - hf_correlation_electron_hadron::PoolBin); + hf_correlation_electron_hadron::PoolBin, + hf_correlation_electron_hadron::NPairsLS, + hf_correlation_electron_hadron::NPairsUS); + +// Note: definition of columns and tables for Electron Hadron correlation pairs for MC Gen +namespace hf_correlation_mcgenelectron_hadron +{ +DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between Electron and Hadrons +DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between Electron and Hadrons +DECLARE_SOA_COLUMN(PtElectron, ptElectron, float); //! Transverse momentum of Electron +DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! Transverse momentum of Hadron; +DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin of event defined using zvtx and multiplicity +DECLARE_SOA_COLUMN(IsNonHfEHCorr, isNonHfEHCorr, int); //! nonHeavy Flavour Electron hadron coorelation + +} // namespace hf_correlation_mcgenelectron_hadron +DECLARE_SOA_TABLE(HfEHadronMcPair, "AOD", "HFEHADRONMCPAIR", //! Hfe-Hadrons pairs Informations + hf_correlation_mcgenelectron_hadron::DeltaPhi, + hf_correlation_mcgenelectron_hadron::DeltaEta, + hf_correlation_mcgenelectron_hadron::PtElectron, + hf_correlation_mcgenelectron_hadron::PtHadron, + hf_correlation_mcgenelectron_hadron::PoolBin, + hf_correlation_mcgenelectron_hadron::IsNonHfEHCorr); } // namespace o2::aod #endif // PWGHF_HFC_DATAMODEL_CORRELATIONTABLES_H_ diff --git a/PWGHF/HFC/DataModel/DMesonPairsTables.h b/PWGHF/HFC/DataModel/DMesonPairsTables.h index bb149169d19..35e12760919 100644 --- a/PWGHF/HFC/DataModel/DMesonPairsTables.h +++ b/PWGHF/HFC/DataModel/DMesonPairsTables.h @@ -17,7 +17,10 @@ #ifndef PWGHF_HFC_DATAMODEL_DMESONPAIRSTABLES_H_ #define PWGHF_HFC_DATAMODEL_DMESONPAIRSTABLES_H_ -#include "Framework/AnalysisDataModel.h" +#include + +#include +#include namespace o2::aod { @@ -25,10 +28,12 @@ namespace o2::aod namespace hf_correlation_d_meson_pair { // Kinematic info -DECLARE_SOA_COLUMN(PtCand1, ptCand1, float); //! Transverse momentum of first candidate -DECLARE_SOA_COLUMN(PtCand2, ptCand2, float); //! Transverse momentum of second candidate -DECLARE_SOA_COLUMN(YCand1, yCand1, float); //! Rapidity of first candidate -DECLARE_SOA_COLUMN(YCand2, yCand2, float); //! Rapidity of second candidate +DECLARE_SOA_COLUMN(PtCand1, ptCand1, float); //! Transverse momentum of first candidate +DECLARE_SOA_COLUMN(PtCand2, ptCand2, float); //! Transverse momentum of second candidate +DECLARE_SOA_COLUMN(YCand1, yCand1, float); //! Rapidity of first candidate +DECLARE_SOA_COLUMN(YCand2, yCand2, float); //! Rapidity of second candidate +DECLARE_SOA_COLUMN(PhiCand1, phiCand1, float); //! Azimuthal angle of first candidate +DECLARE_SOA_COLUMN(PhiCand2, phiCand2, float); //! Azimuthal angle of second candidate // Invariant mass DECLARE_SOA_COLUMN(MDCand1, mDCand1, float); //! Invariant mass of first candidate as D DECLARE_SOA_COLUMN(MDbarCand1, mDbarCand1, float); //! Invariant mass of first candidate as Dbar @@ -42,6 +47,11 @@ DECLARE_SOA_COLUMN(Origin1, origin1, uint8_t); //! candidate 1 origin DECLARE_SOA_COLUMN(Origin2, origin2, uint8_t); //! candidate 2 origin DECLARE_SOA_COLUMN(MatchedMc1, matchedMc1, uint8_t); //! MC matching of candidate 1 DECLARE_SOA_COLUMN(MatchedMc2, matchedMc2, uint8_t); //! MC matching of candidate 2 +// ML info +DECLARE_SOA_COLUMN(MlProbD0Cand1, mlProbD0Cand1, std::vector); //! +DECLARE_SOA_COLUMN(MlProbD0barCand1, mlProbD0barCand1, std::vector); //! +DECLARE_SOA_COLUMN(MlProbD0Cand2, mlProbD0Cand2, std::vector); //! +DECLARE_SOA_COLUMN(MlProbD0barCand2, mlProbD0barCand2, std::vector); //! } // namespace hf_correlation_d_meson_pair // Definition of the D meson pair table. Contains the info needed at Data level. @@ -51,6 +61,8 @@ DECLARE_SOA_COLUMN(MatchedMc2, matchedMc2, uint8_t); //! MC matching of candidat hf_correlation_d_meson_pair::PtCand2, \ hf_correlation_d_meson_pair::YCand1, \ hf_correlation_d_meson_pair::YCand2, \ + hf_correlation_d_meson_pair::PhiCand1, \ + hf_correlation_d_meson_pair::PhiCand2, \ hf_correlation_d_meson_pair::MDCand1, \ hf_correlation_d_meson_pair::MDbarCand1, \ hf_correlation_d_meson_pair::MDCand2, \ @@ -65,10 +77,18 @@ DECLARE_SOA_COLUMN(MatchedMc2, matchedMc2, uint8_t); //! MC matching of candidat hf_correlation_d_meson_pair::Origin2, \ hf_correlation_d_meson_pair::MatchedMc1, \ hf_correlation_d_meson_pair::MatchedMc2); +// Definition of the table with the ML info of the D meson pair. +#define DECLARE_DMESON_PAIR_MLINFO_TABLE(_pair_type_, _marker_value_, _description_) \ + DECLARE_SOA_TABLE(_pair_type_, "AOD", _description_ "ML", o2::soa::Marker<_marker_value_>, \ + hf_correlation_d_meson_pair::MlProbD0Cand1, \ + hf_correlation_d_meson_pair::MlProbD0barCand1, \ + hf_correlation_d_meson_pair::MlProbD0Cand2, \ + hf_correlation_d_meson_pair::MlProbD0barCand2); // Creation of tables with D Meson Pairs info DECLARE_DMESON_PAIR_TABLE(D0Pair, 1, "D0PAIR"); //! D0 pairs Info DECLARE_DMESON_PAIR_MCINFO_TABLE(D0PairMcInfo, 1, "D0PAIR"); //! D0 pairs MC Rec Info +DECLARE_DMESON_PAIR_MLINFO_TABLE(D0PairMl, 1, "D0PAIR"); //! D0 pairs ML Info DECLARE_DMESON_PAIR_TABLE(D0PairMcGen, 2, "D0PAIRGEN"); //! D0 pairs MC Gen Kinematic Info DECLARE_DMESON_PAIR_MCINFO_TABLE(D0PairMcGenInfo, 2, "D0PAIRGEN"); //! D0 pairs MC Gen Info diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h index 8bd3815df00..39a3231977c 100644 --- a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -9,19 +9,20 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file DerivedDataCorrelations.h +/// \file DerivedDataCorrelationTables.h /// \brief Tables for producing derived data for correlation analysis /// \author Samuele Cattaruzzi #ifndef PWGHF_HFC_DATAMODEL_DERIVEDDATACORRELATIONTABLES_H_ #define PWGHF_HFC_DATAMODEL_DERIVEDDATACORRELATIONTABLES_H_ -#include "Framework/AnalysisDataModel.h" +#include namespace o2::aod { namespace hf_collisions_reduced { +DECLARE_SOA_COLUMN(NumPvContrib, numPvContrib, int); //! Event multiplicity from PV contributors DECLARE_SOA_COLUMN(Multiplicity, multiplicity, float); //! Event multiplicity DECLARE_SOA_COLUMN(PosZ, posZ, float); //! Primary vertex z position @@ -30,6 +31,7 @@ DECLARE_SOA_COLUMN(PosZ, posZ, float); //! Primary vertex z posi DECLARE_SOA_TABLE(HfcRedCollisions, "AOD", "HFCREDCOLLISION", //! Table with collision info soa::Index<>, aod::hf_collisions_reduced::Multiplicity, + aod::hf_collisions_reduced::NumPvContrib, aod::hf_collisions_reduced::PosZ); using HfcRedCollision = HfcRedCollisions::iterator; @@ -40,32 +42,61 @@ using HfcRedCollision = HfcRedCollisions::iterator; namespace hf_candidate_reduced { DECLARE_SOA_INDEX_COLUMN(HfcRedCollision, hfcRedCollision); //! ReducedCollision index -DECLARE_SOA_COLUMN(PhiCand, phiCand, float); //! Phi of the candidate -DECLARE_SOA_COLUMN(EtaCand, etaCand, float); //! Eta of the candidate -DECLARE_SOA_COLUMN(PtCand, ptCand, float); //! Pt of the candidate -DECLARE_SOA_COLUMN(InvMassDs, invMassDs, float); //! Invariant mass of Ds candidate +DECLARE_SOA_COLUMN(Prong0Id, prong0Id, int); //! Prong 0 index +DECLARE_SOA_COLUMN(Prong1Id, prong1Id, int); //! Prong 1 index +DECLARE_SOA_COLUMN(Prong2Id, prong2Id, int); //! Prong2 index +DECLARE_SOA_COLUMN(PhiCand, phiCand, float); //! Phi of the candidate +DECLARE_SOA_COLUMN(EtaCand, etaCand, float); //! Eta of the candidate +DECLARE_SOA_COLUMN(PtCand, ptCand, float); //! Pt of the candidate +DECLARE_SOA_COLUMN(InvMassDs, invMassDs, float); //! Invariant mass of Ds candidate +DECLARE_SOA_COLUMN(BdtScorePrompt, bdtScorePrompt, float); //! BDT output score for prompt hypothesis +DECLARE_SOA_COLUMN(BdtScoreBkg, bdtScoreBkg, float); //! BDT output score for backgronud hypothesis } // namespace hf_candidate_reduced -DECLARE_SOA_TABLE(DsCandReduceds, "AOD", "DSCANDREDUCED", //! Table with Ds candidate info (rectangular selection) +DECLARE_SOA_TABLE(DsCandReduceds, "AOD", "DSCANDREDUCED", //! Table with Ds candidate info soa::Index<>, aod::hf_candidate_reduced::HfcRedCollisionId, aod::hf_candidate_reduced::PhiCand, aod::hf_candidate_reduced::EtaCand, aod::hf_candidate_reduced::PtCand, - aod::hf_candidate_reduced::InvMassDs); + aod::hf_candidate_reduced::InvMassDs, + aod::hf_candidate_reduced::Prong0Id, + aod::hf_candidate_reduced::Prong1Id, + aod::hf_candidate_reduced::Prong2Id); + +DECLARE_SOA_TABLE(DsCandSelInfos, "AOD", "DSCANDSELINFO", //! Table with Ds candidate selection info + soa::Index<>, + aod::hf_candidate_reduced::HfcRedCollisionId, + aod::hf_candidate_reduced::BdtScorePrompt, + aod::hf_candidate_reduced::BdtScoreBkg); namespace hf_assoc_track_reduced { -DECLARE_SOA_COLUMN(TrackId, trackId, int); //! Original track index -DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track -DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track -DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(OriginTrackId, originTrackId, int); //! Original track index +DECLARE_SOA_COLUMN(NTpcCrossedRows, nTpcCrossedRows, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(ItsClusterMap, itsClusterMap, int); //! ITS cluster map, one bit per a layer, starting from the innermost +DECLARE_SOA_COLUMN(ItsNCls, itsNCls, int); //! Number of ITS clusters +DECLARE_SOA_COLUMN(EtaAssocTrack, etaAssocTrack, float); //! Eta of the track +DECLARE_SOA_COLUMN(PhiAssocTrack, phiAssocTrack, float); //! Phi of the track +DECLARE_SOA_COLUMN(PtAssocTrack, ptAssocTrack, float); //! Pt of the track +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //! Impact parameter in XY of the track to the primary vertex +DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //! Impact parameter in Z of the track to the primary vertex } // namespace hf_assoc_track_reduced DECLARE_SOA_TABLE(AssocTrackReds, "AOD", "ASSOCTRACKRED", //! Table with associated track info soa::Index<>, aod::hf_candidate_reduced::HfcRedCollisionId, + aod::hf_assoc_track_reduced::OriginTrackId, aod::hf_assoc_track_reduced::PhiAssocTrack, aod::hf_assoc_track_reduced::EtaAssocTrack, - aod::hf_assoc_track_reduced::PtAssocTrack) + aod::hf_assoc_track_reduced::PtAssocTrack); + +DECLARE_SOA_TABLE(AssocTrackSels, "AOD", "ASSOCTRACKSEL", //! Table with associated track info + soa::Index<>, + aod::hf_candidate_reduced::HfcRedCollisionId, + aod::hf_assoc_track_reduced::NTpcCrossedRows, + aod::hf_assoc_track_reduced::ItsClusterMap, + aod::hf_assoc_track_reduced::ItsNCls, + aod::hf_assoc_track_reduced::DcaXY, + aod::hf_assoc_track_reduced::DcaZ) } // namespace o2::aod #endif // PWGHF_HFC_DATAMODEL_DERIVEDDATACORRELATIONTABLES_H_ diff --git a/PWGHF/HFC/Macros/DhCorrelationExtraction.cxx b/PWGHF/HFC/Macros/DhCorrelationExtraction.cxx index 2c222fe5982..c4faa289abb 100644 --- a/PWGHF/HFC/Macros/DhCorrelationExtraction.cxx +++ b/PWGHF/HFC/Macros/DhCorrelationExtraction.cxx @@ -16,6 +16,19 @@ #include "DhCorrelationExtraction.h" +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + DhCorrelationExtraction::DhCorrelationExtraction() : // default constructor fFileMass(0x0), fFileSE(0x0), diff --git a/PWGHF/HFC/Macros/DhCorrelationExtraction.h b/PWGHF/HFC/Macros/DhCorrelationExtraction.h index a659724594b..73b07c61e83 100644 --- a/PWGHF/HFC/Macros/DhCorrelationExtraction.h +++ b/PWGHF/HFC/Macros/DhCorrelationExtraction.h @@ -17,22 +17,16 @@ #ifndef PWGHF_HFC_MACROS_DHCORRELATIONEXTRACTION_H_ #define PWGHF_HFC_MACROS_DHCORRELATIONEXTRACTION_H_ -#include -#include "TObject.h" -#include "TMath.h" -#include "TFile.h" -#include "TDirectoryFile.h" -#include "TList.h" -#include "TCanvas.h" -#include "TPaveText.h" -#include "TLegend.h" -#include "TSystem.h" -#include "TH1D.h" -#include "TH2D.h" -#include "TH3D.h" -#include "TF1.h" -#include "THnSparse.h" -#include "TVector.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include class DhCorrelationExtraction : public TObject { diff --git a/PWGHF/HFC/Macros/DhCorrelationFitter.cxx b/PWGHF/HFC/Macros/DhCorrelationFitter.cxx index 7e5157bb752..8882c567535 100644 --- a/PWGHF/HFC/Macros/DhCorrelationFitter.cxx +++ b/PWGHF/HFC/Macros/DhCorrelationFitter.cxx @@ -16,32 +16,26 @@ #include "DhCorrelationFitter.h" -#include -#include -#include - -#include -#include -#include -#include +#include #include -#include -#include #include #include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include +#include +#include // IWYU pragma: keep (do not replace with TMatrixDfwd.h) +#include #include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include using namespace std; diff --git a/PWGHF/HFC/Macros/DhCorrelationFitter.h b/PWGHF/HFC/Macros/DhCorrelationFitter.h index 83734f44257..a4bdf3c3bb1 100644 --- a/PWGHF/HFC/Macros/DhCorrelationFitter.h +++ b/PWGHF/HFC/Macros/DhCorrelationFitter.h @@ -17,10 +17,11 @@ #ifndef PWGHF_HFC_MACROS_DHCORRELATIONFITTER_H_ #define PWGHF_HFC_MACROS_DHCORRELATIONFITTER_H_ -#include -#include -#include -#include +#include + +#include +#include +#include class DhCorrelationFitter { diff --git a/PWGHF/HFC/Macros/ExtractOutputCorrel.C b/PWGHF/HFC/Macros/ExtractOutputCorrel.C index f13116bffd6..301434f66e2 100644 --- a/PWGHF/HFC/Macros/ExtractOutputCorrel.C +++ b/PWGHF/HFC/Macros/ExtractOutputCorrel.C @@ -26,7 +26,7 @@ using namespace rapidjson; template -void readArray(const Value& jsonArray, vector& output) +void readArray(const Value& jsonArray, std::vector& output) { for (auto it = jsonArray.Begin(); it != jsonArray.End(); it++) { auto value = it->template Get(); @@ -34,7 +34,7 @@ void readArray(const Value& jsonArray, vector& output) } } -void parseStringArray(const Value& jsonArray, vector& output) +void parseStringArray(const Value& jsonArray, std::vector& output) { size_t arrayLength = jsonArray.Size(); for (size_t i = 0; i < arrayLength; i++) { @@ -45,7 +45,7 @@ void parseStringArray(const Value& jsonArray, vector& output) } void SetInputCorrelNames(DhCorrelationExtraction* plotter, TString pathFileMass, TString pathFileSE, TString pathFileME, TString dirSE, TString dirME, TString histoNameCorrSignal, TString histoNameCorrSideba); -void SetInputHistoInvMassNames(DhCorrelationExtraction* plotter, vector inputMassNames); +void SetInputHistoInvMassNames(DhCorrelationExtraction* plotter, std::vector inputMassNames); void ExtractOutputCorrel(TString cfgFileName = "config_CorrAnalysis.json") { @@ -185,7 +185,7 @@ void SetInputCorrelNames(DhCorrelationExtraction* plotter, TString pathFileMass, return; } -void SetInputHistoInvMassNames(DhCorrelationExtraction* plotter, vector inputMassNames) +void SetInputHistoInvMassNames(DhCorrelationExtraction* plotter, std::vector inputMassNames) { // to use if sgn and bkg extraction is done apart plotter->SetMassHistoNameSgn(inputMassNames[0].data()); diff --git a/PWGHF/HFC/Macros/FitCorrel.C b/PWGHF/HFC/Macros/FitCorrel.C index 591933112c6..37b36a5e1b3 100644 --- a/PWGHF/HFC/Macros/FitCorrel.C +++ b/PWGHF/HFC/Macros/FitCorrel.C @@ -31,7 +31,7 @@ using namespace rapidjson; template -void readArray(const Value& jsonArray, vector& output) +void readArray(const Value& jsonArray, std::vector& output) { for (auto it = jsonArray.Begin(); it != jsonArray.End(); it++) { auto value = it->template Get(); diff --git a/PWGHF/HFC/TableProducer/CMakeLists.txt b/PWGHF/HFC/TableProducer/CMakeLists.txt index 1847bcf9890..99f2c4fb152 100644 --- a/PWGHF/HFC/TableProducer/CMakeLists.txt +++ b/PWGHF/HFC/TableProducer/CMakeLists.txt @@ -26,7 +26,7 @@ o2physics_add_dpl_workflow(correlator-d0-hadrons o2physics_add_dpl_workflow(correlator-d-meson-pairs SOURCES correlatorDMesonPairs.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(correlator-dplus-dminus @@ -64,7 +64,12 @@ o2physics_add_dpl_workflow(correlator-lc-hadrons PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(correlator-lc-sc-hadrons + SOURCES correlatorLcScHadrons.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(femto-dream-producer SOURCES femtoDreamProducer.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils O2Physics::MLCore COMPONENT_NAME Analysis) diff --git a/PWGHF/HFC/TableProducer/correlatorD0D0bar.cxx b/PWGHF/HFC/TableProducer/correlatorD0D0bar.cxx index d51ded0baa4..a2ed89ce8d9 100644 --- a/PWGHF/HFC/TableProducer/correlatorD0D0bar.cxx +++ b/PWGHF/HFC/TableProducer/correlatorD0D0bar.cxx @@ -14,18 +14,32 @@ /// /// \author Fabio Colamaria , INFN Bari -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include using namespace o2; using namespace o2::analysis; @@ -48,7 +62,7 @@ const double incrementEtaCut = 0.1; const double incrementPtThreshold = 0.5; const double epsilon = 1E-5; -const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::nBinsPt; +const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::NBinsPt; const double efficiencyDmesonDefault[npTBinsMassAndEfficiency] = {}; auto efficiencyDmeson_v = std::vector{efficiencyDmesonDefault, efficiencyDmesonDefault + npTBinsMassAndEfficiency}; @@ -293,7 +307,7 @@ struct HfCorrelatorD0D0bar { efficiencyWeight = 1. / efficiencyD->at(o2::analysis::findBin(binsPt, candidate1.pt())); } - if (std::abs(candidate1.flagMcMatchRec()) == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { + if (std::abs(candidate1.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // fill per-candidate distributions from D0/D0bar true candidates registry.fill(HIST("hPtCandMCRec"), candidate1.pt()); registry.fill(HIST("hPtProng0MCRec"), candidate1.ptProng0()); @@ -304,19 +318,19 @@ struct HfCorrelatorD0D0bar { registry.fill(HIST("hSelectionStatusMCRec"), candidate1.isSelD0bar() + (candidate1.isSelD0() * 2)); } // fill invariant mass plots from D0/D0bar signal and background candidates - if (candidate1.isSelD0() >= selectionFlagD0) { // only reco as D0 - if (candidate1.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { // also matched as D0 + if (candidate1.isSelD0() >= selectionFlagD0) { // only reco as D0 + if (candidate1.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // also matched as D0 registry.fill(HIST("hMassD0MCRecSig"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), efficiencyWeight); - } else if (candidate1.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + } else if (candidate1.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMassD0MCRecRefl"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), efficiencyWeight); } else { registry.fill(HIST("hMassD0MCRecBkg"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), efficiencyWeight); } } - if (candidate1.isSelD0bar() >= selectionFlagD0bar) { // only reco as D0bar - if (candidate1.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { // also matched as D0bar + if (candidate1.isSelD0bar() >= selectionFlagD0bar) { // only reco as D0bar + if (candidate1.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // also matched as D0bar registry.fill(HIST("hMassD0barMCRecSig"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), efficiencyWeight); - } else if (candidate1.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { + } else if (candidate1.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMassD0barMCRecRefl"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), efficiencyWeight); } else { registry.fill(HIST("hMassD0barMCRecBkg"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), efficiencyWeight); @@ -328,8 +342,8 @@ struct HfCorrelatorD0D0bar { if (candidate1.isSelD0() < selectionFlagD0) { // discard candidates not selected as D0 in outer loop continue; } - flagD0Signal = candidate1.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK; // flagD0Signal 'true' if candidate1 matched to D0 (particle) - flagD0Reflection = candidate1.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK); // flagD0Reflection 'true' if candidate1, selected as D0 (particle), is matched to D0bar (antiparticle) + flagD0Signal = candidate1.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0Signal 'true' if candidate1 matched to D0 (particle) + flagD0Reflection = candidate1.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0Reflection 'true' if candidate1, selected as D0 (particle), is matched to D0bar (antiparticle) for (const auto& candidate2 : selectedD0CandidatesGroupedMC) { if (!(candidate2.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { // check decay channel flag for candidate2 continue; @@ -337,8 +351,8 @@ struct HfCorrelatorD0D0bar { if (candidate2.isSelD0bar() < selectionFlagD0bar) { // discard candidates not selected as D0bar in inner loop continue; } - flagD0barSignal = candidate2.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK); // flagD0barSignal 'true' if candidate2 matched to D0bar (antiparticle) - flagD0barReflection = candidate2.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK; // flagD0barReflection 'true' if candidate2, selected as D0bar (antiparticle), is matched to D0 (particle) + flagD0barSignal = candidate2.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0barSignal 'true' if candidate2 matched to D0bar (antiparticle) + flagD0barReflection = candidate2.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0barReflection 'true' if candidate2, selected as D0bar (antiparticle), is matched to D0 (particle) if (yCandMax >= 0. && std::abs(hfHelper.yD0(candidate2)) > yCandMax) { continue; } @@ -442,7 +456,7 @@ struct HfCorrelatorD0D0bar { // fill pairs vs etaCut plot bool rightDecayChannels = false; - if ((std::abs(particle1.flagMcMatchGen()) == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) && (std::abs(particle2.flagMcMatchGen()) == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if ((std::abs(particle1.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) && (std::abs(particle2.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK)) { rightDecayChannels = true; } do { @@ -475,7 +489,7 @@ struct HfCorrelatorD0D0bar { } while (ptCut < ptThresholdForMaxEtaCut - epsilon); } while (etaCut < maxEtaCut - epsilon); } // end inner loop - } // end outer loop + } // end outer loop registry.fill(HIST("hCountD0D0barPerEvent"), counterD0D0bar); } @@ -540,8 +554,8 @@ struct HfCorrelatorD0D0bar { entryD0D0barRecoInfo(1.864, 1.864, 8); // dummy information - } // end inner loop - } // end outer loop + } // end inner loop + } // end outer loop registry.fill(HIST("hCountCCbarPerEvent"), counterCCbar); registry.fill(HIST("hCountCCbarPerEventBeforeEtaCut"), counterCCbarBeforeEtasel); } diff --git a/PWGHF/HFC/TableProducer/correlatorD0D0barBarrelFullPid.cxx b/PWGHF/HFC/TableProducer/correlatorD0D0barBarrelFullPid.cxx index 26522739841..8fa93dc0d63 100644 --- a/PWGHF/HFC/TableProducer/correlatorD0D0barBarrelFullPid.cxx +++ b/PWGHF/HFC/TableProducer/correlatorD0D0barBarrelFullPid.cxx @@ -14,18 +14,32 @@ /// /// \author Fabio Colamaria , INFN Bari -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include using namespace o2; using namespace o2::analysis; @@ -48,7 +62,7 @@ const double incrementEtaCut = 0.1; const double incrementPtThreshold = 0.5; const double epsilon = 1E-5; -const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::nBinsPt; +const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::NBinsPt; const double efficiencyDmesonDefault[npTBinsMassAndEfficiency] = {}; auto efficiencyDmeson_v = std::vector{efficiencyDmesonDefault, efficiencyDmesonDefault + npTBinsMassAndEfficiency}; @@ -294,7 +308,7 @@ struct HfCorrelatorD0D0barBarrelFullPid { efficiencyWeight = 1. / efficiencyD->at(o2::analysis::findBin(binsPt, candidate1.pt())); } - if (std::abs(candidate1.flagMcMatchRec()) == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { + if (std::abs(candidate1.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // fill per-candidate distributions from D0/D0bar true candidates registry.fill(HIST("hPtCandMCRec"), candidate1.pt()); registry.fill(HIST("hPtProng0MCRec"), candidate1.ptProng0()); @@ -305,19 +319,19 @@ struct HfCorrelatorD0D0barBarrelFullPid { registry.fill(HIST("hSelectionStatusMCRec"), candidate1.isSelD0barTofPlusRichPid() + (candidate1.isSelD0TofPlusRichPid() * 2)); } // fill invariant mass plots from D0/D0bar signal and background candidates - if (candidate1.isSelD0TofPlusRichPid() >= selectionFlagD0) { // only reco as D0 - if (candidate1.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { // also matched as D0 + if (candidate1.isSelD0TofPlusRichPid() >= selectionFlagD0) { // only reco as D0 + if (candidate1.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // also matched as D0 registry.fill(HIST("hMassD0MCRecSig"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), efficiencyWeight); - } else if (candidate1.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + } else if (candidate1.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMassD0MCRecRefl"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), efficiencyWeight); } else { registry.fill(HIST("hMassD0MCRecBkg"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), efficiencyWeight); } } - if (candidate1.isSelD0barTofPlusRichPid() >= selectionFlagD0bar) { // only reco as D0bar - if (candidate1.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { // also matched as D0bar + if (candidate1.isSelD0barTofPlusRichPid() >= selectionFlagD0bar) { // only reco as D0bar + if (candidate1.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // also matched as D0bar registry.fill(HIST("hMassD0barMCRecSig"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), efficiencyWeight); - } else if (candidate1.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { + } else if (candidate1.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMassD0barMCRecRefl"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), efficiencyWeight); } else { registry.fill(HIST("hMassD0barMCRecBkg"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), efficiencyWeight); @@ -329,8 +343,8 @@ struct HfCorrelatorD0D0barBarrelFullPid { if (candidate1.isSelD0TofPlusRichPid() < selectionFlagD0) { // discard candidates not selected as D0 in outer loop continue; } - flagD0Signal = candidate1.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK; // flagD0Signal 'true' if candidate1 matched to D0 (particle) - flagD0Reflection = candidate1.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK); // flagD0Reflection 'true' if candidate1, selected as D0 (particle), is matched to D0bar (antiparticle) + flagD0Signal = candidate1.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0Signal 'true' if candidate1 matched to D0 (particle) + flagD0Reflection = candidate1.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0Reflection 'true' if candidate1, selected as D0 (particle), is matched to D0bar (antiparticle) for (const auto& candidate2 : selectedD0candidatesGroupedMC) { if (!(candidate2.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { // check decay channel flag for candidate2 continue; @@ -338,8 +352,8 @@ struct HfCorrelatorD0D0barBarrelFullPid { if (candidate2.isSelD0barTofPlusRichPid() < selectionFlagD0bar) { // discard candidates not selected as D0bar in inner loop continue; } - flagD0barSignal = candidate2.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK); // flagD0barSignal 'true' if candidate2 matched to D0bar (antiparticle) - flagD0barReflection = candidate2.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK; // flagD0barReflection 'true' if candidate2, selected as D0bar (antiparticle), is matched to D0 (particle) + flagD0barSignal = candidate2.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0barSignal 'true' if candidate2 matched to D0bar (antiparticle) + flagD0barReflection = candidate2.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0barReflection 'true' if candidate2, selected as D0bar (antiparticle), is matched to D0 (particle) if (yCandMax >= 0. && std::abs(hfHelper.yD0(candidate2)) > yCandMax) { continue; } @@ -443,7 +457,7 @@ struct HfCorrelatorD0D0barBarrelFullPid { // fill pairs vs etaCut plot bool rightDecayChannels = false; - if ((std::abs(particle1.flagMcMatchGen()) == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) && (std::abs(particle2.flagMcMatchGen()) == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if ((std::abs(particle1.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) && (std::abs(particle2.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK)) { rightDecayChannels = true; } do { @@ -476,7 +490,7 @@ struct HfCorrelatorD0D0barBarrelFullPid { } while (ptCut < ptThresholdForMaxEtaCut - epsilon); } while (etaCut < maxEtaCut - epsilon); } // end inner loop - } // end outer loop + } // end outer loop registry.fill(HIST("hCountD0D0barPerEvent"), counterD0D0bar); } @@ -541,8 +555,8 @@ struct HfCorrelatorD0D0barBarrelFullPid { entryD0D0barRecoInfo(1.864, 1.864, 8); // dummy information - } // end inner loop - } // end outer loop + } // end inner loop + } // end outer loop registry.fill(HIST("hCountCCbarPerEvent"), counterCCbar); registry.fill(HIST("hCountCCbarPerEventBeforeEtaCut"), counterCCbarBeforeEtasel); } diff --git a/PWGHF/HFC/TableProducer/correlatorD0Hadrons.cxx b/PWGHF/HFC/TableProducer/correlatorD0Hadrons.cxx index 3500b09dc92..afe123a2386 100644 --- a/PWGHF/HFC/TableProducer/correlatorD0Hadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorD0Hadrons.cxx @@ -15,24 +15,46 @@ /// \author Samrangy Sadhu , INFN Bari /// \author Swapnesh Santosh Khade , IIT Indore -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/TrackSelectionTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/HFC/Utils/utilsCorrelations.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -49,39 +71,25 @@ double getDeltaPhi(double phiHadron, double phiD) return RecoDecay::constrainAngle(phiHadron - phiD, -o2::constants::math::PIHalf); } -const int nPtBinsMassAndEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::nBinsPt; -const double efficiencyDmesonDefault[nPtBinsMassAndEfficiency] = {}; -auto vecEfficiencyDmeson = std::vector{efficiencyDmesonDefault, efficiencyDmesonDefault + nPtBinsMassAndEfficiency}; - -// histogram binning definition -const int massAxisNBins = 200; -const double massAxisMin = 1.3848; -const double massAxisMax = 2.3848; -const int phiAxisNBins = 32; -const double phiAxisMin = 0.; -const double phiAxisMax = o2::constants::math::TwoPI; -const int yAxisNBins = 100; -const double yAxisMin = -5.; -const double yAxisMax = 5.; -const int ptDAxisNBins = 180; -const double ptDAxisMin = 0.; -const double ptDAxisMax = 36.; - // Types using BinningType = ColumnBinningPolicy>; +using BinningTypeMcGen = ColumnBinningPolicy; using SelectedCollisions = soa::Filtered>; using SelectedTracks = soa::Filtered>; using SelectedCandidatesData = soa::Filtered>; using SelectedCandidatesDataMl = soa::Filtered>; using SelectedTracksMcRec = soa::Filtered>; using SelectedCandidatesMcRec = soa::Filtered>; +using SelectedCandidatesMcRecMl = soa::Filtered>; using SelectedCollisionsMcGen = soa::Filtered>; using SelectedParticlesMcGen = soa::Join; // Code to select collisions with at least one D0 struct HfCorrelatorD0HadronsSelection { - Produces d0Sel; + Produces collisionsWithSelD0; + Configurable useSel8{"useSel8", true, "Flag for applying sel8 for collision selection"}; + Configurable selNoSameBunchPileUpColl{"selNoSameBunchPileUpColl", true, "Flag for rejecting the collisions associated with the same bunch crossing"}; Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection Flag for D0bar"}; Configurable yCandMax{"yCandMax", 4.0, "max. cand. rapidity"}; @@ -89,60 +97,89 @@ struct HfCorrelatorD0HadronsSelection { HfHelper hfHelper; SliceCache cache; + + using SelCollisions = soa::Join; + Preslice perCol = aod::hf_cand::collisionId; Partition> selectedD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar; Partition> selectedD0candidatesMc = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar; - void processD0SelectionData(aod::Collision const& collision, + void processD0SelectionData(SelCollisions::iterator const& collision, soa::Join const&) { - bool isD0Found = 0; + bool isSelColl = true; + bool isD0Found = true; + bool isSel8 = true; + bool isNosameBunchPileUp = true; if (selectedD0Candidates.size() > 0) { auto selectedD0CandidatesGrouped = selectedD0Candidates->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); for (const auto& candidate : selectedD0CandidatesGrouped) { // check decay channel flag for candidate if (!TESTBIT(candidate.hfflag(), aod::hf_cand_2prong::DecayType::D0ToPiK)) { + isD0Found = false; continue; } if (std::abs(hfHelper.yD0(candidate)) > yCandMax || candidate.pt() < ptCandMin) { + isD0Found = false; continue; } - isD0Found = 1; + isD0Found = true; break; } } - d0Sel(isD0Found); + if (useSel8) { + isSel8 = false; + isSel8 = collision.sel8(); + } + if (selNoSameBunchPileUpColl) { + isNosameBunchPileUp = false; + isNosameBunchPileUp = static_cast(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)); + } + isSelColl = isD0Found && isSel8 && isNosameBunchPileUp; + collisionsWithSelD0(isSelColl); } PROCESS_SWITCH(HfCorrelatorD0HadronsSelection, processD0SelectionData, "Process D0 Selection Data", false); - void processD0SelectionMcRec(aod::Collision const& collision, + void processD0SelectionMcRec(SelCollisions::iterator const& collision, soa::Join const&) { - bool isD0Found = 0; + bool isSelColl = true; + bool isD0Found = true; + bool isSel8 = true; + bool isNosameBunchPileUp = true; if (selectedD0candidatesMc.size() > 0) { auto selectedD0CandidatesGroupedMc = selectedD0candidatesMc->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); for (const auto& candidate : selectedD0CandidatesGroupedMc) { // check decay channel flag for candidate if (!TESTBIT(candidate.hfflag(), aod::hf_cand_2prong::DecayType::D0ToPiK)) { + isD0Found = false; continue; } if (std::abs(hfHelper.yD0(candidate)) > yCandMax || candidate.pt() < ptCandMin) { + isD0Found = false; continue; } - isD0Found = 1; + isD0Found = true; break; } } - d0Sel(isD0Found); + if (useSel8) { + isSel8 = collision.sel8(); + } + if (selNoSameBunchPileUpColl) { + isNosameBunchPileUp = static_cast(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)); + } + isSelColl = isD0Found && isSel8 && isNosameBunchPileUp; + collisionsWithSelD0(isSelColl); } PROCESS_SWITCH(HfCorrelatorD0HadronsSelection, processD0SelectionMcRec, "Process D0 Selection MCRec", true); void processD0SelectionMcGen(aod::McCollision const&, aod::McParticles const& mcParticles) { - bool isD0Found = 0; + bool isD0Found = false; for (const auto& particle : mcParticles) { if (std::abs(particle.pdgCode()) != Pdg::kD0) { continue; @@ -151,10 +188,10 @@ struct HfCorrelatorD0HadronsSelection { if (std::abs(yD) > yCandMax || particle.pt() < ptCandMin) { continue; } - isD0Found = 1; + isD0Found = true; break; } - d0Sel(isD0Found); + collisionsWithSelD0(isD0Found); } PROCESS_SWITCH(HfCorrelatorD0HadronsSelection, processD0SelectionMcGen, "Process D0 Selection MCGen", false); }; @@ -163,8 +200,11 @@ struct HfCorrelatorD0HadronsSelection { struct HfCorrelatorD0Hadrons { Produces entryD0HadronPair; Produces entryD0HadronRecoInfo; + Produces entryD0HadronGenInfo; Produces entryD0HadronMlInfo; Produces entryD0CandRecoInfo; + Produces entryD0CandGenInfo; + Produces entryTrackRecoInfo; Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection Flag for D0bar"}; @@ -175,8 +215,10 @@ struct HfCorrelatorD0Hadrons { Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; Configurable ptTrackMin{"ptTrackMin", 0.3, "min. track pT"}; Configurable ptTrackMax{"ptTrackMax", 99., "max. track pT"}; - Configurable> bins{"bins", std::vector{o2::analysis::hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for candidate mass plots and efficiency"}; - Configurable> efficiencyDmeson{"efficiencyDmeson", std::vector{vecEfficiencyDmeson}, "Efficiency values for D0 meson"}; + Configurable> binsPtD{"binsPtD", std::vector{o2::analysis::hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for candidate mass plots"}; + Configurable> binsPtHadron{"binsPtHadron", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for assoc particle"}; + Configurable> binsPtEfficiencyD{"binsPtEfficiencyD", std::vector{o2::analysis::hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for efficiency"}; + Configurable> efficiencyDmeson{"efficiencyDmeson", {1., 1., 1., 1., 1., 1.}, "Efficiency values for D0 meson"}; Configurable applyEfficiency{"applyEfficiency", 1, "Flag for applying D-meson efficiency weights"}; Configurable multMin{"multMin", 0., "minimum multiplicity accepted"}; Configurable multMax{"multMax", 10000., "maximum multiplicity accepted"}; @@ -206,42 +248,17 @@ struct HfCorrelatorD0Hadrons { ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0f, -2.5f, 2.5f, 10.0f}, "z vertex position pools"}; ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0.0f, 2000.0f, 6000.0f, 10000.0f}, "event multiplicity pools (FT0M)"}; ConfigurableAxis multPoolBinsMcGen{"multPoolBinsMcGen", {VARIABLE_WIDTH, 0.0f, 20.0f, 50.0f, 500.0f}, "Mixing bins - MC multiplicity"}; // In MCGen multiplicity is defined by counting tracks + ConfigurableAxis binsMassD{"binsMassD", {200, 1.3848, 2.3848}, "inv. mass (#pi K) (GeV/#it{c}^{2});entries"}; + ConfigurableAxis binsEta{"binsEta", {100, -5., 5.}, "#it{#eta}"}; + ConfigurableAxis binsPhi{"binsPhi", {64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, "#it{#varphi}"}; + ConfigurableAxis binsMultiplicity{"binsMultiplicity", {10000, 0., 10000.}, "Multiplicity"}; + ConfigurableAxis binsMultFT0M{"binsMultFT0M", {10000, 0., 10000.}, "Multiplicity as FT0M signal amplitude"}; + ConfigurableAxis binsPosZ{"binsPosZ", {100, -10., 10.}, "primary vertex z coordinate"}; + ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; BinningType corrBinning{{zPoolBins, multPoolBins}, true}; - HistogramRegistry registry{ - "registry", - // NOTE: use hMassD0 for trigger normalisation (S*0.955), and hMass2DCorrelationPairs (in final task) for 2D-sideband-subtraction purposes - {{"hPtCand", "D0,D0bar candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisNBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng0", "D0,D0bar candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisNBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng1", "D0,D0bar candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisNBins, ptDAxisMin, ptDAxisMax}}}}, - {"hSelectionStatus", "D0,D0bar candidates;selection status;entries", {HistType::kTH1F, {{4, -0.5, 3.5}}}}, - {"hEta", "D0,D0bar candidates;candidate #it{#eta};entries", {HistType::kTH1F, {{yAxisNBins, yAxisMin, yAxisMax}}}}, - {"hPhi", "D0,D0bar candidates;candidate #it{#varphi};entries", {HistType::kTH1F, {{phiAxisNBins, phiAxisMin, phiAxisMax}}}}, - {"hY", "D0,D0bar candidates;candidate #it{y};entries", {HistType::kTH1F, {{yAxisNBins, yAxisMin, yAxisMax}}}}, - {"hMultiplicityPreSelection", "multiplicity prior to selection;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}}, - {"hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}}, - {"hPtCandRec", "D0,D0bar candidates - MC reco;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisNBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng0Rec", "D0,D0bar candidates - MC reco;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisNBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng1Rec", "D0,D0bar candidates - MC reco;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisNBins, ptDAxisMin, ptDAxisMax}}}}, - {"hSelectionStatusRec", "D0,D0bar candidates - MC reco;selection status;entries", {HistType::kTH1F, {{4, -0.5, 3.5}}}}, - {"hSignalStatusMERec", "Signal Status - MC reco ME;candidate sidnalStatus;entries", {HistType::kTH1F, {{200, 0, 200}}}}, - {"hEtaRec", "D0,D0bar candidates - MC reco;candidate #it{#eta};entries", {HistType::kTH1F, {{yAxisNBins, yAxisMin, yAxisMax}}}}, - {"hPhiRec", "D0,D0bar candidates - MC reco;candidate #it{#varphi};entries", {HistType::kTH1F, {{phiAxisNBins, phiAxisMin, phiAxisMax}}}}, - {"hYRec", "D0,D0bar candidates - MC reco;candidate #it{y};entries", {HistType::kTH1F, {{yAxisNBins, yAxisMin, yAxisMax}}}}, - {"hEvtCountGen", "Event counter - MC gen;;entries", {HistType::kTH1F, {{1, -0.5, 0.5}}}}, - {"hPtCandGen", "D0,D0bar particles - MC gen;particle #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisNBins, ptDAxisMin, ptDAxisMax}}}}, - {"hEtaGen", "D0,D0bar particles - MC gen;particle #it{#eta};entries", {HistType::kTH1F, {{yAxisNBins, yAxisMin, yAxisMax}}}}, - {"hPhiGen", "D0,D0bar particles - MC gen;particle #it{#varphi};entries", {HistType::kTH1F, {{phiAxisNBins, phiAxisMin, phiAxisMax}}}}, - {"hYGen", "D0,D0bar candidates - MC gen;candidate #it{y};entries", {HistType::kTH1F, {{yAxisNBins, yAxisMin, yAxisMax}}}}, - {"hTrackCounter", "soft pion counter - Data", {HistType::kTH1F, {{5, 0., 5.}}}}, - {"hTrackCounterRec", "soft pion counter - MC rec", {HistType::kTH1F, {{5, 0., 5.}}}}, - {"hTrackCounterGen", "soft pion counter - MC gen", {HistType::kTH1F, {{5, 0., 5.}}}}, - {"hMultV0M", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}}, - {"hZvtx", "z vertex;z vertex;entries", {HistType::kTH1F, {{200, -20., 20.}}}}, - {"hMultFT0M", "Multiplicity FT0M", {HistType::kTH1F, {{10000, 0., 10000.}}}}, - {"hD0Bin", "D0 selected in pool Bin;pool Bin;entries", {HistType::kTH1F, {{9, 0., 9.}}}}, - {"hTracksBin", "Tracks selected in pool Bin;pool Bin;entries", {HistType::kTH1F, {{9, 0., 9.}}}}}}; + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(InitContext&) { @@ -249,24 +266,81 @@ struct HfCorrelatorD0Hadrons { massPi = MassPiPlus; massK = MassKPlus; - auto vbins = (std::vector)bins; - registry.add("hMass", "D0,D0bar candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisNBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hMass1D", "D0,D0bar candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{massAxisNBins, massAxisMin, massAxisMax}}}); - registry.add("hMassD01D", "D0,D0bar candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{massAxisNBins, massAxisMin, massAxisMax}}}); - registry.add("hMassD0bar1D", "D0,D0bar candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{massAxisNBins, massAxisMin, massAxisMax}}}); - // mass histogram for D0 signal candidates - registry.add("hMassD0RecSig", "D0 signal candidates - MC reco;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisNBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - // mass histogram for D0 Reflection candidates - registry.add("hMassD0RecRef", "D0 reflection candidates - MC reco;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisNBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - // mass histogram for D0 background candidates - registry.add("hMassD0RecBg", "D0 background candidates - MC reco;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisNBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - // mass histogram for D0bar signal candidates - registry.add("hMassD0barRecSig", "D0bar signal candidates - MC reco;inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisNBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - // mass histogram for D0bar Reflection candidates - registry.add("hMassD0barRecRef", "D0bar reflection candidates - MC reco;inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisNBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - // mass histogram for D0bar background candidates - registry.add("hMassD0barRecBg", "D0bar background candidates - MC reco;inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisNBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hCountD0TriggersGen", "D0 trigger particles - MC gen;;N of trigger D0", {HistType::kTH2F, {{1, -0.5, 0.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + AxisSpec axisMassD = {binsMassD, "inv. mass (#pi K) (GeV/#it{c}^{2})"}; + AxisSpec axisEta = {binsEta, "#it{#eta}"}; + AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; + AxisSpec axisRapidity = {100, -5., 5., "Rapidity"}; + AxisSpec axisPtD = {(std::vector)binsPtD, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisPtHadron = {(std::vector)binsPtHadron, "#it{p}_{T} Hadron (GeV/#it{c})"}; + AxisSpec axisMultiplicity = {binsMultiplicity, "Multiplicity"}; + AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; + AxisSpec axisPosZ = {binsPosZ, "PosZ"}; + AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; + AxisSpec axisStatus = {4, -0.5, 3.5, "Selection status"}; + AxisSpec axisSignalStatus = {200, 0., 200., "Signal status"}; + AxisSpec axisEvtCount = {1, -0.5, 0.5}; + AxisSpec axisTrkCount = {5, 0., 5.}; + AxisSpec axisBdtScoreBkg = {100, 0., 1., "Bdt score background"}; + AxisSpec axisBdtScorePrompt = {100, 0., 1., "Bdt score prompt"}; + AxisSpec axisOrigin = {10, 0., 10., "Candidate origin"}; + + // Histograms for Data + registry.add("hPtCand", "D0, D0bar candidates", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtProng0", "D0, D0bar candidates prong 0", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtProng1", "D0, D0bar candidates prong 1", {HistType::kTH1F, {axisPtD}}); + registry.add("hSelectionStatus", "D0, D0bar candidates selection status", {HistType::kTH1F, {axisStatus}}); + registry.add("hEta", "D0,D0bar candidates", {HistType::kTH1F, {axisEta}}); + registry.add("hPhi", "D0,D0bar candidates", {HistType::kTH1F, {axisPhi}}); + registry.add("hY", "D0,D0bar candidates", {HistType::kTH1F, {axisRapidity}}); + registry.add("hMultiplicityPreSelection", "multiplicity prior to selection;multiplicity;entries", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("hMass", "D0, D0bar candidates massVsPt", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMass1D", "D0, D0bar candidates mass", {HistType::kTH1F, {axisMassD}}); + registry.add("hMassD01D", "D0 candidates mass", {HistType::kTH1F, {axisMassD}}); + registry.add("hMassD0bar1D", "D0bar candidates mass", {HistType::kTH1F, {axisMassD}}); + registry.add("hMLScoresVsMassVsPtVsOrigin", "D0, D0bar candidates massVsPt", {HistType::kTHnSparseD, {{axisBdtScoreBkg}, {axisBdtScorePrompt}, {axisMassD}, {axisPtD}, {axisOrigin}}}); + // Histograms for MC Reco + registry.add("hPtCandRec", "D0, D0bar candidates - MC reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtProng0Rec", "D0, D0bar candidates prong 0 - MC reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtProng1Rec", "D0, D0bar candidates prong 1 - MC reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hSelectionStatusRec", "D0, D0bar candidates selection status - MC reco", {HistType::kTH1F, {axisStatus}}); + registry.add("hSignalStatusMERec", "Signal Status - MC reco ME", {HistType::kTH1F, {axisSignalStatus}}); + registry.add("hEtaRec", "D0,D0bar candidates - MC reco", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiRec", "D0,D0bar candidates - MC reco", {HistType::kTH1F, {axisPhi}}); + registry.add("hYRec", "D0,D0bar candidates - MC reco", {HistType::kTH1F, {axisRapidity}}); + registry.add("hMassD0RecSig", "D0 signal candidates massVsPt - MC reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassD0RecRef", "D0 reflection candidates massVsPt - MC reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassD0RecBg", "D0 background candidates massVsPt - MC reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassD0barRecSig", "D0bar signal candidates massVsPt - MC reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassD0barRecRef", "D0bar reflection candidates massVsPt - MC reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassD0barRecBg", "D0bar background candidates massVsPt - MC reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hPtCandRecSigPrompt", "D0,Hadron candidates Prompt - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandRecSigNonPrompt", "D0,Hadron candidates Non Prompt - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtVsMultiplicityRecPrompt", "Multiplicity FT0M - MC Rec Prompt", {HistType::kTH2F, {{axisPtD}, {axisMultFT0M}}}); + registry.add("hPtVsMultiplicityRecNonPrompt", "Multiplicity FT0M - MC Rec Non Prompt", {HistType::kTH2F, {{axisPtD}, {axisMultFT0M}}}); + registry.add("hPtParticleAssocVsCandRec", "Associated Particle - MC reco", {HistType::kTH2F, {{axisPtHadron}, {axisPtD}}}); + registry.add("hPtPrimaryParticleAssocVsCandRec", "Associated Particle - MC reco", {HistType::kTH2F, {{axisPtHadron}, {axisPtD}}}); + // Histograms for MC Gen + registry.add("hEvtCountGen", "Event counter - MC gen", {HistType::kTH1F, {axisEvtCount}}); + registry.add("hPtCandGen", "D0, D0bar candidates - MC gen", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandGenPrompt", "D0, D0bar candidates - MC gen prompt", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandGenNonPrompt", "D0, D0bar candidates - MC gen non prompt", {HistType::kTH1F, {axisPtD}}); + registry.add("hEtaGen", "D0,D0bar candidates - MC gen", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiGen", "D0,D0bar candidates - MC gen", {HistType::kTH1F, {axisPhi}}); + registry.add("hYGen", "D0,D0bar candidates - MC gen", {HistType::kTH1F, {axisRapidity}}); + registry.add("hCountD0TriggersGen", "D0 trigger particles - MC gen;;N of trigger D0", {HistType::kTH2F, {{axisEvtCount}, {axisPtD}}}); + // Common histograms + registry.add("hTrackCounter", "Track counter", {HistType::kTH1F, {axisTrkCount}}); + registry.get(HIST("hTrackCounter"))->GetXaxis()->SetBinLabel(1, "all"); + registry.get(HIST("hTrackCounter"))->GetXaxis()->SetBinLabel(2, "before softpi"); + registry.get(HIST("hTrackCounter"))->GetXaxis()->SetBinLabel(3, "after softpi"); + registry.get(HIST("hTrackCounter"))->GetXaxis()->SetBinLabel(4, "with leading particles"); + registry.get(HIST("hTrackCounter"))->GetXaxis()->SetBinLabel(5, "fake tracks"); + registry.add("hZvtx", "z vertex", {HistType::kTH1F, {axisPosZ}}); + registry.add("hMultFT0M", "Multiplicity FT0M", {HistType::kTH1F, {axisMultFT0M}}); + registry.add("hCollisionPoolBin", "collision pool bin", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hD0PoolBin", "D0 selected in pool Bin", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hTracksPoolBin", "Particles associated pool bin", {HistType::kTH1F, {axisPoolBin}}); } // ======= Process starts for Data, Same event ============ @@ -278,10 +352,14 @@ struct HfCorrelatorD0Hadrons { { // find leading particle if (correlateD0WithLeadingParticle) { - leadingIndex = findLeadingParticle(tracks, dcaXYTrackMax.value, dcaZTrackMax.value, etaTrackMax.value); + leadingIndex = findLeadingParticle(tracks, etaTrackMax.value); } int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZvtx"), collision.posZ()); + registry.fill(HIST("hMultFT0M"), collision.multFT0M()); + int nTracks = 0; if (collision.numContrib() > 1) { for (const auto& track : tracks) { @@ -295,8 +373,7 @@ struct HfCorrelatorD0Hadrons { } } registry.fill(HIST("hMultiplicityPreSelection"), nTracks); - registry.fill(HIST("hZvtx"), collision.posZ()); - registry.fill(HIST("hMultFT0M"), collision.multFT0M()); + if (nTracks < multMin || nTracks > multMax) { return; } @@ -320,7 +397,7 @@ struct HfCorrelatorD0Hadrons { // ========================== trigger efficiency ================================ double efficiencyWeight = 1.; if (applyEfficiency) { - efficiencyWeight = 1. / efficiencyDmeson->at(o2::analysis::findBin(bins, candidate.pt())); + efficiencyWeight = 1. / efficiencyDmeson->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt())); } // ========================== Fill mass histo ================================ if (candidate.isSelD0() >= selectionFlagD0) { @@ -330,6 +407,7 @@ struct HfCorrelatorD0Hadrons { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMlD0[iclass] = candidate.mlProbD0()[classMl->at(iclass)]; } + registry.fill(HIST("hMLScoresVsMassVsPtVsOrigin"), outputMlD0[0], outputMlD0[2], hfHelper.invMassD0ToPiK(candidate), candidate.pt(), candidate.isSelD0bar() ? o2::aod::hf_correlation_d0_hadron::D0D0barBoth : o2::aod::hf_correlation_d0_hadron::D0Only); } if (candidate.isSelD0bar() >= selectionFlagD0bar) { registry.fill(HIST("hMass"), hfHelper.invMassD0barToKPi(candidate), candidate.pt(), efficiencyWeight); @@ -338,6 +416,7 @@ struct HfCorrelatorD0Hadrons { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMlD0bar[iclass] = candidate.mlProbD0bar()[classMl->at(iclass)]; } + registry.fill(HIST("hMLScoresVsMassVsPtVsOrigin"), outputMlD0bar[0], outputMlD0bar[2], hfHelper.invMassD0barToKPi(candidate), candidate.pt(), candidate.isSelD0() ? o2::aod::hf_correlation_d0_hadron::D0D0barBoth : o2::aod::hf_correlation_d0_hadron::D0barOnly); } entryD0CandRecoInfo(hfHelper.invMassD0ToPiK(candidate), hfHelper.invMassD0barToKPi(candidate), candidate.pt(), outputMlD0[0], outputMlD0[2], outputMlD0bar[0], outputMlD0bar[2]); @@ -349,13 +428,13 @@ struct HfCorrelatorD0Hadrons { registry.fill(HIST("hPhi"), candidate.phi()); registry.fill(HIST("hY"), hfHelper.yD0(candidate)); registry.fill(HIST("hSelectionStatus"), candidate.isSelD0bar() + (candidate.isSelD0() * 2)); - registry.fill(HIST("hD0Bin"), poolBin); + registry.fill(HIST("hD0PoolBin"), poolBin); // ============ D-h correlation dedicated section ================================== // ========================== track loop starts here ================================ for (const auto& track : tracks) { - registry.fill(HIST("hTrackCounter"), 1); // fill total no. of tracks + registry.fill(HIST("hTrackCounter"), 0); // fill total no. of tracks // Remove D0 daughters by checking track indices bool correlationStatus = false; if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex())) { @@ -364,8 +443,7 @@ struct HfCorrelatorD0Hadrons { } correlationStatus = true; } - - registry.fill(HIST("hTrackCounter"), 2); // fill no. of tracks before soft pion removal + registry.fill(HIST("hTrackCounter"), 1); // fill no. of tracks before soft pion removal // ========== soft pion removal =================================================== double invMassDstar1 = 0., invMassDstar2 = 0.; @@ -388,7 +466,7 @@ struct HfCorrelatorD0Hadrons { continue; } } - registry.fill(HIST("hTrackCounter"), 3); // fill no. of tracks after soft pion removal + registry.fill(HIST("hTrackCounter"), 2); // fill no. of tracks after soft pion removal int signalStatus = 0; if ((candidate.isSelD0() >= selectionFlagD0) && !isSoftPiD0) { @@ -402,7 +480,7 @@ struct HfCorrelatorD0Hadrons { if (track.globalIndex() != leadingIndex) { continue; } - registry.fill(HIST("hTrackCounter"), 4); // fill no. of tracks have leading particle + registry.fill(HIST("hTrackCounter"), 3); // fill no. of tracks have leading particle } entryD0HadronPair(getDeltaPhi(track.phi(), candidate.phi()), track.eta() - candidate.eta(), @@ -411,7 +489,9 @@ struct HfCorrelatorD0Hadrons { poolBin, correlationStatus); entryD0HadronRecoInfo(hfHelper.invMassD0ToPiK(candidate), hfHelper.invMassD0barToKPi(candidate), signalStatus); + entryD0HadronGenInfo(false, false, 0); entryD0HadronMlInfo(outputMlD0[0], outputMlD0[1], outputMlD0[2], outputMlD0bar[0], outputMlD0bar[1], outputMlD0bar[2]); + entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.tpcNClsCrossedRows()); } // end inner loop (tracks) @@ -423,13 +503,18 @@ struct HfCorrelatorD0Hadrons { void processMcRec(SelectedCollisions::iterator const& collision, SelectedTracksMcRec const& tracks, - SelectedCandidatesMcRec const& candidates) + SelectedCandidatesMcRecMl const& candidates, + aod::McParticles const& mcParticles) { // find leading particle if (correlateD0WithLeadingParticle) { - leadingIndex = findLeadingParticle(tracks, dcaXYTrackMax.value, dcaZTrackMax.value, etaTrackMax.value); + leadingIndex = findLeadingParticle(tracks, etaTrackMax.value); } int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hZvtx"), collision.posZ()); + registry.fill(HIST("hMultFT0M"), collision.multFT0M()); + int nTracks = 0; if (collision.numContrib() > 1) { for (const auto& track : tracks) { @@ -451,8 +536,14 @@ struct HfCorrelatorD0Hadrons { // MC reco level bool flagD0 = false; bool flagD0bar = false; + bool isD0Prompt = false; + bool isD0NonPrompt = false; + std::vector outputMlD0 = {-1., -1., -1.}; + std::vector outputMlD0bar = {-1., -1., -1.}; for (const auto& candidate : candidates) { + isD0Prompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; + isD0NonPrompt = candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; // check decay channel flag for candidate if (!TESTBIT(candidate.hfflag(), aod::hf_cand_2prong::DecayType::D0ToPiK)) { continue; @@ -461,12 +552,14 @@ struct HfCorrelatorD0Hadrons { continue; } + registry.fill(HIST("hD0PoolBin"), poolBin); + double efficiencyWeight = 1.; if (applyEfficiency) { - efficiencyWeight = 1. / efficiencyDmeson->at(o2::analysis::findBin(bins, candidate.pt())); + efficiencyWeight = 1. / efficiencyDmeson->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt())); } - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // fill per-candidate distributions from D0/D0bar true candidates registry.fill(HIST("hPtCandRec"), candidate.pt()); registry.fill(HIST("hPtProng0Rec"), candidate.ptProng0()); @@ -477,24 +570,46 @@ struct HfCorrelatorD0Hadrons { registry.fill(HIST("hSelectionStatusRec"), candidate.isSelD0bar() + (candidate.isSelD0() * 2)); } // fill invariant mass plots from D0/D0bar signal and background candidates - if (candidate.isSelD0() >= selectionFlagD0) { // only reco as D0 - if (candidate.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { // also matched as D0 + if (candidate.isSelD0() >= selectionFlagD0) { // only reco as D0 + if (candidate.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // also matched as D0 registry.fill(HIST("hMassD0RecSig"), hfHelper.invMassD0ToPiK(candidate), candidate.pt(), efficiencyWeight); - } else if (candidate.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if (isD0Prompt) { + registry.fill(HIST("hPtCandRecSigPrompt"), candidate.pt()); + registry.fill(HIST("hPtVsMultiplicityRecPrompt"), candidate.pt(), collision.multFT0M()); + } else if (isD0NonPrompt) { + registry.fill(HIST("hPtCandRecSigNonPrompt"), candidate.pt()); + registry.fill(HIST("hPtVsMultiplicityRecNonPrompt"), candidate.pt(), collision.multFT0M()); + } + } else if (candidate.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMassD0RecRef"), hfHelper.invMassD0ToPiK(candidate), candidate.pt(), efficiencyWeight); } else { registry.fill(HIST("hMassD0RecBg"), hfHelper.invMassD0ToPiK(candidate), candidate.pt(), efficiencyWeight); } + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMlD0[iclass] = candidate.mlProbD0()[classMl->at(iclass)]; + } } - if (candidate.isSelD0bar() >= selectionFlagD0bar) { // only reco as D0bar - if (candidate.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { // also matched as D0bar + if (candidate.isSelD0bar() >= selectionFlagD0bar) { // only reco as D0bar + if (candidate.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // also matched as D0bar registry.fill(HIST("hMassD0barRecSig"), hfHelper.invMassD0barToKPi(candidate), candidate.pt(), efficiencyWeight); - } else if (candidate.flagMcMatchRec() == 1 << aod::hf_cand_2prong::DecayType::D0ToPiK) { + if (isD0Prompt) { + registry.fill(HIST("hPtCandRecSigPrompt"), candidate.pt()); + registry.fill(HIST("hPtVsMultiplicityRecPrompt"), candidate.pt(), collision.multFT0M()); + } else if (isD0NonPrompt) { + registry.fill(HIST("hPtCandRecSigNonPrompt"), candidate.pt()); + registry.fill(HIST("hPtVsMultiplicityRecNonPrompt"), candidate.pt(), collision.multFT0M()); + } + } else if (candidate.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMassD0barRecRef"), hfHelper.invMassD0barToKPi(candidate), candidate.pt(), efficiencyWeight); } else { registry.fill(HIST("hMassD0barRecBg"), hfHelper.invMassD0barToKPi(candidate), candidate.pt(), efficiencyWeight); } + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMlD0bar[iclass] = candidate.mlProbD0bar()[classMl->at(iclass)]; + } } + entryD0CandRecoInfo(hfHelper.invMassD0ToPiK(candidate), hfHelper.invMassD0barToKPi(candidate), candidate.pt(), outputMlD0[0], outputMlD0[2], outputMlD0bar[0], outputMlD0bar[2]); + entryD0CandGenInfo(isD0Prompt); // ===================== Define parameters for soft pion removal ======================== auto ePiK = RecoDecay::e(candidate.pVectorProng0(), massPi) + RecoDecay::e(candidate.pVectorProng1(), massK); @@ -502,14 +617,16 @@ struct HfCorrelatorD0Hadrons { // ============== D-h correlation dedicated section ==================================== - flagD0 = candidate.flagMcMatchRec() == (1 << aod::hf_cand_2prong::DecayType::D0ToPiK); // flagD0Signal 'true' if candidate matched to D0 (particle) - flagD0bar = candidate.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK); // flagD0Reflection 'true' if candidate, selected as D0 (particle), is matched to D0bar (antiparticle) + flagD0 = candidate.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0Signal 'true' if candidate matched to D0 (particle) + flagD0bar = candidate.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0Reflection 'true' if candidate, selected as D0 (particle), is matched to D0bar (antiparticle) // ========== track loop starts here ======================== for (const auto& track : tracks) { - registry.fill(HIST("hTrackCounterRec"), 1); // fill total no. of tracks - + registry.fill(HIST("hTrackCounter"), 0); // fill total no. of tracks + if (!track.isGlobalTrackWoDCA()) { + continue; + } // Removing D0 daughters by checking track indices bool correlationStatus = false; if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex())) { @@ -518,8 +635,10 @@ struct HfCorrelatorD0Hadrons { } correlationStatus = true; } - registry.fill(HIST("hTrackCounterRec"), 2); // fill no. of tracks before soft pion removal + registry.fill(HIST("hTrackCounter"), 1); // fill no. of tracks before soft pion removal + bool isPhysicalPrimary = false; + int trackOrigin = -1; // ===== soft pion removal =================================================== double invMassDstar1 = 0, invMassDstar2 = 0; bool isSoftPiD0 = false, isSoftPiD0bar = false; @@ -542,13 +661,13 @@ struct HfCorrelatorD0Hadrons { } } - registry.fill(HIST("hTrackCounterRec"), 3); // fill no. of tracks after soft pion removal + registry.fill(HIST("hTrackCounter"), 2); // fill no. of tracks after soft pion removal if (correlateD0WithLeadingParticle) { if (track.globalIndex() != leadingIndex) { continue; } - registry.fill(HIST("hTrackCounterRec"), 4); // fill no. of tracks have leading particle + registry.fill(HIST("hTrackCounter"), 3); // fill no. of tracks have leading particle } int signalStatus = 0; @@ -579,105 +698,125 @@ struct HfCorrelatorD0Hadrons { poolBin, correlationStatus); entryD0HadronRecoInfo(hfHelper.invMassD0ToPiK(candidate), hfHelper.invMassD0barToKPi(candidate), signalStatus); + entryD0HadronMlInfo(outputMlD0[0], outputMlD0[1], outputMlD0[2], outputMlD0bar[0], outputMlD0bar[1], outputMlD0bar[2]); + if (track.has_mcParticle()) { + auto mcParticle = track.template mcParticle_as(); + isPhysicalPrimary = mcParticle.isPhysicalPrimary(); + trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); + entryD0HadronGenInfo(isD0Prompt, isPhysicalPrimary, trackOrigin); + } else { + entryD0HadronGenInfo(isD0Prompt, isPhysicalPrimary, 0); + registry.fill(HIST("hTrackCounter"), 4); // fill no. of fake tracks + } + // for secondary particle fraction estimation + registry.fill(HIST("hPtParticleAssocVsCandRec"), track.pt(), candidate.pt()); + if (isPhysicalPrimary) { + registry.fill(HIST("hPtPrimaryParticleAssocVsCandRec"), track.pt(), candidate.pt()); + } + entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.tpcNClsCrossedRows()); } // end inner loop (Tracks) } // end of outer loop (D0) - registry.fill(HIST("hZvtx"), collision.posZ()); - registry.fill(HIST("hMultV0M"), collision.multFT0M()); } PROCESS_SWITCH(HfCorrelatorD0Hadrons, processMcRec, "Process MC Reco mode", true); // ================= Process starts for MCGen, same event =================== - void processMcGen(aod::McCollision const& mcCollision, - soa::Join const& mcParticles) + void processMcGen(SelectedCollisionsMcGen::iterator const& mcCollision, + SelectedParticlesMcGen const& mcParticles) { + BinningTypeMcGen corrBinningMcGen{{zPoolBins, multPoolBinsMcGen}, true}; + int poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), mcCollision.multMCFT0A())); + registry.fill(HIST("hCollisionPoolBin"), poolBin); registry.fill(HIST("hEvtCountGen"), 0); // MC gen level // find leading particle if (correlateD0WithLeadingParticle) { leadingIndex = findLeadingParticleMcGen(mcParticles, etaTrackMax.value, ptTrackMin.value); } - for (const auto& particle1 : mcParticles) { - // check if the particle is D0 or D0bar (for general plot filling and selection, so both cases are fine) - NOTE: decay channel is not probed! - if (std::abs(particle1.pdgCode()) != Pdg::kD0) { - continue; - } - double yD = RecoDecay::y(particle1.pVector(), MassD0); - if (yCandMax >= 0. && std::abs(yD) > yCandMax) { - continue; - } - if (ptCandMin >= 0. && particle1.pt() < ptCandMin) { - continue; - } - registry.fill(HIST("hPtCandGen"), particle1.pt()); - registry.fill(HIST("hEtaGen"), particle1.eta()); - registry.fill(HIST("hPhiGen"), particle1.phi()); - registry.fill(HIST("hYGen"), yD); - - // =============== D-h correlation dedicated section ===================== + bool isD0Prompt = false; + bool isD0NonPrompt = false; + int trackOrigin = -1; - if (std::abs(particle1.pdgCode()) != Pdg::kD0) { // just checking the particle PDG, not the decay channel (differently from Reco: you have a BR factor btw such levels!) + for (const auto& particleTrigg : mcParticles) { + if (std::abs(particleTrigg.pdgCode()) != Pdg::kD0) { continue; } - registry.fill(HIST("hCountD0TriggersGen"), 0, particle1.pt()); // to count trigger D0 (for normalisation) - - for (const auto& particle2 : mcParticles) { - registry.fill(HIST("hTrackCounterGen"), 1); // total no. of tracks - if (std::abs(particle2.eta()) > etaTrackMax) { - continue; - } - if (particle2.pt() < ptTrackMin) { + if (std::abs(particleTrigg.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + double yD = RecoDecay::y(particleTrigg.pVector(), MassD0); + if (yCandMax >= 0. && std::abs(yD) > yCandMax) { continue; } - if ((std::abs(particle2.pdgCode()) != kElectron) && (std::abs(particle2.pdgCode()) != kMuonMinus) && (std::abs(particle2.pdgCode()) != kPiPlus) && (std::abs(particle2.pdgCode()) != kKPlus) && (std::abs(particle2.pdgCode()) != kProton)) { + if (ptCandMin >= 0. && particleTrigg.pt() < ptCandMin) { continue; } - // ==============================soft pion removal================================ - registry.fill(HIST("hTrackCounterGen"), 2); // fill before soft pi removal - // method used: indexMother = -1 by default if the mother doesn't match with given PID of the mother. We find mother of pion if it is D* and mother of D0 if it is D*. If they are both positive and they both match each other, then it is detected as a soft pion + registry.fill(HIST("hD0PoolBin"), poolBin); + registry.fill(HIST("hPtCandGen"), particleTrigg.pt()); + registry.fill(HIST("hEtaGen"), particleTrigg.eta()); + registry.fill(HIST("hPhiGen"), particleTrigg.phi()); + registry.fill(HIST("hYGen"), yD); + registry.fill(HIST("hCountD0TriggersGen"), 0, particleTrigg.pt()); // to count trigger D0 (for normalisation) + + isD0Prompt = particleTrigg.originMcGen() == RecoDecay::OriginType::Prompt; + isD0NonPrompt = particleTrigg.originMcGen() == RecoDecay::OriginType::NonPrompt; + + // prompt and non-prompt division + if (isD0Prompt) { + registry.fill(HIST("hPtCandGenPrompt"), particleTrigg.pt()); + } else if (isD0NonPrompt) { + registry.fill(HIST("hPtCandGenNonPrompt"), particleTrigg.pt()); + } - auto indexMotherPi = RecoDecay::getMother(mcParticles, particle2, Pdg::kDStar, true, nullptr, 1); // last arguement 1 is written to consider immediate decay mother only - auto indexMotherD0 = RecoDecay::getMother(mcParticles, particle1, Pdg::kDStar, true, nullptr, 1); - bool correlationStatus = false; - if (std::abs(particle2.pdgCode()) == kPiPlus && indexMotherPi >= 0 && indexMotherD0 >= 0 && indexMotherPi == indexMotherD0) { - if (!storeAutoCorrelationFlag) { + // =============== D-h correlation dedicated section ===================== + for (const auto& particleAssoc : mcParticles) { + registry.fill(HIST("hTrackCounter"), 0); // total no. of tracks + if (std::abs(particleAssoc.eta()) > etaTrackMax) { continue; } - correlationStatus = true; - } - - registry.fill(HIST("hTrackCounterGen"), 3); // fill after soft pion removal - - if (correlateD0WithLeadingParticle) { - if (particle2.globalIndex() != leadingIndex) { + if (particleAssoc.pt() < ptTrackMin) { continue; } - registry.fill(HIST("hTrackCounterGen"), 4); // fill no. of tracks have leading particle - } + if ((std::abs(particleAssoc.pdgCode()) != kElectron) && (std::abs(particleAssoc.pdgCode()) != kMuonMinus) && (std::abs(particleAssoc.pdgCode()) != kPiPlus) && (std::abs(particleAssoc.pdgCode()) != kKPlus) && (std::abs(particleAssoc.pdgCode()) != kProton)) { + continue; + } + if (!particleAssoc.isPhysicalPrimary()) { + continue; + } + // ==============================soft pion removal================================ + registry.fill(HIST("hTrackCounter"), 1); // fill before soft pi removal + // method used: indexMother = -1 by default if the mother doesn't match with given PID of the mother. We find mother of pion if it is D* and mother of D0 if it is D*. If they are both positive and they both match each other, then it is detected as a soft pion + + auto indexMotherPi = RecoDecay::getMother(mcParticles, particleAssoc, Pdg::kDStar, true, nullptr, 1); // last arguement 1 is written to consider immediate decay mother only + auto indexMotherD0 = RecoDecay::getMother(mcParticles, particleTrigg, Pdg::kDStar, true, nullptr, 1); + bool correlationStatus = false; + if (std::abs(particleAssoc.pdgCode()) == kPiPlus && indexMotherPi >= 0 && indexMotherD0 >= 0 && indexMotherPi == indexMotherD0) { + if (!storeAutoCorrelationFlag) { + continue; + } + correlationStatus = true; + } - auto getTracksSize = [&mcParticles](aod::McCollision const& /*collision*/) { - int nTracks = 0; - for (const auto& track : mcParticles) { - if (track.isPhysicalPrimary() && std::abs(track.eta()) < 1.0) { - nTracks++; + registry.fill(HIST("hTrackCounter"), 2); // fill after soft pion removal + + if (correlateD0WithLeadingParticle) { + if (particleAssoc.globalIndex() != leadingIndex) { + continue; } + registry.fill(HIST("hTrackCounter"), 3); // fill no. of tracks have leading particle } - return nTracks; - }; - using BinningTypeMcGen = FlexibleBinningPolicy, aod::mccollision::PosZ, decltype(getTracksSize)>; - BinningTypeMcGen corrBinningMcGen{{getTracksSize}, {zPoolBins, multPoolBinsMcGen}, true}; - int poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), getTracksSize(mcCollision))); - entryD0HadronPair(getDeltaPhi(particle2.phi(), particle1.phi()), - particle2.eta() - particle1.eta(), - particle1.pt(), - particle2.pt(), - poolBin, - correlationStatus); - entryD0HadronRecoInfo(massD0, massD0, 0); // dummy info - } // end inner loop (Tracks) - } // end outer loop (D0) + trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true); + entryD0HadronPair(getDeltaPhi(particleAssoc.phi(), particleTrigg.phi()), + particleAssoc.eta() - particleTrigg.eta(), + particleTrigg.pt(), + particleAssoc.pt(), + poolBin, + correlationStatus); + entryD0HadronRecoInfo(massD0, massD0, 0); // dummy info + entryD0HadronGenInfo(isD0Prompt, particleAssoc.isPhysicalPrimary(), trackOrigin); + } // end inner loop (Tracks) + } + } // end outer loop (D0) } PROCESS_SWITCH(HfCorrelatorD0Hadrons, processMcGen, "Process MC Gen mode", false); @@ -697,52 +836,58 @@ struct HfCorrelatorD0Hadrons { Pair pairData{corrBinning, numberEventsMixed, -1, collisions, tracksTuple, &cache}; for (const auto& [c1, tracks1, c2, tracks2] : pairData) { + if (tracks1.size() == 0) { + continue; + } // LOGF(info, "Mixed event collisions: Index = (%d, %d), tracks Size: (%d, %d), Z Vertex: (%f, %f), Pool Bin: (%d, %d)", c1.globalIndex(), c2.globalIndex(), tracks1.size(), tracks2.size(), c1.posZ(), c2.posZ(), corrBinning.getBin(std::make_tuple(c1.posZ(), c1.multFT0M())),corrBinning.getBin(std::make_tuple(c2.posZ(), c2.multFT0M()))); // For debug int poolBin = corrBinning.getBin(std::make_tuple(c2.posZ(), c2.multFT0M())); - for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + int poolBinD0 = corrBinning.getBin(std::make_tuple(c1.posZ(), c1.multFT0M())); + registry.fill(HIST("hTracksPoolBin"), poolBin); + registry.fill(HIST("hD0PoolBin"), poolBinD0); + for (const auto& [candidate, particleAssoc] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - if (std::abs(hfHelper.yD0(t1)) >= yCandMax) { + if (std::abs(hfHelper.yD0(candidate)) >= yCandMax || candidate.pt() < ptCandMin) { continue; } // soft pion removal, signal status 1,3 for D0 and 2,3 for D0bar (SoftPi removed), signal status 11,13 for D0 and 12,13 for D0bar (only SoftPi) - auto ePiK = RecoDecay::e(t1.pVectorProng0(), massPi) + RecoDecay::e(t1.pVectorProng1(), massK); - auto eKPi = RecoDecay::e(t1.pVectorProng0(), massK) + RecoDecay::e(t1.pVectorProng1(), massPi); + auto ePiK = RecoDecay::e(candidate.pVectorProng0(), massPi) + RecoDecay::e(candidate.pVectorProng1(), massK); + auto eKPi = RecoDecay::e(candidate.pVectorProng0(), massK) + RecoDecay::e(candidate.pVectorProng1(), massPi); double invMassDstar1 = 0., invMassDstar2 = 0.; bool isSoftPiD0 = false, isSoftPiD0bar = false; - auto pSum2 = RecoDecay::p2(t1.pVector(), t2.pVector()); - auto ePion = t2.energy(massPi); + auto pSum2 = RecoDecay::p2(candidate.pVector(), particleAssoc.pVector()); + auto ePion = particleAssoc.energy(massPi); invMassDstar1 = std::sqrt((ePiK + ePion) * (ePiK + ePion) - pSum2); invMassDstar2 = std::sqrt((eKPi + ePion) * (eKPi + ePion) - pSum2); std::vector outputMlD0 = {-1., -1., -1.}; std::vector outputMlD0bar = {-1., -1., -1.}; - if (t1.isSelD0() >= selectionFlagD0) { - if ((std::abs(invMassDstar1 - hfHelper.invMassD0ToPiK(t1)) - softPiMass) < ptSoftPionMax) { + if (candidate.isSelD0() >= selectionFlagD0) { + if ((std::abs(invMassDstar1 - hfHelper.invMassD0ToPiK(candidate)) - softPiMass) < ptSoftPionMax) { isSoftPiD0 = true; } for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { - outputMlD0[iclass] = t1.mlProbD0()[classMl->at(iclass)]; + outputMlD0[iclass] = candidate.mlProbD0()[classMl->at(iclass)]; } } - if (t1.isSelD0bar() >= selectionFlagD0bar) { - if ((std::abs(invMassDstar2 - hfHelper.invMassD0barToKPi(t1)) - softPiMass) < ptSoftPionMax) { + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + if ((std::abs(invMassDstar2 - hfHelper.invMassD0barToKPi(candidate)) - softPiMass) < ptSoftPionMax) { isSoftPiD0bar = true; } for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { - outputMlD0bar[iclass] = t1.mlProbD0bar()[classMl->at(iclass)]; + outputMlD0bar[iclass] = candidate.mlProbD0bar()[classMl->at(iclass)]; } } int signalStatus = 0; - if (t1.isSelD0() >= selectionFlagD0) { + if (candidate.isSelD0() >= selectionFlagD0) { if (!isSoftPiD0) { signalStatus += aod::hf_correlation_d0_hadron::ParticleTypeData::D0Only; } else { signalStatus += aod::hf_correlation_d0_hadron::ParticleTypeData::D0OnlySoftPi; } } - if (t1.isSelD0bar() >= selectionFlagD0bar) { + if (candidate.isSelD0bar() >= selectionFlagD0bar) { if (!isSoftPiD0bar) { signalStatus += aod::hf_correlation_d0_hadron::ParticleTypeData::D0barOnly; } else { @@ -750,9 +895,11 @@ struct HfCorrelatorD0Hadrons { } } bool correlationStatus = false; - entryD0HadronPair(getDeltaPhi(t1.phi(), t2.phi()), t1.eta() - t2.eta(), t1.pt(), t2.pt(), poolBin, correlationStatus); - entryD0HadronRecoInfo(hfHelper.invMassD0ToPiK(t1), hfHelper.invMassD0barToKPi(t1), signalStatus); + entryD0HadronPair(getDeltaPhi(candidate.phi(), particleAssoc.phi()), candidate.eta() - particleAssoc.eta(), candidate.pt(), particleAssoc.pt(), poolBin, correlationStatus); + entryD0HadronRecoInfo(hfHelper.invMassD0ToPiK(candidate), hfHelper.invMassD0barToKPi(candidate), signalStatus); + entryD0HadronGenInfo(false, false, 0); entryD0HadronMlInfo(outputMlD0[0], outputMlD0[1], outputMlD0[2], outputMlD0bar[0], outputMlD0bar[1], outputMlD0bar[2]); + entryTrackRecoInfo(particleAssoc.dcaXY(), particleAssoc.dcaZ(), particleAssoc.tpcNClsCrossedRows()); } } } @@ -761,49 +908,77 @@ struct HfCorrelatorD0Hadrons { // ====================== Implement Event mixing on McRec =================================== void processMcRecMixedEvent(SelectedCollisions const& collisions, - SelectedCandidatesMcRec const& candidates, - SelectedTracksMcRec const& tracks) + SelectedCandidatesMcRecMl const& candidates, + SelectedTracksMcRec const& tracks, + aod::McParticles const& mcParticles) { auto tracksTuple = std::make_tuple(candidates, tracks); - Pair pairMcRec{corrBinning, numberEventsMixed, -1, collisions, tracksTuple, &cache}; + Pair pairMcRec{corrBinning, numberEventsMixed, -1, collisions, tracksTuple, &cache}; + bool isD0Prompt = false; bool flagD0 = false; bool flagD0bar = false; + bool isPhysicalPrimary = false; + int trackOrigin = 0; for (const auto& [c1, tracks1, c2, tracks2] : pairMcRec) { int poolBin = corrBinning.getBin(std::make_tuple(c2.posZ(), c2.multFT0M())); + int poolBinD0 = corrBinning.getBin(std::make_tuple(c1.posZ(), c1.multFT0M())); + registry.fill(HIST("hTracksPoolBin"), poolBin); + registry.fill(HIST("hD0PoolBin"), poolBinD0); + registry.fill(HIST("hMultFT0M"), c1.multFT0M()); + registry.fill(HIST("hZvtx"), c1.posZ()); - for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + for (const auto& [candidate, particleAssoc] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - if (std::abs(hfHelper.yD0(t1)) >= yCandMax) { + if (std::abs(hfHelper.yD0(candidate)) >= yCandMax || candidate.pt() < ptCandMin) { continue; } - + if (!particleAssoc.isGlobalTrackWoDCA()) { + continue; + } + std::vector outputMlD0 = {-1., -1., -1.}; + std::vector outputMlD0bar = {-1., -1., -1.}; + isD0Prompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; + if (particleAssoc.has_mcParticle()) { + auto mcParticle = particleAssoc.template mcParticle_as(); + isPhysicalPrimary = mcParticle.isPhysicalPrimary(); + trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); + } + if (candidate.isSelD0() >= selectionFlagD0) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMlD0[iclass] = candidate.mlProbD0()[classMl->at(iclass)]; + } + } else if (candidate.isSelD0bar() >= selectionFlagD0bar) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMlD0bar[iclass] = candidate.mlProbD0bar()[classMl->at(iclass)]; + } + } // soft pion removal - auto ePiK = RecoDecay::e(t1.pVectorProng0(), massPi) + RecoDecay::e(t1.pVectorProng1(), massK); - auto eKPi = RecoDecay::e(t1.pVectorProng0(), massK) + RecoDecay::e(t1.pVectorProng1(), massPi); + auto ePiK = RecoDecay::e(candidate.pVectorProng0(), massPi) + RecoDecay::e(candidate.pVectorProng1(), massK); + auto eKPi = RecoDecay::e(candidate.pVectorProng0(), massK) + RecoDecay::e(candidate.pVectorProng1(), massPi); double invMassDstar1 = 0., invMassDstar2 = 0.; bool isSoftPiD0 = false, isSoftPiD0bar = false; - auto pSum2 = RecoDecay::p2(t1.pVector(), t2.pVector()); - auto ePion = t2.energy(massPi); + auto pSum2 = RecoDecay::p2(candidate.pVector(), particleAssoc.pVector()); + auto ePion = particleAssoc.energy(massPi); invMassDstar1 = std::sqrt((ePiK + ePion) * (ePiK + ePion) - pSum2); invMassDstar2 = std::sqrt((eKPi + ePion) * (eKPi + ePion) - pSum2); - if (t1.isSelD0() >= selectionFlagD0) { - if ((std::abs(invMassDstar1 - hfHelper.invMassD0ToPiK(t1)) - softPiMass) < ptSoftPionMax) { + if (candidate.isSelD0() >= selectionFlagD0) { + if ((std::abs(invMassDstar1 - hfHelper.invMassD0ToPiK(candidate)) - softPiMass) < ptSoftPionMax) { isSoftPiD0 = true; } } - if (t1.isSelD0bar() >= selectionFlagD0bar) { - if ((std::abs(invMassDstar2 - hfHelper.invMassD0barToKPi(t1)) - softPiMass) < ptSoftPionMax) { + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + if ((std::abs(invMassDstar2 - hfHelper.invMassD0barToKPi(candidate)) - softPiMass) < ptSoftPionMax) { isSoftPiD0bar = true; } } - flagD0 = t1.flagMcMatchRec() == (1 << aod::hf_cand_2prong::DecayType::D0ToPiK); // flagD0Signal 'true' if candidate matched to D0 (particle) - flagD0bar = t1.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK); // flagD0Reflection 'true' if candidate, selected as D0 (particle), is matched to D0bar (antiparticle) + flagD0 = candidate.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0Signal 'true' if candidate matched to D0 (particle) + flagD0bar = candidate.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; // flagD0Reflection 'true' if candidate, selected as D0 (particle), is matched to D0bar (antiparticle) int signalStatus = 0; - if (flagD0 && (t1.isSelD0() >= selectionFlagD0)) { + if (flagD0 && (candidate.isSelD0() >= selectionFlagD0)) { if (!isSoftPiD0) { SETBIT(signalStatus, aod::hf_correlation_d0_hadron::ParticleTypeMcRec::D0Sig); // signalStatus += 1; } else { @@ -811,7 +986,7 @@ struct HfCorrelatorD0Hadrons { } } // signal case D0 - if (flagD0bar && (t1.isSelD0() >= selectionFlagD0)) { + if (flagD0bar && (candidate.isSelD0() >= selectionFlagD0)) { if (!isSoftPiD0) { SETBIT(signalStatus, aod::hf_correlation_d0_hadron::ParticleTypeMcRec::D0Ref); // signalStatus += 2; } else { @@ -819,7 +994,7 @@ struct HfCorrelatorD0Hadrons { } } // reflection case D0 - if (!flagD0 && !flagD0bar && (t1.isSelD0() >= selectionFlagD0)) { + if (!flagD0 && !flagD0bar && (candidate.isSelD0() >= selectionFlagD0)) { if (!isSoftPiD0) { SETBIT(signalStatus, aod::hf_correlation_d0_hadron::ParticleTypeMcRec::D0Bg); // signalStatus += 4; } else { @@ -827,7 +1002,7 @@ struct HfCorrelatorD0Hadrons { } } // background case D0 - if (flagD0bar && (t1.isSelD0bar() >= selectionFlagD0bar)) { + if (flagD0bar && (candidate.isSelD0bar() >= selectionFlagD0bar)) { if (!isSoftPiD0bar) { SETBIT(signalStatus, aod::hf_correlation_d0_hadron::ParticleTypeMcRec::D0barSig); // signalStatus += 8; } else { @@ -835,7 +1010,7 @@ struct HfCorrelatorD0Hadrons { } } // signal case D0bar - if (flagD0 && (t1.isSelD0bar() >= selectionFlagD0bar)) { + if (flagD0 && (candidate.isSelD0bar() >= selectionFlagD0bar)) { if (!isSoftPiD0bar) { SETBIT(signalStatus, aod::hf_correlation_d0_hadron::ParticleTypeMcRec::D0barRef); // signalStatus += 16; } else { @@ -843,7 +1018,7 @@ struct HfCorrelatorD0Hadrons { } } // reflection case D0bar - if (!flagD0 && !flagD0bar && (t1.isSelD0bar() >= selectionFlagD0bar)) { + if (!flagD0 && !flagD0bar && (candidate.isSelD0bar() >= selectionFlagD0bar)) { if (!isSoftPiD0bar) { SETBIT(signalStatus, aod::hf_correlation_d0_hadron::ParticleTypeMcRec::D0barBg); // signalStatus += 32; } else { @@ -852,8 +1027,11 @@ struct HfCorrelatorD0Hadrons { } // background case D0bar registry.fill(HIST("hSignalStatusMERec"), signalStatus); bool correlationStatus = false; - entryD0HadronPair(getDeltaPhi(t1.phi(), t2.phi()), t1.eta() - t2.eta(), t1.pt(), t2.pt(), poolBin, correlationStatus); - entryD0HadronRecoInfo(hfHelper.invMassD0ToPiK(t1), hfHelper.invMassD0barToKPi(t1), signalStatus); + entryD0HadronPair(getDeltaPhi(candidate.phi(), particleAssoc.phi()), candidate.eta() - particleAssoc.eta(), candidate.pt(), particleAssoc.pt(), poolBin, correlationStatus); + entryD0HadronRecoInfo(hfHelper.invMassD0ToPiK(candidate), hfHelper.invMassD0barToKPi(candidate), signalStatus); + entryD0HadronGenInfo(isD0Prompt, isPhysicalPrimary, trackOrigin); + entryD0HadronMlInfo(outputMlD0[0], outputMlD0[1], outputMlD0[2], outputMlD0bar[0], outputMlD0bar[1], outputMlD0bar[2]); + entryTrackRecoInfo(particleAssoc.dcaXY(), particleAssoc.dcaZ(), particleAssoc.tpcNClsCrossedRows()); } } } @@ -864,55 +1042,43 @@ struct HfCorrelatorD0Hadrons { void processMcGenMixedEvent(SelectedCollisionsMcGen const& collisions, SelectedParticlesMcGen const& mcParticles) { - - auto getTracksSize = [&mcParticles, this](SelectedCollisionsMcGen::iterator const& collision) { - int nTracks = 0; - auto associatedTracks = mcParticles.sliceByCached(o2::aod::mcparticle::mcCollisionId, collision.globalIndex(), this->cache); - for (const auto& track : associatedTracks) { - if (track.isPhysicalPrimary() && std::abs(track.eta()) < 1.0) { - nTracks++; - } - } - return nTracks; - }; - - using BinningTypeMcGen = FlexibleBinningPolicy, aod::mccollision::PosZ, decltype(getTracksSize)>; - BinningTypeMcGen corrBinningMcGen{{getTracksSize}, {zPoolBins, multPoolBinsMcGen}, true}; - + BinningTypeMcGen corrBinningMcGen{{zPoolBins, multPoolBinsMcGen}, true}; auto tracksTuple = std::make_tuple(mcParticles, mcParticles); Pair pairMcGen{corrBinningMcGen, numberEventsMixed, -1, collisions, tracksTuple, &cache}; for (const auto& [c1, tracks1, c2, tracks2] : pairMcGen) { - for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - - // Check track t1 is D0 - if (std::abs(t1.pdgCode()) != Pdg::kD0) { - continue; - } - - double yD = RecoDecay::y(t1.pVector(), MassD0); - if (std::abs(yD) >= yCandMax || t1.pt() <= ptCandMin || std::abs(t2.eta()) >= etaTrackMax || t2.pt() <= ptTrackMin) { - continue; - } - if ((std::abs(t2.pdgCode()) != kElectron) && (std::abs(t2.pdgCode()) != kMuonMinus) && (std::abs(t2.pdgCode()) != kPiPlus) && (std::abs(t2.pdgCode()) != kKPlus) && (std::abs(t2.pdgCode()) != kProton)) { - continue; - } - if (!t2.isPhysicalPrimary()) { + int poolBin = corrBinningMcGen.getBin(std::make_tuple(c1.posZ(), c1.multMCFT0A())); + for (const auto& [particleTrigg, particleAssoc] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (std::abs(particleTrigg.pdgCode()) != Pdg::kD0) { continue; } + if (std::abs(particleTrigg.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + double yD = RecoDecay::y(particleTrigg.pVector(), MassD0); + if (std::abs(yD) >= yCandMax || particleTrigg.pt() <= ptCandMin || std::abs(particleAssoc.eta()) >= etaTrackMax || particleAssoc.pt() <= ptTrackMin) { + continue; + } + if ((std::abs(particleAssoc.pdgCode()) != kElectron) && (std::abs(particleAssoc.pdgCode()) != kMuonMinus) && (std::abs(particleAssoc.pdgCode()) != kPiPlus) && (std::abs(particleAssoc.pdgCode()) != kKPlus) && (std::abs(particleAssoc.pdgCode()) != kProton)) { + continue; + } + if (!particleAssoc.isPhysicalPrimary()) { + continue; + } - // ==============================soft pion removal================================ - // method used: indexMother = -1 by default if the mother doesn't match with given PID of the mother. We find mother of pion if it is D* and mother of D0 if it is D*. If they are both positive and they both match each other, then it is detected as a soft pion + // ==============================soft pion removal================================ + // method used: indexMother = -1 by default if the mother doesn't match with given PID of the mother. We find mother of pion if it is D* and mother of D0 if it is D*. If they are both positive and they both match each other, then it is detected as a soft pion - auto indexMotherPi = RecoDecay::getMother(mcParticles, t2, Pdg::kDStar, true, nullptr, 1); // last arguement 1 is written to consider immediate decay mother only - auto indexMotherD0 = RecoDecay::getMother(mcParticles, t1, Pdg::kDStar, true, nullptr, 1); - if (std::abs(t2.pdgCode()) == kPiPlus && indexMotherPi >= 0 && indexMotherD0 >= 0 && indexMotherPi == indexMotherD0) { - continue; + auto indexMotherPi = RecoDecay::getMother(mcParticles, particleAssoc, Pdg::kDStar, true, nullptr, 1); // last arguement 1 is written to consider immediate decay mother only + auto indexMotherD0 = RecoDecay::getMother(mcParticles, particleTrigg, Pdg::kDStar, true, nullptr, 1); + if (std::abs(particleAssoc.pdgCode()) == kPiPlus && indexMotherPi >= 0 && indexMotherD0 >= 0 && indexMotherPi == indexMotherD0) { + continue; + } + bool correlationStatus = false; + int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true); + bool isD0Prompt = particleTrigg.originMcGen() == RecoDecay::OriginType::Prompt; + entryD0HadronPair(getDeltaPhi(particleAssoc.phi(), particleTrigg.phi()), particleAssoc.eta() - particleTrigg.eta(), particleTrigg.pt(), particleAssoc.pt(), poolBin, correlationStatus); + entryD0HadronRecoInfo(massD0, massD0, 0); // dummy info + entryD0HadronGenInfo(isD0Prompt, particleAssoc.isPhysicalPrimary(), trackOrigin); } - int poolBin = corrBinningMcGen.getBin(std::make_tuple(c2.posZ(), getTracksSize(c2))); - bool correlationStatus = false; - entryD0HadronPair(getDeltaPhi(t2.phi(), t1.phi()), t2.eta() - t1.eta(), t1.pt(), t2.pt(), poolBin, correlationStatus); - entryD0HadronRecoInfo(massD0, massD0, 0); // dummy info } } } diff --git a/PWGHF/HFC/TableProducer/correlatorDMesonPairs.cxx b/PWGHF/HFC/TableProducer/correlatorDMesonPairs.cxx index 45ad4877388..8616569468c 100644 --- a/PWGHF/HFC/TableProducer/correlatorDMesonPairs.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDMesonPairs.cxx @@ -14,21 +14,39 @@ /// /// \author Andrea Tavira García , IJCLab Orsay -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponseD0ToKPi.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/DMesonPairsTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::constants::physics; @@ -55,10 +73,9 @@ enum PairTypeOfSelMassSel { using McParticlesPlus2Prong = soa::Join; struct HfCorrelatorDMesonPairs { - SliceCache cache; - Preslice perCol2Prong = aod::hf_cand::collisionId; Produces entryD0Pair; + Produces entryD0PairMl; Produces entryD0PairMcInfo; Produces entryD0PairMcGen; Produces entryD0PairMcGenInfo; @@ -72,17 +89,55 @@ struct HfCorrelatorDMesonPairs { Configurable selectSignalRegionOnly{"selectSignalRegionOnly", false, "only use events close to PDG peak"}; Configurable massCut{"massCut", 0.05, "Maximum deviation from PDG peak allowed for signal region"}; Configurable daughterTracksCutFlag{"daughterTracksCutFlag", false, "Flag to add cut on daughter tracks"}; + Configurable removeAmbiguous{"removeAmbiguous", false, "Flag to remove ambiguous candidates"}; + Configurable ptMaxRemoveAmbiguous{"ptMaxRemoveAmbiguous", 5.0, "Max. pT to remove the ambiguous candidates"}; + + // ML inference + Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; + Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; + Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; + + // ML model CCDB configuration + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"EventFiltering/PWGHF/BDTD0"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_D0ToKPi.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; HfHelper hfHelper; + SliceCache cache; + Preslice perCol2Prong = aod::hf_cand::collisionId; + + o2::analysis::HfMlResponseD0ToKPi hfMlResponse; + o2::ccdb::CcdbApi ccdbApi; + + std::vector outputMlD0Cand1 = {}; + std::vector outputMlD0barCand1 = {}; + + std::vector outputMlD0Cand2 = {}; + std::vector outputMlD0barCand2 = {}; // using TracksWPid = soa::Join; - Partition> selectedD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar; - Partition> selectedD0CandidatesMc = aod::hf_sel_candidate_d0::isRecoHfFlag >= selectionFlagHf; + Partition> selectedD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar; + Partition> selectedD0CandidatesMc = aod::hf_sel_candidate_d0::isRecoHfFlag >= selectionFlagHf; + + // ThnSparse for ML outputScores and Vars + ConfigurableAxis thnConfigAxisBkgScore{"thnConfigAxisBkgScore", {100, 0, 1}, "Bkg score bins"}; + ConfigurableAxis thnConfigAxisSignalScore{"thnConfigAxisSignalScore", {100, 0, 1}, "Signal score bins"}; + ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {120, 1.5848, 2.1848}, "Cand. inv-mass bins"}; + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {500, 0, 50}, "Cand. pT bins"}; + ConfigurableAxis thnConfigAxisY{"thnConfigAxisY", {20, -1, 1}, "Cand. rapidity bins"}; + ConfigurableAxis thnConfigAxisOrigin{"thnConfigAxisOrigin", {3, -0.5, 2.5}, "Cand. origin type"}; + ConfigurableAxis thnConfigAxisCandType{"thnConfigAxisCandType", {6, -0.5, 5.5}, "D0 type"}; + ConfigurableAxis thnConfigAxisNumPvContr{"thnConfigAxisNumPvContr", {200, -0.5, 199.5}, "Number of PV contributors"}; HistogramConfigSpec hTH1Pt{HistType::kTH1F, {{180, 0., 36.}}}; HistogramConfigSpec hTH1Y{HistType::kTH1F, {{100, -5., 5.}}}; - HistogramConfigSpec hTH1NContrib{HistType::kTH1F, {{120, -0.5, 119.5}}}; + HistogramConfigSpec hTH1NContrib{HistType::kTH1F, {{200, -0.5, 199.5}}}; HistogramConfigSpec hTH1Phi{HistType::kTH1F, {{32, 0., o2::constants::math::TwoPI}}}; HistogramConfigSpec hTH2Pid{HistType::kTH2F, {{500, 0., 10.}, {400, -20., 20.}}}; HistogramConfigSpec hTH3PtVsYVsNContrib{HistType::kTH3F, {{360, 0., 36.}, {20, -1., 1.}, {120, -0.5, 119.5}}}; @@ -96,16 +151,21 @@ struct HfCorrelatorDMesonPairs { {"hEta", "D meson candidates;candidate #it{#eta};entries", hTH1Y}, {"hPhi", "D meson candidates;candidate #it{#varphi};entries", hTH1Phi}, {"hY", "D meson candidates;candidate #it{y};entries", hTH1Y}, + {"hPVContrib", "D meson candidates;candidate Number of PV contributors;entries", hTH1NContrib}, // MC Gen plots {"hPtCandMcGen", "D meson candidates MC Gen;candidate #it{p}_{T} (GeV/#it{c});entries", hTH1Pt}, {"hPtCandAfterCutMcGen", "D meson candidates after pT cut;candidate #it{p}_{T} (GeV/#it{c});entries", hTH1Pt}, {"hEtaMcGen", "D meson candidates MC Gen;candidate #it{#eta};entries", hTH1Y}, {"hPhiMcGen", "D meson candidates MC Gen;candidate #it{#varphi};entries", hTH1Phi}, {"hPtVsYVsNContribMcGen", "D meson candidates MC Gen;candidate #it{p}_{T} (GeV/#it{c});#it{y};Number of contributors", hTH3PtVsYVsNContrib}, - {"hNContribMcGen", "D meson candidates MC Gen;Number of contributors", hTH1NContrib}, + {"hPtVsYVsNContribMcGenPrompt", "D meson candidates MC Gen Prompt;candidate #it{p}_{T} (GeV/#it{c});#it{y};Number of contributors", hTH3PtVsYVsNContrib}, + {"hPtVsYVsNContribMcGenNonPrompt", "D meson candidates MC Gen Prompt;candidate #it{p}_{T} (GeV/#it{c});#it{y};Number of contributors", hTH3PtVsYVsNContrib}, + {"hNContribMcGen", "D meson candidates MC Gen;Number of PV contributors", hTH1NContrib}, // MC Rec plots {"hPtVsYVsNContribMcRec", "D meson candidates MC Rec;candidate #it{p}_{T} (GeV/#it{c});#it{y};Number of contributors", hTH3PtVsYVsNContrib}, - {"hNContribMcRec", "D meson candidates MC Rec;Number of contributors", hTH1NContrib}, + {"hPtVsYVsNContribMcRecPrompt", "D meson candidates MC Rec Prompt;candidate #it{p}_{T} (GeV/#it{c});#it{y};Number of contributors", hTH3PtVsYVsNContrib}, + {"hPtVsYVsNContribMcRecNonPrompt", "D meson candidates MC Rec Non-prompt;candidate #it{p}_{T} (GeV/#it{c});#it{y};Number of contributors", hTH3PtVsYVsNContrib}, + {"hNContribMcRec", "D meson candidates MC Rec;Number of PV contributors", hTH1NContrib}, // PID plots ----- Not definitively here {"PID/hTofNSigmaPi", "(TOFsignal-time#pi)/tofSigPid;p[GeV/c];(TOFsignal-time#pi)/tofSigPid", hTH2Pid}, {"PID/hTofNSigmaKa", "(TOFsignal-timeK)/tofSigPid;p[GeV/c];(TOFsignal-timeK)/tofSigPid", hTH2Pid}, @@ -116,6 +176,19 @@ struct HfCorrelatorDMesonPairs { void init(InitContext&) { + + if (applyMl) { + hfMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponse.setModelPathsLocal(onnxFileNames); + } + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponse.init(); + } + auto vbins = (std::vector)binsPt; constexpr int kNBinsSelStatus = 25; std::string labels[kNBinsSelStatus]; @@ -215,6 +288,28 @@ struct HfCorrelatorDMesonPairs { registry.add("hMassMcRecPrompt", "D Meson pair candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{120, 1.5848, 2.1848}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("hMassMcRecNonPrompt", "D Meson pair candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{120, 1.5848, 2.1848}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("hMassMcRecReflections", "D Meson pair candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{120, 1.5848, 2.1848}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + + const AxisSpec thnAxisMass{thnConfigAxisMass, "inv. mass (#pi K) (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisY{thnConfigAxisY, "y"}; + const AxisSpec thnAxisOrigin{thnConfigAxisOrigin, "Origin"}; + const AxisSpec thnAxisCandType{thnConfigAxisCandType, "D0 type"}; + const AxisSpec thnAxisNumPvContr{thnConfigAxisNumPvContr, "Number of PV contributors"}; + + std::vector axes = {thnAxisMass, thnAxisPt, thnAxisY, thnAxisNumPvContr, thnAxisOrigin, thnAxisCandType}; + if (applyMl) { + const AxisSpec thnAxisBkgScore{thnConfigAxisBkgScore, "BDT score bkg"}; + const AxisSpec thnAxisSignalScore{thnConfigAxisSignalScore, "BDT score signal"}; + + axes.insert(axes.begin(), thnAxisSignalScore); + axes.insert(axes.begin(), thnAxisBkgScore); + + registry.add("hnDMesonMl", "THn for D Meson candidates", HistType::kTHnSparseD, axes); + registry.get(HIST("hnDMesonMl"))->Sumw2(); + } else { + registry.add("hnDMeson", "Thn for D0 candidates", HistType::kTHnSparseD, axes); + registry.get(HIST("hnDMeson"))->Sumw2(); + } } /// Sets bits to select candidate type for D0 @@ -232,10 +327,10 @@ struct HfCorrelatorDMesonPairs { SETBIT(candidateType, SelectedDbar); } if constexpr (isMcRec) { - if (candidate.flagMcMatchRec() == 1 << o2::aod::hf_cand_2prong::DecayType::D0ToPiK) { // matched as D0 + if (candidate.flagMcMatchRec() == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // matched as D0 SETBIT(candidateType, TrueD); } - if (candidate.flagMcMatchRec() == -(1 << o2::aod::hf_cand_2prong::DecayType::D0ToPiK)) { // matched as D0bar + if (candidate.flagMcMatchRec() == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { // matched as D0bar SETBIT(candidateType, TrueDbar); } } @@ -293,7 +388,7 @@ struct HfCorrelatorDMesonPairs { /// Fill PID related plots for D0 and D0bar /// \param candidate is candidate template - void AnalysePid(const T& candidate) + void analysePid(const T& candidate) { if (candidate.isSelD0() >= selectionFlagD0) { registry.fill(HIST("PID/hTofNSigmaPi"), candidate.ptProng0(), candidate.nSigTofPi0()); @@ -316,7 +411,7 @@ struct HfCorrelatorDMesonPairs { /// Fill counters for D0 and D0bar /// \param selectedD0Candidates contains all D0 candidates template - void GetCountersPerEvent(const T& selectedD0Candidates) + void getCountersPerEvent(const T& selectedD0Candidates) { int nDevent = 0, nDbarevent = 0, nDDbarevent = 0, nDorDbarevent = 0; for (const auto& candidate : selectedD0Candidates) { @@ -328,18 +423,12 @@ struct HfCorrelatorDMesonPairs { } auto candidateType1 = assignCandidateTypeD0(candidate); // Candidate type attribution registry.fill(HIST("hPtCand"), candidate.pt()); - if (abs(hfHelper.yD0(candidate)) > yCandMax) { + if (std::abs(hfHelper.yD0(candidate)) > yCandMax) { continue; } if (ptCandMin >= 0. && candidate.pt() < ptCandMin) { continue; } - registry.fill(HIST("hPtProng0"), candidate.ptProng0()); - registry.fill(HIST("hPtProng1"), candidate.ptProng1()); - registry.fill(HIST("hEta"), candidate.eta()); - registry.fill(HIST("hPhi"), candidate.phi()); - registry.fill(HIST("hY"), candidate.y(MassD0)); - registry.fill(HIST("hPtCandAfterCut"), candidate.pt()); bool isDCand1 = isD(candidateType1); bool isDbarCand1 = isDbar(candidateType1); @@ -382,7 +471,7 @@ struct HfCorrelatorDMesonPairs { /// Fill selection status histogram void fillEntry(const bool& isDCand1, const bool& isDbarCand1, const bool& isDCand2, const bool& isDbarCand2, - const uint8_t& candidateType1, const uint8_t& candidateType2, float yCand1, float yCand2, + const uint8_t& candidateType1, const uint8_t& candidateType2, float yCand1, float yCand2, float phiCand1, float phiCand2, double ptCand1, double ptCand2, float massDCand1, float massDbarCand1, float massDCand2, float massDbarCand2) { @@ -437,24 +526,70 @@ struct HfCorrelatorDMesonPairs { } } - entryD0Pair(ptCand1, ptCand2, yCand1, yCand2, massDCand1, massDbarCand1, massDCand2, massDbarCand2, pairType, candidateType1, candidateType2); + entryD0Pair(ptCand1, ptCand2, yCand1, yCand2, phiCand1, phiCand2, massDCand1, massDbarCand1, massDCand2, massDbarCand2, pairType, candidateType1, candidateType2); + } + + void fillMcHistos(int8_t matchedRec1, int8_t matchedRec2, int8_t isTrueDCand1, int8_t isTrueDbarCand1, int8_t isTrueDCand2, int8_t isTrueDbarCand2) + { + // Fill hMatchingMcRec - Cand 1 + registry.fill(HIST("hMatchingMcRec"), 1); + if (matchedRec1 == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + registry.fill(HIST("hMatchingMcRec"), 2); + } else if (matchedRec1 == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + registry.fill(HIST("hMatchingMcRec"), 3); + } else if (matchedRec1 == 0) { + registry.fill(HIST("hMatchingMcRec"), 4); + } + // Fill hMatchingMcRec - Cand 2 + registry.fill(HIST("hMatchingMcRec"), 5); + if (matchedRec2 == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + registry.fill(HIST("hMatchingMcRec"), 6); + } else if (matchedRec2 == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + registry.fill(HIST("hMatchingMcRec"), 7); + } else if (matchedRec2 == 0) { + registry.fill(HIST("hMatchingMcRec"), 8); + } + // Fill True info + if (isTrueDCand1) { + registry.fill(HIST("hSelectionStatus"), 6); + } else if (isTrueDbarCand1) { + registry.fill(HIST("hSelectionStatus"), 7); + } + if (isTrueDCand2) { + registry.fill(HIST("hSelectionStatus"), 12); + } else if (isTrueDbarCand2) { + registry.fill(HIST("hSelectionStatus"), 13); + } + if (isTrueDCand1 && isTrueDCand2) { + registry.fill(HIST("hSelectionStatus"), 22); + } else if (isTrueDbarCand1 && isTrueDbarCand2) { + registry.fill(HIST("hSelectionStatus"), 23); + } else if (isTrueDCand1 && isTrueDbarCand2) { + registry.fill(HIST("hSelectionStatus"), 24); + } else if (isTrueDbarCand1 && isTrueDCand2) { + registry.fill(HIST("hSelectionStatus"), 25); + } } /// D0(bar)-D0(bar) correlation pair builder - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) void processData(aod::Collision const& collision, - soa::Join const& candidates, aod::Tracks const&) + soa::Join const& candidates, aod::Tracks const&) { for (const auto& candidate : candidates) { - AnalysePid(candidate); + analysePid(candidate); } auto selectedD0CandidatesGrouped = selectedD0Candidates->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); - GetCountersPerEvent(selectedD0CandidatesGrouped); + getCountersPerEvent(selectedD0CandidatesGrouped); // protection against empty tables to be sliced if (selectedD0Candidates.size() <= 1) { return; } for (const auto& candidate1 : selectedD0CandidatesGrouped) { - if (abs(hfHelper.yD0(candidate1)) > yCandMax) { + + outputMlD0Cand1.clear(); + outputMlD0barCand1.clear(); + + if (std::abs(hfHelper.yD0(candidate1)) > yCandMax) { continue; } if (ptCandMin >= 0. && candidate1.pt() < ptCandMin) { @@ -473,15 +608,61 @@ struct HfCorrelatorDMesonPairs { bool isDCand1 = isD(candidateType1); bool isDbarCand1 = isDbar(candidateType1); + bool isSelectedMlD0Cand1 = false; + bool isSelectedMlD0barCand1 = false; + + if (applyMl) { + if (isDCand1) { + std::vector inputFeaturesD0 = hfMlResponse.getInputFeatures(candidate1, o2::constants::physics::kD0); + isSelectedMlD0Cand1 = hfMlResponse.isSelectedMl(inputFeaturesD0, candidate1.pt(), outputMlD0Cand1); + } + if (isDbarCand1) { + std::vector inputFeaturesD0bar = hfMlResponse.getInputFeatures(candidate1, o2::constants::physics::kD0Bar); + isSelectedMlD0barCand1 = hfMlResponse.isSelectedMl(inputFeaturesD0bar, candidate1.pt(), outputMlD0barCand1); + } + + // Remove non-ML selected D0 candidates + if (!isSelectedMlD0Cand1 && !isSelectedMlD0barCand1) { + continue; + } + } + + // Remove ambiguous D0 candidates if flag is true + if (removeAmbiguous && (isDCand1 && isDbarCand1) && candidate1.pt() < ptMaxRemoveAmbiguous) { + continue; + } + + registry.fill(HIST("hPtProng0"), candidate1.ptProng0()); + registry.fill(HIST("hPtProng1"), candidate1.ptProng1()); + registry.fill(HIST("hEta"), candidate1.eta()); + registry.fill(HIST("hPhi"), candidate1.phi()); + registry.fill(HIST("hY"), candidate1.y(MassD0)); + registry.fill(HIST("hPtCandAfterCut"), candidate1.pt()); + registry.fill(HIST("hPVContrib"), collision.numContrib()); + if (isDCand1) { registry.fill(HIST("hMass"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt()); + if (applyMl) { + registry.fill(HIST("hnDMesonMl"), outputMlD0Cand1[0], outputMlD0Cand1[1], hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), candidate1.y(MassD0), collision.numContrib(), 0, candidateType1); + } else { + registry.fill(HIST("hnDMeson"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), candidate1.y(MassD0), collision.numContrib(), 0, candidateType1); + } } if (isDbarCand1) { registry.fill(HIST("hMass"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt()); + if (applyMl) { + registry.fill(HIST("hnDMesonMl"), outputMlD0barCand1[0], outputMlD0barCand1[1], hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), candidate1.y(MassD0), collision.numContrib(), 0, candidateType1); + } else { + registry.fill(HIST("hnDMeson"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), candidate1.y(MassD0), collision.numContrib(), 0, candidateType1); + } } for (auto candidate2 = candidate1 + 1; candidate2 != selectedD0CandidatesGrouped.end(); ++candidate2) { - if (abs(hfHelper.yD0(candidate2)) > yCandMax) { + + outputMlD0Cand2.clear(); + outputMlD0barCand2.clear(); + + if (std::abs(hfHelper.yD0(candidate2)) > yCandMax) { continue; } if (ptCandMin >= 0. && candidate2.pt() < ptCandMin) { @@ -503,35 +684,71 @@ struct HfCorrelatorDMesonPairs { bool isDCand2 = isD(candidateType2); bool isDbarCand2 = isDbar(candidateType2); - fillEntry(isDCand1, isDbarCand1, isDCand2, isDbarCand2, candidateType1, candidateType2, hfHelper.yD0(candidate1), hfHelper.yD0(candidate2), - candidate1.pt(), candidate2.pt(), hfHelper.invMassD0ToPiK(candidate1), hfHelper.invMassD0barToKPi(candidate1), - hfHelper.invMassD0ToPiK(candidate2), hfHelper.invMassD0barToKPi(candidate2)); + bool isSelectedMlD0Cand2 = false; + bool isSelectedMlD0barCand2 = false; + + if (applyMl) { + if (isDCand2) { + std::vector inputFeaturesD0 = hfMlResponse.getInputFeatures(candidate2, o2::constants::physics::kD0); + isSelectedMlD0Cand2 = hfMlResponse.isSelectedMl(inputFeaturesD0, candidate2.pt(), outputMlD0Cand2); + } + if (isDbarCand2) { + std::vector inputFeaturesD0bar = hfMlResponse.getInputFeatures(candidate2, o2::constants::physics::kD0Bar); + isSelectedMlD0barCand2 = hfMlResponse.isSelectedMl(inputFeaturesD0bar, candidate2.pt(), outputMlD0barCand2); + } + + // Remove non-ML selected D0 candidates + if (!isSelectedMlD0Cand2 && !isSelectedMlD0barCand2) { + continue; + } + + // Remove ambiguous D0 candidates if flag is true + if (removeAmbiguous && (isDCand2 && isDbarCand2) && candidate2.pt() < ptMaxRemoveAmbiguous) { + continue; + } + + fillEntry(isDCand1, isDbarCand1, isDCand2, isDbarCand2, candidateType1, candidateType2, hfHelper.yD0(candidate1), hfHelper.yD0(candidate2), + candidate1.phi(), candidate2.phi(), candidate1.pt(), candidate2.pt(), hfHelper.invMassD0ToPiK(candidate1), hfHelper.invMassD0barToKPi(candidate1), + hfHelper.invMassD0ToPiK(candidate2), hfHelper.invMassD0barToKPi(candidate2)); + + entryD0PairMl(outputMlD0Cand1, outputMlD0barCand1, outputMlD0Cand2, outputMlD0barCand2); + } else { + // Fill entries + fillEntry(isDCand1, isDbarCand1, isDCand2, isDbarCand2, candidateType1, candidateType2, hfHelper.yD0(candidate1), hfHelper.yD0(candidate2), candidate1.phi(), candidate2.phi(), + candidate1.pt(), candidate2.pt(), hfHelper.invMassD0ToPiK(candidate1), hfHelper.invMassD0barToKPi(candidate1), + hfHelper.invMassD0ToPiK(candidate2), hfHelper.invMassD0barToKPi(candidate2)); + } } // end inner loop (Cand2) } // end outer loop (Cand1) } PROCESS_SWITCH(HfCorrelatorDMesonPairs, processData, "Process data mode", true); - void processMcRec(aod::Collision const& collision, soa::Join const& candidates, aod::Tracks const&) + void processMcRec(aod::Collision const& collision, soa::Join const& candidates, aod::Tracks const&) { for (const auto& candidate : candidates) { - AnalysePid(candidate); + analysePid(candidate); } auto selectedD0CandidatesGroupedMc = selectedD0CandidatesMc->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); - GetCountersPerEvent(selectedD0CandidatesGroupedMc); + getCountersPerEvent(selectedD0CandidatesGroupedMc); // protection against empty tables to be sliced if (selectedD0CandidatesMc.size() <= 1) { return; } for (const auto& candidate1 : selectedD0CandidatesGroupedMc) { + + outputMlD0Cand1.clear(); + outputMlD0barCand1.clear(); + auto ptCandidate1 = candidate1.pt(); auto yCandidate1 = hfHelper.yD0(candidate1); + auto phiCandidate1 = candidate1.phi(); float massD0Cand1 = hfHelper.invMassD0ToPiK(candidate1); float massD0barCand1 = hfHelper.invMassD0barToKPi(candidate1); auto prong0Cand1 = candidate1.template prong0_as(); auto prong1Cand1 = candidate1.template prong1_as(); - if (abs(hfHelper.yD0(candidate1)) > yCandMax) { + if (std::abs(hfHelper.yD0(candidate1)) > yCandMax) { continue; } if (ptCandMin >= 0. && candidate1.pt() < ptCandMin) { @@ -556,34 +773,76 @@ struct HfCorrelatorDMesonPairs { int8_t matchedRec1 = candidate1.flagMcMatchRec(); int8_t originRec1 = candidate1.originMcRec(); + bool isSelectedMlD0Cand1 = false; + bool isSelectedMlD0barCand1 = false; + + if (applyMl) { + if (isDCand1) { + std::vector inputFeaturesD0 = hfMlResponse.getInputFeatures(candidate1, o2::constants::physics::kD0); + isSelectedMlD0Cand1 = hfMlResponse.isSelectedMl(inputFeaturesD0, candidate1.pt(), outputMlD0Cand1); + } + if (isDbarCand1) { + std::vector inputFeaturesD0bar = hfMlResponse.getInputFeatures(candidate1, o2::constants::physics::kD0Bar); + isSelectedMlD0barCand1 = hfMlResponse.isSelectedMl(inputFeaturesD0bar, candidate1.pt(), outputMlD0barCand1); + } + // Remove non-ML selected D0 candidates + if (!isSelectedMlD0Cand1 && !isSelectedMlD0barCand1) { + continue; + } + } + + // Remove ambiguous D0 candidates if flag is true + if (removeAmbiguous && (isDCand1 && isDbarCand1) && candidate1.pt() < ptMaxRemoveAmbiguous) { + continue; + } + if (isTrueDCand1) { registry.fill(HIST("hStatusSinglePart"), 5); } else if (isTrueDbarCand1) { registry.fill(HIST("hStatusSinglePart"), 6); } + registry.fill(HIST("hPtProng0"), candidate1.ptProng0()); + registry.fill(HIST("hPtProng1"), candidate1.ptProng1()); + registry.fill(HIST("hEta"), candidate1.eta()); + registry.fill(HIST("hPhi"), candidate1.phi()); + registry.fill(HIST("hY"), candidate1.y(MassD0)); + registry.fill(HIST("hPtCandAfterCut"), candidate1.pt()); + if (isDCand1) { + if (applyMl) { + registry.fill(HIST("hnDMesonMl"), outputMlD0Cand1[0], outputMlD0Cand1[1], hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), candidate1.y(MassD0), collision.numContrib(), originRec1, candidateType1); + } else { + registry.fill(HIST("hnDMeson"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt(), candidate1.y(MassD0), collision.numContrib(), originRec1, candidateType1); + } if (isTrueDCand1) { registry.fill(HIST("hMass"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt()); registry.fill(HIST("hPtVsYVsNContribMcRec"), candidate1.pt(), hfHelper.yD0(candidate1), collision.numContrib()); registry.fill(HIST("hNContribMcRec"), collision.numContrib()); - if (originRec1 == 1) { + if (originRec1 == RecoDecay::Prompt) { registry.fill(HIST("hMassMcRecPrompt"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt()); - } else if (originRec1 == 2) { + registry.fill(HIST("hPtVsYVsNContribMcRecPrompt"), candidate1.pt(), hfHelper.yD0(candidate1), collision.numContrib()); + } else if (originRec1 == RecoDecay::NonPrompt) { registry.fill(HIST("hMassMcRecNonPrompt"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt()); + registry.fill(HIST("hPtVsYVsNContribMcRecNonPrompt"), candidate1.pt(), hfHelper.yD0(candidate1), collision.numContrib()); } } else if (isTrueDbarCand1) { registry.fill(HIST("hMassMcRecReflections"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt()); } } if (isDbarCand1) { + if (applyMl) { + registry.fill(HIST("hnDMesonMl"), outputMlD0barCand1[0], outputMlD0barCand1[1], hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), candidate1.y(MassD0), collision.numContrib(), originRec1, candidateType1); + } else { + registry.fill(HIST("hnDMeson"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt(), candidate1.y(MassD0), collision.numContrib(), originRec1, candidateType1); + } if (isTrueDbarCand1) { registry.fill(HIST("hMass"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt()); registry.fill(HIST("hPtVsYVsNContribMcRec"), candidate1.pt(), hfHelper.yD0(candidate1), collision.numContrib()); registry.fill(HIST("hNContribMcRec"), collision.numContrib()); - if (originRec1 == 1) { + if (originRec1 == RecoDecay::Prompt) { registry.fill(HIST("hMassMcRecPrompt"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt()); - } else if (originRec1 == 2) { + } else if (originRec1 == RecoDecay::NonPrompt) { registry.fill(HIST("hMassMcRecNonPrompt"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt()); } } else if (isTrueDCand1) { @@ -592,14 +851,19 @@ struct HfCorrelatorDMesonPairs { } for (auto candidate2 = candidate1 + 1; candidate2 != selectedD0CandidatesGroupedMc.end(); ++candidate2) { + + outputMlD0Cand2.clear(); + outputMlD0barCand2.clear(); + auto ptCandidate2 = candidate2.pt(); auto yCandidate2 = hfHelper.yD0(candidate2); + auto phiCandidate2 = candidate2.phi(); float massD0Cand2 = hfHelper.invMassD0ToPiK(candidate2); float massD0barCand2 = hfHelper.invMassD0barToKPi(candidate2); auto prong0Cand2 = candidate2.template prong0_as(); auto prong1Cand2 = candidate2.template prong1_as(); - if (abs(hfHelper.yD0(candidate2)) > yCandMax) { + if (std::abs(hfHelper.yD0(candidate2)) > yCandMax) { continue; } if (ptCandMin >= 0. && candidate2.pt() < ptCandMin) { @@ -626,47 +890,43 @@ struct HfCorrelatorDMesonPairs { int8_t matchedRec2 = candidate2.flagMcMatchRec(); int8_t originRec2 = candidate2.originMcRec(); - // Fill hMatchingMcRec - Cand 1 - registry.fill(HIST("hMatchingMcRec"), 1); - if (matchedRec1 == 1) { - registry.fill(HIST("hMatchingMcRec"), 2); - } else if (matchedRec1 == -1) { - registry.fill(HIST("hMatchingMcRec"), 3); - } else if (matchedRec1 == 0) { - registry.fill(HIST("hMatchingMcRec"), 4); + bool isSelectedMlD0Cand2 = false; + bool isSelectedMlD0barCand2 = false; + + if (applyMl) { + if (isDCand2) { + std::vector inputFeaturesD0 = hfMlResponse.getInputFeatures(candidate2, o2::constants::physics::kD0); + isSelectedMlD0Cand2 = hfMlResponse.isSelectedMl(inputFeaturesD0, candidate2.pt(), outputMlD0Cand2); + } + if (isDbarCand2) { + std::vector inputFeaturesD0bar = hfMlResponse.getInputFeatures(candidate2, o2::constants::physics::kD0Bar); + isSelectedMlD0barCand2 = hfMlResponse.isSelectedMl(inputFeaturesD0bar, candidate2.pt(), outputMlD0barCand2); + } + + // Remove non-ML selected D0 candidates + if (!isSelectedMlD0Cand2 && !isSelectedMlD0barCand2) { + continue; + } + + // Remove ambiguous D0 candidates if flag is true + if (removeAmbiguous && (isDCand2 && isDbarCand2) && candidate2.pt() < ptMaxRemoveAmbiguous) { + continue; + } + + // Fill tables + fillEntry(isDCand1, isDbarCand1, isDCand2, isDbarCand2, candidateType1, candidateType2, yCandidate1, yCandidate2, phiCandidate1, phiCandidate2, + ptCandidate1, ptCandidate2, massD0Cand1, massD0barCand1, massD0Cand2, massD0barCand2); + fillMcHistos(matchedRec1, matchedRec2, isTrueDCand1, isTrueDbarCand1, isTrueDCand2, isTrueDbarCand2); + entryD0PairMcInfo(originRec1, originRec2, matchedRec1, matchedRec2); + entryD0PairMl(outputMlD0Cand1, outputMlD0barCand1, outputMlD0Cand2, outputMlD0barCand2); + + } else { + // Fill tables + fillEntry(isDCand1, isDbarCand1, isDCand2, isDbarCand2, candidateType1, candidateType2, yCandidate1, yCandidate2, phiCandidate1, phiCandidate2, + ptCandidate1, ptCandidate2, massD0Cand1, massD0barCand1, massD0Cand2, massD0barCand2); + fillMcHistos(matchedRec1, matchedRec2, isTrueDCand1, isTrueDbarCand1, isTrueDCand2, isTrueDbarCand2); + entryD0PairMcInfo(originRec1, originRec2, matchedRec1, matchedRec2); } - // Fill hMatchingMcRec - Cand 2 - registry.fill(HIST("hMatchingMcRec"), 5); - if (matchedRec2 == 1) { - registry.fill(HIST("hMatchingMcRec"), 6); - } else if (matchedRec2 == -1) { - registry.fill(HIST("hMatchingMcRec"), 7); - } else if (matchedRec2 == 0) { - registry.fill(HIST("hMatchingMcRec"), 8); - } - // Fill True info - if (isTrueDCand1) { - registry.fill(HIST("hSelectionStatus"), 6); - } else if (isTrueDbarCand1) { - registry.fill(HIST("hSelectionStatus"), 7); - } - if (isTrueDCand2) { - registry.fill(HIST("hSelectionStatus"), 12); - } else if (isTrueDbarCand2) { - registry.fill(HIST("hSelectionStatus"), 13); - } - if (isTrueDCand1 && isTrueDCand2) { - registry.fill(HIST("hSelectionStatus"), 22); - } else if (isTrueDbarCand1 && isTrueDbarCand2) { - registry.fill(HIST("hSelectionStatus"), 23); - } else if (isTrueDCand1 && isTrueDbarCand2) { - registry.fill(HIST("hSelectionStatus"), 24); - } else if (isTrueDbarCand1 && isTrueDCand2) { - registry.fill(HIST("hSelectionStatus"), 25); - } - fillEntry(isDCand1, isDbarCand1, isDCand2, isDbarCand2, candidateType1, candidateType2, yCandidate1, yCandidate2, - ptCandidate1, ptCandidate2, massD0Cand1, massD0barCand1, massD0Cand2, massD0barCand2); - entryD0PairMcInfo(originRec1, originRec2, matchedRec1, matchedRec2); } // end inner loop (Cand2) } // end outer loop (Cand1) } @@ -690,7 +950,7 @@ struct HfCorrelatorDMesonPairs { if (std::abs(particle.pdgCode()) != Pdg::kD0) { continue; } - if (abs(particle.y()) > yCandMax) { + if (std::abs(particle.y()) > yCandMax) { continue; } if (ptCandMin >= 0. && particle.pt() < ptCandMin) { @@ -735,7 +995,7 @@ struct HfCorrelatorDMesonPairs { } registry.fill(HIST("hPtCandMcGen"), particle1.pt()); - if (abs(particle1.y()) > yCandMax) { + if (std::abs(particle1.y()) > yCandMax) { continue; } if (ptCandMin >= 0. && particle1.pt() < ptCandMin) { @@ -767,6 +1027,12 @@ struct HfCorrelatorDMesonPairs { } registry.fill(HIST("hPtVsYVsNContribMcGen"), particle1.pt(), particle1.y(), numPvContributorsGen); + if (originGen1 == RecoDecay::Prompt) { + registry.fill(HIST("hPtVsYVsNContribMcGenPrompt"), particle1.pt(), particle1.y(), numPvContributorsGen); + } + if (originGen1 == RecoDecay::NonPrompt) { + registry.fill(HIST("hPtVsYVsNContribMcGenNonPrompt"), particle1.pt(), particle1.y(), numPvContributorsGen); + } registry.fill(HIST("hNContribMcGen"), numPvContributorsGen); for (auto particle2 = particle1 + 1; particle2 != mcParticles.end(); ++particle2) { @@ -774,7 +1040,7 @@ struct HfCorrelatorDMesonPairs { if (std::abs(particle2.pdgCode()) != Pdg::kD0) { continue; } - if (abs(particle2.y()) > yCandMax) { + if (std::abs(particle2.y()) > yCandMax) { continue; } if (ptCandMin >= 0. && particle2.pt() < ptCandMin) { @@ -792,18 +1058,18 @@ struct HfCorrelatorDMesonPairs { // Fill hMatchingMcGen - Cand 1 registry.fill(HIST("hMatchingMcGen"), 1); - if (matchedGen1 == 1) { + if (matchedGen1 == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMatchingMcGen"), 2); - } else if (matchedGen1 == -1) { + } else if (matchedGen1 == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMatchingMcGen"), 3); } else if (matchedGen1 == 0) { registry.fill(HIST("hMatchingMcGen"), 4); } // Fill hMatchingMcRec - Cand 2 registry.fill(HIST("hMatchingMcGen"), 5); - if (matchedGen2 == 1) { + if (matchedGen2 == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMatchingMcGen"), 6); - } else if (matchedGen2 == -1) { + } else if (matchedGen2 == -o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { registry.fill(HIST("hMatchingMcGen"), 7); } else if (matchedGen2 == 0) { registry.fill(HIST("hMatchingMcGen"), 8); @@ -847,7 +1113,7 @@ struct HfCorrelatorDMesonPairs { } // Fill pair Selection Status - entryD0PairMcGen(particle1.pt(), particle2.pt(), particle1.y(), particle2.y(), massD, massDbar, massD, massDbar, pairType, particleType1, particleType2); + entryD0PairMcGen(particle1.pt(), particle2.pt(), particle1.y(), particle2.y(), particle1.phi(), particle2.phi(), massD, massDbar, massD, massDbar, pairType, particleType1, particleType2); entryD0PairMcGenInfo(originGen1, originGen2, matchedGen1, matchedGen2); } // end inner loop diff --git a/PWGHF/HFC/TableProducer/correlatorDplusDminus.cxx b/PWGHF/HFC/TableProducer/correlatorDplusDminus.cxx index cb70b35e9ad..e4c2e0fe6bb 100644 --- a/PWGHF/HFC/TableProducer/correlatorDplusDminus.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDplusDminus.cxx @@ -14,18 +14,32 @@ /// /// \author Fabio Colamaria , INFN Bari -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include using namespace o2; using namespace o2::analysis; @@ -48,7 +62,7 @@ const double incrementEtaCut = 0.1; const double incrementPtThreshold = 0.5; const double epsilon = 1E-5; -const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_dplus_to_pi_k_pi::nBinsPt; +const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_dplus_to_pi_k_pi::NBinsPt; const double efficiencyDmesonDefault[npTBinsMassAndEfficiency] = {}; auto efficiencyDmeson_v = std::vector{efficiencyDmesonDefault, efficiencyDmesonDefault + npTBinsMassAndEfficiency}; @@ -241,7 +255,7 @@ struct HfCorrelatorDplusDminus { } while (ptCut < ptThresholdForMaxEtaCut - epsilon); } while (etaCut < maxEtaCut - epsilon); } // end inner loop (Dminus) - } // end outer loop (Dplus) + } // end outer loop (Dplus) } PROCESS_SWITCH(HfCorrelatorDplusDminus, processData, "Process data", false); @@ -295,7 +309,7 @@ struct HfCorrelatorDplusDminus { if (outerSecondTrack.sign() == 1) { outerParticleSign = -1; // Dminus (second daughter track is positive) } - if (std::abs(candidate1.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi) { + if (std::abs(candidate1.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { // fill invariant mass plots and per-candidate distributions from Dplus/Dminus signal candidates if (outerParticleSign == 1) { // reco and matched as Dplus registry.fill(HIST("hMassDplusMCRecSig"), hfHelper.invMassDplusToPiKPi(candidate1), candidate1.pt(), efficiencyWeight); @@ -323,7 +337,7 @@ struct HfCorrelatorDplusDminus { if (outerParticleSign == -1) { continue; // reject Dminus in outer loop } - flagDplusSignal = std::abs(candidate1.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi; // flagDplusSignal 'true' if candidate1 matched to Dplus + flagDplusSignal = std::abs(candidate1.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi; // flagDplusSignal 'true' if candidate1 matched to Dplus for (const auto& candidate2 : selectedDPlusCandidatesGroupedMC) { if (!(candidate2.hfflag() & 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi)) { // check decay channel flag for candidate2 continue; @@ -332,7 +346,7 @@ struct HfCorrelatorDplusDminus { if (innerSecondTrack.sign() != 1) { // keep only Dminus (with second daughter track positive) continue; } - flagDminusSignal = std::abs(candidate2.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi; // flagDminusSignal 'true' if candidate2 matched to Dminus + flagDminusSignal = std::abs(candidate2.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi; // flagDminusSignal 'true' if candidate2 matched to Dminus if (yCandMax >= 0. && std::abs(hfHelper.yDplus(candidate2)) > yCandMax) { continue; } @@ -425,7 +439,7 @@ struct HfCorrelatorDplusDminus { // fill pairs vs etaCut plot bool rightDecayChannels = false; - if ((std::abs(particle1.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi) && (std::abs(particle2.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi)) { + if ((std::abs(particle1.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) && (std::abs(particle2.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi)) { rightDecayChannels = true; } do { @@ -458,7 +472,7 @@ struct HfCorrelatorDplusDminus { } while (ptCut < ptThresholdForMaxEtaCut - epsilon); } while (etaCut < maxEtaCut - epsilon); } // end inner loop - } // end outer loop + } // end outer loop registry.fill(HIST("hCountDplusDminusPerEvent"), counterDplusDminus); } PROCESS_SWITCH(HfCorrelatorDplusDminus, processMcGen, "Process MC Gen mode", false); @@ -522,8 +536,8 @@ struct HfCorrelatorDplusDminus { entryDplusDminusRecoInfo(1.869, 1.869, 8); // Dummy - } // end inner loop - } // end outer loop + } // end inner loop + } // end outer loop registry.fill(HIST("hCountCCbarPerEvent"), counterCCbar); registry.fill(HIST("hCountCCbarPerEventBeforeEtaCut"), counterCCbarBeforeEtasel); } diff --git a/PWGHF/HFC/TableProducer/correlatorDplusHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDplusHadrons.cxx index 166ebb7eab8..c10865e21d2 100644 --- a/PWGHF/HFC/TableProducer/correlatorDplusHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDplusHadrons.cxx @@ -10,23 +10,44 @@ // or submit itself to any jurisdiction. /// \file correlatorDplusHadrons.cxx +/// \brief D+-Hadrons correlator task - data-like, MC-reco and MC-Gen analyses /// \author Shyam Kumar -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/Centrality.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "PWGHF/Core/HfHelper.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -43,7 +64,7 @@ double getDeltaPhi(double phiD, double phiHadron) } /// definition of variables for Dplus hadron pairs (in data-like, MC-reco and MC-kine tasks) -const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_dplus_to_pi_k_pi::nBinsPt; +const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_dplus_to_pi_k_pi::NBinsPt; std::vector efficiencyDmeson(npTBinsMassAndEfficiency + 1); // definition of ME variables @@ -159,6 +180,7 @@ struct HfCorrelatorDplusHadrons { Produces entryTrackRecoInfo; Produces entryDplus; Produces entryHadron; + static constexpr std::size_t NDaughters{3u}; Configurable selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for Dplus"}; // 7 corresponds to topo+PID cuts Configurable numberEventsMixed{"numberEventsMixed", 5, "Number of events mixed in ME process"}; @@ -180,19 +202,9 @@ struct HfCorrelatorDplusHadrons { Configurable> binsPtHadron{"binsPtHadron", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for assoc particle"}; Configurable> binsPtEfficiencyD{"binsPtEfficiencyD", std::vector{o2::analysis::hf_cuts_dplus_to_pi_k_pi::vecBinsPt}, "pT bin limits for efficiency"}; Configurable> efficiencyD{"efficiencyD", {1., 1., 1., 1., 1., 1.}, "efficiency values for D+ meson"}; - ConfigurableAxis binsMultiplicity{"binsMultiplicity", {VARIABLE_WIDTH, 0.0f, 2000.0f, 6000.0f, 100000.0f}, "Mixing bins - multiplicity"}; - ConfigurableAxis binsZVtx{"binsZVtx", {VARIABLE_WIDTH, -10.0f, -2.5f, 2.5f, 10.0f}, "Mixing bins - z-vertex"}; - ConfigurableAxis binsMultiplicityMc{"binsMultiplicityMc", {VARIABLE_WIDTH, 0.0f, 20.0f, 50.0f, 500.0f}, "Mixing bins - MC multiplicity"}; // In MCGen multiplicity is defined by counting tracks - ConfigurableAxis binsBdtScore{"binsBdtScore", {100, 0., 1.}, "Bdt output scores"}; - ConfigurableAxis binsEta{"binsEta", {50, -2., 2.}, "#it{#eta}"}; - ConfigurableAxis binsPhi{"binsPhi", {64, -PIHalf, 3. * PIHalf}, "#it{#varphi}"}; - ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; - ConfigurableAxis binsMultFT0M{"binsMultFT0M", {600, 0., 6000.}, "Multiplicity as FT0M signal amplitude"}; - ConfigurableAxis binsMassD{"binsMassD", {200, 1.7, 2.10}, "inv. mass (#pi^{+}K^{-}#pi^{+}) (GeV/#it{c}^{2})"}; HfHelper hfHelper; SliceCache cache; - BinningType corrBinning{{binsZVtx, binsMultiplicity}, true}; // Event Mixing for the Data Mode using SelCollisionsWithDplus = soa::Filtered>; @@ -213,9 +225,16 @@ struct HfCorrelatorDplusHadrons { Filter dplusFilter = ((o2::aod::hf_track_index::hfflag & static_cast(1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi)) != static_cast(0)) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; Filter trackFilter = (nabs(aod::track::eta) < etaTrackMax) && (nabs(aod::track::pt) > ptTrackMin) && (nabs(aod::track::dcaXY) < dcaXYTrackMax) && (nabs(aod::track::dcaZ) < dcaZTrackMax); // Filter particlesFilter = nabs(aod::mcparticle::pdgCode) == 411 || ((aod::mcparticle::flags & (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary) == (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary); - - Preslice perCol = aod::hf_cand::collisionId; - + ConfigurableAxis binsMultiplicity{"binsMultiplicity", {VARIABLE_WIDTH, 0.0f, 2000.0f, 6000.0f, 100000.0f}, "Mixing bins - multiplicity"}; + ConfigurableAxis binsZVtx{"binsZVtx", {VARIABLE_WIDTH, -10.0f, -2.5f, 2.5f, 10.0f}, "Mixing bins - z-vertex"}; + ConfigurableAxis binsMultiplicityMc{"binsMultiplicityMc", {VARIABLE_WIDTH, 0.0f, 20.0f, 50.0f, 500.0f}, "Mixing bins - MC multiplicity"}; // In MCGen multiplicity is defined by counting tracks + ConfigurableAxis binsBdtScore{"binsBdtScore", {100, 0., 1.}, "Bdt output scores"}; + ConfigurableAxis binsEta{"binsEta", {50, -2., 2.}, "#it{#eta}"}; + ConfigurableAxis binsPhi{"binsPhi", {64, -PIHalf, 3. * PIHalf}, "#it{#varphi}"}; + ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; + ConfigurableAxis binsMultFT0M{"binsMultFT0M", {600, 0., 6000.}, "Multiplicity as FT0M signal amplitude"}; + ConfigurableAxis binsMassD{"binsMassD", {200, 1.7, 2.10}, "inv. mass (#pi^{+}K^{-}#pi^{+}) (GeV/#it{c}^{2})"}; + BinningType corrBinning{{binsZVtx, binsMultiplicity}, true}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(InitContext&) @@ -342,7 +361,7 @@ struct HfCorrelatorDplusHadrons { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)]; } - entryDplusCandRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1]); // 0: BkgBDTScore, 1:PromptBDTScore + entryDplusCandRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2]); // 0: BkgBDTScore, 1:PromptBDTScore, 2: FDScore entryDplus(candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassDplusToPiKPi(candidate), poolBin, gCollisionId, timeStamp); // Dplus-Hadron correlation dedicated section @@ -364,7 +383,7 @@ struct HfCorrelatorDplusHadrons { track.pt(), poolBin); entryDplusHadronRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), false); entryDplusHadronGenInfo(false, false, 0); - entryDplusHadronMlInfo(outputMl[0], outputMl[1]); + entryDplusHadronMlInfo(outputMl[0], outputMl[1], outputMl[2]); entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.tpcNClsCrossedRows()); if (cntDplus == 0) { entryHadron(track.phi(), track.eta(), track.pt(), poolBin, gCollisionId, timeStamp); @@ -420,7 +439,7 @@ struct HfCorrelatorDplusHadrons { efficiencyWeightD = 1. / efficiencyD->at(effBinD); } // Dplus flag - isDplusSignal = TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::DplusToPiKPi); + isDplusSignal = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi; // prompt and non-prompt division isDplusPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; isDplusNonPrompt = candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; @@ -456,7 +475,7 @@ struct HfCorrelatorDplusHadrons { outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)]; } registry.fill(HIST("hMassDplusMcRecSig"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), efficiencyWeightD); - entryDplusCandRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1]); + entryDplusCandRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2]); entryDplusCandGenInfo(isDplusPrompt); } else { registry.fill(HIST("hPtCandMcRecBkg"), candidate.pt()); @@ -485,7 +504,7 @@ struct HfCorrelatorDplusHadrons { candidate.pt(), track.pt(), poolBin); entryDplusHadronRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), isDplusSignal); - entryDplusHadronMlInfo(outputMl[0], outputMl[1]); + entryDplusHadronMlInfo(outputMl[0], outputMl[1], outputMl[2]); if (track.has_mcParticle()) { auto mcParticle = track.template mcParticle_as(); isPhysicalPrimary = mcParticle.isPhysicalPrimary(); @@ -529,7 +548,7 @@ struct HfCorrelatorDplusHadrons { if (std::abs(particle1.pdgCode()) != Pdg::kDPlus) { continue; } - if (!TESTBIT(std::abs(particle1.flagMcMatchGen()), aod::hf_cand_3prong::DecayType::DplusToPiKPi)) { + if (std::abs(particle1.flagMcMatchGen()) != hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { continue; } double yD = RecoDecay::y(particle1.pVector(), MassDPlus); @@ -553,12 +572,12 @@ struct HfCorrelatorDplusHadrons { // prompt and non-prompt division std::vector listDaughters{}; - std::array arrDaughDplusPDG = {+kPiPlus, -kKPlus, kPiPlus}; - std::array prongsId; + std::array arrDaughDplusPDG = {+kPiPlus, -kKPlus, kPiPlus}; + std::array prongsId; listDaughters.clear(); RecoDecay::getDaughters(particle1, &listDaughters, arrDaughDplusPDG, 2); int counterDaughters = 0; - if (listDaughters.size() == 3) { + if (listDaughters.size() == NDaughters) { for (const auto& dauIdx : listDaughters) { auto daughI = mcParticles.rawIteratorAt(dauIdx - mcParticles.offset()); counterDaughters += 1; @@ -635,7 +654,7 @@ struct HfCorrelatorDplusHadrons { continue; } // Dplus flag - bool isDplusSignal = TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::DplusToPiKPi); + bool isDplusSignal = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi; // prompt and non-prompt division bool isDplusPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; bool isDplusNonPrompt = candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; @@ -673,7 +692,7 @@ struct HfCorrelatorDplusHadrons { std::vector outputMl = {-1., -1., -1.}; bool isPhysicalPrimary = false; int trackOrigin = -1; - bool isDplusSignal = std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi; + bool isDplusSignal = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi; // prompt and non-prompt division bool isDplusPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; if (pAssoc.has_mcParticle()) { @@ -693,7 +712,7 @@ struct HfCorrelatorDplusHadrons { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)]; } - entryDplusHadronMlInfo(outputMl[0], outputMl[1]); + entryDplusHadronMlInfo(outputMl[0], outputMl[1], outputMl[2]); entryTrackRecoInfo(pAssoc.dcaXY(), pAssoc.dcaZ(), pAssoc.tpcNClsCrossedRows()); } } diff --git a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx index 740d7832491..c788f35dd92 100644 --- a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx @@ -14,24 +14,44 @@ /// \author Grazia Luparello /// \author Samuele Cattaruzzi -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/TrackSelectionTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h" +#include "PWGHF/HFC/Utils/utilsCorrelations.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -39,6 +59,14 @@ using namespace o2::constants::physics; using namespace o2::constants::math; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::analysis::hf_correlations; + +enum ResonantChannel : int8_t { + PhiPi = 1, + Kstar0K = 2 +}; + +static std::unordered_map channelsResonant = {{{ResonantChannel::PhiPi, hf_decay::hf_cand_3prong::DecayChannelResonant::DsToPhiPi}, {ResonantChannel::Kstar0K, hf_decay::hf_cand_3prong::DecayChannelResonant::DsToKstar0K}}}; /// Returns deltaPhi value in range [-pi/2., 3.*pi/2], typically used for correlation studies double getDeltaPhi(double phiHadron, double phiD) @@ -143,17 +171,21 @@ struct HfCorrelatorDsHadrons { Produces entryTrackRecoInfo; Produces collReduced; Produces candReduced; + Produces candSelInfo; Produces assocTrackReduced; + Produces assocTrackSelInfo; Configurable fillHistoData{"fillHistoData", true, "Flag for filling histograms in data processes"}; Configurable fillHistoMcRec{"fillHistoMcRec", true, "Flag for filling histograms in MC Rec processes"}; Configurable fillHistoMcGen{"fillHistoMcGen", true, "Flag for filling histograms in MC Gen processes"}; Configurable removeCollWSplitVtx{"removeCollWSplitVtx", false, "Flag for rejecting the splitted collisions"}; - Configurable useSel8{"useSel8", true, "Flag for applying sel8 for collision selection"}; - Configurable selNoSameBunchPileUpColl{"selNoSameBunchPileUpColl", true, "Flag for rejecting the collisions associated with the same bunch crossing"}; + Configurable useSel8{"useSel8", true, "Flag for applying sel8 for collision selection (used only in MC processes)"}; + Configurable selNoSameBunchPileUpColl{"selNoSameBunchPileUpColl", true, "Flag for rejecting the collisions associated with the same bunch crossing (used only in MC processes)"}; + Configurable pidTrkApplied{"pidTrkApplied", false, "Apply PID selection for associated tracks"}; + Configurable forceTOF{"forceTOF", false, "force the TOF signal for the PID"}; Configurable selectionFlagDs{"selectionFlagDs", 7, "Selection Flag for Ds (avoid the case of flag = 0, no outputMlScore)"}; Configurable numberEventsMixed{"numberEventsMixed", 5, "Number of events mixed in ME process"}; - Configurable decayChannel{"decayChannel", 1, "Decay channels: 1 for Ds->PhiPi->KKpi, 2 for Ds->K0*K->KKPi"}; + Configurable decayChannel{"decayChannel", 1, "Resonant decay channels: 1 for Ds->PhiPi->KKpi, 2 for Ds->K0*K->KKPi"}; Configurable applyEfficiency{"applyEfficiency", true, "Flag for applying D-meson efficiency weights"}; Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity"}; Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen. cand. rapidity"}; @@ -164,13 +196,19 @@ struct HfCorrelatorDsHadrons { Configurable ptCandMax{"ptCandMax", 50., "max. cand pT"}; Configurable ptTrackMin{"ptTrackMin", 0.3, "min. track pT"}; Configurable ptTrackMax{"ptTrackMax", 50., "max. track pT"}; + Configurable zVtxMax{"zVtxMax", 10., "max. position-z of the reconstructed collision"}; + Configurable tofPIDThreshold{"tofPIDThreshold", 0.75, "minimum pT after which TOF PID is applicable"}; Configurable> classMl{"classMl", {0, 1, 2}, "Indexes of ML scores to be stored. Three indexes max."}; + Configurable> trkPIDspecies{"trkPIDspecies", std::vector{o2::track::PID::Proton, o2::track::PID::Pion, o2::track::PID::Kaon}, "Trk sel: Particles species for PID, proton, pion, kaon"}; + Configurable> pidTPCMax{"pidTPCMax", std::vector{3., 0., 0.}, "maximum nSigma TPC"}; + Configurable> pidTOFMax{"pidTOFMax", std::vector{3., 0., 0.}, "maximum nSigma TOF"}; Configurable> binsPtD{"binsPtD", std::vector{o2::analysis::hf_cuts_ds_to_k_k_pi::vecBinsPt}, "pT bin limits for candidate mass plots"}; Configurable> binsPtHadron{"binsPtHadron", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for assoc particle"}; Configurable> binsPtEfficiencyD{"binsPtEfficiencyD", std::vector{o2::analysis::hf_cuts_ds_to_k_k_pi::vecBinsPt}, "pT bin limits for efficiency"}; Configurable> efficiencyD{"efficiencyD", {1., 1., 1., 1., 1., 1.}, "efficiency values for Ds meson"}; int hfcReducedCollisionIndex = 0; + static constexpr std::size_t NDaughtersDs{3u}; HfHelper hfHelper; SliceCache cache; @@ -220,6 +258,7 @@ struct HfCorrelatorDsHadrons { AxisSpec axisStatus = {15, 0.5, 15.5, "Selection status"}; // Histograms for data analysis + registry.add("hCollisionPoolBin", "Ds candidates collision pool bin", {HistType::kTH1F, {axisPoolBin}}); if (fillHistoData) { registry.add("hPtCand", "Ds candidates pt", {HistType::kTH1F, {axisPtD}}); registry.add("hSelectionStatusDsToKKPi", "Ds candidates selection", {HistType::kTH1F, {axisStatus}}); @@ -236,7 +275,6 @@ struct HfCorrelatorDsHadrons { registry.add("hZVtx", "z vertex", {HistType::kTH1F, {axisPosZ}}); registry.add("hMassDsVsPt", "Ds candidates massVsPt", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); registry.add("hMassDsData", "Ds candidates mass", {HistType::kTH1F, {axisMassD}}); - registry.add("hCollisionPoolBin", "Ds candidates collision pool bin", {HistType::kTH1F, {axisPoolBin}}); registry.add("hDsPoolBin", "Ds candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); registry.add("hTracksPoolBin", "Particles associated pool bin", {HistType::kTH1F, {axisPoolBin}}); } @@ -273,6 +311,12 @@ struct HfCorrelatorDsHadrons { registry.add("hEtaMcGen", "Ds,Hadron particles - MC Gen", {HistType::kTH1F, {axisEta}}); registry.add("hPhiMcGen", "Ds,Hadron particles - MC Gen", {HistType::kTH1F, {axisPhi}}); registry.add("hMultFT0AMcGen", "Ds,Hadron multiplicity FT0A - MC Gen", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("hCorrAllPrimaryParticles", "Ds-ch. part. correlations MC Gen", {HistType::kTH3F, {{axisPhi}, {axisPtD}, {axisPtHadron}}}); + registry.add("hCorrAllPrimaryHadrons", "Ds-h correlations MC Gen", {HistType::kTH3F, {{axisPhi}, {axisPtD}, {axisPtHadron}}}); + registry.add("hCorrAllPrimaryPions", "Ds-pion correlations MC Gen", {HistType::kTH3F, {{axisPhi}, {axisPtD}, {axisPtHadron}}}); + registry.add("hCorrAllPrimaryKaons", "Ds-kaon correlations MC Gen", {HistType::kTH3F, {{axisPhi}, {axisPtD}, {axisPtHadron}}}); + registry.add("hCorrAllPrimaryProtons", "Ds-proton correlations MC Gen", {HistType::kTH3F, {{axisPhi}, {axisPtD}, {axisPtHadron}}}); + registry.add("hFakeCollision", "Fake collision counter", {HistType::kTH1F, {{1, -0.5, 0.5, "n fake coll"}}}); } } @@ -432,7 +476,7 @@ struct HfCorrelatorDsHadrons { entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.tpcNClsCrossedRows()); } } // end track loop - } // end candidate loop + } // end candidate loop } PROCESS_SWITCH(HfCorrelatorDsHadrons, processData, "Process data", true); @@ -459,8 +503,8 @@ struct HfCorrelatorDsHadrons { // prompt and non-prompt division isDsPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; // Ds Signal - isDsSignal = std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi; - isDecayChan = candidate.flagMcDecayChanRec() == decayChannel; + isDsSignal = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK; + isDecayChan = candidate.flagMcDecayChanRec() == channelsResonant[decayChannel]; if (std::abs(hfHelper.yDs(candidate)) > yCandMax || candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { continue; @@ -622,7 +666,7 @@ struct HfCorrelatorDsHadrons { if (useSel8 && !collision.sel8()) { continue; } - if (std::abs(collision.posZ()) > 10.) { + if (std::abs(collision.posZ()) > zVtxMax) { continue; } if (selNoSameBunchPileUpColl && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { @@ -640,7 +684,7 @@ struct HfCorrelatorDsHadrons { // MC gen level for (const auto& particle : groupedMcParticles) { // check if the particle is Ds - if ((std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (particle.flagMcDecayChanGen() == decayChannel)) { + if ((std::abs(particle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && (particle.flagMcDecayChanGen() == channelsResonant[decayChannel])) { double yD = RecoDecay::y(particle.pVector(), MassDS); if (std::abs(yD) > yCandGenMax || particle.pt() < ptCandMin || particle.pt() > ptCandMax) { continue; @@ -648,14 +692,14 @@ struct HfCorrelatorDsHadrons { fillMcGenHisto(particle); // prompt and non-prompt division isDsPrompt = particle.originMcGen() == RecoDecay::OriginType::Prompt; - isDecayChan = particle.flagMcDecayChanGen() == decayChannel; + isDecayChan = particle.flagMcDecayChanGen() == channelsResonant[decayChannel]; std::vector listDaughters{}; std::array arrDaughDsPDG = {+kKPlus, -kKPlus, kPiPlus}; std::array prongsId; listDaughters.clear(); RecoDecay::getDaughters(particle, &listDaughters, arrDaughDsPDG, 2); int counterDaughters = 0; - if (listDaughters.size() == 3) { + if (listDaughters.size() == NDaughtersDs) { for (const auto& dauIdx : listDaughters) { // auto daughI = mcParticles.rawIteratorAt(dauIdx - mcParticles.offset()); auto daughI = groupedMcParticles.rawIteratorAt(dauIdx - groupedMcParticles.offset()); @@ -677,6 +721,21 @@ struct HfCorrelatorDsHadrons { if (!particleAssoc.isPhysicalPrimary()) { continue; } + + if (isDsPrompt) { + registry.fill(HIST("hCorrAllPrimaryParticles"), getDeltaPhi(particleAssoc.phi(), particle.phi()), particle.pt(), particleAssoc.pt()); + if (std::abs(particleAssoc.pdgCode()) == kPiPlus) { + registry.fill(HIST("hCorrAllPrimaryHadrons"), getDeltaPhi(particleAssoc.phi(), particle.phi()), particle.pt(), particleAssoc.pt()); + registry.fill(HIST("hCorrAllPrimaryPions"), getDeltaPhi(particleAssoc.phi(), particle.phi()), particle.pt(), particleAssoc.pt()); + } else if (std::abs(particleAssoc.pdgCode()) == kKPlus) { + registry.fill(HIST("hCorrAllPrimaryHadrons"), getDeltaPhi(particleAssoc.phi(), particle.phi()), particle.pt(), particleAssoc.pt()); + registry.fill(HIST("hCorrAllPrimaryKaons"), getDeltaPhi(particleAssoc.phi(), particle.phi()), particle.pt(), particleAssoc.pt()); + } else if (std::abs(particleAssoc.pdgCode()) == kProton) { + registry.fill(HIST("hCorrAllPrimaryHadrons"), getDeltaPhi(particleAssoc.phi(), particle.phi()), particle.pt(), particleAssoc.pt()); + registry.fill(HIST("hCorrAllPrimaryProtons"), getDeltaPhi(particleAssoc.phi(), particle.phi()), particle.pt(), particleAssoc.pt()); + } + } + // trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true); trackOrigin = RecoDecay::getCharmHadronOrigin(groupedMcParticles, particleAssoc, true); registry.fill(HIST("hPtParticleAssocMcGen"), particleAssoc.pt()); @@ -691,7 +750,7 @@ struct HfCorrelatorDsHadrons { } // end loop generated particles } // end loop generated Ds } // end loop reconstructed collision - } // end loop generated collision + } // end loop generated collision } PROCESS_SWITCH(HfCorrelatorDsHadrons, processMcGen, "Process MC Gen mode", false); @@ -700,40 +759,6 @@ struct HfCorrelatorDsHadrons { MyTracksData const& tracks) { - for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto candsDsThisColl = candidates.sliceBy(candsDsPerCollision, thisCollId); - auto tracksThisColl = tracks.sliceBy(trackIndicesPerCollision, thisCollId); - - // Ds fill histograms and Ds candidates information stored - for (const auto& candidate : candsDsThisColl) { - // candidate selected - if (candidate.isSelDsToKKPi() >= selectionFlagDs) { - candReduced(hfcReducedCollisionIndex, candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassDsToKKPi(candidate)); - } else if (candidate.isSelDsToPiKK() >= selectionFlagDs) { - candReduced(hfcReducedCollisionIndex, candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassDsToPiKK(candidate)); - } - } - - // tracks information - for (const auto& track : tracksThisColl) { - if (!track.isGlobalTrackWoDCA()) { - continue; - } - assocTrackReduced(hfcReducedCollisionIndex, track.phi(), track.eta(), track.pt()); - } - - collReduced(collision.multFT0M(), collision.posZ()); - hfcReducedCollisionIndex++; - } - } - PROCESS_SWITCH(HfCorrelatorDsHadrons, processDerivedDataDs, "Process derived data Ds", false); - - void processDerivedDataDsLastIndex(SelCollisionsWithDs const& collisions, - CandDsData const& candidates, - MyTracksData const& tracks) - { - for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); auto candsDsThisColl = candidates.sliceBy(candsDsPerCollision, thisCollId); @@ -743,11 +768,22 @@ struct HfCorrelatorDsHadrons { // Ds fill histograms and Ds candidates information stored for (const auto& candidate : candsDsThisColl) { + std::vector outputMl = {-1., -1., -1.}; + auto prong0 = candidate.template prong0_as(); + int chargeDs = prong0.sign(); // candidate selected if (candidate.isSelDsToKKPi() >= selectionFlagDs) { - candReduced(indexHfcReducedCollision, candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassDsToKKPi(candidate)); + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMl[iclass] = candidate.mlProbDsToKKPi()[classMl->at(iclass)]; + } + candReduced(indexHfcReducedCollision, candidate.phi(), candidate.eta(), candidate.pt() * chargeDs, hfHelper.invMassDsToKKPi(candidate), candidate.prong0Id(), candidate.prong1Id(), candidate.prong2Id()); + candSelInfo(indexHfcReducedCollision, outputMl[0], outputMl[2]); } else if (candidate.isSelDsToPiKK() >= selectionFlagDs) { - candReduced(indexHfcReducedCollision, candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassDsToPiKK(candidate)); + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMl[iclass] = candidate.mlProbDsToPiKK()[classMl->at(iclass)]; + } + candReduced(indexHfcReducedCollision, candidate.phi(), candidate.eta(), candidate.pt() * chargeDs, hfHelper.invMassDsToPiKK(candidate), candidate.prong0Id(), candidate.prong1Id(), candidate.prong2Id()); + candSelInfo(indexHfcReducedCollision, outputMl[0], outputMl[2]); } } @@ -756,13 +792,18 @@ struct HfCorrelatorDsHadrons { if (!track.isGlobalTrackWoDCA()) { continue; } - assocTrackReduced(indexHfcReducedCollision, track.phi(), track.eta(), track.pt()); + if (pidTrkApplied) { + if (!passPIDSelection(track, trkPIDspecies, pidTPCMax, pidTOFMax, tofPIDThreshold, forceTOF)) + continue; + } + assocTrackReduced(indexHfcReducedCollision, track.globalIndex(), track.phi(), track.eta(), track.pt() * track.sign()); + assocTrackSelInfo(indexHfcReducedCollision, track.tpcNClsCrossedRows(), track.itsClusterMap(), track.itsNCls(), track.dcaXY(), track.dcaZ()); } - collReduced(collision.multFT0M(), collision.posZ()); + collReduced(collision.multFT0M(), collision.numContrib(), collision.posZ()); } } - PROCESS_SWITCH(HfCorrelatorDsHadrons, processDerivedDataDsLastIndex, "Process derived data Ds w lastIndex", false); + PROCESS_SWITCH(HfCorrelatorDsHadrons, processDerivedDataDs, "Process derived data Ds", false); // Event Mixing void processDataME(SelCollisionsWithDs const& collisions, @@ -844,7 +885,7 @@ struct HfCorrelatorDsHadrons { if (std::abs(hfHelper.yDs(candidate)) > yCandMax || candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { continue; } - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) { + if (std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) { // DsToKKPi and DsToPiKK division if (candidate.isSelDsToKKPi() >= selectionFlagDs) { fillHistoMcRecSig(candidate, 0.); @@ -881,7 +922,7 @@ struct HfCorrelatorDsHadrons { // prompt and non-prompt division isDsPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; // Ds Signal - isDsSignal = std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi; + isDsSignal = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK; isDecayChan = candidate.flagMcDecayChanRec() == decayChannel; if (pAssoc.has_mcParticle()) { auto mcParticle = pAssoc.template mcParticle_as(); @@ -932,7 +973,7 @@ struct HfCorrelatorDsHadrons { for (const auto& [c1, tracks1, c2, tracks2] : pairMcGen) { int poolBin = corrBinningMcGen.getBin(std::make_tuple(c1.posZ(), c1.multMCFT0A())); for (const auto& [candidate, particleAssoc] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - if ((std::abs(candidate.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (candidate.flagMcDecayChanGen() == decayChannel)) { + if ((std::abs(candidate.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && (candidate.flagMcDecayChanGen() == decayChannel)) { double yD = RecoDecay::y(candidate.pVector(), MassDS); if (std::abs(yD) > yCandGenMax || candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { continue; diff --git a/PWGHF/HFC/TableProducer/correlatorDsHadronsReduced.cxx b/PWGHF/HFC/TableProducer/correlatorDsHadronsReduced.cxx index 78e05a61ec1..5684619dd3f 100644 --- a/PWGHF/HFC/TableProducer/correlatorDsHadronsReduced.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDsHadronsReduced.cxx @@ -10,21 +10,33 @@ // or submit itself to any jurisdiction. /// \file correlatorDsHadronsReduced.cxx -/// \brief Ds-Hadrons correlator task for ME offline +/// \brief Ds-Hadrons correlator task for offline analysis /// \author Samuele Cattaruzzi -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + using namespace o2; -using namespace o2::analysis; using namespace o2::constants::physics; using namespace o2::constants::math; using namespace o2::framework; @@ -43,10 +55,15 @@ using BinningTypeDerived = ColumnBinningPolicy entryDsHadronPair; Produces entryDsHadronRecoInfo; + Produces entryDsHadronMlInfo; + Produces entryDsCandRecoInfo; + Produces entryTrackRecoInfo; // Produces entryDsHadronGenInfo; Configurable fillHistoData{"fillHistoData", true, "Flag for filling histograms in data processes"}; Configurable numberEventsMixed{"numberEventsMixed", 5, "Number of events mixed in ME process"}; + Configurable> binsPtD{"binsPtD", std::vector{1., 3., 5., 8., 16., 36.}, "pT bin limits for candidate mass plots"}; + Configurable> binsPtHadron{"binsPtHadron", std::vector{0.3, 1., 2., 50.}, "pT bin limits for assoc particle"}; SliceCache cache; @@ -56,9 +73,11 @@ struct HfCorrelatorDsHadronsReduced { ConfigurableAxis zPoolBins{"zPoolBins", {VARIABLE_WIDTH, -10.0, -2.5, 2.5, 10.0}, "z vertex position pools"}; ConfigurableAxis multPoolBins{"multPoolBins", {VARIABLE_WIDTH, 0., 900., 1800., 6000.}, "event multiplicity pools (FT0M)"}; - ConfigurableAxis binsMultFT0M{"binsMultFT0M", {600, 0., 6000.}, "Multiplicity as FT0M signal amplitude"}; + ConfigurableAxis binsMultFT0M{"binsMultFT0M", {100, 0., 10000.}, "Multiplicity as FT0M signal amplitude"}; ConfigurableAxis binsPosZ{"binsPosZ", {100, -10., 10.}, "primary vertex z coordinate"}; ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; + ConfigurableAxis binsEta{"binsEta", {50, -2., 2.}, "#it{#eta}"}; + ConfigurableAxis binsPhi{"binsPhi", {64, -PIHalf, 3. * PIHalf}, "#it{#varphi}"}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -67,16 +86,70 @@ struct HfCorrelatorDsHadronsReduced { AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; AxisSpec axisPosZ = {binsPosZ, "PosZ"}; AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; + AxisSpec axisEta = {binsEta, "#it{#eta}"}; + AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; + AxisSpec axisPtD = {(std::vector)binsPtD, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisPtHadron = {(std::vector)binsPtHadron, "#it{p}_{T} Hadron (GeV/#it{c})"}; // Histograms for data analysis if (fillHistoData) { registry.add("hMultFT0M", "Multiplicity FT0M", {HistType::kTH1F, {axisMultFT0M}}); registry.add("hZVtx", "z vertex", {HistType::kTH1F, {axisPosZ}}); + registry.add("hCollisionPoolBin", "Collision pool bin", {HistType::kTH1F, {axisPoolBin}}); registry.add("hDsPoolBin", "Ds candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hPhiVsPtCand", "Ds candidates phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtD}}}); + registry.add("hPhiVsPtPartAssoc", "Particles associated phiVsPt", {HistType::kTH3F, {{axisPhi}, {axisPtD}, {axisPtHadron}}}); + registry.add("hEtaVsPtCand", "Ds candidates etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtD}}}); + registry.add("hEtaVsPtPartAssoc", "Particles associated etaVsPt", {HistType::kTH3F, {{axisEta}, {axisPtD}, {axisPtHadron}}}); registry.add("hTracksPoolBin", "Particles associated pool bin", {HistType::kTH1F, {axisPoolBin}}); } } + void processDerivedData(aod::HfcRedCollisions const& collisions, + soa::Join const& candidates, + soa::Join const& tracks) + { + + BinningTypeDerived corrBinning{{zPoolBins, multPoolBins}, true}; + + for (const auto& collision : collisions) { + int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multiplicity())); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hMultFT0M"), collision.multiplicity()); + registry.fill(HIST("hZVtx"), collision.posZ()); + + auto thisCollId = collision.globalIndex(); + auto candsDsThisColl = candidates.sliceBy(candPerCol, thisCollId); + auto tracksThisColl = tracks.sliceBy(tracksPerCol, thisCollId); + + for (const auto& candidate : candsDsThisColl) { + registry.fill(HIST("hDsPoolBin"), poolBin); + registry.fill(HIST("hPhiVsPtCand"), RecoDecay::constrainAngle(candidate.phiCand(), -PIHalf), candidate.ptCand()); + registry.fill(HIST("hEtaVsPtCand"), candidate.etaCand(), candidate.ptCand()); + entryDsCandRecoInfo(candidate.invMassDs(), candidate.ptCand(), candidate.bdtScorePrompt(), candidate.bdtScoreBkg()); + for (const auto& track : tracksThisColl) { + // Removing Ds daughters by checking track indices + if ((candidate.prong0Id() == track.originTrackId()) || (candidate.prong1Id() == track.originTrackId()) || (candidate.prong2Id() == track.originTrackId())) { + continue; + } + registry.fill(HIST("hTracksPoolBin"), poolBin); + registry.fill(HIST("hPhiVsPtPartAssoc"), RecoDecay::constrainAngle(track.phiAssocTrack(), -PIHalf), candidate.ptCand(), track.ptAssocTrack()); + registry.fill(HIST("hEtaVsPtPartAssoc"), track.etaAssocTrack(), candidate.ptCand(), track.ptAssocTrack()); + + entryDsHadronPair(getDeltaPhi(track.phiAssocTrack(), candidate.phiCand()), + track.etaAssocTrack() - candidate.etaCand(), + candidate.ptCand(), + track.ptAssocTrack(), + poolBin); + entryDsHadronRecoInfo(candidate.invMassDs(), false, false); + entryDsHadronMlInfo(candidate.bdtScorePrompt(), candidate.bdtScoreBkg()); + entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.nTpcCrossedRows()); + } + } + } + } + PROCESS_SWITCH(HfCorrelatorDsHadronsReduced, processDerivedData, "Process Derived Data", true); + void processDerivedDataME(aod::HfcRedCollisions const& collisions, aod::DsCandReduceds const& candidates, aod::AssocTrackReds const& tracks) @@ -84,6 +157,28 @@ struct HfCorrelatorDsHadronsReduced { BinningTypeDerived corrBinning{{zPoolBins, multPoolBins}, true}; + for (const auto& collision : collisions) { + int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multiplicity())); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hMultFT0M"), collision.multiplicity()); + registry.fill(HIST("hZVtx"), collision.posZ()); + + auto thisCollId = collision.globalIndex(); + auto candsDsThisColl = candidates.sliceBy(candPerCol, thisCollId); + auto tracksThisColl = tracks.sliceBy(tracksPerCol, thisCollId); + + for (const auto& candidate : candsDsThisColl) { + registry.fill(HIST("hDsPoolBin"), poolBin); + registry.fill(HIST("hPhiVsPtCand"), RecoDecay::constrainAngle(candidate.phiCand(), -PIHalf), candidate.ptCand()); + registry.fill(HIST("hEtaVsPtCand"), candidate.etaCand(), candidate.ptCand()); + for (const auto& track : tracksThisColl) { + registry.fill(HIST("hTracksPoolBin"), poolBin); + registry.fill(HIST("hPhiVsPtPartAssoc"), RecoDecay::constrainAngle(track.phiAssocTrack(), -PIHalf), candidate.ptCand(), track.ptAssocTrack()); + registry.fill(HIST("hEtaVsPtPartAssoc"), track.etaAssocTrack(), candidate.ptCand(), track.ptAssocTrack()); + } + } + } + auto tracksTuple = std::make_tuple(candidates, tracks); Pair pairData{corrBinning, numberEventsMixed, -1, collisions, tracksTuple, &cache}; @@ -95,13 +190,13 @@ struct HfCorrelatorDsHadronsReduced { int poolBin = corrBinning.getBin(std::make_tuple(c2.posZ(), c2.multiplicity())); int poolBinDs = corrBinning.getBin(std::make_tuple(c1.posZ(), c1.multiplicity())); - registry.fill(HIST("hMultFT0M"), c1.multiplicity()); - registry.fill(HIST("hZVtx"), c1.posZ()); - registry.fill(HIST("hTracksPoolBin"), poolBin); - registry.fill(HIST("hDsPoolBin"), poolBinDs); + + if (poolBin != poolBinDs) { + LOGF(info, "Error, poolBins are diffrent"); + } for (const auto& [cand, pAssoc] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", cand.index(), pAssoc.index(), c1.index(), c2.index(), cand.hfcRedCollisionId(), pAssoc.hfcRedCollisionId()); + // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", cand.index(), pAssoc.index(), c1.index(), c2.index(), cand.hfcRedCollisionId(), pAssoc.hfcRedCollisionId()); entryDsHadronPair(getDeltaPhi(pAssoc.phiAssocTrack(), cand.phiCand()), pAssoc.etaAssocTrack() - cand.etaCand(), @@ -113,7 +208,7 @@ struct HfCorrelatorDsHadronsReduced { } } } - PROCESS_SWITCH(HfCorrelatorDsHadronsReduced, processDerivedDataME, "Process Mixed Event Derived Data", true); + PROCESS_SWITCH(HfCorrelatorDsHadronsReduced, processDerivedDataME, "Process Mixed Event Derived Data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx index 849d15e9013..1a4cafe02ac 100644 --- a/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDstarHadrons.cxx @@ -15,24 +15,36 @@ /// \brief Correlator for D* and hadrons. This task is used to produce table for D* and hadron pairs. -// c++ -#include - -// O2 -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -// O2Physics -#include "Common/DataModel/Multiplicity.h" - -// PWGHF #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; diff --git a/PWGHF/HFC/TableProducer/correlatorHfeHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorHfeHadrons.cxx index 2d9221f7190..30989581962 100644 --- a/PWGHF/HFC/TableProducer/correlatorHfeHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorHfeHadrons.cxx @@ -14,21 +14,30 @@ /// \author Rashi Gupta , IIT Indore /// \author Ravindra Singh , IIT Indore -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/HFL/DataModel/ElectronSelectionTable.h" -#include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/CCDB/TriggerAliases.h" #include "Common/Core/RecoDecay.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "PWGHF/HFC/DataModel/CorrelationTables.h" -#include "PWGHF/HFL/DataModel/ElectronSelectionTable.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include using namespace o2; using namespace o2::framework; @@ -36,21 +45,24 @@ using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::aod::hf_sel_electron; -// definition of ME variables and new types std::vector zBins{VARIABLE_WIDTH, -10.0, -2.5, 2.5, 10.0}; std::vector multBins{VARIABLE_WIDTH, 0., 200., 500.0, 5000.}; std::vector multBinsMcGen{VARIABLE_WIDTH, 0., 20., 50.0, 500.}; // In MCGen multiplicity is defined by counting primaries using BinningType = ColumnBinningPolicy>; BinningType corrBinning{{zBins, multBins}, true}; +using BinningTypeMcGen = ColumnBinningPolicy; struct HfCorrelatorHfeHadrons { - SliceCache cache; Produces entryElectronHadronPair; + Produces entryElectronHadronPairmcGen; + Produces entryElectron; + Produces entryHadron; // Configurables // Event Selection Configurable zPvPosMax{"zPvPosMax", 10., "Maximum z of the primary vertex (cm)"}; Configurable isRun3{"isRun3", true, "Data is from Run3 or Run2"}; + Configurable numberEventsMixed{"numberEventsMixed", 5, "number of events mixed in ME process"}; // Associated Hadron selection Configurable ptTrackMin{"ptTrackMin", 0.1f, "Transverse momentum range for associated hadron tracks"}; Configurable etaTrackMax{"etaTrackMax", 0.8f, "Eta range for associated hadron tracks"}; @@ -61,29 +73,52 @@ struct HfCorrelatorHfeHadrons { // Electron hadron correlation condition Configurable ptCondition{"ptCondition", true, "Electron pT should be greater than associate particle pT"}; + SliceCache cache; using TableCollisions = o2::soa::Filtered>; using TableCollision = TableCollisions::iterator; using TableTracks = o2::soa::Join; - + using McGenTableCollisions = soa::Join; + using McGenTableCollision = McGenTableCollisions::iterator; using McTableCollisions = o2::soa::Filtered>; using McTableCollision = McTableCollisions::iterator; using McTableTracks = soa::Join; - Filter CollisionFilter = nabs(aod::collision::posZ) < zPvPosMax && aod::collision::numContrib > (uint16_t)1; + Filter collisionFilter = nabs(aod::collision::posZ) < zPvPosMax && aod::collision::numContrib > static_cast(1); Preslice perCol = aod::track::collisionId; Preslice perCollision = aod::hf_sel_electron::collisionId; - HistogramConfigSpec hCorrelSpec{HistType::kTHnSparseD, {{30, 0., 30.}, {20, 0., 20.}, {32, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {50, -1.8, 1.8}}}; + + ConfigurableAxis binsDeltaEta{"binsDeltaEta", {30, -1.8, 1.8}, "#it{#Delta#eta}"}; + ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {32, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, "#it{#Delta#varphi}"}; + ConfigurableAxis binsPt{"binsPt", {50, 0.0, 50}, "#it{p_{T}}(GeV/#it{c})"}; + ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; HistogramRegistry registry{ "registry", - {{"hInclusiveEHCorrel", "Sparse for Delta phi and Delta eta Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", hCorrelSpec}, - {"hptElectron", "hptElectron", {HistType::kTH1F, {{100, 0, 100}}}}, - {"hMixEventInclusiveEHCorrl", "Sparse for mix event Delta phi and Delta eta Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", hCorrelSpec}}}; + {}}; void init(InitContext&) { - registry.get(HIST("hInclusiveEHCorrel"))->Sumw2(); - registry.get(HIST("hMixEventInclusiveEHCorrl"))->Sumw2(); + AxisSpec axisDeltaEta = {binsDeltaEta, "#Delta #eta = #eta_{Electron}- #eta_{Hadron}"}; + AxisSpec axisDeltaPhi = {binsDeltaPhi, "#Delta #varphi = #varphi_{Electron}- #varphi_{Hadron}"}; + AxisSpec axisPt = {binsPt, "#it{p_{T}}(GeV/#it{c})"}; + AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; + + registry.add("hInclusiveEHCorrel", "Sparse for Delta phi and Delta eta Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hLSEHCorrel", "Sparse for Delta phi and Delta eta Like sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hULSEHCorrel", "Sparse for Delta phi and Delta eta UnLike sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hMCgenNonHfEHCorrel", "Sparse for Delta phi and Delta eta for McGen Non Hf Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hMCgenInclusiveEHCorrl", "Sparse for Delta phi and Delta eta for McGen Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hptElectron", "hptElectron", {HistType::kTH1D, {axisPt}}); + + registry.add("hMixEventInclusiveEHCorrl", "Sparse for mix event Delta phi and Delta eta Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hMixEventLSEHCorrel", "Sparse for mix event Delta phi and Delta eta Like sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hMixEventULSEHCorrel", "Sparse for mix event Delta phi and Delta eta Unlike sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hMixEventMcGenInclusiveEHCorrl", "Sparse for mix event Delta phi and Delta eta Mc gen Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hMixEventMcGenNonHfEHCorrl", "Sparse for mix event Delta phi and Delta eta Mc gen Non Hf Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hElectronBin", "Electron bin", {HistType::kTH1D, {axisPoolBin}}); + registry.add("hLSElectronBin", "Electron bin", {HistType::kTH1D, {axisPoolBin}}); + registry.add("hULSElectronBin", "Electron bin", {HistType::kTH1D, {axisPoolBin}}); + registry.add("hTracksBin", "Particles associated pool bin", {HistType::kTH1D, {axisPoolBin}}); } // Associated Hadron Selection Cut @@ -107,18 +142,22 @@ struct HfCorrelatorHfeHadrons { } // Electron-hadron Correlation - template - void fillCorrelation(CollisionType const& collision, ElectronType const& electron, TracksType const& tracks) + template + void fillCorrelation(CollisionType const& collision, ElectronType const& electron, TracksType const& tracks, BcType const&) { if (!(isRun3 ? collision.sel8() : (collision.sel7() && collision.alias_bit(kINT7)))) return; int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFV0M())); + auto bc = collision.template bc_as(); + int gCollisionId = collision.globalIndex(); + int64_t timeStamp = bc.timestamp(); // Construct Deta Phi between electrons and hadrons double ptElectron = -999; double phiElectron = -999; double etaElectron = -999; + int nElectron = 0; for (const auto& eTrack : electron) { ptElectron = eTrack.ptTrack(); @@ -131,28 +170,74 @@ struct HfCorrelatorHfeHadrons { double etaHadron = -999; double phiHadron = -999; - if (!eTrack.isEmcal()) + if (!eTrack.isEmcal()) { continue; - + } registry.fill(HIST("hptElectron"), ptElectron); + int nElectronLS = 0; + int nElectronUS = 0; + if (eTrack.nElPairLS() > 0) { + for (int i = 0; i < eTrack.nElPairLS(); ++i) { + + ++nElectronLS; + registry.fill(HIST("hLSElectronBin"), poolBin); + } + } + if (eTrack.nElPairUS() > 0) { + for (int i = 0; i < eTrack.nElPairUS(); ++i) { + + ++nElectronUS; + registry.fill(HIST("hULSElectronBin"), poolBin); + } + } + + registry.fill(HIST("hElectronBin"), poolBin); + entryElectron(phiElectron, etaElectron, ptElectron, nElectronLS, nElectronUS, poolBin, gCollisionId, timeStamp); + for (const auto& hTrack : tracks) { - if (hTrack.globalIndex() == eTrack.trackId()) - continue; // Apply Hadron cut - if (!selAssoHadron(hTrack)) + if (!selAssoHadron(hTrack)) { continue; + } ptHadron = hTrack.pt(); phiHadron = hTrack.phi(); etaHadron = hTrack.eta(); + if (hTrack.globalIndex() == eTrack.trackId()) { + continue; + } - if (ptCondition && (ptElectron < ptHadron)) + if (ptCondition && (ptElectron < ptHadron)) { continue; + } + if (nElectron == 0) { + registry.fill(HIST("hTracksBin"), poolBin); + entryHadron(phiHadron, etaHadron, ptHadron, poolBin, gCollisionId, timeStamp); + } deltaPhi = RecoDecay::constrainAngle(phiElectron - phiHadron, -o2::constants::math::PIHalf); deltaEta = etaElectron - etaHadron; registry.fill(HIST("hInclusiveEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); - entryElectronHadronPair(deltaPhi, deltaEta, ptElectron, ptHadron, poolBin); - } - } + + int nElHadLSCorr = 0; + int nElHadUSCorr = 0; + if (eTrack.nElPairLS() > 0) { + for (int i = 0; i < eTrack.nElPairLS(); ++i) { + + ++nElHadLSCorr; + registry.fill(HIST("hLSEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); + } + } + if (eTrack.nElPairUS() > 0) { + for (int i = 0; i < eTrack.nElPairUS(); ++i) { + + registry.fill(HIST("hULSEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); + ++nElHadUSCorr; + } + } + entryElectronHadronPair(deltaPhi, deltaEta, ptElectron, ptHadron, poolBin, nElHadLSCorr, nElHadUSCorr); + + } // end Hadron Track loop + nElectron++; + } // end Electron loop } // mix event electron-hadron correlation @@ -171,34 +256,56 @@ struct HfCorrelatorHfeHadrons { double etaHadronMix = -999; double phiHadronMix = -999; int poolBin = corrBinning.getBin(std::make_tuple(c2.posZ(), c2.multFV0M())); - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { - if (!t1.isEmcal()) + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (!t1.isEmcal()) { continue; + } + ptHadronMix = t2.pt(); ptElectronMix = t1.ptTrack(); phiElectronMix = t1.phiTrack(); phiHadronMix = t2.phi(); etaElectronMix = t1.etaTrack(); etaHadronMix = t2.eta(); - if (!selAssoHadron(t2)) + if (!selAssoHadron(t2)) { continue; - if (ptCondition && (ptElectronMix < ptHadronMix)) + } + + if (ptCondition && (ptElectronMix < ptHadronMix)) { continue; + } + deltaPhiMix = RecoDecay::constrainAngle(phiElectronMix - phiHadronMix, -o2::constants::math::PIHalf); deltaEtaMix = etaElectronMix - etaHadronMix; registry.fill(HIST("hMixEventInclusiveEHCorrl"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix); - entryElectronHadronPair(deltaPhiMix, deltaEtaMix, ptElectronMix, ptHadronMix, poolBin); + int nElHadLSCorr = 0; + int nElHadUSCorr = 0; + if (t1.nElPairLS() > 0) { + for (int i = 0; i < t1.nElPairLS(); ++i) { + + registry.fill(HIST("hMixEventLSEHCorrel"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix); + ++nElHadLSCorr; + } + } + if (t1.nElPairUS() > 0) { + for (int i = 0; i < t1.nElPairUS(); ++i) { + + registry.fill(HIST("hMixEventULSEHCorrel"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix); + ++nElHadUSCorr; + } + } + entryElectronHadronPair(deltaPhiMix, deltaEtaMix, ptElectronMix, ptHadronMix, poolBin, nElHadLSCorr, nElHadUSCorr); } } // ======= Process starts for Data, Same event ============ void processData(TableCollision const& collision, - aod::HfSelEl const& electron, - TableTracks const& tracks) + aod::HfCorrSelEl const& electron, + TableTracks const& tracks, aod::BCsWithTimestamps const& bc) { - fillCorrelation(collision, electron, tracks); + fillCorrelation(collision, electron, tracks, bc); } PROCESS_SWITCH(HfCorrelatorHfeHadrons, processData, "Process for Data", true); @@ -206,23 +313,82 @@ struct HfCorrelatorHfeHadrons { // ======= Process starts for McRec, Same event ============ void processMcRec(McTableCollision const& mcCollision, - aod::HfSelEl const& mcElectron, + aod::HfCorrSelEl const& mcElectron, McTableTracks const& mcTracks) { - fillCorrelation(mcCollision, mcElectron, mcTracks); + fillCorrelation(mcCollision, mcElectron, mcTracks, 0); } PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcRec, "Process MC Reco mode", false); + void processMcGen(McGenTableCollision const& mcCollision, aod::McParticles const& mcParticles, aod::HfMcGenSelEl const& electron) + { + + BinningTypeMcGen corrBinningMcGen{{zBins, multBinsMcGen}, true}; + int poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), mcCollision.multMCFT0A())); + + double ptElectron = 0; + double phiElectron = 0; + double etaElectron = 0; + for (const auto& electronMc : electron) { + double ptHadron = 0; + double phiHadron = 0; + double etaHadron = 0; + double deltaPhi = 0; + double deltaEta = 0; + ptElectron = electronMc.ptTrackMc(); + phiElectron = electronMc.phiTrackMc(); + etaElectron = electronMc.etaTrackMc(); + for (const auto& particleMc : mcParticles) { + if (particleMc.globalIndex() == electronMc.trackId()) { + + continue; + } + + // Associated hadron Selection ////// + if (!particleMc.isPhysicalPrimary()) { + continue; + } + + if (particleMc.eta() < etaTrackMin || particleMc.eta() > etaTrackMax) { + continue; + } + if (particleMc.pt() < ptTrackMin) { + continue; + } + ptHadron = particleMc.pt(); + phiHadron = particleMc.phi(); + etaHadron = particleMc.eta(); + if (ptCondition && (ptElectron < ptHadron)) { + return; // Apply pT condition + } + deltaPhi = RecoDecay::constrainAngle(phiElectron - phiHadron, -o2::constants::math::PIHalf); + deltaEta = etaElectron - etaHadron; + bool isNonHfeCorr = false; + if (electronMc.isNonHfeMc()) { + + registry.fill(HIST("hMCgenNonHfEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); + isNonHfeCorr = true; + } else { + + registry.fill(HIST("hMCgenInclusiveEHCorrl"), ptElectron, ptHadron, deltaPhi, deltaEta); + } + entryElectronHadronPairmcGen(deltaPhi, deltaEta, ptElectron, ptHadron, poolBin, isNonHfeCorr); + } + } + } + PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcGen, "Process MC Gen mode", false); + // ====================== Implement Event mixing on Data =============================== + // ====================== Implement Event mixing on Data =================================== - void processDataMixedEvent(TableCollisions const& collision, aod::HfSelEl const& electron, TableTracks const& tracks) + void processDataMixedEvent(TableCollisions const& collision, aod::HfCorrSelEl const& electron, TableTracks const& tracks) { auto tracksTuple = std::make_tuple(electron, tracks); - Pair pair{corrBinning, 5, -1, collision, tracksTuple, &cache}; + Pair pair{corrBinning, numberEventsMixed, -1, collision, tracksTuple, &cache}; // loop over the rows of the new table - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { fillMixCorrelation(c1, c2, tracks1, tracks2); } @@ -231,20 +397,71 @@ struct HfCorrelatorHfeHadrons { // ====================== Implement Event mixing on McRec =================================== - void processMcRecMixedEvent(McTableCollisions const& mccollision, aod::HfSelEl const& electron, McTableTracks const& mcTracks) + void processMcRecMixedEvent(McTableCollisions const& mccollision, aod::HfCorrSelEl const& electron, McTableTracks const& mcTracks) { auto tracksTuple = std::make_tuple(electron, mcTracks); - Pair pairMcRec{corrBinning, 5, -1, mccollision, tracksTuple, &cache}; + Pair pairMcRec{corrBinning, numberEventsMixed, -1, mccollision, tracksTuple, &cache}; // loop over the rows of the new table - for (auto& [c1, tracks1, c2, tracks2] : pairMcRec) { + for (const auto& [c1, tracks1, c2, tracks2] : pairMcRec) { fillMixCorrelation(c1, c2, tracks1, tracks2); } } PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcRecMixedEvent, "Process Mixed Event MC Reco mode", false); -}; + void processMcGenMixedEvent(McGenTableCollisions const& mcCollision, aod::HfMcGenSelEl const& electrons, aod::McParticles const& mcParticles) + { + + BinningTypeMcGen corrBinningMcGen{{zBins, multBinsMcGen}, true}; + + auto tracksTuple = std::make_tuple(electrons, mcParticles); + Pair pairMcGen{corrBinningMcGen, 5, -1, mcCollision, tracksTuple, &cache}; + + // loop over the rows of the new table + double ptElectronMix = -999; + double phiElectronMix = -999; + double etaElectronMix = -999; + double deltaPhiMix = -999; + double deltaEtaMix = -999; + double ptHadronMix = -999; + double etaHadronMix = -999; + double phiHadronMix = -999; + for (const auto& [c1, tracks1, c2, tracks2] : pairMcGen) { + int poolBin = corrBinningMcGen.getBin(std::make_tuple(c1.posZ(), c1.multMCFT0A())); + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + ptHadronMix = t2.pt(); + ptElectronMix = t1.ptTrackMc(); + phiElectronMix = t1.phiTrackMc(); + phiHadronMix = t2.phi(); + etaElectronMix = t1.etaTrackMc(); + etaHadronMix = t2.eta(); + if (t2.eta() < etaTrackMin || t2.eta() > etaTrackMax) { + continue; + } + if (t2.pt() < ptTrackMin) { + continue; + } + if (ptCondition && (ptElectronMix < ptHadronMix)) { + continue; + } + + deltaPhiMix = RecoDecay::constrainAngle(phiElectronMix - phiHadronMix, -o2::constants::math::PIHalf); + deltaEtaMix = etaElectronMix - etaHadronMix; + bool isNonHfeCorr = false; + if (t1.isNonHfeMc()) { + isNonHfeCorr = true; + registry.fill(HIST("hMixEventMcGenNonHfEHCorrl"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix); + } else { + + registry.fill(HIST("hMixEventMcGenInclusiveEHCorrl"), ptElectronMix, ptHadronMix, deltaPhiMix, deltaEtaMix); + } + entryElectronHadronPairmcGen(deltaPhiMix, deltaEtaMix, ptElectronMix, ptHadronMix, poolBin, isNonHfeCorr); + } + } + } + PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcGenMixedEvent, "Process Mixed Event MC Gen mode", false); +}; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ diff --git a/PWGHF/HFC/TableProducer/correlatorLcHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorLcHadrons.cxx index 761eb974c42..22770502878 100644 --- a/PWGHF/HFC/TableProducer/correlatorLcHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorLcHadrons.cxx @@ -16,25 +16,47 @@ /// \author Zhen Zhang /// \author Ravindra Singh -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/TrackSelectionTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/HFC/Utils/utilsCorrelations.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -43,6 +65,7 @@ using namespace o2::constants::math; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::analysis::hf_correlations; + /// /// Returns deltaPhi values in range [-pi/2., 3.*pi/2.], typically used for correlation studies /// @@ -159,6 +182,7 @@ struct HfCorrelatorLcHadronsSelection { // Lc-Hadron correlation pair builder - for real data and data-like analysis (i.e. reco-level w/o matching request via Mc truth) struct HfCorrelatorLcHadrons { Produces entryLcHadronPair; + Produces entryLcHadronPairY; Produces entryLcHadronPairTrkPID; Produces entryLcHadronRecoInfo; Produces entryLcHadronMlInfo; @@ -168,6 +192,7 @@ struct HfCorrelatorLcHadrons { Produces entryTrackRecoInfo; Produces entryLc; Produces entryHadron; + Produces entryTrkPID; Configurable selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc"}; Configurable numberEventsMixed{"numberEventsMixed", 5, "number of events mixed in ME process"}; @@ -190,19 +215,25 @@ struct HfCorrelatorLcHadrons { Configurable> efficiencyLc{"efficiencyLc", {1., 1., 1., 1., 1., 1.}, "efficiency values for Lc"}; Configurable storeAutoCorrelationFlag{"storeAutoCorrelationFlag", false, "Store flag that indicates if the track is paired to its Lc mother instead of skipping it"}; Configurable correlateLcWithLeadingParticle{"correlateLcWithLeadingParticle", false, "Switch for correlation of Lc baryons with leading particle only"}; - Configurable> trkPIDspecies{"trkPIDspecies", std::vector{o2::track::PID::Proton, o2::track::PID::Pion, o2::track::PID::Kaon}, "Trk sel: Particles species for PID, proton, pion, kaon"}; Configurable pidTrkApplied{"pidTrkApplied", false, "Apply PID selection for associated tracks"}; + Configurable> trkPIDspecies{"trkPIDspecies", std::vector{o2::track::PID::Proton, o2::track::PID::Pion, o2::track::PID::Kaon}, "Trk sel: Particles species for PID, proton, pion, kaon"}; Configurable> pidTPCMax{"pidTPCMax", std::vector{3., 0., 0.}, "maximum nSigma TPC"}; Configurable> pidTOFMax{"pidTOFMax", std::vector{3., 0., 0.}, "maximum nSigma TOF"}; - Configurable tofPIDThreshold{"tofPIDThreshold", 0.80, "minimum pT after which TOF PID is applicable"}; + Configurable tofPIDThreshold{"tofPIDThreshold", 0.75, "minimum pT after which TOF PID is applicable"}; Configurable fillTrkPID{"fillTrkPID", false, "fill PID information for associated tracks"}; Configurable forceTOF{"forceTOF", false, "fill PID information for associated tracks"}; + Configurable calTrkEff{"calTrkEff", false, "fill histograms to calculate efficiency"}; + Configurable isRecTrkPhyPrimary{"isRecTrkPhyPrimary", true, "Calculate the efficiency of reconstructed primary physical tracks"}; + Configurable calEffLcEvent{"calEffLcEvent", true, "Calculate the efficiency of Lc candidate"}; + Configurable eventFractionToAnalyze{"eventFractionToAnalyze", -1, "Fraction of events to analyze (use only for ME offline on very large samples)"}; HfHelper hfHelper; SliceCache cache; Service pdg; int leadingIndex = 0; bool correlationStatus = false; + static constexpr std::size_t NDaughters{3u}; + TRandom3* rnd = new TRandom3(0); // Event Mixing for the Data Mode using SelCollisionsWithLc = soa::Filtered>; @@ -222,6 +253,10 @@ struct HfCorrelatorLcHadrons { Filter lcFilter = ((o2::aod::hf_track_index::hfflag & static_cast(1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) != static_cast(0)) && (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc); Filter trackFilter = (nabs(aod::track::eta) < etaTrackMax) && (nabs(aod::track::pt) > ptTrackMin) && (nabs(aod::track::dcaXY) < dcaXYTrackMax) && (nabs(aod::track::dcaZ) < dcaZTrackMax); + Preslice perTrueCollision = o2::aod::mcparticle::mcCollisionId; + Preslice perCollisionID = aod::track::collisionId; + Preslice cand3ProngPerCol = aod::hf_cand::collisionId; + // configurable axis definition ConfigurableAxis binsMultiplicity{"binsMultiplicity", {VARIABLE_WIDTH, 0.0f, 2000.0f, 6000.0f, 100000.0f}, "Mixing bins - multiplicity"}; ConfigurableAxis binsZVtx{"binsZVtx", {VARIABLE_WIDTH, -10.0f, -2.5f, 2.5f, 10.0f}, "Mixing bins - z-vertex"}; @@ -243,12 +278,14 @@ struct HfCorrelatorLcHadrons { AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; AxisSpec axisPtLc = {(std::vector)binsPtLc, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec axisPtHadron = {(std::vector)binsPtHadron, "#it{p}_{T} Hadron (GeV/#it{c})"}; + AxisSpec axisPtTrack = {500, 0, 50, "#it{p}_{T} Hadron (GeV/#it{c})"}; AxisSpec axisMultiplicity = {binsMultiplicity, "Multiplicity"}; AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; AxisSpec axisPosZ = {binsZVtx, "PosZ"}; AxisSpec axisBdtScore = {binsBdtScore, "Bdt score"}; AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; AxisSpec axisRapidity = {100, -2, 2, "Rapidity"}; + AxisSpec axisSign = {2, -1, 1, "Sign"}; registry.add("hPtCand", "Lc,Hadron candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtLc}}); registry.add("hPtProng0", "Lc,Hadron candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtLc}}); @@ -293,6 +330,9 @@ struct HfCorrelatorLcHadrons { registry.add("hYMcRecBkg", "Lc,Hadron candidates - MC reco;candidate #it{#y};entries", {HistType::kTH1F, {axisRapidity}}); registry.add("hFakeTracksMcRec", "Fake tracks - MC Rec", {HistType::kTH1F, {axisPtHadron}}); registry.add("hPtParticleAssocVsCandMcRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtHadron}, {axisPtLc}}}); + registry.add("hPtTracksVsSignRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtTrack}, {axisSign}}}); + registry.add("hPtTracksVsSignRecTrue", "Associated Particle - MC Rec (True)", {HistType::kTH2F, {{axisPtTrack}, {axisSign}}}); + registry.add("hPtTracksVsSignGen", "Associated Particle - MC Gen", {HistType::kTH2F, {{axisPtTrack}, {axisSign}}}); registry.add("hPtPrimaryParticleAssocVsCandMcRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtHadron}, {axisPtLc}}}); registry.add("hPtVsMultiplicityMcRecPrompt", "Multiplicity FT0M - MC Rec Prompt", {HistType::kTH2F, {{axisPtLc}, {axisMultFT0M}}}); registry.add("hPtVsMultiplicityMcRecNonPrompt", "Multiplicity FT0M - MC Rec Non Prompt", {HistType::kTH2F, {{axisPtLc}, {axisMultFT0M}}}); @@ -319,9 +359,16 @@ struct HfCorrelatorLcHadrons { return; } + bool skipMixedEventTableFilling = false; + if (eventFractionToAnalyze > 0) { + if (rnd->Uniform(0, 1) > eventFractionToAnalyze) { + skipMixedEventTableFilling = true; + } + } + // find leading particle if (correlateLcWithLeadingParticle) { - leadingIndex = findLeadingParticle(tracks, dcaXYTrackMax.value, dcaZTrackMax.value, etaTrackMax.value); + leadingIndex = findLeadingParticle(tracks, etaTrackMax.value); } auto bc = collision.bc_as(); int gCollisionId = collision.globalIndex(); @@ -343,7 +390,7 @@ struct HfCorrelatorLcHadrons { } registry.fill(HIST("hMultiplicity"), nTracks); - int cntLc = 0; + int countLc = 0; std::vector outputMl = {-1., -1., -1.}; for (const auto& candidate : candidates) { @@ -373,7 +420,7 @@ struct HfCorrelatorLcHadrons { outputMl[iclass] = candidate.mlProbLcToPKPi()[classMl->at(iclass)]; } entryLcCandRecoInfo(hfHelper.invMassLcToPKPi(candidate), candidate.pt() * chargeLc, outputMl[0], outputMl[1]); // 0: BkgBDTScore, 1:PromptBDTScore - entryLc(candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassLcToPKPi(candidate), poolBin, gCollisionId, timeStamp); + entryLc(candidate.phi(), candidate.eta(), candidate.pt() * chargeLc, hfHelper.invMassLcToPKPi(candidate), poolBin, gCollisionId, timeStamp); } if (candidate.isSelLcToPiKP() >= selectionFlagLc) { registry.fill(HIST("hMassLcVsPt"), hfHelper.invMassLcToPiKP(candidate), candidate.pt(), efficiencyWeightLc); @@ -383,7 +430,9 @@ struct HfCorrelatorLcHadrons { outputMl[iclass] = candidate.mlProbLcToPiKP()[classMl->at(iclass)]; } entryLcCandRecoInfo(hfHelper.invMassLcToPiKP(candidate), candidate.pt() * chargeLc, outputMl[0], outputMl[1]); // 0: BkgBDTScore, 1:PromptBDTScore - entryLc(candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassLcToPiKP(candidate), poolBin, gCollisionId, timeStamp); + if (!skipMixedEventTableFilling) { + entryLc(candidate.phi(), candidate.eta(), candidate.pt() * chargeLc, hfHelper.invMassLcToPiKP(candidate), poolBin, gCollisionId, timeStamp); + } } // Lc-Hadron correlation dedicated section @@ -415,6 +464,7 @@ struct HfCorrelatorLcHadrons { track.pt() * track.sign(), poolBin, correlationStatus); + entryLcHadronPairY(track.rapidity(MassProton) - hfHelper.yLc(candidate)); // only for proton as of now entryLcHadronRecoInfo(hfHelper.invMassLcToPKPi(candidate), false); entryLcHadronGenInfo(false, false, 0); entryLcHadronMlInfo(outputMl[0], outputMl[1]); @@ -430,6 +480,7 @@ struct HfCorrelatorLcHadrons { track.pt() * track.sign(), poolBin, correlationStatus); + entryLcHadronPairY(track.rapidity(MassProton) - hfHelper.yLc(candidate)); // only for proton as of now entryLcHadronRecoInfo(hfHelper.invMassLcToPiKP(candidate), false); entryLcHadronGenInfo(false, false, 0); entryLcHadronMlInfo(outputMl[0], outputMl[1]); @@ -438,12 +489,17 @@ struct HfCorrelatorLcHadrons { entryLcHadronPairTrkPID(track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()); } } - if (cntLc == 0) { - entryHadron(track.phi(), track.eta(), track.pt(), poolBin, gCollisionId, timeStamp); - registry.fill(HIST("hTracksBin"), poolBin); + if (countLc == 0) { + if (!skipMixedEventTableFilling) { + entryHadron(track.phi(), track.eta(), track.pt() * track.sign(), poolBin, gCollisionId, timeStamp); + if (fillTrkPID) { + entryTrkPID(track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()); + } + registry.fill(HIST("hTracksBin"), poolBin); + } } } // Hadron Tracks loop - cntLc++; + countLc++; } // end outer Lc loop registry.fill(HIST("hZvtx"), collision.posZ()); registry.fill(HIST("hMultFT0M"), collision.multFT0M()); @@ -462,7 +518,7 @@ struct HfCorrelatorLcHadrons { // find leading particle if (correlateLcWithLeadingParticle) { - leadingIndex = findLeadingParticle(tracks, dcaXYTrackMax.value, dcaZTrackMax.value, etaTrackMax.value); + leadingIndex = findLeadingParticle(tracks, etaTrackMax.value); } int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); @@ -486,6 +542,7 @@ struct HfCorrelatorLcHadrons { bool isLcPrompt = false; bool isLcNonPrompt = false; bool isLcSignal = false; + int countLc = 1; for (const auto& candidate : candidates) { // check decay channel flag for candidate if (std::abs(hfHelper.yLc(candidate)) > yCandMax || candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { @@ -496,8 +553,9 @@ struct HfCorrelatorLcHadrons { efficiencyWeightLc = 1. / efficiencyLc->at(o2::analysis::findBin(binsPtEfficiencyLc, candidate.pt())); } auto trackPos1 = candidate.template prong0_as(); // positive daughter (negative for the antiparticles) - int8_t chargeLc = trackPos1.sign(); // charge of 1st prong will be the charge of Lc candidate - isLcSignal = TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::LcToPKPi); + auto trackPos2 = candidate.template prong2_as(); + int8_t chargeLc = trackPos1.sign(); // charge of 1st prong will be the charge of Lc candidate + isLcSignal = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi; isLcPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; isLcNonPrompt = candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; std::vector outputMl = {-1., -1., -1.}; @@ -574,6 +632,42 @@ struct HfCorrelatorLcHadrons { } registry.fill(HIST("hLcBin"), poolBin); + if (calTrkEff && countLc == 1 && (isLcSignal || !calEffLcEvent)) { + // genrated tracks + decltype(trackPos1.mcParticle_as()) mctrk{}; + if (trackPos1.has_mcParticle()) { // ambiguous tracks should be small + mctrk = trackPos1.template mcParticle_as(); + } else if (trackPos2.has_mcParticle()) { + mctrk = trackPos2.template mcParticle_as(); + } else { + continue; + } + auto gentracks = mcParticles.sliceBy(perTrueCollision, mctrk.mcCollisionId()); + for (const auto& track : gentracks) { + if (std::abs(track.eta()) > etaTrackMax || track.pt() < ptTrackMin || track.pt() > ptTrackMax) { + continue; + } + if ((std::abs(track.pdgCode()) != kElectron) && (std::abs(track.pdgCode()) != kMuonMinus) && (std::abs(track.pdgCode()) != kPiPlus) && (std::abs(track.pdgCode()) != kKPlus) && (std::abs(track.pdgCode()) != kProton)) { + continue; + } + + if (pidTrkApplied && (std::abs(track.pdgCode()) != kProton)) + continue; // proton PID + + if (!track.isPhysicalPrimary()) { + continue; + } + + auto motherTrkGen = mcParticles.iteratorAt(track.mothersIds()[0]); + if (std::abs(motherTrkGen.pdgCode()) == kLambdaCPlus) + continue; + + auto chargeTrack = pdg->GetParticle(track.pdgCode())->Charge(); // Retrieve charge + registry.fill(HIST("hPtTracksVsSignGen"), track.pt(), chargeTrack / (2 * std::abs(chargeTrack))); + } + //} + } + // Lc-Hadron correlation dedicated section // if the candidate is selected as Lc, search for Hadron ad evaluate correlations for (const auto& track : tracks) { @@ -587,6 +681,21 @@ struct HfCorrelatorLcHadrons { if (!passPIDSelection(track, trkPIDspecies, pidTPCMax, pidTOFMax, tofPIDThreshold, forceTOF)) continue; } + + if (calTrkEff && countLc == 1 && (isLcSignal || !calEffLcEvent) && track.has_mcParticle()) { + auto mcParticle = track.template mcParticle_as(); + if (!mcParticle.isPhysicalPrimary() && isRecTrkPhyPrimary) + continue; + + auto motherTrk = mcParticles.iteratorAt(mcParticle.mothersIds()[0]); + if (std::abs(motherTrk.pdgCode()) == kLambdaCPlus) + continue; + + registry.fill(HIST("hPtTracksVsSignRec"), track.pt(), track.sign() / 2.); + if (std::abs(mcParticle.pdgCode()) == kProton) + registry.fill(HIST("hPtTracksVsSignRecTrue"), track.pt(), track.sign() / 2.); + } + // Removing Lc daughters by checking track indices if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex()) || (candidate.prong2Id() == track.globalIndex())) { if (!storeAutoCorrelationFlag) { @@ -608,6 +717,7 @@ struct HfCorrelatorLcHadrons { track.pt() * track.sign(), poolBin, correlationStatus); + entryLcHadronPairY(track.rapidity(MassProton) - hfHelper.yLc(candidate)); // only for proton as of now entryLcHadronRecoInfo(hfHelper.invMassLcToPKPi(candidate), isLcSignal); if (fillTrkPID) { entryLcHadronPairTrkPID(track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()); @@ -637,6 +747,7 @@ struct HfCorrelatorLcHadrons { track.pt() * track.sign(), poolBin, correlationStatus); + entryLcHadronPairY(track.rapidity(MassProton) - hfHelper.yLc(candidate)); // only for proton as of now entryLcHadronRecoInfo(hfHelper.invMassLcToPiKP(candidate), isLcSignal); if (fillTrkPID) { entryLcHadronPairTrkPID(track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()); @@ -659,6 +770,7 @@ struct HfCorrelatorLcHadrons { entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.tpcNClsCrossedRows()); } } // end inner loop (Tracks) + countLc++; } // end outer Lc loop registry.fill(HIST("hZvtx"), collision.posZ()); registry.fill(HIST("hMultFT0M"), collision.multFT0M()); @@ -689,11 +801,11 @@ struct HfCorrelatorLcHadrons { if (std::abs(particle.pdgCode()) != Pdg::kLambdaCPlus) { continue; } - if (!TESTBIT(std::abs(particle.flagMcMatchGen()), aod::hf_cand_3prong::DecayType::LcToPKPi)) { + if (std::abs(particle.flagMcMatchGen()) != hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { continue; } double yL = RecoDecay::y(particle.pVector(), MassLambdaCPlus); - if (std::abs(yL) > yCandMax || particle.pt() < ptCandMin) { + if (std::abs(yL) > yCandGenMax || particle.pt() < ptCandMin) { continue; } registry.fill(HIST("hLcBin"), poolBin); @@ -712,12 +824,12 @@ struct HfCorrelatorLcHadrons { // prompt and non-prompt division std::vector listDaughters{}; - std::array arrDaughLcPDG = {kProton, -kKPlus, kPiPlus}; - std::array prongsId; + std::array arrDaughLcPDG = {kProton, -kKPlus, kPiPlus}; + std::array prongsId; listDaughters.clear(); RecoDecay::getDaughters(particle, &listDaughters, arrDaughLcPDG, 2); int counterDaughters = 0; - if (listDaughters.size() == 3) { + if (listDaughters.size() == NDaughters) { for (const auto& dauIdx : listDaughters) { auto daughI = mcParticles.rawIteratorAt(dauIdx - mcParticles.offset()); counterDaughters += 1; @@ -763,10 +875,11 @@ struct HfCorrelatorLcHadrons { registry.fill(HIST("hPtParticleAssocMcGen"), particleAssoc.pt()); entryLcHadronPair(getDeltaPhi(particleAssoc.phi(), particle.phi()), particleAssoc.eta() - particle.eta(), - particle.pt() * chargeLc, - particleAssoc.pt() * chargeAssoc, + particle.pt() * chargeLc / std::abs(chargeLc), + particleAssoc.pt() * chargeAssoc / std::abs(chargeAssoc), poolBin, correlationStatus); + entryLcHadronPairY(particleAssoc.y() - yL); entryLcHadronRecoInfo(MassLambdaCPlus, true); entryLcHadronGenInfo(isLcPrompt, particleAssoc.isPhysicalPrimary(), trackOrigin); } // end inner loop @@ -807,6 +920,7 @@ struct HfCorrelatorLcHadrons { assocParticle.pt() * assocParticle.sign(), poolBin, correlationStatus); + entryLcHadronPairY(assocParticle.y() - hfHelper.yLc(trigLc)); entryLcHadronRecoInfo(hfHelper.invMassLcToPKPi(trigLc), false); entryLcHadronGenInfo(false, false, 0); if (fillTrkPID) { @@ -825,6 +939,7 @@ struct HfCorrelatorLcHadrons { assocParticle.pt() * assocParticle.sign(), poolBin, correlationStatus); + entryLcHadronPairY(assocParticle.y() - hfHelper.yLc(trigLc)); entryLcHadronRecoInfo(hfHelper.invMassLcToPiKP(trigLc), false); entryLcHadronGenInfo(false, false, 0); if (fillTrkPID) { @@ -852,7 +967,7 @@ struct HfCorrelatorLcHadrons { continue; } // Lc flag - bool isLcSignal = TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::LcToPKPi); + bool isLcSignal = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi; // prompt and non-prompt division bool isLcPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; bool isLcNonPrompt = candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; @@ -901,7 +1016,7 @@ struct HfCorrelatorLcHadrons { std::vector outputMl = {-1., -1., -1.}; bool isPhysicalPrimary = false; int trackOrigin = -1; - bool isLcSignal = std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi; + bool isLcSignal = std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi; bool isLcPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; if (pidTrkApplied) { if (!passPIDSelection(pAssoc, trkPIDspecies, pidTPCMax, pidTOFMax, tofPIDThreshold, forceTOF)) @@ -924,6 +1039,7 @@ struct HfCorrelatorLcHadrons { pAssoc.pt() * pAssoc.sign(), poolBin, correlationStatus); + entryLcHadronPairY(pAssoc.y() - hfHelper.yLc(candidate)); entryLcHadronRecoInfo(hfHelper.invMassLcToPKPi(candidate), isLcSignal); entryLcHadronGenInfo(isLcPrompt, isPhysicalPrimary, trackOrigin); if (fillTrkPID) { @@ -942,6 +1058,7 @@ struct HfCorrelatorLcHadrons { pAssoc.pt() * pAssoc.sign(), poolBin, correlationStatus); + entryLcHadronPairY(pAssoc.y() - hfHelper.yLc(candidate)); entryLcHadronRecoInfo(hfHelper.invMassLcToPiKP(candidate), isLcSignal); entryLcHadronGenInfo(isLcPrompt, isPhysicalPrimary, trackOrigin); if (fillTrkPID) { @@ -993,10 +1110,11 @@ struct HfCorrelatorLcHadrons { bool isLcPrompt = candidate.originMcGen() == RecoDecay::OriginType::Prompt; entryLcHadronPair(getDeltaPhi(particleAssoc.phi(), candidate.phi()), particleAssoc.eta() - candidate.eta(), - candidate.pt() * chargeLc, - particleAssoc.pt() * chargeAssoc, + candidate.pt() * chargeLc / std::abs(chargeLc), + particleAssoc.pt() * chargeAssoc / std::abs(chargeAssoc), poolBin, correlationStatus); + entryLcHadronPairY(particleAssoc.y() - yL); entryLcHadronRecoInfo(MassLambdaCPlus, true); entryLcHadronGenInfo(isLcPrompt, particleAssoc.isPhysicalPrimary(), trackOrigin); } diff --git a/PWGHF/HFC/TableProducer/correlatorLcScHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorLcScHadrons.cxx new file mode 100644 index 00000000000..b06f67990a9 --- /dev/null +++ b/PWGHF/HFC/TableProducer/correlatorLcScHadrons.cxx @@ -0,0 +1,1191 @@ +// 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. + +/// \file correlatorLcScHadrons.cxx +/// \brief Lc-Hadrons correlator task - data-like, Mc-Reco and Mc-Gen analyses +/// +/// \author Marianna Mazzilli +/// \author Zhen Zhang +/// \author Ravindra Singh + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/HFC/Utils/utilsCorrelations.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::analysis; +using namespace o2::constants::physics; +using namespace o2::constants::math; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::analysis::hf_correlations; +/// +/// Returns deltaPhi values in range [-pi/2., 3.*pi/2.], typically used for correlation studies +/// +double getDeltaPhi(double phiLc, double phiHadron) +{ + return RecoDecay::constrainAngle(phiHadron - phiLc, -PIHalf); +} + +// definition of ME variables +using BinningType = ColumnBinningPolicy>; +using BinningTypeMcGen = ColumnBinningPolicy; + +// Code to select collisions with at least one Lambda_c +struct HfCorrelatorLcScHadronsSelection { + Produces candSel; + + Configurable useSel8{"useSel8", true, "Flag for applying sel8 for collision selection"}; + Configurable selNoSameBunchPileUpColl{"selNoSameBunchPileUpColl", true, "Flag for rejecting the collisions associated with the same bunch crossing"}; + Configurable doSelLcCollision{"doSelLcCollision", true, "Select collisions with at least one Lc"}; + Configurable selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc"}; + Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity"}; + Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; + + HfHelper hfHelper; + SliceCache cache; + + using SelCollisions = soa::Join; + using CandsLcDataFiltered = soa::Filtered>; + using CandsLcMcRecFiltered = soa::Filtered>; + using CandsScMcRec = soa::Join; + using CandidatesLcMcGen = soa::Join; + using CandidatesScMcGen = soa::Join; + // filter on selection of Lc and decay channel Lc->PKPi + Filter lcFilter = ((o2::aod::hf_track_index::hfflag & static_cast(1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) != static_cast(0)) && (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc); + + template + void selectionCollision(CollType const& collision, CandType const& candidates) + { + bool isSelColl = true; + bool isCandFound = false; + bool isSel8 = true; + bool isNosameBunchPileUp = true; + double yCand = -999.; + const int chargeZero = 0; + if (doSelLcCollision) { + for (const auto& candidate : candidates) { + + if constexpr (isCandSc) { + int8_t chargeCand = candidate.charge(); + + if (chargeCand == chargeZero) { + yCand = hfHelper.ySc0(candidate); + } else { + yCand = hfHelper.yScPlusPlus(candidate); + } + + } else { + yCand = hfHelper.yLc(candidate); + } + + if (std::abs(yCand) > yCandMax || candidate.pt() < ptCandMin) { + isCandFound = false; + continue; + } + isCandFound = true; + break; + } + } + if (useSel8) { + isSel8 = collision.sel8(); + } + if (selNoSameBunchPileUpColl) { + isNosameBunchPileUp = static_cast(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)); + } + isSelColl = isCandFound && isSel8 && isNosameBunchPileUp; + candSel(isSelColl); + } + + template + void selectionCollisionMcGen(CandType const& mcParticles) + { + bool isCandFound = false; + double massCand = -999.0; + for (const auto& particle : mcParticles) { + + isCandFound = matchCandAndMass(particle, massCand); + if (!isCandFound) { + continue; + } + + double yCand = RecoDecay::y(particle.pVector(), massCand); + if (std::abs(yCand) > yCandMax || particle.pt() < ptCandMin) { + isCandFound = false; + continue; + } + + isCandFound = true; + break; + } + candSel(isCandFound); + } + + /// Code to select collisions with at least one Lc - for real data and data-like analysis + void processLcSelection(SelCollisions::iterator const& collision, + CandsLcDataFiltered const& candidates) + { + selectionCollision(collision, candidates); + } + PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processLcSelection, "Process Lc Collision Selection for Data and Mc", true); + + void processScSelection(SelCollisions::iterator const& collision, + aod::HfCandSc const& candidates) + { + selectionCollision(collision, candidates); + } + PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processScSelection, "Process Sc Collision Selection for Data and Mc", false); + + void processLcSelectionMcRec(SelCollisions::iterator const& collision, + CandsLcMcRecFiltered const& candidates) + { + selectionCollision(collision, candidates); + } + PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processLcSelectionMcRec, "Process Lc Selection McRec", false); + + void processScSelectionMcRec(SelCollisions::iterator const& collision, + CandsScMcRec const& candidates) + { + selectionCollision(collision, candidates); + } + PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processScSelectionMcRec, "Process Sc Selection McRec", false); + + void processLcSelectionMcGen(aod::McCollision const&, + CandidatesLcMcGen const& mcParticles) + { + selectionCollisionMcGen(mcParticles); + } + PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processLcSelectionMcGen, "Process Lc Selection McGen", false); + + void processScSelectionMcGen(aod::McCollision const&, + CandidatesScMcGen const& mcParticles) + { + selectionCollisionMcGen(mcParticles); + } + PROCESS_SWITCH(HfCorrelatorLcScHadronsSelection, processScSelectionMcGen, "Process Lc Selection McGen", false); +}; + +// Lc-Hadron correlation pair builder - for real data and data-like analysis (i.e. reco-level w/o matching request via Mc truth) +struct HfCorrelatorLcScHadrons { + Produces entryCandHadronPair; + Produces entryCandHadronPairY; + Produces entryCandHadronPairTrkPID; + Produces entryCandHadronRecoInfo; + Produces entryCandHadronMlInfo; + Produces entryCandCandRecoInfo; + Produces entryCandHadronGenInfo; + Produces entryCandCandGenInfo; + Produces entryTrackRecoInfo; + Produces entryCand; + Produces entryHadron; + Produces entryTrkPID; + Produces entryPairCandCharge; + Produces entryCandCharge; + + Configurable selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc"}; + Configurable numberEventsMixed{"numberEventsMixed", 5, "number of events mixed in ME process"}; + Configurable applyEfficiency{"applyEfficiency", 1, "Flag for applying Lc efficiency weights"}; + Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen. cand. rapidity"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "max. eta of tracks"}; + Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. DCAxy of tracks"}; + Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. DCAz of tracks"}; + Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; + Configurable ptCandMax{"ptCandMax", 50., "max. cand. pT"}; + Configurable ptTrackMin{"ptTrackMin", 0.3, "min. track pT"}; + Configurable ptTrackMax{"ptTrackMax", 50., "max. track pT"}; + Configurable multMin{"multMin", 0., "minimum multiplicity accepted"}; + Configurable multMax{"multMax", 10000., "maximum multiplicity accepted"}; + Configurable> classMl{"classMl", {0, 1, 2}, "Indexes of ML scores to be stored. Three indexes max."}; + Configurable> binsPtLc{"binsPtLc", std::vector{o2::analysis::hf_cuts_lc_to_p_k_pi::vecBinsPt}, "pT bin limits for candidate mass plots"}; + Configurable> binsPtHadron{"binsPtHadron", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for assoc particle"}; + Configurable> binsPtEfficiencyLc{"binsPtEfficiencyLc", std::vector{o2::analysis::hf_cuts_lc_to_p_k_pi::vecBinsPt}, "pT bin limits for efficiency"}; + Configurable> efficiencyLc{"efficiencyLc", {1., 1., 1., 1., 1., 1.}, "efficiency values for Lc"}; + Configurable storeAutoCorrelationFlag{"storeAutoCorrelationFlag", false, "Store flag that indicates if the track is paired to its Lc mother instead of skipping it"}; + Configurable correlateLcWithLeadingParticle{"correlateLcWithLeadingParticle", false, "Switch for correlation of Lc baryons with leading particle only"}; + Configurable pidTrkApplied{"pidTrkApplied", false, "Apply PID selection for associated tracks"}; + Configurable> trkPIDspecies{"trkPIDspecies", std::vector{o2::track::PID::Proton, o2::track::PID::Pion, o2::track::PID::Kaon}, "Trk sel: Particles species for PID, proton, pion, kaon"}; + Configurable> pidTPCMax{"pidTPCMax", std::vector{3., 0., 0.}, "maximum nSigma TPC"}; + Configurable> pidTOFMax{"pidTOFMax", std::vector{3., 0., 0.}, "maximum nSigma TOF"}; + Configurable tofPIDThreshold{"tofPIDThreshold", 0.75, "minimum pT after which TOF PID is applicable"}; + Configurable fillTrkPID{"fillTrkPID", false, "fill PID information for associated tracks"}; + Configurable forceTOF{"forceTOF", false, "fill PID information for associated tracks"}; + Configurable calTrkEff{"calTrkEff", false, "fill histograms to calculate efficiency"}; + Configurable isRecTrkPhyPrimary{"isRecTrkPhyPrimary", true, "Calculate the efficiency of reconstructed primary physical tracks"}; + Configurable calEffEventWithCand{"calEffEventWithCand", true, "Calculate the efficiency of Lc candidate"}; + Configurable eventFractionToAnalyze{"eventFractionToAnalyze", -1, "Fraction of events to analyze (use only for ME offline on very large samples)"}; + + HfHelper hfHelper; + SliceCache cache; + Service pdg; + int8_t chargeCand = 3; + int8_t signSoftPion = 0; + int leadingIndex = 0; + int poolBin = 0; + int poolBinLc = 0; + bool correlationStatus = false; + bool isPrompt = false; + bool isNonPrompt = false; + bool isSignal = false; + const int8_t chargeScPlusPlus = 2; + const int8_t chargeZero = 0; + const int8_t assignedChargeSc0 = 1; // to distingush sc0 from anti-sc0, charge set to +1 and -1 + + TRandom3* rnd = new TRandom3(0); + // std::vector outputMl = {-1., -1., -1.}; + std::vector outputMlPKPi = {-1., -1., -1.}; + std::vector outputMlPiKP = {-1., -1., -1.}; + + // Event Mixing for the Data Mode + // using SelCollisionsWithSc = soa::Join; + using SelCollisions = soa::Filtered>; + using SelCollisionsMc = soa::Filtered>; // collisionFilter applied + + using CandsLcData = soa::Join; + using CandsLcDataFiltered = soa::Filtered; + + // Event Mixing for the MCRec Mode + using CandsLcMcRec = soa::Join; + using CandsLcMcRecFiltered = soa::Filtered; + using CandidatesLcMcGen = soa::Join; // flagLcFilter applied + using CandsScMcRec = soa::Join; + using CandidatesScMcGen = soa::Join; + // Event Mixing for the MCGen Mode + using McCollisionsSel = soa::Filtered>; + using McParticlesSel = soa::Filtered; + // Tracks used in Data and MC + using TracksData = soa::Filtered>; // trackFilter applied + using TracksWithMc = soa::Filtered>; // trackFilter applied + // Filters for ME + Filter collisionFilter = aod::hf_selection_lc_collision::lcSel == true; + Filter lcFilter = ((o2::aod::hf_track_index::hfflag & static_cast(1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) != static_cast(0)) && (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc); + Filter trackFilter = (nabs(aod::track::eta) < etaTrackMax) && (nabs(aod::track::pt) > ptTrackMin) && (nabs(aod::track::dcaXY) < dcaXYTrackMax) && (nabs(aod::track::dcaZ) < dcaZTrackMax); + + Preslice perTrueCollision = o2::aod::mcparticle::mcCollisionId; + Preslice perCollisionID = aod::track::collisionId; + Preslice cand3ProngPerCol = aod::hf_cand::collisionId; + Preslice csndScPerCol = aod::hf_cand::collisionId; + + // configurable axis definition + ConfigurableAxis binsMultiplicity{"binsMultiplicity", {VARIABLE_WIDTH, 0.0f, 2000.0f, 6000.0f, 100000.0f}, "Mixing bins - multiplicity"}; + ConfigurableAxis binsZVtx{"binsZVtx", {VARIABLE_WIDTH, -10.0f, -2.5f, 2.5f, 10.0f}, "Mixing bins - z-vertex"}; + ConfigurableAxis binsMultiplicityMc{"binsMultiplicityMc", {VARIABLE_WIDTH, 0.0f, 20.0f, 50.0f, 500.0f}, "Mixing bins - MC multiplicity"}; // In MCGen multiplicity is defined by counting tracks + ConfigurableAxis binsBdtScore{"binsBdtScore", {100, 0., 1.}, "Bdt output scores"}; + ConfigurableAxis binsEta{"binsEta", {50, -2., 2.}, "#it{#eta}"}; + ConfigurableAxis binsPhi{"binsPhi", {64, -PIHalf, 3. * PIHalf}, "#it{#varphi}"}; + ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; + ConfigurableAxis binsMultFT0M{"binsMultFT0M", {600, 0., 6000.}, "Multiplicity as FT0M signal amplitude"}; + ConfigurableAxis binsCandMass{"binsCandMass", {200, 1.98, 2.58}, "inv. mass (p K #pi) (GeV/#it{c}^{2})"}; + + BinningType corrBinning{{binsZVtx, binsMultiplicity}, true}; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + void init(InitContext&) + { + AxisSpec axisCandMass = {binsCandMass, "inv. mass (p K #pi) (GeV/#it{c}^{2})"}; + AxisSpec axisEta = {binsEta, "#it{eta}"}; + AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; + AxisSpec axisPtLc = {static_cast>(binsPtLc), "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisPtHadron = {static_cast>(binsPtHadron), "#it{p}_{T} Hadron (GeV/#it{c})"}; + AxisSpec axisPtTrack = {500, 0, 50, "#it{p}_{T} Hadron (GeV/#it{c})"}; + AxisSpec axisMultiplicity = {binsMultiplicity, "Multiplicity"}; + AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; + AxisSpec axisPosZ = {binsZVtx, "PosZ"}; + AxisSpec axisBdtScore = {binsBdtScore, "Bdt score"}; + AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; + AxisSpec axisRapidity = {100, -2, 2, "Rapidity"}; + AxisSpec axisSign = {5, -2.5, 2.5, "Sign"}; + + registry.add("hPtCand", "Lc,Hadron candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtLc}}); + registry.add("hPtProng0", "Lc,Hadron candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtLc}}); + registry.add("hPtProng1", "Lc,Hadron candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtLc}}); + registry.add("hPtProng2", "Lc,Hadron candidates;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtLc}}); + registry.add("hSelectionStatusLcToPKPi", "Lc,Hadron candidates;selection status;entries", {HistType::kTH1F, {{8, -0.5, 7.5}}}); + registry.add("hSelectionStatusLcToPiKP", "Lc,Hadron candidates;selection status;entries", {HistType::kTH1F, {{8, -0.5, 7.5}}}); + registry.add("hEta", "Lc,Hadron candidates;candidate #it{#eta};entries", {HistType::kTH1F, {axisEta}}); + registry.add("hPhi", "Lc,Hadron candidates;candidate #it{#varphi};entries", {HistType::kTH1F, {axisPhi}}); + registry.add("hcountCandHadronPerEvent", "Lc,Hadron particles - MC gen;Number per event;entries", {HistType::kTH1F, {{21, -0.5, 20.5}}}); + registry.add("hMultiplicityPreSelection", "multiplicity prior to selection;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}); + registry.add("hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}); + registry.add("hMultFT0M", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}); + registry.add("hZvtx", "z vertex;z vertex;entries", {HistType::kTH1F, {{200, -20., 20.}}}); + registry.add("hCandBin", "Lc selected in pool Bin;pool Bin;entries", {HistType::kTH1F, {{9, 0., 9.}}}); + registry.add("hTracksBin", "Tracks selected in pool Bin;pool Bin;entries", {HistType::kTH1F, {{9, 0., 9.}}}); + registry.add("hMassLcVsPt", "Lc candidates;inv. mass (p K #pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{axisCandMass}, {axisPtLc}}}); + registry.add("hMassScVsPtVsSign", "Sc candidates;inv. mass (p K #pi) (GeV/#it{c}^{2});sign;entries", {HistType::kTH3F, {{axisCandMass}, {axisPtLc}, {axisSign}}}); + registry.add("hMassLcData", "Lc candidates;inv. mass (p K #pi) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{axisCandMass}}}); + registry.add("hLcPoolBin", "Lc candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hTracksPoolBin", "Particles associated pool bin", {HistType::kTH1F, {axisPoolBin}}); + // Histograms for MC Reco analysis + registry.add("hMcEvtCount", "Event counter - MC gen;;entries", {HistType::kTH1F, {{1, -0.5, 0.5}}}); + registry.add("hMassLcMcRecBkg", "Lc background candidates - MC reco;inv. mass (p K #pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{axisCandMass}, {axisPtLc}}}); + registry.add("hPtCandSig", "Lc,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPtLc}}); + registry.add("hPtCandSigPrompt", "Lc,Hadron candidates Prompt - MC Reco", {HistType::kTH1F, {axisPtLc}}); + registry.add("hPtCandSigNonPrompt", "Lc,Hadron candidates Non Prompt - MC Reco", {HistType::kTH1F, {axisPtLc}}); + registry.add("hPtCandMcRecBkg", "Lc,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPtLc}}); + registry.add("hEtaSig", "Lc,Hadron candidates - MC Reco", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiSig", "Lc,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPhi}}); + registry.add("hY", "Lc,Hadron candidates;candidate #it{#y};entries", {HistType::kTH1F, {axisRapidity}}); + registry.add("hYSig", "Lc,Hadron candidates - MC reco;candidate #it{#y};entries", {HistType::kTH1F, {axisRapidity}}); + registry.add("hPtCandMcRecSigPrompt", "Lc,Hadron candidates Prompt - MC Reco", {HistType::kTH1F, {axisPtLc}}); + registry.add("hPtCandMcRecSigNonPrompt", "Lc,Hadron candidates Non Prompt - MC Reco", {HistType::kTH1F, {axisPtLc}}); + registry.add("hEtaMcRecBkg", "Lc,Hadron candidates - MC Reco", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiMcRecBkg", "Lc,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPhi}}); + registry.add("hYMcRecBkg", "Lc,Hadron candidates - MC reco;candidate #it{#y};entries", {HistType::kTH1F, {axisRapidity}}); + registry.add("hFakeTracksMcRec", "Fake tracks - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtParticleAssocVsCandMcRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtHadron}, {axisPtLc}}}); + registry.add("hPtTracksVsSignRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtTrack}, {axisSign}}}); + registry.add("hPtTracksVsSignRecTrue", "Associated Particle - MC Rec (True)", {HistType::kTH2F, {{axisPtTrack}, {axisSign}}}); + registry.add("hPtTracksVsSignGen", "Associated Particle - MC Gen", {HistType::kTH2F, {{axisPtTrack}, {axisSign}}}); + registry.add("hPtPrimaryParticleAssocVsCandMcRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtHadron}, {axisPtLc}}}); + registry.add("hPtVsMultiplicityMcRecPrompt", "Multiplicity FT0M - MC Rec Prompt", {HistType::kTH2F, {{axisPtLc}, {axisMultFT0M}}}); + registry.add("hPtVsMultiplicityMcRecNonPrompt", "Multiplicity FT0M - MC Rec Non Prompt", {HistType::kTH2F, {{axisPtLc}, {axisMultFT0M}}}); + // Histograms for MC Gen analysis + registry.add("hcountCandtriggersMcGen", "Lc trigger particles - MC gen;;N of trigger Lc", {HistType::kTH2F, {{1, -0.5, 0.5}, {axisPtLc}}}); + registry.add("hPtCandMcGen", "Lc,Hadron particles - MC gen;particle #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtLc}}); + registry.add("hYMcGen", "Lc,Hadron candidates - MC gen;candidate #it{#y};entries", {HistType::kTH1F, {axisRapidity}}); + registry.add("hPtCandMcGenPrompt", "Lc,Hadron particles - MC Gen Prompt", {HistType::kTH1F, {axisPtLc}}); + registry.add("hPtCandVsChargeMcGenPrompt", "Charm Hadron particles - MC Gen Prompt", {HistType::kTH2F, {{axisPtLc}, {axisSign}}}); + registry.add("hPtCandMcGenNonPrompt", "Charm Hadron particles - MC Gen Non Prompt", {HistType::kTH1F, {axisPtLc}}); + registry.add("hPtCandVsChargeMcGenNonPrompt", "Lc,Hadron particles - MC Gen Non Prompt", {HistType::kTH2F, {{axisPtLc}, {axisSign}}}); + registry.add("hPtParticleAssocMcGen", "Associated Particle - MC Gen", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hEtaMcGen", "Lc,Hadron particles - MC Gen", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiMcGen", "Lc,Hadron particles - MC Gen", {HistType::kTH1F, {axisPhi}}); + registry.add("hMultFT0AMcGen", "Lc,Hadron multiplicity FT0A - MC Gen", {HistType::kTH1F, {axisMultiplicity}}); + + corrBinning = {{binsZVtx, binsMultiplicity}, true}; + } + + template + void fillMlOutput(MlProbType const& mlProb, std::vector& outputMl) + { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMl[iclass] = mlProb[classMl->at(iclass)]; + } + }; + + template + double estimateY(CandType const& candidate) + { + double y = -999.; + if constexpr (isCandSc) { + int8_t chargeCand = candidate.charge(); + + if (chargeCand == chargeZero) { + y = hfHelper.ySc0(candidate); + } else { + y = hfHelper.yScPlusPlus(candidate); + } + + } else { + y = hfHelper.yLc(candidate); + } + return y; + } + + template + void calculateTrkEff(T1 const& trackPos1, T2 const& trackPos2, McPart const& mcParticles) + { + // genrated tracks + decltype(trackPos1.template mcParticle_as()) mctrk{}; + if (trackPos1.has_mcParticle()) { // ambiguous tracks should be small + mctrk = trackPos1.template mcParticle_as(); + } else if (trackPos2.has_mcParticle()) { + mctrk = trackPos2.template mcParticle_as(); + } else { + return; + } + auto gentracks = mcParticles.sliceBy(perTrueCollision, mctrk.mcCollisionId()); + for (const auto& track : gentracks) { + if (std::abs(track.eta()) > etaTrackMax || track.pt() < ptTrackMin || track.pt() > ptTrackMax) { + continue; + } + if ((std::abs(track.pdgCode()) != kElectron) && (std::abs(track.pdgCode()) != kMuonMinus) && (std::abs(track.pdgCode()) != kPiPlus) && (std::abs(track.pdgCode()) != kKPlus) && (std::abs(track.pdgCode()) != kProton)) { + continue; + } + + if (pidTrkApplied && (std::abs(track.pdgCode()) != kProton)) + continue; // proton PID + + if (!track.isPhysicalPrimary()) { + continue; + } + + auto motherTrkGen = mcParticles.iteratorAt(track.mothersIds()[0]); + if (std::abs(motherTrkGen.pdgCode()) == kLambdaCPlus) + continue; + + auto chargeTrack = pdg->GetParticle(track.pdgCode())->Charge(); // Retrieve charge + registry.fill(HIST("hPtTracksVsSignGen"), track.pt(), chargeTrack / (std::abs(chargeTrack))); + } + } + template + void fillCorrelationTable(bool trkPidFill, TrackType const& track, CandType const& candidate, + const std::vector& outMl, int binPool, int8_t correlStatus, + double yCand, int signCand, McPart const& mcParticles) + { + bool isPhysicalPrimary = false; + int trackOrigin = -1; + + entryCandHadronPair(getDeltaPhi(track.phi(), candidate.phi()), + track.eta() - candidate.eta(), + candidate.pt(), + track.pt() * track.sign(), + binPool, + correlStatus); + entryCandHadronPairY(track.rapidity(MassProton) - yCand); + entryCandHadronMlInfo(outMl[0], outMl[1]); + entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.tpcNClsCrossedRows()); + entryPairCandCharge(signCand); + if (trkPidFill) { + entryCandHadronPairTrkPID(track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()); + } + if constexpr (isMcRec) { + if (track.has_mcParticle()) { + auto mcParticle = track.template mcParticle_as(); + isPhysicalPrimary = mcParticle.isPhysicalPrimary(); + trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); + entryCandHadronGenInfo(isPrompt, isPhysicalPrimary, trackOrigin); + } else { + entryCandHadronGenInfo(isPrompt, false, 0); + registry.fill(HIST("hFakeTracksMcRec"), track.pt()); + } + registry.fill(HIST("hPtParticleAssocVsCandMcRec"), track.pt(), candidate.pt()); + if (isPhysicalPrimary) { + registry.fill(HIST("hPtPrimaryParticleAssocVsCandMcRec"), track.pt(), candidate.pt()); + } + } + } + + template + void doSameEvent(CollisionType const& collision, + TrackType const& tracks, + CandType const& candidates, + aod::McParticles const* mcParticles = nullptr) + { + + int nTracks = 0; + int64_t timeStamp = 0; + bool skipMixedEventTableFilling = false; + float multiplicityFT0M = collision.multFT0M(); + int gCollisionId = collision.globalIndex(); + if (candidates.size() == 0) { + return; + } + + if (eventFractionToAnalyze > 0) { + if (rnd->Uniform(0, 1) > eventFractionToAnalyze) { + skipMixedEventTableFilling = true; + } + } + + if constexpr (!isMcRec) { + timeStamp = collision.template bc_as().timestamp(); + } + + poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), multiplicityFT0M)); + if (correlateLcWithLeadingParticle) { + leadingIndex = findLeadingParticle(tracks, etaTrackMax.value); + } + + // Count good tracks + if (collision.numContrib() > 1) { + for (const auto& track : tracks) { + if (std::abs(track.eta()) > etaTrackMax || std::abs(track.dcaXY()) > dcaXYTrackMax || std::abs(track.dcaZ()) > dcaZTrackMax) { + continue; + } + nTracks++; + } + } + + registry.fill(HIST("hMultiplicityPreSelection"), nTracks); + if (nTracks < multMin || nTracks > multMax) { + return; + } + registry.fill(HIST("hMultiplicity"), nTracks); + + int countCand = 1; + + for (const auto& candidate : candidates) { + double efficiencyWeightCand = 1.; + double yCand = -999.0; + double etaCand = -999.0; + double ptCandLc = -999.0; + double ptCand = -999.0; + double phiCand = -999.0; + double massCandPKPi = -999.0; + double massCandPiKP = -999.0; + bool selLcPKPi = false; + bool selLcPiKP = false; + + yCand = estimateY(candidate); + etaCand = candidate.eta(); + ptCand = candidate.pt(); + phiCand = RecoDecay::constrainAngle(candidate.phi(), -PIHalf); + + if ((std::abs(yCand) > yCandMax) || ptCand < ptCandMin || ptCand > ptCandMax) { + continue; + } + + registry.fill(HIST("hY"), yCand); + registry.fill(HIST("hPtCand"), ptCand); + registry.fill(HIST("hEta"), etaCand); + registry.fill(HIST("hPhi"), phiCand); + registry.fill(HIST("hCandBin"), poolBin); + + if (applyEfficiency) { + efficiencyWeightCand = 1. / efficiencyLc->at(o2::analysis::findBin(binsPtEfficiencyLc, ptCand)); + } + + if constexpr (isMcRec) { + isPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; + isNonPrompt = candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; + } + + if constexpr (isCandSc) { + chargeCand = candidate.charge(); + const auto& candidateLc = candidate.template prongLc_as(); + ptCandLc = candidateLc.pt(); + selLcPKPi = (candidateLc.isSelLcToPKPi() >= selectionFlagLc) && (candidate.statusSpreadLcMinvPKPiFromPDG()); + selLcPiKP = (candidateLc.isSelLcToPiKP() >= selectionFlagLc) && (candidate.statusSpreadLcMinvPiKPFromPDG()); + if (selLcPKPi) { + const auto& probs = candidateLc.mlProbLcToPKPi(); + fillMlOutput(probs, outputMlPKPi); + massCandPKPi = std::abs(hfHelper.invMassScRecoLcToPKPi(candidate, candidateLc) - hfHelper.invMassLcToPKPi(candidateLc)); + } + if (selLcPiKP) { + const auto& probs = candidateLc.mlProbLcToPiKP(); + fillMlOutput(probs, outputMlPiKP); + massCandPiKP = std::abs(hfHelper.invMassScRecoLcToPiKP(candidate, candidateLc) - hfHelper.invMassLcToPiKP(candidateLc)); + } + if constexpr (isMcRec) { + // isSignal = + // (TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi) && chargeCand == 0) || + // (TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi) && std::abs(chargeCand) == 2); + isSignal = + (std::abs(candidate.flagMcMatchRec()) == (1 << aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi) && chargeCand == chargeZero) || + (std::abs(candidate.flagMcMatchRec()) == (1 << aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi) && std::abs(chargeCand) == chargeScPlusPlus); + + auto trackPos1 = candidateLc.template prong0_as(); + auto trackPos2 = candidateLc.template prong2_as(); + signSoftPion = candidate.template prong1_as().sign(); + if (calTrkEff && countCand == 1 && (isSignal || !calEffEventWithCand)) { + calculateTrkEff(trackPos1, trackPos2, *mcParticles); + } + registry.fill(HIST("hPtProng1"), candidate.template prong1_as().pt()); + } else { + signSoftPion = candidate.template prong1_as().sign(); + registry.fill(HIST("hPtProng1"), candidate.prong1().pt()); + } + registry.fill(HIST("hPtProng0"), ptCandLc); + + if (chargeCand == chargeZero) { + chargeCand = (signSoftPion < chargeZero) ? assignedChargeSc0 : -assignedChargeSc0; // to distingush sc0 from anti-sc0, charge set to +1 and -1 + } + + } else { + selLcPKPi = candidate.isSelLcToPKPi() >= selectionFlagLc; + selLcPiKP = candidate.isSelLcToPiKP() >= selectionFlagLc; + if (selLcPKPi) { + const auto& probs = candidate.mlProbLcToPKPi(); + fillMlOutput(probs, outputMlPKPi); + massCandPKPi = hfHelper.invMassLcToPKPi(candidate); + } + if (selLcPiKP) { + const auto& probs = candidate.mlProbLcToPiKP(); + fillMlOutput(probs, outputMlPiKP); + massCandPiKP = hfHelper.invMassLcToPiKP(candidate); + } + auto trackPos1 = candidate.template prong0_as(); + auto trackPos2 = candidate.template prong2_as(); + chargeCand = trackPos1.sign(); + if constexpr (isMcRec) { + isSignal = std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi; + if (calTrkEff && countCand == 1 && (isSignal || !calEffEventWithCand)) { + calculateTrkEff(trackPos1, trackPos2, *mcParticles); + } + } + registry.fill(HIST("hPtProng0"), candidate.ptProng0()); + registry.fill(HIST("hPtProng1"), candidate.ptProng1()); + registry.fill(HIST("hPtProng2"), candidate.ptProng2()); + } + + if (isSignal) { + registry.fill(HIST("hPtCandSig"), ptCand); + registry.fill(HIST("hEtaSig"), ptCand); + registry.fill(HIST("hPhiSig"), phiCand); + registry.fill(HIST("hYSig"), yCand); + } + + if (selLcPKPi) { + registry.fill(HIST("hMassLcVsPt"), massCandPKPi, ptCand, efficiencyWeightCand); + registry.fill(HIST("hMassScVsPtVsSign"), massCandPKPi, ptCand, chargeCand, efficiencyWeightCand); + registry.fill(HIST("hMassLcData"), massCandPKPi, efficiencyWeightCand); + registry.fill(HIST("hSelectionStatusLcToPKPi"), selLcPKPi); + if (isPrompt) { + registry.fill(HIST("hPtCandSigPrompt"), ptCand); + registry.fill(HIST("hPtVsMultiplicityMcRecPrompt"), ptCand, multiplicityFT0M); + } else if (isNonPrompt) { + registry.fill(HIST("hPtCandSigNonPrompt"), ptCand); + registry.fill(HIST("hPtVsMultiplicityMcRecNonPrompt"), ptCand, multiplicityFT0M); + } + + entryCandCandRecoInfo(massCandPKPi, ptCand, outputMlPKPi[0], outputMlPKPi[1]); + entryCandCandGenInfo(isPrompt); + if (!skipMixedEventTableFilling) { + entryCand(candidate.phi(), etaCand, ptCand, massCandPKPi, poolBin, gCollisionId, timeStamp); + entryCandCharge(chargeCand); + } + } + + if (selLcPiKP) { + registry.fill(HIST("hMassLcVsPt"), massCandPiKP, ptCand, efficiencyWeightCand); + registry.fill(HIST("hMassScVsPtVsSign"), massCandPKPi, ptCand, chargeCand, efficiencyWeightCand); + registry.fill(HIST("hMassLcData"), massCandPiKP, efficiencyWeightCand); + registry.fill(HIST("hSelectionStatusLcToPiKP"), selLcPiKP); + if (isPrompt) { + registry.fill(HIST("hPtCandSigPrompt"), ptCand); + registry.fill(HIST("hPtVsMultiplicityMcRecPrompt"), ptCand, multiplicityFT0M); + } else if (isNonPrompt) { + registry.fill(HIST("hPtCandSigNonPrompt"), ptCand); + registry.fill(HIST("hPtVsMultiplicityMcRecNonPrompt"), ptCand, multiplicityFT0M); + } + entryCandCandRecoInfo(massCandPiKP, ptCand, outputMlPiKP[0], outputMlPiKP[1]); + entryCandCandGenInfo(isPrompt); + if (!skipMixedEventTableFilling) { + entryCand(candidate.phi(), etaCand, ptCand, massCandPiKP, poolBin, gCollisionId, timeStamp); + entryCandCharge(chargeCand); + } + } + + registry.fill(HIST("hCandBin"), poolBin); + // Correlation with hadrons + for (const auto& track : tracks) { + // Remove Lc daughters by checking track indices + if constexpr (!isCandSc) { + if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex()) || (candidate.prong2Id() == track.globalIndex())) { + if (!storeAutoCorrelationFlag) { + continue; + } + correlationStatus = true; + } + } else { + const auto& candidateLc = candidate.template prongLc_as(); + if ((candidateLc.prong0Id() == track.globalIndex()) || (candidateLc.prong1Id() == track.globalIndex()) || (candidateLc.prong2Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex())) { + if (!storeAutoCorrelationFlag) { + continue; + } + correlationStatus = true; + } + } + if (!track.isGlobalTrackWoDCA()) { + continue; + } + if (pidTrkApplied) { + if (!passPIDSelection(track, trkPIDspecies, pidTPCMax, pidTOFMax, tofPIDThreshold, forceTOF)) + continue; + } + if (correlateLcWithLeadingParticle) { + if (track.globalIndex() != leadingIndex) { + continue; + } + } + if constexpr (isMcRec) { + if (calTrkEff && countCand == 1 && (isSignal || !calEffEventWithCand) && track.has_mcParticle()) { + auto mcParticle = track.template mcParticle_as(); + if (!mcParticle.isPhysicalPrimary() && isRecTrkPhyPrimary) + continue; + + auto motherTrk = mcParticles->iteratorAt(mcParticle.mothersIds()[0]); + if (std::abs(motherTrk.pdgCode()) == kLambdaCPlus) + continue; + + registry.fill(HIST("hPtTracksVsSignRec"), track.pt(), track.sign()); + if (std::abs(mcParticle.pdgCode()) == kProton) + registry.fill(HIST("hPtTracksVsSignRecTrue"), track.pt(), track.sign()); + } + } + + if (selLcPKPi) { + fillCorrelationTable(fillTrkPID, track, candidate, outputMlPKPi, poolBin, correlationStatus, yCand, chargeCand, *mcParticles); + entryCandHadronRecoInfo(massCandPKPi, false); + } + if (selLcPiKP) { + fillCorrelationTable(fillTrkPID, track, candidate, outputMlPiKP, poolBin, correlationStatus, yCand, chargeCand, *mcParticles); + entryCandHadronRecoInfo(massCandPiKP, false); + } + + if (countCand == 1) { + if (!skipMixedEventTableFilling) { + entryHadron(track.phi(), track.eta(), track.pt() * track.sign(), poolBin, gCollisionId, timeStamp); + if (fillTrkPID) { + entryTrkPID(track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()); + } + registry.fill(HIST("hTracksBin"), poolBin); + } + } + } // end Hadron Tracks loop + countCand++; + } // end outer Lc loop + registry.fill(HIST("hZvtx"), collision.posZ()); + registry.fill(HIST("hMultFT0M"), multiplicityFT0M); + } + + template + void doMixEvent(CollisionType const& collisions, + TrackType const& tracks, + CandType const& candidates, + aod::McParticles const* mcParticles = nullptr) + { + + if (candidates.size() == 0) { + return; + } + + double yCand = -999.; + double ptCand = -999.; + int8_t chargeCand = 3; + double massCandPKPi = -999.0; + double massCandPiKP = -999.0; + bool selLcPKPi = false; + bool selLcPiKP = false; + + auto tracksTuple = std::make_tuple(candidates, tracks); + Pair pairData{corrBinning, numberEventsMixed, -1, collisions, tracksTuple, &cache}; + + for (const auto& [c1, tracks1, c2, tracks2] : pairData) { + poolBin = corrBinning.getBin(std::make_tuple(c2.posZ(), c2.multFT0M())); + poolBinLc = corrBinning.getBin(std::make_tuple(c1.posZ(), c1.multFT0M())); + registry.fill(HIST("hMultFT0M"), c1.multFT0M()); + registry.fill(HIST("hZvtx"), c1.posZ()); + registry.fill(HIST("hTracksPoolBin"), poolBin); + registry.fill(HIST("hLcPoolBin"), poolBinLc); + for (const auto& [candidate, assocParticle] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + + yCand = estimateY(candidate); + ptCand = candidate.pt(); + if constexpr (isMcRec) { + isPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; + isNonPrompt = candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; + } + + if constexpr (isCandSc) { + const auto& candidateLc = candidate.template prongLc_as(); + chargeCand = candidate.charge(); + + selLcPKPi = (candidateLc.isSelLcToPKPi() >= selectionFlagLc) && (candidate.statusSpreadLcMinvPKPiFromPDG()); + selLcPiKP = (candidateLc.isSelLcToPiKP() >= selectionFlagLc) && (candidate.statusSpreadLcMinvPiKPFromPDG()); + if (selLcPKPi) { + const auto& probs = candidateLc.mlProbLcToPKPi(); + fillMlOutput(probs, outputMlPKPi); + massCandPKPi = std::abs(hfHelper.invMassScRecoLcToPKPi(candidate, candidateLc) - hfHelper.invMassLcToPKPi(candidateLc)); + } + if (selLcPiKP) { + const auto& probs = candidateLc.mlProbLcToPiKP(); + fillMlOutput(probs, outputMlPiKP); + massCandPiKP = std::abs(hfHelper.invMassScRecoLcToPiKP(candidate, candidateLc) - hfHelper.invMassLcToPiKP(candidateLc)); + } + if constexpr (isMcRec) { + isSignal = + (TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi) && chargeCand == chargeZero) || + (TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi) && std::abs(chargeCand) == chargeScPlusPlus); + signSoftPion = candidate.template prong1_as().sign(); + } else { + signSoftPion = candidate.template prong1_as().sign(); + } + if (chargeCand == chargeZero) { + chargeCand = (signSoftPion < chargeZero) ? assignedChargeSc0 : -assignedChargeSc0; // to distingush sc0 from anti-sc0, charge set to +1 and -1 + } + } else { + selLcPKPi = candidate.isSelLcToPKPi() >= selectionFlagLc; + selLcPiKP = candidate.isSelLcToPiKP() >= selectionFlagLc; + if (selLcPKPi) { + const auto& probs = candidate.mlProbLcToPKPi(); + fillMlOutput(probs, outputMlPKPi); + massCandPKPi = hfHelper.invMassLcToPKPi(candidate); + } + if (selLcPiKP) { + const auto& probs = candidate.mlProbLcToPiKP(); + fillMlOutput(probs, outputMlPiKP); + massCandPiKP = hfHelper.invMassLcToPiKP(candidate); + } + auto trackPos1 = candidate.template prong0_as(); + chargeCand = trackPos1.sign(); + if constexpr (isMcRec) { + isSignal = std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi; + } + } + + if (!assocParticle.isGlobalTrackWoDCA() || std::abs(yCand) > yCandMax) { + continue; + } + + if (pidTrkApplied) { + if (!passPIDSelection(assocParticle, trkPIDspecies, pidTPCMax, pidTOFMax, tofPIDThreshold, forceTOF)) + continue; + } + + if (selLcPKPi) { + fillCorrelationTable(fillTrkPID, assocParticle, candidate, outputMlPKPi, poolBin, correlationStatus, yCand, chargeCand, *mcParticles); + entryCandHadronRecoInfo(massCandPKPi, false); + + if (isPrompt) { + registry.fill(HIST("hPtCandMcRecSigPrompt"), ptCand); + registry.fill(HIST("hPtVsMultiplicityMcRecPrompt"), ptCand, 0); + } else if (isNonPrompt) { + registry.fill(HIST("hPtCandMcRecSigNonPrompt"), ptCand); + registry.fill(HIST("hPtVsMultiplicityMcRecNonPrompt"), ptCand, 0); + } + } + + if (selLcPiKP) { + fillCorrelationTable(fillTrkPID, assocParticle, candidate, outputMlPiKP, poolBin, correlationStatus, yCand, chargeCand, *mcParticles); + entryCandHadronRecoInfo(massCandPiKP, false); + + if (isPrompt) { + registry.fill(HIST("hPtCandMcRecSigPrompt"), ptCand); + registry.fill(HIST("hPtVsMultiplicityMcRecPrompt"), ptCand, 0); + } else if (isNonPrompt) { + registry.fill(HIST("hPtCandMcRecSigNonPrompt"), ptCand); + registry.fill(HIST("hPtVsMultiplicityMcRecNonPrompt"), ptCand, 0); + } + } + } + } + } + + template + void doSameEventMcGen(CollisionType const& mcCollision, PartType const& mcParticles) + { + + int counterCharmCand = 0; + static constexpr std::size_t PDGChargeScale{3u}; + + registry.fill(HIST("hMcEvtCount"), 0); + BinningTypeMcGen corrBinningMcGen{{binsZVtx, binsMultiplicityMc}, true}; + poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), mcCollision.multMCFT0A())); + registry.fill(HIST("hMultFT0AMcGen"), mcCollision.multMCFT0A()); + + // find leading particle + if (correlateLcWithLeadingParticle) { + leadingIndex = findLeadingParticleMcGen(mcParticles, etaTrackMax.value, ptTrackMin.value); + } + // Mc Gen level + for (const auto& particle : mcParticles) { + + double massCand = -999.0; + bool isCandFound = isCandSc ? matchCandAndMass(particle, massCand) : matchCandAndMass(particle, massCand); + if (!isCandFound) { + continue; + } + double yCand = RecoDecay::y(particle.pVector(), massCand); + + if (std::abs(yCand) > yCandGenMax || particle.pt() < ptCandMin) { + continue; + } + registry.fill(HIST("hCandBin"), poolBin); + registry.fill(HIST("hPtCandMcGen"), particle.pt()); + registry.fill(HIST("hEtaMcGen"), particle.eta()); + registry.fill(HIST("hPhiMcGen"), RecoDecay::constrainAngle(particle.phi(), -PIHalf)); + registry.fill(HIST("hYMcGen"), yCand); + + int8_t chargeCand = pdg->GetParticle(particle.pdgCode())->Charge() / PDGChargeScale; // Retrieve charge + if (chargeCand == chargeZero) { + chargeCand = (particle.pdgCode() > chargeZero) ? assignedChargeSc0 : -assignedChargeSc0; // to distingush sc0 from anti-sc0, charge set to +1 and -1 + } + + isPrompt = particle.originMcGen() == RecoDecay::OriginType::Prompt; + isNonPrompt = particle.originMcGen() == RecoDecay::OriginType::NonPrompt; + if (isPrompt) { + registry.fill(HIST("hPtCandMcGenPrompt"), particle.pt()); + registry.fill(HIST("hPtCandVsChargeMcGenPrompt"), particle.pt(), chargeCand); + } else if (isNonPrompt) { + registry.fill(HIST("hPtCandMcGenNonPrompt"), particle.pt()); + registry.fill(HIST("hPtCandVsChargeMcGenNonPrompt"), particle.pt(), chargeCand); + } + + static constexpr std::size_t NDaughtersSc{4u}; + static constexpr std::size_t NDaughtersLc{3u}; + std::vector listDaughters{}; + listDaughters.clear(); + const std::size_t nDaughtersExpected = isCandSc ? NDaughtersSc : NDaughtersLc; + + if (isCandSc) { + if (massCand == o2::constants::physics::MassSigmaC0 || massCand == o2::constants::physics::MassSigmaCStar0) { + std::array arrDaughSc0PDG = {kProton, -kKPlus, kPiPlus, kPiMinus}; + RecoDecay::getDaughters(particle, &listDaughters, arrDaughSc0PDG, 2); + } else { + std::array arrDaughScPlusPDG = {kProton, -kKPlus, kPiPlus, kPiPlus}; + RecoDecay::getDaughters(particle, &listDaughters, arrDaughScPlusPDG, 2); + } + } else { + std::array arrDaughLcPDG = {kProton, -kKPlus, kPiPlus}; + RecoDecay::getDaughters(particle, &listDaughters, arrDaughLcPDG, 2); + } + + int counterDaughters = 0; + std::vector prongsId(nDaughtersExpected); + if (listDaughters.size() == nDaughtersExpected) { + for (const auto& dauIdx : listDaughters) { + auto daughI = mcParticles.rawIteratorAt(dauIdx - mcParticles.offset()); + counterDaughters += 1; + prongsId[counterDaughters - 1] = daughI.globalIndex(); + } + } + counterCharmCand++; + + // Lc Hadron correlation dedicated section + // if it's a Lc particle, search for Hadron and evalutate correlations + registry.fill(HIST("hcountCandtriggersMcGen"), 0, particle.pt()); // to count trigger Lc for normalisation + for (const auto& particleAssoc : mcParticles) { + if (std::abs(particleAssoc.eta()) > etaTrackMax || particleAssoc.pt() < ptTrackMin || particleAssoc.pt() > ptTrackMax) { + continue; + } + + if (std::find(prongsId.begin(), prongsId.end(), particleAssoc.globalIndex()) != prongsId.end()) { + if (!storeAutoCorrelationFlag) { + continue; + } + correlationStatus = true; + } + + if ((std::abs(particleAssoc.pdgCode()) != kElectron) && (std::abs(particleAssoc.pdgCode()) != kMuonMinus) && (std::abs(particleAssoc.pdgCode()) != kPiPlus) && (std::abs(particle.pdgCode()) != kKPlus) && (std::abs(particleAssoc.pdgCode()) != kProton)) { + continue; + } + + if (pidTrkApplied && (std::abs(particleAssoc.pdgCode()) != kProton)) + continue; // proton PID + + if (!particleAssoc.isPhysicalPrimary()) { + continue; + } + + if (correlateLcWithLeadingParticle) { + if (particleAssoc.globalIndex() != leadingIndex) { + continue; + } + } + + int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true); + int8_t chargeAssoc = pdg->GetParticle(particleAssoc.pdgCode())->Charge(); // Retrieve charge + chargeAssoc = chargeAssoc / std::abs(chargeAssoc); + registry.fill(HIST("hPtParticleAssocMcGen"), particleAssoc.pt()); + entryCandHadronPair(getDeltaPhi(particleAssoc.phi(), particle.phi()), + particleAssoc.eta() - particle.eta(), + particle.pt(), + particleAssoc.pt() * chargeAssoc, + poolBin, + correlationStatus); + entryCandHadronPairY(particleAssoc.y() - yCand); + entryCandHadronRecoInfo(massCand, true); + entryCandHadronGenInfo(isPrompt, particleAssoc.isPhysicalPrimary(), trackOrigin); + entryPairCandCharge(chargeCand); + } // end inner loop + } // end outer loop + registry.fill(HIST("hcountCandHadronPerEvent"), counterCharmCand); + registry.fill(HIST("hZvtx"), mcCollision.posZ()); + } + + //} + + /// Lc-hadron correlation pair builder - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) + void processDataLc(SelCollisions::iterator const& collision, + TracksData const& tracks, + CandsLcDataFiltered const& candidates, + aod::BCsWithTimestamps const&) + { + doSameEvent(collision, tracks, candidates); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processDataLc, "Process data", true); + + void processDataSc(SelCollisions::iterator const& collision, + TracksData const& tracks, + aod::Tracks const&, + aod::HfCandSc const& candidates, + CandsLcData const&, + aod::BCsWithTimestamps const&) // MUST be last among index-compatible + { + doSameEvent(collision, tracks, candidates); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processDataSc, "Process data Sc", false); + + /// Lc-Hadron correlation process starts for McRec + void processMcRecLc(SelCollisions::iterator const& collision, + TracksWithMc const& tracks, + CandsLcMcRecFiltered const& candidates, + aod::McParticles const& mcParticles) + { + doSameEvent(collision, tracks, candidates, &mcParticles); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processMcRecLc, "Process Mc Reco mode", false); + + /// Lc-Hadron correlation process starts for McRec + void processMcRecSc(SelCollisions::iterator const& collision, + TracksWithMc const& tracks, + aod::TracksWMc const&, + CandsScMcRec const& candidates, + CandsLcData const&, + aod::McParticles const& mcParticles) + { + doSameEvent(collision, tracks, candidates, &mcParticles); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processMcRecSc, "Process Mc Reco mode", false); + + void processDataMixedEventSc(SelCollisions const& collisions, + TracksData const& tracks, + aod::Tracks const&, + aod::HfCandSc const& candidates, + CandsLcData const&) + { + doMixEvent(collisions, tracks, candidates); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processDataMixedEventSc, "Process Mixed Event Data", false); + + void processDataMixedEventLc(SelCollisions const& collisions, + CandsLcDataFiltered const& candidates, + TracksData const& tracks) + { + + doMixEvent(collisions, tracks, candidates); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processDataMixedEventLc, "Process Mixed Event Data", false); + + void processMcRecMixedEventSc(SelCollisions const& collisions, + TracksWithMc const& tracks, + aod::TracksWMc const&, + soa::Join const& candidates, + CandsLcData const&, + aod::McParticles const& mcParticles) + { + doMixEvent(collisions, tracks, candidates, &mcParticles); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processMcRecMixedEventSc, "Process Mixed Event McRec", false); + + void processMcRecMixedEventLc(SelCollisions const& collisions, + CandsLcMcRecFiltered const& candidates, + TracksWithMc const& tracks, + aod::McParticles const& mcParticles) + { + doMixEvent(collisions, tracks, candidates, &mcParticles); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processMcRecMixedEventLc, "Process Mixed Event McRec", false) + + /// Lc-Hadron correlation pair builder - for Mc Gen-level analysis + void processMcGenLc(SelCollisionsMc::iterator const& mcCollision, + CandidatesLcMcGen const& mcParticles) + { + doSameEventMcGen(mcCollision, mcParticles); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processMcGenLc, "Process Mc Gen Lc mode", false); + + void processMcGenSc(SelCollisionsMc::iterator const& mcCollision, + CandidatesScMcGen const& mcParticles) + { + doSameEventMcGen(mcCollision, mcParticles); + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processMcGenSc, "Process Mc Gen Sc mode", false); + + void processMcGenMixedEvent(SelCollisionsMc const& collisions, + CandidatesLcMcGen const& mcParticles) + { + BinningTypeMcGen corrBinningMcGen{{binsZVtx, binsMultiplicityMc}, true}; + auto tracksTuple = std::make_tuple(mcParticles, mcParticles); + Pair pairMcGen{corrBinningMcGen, numberEventsMixed, -1, collisions, tracksTuple, &cache}; + for (const auto& [c1, tracks1, c2, tracks2] : pairMcGen) { + poolBin = corrBinningMcGen.getBin(std::make_tuple(c1.posZ(), c1.multMCFT0A())); + for (const auto& [candidate, particleAssoc] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (std::abs(candidate.pdgCode()) != Pdg::kLambdaCPlus) { + continue; + } + double yL = RecoDecay::y(candidate.pVector(), MassLambdaCPlus); + if (std::abs(yL) > yCandGenMax || candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { + continue; + } + if (std::abs(particleAssoc.eta()) > etaTrackMax || particleAssoc.pt() < ptTrackMin || particleAssoc.pt() > ptTrackMax) { + continue; + } + if ((std::abs(particleAssoc.pdgCode()) != kElectron) && (std::abs(particleAssoc.pdgCode()) != kMuonMinus) && (std::abs(particleAssoc.pdgCode()) != kPiPlus) && (std::abs(particleAssoc.pdgCode()) != kKPlus) && (std::abs(particleAssoc.pdgCode()) != kProton)) { + continue; + } + if (!particleAssoc.isPhysicalPrimary()) { + continue; + } + if (pidTrkApplied && (std::abs(particleAssoc.pdgCode()) != kProton)) { + continue; // proton PID + } + int8_t chargeLc = pdg->GetParticle(candidate.pdgCode())->Charge(); // Retrieve charge + int8_t chargeAssoc = pdg->GetParticle(particleAssoc.pdgCode())->Charge(); // Retrieve charge + + int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true); + bool isPrompt = candidate.originMcGen() == RecoDecay::OriginType::Prompt; + entryCandHadronPair(getDeltaPhi(particleAssoc.phi(), candidate.phi()), + particleAssoc.eta() - candidate.eta(), + candidate.pt() * chargeLc / std::abs(chargeLc), + particleAssoc.pt() * chargeAssoc / std::abs(chargeAssoc), + poolBin, + correlationStatus); + entryCandHadronPairY(particleAssoc.y() - yL); + entryCandHadronRecoInfo(MassLambdaCPlus, true); + entryCandHadronGenInfo(isPrompt, particleAssoc.isPhysicalPrimary(), trackOrigin); + } + } + } + PROCESS_SWITCH(HfCorrelatorLcScHadrons, processMcGenMixedEvent, "Process Mixed Event McGen", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/HFC/TableProducer/femtoDreamProducer.cxx b/PWGHF/HFC/TableProducer/femtoDreamProducer.cxx index 3ed86b564cf..a605bc74f6c 100644 --- a/PWGHF/HFC/TableProducer/femtoDreamProducer.cxx +++ b/PWGHF/HFC/TableProducer/femtoDreamProducer.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -14,37 +14,57 @@ /// \author Ravindra Singh, GSI, ravindra.singh@cern.ch /// \author Biao Zhang, Heidelberg University, biao.zhang@cern.ch -#include -#include -#include "CCDB/BasicCCDBManager.h" - -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" - -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DetectorsBase/Propagator.h" - -#include "Framework/ASoAHelpers.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h" +#include "PWGCF/DataModel/FemtoDerived.h" +#include "PWGCF/FemtoDream/Core/femtoDreamSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamTrackSelection.h" #include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" - +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponseLcToPKPi.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" -#include "PWGHF/Core/CentralityEstimation.h" + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; +using namespace o2::analysis; using namespace o2::framework::expressions; using namespace o2::analysis::femtoDream; using namespace o2::hf_evsel; @@ -52,12 +72,19 @@ using namespace o2::hf_centrality; // event types enum Event : uint8_t { - kAll = 0, - kRejEveSel, - kRejNoTracksAndCharm, - kTrackSelected, - kCharmSelected, - kPairSelected + All = 0, + RejEveSel, + RejNoTracksAndCharm, + TrackSelected, + CharmSelected, + PairSelected +}; + +// ml modes +enum MlMode : uint8_t { + NoMl = 0, + FillMlFromSelector, + FillMlFromNewBDT }; struct HfFemtoDreamProducer { @@ -82,6 +109,11 @@ struct HfFemtoDreamProducer { Configurable ccdbPathGrp{"ccdbPathGrp", "GLO/GRP/GRP", "Path of the grp file (Run 2)"}; Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"EventFiltering/PWGHF/BDTLc"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_LcToPKPi.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + // Configurable isForceGRP{"isForceGRP", false, "Set true if the magnetic field configuration is not available in the usual CCDB directory (e.g. for Run 2 converted data or unanchorad Monte Carlo)"}; Configurable isDebug{"isDebug", true, "Enable Debug tables"}; @@ -108,37 +140,46 @@ struct HfFemtoDreamProducer { Configurable> trkTPCsCls{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCsClsMax, "trk"), std::vector{0.1f, 160.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCsClsMax, "Track selection: ")}; Configurable> trkITSnclsIbMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kITSnClsIbMin, "trk"), std::vector{-1.f, 1.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kITSnClsIbMin, "Track selection: ")}; Configurable> trkITSnclsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kITSnClsMin, "trk"), std::vector{-1.f, 2.f, 4.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kITSnClsMin, "Track selection: ")}; + // ML inference + Configurable applyMlMode{"applyMlMode", 1, "None: 0, BDT model from Lc selector: 1, New BDT model on Top of Lc selector: 2"}; + Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; + Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; - using CandidateLc = soa::Join; - using CandidateLcMc = soa::Join; + FemtoDreamTrackSelection trackCuts; + + HfHelper hfHelper; + o2::analysis::HfMlResponseLcToPKPi hfMlResponse; + std::vector outputMlPKPi = {}; + std::vector outputMlPiKP = {}; + o2::ccdb::CcdbApi ccdbApi; + o2::hf_evsel::HfEventSelection hfEvSel; + Service ccdb; /// Accessing the CCDB + o2::base::MatLayerCylSet* lut; + // if (doPvRefit){ lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut));} //! may be it useful, will check later + + float magField; + int runNumber; + using CandidateLc = soa::Join; + using CandidateLcMc = soa::Join; using FemtoFullCollision = soa::Join::iterator; using FemtoFullCollisionMc = soa::Join::iterator; using FemtoFullMcgenCollisions = soa::Join; using FemtoFullMcgenCollision = FemtoFullMcgenCollisions::iterator; - using FemtoHFTracks = soa::Join; + using FemtoHFTracks = soa::Join; using FemtoHFTrack = FemtoHFTracks::iterator; using FemtoHFMcTracks = soa::Join; using FemtoHFMcTrack = FemtoHFMcTracks::iterator; using GeneratedMc = soa::Filtered>; - FemtoDreamTrackSelection trackCuts; - Filter filterSelectCandidateLc = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc); HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry TrackRegistry{"Tracks", {}, OutputObjHandlingPolicy::AnalysisObject}; - - HfHelper hfHelper; - o2::hf_evsel::HfEventSelection hfEvSel; - - float magField; - int runNumber; - - Service ccdb; /// Accessing the CCDB - o2::base::MatLayerCylSet* lut; - // if (doPvRefit){ lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut));} //! may be it useful, will check later + HistogramRegistry trackRegistry{"Tracks", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(InitContext&) { @@ -147,18 +188,18 @@ struct HfFemtoDreamProducer { LOGP(fatal, "One and only one process function must be enabled at a time."); } - int CutBits = 8 * sizeof(o2::aod::femtodreamparticle::cutContainerType); - TrackRegistry.add("AnalysisQA/CutCounter", "; Bit; Counter", kTH1F, {{CutBits + 1, -0.5, CutBits + 0.5}}); + int cutBits = 8 * sizeof(o2::aod::femtodreamparticle::cutContainerType); + trackRegistry.add("AnalysisQA/CutCounter", "; Bit; Counter", kTH1F, {{cutBits + 1, -0.5, cutBits + 0.5}}); // event QA histograms - constexpr int kEventTypes = kPairSelected + 1; + constexpr int kEventTypes = PairSelected + 1; std::string labels[kEventTypes]; - labels[Event::kAll] = "All events"; - labels[Event::kRejEveSel] = "rejected by event selection"; - labels[Event::kRejNoTracksAndCharm] = "rejected by no tracks and charm"; - labels[Event::kTrackSelected] = "with tracks "; - labels[Event::kCharmSelected] = "with charm hadrons "; - labels[Event::kPairSelected] = "with pairs"; + labels[Event::All] = "All events"; + labels[Event::RejEveSel] = "rejected by event selection"; + labels[Event::RejNoTracksAndCharm] = "rejected by no tracks and charm"; + labels[Event::TrackSelected] = "with tracks "; + labels[Event::CharmSelected] = "with charm hadrons "; + labels[Event::PairSelected] = "with pairs"; static const AxisSpec axisEvents = {kEventTypes, 0.5, kEventTypes + 0.5, ""}; qaRegistry.add("hEventQA", "Events;;entries", HistType::kTH1F, {axisEvents}); @@ -181,7 +222,7 @@ struct HfFemtoDreamProducer { trackCuts.setSelection(trkPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit); trackCuts.setPIDSpecies(trkPIDspecies); trackCuts.setnSigmaPIDOffset(trkPIDnSigmaOffsetTPC, trkPIDnSigmaOffsetTOF); - trackCuts.init(&qaRegistry, &TrackRegistry); + trackCuts.init(&qaRegistry, &trackRegistry); runNumber = 0; magField = 0.0; @@ -194,6 +235,18 @@ struct HfFemtoDreamProducer { int64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); ccdb->setCreatedNotAfter(now); + + if (applyMlMode == FillMlFromNewBDT) { + hfMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponse.setModelPathsLocal(onnxFileNames); + } + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponse.init(); + } } /// Function to retrieve the nominal magnetic field in kG (0.1T) and convert it directly to T @@ -228,9 +281,12 @@ struct HfFemtoDreamProducer { particle.tofNSigmaKa(), particle.tofNSigmaPr(), particle.tofNSigmaDe(), - -999., - -999., - -999., -999., -999., -999., -999., -999.); + -999., -999., -999., -999., + -999., -999., -999., -999., + -999., -999., -999., -999., + -999., -999., -999., -999., + -999., -999., -999., -999., + -999., -999., -999.); } template @@ -242,11 +298,12 @@ struct HfFemtoDreamProducer { auto pdgCode = particleMc.pdgCode(); int particleOrigin = 99; int pdgCodeMother = -1; + constexpr int GenFromTransport = -1; // -1 if a particle produced during transport // get list of mothers, but it could be empty (for example in case of injected light nuclei) auto motherparticlesMc = particleMc.template mothers_as(); // check pdg code // if this fails, the particle is a fake - if (abs(pdgCode) == abs(trkPDGCode.value)) { + if (std::abs(pdgCode) == std::abs(trkPDGCode.value)) { // check first if particle is from pile up // check if the collision associated with the particle is the same as the analyzed collision by checking their Ids if ((col.has_mcCollision() && (particleMc.mcCollisionId() != col.mcCollisionId())) || !col.has_mcCollision()) { @@ -258,7 +315,7 @@ struct HfFemtoDreamProducer { // particle is from a decay -> getProcess() == 4 // particle is generated during transport -> getGenStatusCode() == -1 // list of mothers is not empty - } else if (particleMc.getProcess() == 4 && particleMc.getGenStatusCode() == -1 && !motherparticlesMc.empty()) { + } else if (particleMc.getProcess() == TMCProcess::kPDecay && particleMc.getGenStatusCode() == GenFromTransport && !motherparticlesMc.empty()) { // get direct mother auto motherparticleMc = motherparticlesMc.front(); pdgCodeMother = motherparticleMc.pdgCode(); @@ -266,7 +323,7 @@ struct HfFemtoDreamProducer { // check if particle is material // particle is from inelastic hadronic interaction -> getProcess() == 23 // particle is generated during transport -> getGenStatusCode() == -1 - } else if (particleMc.getProcess() == 23 && particleMc.getGenStatusCode() == -1) { + } else if (particleMc.getProcess() == TMCProcess::kPHInhelastic && particleMc.getGenStatusCode() == GenFromTransport) { particleOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kMaterial; // cross check to see if we missed a case } else { @@ -311,7 +368,7 @@ struct HfFemtoDreamProducer { // std::vector tmpIDtrack; // this vector keeps track of the matching of the primary track table row <-> aod::track table global index bool fIsTrackFilled = false; - for (auto& track : tracks) { + for (const auto& track : tracks) { /// if the most open selection criteria are not fulfilled there is no /// point looking further at the track if (!trackCuts.isSelectedMinimal(track)) { @@ -320,7 +377,7 @@ struct HfFemtoDreamProducer { trackCuts.fillQA(track); // the bit-wise container of the systematic variations is obtained - auto cutContainer = trackCuts.getCutContainer(track, track.pt(), track.eta(), sqrtf(powf(track.dcaXY(), 2.f) + powf(track.dcaZ(), 2.f))); + auto cutContainer = trackCuts.getCutContainer(track, track.pt(), track.eta(), sqrtf(powf(track.dcaXY(), 2.f) + powf(track.dcaZ(), 2.f))); // track global index outputPartsIndex(track.globalIndex()); @@ -369,18 +426,18 @@ struct HfFemtoDreamProducer { const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(col, mult, ccdb, qaRegistry); - qaRegistry.fill(HIST("hEventQA"), 1 + Event::kAll); + qaRegistry.fill(HIST("hEventQA"), 1 + Event::All); /// monitor the satisfied event selections hfEvSel.fillHistograms(col, rejectionMask, mult); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate - qaRegistry.fill(HIST("hEventQA"), 1 + Event::kRejEveSel); + qaRegistry.fill(HIST("hEventQA"), 1 + Event::RejEveSel); return; } if (isNoSelectedTracks(col, tracks, trackCuts) && sizeCand <= 0) { - qaRegistry.fill(HIST("hEventQA"), 1 + Event::kRejNoTracksAndCharm); + qaRegistry.fill(HIST("hEventQA"), 1 + Event::RejNoTracksAndCharm); return; } @@ -392,58 +449,81 @@ struct HfFemtoDreamProducer { // Filling candidate properties rowCandCharmHad.reserve(sizeCand); bool isTrackFilled = false; + bool isSelectedMlLcToPKPi = true; + bool isSelectedMlLcToPiKP = true; for (const auto& candidate : candidates) { - std::array outputMlPKPi{-1., -1., -1.}; - std::array outputMlPiKP{-1., -1., -1.}; + outputMlPKPi = {-1.0f, -1.0f, -1.0f}; + outputMlPiKP = {-1.0f, -1.0f, -1.0f}; + auto trackPos1 = candidate.template prong0_as(); // positive daughter (negative for the antiparticles) + auto trackNeg = candidate.template prong1_as(); // negative daughter (positive for the antiparticles) + auto trackPos2 = candidate.template prong2_as(); // positive daughter (negative for the antiparticles) + if constexpr (useCharmMl) { /// fill with ML information /// BDT index 0: bkg score; BDT index 1: prompt score; BDT index 2: non-prompt score - if (candidate.mlProbLcToPKPi().size() > 0) { - outputMlPKPi.at(0) = candidate.mlProbLcToPKPi()[0]; /// bkg score - outputMlPKPi.at(1) = candidate.mlProbLcToPKPi()[1]; /// prompt score - outputMlPKPi.at(2) = candidate.mlProbLcToPKPi()[2]; /// non-prompt score - } - if (candidate.mlProbLcToPiKP().size() > 0) { - outputMlPiKP.at(0) = candidate.mlProbLcToPiKP()[0]; /// bkg score - outputMlPiKP.at(1) = candidate.mlProbLcToPiKP()[1]; /// prompt score - outputMlPiKP.at(2) = candidate.mlProbLcToPiKP()[2]; /// non-prompt score + if (applyMlMode == FillMlFromSelector) { + if (candidate.mlProbLcToPKPi().size() > 0) { + outputMlPKPi.at(0) = candidate.mlProbLcToPKPi()[0]; /// bkg score + outputMlPKPi.at(1) = candidate.mlProbLcToPKPi()[1]; /// prompt score + outputMlPKPi.at(2) = candidate.mlProbLcToPKPi()[2]; /// non-prompt score + } + if (candidate.mlProbLcToPiKP().size() > 0) { + outputMlPiKP.at(0) = candidate.mlProbLcToPiKP()[0]; /// bkg score + outputMlPiKP.at(1) = candidate.mlProbLcToPiKP()[1]; /// prompt score + outputMlPiKP.at(2) = candidate.mlProbLcToPiKP()[2]; /// non-prompt score + } + } else if (applyMlMode == FillMlFromNewBDT) { + isSelectedMlLcToPKPi = false; + isSelectedMlLcToPiKP = false; + if (candidate.mlProbLcToPKPi().size() > 0) { + std::vector inputFeaturesLcToPKPi = hfMlResponse.getInputFeatures(candidate, true); + isSelectedMlLcToPKPi = hfMlResponse.isSelectedMl(inputFeaturesLcToPKPi, candidate.pt(), outputMlPKPi); + } + if (candidate.mlProbLcToPiKP().size() > 0) { + std::vector inputFeaturesLcToPiKP = hfMlResponse.getInputFeatures(candidate, false); + isSelectedMlLcToPiKP = hfMlResponse.isSelectedMl(inputFeaturesLcToPiKP, candidate.pt(), outputMlPKPi); + } + if (!isSelectedMlLcToPKPi && !isSelectedMlLcToPiKP) + continue; + } else { + LOGF(fatal, "Please check your Ml configuration!!"); } } - auto trackPos1 = candidate.template prong0_as(); // positive daughter (negative for the antiparticles) - auto trackNeg = candidate.template prong1_as(); // negative daughter (positive for the antiparticles) - auto trackPos2 = candidate.template prong2_as(); // positive daughter (negative for the antiparticles) - + auto bc = col.template bc_as(); + int64_t timeStamp = bc.timestamp(); auto fillTable = [&](int CandFlag, int FunctionSelection, float BDTScoreBkg, float BDTScorePrompt, float BDTScoreFD) { if (FunctionSelection >= 1){ - rowCandCharmHad( - outputCollision.lastIndex(), - trackPos1.sign() + trackNeg.sign() + trackPos2.sign(), - trackPos1.globalIndex(), - trackNeg.globalIndex(), - trackPos2.globalIndex(), - trackPos1.pt(), - trackNeg.pt(), - trackPos2.pt(), - trackPos1.eta(), - trackNeg.eta(), - trackPos2.eta(), - trackPos1.phi(), - trackNeg.phi(), - trackPos2.phi(), - 1 << CandFlag, - BDTScoreBkg, - BDTScorePrompt, - BDTScoreFD); - - // Row for MC candidate charm hadron (if constexpr isMc) - if constexpr (isMc) { - rowCandMcCharmHad( - candidate.flagMcMatchRec(), - candidate.originMcRec());} + rowCandCharmHad( + outputCollision.lastIndex(), + timeStamp, + trackPos1.sign() + trackNeg.sign() + trackPos2.sign(), + trackPos1.globalIndex(), + trackNeg.globalIndex(), + trackPos2.globalIndex(), + trackPos1.pt(), + trackNeg.pt(), + trackPos2.pt(), + trackPos1.eta(), + trackNeg.eta(), + trackPos2.eta(), + trackPos1.phi(), + trackNeg.phi(), + trackPos2.phi(), + 1 << CandFlag, + BDTScoreBkg, + BDTScorePrompt, + BDTScoreFD); + + // Row for MC candidate charm hadron (if constexpr isMc) + if constexpr (isMc) { + rowCandMcCharmHad( + candidate.flagMcMatchRec(), + candidate.originMcRec()); + } } }; fillTable(0, candidate.isSelLcToPKPi(), outputMlPKPi.at(0), outputMlPKPi.at(1), outputMlPKPi.at(2)); @@ -458,17 +538,17 @@ struct HfFemtoDreamProducer { aod::femtodreamcollision::BitMaskType bitTrack = 0; if (isTrackFilled) { bitTrack |= 1 << 0; - qaRegistry.fill(HIST("hEventQA"), 1 + Event::kTrackSelected); + qaRegistry.fill(HIST("hEventQA"), 1 + Event::TrackSelected); } aod::femtodreamcollision::BitMaskType bitCand = 0; if (sizeCand > 0) { bitCand |= 1 << 0; - qaRegistry.fill(HIST("hEventQA"), 1 + Event::kCharmSelected); + qaRegistry.fill(HIST("hEventQA"), 1 + Event::CharmSelected); } if (isTrackFilled && (sizeCand > 0)) - qaRegistry.fill(HIST("hEventQA"), 1 + Event::kPairSelected); + qaRegistry.fill(HIST("hEventQA"), 1 + Event::PairSelected); rowMasks(static_cast(bitTrack), static_cast(bitCand), @@ -497,7 +577,7 @@ struct HfFemtoDreamProducer { // Filling particle properties rowCandCharmHadGen.reserve(particles.size()); for (const auto& particle : particles) { - if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(particle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { rowCandCharmHadGen( particle.mcCollisionId(), particle.flagMcMatchGen(), diff --git a/PWGHF/HFC/Tasks/taskCharmHadronsFemtoDream.cxx b/PWGHF/HFC/Tasks/taskCharmHadronsFemtoDream.cxx index 9faaa37360a..bd9c2679ff5 100644 --- a/PWGHF/HFC/Tasks/taskCharmHadronsFemtoDream.cxx +++ b/PWGHF/HFC/Tasks/taskCharmHadronsFemtoDream.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2022 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -14,25 +14,36 @@ /// \author Ravindra SIngh, GSI, ravindra.singh@cern.ch /// \author Biao Zhang, Heidelberg University, biao.zhang@cern.ch -#include -#include - -#include "Framework/Expressions.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/StepTHn.h" - #include "PWGCF/DataModel/FemtoDerived.h" -#include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h" -#include "PWGCF/FemtoDream/Core/femtoDreamEventHisto.h" -#include "PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h" #include "PWGCF/FemtoDream/Core/femtoDreamContainer.h" #include "PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h" +#include "PWGCF/FemtoDream/Core/femtoDreamEventHisto.h" +#include "PWGCF/FemtoDream/Core/femtoDreamMath.h" +#include "PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h" +#include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h" #include "PWGCF/FemtoDream/Core/femtoDreamUtils.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::soa; @@ -47,12 +58,6 @@ struct HfTaskCharmHadronsFemtoDream { NegativeCharge = -1 }; - enum PairSign { - PairNotDefined = 0, - LikeSignPair = 1, - UnLikeSignPair = 2 - }; - /// Binning configurables ConfigurableAxis bin4Dkstar{"bin4Dkstar", {1500, 0., 6.}, "binning kstar for the 4Dimensional plot: k* vs multiplicity vs multiplicity percentile vs mT (set <> to true in order to use)"}; ConfigurableAxis bin4DMult{"bin4Dmult", {VARIABLE_WIDTH, 0.0f, 4.0f, 8.0f, 12.0f, 16.0f, 20.0f, 24.0f, 28.0f, 32.0f, 36.0f, 40.0f, 44.0f, 48.0f, 52.0f, 56.0f, 60.0f, 64.0f, 68.0f, 72.0f, 76.0f, 80.0f, 84.0f, 88.0f, 92.0f, 96.0f, 100.0f, 200.0f}, "multiplicity Binning for the 4Dimensional plot: k* vs multiplicity vs multiplicity percentile vs mT (set <> to true in order to use)"}; @@ -195,7 +200,9 @@ struct HfTaskCharmHadronsFemtoDream { SliceCache cache; Preslice perCol = aod::femtodreamparticle::fdCollisionId; - Produces fillFemtoResult; + Produces rowFemtoResultCharm; + Produces rowFemtoResultTrk; + Produces rowFemtoResultColl; void init(InitContext& /*context*/) { @@ -204,8 +211,8 @@ struct HfTaskCharmHadronsFemtoDream { colBinningMultPercentile = {{mixingBinVztx, mixingBinMultPercentile}, true}; colBinningMultMultPercentile = {{mixingBinVztx, mixingBinMult, mixingBinMultPercentile}, true}; eventHisto.init(®istry); - allTrackHisto.init(®istry, binmultTempFit, binMulPercentile, binpTTrack, binEta, binPhi, binTempFitVarTrack, binNSigmaTPC, binNSigmaTOF, binNSigmaTPCTOF, binTPCClusters, dummy, isMc, pdgCodeTrack1, true); - selectedTrackHisto.init(®istry, binmultTempFit, binMulPercentile, binpTTrack, binEta, binPhi, binTempFitVarTrack, binNSigmaTPC, binNSigmaTOF, binNSigmaTPCTOF, binTPCClusters, dummy, isMc, pdgCodeTrack1, true); + allTrackHisto.init(®istry, binmultTempFit, binMulPercentile, binpTTrack, binEta, binPhi, binTempFitVarTrack, binNSigmaTPC, binNSigmaTOF, binNSigmaTPCTOF, binTPCClusters, dummy, dummy, isMc, pdgCodeTrack1, true); + selectedTrackHisto.init(®istry, binmultTempFit, binMulPercentile, binpTTrack, binEta, binPhi, binTempFitVarTrack, binNSigmaTPC, binNSigmaTOF, binNSigmaTPCTOF, binTPCClusters, dummy, dummy, isMc, pdgCodeTrack1, true); sameEventCont.init(®istry, binkstar, binpTTrack, binkT, binmT, mixingBinMult, mixingBinMultPercentile, @@ -248,8 +255,6 @@ struct HfTaskCharmHadronsFemtoDream { { fillCollision(col); - processType = 1; // for same event - for (auto const& [p1, p2] : combinations(CombinationsFullIndexPolicy(sliceTrk1, sliceCharmHad))) { if (p1.trackId() == p2.prong0Id() || p1.trackId() == p2.prong1Id() || p1.trackId() == p2.prong2Id()) @@ -273,24 +278,11 @@ struct HfTaskCharmHadronsFemtoDream { chargeTrack = NegativeCharge; } - int pairSign = 0; - if (chargeTrack == p2.charge()) { - pairSign = LikeSignPair; - } else { - pairSign = UnLikeSignPair; - } - float kstar = FemtoDreamMath::getkstar(p1, massOne, p2, massTwo); if (kstar > highkstarCut) { continue; } - // if (chargeTrack == 1) { - // partSign = 1; - // } else { - // partSign = 1 << 1; - // } - float invMass; if (p2.candidateSelFlag() == 1) { invMass = p2.m(std::array{o2::constants::physics::MassProton, o2::constants::physics::MassKPlus, o2::constants::physics::MassPiPlus}); @@ -314,24 +306,40 @@ struct HfTaskCharmHadronsFemtoDream { charmHadMc = p2.flagMc(); originType = p2.originMcRec(); } - fillFemtoResult( + + rowFemtoResultCharm( + col.globalIndex(), + p2.timeStamp(), invMass, p2.pt(), - p1.pt(), + p2.eta(), + p2.phi(), + p2.charge(), p2.bdtBkg(), p2.bdtPrompt(), p2.bdtFD(), - kstar, - FemtoDreamMath::getkT(p1, massOne, p2, massTwo), - FemtoDreamMath::getmT(p1, massOne, p2, massTwo), - col.multNtr(), - col.multV0M(), - p2.charge(), - pairSign, - processType, charmHadMc, originType); + rowFemtoResultTrk( + col.globalIndex(), + p2.timeStamp(), + p1.pt(), + p1.eta(), + p1.phi(), + chargeTrack, + p1.tpcNClsFound(), + p1.tpcNClsFindable(), + p1.tpcNClsCrossedRows(), + p1.tpcNSigmaPr(), + p1.tofNSigmaPr()); + + rowFemtoResultColl( + col.globalIndex(), + p2.timeStamp(), + col.posZ(), + col.multNtr()); + sameEventCont.setPair(p1, p2, col.multNtr(), col.multV0M(), use4D, extendedPlots, smearingByOrigin); } } @@ -341,8 +349,6 @@ struct HfTaskCharmHadronsFemtoDream { { // Mixed events that contain the pair of interest - processType = 2; // for mixed event - Partition PartitionMaskedCol1 = (aod::femtodreamcollision::bitmaskTrackOne & BitMask) == BitMask; PartitionMaskedCol1.bindTable(cols); @@ -371,20 +377,6 @@ struct HfTaskCharmHadronsFemtoDream { continue; } - float chargeTrack = 0.; - if ((p1.cut() & 2) == 2) { - chargeTrack = PositiveCharge; - } else { - chargeTrack = NegativeCharge; - } - - int pairSign = 0; - if (chargeTrack == p2.charge()) { - pairSign = LikeSignPair; - } else { - pairSign = UnLikeSignPair; - } - float kstar = FemtoDreamMath::getkstar(p1, massOne, p2, massTwo); if (kstar > highkstarCut) { continue; @@ -404,30 +396,6 @@ struct HfTaskCharmHadronsFemtoDream { continue; } - int charmHadMc = 0; - int originType = 0; - if constexpr (isMc) { - charmHadMc = p2.flagMc(); - originType = p2.originMcRec(); - } - fillFemtoResult( - invMass, - p2.pt(), - p1.pt(), - p2.bdtBkg(), - p2.bdtPrompt(), - p2.bdtFD(), - kstar, - FemtoDreamMath::getkT(p1, massOne, p2, massTwo), - FemtoDreamMath::getmT(p1, massOne, p2, massTwo), - collision1.multNtr(), - collision1.multV0M(), - p2.charge(), - pairSign, - processType, - charmHadMc, - originType); - // if constexpr (!isMc) mixedEventCont.setPair(p1, p2, collision1.multNtr(), collision1.multV0M(), use4D, extendedPlots, smearingByOrigin); mixedEventCont.setPair(p1, p2, collision1.multNtr(), collision1.multV0M(), use4D, extendedPlots, smearingByOrigin); } diff --git a/PWGHF/HFC/Tasks/taskCorrelationD0Hadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationD0Hadrons.cxx index 2654984c45a..bea1510a24b 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationD0Hadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationD0Hadrons.cxx @@ -16,52 +16,49 @@ /// \author Samrangy Sadhu , INFN Bari /// \author Swapnesh Santosh Khade , IIT Indore -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsAnalysis.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/HFC/Utils/utilsCorrelations.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include using namespace o2; +using namespace o2::constants::physics; +using namespace o2::constants::math; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::aod::hf_correlation_d0_hadron; using namespace o2::analysis::hf_correlations; -namespace o2::aod -{ -using D0HadronPairFull = soa::Join; -using D0HadronPairFullMl = soa::Join; -} // namespace o2::aod - -// string definitions, used for histogram axis labels -const TString stringPtD = "#it{p}_{T}^{D} (GeV/#it{c});"; -const TString stringPtHadron = "#it{p}_{T}^{Hadron} (GeV/#it{c});"; -const TString stringDeltaEta = "#it{#eta}^{Hadron}-#it{#eta}^{D};"; -const TString stringDeltaPhi = "#it{#varphi}^{Hadron}-#it{#varphi}^{D} (rad);"; -const TString stringDHadron = "D,Hadron candidates "; -const TString stringSignal = "signal region;"; -const TString stringSideband = "sidebands;"; -const TString stringMcParticles = "MC gen - D,Hadron particles;"; -const TString stringMcReco = "MC reco - D,Hadron candidates "; - -// histogram axes definition -AxisSpec axisDeltaEta = {100, -2., 2., ""}; -AxisSpec axisDeltaPhi = {64, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf, ""}; -AxisSpec axisPtD = {10, 0., 10., ""}; -AxisSpec axisPtHadron = {11, 0., 11., ""}; -AxisSpec axisPoolBin = {9, 0., 9., ""}; -AxisSpec axisCorrelationState = {2, 0., 2., ""}; -ConfigurableAxis axisMass{"axisMass", {250, 1.65f, 2.15f}, ""}; -ConfigurableAxis binsBdtScore{"binsBdtScore", {100, 0., 1.}, "Bdt output scores"}; -AxisSpec axisBdtScore = {binsBdtScore, "Bdt score"}; - // definition of vectors for standard ptbin and invariant mass configurables const int nPtBinsCorrelations = 12; const double pTBinsCorrelations[nPtBinsCorrelations + 1] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 12., 16., 24., 99.}; @@ -78,174 +75,234 @@ auto vecSidebandLeftInner = std::vector{sidebandLeftInnerDefault, sideba auto vecSidebandLeftOuter = std::vector{sidebandLeftOuterDefault, sidebandLeftOuterDefault + nPtBinsCorrelations}; auto vecSidebandRightInner = std::vector{sidebandRightInnerDefault, sidebandRightInnerDefault + nPtBinsCorrelations}; auto vecSidebandRightOuter = std::vector{sidebandRightOuterDefault, sidebandRightOuterDefault + nPtBinsCorrelations}; -const int nPtBinsEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::nBinsPt; -const double efficiencyDmesonDefault[nPtBinsEfficiency] = {}; -auto vecEfficiencyDmeson = std::vector{efficiencyDmesonDefault, efficiencyDmesonDefault + nPtBinsEfficiency}; -const double ptHadronMax = 10.0; +const int nPtbinsPtEfficiencyD = o2::analysis::hf_cuts_d0_to_pi_k::NBinsPt; +const double efficiencyDmesonDefault[nPtbinsPtEfficiencyD] = {}; +auto vecEfficiencyDmeson = std::vector{efficiencyDmesonDefault, efficiencyDmesonDefault + nPtbinsPtEfficiencyD}; struct HfTaskCorrelationD0Hadrons { - // pT ranges for correlation plots: the default values are those embedded in hf_cuts_d0_to_pi_k (i.e. the mass pT bins), but can be redefined via json files + // pT ranges: the default values are those embedded in hf_cuts_d0_to_pi_k (i.e. the mass pT bins), but can be redefined via json files + Configurable> binsPtD{"binsPtD", std::vector{o2::analysis::hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for candidate mass plots and efficiency"}; + Configurable> binsPtHadron{"binsPtHadron", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for assoc particle efficiency"}; Configurable> binsCorrelations{"binsCorrelations", std::vector{vecPtBinsCorrelations}, "pT bin limits for correlation plots"}; - // pT bins for effiencies: same as above - Configurable> binsEfficiency{"binsEfficiency", std::vector{o2::analysis::hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for efficiency"}; + Configurable> binsPtEfficiencyD{"binsPtEfficiencyD", std::vector{o2::analysis::hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for efficiency"}; + Configurable> binsPtEfficiencyHad{"binsPtEfficiencyHad", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for associated particle efficiency"}; + Configurable> efficiencyDmeson{"efficiencyDmeson", std::vector{vecEfficiencyDmeson}, "Efficiency values for D meson specie under study"}; + Configurable> efficiencyHad{"efficiencyHad", {1., 1., 1., 1., 1., 1.}, "efficiency values for associated particles"}; + Configurable applyEfficiency{"applyEfficiency", 1, "Flag for applying efficiency weights"}; Configurable> classMl{"classMl", {0, 1, 2}, "Indexes of ML scores to be stored. Three indexes max."}; Configurable> mlOutputPromptD0{"mlOutputPromptD0", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for prompt"}; Configurable> mlOutputBkgD0{"mlOutputBkgD0", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for bkg"}; Configurable> mlOutputPromptD0bar{"mlOutputPromptD0bar", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for prompt"}; Configurable> mlOutputBkgD0bar{"mlOutputBkgD0bar", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for bkg"}; - // signal and sideband region edges, to be defined via json file (initialised to empty) + Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; + Configurable ptCandMax{"ptCandMax", 50., "max. cand pT"}; + Configurable ptTrackMin{"ptTrackMin", 0.3, "min. track pT"}; + Configurable ptTrackMax{"ptTrackMax", 99., "max. track pT"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "max. eta of tracks"}; + Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen. cand. rapidity"}; + Configurable ptDaughterMin{"ptDaughterMin", 0.1, "min. daughter pT"}; + Configurable nTpcCrossedRaws{"nTpcCrossedRaws", 70, "Number of crossed TPC Rows"}; + Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. DCA_xy of tracks"}; + Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. DCA_z of tracks"}; + Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0 (bar)"}; + Configurable selNoSameBunchPileUpColl{"selNoSameBunchPileUpColl", true, "Flag for rejecting the collisions associated with the same bunch crossing"}; Configurable> signalRegionLeft{"signalRegionLeft", std::vector{vecsignalRegionLeft}, "Inner values of signal region vs pT"}; Configurable> signalRegionRight{"signalRegionRight", std::vector{vecsignalRegionRight}, "Outer values of signal region vs pT"}; Configurable> sidebandLeftInner{"sidebandLeftInner", std::vector{vecSidebandLeftInner}, "Inner values of left sideband vs pT"}; Configurable> sidebandLeftOuter{"sidebandLeftOuter", std::vector{vecSidebandLeftOuter}, "Outer values of left sideband vs pT"}; Configurable> sidebandRightInner{"sidebandRightInner", std::vector{vecSidebandRightInner}, "Inner values of right sideband vs pT"}; Configurable> sidebandRightOuter{"sidebandRightOuter", std::vector{vecSidebandRightOuter}, "Outer values of right sideband vs pT"}; - Configurable> efficiencyDmeson{"efficiencyDmeson", std::vector{vecEfficiencyDmeson}, "Efficiency values for D meson specie under study"}; Configurable isTowardTransverseAway{"isTowardTransverseAway", false, "Divide into three regions: toward, transverse, and away"}; Configurable leadingParticlePtMin{"leadingParticlePtMin", 0., "Min for leading particle pt"}; - Configurable applyEfficiency{"applyEfficiency", 1, "Flag for applying efficiency weights"}; - HistogramRegistry registry{ - "registry", - {{"hDeltaEtaPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DVsPtSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the pT) are updated in the init() - {"hDeltaEtaPtIntSignalRegionSoftPi", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSignalRegionSoftPi", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DPtIntSignalRegionSoftPi", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DVsPtSignalRegionSoftPi", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the pT) are updated in the init() - {"hDeltaEtaPtIntSidebands", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DVsPtSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the pT) are updated in the init() - {"hDeltaEtaPtIntSidebandsSoftPi", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSidebandsSoftPi", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DPtIntSidebandsSoftPi", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DVsPtSidebandsSoftPi", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the pT) are updated in the init() - {"hCorrel2DVsPtRecSig", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DVsPtRecBg", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - // correlation histograms for MCRec for signal only - {"hCorrel2DVsPtSignalRegionRecSig", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DVsPtSignalRegionSoftPiRecSig", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSignalRegionRecSig", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DPtIntSignalRegionSoftPiRecSig", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSignalRegionRecSig", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaEtaPtIntSignalRegionSoftPiRecSig", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSignalRegionRecSig", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hDeltaPhiPtIntSignalRegionSoftPiRecSig", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DVsPtSidebandsRecSig", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DVsPtSidebandsSoftPiRecSig", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSidebandsRecSig", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DPtIntSidebandsSoftPiRecSig", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSidebandsRecSig", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaEtaPtIntSidebandsSoftPiRecSig", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSidebandsRecSig", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hDeltaPhiPtIntSidebandsSoftPiRecSig", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - // correlation histograms for MCRec for reflection candidates only - {"hCorrel2DVsPtSignalRegionRecRef", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSignalRegionRecRef", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSignalRegionRecRef", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSignalRegionRecRef", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DVsPtSidebandsRecRef", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSidebandsRecRef", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSidebandsRecRef", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSidebandsRecRef", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DVsPtSignalRegionSoftPiRecRef", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSignalRegionSoftPiRecRef", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSignalRegionSoftPiRecRef", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSignalRegionSoftPiRecRef", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DVsPtSidebandsSoftPiRecRef", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSidebandsSoftPiRecRef", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSidebandsSoftPiRecRef", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSidebandsSoftPiRecRef", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - // correlation histograms for MCRec for background candidates only - {"hCorrel2DVsPtSignalRegionRecBg", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSignalRegionRecBg", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSignalRegionRecBg", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSignalRegionRecBg", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DVsPtSidebandsRecBg", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSidebandsRecBg", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSidebandsRecBg", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSidebandsRecBg", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DVsPtSignalRegionSoftPiRecBg", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSignalRegionSoftPiRecBg", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSignalRegionSoftPiRecBg", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSignalRegionSoftPiRecBg", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DVsPtSidebandsSoftPiRecBg", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DPtIntSidebandsSoftPiRecBg", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntSidebandsSoftPiRecBg", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSidebandsSoftPiRecBg", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - // correlation histograms for MCGen - {"hCorrel2DVsPtGen", stringMcParticles + stringDeltaPhi + stringDeltaEta + stringPtD + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the pT) are updated in the init(), - {"hCorrel2DPtIntGen", stringMcParticles + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hDeltaEtaPtIntGen", stringMcParticles + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntGen", stringMcParticles + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - // Toward Transverse Away - {"hToward", "Toward invmass; ptD; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtD}, {axisCorrelationState}}}}, - {"hTransverse", "Transverse invmass; ptD; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtD}, {axisCorrelationState}}}}, - {"hAway", "Away invmass; ptD; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtD}, {axisCorrelationState}}}}, - - // Toward Transverse Away for McRec - {"hTowardRec", "Toward invmass; ptD; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtD}, {axisCorrelationState}}}}, - {"hTransverseRec", "Transverse invmass; ptD; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtD}, {axisCorrelationState}}}}, - {"hAwayRec", "Away invmass; ptD; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtD}, {axisCorrelationState}}}}, - // Toward Transverse Away for McGen - {"hTowardGen", "Toward invmass; ptD; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtD}, {axisCorrelationState}}}}, - {"hTransverseGen", "Transverse invmass; ptD; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtD}, {axisCorrelationState}}}}, - {"hAwayGen", "Away invmass; ptD; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtD}, {axisCorrelationState}}}}}}; + HfHelper hfHelper; + + enum CandidateStep { kCandidateStepMcGenAll = 0, + kCandidateStepMcGenD0ToPiKPi, + kCandidateStepMcCandInAcceptance, + kCandidateStepMcDaughtersInAcceptance, + kCandidateStepMcReco, + kCandidateStepMcRecoInAcceptance, + kCandidateNSteps }; + + using D0HadronPairFull = soa::Join; + using D0HadronPairFullMl = soa::Join; + using CandD0McReco = soa::Filtered>; + using CandD0McGen = soa::Join; + using TracksWithMc = soa::Filtered>; // trackFilter applied + + Filter d0Filter = (aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0) || (aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0); + Filter trackFilter = (nabs(aod::track::eta) < etaTrackMax) && (aod::track::pt > ptTrackMin) && (aod::track::pt < ptTrackMax) && (nabs(aod::track::dcaXY) < dcaXYTrackMax) && (nabs(aod::track::dcaZ) < dcaZTrackMax); + + ConfigurableAxis binsMassD{"binsMassD", {200, 1.3848, 2.3848}, "inv. mass (#pi K) (GeV/#it{c}^{2});entries"}; + ConfigurableAxis binsBdtScore{"binsBdtScore", {100, 0., 1.}, "Bdt output scores"}; + ConfigurableAxis binsEta{"binsEta", {100, -2., 2.}, "#it{#eta}"}; + ConfigurableAxis binsPhi{"binsPhi", {64, -PIHalf, 3. * PIHalf}, "#it{#varphi}"}; + ConfigurableAxis binsMultFT0M{"binsMultFT0M", {600, 0., 8000.}, "Multiplicity as FT0M signal amplitude"}; + ConfigurableAxis binsPosZ{"binsPosZ", {100, -10., 10.}, "primary vertex z coordinate"}; + ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + void init(InitContext&) { - int nBinsPtAxis = binsCorrelations->size() - 1; - const double* valuesPtAxis = binsCorrelations->data(); - registry.add("hBdtScorePromptD0", "D0 BDT prompt score", {HistType::kTH1F, {axisBdtScore}}); - registry.add("hBdtScoreBkgD0", "D0 BDT bkg score", {HistType::kTH1F, {axisBdtScore}}); - registry.add("hBdtScorePromptD0bar", "D0bar BDT prompt score", {HistType::kTH1F, {axisBdtScore}}); - registry.add("hBdtScoreBkgD0bar", "D0bar BDT bkg score", {HistType::kTH1F, {axisBdtScore}}); - registry.get(HIST("hCorrel2DVsPtSignalRegion"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtSidebands"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); + AxisSpec axisMassD = {binsMassD, "inv. mass (#pi K) (GeV/#it{c}^{2})"}; + AxisSpec axisDeltaEta = {binsEta, "#it{#eta}^{Hadron}-#it{#eta}^{D}"}; + AxisSpec axisEta = {binsEta, "#it{#eta}"}; + AxisSpec axisDeltaPhi = {binsPhi, "#it{#varphi}^{Hadron}-#it{#varphi}^{D} (rad)"}; + AxisSpec axisPtD = {(std::vector)binsPtD, "#it{p}_{T}^{D} (GeV/#it{c})"}; + AxisSpec axisPtHadron = {(std::vector)binsPtHadron, "#it{p}_{T}^{Hadron} (GeV/#it{c})"}; + AxisSpec axisPoolBin = {binsPoolBin, "poolBin"}; + AxisSpec axisBdtScore = {binsBdtScore, "Bdt score"}; + AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; + AxisSpec axisPosZ = {binsPosZ, "PosZ"}; + AxisSpec axisD0Prompt = {2, -0.5, 1.5, "Prompt D0"}; + AxisSpec axisCorrelationState = {2, 0., 2., "correlationState"}; + + // Histograms for data + registry.add("hDeltaEtaPtIntSignalRegion", "D0-h deltaEta signal region", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegion", "D0-h deltaPhi signal region", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSignalRegion", "D0-h deltaPhi vs deltaEta signal region", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegion", "D0-h correlations signal region", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSignalRegionSoftPi", "D0-h deltaEta signal region soft pi only", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegionSoftPi", "D0-h deltaPhi signal region soft pi only", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSignalRegionSoftPi", "D0-h deltaPhi vs deltaEta signal region soft pi only", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegionSoftPi", "D0-h correlations signal region soft pi only", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebands", "D0-h deltaEta sidebands", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebands", "D0-h deltaPhi sidebands", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebands", "D0-h deltaPhi vs deltaEta sidebands", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebands", "D0-h correlations sidebands", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandsSoftPi", "D0-h deltaEta sidebands soft pi only", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandsSoftPi", "D0-h deltaPhi sidebands soft pi only", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebandsSoftPi", "D0-h deltaPhi vs deltaEta sidebands soft pi only", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebandsSoftPi", "D0-h correlations sidebands soft pi only", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); registry.get(HIST("hCorrel2DVsPtSignalRegion"))->Sumw2(); registry.get(HIST("hCorrel2DVsPtSidebands"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSignalRegionSoftPi"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtSidebandsSoftPi"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); registry.get(HIST("hCorrel2DVsPtSignalRegionSoftPi"))->Sumw2(); registry.get(HIST("hCorrel2DVsPtSidebandsSoftPi"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSignalRegionRecSig"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtSignalRegionSoftPiRecSig"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtSidebandsRecSig"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtSidebandsSoftPiRecSig"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); + // Toward Transverse Away for Data + registry.add("hToward", "Toward", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisCorrelationState}}}); + registry.add("hTransverse", "Transverse", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisCorrelationState}}}); + registry.add("hAway", "Away", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisCorrelationState}}}); + + // Histograms for MC reco + registry.add("hCorrel2DVsPtRecSig", "D0-h correlations MC reco signal", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.get(HIST("hCorrel2DVsPtRecSig"))->Sumw2(); + registry.add("hCorrel2DVsPtRecBg", "D0-h correlations MC reco background", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.get(HIST("hCorrel2DVsPtRecBg"))->Sumw2(); + // MC reco D0, D0bar signal case + registry.add("hDeltaEtaPtIntSignalRegionRecSig", "D0-h deltaEta MC reco signal region, signal", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegionRecSig", "D0-h deltaPhi MC reco signal region, signal", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSignalRegionRecSig", "D0-h deltaPhi vs deltaEta MC reco signal region, signal", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegionRecSig", "D0-h correlations MC reco signal region, signal", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisD0Prompt}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtPhysicalPrimaryRecSig", "D0-h correlations signal region (only true primary particles) MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisD0Prompt}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtSignalRegionPromptD0PromptHadronRecSig", "D0-h correlations signal region Prompt-NonPrompt MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtSignalRegionNonPromptD0NonPromptHadronRecSig", "D0-h correlations signal region NonPrompt-NonPrompt MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSignalRegionSoftPiRecSig", "D0-h deltaEta MC reco signal region, signal", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegionSoftPiRecSig", "D0-h deltaPhi MC reco signal region, signal", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSignalRegionSoftPiRecSig", "D0-h deltaPhi vs deltaEta MC reco signal region, signal", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegionSoftPiRecSig", "D0-h correlations MC reco signal region, signal", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandsRecSig", "D0-h deltaEta MC reco sidebands, signal", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandsRecSig", "D0-h deltaPhi MC reco sidebands, signal", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebandsRecSig", "D0-h deltaPhi vs deltaEta MC reco sidebands, signal", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebandsRecSig", "D0-h correlations MC reco sidebands, signal", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandsSoftPiRecSig", "D0-h deltaEta MC reco sidebands, signal", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandsSoftPiRecSig", "D0-h deltaPhi MC reco sidebands, signal", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebandsSoftPiRecSig", "D0-h deltaPhi vs deltaEta MC reco sidebands, signal", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebandsSoftPiRecSig", "D0-h correlations MC reco sidebands, signal", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); registry.get(HIST("hCorrel2DVsPtSignalRegionRecSig"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtPhysicalPrimaryRecSig"))->Sumw2(); registry.get(HIST("hCorrel2DVsPtSignalRegionSoftPiRecSig"))->Sumw2(); registry.get(HIST("hCorrel2DVsPtSidebandsRecSig"))->Sumw2(); registry.get(HIST("hCorrel2DVsPtSidebandsSoftPiRecSig"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSignalRegionRecRef"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtSidebandsRecRef"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); + // MC reco D0, D0bar reflection case + registry.add("hDeltaEtaPtIntSignalRegionRecRef", "D0-h deltaEta MC reco signal region, refelction", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegionRecRef", "D0-h deltaPhi MC reco signal region, refelction", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSignalRegionRecRef", "D0-h deltaPhi vs deltaEta MC reco signal region, refelction", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegionRecRef", "D0-h correlations MC reco signal region, refelction", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSignalRegionSoftPiRecRef", "D0-h deltaEta MC reco signal region, refelction", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegionSoftPiRecRef", "D0-h deltaPhi MC reco signal region, refelction", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSignalRegionSoftPiRecRef", "D0-h deltaPhi vs deltaEta MC reco signal region, refelction", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegionSoftPiRecRef", "D0-h correlations MC reco signal region, refelction", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandsRecRef", "D0-h deltaEta MC reco sidebands, refelction", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandsRecRef", "D0-h deltaPhi MC reco sidebands, refelction", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebandsRecRef", "D0-h deltaPhi vs deltaEta MC reco sidebands, refelction", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebandsRecRef", "D0-h correlations MC reco sidebands, refelction", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandsSoftPiRecRef", "D0-h deltaEta MC reco sidebands, refelction", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandsSoftPiRecRef", "D0-h deltaPhi MC reco sidebands, refelction", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebandsSoftPiRecRef", "D0-h deltaPhi vs deltaEta MC reco sidebands, refelction", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebandsSoftPiRecRef", "D0-h correlations MC reco sidebands, refelction", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); registry.get(HIST("hCorrel2DVsPtSignalRegionRecRef"))->Sumw2(); registry.get(HIST("hCorrel2DVsPtSidebandsRecRef"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSignalRegionSoftPiRecRef"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtSidebandsSoftPiRecRef"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); registry.get(HIST("hCorrel2DVsPtSignalRegionSoftPiRecRef"))->Sumw2(); registry.get(HIST("hCorrel2DVsPtSidebandsSoftPiRecRef"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSignalRegionRecBg"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtSidebandsRecBg"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); + // MC reco D0, D0bar background case + registry.add("hDeltaEtaPtIntSignalRegionRecBg", "D0-h deltaEta MC reco signal region, background", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegionRecBg", "D0-h deltaPhi MC reco signal region, background", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSignalRegionRecBg", "D0-h deltaPhi vs deltaEta MC reco signal region, background", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegionRecBg", "D0-h correlations MC reco signal region, background", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSignalRegionSoftPiRecBg", "D0-h deltaEta MC reco signal region, background", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegionSoftPiRecBg", "D0-h deltaPhi MC reco signal region, background", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSignalRegionSoftPiRecBg", "D0-h deltaPhi vs deltaEta MC reco signal region, background", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegionSoftPiRecBg", "D0-h correlations MC reco signal region, background", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandsRecBg", "D0-h deltaEta MC reco sidebands, background", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandsRecBg", "D0-h deltaPhi MC reco sidebands, background", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebandsRecBg", "D0-h deltaPhi vs deltaEta MC reco sidebands, background", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebandsRecBg", "D0-h correlations MC reco sidebands, background", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandsSoftPiRecBg", "D0-h deltaEta MC reco sidebands, background", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandsSoftPiRecBg", "D0-h deltaPhi MC reco sidebands, background", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebandsSoftPiRecBg", "D0-h deltaPhi vs deltaEta MC reco sidebands, background", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebandsSoftPiRecBg", "D0-h correlations MC reco sidebands, background", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); registry.get(HIST("hCorrel2DVsPtSignalRegionRecBg"))->Sumw2(); registry.get(HIST("hCorrel2DVsPtSidebandsRecBg"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSignalRegionSoftPiRecBg"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtSidebandsSoftPiRecBg"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); registry.get(HIST("hCorrel2DVsPtSignalRegionSoftPiRecBg"))->Sumw2(); registry.get(HIST("hCorrel2DVsPtSidebandsSoftPiRecBg"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtRecSig"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtRecSig"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtRecBg"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtRecBg"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtGen"))->GetAxis(2)->Set(nBinsPtAxis, valuesPtAxis); - registry.get(HIST("hCorrel2DVsPtGen"))->Sumw2(); + // Toward Transverse Away for McRec + registry.add("hTowardRec", "Toward", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisCorrelationState}}}); + registry.add("hTransverseRec", "Transverse", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisCorrelationState}}}); + registry.add("hAwayRec", "Away", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisCorrelationState}}}); + + // Histograms for MC gen + registry.add("hDeltaEtaPtIntGen", "D0-h deltaEta MC gen", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntGen", "D0-h deltaPhi MC gen", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntGen", "D0-h deltaPhi vs deltaEta MC gen", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtGenPrompt", "D0-h correlations MC gen, prompt", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtGenNonPrompt", "D0-h correlations MC gen, non prompt", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtGenPromptD0PromptHadron", "D0-h correlations MC gen, prompt D0, non-prompt hadrons", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtGenNonPromptD0NonPromptHadron", "D0-h correlations MC gen, prompt D0, non-prompt hadrons", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.get(HIST("hCorrel2DVsPtGenPrompt"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtGenNonPrompt"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtGenPromptD0PromptHadron"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtGenNonPromptD0NonPromptHadron"))->Sumw2(); + // Toward Transverse Away for MC gen + registry.add("hTowardGen", "Toward", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisCorrelationState}}}); + registry.add("hTransverseGen", "Transverse", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisCorrelationState}}}); + registry.add("hAwayGen", "Away", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisCorrelationState}}}); + + // Common histograms + registry.add("hBdtScorePromptD0", "D0 BDT prompt score", {HistType::kTH1F, {axisBdtScore}}); + registry.add("hBdtScoreBkgD0", "D0 BDT bkg score", {HistType::kTH1F, {axisBdtScore}}); + registry.add("hBdtScorePromptD0bar", "D0bar BDT prompt score", {HistType::kTH1F, {axisBdtScore}}); + registry.add("hBdtScoreBkgD0bar", "D0bar BDT bkg score", {HistType::kTH1F, {axisBdtScore}}); + + // Efficiency histograms + registry.add("hPtCandMcRecPrompt", "D0 prompt candidates pt", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcRecNonPrompt", "D0 non prompt candidates pt", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcGenPrompt", "D0,Hadron particles prompt - MC Gen", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcGenNonPrompt", "D0,Hadron particles non prompt - MC Gen", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcGenDaughterInAcc", "D0,Hadron particles non prompt - MC Gen", {HistType::kTH1F, {axisPtD}}); + + auto hCandidates = registry.add("hCandidates", "Candidate count at different steps", {HistType::kStepTHnF, {axisPtD, axisMultFT0M, {RecoDecay::OriginType::NonPrompt + 1, +RecoDecay::OriginType::None - 0.5, +RecoDecay::OriginType::NonPrompt + 0.5}}, kCandidateNSteps}); + hCandidates->GetAxis(0)->SetTitle("#it{p}_{T} (GeV/#it{c})"); + hCandidates->GetAxis(1)->SetTitle("multiplicity"); + hCandidates->GetAxis(2)->SetTitle("Charm hadron origin"); } /// D-h correlation pair filling task, from pair tables - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) /// Works on both USL and LS analyses pair tables - void processData(aod::D0HadronPairFullMl const& pairEntries, + void processData(D0HadronPairFullMl const& pairEntries, aod::D0CandRecoInfo const& candidates) { for (const auto& candidate : candidates) { @@ -254,15 +311,17 @@ struct HfTaskCorrelationD0Hadrons { float bdtScoreBkgD0 = candidate.mlScoreBkgD0(); float bdtScorePromptD0bar = candidate.mlScorePromptD0bar(); float bdtScoreBkgD0bar = candidate.mlScoreBkgD0bar(); - int effBinD = o2::analysis::findBin(binsEfficiency, ptD); - if (bdtScorePromptD0 < mlOutputPromptD0->at(effBinD) || bdtScoreBkgD0 > mlOutputBkgD0->at(effBinD) || - bdtScorePromptD0bar < mlOutputPromptD0bar->at(effBinD) || bdtScoreBkgD0bar > mlOutputBkgD0bar->at(effBinD)) { - continue; - } + int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); + registry.fill(HIST("hBdtScorePromptD0"), bdtScorePromptD0); registry.fill(HIST("hBdtScoreBkgD0"), bdtScoreBkgD0); registry.fill(HIST("hBdtScorePromptD0bar"), bdtScorePromptD0bar); registry.fill(HIST("hBdtScoreBkgD0bar"), bdtScoreBkgD0bar); + + if (bdtScorePromptD0 < mlOutputPromptD0->at(effBinD) || bdtScoreBkgD0 > mlOutputBkgD0->at(effBinD) || + bdtScorePromptD0bar < mlOutputPromptD0bar->at(effBinD) || bdtScoreBkgD0bar > mlOutputBkgD0bar->at(effBinD)) { + continue; + } } for (const auto& pairEntry : pairEntries) { @@ -274,9 +333,12 @@ struct HfTaskCorrelationD0Hadrons { double massD = pairEntry.mD(); double massDbar = pairEntry.mDbar(); int signalStatus = pairEntry.signalStatus(); - int effBinD = o2::analysis::findBin(binsEfficiency, ptD); + int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); int ptBinD = o2::analysis::findBin(binsCorrelations, ptD); int poolBin = pairEntry.poolBin(); + float trackDcaXY = pairEntry.trackDcaXY(); + float trackDcaZ = pairEntry.trackDcaZ(); + int trackTpcCrossedRows = pairEntry.trackTPCNClsCrossedRows(); bool isAutoCorrelated = pairEntry.isAutoCorrelated(); float bdtScorePromptD0 = pairEntry.mlScorePromptD0(); float bdtScoreBkgD0 = pairEntry.mlScoreBkgD0(); @@ -286,16 +348,16 @@ struct HfTaskCorrelationD0Hadrons { if (ptBinD < 0 || effBinD < 0) { continue; } - if (ptHadron > ptHadronMax) { - ptHadron = ptHadronMax + 0.5; - } if (bdtScorePromptD0 < mlOutputPromptD0->at(ptBinD) || bdtScoreBkgD0 > mlOutputBkgD0->at(ptBinD) || bdtScorePromptD0bar < mlOutputPromptD0bar->at(ptBinD) || bdtScoreBkgD0bar > mlOutputBkgD0bar->at(ptBinD)) { continue; } + if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { + continue; + } double efficiencyWeight = 1.; if (applyEfficiency) { - efficiencyWeight = 1. / (efficiencyDmeson->at(o2::analysis::findBin(binsEfficiency, ptD))); // ***** track efficiency to be implemented ***** + efficiencyWeight = 1. / (efficiencyDmeson->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); } // reject entries outside pT ranges of interest if (ptBinD == -1) { // at least one particle outside accepted pT range @@ -324,7 +386,7 @@ struct HfTaskCorrelationD0Hadrons { } } // check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots - if ((massD > signalRegionLeft->at(ptBinD) && massD < signalRegionRight->at(ptBinD)) && ((signalStatus == ParticleTypeData::D0Only) || (signalStatus == ParticleTypeData::D0D0barBoth))) { + if ((massD > signalRegionLeft->at(ptBinD) && massD < signalRegionRight->at(ptBinD)) && (signalStatus == ParticleTypeData::D0Only)) { // in signal region registry.fill(HIST("hCorrel2DVsPtSignalRegion"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSignalRegion"), deltaPhi, deltaEta, efficiencyWeight); @@ -332,7 +394,7 @@ struct HfTaskCorrelationD0Hadrons { registry.fill(HIST("hDeltaPhiPtIntSignalRegion"), deltaPhi, efficiencyWeight); } - if ((massD > signalRegionLeft->at(ptBinD) && massD < signalRegionRight->at(ptBinD)) && ((signalStatus == ParticleTypeData::D0OnlySoftPi) || (signalStatus >= ParticleTypeData::D0D0barBothSoftPi))) { + if ((massD > signalRegionLeft->at(ptBinD) && massD < signalRegionRight->at(ptBinD)) && (signalStatus == ParticleTypeData::D0OnlySoftPi)) { // in signal region, fills for soft pion only in ME registry.fill(HIST("hCorrel2DVsPtSignalRegionSoftPi"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSignalRegionSoftPi"), deltaPhi, deltaEta, efficiencyWeight); @@ -340,7 +402,7 @@ struct HfTaskCorrelationD0Hadrons { registry.fill(HIST("hDeltaPhiPtIntSignalRegionSoftPi"), deltaPhi, efficiencyWeight); } - if ((massDbar > signalRegionLeft->at(ptBinD) && massDbar < signalRegionRight->at(ptBinD)) && ((signalStatus == ParticleTypeData::D0barOnly) || (signalStatus == ParticleTypeData::D0D0barBoth))) { + if ((massDbar > signalRegionLeft->at(ptBinD) && massDbar < signalRegionRight->at(ptBinD)) && (signalStatus == ParticleTypeData::D0barOnly)) { // in signal region registry.fill(HIST("hCorrel2DVsPtSignalRegion"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSignalRegion"), deltaPhi, deltaEta, efficiencyWeight); @@ -358,7 +420,7 @@ struct HfTaskCorrelationD0Hadrons { if (((massD > sidebandLeftOuter->at(ptBinD) && massD < sidebandLeftInner->at(ptBinD)) || (massD > sidebandRightInner->at(ptBinD) && massD < sidebandRightOuter->at(ptBinD))) && - ((signalStatus == ParticleTypeData::D0Only) || (signalStatus == ParticleTypeData::D0D0barBoth))) { + (signalStatus == ParticleTypeData::D0Only)) { // in sideband region registry.fill(HIST("hCorrel2DVsPtSidebands"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSidebands"), deltaPhi, deltaEta, efficiencyWeight); @@ -368,7 +430,7 @@ struct HfTaskCorrelationD0Hadrons { if (((massD > sidebandLeftOuter->at(ptBinD) && massD < sidebandLeftInner->at(ptBinD)) || (massD > sidebandRightInner->at(ptBinD) && massD < sidebandRightOuter->at(ptBinD))) && - ((signalStatus == ParticleTypeData::D0OnlySoftPi) || (signalStatus >= ParticleTypeData::D0D0barBothSoftPi))) { + (signalStatus == ParticleTypeData::D0OnlySoftPi)) { // in sideband region, fills for soft pion only in ME registry.fill(HIST("hCorrel2DVsPtSidebandsSoftPi"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSidebandsSoftPi"), deltaPhi, deltaEta, efficiencyWeight); @@ -378,7 +440,7 @@ struct HfTaskCorrelationD0Hadrons { if (((massDbar > sidebandLeftOuter->at(ptBinD) && massDbar < sidebandLeftInner->at(ptBinD)) || (massDbar > sidebandRightInner->at(ptBinD) && massDbar < sidebandRightOuter->at(ptBinD))) && - ((signalStatus == ParticleTypeData::D0barOnly) || (signalStatus == ParticleTypeData::D0D0barBoth))) { + (signalStatus == ParticleTypeData::D0barOnly)) { // in sideband region registry.fill(HIST("hCorrel2DVsPtSidebands"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSidebands"), deltaPhi, deltaEta, efficiencyWeight); @@ -399,8 +461,28 @@ struct HfTaskCorrelationD0Hadrons { } PROCESS_SWITCH(HfTaskCorrelationD0Hadrons, processData, "Process data", false); - void processMcRec(aod::D0HadronPairFull const& pairEntries) + void processMcRec(D0HadronPairFullMl const& pairEntries, + soa::Join const& candidates) { + for (const auto& candidate : candidates) { + float ptD = candidate.ptD(); + float bdtScorePromptD0 = candidate.mlScorePromptD0(); + float bdtScoreBkgD0 = candidate.mlScoreBkgD0(); + float bdtScorePromptD0bar = candidate.mlScorePromptD0bar(); + float bdtScoreBkgD0bar = candidate.mlScoreBkgD0bar(); + int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); + + registry.fill(HIST("hBdtScorePromptD0"), bdtScorePromptD0); + registry.fill(HIST("hBdtScoreBkgD0"), bdtScoreBkgD0); + registry.fill(HIST("hBdtScorePromptD0bar"), bdtScorePromptD0bar); + registry.fill(HIST("hBdtScoreBkgD0bar"), bdtScoreBkgD0bar); + + if (bdtScorePromptD0 < mlOutputPromptD0->at(effBinD) || bdtScoreBkgD0 > mlOutputBkgD0->at(effBinD) || + bdtScorePromptD0bar < mlOutputPromptD0bar->at(effBinD) || bdtScoreBkgD0bar > mlOutputBkgD0bar->at(effBinD)) { + continue; + } + } + for (const auto& pairEntry : pairEntries) { // define variables for widely used quantities double deltaPhi = pairEntry.deltaPhi(); @@ -412,11 +494,28 @@ struct HfTaskCorrelationD0Hadrons { int signalStatus = pairEntry.signalStatus(); int ptBinD = o2::analysis::findBin(binsCorrelations, ptD); int poolBin = pairEntry.poolBin(); + float trackDcaXY = pairEntry.trackDcaXY(); + float trackDcaZ = pairEntry.trackDcaZ(); + int trackTpcCrossedRows = pairEntry.trackTPCNClsCrossedRows(); bool isAutoCorrelated = pairEntry.isAutoCorrelated(); + float bdtScorePromptD0 = pairEntry.mlScorePromptD0(); + float bdtScoreBkgD0 = pairEntry.mlScoreBkgD0(); + float bdtScorePromptD0bar = pairEntry.mlScorePromptD0bar(); + float bdtScoreBkgD0bar = pairEntry.mlScoreBkgD0bar(); + bool isPhysicalPrimary = pairEntry.isPhysicalPrimary(); + bool isD0Prompt = pairEntry.isPrompt(); + int statusPromptHadron = pairEntry.trackOrigin(); + if (bdtScorePromptD0 < mlOutputPromptD0->at(ptBinD) || bdtScoreBkgD0 > mlOutputBkgD0->at(ptBinD) || + bdtScorePromptD0bar < mlOutputPromptD0bar->at(ptBinD) || bdtScoreBkgD0bar > mlOutputBkgD0bar->at(ptBinD)) { + continue; + } + if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { + continue; + } double efficiencyWeight = 1.; if (applyEfficiency) { - efficiencyWeight = 1. / (efficiencyDmeson->at(o2::analysis::findBin(binsEfficiency, ptD))); + efficiencyWeight = 1. / (efficiencyDmeson->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); } if (isTowardTransverseAway) { // Divide into three regions: toward, transverse, and away @@ -451,18 +550,34 @@ struct HfTaskCorrelationD0Hadrons { // ---------------------- Fill plots for signal case, D0 ->1, D0bar ->8 --------------------------------------------- if ((massD > signalRegionLeft->at(ptBinD) && massD < signalRegionRight->at(ptBinD)) && (TESTBIT(signalStatus, ParticleTypeMcRec::D0Sig))) { // in signal region, tests bit ParticleTypeMcRec::D0Sig, SE-> softpi removed, ME-> inclusive - registry.fill(HIST("hCorrel2DVsPtSignalRegionRecSig"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtSignalRegionRecSig"), deltaPhi, deltaEta, ptD, ptHadron, static_cast(isD0Prompt), poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSignalRegionRecSig"), deltaPhi, deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaEtaPtIntSignalRegionRecSig"), deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaPhiPtIntSignalRegionRecSig"), deltaPhi, efficiencyWeight); + if (isPhysicalPrimary) { + registry.fill(HIST("hCorrel2DVsPtPhysicalPrimaryRecSig"), deltaPhi, deltaEta, ptD, ptHadron, static_cast(isD0Prompt), poolBin, efficiencyWeight); + if (isD0Prompt && statusPromptHadron == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("hCorrel2DVsPtSignalRegionPromptD0PromptHadronRecSig"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + } else if (!isD0Prompt && statusPromptHadron == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hCorrel2DVsPtSignalRegionNonPromptD0NonPromptHadronRecSig"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + } + } } if ((massDbar > signalRegionLeft->at(ptBinD) && massDbar < signalRegionRight->at(ptBinD)) && (TESTBIT(signalStatus, ParticleTypeMcRec::D0barSig))) { // in signal region, tests bit ParticleTypeMcRec::D0barSig, SE-> softpi removed, ME-> inclusive - registry.fill(HIST("hCorrel2DVsPtSignalRegionRecSig"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtSignalRegionRecSig"), deltaPhi, deltaEta, ptD, ptHadron, static_cast(isD0Prompt), poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSignalRegionRecSig"), deltaPhi, deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaEtaPtIntSignalRegionRecSig"), deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaPhiPtIntSignalRegionRecSig"), deltaPhi, efficiencyWeight); + if (isPhysicalPrimary) { + registry.fill(HIST("hCorrel2DVsPtPhysicalPrimaryRecSig"), deltaPhi, deltaEta, ptD, ptHadron, static_cast(isD0Prompt), poolBin, efficiencyWeight); + if (isD0Prompt && statusPromptHadron == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("hCorrel2DVsPtSignalRegionPromptD0PromptHadronRecSig"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + } else if (!isD0Prompt && statusPromptHadron == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hCorrel2DVsPtSignalRegionNonPromptD0NonPromptHadronRecSig"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + } + } } if ((massDbar > signalRegionLeft->at(ptBinD) && massDbar < signalRegionRight->at(ptBinD)) && (signalStatus >= static_cast(BIT(ParticleTypeMcRec::SoftPi)))) { @@ -617,7 +732,7 @@ struct HfTaskCorrelationD0Hadrons { PROCESS_SWITCH(HfTaskCorrelationD0Hadrons, processMcRec, "Process MC Reco mode", true); /// D-Hadron correlation pair filling task, from pair tables - for MC gen-level analysis (no filter/selection, only true signal) - void processMcGen(aod::D0HadronPairFull const& pairEntries) + void processMcGen(D0HadronPairFull const& pairEntries) { for (const auto& pairEntry : pairEntries) { // define variables for widely used quantities @@ -628,13 +743,13 @@ struct HfTaskCorrelationD0Hadrons { int poolBin = pairEntry.poolBin(); double massD = pairEntry.mD(); bool isAutoCorrelated = pairEntry.isAutoCorrelated(); + int statusPromptHadron = pairEntry.trackOrigin(); + bool isD0Prompt = pairEntry.isPrompt(); + // reject entries outside pT ranges of interest if (o2::analysis::findBin(binsCorrelations, ptD) < 0) { continue; } - if (ptHadron > ptHadronMax) { - ptHadron = ptHadronMax + 0.5; - } if (isTowardTransverseAway) { // Divide into three regions: toward, transverse, and away if (ptHadron < leadingParticlePtMin) { @@ -655,13 +770,108 @@ struct HfTaskCorrelationD0Hadrons { break; } } - registry.fill(HIST("hCorrel2DVsPtGen"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + if (isD0Prompt) { + registry.fill(HIST("hCorrel2DVsPtGenPrompt"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + if (statusPromptHadron == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("hCorrel2DVsPtGenPromptD0PromptHadron"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + } + } else { + registry.fill(HIST("hCorrel2DVsPtGenNonPrompt"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + if (statusPromptHadron == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hCorrel2DVsPtGenNonPromptD0NonPromptHadron"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + } + } registry.fill(HIST("hCorrel2DPtIntGen"), deltaPhi, deltaEta); registry.fill(HIST("hDeltaEtaPtIntGen"), deltaEta); registry.fill(HIST("hDeltaPhiPtIntGen"), deltaPhi); } // end loop } PROCESS_SWITCH(HfTaskCorrelationD0Hadrons, processMcGen, "Process MC Gen mode", false); + + /// D0 reconstruction and selection efficiency + void processMcCandEfficiency(soa::Join const&, + soa::Join const&, + CandD0McGen const& mcParticles, + CandD0McReco const& candidates, + aod::TracksWMc const&) + { + auto hCandidates = registry.get(HIST("hCandidates")); + + /// Gen loop + float multiplicity = -1.; + for (const auto& mcParticle : mcParticles) { + // generated candidates + if (std::abs(mcParticle.pdgCode()) == Pdg::kD0) { + auto mcCollision = mcParticle.template mcCollision_as>(); + multiplicity = mcCollision.multMCFT0A() + mcCollision.multMCFT0C(); // multFT0M = multFt0A + multFT0C + hCandidates->Fill(kCandidateStepMcGenAll, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); + if (std::abs(mcParticle.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + hCandidates->Fill(kCandidateStepMcGenD0ToPiKPi, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); + auto yD0 = RecoDecay::y(mcParticle.pVector(), o2::constants::physics::MassD0); + if (std::abs(yD0) <= yCandGenMax) { + hCandidates->Fill(kCandidateStepMcCandInAcceptance, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); + if (mcParticle.originMcGen() == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("hPtCandMcGenPrompt"), mcParticle.pt()); + } + if (mcParticle.originMcGen() == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hPtCandMcGenNonPrompt"), mcParticle.pt()); + } + } + bool isDaughterInAcceptance = true; + auto daughters = mcParticle.template daughters_as(); + for (const auto& daughter : daughters) { + if (daughter.pt() < ptDaughterMin || std::abs(daughter.eta()) > etaTrackMax) { + isDaughterInAcceptance = false; + } + } + if (isDaughterInAcceptance) { + hCandidates->Fill(kCandidateStepMcDaughtersInAcceptance, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); + registry.fill(HIST("hPtCandMcGenDaughterInAcc"), mcParticle.pt()); + } + } + } + } + + // recontructed candidates loop + for (const auto& candidate : candidates) { + if (candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { + continue; + } + std::vector outputMlD0 = {-1., -1., -1.}; + std::vector outputMlD0bar = {-1., -1., -1.}; + if (candidate.isSelD0() < selectionFlagD0 || candidate.isSelD0bar() < selectionFlagD0) { + continue; + } + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMlD0[iclass] = candidate.mlProbD0()[classMl->at(iclass)]; + outputMlD0bar[iclass] = candidate.mlProbD0bar()[classMl->at(iclass)]; + } + if (outputMlD0[0] > mlOutputBkgD0->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt())) || outputMlD0[1] < mlOutputPromptD0->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt()))) { + continue; + } + if (outputMlD0bar[0] > mlOutputBkgD0bar->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt())) || outputMlD0bar[1] < mlOutputPromptD0bar->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt()))) { + continue; + } + auto collision = candidate.template collision_as>(); + if (selNoSameBunchPileUpColl && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + continue; + } + multiplicity = collision.multFT0M(); + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + hCandidates->Fill(kCandidateStepMcReco, candidate.pt(), multiplicity, candidate.originMcRec()); + if (std::abs(hfHelper.yD0(candidate)) <= yCandMax) { + hCandidates->Fill(kCandidateStepMcRecoInAcceptance, candidate.pt(), multiplicity, candidate.originMcRec()); + if (candidate.originMcRec() == RecoDecay::OriginType::Prompt) { + registry.fill(HIST("hPtCandMcRecPrompt"), candidate.pt()); + } + if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hPtCandMcRecNonPrompt"), candidate.pt()); + } + } + } + } + } + PROCESS_SWITCH(HfTaskCorrelationD0Hadrons, processMcCandEfficiency, "Process MC for calculating candidate reconstruction efficiency", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/HFC/Tasks/taskCorrelationDDbar.cxx b/PWGHF/HFC/Tasks/taskCorrelationDDbar.cxx index 3172d8e6e22..21321f51f21 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationDDbar.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationDDbar.cxx @@ -14,14 +14,26 @@ /// /// \author Fabio Colamaria , INFN Bari -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsAnalysis.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include using namespace o2; using namespace o2::framework; @@ -61,7 +73,7 @@ const TString stringSideband = "sidebands;"; const TString stringMCParticles = "MC gen - D,Dbar particles;"; const TString stringMCReco = "MC reco - D,Dbar candidates "; -//definition of vectors for standard ptbin and invariant mass configurables +// definition of vectors for standard ptbin and invariant mass configurables const int npTBinsCorrelations = 8; const double pTBinsCorrelations[npTBinsCorrelations + 1] = {0., 2., 4., 6., 8., 12., 16., 24., 99.}; auto pTBinsCorrelations_v = std::vector{pTBinsCorrelations, pTBinsCorrelations + npTBinsCorrelations + 1}; @@ -77,7 +89,7 @@ auto sidebandLeftInner_v = std::vector{sidebandLeftInnerDefault, sideban auto sidebandLeftOuter_v = std::vector{sidebandLeftOuterDefault, sidebandLeftOuterDefault + npTBinsCorrelations}; auto sidebandRightInner_v = std::vector{sidebandRightInnerDefault, sidebandRightInnerDefault + npTBinsCorrelations}; auto sidebandRightOuter_v = std::vector{sidebandRightOuterDefault, sidebandRightOuterDefault + npTBinsCorrelations}; -const int npTBinsEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::nBinsPt; +const int npTBinsEfficiency = o2::analysis::hf_cuts_d0_to_pi_k::NBinsPt; const double efficiencyDmesonDefault[npTBinsEfficiency] = {}; auto efficiencyDmeson_v = std::vector{efficiencyDmesonDefault, efficiencyDmesonDefault + npTBinsEfficiency}; @@ -233,7 +245,7 @@ struct HfTaskCorrelationDDbar { void processData(aod::DDbarPairFull const& pairEntries) { for (const auto& pairEntry : pairEntries) { - //define variables for widely used quantities + // define variables for widely used quantities double deltaPhi = pairEntry.deltaPhi(); double deltaEta = pairEntry.deltaEta(); double ptD = pairEntry.ptD(); @@ -249,17 +261,17 @@ struct HfTaskCorrelationDDbar { efficiencyWeight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiency, ptD)) * efficiencyD->at(o2::analysis::findBin(binsPtEfficiency, ptDbar))); } - //fill 2D invariant mass plots + // fill 2D invariant mass plots registry.fill(HIST("hMass2DCorrelationPairs"), massD, massDbar, ptD, ptDbar, efficiencyWeight); - //reject entries outside pT ranges of interest - if (pTBinD == -1 || pTBinDbar == -1) { //at least one particle outside accepted pT range + // reject entries outside pT ranges of interest + if (pTBinD == -1 || pTBinDbar == -1) { // at least one particle outside accepted pT range continue; } - //check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots + // check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots if (massD > signalRegionInner->at(pTBinD) && massD < signalRegionOuter->at(pTBinD) && massDbar > signalRegionInner->at(pTBinDbar) && massDbar < signalRegionOuter->at(pTBinDbar)) { - //in signal region + // in signal region registry.fill(HIST("hCorrel2DVsPtSignalRegion"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSignalRegion"), deltaPhi, deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaEtaPtIntSignalRegion"), deltaEta, efficiencyWeight); @@ -272,7 +284,7 @@ struct HfTaskCorrelationDDbar { (massD > sidebandRightInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar)) || (massD > sidebandLeftInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandLeftOuter->at(pTBinDbar)) || (massD > sidebandLeftInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandRightInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar))) { - //in sideband region + // in sideband region registry.fill(HIST("hCorrel2DVsPtSidebands"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSidebands"), deltaPhi, deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaEtaPtIntSidebands"), deltaEta, efficiencyWeight); @@ -290,7 +302,7 @@ struct HfTaskCorrelationDDbar { void processMcRec(aod::DDbarPairFull const& pairEntries) { for (const auto& pairEntry : pairEntries) { - //define variables for widely used quantities + // define variables for widely used quantities double deltaPhi = pairEntry.deltaPhi(); double deltaEta = pairEntry.deltaEta(); double ptD = pairEntry.ptD(); @@ -306,81 +318,81 @@ struct HfTaskCorrelationDDbar { efficiencyWeight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiency, ptD)) * efficiencyD->at(o2::analysis::findBin(binsPtEfficiency, ptDbar))); } - //fill 2D invariant mass plots + // fill 2D invariant mass plots switch (pairEntry.signalStatus()) { - case 0: //D Bkg, Dbar Bkg + case 0: // D Bkg, Dbar Bkg registry.fill(HIST("hMass2DCorrelationPairsMCRecBkgBkg"), massD, massDbar, ptD, ptDbar, efficiencyWeight); break; - case 1: //D Bkg, Dbar Ref + case 1: // D Bkg, Dbar Ref registry.fill(HIST("hMass2DCorrelationPairsMCRecBkgRef"), massD, massDbar, ptD, ptDbar, efficiencyWeight); break; - case 2: //D Bkg, Dbar Sig + case 2: // D Bkg, Dbar Sig registry.fill(HIST("hMass2DCorrelationPairsMCRecBkgSig"), massD, massDbar, ptD, ptDbar, efficiencyWeight); break; - case 3: //D Ref, Dbar Bkg + case 3: // D Ref, Dbar Bkg registry.fill(HIST("hMass2DCorrelationPairsMCRecRefBkg"), massD, massDbar, ptD, ptDbar, efficiencyWeight); break; - case 4: //D Ref, Dbar Ref + case 4: // D Ref, Dbar Ref registry.fill(HIST("hMass2DCorrelationPairsMCRecRefRef"), massD, massDbar, ptD, ptDbar, efficiencyWeight); break; - case 5: //D Ref, Dbar Sig + case 5: // D Ref, Dbar Sig registry.fill(HIST("hMass2DCorrelationPairsMCRecRefSig"), massD, massDbar, ptD, ptDbar, efficiencyWeight); break; - case 6: //D Sig, Dbar Bkg + case 6: // D Sig, Dbar Bkg registry.fill(HIST("hMass2DCorrelationPairsMCRecSigBkg"), massD, massDbar, ptD, ptDbar, efficiencyWeight); break; - case 7: //D Sig, Dbar Ref + case 7: // D Sig, Dbar Ref registry.fill(HIST("hMass2DCorrelationPairsMCRecSigRef"), massD, massDbar, ptD, ptDbar, efficiencyWeight); break; - case 8: //D Sig, Dbar Sig + case 8: // D Sig, Dbar Sig registry.fill(HIST("hMass2DCorrelationPairsMCRecSigSig"), massD, massDbar, ptD, ptDbar, efficiencyWeight); break; - default: //should not happen for MC reco + default: // should not happen for MC reco break; } - //reject entries outside pT ranges of interest - if (pTBinD == -1 || pTBinDbar == -1) { //at least one particle outside accepted pT range + // reject entries outside pT ranges of interest + if (pTBinD == -1 || pTBinDbar == -1) { // at least one particle outside accepted pT range continue; } - //check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots + // check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots if (massD > signalRegionInner->at(pTBinD) && massD < signalRegionOuter->at(pTBinD) && massDbar > signalRegionInner->at(pTBinDbar) && massDbar < signalRegionOuter->at(pTBinDbar)) { - //in signal region + // in signal region registry.fill(HIST("hCorrel2DPtIntSignalRegionMCRec"), deltaPhi, deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaEtaPtIntSignalRegionMCRec"), deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaPhiPtIntSignalRegionMCRec"), deltaPhi, efficiencyWeight); registry.fill(HIST("hDeltaPtDDbarSignalRegionMCRec"), ptDbar - ptD, efficiencyWeight); registry.fill(HIST("hDeltaPtMaxMinSignalRegionMCRec"), std::abs(ptDbar - ptD), efficiencyWeight); switch (pairEntry.signalStatus()) { - case 0: //D Bkg, Dbar Bkg + case 0: // D Bkg, Dbar Bkg registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecBkgBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 1: //D Bkg, Dbar Ref + case 1: // D Bkg, Dbar Ref registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecBkgRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 2: //D Bkg, Dbar Sig + case 2: // D Bkg, Dbar Sig registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecBkgSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 3: //D Ref, Dbar Bkg + case 3: // D Ref, Dbar Bkg registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecRefBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 4: //D Ref, Dbar Ref + case 4: // D Ref, Dbar Ref registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecRefRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 5: //D Ref, Dbar Sig + case 5: // D Ref, Dbar Sig registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecRefSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 6: //D Sig, Dbar Bkg + case 6: // D Sig, Dbar Bkg registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecSigBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 7: //D Sig, Dbar Ref + case 7: // D Sig, Dbar Ref registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecSigRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 8: //D Sig, Dbar Sig + case 8: // D Sig, Dbar Sig registry.fill(HIST("hCorrel2DVsPtSignalRegionMCRecSigSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - default: //should not happen for MC reco + default: // should not happen for MC reco break; } } @@ -389,41 +401,41 @@ struct HfTaskCorrelationDDbar { (massD > sidebandRightInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar)) || (massD > sidebandLeftInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandLeftInner->at(pTBinDbar) && massDbar < sidebandLeftOuter->at(pTBinDbar)) || (massD > sidebandLeftInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD) && massDbar > sidebandRightInner->at(pTBinDbar) && massDbar < sidebandRightOuter->at(pTBinDbar))) { - //in sideband region + // in sideband region registry.fill(HIST("hCorrel2DPtIntSidebandsMCRec"), deltaPhi, deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaEtaPtIntSidebandsMCRec"), deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaPhiPtIntSidebandsMCRec"), deltaPhi, efficiencyWeight); registry.fill(HIST("hDeltaPtDDbarSidebandsMCRec"), ptDbar - ptD, efficiencyWeight); registry.fill(HIST("hDeltaPtMaxMinSidebandsMCRec"), std::abs(ptDbar - ptD), efficiencyWeight); switch (pairEntry.signalStatus()) { - case 0: //D Bkg, Dbar Bkg + case 0: // D Bkg, Dbar Bkg registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecBkgBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 1: //D Bkg, Dbar Ref + case 1: // D Bkg, Dbar Ref registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecBkgRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 2: //D Bkg, Dbar Sig + case 2: // D Bkg, Dbar Sig registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecBkgSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 3: //D Ref, Dbar Bkg + case 3: // D Ref, Dbar Bkg registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecRefBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 4: //D Ref, Dbar Ref + case 4: // D Ref, Dbar Ref registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecRefRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 5: //D Ref, Dbar Sig + case 5: // D Ref, Dbar Sig registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecRefSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 6: //D Sig, Dbar Bkg + case 6: // D Sig, Dbar Bkg registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecSigBkg"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 7: //D Sig, Dbar Ref + case 7: // D Sig, Dbar Ref registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecSigRef"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - case 8: //D Sig, Dbar Sig + case 8: // D Sig, Dbar Sig registry.fill(HIST("hCorrel2DVsPtSidebandsMCRecSigSig"), deltaPhi, deltaEta, ptD, ptDbar, efficiencyWeight); break; - default: //should not happen for MC reco + default: // should not happen for MC reco break; } } @@ -437,13 +449,13 @@ struct HfTaskCorrelationDDbar { void processMcGen(aod::DDbarPair const& pairEntries) { for (const auto& pairEntry : pairEntries) { - //define variables for widely used quantities + // define variables for widely used quantities double deltaPhi = pairEntry.deltaPhi(); double deltaEta = pairEntry.deltaEta(); double ptD = pairEntry.ptD(); double ptDbar = pairEntry.ptDbar(); - //reject entries outside pT ranges of interest + // reject entries outside pT ranges of interest if (o2::analysis::findBin(binsPtCorrelations, ptD) == -1 || o2::analysis::findBin(binsPtCorrelations, ptDbar) == -1) { continue; } diff --git a/PWGHF/HFC/Tasks/taskCorrelationDMesonPairs.cxx b/PWGHF/HFC/Tasks/taskCorrelationDMesonPairs.cxx index 41a1f77836f..31082ef795a 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationDMesonPairs.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationDMesonPairs.cxx @@ -14,15 +14,21 @@ /// /// \author Andrea Tavira García , IJCLab Orsay -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsAnalysis.h" #include "PWGHF/HFC/DataModel/DMesonPairsTables.h" +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; diff --git a/PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx index a196c6fb9a8..ebdbab469df 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx @@ -10,20 +10,51 @@ // or submit itself to any jurisdiction. /// \file taskCorrelationDplusHadrons.cxx +/// \brief D+-Hadrons azimuthal correlations analysis task - data-like, MC-reco and MC-Gen analyses /// \author Shyam Kumar -#include // std::shared_ptr -#include -#include -#include "CCDB/BasicCCDBManager.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsAnalysis.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include // std::shared_ptr +#include +#include using namespace o2; using namespace o2::constants::math; @@ -48,24 +79,25 @@ const TString stringMCGenDFd = "MC gen, non-prompt D+;"; const int npTBinsCorrelations = 8; const double pTBinsCorrelations[npTBinsCorrelations + 1] = {0., 2., 4., 6., 8., 12., 16., 24., 99.}; -auto pTBinsCorrelations_v = std::vector{pTBinsCorrelations, pTBinsCorrelations + npTBinsCorrelations + 1}; +auto ptBinsCorrelationsVec = std::vector{pTBinsCorrelations, pTBinsCorrelations + npTBinsCorrelations + 1}; const double signalRegionInnerDefault[npTBinsCorrelations] = {1.8490, 1.8490, 1.8490, 1.8490, 1.8490, 1.8490, 1.8490, 1.8490}; const double signalRegionOuterDefault[npTBinsCorrelations] = {1.8890, 1.8890, 1.8890, 1.8890, 1.8890, 1.8890, 1.8890, 1.8890}; const double sidebandLeftOuterDefault[npTBinsCorrelations] = {1.7690, 1.7690, 1.7690, 1.7690, 1.7690, 1.7690, 1.7690, 1.7690}; const double sidebandLeftInnerDefault[npTBinsCorrelations] = {1.8250, 1.8250, 1.8250, 1.8250, 1.8250, 1.8250, 1.8250, 1.8250}; const double sidebandRightInnerDefault[npTBinsCorrelations] = {1.9130, 1.9130, 1.9130, 1.9130, 1.9130, 1.9130, 1.9130, 1.9130}; const double sidebandRightOuterDefault[npTBinsCorrelations] = {1.9690, 1.9690, 1.9690, 1.9690, 1.9690, 1.9690, 1.9690, 1.9690}; -auto signalRegionInner_v = std::vector{signalRegionInnerDefault, signalRegionInnerDefault + npTBinsCorrelations}; -auto signalRegionOuter_v = std::vector{signalRegionOuterDefault, signalRegionOuterDefault + npTBinsCorrelations}; -auto sidebandLeftInner_v = std::vector{sidebandLeftInnerDefault, sidebandLeftInnerDefault + npTBinsCorrelations}; -auto sidebandLeftOuter_v = std::vector{sidebandLeftOuterDefault, sidebandLeftOuterDefault + npTBinsCorrelations}; -auto sidebandRightInner_v = std::vector{sidebandRightInnerDefault, sidebandRightInnerDefault + npTBinsCorrelations}; -auto sidebandRightOuter_v = std::vector{sidebandRightOuterDefault, sidebandRightOuterDefault + npTBinsCorrelations}; -const int npTBinsEfficiency = o2::analysis::hf_cuts_dplus_to_pi_k_pi::nBinsPt; +auto signalRegionInnerVec = std::vector{signalRegionInnerDefault, signalRegionInnerDefault + npTBinsCorrelations}; +auto signalRegionOuterVec = std::vector{signalRegionOuterDefault, signalRegionOuterDefault + npTBinsCorrelations}; +auto sidebandLeftInnerVec = std::vector{sidebandLeftInnerDefault, sidebandLeftInnerDefault + npTBinsCorrelations}; +auto sidebandLeftOuterVec = std::vector{sidebandLeftOuterDefault, sidebandLeftOuterDefault + npTBinsCorrelations}; +auto sidebandRightInnerVec = std::vector{sidebandRightInnerDefault, sidebandRightInnerDefault + npTBinsCorrelations}; +auto sidebandRightOuterVec = std::vector{sidebandRightOuterDefault, sidebandRightOuterDefault + npTBinsCorrelations}; +const int npTBinsEfficiency = o2::analysis::hf_cuts_dplus_to_pi_k_pi::NBinsPt; std::vector efficiencyDmeson(npTBinsEfficiency + 1); /// Dplus-Hadron correlation pair filling task, from pair tables - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) struct HfTaskCorrelationDplusHadrons { + Configurable isPromptAnalysis{"isPromptAnalysis", true, "Flag for prompt D+-hadron correlations"}; Configurable fillHistoData{"fillHistoData", true, "Flag for filling histograms in data processes"}; Configurable fillHistoMcRec{"fillHistoMcRec", true, "Flag for filling histograms in MC Rec processes"}; Configurable fillHistoMcGen{"fillHistoMcGen", true, "Flag for filling histograms in MC Gen processes"}; @@ -75,10 +107,11 @@ struct HfTaskCorrelationDplusHadrons { Configurable selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for D+"}; // 7 corresponds to topo+PID cuts Configurable selNoSameBunchPileUpColl{"selNoSameBunchPileUpColl", true, "Flag for rejecting the collisions associated with the same bunch crossing"}; Configurable> classMl{"classMl", {0, 1, 2}, "Indexes of ML scores to be stored. Three indexes max."}; - Configurable> mlOutputPrompt{"mlScorePrompt", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for prompt"}; - Configurable> mlOutputBkg{"mlScoreBkg", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for bkg"}; + Configurable> mlScorePromptOrNonPromptMin{"mlScorePromptOrNonPromptMin", {0.5, 0.5, 0.5, 0.5}, "Minimum Machine learning scores for prompt or Feed-down"}; + Configurable> mlScorePromptOrNonPromptMax{"mlScorePromptOrNonPromptMax", {1.0, 1.0, 1.0, 1.0}, "Maximum Machine learning scores for prompt or Feed-down"}; + Configurable> mlScoreBkg{"mlScoreBkg", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for bkg"}; // pT ranges for correlation plots: the default values are those embedded in hf_cuts_dplus_to_pi_k_pi (i.e. the mass pT bins), but can be redefined via json files - Configurable> binsPtCorrelations{"binsPtCorrelations", std::vector{pTBinsCorrelations_v}, "pT bin limits for correlation plots"}; + Configurable> binsPtCorrelations{"binsPtCorrelations", std::vector{ptBinsCorrelationsVec}, "pT bin limits for correlation plots"}; Configurable> binsPtHadron{"binsPtHadron", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for assoc particle efficiency"}; Configurable> binsPtEfficiencyD{"binsPtEfficiencyD", std::vector{o2::analysis::hf_cuts_dplus_to_pi_k_pi::vecBinsPt}, "pT bin limits for efficiency"}; Configurable> binsPtEfficiencyHad{"binsPtEfficiencyHad", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for associated particle efficiency"}; @@ -86,12 +119,12 @@ struct HfTaskCorrelationDplusHadrons { Configurable> efficiencyFdD{"efficiencyFdD", {1., 1., 1., 1., 1., 1.}, "efficiency values for beauty feed-down D+ meson"}; Configurable> efficiencyHad{"efficiencyHad", {1., 1., 1., 1., 1., 1.}, "efficiency values for associated particles"}; // signal and sideband region edges, to be defined via json file (initialised to empty) - Configurable> signalRegionInner{"signalRegionInner", std::vector{signalRegionInner_v}, "Inner values of signal region vs pT"}; - Configurable> signalRegionOuter{"signalRegionOuter", std::vector{signalRegionOuter_v}, "Outer values of signal region vs pT"}; - Configurable> sidebandLeftInner{"sidebandLeftInner", std::vector{sidebandLeftInner_v}, "Inner values of left sideband vs pT"}; - Configurable> sidebandLeftOuter{"sidebandLeftOuter", std::vector{sidebandLeftOuter_v}, "Outer values of left sideband vs pT"}; - Configurable> sidebandRightInner{"sidebandRightInner", std::vector{sidebandRightInner_v}, "Inner values of right sideband vs pT"}; - Configurable> sidebandRightOuter{"sidebandRightOuter", std::vector{sidebandRightOuter_v}, "Outer values of right sideband vs pT"}; + Configurable> signalRegionInner{"signalRegionInner", std::vector{signalRegionInnerVec}, "Inner values of signal region vs pT"}; + Configurable> signalRegionOuter{"signalRegionOuter", std::vector{signalRegionOuterVec}, "Outer values of signal region vs pT"}; + Configurable> sidebandLeftInner{"sidebandLeftInner", std::vector{sidebandLeftInnerVec}, "Inner values of left sideband vs pT"}; + Configurable> sidebandLeftOuter{"sidebandLeftOuter", std::vector{sidebandLeftOuterVec}, "Outer values of left sideband vs pT"}; + Configurable> sidebandRightInner{"sidebandRightInner", std::vector{sidebandRightInnerVec}, "Inner values of right sideband vs pT"}; + Configurable> sidebandRightOuter{"sidebandRightOuter", std::vector{sidebandRightOuterVec}, "Outer values of right sideband vs pT"}; Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. DCA_xy of tracks"}; Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. DCA_z of tracks"}; Configurable etaTrackMax{"etaTrackMax", 0.8, "max. eta of tracks"}; @@ -112,20 +145,14 @@ struct HfTaskCorrelationDplusHadrons { Configurable fdEffCcdbPath{"fdEffCcdbPath", "", "CCDB path for trigger efficiency"}; Configurable timestampCcdb{"timestampCcdb", -1, "timestamp of the efficiency files used to query in CCDB"}; Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; - // configurable axis definition - ConfigurableAxis binsMassD{"binsMassD", {200, 1.7, 2.10}, "inv. mass (#pi^{+}K^{-}#pi^{+}) (GeV/#it{c}^{2})"}; - ConfigurableAxis binsBdtScore{"binsBdtScore", {100, 0., 1.}, "Bdt output scores"}; - ConfigurableAxis binsEta{"binsEta", {100, -2., 2.}, "#it{#eta}"}; - ConfigurableAxis binsPhi{"binsPhi", {64, -PIHalf, 3. * PIHalf}, "#it{#varphi}"}; - ConfigurableAxis binsMultFT0M{"binsMultFT0M", {600, 0., 8000.}, "Multiplicity as FT0M signal amplitude"}; - ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; + HfHelper hfHelper; Service ccdb; std::shared_ptr mEfficiencyPrompt = nullptr; std::shared_ptr mEfficiencyFD = nullptr; std::shared_ptr mEfficiencyAssociated = nullptr; - - HfHelper hfHelper; + std::shared_ptr effD = nullptr; + int idxBdtScore = 1; // Index BDTScore 1 for Prompt and 2 for FD Analysis enum CandidateStep { kCandidateStepMcGenAll = 0, kCandidateStepMcGenDplusToPiKPi, @@ -143,6 +170,13 @@ struct HfTaskCorrelationDplusHadrons { Filter dplusFilter = ((o2::aod::hf_track_index::hfflag & static_cast(1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi)) != static_cast(0)) && aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; Filter trackFilter = (nabs(aod::track::eta) < etaTrackMax) && (aod::track::pt > ptTrackMin) && (aod::track::pt < ptTrackMax) && (nabs(aod::track::dcaXY) < dcaXYTrackMax) && (nabs(aod::track::dcaZ) < dcaZTrackMax); + // configurable axis definition + ConfigurableAxis binsMassD{"binsMassD", {200, 1.7, 2.10}, "inv. mass (#pi^{+}K^{-}#pi^{+}) (GeV/#it{c}^{2})"}; + ConfigurableAxis binsBdtScore{"binsBdtScore", {100, 0., 1.}, "Bdt output scores"}; + ConfigurableAxis binsEta{"binsEta", {100, -2., 2.}, "#it{#eta}"}; + ConfigurableAxis binsPhi{"binsPhi", {64, -PIHalf, 3. * PIHalf}, "#it{#varphi}"}; + ConfigurableAxis binsMultFT0M{"binsMultFT0M", {600, 0., 8000.}, "Multiplicity as FT0M signal amplitude"}; + ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -271,6 +305,8 @@ struct HfTaskCorrelationDplusHadrons { } LOGF(info, "Loaded associated efficiency histogram from %s", associatedEffCcdbPath.value.c_str()); } + auto effD = isPromptAnalysis ? mEfficiencyPrompt : mEfficiencyFD; + idxBdtScore = isPromptAnalysis ? 1 : 2; if (activateQA) { const int regionLimits = 6; @@ -297,22 +333,24 @@ struct HfTaskCorrelationDplusHadrons { float massD = candidate.mD(); float ptD = candidate.ptD(); float bdtScorePrompt = candidate.mlScorePrompt(); + float bdtScoreNonPrompt = candidate.mlScoreNonPrompt(); float bdtScoreBkg = candidate.mlScoreBkg(); int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); + float bdtScorePromptOrNonPrompt = isPromptAnalysis ? bdtScorePrompt : bdtScoreNonPrompt; // reject entries outside pT ranges of interest if (ptD < binsPtEfficiencyD->front() || ptD > binsPtEfficiencyD->back()) { continue; } - if (bdtScorePrompt < mlOutputPrompt->at(effBinD) || bdtScoreBkg > mlOutputBkg->at(effBinD)) { + if (bdtScorePromptOrNonPrompt < mlScorePromptOrNonPromptMin->at(effBinD) || bdtScorePromptOrNonPrompt > mlScorePromptOrNonPromptMax->at(effBinD) || bdtScoreBkg > mlScoreBkg->at(effBinD)) { continue; } double efficiencyWeightD = 1.; if (applyEfficiency) { efficiencyWeightD = 1. / efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)); if (loadAccXEffFromCCDB) { - efficiencyWeightD = 1. / mEfficiencyPrompt->GetBinContent(mEfficiencyPrompt->FindBin(ptD)); + efficiencyWeightD = 1. / effD->GetBinContent(effD->FindBin(ptD)); } } registry.fill(HIST("hMassDplusVsPt"), massD, ptD, efficiencyWeightD); @@ -328,6 +366,7 @@ struct HfTaskCorrelationDplusHadrons { float ptD = pairEntry.ptD(); float ptHadron = pairEntry.ptHadron(); float bdtScorePrompt = pairEntry.mlScorePrompt(); + float bdtScoreNonPrompt = pairEntry.mlScoreNonPrompt(); float bdtScoreBkg = pairEntry.mlScoreBkg(); float trackDcaXY = pairEntry.trackDcaXY(); float trackDcaZ = pairEntry.trackDcaZ(); @@ -336,13 +375,14 @@ struct HfTaskCorrelationDplusHadrons { double massD = pairEntry.mD(); int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); int pTBinD = o2::analysis::findBin(binsPtCorrelations, ptD); + float bdtScorePromptOrNonPrompt = isPromptAnalysis ? bdtScorePrompt : bdtScoreNonPrompt; // reject entries outside pT ranges of interest if (ptD < binsPtEfficiencyD->front() || ptD > binsPtEfficiencyD->back()) { continue; } - if (bdtScorePrompt < mlOutputPrompt->at(effBinD) || bdtScoreBkg > mlOutputBkg->at(effBinD)) { + if (bdtScorePromptOrNonPrompt < mlScorePromptOrNonPromptMin->at(effBinD) || bdtScorePromptOrNonPrompt > mlScorePromptOrNonPromptMax->at(effBinD) || bdtScoreBkg > mlScoreBkg->at(effBinD)) { continue; } if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { @@ -352,7 +392,7 @@ struct HfTaskCorrelationDplusHadrons { if (applyEfficiency) { efficiencyWeight = 1. / (efficiencyD->at(effBinD) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); if (loadAccXEffFromCCDB) { - efficiencyWeight = 1. / (mEfficiencyPrompt->GetBinContent(mEfficiencyPrompt->FindBin(ptD)) * mEfficiencyAssociated->GetBinContent(mEfficiencyAssociated->FindBin(ptHadron))); + efficiencyWeight = 1. / (effD->GetBinContent(effD->FindBin(ptD)) * mEfficiencyAssociated->GetBinContent(mEfficiencyAssociated->FindBin(ptHadron))); } } // check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots @@ -395,15 +435,17 @@ struct HfTaskCorrelationDplusHadrons { float massD = candidate.mD(); float ptD = candidate.ptD(); float bdtScorePrompt = candidate.mlScorePrompt(); + float bdtScoreNonPrompt = candidate.mlScoreNonPrompt(); float bdtScoreBkg = candidate.mlScoreBkg(); int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); bool isDplusPrompt = candidate.isPrompt(); + float bdtScorePromptOrNonPrompt = isPromptAnalysis ? bdtScorePrompt : bdtScoreNonPrompt; // reject entries outside pT ranges of interest if (ptD < binsPtEfficiencyD->front() || ptD > binsPtEfficiencyD->back()) continue; - if (bdtScorePrompt < mlOutputPrompt->at(effBinD) || bdtScoreBkg > mlOutputBkg->at(effBinD)) { + if (bdtScorePromptOrNonPrompt < mlScorePromptOrNonPromptMin->at(effBinD) || bdtScorePromptOrNonPrompt > mlScorePromptOrNonPromptMax->at(effBinD) || bdtScoreBkg > mlScoreBkg->at(effBinD)) { continue; } double efficiencyWeightD = 1.; @@ -440,22 +482,24 @@ struct HfTaskCorrelationDplusHadrons { float ptHadron = pairEntry.ptHadron(); float massD = pairEntry.mD(); float bdtScorePrompt = pairEntry.mlScorePrompt(); + float bdtScoreNonPrompt = pairEntry.mlScoreNonPrompt(); float bdtScoreBkg = pairEntry.mlScoreBkg(); bool isPhysicalPrimary = pairEntry.isPhysicalPrimary(); float trackDcaXY = pairEntry.trackDcaXY(); float trackDcaZ = pairEntry.trackDcaZ(); int trackTpcCrossedRows = pairEntry.trackTPCNClsCrossedRows(); - int statusDplusPrompt = static_cast(pairEntry.isPrompt()); - int statusPromptHadron = pairEntry.trackOrigin(); + bool isDplusPrompt = pairEntry.isPrompt(); + int originHadron = pairEntry.trackOrigin(); int poolBin = pairEntry.poolBin(); int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); int pTBinD = o2::analysis::findBin(binsPtCorrelations, ptD); + float bdtScorePromptOrNonPrompt = isPromptAnalysis ? bdtScorePrompt : bdtScoreNonPrompt; // reject entries outside pT ranges of interest if (ptD < binsPtEfficiencyD->front() || ptD > binsPtEfficiencyD->back()) continue; - if (bdtScorePrompt < mlOutputPrompt->at(effBinD) || bdtScoreBkg > mlOutputBkg->at(effBinD)) { + if (bdtScorePromptOrNonPrompt < mlScorePromptOrNonPromptMin->at(effBinD) || bdtScorePromptOrNonPrompt > mlScorePromptOrNonPromptMax->at(effBinD) || bdtScoreBkg > mlScoreBkg->at(effBinD)) { continue; } if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { @@ -464,7 +508,7 @@ struct HfTaskCorrelationDplusHadrons { double efficiencyWeight = 1.; if (applyEfficiency) { - if (statusDplusPrompt) { + if (isDplusPrompt) { efficiencyWeight = 1. / (efficiencyD->at(effBinD) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); if (loadAccXEffFromCCDB) { efficiencyWeight = 1. / (mEfficiencyPrompt->GetBinContent(mEfficiencyPrompt->FindBin(ptD)) * mEfficiencyAssociated->GetBinContent(mEfficiencyAssociated->FindBin(ptHadron))); @@ -488,15 +532,15 @@ struct HfTaskCorrelationDplusHadrons { // check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots if (massD > signalRegionInner->at(pTBinD) && massD < signalRegionOuter->at(pTBinD)) { // in signal region - registry.fill(HIST("hCorrel2DVsPtSignalRegionMcRec"), deltaPhi, deltaEta, ptD, ptHadron, statusDplusPrompt, poolBin, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtSignalRegionMcRec"), deltaPhi, deltaEta, ptD, ptHadron, static_cast(isDplusPrompt), poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSignalRegionMcRec"), deltaPhi, deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaEtaPtIntSignalRegionMcRec"), deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaPhiPtIntSignalRegionMcRec"), deltaPhi, efficiencyWeight); if (isPhysicalPrimary) { - registry.fill(HIST("hCorrel2DVsPtPhysicalPrimaryMcRec"), deltaPhi, deltaEta, ptD, ptHadron, statusDplusPrompt, poolBin, efficiencyWeight); - if (statusDplusPrompt == 1 && statusPromptHadron == 1) { + registry.fill(HIST("hCorrel2DVsPtPhysicalPrimaryMcRec"), deltaPhi, deltaEta, ptD, ptHadron, static_cast(isDplusPrompt), poolBin, efficiencyWeight); + if (isDplusPrompt && originHadron == RecoDecay::OriginType::Prompt) { registry.fill(HIST("hCorrel2DVsPtSignalRegionPromptDplusPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); - } else if (statusDplusPrompt == 0 && statusPromptHadron == 2) { + } else if (!isDplusPrompt && originHadron == RecoDecay::OriginType::NonPrompt) { registry.fill(HIST("hCorrel2DVsPtSignalRegionNonPromptDplusNonPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); } } @@ -535,7 +579,7 @@ struct HfTaskCorrelationDplusHadrons { float ptD = pairEntry.ptD(); float ptHadron = pairEntry.ptHadron(); int poolBin = pairEntry.poolBin(); - int statusPromptHadron = pairEntry.trackOrigin(); + int originHadron = pairEntry.trackOrigin(); bool isDplusPrompt = pairEntry.isPrompt(); registry.fill(HIST("hCorrel2DVsPtMcGen"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); @@ -543,12 +587,12 @@ struct HfTaskCorrelationDplusHadrons { registry.fill(HIST("hDeltaPhiPtIntMcGen"), deltaPhi); if (isDplusPrompt) { registry.fill(HIST("hCorrel2DVsPtMcGenPrompt"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); - if (statusPromptHadron == 1) { + if (originHadron == RecoDecay::OriginType::Prompt) { registry.fill(HIST("hCorrel2DVsPtMcGenPromptDPromptHadron"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); } } else { registry.fill(HIST("hCorrel2DVsPtMcGenNonPrompt"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); - if (statusPromptHadron == 2) { + if (originHadron == RecoDecay::OriginType::NonPrompt) { registry.fill(HIST("hCorrel2DVsPtMcGenNonPromptDNonPromptHadron"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); } } @@ -573,7 +617,7 @@ struct HfTaskCorrelationDplusHadrons { auto mcCollision = mcParticle.template mcCollision_as>(); multiplicity = mcCollision.multMCFT0A() + mcCollision.multMCFT0C(); // multFT0M = multFt0A + multFT0C hCandidates->Fill(kCandidateStepMcGenAll, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); - if (std::abs(mcParticle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi) { + if (std::abs(mcParticle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { hCandidates->Fill(kCandidateStepMcGenDplusToPiKPi, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); auto yDplus = RecoDecay::y(mcParticle.pVector(), o2::constants::physics::MassDPlus); if (std::abs(yDplus) <= yCandGenMax) { @@ -612,7 +656,7 @@ struct HfTaskCorrelationDplusHadrons { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)]; } - if (outputMl[0] > mlOutputBkg->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt())) || outputMl[1] < mlOutputPrompt->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt()))) { + if (outputMl[0] > mlScoreBkg->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt())) || outputMl[idxBdtScore] < mlScorePromptOrNonPromptMin->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt())) || outputMl[idxBdtScore] > mlScorePromptOrNonPromptMax->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt()))) { continue; } auto collision = candidate.template collision_as>(); @@ -620,7 +664,7 @@ struct HfTaskCorrelationDplusHadrons { continue; } multiplicity = collision.multFT0M(); - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi) { + if (std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { hCandidates->Fill(kCandidateStepMcReco, candidate.pt(), multiplicity, candidate.originMcRec()); if (std::abs(hfHelper.yDplus(candidate)) <= yCandMax) { hCandidates->Fill(kCandidateStepMcRecoInAcceptance, candidate.pt(), multiplicity, candidate.originMcRec()); diff --git a/PWGHF/HFC/Tasks/taskCorrelationDsHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationDsHadrons.cxx index 35617444261..51a56e5a766 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationDsHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationDsHadrons.cxx @@ -14,17 +14,47 @@ /// \author Grazia Luparello /// \author Samuele Cattaruzzi -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsAnalysis.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::constants::physics; @@ -32,6 +62,13 @@ using namespace o2::constants::math; using namespace o2::framework; using namespace o2::framework::expressions; +enum ResonantChannel : int8_t { + PhiPi = 1, + Kstar0K = 2 +}; + +static std::unordered_map channelsResonant = {{{ResonantChannel::PhiPi, hf_decay::hf_cand_3prong::DecayChannelResonant::DsToPhiPi}, {ResonantChannel::Kstar0K, hf_decay::hf_cand_3prong::DecayChannelResonant::DsToKstar0K}}}; + /// Ds-Hadron correlation pair filling task, from pair tables - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) struct HfTaskCorrelationDsHadrons { Configurable fillHistoData{"fillHistoData", true, "Flag for filling histograms in data processes"}; @@ -42,26 +79,30 @@ struct HfTaskCorrelationDsHadrons { Configurable useSel8ForEff{"useSel8ForEff", true, "Flag for applying sel8 for collision selection"}; Configurable selNoSameBunchPileUpColl{"selNoSameBunchPileUpColl", true, "Flag for rejecting the collisions associated with the same bunch crossing"}; Configurable removeCollWSplitVtx{"removeCollWSplitVtx", false, "Flag for rejecting the splitted collisions"}; + Configurable loadAccXEffFromCCDB{"loadAccXEffFromCCDB", false, "Flag for loading efficiency distributions from CCDB"}; + Configurable separateTrackOrigins{"separateTrackOrigins", false, "Flag to enable separation of track origins (from c or b)"}; + Configurable useHighDimHistoForEff{"useHighDimHistoForEff", false, "Flag to create higher dimension histograms in the efficiency processes"}; // Configurable doMcCollisionCheck{"doMcCollisionCheck", false, "Flag for applying the collision check and selection based on MC collision info"}; Configurable selectionFlagDs{"selectionFlagDs", 7, "Selection Flag for Ds (avoid the case of flag = 0, no outputMlScore)"}; Configurable nTpcCrossedRaws{"nTpcCrossedRaws", 70, "Number of crossed TPC Rows"}; // Configurable eventGeneratorType{"eventGeneratorType", -1, "If positive, enable event selection using subGeneratorId information. The value indicates which events to keep (0 = MB, 4 = charm triggered, 5 = beauty triggered)"}; - Configurable decayChannel{"decayChannel", 1, "Decay channels: 1 for Ds->PhiPi->KKpi, 2 for Ds->K0*K->KKPi"}; + Configurable decayChannel{"decayChannel", 1, "Resonant decay channels: 1 for Ds->PhiPi->KKpi, 2 for Ds->K0*K->KKPi"}; Configurable cutCollPosZMc{"cutCollPosZMc", 10., "max z-vertex position for collision acceptance"}; Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. DCA_xy of tracks"}; Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. DCA_z of tracks"}; Configurable etaTrackMax{"etaTrackMax", 0.8, "max. eta of tracks"}; - Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; - Configurable ptCandMax{"ptCandMax", 50., "max. cand pT"}; - Configurable ptTrackMin{"ptTrackMin", 0.3, "min. track pT"}; - Configurable ptTrackMax{"ptTrackMax", 50., "max. track pT"}; - Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity"}; - Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen. cand. rapidity"}; - Configurable ptDaughterMin{"ptDaughterMin", 0.1, "min. daughter pT"}; + Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT (used in eff. process only)"}; + Configurable ptCandMax{"ptCandMax", 50., "max. cand pT (used in eff. process only)"}; + Configurable ptTrackMin{"ptTrackMin", 0.3, "min. track pT (used in eff. process only)"}; + Configurable ptTrackMax{"ptTrackMax", 50., "max. track pT (used in eff. process only)"}; + Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity (used in eff. process only)"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen. cand. rapidity (used in eff. process only)"}; + Configurable ptDaughterMin{"ptDaughterMin", 0.1, "min. daughter pT (used in eff. process only)"}; Configurable> classMl{"classMl", {0, 1, 2}, "Indexes of ML scores to be stored. Three indexes max."}; Configurable> binsPtD{"binsPtD", std::vector{o2::analysis::hf_cuts_ds_to_k_k_pi::vecBinsPt}, "pT bin limits for candidate mass plots and efficiency"}; Configurable> binsPtHadron{"binsPtHadron", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for assoc particle efficiency"}; - Configurable> mlOutputPrompt{"mlOutputPrompt", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for prompt"}; + Configurable> mlOutputPromptMin{"mlOutputPromptMin", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for prompt"}; + Configurable> mlOutputPromptMax{"mlOutputPromptMax", {1.0, 1.0, 1.0, 1.0}, "Machine learning scores for prompt"}; Configurable> mlOutputBkg{"mlOutputBkg", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for bkg"}; Configurable> binsPtEfficiencyD{"binsPtEfficiencyD", std::vector{o2::analysis::hf_cuts_ds_to_k_k_pi::vecBinsPt}, "pT bin limits for D-meson efficiency"}; Configurable> binsPtEfficiencyHad{"binsPtEfficiencyHad", std::vector{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for associated particle efficiency"}; @@ -73,27 +114,22 @@ struct HfTaskCorrelationDsHadrons { Configurable> sidebandLeftOuter{"sidebandLeftOuter", {1.9040, 1.9040, 1.9040, 1.9040, 1.9040, 1.9040, 1.9040, 1.9040}, "Outer values of left sideband vs pT"}; Configurable> sidebandRightInner{"sidebandRightInner", {2.0000, 2.0000, 2.0000, 2.0000, 2.0000, 2.0000, 2.0000, 2.0000}, "Inner values of right sideband vs pT"}; Configurable> sidebandRightOuter{"sidebandRightOuter", {2.0320, 2.0320, 2.0320, 2.0320, 2.0320, 2.0320, 2.0320, 2.0320}, "Outer values of right sideband vs pT"}; + // CCDB configuration + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable associatedEffCcdbPath{"associatedEffCcdbPath", "", "CCDB path for associated efficiency"}; + Configurable promptEffCcdbPath{"promptEffCcdbPath", "", "CCDB path for trigger efficiency"}; + Configurable fdEffCcdbPath{"fdEffCcdbPath", "", "CCDB path for trigger efficiency"}; + Configurable timestampCcdb{"timestampCcdb", -1, "timestamp of the efficiency files used to query in CCDB"}; - enum CandidateStep { - kCandidateStepMcGenDsToKKPi = 0, - kCandidateStepMcCandInAcceptance, - kCandidateStepMcDaughtersInAcceptance, - kCandidateStepMcReco, - kCandidateStepMcRecoInAcceptance, - kCandidateNSteps - }; - - enum AssocTrackStep { kAssocTrackStepMcGen = 0, - kAssocTrackStepMcGenInAcceptance, - kAssocTrackStepRecoAll, - kAssocTrackStepRecoMcMatch, - kAssocTrackStepRecoPrimaries, - kAssocTrackStepRecoSpecies, - kAssocTrackNSteps }; + std::shared_ptr hEfficiencyD = nullptr; + std::shared_ptr hEfficiencyAssociated = nullptr; + const float epsilon = 1.e-8; HfHelper hfHelper; SliceCache cache; + Service ccdb; + using DsHadronPair = soa::Join; using DsHadronPairFull = soa::Join; using DsHadronPairWithMl = soa::Join; @@ -117,6 +153,7 @@ struct HfTaskCorrelationDsHadrons { ConfigurableAxis binsPhi{"binsPhi", {64, -PIHalf, 3. * PIHalf}, "#it{#varphi}"}; ConfigurableAxis binsMultFT0M{"binsMultFT0M", {600, 0., 8000.}, "Multiplicity as FT0M signal amplitude"}; ConfigurableAxis binsPosZ{"binsPosZ", {100, -10., 10.}, "primary vertex z coordinate"}; + ConfigurableAxis binsNumPvContr{"binsNumPvContr", {100, 0., 1000.}, "number PV contributors"}; ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -133,6 +170,7 @@ struct HfTaskCorrelationDsHadrons { AxisSpec axisBdtScore = {binsBdtScore, "Bdt score"}; AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; AxisSpec axisPosZ = {binsPosZ, "PosZ"}; + AxisSpec axisNumPvContr = {binsNumPvContr, "Num PV contributors"}; AxisSpec axisDsPrompt = {2, -0.5, 1.5, "Prompt Ds"}; // Histograms for data analysis @@ -192,44 +230,133 @@ struct HfTaskCorrelationDsHadrons { } // Histograms for efficiencies if (fillHistoMcEff) { - registry.add("hPtCandMcRecPrompt", "Ds prompt candidates pt", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtCandMcRecNonPrompt", "Ds non prompt candidates pt", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtCandMcGenPrompt", "Ds,Hadron particles prompt - MC Gen", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtCandMcGenNonPrompt", "Ds,Hadron particles non prompt - MC Gen", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtCandMcGenDaughterInAcc", "Ds,Hadron particles non prompt - MC Gen", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtParticleAssocMcRec", "Associated Particle - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtParticleAssocSpecieMcRec", "Associated Particle - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtMcParticleAssocSpecieMcRec", "Associated Particle - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmPionMcRec", "Primary pions - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmKaonMcRec", "Primary kaons - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmProtonMcRec", "Primary protons - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmElectronMcRec", "Primary electrons - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmMuonMcRec", "Primary muons - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmPromptPartMcRec", "Primary prompt particles - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmNonPromptPartMcRec", "Primary non-prompt particles - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtParticleAssocMcGen", "Associated Particle - MC Gen", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmPionMcGen", "Primary pions - MC Gen", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmKaonMcGen", "Primary kaons - MC Gen", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmProtonMcGen", "Primary protons - MC Gen", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmElectronMcGen", "Primary electrons - MC Gen", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmMuonMcGen", "Primary muons - MC Gen", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmPromptPartMcGen", "Primary prompt particles - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtPrmNonPromptPartMcGen", "Primary non-prompt particles - MC Rec", {HistType::kTH1F, {axisPtHadron}}); registry.add("hFakeCollision", "Fake collision counter", {HistType::kTH1F, {{1, -0.5, 0.5, "n fake coll"}}}); registry.add("hFakeTracks", "Fake tracks counter", {HistType::kTH1F, {{1, -0.5, 0.5, "n fake tracks"}}}); + registry.add("hNumPvContrib", "Num PV contributors", {HistType::kTH1F, {axisNumPvContr}}); + registry.add("hPtPrmPromptPartMcGen", "Primary prompt particles - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmNonPromptPartMcGen", "Primary non-prompt particles - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmPromptPartMcRec", "Primary prompt particles - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmNonPromptPartMcRec", "Primary non-prompt particles - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtMcParticleAssocSpecieMcRec", "Associated Particle - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtParticleAssocMcRec", "Associated Particle - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtCandMcGenDaughterInAcc", "Ds,Hadron particles non prompt - MC Gen", {HistType::kTH1F, {axisPtD}}); + + if (useHighDimHistoForEff) { + registry.add("hPtCandMcRecPrompt", "Ds prompt candidates", {HistType::kTH2F, {{axisPtD}, {axisNumPvContr}}}); + registry.add("hPtCandMcRecNonPrompt", "Ds non prompt candidates pt", {HistType::kTH2F, {{axisPtD}, {axisNumPvContr}}}); + registry.add("hPtCandMcGenPrompt", "Ds,Hadron particles prompt - MC Gen", {HistType::kTH2F, {{axisPtD}, {axisNumPvContr}}}); + registry.add("hPtCandMcGenNonPrompt", "Ds,Hadron particles non prompt - MC Gen", {HistType::kTH2F, {{axisPtD}, {axisNumPvContr}}}); + registry.add("hPtParticleAssocSpecieMcRec", "Associated Particle - MC Rec", {HistType::kTHnSparseF, {axisPtHadron}}); + registry.add("hPtPrmPionMcRec", "Primary pions - MC Rec", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtPrmKaonMcRec", "Primary kaons - MC Rec", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtPrmProtonMcRec", "Primary protons - MC Rec", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtPrmElectronMcRec", "Primary electrons - MC Rec", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtPrmMuonMcRec", "Primary muons - MC Rec", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtParticleAssocMcGen", "Associated Particle - MC Gen", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtPrmPionMcGen", "Primary pions - MC Gen", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtPrmKaonMcGen", "Primary kaons - MC Gen", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtPrmProtonMcGen", "Primary protons - MC Gen", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtPrmElectronMcGen", "Primary electrons - MC Gen", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + registry.add("hPtPrmMuonMcGen", "Primary muons - MC Gen", {HistType::kTHnSparseF, {{axisPtHadron}, {axisEta}, {axisPosZ}, {axisNumPvContr}}}); + } else { + registry.add("hPtCandMcRecPrompt", "Ds prompt candidates pt", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcRecNonPrompt", "Ds non prompt candidates pt", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcGenPrompt", "Ds,Hadron particles prompt - MC Gen", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcGenNonPrompt", "Ds,Hadron particles non prompt - MC Gen", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtParticleAssocSpecieMcRec", "Associated Particle - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmPionMcRec", "Primary pions - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmKaonMcRec", "Primary kaons - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmProtonMcRec", "Primary protons - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmElectronMcRec", "Primary electrons - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmMuonMcRec", "Primary muons - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtParticleAssocMcGen", "Associated Particle - MC Gen", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmPionMcGen", "Primary pions - MC Gen", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmKaonMcGen", "Primary kaons - MC Gen", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmProtonMcGen", "Primary protons - MC Gen", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmElectronMcGen", "Primary electrons - MC Gen", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtPrmMuonMcGen", "Primary muons - MC Gen", {HistType::kTH1F, {axisPtHadron}}); + } + } + + // Loading efficiency histograms from CCDB + if (applyEfficiency && loadAccXEffFromCCDB) { + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - auto hCandidates = registry.add("hCandidates", "Candidate count at different steps", {HistType::kStepTHnF, {axisPtD, axisMultFT0M, {RecoDecay::OriginType::NonPrompt + 1, +RecoDecay::OriginType::None - 0.5, +RecoDecay::OriginType::NonPrompt + 0.5}}, kCandidateNSteps}); - hCandidates->GetAxis(0)->SetTitle("#it{p}_{T} (GeV/#it{c})"); - hCandidates->GetAxis(1)->SetTitle("multiplicity"); - hCandidates->GetAxis(2)->SetTitle("Charm hadron origin"); - auto hAssocTracks = registry.add("hAssocTracks", "Associated tracks at different steps", {HistType::kStepTHnF, {axisEta, axisPtHadron, axisMultFT0M, axisPosZ}, kAssocTrackNSteps}); - hAssocTracks->GetAxis(0)->SetTitle("#eta"); - hAssocTracks->GetAxis(1)->SetTitle("#it{p}_{T} (GeV/#it{c})"); - hAssocTracks->GetAxis(2)->SetTitle("multiplicity"); - hAssocTracks->GetAxis(3)->SetTitle("pos z"); + hEfficiencyD = std::shared_ptr(ccdb->getForTimeStamp(promptEffCcdbPath, timestampCcdb)); + if (hEfficiencyD == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", promptEffCcdbPath.value.c_str()); + } + LOGF(info, "Loaded trigger efficiency (prompt D) histogram from %s", promptEffCcdbPath.value.c_str()); + + hEfficiencyAssociated = std::shared_ptr(ccdb->getForTimeStamp(associatedEffCcdbPath, timestampCcdb)); + if (hEfficiencyAssociated == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for associated particles from %s", associatedEffCcdbPath.value.c_str()); + } + LOGF(info, "Loaded associated efficiency histogram from %s", associatedEffCcdbPath.value.c_str()); } } + enum class EfficiencyMode { + DsOnly = 1, + DsHadronPair = 2 + }; + + bool isSelectedCandidate(const int ptBinD, const float bdtScorePrompt, const float bdtScoreBkg) + { + + return (ptBinD != -1 && bdtScorePrompt >= mlOutputPromptMin->at(ptBinD) && bdtScorePrompt <= mlOutputPromptMax->at(ptBinD) && bdtScoreBkg <= mlOutputBkg->at(ptBinD)); + } + + double getEfficiencyWeight(float ptD, std::optional ptAssoc = std::nullopt, EfficiencyMode mode = EfficiencyMode::DsOnly) + { + if (!applyEfficiency) { + return 1.; + } + + double weight = 1.; + + switch (mode) { + case EfficiencyMode::DsOnly: + if (loadAccXEffFromCCDB) { + if (hEfficiencyD->GetBinContent(hEfficiencyD->FindBin(ptD)) <= epsilon) { + LOG(fatal) << "A bin content in Ds-meson efficiency histogram is zero!"; + } + weight = 1. / hEfficiencyD->GetBinContent(hEfficiencyD->FindBin(ptD)); + } else { + if (efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)) <= epsilon) { + LOG(fatal) << "A bin content in Ds-meson efficiency vector is zero!"; + } + weight = 1. / efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)); + } + break; + case EfficiencyMode::DsHadronPair: + if (loadAccXEffFromCCDB) { + if (ptAssoc && hEfficiencyAssociated) { + if (hEfficiencyAssociated->GetBinContent(hEfficiencyAssociated->FindBin(*ptAssoc)) <= epsilon) { + LOG(fatal) << "A bin content in associated particle efficiency histogram is zero!"; + } + weight = 1. / (hEfficiencyD->GetBinContent(hEfficiencyD->FindBin(ptD)) * hEfficiencyAssociated->GetBinContent(hEfficiencyAssociated->FindBin(*ptAssoc))); + } + } else { + if (ptAssoc) { + if (efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, *ptAssoc)) <= epsilon) { + LOG(fatal) << "A bin content in associated particle efficiency vector is zero!"; + } + weight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, *ptAssoc))); + } + } + break; + default: + LOG(fatal) << "Unknown efficiency mode!"; + break; + } + + return weight; + } + void processData(DsHadronPairWithMl const& pairEntries, aod::DsCandRecoInfo const& candidates) { @@ -240,13 +367,12 @@ struct HfTaskCorrelationDsHadrons { float bdtScoreBkg = candidate.mlScoreBkg(); int ptBinD = o2::analysis::findBin(binsPtD, ptD); - if (bdtScorePrompt < mlOutputPrompt->at(ptBinD) || bdtScoreBkg > mlOutputBkg->at(ptBinD)) { + if (!isSelectedCandidate(ptBinD, bdtScorePrompt, bdtScoreBkg)) { continue; } - double efficiencyWeightD = 1.; - if (applyEfficiency) { - efficiencyWeightD = 1. / efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)); - } + + double efficiencyWeightD = getEfficiencyWeight(ptD); + registry.fill(HIST("hMassDsVsPt"), massD, ptD, efficiencyWeightD); registry.fill(HIST("hBdtScorePrompt"), bdtScorePrompt); registry.fill(HIST("hBdtScoreBkg"), bdtScoreBkg); @@ -267,16 +393,15 @@ struct HfTaskCorrelationDsHadrons { int poolBin = pairEntry.poolBin(); int ptBinD = o2::analysis::findBin(binsPtD, ptD); - if (bdtScorePrompt < mlOutputPrompt->at(ptBinD) || bdtScoreBkg > mlOutputBkg->at(ptBinD)) { + if (!isSelectedCandidate(ptBinD, bdtScorePrompt, bdtScoreBkg)) { continue; } + if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { continue; } - double efficiencyWeight = 1.; - if (applyEfficiency) { - efficiencyWeight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); - } + + double efficiencyWeight = getEfficiencyWeight(ptD, ptHadron, EfficiencyMode::DsHadronPair); // in signal region if (massD > signalRegionInner->at(ptBinD) && massD < signalRegionOuter->at(ptBinD)) { @@ -312,13 +437,12 @@ struct HfTaskCorrelationDsHadrons { int ptBinD = o2::analysis::findBin(binsPtD, ptD); bool isDsPrompt = candidate.isPrompt(); - if (bdtScorePrompt < mlOutputPrompt->at(ptBinD) || bdtScoreBkg > mlOutputBkg->at(ptBinD)) { + if (!isSelectedCandidate(ptBinD, bdtScorePrompt, bdtScoreBkg)) { continue; } - double efficiencyWeightD = 1.; - if (applyEfficiency) { - efficiencyWeightD = 1. / efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)); - } + + double efficiencyWeightD = getEfficiencyWeight(ptD); + if (isDsPrompt) { registry.fill(HIST("hMassPromptDsVsPt"), massD, ptD, efficiencyWeightD); registry.fill(HIST("hBdtScorePrompt"), bdtScorePrompt); @@ -348,16 +472,16 @@ struct HfTaskCorrelationDsHadrons { int ptBinD = o2::analysis::findBin(binsPtD, ptD); bool isPhysicalPrimary = pairEntry.isPhysicalPrimary(); - if (bdtScorePrompt < mlOutputPrompt->at(ptBinD) || bdtScoreBkg > mlOutputBkg->at(ptBinD)) { + if (!isSelectedCandidate(ptBinD, bdtScorePrompt, bdtScoreBkg)) { continue; } + if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { continue; } - double efficiencyWeight = 1.; - if (applyEfficiency) { - efficiencyWeight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); - } + + double efficiencyWeight = getEfficiencyWeight(ptD, ptHadron, EfficiencyMode::DsHadronPair); + // in signal region if (massD > signalRegionInner->at(ptBinD) && massD < signalRegionOuter->at(ptBinD)) { // prompt and non-prompt division @@ -367,9 +491,9 @@ struct HfTaskCorrelationDsHadrons { registry.fill(HIST("hCorrel2DVsPtSignalRegionMcRec"), deltaPhi, deltaEta, ptD, ptHadron, statusDsPrompt, poolBin, efficiencyWeight); if (isPhysicalPrimary) { registry.fill(HIST("hCorrel2DVsPtPhysicalPrimaryMcRec"), deltaPhi, deltaEta, ptD, ptHadron, statusDsPrompt, poolBin, efficiencyWeight); - if (statusDsPrompt == 1 && statusPromptHadron == 1) { + if (statusDsPrompt == 1 && statusPromptHadron == RecoDecay::OriginType::Prompt) { registry.fill(HIST("hCorrel2DVsPtSignalRegionPromptDsPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); - } else if (statusDsPrompt == 0 && statusPromptHadron == 2) { + } else if (statusDsPrompt == 0 && statusPromptHadron == RecoDecay::OriginType::NonPrompt) { registry.fill(HIST("hCorrel2DVsPtSignalRegionNonPromptDsNonPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); } } @@ -409,12 +533,12 @@ struct HfTaskCorrelationDsHadrons { registry.fill(HIST("hDeltaPhiPtIntMcGen"), deltaPhi); if (isDsPrompt) { registry.fill(HIST("hCorrel2DVsPtMcGenPrompt"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); - if (statusPromptHadron == 1) { + if (statusPromptHadron == RecoDecay::OriginType::Prompt) { registry.fill(HIST("hCorrel2DVsPtMcGenPromptDsPromptHadron"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); } } else { registry.fill(HIST("hCorrel2DVsPtMcGenNonPrompt"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); - if (statusPromptHadron == 2) { + if (statusPromptHadron == RecoDecay::OriginType::NonPrompt) { registry.fill(HIST("hCorrel2DVsPtMcGenNonPromptDsNonPromptHadron"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); } } @@ -439,16 +563,15 @@ struct HfTaskCorrelationDsHadrons { int poolBin = pairEntry.poolBin(); int ptBinD = o2::analysis::findBin(binsPtD, ptD); - if (bdtScorePrompt < mlOutputPrompt->at(ptBinD) || bdtScoreBkg > mlOutputBkg->at(ptBinD)) { + if (!isSelectedCandidate(ptBinD, bdtScorePrompt, bdtScoreBkg)) { continue; } + if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { continue; } - double efficiencyWeight = 1.; - if (applyEfficiency) { - efficiencyWeight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); - } + + double efficiencyWeight = getEfficiencyWeight(ptD, ptHadron, EfficiencyMode::DsHadronPair); // in signal region if (massD > signalRegionInner->at(ptBinD) && massD < signalRegionOuter->at(ptBinD)) { @@ -484,10 +607,7 @@ struct HfTaskCorrelationDsHadrons { int poolBin = pairEntry.poolBin(); int ptBinD = o2::analysis::findBin(binsPtD, ptD); - double efficiencyWeight = 1.; - if (applyEfficiency) { - efficiencyWeight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); - } + double efficiencyWeight = getEfficiencyWeight(ptD, ptHadron, EfficiencyMode::DsHadronPair); // in signal region if (massD > signalRegionInner->at(ptBinD) && massD < signalRegionOuter->at(ptBinD)) { @@ -532,16 +652,16 @@ struct HfTaskCorrelationDsHadrons { int ptBinD = o2::analysis::findBin(binsPtD, ptD); bool isPhysicalPrimary = pairEntry.isPhysicalPrimary(); - if (bdtScorePrompt < mlOutputPrompt->at(ptBinD) || bdtScoreBkg > mlOutputBkg->at(ptBinD)) { + if (!isSelectedCandidate(ptBinD, bdtScorePrompt, bdtScoreBkg)) { continue; } + if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { continue; } - double efficiencyWeight = 1.; - if (applyEfficiency) { - efficiencyWeight = 1. / (efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, ptD)) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); - } + + double efficiencyWeight = getEfficiencyWeight(ptD, ptHadron, EfficiencyMode::DsHadronPair); + // in signal region if (massD > signalRegionInner->at(ptBinD) && massD < signalRegionOuter->at(ptBinD)) { // prompt and non-prompt division @@ -551,9 +671,9 @@ struct HfTaskCorrelationDsHadrons { registry.fill(HIST("hCorrel2DVsPtSignalRegionMcRec"), deltaPhi, deltaEta, ptD, ptHadron, statusDsPrompt, poolBin, efficiencyWeight); if (isPhysicalPrimary) { registry.fill(HIST("hCorrel2DVsPtPhysicalPrimaryMcRec"), deltaPhi, deltaEta, ptD, ptHadron, statusDsPrompt, poolBin, efficiencyWeight); - if (statusDsPrompt == 1 && statusPromptHadron == 1) { + if (statusDsPrompt == 1 && statusPromptHadron == RecoDecay::OriginType::Prompt) { registry.fill(HIST("hCorrel2DVsPtSignalRegionPromptDsPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); - } else if (statusDsPrompt == 0 && statusPromptHadron == 2) { + } else if (statusDsPrompt == 0 && statusPromptHadron == RecoDecay::OriginType::NonPrompt) { registry.fill(HIST("hCorrel2DVsPtSignalRegionNonPromptDsNonPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); } } @@ -582,8 +702,6 @@ struct HfTaskCorrelationDsHadrons { CandDsMcReco const& candidates, aod::TracksWMc const&) { - auto hCandidates = registry.get(HIST("hCandidates")); - /// loop over generated collisions for (const auto& mcCollision : mcCollisions) { @@ -615,38 +733,43 @@ struct HfTaskCorrelationDsHadrons { continue; } - float multiplicityReco = collision.multFT0M(); - float multiplicityGen = mcCollision.multMCFT0A() + mcCollision.multMCFT0C(); // multFT0M = multFt0A + multFT0C + registry.fill(HIST("hNumPvContrib"), collision.numContrib()); const auto groupedCandidates = candidates.sliceBy(perCollisionCand, collision.globalIndex()); // generated candidate loop for (const auto& mcParticle : groupedMcParticles) { - if ((std::abs(mcParticle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (mcParticle.flagMcDecayChanGen() == decayChannel)) { - hCandidates->Fill(kCandidateStepMcGenDsToKKPi, mcParticle.pt(), multiplicityGen, mcParticle.originMcGen()); + if ((std::abs(mcParticle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && (mcParticle.flagMcDecayChanGen() == channelsResonant[decayChannel])) { auto yDs = RecoDecay::y(mcParticle.pVector(), o2::constants::physics::MassDS); if (std::abs(yDs) <= yCandGenMax) { - hCandidates->Fill(kCandidateStepMcCandInAcceptance, mcParticle.pt(), multiplicityGen, mcParticle.originMcGen()); if (mcParticle.originMcGen() == RecoDecay::OriginType::Prompt) { - registry.fill(HIST("hPtCandMcGenPrompt"), mcParticle.pt()); + if (useHighDimHistoForEff) { + registry.fill(HIST("hPtCandMcGenPrompt"), mcParticle.pt(), collision.numContrib()); + } else { + registry.fill(HIST("hPtCandMcGenPrompt"), mcParticle.pt()); + } } if (mcParticle.originMcGen() == RecoDecay::OriginType::NonPrompt) { - registry.fill(HIST("hPtCandMcGenNonPrompt"), mcParticle.pt()); + if (useHighDimHistoForEff) { + registry.fill(HIST("hPtCandMcGenNonPrompt"), mcParticle.pt(), collision.numContrib()); + } else { + registry.fill(HIST("hPtCandMcGenNonPrompt"), mcParticle.pt()); + } } - } - bool isDaughterInAcceptance = true; - auto daughters = mcParticle.template daughters_as(); - for (const auto& daughter : daughters) { - if (daughter.pt() < ptDaughterMin || std::abs(daughter.eta()) > etaTrackMax) { - isDaughterInAcceptance = false; + + bool isDaughterInAcceptance = true; + auto daughters = mcParticle.template daughters_as(); + for (const auto& daughter : daughters) { + if (daughter.pt() < ptDaughterMin || std::abs(daughter.eta()) > etaTrackMax) { + isDaughterInAcceptance = false; + } + } + if (isDaughterInAcceptance) { + registry.fill(HIST("hPtCandMcGenDaughterInAcc"), mcParticle.pt()); } - } - if (isDaughterInAcceptance) { - hCandidates->Fill(kCandidateStepMcDaughtersInAcceptance, mcParticle.pt(), multiplicityGen, mcParticle.originMcGen()); - registry.fill(HIST("hPtCandMcGenDaughterInAcc"), mcParticle.pt()); } } - } + } // end loop candidate gen // reconstructed candidate loop for (const auto& candidate : groupedCandidates) { @@ -663,30 +786,35 @@ struct HfTaskCorrelationDsHadrons { outputMl[iclass] = candidate.mlProbDsToPiKK()[classMl->at(iclass)]; } } - if (outputMl[0] < mlOutputPrompt->at(o2::analysis::findBin(binsPtD, candidate.pt())) || outputMl[2] > mlOutputBkg->at(o2::analysis::findBin(binsPtD, candidate.pt()))) { + if (outputMl[0] < mlOutputPromptMin->at(o2::analysis::findBin(binsPtD, candidate.pt())) || outputMl[0] > mlOutputPromptMax->at(o2::analysis::findBin(binsPtD, candidate.pt())) || outputMl[2] > mlOutputBkg->at(o2::analysis::findBin(binsPtD, candidate.pt()))) { continue; } - if ((std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (candidate.flagMcDecayChanRec() == decayChannel)) { + if ((std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && (candidate.flagMcDecayChanRec() == channelsResonant[decayChannel])) { auto prong0McPart = candidate.template prong0_as().template mcParticle_as(); // DsToKKPi and DsToPiKK division if (((std::abs(prong0McPart.pdgCode()) == kKPlus) && (candidate.isSelDsToKKPi() >= selectionFlagDs)) || ((std::abs(prong0McPart.pdgCode()) == kPiPlus) && (candidate.isSelDsToPiKK() >= selectionFlagDs))) { - hCandidates->Fill(kCandidateStepMcReco, candidate.pt(), multiplicityReco, candidate.originMcRec()); if (std::abs(hfHelper.yDs(candidate)) <= yCandMax) { - hCandidates->Fill(kCandidateStepMcRecoInAcceptance, candidate.pt(), multiplicityReco, candidate.originMcRec()); if (candidate.originMcRec() == RecoDecay::OriginType::Prompt) { - registry.fill(HIST("hPtCandMcRecPrompt"), candidate.pt()); + if (useHighDimHistoForEff) { + registry.fill(HIST("hPtCandMcRecPrompt"), candidate.pt(), collision.numContrib()); + } else { + registry.fill(HIST("hPtCandMcRecPrompt"), candidate.pt()); + } } if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { - registry.fill(HIST("hPtCandMcRecNonPrompt"), candidate.pt()); + if (useHighDimHistoForEff) { + registry.fill(HIST("hPtCandMcRecNonPrompt"), candidate.pt(), collision.numContrib()); + } else { + registry.fill(HIST("hPtCandMcRecNonPrompt"), candidate.pt()); + } } } } } - } - + } // end loop candidate reco } // end loop reconstructed collision - } // end loop generated collisions + } // end loop generated collisions } PROCESS_SWITCH(HfTaskCorrelationDsHadrons, processMcCandEfficiency, "Process MC for calculating candidate reconstruction efficiency", false); @@ -696,19 +824,12 @@ struct HfTaskCorrelationDsHadrons { CandDsMcReco const& candidates, aod::TracksWMc const&) { - auto hCandidates = registry.get(HIST("hCandidates")); - /// Gen loop - float multiplicity = -1.; for (const auto& mcParticle : mcParticles) { // generated candidates - if ((std::abs(mcParticle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (mcParticle.flagMcDecayChanGen() == decayChannel)) { - auto mcCollision = mcParticle.template mcCollision_as>(); - multiplicity = mcCollision.multMCFT0A() + mcCollision.multMCFT0C(); // multFT0M = multFt0A + multFT0C - hCandidates->Fill(kCandidateStepMcGenDsToKKPi, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); + if ((std::abs(mcParticle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && (mcParticle.flagMcDecayChanGen() == channelsResonant[decayChannel])) { auto yDs = RecoDecay::y(mcParticle.pVector(), o2::constants::physics::MassDS); if (std::abs(yDs) <= yCandGenMax) { - hCandidates->Fill(kCandidateStepMcCandInAcceptance, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); if (mcParticle.originMcGen() == RecoDecay::OriginType::Prompt) { registry.fill(HIST("hPtCandMcGenPrompt"), mcParticle.pt()); } @@ -724,7 +845,6 @@ struct HfTaskCorrelationDsHadrons { } } if (isDaughterInAcceptance) { - hCandidates->Fill(kCandidateStepMcDaughtersInAcceptance, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); registry.fill(HIST("hPtCandMcGenDaughterInAcc"), mcParticle.pt()); } } @@ -745,21 +865,18 @@ struct HfTaskCorrelationDsHadrons { outputMl[iclass] = candidate.mlProbDsToPiKK()[classMl->at(iclass)]; } } - if (outputMl[0] < mlOutputPrompt->at(o2::analysis::findBin(binsPtD, candidate.pt())) || outputMl[2] > mlOutputBkg->at(o2::analysis::findBin(binsPtD, candidate.pt()))) { + if (outputMl[0] < mlOutputPromptMin->at(o2::analysis::findBin(binsPtD, candidate.pt())) || outputMl[0] > mlOutputPromptMax->at(o2::analysis::findBin(binsPtD, candidate.pt())) || outputMl[2] > mlOutputBkg->at(o2::analysis::findBin(binsPtD, candidate.pt()))) { continue; } auto collision = candidate.template collision_as>(); if (selNoSameBunchPileUpColl && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { continue; } - multiplicity = collision.multFT0M(); - if ((std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (candidate.flagMcDecayChanRec() == decayChannel)) { + if ((std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && (candidate.flagMcDecayChanRec() == channelsResonant[decayChannel])) { auto prong0McPart = candidate.template prong0_as().template mcParticle_as(); // DsToKKPi and DsToPiKK division if (((std::abs(prong0McPart.pdgCode()) == kKPlus) && (candidate.isSelDsToKKPi() >= selectionFlagDs)) || ((std::abs(prong0McPart.pdgCode()) == kPiPlus) && (candidate.isSelDsToPiKK() >= selectionFlagDs))) { - hCandidates->Fill(kCandidateStepMcReco, candidate.pt(), multiplicity, candidate.originMcRec()); if (std::abs(hfHelper.yDs(candidate)) <= yCandMax) { - hCandidates->Fill(kCandidateStepMcRecoInAcceptance, candidate.pt(), multiplicity, candidate.originMcRec()); if (candidate.originMcRec() == RecoDecay::OriginType::Prompt) { registry.fill(HIST("hPtCandMcRecPrompt"), candidate.pt()); } @@ -779,7 +896,6 @@ struct HfTaskCorrelationDsHadrons { aod::McParticles const& mcParticles, TracksWithMc const& tracksData) { - auto hAssocTracks = registry.get(HIST("hAssocTracks")); /// loop over generated collisions for (const auto& mcCollision : mcCollisions) { @@ -812,37 +928,47 @@ struct HfTaskCorrelationDsHadrons { continue; } - float multiplicityReco = collision.multFT0M(); - float posZReco = collision.posZ(); - float multiplicityGen = mcCollision.multMCFT0A() + mcCollision.multMCFT0C(); // multFT0M = multFt0A + multFT0C - float posZGen = mcCollision.posZ(); - const auto groupedTracks = tracksData.sliceBy(perCollision, collision.globalIndex()); // generated track loop for (const auto& mcParticle : groupedMcParticles) { if (mcParticle.isPhysicalPrimary() && ((std::abs(mcParticle.pdgCode()) == kElectron) || (std::abs(mcParticle.pdgCode()) == kMuonMinus) || (std::abs(mcParticle.pdgCode()) == kPiPlus) || (std::abs(mcParticle.pdgCode()) == kKPlus) || (std::abs(mcParticle.pdgCode()) == kProton))) { if (mcParticle.pt() > ptTrackMin && mcParticle.pt() < ptTrackMax) { - hAssocTracks->Fill(kAssocTrackStepMcGen, mcParticle.eta(), mcParticle.pt(), multiplicityGen, posZGen); if (std::abs(mcParticle.eta()) < etaTrackMax) { - hAssocTracks->Fill(kAssocTrackStepMcGenInAcceptance, mcParticle.eta(), mcParticle.pt(), multiplicityGen, posZGen); - registry.fill(HIST("hPtParticleAssocMcGen"), mcParticle.pt()); - if (std::abs(mcParticle.pdgCode()) == kPiPlus) { - registry.fill(HIST("hPtPrmPionMcGen"), mcParticle.pt()); - } else if (std::abs(mcParticle.pdgCode()) == kKPlus) { - registry.fill(HIST("hPtPrmKaonMcGen"), mcParticle.pt()); - } else if (std::abs(mcParticle.pdgCode()) == kProton) { - registry.fill(HIST("hPtPrmProtonMcGen"), mcParticle.pt()); - } else if (std::abs(mcParticle.pdgCode()) == kElectron) { - registry.fill(HIST("hPtPrmElectronMcGen"), mcParticle.pt()); - } else if (std::abs(mcParticle.pdgCode()) == kMuonMinus) { - registry.fill(HIST("hPtPrmMuonMcGen"), mcParticle.pt()); + if (useHighDimHistoForEff) { + registry.fill(HIST("hPtParticleAssocMcGen"), mcParticle.pt(), mcParticle.eta(), collision.posZ(), collision.numContrib()); + if (std::abs(mcParticle.pdgCode()) == kPiPlus) { + registry.fill(HIST("hPtPrmPionMcGen"), mcParticle.pt(), mcParticle.eta(), collision.posZ(), collision.numContrib()); + } else if (std::abs(mcParticle.pdgCode()) == kKPlus) { + registry.fill(HIST("hPtPrmKaonMcGen"), mcParticle.pt(), mcParticle.eta(), collision.posZ(), collision.numContrib()); + } else if (std::abs(mcParticle.pdgCode()) == kProton) { + registry.fill(HIST("hPtPrmProtonMcGen"), mcParticle.pt(), mcParticle.eta(), collision.posZ(), collision.numContrib()); + } else if (std::abs(mcParticle.pdgCode()) == kElectron) { + registry.fill(HIST("hPtPrmElectronMcGen"), mcParticle.pt(), mcParticle.eta(), collision.posZ(), collision.numContrib()); + } else if (std::abs(mcParticle.pdgCode()) == kMuonMinus) { + registry.fill(HIST("hPtPrmMuonMcGen"), mcParticle.pt(), mcParticle.eta(), collision.posZ(), collision.numContrib()); + } + } else { + registry.fill(HIST("hPtParticleAssocMcGen"), mcParticle.pt()); + if (std::abs(mcParticle.pdgCode()) == kPiPlus) { + registry.fill(HIST("hPtPrmPionMcGen"), mcParticle.pt()); + } else if (std::abs(mcParticle.pdgCode()) == kKPlus) { + registry.fill(HIST("hPtPrmKaonMcGen"), mcParticle.pt()); + } else if (std::abs(mcParticle.pdgCode()) == kProton) { + registry.fill(HIST("hPtPrmProtonMcGen"), mcParticle.pt()); + } else if (std::abs(mcParticle.pdgCode()) == kElectron) { + registry.fill(HIST("hPtPrmElectronMcGen"), mcParticle.pt()); + } else if (std::abs(mcParticle.pdgCode()) == kMuonMinus) { + registry.fill(HIST("hPtPrmMuonMcGen"), mcParticle.pt()); + } } - int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); - if (trackOrigin == 1) { // charm orgin - registry.fill(HIST("hPtPrmPromptPartMcGen"), mcParticle.pt()); - } else if (trackOrigin == 2) { // beauty origin - registry.fill(HIST("hPtPrmNonPromptPartMcGen"), mcParticle.pt()); + if (separateTrackOrigins) { + int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); + if (trackOrigin == RecoDecay::OriginType::Prompt) { // charm orgin + registry.fill(HIST("hPtPrmPromptPartMcGen"), mcParticle.pt()); + } else if (trackOrigin == RecoDecay::OriginType::NonPrompt) { // beauty origin + registry.fill(HIST("hPtPrmNonPromptPartMcGen"), mcParticle.pt()); + } } } } @@ -851,37 +977,51 @@ struct HfTaskCorrelationDsHadrons { // reconstructed track loop for (const auto& track : groupedTracks) { - if (!track.isGlobalTrackWoDCA()) { + if (!track.isGlobalTrackWoDCA() || track.tpcNClsCrossedRows() < nTpcCrossedRaws) { continue; } if (track.has_mcParticle()) { - hAssocTracks->Fill(kAssocTrackStepRecoMcMatch, track.eta(), track.pt(), multiplicityReco, posZReco); auto mcParticle = track.template mcParticle_as(); if (mcParticle.isPhysicalPrimary()) { - hAssocTracks->Fill(kAssocTrackStepRecoPrimaries, track.eta(), track.pt(), multiplicityReco, posZReco); registry.fill(HIST("hPtParticleAssocMcRec"), track.pt()); if ((std::abs(mcParticle.pdgCode()) == kElectron) || (std::abs(mcParticle.pdgCode()) == kMuonMinus) || (std::abs(mcParticle.pdgCode()) == kPiPlus) || (std::abs(mcParticle.pdgCode()) == kKPlus) || (std::abs(mcParticle.pdgCode()) == kProton)) { - hAssocTracks->Fill(kAssocTrackStepRecoSpecies, track.eta(), track.pt(), multiplicityReco, posZReco); - registry.fill(HIST("hPtParticleAssocSpecieMcRec"), track.pt()); // check the pt spectra of mcParticle registry.fill(HIST("hPtMcParticleAssocSpecieMcRec"), mcParticle.pt()); - if (std::abs(mcParticle.pdgCode()) == kPiPlus) { - registry.fill(HIST("hPtPrmPionMcRec"), track.pt()); - } else if (std::abs(mcParticle.pdgCode()) == kKPlus) { - registry.fill(HIST("hPtPrmKaonMcRec"), track.pt()); - } else if (std::abs(mcParticle.pdgCode()) == kProton) { - registry.fill(HIST("hPtPrmProtonMcRec"), track.pt()); - } else if (std::abs(mcParticle.pdgCode()) == kElectron) { - registry.fill(HIST("hPtPrmElectronMcRec"), track.pt()); - } else if (std::abs(mcParticle.pdgCode()) == kMuonMinus) { - registry.fill(HIST("hPtPrmMuonMcRec"), track.pt()); + if (useHighDimHistoForEff) { + registry.fill(HIST("hPtParticleAssocSpecieMcRec"), track.pt()); + if (std::abs(mcParticle.pdgCode()) == kPiPlus) { + registry.fill(HIST("hPtPrmPionMcRec"), track.pt(), track.eta(), collision.posZ(), collision.numContrib()); + } else if (std::abs(mcParticle.pdgCode()) == kKPlus) { + registry.fill(HIST("hPtPrmKaonMcRec"), track.pt(), track.eta(), collision.posZ(), collision.numContrib()); + } else if (std::abs(mcParticle.pdgCode()) == kProton) { + registry.fill(HIST("hPtPrmProtonMcRec"), track.pt(), track.eta(), collision.posZ(), collision.numContrib()); + } else if (std::abs(mcParticle.pdgCode()) == kElectron) { + registry.fill(HIST("hPtPrmElectronMcRec"), track.pt(), track.eta(), collision.posZ(), collision.numContrib()); + } else if (std::abs(mcParticle.pdgCode()) == kMuonMinus) { + registry.fill(HIST("hPtPrmMuonMcRec"), track.pt(), track.eta(), collision.posZ(), collision.numContrib()); + } + } else { + registry.fill(HIST("hPtParticleAssocSpecieMcRec"), track.pt()); + if (std::abs(mcParticle.pdgCode()) == kPiPlus) { + registry.fill(HIST("hPtPrmPionMcRec"), track.pt()); + } else if (std::abs(mcParticle.pdgCode()) == kKPlus) { + registry.fill(HIST("hPtPrmKaonMcRec"), track.pt()); + } else if (std::abs(mcParticle.pdgCode()) == kProton) { + registry.fill(HIST("hPtPrmProtonMcRec"), track.pt()); + } else if (std::abs(mcParticle.pdgCode()) == kElectron) { + registry.fill(HIST("hPtPrmElectronMcRec"), track.pt()); + } else if (std::abs(mcParticle.pdgCode()) == kMuonMinus) { + registry.fill(HIST("hPtPrmMuonMcRec"), track.pt()); + } } // check track origin - int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); - if (trackOrigin == 1) { // charm orgin - registry.fill(HIST("hPtPrmPromptPartMcRec"), track.pt()); - } else if (trackOrigin == 2) { // beauty origin - registry.fill(HIST("hPtPrmNonPromptPartMcRec"), track.pt()); + if (separateTrackOrigins) { + int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); + if (trackOrigin == RecoDecay::OriginType::Prompt) { // charm orgin + registry.fill(HIST("hPtPrmPromptPartMcRec"), track.pt()); + } else if (trackOrigin == RecoDecay::OriginType::NonPrompt) { // beauty origin + registry.fill(HIST("hPtPrmNonPromptPartMcRec"), track.pt()); + } } } } @@ -892,7 +1032,7 @@ struct HfTaskCorrelationDsHadrons { } } // end loop reconstructed collision - } // end loop generated collisions + } // end loop generated collisions } PROCESS_SWITCH(HfTaskCorrelationDsHadrons, processMcTrackEfficiency, "Process MC for calculating associated particle tracking efficiency", false); }; diff --git a/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx index 609f213ae3a..eb450cc7e61 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationDstarHadrons.cxx @@ -14,16 +14,23 @@ /// \author Fabrizio Grosa , CERN /// \author Shyam Kumar -// Framework -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -// PWGHF #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -61,7 +68,7 @@ auto vecSidebandRightInnerDefault = std::vector{sidebandRightInnerDefaul const double sidebandRightOuterDefault[nBinsPtCorrelation] = {0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154, 0.154}; auto vecSidebandRightOuterDefault = std::vector{sidebandRightOuterDefault, sidebandRightOuterDefault + nBinsPtCorrelation}; -const int npTBinsEfficiency = o2::analysis::hf_cuts_dstar_to_d0_pi::nBinsPt; +const int npTBinsEfficiency = o2::analysis::hf_cuts_dstar_to_d0_pi::NBinsPt; std::vector vecEfficiencyDstarDefault(npTBinsEfficiency); // line # 76 in taskCorrelationDstarHadron.cxx; why (npTBinsEfficiency+1) ? // Dstar-Hadron correlation pair diff --git a/PWGHF/HFC/Tasks/taskCorrelationHfeHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationHfeHadrons.cxx index 5f63948b769..00202c55122 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationHfeHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationHfeHadrons.cxx @@ -14,13 +14,16 @@ /// \author Rashi Gupta , IIT Indore /// \author Ravindra Singh , IIT Indore -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/RecoDecay.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -31,15 +34,25 @@ struct HfTaskCorrelationHfeHadrons { // Deltaphi binning Configurable nBinsDeltaPhi{"nBinsDeltaPhi", 32, "Bins for #Delta#varphi bins"}; - HistogramConfigSpec hCorrelSpec{HistType::kTHnSparseD, {{30, 0., 30.}, {20, 0., 20.}, {nBinsDeltaPhi, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, {50, -1.8, 1.8}}}; + ConfigurableAxis binsDeltaEta{"binsDeltaEta", {30, -1.8, 1.8}, "#it{#Delta#eta}"}; + ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {32, -o2::constants::math::PIHalf, 3. * o2::constants::math::PIHalf}, "#it{#Delta#varphi}"}; + ConfigurableAxis binsPt{"binsPt", {50, 0.0, 50}, "#it{p_{T}}(GeV/#it{c})"}; HistogramRegistry registry{ "registry", - {{"hInclusiveEHCorrel", "Sparse for Delta phi and Delta eta Hadron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", hCorrelSpec}}}; + {}}; void init(InitContext&) { - registry.get(HIST("hInclusiveEHCorrel"))->Sumw2(); + AxisSpec axisDeltaEta = {binsDeltaEta, "#Delta #eta = #eta_{Electron}- #eta_{Hadron}"}; + AxisSpec axisDeltaPhi = {binsDeltaPhi, "#Delta #varphi = #varphi_{Electron}- #varphi_{Hadron}"}; + AxisSpec axisPt = {binsPt, "#it{p_{T}}(GeV/#it{c})"}; + + registry.add("hInclusiveEHCorrel", "Sparse for Delta phi and Delta eta Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hLikeSignEHCorrel", "Sparse for Delta phi and Delta eta Like sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hUnLikeSignEHCorrel", "Sparse for Delta phi and Delta eta UnLike sign Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hMcGenInclusiveEHCorrel", "Sparse for Delta phi and Delta eta for McGen Inclusive Electron with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hMcGenNonHfEHCorrel", "Sparse for Delta phi and Delta eta for McGen NonHeavy flavour Electron pair with Hadron;p_{T}^{e} (GeV#it{/c});p_{T}^{h} (GeV#it{/c});#Delta#varphi;#Delta#eta;", {HistType::kTHnSparseF, {{axisPt}, {axisPt}, {axisDeltaPhi}, {axisDeltaEta}}}); } // correlation for electron hadron @@ -58,8 +71,45 @@ struct HfTaskCorrelationHfeHadrons { ptHadron = pairEntry.ptHadron(); registry.fill(HIST("hInclusiveEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); + if (pairEntry.nPairsLS() > 0) { + for (int i = 0; i < pairEntry.nPairsLS(); ++i) { + + registry.fill(HIST("hLikeSignEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); + } + } + if (pairEntry.nPairsUS() > 0) { + for (int i = 0; i < pairEntry.nPairsLS(); ++i) { + + registry.fill(HIST("hUnlikeSignEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); + } + } + } + } + + PROCESS_SWITCH(HfTaskCorrelationHfeHadrons, process, "Process ", false); + + void processMcGen(aod::HfEHadronMcPair const& McGenpairEntries) + { + double deltaPhi = -999; + double deltaEta = -999; + double ptHadron = -999; + double ptElectron = -999; + + for (const auto& pairEntry : McGenpairEntries) { + + deltaPhi = pairEntry.deltaPhi(); + deltaEta = pairEntry.deltaEta(); + ptElectron = pairEntry.ptElectron(); + ptHadron = pairEntry.ptHadron(); + + registry.fill(HIST("hMcGenInclusiveEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); + if (pairEntry.isNonHfEHCorr()) { + + registry.fill(HIST("hMcGenNonHfEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); + } } } + PROCESS_SWITCH(HfTaskCorrelationHfeHadrons, processMcGen, "Process for Mc Gen ", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/HFC/Tasks/taskCorrelationLcHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationLcHadrons.cxx index ede013d1f22..84386ab9794 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationLcHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationLcHadrons.cxx @@ -14,20 +14,49 @@ /// \author Marianna Mazzilli /// \author Zhen Zhang -#include // std::shared_ptr -#include -#include -#include "CCDB/BasicCCDBManager.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsAnalysis.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" #include "PWGHF/HFC/Utils/utilsCorrelations.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include // std::shared_ptr +#include +#include using namespace o2; using namespace o2::constants::math; @@ -661,7 +690,7 @@ struct HfTaskCorrelationLcHadrons { if (fillSign) { registry.fill(HIST("hCorrel2DVsPtSignSignalRegionMcRec"), deltaPhi, deltaEta, ptLc, ptHadron, signPair, poolBin, efficiencyWeight); } else { - registry.fill(HIST("hCorrel2DVsPtSignalRegionMcRec"), deltaPhi, deltaEta, ptLc, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtSignalRegionMcRec"), deltaPhi, deltaEta, ptLc, ptHadron, statusLcPrompt, poolBin, efficiencyWeight); } registry.fill(HIST("hCorrel2DPtIntSignalRegionMcRec"), deltaPhi, deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaEtaPtIntSignalRegionMcRec"), deltaEta, efficiencyWeight); @@ -809,7 +838,7 @@ struct HfTaskCorrelationLcHadrons { auto mcCollision = mcParticle.template mcCollision_as>(); multiplicity = mcCollision.multMCFT0A() + mcCollision.multMCFT0C(); // multFT0M = multFt0A + multFT0C hCandidates->Fill(kCandidateStepMcGenAll, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); - if (std::abs(mcParticle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(mcParticle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { hCandidates->Fill(kCandidateStepMcGenLcToPKPi, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); auto yL = RecoDecay::y(mcParticle.pVector(), o2::constants::physics::MassLambdaCPlus); if (std::abs(yL) <= yCandGenMax) { @@ -860,7 +889,7 @@ struct HfTaskCorrelationLcHadrons { continue; } multiplicity = collision.multFT0M(); - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { hCandidates->Fill(kCandidateStepMcReco, candidate.pt(), multiplicity, candidate.originMcRec()); if (std::abs(hfHelper.yLc(candidate)) <= yCandMax) { hCandidates->Fill(kCandidateStepMcRecoInAcceptance, candidate.pt(), multiplicity, candidate.originMcRec()); diff --git a/PWGHF/HFC/Tasks/taskFlow.cxx b/PWGHF/HFC/Tasks/taskFlow.cxx index fd87b1c5fe0..6f6870c49fc 100644 --- a/PWGHF/HFC/Tasks/taskFlow.cxx +++ b/PWGHF/HFC/Tasks/taskFlow.cxx @@ -15,40 +15,50 @@ /// \author Katarina Krizkova Gajdosova , CERN /// \author Maja Kabus , CERN -#include -#include - -#include -#include -#include - -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/Logger.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/StepTHn.h" -#include "ReconstructionDataFormats/GlobalTrackID.h" +#include "PWGCF/Core/CorrelationContainer.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsPid.h" +#include "PWGMM/Mult/DataModel/bestCollisionTable.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/McCollisionExtra.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "CommonConstants/MathConstants.h" -#include "PWGCF/Core/CorrelationContainer.h" -#include "PWGCF/Core/PairCuts.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "PWGHF/Core/HfHelper.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; +using namespace o2::aod::pid_tpc_tof_utils; using namespace o2::constants::math; using namespace o2::framework; using namespace o2::framework::expressions; @@ -56,6 +66,9 @@ using namespace o2::framework::expressions; struct HfTaskFlow { // configurables for processing options + + Configurable centralityBinsForMc{"centralityBinsForMc", false, "false = OFF, true = ON for data like multiplicity/centrality bins for MC steps"}; + Configurable mftMaxDCAxy{"mftMaxDCAxy", 2.0f, "Cut on dcaXY for MFT tracks"}; Configurable doReferenceFlow{"doReferenceFlow", false, "Flag to know if reference flow should be done"}; Configurable processRun2{"processRun2", false, "Flag to run on Run 2 data"}; Configurable processRun3{"processRun3", true, "Flag to run on Run 3 data"}; @@ -63,25 +76,28 @@ struct HfTaskFlow { Configurable nMixedEvents{"nMixedEvents", 5, "Number of mixed events per event"}; // configurables for collisions Configurable zVertexMax{"zVertexMax", 7.0f, "Accepted z-vertex range"}; - // configurables for associated particles - Configurable etaTrackAssocMax{"etaTrackAssocMax", 0.8f, "max. eta of associated tracks"}; - Configurable ptTrackAssocMin{"ptTrackAssocMin", 0.5f, "min. pT of associated tracks"}; + // configurables for TPC tracks + Configurable etaTpcTrackMax{"etaTpcTrackMax", 0.8f, "max. eta of TPC tracks"}; + Configurable ptTpcTrackMin{"ptTpcTrackMin", 0.5f, "min. pT of TPC tracks"}; // configurables for HF candidates Configurable etaCandidateMax{"etaCandidateMax", 0.8f, "max. eta of HF candidate"}; - Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; - Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection Flag for D0bar"}; - Configurable selectionFlagLcToPKPi{"selectionFlagLcToPKPi", 1, "Selection Flag for LambdaC"}; - Configurable selectionFlagLcToPiKP{"selectionFlagLcToPiKP", 1, "Selection Flag for LambdaC bar"}; - Configurable yCandMax{"yCandMax", -1., "max. cand. rapidity"}; - Configurable> binsPt{"binsPt", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"}; - // configurables for MFT tracks - Configurable etaMftTrackMax{"etaMftTrackMax", 0, "Maximum value for the eta of MFT tracks"}; - Configurable etaMftTrackMin{"etaMftTrackMin", -5, "Minimum value for the eta of MFT tracks"}; + Configurable selectionFlagHf{"selectionFlagHf", 1, "Selection Flag for Hf candidates"}; + // Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; + // Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection Flag for D0bar"}; + // Configurable selectionFlagLcToPKPi{"selectionFlagLcToPKPi", 1, "Selection Flag for LambdaC"}; + // Configurable selectionFlagLcToPiKP{"selectionFlagLcToPiKP", 1, "Selection Flag for LambdaC bar"}; + // configurables for MFT tracks + Configurable etaMftTrackMax{"etaMftTrackMax", -2.4f, "Maximum value for the eta of MFT tracks"}; + Configurable etaMftTrackMin{"etaMftTrackMin", -3.36f, "Minimum value for the eta of MFT tracks"}; + Configurable> mcTriggerPdgs{"mcTriggerPdgs", {421, -421}, "MC PDG codes to use exclusively as trigger particles. D0= +-421, Lc = +-4122"}; Configurable nClustersMftTrack{"nClustersMftTrack", 5, "Minimum number of clusters for the reconstruction of MFT tracks"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; - Service pdg; HfHelper hfHelper; SliceCache cache; + Service pdg; + std::vector hfIndexCache; // ========================= // using declarations : DATA @@ -90,23 +106,28 @@ struct HfTaskFlow { using FilteredCollisionsWSelMult = soa::Filtered>; using HfCandidatesSelD0 = soa::Filtered>; using HfCandidatesSelLc = soa::Filtered>; - using TracksWDcaSel = soa::Filtered>; + // using FilteredMftTracksWColls = soa::Filtered>; + using FilteredMftTracksWColls = soa::Filtered; + using FilteredTracksWDcaSel = soa::Filtered>; // ========================= - // using declarations : MC + // using declarations : MONTE CARLO // ========================= // Even add McCollisions in the join ? // Kata adds subscribes to it but do not add it in the join - // using FilteredCollisionsWSelMultMC = soa::Filtered>; - using FilteredCollisionsWSelMultMC = soa::Filtered>; - using FilteredMcCollisions = soa::Filtered; - using FilteredMcParticles = soa::Filtered; - using TracksWDcaSelMC = soa::Filtered>; - - // Remnants, need Katarina's info - // using FilteredCollisionsWDcaSelMcLabels = soa::Filtered>; - // using FilteredTracksWDcaSelMcLabels = soa::Filtered>; + // using FilteredCollisionsWSelMultMcLabels = soa::Filtered>; + + using FilteredCollisionsWSelMultMcLabels = soa::Filtered>; + using FilteredMcCollisions = soa::Filtered>; + using HfCandidatesSelD0McRec = soa::Join; + using HfCandidatesSelLcMcRec = soa::Join; + using McParticles = aod::McParticles; + using McParticles2ProngMatched = soa::Join; + using McParticles3ProngMatched = soa::Join; + // using FilteredMftTracksWCollsMcLabels = soa::Filtered>; + using FilteredMftTracksWCollsMcLabels = soa::Filtered>; + using FilteredTracksWDcaSelMC = soa::Filtered>; // ========================= // Filters & partitions : DATA @@ -114,76 +135,99 @@ struct HfTaskFlow { // HF candidate filter // TODO: use Partition instead of filter - Filter candidateFilterD0 = (aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0) || - (aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar); + Filter candidateFilterD0 = (aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagHf) || + (aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagHf); - Filter candidateFilterLc = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLcToPKPi) || - (aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLcToPiKP); + Filter candidateFilterLc = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagHf) || + (aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagHf); // Collision filters // FIXME: The filter is applied also on the candidates! Beware! Filter collisionVtxZFilter = nabs(aod::collision::posZ) < zVertexMax; - Filter trackFilter = (nabs(aod::track::eta) < etaTrackAssocMax) && - (aod::track::pt > ptTrackAssocMin) && + Filter trackFilter = (nabs(aod::track::eta) < etaTpcTrackMax) && + (aod::track::pt > ptTpcTrackMin) && requireGlobalTrackWoPtEtaInFilter(); + Filter mftTrackEtaFilter = (aod::fwdtrack::eta < etaMftTrackMax) && + (aod::fwdtrack::eta > etaMftTrackMin); + + Filter mftTrackCollisionIdFilter = (aod::fwdtrack::bestCollisionId >= 0); + + Filter mftTrackDcaFilter = (nabs(aod::fwdtrack::bestDCAXY) < mftMaxDCAxy); + // ========================= // Filters & partitions : MC // ========================= + Filter candidateFilterD0Mc = (aod::hf_sel_candidate_d0::isRecoHfFlag >= selectionFlagHf) || + (aod::hf_sel_candidate_d0::isRecoHfFlag >= selectionFlagHf); + + Filter candidateFilterLcMc = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagHf) || + (aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagHf); + // From Katarina's code, but not sure if I use it Filter mcCollisionFilter = nabs(aod::mccollision::posZ) < zVertexMax; - // From Katarina's code - Filter mcParticlesFilter = (nabs(aod::mcparticle::eta) < etaTrackAssocMax) && - (aod::mcparticle::pt > ptTrackAssocMin); //&& - //(aod::mcparticle::sign != 0) + // Filter mcParticlesFilter = (nabs(aod::mcparticle::eta) < etaTpcTrackMax) && + // (aod::mcparticle::pt > ptTpcTrackMin); + + // I didn't manage to make partitions work with my mixed event, as I am pair my tracks BEFORE looping over collisions + // I am thus not able to group tracks with sliceBy and can't use this method + // For now I am fine as I am doing only TPC-MFT correlations and using only McParticles with MFT acceptance + // However at some point I will have to use tracks from the other side (FV0, FT0-A) and I will have to do something about it + // TO-DO : either change how I do mixed event, or implement isAcceptedTpcMcParticle, isAcceptedMftMcParticle + // Partition mcParticlesMft = (aod::mcparticle::eta > etaMftTrackMin) && (aod::mcparticle::eta < etaMftTrackMax); + // Partition mcParticlesTpc = (nabs(aod::mcparticle::eta) < etaTpcTrackMax) && + // (aod::mcparticle::pt > ptTpcTrackMin); // ========================= // Preslice : DATA // ========================= - Preslice dataPerCol = aod::track::collisionId; + // Preslice dataPerCol = aod::track::collisionId; // ========================= // Preslice : MC // ========================= - Preslice mcTruthPerCol = aod::mcparticle::mcCollisionId; - // Do I have to adapt this preslice to MC ? How does it work exactly ? - // Preslice mcRecPerCol = aod::track::collisionId; + Preslice mftTracksPerCollision = aod::fwdtrack::collisionId; + // Preslice d0CandidatesPerCollision = aod::hf_cand::collisionId; + // Preslice mcPerCol = aod::mcparticle::mcCollisionId; + // PresliceUnsorted collisionsMcLabelPerMcCollision = aod::mccollisionlabel::mcCollisionId; // configurables for containers - ConfigurableAxis axisVertex{"axisVertex", {14, -7, 7}, "vertex axis for histograms"}; + // TODO: flow of HF will need to be done vs. invariant mass, in the signal and side-band regions + // either 1) add invariant mass axis or 2) define several containers for different inv. mass regions + // Note: don't forget to check inv. mass separately for D0 and D0bar candidate + ConfigurableAxis axisMass{"axisMass", {120, 1.5848, 2.1848}, "axis of invariant mass of candidates"}; + ConfigurableAxis binsMixingMultiplicity{"binsMixingMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 100.1}, "multiplicity bins for event mixing"}; + ConfigurableAxis binsMixingVertex{"binsMixingVertex", {14, -7, 7}, "vertex bins for event mixing"}; + ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"}; + ConfigurableAxis axisEtaMft{"axisEtaMft", {48, -4, -2}, "eta axis for MFT histograms"}; + ConfigurableAxis axisEtaTpc{"axisEtaTpc", {48, -1, 1}, "eta axis for TPC histograms"}; ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"}; ConfigurableAxis axisDeltaEta{"axisDeltaEta", {48, -2.4, 2.4}, "delta eta axis for histograms"}; - ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0}, "pt trigger axis for histograms"}; - ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0}, "pt associated axis for histograms"}; ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 100.1}, "multiplicity axis for histograms"}; - ConfigurableAxis axisVertexEfficiency{"axisVertexEfficiency", {10, -10, 10}, "vertex axis for efficiency histograms"}; - ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"}; + ConfigurableAxis axisPhi{"axisPhi", {72, 0, TwoPI}, "phi axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {72, 0, 36}, "pt axis for histograms"}; + ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0}, "pt associated axis for histograms"}; ConfigurableAxis axisPtEfficiency{"axisPtEfficiency", {VARIABLE_WIDTH, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0}, "pt axis for efficiency histograms"}; - // TODO: flow of HF will need to be done vs. invariant mass, in the signal and side-band regions - // either 1) add invariant mass axis or 2) define several containers for different inv. mass regions - // Note: don't forget to check inv. mass separately for D0 and D0bar candidate - ConfigurableAxis axisMass{"axisMass", {2, 1.7, 2.0}, "axis of invariant mass of HF candidates"}; + ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0}, "pt trigger axis for histograms"}; + ConfigurableAxis axisVertex{"axisVertex", {14, -7, 7}, "vertex axis for histograms"}; + ConfigurableAxis axisVertexEfficiency{"axisVertexEfficiency", {10, -10, 10}, "vertex axis for efficiency histograms"}; HistogramRegistry registry{"registry"}; // Correlation containers used for data - OutputObj sameTPCTPCChCh{"sameTPCTPCChCh"}; - OutputObj mixedTPCTPCChCh{"mixedTPCTPCChCh"}; - OutputObj sameTPCTPCHfCh{"sameTPCTPCHfCh"}; // I still keep only one Correlation Container for HF, whether is D0 or Lc - OutputObj mixedTPCTPCHfCh{"mixedTPCTPCHfCh"}; // Because only one should be run at the same time - OutputObj sameTPCMFTChCh{"sameTPCMFTChCh"}; - OutputObj mixedTPCMFTChCh{"mixedTPCMFTChCh"}; - OutputObj sameTPCMFTHfCh{"sameTPCMFTHfCh"}; // I still keep only one Correlation Container for HF, whether is D0 or Lc - OutputObj mixedTPCMFTHfCh{"mixedTPCMFTHfCh"}; // Because only one should be run at the same time + OutputObj sameEvent{"sameEvent"}; + OutputObj mixedEvent{"mixedEvent"}; + OutputObj sameEventHf{"sameEventHf"}; + OutputObj mixedEventHf{"mixedEventHf"}; // Correlation containers used for Monte-Carlo - OutputObj sameTPCTPCChChMC{"sameTPCTPCChChMC"}; - OutputObj mixedTPCTPCChChMC{"mixedTPCTPCChChMC"}; + OutputObj sameEventHfMc{"sameEventHfMc"}; + OutputObj mixedEventHfMc{"mixedEventHfMc"}; // ========================= // init() @@ -194,13 +238,12 @@ struct HfTaskFlow { // Event histograms // TO-DO : do i have to separate event histograms between DATA and MC ? // ========================= - constexpr int kNBinsEvents = 3; + constexpr int kNBinsEvents = 2; registry.add("Data/hEventCounter", "hEventCounter", {HistType::kTH1F, {{kNBinsEvents, 0.5, 0.5 + kNBinsEvents}}}); // set axes of the event counter histogram std::string labels[kNBinsEvents]; labels[0] = "all"; - labels[1] = "after trigger selection (Run 2)"; - labels[2] = "after Physics selection"; + labels[1] = "after Physics selection"; const int nBinsMix = axisMultiplicity->size() * 14; // 14 bins for z-vertex @@ -213,118 +256,68 @@ struct HfTaskFlow { // ========================= // DATA : event histograms for TPC-TPC h-h same event - registry.add("Data/TpcTpc/HadronHadron/SameEvent/hMultiplicity", "hMultiplicity", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcTpc/HadronHadron/SameEvent/hVtxZ", "hVtxZ", {HistType::kTH1F, {{400, -50, 50}}}); + registry.add("Data/TpcTpc/HadronHadron/SameEvent/hMultiplicity", "hMultiplicity", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("Data/TpcTpc/HadronHadron/SameEvent/hVtxZ", "hVtxZ", {HistType::kTH1F, {axisVertex}}); registry.add("Data/TpcTpc/HadronHadron/SameEvent/hEventCountSame", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); // DATA : associated particles histograms for TPC-TPC h-h same event - registry.add("Data/TpcTpc/HadronHadron/SameEvent/hPt", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcTpc/HadronHadron/SameEvent/hEta", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcTpc/HadronHadron/SameEvent/hPhi", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcTpc/HadronHadron/SameEvent/hYields", "multiplicity vs pT vs eta", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); - registry.add("Data/TpcTpc/HadronHadron/SameEvent/hEtaPhi", "multiplicity vs eta vs phi", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}}}); - // registry.add("Data/TpcTpc/HadronHadron/SameEvent/hNtracks", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("Data/TpcTpc/HadronHadron/SameEvent/hPt", "pT", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcTpc/HadronHadron/SameEvent/hEta", "eta", {HistType::kTH1F, {axisEtaTpc}}); + registry.add("Data/TpcTpc/HadronHadron/SameEvent/hPhi", "phi", {HistType::kTH1F, {axisPhi}}); + registry.add("Data/TpcTpc/HadronHadron/SameEvent/hYields", "multiplicity vs pT vs eta", {HistType::kTH3F, {axisMultiplicity, axisPt, axisEtaTpc}}); + registry.add("Data/TpcTpc/HadronHadron/SameEvent/hEtaPhi", "multiplicity vs eta vs phi", {HistType::kTH3F, {axisMultiplicity, axisEtaTpc, axisPhi}}); // Katarina had this : - registry.add("Data/TpcTpc/HadronHadron/SameEvent/hVzEta", "eta vs. Vz", {HistType::kTH2F, {{100, -4, 4, "#eta"}, {20, -10, 10, "Vz"}}}); + registry.add("Data/TpcTpc/HadronHadron/SameEvent/hVzEta", "eta vs. Vz", {HistType::kTH2F, {axisEtaTpc, axisVertex}}); // DATA : event mixing histograms for TPC-TPC h-h mixed event registry.add("Data/TpcTpc/HadronHadron/MixedEvent/hEventCountMixing", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); - registry.add("Data/TpcTpc/HadronHadron/MixedEvent/hMultiplicityMixing", "hMultiplicityMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcTpc/HadronHadron/MixedEvent/hVtxZMixing", "hVtxZMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("Data/TpcTpc/HadronHadron/MixedEvent/hNtracksMixing", "hNtracksMixing", {HistType::kTH1F, {{500, 0, 500}}}); - - // DATA : particles histograms for TPC-TPC h-h mixed event - registry.add("Data/TpcTpc/HadronHadron/MixedEvent/hPtMixing", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcTpc/HadronHadron/MixedEvent/hEtaMixing", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcTpc/HadronHadron/MixedEvent/hPhiMixing", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); // ========================= // DATA : histograms for TPC-TPC HF-h case for 2PRONG // ========================= // DATA : event histograms for TPC-TPC HF-h same event - registry.add("Data/TpcTpc/HfHadron/SameEvent/hPt", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/hEta", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/hPhi", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/hYields", "multiplicity vs pT vs eta", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/hEtaPhi", "multiplicity vs eta vs phi", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/hPt", "pT", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/hEta", "eta", {HistType::kTH1F, {axisEtaTpc}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/hPhi", "phi", {HistType::kTH1F, {axisPhi}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/hYields", "multiplicity vs pT vs eta", {HistType::kTH3F, {axisMultiplicity, axisPt, axisEtaTpc}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/hEtaPhi", "multiplicity vs eta vs phi", {HistType::kTH3F, {axisMultiplicity, axisEtaTpc, axisPhi}}); registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEventCountSame", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEta", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPhi", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEta", "eta", {HistType::kTH1F, {axisEtaTpc}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPhi", "phi", {HistType::kTH1F, {axisPhi}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {axisMultiplicity}}); registry.add("Data/TpcTpc/HfHadron/MixedEvent/hEventCountHFMixing", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); - registry.add("Data/TpcTpc/HfHadron/MixedEvent/hMultiplicityHFMixing", "hMultiplicityHFMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcTpc/HfHadron/MixedEvent/hVtxZHFMixing", "hVtxZHFMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("Data/TpcTpc/HfHadron/MixedEvent/hNtracksHFMixing", "hNtracksHFMixing", {HistType::kTH1F, {{500, 0, 500}}}); - - // DATA : trigger particles (candidates) histograms for TPC-TPC h-h same event - auto vbins = (std::vector)binsPt; - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtCandidate", "2-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtProng0", "2-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtProng1", "2-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMassVsPt", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{500, 0., 5.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMass", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLength", "2-prong candidates;decay length (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLengthXY", "2-prong candidates;decay length xy (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hd0Prong0", "2-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hd0Prong1", "2-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hd0d0", "2-prong candidates;product of DCAxy to prim. vertex (cm^{2});entries", {HistType::kTH2F, {{500, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hCTS", "2-prong candidates;cos #it{#theta}* (D^{0});entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hCt", "2-prong candidates;proper lifetime (D^{0}) * #it{c} (cm);entries", {HistType::kTH2F, {{120, -20., 100.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hCPA", "2-prong candidates;cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEtaCandVsPt", "2-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hSelectionStatus", "2-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hImpParErr", "2-prong candidates;impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLenErr", "2-prong candidates;decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLenXYErr", "2-prong candidates;decay length xy error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - - // DATA : trigger particles (candidates) histograms for TPC-TPC h-h mixed event - registry.add("Data/TpcTpc/HfHadron/MixedEvent/hPtHFMixing", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcTpc/HfHadron/MixedEvent/hEtaHFMixing", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcTpc/HfHadron/MixedEvent/hPhiHFMixing", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); + + // DATA : trigger particles (candidates) histograms for TPC-TPC D0-h same event + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtCandidate", "2-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtProng0", "2-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtProng1", "2-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMassVsPt", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisMass, axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMassVsPtVsMult", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2}); p_{T}; multiplicity", {HistType::kTH3F, {axisMass, axisPt, axisMultiplicity}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMass", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axisMass}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEtaCandVsPt", "2-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {axisEtaTpc, axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/2Prong/hSelectionStatus", "2-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, axisPt}}); // ========================= // DATA : histograms for TPC-TPC HF-h case for 3PRONG // =================== registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEventCountSame", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPt", "3-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{500, 0., 5.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMass", "3-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPtVsMult", "3-prong candidates;inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}; multiplicity", {HistType::kTH3F, {{600, 1.98, 2.58}, {vbins, "#it{p}_{T} (GeV/#it{c})"}, {5000, 0., 10000.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0VsPtProng0", "3-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{600, -0.4, 0.4}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0VsPtProng1", "3-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{600, -0.4, 0.4}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0VsPtProng2", "3-prong candidates;prong 2 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{600, -0.4, 0.4}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPt", "3-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPtProng0", "3-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPtProng1", "3-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPtProng2", "3-prong candidates;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0Prong0", "3-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{600, -0.4, 0.4}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0Prong1", "3-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{600, -0.4, 0.4}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0Prong2", "3-prong candidates;prong 2 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{600, -0.4, 0.4}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLength", "3-prong candidates;decay length (cm);entries", {HistType::kTH1F, {{400, 0., 1.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLengthxy", "3-prong candidates;decay length xy (cm);entries", {HistType::kTH1F, {{400, 0., 1.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCt", "3-prong candidates;proper lifetime (#Lambda_{c}) * #it{c} (cm);entries", {HistType::kTH1F, {{100, 0., 0.2}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCPA", "3-prong candidates;cosine of pointing angle;entries", {HistType::kTH1F, {{110, -1.1, 1.1}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCPAxy", "3-prong candidates;cosine of pointing angle xy;entries", {HistType::kTH1F, {{110, -1.1, 1.1}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDca2", "3-prong candidates;prong Chi2PCA to sec. vertex (cm);entries", {HistType::kTH1F, {{400, 0., 20.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEta", "3-prong candidates;#it{#eta};entries", {HistType::kTH1F, {{100, -2., 2.}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPhi", "3-prong candidates;#it{#Phi};entries", {HistType::kTH1F, {{100, 0., 6.3}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLengthVsPt", "3-prong candidates;decay length (cm);entries", {HistType::kTH2F, {{400, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLengthxyVsPt", "3-prong candidates;decay length xy(cm);entries", {HistType::kTH2F, {{400, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCtVsPt", "3-prong candidates;proper lifetime (#Lambda_{c}) * #it{c} (cm);entries", {HistType::kTH2F, {{100, 0., 0.2}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCPAVsPt", "3-prong candidates;cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCPAxyVsPt", "3-prong candidates;cosine of pointing angle xy;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDca2VsPt", "3-prong candidates;prong Chi2PCA to sec. vertex (cm);entries", {HistType::kTH2F, {{400, 0., 20.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEtaVsPt", "3-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPhiVsPt", "3-prong candidates;candidate #it{#Phi};entries", {HistType::kTH2F, {{100, 0., 6.3}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hSelectionStatus", "3-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hImpParErrProng0", "3-prong candidates;prong 0 impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hImpParErrProng1", "3-prong candidates;prong 1 impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hImpParErrProng2", "3-prong candidates;prong 2 impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLenErr", "3-prong candidates;decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPt", "3-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisMass, axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMass", "3-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axisMass}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPtVsMult", "3-prong candidates;inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}; multiplicity", {HistType::kTH3F, {axisMass, axisPt, axisMultiplicity}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPt", "3-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPtProng0", "3-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPtProng1", "3-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPtProng2", "3-prong candidates;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEta", "3-prong candidates;#it{#eta};entries", {HistType::kTH1F, {axisEtaTpc}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPhi", "3-prong candidates;#it{#Phi};entries", {HistType::kTH1F, {axisPhi}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEtaVsPt", "3-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {axisEtaTpc, axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPhiVsPt", "3-prong candidates;candidate #it{#Phi};entries", {HistType::kTH2F, {axisPhi, axisPt}}); + registry.add("Data/TpcTpc/HfHadron/SameEvent/3Prong/hSelectionStatus", "3-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, axisPt}}); // ========================= // DATA : histograms for TPC-MFT h-h case @@ -332,37 +325,19 @@ struct HfTaskFlow { // DATA : trigger particles (TPC tracks) histograms for TPC-MFT h-h same event registry.add("Data/TpcMft/HadronHadron/SameEvent/hEventCountSame", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hEtaPhiTPC", "multiplicity vs eta vs phi in TPC", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hEtaTPC", "etaTPC", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hPhiTPC", "phiTPC", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hPtTPC", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hYieldsTPC", "multiplicity vs pT vs eta", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); - // registry.add("Data/TpcMft/HadronHadron/SameEvent/hNtracksTPC", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hMultiplicityTPC", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hEtaPhiTPC", "multiplicity vs eta vs phi in TPC", {HistType::kTH3F, {axisMultiplicity, axisEtaTpc, axisPhi}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hEtaTPC", "etaTPC", {HistType::kTH1F, {axisEtaTpc}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hPhiTPC", "phiTPC", {HistType::kTH1F, {axisPhi}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hPtTPC", "pT", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hYieldsTPC", "multiplicity vs pT vs eta", {HistType::kTH3F, {axisMultiplicity, axisPt, axisEtaTpc}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hMultiplicityTPC", "multiplicity;multiplicity;entries", {HistType::kTH1F, {axisMultiplicity}}); // DATA : associated particles (MFT tracks) histograms for TPC-MFT h-h same event - registry.add("Data/TpcMft/HadronHadron/SameEvent/hEtaPhiMFT", "multiplicity vs eta vs phi in MFT", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hEtaMFT", "etaMFT", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hPhiMFT", "phiMFT", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hPtMFT", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcMft/HadronHadron/SameEvent/hYieldsMFT", "multiplicity vs pT vs eta", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -5, 0, "#eta"}}}); - // registry.add("Data/TpcMft/HadronHadron/SameEvent/hNtracksMFT", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); - - // DATA : histograms for TPC-MFT h-h event mixing for TPC tracks - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hMultiplicityMixingTPC", "hMultiplicityMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hVtxZMixingTPC", "hVtxZMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hPtMixingTPC", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hEtaMixingTPC", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hPhiMixingTPC", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hNtracksMixingTPC", "hNtracksMixing", {HistType::kTH1F, {{500, 0, 500}}}); - - // DATA : histograms for TPC-MFT h-h event mixing for MFT tracks - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hMultiplicityMixingMFT", "hMultiplicityMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hVtxZMixingMFT", "hVtxZMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hPtMixingMFT", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hEtaMixingMFT", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hPhiMixingMFT", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HadronHadron/MixedEvent/hNtracksMixingMFT", "hNtracksMixing", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hEtaPhiMFT", "multiplicity vs eta vs phi in MFT", {HistType::kTH3F, {axisMultiplicity, axisEtaMft, axisPhi}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hEtaMFT", "etaMFT", {HistType::kTH1F, {axisEtaMft}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hPhiMFT", "phiMFT", {HistType::kTH1F, {axisPhi}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hPtMFT", "pT", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HadronHadron/SameEvent/hYieldsMFT", "multiplicity vs pT vs eta", {HistType::kTH3F, {axisMultiplicity, axisPt, axisEtaMft}}); // DATA : histograms for TPC-MFT h-h event mixing for events QA registry.add("Data/TpcMft/HadronHadron/MixedEvent/hEventCountMixing", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); @@ -373,56 +348,28 @@ struct HfTaskFlow { // DATA : trigger particles (candidates) histograms for TPC-MFT HF-h same event registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hEventCountSame", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaPhiCandidate", "multiplicity vs eta vs phi in TPC", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaCandidate", "etaTPC", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hPhiCandidate", "phiTPC", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hYieldsCandidate", "multiplicity vs pT vs eta", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hMultiplicityCandidate", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{500, 0, 500}}}); - // registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hNtracksCandidate", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaPhiCandidate", "multiplicity vs eta vs phi in TPC", {HistType::kTH3F, {axisMultiplicity, axisEtaMft, axisPhi}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaCandidate", "etaTPC", {HistType::kTH1F, {axisEtaMft}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hPhiCandidate", "phiTPC", {HistType::kTH1F, {axisPhi}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hYieldsCandidate", "multiplicity vs pT vs eta", {HistType::kTH3F, {axisMultiplicity, axisPt, axisEtaMft}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hMultiplicityCandidate", "multiplicity;multiplicity;entries", {HistType::kTH1F, {axisMultiplicity}}); // DATA : trigger particles (candidates) histograms for TPC-MFT HF-h same event - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtCandidate", "2-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtProng0", "2-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtProng1", "2-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hMassVsPt", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{500, 0., 5.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hMass", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLength", "2-prong candidates;decay length (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLengthXY", "2-prong candidates;decay length xy (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hd0Prong0", "2-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hd0Prong1", "2-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hd0d0", "2-prong candidates;product of DCAxy to prim. vertex (cm^{2});entries", {HistType::kTH2F, {{500, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hCTS", "2-prong candidates;cos #it{#theta}* (D^{0});entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hCt", "2-prong candidates;proper lifetime (D^{0}) * #it{c} (cm);entries", {HistType::kTH2F, {{120, -20., 100.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hCPA", "2-prong candidates;cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaCandVsPt", "2-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hSelectionStatus", "2-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hImpParErr", "2-prong candidates;impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLenErr", "2-prong candidates;decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLenXYErr", "2-prong candidates;decay length xy error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtCandidate", "2-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtProng0", "2-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtProng1", "2-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hMassVsPt", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisMass, axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hMass", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axisMass}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hMassVsPtVsMult", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2}); p_{T}; multiplicity", {HistType::kTH3F, {axisMass, axisPt, axisMultiplicity}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaCandVsPt", "2-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {axisEtaMft, axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/2Prong/hSelectionStatus", "2-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, axisPt}}); // DATA : associated particles (MFT tracks) histograms for TPC-MFT h-h same event - registry.add("Data/TpcMft/HfHadron/SameEvent/hEtaPhiMFT", "multiplicity vs eta vs phi in MFT", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/hEtaMFT", "etaMFT", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/hPhiMFT", "phiMFT", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/hPtMFT", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/hYieldsMFT", "multiplicity vs pT vs eta", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -5, 0, "#eta"}}}); - // registry.add("Data/TpcMft/HfHadron/SameEvent/hNtracksMFT", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); - - // DATA : histograms for TPC-MFT h-h event mixing for candidates - registry.add("Data/TpcMft/HfHadron/MixedEvent/hMultiplicityMixingCandidate", "hMultiplicityMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hVtxZMixingCandidate", "hVtxZMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hPtMixingCandidate", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hEtaMixingCandidate", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hPhiMixingCandidate", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hNtracksMixingCandidate", "hNtracksMixing", {HistType::kTH1F, {{500, 0, 500}}}); - - // DATA : histograms for TPC-MFT h-h event mixing for MFT tracks - registry.add("Data/TpcMft/HfHadron/MixedEvent/hMultiplicityMixingMFT", "hMultiplicityMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hVtxZMixingMFT", "hVtxZMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hPtMixingMFT", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hEtaMixingMFT", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hPhiMixingMFT", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HfHadron/MixedEvent/hNtracksMixingMFT", "hNtracksMixing", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/hEtaPhiMFT", "multiplicity vs eta vs phi in MFT", {HistType::kTH3F, {axisMultiplicity, axisEtaMft, axisPhi}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/hEtaMFT", "etaMFT", {HistType::kTH1F, {axisEtaMft}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/hPhiMFT", "phiMFT", {HistType::kTH1F, {axisPhi}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/hPtMFT", "pT", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/hYieldsMFT", "multiplicity vs pT vs eta", {HistType::kTH3F, {axisMultiplicity, axisPt, axisEtaMft}}); // DATA : histograms for TPC-MFT h-h event mixing for events QA registry.add("Data/TpcMft/HfHadron/MixedEvent/hEventCountMixing", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); @@ -432,44 +379,21 @@ struct HfTaskFlow { // ========================= registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hEventCountSame", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hYieldsCandidate", "multiplicity vs pT vs eta", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hMultiplicityCandidate", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{500, 0, 500}}}); - // registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hNtracksCandidate", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hEtaPhiCandidate", "multiplicity vs eta vs phi in TPC", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hMassVsPt", "3-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{500, 0., 5.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hMass", "3-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hMassVsPtVsMult", "3-prong candidates;inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}; multiplicity", {HistType::kTH3F, {{600, 1.98, 2.58}, {vbins, "#it{p}_{T} (GeV/#it{c})"}, {5000, 0., 10000.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0VsPtProng0", "3-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{600, -0.4, 0.4}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0VsPtProng1", "3-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{600, -0.4, 0.4}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0VsPtProng2", "3-prong candidates;prong 2 DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{600, -0.4, 0.4}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPt", "3-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPtProng0", "3-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPtProng1", "3-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPtProng2", "3-prong candidates;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0Prong0", "3-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{600, -0.4, 0.4}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0Prong1", "3-prong candidates;prong 1 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{600, -0.4, 0.4}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0Prong2", "3-prong candidates;prong 2 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{600, -0.4, 0.4}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLength", "3-prong candidates;decay length (cm);entries", {HistType::kTH1F, {{400, 0., 1.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLengthxy", "3-prong candidates;decay length xy (cm);entries", {HistType::kTH1F, {{400, 0., 1.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hCt", "3-prong candidates;proper lifetime (#Lambda_{c}) * #it{c} (cm);entries", {HistType::kTH1F, {{100, 0., 0.2}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hCPA", "3-prong candidates;cosine of pointing angle;entries", {HistType::kTH1F, {{110, -1.1, 1.1}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hCPAxy", "3-prong candidates;cosine of pointing angle xy;entries", {HistType::kTH1F, {{110, -1.1, 1.1}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hDca2", "3-prong candidates;prong Chi2PCA to sec. vertex (cm);entries", {HistType::kTH1F, {{400, 0., 20.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hEta", "3-prong candidates;#it{#eta};entries", {HistType::kTH1F, {{100, -2., 2.}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPhi", "3-prong candidates;#it{#Phi};entries", {HistType::kTH1F, {{100, 0., 6.3}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLengthVsPt", "3-prong candidates;decay length (cm);entries", {HistType::kTH2F, {{400, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLengthxyVsPt", "3-prong candidates;decay length xy(cm);entries", {HistType::kTH2F, {{400, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hCtVsPt", "3-prong candidates;proper lifetime (#Lambda_{c}) * #it{c} (cm);entries", {HistType::kTH2F, {{100, 0., 0.2}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hCPAVsPt", "3-prong candidates;cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hCPAxyVsPt", "3-prong candidates;cosine of pointing angle xy;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hDca2VsPt", "3-prong candidates;prong Chi2PCA to sec. vertex (cm);entries", {HistType::kTH2F, {{400, 0., 20.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hEtaVsPt", "3-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPhiVsPt", "3-prong candidates;candidate #it{#Phi};entries", {HistType::kTH2F, {{100, 0., 6.3}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hSelectionStatus", "3-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hImpParErrProng0", "3-prong candidates;prong 0 impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hImpParErrProng1", "3-prong candidates;prong 1 impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hImpParErrProng2", "3-prong candidates;prong 2 impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLenErr", "3-prong candidates;decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hYieldsCandidate", "multiplicity vs pT vs eta", {HistType::kTH3F, {axisMultiplicity, axisPt, axisEtaMft}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hMultiplicityCandidate", "multiplicity;multiplicity;entries", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hEtaPhiCandidate", "multiplicity vs eta vs phi in TPC", {HistType::kTH3F, {axisMultiplicity, axisEtaMft, axisPhi}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hMassVsPt", "3-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisMass, axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hMass", "3-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axisMass}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hMassVsPtVsMult", "3-prong candidates;inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}; multiplicity", {HistType::kTH3F, {axisMass, axisPt, axisMultiplicity}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPt", "3-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPtProng0", "3-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPtProng1", "3-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPtProng2", "3-prong candidates;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hEta", "3-prong candidates;#it{#eta};entries", {HistType::kTH1F, {axisEtaMft}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPhi", "3-prong candidates;#it{#Phi};entries", {HistType::kTH1F, {axisPhi}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hEtaVsPt", "3-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {axisEtaMft, axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hPhiVsPt", "3-prong candidates;candidate #it{#Phi};entries", {HistType::kTH2F, {axisPhi, axisPt}}); + registry.add("Data/TpcMft/HfHadron/SameEvent/3Prong/hSelectionStatus", "3-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, axisPt}}); // ========================= // MC : histograms for TPC-TPC h-h case @@ -477,49 +401,49 @@ struct HfTaskFlow { // MC reconstructed - registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hMultiplicity", "hMultiplicity", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hVtxZ", "hVtxZ", {HistType::kTH1F, {{400, -50, 50}}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hMultiplicity", "hMultiplicity", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hVtxZ", "hVtxZ", {HistType::kTH1F, {axisVertex}}); registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEventCountSame", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); // Katarina had this : - registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hMultiplicityPrimary", "hMultiplicityPrimary", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hMultiplicityPrimary", "hMultiplicityPrimary", {HistType::kTH1F, {axisMultiplicity}}); // histograms for MC associated particles - registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hPt", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEta", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hPhi", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hYields", "multiplicity vs pT vs eta", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEtaPhi", "multiplicity vs eta vs phi", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hNtracks", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hPt", "pT", {HistType::kTH1F, {axisPt}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEta", "eta", {HistType::kTH1F, {axisEtaTpc}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hPhi", "phi", {HistType::kTH1F, {axisPhi}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hYields", "multiplicity vs pT vs eta", {HistType::kTH3F, {axisMultiplicity, axisPt, axisEtaTpc}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEtaPhi", "multiplicity vs eta vs phi", {HistType::kTH3F, {axisMultiplicity, axisEtaTpc, axisPhi}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hNtracks", "hNtracks", {HistType::kTH1F, {axisMultiplicity}}); // histograms for MC particles in event mixing registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hEventCountMixing", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hMultiplicityMixing", "hMultiplicityMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hVtxZMixing", "hVtxZMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hPtMixing", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hEtaMixing", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hPhiMixing", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hNtracksMixing", "hNtracksMixing", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hMultiplicityMixing", "hMultiplicityMixing", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hVtxZMixing", "hVtxZMixing", {HistType::kTH1F, {axisVertex}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hPtMixing", "pT", {HistType::kTH1F, {axisPt}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hEtaMixing", "eta", {HistType::kTH1F, {axisEtaTpc}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hPhiMixing", "phi", {HistType::kTH1F, {axisPhi}}); + registry.add("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hNtracksMixing", "hNtracksMixing", {HistType::kTH1F, {axisMultiplicity}}); // MC Truth - registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hMultiplicity", "hMultiplicity", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hVtxZ", "hVtxZ", {HistType::kTH1F, {{400, -50, 50}}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hMultiplicity", "hMultiplicity", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hVtxZ", "hVtxZ", {HistType::kTH1F, {axisVertex}}); registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEventCountSame", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); // Katarina had this : - registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hMultiplicityPrimary", "hMultiplicityPrimary", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hMultiplicityPrimary", "hMultiplicityPrimary", {HistType::kTH1F, {axisMultiplicity}}); // histograms for MC associated particles - registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hPt", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEta", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hPhi", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hYields", "multiplicity vs pT vs eta", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEtaPhi", "multiplicity vs eta vs phi", {HistType::kTH3F, {{200, 0, 200, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, TwoPI, "#varphi"}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hNtracks", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hPt", "pT", {HistType::kTH1F, {axisPt}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEta", "eta", {HistType::kTH1F, {axisEtaTpc}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hPhi", "phi", {HistType::kTH1F, {axisPhi}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hYields", "multiplicity vs pT vs eta", {HistType::kTH3F, {axisMultiplicity, axisPt, axisEtaTpc}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEtaPhi", "multiplicity vs eta vs phi", {HistType::kTH3F, {axisMultiplicity, axisEtaTpc, axisPhi}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hNtracks", "hNtracks", {HistType::kTH1F, {axisMultiplicity}}); // histograms for MC particles in event mixing registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hEventCountMixing", "bin", {HistType::kTH1F, {{nBinsMix + 2, -2.5, -0.5 + nBinsMix, "bin"}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hMultiplicityMixing", "hMultiplicityMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hVtxZMixing", "hVtxZMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hPtMixing", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hEtaMixing", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hPhiMixing", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hNtracksMixing", "hNtracksMixing", {HistType::kTH1F, {{500, 0, 500}}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hMultiplicityMixing", "hMultiplicityMixing", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hVtxZMixing", "hVtxZMixing", {HistType::kTH1F, {axisVertex}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hPtMixing", "pT", {HistType::kTH1F, {axisPt}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hEtaMixing", "eta", {HistType::kTH1F, {axisEtaTpc}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hPhiMixing", "phi", {HistType::kTH1F, {axisPhi}}); + registry.add("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hNtracksMixing", "hNtracksMixing", {HistType::kTH1F, {axisMultiplicity}}); // ========================= // Declaration of correlation containers and their respective axis @@ -537,18 +461,14 @@ struct HfTaskFlow { std::vector userAxis = {{axisMass, "m_{inv} (GeV/c^{2})"}}; // initialization of correlation containers for data - sameTPCTPCChCh.setObject(new CorrelationContainer("sameTPCTPCChCh", "sameTPCTPCChCh", corrAxis, effAxis, {})); - mixedTPCTPCChCh.setObject(new CorrelationContainer("mixedTPCTPCChCh", "mixedTPCTPCChCh", corrAxis, effAxis, {})); - sameTPCTPCHfCh.setObject(new CorrelationContainer("sameTPCTPCHfCh", "sameTPCTPCHfCh", corrAxis, effAxis, userAxis)); - mixedTPCTPCHfCh.setObject(new CorrelationContainer("mixedTPCTPCHfCh", "mixedTPCTPCHfCh", corrAxis, effAxis, userAxis)); - sameTPCMFTChCh.setObject(new CorrelationContainer("sameTPCMFTChCh", "sameTPCMFTChCh", corrAxis, effAxis, {})); - mixedTPCMFTChCh.setObject(new CorrelationContainer("mixedTPCMFTChCh", "mixedTPCMFTChCh", corrAxis, effAxis, {})); - sameTPCMFTHfCh.setObject(new CorrelationContainer("sameTPCMFTHfCh", "sameTPCMFTHfCh", corrAxis, effAxis, userAxis)); - mixedTPCMFTHfCh.setObject(new CorrelationContainer("mixedTPCMFTHfCh", "mixedTPCMFTHfCh", corrAxis, effAxis, userAxis)); + sameEvent.setObject(new CorrelationContainer("sameEvent", "sameEvent", corrAxis, effAxis, {})); + mixedEvent.setObject(new CorrelationContainer("mixedEvent", "mixedEvent", corrAxis, effAxis, {})); + sameEventHf.setObject(new CorrelationContainer("sameEventHf", "sameEventHf", corrAxis, effAxis, userAxis)); + mixedEventHf.setObject(new CorrelationContainer("mixedEventHf", "mixedEventHf", corrAxis, effAxis, userAxis)); // initialization of correlation containes for monte-carlo - sameTPCTPCChChMC.setObject(new CorrelationContainer("sameTPCTPCChChMC", "sameTPCTPCChChMC", corrAxis, effAxis, {})); - mixedTPCTPCChChMC.setObject(new CorrelationContainer("mixedTPCTPCChChMC", "mixedTPCTPCChChMC", corrAxis, effAxis, {})); + sameEventHfMc.setObject(new CorrelationContainer("sameEventHfMc", "sameEventHfMc", corrAxis, effAxis, userAxis)); + mixedEventHfMc.setObject(new CorrelationContainer("mixedEventHfMc", "mixedEventHfMc", corrAxis, effAxis, userAxis)); } // End of init() function // ========================= @@ -576,44 +496,23 @@ struct HfTaskFlow { registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/hEtaPhi"), multiplicity, track.eta(), track.phi()); } - // ---- MC : TPC-TPC h-h Same Event QA ---- - // Changed quickly void for int type + added the return for a test - template - int fillTpcTpcChChSameEventQaMc(float multiplicity, TTracks const& tracks) + // ---- MC REC : TPC-TPC h-h Same Event QA ---- + template + void fillTpcTpcChChSameEventQaMc(float multiplicity, TTrack const& track) { - int nTracks = tracks.size(); - for (const auto& track1 : tracks) { - - // in case of MC-generated, do additional selection on MCparticles : charge and isPhysicalPrimary - if constexpr (std::is_same_v) { - if (!isMcParticleSelected(track1)) { - continue; - } - // TO-DO : add other if constexpr conditions when I will have more MC cases - } - - if constexpr (std::is_same_v) { // if MC Rec - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hPt"), track1.pt()); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEta"), track1.eta()); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hPhi"), track1.phi()); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hYields"), multiplicity, track1.pt(), track1.eta()); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEtaPhi"), multiplicity, track1.eta(), track1.phi()); - } else { // if MC Gen - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hPt"), track1.pt()); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEta"), track1.eta()); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hPhi"), track1.phi()); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hYields"), multiplicity, track1.pt(), track1.eta()); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEtaPhi"), multiplicity, track1.eta(), track1.phi()); - } - } - if constexpr (std::is_same_v) { // if MC Rec - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hNtracks"), nTracks); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hMultiplicityPrimary"), nTracks); + if constexpr (std::is_same_v) { // if MC Rec + registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hPt"), track.pt()); + registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEta"), track.eta()); + registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hPhi"), track.phi()); + registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hYields"), multiplicity, track.pt(), track.eta()); + registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEtaPhi"), multiplicity, track.eta(), track.phi()); } else { // if MC Gen - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hNtracks"), nTracks); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hMultiplicityPrimary"), nTracks); + registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hPt"), track.pt()); + registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEta"), track.eta()); + registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hPhi"), track.phi()); + registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hYields"), multiplicity, track.pt(), track.eta()); + registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEtaPhi"), multiplicity, track.eta(), track.phi()); } - return nTracks; } // ---- DATA : TPC-MFT h-h Same Event QA ---- @@ -658,46 +557,34 @@ struct HfTaskFlow { } // ---- DATA : TPC-TPC HF-h Same Event (Candidates) QA ---- - // TODO: Note: we do not need all these plots since they are in D0 and Lc task -> remove it after we are sure this works - // TODO: Note: we do not need all these plots since they are in D0 and Lc task -> remove it after we are sure this works template void fillTpcTpcD0CandidateQa(float multiplicity, TTrack const& candidate) { float phi = candidate.phi(); o2::math_utils::bringTo02Pi(phi); - + auto eta = candidate.eta(); auto pt = candidate.pt(); - if (candidate.isSelD0() >= selectionFlagD0) { + if (candidate.isSelD0() >= selectionFlagHf) { + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMassVsPtVsMult"), hfHelper.invMassD0ToPiK(candidate), pt, multiplicity); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMassVsPt"), hfHelper.invMassD0ToPiK(candidate), pt); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMass"), hfHelper.invMassD0ToPiK(candidate)); } - if (candidate.isSelD0bar() >= selectionFlagD0bar) { + if (candidate.isSelD0bar() >= selectionFlagHf) { + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMassVsPtVsMult"), hfHelper.invMassD0barToKPi(candidate), pt, multiplicity); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMassVsPt"), hfHelper.invMassD0barToKPi(candidate), pt); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMass"), hfHelper.invMassD0barToKPi(candidate)); } registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMultiplicity"), multiplicity); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEta"), candidate.eta()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEta"), eta); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPhi"), phi); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtCandidate"), pt); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtProng0"), candidate.ptProng0()); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtProng1"), candidate.ptProng1()); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLength"), candidate.decayLength(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLengthXY"), candidate.decayLengthXY(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hd0Prong0"), candidate.impactParameter0(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hd0Prong1"), candidate.impactParameter1(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hd0d0"), candidate.impactParameterProduct(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hCTS"), hfHelper.cosThetaStarD0(candidate), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hCt"), hfHelper.ctD0(candidate), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hCPA"), candidate.cpa(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEtaCandVsPt"), candidate.eta(), pt); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEtaCandVsPt"), eta, pt); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hSelectionStatus"), candidate.isSelD0() + (candidate.isSelD0bar() * 2), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hImpParErr"), candidate.errorImpactParameter0(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hImpParErr"), candidate.errorImpactParameter1(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLenErr"), candidate.errorDecayLength(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLenXYErr"), candidate.errorDecayLengthXY(), pt); } // ---- DATA : TPC-TPC HF-h Same Event (Candidates) QA ---- @@ -712,18 +599,14 @@ struct HfTaskFlow { auto ptProng0 = candidate.ptProng0(); auto ptProng1 = candidate.ptProng1(); auto ptProng2 = candidate.ptProng2(); - auto decayLength = candidate.decayLength(); - auto decayLengthXY = candidate.decayLengthXY(); - auto chi2PCA = candidate.chi2PCA(); - auto cpa = candidate.cpa(); - auto cpaXY = candidate.cpaXY(); + auto eta = candidate.eta(); - if (candidate.isSelLcToPKPi() >= selectionFlagLcToPKPi) { + if (candidate.isSelLcToPKPi() >= selectionFlagHf) { registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMass"), hfHelper.invMassLcToPKPi(candidate)); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPtVsMult"), hfHelper.invMassLcToPKPi(candidate), pt, multiplicity); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPt"), hfHelper.invMassLcToPKPi(candidate), pt); } - if (candidate.isSelLcToPiKP() >= selectionFlagLcToPiKP) { + if (candidate.isSelLcToPiKP() >= selectionFlagHf) { registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMass"), hfHelper.invMassLcToPiKP(candidate)); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPtVsMult"), hfHelper.invMassLcToPiKP(candidate), pt, multiplicity); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPt"), hfHelper.invMassLcToPiKP(candidate), pt); @@ -734,34 +617,12 @@ struct HfTaskFlow { registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPtProng0"), ptProng0); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPtProng1"), ptProng1); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPtProng2"), ptProng2); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0Prong0"), candidate.impactParameter0()); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0Prong1"), candidate.impactParameter1()); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0Prong2"), candidate.impactParameter2()); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0VsPtProng0"), candidate.impactParameter0(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0VsPtProng1"), candidate.impactParameter1(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hd0VsPtProng2"), candidate.impactParameter2(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLength"), decayLength); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLengthVsPt"), decayLength, pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLengthxy"), decayLengthXY); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLengthxyVsPt"), decayLengthXY, pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCt"), hfHelper.ctLc(candidate)); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCtVsPt"), hfHelper.ctLc(candidate), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCPA"), cpa); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCPAVsPt"), cpa, pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCPAxy"), cpaXY); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hCPAxyVsPt"), cpaXY, pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDca2"), chi2PCA); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDca2VsPt"), chi2PCA, pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEta"), candidate.eta()); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEtaVsPt"), candidate.eta(), pt); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEta"), eta); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEtaVsPt"), eta, pt); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPhi"), phi); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPhiVsPt"), phi, pt); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hSelectionStatus"), candidate.isSelLcToPKPi(), pt); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hSelectionStatus"), candidate.isSelLcToPiKP(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hImpParErrProng0"), candidate.errorImpactParameter0(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hImpParErrProng1"), candidate.errorImpactParameter1(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hImpParErrProng2"), candidate.errorImpactParameter2(), pt); - registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hDecLenErr"), candidate.errorDecayLength(), pt); } // ---- DATA : TPC-MFT HF-h Same Event (Candidates) QA ---- @@ -773,11 +634,13 @@ struct HfTaskFlow { auto pt = candidate.pt(); o2::math_utils::bringTo02Pi(phi); - if (candidate.isSelD0() >= selectionFlagD0) { + if (candidate.isSelD0() >= selectionFlagHf) { + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMassVsPtVsMult"), hfHelper.invMassD0ToPiK(candidate), pt, multiplicity); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMassVsPt"), hfHelper.invMassD0ToPiK(candidate), pt); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMass"), hfHelper.invMassD0ToPiK(candidate)); } - if (candidate.isSelD0bar() >= selectionFlagD0bar) { + if (candidate.isSelD0bar() >= selectionFlagHf) { + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMassVsPtVsMult"), hfHelper.invMassD0barToKPi(candidate), pt, multiplicity); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMassVsPt"), hfHelper.invMassD0barToKPi(candidate), pt); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMass"), hfHelper.invMassD0barToKPi(candidate)); } @@ -790,20 +653,8 @@ struct HfTaskFlow { registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtCandidate"), pt); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtProng0"), candidate.ptProng0()); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtProng1"), candidate.ptProng1()); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLength"), candidate.decayLength(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLengthXY"), candidate.decayLengthXY(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hd0Prong0"), candidate.impactParameter0(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hd0Prong1"), candidate.impactParameter1(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hd0d0"), candidate.impactParameterProduct(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hCTS"), hfHelper.cosThetaStarD0(candidate), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hCt"), hfHelper.ctD0(candidate), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hCPA"), candidate.cpa(), pt); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaCandVsPt"), candidate.eta(), pt); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hSelectionStatus"), candidate.isSelD0() + (candidate.isSelD0bar() * 2), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hImpParErr"), candidate.errorImpactParameter0(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hImpParErr"), candidate.errorImpactParameter1(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLenErr"), candidate.errorDecayLength(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLenXYErr"), candidate.errorDecayLengthXY(), pt); } // ---- DATA : TPC-MFT HF-h Same Event (Candidates) QA ---- @@ -816,20 +667,15 @@ struct HfTaskFlow { auto ptProng0 = candidate.ptProng0(); auto ptProng1 = candidate.ptProng1(); auto ptProng2 = candidate.ptProng2(); - auto decayLength = candidate.decayLength(); - auto decayLengthXY = candidate.decayLengthXY(); - auto chi2PCA = candidate.chi2PCA(); - auto cpa = candidate.cpa(); - auto cpaXY = candidate.cpaXY(); float phi = candidate.phi(); o2::math_utils::bringTo02Pi(phi); - if (candidate.isSelLcToPKPi() >= selectionFlagLcToPKPi) { + if (candidate.isSelLcToPKPi() >= selectionFlagHf) { registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hMass"), hfHelper.invMassLcToPKPi(candidate)); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hMassVsPtVsMult"), hfHelper.invMassLcToPKPi(candidate), pt, multiplicity); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hMassVsPt"), hfHelper.invMassLcToPKPi(candidate), pt); } - if (candidate.isSelLcToPiKP() >= selectionFlagLcToPiKP) { + if (candidate.isSelLcToPiKP() >= selectionFlagHf) { registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hMass"), hfHelper.invMassLcToPiKP(candidate)); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hMassVsPtVsMult"), hfHelper.invMassLcToPiKP(candidate), pt, multiplicity); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hMassVsPt"), hfHelper.invMassLcToPiKP(candidate), pt); @@ -842,188 +688,29 @@ struct HfTaskFlow { registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hPtProng0"), ptProng0); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hPtProng1"), ptProng1); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hPtProng2"), ptProng2); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0Prong0"), candidate.impactParameter0()); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0Prong1"), candidate.impactParameter1()); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0Prong2"), candidate.impactParameter2()); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0VsPtProng0"), candidate.impactParameter0(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0VsPtProng1"), candidate.impactParameter1(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hd0VsPtProng2"), candidate.impactParameter2(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLength"), decayLength); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLengthVsPt"), decayLength, pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLengthxy"), decayLengthXY); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLengthxyVsPt"), decayLengthXY, pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hCt"), hfHelper.ctLc(candidate)); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hCtVsPt"), hfHelper.ctLc(candidate), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hCPA"), cpa); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hCPAVsPt"), cpa, pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hCPAxy"), cpaXY); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hCPAxyVsPt"), cpaXY, pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hDca2"), chi2PCA); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hDca2VsPt"), chi2PCA, pt); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hEta"), candidate.eta()); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hEtaVsPt"), candidate.eta(), pt); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hPhi"), candidate.phi()); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hPhiVsPt"), candidate.phi(), pt); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hSelectionStatus"), candidate.isSelLcToPKPi(), pt); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hSelectionStatus"), candidate.isSelLcToPiKP(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hImpParErrProng0"), candidate.errorImpactParameter0(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hImpParErrProng1"), candidate.errorImpactParameter1(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hImpParErrProng2"), candidate.errorImpactParameter2(), pt); - registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hDecLenErr"), candidate.errorDecayLength(), pt); } // ========================= - // Quality Assesment plots for Mixed Event + // Helper functions // ========================= - // ---- DATA : TPC-TPC h-h Mixed Event QA ---- - template - void fillTpcTpcChChMixedEventQa(float multiplicity, float vz, TTracks const& tracks) + HfProngSpecies getSpecies(int pdgCode) { - registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hMultiplicityMixing"), multiplicity); - registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hVtxZMixing"), vz); - - int nTracks = tracks.size(); - for (const auto& track1 : tracks) { - registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hPtMixing"), track1.pt()); - registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hEtaMixing"), track1.eta()); - registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hPhiMixing"), track1.phi()); - } - registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hNtracksMixing"), nTracks); - } - - // ---- MC : TPC-TPC h-h Mixed Event QA ---- - template - void fillTpcTpcChChMixedEventQaMc(float multiplicity, float vz, TTracks const& tracks) - { - if constexpr (std::is_same_v) { // if MC Rec - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hMultiplicityMixing"), multiplicity); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hVtxZMixing"), vz); - } else { // if MC Gen - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hMultiplicityMixing"), multiplicity); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hVtxZMixing"), vz); - } - - int nTracks = tracks.size(); - for (const auto& track1 : tracks) { - if constexpr (std::is_same_v) { // if MC Rec - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hPtMixing"), track1.pt()); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hEtaMixing"), track1.eta()); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hPhiMixing"), track1.phi()); - } else { // if MC Gen - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hPtMixing"), track1.pt()); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hEtaMixing"), track1.eta()); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hPhiMixing"), track1.phi()); - } - } - if constexpr (std::is_same_v) { // if MC Rec - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hNtracksMixing"), nTracks); - } else { // if MC Gen - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hNtracksMixing"), nTracks); - } - } - - // ---- DATA : TPC-TPC HF-h Mixed Event QA ---- - template - void fillTpcTpcHfChMixedEventQa(float multiplicity, float vz, TTracks const& tracks) - { - // This function is only called with HF candidates - - registry.fill(HIST("Data/TpcTpc/HfHadron/MixedEvent/hMultiplicityHFMixing"), multiplicity); - registry.fill(HIST("Data/TpcTpc/HfHadron/MixedEvent/hVtxZHFMixing"), vz); - - int nTracks = tracks.size(); - for (const auto& track1 : tracks) { - - // apply candidate cuts - if (!isAcceptedCandidate(track1)) { - continue; - } - - registry.fill(HIST("Data/TpcTpc/HfHadron/MixedEvent/hPtHFMixing"), track1.pt()); - registry.fill(HIST("Data/TpcTpc/HfHadron/MixedEvent/hEtaHFMixing"), track1.eta()); - registry.fill(HIST("Data/TpcTpc/HfHadron/MixedEvent/hPhiHFMixing"), track1.phi()); - } - registry.fill(HIST("Data/TpcTpc/HfHadron/MixedEvent/hNtracksHFMixing"), nTracks); - } - - // ---- DATA : TPC-MFT h-h Mixed Event QA ---- - template - void fillTpcMftChChMixedEventQa(float multiplicity, float vz, TTracks const& tracks) - { - if constexpr (std::is_same_v) { // if MFT tracks - int nTracks = tracks.size(); - - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hMultiplicityMixingMFT"), multiplicity); - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hVtxZMixingMFT"), vz); - - for (const auto& track1 : tracks) { - - // apply cuts for MFT tracks - if (!isAcceptedMftTrack(track1)) { - continue; - } - - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hPtMixingMFT"), track1.pt()); - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hEtaMixingMFT"), track1.eta()); - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hPhiMixingMFT"), track1.phi()); - } - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hNtracksMixingMFT"), nTracks); - } else { // if TPC tracks - - int nTracks = tracks.size(); - - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hMultiplicityMixingTPC"), multiplicity); - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hVtxZMixingTPC"), vz); - - for (const auto& track1 : tracks) { - - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hPtMixingTPC"), track1.pt()); - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hEtaMixingTPC"), track1.eta()); - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hPhiMixingTPC"), track1.phi()); - } - registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hNtracksMixingTPC"), nTracks); - } - } - - // ---- DATA : TPC-MFT h-h Mixed Event QA ---- - template - void fillTpcMftHfChMixedEventQa(float multiplicity, float vz, TTracks const& tracks) - { - if constexpr (std::is_same_v) { // if MFT tracks - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hMultiplicityMixingMFT"), multiplicity); - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hVtxZMixingMFT"), vz); - - int nTracks = tracks.size(); - for (const auto& track1 : tracks) { - - // apply cuts for MFT tracks - if (!isAcceptedMftTrack(track1)) { - continue; - } - - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hPtMixingMFT"), track1.pt()); - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hEtaMixingMFT"), track1.eta()); - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hPhiMixingMFT"), track1.phi()); - } - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hNtracksMixingMFT"), nTracks); - } else { // if candidate tracks - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hMultiplicityMixingCandidate"), multiplicity); - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hVtxZMixingCandidate"), vz); - - int nTracks = tracks.size(); - for (const auto& track1 : tracks) { - - // apply candidate cuts - if (!isAcceptedCandidate(track1)) { - continue; - } - - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hPtMixingCandidate"), track1.pt()); - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hEtaMixingCandidate"), track1.eta()); - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hPhiMixingCandidate"), track1.phi()); - } - registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hNtracksMixingCandidate"), nTracks); + switch (std::abs(pdgCode)) { + case PDG_t::kPiPlus: // positive or negative pion + return HfProngSpecies::Pion; + case PDG_t::kKPlus: // positive or negative kaon + return HfProngSpecies::Kaon; + case PDG_t::kProton: // proton or proton bar + return HfProngSpecies::Proton; + default: // NOTE. The efficiency histogram is hardcoded to contain 4 species. Anything special will have the last slot. + return HfProngSpecies::NHfProngSpecies; } } @@ -1033,10 +720,11 @@ struct HfTaskFlow { // FIXME: Some collisions are rejected here, what causes (part of) differences with the D0 task template - bool isCollisionSelected(TCollision const& collision, bool fillHistograms = false) + bool isAcceptedCollision(TCollision const& collision, bool fillHistograms = false) { - if (fillHistograms) + if (fillHistograms) { registry.fill(HIST("Data/hEventCounter"), 1); + } if (processMc == false) { if (!collision.sel8()) { @@ -1044,8 +732,9 @@ struct HfTaskFlow { } } - if (fillHistograms) - registry.fill(HIST("Data/hEventCounter"), 3); + if (fillHistograms) { + registry.fill(HIST("Data/hEventCounter"), 2); + } return true; } @@ -1060,21 +749,22 @@ struct HfTaskFlow { if (!(candidate.hfflag() & 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { return false; } - if (yCandMax >= 0. && std::abs(hfHelper.yLc(candidate)) > yCandMax) { + if (etaCandidateMax >= 0. && std::abs(etaCandidate) > etaCandidateMax) { return false; } - if (etaCandidateMax >= 0. && std::abs(etaCandidate) > etaCandidateMax) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLc(candidate)) > yCandRecoMax) { return false; } return true; } else { // For now, that means we do D0 + // Doesn't this exclude D0bar ? if (!(candidate.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { return false; } - if (yCandMax >= 0. && std::abs(hfHelper.yD0(candidate)) > yCandMax) { + if (etaCandidateMax >= 0. && std::abs(etaCandidate) > etaCandidateMax) { return false; } - if (etaCandidateMax >= 0. && std::abs(etaCandidate) > etaCandidateMax) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yD0(candidate)) > yCandRecoMax) { return false; } return true; @@ -1088,9 +778,9 @@ struct HfTaskFlow { bool isAcceptedMftTrack(TTrack const& mftTrack) { // cut on the eta of MFT tracks - if (mftTrack.eta() > etaMftTrackMax || mftTrack.eta() < etaMftTrackMin) { - return false; - } + // if (mftTrack.eta() > etaMftTrackMax || mftTrack.eta() < etaMftTrackMin) { + // return false; + // } // cut on the number of clusters of the reconstructed MFT track if (mftTrack.nClusters() < nClustersMftTrack) { @@ -1101,30 +791,89 @@ struct HfTaskFlow { } // I am not sure if to template McParticles is useful, I'll address this when doing the MC Gen case of HF-h correlations - template - bool isMcParticleSelected(TMcParticles& mcParticles) + template + bool isAcceptedMcCandidate(TMcTrack& mcCandidate) + { + auto etaCandidate = mcCandidate.eta(); + + if constexpr (std::is_same_v) { // For now, that means we do D0 + if (std::abs(mcCandidate.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + + if (etaCandidateMax >= 0. && std::abs(etaCandidate) > etaCandidateMax) { + return false; + } + + if (yCandGenMax >= 0. && std::abs(RecoDecay::y(mcCandidate.pVector(), o2::constants::physics::MassD0)) > yCandGenMax) { + return false; + } + + // Later on, if I want to add prompt/non-prompt selection, below is how to select prompt only + // if (!(particle.originMcGen() == RecoDecay::OriginType::Prompt)){ + // return false; + // } + } + } else { // For now, that means we do LambdaC + if (std::abs(mcCandidate.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + + if (etaCandidateMax >= 0. && std::abs(etaCandidate) > etaCandidateMax) { + return false; + } + + if (yCandGenMax >= 0. && std::abs(RecoDecay::y(mcCandidate.pVector(), o2::constants::physics::MassLambdaCPlus)) > yCandGenMax) { + return false; + } + + // Later on, if I want to add prompt/non-prompt selection, below is how to select prompt only + // if (!(particle.originMcGen() == RecoDecay::OriginType::Prompt)){ + // return false; + // } + } + } + + return true; + } + + // I am not sure if to template McParticles is useful, I'll address this when doing the MC Gen case of HF-h correlations + template + bool isAcceptedMftMcParticle(TMcParticle& mcParticle) { // remove MC particles with charge = 0 - TParticlePDG* pdgparticle = pdg->GetParticle(mcParticles.pdgCode()); + TParticlePDG* pdgparticle = pdg->GetParticle(mcParticle.pdgCode()); if (pdgparticle != nullptr) { if (pdgparticle->Charge() == 0) { return false; } } + /* // MC particle has to be primary if constexpr (step <= CorrelationContainer::kCFStepAnaTopology) { - return mcParticles.isPhysicalPrimary(); + return mcParticle.isPhysicalPrimary(); } - return true; + */ + + if (mcParticle.eta() > etaMftTrackMax || mcParticle.eta() < etaMftTrackMin) { + return false; + } + + // return true; + return mcParticle.isPhysicalPrimary(); } - // ========================= + // =============================================================================================================================================================================== + // =============================================================================================================================================================================== // Correlation functions - // ========================= + // =============================================================================================================================================================================== + // =============================================================================================================================================================================== + + // =============================================================================================================================================================================== + // fillCorrelations + // =============================================================================================================================================================================== template - void fillCorrelations(TTarget target, TTracksTrig const& tracks1, TTracksAssoc const& tracks2, float multiplicity, float posZ, bool sameEvent) + void fillCorrelations(TTarget target, + TTracksTrig const& tracks1, TTracksAssoc const& tracks2, + float multiplicity, float posZ, bool sameEvent) { auto triggerWeight = 1; auto associatedWeight = 1; @@ -1133,6 +882,9 @@ struct HfTaskFlow { // I fill it only for the first trigger track of the collision auto loopCounter = 0; + // + // TRIGGER PARTICLE + // for (const auto& track1 : tracks1) { loopCounter++; @@ -1150,7 +902,7 @@ struct HfTaskFlow { bool fillingHFcontainer = false; double invmass = 0; if constexpr (std::is_same_v || std::is_same_v) { - // TODO: Check how to put this into a Filter + // TODO: Check how to put this into a Filter -> Pretty sure it cannot be a filter if (!isAcceptedCandidate(track1)) { continue; } @@ -1164,15 +916,20 @@ struct HfTaskFlow { } } - // From Katarina's code - // in case of MC-generated, do additional selection on MCparticles : charge and isPhysicalPrimary - // if (processMc) { - // NOTE : this version with FilteredMcParticles is only for MC truth - if constexpr (std::is_same_v || std::is_same_v) { - if (!isMcParticleSelected(track1)) { + // Selections for MC GENERATED + if constexpr (std::is_same_v || std::is_same_v) { + // TODO: Check how to put this into a Filter -> Pretty sure it cannot be a filter + if (!isAcceptedMcCandidate(track1)) { continue; } - // TO-DO : add other if constexpr conditions when I will have more MC cases + fillingHFcontainer = true; + if constexpr (std::is_same_v) { // If D0 + invmass = o2::constants::physics::MassD0; + // Should add D0 bar ? + } else { // If Lc + invmass = o2::constants::physics::MassLambdaCPlus; + // Should add Lc bar ? (maybe not its the same mass right ?) + } } // fill single-track distributions @@ -1184,34 +941,39 @@ struct HfTaskFlow { // FILL QA PLOTS for trigger particle if (sameEvent) { - // if constexpr (std::is_same_v) { // If DATA - if constexpr (!std::is_same_v) { // IF TPC-TPC case - if constexpr (std::is_same_v) { // IF D0 CASE -> TPC-TPC D0-h - fillTpcTpcD0CandidateQa(multiplicity, track1); - } else if constexpr (std::is_same_v) { // IF LC CASE -> TPC-TPC Lc-h - fillTpcTpcLcCandidateQa(multiplicity, track1); - } else { // IF NEITHER D0 NOR LC -> TPC-TPC h-h - fillTpcTpcChChSameEventQa(multiplicity, track1); + if (processMc == false) { // If DATA + if constexpr (!std::is_same_v) { // IF TPC-TPC case + if constexpr (std::is_same_v) { // IF D0 CASE -> TPC-TPC D0-h + fillTpcTpcD0CandidateQa(multiplicity, track1); + } else if constexpr (std::is_same_v) { // IF LC CASE -> TPC-TPC Lc-h + fillTpcTpcLcCandidateQa(multiplicity, track1); + } else { // IF NEITHER D0 NOR LC -> TPC-TPC h-h + fillTpcTpcChChSameEventQa(multiplicity, track1); + } + } else { // IF TPC-MFT case + if constexpr (std::is_same_v) { // IF D0 CASE -> TPC-MFT D0-h + fillTpcMftD0CandidateQa(multiplicity, track1); + } else if constexpr (std::is_same_v) { // IF LC CASE -> TPC-MFT Lc-h + fillTpcMftLcCandidateQa(multiplicity, track1); + } else { // IF NEITHER D0 NOR LC -> TPC-MFT h-h + fillTpcMftChChSameEventQa(multiplicity, track1, true); + } // end of if condition for TPC-TPC or TPC-MFT case + } + // Maybe I won't need it for MC (first files are way lighter in MC, but also I need to loop over all tracks in MC GEN) + } else { // If MC (add cases later) + if constexpr (!std::is_same_v) { // IF TPC-TPC case + fillTpcTpcChChSameEventQaMc(multiplicity, track1); } - } else { // IF TPC-MFT case - if constexpr (std::is_same_v) { // IF D0 CASE -> TPC-MFT D0-h - fillTpcMftD0CandidateQa(multiplicity, track1); - } else if constexpr (std::is_same_v) { // IF LC CASE -> TPC-MFT Lc-h - fillTpcMftLcCandidateQa(multiplicity, track1); - } else { // IF NEITHER D0 NOR LC -> TPC-MFT h-h - fillTpcMftChChSameEventQa(multiplicity, track1, true); - } // end of if condition for TPC-TPC or TPC-MFT case } - // Maybe I won't need it for MC (first files are way lighter in MC, but also I need to loop over all tracks in MC GEN) - //} else { // If MC (add cases later) - // fillTpcTpcChChSameEventQaMc(multiplicityTracks2, vz, tracks1); - //} } + // + // ASSOCIATED PARTICLE + // for (const auto& track2 : tracks2) { // apply cuts for MFT tracks - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { if (!isAcceptedMftTrack(track2)) { continue; } @@ -1227,8 +989,8 @@ struct HfTaskFlow { // in case of HF-h correlations, remove candidate daughters from the pool of associated hadrons // with which the candidate is being correlated (will not have to do it for TPC-MFT case) - if constexpr (!std::is_same_v) { // if NOT TPC-MFT case -> TPC-TPC case - if constexpr (std::is_same_v) { // Remove the 2 prong daughters + if constexpr (!std::is_same_v) { // if NOT TPC-MFT case -> TPC-TPC case + if constexpr (std::is_same_v) { // Remove the 2 prong daughters if ((track1.prong0Id() == track2.globalIndex()) || (track1.prong1Id() == track2.globalIndex())) { continue; } @@ -1242,11 +1004,10 @@ struct HfTaskFlow { // in case of MC-generated, do additional selection on MCparticles : charge and isPhysicalPrimary // if (processMc) { - if constexpr (std::is_same_v || std::is_same_v) { - if (!isMcParticleSelected(track2)) { + if constexpr (std::is_same_v || std::is_same_v) { + if (!isAcceptedMftMcParticle(track2)) { continue; } - // Note : no need for HF if condition as this will always be normal track, but maybe for MFT } float eta2 = track2.eta(); @@ -1274,8 +1035,8 @@ struct HfTaskFlow { // FILL QA PLOTS for associated particle if (sameEvent && (loopCounter == 1)) { // if constexpr (std::is_same_v) { // If DATA - if constexpr (!std::is_same_v) { // IF TPC-TPC case - if constexpr (std::is_same_v) { // IF D0 CASE -> TPC-TPC D0-h + if constexpr (!std::is_same_v) { // IF TPC-TPC case + if constexpr (std::is_same_v) { // IF D0 CASE -> TPC-TPC D0-h fillTpcTpcHfChSameEventQa(multiplicity, track2); } else if constexpr (std::is_same_v) { // IF LC CASE -> TPC-TPC Lc-h fillTpcTpcHfChSameEventQa(multiplicity, track2); @@ -1299,23 +1060,30 @@ struct HfTaskFlow { } // end of loop over tracks 1 } + // =============================================================================================================================================================================== + // mixCollisions for RECONSTRUCTED events + // =============================================================================================================================================================================== + template - void mixCollisions(TCollisions const& collisions, TTracksTrig const& tracks1, TTracksAssoc const& tracks2, TLambda getPartsSize, OutputObj& corrContainer) + void mixCollisions(TCollisions const& collisions, + TTracksTrig const& tracks1, TTracksAssoc const& tracks2, + TLambda getPartsSize, + OutputObj& corrContainer) { // The first one that I call "Data" should work for data and mc rec using BinningTypeData = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getPartsSize)>; - BinningTypeData binningWithTracksSize{{getPartsSize}, {axisVertex, axisMultiplicity}, true}; + BinningTypeData binningWithTracksSize{{getPartsSize}, {binsMixingVertex, binsMixingMultiplicity}, true}; auto tracksTuple = std::make_tuple(tracks1, tracks2); Pair pair{binningWithTracksSize, nMixedEvents, -1, collisions, tracksTuple, &cache}; for (const auto& [collision1, tracks1, collision2, tracks2] : pair) { if constexpr (!std::is_same_v) { // if NOT MC -> do collision cut - if (!(isCollisionSelected(collision1, false))) { + if (!(isAcceptedCollision(collision1, false))) { continue; } - if (!(isCollisionSelected(collision2, false))) { + if (!(isAcceptedCollision(collision2, false))) { continue; } } @@ -1324,41 +1092,21 @@ struct HfTaskFlow { int bin = binningWithTracksSize.getBin(binningValues); const auto multiplicityTracks1 = getPartsSize(collision1); - const auto multiplicityTracks2 = getPartsSize(collision2); - // const auto multiplicityTracks1 = tracks1.size(); // get multiplicity of charged hadrons, which is used for slicing in mixing - // const auto multiplicityTracks2 = tracks2.size(); // get multiplicity of charged hadrons, which is used for slicing in mixing - const auto vz = collision1.posZ(); - if constexpr (std::is_same_v) { // If MC + if constexpr (std::is_same_v) { // If MC registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/MixedEvent/hEventCountMixing"), bin); - // fillTpcTpcChChMixedEventQaMc(multiplicityTracks2, vz, tracks1); - - // if constexpr (std::is_same_v || std::is_same_v) { - // registry.fill(HIST("Data/TpcTpc/HfHadron/MixedEvent/hEventCountHFMixing"), bin); - // fillHFMixingQA(multiplicity, vz, tracks1); - // } else { - // registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hEventCountMixing"), bin); - // fillMixingQA(multiplicity, vz, tracks1); - // } - } else { // If not MC - if constexpr (std::is_same_v) { // IF TPC-MFT case + if constexpr (std::is_same_v) { // IF TPC-MFT case if constexpr (std::is_same_v || std::is_same_v) { // IF HF-h case -> TPC-MFT HF-h registry.fill(HIST("Data/TpcMft/HfHadron/MixedEvent/hEventCountMixing"), bin); - fillTpcMftHfChMixedEventQa(multiplicityTracks1, vz, tracks1); // Candidates - fillTpcMftHfChMixedEventQa(multiplicityTracks2, vz, tracks2); // MFT tracks - } else { // IF h-h case -> TPC-MFT h-h case + } else { // IF h-h case -> TPC-MFT h-h case registry.fill(HIST("Data/TpcMft/HadronHadron/MixedEvent/hEventCountMixing"), bin); - fillTpcMftChChMixedEventQa(multiplicityTracks1, vz, tracks1); // TPC tracks - fillTpcMftChChMixedEventQa(multiplicityTracks2, vz, tracks2); // MFT tracks } } else { // IF TPC-TPC case if constexpr (std::is_same_v || std::is_same_v) { // IF HF-h case -> TPC-TPC HF-h registry.fill(HIST("Data/TpcTpc/HfHadron/MixedEvent/hEventCountHFMixing"), bin); - fillTpcTpcHfChMixedEventQa(multiplicityTracks2, vz, tracks1); } else { // IF h-h case -> TPC-TPC h-h case registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hEventCountMixing"), bin); - fillTpcTpcChChMixedEventQa(multiplicityTracks2, vz, tracks1); } } // end of if condition for TPC-TPC or TPC-MFT case } @@ -1368,62 +1116,55 @@ struct HfTaskFlow { } } - // template - // void mixCollisions(FilteredCollisionsWSelMult const& collisions, TTracksTrig const& tracks1, TTracksAssoc const& tracks2, TLambda getPartsSize, OutputObj& corrContainer) - template - void mixCollisionsMcTruth(TCollisions const& collisions, TTracksTrig const& tracks1, TTracksAssoc const& tracks2, TLambda getPartsSize, OutputObj& corrContainer) + // =============================================================================================================================================================================== + // mixCollisions for GENERATED events + // =============================================================================================================================================================================== + + template + void mixCollisionsMcTruth(TMcCollisions const& mcCollisions, + TTracksTrig const& tracks1, TTracksAssoc const& tracks2, + TLambda getPartsSize, OutputObj& corrContainer) { using BinningTypeMcTruth = FlexibleBinningPolicy, aod::mccollision::PosZ, decltype(getPartsSize)>; - BinningTypeMcTruth binningWithTracksSize{{getPartsSize}, {axisVertex, axisMultiplicity}, true}; + BinningTypeMcTruth binningWithTracksSize{{getPartsSize}, {binsMixingVertex, binsMixingMultiplicity}, true}; auto tracksTuple = std::make_tuple(tracks1, tracks2); - Pair pair{binningWithTracksSize, nMixedEvents, -1, collisions, tracksTuple, &cache}; + Pair pair{binningWithTracksSize, nMixedEvents, -1, mcCollisions, tracksTuple, &cache}; for (const auto& [collision1, tracks1, collision2, tracks2] : pair) { - // added this to try to compile when doing mixed event with FilteredMcParticles and FilteredMcCollisions (MC truth) - // TODO : GET RID OF THE COLLISION SELECTION FOR MC TRUTH - // if constexpr (!std::is_same_v) { - // if (!(isCollisionSelected(collision1, false))) { - // continue; - // } - // if (!(isCollisionSelected(collision2, false))) { - // continue; - // } - //} - - auto binningValues = binningWithTracksSize.getBinningValues(collision1, collisions); + auto binningValues = binningWithTracksSize.getBinningValues(collision1, mcCollisions); int bin = binningWithTracksSize.getBin(binningValues); - const auto multiplicity = tracks2.size(); // get multiplicity of charged hadrons, which is used for slicing in mixing - // const auto vz = collision1.posZ(); + const auto multiplicity = getPartsSize(collision1); // get multiplicity of charged hadrons, which is used for slicing in mixing // TO BE DONE : ADD ONE MORE IF CONDITION TO FILL THE MC CASE // TODO : FILL NEW PLOTS FOR MCTRUTH ONLY registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/MixedEvent/hEventCountMixing"), bin); - // fillTpcTpcChChMixedEventQaMc(multiplicity, vz, tracks1); - - // if constexpr (std::is_same_v || std::is_same_v) { - // registry.fill(HIST("Data/TpcTpc/HfHadron/MixedEvent/hEventCountHFMixing"), bin); - // fillHFMixingQA(multiplicity, vz, tracks1); - // } else { - // registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hEventCountMixing"), bin); - // fillMixingQA(multiplicity, vz, tracks1); - // } corrContainer->fillEvent(multiplicity, CorrelationContainer::kCFStepAll); fillCorrelations(corrContainer, tracks1, tracks2, multiplicity, collision1.posZ(), false); } } + // =================================================================================================================================================================================================================================================================== + // =================================================================================================================================================================================================================================================================== + // SAME EVENT PROCESS FUNCTIONS + // =================================================================================================================================================================================================================================================================== + // =================================================================================================================================================================================================================================================================== + + // =================================================================================================================================================================================================================================================================== + // DATA + // =================================================================================================================================================================================================================================================================== + // ===================================== // DATA : process same event correlations: TPC-TPC h-h case // ===================================== void processSameTpcTpcChCh(FilteredCollisionsWSelMult::iterator const& collision, - TracksWDcaSel const& tracks) + FilteredTracksWDcaSel const& tracks) { - if (!(isCollisionSelected(collision, true))) { + if (!(isAcceptedCollision(collision, true))) { return; } @@ -1432,7 +1173,6 @@ struct HfTaskFlow { // options are ran at the same time // temporary solution, since other correlation options always have to be ran with h-h, too // TODO: rewrite it in a more intelligent way - // const auto multiplicity = tracks.size(); const auto multiplicity = collision.multNTracksPV(); registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hMultiplicity"), multiplicity); registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hVtxZ"), collision.posZ()); @@ -1441,10 +1181,10 @@ struct HfTaskFlow { int bin = baseBinning.getBin(std::make_tuple(collision.posZ(), multiplicity)); registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hEventCountSame"), bin); - sameTPCTPCChCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + sameEvent->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); // TO-DO : add if condition for when we will implant corrected correlations (kCFStepReconstructed -> kCFStepCorrected) - fillCorrelations(sameTPCTPCChCh, tracks, tracks, multiplicity, collision.posZ(), true); + fillCorrelations(sameEvent, tracks, tracks, multiplicity, collision.posZ(), true); } PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcChCh, "DATA : Process same-event correlations for TPC-TPC h-h case", false); @@ -1453,7 +1193,7 @@ struct HfTaskFlow { // ===================================== void processSameTpcTpcD0Ch(FilteredCollisionsWSelMult::iterator const& collision, - TracksWDcaSel const& tracks, + FilteredTracksWDcaSel const& tracks, HfCandidatesSelD0 const& candidates) { auto fillEventSelectionPlots = true; @@ -1462,7 +1202,7 @@ struct HfTaskFlow { if (doReferenceFlow) fillEventSelectionPlots = false; - if (!(isCollisionSelected(collision, fillEventSelectionPlots))) { + if (!(isAcceptedCollision(collision, fillEventSelectionPlots))) { return; } @@ -1471,9 +1211,9 @@ struct HfTaskFlow { int bin = baseBinning.getBin(std::make_tuple(collision.posZ(), multiplicity)); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEventCountSame"), bin); - sameTPCTPCHfCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + sameEventHf->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCorrelations(sameTPCTPCHfCh, candidates, tracks, multiplicity, collision.posZ(), true); + fillCorrelations(sameEventHf, candidates, tracks, multiplicity, collision.posZ(), true); } PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcD0Ch, "DATA : Process same-event correlations for TPC-TPC D0-h case", false); @@ -1482,7 +1222,7 @@ struct HfTaskFlow { // ===================================== void processSameTpcTpcLcCh(FilteredCollisionsWSelMult::iterator const& collision, - TracksWDcaSel const& tracks, + FilteredTracksWDcaSel const& tracks, HfCandidatesSelLc const& candidates) { auto fillEventSelectionPlots = true; @@ -1491,7 +1231,7 @@ struct HfTaskFlow { if (doReferenceFlow) fillEventSelectionPlots = false; - if (!(isCollisionSelected(collision, fillEventSelectionPlots))) { + if (!(isAcceptedCollision(collision, fillEventSelectionPlots))) { return; } @@ -1500,9 +1240,9 @@ struct HfTaskFlow { int bin = baseBinning.getBin(std::make_tuple(collision.posZ(), multiplicity)); registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hEventCountSame"), bin); - sameTPCTPCHfCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + sameEventHf->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCorrelations(sameTPCTPCHfCh, candidates, tracks, multiplicity, collision.posZ(), true); + fillCorrelations(sameEventHf, candidates, tracks, multiplicity, collision.posZ(), true); } PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcLcCh, "DATA : Process same-event correlations for TPC-TPC Lc-h case", false); @@ -1511,10 +1251,10 @@ struct HfTaskFlow { // ===================================== void processSameTpcMftChCh(FilteredCollisionsWSelMult::iterator const& collision, - TracksWDcaSel const& tracks, - aod::MFTTracks const& mftTracks) + FilteredTracksWDcaSel const& tracks, + FilteredMftTracksWColls const& mftTracks) { - if (!(isCollisionSelected(collision, true))) { + if (!(isAcceptedCollision(collision, true))) { return; } @@ -1523,9 +1263,9 @@ struct HfTaskFlow { int bin = baseBinning.getBin(std::make_tuple(collision.posZ(), multiplicity)); registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hEventCountSame"), bin); - sameTPCMFTChCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + sameEvent->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCorrelations(sameTPCMFTChCh, tracks, mftTracks, multiplicity, collision.posZ(), true); + fillCorrelations(sameEvent, tracks, mftTracks, multiplicity, collision.posZ(), true); } PROCESS_SWITCH(HfTaskFlow, processSameTpcMftChCh, "DATA : Process same-event correlations for TPC-MFT h-h case", false); @@ -1535,8 +1275,8 @@ struct HfTaskFlow { void processSameTpcMftD0Ch(FilteredCollisionsWSelMult::iterator const& collision, HfCandidatesSelD0 const& candidates, - TracksWDcaSel const& /*tracks*/, - aod::MFTTracks const& mftTracks) + FilteredTracksWDcaSel const& /*tracks*/, + FilteredMftTracksWColls const& mftTracks) { auto fillEventSelectionPlots = true; @@ -1544,7 +1284,7 @@ struct HfTaskFlow { if (doReferenceFlow) fillEventSelectionPlots = false; - if (!(isCollisionSelected(collision, fillEventSelectionPlots))) { + if (!(isAcceptedCollision(collision, fillEventSelectionPlots))) { return; } @@ -1553,9 +1293,9 @@ struct HfTaskFlow { int bin = baseBinning.getBin(std::make_tuple(collision.posZ(), multiplicity)); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hEventCountSame"), bin); - sameTPCMFTHfCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + sameEventHf->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCorrelations(sameTPCMFTHfCh, candidates, mftTracks, multiplicity, collision.posZ(), true); + fillCorrelations(sameEventHf, candidates, mftTracks, multiplicity, collision.posZ(), true); } PROCESS_SWITCH(HfTaskFlow, processSameTpcMftD0Ch, "DATA : Process same-event correlations for TPC-MFT D0-h case", false); @@ -1565,8 +1305,8 @@ struct HfTaskFlow { void processSameTpcMftLcCh(FilteredCollisionsWSelMult::iterator const& collision, HfCandidatesSelLc const& candidates, - TracksWDcaSel const& /*tracks*/, - aod::MFTTracks const& mftTracks) + FilteredTracksWDcaSel const& /*tracks*/, + FilteredMftTracksWColls const& mftTracks) { auto fillEventSelectionPlots = true; @@ -1574,7 +1314,7 @@ struct HfTaskFlow { if (doReferenceFlow) fillEventSelectionPlots = false; - if (!(isCollisionSelected(collision, fillEventSelectionPlots))) { + if (!(isAcceptedCollision(collision, fillEventSelectionPlots))) { return; } @@ -1583,92 +1323,70 @@ struct HfTaskFlow { int bin = baseBinning.getBin(std::make_tuple(collision.posZ(), multiplicity)); registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hEventCountSame"), bin); - sameTPCMFTHfCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + sameEventHf->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCorrelations(sameTPCMFTHfCh, candidates, mftTracks, multiplicity, collision.posZ(), true); + fillCorrelations(sameEventHf, candidates, mftTracks, multiplicity, collision.posZ(), true); } PROCESS_SWITCH(HfTaskFlow, processSameTpcMftLcCh, "DATA : Process same-event correlations for TPC-MFT Lc-h case", false); + // =================================================================================================================================================================================================================================================================== + // MONTE-CARLO + // =================================================================================================================================================================================================================================================================== + // ===================================== - // MONTE-CARLO : process same event correlations: TPC-TPC h-h case + // MONTE-CARLO GENERATED : process same event correlations : TPC-MFT D0-ch. part. case // ===================================== - void processSameTpcTpcChChmcREC(FilteredCollisionsWSelMultMC::iterator const& mcCollision, - TracksWDcaSelMC const& mcTracks) + void processSameTpcMftD0ChMcGen(FilteredMcCollisions::iterator const& mcCollision, + McParticles2ProngMatched const& mcParticles2Prong, + McParticles const& mcParticles) { - - // NEED TO COMMENT THIS - // if (!(isCollisionSelected(mcCollision, true))) { - // return; - //} - - const auto multiplicity = mcCollision.multNTracksPV(); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hMultiplicity"), multiplicity); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hVtxZ"), mcCollision.posZ()); + const auto multiplicity = mcCollision.multMCPVz(); BinningPolicyBase<2> baseBinning{{axisVertex, axisMultiplicity}, true}; - int bin = baseBinning.getBin(std::make_tuple(mcCollision.posZ(), multiplicity)); - registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hEventCountSame"), bin); - - sameTPCTPCChChMC->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + // int bin = baseBinning.getBin(std::make_tuple(mcCollision.posZ(), multiplicity)); + // registry.fill(HIST("MC/Gen/TpcMft/HfHadron/SameEvent/2Prong/hEventCountSame"), bin); - fillTpcTpcChChSameEventQaMc(multiplicity, mcTracks); - fillCorrelations(sameTPCTPCChChMC, mcTracks, mcTracks, multiplicity, mcCollision.posZ(), true); + sameEventHfMc->fillEvent(multiplicity, CorrelationContainer::kCFStepAll); + fillCorrelations(sameEventHfMc, mcParticles2Prong, mcParticles, multiplicity, mcCollision.posZ(), true); } - PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcChChmcREC, "MONTE-CARLO : Process same-event correlations for TPC-TPC h-h case", false); + PROCESS_SWITCH(HfTaskFlow, processSameTpcMftD0ChMcGen, "MONTE-CARLO : Process same-event correlations for TPC-MFT D0-h case", false); - // Katarina's version = MC Truth - void processSameTpcTpcChChmcGEN(FilteredMcCollisions::iterator const& mcCollision, - FilteredMcParticles const& mcParticles) - { - - // if (!(isCollisionSelected(mcCollision, true))) { - // return; - // } + // ===================================== + // MONTE-CARLO GENERATED : process same event correlations : TPC-MFT Lc-ch. part. case + // ===================================== - // Not sure why to use this - // if (collisions.size() == 0) { - // return; - //} + void processSameTpcMftLcChMcGen(FilteredMcCollisions::iterator const& mcCollision, + McParticles3ProngMatched const& mcParticles3Prong, + McParticles const& mcParticles) + { + const auto multiplicity = mcCollision.multMCPVz(); - // if (!collision.has_mcCollision()) { - // LOGF(info, "No MC collision for this collision, skip..."); - // return; - // } + BinningPolicyBase<2> baseBinning{{axisVertex, axisMultiplicity}, true}; + // int bin = baseBinning.getBin(std::make_tuple(mcCollision.posZ(), multiplicity)); + // registry.fill(HIST("MC/Gen/TpcMft/HfHadron/SameEvent/2Prong/hEventCountSame"), bin); - // TODO : check if I have to get my multiplicity based on multNTracksPV or mcParticles.size() - const auto multiplicity = mcParticles.size(); // Note: these are all MC particles after selection (not only primary) - // const auto multiplicity = collision.multNTracksPV(); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hMultiplicity"), multiplicity); - registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hVtxZ"), mcCollision.posZ()); + sameEventHfMc->fillEvent(multiplicity, CorrelationContainer::kCFStepAll); + fillCorrelations(sameEventHfMc, mcParticles3Prong, mcParticles, multiplicity, mcCollision.posZ(), true); + } + PROCESS_SWITCH(HfTaskFlow, processSameTpcMftLcChMcGen, "MONTE-CARLO : Process same-event correlations for TPC-MFT Lc-h case", false); - // fill correlations for all MC collisions - // In Katka's code, the first time doing this does not fill the histograms, right now will be filled two times.. - auto multPrimaryCharge0 = fillTpcTpcChChSameEventQaMc(multiplicity, mcParticles); - sameTPCTPCChChMC->fillEvent(multPrimaryCharge0, CorrelationContainer::kCFStepAll); - fillCorrelations(sameTPCTPCChChMC, mcParticles, mcParticles, multPrimaryCharge0, mcCollision.posZ(), true); + // =================================================================================================================================================================================================================================================================== + // =================================================================================================================================================================================================================================================================== + // MIXED EVENT PROCESS FUNCTIONS + // =================================================================================================================================================================================================================================================================== + // =================================================================================================================================================================================================================================================================== - // NOT USED BY KATARINA APPARENTLY - // BinningPolicyBase<2> baseBinning{{axisVertex, axisMultiplicity}, true}; - // int bin = baseBinning.getBin(std::make_tuple(mcCollision.posZ(), multiplicity)); - // registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hEventCountSame"), bin); - - // TO-DO : fill correlation container for MC collisions that have a reconstructed collision - // got rid of the second const auto for multPrimaryCharge0 - // This line below for sure induce that some plots are filled two times - // multPrimaryCharge0 = fillTpcTpcChChSameEventQaMc(multiplicity, mcParticles); - // sameTPCTPCChChMC->fillEvent(multPrimaryCharge0, CorrelationContainer::kCFStepVertex); - // fillCorrelations(sameTPCTPCChChMC, mcParticles, mcParticles, multPrimaryCharge0, mcCollision.posZ(), true); - } - PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcChChmcGEN, "MONTE-CARLO : Process same-event correlations for TPC-TPC h-h case", false); + // =================================================================================================================================================================================================================================================================== + // DATA + // =================================================================================================================================================================================================================================================================== // ===================================== // DATA : process mixed event correlations:TPC-TPC h-h case // ===================================== - // TO BECOME DATA & MC REC ? void processMixedTpcTpcChCh(FilteredCollisionsWSelMult const& collisions, - TracksWDcaSel const& tracks) + FilteredTracksWDcaSel const& tracks) { // we want to group collisions based on charged-track multiplicity // auto getTracksSize = [&tracks, this](FilteredCollisionsWSelMult::iterator const& col) { @@ -1682,8 +1400,8 @@ struct HfTaskFlow { return multiplicity; }; - // mixCollisions(collisions, tracks, tracks, getTracksSize, mixedTPCTPCChCh); - mixCollisions(collisions, tracks, tracks, getMultiplicity, mixedTPCTPCChCh); + // mixCollisions(collisions, tracks, tracks, getTracksSize, mixedEvent); + mixCollisions(collisions, tracks, tracks, getMultiplicity, mixedEvent); } PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcChCh, "DATA : Process mixed-event correlations for TPC-TPC h-h case", false); @@ -1692,16 +1410,15 @@ struct HfTaskFlow { // ===================================== void processMixedTpcTpcD0Ch(FilteredCollisionsWSelMult const& collisions, - TracksWDcaSel const& tracks, + FilteredTracksWDcaSel const& tracks, HfCandidatesSelD0 const& candidates) { - // we want to group collisions based on charged-track multiplicity auto getMultiplicity = [](FilteredCollisionsWSelMult::iterator const& collision) { auto multiplicity = collision.numContrib(); return multiplicity; }; - mixCollisions(collisions, candidates, tracks, getMultiplicity, mixedTPCTPCHfCh); + mixCollisions(collisions, candidates, tracks, getMultiplicity, mixedEventHf); } PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcD0Ch, "DATA : Process mixed-event correlations for TPC-TPC D0-h case", false); @@ -1710,18 +1427,15 @@ struct HfTaskFlow { // ===================================== void processMixedTpcTpcLcCh(FilteredCollisionsWSelMult const& collisions, - TracksWDcaSel const& tracks, + FilteredTracksWDcaSel const& tracks, HfCandidatesSelLc const& candidates) { - // we want to group collisions based on charged-track multiplicity - auto getTracksSize = [&tracks, this](FilteredCollisionsWSelMult::iterator const& col) { - // Still o2::aod::track::collisionId with HF ??? -> I don't think so - auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, col.globalIndex(), this->cache); - auto size = associatedTracks.size(); - return size; + auto getMultiplicity = [](FilteredCollisionsWSelMult::iterator const& collision) { + auto multiplicity = collision.numContrib(); + return multiplicity; }; - mixCollisions(collisions, candidates, tracks, getTracksSize, mixedTPCTPCHfCh); + mixCollisions(collisions, candidates, tracks, getMultiplicity, mixedEventHf); } PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcLcCh, "DATA : Process mixed-event correlations for TPC-TPC Lc-h case", false); @@ -1730,22 +1444,15 @@ struct HfTaskFlow { // ===================================== void processMixedTpcMftChCh(FilteredCollisionsWSelMult const& collisions, - TracksWDcaSel const& tracks, - aod::MFTTracks const& mftTracks) + FilteredTracksWDcaSel const& tracks, + FilteredMftTracksWColls const& mftTracks) { - // we want to group collisions based on charged-track multiplicity - // auto getTracksSize = [&tracks, this](FilteredCollisionsWSelMult::iterator const& col) { - // auto associatedTracks = tracks.sliceByCached(o2::aod::track::collisionId, col.globalIndex(), this->cache); - // auto size = associatedTracks.size(); - // return size; - // }; - auto getMultiplicity = [](FilteredCollisionsWSelMult::iterator const& collision) { auto multiplicity = collision.numContrib(); return multiplicity; }; - mixCollisions(collisions, tracks, mftTracks, getMultiplicity, mixedTPCMFTChCh); + mixCollisions(collisions, tracks, mftTracks, getMultiplicity, mixedEvent); } PROCESS_SWITCH(HfTaskFlow, processMixedTpcMftChCh, "DATA : Process mixed-event correlations for TPC-MFT h-h case", false); @@ -1755,16 +1462,15 @@ struct HfTaskFlow { void processMixedTpcMftD0Ch(FilteredCollisionsWSelMult const& collisions, HfCandidatesSelD0 const& candidates, - aod::MFTTracks const& mftTracks, - TracksWDcaSel const& /*tracks*/) + FilteredMftTracksWColls const& mftTracks, + FilteredTracksWDcaSel const& /*tracks*/) { - // we want to group collisions based on charged-track multiplicity auto getMultiplicity = [](FilteredCollisionsWSelMult::iterator const& collision) { auto multiplicity = collision.numContrib(); return multiplicity; }; - mixCollisions(collisions, candidates, mftTracks, getMultiplicity, mixedTPCMFTHfCh); + mixCollisions(collisions, candidates, mftTracks, getMultiplicity, mixedEventHf); } PROCESS_SWITCH(HfTaskFlow, processMixedTpcMftD0Ch, "DATA : Process mixed-event correlations for TPC-MFT D0-h case", false); @@ -1774,58 +1480,107 @@ struct HfTaskFlow { void processMixedTpcMftLcCh(FilteredCollisionsWSelMult const& collisions, HfCandidatesSelLc const& candidates, - aod::MFTTracks const& mftTracks) + FilteredMftTracksWColls const& mftTracks) { - - // we want to group collisions based on charged-track multiplicity auto getMultiplicity = [](FilteredCollisionsWSelMult::iterator const& collision) { auto multiplicity = collision.numContrib(); return multiplicity; }; - mixCollisions(collisions, candidates, mftTracks, getMultiplicity, mixedTPCMFTHfCh); + mixCollisions(collisions, candidates, mftTracks, getMultiplicity, mixedEventHf); } PROCESS_SWITCH(HfTaskFlow, processMixedTpcMftLcCh, "DATA : Process mixed-event correlations for TPC-MFT Lc-h case", false); + // =================================================================================================================================================================================================================================================================== + // MONTE-CARLO + // =================================================================================================================================================================================================================================================================== + // ===================================== - // MONTE-CARLO : process mixed event correlations: TPC-TPC h-h case + // MONTE-CARLO GENERATED : process mixed event correlations: TPC-MFT D0-ch. part. case // ===================================== - // MC rec - void processMixedTpcTpcChChmcREC(FilteredCollisionsWSelMultMC const& mcCollisions, - TracksWDcaSelMC const& mcTracks) + void processMixedTpcMftD0ChMcGen(FilteredMcCollisions const& mcCollisions, + McParticles2ProngMatched const& mcParticles2Prong, + McParticles const& mcParticles) { - // use normal index instead of globalIndex for MixedEvent ?? - - // we want to group collisions based on charged-track multiplicity - auto getTracksSize = [&mcTracks, this](FilteredCollisionsWSelMultMC::iterator const& mcCol) { - auto associatedTracks = mcTracks.sliceByCached(o2::aod::track::collisionId, mcCol.globalIndex(), this->cache); // it's cached, so slicing/grouping happens only once - auto size = associatedTracks.size(); - return size; + auto getMultiplicity = [](FilteredMcCollisions::iterator const& mcCollision) { + auto multiplicity = mcCollision.multMCPVz(); + return multiplicity; }; - mixCollisions(mcCollisions, mcTracks, mcTracks, getTracksSize, mixedTPCTPCChChMC); + mixCollisionsMcTruth(mcCollisions, mcParticles2Prong, mcParticles, getMultiplicity, mixedEventHfMc); } - PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcChChmcREC, "MONTE-CARLO : Process mixed-event correlations for TPC-TPC h-h case", false); + PROCESS_SWITCH(HfTaskFlow, processMixedTpcMftD0ChMcGen, "MONTE-CARLO : Process mixed-event correlations for TPC-MFT D0-h case", false); - // MC gen - void processMixedTpcTpcChChmcGEN(FilteredMcCollisions const& mcCollisions, - FilteredMcParticles const& mcParticles) - { - // use normal index instead of globalIndex for MixedEvent ?? + // ===================================== + // MONTE-CARLO GENERATED : process mixed event correlations: TPC-MFT Lc-ch. part. case + // ===================================== - // we want to group collisions based on charged-track multiplicity - auto getTracksSize = [&mcParticles, this](FilteredMcCollisions::iterator const& mcCol) { - auto associatedTracks = mcParticles.sliceByCached(o2::aod::mcparticle::mcCollisionId, mcCol.globalIndex(), this->cache); // it's cached, so slicing/grouping happens only once - auto size = associatedTracks.size(); - return size; + void processMixedTpcMftLcChMcGen(FilteredMcCollisions const& mcCollisions, + McParticles3ProngMatched const& mcParticles3Prong, + McParticles const& mcParticles) + { + auto getMultiplicity = [](FilteredMcCollisions::iterator const& mcCollision) { + auto multiplicity = mcCollision.multMCPVz(); + return multiplicity; }; - mixCollisionsMcTruth(mcCollisions, mcParticles, mcParticles, getTracksSize, mixedTPCTPCChChMC); + mixCollisionsMcTruth(mcCollisions, mcParticles3Prong, mcParticles, getMultiplicity, mixedEventHfMc); + } + PROCESS_SWITCH(HfTaskFlow, processMixedTpcMftLcChMcGen, "MONTE-CARLO : Process mixed-event correlations for TPC-MFT D0-h case", false); + + // =================================================================================================================================================================================================================================================================== + // =================================================================================================================================================================================================================================================================== + // EFFICIENCIES PROCESS FUNCTIONS + // =================================================================================================================================================================================================================================================================== + // =================================================================================================================================================================================================================================================================== + + // NOTE SmallGroups includes soa::Filtered always -> in the smallGroups there is the equivalent of FilteredCollisionsWSelMultMcLabels + void processMcEfficiencyMft(FilteredMcCollisions::iterator const& mcCollision, + McParticles const& mcParticles, + soa::SmallGroups> const& collisionsMcLabels, + FilteredMftTracksWCollsMcLabels const& mftTTracksMcLabels) + { + LOGF(info, "MC collision at vtx-z = %f with %d mc particles and %d reconstructed collisions", mcCollision.posZ(), mcParticles.size(), collisionsMcLabels.size()); - // TO-DO : mixed event for particles that have a reconstructed collision kCFStepVertex + auto multiplicity = mcCollision.multMCPVz(); + if (centralityBinsForMc) { + if (collisionsMcLabels.size() == 0) { + return; + } + for (const auto& collision : collisionsMcLabels) { + multiplicity = collision.multNTracksPV(); + } + } + + // Primaries + for (const auto& mcParticle : mcParticles) { + if (!isAcceptedMftMcParticle(mcParticle)) { + sameEventHf->getTrackHistEfficiency()->Fill(CorrelationContainer::MC, mcParticle.eta(), mcParticle.pt(), getSpecies(mcParticle.pdgCode()), multiplicity, mcCollision.posZ()); + } + } + for (const auto& collision : collisionsMcLabels) { + auto groupedMftTTracksMcLabels = mftTTracksMcLabels.sliceBy(mftTracksPerCollision, collision.globalIndex()); + LOGF(info, " Reconstructed collision at vtx-z = %f", collision.posZ()); + LOGF(info, " which has %d mft tracks", groupedMftTTracksMcLabels.size()); + + for (const auto& mftTrack : groupedMftTTracksMcLabels) { + if (mftTrack.has_mcParticle()) { + const auto& mcParticle = mftTrack.mcParticle(); + if (!isAcceptedMftMcParticle(mcParticle)) { + sameEventHf->getTrackHistEfficiency()->Fill(CorrelationContainer::RecoPrimaries, mcParticle.eta(), mcParticle.pt(), getSpecies(mcParticle.pdgCode()), multiplicity, mcCollision.posZ()); + } + sameEventHf->getTrackHistEfficiency()->Fill(CorrelationContainer::RecoAll, mcParticle.eta(), mcParticle.pt(), getSpecies(mcParticle.pdgCode()), multiplicity, mcCollision.posZ()); + } else { + // fake track + // In the MFT the measurement of pT is not precise + sameEventHf->getTrackHistEfficiency()->Fill(CorrelationContainer::Fake, mftTrack.eta(), mftTrack.pt(), 0, multiplicity, mcCollision.posZ()); + } + } + } } - PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcChChmcGEN, "MONTE-CARLO : Process mixed-event correlations for TPC-TPC h-h case", false); + PROCESS_SWITCH(HfTaskFlow, processMcEfficiencyMft, "MONTE-CARLO : Extract efficiencies for MFT tracks", false); + }; // End of struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/HFC/Utils/utilsCorrelations.h b/PWGHF/HFC/Utils/utilsCorrelations.h index 20d007b3e29..56fc5e435e2 100644 --- a/PWGHF/HFC/Utils/utilsCorrelations.h +++ b/PWGHF/HFC/Utils/utilsCorrelations.h @@ -16,10 +16,22 @@ #ifndef PWGHF_HFC_UTILS_UTILSCORRELATIONS_H_ #define PWGHF_HFC_UTILS_UTILSCORRELATIONS_H_ -#include +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" + +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" + +#include +#include +#include + #include -#include "CommonConstants/PhysicsConstants.h" +#include + +#include +#include namespace o2::analysis::hf_correlations { @@ -38,12 +50,16 @@ enum PairSign { LcNegTrkNeg }; +constexpr float PhiTowardMax{o2::constants::math::PIThird}; +constexpr float PhiAwayMin{2.f * o2::constants::math::PIThird}; +constexpr float PhiAwayMax{4.f * o2::constants::math::PIThird}; + template Region getRegion(T const deltaPhi) { - if (std::abs(deltaPhi) < o2::constants::math::PIThird) { + if (std::abs(deltaPhi) < PhiTowardMax) { return Toward; - } else if (deltaPhi > 2. * o2::constants::math::PIThird && deltaPhi < 4. * o2::constants::math::PIThird) { + } else if (deltaPhi > PhiAwayMin && deltaPhi < PhiAwayMax) { return Away; } else { return Transverse; @@ -112,15 +128,76 @@ bool passPIDSelection(Atrack const& track, SpeciesContainer const mPIDspecies, return true; // Passed all checks } +/// @brief Selects a candidate based on its PDG code, decay channel, and assigns the corresponding mass. +/// +/// @tparam isScCandidate Boolean template parameter: +/// - `true` to check for Sigma_c candidates +/// - `false` to check for Lambda_c candidates +/// @tparam McParticleType Type representing the MC particle, must provide `pdgCode()` and `flagMcMatchGen()` +/// +/// @param[in] particle MC particle whose PDG code and decay flag are evaluated +/// @param[out] massCand Mass of the matched candidate is set here, if a valid match is found +/// +/// @return `true` if candidate matches expected PDG and decay flag, and mass is set; `false` otherwise +template +bool matchCandAndMass(McParticleType const& particle, double& massCand) +{ + const auto pdgCand = std::abs(particle.pdgCode()); + const auto matchGenFlag = std::abs(particle.flagMcMatchGen()); + + // Validate PDG code based on candidate type + if (isScCandidate) { + if (!(pdgCand == o2::constants::physics::Pdg::kSigmaC0 || + pdgCand == o2::constants::physics::Pdg::kSigmaCPlusPlus || + pdgCand == o2::constants::physics::Pdg::kSigmaCStar0 || + pdgCand == o2::constants::physics::Pdg::kSigmaCStarPlusPlus)) { + return false; + } + } else { + if (pdgCand != o2::constants::physics::Pdg::kLambdaCPlus) { + return false; + } + } + + // Map decay type to mass + switch (matchGenFlag) { + case BIT(aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi): { + massCand = o2::constants::physics::MassSigmaC0; + return true; + } + + case BIT(aod::hf_cand_sigmac::DecayType::ScStar0ToPKPiPi): { + massCand = o2::constants::physics::MassSigmaCStar0; + return true; + } + + case BIT(aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi): { + massCand = o2::constants::physics::MassSigmaCStarPlusPlus; + return true; + } + + case BIT(aod::hf_cand_sigmac::DecayType::ScStarPlusPlusToPKPiPi): { + massCand = o2::constants::physics::MassSigmaCStarPlusPlus; + return true; + } + + case hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi: { + massCand = o2::constants::physics::MassLambdaCPlus; + return true; + } + + default: { + return false; + } + } +} + // ========= Find Leading Particle ============== -template -int findLeadingParticle(TTracks const& tracks, T1 const dcaXYTrackMax, T2 const dcaZTrackMax, T3 const etaTrackMax) +template //// FIXME: 14 days +int findLeadingParticle(TTracks const& tracks, T1 const etaTrackMax) { auto leadingParticle = tracks.begin(); for (auto const& track : tracks) { - if (std::abs(track.dcaXY()) >= dcaXYTrackMax || std::abs(track.dcaZ()) >= dcaZTrackMax) { - continue; - } if (std::abs(track.eta()) > etaTrackMax) { continue; } diff --git a/PWGHF/HFJ/CMakeLists.txt b/PWGHF/HFJ/CMakeLists.txt index bbfd7adac2b..62f88c324cf 100644 --- a/PWGHF/HFJ/CMakeLists.txt +++ b/PWGHF/HFJ/CMakeLists.txt @@ -7,4 +7,4 @@ # # 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. +# or submit itself to any jurisdiction. \ No newline at end of file diff --git a/PWGHF/HFL/DataModel/ElectronSelectionTable.h b/PWGHF/HFL/DataModel/ElectronSelectionTable.h index ecf50e1e3de..cae859d08f1 100644 --- a/PWGHF/HFL/DataModel/ElectronSelectionTable.h +++ b/PWGHF/HFL/DataModel/ElectronSelectionTable.h @@ -18,11 +18,14 @@ #ifndef PWGHF_HFL_DATAMODEL_ELECTRONSELECTIONTABLE_H_ #define PWGHF_HFL_DATAMODEL_ELECTRONSELECTIONTABLE_H_ -#include "Framework/AnalysisDataModel.h" +#include +#include + +#include namespace o2::aod { -// definition of columns and tables forElectron Selection +// definition of columns and tables for electron selection namespace hf_sel_electron { DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! collisioniD of the electron track @@ -31,11 +34,11 @@ DECLARE_SOA_COLUMN(EtaTrack, etaTrack, float); //! pseudorapidit DECLARE_SOA_COLUMN(PhiTrack, phiTrack, float); //! azimuth of the electron track DECLARE_SOA_COLUMN(PtTrack, ptTrack, float); //! transverse momentum of the electron track DECLARE_SOA_COLUMN(PTrack, pTrack, float); //! momentum of the electron track -DECLARE_SOA_COLUMN(RapidityTrack, rapadityTrack, float); //! rapidity of the electron track +DECLARE_SOA_COLUMN(RapidityTrack, rapidityTrack, float); //! rapidity of the electron track DECLARE_SOA_COLUMN(DcaXYTrack, dcaXYTrack, float); //! dca of the electron in xy direction DECLARE_SOA_COLUMN(DcaZTrack, dcaZTrack, float); //! dca of the electron in z direction -DECLARE_SOA_COLUMN(TPCNSigmaElTrack, tpcNSigmaElTrack, float); //! tpcNSigma of the electron track(TPC PID) -DECLARE_SOA_COLUMN(TOFNSigmaElTrack, tofNSigmaElTrack, float); //! tofNSigma of the electron track(TOF PID) +DECLARE_SOA_COLUMN(TpcNSigmaElTrack, tpcNSigmaElTrack, float); //! tpcNSigma of the electron track(TPC PID) +DECLARE_SOA_COLUMN(TofNSigmaElTrack, tofNSigmaElTrack, float); //! tofNSigma of the electron track(TOF PID) // EMCal cluster values DECLARE_SOA_COLUMN(EnergyEmcCluster, energyEmcCluster, float); //! energy of the EMCal cluster @@ -48,11 +51,9 @@ DECLARE_SOA_COLUMN(TimeEmcCluster, timeEmcCluster, float); //! time of the DECLARE_SOA_COLUMN(DeltaEtaMatch, deltaEtaMatch, float); //! dEta matched track to EMCal cluster DECLARE_SOA_COLUMN(DeltaPhiMatch, deltaPhiMatch, float); //! dPhi matched track to EMCal cluster -DECLARE_SOA_COLUMN(ISEmcal, isEmcal, bool); //! electron information with Emcal - +DECLARE_SOA_COLUMN(IsEmcal, isEmcal, bool); //! electron information with Emcal } // namespace hf_sel_electron DECLARE_SOA_TABLE(HfSelEl, "AOD", "HFSELEL", //! Electron Informations - o2::soa::Index<>, hf_sel_electron::CollisionId, hf_sel_electron::TrackId, hf_sel_electron::EtaTrack, @@ -62,8 +63,8 @@ DECLARE_SOA_TABLE(HfSelEl, "AOD", "HFSELEL", //! Electron Informations hf_sel_electron::RapidityTrack, hf_sel_electron::DcaXYTrack, hf_sel_electron::DcaZTrack, - hf_sel_electron::TPCNSigmaElTrack, - hf_sel_electron::TOFNSigmaElTrack, + hf_sel_electron::TpcNSigmaElTrack, + hf_sel_electron::TofNSigmaElTrack, hf_sel_electron::EnergyEmcCluster, hf_sel_electron::EtaEmcCluster, hf_sel_electron::PhiEmcCluster, @@ -73,8 +74,53 @@ DECLARE_SOA_TABLE(HfSelEl, "AOD", "HFSELEL", //! Electron Informations hf_sel_electron::TimeEmcCluster, hf_sel_electron::DeltaEtaMatch, hf_sel_electron::DeltaPhiMatch, - hf_sel_electron::ISEmcal); + hf_sel_electron::IsEmcal); +// definition of columns and tables for HfcorrElectron Selection +namespace hf_corr_sel_electron +{ +DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! collisioniD of the electron track +DECLARE_SOA_INDEX_COLUMN(Track, track); //! trackid of of the electron track +DECLARE_SOA_COLUMN(EtaTrack, etaTrack, float); //! pseudorapidity of the electron track +DECLARE_SOA_COLUMN(PhiTrack, phiTrack, float); //! azimuth of the electron track +DECLARE_SOA_COLUMN(PtTrack, ptTrack, float); //! transverse momentum of the electron track +DECLARE_SOA_COLUMN(TpcNSigmaElTrack, tpcNSigmaElTrack, float); //! tpcNSigma of the electron track(TPC PID) +DECLARE_SOA_COLUMN(TofNSigmaElTrack, tofNSigmaElTrack, float); //! tofNSigma of the electron track(TOF PID) +DECLARE_SOA_COLUMN(NElPairLS, nElPairLS, int); //! Number of Like sign electron pair +DECLARE_SOA_COLUMN(NElPairUS, nElPairUS, int); //! Number of UnLike sign electron pair +DECLARE_SOA_COLUMN(IsEmcal, isEmcal, bool); //! electron information +} // namespace hf_corr_sel_electron + +DECLARE_SOA_TABLE(HfCorrSelEl, "AOD", "HfCORRSELEL", //! Electron Informations + hf_corr_sel_electron::CollisionId, + hf_corr_sel_electron::TrackId, + hf_corr_sel_electron::EtaTrack, + hf_corr_sel_electron::PhiTrack, + hf_corr_sel_electron::PtTrack, + hf_corr_sel_electron::TpcNSigmaElTrack, + hf_corr_sel_electron::TofNSigmaElTrack, + hf_corr_sel_electron::NElPairLS, + hf_corr_sel_electron::NElPairUS, + hf_corr_sel_electron::IsEmcal); + +// definition of columns and tables for Mc Gen HfElectron Selection +namespace hf_mcgen_sel_electron +{ +DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); //! collisioniD of the electron track +DECLARE_SOA_INDEX_COLUMN(Track, track); //! trackid of of the electron track +DECLARE_SOA_COLUMN(EtaTrackMc, etaTrackMc, float); //! pseudorapidity of the electron track +DECLARE_SOA_COLUMN(PhiTrackMc, phiTrackMc, float); //! azimuth of the electron track +DECLARE_SOA_COLUMN(PtTrackMc, ptTrackMc, float); //! transverse momentum of the electron track +DECLARE_SOA_COLUMN(IsNonHfeMc, isNonHfeMc, bool); //! Non-Heavy flavour electron information + +} // namespace hf_mcgen_sel_electron +DECLARE_SOA_TABLE(HfMcGenSelEl, "AOD", "HFMCGENSELEL", //! Electron Informations + hf_mcgen_sel_electron::McCollisionId, + hf_mcgen_sel_electron::TrackId, + hf_mcgen_sel_electron::EtaTrackMc, + hf_mcgen_sel_electron::PhiTrackMc, + hf_mcgen_sel_electron::PtTrackMc, + hf_mcgen_sel_electron::IsNonHfeMc); } // namespace o2::aod #endif // PWGHF_HFL_DATAMODEL_ELECTRONSELECTIONTABLE_H_ diff --git a/PWGHF/HFL/TableProducer/CMakeLists.txt b/PWGHF/HFL/TableProducer/CMakeLists.txt index 8782812337b..69f571377c8 100644 --- a/PWGHF/HFL/TableProducer/CMakeLists.txt +++ b/PWGHF/HFL/TableProducer/CMakeLists.txt @@ -11,6 +11,10 @@ o2physics_add_dpl_workflow(electron-selection-with-tpc-emcal SOURCES electronSelectionWithTpcEmcal.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore KFParticle::KFParticle COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(tree-creator-electron-d-c-a + SOURCES treeCreatorElectronDCA.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGHF/HFL/TableProducer/electronSelectionWithTpcEmcal.cxx b/PWGHF/HFL/TableProducer/electronSelectionWithTpcEmcal.cxx index cd583c3a83f..94bad334ce4 100644 --- a/PWGHF/HFL/TableProducer/electronSelectionWithTpcEmcal.cxx +++ b/PWGHF/HFL/TableProducer/electronSelectionWithTpcEmcal.cxx @@ -14,25 +14,38 @@ /// \author Rashi Gupta , IIT Indore /// \author Ravindra Singh , IIT Indore -#include -#include "THnSparse.h" - -#include "DataFormatsEMCAL/AnalysisCluster.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/HFL/DataModel/ElectronSelectionTable.h" +#include "PWGJE/DataModel/EMCALClusters.h" -#include "Common/Core/PID/TPCPIDResponse.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/Centrality.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "Tools/KFparticle/KFUtilities.h" -#include "PWGJE/DataModel/EMCALClusters.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "PWGHF/HFL/DataModel/ElectronSelectionTable.h" +#include + +#include +#include + +#include +#include +#include using namespace o2; using namespace o2::constants::physics; @@ -40,40 +53,24 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -const int etaAxisBins = 100; -const float trackEtaAxisMin = -1.5; -const float trackEtaAxisMax = 1.5; -const int phiAxisBins = 100; -const float trackPhiAxisMin = 0.; -const float trackPhiAxisMax = o2::constants::math::TwoPI; -const int passEMCalBins = 3; -const int passEMCalAxisMin = 0.; -const int passEMCalAxisMax = 3; -const int eopAxisBins = 60; -const float eopAxisMin = 0.; -const float eopAxisMax = 3.0; -const int pAxisBins = 500; -const float pAxisMin = 0.; -const float pAxisMax = 50.0; -const int m02AxisBins = 100; -const float m02AxisMin = 0.; -const float m02AxisMax = 2.0; -const int m20AxisBins = 100; -const float m20AxisMin = 0.; -const float m20AxisMax = 2.0; -const int nSigmaAxisBins = 300; -const float nSigmaAxisMin = -15.; -const float nSigmaAxisMax = 15.; -const int dEdxAxisBins = 480; -const float dEdxAxisMin = 0.; -const float dEdxAxisMax = 160.; +const int kEta = 221; + struct HfElectronSelectionWithTpcEmcal { Produces electronSel; + Produces hfElectronSelection; + Produces hfGenElectronSel; + + enum EMCalRegion { + NoAcceptance = 0, + EMCalAcceptance = 1, + DCalAcceptance = 2 + }; // Configurables // EMCal Cluster information - + KFParticle kfNonHfe; Configurable fillEmcClusterInfo{"fillEmcClusterInfo", true, "Fill histograms with EMCal cluster info before and after track match"}; + Configurable fillTrackInfo{"fillTrackInfo", true, "Fill histograms with Track Information info before track match"}; // Event Selection Configurable zPvPosMax{"zPvPosMax", 10., "Maximum z of the primary vertex (cm)"}; @@ -86,15 +83,24 @@ struct HfElectronSelectionWithTpcEmcal { Configurable etaTrackMin{"etaTrackMin", -0.6f, "Eta range for electron tracks"}; Configurable ptTrackMin{"ptTrackMin", 3.0f, "Transverse MOmentum range for electron tracks"}; + // Associated electron selection cut + Configurable etaAssoTrackMax{"etaAssoTrackMax", 0.9f, "Eta range for Associatred electron tracks"}; + Configurable etaAssoTrackMin{"etaAssoTrackMin", -0.9f, "Eta range for Associatred electron tracks"}; + Configurable ptAssoTrackMin{"ptAssoTrackMin", 0.2f, "Transverse MOmentum range for Associatred electron tracks"}; + Configurable tpcNsigmaAssoElectronMin{"tpcNsigmaAssoElectronMin", -3.0f, "min Associated Electron TPCnsigma"}; + Configurable tpcNsigmaAssoElectronMax{"tpcNsigmaAssoElectronMax", 3.0f, "max Associated Electron TPCnsigma"}; + Configurable invariantMass{"invariantMass", 0.14f, "max Invariant Mass for Photonic electron"}; + Configurable chiSquareMax{"chiSquareMax", 3.0f, "chiSquare on the reconstructed parent particle"}; + // EMcal and Dcal selection cut Configurable etaTrackDCalNegativeMax{"etaTrackDCalNegativeMax", -0.22f, "Eta range for electron Dcal tracks"}; Configurable etaTrackDCalNegativeMin{"etaTrackDCalNegativeMin", -0.6f, "Eta range for electron tracks"}; Configurable etaTrackDCalPositiveMax{"etaTrackDCalPositiveMax", 0.6f, "Eta range for electron Dcal tracks"}; Configurable etaTrackDCalPositiveMin{"etaTrackDCalPositiveMin", 0.22f, "Eta range for electron tracks"}; - Configurable phiTrackDCalMax{"phiTrackDCalMax", 3.3621f, "phi range for electron tracks associated Dcal"}; - Configurable phiTrackDCalMin{"phiTrackDCalMin", 1.3955f, "phi range for electron tracks associated Dcal"}; - Configurable phiTrackEMCalMax{"phiTrackEMCalMax", 5.708f, "phi range for electron tracks associated Emcal"}; - Configurable phiTrackEMCalMin{"phiTrackEMCalMin", 4.5355f, "phi range for electron tracks associated Emcal"}; + Configurable phiTrackDCalMax{"phiTrackDCalMax", 5.708f, "phi range for electron tracks associated Dcal"}; + Configurable phiTrackDCalMin{"phiTrackDCalMin", 4.5355f, "phi range for electron tracks associated Dcal"}; + Configurable phiTrackEMCalMax{"phiTrackEMCalMax", 3.3621f, "phi range for electron tracks associated Emcal"}; + Configurable phiTrackEMCalMin{"phiTrackEMCalMin", 1.3955f, "phi range for electron tracks associated Emcal"}; // Track and EMCal Cluster matching cut Configurable deltaEtaMatchMin{"deltaEtaMatchMin", -0.013f, "Min Eta distance of EMCAL cluster to its closest track"}; @@ -113,82 +119,102 @@ struct HfElectronSelectionWithTpcEmcal { Configurable tpcNsigmaElectronMin{"tpcNsigmaElectronMin", -0.5f, "min Electron TPCnsigma"}; Configurable tpcNsigmaElectronMax{"tpcNsigmaElectronMax", 3.0f, "max Electron TPCnsigma"}; - // Track and EMCal Cluster matching cut for Mc Reco - Configurable mcRecDeltaEtaMatchMin{"mcRecDeltaEtaMatchMin", -0.013f, "McReco Min Eta distance of EMCAL cluster to its closest track"}; - Configurable mcRecDeltaEtaMatchMax{"mcRecDeltaEtaMatchMax", 0.0171f, "McReco Max Eta distance of EMCAL cluster to its closest track"}; - Configurable mcRecDeltaPhiMatchMin{"mcRecDeltaPhiMatchMin", -0.022f, "McReco Min Phi distance of EMCAL cluster to its closest track"}; - Configurable mcRecDeltaPhiMatchMax{"mcRecDeltaPhiMatchMax", 0.028f, "McReco Max Phi distance of EMCAL cluster to its closest track"}; - - Configurable mcRecTimeEmcClusterMax{"mcRecTimeEmcClusterMax", 50.f, "McReco EMCal Cluster time"}; - - // Inclusive electron selection cut for Mc Reco - Configurable mcRecM02EmcClusterElectronMax{"mcRecM02EmcClusterElectronMax", 0.9f, "MC Reco max Electron EMCal Cluster M02"}; - Configurable mcRecM02EmcClusterElectronMin{"mcRecM02EmcClusterElectronMin", 0.02f, "MC Reco min Electron EMCal Cluster M02"}; - Configurable mcRecM20EmcClusterElectronMax{"mcRecM20EmcClusterElectronMax", 1000.f, "MC Reco max Electron EMCal Cluster M20"}; - Configurable mcRecM20EmcClusterElectronMin{"mcRecM20EmcClusterElectronMin", 0.0f, "MC Reco min Electron EMCal Cluster M20"}; - Configurable mcRecTpcNsigmaElectronMin{"mcRecTpcNsigmaElectronMin", -0.5f, "MC Reco min Electron TPCnsigma"}; - Configurable mcRecTpcNsigmaElectronMax{"mcRecTpcNsigmaElectronMax", 3.0f, "MC Reco max Electron TPCnsigma"}; - using TableCollisions = o2::soa::Filtered>; using TableCollision = TableCollisions::iterator; using TableTracks = o2::soa::Join; using McTableCollisions = o2::soa::Filtered>; using McTableCollision = McTableCollisions::iterator; + using McGenTableCollisions = soa::Join; + using McGenTableCollision = McGenTableCollisions::iterator; using McTableTracks = soa::Join; using McTableEmcals = soa::Join; - Filter CollisionFilter = nabs(aod::collision::posZ) < zPvPosMax && aod::collision::numContrib > (uint16_t)1; + Filter collisionFilter = nabs(aod::collision::posZ) < zPvPosMax && aod::collision::numContrib > static_cast(1); PresliceUnsorted perClusterMatchedTracks = o2::aod::emcalmatchedtrack::trackId; - HistogramConfigSpec hEmcClusterEnergySpec{HistType::kTH1F, {{300, 0.0, 30.0}}}; - HistogramConfigSpec hEmcClusterEtaPhiSpec{HistType::kTH2F, {{100, -0.9, 0.9}, {200, 0, 6.3}}}; - HistogramConfigSpec hEmcClusterEnergyCellSpec{HistType::kTH2F, {{400, 0.0, 30.0}, {50, 0, 50}}}; - HistogramConfigSpec hEmcClusterEnergyTimeSpec{HistType::kTH2F, {{300, 0.0, 30.0}, {1800, -900, 900}}}; - - HistogramConfigSpec hDeltaPhiDeltaEtaEmcClusterTrackSpecEnergy{HistType::kTH3F, {{400, -0.2, 0.2}, {400, -0.2, 0.2}, {600, -300, 300}}}; - HistogramConfigSpec hAfterMatchEoPSigamSpec{HistType::kTHnSparseD, {{eopAxisBins, eopAxisMin, eopAxisMax}, {pAxisBins, pAxisMin, pAxisMax}, {nSigmaAxisBins, nSigmaAxisMin, nSigmaAxisMax}, {m02AxisBins, m02AxisMin, m02AxisMax}, {m20AxisBins, m20AxisMin, m20AxisMax}}}; - - HistogramConfigSpec hTrackEnergyLossSpec{HistType::kTH3F, {{dEdxAxisBins, dEdxAxisMin, dEdxAxisMax}, {pAxisBins, pAxisMin, pAxisMax}, {passEMCalBins, passEMCalAxisMin, passEMCalAxisMax}}}; - - HistogramConfigSpec hTracknSigmaSpec{HistType::kTH3F, {{nSigmaAxisBins, nSigmaAxisMin, nSigmaAxisMax}, {pAxisBins, pAxisMin, pAxisMax}, {passEMCalBins, passEMCalAxisMin, passEMCalAxisMax}}}; + // configurable axis + + ConfigurableAxis binsPosZ{"binsPosZ", {100, -10., 10.}, "primary vertex z coordinate"}; + ConfigurableAxis binsEta{"binsEta", {100, -2.0, 2.}, "#it{#eta}"}; + ConfigurableAxis binsPhi{"binsPhi", {32, 0.0, o2::constants::math::TwoPI}, "#it{#varphi}"}; + ConfigurableAxis binsPt{"binsPt", {50, 0.0, 50}, "#it{p_{T}}(GeV/#it{c})"}; + ConfigurableAxis binsdEdx{"binsdEdx", {160, 0., 160.}, "dE/dX"}; + ConfigurableAxis binsnSigma{"binsnSigma", {30, -15., 15.}, "#it{#sigma_{TPC}}"}; + ConfigurableAxis binsM02{"binsM02", {50, 0., 2.0}, "M02; entries"}; + ConfigurableAxis binsM20{"binsM20", {50, 0., 2.0}, "M20; entries"}; + ConfigurableAxis binsEoP{"binsEoP", {30, 0., 3.}, "e/p"}; + ConfigurableAxis binsEmcEnergy{"binsEmcEnergy", {50, 0., 50.}, "Cluster Energy (GeV/#it{c}^{2})"}; + ConfigurableAxis binsEmcClsNCells{"binsEmcClsNCells", {50, 0., 50.}, "nCells"}; + ConfigurableAxis binsEmcClsTime{"binsEmcClsTime", {1800, -900.0, 900.}, "Cluster Time"}; + ConfigurableAxis binsPassEMcal{"binsPassEMcal", {3, 0.0, 3.}, "Pass EMcal"}; + + ConfigurableAxis binsDeltaEta{"binsDeltaEta", {20, -0.2, 0.2}, "Track Cluser Match #Delta #eta"}; + ConfigurableAxis binsDeltaPhi{"binsDeltaPhi", {20, -0.2, 0.2}, "Track Cluser Match #Delta #varphi"}; + ConfigurableAxis binsMass{"binsMass", {100, 0.0, 2.0}, "Mass (GeV/#it{c}^{2}); entries"}; HistogramRegistry registry{ "registry", - {{"hNevents", "No of events", {HistType::kTH1F, {{3, 1, 4}}}}, - {"hZvertex", "z vertex", {HistType::kTH1F, {{100, -100, 100}}}}, - {"hEmcClusterM02", "m02", {HistType::kTH1F, {{m02AxisBins, m02AxisMin, m02AxisMax}}}}, - {"hEmcClusterM20", "m20", {HistType::kTH1F, {{m20AxisBins, m20AxisMin, m20AxisMax}}}}, - {"hTrackEtaPhi", "TPC EtaPhi Info; #eta;#varphi;passEMcal;", {HistType::kTH3F, {{etaAxisBins, trackEtaAxisMin, trackEtaAxisMax}, {phiAxisBins, trackPhiAxisMin, trackPhiAxisMax}, {passEMCalBins, passEMCalAxisMin, passEMCalAxisMax}}}}, - {"hTrackEnergyLossVsP", " TPC Energy loss info vs P; dE/dx;#it{p} (GeV#it{/c});passEMcal;", hTrackEnergyLossSpec}, - {"hTrackEnergyLossVsPt", " TPC Energy loss info vs Pt; dE/dx;#it{p}_{T} (GeV#it{/c});passEMcal;", hTrackEnergyLossSpec}, - {"hTracknSigmaVsP", " TPC nSigma info vs P; n#sigma;#it{p} (GeV#it{/c});passEMcal;", hTracknSigmaSpec}, - {"hTracknSigmaVsPt", " TPC nSigma info vs Pt; n#sigma;#it{p}_{T} (GeV#it{/c});passEMcal;", hTracknSigmaSpec}, - {"hEmcClusterEnergy", "EMCal Cluster Info before match Energy; Energy (GeV)", hEmcClusterEnergySpec}, - {"hEmcClusterEtaPhi", "EMCal Cluster Info before match Eta and Phi; #eta;#varphi;", hEmcClusterEtaPhiSpec}, - {"hEmcClusterEnergyCell", "EMCal Cluster Info before match Energy vs nCells; Energy (GeV);ncell;", hEmcClusterEnergyCellSpec}, - {"hEmcClusterEnergyTime", "EMCal Cluster Info before match Energy vs time; Energy (GeV); sec;", hEmcClusterEnergyTimeSpec}, - {"hEmcClusterAfterMatchEnergy", "EMCal Cluster Info After match Energy; Energy (GeV)", hEmcClusterEnergySpec}, - {"hEmcClusterAfterMatchEtaPhi", "EMCal Cluster Info After match Eta and Phi; #eta;#varphi;", hEmcClusterEtaPhiSpec}, - {"hEmcClusterAfterMatchEnergyCells", "EMCal Cluster Info After match Energy vs nCells; Energy (GeV);ncell;", hEmcClusterEnergyCellSpec}, - {"hEmcClusterAfterMatchEnergyTime", "EMCal Cluster Info After match Energy vs time; Energy (GeV); sec;", hEmcClusterEnergyTimeSpec}, - - {"hAfterMatchSigmaVsEoP", "PID Info after match EoP vs Sigma ; E/P;#it{p}_{T} (GeV#it{/c});n#sigma; m02; m20;", hAfterMatchEoPSigamSpec}, - {"hAfterMatchEoPVsP", "PID Info after match EoP vs P; E/P;#it{p} (GeV#it{/c});", {HistType::kTH2F, {{eopAxisBins, eopAxisMin, eopAxisMax}, {pAxisBins, pAxisMin, pAxisMax}}}}, - {"hAfterMatchSigmaVsP", "PID Info after match Sigma vs Momentum ; n#sigma; #it{p} (GeV#it{/c}; ", {HistType::kTH2F, {{nSigmaAxisBins, nSigmaAxisMin, nSigmaAxisMax}, {pAxisBins, pAxisMin, pAxisMax}}}}, - {"hAfterMatchEtaPhi", "PID Info after match Eta vs Phi ; #eta; #varphi; ", {HistType::kTH2F, {{etaAxisBins, trackEtaAxisMin, trackEtaAxisMax}, {phiAxisBins, trackPhiAxisMin, trackPhiAxisMax}}}}, - {"hAfterMatchEnergyLossVsP", "PID Info after match Energy loss info vs P ; dE/dx;#it{p} (GeV#it{/c});; ", {HistType::kTH2F, {{dEdxAxisBins, dEdxAxisMin, dEdxAxisMax}, {pAxisBins, pAxisMin, pAxisMax}}}}, - {"hAfterMatchEnergyLossVsPt", "PID Info after match Energy loss info vs Pt ;dE/dx;#it{p}_{T} (GeV#it{/c}); ", {HistType::kTH2F, {{dEdxAxisBins, dEdxAxisMin, dEdxAxisMax}, {pAxisBins, pAxisMin, pAxisMax}}}}, - - {"hAfterPIDEtaPhi", "PID Info after PID Cuts Eta vs Phi ; #eta; #varphi; ", {HistType::kTH2F, {{etaAxisBins, trackEtaAxisMin, trackEtaAxisMax}, {phiAxisBins, trackPhiAxisMin, trackPhiAxisMax}}}}, - {"hEPRatioAfterPID", "E/P Ratio after PID Cuts apply only trackwodca filter", {HistType::kTH2F, {{pAxisBins, pAxisMin, pAxisMax}, {300, 0, 30}}}}, - {"hPIDAfterPIDCuts", "PID Info after PID cuts; E/P;#it{p}_{T} (GeV#it{/c});n#sigma;m02; m20;", hAfterMatchEoPSigamSpec}, - {"hEmcClsTrkEtaPhiDiffTimeEnergy", "EmcClsTrkEtaPhiDiffTimeEnergy;#Delta#eta;#Delta#varphi;Sec;", hDeltaPhiDeltaEtaEmcClusterTrackSpecEnergy}}}; + {}}; void init(o2::framework::InitContext&) { - registry.get(HIST("hAfterMatchSigmaVsEoP"))->Sumw2(); - registry.get(HIST("hPIDAfterPIDCuts"))->Sumw2(); + AxisSpec axisPosZ = {binsPosZ, "Pos Z"}; + AxisSpec axisMass = {binsMass, "Mass (GeV/#it{c}^{2}); entries"}; + AxisSpec axisPt = {binsPt, "#it{p_{T}}(GeV/#it{c})"}; + AxisSpec axisEta = {binsEta, "#it{#eta}"}; + AxisSpec axisPhi = {binsPhi, "#it{#varphi}"}; + AxisSpec axisdEdx = {binsdEdx, "dE/dX"}; + AxisSpec axisnSigma = {binsnSigma, "it{#sigma_{TPC}}"}; + AxisSpec axisM02 = {binsM02, "M02; entries"}; + AxisSpec axisM20 = {binsM20, "M20; entries"}; + AxisSpec axisEoP = {binsEoP, "E/p"}; + AxisSpec axisEmcEnergy = {binsEmcEnergy, "Cluster Energy (GeV/#it{c}^{2})"}; + AxisSpec axisEmcClsNCells = {binsEmcClsNCells, "nCell"}; + AxisSpec axisEmcClsTime = {binsEmcClsTime, "Cluster Time"}; + AxisSpec axisPassEMcal = {binsPassEMcal, "Pass EMcal"}; + AxisSpec axisDeltaEta = {binsDeltaEta, "#Delta #eta = #eta_{trk}- #eta_{cluster}"}; + AxisSpec axisDeltaPhi = {binsDeltaPhi, "#Delta #varphi = #varphi_{trk}- #varphi_{cluster}"}; + + registry.add("hZvertex", "z vertex", {HistType::kTH1D, {axisPosZ}}); + registry.add("hNevents", "No of events", {HistType::kTH1D, {{3, 1, 4}}}); + registry.add("hLikeMass", "Like mass", {HistType::kTH1D, {{axisMass}}}); + registry.add("hUnLikeMass", "unLike mass", {HistType::kTH1D, {{axisMass}}}); + registry.add("hLikeSignPt", "Like sign Momentum ", {HistType::kTH1D, {{axisPt}}}); + registry.add("hUnLikeSignPt", "UnLike sign Momentum", {HistType::kTH1D, {{axisPt}}}); + registry.add("hMcgenInElectron", "Mc Gen Inclusive Electron", {HistType::kTH1D, {{axisPt}}}); + registry.add("hMcgenAllNonHfeElectron", "Mc Gen All NonHf Electron", {HistType::kTH1D, {{axisPt}}}); + registry.add("hMcgenNonHfeElectron", "Mc Gen NonHf Electron with mother", {HistType::kTH1D, {{axisPt}}}); + registry.add("hPi0eEmbTrkPt", "Mc Gen Pi0 mother NonHf Electron", {HistType::kTH1D, {{axisPt}}}); + + registry.add("hEtaeEmbTrkPt", "Mc Gen Eta mother NonHf Electron", {HistType::kTH1D, {{axisPt}}}); + registry.add("hEmcClusterM02", "m02", {HistType::kTH1D, {{axisM02}}}); + registry.add("hEmcClusterM20", "m20", {HistType::kTH1D, {{axisM20}}}); + registry.add("hTrackEtaPhi", "TPC EtaPhi Info; #eta;#varphi;passEMcal;", {HistType::kTH3F, {{axisEta}, {axisPhi}, {axisPassEMcal}}}); + registry.add("hTrackEnergyLossVsP", " TPC Energy loss info vs P; dE/dx;#it{p} (GeV#it{/c});passEMcal;", {HistType::kTH3F, {{axisdEdx}, {axisPt}, {axisPassEMcal}}}); + registry.add("hTrackEnergyLossVsPt", "TPC Energy loss info vs Pt; dE/dx;#it{p}_{T} (GeV#it{/c});passEMcal;", {HistType::kTH3F, {{axisdEdx}, {axisPt}, {axisPassEMcal}}}); + registry.add("hTracknSigmaVsP", " TPC nSigma info vs P; n#sigma;#it{p} (GeV#it{/c});passEMcal;", {HistType::kTH3F, {{axisnSigma}, {axisPt}, {axisPassEMcal}}}); + registry.add("hTracknSigmaVsPt", " TPC nSigma info vs Pt; n#sigma;#it{p}_{T} (GeV#it{/c});passEMcal;", {HistType::kTH3F, {{axisnSigma}, {axisPt}, {axisPassEMcal}}}); + registry.add("hEmcClusterEnergy", "EMCal Cluster Info before match Energy; Energy (GeV); entries;", {HistType::kTH1D, {{axisEmcEnergy}}}); + registry.add("hEmcClusterEtaPhi", "EMCal Cluster Info before match Eta and Phi; #eta;#varphi;", {HistType::kTH2F, {{axisEta}, {axisPhi}}}); + registry.add("hEmcClusterEnergyCell", "EMCal Cluster Info before match Energy vs nCells; Energy (GeV);ncell;", {HistType::kTH2F, {{axisEmcEnergy}, {axisEmcClsNCells}}}); + registry.add("hEmcClusterEnergyTime", "EMCal Cluster Info before match Energy vs time; Energy (GeV); sec;", {HistType::kTH2F, {{axisEmcEnergy}, {axisEmcClsTime}}}); + registry.add("hEmcClusterAfterMatchEnergy", "EMCal Cluster Info After match Energy; Energy (GeV); entries;", {HistType::kTH1D, {{axisEmcEnergy}}}); + registry.add("hEmcClusterAfterMatchEtaPhi", "EMCal Cluster Info After match Eta and Phi; #eta;#varphi;", {HistType::kTH2F, {{axisEta}, {axisPhi}}}); + registry.add("hEmcClusterAfterMatchEnergyCells", "EMCal Cluster Info After match Energy vs nCells; Energy (GeV);ncell;", {HistType::kTH2F, {{axisEmcEnergy}, {axisEmcClsNCells}}}); + registry.add("hEmcClusterAfterMatchEnergyTime", "EMCal Cluster Info After match Energy vs time; Energy (GeV); sec;", {HistType::kTH2F, {{axisEmcEnergy}, {axisEmcClsTime}}}); + registry.add("hAfterMatchSigmaVsEoP", "PID Info after match EoP vs Sigma ; E/P;#it{p}_{T} (GeV#it{/c});n#sigma; m02; m20;", {HistType::kTHnSparseF, {{axisEoP}, {axisPt}, {axisnSigma}, {axisM02}, {axisM20}}}); + registry.add("hAfterMatchEoPVsP", "PID Info after match EoP vs P; E/P;#it{p} (GeV#it{/c});", {HistType::kTH2F, {{axisEoP}, {axisPt}}}); + registry.add("hAfterMatchSigmaVsP", "PID Info after match Sigma vs Momentum ; n#sigma; #it{p} (GeV#it{/c}; ", {HistType::kTH2F, {{axisnSigma}, {axisPt}}}); + registry.add("hAfterMatchEtaPhi", "PID Info after match Eta vs Phi ; #eta; #varphi; ", {HistType::kTH2F, {{axisEta}, {axisPhi}}}); + registry.add("hAfterMatchEnergyLossVsP", "PID Info after match Energy loss info vs P ; dE/dx;#it{p} (GeV#it{/c});; ", {HistType::kTH2F, {{axisdEdx}, {axisPt}}}); + registry.add("hAfterMatchEnergyLossVsPt", "PID Info after match Energy loss info vs Pt ;dE/dx;#it{p}_{T} (GeV#it{/c}); ", {HistType::kTH2F, {{axisdEdx}, {axisPt}}}); + + registry.add("hAfterPIDEtaPhi", "PID Info after PID Cuts Eta vs Phi ; #eta; #varphi; ", {HistType::kTH2F, {{axisEta}, {axisPhi}}}); + registry.add("hEPRatioAfterPID", "E/P Ratio after PID Cuts apply only trackwodca filter", {HistType::kTH2F, {{axisPt}, {axisEmcEnergy}}}); + + registry.add("hPIDAfterPIDCuts", "PID Info after PID cuts; E/P;#it{p}_{T} (GeV#it{/c});n#sigma;m02; m20;", {HistType::kTHnSparseF, {{axisEoP}, {axisPt}, {axisnSigma}, {axisM02}, {axisM20}}}); + registry.add("hEmcClsTrkEtaPhiDiffTime", "EmcClsTrkEtaPhiDiffTime;#Delta#eta;#Delta#varphi;Sec;", {HistType::kTH3F, {{axisDeltaEta}, {axisDeltaPhi}, {axisEmcClsTime}}}); } // Track Selection Cut template @@ -211,7 +237,137 @@ struct HfElectronSelectionWithTpcEmcal { } return true; } + // Associated electron Selection Cut + template + bool selAssoTracks(T const& track) + { + if (!track.isGlobalTrackWoDCA()) { + return false; + } + if (std::abs(track.dcaXY()) > dcaXYTrackMax || std::abs(track.dcaZ()) > dcaZTrackMax) { + return false; + } + if (track.eta() < etaAssoTrackMin || track.eta() > etaAssoTrackMax) { + return false; + } + + if (track.pt() < ptAssoTrackMin) { + return false; + } + if (track.tpcNSigmaEl() < tpcNsigmaAssoElectronMin || track.tpcNSigmaEl() > tpcNsigmaAssoElectronMax) { + return false; + } + return true; + } + + // mc gen particle selection cut + template + bool mcGensel(T const& track) + { + if (track.eta() < etaTrackMin || track.eta() > etaTrackMax) { + return false; + } + if ((track.phi() < phiTrackEMCalMin || track.phi() > phiTrackEMCalMax) && (track.phi() < phiTrackDCalMin || track.phi() > phiTrackDCalMax)) { + return false; + } + if (track.pt() < ptTrackMin) { + return false; + } + return true; + } + // nonHfe Identification + + template + void nonHfe(ElectronType const& electron, TracksType const& tracks, bool isEMcal) + { + int nElPairsLS = 0; + int nElPairsUS = 0; + bool isLSElectron = false; + bool isULSElectron = false; + float invMassElectron = 0.; + float massLike = 0; + float massUnLike = 0; + + for (const auto& pTrack : tracks) { + if (pTrack.globalIndex() == electron.globalIndex()) { + continue; + } + // Apply partner electron selection + + if (!selAssoTracks(pTrack)) { + continue; + } + if (electron.pt() <= pTrack.pt()) { + continue; + } + int pdgE1 = kElectron; + int pdgE2 = kElectron; + if (electron.sign() > 0) { + pdgE1 = kPositron; + } + + if (pTrack.sign() > 0) { + pdgE2 = kPositron; + } + + KFPTrack kfpTrack = createKFPTrackFromTrack(electron); + KFPTrack kfpAssociatedTrack = createKFPTrackFromTrack(pTrack); + KFParticle kfTrack(kfpTrack, pdgE1); + KFParticle kfAssociatedTrack(kfpAssociatedTrack, pdgE2); + const KFParticle* electronPairs[2] = {&kfTrack, &kfAssociatedTrack}; + kfNonHfe.SetConstructMethod(2); + kfNonHfe.Construct(electronPairs, 2); + + int ndf = kfNonHfe.GetNDF(); + double chi2recg = kfNonHfe.GetChi2() / ndf; + if (ndf < 1.0) { + continue; + } + + if (std::sqrt(std::abs(chi2recg)) > chiSquareMax) { + continue; + } + + invMassElectron = RecoDecay::m(std::array{pTrack.pVector(), electron.pVector()}, std::array{MassElectron, MassElectron}); + + // for like charge + if (pTrack.sign() == electron.sign()) { + massLike = invMassElectron; + isLSElectron = true; + if (isEMcal) { + registry.fill(HIST("hLikeMass"), massLike); + } + } + // for unlike charge + if (pTrack.sign() != electron.sign()) { + massUnLike = invMassElectron; + isULSElectron = true; + if (isEMcal) { + registry.fill(HIST("hUnLikeMass"), massUnLike); + } + } + + // for like charge + if (isLSElectron && (invMassElectron <= invariantMass)) { + massLike = invMassElectron; + ++nElPairsLS; + if (isEMcal) { + registry.fill(HIST("hLikeSignPt"), electron.pt()); + } + } + // for unlike charge + if (isULSElectron && (invMassElectron <= invariantMass)) { + massUnLike = invMassElectron; + ++nElPairsUS; + if (isEMcal) { + registry.fill(HIST("hUnLikeSignPt"), electron.pt()); + } + } + } + // Pass multiplicities and other required parameters for this electron + hfElectronSelection(electron.collisionId(), electron.globalIndex(), electron.eta(), electron.phi(), electron.pt(), electron.tpcNSigmaEl(), electron.tofNSigmaEl(), nElPairsLS, nElPairsUS, isEMcal); + } // Electron Identification template void fillElectronTrack(CollisionType const& collision, TracksType const& tracks, EmcClusterType const& emcClusters, MatchType const& matchedTracks, ParticleType const& /*particlemc*/) @@ -220,6 +376,11 @@ struct HfElectronSelectionWithTpcEmcal { return; registry.fill(HIST("hNevents"), 1); + + // skip events with no clusters + if (emcClusters.size() == 0) { + return; + } registry.fill(HIST("hZvertex"), collision.posZ()); ///////////////////////////////// @@ -235,7 +396,7 @@ struct HfElectronSelectionWithTpcEmcal { registry.fill(HIST("hEmcClusterM20"), emcClusterBefore.m20()); } } - int passEMCal; + EMCalRegion passEMCal = NoAcceptance; float phiTrack = -999; float etaTrack = -999; float pTrack = -999; @@ -243,7 +404,7 @@ struct HfElectronSelectionWithTpcEmcal { float dcaxyTrack = -999; float dcazTrack = -999; float tpcNsigmaTrack = -999; - int electronId = -999; + for (const auto& track : tracks) { phiTrack = track.phi(); etaTrack = track.eta(); @@ -252,24 +413,22 @@ struct HfElectronSelectionWithTpcEmcal { dcaxyTrack = track.dcaXY(); dcazTrack = track.dcaZ(); tpcNsigmaTrack = track.tpcNSigmaEl(); - electronId = track.globalIndex(); // Apply Track Selection if (!selTracks(track)) { continue; } - passEMCal = 0; - if ((phiTrack > phiTrackEMCalMin && phiTrack < phiTrackEMCalMax) && (etaTrack > etaTrackMin && etaTrack < etaTrackMax)) - passEMCal = 1; // EMcal acceptance passed + passEMCal = EMCalAcceptance; // EMcal acceptance passed if ((phiTrack > phiTrackDCalMin && phiTrack < phiTrackDCalMax) && ((etaTrack > etaTrackDCalPositiveMin && etaTrack < etaTrackDCalPositiveMax) || (etaTrack > etaTrackDCalNegativeMin && etaTrack < etaTrackDCalNegativeMax))) - passEMCal = 2; // Dcal acceptance passed - - registry.fill(HIST("hTrackEtaPhi"), etaTrack, phiTrack, passEMCal); // track etaphi infor after filter bit - registry.fill(HIST("hTrackEnergyLossVsP"), track.tpcSignal(), pTrack, passEMCal); // track etaphi infor after filter bit - registry.fill(HIST("hTrackEnergyLossVsPt"), track.tpcSignal(), ptTrack, passEMCal); // track etaphi infor after filter bit - registry.fill(HIST("hTracknSigmaVsP"), tpcNsigmaTrack, pTrack, passEMCal); // track etaphi infor after filter bit - registry.fill(HIST("hTracknSigmaVsPt"), tpcNsigmaTrack, ptTrack, passEMCal); // track etaphi infor after filter bit - + passEMCal = DCalAcceptance; // Dcal acceptance passed + + if (fillTrackInfo) { + registry.fill(HIST("hTrackEtaPhi"), etaTrack, phiTrack, passEMCal); // track etaphi infor after filter bit + registry.fill(HIST("hTrackEnergyLossVsP"), track.tpcSignal(), pTrack, passEMCal); // track etaphi infor after filter bit + registry.fill(HIST("hTrackEnergyLossVsPt"), track.tpcSignal(), ptTrack, passEMCal); // track etaphi infor after filter bit + registry.fill(HIST("hTracknSigmaVsP"), tpcNsigmaTrack, pTrack, passEMCal); // track etaphi infor after filter bit + registry.fill(HIST("hTracknSigmaVsPt"), tpcNsigmaTrack, ptTrack, passEMCal); // track etaphi infor after filter bit + } auto tracksofcluster = matchedTracks.sliceBy(perClusterMatchedTracks, track.globalIndex()); float phiMatchTrack = -999; float etaMatchTrack = -999; @@ -313,30 +472,21 @@ struct HfElectronSelectionWithTpcEmcal { deltaEtaMatch = matchTrack.trackEtaEmcal() - etaMatchEmcCluster; // Track and EMCal cluster Matching - - if constexpr (!isMc) { - if (std::abs(timeEmcCluster) > timeEmcClusterMax) { - continue; - } - if (deltaPhiMatch < deltaPhiMatchMin || deltaPhiMatch > deltaPhiMatchMax || deltaEtaMatch < deltaEtaMatchMin || deltaEtaMatch > deltaEtaMatchMax) { - continue; - } - } else { - if (std::abs(timeEmcCluster) > mcRecTimeEmcClusterMax) { - continue; - } - if (deltaPhiMatch < mcRecDeltaPhiMatchMin || deltaPhiMatch > mcRecDeltaPhiMatchMax || deltaEtaMatch < mcRecDeltaEtaMatchMin || deltaEtaMatch > mcRecDeltaEtaMatchMax) { - continue; - } + if (std::abs(timeEmcCluster) > timeEmcClusterMax) { + continue; + } + if (deltaPhiMatch < deltaPhiMatchMin || deltaPhiMatch > deltaPhiMatchMax || deltaEtaMatch < deltaEtaMatchMin || deltaEtaMatch > deltaEtaMatchMax) { + continue; } - registry.fill(HIST("hEmcClsTrkEtaPhiDiffTimeEnergy"), deltaEtaMatch, deltaPhiMatch, timeEmcCluster); + registry.fill(HIST("hEmcClsTrkEtaPhiDiffTime"), deltaEtaMatch, deltaPhiMatch, timeEmcCluster); - if (fillEmcClusterInfo) - registry.fill(HIST("hEmcClusterAfterMatchEnergy"), emcCluster.energy()); // track etaphi infor after filter bit - registry.fill(HIST("hEmcClusterAfterMatchEtaPhi"), emcCluster.eta(), emcCluster.phi()); // track etaphi infor after filter bit - registry.fill(HIST("hEmcClusterAfterMatchEnergyCells"), emcCluster.energy(), emcCluster.nCells()); // track etaphi infor after filter bit - registry.fill(HIST("hEmcClusterAfterMatchEnergyTime"), emcCluster.energy(), emcCluster.time()); // track etaphi infor after filter bit + if (fillEmcClusterInfo) { + registry.fill(HIST("hEmcClusterAfterMatchEnergy"), emcCluster.energy()); // track etaphi infor after filter bit + registry.fill(HIST("hEmcClusterAfterMatchEtaPhi"), emcCluster.eta(), emcCluster.phi()); // track etaphi infor after filter bit + registry.fill(HIST("hEmcClusterAfterMatchEnergyCells"), emcCluster.energy(), emcCluster.nCells()); // track etaphi infor after filter bit + registry.fill(HIST("hEmcClusterAfterMatchEnergyTime"), emcCluster.energy(), emcCluster.time()); // track etaphi infor after filter bit + } eop = eMatchEmcCluster / pMatchTrack; @@ -346,16 +496,10 @@ struct HfElectronSelectionWithTpcEmcal { registry.fill(HIST("hAfterMatchEtaPhi"), etaMatchTrack, phiMatchTrack); registry.fill(HIST("hAfterMatchEnergyLossVsP"), matchTrack.tpcSignal(), pMatchTrack); registry.fill(HIST("hAfterMatchEnergyLossVsPt"), matchTrack.tpcSignal(), ptMatchTrack); - // Apply Electron Identification cuts - if constexpr (!isMc) { - if ((tpcNsigmaMatchTrack < tpcNsigmaElectronMin || tpcNsigmaMatchTrack > tpcNsigmaElectronMax) || (m02MatchEmcCluster < m02EmcClusterElectronMin || m02MatchEmcCluster > m02EmcClusterElectronMax) || (m20MatchEmcCluster < m20EmcClusterElectronMin || m20MatchEmcCluster > m20EmcClusterElectronMax)) { - continue; - } - } else { - if ((tpcNsigmaMatchTrack < mcRecTpcNsigmaElectronMin || tpcNsigmaMatchTrack > mcRecTpcNsigmaElectronMax) || (m02MatchEmcCluster < mcRecM02EmcClusterElectronMin || m02MatchEmcCluster > mcRecM02EmcClusterElectronMax) || (m20MatchEmcCluster < mcRecM20EmcClusterElectronMin || m20MatchEmcCluster > mcRecM20EmcClusterElectronMax)) { - continue; - } + + if ((tpcNsigmaMatchTrack < tpcNsigmaElectronMin || tpcNsigmaMatchTrack > tpcNsigmaElectronMax) || (m02MatchEmcCluster < m02EmcClusterElectronMin || m02MatchEmcCluster > m02EmcClusterElectronMax) || (m20MatchEmcCluster < m20EmcClusterElectronMin || m20MatchEmcCluster > m20EmcClusterElectronMax)) { + continue; } registry.fill(HIST("hPIDAfterPIDCuts"), eop, ptMatchTrack, tpcNsigmaMatchTrack, m02MatchEmcCluster, m20MatchEmcCluster); @@ -365,17 +509,20 @@ struct HfElectronSelectionWithTpcEmcal { continue; } - isEMcal = true; - std::cout << " electron id in selection" << electronId << std::endl; - electronSel(matchTrack.collisionId(), electronId, etaMatchTrack, phiMatchTrack, ptMatchTrack, pMatchTrack, trackRapidity, matchTrack.dcaXY(), matchTrack.dcaZ(), matchTrack.tpcNSigmaEl(), matchTrack.tofNSigmaEl(), + ///////////////// NonHf electron Selection with Emcal //////////////////////// + + nonHfe(matchTrack, tracks, true); + + electronSel(track.collisionId(), matchTrack.globalIndex(), etaMatchTrack, phiMatchTrack, ptMatchTrack, pMatchTrack, trackRapidity, matchTrack.dcaXY(), matchTrack.dcaZ(), matchTrack.tpcNSigmaEl(), matchTrack.tofNSigmaEl(), eMatchEmcCluster, etaMatchEmcCluster, phiMatchEmcCluster, m02MatchEmcCluster, m20MatchEmcCluster, cellEmcCluster, timeEmcCluster, deltaEtaMatch, deltaPhiMatch, isEMcal); } - /// Electron information without Emcal and use TPC and TOF if (isEMcal) { continue; } - electronSel(track.collisionId(), electronId, etaTrack, phiTrack, ptTrack, pTrack, trackRapidity, dcaxyTrack, dcazTrack, track.tpcNSigmaEl(), track.tofNSigmaEl(), + nonHfe(track, tracks, false); + ///////////////// NonHf electron Selection without Emcal //////////////////////// + electronSel(track.collisionId(), track.globalIndex(), etaTrack, phiTrack, ptTrack, pTrack, trackRapidity, dcaxyTrack, dcazTrack, track.tpcNSigmaEl(), track.tofNSigmaEl(), eMatchEmcCluster, etaMatchEmcCluster, phiMatchEmcCluster, m02MatchEmcCluster, m20MatchEmcCluster, cellEmcCluster, timeEmcCluster, deltaEtaMatch, deltaPhiMatch, isEMcal); } } @@ -389,7 +536,6 @@ struct HfElectronSelectionWithTpcEmcal { fillElectronTrack(collision, tracks, emcClusters, matchedTracks, 0); } PROCESS_SWITCH(HfElectronSelectionWithTpcEmcal, processData, "process Data info only", true); - /// Electron selection - for MC reco-level analysis void processMcRec(McTableCollision const& mcCollision, McTableTracks const& mcTracks, @@ -400,6 +546,88 @@ struct HfElectronSelectionWithTpcEmcal { fillElectronTrack(mcCollision, mcTracks, mcEmcClusters, matchedTracks, mcParticles); } PROCESS_SWITCH(HfElectronSelectionWithTpcEmcal, processMcRec, "Process MC Reco mode", false); + + void processMcGen(McGenTableCollision const& mcCollision, aod::McParticles const& mcParticles) + { + + ///// electron identification + bool isNonHfe = false; + for (const auto& particleMc : mcParticles) { + + if (!particleMc.isPhysicalPrimary()) + continue; + if (!mcGensel(particleMc)) { + continue; + } + if (std::abs(particleMc.pdgCode()) == kElectron) { + + registry.fill(HIST("hMcgenInElectron"), particleMc.pt()); + bool isEmbEta = false; + bool isEmbPi0 = false; + + if (particleMc.has_mothers()) { + // Check first mother + auto const& mother = particleMc.mothers_first_as(); + + if (std::abs(mother.pdgCode()) == kEta || std::abs(mother.pdgCode()) == kPi0 || std::abs(mother.pdgCode()) == kGamma) { + registry.fill(HIST("hMcgenAllNonHfeElectron"), particleMc.pt()); + if (mother.has_mothers()) { + auto const& gmother = mother.mothers_first_as(); + if (gmother.has_mothers()) { + auto const& ggmother = gmother.mothers_first_as(); + + // cases to consider: eta->e, eta->pi0->e, eta->gamma->e, eta->pi0->gamma->e, pi0->e, pi0->gamma->e + + //================= eta->e ====================================== + if (std::abs(mother.pdgCode()) == kEta) { + isEmbEta = true; + } + //================= eta->pi0->e ====================================== + + if (std::abs(mother.pdgCode()) == kPi0) { + isEmbPi0 = true; // pi0 -> e + + if (std::abs(gmother.pdgCode()) == kEta) { + isEmbEta = true; // eta->pi0-> e + } + } + + /// ==================================== eta->gamma->e and eta->pi0->gamma->e============ + if (std::abs(mother.pdgCode()) == kGamma) { + if (std::abs(gmother.pdgCode()) == kEta) { + isEmbEta = true; // eta->gamma-> e + } + + if (std::abs(gmother.pdgCode()) == kPi0) { + isEmbPi0 = true; // pi0-> gamma-> e + + if (std::abs(ggmother.pdgCode()) == kEta) { + + isEmbEta = true; // eta->pi0->gamma-> e + } + } + } + } + } + } + } + if (isEmbPi0 || isEmbEta) { + registry.fill(HIST("hMcgenNonHfeElectron"), particleMc.pt()); + isNonHfe = true; + if (isEmbPi0) { + + registry.fill(HIST("hPi0eEmbTrkPt"), particleMc.pt()); + } + if (isEmbEta) { + registry.fill(HIST("hEtaeEmbTrkPt"), particleMc.pt()); + } + } + hfGenElectronSel(mcCollision.globalIndex(), particleMc.globalIndex(), particleMc.eta(), particleMc.phi(), particleMc.pt(), isNonHfe); + } + } + } + + PROCESS_SWITCH(HfElectronSelectionWithTpcEmcal, processMcGen, "Process MC Gen mode", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/HFL/TableProducer/treeCreatorElectronDCA.cxx b/PWGHF/HFL/TableProducer/treeCreatorElectronDCA.cxx new file mode 100644 index 00000000000..1b32608a310 --- /dev/null +++ b/PWGHF/HFL/TableProducer/treeCreatorElectronDCA.cxx @@ -0,0 +1,151 @@ +// 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. + +/// \file treeCreatorElectronDCA.cxx +/// \brief Basic electron DCA analysis task +/// +/// \author Martin Voelkl , University of Birmingham + +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::analysis; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace hf_ele_mc_red +{ +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(SourcePdg, sourcePdg, int); +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); +DECLARE_SOA_COLUMN(ProductionRadius, productionRadius, float); + +} // namespace hf_ele_mc_red +DECLARE_SOA_TABLE(HFeleMCRedTable, "AOD", "HFELERED", + hf_ele_mc_red::Eta, hf_ele_mc_red::Phi, hf_ele_mc_red::Pt, hf_ele_mc_red::SourcePdg, hf_ele_mc_red::DcaXY, hf_ele_mc_red::ProductionRadius); +} // namespace o2::aod + +/// Electron DCA analysis task +struct HfTreeCreatorElectronDCA { + Produces hfEleTable; + + Configurable etaRange{"etaRange", 0.5, "pseudorapidity range"}; + Configurable pTMin{"pTMin", 0.5, "min pT"}; + + HfHelper hfHelper; + Service pdg; + + using TracksWExt = soa::Join; + using TracksWExtMc = soa::Join; + + HistogramRegistry registry{ + "registry", + {{"hZVertex", "z Vertex;z_{vtx};counts", {HistType::kTH1F, {{100, -20., 20.}}}}, + {"hpTTracks", "pT of tracks; p_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 10.}}}}, + {"hpTElectrons", "pT of electrons; p_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 10.}}}}}}; + + void init(InitContext&) + { + } + + void processData(aod::Collisions::iterator const& collision) + { + registry.get(HIST("hZVertex"))->Fill(collision.posZ()); + } + PROCESS_SWITCH(HfTreeCreatorElectronDCA, processData, "Process Data", true); + + void processMc(aod::Collisions::iterator const& collision, + TracksWExtMc const& tracks, + aod::McParticles const&) + { + registry.get(HIST("hZVertex"))->Fill(collision.posZ()); + int pdgCode = 0, absPDGCode = 0, sourcePDG = 0; + for (const auto& track : tracks) { + if (!track.trackCutFlagFb3()) + continue; + registry.get(HIST("hpTTracks"))->Fill(track.pt()); + if (track.pt() < pTMin) + continue; + if (std::abs(track.eta()) > etaRange) + continue; + if (track.mcParticleId() < 1) + continue; + auto mcTrack = track.mcParticle(); + if (std::abs(mcTrack.pdgCode()) == kElectron) { + bool isConversion = false; + bool isBeauty = false; + bool isCharm = false; + double productionRadius = RecoDecay::sqrtSumOfSquares(mcTrack.vx(), mcTrack.vy()); + registry.get(HIST("hpTElectrons"))->Fill(track.pt()); + auto motherTracks = mcTrack.mothers_as(); + int numberOfMothers = motherTracks.size(); + // Categorise the electron sources + int firstMotherPDG = motherTracks[0].pdgCode(); + if (firstMotherPDG == kGamma) + isConversion = true; + while (numberOfMothers == 1) // loop through all generations + { + pdgCode = motherTracks[0].pdgCode(); + absPDGCode = std::abs(pdgCode); + if (static_cast(absPDGCode / 100) == 4 || static_cast(absPDGCode / 1000) == 4) { + isCharm = true; + sourcePDG = pdgCode; + } + if (static_cast(absPDGCode / 100) == 5 || static_cast(absPDGCode / 1000) == 5) { + isBeauty = true; + sourcePDG = pdgCode; // already in order, since beauty would decay to charm + } + auto firstMother = motherTracks[0]; + motherTracks = firstMother.mothers_as(); + numberOfMothers = motherTracks.size(); + } + if (!isBeauty && !isCharm) { + if (isConversion) + sourcePDG = kGamma; + else + sourcePDG = firstMotherPDG; + } + hfEleTable(track.eta(), track.phi(), track.pt(), sourcePDG, track.dcaXY(), productionRadius); + } + } + } + PROCESS_SWITCH(HfTreeCreatorElectronDCA, processMc, "Process MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/HFL/Tasks/CMakeLists.txt b/PWGHF/HFL/Tasks/CMakeLists.txt index 8a6c9ab4285..49bafac661a 100644 --- a/PWGHF/HFL/Tasks/CMakeLists.txt +++ b/PWGHF/HFL/Tasks/CMakeLists.txt @@ -11,7 +11,7 @@ o2physics_add_dpl_workflow(task-electron-weak-boson SOURCES taskElectronWeakBoson.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils KFParticle::KFParticle COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(task-muon-charm-beauty-separation @@ -19,11 +19,21 @@ o2physics_add_dpl_workflow(task-muon-charm-beauty-separation PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-single-electron + SOURCES taskSingleElectron.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-single-muon SOURCES taskSingleMuon.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-single-muon-mult + SOURCES taskSingleMuonMult.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-single-muon-reader SOURCES taskSingleMuonReader.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGDQCore diff --git a/PWGHF/HFL/Tasks/taskElectronWeakBoson.cxx b/PWGHF/HFL/Tasks/taskElectronWeakBoson.cxx index 55f586dcbe7..a9b15ce7a0f 100644 --- a/PWGHF/HFL/Tasks/taskElectronWeakBoson.cxx +++ b/PWGHF/HFL/Tasks/taskElectronWeakBoson.cxx @@ -13,23 +13,47 @@ /// \brief task for WeakBoson (W/Z) based on electron in mid-rapidity /// \author S. Sakai & S. Ito (Univ. of Tsukuba) -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" +#ifndef HomogeneousField +#define HomogeneousField // o2-linter: disable=name/macro (required by KFParticle) +#endif -#include "EMCALBase/Geometry.h" -#include "EMCALCalib/BadChannelMap.h" - -#include "DataFormatsEMCAL/Cell.h" -#include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" +#include "PWGJE/DataModel/EMCALClusters.h" #include "Common/Core/RecoDecay.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" - -#include "PWGJE/DataModel/EMCALClusters.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" +#include "Tools/KFparticle/KFUtilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -45,15 +69,20 @@ struct HfTaskElectronWeakBoson { Configurable vtxZ{"vtxZ", 10.f, ""}; - Configurable etaTrLow{"etaTrLow", -0.6f, "minimun track eta"}; - Configurable etaTrUp{"etaTrUp", 0.6f, "maximum track eta"}; + Configurable etaTrMin{"etaTrMin", -1.0f, "minimun track eta"}; + Configurable etaTrMax{"etaTrMax", 1.0f, "maximum track eta"}; + Configurable etaEmcMax{"etaEmcMax", 0.6f, "maximum track eta"}; Configurable dcaxyMax{"dcaxyMax", 2.0f, "mximum DCA xy"}; Configurable chi2ItsMax{"chi2ItsMax", 15.0f, "its chi2 cut"}; Configurable ptMin{"ptMin", 3.0f, "minimum pT cut"}; + Configurable ptAssMin{"ptAssMin", 0.15, "minimum pT cut for associated hadrons"}; + Configurable ptMatch{"ptMatch", 0.001, "pT match in Z->ee and associated tracks"}; + Configurable ptZeeMin{"ptZeeMin", 20.0f, "minimum pT cut for Zee"}; Configurable chi2TpcMax{"chi2TpcMax", 4.0f, "tpc chi2 cut"}; Configurable nclItsMin{"nclItsMin", 2.0f, "its # of cluster cut"}; Configurable nclTpcMin{"nclTpcMin", 100.0f, "tpc # if cluster cut"}; Configurable nclcrossTpcMin{"nclcrossTpcMin", 100.0f, "tpc # of crossedRows cut"}; + Configurable nsigTpcMinLose{"nsigTpcMinLose", -3.0, "tpc Nsig lose lower cut"}; Configurable nsigTpcMin{"nsigTpcMin", -1.0, "tpc Nsig lower cut"}; Configurable nsigTpcMax{"nsigTpcMax", 3.0, "tpc Nsig upper cut"}; @@ -65,13 +94,59 @@ struct HfTaskElectronWeakBoson { Configurable m02Min{"m02Min", 0.1, "Minimum M02"}; Configurable m02Max{"m02Max", 0.9, "Maximum M02"}; Configurable rMatchMax{"rMatchMax", 0.05, "cluster - track matching cut"}; + Configurable eopMin{"eopMin", 0.9, "Minimum eop"}; + Configurable eopMax{"eopMax", 1.3, "Maximum eop"}; Configurable rIsolation{"rIsolation", 0.3, "cone radius for isolation cut"}; Configurable energyIsolationMax{"energyIsolationMax", 0.1, "isolation cut on energy"}; + Configurable trackIsolationMax{"trackIsolationMax", 3, "Maximum number of tracks in isolation cone"}; + + Configurable massZMin{"massZMin", 60.0, "Minimum Z mass (GeV/c^2)"}; + Configurable massZMax{"massZMax", 120.0, "Maximum Z mass (GeV/c^2)"}; + Configurable correctionPtElectron{"correctionPtElectron", 1.0, "momentum correction factor for decay electrons from Z boson"}; + + // flag for THn + Configurable isTHnElectron{"isTHnElectron", true, "Enables THn for electrons"}; + Configurable ptTHnThresh{"ptTHnThresh", 5.0, "Threshold for THn make"}; + + // Skimmed dataset processing configurations + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", true, "Enables processing of skimmed datasets"}; + Configurable cfgTriggerName{"cfgTriggerName", "fGammaHighPtEMCAL", "Trigger of interest (comma separated for multiple)"}; + + // CCDB service configurations + Configurable cfgCCDBPath{"cfgCCDBPath", "Users/m/mpuccio/EventFiltering/OTS/", "Path to CCDB for trigger data"}; + Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; + + // KFParticle + Configurable kfConstructMethod{"kfConstructMethod", 2, "KF Construct Method"}; + Configurable chiSqNdfMax{"chiSqNdfMax", 10, "Chi2 Max for mass reco by KF particle"}; + + // CCDB service object + Service ccdb; + + struct HfElectronCandidate { + float pt, eta, phi, energy; + int charge; + HfElectronCandidate(float ptr, float e, float ph, float en, int ch) + : pt(ptr), eta(e), phi(ph), energy(en), charge(ch) {} + + int sign() const { return charge; } + }; + std::vector selectedElectronsIso; + std::vector selectedElectronsAss; + + struct HfZeeCandidate { + float pt, eta, phi, mass, ptchild0, ptchild1; + int charge; + HfZeeCandidate(float ptr, float e, float ph, float m, int ch, float ptzee0, float ptzee1) + : pt(ptr), eta(e), phi(ph), mass(m), ptchild0(ptzee0), ptchild1(ptzee1), charge(ch) {} + }; + std::vector reconstructedZ; using SelectedClusters = o2::aod::EMCALClusters; // PbPb - using TrackEle = o2::soa::Join; + // using TrackEle = o2::soa::Join; + using TrackEle = o2::soa::Join; // pp // using TrackEle = o2::soa::Filtered>; @@ -80,7 +155,7 @@ struct HfTaskElectronWeakBoson { Filter eventFilter = (o2::aod::evsel::sel8 == true); Filter posZFilter = (nabs(o2::aod::collision::posZ) < vtxZ); - Filter etafilter = (aod::track::eta < etaTrUp) && (aod::track::eta > etaTrLow); + Filter etafilter = (aod::track::eta < etaTrMax) && (aod::track::eta > etaTrMin); Filter dcaxyfilter = (nabs(aod::track::dcaXY) < dcaxyMax); Filter filterGlobalTr = requireGlobalTrackInFilter(); @@ -94,30 +169,59 @@ struct HfTaskElectronWeakBoson { // Histogram registry: an object to hold your registrygrams HistogramRegistry registry{"registry"}; + // Zorro objects for skimmed data processing + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + void init(InitContext const&) { + // Configure CCDB + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + // CCDB path for debug + LOGF(info, "CCDB path for Zorro: %s", cfgCCDBPath.value.c_str()); + + // Setup Zorro Summary + if (cfgSkimmedProcessing) { + zorroSummary.setObject(zorro.getZorroSummary()); + } + + // add configurable for CCDB path + zorro.setBaseCCDBPath(cfgCCDBPath.value); // define axes you want to use - const AxisSpec axisZvtx{400, -20, 20, "Zvtx"}; + const AxisSpec axisZvtx{40, -20, 20, "Zvtx"}; const AxisSpec axisCounter{1, 0, 1, "events"}; - const AxisSpec axisEta{200, -1.0, 1.0, "#eta"}; + const AxisSpec axisEta{20, -1.0, 1.0, "#eta"}; const AxisSpec axisPt{nBinsPt, 0, binPtmax, "p_{T}"}; const AxisSpec axisNsigma{100, -5, 5, "N#sigma"}; + const AxisSpec axisDedx{150, 0, 150, "dEdx"}; const AxisSpec axisE{nBinsE, 0, binEmax, "Energy"}; const AxisSpec axisM02{100, 0, 1, "M02"}; - const AxisSpec axisdPhi{200, -1, 1, "dPhi"}; - const AxisSpec axisdEta{200, -1, 1, "dEta"}; + const AxisSpec axisdPhi{100, -0.5, 0.5, "dPhi"}; + const AxisSpec axisdEta{100, -0.5, 0.5, "dEta"}; + const AxisSpec axisdR{20, 0.0, 0.2, "dR"}; + const AxisSpec axisNcell{50, 0.0, 50.0, "Ncell"}; const AxisSpec axisPhi{350, 0, 7, "Phi"}; const AxisSpec axisEop{200, 0, 2, "Eop"}; - const AxisSpec axisChi2{500, 0.0, 50.0, "#chi^{2}"}; + const AxisSpec axisChi2{250, 0.0, 25.0, "#chi^{2}"}; const AxisSpec axisCluster{100, 0.0, 200.0, "counts"}; - const AxisSpec axisITSNCls{20, 0.0, 20, "counts"}; - const AxisSpec axisEMCtime{200, -100.0, 100, "EMC time"}; - const AxisSpec axisIsoEnergy{100, 0, 1, "Isolation energy(GeV/C)"}; + const AxisSpec axisITSNCls{10, 0.0, 10, "counts"}; + const AxisSpec axisEMCtime{100, -50.0, 50, "EMC time"}; + const AxisSpec axisIsoEnergy{100, 0, 1.0, "Isolation energy(GeV/C)"}; + const AxisSpec axisIsoTrack{15, -0.5, 14.5, "Isolation Track"}; + const AxisSpec axisInvMassZ{150, 0, 150, "M_{ee} (GeV/c^{2})"}; + const AxisSpec axisTrigger{3, -0.5, 2.5, "Trigger status of zorro"}; + const AxisSpec axisDPhiZh{64, -o2::constants::math::PIHalf, 3 * o2::constants::math::PIHalf, "#Delta#phi(Z-h)"}; + const AxisSpec axisPtHadron{50, 0, 50, "p_{T,hadron} (GeV/c)"}; + const AxisSpec axisPtZ{150, 0, 150, "p_{T,Z} (GeV/c)"}; + const AxisSpec axisSign{2, -2, 2, "charge sign"}; // create registrygrams - registry.add("hZvtx", "Z vertex", kTH1F, {axisZvtx}); - registry.add("hEventCounter", "hEventCounter", kTH1F, {axisCounter}); + registry.add("hZvtx", "Z vertex", kTH1D, {axisZvtx}); + registry.add("hEventCounterInit", "hEventCounterInit", kTH1D, {axisCounter}); + registry.add("hEventCounter", "hEventCounter", kTH1D, {axisCounter}); registry.add("hITSchi2", "ITS #chi^{2}", kTH1F, {axisChi2}); registry.add("hTPCchi2", "TPC #chi^{2}", kTH1F, {axisChi2}); registry.add("hTPCnCls", "TPC NCls", kTH1F, {axisCluster}); @@ -127,25 +231,40 @@ struct HfTaskElectronWeakBoson { registry.add("hPt", "track pt", kTH1F, {axisPt}); registry.add("hTPCNsigma", "TPC electron Nsigma", kTH2F, {{axisPt}, {axisNsigma}}); registry.add("hEnergy", "EMC cluster energy", kTH1F, {axisE}); - registry.add("hM02", "EMC M02", kTH2F, {{axisNsigma}, {axisM02}}); - registry.add("hM20", "EMC M20", kTH2F, {{axisNsigma}, {axisM02}}); - registry.add("hTrMatch", "Track EMC Match", kTH2F, {{axisdPhi}, {axisdEta}}); + registry.add("hEnergyNcell", "EMC cluster energy and cell", kTH2F, {{axisE}, {axisNcell}}); + registry.add("hTrMatchR", "Track EMC Match in radius", kTH2F, {{axisPt}, {axisdR}}); registry.add("hTrMatch_mim", "Track EMC Match minimu minimumm", kTH2F, {{axisdPhi}, {axisdEta}}); registry.add("hMatchPhi", "Match in Phi", kTH2F, {{axisPhi}, {axisPhi}}); registry.add("hMatchEta", "Match in Eta", kTH2F, {{axisEta}, {axisEta}}); registry.add("hEop", "energy momentum match", kTH2F, {{axisPt}, {axisEop}}); registry.add("hEopIsolation", "energy momentum match after isolation", kTH2F, {{axisPt}, {axisEop}}); + registry.add("hEopIsolationTr", "energy momentum match after isolationTr", kTH2F, {{axisPt}, {axisEop}}); registry.add("hEopNsigTPC", "Eop vs. Nsigma", kTH2F, {{axisNsigma}, {axisEop}}); registry.add("hEMCtime", "EMC timing", kTH1F, {axisEMCtime}); registry.add("hIsolationEnergy", "Isolation Energy", kTH2F, {{axisE}, {axisIsoEnergy}}); + registry.add("hIsolationTrack", "Isolation Track", kTH2F, {{axisE}, {axisIsoTrack}}); + registry.add("hInvMassZeeLs", "invariant mass for Z LS pair", kTH2F, {{axisPt}, {axisInvMassZ}}); + registry.add("hInvMassZeeUls", "invariant mass for Z ULS pair", kTH2F, {{axisPt}, {axisInvMassZ}}); + registry.add("hKfInvMassZeeLs", "invariant mass for Z LS pair KFp", kTH2F, {{axisPt}, {axisInvMassZ}}); + registry.add("hKfInvMassZeeUls", "invariant mass for Z ULS pair KFp", kTH2F, {{axisPt}, {axisInvMassZ}}); + registry.add("hTHnElectrons", "electron info", HistType::kTHnSparseF, {axisPt, axisNsigma, axisM02, axisEop, axisIsoEnergy, axisIsoTrack, axisEta, axisDedx}); + registry.add("hTHnTrMatch", "Track EMC Match", HistType::kTHnSparseF, {axisPt, axisdPhi, axisdEta}); + + // Z-hadron correlation histograms + registry.add("hZHadronDphi", "Z-hadron #Delta#phi correlation", HistType::kTHnSparseF, {axisSign, axisPtZ, axisDPhiZh}); + registry.add("hZptSpectrum", "Z boson p_{T} spectrum", kTH2F, {{axisSign}, {axisPtZ}}); + + // hisotgram for EMCal trigger + registry.add("hEMCalTrigger", "EMCal trigger", kTH1D, {axisTrigger}); } - bool isIsolatedCluster(const o2::aod::EMCALCluster& cluster, - const SelectedClusters& clusters) + + double getIsolatedCluster(const o2::aod::EMCALCluster& cluster, + const SelectedClusters& clusters) { - float energySum = 0.0; - float isoEnergy = 10.0; - float etaAssCluster = cluster.eta(); - float phiAssCluster = cluster.phi(); + double energySum = 0.0; + double isoEnergy = 10.0; + double etaAssCluster = cluster.eta(); + double phiAssCluster = cluster.phi(); for (const auto& associateCluster : clusters) { // Calculate angular distances @@ -170,14 +289,155 @@ struct HfTaskElectronWeakBoson { registry.fill(HIST("hIsolationEnergy"), cluster.energy(), isoEnergy); - return (isoEnergy < energyIsolationMax); + return (isoEnergy); + } + int getIsolatedTrack(double etaEle, + double phiEle, + float ptEle, + TrackEle const& tracks) + { + int trackCount = 0; + + for (const auto& track : tracks) { + + double dEta = track.eta() - etaEle; + double dPhi = track.phi() - phiEle; + dPhi = RecoDecay::constrainAngle(dPhi, -o2::constants::math::PI); + + double deltaR = std::sqrt(dEta * dEta + dPhi * dPhi); + + if (deltaR < rIsolation) { + trackCount++; + } + } + + registry.fill(HIST("hIsolationTrack"), ptEle, trackCount); + + return (trackCount); + } + + void recoMassZee(KFParticle kfpIsoEle, + int charge, + TrackEle const& tracks) + { + // LOG(info) << "Invarimass cal by KF particle "; + for (const auto& track : tracks) { + + if (track.pt() < ptZeeMin) { + continue; + } + if (std::abs(track.tpcNSigmaEl()) > nsigTpcMax) { + continue; + } + if (std::abs(track.eta()) > etaTrMax) { + continue; + } + int pdgAss = kElectron; + if (track.sign() > 0) { + pdgAss = kPositron; + } + + KFPTrack kfpTrackAssEle = createKFPTrackFromTrack(track); + KFParticle kfpAssEle(kfpTrackAssEle, pdgAss); + // reco by RecoDecay + auto child1 = RecoDecayPtEtaPhi::pVector(kfpIsoEle.GetPt() * correctionPtElectron, kfpIsoEle.GetEta(), kfpIsoEle.GetPhi()); + auto child2 = RecoDecayPtEtaPhi::pVector(kfpAssEle.GetPt() * correctionPtElectron, kfpAssEle.GetEta(), kfpAssEle.GetPhi()); + double invMassEE = RecoDecay::m(std::array{child1, child2}, std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassElectron}); + + // reco by KFparticle + const KFParticle* electronPairs[2] = {&kfpIsoEle, &kfpAssEle}; + KFParticle zeeKF; + zeeKF.SetConstructMethod(kfConstructMethod); + zeeKF.Construct(electronPairs, 2); + // LOG(info) << "Invarimass cal by KF particle Chi2/NDF = " << zeeKF.GetChi2()/zeeKF.GetNDF(); + float chiSqNdf = zeeKF.GetChi2() / zeeKF.GetNDF(); + if (zeeKF.GetNDF() < 1) { + continue; + } + if (zeeKF.GetChi2() < 0) { + continue; + } + if (chiSqNdf > chiSqNdfMax) { + continue; + } + float massZee, massZeeErr; + zeeKF.GetMass(massZee, massZeeErr); + // LOG(info) << "Invarimass cal by KF particle mass = " << massZee; + // LOG(info) << "Invarimass cal by RecoDecay = " << invMassEE; + + if (track.sign() * charge > 0) { + registry.fill(HIST("hKfInvMassZeeLs"), kfpIsoEle.GetPt(), massZee); + registry.fill(HIST("hInvMassZeeLs"), kfpIsoEle.GetPt(), invMassEE); + } else { + registry.fill(HIST("hKfInvMassZeeUls"), kfpIsoEle.GetPt(), massZee); + registry.fill(HIST("hInvMassZeeUls"), kfpIsoEle.GetPt(), invMassEE); + } + + reconstructedZ.emplace_back( + zeeKF.GetPt(), + zeeKF.GetEta(), + zeeKF.GetPhi(), + massZee, + track.sign() * charge, + kfpIsoEle.GetPt(), + kfpAssEle.GetPt()); + } } void process(soa::Filtered::iterator const& collision, + aod::BCsWithTimestamps const&, SelectedClusters const& emcClusters, TrackEle const& tracks, o2::aod::EMCALMatchedTracks const& matchedtracks) { + registry.fill(HIST("hEventCounterInit"), 0.5); + + // Get BC for this collision + auto bc = collision.bc_as(); + uint64_t globalBC = bc.globalBC(); + int runNumber = bc.runNumber(); + + // Initialize Zorro for the first event (once per run) + static bool isFirstEvent = true; + static int lastRunNumber = -1; + + if ((isFirstEvent || runNumber != lastRunNumber) && cfgSkimmedProcessing) { + LOGF(info, "Initializing Zorro for run %d", runNumber); + uint64_t currentTimestamp = bc.timestamp(); + + // debug for timestamp + LOGF(info, "Using CCDB path: %s, timestamp: %llu", cfgCCDBPath.value.c_str(), currentTimestamp); + + // initialize Zorro + zorro.initCCDB(ccdb.service, runNumber, currentTimestamp, cfgTriggerName); + isFirstEvent = false; + lastRunNumber = runNumber; + + // initialize magnetic field + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(ccdbPathGrpMag, currentTimestamp); + o2::base::Propagator::initFieldFromGRP(grpo); + double magneticField = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "magneticField = " << magneticField; + if (magneticField) + KFParticle::SetField(magneticField); + } + + // Check if this is a triggered event using Zorro + bool isTriggered = true; + if (cfgSkimmedProcessing) { + isTriggered = zorro.isSelected(globalBC); + registry.fill(HIST("hEMCalTrigger"), isTriggered ? 1 : 0); + + // Skip event if not triggered and we're processing skimmed data + if (!isTriggered) { + return; + } + } + // initialze for inclusive-electron + selectedElectronsIso.clear(); + selectedElectronsAss.clear(); + reconstructedZ.clear(); + registry.fill(HIST("hEventCounter"), 0.5); // LOGF(info, "Collision index : %d", collision.index()); @@ -188,22 +448,27 @@ struct HfTaskElectronWeakBoson { for (const auto& track : tracks) { - if (std::abs(track.eta()) > etaTrUp) - continue; - if (track.tpcNClsCrossedRows() < nclcrossTpcMin) + if (std::abs(track.eta()) > etaTrMax) { continue; - if (std::abs(track.dcaXY()) > dcaxyMax) + } + if (track.tpcNClsCrossedRows() < nclcrossTpcMin) { continue; - if (track.itsChi2NCl() > chi2ItsMax) + } + if (std::abs(track.dcaXY()) > dcaxyMax) { continue; - if (track.tpcChi2NCl() > chi2TpcMax) + } + if (track.itsChi2NCl() > chi2ItsMax) { continue; - if (track.tpcNClsFound() < nclTpcMin) + } + if (track.tpcChi2NCl() > chi2TpcMax) { continue; - if (track.itsNCls() < nclItsMin) + } + if (track.tpcNClsFound() < nclTpcMin) { continue; - if (track.pt() < ptMin) + } + if (track.itsNCls() < nclItsMin) { continue; + } registry.fill(HIST("hEta"), track.eta()); registry.fill(HIST("hITSchi2"), track.itsChi2NCl()); @@ -214,11 +479,27 @@ struct HfTaskElectronWeakBoson { registry.fill(HIST("hPt"), track.pt()); registry.fill(HIST("hTPCNsigma"), track.p(), track.tpcNSigmaEl()); + float energyTrk = 0.0; + + if (track.pt() > ptAssMin) { + selectedElectronsAss.emplace_back( + track.pt(), + track.eta(), + track.phi(), + energyTrk, + track.sign()); + } + + if (track.pt() < ptMin) { + continue; + } // track - match // continue; if (track.phi() < phiEmcMin || track.phi() > phiEmcMax) continue; + if (std::abs(track.eta()) > etaEmcMax) + continue; auto tracksofcluster = matchedtracks.sliceBy(perClusterMatchedTracks, track.globalIndex()); // LOGF(info, "Number of matched track: %d", tracksofcluster.size()); @@ -226,16 +507,15 @@ struct HfTaskElectronWeakBoson { double rMin = 999.9; double dPhiMin = 999.9; double dEtaMin = 999.9; + bool isIsolated = false; + bool isIsolatedTr = false; if (tracksofcluster.size()) { int nMatch = 0; for (const auto& match : tracksofcluster) { if (match.emcalcluster_as().time() < timeEmcMin || match.emcalcluster_as().time() > timeEmcMax) continue; - if (match.emcalcluster_as().m02() < m02Min || match.emcalcluster_as().m02() > m02Max) - continue; - float m20Emc = match.emcalcluster_as().m20(); float m02Emc = match.emcalcluster_as().m02(); float energyEmc = match.emcalcluster_as().energy(); double phiEmc = match.emcalcluster_as().phi(); @@ -244,6 +524,7 @@ struct HfTaskElectronWeakBoson { // LOG(info) << "tr phi0 = " << match.track_as().phi(); // LOG(info) << "tr phi1 = " << track.phi(); // LOG(info) << "emc phi = " << phiEmc; + if (nMatch == 0) { double dEta = match.track_as().trackEtaEmcal() - etaEmc; double dPhi = match.track_as().trackPhiEmcal() - phiEmc; @@ -258,30 +539,64 @@ struct HfTaskElectronWeakBoson { dPhiMin = dPhi; dEtaMin = dEta; } - registry.fill(HIST("hTrMatch"), dPhi, dEta); + registry.fill(HIST("hTHnTrMatch"), match.track_as().pt(), dPhi, dEta); registry.fill(HIST("hEMCtime"), timeEmc); registry.fill(HIST("hEnergy"), energyEmc); - if (r > rMatchMax) + if (std::abs(dPhi) > rMatchMax || std::abs(dEta) > rMatchMax) continue; + registry.fill(HIST("hTrMatchR"), match.track_as().pt(), r); + registry.fill(HIST("hEnergyNcell"), energyEmc, match.emcalcluster_as().nCells()); + const auto& cluster = match.emcalcluster_as(); - bool isIsolated = isIsolatedCluster(cluster, emcClusters); double eop = energyEmc / match.track_as().p(); + + double isoEnergy = getIsolatedCluster(cluster, emcClusters); + + int trackCount = getIsolatedTrack(track.eta(), track.phi(), track.pt(), tracks) - 1; + + if (match.track_as().pt() > ptTHnThresh && isTHnElectron) { + registry.fill(HIST("hTHnElectrons"), match.track_as().pt(), match.track_as().tpcNSigmaEl(), m02Emc, eop, isoEnergy, trackCount, track.eta(), track.tpcSignal()); + } // LOG(info) << "E/p" << eop; registry.fill(HIST("hEopNsigTPC"), match.track_as().tpcNSigmaEl(), eop); - registry.fill(HIST("hM02"), match.track_as().tpcNSigmaEl(), m02Emc); - registry.fill(HIST("hM20"), match.track_as().tpcNSigmaEl(), m20Emc); + if (match.emcalcluster_as().m02() < m02Min || match.emcalcluster_as().m02() > m02Max) + continue; + if (match.track_as().tpcNSigmaEl() > nsigTpcMin && match.track_as().tpcNSigmaEl() < nsigTpcMax) { registry.fill(HIST("hEop"), match.track_as().pt(), eop); + if (eop > eopMin && eop < eopMax && isoEnergy < energyIsolationMax) + isIsolated = true; + if (eop > eopMin && eop < eopMax && trackCount < trackIsolationMax) + isIsolatedTr = true; - if (isIsolated) { + if (isIsolated && isIsolatedTr) { registry.fill(HIST("hEopIsolation"), match.track_as().pt(), eop); + + if (match.track_as().pt() > ptZeeMin) { + int pdgIso = kElectron; + if (match.track_as().sign() > 0) { + pdgIso = kPositron; + } + KFPTrack kfpTrackIsoEle = createKFPTrackFromTrack(match.track_as()); + KFParticle kfpIsoEle(kfpTrackIsoEle, pdgIso); + recoMassZee(kfpIsoEle, match.track_as().sign(), tracks); + + selectedElectronsIso.emplace_back( + match.track_as().pt(), + match.track_as().eta(), + match.track_as().phi(), + energyEmc, + match.track_as().sign()); + } + } + if (isIsolatedTr) { + registry.fill(HIST("hEopIsolationTr"), match.track_as().pt(), eop); } } } - nMatch++; } } @@ -292,6 +607,27 @@ struct HfTaskElectronWeakBoson { } } // end of track loop + // Z-hadron + if (reconstructedZ.size() > 0) { + for (const auto& zBoson : reconstructedZ) { + // Z boson selection + if (zBoson.mass < massZMin || zBoson.mass > massZMax) { + continue; + } + registry.fill(HIST("hZptSpectrum"), zBoson.charge, zBoson.pt); + for (const auto& trackAss : selectedElectronsAss) { + if (std::abs(trackAss.pt - zBoson.ptchild0) < ptMatch) { + continue; + } + if (std::abs(trackAss.pt - zBoson.ptchild1) < ptMatch) { + continue; + } + // calculate Z-h correlation + double deltaPhi = RecoDecay::constrainAngle(trackAss.phi - zBoson.phi, -o2::constants::math::PIHalf); + registry.fill(HIST("hZHadronDphi"), zBoson.charge, zBoson.pt, deltaPhi); + } + } + } // end of Z-hadron correlation } }; diff --git a/PWGHF/HFL/Tasks/taskMuonCharmBeautySeparation.cxx b/PWGHF/HFL/Tasks/taskMuonCharmBeautySeparation.cxx index cc2637cedc3..5fca08870fa 100644 --- a/PWGHF/HFL/Tasks/taskMuonCharmBeautySeparation.cxx +++ b/PWGHF/HFL/Tasks/taskMuonCharmBeautySeparation.cxx @@ -14,13 +14,18 @@ /// \brief Task to estimate HF->mu in the forward direction and use DCA observable to separate b-> mu, c-> mu. /// \author Shreyasi Acharya , LPC, France -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/TrackFwd.h" - #include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include + +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; diff --git a/PWGHF/HFL/Tasks/taskSingleElectron.cxx b/PWGHF/HFL/Tasks/taskSingleElectron.cxx new file mode 100644 index 00000000000..d8a8b6e5b87 --- /dev/null +++ b/PWGHF/HFL/Tasks/taskSingleElectron.cxx @@ -0,0 +1,202 @@ +// 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. +/// +/// \file taskSingleElectron.cxx +/// \brief task for electrons from heavy-flavour hadron decays +/// \author Jonghan Park (Jeonbuk National University) + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include + +using namespace o2; +using namespace o2::constants::math; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct HfTaskSingleElectron { + + // Produces + + // Configurable + Configurable nContribMin{"nContribMin", 2, "min number of contributors"}; + Configurable posZMax{"posZMax", 10., "max posZ cut"}; + Configurable ptTrackMax{"ptTrackMax", 10., "max pt cut"}; + Configurable ptTrackMin{"ptTrackMin", 0.5, "min pt cut"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "eta cut"}; + Configurable tpcNCrossedRowMin{"tpcNCrossedRowMin", 70, "max of TPC n cluster crossed rows"}; + Configurable tpcNClsFoundOverFindableMin{"tpcNClsFoundOverFindableMin", 0.8, "min # of TPC found/findable clusters"}; + Configurable tpcChi2perNClMax{"tpcChi2perNClMax", 4., "min # of tpc chi2 per clusters"}; + Configurable itsIBClsMin{"itsIBClsMin", 3, "min # of its clusters in IB"}; + Configurable dcaxyMax{"dcaxyMax", 1., "max of track dca in xy"}; + Configurable dcazMax{"dcazMax", 2., "max of track dca in z"}; + Configurable tofNSigmaMax{"tofNSigmaMax", 3., "max of tof nsigma"}; + Configurable tpcNSigmaMin{"tpcNSigmaMin", -1., "min of tpc nsigma"}; + Configurable tpcNSigmaMax{"tpcNSigmaMax", 3., "max of tpc nsigma"}; + + Configurable nBinsPt{"nBinsPt", 100, "N bins in pT histo"}; + + // SliceCache + SliceCache cache; + + // using declarations + using MyCollisions = soa::Join; + using TracksEl = soa::Join; + + // Filter + Filter collZFilter = nabs(aod::collision::posZ) < posZMax; + + // Partition + + // ConfigurableAxis + ConfigurableAxis axisPtEl{"axisPtEl", {VARIABLE_WIDTH, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.75f, 2.0f, 2.25f, 2.5f, 2.75f, 3.f, 3.5f, 4.0f, 5.0f, 6.0f, 8.0f, 10.0f}, "electron pt bins"}; + + // AxisSpec + const AxisSpec axisEvt{4, 0., 4., "nEvents"}; + const AxisSpec axisNCont{100, 0., 100., "nCont"}; + const AxisSpec axisPosZ{600, -30., 30., "Z_{pos}"}; + const AxisSpec axisEta{30, -1.5, +1.5, "#eta"}; + const AxisSpec axisPt{nBinsPt, 0., 15., "p_{T}"}; + const AxisSpec axisNsig{800, -20., 20.}; + const AxisSpec axisTrackIp{4000, -0.2, 0.2, "dca"}; + + // Histogram registry + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(InitContext const&) + { + // create histograms + histos.add("hEventCounter", "hEventCounter", kTH1F, {axisEvt}); + histos.add("nEvents", "Number of events", kTH1F, {{1, 0., 1.}}); + histos.add("VtxZ", "VtxZ; cm; entries", kTH1F, {axisPosZ}); + histos.add("etaTrack", "etaTrack; #eta; entries", kTH1F, {axisEta}); + histos.add("ptTrack", "#it{p}_{T} distribution of selected tracks; #it{p}_{T} (GeV/#it{c}); entries", kTH1F, {axisPt}); + + // QA plots for trigger track selection + histos.add("tpcNClsTrack", "tpcNClsTrack", kTH1F, {{200, 0, 200}}); + histos.add("tpcFoundFindableTrack", "", kTH1F, {{10, 0, 1}}); + histos.add("tpcChi2Track", "", kTH1F, {{100, 0, 10}}); + histos.add("itsIBClsTrack", "", kTH1F, {{10, 0, 10}}); + histos.add("dcaXYTrack", "", kTH1F, {{600, -3, 3}}); + histos.add("dcaZTrack", "", kTH1F, {{600, -3, 3}}); + + // pid + histos.add("tofNSigPt", "", kTH2F, {{axisPtEl}, {axisNsig}}); + histos.add("tofNSigPtQA", "", kTH2F, {{axisPtEl}, {axisNsig}}); + histos.add("tpcNSigPt", "", kTH2F, {{axisPtEl}, {axisNsig}}); + histos.add("tpcNSigPtAfterTofCut", "", kTH2F, {{axisPtEl}, {axisNsig}}); + histos.add("tpcNSigPtQA", "", kTH2F, {{axisPtEl}, {axisNsig}}); + + // track impact parameter + histos.add("dcaTrack", "", kTH2F, {{axisPtEl}, {axisTrackIp}}); + } + + template + bool trackSel(const TrackType& track) + { + if ((track.pt() > ptTrackMax) || (track.pt() < ptTrackMin)) { + return false; + } + if (std::abs(track.eta()) > etaTrackMax) { + return false; + } + + if (track.tpcNClsCrossedRows() < tpcNCrossedRowMin) { + return false; + } + if (track.tpcCrossedRowsOverFindableCls() < tpcNClsFoundOverFindableMin) { + return false; + } + if (track.tpcChi2NCl() > tpcChi2perNClMax) { + return false; + } + + if (!(track.itsNClsInnerBarrel() == itsIBClsMin)) { + return false; + } + + if (std::abs(track.dcaXY()) > dcaxyMax) { + return false; + } + if (std::abs(track.dcaZ()) > dcazMax) { + return false; + } + + return true; + } + + void process(soa::Filtered::iterator const& collision, + TracksEl const& tracks) + { + float flagEventFill = 0.5; + float flagAnalysedEvt = 0.5; + histos.fill(HIST("hEventCounter"), flagEventFill); + + if (!collision.sel8()) { + return; + } + flagEventFill += 1.; + histos.fill(HIST("hEventCounter"), flagEventFill); + + if (collision.numContrib() < nContribMin) { + return; + } + flagEventFill += 1.; + histos.fill(HIST("hEventCounter"), flagEventFill); + + histos.fill(HIST("VtxZ"), collision.posZ()); + histos.fill(HIST("nEvents"), flagAnalysedEvt); + + for (const auto& track : tracks) { + + if (!trackSel(track)) { + continue; + } + + histos.fill(HIST("etaTrack"), track.eta()); + histos.fill(HIST("ptTrack"), track.pt()); + + histos.fill(HIST("tpcNClsTrack"), track.tpcNClsCrossedRows()); + histos.fill(HIST("tpcFoundFindableTrack"), track.tpcCrossedRowsOverFindableCls()); + histos.fill(HIST("tpcChi2Track"), track.tpcChi2NCl()); + histos.fill(HIST("itsIBClsTrack"), track.itsNClsInnerBarrel()); + histos.fill(HIST("dcaXYTrack"), track.dcaXY()); + histos.fill(HIST("dcaZTrack"), track.dcaZ()); + + histos.fill(HIST("tofNSigPt"), track.pt(), track.tofNSigmaEl()); + histos.fill(HIST("tpcNSigPt"), track.pt(), track.tpcNSigmaEl()); + + if (std::abs(track.tofNSigmaEl()) > tofNSigmaMax) { + continue; + } + histos.fill(HIST("tofNSigPtQA"), track.pt(), track.tofNSigmaEl()); + histos.fill(HIST("tpcNSigPtAfterTofCut"), track.pt(), track.tpcNSigmaEl()); + + if (track.tpcNSigmaEl() < tpcNSigmaMin || track.tpcNSigmaEl() > tpcNSigmaMax) { + continue; + } + histos.fill(HIST("tpcNSigPtQA"), track.pt(), track.tpcNSigmaEl()); + + histos.fill(HIST("dcaTrack"), track.pt(), track.dcaXY()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/HFL/Tasks/taskSingleMuon.cxx b/PWGHF/HFL/Tasks/taskSingleMuon.cxx index 73445124ae9..9b38f3f45a6 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuon.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuon.cxx @@ -13,17 +13,23 @@ /// \brief Task used to extract the observables on single muons needed for the HF-muon analysis. /// \author Maolin Zhang , CCNU -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/TrackFwd.h" - #include "Common/Core/RecoDecay.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + using namespace o2; using namespace o2::aod; using namespace o2::framework; diff --git a/PWGHF/HFL/Tasks/taskSingleMuonMult.cxx b/PWGHF/HFL/Tasks/taskSingleMuonMult.cxx new file mode 100644 index 00000000000..b51635dda6b --- /dev/null +++ b/PWGHF/HFL/Tasks/taskSingleMuonMult.cxx @@ -0,0 +1,271 @@ +// 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. + +/// \file taskSingleMuonMult.cxx +/// \brief Task used to study the Open heavy flavour decay muon production as a function of multiplicity. +/// \author Md Samsul Islam , IITB + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::fwdtrack; + +struct HfTaskSingleMuonMult { + + // enum for event selection bins + enum EventSelection { + AllEvents = 0, + Sel8, + VtxZAfterSel, + NEventSelection + }; + + // enum for muon track selection bins + enum MuonSelection { + NoCut = 0, + EtaCut, + RAbsorbCut, + PDcaCut, + Chi2Cut, + NMuonSelection + }; + + Configurable zVtxMax{"zVtxMax", 10., "maxium z of primary vertex [cm]"}; + Configurable ptTrackMin{"ptTrackMin", 0.15, "minimum pt of tracks"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "maximum pseudorapidity of tracks"}; + Configurable etaMin{"etaMin", -3.6, "minimum pseudorapidity"}; + Configurable etaMax{"etaMax", -2.5, "maximum pseudorapidity"}; + Configurable pDcaMin{"pDcaMin", 324., "p*DCA value for small RAbsorb"}; + Configurable pDcaMax{"pDcaMax", 594., "p*DCA value for large RAbsorb"}; + Configurable rAbsorbMin{"rAbsorbMin", 17.6, "R at absorber end minimum value"}; + Configurable rAbsorbMax{"rAbsorbMax", 89.5, "R at absorber end maximum value"}; + Configurable rAbsorbMid{"rAbsorbMid", 26.5, "R at absorber end split point for different p*DCA selections"}; + Configurable reduceOrphMft{"reduceOrphMft", true, "reduce orphan MFT tracks"}; + + using MyCollisions = soa::Join; + using MyMuons = soa::Join; + using MyMcMuons = soa::Join; + using MyTracks = soa::Filtered>; + + // Filter Global Track for Multiplicty + Filter trackFilter = ((nabs(aod::track::eta) < etaTrackMax) && (aod::track::pt > ptTrackMin)); + + // Number the types of muon tracks + static constexpr uint8_t NTrackTypes{ForwardTrackTypeEnum::MCHStandaloneTrack + 1}; + + HistogramRegistry registry{"registry"}; + + void init(InitContext&) + { + AxisSpec axisCent = {101, -0.5, 100.5, "centrality"}; + AxisSpec axisEvent{NEventSelection, 0, NEventSelection, "Event Selection"}; + AxisSpec axisVtxZ{80, -20., 20., "#it{z}_{vtx} (cm)"}; + AxisSpec axisMuon{NMuonSelection, 0, NMuonSelection, "Muon Selection"}; + AxisSpec axisNCh{500, 0.5, 500.5, "#it{N}_{ch}"}; + AxisSpec axisNMu{20, -0.5, 19.5, "#it{N}_{#mu}"}; + AxisSpec axisPt{1000, 0., 500., "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisEta{250, -5., 5., "#it{#eta}"}; + AxisSpec axisTheta{500, 170., 180., "#it{#theta}"}; + AxisSpec axisRAbsorb{1000, 0., 100., "#it{R}_{Absorb} (cm)"}; + AxisSpec axisDCA{500, 0., 5., "#it{DCA}_{xy} (cm)"}; + AxisSpec axisChi2MatchMCHMFT{1000, 0., 1000., "MCH-MFT matching #chi^{2}"}; + AxisSpec axisSign{5, -2.5, 2.5, "Charge"}; + AxisSpec axisPDca{100000, 0, 100000, "#it{p} #times DCA (GeV/#it{c} * cm)"}; + AxisSpec axisDCAx{1000, -5., 5., "#it{DCA}_{x or y} (cm)"}; + AxisSpec axisEtaDif{200, -2., 2., "#it{#eta} diff"}; + AxisSpec axisDeltaPt{10000, -50, 50, "#Delta #it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisTrackType{8, -1.5, 6.5, "TrackType"}; + AxisSpec axisPtDif{200, -2., 2., "#it{p}_{T} diff (GeV/#it{c})"}; + + registry.add("hCentrality", "Centrality Percentile", {HistType::kTH1F, {axisCent}}); + registry.add("hEventSel", " Number of Events", {HistType::kTH1F, {axisEvent}}); + registry.add("hNch", "Charged Particle Multiplicity", {HistType::kTH1F, {axisNCh}}); + registry.add("hVtxZBeforeSel", "Z-vertex distribution before zVtx Cut", {HistType::kTH1F, {axisVtxZ}}); + registry.add("hVtxZAfterSel", "Z-vertex distribution after zVtx Cut", {HistType::kTH1F, {axisVtxZ}}); + + registry.add("hMuonSel", "Selection of muon tracks at various kinematic cuts", {HistType::kTH1F, {axisMuon}}); + registry.add("hMuBeforeMatchMFT", "Muon information before any Kinemeatic cuts applied", {HistType::kTHnSparseF, {axisCent, axisNCh, axisPt, axisEta, axisTheta, axisRAbsorb, axisDCA, axisPDca, axisChi2MatchMCHMFT, axisTrackType}, 10}); + registry.add("hMuBeforeAccCuts", "Muon information before applying Acceptance cuts", {HistType::kTHnSparseF, {axisCent, axisNCh, axisPt, axisEta, axisTheta, axisRAbsorb, axisDCA, axisPDca, axisChi2MatchMCHMFT, axisTrackType}, 10}); + registry.add("h3DCABeforeAccCuts", "DCAx,DCAy,DCAz information before Acceptance cuts", {HistType::kTH3F, {axisDCAx, axisDCAx, axisTrackType}}); + registry.add("hMuDeltaPtBeforeAccCuts", "Muon information with DeltaPt before applying Acceptance cuts", {HistType::kTHnSparseF, {axisCent, axisNCh, axisPt, axisEta, axisTheta, axisRAbsorb, axisDCA, axisPDca, axisChi2MatchMCHMFT, axisDeltaPt}, 10}); + registry.add("hMuAfterEtaCuts", "Muon information after applying Eta cuts", {HistType::kTHnSparseF, {axisCent, axisNCh, axisPt, axisEta, axisTheta, axisRAbsorb, axisDCA, axisPDca, axisChi2MatchMCHMFT, axisTrackType}, 10}); + registry.add("hMuAfterRAbsorbCuts", "Muon information after applying RAbsorb cuts", {HistType::kTHnSparseF, {axisCent, axisNCh, axisPt, axisEta, axisTheta, axisRAbsorb, axisDCA, axisPDca, axisChi2MatchMCHMFT, axisTrackType}, 10}); + registry.add("hMuAfterPdcaCuts", "Muon information after applying Pdca cuts", {HistType::kTHnSparseF, {axisCent, axisNCh, axisPt, axisEta, axisTheta, axisRAbsorb, axisDCA, axisPDca, axisChi2MatchMCHMFT, axisTrackType}, 10}); + registry.add("hMuAfterAccCuts", "Muon information after applying all Kinematic cuts", {HistType::kTHnSparseF, {axisCent, axisNCh, axisPt, axisEta, axisTheta, axisRAbsorb, axisDCA, axisPDca, axisChi2MatchMCHMFT, axisTrackType}, 10}); + registry.add("h3DCAAfterAccCuts", "DCAx,DCAy,DCAz information after Acceptance cuts", {HistType::kTH3F, {axisDCAx, axisDCAx, axisTrackType}}); + registry.add("hMuDeltaPtAfterAccCuts", "Muon information with DeltaPt after applying Acceptance cuts", {HistType::kTHnSparseF, {axisCent, axisNCh, axisPt, axisEta, axisTheta, axisRAbsorb, axisDCA, axisPDca, axisChi2MatchMCHMFT, axisDeltaPt}, 10}); + + registry.add("hTHnTrk", "Muon information with multiplicity", {HistType::kTHnSparseF, {axisCent, axisNCh, axisPt, axisEta, axisSign}, 5}); + registry.add("h3MultNchNmu", "Number of muons and multiplicity", {HistType::kTH3F, {axisCent, axisNCh, axisNMu}}); + registry.add("hMultNchNmuTrackType", "Number of muons with different types and multiplicity", {HistType::kTHnSparseF, {axisCent, axisNCh, axisNMu, axisTrackType}, 4}); + + auto hEvstat = registry.get(HIST("hEventSel")); + auto* xEv = hEvstat->GetXaxis(); + xEv->SetBinLabel(AllEvents + 1, "All events"); + xEv->SetBinLabel(Sel8 + 1, "sel8"); + xEv->SetBinLabel(VtxZAfterSel + 1, "VtxZAfterSel"); + + auto hMustat = registry.get(HIST("hMuonSel")); + auto* xMu = hMustat->GetXaxis(); + xMu->SetBinLabel(NoCut + 1, "noCut"); + xMu->SetBinLabel(EtaCut + 1, "etaCut"); + xMu->SetBinLabel(RAbsorbCut + 1, "RAbsorbCut"); + xMu->SetBinLabel(PDcaCut + 1, "pDcaCut"); + xMu->SetBinLabel(Chi2Cut + 1, "chi2Cut"); + } + + void process(MyCollisions::iterator const& collision, + MyTracks const& tracks, + MyMuons const& muons) + { + registry.fill(HIST("hEventSel"), AllEvents); + + if (!collision.sel8()) { + return; + } + registry.fill(HIST("hEventSel"), Sel8); + registry.fill(HIST("hVtxZBeforeSel"), collision.posZ()); + + if (std::abs(collision.posZ()) > zVtxMax) { + return; + } + registry.fill(HIST("hEventSel"), VtxZAfterSel); + registry.fill(HIST("hVtxZAfterSel"), collision.posZ()); + + // T0M centrality + const auto cent = collision.centFT0M(); + registry.fill(HIST("hCentrality"), cent); + + // Charged particles + for (const auto& track : tracks) { + if (!track.isGlobalTrack()) { + continue; + } + } + + auto nCh{tracks.size()}; + if (nCh < 1) { + return; + } + registry.fill(HIST("hNch"), nCh); + + for (const auto& track : tracks) { + registry.fill(HIST("hTHnTrk"), cent, nCh, track.pt(), track.eta(), track.sign()); + } + + // muons per event + int nMu{0}; + int nMuType[NTrackTypes] = {0}; + + for (const auto& muon : muons) { + const auto pt{muon.pt()}, eta{muon.eta()}, theta{90.0f - ((std::atan(muon.tgl())) * constants::math::Rad2Deg)}, pDca{muon.pDca()}, rAbsorb{muon.rAtAbsorberEnd()}, chi2{muon.chi2MatchMCHMFT()}; + const auto dcaXY{RecoDecay::sqrtSumOfSquares(muon.fwdDcaX(), muon.fwdDcaY())}; + const auto muTrackType{muon.trackType()}; + + registry.fill(HIST("hMuBeforeMatchMFT"), cent, nCh, pt, eta, theta, rAbsorb, dcaXY, pDca, chi2, muTrackType); + + // histograms before the acceptance cuts + registry.fill(HIST("hMuonSel"), NoCut); + registry.fill(HIST("hMuBeforeAccCuts"), cent, nCh, pt, eta, theta, rAbsorb, dcaXY, pDca, chi2, muTrackType); + registry.fill(HIST("h3DCABeforeAccCuts"), muon.fwdDcaX(), muon.fwdDcaY(), muTrackType); + + if (muon.has_matchMCHTrack()) { + auto muonType3 = muon.template matchMCHTrack_as(); + auto dpt = muonType3.pt() - pt; + if (muTrackType == ForwardTrackTypeEnum::GlobalMuonTrack) { + registry.fill(HIST("hMuDeltaPtBeforeAccCuts"), cent, nCh, pt, eta, theta, rAbsorb, dcaXY, pDca, chi2, dpt); + } + } + + // Apply various standard muon acceptance cuts + // eta cuts + if ((eta >= etaMax) || (eta < etaMin)) { + continue; + } + registry.fill(HIST("hMuonSel"), EtaCut); + registry.fill(HIST("hMuAfterEtaCuts"), cent, nCh, pt, eta, theta, rAbsorb, dcaXY, pDca, chi2, muTrackType); + + // Rabsorb cuts + if ((rAbsorb < rAbsorbMin) || (rAbsorb >= rAbsorbMax)) { + continue; + } + registry.fill(HIST("hMuonSel"), RAbsorbCut); + registry.fill(HIST("hMuAfterRAbsorbCuts"), cent, nCh, pt, eta, theta, rAbsorb, dcaXY, pDca, chi2, muTrackType); + + if ((rAbsorb < rAbsorbMid) && (pDca >= pDcaMin)) { + continue; + } + if ((rAbsorb >= rAbsorbMid) && (pDca >= pDcaMax)) { + continue; + } + registry.fill(HIST("hMuonSel"), PDcaCut); + registry.fill(HIST("hMuAfterPdcaCuts"), cent, nCh, pt, eta, theta, rAbsorb, dcaXY, pDca, chi2, muTrackType); + + // MCH-MFT matching chi2 + if (muon.chi2() >= 1e6) { + continue; + } + registry.fill(HIST("hMuonSel"), Chi2Cut); + + // histograms after acceptance cuts + registry.fill(HIST("hMuAfterAccCuts"), cent, nCh, pt, eta, theta, rAbsorb, dcaXY, pDca, chi2, muTrackType); + registry.fill(HIST("h3DCAAfterAccCuts"), muon.fwdDcaX(), muon.fwdDcaY(), muTrackType); + nMu++; + nMuType[muTrackType]++; + + if (muon.has_matchMCHTrack()) { + auto muonType3 = muon.template matchMCHTrack_as(); + auto dpt = muonType3.pt() - pt; + + if (muTrackType == ForwardTrackTypeEnum::GlobalMuonTrack) { + registry.fill(HIST("hMuDeltaPtAfterAccCuts"), cent, nCh, pt, eta, theta, rAbsorb, dcaXY, pDca, chi2, dpt); + } + } + } + + registry.fill(HIST("h3MultNchNmu"), cent, nCh, nMu); + + // Fill number of muons of various types with multiplicity + for (auto indexType{0u}; indexType < NTrackTypes; ++indexType) { + if (nMuType[indexType] > 0) { + registry.fill(HIST("hMultNchNmuTrackType"), cent, nCh, nMuType[indexType], indexType); + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/HFL/Tasks/taskSingleMuonReader.cxx b/PWGHF/HFL/Tasks/taskSingleMuonReader.cxx index 7d04bead362..52cb12b6f41 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuonReader.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuonReader.cxx @@ -12,17 +12,20 @@ /// \file taskSingleMuonReader.cxx /// \brief Task used to read the derived table produced by the tableMaker of DQ framework and extract observables on single muons needed for the HF-muon analysis. /// \author Maolin Zhang , CCNU -#include -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/TrackFwd.h" + #include "PWGDQ/DataModel/ReducedInfoTables.h" + #include "Common/Core/RecoDecay.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; diff --git a/PWGHF/HFL/Tasks/taskSingleMuonReaderAssoc.cxx b/PWGHF/HFL/Tasks/taskSingleMuonReaderAssoc.cxx index 03fa6efb5a5..2b43e9ab14f 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuonReaderAssoc.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuonReaderAssoc.cxx @@ -13,18 +13,18 @@ /// \brief Task used to read the derived table produced by the tableMaker-association of DQ framework and extract observables on single muons needed for the HF-muon analysis. /// \author Maolin Zhang , CCNU -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/TrackFwd.h" +#include "PWGDQ/DataModel/ReducedInfoTables.h" #include "Common/Core/RecoDecay.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; diff --git a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx index d60a04f80d0..58f6654ee68 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx @@ -13,20 +13,30 @@ // \brief Task used to seperate single muons source in Monte Carlo simulation. // \author Maolin Zhang , CCNU +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/TrackFwd.h" +#include -#include "Common/Core/RecoDecay.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include using namespace o2; using namespace o2::aod; diff --git a/PWGHF/Macros/computeFonllPlusPythiaPredictions.C b/PWGHF/Macros/computeFonllPlusPythiaPredictions.C index bdd8f1ca7e2..c112f7f5d24 100644 --- a/PWGHF/Macros/computeFonllPlusPythiaPredictions.C +++ b/PWGHF/Macros/computeFonllPlusPythiaPredictions.C @@ -16,27 +16,27 @@ #if !defined(__CINT__) || defined(__CLING__) -#include -#include -#include -#include -#include +#include +#include -#include -#include -#include #include -#include -#include +#include #include +#include +#include +#include +#include +#include -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" - -#include "CommonConstants/MathConstants.h" -#include "Framework/Logger.h" +#include -#include "Pythia8/Pythia.h" +#include +#include +#include +#include +#include +#include +#include #endif diff --git a/PWGHF/TableProducer/CMakeLists.txt b/PWGHF/TableProducer/CMakeLists.txt index a9d71f86da1..e57147f6cfc 100644 --- a/PWGHF/TableProducer/CMakeLists.txt +++ b/PWGHF/TableProducer/CMakeLists.txt @@ -13,7 +13,7 @@ o2physics_add_dpl_workflow(track-index-skim-creator SOURCES trackIndexSkimCreator.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing O2::DCAFitter O2Physics::AnalysisCCDB O2Physics::MLCore O2Physics::EventFilteringUtils + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing O2::DCAFitter O2Physics::AnalysisCCDB O2Physics::MLCore O2Physics::EventFilteringUtils O2Physics::SGCutParHolder COMPONENT_NAME Analysis) # Helpers @@ -37,12 +37,12 @@ o2physics_add_dpl_workflow(mc-pid-tof o2physics_add_dpl_workflow(candidate-creator-2prong SOURCES candidateCreator2Prong.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2Physics::EventFilteringUtils + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2Physics::EventFilteringUtils O2Physics::SGCutParHolder COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(candidate-creator-3prong SOURCES candidateCreator3Prong.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter O2Physics::EventFilteringUtils + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2Physics::EventFilteringUtils O2Physics::SGCutParHolder COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(candidate-creator-b0 @@ -92,7 +92,7 @@ o2physics_add_dpl_workflow(candidate-creator-xic0-omegac0 o2physics_add_dpl_workflow(candidate-creator-xic-to-xi-pi-pi SOURCES candidateCreatorXicToXiPiPi.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(candidate-creator-xicc @@ -100,11 +100,16 @@ o2physics_add_dpl_workflow(candidate-creator-xicc PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(candidate-creator-mc-gen + SOURCES candidateCreatorMcGen.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + # Candidate selectors o2physics_add_dpl_workflow(candidate-selector-b0-to-d-pi SOURCES candidateSelectorB0ToDPi.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(candidate-selector-bplus-to-d0-pi @@ -164,12 +169,17 @@ o2physics_add_dpl_workflow(candidate-selector-omegac0-to-omega-ka o2physics_add_dpl_workflow(candidate-selector-omegac0-to-omega-pi SOURCES candidateSelectorOmegac0ToOmegaPi.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(candidate-selector-omegac0-xic0-to-omega-ka + SOURCES candidateSelectorOmegac0Xic0ToOmegaKa.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(candidate-selector-xic0-to-xi-pi-kf SOURCES candidateSelectorXic0ToXiPiKf.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(candidate-selector-to-xi-pi @@ -245,12 +255,12 @@ o2physics_add_dpl_workflow(tree-creator-omegac-st COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(tree-creator-omegac0-to-omega-ka - SOURCES treeCreatorOmegacToOmegaKa.cxx + SOURCES treeCreatorOmegac0ToOmegaKa.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(tree-creator-omegac0-to-omega-pi - SOURCES treeCreatorOmegacToOmegaPi.cxx + SOURCES treeCreatorOmegac0ToOmegaPi.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -284,8 +294,17 @@ o2physics_add_dpl_workflow(tree-creator-dstar-to-d0-pi PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(tree-creator-tcc-to-d0-d0-pi + SOURCES treeCreatorTccToD0D0Pi.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) # Derived-data creators +o2physics_add_dpl_workflow(derived-data-creator-b0-to-d-pi + SOURCES derivedDataCreatorB0ToDPi.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(derived-data-creator-bplus-to-d0-pi SOURCES derivedDataCreatorBplusToD0Pi.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -296,14 +315,34 @@ o2physics_add_dpl_workflow(derived-data-creator-d0-to-k-pi PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(derived-data-creator-dplus-to-pi-k-pi + SOURCES derivedDataCreatorDplusToPiKPi.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(derived-data-creator-ds-to-k-k-pi + SOURCES derivedDataCreatorDsToKKPi.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(derived-data-creator-dstar-to-d0-pi + SOURCES derivedDataCreatorDstarToD0Pi.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(derived-data-creator-lc-to-p-k-pi SOURCES derivedDataCreatorLcToPKPi.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(derived-data-creator-xic-to-xi-pi-pi + SOURCES derivedDataCreatorXicToXiPiPi.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + # Converters o2physics_add_dpl_workflow(converter-dstar-indices - SOURCES converterDstarIndices.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) + SOURCES converterDstarIndices.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index d12acd58271..a4c7c4ced21 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -17,44 +17,69 @@ /// \author Pengzhong Lu , GSI Darmstadt, USTC #ifndef HomogeneousField -#define HomogeneousField +#define HomogeneousField // o2-linter: disable=name/macro (required by KFParticle) +#include "PWGHF/Core/DecayChannels.h" #endif -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "ReconstructionDataFormats/DCA.h" - -#include "Common/Core/trackUtilities.h" -#include "Tools/KFparticle/KFUtilities.h" - #include "PWGHF/Core/CentralityEstimation.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsMcGen.h" +#include "PWGHF/Utils/utilsMcMatching.h" #include "PWGHF/Utils/utilsPid.h" #include "PWGHF/Utils/utilsTrkCandHf.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Tools/KFparticle/KFUtilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; using namespace o2::hf_evsel; using namespace o2::hf_trkcandsel; using namespace o2::aod::hf_cand_2prong; +using namespace o2::hf_decay; +using namespace o2::hf_decay::hf_cand_2prong; using namespace o2::hf_centrality; using namespace o2::hf_occupancy; using namespace o2::constants::physics; @@ -96,27 +121,36 @@ struct HfCandidateCreator2Prong { float toMicrometers = 10000.; // from cm to µm double massPi{0.}; double massK{0.}; + double massE{0.}; + double massMu{0.}; double massPiK{0.}; double massKPi{0.}; + double massEE{0.}; + double massMuMu{0.}; double bz{0.}; std::shared_ptr hCandidates; + + ConfigurableAxis axisMass{"axisMass", {500, 1.6, 2.1}, "axis for mass (GeV/c^2)"}; + HistogramRegistry registry{"registry"}; void init(InitContext const&) { - std::array doprocessDF{doprocessPvRefitWithDCAFitterN, doprocessNoPvRefitWithDCAFitterN, + std::array doprocessDF{doprocessPvRefitWithDCAFitterN, doprocessNoPvRefitWithDCAFitterN, doprocessPvRefitWithDCAFitterNCentFT0C, doprocessNoPvRefitWithDCAFitterNCentFT0C, - doprocessPvRefitWithDCAFitterNCentFT0M, doprocessNoPvRefitWithDCAFitterNCentFT0M}; - std::array doprocessKF{doprocessPvRefitWithKFParticle, doprocessNoPvRefitWithKFParticle, + doprocessPvRefitWithDCAFitterNCentFT0M, doprocessNoPvRefitWithDCAFitterNCentFT0M, doprocessPvRefitWithDCAFitterNUpc, doprocessNoPvRefitWithDCAFitterNUpc}; + std::array doprocessKF{doprocessPvRefitWithKFParticle, doprocessNoPvRefitWithKFParticle, doprocessPvRefitWithKFParticleCentFT0C, doprocessNoPvRefitWithKFParticleCentFT0C, - doprocessPvRefitWithKFParticleCentFT0M, doprocessNoPvRefitWithKFParticleCentFT0M}; + doprocessPvRefitWithKFParticleCentFT0M, doprocessNoPvRefitWithKFParticleCentFT0M, doprocessPvRefitWithKFParticleUpc, doprocessNoPvRefitWithKFParticleUpc}; if ((std::accumulate(doprocessDF.begin(), doprocessDF.end(), 0) + std::accumulate(doprocessKF.begin(), doprocessKF.end(), 0)) != 1) { LOGP(fatal, "One and only one process function must be enabled at a time."); } - std::array processesCollisions = {doprocessCollisions, doprocessCollisionsCentFT0C, doprocessCollisionsCentFT0M}; + std::array processesCollisions = {doprocessCollisions, doprocessCollisionsCentFT0C, doprocessCollisionsCentFT0M, doprocessCollisionsUpc}; const int nProcessesCollisions = std::accumulate(processesCollisions.begin(), processesCollisions.end(), 0); + std::array processesUpc = {doprocessPvRefitWithDCAFitterNUpc, doprocessNoPvRefitWithDCAFitterNUpc, doprocessPvRefitWithKFParticleUpc, doprocessNoPvRefitWithKFParticleUpc, doprocessCollisionsUpc}; + const int nProcessesUpc = std::accumulate(processesUpc.begin(), processesUpc.end(), 0); if (nProcessesCollisions > 1) { LOGP(fatal, "At most one process function for collision monitoring can be enabled at a time."); } @@ -130,10 +164,18 @@ struct HfCandidateCreator2Prong { if ((doprocessPvRefitWithDCAFitterNCentFT0M || doprocessNoPvRefitWithDCAFitterNCentFT0M || doprocessPvRefitWithKFParticleCentFT0M || doprocessNoPvRefitWithKFParticleCentFT0M) && !doprocessCollisionsCentFT0M) { LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0M\"?"); } + if ((doprocessPvRefitWithDCAFitterNUpc || doprocessNoPvRefitWithDCAFitterNUpc || doprocessPvRefitWithKFParticleUpc || doprocessNoPvRefitWithKFParticleUpc) && !doprocessCollisionsUpc) { + LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsUpc\"?"); + } + } + if (nProcessesUpc > 0 && isRun2) { + LOGP(fatal, "Process function for UPC is only available in Run 3!"); } // histograms - registry.add("hMass2", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 1.6, 2.1}}}); + registry.add("hMass2", "2-prong candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axisMass}}); + registry.add("hMassEE", "2-prong candidates;inv. mass (e e) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axisMass}}); + registry.add("hMassMuMu", "2-prong candidates;inv. mass (#mu #mu) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axisMass}}); registry.add("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}); registry.add("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 0.2}}}); registry.add("hCovPVYY", "2-prong candidates;YY element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}); @@ -146,10 +188,14 @@ struct HfCandidateCreator2Prong { registry.add("hDcaZProngs", "DCAz of 2-prong candidate daughters;#it{p}_{T} (GeV/#it{c};#it{d}_{z}) (#mum);entries", {HistType::kTH2F, {{100, 0., 20.}, {200, -500., 500.}}}); registry.add("hVertexerType", "Use KF or DCAFitterN;Vertexer type;entries", {HistType::kTH1D, {{2, -0.5, 1.5}}}); // See o2::aod::hf_cand::VertexerType hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); - hfEvSel.addHistograms(registry); // collision monitoring + + // init HF event selection helper + hfEvSel.init(registry); massPi = MassPiPlus; massK = MassKPlus; + massE = MassElectron; + massMu = MassMuon; if (std::accumulate(doprocessDF.begin(), doprocessDF.end(), 0) == 1) { registry.fill(HIST("hVertexerType"), aod::hf_cand::VertexerType::DCAFitter); @@ -176,11 +222,11 @@ struct HfCandidateCreator2Prong { setLabelHistoCands(hCandidates); } - template + template void runCreator2ProngWithDCAFitterN(Coll const&, CandType const& rowsTrackIndexProng2, TTracks const&, - aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) + BCsType const& bcs) { // loop over pairs of track indices for (const auto& rowTrackIndexProng2 : rowsTrackIndexProng2) { @@ -188,7 +234,12 @@ struct HfCandidateCreator2Prong { /// reject candidates not satisfying the event selections auto collision = rowTrackIndexProng2.template collision_as(); float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + uint32_t rejectionMask{0}; + if constexpr (applyUpcSel) { + rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); + } else { + rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + } if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate continue; @@ -202,7 +253,7 @@ struct HfCandidateCreator2Prong { /// Set the magnetic field from ccdb. /// The static instance of the propagator was already modified in the HFTrackIndexSkimCreator, /// but this is not true when running on Run2 data/MC already converted into AO2Ds. - auto bc = collision.template bc_as(); + auto bc = collision.template bc_as(); if (runNumber != bc.runNumber()) { LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; initCCDB(bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, nullptr, isRun2); @@ -318,17 +369,21 @@ struct HfCandidateCreator2Prong { auto arrayMomenta = std::array{pvec0, pvec1}; massPiK = RecoDecay::m(arrayMomenta, std::array{massPi, massK}); massKPi = RecoDecay::m(arrayMomenta, std::array{massK, massPi}); + massEE = RecoDecay::m(arrayMomenta, std::array{massE, massE}); + massMuMu = RecoDecay::m(arrayMomenta, std::array{massMu, massMu}); registry.fill(HIST("hMass2"), massPiK); registry.fill(HIST("hMass2"), massKPi); + registry.fill(HIST("hMassEE"), massEE); + registry.fill(HIST("hMassMuMu"), massMuMu); } } } - template + template void runCreator2ProngWithKFParticle(Coll const&, CandType const& rowsTrackIndexProng2, TTracks const&, - aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) + BCsType const& bcs) { for (const auto& rowTrackIndexProng2 : rowsTrackIndexProng2) { @@ -336,7 +391,12 @@ struct HfCandidateCreator2Prong { /// reject candidates in collisions not satisfying the event selections auto collision = rowTrackIndexProng2.template collision_as(); float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + uint32_t rejectionMask{0}; + if constexpr (applyUpcSel) { + rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); + } else { + rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + } if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate continue; @@ -348,7 +408,7 @@ struct HfCandidateCreator2Prong { /// Set the magnetic field from ccdb. /// The static instance of the propagator was already modified in the HFTrackIndexSkimCreator, /// but this is not true when running on Run2 data/MC already converted into AO2Ds. - auto bc = collision.template bc_as(); + auto bc = collision.template bc_as(); if (runNumber != bc.runNumber()) { LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; initCCDB(bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, nullptr, isRun2); @@ -371,7 +431,7 @@ struct HfCandidateCreator2Prong { kfpVertex.SetCovarianceMatrix(rowTrackIndexProng2.pvRefitSigmaX2(), rowTrackIndexProng2.pvRefitSigmaXY(), rowTrackIndexProng2.pvRefitSigmaY2(), rowTrackIndexProng2.pvRefitSigmaXZ(), rowTrackIndexProng2.pvRefitSigmaYZ(), rowTrackIndexProng2.pvRefitSigmaZ2()); } kfpVertex.GetCovarianceMatrix(covMatrixPV); - KFParticle KFPV(kfpVertex); + KFParticle kfpV(kfpVertex); registry.fill(HIST("hCovPVXX"), covMatrixPV[0]); registry.fill(HIST("hCovPVYY"), covMatrixPV[2]); registry.fill(HIST("hCovPVXZ"), covMatrixPV[3]); @@ -386,16 +446,16 @@ struct HfCandidateCreator2Prong { KFParticle kfNegKaon(kfpTrack1, kKPlus); float impactParameter0XY = 0., errImpactParameter0XY = 0., impactParameter1XY = 0., errImpactParameter1XY = 0.; - if (!kfPosPion.GetDistanceFromVertexXY(KFPV, impactParameter0XY, errImpactParameter0XY)) { + if (!kfPosPion.GetDistanceFromVertexXY(kfpV, impactParameter0XY, errImpactParameter0XY)) { registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0XY * toMicrometers); - registry.fill(HIST("hDcaZProngs"), track0.pt(), std::sqrt(kfPosPion.GetDistanceFromVertex(KFPV) * kfPosPion.GetDistanceFromVertex(KFPV) - impactParameter0XY * impactParameter0XY) * toMicrometers); + registry.fill(HIST("hDcaZProngs"), track0.pt(), std::sqrt(kfPosPion.GetDistanceFromVertex(kfpV) * kfPosPion.GetDistanceFromVertex(kfpV) - impactParameter0XY * impactParameter0XY) * toMicrometers); } else { registry.fill(HIST("hDcaXYProngs"), track0.pt(), -999.f); registry.fill(HIST("hDcaZProngs"), track0.pt(), -999.f); } - if (!kfNegPion.GetDistanceFromVertexXY(KFPV, impactParameter1XY, errImpactParameter1XY)) { + if (!kfNegPion.GetDistanceFromVertexXY(kfpV, impactParameter1XY, errImpactParameter1XY)) { registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1XY * toMicrometers); - registry.fill(HIST("hDcaZProngs"), track1.pt(), std::sqrt(kfNegPion.GetDistanceFromVertex(KFPV) * kfNegPion.GetDistanceFromVertex(KFPV) - impactParameter1XY * impactParameter1XY) * toMicrometers); + registry.fill(HIST("hDcaZProngs"), track1.pt(), std::sqrt(kfNegPion.GetDistanceFromVertex(kfpV) * kfNegPion.GetDistanceFromVertex(kfpV) - impactParameter1XY * impactParameter1XY) * toMicrometers); } else { registry.fill(HIST("hDcaXYProngs"), track1.pt(), -999.f); registry.fill(HIST("hDcaZProngs"), track1.pt(), -999.f); @@ -421,7 +481,7 @@ struct HfCandidateCreator2Prong { auto covMatrixSV = kfCandD0.CovarianceMatrix(); double phi, theta; - getPointDirection(std::array{KFPV.GetX(), KFPV.GetY(), KFPV.GetZ()}, std::array{kfCandD0.GetX(), kfCandD0.GetY(), kfCandD0.GetZ()}, phi, theta); + getPointDirection(std::array{kfpV.GetX(), kfpV.GetY(), kfpV.GetZ()}, std::array{kfCandD0.GetX(), kfCandD0.GetY(), kfCandD0.GetZ()}, phi, theta); auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixSV, phi, theta)); auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixSV, phi, 0.)); @@ -429,7 +489,7 @@ struct HfCandidateCreator2Prong { KFParticle kfCandD0Topol2PV; if (constrainKfToPv) { kfCandD0Topol2PV = kfCandD0; - kfCandD0Topol2PV.SetProductionVertex(KFPV); + kfCandD0Topol2PV.SetProductionVertex(kfpV); topolChi2PerNdfD0 = kfCandD0Topol2PV.GetChi2() / kfCandD0Topol2PV.GetNDF(); } @@ -445,7 +505,7 @@ struct HfCandidateCreator2Prong { // fill candidate table rows rowCandidateBase(indexCollision, - KFPV.GetX(), KFPV.GetY(), KFPV.GetZ(), + kfpV.GetX(), kfpV.GetY(), kfpV.GetZ(), kfCandD0.GetX(), kfCandD0.GetY(), kfCandD0.GetZ(), errorDecayLength, errorDecayLengthXY, // TODO: much different from the DCAFitterN one kfCandD0.GetChi2() / kfCandD0.GetNDF(), // TODO: to make sure it should be chi2 only or chi2/ndf, much different from the DCAFitterN one @@ -488,7 +548,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processPvRefitWithDCAFitterN, "Run candidate creator using DCA fitter w/ PV refit and w/o centrality selections", false); @@ -498,7 +558,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithDCAFitterN, "Run candidate creator using DCA fitter w/o PV refit and w/o centrality selections", true); @@ -508,7 +568,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processPvRefitWithKFParticle, "Run candidate creator using KFParticle package w/ PV refit and w/o centrality selections", false); @@ -518,7 +578,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithKFParticle, "Run candidate creator using KFParticle package w/o PV refit and w/o centrality selections", false); @@ -534,7 +594,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processPvRefitWithDCAFitterNCentFT0C, "Run candidate creator using DCA fitter w/ PV refit and w/ centrality selection on FT0C", false); @@ -544,7 +604,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithDCAFitterNCentFT0C, "Run candidate creator using DCA fitter w/o PV refit and w/ centrality selection FT0C", false); @@ -554,7 +614,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processPvRefitWithKFParticleCentFT0C, "Run candidate creator using KFParticle package w/ PV refit and w/ centrality selection on FT0C", false); @@ -564,7 +624,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithKFParticleCentFT0C, "Run candidate creator using KFParticle package w/o PV refit and w/ centrality selection on FT0C", false); @@ -580,7 +640,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processPvRefitWithDCAFitterNCentFT0M, "Run candidate creator using DCA fitter w/ PV refit and w/ centrality selection on FT0M", false); @@ -590,7 +650,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithDCAFitterNCentFT0M, "Run candidate creator using DCA fitter w/o PV refit and w/ centrality selection FT0M", false); @@ -600,7 +660,7 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processPvRefitWithKFParticleCentFT0M, "Run candidate creator using KFParticle package w/ PV refit and w/ centrality selection on FT0M", false); @@ -610,10 +670,72 @@ struct HfCandidateCreator2Prong { TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); } PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithKFParticleCentFT0M, "Run candidate creator using KFParticle package w/o PV refit and w/ centrality selection on FT0M", false); + ///////////////////////////////////////////// + /// /// + /// with centrality selection on UPC /// + /// /// + ///////////////////////////////////////////// + + /// @brief process function using DCA fitter w/ PV refit and w/ centrality selection on UPC + void processPvRefitWithDCAFitterNUpc(soa::Join const& collisions, + soa::Join const& rowsTrackIndexProng2, + TracksWCovExtraPidPiKa const& tracks, + aod::BcFullInfos const& bcWithTimeStamps, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator2Prong, processPvRefitWithDCAFitterNUpc, "Run candidate creator using DCA fitter w/ PV refit and w/ centrality selection on UltraPeripheral Collision", false); + + /// @brief process function using DCA fitter w/o PV refit and w/ centrality selection UPC + void processNoPvRefitWithDCAFitterNUpc(soa::Join const& collisions, + aod::Hf2Prongs const& rowsTrackIndexProng2, + TracksWCovExtraPidPiKa const& tracks, + aod::BcFullInfos const& bcWithTimeStamps, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithDCAFitterNUpc, "Run candidate creator using DCA fitter w/o PV refit and w/ centrality selection UltraPeripheral Collision", false); + + /// @brief process function using KFParticle package w/ PV refit and w/ centrality selection on UPC + void processPvRefitWithKFParticleUpc(soa::Join const& collisions, + soa::Join const& rowsTrackIndexProng2, + TracksWCovExtraPidPiKa const& tracks, + aod::BcFullInfos const& bcWithTimeStamps, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator2Prong, processPvRefitWithKFParticleUpc, "Run candidate creator using KFParticle package w/ PV refit and w/ centrality selection on UltraPeripheral Collision", false); + + /// @brief process function using KFParticle package w/o PV refit and w/o centrality selections on UPC + void processNoPvRefitWithKFParticleUpc(soa::Join const& collisions, + aod::Hf2Prongs const& rowsTrackIndexProng2, + TracksWCovExtraPidPiKa const& tracks, + aod::BcFullInfos const& bcWithTimeStamps, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator2Prong, processNoPvRefitWithKFParticleUpc, "Run candidate creator using KFParticle package w/o PV refit and w/ centrality selection on UltraPeripheral Collision", false); + /////////////////////////////////////////////////////////// /// /// /// Process functions only for collision monitoring /// @@ -628,7 +750,7 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, OccupancyEstimator::Its); + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -646,7 +768,7 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, OccupancyEstimator::Its); + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -664,7 +786,7 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, OccupancyEstimator::Its); + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -673,6 +795,29 @@ struct HfCandidateCreator2Prong { } /// end loop over collisions } PROCESS_SWITCH(HfCandidateCreator2Prong, processCollisionsCentFT0M, "Collision monitoring - FT0M centrality", false); + + /// @brief process function to monitor collisions - UPC collision + void processCollisionsUpc(soa::Join const& collisions, + aod::BcFullInfos const& bcs, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + /// loop over collisions + for (const auto& collision : collisions) { + + /// bitmask with event. selection info + float centrality{-1.f}; + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); + + /// monitor the satisfied event selections + hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy); + + } /// end loop over collisions + } + PROCESS_SWITCH(HfCandidateCreator2Prong, processCollisionsUpc, "Collision monitoring - UPC", false); }; /// Extends the base table with expression columns. @@ -682,8 +827,10 @@ struct HfCandidateCreator2ProngExpressions { Produces rowMcMatchGen; // Configuration - o2::framework::Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; - o2::framework::Configurable matchKinkedDecayTopology{"matchKinkedDecayTopology", false, "Match also candidates with tracks that decay with kinked topology"}; + Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + Configurable matchKinkedDecayTopology{"matchKinkedDecayTopology", false, "Match also candidates with tracks that decay with kinked topology"}; + Configurable matchInteractionsWithMaterial{"matchInteractionsWithMaterial", false, "Match also candidates with tracks that interact with material"}; + Configurable matchCorrelatedBackground{"matchCorrelatedBackground", false, "Match correlated background candidates"}; HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring @@ -691,12 +838,13 @@ struct HfCandidateCreator2ProngExpressions { using McCollisionsFT0Cs = soa::Join; using McCollisionsFT0Ms = soa::Join; using McCollisionsCentFT0Ms = soa::Join; + using BCsInfo = soa::Join; + + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId; - Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; - using BCsInfo = soa::Join; HistogramRegistry registry{"registry"}; // inspect for which zPvPosMax cut was set for reconstructed @@ -710,11 +858,11 @@ struct HfCandidateCreator2ProngExpressions { const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-2prong") == 0) { - hfEvSelMc.configureFromDevice(device); + // init HF event selection helper + hfEvSelMc.init(device, registry); break; } } - hfEvSelMc.addHistograms(registry); // particles monitoring } /// Performs MC matching. @@ -729,14 +877,18 @@ struct HfCandidateCreator2ProngExpressions { int indexRec = -1; int8_t sign = 0; - int8_t flag = 0; + int8_t flagChannelMain = 0; + int8_t flagChannelResonant = 0; int8_t origin = 0; int8_t nKinkedTracks = 0; + int8_t nInteractionsWithMaterial = 0; + constexpr std::size_t NDaughtersResonant{2u}; // Match reconstructed candidates. // Spawned table can be used directly for (const auto& candidate : *rowCandidateProng2) { - flag = 0; + flagChannelMain = 0; + flagChannelResonant = 0; origin = 0; auto arrayDaughters = std::array{candidate.prong0_as(), candidate.prong1_as()}; @@ -753,48 +905,120 @@ struct HfCandidateCreator2ProngExpressions { } } if (fromBkg) { - rowMcMatchRec(flag, origin, -1.f, 0, 0); + rowMcMatchRec(flagChannelMain, origin, flagChannelResonant, -1.f, 0, 0, 0); continue; } } std::vector idxBhadMothers{}; - // D0(bar) → π± K∓ - if (matchKinkedDecayTopology) { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign, 1, &nKinkedTracks); - } else { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign); - } - if (indexRec > -1) { - flag = sign * (1 << DecayType::D0ToPiK); - } + if (matchCorrelatedBackground) { + indexRec = -1; // Index of the matched reconstructed candidate + constexpr int FinalStateDepth = 2; + constexpr int ResoDepth = 1; + + // D0(bar) → π+ K−, π+ K− π0, π+ π−, π+ π− π0, K+ K− + for (const auto& [channelMain, finalState] : daughtersD0Main) { + std::array arrPdgDaughtersMain2Prongs = std::array{finalState[0], finalState[1]}; + if (finalState.size() == 3) { // o2-linter: disable=magic-number (partially reconstructed 3-prong decays) + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, arrPdgDaughtersMain2Prongs, true, &sign, FinalStateDepth, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, arrPdgDaughtersMain2Prongs, true, &sign, FinalStateDepth, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, arrPdgDaughtersMain2Prongs, true, &sign, FinalStateDepth, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, arrPdgDaughtersMain2Prongs, true, &sign, FinalStateDepth); + } - // J/ψ → e+ e− - if (flag == 0) { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kJPsi, std::array{+kElectron, -kElectron}, true); + if (indexRec > -1) { + auto motherParticle = mcParticles.rawIteratorAt(indexRec); + std::array arrPdgDaughtersMain3Prongs = std::array{finalState[0], finalState[1], finalState[2]}; + flipPdgSign(motherParticle.pdgCode(), +kPi0, arrPdgDaughtersMain3Prongs); + if (!RecoDecay::isMatchedMCGen(mcParticles, motherParticle, Pdg::kD0, arrPdgDaughtersMain3Prongs, true, &sign, FinalStateDepth)) { + indexRec = -1; // Reset indexRec if the generated decay does not match the reconstructed one + } + } + } else if (finalState.size() == 2) { // o2-linter: disable=magic-number (fully reconstructed 2-prong decays) + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, arrPdgDaughtersMain2Prongs, true, &sign, FinalStateDepth, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, arrPdgDaughtersMain2Prongs, true, &sign, FinalStateDepth, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, arrPdgDaughtersMain2Prongs, true, &sign, FinalStateDepth, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, arrPdgDaughtersMain2Prongs, true, &sign, FinalStateDepth); + } + } else { + LOG(fatal) << "Final state size not supported: " << finalState.size(); + return; + } + if (indexRec > -1) { + flagChannelMain = sign * channelMain; + + // Flag the resonant decay channel + std::vector arrResoDaughIndex = {}; + RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRec), &arrResoDaughIndex, std::array{0}, ResoDepth); + std::array arrPdgDaughters = {}; + if (arrResoDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < arrResoDaughIndex.size(); ++iProng) { + auto daughI = mcParticles.rawIteratorAt(arrResoDaughIndex[iProng]); + arrPdgDaughters[iProng] = daughI.pdgCode(); + } + flagChannelResonant = getDecayChannelResonant(Pdg::kD0, arrPdgDaughters); + } + break; + } + } + } else { + // D0(bar) → π± K∓ + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign, 1, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign, 1, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign, 1, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign); + } if (indexRec > -1) { - flag = 1 << DecayType::JpsiToEE; + flagChannelMain = sign * DecayChannelMain::D0ToPiK; } - } - // J/ψ → μ+ μ− - if (flag == 0) { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kJPsi, std::array{+kMuonPlus, -kMuonPlus}, true); - if (indexRec > -1) { - flag = 1 << DecayType::JpsiToMuMu; + // J/ψ → e+ e− + if (flagChannelMain == 0) { + if (matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kJPsi, std::array{+kElectron, +kPositron}, true, &sign, 1, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kJPsi, std::array{+kElectron, +kPositron}, true); + } + if (indexRec > -1) { + flagChannelMain = DecayChannelMain::JpsiToEE; + } + } + + // J/ψ → μ+ μ− + if (flagChannelMain == 0) { + if (matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kJPsi, std::array{+kMuonMinus, +kMuonPlus}, true, &sign, 1, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kJPsi, std::array{+kMuonMinus, +kMuonPlus}, true); + } + if (indexRec > -1) { + flagChannelMain = DecayChannelMain::JpsiToMuMu; + } } } // Check whether the particle is non-prompt (from a b quark). - if (flag != 0) { + if (flagChannelMain != 0) { auto particle = mcParticles.rawIteratorAt(indexRec); origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); } if (origin == RecoDecay::OriginType::NonPrompt) { auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); - rowMcMatchRec(flag, origin, bHadMother.pt(), bHadMother.pdgCode(), nKinkedTracks); + rowMcMatchRec(flagChannelMain, origin, flagChannelResonant, bHadMother.pt(), bHadMother.pdgCode(), nKinkedTracks, nInteractionsWithMaterial); } else { - rowMcMatchRec(flag, origin, -1.f, 0, nKinkedTracks); + rowMcMatchRec(flagChannelMain, origin, flagChannelResonant, -1.f, 0, nKinkedTracks, nInteractionsWithMaterial); } } @@ -804,66 +1028,28 @@ struct HfCandidateCreator2ProngExpressions { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint16_t rejectionMask{0}; + uint32_t rejectionMask{0u}; + int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } else if constexpr (centEstimator == CentralityEstimator::FT0M) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0M, mcCollision.globalIndex()); + nSplitColl = collSlice.size(); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } else if constexpr (centEstimator == CentralityEstimator::None) { const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } - hfEvSelMc.fillHistograms(mcCollision, rejectionMask); + hfEvSelMc.fillHistograms(mcCollision, rejectionMask, nSplitColl); if (rejectionMask != 0) { // at least one event selection not satisfied --> reject all particles from this collision for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) { - rowMcMatchGen(0, 0, -1); + rowMcMatchGen(0, 0, 0, -1); } continue; } - - // Match generated particles. - for (const auto& particle : mcParticlesPerMcColl) { - flag = 0; - origin = 0; - std::vector idxBhadMothers{}; - // Reject particles from background events - if (particle.fromBackgroundEvent() && rejectBackground) { - rowMcMatchGen(flag, origin, -1); - continue; - } - - // D0(bar) → π± K∓ - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign)) { - flag = sign * (1 << DecayType::D0ToPiK); - } - - // J/ψ → e+ e− - if (flag == 0) { - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kJPsi, std::array{+kElectron, -kElectron}, true)) { - flag = 1 << DecayType::JpsiToEE; - } - } - - // J/ψ → μ+ μ− - if (flag == 0) { - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kJPsi, std::array{+kMuonPlus, -kMuonPlus}, true)) { - flag = 1 << DecayType::JpsiToMuMu; - } - } - - // Check whether the particle is non-prompt (from a b quark). - if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - } - if (origin == RecoDecay::OriginType::NonPrompt) { - rowMcMatchGen(flag, origin, idxBhadMothers[0]); - } else { - rowMcMatchGen(flag, origin, -1); - } - } + hf_mc_gen::fillMcMatchGen2Prong(mcParticles, mcParticlesPerMcColl, rowMcMatchGen, rejectBackground, matchCorrelatedBackground); } } @@ -901,6 +1087,6 @@ struct HfCandidateCreator2ProngExpressions { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"hf-candidate-creator-2prong"}), - adaptAnalysisTask(cfgc, TaskName{"hf-candidate-creator-2prong-expressions"})}; + adaptAnalysisTask(cfgc, TaskName{"hf-candidate-creator-2prong"}), // o2-linter: disable=name/o2-task (wrong hyphenation) + adaptAnalysisTask(cfgc, TaskName{"hf-candidate-creator-2prong-expressions"})}; // o2-linter: disable=name/o2-task (wrong hyphenation) } diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index d59cf2989b2..f3bfce8ba51 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -15,43 +15,91 @@ /// /// \author Vít Kučera , CERN -#include -#include -#include -#include - -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "ReconstructionDataFormats/DCA.h" - -#include "Common/Core/trackUtilities.h" +#ifndef HomogeneousField +#define HomogeneousField // o2-linter: disable=name/macro (required by KFParticle) +#endif #include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsMcGen.h" +#include "PWGHF/Utils/utilsMcMatching.h" +#include "PWGHF/Utils/utilsPid.h" #include "PWGHF/Utils/utilsTrkCandHf.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Tools/KFparticle/KFUtilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; -using namespace o2::analysis; using namespace o2::hf_evsel; using namespace o2::hf_trkcandsel; using namespace o2::aod::hf_cand_3prong; +using namespace o2::hf_decay; +using namespace o2::hf_decay::hf_cand_3prong; using namespace o2::hf_centrality; using namespace o2::hf_occupancy; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::aod::pid_tpc_tof_utils; /// Reconstruction of heavy-flavour 3-prong decay candidates struct HfCandidateCreator3Prong { Produces rowCandidateBase; + Produces rowCandidateKF; + Produces rowProng0PidPi; + Produces rowProng0PidKa; + Produces rowProng0PidPr; + Produces rowProng1PidPi; + Produces rowProng1PidKa; + Produces rowProng1PidPr; + Produces rowProng2PidPi; + Produces rowProng2PidKa; + Produces rowProng2PidPr; // vertexing Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; @@ -72,6 +120,9 @@ struct HfCandidateCreator3Prong { Configurable createDs{"createDs", false, "enable Ds+/- candidate creation"}; Configurable createLc{"createLc", false, "enable Lc+/- candidate creation"}; Configurable createXic{"createXic", false, "enable Xic+/- candidate creation"}; + // KF + Configurable applyTopoConstraint{"applyTopoConstraint", false, "apply origin from PV hypothesis for created candidate, works only in KF mode"}; + Configurable applyInvMassConstraint{"applyInvMassConstraint", false, "apply particle type hypothesis to recalculate created candidate's momentum, works only in KF mode"}; HfEventSelection hfEvSel; // event selection and monitoring o2::vertexing::DCAFitterN<3> df; // 3-prong vertex fitter @@ -79,53 +130,84 @@ struct HfCandidateCreator3Prong { int runNumber{0}; float toMicrometers = 10000.; // from cm to µm + double massP{0.}; double massPi{0.}; double massK{0.}; + double massPKPi{0.}; + double massPiKP{0.}; double massPiKPi{0.}; + double massKKPi{0.}; + double massPiKK{0.}; + double massKPi{0.}; + double massPiK{0.}; double bz{0.}; + constexpr static float UndefValueFloat{-999.f}; + using FilteredHf3Prongs = soa::Filtered; using FilteredPvRefitHf3Prongs = soa::Filtered>; + using TracksWCovExtraPidPiKaPr = soa::Join; // filter candidates - Filter filterSelected3Prongs = (createDplus && (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi))) != static_cast(0)) || (createDs && (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi))) != static_cast(0)) || (createLc && (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::LcToPKPi))) != static_cast(0)) || (createXic && (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::XicToPKPi))) != static_cast(0)); + Filter filterSelected3Prongs = (createDplus && (o2::aod::hf_track_index::hfflag & static_cast(BIT(DecayType::DplusToPiKPi))) != static_cast(0)) || (createDs && (o2::aod::hf_track_index::hfflag & static_cast(BIT(DecayType::DsToKKPi))) != static_cast(0)) || (createLc && (o2::aod::hf_track_index::hfflag & static_cast(BIT(DecayType::LcToPKPi))) != static_cast(0)) || (createXic && (o2::aod::hf_track_index::hfflag & static_cast(BIT(DecayType::XicToPKPi))) != static_cast(0)); std::shared_ptr hCandidates; HistogramRegistry registry{"registry"}; void init(InitContext const&) { - std::array processes = {doprocessPvRefit, doprocessNoPvRefit, - doprocessPvRefitCentFT0C, doprocessNoPvRefitCentFT0C, - doprocessPvRefitCentFT0M, doprocessNoPvRefitCentFT0M}; - if (std::accumulate(processes.begin(), processes.end(), 0) != 1) { + std::array doprocessDF{doprocessPvRefitWithDCAFitterN, doprocessNoPvRefitWithDCAFitterN, + doprocessPvRefitWithDCAFitterNCentFT0C, doprocessNoPvRefitWithDCAFitterNCentFT0C, + doprocessPvRefitWithDCAFitterNCentFT0M, doprocessNoPvRefitWithDCAFitterNCentFT0M, doprocessPvRefitWithDCAFitterNUpc, doprocessNoPvRefitWithDCAFitterNUpc}; + std::array doprocessKF{doprocessPvRefitWithKFParticle, doprocessNoPvRefitWithKFParticle, + doprocessPvRefitWithKFParticleCentFT0C, doprocessNoPvRefitWithKFParticleCentFT0C, + doprocessPvRefitWithKFParticleCentFT0M, doprocessNoPvRefitWithKFParticleCentFT0M, doprocessPvRefitWithKFParticleUpc, doprocessNoPvRefitWithKFParticleUpc}; + if ((std::accumulate(doprocessDF.begin(), doprocessDF.end(), 0) + std::accumulate(doprocessKF.begin(), doprocessKF.end(), 0)) != 1) { LOGP(fatal, "One and only one process function must be enabled at a time."); } - - std::array processesCollisions = {doprocessCollisions, doprocessCollisionsCentFT0C, doprocessCollisionsCentFT0M}; + std::array processesCollisions = {doprocessCollisions, doprocessCollisionsCentFT0C, doprocessCollisionsCentFT0M, doprocessCollisionsUpc}; const int nProcessesCollisions = std::accumulate(processesCollisions.begin(), processesCollisions.end(), 0); + + std::array processesUpc = {doprocessPvRefitWithDCAFitterNUpc, doprocessNoPvRefitWithDCAFitterNUpc, doprocessPvRefitWithKFParticleUpc, doprocessNoPvRefitWithKFParticleUpc, doprocessCollisionsUpc}; + const int nProcessesUpc = std::accumulate(processesUpc.begin(), processesUpc.end(), 0); + if (nProcessesCollisions > 1) { LOGP(fatal, "At most one process function for collision monitoring can be enabled at a time."); } if (nProcessesCollisions == 1) { - if ((doprocessPvRefit || doprocessNoPvRefit) && !doprocessCollisions) { + if ((doprocessPvRefitWithDCAFitterN || doprocessNoPvRefitWithDCAFitterN || doprocessPvRefitWithKFParticle || doprocessNoPvRefitWithKFParticle) && !doprocessCollisions) { LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisions\"?"); } - if ((doprocessPvRefitCentFT0C || doprocessNoPvRefitCentFT0C) && !doprocessCollisionsCentFT0C) { + if ((doprocessPvRefitWithDCAFitterNCentFT0C || doprocessNoPvRefitWithDCAFitterNCentFT0C || doprocessPvRefitWithKFParticleCentFT0C || doprocessNoPvRefitWithKFParticleCentFT0C) && !doprocessCollisionsCentFT0C) { LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0C\"?"); } - if ((doprocessPvRefitCentFT0M || doprocessNoPvRefitCentFT0M) && !doprocessCollisionsCentFT0M) { + if ((doprocessPvRefitWithDCAFitterNCentFT0M || doprocessNoPvRefitWithDCAFitterNCentFT0M || doprocessPvRefitWithKFParticleCentFT0M || doprocessNoPvRefitWithKFParticleCentFT0M) && !doprocessCollisionsCentFT0M) { LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsCentFT0M\"?"); } + if ((doprocessPvRefitWithDCAFitterNUpc || doprocessNoPvRefitWithDCAFitterNUpc || doprocessPvRefitWithKFParticleUpc || doprocessNoPvRefitWithKFParticleUpc) && !doprocessCollisionsUpc) { + LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisionsUpc\"?"); + } + } + if (nProcessesUpc > 0 && isRun2) { + LOGP(fatal, "Process function for UPC is only available in Run 3!"); } - std::array creationFlags = {createDplus, createDs, createLc, createXic}; if (std::accumulate(creationFlags.begin(), creationFlags.end(), 0) == 0) { LOGP(fatal, "At least one particle specie should be enabled for the creation."); } + if (createLc && createXic && applyInvMassConstraint) { + LOGP(fatal, "Unable to apply invariant mass constraint due to ambiguity of mass hypothesis: only one of Lc and Xic can be reconstructed."); + } + // histograms - registry.add("hMass3", "3-prong candidates;inv. mass (#pi K #pi) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{500, 1.6, 2.1}}}); + registry.add("hMass3PKPi", "3-prong candidates;inv. mass (pK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{1200, 1.8, 3.0}}}); + registry.add("hMass3PiKP", "3-prong candidates;inv. mass (#pi Kp) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{1200, 1.8, 3.0}}}); + registry.add("hMass3PiKPi", "3-prong candidates;inv. mass (#pi K#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{600, 1.6, 2.2}}}); + registry.add("hMass3KKPi", "3-prong candidates;inv. mass (KK #pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{600, 1.7, 2.3}}}); + registry.add("hMass3PiKK", "3-prong candidates;inv. mass (#pi KK) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{600, 1.7, 2.3}}}); + registry.add("hMass2KPi", "2-prong pairs;inv. mass (K#pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{1200, 0.8, 2.0}}}); + registry.add("hMass2PiK", "2-prong pairs;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{1200, 0.8, 2.0}}}); registry.add("hCovPVXX", "3-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}); registry.add("hCovSVXX", "3-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 0.2}}}); registry.add("hCovPVYY", "3-prong candidates;YY element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}); @@ -137,8 +219,11 @@ struct HfCandidateCreator3Prong { registry.add("hDcaXYProngs", "DCAxy of 3-prong candidate daughters;#it{p}_{T} (GeV/#it{c};#it{d}_{xy}) (#mum);entries", {HistType::kTH2F, {{100, 0., 20.}, {200, -500., 500.}}}); registry.add("hDcaZProngs", "DCAz of 3-prong candidate daughters;#it{p}_{T} (GeV/#it{c};#it{d}_{z}) (#mum);entries", {HistType::kTH2F, {{100, 0., 20.}, {200, -500., 500.}}}); hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); - hfEvSel.addHistograms(registry); // collision monitoring + // init HF event selection helper + hfEvSel.init(registry); + + massP = MassProton; massPi = MassPiPlus; massK = MassKPlus; @@ -161,11 +246,29 @@ struct HfCandidateCreator3Prong { setLabelHistoCands(hCandidates); } - template - void runCreator3Prong(Coll const&, - Cand const& rowsTrackIndexProng3, - aod::TracksWCovExtra const&, - aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) + template + void fillProngsPid(TRK const& track0, TRK const& track1, TRK const& track2) + { + fillProngPid(track0, rowProng0PidPi); + fillProngPid(track0, rowProng0PidKa); + fillProngPid(track1, rowProng1PidPi); + fillProngPid(track1, rowProng1PidKa); + fillProngPid(track2, rowProng2PidPi); + fillProngPid(track2, rowProng2PidKa); + + /// fill proton PID information only if necessary + if (createLc || createXic) { + fillProngPid(track0, rowProng0PidPr); + fillProngPid(track1, rowProng1PidPr); + fillProngPid(track2, rowProng2PidPr); + } + } + + template + void runCreator3ProngWithDCAFitterN(Coll const&, + Cand const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const&, + BCsType const& bcs) { // loop over triplets of track indices for (const auto& rowTrackIndexProng3 : rowsTrackIndexProng3) { @@ -173,15 +276,20 @@ struct HfCandidateCreator3Prong { /// reject candidates in collisions not satisfying the event selections auto collision = rowTrackIndexProng3.template collision_as(); float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + uint32_t rejectionMask{0}; + if constexpr (applyUpcSel) { + rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); + } else { + rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + } if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate continue; } - auto track0 = rowTrackIndexProng3.template prong0_as(); - auto track1 = rowTrackIndexProng3.template prong1_as(); - auto track2 = rowTrackIndexProng3.template prong2_as(); + auto track0 = rowTrackIndexProng3.template prong0_as(); + auto track1 = rowTrackIndexProng3.template prong1_as(); + auto track2 = rowTrackIndexProng3.template prong2_as(); auto trackParVar0 = getTrackParCov(track0); auto trackParVar1 = getTrackParCov(track1); auto trackParVar2 = getTrackParCov(track2); @@ -189,7 +297,7 @@ struct HfCandidateCreator3Prong { /// Set the magnetic field from ccdb. /// The static instance of the propagator was already modified in the HFTrackIndexSkimCreator, /// but this is not true when running on Run2 data/MC already converted into AO2Ds. - auto bc = collision.template bc_as(); + auto bc = collision.template bc_as(); if (runNumber != bc.runNumber()) { LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; initCCDB(bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, nullptr, isRun2); @@ -304,12 +412,270 @@ struct HfCandidateCreator3Prong { rowTrackIndexProng3.prong0Id(), rowTrackIndexProng3.prong1Id(), rowTrackIndexProng3.prong2Id(), nProngsContributorsPV, bitmapProngsContributorsPV, rowTrackIndexProng3.hfflag()); + // fill candidate prong PID rows + fillProngsPid(track0, track1, track2); + // fill histograms if (fillHistograms) { // calculate invariant mass auto arrayMomenta = std::array{pvec0, pvec1, pvec2}; - massPiKPi = RecoDecay::m(std::move(arrayMomenta), std::array{massPi, massK, massPi}); - registry.fill(HIST("hMass3"), massPiKPi); + massPKPi = RecoDecay::m(arrayMomenta, std::array{massP, massK, massPi}); + massPiKP = RecoDecay::m(arrayMomenta, std::array{massPi, massK, massP}); + massPiKPi = RecoDecay::m(arrayMomenta, std::array{massPi, massK, massPi}); + massKKPi = RecoDecay::m(arrayMomenta, std::array{massK, massK, massPi}); + massPiKK = RecoDecay::m(arrayMomenta, std::array{massPi, massK, massK}); + massKPi = RecoDecay::m(std::array{arrayMomenta.at(1), arrayMomenta.at(2)}, std::array{massK, massPi}); + massPiK = RecoDecay::m(std::array{arrayMomenta.at(0), arrayMomenta.at(1)}, std::array{massPi, massK}); + registry.fill(HIST("hMass3PiKPi"), massPiKPi); + registry.fill(HIST("hMass3PKPi"), massPKPi); + registry.fill(HIST("hMass3PiKP"), massPiKP); + registry.fill(HIST("hMass3KKPi"), massKKPi); + registry.fill(HIST("hMass3PiKK"), massPiKK); + registry.fill(HIST("hMass2KPi"), massKPi); + registry.fill(HIST("hMass2PiK"), massPiK); + } + } + } + + template + void runCreator3ProngWithKFParticle(Coll const&, + Cand const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const&, + BCsType const& bcs) + { + for (const auto& rowTrackIndexProng3 : rowsTrackIndexProng3) { + /// reject candidates in collisions not satisfying the event selections + auto collision = rowTrackIndexProng3.template collision_as(); + float centrality{-1.f}; + uint32_t rejectionMask{0}; + if constexpr (applyUpcSel) { + rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); + } else { + rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + } + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the candidate + continue; + } + + auto track0 = rowTrackIndexProng3.template prong0_as(); + auto track1 = rowTrackIndexProng3.template prong1_as(); + auto track2 = rowTrackIndexProng3.template prong2_as(); + + /// Set the magnetic field from ccdb. + /// The static instance of the propagator was already modified in the HFTrackIndexSkimCreator, + /// but this is not true when running on Run2 data/MC already converted into AO2Ds. + auto bc = collision.template bc_as(); + if (runNumber != bc.runNumber()) { + LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; + initCCDB(bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, nullptr, isRun2); + bz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << ">>>>>>>>>>>> Magnetic field: " << bz; + // df.setBz(bz); /// put it outside the 'if'! Otherwise we have a difference wrt bz Configurable (< 1 permille) in Run2 conv. data + // df.print(); + } + float covMatrixPV[6]; + + KFParticle::SetField(bz); + KFPVertex kfpVertex = createKFPVertexFromCollision(collision); + + if constexpr (doPvRefit) { + /// use PV refit + /// Using it in the rowCandidateBase all dynamic columns shall take it into account + // coordinates + kfpVertex.SetXYZ(rowTrackIndexProng3.pvRefitX(), rowTrackIndexProng3.pvRefitY(), rowTrackIndexProng3.pvRefitZ()); + // covariance matrix + kfpVertex.SetCovarianceMatrix(rowTrackIndexProng3.pvRefitSigmaX2(), rowTrackIndexProng3.pvRefitSigmaXY(), rowTrackIndexProng3.pvRefitSigmaY2(), rowTrackIndexProng3.pvRefitSigmaXZ(), rowTrackIndexProng3.pvRefitSigmaYZ(), rowTrackIndexProng3.pvRefitSigmaZ2()); + } + kfpVertex.GetCovarianceMatrix(covMatrixPV); + KFParticle kfpV(kfpVertex); + registry.fill(HIST("hCovPVXX"), covMatrixPV[0]); + registry.fill(HIST("hCovPVYY"), covMatrixPV[2]); + registry.fill(HIST("hCovPVXZ"), covMatrixPV[3]); + registry.fill(HIST("hCovPVZZ"), covMatrixPV[5]); + + KFPTrack kfpTrack0 = createKFPTrackFromTrack(track0); + KFPTrack kfpTrack1 = createKFPTrackFromTrack(track1); + KFPTrack kfpTrack2 = createKFPTrackFromTrack(track2); + + KFParticle kfFirstProton(kfpTrack0, kProton); + KFParticle kfFirstPion(kfpTrack0, kPiPlus); + KFParticle kfFirstKaon(kfpTrack0, kKPlus); + KFParticle kfSecondKaon(kfpTrack1, kKPlus); + KFParticle kfThirdProton(kfpTrack2, kProton); + KFParticle kfThirdPion(kfpTrack2, kPiPlus); + KFParticle kfThirdKaon(kfpTrack2, kKPlus); + + float impactParameter0XY = 0., errImpactParameter0XY = 0., impactParameter1XY = 0., errImpactParameter1XY = 0., impactParameter2XY = 0., errImpactParameter2XY = 0.; + if (!kfFirstProton.GetDistanceFromVertexXY(kfpV, impactParameter0XY, errImpactParameter0XY)) { + registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0XY * toMicrometers); + registry.fill(HIST("hDcaZProngs"), track0.pt(), std::sqrt(kfFirstProton.GetDistanceFromVertex(kfpV) * kfFirstProton.GetDistanceFromVertex(kfpV) - impactParameter0XY * impactParameter0XY) * toMicrometers); + } else { + registry.fill(HIST("hDcaXYProngs"), track0.pt(), UndefValueFloat); + registry.fill(HIST("hDcaZProngs"), track0.pt(), UndefValueFloat); + } + if (!kfSecondKaon.GetDistanceFromVertexXY(kfpV, impactParameter1XY, errImpactParameter1XY)) { + registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1XY * toMicrometers); + registry.fill(HIST("hDcaZProngs"), track1.pt(), std::sqrt(kfSecondKaon.GetDistanceFromVertex(kfpV) * kfSecondKaon.GetDistanceFromVertex(kfpV) - impactParameter1XY * impactParameter1XY) * toMicrometers); + } else { + registry.fill(HIST("hDcaXYProngs"), track1.pt(), UndefValueFloat); + registry.fill(HIST("hDcaZProngs"), track1.pt(), UndefValueFloat); + } + if (!kfThirdProton.GetDistanceFromVertexXY(kfpV, impactParameter2XY, errImpactParameter2XY)) { + registry.fill(HIST("hDcaXYProngs"), track2.pt(), impactParameter2XY * toMicrometers); + registry.fill(HIST("hDcaZProngs"), track2.pt(), std::sqrt(kfThirdProton.GetDistanceFromVertex(kfpV) * kfThirdProton.GetDistanceFromVertex(kfpV) - impactParameter2XY * impactParameter2XY) * toMicrometers); + } else { + registry.fill(HIST("hDcaXYProngs"), track2.pt(), UndefValueFloat); + registry.fill(HIST("hDcaZProngs"), track2.pt(), UndefValueFloat); + } + + auto [impactParameter0Z, errImpactParameter0Z] = kfCalculateImpactParameterZ(kfFirstProton, kfpV); + auto [impactParameter1Z, errImpactParameter1Z] = kfCalculateImpactParameterZ(kfSecondKaon, kfpV); + auto [impactParameter2Z, errImpactParameter2Z] = kfCalculateImpactParameterZ(kfThirdProton, kfpV); + + const float chi2primFirst = kfCalculateChi2ToPrimaryVertex(kfFirstProton, kfpV); + const float chi2primSecond = kfCalculateChi2ToPrimaryVertex(kfSecondKaon, kfpV); + const float chi2primThird = kfCalculateChi2ToPrimaryVertex(kfThirdPion, kfpV); + + const float dcaSecondThird = kfCalculateDistanceBetweenParticles(kfSecondKaon, kfThirdPion); + const float dcaFirstThird = kfCalculateDistanceBetweenParticles(kfFirstProton, kfThirdPion); + const float dcaFirstSecond = kfCalculateDistanceBetweenParticles(kfFirstProton, kfSecondKaon); + + const float chi2geoSecondThird = kfCalculateChi2geoBetweenParticles(kfSecondKaon, kfThirdPion); + const float chi2geoFirstThird = kfCalculateChi2geoBetweenParticles(kfFirstProton, kfThirdPion); + const float chi2geoFirstSecond = kfCalculateChi2geoBetweenParticles(kfFirstProton, kfSecondKaon); + + // Λc± → p± K∓ π±, Ξc± → p± K∓ π± + KFParticle kfCandPKPi; + const KFParticle* kfDaughtersPKPi[3] = {&kfFirstProton, &kfSecondKaon, &kfThirdPion}; + kfCandPKPi.SetConstructMethod(2); + kfCandPKPi.Construct(kfDaughtersPKPi, 3); + KFParticle kfCandPiKP; + const KFParticle* kfDaughtersPiKP[3] = {&kfFirstPion, &kfSecondKaon, &kfThirdProton}; + kfCandPiKP.SetConstructMethod(2); + kfCandPiKP.Construct(kfDaughtersPiKP, 3); + + // D± → π± K∓ π± + KFParticle kfCandPiKPi; + const KFParticle* kfDaughtersPiKPi[3] = {&kfFirstPion, &kfSecondKaon, &kfThirdPion}; + kfCandPiKPi.SetConstructMethod(2); + kfCandPiKPi.Construct(kfDaughtersPiKPi, 3); + + // Ds± → K± K∓ π± + KFParticle kfCandKKPi; + const KFParticle* kfDaughtersKKPi[3] = {&kfFirstKaon, &kfSecondKaon, &kfThirdPion}; + kfCandKKPi.SetConstructMethod(2); + kfCandKKPi.Construct(kfDaughtersKKPi, 3); + KFParticle kfCandPiKK; + const KFParticle* kfDaughtersPiKK[3] = {&kfFirstPion, &kfSecondKaon, &kfThirdKaon}; + kfCandPiKK.SetConstructMethod(2); + kfCandPiKK.Construct(kfDaughtersPiKK, 3); + + const float chi2topo = kfCalculateChi2ToPrimaryVertex(kfCandPKPi, kfpV); + + if (applyTopoConstraint) { // constraints applied after chi2topo getter - to preserve unbiased value of chi2topo + for (const auto& kfCand : std::array{&kfCandPKPi, &kfCandPiKP, &kfCandPiKPi, &kfCandKKPi, &kfCandPiKK}) { + kfCand->SetProductionVertex(kfpV); + kfCand->TransportToDecayVertex(); + } + } + + KFParticle kfPairKPi; + const KFParticle* kfDaughtersKPi[3] = {&kfSecondKaon, &kfThirdPion}; + kfPairKPi.SetConstructMethod(2); + kfPairKPi.Construct(kfDaughtersKPi, 2); + + KFParticle kfPairPiK; + const KFParticle* kfDaughtersPiK[3] = {&kfFirstPion, &kfSecondKaon}; + kfPairPiK.SetConstructMethod(2); + kfPairPiK.Construct(kfDaughtersPiK, 2); + + const float massPKPi = kfCandPKPi.GetMass(); + const float massPiKP = kfCandPiKP.GetMass(); + const float massPiKPi = kfCandPiKPi.GetMass(); + const float massKKPi = kfCandKKPi.GetMass(); + const float massPiKK = kfCandPiKK.GetMass(); + const float massKPi = kfPairKPi.GetMass(); + const float massPiK = kfPairPiK.GetMass(); + + if (applyInvMassConstraint) { // constraints applied after minv getters - to preserve unbiased values of minv + kfCandPKPi.SetNonlinearMassConstraint(createLc ? MassLambdaCPlus : MassXiCPlus); + kfCandPiKP.SetNonlinearMassConstraint(createLc ? MassLambdaCPlus : MassXiCPlus); + kfCandPiKPi.SetNonlinearMassConstraint(MassDPlus); + kfCandKKPi.SetNonlinearMassConstraint(MassDS); + kfCandPiKK.SetNonlinearMassConstraint(MassDS); + } + + const float chi2geo = kfCandPKPi.Chi2() / kfCandPKPi.NDF(); + const std::pair ldl = kfCalculateLdL(kfCandPKPi, kfpV); + + std::array pProng0 = kfCalculateProngMomentumInSecondaryVertex(kfFirstProton, kfCandPiKP); + std::array pProng1 = kfCalculateProngMomentumInSecondaryVertex(kfSecondKaon, kfCandPiKP); + std::array pProng2 = kfCalculateProngMomentumInSecondaryVertex(kfThirdPion, kfCandPiKP); + + registry.fill(HIST("hCovSVXX"), kfCandPKPi.Covariance(0, 0)); + registry.fill(HIST("hCovSVYY"), kfCandPKPi.Covariance(1, 1)); + registry.fill(HIST("hCovSVXZ"), kfCandPKPi.Covariance(2, 0)); + registry.fill(HIST("hCovSVZZ"), kfCandPKPi.Covariance(2, 2)); + + auto covMatrixSV = kfCandPKPi.CovarianceMatrix(); + double phi, theta; + getPointDirection(std::array{kfpV.GetX(), kfpV.GetY(), kfpV.GetZ()}, std::array{kfCandPKPi.GetX(), kfCandPKPi.GetY(), kfCandPKPi.GetZ()}, phi, theta); + auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixSV, phi, theta)); + auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixSV, phi, 0.)); + + auto indexCollision = collision.globalIndex(); + uint8_t bitmapProngsContributorsPV = 0; + if (indexCollision == track0.collisionId() && track0.isPVContributor()) { + SETBIT(bitmapProngsContributorsPV, 0); + } + if (indexCollision == track1.collisionId() && track1.isPVContributor()) { + SETBIT(bitmapProngsContributorsPV, 1); + } + if (indexCollision == track2.collisionId() && track2.isPVContributor()) { + SETBIT(bitmapProngsContributorsPV, 2); + } + uint8_t nProngsContributorsPV = hf_trkcandsel::countOnesInBinary(bitmapProngsContributorsPV); + + // fill candidate table rows + rowCandidateBase(indexCollision, + kfpV.GetX(), kfpV.GetY(), kfpV.GetZ(), + kfCandPKPi.GetX(), kfCandPKPi.GetY(), kfCandPKPi.GetZ(), + errorDecayLength, errorDecayLengthXY, + kfCandPKPi.GetChi2() / kfCandPKPi.GetNDF(), + pProng0.at(0), pProng0.at(1), pProng0.at(2), + pProng1.at(0), pProng1.at(1), pProng1.at(2), + pProng2.at(0), pProng2.at(1), pProng2.at(2), + impactParameter0XY, impactParameter1XY, impactParameter2XY, + errImpactParameter0XY, errImpactParameter1XY, errImpactParameter2XY, + impactParameter0Z, impactParameter1Z, impactParameter2Z, + errImpactParameter0Z, errImpactParameter1Z, errImpactParameter2Z, + rowTrackIndexProng3.prong0Id(), rowTrackIndexProng3.prong1Id(), rowTrackIndexProng3.prong2Id(), nProngsContributorsPV, bitmapProngsContributorsPV, + rowTrackIndexProng3.hfflag()); + + // fill KF info + rowCandidateKF(kfCandPKPi.GetErrX(), kfCandPKPi.GetErrY(), kfCandPKPi.GetErrZ(), + std::sqrt(kfpV.Covariance(0, 0)), std::sqrt(kfpV.Covariance(1, 1)), std::sqrt(kfpV.Covariance(2, 2)), + massPKPi, massPiKP, massPiKPi, massKKPi, massPiKK, massKPi, massPiK, + kfCandPKPi.GetPx(), kfCandPKPi.GetPy(), kfCandPKPi.GetPz(), + kfCandPKPi.GetErrPx(), kfCandPKPi.GetErrPy(), kfCandPKPi.GetErrPz(), + chi2primFirst, chi2primSecond, chi2primThird, + dcaSecondThird, dcaFirstThird, dcaFirstSecond, + chi2geoSecondThird, chi2geoFirstThird, chi2geoFirstSecond, + chi2geo, ldl.first, ldl.second, chi2topo); + + // fill candidate prong PID rows + fillProngsPid(track0, track1, track2); + + // fill histograms + if (fillHistograms) { + registry.fill(HIST("hMass3PiKPi"), massPiKPi); + registry.fill(HIST("hMass3PKPi"), massPKPi); + registry.fill(HIST("hMass3PiKP"), massPiKP); + registry.fill(HIST("hMass3KKPi"), massKKPi); + registry.fill(HIST("hMass3PiKK"), massPiKK); + registry.fill(HIST("hMass2KPi"), massKPi); + registry.fill(HIST("hMass2PiK"), massPiK); } } } @@ -320,25 +686,45 @@ struct HfCandidateCreator3Prong { /// /// /////////////////////////////////// - /// @brief process function w/ PV refit and w/o centrality selections - void processPvRefit(soa::Join const& collisions, - FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, - aod::TracksWCovExtra const& tracks, - aod::BCsWithTimestamps const& bcWithTimeStamps) + /// @brief process function using DCA fitter w/ PV refit and w/o centrality selections + void processPvRefitWithDCAFitterN(soa::Join const& collisions, + FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) + { + runCreator3ProngWithDCAFitterN(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitWithDCAFitterN, "Run candidate creator using DCA fitter with PV refit and w/o centrality selections", false); + + /// @brief process function using DCA fitter w/o PV refit and w/o centrality selections + void processNoPvRefitWithDCAFitterN(soa::Join const& collisions, + FilteredHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator3Prong(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + runCreator3ProngWithDCAFitterN(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); } - PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefit, "Run candidate creator with PV refit and w/o centrality selections", false); + PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitWithDCAFitterN, "Run candidate creator using DCA fitter without PV refit and w/o centrality selections", true); - /// @brief process function w/o PV refit and w/o centrality selections - void processNoPvRefit(soa::Join const& collisions, - FilteredHf3Prongs const& rowsTrackIndexProng3, - aod::TracksWCovExtra const& tracks, - aod::BCsWithTimestamps const& bcWithTimeStamps) + /// @brief process function using KFParticle package w/ PV refit and w/o centrality selections + void processPvRefitWithKFParticle(soa::Join const& collisions, + FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator3Prong(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + runCreator3ProngWithKFParticle(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); } - PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefit, "Run candidate creator without PV refit and w/o centrality selections", true); + PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitWithKFParticle, "Run candidate creator using KFParticle package with PV refit and w/o centrality selections", false); + + /// @brief process function using KFParticle package w/o PV refit and w/o centrality selections + void processNoPvRefitWithKFParticle(soa::Join const& collisions, + FilteredHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) + { + runCreator3ProngWithKFParticle(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitWithKFParticle, "Run candidate creator using KFParticle package without PV refit and w/o centrality selections", false); ///////////////////////////////////////////// /// /// @@ -346,25 +732,45 @@ struct HfCandidateCreator3Prong { /// /// ///////////////////////////////////////////// - /// @brief process function w/ PV refit and w/ centrality selection on FT0C - void processPvRefitCentFT0C(soa::Join const& collisions, - FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, - aod::TracksWCovExtra const& tracks, - aod::BCsWithTimestamps const& bcWithTimeStamps) + /// @brief process function using DCA fitter w/ PV refit and w/ centrality selection on FT0C + void processPvRefitWithDCAFitterNCentFT0C(soa::Join const& collisions, + FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) + { + runCreator3ProngWithDCAFitterN(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitWithDCAFitterNCentFT0C, "Run candidate creator using DCA fitter with PV refit and w/ centrality selection on FT0C", false); + + /// @brief process function using DCA fitter w/o PV refit and w/ centrality selection on FT0C + void processNoPvRefitWithDCAFitterNCentFT0C(soa::Join const& collisions, + FilteredHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) + { + runCreator3ProngWithDCAFitterN(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitWithDCAFitterNCentFT0C, "Run candidate creator using DCA fitter without PV refit and w/ centrality selection on FT0C", false); + + /// @brief process function using KFParticle package w/ PV refit and w/ centrality selection on FT0C + void processPvRefitWithKFParticleCentFT0C(soa::Join const& collisions, + FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator3Prong(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + runCreator3ProngWithKFParticle(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); } - PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitCentFT0C, "Run candidate creator with PV refit and w/ centrality selection on FT0C", false); + PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitWithKFParticleCentFT0C, "Run candidate creator using KFParticle package with PV refit and w/ centrality selection on FT0C", false); - /// @brief process function w/o PV refit and w/ centrality selection on FT0C - void processNoPvRefitCentFT0C(soa::Join const& collisions, - FilteredHf3Prongs const& rowsTrackIndexProng3, - aod::TracksWCovExtra const& tracks, - aod::BCsWithTimestamps const& bcWithTimeStamps) + /// @brief process function using KFParticle package w/o PV refit and w/ centrality selection on FT0C + void processNoPvRefitWithKFParticleCentFT0C(soa::Join const& collisions, + FilteredHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator3Prong(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + runCreator3ProngWithKFParticle(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); } - PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitCentFT0C, "Run candidate creator without PV refit and w/ centrality selection on FT0C", false); + PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitWithKFParticleCentFT0C, "Run candidate creator using KFParticle package without PV refit and w/ centrality selection on FT0C", false); ///////////////////////////////////////////// /// /// @@ -372,25 +778,107 @@ struct HfCandidateCreator3Prong { /// /// ///////////////////////////////////////////// - /// @brief process function w/ PV refit and w/ centrality selection on FT0M - void processPvRefitCentFT0M(soa::Join const& collisions, - FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, - aod::TracksWCovExtra const& tracks, - aod::BCsWithTimestamps const& bcWithTimeStamps) + /// @brief process function using DCA fitter w/ PV refit and w/ centrality selection on FT0M + void processPvRefitWithDCAFitterNCentFT0M(soa::Join const& collisions, + FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator3Prong(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + runCreator3ProngWithDCAFitterN(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); } - PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitCentFT0M, "Run candidate creator with PV refit and w/ centrality selection on FT0M", false); + PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitWithDCAFitterNCentFT0M, "Run candidate creator using DCA fitter with PV refit and w/ centrality selection on FT0M", false); - /// @brief process function w/o PV refit and w/ centrality selection on FT0M - void processNoPvRefitCentFT0M(soa::Join const& collisions, - FilteredHf3Prongs const& rowsTrackIndexProng3, - aod::TracksWCovExtra const& tracks, - aod::BCsWithTimestamps const& bcWithTimeStamps) + /// @brief process function using DCA fitter w/o PV refit and w/ centrality selection on FT0M + void processNoPvRefitWithDCAFitterNCentFT0M(soa::Join const& collisions, + FilteredHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) { - runCreator3Prong(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + runCreator3ProngWithDCAFitterN(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); } - PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitCentFT0M, "Run candidate creator without PV refit and w/ centrality selection on FT0M", false); + PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitWithDCAFitterNCentFT0M, "Run candidate creator using DCA fitter without PV refit and w/ centrality selection on FT0M", false); + + /// @brief process function using KFParticle package w/ PV refit and w/ centrality selection on FT0M + void processPvRefitWithKFParticleCentFT0M(soa::Join const& collisions, + FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) + { + runCreator3ProngWithKFParticle(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitWithKFParticleCentFT0M, "Run candidate creator using KFParticle package with PV refit and w/ centrality selection on FT0M", false); + + /// @brief process function using KFParticle package w/o PV refit and w/ centrality selection on FT0M + void processNoPvRefitWithKFParticleCentFT0M(soa::Join const& collisions, + FilteredHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BCsWithTimestamps const& bcWithTimeStamps) + { + runCreator3ProngWithKFParticle(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitWithKFParticleCentFT0M, "Run candidate creator using KFParticle package without PV refit and w/ centrality selection on FT0M", false); + + ///////////////////////////////////////////// + /// /// + /// with centrality selection on UPC /// + /// /// + ///////////////////////////////////////////// + + /// @brief process function using DCA fitter w/ PV refit and w/ centrality selection on UPC + void processPvRefitWithDCAFitterNUpc(soa::Join const& collisions, + FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BcFullInfos const& bcWithTimeStamps, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + runCreator3ProngWithDCAFitterN(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitWithDCAFitterNUpc, "Run candidate creator using DCA fitter with PV refit and w/ centrality selection on UPC", false); + + /// @brief process function using DCA fitter w/o PV refit and w/ centrality selection on UPC + void processNoPvRefitWithDCAFitterNUpc(soa::Join const& collisions, + FilteredHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BcFullInfos const& bcWithTimeStamps, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + runCreator3ProngWithDCAFitterN(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitWithDCAFitterNUpc, "Run candidate creator using DCA fitter without PV refit and w/ centrality selection on UPC", false); + + /// @brief process function using KFParticle package w/ PV refit and w/ centrality selection on UPC + void processPvRefitWithKFParticleUpc(soa::Join const& collisions, + FilteredPvRefitHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BcFullInfos const& bcWithTimeStamps, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + runCreator3ProngWithKFParticle(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processPvRefitWithKFParticleUpc, "Run candidate creator using KFParticle package with PV refit and w/ centrality selection on UPC", false); + + /// @brief process function using KFParticle package w/o PV refit and w/ centrality selection on UPC + void processNoPvRefitWithKFParticleUpc(soa::Join const& collisions, + FilteredHf3Prongs const& rowsTrackIndexProng3, + TracksWCovExtraPidPiKaPr const& tracks, + aod::BcFullInfos const& bcWithTimeStamps, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + runCreator3ProngWithKFParticle(collisions, rowsTrackIndexProng3, tracks, bcWithTimeStamps); + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processNoPvRefitWithKFParticleUpc, "Run candidate creator using KFParticle package without PV refit and w/ centrality selection on UPC", false); /////////////////////////////////////////////////////////// /// /// @@ -406,7 +894,7 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, OccupancyEstimator::Its); + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -424,7 +912,7 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, OccupancyEstimator::Its); + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -442,7 +930,7 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, OccupancyEstimator::Its); + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -451,6 +939,29 @@ struct HfCandidateCreator3Prong { } /// end loop over collisions } PROCESS_SWITCH(HfCandidateCreator3Prong, processCollisionsCentFT0M, "Collision monitoring - FT0M centrality", false); + + /// @brief process function to monitor collisions - UPC + void processCollisionsUpc(soa::Join const& collisions, + aod::BcFullInfos const& bcs, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + /// loop over collisions + for (const auto& collision : collisions) { + + /// bitmask with event. selection info + float centrality{-1.f}; + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); + + /// monitor the satisfied event selections + hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy); + + } /// end loop over collisions + } + PROCESS_SWITCH(HfCandidateCreator3Prong, processCollisionsUpc, "Collision monitoring - UPC", false); }; /// Extends the base table with expression columns. @@ -460,26 +971,28 @@ struct HfCandidateCreator3ProngExpressions { Produces rowMcMatchGen; // Configuration - o2::framework::Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; - o2::framework::Configurable matchKinkedDecayTopology{"matchKinkedDecayTopology", false, "Match also candidates with tracks that decay with kinked topology"}; + Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + Configurable matchKinkedDecayTopology{"matchKinkedDecayTopology", false, "Match also candidates with tracks that decay with kinked topology"}; + Configurable matchInteractionsWithMaterial{"matchInteractionsWithMaterial", false, "Match also candidates with tracks that interact with material"}; + Configurable matchCorrelatedBackground{"matchCorrelatedBackground", false, "Match correlated background candidates"}; + Configurable> pdgMothersCorrelBkg{"pdgMothersCorrelBkg", {Pdg::kDPlus, Pdg::kDS, Pdg::kDStar, Pdg::kLambdaCPlus, Pdg::kXiCPlus}, "PDG codes of the mother particles of correlated background candidates"}; - bool createDplus{false}; - bool createDs{false}; - bool createLc{false}; - bool createXic{false}; + constexpr static std::size_t NDaughtersResonant{2u}; HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring - using BCsInfo = soa::Join; - HistogramRegistry registry{"registry"}; + using BCsInfo = soa::Join; using McCollisionsNoCents = soa::Join; using McCollisionsFT0Cs = soa::Join; using McCollisionsFT0Ms = soa::Join; using McCollisionsCentFT0Ms = soa::Join; + + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId; - Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + + HistogramRegistry registry{"registry"}; void init(InitContext& initContext) { @@ -492,29 +1005,11 @@ struct HfCandidateCreator3ProngExpressions { const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-3prong") == 0) { - hfEvSelMc.configureFromDevice(device); - for (const auto& option : device.options) { - if (option.name.compare("createDplus") == 0) { - createDplus = option.defaultValue.get(); - } else if (option.name.compare("createDs") == 0) { - createDs = option.defaultValue.get(); - } else if (option.name.compare("createLc") == 0) { - createLc = option.defaultValue.get(); - } else if (option.name.compare("createXic") == 0) { - createXic = option.defaultValue.get(); - } - } + // init HF event selection helper + hfEvSelMc.init(device, registry); break; } } - - hfEvSelMc.addHistograms(registry); // particles monitoring - - LOGP(info, "Flags for candidate creation from the reco workflow:"); - LOGP(info, " --> createDplus = {}", createDplus); - LOGP(info, " --> createDs = {}", createDs); - LOGP(info, " --> createLc = {}", createLc); - LOGP(info, " --> createXic = {}", createXic); } /// Performs MC matching. @@ -529,26 +1024,28 @@ struct HfCandidateCreator3ProngExpressions { int indexRec = -1; int8_t sign = 0; - int8_t flag = 0; + int8_t flagChannelMain = 0; + int8_t flagChannelResonant = 0; int8_t origin = 0; int8_t swapping = 0; - int8_t channel = 0; int8_t nKinkedTracks = 0; + int8_t nInteractionsWithMaterial = 0; std::vector arrDaughIndex; - std::array arrPDGDaugh; - std::array arrPDGResonant1 = {kProton, 313}; // Λc± → p± K* - std::array arrPDGResonant2 = {2224, kKPlus}; // Λc± → Δ(1232)±± K∓ - std::array arrPDGResonant3 = {102134, kPiPlus}; // Λc± → Λ(1520) π± - std::array arrPDGResonantDPhiPi = {333, kPiPlus}; // Ds± → Phi π± and D± → Phi π± - std::array arrPDGResonantDKstarK = {313, kKPlus}; // Ds± → K*(892)0bar K± and D± → K*(892)0bar K± + std::array arrPdgDaugResonant; + const std::array arrPdgDaugResonantLcToPKstar0{daughtersLcResonant.at(DecayChannelResonant::LcToPKstar0)}; // Λc± → p± K* + const std::array arrPdgDaugResonantLcToDeltaplusplusK{daughtersLcResonant.at(DecayChannelResonant::LcToDeltaplusplusK)}; // Λc± → Δ(1232)±± K∓ + const std::array arrPdgDaugResonantLcToL1520Pi{daughtersLcResonant.at(DecayChannelResonant::LcToL1520Pi)}; // Λc± → Λ(1520) π± + const std::array arrPdgDaugResonantDToPhiPi{daughtersDsResonant.at(DecayChannelResonant::DsToPhiPi)}; // Ds± → φ π± and D± → φ π± + const std::array arrPdgDaugResonantDToKstar0K{daughtersDsResonant.at(DecayChannelResonant::DsToKstar0K)}; // Ds± → anti-K*(892)0 K± and D± → anti-K*(892)0 K± // Match reconstructed candidates. // Spawned table can be used directly for (const auto& candidate : *rowCandidateProng3) { - flag = 0; + flagChannelMain = 0; + flagChannelResonant = 0; origin = 0; swapping = 0; - channel = 0; + indexRec = -1; arrDaughIndex.clear(); std::vector idxBhadMothers{}; auto arrayDaughters = std::array{candidate.prong0_as(), candidate.prong1_as(), candidate.prong2_as()}; @@ -566,114 +1063,250 @@ struct HfCandidateCreator3ProngExpressions { } } if (fromBkg) { - rowMcMatchRec(flag, origin, swapping, channel, -1.f, 0, 0); + rowMcMatchRec(flagChannelMain, origin, swapping, flagChannelResonant, -1.f, 0, 0, 0); continue; } } - // D± → π± K∓ π± - if (createDplus) { - if (matchKinkedDecayTopology) { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2, &nKinkedTracks); - } else { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2); - } - if (indexRec > -1) { - flag = sign * (1 << DecayType::DplusToPiKPi); - } - } + if (matchCorrelatedBackground) { + indexRec = -1; // Index of the matched reconstructed candidate + constexpr int DepthMainMax = 2; // Depth for final state matching + constexpr int DepthResoMax = 1; // Depth for resonant decay matching + + for (const auto& pdgMother : pdgMothersCorrelBkg.value) { + int depthMainMax = DepthMainMax; + if (pdgMother == Pdg::kDStar) { + depthMainMax = DepthMainMax + 1; // D0 resonant decays are active + } + auto finalStates = getDecayChannelsMain(pdgMother); + for (const auto& [channelMain, finalState] : finalStates) { + std::array arrPdgDaughtersMain3Prongs = std::array{finalState[0], finalState[1], finalState[2]}; + if (finalState.size() > 3) { // o2-linter: disable=magic-number (partially reconstructed decays with 4 or 5 final state particles) + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgMother, arrPdgDaughtersMain3Prongs, true, &sign, depthMainMax, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgMother, arrPdgDaughtersMain3Prongs, true, &sign, depthMainMax, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgMother, arrPdgDaughtersMain3Prongs, true, &sign, depthMainMax, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgMother, arrPdgDaughtersMain3Prongs, true, &sign, depthMainMax); + } + + if (indexRec > -1) { + auto motherParticle = mcParticles.rawIteratorAt(indexRec); + if (finalState.size() == 4) { // o2-linter: disable=magic-number (Check if the final state has 4 particles) + std::array arrPdgDaughtersMain4Prongs = std::array{finalState[0], finalState[1], finalState[2], finalState[3]}; + flipPdgSign(motherParticle.pdgCode(), +kPi0, arrPdgDaughtersMain4Prongs); + if (!RecoDecay::isMatchedMCGen(mcParticles, motherParticle, pdgMother, arrPdgDaughtersMain4Prongs, true, &sign, depthMainMax)) { + indexRec = -1; // Reset indexRec if the generated decay does not match the reconstructed one is not matched + } + } else if (finalState.size() == 5) { // o2-linter: disable=magic-number (Check if the final state has 5 particles) + std::array arrPdgDaughtersMain5Prongs = std::array{finalState[0], finalState[1], finalState[2], finalState[3], finalState[4]}; + flipPdgSign(motherParticle.pdgCode(), +kPi0, arrPdgDaughtersMain5Prongs); + if (!RecoDecay::isMatchedMCGen(mcParticles, motherParticle, pdgMother, arrPdgDaughtersMain5Prongs, true, &sign, depthMainMax)) { + indexRec = -1; // Reset indexRec if the generated decay does not match the reconstructed one is not matched + } + } + } + } else if (finalState.size() == 3) { // o2-linter: disable=magic-number(fully reconstructed 3-prong decays) + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgMother, arrPdgDaughtersMain3Prongs, true, &sign, depthMainMax, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgMother, arrPdgDaughtersMain3Prongs, true, &sign, depthMainMax, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgMother, arrPdgDaughtersMain3Prongs, true, &sign, depthMainMax, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgMother, arrPdgDaughtersMain3Prongs, true, &sign, depthMainMax); + } + } else { + LOG(fatal) << "Final state size not supported: " << finalState.size(); + return; + } + if (indexRec > -1) { + flagChannelMain = sign * channelMain; + + /// swapping for D+, Ds->Kpipi and Lc->pKpi + if (std::abs(flagChannelMain) == DecayChannelMain::DplusToPiKK || std::abs(flagChannelMain) == DecayChannelMain::DsToPiKK || std::abs(flagChannelMain) == DecayChannelMain::LcToPKPi) { + if (arrayDaughters[0].has_mcParticle()) { + swapping = static_cast(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus); + } + } - // Ds± → K± K∓ π± and D± → K± K∓ π± - if (flag == 0 && createDs) { - bool isDplus = false; - if (matchKinkedDecayTopology) { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDS, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2, &nKinkedTracks); - } else { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDS, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2); + // Flag the resonant decay channel + std::vector arrResoDaughIndex = {}; + if (pdgMother == Pdg::kDStar) { + std::vector arrResoDaughIndexDstar = {}; + RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRec), &arrResoDaughIndexDstar, std::array{0}, DepthResoMax); + for (size_t iDaug = 0; iDaug < arrResoDaughIndexDstar.size(); iDaug++) { + auto daughDstar = mcParticles.rawIteratorAt(arrResoDaughIndexDstar[iDaug]); + if (std::abs(daughDstar.pdgCode()) == Pdg::kD0 || std::abs(daughDstar.pdgCode()) == Pdg::kDPlus) { + RecoDecay::getDaughters(daughDstar, &arrResoDaughIndex, std::array{0}, DepthResoMax); + break; + } + } + } else { + RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRec), &arrResoDaughIndex, std::array{0}, DepthResoMax); + } + std::array arrPdgDaughters = {}; + if (arrResoDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < NDaughtersResonant; ++iProng) { + auto daughI = mcParticles.rawIteratorAt(arrResoDaughIndex[iProng]); + arrPdgDaughters[iProng] = daughI.pdgCode(); + } + flagChannelResonant = getDecayChannelResonant(pdgMother, arrPdgDaughters); + } + break; // Exit loop if a match is found + } + } + if (indexRec > -1) { + break; // Exit loop if a match is found + } } - if (indexRec == -1) { - isDplus = true; - if (matchKinkedDecayTopology) { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2, &nKinkedTracks); + } else { + // D± → π± K∓ π± + if (flagChannelMain == 0) { + auto arrPdgDaughtersDplusToPiKPi{std::array{+kPiPlus, -kKPlus, +kPiPlus}}; + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDplusToPiKPi, true, &sign, 2, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDplusToPiKPi, true, &sign, 2, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDplusToPiKPi, true, &sign, 2, nullptr, &nInteractionsWithMaterial); } else { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDplusToPiKPi, true, &sign, 2); + } + if (indexRec > -1) { + flagChannelMain = sign * DecayChannelMain::DplusToPiKPi; } } - if (indexRec > -1) { - // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π± - // TODO: move to different and explicit flags - flag = sign * (1 << DecayType::DsToKKPi); - if (arrayDaughters[0].has_mcParticle()) { - swapping = int8_t(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus); + + // Ds± → K± K∓ π± and D± → K± K∓ π± + if (flagChannelMain == 0) { + auto arrPdgDaughtersDToPiKK{std::array{+kKPlus, -kKPlus, +kPiPlus}}; + bool isDplus = false; + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDS, arrPdgDaughtersDToPiKK, true, &sign, 2, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDS, arrPdgDaughtersDToPiKK, true, &sign, 2, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDS, arrPdgDaughtersDToPiKK, true, &sign, 2, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDS, arrPdgDaughtersDToPiKK, true, &sign, 2); } - RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRec), &arrDaughIndex, std::array{0}, 1); - if (arrDaughIndex.size() == 2) { - for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) { - auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]); - arrPDGDaugh[iProng] = std::abs(daughI.pdgCode()); + if (indexRec == -1) { + isDplus = true; + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDToPiKK, true, &sign, 2, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDToPiKK, true, &sign, 2, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDToPiKK, true, &sign, 2, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDToPiKK, true, &sign, 2); + } + } + if (indexRec > -1) { + flagChannelMain = sign * (isDplus ? DecayChannelMain::DplusToPiKK : DecayChannelMain::DsToPiKK); + if (arrayDaughters[0].has_mcParticle()) { + swapping = static_cast(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus); } - if ((arrPDGDaugh[0] == arrPDGResonantDPhiPi[0] && arrPDGDaugh[1] == arrPDGResonantDPhiPi[1]) || (arrPDGDaugh[0] == arrPDGResonantDPhiPi[1] && arrPDGDaugh[1] == arrPDGResonantDPhiPi[0])) { - channel = isDplus ? DecayChannelDToKKPi::DplusToPhiPi : DecayChannelDToKKPi::DsToPhiPi; - } else if ((arrPDGDaugh[0] == arrPDGResonantDKstarK[0] && arrPDGDaugh[1] == arrPDGResonantDKstarK[1]) || (arrPDGDaugh[0] == arrPDGResonantDKstarK[1] && arrPDGDaugh[1] == arrPDGResonantDKstarK[0])) { - channel = isDplus ? DecayChannelDToKKPi::DplusToK0starK : DecayChannelDToKKPi::DsToK0starK; + RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRec), &arrDaughIndex, std::array{0}, 1); + if (arrDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) { + auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]); + arrPdgDaugResonant[iProng] = std::abs(daughI.pdgCode()); + } + if ((arrPdgDaugResonant[0] == arrPdgDaugResonantDToPhiPi[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantDToPhiPi[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantDToPhiPi[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantDToPhiPi[0])) { + flagChannelResonant = isDplus ? DecayChannelResonant::DplusToPhiPi : DecayChannelResonant::DsToPhiPi; + } else if ((arrPdgDaugResonant[0] == arrPdgDaugResonantDToKstar0K[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantDToKstar0K[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantDToKstar0K[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantDToKstar0K[0])) { + flagChannelResonant = isDplus ? DecayChannelResonant::DplusToKstar0K : DecayChannelResonant::DsToKstar0K; + } } } } - } - // Λc± → p± K∓ π± - if (flag == 0 && createLc) { - if (matchKinkedDecayTopology) { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2, &nKinkedTracks); - } else { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2); + // D* → D0 π → K π π + if (flagChannelMain == 0) { + auto arrPdgDaughtersDstarToPiKPi{std::array{+kPiPlus, +kPiPlus, -kKPlus}}; + if (matchKinkedDecayTopology) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDStar, arrPdgDaughtersDstarToPiKPi, true, &sign, 2, &nKinkedTracks); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDStar, arrPdgDaughtersDstarToPiKPi, true, &sign, 2); + } + if (indexRec > -1) { + flagChannelMain = sign * DecayChannelMain::DstarToPiKPi; + flagChannelResonant = 0; + } } - if (indexRec > -1) { - flag = sign * (1 << DecayType::LcToPKPi); - // Flagging the different Λc± → p± K∓ π± decay channels - if (arrayDaughters[0].has_mcParticle()) { - swapping = int8_t(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus); + // Λc± → p± K∓ π± + if (flagChannelMain == 0) { + auto arrPdgDaughtersLcToPKPi{std::array{+kProton, -kKPlus, +kPiPlus}}; + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kLambdaCPlus, arrPdgDaughtersLcToPKPi, true, &sign, 2, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kLambdaCPlus, arrPdgDaughtersLcToPKPi, true, &sign, 2, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kLambdaCPlus, arrPdgDaughtersLcToPKPi, true, &sign, 2, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kLambdaCPlus, arrPdgDaughtersLcToPKPi, true, &sign, 2); } - RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRec), &arrDaughIndex, std::array{0}, 1); - if (arrDaughIndex.size() == 2) { - for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) { - auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]); - arrPDGDaugh[iProng] = std::abs(daughI.pdgCode()); + if (indexRec > -1) { + flagChannelMain = sign * DecayChannelMain::LcToPKPi; + + // Flagging the different Λc± → p± K∓ π± decay channels + if (arrayDaughters[0].has_mcParticle()) { + swapping = static_cast(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus); } - if ((arrPDGDaugh[0] == arrPDGResonant1[0] && arrPDGDaugh[1] == arrPDGResonant1[1]) || (arrPDGDaugh[0] == arrPDGResonant1[1] && arrPDGDaugh[1] == arrPDGResonant1[0])) { - channel = 1; - } else if ((arrPDGDaugh[0] == arrPDGResonant2[0] && arrPDGDaugh[1] == arrPDGResonant2[1]) || (arrPDGDaugh[0] == arrPDGResonant2[1] && arrPDGDaugh[1] == arrPDGResonant2[0])) { - channel = 2; - } else if ((arrPDGDaugh[0] == arrPDGResonant3[0] && arrPDGDaugh[1] == arrPDGResonant3[1]) || (arrPDGDaugh[0] == arrPDGResonant3[1] && arrPDGDaugh[1] == arrPDGResonant3[0])) { - channel = 3; + RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRec), &arrDaughIndex, std::array{0}, 1); + if (arrDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) { + auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]); + arrPdgDaugResonant[iProng] = std::abs(daughI.pdgCode()); + } + if ((arrPdgDaugResonant[0] == arrPdgDaugResonantLcToPKstar0[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToPKstar0[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantLcToPKstar0[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToPKstar0[0])) { + flagChannelResonant = DecayChannelResonant::LcToPKstar0; + } else if ((arrPdgDaugResonant[0] == arrPdgDaugResonantLcToDeltaplusplusK[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToDeltaplusplusK[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantLcToDeltaplusplusK[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToDeltaplusplusK[0])) { + flagChannelResonant = DecayChannelResonant::LcToDeltaplusplusK; + } else if ((arrPdgDaugResonant[0] == arrPdgDaugResonantLcToL1520Pi[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToL1520Pi[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantLcToL1520Pi[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToL1520Pi[0])) { + flagChannelResonant = DecayChannelResonant::LcToL1520Pi; + } } } } - } - // Ξc± → p± K∓ π± - if (flag == 0 && createXic) { - if (matchKinkedDecayTopology) { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2, &nKinkedTracks); - } else { - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2); - } - if (indexRec > -1) { - flag = sign * (1 << DecayType::XicToPKPi); + // Ξc± → p± K∓ π± + if (flagChannelMain == 0) { + auto arrPdgDaughtersXicToPKPi{std::array{+kProton, -kKPlus, +kPiPlus}}; + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, arrPdgDaughtersXicToPKPi, true, &sign, 2, &nKinkedTracks, &nInteractionsWithMaterial); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, arrPdgDaughtersXicToPKPi, true, &sign, 2, &nKinkedTracks); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, arrPdgDaughtersXicToPKPi, true, &sign, 2, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, arrPdgDaughtersXicToPKPi, true, &sign, 2); + } + if (indexRec > -1) { + flagChannelMain = sign * DecayChannelMain::XicToPKPi; + flagChannelResonant = 0; // TODO + if (arrayDaughters[0].has_mcParticle()) { + swapping = static_cast(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus); + } + } } } // Check whether the particle is non-prompt (from a b quark). - if (flag != 0) { + if (flagChannelMain != 0) { auto particle = mcParticles.rawIteratorAt(indexRec); origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); } if (origin == RecoDecay::OriginType::NonPrompt) { auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); - rowMcMatchRec(flag, origin, swapping, channel, bHadMother.pt(), bHadMother.pdgCode(), nKinkedTracks); + rowMcMatchRec(flagChannelMain, origin, swapping, flagChannelResonant, bHadMother.pt(), bHadMother.pdgCode(), nKinkedTracks, nInteractionsWithMaterial); } else { - rowMcMatchRec(flag, origin, swapping, channel, -1.f, 0, nKinkedTracks); + rowMcMatchRec(flagChannelMain, origin, swapping, flagChannelResonant, -1.f, 0, nKinkedTracks, nInteractionsWithMaterial); } } @@ -683,18 +1316,20 @@ struct HfCandidateCreator3ProngExpressions { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint16_t rejectionMask{0}; + uint32_t rejectionMask{0u}; + int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } else if constexpr (centEstimator == CentralityEstimator::FT0M) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0M, mcCollision.globalIndex()); + nSplitColl = collSlice.size(); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } else if constexpr (centEstimator == CentralityEstimator::None) { const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } - hfEvSelMc.fillHistograms(mcCollision, rejectionMask); + hfEvSelMc.fillHistograms(mcCollision, rejectionMask, nSplitColl); if (rejectionMask != 0) { // at least one event selection not satisfied --> reject all gen particles from this collision for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) { @@ -702,96 +1337,7 @@ struct HfCandidateCreator3ProngExpressions { } continue; } - - // Match generated particles. - for (const auto& particle : mcParticlesPerMcColl) { - flag = 0; - origin = 0; - channel = 0; - arrDaughIndex.clear(); - std::vector idxBhadMothers{}; - // Reject particles from background events - if (particle.fromBackgroundEvent() && rejectBackground) { - rowMcMatchGen(flag, origin, channel, -1); - continue; - } - - // D± → π± K∓ π± - if (createDplus) { - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2)) { - flag = sign * (1 << DecayType::DplusToPiKPi); - } - } - - // Ds± → K± K∓ π± and D± → K± K∓ π± - if (flag == 0 && createDs) { - bool isDplus = false; - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDS, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2)) { - // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π± - // TODO: move to different and explicit flags - flag = sign * (1 << DecayType::DsToKKPi); - } else if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDPlus, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2)) { - // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π± - // TODO: move to different and explicit flags - flag = sign * (1 << DecayType::DsToKKPi); - isDplus = true; - } - if (flag != 0) { - RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{0}, 1); - if (arrDaughIndex.size() == 2) { - for (auto jProng = 0u; jProng < arrDaughIndex.size(); ++jProng) { - auto daughJ = mcParticles.rawIteratorAt(arrDaughIndex[jProng]); - arrPDGDaugh[jProng] = std::abs(daughJ.pdgCode()); - } - if ((arrPDGDaugh[0] == arrPDGResonantDPhiPi[0] && arrPDGDaugh[1] == arrPDGResonantDPhiPi[1]) || (arrPDGDaugh[0] == arrPDGResonantDPhiPi[1] && arrPDGDaugh[1] == arrPDGResonantDPhiPi[0])) { - channel = isDplus ? DecayChannelDToKKPi::DplusToPhiPi : DecayChannelDToKKPi::DsToPhiPi; - } else if ((arrPDGDaugh[0] == arrPDGResonantDKstarK[0] && arrPDGDaugh[1] == arrPDGResonantDKstarK[1]) || (arrPDGDaugh[0] == arrPDGResonantDKstarK[1] && arrPDGDaugh[1] == arrPDGResonantDKstarK[0])) { - channel = isDplus ? DecayChannelDToKKPi::DplusToK0starK : DecayChannelDToKKPi::DsToK0starK; - } - } - } - } - - // Λc± → p± K∓ π± - if (flag == 0 && createLc) { - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2)) { - flag = sign * (1 << DecayType::LcToPKPi); - - // Flagging the different Λc± → p± K∓ π± decay channels - RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{0}, 1); - if (arrDaughIndex.size() == 2) { - for (auto jProng = 0u; jProng < arrDaughIndex.size(); ++jProng) { - auto daughJ = mcParticles.rawIteratorAt(arrDaughIndex[jProng]); - arrPDGDaugh[jProng] = std::abs(daughJ.pdgCode()); - } - if ((arrPDGDaugh[0] == arrPDGResonant1[0] && arrPDGDaugh[1] == arrPDGResonant1[1]) || (arrPDGDaugh[0] == arrPDGResonant1[1] && arrPDGDaugh[1] == arrPDGResonant1[0])) { - channel = 1; - } else if ((arrPDGDaugh[0] == arrPDGResonant2[0] && arrPDGDaugh[1] == arrPDGResonant2[1]) || (arrPDGDaugh[0] == arrPDGResonant2[1] && arrPDGDaugh[1] == arrPDGResonant2[0])) { - channel = 2; - } else if ((arrPDGDaugh[0] == arrPDGResonant3[0] && arrPDGDaugh[1] == arrPDGResonant3[1]) || (arrPDGDaugh[0] == arrPDGResonant3[1] && arrPDGDaugh[1] == arrPDGResonant3[0])) { - channel = 3; - } - } - } - } - - // Ξc± → p± K∓ π± - if (flag == 0 && createXic) { - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kXiCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2)) { - flag = sign * (1 << DecayType::XicToPKPi); - } - } - - // Check whether the particle is non-prompt (from a b quark). - if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - } - if (origin == RecoDecay::OriginType::NonPrompt) { - rowMcMatchGen(flag, origin, channel, idxBhadMothers[0]); - } else { - rowMcMatchGen(flag, origin, channel, -1); - } - } + hf_mc_gen::fillMcMatchGen3Prong(mcParticles, mcParticlesPerMcColl, rowMcMatchGen, rejectBackground, matchCorrelatedBackground ? pdgMothersCorrelBkg : std::vector{}); } } @@ -829,6 +1375,6 @@ struct HfCandidateCreator3ProngExpressions { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"hf-candidate-creator-3prong"}), - adaptAnalysisTask(cfgc, TaskName{"hf-candidate-creator-3prong-expressions"})}; + adaptAnalysisTask(cfgc, TaskName{"hf-candidate-creator-3prong"}), // o2-linter: disable=name/o2-task (wrong hyphenation) + adaptAnalysisTask(cfgc, TaskName{"hf-candidate-creator-3prong-expressions"})}; // o2-linter: disable=name/o2-task (wrong hyphenation) } diff --git a/PWGHF/TableProducer/candidateCreatorB0.cxx b/PWGHF/TableProducer/candidateCreatorB0.cxx index 559734c7b12..a2751e9f3eb 100644 --- a/PWGHF/TableProducer/candidateCreatorB0.cxx +++ b/PWGHF/TableProducer/candidateCreatorB0.cxx @@ -15,22 +15,50 @@ /// /// \author Alexandre Bigot , IPHC Strasbourg -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/V0.h" - -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsMcGen.h" #include "PWGHF/Utils/utilsTrkCandHf.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::aod; @@ -38,6 +66,7 @@ using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::hf_trkcandsel; +using namespace o2::hf_decay::hf_cand_beauty; /// Reconstruction of B0 candidates struct HfCandidateCreatorB0 { @@ -57,7 +86,7 @@ struct HfCandidateCreatorB0 { Configurable usePionIsGlobalTrackWoDCA{"usePionIsGlobalTrackWoDCA", true, "check isGlobalTrackWoDCA status for pions, for Run3 studies"}; Configurable ptPionMin{"ptPionMin", 0.5, "minimum pion pT threshold (GeV/c)"}; Configurable> binsPtPion{"binsPtPion", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for pion DCA XY pT-dependent cut"}; - Configurable> cutsTrackPionDCA{"cutsTrackPionDCA", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for pions"}; + Configurable> cutsTrackPionDCA{"cutsTrackPionDCA", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for pions"}; Configurable invMassWindowB0{"invMassWindowB0", 0.3, "invariant-mass window for B0 candidates"}; Configurable selectionFlagD{"selectionFlagD", 1, "Selection Flag for D"}; // magnetic field setting from CCDB @@ -93,6 +122,9 @@ struct HfCandidateCreatorB0 { Preslice candsDPerCollision = aod::track_association::collisionId; Preslice trackIndicesPerCollision = aod::track_association::collisionId; + std::shared_ptr hCandidatesD, hCandidatesB; + HistogramRegistry registry{"registry"}; + OutputObj hMassDToPiKPi{TH1F("hMassDToPiKPi", "D^{#minus} candidates;inv. mass (p^{#minus} K^{#plus} #pi^{#minus}) (GeV/#it{c}^{2});entries", 500, 0., 5.)}; OutputObj hPtD{TH1F("hPtD", "D^{#minus} candidates;D^{#minus} candidate #it{p}_{T} (GeV/#it{c});entries", 100, 0., 10.)}; OutputObj hPtPion{TH1F("hPtPion", "#pi^{#plus} candidates;#pi^{#plus} candidate #it{p}_{T} (GeV/#it{c});entries", 100, 0., 10.)}; @@ -101,9 +133,6 @@ struct HfCandidateCreatorB0 { OutputObj hCovPVXX{TH1F("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", 100, 0., 1.e-4)}; OutputObj hCovSVXX{TH1F("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)}; - std::shared_ptr hCandidatesD, hCandidatesB; - HistogramRegistry registry{"registry"}; - void init(InitContext const&) { // invariant-mass window cut @@ -355,10 +384,10 @@ struct HfCandidateCreatorB0 { rowCandidateProngs(candD.globalIndex(), trackPion.globalIndex()); } // pi loop - } // D loop - } // collision loop - } // process -}; // struct + } // D loop + } // collision loop + } // process +}; // struct /// Extends the base table with expression columns and performs MC matching. struct HfCandidateCreatorB0Expressions { @@ -376,13 +405,14 @@ struct HfCandidateCreatorB0Expressions { int indexRec = -1; int8_t sign = 0; - int8_t flag = 0; + int8_t flagChannelMain = 0; + int8_t flagChannelReso = 0; int8_t origin = 0; int8_t debug = 0; // Match reconstructed candidates. for (const auto& candidate : candsB0) { - flag = 0; + flagChannelMain = 0; origin = 0; debug = 0; auto candD = candidate.prong0(); @@ -400,7 +430,7 @@ struct HfCandidateCreatorB0Expressions { // D- → π- K+ π- indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersD, Pdg::kDMinus, std::array{-kPiPlus, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { - flag = sign * BIT(hf_cand_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi); + flagChannelMain = sign * DecayChannelMain::B0ToDminusPi; } else { debug = 1; LOGF(debug, "WARNING: B0 in decays in the expected final state but the condition on the intermediate state is not fulfilled"); @@ -408,20 +438,20 @@ struct HfCandidateCreatorB0Expressions { } // B0 → Ds- π+ → (K- K+ π-) π+ - if (!flag) { + if (!flagChannelMain) { indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersB0, Pdg::kB0, std::array{-kKPlus, +kKPlus, -kPiPlus, +kPiPlus}, true, &sign, 3); if (indexRec > -1) { // Ds- → K- K+ π- indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersD, -Pdg::kDS, std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2); if (indexRec > -1) { - flag = sign * BIT(hf_cand_b0::DecayTypeMc::B0ToDsPiToKKPiPi); + flagChannelMain = sign * DecayChannelMain::B0ToDsPi; } } } // Partly reconstructed decays, i.e. the 4 prongs have a common b-hadron ancestor // convention: final state particles are prong0,1,2,3 - if (!flag) { + if (!flagChannelMain) { auto particleProng0 = arrayDaughtersB0[0].mcParticle(); auto particleProng1 = arrayDaughtersB0[1].mcParticle(); auto particleProng2 = arrayDaughtersB0[2].mcParticle(); @@ -436,33 +466,18 @@ struct HfCandidateCreatorB0Expressions { int index3Mother = RecoDecay::getMother(mcParticles, particleProng3, bHadronMotherHypo, true); // look for common b-hadron ancestor - if (index0Mother > -1 && index1Mother > -1 && index2Mother > -1 && index3Mother > -1) { - if (index0Mother == index1Mother && index1Mother == index2Mother && index2Mother == index3Mother) { - flag = BIT(hf_cand_b0::DecayTypeMc::PartlyRecoDecay); - break; - } + if (index0Mother > -1 && index0Mother == index1Mother && index1Mother == index2Mother && index2Mother == index3Mother) { + flagChannelMain = hf_cand_b0::DecayTypeMc::PartlyRecoDecay; // FIXME + break; } } } - rowMcMatchRec(flag, origin, debug); + rowMcMatchRec(flagChannelMain, flagChannelReso, origin, debug); } // rec - // Match generated particles. - for (const auto& particle : mcParticles) { - flag = 0; - origin = 0; - // B0 → D- π+ - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kB0, std::array{-static_cast(Pdg::kDPlus), +kPiPlus}, true)) { - // D- → π- K+ π- - auto candDMC = mcParticles.rawIteratorAt(particle.daughtersIds().front()); - if (RecoDecay::isMatchedMCGen(mcParticles, candDMC, -static_cast(Pdg::kDPlus), std::array{-kPiPlus, +kKPlus, -kPiPlus}, true, &sign)) { - flag = sign * BIT(hf_cand_b0::DecayType::B0ToDPi); - } - } - rowMcMatchGen(flag, origin); - } // gen - } // processMc + hf_mc_gen::fillMcMatchGenB0(mcParticles, rowMcMatchGen); // gen + } // processMc PROCESS_SWITCH(HfCandidateCreatorB0Expressions, processMc, "Process MC", false); }; // struct diff --git a/PWGHF/TableProducer/candidateCreatorBplus.cxx b/PWGHF/TableProducer/candidateCreatorBplus.cxx index 0d4753c6c98..f3cc0baa11e 100644 --- a/PWGHF/TableProducer/candidateCreatorBplus.cxx +++ b/PWGHF/TableProducer/candidateCreatorBplus.cxx @@ -18,26 +18,52 @@ /// \author Deepa Thomas , UT Austin /// \author Antonio Palasciano , Università degli Studi di Bari & INFN, Sezione di Bari -#include -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/V0.h" - -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsMcGen.h" #include "PWGHF/Utils/utilsTrkCandHf.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::hf_trkcandsel; @@ -45,6 +71,7 @@ using namespace o2::aod; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_decay::hf_cand_beauty; /// Reconstruction of B± → D0bar(D0) π± → (K± π∓) π± struct HfCandidateCreatorBplus { @@ -64,7 +91,7 @@ struct HfCandidateCreatorBplus { Configurable usePionIsGlobalTrackWoDCA{"usePionIsGlobalTrackWoDCA", true, "check isGlobalTrackWoDCA status for pions, for Run3 studies"}; Configurable ptPionMin{"ptPionMin", 0.2, "minimum pion pT threshold (GeV/c)"}; Configurable> binsPtPion{"binsPtPion", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for pion DCA XY pT-dependent cut"}; - Configurable> cutsTrackPionDCA{"cutsTrackPionDCA", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for pions"}; + Configurable> cutsTrackPionDCA{"cutsTrackPionDCA", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for pions"}; Configurable invMassWindowBplus{"invMassWindowBplus", 0.3, "invariant-mass window for B^{+} candidates"}; Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection Flag for D0bar"}; @@ -99,15 +126,15 @@ struct HfCandidateCreatorBplus { Preslice candsDPerCollision = aod::track_association::collisionId; Preslice trackIndicesPerCollision = aod::track_association::collisionId; + std::shared_ptr hCandidatesD, hCandidatesB; + HistogramRegistry registry{"registry"}; + OutputObj hCovPVXX{TH1F("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", 100, 0., 1.e-4)}; OutputObj hCovSVXX{TH1F("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)}; OutputObj hRapidityD0{TH1F("hRapidityD0", "D0 candidates;#it{y};entries", 100, -2, 2)}; OutputObj hEtaPi{TH1F("hEtaPi", "Pion track;#it{#eta};entries", 400, -2., 2.)}; OutputObj hMassBplusToD0Pi{TH1F("hMassBplusToD0Pi", "2-prong candidates;inv. mass (B^{+} #rightarrow #bar{D^{0}}#pi^{+}) (GeV/#it{c}^{2});entries", 500, 3., 8.)}; - std::shared_ptr hCandidatesD, hCandidatesB; - HistogramRegistry registry{"registry"}; - void init(InitContext const&) { // invariant-mass window cut @@ -341,11 +368,11 @@ struct HfCandidateCreatorBplus { std::sqrt(impactParameter0.getSigmaY2()), std::sqrt(impactParameter1.getSigmaY2())); rowCandidateProngs(candD0.globalIndex(), trackPion.globalIndex()); // index D0 and bachelor - } // track loop - } // D0 cand loop - } // collision - } // process -}; // struct + } // track loop + } // D0 cand loop + } // collision + } // process +}; // struct /// Extends the base table with expression columns and performs MC matching struct HfCandidateCreatorBplusExpressions { @@ -363,15 +390,16 @@ struct HfCandidateCreatorBplusExpressions { int indexRec = -1, indexRecD0 = -1; int8_t signB = 0, signD0 = 0; - int8_t flag = 0; + int8_t flagChannelMain = 0; + int8_t flagChannelReso = 0; int8_t origin = 0; - int kD0pdg = Pdg::kD0; // Match reconstructed candidates. // Spawned table can be used directly for (const auto& candidate : candsBplus) { - flag = 0; + flagChannelMain = 0; + flagChannelReso = 0; origin = 0; auto candDaughterD0 = candidate.prong0(); auto arrayDaughtersD0 = std::array{candDaughterD0.prong0_as(), candDaughterD0.prong1_as()}; @@ -382,36 +410,12 @@ struct HfCandidateCreatorBplusExpressions { indexRecD0 = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersD0, -Pdg::kD0, std::array{+kKPlus, -kPiPlus}, true, &signD0, 1); if (indexRecD0 > -1 && indexRec > -1) { - flag = signB * (1 << hf_cand_bplus::DecayType::BplusToD0Pi); + flagChannelMain = signB * DecayChannelMain::BplusToD0Pi; } - rowMcMatchRec(flag, origin); + rowMcMatchRec(flagChannelMain, flagChannelReso, origin); } - - // Match generated particles. - for (const auto& particle : mcParticles) { - flag = 0; - origin = 0; - signB = 0; - signD0 = 0; - int indexGenD0 = -1; - - // B± → D0bar(D0) π± → (K± π∓) π± - std::vector arrayDaughterB; - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kBPlus, std::array{-kD0pdg, +kPiPlus}, true, &signB, 1, &arrayDaughterB)) { - // D0(bar) → π± K∓ - for (auto iD : arrayDaughterB) { - auto candDaughterMC = mcParticles.rawIteratorAt(iD); - if (std::abs(candDaughterMC.pdgCode()) == kD0pdg) { - indexGenD0 = RecoDecay::isMatchedMCGen(mcParticles, candDaughterMC, Pdg::kD0, std::array{-kKPlus, +kPiPlus}, true, &signD0, 1); - } - } - if (indexGenD0 > -1) { - flag = signB * (1 << hf_cand_bplus::DecayType::BplusToD0Pi); - } - } - rowMcMatchGen(flag, origin); - } // B candidate - } // process + hf_mc_gen::fillMcMatchGenBplus(mcParticles, rowMcMatchGen); // gen + } // process PROCESS_SWITCH(HfCandidateCreatorBplusExpressions, processMc, "Process MC", false); }; // struct diff --git a/PWGHF/TableProducer/candidateCreatorBs.cxx b/PWGHF/TableProducer/candidateCreatorBs.cxx index e9aef03fd30..0bf80217b41 100644 --- a/PWGHF/TableProducer/candidateCreatorBs.cxx +++ b/PWGHF/TableProducer/candidateCreatorBs.cxx @@ -15,22 +15,49 @@ /// /// \author Phil Stahlhut -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/V0.h" - -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsTrkCandHf.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::aod; @@ -38,10 +65,11 @@ using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::hf_trkcandsel; +using namespace o2::hf_decay::hf_cand_beauty; /// Reconstruction of Bs candidates struct HfCandidateCreatorBs { - Produces rowCandidateBase; // table defined in CandidateReconstructionTables.h + Produces rowCandidateBase; // table defined in CandidateReconstructionTables.h Produces rowCandidateProngs; // table defined in CandidateReconstructionTables.h // vertexing @@ -57,7 +85,7 @@ struct HfCandidateCreatorBs { Configurable usePionIsGlobalTrackWoDCA{"usePionIsGlobalTrackWoDCA", true, "check isGlobalTrackWoDCA status for pions, for Run3 studies"}; Configurable ptPionMin{"ptPionMin", 0.5, "minimum pion pT threshold (GeV/c)"}; Configurable> binsPtPion{"binsPtPion", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for pion DCA XY pT-dependent cut"}; - Configurable> cutsTrackPionDCA{"cutsTrackPionDCA", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for pions"}; + Configurable> cutsTrackPionDCA{"cutsTrackPionDCA", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for pions"}; Configurable invMassWindowBs{"invMassWindowBs", 0.3, "invariant-mass window for Bs candidates"}; Configurable selectionFlagDs{"selectionFlagDs", 1, "Selection Flag for Ds"}; // magnetic field setting from CCDB @@ -89,6 +117,9 @@ struct HfCandidateCreatorBs { Preslice candsDsPerCollision = aod::track_association::collisionId; Preslice trackIndicesPerCollision = aod::track_association::collisionId; + std::shared_ptr hCandidatesD, hCandidatesB; + HistogramRegistry registry{"registry"}; + OutputObj hMassDsToKKPi{TH1F("hMassDsToKKPi", "D_{s} candidates;inv. mass (K K #pi) (GeV/#it{c}^{2});entries", 500, 0., 5.)}; OutputObj hPtDs{TH1F("hPtDs", "D_{s} candidates;D_{s} candidate #it{p}_{T} (GeV/#it{c});entries", 100, 0., 10.)}; OutputObj hPtPion{TH1F("hPtPion", "#pi candidates;#pi candidate #it{p}_{T} (GeV/#it{c});entries", 100, 0., 10.)}; @@ -97,9 +128,6 @@ struct HfCandidateCreatorBs { OutputObj hCovPVXX{TH1F("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", 100, 0., 1.e-4)}; OutputObj hCovSVXX{TH1F("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)}; - std::shared_ptr hCandidatesD, hCandidatesB; - HistogramRegistry registry{"registry"}; - void init(InitContext const&) { massPi = MassPiPlus; @@ -343,10 +371,10 @@ struct HfCandidateCreatorBs { rowCandidateProngs(candDs.globalIndex(), trackPion.globalIndex()); } // pi loop - } // Ds loop - } // collision loop - } // process -}; // struct + } // Ds loop + } // collision loop + } // process +}; // struct /// Extends the base table with expression columns and performs MC matching. struct HfCandidateCreatorBsExpressions { @@ -363,14 +391,16 @@ struct HfCandidateCreatorBsExpressions { { int indexRec = -1; int8_t sign = 0; - int8_t flag = 0; + int8_t flagChannelMain = 0; + int8_t flagChannelReso = 0; std::vector arrDaughDsIndex; std::array arrPDGDaughDs; std::array arrPDGResonantDsPhiPi = {Pdg::kPhi, kPiPlus}; // Ds± → Phi π± // Match reconstructed candidates. for (const auto& candidate : candsBs) { - flag = 0; + flagChannelMain = 0; + flagChannelReso = 0; arrDaughDsIndex.clear(); auto candDs = candidate.prong0(); auto arrayDaughtersBs = std::array{candDs.prong0_as(), @@ -394,13 +424,13 @@ struct HfCandidateCreatorBsExpressions { arrPDGDaughDs[iProng] = std::abs(daughI.pdgCode()); } if ((arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[0] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[1]) || (arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[1] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[0])) { - flag = sign * BIT(hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi); + flagChannelMain = sign * DecayChannelMain::BsToDsPi; } } } } - if (!flag) { + if (!flagChannelMain) { // Checking B0(bar) → Ds± π∓ → (K- K+ π±) π∓ indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersBs, Pdg::kB0, std::array{-kKPlus, +kKPlus, +kPiPlus, -kPiPlus}, true, &sign, 3); if (indexRec > -1) { @@ -414,7 +444,7 @@ struct HfCandidateCreatorBsExpressions { arrPDGDaughDs[iProng] = std::abs(daughI.pdgCode()); } if ((arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[0] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[1]) || (arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[1] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[0])) { - flag = sign * BIT(hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi); + flagChannelMain = sign * DecayChannelMain::B0ToDsPi; } } } @@ -423,7 +453,7 @@ struct HfCandidateCreatorBsExpressions { // Partly reconstructed decays, i.e. the 4 prongs have a common b-hadron ancestor // convention: final state particles are prong0,1,2,3 - if (!flag) { + if (!flagChannelMain) { auto particleProng0 = arrayDaughtersBs[0].mcParticle(); auto particleProng1 = arrayDaughtersBs[1].mcParticle(); auto particleProng2 = arrayDaughtersBs[2].mcParticle(); @@ -438,21 +468,20 @@ struct HfCandidateCreatorBsExpressions { int index3Mother = RecoDecay::getMother(mcParticles, particleProng3, bHadronMotherHypo, true); // look for common b-hadron ancestor - if (index0Mother > -1 && index1Mother > -1 && index2Mother > -1 && index3Mother > -1) { - if (index0Mother == index1Mother && index1Mother == index2Mother && index2Mother == index3Mother) { - flag = BIT(hf_cand_bs::DecayTypeMc::PartlyRecoDecay); - break; - } + if (index0Mother > -1 && index0Mother == index1Mother && index1Mother == index2Mother && index2Mother == index3Mother) { + flagChannelMain = hf_cand_bs::DecayTypeMc::PartlyRecoDecay; // FIXME + break; } } } - rowMcMatchRec(flag); + rowMcMatchRec(flagChannelMain, flagChannelReso); } // rec // Match generated particles. for (const auto& particle : mcParticles) { - flag = 0; + flagChannelMain = 0; + flagChannelReso = 0; arrDaughDsIndex.clear(); // Checking Bs0(bar) → Ds∓ π± → (K- K+ π∓) π± @@ -467,13 +496,13 @@ struct HfCandidateCreatorBsExpressions { arrPDGDaughDs[jProng] = std::abs(daughJ.pdgCode()); } if ((arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[0] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[1]) || (arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[1] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[0])) { - flag = sign * BIT(hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi); + flagChannelMain = sign * DecayChannelMain::BsToDsPi; } } } } - if (!flag) { + if (!flagChannelMain) { // Checking B0(bar) → Ds± π∓ → (K- K+ π±) π∓ if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kB0, std::array{+Pdg::kDS, -kPiPlus}, true)) { // Checking Ds± → K- K+ π± @@ -486,14 +515,14 @@ struct HfCandidateCreatorBsExpressions { arrPDGDaughDs[jProng] = std::abs(daughJ.pdgCode()); } if ((arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[0] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[1]) || (arrPDGDaughDs[0] == arrPDGResonantDsPhiPi[1] && arrPDGDaughDs[1] == arrPDGResonantDsPhiPi[0])) { - flag = sign * BIT(hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi); + flagChannelMain = sign * DecayChannelMain::B0ToDsPi; } } } } } - rowMcMatchGen(flag); + rowMcMatchGen(flagChannelMain, flagChannelReso); } // gen } // processMc PROCESS_SWITCH(HfCandidateCreatorBsExpressions, processMc, "Process MC", false); diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index 288713aafbd..20e16710463 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -15,28 +15,50 @@ /// \author Chiara Zampolli, , CERN /// Paul Buehler, , Vienna -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/V0.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" - -#include "Common/Core/trackUtilities.h" - #include "PWGHF/Core/CentralityEstimation.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" #include "PWGHF/Utils/utilsTrkCandHf.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; -using namespace o2::analysis; using namespace o2::hf_evsel; using namespace o2::hf_trkcandsel; using namespace o2::hf_centrality; @@ -79,6 +101,9 @@ struct HfCandidateCreatorCascade { double mass2K0sP{0.}; double bz = 0.; + using V0full = soa::Join; + using V0fCfull = soa::Join; + std::shared_ptr hCandidates; HistogramRegistry registry{"registry"}; @@ -111,7 +136,9 @@ struct HfCandidateCreatorCascade { registry.add("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}); registry.add("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 0.2}}}); hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); - hfEvSel.addHistograms(registry); // collision monitoring + + // init HF event selection helper + hfEvSel.init(registry); massP = MassProton; massK0s = MassK0Short; @@ -137,9 +164,6 @@ struct HfCandidateCreatorCascade { setLabelHistoCands(hCandidates); } - using V0full = soa::Join; - using V0fCfull = soa::Join; - template void runCreatorCascade(Coll const&, aod::HfCascades const& rowsTrackIndexCasc, @@ -170,7 +194,7 @@ struct HfCandidateCreatorCascade { } int posGlobalIndex = -1, negGlobalIndex = -1; - float v0x, v0y, v0z, v0px, v0py, v0pz; + float v0X, v0Y, v0Z, v0px, v0py, v0pz; float v0PosPx, v0PosPy, v0PosPz, v0NegPx, v0NegPy, v0NegPz; float dcaV0dau, dcaPosToPV, dcaNegToPV, v0cosPA; std::array covV = {0.}; @@ -183,9 +207,9 @@ struct HfCandidateCreatorCascade { const auto& trackV0DaughNeg = v0row.negTrack_as(); posGlobalIndex = trackV0DaughPos.globalIndex(); negGlobalIndex = trackV0DaughNeg.globalIndex(); - v0x = v0row.x(); - v0y = v0row.y(); - v0z = v0row.z(); + v0X = v0row.x(); + v0Y = v0row.y(); + v0Z = v0row.z(); v0px = v0row.px(); v0py = v0row.py(); v0pz = v0row.pz(); @@ -212,9 +236,9 @@ struct HfCandidateCreatorCascade { const auto& trackV0DaughNeg = v0row.negTrack_as(); posGlobalIndex = trackV0DaughPos.globalIndex(); negGlobalIndex = trackV0DaughNeg.globalIndex(); - v0x = v0row.x(); - v0y = v0row.y(); - v0z = v0row.z(); + v0X = v0row.x(); + v0Y = v0row.y(); + v0Z = v0row.z(); v0px = v0row.px(); v0py = v0row.py(); v0pz = v0row.pz(); @@ -251,7 +275,7 @@ struct HfCandidateCreatorCascade { df.setBz(bz); auto trackBach = getTrackParCov(bach); - const std::array vertexV0 = {v0x, v0y, v0z}; + const std::array vertexV0 = {v0X, v0Y, v0Z}; const std::array momentumV0 = {v0px, v0py, v0pz}; // we build the neutral track to then build the cascade auto trackV0 = o2::track::TrackParCov(vertexV0, momentumV0, covV, 0, true); @@ -314,7 +338,7 @@ struct HfCandidateCreatorCascade { impactParameterBach.getY(), impactParameterV0.getY(), std::sqrt(impactParameterBach.getSigmaY2()), std::sqrt(impactParameterV0.getSigmaY2()), casc.prong0Id(), casc.v0Id(), - v0x, v0y, v0z, + v0X, v0Y, v0Z, posGlobalIndex, negGlobalIndex, v0PosPx, v0PosPy, v0PosPz, v0NegPx, v0NegPy, v0NegPz, @@ -437,22 +461,24 @@ struct HfCandidateCreatorCascadeMc { Produces rowMcMatchRec; Produces rowMcMatchGen; + // Configuration + Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring + using MyTracksWMc = soa::Join; using BCsInfo = soa::Join; - HistogramRegistry registry{"registry"}; - - // Configuration - o2::framework::Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; - using McCollisionsNoCents = soa::Join; using McCollisionsFT0Cs = soa::Join; using McCollisionsFT0Ms = soa::Join; using McCollisionsCentFT0Ms = soa::Join; + + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId; - Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + + HistogramRegistry registry{"registry"}; // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) @@ -465,11 +491,11 @@ struct HfCandidateCreatorCascadeMc { const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-cascade") == 0) { - hfEvSelMc.configureFromDevice(device); + // init HF event selection helper + hfEvSelMc.init(device, registry); break; } } - hfEvSelMc.addHistograms(registry); // particles monitoring } template @@ -538,18 +564,20 @@ struct HfCandidateCreatorCascadeMc { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint16_t rejectionMask{0}; + uint32_t rejectionMask{0u}; + int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } else if constexpr (centEstimator == CentralityEstimator::FT0M) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0M, mcCollision.globalIndex()); + nSplitColl = collSlice.size(); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } else if constexpr (centEstimator == CentralityEstimator::None) { const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } - hfEvSelMc.fillHistograms(mcCollision, rejectionMask); + hfEvSelMc.fillHistograms(mcCollision, rejectionMask, nSplitColl); if (rejectionMask != 0) { // at least one event selection not satisfied --> reject all particles from this collision for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) { diff --git a/PWGHF/TableProducer/candidateCreatorDstar.cxx b/PWGHF/TableProducer/candidateCreatorDstar.cxx index 6bfc79b3b66..9036717104b 100644 --- a/PWGHF/TableProducer/candidateCreatorDstar.cxx +++ b/PWGHF/TableProducer/candidateCreatorDstar.cxx @@ -15,27 +15,50 @@ /// \author Vít Kučera , CERN /// \author Deependra Sharma , IITB /// \author Fabrizio Grosa , CERN -// std -#include -#include -#include -// ROOT -#include -// O2 -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -// O2Physics -#include "Common/Core/trackUtilities.h" -// PWGHF + #include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsPid.h" #include "PWGHF/Utils/utilsTrkCandHf.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::hf_evsel; @@ -43,6 +66,7 @@ using namespace o2::hf_trkcandsel; using namespace o2::hf_centrality; using namespace o2::constants::physics; using namespace o2::framework; +using namespace o2::aod::pid_tpc_tof_utils; namespace o2::aod { @@ -53,6 +77,12 @@ using HfDstarsWithPvRefitInfo = soa::Join; struct HfCandidateCreatorDstar { Produces rowCandD0Base; Produces rowCandDstarBase; + Produces rowProng0PidPi; + Produces rowProng0PidKa; + Produces rowProng1PidPi; + Produces rowProng1PidKa; + Produces rowProngSoftPiPidPi; + Produces rowProngSoftPiPidKa; Configurable fillHistograms{"fillHistograms", true, "fill histograms"}; @@ -82,6 +112,8 @@ struct HfCandidateCreatorDstar { static constexpr float CmToMicrometers = 10000.; // from cm to µm double massPi, massK, massD0; + using TracksWCovExtraPidPiKa = soa::Join; + AxisSpec ptAxis = {100, 0., 2.0, "#it{p}_{T} (GeV/#it{c}"}; AxisSpec dcaAxis = {200, -500., 500., "#it{d}_{xy,z} (#mum)"}; @@ -136,7 +168,9 @@ struct HfCandidateCreatorDstar { } hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); - hfEvSel.addHistograms(registry); // collision monitoring + + // init HF event selection helper + hfEvSel.init(registry); // LOG(info) << "Init Function Invoked"; massPi = MassPiPlus; @@ -174,7 +208,7 @@ struct HfCandidateCreatorDstar { void runCreatorDstar(Coll const&, CandsDstar const& rowsTrackIndexDstar, aod::Hf2Prongs const&, - aod::TracksWCov const&, + TracksWCovExtraPidPiKa const&, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) { // LOG(info) << "runCreatorDstar function called"; @@ -191,10 +225,10 @@ struct HfCandidateCreatorDstar { continue; } - auto trackPi = rowTrackIndexDstar.template prong0_as(); + auto trackPi = rowTrackIndexDstar.template prong0_as(); auto prongD0 = rowTrackIndexDstar.template prongD0_as(); - auto trackD0Prong0 = prongD0.template prong0_as(); - auto trackD0Prong1 = prongD0.template prong1_as(); + auto trackD0Prong0 = prongD0.template prong0_as(); + auto trackD0Prong1 = prongD0.template prong1_as(); // Extracts primary vertex position and covariance matrix from a collision auto primaryVertex = getPrimaryVertex(collision); @@ -344,6 +378,14 @@ struct HfCandidateCreatorDstar { std::sqrt(impactParameter0.getSigmaZ2()), std::sqrt(impactParameter1.getSigmaZ2()), prongD0.prong0Id(), prongD0.prong1Id(), prongD0.hfflag()); + // fill candidate D0 prong PID rows + fillProngPid(trackD0Prong0, rowProng0PidPi); + fillProngPid(trackD0Prong0, rowProng0PidKa); + fillProngPid(trackD0Prong1, rowProng1PidPi); + fillProngPid(trackD0Prong1, rowProng1PidKa); + // fill soft-pion PID rows + fillProngPid(trackPi, rowProngSoftPiPidPi); + fillProngPid(trackPi, rowProngSoftPiPidKa); if (fillHistograms) { registry.fill(HIST("QA/hPtD0"), ptD0); @@ -366,7 +408,7 @@ struct HfCandidateCreatorDstar { void processPvRefit(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexD0, aod::HfDstarsWithPvRefitInfo const& rowsTrackIndexDstar, - aod::TracksWCov const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreatorDstar(collisions, rowsTrackIndexDstar, rowsTrackIndexD0, tracks, bcWithTimeStamps); @@ -377,7 +419,7 @@ struct HfCandidateCreatorDstar { void processNoPvRefit(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexD0, aod::HfDstars const& rowsTrackIndexDstar, - aod::TracksWCov const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreatorDstar(collisions, rowsTrackIndexDstar, rowsTrackIndexD0, tracks, bcWithTimeStamps); @@ -394,7 +436,7 @@ struct HfCandidateCreatorDstar { void processPvRefitCentFT0C(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexD0, aod::HfDstarsWithPvRefitInfo const& rowsTrackIndexDstar, - aod::TracksWCov const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreatorDstar(collisions, rowsTrackIndexDstar, rowsTrackIndexD0, tracks, bcWithTimeStamps); @@ -405,7 +447,7 @@ struct HfCandidateCreatorDstar { void processNoPvRefitCentFT0C(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexD0, aod::HfDstars const& rowsTrackIndexDstar, - aod::TracksWCov const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreatorDstar(collisions, rowsTrackIndexDstar, rowsTrackIndexD0, tracks, bcWithTimeStamps); @@ -422,7 +464,7 @@ struct HfCandidateCreatorDstar { void processPvRefitCentFT0M(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexD0, aod::HfDstarsWithPvRefitInfo const& rowsTrackIndexDstar, - aod::TracksWCov const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreatorDstar(collisions, rowsTrackIndexDstar, rowsTrackIndexD0, tracks, bcWithTimeStamps); @@ -433,7 +475,7 @@ struct HfCandidateCreatorDstar { void processNoPvRefitCentFT0M(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexD0, aod::HfDstars const& rowsTrackIndexDstar, - aod::TracksWCov const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreatorDstar(collisions, rowsTrackIndexDstar, rowsTrackIndexD0, tracks, bcWithTimeStamps); @@ -500,28 +542,27 @@ struct HfCandidateCreatorDstar { struct HfCandidateCreatorDstarExpressions { Spawns rowsCandidateD0; - Produces rowsMcMatchRecD0; - Produces rowsMcMatchGenD0; - Spawns rowsCandidateDstar; Produces rowsMcMatchRecDstar; Produces rowsMcMatchGenDstar; // Configuration - o2::framework::Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; - o2::framework::Configurable matchKinkedDecayTopology{"matchKinkedDecayTopology", false, "Match also candidates with tracks that decay with kinked topology"}; + Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + Configurable matchKinkedDecayTopology{"matchKinkedDecayTopology", false, "Match also candidates with tracks that decay with kinked topology"}; + Configurable matchInteractionsWithMaterial{"matchInteractionsWithMaterial", false, "Match also candidates with tracks that interact with material"}; using McCollisionsNoCents = soa::Join; using McCollisionsFT0Cs = soa::Join; using McCollisionsFT0Ms = soa::Join; using McCollisionsCentFT0Ms = soa::Join; + using BCsInfo = soa::Join; + + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId; - Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring - using BCsInfo = soa::Join; HistogramRegistry registry{"registry"}; // inspect for which zPvPosMax cut was set for reconstructed @@ -535,11 +576,11 @@ struct HfCandidateCreatorDstarExpressions { const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-dstar") == 0) { - hfEvSelMc.configureFromDevice(device); + // init HF event selection helper + hfEvSelMc.init(device, registry); break; } } - hfEvSelMc.addHistograms(registry); // particles monitoring } /// Perform MC Matching. @@ -556,15 +597,15 @@ struct HfCandidateCreatorDstarExpressions { int indexRecDstar = -1, indexRecD0 = -1; int8_t signDstar = 0, signD0 = 0; int8_t flagDstar = 0, flagD0 = 0; - int8_t originDstar = 0, originD0 = 0; + int8_t originDstar = 0; int8_t nKinkedTracksDstar = 0, nKinkedTracksD0 = 0; + int8_t nInteractionsWithMaterialDstar = 0, nInteractionsWithMaterialD0 = 0; // Match reconstructed candidates. for (const auto& rowCandidateDstar : *rowsCandidateDstar) { flagDstar = 0; flagD0 = 0; originDstar = 0; - originD0 = 0; std::vector idxBhadMothers{}; auto indexDstar = rowCandidateDstar.globalIndex(); @@ -587,16 +628,26 @@ struct HfCandidateCreatorDstarExpressions { } } if (fromBkg) { - rowsMcMatchRecDstar(flagDstar, originDstar, -1.f, 0, 0); + rowsMcMatchRecDstar(flagDstar, flagD0, originDstar, -1.f, 0, 0, 0); continue; } } - if (matchKinkedDecayTopology) { + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + // D*± → D0(bar) π± + indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2, &nKinkedTracksDstar, &nInteractionsWithMaterialDstar); + // D0(bar) → π± K∓ + indexRecD0 = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersofD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0, 1, &nKinkedTracksD0, &nInteractionsWithMaterialD0); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { // D*± → D0(bar) π± - indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2, &nKinkedTracksDstar); + indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2, &nKinkedTracksDstar); // D0(bar) → π± K∓ - indexRecD0 = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersofD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0, 1, &nKinkedTracksD0); + indexRecD0 = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersofD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0, 1, &nKinkedTracksD0); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + // D*± → D0(bar) π± + indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2, nullptr, &nInteractionsWithMaterialDstar); + // D0(bar) → π± K∓ + indexRecD0 = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersofD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0, 1, nullptr, &nInteractionsWithMaterialD0); } else { // D*± → D0(bar) π± indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2); @@ -605,10 +656,62 @@ struct HfCandidateCreatorDstarExpressions { } if (indexRecDstar > -1) { - flagDstar = signDstar * (BIT(aod::hf_cand_dstar::DecayType::DstarToD0Pi)); + flagDstar = signDstar * hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi; } if (indexRecD0 > -1) { - flagD0 = signD0 * (BIT(aod::hf_cand_dstar::DecayType::D0ToPiK)); + flagD0 = signD0 * hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; + } + + // check partly reconstructed decays, namely D0->Kpipi0 + if (indexRecDstar < 0 && indexRecD0) { + if (matchKinkedDecayTopology && matchInteractionsWithMaterial) { + // D*± → D0(bar) π± + indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2, &nKinkedTracksDstar, &nInteractionsWithMaterialDstar); + // D0(bar) → π± K∓ + indexRecD0 = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersofD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0, 1, &nKinkedTracksD0, &nInteractionsWithMaterialD0); + } else if (matchKinkedDecayTopology && !matchInteractionsWithMaterial) { + // D*± → D0(bar) π± + indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2, &nKinkedTracksDstar); + // D0(bar) → π± K∓ + indexRecD0 = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersofD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0, 1, &nKinkedTracksD0); + } else if (!matchKinkedDecayTopology && matchInteractionsWithMaterial) { + // D*± → D0(bar) π± + indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2, nullptr, &nInteractionsWithMaterialDstar); + // D0(bar) → π± K∓ + indexRecD0 = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersofD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0, 1, nullptr, &nInteractionsWithMaterialD0); + } else { + // D*± → D0(bar) π± + indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2); + // D0(bar) → π± K∓ + indexRecD0 = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersofD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0); + } + + if (indexRecDstar > -1) { + // D*± → D0(bar) π± π0 + auto motherParticleDstar = mcParticles.rawIteratorAt(indexRecDstar); + if (signDstar > 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, motherParticleDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus, +kPi0}, false, &signDstar, 2)) { + flagDstar = signDstar * hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPiPi0; + } + } else { + if (RecoDecay::isMatchedMCGen(mcParticles, motherParticleDstar, -Pdg::kDStar, std::array{-kPiPlus, -kPiPlus, +kKPlus, +kPi0}, false, &signDstar, 2)) { + flagDstar = signDstar * hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPiPi0; + } + } + } + if (indexRecD0 > -1) { + // D0(bar) → π± K∓ π0 + auto motherParticleD0 = mcParticles.rawIteratorAt(indexRecD0); + if (signD0 > 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, motherParticleD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus, +kPi0}, false, &signD0)) { + flagD0 = signD0 * hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiKPi0; + } + } else { + if (RecoDecay::isMatchedMCGen(mcParticles, motherParticleD0, -Pdg::kD0, std::array{-kPiPlus, +kKPlus, +kPi0}, false, &signD0)) { + flagD0 = signD0 * hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiKPi0; + } + } + } } // check wether the particle is non-promt (from a B0 hadron) @@ -616,17 +719,12 @@ struct HfCandidateCreatorDstarExpressions { auto particleDstar = mcParticles.iteratorAt(indexRecDstar); originDstar = RecoDecay::getCharmHadronOrigin(mcParticles, particleDstar, false, &idxBhadMothers); } - if (flagD0 != 0) { - auto particleD0 = mcParticles.iteratorAt(indexRecD0); - originD0 = RecoDecay::getCharmHadronOrigin(mcParticles, particleD0); - } if (originDstar == RecoDecay::OriginType::NonPrompt) { auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); - rowsMcMatchRecDstar(flagDstar, originDstar, bHadMother.pt(), bHadMother.pdgCode(), nKinkedTracksDstar); + rowsMcMatchRecDstar(flagDstar, flagD0, originDstar, bHadMother.pt(), bHadMother.pdgCode(), nKinkedTracksDstar, nInteractionsWithMaterialDstar); } else { - rowsMcMatchRecDstar(flagDstar, originDstar, -1.f, 0, nKinkedTracksDstar); + rowsMcMatchRecDstar(flagDstar, flagD0, originDstar, -1.f, 0, nKinkedTracksDstar, nInteractionsWithMaterialDstar); } - rowsMcMatchRecD0(flagD0, originD0, -1.f, 0, nKinkedTracksD0); } for (const auto& mcCollision : mcCollisions) { @@ -634,23 +732,24 @@ struct HfCandidateCreatorDstarExpressions { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint16_t rejectionMask{0}; + uint32_t rejectionMask{0u}; + int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } else if constexpr (centEstimator == CentralityEstimator::FT0M) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0M, mcCollision.globalIndex()); + nSplitColl = collSlice.size(); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } else if constexpr (centEstimator == CentralityEstimator::None) { const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); } - hfEvSelMc.fillHistograms(mcCollision, rejectionMask); + hfEvSelMc.fillHistograms(mcCollision, rejectionMask, nSplitColl); if (rejectionMask != 0) { // at least one event selection not satisfied --> reject all particles from this collision for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) { - rowsMcMatchGenDstar(0, 0, -1); - rowsMcMatchGenD0(0, 0, -1); + rowsMcMatchGenDstar(0, 0, 0, -1); } continue; } @@ -660,38 +759,47 @@ struct HfCandidateCreatorDstarExpressions { flagDstar = 0; flagD0 = 0; originDstar = 0; - originD0 = 0; std::vector idxBhadMothers{}; // Reject particles from background events if (particle.fromBackgroundEvent() && rejectBackground) { - rowsMcMatchGenDstar(flagDstar, originDstar, -1); - rowsMcMatchGenD0(flagD0, originD0, -1); + rowsMcMatchGenDstar(flagDstar, flagD0, originDstar, -1); continue; } // D*± → D0(bar) π± - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2)) { - flagDstar = signDstar * (BIT(aod::hf_cand_dstar::DecayType::DstarToD0Pi)); - } + std::vector listIndexDaughters{}; + bool isDstarToDzeroPi = RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDStar, std::array{+Pdg::kD0, +kPiPlus}, true, &signDstar, 1, &listIndexDaughters); + // D0(bar) → π± K∓ - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0)) { - flagD0 = signD0 * (BIT(aod::hf_cand_dstar::DecayType::D0ToPiK)); + if (isDstarToDzeroPi) { + aod::McParticles::iterator particleD0; + for (const auto& dauIdx : listIndexDaughters) { + if (dauIdx >= 0) { + particleD0 = mcParticles.rawIteratorAt(dauIdx); + if (std::abs(particleD0.pdgCode()) == Pdg::kD0) { + break; + } + } + } + if (RecoDecay::isMatchedMCGen(mcParticles, particleD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &signD0)) { + flagDstar = signDstar * hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi; + flagD0 = signD0 * hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; + } else if (RecoDecay::isMatchedMCGen(mcParticles, particleD0, Pdg::kD0, std::array{+kPiPlus, -kKPlus, +kPi0}, false, &signD0) || RecoDecay::isMatchedMCGen(mcParticles, particleD0, -Pdg::kD0, std::array{-kPiPlus, +kKPlus, +kPi0}, false, &signD0)) { + flagDstar = signDstar * hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPiPi0; + flagD0 = signD0 * hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiKPi0; + } } - // check wether the particle is non-promt (from a B0 hadron) + // check wether the particle is non-prompt (from a B0 hadron) if (flagDstar != 0) { originDstar = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); } - if (flagD0 != 0) { - originD0 = RecoDecay::getCharmHadronOrigin(mcParticles, particle); - } if (originDstar == RecoDecay::OriginType::NonPrompt) { - rowsMcMatchGenDstar(flagDstar, originDstar, idxBhadMothers[0]); + rowsMcMatchGenDstar(flagDstar, flagD0, originDstar, idxBhadMothers[0]); } else { - rowsMcMatchGenDstar(flagDstar, originDstar, -1); + rowsMcMatchGenDstar(flagDstar, flagD0, originDstar, -1); } - rowsMcMatchGenD0(flagD0, originD0, -1.); } } } diff --git a/PWGHF/TableProducer/candidateCreatorLb.cxx b/PWGHF/TableProducer/candidateCreatorLb.cxx index a47c0bde898..9d15a7e3e1d 100644 --- a/PWGHF/TableProducer/candidateCreatorLb.cxx +++ b/PWGHF/TableProducer/candidateCreatorLb.cxx @@ -15,20 +15,40 @@ /// /// \author Panos Christakoglou , Nikhef -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/V0.h" - -#include "Common/Core/trackUtilities.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsTrkCandHf.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::aod; @@ -36,11 +56,12 @@ using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::hf_trkcandsel; +using namespace o2::hf_decay::hf_cand_beauty; /// Reconstruction of Λb candidates struct HfCandidateCreatorLb { Produces rowCandidateBase; - + Produces rowCandidateProngs; // vertexing Configurable bz{"bz", 20., "magnetic field"}; Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; @@ -65,6 +86,9 @@ struct HfCandidateCreatorLb { Filter filterSelectCandidates = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc); + std::shared_ptr hCandidatesLc, hCandidatesLb; + HistogramRegistry registry{"registry"}; + OutputObj hMassLcToPKPi{TH1F("hMassLcToPKPi", "#Lambda_{c}^{#plus} candidates;inv. mass (pK^{#minus} #pi^{#plus}) (GeV/#it{c}^{2});entries", 500, 0., 5.)}; OutputObj hPtLc{TH1F("hPtLc", "#Lambda_{c}^{#plus} candidates;#Lambda_{c}^{#plus} candidate #it{p}_{T} (GeV/#it{c});entries", 100, 0., 10.)}; OutputObj hPtPion{TH1F("hPtPion", "#pi^{#minus} candidates;#pi^{#minus} candidate #it{p}_{T} (GeV/#it{c});entries", 100, 0., 10.)}; @@ -73,9 +97,6 @@ struct HfCandidateCreatorLb { OutputObj hCovPVXX{TH1F("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", 100, 0., 1.e-4)}; OutputObj hCovSVXX{TH1F("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)}; - std::shared_ptr hCandidatesLc, hCandidatesLb; - HistogramRegistry registry{"registry"}; - void init(InitContext const&) { massPi = MassPiMinus; @@ -214,8 +235,6 @@ struct HfCandidateCreatorLb { auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta)); auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); - int hfFlag = 1 << hf_cand_lb::DecayType::LbToLcPi; - // fill the candidate table for the Lb here: rowCandidateBase(collision.globalIndex(), collision.posX(), collision.posY(), collision.posZ(), @@ -225,10 +244,8 @@ struct HfCandidateCreatorLb { pvecLc[0], pvecLc[1], pvecLc[2], pvecPion[0], pvecPion[1], pvecPion[2], impactParameter0.getY(), impactParameter1.getY(), - std::sqrt(impactParameter0.getSigmaY2()), std::sqrt(impactParameter1.getSigmaY2()), - lcCand.globalIndex(), trackPion.globalIndex(), - hfFlag); - + std::sqrt(impactParameter0.getSigmaY2()), std::sqrt(impactParameter1.getSigmaY2())); + rowCandidateProngs(lcCand.globalIndex(), trackPion.globalIndex()); // calculate invariant mass auto arrayMomenta = std::array{pvecLc, pvecPion}; massLcPi = RecoDecay::m(std::move(arrayMomenta), std::array{massLc, massPi}); @@ -239,38 +256,37 @@ struct HfCandidateCreatorLb { hMassLbToLcPi->Fill(massLcPi); } } // pi- loop - } // Lc loop - } // process -}; // struct + } // Lc loop + } // process +}; // struct /// Extends the base table with expression columns. struct HfCandidateCreatorLbExpressions { Spawns rowCandidateLb; - - void init(InitContext const&) {} - Produces rowMcMatchRec; Produces rowMcMatchGen; + void init(InitContext const&) {} + /// @brief dummy process function, to be run on data void process(aod::Tracks const&) {} - void processMc(aod::HfCand3Prong const& lcCandidates, - aod::TracksWMc const& tracks, - aod::McParticles const& mcParticles) + void processMc(aod::HfCand3Prong const&, + aod::TracksWMc const&, + aod::McParticles const& mcParticles, + aod::HfCandLbProngs const& candsLb) { int indexRec = -1; int8_t sign = 0; - int8_t flag = 0; + int8_t flagChannelMain = 0; + int8_t flagChannelReso = 0; int8_t origin = 0; int8_t debug = 0; - rowCandidateLb->bindExternalIndices(&tracks); - rowCandidateLb->bindExternalIndices(&lcCandidates); - // Match reconstructed candidates. - for (const auto& candidate : *rowCandidateLb) { - flag = 0; + for (const auto& candidate : candsLb) { + flagChannelMain = 0; + flagChannelReso = 0; origin = 0; debug = 0; auto lcCand = candidate.prong0(); @@ -287,28 +303,29 @@ struct HfCandidateCreatorLbExpressions { // Λb → Λc+ π- indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersLc, Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 1); if (indexRec > -1) { - flag = 1 << hf_cand_lb::DecayType::LbToLcPi; + flagChannelMain = sign * DecayChannelMain::LbToLcPi; } else { debug = 1; LOGF(info, "WARNING: Λb in decays in the expected final state but the condition on the intermediate state is not fulfilled"); } } - rowMcMatchRec(flag, origin, debug); + rowMcMatchRec(flagChannelMain, flagChannelReso, origin, debug); } // Match generated particles. for (const auto& particle : mcParticles) { - flag = 0; + flagChannelMain = 0; + flagChannelReso = 0; origin = 0; // Λb → Λc+ π- if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kLambdaB0, std::array{static_cast(Pdg::kLambdaCPlus), -kPiPlus}, true)) { // Λc+ → p K- π+ - auto LcCandMC = mcParticles.rawIteratorAt(particle.daughtersIds().front()); - if (RecoDecay::isMatchedMCGen(mcParticles, LcCandMC, static_cast(Pdg::kLambdaCPlus), std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign)) { - flag = sign * (1 << hf_cand_lb::DecayType::LbToLcPi); + auto candLcMc = mcParticles.rawIteratorAt(particle.daughtersIds().front()); + if (RecoDecay::isMatchedMCGen(mcParticles, candLcMc, static_cast(Pdg::kLambdaCPlus), std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign)) { + flagChannelMain = sign * DecayChannelMain::LbToLcPi; } } - rowMcMatchGen(flag, origin); + rowMcMatchGen(flagChannelMain, flagChannelReso, origin); } } PROCESS_SWITCH(HfCandidateCreatorLbExpressions, processMc, "Process MC", false); diff --git a/PWGHF/TableProducer/candidateCreatorMcGen.cxx b/PWGHF/TableProducer/candidateCreatorMcGen.cxx new file mode 100644 index 00000000000..1c923a5b6e3 --- /dev/null +++ b/PWGHF/TableProducer/candidateCreatorMcGen.cxx @@ -0,0 +1,79 @@ +// 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. + +/// \file candidateCreatorMcGen.cxx +/// \brief McGen only selection of heavy-flavour particles +/// +/// \author Nima Zardoshti, nima.zardoshti@cern.ch, CERN + +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsMcGen.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::constants::physics; + +/// Reconstruction of heavy-flavour 2-prong decay candidates +struct HfCandidateCreatorMcGen { + + Produces rowMcMatchGen2Prong; + Produces rowMcMatchGen3Prong; + Produces rowMcMatchGenBplus; + Produces rowMcMatchGenB0; + Configurable fill2Prong{"fill2Prong", false, "fill table for 2 prong candidates"}; + Configurable fill3Prong{"fill3Prong", false, "fill table for 3 prong candidates"}; + Configurable matchCorrelatedBackground{"matchCorrelatedBackground", false, "Match correlated background candidates"}; + Configurable> pdgMothersCorrelBkg{"pdgMothersCorrelBkg", {Pdg::kDPlus, Pdg::kDS, Pdg::kDStar, Pdg::kLambdaCPlus, Pdg::kXiCPlus}, "PDG codes of the mother particles of correlated background candidates"}; + Configurable fillBplus{"fillBplus", false, "fill table for for B+ candidates"}; + Configurable fillB0{"fillB0", false, "fill table for B0 candidates"}; + Configurable rejectBackground2Prong{"rejectBackground2Prong", false, "Reject particles from PbPb background for 2 prong candidates"}; + Configurable rejectBackground3Prong{"rejectBackground3Prong", false, "Reject particles from PbPb background for 3 prong candidates"}; + + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + + void process(aod::McCollisions const& mcCollisions, + aod::McParticles const& mcParticles) + { + + for (const auto& mcCollision : mcCollisions) { + const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); + if (fill2Prong) { + hf_mc_gen::fillMcMatchGen2Prong(mcParticles, mcParticlesPerMcColl, rowMcMatchGen2Prong, rejectBackground2Prong, matchCorrelatedBackground); + } + if (fill3Prong) { + hf_mc_gen::fillMcMatchGen3Prong(mcParticles, mcParticlesPerMcColl, rowMcMatchGen3Prong, rejectBackground3Prong, matchCorrelatedBackground ? pdgMothersCorrelBkg : std::vector{}); + } + } + if (fillBplus) { + hf_mc_gen::fillMcMatchGenBplus(mcParticles, rowMcMatchGenBplus); + } + if (fillB0) { + hf_mc_gen::fillMcMatchGenB0(mcParticles, rowMcMatchGenB0); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx b/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx index 509b74d1daa..9a59c28cf9c 100644 --- a/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx +++ b/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx @@ -15,26 +15,52 @@ /// /// \author Mattia Faggin , University and INFN PADOVA -#include "CCDB/BasicCCDBManager.h" // for dca recalculation -#include "CommonConstants/PhysicsConstants.h" -#include "DataFormatsParameters/GRPMagField.h" // for dca recalculation -#include "DataFormatsParameters/GRPObject.h" // for dca recalculation -#include "DetectorsBase/GeometryManager.h" // for dca recalculation -#include "DetectorsBase/Propagator.h" // for dca recalculation -#include "DetectorsVertexing/PVertexer.h" // for dca recalculation -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" -#include "Common/Core/TrackSelectionDefaults.h" - +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" // for dca recalculation +#include "PWGHF/Utils/utilsEvSelHf.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" + +#include // for dca recalculation +#include +#include +#include // for dca recalculation +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -51,7 +77,7 @@ struct HfCandidateCreatorSigmac0plusplus { Configurable selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc"}; Configurable yCandLcMax{"yCandLcMax", -1., "max. candLc. Lc rapidity"}; Configurable> binsPt{"binsPt", std::vector{hf_cuts_sigmac_to_p_k_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cutsMassLcMax{"cutsMassLcMax", {hf_cuts_sigmac_to_p_k_pi::cuts[0], hf_cuts_sigmac_to_p_k_pi::nBinsPt, hf_cuts_sigmac_to_p_k_pi::nCutVars, hf_cuts_sigmac_to_p_k_pi::labelsPt, hf_cuts_sigmac_to_p_k_pi::labelsCutVar}, "Lc candidate selection per pT bin"}; + Configurable> cutsMassLcMax{"cutsMassLcMax", {hf_cuts_sigmac_to_p_k_pi::Cuts[0], hf_cuts_sigmac_to_p_k_pi::NBinsPt, hf_cuts_sigmac_to_p_k_pi::NCutVars, hf_cuts_sigmac_to_p_k_pi::labelsPt, hf_cuts_sigmac_to_p_k_pi::labelsCutVar}, "Lc candidate selection per pT bin"}; /// Selections on candidate soft π-,+ Configurable applyGlobalTrkWoDcaCutsSoftPi{"applyGlobalTrkWoDcaCutsSoftPi", false, "Switch on the application of the global-track w/o dca cuts for soft pion BEFORE ALL OTHER CUSTOM CUTS"}; @@ -138,7 +164,8 @@ struct HfCandidateCreatorSigmac0plusplus { softPiCuts.SetMaxChi2PerClusterITS(softPiChi2Max); // ITS hitmap std::set setSoftPiItsHitMap; // = {}; - for (int idItsLayer = 0; idItsLayer < 7; idItsLayer++) { + constexpr std::size_t NLayersIts = 7; + for (std::size_t idItsLayer = 0u; idItsLayer < NLayersIts; idItsLayer++) { if (TESTBIT(softPiItsHitMap, idItsLayer)) { setSoftPiItsHitMap.insert(static_cast(idItsLayer)); } @@ -165,7 +192,7 @@ struct HfCandidateCreatorSigmac0plusplus { /// @param candidates are 3-prong candidates satisfying the analysis selections for Λc+ → pK-π+ (and charge conj.) /// @param tracks are the tracks (with dcaXY, dcaZ information) → soft-pion candidate tracks template - void makeSoftPiLcPair(TRK const& trackSoftPi, CAND const& candidatesThisColl, aod::TracksWDcaExtra const&) + void makeSoftPiLcPair(const std::array softPiDca, TRK const& trackSoftPi, CAND const& candidatesThisColl, aod::TracksWDcaExtra const&) { /// loop over Λc+ → pK-π+ (and charge conj.) candidates @@ -174,7 +201,7 @@ struct HfCandidateCreatorSigmac0plusplus { /// keep only the candidates flagged as possible Λc+ (and charge conj.) decaying into a charged pion, kaon and proton /// if not selected, skip it and go to the next one - if (!(candLc.hfflag() & 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { + if (!(candLc.hfflag() & BIT(aod::hf_cand_3prong::DecayType::LcToPKPi))) { continue; } /// keep only the candidates Λc+ (and charge conj.) within the desired rapidity @@ -230,7 +257,7 @@ struct HfCandidateCreatorSigmac0plusplus { int chargeLc = candLc.template prong0_as().sign() + candLc.template prong1_as().sign() + candLc.template prong2_as().sign(); int chargeSoftPi = trackSoftPi.sign(); int8_t chargeSigmac = chargeLc + chargeSoftPi; - if (std::abs(chargeSigmac) != 0 && std::abs(chargeSigmac) != 2) { + if (std::abs(chargeSigmac) != o2::aod::hf_cand_sigmac::ChargeNull && std::abs(chargeSigmac) != o2::aod::hf_cand_sigmac::ChargePlusPlus) { /// this shall never happen LOG(fatal) << ">>> Sc candidate with charge +1 built, not possible! Charge Lc: " << chargeLc << ", charge soft pion: " << chargeSoftPi; } @@ -246,9 +273,10 @@ struct HfCandidateCreatorSigmac0plusplus { candLc.hfflag(), /* Σc0,++ specific columns */ chargeSigmac, - statusSpreadMinvPKPiFromPDG, statusSpreadMinvPiKPFromPDG); + statusSpreadMinvPKPiFromPDG, statusSpreadMinvPiKPFromPDG, + softPiDca[0], softPiDca[1]); } /// end loop over Λc+ → pK-π+ (and charge conj.) candidates - } /// end makeSoftPiLcPair + } /// end makeSoftPiLcPair /// @brief function to loop over candidate soft pions and, for each of them, over candidate Λc+ for Σc0,++ → Λc+(→pK-π+) π- candidate reconstruction /// @param collision is a o2::aod::Collisions @@ -271,6 +299,7 @@ struct HfCandidateCreatorSigmac0plusplus { if (!softPiCuts.IsSelected(trackSoftPi)) { return; } + std::array softPiDca = {-999.f, -999.f}; if constexpr (withTimeAssoc) { /// dcaXY, dcaZ selections /// To be done separately from the others, because for reassigned tracks the dca must be recalculated @@ -278,28 +307,29 @@ struct HfCandidateCreatorSigmac0plusplus { if (trackSoftPi.collisionId() == thisCollId) { /// this is a track originally assigned to the current collision /// therefore, the dcaXY, dcaZ are those already calculated in the track-propagation workflow - if (std::abs(trackSoftPi.dcaXY()) > softPiDcaXYMax || std::abs(trackSoftPi.dcaZ()) > softPiDcaZMax) { - return; - } + softPiDca[0] = trackSoftPi.dcaXY(); + softPiDca[1] = trackSoftPi.dcaZ(); } else { /// this is a reassigned track /// therefore we need to calculate the dcaXY, dcaZ with respect to this new primary vertex auto bc = collision.bc_as(); initCCDB(bc, runNumber, ccdb, isRun2Ccdb ? ccdbPathGrp : ccdbPathGrpMag, lut, isRun2Ccdb); auto trackParSoftPi = getTrackPar(trackSoftPi); - o2::gpu::gpustd::array dcaInfo{-999., -999.}; + std::array dcaInfo{-999., -999.}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParSoftPi, 2.f, noMatCorr, &dcaInfo); - if (std::abs(dcaInfo[0]) > softPiDcaXYMax || std::abs(dcaInfo[1]) > softPiDcaZMax) { - return; - } + softPiDca[0] = dcaInfo[0]; + softPiDca[1] = dcaInfo[1]; } } else { /// this is a track originally assigned to the current collision /// therefore, the dcaXY, dcaZ are those already calculated in the track-propagation workflow /// No need to consider the time-reassociated tracks, since withTimeAssoc == false here - if (std::abs(trackSoftPi.dcaXY()) > softPiDcaXYMax || std::abs(trackSoftPi.dcaZ()) > softPiDcaZMax) { - return; - } + softPiDca[0] = trackSoftPi.dcaXY(); + softPiDca[1] = trackSoftPi.dcaZ(); + } + if (std::abs(softPiDca[0]) > softPiDcaXYMax || std::abs(softPiDca[1]) > softPiDcaZMax) { + /// soft-pion dca too large, reject the candidate + return; } histos.fill(HIST("hCounter"), 3); @@ -307,10 +337,10 @@ struct HfCandidateCreatorSigmac0plusplus { if constexpr (withTimeAssoc) { /// need to group candidates manually auto candidatesThisColl = candidates.sliceBy(hf3ProngPerCollision, thisCollId); - makeSoftPiLcPair(trackSoftPi, candidatesThisColl, tracks); + makeSoftPiLcPair(softPiDca, trackSoftPi, candidatesThisColl, tracks); } else { /// tracks and candidates already grouped by collision at the level of process function - makeSoftPiLcPair(trackSoftPi, candidates, tracks); + makeSoftPiLcPair(softPiDca, trackSoftPi, candidates, tracks); } } /// end createSigmaC @@ -383,28 +413,52 @@ struct HfCandidateSigmac0plusplusMc { Produces rowMCMatchScRec; Produces rowMCMatchScGen; + o2::hf_evsel::HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring + + using BCsInfo = soa::Join; using LambdacMc = soa::Join; - // using LambdacMcGen = soa::Join; + using McParticlesLcGenMatch = soa::Join; // including response of particle matching to MC from candidate-creator-3-prong + using McCollisionsNoCents = soa::Join; + + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; - float zPvPosMax{1000.f}; + HistogramRegistry registry{"registry"}; /// @brief init function void init(InitContext& initContext) { const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { - if (device.name.compare("hf-candidate-creator-3prong") == 0) { // here we assume that the hf-candidate-creator-3prong is in the workflow - for (const auto& option : device.options) { - if (option.name.compare("hfEvSel.zPvPosMax") == 0) { - zPvPosMax = option.defaultValue.get(); - break; - } - } + // here we assume that the hf-candidate-creator-3prong is in the workflow + // configure the ev. sel from that workflow + if (device.name.compare("hf-candidate-creator-3prong") == 0) { + // init HF event selection helper + hfEvSelMc.init(device, registry); break; } } } + // @brief function to check whether a matched Sigmac is particle or antiparticle + // @tparam particle the MC particle under study, matched with some Sigmac + // @param pdgSigmac the pdgcode to look for (either of Sigmac(2455), or of Sigmac(2520)) + template + int8_t isParticleAntiparticle(PART const& particle, int pdgSigmac) + { + + int pdgCode = particle.pdgCode(); + if (pdgCode == pdgSigmac) { + // particle + return aod::hf_cand_sigmac::Particle; + } else if (pdgCode == -pdgSigmac) { + // antiparticle + return aod::hf_cand_sigmac::Antiparticle; + } + + // the current particle is not a Sigmac of this species + return -1; + } + /// @brief dummy process function, to be run on data /// @param void process(aod::Tracks const&) {} @@ -412,10 +466,12 @@ struct HfCandidateSigmac0plusplusMc { /// @brief process function for MC matching of Σc0,++ → Λc+(→pK-π+) π- reconstructed candidates and counting of generated ones /// @param candidatesSigmac reconstructed Σc0,++ candidates /// @param mcParticles table of generated particles - void processMc(aod::McParticles const& mcParticles, + void processMc(McParticlesLcGenMatch const& mcParticles, aod::TracksWMc const& tracks, - LambdacMc const& candsLc /*, const LambdacMcGen&*/, - aod::McCollisions const&) + LambdacMc const& candsLc, + McCollisionsNoCents const& collInfos, + aod::McCollisions const&, + BCsInfo const&) { // Match reconstructed candidates. @@ -435,11 +491,12 @@ struct HfCandidateSigmac0plusplusMc { flag = 0; origin = 0; std::vector idxBhadMothers{}; + int8_t particleAntiparticle = -1; /// skip immediately the candidate Σc0,++ w/o a Λc+ matched to MC auto candLc = candSigmac.prongLc_as(); - if (!(std::abs(candLc.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { /// (*) - rowMCMatchScRec(flag, origin, -1.f, 0); + if (std::abs(candLc.flagMcMatchRec()) != hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { /// (*) + rowMCMatchScRec(flag, origin, -1.f, 0, -1); continue; } @@ -449,25 +506,58 @@ struct HfCandidateSigmac0plusplusMc { candLc.prong2_as(), candSigmac.prong1_as()}; chargeSigmac = candSigmac.charge(); - if (chargeSigmac == 0) { + if (chargeSigmac == o2::aod::hf_cand_sigmac::ChargeNull) { /// candidate Σc0 /// 3 levels: /// 1. Σc0 → Λc+ π-,+ /// 2. Λc+ → pK-π+ direct (i) or Λc+ → resonant channel Λc± → p± K*, Λc± → Δ(1232)±± K∓ or Λc± → Λ(1520) π± (ii) /// 3. in case of (ii): resonant channel to pK-π+ + + /// look for Σc0(2455) indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kSigmaC0, std::array{+kProton, -kKPlus, +kPiPlus, -kPiPlus}, true, &sign, 3); if (indexRec > -1) { /// due to (*) no need to check anything for LambdaC - flag = sign * (1 << aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi); + flag = sign * BIT(aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi); + } + auto particle = mcParticles.rawIteratorAt(indexRec); + particleAntiparticle = isParticleAntiparticle(particle, Pdg::kSigmaC0); + + /// look for Σc0(2520) + if (flag == 0) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kSigmaCStar0, std::array{+kProton, -kKPlus, +kPiPlus, -kPiPlus}, true, &sign, 3); + if (indexRec > -1) { /// due to (*) no need to check anything for LambdaC + flag = sign * BIT(aod::hf_cand_sigmac::DecayType::ScStar0ToPKPiPi); + } + if (particleAntiparticle < 0) { + auto particle = mcParticles.rawIteratorAt(indexRec); + particleAntiparticle = isParticleAntiparticle(particle, Pdg::kSigmaCStar0); + } } - } else if (std::abs(chargeSigmac) == 2) { + + } else if (std::abs(chargeSigmac) == o2::aod::hf_cand_sigmac::ChargePlusPlus) { /// candidate Σc++ /// 3 levels: /// 1. Σc0 → Λc+ π-,+ /// 2. Λc+ → pK-π+ direct (i) or Λc+ → resonant channel Λc± → p± K*, Λc± → Δ(1232)±± K∓ or Λc± → Λ(1520) π± (ii) /// 3. in case of (ii): resonant channel to pK-π+ + + /// look for Σc++(2455) indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kSigmaCPlusPlus, std::array{+kProton, -kKPlus, +kPiPlus, +kPiPlus}, true, &sign, 3); if (indexRec > -1) { /// due to (*) no need to check anything for LambdaC - flag = sign * (1 << aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi); + flag = sign * BIT(aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi); + } + auto particle = mcParticles.rawIteratorAt(indexRec); + particleAntiparticle = isParticleAntiparticle(particle, Pdg::kSigmaCPlusPlus); + + /// look for Σc++(2520) + if (flag == 0) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kSigmaCStarPlusPlus, std::array{+kProton, -kKPlus, +kPiPlus, +kPiPlus}, true, &sign, 3); + if (indexRec > -1) { /// due to (*) no need to check anything for LambdaC + flag = sign * BIT(aod::hf_cand_sigmac::DecayType::ScStarPlusPlusToPKPiPi); + } + if (particleAntiparticle < 0) { + auto particle = mcParticles.rawIteratorAt(indexRec); + particleAntiparticle = isParticleAntiparticle(particle, Pdg::kSigmaCStarPlusPlus); + } } } @@ -479,9 +569,9 @@ struct HfCandidateSigmac0plusplusMc { /// fill the table with results of reconstruction level MC matching if (origin == RecoDecay::OriginType::NonPrompt) { auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); - rowMCMatchScRec(flag, origin, bHadMother.pt(), bHadMother.pdgCode()); + rowMCMatchScRec(flag, origin, bHadMother.pt(), bHadMother.pdgCode(), particleAntiparticle); } else { - rowMCMatchScRec(flag, origin, -1.f, 0); + rowMCMatchScRec(flag, origin, -1.f, 0, particleAntiparticle); } } /// end loop over reconstructed Σc0,++ candidates @@ -490,11 +580,18 @@ struct HfCandidateSigmac0plusplusMc { flag = 0; origin = 0; std::vector idxBhadMothers{}; + int8_t particleAntiparticle = -1; + /// MC ev. selection done w/o centrality estimator + /// In case of need, readapt the code templetizing the function auto mcCollision = particle.mcCollision(); - float zPv = mcCollision.posZ(); - if (zPv < -zPvPosMax || zPv > zPvPosMax) { // to avoid counting particles in collisions with Zvtx larger than the maximum, we do not match them - rowMCMatchScGen(flag, origin, -1); + float centrality{-1.f}; + const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + hfEvSelMc.fillHistograms(mcCollision, rejectionMask, 0); + if (rejectionMask != 0) { + // at least one event selection not satisfied --> reject gen particles from this collision + rowMCMatchScGen(flag, origin, -1, -1); continue; } @@ -503,49 +600,85 @@ struct HfCandidateSigmac0plusplusMc { /// 2. Λc+ → pK-π+ direct (i) or Λc+ → resonant channel Λc± → p± K*, Λc± → Δ(1232)±± K∓ or Λc± → Λ(1520) π± (ii) /// 3. in case of (ii): resonant channel to pK-π+ /// → here we check level 1. first, and then levels 2. and 3. are inherited by the Λc+ → pK-π+ MC matching in candidateCreator3Prong.cxx + + /// look for Σc0,++(2455) if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kSigmaC0, std::array{static_cast(Pdg::kLambdaCPlus), static_cast(kPiMinus)}, true, &sign, 1)) { - // generated Σc0 - // for (const auto& daughter : particle.daughters_as()) { - for (const auto& daughter : particle.daughters_as()) { + // generated Σc0(2455) + for (const auto& daughter : particle.daughters_as()) { // look for Λc+ daughter decaying in pK-π+ if (std::abs(daughter.pdgCode()) != Pdg::kLambdaCPlus) continue; - // if (std::abs(daughter.flagMcMatchGen()) == (1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2)) { + if (std::abs(daughter.flagMcMatchGen()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { /// Λc+ daughter decaying in pK-π+ found! - flag = sign * (1 << aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi); + flag = sign * BIT(aod::hf_cand_sigmac::DecayType::Sc0ToPKPiPi); + particleAntiparticle = isParticleAntiparticle(particle, Pdg::kSigmaC0); break; } } } else if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kSigmaCPlusPlus, std::array{static_cast(Pdg::kLambdaCPlus), static_cast(kPiPlus)}, true, &sign, 1)) { - // generated Σc++ - // for (const auto& daughter : particle.daughters_as()) { - for (const auto& daughter : particle.daughters_as()) { + // generated Σc++(2455) + for (const auto& daughter : particle.daughters_as()) { // look for Λc+ daughter decaying in pK-π+ if (std::abs(daughter.pdgCode()) != Pdg::kLambdaCPlus) continue; - // if (std::abs(daughter.flagMcMatchGen()) == (1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2)) { + if (std::abs(daughter.flagMcMatchGen()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { /// Λc+ daughter decaying in pK-π+ found! - flag = sign * (1 << aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi); + flag = sign * BIT(aod::hf_cand_sigmac::DecayType::ScplusplusToPKPiPi); + particleAntiparticle = isParticleAntiparticle(particle, Pdg::kSigmaCPlusPlus); break; } } } + /// look for Σc0,++(2520) + if (flag == 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kSigmaCStar0, std::array{static_cast(Pdg::kLambdaCPlus), static_cast(kPiMinus)}, true, &sign, 1)) { + // generated Σc0(2520) + for (const auto& daughter : particle.daughters_as()) { + // look for Λc+ daughter decaying in pK-π+ + if (std::abs(daughter.pdgCode()) != Pdg::kLambdaCPlus) + continue; + if (std::abs(daughter.flagMcMatchGen()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + /// Λc+ daughter decaying in pK-π+ found! + flag = sign * BIT(aod::hf_cand_sigmac::DecayType::ScStar0ToPKPiPi); + particleAntiparticle = isParticleAntiparticle(particle, Pdg::kSigmaCStar0); + break; + } + } + } else if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kSigmaCStarPlusPlus, std::array{static_cast(Pdg::kLambdaCPlus), static_cast(kPiPlus)}, true, &sign, 1)) { + // generated Σc++(2520) + for (const auto& daughter : particle.daughters_as()) { + // look for Λc+ daughter decaying in pK-π+ + if (std::abs(daughter.pdgCode()) != Pdg::kLambdaCPlus) + continue; + if (std::abs(daughter.flagMcMatchGen()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + /// Λc+ daughter decaying in pK-π+ found! + flag = sign * BIT(aod::hf_cand_sigmac::DecayType::ScStarPlusPlusToPKPiPi); + particleAntiparticle = isParticleAntiparticle(particle, Pdg::kSigmaCStarPlusPlus); + break; + } + } + } + } + /// check the origin (prompt vs. non-prompt) if (flag != 0) { - auto particle = mcParticles.rawIteratorAt(indexRec); origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); } /// fill the table with results of generation level MC matching if (origin == RecoDecay::OriginType::NonPrompt) { - rowMCMatchScGen(flag, origin, idxBhadMothers[0]); + rowMCMatchScGen(flag, origin, idxBhadMothers[0], particleAntiparticle); } else { - rowMCMatchScGen(flag, origin, -1); + rowMCMatchScGen(flag, origin, -1, particleAntiparticle); } + + // debug + // if(origin != RecoDecay::OriginType::Prompt && origin != RecoDecay::OriginType::NonPrompt) { + // LOG(info) << " --> origin " << static_cast(origin) << ", flag " << static_cast(flag); + //} + } /// end loop over mcParticles - } /// end processMc + } /// end processMc PROCESS_SWITCH(HfCandidateSigmac0plusplusMc, processMc, "Process MC", false); }; diff --git a/PWGHF/TableProducer/candidateCreatorSigmac0plusplusCascade.cxx b/PWGHF/TableProducer/candidateCreatorSigmac0plusplusCascade.cxx index 3a953ba0ba1..71a61bec437 100644 --- a/PWGHF/TableProducer/candidateCreatorSigmac0plusplusCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorSigmac0plusplusCascade.cxx @@ -15,18 +15,27 @@ /// \author Rutuparna Rath , INFN BOLOGNA and GSI Darmstadt /// In collaboration with Andrea Alici , INFN BOLOGNA -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelectionDefaults.h" - #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::constants::physics; @@ -66,6 +75,8 @@ struct HfCandidateCreatorSigmac0plusplusCascade { Configurable softPiDcaZMax{"softPiDcaZMax", 0.065, "Soft pion max dcaZ (cm)"}; Configurable addQA{"addQA", true, "Switch for the qa PLOTS"}; + HfHelper hfHelper; + using TracksWithPID = soa::Join; /// Filter the candidate Λc+ used for the Σc0,++ creation @@ -76,7 +87,6 @@ struct HfCandidateCreatorSigmac0plusplusCascade { Preslice trackIndicesPerCollision = aod::track::collisionId; HistogramRegistry registry; - HfHelper hfHelper; void init(InitContext&) { @@ -288,9 +298,9 @@ struct HfCandidateCreatorSigmac0plusplusCascade { continue; } registry.fill(HIST("candidateStat"), 1); - auto K0short = candidateLc.v0_as(); // get the soft pions for the given collId - auto pos = K0short.template posTrack_as(); - auto neg = K0short.template negTrack_as(); + auto k0Short = candidateLc.v0_as(); // get the soft pions for the given collId + auto pos = k0Short.template posTrack_as(); + auto neg = k0Short.template negTrack_as(); for (const auto& trackSoftPi : tracksInThisCollision) { int chargeSoftPi = trackSoftPi.sign(); if (chargeSoftPi == pos.sign() && trackSoftPi.globalIndex() == pos.globalIndex()) { diff --git a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx index 8c1a0aadec1..9d7413d75d1 100644 --- a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx +++ b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx @@ -12,57 +12,68 @@ /// \file candidateCreatorXic0Omegac0.cxx /// \brief Reconstruction of Omegac0 and Xic0 decays candidates /// \author Federica Zanone , Heidelberg University +/// \author Ruiqi Yin , Fudan University /// \author Yunfan Liu , China University of Geosciences +/// \author Ran Tu , Fudan University +/// \author Tao Fang , Central China Normal University #ifndef HomogeneousField -#define HomogeneousField +#define HomogeneousField // o2-linter: disable=name/macro (required by KFParticle) #endif -#include -#include -#include -#include - -/// includes KFParticle -#include "KFParticle.h" -#include "KFParticleBase.h" -#include "KFPTrack.h" -#include "KFPVertex.h" -#include "KFVertex.h" - -#include "CCDB/BasicCCDBManager.h" -#include "CommonConstants/PhysicsConstants.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DCAFitter/DCAFitterN.h" -#include "DetectorsBase/Propagator.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/Track.h" -#include "ReconstructionDataFormats/V0.h" +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/mcCentrality.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Tools/KFparticle/KFUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" - -#include "PWGHF/Core/CentralityEstimation.h" -#include "PWGHF/Core/SelectorCuts.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsBfieldCCDB.h" -#include "PWGHF/Utils/utilsEvSelHf.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::track; -using namespace o2::analysis; using namespace o2::aod; using namespace o2::aod::cascdata; using namespace o2::aod::v0data; @@ -73,6 +84,13 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::hf_evsel; +enum McMatchFlag : uint8_t { + None = 0, + CharmbaryonUnmatched, + CascUnmatched, + V0Unmatched +}; + // Reconstruction of omegac0 and xic0 candidates struct HfCandidateCreatorXic0Omegac0 { Produces rowCandToXiPi; @@ -80,6 +98,8 @@ struct HfCandidateCreatorXic0Omegac0 { Produces rowCandToOmegaK; Produces kfCandidateData; Produces kfCandidateXicData; + Produces rowKfXic0Qa; + Produces kfCandidateOmegaKaData; Configurable propagateToPCA{"propagateToPCA", false, "create tracks version propagated to PCA"}; Configurable useAbsDCA{"useAbsDCA", true, "Minimise abs. distance rather than chi2"}; @@ -92,6 +112,11 @@ struct HfCandidateCreatorXic0Omegac0 { Configurable maxChi2{"maxChi2", 100., "discard vertices with chi2/Nprongs > this (or sum{DCAi^2}/Nprongs for abs. distance minimization)"}; Configurable refitWithMatCorr{"refitWithMatCorr", true, "when doing propagateTracksToVertex, propagate tracks to vtx with material corrections and rerun minimization"}; Configurable rejDiffCollTrack{"rejDiffCollTrack", true, "Reject tracks coming from different collisions"}; + Configurable fillAllHist{"fillAllHist", true, "Fill additional KF histograms to check selector cuts"}; + Configurable doCascadePreselection{"doCascadePreselection", true, "Use invariant mass and dcaXY cuts to preselect cascade candidates"}; + Configurable dcaXYToPVCascadeMax{"dcaXYToPVCascadeMax", 3.0, "Max cascade DCA to PV in xy plane"}; + Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 1.0, "Max DCA of V0 daughter"}; + Configurable dcaCascDaughtersMax{"dcaCascDaughtersMax", 1.0, "Max DCA of cascade daughter"}; // magnetic field setting from CCDB Configurable isRun2{"isRun2", false, "enable Run 2 or Run 3 GRP objects for magnetic field"}; @@ -105,10 +130,12 @@ struct HfCandidateCreatorXic0Omegac0 { Configurable lambdaMassWindow{"lambdaMassWindow", 0.0075, "Distance from Lambda mass"}; // cascade cuts Configurable massToleranceCascade{"massToleranceCascade", 0.01, "Invariant mass tolerance for cascade"}; + Configurable massToleranceCascadeRej{"massToleranceCascadeRej", 0.01, "Invariant mass tolerance for rejected Xi"}; // for KF particle operation Configurable kfConstructMethod{"kfConstructMethod", 2, "KF Construct Method"}; Configurable kfUseV0MassConstraint{"kfUseV0MassConstraint", false, "KF: use Lambda mass constraint"}; Configurable kfUseCascadeMassConstraint{"kfUseCascadeMassConstraint", false, "KF: use Cascade mass constraint"}; + Configurable kfResolutionQA{"kfResolutionQA", false, "KF: KFParticle Quality Assurance"}; HfEventSelection hfEvSel; // event selection and monitoring o2::vertexing::DCAFitterN<2> df; // 2-prong vertex fitter to build the omegac/xic vertex @@ -125,6 +152,7 @@ struct HfCandidateCreatorXic0Omegac0 { using MyV0Table = soa::Join; using MyLFTracksWCov = soa::Join; + using MyKfTracksIU = soa::Join; using MyKfTracks = soa::Join; using MyKfCascTable = soa::Join; using KFCascadesLinked = soa::Join; @@ -136,10 +164,10 @@ struct HfCandidateCreatorXic0Omegac0 { struct { float chi2GeoV0; float ldlV0; - float chi2TopoV0ToPv; + float chi2NdfTopoV0ToPv; float chi2GeoCasc; float ldlCasc; - float chi2TopoCascToPv; + float chi2NdfTopoCascToPv; float decayLenXYLambda; float decayLenXYCasc; float cosPaV0ToCasc; @@ -157,17 +185,18 @@ struct HfCandidateCreatorXic0Omegac0 { float rapOmegac; float massOmegac; float cosThetaStarPiFromOmegac; - float chi2TopoPiFromOmegacToPv; + float chi2NdfTopoPiFromOmegacToPv; + float deviationPiFromOmegacToPv; float kfDcaXYPiFromOmegac; - float chi2TopoV0ToCasc; - float chi2TopoCascToOmegac; + float chi2NdfTopoV0ToCasc; + float chi2NdfTopoCascToOmegac; float decayLenXYOmegac; float chi2GeoOmegac; float kfDcaV0Dau; float kfDcaCascDau; float kfDcaOmegacDau; float kfDcaXYCascToPv; - float chi2TopoOmegacToPv; + float chi2NdfTopoOmegacToPv; float cosPaOmegacToPv; float cosPaXYOmegacToPv; float ldlOmegac; @@ -177,15 +206,16 @@ struct HfCandidateCreatorXic0Omegac0 { float chi2MassV0; float chi2MassCasc; float etaOmegac; + float cascRejectInvmass; // rej } kfOmegac0Candidate; struct { float chi2GeoV0; float ldlV0; - float chi2TopoV0ToPv; + float chi2NdfTopoV0ToPv; float chi2GeoCasc; float ldlCasc; - float chi2TopoCascToPv; + float chi2NdfTopoCascToPv; float decayLenXYLambda; float decayLenXYCasc; float cosPaV0ToCasc; @@ -198,45 +228,43 @@ struct HfCandidateCreatorXic0Omegac0 { float cosPaXYCascToPv; float massV0; float massCasc; - float ptPiFromXic; - float ptXic; float rapXic; float massXic; float cosThetaStarPiFromXic; - float chi2TopoPiFromXicToPv; + float chi2NdfTopoPiFromXicToPv; float kfDcaXYPiFromXic; - float chi2TopoV0ToCasc; - float chi2TopoCascToXic; + float chi2NdfTopoV0ToCasc; + float chi2NdfTopoCascToXic; float decayLenXYXic; float chi2GeoXic; float kfDcaV0Dau; float kfDcaCascDau; float kfDcaXicDau; float kfDcaXYCascToPv; - float chi2TopoXicToPv; + float chi2NdfTopoXicToPv; float cosPaXicToPv; float cosPaXYXicToPv; float ldlXic; float ctV0; float ctCasc; float ctXic; - float ctOmegac; float chi2MassV0; float chi2MassCasc; float etaXic; } kfXic0Candidate; + void init(InitContext const&) { - std::array allProcesses = {doprocessNoCentToXiPi, doprocessNoCentToXiPiTraCasc, doprocessCentFT0CToXiPi, doprocessCentFT0MToXiPi, doprocessNoCentToOmegaPi, doprocessOmegacToOmegaPiWithKFParticle, doprocessCentFT0CToOmegaPi, doprocessCentFT0MToOmegaPi, doprocessNoCentToOmegaK, doprocessCentFT0CToOmegaK, doprocessCentFT0MToOmegaK, doprocessXicToXiPiWithKFParticle}; + std::array allProcesses = {doprocessNoCentToXiPi, doprocessNoCentToXiPiTraCasc, doprocessCentFT0CToXiPi, doprocessCentFT0MToXiPi, doprocessNoCentToOmegaPi, doprocessNoCentOmegacToOmegaPiWithKFParticle, doprocessCentFT0COmegacToOmegaPiWithKFParticle, doprocessCentFT0MOmegacToOmegaPiWithKFParticle, doprocessCentFT0CToOmegaPi, doprocessCentFT0MToOmegaPi, doprocessNoCentToOmegaK, doprocessCentFT0CToOmegaK, doprocessCentFT0MToOmegaK, doprocessNoCentXicToXiPiWithKFParticle, doprocessCentFT0CXicToXiPiWithKFParticle, doprocessCentFT0MXicToXiPiWithKFParticle}; if (std::accumulate(allProcesses.begin(), allProcesses.end(), 0) == 0) { LOGP(fatal, "No process function enabled, please select one for at least one channel."); } - std::array processesToXiPi = {doprocessNoCentToXiPi, doprocessNoCentToXiPiTraCasc, doprocessCentFT0CToXiPi, doprocessCentFT0MToXiPi, doprocessXicToXiPiWithKFParticle}; + std::array processesToXiPi = {doprocessNoCentToXiPi, doprocessNoCentToXiPiTraCasc, doprocessCentFT0CToXiPi, doprocessCentFT0MToXiPi, doprocessNoCentXicToXiPiWithKFParticle, doprocessCentFT0CXicToXiPiWithKFParticle, doprocessCentFT0MXicToXiPiWithKFParticle}; if (std::accumulate(processesToXiPi.begin(), processesToXiPi.end(), 0) > 1) { LOGP(fatal, "One and only one ToXiPi process function must be enabled at a time."); } - std::array processesToOmegaPi = {doprocessNoCentToOmegaPi, doprocessCentFT0CToOmegaPi, doprocessCentFT0MToOmegaPi, doprocessOmegacToOmegaPiWithKFParticle}; + std::array processesToOmegaPi = {doprocessNoCentToOmegaPi, doprocessCentFT0CToOmegaPi, doprocessCentFT0MToOmegaPi, doprocessNoCentOmegacToOmegaPiWithKFParticle, doprocessCentFT0COmegacToOmegaPiWithKFParticle, doprocessCentFT0MOmegacToOmegaPiWithKFParticle}; if (std::accumulate(processesToOmegaPi.begin(), processesToOmegaPi.end(), 0) > 1) { LOGP(fatal, "One and only one process ToOmegaPi function must be enabled at a time."); } @@ -251,7 +279,7 @@ struct HfCandidateCreatorXic0Omegac0 { LOGP(fatal, "At most one process function for collision monitoring can be enabled at a time."); } if (nProcessesCollisions == 1) { - if ((doprocessNoCentToXiPi && !doprocessCollisions) || (doprocessNoCentToXiPiTraCasc && !doprocessCollisions) || (doprocessNoCentToOmegaPi && !doprocessCollisions) || (doprocessNoCentToOmegaK && !doprocessCollisions) || (doprocessOmegacToOmegaPiWithKFParticle && !doprocessCollisions) || (doprocessXicToXiPiWithKFParticle && !doprocessCollisions)) { + if ((doprocessNoCentToXiPi && !doprocessCollisions) || (doprocessNoCentToXiPiTraCasc && !doprocessCollisions) || (doprocessNoCentToOmegaPi && !doprocessCollisions) || (doprocessNoCentToOmegaK && !doprocessCollisions) || (doprocessNoCentOmegacToOmegaPiWithKFParticle && !doprocessCollisions) || (doprocessNoCentXicToXiPiWithKFParticle && !doprocessCollisions)) { LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisions\"?"); } if ((doprocessCentFT0CToXiPi && !doprocessCollisionsCentFT0C) || (doprocessCentFT0CToOmegaPi && !doprocessCollisionsCentFT0C) || (doprocessCentFT0CToOmegaK && !doprocessCollisionsCentFT0C)) { @@ -275,13 +303,19 @@ struct HfCandidateCreatorXic0Omegac0 { hCascadesCounterToOmegaPi = registry.add("hCascadesCounterToOmegaPi", "Cascades counter wrt derived data - #Omega #pi decay;status;entries", {HistType::kTH1D, {{2, -0.5, 1.5}}}); // 0 --> cascades in derived data table (and stored in AOD table), 1 --> cascades in derived data table and also accessible in cascData table hCascadesCounterToOmegaK = registry.add("hCascadesCounterToOmegaK", "Cascades counter wrt derived data - #Omega K decay;status;entries", {HistType::kTH1D, {{2, -0.5, 1.5}}}); // 0 --> cascades in derived data table (and stored in AOD table), 1 --> cascades in derived data table and also accessible in cascData table - // KFparticle variables hist + // KFParticle Variables Histograms registry.add("hKFParticleV0TopoChi2", "hKFParticleV0TopoChi2", kTH1D, {{1000, -0.10f, 100.0f}}); registry.add("hKFParticleCascTopoChi2", "hKFParticleCascTopoChi2", kTH1D, {{1000, -0.1f, 100.0f}}); + registry.add("hKfChi2TopoPiFromCharmBaryon", "hKfChi2TopoPifromCharmBaryon", kTH1F, {{2000, -0.1f, 1000.0f}}); + registry.add("hKfNdfPiFromCharmBaryon", "hKfNDfPifromCharmBaryon", kTH1F, {{2000, -0.1f, 200.0f}}); + registry.add("hKfChi2OverNdfPiFromCharmBaryon", "hKfChi2OverNdfPifromCharmBaryon", kTH1F, {{1000, -0.1f, 200.0f}}); + registry.add("hKFParticlechi2TopoOmegacToPv", "hKFParticlechi2TopoOmegacToPv", kTH1D, {{1000, -0.1f, 100.0f}}); + registry.add("hKfNdfOmegacToPv", "hKfNDfOmegacToPv", kTH1F, {{2000, -0.1f, 200.0f}}); + registry.add("hKfChi2TopoOmegacToPv", "hKfChi2TopoOmegacToPv", kTH1F, {{1000, -0.1f, 200.0f}}); + registry.add("hKfDeviationPiFromCharmBaryon", "hKfDeviationPiFromCharmBaryon", kTH1F, {{1000, -0.1f, 200.0f}}); registry.add("hKFParticleCascBachTopoChi2", "hKFParticleCascBachTopoChi2", kTH1D, {{1000, -0.1f, 100.0f}}); - registry.add("hKFParticleDcaCharmBaryonDau", "hKFParticleDcaCharmBaryonDau", kTH1D, {{1000, -0.1f, 100.0f}}); - registry.add("hKFParticleDcaXYV0DauToPv", "hKFParticleDcaXYV0DauToPv", kTH1D, {{1000, -0.1f, 100.0f}}); - registry.add("hKFParticleDcaXYCascBachToPv", "hKFParticleDcaXYCascBachToPv", kTH1D, {{1000, -0.1f, 100.0f}}); + registry.add("hKFParticleDcaCharmBaryonDau", "hKFParticleDcaCharmBaryonDau", kTH1D, {{1000, -0.1f, 1.0f}}); + registry.add("hKFParticleDcaXYCascBachToPv", "hKFParticleDcaXYCascBachToPv", kTH1D, {{1000, -0.1f, 15.0f}}); registry.add("hKfLambda_ldl", "hKfLambda_ldl", kTH1D, {{1000, 0.0f, 1000.0f}}); registry.add("hKfOmega_ldl", "hKfOmega_ldl", kTH1D, {{1000, 0.0f, 1000.0f}}); registry.add("hKfXi_ldl", "hKfXi_ldl", kTH1D, {{1000, 0.0f, 1000.0f}}); @@ -290,8 +324,43 @@ struct HfCandidateCreatorXic0Omegac0 { registry.add("hDcaXYCascadeToPVKf", "hDcaXYCascadeToPVKf", kTH1D, {{1000, 0.0f, 2.0f}}); registry.add("hInvMassOmegaMinus", "hInvMassOmegaMinus", kTH1D, {{1000, 1.6f, 2.0f}}); registry.add("hInvMassXiMinus", "hInvMassXiMinus", kTH1D, {{1000, 1.25f, 1.65f}}); + registry.add("hInvMassXiMinus_rej", "hInvMassXiMinus_rej", kTH1D, {{1000, 1.25f, 1.65f}}); + registry.add("hKFParticlechi2TopoCascToPv", "hKFParticlechi2TopoCascToPv", kTH1D, {{1000, -0.1f, 100.0f}}); + registry.add("hKFParticleDcaXYV0DauPosToPv", "hKFParticleDcaXYV0DauPosToPv", kTH1D, {{1000, -0.1f, 30.0f}}); + registry.add("hKFParticleDcaXYV0DauNegToPv", "hKFParticleDcaXYV0DauNegToPv", kTH1D, {{1000, -0.1f, 30.0f}}); + + // Additional KFParticle Histograms + if (fillAllHist) { + registry.add("hEtaV0PosDau", "hEtaV0PosDau", kTH1D, {{1000, -5.0f, 5.0f}}); + registry.add("hEtaV0NegDau", "hEtaV0NegDau", kTH1D, {{1000, -5.0f, 5.0f}}); + registry.add("hEtaKaFromCasc", "hEtaKaFromCasc", kTH1D, {{1000, -5.0f, 5.0f}}); + registry.add("hEtaPiFromCharmBaryon", "hEtaPiFromCharmBaryon", kTH1D, {{1000, -5.0f, 5.0f}}); + registry.add("hCascradius", "hCascradius", kTH1D, {{1000, 0.0f, 50.0f}}); + registry.add("hV0radius", "hV0radius", kTH1D, {{1000, 0.0f, 50.0f}}); + registry.add("hCosPACasc", "hCosPACasc", kTH1D, {{5000, 0.8f, 1.1f}}); + registry.add("hCosPAV0", "hCosPAV0", kTH1D, {{5000, 0.8f, 1.1f}}); + registry.add("hDcaCascDau", "hDcaCascDau", kTH1D, {{1000, -0.1f, 10.0f}}); + registry.add("hDcaV0Dau", "hDcaV0Dau", kTH1D, {{1000, -0.1f, 10.0f}}); + registry.add("hDcaXYToPvKa", "hDcaXYToPvKa", kTH1D, {{1000, -0.1f, 10.0f}}); + registry.add("hImpactParBachFromCharmBaryonXY", "hImpactParBachFromCharmBaryonXY", kTH1D, {{1000, -1.0f, 1.0f}}); + registry.add("hImpactParBachFromCharmBaryonZ", "hImpactParBachFromCharmBaryonZ", kTH1D, {{1000, -2.0f, 2.0f}}); + registry.add("hImpactParCascXY", "hImpactParCascXY", kTH1D, {{1000, -4.0f, 4.0f}}); + registry.add("hImpactParCascZ", "hImpactParCascZ", kTH1D, {{1000, -5.0f, 5.0f}}); + registry.add("hPtKaFromCasc", "hPtKaFromCasc", kTH1D, {{1000, 0.0f, 5.0f}}); + registry.add("hPtPiFromCharmBaryon", "hPtPiFromCharmBaryon", kTH1D, {{1000, 0.0f, 5.0f}}); + registry.add("hCTauOmegac", "hCTauOmegac", kTH1D, {{1000, 0.0f, 0.1f}}); + registry.add("hKFGeoV0Chi2OverNdf", "hKFGeoV0Chi2OverNdf", kTH1D, {{1000, 0.0f, 100.0f}}); + registry.add("hKFGeoCascChi2OverNdf", "hKFGeoCascChi2OverNdf", kTH1D, {{1000, 0.0f, 100.0f}}); + registry.add("hKFGeoCharmbaryonChi2OverNdf", "hKFGeoCharmbaryonChi2OverNdf", kTH1D, {{1000, 0.0f, 100.0f}}); + registry.add("hKFdecayLenXYLambda", "hKFdecayLenXYLambda", kTH1D, {{1000, 0.0f, 50.0f}}); + registry.add("hKFdecayLenXYCasc", "hKFdecayLenXYCasc", kTH1D, {{1000, 0.0f, 50.0f}}); + registry.add("hKFdecayLenXYOmegac", "hKFdecayLenXYOmegac", kTH1D, {{1000, 0.0f, 50.0f}}); + registry.add("hKFcosPaV0ToCasc", "hKFcosPaV0ToCasc", kTH1D, {{5000, 0.8f, 1.1f}}); + registry.add("hKFcosPaCascToOmegac", "hKFcosPaCascToOmegac", kTH1D, {{5000, 0.8f, 1.1f}}); + } - hfEvSel.addHistograms(registry); // collision monitoring + // init HF event selection helper + hfEvSel.init(registry); df.setPropagateToPCA(propagateToPCA); df.setMaxR(maxR); @@ -425,8 +494,9 @@ struct HfCandidateCreatorXic0Omegac0 { std::array vertexCasc = {casc.x(), casc.y(), casc.z()}; std::array pVecCasc = {casc.px(), casc.py(), casc.pz()}; std::array covCasc = {0.}; - constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component - for (int i = 0; i < 6; i++) { + constexpr int NumCovElements = 6; + constexpr int MomInd[NumCovElements] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int i = 0; i < NumCovElements; i++) { covCasc[MomInd[i]] = casc.momentumCovMat()[i]; covCasc[i] = casc.positionCovMat()[i]; } @@ -631,7 +701,7 @@ struct HfCandidateCreatorXic0Omegac0 { dcaxyV0Dau0, dcaxyV0Dau1, dcaxyCascBachelor, dcazV0Dau0, dcazV0Dau1, dcazCascBachelor, dcaCascDau, dcaV0Dau, dcaCharmBaryonDau, - decLenCharmBaryon, decLenCascade, decLenV0, errorDecayLengthCharmBaryon, errorDecayLengthXYCharmBaryon); + decLenCharmBaryon, decLenCascade, decLenV0, errorDecayLengthCharmBaryon, errorDecayLengthXYCharmBaryon, cand.hfflag()); } else { rowCandToOmegaK( @@ -667,10 +737,11 @@ struct HfCandidateCreatorXic0Omegac0 { } // loop over LF Cascade-bachelor candidates } // end of run function - template + template void runKfOmegac0CreatorWithKFParticle(Coll const&, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/, - MyKfTracks const&, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, MyKfCascTable const&, KFCascadesLinked const&, aod::HfCascLf2Prongs const& candidates, Hist& hInvMassCharmBaryon, @@ -682,6 +753,12 @@ struct HfCandidateCreatorXic0Omegac0 { hCandidateCounter->Fill(1); auto collision = cand.collision_as(); + float centrality{-1.f}; + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the candidate + continue; + } // set the magnetic field from CCDB auto bc = collision.template bc_as(); @@ -695,8 +772,8 @@ struct HfCandidateCreatorXic0Omegac0 { df.setBz(magneticField); KFParticle::SetField(magneticField); // bachelor from Omegac0 - auto trackCharmBachelor = cand.prong0_as(); - + auto trackCharmBachelorId = cand.prong0Id(); + auto trackCharmBachelor = tracks.rawIteratorAt(trackCharmBachelorId); auto cascAodElement = cand.cascade_as(); hCascadesCounter->Fill(0); int v0index = cascAodElement.v0Id(); @@ -705,9 +782,12 @@ struct HfCandidateCreatorXic0Omegac0 { } auto casc = cascAodElement.kfCascData_as(); hCascadesCounter->Fill(1); - auto trackCascDauCharged = casc.bachelor_as(); // pion <- xi track - auto trackV0Dau0 = casc.posTrack_as(); // V0 positive daughter track - auto trackV0Dau1 = casc.negTrack_as(); // V0 negative daughter track + auto trackCascDauChargedId = casc.bachelorId(); + auto trackV0Dau0Id = casc.posTrackId(); + auto trackV0Dau1Id = casc.negTrackId(); + auto trackCascDauCharged = tracksIU.rawIteratorAt(trackCascDauChargedId); // pion <- xi track + auto trackV0Dau0 = tracksIU.rawIteratorAt(trackV0Dau0Id); // V0 positive daughter track + auto trackV0Dau1 = tracksIU.rawIteratorAt(trackV0Dau1Id); // V0 negative daughter track auto bachCharge = trackCascDauCharged.signed1Pt() > 0 ? +1 : -1; @@ -724,21 +804,26 @@ struct HfCandidateCreatorXic0Omegac0 { KFParticle kfPosPr(kfTrack0, kProton); KFParticle kfNegPi(kfTrack1, kPiMinus); KFParticle kfNegKa(kfTrackBach, kKMinus); + KFParticle kfNegPiRej(kfTrackBach, kPiMinus); // rej KFParticle kfPosPi(kfTrack0, kPiPlus); KFParticle kfNegPr(kfTrack1, kProton); KFParticle kfPosKa(kfTrackBach, kKPlus); + KFParticle kfPosPiRej(kfTrackBach, kPiPlus); // rej KFParticle kfBachKaon; KFParticle kfPos; KFParticle kfNeg; + KFParticle kfBachPionRej; // rej if (bachCharge < 0) { kfPos = kfPosPr; kfNeg = kfNegPi; kfBachKaon = kfNegKa; + kfBachPionRej = kfNegPiRej; // rej } else { kfPos = kfPosPi; kfNeg = kfNegPr; kfBachKaon = kfPosKa; + kfBachPionRej = kfPosPiRej; // rej } //__________________________________________ @@ -757,14 +842,11 @@ struct HfCandidateCreatorXic0Omegac0 { // mass window cut on lambda before mass constraint float massLam, sigLam; kfV0.GetMass(massLam, sigLam); - if (TMath::Abs(massLam - MassLambda0) > lambdaMassWindow) + if (std::abs(massLam - MassLambda0) > lambdaMassWindow) continue; // err_mass>0 of Lambda if (sigLam <= 0) continue; - // chi2>0 && NDF>0 for selecting Lambda - if ((kfV0.GetNDF() <= 0 || kfV0.GetChi2() <= 0)) - continue; kfOmegac0Candidate.chi2GeoV0 = kfV0.GetChi2(); KFParticle kfV0MassConstrained = kfV0; kfV0MassConstrained.SetNonlinearMassConstraint(o2::constants::physics::MassLambda); // set mass constrain to Lambda @@ -776,26 +858,32 @@ struct HfCandidateCreatorXic0Omegac0 { //__________________________________________ //*>~<* step 2 : reconstruct cascade(Omega) with KF const KFParticle* omegaDaugthers[2] = {&kfBachKaon, &kfV0}; + const KFParticle* omegaDaugthersRej[2] = {&kfBachPionRej, &kfV0}; // rej // construct cascade KFParticle kfOmega; + KFParticle kfOmegarej; // rej kfOmega.SetConstructMethod(kfConstructMethod); + kfOmegarej.SetConstructMethod(kfConstructMethod); // rej try { kfOmega.Construct(omegaDaugthers, 2); + kfOmegarej.Construct(omegaDaugthersRej, 2); // rej } catch (std::runtime_error& e) { - LOG(debug) << "Failed to construct Omega from V0 and bachelor track: " << e.what(); + LOG(debug) << "Failed to construct Omega or Omega_rej from V0 and bachelor track: " << e.what(); continue; } float massCasc, sigCasc; + float massCascrej, sigCascrej; kfOmega.GetMass(massCasc, sigCasc); + kfOmegarej.GetMass(massCascrej, sigCascrej); // rej // err_massOmega > 0 if (sigCasc <= 0) continue; if (std::abs(massCasc - MassOmegaMinus) > massToleranceCascade) continue; - // chi2>0 && NDF>0 - if (kfOmega.GetNDF() <= 0 || kfOmega.GetChi2() <= 0) - continue; + kfOmegac0Candidate.chi2GeoCasc = kfOmega.GetChi2(); + kfOmegac0Candidate.cascRejectInvmass = massCascrej; + registry.fill(HIST("hInvMassXiMinus_rej"), massCascrej); // rej KFParticle kfOmegaMassConstrained = kfOmega; kfOmegaMassConstrained.SetNonlinearMassConstraint(o2::constants::physics::MassOmegaMinus); // set mass constrain to OmegaMinus if (kfUseCascadeMassConstraint) { @@ -804,6 +892,7 @@ struct HfCandidateCreatorXic0Omegac0 { } registry.fill(HIST("hInvMassOmegaMinus"), massCasc); kfOmega.TransportToDecayVertex(); + // rej: Add competing rejection to minimize misidentified Xi impact. Reject if kfBachPionRej is Pion and the constructed cascade has Xi's invariant mass. //__________________________________________ //*>~<* step 3 : reconstruc Omegac0 with KF @@ -825,9 +914,7 @@ struct HfCandidateCreatorXic0Omegac0 { kfOmegaC0.GetMass(massOmegaC0, sigOmegaC0); if (sigOmegaC0 <= 0) continue; - // chi2>0 && NDF>0 - if (kfOmegaC0.GetNDF() <= 0 || kfOmegaC0.GetChi2() <= 0) - continue; + hFitterStatus->Fill(0); hCandidateCounter->Fill(2); kfOmegaC0.TransportToDecayVertex(); @@ -907,9 +994,9 @@ struct HfCandidateCreatorXic0Omegac0 { kfVertex.GetCovarianceMatrix(covMatrixPV); // impact parameters - gpu::gpustd::array impactParameterV0Dau0; - gpu::gpustd::array impactParameterV0Dau1; - gpu::gpustd::array impactParameterKaFromCasc; + std::array impactParameterV0Dau0; + std::array impactParameterV0Dau1; + std::array impactParameterKaFromCasc; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovV0Dau0, 2.f, matCorr, &impactParameterV0Dau0); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovV0Dau1, 2.f, matCorr, &impactParameterV0Dau1); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, omegaDauChargedTrackParCov, 2.f, matCorr, &impactParameterKaFromCasc); @@ -965,15 +1052,16 @@ struct HfCandidateCreatorXic0Omegac0 { auto cascNdfm = kfOmegaMassConstrained.GetNDF(); auto cascChi2OverNdfm = kfOmegac0Candidate.chi2MassCasc / cascNdfm; - // KF topo Chi2 - kfOmegac0Candidate.chi2TopoV0ToPv = kfV0ToPv.GetChi2(); - kfOmegac0Candidate.chi2TopoCascToPv = kfOmegaToPv.GetChi2(); - kfOmegac0Candidate.chi2TopoPiFromOmegacToPv = kfPiFromOmegacToPv.GetChi2(); - kfOmegac0Candidate.chi2TopoOmegacToPv = kfOmegac0ToPv.GetChi2(); + // KF topo Chi2 over NDF + kfOmegac0Candidate.chi2NdfTopoV0ToPv = kfV0ToPv.GetChi2() / kfV0ToPv.GetNDF(); + kfOmegac0Candidate.chi2NdfTopoCascToPv = kfOmegaToPv.GetChi2() / kfOmegaToPv.GetNDF(); + kfOmegac0Candidate.chi2NdfTopoPiFromOmegacToPv = kfPiFromOmegacToPv.GetChi2() / kfPiFromOmegacToPv.GetNDF(); + kfOmegac0Candidate.chi2NdfTopoOmegacToPv = kfOmegac0ToPv.GetChi2() / kfOmegac0ToPv.GetNDF(); + kfOmegac0Candidate.deviationPiFromOmegacToPv = kfCalculateChi2ToPrimaryVertex(kfOmegaC0, kfPV); - auto cascBachTopoChi2 = kfBachKaonToOmega.GetChi2(); - kfOmegac0Candidate.chi2TopoV0ToCasc = kfV0ToCasc.GetChi2(); - kfOmegac0Candidate.chi2TopoCascToOmegac = kfOmegaToOmegaC.GetChi2(); + auto cascBachTopoChi2Ndf = kfBachKaonToOmega.GetChi2() / kfBachKaonToOmega.GetNDF(); + kfOmegac0Candidate.chi2NdfTopoV0ToCasc = kfV0ToCasc.GetChi2() / kfV0ToCasc.GetNDF(); + kfOmegac0Candidate.chi2NdfTopoCascToOmegac = kfOmegaToOmegaC.GetChi2() / kfOmegaToOmegaC.GetNDF(); // KF ldl kfOmegac0Candidate.ldlV0 = ldlFromKF(kfV0, kfPV); @@ -1036,16 +1124,54 @@ struct HfCandidateCreatorXic0Omegac0 { kfOmegac0Candidate.etaOmegac = kfOmegaC0.GetEta(); // fill KF hist - registry.fill(HIST("hKFParticleCascBachTopoChi2"), cascBachTopoChi2); - registry.fill(HIST("hKFParticleV0TopoChi2"), kfOmegac0Candidate.chi2TopoV0ToCasc); - registry.fill(HIST("hKFParticleCascTopoChi2"), kfOmegac0Candidate.chi2TopoCascToOmegac); + registry.fill(HIST("hKFParticleCascBachTopoChi2"), cascBachTopoChi2Ndf); + registry.fill(HIST("hKFParticleV0TopoChi2"), kfOmegac0Candidate.chi2NdfTopoV0ToCasc); + registry.fill(HIST("hKFParticleCascTopoChi2"), kfOmegac0Candidate.chi2NdfTopoCascToOmegac); + registry.fill(HIST("hKFParticlechi2TopoOmegacToPv"), kfOmegac0Candidate.chi2NdfTopoOmegacToPv); + registry.fill(HIST("hKfChi2TopoOmegacToPv"), kfOmegac0ToPv.GetChi2()); + registry.fill(HIST("hKfNdfOmegacToPv"), kfOmegac0ToPv.GetNDF()); + registry.fill(HIST("hKFParticlechi2TopoCascToPv"), kfOmegac0Candidate.chi2NdfTopoCascToPv); registry.fill(HIST("hKFParticleDcaCharmBaryonDau"), kfOmegac0Candidate.kfDcaOmegacDau); registry.fill(HIST("hKFParticleDcaXYCascBachToPv"), dcaxyCascBachelor); - registry.fill(HIST("hKFParticleDcaXYV0DauToPv"), dcaxyV0Dau0); + registry.fill(HIST("hKFParticleDcaXYV0DauPosToPv"), dcaxyV0Dau0); + registry.fill(HIST("hKFParticleDcaXYV0DauNegToPv"), dcaxyV0Dau1); registry.fill(HIST("hKfLambda_ldl"), kfOmegac0Candidate.ldlV0); registry.fill(HIST("hKfOmega_ldl"), kfOmegac0Candidate.ldlCasc); registry.fill(HIST("hKfOmegaC0_ldl"), kfOmegac0Candidate.ldlOmegac); registry.fill(HIST("hDcaXYCascadeToPVKf"), kfOmegac0Candidate.kfDcaXYCascToPv); + registry.fill(HIST("hKfChi2TopoPiFromCharmBaryon"), kfPiFromOmegacToPv.GetChi2()); + registry.fill(HIST("hKfNdfPiFromCharmBaryon"), kfPiFromOmegacToPv.GetNDF()); + registry.fill(HIST("hKfChi2OverNdfPiFromCharmBaryon"), kfOmegac0Candidate.chi2NdfTopoPiFromOmegacToPv); + registry.fill(HIST("hKfDeviationPiFromCharmBaryon"), kfOmegac0Candidate.deviationPiFromOmegacToPv); + // Additional histograms + if (fillAllHist) { + registry.fill(HIST("hEtaV0PosDau"), kfPos.GetEta()); + registry.fill(HIST("hEtaV0NegDau"), kfNeg.GetEta()); + registry.fill(HIST("hEtaKaFromCasc"), kfBachKaonToOmega.GetEta()); + registry.fill(HIST("hEtaPiFromCharmBaryon"), kfBachPionToOmegaC.GetEta()); + registry.fill(HIST("hCascradius"), RecoDecay::sqrtSumOfSquares(vertexCasc[0], vertexCasc[1])); + registry.fill(HIST("hV0radius"), RecoDecay::sqrtSumOfSquares(vertexV0[0], vertexV0[1])); + registry.fill(HIST("hCosPACasc"), kfOmegac0Candidate.cosPaCascToPv); + registry.fill(HIST("hCosPAV0"), kfOmegac0Candidate.cosPaV0ToPv); + registry.fill(HIST("hDcaCascDau"), kfOmegac0Candidate.kfDcaCascDau); + registry.fill(HIST("hDcaV0Dau"), kfOmegac0Candidate.kfDcaV0Dau); + registry.fill(HIST("hDcaXYToPvKa"), dcaxyCascBachelor); + registry.fill(HIST("hImpactParBachFromCharmBaryonXY"), impactParBachFromCharmBaryonXY); + registry.fill(HIST("hImpactParBachFromCharmBaryonZ"), impactParBachFromCharmBaryonZ); + registry.fill(HIST("hImpactParCascXY"), impactParameterCasc.getY()); + registry.fill(HIST("hImpactParCascZ"), impactParameterCasc.getZ()); + registry.fill(HIST("hPtKaFromCasc"), RecoDecay::sqrtSumOfSquares(pVecCascBachelor[0], pVecCascBachelor[1])); + registry.fill(HIST("hPtPiFromCharmBaryon"), RecoDecay::sqrtSumOfSquares(pVecCharmBachelorAsD[0], pVecCharmBachelorAsD[1])); + registry.fill(HIST("hCTauOmegac"), kfOmegac0Candidate.ctOmegac); + registry.fill(HIST("hKFGeoV0Chi2OverNdf"), v0Chi2OverNdf); + registry.fill(HIST("hKFGeoCascChi2OverNdf"), cascChi2OverNdf); + registry.fill(HIST("hKFGeoCharmbaryonChi2OverNdf"), charmbaryonChi2OverNdf); + registry.fill(HIST("hKFdecayLenXYLambda"), kfOmegac0Candidate.decayLenXYLambda); + registry.fill(HIST("hKFdecayLenXYCasc"), kfOmegac0Candidate.decayLenXYCasc); + registry.fill(HIST("hKFdecayLenXYOmegac"), kfOmegac0Candidate.decayLenXYOmegac); + registry.fill(HIST("hKFcosPaV0ToCasc"), kfOmegac0Candidate.cosPaV0ToCasc); + registry.fill(HIST("hKFcosPaCascToOmegac"), kfOmegac0Candidate.cosPaCascToOmegac); + } // fill the table rowCandToOmegaPi(collision.globalIndex(), @@ -1075,27 +1201,28 @@ struct HfCandidateCreatorXic0Omegac0 { dcaxyV0Dau0, dcaxyV0Dau1, dcaxyCascBachelor, dcazV0Dau0, dcazV0Dau1, dcazCascBachelor, kfOmegac0Candidate.kfDcaCascDau, kfOmegac0Candidate.kfDcaV0Dau, kfOmegac0Candidate.kfDcaOmegacDau, - decLenCharmBaryon, decLenCascade, decLenV0, errorDecayLengthCharmBaryon, errorDecayLengthXYCharmBaryon); + decLenCharmBaryon, decLenCascade, decLenV0, errorDecayLengthCharmBaryon, errorDecayLengthXYCharmBaryon, cand.hfflag()); // fill kf table kfCandidateData(kfOmegac0Candidate.kfDcaXYPiFromOmegac, kfOmegac0Candidate.kfDcaXYCascToPv, kfOmegac0Candidate.chi2GeoV0, kfOmegac0Candidate.chi2GeoCasc, kfOmegac0Candidate.chi2GeoOmegac, kfOmegac0Candidate.chi2MassV0, kfOmegac0Candidate.chi2MassCasc, kfOmegac0Candidate.ldlV0, kfOmegac0Candidate.ldlCasc, kfOmegac0Candidate.ldlOmegac, - kfOmegac0Candidate.chi2TopoV0ToPv, kfOmegac0Candidate.chi2TopoCascToPv, kfOmegac0Candidate.chi2TopoPiFromOmegacToPv, kfOmegac0Candidate.chi2TopoOmegacToPv, - kfOmegac0Candidate.chi2TopoV0ToCasc, kfOmegac0Candidate.chi2TopoCascToOmegac, + kfOmegac0Candidate.chi2NdfTopoV0ToPv, kfOmegac0Candidate.chi2NdfTopoCascToPv, kfOmegac0Candidate.chi2NdfTopoPiFromOmegacToPv, kfOmegac0Candidate.chi2NdfTopoOmegacToPv, kfOmegac0Candidate.deviationPiFromOmegacToPv, + kfOmegac0Candidate.chi2NdfTopoV0ToCasc, kfOmegac0Candidate.chi2NdfTopoCascToOmegac, kfOmegac0Candidate.decayLenXYLambda, kfOmegac0Candidate.decayLenXYCasc, kfOmegac0Candidate.decayLenXYOmegac, kfOmegac0Candidate.cosPaV0ToCasc, kfOmegac0Candidate.cosPaCascToOmegac, kfOmegac0Candidate.cosPaXYV0ToCasc, kfOmegac0Candidate.cosPaXYCascToOmegac, kfOmegac0Candidate.rapOmegac, kfOmegac0Candidate.ptPiFromOmegac, kfOmegac0Candidate.ptOmegac, kfOmegac0Candidate.cosThetaStarPiFromOmegac, v0NDF, cascNDF, charmbaryonNDF, v0Ndfm, cascNdfm, - v0Chi2OverNdf, cascChi2OverNdf, charmbaryonChi2OverNdf, v0Chi2OverNdfm, cascChi2OverNdfm); + v0Chi2OverNdf, cascChi2OverNdf, charmbaryonChi2OverNdf, v0Chi2OverNdfm, cascChi2OverNdfm, kfOmegac0Candidate.cascRejectInvmass); } // loop over LF Cascade-bachelor candidates } // end of run function //========================================================== - template + template void runKfXic0CreatorWithKFParticle(Coll const&, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/, - MyKfTracks const&, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, MyKfCascTable const&, KFCascadesLinked const&, aod::HfCascLf2Prongs const& candidates, Hist& hInvMassCharmBaryon, @@ -1105,9 +1232,18 @@ struct HfCandidateCreatorXic0Omegac0 { { for (const auto& cand : candidates) { hCandidateCounter->Fill(1); - + if (!TESTBIT(cand.hfflag(), aod::hf_cand_casc_lf::DecayType2Prong::XiczeroOmegaczeroToXiPi)) { + continue; + } auto collision = cand.collision_as(); + float centrality{-1.f}; + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the candidate + continue; + } + // set the magnetic field from CCDB auto bc = collision.template bc_as(); if (runNumber != bc.runNumber()) { @@ -1120,8 +1256,8 @@ struct HfCandidateCreatorXic0Omegac0 { df.setBz(magneticField); KFParticle::SetField(magneticField); // bachelor from Xic0 - auto trackCharmBachelor = cand.prong0_as(); - + auto trackCharmBachelorId = cand.prong0Id(); + auto trackCharmBachelor = tracks.rawIteratorAt(trackCharmBachelorId); auto cascAodElement = cand.cascade_as(); hCascadesCounter->Fill(0); int v0index = cascAodElement.v0Id(); @@ -1130,9 +1266,12 @@ struct HfCandidateCreatorXic0Omegac0 { } auto casc = cascAodElement.kfCascData_as(); hCascadesCounter->Fill(1); - auto trackCascDauCharged = casc.bachelor_as(); // pion <- xi track - auto trackV0Dau0 = casc.posTrack_as(); // V0 positive daughter track - auto trackV0Dau1 = casc.negTrack_as(); // V0 negative daughter track + auto trackCascDauChargedId = casc.bachelorId(); + auto trackV0Dau0Id = casc.posTrackId(); + auto trackV0Dau1Id = casc.negTrackId(); + auto trackCascDauCharged = tracksIU.rawIteratorAt(trackCascDauChargedId); // pion <- xi track + auto trackV0Dau0 = tracksIU.rawIteratorAt(trackV0Dau0Id); // V0 positive daughter track + auto trackV0Dau1 = tracksIU.rawIteratorAt(trackV0Dau1Id); // V0 negative daughter track auto bachCharge = trackCascDauCharged.signed1Pt() > 0 ? +1 : -1; @@ -1183,7 +1322,7 @@ struct HfCandidateCreatorXic0Omegac0 { // mass window cut on lambda before mass constraint float massLam, sigLam; kfV0.GetMass(massLam, sigLam); - if (TMath::Abs(massLam - MassLambda0) > lambdaMassWindow) + if (std::abs(massLam - MassLambda0) > lambdaMassWindow) continue; // err_mass>0 of Lambda @@ -1197,7 +1336,7 @@ struct HfCandidateCreatorXic0Omegac0 { KFParticle kfV0MassConstrained = kfV0; kfV0MassConstrained.SetNonlinearMassConstraint(o2::constants::physics::MassLambda); // set mass constrain to Lambda if (kfUseV0MassConstraint) { - KFParticle kfV0 = kfV0MassConstrained; + kfV0 = kfV0MassConstrained; } kfV0.TransportToDecayVertex(); @@ -1266,6 +1405,8 @@ struct HfCandidateCreatorXic0Omegac0 { KFPVertex kfVertex = createKFPVertexFromCollision(collision); KFParticle kfPV(kfVertex); + KFParticle kfPosOrigin = kfPos; + KFParticle kfNegOrigin = kfNeg; // set production vertex; kfNeg.SetProductionVertex(kfV0); kfPos.SetProductionVertex(kfV0); @@ -1323,55 +1464,31 @@ struct HfCandidateCreatorXic0Omegac0 { std::array vertexCasc = {kfXi.GetX(), kfXi.GetY(), kfXi.GetZ()}; std::array pVecCascBachelor = {kfBachPionToXi.GetPx(), kfBachPionToXi.GetPy(), kfBachPionToXi.GetPz()}; - auto primaryVertex = getPrimaryVertex(collision); std::array pvCoord = {collision.posX(), collision.posY(), collision.posZ()}; - std::array vertexCharmBaryonFromFitter = {0.0, 0.0, 0.0}; // This variable get from DCAfitter in default process, in KF process it is set as 0. std::array pVecCharmBachelorAsD; pVecCharmBachelorAsD[0] = kfCharmBachPionToXiC.GetPx(); pVecCharmBachelorAsD[1] = kfCharmBachPionToXiC.GetPy(); pVecCharmBachelorAsD[2] = kfCharmBachPionToXiC.GetPz(); std::array pVecCharmBaryon = {kfXiC0.GetPx(), kfXiC0.GetPy(), kfXiC0.GetPz()}; - std::array coordVtxCharmBaryon = {kfXiC0.GetX(), kfXiC0.GetY(), kfXiC0.GetZ()}; auto covVtxCharmBaryon = kfXiC0.CovarianceMatrix(); float covMatrixPV[6]; kfVertex.GetCovarianceMatrix(covMatrixPV); // impact parameters - gpu::gpustd::array impactParameterV0Dau0; - gpu::gpustd::array impactParameterV0Dau1; - gpu::gpustd::array impactParameterKaFromCasc; + std::array impactParameterV0Dau0; + std::array impactParameterV0Dau1; + std::array impactParameterPiFromCasc; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovV0Dau0, 2.f, matCorr, &impactParameterV0Dau0); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCovV0Dau1, 2.f, matCorr, &impactParameterV0Dau1); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, xiDauChargedTrackParCov, 2.f, matCorr, &impactParameterKaFromCasc); + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, xiDauChargedTrackParCov, 2.f, matCorr, &impactParameterPiFromCasc); float dcaxyV0Dau0 = impactParameterV0Dau0[0]; float dcaxyV0Dau1 = impactParameterV0Dau1[0]; - float dcaxyCascBachelor = impactParameterKaFromCasc[0]; - float dcazV0Dau0 = impactParameterV0Dau0[1]; - float dcazV0Dau1 = impactParameterV0Dau1[1]; - float dcazCascBachelor = impactParameterKaFromCasc[1]; + float dcaxyCascBachelor = impactParameterPiFromCasc[0]; // pseudorapidity float pseudorapCharmBachelor = kfCharmBachPionToXiC.GetEta(); - // impact parameters - o2::dataformats::DCA impactParameterCasc; - o2::dataformats::DCA impactParameterCharmBachelor; - o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVertex, trackCasc, 2.f, matCorr, &impactParameterCasc); - o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVertex, trackParVarCharmBachelor, 2.f, matCorr, &impactParameterCharmBachelor); - float impactParBachFromCharmBaryonXY = impactParameterCharmBachelor.getY(); - float impactParBachFromCharmBaryonZ = impactParameterCharmBachelor.getZ(); - - // computing decay length and ctau - float decLenCharmBaryon = RecoDecay::distance(pvCoord, coordVtxCharmBaryon); - float decLenCascade = RecoDecay::distance(coordVtxCharmBaryon, vertexCasc); - float decLenV0 = RecoDecay::distance(vertexCasc, vertexV0); - - double phiCharmBaryon, thetaCharmBaryon; - getPointDirection(std::array{kfV0.GetX(), kfV0.GetY(), kfV0.GetZ()}, coordVtxCharmBaryon, phiCharmBaryon, thetaCharmBaryon); - auto errorDecayLengthCharmBaryon = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phiCharmBaryon, thetaCharmBaryon) + getRotatedCovMatrixXX(covVtxCharmBaryon, phiCharmBaryon, thetaCharmBaryon)); - auto errorDecayLengthXYCharmBaryon = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phiCharmBaryon, 0.) + getRotatedCovMatrixXX(covVtxCharmBaryon, phiCharmBaryon, 0.)); - // fill test histograms hInvMassCharmBaryon->Fill(massXiC0); hCandidateCounter->Fill(3); @@ -1397,14 +1514,14 @@ struct HfCandidateCreatorXic0Omegac0 { auto cascChi2OverNdfm = kfXic0Candidate.chi2MassCasc / cascNdfm; // KF topo Chi2 - kfXic0Candidate.chi2TopoV0ToPv = kfV0ToPv.GetChi2(); - kfXic0Candidate.chi2TopoCascToPv = kfXiToPv.GetChi2(); - kfXic0Candidate.chi2TopoPiFromXicToPv = kfPiFromXicToPv.GetChi2(); - kfXic0Candidate.chi2TopoXicToPv = kfXic0ToPv.GetChi2(); + kfXic0Candidate.chi2NdfTopoV0ToPv = kfV0ToPv.GetChi2() / kfV0ToPv.GetNDF(); + kfXic0Candidate.chi2NdfTopoCascToPv = kfXiToPv.GetChi2() / kfXiToPv.GetNDF(); + kfXic0Candidate.chi2NdfTopoPiFromXicToPv = kfPiFromXicToPv.GetChi2() / kfPiFromXicToPv.GetNDF(); + kfXic0Candidate.chi2NdfTopoXicToPv = kfXic0ToPv.GetChi2() / kfXic0ToPv.GetNDF(); auto cascBachTopoChi2 = kfBachPionToXi.GetChi2(); - kfXic0Candidate.chi2TopoV0ToCasc = kfV0ToCasc.GetChi2(); - kfXic0Candidate.chi2TopoCascToXic = kfXiToXiC.GetChi2(); + kfXic0Candidate.chi2NdfTopoV0ToCasc = kfV0ToCasc.GetChi2() / kfV0ToCasc.GetNDF(); + kfXic0Candidate.chi2NdfTopoCascToXic = kfXiToXiC.GetChi2() / kfXiToXiC.GetNDF(); // KF ldl kfXic0Candidate.ldlV0 = ldlFromKF(kfV0, kfPV); @@ -1448,41 +1565,26 @@ struct HfCandidateCreatorXic0Omegac0 { kfXic0Candidate.massCasc = massCasc; kfXic0Candidate.massXic = massXiC0; - // KF pT - kfXic0Candidate.ptPiFromXic = kfCharmBachPionToXiC.GetPt(); - kfXic0Candidate.ptXic = kfXiC0.GetPt(); - // KF rapidity kfXic0Candidate.rapXic = kfXiC0.GetRapidity(); // KF cosThetaStar - kfXic0Candidate.cosThetaStarPiFromXic = cosThetaStarFromKF(0, 4332, 211, 3312, kfCharmBachPionToXiC, kfXiToXiC); + kfXic0Candidate.cosThetaStarPiFromXic = cosThetaStarFromKF(0, 4132, 211, 3312, kfCharmBachPionToXiC, kfXiToXiC); // KF ct - kfXic0Candidate.ctV0 = kfV0.GetLifeTime(); - kfXic0Candidate.ctCasc = kfXi.GetLifeTime(); - kfXic0Candidate.ctXic = kfXiC0.GetLifeTime(); - kfXic0Candidate.ctOmegac = kfXiC0.GetLifeTime(); - + kfXic0Candidate.ctV0 = kfV0ToCasc.GetLifeTime(); + kfXic0Candidate.ctCasc = kfXiToXiC.GetLifeTime(); + kfXic0Candidate.ctXic = kfXic0ToPv.GetLifeTime(); // KF eta kfXic0Candidate.etaXic = kfXiC0.GetEta(); // fill KF hist registry.fill(HIST("hKFParticleCascBachTopoChi2"), cascBachTopoChi2); - registry.fill(HIST("hKFParticleV0TopoChi2"), kfXic0Candidate.chi2TopoV0ToCasc); - registry.fill(HIST("hKFParticleCascTopoChi2"), kfXic0Candidate.chi2TopoCascToXic); - registry.fill(HIST("hKFParticleDcaCharmBaryonDau"), kfXic0Candidate.kfDcaXicDau); - registry.fill(HIST("hKFParticleDcaXYCascBachToPv"), dcaxyCascBachelor); - registry.fill(HIST("hKFParticleDcaXYV0DauToPv"), dcaxyV0Dau0); - registry.fill(HIST("hKfLambda_ldl"), kfXic0Candidate.ldlV0); - registry.fill(HIST("hKfXi_ldl"), kfXic0Candidate.ldlCasc); registry.fill(HIST("hKfXiC0_ldl"), kfXic0Candidate.ldlXic); - registry.fill(HIST("hDcaXYCascadeToPVKf"), kfXic0Candidate.kfDcaXYCascToPv); // fill kf table kfCandidateXicData(collision.globalIndex(), pvCoord[0], pvCoord[1], pvCoord[2], - vertexCharmBaryonFromFitter[0], vertexCharmBaryonFromFitter[1], vertexCharmBaryonFromFitter[2], vertexCasc[0], vertexCasc[1], vertexCasc[2], vertexV0[0], vertexV0[1], vertexV0[2], trackCascDauCharged.sign(), @@ -1494,34 +1596,374 @@ struct HfCandidateCreatorXic0Omegac0 { pVecCascBachelor[0], pVecCascBachelor[1], pVecCascBachelor[2], pVecV0Dau0[0], pVecV0Dau0[1], pVecV0Dau0[2], pVecV0Dau1[0], pVecV0Dau1[1], pVecV0Dau1[2], - impactParameterCasc.getY(), impactParBachFromCharmBaryonXY, - impactParameterCasc.getZ(), impactParBachFromCharmBaryonZ, - std::sqrt(impactParameterCasc.getSigmaY2()), std::sqrt(impactParameterCharmBachelor.getSigmaY2()), v0index, casc.posTrackId(), casc.negTrackId(), casc.cascadeId(), trackCharmBachelor.globalIndex(), casc.bachelorId(), kfXic0Candidate.massV0, kfXic0Candidate.massCasc, kfXic0Candidate.massXic, - kfXic0Candidate.cosPaV0ToPv, kfXic0Candidate.cosPaXicToPv, kfXic0Candidate.cosPaCascToPv, kfXic0Candidate.cosPaXYV0ToPv, kfXic0Candidate.cosPaXYXicToPv, kfXic0Candidate.cosPaXYCascToPv, - kfXic0Candidate.ctOmegac, kfXic0Candidate.ctCasc, kfXic0Candidate.ctV0, kfXic0Candidate.ctXic, + kfXic0Candidate.cosPaV0ToPv, kfXic0Candidate.cosPaCascToPv, + kfXic0Candidate.ctCasc, kfXic0Candidate.ctV0, kfXic0Candidate.ctXic, pseudorapV0Dau0, pseudorapV0Dau1, pseudorapCascBachelor, pseudorapCharmBachelor, kfXic0Candidate.etaXic, kfXi.GetEta(), kfV0.GetEta(), dcaxyV0Dau0, dcaxyV0Dau1, dcaxyCascBachelor, - dcazV0Dau0, dcazV0Dau1, dcazCascBachelor, kfXic0Candidate.kfDcaCascDau, kfXic0Candidate.kfDcaV0Dau, kfXic0Candidate.kfDcaXicDau, - decLenCharmBaryon, decLenCascade, decLenV0, errorDecayLengthCharmBaryon, errorDecayLengthXYCharmBaryon, kfXic0Candidate.kfDcaXYPiFromXic, kfXic0Candidate.kfDcaXYCascToPv, kfXic0Candidate.chi2GeoV0, kfXic0Candidate.chi2GeoCasc, kfXic0Candidate.chi2GeoXic, kfXic0Candidate.chi2MassV0, kfXic0Candidate.chi2MassCasc, - kfXic0Candidate.ldlV0, kfXic0Candidate.ldlCasc, kfXic0Candidate.ldlXic, - kfXic0Candidate.chi2TopoV0ToPv, kfXic0Candidate.chi2TopoCascToPv, kfXic0Candidate.chi2TopoPiFromXicToPv, kfXic0Candidate.chi2TopoXicToPv, - kfXic0Candidate.chi2TopoV0ToCasc, kfXic0Candidate.chi2TopoCascToXic, + kfXic0Candidate.ldlV0, kfXic0Candidate.ldlCasc, + kfXic0Candidate.chi2NdfTopoV0ToPv, kfXic0Candidate.chi2NdfTopoCascToPv, kfXic0Candidate.chi2NdfTopoPiFromXicToPv, kfXic0Candidate.chi2NdfTopoXicToPv, + kfXic0Candidate.chi2NdfTopoV0ToCasc, kfXic0Candidate.chi2NdfTopoCascToXic, kfXic0Candidate.decayLenXYLambda, kfXic0Candidate.decayLenXYCasc, kfXic0Candidate.decayLenXYXic, - kfXic0Candidate.cosPaV0ToCasc, kfXic0Candidate.cosPaCascToXic, kfXic0Candidate.cosPaXYV0ToCasc, kfXic0Candidate.cosPaXYCascToXic, - kfXic0Candidate.rapXic, kfXic0Candidate.ptPiFromXic, kfXic0Candidate.ptXic, + kfXic0Candidate.cosPaV0ToCasc, kfXic0Candidate.cosPaCascToXic, + kfXic0Candidate.rapXic, kfXic0Candidate.cosThetaStarPiFromXic, v0NDF, cascNDF, charmbaryonNDF, v0Ndfm, cascNdfm, v0Chi2OverNdf, cascChi2OverNdf, charmbaryonChi2OverNdf, v0Chi2OverNdfm, cascChi2OverNdfm); - + // fill QA table + if (kfResolutionQA) { + rowKfXic0Qa(massLam, massCasc, massXiC0, sigLam, sigCasc, sigXiC0, + collision.globalIndex(), v0index, casc.posTrackId(), casc.negTrackId(), casc.cascadeId(), trackCharmBachelor.globalIndex(), casc.bachelorId(), + kfPos.GetX(), kfPos.GetY(), kfPos.GetZ(), kfPos.GetErrX(), kfPos.GetErrY(), kfPos.GetErrZ(), kfPos.GetPt(), + kfNeg.GetX(), kfNeg.GetY(), kfNeg.GetZ(), kfNeg.GetErrX(), kfNeg.GetErrY(), kfNeg.GetErrZ(), kfNeg.GetPt(), + kfV0.GetX(), kfV0.GetY(), kfV0.GetZ(), kfV0.GetErrX(), kfV0.GetErrY(), kfV0.GetErrZ(), kfV0.GetPt(), + kfBachPionToXi.GetX(), kfBachPionToXi.GetY(), kfBachPionToXi.GetZ(), kfBachPionToXi.GetErrX(), kfBachPionToXi.GetErrY(), kfBachPionToXi.GetErrZ(), kfBachPionToXi.GetPt(), + kfXi.GetX(), kfXi.GetY(), kfXi.GetZ(), kfXi.GetErrX(), kfXi.GetErrY(), kfXi.GetErrZ(), kfXi.GetPt(), + kfCharmBachPionToXiC.GetX(), kfCharmBachPionToXiC.GetY(), kfCharmBachPionToXiC.GetZ(), kfCharmBachPionToXiC.GetErrX(), kfCharmBachPionToXiC.GetErrY(), kfCharmBachPionToXiC.GetErrZ(), kfCharmBachPionToXiC.GetPt(), + kfXiC0.GetX(), kfXiC0.GetY(), kfXiC0.GetZ(), kfXiC0.GetErrX(), kfXiC0.GetErrY(), kfXiC0.GetErrZ(), kfXiC0.GetPt(), + casc.xlambda(), casc.ylambda(), casc.zlambda(), casc.x(), casc.y(), casc.z()); + } } // loop over LF Cascade-bachelor candidates } + + template + void runOmegac0Xic0ToOmegaKaCreatorWithKFParticle(Coll const&, + aod::BCsWithTimestamps const& /*bcWithTimeStamps*/, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, + MyKfCascTable const&, KFCascadesLinked const&, + aod::HfCascLf2Prongs const& candidates, + Hist& hInvMassCharmBaryon, + Hist& hFitterStatus, + Hist& hCandidateCounter, + Hist& hCascadesCounter) + { + for (const auto& cand : candidates) { + hCandidateCounter->Fill(1); + + //----------------------check if the event is selected----------------------------- + auto collision = cand.collision_as(); + float centrality{-1.f}; + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the candidate + continue; + } + + //----------------------Set the magnetic field from ccdb----------------------------- + auto bc = collision.template bc_as(); + if (runNumber != bc.runNumber()) { + LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; + initCCDB(bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, isRun2); + magneticField = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << ">>>>>>>>>>>> Magnetic field: " << magneticField; + runNumber = bc.runNumber(); + } + KFParticle::SetField(magneticField); + + // Retrieve skimmed cascade and pion tracks + auto cascAodElement = cand.cascade_as(); + hCascadesCounter->Fill(0); + if (!cascAodElement.has_kfCascData()) { + continue; + } + auto casc = cascAodElement.kfCascData_as(); + hCascadesCounter->Fill(1); + + // convert KaonFromCharm&KaFromOmega&V0DauPos&V0DauNeg tracks into KFParticle object + auto trackCharmBachelorId = cand.prong0Id(); + auto trackKaFromCharm = tracks.rawIteratorAt(trackCharmBachelorId); + auto trackCascDauChargedId = casc.bachelorId(); + auto trackV0Dau0Id = casc.posTrackId(); + auto trackV0Dau1Id = casc.negTrackId(); + auto trackKaFromOmega = tracksIU.rawIteratorAt(trackCascDauChargedId); // Ka <- Omega track + auto trackV0DauPos = tracksIU.rawIteratorAt(trackV0Dau0Id); // V0 positive daughter track + auto trackV0DauNeg = tracksIU.rawIteratorAt(trackV0Dau1Id); // V0 negative daughter track + auto kaFromOmegaCharge = trackKaFromOmega.sign(); + auto signOmega = casc.sign(); + + KFPTrack kfpTrackKaFromCharm = createKFPTrackFromTrack(trackKaFromCharm); + KFPTrack kfpTrackKaFromOmega = createKFPTrackFromTrack(trackKaFromOmega); + KFPTrack kfpTrackV0DauPos = createKFPTrackFromTrack(trackV0DauPos); + KFPTrack kfpTrackV0DauNeg = createKFPTrackFromTrack(trackV0DauNeg); + + KFParticle kfPrFromV0(kfpTrackV0DauPos, kProton); + KFParticle kfPiFromV0(kfpTrackV0DauNeg, kPiMinus); + KFParticle kfKaFromOmega(kfpTrackKaFromOmega, kKMinus); + KFParticle kfPiFromXiRej(kfpTrackKaFromOmega, kPiMinus); // rej + KFParticle kfKaFromCharm(kfpTrackKaFromCharm, kKPlus); + + if (signOmega == 0 || kaFromOmegaCharge == 0 || kaFromOmegaCharge != signOmega) { + continue; + } + // convert for Pos and Neg Particles + if (signOmega > 0) { + kfPiFromV0 = KFParticle(kfpTrackV0DauPos, kPiPlus); + kfPrFromV0 = KFParticle(kfpTrackV0DauNeg, -kProton); + kfKaFromOmega = KFParticle(kfpTrackKaFromOmega, kKPlus); + kfPiFromXiRej = KFParticle(kfpTrackKaFromOmega, kPiPlus); // rej + kfKaFromCharm = KFParticle(kfpTrackKaFromCharm, kKMinus); + } + + if (doCascadePreselection) { + if (std::abs(casc.dcaXYCascToPV()) > dcaXYToPVCascadeMax) { + continue; + } + if (std::abs(casc.dcaV0daughters()) > dcaV0DaughtersMax) { + continue; + } + if (std::abs(casc.dcacascdaughters()) > dcaCascDaughtersMax) { + continue; + } + if (std::abs(casc.mOmega() - MassOmegaMinus) > massToleranceCascade) { + continue; + } + } + + //----------------------info of V0 and cascade tracks from LF-table------------------ + std::array vertexV0 = {casc.xlambda(), casc.ylambda(), casc.zlambda()}; + std::array pVecV0 = {casc.pxlambda(), casc.pylambda(), casc.pzlambda()}; + std::array vertexCasc = {casc.x(), casc.y(), casc.z()}; + std::array pVecCasc = {casc.px(), casc.py(), casc.pz()}; + + // step 1 : construct V0 with KF + const KFParticle* v0Daughters[2] = {&kfPrFromV0, &kfPiFromV0}; + // construct V0 + KFParticle kfV0; + kfV0.SetConstructMethod(kfConstructMethod); + try { + kfV0.Construct(v0Daughters, 2); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to construct cascade V0 from daughter tracks: " << e.what(); + continue; + } + // mass window cut on lambda before mass constraint + float massLam, sigLam; + kfV0.GetMass(massLam, sigLam); + if (std::abs(massLam - MassLambda0) > lambdaMassWindow) + continue; + // err_mass>0 of Lambda + if (sigLam <= 0) + continue; + // chi2>0 && NDF>0 for selecting Lambda + if ((kfV0.GetNDF() <= 0 || kfV0.GetChi2() <= 0)) + continue; + KFParticle kfV0MassConstrained = kfV0; + kfV0MassConstrained.SetNonlinearMassConstraint(o2::constants::physics::MassLambda); // set mass constrain to Lambda + if (kfUseV0MassConstraint) { + kfV0 = kfV0MassConstrained; + } + kfV0.TransportToDecayVertex(); + + // step 2 : reconstruct cascade(Omega) with KF + const KFParticle* omegaDaugthers[2] = {&kfKaFromOmega, &kfV0}; + const KFParticle* omegaDaugthersRej[2] = {&kfPiFromXiRej, &kfV0}; // rej + // construct cascade + KFParticle kfOmega; + KFParticle kfOmegarej; // rej + kfOmega.SetConstructMethod(kfConstructMethod); + kfOmegarej.SetConstructMethod(kfConstructMethod); // rej + try { + kfOmega.Construct(omegaDaugthers, 2); + kfOmegarej.Construct(omegaDaugthersRej, 2); // rej + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to construct Omega or Omega_rej from V0 and bachelor track: " << e.what(); + continue; + } + float massCasc, sigCasc; + float massCascrej, sigCascrej; + kfOmega.GetMass(massCasc, sigCasc); + kfOmegarej.GetMass(massCascrej, sigCascrej); // rej + // err_massOmega and err_massXiRej > 0 + if (sigCasc <= 0 || sigCascrej <= 0) + continue; + // chi2>0 && NDF>0 + if (kfOmega.GetNDF() <= 0 || kfOmega.GetChi2() <= 0) + continue; + if ((std::abs(massCasc - MassOmegaMinus) > massToleranceCascade) || (std::abs(massCascrej - MassXiMinus) < massToleranceCascadeRej)) + continue; + registry.fill(HIST("hInvMassXiMinus_rej"), massCascrej); // rej: Add competing rejection to minimize misidentified Xi impact. Reject if kfBachPionRej is Pion and the constructed cascade has Xi's invariant mass. + KFParticle kfOmegaMassConstrained = kfOmega; + kfOmegaMassConstrained.SetNonlinearMassConstraint(o2::constants::physics::MassOmegaMinus); // set mass constrain to XiMinus + if (kfUseCascadeMassConstraint) { + // set mass constraint if requested + kfOmega = kfOmegaMassConstrained; + } + registry.fill(HIST("hInvMassXiMinus"), massCasc); + kfOmega.TransportToDecayVertex(); + // rej: Add competing rejection to minimize misidentified Xi impact. Reject if kfBachPionRej is Pion and the constructed cascade has Xi's invariant mass. + + // step 3 : reconstruc OmegaKa with KF + // Create KF charm bach Pion from track + const KFParticle* omegaKaDaugthers[2] = {&kfKaFromCharm, &kfOmega}; + // construct Omegac0 or Xic0 + KFParticle kfOmegaKa; + kfOmegaKa.SetConstructMethod(kfConstructMethod); + try { + kfOmegaKa.Construct(omegaKaDaugthers, 2); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to construct OmegaKa from Cascade and bachelor pion track: " << e.what(); + continue; + } + float massOmegaKa, sigOmegaKa; + kfOmegaKa.GetMass(massOmegaKa, sigOmegaKa); + if (sigOmegaKa <= 0) + continue; + if (kfOmegaKa.GetNDF() <= 0 || kfOmegaKa.GetChi2() <= 0) + continue; + kfOmegaKa.TransportToDecayVertex(); + hFitterStatus->Fill(0); + hCandidateCounter->Fill(2); + + // initialize primary vertex + KFPVertex kfpVertex = createKFPVertexFromCollision(collision); + float covMatrixPV[6]; + kfpVertex.GetCovarianceMatrix(covMatrixPV); + KFParticle kfPv(kfpVertex); // for calculation of DCAs to PV + + // fill test histograms + hInvMassCharmBaryon->Fill(massOmegaKa); + + // topological constraint of daughter to mother + KFParticle kfKaFromCharmToOmegaKa = kfKaFromCharm; + KFParticle kfOmegaToOmegaKa = kfOmega; + KFParticle kfV0ToOmega = kfV0; + KFParticle kfKaToOmega = kfKaFromOmega; + KFParticle kfPrToV0 = kfPrFromV0; + KFParticle kfPiToV0 = kfPiFromV0; + + kfPrToV0.SetProductionVertex(kfV0); + kfPiToV0.SetProductionVertex(kfV0); + kfV0ToOmega.SetProductionVertex(kfOmega); + kfKaToOmega.SetProductionVertex(kfOmega); + kfKaFromCharmToOmegaKa.SetProductionVertex(kfOmegaKa); + kfOmegaToOmegaKa.SetProductionVertex(kfOmegaKa); + + // topological constraint to PV + // KFParticle to PV + KFParticle kfV0ToPv = kfV0; + KFParticle kfOmegaToPv = kfOmega; + KFParticle kfCharmToPv = kfOmegaKa; + KFParticle kfKaFromCharmToPv = kfKaFromCharm; + + kfV0ToPv.SetProductionVertex(kfPv); + kfOmegaToPv.SetProductionVertex(kfPv); + kfCharmToPv.SetProductionVertex(kfPv); + kfKaFromCharmToPv.SetProductionVertex(kfPv); + + //---------------------calculate physical parameters of OmegaKa candidate---------------------- + + // transport OmegaKa daughters to decay vertex (secondary vertex) + float secondaryVertex[3] = {0.}; + secondaryVertex[0] = kfOmegaKa.GetX(); + secondaryVertex[1] = kfOmegaKa.GetY(); + secondaryVertex[2] = kfOmegaKa.GetZ(); + kfKaFromCharm.TransportToPoint(secondaryVertex); + kfOmega.TransportToPoint(secondaryVertex); + + // get impact parameters of OmegaKa daughters + float impactParameterKaFromCharmXY = 0., errImpactParameterKaFromCharmXY = 0.; + float impactParameterOmegaXY = 0., errImpactParameterOmegaXY = 0.; + kfKaFromCharm.GetDistanceFromVertexXY(kfPv, impactParameterKaFromCharmXY, errImpactParameterKaFromCharmXY); + kfOmega.GetDistanceFromVertexXY(kfPv, impactParameterOmegaXY, errImpactParameterOmegaXY); + + // calculate cosine of pointing angle + float cosPaV0ToPv = cpaFromKF(kfV0, kfPv); + float cosPaCascToPv = cpaFromKF(kfOmega, kfPv); + float cosPaOmegaKaToPv = cpaFromKF(kfOmegaKa, kfPv); + float cosPaXYV0ToPv = cpaXYFromKF(kfV0, kfPv); + float cosPaXYCascToPv = cpaXYFromKF(kfOmega, kfPv); + float cosPaXYOmegaKaToPv = cpaXYFromKF(kfOmegaKa, kfPv); + float cosPaV0ToCasc = cpaFromKF(kfV0, kfOmega); + float cosPaCascToOmegaKa = cpaFromKF(kfOmega, kfOmegaKa); + float cosPaXYV0ToCasc = cpaXYFromKF(kfV0, kfOmega); + float cosPaXYCascToOmegaKa = cpaXYFromKF(kfOmega, kfOmegaKa); + + // Get Chi2Geo/NDF + float chi2GeoV0 = kfV0.GetChi2() / kfV0.GetNDF(); + float chi2GeoCasc = kfOmega.GetChi2() / kfOmega.GetNDF(); + float chi2GeoOmegaKa = kfOmegaKa.GetChi2() / kfOmegaKa.GetNDF(); + + // Get Chi2Topo/NDF + float chi2NdfTopoV0ToCasc = kfV0ToOmega.GetChi2() / kfV0ToOmega.GetNDF(); + float chi2NdfTopoKaToCasc = kfKaToOmega.GetChi2() / kfKaToOmega.GetNDF(); + float chi2NdfTopoKaFromOmegaKaToOmegaKa = kfKaFromCharmToOmegaKa.GetChi2() / kfKaFromCharmToOmegaKa.GetNDF(); + float chi2NdfTopoCascToOmegaKa = kfOmegaToOmegaKa.GetChi2() / kfOmegaToOmegaKa.GetNDF(); + float chi2NdfTopoV0ToPv = kfV0ToPv.GetChi2() / kfV0ToPv.GetNDF(); + float chi2NdfTopoCascToPv = kfOmegaToPv.GetChi2() / kfOmegaToPv.GetNDF(); + float chi2NdfTopoOmegaKaToPv = kfCharmToPv.GetChi2() / kfCharmToPv.GetNDF(); + float chi2NdfTopoKaFromOmegaKaToPv = kfKaFromCharmToPv.GetChi2() / kfKaFromCharmToPv.GetNDF(); + + // Get MassChi2/NDF + auto v0Chi2OverNdfm = kfV0MassConstrained.GetChi2() / kfV0MassConstrained.GetNDF(); + auto cascChi2OverNdfm = kfOmegaMassConstrained.GetChi2() / kfOmegaMassConstrained.GetNDF(); + + // KF ldl + float ldlV0 = ldlFromKF(kfV0, kfPv); + float ldlCasc = ldlFromKF(kfOmega, kfPv); + float ldlOmegaKa = ldlFromKF(kfOmegaKa, kfPv); + + // KF decay length + float decayLxyLam, errDecayLxyLam; + kfV0ToOmega.GetDecayLengthXY(decayLxyLam, errDecayLxyLam); + float decayLxyCasc, errDecayLxyCasc; + kfOmegaToOmegaKa.GetDecayLengthXY(decayLxyCasc, errDecayLxyCasc); + float decayLxyOmegaKa, errDecayLxyOmegaKa; + kfCharmToPv.GetDecayLengthXY(decayLxyOmegaKa, errDecayLxyOmegaKa); + + // KF pT + float ptOmegaKa = kfOmegaKa.GetPt(); + float ptKaFromCharm = kfKaFromCharm.GetPt(); + float ptOmega = kfOmega.GetPt(); + + // KF cosThetaStar + float cosThetaStarKaFromOmegac = cosThetaStarFromKF(0, 4332, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa); + float cosThetaStarKaFromXic = cosThetaStarFromKF(0, 4132, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa); + + // KF ct + float ctV0 = kfV0ToOmega.GetLifeTime(); + float ctCasc = kfOmegaToOmegaKa.GetLifeTime(); + float ctOmegaKa = kfCharmToPv.GetLifeTime(); + + hCandidateCounter->Fill(3); + + // fill full kf table + kfCandidateOmegaKaData(collision.globalIndex(), + collision.posX(), collision.posY(), collision.posZ(), // PV Coord + kfPv.GetX(), kfPv.GetY(), kfPv.GetZ(), // PV KF + vertexV0[0], vertexV0[1], vertexV0[2], // V0 Vtx from LF-table + pVecV0[0], pVecV0[1], pVecV0[2], // V0 P from LF-table + vertexCasc[0], vertexCasc[1], vertexCasc[2], // Casc Vtx from LF-table + pVecCasc[0], pVecCasc[1], pVecCasc[2], // Casc P from LF-table + kfV0.GetX(), kfV0.GetY(), kfV0.GetZ(), // V0 Vtx KF + kfV0.GetPx(), kfV0.GetPy(), kfV0.GetPz(), // V0 P KF + kfOmega.GetX(), kfOmega.GetY(), kfOmega.GetZ(), // Omega Vtx KF + kfOmega.GetPx(), kfOmega.GetPx(), kfOmega.GetPx(), // Omega Vtx KF + kfOmegaKa.GetX(), kfOmegaKa.GetY(), kfOmegaKa.GetZ(), // OmegaKa Vtx KF (SecondaryVertex) + kfOmegaKa.GetPx(), kfOmegaKa.GetPx(), kfOmegaKa.GetPx(), // OmegaKa P KF + signOmega, // Check Omega sign + kfPrFromV0.GetEta(), kfPiFromV0.GetEta(), kfKaFromOmega.GetEta(), kfKaFromCharm.GetEta(), kfV0.GetEta(), kfOmega.GetEta(), kfOmegaKa.GetEta(), kfOmegaKa.GetRapidity(), // Eta of daughters and mothers. Rapidity of OmegaKa + impactParameterKaFromCharmXY, errImpactParameterKaFromCharmXY, impactParameterOmegaXY, errImpactParameterOmegaXY, // DCAXY of KaFromCharm and Omega + kfPrToV0.GetDistanceFromParticle(kfPiToV0), kfV0ToOmega.GetDistanceFromParticle(kfKaToOmega), kfOmegaToOmegaKa.GetDistanceFromParticle(kfKaFromCharmToOmegaKa), // DCA of daughters + cosPaV0ToPv, cosPaCascToPv, cosPaOmegaKaToPv, cosPaXYV0ToPv, cosPaXYCascToPv, cosPaXYOmegaKaToPv, cosPaV0ToCasc, cosPaCascToOmegaKa, cosPaXYV0ToCasc, cosPaXYCascToOmegaKa, // CosPA of PV and mothers + chi2GeoV0, chi2GeoCasc, chi2GeoOmegaKa, // Chi2Geo/NDF + v0Chi2OverNdfm, cascChi2OverNdfm, // Chi2Mass/NDF + chi2NdfTopoV0ToCasc, chi2NdfTopoKaToCasc, chi2NdfTopoKaFromOmegaKaToOmegaKa, chi2NdfTopoCascToOmegaKa, chi2NdfTopoV0ToPv, chi2NdfTopoCascToPv, chi2NdfTopoKaFromOmegaKaToPv, chi2NdfTopoOmegaKaToPv, // Chi2Topo/NDF + ldlV0, ldlCasc, ldlOmegaKa, // ldl + decayLxyLam, decayLxyCasc, decayLxyOmegaKa, // DecaylengthXY + massLam, sigLam, massCasc, sigCasc, massCascrej, sigCascrej, massOmegaKa, sigOmegaKa, // massKF and masserror + ptOmegaKa, ptKaFromCharm, ptOmega, // pT + cosThetaStarKaFromOmegac, cosThetaStarKaFromXic, ctV0, ctCasc, ctOmegaKa, // cosThetaStar & ct + cascAodElement.v0Id(), casc.posTrackId(), casc.negTrackId(), casc.cascadeId(), casc.bachelorId(), trackKaFromCharm.globalIndex()); + } + } + /// @brief process function w/o centrality selections void processNoCentToXiPi(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, @@ -1559,27 +2001,41 @@ struct HfCandidateCreatorXic0Omegac0 { } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processNoCentToOmegaPi, "Run candidate creator w/o centrality selections for omega pi decay channel", false); - void processOmegacToOmegaPiWithKFParticle(aod::Collisions const& collisions, + void processNoCentOmegacToOmegaPiWithKFParticle(soa::Join const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, + MyKfCascTable const& cascades, + KFCascadesLinked const& cascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runKfOmegac0CreatorWithKFParticle(collisions, bcWithTimeStamps, tracksIU, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processNoCentOmegacToOmegaPiWithKFParticle, "Run candidate creator w/o centrality selections for Omegac0 To omega pi decay channel using KFParticle", false); + + void processNoCentOmegac0Xic0ToOmegaKaCreatorWithKFParticle(soa::Join const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, + MyKfCascTable const& cascades, + KFCascadesLinked const& cascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runOmegac0Xic0ToOmegaKaCreatorWithKFParticle(collisions, bcWithTimeStamps, tracksIU, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaK, hFitterStatusToOmegaK, hCandidateCounterToOmegaK, hCascadesCounterToOmegaK); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processNoCentOmegac0Xic0ToOmegaKaCreatorWithKFParticle, "Run candidate creator w/o centrality selections for Omegac0 To omega ka decay channel using KFParticle", false); + + void processNoCentXicToXiPiWithKFParticle(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracksIU const& tracksIU, MyKfTracks const& tracks, MyKfCascTable const& cascades, KFCascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runKfOmegac0CreatorWithKFParticle(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); + runKfXic0CreatorWithKFParticle(collisions, bcWithTimeStamps, tracksIU, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); } - PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processOmegacToOmegaPiWithKFParticle, "Run candidate creator w/o centrality selections for Omegac0 To omega pi decay channel using KFParticle", false); - - void processXicToXiPiWithKFParticle(aod::Collisions const& collisions, - aod::BCsWithTimestamps const& bcWithTimeStamps, - MyKfTracks const& tracks, - MyKfCascTable const& cascades, - KFCascadesLinked const& cascadeLinks, - aod::HfCascLf2Prongs const& candidates) - { - runKfXic0CreatorWithKFParticle(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); - } - PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processXicToXiPiWithKFParticle, "Run candidate creator w/o centrality selections for Xic0 To Xi pi decay channel using KFParticle", false); + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processNoCentXicToXiPiWithKFParticle, "Run candidate creator w/o centrality selections for Xic0 To Xi pi decay channel using KFParticle", false); void processNoCentToOmegaK(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, @@ -1618,6 +2074,42 @@ struct HfCandidateCreatorXic0Omegac0 { } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0CToOmegaPi, "Run candidate creator w/ centrality selection on FT0C for omega pi channel", false); + void processCentFT0COmegacToOmegaPiWithKFParticle(soa::Join const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, + MyKfCascTable const& cascades, + KFCascadesLinked const& cascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runKfOmegac0CreatorWithKFParticle(collisions, bcWithTimeStamps, tracksIU, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0COmegacToOmegaPiWithKFParticle, "Run candidate creator w/o centrality selections for Omegac0 To omega pi decay channel using KFParticle", false); + + void processCentFT0COmegac0Xic0ToOmegaKaCreatorWithKFParticle(soa::Join const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, + MyKfCascTable const& cascades, + KFCascadesLinked const& cascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runOmegac0Xic0ToOmegaKaCreatorWithKFParticle(collisions, bcWithTimeStamps, tracksIU, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaK, hFitterStatusToOmegaK, hCandidateCounterToOmegaK, hCascadesCounterToOmegaK); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0COmegac0Xic0ToOmegaKaCreatorWithKFParticle, "Run candidate creator w/o centrality selections for Omegac0 To omega ka decay channel using KFParticle", false); + + void processCentFT0CXicToXiPiWithKFParticle(soa::Join const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, + MyKfCascTable const& cascades, + KFCascadesLinked const& cascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runKfXic0CreatorWithKFParticle(collisions, bcWithTimeStamps, tracksIU, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0CXicToXiPiWithKFParticle, "Run candidate creator w FT0C centrality selections for Xic0 To Xi pi decay channel using KFParticle", false); + void processCentFT0CToOmegaK(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, @@ -1655,6 +2147,42 @@ struct HfCandidateCreatorXic0Omegac0 { } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0MToOmegaPi, "Run candidate creator w/ centrality selection on FT0M for omega pi channel", false); + void processCentFT0MOmegacToOmegaPiWithKFParticle(soa::Join const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, + MyKfCascTable const& cascades, + KFCascadesLinked const& cascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runKfOmegac0CreatorWithKFParticle(collisions, bcWithTimeStamps, tracksIU, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0MOmegacToOmegaPiWithKFParticle, "Run candidate creator w/o centrality selections for Omegac0 To omega pi decay channel using KFParticle", false); + + void processCentFT0MOmegac0Xic0ToOmegaKaCreatorWithKFParticle(soa::Join const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, + MyKfCascTable const& cascades, + KFCascadesLinked const& cascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runOmegac0Xic0ToOmegaKaCreatorWithKFParticle(collisions, bcWithTimeStamps, tracksIU, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaK, hFitterStatusToOmegaK, hCandidateCounterToOmegaK, hCascadesCounterToOmegaK); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0MOmegac0Xic0ToOmegaKaCreatorWithKFParticle, "Run candidate creator w/o centrality selections for Omegac0 To omega ka decay channel using KFParticle", false); + + void processCentFT0MXicToXiPiWithKFParticle(soa::Join const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracksIU const& tracksIU, + MyKfTracks const& tracks, + MyKfCascTable const& cascades, + KFCascadesLinked const& cascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runKfXic0CreatorWithKFParticle(collisions, bcWithTimeStamps, tracksIU, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0MXicToXiPiWithKFParticle, "Run candidate creator w FT0M centrality selections for Xic0 To Xi pi decay channel using KFParticle", false); + void processCentFT0MToOmegaK(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, @@ -1738,20 +2266,22 @@ struct HfCandidateCreatorXic0Omegac0Mc { Produces rowMCMatchGenToOmegaK; // Configuration - o2::framework::Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + Configurable acceptTrackIntWithMaterial{"acceptTrackIntWithMaterial", false, " switch to accept candidates with final (i.e. p, K, pi) daughter tracks interacting with material"}; using MyTracksWMc = soa::Join; using McCollisionsNoCents = soa::Join; using McCollisionsFT0Cs = soa::Join; using McCollisionsFT0Ms = soa::Join; using McCollisionsCentFT0Ms = soa::Join; + using BCsInfo = soa::Join; + + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId; PresliceUnsorted colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId; - Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring - using BCsInfo = soa::Join; std::shared_ptr hGenCharmBaryonPtRapidityTightXicToXiPi, hGenCharmBaryonPtRapidityLooseXicToXiPi, hGenCharmBaryonPtRapidityTightOmegacToXiPi, hGenCharmBaryonPtRapidityLooseOmegacToXiPi, hGenCharmBaryonPtRapidityTightOmegacToOmegaPi, hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi, hGenCharmBaryonPtRapidityTightOmegacToOmegaK, hGenCharmBaryonPtRapidityLooseOmegacToOmegaK; @@ -1760,7 +2290,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) { - std::array procCollisionsXicToXiPi{doprocessMcXicToXiPi, doprocessMcXicToXiPiFT0m, doprocessMcXicToXiPiFT0c, doprocessMcXicToXiPiKf}; + std::array procCollisionsXicToXiPi{doprocessMcXicToXiPi, doprocessMcXicToXiPiFT0m, doprocessMcXicToXiPiFT0c, doprocessMcXicToXiPiKf, doprocessMcXicToXiPiKfQa}; if (std::accumulate(procCollisionsXicToXiPi.begin(), procCollisionsXicToXiPi.end(), 0) > 1) { LOGP(fatal, "At most one process function for XicToXiPi collision study can be enabled at a time."); } @@ -1780,11 +2310,11 @@ struct HfCandidateCreatorXic0Omegac0Mc { const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-xic0-omegac0") == 0) { - hfEvSelMc.configureFromDevice(device); + // init HF event selection helper + hfEvSelMc.init(device, registry); break; } } - hfEvSelMc.addHistograms(registry); // particles monitoring hGenCharmBaryonPtRapidityTightXicToXiPi = registry.add("hGenCharmBaryonPtRapidityTightXicToXiPi", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); // keep track of generated candidates pt when |y|<0.5 hGenCharmBaryonPtRapidityLooseXicToXiPi = registry.add("hGenCharmBaryonPtRapidityLooseXicToXiPi", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); // keep track of generated candidates pt when |y|<0.8 @@ -1797,6 +2327,141 @@ struct HfCandidateCreatorXic0Omegac0Mc { hGenCharmBaryonPtRapidityTightOmegacToOmegaK = registry.add("hGenCharmBaryonPtRapidityTightOmegacToOmegaK", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); hGenCharmBaryonPtRapidityLooseOmegacToOmegaK = registry.add("hGenCharmBaryonPtRapidityLooseOmegacToOmegaK", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); + + // QA + if (doprocessMcXicToXiPiKfQa) { + AxisSpec axisPt{20, 0., 20.}; + AxisSpec axisDelta{1000, -0.5, 0.5}; + AxisSpec axisPull{2000, -10., 10.}; + AxisSpec axisPtRes{400, -0.2, 0.2}; + // mass over pt + registry.add("hV0MassPullVsPt", "m_{PULL}(V0) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXiMassPullVsPt", "m_{PULL}(#Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXic0MassPullVsPt", "m_{PULL}(#Xic0) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + // delta + registry.add("hV0DauPosXDelta", "x^{p} - x^{MC}", kTH1D, {axisDelta}); + registry.add("hV0DauPosYDelta", "y^{p} - y^{MC}", kTH1D, {axisDelta}); + registry.add("hV0DauPosZDelta", "z^{p} - z^{MC}", kTH1D, {axisDelta}); + registry.add("hV0DauNegXDelta", "x^{#pi^{-}} - x^{MC}", kTH1D, {axisDelta}); + registry.add("hV0DauNegYDelta", "y^{#pi^{-}} - y^{MC}", kTH1D, {axisDelta}); + registry.add("hV0DauNegZDelta", "z^{#pi^{-}} - z^{MC}", kTH1D, {axisDelta}); + registry.add("hV0XDelta", "x^{#Lambda} - x^{MC}", kTH1D, {axisDelta}); + registry.add("hV0YDelta", "y^{#Lambda} - y^{MC}", kTH1D, {axisDelta}); + registry.add("hV0ZDelta", "z^{#Lambda} - z^{MC}", kTH1D, {axisDelta}); + + registry.add("hXiBachelorXDelta", "x^{#pi^{-} from #Xi^{-}} - x^{MC}", kTH1D, {axisDelta}); + registry.add("hXiBachelorYDelta", "y^{#pi^{-} from #Xi^{-}} - y^{MC}", kTH1D, {axisDelta}); + registry.add("hXiBachelorZDelta", "z^{#pi^{-} from #Xi^{-}} - z^{MC}", kTH1D, {axisDelta}); + + registry.add("hXiXDelta", "x^{#Xi^{-}} - x^{MC}", kTH1D, {axisDelta}); + registry.add("hXiYDelta", "y^{#Xi^{-}} - y^{MC}", kTH1D, {axisDelta}); + registry.add("hXiZDelta", "z^{#Xi^{-}} - z^{MC}", kTH1D, {axisDelta}); + + registry.add("hXic0BachelorXDelta", "x^{#pi^{+} from #Xi_{c}^{0}} - x^{MC}", kTH1D, {axisDelta}); + registry.add("hXic0BachelorYDelta", "y^{#pi^{+} from #Xi_{c}^{0}} - y^{MC}", kTH1D, {axisDelta}); + registry.add("hXic0BachelorZDelta", "z^{#pi^{+} from #Xi_{c}^{0}} - z^{MC}", kTH1D, {axisDelta}); + + registry.add("hXic0XDelta", "x^{#Xi_(c)^(0)} - x^{MC}", kTH1D, {axisDelta}); + registry.add("hXic0YDelta", "y^{#Xi_(c)^(0)} - y^{MC}", kTH1D, {axisDelta}); + registry.add("hXic0ZDelta", "z^{#Xi_(c)^(0)} - z^{MC}", kTH1D, {axisDelta}); + // delta over pt + registry.add("hV0DauPosXDeltaVsPt", "#Delta_{x}(p) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hV0DauPosYDeltaVsPt", "#Delta_{y}(p) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hV0DauPosZDeltaVsPt", "#Delta_{z}(p) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hV0DauNegXDeltaVsPt", "#Delta_{x}(#pi) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hV0DauNegYDeltaVsPt", "#Delta_{y}(#pi) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hV0DauNegZDeltaVsPt", "#Delta_{z}(#pi) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hV0XDeltaVsPt", "#Delta_{x}(#Lambda) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hV0YDeltaVsPt", "#Delta_{y}(#Lambda) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hV0ZDeltaVsPt", "#Delta_{z}(#Lambda) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + + registry.add("hXiBachelorXDeltaVsPt", "#Delta_{x}(#pi^{-} from #Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hXiBachelorYDeltaVsPt", "#Delta_{y}(#pi^{-} from #Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hXiBachelorZDeltaVsPt", "#Delta_{z}(#pi^{-} from #Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + + registry.add("hXiXDeltaVsPt", "#Delta_{x}(#Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hXiYDeltaVsPt", "#Delta_{y}(#Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hXiZDeltaVsPt", "#Delta_{z}(#Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + + registry.add("hXic0BachelorXDeltaVsPt", "#Delta_{x}(#pi^{+} from #Xi_{c}^{0}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hXic0BachelorYDeltaVsPt", "#Delta_{y}(#pi^{+} from #Xi_{c}^{0}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hXic0BachelorZDeltaVsPt", "#Delta_{z}(#pi^{+} from #Xi_{c}^{0}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + + registry.add("hXic0XDeltaVsPt", "#Delta_{x}(#Xi_{c}^{0}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hXic0YDeltaVsPt", "#Delta_{y}(#Xi_{c}^{0}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + registry.add("hXic0ZDeltaVsPt", "#Delta_{z}(#Xi_{c}^{0}) vs. p_{T}", HistType::kTH2D, {axisPt, axisDelta}); + + // pull + registry.add("hV0DauPosXPull", "x^{PULL}", kTH1D, {axisPull}); + registry.add("hV0DauPosYPull", "y^{PULL}", kTH1D, {axisPull}); + registry.add("hV0DauPosZPull", "z^{PULL}", kTH1D, {axisPull}); + registry.add("hV0DauNegXPull", "x^{PULL}", kTH1D, {axisPull}); + registry.add("hV0DauNegYPull", "y^{PULL}", kTH1D, {axisPull}); + registry.add("hV0DauNegZPull", "z^{PULL}", kTH1D, {axisPull}); + registry.add("hV0XPull", "x^{PULL}(#Lambda)", kTH1D, {axisPull}); + registry.add("hV0YPull", "y^{PULL}(#Lambda)", kTH1D, {axisPull}); + registry.add("hV0ZPull", "z^{PULL}(#Lambda)", kTH1D, {axisPull}); + + registry.add("hXiBachelorXPull", "x^{PULL}", kTH1D, {axisPull}); + registry.add("hXiBachelorYPull", "y^{PULL}", kTH1D, {axisPull}); + registry.add("hXiBachelorZPull", "z^{PULL}", kTH1D, {axisPull}); + + registry.add("hXiXPull", "x^{PULL}(#Xi^{-})", kTH1D, {axisPull}); + registry.add("hXiYPull", "y^{PULL}(#Xi^{-})", kTH1D, {axisPull}); + registry.add("hXiZPull", "z^{PULL}(#Xi^{-})", kTH1D, {axisPull}); + + registry.add("hXic0BachelorXPull", "x^{PULL}", kTH1D, {axisPull}); + registry.add("hXic0BachelorYPull", "y^{PULL}", kTH1D, {axisPull}); + registry.add("hXic0BachelorZPull", "z^{PULL}", kTH1D, {axisPull}); + + registry.add("hXic0XPull", "x^{PULL}(#Xi_{c}^{0})", kTH1D, {axisPull}); + registry.add("hXic0YPull", "y^{PULL}(#Xi_{c}^{0})", kTH1D, {axisPull}); + registry.add("hXic0ZPull", "z^{PULL}(#Xi_{c}^{0})", kTH1D, {axisPull}); + // pull over pt + registry.add("hV0DauPosXPullVsPt", "x_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hV0DauPosYPullVsPt", "y_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hV0DauPosZPullVsPt", "z_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hV0DauNegXPullVsPt", "x_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hV0DauNegYPullVsPt", "y_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hV0DauNegZPullVsPt", "z_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hV0XPullVsPt", "x_{PULL}(#Lambda) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hV0YPullVsPt", "y_{PULL}(#Lambda) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hV0ZPullVsPt", "z_{PULL}(#Lambda) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + + registry.add("hXiBachelorXPullVsPt", "x_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXiBachelorYPullVsPt", "y_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXiBachelorZPullVsPt", "z_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + + registry.add("hXiXPullVsPt", "x_{PULL}(#Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXiYPullVsPt", "y_{PULL}(#Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXiZPullVsPt", "z_{PULL}(#Xi^{-}) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + + registry.add("hXic0BachelorXPullVsPt", "x_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXic0BachelorYPullVsPt", "y_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXic0BachelorZPullVsPt", "z_{PULL} vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + + registry.add("hXic0XPullVsPt", "x_{PULL}(#Xi_{c}^{0}) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXic0YPullVsPt", "y_{PULL}(#Xi_{c}^{0}) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + registry.add("hXic0ZPullVsPt", "z_{PULL}(#Xi_{c}^{0}) vs. p_{T}", HistType::kTH2D, {axisPt, axisPull}); + + // Defaut delta + registry.add("hLambdaXDelta", "x^{#Lambda} - x^{MC}(Default)", kTH1D, {axisDelta}); + registry.add("hLambdaYDelta", "y^{#Lambda} - y^{MC}(Default)", kTH1D, {axisDelta}); + registry.add("hLambdaZDelta", "z^{#Lambda} - z^{MC}(Default)", kTH1D, {axisDelta}); + + registry.add("hCascXDelta", "x^{#Xi^{-}} - x^{MC}(Default)", kTH1D, {axisDelta}); + registry.add("hCascYDelta", "y^{#Xi^{-}} - y^{MC}(Default)", kTH1D, {axisDelta}); + registry.add("hCascZDelta", "z^{#Xi^{-}} - z^{MC}(Default)", kTH1D, {axisDelta}); + + // Pt Resolution + registry.add("hV0DauPosPtRes", "Pt Resolution (p)", kTH1D, {axisPtRes}); + registry.add("hV0DauNegPtRes", "Pt Resolution (#pi^{-} from #Lambda)", kTH1D, {axisPtRes}); + registry.add("hV0PtRes", "Pt Resolution (V0)", kTH1D, {axisPtRes}); + registry.add("hXiBachelorPtRes", "Pt Resolution (#pi^{-} from #Xi^{-})", kTH1D, {axisPtRes}); + registry.add("hXiPtRes", "Pt Resolution (#Xi^{-})", kTH1D, {axisPtRes}); + registry.add("hXic0BachelorPtRes", "Pt Resolution (#pi^{+} from #Xi_{c}^{0})", kTH1D, {axisPtRes}); + registry.add("hXic0PtRes", "Pt Resolution (#Xi_{c}^{0})", kTH1D, {axisPtRes}); + } } template @@ -1816,28 +2481,19 @@ struct HfCandidateCreatorXic0Omegac0Mc { int8_t signV0 = -9; int8_t flag = 0; int8_t origin = 0; // to be used for prompt/non prompt - int8_t debug = 0; + McMatchFlag debug{McMatchFlag::None}; int8_t debugGenCharmBar = 0; int8_t debugGenCasc = 0; int8_t debugGenLambda = 0; + int8_t nPiToMuV0{0}, nPiToMuCasc{0}, nPiToMuOmegac0{0}; + int8_t nKaToPiCasc{0}, nKaToPiOmegac0{0}; bool collisionMatched = false; - int pdgCodeOmegac0 = Pdg::kOmegaC0; // 4332 - int pdgCodeXic0 = Pdg::kXiC0; // 4132 - int pdgCodeXiMinus = kXiMinus; // 3312 - int pdgCodeOmegaMinus = kOmegaMinus; // 3334 - int pdgCodeLambda = kLambda0; // 3122 - int pdgCodePiPlus = kPiPlus; // 211 - int pdgCodePiMinus = kPiMinus; // -211 - int pdgCodeProton = kProton; // 2212 - int pdgCodeKaonPlus = kKPlus; // 321 - int pdgCodeKaonMinus = kKMinus; // -321 - // Match reconstructed candidates. for (const auto& candidate : candidates) { flag = 0; origin = RecoDecay::OriginType::None; - debug = 0; + debug = McMatchFlag::None; collisionMatched = false; std::vector idxBhadMothers{}; @@ -1871,26 +2527,25 @@ struct HfCandidateCreatorXic0Omegac0Mc { continue; } } - // Xic0 -> xi pi matching if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { // Xic → pi pi pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgCodeXic0, std::array{pdgCodePiPlus, pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, +kXiC0, std::array{+kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 3); indexRecCharmBaryon = indexRec; if (indexRec == -1) { - debug = 1; + debug = McMatchFlag::CharmbaryonUnmatched; } if (indexRec > -1) { // Xi- → pi pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, pdgCodeXiMinus, std::array{pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &signCasc, 2); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, &signCasc, 2); if (indexRec == -1) { - debug = 2; + debug = McMatchFlag::CascUnmatched; } if (indexRec > -1) { // Lambda → p pi - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true, &signV0, 1); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &signV0, 1); if (indexRec == -1) { - debug = 3; + debug = McMatchFlag::V0Unmatched; } if (indexRec > -1) { flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi); @@ -1909,27 +2564,27 @@ struct HfCandidateCreatorXic0Omegac0Mc { } else { rowMCMatchRecXicToXiPi(flag, debug, origin, collisionMatched, -1.f, 0); } - if (debug == 2 || debug == 3) { + if (debug == McMatchFlag::CascUnmatched || debug == McMatchFlag::V0Unmatched) { LOGF(info, "WARNING: Xic0ToXiPi decays in the expected final state but the condition on the intermediate states are not fulfilled"); } } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { // Omegac -> xi pi matching // Omegac → pi pi pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgCodeOmegac0, std::array{pdgCodePiPlus, pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, +kOmegaC0, std::array{+kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 3); indexRecCharmBaryon = indexRec; if (indexRec == -1) { - debug = 1; + debug = McMatchFlag::CharmbaryonUnmatched; } if (indexRec > -1) { // Xi- → pi pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, pdgCodeXiMinus, std::array{pdgCodePiMinus, pdgCodeProton, pdgCodePiMinus}, true, &signCasc, 2); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, &signCasc, 2); if (indexRec == -1) { - debug = 2; + debug = McMatchFlag::CascUnmatched; } if (indexRec > -1) { // Lambda → p pi - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true, &signV0, 1); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &signV0, 1); if (indexRec == -1) { - debug = 3; + debug = McMatchFlag::V0Unmatched; } if (indexRec > -1) { flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi); @@ -1948,31 +2603,64 @@ struct HfCandidateCreatorXic0Omegac0Mc { } else { rowMCMatchRecOmegacToXiPi(flag, debug, origin, collisionMatched, -1.f, 0); } - if (debug == 2 || debug == 3) { + if (debug == McMatchFlag::CascUnmatched || debug == McMatchFlag::V0Unmatched) { LOGF(info, "WARNING: Omegac0ToXiPi decays in the expected final state but the condition on the intermediate states are not fulfilled"); } } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { // Omegac0 -> omega pi matching - // Omegac → pi K pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgCodeOmegac0, std::array{pdgCodePiPlus, pdgCodeKaonMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3); - indexRecCharmBaryon = indexRec; - if (indexRec == -1) { - debug = 1; - } - if (indexRec > -1) { - // Omega- → K pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, pdgCodeOmegaMinus, std::array{pdgCodeKaonMinus, pdgCodeProton, pdgCodePiMinus}, true, &signCasc, 2); + if (acceptTrackIntWithMaterial) { + // Omegac → pi K pi p + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, +kOmegaC0, std::array{+kPiPlus, +kKMinus, +kProton, +kPiMinus}, true, &sign, 3, &nPiToMuOmegac0, &nKaToPiOmegac0); + indexRecCharmBaryon = indexRec; if (indexRec == -1) { - debug = 2; + debug = McMatchFlag::CharmbaryonUnmatched; } if (indexRec > -1) { - // Lambda → p pi - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true, &signV0, 1); + // Omega- → K pi p + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kOmegaMinus, std::array{+kKMinus, +kProton, +kPiMinus}, true, &signCasc, 2, &nPiToMuCasc, &nKaToPiCasc); if (indexRec == -1) { - debug = 3; + debug = McMatchFlag::CascUnmatched; } if (indexRec > -1) { - flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi); - collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); + // Lambda → p pi + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &signV0, 1, &nPiToMuV0); + if (indexRec == -1) { + debug = McMatchFlag::V0Unmatched; + } + if (indexRec > -1 && nPiToMuOmegac0 >= 1 && nKaToPiOmegac0 == 0) { + flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPiOneMu); + collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); + } else if (indexRec > -1 && nPiToMuOmegac0 == 0 && nKaToPiOmegac0 == 0) { + flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi); + collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); + } + } + } + } else { + // Omegac → pi K pi p + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, +kOmegaC0, std::array{+kPiPlus, +kKMinus, +kProton, +kPiMinus}, true, &sign, 3, &nPiToMuOmegac0, &nKaToPiOmegac0); + indexRecCharmBaryon = indexRec; + if (indexRec == -1) { + debug = McMatchFlag::CharmbaryonUnmatched; + } + if (indexRec > -1) { + // Omega- → K pi p + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kOmegaMinus, std::array{+kKMinus, +kProton, +kPiMinus}, true, &signCasc, 2, &nPiToMuCasc, &nKaToPiCasc); + if (indexRec == -1) { + debug = McMatchFlag::CascUnmatched; + } + if (indexRec > -1) { + // Lambda → p pi + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &signV0, 1, &nPiToMuV0); + if (indexRec == -1) { + debug = McMatchFlag::V0Unmatched; + } + if (indexRec > -1 && nPiToMuOmegac0 >= 1 && nKaToPiOmegac0 == 0) { + flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPiOneMu); + collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); + } else if (indexRec > -1 && nPiToMuOmegac0 == 0 && nKaToPiOmegac0 == 0) { + flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi); + collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); + } } } } @@ -1987,27 +2675,27 @@ struct HfCandidateCreatorXic0Omegac0Mc { } else { rowMCMatchRecToOmegaPi(flag, debug, origin, collisionMatched, -1.f, 0); } - if (debug == 2 || debug == 3) { + if (debug == McMatchFlag::CascUnmatched || debug == McMatchFlag::V0Unmatched) { LOGF(info, "WARNING: Omegac0ToOmegaPi decays in the expected final state but the condition on the intermediate states are not fulfilled"); } } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { // Omegac0 -> omega K matching // Omegac → K K pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, pdgCodeOmegac0, std::array{pdgCodeKaonPlus, pdgCodeKaonMinus, pdgCodeProton, pdgCodePiMinus}, true, &sign, 3); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, +kOmegaC0, std::array{+kKPlus, +kKMinus, +kProton, +kPiMinus}, true, &sign, 3); indexRecCharmBaryon = indexRec; if (indexRec == -1) { - debug = 1; + debug = McMatchFlag::CharmbaryonUnmatched; } if (indexRec > -1) { // Omega- → K pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, pdgCodeOmegaMinus, std::array{pdgCodeKaonMinus, pdgCodeProton, pdgCodePiMinus}, true, &signCasc, 2); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kOmegaMinus, std::array{+kKMinus, +kProton, +kPiMinus}, true, &signCasc, 2); if (indexRec == -1) { - debug = 2; + debug = McMatchFlag::CascUnmatched; } if (indexRec > -1) { // Lambda → p pi - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true, &signV0, 1); + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &signV0, 1); if (indexRec == -1) { - debug = 3; + debug = McMatchFlag::V0Unmatched; } if (indexRec > -1) { flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK); @@ -2026,7 +2714,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { } else { rowMCMatchRecToOmegaK(flag, debug, origin, collisionMatched, -1.f, 0); } - if (debug == 2 || debug == 3) { + if (debug == McMatchFlag::CascUnmatched || debug == McMatchFlag::V0Unmatched) { LOGF(info, "WARNING: Omegac0ToOmegaK decays in the expected final state but the condition on the intermediate states are not fulfilled"); } } @@ -2038,18 +2726,22 @@ struct HfCandidateCreatorXic0Omegac0Mc { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint16_t rejectionMask{0}; + uint32_t rejectionMask{0u}; + int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collsWithMcLabels.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + nSplitColl = collSlice.size(); } else if constexpr (centEstimator == CentralityEstimator::FT0M) { const auto collSlice = collsWithMcLabels.sliceBy(colPerMcCollisionFT0M, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + nSplitColl = collSlice.size(); } else if constexpr (centEstimator == CentralityEstimator::None) { const auto collSlice = collsWithMcLabels.sliceBy(colPerMcCollision, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + nSplitColl = collSlice.size(); } - hfEvSelMc.fillHistograms(mcCollision, rejectionMask); + hfEvSelMc.fillHistograms(mcCollision, rejectionMask, nSplitColl); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject all particles from this collision for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) { @@ -2077,6 +2769,8 @@ struct HfCandidateCreatorXic0Omegac0Mc { debugGenLambda = 0; origin = RecoDecay::OriginType::None; std::vector idxBhadMothers{}; + float kRapidityCutTight = 0.5; + float kRapidityCutLoose = 0.8; // Reject particles from background events if (particle.fromBackgroundEvent() && rejectBackground) { @@ -2094,23 +2788,23 @@ struct HfCandidateCreatorXic0Omegac0Mc { if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { // Xic → Xi pi - if (RecoDecay::isMatchedMCGen(mcParticles, particle, pdgCodeXic0, std::array{pdgCodeXiMinus, pdgCodePiPlus}, true, &sign)) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, +kXiC0, std::array{+kXiMinus, +kPiPlus}, true, &sign)) { debugGenCharmBar = 1; ptCharmBaryonGen = particle.pt(); rapidityCharmBaryonGen = particle.y(); for (const auto& daughterCharm : particle.template daughters_as()) { - if (std::abs(daughterCharm.pdgCode()) != pdgCodeXiMinus) { + if (std::abs(daughterCharm.pdgCode()) != +kXiMinus) { continue; } // Xi -> Lambda pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) { + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, +kXiMinus, std::array{+kLambda0, +kPiMinus}, true)) { debugGenCasc = 1; for (const auto& daughterCascade : daughterCharm.template daughters_as()) { - if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { + if (std::abs(daughterCascade.pdgCode()) != +kLambda0) { continue; } // Lambda -> p pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, +kLambda0, std::array{+kProton, +kPiMinus}, true)) { debugGenLambda = 1; flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi); } @@ -2121,10 +2815,10 @@ struct HfCandidateCreatorXic0Omegac0Mc { // Check whether the charm baryon is non-prompt (from a b quark) if (flag != 0) { origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - if (std::abs(rapidityCharmBaryonGen) < 0.5) { + if (std::abs(rapidityCharmBaryonGen) < kRapidityCutTight) { hGenCharmBaryonPtRapidityTightXicToXiPi->SetBinContent(hGenCharmBaryonPtRapidityTightXicToXiPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityTightXicToXiPi->GetBinContent(hGenCharmBaryonPtRapidityTightXicToXiPi->FindBin(ptCharmBaryonGen)) + 1); } - if (std::abs(rapidityCharmBaryonGen) < 0.8) { + if (std::abs(rapidityCharmBaryonGen) < kRapidityCutLoose) { hGenCharmBaryonPtRapidityLooseXicToXiPi->SetBinContent(hGenCharmBaryonPtRapidityLooseXicToXiPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityLooseXicToXiPi->GetBinContent(hGenCharmBaryonPtRapidityLooseXicToXiPi->FindBin(ptCharmBaryonGen)) + 1); } } @@ -2136,23 +2830,23 @@ struct HfCandidateCreatorXic0Omegac0Mc { } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { // Omegac → Xi pi - if (RecoDecay::isMatchedMCGen(mcParticles, particle, pdgCodeOmegac0, std::array{pdgCodeXiMinus, pdgCodePiPlus}, true, &sign)) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, +kOmegaC0, std::array{+kXiMinus, +kPiPlus}, true, &sign)) { debugGenCharmBar = 1; ptCharmBaryonGen = particle.pt(); rapidityCharmBaryonGen = particle.y(); for (const auto& daughterCharm : particle.template daughters_as()) { - if (std::abs(daughterCharm.pdgCode()) != pdgCodeXiMinus) { + if (std::abs(daughterCharm.pdgCode()) != +kXiMinus) { continue; } // Xi -> Lambda pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) { + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, +kXiMinus, std::array{+kLambda0, +kPiMinus}, true)) { debugGenCasc = 1; for (const auto& daughterCascade : daughterCharm.template daughters_as()) { - if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { + if (std::abs(daughterCascade.pdgCode()) != +kLambda0) { continue; } // Lambda -> p pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, +kLambda0, std::array{+kProton, +kPiMinus}, true)) { debugGenLambda = 1; flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi); } @@ -2163,10 +2857,10 @@ struct HfCandidateCreatorXic0Omegac0Mc { // Check whether the charm baryon is non-prompt (from a b quark) if (flag != 0) { origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - if (std::abs(rapidityCharmBaryonGen) < 0.5) { + if (std::abs(rapidityCharmBaryonGen) < kRapidityCutTight) { hGenCharmBaryonPtRapidityTightOmegacToXiPi->SetBinContent(hGenCharmBaryonPtRapidityTightOmegacToXiPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityTightOmegacToXiPi->GetBinContent(hGenCharmBaryonPtRapidityTightOmegacToXiPi->FindBin(ptCharmBaryonGen)) + 1); } - if (std::abs(rapidityCharmBaryonGen) < 0.8) { + if (std::abs(rapidityCharmBaryonGen) < kRapidityCutLoose) { hGenCharmBaryonPtRapidityLooseOmegacToXiPi->SetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToXiPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityLooseOmegacToXiPi->GetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToXiPi->FindBin(ptCharmBaryonGen)) + 1); } } @@ -2178,23 +2872,23 @@ struct HfCandidateCreatorXic0Omegac0Mc { } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { // Omegac → Omega pi - if (RecoDecay::isMatchedMCGen(mcParticles, particle, pdgCodeOmegac0, std::array{pdgCodeOmegaMinus, pdgCodePiPlus}, true, &sign)) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, +kOmegaC0, std::array{+kOmegaMinus, +kPiPlus}, true, &sign)) { debugGenCharmBar = 1; ptCharmBaryonGen = particle.pt(); rapidityCharmBaryonGen = particle.y(); for (const auto& daughterCharm : particle.template daughters_as()) { - if (std::abs(daughterCharm.pdgCode()) != pdgCodeOmegaMinus) { + if (std::abs(daughterCharm.pdgCode()) != +kOmegaMinus) { continue; } // Omega -> Lambda K - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeOmegaMinus, std::array{pdgCodeLambda, pdgCodeKaonMinus}, true)) { + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, +kOmegaMinus, std::array{+kLambda0, +kKMinus}, true)) { debugGenCasc = 1; for (const auto& daughterCascade : daughterCharm.template daughters_as()) { - if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { + if (std::abs(daughterCascade.pdgCode()) != +kLambda0) { continue; } // Lambda -> p pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, +kLambda0, std::array{+kProton, +kPiMinus}, true)) { debugGenLambda = 1; flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi); } @@ -2205,10 +2899,10 @@ struct HfCandidateCreatorXic0Omegac0Mc { // Check whether the charm baryon is non-prompt (from a b quark) if (flag != 0) { origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - if (std::abs(rapidityCharmBaryonGen) < 0.5) { + if (std::abs(rapidityCharmBaryonGen) < kRapidityCutTight) { hGenCharmBaryonPtRapidityTightOmegacToOmegaPi->SetBinContent(hGenCharmBaryonPtRapidityTightOmegacToOmegaPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityTightOmegacToOmegaPi->GetBinContent(hGenCharmBaryonPtRapidityTightOmegacToOmegaPi->FindBin(ptCharmBaryonGen)) + 1); } - if (std::abs(rapidityCharmBaryonGen) < 0.8) { + if (std::abs(rapidityCharmBaryonGen) < kRapidityCutLoose) { hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi->SetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi->GetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi->FindBin(ptCharmBaryonGen)) + 1); } } @@ -2220,23 +2914,23 @@ struct HfCandidateCreatorXic0Omegac0Mc { } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { // Omegac → Omega K - if (RecoDecay::isMatchedMCGen(mcParticles, particle, pdgCodeOmegac0, std::array{pdgCodeOmegaMinus, pdgCodeKaonPlus}, true, &sign)) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, +kOmegaC0, std::array{+kOmegaMinus, +kKPlus}, true, &sign)) { debugGenCharmBar = 1; ptCharmBaryonGen = particle.pt(); rapidityCharmBaryonGen = particle.y(); for (const auto& daughterCharm : particle.template daughters_as()) { - if (std::abs(daughterCharm.pdgCode()) != pdgCodeOmegaMinus) { + if (std::abs(daughterCharm.pdgCode()) != +kOmegaMinus) { continue; } // Omega -> Lambda K - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeOmegaMinus, std::array{pdgCodeLambda, pdgCodeKaonMinus}, true)) { + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, +kOmegaMinus, std::array{+kLambda0, +kKMinus}, true)) { debugGenCasc = 1; for (const auto& daughterCascade : daughterCharm.template daughters_as()) { - if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { + if (std::abs(daughterCascade.pdgCode()) != +kLambda0) { continue; } // Lambda -> p pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, +kLambda0, std::array{+kProton, +kPiMinus}, true)) { debugGenLambda = 1; flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK); } @@ -2247,10 +2941,10 @@ struct HfCandidateCreatorXic0Omegac0Mc { // Check whether the charm baryon is non-prompt (from a b quark) if (flag != 0) { origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - if (std::abs(rapidityCharmBaryonGen) < 0.5) { + if (std::abs(rapidityCharmBaryonGen) < kRapidityCutTight) { hGenCharmBaryonPtRapidityTightOmegacToOmegaK->SetBinContent(hGenCharmBaryonPtRapidityTightOmegacToOmegaK->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityTightOmegacToOmegaK->GetBinContent(hGenCharmBaryonPtRapidityTightOmegacToOmegaK->FindBin(ptCharmBaryonGen)) + 1); } - if (std::abs(rapidityCharmBaryonGen) < 0.8) { + if (std::abs(rapidityCharmBaryonGen) < kRapidityCutLoose) { hGenCharmBaryonPtRapidityLooseOmegacToOmegaK->SetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToOmegaK->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityLooseOmegacToOmegaK->GetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToOmegaK->FindBin(ptCharmBaryonGen)) + 1); } } @@ -2264,6 +2958,236 @@ struct HfCandidateCreatorXic0Omegac0Mc { } // close loop on MCCollisions } // close process + template + void runXic0Omegac0McQa(TMyRecoCand const& candidates, + MyTracksWMc const&, + aod::McParticles const& mcParticles, + BCsInfo const&) + { + int indexRec = -1; + int8_t sign = -9; + int8_t signCasc = -9; + int8_t signV0 = -9; + + for (const auto& candidate : candidates) { + + auto arrayDaughters = std::array{candidate.template bachelorFromCharmBaryon_as(), // bachelor <- charm baryon + candidate.template bachelor_as(), // bachelor <- cascade + candidate.template posTrack_as(), // p <- lambda + candidate.template negTrack_as()}; // pi <- lambda + auto arrayDaughtersCasc = std::array{candidate.template bachelor_as(), + candidate.template posTrack_as(), + candidate.template negTrack_as()}; + auto arrayDaughtersV0 = std::array{candidate.template posTrack_as(), + candidate.template negTrack_as()}; + + auto mcV0DauPos = arrayDaughtersV0[0].mcParticle(); + auto mcV0DauNeg = arrayDaughtersV0[1].mcParticle(); + auto mcXiBachelor = arrayDaughtersCasc[0].mcParticle(); + auto mcXic0Bachelor = arrayDaughters[0].mcParticle(); + + // Xic0 -> xi pi matching + if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { + // Lambda → p pi + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &signV0, 1); + if (indexRec > -1 && signV0 == 1) { + auto mcV0 = mcParticles.rawIteratorAt(indexRec - mcParticles.offset()); + + float v0MassPull = (candidate.invMassLambda() - MassLambda0) / candidate.invMassV0Err(); + registry.fill(HIST("hV0MassPullVsPt"), candidate.v0Pt(), v0MassPull); + + float v0DauPosXDelta = candidate.v0DauPosX() - mcV0DauPos.vx(); + float v0DauPosYDelta = candidate.v0DauPosY() - mcV0DauPos.vy(); + float v0DauPosZDelta = candidate.v0DauPosZ() - mcV0DauPos.vz(); + float v0DauPosPt = mcV0DauPos.pt(); + float v0DauPosXPull = v0DauPosXDelta / candidate.v0DauPosXError(); + float v0DauPosYPull = v0DauPosYDelta / candidate.v0DauPosYError(); + float v0DauPosZPull = v0DauPosZDelta / candidate.v0DauPosZError(); + + float v0DauNegXDelta = candidate.v0DauNegX() - mcV0DauNeg.vx(); + float v0DauNegYDelta = candidate.v0DauNegY() - mcV0DauNeg.vy(); + float v0DauNegZDelta = candidate.v0DauNegZ() - mcV0DauNeg.vz(); + float v0DauNegPt = mcV0DauNeg.pt(); + float v0DauNegXPull = v0DauNegXDelta / candidate.v0DauNegXError(); + float v0DauNegYPull = v0DauNegYDelta / candidate.v0DauNegYError(); + float v0DauNegZPull = v0DauNegZDelta / candidate.v0DauNegZError(); + + float v0XDelta = candidate.v0VtxX() - mcV0DauNeg.vx(); + float v0YDelta = candidate.v0VtxY() - mcV0DauNeg.vy(); + float v0ZDelta = candidate.v0VtxZ() - mcV0DauNeg.vz(); + float v0Pt = mcV0.pt(); + float v0XPull = v0XDelta / candidate.v0XError(); + float v0YPull = v0YDelta / candidate.v0YError(); + float v0ZPull = v0ZDelta / candidate.v0ZError(); + + float lambdaXDelta = candidate.v0X() - mcV0DauNeg.vx(); + float lambdaYDelta = candidate.v0Y() - mcV0DauNeg.vy(); + float lambdaZDelta = candidate.v0Z() - mcV0DauNeg.vz(); + registry.fill(HIST("hV0DauPosXDelta"), v0DauPosXDelta); + registry.fill(HIST("hV0DauPosYDelta"), v0DauPosYDelta); + registry.fill(HIST("hV0DauPosZDelta"), v0DauPosZDelta); + registry.fill(HIST("hV0DauPosXDeltaVsPt"), v0DauPosPt, v0DauPosXDelta); + registry.fill(HIST("hV0DauPosYDeltaVsPt"), v0DauPosPt, v0DauPosYDelta); + registry.fill(HIST("hV0DauPosZDeltaVsPt"), v0DauPosPt, v0DauPosZDelta); + registry.fill(HIST("hV0DauPosXPull"), v0DauPosXPull); + registry.fill(HIST("hV0DauPosYPull"), v0DauPosYPull); + registry.fill(HIST("hV0DauPosZPull"), v0DauPosZPull); + registry.fill(HIST("hV0DauPosXPullVsPt"), v0DauPosPt, v0DauPosXPull); + registry.fill(HIST("hV0DauPosYPullVsPt"), v0DauPosPt, v0DauPosYPull); + registry.fill(HIST("hV0DauPosZPullVsPt"), v0DauPosPt, v0DauPosZPull); + + registry.fill(HIST("hV0DauNegXDelta"), v0DauNegXDelta); + registry.fill(HIST("hV0DauNegYDelta"), v0DauNegYDelta); + registry.fill(HIST("hV0DauNegZDelta"), v0DauNegZDelta); + registry.fill(HIST("hV0DauNegXDeltaVsPt"), v0DauNegPt, v0DauNegXDelta); + registry.fill(HIST("hV0DauNegYDeltaVsPt"), v0DauNegPt, v0DauNegYDelta); + registry.fill(HIST("hV0DauNegZDeltaVsPt"), v0DauNegPt, v0DauNegZDelta); + registry.fill(HIST("hV0DauNegXPull"), v0DauNegXPull); + registry.fill(HIST("hV0DauNegYPull"), v0DauNegYPull); + registry.fill(HIST("hV0DauNegZPull"), v0DauNegZPull); + registry.fill(HIST("hV0DauNegXPullVsPt"), v0DauNegPt, v0DauNegXPull); + registry.fill(HIST("hV0DauNegYPullVsPt"), v0DauNegPt, v0DauNegYPull); + registry.fill(HIST("hV0DauNegZPullVsPt"), v0DauNegPt, v0DauNegZPull); + + registry.fill(HIST("hV0XDelta"), v0XDelta); + registry.fill(HIST("hV0YDelta"), v0YDelta); + registry.fill(HIST("hV0ZDelta"), v0ZDelta); + registry.fill(HIST("hV0XDeltaVsPt"), v0Pt, v0XDelta); + registry.fill(HIST("hV0YDeltaVsPt"), v0Pt, v0YDelta); + registry.fill(HIST("hV0ZDeltaVsPt"), v0Pt, v0ZDelta); + registry.fill(HIST("hV0XPull"), v0XPull); + registry.fill(HIST("hV0YPull"), v0YPull); + registry.fill(HIST("hV0ZPull"), v0ZPull); + registry.fill(HIST("hV0XPullVsPt"), v0Pt, v0XPull); + registry.fill(HIST("hV0YPullVsPt"), v0Pt, v0YPull); + registry.fill(HIST("hV0ZPullVsPt"), v0Pt, v0ZPull); + + registry.fill(HIST("hLambdaXDelta"), lambdaXDelta); + registry.fill(HIST("hLambdaYDelta"), lambdaYDelta); + registry.fill(HIST("hLambdaZDelta"), lambdaZDelta); + + registry.fill(HIST("hV0DauPosPtRes"), (candidate.v0DauPosPt() - mcV0DauPos.pt()) / candidate.v0DauPosPt()); + registry.fill(HIST("hV0DauNegPtRes"), (candidate.v0DauNegPt() - mcV0DauNeg.pt()) / candidate.v0DauNegPt()); + registry.fill(HIST("hV0PtRes"), (candidate.v0Pt() - mcV0.pt()) / candidate.v0Pt()); + // Xi- → pi pi p + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, &signCasc, 2); + if (indexRec > -1 && signCasc == 1) { + // QA + float xiMassPull = (candidate.invMassCascade() - MassXiMinus) / candidate.invMassXiErr(); + registry.fill(HIST("hXiMassPullVsPt"), candidate.xiPt(), xiMassPull); + + float xiBachelorXDelta = candidate.xiBachelorX() - mcXiBachelor.vx(); + float xiBachelorYDelta = candidate.xiBachelorY() - mcXiBachelor.vy(); + float xiBachelorZDelta = candidate.xiBachelorZ() - mcXiBachelor.vz(); + float xiBachelorPt = mcXiBachelor.pt(); + float xiBachelorXPull = xiBachelorXDelta / candidate.xiBachelorXError(); + float xiBachelorYPull = xiBachelorYDelta / candidate.xiBachelorYError(); + float xiBachelorZPull = xiBachelorZDelta / candidate.xiBachelorZError(); + + auto mcXi = mcParticles.rawIteratorAt(indexRec - mcParticles.offset()); + + float xiXDelta = candidate.xiX() - mcXiBachelor.vx(); + float xiYDelta = candidate.xiY() - mcXiBachelor.vy(); + float xiZDelta = candidate.xiZ() - mcXiBachelor.vz(); + float xiPt = mcXi.pt(); + float xiXPull = xiXDelta / candidate.xiXError(); + float xiYPull = xiYDelta / candidate.xiYError(); + float xiZPull = xiZDelta / candidate.xiZError(); + + float cascXDelta = candidate.xDecayVtxCascade() - mcXiBachelor.vx(); + float cascYDelta = candidate.yDecayVtxCascade() - mcXiBachelor.vy(); + float cascZDelta = candidate.zDecayVtxCascade() - mcXiBachelor.vz(); + + registry.fill(HIST("hXiBachelorXDelta"), xiBachelorXDelta); + registry.fill(HIST("hXiBachelorYDelta"), xiBachelorYDelta); + registry.fill(HIST("hXiBachelorZDelta"), xiBachelorZDelta); + registry.fill(HIST("hXiBachelorXDeltaVsPt"), xiBachelorPt, xiBachelorXDelta); + registry.fill(HIST("hXiBachelorYDeltaVsPt"), xiBachelorPt, xiBachelorYDelta); + registry.fill(HIST("hXiBachelorZDeltaVsPt"), xiBachelorPt, xiBachelorZDelta); + registry.fill(HIST("hXiBachelorXPull"), xiBachelorXPull); + registry.fill(HIST("hXiBachelorYPull"), xiBachelorYPull); + registry.fill(HIST("hXiBachelorZPull"), xiBachelorZPull); + registry.fill(HIST("hXiBachelorXPullVsPt"), xiBachelorPt, xiBachelorXPull); + registry.fill(HIST("hXiBachelorYPullVsPt"), xiBachelorPt, xiBachelorYPull); + registry.fill(HIST("hXiBachelorZPullVsPt"), xiBachelorPt, xiBachelorZPull); + + registry.fill(HIST("hXiXDelta"), xiXDelta); + registry.fill(HIST("hXiYDelta"), xiYDelta); + registry.fill(HIST("hXiZDelta"), xiZDelta); + registry.fill(HIST("hXiXDeltaVsPt"), xiPt, xiXDelta); + registry.fill(HIST("hXiYDeltaVsPt"), xiPt, xiYDelta); + registry.fill(HIST("hXiZDeltaVsPt"), xiPt, xiZDelta); + registry.fill(HIST("hXiXPull"), xiXPull); + registry.fill(HIST("hXiYPull"), xiYPull); + registry.fill(HIST("hXiZPull"), xiZPull); + registry.fill(HIST("hXiXPullVsPt"), xiPt, xiXPull); + registry.fill(HIST("hXiYPullVsPt"), xiPt, xiYPull); + registry.fill(HIST("hXiZPullVsPt"), xiPt, xiZPull); + + registry.fill(HIST("hCascXDelta"), cascXDelta); + registry.fill(HIST("hCascYDelta"), cascYDelta); + registry.fill(HIST("hCascZDelta"), cascZDelta); + + registry.fill(HIST("hXiBachelorPtRes"), (candidate.xiBachelorPt() - mcXiBachelor.pt()) / candidate.xiBachelorPt()); + registry.fill(HIST("hXiPtRes"), (candidate.xiPt() - mcXi.pt()) / candidate.xiPt()); + + // Xic → pi pi pi p + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, +kXiC0, std::array{+kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 3); + if (indexRec > -1 && sign == 1) { + auto mcXic0 = mcParticles.rawIteratorAt(indexRec - mcParticles.offset()); + float xic0MassPull = (candidate.invMassCharmBaryon() - MassXiC0) / candidate.invMassXic0Err(); + registry.fill(HIST("hXic0MassPullVsPt"), candidate.xic0Pt(), xic0MassPull); + + float xic0BachelorXDelta = candidate.xic0BachelorX() - mcXic0Bachelor.vx(); + float xic0BachelorYDelta = candidate.xic0BachelorY() - mcXic0Bachelor.vy(); + float xic0BachelorZDelta = candidate.xic0BachelorZ() - mcXic0Bachelor.vz(); + float xic0BachelorPt = mcXic0Bachelor.pt(); + float xic0BachelorXPull = xic0BachelorXDelta / candidate.xic0BachelorXError(); + float xic0BachelorYPull = xic0BachelorYDelta / candidate.xic0BachelorYError(); + float xic0BachelorZPull = xic0BachelorZDelta / candidate.xic0BachelorZError(); + + float xic0XDelta = candidate.xDecayVtxCharmBaryon() - mcXic0Bachelor.vx(); + float xic0YDelta = candidate.yDecayVtxCharmBaryon() - mcXic0Bachelor.vy(); + float xic0ZDelta = candidate.zDecayVtxCharmBaryon() - mcXic0Bachelor.vz(); + float xic0Pt = mcXic0.pt(); + float xic0XPull = xic0XDelta / candidate.xic0XError(); + float xic0YPull = xic0YDelta / candidate.xic0YError(); + float xic0ZPull = xic0ZDelta / candidate.xic0ZError(); + registry.fill(HIST("hXic0BachelorXDelta"), xic0BachelorXDelta); + registry.fill(HIST("hXic0BachelorYDelta"), xic0BachelorYDelta); + registry.fill(HIST("hXic0BachelorZDelta"), xic0BachelorZDelta); + registry.fill(HIST("hXic0BachelorXDeltaVsPt"), xic0BachelorPt, xic0BachelorXDelta); + registry.fill(HIST("hXic0BachelorYDeltaVsPt"), xic0BachelorPt, xic0BachelorYDelta); + registry.fill(HIST("hXic0BachelorZDeltaVsPt"), xic0BachelorPt, xic0BachelorZDelta); + registry.fill(HIST("hXic0BachelorXPull"), xic0BachelorXPull); + registry.fill(HIST("hXic0BachelorYPull"), xic0BachelorYPull); + registry.fill(HIST("hXic0BachelorZPull"), xic0BachelorZPull); + registry.fill(HIST("hXic0BachelorXPullVsPt"), xic0BachelorPt, xic0BachelorXPull); + registry.fill(HIST("hXic0BachelorYPullVsPt"), xic0BachelorPt, xic0BachelorYPull); + registry.fill(HIST("hXic0BachelorZPullVsPt"), xic0BachelorPt, xic0BachelorZPull); + + registry.fill(HIST("hXic0XDelta"), xic0XDelta); + registry.fill(HIST("hXic0YDelta"), xic0YDelta); + registry.fill(HIST("hXic0ZDelta"), xic0ZDelta); + registry.fill(HIST("hXic0XDeltaVsPt"), xic0Pt, xic0XDelta); + registry.fill(HIST("hXic0YDeltaVsPt"), xic0Pt, xic0YDelta); + registry.fill(HIST("hXic0ZDeltaVsPt"), xic0Pt, xic0ZDelta); + registry.fill(HIST("hXic0XPull"), xic0XPull); + registry.fill(HIST("hXic0YPull"), xic0YPull); + registry.fill(HIST("hXic0ZPull"), xic0ZPull); + registry.fill(HIST("hXic0XPullVsPt"), xic0Pt, xic0XPull); + registry.fill(HIST("hXic0YPullVsPt"), xic0Pt, xic0YPull); + registry.fill(HIST("hXic0ZPullVsPt"), xic0Pt, xic0ZPull); + + registry.fill(HIST("hXic0BachelorPtRes"), (candidate.xic0BachelorPt() - mcXic0Bachelor.pt()) / candidate.xic0BachelorPt()); + registry.fill(HIST("hXic0PtRes"), (candidate.xic0Pt() - mcXic0.pt()) / candidate.xic0Pt()); + } + } + } + } + } + } + void processDoNoMc(aod::Collisions::iterator const&) { // dummy process function - should not be required in the future @@ -2292,6 +3216,15 @@ struct HfCandidateCreatorXic0Omegac0Mc { } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcXicToXiPiKf, "Run Xic0 to xi pi MC process function - no centrality", false); + void processMcXicToXiPiKfQa(aod::HfCandToXiPiKfQa const& candidates, + MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + BCsInfo const& bcs) + { + runXic0Omegac0McQa(candidates, tracks, mcParticles, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcXicToXiPiKfQa, "Run Xic0 to xi pi MC QA process function - no centrality", false); + void processMcXicToXiPiFT0m(aod::HfCandToXiPi const& candidates, MyTracksWMc const& tracks, aod::McParticles const& mcParticles, diff --git a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx index c0431900292..5fea174e4f9 100644 --- a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx @@ -14,45 +14,70 @@ /// /// \author Phil Lennart Stahlhut , Heidelberg University /// \author Carolina Reetz , Heidelberg University +/// \author Jaeyoon Cho , Inha University /// \author Jinjoo Seo , Heidelberg University #ifndef HomogeneousField -#define HomogeneousField +#define HomogeneousField // o2-linter: disable=name/macro (required by KFParticle) #endif -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/mcCentrality.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" #include "Tools/KFparticle/KFUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; -using namespace o2::analysis; -using namespace o2::aod::hf_cand_xic_to_xi_pi_pi; using namespace o2::constants::physics; using namespace o2::framework; +using namespace o2::hf_evsel; +using namespace o2::hf_centrality; +using namespace o2::hf_occupancy; +using namespace o2::aod::hf_cand_xic_to_xi_pi_pi; /// Reconstruction of heavy-flavour 3-prong decay candidates struct HfCandidateCreatorXicToXiPiPi { @@ -79,8 +104,8 @@ struct HfCandidateCreatorXicToXiPiPi { Configurable useAbsDCA{"useAbsDCA", false, "Minimise abs. distance rather than chi2"}; Configurable useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; // KFParticle + Configurable useXiMassConstraint{"useXiMassConstraint", true, "Use mass constraint for Xi"}; Configurable constrainXicPlusToPv{"constrainXicPlusToPv", false, "Constrain XicPlus to PV"}; - Configurable constrainXiToXicPlus{"constrainXiToXicPlus", false, "Constrain Xi to XicPlus"}; Configurable kfConstructMethod{"kfConstructMethod", 2, "Construct method of XicPlus: 0 fast mathematics without constraint of fixed daughter particle masses, 2 daughter particle masses stay fixed in construction process"}; Configurable rejDiffCollTrack{"rejDiffCollTrack", true, "Reject tracks coming from different collisions (effective only for KFParticle w/o derived data)"}; @@ -90,12 +115,15 @@ struct HfCandidateCreatorXicToXiPiPi { o2::vertexing::DCAFitterN<3> df; + HfEventSelection hfEvSel; + int runNumber{0}; float massXiPiPi{0.}; float massXiPi0{0.}; float massXiPi1{0.}; double bz{0.}; - enum XicCandCounter { AllIdTriplets = 0, + enum XicCandCounter { TotalSkimmedTriplets = 0, + SelEvent, CascPreSel, VertexFit }; @@ -110,19 +138,21 @@ struct HfCandidateCreatorXicToXiPiPi { void init(InitContext const&) { - if ((doprocessXicplusWithDcaFitter + doprocessXicplusWithKFParticle) != 1) { - LOGP(fatal, "Only one process function can be enabled at a time."); + if ((doprocessNoCentXicplusWithDcaFitter + doprocessCentFT0CXicplusWithDcaFitter + doprocessCentFT0MXicplusWithDcaFitter + doprocessNoCentXicplusWithKFParticle + doprocessCentFT0CXicplusWithKFParticle + doprocessCentFT0MXicplusWithKFParticle) != 1) { + LOGP(fatal, "Only one process function for the Xic reconstruction can be enabled at a time."); } // add histograms to registry + registry.add("hVertexerType", "Use DCAFitter or KFParticle;;entries", {HistType::kTH1F, {{2, -0.5, 1.5}}}); + registry.get(HIST("hVertexerType"))->GetXaxis()->SetBinLabel(1 + aod::hf_cand::VertexerType::DCAFitter, "DCAFitter"); + registry.get(HIST("hVertexerType"))->GetXaxis()->SetBinLabel(1 + aod::hf_cand::VertexerType::KfParticle, "KFParticle"); + registry.add("hCandCounter", "hCandCounter", {HistType::kTH1D, {{4, -0.5, 3.5}}}); + registry.get(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + TotalSkimmedTriplets, "total"); + registry.get(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + SelEvent, "Event selected"); + registry.get(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + CascPreSel, "Cascade preselection"); + registry.get(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + VertexFit, "Successful vertex fit"); + // physical variables if (fillHistograms) { - // counter - registry.add("hVertexerType", "Use KF or DCAFitterN;Vertexer type;entries", {HistType::kTH1F, {{2, -0.5, 1.5}}}); // See o2::aod::hf_cand::VertexerType - registry.add("hCandCounter", "hCandCounter", {HistType::kTH1F, {{3, 0.f, 0.3}}}); - registry.get(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + AllIdTriplets, "total"); - registry.get(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + CascPreSel, "Cascade preselection"); - registry.get(HIST("hCandCounter"))->GetXaxis()->SetBinLabel(1 + VertexFit, "Successful vertex fit"); - // physical variables registry.add("hMass3", "3-prong candidates;inv. mass (#Xi #pi #pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 2.3, 2.7}}}); registry.add("hCovPVXX", "3-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1D, {{100, 0., 1.e-4}}}); registry.add("hCovSVXX", "3-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", {HistType::kTH1D, {{100, 0., 0.2}}}); @@ -137,10 +167,10 @@ struct HfCandidateCreatorXicToXiPiPi { } // fill hVertexerType histogram - if (doprocessXicplusWithDcaFitter && fillHistograms) { + if ((doprocessNoCentXicplusWithDcaFitter || doprocessCentFT0CXicplusWithDcaFitter || doprocessCentFT0MXicplusWithDcaFitter) && fillHistograms) { registry.fill(HIST("hVertexerType"), aod::hf_cand::VertexerType::DCAFitter); } - if (doprocessXicplusWithKFParticle && fillHistograms) { + if ((doprocessNoCentXicplusWithKFParticle || doprocessCentFT0CXicplusWithKFParticle || doprocessCentFT0MXicplusWithKFParticle) && fillHistograms) { registry.fill(HIST("hVertexerType"), aod::hf_cand::VertexerType::KfParticle); } @@ -151,6 +181,9 @@ struct HfCandidateCreatorXicToXiPiPi { lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); runNumber = 0; + // initialize HF event selection helper + hfEvSel.init(registry); + // initialize 3-prong vertex fitter df.setPropagateToPCA(propagateToPCA); df.setMaxR(maxR); @@ -161,15 +194,29 @@ struct HfCandidateCreatorXicToXiPiPi { df.setWeightedFinalPCA(useWeightedFinalPCA); } - void processXicplusWithDcaFitter(aod::Collisions const&, - aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, - CascadesLinked const&, - CascFull const&, - TracksWCovDcaPidPrPi const&, - aod::BCsWithTimestamps const&) + template + void runXicplusCreatorWithDcaFitter(Collision const&, + aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, + CascadesLinked const&, + CascFull const&, + TracksWCovDcaPidPrPi const&, + aod::BCsWithTimestamps const&) { // loop over triplets of track indices for (const auto& rowTrackIndexXicPlus : rowsTrackIndexXicPlus) { + registry.fill(HIST("hCandCounter"), TotalSkimmedTriplets); + + // check if the event is selected + auto collision = rowTrackIndexXicPlus.collision_as(); + float centrality{-1.f}; + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the candidate + continue; + } + registry.fill(HIST("hCandCounter"), SelEvent); + + // Retrieve skimmed cascade and pion tracks auto cascAodElement = rowTrackIndexXicPlus.cascade_as(); if (!cascAodElement.has_cascData()) { continue; @@ -177,8 +224,6 @@ struct HfCandidateCreatorXicToXiPiPi { auto casc = cascAodElement.cascData_as(); auto trackCharmBachelor0 = rowTrackIndexXicPlus.prong0_as(); auto trackCharmBachelor1 = rowTrackIndexXicPlus.prong1_as(); - auto collision = rowTrackIndexXicPlus.collision(); - registry.fill(HIST("hCandCounter"), 1 + AllIdTriplets); // preselect cascade candidates if (doCascadePreselection) { @@ -189,12 +234,12 @@ struct HfCandidateCreatorXicToXiPiPi { continue; } } - registry.fill(HIST("hCandCounter"), 1 + CascPreSel); + registry.fill(HIST("hCandCounter"), CascPreSel); //----------------------Set the magnetic field from ccdb--------------------------------------- /// The static instance of the propagator was already modified in the HFTrackIndexSkimCreator, /// but this is not true when running on Run2 data/MC already converted into AO2Ds. - auto bc = collision.bc_as(); + auto bc = collision.template bc_as(); if (runNumber != bc.runNumber()) { LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; initCCDB(bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, isRun2); @@ -211,10 +256,11 @@ struct HfCandidateCreatorXicToXiPiPi { std::array covCasc = {0.}; //----------------create cascade track------------------------------------------------------------ - constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component - for (int i = 0; i < 6; i++) { - covCasc[MomInd[i]] = casc.momentumCovMat()[i]; + constexpr std::size_t NElementsCovMatrix{6u}; + constexpr std::array MomInd = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (auto i = 0u; i < NElementsCovMatrix; i++) { covCasc[i] = casc.positionCovMat()[i]; + covCasc[MomInd[i]] = casc.momentumCovMat()[i]; } // create cascade track o2::track::TrackParCov trackCasc; @@ -241,11 +287,11 @@ struct HfCandidateCreatorXicToXiPiPi { LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; continue; } - registry.fill(HIST("hCandCounter"), 1 + VertexFit); + registry.fill(HIST("hCandCounter"), VertexFit); //----------------------------calculate physical properties----------------------- // Charge of charm baryon - int signXic = casc.sign() < 0 ? +1 : -1; + int8_t signXic = casc.sign() < 0 ? +1 : -1; // get SV properties const auto& secondaryVertex = df.getPCACandidate(); @@ -380,17 +426,30 @@ struct HfCandidateCreatorXicToXiPiPi { nSigTofPiFromXicPlus0, nSigTofPiFromXicPlus1, nSigTofBachelorPi, nSigTofPiFromLambda, nSigTofPrFromLambda); } // loop over track triplets } - PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processXicplusWithDcaFitter, "Run candidate creator with DCAFitter.", true); - - void processXicplusWithKFParticle(aod::Collisions const&, - aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, - KFCascadesLinked const&, - KFCascFull const&, - TracksWCovExtraPidPrPi const&, - aod::BCsWithTimestamps const&) + + template + void runXicplusCreatorWithKFParticle(Collision const&, + aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, + KFCascadesLinked const&, + KFCascFull const&, + TracksWCovExtraPidPrPi const&, + aod::BCsWithTimestamps const&) { // loop over triplets of track indices for (const auto& rowTrackIndexXicPlus : rowsTrackIndexXicPlus) { + registry.fill(HIST("hCandCounter"), TotalSkimmedTriplets); + + // check if the event is selected + auto collision = rowTrackIndexXicPlus.collision_as(); + float centrality{-1.f}; + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + if (rejectionMask != 0) { + /// at least one event selection not satisfied --> reject the candidate + continue; + } + registry.fill(HIST("hCandCounter"), SelEvent); + + // Retrieve skimmed cascade and pion tracks auto cascAodElement = rowTrackIndexXicPlus.cascade_as(); if (!cascAodElement.has_kfCascData()) { continue; @@ -398,8 +457,6 @@ struct HfCandidateCreatorXicToXiPiPi { auto casc = cascAodElement.kfCascData_as(); auto trackCharmBachelor0 = rowTrackIndexXicPlus.prong0_as(); auto trackCharmBachelor1 = rowTrackIndexXicPlus.prong1_as(); - auto collision = rowTrackIndexXicPlus.collision(); - registry.fill(HIST("hCandCounter"), 1 + AllIdTriplets); //-------------------preselect cascade candidates-------------------------------------- if (doCascadePreselection) { @@ -410,12 +467,12 @@ struct HfCandidateCreatorXicToXiPiPi { continue; } } - registry.fill(HIST("hCandCounter"), 1 + CascPreSel); + registry.fill(HIST("hCandCounter"), CascPreSel); //----------------------Set the magnetic field from ccdb----------------------------- /// The static instance of the propagator was already modified in the HFTrackIndexSkimCreator, /// but this is not true when running on Run2 data/MC already converted into AO2Ds. - auto bc = collision.bc_as(); + auto bc = collision.template bc_as(); if (runNumber != bc.runNumber()) { LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; initCCDB(bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, isRun2); @@ -435,7 +492,7 @@ struct HfCandidateCreatorXicToXiPiPi { KFPVertex kfpVertex = createKFPVertexFromCollision(collision); float covMatrixPV[6]; kfpVertex.GetCovarianceMatrix(covMatrixPV); - KFParticle KFPV(kfpVertex); // for calculation of DCAs to PV + KFParticle kfPv(kfpVertex); // for calculation of DCAs to PV // convert pion tracks into KFParticle object KFPTrack kfpTrackCharmBachelor0 = createKFPTrackFromTrack(trackCharmBachelor0); @@ -445,14 +502,17 @@ struct HfCandidateCreatorXicToXiPiPi { // create Xi as KFParticle object // read {X,Y,Z,Px,Py,Pz} and corresponding covariance matrix from KF cascade Tables - std::array xyzpxpypz = {casc.x(), casc.y(), casc.z(), casc.px(), casc.py(), casc.pz()}; - float parPosMom[6]; - for (int i{0}; i < 6; ++i) { - parPosMom[i] = xyzpxpypz[i]; - } + constexpr std::size_t NElementsStateVector{6}; + std::array xyzpxpypz = {casc.x(), casc.y(), casc.z(), casc.px(), casc.py(), casc.pz()}; + float parPosMom[NElementsStateVector]; + std::copy(xyzpxpypz.begin(), xyzpxpypz.end(), parPosMom); // create KFParticle KFParticle kfXi; - kfXi.Create(parPosMom, casc.kfTrackCovMat(), casc.sign(), casc.mXi()); + float massXi = casc.mXi(); + kfXi.Create(parPosMom, casc.kfTrackCovMat(), casc.sign(), massXi); + if (useXiMassConstraint) { + kfXi.SetNonlinearMassConstraint(MassXiMinus); + } // create XicPlus as KFParticle object KFParticle kfXicPlus; @@ -464,46 +524,27 @@ struct HfCandidateCreatorXicToXiPiPi { LOG(debug) << "Failed to construct XicPlus : " << e.what(); continue; } - registry.fill(HIST("hCandCounter"), 1 + VertexFit); + registry.fill(HIST("hCandCounter"), VertexFit); - // get geometrical chi2 of XicPlus + // get chi2 values float chi2GeoXicPlus = kfXicPlus.GetChi2() / kfXicPlus.GetNDF(); + float chi2PrimXi = kfXi.GetDeviationFromVertex(kfPv); + float chi2PrimPi0 = kfCharmBachelor0.GetDeviationFromVertex(kfPv); + float chi2PrimPi1 = kfCharmBachelor1.GetDeviationFromVertex(kfPv); // topological constraint of Xic to PV - float chi2topoXicPlusToPVBeforeConstraint = kfXicPlus.GetDeviationFromVertex(KFPV); + float chi2TopoXicPlusToPVBefConst = kfXicPlus.GetDeviationFromVertex(kfPv); KFParticle kfXicPlusToPV = kfXicPlus; - kfXicPlusToPV.SetProductionVertex(KFPV); - float chi2topoXicPlusToPV = kfXicPlusToPV.GetChi2() / kfXicPlusToPV.GetNDF(); + kfXicPlusToPV.SetProductionVertex(kfPv); + float chi2TopoXicPlusToPV = kfXicPlusToPV.GetChi2() / kfXicPlusToPV.GetNDF(); if (constrainXicPlusToPv) { kfXicPlus = kfXicPlusToPV; kfXicPlus.TransportToDecayVertex(); } - // topological constraint of Xi to XicPlus - float chi2topoXiToXicPlusBeforeConstraint = kfXi.GetDeviationFromVertex(kfXicPlus); - KFParticle kfXiToXicPlus = kfXi; - kfXiToXicPlus.SetProductionVertex(kfXicPlus); - float chi2topoXiToXicPlus = kfXiToXicPlus.GetChi2() / kfXiToXicPlus.GetNDF(); - kfXiToXicPlus.TransportToDecayVertex(); - if (constrainXiToXicPlus) { - KFParticle kfXicPlusWithXiToXicPlus; - const KFParticle* kfDaughtersXicPlusWithXiToXicPlus[3] = {&kfCharmBachelor0, &kfCharmBachelor1, &kfXiToXicPlus}; - kfXicPlusWithXiToXicPlus.SetConstructMethod(kfConstructMethod); - try { - kfXicPlusWithXiToXicPlus.Construct(kfDaughtersXicPlusWithXiToXicPlus, 3); - } catch (std::runtime_error& e) { - LOG(debug) << "Failed to construct XicPlus with Xi connstrained to XicPlus: " << e.what(); - continue; - } - kfXicPlus = kfXicPlusWithXiToXicPlus; - } - - // get covariance matrix of XicPlus - auto covMatrixXicPlus = kfXicPlus.CovarianceMatrix(); - //---------------------calculate physical parameters of XicPlus candidate---------------------- // sign of charm baryon - int signXic = casc.sign() < 0 ? +1 : -1; + int8_t signXic = casc.sign() < 0 ? +1 : -1; // transport XicPlus daughters to XicPlus decay vertex (secondary vertex) float secondaryVertex[3] = {0.}; @@ -518,9 +559,9 @@ struct HfCandidateCreatorXicToXiPiPi { float impactParameterPi0XY = 0., errImpactParameterPi0XY = 0.; float impactParameterPi1XY = 0., errImpactParameterPi1XY = 0.; float impactParameterXiXY = 0., errImpactParameterXiXY = 0.; - kfCharmBachelor0.GetDistanceFromVertexXY(KFPV, impactParameterPi0XY, errImpactParameterPi0XY); - kfCharmBachelor1.GetDistanceFromVertexXY(KFPV, impactParameterPi1XY, errImpactParameterPi1XY); - kfXi.GetDistanceFromVertexXY(KFPV, impactParameterXiXY, errImpactParameterXiXY); + kfCharmBachelor0.GetDistanceFromVertexXY(kfPv, impactParameterPi0XY, errImpactParameterPi0XY); + kfCharmBachelor1.GetDistanceFromVertexXY(kfPv, impactParameterPi1XY, errImpactParameterPi1XY); + kfXi.GetDistanceFromVertexXY(kfPv, impactParameterXiXY, errImpactParameterXiXY); // calculate cosine of pointing angle std::array pvCoord = {collision.posX(), collision.posY(), collision.posZ()}; @@ -531,13 +572,18 @@ struct HfCandidateCreatorXicToXiPiPi { float cpaLambdaToXi = RecoDecay::cpa(vertexCasc, vertexV0, pVecV0); float cpaXYLambdaToXi = RecoDecay::cpaXY(vertexCasc, vertexV0, pVecV0); + // get chi2 deviation of Pi0-Pi1, Pi0-Xi, Pi1-Xi + float chi2DevPi0Pi1 = kfCharmBachelor0.GetDeviationFromParticle(kfCharmBachelor1); + float chi2DevPi0Xi = kfCharmBachelor0.GetDeviationFromParticle(kfXi); + float chi2DevPi1Xi = kfCharmBachelor1.GetDeviationFromParticle(kfXi); + // get DCAs of Pi0-Pi1, Pi0-Xi, Pi1-Xi - float dcaXYPi0Pi1 = kfCharmBachelor0.GetDistanceFromParticleXY(kfCharmBachelor1); - float dcaXYPi0Xi = kfCharmBachelor0.GetDistanceFromParticleXY(kfXi); - float dcaXYPi1Xi = kfCharmBachelor1.GetDistanceFromParticleXY(kfXi); float dcaPi0Pi1 = kfCharmBachelor0.GetDistanceFromParticle(kfCharmBachelor1); float dcaPi0Xi = kfCharmBachelor0.GetDistanceFromParticle(kfXi); float dcaPi1Xi = kfCharmBachelor1.GetDistanceFromParticle(kfXi); + float dcaXYPi0Pi1 = kfCharmBachelor0.GetDistanceFromParticleXY(kfCharmBachelor1); + float dcaXYPi0Xi = kfCharmBachelor0.GetDistanceFromParticleXY(kfXi); + float dcaXYPi1Xi = kfCharmBachelor1.GetDistanceFromParticleXY(kfXi); // mass of Xi-Pi0 pair KFParticle kfXiPi0; @@ -567,6 +613,14 @@ struct HfCandidateCreatorXicToXiPiPi { float errMassXiPiPi; kfXicPlus.GetMass(massXiPiPi, errMassXiPiPi); + // decay length of XicPlus + // use XicPlus constrained to PV (kfXicPlusToPV), since production point must be set before calling GetDecayLength(XY) on KFParticle + float kfDecayLength = 0., errorKfDecayLength = 0., kfDecayLengthXY = 0., errorKfDecayLengthXY = 0.; + kfXicPlusToPV.GetDecayLength(kfDecayLength, errorKfDecayLength); + kfXicPlusToPV.GetDecayLengthXY(kfDecayLengthXY, errorKfDecayLengthXY); + float kfDecayLengthNormalised = ldlFromKF(kfXicPlus, kfPv); + float kfDecayLengthXYNormalised = ldlXYFromKF(kfXicPlus, kfPv); + //--------------------- get PID information----------------------- float nSigTpcPiFromXicPlus0 = trackCharmBachelor0.tpcNSigmaPi(); float nSigTofPiFromXicPlus0 = trackCharmBachelor0.tofNSigmaPi(); @@ -606,6 +660,7 @@ struct HfCandidateCreatorXicToXiPiPi { registry.fill(HIST("hCovPVXZ"), covMatrixPV[3]); registry.fill(HIST("hCovPVZZ"), covMatrixPV[5]); // covariance matrix elements of SV + auto covMatrixXicPlus = kfXicPlus.CovarianceMatrix(); registry.fill(HIST("hCovSVXX"), covMatrixXicPlus[0]); registry.fill(HIST("hCovSVYY"), covMatrixXicPlus[2]); registry.fill(HIST("hCovSVXZ"), covMatrixXicPlus[3]); @@ -618,14 +673,14 @@ struct HfCandidateCreatorXicToXiPiPi { //------------------------------fill candidate table rows-------------------------------------- rowCandidateBase(collision.globalIndex(), - KFPV.GetX(), KFPV.GetY(), KFPV.GetZ(), + kfPv.GetX(), kfPv.GetY(), kfPv.GetZ(), std::sqrt(covMatrixPV[0]), std::sqrt(covMatrixPV[2]), std::sqrt(covMatrixPV[5]), /*3-prong specific columns*/ rowTrackIndexXicPlus.cascadeId(), rowTrackIndexXicPlus.prong0Id(), rowTrackIndexXicPlus.prong1Id(), casc.bachelorId(), casc.posTrackId(), casc.negTrackId(), secondaryVertex[0], secondaryVertex[1], secondaryVertex[2], kfXicPlus.GetErrX(), kfXicPlus.GetErrY(), kfXicPlus.GetErrZ(), - kfXicPlus.GetErrDecayLength(), kfXicPlus.GetErrDecayLengthXY(), + errorKfDecayLength, errorKfDecayLengthXY, chi2GeoXicPlus, massXiPiPi, signXic, kfXi.GetPx(), kfXi.GetPy(), kfXi.GetPz(), kfCharmBachelor0.GetPx(), kfCharmBachelor0.GetPy(), kfCharmBachelor0.GetPz(), @@ -635,21 +690,157 @@ struct HfCandidateCreatorXicToXiPiPi { /*cascade specific columns*/ trackPionFromXi.p(), pPiFromLambda, pPrFromLambda, cpaXi, cpaXYXi, cpaLambda, cpaXYLambda, cpaLambdaToXi, cpaXYLambdaToXi, - casc.mXi(), casc.mLambda(), massXiPi0, massXiPi1, + massXi, casc.mLambda(), massXiPi0, massXiPi1, /*DCA information*/ casc.dcacascdaughters(), casc.dcaV0daughters(), casc.dcapostopv(), casc.dcanegtopv(), casc.dcabachtopv(), casc.dcaXYCascToPV(), casc.dcaZCascToPV(), /*PID information*/ nSigTpcPiFromXicPlus0, nSigTpcPiFromXicPlus1, nSigTpcBachelorPi, nSigTpcPiFromLambda, nSigTpcPrFromLambda, nSigTofPiFromXicPlus0, nSigTofPiFromXicPlus1, nSigTofBachelorPi, nSigTofPiFromLambda, nSigTofPrFromLambda); - rowCandidateKF(casc.kfCascadeChi2(), casc.kfV0Chi2(), - chi2topoXicPlusToPVBeforeConstraint, chi2topoXicPlusToPV, chi2topoXiToXicPlusBeforeConstraint, chi2topoXiToXicPlus, - dcaXYPi0Pi1, dcaXYPi0Xi, dcaXYPi1Xi, + rowCandidateKF(kfDecayLength, kfDecayLengthNormalised, kfDecayLengthXY, kfDecayLengthXYNormalised, + casc.kfCascadeChi2(), casc.kfV0Chi2(), + chi2TopoXicPlusToPVBefConst, chi2TopoXicPlusToPV, + chi2PrimXi, chi2PrimPi0, chi2PrimPi1, + chi2DevPi0Pi1, chi2DevPi0Xi, chi2DevPi1Xi, dcaPi0Pi1, dcaPi0Xi, dcaPi1Xi, - casc.dcacascdaughters()); + dcaXYPi0Pi1, dcaXYPi0Xi, dcaXYPi1Xi); } // loop over track triplets } - PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processXicplusWithKFParticle, "Run candidate creator with KFParticle using derived data from HfTrackIndexSkimCreatorLfCascades.", false); + + /////////////////////////////////////////////////////////// + /// /// + /// Process functions with DCAFitter /// + /// /// + /////////////////////////////////////////////////////////// + + void processNoCentXicplusWithDcaFitter(soa::Join const& collisions, + aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, + CascadesLinked const& cascadesLinked, + CascFull const& cascadesFull, + TracksWCovDcaPidPrPi const& tracks, + aod::BCsWithTimestamps const& bcs) + { + runXicplusCreatorWithDcaFitter(collisions, rowsTrackIndexXicPlus, cascadesLinked, cascadesFull, tracks, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processNoCentXicplusWithDcaFitter, "Run candidate creator with DCAFitter without centrality selection.", true); + + void processCentFT0CXicplusWithDcaFitter(soa::Join const& collisions, + aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, + CascadesLinked const& cascadesLinked, + CascFull const& cascadesFull, + TracksWCovDcaPidPrPi const& tracks, + aod::BCsWithTimestamps const& bcs) + { + runXicplusCreatorWithDcaFitter(collisions, rowsTrackIndexXicPlus, cascadesLinked, cascadesFull, tracks, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processCentFT0CXicplusWithDcaFitter, "Run candidate creator with DCAFitter with centrality selection on FT0C.", false); + + void processCentFT0MXicplusWithDcaFitter(soa::Join const& collisions, + aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, + CascadesLinked const& cascadesLinked, + CascFull const& cascadesFull, + TracksWCovDcaPidPrPi const& tracks, + aod::BCsWithTimestamps const& bcs) + { + runXicplusCreatorWithDcaFitter(collisions, rowsTrackIndexXicPlus, cascadesLinked, cascadesFull, tracks, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processCentFT0MXicplusWithDcaFitter, "Run candidate creator with DCAFitter with centrality selection on FT0M.", false); + + /////////////////////////////////////////////////////////// + /// /// + /// Process functions with KFParticle /// + /// /// + /////////////////////////////////////////////////////////// + + void processNoCentXicplusWithKFParticle(soa::Join const& collisions, + aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, + KFCascadesLinked const& kfCascadesLinked, + KFCascFull const& kfCascadesFull, + TracksWCovExtraPidPrPi const& tracks, + aod::BCsWithTimestamps const& bcs) + { + runXicplusCreatorWithKFParticle(collisions, rowsTrackIndexXicPlus, kfCascadesLinked, kfCascadesFull, tracks, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processNoCentXicplusWithKFParticle, "Run candidate creator with KFParticle without centrality selection.", false); + + void processCentFT0CXicplusWithKFParticle(soa::Join const& collisions, + aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, + KFCascadesLinked const& kfCascadesLinked, + KFCascFull const& kfCascadesFull, + TracksWCovExtraPidPrPi const& tracks, + aod::BCsWithTimestamps const& bcs) + { + runXicplusCreatorWithKFParticle(collisions, rowsTrackIndexXicPlus, kfCascadesLinked, kfCascadesFull, tracks, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processCentFT0CXicplusWithKFParticle, "Run candidate creator with KFParticle with centrality selection on FT0C.", false); + + void processCentFT0MXicplusWithKFParticle(soa::Join const& collisions, + aod::HfCascLf3Prongs const& rowsTrackIndexXicPlus, + KFCascadesLinked const& kfCascadesLinked, + KFCascFull const& kfCascadesFull, + TracksWCovExtraPidPrPi const& tracks, + aod::BCsWithTimestamps const& bcs) + { + runXicplusCreatorWithKFParticle(collisions, rowsTrackIndexXicPlus, kfCascadesLinked, kfCascadesFull, tracks, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processCentFT0MXicplusWithKFParticle, "Run candidate creator with KFParticle with centrality selection on FT0M.", false); + + /////////////////////////////////////////////////////////// + /// /// + /// Process functions only for collision monitoring /// + /// /// + /////////////////////////////////////////////////////////// + + void processCollisions(soa::Join const& collisions, aod::BCsWithTimestamps const&) + { + /// loop over collisions + for (const auto& collision : collisions) { + + /// bitmask with event. selection info + float centrality{-1.f}; + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + + /// monitor the satisfied event selections + hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy); + + } /// end loop over collisions + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processCollisions, "Collision monitoring - no centrality", false); + + void processCollisionsCentFT0C(soa::Join const& collisions, aod::BCsWithTimestamps const&) + { + /// loop over collisions + for (const auto& collision : collisions) { + + /// bitmask with event. selection info + float centrality{-1.f}; + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + + /// monitor the satisfied event selections + hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy); + + } /// end loop over collisions + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processCollisionsCentFT0C, "Collision monitoring - FT0C centrality", false); + + void processCollisionsCentFT0M(soa::Join const& collisions, aod::BCsWithTimestamps const&) + { + /// loop over collisions + for (const auto& collision : collisions) { + + /// bitmask with event. selection info + float centrality{-1.f}; + float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + + /// monitor the satisfied event selections + hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy); + + } /// end loop over collisions + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processCollisionsCentFT0M, "Collision monitoring - FT0M centrality", false); }; // struct /// Performs MC matching. @@ -657,11 +848,62 @@ struct HfCandidateCreatorXicToXiPiPiExpressions { Spawns rowCandidateXic; Produces rowMcMatchRec; Produces rowMcMatchGen; + Produces rowResiduals; - void init(InitContext const&) {} + Configurable fillMcHistograms{"fillMcHistograms", true, "Fill validation plots"}; + Configurable matchDecayedPions{"matchDecayedPions", true, "Match also candidates with daughter pion tracks that decay with kinked topology"}; + Configurable matchInteractionsWithMaterial{"matchInteractionsWithMaterial", true, "Match also candidates with daughter tracks that interact with material"}; + Configurable fillResidualTable{"fillResidualTable", false, "Fill table containing residuals and pulls of PV and SV"}; - void processMc(aod::TracksWMc const& tracks, - aod::McParticles const& mcParticles) + HfEventSelectionMc hfEvSelMc; + + enum DebugRec { TotalRec = 0, + XicToFinalState, + XiToPiPPi, + LambdaToPPi }; + + using McCollisionsNoCents = soa::Join; + using McCollisionsFT0Cs = soa::Join; + using McCollisionsFT0Ms = soa::Join; + using McCollisionsCentFT0Ms = soa::Join; + using BCsInfo = soa::Join; + + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId; + + HistogramRegistry registry{"registry"}; + + void init(InitContext& initContext) + { + // add histograms to registry + if (fillMcHistograms) { + registry.add("hDecayedPions", "hDecayedPions", {HistType::kTH1F, {{5, -0.5, 4.5}}}); + registry.add("hInteractionsWithMaterial", "hInteractionsWithMaterial", {HistType::kTH1F, {{6, -0.5, 5.5}}}); + registry.add("hDebugRec", "hDebugRec", {HistType::kTH1F, {{4, -0.5, 3.5}}}); + registry.get(HIST("hDebugRec"))->GetXaxis()->SetBinLabel(1 + TotalRec, "total"); + registry.get(HIST("hDebugRec"))->GetXaxis()->SetBinLabel(1 + XicToFinalState, "#Xi^{+}_{c} #rightarrow #pi^{#plus} #pi^{#plus} #pi^{#minus} p #pi^{#minus}"); + registry.get(HIST("hDebugRec"))->GetXaxis()->SetBinLabel(1 + XiToPiPPi, "#Xi^{#minus} #rightarrow #pi^{#minus} p #pi^{#minus}"); + registry.get(HIST("hDebugRec"))->GetXaxis()->SetBinLabel(1 + LambdaToPPi, "#Lambda #rightarrow p #pi^{#minus}"); + } + + // initialize HF event selection helper + const auto& workflows = initContext.services().get(); + for (const DeviceSpec& device : workflows.devices) { + if (device.name.compare("hf-candidate-creator-xic-to-xi-pi-pi") == 0) { + hfEvSelMc.init(device, registry); + break; + } + } + } + + template + void runMcMatching(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisions const& mcCollisions, + CollInfos const& collInfos, + BCsInfo const&) { rowCandidateXic->bindExternalIndices(&tracks); @@ -669,20 +911,38 @@ struct HfCandidateCreatorXicToXiPiPiExpressions { int indexRecXicPlus = -1; int8_t sign = 0; int8_t flag = 0; - int8_t origin = 0; - int8_t debug = 0; - // for resonance matching: + int8_t origin = RecoDecay::OriginType::None; + int8_t nPionsDecayed = 0; + int8_t nInteractionsWithMaterial = 0; + // for resonance matching std::vector arrDaughIndex; - std::array arrPDGDaugh; - std::array arrXiResonance = {3324, kPiPlus}; // 3324: Ξ(1530) + constexpr std::size_t NDaughtersResonant{2u}; + std::array arrPDGDaugh; + std::array arrXiResonance = {3324, kPiPlus}; // 3324: Ξ(1530) + // for non-prompt + std::vector idxBhadMothers; + // residuals and pulls + std::array momentumResiduals{-9999.f}; + std::array pvResiduals{-9999.f}; + std::array pvPulls{-9999.f}; + std::array svResiduals{-9999.f}; + std::array svPulls{-9999.f}; // Match reconstructed candidates. for (const auto& candidate : *rowCandidateXic) { - flag = 0; sign = 0; + flag = 0; origin = RecoDecay::OriginType::None; - debug = 0; + nPionsDecayed = 0; + nInteractionsWithMaterial = 0; arrDaughIndex.clear(); + if (fillResidualTable) { + momentumResiduals.fill(-9999.f); + pvResiduals.fill(-9999.f); + pvPulls.fill(-9999.f); + svResiduals.fill(-9999.f); + svPulls.fill(-9999.f); + } auto arrayDaughters = std::array{candidate.pi0_as(), // pi <- Xic candidate.pi1_as(), // pi <- Xic @@ -695,99 +955,226 @@ struct HfCandidateCreatorXicToXiPiPiExpressions { auto arrayDaughtersV0 = std::array{candidate.posTrack_as(), candidate.negTrack_as()}; + if (fillMcHistograms) { + registry.fill(HIST("hDebugRec"), TotalRec); + } + // Xic → pi pi pi pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4); - indexRecXicPlus = indexRec; - if (indexRec == -1) { - debug = 1; + if (matchDecayedPions && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4, &nPionsDecayed, nullptr, &nInteractionsWithMaterial); + } else if (matchDecayedPions && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4, &nPionsDecayed, nullptr, &nInteractionsWithMaterial); + } else if (!matchDecayedPions && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4, &nPionsDecayed, nullptr, &nInteractionsWithMaterial); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4, &nPionsDecayed, nullptr, &nInteractionsWithMaterial); } + indexRecXicPlus = indexRec; if (indexRec > -1) { + if (fillMcHistograms) { + registry.fill(HIST("hDebugRec"), XicToFinalState); + } // Xi- → pi pi p - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, &sign, 2); - if (indexRec == -1) { - debug = 2; + if (matchDecayedPions && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, nullptr, 2); + } else if (matchDecayedPions && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, nullptr, 2); + } else if (!matchDecayedPions && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, nullptr, 2); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersCasc, +kXiMinus, std::array{+kPiMinus, +kProton, +kPiMinus}, true, nullptr, 2); } if (indexRec > -1) { + if (fillMcHistograms) { + registry.fill(HIST("hDebugRec"), XiToPiPPi); + } // Lambda → p pi - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &sign, 1); - if (indexRec == -1) { - debug = 3; + if (matchDecayedPions && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true); + } else if (matchDecayedPions && !matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true); + } else if (!matchDecayedPions && matchInteractionsWithMaterial) { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true); + } else { + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true); } if (indexRec > -1) { - RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRecXicPlus), &arrDaughIndex, std::array{0}, 1); - if (arrDaughIndex.size() == 2) { - for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) { + if (fillMcHistograms) { + registry.fill(HIST("hDebugRec"), LambdaToPPi); + } + auto particleXicPlus = mcParticles.rawIteratorAt(indexRecXicPlus); + // Check whether XicPlus decays via resonant decay + RecoDecay::getDaughters(particleXicPlus, &arrDaughIndex, std::array{0}, 1); + if (arrDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < NDaughtersResonant; ++iProng) { auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]); arrPDGDaugh[iProng] = std::abs(daughI.pdgCode()); } if ((arrPDGDaugh[0] == arrXiResonance[0] && arrPDGDaugh[1] == arrXiResonance[1]) || (arrPDGDaugh[0] == arrXiResonance[1] && arrPDGDaugh[1] == arrXiResonance[0])) { flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi); - } else { - debug = 4; } } else { flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi); } + // Check whether the charm baryon is non-prompt (from a b quark). + if (flag != 0) { + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particleXicPlus, false); + } + // Calculate residuals and pulls + if (flag != 0 && fillResidualTable) { + auto mcCollision = particleXicPlus.template mcCollision_as(); + auto particleDaughter0 = mcParticles.rawIteratorAt(arrDaughIndex[0]); + + momentumResiduals[0] = candidate.p() - particleXicPlus.p(); + momentumResiduals[1] = candidate.pt() - particleXicPlus.pt(); + pvResiduals[0] = candidate.posX() - mcCollision.posX(); + pvResiduals[1] = candidate.posY() - mcCollision.posY(); + pvResiduals[2] = candidate.posZ() - mcCollision.posZ(); + svResiduals[0] = candidate.xSecondaryVertex() - particleDaughter0.vx(); + svResiduals[1] = candidate.ySecondaryVertex() - particleDaughter0.vy(); + svResiduals[2] = candidate.zSecondaryVertex() - particleDaughter0.vz(); + try { + pvPulls[0] = pvResiduals[0] / candidate.xPvErr(); + pvPulls[1] = pvResiduals[1] / candidate.yPvErr(); + pvPulls[2] = pvResiduals[2] / candidate.zPvErr(); + svPulls[0] = svResiduals[0] / candidate.xSvErr(); + svPulls[1] = svResiduals[1] / candidate.ySvErr(); + svPulls[2] = svResiduals[2] / candidate.zSvErr(); + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". Set values of vertex pulls to -9999.9."; + } + } } } } - // Check whether the charm baryon is non-prompt (from a b quark). - if (flag != 0) { - auto particle = mcParticles.rawIteratorAt(indexRecXicPlus); - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); + // Fill histograms + if (flag != 0 && fillMcHistograms) { + registry.fill(HIST("hDecayedPions"), nPionsDecayed); + registry.fill(HIST("hInteractionsWithMaterial"), nInteractionsWithMaterial); } - rowMcMatchRec(flag, debug, origin); + // Fill tables + rowMcMatchRec(flag, origin); + if (flag != 0 && fillResidualTable) { + rowResiduals(origin, momentumResiduals[0], momentumResiduals[1], + pvResiduals[0], pvResiduals[1], pvResiduals[2], + pvPulls[0], pvPulls[1], pvPulls[2], + svResiduals[0], svResiduals[1], svResiduals[2], + svPulls[0], svPulls[1], svPulls[2]); + } } // close loop over candidates // Match generated particles. - for (const auto& particle : mcParticles) { - flag = 0; - sign = 0; - debug = 0; - origin = RecoDecay::OriginType::None; - arrDaughIndex.clear(); + for (const auto& mcCollision : mcCollisions) { + // Slice the particles table to get the particles for the current MC collision + const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); + // Slice the collisions table to get the collision info for the current MC collision + float centrality{-1.f}; + uint32_t rejectionMask{0u}; + int nSplitColl = 0; + if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0C) { + const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + } else if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0M) { + const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0M, mcCollision.globalIndex()); + nSplitColl = collSlice.size(); + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + } else if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::None) { + const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + } + hfEvSelMc.fillHistograms(mcCollision, rejectionMask, nSplitColl); + if (rejectionMask != 0) { + // at least one event selection not satisfied --> reject all particles from this collision + for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) { + rowMcMatchGen(-99, -99, -99); + } + continue; + } - // Xic → Xi pi pi - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kXiCPlus, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, true, &sign, 2)) { - debug = 1; - // Xi- -> Lambda pi - auto cascMC = mcParticles.rawIteratorAt(particle.daughtersIds().front()); - if (RecoDecay::isMatchedMCGen(mcParticles, cascMC, +kXiMinus, std::array{+kLambda0, +kPiMinus}, true)) { - debug = 2; - // Lambda -> p pi - auto v0MC = mcParticles.rawIteratorAt(cascMC.daughtersIds().front()); - if (RecoDecay::isMatchedMCGen(mcParticles, v0MC, +kLambda0, std::array{+kProton, +kPiMinus}, true)) { - debug = 3; - - RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{0}, 1); - if (arrDaughIndex.size() == 2) { - for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) { - auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]); - arrPDGDaugh[iProng] = std::abs(daughI.pdgCode()); - } - if ((arrPDGDaugh[0] == arrXiResonance[0] && arrPDGDaugh[1] == arrXiResonance[1]) || (arrPDGDaugh[0] == arrXiResonance[1] && arrPDGDaugh[1] == arrXiResonance[0])) { - flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi); + for (const auto& particle : mcParticlesPerMcColl) { + sign = 0; + flag = 0; + origin = RecoDecay::OriginType::None; + arrDaughIndex.clear(); + idxBhadMothers.clear(); + + // Xic → Xi pi pi + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kXiCPlus, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, true, &sign, 2)) { + // Xi- -> Lambda pi + auto cascMC = mcParticles.rawIteratorAt(particle.daughtersIds().front()); + // Find Xi- from Xi(1530) -> Xi pi in case of resonant decay + RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{0}, 1); + if (arrDaughIndex.size() == NDaughtersResonant) { + auto cascStarMC = mcParticles.rawIteratorAt(particle.daughtersIds().front()); + if (RecoDecay::isMatchedMCGen(mcParticles, cascStarMC, +3324, std::array{+kXiMinus, +kPiPlus}, true)) { + cascMC = mcParticles.rawIteratorAt(cascStarMC.daughtersIds().front()); + } + } + if (RecoDecay::isMatchedMCGen(mcParticles, cascMC, +kXiMinus, std::array{+kLambda0, +kPiMinus}, true)) { + // Lambda -> p pi + auto v0MC = mcParticles.rawIteratorAt(cascMC.daughtersIds().front()); + if (RecoDecay::isMatchedMCGen(mcParticles, v0MC, +kLambda0, std::array{+kProton, +kPiMinus}, true)) { + if (arrDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < NDaughtersResonant; ++iProng) { + auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]); + arrPDGDaugh[iProng] = std::abs(daughI.pdgCode()); + } + if ((arrPDGDaugh[0] == arrXiResonance[0] && arrPDGDaugh[1] == arrXiResonance[1]) || (arrPDGDaugh[0] == arrXiResonance[1] && arrPDGDaugh[1] == arrXiResonance[0])) { + flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi); + } } else { - debug = 4; + flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi); } - } else { - flag = sign * (1 << aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi); } } } - } - // Check whether the charm baryon is non-prompt (from a b quark). - if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, true); - } + // Check whether the charm baryon is non-prompt (from a b quark). + if (flag != 0) { + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + } + // Fill table + if (origin == RecoDecay::OriginType::NonPrompt) { + auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]); + rowMcMatchGen(flag, origin, bHadMother.pdgCode()); + } else { + rowMcMatchGen(flag, origin, 0); + } + } // close loop over generated particles + } // close loop over McCollisions + } // close template function - rowMcMatchGen(flag, debug, origin); - } // close loop over generated particles - } // close process - PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPiExpressions, processMc, "Process MC", false); + void processMc(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcCollisions, + McCollisionsNoCents const& mcCollisionsNoCents, + BCsInfo const& bcs) + { + runMcMatching(tracks, mcParticles, mcCollisions, mcCollisionsNoCents, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPiExpressions, processMc, "Perform MC matching with no centrality selection.", true); + + void processMcCentFT0C(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcCollisions, + McCollisionsFT0Cs const& mcCollisionsFT0Cs, + BCsInfo const& bcs) + { + runMcMatching(tracks, mcParticles, mcCollisions, mcCollisionsFT0Cs, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPiExpressions, processMcCentFT0C, "Perform MC matching with centrality selection on FT0C.", false); + + void processMcCentFT0M(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsCentFT0Ms const& mcCollisionsCentFT0Ms, + McCollisionsFT0Ms const& mcCollisionsFT0Ms, + BCsInfo const& bcs) + { + runMcMatching(tracks, mcParticles, mcCollisionsCentFT0Ms, mcCollisionsFT0Ms, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPiExpressions, processMcCentFT0M, "Perform MC matching with centrality selection on FT0M.", false); }; // close struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/candidateCreatorXicc.cxx b/PWGHF/TableProducer/candidateCreatorXicc.cxx index 214c2cea891..915d6501d6f 100644 --- a/PWGHF/TableProducer/candidateCreatorXicc.cxx +++ b/PWGHF/TableProducer/candidateCreatorXicc.cxx @@ -17,18 +17,34 @@ /// \author Luigi Dello Stritto , SALERNO /// \author Mattia Faggin , University and INFN PADOVA -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/V0.h" - -#include "Common/Core/trackUtilities.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::constants::physics; @@ -41,7 +57,7 @@ void customize(std::vector& workflowOptions) workflowOptions.push_back(optionDoMC); } -#include "Framework/runDataProcessing.h" +#include /// Reconstruction of xicc candidates struct HfCandidateCreatorXicc { @@ -105,7 +121,7 @@ struct HfCandidateCreatorXicc { aod::TracksWCov const& tracks) { for (const auto& xicCand : xicCands) { - if (!(xicCand.hfflag() & 1 << o2::aod::hf_cand_3prong::XicToPKPi)) { + if (!(xicCand.hfflag() & 1 << o2::aod::hf_cand_3prong::DecayType::XicToPKPi)) { continue; } if (xicCand.isSelXicToPKPi() >= selectionFlagXic) { @@ -195,9 +211,9 @@ struct HfCandidateCreatorXicc { xicCand.globalIndex(), trackpion.globalIndex(), hfFlag); } // if on selected Xicc - } // loop over candidates - } // end of process -}; // end of struct + } // loop over candidates + } // end of process +}; // end of struct /// Extends the base table with expression columns. struct HfCandidateCreatorXiccExpressions { diff --git a/PWGHF/TableProducer/candidateSelectorB0ToDPi.cxx b/PWGHF/TableProducer/candidateSelectorB0ToDPi.cxx index 985be6f5aa6..60709a4e4dc 100644 --- a/PWGHF/TableProducer/candidateSelectorB0ToDPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorB0ToDPi.cxx @@ -14,29 +14,54 @@ /// /// \author Alexandre Bigot , IPHC Strasbourg -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponseB0ToDPi.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsPid.h" + +#include "Common/Core/TrackSelectorPID.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::analysis; +using namespace o2::aod::pid_tpc_tof_utils; struct HfCandidateSelectorB0ToDPi { Produces hfSelB0ToDPiCandidate; // table defined in CandidateSelectionTables.h + Produces hfMlB0ToDPiCandidate; // table defined in CandidateSelectionTables.h Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; // Enable PID - Configurable usePid{"usePid", true, "Switch for PID selection at track level"}; + Configurable pionPidMethod{"pionPidMethod", PidMethod::TpcOrTof, "PID selection method for the bachelor pion (PidMethod::NoPid: none, PidMethod::TpcOrTof: TPC or TOF, PidMethod::TpcAndTof: TPC and TOF)"}; Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; // TPC PID Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; @@ -50,22 +75,50 @@ struct HfCandidateSelectorB0ToDPi { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_b0_to_d_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_b0_to_d_pi::cuts[0], hf_cuts_b0_to_d_pi::nBinsPt, hf_cuts_b0_to_d_pi::nCutVars, hf_cuts_b0_to_d_pi::labelsPt, hf_cuts_b0_to_d_pi::labelsCutVar}, "B0 candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_b0_to_d_pi::Cuts[0], hf_cuts_b0_to_d_pi::NBinsPt, hf_cuts_b0_to_d_pi::NCutVars, hf_cuts_b0_to_d_pi::labelsPt, hf_cuts_b0_to_d_pi::labelsCutVar}, "B0 candidate selection per pT bin"}; + // D-meson ML cuts + Configurable> binsPtDmesMl{"binsPtDmesMl", std::vector{hf_cuts_ml::vecBinsPt}, "D-meson pT bin limits for ML cuts"}; + Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D-meson ML cuts per pT bin"}; // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; - // check if selectionFlagD (defined in candidateCreatorB0.cxx) and usePid configurables are in sync + // B0 ML inference + Configurable applyB0Ml{"applyB0Ml", false, "Flag to apply ML selections"}; + Configurable> binsPtB0Ml{"binsPtB0Ml", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; + Configurable> cutDirB0Ml{"cutDirB0Ml", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsB0Ml{"cutsB0Ml", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesB0Ml{"nClassesB0Ml", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; + // CCDB configuration + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"path_ccdb/BDT_B0/"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_B0ToDPi.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + + o2::analysis::HfMlResponseB0ToDPi hfMlResponse; + float outputMlNotPreselected = -1.; + std::vector outputMl = {}; + o2::ccdb::CcdbApi ccdbApi; - bool selectionFlagDAndUsePidInSync = true; - TrackSelectorPi selectorPion; HfHelper hfHelper; + TrackSelectorPi selectorPion; - using TracksPidWithSel = soa::Join; + using TracksPion = soa::Join; HistogramRegistry registry{"registry"}; - void init(InitContext& initContext) + void init(InitContext const&) { - if (usePid) { + std::array doprocess{doprocessSelection, doprocessSelectionWithDmesMl}; + if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { + LOGP(fatal, "Only one process function for data should be enabled at a time."); + } + + if (pionPidMethod < 0 || pionPidMethod >= PidMethod::NPidMethods) { + LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); + } + + if (pionPidMethod != PidMethod::NoPid) { selectorPion.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); selectorPion.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax); selectorPion.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedMax, nSigmaTpcCombinedMax); @@ -81,6 +134,7 @@ struct HfCandidateSelectorB0ToDPi { labels[1 + SelectionStep::RecoSkims] = "Skims selection"; labels[1 + SelectionStep::RecoTopol] = "Skims & Topological selections"; labels[1 + SelectionStep::RecoPID] = "Skims & Topological & PID selections"; + labels[1 + aod::SelectionStep::RecoMl] = "ML selection"; static const AxisSpec axisSelections = {kNBinsSelections, 0.5, kNBinsSelections + 0.5, ""}; registry.add("hSelections", "Selections;;#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisSelections, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); for (int iBin = 0; iBin < kNBinsSelections; ++iBin) { @@ -88,76 +142,129 @@ struct HfCandidateSelectorB0ToDPi { } } - int selectionFlagD = -1; - auto& workflows = initContext.services().get(); - for (const DeviceSpec& device : workflows.devices) { - if (device.name.compare("hf-candidate-creator-b0") == 0) { - for (const auto& option : device.options) { - if (option.name.compare("selectionFlagD") == 0) { - selectionFlagD = option.defaultValue.get(); - LOGF(info, "selectionFlagD = %d", selectionFlagD); - } - } + if (applyB0Ml) { + hfMlResponse.configure(binsPtB0Ml, cutsB0Ml, cutDirB0Ml, nClassesB0Ml); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponse.setModelPathsLocal(onnxFileNames); } - } - - if (usePid && !TESTBIT(selectionFlagD, SelectionStep::RecoPID)) { - selectionFlagDAndUsePidInSync = false; - LOG(warning) << "PID selections required on B0 daughters (usePid=true) but no PID selections on D candidates were required a priori (selectionFlagD<7). Set selectionFlagD=7 in hf-candidate-creator-b0"; - } - if (!usePid && TESTBIT(selectionFlagD, SelectionStep::RecoPID)) { - selectionFlagDAndUsePidInSync = false; - LOG(warning) << "No PID selections required on B0 daughters (usePid=false) but PID selections on D candidates were required a priori (selectionFlagD=7). Set selectionFlagD<7 in hf-candidate-creator-b0"; + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponse.init(); } } - void process(aod::HfCandB0 const& hfCandsB0, - TracksPidWithSel const&) + /// Main function to perform B0 candidate creation + /// \param withDmesMl is the flag to use the table with ML scores for the D- daughter (only possible if present in the derived data) + /// \param hfCandsB0 B0 candidates + /// \param pionTracks pion tracks + template + void runSelection(Cands const& hfCandsB0, + CandsDmes const& /*hfCandsD*/, + TracksPion const& /*pionTracks*/) { + for (const auto& hfCandB0 : hfCandsB0) { - int statusB0ToDPi = 0; + int statusB0 = 0; auto ptCandB0 = hfCandB0.pt(); - SETBIT(statusB0ToDPi, SelectionStep::RecoSkims); // RecoSkims = 0 --> statusB0ToDPi = 1 + SETBIT(statusB0, SelectionStep::RecoSkims); // RecoSkims = 0 --> statusB0 = 1 if (activateQA) { registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoSkims, ptCandB0); } // topological cuts if (!hfHelper.selectionB0ToDPiTopol(hfCandB0, cuts, binsPt)) { - hfSelB0ToDPiCandidate(statusB0ToDPi); + hfSelB0ToDPiCandidate(statusB0); + if (applyB0Ml) { + hfMlB0ToDPiCandidate(outputMlNotPreselected); + } // LOGF(info, "B0 candidate selection failed at topology selection"); continue; } - SETBIT(statusB0ToDPi, SelectionStep::RecoTopol); // RecoTopol = 1 --> statusB0ToDPi = 3 + + auto trackPi = hfCandB0.template prong1_as(); + auto hfCandD = hfCandB0.template prong0_as(); + + std::vector mlScoresD; + if constexpr (withDmesMl) { + std::copy(hfCandD.mlProbDplusToPiKPi().begin(), hfCandD.mlProbDplusToPiKPi().end(), std::back_inserter(mlScoresD)); + + if (!hfHelper.selectionDmesMlScoresForB(hfCandD, cutsDmesMl, binsPtDmesMl, mlScoresD)) { + hfSelB0ToDPiCandidate(statusB0); + if (applyB0Ml) { + hfMlB0ToDPiCandidate(outputMlNotPreselected); + } + // LOGF(info, "B0 candidate selection failed at D-meson ML selection"); + continue; + } + } + + SETBIT(statusB0, SelectionStep::RecoTopol); // RecoTopol = 1 --> statusB0 = 3 if (activateQA) { registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoTopol, ptCandB0); } - // checking if selectionFlagD and usePid are in sync - if (!selectionFlagDAndUsePidInSync) { - hfSelB0ToDPiCandidate(statusB0ToDPi); - continue; - } // track-level PID selection - if (usePid) { - auto trackPi = hfCandB0.prong1_as(); - int pidTrackPi = selectorPion.statusTpcAndTof(trackPi); + if (pionPidMethod == PidMethod::TpcOrTof || pionPidMethod == PidMethod::TpcAndTof) { + int pidTrackPi{TrackSelectorPID::Status::NotApplicable}; + if (pionPidMethod == PidMethod::TpcOrTof) { + pidTrackPi = selectorPion.statusTpcOrTof(trackPi); + } else if (pionPidMethod == PidMethod::TpcAndTof) { + pidTrackPi = selectorPion.statusTpcAndTof(trackPi); + } if (!hfHelper.selectionB0ToDPiPid(pidTrackPi, acceptPIDNotApplicable.value)) { // LOGF(info, "B0 candidate selection failed at PID selection"); - hfSelB0ToDPiCandidate(statusB0ToDPi); + hfSelB0ToDPiCandidate(statusB0); + if (applyB0Ml) { + hfMlB0ToDPiCandidate(outputMlNotPreselected); + } continue; } - SETBIT(statusB0ToDPi, SelectionStep::RecoPID); // RecoPID = 2 --> statusB0ToDPi = 7 + SETBIT(statusB0, SelectionStep::RecoPID); // RecoPID = 2 --> statusB0 = 7 if (activateQA) { registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoPID, ptCandB0); } } + if (applyB0Ml) { + // B0 ML selections + std::vector inputFeatures = hfMlResponse.getInputFeatures(hfCandB0, trackPi, &mlScoresD); + bool isSelectedMl = hfMlResponse.isSelectedMl(inputFeatures, ptCandB0, outputMl); + hfMlB0ToDPiCandidate(outputMl[1]); // storing ML score for signal class - hfSelB0ToDPiCandidate(statusB0ToDPi); + if (!isSelectedMl) { + hfSelB0ToDPiCandidate(statusB0); + continue; + } + SETBIT(statusB0, SelectionStep::RecoMl); // RecoML = 3 --> statusB0 = 15 if pionPidMethod, 11 otherwise + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoMl, ptCandB0); + } + } + + hfSelB0ToDPiCandidate(statusB0); // LOGF(info, "B0 candidate selection passed all selections"); } } + + void processSelection(HfCandB0 const& hfCandsB0, + aod::HfCand3ProngWPidPiKa const& hfCandsD, + TracksPion const& pionTracks) + { + runSelection(hfCandsB0, hfCandsD, pionTracks); + } // processSelection + + PROCESS_SWITCH(HfCandidateSelectorB0ToDPi, processSelection, "Process selection without ML scores of D mesons", true); + + void processSelectionWithDmesMl(HfCandB0 const& hfCandsB0, + soa::Join const& hfCandsD, + TracksPion const& pionTracks) + { + runSelection(hfCandsB0, hfCandsD, pionTracks); + } // processSelectionWithDmesMl + + PROCESS_SWITCH(HfCandidateSelectorB0ToDPi, processSelectionWithDmesMl, "Process selection with ML scores of D mesons", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/candidateSelectorBplusToD0Pi.cxx b/PWGHF/TableProducer/candidateSelectorBplusToD0Pi.cxx index 11188cbe117..1bcc8bff8e0 100644 --- a/PWGHF/TableProducer/candidateSelectorBplusToD0Pi.cxx +++ b/PWGHF/TableProducer/candidateSelectorBplusToD0Pi.cxx @@ -16,25 +16,46 @@ /// \author Deepa Thomas , UT Austin /// \author Nima Zardoshti , CERN -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponseBplusToD0Pi.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsPid.h" + +#include "Common/Core/TrackSelectorPID.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::analysis; +using namespace o2::aod::pid_tpc_tof_utils; struct HfCandidateSelectorBplusToD0Pi { Produces hfSelBplusToD0PiCandidate; // table defined in CandidateSelectionTables.h @@ -43,7 +64,7 @@ struct HfCandidateSelectorBplusToD0Pi { Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; // Enable PID - Configurable pionPidMethod{"pionPidMethod", 1, "PID selection method for the bachelor pion (0: none, 1: TPC or TOF, 2: TPC and TOF)"}; + Configurable pionPidMethod{"pionPidMethod", PidMethod::TpcOrTof, "PID selection method for the bachelor pion (PidMethod::NoPid: none, PidMethod::TpcOrTof: TPC or TOF, PidMethod::TpcAndTof: TPC and TOF)"}; Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; // TPC PID Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; @@ -57,18 +78,18 @@ struct HfCandidateSelectorBplusToD0Pi { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_bplus_to_d0_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_bplus_to_d0_pi::cuts[0], hf_cuts_bplus_to_d0_pi::nBinsPt, hf_cuts_bplus_to_d0_pi::nCutVars, hf_cuts_bplus_to_d0_pi::labelsPt, hf_cuts_bplus_to_d0_pi::labelsCutVar}, "B+ candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_bplus_to_d0_pi::Cuts[0], hf_cuts_bplus_to_d0_pi::NBinsPt, hf_cuts_bplus_to_d0_pi::NCutVars, hf_cuts_bplus_to_d0_pi::labelsPt, hf_cuts_bplus_to_d0_pi::labelsCutVar}, "B+ candidate selection per pT bin"}; // D0-meson ML cuts Configurable> binsPtDmesMl{"binsPtDmesMl", std::vector{hf_cuts_ml::vecBinsPt}, "D0-meson pT bin limits for ML cuts"}; - Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D0-meson ML cuts per pT bin"}; + Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D0-meson ML cuts per pT bin"}; // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; // B+ ML inference Configurable applyBplusMl{"applyBplusMl", false, "Flag to apply ML selections"}; Configurable> binsPtBpMl{"binsPtBpMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirBpMl{"cutDirBpMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsBpMl{"cutsBpMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesBpMl{"nClassesBpMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsBpMl{"cutsBpMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesBpMl{"nClassesBpMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -85,10 +106,10 @@ struct HfCandidateSelectorBplusToD0Pi { HfHelper hfHelper; TrackSelectorPi selectorPion; - HistogramRegistry registry{"registry"}; - using TracksPion = soa::Join; + HistogramRegistry registry{"registry"}; + void init(InitContext const&) { std::array doprocess{doprocessSelection, doprocessSelectionWithDmesMl}; @@ -96,11 +117,11 @@ struct HfCandidateSelectorBplusToD0Pi { LOGP(fatal, "Only one process function for data should be enabled at a time."); } - if (pionPidMethod < 0 || pionPidMethod > 2) { + if (pionPidMethod < 0 || pionPidMethod >= PidMethod::NPidMethods) { LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); } - if (pionPidMethod != 0) { + if (pionPidMethod != PidMethod::NoPid) { selectorPion.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); selectorPion.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax); selectorPion.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedMax, nSigmaTpcCombinedMax); @@ -193,11 +214,11 @@ struct HfCandidateSelectorBplusToD0Pi { } // track-level PID selection - if (pionPidMethod) { + if (pionPidMethod == PidMethod::TpcOrTof || pionPidMethod == PidMethod::TpcAndTof) { int pidTrackPi{TrackSelectorPID::Status::NotApplicable}; - if (pionPidMethod == 1) { + if (pionPidMethod == PidMethod::TpcOrTof) { pidTrackPi = selectorPion.statusTpcOrTof(trackPi); - } else { + } else if (pionPidMethod == PidMethod::TpcAndTof) { pidTrackPi = selectorPion.statusTpcAndTof(trackPi); } if (!hfHelper.selectionBplusToD0PiPid(pidTrackPi, acceptPIDNotApplicable.value)) { diff --git a/PWGHF/TableProducer/candidateSelectorBsToDsPi.cxx b/PWGHF/TableProducer/candidateSelectorBsToDsPi.cxx index 9fc9fc8bdfc..05a66854ada 100644 --- a/PWGHF/TableProducer/candidateSelectorBsToDsPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorBsToDsPi.cxx @@ -15,21 +15,37 @@ /// /// \author Phil Stahlhut -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponse.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/TrackSelectorPID.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::framework; @@ -54,19 +70,19 @@ struct HfCandidateSelectorBsToDsPi { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_bs_to_ds_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_bs_to_ds_pi::cuts[0], hf_cuts_bs_to_ds_pi::nBinsPt, hf_cuts_bs_to_ds_pi::nCutVars, hf_cuts_bs_to_ds_pi::labelsPt, hf_cuts_bs_to_ds_pi::labelsCutVar}, "Bs candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_bs_to_ds_pi::Cuts[0], hf_cuts_bs_to_ds_pi::NBinsPt, hf_cuts_bs_to_ds_pi::NCutVars, hf_cuts_bs_to_ds_pi::labelsPt, hf_cuts_bs_to_ds_pi::labelsCutVar}, "Bs candidate selection per pT bin"}; // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; // ML inference Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"EventFiltering/PWGHF/BDTBs"}, "Paths of models on CCDB"}; - Configurable> onnxFileNames{"onnxFilesCCDB", std::vector{"ModelHandler_onnx_BsToDsPi.onnx"}, "ONNX file names on CCDB for each pT bin (if not from CCDB full path)"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_BsToDsPi.onnx"}, "ONNX file names on CCDB for each pT bin (if not from CCDB full path)"}; Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; diff --git a/PWGHF/TableProducer/candidateSelectorD0.cxx b/PWGHF/TableProducer/candidateSelectorD0.cxx index 88a8fb017b3..98634b9cf08 100644 --- a/PWGHF/TableProducer/candidateSelectorD0.cxx +++ b/PWGHF/TableProducer/candidateSelectorD0.cxx @@ -15,22 +15,34 @@ /// \author Nima Zardoshti , CERN /// \author Vít Kučera , CERN -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" -#include "PWGHF/Core/HfMlResponse.h" #include "PWGHF/Core/HfMlResponseD0ToKPi.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -56,18 +68,26 @@ struct HfCandidateSelectorD0 { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // AND logic for TOF+TPC PID (as in Run2) Configurable usePidTpcAndTof{"usePidTpcAndTof", false, "Use AND logic for TPC and TOF PID"}; + // ITS quality track cuts + Configurable itsNClustersFoundMin{"itsNClustersFoundMin", 0, "Minimum number of found ITS clusters"}; + Configurable itsChi2PerClusterMax{"itsChi2PerClusterMax", 1e10f, "Maximum its fit chi2 per ITS cluster"}; + // TPC quality track cuts + Configurable tpcNClustersFoundMin{"tpcNClustersFoundMin", 0, "Minimum number of found TPC clusters"}; + Configurable tpcNCrossedRowsMin{"tpcNCrossedRowsMin", 0, "Minimum number of crossed rows in TPC"}; + Configurable tpcNCrossedRowsOverFindableClustersMin{"tpcNCrossedRowsOverFindableClustersMin", 0., "Minimum ratio crossed rows / findable clusters"}; + Configurable tpcChi2PerClusterMax{"tpcChi2PerClusterMax", 1e10f, "Maximum TPC fit chi2 per TPC cluster"}; // selecting only background candidates Configurable keepOnlySidebandCandidates{"keepOnlySidebandCandidates", false, "Select only sideband candidates, for studying background cut variable distributions"}; Configurable distanceFromD0MassForSidebands{"distanceFromD0MassForSidebands", 0.15, "Minimum distance from nominal D0 mass value for sideband region"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_d0_to_pi_k::cuts[0], hf_cuts_d0_to_pi_k::nBinsPt, hf_cuts_d0_to_pi_k::nCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_d0_to_pi_k::Cuts[0], hf_cuts_d0_to_pi_k::NBinsPt, hf_cuts_d0_to_pi_k::NCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; // ML inference Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable enableDebugMl{"enableDebugMl", false, "Flag to enable histograms to monitor BDT application"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration @@ -131,6 +151,23 @@ struct HfCandidateSelectorD0 { } } + /// Single track quality cuts + /// \param track is track + /// \return true if track passes all cuts + template + bool isSelectedCandidateProng(const T& trackPos, const T& trackNeg) + { + if (!isSelectedTrackTpcQuality(trackPos, tpcNClustersFoundMin.value, tpcNCrossedRowsMin.value, tpcNCrossedRowsOverFindableClustersMin.value, tpcChi2PerClusterMax.value) || + !isSelectedTrackTpcQuality(trackNeg, tpcNClustersFoundMin.value, tpcNCrossedRowsMin.value, tpcNCrossedRowsOverFindableClustersMin.value, tpcChi2PerClusterMax.value)) { + return false; + } + if (!isSelectedTrackItsQuality(trackPos, itsNClustersFoundMin.value, itsChi2PerClusterMax.value) || + !isSelectedTrackItsQuality(trackNeg, itsNClustersFoundMin.value, itsChi2PerClusterMax.value)) { + return false; + } + return true; + } + /// Conjugate-independent topological cuts /// \param reconstructionType is the reconstruction type (DCAFitterN or KFParticle) /// \param candidate is candidate @@ -297,6 +334,15 @@ struct HfCandidateSelectorD0 { auto trackPos = candidate.template prong0_as(); // positive daughter auto trackNeg = candidate.template prong1_as(); // negative daughter + // implement track quality selection for D0 daughters + if (!isSelectedCandidateProng(trackPos, trackNeg)) { + hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); + if (applyMl) { + hfMlD0Candidate(outputMlD0, outputMlD0bar); + } + continue; + } + // conjugate-independent topological selection if (!selectionTopol(candidate)) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); diff --git a/PWGHF/TableProducer/candidateSelectorDplusToPiKPi.cxx b/PWGHF/TableProducer/candidateSelectorDplusToPiKPi.cxx index d6d607ba9c4..a531b6dbab0 100644 --- a/PWGHF/TableProducer/candidateSelectorDplusToPiKPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorDplusToPiKPi.cxx @@ -15,21 +15,35 @@ /// \author Fabio Catalano , Politecnico and INFN Torino /// \author Vít Kučera , CERN -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponseDplusToPiKPi.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -57,20 +71,18 @@ struct HfCandidateSelectorDplusToPiKPi { Configurable usePidTpcAndTof{"usePidTpcAndTof", false, "Use AND logic for TPC and TOF PID"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_dplus_to_pi_k_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_dplus_to_pi_k_pi::cuts[0], hf_cuts_dplus_to_pi_k_pi::nBinsPt, hf_cuts_dplus_to_pi_k_pi::nCutVars, hf_cuts_dplus_to_pi_k_pi::labelsPt, hf_cuts_dplus_to_pi_k_pi::labelsCutVar}, "Dplus candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_dplus_to_pi_k_pi::Cuts[0], hf_cuts_dplus_to_pi_k_pi::NBinsPt, hf_cuts_dplus_to_pi_k_pi::NCutVars, hf_cuts_dplus_to_pi_k_pi::labelsPt, hf_cuts_dplus_to_pi_k_pi::labelsCutVar}, "Dplus candidate selection per pT bin"}; // DCAxy selections - Configurable> cutsSingleTrack{"cutsSingleTrack", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections"}; + Configurable> cutsSingleTrack{"cutsSingleTrack", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections"}; Configurable> binsPtTrack{"binsPtTrack", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for DCA pT-dependent cut"}; // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; - // Correlated background from Ds and D+ - Configurable storeDsDplusBkg{"storeDsDplusBkg", false, "Flag to store correlated background from misidentified product of Ds and D+ decay"}; // ML inference Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -217,7 +229,7 @@ struct HfCandidateSelectorDplusToPiKPi { return true; } - void process(aod::HfCand3Prong const& candidates, + void process(aod::HfCand3ProngWPidPiKa const& candidates, TracksSel const&) { // looping over 3-prong candidates @@ -228,7 +240,7 @@ struct HfCandidateSelectorDplusToPiKPi { auto ptCand = candidate.pt(); - if (!TESTBIT(candidate.hfflag(), aod::hf_cand_3prong::DecayType::DplusToPiKPi) && !(storeDsDplusBkg && TESTBIT(candidate.hfflag(), aod::hf_cand_3prong::DecayType::DsToKKPi))) { // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π± + if (!TESTBIT(candidate.hfflag(), aod::hf_cand_3prong::DecayType::DplusToPiKPi)) { hfSelDplusToPiKPiCandidate(statusDplusToPiKPi); if (applyMl) { hfMlDplusToPiKPiCandidate(outputMlNotPreselected); @@ -266,13 +278,13 @@ struct HfCandidateSelectorDplusToPiKPi { int pidTrackPos2Pion = -1; if (usePidTpcAndTof) { - pidTrackPos1Pion = selectorPion.statusTpcAndTof(trackPos1); - pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg); - pidTrackPos2Pion = selectorPion.statusTpcAndTof(trackPos2); + pidTrackPos1Pion = selectorPion.statusTpcAndTof(trackPos1, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); + pidTrackPos2Pion = selectorPion.statusTpcAndTof(trackPos2, candidate.nSigTpcPi2(), candidate.nSigTofPi2()); } else { - pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1); - pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg); - pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2); + pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); + pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2, candidate.nSigTpcPi2(), candidate.nSigTofPi2()); } if (!selectionPID(pidTrackPos1Pion, pidTrackNegKaon, pidTrackPos2Pion)) { // exclude D± @@ -289,7 +301,7 @@ struct HfCandidateSelectorDplusToPiKPi { if (applyMl) { // ML selections - std::vector inputFeatures = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2); + std::vector inputFeatures = hfMlResponse.getInputFeatures(candidate); bool isSelectedMl = hfMlResponse.isSelectedMl(inputFeatures, ptCand, outputMl); hfMlDplusToPiKPiCandidate(outputMl); diff --git a/PWGHF/TableProducer/candidateSelectorDsToKKPi.cxx b/PWGHF/TableProducer/candidateSelectorDsToKKPi.cxx index 6d00e6daee9..80f22343ff1 100644 --- a/PWGHF/TableProducer/candidateSelectorDsToKKPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorDsToKKPi.cxx @@ -15,21 +15,35 @@ /// \author Fabio Catalano , Universita and INFN Torino /// \author Stefano Politano , Politecnico and INFN Torino -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponseDsToKKPi.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -55,11 +69,11 @@ struct HfCandidateSelectorDsToKKPi { Configurable usePidTpcAndTof{"usePidTpcAndTof", false, "Use AND logic for TPC and TOF PID"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_ds_to_k_k_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_ds_to_k_k_pi::cuts[0], hf_cuts_ds_to_k_k_pi::nBinsPt, hf_cuts_ds_to_k_k_pi::nCutVars, hf_cuts_ds_to_k_k_pi::labelsPt, hf_cuts_ds_to_k_k_pi::labelsCutVar}, "Ds candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_ds_to_k_k_pi::Cuts[0], hf_cuts_ds_to_k_k_pi::NBinsPt, hf_cuts_ds_to_k_k_pi::NCutVars, hf_cuts_ds_to_k_k_pi::labelsPt, hf_cuts_ds_to_k_k_pi::labelsCutVar}, "Ds candidate selection per pT bin"}; Configurable rejectCandsInDplusToPiKPiRegion{"rejectCandsInDplusToPiKPiRegion", false, "Flag to reject candidates in the D+ to PiKPi signal region"}; Configurable deltaMRegionDplusToPiKPi{"deltaMRegionDplusToPiKPi", 0.03, "Width of the D+ to PiKPi signal region (GeV/c^2)"}; // DCAxy and DCAz selections - Configurable> cutsSingleTrack{"cutsSingleTrack", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections"}; + Configurable> cutsSingleTrack{"cutsSingleTrack", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections"}; // pT bins for single-track cuts Configurable> binsPtTrack{"binsPtTrack", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for DCA pT-dependent cut"}; // QA switch @@ -68,8 +82,8 @@ struct HfCandidateSelectorDsToKKPi { Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -251,7 +265,7 @@ struct HfCandidateSelectorDsToKKPi { return true; } - void process(aod::HfCand3Prong const& candidates, + void process(aod::HfCand3ProngWPidPiKa const& candidates, TracksSel const&) { // looping over 3-prong candidates @@ -320,17 +334,17 @@ struct HfCandidateSelectorDsToKKPi { int pidTrackNegKaon = -1; if (usePidTpcAndTof) { - pidTrackPos1Pion = selectorPion.statusTpcAndTof(trackPos1); - pidTrackPos1Kaon = selectorKaon.statusTpcAndTof(trackPos1); - pidTrackPos2Pion = selectorPion.statusTpcAndTof(trackPos2); - pidTrackPos2Kaon = selectorKaon.statusTpcAndTof(trackPos2); - pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg); + pidTrackPos1Pion = selectorPion.statusTpcAndTof(trackPos1, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + pidTrackPos1Kaon = selectorKaon.statusTpcAndTof(trackPos1, candidate.nSigTpcKa0(), candidate.nSigTofKa0()); + pidTrackPos2Pion = selectorPion.statusTpcAndTof(trackPos2, candidate.nSigTpcPi2(), candidate.nSigTofPi2()); + pidTrackPos2Kaon = selectorKaon.statusTpcAndTof(trackPos2, candidate.nSigTpcKa2(), candidate.nSigTofKa2()); + pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); } else { - pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1); - pidTrackPos1Kaon = selectorKaon.statusTpcOrTof(trackPos1); - pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2); - pidTrackPos2Kaon = selectorKaon.statusTpcOrTof(trackPos2); - pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg); + pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + pidTrackPos1Kaon = selectorKaon.statusTpcOrTof(trackPos1, candidate.nSigTpcKa0(), candidate.nSigTofKa0()); + pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2, candidate.nSigTpcPi2(), candidate.nSigTofPi2()); + pidTrackPos2Kaon = selectorKaon.statusTpcOrTof(trackPos2, candidate.nSigTpcKa2(), candidate.nSigTofKa2()); + pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); } bool pidDsToKKPi = !(pidTrackPos1Kaon == TrackSelectorPID::Rejected || @@ -364,11 +378,11 @@ struct HfCandidateSelectorDsToKKPi { bool isSelectedMlDsToPiKK = false; if (topolDsToKKPi && pidDsToKKPi) { - std::vector inputFeaturesDsToKKPi = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2, true); + std::vector inputFeaturesDsToKKPi = hfMlResponse.getInputFeatures(candidate, true); isSelectedMlDsToKKPi = hfMlResponse.isSelectedMl(inputFeaturesDsToKKPi, candidate.pt(), outputMlDsToKKPi); } if (topolDsToPiKK && pidDsToPiKK) { - std::vector inputFeaturesDsToPiKK = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2, false); + std::vector inputFeaturesDsToPiKK = hfMlResponse.getInputFeatures(candidate, false); isSelectedMlDsToPiKK = hfMlResponse.isSelectedMl(inputFeaturesDsToPiKK, candidate.pt(), outputMlDsToPiKK); } diff --git a/PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx b/PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx index 90115a3f257..dbc06282ce0 100644 --- a/PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx +++ b/PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx @@ -15,25 +15,36 @@ /// \author Deependra Sharma , IITB /// \author Fabrizio Grosa , CERN -#include -#include -#include - -// O2 -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/Logger.h" -#include "Framework/runDataProcessing.h" -// O2Physics -#include "Common/Core/TrackSelectorPID.h" -// PWGHF #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponseD0ToKPi.h" #include "PWGHF/Core/HfMlResponseDstarToD0Pi.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + using namespace o2; using namespace o2::constants::physics; using namespace o2::analysis; @@ -48,7 +59,7 @@ struct HfCandidateSelectorDstarToD0Pi { Configurable ptD0CandMin{"ptD0CandMin", 0., "Minimum D0 candidate pT"}; Configurable ptD0CandMax{"ptD0CandMax", 50., "Maximum D0 candidate pT"}; Configurable> binsPtD0{"binsPtD0", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for D0"}; - Configurable> cutsD0{"cutsD0", {hf_cuts_d0_to_pi_k::cuts[0], hf_cuts_d0_to_pi_k::nBinsPt, hf_cuts_d0_to_pi_k::nCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; + Configurable> cutsD0{"cutsD0", {hf_cuts_d0_to_pi_k::Cuts[0], hf_cuts_d0_to_pi_k::NBinsPt, hf_cuts_d0_to_pi_k::NCutVars, hf_cuts_d0_to_pi_k::labelsPt, hf_cuts_d0_to_pi_k::labelsCutVar}, "D0 candidate selection per pT bin"}; // Mass Cut for trigger analysis Configurable useTriggerMassCut{"useTriggerMassCut", false, "Flag to enable parametrize pT differential mass cut for triggered data"}; @@ -56,7 +67,7 @@ struct HfCandidateSelectorDstarToD0Pi { Configurable ptDstarCandMin{"ptDstarCandMin", 0., "Minimum Dstar candidate pT"}; Configurable ptDstarCandMax{"ptDstarCandMax", 50., "Maximum Dstar candidate pT"}; Configurable> binsPtDstar{"binsPtDstar", std::vector{hf_cuts_dstar_to_d0_pi::vecBinsPt}, "pT bin limits for Dstar"}; - Configurable> cutsDstar{"cutsDstar", {hf_cuts_dstar_to_d0_pi::cuts[0], hf_cuts_dstar_to_d0_pi::nBinsPt, hf_cuts_dstar_to_d0_pi::nCutVars, hf_cuts_dstar_to_d0_pi::labelsPt, hf_cuts_dstar_to_d0_pi::labelsCutVar}, "Dstar candidate selection per pT bin"}; + Configurable> cutsDstar{"cutsDstar", {hf_cuts_dstar_to_d0_pi::Cuts[0], hf_cuts_dstar_to_d0_pi::NBinsPt, hf_cuts_dstar_to_d0_pi::NCutVars, hf_cuts_dstar_to_d0_pi::labelsPt, hf_cuts_dstar_to_d0_pi::labelsCutVar}, "Dstar candidate selection per pT bin"}; // common Configurable // TPC PID @@ -80,18 +91,27 @@ struct HfCandidateSelectorDstarToD0Pi { // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; - // ML inference + // ML inference D* Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; + // ML inference D0 + Configurable applyMlD0Daug{"applyMlD0Daug", false, "Flag to apply ML selections on D0 daughter"}; + Configurable> binsPtMlD0Daug{"binsPtMlD0Daug", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application on D0 daughter"}; + Configurable> cutDirMlD0Daug{"cutDirMlD0Daug", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold on D0 daughter"}; + Configurable> cutsMlD0Daug{"cutsMlD0Daug", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin on D0 daughter"}; + Configurable nClassesMlD0Daug{"nClassesMlD0Daug", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model on D0 daughter"}; + Configurable> namesInputFeaturesD0Daug{"namesInputFeaturesD0Daug", std::vector{"feature1", "feature2"}, "Names of ML model input features on D0 daughter"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{""}, "Paths of models on CCDB"}; + Configurable> modelPathsCCDBD0Daug{"modelPathsCCDBD0Daug", std::vector{""}, "Paths of models on CCDB for D0 daughter"}; Configurable> onnxFileNames{"onnxFileNames", std::vector{"Model.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable> onnxFileNamesD0Daug{"onnxFileNamesD0Daug", std::vector{"Model.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path) for D0 daughter"}; Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; @@ -100,7 +120,9 @@ struct HfCandidateSelectorDstarToD0Pi { HfHelper hfHelper; o2::analysis::HfMlResponseDstarToD0Pi hfMlResponse; + o2::analysis::HfMlResponseDstarToD0Pi hfMlResponseD0Daughter; std::vector outputMlDstarToD0Pi = {}; + std::vector outputMlD0ToKPi = {}; o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; @@ -108,7 +130,7 @@ struct HfCandidateSelectorDstarToD0Pi { using TracksSel = soa::Join; // using TracksSel = soa::Join; - using HfFullDstarCandidate = soa::Join; + using HfFullDstarCandidate = soa::Join; AxisSpec axisBdtScore{100, 0.f, 1.f}; AxisSpec axisSelStatus{2, -0.5f, 1.5f}; @@ -162,6 +184,18 @@ struct HfCandidateSelectorDstarToD0Pi { hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); hfMlResponse.init(); } + + if (applyMlD0Daug) { + hfMlResponseD0Daughter.configure(binsPtMlD0Daug, cutsMlD0Daug, cutDirMlD0Daug, nClassesMlD0Daug); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponseD0Daughter.setModelPathsCCDB(onnxFileNamesD0Daug, ccdbApi, modelPathsCCDBD0Daug, timestampCCDB); + } else { + hfMlResponseD0Daughter.setModelPathsLocal(onnxFileNamesD0Daug); + } + hfMlResponseD0Daughter.cacheInputFeaturesIndices(namesInputFeaturesD0Daug); + hfMlResponseD0Daughter.init(); + } } /// Conjugate-independent topological cuts on D0 @@ -225,9 +259,13 @@ struct HfCandidateSelectorDstarToD0Pi { return false; } - //.............Why is this if condition commented? - if (candidate.decayLengthNormalisedD0() * candidate.decayLengthNormalisedD0() < 1.0) { - // return false; // add back when getter fixed + if (applyMlD0Daug) { + outputMlD0ToKPi.clear(); + std::vector inputFeaturesD0 = hfMlResponseD0Daughter.getInputFeaturesTrigger(candidate); + bool isSelectedMlD0 = hfMlResponseD0Daughter.isSelectedMl(inputFeaturesD0, candpT, outputMlD0ToKPi); + if (!isSelectedMlD0) { + return false; + } } return true; } @@ -365,10 +403,6 @@ struct HfCandidateSelectorDstarToD0Pi { outputMlDstarToD0Pi.clear(); auto ptCand = candDstar.pt(); - auto prongPi = candDstar.prongPi_as(); - auto prong0 = candDstar.prong0_as(); - auto prong1 = candDstar.prong1_as(); - if (!TESTBIT(candDstar.hfflag(), aod::hf_cand_2prong::DecayType::D0ToPiK)) { hfSelDstarCandidate(statusDstar, statusD0Flag, statusTopol, statusCand, statusPID); if (applyMl) { @@ -417,16 +451,18 @@ struct HfCandidateSelectorDstarToD0Pi { int pidTrackNegKaon = -1; int pidTrackNegPion = -1; + auto prong0 = candDstar.prong0_as(); + auto prong1 = candDstar.prong1_as(); if (usePidTpcAndTof) { - pidTrackPosKaon = selectorKaon.statusTpcAndTof(candDstar.prong0_as()); - pidTrackPosPion = selectorPion.statusTpcAndTof(candDstar.prong0_as()); - pidTrackNegKaon = selectorKaon.statusTpcAndTof(candDstar.prong1_as()); - pidTrackNegPion = selectorPion.statusTpcAndTof(candDstar.prong1_as()); + pidTrackPosKaon = selectorKaon.statusTpcAndTof(prong0, candDstar.nSigTpcKa0(), candDstar.nSigTofKa0()); + pidTrackPosPion = selectorPion.statusTpcAndTof(prong0, candDstar.nSigTpcPi0(), candDstar.nSigTofPi0()); + pidTrackNegKaon = selectorKaon.statusTpcAndTof(prong1, candDstar.nSigTpcKa1(), candDstar.nSigTofKa1()); + pidTrackNegPion = selectorPion.statusTpcAndTof(prong1, candDstar.nSigTpcPi1(), candDstar.nSigTofPi1()); } else { - pidTrackPosKaon = selectorKaon.statusTpcOrTof(candDstar.prong0_as()); - pidTrackPosPion = selectorPion.statusTpcOrTof(candDstar.prong0_as()); - pidTrackNegKaon = selectorKaon.statusTpcOrTof(candDstar.prong1_as()); - pidTrackNegPion = selectorPion.statusTpcOrTof(candDstar.prong1_as()); + pidTrackPosKaon = selectorKaon.statusTpcOrTof(prong0, candDstar.nSigTpcKa0(), candDstar.nSigTofKa0()); + pidTrackPosPion = selectorPion.statusTpcOrTof(prong0, candDstar.nSigTpcPi0(), candDstar.nSigTofPi0()); + pidTrackNegKaon = selectorKaon.statusTpcOrTof(prong1, candDstar.nSigTpcKa1(), candDstar.nSigTofKa1()); + pidTrackNegPion = selectorPion.statusTpcOrTof(prong1, candDstar.nSigTpcPi1(), candDstar.nSigTofPi1()); } int pidDstar = -1; @@ -465,7 +501,7 @@ struct HfCandidateSelectorDstarToD0Pi { // ML selections bool isSelectedMlDstar = false; - std::vector inputFeatures = hfMlResponse.getInputFeatures(candDstar, prong0, prong1, prongPi); + std::vector inputFeatures = hfMlResponse.getInputFeatures(candDstar); isSelectedMlDstar = hfMlResponse.isSelectedMl(inputFeatures, ptCand, outputMlDstarToD0Pi); hfMlDstarCandidate(outputMlDstarToD0Pi); diff --git a/PWGHF/TableProducer/candidateSelectorLbToLcPi.cxx b/PWGHF/TableProducer/candidateSelectorLbToLcPi.cxx index d9b1872e83e..74abba33758 100644 --- a/PWGHF/TableProducer/candidateSelectorLbToLcPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorLbToLcPi.cxx @@ -14,17 +14,26 @@ /// /// \author Panos Christakoglou , Nikhef -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::framework; @@ -51,7 +60,7 @@ struct HfCandidateSelectorLbToLcPi { Configurable maxDecayLengthError{"maxDecayLengthError", 0.015, "decay length error quality selection"}; Configurable maxDecayLengthXYError{"maxDecayLengthXYError", 0.01, "decay length xy error quality selection"}; Configurable maxVertexDistanceLbLc{"maxVertexDistanceLbLc", 0.05, "maximum distance between Lb and Lc vertex"}; - Configurable> cuts{"cuts", {hf_cuts_lb_to_lc_pi::cuts[0], hf_cuts_lb_to_lc_pi::nBinsPt, hf_cuts_lb_to_lc_pi::nCutVars, hf_cuts_lb_to_lc_pi::labelsPt, hf_cuts_lb_to_lc_pi::labelsCutVar}, "Lb0 candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_lb_to_lc_pi::Cuts[0], hf_cuts_lb_to_lc_pi::NBinsPt, hf_cuts_lb_to_lc_pi::NCutVars, hf_cuts_lb_to_lc_pi::labelsPt, hf_cuts_lb_to_lc_pi::labelsCutVar}, "Lb0 candidate selection per pT bin"}; Configurable selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc+"}; HfHelper hfHelper; @@ -60,7 +69,7 @@ struct HfCandidateSelectorLbToLcPi { bool passesImpactParameterResolution(float pT, float d0Resolution) { - float expectedResolution(0.001 + 0.0052 * exp(-0.655 * pT)); + float expectedResolution(0.001 + 0.0052 * std::exp(-0.655 * pT)); if (d0Resolution > expectedResolution * 1.5) return false; else @@ -147,7 +156,7 @@ struct HfCandidateSelectorLbToLcPi { float diffXVert = hfCandLb.xSecondaryVertex() - hfCandLc.xSecondaryVertex(); float diffYVert = hfCandLb.ySecondaryVertex() - hfCandLc.ySecondaryVertex(); float diffZVert = hfCandLb.zSecondaryVertex() - hfCandLc.zSecondaryVertex(); - float vertexDistance = sqrt(diffXVert * diffXVert + diffYVert * diffYVert + diffZVert * diffZVert); + float vertexDistance = std::sqrt(diffXVert * diffXVert + diffYVert * diffYVert + diffZVert * diffZVert); if (vertexDistance > maxVertexDistanceLbLc) { return false; } @@ -162,14 +171,6 @@ struct HfCandidateSelectorLbToLcPi { for (const auto& hfCandLb : hfCandLbs) { // looping over Lb candidates int statusLb = 0; - - // check if flagged as Λb --> Λc+ π- - if (!(hfCandLb.hfflag() & 1 << hf_cand_lb::DecayType::LbToLcPi)) { - hfSelLbToLcPiCandidate(statusLb); - // LOGF(debug, "Lb candidate selection failed at hfflag check"); - continue; - } - // Lc is always index0 and pi is index1 by default // auto candLc = hfCandLb.prong0(); auto candLc = hfCandLb.prong0_as>(); diff --git a/PWGHF/TableProducer/candidateSelectorLc.cxx b/PWGHF/TableProducer/candidateSelectorLc.cxx index 818d65bb269..2b06decbec7 100644 --- a/PWGHF/TableProducer/candidateSelectorLc.cxx +++ b/PWGHF/TableProducer/candidateSelectorLc.cxx @@ -17,21 +17,36 @@ /// \author Vít Kučera , CERN /// \author Grazia Luparello , INFN Trieste -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponseLcToPKPi.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/TrackSelectorPID.h" +#include "Common/DataModel/PIDResponseCombined.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -69,18 +84,21 @@ struct HfCandidateSelectorLc { Configurable itsChi2PerClusterMax{"itsChi2PerClusterMax", 1e10f, "max its fit chi2 per ITS cluster"}; // DCA track cuts Configurable> binsPtTrack{"binsPtTrack", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for DCA XY/Z pT-dependent cut"}; - Configurable> cutsSingleTrack{"cutsSingleTrack", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections"}; + Configurable> cutsSingleTrack{"cutsSingleTrack", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_lc_to_p_k_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_lc_to_p_k_pi::cuts[0], hf_cuts_lc_to_p_k_pi::nBinsPt, hf_cuts_lc_to_p_k_pi::nCutVars, hf_cuts_lc_to_p_k_pi::labelsPt, hf_cuts_lc_to_p_k_pi::labelsCutVar}, "Lc candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_lc_to_p_k_pi::Cuts[0], hf_cuts_lc_to_p_k_pi::NBinsPt, hf_cuts_lc_to_p_k_pi::NCutVars, hf_cuts_lc_to_p_k_pi::labelsPt, hf_cuts_lc_to_p_k_pi::labelsCutVar}, "Lc candidate selection per pT bin"}; + Configurable> kfCuts{"kfCuts", {hf_cuts_lc_to_p_k_pi::CutsKf[0], hf_cuts_lc_to_p_k_pi::NBinsPt, hf_cuts_lc_to_p_k_pi::NCutKfVars, hf_cuts_lc_to_p_k_pi::labelsPt, hf_cuts_lc_to_p_k_pi::labelsCutKfVar}, "Lc candidate selection per pT bin with KF-associated variables"}; + Configurable applyNonKfCuts{"applyNonKfCuts", true, "Whether to apply non-KF cuts when running in KF mode. In DCAFitter mode this field is not effective"}; + Configurable applyKfCuts{"applyKfCuts", true, "Whether to apply KF cuts when running in KF mode. In DCAFitter mode this field is not effective"}; // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; // ML inference Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -90,7 +108,8 @@ struct HfCandidateSelectorLc { Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; HfHelper hfHelper; - o2::analysis::HfMlResponseLcToPKPi hfMlResponse; + o2::analysis::HfMlResponseLcToPKPi hfMlResponseDCA; + o2::analysis::HfMlResponseLcToPKPi hfMlResponseKF; std::vector outputMlLcToPKPi = {}; std::vector outputMlLcToPiKP = {}; o2::ccdb::CcdbApi ccdbApi; @@ -108,7 +127,7 @@ struct HfCandidateSelectorLc { void init(InitContext const&) { - std::array processes = {doprocessNoBayesPid, doprocessBayesPid}; + std::array processes = {doprocessNoBayesPidWithDCAFitterN, doprocessBayesPidWithDCAFitterN, doprocessNoBayesPidWithKFParticle, doprocessBayesPidWithKFParticle}; if (std::accumulate(processes.begin(), processes.end(), 0) != 1) { LOGP(fatal, "One and only one process function must be enabled at a time."); } @@ -139,15 +158,28 @@ struct HfCandidateSelectorLc { } if (applyMl) { - hfMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); - if (loadModelsFromCCDB) { - ccdbApi.init(ccdbUrl); - hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); - } else { - hfMlResponse.setModelPathsLocal(onnxFileNames); + if (doprocessNoBayesPidWithDCAFitterN || doprocessBayesPidWithDCAFitterN) { + hfMlResponseDCA.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponseDCA.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponseDCA.setModelPathsLocal(onnxFileNames); + } + hfMlResponseDCA.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponseDCA.init(); + } + if (doprocessNoBayesPidWithKFParticle || doprocessBayesPidWithKFParticle) { + hfMlResponseKF.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponseKF.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponseKF.setModelPathsLocal(onnxFileNames); + } + hfMlResponseKF.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponseKF.init(); } - hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); - hfMlResponse.init(); } massK0Star892 = o2::constants::physics::MassK0Star892; @@ -175,7 +207,7 @@ struct HfCandidateSelectorLc { /// Conjugate-independent topological cuts /// \param candidate is candidate /// \return true if candidate passes all cuts - template + template bool selectionTopol(const T& candidate) { auto candpT = candidate.pt(); @@ -190,33 +222,54 @@ struct HfCandidateSelectorLc { return false; } - // cosine of pointing angle - if (candidate.cpa() <= cuts->get(pTBin, "cos pointing angle")) { - return false; - } + if (reconstructionType == aod::hf_cand::VertexerType::DCAFitter || (reconstructionType == aod::hf_cand::VertexerType::KfParticle && applyNonKfCuts)) { + // cosine of pointing angle + if (candidate.cpa() <= cuts->get(pTBin, "cos pointing angle")) { + return false; + } - // candidate chi2PCA - if (candidate.chi2PCA() > cuts->get(pTBin, "Chi2PCA")) { - return false; - } + // candidate chi2PCA + if (candidate.chi2PCA() > cuts->get(pTBin, "Chi2PCA")) { + return false; + } - if (candidate.decayLength() <= cuts->get(pTBin, "decay length")) { - return false; - } + if (candidate.decayLength() <= cuts->get(pTBin, "decay length")) { + return false; + } - // candidate decay length XY - if (candidate.decayLengthXY() <= cuts->get(pTBin, "decLengthXY")) { - return false; - } + // candidate decay length XY + if (candidate.decayLengthXY() <= cuts->get(pTBin, "decLengthXY")) { + return false; + } - // candidate normalized decay length XY - if (candidate.decayLengthXYNormalised() < cuts->get(pTBin, "normDecLXY")) { - return false; + // candidate normalized decay length XY + if (candidate.decayLengthXYNormalised() < cuts->get(pTBin, "normDecLXY")) { + return false; + } + + // candidate impact parameter XY + if (std::abs(candidate.impactParameterXY()) > cuts->get(pTBin, "impParXY")) { + return false; + } } - // candidate impact parameter XY - if (std::abs(candidate.impactParameterXY()) > cuts->get(pTBin, "impParXY")) { - return false; + if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { + if (applyKfCuts) { + // candidate chi2geo of the triplet of prongs + if (candidate.kfChi2Geo() > kfCuts->get(pTBin, "kfChi2Geo")) { + return false; + } + + // candidate's decay point separation from the PV in terms of its error + if (candidate.kfDecayLength() / candidate.kfDecayLengthError() < kfCuts->get(pTBin, "kfLdL")) { + return false; + } + + // candidate's chi2 to the PV + if (candidate.kfChi2Topo() > kfCuts->get(pTBin, "kfChi2Topo")) { + return false; + } + } } if (!isSelectedCandidateProngDca(candidate)) { @@ -232,7 +285,7 @@ struct HfCandidateSelectorLc { /// \param trackPion is the track with the pion hypothesis /// \param trackKaon is the track with the kaon hypothesis /// \return true if candidate passes all cuts for the given Conjugate - template + template bool selectionTopolConjugate(const T1& candidate, const T2& trackProton, const T2& trackKaon, const T2& trackPion) { @@ -242,35 +295,114 @@ struct HfCandidateSelectorLc { return false; } - // cut on daughter pT - if (trackProton.pt() < cuts->get(pTBin, "pT p") || trackKaon.pt() < cuts->get(pTBin, "pT K") || trackPion.pt() < cuts->get(pTBin, "pT Pi")) { - return false; - } + if (reconstructionType == aod::hf_cand::VertexerType::DCAFitter || (reconstructionType == aod::hf_cand::VertexerType::KfParticle && applyNonKfCuts)) { - // cut on Lc->pKpi, piKp mass values - if (trackProton.globalIndex() == candidate.prong0Id()) { - if (std::abs(hfHelper.invMassLcToPKPi(candidate) - o2::constants::physics::MassLambdaCPlus) > cuts->get(pTBin, "m")) { + // cut on daughter pT + if (trackProton.pt() < cuts->get(pTBin, "pT p") || trackKaon.pt() < cuts->get(pTBin, "pT K") || trackPion.pt() < cuts->get(pTBin, "pT Pi")) { return false; } - } else { - if (std::abs(hfHelper.invMassLcToPiKP(candidate) - o2::constants::physics::MassLambdaCPlus) > cuts->get(pTBin, "m")) { + + float massLc{0.f}, massKPi{0.f}; + if constexpr (reconstructionType == aod::hf_cand::VertexerType::DCAFitter) { + if (trackProton.globalIndex() == candidate.prong0Id()) { + massLc = hfHelper.invMassLcToPKPi(candidate); + massKPi = hfHelper.invMassKPiPairLcToPKPi(candidate); + } else { + massLc = hfHelper.invMassLcToPiKP(candidate); + massKPi = hfHelper.invMassKPiPairLcToPiKP(candidate); + } + } else if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { + if (trackProton.globalIndex() == candidate.prong0Id()) { + massLc = candidate.kfMassPKPi(); + massKPi = candidate.kfMassKPi(); + } else { + massLc = candidate.kfMassPiKP(); + massKPi = candidate.kfMassPiK(); + } + } + + // cut on Lc->pKpi, piKp mass values + if (std::abs(massLc - o2::constants::physics::MassLambdaCPlus) > cuts->get(pTBin, "m")) { + return false; + } + + /// cut on the Kpi pair invariant mass, to study Lc->pK*(->Kpi) + const double cutMassKPi = cuts->get(pTBin, "mass (Kpi)"); + if (cutMassKPi > 0 && std::abs(massKPi - massK0Star892) > cutMassKPi) { return false; } } - /// cut on the Kpi pair invariant mass, to study Lc->pK*(->Kpi) - const double cutMassKPi = cuts->get(pTBin, "mass (Kpi)"); - if (cutMassKPi > 0) { - if (trackProton.globalIndex() == candidate.prong0Id()) { - // inspecting the pKpi hypothesis - // K: prong1, pi: prong 2 - if (std::abs(hfHelper.invMassKPiPairLcToPKPi(candidate) - massK0Star892) > cutMassKPi) { + if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { + if (applyKfCuts) { + const float chi2PrimProng0 = candidate.kfChi2PrimProng0(); + const float chi2PrimProng1 = candidate.kfChi2PrimProng1(); + const float chi2PrimProng2 = candidate.kfChi2PrimProng2(); + + const float chi2GeoProng1Prong2 = candidate.kfChi2GeoProng1Prong2(); + const float chi2GeoProng0Prong2 = candidate.kfChi2GeoProng0Prong2(); + const float chi2GeoProng0Prong1 = candidate.kfChi2GeoProng0Prong1(); + + const float dcaProng1Prong2 = candidate.kfDcaProng1Prong2(); + const float dcaProng0Prong2 = candidate.kfDcaProng0Prong2(); + const float dcaProng0Prong1 = candidate.kfDcaProng0Prong1(); + + const double cutChi2PrimPr = kfCuts->get(pTBin, "kfChi2PrimPr"); + const double cutChi2PrimKa = kfCuts->get(pTBin, "kfChi2PrimKa"); + const double cutChi2PrimPi = kfCuts->get(pTBin, "kfChi2PrimPi"); + + const double cutChi2GeoKaPi = kfCuts->get(pTBin, "kfChi2GeoKaPi"); + const double cutChi2GeoPrPi = kfCuts->get(pTBin, "kfChi2GeoPrPi"); + const double cutChi2GeoPrKa = kfCuts->get(pTBin, "kfChi2GeoPrKa"); + + const double cutDcaKaPi = kfCuts->get(pTBin, "kfDcaKaPi"); + const double cutDcaPrPi = kfCuts->get(pTBin, "kfDcaPrPi"); + const double cutDcaPrKa = kfCuts->get(pTBin, "kfDcaPrKa"); + + // kaon's chi2 to the PV + if (chi2PrimProng1 < cutChi2PrimKa) { + return false; + } + + // chi2geo between proton and pion + if (chi2GeoProng0Prong2 > cutChi2GeoPrPi) { + return false; + } + + // dca between proton and pion + if (dcaProng0Prong2 > cutDcaPrPi) { + return false; + } + + const bool isPKPi = trackProton.globalIndex() == candidate.prong0Id(); + + // 0-th prong chi2 to the PV + if (chi2PrimProng0 < (isPKPi ? cutChi2PrimPr : cutChi2PrimPi)) { return false; } - } else { - // inspecting the piKp hypothesis - // K: prong1, pi: prong 0 - if (std::abs(hfHelper.invMassKPiPairLcToPiKP(candidate) - massK0Star892) > cutMassKPi) { + + // 2-nd prong chi2 to the PV + if (chi2PrimProng2 < (isPKPi ? cutChi2PrimPi : cutChi2PrimPr)) { + return false; + } + + // chi2geo between 1-st and 2-nd prongs + if (chi2GeoProng1Prong2 > (isPKPi ? cutChi2GeoKaPi : cutChi2GeoPrKa)) { + return false; + } + + // chi2geo between 0-th and 1-st prongs + if (chi2GeoProng0Prong1 > (isPKPi ? cutChi2GeoPrKa : cutChi2GeoKaPi)) { + return false; + } + + // dca between 1-st and 2-nd prongs + if (dcaProng1Prong2 > (isPKPi ? cutDcaKaPi : cutDcaPrKa)) { + return false; + } + + // dca between 0-th and 1-st prongs + if (dcaProng0Prong1 > (isPKPi ? cutDcaPrKa : cutDcaKaPi)) { return false; } } @@ -306,10 +438,11 @@ struct HfCandidateSelectorLc { } /// \brief function to apply Lc selections + /// \param reconstructionType is the reconstruction type (DCAFitterN or KFParticle) /// \param candidates Lc candidate table /// \param tracks track table - template - void runSelectLc(aod::HfCand3Prong const& candidates, TTracks const&) + template + void runSelectLc(CandType const& candidates, TTracks const&) { // looping over 3-prong candidates for (const auto& candidate : candidates) { @@ -355,7 +488,7 @@ struct HfCandidateSelectorLc { } // conjugate-independent topological selection - if (!selectionTopol(candidate)) { + if (!selectionTopol(candidate)) { hfSelLcCandidate(statusLcToPKPi, statusLcToPiKP); if (applyMl) { hfMlLcToPKPiCandidate(outputMlLcToPKPi, outputMlLcToPiKP); @@ -364,8 +497,8 @@ struct HfCandidateSelectorLc { } // conjugate-dependent topological selection for Lc - bool topolLcToPKPi = selectionTopolConjugate(candidate, trackPos1, trackNeg, trackPos2); - bool topolLcToPiKP = selectionTopolConjugate(candidate, trackPos2, trackNeg, trackPos1); + bool topolLcToPKPi = selectionTopolConjugate(candidate, trackPos1, trackNeg, trackPos2); + bool topolLcToPiKP = selectionTopolConjugate(candidate, trackPos2, trackNeg, trackPos1); if (!topolLcToPKPi && !topolLcToPiKP) { hfSelLcCandidate(statusLcToPKPi, statusLcToPiKP); @@ -393,17 +526,17 @@ struct HfCandidateSelectorLc { TrackSelectorPID::Status pidTrackPos2Pion = TrackSelectorPID::Accepted; TrackSelectorPID::Status pidTrackNegKaon = TrackSelectorPID::Accepted; if (usePidTpcAndTof) { - pidTrackPos1Proton = selectorProton.statusTpcAndTof(trackPos1); - pidTrackPos2Proton = selectorProton.statusTpcAndTof(trackPos2); - pidTrackPos1Pion = selectorPion.statusTpcAndTof(trackPos1); - pidTrackPos2Pion = selectorPion.statusTpcAndTof(trackPos2); - pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg); + pidTrackPos1Proton = selectorProton.statusTpcAndTof(trackPos1, candidate.nSigTpcPr0(), candidate.nSigTofPr0()); + pidTrackPos2Proton = selectorProton.statusTpcAndTof(trackPos2, candidate.nSigTpcPr2(), candidate.nSigTofPr2()); + pidTrackPos1Pion = selectorPion.statusTpcAndTof(trackPos1, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + pidTrackPos2Pion = selectorPion.statusTpcAndTof(trackPos2, candidate.nSigTpcPi2(), candidate.nSigTofPi2()); + pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); } else { - pidTrackPos1Proton = selectorProton.statusTpcOrTof(trackPos1); - pidTrackPos2Proton = selectorProton.statusTpcOrTof(trackPos2); - pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1); - pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2); - pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg); + pidTrackPos1Proton = selectorProton.statusTpcOrTof(trackPos1, candidate.nSigTpcPr0(), candidate.nSigTofPr0()); + pidTrackPos2Proton = selectorProton.statusTpcOrTof(trackPos2, candidate.nSigTpcPr2(), candidate.nSigTofPr2()); + pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2, candidate.nSigTpcPi2(), candidate.nSigTofPi2()); + pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); } if (!isSelectedPID(pidTrackPos1Proton, pidTrackNegKaon, pidTrackPos2Pion)) { @@ -449,13 +582,24 @@ struct HfCandidateSelectorLc { isSelectedMlLcToPKPi = false; isSelectedMlLcToPiKP = false; - if (pidLcToPKPi == 1 && pidBayesLcToPKPi == 1 && topolLcToPKPi) { - std::vector inputFeaturesLcToPKPi = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2, true); - isSelectedMlLcToPKPi = hfMlResponse.isSelectedMl(inputFeaturesLcToPKPi, candidate.pt(), outputMlLcToPKPi); - } - if (pidLcToPiKP == 1 && pidBayesLcToPiKP == 1 && topolLcToPiKP) { - std::vector inputFeaturesLcToPiKP = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2, false); - isSelectedMlLcToPiKP = hfMlResponse.isSelectedMl(inputFeaturesLcToPiKP, candidate.pt(), outputMlLcToPiKP); + if constexpr (reconstructionType == aod::hf_cand::VertexerType::DCAFitter) { + if (pidLcToPKPi == 1 && pidBayesLcToPKPi == 1 && topolLcToPKPi) { + std::vector inputFeaturesLcToPKPi = hfMlResponseDCA.getInputFeatures(candidate, true); + isSelectedMlLcToPKPi = hfMlResponseDCA.isSelectedMl(inputFeaturesLcToPKPi, candidate.pt(), outputMlLcToPKPi); + } + if (pidLcToPiKP == 1 && pidBayesLcToPiKP == 1 && topolLcToPiKP) { + std::vector inputFeaturesLcToPiKP = hfMlResponseDCA.getInputFeatures(candidate, false); + isSelectedMlLcToPiKP = hfMlResponseDCA.isSelectedMl(inputFeaturesLcToPiKP, candidate.pt(), outputMlLcToPiKP); + } + } else { + if (pidLcToPKPi == 1 && pidBayesLcToPKPi == 1 && topolLcToPKPi) { + std::vector inputFeaturesLcToPKPi = hfMlResponseKF.getInputFeatures(candidate, true); + isSelectedMlLcToPKPi = hfMlResponseKF.isSelectedMl(inputFeaturesLcToPKPi, candidate.pt(), outputMlLcToPKPi); + } + if (pidLcToPiKP == 1 && pidBayesLcToPiKP == 1 && topolLcToPiKP) { + std::vector inputFeaturesLcToPiKP = hfMlResponseKF.getInputFeatures(candidate, false); + isSelectedMlLcToPiKP = hfMlResponseKF.isSelectedMl(inputFeaturesLcToPiKP, candidate.pt(), outputMlLcToPiKP); + } } hfMlLcToPKPiCandidate(outputMlLcToPKPi, outputMlLcToPiKP); @@ -481,25 +625,45 @@ struct HfCandidateSelectorLc { } } - /// \brief process function w/o Bayes PID + /// \brief process function w/o Bayes PID with DCAFitterN + /// \param candidates Lc candidate table + /// \param tracks track table + void processNoBayesPidWithDCAFitterN(aod::HfCand3ProngWPidPiKaPr const& candidates, + TracksSel const& tracks) + { + runSelectLc(candidates, tracks); + } + PROCESS_SWITCH(HfCandidateSelectorLc, processNoBayesPidWithDCAFitterN, "Process Lc selection w/o Bayes PID with DCAFitterN", true); + + /// \brief process function with Bayes PID with DCAFitterN + /// \param candidates Lc candidate table + /// \param tracks track table with Bayes PID information + void processBayesPidWithDCAFitterN(aod::HfCand3ProngWPidPiKaPr const& candidates, + TracksSelBayesPid const& tracks) + { + runSelectLc(candidates, tracks); + } + PROCESS_SWITCH(HfCandidateSelectorLc, processBayesPidWithDCAFitterN, "Process Lc selection with Bayes PID with DCAFitterN", false); + + /// \brief process function w/o Bayes PID with KFParticle /// \param candidates Lc candidate table /// \param tracks track table - void processNoBayesPid(aod::HfCand3Prong const& candidates, - TracksSel const& tracks) + void processNoBayesPidWithKFParticle(soa::Join const& candidates, + TracksSel const& tracks) { - runSelectLc(candidates, tracks); + runSelectLc(candidates, tracks); } - PROCESS_SWITCH(HfCandidateSelectorLc, processNoBayesPid, "Process Lc selection w/o Bayes PID", true); + PROCESS_SWITCH(HfCandidateSelectorLc, processNoBayesPidWithKFParticle, "Process Lc selection w/o Bayes PID with KFParticle", false); - /// \brief process function with Bayes PID + /// \brief process function with Bayes PID with KFParticle /// \param candidates Lc candidate table /// \param tracks track table with Bayes PID information - void processBayesPid(aod::HfCand3Prong const& candidates, - TracksSelBayesPid const& tracks) + void processBayesPidWithKFParticle(soa::Join const& candidates, + TracksSelBayesPid const& tracks) { - runSelectLc(candidates, tracks); + runSelectLc(candidates, tracks); } - PROCESS_SWITCH(HfCandidateSelectorLc, processBayesPid, "Process Lc selection with Bayes PID", false); + PROCESS_SWITCH(HfCandidateSelectorLc, processBayesPidWithKFParticle, "Process Lc selection with Bayes PID with KFParticle", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/candidateSelectorLcPidMl.cxx b/PWGHF/TableProducer/candidateSelectorLcPidMl.cxx index 1bac21ed7cf..9a68436f861 100644 --- a/PWGHF/TableProducer/candidateSelectorLcPidMl.cxx +++ b/PWGHF/TableProducer/candidateSelectorLcPidMl.cxx @@ -17,18 +17,41 @@ /// \author Vít Kučera , CERN /// \author Maja Kabus , CERN, Warsaw University of Technology -#include "CommonConstants/PhysicsConstants.h" -#include "CCDB/CcdbApi.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelectorPID.h" #include "Common/Core/trackUtilities.h" +#include "Common/DataModel/PIDResponseCombined.h" #include "Tools/ML/model.h" -#include "PWGHF/Core/SelectorCuts.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -61,7 +84,7 @@ struct HfCandidateSelectorLcPidMl { // ONNX BDT Configurable applyML{"applyML", false, "Flag to enable or disable ML application"}; Configurable onnxFileLcToPiKPConf{"onnxFileLcToPiKPConf", "/cvmfs/alice.cern.ch/data/analysis/2022/vAN-20220818/PWGHF/o2/trigger/ModelHandler_onnx_LcToPKPi.onnx", "ONNX file for ML model for Lc+ candidates"}; - Configurable> thresholdBDTScoreLcToPiKP{"thresholdBDTScoreLcToPiKP", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Lc+ candidates"}; + Configurable> thresholdBDTScoreLcToPiKP{"thresholdBDTScoreLcToPiKP", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for BDT output scores of Lc+ candidates"}; Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable mlModelPathCCDB{"mlModelPathCCDB", "Analysis/PWGHF/ML/HFTrigger/Lc", "Path on CCDB"}; @@ -123,15 +146,11 @@ struct HfCandidateSelectorLcPidMl { } if (retrieveSuccess) { auto session = model.getSession(); -#if __has_include() - auto inputShapes = session->GetInputShapes(); -#else std::vector> inputShapes; Ort::AllocatorWithDefaultOptions tmpAllocator; for (size_t i = 0; i < session->GetInputCount(); ++i) { inputShapes.emplace_back(session->GetInputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape()); } -#endif if (inputShapes[0][0] < 0) { LOGF(warning, "Model for Lc with negative input shape likely because converted with hummingbird, setting it to 1."); inputShapes[0][0] = 1; @@ -145,7 +164,7 @@ struct HfCandidateSelectorLcPidMl { } } - void process(aod::HfCand3Prong const& candidates, + void process(aod::HfCand3ProngWPidPiKaPr const& candidates, TracksSel const&) { // looping over 3-prong candidates @@ -177,11 +196,11 @@ struct HfCandidateSelectorLcPidMl { pidLcToPiKP = 1; } else { // track-level PID selection - int pidTrackPos1Proton = selectorProton.statusTpcOrTof(trackPos1); - int pidTrackPos2Proton = selectorProton.statusTpcOrTof(trackPos2); - int pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1); - int pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2); - int pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg); + TrackSelectorPID::Status pidTrackPos1Proton = selectorProton.statusTpcOrTof(trackPos1, candidate.nSigTpcPr0(), candidate.nSigTofPr0()); + TrackSelectorPID::Status pidTrackPos2Proton = selectorProton.statusTpcOrTof(trackPos2, candidate.nSigTpcPr2(), candidate.nSigTofPr2()); + TrackSelectorPID::Status pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + TrackSelectorPID::Status pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2, candidate.nSigTpcPi2(), candidate.nSigTofPi2()); + TrackSelectorPID::Status pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); if (pidTrackPos1Proton == TrackSelectorPID::Accepted && pidTrackNegKaon == TrackSelectorPID::Accepted && diff --git a/PWGHF/TableProducer/candidateSelectorLcToK0sP.cxx b/PWGHF/TableProducer/candidateSelectorLcToK0sP.cxx index c7b17972b8f..a4a026a005b 100644 --- a/PWGHF/TableProducer/candidateSelectorLcToK0sP.cxx +++ b/PWGHF/TableProducer/candidateSelectorLcToK0sP.cxx @@ -17,21 +17,37 @@ /// Daniel Samitz, , Vienna /// Elisa Meninno, , Vienna -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" -#include "PWGHF/Core/HfMlResponse.h" #include "PWGHF/Core/HfMlResponseLcToK0sP.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/TrackSelectorPID.h" +#include "Common/DataModel/PIDResponseCombined.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -59,13 +75,13 @@ struct HfCandidateSelectorLcToK0sP { Configurable probBayesMinHighP{"probBayesMinHighP", 0.8, "min. Bayes probability for bachelor at high p [%]"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_lc_to_k0s_p::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_lc_to_k0s_p::cuts[0], hf_cuts_lc_to_k0s_p::nBinsPt, hf_cuts_lc_to_k0s_p::nCutVars, hf_cuts_lc_to_k0s_p::labelsPt, hf_cuts_lc_to_k0s_p::labelsCutVar}, "Lc candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_lc_to_k0s_p::Cuts[0], hf_cuts_lc_to_k0s_p::NBinsPt, hf_cuts_lc_to_k0s_p::NCutVars, hf_cuts_lc_to_k0s_p::labelsPt, hf_cuts_lc_to_k0s_p::labelsCutVar}, "Lc candidate selection per pT bin"}; // ML inference Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -148,6 +164,10 @@ struct HfCandidateSelectorLcToK0sP { return false; // check that the candidate pT is within the analysis range } + if (std::abs(hfHelper.invMassLcToK0sP(hfCandCascade) - o2::constants::physics::MassLambdaCPlus) > cuts->get(ptBin, "mLc")) { + return false; // mass of the Lambda c + } + if (std::abs(hfCandCascade.mK0Short() - o2::constants::physics::MassK0Short) > cuts->get(ptBin, "mK0s")) { return false; // mass of the K0s } diff --git a/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaKa.cxx b/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaKa.cxx index b523f8bd7a4..d65b56a40a9 100644 --- a/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaKa.cxx +++ b/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaKa.cxx @@ -9,31 +9,46 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file candidateSelectorToOmegaKa.cxx +/// \file candidateSelectorOmegac0ToOmegaKa.cxx /// \brief Omegac0 → Omega Ka selection task /// \author Federica Zanone , Heidelberg University -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::analysis; -enum pidInfoStored { - kPiFromLam = 0, - kPrFromLam, - kKaFromCasc, - kKaFromCharm +enum PidInfoStored { + PiFromLam = 0, + PrFromLam, + KaFromCasc, + KaFromCharm }; /// Struct for applying Omegac0 -> Omega pi selection cuts @@ -423,28 +438,28 @@ struct HfCandidateSelectorToOmegaKa { } if (trackPiFromLam.hasTPC()) { - SETBIT(infoTpcStored, kPiFromLam); + SETBIT(infoTpcStored, PiFromLam); } if (trackPrFromLam.hasTPC()) { - SETBIT(infoTpcStored, kPrFromLam); + SETBIT(infoTpcStored, PrFromLam); } if (trackKaFromCasc.hasTPC()) { - SETBIT(infoTpcStored, kKaFromCasc); + SETBIT(infoTpcStored, KaFromCasc); } if (trackKaFromCharm.hasTPC()) { - SETBIT(infoTpcStored, kKaFromCharm); + SETBIT(infoTpcStored, KaFromCharm); } if (trackPiFromLam.hasTOF()) { - SETBIT(infoTofStored, kPiFromLam); + SETBIT(infoTofStored, PiFromLam); } if (trackPrFromLam.hasTOF()) { - SETBIT(infoTofStored, kPrFromLam); + SETBIT(infoTofStored, PrFromLam); } if (trackKaFromCasc.hasTOF()) { - SETBIT(infoTofStored, kKaFromCasc); + SETBIT(infoTofStored, KaFromCasc); } if (trackKaFromCharm.hasTOF()) { - SETBIT(infoTofStored, kKaFromCharm); + SETBIT(infoTofStored, KaFromCharm); } if (usePidTpcOnly) { @@ -567,7 +582,7 @@ struct HfCandidateSelectorToOmegaKa { } } } // end process -}; // end struct +}; // end struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPi.cxx b/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPi.cxx index 129887ed876..7b31151af9d 100644 --- a/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPi.cxx @@ -9,36 +9,63 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file candidateSelectorToOmegaPi.cxx +/// \file candidateSelectorOmegac0ToOmegaPi.cxx /// \brief Omegac0 → Omega Pi selection task /// \author Federica Zanone , Heidelberg University +/// \author Ruiqi Yin , Fudan University +/// \author Yunfan Liu , China University of Geosciences +/// \author Fabio Catalano , University of Houston -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectorPID.h" - +#include "PWGHF/Core/HfMlResponseOmegacToOmegaPi.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::analysis; -enum pidInfoStored { - kPiFromLam = 0, - kPrFromLam, - kKaFromCasc, - kPiFromCharm +enum PidInfoStored { + PiFromLam = 0, + PrFromLam, + KaFromCasc, + PiFromCharm }; /// Struct for applying Omegac0 -> Omega pi selection cuts struct HfCandidateSelectorToOmegaPi { Produces hfSelToOmegaPi; + Produces hfMlSelToOmegaPi; // LF analysis selections Configurable radiusCascMin{"radiusCascMin", 0.5, "Min cascade radius"}; @@ -68,7 +95,7 @@ struct HfCandidateSelectorToOmegaPi { Configurable impactParameterXYPiFromCharmBaryonMax{"impactParameterXYPiFromCharmBaryonMax", 10., "Max dcaxy pi from charm baryon track to PV"}; Configurable impactParameterZPiFromCharmBaryonMin{"impactParameterZPiFromCharmBaryonMin", 0., "Min dcaz pi from charm baryon track to PV"}; Configurable impactParameterZPiFromCharmBaryonMax{"impactParameterZPiFromCharmBaryonMax", 10., "Max dcaz pi from charm baryon track to PV"}; - + Configurable ptPionMin{"ptPionMin", 0., "Lower bound of Pion from Charmbaryon pT"}; Configurable impactParameterXYCascMin{"impactParameterXYCascMin", 0., "Min dcaxy cascade track to PV"}; Configurable impactParameterXYCascMax{"impactParameterXYCascMax", 10., "Max dcaxy cascade track to PV"}; Configurable impactParameterZCascMin{"impactParameterZCascMin", 0., "Min dcaz cascade track to PV"}; @@ -123,6 +150,49 @@ struct HfCandidateSelectorToOmegaPi { Configurable nClustersItsMin{"nClustersItsMin", 3, "Minimum number of ITS clusters requirement for pi <- charm baryon"}; Configurable nClustersItsInnBarrMin{"nClustersItsInnBarrMin", 1, "Minimum number of ITS clusters in inner barrel requirement for pi <- charm baryon"}; Configurable itsChi2PerClusterMax{"itsChi2PerClusterMax", 36, "Maximum value of chi2 fit over ITS clusters for pi <- charm baryon"}; + struct : ConfigurableGroup { + //// KF selection + std::string prefix = "kfSel"; + Configurable applyKFpreselections{"applyKFpreselections", false, "Apply KFParticle related rejection"}; + Configurable applyCompetingCascRejection{"applyCompetingCascRejection", false, "Apply competing Xi(for Omegac0) rejection"}; + Configurable cascadeRejMassWindow{"cascadeRejMassWindow", 0.01, "competing Xi(for Omegac0) rejection mass window"}; + Configurable v0LdlMin{"v0LdlMin", 3., "Minimum value of l/dl of V0"}; // l/dl and Chi2 are to be determined + Configurable cascLdlMin{"cascLdlMin", 1., "Minimum value of l/dl of casc"}; + Configurable omegacLdlMax{"omegacLdlMax", 5., "Maximum value of l/dl of Omegac"}; + Configurable cTauOmegacMax{"cTauOmegacMax", 0.4, "lifetime τ of Omegac"}; + Configurable v0Chi2OverNdfMax{"v0Chi2OverNdfMax", 100., "Maximum chi2Geo/NDF of V0"}; + Configurable cascChi2OverNdfMax{"cascChi2OverNdfMax", 100., "Maximum chi2Geo/NDF of casc"}; + Configurable omegacChi2OverNdfMax{"omegacChi2OverNdfMax", 100., "Maximum chi2Geo/NDF of Omegac"}; + Configurable chi2TopoV0ToCascMax{"chi2TopoV0ToCascMax", 100., "Maximum chi2Topo/NDF of V0ToCas"}; + Configurable chi2TopoOmegacToPvMax{"chi2TopoOmegacToPvMax", 100., "Maximum chi2Topo/NDF of OmegacToPv"}; + Configurable chi2TopoCascToOmegacMax{"chi2TopoCascToOmegacMax", 100., "Maximum chi2Topo/NDF of CascToOmegac"}; + Configurable chi2TopoCascToPvMax{"chi2TopoCascToPvMax", 100., "Maximum chi2Topo/NDF of CascToPv"}; + Configurable decayLenXYOmegacMax{"decayLenXYOmegacMax", 1.5, "Maximum decay lengthXY of Omegac"}; + Configurable decayLenXYCascMin{"decayLenXYCascMin", 1., "Minimum decay lengthXY of Cascade"}; + Configurable decayLenXYLambdaMin{"decayLenXYLambdaMin", 0., "Minimum decay lengthXY of V0"}; + Configurable cosPaCascToOmegacMin{"cosPaCascToOmegacMin", 0.995, "Minimum cosPA of cascade<-Omegac"}; + Configurable cosPaV0ToCascMin{"cosPaV0ToCascMin", 0.99, "Minimum cosPA of V0<-cascade"}; + } KfconfigurableGroup; + // topological cuts + Configurable> binsPt{"binsPt", std::vector{hf_cuts_omegac_to_omega_pi::vecBinsPt}, "pT bin limits"}; + Configurable> cuts{"cuts", {hf_cuts_omegac_to_omega_pi::Cuts[0], hf_cuts_omegac_to_omega_pi::NBinsPt, hf_cuts_omegac_to_omega_pi::NCutVars, hf_cuts_omegac_to_omega_pi::labelsPt, hf_cuts_omegac_to_omega_pi::labelsCutVar}, "OmegaC0 candidate selection per pT bin"}; + // ML inference + Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; + Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; + Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; + // CCDB configuration + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"EventFiltering/PWGHF/BDTOmegac0"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_Omegac0ToOmegaPi.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + + o2::analysis::HfMlResponseOmegacToOmegaPi hfMlResponse; + std::vector outputMlOmegac = {}; + o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; TrackSelectorPr selectorProton; @@ -133,10 +203,17 @@ struct HfCandidateSelectorToOmegaPi { HistogramRegistry registry{"registry"}; // for QA of selections - OutputObj hInvMassCharmBaryon{TH1F("hInvMassCharmBaryon", "Charm baryon invariant mass;inv mass;entries", 500, 2.3, 3.1)}; + OutputObj hInvMassCharmBaryon{TH1D("hInvMassCharmBaryon", "Charm baryon invariant mass;inv mass;entries", 500, 2.3, 3.1)}; + OutputObj hPtCharmBaryon{TH1D("hPtCharmBaryon", "Charm baryon transverse momentum before sel;Pt;entries", 8000, 0., 80)}; void init(InitContext const&) { + std::array processesSelector = {doprocessOmegac0SelectorWithDCAFitter, doprocessOmegac0SelectorWithKFParticle}; + const int nProcessesSelector = std::accumulate(processesSelector.begin(), processesSelector.end(), 0); + if (nProcessesSelector != 1) { + LOGP(fatal, "At most one process function for selector can be enabled at a time."); + } + selectorPion.setRangePtTpc(ptPiPidTpcMin, ptPiPidTpcMax); selectorPion.setRangeNSigmaTpc(-nSigmaTpcPiMax, nSigmaTpcPiMax); selectorPion.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedPiMax, nSigmaTpcCombinedPiMax); @@ -160,49 +237,114 @@ struct HfCandidateSelectorToOmegaPi { const AxisSpec axisSel{2, -0.5, 1.5, "status"}; - registry.add("hSelPID", "hSelPID;status;entries", {HistType::kTH1F, {{12, 0., 12.}}}); - registry.add("hStatusCheck", "Check consecutive selections status;status;entries", {HistType::kTH1F, {{12, 0., 12.}}}); + registry.add("hSelPID", "hSelPID;status;entries", {HistType::kTH1D, {{12, 0., 12.}}}); + registry.add("hStatusCheck", "Check consecutive selections status;status;entries", {HistType::kTH1D, {{12, 0., 12.}}}); // for QA of the selections (bin 0 -> candidates that did not pass the selection, bin 1 -> candidates that passed the selection) - registry.add("hSelSignDec", "hSelSignDec;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelEtaPosV0Dau", "hSelEtaPosV0Dau;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelEtaNegV0Dau", "hSelEtaNegV0Dau;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelEtaKaFromCasc", "hSelEtaKaFromCasc;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelEtaPiFromCharm", "hSelEtaPiFromCharm;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelRadCasc", "hSelRadCasc;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelRadV0", "hSelRadV0;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelCosPACasc", "hSelCosPACasc;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelCosPAV0", "hSelCosPAV0;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelDCACascDau", "hSelDCACascDau;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelDCAV0Dau", "hSelDCAV0Dau;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelDCACharmDau", "hSelDCACharmDau;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelDCAXYPrimPi", "hSelDCAXYPrimPi;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelDCAZPrimPi", "hSelDCAZPrimPi;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelDCAXYCasc", "hSelDCAXYCasc;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelDCAZCasc", "hSelDCAZCasc;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelPtKaFromCasc", "hSelPtKaFromCasc;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelPtPiFromCharm", "hSelPtPiFromCharm;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelTPCQualityPiFromCharm", "hSelTPCQualityPiFromCharm;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelTPCQualityPiFromLam", "hSelTPCQualityPiFromLam;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelTPCQualityPrFromLam", "hSelTPCQualityPrFromLam;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelTPCQualityKaFromCasc", "hSelTPCQualityKaFromCasc;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelITSQualityPiFromCharm", "hSelITSQualityPiFromCharm;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelMassLam", "hSelMassLam;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelMassCasc", "hSelMassCasc;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelMassCharmBaryon", "hSelMassCharmBaryon;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelDcaXYToPvV0Daughters", "hSelDcaXYToPvV0Daughters;status;entries", {HistType::kTH1F, {axisSel}}); - registry.add("hSelDcaXYToPvKaFromCasc", "hSelDcaXYToPvKaFromCasc;status;entries", {HistType::kTH1F, {axisSel}}); + registry.add("hSelSignDec", "hSelSignDec;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelEtaPosV0Dau", "hSelEtaPosV0Dau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelEtaNegV0Dau", "hSelEtaNegV0Dau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelEtaKaFromCasc", "hSelEtaKaFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelEtaPiFromCharm", "hSelEtaPiFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelRadCasc", "hSelRadCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelRadV0", "hSelRadV0;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelCosPACasc", "hSelCosPACasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelCosPAV0", "hSelCosPAV0;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCACascDau", "hSelDCACascDau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCAV0Dau", "hSelDCAV0Dau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCACharmDau", "hSelDCACharmDau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCAXYPrimPi", "hSelDCAXYPrimPi;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCAZPrimPi", "hSelDCAZPrimPi;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCAXYCasc", "hSelDCAXYCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCAZCasc", "hSelDCAZCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelPtKaFromCasc", "hSelPtKaFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelPtPiFromCharm", "hSelPtPiFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelTPCQualityPiFromCharm", "hSelTPCQualityPiFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelTPCQualityPiFromLam", "hSelTPCQualityPiFromLam;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelTPCQualityPrFromLam", "hSelTPCQualityPrFromLam;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelTPCQualityKaFromCasc", "hSelTPCQualityKaFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelITSQualityPiFromCharm", "hSelITSQualityPiFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelMassLam", "hSelMassLam;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelMassCasc", "hSelMassCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelMassCharmBaryon", "hSelMassCharmBaryon;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDcaXYToPvV0Daughters", "hSelDcaXYToPvV0Daughters;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDcaXYToPvKaFromCasc", "hSelDcaXYToPvKaFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); + + if (KfconfigurableGroup.applyKFpreselections) { + registry.add("hSelPtOmegac", "hSelPtOmegac;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelCompetingCasc", "hSelCompetingCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelKFstatus", "hSelKFstatus;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelV0_Casc_Omegacldl", "hSelV0_Casc_Omegacldl;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelctauOmegac", "hSelctauOmegac;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelChi2GeooverNDFV0_Casc_Omegac", "hSelChi2GeooverNDFV0_Casc_Omegac;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelChi2TopooverNDFV0_Casc_Omegac", "hSelChi2TopooverNDFV0_Casc_Omegac;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSeldecayLenXYOmegac_Casc_V0", "hSeldecayLenXYOmegac_Casc_V0;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelcosPaCascToOmegac_V0ToCasc", "hSelcosPaCascToOmegac_V0ToCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hInvMassXiMinus_rej_cut", "hInvMassXiMinus_rej_cut", kTH1D, {{1000, 1.25f, 1.65f}}); + } + if (applyMl) { + registry.add("hBDTScoreTest1", "hBDTScoreTest1", {HistType::kTH1D, {{100, 0.0f, 1.0f, "score"}}}); + hfMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponse.setModelPathsLocal(onnxFileNames); + } + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponse.init(); + } } + // for pT-dependent cuts (other selections will move into this in futrue) + // \param hfCandOmegac is candidate + // return true if candidate passes all cuts + template + bool selectionTopol(const T1& hfCandOmegac) + { + auto candpT = hfCandOmegac.ptCharmBaryon(); + auto pionPtFromOmegac = hfCandOmegac.ptPiFromCharmBaryon(); + int pTBin = findBin(binsPt, candpT); + if (pTBin == -1) { + return false; + } + + // check that the candidate pT is within the analysis range + if (candpT <= ptCandMin || candpT >= ptCandMax) { + return false; + } - void process(aod::HfCandToOmegaPi const& candidates, - TracksSel const& tracks, - TracksSelLf const& lfTracks) + // check that the candidate pT is within the analysis range + if (pionPtFromOmegac < cuts->get(pTBin, "pT pi from Omegac")) { + registry.fill(HIST("hSelPtPiFromCharm"), 0); + return false; + } else { + registry.fill(HIST("hSelPtPiFromCharm"), 1); + } + + return true; + } // end template + + template + void runOmegac0Selector(const Candidates& candidates, + TracksSel const& tracks, + TracksSelLf const& lfTracks) { // looping over charm baryon candidates for (const auto& candidate : candidates) { + // initializing selection flags + bool statusPidLambda = false; + bool statusPidCascade = false; + bool statusPidCharmBaryon = false; + + bool statusInvMassLambda = false; + bool statusInvMassCascade = false; + bool statusInvMassCharmBaryon = false; bool resultSelections = true; // True if the candidate passes all the selections, False otherwise + int infoTpcStored = 0; + int infoTofStored = 0; + auto trackV0PosDauId = candidate.posTrackId(); // positive V0 daughter auto trackV0NegDauId = candidate.negTrackId(); // negative V0 daughter auto trackKaFromCascId = candidate.bachelorId(); // kaon <- cascade @@ -215,6 +357,7 @@ struct HfCandidateSelectorToOmegaPi { auto trackPiFromLam = trackV0NegDau; auto trackPrFromLam = trackV0PosDau; + auto ptCand = candidate.ptCharmBaryon(); int8_t signDecay = candidate.signDecay(); // sign of pi <- cascade if (signDecay > 0) { @@ -225,6 +368,20 @@ struct HfCandidateSelectorToOmegaPi { registry.fill(HIST("hSelSignDec"), 0); // particle decay } + // pt-dependent selection + if (!selectionTopol(candidate)) { + resultSelections = false; + hfSelToOmegaPi(statusPidLambda, statusPidCascade, statusPidCharmBaryon, statusInvMassLambda, statusInvMassCascade, statusInvMassCharmBaryon, resultSelections, infoTpcStored, infoTofStored, + trackPiFromCharm.tpcNSigmaPi(), trackKaFromCasc.tpcNSigmaKa(), trackPiFromLam.tpcNSigmaPi(), trackPrFromLam.tpcNSigmaPr(), + trackPiFromCharm.tofNSigmaPi(), trackKaFromCasc.tofNSigmaKa(), trackPiFromLam.tofNSigmaPi(), trackPrFromLam.tofNSigmaPr()); + if constexpr (ConstructMethod == hf_cand_casc_lf::ConstructMethod::KfParticle) { + if (applyMl) { + hfMlSelToOmegaPi(outputMlOmegac); + } + } + continue; + } + // eta selection double etaV0PosDau = candidate.etaV0PosDau(); double etaV0NegDau = candidate.etaV0NegDau(); @@ -366,6 +523,89 @@ struct HfCandidateSelectorToOmegaPi { registry.fill(HIST("hSelPtPiFromCharm"), 1); } + if constexpr (ConstructMethod == hf_cand_casc_lf::ConstructMethod::KfParticle) { + // KFParticle Preselections(kfsel) + if (KfconfigurableGroup.applyKFpreselections) { + + bool inputKF = false; + if (resultSelections) { + inputKF = true; + registry.fill(HIST("hSelKFstatus"), 0); + } + + // Competing Ξ rejection(KF) Try to reject cases in which the candidate has a an inv. mass compatibler to Xi (bachelor pion) instead of Omega (bachelor kaon) + if (KfconfigurableGroup.applyCompetingCascRejection) { + if (std::abs(candidate.cascRejectInvmass() - o2::constants::physics::MassXiMinus) < KfconfigurableGroup.cascadeRejMassWindow) { + resultSelections = false; + registry.fill(HIST("hSelCompetingCasc"), 0); + } else { + registry.fill(HIST("hSelCompetingCasc"), 1); + registry.fill(HIST("hInvMassXiMinus_rej_cut"), candidate.cascRejectInvmass()); + } + } + + // Omegac Pt selection + if (std::abs(candidate.kfptOmegac()) < ptCandMin || std::abs(candidate.kfptOmegac()) > ptCandMax) { + resultSelections = false; + registry.fill(HIST("hSelPtOmegac"), 0); + } else { + registry.fill(HIST("hSelPtOmegac"), 1); + } + + // v0&Casc&Omegac ldl selection + if ((candidate.v0ldl() < KfconfigurableGroup.v0LdlMin) || (candidate.cascldl() < KfconfigurableGroup.cascLdlMin) || (candidate.omegacldl() > KfconfigurableGroup.omegacLdlMax)) { + resultSelections = false; + registry.fill(HIST("hSelV0_Casc_Omegacldl"), 0); + } else { + registry.fill(HIST("hSelV0_Casc_Omegacldl"), 1); + } + + // Omegac ctau selsection + if (candidate.cTauOmegac() > KfconfigurableGroup.cTauOmegacMax) { + resultSelections = false; + registry.fill(HIST("hSelctauOmegac"), 0); + } else { + registry.fill(HIST("hSelctauOmegac"), 1); + } + + // Chi2Geo/NDF V0&Casc&Omegac selection + if ((candidate.v0Chi2OverNdf() > KfconfigurableGroup.v0Chi2OverNdfMax) || (candidate.v0Chi2OverNdf() < 0) || (candidate.cascChi2OverNdf() > KfconfigurableGroup.cascChi2OverNdfMax) || (candidate.cascChi2OverNdf() < 0) || (candidate.omegacChi2OverNdf() > KfconfigurableGroup.omegacChi2OverNdfMax) || (candidate.omegacChi2OverNdf() < 0)) { + resultSelections = false; + registry.fill(HIST("hSelChi2GeooverNDFV0_Casc_Omegac"), 0); + } else { + registry.fill(HIST("hSelChi2GeooverNDFV0_Casc_Omegac"), 1); + } + + // Chi2Topo/NDF (chi2TopoV0ToCasc chi2TopoOmegacToPv chi2TopoCascToOmegac chi2TopoCascToPv) selection (???????????/NDF of which particle????????) + if ((candidate.chi2TopoV0ToCasc() > KfconfigurableGroup.chi2TopoV0ToCascMax) || (candidate.chi2TopoV0ToCasc() < 0) || (candidate.chi2TopoOmegacToPv() > KfconfigurableGroup.chi2TopoOmegacToPvMax) || (candidate.chi2TopoOmegacToPv() < 0) || (candidate.chi2TopoCascToOmegac() > KfconfigurableGroup.chi2TopoCascToOmegacMax) || (candidate.chi2TopoCascToOmegac() < 0) || (candidate.chi2TopoCascToPv() > KfconfigurableGroup.chi2TopoCascToPvMax) || (candidate.chi2TopoCascToPv() < 0)) { + resultSelections = false; + registry.fill(HIST("hSelChi2TopooverNDFV0_Casc_Omegac"), 0); + } else { + registry.fill(HIST("hSelChi2TopooverNDFV0_Casc_Omegac"), 1); + } + + // DecaylengthXY of Omegac&Casc&V0 selection + if ((std::abs(candidate.decayLenXYOmegac()) > KfconfigurableGroup.decayLenXYOmegacMax) || (std::abs(candidate.decayLenXYCasc()) < KfconfigurableGroup.decayLenXYCascMin) || (std::abs(candidate.decayLenXYLambda()) < KfconfigurableGroup.decayLenXYLambdaMin)) { + resultSelections = false; + registry.fill(HIST("hSeldecayLenXYOmegac_Casc_V0"), 0); + } else { + registry.fill(HIST("hSeldecayLenXYOmegac_Casc_V0"), 1); + } + + // KFPA cut cosPaCascToOmegac cosPaV0ToCasc + if ((candidate.cosPaCascToOmegac() < KfconfigurableGroup.cosPaCascToOmegacMin) || (candidate.cosPaV0ToCasc() < KfconfigurableGroup.cosPaV0ToCascMin)) { + resultSelections = false; + registry.fill(HIST("hSelcosPaCascToOmegac_V0ToCasc"), 0); + } else { + registry.fill(HIST("hSelcosPaCascToOmegac_V0ToCasc"), 1); + } + + if (resultSelections && inputKF) { + registry.fill(HIST("hSelKFstatus"), 1); + } + } + } + // TPC clusters selections if (applyTrkSelLf) { if (!isSelectedTrackTpcQuality(trackPiFromLam, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax)) { @@ -410,40 +650,33 @@ struct HfCandidateSelectorToOmegaPi { int statusPidKaFromCasc = -999; int statusPidPiFromCharmBaryon = -999; - bool statusPidLambda = false; - bool statusPidCascade = false; - bool statusPidCharmBaryon = false; - - int infoTpcStored = 0; - int infoTofStored = 0; - if (usePidTpcOnly == usePidTpcTofCombined) { LOGF(fatal, "Check the PID configurables, usePidTpcOnly and usePidTpcTofCombined can't have the same value"); } if (trackPiFromLam.hasTPC()) { - SETBIT(infoTpcStored, kPiFromLam); + SETBIT(infoTpcStored, PiFromLam); } if (trackPrFromLam.hasTPC()) { - SETBIT(infoTpcStored, kPrFromLam); + SETBIT(infoTpcStored, PrFromLam); } if (trackKaFromCasc.hasTPC()) { - SETBIT(infoTpcStored, kKaFromCasc); + SETBIT(infoTpcStored, KaFromCasc); } if (trackPiFromCharm.hasTPC()) { - SETBIT(infoTpcStored, kPiFromCharm); + SETBIT(infoTpcStored, PiFromCharm); } if (trackPiFromLam.hasTOF()) { - SETBIT(infoTofStored, kPiFromLam); + SETBIT(infoTofStored, PiFromLam); } if (trackPrFromLam.hasTOF()) { - SETBIT(infoTofStored, kPrFromLam); + SETBIT(infoTofStored, PrFromLam); } if (trackKaFromCasc.hasTOF()) { - SETBIT(infoTofStored, kKaFromCasc); + SETBIT(infoTofStored, KaFromCasc); } if (trackPiFromCharm.hasTOF()) { - SETBIT(infoTofStored, kPiFromCharm); + SETBIT(infoTofStored, PiFromCharm); } if (usePidTpcOnly) { @@ -463,6 +696,8 @@ struct HfCandidateSelectorToOmegaPi { if (resultSelections) { registry.fill(HIST("hStatusCheck"), 0.5); } + } else { + resultSelections = false; } if (statusPidPrFromLam == TrackSelectorPID::Accepted && statusPidPiFromLam == TrackSelectorPID::Accepted && statusPidKaFromCasc == TrackSelectorPID::Accepted) { @@ -470,6 +705,8 @@ struct HfCandidateSelectorToOmegaPi { if (resultSelections) { registry.fill(HIST("hStatusCheck"), 1.5); } + } else { + resultSelections = false; } if (statusPidPrFromLam == TrackSelectorPID::Accepted && statusPidPiFromLam == TrackSelectorPID::Accepted && statusPidKaFromCasc == TrackSelectorPID::Accepted && statusPidPiFromCharmBaryon == TrackSelectorPID::Accepted) { @@ -477,13 +714,11 @@ struct HfCandidateSelectorToOmegaPi { if (resultSelections) { registry.fill(HIST("hStatusCheck"), 2.5); } + } else { + resultSelections = false; } // invariant mass cuts - bool statusInvMassLambda = false; - bool statusInvMassCascade = false; - bool statusInvMassCharmBaryon = false; - double invMassLambda = candidate.invMassLambda(); double invMassCascade = candidate.invMassCascade(); double invMassCharmBaryon = candidate.invMassCharmBaryon(); @@ -496,6 +731,7 @@ struct HfCandidateSelectorToOmegaPi { } } else { registry.fill(HIST("hSelMassLam"), 0); + resultSelections = false; } if (std::abs(invMassCascade - o2::constants::physics::MassOmegaMinus) < cascadeMassWindow) { @@ -506,6 +742,7 @@ struct HfCandidateSelectorToOmegaPi { } } else { registry.fill(HIST("hSelMassCasc"), 0); + resultSelections = false; } if ((invMassCharmBaryon >= invMassCharmBaryonMin) && (invMassCharmBaryon <= invMassCharmBaryonMax)) { @@ -516,6 +753,19 @@ struct HfCandidateSelectorToOmegaPi { } } else { registry.fill(HIST("hSelMassCharmBaryon"), 0); + resultSelections = false; + } + // ML selections + if constexpr (ConstructMethod == hf_cand_casc_lf::ConstructMethod::KfParticle) { + if (applyMl) { + bool isSelectedMlOmegac = false; + std::vector inputFeaturesOmegaC = hfMlResponse.getInputFeatures(candidate, trackPiFromLam, trackKaFromCasc, trackPiFromCharm); + isSelectedMlOmegac = hfMlResponse.isSelectedMl(inputFeaturesOmegaC, ptCand, outputMlOmegac); + if (isSelectedMlOmegac) { + registry.fill(HIST("hBDTScoreTest1"), outputMlOmegac[0]); + } + hfMlSelToOmegaPi(outputMlOmegac); + } } hfSelToOmegaPi(statusPidLambda, statusPidCascade, statusPidCharmBaryon, statusInvMassLambda, statusInvMassCascade, statusInvMassCharmBaryon, resultSelections, infoTpcStored, infoTofStored, @@ -563,10 +813,32 @@ struct HfCandidateSelectorToOmegaPi { if (statusPidLambda && statusPidCascade && statusPidCharmBaryon && statusInvMassLambda && statusInvMassCascade && statusInvMassCharmBaryon && resultSelections) { hInvMassCharmBaryon->Fill(invMassCharmBaryon); + if constexpr (ConstructMethod == hf_cand_casc_lf::ConstructMethod::KfParticle) { + hPtCharmBaryon->Fill(candidate.kfptOmegac()); + } else { + hPtCharmBaryon->Fill(ptCand); + } } } } // end process -}; // end struct + + void processOmegac0SelectorWithKFParticle(soa::Join const& candidates, + TracksSel const& tracks, + TracksSelLf const& lfTracks) + { + runOmegac0Selector(candidates, tracks, lfTracks); + } + PROCESS_SWITCH(HfCandidateSelectorToOmegaPi, processOmegac0SelectorWithKFParticle, "Run Omegac0 to Omega pi selector with both DCA and KFParticle related selection.", false); + + void processOmegac0SelectorWithDCAFitter(aod::HfCandToOmegaPi const& candidates, + TracksSel const& tracks, + TracksSelLf const& lfTracks) + { + runOmegac0Selector(candidates, tracks, lfTracks); + } + PROCESS_SWITCH(HfCandidateSelectorToOmegaPi, processOmegac0SelectorWithDCAFitter, "Run Omegac0 to Omega pi selector with only DCA related selection.", true); + +}; // end struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGHF/TableProducer/candidateSelectorOmegac0Xic0ToOmegaKa.cxx b/PWGHF/TableProducer/candidateSelectorOmegac0Xic0ToOmegaKa.cxx new file mode 100644 index 00000000000..3bb9e410347 --- /dev/null +++ b/PWGHF/TableProducer/candidateSelectorOmegac0Xic0ToOmegaKa.cxx @@ -0,0 +1,720 @@ +// 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. + +/// \file candidateSelectorOmegaKa0Xic0ToOmegaKa.cxx +/// \brief OmegaKa0 Xic0 → Omega Ka selection task +/// \author Federica Zanone , Heidelberg University +/// \author Ruiqi Yin , Fudan University + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +// #include "PWGHF/Core/HfMlResponseOmegaKaToOmegaKa.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::analysis; + +enum PidInfoStored { + PiFromLam = 0, + PrFromLam, + KaFromCasc, + KaFromCharm +}; + +/// Struct for applying OmegaKa -> Omega Ka selection cuts +struct HfCandidateSelectorToOmegaKa { + Produces hfSelToOmegaKaKf; + // Produces hfMlSelToOmegaKa; + + // LF analysis selections + Configurable radiusCascMin{"radiusCascMin", 0.5, "Min cascade radius"}; + Configurable radiusV0Min{"radiusV0Min", 1.1, "Min V0 radius"}; + Configurable cosPAV0Min{"cosPAV0Min", 0.97, "Min valueCosPA V0"}; + Configurable cosPACascMin{"cosPACascMin", 0.97, "Min value CosPA cascade"}; + Configurable dcaCascDauMax{"dcaCascDauMax", 1.0, "Max DCA cascade daughters"}; + Configurable dcaV0DauMax{"dcaV0DauMax", 1.0, "Max DCA V0 daughters"}; + Configurable dcaBachToPvMin{"dcaBachToPvMin", 0.04, "DCA Bach To PV"}; + Configurable v0MassWindow{"v0MassWindow", 0.01, "V0 mass window"}; + Configurable cascadeMassWindow{"cascadeMassWindow", 0.01, "Cascade mass window"}; + Configurable applyTrkSelLf{"applyTrkSelLf", true, "Apply track selection for LF daughters"}; + + // topological cuts + Configurable> binsPt{"binsPt", std::vector{hf_cuts_omegacxic_to_omega_ka::vecBinsPt}, "pT bin limits"}; + Configurable> cuts{"cuts", {hf_cuts_omegacxic_to_omega_ka::Cuts[0], hf_cuts_omegacxic_to_omega_ka::NBinsPt, hf_cuts_omegacxic_to_omega_ka::NCutVars, hf_cuts_omegacxic_to_omega_ka::labelsPt, hf_cuts_omegacxic_to_omega_ka::labelsCutVar}, "OmegaC0 candidate selection per pT bin"}; + + // limit charm baryon invariant mass spectrum + Configurable invMassCharmBaryonMin{"invMassCharmBaryonMin", 2.0, "Lower limit invariant mass spectrum charm baryon"}; // Xic0:2.470 Omegac0:2.695 + Configurable invMassCharmBaryonMax{"invMassCharmBaryonMax", 3.1, "Upper limit invariant mass spectrum charm baryon"}; + + // kinematic selections + Configurable etaTrackCharmBachMax{"etaTrackCharmBachMax", 0.8, "Max absolute value of eta for charm baryon bachelor"}; + Configurable etaTrackLFDauMax{"etaTrackLFDauMax", 0.8, "Max absolute value of eta for V0 and cascade daughters"}; + Configurable ptCascMin{"ptCascMin", 0.1, "Min pT kaon <- casc"}; + Configurable ptKaFromCharmBaryonMin{"ptKaFromCharmBaryonMin", 0.2, "Min pT Ka <- charm baryon"}; + + Configurable impactParameterXYKaFromCharmBaryonMin{"impactParameterXYKaFromCharmBaryonMin", 0., "Min dcaxy pi from charm baryon track to PV"}; + Configurable impactParameterXYKaFromCharmBaryonMax{"impactParameterXYKaFromCharmBaryonMax", 10., "Max dcaxy pi from charm baryon track to PV"}; + Configurable impactParameterXYCascMin{"impactParameterXYCascMin", 0., "Min dcaxy cascade track to PV"}; + Configurable impactParameterXYCascMax{"impactParameterXYCascMax", 10., "Max dcaxy cascade track to PV"}; + + Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; + Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; + + Configurable dcaCharmBaryonDauMax{"dcaCharmBaryonDauMax", 2.0, "Max DCA charm baryon daughters"}; + + // PID options + Configurable usePidTpcOnly{"usePidTpcOnly", false, "Perform PID using only TPC"}; + Configurable usePidTpcTofCombined{"usePidTpcTofCombined", true, "Perform PID using TPC & TOF"}; + + // PID - TPC selections + Configurable ptPiPidTpcMin{"ptPiPidTpcMin", -1, "Lower bound of track pT for TPC PID for pion selection"}; + Configurable ptPiPidTpcMax{"ptPiPidTpcMax", 9999.9, "Upper bound of track pT for TPC PID for pion selection"}; + Configurable nSigmaTpcPiMax{"nSigmaTpcPiMax", 3., "Nsigma cut on TPC only for pion selection"}; + Configurable nSigmaTpcCombinedPiMax{"nSigmaTpcCombinedPiMax", 0., "Nsigma cut on TPC combined with TOF for pion selection"}; + + Configurable ptPrPidTpcMin{"ptPrPidTpcMin", -1, "Lower bound of track pT for TPC PID for proton selection"}; + Configurable ptPrPidTpcMax{"ptPrPidTpcMax", 9999.9, "Upper bound of track pT for TPC PID for proton selection"}; + Configurable nSigmaTpcPrMax{"nSigmaTpcPrMax", 3., "Nsigma cut on TPC only for proton selection"}; + Configurable nSigmaTpcCombinedPrMax{"nSigmaTpcCombinedPrMax", 0., "Nsigma cut on TPC combined with TOF for proton selection"}; + + Configurable ptKaPidTpcMin{"ptKaPidTpcMin", -1, "Lower bound of track pT for TPC PID for kaon selection"}; + Configurable ptKaPidTpcMax{"ptKaPidTpcMax", 9999.9, "Upper bound of track pT for TPC PID for kaon selection"}; + Configurable nSigmaTpcKaMax{"nSigmaTpcKaMax", 3., "Nsigma cut on TPC only for kaon selection"}; + Configurable nSigmaTpcCombinedKaMax{"nSigmaTpcCombinedKaMax", 0., "Nsigma cut on TPC combined with TOF for kaon selection"}; + + // PID - TOF selections + Configurable ptPiPidTofMin{"ptPiPidTofMin", -1, "Lower bound of track pT for TOF PID for pion selection"}; + Configurable ptPiPidTofMax{"ptPiPidTofMax", 9999.9, "Upper bound of track pT for TOF PID for pion selection"}; + Configurable nSigmaTofPiMax{"nSigmaTofPiMax", 3., "Nsigma cut on TOF only for pion selection"}; + Configurable nSigmaTofCombinedPiMax{"nSigmaTofCombinedPiMax", 0., "Nsigma cut on TOF combined with TPC for pion selection"}; + + Configurable ptPrPidTofMin{"ptPrPidTofMin", -1, "Lower bound of track pT for TOF PID for proton selection"}; + Configurable ptPrPidTofMax{"ptPrPidTofMax", 9999.9, "Upper bound of track pT for TOF PID for proton selection"}; + Configurable nSigmaTofPrMax{"nSigmaTofPrMax", 3., "Nsigma cut on TOF only for proton selection"}; + Configurable nSigmaTofCombinedPrMax{"nSigmaTofCombinedPrMax", 0., "Nsigma cut on TOF combined with TPC for proton selection"}; + + Configurable ptKaPidTofMin{"ptKaPidTofMin", -1, "Lower bound of track pT for TOF PID for kaon selection"}; + Configurable ptKaPidTofMax{"ptKaPidTofMax", 9999.9, "Upper bound of track pT for TOF PID for kaon selection"}; + Configurable nSigmaTofKaMax{"nSigmaTofKaMax", 3., "Nsigma cut on TOF only for kaon selection"}; + Configurable nSigmaTofCombinedKaMax{"nSigmaTofCombinedKaMax", 0., "Nsigma cut on TOF combined with TOF for kaon selection"}; + + // detector clusters selections + Configurable nClustersTpcMin{"nClustersTpcMin", 70, "Minimum number of TPC clusters requirement"}; + Configurable nTpcCrossedRowsMin{"nTpcCrossedRowsMin", 70, "Minimum number of TPC crossed rows requirement"}; + Configurable tpcCrossedRowsOverFindableClustersRatioMin{"tpcCrossedRowsOverFindableClustersRatioMin", 0.8, "Minimum ratio TPC crossed rows over findable clusters requirement"}; + Configurable tpcChi2PerClusterMax{"tpcChi2PerClusterMax", 4, "Maximum value of chi2 fit over TPC clusters"}; + Configurable nClustersItsMin{"nClustersItsMin", 3, "Minimum number of ITS clusters requirement for pi <- charm baryon"}; + Configurable nClustersItsInnBarrMin{"nClustersItsInnBarrMin", 1, "Minimum number of ITS clusters in inner barrel requirement for pi <- charm baryon"}; + Configurable itsChi2PerClusterMax{"itsChi2PerClusterMax", 36, "Maximum value of chi2 fit over ITS clusters for pi <- charm baryon"}; + + ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {120, 2.4, 3.1}, "Cand. inv-mass bins"}; + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {100, 0, 20}, "Cand. pT bins"}; + ConfigurableAxis thnConfigAxisCent{"thnConfigAxisCent", {100, 0, 100}, "Centrality bins"}; + ConfigurableAxis thnConfigAxisPtKaon{"thnConfigAxisPtKaon", {100, 0, 10}, "PtPion from Omegac0 bins"}; + + struct : ConfigurableGroup { + //// KF selection + std::string prefix = "kfSel"; + Configurable applyCompetingCascRejection{"applyCompetingCascRejection", false, "Apply competing Xi(for OmegaKa) rejection"}; + Configurable cascadeRejMassWindow{"cascadeRejMassWindow", 0.01, "competing Xi(for OmegaKa) rejection mass window"}; + Configurable v0LdlMin{"v0LdlMin", 3., "Minimum value of l/dl of V0"}; // l/dl and Chi2 are to be determined + Configurable cascLdlMin{"cascLdlMin", 1., "Minimum value of l/dl of casc"}; + Configurable omegaKaLdlMax{"omegaKaLdlMax", 5., "Maximum value of l/dl of OmegaKa"}; + Configurable cTauOmegaKaMax{"cTauOmegaKaMax", 0.4, "lifetime τ of OmegaKa"}; + Configurable v0Chi2OverNdfMax{"v0Chi2OverNdfMax", 100., "Maximum chi2Geo/NDF of V0"}; + Configurable cascChi2OverNdfMax{"cascChi2OverNdfMax", 100., "Maximum chi2Geo/NDF of casc"}; + Configurable omegaKaChi2OverNdfMax{"omegaKaChi2OverNdfMax", 100., "Maximum chi2Geo/NDF of OmegaKa"}; + Configurable chi2TopoV0ToCascMax{"chi2TopoV0ToCascMax", 100., "Maximum chi2Topo/NDF of V0ToCasc"}; + Configurable chi2TopoKaToCascMax{"chi2TopoKaToCascMax", 100., "Maximum chi2Topo/NDF of KaToCasc"}; + Configurable chi2TopoOmegaKaToPvMax{"chi2TopoOmegaKaToPvMax", 100., "Maximum chi2Topo/NDF of OmegaKaToPv"}; + Configurable chi2TopoCascToOmegaKaMax{"chi2TopoCascToOmegaKaMax", 100., "Maximum chi2Topo/NDF of CascToOmegaKa"}; + Configurable chi2TopoKaToOmegaKaMax{"chi2TopoKaToOmegaKaMax", 100., "Maximum chi2Topo/NDF of KaToOmegaKa"}; + Configurable chi2TopoCascToPvMax{"chi2TopoCascToPvMax", 100., "Maximum chi2Topo/NDF of CascToPv"}; + Configurable chi2TopoKaFromOmegaKaToPvMax{"chi2TopoKaFromOmegaKaToPvMax", 100., "Maximum chi2Topo/NDF of CascToPv"}; + Configurable decayLenOmegaKaMax{"decayLenOmegaKaMax", 1.5, "Maximum decay lengthXY of OmegaKa"}; + Configurable decayLenCascMin{"decayLenCascMin", 1., "Minimum decay lengthXY of Cascade"}; + Configurable decayLenLambdaMin{"decayLenLambdaMin", 0., "Minimum decay lengthXY of V0"}; + Configurable cosPaCascToOmegaKaMin{"cosPaCascToOmegaKaMin", 0.995, "Minimum cosPA of cascade<-OmegaKa"}; + Configurable cosPaV0ToCascMin{"cosPaV0ToCascMin", 0.99, "Minimum cosPA of V0<-cascade"}; + } KfconfigurableGroup; + + TrackSelectorPi selectorPion; + TrackSelectorPr selectorProton; + TrackSelectorKa selectorKaon; + + using TracksSel = soa::Join; + using TracksSelLf = soa::Join; + + HistogramRegistry registry{"registry"}; // for QA of selections + + OutputObj hInvMassCharmBaryon{TH1D("hInvMassCharmBaryon", "Charm baryon invariant mass;inv mass;entries", 500, 2.0, 3.1)}; + OutputObj hPtCharmBaryon{TH1D("hPtCharmBaryon", "Charm baryon transverse momentum before sel;Pt;entries", 3000, 0., 30)}; + OutputObj hPtKaFromCharmBaryon{TH1D("hPtKaFromCharmBaryon", "Ka from charm baryon transverse momentum before sel;Pt;entries", 2000, 0., 20)}; + + void init(InitContext const&) + { + const AxisSpec thnAxisMass{thnConfigAxisMass, "inv. mass (#Omega#Ka) (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisPtKaon{thnConfigAxisPtKaon, "Pt of Kaon from Omegac0."}; + std::vector axes = {thnAxisMass, thnAxisPt, thnAxisPtKaon}; + registry.add("hMassVsPtVsPtKaon", "Thn for Omegac0 or Xic candidates with InvmassOmegaKa&pT&pTKa", HistType::kTHnSparseF, axes); + registry.get(HIST("hMassVsPtVsPtKaon"))->Sumw2(); + + selectorPion.setRangePtTpc(ptPiPidTpcMin, ptPiPidTpcMax); + selectorPion.setRangeNSigmaTpc(-nSigmaTpcPiMax, nSigmaTpcPiMax); + selectorPion.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedPiMax, nSigmaTpcCombinedPiMax); + selectorPion.setRangePtTof(ptPiPidTofMin, ptPiPidTofMax); + selectorPion.setRangeNSigmaTof(-nSigmaTofPiMax, nSigmaTofPiMax); + selectorPion.setRangeNSigmaTofCondTpc(-nSigmaTofCombinedPiMax, nSigmaTofCombinedPiMax); + + selectorProton.setRangePtTpc(ptPrPidTpcMin, ptPrPidTpcMax); + selectorProton.setRangeNSigmaTpc(-nSigmaTpcPrMax, nSigmaTpcPrMax); + selectorProton.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedPrMax, nSigmaTpcCombinedPrMax); + selectorProton.setRangePtTof(ptPrPidTofMin, ptPrPidTofMax); + selectorProton.setRangeNSigmaTof(-nSigmaTofPrMax, nSigmaTofPrMax); + selectorProton.setRangeNSigmaTofCondTpc(-nSigmaTofCombinedPrMax, nSigmaTofCombinedPrMax); + + selectorKaon.setRangePtTpc(ptKaPidTpcMin, ptKaPidTpcMax); + selectorKaon.setRangeNSigmaTpc(-nSigmaTpcKaMax, nSigmaTpcKaMax); + selectorKaon.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedKaMax, nSigmaTpcCombinedKaMax); + selectorKaon.setRangePtTof(ptKaPidTofMin, ptKaPidTofMax); + selectorKaon.setRangeNSigmaTof(-nSigmaTofKaMax, nSigmaTofKaMax); + selectorKaon.setRangeNSigmaTofCondTpc(-nSigmaTofCombinedKaMax, nSigmaTofCombinedKaMax); + + const AxisSpec axisSel{2, -0.5, 1.5, "status"}; + + registry.add("hSelPID", "hSelPID;status;entries", {HistType::kTH1D, {{12, 0., 12.}}}); + registry.add("hStatusCheck", "Check consecutive selections status;status;entries", {HistType::kTH1D, {{12, 0., 12.}}}); + + // for QA of the selections (bin 0 -> candidates that did not pass the selection, bin 1 -> candidates that passed the selection) + registry.add("hSelSignDec", "hSelSignDec;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelEtaPosV0Dau", "hSelEtaPosV0Dau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelEtaNegV0Dau", "hSelEtaNegV0Dau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelEtaKaFromCasc", "hSelEtaKaFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelEtaKaFromCharm", "hSelEtaKaFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelRadCasc", "hSelRadCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelRadV0", "hSelRadV0;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelCosPACasc", "hSelCosPACasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelCosPAV0", "hSelCosPAV0;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCACascDau", "hSelDCACascDau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCAV0Dau", "hSelDCAV0Dau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCACharmDau", "hSelDCACharmDau;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCAXYPrimPi", "hSelDCAXYPrimPi;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCAZPrimPi", "hSelDCAZPrimPi;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDCAXYCasc", "hSelDCAXYCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelKfPtOmega", "hSelKfPtOmega;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelPtKaFromCharm", "hSelPtKaFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelTPCQualityKaFromCharm", "hSelTPCQualityKaFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelTPCQualityPiFromLam", "hSelTPCQualityPiFromLam;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelTPCQualityPrFromLam", "hSelTPCQualityPrFromLam;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelTPCQualityKaFromCasc", "hSelTPCQualityKaFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelITSQualityKaFromCharm", "hSelITSQualityKaFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelMassLam", "hSelMassLam;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelMassCasc", "hSelMassCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelMassCharmBaryon", "hSelMassCharmBaryon;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelDcaXYToPvKaFromCasc", "hSelDcaXYToPvKaFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelPtOmegaKa", "hSelPtOmegaKa;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelCompetingCasc", "hSelCompetingCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelV0_Casc_OmegaKaldl", "hSelV0_Casc_OmegaKaldl;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelctauOmegaKa", "hSelctauOmegaKa;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelChi2GeooverNDFV0_Casc_OmegaKa", "hSelChi2GeooverNDFV0_Casc_OmegaKa;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelChi2TopooverNDFV0_Casc_OmegaKa", "hSelChi2TopooverNDFV0_Casc_OmegaKa;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSeldecayLenOmegaKa_Casc_V0", "hSeldecayLenOmegaKa_Casc_V0;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelcosPaCascToOmegaKa_V0ToCasc", "hSelcosPaCascToOmegaKa_V0ToCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hInvMassXiMinus_rej_cut", "hInvMassXiMinus_rej_cut", kTH1D, {{1000, 1.25f, 1.65f}}); + } + // for pT-dependent cuts (other selections will move into this in futrue) + // \param hfCandOmegaKa is candidate + // return true if candidate passes all cuts + template + bool selectionTopol(const T1& hfCandOmegaKa) + { + auto candpT = hfCandOmegaKa.kfPtOmegaKa(); + auto KaPtFromOmegaKa = hfCandOmegaKa.kfPtKaFromOmegaKa(); + int pTBin = findBin(binsPt, candpT); + if (pTBin == -1) { + return false; + } + + // check that the candidate pT is within the analysis range + if (candpT <= ptCandMin || candpT >= ptCandMax) { + registry.fill(HIST("hSelPtOmegaKa"), 0); + return false; + } else { + registry.fill(HIST("hSelPtOmegaKa"), 1); + } + + // check that the candidate pT is within the analysis range + if (KaPtFromOmegaKa < cuts->get(pTBin, "pT ka from OmegaKa")) { + registry.fill(HIST("hSelPtKaFromCharm"), 0); + return false; + } else { + registry.fill(HIST("hSelPtKaFromCharm"), 1); + } + + return true; + } // end template + + void process(aod::HfCandToOmegaKaKf const& candidates, + TracksSel const& tracks, + TracksSelLf const& lfTracks) + { + // looping over charm baryon candidates + for (const auto& candidate : candidates) { + // initializing selection flags + bool statusPidLambda = false; + bool statusPidCascade = false; + bool statusPidCharmBaryon = false; + + bool statusInvMassLambda = false; + bool statusInvMassCascade = false; + bool statusInvMassCharmBaryon = false; + + bool resultSelections = true; // True if the candidate passes all the selections, False otherwise + + int infoTpcStored = 0; + int infoTofStored = 0; + + auto trackV0PosDauId = candidate.posTrackId(); // positive V0 daughter + auto trackV0NegDauId = candidate.negTrackId(); // negative V0 daughter + auto trackKaFromCascId = candidate.bachelorId(); // kaon <- cascade + auto trackKaFromCharmId = candidate.bachelorFromCharmBaryonId(); // pion <- charm baryon + auto trackV0PosDau = lfTracks.rawIteratorAt(trackV0PosDauId); + auto trackV0NegDau = lfTracks.rawIteratorAt(trackV0NegDauId); + auto trackKaFromCasc = lfTracks.rawIteratorAt(trackKaFromCascId); + auto trackKaFromCharm = tracks.rawIteratorAt(trackKaFromCharmId); + + auto trackPiFromLam = trackV0NegDau; + auto trackPrFromLam = trackV0PosDau; + + int8_t signDecay = candidate.signDecay(); // sign of pi <- cascade + + if (signDecay > 0) { + trackPiFromLam = trackV0PosDau; + trackPrFromLam = trackV0NegDau; + registry.fill(HIST("hSelSignDec"), 1); // anti-particle decay + } else if (signDecay < 0) { + registry.fill(HIST("hSelSignDec"), 0); // particle decay + } + + // pt-dependent selection + if (!selectionTopol(candidate)) { + resultSelections = false; + } + + // eta selection + double etaV0DauPr = candidate.etaV0DauPr(); + double etaV0DauPi = candidate.etaV0DauPi(); + double etaKaFromCasc = candidate.etaBachFromCasc(); + double etaKaFromCharmBaryon = candidate.etaBachFromCharmBaryon(); + if (std::abs(etaV0DauPr) > etaTrackLFDauMax) { + resultSelections = false; + registry.fill(HIST("hSelEtaPosV0Dau"), 0); + } else { + registry.fill(HIST("hSelEtaPosV0Dau"), 1); + } + if (std::abs(etaV0DauPi) > etaTrackLFDauMax) { + resultSelections = false; + registry.fill(HIST("hSelEtaNegV0Dau"), 0); + } else { + registry.fill(HIST("hSelEtaNegV0Dau"), 1); + } + if (std::abs(etaKaFromCasc) > etaTrackLFDauMax) { + resultSelections = false; + registry.fill(HIST("hSelEtaKaFromCasc"), 0); + } else { + registry.fill(HIST("hSelEtaKaFromCasc"), 1); + } + if (std::abs(etaKaFromCharmBaryon) > etaTrackCharmBachMax) { + resultSelections = false; + registry.fill(HIST("hSelEtaKaFromCharm"), 0); + } else { + registry.fill(HIST("hSelEtaKaFromCharm"), 1); + } + + // minimum radius cut (LFcut) + if (RecoDecay::sqrtSumOfSquares(candidate.xDecayVtxCascadeKf(), candidate.yDecayVtxCascadeKf()) < radiusCascMin) { + resultSelections = false; + registry.fill(HIST("hSelRadCasc"), 0); + } else { + registry.fill(HIST("hSelRadCasc"), 1); + } + if (RecoDecay::sqrtSumOfSquares(candidate.xDecayVtxV0Kf(), candidate.yDecayVtxV0Kf()) < radiusV0Min) { + resultSelections = false; + registry.fill(HIST("hSelRadV0"), 0); + } else { + registry.fill(HIST("hSelRadV0"), 1); + } + + // cosPA (LFcut) + if (candidate.cosPACasc() < cosPACascMin) { + resultSelections = false; + registry.fill(HIST("hSelCosPACasc"), 0); + } else { + registry.fill(HIST("hSelCosPACasc"), 1); + } + if (candidate.cosPAV0() < cosPAV0Min) { + resultSelections = false; + registry.fill(HIST("hSelCosPAV0"), 0); + } else { + registry.fill(HIST("hSelCosPAV0"), 1); + } + + // cascade and v0 daughters dca cut (LF cut) + if (candidate.dcaCascDau() > dcaCascDauMax) { + resultSelections = false; + registry.fill(HIST("hSelDCACascDau"), 0); + } else { + registry.fill(HIST("hSelDCACascDau"), 1); + } + + if (candidate.dcaV0Dau() > dcaV0DauMax) { + resultSelections = false; + registry.fill(HIST("hSelDCAV0Dau"), 0); + } else { + registry.fill(HIST("hSelDCAV0Dau"), 1); + } + + // dca charm baryon daughters cut + if (candidate.dcaCharmBaryonDau() > dcaCharmBaryonDauMax) { + resultSelections = false; + registry.fill(HIST("hSelDCACharmDau"), 0); + } else { + registry.fill(HIST("hSelDCACharmDau"), 1); + } + + // cut on charm bachelor Kaon dcaXY + if ((std::abs(candidate.impactParBachFromCharmBaryonXY()) < impactParameterXYKaFromCharmBaryonMin) || (std::abs(candidate.impactParBachFromCharmBaryonXY()) > impactParameterXYKaFromCharmBaryonMax)) { + resultSelections = false; + registry.fill(HIST("hSelDCAXYPrimPi"), 0); + } else { + registry.fill(HIST("hSelDCAXYPrimPi"), 1); + } + + // cut on cascade dcaXY + if ((std::abs(candidate.impactParCascXY()) < impactParameterXYCascMin) || (std::abs(candidate.impactParCascXY()) > impactParameterXYCascMax)) { + resultSelections = false; + registry.fill(HIST("hSelDCAXYCasc"), 0); + } else { + registry.fill(HIST("hSelDCAXYCasc"), 1); + } + + // Charm daughter pT selections + if (std::abs(candidate.kfPtOmega()) < ptCascMin) { + resultSelections = false; + registry.fill(HIST("hSelKfPtOmega"), 0); + } else { + registry.fill(HIST("hSelKfPtOmega"), 1); + } + if (std::abs(candidate.kfPtKaFromOmegaKa()) < ptKaFromCharmBaryonMin) { + resultSelections = false; + } + + // Competing Ξ rejection(KF) Try to reject cases in which the candidate has a an inv. mass compatibler to Xi (bachelor pion) instead of Omega (bachelor kaon) + if (KfconfigurableGroup.applyCompetingCascRejection) { + if (std::abs(candidate.invMassCascadeRej() - o2::constants::physics::MassXiMinus) < KfconfigurableGroup.cascadeRejMassWindow) { + resultSelections = false; + registry.fill(HIST("hSelCompetingCasc"), 0); + } else { + registry.fill(HIST("hSelCompetingCasc"), 1); + registry.fill(HIST("hInvMassXiMinus_rej_cut"), candidate.invMassCascadeRej()); + } + } + + // v0&Casc&OmegaKa ldl selection + if ((candidate.v0ldl() < KfconfigurableGroup.v0LdlMin) || (candidate.cascldl() < KfconfigurableGroup.cascLdlMin) || (candidate.omegaKaldl() > KfconfigurableGroup.omegaKaLdlMax)) { + resultSelections = false; + registry.fill(HIST("hSelV0_Casc_OmegaKaldl"), 0); + } else { + registry.fill(HIST("hSelV0_Casc_OmegaKaldl"), 1); + } + + // OmegaKa ctau selsection + if (candidate.cTauOmegaKa() > KfconfigurableGroup.cTauOmegaKaMax) { + resultSelections = false; + registry.fill(HIST("hSelctauOmegaKa"), 0); + } else { + registry.fill(HIST("hSelctauOmegaKa"), 1); + } + + // Chi2Geo/NDF V0&Casc&OmegaKa selection + if ((candidate.chi2GeoV0() > KfconfigurableGroup.v0Chi2OverNdfMax) || (candidate.chi2GeoV0() < 0) || (candidate.chi2GeoCasc() > KfconfigurableGroup.cascChi2OverNdfMax) || (candidate.chi2GeoCasc() < 0) || (candidate.chi2GeoOmegaKa() > KfconfigurableGroup.omegaKaChi2OverNdfMax) || (candidate.chi2GeoOmegaKa() < 0)) { + resultSelections = false; + registry.fill(HIST("hSelChi2GeooverNDFV0_Casc_OmegaKa"), 0); + } else { + registry.fill(HIST("hSelChi2GeooverNDFV0_Casc_OmegaKa"), 1); + } + + // Chi2Topo/NDF selection + if ((candidate.chi2TopoV0ToCasc() > KfconfigurableGroup.chi2TopoV0ToCascMax) || (candidate.chi2TopoV0ToCasc() < 0) || (candidate.chi2TopoKaToCasc() > KfconfigurableGroup.chi2TopoKaToCascMax) || (candidate.chi2TopoKaToCasc() < 0) || (candidate.chi2TopoCascToOmegaKa() > KfconfigurableGroup.chi2TopoCascToOmegaKaMax) || (candidate.chi2TopoCascToOmegaKa() < 0) || (candidate.chi2TopoKaToOmegaKa() > KfconfigurableGroup.chi2TopoKaToOmegaKaMax) || (candidate.chi2TopoKaToOmegaKa() < 0) || + (candidate.chi2TopoOmegaKaToPv() > KfconfigurableGroup.chi2TopoOmegaKaToPvMax) || (candidate.chi2TopoOmegaKaToPv() < 0) || (candidate.chi2TopoCascToPv() > KfconfigurableGroup.chi2TopoCascToPvMax) || (candidate.chi2TopoCascToPv() < 0) || (candidate.chi2TopoKaFromOmegaKaToPv() > KfconfigurableGroup.chi2TopoKaFromOmegaKaToPvMax) || (candidate.chi2TopoKaFromOmegaKaToPv() < 0)) { + resultSelections = false; + registry.fill(HIST("hSelChi2TopooverNDFV0_Casc_OmegaKa"), 0); + } else { + registry.fill(HIST("hSelChi2TopooverNDFV0_Casc_OmegaKa"), 1); + } + + // DecaylengthXY of OmegaKa&Casc&V0 selection + if ((std::abs(candidate.decLenCharmBaryon()) > KfconfigurableGroup.decayLenOmegaKaMax) || (std::abs(candidate.decLenCascade()) < KfconfigurableGroup.decayLenCascMin) || (std::abs(candidate.decLenV0()) < KfconfigurableGroup.decayLenLambdaMin)) { + resultSelections = false; + registry.fill(HIST("hSeldecayLenOmegaKa_Casc_V0"), 0); + } else { + registry.fill(HIST("hSeldecayLenOmegaKa_Casc_V0"), 1); + } + + // KFPA cut cosPaCascToOmegaKa cosPaV0ToCasc + if ((candidate.cosPaCascToOmegaKa() < KfconfigurableGroup.cosPaCascToOmegaKaMin) || (candidate.cosPaV0ToCasc() < KfconfigurableGroup.cosPaV0ToCascMin)) { + resultSelections = false; + registry.fill(HIST("hSelcosPaCascToOmegaKa_V0ToCasc"), 0); + } else { + registry.fill(HIST("hSelcosPaCascToOmegaKa_V0ToCasc"), 1); + } + + // TPC clusters selections + if (applyTrkSelLf) { + if (!isSelectedTrackTpcQuality(trackPiFromLam, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax)) { + resultSelections = false; + registry.fill(HIST("hSelTPCQualityPiFromLam"), 0); + } else { + registry.fill(HIST("hSelTPCQualityPiFromLam"), 1); + } + if (!isSelectedTrackTpcQuality(trackPrFromLam, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax)) { + resultSelections = false; + registry.fill(HIST("hSelTPCQualityPrFromLam"), 0); + } else { + registry.fill(HIST("hSelTPCQualityPrFromLam"), 1); + } + if (!isSelectedTrackTpcQuality(trackKaFromCasc, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax)) { + resultSelections = false; + registry.fill(HIST("hSelTPCQualityKaFromCasc"), 0); + } else { + registry.fill(HIST("hSelTPCQualityKaFromCasc"), 1); + } + } + if (!isSelectedTrackTpcQuality(trackKaFromCharm, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax)) { + resultSelections = false; + registry.fill(HIST("hSelTPCQualityKaFromCharm"), 0); + } else { + registry.fill(HIST("hSelTPCQualityKaFromCharm"), 1); + } + + // ITS clusters selection + if (!isSelectedTrackItsQuality(trackKaFromCharm, nClustersItsMin, itsChi2PerClusterMax) || trackKaFromCharm.itsNClsInnerBarrel() < nClustersItsInnBarrMin) { + resultSelections = false; + registry.fill(HIST("hSelITSQualityKaFromCharm"), 0); + } else { + registry.fill(HIST("hSelITSQualityKaFromCharm"), 1); + } + + // track-level PID selection + + // for TrackSelectorPID + int statusPidPrFromLam = -999; + int statusPidPiFromLam = -999; + int statusPidKaFromCasc = -999; + int statusPidKaFromCharmBaryon = -999; + + if (usePidTpcOnly && usePidTpcTofCombined) { + LOGF(fatal, "Check the PID configurables, usePidTpcOnly and usePidTpcTofCombined can't have the same value"); + } else if (!usePidTpcOnly && !usePidTpcTofCombined) { + LOGF(fatal, "At least one PID method must be enabled"); + } + + if (trackPiFromLam.hasTPC()) { + SETBIT(infoTpcStored, PiFromLam); + } + if (trackPrFromLam.hasTPC()) { + SETBIT(infoTpcStored, PrFromLam); + } + if (trackKaFromCasc.hasTPC()) { + SETBIT(infoTpcStored, KaFromCasc); + } + if (trackKaFromCharm.hasTPC()) { + SETBIT(infoTpcStored, KaFromCharm); + } + if (trackPiFromLam.hasTOF()) { + SETBIT(infoTofStored, PiFromLam); + } + if (trackPrFromLam.hasTOF()) { + SETBIT(infoTofStored, PrFromLam); + } + if (trackKaFromCasc.hasTOF()) { + SETBIT(infoTofStored, KaFromCasc); + } + if (trackKaFromCharm.hasTOF()) { + SETBIT(infoTofStored, KaFromCharm); + } + + if (usePidTpcOnly) { + statusPidPrFromLam = selectorProton.statusTpc(trackPrFromLam); + statusPidPiFromLam = selectorPion.statusTpc(trackPiFromLam); + statusPidKaFromCasc = selectorKaon.statusTpc(trackKaFromCasc); + statusPidKaFromCharmBaryon = selectorKaon.statusTpc(trackKaFromCharm); + } else if (usePidTpcTofCombined) { + statusPidPrFromLam = selectorProton.statusTpcOrTof(trackPrFromLam); + statusPidPiFromLam = selectorPion.statusTpcOrTof(trackPiFromLam); + statusPidKaFromCasc = selectorKaon.statusTpcOrTof(trackKaFromCasc); + statusPidKaFromCharmBaryon = selectorKaon.statusTpcOrTof(trackKaFromCharm); + } + + if (statusPidPrFromLam == TrackSelectorPID::Accepted && statusPidPiFromLam == TrackSelectorPID::Accepted) { + statusPidLambda = true; + if (resultSelections) { + registry.fill(HIST("hStatusCheck"), 0.5); + } + } else { + resultSelections = false; + } + + if (statusPidPrFromLam == TrackSelectorPID::Accepted && statusPidPiFromLam == TrackSelectorPID::Accepted && statusPidKaFromCasc == TrackSelectorPID::Accepted) { + statusPidCascade = true; + if (resultSelections) { + registry.fill(HIST("hStatusCheck"), 1.5); + } + } else { + resultSelections = false; + } + + if (statusPidPrFromLam == TrackSelectorPID::Accepted && statusPidPiFromLam == TrackSelectorPID::Accepted && statusPidKaFromCasc == TrackSelectorPID::Accepted && statusPidKaFromCharmBaryon == TrackSelectorPID::Accepted) { + statusPidCharmBaryon = true; + if (resultSelections) { + registry.fill(HIST("hStatusCheck"), 2.5); + } + } else { + resultSelections = false; + } + + // invariant mass cuts + double invMassLambda = candidate.invMassLambda(); + double invMassCascade = candidate.invMassCascade(); + double invMassCharmBaryon = candidate.invMassCharmBaryon(); + + if (std::abs(invMassLambda - o2::constants::physics::MassLambda0) < v0MassWindow) { + statusInvMassLambda = true; + registry.fill(HIST("hSelMassLam"), 1); + if (statusPidLambda && statusPidCascade && statusPidCharmBaryon && resultSelections) { + registry.fill(HIST("hStatusCheck"), 3.5); + } + } else { + registry.fill(HIST("hSelMassLam"), 0); + resultSelections = false; + } + + if (std::abs(invMassCascade - o2::constants::physics::MassOmegaMinus) < cascadeMassWindow) { + statusInvMassCascade = true; + registry.fill(HIST("hSelMassCasc"), 1); + if (statusPidLambda && statusPidCascade && statusPidCharmBaryon && statusInvMassLambda && resultSelections) { + registry.fill(HIST("hStatusCheck"), 4.5); + } + } else { + registry.fill(HIST("hSelMassCasc"), 0); + resultSelections = false; + } + + if ((invMassCharmBaryon >= invMassCharmBaryonMin) && (invMassCharmBaryon <= invMassCharmBaryonMax)) { + statusInvMassCharmBaryon = true; + registry.fill(HIST("hSelMassCharmBaryon"), 1); + if (statusPidLambda && statusPidCascade && statusPidCharmBaryon && statusInvMassLambda && statusInvMassCascade && resultSelections) { + registry.fill(HIST("hStatusCheck"), 5.5); + } + } else { + registry.fill(HIST("hSelMassCharmBaryon"), 0); + resultSelections = false; + } + + hfSelToOmegaKaKf(statusPidLambda, statusPidCascade, statusPidCharmBaryon, statusInvMassLambda, statusInvMassCascade, statusInvMassCharmBaryon, resultSelections, infoTpcStored, infoTofStored, + trackKaFromCharm.tpcNSigmaKa(), trackKaFromCasc.tpcNSigmaKa(), trackPiFromLam.tpcNSigmaPi(), trackPrFromLam.tpcNSigmaPr(), + trackKaFromCharm.tofNSigmaKa(), trackKaFromCasc.tofNSigmaKa(), trackPiFromLam.tofNSigmaPi(), trackPrFromLam.tofNSigmaPr()); + + if (resultSelections) { + if (!statusPidLambda) { + registry.fill(HIST("hSelPID"), 0.5); + } + if (statusPidLambda) { + registry.fill(HIST("hSelPID"), 1.5); + } + if (!statusPidCascade) { + registry.fill(HIST("hSelPID"), 2.5); + } + if (statusPidCascade) { + registry.fill(HIST("hSelPID"), 3.5); + } + if (!statusPidCharmBaryon) { + registry.fill(HIST("hSelPID"), 4.5); + } + if (statusPidCharmBaryon) { + registry.fill(HIST("hSelPID"), 5.5); + } + if (!statusInvMassLambda) { + registry.fill(HIST("hSelPID"), 6.5); + } + if (statusInvMassLambda) { + registry.fill(HIST("hSelPID"), 7.5); + } + if (!statusInvMassCascade) { + registry.fill(HIST("hSelPID"), 8.5); + } + if (statusInvMassCascade) { + registry.fill(HIST("hSelPID"), 9.5); + } + if (!statusInvMassCharmBaryon) { + registry.fill(HIST("hSelPID"), 10.5); + } + if (statusInvMassCharmBaryon) { + registry.fill(HIST("hSelPID"), 11.5); + } + } + + if (statusPidLambda && statusPidCascade && statusPidCharmBaryon && statusInvMassLambda && statusInvMassCascade && statusInvMassCharmBaryon && resultSelections) { + hInvMassCharmBaryon->Fill(invMassCharmBaryon); + hPtCharmBaryon->Fill(candidate.kfPtOmegaKa()); + hPtKaFromCharmBaryon->Fill(candidate.kfPtKaFromOmegaKa()); + registry.fill(HIST("hMassVsPtVsPtKaon"), + candidate.invMassCharmBaryon(), + candidate.kfPtOmegaKa(), + candidate.kfPtKaFromOmegaKa()); + } + } + } // end process +}; // end struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/TableProducer/candidateSelectorToXiPi.cxx b/PWGHF/TableProducer/candidateSelectorToXiPi.cxx index 20fb96ece0b..4372e3cb40a 100644 --- a/PWGHF/TableProducer/candidateSelectorToXiPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorToXiPi.cxx @@ -13,27 +13,42 @@ /// \brief Xic0 and Omegac0 → Xi Pi selection task /// \author Federica Zanone , Heidelberg University -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::analysis; -enum pidInfoStored { - kPiFromLam = 0, - kPrFromLam, - kPiFromCasc, - kPiFromCharm +enum PidInfoStored { + PiFromLam = 0, + PrFromLam, + PiFromCasc, + PiFromCharm }; /// Struct for applying Omegac0/Xic0 selection cuts @@ -408,28 +423,28 @@ struct HfCandidateSelectorToXiPi { } if (trackPiFromLam.hasTPC()) { - SETBIT(infoTpcStored, kPiFromLam); + SETBIT(infoTpcStored, PiFromLam); } if (trackPrFromLam.hasTPC()) { - SETBIT(infoTpcStored, kPrFromLam); + SETBIT(infoTpcStored, PrFromLam); } if (trackPiFromCasc.hasTPC()) { - SETBIT(infoTpcStored, kPiFromCasc); + SETBIT(infoTpcStored, PiFromCasc); } if (trackPiFromCharm.hasTPC()) { - SETBIT(infoTpcStored, kPiFromCharm); + SETBIT(infoTpcStored, PiFromCharm); } if (trackPiFromLam.hasTOF()) { - SETBIT(infoTofStored, kPiFromLam); + SETBIT(infoTofStored, PiFromLam); } if (trackPrFromLam.hasTOF()) { - SETBIT(infoTofStored, kPrFromLam); + SETBIT(infoTofStored, PrFromLam); } if (trackPiFromCasc.hasTOF()) { - SETBIT(infoTofStored, kPiFromCasc); + SETBIT(infoTofStored, PiFromCasc); } if (trackPiFromCharm.hasTOF()) { - SETBIT(infoTofStored, kPiFromCharm); + SETBIT(infoTofStored, PiFromCharm); } if (usePidTpcOnly) { @@ -552,7 +567,7 @@ struct HfCandidateSelectorToXiPi { } } } // end process -}; // end struct +}; // end struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGHF/TableProducer/candidateSelectorXic0ToXiPiKf.cxx b/PWGHF/TableProducer/candidateSelectorXic0ToXiPiKf.cxx index 46b4169d564..88824d4d75d 100644 --- a/PWGHF/TableProducer/candidateSelectorXic0ToXiPiKf.cxx +++ b/PWGHF/TableProducer/candidateSelectorXic0ToXiPiKf.cxx @@ -12,44 +12,66 @@ /// \file candidateSelectorXic0ToXiPiKf.cxx /// \brief Xic0 → Xi Pi selection task /// \author Ran Tu , Fudan University +/// \author Tao Fang , Central China Normal University -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectorPID.h" - +#include "PWGHF/Core/HfMlResponseXic0ToXiPiKf.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::analysis; enum PidInfoStored { - KPiFromLam = 0, - KPrFromLam, - KPiFromCasc, - KPiFromCharm + PiFromLam = 0, + PrFromLam, + PiFromCasc, + PiFromCharm }; /// Struct for applying Xic0 -> Xi pi selection cuts struct HfCandidateSelectorXic0ToXiPiKf { Produces hfSelToXiPi; + Produces hfMlToXiPi; + + // kinematic selections + Configurable etaTrackCharmBachMax{"etaTrackCharmBachMax", 0.8, "Max absolute value of eta for charm baryon bachelor"}; + Configurable etaTrackLFDauMax{"etaTrackLFDauMax", 0.8, "Max absolute value of eta for V0 and cascade daughters"}; + Configurable ptPiFromCascMin{"ptPiFromCascMin", 0.15, "Min pT pion <- casc"}; - // LF analysis selections + // minimum radius cut (LFcut) Configurable radiusCascMin{"radiusCascMin", 0.5, "Min cascade radius"}; Configurable radiusV0Min{"radiusV0Min", 1.1, "Min V0 radius"}; - Configurable cosPAV0Min{"cosPAV0Min", 0.97, "Min valueCosPA V0"}; - Configurable cosPACascMin{"cosPACascMin", 0.97, "Min value CosPA cascade"}; - Configurable dcaCascDauMax{"dcaCascDauMax", 1.0, "Max DCA cascade daughters"}; - Configurable dcaV0DauMax{"dcaV0DauMax", 1.0, "Max DCA V0 daughters"}; - Configurable dcaBachToPvMin{"dcaBachToPvMin", 0.04, "DCA Bach To PV"}; - Configurable dcaNegToPvMin{"dcaNegToPvMin", 0.06, "DCA Neg To PV"}; - Configurable dcaPosToPvMin{"dcaPosToPvMin", 0.06, "DCA Pos To PV"}; + Configurable v0MassWindow{"v0MassWindow", 0.01, "V0 mass window"}; Configurable cascadeMassWindow{"cascadeMassWindow", 0.01, "Cascade mass window"}; Configurable applyTrkSelLf{"applyTrkSelLf", true, "Apply track selection for LF daughters"}; @@ -58,27 +80,6 @@ struct HfCandidateSelectorXic0ToXiPiKf { Configurable invMassCharmBaryonMin{"invMassCharmBaryonMin", 2.0, "Lower limit invariant mass spectrum charm baryon"}; // 2.4 Omegac0 only Configurable invMassCharmBaryonMax{"invMassCharmBaryonMax", 3.1, "Upper limit invariant mass spectrum charm baryon"}; - // kinematic selections - Configurable etaTrackCharmBachMax{"etaTrackCharmBachMax", 0.8, "Max absolute value of eta for charm baryon bachelor"}; - Configurable etaTrackLFDauMax{"etaTrackLFDauMax", 1.0, "Max absolute value of eta for V0 and cascade daughters"}; - Configurable ptPiFromCascMin{"ptPiFromCascMin", 0.15, "Min pT pion <- casc"}; - Configurable ptPiFromCharmBaryonMin{"ptPiFromCharmBaryonMin", 0.2, "Min pT pi <- charm baryon"}; - - Configurable impactParameterXYPiFromCharmBaryonMin{"impactParameterXYPiFromCharmBaryonMin", 0., "Min dcaxy pi from charm baryon track to PV"}; - Configurable impactParameterXYPiFromCharmBaryonMax{"impactParameterXYPiFromCharmBaryonMax", 10., "Max dcaxy pi from charm baryon track to PV"}; - Configurable impactParameterZPiFromCharmBaryonMin{"impactParameterZPiFromCharmBaryonMin", 0., "Min dcaz pi from charm baryon track to PV"}; - Configurable impactParameterZPiFromCharmBaryonMax{"impactParameterZPiFromCharmBaryonMax", 10., "Max dcaz pi from charm baryon track to PV"}; - - Configurable impactParameterXYCascMin{"impactParameterXYCascMin", 0., "Min dcaxy cascade track to PV"}; - Configurable impactParameterXYCascMax{"impactParameterXYCascMax", 10., "Max dcaxy cascade track to PV"}; - Configurable impactParameterZCascMin{"impactParameterZCascMin", 0., "Min dcaz cascade track to PV"}; - Configurable impactParameterZCascMax{"impactParameterZCascMax", 10., "Max dcaz cascade track to PV"}; - - Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; - Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; - - Configurable dcaCharmBaryonDauMax{"dcaCharmBaryonDauMax", 2.0, "Max DCA charm baryon daughters"}; - // PID options Configurable usePidTpcOnly{"usePidTpcOnly", false, "Perform PID using only TPC"}; Configurable usePidTpcTofCombined{"usePidTpcTofCombined", true, "Perform PID using TPC & TOF"}; @@ -99,12 +100,12 @@ struct HfCandidateSelectorXic0ToXiPiKf { Configurable ptPrPidTofMin{"ptPrPidTofMin", -1, "Lower bound of track pT for TOF PID for proton selection"}; Configurable ptPrPidTofMax{"ptPrPidTofMax", 9999.9, "Upper bound of track pT for TOF PID for proton selection"}; - Configurable nSigmaTofPrMax{"nSigmaTofPrMax", 3., "Nsigma cut on TOF only for proton selection"}; + Configurable nSigmaTofPrMax{"nSigmaTofPrMax", 5., "Nsigma cut on TOF only for proton selection"}; Configurable nSigmaTofCombinedPrMax{"nSigmaTofCombinedPrMax", 0., "Nsigma cut on TOF combined with TPC for proton selection"}; Configurable ptPiPidTofMin{"ptPiPidTofMin", -1, "Lower bound of track pT for TOF PID for pion selection"}; Configurable ptPiPidTofMax{"ptPiPidTofMax", 9999.9, "Upper bound of track pT for TOF PID for pion selection"}; - Configurable nSigmaTofPiMax{"nSigmaTofPiMax", 3., "Nsigma cut on TOF only for pion selection"}; + Configurable nSigmaTofPiMax{"nSigmaTofPiMax", 5., "Nsigma cut on TOF only for pion selection"}; Configurable nSigmaTofCombinedPiMax{"nSigmaTofCombinedPiMax", 0., "Nsigma cut on TOF combined with TOF for pion selection"}; // detector clusters selections @@ -116,6 +117,29 @@ struct HfCandidateSelectorXic0ToXiPiKf { Configurable nClustersItsInnBarrMin{"nClustersItsInnBarrMin", 1, "Minimum number of ITS clusters in inner barrel requirement for pi <- charm baryon"}; Configurable itsChi2PerClusterMax{"itsChi2PerClusterMax", 36, "Maximum value of chi2 fit over ITS clusters for pi <- charm baryon"}; + // topological cuts + Configurable> binsPt{"binsPt", std::vector{hf_cuts_xic_to_xi_pi::vecBinsPt}, "pT bin limits"}; + Configurable> cuts{"cuts", {hf_cuts_xic_to_xi_pi::Cuts[0], hf_cuts_xic_to_xi_pi::NBinsPt, hf_cuts_xic_to_xi_pi::NCutVars, hf_cuts_xic_to_xi_pi::labelsPt, hf_cuts_xic_to_xi_pi::labelsCutVar}, "Xic0 candidate selection per pT bin"}; + + // ML inference + Configurable applyMl{"applyMl", true, "Flag to apply ML selections"}; + Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; + Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; + + // CCDB configuration + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"EventFiltering/PWGHF/BDTXic0ToXipiKf"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_Xic0ToXipiKf.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + + o2::analysis::HfMlResponseXic0ToXiPiKf hfMlResponse; + std::vector outputMlXic0ToXiPiKf = {}; + o2::ccdb::CcdbApi ccdbApi; + TrackSelectorPr selectorProton; TrackSelectorPi selectorPion; @@ -143,39 +167,37 @@ struct HfCandidateSelectorXic0ToXiPiKf { selectorPion.setRangeNSigmaTofCondTpc(-nSigmaTofCombinedPiMax, nSigmaTofCombinedPiMax); const AxisSpec axisSel{2, -0.5, 1.5, "status"}; - - registry.add("hSelPID", "hSelPID;status;entries", {HistType::kTH1D, {{12, 0., 12.}}}); - registry.add("hStatusCheck", "Check consecutive selections status;status;entries", {HistType::kTH1D, {{12, 0., 12.}}}); - - // for QA of the selections (bin 0 -> candidates that did not pass the selection, bin 1 -> candidates that passed the selection) + registry.add("hStatusCheck", "Check consecutive selections status;status;entries", {HistType::kTH1D, {{3, 0., 3.}}}); + // sign of candidates registry.add("hSelSignDec", "hSelSignDec;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelEtaPosV0Dau", "hSelEtaPosV0Dau;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelEtaNegV0Dau", "hSelEtaNegV0Dau;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelEtaPiFromCasc", "hSelEtaPiFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelEtaPiFromCharm", "hSelEtaPiFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + // basic selections (bin 0 -> candidates that did not pass the selection, bin 1 -> candidates that passed the selection) + registry.add("hSelPtPiFromCasc", "hSelPtPiFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); registry.add("hSelRadCasc", "hSelRadCasc;status;entries", {HistType::kTH1D, {axisSel}}); registry.add("hSelRadV0", "hSelRadV0;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelCosPACasc", "hSelCosPACasc;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelCosPAV0", "hSelCosPAV0;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelDCACascDau", "hSelDCACascDau;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelDCAV0Dau", "hSelDCAV0Dau;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelDCACharmDau", "hSelDCACharmDau;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelDCAXYPrimPi", "hSelDCAXYPrimPi;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelDCAZPrimPi", "hSelDCAZPrimPi;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelDCAXYCasc", "hSelDCAXYCasc;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelDCAZCasc", "hSelDCAZCasc;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelPtPiFromCasc", "hSelPtPiFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelPtPiFromCharm", "hSelPtPiFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + + // TPC and ITS selections (bin 0 -> candidates that did not pass the selection, bin 1 -> candidates that passed the selection) registry.add("hSelTPCQualityPiFromCharm", "hSelTPCQualityPiFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); registry.add("hSelTPCQualityPiFromLam", "hSelTPCQualityPiFromLam;status;entries", {HistType::kTH1D, {axisSel}}); registry.add("hSelTPCQualityPrFromLam", "hSelTPCQualityPrFromLam;status;entries", {HistType::kTH1D, {axisSel}}); registry.add("hSelTPCQualityPiFromCasc", "hSelTPCQualityPiFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); registry.add("hSelITSQualityPiFromCharm", "hSelITSQualityPiFromCharm;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelPID", "hSelPID;status;entries", {HistType::kTH1D, {{12, 0., 12.}}}); registry.add("hSelMassLam", "hSelMassLam;status;entries", {HistType::kTH1D, {axisSel}}); registry.add("hSelMassCasc", "hSelMassCasc;status;entries", {HistType::kTH1D, {axisSel}}); registry.add("hSelMassCharmBaryon", "hSelMassCharmBaryon;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelDcaXYToPvV0Daughters", "hSelDcaXYToPvV0Daughters;status;entries", {HistType::kTH1D, {axisSel}}); - registry.add("hSelDcaXYToPvPiFromCasc", "hSelDcaXYToPvPiFromCasc;status;entries", {HistType::kTH1D, {axisSel}}); + registry.add("hSelMlXic0", "hSelMlXic0;status;entries", {HistType::kTH1D, {axisSel}}); + + if (applyMl) { + hfMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponse.setModelPathsLocal(onnxFileNames); + } + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponse.init(); + } } void process(aod::HfCandToXiPiKf const& candidates, @@ -186,6 +208,10 @@ struct HfCandidateSelectorXic0ToXiPiKf { // looping over charm baryon candidates for (const auto& candidate : candidates) { + outputMlXic0ToXiPiKf.clear(); + + auto ptCand = RecoDecay::pt(candidate.pxCharmBaryon(), candidate.pyCharmBaryon()); + bool resultSelections = true; // True if the candidate passes all the selections, False otherwise auto trackV0PosDauId = candidate.posTrackId(); // positive V0 daughter @@ -215,29 +241,15 @@ struct HfCandidateSelectorXic0ToXiPiKf { double etaV0NegDau = candidate.etaV0NegDau(); double etaPiFromCasc = candidate.etaBachFromCasc(); double etaPiFromCharmBaryon = candidate.etaBachFromCharmBaryon(); - if (std::abs(etaV0PosDau) > etaTrackLFDauMax) { - resultSelections = false; - registry.fill(HIST("hSelEtaPosV0Dau"), 0); - } else { - registry.fill(HIST("hSelEtaPosV0Dau"), 1); - } - if (std::abs(etaV0NegDau) > etaTrackLFDauMax) { + if (std::abs(etaV0PosDau) > etaTrackLFDauMax || std::abs(etaV0NegDau) > etaTrackLFDauMax || std::abs(etaPiFromCasc) > etaTrackLFDauMax || std::abs(etaPiFromCharmBaryon) > etaTrackCharmBachMax) { resultSelections = false; - registry.fill(HIST("hSelEtaNegV0Dau"), 0); - } else { - registry.fill(HIST("hSelEtaNegV0Dau"), 1); - } - if (std::abs(etaPiFromCasc) > etaTrackLFDauMax) { - resultSelections = false; - registry.fill(HIST("hSelEtaPiFromCasc"), 0); - } else { - registry.fill(HIST("hSelEtaPiFromCasc"), 1); } - if (std::abs(etaPiFromCharmBaryon) > etaTrackCharmBachMax) { + double ptPiFromCasc = RecoDecay::sqrtSumOfSquares(candidate.pxBachFromCasc(), candidate.pyBachFromCasc()); + if (std::abs(ptPiFromCasc) < ptPiFromCascMin) { resultSelections = false; - registry.fill(HIST("hSelEtaPiFromCharm"), 0); + registry.fill(HIST("hSelPtPiFromCasc"), 0); } else { - registry.fill(HIST("hSelEtaPiFromCharm"), 1); + registry.fill(HIST("hSelPtPiFromCasc"), 1); } // minimum radius cut (LFcut) @@ -254,103 +266,6 @@ struct HfCandidateSelectorXic0ToXiPiKf { registry.fill(HIST("hSelRadV0"), 1); } - // cosPA (LFcut) - if (candidate.cosPACasc() < cosPACascMin) { - resultSelections = false; - registry.fill(HIST("hSelCosPACasc"), 0); - } else { - registry.fill(HIST("hSelCosPACasc"), 1); - } - if (candidate.cosPAV0() < cosPAV0Min) { - resultSelections = false; - registry.fill(HIST("hSelCosPAV0"), 0); - } else { - registry.fill(HIST("hSelCosPAV0"), 1); - } - - // cascade and v0 daughters dca cut (LF cut) - if (candidate.dcaCascDau() > dcaCascDauMax) { - resultSelections = false; - registry.fill(HIST("hSelDCACascDau"), 0); - } else { - registry.fill(HIST("hSelDCACascDau"), 1); - } - - if (candidate.dcaV0Dau() > dcaV0DauMax) { - resultSelections = false; - registry.fill(HIST("hSelDCAV0Dau"), 0); - } else { - registry.fill(HIST("hSelDCAV0Dau"), 1); - } - - // dca charm baryon daughters cut - if (candidate.dcaCharmBaryonDau() > dcaCharmBaryonDauMax) { - resultSelections = false; - registry.fill(HIST("hSelDCACharmDau"), 0); - } else { - registry.fill(HIST("hSelDCACharmDau"), 1); - } - - // dcaXY v0 daughters to PV cut - if (std::abs(candidate.dcaXYToPvV0Dau0()) < dcaPosToPvMin || std::abs(candidate.dcaXYToPvV0Dau1()) < dcaNegToPvMin) { - resultSelections = false; - registry.fill(HIST("hSelDcaXYToPvV0Daughters"), 0); - } else { - registry.fill(HIST("hSelDcaXYToPvV0Daughters"), 1); - } - - // dcaXY ka <-- cascade to PV cut - if (std::abs(candidate.dcaXYToPvCascDau()) < dcaBachToPvMin) { - resultSelections = false; - registry.fill(HIST("hSelDcaXYToPvPiFromCasc"), 0); - } else { - registry.fill(HIST("hSelDcaXYToPvPiFromCasc"), 1); - } - - // cut on charm bachelor pion dcaXY and dcaZ - if ((std::abs(candidate.impactParBachFromCharmBaryonXY()) < impactParameterXYPiFromCharmBaryonMin) || (std::abs(candidate.impactParBachFromCharmBaryonXY()) > impactParameterXYPiFromCharmBaryonMax)) { - resultSelections = false; - registry.fill(HIST("hSelDCAXYPrimPi"), 0); - } else { - registry.fill(HIST("hSelDCAXYPrimPi"), 1); - } - if ((std::abs(candidate.impactParBachFromCharmBaryonZ()) < impactParameterZPiFromCharmBaryonMin) || (std::abs(candidate.impactParBachFromCharmBaryonZ()) > impactParameterZPiFromCharmBaryonMax)) { - resultSelections = false; - registry.fill(HIST("hSelDCAZPrimPi"), 0); - } else { - registry.fill(HIST("hSelDCAZPrimPi"), 1); - } - - // cut on cascade dcaXY and dcaZ - if ((std::abs(candidate.impactParCascXY()) < impactParameterXYCascMin) || (std::abs(candidate.impactParCascXY()) > impactParameterXYCascMax)) { - resultSelections = false; - registry.fill(HIST("hSelDCAXYCasc"), 0); - } else { - registry.fill(HIST("hSelDCAXYCasc"), 1); - } - if ((std::abs(candidate.impactParCascZ()) < impactParameterZCascMin) || (std::abs(candidate.impactParCascZ()) > impactParameterZCascMax)) { - resultSelections = false; - registry.fill(HIST("hSelDCAZCasc"), 0); - } else { - registry.fill(HIST("hSelDCAZCasc"), 1); - } - - // pT selections - double ptPiFromCasc = RecoDecay::sqrtSumOfSquares(candidate.pxBachFromCasc(), candidate.pyBachFromCasc()); - double ptPiFromCharmBaryon = RecoDecay::sqrtSumOfSquares(candidate.pxBachFromCharmBaryon(), candidate.pyBachFromCharmBaryon()); - if (std::abs(ptPiFromCasc) < ptPiFromCascMin) { - resultSelections = false; - registry.fill(HIST("hSelPtPiFromCasc"), 0); - } else { - registry.fill(HIST("hSelPtPiFromCasc"), 1); - } - if (std::abs(ptPiFromCharmBaryon) < ptPiFromCharmBaryonMin) { - resultSelections = false; - registry.fill(HIST("hSelPtPiFromCharm"), 0); - } else { - registry.fill(HIST("hSelPtPiFromCharm"), 1); - } - // TPC clusters selections if (applyTrkSelLf) { if (!isSelectedTrackTpcQuality(trackPiFromLam, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax)) { @@ -407,28 +322,28 @@ struct HfCandidateSelectorXic0ToXiPiKf { } if (trackPiFromLam.hasTPC()) { - SETBIT(infoTpcStored, KPiFromLam); + SETBIT(infoTpcStored, PiFromLam); } if (trackPrFromLam.hasTPC()) { - SETBIT(infoTpcStored, KPiFromLam); + SETBIT(infoTpcStored, PiFromLam); } if (trackPiFromCasc.hasTPC()) { - SETBIT(infoTpcStored, KPiFromCasc); + SETBIT(infoTpcStored, PiFromCasc); } if (trackPiFromCharm.hasTPC()) { - SETBIT(infoTpcStored, KPiFromCharm); + SETBIT(infoTpcStored, PiFromCharm); } if (trackPiFromLam.hasTOF()) { - SETBIT(infoTofStored, KPiFromLam); + SETBIT(infoTofStored, PiFromLam); } if (trackPrFromLam.hasTOF()) { - SETBIT(infoTofStored, KPiFromLam); + SETBIT(infoTofStored, PiFromLam); } if (trackPiFromCasc.hasTOF()) { - SETBIT(infoTofStored, KPiFromCasc); + SETBIT(infoTofStored, PiFromCasc); } if (trackPiFromCharm.hasTOF()) { - SETBIT(infoTofStored, KPiFromCharm); + SETBIT(infoTofStored, PiFromCharm); } if (usePidTpcOnly) { @@ -459,9 +374,9 @@ struct HfCandidateSelectorXic0ToXiPiKf { if (statusPidPrFromLam == TrackSelectorPID::Accepted && statusPidPiFromLam == TrackSelectorPID::Accepted && statusPidPiFromCasc == TrackSelectorPID::Accepted && statusPidPiFromCharmBaryon == TrackSelectorPID::Accepted) { statusPidCharmBaryon = true; - if (resultSelections) { - registry.fill(HIST("hStatusCheck"), 2.5); - } + } else { + registry.fill(HIST("hStatusCheck"), 2.5); + resultSelections = false; } // invariant mass cuts @@ -473,37 +388,46 @@ struct HfCandidateSelectorXic0ToXiPiKf { double invMassCascade = candidate.invMassCascade(); double invMassCharmBaryon = candidate.invMassCharmBaryon(); - if (std::abs(invMassLambda - o2::constants::physics::MassLambda0) < v0MassWindow) { - statusInvMassLambda = true; - registry.fill(HIST("hSelMassLam"), 1); - if (statusPidLambda && statusPidCascade && statusPidCharmBaryon && resultSelections) { - registry.fill(HIST("hStatusCheck"), 3.5); + if (resultSelections) { + resultSelections = selectionTopolKf(candidate); + if (std::abs(invMassLambda - o2::constants::physics::MassLambda0) < v0MassWindow) { + statusInvMassLambda = true; + registry.fill(HIST("hSelMassLam"), 1); + } else { + resultSelections = false; + registry.fill(HIST("hSelMassLam"), 0); } - } else { - registry.fill(HIST("hSelMassLam"), 0); - } - if (std::abs(invMassCascade - o2::constants::physics::MassXiMinus) < cascadeMassWindow) { - statusInvMassCascade = true; - registry.fill(HIST("hSelMassCasc"), 1); - if (statusPidLambda && statusPidCascade && statusPidCharmBaryon && statusInvMassLambda && resultSelections) { - registry.fill(HIST("hStatusCheck"), 4.5); + if (std::abs(invMassCascade - o2::constants::physics::MassXiMinus) < cascadeMassWindow) { + statusInvMassCascade = true; + registry.fill(HIST("hSelMassCasc"), 1); + } else { + resultSelections = false; + registry.fill(HIST("hSelMassCasc"), 0); } - } else { - registry.fill(HIST("hSelMassCasc"), 0); - } - if ((invMassCharmBaryon >= invMassCharmBaryonMin) && (invMassCharmBaryon <= invMassCharmBaryonMax)) { - statusInvMassCharmBaryon = true; - registry.fill(HIST("hSelMassCharmBaryon"), 1); - if (statusPidLambda && statusPidCascade && statusPidCharmBaryon && statusInvMassLambda && statusInvMassCascade && resultSelections) { - registry.fill(HIST("hStatusCheck"), 5.5); + if ((invMassCharmBaryon >= invMassCharmBaryonMin) && (invMassCharmBaryon <= invMassCharmBaryonMax)) { + statusInvMassCharmBaryon = true; + registry.fill(HIST("hSelMassCharmBaryon"), 1); + } else { + resultSelections = false; + registry.fill(HIST("hSelMassCharmBaryon"), 0); + } + } + // ML selections + if (applyMl) { + bool isSelectedMlXic0 = false; + std::vector inputFeaturesXic0 = hfMlResponse.getInputFeatures(candidate, trackPiFromLam, trackPiFromCasc, trackPiFromCharm); + if (!resultSelections) { + hfMlToXiPi(outputMlXic0ToXiPiKf); + } else { + isSelectedMlXic0 = hfMlResponse.isSelectedMl(inputFeaturesXic0, ptCand, outputMlXic0ToXiPiKf); + registry.fill(HIST("hSelMlXic0"), isSelectedMlXic0); + hfMlToXiPi(outputMlXic0ToXiPiKf); } - } else { - registry.fill(HIST("hSelMassCharmBaryon"), 0); } - hfSelToXiPi(statusPidCharmBaryon, statusPidCascade, statusPidLambda, statusInvMassCharmBaryon, statusInvMassCascade, statusInvMassLambda, resultSelections, infoTpcStored, infoTofStored, + hfSelToXiPi(resultSelections, trackPiFromCharm.tpcNSigmaPi(), trackPiFromCasc.tpcNSigmaPi(), trackPiFromLam.tpcNSigmaPi(), trackPrFromLam.tpcNSigmaPr(), trackPiFromCharm.tofNSigmaPi(), trackPiFromCasc.tofNSigmaPi(), trackPiFromLam.tofNSigmaPi(), trackPrFromLam.tofNSigmaPr()); @@ -551,6 +475,125 @@ struct HfCandidateSelectorXic0ToXiPiKf { } } } // end process + + /// \param candidate is candidate + /// \return true if candidate passes all cuts + template + bool selectionTopolKf(const T& candidate) + { + auto candpT = RecoDecay::pt(candidate.pxCharmBaryon(), candidate.pyCharmBaryon()); + + int pTBin = findBin(binsPt, candpT); + if (pTBin == -1) { + return false; + } + + double ptPiFromCharmBaryon = RecoDecay::sqrtSumOfSquares(candidate.pxBachFromCharmBaryon(), candidate.pyBachFromCharmBaryon()); + if (ptPiFromCharmBaryon <= cuts->get(pTBin, "ptPiFromCharmBaryon")) { + return false; + } + + // cosPA (LFcut) + if (candidate.cosPACasc() < cuts->get(pTBin, "cosPACasc")) { + return false; + } + if (candidate.cosPAV0() < cuts->get(pTBin, "cosPAV0")) { + return false; + } + if (candidate.cosPaCascToXic() < cuts->get(pTBin, "cosPaCascToXic")) { + return false; + } + if (candidate.cosPaV0ToCasc() < cuts->get(pTBin, "cosPaV0ToCasc")) { + return false; + } + + // dca cut + if (candidate.dcaCharmBaryonDau() > cuts->get(pTBin, "dcaCharmBaryonDau")) { + return false; + } + if (candidate.dcaCascDau() > cuts->get(pTBin, "dcaCascDau")) { + return false; + } + + if (candidate.dcaV0Dau() > cuts->get(pTBin, "dcaV0Dau")) { + return false; + } + + // dcaXY pion <-- cascade to PV cut + if (std::abs(candidate.dcaXYToPvCascDau()) < cuts->get(pTBin, "dcaXYToPvCascDau")) { + return false; + } + + // dcaXY v0 daughters to PV cut + if (std::abs(candidate.dcaXYToPvV0Dau0()) < cuts->get(pTBin, "dcaXYToPvV0Dau0") || std::abs(candidate.dcaXYToPvV0Dau1()) < cuts->get(pTBin, "dcaXYToPvV0Dau0")) { + return false; + } + + // dacXY pion <-- Xic0 to PV cut + if (std::abs(candidate.kfDcaXYPiFromXic()) > cuts->get(pTBin, "kfDcaXYPiFromXic")) { + return false; + } + + // dacXY cascade to PV cut + if (std::abs(candidate.kfDcaXYCascToPv()) > cuts->get(pTBin, "kfDcaXYCascToPv")) { + return false; + } + + // Chi2Geo + if (candidate.chi2GeoXic() < 0 || candidate.chi2GeoXic() > cuts->get(pTBin, "chi2GeoXic")) { + return false; + } + if (candidate.chi2GeoCasc() < 0 || candidate.chi2GeoCasc() > cuts->get(pTBin, "chi2GeoCasc")) { + return false; + } + if (candidate.chi2GeoV0() < 0 || candidate.chi2GeoV0() > cuts->get(pTBin, "chi2GeoV0")) { + return false; + } + + // Chi2Topo + if (candidate.chi2TopoXicToPv() < 0 || candidate.chi2TopoXicToPv() > cuts->get(pTBin, "chi2TopoXicToPv")) { + return false; + } + if (candidate.chi2TopoPiFromXicToPv() < 0 || candidate.chi2TopoPiFromXicToPv() > cuts->get(pTBin, "chi2TopoPiFromXicToPv")) { + return false; + } + if (candidate.chi2TopoCascToPv() < 0 || candidate.chi2TopoCascToPv() > cuts->get(pTBin, "chi2TopoCascToPv")) { + return false; + } + if (candidate.chi2TopoV0ToPv() > 0 && candidate.chi2TopoV0ToPv() < cuts->get(pTBin, "chi2TopoV0ToPv")) { + return false; + } + if (candidate.chi2TopoV0ToCasc() < 0 || candidate.chi2TopoV0ToCasc() > cuts->get(pTBin, "chi2TopoV0ToCasc")) { + return false; + } + if (candidate.chi2TopoCascToXic() < 0 || candidate.chi2TopoCascToXic() > cuts->get(pTBin, "chi2TopoCascToXic")) { + return false; + } + + // ldl + if (candidate.cascldl() < cuts->get(pTBin, "cascldl")) { + return false; + } + if (candidate.v0ldl() < cuts->get(pTBin, "v0ldl")) { + return false; + } + // decay length + if (std::abs(candidate.decayLenXYXic()) > cuts->get(pTBin, "decayLenXYXic")) { + return false; + } + if (std::abs(candidate.decayLenXYCasc()) < cuts->get(pTBin, "decayLenXYCasc")) { + return false; + } + if (std::abs(candidate.decayLenXYLambda()) < cuts->get(pTBin, "decayLenXYLambda")) { + return false; + } + // ctau + if (std::abs(candidate.cTauXic()) > cuts->get(pTBin, "cTauXic")) { + return false; + } + return true; + } + }; // end struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx b/PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx index 64ecd5cf65e..14b010aeaa2 100644 --- a/PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx @@ -17,21 +17,34 @@ /// \author Vít Kučera , CERN /// \author Cristina Terrevoli , INFN BARI -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - -#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponseXicToPKPi.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -44,6 +57,8 @@ struct HfCandidateSelectorXicToPKPi { Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; Configurable ptCandMax{"ptCandMax", 36., "Upper bound of candidate pT"}; Configurable usePid{"usePid", true, "Bool to use or not the PID at filtering level"}; + // Combined PID options + Configurable usePidTpcAndTof{"usePidTpcAndTof", false, "Bool to decide how to combine TPC and TOF PID: true = both (if present, only one otherwise); false = one is enough"}; // TPC PID Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; Configurable ptPidTpcMax{"ptPidTpcMax", 20., "Upper bound of track pT for TPC PID"}; @@ -57,13 +72,13 @@ struct HfCandidateSelectorXicToPKPi { // topological cuts Configurable decayLengthXYNormalisedMin{"decayLengthXYNormalisedMin", 3., "Min. normalised decay length XY"}; Configurable> binsPt{"binsPt", std::vector{hf_cuts_xic_to_p_k_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_xic_to_p_k_pi::cuts[0], hf_cuts_xic_to_p_k_pi::nBinsPt, hf_cuts_xic_to_p_k_pi::nCutVars, hf_cuts_xic_to_p_k_pi::labelsPt, hf_cuts_xic_to_p_k_pi::labelsCutVar}, "Xic candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_xic_to_p_k_pi::Cuts[0], hf_cuts_xic_to_p_k_pi::NBinsPt, hf_cuts_xic_to_p_k_pi::NCutVars, hf_cuts_xic_to_p_k_pi::labelsPt, hf_cuts_xic_to_p_k_pi::labelsCutVar}, "Xic candidate selection per pT bin"}; // ML inference Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -71,6 +86,8 @@ struct HfCandidateSelectorXicToPKPi { Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_XicToPKPi.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + // QA switch + Configurable activateQA{"activateQA", true, "Flag to enable QA histogram"}; o2::analysis::HfMlResponseXicToPKPi hfMlResponse; std::vector outputMlXicToPKPi = {}; @@ -81,7 +98,9 @@ struct HfCandidateSelectorXicToPKPi { TrackSelectorPr selectorProton; HfHelper hfHelper; - using TracksSel = soa::Join; + using TracksSel = soa::Join; + + HistogramRegistry registry{"registry"}; void init(InitContext const&) { @@ -94,6 +113,21 @@ struct HfCandidateSelectorXicToPKPi { selectorKaon = selectorPion; selectorProton = selectorPion; + if (activateQA) { + constexpr int kNBinsSelections = 1 + aod::SelectionStep::NSelectionSteps; + std::string labels[kNBinsSelections]; + labels[0] = "No selection"; + labels[1 + aod::SelectionStep::RecoSkims] = "Skims selection"; + labels[1 + aod::SelectionStep::RecoTopol] = "Skims & Topological selections"; + labels[1 + aod::SelectionStep::RecoPID] = "Skims & Topological & PID selections"; + labels[1 + aod::SelectionStep::RecoMl] = "ML selection"; + static const AxisSpec axisSelections = {kNBinsSelections, 0.5, kNBinsSelections + 0.5, ""}; + registry.add("hSelections", "Selections;;#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisSelections, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); + for (int iBin = 0; iBin < kNBinsSelections; ++iBin) { + registry.get(HIST("hSelections"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); + } + } + if (applyMl) { hfMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); if (loadModelsFromCCDB) { @@ -201,7 +235,7 @@ struct HfCandidateSelectorXicToPKPi { return true; } - void process(aod::HfCand3Prong const& candidates, + void process(aod::HfCand3ProngWPidPiKaPr const& candidates, TracksSel const&) { // looping over 3-prong candidates @@ -214,18 +248,24 @@ struct HfCandidateSelectorXicToPKPi { outputMlXicToPKPi.clear(); outputMlXicToPiKP.clear(); + auto ptCand = candidate.pt(); + if (!TESTBIT(candidate.hfflag(), aod::hf_cand_3prong::DecayType::XicToPKPi)) { hfSelXicToPKPiCandidate(statusXicToPKPi, statusXicToPiKP); if (applyMl) { hfMlXicToPKPiCandidate(outputMlXicToPKPi, outputMlXicToPiKP); } + if (activateQA) { + registry.fill(HIST("hSelections"), 1, ptCand); + } continue; } + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + aod::SelectionStep::RecoSkims, ptCand); + } SETBIT(statusXicToPKPi, aod::SelectionStep::RecoSkims); SETBIT(statusXicToPiKP, aod::SelectionStep::RecoSkims); - auto ptCand = candidate.pt(); - auto trackPos1 = candidate.prong0_as(); // positive daughter (negative for the antiparticles) auto trackNeg = candidate.prong1_as(); // negative daughter (positive for the antiparticles) auto trackPos2 = candidate.prong2_as(); // positive daughter (negative for the antiparticles) @@ -260,6 +300,10 @@ struct HfCandidateSelectorXicToPKPi { SETBIT(statusXicToPiKP, aod::SelectionStep::RecoTopol); } + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + aod::SelectionStep::RecoTopol, candidate.pt()); + } + auto pidXicToPKPi = -1; auto pidXicToPiKP = -1; @@ -269,11 +313,25 @@ struct HfCandidateSelectorXicToPKPi { pidXicToPiKP = 1; } else { // track-level PID selection - auto pidTrackPos1Proton = selectorProton.statusTpcOrTof(trackPos1); - auto pidTrackPos2Proton = selectorProton.statusTpcOrTof(trackPos2); - auto pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1); - auto pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2); - auto pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg); + TrackSelectorPID::Status pidTrackPos1Proton = TrackSelectorPID::Accepted; + TrackSelectorPID::Status pidTrackPos2Proton = TrackSelectorPID::Accepted; + TrackSelectorPID::Status pidTrackPos1Pion = TrackSelectorPID::Accepted; + TrackSelectorPID::Status pidTrackPos2Pion = TrackSelectorPID::Accepted; + TrackSelectorPID::Status pidTrackNegKaon = TrackSelectorPID::Accepted; + if (usePidTpcAndTof) { + + pidTrackPos1Proton = selectorProton.statusTpcAndTof(trackPos1, candidate.nSigTpcPr0(), candidate.nSigTofPr0()); + pidTrackPos2Proton = selectorProton.statusTpcAndTof(trackPos2, candidate.nSigTpcPr2(), candidate.nSigTofPr2()); + pidTrackPos1Pion = selectorPion.statusTpcAndTof(trackPos1, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + pidTrackPos2Pion = selectorPion.statusTpcAndTof(trackPos2, candidate.nSigTpcPi2(), candidate.nSigTofPi2()); + pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); + } else { + pidTrackPos1Proton = selectorProton.statusTpcOrTof(trackPos1, candidate.nSigTpcPr0(), candidate.nSigTofPr0()); + pidTrackPos2Proton = selectorProton.statusTpcOrTof(trackPos2, candidate.nSigTpcPr2(), candidate.nSigTofPr2()); + pidTrackPos1Pion = selectorPion.statusTpcOrTof(trackPos1, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + pidTrackPos2Pion = selectorPion.statusTpcOrTof(trackPos2, candidate.nSigTpcPi2(), candidate.nSigTofPi2()); + pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); + } if (pidTrackPos1Proton == TrackSelectorPID::Accepted && pidTrackNegKaon == TrackSelectorPID::Accepted && @@ -309,6 +367,9 @@ struct HfCandidateSelectorXicToPKPi { if ((pidXicToPiKP == -1 || pidXicToPiKP == 1) && topolXicToPiKP) { SETBIT(statusXicToPiKP, aod::SelectionStep::RecoPID); } + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + aod::SelectionStep::RecoPID, candidate.pt()); + } if (applyMl) { // ML selections @@ -316,11 +377,11 @@ struct HfCandidateSelectorXicToPKPi { bool isSelectedMlXicToPiKP = false; if (topolXicToPKPi && pidXicToPKPi) { - std::vector inputFeaturesXicToPKPi = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2, true); + std::vector inputFeaturesXicToPKPi = hfMlResponse.getInputFeatures(candidate, true); isSelectedMlXicToPKPi = hfMlResponse.isSelectedMl(inputFeaturesXicToPKPi, ptCand, outputMlXicToPKPi); } if (topolXicToPiKP && pidXicToPiKP) { - std::vector inputFeaturesXicToPiKP = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2, false); + std::vector inputFeaturesXicToPiKP = hfMlResponse.getInputFeatures(candidate, false); isSelectedMlXicToPiKP = hfMlResponse.isSelectedMl(inputFeaturesXicToPiKP, ptCand, outputMlXicToPiKP); } @@ -335,7 +396,10 @@ struct HfCandidateSelectorXicToPKPi { SETBIT(statusXicToPKPi, aod::SelectionStep::RecoMl); } if (isSelectedMlXicToPiKP) { - SETBIT(statusXicToPKPi, aod::SelectionStep::RecoMl); + SETBIT(statusXicToPiKP, aod::SelectionStep::RecoMl); + } + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + aod::SelectionStep::RecoMl, candidate.pt()); } } diff --git a/PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx b/PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx index a2191501706..c4087a93e75 100644 --- a/PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx @@ -15,19 +15,33 @@ /// \author Phil Lennart Stahlhut , Heidelberg University /// \author Jaeyoon Cho , Inha University -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfMlResponseXicToXiPiPi.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/Utils/utilsAnalysis.h" // findBin function +#include "PWGHF/Utils/utilsAnalysis.h" + +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -38,16 +52,12 @@ struct HfCandidateSelectorXicToXiPiPi { Produces hfSelXicToXiPiPiCandidate; Produces hfMlXicToXiPiPiCandidate; - Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; - Configurable ptCandMax{"ptCandMax", 36., "Upper bound of candidate pT"}; - // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_xic_to_xi_pi_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_xic_to_xi_pi_pi::cuts[0], hf_cuts_xic_to_xi_pi_pi::nBinsPt, hf_cuts_xic_to_xi_pi_pi::nCutVars, hf_cuts_xic_to_xi_pi_pi::labelsPt, hf_cuts_xic_to_xi_pi_pi::labelsCutVar}, "Xicplus candidate selection per pT bin"}; - // QA switch - Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; + Configurable> cuts{"cuts", {hf_cuts_xic_to_xi_pi_pi::Cuts[0], hf_cuts_xic_to_xi_pi_pi::NBinsPt, hf_cuts_xic_to_xi_pi_pi::NCutVars, hf_cuts_xic_to_xi_pi_pi::labelsPt, hf_cuts_xic_to_xi_pi_pi::labelsCutVar}, "Xicplus candidate selection per pT bin"}; + Configurable fillQAHistograms{"fillQAHistograms", false, "Switch to enable filling of QA histograms"}; // Enable PID Configurable usePid{"usePid", true, "Switch for PID selection at track level"}; - Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; + Configurable useTpcPidOnly{"useTpcPidOnly", false, "Switch to use TPC PID only instead of TPC OR TOF)"}; // TPC PID Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; Configurable ptPidTpcMax{"ptPidTpcMax", 20., "Upper bound of track pT for TPC PID"}; @@ -58,12 +68,21 @@ struct HfCandidateSelectorXicToXiPiPi { Configurable ptPidTofMax{"ptPidTofMax", 20., "Upper bound of track pT for TOF PID"}; Configurable nSigmaTofMax{"nSigmaTofMax", 5., "Nsigma cut on TOF only"}; Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; + // TrackQualitySelection + Configurable doTrackQualitySelection{"doTrackQualitySelection", true, "Switch to apply track quality selections on final state daughter particles"}; + Configurable nClustersTpcMin{"nClustersTpcMin", 70, "Minimum number of TPC clusters requirement"}; + Configurable nTpcCrossedRowsMin{"nTpcCrossedRowsMin", 70, "Minimum number of TPC crossed rows requirement"}; + Configurable tpcCrossedRowsOverFindableClustersRatioMin{"tpcCrossedRowsOverFindableClustersRatioMin", 0.8, "Minimum ratio TPC crossed rows over findable clusters requirement"}; + Configurable tpcChi2PerClusterMax{"tpcChi2PerClusterMax", 4, "Maximum value of chi2 fit over TPC clusters"}; + Configurable nClustersItsMin{"nClustersItsMin", 3, "Minimum number of ITS clusters requirement for pi <- charm baryon"}; + Configurable nClustersItsInnBarrMin{"nClustersItsInnBarrMin", 1, "Minimum number of ITS clusters in inner barrel requirement for pi <- charm baryon"}; + Configurable itsChi2PerClusterMax{"itsChi2PerClusterMax", 36, "Maximum value of chi2 fit over ITS clusters for pi <- charm baryon"}; // ML inference Configurable applyMl{"applyMl", false, "Flag to apply ML selections"}; Configurable> binsPtMl{"binsPtMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", (int8_t)hf_cuts_ml::nCutScores, "Number of classes in ML model"}; + Configurable> cutsMl{"cutsMl", {hf_cuts_ml::Cuts[0], hf_cuts_ml::NBinsPt, hf_cuts_ml::NCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", static_cast(hf_cuts_ml::NCutScores), "Number of classes in ML model"}; Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -77,13 +96,34 @@ struct HfCandidateSelectorXicToXiPiPi { o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; TrackSelectorPr selectorProton; - - using TracksPidWithSel = soa::Join; + enum XicSelCriteria { All = 0, + Pt, + Mass, + Rapidity, + Eta, + EtaPionFromXicPlus, + EtaXiDaughters, + PtPionFromXicPlus, + Chi2SV, + MinDecayLength, + MaxInvMassXiPiPairs, + TpcTrackQualityXiDaughters, + TpcTrackQualityPiFromCharm, + ItsTrackQualityPiFromCharm, + PidSelected, + BdtSelected, + NSelectionCriteria }; + + using TracksExtraWPid = soa::Join; HistogramRegistry registry{"registry"}; void init(InitContext&) { + if ((doprocessData + doprocessMc) != 1) { + LOGP(fatal, "Enable exactly one process function at a time."); + } + if (usePid) { // pion selectorPion.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); @@ -101,18 +141,109 @@ struct HfCandidateSelectorXicToXiPiPi { selectorProton.setRangeNSigmaTofCondTpc(-nSigmaTofCombinedMax, nSigmaTofCombinedMax); } - if (activateQA) { - constexpr int kNBinsSelections = 1 + SelectionStep::NSelectionSteps; - std::string labels[kNBinsSelections]; - labels[0] = "No selection"; - labels[1 + SelectionStep::RecoSkims] = "Skims selection"; - labels[1 + SelectionStep::RecoTopol] = "Skims & Topological selections"; - labels[1 + SelectionStep::RecoPID] = "Skims & Topological & PID selections"; - labels[1 + SelectionStep::RecoMl] = "Skims & Topological & PID & ML selections"; - static const AxisSpec axisSelections = {kNBinsSelections, 0.5, kNBinsSelections + 0.5, ""}; - registry.add("hSelections", "Selections;;#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisSelections, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); - for (int iBin = 0; iBin < kNBinsSelections; ++iBin) { - registry.get(HIST("hSelections"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); + std::string labels[NSelectionCriteria]; + labels[All] = "All"; + labels[Pt] = "#it{p}_{T}"; + labels[Mass] = "#Delta M"; + labels[Rapidity] = "y"; + labels[Eta] = "#eta"; + labels[EtaPionFromXicPlus] = "#eta (#pi #leftarrow #Xi_{c}^{#plus})"; + labels[EtaXiDaughters] = "#eta (#Xi daughters)"; + labels[PtPionFromXicPlus] = "#it{p}_{T} (#pi #leftarrow #Xi_{c}^{#plus})"; + labels[Chi2SV] = "#chi^{2}_{SV}"; + labels[MinDecayLength] = "Decay length"; + labels[MaxInvMassXiPiPairs] = "M_{#Xi #pi}"; + labels[TpcTrackQualityXiDaughters] = "TPC track quality selection on #Xi daughters"; + labels[TpcTrackQualityPiFromCharm] = "TPC track quality selection on #pi #leftarrow #Xi_{c}^{#plus}"; + labels[ItsTrackQualityPiFromCharm] = "ITS track quality selection on #pi #leftarrow #Xi_{c}^{#plus}"; + labels[PidSelected] = "PID selection"; + labels[BdtSelected] = "BDT selection"; + + if (doprocessData) { + registry.add("hSelCandidates", ";;entries", {HistType::kTH1D, {{NSelectionCriteria, -0.5f, +NSelectionCriteria - 0.5f}}}); + for (int iBin = 0; iBin < NSelectionCriteria; ++iBin) { + registry.get(HIST("hSelCandidates"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); + } + } else if (doprocessMc) { + registry.add("hSelCandidatesRecSig", ";;entries", {HistType::kTH1D, {{NSelectionCriteria, -0.5f, +NSelectionCriteria - 0.5f}}}); + registry.add("hSelCandidatesRecBkg", ";;entries", {HistType::kTH1D, {{NSelectionCriteria, -0.5f, +NSelectionCriteria - 0.5f}}}); + for (int iBin = 0; iBin < NSelectionCriteria; ++iBin) { + registry.get(HIST("hSelCandidatesRecSig"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); + registry.get(HIST("hSelCandidatesRecBkg"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); + } + } + + if (fillQAHistograms) { + if (doprocessData) { + // eta of all final state daughters + registry.add("hEtaPi0FromXic", ";#eta (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaPi1FromXic", ";#eta (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaBachelorPion", ";#eta (#pi #leftarrow #Xi);entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaV0PosDau", ";;#eta (V0 pos. dau.);entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaV0NegDau", ";;#eta (V0 neg. dau.);entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + // pions from XicPlus + registry.add("hNClustersTpcPi0FromXic", ";#it{N}_{clusters}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersTpcPi1FromXic", ";#it{N}_{clusters}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcPi0FromXic", ";#it{N}_{rows}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcPi1FromXic", ";#it{N}_{rows}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersItsPi0FromXic", ";#it{N}_{clusters}^{ITS} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{7, 0.5, 7.5}}}); + registry.add("hNClustersItsPi1FromXic", ";#it{N}_{clusters}^{ITS} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{7, 0.5, 7.5}}}); + registry.add("hNClustersItsInnBarrPi0FromXic", ";#it{N}_{clusters}^{ITS-IB} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{3, 0.5, 3.5}}}); + registry.add("hNClustersItsInnBarrPi1FromXic", ";#it{N}_{clusters}^{ITS-IB} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{3, 0.5, 3.5}}}); + // Xi daughters + registry.add("hNClustersTpcBachelorPion", ";#it{N}_{clusters}^{TPC} (#pi #leftarrow #Xi);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersTpcV0PosDau", ";#it{N}_{clusters}^{TPC} (V0 pos. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersTpcV0NegDau", ";#it{N}_{clusters}^{TPC} (V0 neg. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcBachelorPion", ";#it{N}_{rows}^{TPC} (#pi #leftarrow #Xi);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcV0PosDau", ";#it{N}_{rows}^{TPC} (V0 pos. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcV0NegDau", ";#it{N}_{rows}^{TPC} (V0 neg. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + } else if (doprocessMc) { + // Reconstructed signal + // eta of all final state daughters + registry.add("hEtaPi0FromXicRecSig", "Reconstructed signal;#eta (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaPi1FromXicRecSig", "Reconstructed signal;#eta (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaBachelorPionRecSig", "Reconstructed signal;#eta (#pi #leftarrow #Xi);entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaV0PosDauRecSig", "Reconstructed signal;#eta (V0 pos. dau.);entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaV0NegDauRecSig", "Reconstructed signal;#eta (V0 neg. dau.);entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + // pions from XicPlus + registry.add("hNClustersTpcPi0FromXicRecSig", "Reconstructed signal;#it{N}_{clusters}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersTpcPi1FromXicRecSig", "Reconstructed signal;#it{N}_{clusters}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcPi0FromXicRecSig", "Reconstructed signal;#it{N}_{rows}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcPi1FromXicRecSig", "Reconstructed signal;#it{N}_{rows}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersItsPi0FromXicRecSig", "Reconstructed signal;#it{N}_{clusters}^{ITS} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{7, 0.5, 7.5}}}); + registry.add("hNClustersItsPi1FromXicRecSig", "Reconstructed signal;#it{N}_{clusters}^{ITS} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{7, 0.5, 7.5}}}); + registry.add("hNClustersItsInnBarrPi0FromXicRecSig", "Reconstructed signal;#it{N}_{clusters}^{ITS-IB} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{3, 0.5, 3.5}}}); + registry.add("hNClustersItsInnBarrPi1FromXicRecSig", "Reconstructed signal;#it{N}_{clusters}^{ITS-IB} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{3, 0.5, 3.5}}}); + // Xi daughters + registry.add("hNClustersTpcBachelorPionRecSig", "Reconstructed signal;#it{N}_{clusters}^{TPC} (#pi #leftarrow #Xi);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersTpcV0PosDauRecSig", "Reconstructed signal;#it{N}_{clusters}^{TPC} (V0 pos. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersTpcV0NegDauRecSig", "Reconstructed signal;#it{N}_{clusters}^{TPC} (V0 neg. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcBachelorPionRecSig", "Reconstructed signal;#it{N}_{rows}^{TPC} (#pi #leftarrow #Xi);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcV0PosDauRecSig", "Reconstructed signal;#it{N}_{rows}^{TPC} (V0 pos. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcV0NegDauRecSig", "Reconstructed signal;#it{N}_{rows}^{TPC} (V0 neg. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + // Reconstructed background + // eta of all final state daughters + registry.add("hEtaPi0FromXicRecBkg", "Reconstructed background;#eta (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaPi1FromXicRecBkg", "Reconstructed background;#eta (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaBachelorPionRecBkg", "Reconstructed background;#eta (#pi #leftarrow #Xi);entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaV0PosDauRecBkg", "Reconstructed background;#eta (V0 pos. dau.);entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + registry.add("hEtaV0NegDauRecBkg", "Reconstructed background;#eta (V0 neg. dau.);entries", {HistType::kTH1F, {{150, -1.5f, +1.5f}}}); + // pions from XicPlus + registry.add("hNClustersTpcPi0FromXicRecBkg", "Reconstructed background;#it{N}_{clusters}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersTpcPi1FromXicRecBkg", "Reconstructed background;#it{N}_{clusters}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcPi0FromXicRecBkg", "Reconstructed background;#it{N}_{rows}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcPi1FromXicRecBkg", "Reconstructed background;#it{N}_{rows}^{TPC} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersItsPi0FromXicRecBkg", "Reconstructed background;#it{N}_{clusters}^{ITS} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{7, 0.5, 7.5}}}); + registry.add("hNClustersItsPi1FromXicRecBkg", "Reconstructed background;#it{N}_{clusters}^{ITS} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{7, 0.5, 7.5}}}); + registry.add("hNClustersItsInnBarrPi0FromXicRecBkg", "Reconstructed background;#it{N}_{clusters}^{ITS-IB} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{3, 0.5, 3.5}}}); + registry.add("hNClustersItsInnBarrPi1FromXicRecBkg", "Reconstructed background;#it{N}_{clusters}^{ITS-IB} (#pi #leftarrow #Xi_{c}^{#plus});entries", {HistType::kTH1F, {{3, 0.5, 3.5}}}); + // Xi daughters + registry.add("hNClustersTpcBachelorPionRecBkg", "Reconstructed background;#it{N}_{clusters}^{TPC} (#pi #leftarrow #Xi);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersTpcV0PosDauRecBkg", "Reconstructed background;#it{N}_{clusters}^{TPC} (V0 pos. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNClustersTpcV0NegDauRecBkg", "Reconstructed background;#it{N}_{clusters}^{TPC} (V0 neg. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcBachelorPionRecBkg", "Reconstructed background;#it{N}_{rows}^{TPC} (#pi #leftarrow #Xi);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcV0PosDauRecBkg", "Reconstructed background;#it{N}_{rows}^{TPC} (V0 pos. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); + registry.add("hNCrossedRowsTpcV0NegDauRecBkg", "Reconstructed background;#it{N}_{rows}^{TPC} (V0 neg. dau.);entries", {HistType::kTH1F, {{103, 49.5, 152.5}}}); } } @@ -129,183 +260,510 @@ struct HfCandidateSelectorXicToXiPiPi { } } - /// Conjugate-independent topological cuts - /// \param candidate is candidate - /// \return true if candidate passes all cuts - template - bool selectionTopol(const T1& hfCandXic) + /// Apply PID selection + /// \param statusPidPi0 PID status of prong1 with pion hypothesis + /// \param statusPidPi1 PID status of prong2 with pion hypothesis + /// \param statusPidPiXi PID status of bachelor track with pion hypothesis + /// \param statusPidPrLam PID status of V0 daughter with proton hypothesis + /// \param statusPidPiLam PID status of V0 daughter with pion hypothesis + /// \param usePidTpcOnly switch to check only TPC status + /// \return true if prongs of Xic candidate pass all PID selections + bool isSelectedPid(TrackSelectorPID::Status const statusPidPi0, + TrackSelectorPID::Status const statusPidPi1, + TrackSelectorPID::Status const statusPidPiXi, + TrackSelectorPID::Status const statusPidPrLam, + TrackSelectorPID::Status const statusPidPiLam, + bool const useTpcPidOnly) { - auto candpT = hfCandXic.pt(); - int pTBin = findBin(binsPt, candpT); - if (pTBin == -1) { + if (useTpcPidOnly) { + if ((statusPidPi0 != TrackSelectorPID::Accepted && statusPidPi0 != TrackSelectorPID::NotApplicable) || (statusPidPi1 != TrackSelectorPID::Accepted && statusPidPi1 != TrackSelectorPID::NotApplicable) || (statusPidPiXi != TrackSelectorPID::Accepted && statusPidPiXi != TrackSelectorPID::NotApplicable) || (statusPidPrLam != TrackSelectorPID::Accepted && statusPidPrLam != TrackSelectorPID::NotApplicable) || (statusPidPiLam != TrackSelectorPID::Accepted && statusPidPiLam != TrackSelectorPID::NotApplicable)) { + return false; + } + return true; + } + if (statusPidPi0 == TrackSelectorPID::Rejected || statusPidPi1 == TrackSelectorPID::Rejected || statusPidPiXi == TrackSelectorPID::Rejected || statusPidPrLam == TrackSelectorPID::Rejected || statusPidPiLam == TrackSelectorPID::Rejected) { return false; } + return true; + } + + /// Combine kinematic, topological, track quality and PID selections + /// \param hfCandXic Xic candidate + /// \param statusXicToXiPiPi Flag to store selection status as defined in hf_sel_candidate_xic::XicToXiPiPiSelectionStep + /// \param isMatchedSignal Flag to indicate if the candidate is matched to a genereated XiCplus MC particle + /// \return true if Xic candidate passes all selections, otherwise false + template + bool isSelectedXicToXiPiPiCandidateWoMl(XicCandidate const& hfCandXic, + TracksExtraWPid const&, + int& statusXicToXiPiPi, + bool const isMatchedSignal = false) + { + // Successful reconstruction + SETBIT(statusXicToXiPiPi, hf_sel_candidate_xic::XicToXiPiPiSelectionStep::RecoTotal); // RecoTotal = 0 --> statusXicToXiPiPi += 1 + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), All); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), All); + } + } else { + registry.fill(HIST("hSelCandidates"), All); + } + + // Retrieve daughter tracks + auto trackPi0 = hfCandXic.template pi0_as(); + auto trackPi1 = hfCandXic.template pi1_as(); + auto trackPiFromXi = hfCandXic.template bachelor_as(); + auto trackV0PosDau = hfCandXic.template posTrack_as(); + auto trackV0NegDau = hfCandXic.template negTrack_as(); + + if (fillQAHistograms) { + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hEtaPi0FromXicRecSig"), trackPi0.eta()); + registry.fill(HIST("hEtaPi1FromXicRecSig"), trackPi1.eta()); + registry.fill(HIST("hEtaBachelorPionRecSig"), trackPiFromXi.eta()); + registry.fill(HIST("hEtaV0PosDauRecSig"), trackV0PosDau.eta()); + registry.fill(HIST("hEtaV0NegDauRecSig"), trackV0NegDau.eta()); + registry.fill(HIST("hNClustersTpcPi0FromXicRecSig"), trackPi0.tpcNClsFound()); + registry.fill(HIST("hNClustersTpcPi1FromXicRecSig"), trackPi1.tpcNClsFound()); + registry.fill(HIST("hNCrossedRowsTpcPi0FromXicRecSig"), trackPi0.tpcNClsCrossedRows()); + registry.fill(HIST("hNCrossedRowsTpcPi1FromXicRecSig"), trackPi1.tpcNClsCrossedRows()); + registry.fill(HIST("hNClustersItsPi0FromXicRecSig"), trackPi0.itsNCls()); + registry.fill(HIST("hNClustersItsPi1FromXicRecSig"), trackPi1.itsNCls()); + registry.fill(HIST("hNClustersItsInnBarrPi0FromXicRecSig"), trackPi0.itsNClsInnerBarrel()); + registry.fill(HIST("hNClustersItsInnBarrPi1FromXicRecSig"), trackPi1.itsNClsInnerBarrel()); + registry.fill(HIST("hNClustersTpcBachelorPionRecSig"), trackPiFromXi.tpcNClsFound()); + registry.fill(HIST("hNClustersTpcV0PosDauRecSig"), trackV0PosDau.tpcNClsFound()); + registry.fill(HIST("hNClustersTpcV0NegDauRecSig"), trackV0NegDau.tpcNClsFound()); + registry.fill(HIST("hNCrossedRowsTpcBachelorPionRecSig"), trackPiFromXi.tpcNClsCrossedRows()); + registry.fill(HIST("hNCrossedRowsTpcV0PosDauRecSig"), trackV0PosDau.tpcNClsCrossedRows()); + registry.fill(HIST("hNCrossedRowsTpcV0NegDauRecSig"), trackV0NegDau.tpcNClsCrossedRows()); + } else { + registry.fill(HIST("hEtaPi0FromXicRecBkg"), trackPi0.eta()); + registry.fill(HIST("hEtaPi1FromXicRecBkg"), trackPi1.eta()); + registry.fill(HIST("hEtaBachelorPionRecBkg"), trackPiFromXi.eta()); + registry.fill(HIST("hEtaV0PosDauRecBkg"), trackV0PosDau.eta()); + registry.fill(HIST("hEtaV0NegDauRecBkg"), trackV0NegDau.eta()); + registry.fill(HIST("hNClustersTpcPi0FromXicRecBkg"), trackPi0.tpcNClsFound()); + registry.fill(HIST("hNClustersTpcPi1FromXicRecBkg"), trackPi1.tpcNClsFound()); + registry.fill(HIST("hNCrossedRowsTpcPi0FromXicRecBkg"), trackPi0.tpcNClsCrossedRows()); + registry.fill(HIST("hNCrossedRowsTpcPi1FromXicRecBkg"), trackPi1.tpcNClsCrossedRows()); + registry.fill(HIST("hNClustersItsPi0FromXicRecBkg"), trackPi0.itsNCls()); + registry.fill(HIST("hNClustersItsPi1FromXicRecBkg"), trackPi1.itsNCls()); + registry.fill(HIST("hNClustersItsInnBarrPi0FromXicRecBkg"), trackPi0.itsNClsInnerBarrel()); + registry.fill(HIST("hNClustersItsInnBarrPi1FromXicRecBkg"), trackPi1.itsNClsInnerBarrel()); + registry.fill(HIST("hNClustersTpcBachelorPionRecBkg"), trackPiFromXi.tpcNClsFound()); + registry.fill(HIST("hNClustersTpcV0PosDauRecBkg"), trackV0PosDau.tpcNClsFound()); + registry.fill(HIST("hNClustersTpcV0NegDauRecBkg"), trackV0NegDau.tpcNClsFound()); + registry.fill(HIST("hNCrossedRowsTpcBachelorPionRecBkg"), trackPiFromXi.tpcNClsCrossedRows()); + registry.fill(HIST("hNCrossedRowsTpcV0PosDauRecBkg"), trackV0PosDau.tpcNClsCrossedRows()); + registry.fill(HIST("hNCrossedRowsTpcV0NegDauRecBkg"), trackV0NegDau.tpcNClsCrossedRows()); + } + } else { + registry.fill(HIST("hEtaPi0FromXic"), trackPi0.eta()); + registry.fill(HIST("hEtaPi1FromXic"), trackPi1.eta()); + registry.fill(HIST("hEtaBachelorPion"), trackPiFromXi.eta()); + registry.fill(HIST("hEtaV0PosDau"), trackV0PosDau.eta()); + registry.fill(HIST("hEtaV0NegDau"), trackV0NegDau.eta()); + registry.fill(HIST("hNClustersTpcPi0FromXic"), trackPi0.tpcNClsFound()); + registry.fill(HIST("hNClustersTpcPi1FromXic"), trackPi1.tpcNClsFound()); + registry.fill(HIST("hNCrossedRowsTpcPi0FromXic"), trackPi0.tpcNClsCrossedRows()); + registry.fill(HIST("hNCrossedRowsTpcPi1FromXic"), trackPi1.tpcNClsCrossedRows()); + registry.fill(HIST("hNClustersItsPi0FromXic"), trackPi0.itsNCls()); + registry.fill(HIST("hNClustersItsPi1FromXic"), trackPi1.itsNCls()); + registry.fill(HIST("hNClustersItsInnBarrPi0FromXic"), trackPi0.itsNClsInnerBarrel()); + registry.fill(HIST("hNClustersItsInnBarrPi1FromXic"), trackPi1.itsNClsInnerBarrel()); + registry.fill(HIST("hNClustersTpcBachelorPion"), trackPiFromXi.tpcNClsFound()); + registry.fill(HIST("hNClustersTpcV0PosDau"), trackV0PosDau.tpcNClsFound()); + registry.fill(HIST("hNClustersTpcV0NegDau"), trackV0NegDau.tpcNClsFound()); + registry.fill(HIST("hNCrossedRowsTpcBachelorPion"), trackPiFromXi.tpcNClsCrossedRows()); + registry.fill(HIST("hNCrossedRowsTpcV0PosDau"), trackV0PosDau.tpcNClsCrossedRows()); + registry.fill(HIST("hNCrossedRowsTpcV0NegDau"), trackV0NegDau.tpcNClsCrossedRows()); + } + } - // check that the candidate pT is within the analysis range - if (candpT < ptCandMin || candpT >= ptCandMax) { + //////////////////////////////////////////////// + // Kinematic and topological selection // + //////////////////////////////////////////////// + + // check whether candidate is in analyzed pT range + auto ptCandXic = hfCandXic.pt(); + int pTBin = findBin(binsPt, ptCandXic); + if (pTBin == -1) { return false; } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), Pt); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), Pt); + } + } else { + registry.fill(HIST("hSelCandidates"), Pt); + } - // check candidate mass is within a defined mass window + // check whether candidate mass is within a defined mass window if (std::abs(hfCandXic.invMassXicPlus() - o2::constants::physics::MassXiCPlus) > cuts->get(pTBin, "m")) { return false; } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), Mass); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), Mass); + } + } else { + registry.fill(HIST("hSelCandidates"), Mass); + } - // cosine of pointing angle - if (hfCandXic.cpa() <= cuts->get(pTBin, "cos pointing angle")) { + // cut on candidate rapidity + if (std::abs(hfCandXic.y(o2::constants::physics::MassXiCPlus)) > cuts->get(pTBin, "y")) { return false; } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), Rapidity); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), Rapidity); + } + } else { + registry.fill(HIST("hSelCandidates"), Rapidity); + } - // cosine of pointing angle XY - if (hfCandXic.cpaXY() <= cuts->get(pTBin, "cos pointing angle XY")) { + // cut on candidate pseudorapidity + if (std::abs(hfCandXic.eta()) > cuts->get(pTBin, "eta")) { return false; } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), Eta); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), Eta); + } + } else { + registry.fill(HIST("hSelCandidates"), Eta); + } - // candidate maximum decay length - if (hfCandXic.decayLength() > cuts->get(pTBin, "max decay length")) { + // cut on pseudorapidity of pions from XicPlus + if (std::abs(trackPi0.eta()) > cuts->get(pTBin, "eta Pi from XicPlus") || std::abs(trackPi1.eta()) > cuts->get(pTBin, "eta Pi from XicPlus")) { return false; } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), EtaPionFromXicPlus); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), EtaPionFromXicPlus); + } + } else { + registry.fill(HIST("hSelCandidates"), EtaPionFromXicPlus); + } - // candidate maximum decay length XY - if (hfCandXic.decayLengthXY() > cuts->get(pTBin, "max decay length XY")) { + // cut on pseudorapidity of Xi daughters + if (std::abs(trackPiFromXi.eta()) > cuts->get(pTBin, "eta Xi Daughters") || std::abs(trackV0PosDau.eta()) > cuts->get(pTBin, "eta Xi Daughters") || std::abs(trackV0NegDau.eta()) > cuts->get(pTBin, "eta Xi Daughters")) { return false; } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), EtaXiDaughters); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), EtaXiDaughters); + } + } else { + registry.fill(HIST("hSelCandidates"), EtaXiDaughters); + } - // candidate chi2PC - if (hfCandXic.chi2PCA() > cuts->get(pTBin, "chi2PCA")) { + // cut on pion pT + if (hfCandXic.ptProng1() < cuts->get(pTBin, "pT Pi0") || hfCandXic.ptProng2() < cuts->get(pTBin, "pT Pi1") || (hfCandXic.ptProng1() + hfCandXic.ptProng2()) < cuts->get(pTBin, "pT Pi0 + Pi1")) { return false; } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), PtPionFromXicPlus); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), PtPionFromXicPlus); + } + } else { + registry.fill(HIST("hSelCandidates"), PtPionFromXicPlus); + } - // maximum DCA of daughters - if ((std::abs(hfCandXic.impactParameter0()) > cuts->get(pTBin, "max impParXY Xi")) || - (std::abs(hfCandXic.impactParameter1()) > cuts->get(pTBin, "max impParXY Pi0")) || - (std::abs(hfCandXic.impactParameter2()) > cuts->get(pTBin, "max impParXY Pi1"))) { + // cut on chi2 of secondary vertex + if (hfCandXic.chi2PCA() > cuts->get(pTBin, "chi2SV")) { return false; } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), Chi2SV); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), Chi2SV); + } + } else { + registry.fill(HIST("hSelCandidates"), Chi2SV); + } - // cut on daughter pT - if (hfCandXic.ptProng0() < cuts->get(pTBin, "pT Xi") || - hfCandXic.ptProng1() < cuts->get(pTBin, "pT Pi0") || - hfCandXic.ptProng2() < cuts->get(pTBin, "pT Pi1")) { + // cut on candidate decay length + if (hfCandXic.decayLength() < cuts->get(pTBin, "min decay length") || hfCandXic.decayLengthXY() < cuts->get(pTBin, "min decay length XY")) { return false; } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), MinDecayLength); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), MinDecayLength); + } + } else { + registry.fill(HIST("hSelCandidates"), MinDecayLength); + } - return true; - } - - /// Apply PID selection - /// \param pidTrackPi0 PID status of trackPi0 (prong1 of Xic candidate) - /// \param pidTrackPi1 PID status of trackPi1 (prong2 of Xic candidate) - /// \param pidTrackPr PID status of trackPr (positive daughter of V0 candidate) - /// \param pidTrackPiLam PID status of trackPiLam (negative daughter of V0 candidate) - /// \param pidTrackPiXi PID status of trackPiXi (Bachelor of cascade candidate) - /// \param acceptPIDNotApplicable switch to accept Status::NotApplicable - /// \return true if prongs of Xic candidate pass all selections - bool selectionPid(TrackSelectorPID::Status const pidTrackPi0, - TrackSelectorPID::Status const pidTrackPi1, - TrackSelectorPID::Status const pidTrackPr, - TrackSelectorPID::Status const pidTrackPiLam, - TrackSelectorPID::Status const pidTrackPiXi, - bool const acceptPIDNotApplicable) - { - if (!acceptPIDNotApplicable && (pidTrackPi0 != TrackSelectorPID::Accepted || pidTrackPi1 != TrackSelectorPID::Accepted || pidTrackPr != TrackSelectorPID::Accepted || pidTrackPiLam != TrackSelectorPID::Accepted || pidTrackPiXi != TrackSelectorPID::Accepted)) { + // cut on invariant mass of Xi-pion pairs + if (hfCandXic.invMassXiPi0() > cuts->get(pTBin, "max inv mass Xi-Pi0") || hfCandXic.invMassXiPi1() > cuts->get(pTBin, "max inv mass Xi-Pi1")) { return false; } - if (acceptPIDNotApplicable && (pidTrackPi0 == TrackSelectorPID::Rejected || pidTrackPi1 == TrackSelectorPID::Rejected || pidTrackPr == TrackSelectorPID::Rejected || pidTrackPiLam == TrackSelectorPID::Rejected || pidTrackPiXi == TrackSelectorPID::Rejected)) { - return false; + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), MaxInvMassXiPiPairs); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), MaxInvMassXiPiPairs); + } + } else { + registry.fill(HIST("hSelCandidates"), MaxInvMassXiPiPairs); } + + // Successful kinematic and topological selection + SETBIT(statusXicToXiPiPi, hf_sel_candidate_xic::XicToXiPiPiSelectionStep::RecoKinTopol); // RecoKinTopol = 1 --> statusXicToXiPiPi += 2 + + //////////////////////////////////////////////// + // Track quality selection // + //////////////////////////////////////////////// + if (doTrackQualitySelection) { + // TPC track quality selection on Xi daughters (bachelor pion and V0 daughters) + if (!isSelectedTrackTpcQuality(trackPiFromXi, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax) || + !isSelectedTrackTpcQuality(trackV0PosDau, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax) || + !isSelectedTrackTpcQuality(trackV0NegDau, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax)) { + return false; + } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), TpcTrackQualityXiDaughters); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), TpcTrackQualityXiDaughters); + } + } else { + registry.fill(HIST("hSelCandidates"), TpcTrackQualityXiDaughters); + } + + // TPC track quality selection on pions from charm baryon + if (!isSelectedTrackTpcQuality(trackPi0, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax) || + !isSelectedTrackTpcQuality(trackPi1, nClustersTpcMin, nTpcCrossedRowsMin, tpcCrossedRowsOverFindableClustersRatioMin, tpcChi2PerClusterMax)) { + return false; + } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), TpcTrackQualityPiFromCharm); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), TpcTrackQualityPiFromCharm); + } + } else { + registry.fill(HIST("hSelCandidates"), TpcTrackQualityPiFromCharm); + } + + // ITS track quality selection on pions from charm baryon + if ((!isSelectedTrackItsQuality(trackPi0, nClustersItsMin, itsChi2PerClusterMax) || trackPi0.itsNClsInnerBarrel() < nClustersItsInnBarrMin) || + (!isSelectedTrackItsQuality(trackPi0, nClustersItsMin, itsChi2PerClusterMax) || trackPi1.itsNClsInnerBarrel() < nClustersItsInnBarrMin)) { + return false; + } + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), ItsTrackQualityPiFromCharm); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), ItsTrackQualityPiFromCharm); + } + } else { + registry.fill(HIST("hSelCandidates"), ItsTrackQualityPiFromCharm); + } + + // Successful track quality selection + SETBIT(statusXicToXiPiPi, hf_sel_candidate_xic::XicToXiPiPiSelectionStep::RecoTrackQuality); // RecoTrackQuality = 2 --> statusXicToXiPiPi += 4 + } else { + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), TpcTrackQualityXiDaughters); + registry.fill(HIST("hSelCandidatesRecSig"), TpcTrackQualityPiFromCharm); + registry.fill(HIST("hSelCandidatesRecSig"), ItsTrackQualityPiFromCharm); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), TpcTrackQualityXiDaughters); + registry.fill(HIST("hSelCandidatesRecBkg"), TpcTrackQualityPiFromCharm); + registry.fill(HIST("hSelCandidatesRecBkg"), ItsTrackQualityPiFromCharm); + } + } else { + registry.fill(HIST("hSelCandidates"), TpcTrackQualityXiDaughters); + registry.fill(HIST("hSelCandidates"), TpcTrackQualityPiFromCharm); + registry.fill(HIST("hSelCandidates"), ItsTrackQualityPiFromCharm); + } + } + + //////////////////////////////////////////////// + // PID selection // + //////////////////////////////////////////////// + if (usePid) { + TrackSelectorPID::Status statusPidPi0 = TrackSelectorPID::NotApplicable; + TrackSelectorPID::Status statusPidPi1 = TrackSelectorPID::NotApplicable; + TrackSelectorPID::Status statusPidPiXi = TrackSelectorPID::NotApplicable; + TrackSelectorPID::Status statusPidPrLam = TrackSelectorPID::NotApplicable; + TrackSelectorPID::Status statusPidPiLam = TrackSelectorPID::NotApplicable; + + // assign proton and pion hypothesis to V0 daughters + auto trackPr = trackV0PosDau; + auto trackPiFromLam = trackV0NegDau; + if (hfCandXic.sign() < 0) { + trackPr = trackV0NegDau; + trackPiFromLam = trackV0PosDau; + } + + if (useTpcPidOnly) { + statusPidPi0 = selectorPion.statusTpc(trackPi0); + statusPidPi1 = selectorPion.statusTpc(trackPi1); + statusPidPiXi = selectorPion.statusTpc(trackPiFromXi); + statusPidPrLam = selectorProton.statusTpc(trackPr); + statusPidPiLam = selectorPion.statusTpc(trackPiFromLam); + } else { + statusPidPi0 = selectorPion.statusTpcOrTof(trackPi0); + statusPidPi1 = selectorPion.statusTpcOrTof(trackPi1); + statusPidPiXi = selectorPion.statusTpcOrTof(trackPiFromXi); + statusPidPrLam = selectorProton.statusTpcOrTof(trackPr); + statusPidPiLam = selectorPion.statusTpcOrTof(trackPiFromLam); + } + + if (!isSelectedPid(statusPidPi0, statusPidPi1, statusPidPiXi, statusPidPrLam, statusPidPiLam, useTpcPidOnly.value)) { + return false; + } + + // Successful PID selection + SETBIT(statusXicToXiPiPi, hf_sel_candidate_xic::XicToXiPiPiSelectionStep::RecoPID); // RecoPID = 3 --> statusXicToXiPiPi += 8 + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), PidSelected); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), PidSelected); + } + } else { + registry.fill(HIST("hSelCandidates"), PidSelected); + } + } else { + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), PidSelected); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), PidSelected); + } + } else { + registry.fill(HIST("hSelCandidates"), PidSelected); + } + } + return true; } - void process(aod::HfCandXic const& hfCandsXic, - TracksPidWithSel const&) + /// Apply BDT selection + /// \param hfCandXic Xic candidate + /// \param statusXicToXiPiPi Flag to store selection status as defined in hf_sel_candidate_xic::XicToXiPiPiSelectionStep + /// \param isMatchedSignal Flag to indicate if the candidate is matched to a genereated XiCplus MC particle + template + void isBdtSelected(XicCandidate const& hfCandXic, + int& statusXicToXiPiPi, + bool const isMatchedSignal = false) { - for (const auto& hfCandXic : hfCandsXic) { - int statusXicToXiPiPi = 0; + bool isSelectedMlXicToXiPiPi = false; + float ptCandXic = hfCandXic.pt(); - outputMlXicToXiPiPi.clear(); + std::vector inputFeaturesXicToXiPiPi = hfMlResponse.getInputFeatures(hfCandXic); + isSelectedMlXicToXiPiPi = hfMlResponse.isSelectedMl(inputFeaturesXicToXiPiPi, ptCandXic, outputMlXicToXiPiPi); - auto ptCandXic = hfCandXic.pt(); + hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi); - if (activateQA) { - registry.fill(HIST("hSelections"), 1, ptCandXic); + if (!isSelectedMlXicToXiPiPi) { + return; + } + + // Successful ML selection + SETBIT(statusXicToXiPiPi, hf_sel_candidate_xic::XicToXiPiPiSelectionStep::RecoMl); // RecoML = 4 --> statusXicToXiPiPi += 16 + if constexpr (isMc) { + if (isMatchedSignal) { + registry.fill(HIST("hSelCandidatesRecSig"), BdtSelected); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), BdtSelected); } + } else { + registry.fill(HIST("hSelCandidates"), BdtSelected); + } + } - // No hfFlag -> by default skim selected - SETBIT(statusXicToXiPiPi, SelectionStep::RecoSkims); // RecoSkims = 0 --> statusXicToXiPiPi = 1 - if (activateQA) { - registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoSkims, ptCandXic); + void processData(aod::HfCandXic const& hfCandsXic, + TracksExtraWPid const& tracks) + { + for (const auto& hfCandXic : hfCandsXic) { + int statusXicToXiPiPi = 0; + if (applyMl) { + outputMlXicToXiPiPi.clear(); } - // topological cuts - if (!selectionTopol(hfCandXic)) { + // Kinematic, topological, track quality and PID selections + if (!isSelectedXicToXiPiPiCandidateWoMl(hfCandXic, tracks, statusXicToXiPiPi)) { hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); if (applyMl) { hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi); } continue; } - SETBIT(statusXicToXiPiPi, SelectionStep::RecoTopol); // RecoTopol = 1 --> statusXicToXiPiPi = 3 - if (activateQA) { - registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoTopol, ptCandXic); - } - - // track-level PID selection - if (usePid) { - auto trackPi0 = hfCandXic.pi0_as(); - auto trackPi1 = hfCandXic.pi1_as(); - auto trackV0PosDau = hfCandXic.posTrack_as(); - auto trackV0NegDau = hfCandXic.negTrack_as(); - auto trackPiFromXi = hfCandXic.bachelor_as(); - // assign proton and pion hypothesis to V0 daughters - auto trackPr = trackV0PosDau; - auto trackPiFromLam = trackV0NegDau; - if (hfCandXic.sign() < 0) { - trackPr = trackV0NegDau; - trackPiFromLam = trackV0PosDau; - } - // PID info - TrackSelectorPID::Status pidTrackPi0 = selectorPion.statusTpcAndTof(trackPi0); - TrackSelectorPID::Status pidTrackPi1 = selectorPion.statusTpcAndTof(trackPi1); - TrackSelectorPID::Status pidTrackPr = selectorProton.statusTpcAndTof(trackPr); - TrackSelectorPID::Status pidTrackPiLam = selectorPion.statusTpcAndTof(trackPiFromLam); - TrackSelectorPID::Status pidTrackPiXi = selectorPion.statusTpcAndTof(trackPiFromXi); - - if (!selectionPid(pidTrackPi0, pidTrackPi1, pidTrackPr, pidTrackPiLam, pidTrackPiXi, acceptPIDNotApplicable.value)) { - hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); - if (applyMl) { - hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi); - } - continue; - } - SETBIT(statusXicToXiPiPi, SelectionStep::RecoPID); // RecoPID = 2 --> statusXicToXiPiPi = 7 - if (activateQA) { - registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoPID, ptCandXic); - } - } // ML selection if (applyMl) { - bool isSelectedMlXicToXiPiPi = false; - std::vector inputFeaturesXicToXiPiPi = hfMlResponse.getInputFeatures(hfCandXic); + isBdtSelected(hfCandXic, statusXicToXiPiPi); + } else { + registry.fill(HIST("hSelCandidates"), BdtSelected); + } - isSelectedMlXicToXiPiPi = hfMlResponse.isSelectedMl(inputFeaturesXicToXiPiPi, ptCandXic, outputMlXicToXiPiPi); + hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); + } + } + PROCESS_SWITCH(HfCandidateSelectorXicToXiPiPi, processData, "Select candidates without MC matching information", true); - hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi); + void processMc(soa::Join const& hfCandsXic, + TracksExtraWPid const& tracks) + { + for (const auto& hfCandXic : hfCandsXic) { + int statusXicToXiPiPi = 0; + if (applyMl) { + outputMlXicToXiPiPi.clear(); + } - if (!isSelectedMlXicToXiPiPi) { - hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); - continue; - } - SETBIT(statusXicToXiPiPi, aod::SelectionStep::RecoMl); - if (activateQA) { - registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoMl, ptCandXic); + bool isMatchedCandidate = false; + if (hfCandXic.flagMcMatchRec() != int8_t(0)) { + isMatchedCandidate = true; + } + + // Kinematic, topological, track quality and PID selections + if (!isSelectedXicToXiPiPiCandidateWoMl(hfCandXic, tracks, statusXicToXiPiPi, isMatchedCandidate)) { + hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); + if (applyMl) { + hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi); } + continue; + } + + // ML selection + if (applyMl) { + isBdtSelected(hfCandXic, statusXicToXiPiPi, isMatchedCandidate); + } else if (isMatchedCandidate) { + registry.fill(HIST("hSelCandidatesRecSig"), BdtSelected); + } else { + registry.fill(HIST("hSelCandidatesRecBkg"), BdtSelected); } hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); } } + PROCESS_SWITCH(HfCandidateSelectorXicToXiPiPi, processMc, "Select candidates with MC matching information", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/candidateSelectorXiccToPKPiPi.cxx b/PWGHF/TableProducer/candidateSelectorXiccToPKPiPi.cxx index ce9a5f3375f..dd178bd83f0 100644 --- a/PWGHF/TableProducer/candidateSelectorXiccToPKPiPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorXiccToPKPiPi.cxx @@ -14,16 +14,25 @@ /// /// \author Gian Michele Innocenti , CERN -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelectorPID.h" - #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/TrackSelectorPID.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -47,7 +56,7 @@ struct HfCandidateSelectorXiccToPKPiPi { Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_xicc_to_p_k_pi_pi::vecBinsPt}, "pT bin limits"}; - Configurable> cuts{"cuts", {hf_cuts_xicc_to_p_k_pi_pi::cuts[0], hf_cuts_xicc_to_p_k_pi_pi::nBinsPt, hf_cuts_xicc_to_p_k_pi_pi::nCutVars, hf_cuts_xicc_to_p_k_pi_pi::labelsPt, hf_cuts_xicc_to_p_k_pi_pi::labelsCutVar}, "Xicc candidate selection per pT bin"}; + Configurable> cuts{"cuts", {hf_cuts_xicc_to_p_k_pi_pi::Cuts[0], hf_cuts_xicc_to_p_k_pi_pi::NBinsPt, hf_cuts_xicc_to_p_k_pi_pi::NCutVars, hf_cuts_xicc_to_p_k_pi_pi::labelsPt, hf_cuts_xicc_to_p_k_pi_pi::labelsCutVar}, "Xicc candidate selection per pT bin"}; HfHelper hfHelper; TrackSelectorPi selectorPion; diff --git a/PWGHF/TableProducer/converterDstarIndices.cxx b/PWGHF/TableProducer/converterDstarIndices.cxx index 9596a571498..8b26f94610e 100644 --- a/PWGHF/TableProducer/converterDstarIndices.cxx +++ b/PWGHF/TableProducer/converterDstarIndices.cxx @@ -14,12 +14,12 @@ /// /// \author Fabrizio Grosa , CERN -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" - #include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include +#include +#include + using namespace o2; using namespace o2::framework; diff --git a/PWGHF/TableProducer/derivedDataCreatorB0ToDPi.cxx b/PWGHF/TableProducer/derivedDataCreatorB0ToDPi.cxx new file mode 100644 index 00000000000..290773cfa9f --- /dev/null +++ b/PWGHF/TableProducer/derivedDataCreatorB0ToDPi.cxx @@ -0,0 +1,444 @@ +// 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. + +/// \file derivedDataCreatorB0ToDPi.cxx +/// \brief Producer of derived tables of B+ candidates, collisions and MC particles +/// \note Based on derivedDataCreatorBplusToD0Pi.cxx +/// +/// \author Vít Kučera , Inha University + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGHF/Utils/utilsDerivedData.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::pid_tpc_tof_utils; +using namespace o2::analysis::hf_derived; +using namespace o2::hf_decay::hf_cand_beauty; + +/// Writes the full information in an output TTree +struct HfDerivedDataCreatorB0ToDPi { + HfProducesDerivedData< + o2::aod::HfB0Bases, + o2::aod::HfB0CollBases, + o2::aod::HfB0CollIds, + o2::aod::HfB0McCollBases, + o2::aod::HfB0McCollIds, + o2::aod::HfB0McRCollIds, + o2::aod::HfB0PBases, + o2::aod::HfB0PIds> + rowsCommon; + // Candidates + Produces rowCandidatePar; + Produces rowCandidateParDplus; + Produces rowCandidateParE; + Produces rowCandidateSel; + Produces rowCandidateMl; + Produces rowCandidateMlDplus; + Produces rowCandidateId; + Produces rowCandidateMc; + + // Switches for filling tables + HfConfigurableDerivedData confDerData; + Configurable fillCandidatePar{"fillCandidatePar", true, "Fill candidate parameters"}; + Configurable fillCandidateParDplus{"fillCandidateParDplus", true, "Fill D+ candidate parameters"}; + Configurable fillCandidateParE{"fillCandidateParE", true, "Fill candidate extended parameters"}; + Configurable fillCandidateSel{"fillCandidateSel", true, "Fill candidate selection flags"}; + Configurable fillCandidateMl{"fillCandidateMl", true, "Fill candidate selection ML scores"}; + Configurable fillCandidateMlDplus{"fillCandidateMlDplus", true, "Fill D+ candidate selection ML scores"}; + Configurable fillCandidateId{"fillCandidateId", true, "Fill original indices from the candidate table"}; + Configurable fillCandidateMc{"fillCandidateMc", true, "Fill candidate MC info"}; + // Parameters for production of training samples + Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + + HfHelper hfHelper; + SliceCache cache; + static constexpr double mass{o2::constants::physics::MassB0}; + + using CollisionsWCentMult = soa::Join; + using CollisionsWMcCentMult = soa::Join; + using TracksWPid = soa::Join; + using SelectedCandidates = soa::Filtered>; + using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMl = soa::Filtered>; + using SelectedCandidatesMcMl = soa::Filtered>; + using MatchedGenCandidatesMc = soa::Filtered>; + using TypeMcCollisions = soa::Join; + using THfCandDaughtersMl = soa::Join; + + Filter filterSelectCandidates = (aod::hf_sel_candidate_b0::isSelB0ToDPi & static_cast(BIT(aod::SelectionStep::RecoMl - 1))) != 0; + Filter filterMcGenMatching = nabs(aod::hf_cand_b0::flagMcMatchGen) == static_cast(DecayChannelMain::B0ToDminusPi); + + Preslice candidatesPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMlPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcMlPerCollision = aod::hf_cand::collisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + + // trivial partitions for all candidates to allow "->sliceByCached" inside processCandidates + Partition candidatesAll = aod::hf_sel_candidate_b0::isSelB0ToDPi >= 0; + Partition candidatesMcAll = aod::hf_sel_candidate_b0::isSelB0ToDPi >= 0; + Partition candidatesMlAll = aod::hf_sel_candidate_b0::isSelB0ToDPi >= 0; + Partition candidatesMcMlAll = aod::hf_sel_candidate_b0::isSelB0ToDPi >= 0; + // partitions for signal and background + Partition candidatesMcSig = nabs(aod::hf_cand_b0::flagMcMatchRec) == static_cast(DecayChannelMain::B0ToDminusPi); + Partition candidatesMcBkg = nabs(aod::hf_cand_b0::flagMcMatchRec) != static_cast(DecayChannelMain::B0ToDminusPi); + Partition candidatesMcMlSig = nabs(aod::hf_cand_b0::flagMcMatchRec) == static_cast(DecayChannelMain::B0ToDminusPi); + Partition candidatesMcMlBkg = nabs(aod::hf_cand_b0::flagMcMatchRec) != static_cast(DecayChannelMain::B0ToDminusPi); + + void init(InitContext const&) + { + std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll, doprocessMcGenOnly}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "Only one process function can be enabled at a time."); + } + rowsCommon.init(confDerData); + } + + template + void fillTablesCandidate(const T& candidate, const U& prongCharm, const V& prongBachelor, int candFlag, double invMass, + double ct, double y, int8_t flagMc, int8_t origin, float mlScore, const std::vector& mlScoresCharm) + { + rowsCommon.fillTablesCandidate(candidate, invMass, y); + if (fillCandidatePar) { + rowCandidatePar( + candidate.chi2PCA(), + candidate.cpa(), + candidate.cpaXY(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameterNormalised0(), + candidate.impactParameterNormalised1(), + prongBachelor.tpcNSigmaPi(), + prongBachelor.tofNSigmaPi(), + prongBachelor.tpcTofNSigmaPi(), + prongBachelor.tpcNSigmaKa(), + prongBachelor.tofNSigmaKa(), + prongBachelor.tpcTofNSigmaKa(), + candidate.maxNormalisedDeltaIP(), + candidate.impactParameterProduct()); + } + if (fillCandidateParDplus) { + rowCandidateParDplus( + prongCharm.chi2PCA(), + prongCharm.nProngsContributorsPV(), + prongCharm.cpa(), + prongCharm.cpaXY(), + prongCharm.decayLength(), + prongCharm.decayLengthXY(), + prongCharm.decayLengthNormalised(), + prongCharm.decayLengthXYNormalised(), + prongCharm.ptProng0(), + prongCharm.ptProng1(), + prongCharm.ptProng2(), + prongCharm.impactParameter0(), + prongCharm.impactParameter1(), + prongCharm.impactParameter2(), + prongCharm.impactParameterNormalised0(), + prongCharm.impactParameterNormalised1(), + prongCharm.impactParameterNormalised2(), + prongCharm.nSigTpcPi0(), + prongCharm.nSigTofPi0(), + prongCharm.tpcTofNSigmaPi0(), + prongCharm.nSigTpcKa1(), + prongCharm.nSigTofKa1(), + prongCharm.tpcTofNSigmaKa1(), + prongCharm.nSigTpcPi2(), + prongCharm.nSigTofPi2(), + prongCharm.tpcTofNSigmaPi2()); + } + if (fillCandidateParE) { + rowCandidateParE( + candidate.xSecondaryVertex(), + candidate.ySecondaryVertex(), + candidate.zSecondaryVertex(), + candidate.errorDecayLength(), + candidate.errorDecayLengthXY(), + candidate.rSecondaryVertex(), + RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()), + candidate.pxProng1(), + candidate.pyProng1(), + candidate.pzProng1(), + candidate.errorImpactParameter1(), + hfHelper.cosThetaStarB0(candidate), + ct); + } + if (fillCandidateSel) { + rowCandidateSel( + BIT(candFlag)); + } + if (fillCandidateMl) { + rowCandidateMl( + mlScore); + } + if (fillCandidateMlDplus) { + rowCandidateMlDplus( + mlScoresCharm); + } + if (fillCandidateId) { + rowCandidateId( + candidate.collisionId(), + prongCharm.prong0Id(), + prongCharm.prong1Id(), + prongCharm.prong2Id(), + candidate.prong1Id()); + } + if (fillCandidateMc) { + rowCandidateMc( + flagMc, + origin); + } + } + + template + void processCandidates(CollType const& collisions, + Partition& candidates, + CandCharmType const&, + TracksWPid const&, + aod::BCs const&) + { + // Fill collision properties + if constexpr (isMc) { + if (confDerData.fillMcRCollId) { + rowsCommon.matchedCollisions.clear(); + } + } + auto sizeTableColl = collisions.size(); + rowsCommon.reserveTablesColl(sizeTableColl); + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candidatesThisColl = candidates->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); // FIXME + auto sizeTableCand = candidatesThisColl.size(); + LOGF(debug, "Rec. collision %d has %d candidates", thisCollId, sizeTableCand); + // Skip collisions without HF candidates (and without HF particles in matched MC collisions if saving indices of reconstructed collisions matched to MC collisions) + bool mcCollisionHasMcParticles{false}; + if constexpr (isMc) { + mcCollisionHasMcParticles = confDerData.fillMcRCollId && collision.has_mcCollision() && rowsCommon.hasMcParticles[collision.mcCollisionId()]; + LOGF(debug, "Rec. collision %d has MC collision %d with MC particles? %s", thisCollId, collision.mcCollisionId(), mcCollisionHasMcParticles ? "yes" : "no"); + } + if (sizeTableCand == 0 && (!confDerData.fillMcRCollId || !mcCollisionHasMcParticles)) { + LOGF(debug, "Skipping rec. collision %d", thisCollId); + continue; + } + LOGF(debug, "Filling rec. collision %d at derived index %d", thisCollId, rowsCommon.rowCollBase.lastIndex() + 1); + rowsCommon.fillTablesCollision(collision); + + // Fill candidate properties + rowsCommon.reserveTablesCandidates(sizeTableCand); + reserveTable(rowCandidatePar, fillCandidatePar, sizeTableCand); + reserveTable(rowCandidateParDplus, fillCandidateParDplus, sizeTableCand); + reserveTable(rowCandidateParE, fillCandidateParE, sizeTableCand); + reserveTable(rowCandidateSel, fillCandidateSel, sizeTableCand); + reserveTable(rowCandidateMl, fillCandidateMl, sizeTableCand); + reserveTable(rowCandidateMlDplus, fillCandidateMlDplus, sizeTableCand); + reserveTable(rowCandidateId, fillCandidateId, sizeTableCand); + if constexpr (isMc) { + reserveTable(rowCandidateMc, fillCandidateMc, sizeTableCand); + } + int8_t flagMcRec = 0, origin = 0; + for (const auto& candidate : candidatesThisColl) { + if constexpr (isMl) { + if (!TESTBIT(candidate.isSelB0ToDPi(), aod::SelectionStep::RecoMl)) { + continue; + } + } + if constexpr (isMc) { + flagMcRec = candidate.flagMcMatchRec(); + origin = candidate.originMcRec(); + if constexpr (onlyBkg) { + if (std::abs(flagMcRec) == DecayChannelMain::B0ToDminusPi) { + continue; + } + if (downSampleBkgFactor < 1.) { + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); + if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { + continue; + } + } + } + if constexpr (onlySig) { + if (std::abs(flagMcRec) != DecayChannelMain::B0ToDminusPi) { + continue; + } + } + } + auto prongCharm = candidate.template prong0_as(); + auto prongBachelor = candidate.template prong1_as(); + double ct = hfHelper.ctB0(candidate); + double y = hfHelper.yB0(candidate); + float massB0ToDPi = hfHelper.invMassB0ToDPi(candidate); + float mlScoreB0ToDPi{-1.f}; + std::vector mlScoresDplus; + std::copy(prongCharm.mlProbDplusToPiKPi().begin(), prongCharm.mlProbDplusToPiKPi().end(), std::back_inserter(mlScoresDplus)); + if constexpr (isMl) { + mlScoreB0ToDPi = candidate.mlProbB0ToDPi(); + } + fillTablesCandidate(candidate, prongCharm, prongBachelor, 0, massB0ToDPi, ct, y, flagMcRec, origin, mlScoreB0ToDPi, mlScoresDplus); + } + } + } + + void processData(CollisionsWCentMult const& collisions, + SelectedCandidates const&, + THfCandDaughtersMl const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesAll, candidatesDaughters, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorB0ToDPi, processData, "Process data", true); + + void processMcSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + THfCandDaughtersMl const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcSig, candidatesDaughters, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorB0ToDPi, processMcSig, "Process MC only for signals", false); + + void processMcBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + THfCandDaughtersMl const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcBkg, candidatesDaughters, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorB0ToDPi, processMcBkg, "Process MC only for background", false); + + void processMcAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + THfCandDaughtersMl const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcAll, candidatesDaughters, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorB0ToDPi, processMcAll, "Process MC", false); + + // ML versions + + void processDataMl(CollisionsWCentMult const& collisions, + SelectedCandidatesMl const&, + THfCandDaughtersMl const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesMlAll, candidatesDaughters, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorB0ToDPi, processDataMl, "Process data with ML", false); + + void processMcMlSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + THfCandDaughtersMl const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlSig, candidatesDaughters, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorB0ToDPi, processMcMlSig, "Process MC with ML only for signals", false); + + void processMcMlBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + THfCandDaughtersMl const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlBkg, candidatesDaughters, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorB0ToDPi, processMcMlBkg, "Process MC with ML only for background", false); + + void processMcMlAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + THfCandDaughtersMl const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlAll, candidatesDaughters, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorB0ToDPi, processMcMlAll, "Process MC with ML", false); + + void processMcGenOnly(TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles) + { + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorB0ToDPi, processMcGenOnly, "Process MC gen. only", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx b/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx index bfd7034ef11..ca79660d0bc 100644 --- a/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx +++ b/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx @@ -15,32 +15,46 @@ /// /// \author Vít Kučera , Inha University -#include -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" - -#include "PWGLF/DataModel/mcCentrality.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/DataModel/DerivedTables.h" #include "PWGHF/Utils/utilsDerivedData.h" #include "PWGHF/Utils/utilsPid.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::aod::pid_tpc_tof_utils; using namespace o2::analysis::hf_derived; +using namespace o2::hf_decay::hf_cand_beauty; /// Writes the full information in an output TTree struct HfDerivedDataCreatorBplusToD0Pi { @@ -91,11 +105,10 @@ struct HfDerivedDataCreatorBplusToD0Pi { using SelectedCandidatesMcMl = soa::Filtered>; using MatchedGenCandidatesMc = soa::Filtered>; using TypeMcCollisions = soa::Join; - using THfCandDaughters = aod::HfCand2ProngWPid; - using THfCandDaughtersMl = soa::Join; + using THfCandDaughtersMl = soa::Join; - Filter filterSelectCandidates = aod::hf_sel_candidate_bplus::isSelBplusToD0Pi >= 1; - Filter filterMcGenMatching = nabs(aod::hf_cand_bplus::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_bplus::DecayType::BplusToD0Pi)); + Filter filterSelectCandidates = (aod::hf_sel_candidate_bplus::isSelBplusToD0Pi & static_cast(BIT(aod::SelectionStep::RecoMl - 1))) != 0; + Filter filterMcGenMatching = nabs(aod::hf_cand_bplus::flagMcMatchGen) == static_cast(DecayChannelMain::BplusToD0Pi); Preslice candidatesPerCollision = aod::hf_cand::collisionId; Preslice candidatesMcPerCollision = aod::hf_cand::collisionId; @@ -109,14 +122,14 @@ struct HfDerivedDataCreatorBplusToD0Pi { Partition candidatesMlAll = aod::hf_sel_candidate_bplus::isSelBplusToD0Pi >= 0; Partition candidatesMcMlAll = aod::hf_sel_candidate_bplus::isSelBplusToD0Pi >= 0; // partitions for signal and background - Partition candidatesMcSig = nabs(aod::hf_cand_bplus::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_bplus::DecayType::BplusToD0Pi)); - Partition candidatesMcBkg = nabs(aod::hf_cand_bplus::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_bplus::DecayType::BplusToD0Pi)); - Partition candidatesMcMlSig = nabs(aod::hf_cand_bplus::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_bplus::DecayType::BplusToD0Pi)); - Partition candidatesMcMlBkg = nabs(aod::hf_cand_bplus::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_bplus::DecayType::BplusToD0Pi)); + Partition candidatesMcSig = nabs(aod::hf_cand_bplus::flagMcMatchRec) == static_cast(DecayChannelMain::BplusToD0Pi); + Partition candidatesMcBkg = nabs(aod::hf_cand_bplus::flagMcMatchRec) != static_cast(DecayChannelMain::BplusToD0Pi); + Partition candidatesMcMlSig = nabs(aod::hf_cand_bplus::flagMcMatchRec) == static_cast(DecayChannelMain::BplusToD0Pi); + Partition candidatesMcMlBkg = nabs(aod::hf_cand_bplus::flagMcMatchRec) != static_cast(DecayChannelMain::BplusToD0Pi); void init(InitContext const&) { - std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll}; + std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll, doprocessMcGenOnly}; if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { LOGP(fatal, "Only one process function can be enabled at a time."); } @@ -273,11 +286,16 @@ struct HfDerivedDataCreatorBplusToD0Pi { } int8_t flagMcRec = 0, origin = 0; for (const auto& candidate : candidatesThisColl) { + if constexpr (isMl) { + if (!TESTBIT(candidate.isSelBplusToD0Pi(), aod::SelectionStep::RecoMl)) { + continue; + } + } if constexpr (isMc) { flagMcRec = candidate.flagMcMatchRec(); origin = candidate.originMcRec(); if constexpr (onlyBkg) { - if (TESTBIT(std::abs(flagMcRec), aod::hf_cand_bplus::DecayType::BplusToD0Pi)) { + if (std::abs(flagMcRec) == DecayChannelMain::BplusToD0Pi) { continue; } if (downSampleBkgFactor < 1.) { @@ -288,7 +306,7 @@ struct HfDerivedDataCreatorBplusToD0Pi { } } if constexpr (onlySig) { - if (!TESTBIT(std::abs(flagMcRec), aod::hf_cand_bplus::DecayType::BplusToD0Pi)) { + if (std::abs(flagMcRec) != DecayChannelMain::BplusToD0Pi) { continue; } } @@ -300,14 +318,14 @@ struct HfDerivedDataCreatorBplusToD0Pi { float massBplusToD0Pi = hfHelper.invMassBplusToD0Pi(candidate); float mlScoreBplusToD0Pi{-1.f}; std::vector mlScoresD0; - bool isD0 = prongBachelor.sign() < 0; // D0 or D0bar + bool isD0 = prongBachelor.sign() < 0; + if (isD0) { // is D0 + std::copy(prongCharm.mlProbD0().begin(), prongCharm.mlProbD0().end(), std::back_inserter(mlScoresD0)); + } else { // is D0bar + std::copy(prongCharm.mlProbD0bar().begin(), prongCharm.mlProbD0bar().end(), std::back_inserter(mlScoresD0)); + } if constexpr (isMl) { mlScoreBplusToD0Pi = candidate.mlProbBplusToD0Pi(); - if (isD0) { - std::copy(prongCharm.mlProbD0().begin(), prongCharm.mlProbD0().end(), std::back_inserter(mlScoresD0)); - } else { - std::copy(prongCharm.mlProbD0bar().begin(), prongCharm.mlProbD0bar().end(), std::back_inserter(mlScoresD0)); - } } // flag = 0 for D0 pi-, flag = 1 for D0bar pi+ fillTablesCandidate(candidate, prongCharm, prongBachelor, isD0 ? 0 : 1, massBplusToD0Pi, ct, y, flagMcRec, origin, mlScoreBplusToD0Pi, mlScoresD0); @@ -317,7 +335,7 @@ struct HfDerivedDataCreatorBplusToD0Pi { void processData(CollisionsWCentMult const& collisions, SelectedCandidates const&, - THfCandDaughters const& candidatesDaughters, + THfCandDaughtersMl const& candidatesDaughters, TracksWPid const& tracks, aod::BCs const& bcs) { @@ -329,7 +347,7 @@ struct HfDerivedDataCreatorBplusToD0Pi { SelectedCandidatesMc const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - THfCandDaughters const& candidatesDaughters, + THfCandDaughtersMl const& candidatesDaughters, TracksWPid const& tracks, aod::BCs const& bcs) { @@ -343,7 +361,7 @@ struct HfDerivedDataCreatorBplusToD0Pi { SelectedCandidatesMc const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - THfCandDaughters const& candidatesDaughters, + THfCandDaughtersMl const& candidatesDaughters, TracksWPid const& tracks, aod::BCs const& bcs) { @@ -357,7 +375,7 @@ struct HfDerivedDataCreatorBplusToD0Pi { SelectedCandidatesMc const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - THfCandDaughters const& candidatesDaughters, + THfCandDaughtersMl const& candidatesDaughters, TracksWPid const& tracks, aod::BCs const& bcs) { @@ -420,6 +438,13 @@ struct HfDerivedDataCreatorBplusToD0Pi { rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); } PROCESS_SWITCH(HfDerivedDataCreatorBplusToD0Pi, processMcMlAll, "Process MC with ML", false); + + void processMcGenOnly(TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles) + { + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorBplusToD0Pi, processMcGenOnly, "Process MC gen. only", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/derivedDataCreatorD0ToKPi.cxx b/PWGHF/TableProducer/derivedDataCreatorD0ToKPi.cxx index 92fdd9089b8..194b50eb2c0 100644 --- a/PWGHF/TableProducer/derivedDataCreatorD0ToKPi.cxx +++ b/PWGHF/TableProducer/derivedDataCreatorD0ToKPi.cxx @@ -15,26 +15,39 @@ /// /// \author Vít Kučera , Inha University -#include -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" - -#include "PWGLF/DataModel/mcCentrality.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/DataModel/DerivedTables.h" #include "PWGHF/Utils/utilsDerivedData.h" #include "PWGHF/Utils/utilsPid.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -93,7 +106,7 @@ struct HfDerivedDataCreatorD0ToKPi { using TypeMcCollisions = soa::Join; Filter filterSelectCandidates = aod::hf_sel_candidate_d0::isSelD0 >= 1 || aod::hf_sel_candidate_d0::isSelD0bar >= 1; - Filter filterMcGenMatching = nabs(aod::hf_cand_2prong::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); + Filter filterMcGenMatching = nabs(aod::hf_cand_2prong::flagMcMatchGen) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); Preslice candidatesPerCollision = aod::hf_cand::collisionId; Preslice candidatesKfPerCollision = aod::hf_cand::collisionId; @@ -115,19 +128,19 @@ struct HfDerivedDataCreatorD0ToKPi { Partition candidatesMcMlAll = aod::hf_sel_candidate_d0::isSelD0 >= 0; Partition candidatesMcKfMlAll = aod::hf_sel_candidate_d0::isSelD0 >= 0; // partitions for signal and background - Partition candidatesMcSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition candidatesMcBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition candidatesMcKfSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition candidatesMcKfBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition candidatesMcMlSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition candidatesMcMlBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition candidatesMcKfMlSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition candidatesMcKfMlBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); + Partition candidatesMcSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + Partition candidatesMcBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + Partition candidatesMcKfSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + Partition candidatesMcKfBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + Partition candidatesMcMlSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + Partition candidatesMcMlBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + Partition candidatesMcKfMlSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + Partition candidatesMcKfMlBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); void init(InitContext const&) { - std::array doprocess{doprocessDataWithDCAFitterN, doprocessDataWithKFParticle, doprocessMcWithDCAFitterSig, doprocessMcWithDCAFitterBkg, doprocessMcWithDCAFitterAll, doprocessMcWithKFParticleSig, doprocessMcWithKFParticleBkg, doprocessMcWithKFParticleAll, - doprocessDataWithDCAFitterNMl, doprocessDataWithKFParticleMl, doprocessMcWithDCAFitterMlSig, doprocessMcWithDCAFitterMlBkg, doprocessMcWithDCAFitterMlAll, doprocessMcWithKFParticleMlSig, doprocessMcWithKFParticleMlBkg, doprocessMcWithKFParticleMlAll}; + std::array doprocess{doprocessDataWithDCAFitterN, doprocessDataWithKFParticle, doprocessMcWithDCAFitterSig, doprocessMcWithDCAFitterBkg, doprocessMcWithDCAFitterAll, doprocessMcWithKFParticleSig, doprocessMcWithKFParticleBkg, doprocessMcWithKFParticleAll, + doprocessDataWithDCAFitterNMl, doprocessDataWithKFParticleMl, doprocessMcWithDCAFitterMlSig, doprocessMcWithDCAFitterMlBkg, doprocessMcWithDCAFitterMlAll, doprocessMcWithKFParticleMlSig, doprocessMcWithKFParticleMlBkg, doprocessMcWithKFParticleMlAll, doprocessMcGenOnly}; if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { LOGP(fatal, "Only one process function can be enabled at a time."); } @@ -272,7 +285,7 @@ struct HfDerivedDataCreatorD0ToKPi { flagMcRec = candidate.flagMcMatchRec(); origin = candidate.originMcRec(); if constexpr (onlyBkg) { - if (TESTBIT(std::abs(flagMcRec), aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if (std::abs(flagMcRec) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { continue; } if (downSampleBkgFactor < 1.) { @@ -283,7 +296,7 @@ struct HfDerivedDataCreatorD0ToKPi { } } if constexpr (onlySig) { - if (!TESTBIT(std::abs(flagMcRec), aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if (std::abs(flagMcRec) != o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { continue; } } @@ -516,6 +529,13 @@ struct HfDerivedDataCreatorD0ToKPi { rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); } PROCESS_SWITCH(HfDerivedDataCreatorD0ToKPi, processMcWithKFParticleMlAll, "Process MC with KFParticle and ML", false); + + void processMcGenOnly(TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles) + { + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorD0ToKPi, processMcGenOnly, "Process MC gen. only", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/derivedDataCreatorDplusToPiKPi.cxx b/PWGHF/TableProducer/derivedDataCreatorDplusToPiKPi.cxx new file mode 100644 index 00000000000..96d3ed0acf4 --- /dev/null +++ b/PWGHF/TableProducer/derivedDataCreatorDplusToPiKPi.cxx @@ -0,0 +1,406 @@ +// 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. + +/// \file derivedDataCreatorDplusToPiKPi.cxx +/// \brief Producer of derived tables of Dplus candidates, collisions and MC particles +/// \note Based on derivedDataCreatorLcToPKPi.cxx +/// +/// \author Vít Kučera , Inha University + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGHF/Utils/utilsDerivedData.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::analysis::hf_derived; + +/// Writes the full information in an output TTree +struct HfDerivedDataCreatorDplusToPiKPi { + HfProducesDerivedData< + o2::aod::HfDplusBases, + o2::aod::HfDplusCollBases, + o2::aod::HfDplusCollIds, + o2::aod::HfDplusMcCollBases, + o2::aod::HfDplusMcCollIds, + o2::aod::HfDplusMcRCollIds, + o2::aod::HfDplusPBases, + o2::aod::HfDplusPIds> + rowsCommon; + // Candidates + Produces rowCandidatePar; + Produces rowCandidateParE; + Produces rowCandidateSel; + Produces rowCandidateMl; + Produces rowCandidateId; + Produces rowCandidateMc; + + // Switches for filling tables + HfConfigurableDerivedData confDerData; + Configurable fillCandidatePar{"fillCandidatePar", true, "Fill candidate parameters"}; + Configurable fillCandidateParE{"fillCandidateParE", true, "Fill candidate extended parameters"}; + Configurable fillCandidateSel{"fillCandidateSel", true, "Fill candidate selection flags"}; + Configurable fillCandidateMl{"fillCandidateMl", true, "Fill candidate selection ML scores"}; + Configurable fillCandidateId{"fillCandidateId", true, "Fill original indices from the candidate table"}; + Configurable fillCandidateMc{"fillCandidateMc", true, "Fill candidate MC info"}; + // Parameters for production of training samples + Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + + HfHelper hfHelper; + SliceCache cache; + static constexpr double mass{o2::constants::physics::MassDPlus}; + + using CollisionsWCentMult = soa::Join; + using CollisionsWMcCentMult = soa::Join; + using TracksWPid = soa::Join; + using SelectedCandidates = soa::Filtered>; + using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMl = soa::Filtered>; + using SelectedCandidatesMcMl = soa::Filtered>; + using MatchedGenCandidatesMc = soa::Filtered>; + using TypeMcCollisions = soa::Join; + + Filter filterSelectCandidates = (aod::hf_sel_candidate_dplus::isSelDplusToPiKPi & static_cast(BIT(aod::SelectionStep::RecoMl - 1))) != 0; // select candidates which passed all cuts at least up to RecoMl - 1 + Filter filterMcGenMatching = nabs(aod::hf_cand_3prong::flagMcMatchGen) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi); + + Preslice candidatesPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMlPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcMlPerCollision = aod::hf_cand::collisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + + // trivial partitions for all candidates to allow "->sliceByCached" inside processCandidates + Partition candidatesAll = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= 0; + Partition candidatesMcAll = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= 0; + Partition candidatesMlAll = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= 0; + Partition candidatesMcMlAll = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= 0; + // partitions for signal and background + Partition candidatesMcSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi); + Partition candidatesMcBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi); + Partition candidatesMcMlSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi); + Partition candidatesMcMlBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi); + + void init(InitContext const&) + { + std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll, doprocessMcGenOnly}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "Only one process function can be enabled at a time."); + } + rowsCommon.init(confDerData); + } + + template + void fillTablesCandidate(const T& candidate, int candFlag, double invMass, + double ct, double y, int8_t flagMc, int8_t origin, int8_t swapping, int8_t flagDecayChan, const std::vector& mlScores) + { + rowsCommon.fillTablesCandidate(candidate, invMass, y); + if (fillCandidatePar) { + rowCandidatePar( + candidate.chi2PCA(), + candidate.nProngsContributorsPV(), + candidate.cpa(), + candidate.cpaXY(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.ptProng2(), + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameter2(), + candidate.impactParameterNormalised0(), + candidate.impactParameterNormalised1(), + candidate.impactParameterNormalised2(), + candidate.nSigTpcPi0(), + candidate.nSigTofPi0(), + candidate.tpcTofNSigmaPi0(), + candidate.nSigTpcKa1(), + candidate.nSigTofKa1(), + candidate.tpcTofNSigmaKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTofPi2(), + candidate.tpcTofNSigmaPi2()); + } + if (fillCandidateParE) { + rowCandidateParE( + candidate.xSecondaryVertex(), + candidate.ySecondaryVertex(), + candidate.zSecondaryVertex(), + candidate.errorDecayLength(), + candidate.errorDecayLengthXY(), + candidate.rSecondaryVertex(), + RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()), + RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()), + RecoDecay::p(candidate.pxProng2(), candidate.pyProng2(), candidate.pzProng2()), + candidate.pxProng0(), + candidate.pyProng0(), + candidate.pzProng0(), + candidate.pxProng1(), + candidate.pyProng1(), + candidate.pzProng1(), + candidate.pxProng2(), + candidate.pyProng2(), + candidate.pzProng2(), + candidate.errorImpactParameter0(), + candidate.errorImpactParameter1(), + candidate.errorImpactParameter2(), + ct); + } + if (fillCandidateSel) { + rowCandidateSel( + BIT(candFlag)); + } + if (fillCandidateMl) { + rowCandidateMl( + mlScores); + } + if (fillCandidateId) { + rowCandidateId( + candidate.collisionId(), + candidate.prong0Id(), + candidate.prong1Id(), + candidate.prong2Id()); + } + if (fillCandidateMc) { + rowCandidateMc( + flagMc, + origin, + swapping, + flagDecayChan); + } + } + + template + void processCandidates(CollType const& collisions, + Partition& candidates, + TracksWPid const&, + aod::BCs const&) + { + // Fill collision properties + if constexpr (isMc) { + if (confDerData.fillMcRCollId) { + rowsCommon.matchedCollisions.clear(); + } + } + auto sizeTableColl = collisions.size(); + rowsCommon.reserveTablesColl(sizeTableColl); + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candidatesThisColl = candidates->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); // FIXME + auto sizeTableCand = candidatesThisColl.size(); + LOGF(debug, "Rec. collision %d has %d candidates", thisCollId, sizeTableCand); + // Skip collisions without HF candidates (and without HF particles in matched MC collisions if saving indices of reconstructed collisions matched to MC collisions) + bool mcCollisionHasMcParticles{false}; + if constexpr (isMc) { + mcCollisionHasMcParticles = confDerData.fillMcRCollId && collision.has_mcCollision() && rowsCommon.hasMcParticles[collision.mcCollisionId()]; + LOGF(debug, "Rec. collision %d has MC collision %d with MC particles? %s", thisCollId, collision.mcCollisionId(), mcCollisionHasMcParticles ? "yes" : "no"); + } + if (sizeTableCand == 0 && (!confDerData.fillMcRCollId || !mcCollisionHasMcParticles)) { + LOGF(debug, "Skipping rec. collision %d", thisCollId); + continue; + } + LOGF(debug, "Filling rec. collision %d at derived index %d", thisCollId, rowsCommon.rowCollBase.lastIndex() + 1); + rowsCommon.fillTablesCollision(collision); + + // Fill candidate properties + rowsCommon.reserveTablesCandidates(sizeTableCand); + reserveTable(rowCandidatePar, fillCandidatePar, sizeTableCand); + reserveTable(rowCandidateParE, fillCandidateParE, sizeTableCand); + reserveTable(rowCandidateSel, fillCandidateSel, sizeTableCand); + reserveTable(rowCandidateMl, fillCandidateMl, sizeTableCand); + reserveTable(rowCandidateId, fillCandidateId, sizeTableCand); + if constexpr (isMc) { + reserveTable(rowCandidateMc, fillCandidateMc, sizeTableCand); + } + int8_t flagMcRec = 0, origin = 0, swapping = 0, flagDecayChanRec = 0; + for (const auto& candidate : candidatesThisColl) { + if constexpr (isMl) { + if (!TESTBIT(candidate.isSelDplusToPiKPi(), aod::SelectionStep::RecoMl)) { + continue; + } + } + if constexpr (isMc) { + flagMcRec = candidate.flagMcMatchRec(); + origin = candidate.originMcRec(); + swapping = candidate.isCandidateSwapped(); + flagDecayChanRec = candidate.flagMcDecayChanRec(); + if constexpr (onlyBkg) { + if (std::abs(flagMcRec) == hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { + continue; + } + if (downSampleBkgFactor < 1.) { + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); + if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { + continue; + } + } + } + if constexpr (onlySig) { + if (std::abs(flagMcRec) != hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { + continue; + } + } + } + double ct = hfHelper.ctDplus(candidate); + double y = hfHelper.yDplus(candidate); + float massDplusToPiKPi = hfHelper.invMassDplusToPiKPi(candidate); + std::vector mlScoresDplusToPiKPi; + if constexpr (isMl) { + std::copy(candidate.mlProbDplusToPiKPi().begin(), candidate.mlProbDplusToPiKPi().end(), std::back_inserter(mlScoresDplusToPiKPi)); + } + fillTablesCandidate(candidate, 0, massDplusToPiKPi, ct, y, flagMcRec, origin, swapping, flagDecayChanRec, mlScoresDplusToPiKPi); + } + } + } + + void processData(CollisionsWCentMult const& collisions, + SelectedCandidates const&, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesAll, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorDplusToPiKPi, processData, "Process data", true); + + void processMcSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcSig, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDplusToPiKPi, processMcSig, "Process MC only for signals", false); + + void processMcBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcBkg, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDplusToPiKPi, processMcBkg, "Process MC only for background", false); + + void processMcAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcAll, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDplusToPiKPi, processMcAll, "Process MC", false); + + // ML versions + + void processDataMl(CollisionsWCentMult const& collisions, + SelectedCandidatesMl const&, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesMlAll, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorDplusToPiKPi, processDataMl, "Process data with ML", false); + + void processMcMlSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlSig, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDplusToPiKPi, processMcMlSig, "Process MC with ML only for signals", false); + + void processMcMlBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlBkg, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDplusToPiKPi, processMcMlBkg, "Process MC with ML only for background", false); + + void processMcMlAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlAll, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDplusToPiKPi, processMcMlAll, "Process MC with ML", false); + + void processMcGenOnly(TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles) + { + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDplusToPiKPi, processMcGenOnly, "Process MC gen. only", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/TableProducer/derivedDataCreatorDsToKKPi.cxx b/PWGHF/TableProducer/derivedDataCreatorDsToKKPi.cxx new file mode 100644 index 00000000000..d63294ff14d --- /dev/null +++ b/PWGHF/TableProducer/derivedDataCreatorDsToKKPi.cxx @@ -0,0 +1,412 @@ +// 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. + +/// \file derivedDataCreatorDsToKKPi.cxx +/// \brief Producer of derived tables of Ds candidates, collisions and MC particles +/// \note Based on derivedDataCreatorDplusToPiKPi.cxx +/// +/// \author Vít Kučera , Inha University + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGHF/Utils/utilsDerivedData.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::analysis::hf_derived; + +/// Writes the full information in an output TTree +struct HfDerivedDataCreatorDsToKKPi { + HfProducesDerivedData< + o2::aod::HfDsBases, + o2::aod::HfDsCollBases, + o2::aod::HfDsCollIds, + o2::aod::HfDsMcCollBases, + o2::aod::HfDsMcCollIds, + o2::aod::HfDsMcRCollIds, + o2::aod::HfDsPBases, + o2::aod::HfDsPIds> + rowsCommon; + // Candidates + Produces rowCandidatePar; + Produces rowCandidateParE; + Produces rowCandidateSel; + Produces rowCandidateMl; + Produces rowCandidateId; + Produces rowCandidateMc; + + // Switches for filling tables + HfConfigurableDerivedData confDerData; + Configurable fillCandidatePar{"fillCandidatePar", true, "Fill candidate parameters"}; + Configurable fillCandidateParE{"fillCandidateParE", true, "Fill candidate extended parameters"}; + Configurable fillCandidateSel{"fillCandidateSel", true, "Fill candidate selection flags"}; + Configurable fillCandidateMl{"fillCandidateMl", true, "Fill candidate selection ML scores"}; + Configurable fillCandidateId{"fillCandidateId", true, "Fill original indices from the candidate table"}; + Configurable fillCandidateMc{"fillCandidateMc", true, "Fill candidate MC info"}; + // Parameters for production of training samples + Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + + HfHelper hfHelper; + SliceCache cache; + static constexpr double Mass{o2::constants::physics::MassDS}; + + using CollisionsWCentMult = soa::Join; + using CollisionsWMcCentMult = soa::Join; + using TracksWPid = soa::Join; + using SelectedCandidates = soa::Filtered>; + using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMl = soa::Filtered>; + using SelectedCandidatesMcMl = soa::Filtered>; + using MatchedGenCandidatesMc = soa::Filtered>; + using TypeMcCollisions = soa::Join; + + Filter filterSelectCandidates = (aod::hf_sel_candidate_ds::isSelDsToKKPi & static_cast(BIT(aod::SelectionStep::RecoMl - 1))) != 0; // select candidates which passed all cuts at least up to RecoMl - 1 + Filter filterMcGenMatching = nabs(aod::hf_cand_3prong::flagMcMatchGen) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK); + + Preslice candidatesPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMlPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcMlPerCollision = aod::hf_cand::collisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + + // trivial partitions for all candidates to allow "->sliceByCached" inside processCandidates + Partition candidatesAll = aod::hf_sel_candidate_ds::isSelDsToKKPi >= 0; + Partition candidatesMcAll = aod::hf_sel_candidate_ds::isSelDsToKKPi >= 0; + Partition candidatesMlAll = aod::hf_sel_candidate_ds::isSelDsToKKPi >= 0; + Partition candidatesMcMlAll = aod::hf_sel_candidate_ds::isSelDsToKKPi >= 0; + // partitions for signal and background + Partition candidatesMcSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK); + Partition candidatesMcBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK); + Partition candidatesMcMlSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK); + Partition candidatesMcMlBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK); + + void init(InitContext const&) + { + std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll, doprocessMcGenOnly}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "Only one process function can be enabled at a time."); + } + rowsCommon.init(confDerData); + } + + template + void fillTablesCandidate(const T& candidate, int candFlag, double invMass, + double ct, double y, int8_t flagMc, int8_t origin, int8_t swapping, int8_t flagDecayChan, const std::vector& mlScores) + { + rowsCommon.fillTablesCandidate(candidate, invMass, y); + if (fillCandidatePar) { + rowCandidatePar( + candidate.chi2PCA(), + candidate.nProngsContributorsPV(), + candidate.cpa(), + candidate.cpaXY(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.ptProng2(), + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameter2(), + candidate.impactParameterNormalised0(), + candidate.impactParameterNormalised1(), + candidate.impactParameterNormalised2(), + candidate.nSigTpcPi0(), + candidate.nSigTpcKa0(), + candidate.nSigTofPi0(), + candidate.nSigTofKa0(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaKa0(), + candidate.nSigTpcKa1(), + candidate.nSigTofKa1(), + candidate.tpcTofNSigmaKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcKa2(), + candidate.nSigTofPi2(), + candidate.nSigTofKa2(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaKa2()); + } + if (fillCandidateParE) { + rowCandidateParE( + candidate.xSecondaryVertex(), + candidate.ySecondaryVertex(), + candidate.zSecondaryVertex(), + candidate.errorDecayLength(), + candidate.errorDecayLengthXY(), + candidate.rSecondaryVertex(), + RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()), + RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()), + RecoDecay::p(candidate.pxProng2(), candidate.pyProng2(), candidate.pzProng2()), + candidate.pxProng0(), + candidate.pyProng0(), + candidate.pzProng0(), + candidate.pxProng1(), + candidate.pyProng1(), + candidate.pzProng1(), + candidate.pxProng2(), + candidate.pyProng2(), + candidate.pzProng2(), + candidate.errorImpactParameter0(), + candidate.errorImpactParameter1(), + candidate.errorImpactParameter2(), + ct); + } + if (fillCandidateSel) { + rowCandidateSel( + BIT(candFlag)); + } + if (fillCandidateMl) { + rowCandidateMl( + mlScores); + } + if (fillCandidateId) { + rowCandidateId( + candidate.collisionId(), + candidate.prong0Id(), + candidate.prong1Id(), + candidate.prong2Id()); + } + if (fillCandidateMc) { + rowCandidateMc( + flagMc, + origin, + swapping, + flagDecayChan); + } + } + + template + void processCandidates(CollType const& collisions, + Partition& candidates, + TracksWPid const&, + aod::BCs const&) + { + // Fill collision properties + if constexpr (isMc) { + if (confDerData.fillMcRCollId) { + rowsCommon.matchedCollisions.clear(); + } + } + auto sizeTableColl = collisions.size(); + rowsCommon.reserveTablesColl(sizeTableColl); + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candidatesThisColl = candidates->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); // FIXME + auto sizeTableCand = candidatesThisColl.size(); + LOGF(debug, "Rec. collision %d has %d candidates", thisCollId, sizeTableCand); + // Skip collisions without HF candidates (and without HF particles in matched MC collisions if saving indices of reconstructed collisions matched to MC collisions) + bool mcCollisionHasMcParticles{false}; + if constexpr (isMc) { + mcCollisionHasMcParticles = confDerData.fillMcRCollId && collision.has_mcCollision() && rowsCommon.hasMcParticles[collision.mcCollisionId()]; + LOGF(debug, "Rec. collision %d has MC collision %d with MC particles? %s", thisCollId, collision.mcCollisionId(), mcCollisionHasMcParticles ? "yes" : "no"); + } + if (sizeTableCand == 0 && (!confDerData.fillMcRCollId || !mcCollisionHasMcParticles)) { + LOGF(debug, "Skipping rec. collision %d", thisCollId); + continue; + } + LOGF(debug, "Filling rec. collision %d at derived index %d", thisCollId, rowsCommon.rowCollBase.lastIndex() + 1); + rowsCommon.fillTablesCollision(collision); + + // Fill candidate properties + rowsCommon.reserveTablesCandidates(sizeTableCand); + reserveTable(rowCandidatePar, fillCandidatePar, sizeTableCand); + reserveTable(rowCandidateParE, fillCandidateParE, sizeTableCand); + reserveTable(rowCandidateSel, fillCandidateSel, sizeTableCand); + reserveTable(rowCandidateMl, fillCandidateMl, sizeTableCand); + reserveTable(rowCandidateId, fillCandidateId, sizeTableCand); + if constexpr (isMc) { + reserveTable(rowCandidateMc, fillCandidateMc, sizeTableCand); + } + int8_t flagMcRec = 0, origin = 0, swapping = 0, flagDecayChanRec = 0; + for (const auto& candidate : candidatesThisColl) { + if constexpr (isMl) { + if (!TESTBIT(candidate.isSelDsToKKPi(), aod::SelectionStep::RecoMl)) { + continue; + } + } + if constexpr (isMc) { + flagMcRec = candidate.flagMcMatchRec(); + origin = candidate.originMcRec(); + swapping = candidate.isCandidateSwapped(); + flagDecayChanRec = candidate.flagMcDecayChanRec(); + if constexpr (onlyBkg) { + if (std::abs(flagMcRec) == hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) { + continue; + } + if (downSampleBkgFactor < 1.) { + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); + if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { + continue; + } + } + } + if constexpr (onlySig) { + if (std::abs(flagMcRec) != hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) { + continue; + } + } + } + double ct = hfHelper.ctDs(candidate); + double y = hfHelper.yDs(candidate); + float massDsToKKPi = hfHelper.invMassDsToKKPi(candidate); + std::vector mlScoresDsToKKPi; + if constexpr (isMl) { + std::copy(candidate.mlProbDsToKKPi().begin(), candidate.mlProbDsToKKPi().end(), std::back_inserter(mlScoresDsToKKPi)); + } + fillTablesCandidate(candidate, 0, massDsToKKPi, ct, y, flagMcRec, origin, swapping, flagDecayChanRec, mlScoresDsToKKPi); + } + } + } + + void processData(CollisionsWCentMult const& collisions, + SelectedCandidates const&, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesAll, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorDsToKKPi, processData, "Process data", true); + + void processMcSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcSig, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDsToKKPi, processMcSig, "Process MC only for signals", false); + + void processMcBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcBkg, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDsToKKPi, processMcBkg, "Process MC only for background", false); + + void processMcAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcAll, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDsToKKPi, processMcAll, "Process MC", false); + + // ML versions + + void processDataMl(CollisionsWCentMult const& collisions, + SelectedCandidatesMl const&, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesMlAll, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorDsToKKPi, processDataMl, "Process data with ML", false); + + void processMcMlSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlSig, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDsToKKPi, processMcMlSig, "Process MC with ML only for signals", false); + + void processMcMlBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlBkg, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDsToKKPi, processMcMlBkg, "Process MC with ML only for background", false); + + void processMcMlAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlAll, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDsToKKPi, processMcMlAll, "Process MC with ML", false); + + void processMcGenOnly(TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles) + { + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDsToKKPi, processMcGenOnly, "Process MC gen. only", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/TableProducer/derivedDataCreatorDstarToD0Pi.cxx b/PWGHF/TableProducer/derivedDataCreatorDstarToD0Pi.cxx new file mode 100644 index 00000000000..f1b14a5769f --- /dev/null +++ b/PWGHF/TableProducer/derivedDataCreatorDstarToD0Pi.cxx @@ -0,0 +1,415 @@ +// 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. + +/// \file derivedDataCreatorDstarToD0Pi.cxx +/// \brief Producer of derived tables of D*+ candidates, collisions and MC particles +/// \note Based on derivedDataCreatorLcToPKPi.cxx +/// +/// \author Mingze Li , CCNU + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGHF/Utils/utilsDerivedData.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::analysis::hf_derived; + +/// Writes the full information in an output TTree +struct HfDerivedDataCreatorDstarToD0Pi { + HfProducesDerivedData< + o2::aod::HfDstarBases, + o2::aod::HfDstarCollBases, + o2::aod::HfDstarCollIds, + o2::aod::HfDstarMcCollBases, + o2::aod::HfDstarMcCollIds, + o2::aod::HfDstarMcRCollIds, + o2::aod::HfDstarPBases, + o2::aod::HfDstarPIds> + rowsCommon; + // Candidates + Produces rowCandidatePar; + Produces rowCandidateParD0; + Produces rowCandidateSel; + Produces rowCandidateMl; + Produces rowCandidateId; + Produces rowCandidateMc; + + // Switches for filling tables + HfConfigurableDerivedData confDerData; + Configurable fillCandidatePar{"fillCandidatePar", true, "Fill candidate parameters"}; + Configurable fillCandidateParD0{"fillCandidateParD0", true, "Fill charm daughter parameters"}; + Configurable fillCandidateSel{"fillCandidateSel", true, "Fill candidate selection flags"}; + Configurable fillCandidateMl{"fillCandidateMl", true, "Fill candidate selection ML scores"}; + Configurable fillCandidateId{"fillCandidateId", true, "Fill original indices from the candidate table"}; + Configurable fillCandidateMc{"fillCandidateMc", true, "Fill candidate MC info"}; + // Parameters for production of training samples + Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + + SliceCache cache; + static constexpr double Mass{o2::constants::physics::MassDStar}; + + using CollisionsWCentMult = soa::Join; + using CollisionsWMcCentMult = soa::Join; + using TracksWPid = soa::Join; + using SelectedCandidates = soa::Filtered>; + using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMl = soa::Filtered>; + using SelectedCandidatesMcMl = soa::Filtered>; + using MatchedGenCandidatesMc = soa::Filtered>; + using TypeMcCollisions = soa::Join; + + Filter filterSelectCandidates = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == true; + Filter filterMcGenMatching = nabs(aod::hf_cand_dstar::flagMcMatchGen) == static_cast(hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi); + + Preslice candidatesPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMlPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcMlPerCollision = aod::hf_cand::collisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + + // trivial partitions for all candidates to allow "->sliceByCached" inside processCandidates + Partition candidatesAll = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == true; + Partition candidatesMcAll = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == true; + Partition candidatesMlAll = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == true; + Partition candidatesMcMlAll = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == true; + // partitions for signal and background + Partition candidatesMcSig = nabs(aod::hf_cand_dstar::flagMcMatchRec) == static_cast(hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi); + Partition candidatesMcBkg = nabs(aod::hf_cand_dstar::flagMcMatchRec) != static_cast(hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi); + Partition candidatesMcMlSig = nabs(aod::hf_cand_dstar::flagMcMatchRec) == static_cast(hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi); + Partition candidatesMcMlBkg = nabs(aod::hf_cand_dstar::flagMcMatchRec) != static_cast(hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi); + + void init(InitContext const&) + { + std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll, doprocessMcGenOnly}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "Only one process function can be enabled at a time."); + } + rowsCommon.init(confDerData); + } + + template + void fillTablesCandidate(const T& candidate, const U& prong0, const U& prong1, const U& prongSoftPi, int candFlag, double invMass, double invMassD0, + double y, int8_t flagMc, int8_t flagMcD0, int8_t origin, int8_t nTracksDecayed, double ptBhad, int pdgBhad, const std::vector& mlScores) + { + rowsCommon.fillTablesCandidate(candidate, invMass, y); + if (fillCandidatePar) { + rowCandidatePar( + candidate.pxD0(), + candidate.pyD0(), + candidate.pzD0(), + candidate.pxSoftPi(), + candidate.pySoftPi(), + candidate.pzSoftPi(), + candidate.signSoftPi(), + candidate.impParamSoftPi(), + candidate.normalisedImpParamSoftPi(), + prongSoftPi.tpcNSigmaPi(), + prongSoftPi.tofNSigmaPi(), + prongSoftPi.tpcTofNSigmaPi()); + } + if (fillCandidateParD0) { + rowCandidateParD0( + candidate.chi2PCAD0(), + candidate.cpaD0(), + candidate.cpaXYD0(), + candidate.decayLengthD0(), + candidate.decayLengthXYD0(), + candidate.decayLengthNormalisedD0(), + candidate.decayLengthXYNormalisedD0(), + candidate.pxProng0(), + candidate.pyProng0(), + candidate.pzProng0(), + candidate.pxProng1(), + candidate.pyProng1(), + candidate.pzProng1(), + invMassD0, + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameterNormalised0(), + candidate.impactParameterNormalised1(), + prong0.tpcNSigmaPi(), + prong0.tofNSigmaPi(), + prong0.tpcTofNSigmaPi(), + prong0.tpcNSigmaKa(), + prong0.tofNSigmaKa(), + prong0.tpcTofNSigmaKa(), + prong1.tpcNSigmaPi(), + prong1.tofNSigmaPi(), + prong1.tpcTofNSigmaPi(), + prong1.tpcNSigmaKa(), + prong1.tofNSigmaKa(), + prong1.tpcTofNSigmaKa()); + } + if (fillCandidateSel) { + rowCandidateSel( + BIT(candFlag)); + } + if (fillCandidateMl) { + rowCandidateMl( + mlScores); + } + if (fillCandidateId) { + rowCandidateId( + candidate.collisionId(), + candidate.prong0Id(), + candidate.prong1Id(), + candidate.prongPiId()); + } + if (fillCandidateMc) { + rowCandidateMc( + flagMc, + flagMcD0, + origin, + ptBhad, + pdgBhad, + nTracksDecayed); + } + } + + template + void processCandidates(CollType const& collisions, + Partition& candidates, + TracksWPid const&, + aod::BCs const&) + { + // Fill collision properties + if constexpr (isMc) { + if (confDerData.fillMcRCollId) { + rowsCommon.matchedCollisions.clear(); + } + } + auto sizeTableColl = collisions.size(); + rowsCommon.reserveTablesColl(sizeTableColl); + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candidatesThisColl = candidates->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); // FIXME + auto sizeTableCand = candidatesThisColl.size(); + LOGF(debug, "Rec. collision %d has %d candidates", thisCollId, sizeTableCand); + // Skip collisions without HF candidates (and without HF particles in matched MC collisions if saving indices of reconstructed collisions matched to MC collisions) + bool mcCollisionHasMcParticles{false}; + if constexpr (isMc) { + mcCollisionHasMcParticles = confDerData.fillMcRCollId && collision.has_mcCollision() && rowsCommon.hasMcParticles[collision.mcCollisionId()]; + LOGF(debug, "Rec. collision %d has MC collision %d with MC particles? %s", thisCollId, collision.mcCollisionId(), mcCollisionHasMcParticles ? "yes" : "no"); + } + if (sizeTableCand == 0 && (!confDerData.fillMcRCollId || !mcCollisionHasMcParticles)) { + LOGF(debug, "Skipping rec. collision %d", thisCollId); + continue; + } + LOGF(debug, "Filling rec. collision %d at derived index %d", thisCollId, rowsCommon.rowCollBase.lastIndex() + 1); + rowsCommon.fillTablesCollision(collision); + + // Fill candidate properties + rowsCommon.reserveTablesCandidates(sizeTableCand); + reserveTable(rowCandidatePar, fillCandidatePar, sizeTableCand); + reserveTable(rowCandidateParD0, fillCandidateParD0, sizeTableCand); + reserveTable(rowCandidateSel, fillCandidateSel, sizeTableCand); + reserveTable(rowCandidateMl, fillCandidateMl, sizeTableCand); + reserveTable(rowCandidateId, fillCandidateId, sizeTableCand); + if constexpr (isMc) { + reserveTable(rowCandidateMc, fillCandidateMc, sizeTableCand); + } + int8_t flagMcRec = 0, flagMcRecD0 = 0, origin = 0, nTracksDecayed = 0; + double ptBhadMotherPart = 0; + int pdgBhadMotherPart = 0; + for (const auto& candidate : candidatesThisColl) { + if constexpr (isMl) { + if (!TESTBIT(candidate.isSelDstarToD0Pi(), aod::SelectionStep::RecoMl)) { + continue; + } + } + if constexpr (isMc) { + flagMcRec = candidate.flagMcMatchRec(); + flagMcRecD0 = candidate.flagMcMatchRecD0(); + origin = candidate.originMcRec(); + nTracksDecayed = candidate.nTracksDecayed(); + ptBhadMotherPart = candidate.ptBhadMotherPart(); + pdgBhadMotherPart = candidate.pdgBhadMotherPart(); + if constexpr (onlyBkg) { + if (std::abs(flagMcRec) == hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { + continue; + } + if (downSampleBkgFactor < 1.) { + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); + if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { + continue; + } + } + } + if constexpr (onlySig) { + if (std::abs(flagMcRec) != hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { + continue; + } + } + } + auto prong0 = candidate.template prong0_as(); + auto prong1 = candidate.template prong1_as(); + auto prongSoftPi = candidate.template prongPi_as(); + double y = candidate.y(o2::constants::physics::MassDStar); + int flagSign = -1; + double massDstar = 0, invMassD0 = 0; + std::vector mlScoresDstarToD0Pi; + if constexpr (isMl) { + std::copy(candidate.mlProbDstarToD0Pi().begin(), candidate.mlProbDstarToD0Pi().end(), std::back_inserter(mlScoresDstarToD0Pi)); + } + if (candidate.signSoftPi() > 0) { + massDstar = candidate.invMassDstar(); + invMassD0 = candidate.invMassD0(); + flagSign = 0; + } else { + massDstar = candidate.invMassAntiDstar(); + invMassD0 = candidate.invMassD0Bar(); + flagSign = 1; + } + fillTablesCandidate(candidate, prong0, prong1, prongSoftPi, flagSign, massDstar, invMassD0, y, flagMcRec, flagMcRecD0, origin, nTracksDecayed, ptBhadMotherPart, pdgBhadMotherPart, mlScoresDstarToD0Pi); + } + } + } + + void processData(CollisionsWCentMult const& collisions, + SelectedCandidates const&, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesAll, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processData, "Process data", true); + + void processMcSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcSig, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcSig, "Process MC only for signals", false); + + void processMcBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcBkg, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcBkg, "Process MC only for background", false); + + void processMcAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcAll, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcAll, "Process MC", false); + + // ML versions + + void processDataMl(CollisionsWCentMult const& collisions, + SelectedCandidatesMl const&, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesMlAll, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processDataMl, "Process data with ML", false); + + void processMcMlSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlSig, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcMlSig, "Process MC with ML only for signals", false); + + void processMcMlBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlBkg, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcMlBkg, "Process MC with ML only for background", false); + + void processMcMlAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlAll, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcMlAll, "Process MC with ML", false); + + void processMcGenOnly(TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles) + { + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorDstarToD0Pi, processMcGenOnly, "Process MC gen. only", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx b/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx index c574611228d..96835cdefe5 100644 --- a/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx +++ b/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx @@ -15,25 +15,38 @@ /// /// \author Vít Kučera , Inha University -#include -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGHF/Utils/utilsDerivedData.h" +#include "PWGLF/DataModel/mcCentrality.h" #include "Common/Core/RecoDecay.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/Multiplicity.h" -#include "PWGLF/DataModel/mcCentrality.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "PWGHF/Core/HfHelper.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/DataModel/DerivedTables.h" -#include "PWGHF/Utils/utilsDerivedData.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -74,20 +87,20 @@ struct HfDerivedDataCreatorLcToPKPi { HfHelper hfHelper; SliceCache cache; - static constexpr double mass{o2::constants::physics::MassLambdaCPlus}; + static constexpr double Mass{o2::constants::physics::MassLambdaCPlus}; using CollisionsWCentMult = soa::Join; using CollisionsWMcCentMult = soa::Join; using TracksWPid = soa::Join; - using SelectedCandidates = soa::Filtered>; - using SelectedCandidatesMc = soa::Filtered>; - using SelectedCandidatesMl = soa::Filtered>; - using SelectedCandidatesMcMl = soa::Filtered>; + using SelectedCandidates = soa::Filtered>; + using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMl = soa::Filtered>; + using SelectedCandidatesMcMl = soa::Filtered>; using MatchedGenCandidatesMc = soa::Filtered>; using TypeMcCollisions = soa::Join; Filter filterSelectCandidates = aod::hf_sel_candidate_lc::isSelLcToPKPi >= 1 || aod::hf_sel_candidate_lc::isSelLcToPiKP >= 1; - Filter filterMcGenMatching = nabs(aod::hf_cand_3prong::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_3prong::DecayType::LcToPKPi)); + Filter filterMcGenMatching = nabs(aod::hf_cand_3prong::flagMcMatchGen) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi); Preslice candidatesPerCollision = aod::hf_cand::collisionId; Preslice candidatesMcPerCollision = aod::hf_cand::collisionId; @@ -101,22 +114,22 @@ struct HfDerivedDataCreatorLcToPKPi { Partition candidatesMlAll = aod::hf_sel_candidate_lc::isSelLcToPKPi >= 0; Partition candidatesMcMlAll = aod::hf_sel_candidate_lc::isSelLcToPKPi >= 0; // partitions for signal and background - Partition candidatesMcSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::LcToPKPi)); - Partition candidatesMcBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_3prong::DecayType::LcToPKPi)); - Partition candidatesMcMlSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::LcToPKPi)); - Partition candidatesMcMlBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_3prong::DecayType::LcToPKPi)); + Partition candidatesMcSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi); + Partition candidatesMcBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi); + Partition candidatesMcMlSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi); + Partition candidatesMcMlBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi); void init(InitContext const&) { - std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll}; + std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll, doprocessMcGenOnly}; if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { LOGP(fatal, "Only one process function can be enabled at a time."); } rowsCommon.init(confDerData); } - template - void fillTablesCandidate(const T& candidate, const U& prong0, const U& prong1, const U& prong2, int candFlag, double invMass, + template + void fillTablesCandidate(const T& candidate, int candFlag, double invMass, double ct, double y, int8_t flagMc, int8_t origin, int8_t swapping, const std::vector& mlScores) { rowsCommon.fillTablesCandidate(candidate, invMass, y); @@ -139,21 +152,21 @@ struct HfDerivedDataCreatorLcToPKPi { candidate.impactParameterNormalised0(), candidate.impactParameterNormalised1(), candidate.impactParameterNormalised2(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaPr(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaPr(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaPr(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaKa(), - prong2.tpcNSigmaPi(), - prong2.tpcNSigmaPr(), - prong2.tofNSigmaPi(), - prong2.tofNSigmaPr(), - prong2.tpcTofNSigmaPi(), - prong2.tpcTofNSigmaPr()); + candidate.nSigTpcPi0(), + candidate.nSigTpcPr0(), + candidate.nSigTofPi0(), + candidate.nSigTofPr0(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaPr0(), + candidate.nSigTpcKa1(), + candidate.nSigTofKa1(), + candidate.tpcTofNSigmaKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcPr2(), + candidate.nSigTofPi2(), + candidate.nSigTofPr2(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaPr2()); } if (fillCandidateParE) { rowCandidateParE( @@ -252,7 +265,7 @@ struct HfDerivedDataCreatorLcToPKPi { origin = candidate.originMcRec(); swapping = candidate.isCandidateSwapped(); if constexpr (onlyBkg) { - if (TESTBIT(std::abs(flagMcRec), aod::hf_cand_3prong::DecayType::LcToPKPi)) { + if (std::abs(flagMcRec) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { continue; } if (downSampleBkgFactor < 1.) { @@ -263,14 +276,18 @@ struct HfDerivedDataCreatorLcToPKPi { } } if constexpr (onlySig) { - if (!TESTBIT(std::abs(flagMcRec), aod::hf_cand_3prong::DecayType::LcToPKPi)) { + if (std::abs(flagMcRec) != hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + continue; + } + } + } else { + if (downSampleBkgFactor < 1.) { + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); + if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } } } - auto prong0 = candidate.template prong0_as(); - auto prong1 = candidate.template prong1_as(); - auto prong2 = candidate.template prong2_as(); double ct = hfHelper.ctLc(candidate); double y = hfHelper.yLc(candidate); float massLcToPKPi = hfHelper.invMassLcToPKPi(candidate); @@ -281,10 +298,10 @@ struct HfDerivedDataCreatorLcToPKPi { std::copy(candidate.mlProbLcToPiKP().begin(), candidate.mlProbLcToPiKP().end(), std::back_inserter(mlScoresLcToPiKP)); } if (candidate.isSelLcToPKPi()) { - fillTablesCandidate(candidate, prong0, prong1, prong2, 0, massLcToPKPi, ct, y, flagMcRec, origin, swapping, mlScoresLcToPKPi); + fillTablesCandidate(candidate, 0, massLcToPKPi, ct, y, flagMcRec, origin, swapping, mlScoresLcToPKPi); } if (candidate.isSelLcToPiKP()) { - fillTablesCandidate(candidate, prong0, prong1, prong2, 1, massLcToPiKP, ct, y, flagMcRec, origin, swapping, mlScoresLcToPiKP); + fillTablesCandidate(candidate, 1, massLcToPiKP, ct, y, flagMcRec, origin, swapping, mlScoresLcToPiKP); } } } @@ -308,7 +325,7 @@ struct HfDerivedDataCreatorLcToPKPi { { rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); processCandidates(collisions, candidatesMcSig, tracks, bcs); - rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); } PROCESS_SWITCH(HfDerivedDataCreatorLcToPKPi, processMcSig, "Process MC only for signals", false); @@ -321,7 +338,7 @@ struct HfDerivedDataCreatorLcToPKPi { { rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); processCandidates(collisions, candidatesMcBkg, tracks, bcs); - rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); } PROCESS_SWITCH(HfDerivedDataCreatorLcToPKPi, processMcBkg, "Process MC only for background", false); @@ -334,7 +351,7 @@ struct HfDerivedDataCreatorLcToPKPi { { rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); processCandidates(collisions, candidatesMcAll, tracks, bcs); - rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); } PROCESS_SWITCH(HfDerivedDataCreatorLcToPKPi, processMcAll, "Process MC", false); @@ -358,7 +375,7 @@ struct HfDerivedDataCreatorLcToPKPi { { rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); processCandidates(collisions, candidatesMcMlSig, tracks, bcs); - rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); } PROCESS_SWITCH(HfDerivedDataCreatorLcToPKPi, processMcMlSig, "Process MC with ML only for signals", false); @@ -371,7 +388,7 @@ struct HfDerivedDataCreatorLcToPKPi { { rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); processCandidates(collisions, candidatesMcMlBkg, tracks, bcs); - rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); } PROCESS_SWITCH(HfDerivedDataCreatorLcToPKPi, processMcMlBkg, "Process MC with ML only for background", false); @@ -384,9 +401,16 @@ struct HfDerivedDataCreatorLcToPKPi { { rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); processCandidates(collisions, candidatesMcMlAll, tracks, bcs); - rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, mass); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); } PROCESS_SWITCH(HfDerivedDataCreatorLcToPKPi, processMcMlAll, "Process MC with ML", false); + + void processMcGenOnly(TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles) + { + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorLcToPKPi, processMcGenOnly, "Process MC gen. only", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/derivedDataCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/derivedDataCreatorXicToXiPiPi.cxx new file mode 100644 index 00000000000..a59636bc500 --- /dev/null +++ b/PWGHF/TableProducer/derivedDataCreatorXicToXiPiPi.cxx @@ -0,0 +1,409 @@ +// 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. + +/// \file derivedDataCreatorXicToXiPiPi.cxx +/// \brief Producer of derived tables of Ξc± → (Ξ∓ → (Λ → p π∓) π∓) π± π± candidates, collisions and MC particles +/// \note Based on derivedDataCreatorBplusToD0Pi.cxx +/// +/// \author Vít Kučera , Inha University + +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGHF/Utils/utilsDerivedData.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::pid_tpc_tof_utils; +using namespace o2::analysis::hf_derived; +using namespace o2::aod::hf_cand_xic_to_xi_pi_pi; + +/// Writes the full information in an output TTree +struct HfDerivedDataCreatorXicToXiPiPi { + HfProducesDerivedData< + o2::aod::HfXicToXiPiPiBases, + o2::aod::HfXicToXiPiPiCollBases, + o2::aod::HfXicToXiPiPiCollIds, + o2::aod::HfXicToXiPiPiMcCollBases, + o2::aod::HfXicToXiPiPiMcCollIds, + o2::aod::HfXicToXiPiPiMcRCollIds, + o2::aod::HfXicToXiPiPiPBases, + o2::aod::HfXicToXiPiPiPIds> + rowsCommon; + // Candidates + Produces rowCandidatePar; + Produces rowCandidateParE; + Produces rowCandidateSel; + Produces rowCandidateMl; + Produces rowCandidateId; + Produces rowCandidateMc; + + // Switches for filling tables + HfConfigurableDerivedData confDerData; + Configurable fillCandidatePar{"fillCandidatePar", true, "Fill candidate parameters"}; + Configurable fillCandidateParE{"fillCandidateParE", true, "Fill candidate extended parameters"}; + Configurable fillCandidateSel{"fillCandidateSel", true, "Fill candidate selection flags"}; + Configurable fillCandidateMl{"fillCandidateMl", true, "Fill candidate selection ML scores"}; + Configurable fillCandidateId{"fillCandidateId", true, "Fill original indices from the candidate table"}; + Configurable fillCandidateMc{"fillCandidateMc", true, "Fill candidate MC info"}; + // Parameters for production of training samples + Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + + HfHelper hfHelper; + SliceCache cache; + static constexpr double Mass{o2::constants::physics::MassXiCPlus}; + + using CollisionsWCentMult = soa::Join; + using CollisionsWMcCentMult = soa::Join; + using TracksWPid = soa::Join; + using SelectedCandidates = soa::Filtered>; + using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMl = soa::Filtered>; + using SelectedCandidatesMcMl = soa::Filtered>; + using MatchedGenCandidatesMc = soa::Filtered>; + using TypeMcCollisions = soa::Join; + using THfCandDaughtersMl = aod::Cascades; + + Filter filterSelectCandidates = (aod::hf_sel_candidate_xic::isSelXicToXiPiPi & static_cast(BIT(o2::aod::hf_sel_candidate_xic::XicToXiPiPiSelectionStep::RecoMl - 1))) != 0; + Filter filterMcGenMatching = aod::hf_cand_xic_to_xi_pi_pi::flagMcMatchGen != 0; + + Preslice candidatesPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMlPerCollision = aod::hf_cand::collisionId; + Preslice candidatesMcMlPerCollision = aod::hf_cand::collisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + + // trivial partitions for all candidates to allow "->sliceByCached" inside processCandidates + Partition candidatesAll = aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= 0; + Partition candidatesMcAll = aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= 0; + Partition candidatesMlAll = aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= 0; + Partition candidatesMcMlAll = aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= 0; + // partitions for signal and background + Partition candidatesMcSig = aod::hf_cand_xic_to_xi_pi_pi::flagMcMatchRec != 0; + Partition candidatesMcBkg = aod::hf_cand_xic_to_xi_pi_pi::flagMcMatchRec == 0; + Partition candidatesMcMlSig = aod::hf_cand_xic_to_xi_pi_pi::flagMcMatchRec != 0; + Partition candidatesMcMlBkg = aod::hf_cand_xic_to_xi_pi_pi::flagMcMatchRec == 0; + + void init(InitContext const&) + { + std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll, doprocessMcGenOnly}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "Only one process function can be enabled at a time."); + } + rowsCommon.init(confDerData); + } + + template + void fillTablesCandidate(const T& candidate, int candFlag, double invMass, + double ct, double y, int8_t flagMc, int8_t origin, const std::vector& mlScores) + { + rowsCommon.fillTablesCandidate(candidate, invMass, y); + if (fillCandidatePar) { + rowCandidatePar( + candidate.sign(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.ptProng2(), + candidate.invMassXi(), + candidate.invMassLambda(), + candidate.invMassXiPi0(), + candidate.invMassXiPi1(), + candidate.chi2PCA(), + ct, + candidate.decayLength(), + candidate.decayLengthNormalised(), + candidate.decayLengthXY(), + candidate.decayLengthXYNormalised(), + candidate.cpa(), + candidate.cpaXY(), + candidate.cpaXi(), + candidate.cpaXYXi(), + candidate.cpaLambda(), + candidate.cpaXYLambda(), + candidate.impactParameter0(), + candidate.impactParameterNormalised0(), + candidate.impactParameter1(), + candidate.impactParameterNormalised1(), + candidate.impactParameter2(), + candidate.impactParameterNormalised2(), + candidate.maxNormalisedDeltaIP()); + } + if (fillCandidateParE) { + rowCandidateParE( + candidate.cpaLambdaToXi(), + candidate.cpaXYLambdaToXi(), + candidate.pProng1(), + candidate.pProng2(), + candidate.pBachelorPi(), + candidate.pPiFromLambda(), + candidate.pPrFromLambda(), + candidate.dcaXiDaughters(), + candidate.dcaV0Daughters(), + candidate.dcaPosToPV(), + candidate.dcaNegToPV(), + candidate.dcaBachelorToPV(), + candidate.dcaXYCascToPV(), + candidate.dcaZCascToPV(), + candidate.nSigTpcPiFromXicPlus0(), + candidate.nSigTpcPiFromXicPlus1(), + candidate.nSigTpcBachelorPi(), + candidate.nSigTpcPiFromLambda(), + candidate.nSigTpcPrFromLambda(), + candidate.nSigTofPiFromXicPlus0(), + candidate.nSigTofPiFromXicPlus1(), + candidate.nSigTofBachelorPi(), + candidate.nSigTofPiFromLambda(), + candidate.nSigTofPrFromLambda()); + } + if (fillCandidateSel) { + rowCandidateSel( + BIT(candFlag)); + } + if (fillCandidateMl) { + rowCandidateMl( + mlScores); + } + if (fillCandidateId) { + rowCandidateId( + candidate.collisionId(), + candidate.pi0Id(), + candidate.pi1Id(), + candidate.bachelorId(), + candidate.posTrackId(), + candidate.negTrackId()); + } + if (fillCandidateMc) { + rowCandidateMc( + flagMc, + origin); + } + } + + template + void processCandidates(CollType const& collisions, + Partition& candidates, + TracksWPid const&, + aod::BCs const&) + { + // Fill collision properties + if constexpr (isMc) { + if (confDerData.fillMcRCollId) { + rowsCommon.matchedCollisions.clear(); + } + } + auto sizeTableColl = collisions.size(); + rowsCommon.reserveTablesColl(sizeTableColl); + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candidatesThisColl = candidates->sliceByCached(aod::hf_cand::collisionId, thisCollId, cache); // FIXME + auto sizeTableCand = candidatesThisColl.size(); + LOGF(debug, "Rec. collision %d has %d candidates", thisCollId, sizeTableCand); + // Skip collisions without HF candidates (and without HF particles in matched MC collisions if saving indices of reconstructed collisions matched to MC collisions) + bool mcCollisionHasMcParticles{false}; + if constexpr (isMc) { + mcCollisionHasMcParticles = confDerData.fillMcRCollId && collision.has_mcCollision() && rowsCommon.hasMcParticles[collision.mcCollisionId()]; + LOGF(debug, "Rec. collision %d has MC collision %d with MC particles? %s", thisCollId, collision.mcCollisionId(), mcCollisionHasMcParticles ? "yes" : "no"); + } + if (sizeTableCand == 0 && (!confDerData.fillMcRCollId || !mcCollisionHasMcParticles)) { + LOGF(debug, "Skipping rec. collision %d", thisCollId); + continue; + } + LOGF(debug, "Filling rec. collision %d at derived index %d", thisCollId, rowsCommon.rowCollBase.lastIndex() + 1); + rowsCommon.fillTablesCollision(collision); + + // Fill candidate properties + rowsCommon.reserveTablesCandidates(sizeTableCand); + reserveTable(rowCandidatePar, fillCandidatePar, sizeTableCand); + reserveTable(rowCandidateParE, fillCandidateParE, sizeTableCand); + reserveTable(rowCandidateSel, fillCandidateSel, sizeTableCand); + reserveTable(rowCandidateMl, fillCandidateMl, sizeTableCand); + reserveTable(rowCandidateId, fillCandidateId, sizeTableCand); + if constexpr (isMc) { + reserveTable(rowCandidateMc, fillCandidateMc, sizeTableCand); + } + int8_t flagMcRec = 0, origin = 0; + for (const auto& candidate : candidatesThisColl) { + if constexpr (isMl) { + if (!TESTBIT(candidate.isSelXicToXiPiPi(), o2::aod::hf_sel_candidate_xic::XicToXiPiPiSelectionStep::RecoMl)) { + continue; + } + } + if constexpr (isMc) { + flagMcRec = candidate.flagMcMatchRec(); + origin = candidate.originMcRec(); + if constexpr (onlyBkg) { + if (TESTBIT(std::abs(flagMcRec), DecayType::XicToXiPiPi)) { + continue; + } + if (downSampleBkgFactor < 1.) { + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); + if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { + continue; + } + } + } + if constexpr (onlySig) { + if (!TESTBIT(std::abs(flagMcRec), DecayType::XicToXiPiPi)) { + continue; + } + } + } + float massXicToXiPiPi = candidate.invMassXicPlus(); + double ct = hfHelper.ctXic(candidate); + double y = hfHelper.yXic(candidate); + std::vector mlScoresXicToXiPiPi; + if constexpr (isMl) { + std::copy(candidate.mlProbXicToXiPiPi().begin(), candidate.mlProbXicToXiPiPi().end(), std::back_inserter(mlScoresXicToXiPiPi)); + } + // FIXME: Remove candFlag? + fillTablesCandidate(candidate, 1, massXicToXiPiPi, ct, y, flagMcRec, origin, mlScoresXicToXiPiPi); + } + } + } + + void processData(CollisionsWCentMult const& collisions, + SelectedCandidates const&, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesAll, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorXicToXiPiPi, processData, "Process data", true); + + void processMcSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcSig, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorXicToXiPiPi, processMcSig, "Process MC only for signals", false); + + void processMcBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcBkg, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorXicToXiPiPi, processMcBkg, "Process MC only for background", false); + + void processMcAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcAll, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorXicToXiPiPi, processMcAll, "Process MC", false); + + // ML versions + + void processDataMl(CollisionsWCentMult const& collisions, + SelectedCandidatesMl const&, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesMlAll, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorXicToXiPiPi, processDataMl, "Process data with ML", false); + + void processMcMlSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlSig, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorXicToXiPiPi, processMcMlSig, "Process MC with ML only for signals", false); + + void processMcMlBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlBkg, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorXicToXiPiPi, processMcMlBkg, "Process MC with ML only for background", false); + + void processMcMlAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMcMl const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + rowsCommon.preProcessMcCollisions(mcCollisions, mcParticlesPerMcCollision, mcParticles); + processCandidates(collisions, candidatesMcMlAll, tracks, bcs); + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorXicToXiPiPi, processMcMlAll, "Process MC with ML", false); + + void processMcGenOnly(TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles) + { + rowsCommon.processMcParticles(mcCollisions, mcParticlesPerMcCollision, mcParticles, Mass); + } + PROCESS_SWITCH(HfDerivedDataCreatorXicToXiPiPi, processMcGenOnly, "Process MC gen. only", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/TableProducer/mcPidTof.cxx b/PWGHF/TableProducer/mcPidTof.cxx index 68429424b77..70e3d04f17e 100644 --- a/PWGHF/TableProducer/mcPidTof.cxx +++ b/PWGHF/TableProducer/mcPidTof.cxx @@ -16,39 +16,57 @@ /// It works only for MC and adds the possibility to apply postcalibrations for MC. /// -#include -#include -#include -#include -#include - -#include - -// O2 includes -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "ReconstructionDataFormats/Track.h" -#include "CCDB/BasicCCDBManager.h" -#include "TOFBase/EventTimeMaker.h" - -// O2Physics includes -#include "TableHelper.h" -#include "MetadataHelper.h" -#include "CollisionTypeHelper.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/CollisionTypeHelper.h" +#include "Common/Core/MetadataHelper.h" +#include "Common/Core/TableHelper.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/FT0Corrected.h" -#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseTOF.h" #include "Common/TableProducer/PID/pidTOFBase.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::pid; using namespace o2::framework::expressions; using namespace o2::track; -MetadataHelper metadataInfo; +o2::common::core::MetadataHelper metadataInfo; // Input data types using Trks = o2::soa::Join; @@ -82,14 +100,14 @@ struct TOFCalibConfig { } template - void getCfg(o2::framework::InitContext& initContext, const std::string name, VType& v, const std::string task) + void getCfg(o2::framework::InitContext& initContext, const std::string& name, VType& v, const std::string& task) { if (!getTaskOptionValue(initContext, task, name, v, false)) { LOG(fatal) << "Could not get " << name << " from " << task << " task"; } } - void inheritFromBaseTask(o2::framework::InitContext& initContext, const std::string task = "tof-signal") + void inheritFromBaseTask(o2::framework::InitContext& initContext, const std::string& task = "tof-signal") { mInitMode = 2; getCfg(initContext, "ccdb-url", mUrl, task); @@ -297,7 +315,7 @@ struct TOFCalibConfig { // Configurable options std::string mUrl; std::string mPathGrpLhcIf; - int64_t mTimestamp; + int64_t mTimestamp{0}; std::string mTimeShiftCCDBPathPos; std::string mTimeShiftCCDBPathNeg; std::string mTimeShiftCCDBPathPosMC; @@ -306,10 +324,10 @@ struct TOFCalibConfig { std::string mParametrizationPath; std::string mReconstructionPass; std::string mReconstructionPassDefault; - bool mFatalOnPassNotAvailable; - bool mEnableTimeDependentResponse; - int mCollisionSystem; - bool mAutoSetProcessFunctions; + bool mFatalOnPassNotAvailable{false}; + bool mEnableTimeDependentResponse{false}; + int mCollisionSystem{-1}; + bool mAutoSetProcessFunctions{false}; }; // Part 1 TOF signal definition @@ -395,7 +413,7 @@ struct tofSignal { if (enableTablepidTOFFlags) { tableFlags.reserve(tracks.size()); } - for (auto& trk : tracks) { + for (auto const& trk : tracks) { const float& sig = o2::pid::tof::TOFSignal::GetTOFSignal(trk); if (enableQaHistograms) { histos.fill(HIST("tofSignal"), sig); @@ -514,7 +532,7 @@ struct tofEventTime { Preslice perCollision = aod::track::collisionId; template using ResponseImplementationEvTime = o2::pid::tof::ExpTimes; - void process(TrksWtof& tracks, + void process(TrksWtof const& tracks, aod::FT0s const&, EvTimeCollisionsFT0 const&, aod::BCsWithTimestamps const& bcs) @@ -593,7 +611,7 @@ struct tofEventTime { if constexpr (removeTOFEvTimeBias) { evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, t0TOF[0], t0TOF[1], 2); } - if (t0TOF[1] < errDiamond && (maxEvTimeTOF <= 0 || abs(t0TOF[0]) < maxEvTimeTOF)) { + if (t0TOF[1] < errDiamond && (maxEvTimeTOF <= 0 || std::abs(t0TOF[0]) < maxEvTimeTOF)) { flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; weight = 1.f / (t0TOF[1] * t0TOF[1]); @@ -621,7 +639,7 @@ struct tofEventTime { } else { tableFlags(flags); } - tableEvTime(eventTime / sumOfWeights, sqrt(1. / sumOfWeights)); + tableEvTime(eventTime / sumOfWeights, std::sqrt(1. / sumOfWeights)); if (enableTableEvTimeTOFOnly) { tableEvTimeTOFOnly((uint8_t)filterForTOFEventTime(trk), t0TOF[0], t0TOF[1], evTimeMakerTOF.mEventTimeMultiplicity); } @@ -657,7 +675,7 @@ struct tofEventTime { evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, et, erret, 2); } uint8_t flags = 0; - if (erret < errDiamond && (maxEvTimeTOF <= 0.f || abs(et) < maxEvTimeTOF)) { + if (erret < errDiamond && (maxEvTimeTOF <= 0.f || std::abs(et) < maxEvTimeTOF)) { flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; } else { et = 0.f; @@ -737,6 +755,10 @@ struct mcPidTof { Configurable ccdbPath{"ccdbPath", "Users/f/fgrosa/RecalibmcPidTof/", "path for MC recalibration objects in CCDB"}; } mcRecalib; + // list of productions for which the postcalibrations must be turned off (FT0 digitisation fixed) + const std::vector prodNoPostCalib = {"LHC24h1c"}; + bool enableMcRecalib{false}; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; // Running variables @@ -793,6 +815,8 @@ struct mcPidTof { } hnSigmaFull[iSpecie] = histos.add(Form("nSigmaFull/%s", particleNames[iSpecie].c_str()), Form("N_{#sigma}^{TOF}(%s)", particleNames[iSpecie].c_str()), kTH2F, {pAxis, nSigmaAxis}); } + + enableMcRecalib = mcRecalib.enable; } // Reserves an empty table for the given particle ID with size of the given track table @@ -870,6 +894,10 @@ struct mcPidTof { std::map metadata; if (metadataInfo.isFullyDefined()) { metadata["RecoPassName"] = metadataInfo.get("AnchorPassName"); + if (std::find(prodNoPostCalib.begin(), prodNoPostCalib.end(), metadataInfo.get("LPMProductionTag")) != prodNoPostCalib.end()) { + enableMcRecalib = false; + LOGP(warn, "Nsigma postcalibrations turned off for {} (new MC productions have FT0 digitisation fixed)", metadataInfo.get("LPMProductionTag")); + } } else { LOGP(error, "Impossible to read metadata! Using default calibrations (2022 apass7)"); metadata["RecoPassName"] = ""; @@ -956,7 +984,7 @@ struct mcPidTof { continue; } - if (mcRecalib.enable) { + if (enableMcRecalib) { auto runNumber = trk.collision().bc_as().runNumber(); if (runNumber != currentRun) { // update postcalibration files @@ -970,7 +998,7 @@ struct mcPidTof { switch (pidId) { case idxPi: { nSigma = responsePi.GetSeparation(mRespParamsV3, trk); - if (mcRecalib.enable && trk.has_mcParticle()) { + if (enableMcRecalib && trk.has_mcParticle()) { if (std::abs(trk.mcParticle().pdgCode()) == kPiPlus) { // we rescale only true signal nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); } @@ -980,7 +1008,7 @@ struct mcPidTof { } case idxKa: { nSigma = responseKa.GetSeparation(mRespParamsV3, trk); - if (mcRecalib.enable && trk.has_mcParticle()) { + if (enableMcRecalib && trk.has_mcParticle()) { if (std::abs(trk.mcParticle().pdgCode()) == kKPlus) { // we rescale only true signal nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); } @@ -990,7 +1018,7 @@ struct mcPidTof { } case idxPr: { nSigma = responsePr.GetSeparation(mRespParamsV3, trk); - if (mcRecalib.enable && trk.has_mcParticle()) { + if (enableMcRecalib && trk.has_mcParticle()) { if (std::abs(trk.mcParticle().pdgCode()) == kProton) { // we rescale only true signal nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); } @@ -1012,7 +1040,7 @@ struct mcPidTof { case idxPi: { resolution = responsePi.GetExpectedSigma(mRespParamsV3, trk); nSigma = responsePi.GetSeparation(mRespParamsV3, trk); - if (mcRecalib.enable && trk.has_mcParticle()) { + if (enableMcRecalib && trk.has_mcParticle()) { if (std::abs(trk.mcParticle().pdgCode()) == kPiPlus) { // we rescale only true signal nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); } @@ -1023,7 +1051,7 @@ struct mcPidTof { case idxKa: { resolution = responseKa.GetExpectedSigma(mRespParamsV3, trk); nSigma = responseKa.GetSeparation(mRespParamsV3, trk, resolution); - if (mcRecalib.enable && trk.has_mcParticle()) { + if (enableMcRecalib && trk.has_mcParticle()) { if (std::abs(trk.mcParticle().pdgCode()) == kKPlus) { // we rescale only true signal nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); } @@ -1034,7 +1062,7 @@ struct mcPidTof { case idxPr: { resolution = responsePr.GetExpectedSigma(mRespParamsV3, trk); nSigma = responsePr.GetSeparation(mRespParamsV3, trk, resolution); - if (mcRecalib.enable && trk.has_mcParticle()) { + if (enableMcRecalib && trk.has_mcParticle()) { if (std::abs(trk.mcParticle().pdgCode()) == kProton) { // we rescale only true signal nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); } diff --git a/PWGHF/TableProducer/pidCreator.cxx b/PWGHF/TableProducer/pidCreator.cxx index 3444b1936a7..d4a236b5d72 100644 --- a/PWGHF/TableProducer/pidCreator.cxx +++ b/PWGHF/TableProducer/pidCreator.cxx @@ -14,13 +14,21 @@ /// /// \author Vít Kučera , Inha University -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "Common/Core/TableHelper.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include +#include +#include +#include +#include +#include +#include + +#include using namespace o2; using namespace o2::framework; @@ -37,8 +45,8 @@ struct HfPidCreator { Produces trackPidFullPr; Produces trackPidTinyPr; - static constexpr float defaultNSigmaTolerance = .1f; - static constexpr float defaultNSigma = -999.f + defaultNSigmaTolerance; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h + static constexpr float NSigmaToleranceDefault = .1f; + static constexpr float NSigmaDefault = -999.f + NSigmaToleranceDefault; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h /// Function to check whether the process function flag matches the need for filling the table /// \param initContext workflow context (argument of the init function) @@ -85,13 +93,13 @@ struct HfPidCreator { tpcNSigma *= aod::pidtpc_tiny::binning::bin_width; tofNSigma *= aod::pidtof_tiny::binning::bin_width; } - if ((tpcNSigma > defaultNSigma) && (tofNSigma > defaultNSigma)) { // TPC and TOF + if ((tpcNSigma > NSigmaDefault) && (tofNSigma > NSigmaDefault)) { // TPC and TOF return std::sqrt(.5f * (tpcNSigma * tpcNSigma + tofNSigma * tofNSigma)); } - if (tpcNSigma > defaultNSigma) { // only TPC + if (tpcNSigma > NSigmaDefault) { // only TPC return std::abs(tpcNSigma); } - if (tofNSigma > defaultNSigma) { // only TOF + if (tofNSigma > NSigmaDefault) { // only TOF return std::abs(tofNSigma); } return tofNSigma; // no TPC nor TOF diff --git a/PWGHF/TableProducer/refitPvDummy.cxx b/PWGHF/TableProducer/refitPvDummy.cxx index 64b13f2d5cb..51b7db06236 100644 --- a/PWGHF/TableProducer/refitPvDummy.cxx +++ b/PWGHF/TableProducer/refitPvDummy.cxx @@ -14,14 +14,15 @@ /// /// \author Mattia Faggin , University and INFN Padova, Italy -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/Track.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "Common/Core/trackUtilities.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index 5548863ac6c..ebe0713d03a 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -21,39 +21,64 @@ /// \author Federica Zanone , Heidelberg University /// \author Ruiqi Yin , Fudan University -#include // std::find -#include // std::distance -#include // std::string -#include // std::vector - -#include "CommonConstants/PhysicsConstants.h" -#include "CCDB/BasicCCDBManager.h" // for PV refit -#include "DataFormatsParameters/GRPMagField.h" // for PV refit -#include "DataFormatsParameters/GRPObject.h" // for PV refit -#include "DCAFitter/DCAFitterN.h" -#include "DetectorsBase/Propagator.h" // for PV refit -#include "DetectorsVertexing/PVertexer.h" // for PV refit -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/V0.h" -#include "ReconstructionDataFormats/Vertex.h" // for PV refit +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" +#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelectorPID.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/CollisionAssociationTables.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Tools/ML/MlResponse.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" +#include // for PV refit +#include +#include +#include +#include +#include +#include // for PV refit +#include // for PV refit +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // for PV refit + +#include +#include + +#include +#include -#include "PWGHF/Core/CentralityEstimation.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/Utils/utilsAnalysis.h" -#include "PWGHF/Utils/utilsBfieldCCDB.h" -#include "PWGHF/Utils/utilsEvSelHf.h" +#include // std::find +#include +#include +#include +#include +#include // std::distance +#include +#include // std::string +#include // std::vector using namespace o2; using namespace o2::analysis; @@ -91,7 +116,7 @@ enum ChannelsProtonPid { NChannelsProtonPid }; // kaon PID (opposite-sign track in 3-prong decays) -constexpr int channelKaonPid = ChannelsProtonPid::NChannelsProtonPid; +constexpr int ChannelKaonPid = ChannelsProtonPid::NChannelsProtonPid; /// Event selection struct HfTrackIndexSkimCreatorTagSelCollisions { @@ -107,7 +132,7 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { void init(InitContext const&) { - std::array doProcess = {doprocessTrigAndCentFT0ASel, doprocessTrigAndCentFT0CSel, doprocessTrigAndCentFT0MSel, doprocessTrigAndCentFV0ASel, doprocessTrigSel, doprocessNoTrigSel}; + std::array doProcess = {doprocessTrigAndCentFT0ASel, doprocessTrigAndCentFT0CSel, doprocessTrigAndCentFT0MSel, doprocessTrigAndCentFV0ASel, doprocessTrigSel, doprocessNoTrigSel, doprocessUpcSel}; if (std::accumulate(doProcess.begin(), doProcess.end(), 0) != 1) { LOGP(fatal, "One and only one process function for collision selection can be enabled at a time!"); } @@ -131,11 +156,19 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { /// Collision selection /// \param collision collision table with - template - void selectCollision(const Col& collision, const BCs&) + template + void selectCollision(const Col& collision, const BCsType& bcs) { float centrality = -1.; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + uint32_t rejectionMask; + + if constexpr (applyUpcSel) { + rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc( + collision, centrality, ccdb, registry, bcs); + } else { + rejectionMask = hfEvSel.getHfCollisionRejectionMask( + collision, centrality, ccdb, registry); + } if (fillHistograms) { hfEvSel.fillHistograms(collision, rejectionMask, centrality); @@ -154,53 +187,73 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { } /// Event selection with trigger and FT0A centrality selection - void processTrigAndCentFT0ASel(soa::Join::iterator const& collision, aod::BCsWithTimestamps const& bcs) + void processTrigAndCentFT0ASel(soa::Join::iterator const& collision, + aod::BcFullInfos const& bcs) { - selectCollision(collision, bcs); + selectCollision(collision, bcs); } PROCESS_SWITCH(HfTrackIndexSkimCreatorTagSelCollisions, processTrigAndCentFT0ASel, "Use trigger and centrality selection with FT0A", false); /// Event selection with trigger and FT0C centrality selection - void processTrigAndCentFT0CSel(soa::Join::iterator const& collision, aod::BCsWithTimestamps const& bcs) + void processTrigAndCentFT0CSel(soa::Join::iterator const& collision, + aod::BcFullInfos const& bcs) { - selectCollision(collision, bcs); + selectCollision(collision, bcs); } PROCESS_SWITCH(HfTrackIndexSkimCreatorTagSelCollisions, processTrigAndCentFT0CSel, "Use trigger and centrality selection with FT0C", false); /// Event selection with trigger and FT0M centrality selection - void processTrigAndCentFT0MSel(soa::Join::iterator const& collision, aod::BCsWithTimestamps const& bcs) + void processTrigAndCentFT0MSel(soa::Join::iterator const& collision, + aod::BcFullInfos const& bcs) { - selectCollision(collision, bcs); + selectCollision(collision, bcs); } PROCESS_SWITCH(HfTrackIndexSkimCreatorTagSelCollisions, processTrigAndCentFT0MSel, "Use trigger and centrality selection with FT0M", false); /// Event selection with trigger and FV0A centrality selection - void processTrigAndCentFV0ASel(soa::Join::iterator const& collision, aod::BCsWithTimestamps const& bcs) + void processTrigAndCentFV0ASel(soa::Join::iterator const& collision, + aod::BcFullInfos const& bcs) { - selectCollision(collision, bcs); + selectCollision(collision, bcs); } PROCESS_SWITCH(HfTrackIndexSkimCreatorTagSelCollisions, processTrigAndCentFV0ASel, "Use trigger and centrality selection with FV0A", false); /// Event selection with trigger selection - void processTrigSel(soa::Join::iterator const& collision, aod::BCsWithTimestamps const& bcs) + void processTrigSel(soa::Join::iterator const& collision, + aod::BcFullInfos const& bcs) { - selectCollision(collision, bcs); + selectCollision(collision, bcs); } PROCESS_SWITCH(HfTrackIndexSkimCreatorTagSelCollisions, processTrigSel, "Use trigger selection", false); /// Event selection without trigger selection - void processNoTrigSel(aod::Collision const& collision, aod::BCsWithTimestamps const& bcs) + void processNoTrigSel(aod::Collision const& collision, + aod::BcFullInfos const& bcs) { - selectCollision(collision, bcs); + selectCollision(collision, bcs); } PROCESS_SWITCH(HfTrackIndexSkimCreatorTagSelCollisions, processNoTrigSel, "Do not use trigger selection", true); + + /// Event selection with UPC + void processUpcSel(soa::Join::iterator const& collision, + aod::BcFullInfos const& bcs, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs const& /*zdcs*/) + { + selectCollision(collision, bcs); + } + PROCESS_SWITCH(HfTrackIndexSkimCreatorTagSelCollisions, processUpcSel, "Use UPC event selection", false); }; /// Track selection struct HfTrackIndexSkimCreatorTagSelTracks { - SliceCache cache; - Preslice perCol = aod::track::collisionId; - Produces rowSelectedTrack; Produces tabPvRefitTrack; @@ -219,22 +272,22 @@ struct HfTrackIndexSkimCreatorTagSelTracks { Configurable> binsPtTrack{"binsPtTrack", std::vector{hf_cuts_single_track::vecBinsPtTrack}, "track pT bin limits for 2-prong DCA XY pT-dependent cut"}; // 2-prong cuts Configurable ptMinTrack2Prong{"ptMinTrack2Prong", -1., "min. track pT for 2 prong candidate"}; - Configurable> cutsTrack2Prong{"cutsTrack2Prong", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 2-prong candidates"}; + Configurable> cutsTrack2Prong{"cutsTrack2Prong", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 2-prong candidates"}; Configurable etaMinTrack2Prong{"etaMinTrack2Prong", -99999., "min. pseudorapidity for 2 prong candidate"}; Configurable etaMaxTrack2Prong{"etaMaxTrack2Prong", 4., "max. pseudorapidity for 2 prong candidate"}; // 3-prong cuts Configurable ptMinTrack3Prong{"ptMinTrack3Prong", -1., "min. track pT for 3 prong candidate"}; - Configurable> cutsTrack3Prong{"cutsTrack3Prong", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 3-prong candidates"}; + Configurable> cutsTrack3Prong{"cutsTrack3Prong", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 3-prong candidates"}; Configurable etaMinTrack3Prong{"etaMinTrack3Prong", -99999., "min. pseudorapidity for 3 prong candidate"}; Configurable etaMaxTrack3Prong{"etaMaxTrack3Prong", 4., "max. pseudorapidity for 3 prong candidate"}; // bachelor cuts (V0 + bachelor decays) Configurable ptMinTrackBach{"ptMinTrackBach", 0.3, "min. track pT for bachelor in cascade candidate"}; // 0.5 for PbPb 2015? - Configurable> cutsTrackBach{"cutsTrackBach", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for the bachelor of V0-bachelor candidates"}; + Configurable> cutsTrackBach{"cutsTrackBach", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for the bachelor of V0-bachelor candidates"}; Configurable etaMinTrackBach{"etaMinTrackBach", -99999., "min. pseudorapidity for bachelor in cascade candidate"}; Configurable etaMaxTrackBach{"etaMaxTrackBach", 0.8, "max. pseudorapidity for bachelor in cascade candidate"}; // bachelor cuts (cascade + bachelor decays) Configurable ptMinTrackBachLfCasc{"ptMinTrackBachLfCasc", 0.1, "min. track pT for bachelor in cascade + bachelor decays"}; // 0.5 for PbPb 2015? - Configurable> cutsTrackBachLfCasc{"cutsTrackBachLfCasc", {hf_cuts_single_track::cutsTrack[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for the bachelor in cascade + bachelor decays"}; + Configurable> cutsTrackBachLfCasc{"cutsTrackBachLfCasc", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for the bachelor in cascade + bachelor decays"}; Configurable etaMinTrackBachLfCasc{"etaMinTrackBachLfCasc", -99999., "min. pseudorapidity for bachelor in cascade + bachelor decays"}; Configurable etaMaxTrackBachLfCasc{"etaMaxTrackBachLfCasc", 1.1, "max. pseudorapidity for bachelor in cascade + bachelor decays"}; Configurable useIsGlobalTrackForBachLfCasc{"useIsGlobalTrackForBachLfCasc", false, "check isGlobalTrack status for bachelor in cascade + bachelor decays"}; @@ -244,12 +297,12 @@ struct HfTrackIndexSkimCreatorTagSelTracks { Configurable ptMinSoftPionForDstar{"ptMinSoftPionForDstar", 0.05, "min. track pT for soft pion in D* candidate"}; Configurable etaMinSoftPionForDstar{"etaMinSoftPionForDstar", -99999., "min. pseudorapidity for soft pion in D* candidate"}; Configurable etaMaxSoftPionForDstar{"etaMaxSoftPionForDstar", 0.8, "max. pseudorapidity for soft pion in D* candidate"}; - Configurable> cutsTrackDstar{"cutsTrackDstar", {hf_cuts_single_track::cutsTrackPrimary[0], hf_cuts_single_track::nBinsPtTrack, hf_cuts_single_track::nCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for the soft pion of D* candidates"}; + Configurable> cutsTrackDstar{"cutsTrackDstar", {hf_cuts_single_track::CutsTrackPrimary[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for the soft pion of D* candidates"}; Configurable useIsGlobalTrackForSoftPion{"useIsGlobalTrackForSoftPion", false, "check isGlobalTrack status for soft pion tracks"}; Configurable useIsGlobalTrackWoDCAForSoftPion{"useIsGlobalTrackWoDCAForSoftPion", false, "check isGlobalTrackWoDCA status for soft pion tracks"}; Configurable useIsQualityTrackITSForSoftPion{"useIsQualityTrackITSForSoftPion", true, "check qualityTracksITS status for soft pion tracks"}; // proton PID, applied only if corresponding process function enabled - Configurable> selectionsPid{"selectionsPid", {hf_presel_pid::cutsPid[0], 4, 6, hf_presel_pid::labelsRowsPid, hf_presel_pid::labelsCutsPid}, "PID selections for proton / kaon applied if proper process function enabled"}; + Configurable> selectionsPid{"selectionsPid", {hf_presel_pid::CutsPid[0], 4, 6, hf_presel_pid::labelsRowsPid, hf_presel_pid::labelsCutsPid}, "PID selections for proton / kaon applied if proper process function enabled"}; // CCDB Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable ccdbPathLut{"ccdbPathLut", "GLO/Param/MatLUT", "Path for LUT parametrization"}; @@ -257,12 +310,22 @@ struct HfTrackIndexSkimCreatorTagSelTracks { Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; } config; + SliceCache cache; + // Needed for PV refitting Service ccdb; o2::base::MatLayerCylSet* lut; o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; int runNumber; + using TracksWithSelAndDca = soa::Join; + using TracksWithSelAndDcaAndPidTpc = soa::Join; + using TracksWithSelAndDcaAndPidTof = soa::Join; + using TracksWithSelAndDcaAndPidTpcTof = soa::Join; + + Preslice perCol = aod::track::collisionId; + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + // single-track cuts static const int nCuts = 4; // array of 2-prong and 3-prong cuts @@ -271,13 +334,6 @@ struct HfTrackIndexSkimCreatorTagSelTracks { std::array selectorProton; TrackSelectorKa selectorKaon; - using TracksWithSelAndDca = soa::Join; - using TracksWithSelAndDcaAndPidTpc = soa::Join; - using TracksWithSelAndDcaAndPidTof = soa::Join; - using TracksWithSelAndDcaAndPidTpcTof = soa::Join; - - Preslice trackIndicesPerCollision = aod::track_association::collisionId; - Partition pvContributors = ((aod::track::flags & static_cast(aod::track::PVContributor)) == static_cast(aod::track::PVContributor)); Partition pvContributorsWithPidTpc = ((aod::track::flags & static_cast(aod::track::PVContributor)) == static_cast(aod::track::PVContributor)); Partition pvContributorsWithPidTof = ((aod::track::flags & static_cast(aod::track::PVContributor)) == static_cast(aod::track::PVContributor)); @@ -395,10 +451,10 @@ struct HfTrackIndexSkimCreatorTagSelTracks { selectorProton[iChannel].setRangeNSigmaTof(-config.selectionsPid->get(iChannel, 5u), config.selectionsPid->get(iChannel, 5u)); // 5u == "nSigmaMaxTof" } // after the proton PID we have the kaon PID - selectorKaon.setRangePtTpc(config.selectionsPid->get(channelKaonPid, 0u), config.selectionsPid->get(channelKaonPid, 1u)); // 0u == "minPtTpc", 1u == "maxPtTpc" - selectorKaon.setRangePtTof(config.selectionsPid->get(channelKaonPid, 3u), config.selectionsPid->get(channelKaonPid, 4u)); // 3u == "minPtTof, 4u == "maxPtTof" - selectorKaon.setRangeNSigmaTpc(-config.selectionsPid->get(channelKaonPid, 2u), config.selectionsPid->get(channelKaonPid, 2u)); // 2u == "nSigmaMaxTpc" - selectorKaon.setRangeNSigmaTof(-config.selectionsPid->get(channelKaonPid, 5u), config.selectionsPid->get(channelKaonPid, 5u)); // 5u == "nSigmaMaxTof" + selectorKaon.setRangePtTpc(config.selectionsPid->get(ChannelKaonPid, 0u), config.selectionsPid->get(ChannelKaonPid, 1u)); // 0u == "minPtTpc", 1u == "maxPtTpc" + selectorKaon.setRangePtTof(config.selectionsPid->get(ChannelKaonPid, 3u), config.selectionsPid->get(ChannelKaonPid, 4u)); // 3u == "minPtTof, 4u == "maxPtTof" + selectorKaon.setRangeNSigmaTpc(-config.selectionsPid->get(ChannelKaonPid, 2u), config.selectionsPid->get(ChannelKaonPid, 2u)); // 2u == "nSigmaMaxTpc" + selectorKaon.setRangeNSigmaTof(-config.selectionsPid->get(ChannelKaonPid, 5u), config.selectionsPid->get(ChannelKaonPid, 5u)); // 5u == "nSigmaMaxTof" } /// PID track cuts (for proton only) @@ -413,7 +469,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { for (auto iChannel{0u}; iChannel < ChannelsProtonPid::NChannelsProtonPid; ++iChannel) { statusPid[iChannel] = selectorProton[iChannel].statusTof(hfTrack); } - statusPid[channelKaonPid] = selectorKaon.statusTof(hfTrack); + statusPid[ChannelKaonPid] = selectorKaon.statusTof(hfTrack); } } if constexpr (pidStrategy == ProtonPidStrategy::PidTpcOnly) { @@ -421,20 +477,20 @@ struct HfTrackIndexSkimCreatorTagSelTracks { for (auto iChannel{0u}; iChannel < ChannelsProtonPid::NChannelsProtonPid; ++iChannel) { statusPid[iChannel] = selectorProton[iChannel].statusTpc(hfTrack); } - statusPid[channelKaonPid] = selectorKaon.statusTpc(hfTrack); + statusPid[ChannelKaonPid] = selectorKaon.statusTpc(hfTrack); } } if constexpr (pidStrategy == ProtonPidStrategy::PidTpcOrTof) { for (auto iChannel{0u}; iChannel < ChannelsProtonPid::NChannelsProtonPid; ++iChannel) { statusPid[iChannel] = selectorProton[iChannel].statusTpcOrTof(hfTrack); } - statusPid[channelKaonPid] = selectorKaon.statusTpcOrTof(hfTrack); + statusPid[ChannelKaonPid] = selectorKaon.statusTpcOrTof(hfTrack); } if constexpr (pidStrategy == ProtonPidStrategy::PidTpcAndTof) { for (auto iChannel{0u}; iChannel < ChannelsProtonPid::NChannelsProtonPid; ++iChannel) { statusPid[iChannel] = selectorProton[iChannel].statusTpcAndTof(hfTrack); } - statusPid[channelKaonPid] = selectorKaon.statusTpcAndTof(hfTrack); + statusPid[ChannelKaonPid] = selectorKaon.statusTpcAndTof(hfTrack); } int8_t flag = BIT(ChannelsProtonPid::NChannelsProtonPid + 1) - 1; // all bits on (including the kaon one) @@ -813,7 +869,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { /// Track propagation to the PV refit considering also the material budget /// Mandatory for tracks updated at most only to the innermost ITS layer auto trackPar = getTrackPar(trackToRemove); - o2::gpu::gpustd::array dcaInfo{-999., -999.}; + std::array dcaInfo{-999., -999.}; if (o2::base::Propagator::Instance()->propagateToDCABxByBz({primVtxBaseRecalc.getX(), primVtxBaseRecalc.getY(), primVtxBaseRecalc.getZ()}, trackPar, 2.f, noMatCorr, &dcaInfo)) { pvCoord[0] = primVtxBaseRecalc.getX(); pvCoord[1] = primVtxBaseRecalc.getY(); @@ -916,7 +972,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { auto bc = collision.bc_as(); initCCDB(bc, runNumber, ccdb, config.isRun2 ? config.ccdbPathGrp : config.ccdbPathGrpMag, lut, config.isRun2); auto trackPar = getTrackPar(track); - o2::gpu::gpustd::array dcaInfo{-999., -999.}; + std::array dcaInfo{-999., -999.}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPar, 2.f, noMatCorr, &dcaInfo); trackPt = trackPar.getPt(); trackEta = trackPar.getEta(); @@ -1159,28 +1215,28 @@ struct HfTrackIndexSkimCreator { // D0 cuts Configurable> binsPtD0ToPiK{"binsPtD0ToPiK", std::vector{hf_cuts_presel_2prong::vecBinsPt}, "pT bin limits for D0->piK pT-dependent cuts"}; - Configurable> cutsD0ToPiK{"cutsD0ToPiK", {hf_cuts_presel_2prong::cuts[0], hf_cuts_presel_2prong::nBinsPt, hf_cuts_presel_2prong::nCutVars, hf_cuts_presel_2prong::labelsPt, hf_cuts_presel_2prong::labelsCutVar}, "D0->piK selections per pT bin"}; + Configurable> cutsD0ToPiK{"cutsD0ToPiK", {hf_cuts_presel_2prong::Cuts[0], hf_cuts_presel_2prong::NBinsPt, hf_cuts_presel_2prong::NCutVars, hf_cuts_presel_2prong::labelsPt, hf_cuts_presel_2prong::labelsCutVar}, "D0->piK selections per pT bin"}; // Jpsi -> ee cuts Configurable> binsPtJpsiToEE{"binsPtJpsiToEE", std::vector{hf_cuts_presel_2prong::vecBinsPt}, "pT bin limits for Jpsi->ee pT-dependent cuts"}; - Configurable> cutsJpsiToEE{"cutsJpsiToEE", {hf_cuts_presel_2prong::cuts[0], hf_cuts_presel_2prong::nBinsPt, hf_cuts_presel_2prong::nCutVars, hf_cuts_presel_2prong::labelsPt, hf_cuts_presel_2prong::labelsCutVar}, "Jpsi->ee selections per pT bin"}; + Configurable> cutsJpsiToEE{"cutsJpsiToEE", {hf_cuts_presel_2prong::Cuts[0], hf_cuts_presel_2prong::NBinsPt, hf_cuts_presel_2prong::NCutVars, hf_cuts_presel_2prong::labelsPt, hf_cuts_presel_2prong::labelsCutVar}, "Jpsi->ee selections per pT bin"}; // Jpsi -> mumu cuts Configurable> binsPtJpsiToMuMu{"binsPtJpsiToMuMu", std::vector{hf_cuts_presel_2prong::vecBinsPt}, "pT bin limits for Jpsi->mumu pT-dependent cuts"}; - Configurable> cutsJpsiToMuMu{"cutsJpsiToMuMu", {hf_cuts_presel_2prong::cuts[0], hf_cuts_presel_2prong::nBinsPt, hf_cuts_presel_2prong::nCutVars, hf_cuts_presel_2prong::labelsPt, hf_cuts_presel_2prong::labelsCutVar}, "Jpsi->mumu selections per pT bin"}; + Configurable> cutsJpsiToMuMu{"cutsJpsiToMuMu", {hf_cuts_presel_2prong::Cuts[0], hf_cuts_presel_2prong::NBinsPt, hf_cuts_presel_2prong::NCutVars, hf_cuts_presel_2prong::labelsPt, hf_cuts_presel_2prong::labelsCutVar}, "Jpsi->mumu selections per pT bin"}; // D+ cuts Configurable> binsPtDplusToPiKPi{"binsPtDplusToPiKPi", std::vector{hf_cuts_presel_3prong::vecBinsPt}, "pT bin limits for D+->piKpi pT-dependent cuts"}; - Configurable> cutsDplusToPiKPi{"cutsDplusToPiKPi", {hf_cuts_presel_3prong::cuts[0], hf_cuts_presel_3prong::nBinsPt, hf_cuts_presel_3prong::nCutVars, hf_cuts_presel_3prong::labelsPt, hf_cuts_presel_3prong::labelsCutVar}, "D+->piKpi selections per pT bin"}; + Configurable> cutsDplusToPiKPi{"cutsDplusToPiKPi", {hf_cuts_presel_3prong::Cuts[0], hf_cuts_presel_3prong::NBinsPt, hf_cuts_presel_3prong::NCutVars, hf_cuts_presel_3prong::labelsPt, hf_cuts_presel_3prong::labelsCutVar}, "D+->piKpi selections per pT bin"}; // Ds+ cuts Configurable> binsPtDsToKKPi{"binsPtDsToKKPi", std::vector{hf_cuts_presel_ds::vecBinsPt}, "pT bin limits for Ds+->KKPi pT-dependent cuts"}; - Configurable> cutsDsToKKPi{"cutsDsToKKPi", {hf_cuts_presel_ds::cuts[0], hf_cuts_presel_ds::nBinsPt, hf_cuts_presel_ds::nCutVars, hf_cuts_presel_ds::labelsPt, hf_cuts_presel_ds::labelsCutVar}, "Ds+->KKPi selections per pT bin"}; + Configurable> cutsDsToKKPi{"cutsDsToKKPi", {hf_cuts_presel_ds::Cuts[0], hf_cuts_presel_ds::NBinsPt, hf_cuts_presel_ds::NCutVars, hf_cuts_presel_ds::labelsPt, hf_cuts_presel_ds::labelsCutVar}, "Ds+->KKPi selections per pT bin"}; // Lc+ cuts Configurable> binsPtLcToPKPi{"binsPtLcToPKPi", std::vector{hf_cuts_presel_3prong::vecBinsPt}, "pT bin limits for Lc->pKpi pT-dependent cuts"}; - Configurable> cutsLcToPKPi{"cutsLcToPKPi", {hf_cuts_presel_3prong::cuts[0], hf_cuts_presel_3prong::nBinsPt, hf_cuts_presel_3prong::nCutVars, hf_cuts_presel_3prong::labelsPt, hf_cuts_presel_3prong::labelsCutVar}, "Lc->pKpi selections per pT bin"}; + Configurable> cutsLcToPKPi{"cutsLcToPKPi", {hf_cuts_presel_3prong::Cuts[0], hf_cuts_presel_3prong::NBinsPt, hf_cuts_presel_3prong::NCutVars, hf_cuts_presel_3prong::labelsPt, hf_cuts_presel_3prong::labelsCutVar}, "Lc->pKpi selections per pT bin"}; // Xic+ cuts Configurable> binsPtXicToPKPi{"binsPtXicToPKPi", std::vector{hf_cuts_presel_3prong::vecBinsPt}, "pT bin limits for Xic->pKpi pT-dependent cuts"}; - Configurable> cutsXicToPKPi{"cutsXicToPKPi", {hf_cuts_presel_3prong::cuts[0], hf_cuts_presel_3prong::nBinsPt, hf_cuts_presel_3prong::nCutVars, hf_cuts_presel_3prong::labelsPt, hf_cuts_presel_3prong::labelsCutVar}, "Xic->pKpi selections per pT bin"}; + Configurable> cutsXicToPKPi{"cutsXicToPKPi", {hf_cuts_presel_3prong::Cuts[0], hf_cuts_presel_3prong::NBinsPt, hf_cuts_presel_3prong::NCutVars, hf_cuts_presel_3prong::labelsPt, hf_cuts_presel_3prong::labelsCutVar}, "Xic->pKpi selections per pT bin"}; // D*+ cuts Configurable> binsPtDstarToD0Pi{"binsPtDstarToD0Pi", std::vector{hf_cuts_presel_dstar::vecBinsPt}, "pT bin limits for D*+->D0pi pT-dependent cuts"}; - Configurable> cutsDstarToD0Pi{"cutsDstarToD0Pi", {hf_cuts_presel_dstar::cuts[0], hf_cuts_presel_dstar::nBinsPt, hf_cuts_presel_dstar::nCutVars, hf_cuts_presel_dstar::labelsPt, hf_cuts_presel_dstar::labelsCutVar}, "D*+->D0pi selections per pT bin"}; + Configurable> cutsDstarToD0Pi{"cutsDstarToD0Pi", {hf_cuts_presel_dstar::Cuts[0], hf_cuts_presel_dstar::NBinsPt, hf_cuts_presel_dstar::NCutVars, hf_cuts_presel_dstar::labelsPt, hf_cuts_presel_dstar::labelsCutVar}, "D*+->D0pi selections per pT bin"}; // proton PID selections for Lc and Xic Configurable applyProtonPidForLcToPKPi{"applyProtonPidForLcToPKPi", false, "Apply proton PID for Lc->pKpi"}; @@ -1195,11 +1251,11 @@ struct HfTrackIndexSkimCreator { Configurable> onnxFileNames{"onnxFileNames", {hf_cuts_bdt_multiclass::onnxFileNameSpecies[0], 5, 1, hf_cuts_bdt_multiclass::labelsSpecies, hf_cuts_bdt_multiclass::labelsModels}, "ONNX file names for ML models"}; - Configurable> thresholdMlScoreD0ToKPi{"thresholdMlScoreD0ToKPi", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of D0 candidates"}; - Configurable> thresholdMlScoreDplusToPiKPi{"thresholdMlScoreDplusToPiKPi", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of D+ candidates"}; - Configurable> thresholdMlScoreDsToPiKK{"thresholdMlScoreDsToPiKK", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of Ds+ candidates"}; - Configurable> thresholdMlScoreLcToPiKP{"thresholdMlScoreLcToPiKP", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of Lc+ candidates"}; - Configurable> thresholdMlScoreXicToPiKP{"thresholdMlScoreXicToPiKP", {hf_cuts_bdt_multiclass::cuts[0], hf_cuts_bdt_multiclass::nBinsPt, hf_cuts_bdt_multiclass::nCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of Xic+ candidates"}; + Configurable> thresholdMlScoreD0ToKPi{"thresholdMlScoreD0ToKPi", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of D0 candidates"}; + Configurable> thresholdMlScoreDplusToPiKPi{"thresholdMlScoreDplusToPiKPi", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of D+ candidates"}; + Configurable> thresholdMlScoreDsToPiKK{"thresholdMlScoreDsToPiKK", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of Ds+ candidates"}; + Configurable> thresholdMlScoreLcToPiKP{"thresholdMlScoreLcToPiKP", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of Lc+ candidates"}; + Configurable> thresholdMlScoreXicToPiKP{"thresholdMlScoreXicToPiKP", {hf_cuts_bdt_multiclass::Cuts[0], hf_cuts_bdt_multiclass::NBinsPt, hf_cuts_bdt_multiclass::NCutBdtScores, hf_cuts_bdt_multiclass::labelsPt, hf_cuts_bdt_multiclass::labelsCutBdt}, "Threshold values for Ml output scores of Xic+ candidates"}; } config; SliceCache cache; @@ -1223,8 +1279,8 @@ struct HfTrackIndexSkimCreator { static constexpr int kN2ProngDecays = hf_cand_2prong::DecayType::N2ProngDecays; // number of 2-prong hadron types static constexpr int kN3ProngDecays = hf_cand_3prong::DecayType::N3ProngDecays; // number of 3-prong hadron types - static constexpr int kNCuts2Prong[kN2ProngDecays] = {hf_cuts_presel_2prong::nCutVars, hf_cuts_presel_2prong::nCutVars, hf_cuts_presel_2prong::nCutVars}; // how many different selections are made on 2-prongs - static constexpr int kNCuts3Prong[kN3ProngDecays] = {hf_cuts_presel_3prong::nCutVars, hf_cuts_presel_3prong::nCutVars + 1, hf_cuts_presel_ds::nCutVars, hf_cuts_presel_3prong::nCutVars + 1}; // how many different selections are made on 3-prongs (Lc and Xic have also PID potentially) + static constexpr int kNCuts2Prong[kN2ProngDecays] = {hf_cuts_presel_2prong::NCutVars, hf_cuts_presel_2prong::NCutVars, hf_cuts_presel_2prong::NCutVars}; // how many different selections are made on 2-prongs + static constexpr int kNCuts3Prong[kN3ProngDecays] = {hf_cuts_presel_3prong::NCutVars, hf_cuts_presel_3prong::NCutVars + 1, hf_cuts_presel_ds::NCutVars, hf_cuts_presel_3prong::NCutVars + 1}; // how many different selections are made on 3-prongs (Lc and Xic have also PID potentially) static constexpr int kNCutsDstar = 3; // how many different selections are made on Dstars std::array, 2>, kN2ProngDecays> arrMass2Prong; std::array, 2>, kN3ProngDecays> arrMass3Prong; @@ -1245,14 +1301,13 @@ struct HfTrackIndexSkimCreator { using FilteredTrackAssocSel = soa::Filtered>; // filter collisions - Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); - - // define slice of track indices per collisions - Preslice tracksPerCollision = aod::track::collisionId; // needed for PV refit - + Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); // filter track indices Filter filterSelectTrackIds = ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::Cand2Prong))) != 0u) || ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::Cand3Prong))) != 0u) || ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::CandDstar))) != 0u); + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + // define slice of track indices per collisions + Preslice tracksPerCollision = aod::track::collisionId; // needed for PV refit // define partitions Partition positiveFor2And3Prongs = aod::hf_sel_track::isPositive == true && (((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::Cand2Prong))) != 0u) || ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::Cand3Prong))) != 0u)); @@ -1269,7 +1324,7 @@ struct HfTrackIndexSkimCreator { void init(InitContext const&) { - if (!doprocess2And3ProngsWithPvRefit && !doprocess2And3ProngsNoPvRefit) { + if (!doprocess2And3ProngsWithPvRefit && !doprocess2And3ProngsNoPvRefit && !doprocess2And3ProngsWithPvRefitWithPidForHfFiltersBdt && !doprocess2And3ProngsNoPvRefitWithPidForHfFiltersBdt) { return; } @@ -1357,7 +1412,7 @@ struct HfTrackIndexSkimCreator { registry.add("hMassDstarToD0Pi", "D^{*#plus} candidates;inv. mass (K #pi #pi) - mass (K #pi) (GeV/#it{c}^{2});entries", {HistType::kTH1D, {{500, 0.135, 0.185}}}); // needed for PV refitting - if (doprocess2And3ProngsWithPvRefit) { + if (doprocess2And3ProngsWithPvRefit || doprocess2And3ProngsWithPvRefitWithPidForHfFiltersBdt) { AxisSpec axisCollisionX{100, -20.f, 20.f, "X (cm)"}; AxisSpec axisCollisionY{100, -20.f, 20.f, "Y (cm)"}; AxisSpec axisCollisionZ{100, -20.f, 20.f, "Z (cm)"}; @@ -1591,7 +1646,7 @@ struct HfTrackIndexSkimCreator { if (whichHypo[iDecay3P] == 0) { CLRBIT(isSelected, iDecay3P); if (config.debug) { - cutStatus[iDecay3P][hf_cuts_presel_3prong::nCutVars] = false; // PID + cutStatus[iDecay3P][hf_cuts_presel_3prong::NCutVars] = false; // PID } continue; // no need to check further for this particle hypothesis } @@ -1767,9 +1822,12 @@ struct HfTrackIndexSkimCreator { /// Method to perform ML selections for 2-prong candidates after the rectangular selections /// \param featuresCand is the vector with the candidate features + /// \param featuresCandPid is the vector with the candidate PID features /// \param outputScores is the array of vectors with the output scores to be filled /// \param isSelected ia s bitmap with selection outcome - void applyMlSelectionForHfFilters3Prong(std::vector featuresCand, std::array, kN3ProngDecays>& outputScores, int& isSelected) + /// \param usePidForHfFiltersBdt is the flag to determine whether to use also the PID features for the Lc BDT + template + void applyMlSelectionForHfFilters3Prong(std::vector featuresCand, std::vector featuresCandPid, std::array, kN3ProngDecays>& outputScores, int& isSelected) { if (isSelected == 0) { return; @@ -1778,7 +1836,18 @@ struct HfTrackIndexSkimCreator { const float ptDummy = 1.; // dummy pT value (only one pT bin) for (int iDecay3P{0}; iDecay3P < kN3ProngDecays; ++iDecay3P) { if (TESTBIT(isSelected, iDecay3P) && hasMlModel3Prong[iDecay3P]) { - bool isMlSel = hfMlResponse3Prongs[iDecay3P].isSelectedMl(featuresCand, ptDummy, outputScores[iDecay3P]); + bool isMlSel = false; + if constexpr (usePidForHfFiltersBdt) { + if (iDecay3P != hf_cand_3prong::DecayType::LcToPKPi && iDecay3P != hf_cand_3prong::DecayType::XicToPKPi) { + isMlSel = hfMlResponse3Prongs[iDecay3P].isSelectedMl(featuresCand, ptDummy, outputScores[iDecay3P]); + } else { + std::vector featuresCandWithPid = featuresCand; + featuresCandWithPid.insert(featuresCandWithPid.end(), featuresCandPid.begin(), featuresCandPid.end()); + isMlSel = hfMlResponse3Prongs[iDecay3P].isSelectedMl(featuresCandWithPid, ptDummy, outputScores[iDecay3P]); + } + } else { + isMlSel = hfMlResponse3Prongs[iDecay3P].isSelectedMl(featuresCand, ptDummy, outputScores[iDecay3P]); + } if (config.fillHistograms) { switch (iDecay3P) { case hf_cand_3prong::DecayType::DplusToPiKPi: { @@ -1903,7 +1972,7 @@ struct HfTrackIndexSkimCreator { bool pvRefitDoable = vertexer.prepareVertexRefit(vecPvContributorTrackParCov, primVtx); if (!pvRefitDoable) { LOG(info) << "Not enough tracks accepted for the refit"; - if (doprocess2And3ProngsWithPvRefit && config.fillHistograms) { + if ((doprocess2And3ProngsWithPvRefit || doprocess2And3ProngsWithPvRefitWithPidForHfFiltersBdt) && config.fillHistograms) { registry.fill(HIST("PvRefit/hNContribPvRefitNotDoable"), collision.numContrib()); } } @@ -1914,13 +1983,13 @@ struct HfTrackIndexSkimCreator { /// PV refitting, if the tracks contributed to this at the beginning o2::dataformats::VertexBase primVtxBaseRecalc; bool recalcPvRefit = false; - if (doprocess2And3ProngsWithPvRefit && pvRefitDoable) { + if ((doprocess2And3ProngsWithPvRefit || doprocess2And3ProngsWithPvRefitWithPidForHfFiltersBdt) && pvRefitDoable) { if (config.fillHistograms) { registry.fill(HIST("PvRefit/verticesPerCandidate"), 2); } recalcPvRefit = true; int nCandContr = 0; - for (uint64_t myGlobalID : vecCandPvContributorGlobId) { + for (uint64_t myGlobalID : vecCandPvContributorGlobId) { // o2-linter: disable=const-ref-in-for-loop (small type) auto trackIterator = std::find(vecPvContributorGlobId.begin(), vecPvContributorGlobId.end(), myGlobalID); /// track global index if (trackIterator != vecPvContributorGlobId.end()) { /// this is a contributor, let's remove it for the PV refit @@ -2003,7 +2072,7 @@ struct HfTrackIndexSkimCreator { return; } /// end of performPvRefitCandProngs function - template + template void run2And3Prongs(SelectedCollisions const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, FilteredTrackAssocSel const&, @@ -2108,7 +2177,7 @@ struct HfTrackIndexSkimCreator { auto trackParVarPos1 = getTrackParCov(trackPos1); std::array pVecTrackPos1{trackPos1.pVector()}; - o2::gpu::gpustd::array dcaInfoPos1{trackPos1.dcaXY(), trackPos1.dcaZ()}; + std::array dcaInfoPos1{trackPos1.dcaXY(), trackPos1.dcaZ()}; if (thisCollId != trackPos1.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarPos1, 2.f, noMatCorr, &dcaInfoPos1); getPxPyPz(trackParVarPos1, pVecTrackPos1); @@ -2126,7 +2195,7 @@ struct HfTrackIndexSkimCreator { auto trackParVarNeg1 = getTrackParCov(trackNeg1); std::array pVecTrackNeg1{trackNeg1.pVector()}; - o2::gpu::gpustd::array dcaInfoNeg1{trackNeg1.dcaXY(), trackNeg1.dcaZ()}; + std::array dcaInfoNeg1{trackNeg1.dcaXY(), trackNeg1.dcaZ()}; if (thisCollId != trackNeg1.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarNeg1, 2.f, noMatCorr, &dcaInfoNeg1); getPxPyPz(trackParVarNeg1, pVecTrackNeg1); @@ -2270,16 +2339,16 @@ struct HfTrackIndexSkimCreator { } if (config.debug) { - int Prong2CutStatus[kN2ProngDecays]; + int prong2CutStatus[kN2ProngDecays]; for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { - Prong2CutStatus[iDecay2P] = nCutStatus2ProngBit[iDecay2P]; + prong2CutStatus[iDecay2P] = nCutStatus2ProngBit[iDecay2P]; for (int iCut = 0; iCut < kNCuts2Prong[iDecay2P]; iCut++) { if (!cutStatus2Prong[iDecay2P][iCut]) { - CLRBIT(Prong2CutStatus[iDecay2P], iCut); + CLRBIT(prong2CutStatus[iDecay2P], iCut); } } } - rowProng2CutStatus(Prong2CutStatus[0], Prong2CutStatus[1], Prong2CutStatus[2]); // FIXME when we can do this by looping over kN2ProngDecays + rowProng2CutStatus(prong2CutStatus[0], prong2CutStatus[1], prong2CutStatus[2]); // FIXME when we can do this by looping over kN2ProngDecays } // fill histograms @@ -2350,7 +2419,7 @@ struct HfTrackIndexSkimCreator { } } - if (config.applyKaonPidIn3Prongs && !TESTBIT(trackIndexNeg1.isIdentifiedPid(), channelKaonPid)) { // continue immediately if kaon PID enabled and opposite-sign track not a kaon + if (config.applyKaonPidIn3Prongs && !TESTBIT(trackIndexNeg1.isIdentifiedPid(), ChannelKaonPid)) { // continue immediately if kaon PID enabled and opposite-sign track not a kaon if (!config.debug) { continue; } else { @@ -2360,7 +2429,7 @@ struct HfTrackIndexSkimCreator { auto trackPos2 = trackIndexPos2.template track_as(); auto trackParVarPos2 = getTrackParCov(trackPos2); - o2::gpu::gpustd::array dcaInfoPos2{trackPos2.dcaXY(), trackPos2.dcaZ()}; + std::array dcaInfoPos2{trackPos2.dcaXY(), trackPos2.dcaZ()}; // preselection of 3-prong candidates if (isSelected3ProngCand) { @@ -2507,7 +2576,15 @@ struct HfTrackIndexSkimCreator { std::array, kN3ProngDecays> mlScores3Prongs; if (config.applyMlForHfFilters) { std::vector inputFeatures{trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos2.getPt(), dcaInfoPos2[0], dcaInfoPos2[1]}; - applyMlSelectionForHfFilters3Prong(inputFeatures, mlScores3Prongs, isSelected3ProngCand); + std::vector inputFeaturesLcPid{}; + if constexpr (usePidForHfFiltersBdt) { + inputFeaturesLcPid.push_back(trackPos1.tpcNSigmaPr()); + inputFeaturesLcPid.push_back(trackPos2.tpcNSigmaPr()); + inputFeaturesLcPid.push_back(trackPos1.tpcNSigmaPi()); + inputFeaturesLcPid.push_back(trackPos2.tpcNSigmaPi()); + inputFeaturesLcPid.push_back(trackNeg1.tpcNSigmaKa()); + } + applyMlSelectionForHfFilters3Prong(inputFeatures, inputFeaturesLcPid, mlScores3Prongs, isSelected3ProngCand); } if (!config.debug && isSelected3ProngCand == 0) { @@ -2526,16 +2603,16 @@ struct HfTrackIndexSkimCreator { } if (config.debug) { - int Prong3CutStatus[kN3ProngDecays]; + int prong3CutStatus[kN3ProngDecays]; for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { - Prong3CutStatus[iDecay3P] = nCutStatus3ProngBit[iDecay3P]; + prong3CutStatus[iDecay3P] = nCutStatus3ProngBit[iDecay3P]; for (int iCut = 0; iCut < kNCuts3Prong[iDecay3P]; iCut++) { if (!cutStatus3Prong[iDecay3P][iCut]) { - CLRBIT(Prong3CutStatus[iDecay3P], iCut); + CLRBIT(prong3CutStatus[iDecay3P], iCut); } } } - rowProng3CutStatus(Prong3CutStatus[0], Prong3CutStatus[1], Prong3CutStatus[2], Prong3CutStatus[3]); // FIXME when we can do this by looping over kN3ProngDecays + rowProng3CutStatus(prong3CutStatus[0], prong3CutStatus[1], prong3CutStatus[2], prong3CutStatus[3]); // FIXME when we can do this by looping over kN3ProngDecays } // fill histograms @@ -2594,7 +2671,7 @@ struct HfTrackIndexSkimCreator { } } - if (config.applyKaonPidIn3Prongs && !TESTBIT(trackIndexPos1.isIdentifiedPid(), channelKaonPid)) { // continue immediately if kaon PID enabled and opposite-sign track not a kaon + if (config.applyKaonPidIn3Prongs && !TESTBIT(trackIndexPos1.isIdentifiedPid(), ChannelKaonPid)) { // continue immediately if kaon PID enabled and opposite-sign track not a kaon if (!config.debug) { continue; } else { @@ -2604,7 +2681,7 @@ struct HfTrackIndexSkimCreator { auto trackNeg2 = trackIndexNeg2.template track_as(); auto trackParVarNeg2 = getTrackParCov(trackNeg2); - o2::gpu::gpustd::array dcaInfoNeg2{trackNeg2.dcaXY(), trackNeg2.dcaZ()}; + std::array dcaInfoNeg2{trackNeg2.dcaXY(), trackNeg2.dcaZ()}; // preselection of 3-prong candidates if (isSelected3ProngCand) { @@ -2752,7 +2829,15 @@ struct HfTrackIndexSkimCreator { std::array, kN3ProngDecays> mlScores3Prongs; if (config.applyMlForHfFilters) { std::vector inputFeatures{trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg2.getPt(), dcaInfoNeg2[0], dcaInfoNeg2[1]}; - applyMlSelectionForHfFilters3Prong(inputFeatures, mlScores3Prongs, isSelected3ProngCand); + std::vector inputFeaturesLcPid{}; + if constexpr (usePidForHfFiltersBdt) { + inputFeaturesLcPid.push_back(trackNeg1.tpcNSigmaPr()); + inputFeaturesLcPid.push_back(trackNeg2.tpcNSigmaPr()); + inputFeaturesLcPid.push_back(trackNeg1.tpcNSigmaPi()); + inputFeaturesLcPid.push_back(trackNeg2.tpcNSigmaPi()); + inputFeaturesLcPid.push_back(trackPos1.tpcNSigmaKa()); + } + applyMlSelectionForHfFilters3Prong(inputFeatures, inputFeaturesLcPid, mlScores3Prongs, isSelected3ProngCand); } if (!config.debug && isSelected3ProngCand == 0) { @@ -2771,16 +2856,16 @@ struct HfTrackIndexSkimCreator { } if (config.debug) { - int Prong3CutStatus[kN3ProngDecays]; + int prong3CutStatus[kN3ProngDecays]; for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { - Prong3CutStatus[iDecay3P] = nCutStatus3ProngBit[iDecay3P]; + prong3CutStatus[iDecay3P] = nCutStatus3ProngBit[iDecay3P]; for (int iCut = 0; iCut < kNCuts3Prong[iDecay3P]; iCut++) { if (!cutStatus3Prong[iDecay3P][iCut]) { - CLRBIT(Prong3CutStatus[iDecay3P], iCut); + CLRBIT(prong3CutStatus[iDecay3P], iCut); } } } - rowProng3CutStatus(Prong3CutStatus[0], Prong3CutStatus[1], Prong3CutStatus[2], Prong3CutStatus[3]); // FIXME when we can do this by looping over kN3ProngDecays + rowProng3CutStatus(prong3CutStatus[0], prong3CutStatus[1], prong3CutStatus[2], prong3CutStatus[3]); // FIXME when we can do this by looping over kN3ProngDecays } // fill histograms @@ -2830,7 +2915,7 @@ struct HfTrackIndexSkimCreator { if (config.doDstar && TESTBIT(isSelected2ProngCand, hf_cand_2prong::DecayType::D0ToPiK) && (pt2Prong + config.ptTolerance) * 1.2 > config.binsPtDstarToD0Pi->at(0) && whichHypo2Prong[kN2ProngDecays] != 0) { // if D* enabled and pt of the D0 is larger than the minimum of the D* one within 20% (D* and D0 momenta are very similar, always within 20% according to PYTHIA8) // second loop over positive tracks - if (TESTBIT(whichHypo2Prong[kN2ProngDecays], 0) && (!config.applyKaonPidIn3Prongs || TESTBIT(trackIndexNeg1.isIdentifiedPid(), channelKaonPid))) { // only for D0 candidates; moreover if kaon PID enabled, apply to the negative track + if (TESTBIT(whichHypo2Prong[kN2ProngDecays], 0) && (!config.applyKaonPidIn3Prongs || TESTBIT(trackIndexNeg1.isIdentifiedPid(), ChannelKaonPid))) { // only for D0 candidates; moreover if kaon PID enabled, apply to the negative track auto groupedTrackIndicesSoftPionsPos = positiveSoftPions->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); for (auto trackIndexPos2 = groupedTrackIndicesSoftPionsPos.begin(); trackIndexPos2 != groupedTrackIndicesSoftPionsPos.end(); ++trackIndexPos2) { if (trackIndexPos2 == trackIndexPos1) { @@ -2840,7 +2925,7 @@ struct HfTrackIndexSkimCreator { std::array pVecTrackPos2{trackPos2.pVector()}; if (thisCollId != trackPos2.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it auto trackParVarPos2 = getTrackParCov(trackPos2); - o2::gpu::gpustd::array dcaInfoPos2{trackPos2.dcaXY(), trackPos2.dcaZ()}; + std::array dcaInfoPos2{trackPos2.dcaXY(), trackPos2.dcaZ()}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarPos2, 2.f, noMatCorr, &dcaInfoPos2); getPxPyPz(trackParVarPos2, pVecTrackPos2); } @@ -2867,7 +2952,7 @@ struct HfTrackIndexSkimCreator { } // second loop over negative tracks - if (TESTBIT(whichHypo2Prong[kN2ProngDecays], 1) && (!config.applyKaonPidIn3Prongs || TESTBIT(trackIndexPos1.isIdentifiedPid(), channelKaonPid))) { // only for D0bar candidates; moreover if kaon PID enabled, apply to the positive track + if (TESTBIT(whichHypo2Prong[kN2ProngDecays], 1) && (!config.applyKaonPidIn3Prongs || TESTBIT(trackIndexPos1.isIdentifiedPid(), ChannelKaonPid))) { // only for D0bar candidates; moreover if kaon PID enabled, apply to the positive track auto groupedTrackIndicesSoftPionsNeg = negativeSoftPions->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); for (auto trackIndexNeg2 = groupedTrackIndicesSoftPionsNeg.begin(); trackIndexNeg2 != groupedTrackIndicesSoftPionsNeg.end(); ++trackIndexNeg2) { if (trackIndexNeg1 == trackIndexNeg2) { @@ -2877,7 +2962,7 @@ struct HfTrackIndexSkimCreator { std::array pVecTrackNeg2{trackNeg2.pVector()}; if (thisCollId != trackNeg2.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it auto trackParVarNeg2 = getTrackParCov(trackNeg2); - o2::gpu::gpustd::array dcaInfoNeg2{trackNeg2.dcaXY(), trackNeg2.dcaZ()}; + std::array dcaInfoNeg2{trackNeg2.dcaXY(), trackNeg2.dcaZ()}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarNeg2, 2.f, noMatCorr, &dcaInfoNeg2); getPxPyPz(trackParVarNeg2, pVecTrackNeg2); } @@ -2946,6 +3031,26 @@ struct HfTrackIndexSkimCreator { run2And3Prongs(collisions, bcWithTimeStamps, trackIndices, tracks); } PROCESS_SWITCH(HfTrackIndexSkimCreator, process2And3ProngsNoPvRefit, "Process 2-prong and 3-prong skim without PV refit", true); + + void process2And3ProngsWithPvRefitWithPidForHfFiltersBdt( // soa::Join::iterator const& collision, //FIXME add centrality when option for variations to the process function appears + SelectedCollisions const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + FilteredTrackAssocSel const& trackIndices, + soa::Join const& tracks) + { + run2And3Prongs(collisions, bcWithTimeStamps, trackIndices, tracks); + } + PROCESS_SWITCH(HfTrackIndexSkimCreator, process2And3ProngsWithPvRefitWithPidForHfFiltersBdt, "Process 2-prong and 3-prong skim with PV refit and PID for software trigger BDTs (Lc and Xic only)", false); + + void process2And3ProngsNoPvRefitWithPidForHfFiltersBdt( // soa::Join::iterator const& collision, //FIXME add centrality when option for variations to the process function appears + SelectedCollisions const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + FilteredTrackAssocSel const& trackIndices, + soa::Join const& tracks) + { + run2And3Prongs(collisions, bcWithTimeStamps, trackIndices, tracks); + } + PROCESS_SWITCH(HfTrackIndexSkimCreator, process2And3ProngsNoPvRefitWithPidForHfFiltersBdt, "Process 2-prong and 3-prong skim without PV refit and PID for software trigger BDTs (Lc and Xic only)", false); }; //________________________________________________________________________________________________________________________ @@ -3008,7 +3113,7 @@ struct HfTrackIndexSkimCreatorCascades { using SelectedCollisions = soa::Filtered>; using FilteredTrackAssocSel = soa::Filtered>; - Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); + Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); Filter filterSelectTrackIds = (aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::CandV0bachelor))) != 0u && (config.applyProtonPid == false || (aod::hf_sel_track::isIdentifiedPid & static_cast(BIT(ChannelsProtonPid::LcToPK0S))) != 0u); Preslice trackIndicesPerCollision = aod::track_association::collisionId; @@ -3086,7 +3191,7 @@ struct HfTrackIndexSkimCreatorCascades { std::array pVecBach{bach.pVector()}; auto trackBach = getTrackParCov(bach); if (thisCollId != bach.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it - o2::gpu::gpustd::array dcaInfoBach{bach.dcaXY(), bach.dcaZ()}; + std::array dcaInfoBach{bach.dcaXY(), bach.dcaZ()}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackBach, 2.f, noMatCorr, &dcaInfoBach); getPxPyPz(trackBach, pVecBach); } @@ -3287,7 +3392,7 @@ struct HfTrackIndexSkimCreatorLfCascades { using CascFull = soa::Join; using V0Full = soa::Join; - Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); + Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); Filter filterSelectTrackIds = (aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::CandCascadeBachelor))) != 0u; Preslice tracksPerCollision = aod::track::collisionId; // needed for PV refit diff --git a/PWGHF/TableProducer/treeCreatorB0ToDPi.cxx b/PWGHF/TableProducer/treeCreatorB0ToDPi.cxx index f6c717e6e08..ebfd87c5e46 100644 --- a/PWGHF/TableProducer/treeCreatorB0ToDPi.cxx +++ b/PWGHF/TableProducer/treeCreatorB0ToDPi.cxx @@ -16,17 +16,29 @@ /// /// \author Alexandre Bigot , IPHC Strasbourg -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_decay::hf_cand_beauty; namespace o2::aod { @@ -162,7 +174,7 @@ struct HfTreeCreatorB0ToDPi { Produces rowCandidateFullParticles; Produces rowCandidateLite; - Configurable selectionFlagB0{"selectionB0", 1, "Selection Flag for B0"}; + Configurable selectionFlagB0{"selectionFlagB0", 1, "Selection Flag for B0"}; Configurable fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"}; // parameters for production of training samples Configurable fillOnlySignal{"fillOnlySignal", false, "Flag to fill derived tables with signal for ML trainings"}; @@ -177,8 +189,8 @@ struct HfTreeCreatorB0ToDPi { Filter filterSelectCandidates = aod::hf_sel_candidate_b0::isSelB0ToDPi >= selectionFlagB0; - Partition recSig = nabs(aod::hf_cand_b0::flagMcMatchRec) == (int8_t)BIT(aod::hf_cand_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi); - Partition recBg = nabs(aod::hf_cand_b0::flagMcMatchRec) != (int8_t)BIT(aod::hf_cand_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi); + Partition recSig = nabs(aod::hf_cand_b0::flagMcMatchRec) == static_cast(DecayChannelMain::B0ToDminusPi); + Partition recBg = nabs(aod::hf_cand_b0::flagMcMatchRec) != static_cast(DecayChannelMain::B0ToDminusPi); void init(InitContext const&) { @@ -300,7 +312,7 @@ struct HfTreeCreatorB0ToDPi { } for (const auto& candidate : candidates) { if (fillOnlyBackground) { - float pseudoRndm = candidate.ptProng1() * 1000. - (int64_t)(candidate.ptProng1() * 1000); + float pseudoRndm = candidate.ptProng1() * 1000. - static_cast(candidate.ptProng1() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -340,7 +352,7 @@ struct HfTreeCreatorB0ToDPi { rowCandidateLite.reserve(recBg.size()); } for (const auto& candidate : recBg) { - float pseudoRndm = candidate.ptProng1() * 1000. - (int64_t)(candidate.ptProng1() * 1000); + float pseudoRndm = candidate.ptProng1() * 1000. - static_cast(candidate.ptProng1() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -361,7 +373,7 @@ struct HfTreeCreatorB0ToDPi { // Filling particle properties rowCandidateFullParticles.reserve(particles.size()); for (const auto& particle : particles) { - if (TESTBIT(std::abs(particle.flagMcMatchGen()), aod::hf_cand_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi)) { + if (std::abs(particle.flagMcMatchGen()) == DecayChannelMain::B0ToDminusPi) { rowCandidateFullParticles( particle.mcCollision().bcId(), particle.pt(), diff --git a/PWGHF/TableProducer/treeCreatorBplusToD0Pi.cxx b/PWGHF/TableProducer/treeCreatorBplusToD0Pi.cxx index fdc18d3b3e0..cd9665de50c 100644 --- a/PWGHF/TableProducer/treeCreatorBplusToD0Pi.cxx +++ b/PWGHF/TableProducer/treeCreatorBplusToD0Pi.cxx @@ -17,17 +17,30 @@ /// /// \author Antonio Palasciano , Università & INFN, Bari -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_decay::hf_cand_beauty; namespace o2::aod { @@ -232,8 +245,8 @@ struct HfTreeCreatorBplusToD0Pi { Filter filterSelectCandidates = aod::hf_sel_candidate_bplus::isSelBplusToD0Pi >= selectionFlagBplus; - Partition recSig = nabs(aod::hf_cand_bplus::flagMcMatchRec) == (int8_t)BIT(aod::hf_cand_bplus::DecayTypeMc::BplusToD0PiToKPiPi); - Partition recBg = nabs(aod::hf_cand_bplus::flagMcMatchRec) != (int8_t)BIT(aod::hf_cand_bplus::DecayTypeMc::BplusToD0PiToKPiPi); + Partition recSig = nabs(aod::hf_cand_bplus::flagMcMatchRec) == static_cast(DecayChannelMain::BplusToD0Pi); + Partition recBg = nabs(aod::hf_cand_bplus::flagMcMatchRec) != static_cast(DecayChannelMain::BplusToD0Pi); void init(InitContext const&) { @@ -389,7 +402,7 @@ struct HfTreeCreatorBplusToD0Pi { } for (const auto& candidate : candidates) { if (fillOnlyBackground) { - float pseudoRndm = candidate.ptProng1() * 1000. - (int64_t)(candidate.ptProng1() * 1000); + float pseudoRndm = candidate.ptProng1() * 1000. - static_cast(candidate.ptProng1() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -429,7 +442,7 @@ struct HfTreeCreatorBplusToD0Pi { rowCandidateLite.reserve(recBg.size()); } for (const auto& candidate : recBg) { - float pseudoRndm = candidate.ptProng1() * 1000. - (int64_t)(candidate.ptProng1() * 1000); + float pseudoRndm = candidate.ptProng1() * 1000. - static_cast(candidate.ptProng1() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -450,7 +463,7 @@ struct HfTreeCreatorBplusToD0Pi { // Filling particle properties rowCandidateFullParticles.reserve(particles.size()); for (const auto& particle : particles) { - if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_bplus::DecayTypeMc::BplusToD0PiToKPiPi) { + if (std::abs(particle.flagMcMatchGen()) == DecayChannelMain::BplusToD0Pi) { rowCandidateFullParticles( particle.mcCollision().bcId(), particle.mcCollisionId(), diff --git a/PWGHF/TableProducer/treeCreatorBsToDsPi.cxx b/PWGHF/TableProducer/treeCreatorBsToDsPi.cxx index 542ed264892..3c639967995 100644 --- a/PWGHF/TableProducer/treeCreatorBsToDsPi.cxx +++ b/PWGHF/TableProducer/treeCreatorBsToDsPi.cxx @@ -16,17 +16,29 @@ /// \note Adapted from treeCreatorB0T0DPi.cxx /// \author Phil Stahlhut -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_decay::hf_cand_beauty; namespace o2::aod { @@ -172,8 +184,8 @@ struct HfTreeCreatorBsToDsPi { Filter filterSelectCandidates = aod::hf_sel_candidate_bs::isSelBsToDsPi >= selectionFlagBs; - Partition recSig = nabs(aod::hf_cand_bs::flagMcMatchRec) == (int8_t)BIT(aod::hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi); - Partition recBg = nabs(aod::hf_cand_bs::flagMcMatchRec) != (int8_t)BIT(aod::hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi); + Partition recSig = nabs(aod::hf_cand_bs::flagMcMatchRec) == static_cast(DecayChannelMain::BsToDsPi); + Partition recBg = nabs(aod::hf_cand_bs::flagMcMatchRec) != static_cast(DecayChannelMain::BsToDsPi); void init(InitContext const&) { @@ -290,7 +302,7 @@ struct HfTreeCreatorBsToDsPi { } for (const auto& candidate : candidates) { if (fillOnlyBackground && downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng1() * 1000. - (int64_t)(candidate.ptProng1() * 1000); + float pseudoRndm = candidate.ptProng1() * 1000. - static_cast(candidate.ptProng1() * 1000); if (pseudoRndm >= downSampleBkgFactor && candidate.pt() < ptMaxForDownSample) { continue; } @@ -330,7 +342,7 @@ struct HfTreeCreatorBsToDsPi { rowCandidateLite.reserve(recBg.size()); } for (const auto& candidate : recBg) { - float pseudoRndm = candidate.ptProng1() * 1000. - (int64_t)(candidate.ptProng1() * 1000); + float pseudoRndm = candidate.ptProng1() * 1000. - static_cast(candidate.ptProng1() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -351,7 +363,7 @@ struct HfTreeCreatorBsToDsPi { // Filling particle properties rowCandidateFullParticles.reserve(particles.size()); for (const auto& particle : particles) { - if (TESTBIT(std::abs(particle.flagMcMatchGen()), aod::hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi)) { + if (std::abs(particle.flagMcMatchGen()) == DecayChannelMain::BsToDsPi) { rowCandidateFullParticles( particle.mcCollision().bcId(), particle.pt(), diff --git a/PWGHF/TableProducer/treeCreatorD0ToKPi.cxx b/PWGHF/TableProducer/treeCreatorD0ToKPi.cxx index 2b2a7a84ef5..bda20c52903 100644 --- a/PWGHF/TableProducer/treeCreatorD0ToKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorD0ToKPi.cxx @@ -17,14 +17,27 @@ /// \author Nicolo' Jacazio , CERN /// \author Andrea Tavira García , IJCLab -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -72,6 +85,8 @@ DECLARE_SOA_COLUMN(Ct, ct, float); DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float); DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float); DECLARE_SOA_COLUMN(FlagMc, flagMc, int8_t); +DECLARE_SOA_COLUMN(FlagMcDecayChanRec, flagMcDecayChanRec, int8_t); +DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); // is prompt or non-prompt, reco level DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); // is prompt or non-prompt, Gen level DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfCand2Prong, "_0"); @@ -81,6 +96,12 @@ DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); DECLARE_SOA_COLUMN(RunNumber, runNumber, int); DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); } // namespace full +namespace ml +{ +DECLARE_SOA_COLUMN(BdtOutputBkg, bdtOutputBkg, float); +DECLARE_SOA_COLUMN(BdtOutputPrompt, bdtOutputPrompt, float); +DECLARE_SOA_COLUMN(BdtOutputNonPrompt, bdtOutputNonPrompt, float); +} // namespace ml DECLARE_SOA_TABLE(HfCandD0Lites, "AOD", "HFCANDD0LITE", hf_cand::Chi2PCA, @@ -117,6 +138,7 @@ DECLARE_SOA_TABLE(HfCandD0Lites, "AOD", "HFCANDD0LITE", full::Phi, full::Y, full::FlagMc, + full::FlagMcDecayChanRec, full::OriginMcRec) DECLARE_SOA_TABLE(HfCandD0Fulls, "AOD", "HFCANDD0FULL", @@ -179,6 +201,7 @@ DECLARE_SOA_TABLE(HfCandD0Fulls, "AOD", "HFCANDD0FULL", full::Y, full::E, full::FlagMc, + full::FlagMcDecayChanRec, full::OriginMcRec, full::CandidateId); @@ -198,9 +221,15 @@ DECLARE_SOA_TABLE(HfCandD0FullPs, "AOD", "HFCANDD0FULLP", full::Phi, full::Y, full::FlagMc, + full::FlagMcDecayChanGen, full::OriginMcGen, full::McParticleId); +DECLARE_SOA_TABLE(HfCandD0Mls, "AOD", "HFCANDD0ML", + ml::BdtOutputBkg, + ml::BdtOutputNonPrompt, + ml::BdtOutputPrompt); + } // namespace o2::aod /// Writes the full information in an output TTree @@ -209,30 +238,42 @@ struct HfTreeCreatorD0ToKPi { Produces rowCandidateFullEvents; Produces rowCandidateFullParticles; Produces rowCandidateLite; + Produces rowCandidateMl; Configurable fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"}; // parameters for production of training samples Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable fillCorrBkgs{"fillCorrBkgs", false, "Flag to fill derived tables with correlated background candidates"}; HfHelper hfHelper; // using TracksWPid = soa::Join; using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMcMl = soa::Filtered>; using SelectedCandidatesMcKf = soa::Filtered>; + using SelectedCandidatesMcKfMl = soa::Filtered>; using MatchedGenCandidatesMc = soa::Filtered>; Filter filterSelectCandidates = aod::hf_sel_candidate_d0::isSelD0 >= 1 || aod::hf_sel_candidate_d0::isSelD0bar >= 1; - Filter filterMcGenMatching = nabs(aod::hf_cand_2prong::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); + Filter filterMcGenMatching = nabs(aod::hf_cand_2prong::flagMcMatchGen) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || (fillCorrBkgs && (nabs(aod::hf_cand_2prong::flagMcMatchGen) != 0)); + + Partition reconstructedCandSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || (fillCorrBkgs && nabs(aod::hf_cand_2prong::flagMcMatchRec) != 0); + Partition reconstructedCandBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + Partition reconstructedCandSigKF = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || (fillCorrBkgs && nabs(aod::hf_cand_2prong::flagMcMatchRec) != 0); + Partition reconstructedCandBkgKF = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); - Partition reconstructedCandSig = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition reconstructedCandBkg = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition reconstructedCandSigKF = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); - Partition reconstructedCandBkgKF = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_2prong::DecayType::D0ToPiK)); + Partition reconstructedCandSigMl = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || (fillCorrBkgs && nabs(aod::hf_cand_2prong::flagMcMatchRec) != 0); + Partition reconstructedCandBkgMl = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); + Partition reconstructedCandSigKFMl = nabs(aod::hf_cand_2prong::flagMcMatchRec) == static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || (fillCorrBkgs && nabs(aod::hf_cand_2prong::flagMcMatchRec) != 0); + Partition reconstructedCandBkgKFMl = nabs(aod::hf_cand_2prong::flagMcMatchRec) != static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); void init(InitContext const&) { - std::array doprocess{doprocessDataWithDCAFitterN, doprocessDataWithKFParticle, doprocessMcWithDCAFitterOnlySig, doprocessMcWithDCAFitterOnlyBkg, doprocessMcWithDCAFitterAll, doprocessMcWithKFParticleOnlySig, doprocessMcWithKFParticleOnlyBkg, doprocessMcWithKFParticleAll}; + std::array doprocess{doprocessDataWithDCAFitterN, doprocessDataWithKFParticle, doprocessMcWithDCAFitterOnlySig, doprocessMcWithDCAFitterOnlyBkg, + doprocessMcWithDCAFitterAll, doprocessMcWithKFParticleOnlySig, doprocessMcWithKFParticleOnlyBkg, doprocessMcWithKFParticleAll, + doprocessDataWithDCAFitterNMl, doprocessDataWithKFParticleMl, doprocessMcWithDCAFitterOnlySigMl, doprocessMcWithDCAFitterOnlyBkgMl, + doprocessMcWithDCAFitterAllMl, doprocessMcWithKFParticleOnlySigMl, doprocessMcWithKFParticleOnlyBkgMl, doprocessMcWithKFParticleAllMl}; if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { LOGP(fatal, "Only one process function can be enabled at a time."); } @@ -251,9 +292,9 @@ struct HfTreeCreatorD0ToKPi { runNumber); } - template - auto fillTable(const T& candidate, int candFlag, double invMass, double cosThetaStar, double topoChi2, - double ct, double y, double e, int8_t flagMc, int8_t origin) + template + auto fillTable(const T& candidate, int candFlag, double invMass, double topoChi2, + double ct, double y, double e, int8_t flagMc, int8_t flagMcDecay, int8_t origin) { if (fillCandidateLiteTable) { rowCandidateLite( @@ -291,8 +332,10 @@ struct HfTreeCreatorD0ToKPi { candidate.phi(), y, flagMc, + flagMcDecay, origin); } else { + double cosThetaStar = candFlag == 0 ? hfHelper.cosThetaStarD0(candidate) : hfHelper.cosThetaStarD0bar(candidate); rowCandidateFull( candidate.collisionId(), candidate.posX(), @@ -353,12 +396,26 @@ struct HfTreeCreatorD0ToKPi { y, e, flagMc, + flagMcDecay, origin, candidate.globalIndex()); } + if constexpr (applyMl) { + if (candFlag == 0) { + rowCandidateMl( + candidate.mlProbD0()[0], + candidate.mlProbD0()[1], + candidate.mlProbD0()[2]); + } else if (candFlag == 1) { + rowCandidateMl( + candidate.mlProbD0bar()[0], + candidate.mlProbD0bar()[1], + candidate.mlProbD0bar()[2]); + } + } } - template + template void processData(aod::Collisions const& collisions, CandType const& candidates, aod::Tracks const&, aod::BCs const&) @@ -375,9 +432,12 @@ struct HfTreeCreatorD0ToKPi { } else { rowCandidateFull.reserve(candidates.size()); } + if constexpr (applyMl) { + rowCandidateMl.reserve(candidates.size()); + } for (const auto& candidate : candidates) { if (downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -396,10 +456,10 @@ struct HfTreeCreatorD0ToKPi { massD0bar = hfHelper.invMassD0barToKPi(candidate); } if (candidate.isSelD0()) { - fillTable(candidate, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0); + fillTable(candidate, 0, massD0, topolChi2PerNdf, ctD, yD, eD, 0, 0, 0); } if (candidate.isSelD0bar()) { - fillTable(candidate, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0); + fillTable(candidate, 1, massD0bar, topolChi2PerNdf, ctD, yD, eD, 0, 0, 0); } } } @@ -409,20 +469,38 @@ struct HfTreeCreatorD0ToKPi { aod::Tracks const& tracks, aod::BCs const& bcs) { - processData(collisions, candidates, tracks, bcs); + processData(collisions, candidates, tracks, bcs); } PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processDataWithDCAFitterN, "Process data with DCAFitterN", true); + void processDataWithDCAFitterNMl(aod::Collisions const& collisions, + soa::Filtered> const& candidates, + aod::Tracks const& tracks, + aod::BCs const& bcs) + { + processData(collisions, candidates, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processDataWithDCAFitterNMl, "Process data with DCAFitterN and ML", false); + void processDataWithKFParticle(aod::Collisions const& collisions, soa::Filtered> const& candidates, aod::Tracks const& tracks, aod::BCs const& bcs) { - processData(collisions, candidates, tracks, bcs); + processData(collisions, candidates, tracks, bcs); } PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processDataWithKFParticle, "Process data with KFParticle", false); - template + void processDataWithKFParticleMl(aod::Collisions const& collisions, + soa::Filtered> const& candidates, + aod::Tracks const& tracks, + aod::BCs const& bcs) + { + processData(collisions, candidates, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processDataWithKFParticleMl, "Process data with KFParticle and ML", false); + + template void processMc(aod::Collisions const& collisions, aod::McCollisions const&, CandType const& candidates, @@ -442,20 +520,23 @@ struct HfTreeCreatorD0ToKPi { } else { rowCandidateFull.reserve(candidates.size()); } + if constexpr (applyMl) { + rowCandidateMl.reserve(candidates.size()); + } for (const auto& candidate : candidates) { if constexpr (onlyBkg) { - if (TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if ((std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || (fillCorrBkgs && (candidate.flagMcMatchRec() != 0))) { continue; } if (downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } } } if constexpr (onlySig) { - if (!TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if ((std::abs(candidate.flagMcMatchRec()) != o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || (fillCorrBkgs && (candidate.flagMcMatchRec() != 0))) { continue; } } @@ -473,17 +554,17 @@ struct HfTreeCreatorD0ToKPi { massD0bar = hfHelper.invMassD0barToKPi(candidate); } if (candidate.isSelD0()) { - fillTable(candidate, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec()); + fillTable(candidate, 0, massD0, topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.flagMcDecayChanRec(), candidate.originMcRec()); } if (candidate.isSelD0bar()) { - fillTable(candidate, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec()); + fillTable(candidate, 1, massD0bar, topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.flagMcDecayChanRec(), candidate.originMcRec()); } } // Filling particle properties rowCandidateFullParticles.reserve(mcParticles.size()); for (const auto& particle : mcParticles) { - if (TESTBIT(std::abs(particle.flagMcMatchGen()), aod::hf_cand_2prong::DecayType::D0ToPiK)) { + if ((std::abs(particle.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) || (fillCorrBkgs && particle.flagMcMatchGen() != 0)) { rowCandidateFullParticles( particle.mcCollisionId(), particle.pt(), @@ -491,6 +572,7 @@ struct HfTreeCreatorD0ToKPi { particle.phi(), RecoDecay::y(particle.pVector(), o2::constants::physics::MassD0), particle.flagMcMatchGen(), + particle.flagMcDecayChanGen(), particle.originMcGen(), particle.globalIndex()); } @@ -504,10 +586,21 @@ struct HfTreeCreatorD0ToKPi { aod::Tracks const& tracks, aod::BCs const& bcs) { - processMc(collisions, mcCollisions, reconstructedCandSig, mcParticles, tracks, bcs); + processMc(collisions, mcCollisions, reconstructedCandSig, mcParticles, tracks, bcs); } PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithDCAFitterOnlySig, "Process MC with DCAFitterN only for signals", false); + void processMcWithDCAFitterOnlySigMl(aod::Collisions const& collisions, + aod::McCollisions const& mcCollisions, + SelectedCandidatesMcMl const&, + MatchedGenCandidatesMc const& mcParticles, + aod::Tracks const& tracks, + aod::BCs const& bcs) + { + processMc(collisions, mcCollisions, reconstructedCandSigMl, mcParticles, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithDCAFitterOnlySigMl, "Process MC with DCAFitterN only for signals and ML", false); + void processMcWithDCAFitterOnlyBkg(aod::Collisions const& collisions, aod::McCollisions const& mcCollisions, SelectedCandidatesMc const&, @@ -515,10 +608,21 @@ struct HfTreeCreatorD0ToKPi { aod::Tracks const& tracks, aod::BCs const& bcs) { - processMc(collisions, mcCollisions, reconstructedCandBkg, mcParticles, tracks, bcs); + processMc(collisions, mcCollisions, reconstructedCandBkg, mcParticles, tracks, bcs); } PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithDCAFitterOnlyBkg, "Process MC with DCAFitterN only for background", false); + void processMcWithDCAFitterOnlyBkgMl(aod::Collisions const& collisions, + aod::McCollisions const& mcCollisions, + SelectedCandidatesMcMl const&, + MatchedGenCandidatesMc const& mcParticles, + aod::Tracks const& tracks, + aod::BCs const& bcs) + { + processMc(collisions, mcCollisions, reconstructedCandBkgMl, mcParticles, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithDCAFitterOnlyBkgMl, "Process MC with DCAFitterN only for background with ML", false); + void processMcWithDCAFitterAll(aod::Collisions const& collisions, aod::McCollisions const& mcCollisions, SelectedCandidatesMc const& candidates, @@ -526,10 +630,21 @@ struct HfTreeCreatorD0ToKPi { aod::Tracks const& tracks, aod::BCs const& bcs) { - processMc(collisions, mcCollisions, candidates, mcParticles, tracks, bcs); + processMc(collisions, mcCollisions, candidates, mcParticles, tracks, bcs); } PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithDCAFitterAll, "Process MC with DCAFitterN", false); + void processMcWithDCAFitterAllMl(aod::Collisions const& collisions, + aod::McCollisions const& mcCollisions, + SelectedCandidatesMcMl const& candidates, + MatchedGenCandidatesMc const& mcParticles, + aod::Tracks const& tracks, + aod::BCs const& bcs) + { + processMc(collisions, mcCollisions, candidates, mcParticles, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithDCAFitterAllMl, "Process MC with DCAFitterN with ML", false); + void processMcWithKFParticleOnlySig(aod::Collisions const& collisions, aod::McCollisions const& mcCollisions, SelectedCandidatesMcKf const&, @@ -537,10 +652,21 @@ struct HfTreeCreatorD0ToKPi { aod::Tracks const& tracks, aod::BCs const& bcs) { - processMc(collisions, mcCollisions, reconstructedCandSigKF, mcParticles, tracks, bcs); + processMc(collisions, mcCollisions, reconstructedCandSigKF, mcParticles, tracks, bcs); } PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithKFParticleOnlySig, "Process MC with KFParticle only for signals", false); + void processMcWithKFParticleOnlySigMl(aod::Collisions const& collisions, + aod::McCollisions const& mcCollisions, + SelectedCandidatesMcKfMl const&, + MatchedGenCandidatesMc const& mcParticles, + aod::Tracks const& tracks, + aod::BCs const& bcs) + { + processMc(collisions, mcCollisions, reconstructedCandSigKFMl, mcParticles, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithKFParticleOnlySigMl, "Process MC with KFParticle only for signals with ML", false); + void processMcWithKFParticleOnlyBkg(aod::Collisions const& collisions, aod::McCollisions const& mcCollisions, SelectedCandidatesMcKf const&, @@ -548,10 +674,21 @@ struct HfTreeCreatorD0ToKPi { aod::Tracks const& tracks, aod::BCs const& bcs) { - processMc(collisions, mcCollisions, reconstructedCandBkgKF, mcParticles, tracks, bcs); + processMc(collisions, mcCollisions, reconstructedCandBkgKF, mcParticles, tracks, bcs); } PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithKFParticleOnlyBkg, "Process MC with KFParticle only for background", false); + void processMcWithKFParticleOnlyBkgMl(aod::Collisions const& collisions, + aod::McCollisions const& mcCollisions, + SelectedCandidatesMcKfMl const&, + MatchedGenCandidatesMc const& mcParticles, + aod::Tracks const& tracks, + aod::BCs const& bcs) + { + processMc(collisions, mcCollisions, reconstructedCandBkgKFMl, mcParticles, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithKFParticleOnlyBkgMl, "Process MC with KFParticle only for background with ML", false); + void processMcWithKFParticleAll(aod::Collisions const& collisions, aod::McCollisions const& mcCollisions, SelectedCandidatesMcKf const& candidates, @@ -559,9 +696,20 @@ struct HfTreeCreatorD0ToKPi { aod::Tracks const& tracks, aod::BCs const& bcs) { - processMc(collisions, mcCollisions, candidates, mcParticles, tracks, bcs); + processMc(collisions, mcCollisions, candidates, mcParticles, tracks, bcs); } PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithKFParticleAll, "Process MC with KFParticle", false); + + void processMcWithKFParticleAllMl(aod::Collisions const& collisions, + aod::McCollisions const& mcCollisions, + SelectedCandidatesMcKfMl const& candidates, + MatchedGenCandidatesMc const& mcParticles, + aod::Tracks const& tracks, + aod::BCs const& bcs) + { + processMc(collisions, mcCollisions, candidates, mcParticles, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processMcWithKFParticleAllMl, "Process MC with KFParticle with ML", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/treeCreatorDplusToPiKPi.cxx b/PWGHF/TableProducer/treeCreatorDplusToPiKPi.cxx index 5933bda7118..cc684c7003f 100644 --- a/PWGHF/TableProducer/treeCreatorDplusToPiKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorDplusToPiKPi.cxx @@ -16,17 +16,31 @@ /// /// \author Alexandre Bigot , IPHC Strasbourg -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_centrality; namespace o2::aod { @@ -50,6 +64,7 @@ DECLARE_SOA_COLUMN(Y, y, float); DECLARE_SOA_COLUMN(Eta, eta, float); //! Pseudorapidity of candidate DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuth angle of candidate DECLARE_SOA_COLUMN(E, e, float); //! Energy of candidate (GeV) +DECLARE_SOA_COLUMN(Centrality, centrality, float); //! Collision centrality DECLARE_SOA_COLUMN(NSigTpcPi0, nSigTpcPi0, float); //! TPC Nsigma separation for prong0 with pion mass hypothesis DECLARE_SOA_COLUMN(NSigTpcKa0, nSigTpcKa0, float); //! TPC Nsigma separation for prong0 with kaon mass hypothesis DECLARE_SOA_COLUMN(NSigTofPi0, nSigTofPi0, float); //! TOF Nsigma separation for prong0 with pion mass hypothesis @@ -79,7 +94,13 @@ DECLARE_SOA_COLUMN(Ct, ct, float); // Events DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); //! Event rejection flag DECLARE_SOA_COLUMN(RunNumber, runNumber, int); //! Run number +// ML scores +DECLARE_SOA_COLUMN(MlScore0, mlScore0, float); //! ML score of the first configured index +DECLARE_SOA_COLUMN(MlScore1, mlScore1, float); //! ML score of the second configured index } // namespace full +DECLARE_SOA_TABLE(HfCandDpMls, "AOD", "HFCANDDPML", + full::MlScore0, + full::MlScore1) DECLARE_SOA_TABLE(HfCandDpLites, "AOD", "HFCANDDPLITE", hf_cand::Chi2PCA, @@ -123,12 +144,13 @@ DECLARE_SOA_TABLE(HfCandDpLites, "AOD", "HFCANDDPLITE", full::Eta, full::Phi, full::Y, + full::Centrality, + collision::NumContrib, hf_cand_3prong::FlagMcMatchRec, hf_cand_3prong::OriginMcRec, hf_cand_3prong::FlagMcDecayChanRec) DECLARE_SOA_TABLE(HfCandDpFulls, "AOD", "HFCANDDPFULL", - collision::BCId, collision::NumContrib, collision::PosX, collision::PosY, @@ -204,12 +226,12 @@ DECLARE_SOA_TABLE(HfCandDpFulls, "AOD", "HFCANDDPFULL", full::Phi, full::Y, full::E, + full::Centrality, hf_cand_3prong::FlagMcMatchRec, hf_cand_3prong::OriginMcRec, hf_cand_3prong::FlagMcDecayChanRec); DECLARE_SOA_TABLE(HfCandDpFullEvs, "AOD", "HFCANDDPFULLEV", - collision::BCId, collision::NumContrib, collision::PosX, collision::PosY, @@ -218,12 +240,12 @@ DECLARE_SOA_TABLE(HfCandDpFullEvs, "AOD", "HFCANDDPFULLEV", full::RunNumber); DECLARE_SOA_TABLE(HfCandDpFullPs, "AOD", "HFCANDDPFULLP", - collision::BCId, full::Pt, full::Eta, full::Phi, full::Y, - hf_cand_3prong::FlagMcMatchRec, + hf_cand_3prong::FlagMcMatchGen, + hf_cand_3prong::FlagMcDecayChanGen, hf_cand_3prong::OriginMcGen); } // namespace o2::aod @@ -233,26 +255,34 @@ struct HfTreeCreatorDplusToPiKPi { Produces rowCandidateFullEvents; Produces rowCandidateFullParticles; Produces rowCandidateLite; + Produces rowCandidateMl; Configurable selectionFlagDplus{"selectionFlagDplus", 1, "Selection Flag for Dplus"}; Configurable fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"}; // parameters for production of training samples Configurable fillOnlySignal{"fillOnlySignal", false, "Flag to fill derived tables with signal for ML trainings"}; + Configurable fillCorrBkgs{"fillCorrBkgs", false, "Flag to fill derived tables with correlated background candidates"}; Configurable fillOnlyBackground{"fillOnlyBackground", false, "Flag to fill derived tables with background for ML trainings"}; Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable> classMlIndexes{"classMlIndexes", {0, 2}, "Indexes of ML bkg and non-prompt scores."}; + Configurable centEstimator{"centEstimator", 0, "Centrality estimation (None: 0, FT0C: 2, FT0M: 3)"}; HfHelper hfHelper; - using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMc = soa::Filtered>; using MatchedGenCandidatesMc = soa::Filtered>; + using SelectedCandidatesMcWithMl = soa::Filtered>; using TracksWPid = soa::Join; + using CollisionsCent = soa::Join; + Filter filterSelectCandidates = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlagDplus; - Filter filterMcGenMatching = nabs(o2::aod::hf_cand_3prong::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)); + Filter filterMcGenMatching = (nabs(o2::aod::hf_cand_3prong::flagMcMatchGen) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi)) || (fillCorrBkgs && (nabs(o2::aod::hf_cand_3prong::flagMcMatchGen) != 0)); - Partition reconstructedCandSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)) || nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)); // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π± - Partition reconstructedCandBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)); + Partition reconstructedCandSig = (nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi)) || (fillCorrBkgs && (nabs(o2::aod::hf_cand_3prong::flagMcMatchRec) != 0)); + Partition reconstructedCandBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi); + Partition reconstructedCandSigMl = (nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi)) || (fillCorrBkgs && (nabs(o2::aod::hf_cand_3prong::flagMcMatchRec) != 0)); void init(InitContext const&) { @@ -262,7 +292,6 @@ struct HfTreeCreatorDplusToPiKPi { void fillEvent(const T& collision, int isEventReject, int runNumber) { rowCandidateFullEvents( - collision.bcId(), collision.numContrib(), collision.posX(), collision.posY(), @@ -271,7 +300,7 @@ struct HfTreeCreatorDplusToPiKPi { runNumber); } - template + template void fillCandidateTable(const T& candidate) { int8_t flagMc = 0; @@ -283,9 +312,21 @@ struct HfTreeCreatorDplusToPiKPi { channelMc = candidate.flagMcDecayChanRec(); } - auto prong0 = candidate.template prong0_as(); - auto prong1 = candidate.template prong1_as(); - auto prong2 = candidate.template prong2_as(); + std::vector outputMl = {-999., -999.}; + if constexpr (doMl) { + for (unsigned int iclass = 0; iclass < classMlIndexes->size(); iclass++) { + outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMlIndexes->at(iclass)]; + } + rowCandidateMl( + outputMl[0], + outputMl[1]); + } + + float cent{-1.}; + auto coll = candidate.template collision_as(); + if (std::is_same_v && centEstimator != CentralityEstimator::None) { + cent = getCentralityColl(coll, centEstimator); + } if (fillCandidateLiteTable) { rowCandidateLite( @@ -303,24 +344,24 @@ struct HfTreeCreatorDplusToPiKPi { candidate.impactParameterZ0(), candidate.impactParameterZ1(), candidate.impactParameterZ2(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaKa(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaKa(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaKa(), - prong1.tpcNSigmaPi(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaPi(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaPi(), - prong1.tpcTofNSigmaKa(), - prong2.tpcNSigmaPi(), - prong2.tpcNSigmaKa(), - prong2.tofNSigmaPi(), - prong2.tofNSigmaKa(), - prong2.tpcTofNSigmaPi(), - prong2.tpcTofNSigmaKa(), + candidate.nSigTpcPi0(), + candidate.nSigTpcKa0(), + candidate.nSigTofPi0(), + candidate.nSigTofKa0(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaKa0(), + candidate.nSigTpcPi1(), + candidate.nSigTpcKa1(), + candidate.nSigTofPi1(), + candidate.nSigTofKa1(), + candidate.tpcTofNSigmaPi1(), + candidate.tpcTofNSigmaKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcKa2(), + candidate.nSigTofPi2(), + candidate.nSigTofKa2(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaKa2(), candidate.isSelDplusToPiKPi(), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), @@ -330,13 +371,14 @@ struct HfTreeCreatorDplusToPiKPi { candidate.eta(), candidate.phi(), hfHelper.yDplus(candidate), + coll.numContrib(), + cent, flagMc, originMc, channelMc); } else { rowCandidateFull( - candidate.collision().bcId(), - candidate.collision().numContrib(), + coll.numContrib(), candidate.posX(), candidate.posY(), candidate.posZ(), @@ -381,24 +423,24 @@ struct HfTreeCreatorDplusToPiKPi { candidate.errorImpactParameterZ0(), candidate.errorImpactParameterZ1(), candidate.errorImpactParameterZ2(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaKa(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaKa(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaKa(), - prong1.tpcNSigmaPi(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaPi(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaPi(), - prong1.tpcTofNSigmaKa(), - prong2.tpcNSigmaPi(), - prong2.tpcNSigmaKa(), - prong2.tofNSigmaPi(), - prong2.tofNSigmaKa(), - prong2.tpcTofNSigmaPi(), - prong2.tpcTofNSigmaKa(), + candidate.nSigTpcPi0(), + candidate.nSigTpcKa0(), + candidate.nSigTofPi0(), + candidate.nSigTofKa0(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaKa0(), + candidate.nSigTpcPi1(), + candidate.nSigTpcKa1(), + candidate.nSigTofPi1(), + candidate.nSigTofKa1(), + candidate.tpcTofNSigmaPi1(), + candidate.tpcTofNSigmaKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcKa2(), + candidate.nSigTofPi2(), + candidate.nSigTofKa2(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaKa2(), candidate.isSelDplusToPiKPi(), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), @@ -411,6 +453,7 @@ struct HfTreeCreatorDplusToPiKPi { candidate.phi(), hfHelper.yDplus(candidate), hfHelper.eDplus(candidate), + cent, flagMc, originMc, channelMc); @@ -418,7 +461,7 @@ struct HfTreeCreatorDplusToPiKPi { } void processData(aod::Collisions const& collisions, - soa::Filtered> const& candidates, + soa::Filtered> const& candidates, TracksWPid const&) { // Filling event properties @@ -435,22 +478,20 @@ struct HfTreeCreatorDplusToPiKPi { } for (const auto& candidate : candidates) { if (downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } } - fillCandidateTable(candidate); + fillCandidateTable(candidate); } } PROCESS_SWITCH(HfTreeCreatorDplusToPiKPi, processData, "Process data", true); - void processMc(aod::Collisions const& collisions, - aod::McCollisions const&, - SelectedCandidatesMc const& candidates, - MatchedGenCandidatesMc const& particles, - TracksWPid const&) + void processDataWCent(CollisionsCent const& collisions, + soa::Filtered> const& candidates, + TracksWPid const&) { // Filling event properties rowCandidateFullEvents.reserve(collisions.size()); @@ -459,56 +500,122 @@ struct HfTreeCreatorDplusToPiKPi { } // Filling candidate properties - if (fillOnlySignal) { - if (fillCandidateLiteTable) { - rowCandidateLite.reserve(reconstructedCandSig.size()); - } else { - rowCandidateFull.reserve(reconstructedCandSig.size()); - } - for (const auto& candidate : reconstructedCandSig) { - fillCandidateTable(candidate); - } - } else if (fillOnlyBackground) { - if (fillCandidateLiteTable) { - rowCandidateLite.reserve(reconstructedCandBkg.size()); - } else { - rowCandidateFull.reserve(reconstructedCandBkg.size()); - } - for (const auto& candidate : reconstructedCandBkg) { - if (downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); - if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { - continue; - } + if (fillCandidateLiteTable) { + rowCandidateLite.reserve(candidates.size()); + } else { + rowCandidateFull.reserve(candidates.size()); + } + for (const auto& candidate : candidates) { + if (downSampleBkgFactor < 1.) { + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); + if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { + continue; } - fillCandidateTable(candidate); } + fillCandidateTable(candidate); + } + } + + PROCESS_SWITCH(HfTreeCreatorDplusToPiKPi, processDataWCent, "Process data with cent", false); + + template + void fillMcTables(CollType const& collisions, + aod::McCollisions const&, + CandTypeMcRec const& candidates, + CandTypeMcGen const& particles, + TracksWPid const&) + { + // Filling event properties + rowCandidateFullEvents.reserve(collisions.size()); + for (const auto& collision : collisions) { + fillEvent(collision, 0, 1); + } + + // Filling candidate properties + if (fillCandidateLiteTable) { + rowCandidateLite.reserve(candidates.size()); } else { - if (fillCandidateLiteTable) { - rowCandidateLite.reserve(candidates.size()); - } else { - rowCandidateFull.reserve(candidates.size()); - } - for (const auto& candidate : candidates) { - fillCandidateTable(candidate); + rowCandidateFull.reserve(candidates.size()); + } + for (const auto& candidate : candidates) { + if (downSampleBkgFactor < 1.) { + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); + if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { + continue; + } } + fillCandidateTable(candidate); } // Filling particle properties rowCandidateFullParticles.reserve(particles.size()); for (const auto& particle : particles) { rowCandidateFullParticles( - particle.mcCollision().bcId(), particle.pt(), particle.eta(), particle.phi(), RecoDecay::y(particle.pVector(), o2::constants::physics::MassDPlus), particle.flagMcMatchGen(), + particle.flagMcDecayChanGen(), particle.originMcGen()); } } + void processMc(aod::Collisions const& collisions, + aod::McCollisions const& mccollisions, + SelectedCandidatesMc const& candidates, + MatchedGenCandidatesMc const& particles, + TracksWPid const& tracks) + { + if (fillOnlySignal) { + fillMcTables(collisions, mccollisions, reconstructedCandSig, particles, tracks); + } else if (fillOnlyBackground) { + fillMcTables(collisions, mccollisions, reconstructedCandBkg, particles, tracks); + } else { + fillMcTables(collisions, mccollisions, candidates, particles, tracks); + } + } + PROCESS_SWITCH(HfTreeCreatorDplusToPiKPi, processMc, "Process MC", false); + + void processMcWCent(CollisionsCent const& collisions, + aod::McCollisions const& mccollisions, + SelectedCandidatesMc const& candidates, + MatchedGenCandidatesMc const& particles, + TracksWPid const& tracks) + { + if (fillOnlySignal) { + fillMcTables(collisions, mccollisions, reconstructedCandSig, particles, tracks); + } else if (fillOnlyBackground) { + fillMcTables(collisions, mccollisions, reconstructedCandBkg, particles, tracks); + } else { + fillMcTables(collisions, mccollisions, candidates, particles, tracks); + } + } + + PROCESS_SWITCH(HfTreeCreatorDplusToPiKPi, processMcWCent, "Process MC with cent", false); + + void processMcSgnWMl(aod::Collisions const& collisions, + aod::McCollisions const& mccollisions, + SelectedCandidatesMcWithMl const&, + MatchedGenCandidatesMc const& particles, + TracksWPid const& tracks) + { + fillMcTables(collisions, mccollisions, reconstructedCandSigMl, particles, tracks); + } + + PROCESS_SWITCH(HfTreeCreatorDplusToPiKPi, processMcSgnWMl, "Process MC signal with ML info", false); + + void processMcSgnWCentMl(CollisionsCent const& collisions, + aod::McCollisions const& mccollisions, + SelectedCandidatesMcWithMl const&, + MatchedGenCandidatesMc const& particles, + TracksWPid const& tracks) + { + fillMcTables(collisions, mccollisions, reconstructedCandSigMl, particles, tracks); + } + + PROCESS_SWITCH(HfTreeCreatorDplusToPiKPi, processMcSgnWCentMl, "Process MC signal with cent and ML info", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/treeCreatorDsToKKPi.cxx b/PWGHF/TableProducer/treeCreatorDsToKKPi.cxx index 99428bf1e42..de1c9984435 100644 --- a/PWGHF/TableProducer/treeCreatorDsToKKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorDsToKKPi.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2023 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -17,15 +17,30 @@ /// \author Stefano Politanò , Politecnico & INFN, Torino /// \author Fabio Catalano , CERN -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -229,6 +244,19 @@ DECLARE_SOA_TABLE(HfCandDsFullPs, "AOD", "HFCANDDSFULLP", hf_cand_3prong::OriginMcGen); } // namespace o2::aod +enum Mother : int8_t { + Ds, + Dplus +}; + +enum ResonantChannel : int8_t { + PhiPi = 1, + Kstar0K = 2 +}; + +static std::unordered_map> channelsResonant = {{{Mother::Ds, {{ResonantChannel::PhiPi, hf_decay::hf_cand_3prong::DecayChannelResonant::DsToPhiPi}, {ResonantChannel::Kstar0K, hf_decay::hf_cand_3prong::DecayChannelResonant::DsToKstar0K}}}, + {Mother::Dplus, {{ResonantChannel::PhiPi, hf_decay::hf_cand_3prong::DecayChannelResonant::DplusToPhiPi}, {ResonantChannel::Kstar0K, hf_decay::hf_cand_3prong::DecayChannelResonant::DplusToKstar0K}}}}}; + /// Writes the full information in an output TTree struct HfTreeCreatorDsToKKPi { Produces rowCandidateFull; @@ -236,7 +264,7 @@ struct HfTreeCreatorDsToKKPi { Produces rowCandidateFullParticles; Produces rowCandidateLite; - Configurable decayChannel{"decayChannel", 1, "Switch between decay channels: 1 for Ds/Dplus->PhiPi->KKpi, 2 for Ds/Dplus->K0*K->KKPi"}; + Configurable decayChannel{"decayChannel", 1, "Switch between resonant decay channels: 1 for Ds/Dplus->PhiPi->KKpi, 2 for Ds/Dplus->K0*K->KKPi"}; Configurable fillDplusMc{"fillDplusMc", false, "Switch to fill Dplus MC information"}; Configurable selectionFlagDs{"selectionFlagDs", 1, "Selection flag for Ds"}; Configurable fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"}; @@ -248,8 +276,8 @@ struct HfTreeCreatorDsToKKPi { HfHelper hfHelper; - using CandDsData = soa::Filtered>; - using CandDsMcReco = soa::Filtered>; + using CandDsData = soa::Filtered>; + using CandDsMcReco = soa::Filtered>; using CandDsMcGen = soa::Filtered>; using TracksWPid = soa::Join; @@ -257,19 +285,26 @@ struct HfTreeCreatorDsToKKPi { using CollisionsWithFT0M = soa::Join; using CollisionsWithNTracksPV = soa::Join; - int offsetDplusDecayChannel = aod::hf_cand_3prong::DecayChannelDToKKPi::DplusToPhiPi - aod::hf_cand_3prong::DecayChannelDToKKPi::DsToPhiPi; // Offset between Dplus and Ds to use the same decay channel. See aod::hf_cand_3prong::DecayChannelDToKKPi - Filter filterSelectCandidates = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlagDs || aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlagDs; - Filter filterMcGenMatching = nabs(o2::aod::hf_cand_3prong::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && (aod::hf_cand_3prong::flagMcDecayChanGen == decayChannel || (fillDplusMc && aod::hf_cand_3prong::flagMcDecayChanGen == (decayChannel + offsetDplusDecayChannel))); // Do not store Dplus MC if fillDplusMc is false + Filter filterMcGenMatching = + nabs(o2::aod::hf_cand_3prong::flagMcMatchGen) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && + (aod::hf_cand_3prong::flagMcDecayChanGen == channelsResonant[Mother::Ds][decayChannel] || + (fillDplusMc && aod::hf_cand_3prong::flagMcDecayChanGen == channelsResonant[Mother::Dplus][decayChannel])); // Do not store Dplus MC if fillDplusMc is false Partition selectedDsToKKPiCand = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlagDs; Partition selectedDsToPiKKCand = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlagDs; - Partition reconstructedCandSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && (aod::hf_cand_3prong::flagMcDecayChanRec == decayChannel || (fillDplusMc && aod::hf_cand_3prong::flagMcDecayChanRec == (decayChannel + offsetDplusDecayChannel))); // Do not store Dplus MC if fillDplusMc is false - Partition reconstructedCandBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)); + Partition reconstructedCandSig = (nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && aod::hf_cand_3prong::flagMcDecayChanRec == channelsResonant[Mother::Ds][decayChannel]) || (fillDplusMc && nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKK) && aod::hf_cand_3prong::flagMcDecayChanRec == channelsResonant[Mother::Dplus][decayChannel]); // Do not store Dplus MC if fillDplusMc is false + Partition reconstructedCandBkg = (nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKK)) || + (nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) && aod::hf_cand_3prong::flagMcDecayChanRec != channelsResonant[Mother::Ds][decayChannel]) || + (nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKK) && aod::hf_cand_3prong::flagMcDecayChanRec != channelsResonant[Mother::Dplus][decayChannel]) || + (!fillDplusMc && nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKK) && aod::hf_cand_3prong::flagMcDecayChanRec == channelsResonant[Mother::Dplus][decayChannel]); void init(InitContext const&) { + if (decayChannel != ResonantChannel::PhiPi && decayChannel != ResonantChannel::Kstar0K) { + LOGP(fatal, "Invalid value of decayChannel"); + } } template @@ -293,29 +328,6 @@ struct HfTreeCreatorDsToKKPi { template void fillCandidateTable(const T& candidate) { - int8_t flagMc = 0; - int8_t originMc = 0; - int8_t channelMc = 0; - int8_t isSwapped = massHypo; // 0 if KKPi, 1 if PiKK - float yCand = 0; - float eCand = 0; - float ctCand = 0; - if constexpr (doMc) { - flagMc = candidate.flagMcMatchRec(); - originMc = candidate.originMcRec(); - channelMc = candidate.flagMcDecayChanRec(); - isSwapped = candidate.isCandidateSwapped(); - if (fillDplusMc && candidate.flagMcDecayChanRec() == (decayChannel + offsetDplusDecayChannel)) { - yCand = hfHelper.yDplus(candidate); - eCand = hfHelper.eDplus(candidate); - ctCand = hfHelper.ctDplus(candidate); - } else { - yCand = hfHelper.yDs(candidate); - eCand = hfHelper.eDs(candidate); - ctCand = hfHelper.ctDs(candidate); - } - } - float invMassDs = 0; float deltaMassPhiKK = 0; float absCos3PiKDs = 0; @@ -329,6 +341,27 @@ struct HfTreeCreatorDsToKKPi { absCos3PiKDs = hfHelper.absCos3PiKDsToPiKK(candidate); } + int8_t flagMc{0}; + int8_t originMc{0}; + int8_t channelMc{0}; + int8_t isSwapped{massHypo}; // 0 if KKPi, 1 if PiKK + float eCand{0.f}; + float ctCand{0.f}; + float yCand = candidate.y(invMassDs); + if constexpr (doMc) { + flagMc = candidate.flagMcMatchRec(); + originMc = candidate.originMcRec(); + channelMc = candidate.flagMcDecayChanRec(); + isSwapped = candidate.isCandidateSwapped(); + if (fillDplusMc && candidate.flagMcDecayChanRec() == channelsResonant[Mother::Dplus][decayChannel]) { + eCand = hfHelper.eDplus(candidate); + ctCand = hfHelper.ctDplus(candidate); + } else { + eCand = hfHelper.eDs(candidate); + ctCand = hfHelper.ctDs(candidate); + } + } + auto const& collision = candidate.template collision_as(); float centrality = o2::hf_centrality::getCentralityColl(collision); @@ -344,24 +377,24 @@ struct HfTreeCreatorDsToKKPi { candidate.impactParameter0(), candidate.impactParameter1(), candidate.impactParameter2(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaKa(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaKa(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaKa(), - prong1.tpcNSigmaPi(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaPi(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaPi(), - prong1.tpcTofNSigmaKa(), - prong2.tpcNSigmaPi(), - prong2.tpcNSigmaKa(), - prong2.tofNSigmaPi(), - prong2.tofNSigmaKa(), - prong2.tpcTofNSigmaPi(), - prong2.tpcTofNSigmaKa(), + candidate.nSigTpcPi0(), + candidate.nSigTpcKa0(), + candidate.nSigTofPi0(), + candidate.nSigTofKa0(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaKa0(), + candidate.nSigTpcPi1(), + candidate.nSigTpcKa1(), + candidate.nSigTofPi1(), + candidate.nSigTofKa1(), + candidate.tpcTofNSigmaPi1(), + candidate.tpcTofNSigmaKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcKa2(), + candidate.nSigTofPi2(), + candidate.nSigTofKa2(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaKa2(), massHypo == 0 ? candidate.isSelDsToKKPi() : -1, massHypo == 1 ? candidate.isSelDsToPiKK() : -1, invMassDs, @@ -412,24 +445,24 @@ struct HfTreeCreatorDsToKKPi { candidate.impactParameter0(), candidate.impactParameter1(), candidate.impactParameter2(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaKa(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaKa(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaKa(), - prong1.tpcNSigmaPi(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaPi(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaPi(), - prong1.tpcTofNSigmaKa(), - prong2.tpcNSigmaPi(), - prong2.tpcNSigmaKa(), - prong2.tofNSigmaPi(), - prong2.tofNSigmaKa(), - prong2.tpcTofNSigmaPi(), - prong2.tpcTofNSigmaKa(), + candidate.nSigTpcPi0(), + candidate.nSigTpcKa0(), + candidate.nSigTofPi0(), + candidate.nSigTofKa0(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaKa0(), + candidate.nSigTpcPi1(), + candidate.nSigTpcKa1(), + candidate.nSigTofPi1(), + candidate.nSigTofKa1(), + candidate.tpcTofNSigmaPi1(), + candidate.tpcTofNSigmaKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcKa2(), + candidate.nSigTofPi2(), + candidate.nSigTofKa2(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaKa2(), massHypo == 0 ? candidate.isSelDsToKKPi() : -1, massHypo == 1 ? candidate.isSelDsToPiKK() : -1, candidate.xSecondaryVertex(), @@ -482,7 +515,7 @@ struct HfTreeCreatorDsToKKPi { for (const auto& candidate : selectedDsToKKPiCand) { if (downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -492,7 +525,7 @@ struct HfTreeCreatorDsToKKPi { for (const auto& candidate : selectedDsToPiKKCand) { if (downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -538,7 +571,7 @@ struct HfTreeCreatorDsToKKPi { for (const auto& candidate : reconstructedCandBkg) { if (downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -586,7 +619,7 @@ struct HfTreeCreatorDsToKKPi { particle.pt(), particle.eta(), particle.phi(), - RecoDecay::y(particle.pVector(), o2::constants::physics::MassDS), + std::abs(particle.pdgCode()) == o2::constants::physics::Pdg::kDS ? RecoDecay::y(particle.pVector(), o2::constants::physics::MassDS) : RecoDecay::y(particle.pVector(), o2::constants::physics::MassDPlus), particle.flagMcMatchGen(), particle.originMcGen()); } diff --git a/PWGHF/TableProducer/treeCreatorDstarToD0Pi.cxx b/PWGHF/TableProducer/treeCreatorDstarToD0Pi.cxx index fd11fad78b1..18ee43a111b 100644 --- a/PWGHF/TableProducer/treeCreatorDstarToD0Pi.cxx +++ b/PWGHF/TableProducer/treeCreatorDstarToD0Pi.cxx @@ -16,13 +16,23 @@ /// /// \author Fabrizio Grosa , CERN -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -255,16 +265,16 @@ struct HfTreeCreatorDstarToD0Pi { Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"}; Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; - using CandDstarWSelFlag = soa::Filtered>; - using CandDstarWSelFlagMcRec = soa::Filtered>; + using CandDstarWSelFlag = soa::Filtered>; + using CandDstarWSelFlagMcRec = soa::Filtered>; using TracksWPid = soa::Join; using CandDstarMcGen = soa::Filtered>; Filter filterSelectCandidates = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == selectionFlagDstarToD0Pi; - Filter filterMcGenMatching = nabs(aod::hf_cand_dstar::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_dstar::DecayType::DstarToD0Pi)); + Filter filterMcGenMatching = nabs(aod::hf_cand_dstar::flagMcMatchGen) == static_cast(hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi); - Partition reconstructedCandSig = nabs(aod::hf_cand_dstar::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_dstar::DecayType::DstarToD0Pi)); - Partition reconstructedCandBkg = nabs(aod::hf_cand_dstar::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_dstar::DecayType::DstarToD0Pi)); + Partition reconstructedCandSig = nabs(aod::hf_cand_dstar::flagMcMatchRec) == static_cast(hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi); + Partition reconstructedCandBkg = nabs(aod::hf_cand_dstar::flagMcMatchRec) != static_cast(hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi); void init(InitContext const&) { @@ -295,7 +305,6 @@ struct HfTreeCreatorDstarToD0Pi { TracksWPid::iterator prong0; TracksWPid::iterator prong1; - auto prongSoftPi = candidate.template prongPi_as(); float massD0{-1.f}; float massDStar{-1.f}; @@ -360,24 +369,24 @@ struct HfTreeCreatorDstarToD0Pi { impParameterNormalisedProng0, impParameterNormalisedProng1, candidate.normalisedImpParamSoftPi(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaKa(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaKa(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaKa(), - prong1.tpcNSigmaPi(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaPi(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaPi(), - prong1.tpcTofNSigmaKa(), - prongSoftPi.tpcNSigmaPi(), - prongSoftPi.tpcNSigmaKa(), - prongSoftPi.tofNSigmaPi(), - prongSoftPi.tofNSigmaKa(), - prongSoftPi.tpcTofNSigmaPi(), - prongSoftPi.tpcTofNSigmaKa(), + candidate.nSigTpcPi0(), + candidate.nSigTpcKa0(), + candidate.nSigTofPi0(), + candidate.nSigTofKa0(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaKa0(), + candidate.nSigTpcPi1(), + candidate.nSigTpcKa1(), + candidate.nSigTofPi1(), + candidate.nSigTofKa1(), + candidate.tpcTofNSigmaPi1(), + candidate.tpcTofNSigmaKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcKa2(), + candidate.nSigTofPi2(), + candidate.nSigTofKa2(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaKa2(), massD0, candidate.ptD0(), candidate.etaD0(), @@ -429,24 +438,24 @@ struct HfTreeCreatorDstarToD0Pi { candidate.errorImpactParameter0(), candidate.errorImpactParameter1(), candidate.errorImpParamSoftPi(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaKa(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaKa(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaKa(), - prong1.tpcNSigmaPi(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaPi(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaPi(), - prong1.tpcTofNSigmaKa(), - prongSoftPi.tpcNSigmaPi(), - prongSoftPi.tpcNSigmaKa(), - prongSoftPi.tofNSigmaPi(), - prongSoftPi.tofNSigmaKa(), - prongSoftPi.tpcTofNSigmaPi(), - prongSoftPi.tpcTofNSigmaKa(), + candidate.nSigTpcPi0(), + candidate.nSigTpcKa0(), + candidate.nSigTofPi0(), + candidate.nSigTofKa0(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaKa0(), + candidate.nSigTpcPi1(), + candidate.nSigTpcKa1(), + candidate.nSigTofPi1(), + candidate.nSigTofKa1(), + candidate.tpcTofNSigmaPi1(), + candidate.tpcTofNSigmaKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcKa2(), + candidate.nSigTofPi2(), + candidate.nSigTofKa2(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaKa2(), massD0, candidate.ptD0(), candidate.pD0(), diff --git a/PWGHF/TableProducer/treeCreatorLbToLcPi.cxx b/PWGHF/TableProducer/treeCreatorLbToLcPi.cxx index d69de17d4e8..a60a7eba661 100644 --- a/PWGHF/TableProducer/treeCreatorLbToLcPi.cxx +++ b/PWGHF/TableProducer/treeCreatorLbToLcPi.cxx @@ -18,13 +18,22 @@ /// \author Panos Christakoglou , Nikhef /// \author Maurice Jongerhuis , University Utrecht -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" + +#include +#include +#include +#include +#include + +#include + using namespace o2; using namespace o2::framework; @@ -192,7 +201,7 @@ struct HfTreeCreatorLbToLcPi { using TracksWPid = soa::Join; void process(soa::Join const& candidates, - soa::Join const&, + soa::Join const&, TracksWPid const&) { // Filling candidate properties @@ -202,7 +211,7 @@ struct HfTreeCreatorLbToLcPi { float FunctionInvMass, float FunctionCt, float FunctionY) { - auto candLc = candidate.prong0_as>(); + auto candLc = candidate.prong0_as>(); auto track0 = candidate.prong1_as(); // daughter pion track auto track1 = candLc.prong0_as(); // granddaughter tracks (lc decay particles) auto track2 = candLc.prong1_as(); @@ -245,18 +254,18 @@ struct HfTreeCreatorLbToLcPi { candidate.impactParameter1(), candidate.errorImpactParameter0(), candidate.errorImpactParameter1(), - track1.tpcNSigmaPi(), - track1.tpcNSigmaKa(), - track1.tpcNSigmaPr(), - track2.tpcNSigmaPi(), - track2.tpcNSigmaKa(), - track2.tpcNSigmaPr(), - track3.tpcNSigmaPi(), - track3.tpcNSigmaKa(), - track3.tpcNSigmaPr(), - track1.tofNSigmaPr(), - track2.tofNSigmaKa(), - track3.tofNSigmaPi(), + candLc.nSigTpcPi0(), + candLc.nSigTpcKa0(), + candLc.nSigTpcPr0(), + candLc.nSigTpcPi1(), + candLc.nSigTpcKa1(), + candLc.nSigTpcPr1(), + candLc.nSigTpcPi2(), + candLc.nSigTpcKa2(), + candLc.nSigTpcPr2(), + candLc.nSigTofPr0(), + candLc.nSigTofKa1(), + candLc.nSigTofPi2(), hfHelper.invMassLcToPKPi(candLc), hfHelper.ctLc(candLc), hfHelper.yLc(candLc), diff --git a/PWGHF/TableProducer/treeCreatorLcToK0sP.cxx b/PWGHF/TableProducer/treeCreatorLcToK0sP.cxx index 14ae8ab647c..0012108a45c 100644 --- a/PWGHF/TableProducer/treeCreatorLcToK0sP.cxx +++ b/PWGHF/TableProducer/treeCreatorLcToK0sP.cxx @@ -17,13 +17,24 @@ /// /// \author Daniel Samitz -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include using namespace o2; using namespace o2::framework; @@ -307,9 +318,9 @@ struct HfTreeCreatorLcToK0sP { candidate.impactParameter1(), candidate.errorImpactParameter0(), candidate.errorImpactParameter1(), - candidate.v0x(), - candidate.v0y(), - candidate.v0z(), + candidate.v0X(), + candidate.v0Y(), + candidate.v0Z(), candidate.v0radius(), candidate.v0cosPA(), candidate.mLambda(), @@ -387,7 +398,7 @@ struct HfTreeCreatorLcToK0sP { } for (const auto& candidate : recBkg) { if (downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } @@ -445,7 +456,7 @@ struct HfTreeCreatorLcToK0sP { } for (const auto& candidate : candidates) { auto bach = candidate.prong0_as(); // bachelor - double pseudoRndm = bach.pt() * 1000. - (int16_t)(bach.pt() * 1000); + double pseudoRndm = bach.pt() * 1000. - static_cast(bach.pt() * 1000); if (candidate.isSelLcToK0sP() >= 1 && pseudoRndm < downSampleBkgFactor) { fillCandidate(candidate, bach, 0, 0); } diff --git a/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx b/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx index 07f869382a1..90b47824835 100644 --- a/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx @@ -17,19 +17,38 @@ /// \author Nicolo' Jacazio , CERN /// \author Luigi Dello Stritto , CERN -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/Multiplicity.h" -#include "PWGHF/Core/HfHelper.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; +using namespace o2::constants::physics; namespace o2::aod { @@ -65,11 +84,11 @@ DECLARE_SOA_COLUMN(NSigTpcPi2, nSigTpcPi2, float); DECLARE_SOA_COLUMN(NSigTpcPr2, nSigTpcPr2, float); DECLARE_SOA_COLUMN(NSigTofPi2, nSigTofPi2, float); DECLARE_SOA_COLUMN(NSigTofPr2, nSigTofPr2, float); -DECLARE_SOA_COLUMN(NSigTpcTofPr0, nSigTpcTofPi0, float); -DECLARE_SOA_COLUMN(NSigTpcTofPi0, nSigTpcTofPr0, float); +DECLARE_SOA_COLUMN(NSigTpcTofPr0, nSigTpcTofPr0, float); +DECLARE_SOA_COLUMN(NSigTpcTofPi0, nSigTpcTofPi0, float); DECLARE_SOA_COLUMN(NSigTpcTofKa1, nSigTpcTofKa1, float); -DECLARE_SOA_COLUMN(NSigTpcTofPr2, nSigTpcTofPi2, float); -DECLARE_SOA_COLUMN(NSigTpcTofPi2, nSigTpcTofPr2, float); +DECLARE_SOA_COLUMN(NSigTpcTofPr2, nSigTpcTofPr2, float); +DECLARE_SOA_COLUMN(NSigTpcTofPi2, nSigTpcTofPi2, float); DECLARE_SOA_COLUMN(DecayLength, decayLength, float); DECLARE_SOA_COLUMN(DecayLengthXY, decayLengthXY, float); DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float); @@ -81,9 +100,12 @@ DECLARE_SOA_COLUMN(FlagMc, flagMc, int8_t); DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); DECLARE_SOA_COLUMN(IsCandidateSwapped, isCandidateSwapped, int8_t); -DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfCand3Prong, "_0"); +DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfCand3ProngWPidPiKaPr, "_0"); DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); DECLARE_SOA_COLUMN(Channel, channel, int8_t); // direct or resonant +DECLARE_SOA_COLUMN(MlScoreFirstClass, mlScoreFirstClass, float); +DECLARE_SOA_COLUMN(MlScoreSecondClass, mlScoreSecondClass, float); +DECLARE_SOA_COLUMN(MlScoreThirdClass, mlScoreThirdClass, float); // Events DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); @@ -96,31 +118,117 @@ DECLARE_SOA_COLUMN(CentFDDM, centFDDM, float); DECLARE_SOA_COLUMN(MultZeqNTracksPV, multZeqNTracksPV, float); } // namespace full +namespace kf +{ +DECLARE_SOA_COLUMN(X, x, float); //! decay vertex X coordinate +DECLARE_SOA_COLUMN(Y, y, float); //! decay vertex Y coordinate +DECLARE_SOA_COLUMN(Z, z, float); //! decay vertex Z coordinate +DECLARE_SOA_COLUMN(ErrX, errX, float); //! decay vertex X coordinate error +DECLARE_SOA_COLUMN(ErrY, errY, float); //! decay vertex Y coordinate error +DECLARE_SOA_COLUMN(ErrZ, errZ, float); //! decay vertex Z coordinate error +DECLARE_SOA_COLUMN(ErrPVX, errPVX, float); //! event vertex X coordinate error +DECLARE_SOA_COLUMN(ErrPVY, errPVY, float); //! event vertex Y coordinate error +DECLARE_SOA_COLUMN(ErrPVZ, errPVZ, float); //! event vertex Z coordinate error +DECLARE_SOA_COLUMN(Chi2PrimProton, chi2PrimProton, float); //! Chi2 of prong's approach to the PV +DECLARE_SOA_COLUMN(Chi2PrimKaon, chi2PrimKaon, float); //! Chi2 of prong's approach to the PV +DECLARE_SOA_COLUMN(Chi2PrimPion, chi2PrimPion, float); //! Chi2 of prong's approach to the PV +DECLARE_SOA_COLUMN(DcaProtonKaon, dcaProtonKaon, float); //! Distance of closest approach between 2 prongs, cm +DECLARE_SOA_COLUMN(DcaProtonPion, dcaProtonPion, float); //! Distance of closest approach between 2 prongs, cm +DECLARE_SOA_COLUMN(DcaPionKaon, dcaPionKaon, float); //! Distance of closest approach between 2 prongs, cm +DECLARE_SOA_COLUMN(Chi2GeoProtonKaon, chi2GeoProtonKaon, float); //! Chi2 of two prongs' approach to each other +DECLARE_SOA_COLUMN(Chi2GeoProtonPion, chi2GeoProtonPion, float); //! Chi2 of two prongs' approach to each other +DECLARE_SOA_COLUMN(Chi2GeoPionKaon, chi2GeoPionKaon, float); //! Chi2 of two prongs' approach to each other +DECLARE_SOA_COLUMN(Chi2Geo, chi2Geo, float); //! chi2 geo of the full candidate +DECLARE_SOA_COLUMN(Chi2Topo, chi2Topo, float); //! chi2 topo of the full candidate (chi2prim of candidate to PV) +DECLARE_SOA_COLUMN(DecayLength, decayLength, float); //! decay length, cm +DECLARE_SOA_COLUMN(DecayLengthError, decayLengthError, float); //! decay length error +DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float); //! decay length over its error +DECLARE_SOA_COLUMN(T, t, float); //! proper lifetime, ps +DECLARE_SOA_COLUMN(ErrT, errT, float); //! lifetime error +DECLARE_SOA_COLUMN(MassInv, massInv, float); //! invariant mass +DECLARE_SOA_COLUMN(P, p, float); //! momentum +DECLARE_SOA_COLUMN(Pt, pt, float); //! transverse momentum +DECLARE_SOA_COLUMN(ErrP, errP, float); //! momentum error +DECLARE_SOA_COLUMN(ErrPt, errPt, float); //! transverse momentum error +DECLARE_SOA_COLUMN(IsSelected, isSelected, int); //! flag whether candidate was selected in candidateSelectorLc task +DECLARE_SOA_COLUMN(SigBgStatus, sigBgStatus, int); //! 0 bg, 1 prompt, 2 non-prompt, 3 wrong order of prongs, -1 default value (impossible, should not be the case), -999 for data +DECLARE_SOA_COLUMN(NSigTpcPi, nSigTpcPi, float); +DECLARE_SOA_COLUMN(NSigTpcKa, nSigTpcKa, float); +DECLARE_SOA_COLUMN(NSigTpcPr, nSigTpcPr, float); +DECLARE_SOA_COLUMN(NSigTofPi, nSigTofPi, float); +DECLARE_SOA_COLUMN(NSigTofKa, nSigTofKa, float); +DECLARE_SOA_COLUMN(NSigTofPr, nSigTofPr, float); +DECLARE_SOA_COLUMN(NSigTpcTofPi, nSigTpcTofPi, float); +DECLARE_SOA_COLUMN(NSigTpcTofKa, nSigTpcTofKa, float); +DECLARE_SOA_COLUMN(NSigTpcTofPr, nSigTpcTofPr, float); +DECLARE_SOA_COLUMN(MultNTracksPV, multNTracksPV, int); +} // namespace kf + +namespace kf_collision +{ +DECLARE_SOA_COLUMN(PosXErr, posXErr, float); //! PV X coordinate uncertainty +DECLARE_SOA_COLUMN(PosYErr, posYErr, float); //! PV Y coordinate uncertainty +DECLARE_SOA_COLUMN(PosZErr, posZErr, float); //! PV Z coordinate uncertainty +DECLARE_SOA_COLUMN(McPosX, mcPosX, float); //! PV X coordinate uncertainty +DECLARE_SOA_COLUMN(McPosY, mcPosY, float); //! PV Y coordinate uncertainty +DECLARE_SOA_COLUMN(McPosZ, mcPosZ, float); //! PV Z coordinate uncertainty +} // namespace kf_collision + +namespace mc_match +{ +DECLARE_SOA_COLUMN(P, p, float); //! Momentum, GeV/c +DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum, GeV/c +DECLARE_SOA_COLUMN(XDecay, xDecay, float); //! Secondary (decay) vertex X coordinate, cm +DECLARE_SOA_COLUMN(YDecay, yDecay, float); //! Secondary (decay) vertex Y coordinate, cm +DECLARE_SOA_COLUMN(ZDecay, zDecay, float); //! Secondary (decay) vertex Z coordinate, cm +DECLARE_SOA_COLUMN(LDecay, lDecay, float); //! Decay length, cm (distance between PV and SV, curvature is neglected) +DECLARE_SOA_COLUMN(TDecay, tDecay, float); //! Proper lifetime, ps +DECLARE_SOA_COLUMN(XEvent, xEvent, float); //! Primary (event) vertex X coordinate, cm +DECLARE_SOA_COLUMN(YEvent, yEvent, float); //! Primary (event) vertex Y coordinate, cm +DECLARE_SOA_COLUMN(ZEvent, zEvent, float); //! Primary (event) vertex Z coordinate, cm +} // namespace mc_match + +DECLARE_SOA_TABLE(HfCandLcMCs, "AOD", "HFCANDLCMC", + mc_match::P, mc_match::Pt, + mc_match::XDecay, mc_match::YDecay, mc_match::ZDecay, mc_match::LDecay, + mc_match::TDecay, + mc_match::XEvent, mc_match::YEvent, mc_match::ZEvent) + +DECLARE_SOA_TABLE(HfCandLcKFs, "AOD", "HFCANDLCKF", + kf::X, kf::Y, kf::Z, kf::ErrX, kf::ErrY, kf::ErrZ, + kf::ErrPVX, kf::ErrPVY, kf::ErrPVZ, + kf::Chi2PrimProton, kf::Chi2PrimKaon, kf::Chi2PrimPion, + kf::DcaProtonKaon, kf::DcaProtonPion, kf::DcaPionKaon, + kf::Chi2GeoProtonKaon, kf::Chi2GeoProtonPion, kf::Chi2GeoPionKaon, + kf::Chi2Geo, kf::Chi2Topo, kf::DecayLength, kf::DecayLengthError, kf::DecayLengthNormalised, kf::T, kf::ErrT, + kf::MassInv, kf::P, kf::Pt, kf::ErrP, kf::ErrPt, + kf::IsSelected, kf::SigBgStatus, + kf::MultNTracksPV, + kf::NSigTpcPr, + kf::NSigTpcKa, + kf::NSigTpcPi, + kf::NSigTofPr, + kf::NSigTofKa, + kf::NSigTofPi, + kf::NSigTpcTofPr, + kf::NSigTpcTofKa, + kf::NSigTpcTofPi); + DECLARE_SOA_TABLE(HfCandLcLites, "AOD", "HFCANDLCLITE", collision::PosX, collision::PosY, collision::PosZ, hf_cand::NProngsContributorsPV, hf_cand::BitmapProngsContributorsPV, - // hf_cand::ErrorDecayLength, - // hf_cand::ErrorDecayLengthXY, hf_cand::Chi2PCA, full::DecayLength, full::DecayLengthXY, - // full::DecayLengthNormalised, - // full::DecayLengthXYNormalised, - // full::ImpactParameterNormalised0, full::PtProng0, - // full::ImpactParameterNormalised1, full::PtProng1, - // full::ImpactParameterNormalised2, full::PtProng2, hf_cand::ImpactParameter0, hf_cand::ImpactParameter1, hf_cand::ImpactParameter2, - // hf_cand::ErrorImpactParameter0, - // hf_cand::ErrorImpactParameter1, - // hf_cand::ErrorImpactParameter2, full::NSigTpcPi0, full::NSigTpcPr0, full::NSigTofPi0, @@ -149,7 +257,10 @@ DECLARE_SOA_TABLE(HfCandLcLites, "AOD", "HFCANDLCLITE", full::OriginMcRec, full::IsCandidateSwapped, full::Channel, - full::MassKPi); + full::MassKPi, + full::MlScoreFirstClass, + full::MlScoreSecondClass, + full::MlScoreThirdClass); DECLARE_SOA_TABLE(HfCollIdLCLite, "AOD", "HFCOLLIDLCLITE", full::CollisionId); @@ -227,7 +338,10 @@ DECLARE_SOA_TABLE(HfCandLcFulls, "AOD", "HFCANDLCFULL", full::IsCandidateSwapped, full::CandidateId, full::Channel, - full::MassKPi); + full::MassKPi, + full::MlScoreFirstClass, + full::MlScoreSecondClass, + full::MlScoreThirdClass); DECLARE_SOA_TABLE(HfCandLcFullEvs, "AOD", "HFCANDLCFULLEV", full::CollisionId, @@ -236,6 +350,12 @@ DECLARE_SOA_TABLE(HfCandLcFullEvs, "AOD", "HFCANDLCFULLEV", collision::PosX, collision::PosY, collision::PosZ, + kf_collision::PosXErr, + kf_collision::PosYErr, + kf_collision::PosZErr, + kf_collision::McPosX, + kf_collision::McPosY, + kf_collision::McPosZ, full::IsEventReject, full::RunNumber, full::CentFT0A, @@ -243,7 +363,8 @@ DECLARE_SOA_TABLE(HfCandLcFullEvs, "AOD", "HFCANDLCFULLEV", full::CentFT0M, full::CentFV0A, full::CentFDDM, - full::MultZeqNTracksPV); + full::MultZeqNTracksPV, + kf::MultNTracksPV); DECLARE_SOA_TABLE(HfCandLcFullPs, "AOD", "HFCANDLCFULLP", full::Pt, @@ -251,50 +372,115 @@ DECLARE_SOA_TABLE(HfCandLcFullPs, "AOD", "HFCANDLCFULLP", full::Phi, full::Y, full::FlagMc, - full::OriginMcGen); + full::OriginMcGen, + mc_match::P, + mc_match::XDecay, + mc_match::YDecay, + mc_match::ZDecay, + mc_match::LDecay, + mc_match::TDecay, + mc_match::XEvent, + mc_match::YEvent, + mc_match::ZEvent); + } // namespace o2::aod /// Writes the full information in an output TTree struct HfTreeCreatorLcToPKPi { Produces rowCandidateFull; Produces rowCandidateLite; + Produces rowCandidateKF; + Produces rowCandidateMC; Produces rowCollisionId; Produces rowCandidateFullEvents; Produces rowCandidateFullParticles; + Configurable selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc"}; Configurable fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"}; Configurable fillCollIdTable{"fillCollIdTable", false, "Fill a single-column table with collision index"}; + Configurable fillCandidateMcTable{"fillCandidateMcTable", false, "Switch to fill a table with MC particles matched to candidates"}; + Configurable applyMl{"applyMl", false, "Whether ML was used in candidateSelectorLc"}; Configurable keepOnlySignalMc{"keepOnlySignalMc", false, "Fill MC tree only with signal candidates"}; Configurable keepOnlyBkg{"keepOnlyBkg", false, "Fill MC tree only with background candidates"}; + Configurable keepCorrBkgMC{"keepCorrBkgMC", false, "Flag to keep correlated background sources (Λc+ -> p K− π+ π0, p π− π+, p K− K+ and other charm hadrons)"}; Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of candidates to store in the tree"}; Configurable downSampleBkgPtMax{"downSampleBkgPtMax", 100.f, "Max. pt for background downsampling"}; + constexpr static float UndefValueFloat = -999.f; + constexpr static int UndefValueInt = -999; + constexpr static float NanoToPico = 1000.f; + HfHelper hfHelper; using TracksWPid = soa::Join; using Cents = soa::Join; + // number showing MC status of the candidate (signal or background, prompt or non-prompt etc.) + enum SigBgStatus : int { + Background = 0, // combinatorial background, at least one of the prongs do not originate from the Lc decay + Prompt, // signal with Lc produced directly in the event + NonPrompt, // signal with Lc produced aftewards the event, e.g. during decay of beauty particle + WrongOrder, // all the prongs are from Lc decay, but proton and pion hypothesis are swapped + Default = -1 // impossible, should not be the case, to catch logical error if any + }; + + /// \brief function which determines if the candidate corresponds to MC-particle or belongs to a combinatorial background + /// \param candidate candidate to be checked for being signal or background + /// \param candFlag 0 for PKPi hypothesis and 1 for PiKP hypothesis + /// \return SigBgStatus enum with value encoding MC status of the candidate + template + SigBgStatus determineSignalBgStatus(const CandType& candidate, int candFlag) + { + const int flag = candidate.flagMcMatchRec(); + const int origin = candidate.originMcRec(); + const int swapped = candidate.isCandidateSwapped(); + + SigBgStatus status{Default}; + + if (std::abs(flag) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + if (swapped == 0) { + if (candFlag == 0) { + if (origin == RecoDecay::OriginType::Prompt) + status = Prompt; + else if (origin == RecoDecay::OriginType::NonPrompt) + status = NonPrompt; + } else { + status = WrongOrder; + } + } else { + if (candFlag == 1) { + if (origin == RecoDecay::OriginType::Prompt) + status = Prompt; + else if (origin == RecoDecay::OriginType::NonPrompt) + status = NonPrompt; + } else { + status = WrongOrder; + } + } + } else { + status = Background; + } + + return status; + } + void init(InitContext const&) { - std::array processes = {doprocessDataNoCentrality, doprocessDataWithCentrality, doprocessMcNoCentrality, doprocessMcWithCentrality}; + std::array processes = {doprocessDataNoCentralityWithDCAFitterN, doprocessDataWithCentralityWithDCAFitterN, doprocessDataNoCentralityWithKFParticle, doprocessDataWithCentralityWithKFParticle, + doprocessMcNoCentralityWithDCAFitterN, doprocessMcWithCentralityWithDCAFitterN, doprocessMcNoCentralityWithKFParticle, doprocessMcWithCentralityWithKFParticle}; if (std::accumulate(processes.begin(), processes.end(), 0) != 1) { LOGP(fatal, "One and only one process function must be enabled at a time."); } + if (std::accumulate(processes.begin(), processes.begin() + 4, 0) && fillCandidateMcTable) { + LOGP(fatal, "fillCandidateMcTable can be activated only in case of MC processing."); + } } - /// \brief core function to fill tables in MC + /// \brief function to fill event properties /// \param collisions Collision table - /// \param mcCollisions MC collision table - /// \param candidates Lc->pKpi candidate table - /// \param particles Generated particle table - template - void fillTablesMc(Colls const& collisions, - aod::McCollisions const&, - soa::Join const& candidates, - soa::Join const& particles, - TracksWPid const&, aod::BCs const&) + template + void fillEventProperties(Colls const& collisions) { - // Filling event properties rowCandidateFullEvents.reserve(collisions.size()); for (const auto& collision : collisions) { @@ -312,13 +498,34 @@ struct HfTreeCreatorLcToPKPi { centFDDM = collision.centFDDM(); } + float mcPosX{UndefValueFloat}; + float mcPosY{UndefValueFloat}; + float mcPosZ{UndefValueFloat}; + int mcCollId{-1}; + + if constexpr (isMc) { + auto mcCollision = collision.template mcCollision_as(); + + mcPosX = mcCollision.posX(); + mcPosY = mcCollision.posY(); + mcPosZ = mcCollision.posZ(); + + mcCollId = collision.mcCollisionId(); + } + rowCandidateFullEvents( collision.globalIndex(), - collision.mcCollisionId(), + mcCollId, collision.numContrib(), collision.posX(), collision.posY(), collision.posZ(), + std::sqrt(collision.covXX()), + std::sqrt(collision.covYY()), + std::sqrt(collision.covZZ()), + mcPosX, + mcPosY, + mcPosZ, 0, collision.bc().runNumber(), centFT0A, @@ -326,189 +533,499 @@ struct HfTreeCreatorLcToPKPi { centFT0M, centFV0A, centFDDM, - collision.multZeqNTracksPV()); + collision.multZeqNTracksPV(), + collision.multNTracksPV()); } + } - // Filling candidate properties - if (fillCandidateLiteTable) { - rowCandidateLite.reserve(candidates.size()); + /// \brief function to reserve tables size + /// \param candidatesSize size of the candidates table + /// \param isMc boolean flag whether MC or data is processed + template + void reserveTables(size_t candidatesSize, bool isMc) + { + if constexpr (reconstructionType == aod::hf_cand::VertexerType::DCAFitter) { + if (fillCandidateLiteTable) { + rowCandidateLite.reserve(candidatesSize * 2); + } else { + rowCandidateFull.reserve(candidatesSize * 2); + } } else { - rowCandidateFull.reserve(candidates.size()); + rowCandidateKF.reserve(candidatesSize * 2); } if (fillCollIdTable) { /// save also candidate collision indices - rowCollisionId.reserve(candidates.size()); + rowCollisionId.reserve(candidatesSize); } + if (isMc && fillCandidateMcTable) { + rowCandidateMC.reserve(candidatesSize * 2); + } + } + + /// \brief function to evaluate invariant mass of the Lc candidate and KPi pair + /// \param candidate candidate instance + /// \param candFlag flag indicating if PKPi (0) or PiKP (1) hypothesis is used + template + std::pair evaluateInvariantMasses(CandType const& candidate, int candFlag) + { + float invMass, invMassKPi; + if constexpr (reconstructionType == aod::hf_cand::VertexerType::DCAFitter) { + invMass = candFlag == 0 ? hfHelper.invMassLcToPKPi(candidate) : hfHelper.invMassLcToPiKP(candidate); + invMassKPi = candFlag == 0 ? hfHelper.invMassKPiPairLcToPKPi(candidate) : hfHelper.invMassKPiPairLcToPiKP(candidate); + } else { + invMass = candFlag == 0 ? candidate.kfMassPKPi() : candidate.kfMassPiKP(); + invMassKPi = candFlag == 0 ? candidate.kfMassKPi() : candidate.kfMassPiK(); + } + + return std::make_pair(invMass, invMassKPi); + } + + /// \brief function to get ML score values for the current candidate and assign them to input parameters + /// \param candidate candidate instance + /// \param candidateMlScore instance of handler of vectors with ML scores associated with the current candidate + /// \param mlScoreFirstClass ML score for belonging to the first class + /// \param mlScoreSecondClass ML score for belonging to the second class + /// \param mlScoreThirdClass ML score for belonging to the third class + /// \param candFlag flag indicating if PKPi (0) or PiKP (1) hypothesis is used + void assignMlScores(aod::HfMlLcToPKPi::iterator const& candidateMlScore, float& mlScoreFirstClass, float& mlScoreSecondClass, float& mlScoreThirdClass, int candFlag) + { + std::vector mlScores; + if (candFlag == 0) { + std::copy(candidateMlScore.mlProbLcToPKPi().begin(), candidateMlScore.mlProbLcToPKPi().end(), std::back_inserter(mlScores)); + } else { + std::copy(candidateMlScore.mlProbLcToPiKP().begin(), candidateMlScore.mlProbLcToPiKP().end(), std::back_inserter(mlScores)); + } + constexpr int IndexFirstClass{0}; + constexpr int IndexSecondClass{1}; + constexpr int IndexThirdClass{2}; + if (mlScores.size() == 0) { + return; // when candidateSelectorLc rejects a candidate by "usual", non-ML cut, the ml score vector remains empty + } + mlScoreFirstClass = mlScores.at(IndexFirstClass); + mlScoreSecondClass = mlScores.at(IndexSecondClass); + if (mlScores.size() > IndexThirdClass) { + mlScoreThirdClass = mlScores.at(IndexThirdClass); + } + } + + /// \brief function to fill lite table + /// \param candidate candidate instance + /// \param candidateMlScore instance of handler of vectors with ML scores associated with the current candidate + /// \param candFlag flag indicating if PKPi (0) or PiKP (1) hypothesis is used + template + void fillLiteTable(CandType const& candidate, aod::HfMlLcToPKPi::iterator const& candidateMlScore, int candFlag) + { + auto [functionInvMass, functionInvMassKPi] = evaluateInvariantMasses(candidate, candFlag); + const float functionCt = hfHelper.ctLc(candidate); + const float functionY = hfHelper.yLc(candidate); + + int8_t functionFlagMcMatchRec{0}; + int8_t functionOriginMcRec{0}; + int8_t functionIsCandidateSwapped{0}; + int8_t functionFlagMcDecayChanRec{-1}; + + if constexpr (isMc) { + functionFlagMcMatchRec = candidate.flagMcMatchRec(); + functionOriginMcRec = candidate.originMcRec(); + functionIsCandidateSwapped = candidate.isCandidateSwapped(); + functionFlagMcDecayChanRec = candidate.flagMcDecayChanRec(); + } + + float mlScoreFirstClass{UndefValueFloat}; + float mlScoreSecondClass{UndefValueFloat}; + float mlScoreThirdClass{UndefValueFloat}; + + if (applyMl) { + assignMlScores(candidateMlScore, mlScoreFirstClass, mlScoreSecondClass, mlScoreThirdClass, candFlag); + } + + rowCandidateLite( + candidate.posX(), + candidate.posY(), + candidate.posZ(), + candidate.nProngsContributorsPV(), + candidate.bitmapProngsContributorsPV(), + candidate.chi2PCA(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.ptProng2(), + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameter2(), + candidate.nSigTpcPi0(), + candidate.nSigTpcPr0(), + candidate.nSigTofPi0(), + candidate.nSigTofPr0(), + candidate.nSigTpcKa1(), + candidate.nSigTofKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcPr2(), + candidate.nSigTofPi2(), + candidate.nSigTofPr2(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaPr0(), + candidate.tpcTofNSigmaKa1(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaPr2(), + 1 << candFlag, + functionInvMass, + candidate.pt(), + candidate.cpa(), + candidate.cpaXY(), + functionCt, + candidate.eta(), + candidate.phi(), + functionY, + functionFlagMcMatchRec, + functionOriginMcRec, + functionIsCandidateSwapped, + functionFlagMcDecayChanRec, + functionInvMassKPi, + mlScoreFirstClass, + mlScoreSecondClass, + mlScoreThirdClass); + + if (fillCollIdTable) { + /// save also candidate collision indices + rowCollisionId(candidate.collisionId()); + } + } + + /// \brief function to fill lite table + /// \param candidate candidate instance + /// \param candidateMlScore instance of handler of vectors with ML scores associated with the current candidate + /// \param candFlag flag indicating if PKPi (0) or PiKP (1) hypothesis is used + template + void fillFullTable(CandType const& candidate, aod::HfMlLcToPKPi::iterator const& candidateMlScore, int candFlag) + { + auto [functionInvMass, functionInvMassKPi] = evaluateInvariantMasses(candidate, candFlag); + const float functionCt = hfHelper.ctLc(candidate); + const float functionY = hfHelper.yLc(candidate); + const float functionE = hfHelper.eLc(candidate); + + int8_t functionFlagMcMatchRec{0}; + int8_t functionOriginMcRec{0}; + int8_t functionIsCandidateSwapped{0}; + int8_t functionFlagMcDecayChanRec{-1}; + + if constexpr (isMc) { + functionFlagMcMatchRec = candidate.flagMcMatchRec(); + functionOriginMcRec = candidate.originMcRec(); + functionIsCandidateSwapped = candidate.isCandidateSwapped(); + functionFlagMcDecayChanRec = candidate.flagMcDecayChanRec(); + } + + float mlScoreFirstClass{UndefValueFloat}; + float mlScoreSecondClass{UndefValueFloat}; + float mlScoreThirdClass{UndefValueFloat}; + + if (applyMl) { + assignMlScores(candidateMlScore, mlScoreFirstClass, mlScoreSecondClass, mlScoreThirdClass, candFlag); + } + + rowCandidateFull( + candidate.collisionId(), + candidate.posX(), + candidate.posY(), + candidate.posZ(), + candidate.nProngsContributorsPV(), + candidate.bitmapProngsContributorsPV(), + candidate.xSecondaryVertex(), + candidate.ySecondaryVertex(), + candidate.zSecondaryVertex(), + candidate.errorDecayLength(), + candidate.errorDecayLengthXY(), + candidate.chi2PCA(), + candidate.rSecondaryVertex(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + candidate.impactParameterNormalised0(), + candidate.ptProng0(), + RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()), + candidate.impactParameterNormalised1(), + candidate.ptProng1(), + RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()), + candidate.impactParameterNormalised2(), + candidate.ptProng2(), + RecoDecay::p(candidate.pxProng2(), candidate.pyProng2(), candidate.pzProng2()), + candidate.pxProng0(), + candidate.pyProng0(), + candidate.pzProng0(), + candidate.pxProng1(), + candidate.pyProng1(), + candidate.pzProng1(), + candidate.pxProng2(), + candidate.pyProng2(), + candidate.pzProng2(), + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameter2(), + candidate.errorImpactParameter0(), + candidate.errorImpactParameter1(), + candidate.errorImpactParameter2(), + candidate.nSigTpcPi0(), + candidate.nSigTpcPr0(), + candidate.nSigTofPi0(), + candidate.nSigTofPr0(), + candidate.nSigTpcKa1(), + candidate.nSigTofKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcPr2(), + candidate.nSigTofPi2(), + candidate.nSigTofPr2(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaPr0(), + candidate.tpcTofNSigmaKa1(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaPr2(), + 1 << candFlag, + functionInvMass, + candidate.pt(), + candidate.p(), + candidate.cpa(), + candidate.cpaXY(), + functionCt, + candidate.eta(), + candidate.phi(), + functionY, + functionE, + functionFlagMcMatchRec, + functionOriginMcRec, + functionIsCandidateSwapped, + candidate.globalIndex(), + functionFlagMcDecayChanRec, + functionInvMassKPi, + mlScoreFirstClass, + mlScoreSecondClass, + mlScoreThirdClass); + } + + /// \brief function to fill lite table + /// \param candidate candidate instance + /// \param collision collision, to which the candidate belongs + /// \param candFlag flag indicating if PKPi (0) or PiKP (1) hypothesis is used + /// \param functionSelection flag indicating if candidate was selected by candidateSelectorLc task + /// \param sigbgstatus for MC: number indicating if candidate is prompt, non-prompt or background; for data: UndefValueInt + template + void fillKFTable(CandType const& candidate, + CollType const& collision, + int candFlag, + int functionSelection, + int sigbgstatus) + { + float chi2primProton; + float chi2primPion; + float dcaProtonKaon; + float dcaPionKaon; + float chi2GeoProtonKaon; + float chi2GeoPionKaon; + float mass; + float valueTpcNSigmaPr; + const float valueTpcNSigmaKa = candidate.nSigTpcKa1(); + float valueTpcNSigmaPi; + float valueTofNSigmaPr; + const float valueTofNSigmaKa = candidate.nSigTofKa1(); + float valueTofNSigmaPi; + float valueTpcTofNSigmaPr; + const float valueTpcTofNSigmaKa = candidate.tpcTofNSigmaKa1(); + float valueTpcTofNSigmaPi; + if (candFlag == 0) { + chi2primProton = candidate.kfChi2PrimProng0(); + chi2primPion = candidate.kfChi2PrimProng2(); + dcaProtonKaon = candidate.kfDcaProng0Prong1(); + dcaPionKaon = candidate.kfDcaProng1Prong2(); + chi2GeoProtonKaon = candidate.kfChi2GeoProng0Prong1(); + chi2GeoPionKaon = candidate.kfChi2GeoProng1Prong2(); + mass = candidate.kfMassPKPi(); + valueTpcNSigmaPr = candidate.nSigTpcPr0(); + valueTpcNSigmaPi = candidate.nSigTpcPi2(); + valueTofNSigmaPr = candidate.nSigTofPr0(); + valueTofNSigmaPi = candidate.nSigTofPi2(); + valueTpcTofNSigmaPr = candidate.tpcTofNSigmaPr0(); + valueTpcTofNSigmaPi = candidate.tpcTofNSigmaPi2(); + } else { + chi2primProton = candidate.kfChi2PrimProng2(); + chi2primPion = candidate.kfChi2PrimProng0(); + dcaProtonKaon = candidate.kfDcaProng1Prong2(); + dcaPionKaon = candidate.kfDcaProng0Prong1(); + chi2GeoProtonKaon = candidate.kfChi2GeoProng1Prong2(); + chi2GeoPionKaon = candidate.kfChi2GeoProng0Prong1(); + mass = candidate.kfMassPiKP(); + valueTpcNSigmaPr = candidate.nSigTpcPr2(); + valueTpcNSigmaPi = candidate.nSigTpcPi0(); + valueTofNSigmaPr = candidate.nSigTofPr2(); + valueTofNSigmaPi = candidate.nSigTofPi0(); + valueTpcTofNSigmaPr = candidate.tpcTofNSigmaPr2(); + valueTpcTofNSigmaPi = candidate.tpcTofNSigmaPi0(); + } + const float svX = candidate.xSecondaryVertex(); + const float svY = candidate.ySecondaryVertex(); + const float svZ = candidate.zSecondaryVertex(); + const float svErrX = candidate.kfXError(); + const float svErrY = candidate.kfYError(); + const float svErrZ = candidate.kfZError(); + const float pvErrX = candidate.kfXPVError(); + const float pvErrY = candidate.kfYPVError(); + const float pvErrZ = candidate.kfZPVError(); + const float chi2primKaon = candidate.kfChi2PrimProng1(); + const float dcaProtonPion = candidate.kfDcaProng0Prong2(); + const float chi2GeoProtonPion = candidate.kfChi2GeoProng0Prong2(); + const float chi2Geo = candidate.kfChi2Geo(); + const float chi2Topo = candidate.kfChi2Topo(); + const float decayLength = candidate.kfDecayLength(); + const float dl = candidate.kfDecayLengthError(); + const float pt = std::sqrt(candidate.kfPx() * candidate.kfPx() + candidate.kfPy() * candidate.kfPy()); + const float deltaPt = std::sqrt(candidate.kfPx() * candidate.kfPx() * candidate.kfErrorPx() * candidate.kfErrorPx() + + candidate.kfPy() * candidate.kfPy() * candidate.kfErrorPy() * candidate.kfErrorPy()) / + pt; + const float p = std::sqrt(pt * pt + candidate.kfPz() * candidate.kfPz()); + const float deltaP = std::sqrt(pt * pt * deltaPt * deltaPt + + candidate.kfPz() * candidate.kfPz() * candidate.kfErrorPz() * candidate.kfErrorPz()) / + p; + const float lifetime = decayLength * MassLambdaCPlus / LightSpeedCm2PS / p; + const float deltaT = dl * MassLambdaCPlus / LightSpeedCm2PS / p; + rowCandidateKF( + svX, svY, svZ, svErrX, svErrY, svErrZ, + pvErrX, pvErrY, pvErrZ, + chi2primProton, chi2primKaon, chi2primPion, + dcaProtonKaon, dcaProtonPion, dcaPionKaon, + chi2GeoProtonKaon, chi2GeoProtonPion, chi2GeoPionKaon, + chi2Geo, chi2Topo, decayLength, dl, decayLength / dl, lifetime, deltaT, + mass, p, pt, deltaP, deltaPt, + functionSelection, sigbgstatus, + collision.multNTracksPV(), + valueTpcNSigmaPr, + valueTpcNSigmaKa, + valueTpcNSigmaPi, + valueTofNSigmaPr, + valueTofNSigmaKa, + valueTofNSigmaPi, + valueTpcTofNSigmaPr, + valueTpcTofNSigmaKa, + valueTpcTofNSigmaPi); + } + + /// \brief core function to fill tables in MC + /// \param collisions Collision table + /// \param mcCollisions MC collision table + /// \param candidates Lc->pKpi candidate table + /// \param particles Generated particle table + template + void fillTablesMc(Colls const& collisions, + aod::McCollisions const&, + CandType const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, + soa::Join const& particles, + soa::Join const&, aod::BCs const&) + { + + constexpr bool IsMc = true; + + fillEventProperties(collisions); + + const size_t candidatesSize = candidates.size(); + reserveTables(candidatesSize, IsMc); + + int iCand{0}; for (const auto& candidate : candidates) { - auto trackPos1 = candidate.prong0_as(); // positive daughter (negative for the antiparticles) - auto trackNeg = candidate.prong1_as(); // negative daughter (positive for the antiparticles) - auto trackPos2 = candidate.prong2_as(); // positive daughter (negative for the antiparticles) - bool isMcCandidateSignal = std::abs(candidate.flagMcMatchRec()) == (1 << o2::aod::hf_cand_3prong::DecayType::LcToPKPi); - auto fillTable = [&](int CandFlag, - int FunctionSelection, - float FunctionInvMass, - float FunctionCt, - float FunctionY, - float FunctionE, - float FunctionInvMassKPi) { - double pseudoRndm = trackPos1.pt() * 1000. - (int64_t)(trackPos1.pt() * 1000); - if (FunctionSelection >= 1 && (/*keep all*/ (!keepOnlySignalMc && !keepOnlyBkg) || /*keep only signal*/ (keepOnlySignalMc && isMcCandidateSignal) || /*keep only background and downsample it*/ (keepOnlyBkg && !isMcCandidateSignal && (candidate.pt() > downSampleBkgPtMax || (pseudoRndm < downSampleBkgFactor && candidate.pt() < downSampleBkgPtMax))))) { + auto candidateMlScore = candidateMlScores.rawIteratorAt(iCand); + ++iCand; + float ptProng0 = candidate.ptProng0(); + auto collision = candidate.template collision_as(); + auto fillTable = [&](int candFlag) { + double pseudoRndm = ptProng0 * 1000. - static_cast(ptProng0 * 1000); + const int functionSelection = candFlag == 0 ? candidate.isSelLcToPKPi() : candidate.isSelLcToPiKP(); + const int sigbgstatus = determineSignalBgStatus(candidate, candFlag); + const bool isMcCandidateSignal = (sigbgstatus == Prompt) || (sigbgstatus == NonPrompt); + const bool passSelection = functionSelection >= selectionFlagLc; + const bool keepAll = !keepOnlySignalMc && !keepOnlyBkg && !keepCorrBkgMC; + const int flag = candidate.flagMcMatchRec(); + const bool isCorrBkg = (std::abs(flag) != 0 && std::abs(flag) != o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi); + const bool notSkippedBkg = isMcCandidateSignal || candidate.pt() > downSampleBkgPtMax || pseudoRndm < downSampleBkgFactor; + if (passSelection && notSkippedBkg && (keepAll || (keepOnlySignalMc && isMcCandidateSignal) || (keepOnlyBkg && !isMcCandidateSignal) || (keepCorrBkgMC && isCorrBkg))) { if (fillCandidateLiteTable) { - rowCandidateLite( - candidate.posX(), - candidate.posY(), - candidate.posZ(), - candidate.nProngsContributorsPV(), - candidate.bitmapProngsContributorsPV(), - // candidate.errorDecayLength(), - // candidate.errorDecayLengthXY(), - candidate.chi2PCA(), - candidate.decayLength(), - candidate.decayLengthXY(), - // candidate.decayLengthNormalised(), - // candidate.decayLengthXYNormalised(), - // candidate.impactParameterNormalised0(), - candidate.ptProng0(), - // candidate.impactParameterNormalised1(), - candidate.ptProng1(), - // candidate.impactParameterNormalised2(), - candidate.ptProng2(), - candidate.impactParameter0(), - candidate.impactParameter1(), - candidate.impactParameter2(), - // candidate.errorImpactParameter0(), - // candidate.errorImpactParameter1(), - // candidate.errorImpactParameter2(), - trackPos1.tpcNSigmaPi(), - trackPos1.tpcNSigmaPr(), - trackPos1.tofNSigmaPi(), - trackPos1.tofNSigmaPr(), - trackNeg.tpcNSigmaKa(), - trackNeg.tofNSigmaKa(), - trackPos2.tpcNSigmaPi(), - trackPos2.tpcNSigmaPr(), - trackPos2.tofNSigmaPi(), - trackPos2.tofNSigmaPr(), - trackPos1.tpcTofNSigmaPi(), - trackPos1.tpcTofNSigmaPr(), - trackNeg.tpcTofNSigmaKa(), - trackPos2.tpcTofNSigmaPi(), - trackPos2.tpcTofNSigmaPr(), - 1 << CandFlag, - FunctionInvMass, - candidate.pt(), - candidate.cpa(), - candidate.cpaXY(), - FunctionCt, - candidate.eta(), - candidate.phi(), - FunctionY, - candidate.flagMcMatchRec(), - candidate.originMcRec(), - candidate.isCandidateSwapped(), - candidate.flagMcDecayChanRec(), - FunctionInvMassKPi); - // candidate.globalIndex()); - - if (fillCollIdTable) { - /// save also candidate collision indices - rowCollisionId(candidate.collisionId()); - } - + fillLiteTable(candidate, candidateMlScore, candFlag); } else { - rowCandidateFull( - candidate.collisionId(), - candidate.posX(), - candidate.posY(), - candidate.posZ(), - candidate.nProngsContributorsPV(), - candidate.bitmapProngsContributorsPV(), - candidate.xSecondaryVertex(), - candidate.ySecondaryVertex(), - candidate.zSecondaryVertex(), - candidate.errorDecayLength(), - candidate.errorDecayLengthXY(), - candidate.chi2PCA(), - candidate.rSecondaryVertex(), - candidate.decayLength(), - candidate.decayLengthXY(), - candidate.decayLengthNormalised(), - candidate.decayLengthXYNormalised(), - candidate.impactParameterNormalised0(), - candidate.ptProng0(), - RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()), - candidate.impactParameterNormalised1(), - candidate.ptProng1(), - RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()), - candidate.impactParameterNormalised2(), - candidate.ptProng2(), - RecoDecay::p(candidate.pxProng2(), candidate.pyProng2(), candidate.pzProng2()), - candidate.pxProng0(), - candidate.pyProng0(), - candidate.pzProng0(), - candidate.pxProng1(), - candidate.pyProng1(), - candidate.pzProng1(), - candidate.pxProng2(), - candidate.pyProng2(), - candidate.pzProng2(), - candidate.impactParameter0(), - candidate.impactParameter1(), - candidate.impactParameter2(), - candidate.errorImpactParameter0(), - candidate.errorImpactParameter1(), - candidate.errorImpactParameter2(), - trackPos1.tpcNSigmaPi(), - trackPos1.tpcNSigmaPr(), - trackPos1.tofNSigmaPi(), - trackPos1.tofNSigmaPr(), - trackNeg.tpcNSigmaKa(), - trackNeg.tofNSigmaKa(), - trackPos2.tpcNSigmaPi(), - trackPos2.tpcNSigmaPr(), - trackPos2.tofNSigmaPi(), - trackPos2.tofNSigmaPr(), - trackPos1.tpcTofNSigmaPi(), - trackPos1.tpcTofNSigmaPr(), - trackNeg.tpcTofNSigmaKa(), - trackPos2.tpcTofNSigmaPi(), - trackPos2.tpcTofNSigmaPr(), - 1 << CandFlag, - FunctionInvMass, - candidate.pt(), - candidate.p(), - candidate.cpa(), - candidate.cpaXY(), - FunctionCt, - candidate.eta(), - candidate.phi(), - FunctionY, - FunctionE, - candidate.flagMcMatchRec(), - candidate.originMcRec(), - candidate.isCandidateSwapped(), - candidate.globalIndex(), - candidate.flagMcDecayChanRec(), - FunctionInvMassKPi); + fillFullTable(candidate, candidateMlScore, candFlag); + } + + if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { + fillKFTable(candidate, collision, candFlag, functionSelection, sigbgstatus); + } + if (fillCandidateMcTable) { + float p, pt, svX, svY, svZ, pvX, pvY, pvZ, decayLength, lifetime; + if (!isMcCandidateSignal) { + p = UndefValueFloat; + pt = UndefValueFloat; + svX = UndefValueFloat; + svY = UndefValueFloat; + svZ = UndefValueFloat; + pvX = UndefValueFloat; + pvY = UndefValueFloat; + pvZ = UndefValueFloat; + decayLength = UndefValueFloat; + lifetime = UndefValueFloat; + } else { + auto mcParticleProng0 = candidate.template prong0_as>().template mcParticle_as>(); + auto indexMother = RecoDecay::getMother(particles, mcParticleProng0, o2::constants::physics::Pdg::kLambdaCPlus, true); + auto particleMother = particles.rawIteratorAt(indexMother); + auto mcCollision = particleMother.template mcCollision_as(); + p = particleMother.p(); + pt = particleMother.pt(); + const float p2m = p / MassLambdaCPlus; + const float gamma = std::sqrt(1 + p2m * p2m); // mother's particle Lorentz factor + pvX = mcCollision.posX(); + pvY = mcCollision.posY(); + pvZ = mcCollision.posZ(); + svX = mcParticleProng0.vx(); + svY = mcParticleProng0.vy(); + svZ = mcParticleProng0.vz(); + decayLength = RecoDecay::distance(std::array{svX, svY, svZ}, std::array{pvX, pvY, pvZ}); + lifetime = mcParticleProng0.vt() * NanoToPico / gamma; // from ns to ps * from lab time to proper time + } + rowCandidateMC( + p, pt, + svX, svY, svZ, decayLength, lifetime, + pvX, pvY, pvZ); } } }; - fillTable(0, candidate.isSelLcToPKPi(), hfHelper.invMassLcToPKPi(candidate), hfHelper.ctLc(candidate), hfHelper.yLc(candidate), hfHelper.eLc(candidate), hfHelper.invMassKPiPairLcToPKPi(candidate)); - fillTable(1, candidate.isSelLcToPiKP(), hfHelper.invMassLcToPiKP(candidate), hfHelper.ctLc(candidate), hfHelper.yLc(candidate), hfHelper.eLc(candidate), hfHelper.invMassKPiPairLcToPiKP(candidate)); + fillTable(0); + fillTable(1); } // Filling particle properties rowCandidateFullParticles.reserve(particles.size()); for (const auto& particle : particles) { - if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(particle.flagMcMatchGen()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + auto mcDaughter0 = particle.template daughters_as>().begin(); + auto mcCollision = particle.template mcCollision_as(); + auto p = particle.p(); + const float p2m = p / MassLambdaCPlus; + const float gamma = std::sqrt(1 + p2m * p2m); // mother's particle Lorentz factor + const float pvX = mcCollision.posX(); + const float pvY = mcCollision.posY(); + const float pvZ = mcCollision.posZ(); + const float svX = mcDaughter0.vx(); + const float svY = mcDaughter0.vy(); + const float svZ = mcDaughter0.vz(); + const float l = RecoDecay::distance(std::array{svX, svY, svZ}, std::array{pvX, pvY, pvZ}); + const float t = mcDaughter0.vt() * NanoToPico / gamma; // from ns to ps * from lab time to proper time rowCandidateFullParticles( particle.pt(), particle.eta(), particle.phi(), RecoDecay::y(particle.pVector(), o2::constants::physics::MassLambdaCPlus), particle.flagMcMatchGen(), - particle.originMcGen()); + particle.originMcGen(), + p, + svX, svY, svZ, l, t, + pvX, pvY, pvZ); } } } @@ -520,15 +1037,51 @@ struct HfTreeCreatorLcToPKPi { /// \param particles Generated particle table /// \param tracks Track table /// \param bcs Bunch-crossing table - void processMcNoCentrality(soa::Join const& collisions, - aod::McCollisions const& mcCollisions, - soa::Join const& candidates, - soa::Join const& particles, - TracksWPid const& tracks, aod::BCs const& bcs) + void processMcNoCentralityWithDCAFitterN(soa::Join const& collisions, + aod::McCollisions const& mcCollisions, + soa::Join const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, + soa::Join const& particles, + soa::Join const& tracks, aod::BCs const& bcs) + { + fillTablesMc(collisions, mcCollisions, candidates, candidateMlScores, particles, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processMcNoCentralityWithDCAFitterN, "Process MC tree writer w/o centrality with DCAFitterN", false); + + /// \brief process function for MC with centrality + /// \param collisions Collision table with join of the centrality table + /// \param mcCollisions MC collision table + /// \param candidates Lc->pKpi candidate table + /// \param tracks Track table + /// \param bcs Bunch-crossing table + void processMcWithCentralityWithDCAFitterN(soa::Join const& collisions, + aod::McCollisions const& mcCollisions, + soa::Join const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, + soa::Join const& particles, + soa::Join const& tracks, aod::BCs const& bcs) + { + fillTablesMc(collisions, mcCollisions, candidates, candidateMlScores, particles, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processMcWithCentralityWithDCAFitterN, "Process MC tree writer with centrality with DCAFitterN", false); + + /// \brief process function for MC w/o centrality + /// \param collisions Collision table w/o join of the centrality table + /// \param mcCollisions MC collision table + /// \param candidates Lc->pKpi candidate table + /// \param particles Generated particle table + /// \param tracks Track table + /// \param bcs Bunch-crossing table + void processMcNoCentralityWithKFParticle(soa::Join const& collisions, + aod::McCollisions const& mcCollisions, + soa::Join const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, + soa::Join const& particles, + soa::Join const& tracks, aod::BCs const& bcs) { - fillTablesMc(collisions, mcCollisions, candidates, particles, tracks, bcs); + fillTablesMc(collisions, mcCollisions, candidates, candidateMlScores, particles, tracks, bcs); } - PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processMcNoCentrality, "Process MC tree writer w/o centrality", false); + PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processMcNoCentralityWithKFParticle, "Process MC tree writer w/o centrality with KFParticle", false); /// \brief process function for MC with centrality /// \param collisions Collision table with join of the centrality table @@ -536,225 +1089,60 @@ struct HfTreeCreatorLcToPKPi { /// \param candidates Lc->pKpi candidate table /// \param tracks Track table /// \param bcs Bunch-crossing table - void processMcWithCentrality(soa::Join const& collisions, - aod::McCollisions const& mcCollisions, - soa::Join const& candidates, - soa::Join const& particles, - TracksWPid const& tracks, aod::BCs const& bcs) + void processMcWithCentralityWithKFParticle(soa::Join const& collisions, + aod::McCollisions const& mcCollisions, + soa::Join const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, + soa::Join const& particles, + soa::Join const& tracks, aod::BCs const& bcs) { - fillTablesMc(collisions, mcCollisions, candidates, particles, tracks, bcs); + fillTablesMc(collisions, mcCollisions, candidates, candidateMlScores, particles, tracks, bcs); } - PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processMcWithCentrality, "Process MC tree writer with centrality", false); + PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processMcWithCentralityWithKFParticle, "Process MC tree writer with centrality with KFParticle", false); /// \brief core function to fill tables in data /// \param collisions Collision table /// \param candidates Lc->pKpi candidate table - template + template void fillTablesData(Colls const& collisions, - soa::Join const& candidates, + CandType const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, TracksWPid const&, aod::BCs const&) { - // Filling event properties - rowCandidateFullEvents.reserve(collisions.size()); - for (const auto& collision : collisions) { + constexpr bool IsMc = false; - float centFT0A = -1.f; - float centFT0C = -1.f; - float centFT0M = -1.f; - float centFV0A = -1.f; - float centFDDM = -1.f; - if constexpr (useCentrality) { - centFT0A = collision.centFT0A(); - centFT0C = collision.centFT0C(); - centFT0M = collision.centFT0M(); - centFV0A = collision.centFV0A(); - centFDDM = collision.centFDDM(); - } + fillEventProperties(collisions); - rowCandidateFullEvents( - collision.globalIndex(), - -1, - collision.numContrib(), - collision.posX(), - collision.posY(), - collision.posZ(), - 0, - collision.bc().runNumber(), - centFT0A, - centFT0C, - centFT0M, - centFV0A, - centFDDM, - collision.multZeqNTracksPV()); - } + const size_t candidatesSize = candidates.size(); + reserveTables(candidatesSize, IsMc); // Filling candidate properties - if (fillCandidateLiteTable) { - rowCandidateLite.reserve(candidates.size()); - } else { - rowCandidateFull.reserve(candidates.size()); - } - if (fillCollIdTable) { - /// save also candidate collision indices - rowCollisionId.reserve(candidates.size()); - } + + int iCand{0}; for (const auto& candidate : candidates) { - auto trackPos1 = candidate.prong0_as(); // positive daughter (negative for the antiparticles) - auto trackNeg = candidate.prong1_as(); // negative daughter (positive for the antiparticles) - auto trackPos2 = candidate.prong2_as(); // positive daughter (negative for the antiparticles) - auto fillTable = [&](int CandFlag, - int FunctionSelection, - float FunctionInvMass, - float FunctionCt, - float FunctionY, - float FunctionE, - float FunctionInvMassKPi) { - double pseudoRndm = trackPos1.pt() * 1000. - (int64_t)(trackPos1.pt() * 1000); - if (FunctionSelection >= 1 && (candidate.pt() > downSampleBkgPtMax || (pseudoRndm < downSampleBkgFactor && candidate.pt() < downSampleBkgPtMax))) { + auto candidateMlScore = candidateMlScores.rawIteratorAt(iCand); + ++iCand; + float ptProng0 = candidate.ptProng0(); + auto collision = candidate.template collision_as(); + auto fillTable = [&](int candFlag) { + double pseudoRndm = ptProng0 * 1000. - static_cast(ptProng0 * 1000); + const int functionSelection = candFlag == 0 ? candidate.isSelLcToPKPi() : candidate.isSelLcToPiKP(); + if (functionSelection >= selectionFlagLc && (candidate.pt() > downSampleBkgPtMax || (pseudoRndm < downSampleBkgFactor && candidate.pt() < downSampleBkgPtMax))) { if (fillCandidateLiteTable) { - rowCandidateLite( - candidate.posX(), - candidate.posY(), - candidate.posZ(), - candidate.nProngsContributorsPV(), - candidate.bitmapProngsContributorsPV(), - // candidate.errorDecayLength(), - // candidate.errorDecayLengthXY(), - candidate.chi2PCA(), - candidate.decayLength(), - candidate.decayLengthXY(), - // candidate.decayLengthNormalised(), - // candidate.decayLengthXYNormalised(), - // candidate.impactParameterNormalised0(), - candidate.ptProng0(), - // candidate.impactParameterNormalised1(), - candidate.ptProng1(), - // candidate.impactParameterNormalised2(), - candidate.ptProng2(), - candidate.impactParameter0(), - candidate.impactParameter1(), - candidate.impactParameter2(), - // candidate.errorImpactParameter0(), - // candidate.errorImpactParameter1(), - // candidate.errorImpactParameter2(), - trackPos1.tpcNSigmaPi(), - trackPos1.tpcNSigmaPr(), - trackPos1.tofNSigmaPi(), - trackPos1.tofNSigmaPr(), - trackNeg.tpcNSigmaKa(), - trackNeg.tofNSigmaKa(), - trackPos2.tpcNSigmaPi(), - trackPos2.tpcNSigmaPr(), - trackPos2.tofNSigmaPi(), - trackPos2.tofNSigmaPr(), - trackPos1.tpcTofNSigmaPi(), - trackPos1.tpcTofNSigmaPr(), - trackNeg.tpcTofNSigmaKa(), - trackPos2.tpcTofNSigmaPi(), - trackPos2.tpcTofNSigmaPr(), - 1 << CandFlag, - FunctionInvMass, - candidate.pt(), - candidate.cpa(), - candidate.cpaXY(), - FunctionCt, - candidate.eta(), - candidate.phi(), - FunctionY, - 0., - 0., - 0., - -1, - FunctionInvMassKPi); - // candidate.globalIndex()); - - if (fillCollIdTable) { - /// save also candidate collision indices - rowCollisionId(candidate.collisionId()); - } - + fillLiteTable(candidate, candidateMlScore, candFlag); } else { - rowCandidateFull( - candidate.collisionId(), - candidate.posX(), - candidate.posY(), - candidate.posZ(), - candidate.nProngsContributorsPV(), - candidate.bitmapProngsContributorsPV(), - candidate.xSecondaryVertex(), - candidate.ySecondaryVertex(), - candidate.zSecondaryVertex(), - candidate.errorDecayLength(), - candidate.errorDecayLengthXY(), - candidate.chi2PCA(), - candidate.rSecondaryVertex(), - candidate.decayLength(), - candidate.decayLengthXY(), - candidate.decayLengthNormalised(), - candidate.decayLengthXYNormalised(), - candidate.impactParameterNormalised0(), - candidate.ptProng0(), - RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()), - candidate.impactParameterNormalised1(), - candidate.ptProng1(), - RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()), - candidate.impactParameterNormalised2(), - candidate.ptProng2(), - RecoDecay::p(candidate.pxProng2(), candidate.pyProng2(), candidate.pzProng2()), - candidate.pxProng0(), - candidate.pyProng0(), - candidate.pzProng0(), - candidate.pxProng1(), - candidate.pyProng1(), - candidate.pzProng1(), - candidate.pxProng2(), - candidate.pyProng2(), - candidate.pzProng2(), - candidate.impactParameter0(), - candidate.impactParameter1(), - candidate.impactParameter2(), - candidate.errorImpactParameter0(), - candidate.errorImpactParameter1(), - candidate.errorImpactParameter2(), - trackPos1.tpcNSigmaPi(), - trackPos1.tpcNSigmaPr(), - trackPos1.tofNSigmaPi(), - trackPos1.tofNSigmaPr(), - trackNeg.tpcNSigmaKa(), - trackNeg.tofNSigmaKa(), - trackPos2.tpcNSigmaPi(), - trackPos2.tpcNSigmaPr(), - trackPos2.tofNSigmaPi(), - trackPos2.tofNSigmaPr(), - trackPos1.tpcTofNSigmaPi(), - trackPos1.tpcTofNSigmaPr(), - trackNeg.tpcTofNSigmaKa(), - trackPos2.tpcTofNSigmaPi(), - trackPos2.tpcTofNSigmaPr(), - 1 << CandFlag, - FunctionInvMass, - candidate.pt(), - candidate.p(), - candidate.cpa(), - candidate.cpaXY(), - FunctionCt, - candidate.eta(), - candidate.phi(), - FunctionY, - FunctionE, - 0., - 0., - 0., - candidate.globalIndex(), - -1, - FunctionInvMassKPi); + fillFullTable(candidate, candidateMlScore, candFlag); + } + + if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { + fillKFTable(candidate, collision, candFlag, functionSelection, UndefValueInt); } } }; - fillTable(0, candidate.isSelLcToPKPi(), hfHelper.invMassLcToPKPi(candidate), hfHelper.ctLc(candidate), hfHelper.yLc(candidate), hfHelper.eLc(candidate), hfHelper.invMassKPiPairLcToPKPi(candidate)); - fillTable(1, candidate.isSelLcToPiKP(), hfHelper.invMassLcToPiKP(candidate), hfHelper.ctLc(candidate), hfHelper.yLc(candidate), hfHelper.eLc(candidate), hfHelper.invMassKPiPairLcToPiKP(candidate)); + fillTable(0); + fillTable(1); } } @@ -763,26 +1151,56 @@ struct HfTreeCreatorLcToPKPi { /// \param candidates Lc->pKpi candidate table /// \param tracks Track table /// \param bcs Bunch-crossing table - void processDataNoCentrality(soa::Join const& collisions, - soa::Join const& candidates, - TracksWPid const& tracks, aod::BCs const& bcs) + void processDataNoCentralityWithDCAFitterN(soa::Join const& collisions, + soa::Join const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, + TracksWPid const& tracks, aod::BCs const& bcs) + { + fillTablesData(collisions, candidates, candidateMlScores, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processDataNoCentralityWithDCAFitterN, "Process data tree writer w/o centrality with DCAFitterN", false); + + /// \brief process function for data with centrality + /// \param collisions Collision table with join of the centrality table + /// \param candidates Lc->pKpi candidate table + /// \param tracks Track table + /// \param bcs Bunch-crossing table + void processDataWithCentralityWithDCAFitterN(soa::Join const& collisions, + soa::Join const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, + TracksWPid const& tracks, aod::BCs const& bcs) + { + fillTablesData(collisions, candidates, candidateMlScores, tracks, bcs); + } + PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processDataWithCentralityWithDCAFitterN, "Process data tree writer with centrality with DCAFitterN", true); + + /// \brief process function for data w/o centrality + /// \param collisions Collision table w/o join of the centrality table + /// \param candidates Lc->pKpi candidate table + /// \param tracks Track table + /// \param bcs Bunch-crossing table + void processDataNoCentralityWithKFParticle(soa::Join const& collisions, + soa::Join const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, + TracksWPid const& tracks, aod::BCs const& bcs) { - fillTablesData(collisions, candidates, tracks, bcs); + fillTablesData(collisions, candidates, candidateMlScores, tracks, bcs); } - PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processDataNoCentrality, "Process data tree writer w/o centrality", false); + PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processDataNoCentralityWithKFParticle, "Process data tree writer w/o centrality with KFParticle", false); /// \brief process function for data with centrality /// \param collisions Collision table with join of the centrality table /// \param candidates Lc->pKpi candidate table /// \param tracks Track table /// \param bcs Bunch-crossing table - void processDataWithCentrality(soa::Join const& collisions, - soa::Join const& candidates, - TracksWPid const& tracks, aod::BCs const& bcs) + void processDataWithCentralityWithKFParticle(soa::Join const& collisions, + soa::Join const& candidates, + aod::HfMlLcToPKPi const& candidateMlScores, + TracksWPid const& tracks, aod::BCs const& bcs) { - fillTablesData(collisions, candidates, tracks, bcs); + fillTablesData(collisions, candidates, candidateMlScores, tracks, bcs); } - PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processDataWithCentrality, "Process data tree writer with centrality", true); + PROCESS_SWITCH(HfTreeCreatorLcToPKPi, processDataWithCentralityWithKFParticle, "Process data tree writer with centrality with KFParticle", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/treeCreatorOmegacToOmegaKa.cxx b/PWGHF/TableProducer/treeCreatorOmegac0ToOmegaKa.cxx similarity index 95% rename from PWGHF/TableProducer/treeCreatorOmegacToOmegaKa.cxx rename to PWGHF/TableProducer/treeCreatorOmegac0ToOmegaKa.cxx index 0330cabc861..aaa3ee36337 100644 --- a/PWGHF/TableProducer/treeCreatorOmegacToOmegaKa.cxx +++ b/PWGHF/TableProducer/treeCreatorOmegac0ToOmegaKa.cxx @@ -9,19 +9,28 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file treeCreatorOmegacToOmegaKa.cxx +/// \file treeCreatorOmegac0ToOmegaKa.cxx /// \brief Writer of the omegac0 to Omega Ka candidates in the form of flat tables to be stored in TTrees. /// In this file are defined and filled the output tables /// /// \author Federica Zanone , Heidelberg University -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include + +#include using namespace o2; using namespace o2::framework; @@ -86,7 +95,7 @@ DECLARE_SOA_COLUMN(IsKaonGlbTrkWoDca, isKaonGlbTrkWoDca, bool); DECLARE_SOA_COLUMN(KaonItsNCls, kaonItsNCls, uint8_t); // from creator - MC DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level -DECLARE_SOA_COLUMN(OriginRec, originRec, int8_t); +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); DECLARE_SOA_COLUMN(CollisionMatched, collisionMatched, bool); // from selector DECLARE_SOA_COLUMN(PidTpcInfoStored, pidTpcInfoStored, int); @@ -127,7 +136,7 @@ DECLARE_SOA_TABLE(HfOmegac0ToOmegaKaLites, "AOD", "HFTOOMEKALITE", full::PidTpcInfoStored, full::PidTofInfoStored, full::TpcNSigmaKaFromCharmBaryon, full::TpcNSigmaKaFromCasc, full::TpcNSigmaPiFromLambda, full::TpcNSigmaPrFromLambda, full::TofNSigmaKaFromCharmBaryon, full::TofNSigmaKaFromCasc, full::TofNSigmaPiFromLambda, full::TofNSigmaPrFromLambda, - full::FlagMcMatchRec, full::OriginRec, full::CollisionMatched); + full::FlagMcMatchRec, full::OriginMcRec, full::CollisionMatched); } // namespace o2::aod @@ -255,7 +264,7 @@ struct HfTreeCreatorOmegac0ToOmegaKa { // Filling candidate properties rowCandidateLite.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originRec(), candidate.collisionMatched()); + fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); } } PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaKa, processMcLite, "Process MC", false); diff --git a/PWGHF/TableProducer/treeCreatorOmegacToOmegaPi.cxx b/PWGHF/TableProducer/treeCreatorOmegac0ToOmegaPi.cxx similarity index 71% rename from PWGHF/TableProducer/treeCreatorOmegacToOmegaPi.cxx rename to PWGHF/TableProducer/treeCreatorOmegac0ToOmegaPi.cxx index 42b40686a15..4fb9c92235c 100644 --- a/PWGHF/TableProducer/treeCreatorOmegacToOmegaPi.cxx +++ b/PWGHF/TableProducer/treeCreatorOmegac0ToOmegaPi.cxx @@ -9,23 +9,37 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file treeCreatorOmegacToOmegaPi.cxx +/// \file treeCreatorOmegac0ToOmegaPi.cxx /// \brief Writer of the omegac0 to Omega Pi candidates in the form of flat tables to be stored in TTrees. /// In this file are defined and filled the output tables /// /// \author Federica Zanone , Heidelberg University /// \author Yunfan Liu , China University of Geosciences +/// \author Fabio Catalano , University of Houston +/// \author Ruiqi Yin , Fudan University -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include + +#include + +#include using namespace o2; using namespace o2::framework; +using namespace o2::framework::expressions; namespace o2::aod { @@ -87,7 +101,7 @@ DECLARE_SOA_COLUMN(IsPionGlbTrkWoDca, isPionGlbTrkWoDca, bool); DECLARE_SOA_COLUMN(PionItsNCls, pionItsNCls, uint8_t); // from creator - MC DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level -DECLARE_SOA_COLUMN(OriginRec, originRec, int8_t); +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); DECLARE_SOA_COLUMN(CollisionMatched, collisionMatched, bool); // from selector DECLARE_SOA_COLUMN(PidTpcInfoStored, pidTpcInfoStored, int); @@ -121,6 +135,7 @@ DECLARE_SOA_COLUMN(Chi2TopoV0ToPv, chi2TopoV0ToPv, float); DECLARE_SOA_COLUMN(Chi2TopoCascToPv, chi2TopoCascToPv, float); DECLARE_SOA_COLUMN(Chi2TopoPiFromOmegacToPv, chi2TopoPiFromOmegacToPv, float); DECLARE_SOA_COLUMN(Chi2TopoOmegacToPv, chi2TopoOmegacToPv, float); +DECLARE_SOA_COLUMN(DeviationPiFromOmegacToPv, deviationPiFromOmegacToPv, float); DECLARE_SOA_COLUMN(Chi2TopoV0ToCasc, chi2TopoV0ToCasc, float); DECLARE_SOA_COLUMN(Chi2TopoCascToOmegac, chi2TopoCascToOmegac, float); DECLARE_SOA_COLUMN(DecayLenXYLambda, decayLenXYLambda, float); @@ -147,7 +162,7 @@ DECLARE_SOA_COLUMN(CascChi2OverNdf, cascChi2OverNdf, float); DECLARE_SOA_COLUMN(OmegacChi2OverNdf, omegacChi2OverNdf, float); DECLARE_SOA_COLUMN(MassV0Chi2OverNdf, massV0Chi2OverNdf, float); DECLARE_SOA_COLUMN(MassCascChi2OverNdf, massCascChi2OverNdf, float); - +DECLARE_SOA_COLUMN(CascRejectInvmass, cascRejectInvmass, float); } // namespace full DECLARE_SOA_TABLE(HfToOmegaPiEvs, "AOD", "HFTOOMEPIEV", @@ -175,7 +190,7 @@ DECLARE_SOA_TABLE(HfOmegac0ToOmegaPiLites, "AOD", "HFTOOMEPILITE", full::PidTpcInfoStored, full::PidTofInfoStored, full::TpcNSigmaPiFromCharmBaryon, full::TpcNSigmaKaFromCasc, full::TpcNSigmaPiFromLambda, full::TpcNSigmaPrFromLambda, full::TofNSigmaPiFromCharmBaryon, full::TofNSigmaKaFromCasc, full::TofNSigmaPiFromLambda, full::TofNSigmaPrFromLambda, - full::FlagMcMatchRec, full::OriginRec, full::CollisionMatched); + full::FlagMcMatchRec, full::OriginMcRec, full::CollisionMatched, hf_track_index::HFflag); DECLARE_SOA_TABLE(HfKfOmegacFulls, "AOD", "HFKFOMEGACFULL", full::NSigmaTPCPiFromOmegac, full::NSigmaTOFPiFromOmegac, full::NSigmaTPCKaFromCasc, full::NSigmaTOFKaFromCasc, @@ -185,7 +200,7 @@ DECLARE_SOA_TABLE(HfKfOmegacFulls, "AOD", "HFKFOMEGACFULL", full::Chi2GeoV0, full::Chi2GeoCasc, full::Chi2GeoOmegac, full::Chi2MassV0, full::Chi2MassCasc, full::V0ldl, full::Cascldl, full::Omegacldl, - full::Chi2TopoV0ToPv, full::Chi2TopoCascToPv, full::Chi2TopoPiFromOmegacToPv, full::Chi2TopoOmegacToPv, + full::Chi2TopoV0ToPv, full::Chi2TopoCascToPv, full::Chi2TopoPiFromOmegacToPv, full::Chi2TopoOmegacToPv, full::DeviationPiFromOmegacToPv, full::Chi2TopoV0ToCasc, full::Chi2TopoCascToOmegac, full::DecayLenXYLambda, full::DecayLenXYCasc, full::DecayLenXYOmegac, full::CosPaV0ToCasc, full::CosPaV0ToPv, full::CosPaCascToOmegac, full::CosPaCascToPv, full::CosPaOmegacToPv, @@ -195,8 +210,22 @@ DECLARE_SOA_TABLE(HfKfOmegacFulls, "AOD", "HFKFOMEGACFULL", full::V0Ndf, full::CascNdf, full::OmegacNdf, full::MassV0Ndf, full::MassCascNdf, full::V0Chi2OverNdf, full::CascChi2OverNdf, full::OmegacChi2OverNdf, - full::MassV0Chi2OverNdf, full::MassCascChi2OverNdf, - full::FlagMcMatchRec, full::OriginRec, full::CollisionMatched); + full::MassV0Chi2OverNdf, full::MassCascChi2OverNdf, full::CascRejectInvmass, + full::FlagMcMatchRec, full::OriginMcRec, full::CollisionMatched, hf_track_index::HFflag); + +DECLARE_SOA_TABLE(HfKfOmegacLites, "AOD", "HFKFOMEGACLITE", + full::NSigmaTPCPiFromOmegac, full::NSigmaTOFPiFromOmegac, full::NSigmaTPCKaFromCasc, full::NSigmaTOFKaFromCasc, + full::NSigmaTPCPiFromV0, full::NSigmaTPCPrFromV0, + full::KfDcaXYPiFromOmegac, full::DcaCharmBaryonDau, full::KfDcaXYCascToPv, full::DcaCascDau, + full::V0ldl, full::Cascldl, full::Omegacldl, full::Chi2TopoPiFromOmegacToPv, full::Chi2TopoOmegacToPv, full::DeviationPiFromOmegacToPv, + full::DecayLenXYOmegac, + full::CosPaCascToPv, full::CosPaOmegacToPv, + full::InvMassCascade, full::InvMassCharmBaryon, + full::KfptPiFromOmegac, full::KfptOmegac, + full::CosThetaStarPiFromOmegac, full::CtOmegac, full::EtaOmegac, + full::V0Chi2OverNdf, full::CascChi2OverNdf, full::OmegacChi2OverNdf, + full::CascRejectInvmass, + full::FlagMcMatchRec, full::OriginMcRec, full::CollisionMatched, hf_track_index::HFflag); } // namespace o2::aod /// Writes the full information in an output TTree @@ -204,12 +233,18 @@ struct HfTreeCreatorOmegac0ToOmegaPi { Produces rowCandidateLite; Produces rowKfCandidateFull; + Produces rowKfCandidateLite; Produces rowEv; Configurable zPvCut{"zPvCut", 10., "Cut on absolute value of primary vertex z coordinate"}; + Configurable keepOnlyMcSignal{"keepOnlyMcSignal", true, "Fill MC tree only with signal candidates"}; + + using Tracks = soa::Join; + using Colls = soa::Join; + using CandKfSel = soa::Filtered>; + using CascKfMcSel = soa::Filtered>; - using MyTrackTable = soa::Join; - using MyEventTable = soa::Join; + Filter filterOmegaCToOmegaPiFlag = (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaPi))) != static_cast(0); void init(InitContext const&) { @@ -230,8 +265,8 @@ struct HfTreeCreatorOmegac0ToOmegaPi { candidate.xPv(), candidate.yPv(), candidate.zPv(), - candidate.template collision_as().numContrib(), - candidate.template collision_as().chi2(), + candidate.template collision_as().numContrib(), + candidate.template collision_as().chi2(), candidate.xDecayVtxCharmBaryon(), candidate.yDecayVtxCharmBaryon(), candidate.zDecayVtxCharmBaryon(), @@ -277,8 +312,8 @@ struct HfTreeCreatorOmegac0ToOmegaPi { candidate.errorDecayLengthCharmBaryon(), candidate.impactParCascXY() / candidate.errImpactParCascXY(), candidate.impactParBachFromCharmBaryonXY() / candidate.errImpactParBachFromCharmBaryonXY(), - candidate.template bachelorFromCharmBaryon_as().isGlobalTrackWoDCA(), - candidate.template bachelorFromCharmBaryon_as().itsNCls(), + candidate.template bachelorFromCharmBaryon_as().isGlobalTrackWoDCA(), + candidate.template bachelorFromCharmBaryon_as().itsNCls(), candidate.pidTpcInfoStored(), candidate.pidTofInfoStored(), candidate.tpcNSigmaPiFromCharmBaryon(), @@ -291,7 +326,8 @@ struct HfTreeCreatorOmegac0ToOmegaPi { candidate.tofNSigmaPrFromLambda(), flagMc, originMc, - collisionMatched); + collisionMatched, + candidate.hfflag()); } } @@ -326,6 +362,7 @@ struct HfTreeCreatorOmegac0ToOmegaPi { candidate.chi2TopoCascToPv(), candidate.chi2TopoPiFromOmegacToPv(), candidate.chi2TopoOmegacToPv(), + candidate.deviationPiFromOmegacToPv(), candidate.chi2TopoV0ToCasc(), candidate.chi2TopoCascToOmegac(), candidate.decayLenXYLambda(), @@ -343,7 +380,7 @@ struct HfTreeCreatorOmegac0ToOmegaPi { candidate.kfptPiFromOmegac(), candidate.kfptOmegac(), candidate.cosThetaStarPiFromOmegac(), - candidate.ctauOmegac(), + candidate.cTauOmegac(), candidate.etaCharmBaryon(), candidate.v0Ndf(), candidate.cascNdf(), @@ -355,14 +392,59 @@ struct HfTreeCreatorOmegac0ToOmegaPi { candidate.omegacChi2OverNdf(), candidate.massV0Chi2OverNdf(), candidate.massCascChi2OverNdf(), + candidate.cascRejectInvmass(), flagMc, originMc, - collisionMatched); + collisionMatched, + candidate.hfflag()); } } - void processDataLite(MyEventTable const& collisions, MyTrackTable const&, - soa::Join const& candidates) + template + void fillKfCandidateLite(const T& candidate, int8_t flagMc, int8_t originMc, bool collisionMatched) + { + if (candidate.resultSelections() && candidate.statusPidCharmBaryon() && candidate.statusInvMassLambda() && candidate.statusInvMassCascade() && candidate.statusInvMassCharmBaryon()) { + + rowKfCandidateLite( + candidate.tpcNSigmaPiFromCharmBaryon(), + candidate.tofNSigmaPiFromCharmBaryon(), + candidate.tpcNSigmaKaFromCasc(), + candidate.tofNSigmaKaFromCasc(), + candidate.tpcNSigmaPiFromLambda(), + candidate.tpcNSigmaPrFromLambda(), + candidate.kfDcaXYPiFromOmegac(), + candidate.dcaCharmBaryonDau(), + candidate.kfDcaXYCascToPv(), + candidate.dcaCascDau(), + candidate.v0ldl(), + candidate.cascldl(), + candidate.omegacldl(), + candidate.chi2TopoPiFromOmegacToPv(), + candidate.chi2TopoOmegacToPv(), + candidate.deviationPiFromOmegacToPv(), + candidate.decayLenXYOmegac(), + candidate.cosPACasc(), + candidate.cosPACharmBaryon(), + candidate.invMassCascade(), + candidate.invMassCharmBaryon(), + candidate.kfptPiFromOmegac(), + candidate.kfptOmegac(), + candidate.cosThetaStarPiFromOmegac(), + candidate.cTauOmegac(), + candidate.etaCharmBaryon(), + candidate.v0Chi2OverNdf(), + candidate.cascChi2OverNdf(), + candidate.omegacChi2OverNdf(), + candidate.cascRejectInvmass(), + flagMc, + originMc, + collisionMatched, + candidate.hfflag()); + } + } // fillKfCandidateLite end + + void processDataLite(Colls const& collisions, Tracks const&, + soa::Filtered> const& candidates) { // Filling event properties rowEv.reserve(collisions.size()); @@ -376,10 +458,9 @@ struct HfTreeCreatorOmegac0ToOmegaPi { fillCandidateLite(candidate, -7, RecoDecay::OriginType::None, false); } } - PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processDataLite, "Process data", true); + PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processDataLite, "Process data", false); - void processKfDataFull(MyEventTable const& collisions, MyTrackTable const&, - soa::Join const& candidates) + void processKfDataFull(Colls const& collisions, Tracks const&, CandKfSel const& candidates) { // Filling event properties rowEv.reserve(collisions.size()); @@ -395,8 +476,24 @@ struct HfTreeCreatorOmegac0ToOmegaPi { } PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKfDataFull, "Process KF data", false); - void processMcLite(MyEventTable const& collisions, MyTrackTable const&, - soa::Join const& candidates) + void processKfDataLite(Colls const& collisions, Tracks const&, CandKfSel const& candidates) + { + // Filling event properties + rowEv.reserve(collisions.size()); + for (const auto& collision : collisions) { + fillEvent(collision, zPvCut); + } + + // Filling candidate properties + rowKfCandidateFull.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillKfCandidateLite(candidate, -7, RecoDecay::OriginType::None, false); + } + } + PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKfDataLite, "Process KF data Lite", false); + + void processMcLite(Colls const& collisions, Tracks const&, + soa::Filtered> const& candidates) { // Filling event properties rowEv.reserve(collisions.size()); @@ -407,13 +504,12 @@ struct HfTreeCreatorOmegac0ToOmegaPi { // Filling candidate properties rowCandidateLite.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originRec(), candidate.collisionMatched()); + fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); } } PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processMcLite, "Process MC", false); - void processKFMcFull(MyEventTable const& collisions, MyTrackTable const&, - soa::Join const& candidates) + void processKFMcFull(Colls const& collisions, Tracks const&, CascKfMcSel const& candidates) { // Filling event properties rowEv.reserve(collisions.size()); @@ -424,11 +520,39 @@ struct HfTreeCreatorOmegac0ToOmegaPi { // Filling candidate properties rowCandidateLite.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillKfCandidate(candidate, candidate.flagMcMatchRec(), candidate.originRec(), candidate.collisionMatched()); + if (keepOnlyMcSignal) { + if (candidate.originMcRec() != 0) { + fillKfCandidate(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); + } + } else { + fillKfCandidate(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); + } } } PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKFMcFull, "Process KF MC", false); + void processKFMcLite(Colls const& collisions, Tracks const&, CascKfMcSel const& candidates) + { + // Filling event properties + rowEv.reserve(collisions.size()); + for (const auto& collision : collisions) { + fillEvent(collision, zPvCut); + } + + // Filling candidate properties + rowCandidateLite.reserve(candidates.size()); + for (const auto& candidate : candidates) { + if (keepOnlyMcSignal) { + if (candidate.originMcRec() != 0) { + fillKfCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); + } + } else { + fillKfCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); + } + } + } + PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKFMcLite, "Process KF MC Lite", false); + }; // end of struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/treeCreatorOmegacSt.cxx b/PWGHF/TableProducer/treeCreatorOmegacSt.cxx index e2af6b5cff8..c291852c448 100644 --- a/PWGHF/TableProducer/treeCreatorOmegacSt.cxx +++ b/PWGHF/TableProducer/treeCreatorOmegacSt.cxx @@ -9,39 +9,62 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file taskOmegacSt.cxx -/// \brief Task to reconstruct Ωc from strangeness-tracked Ω and pion +/// \file treeCreatorOmegacSt.cxx +/// \brief Task to reconstruct Ωc from strangeness-tracked Ω and pion/kaon /// /// \author Jochen Klein +/// \author Tiantian Cheng -#include -#include +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "CCDB/BasicCCDBManager.h" -#include "CommonConstants/PhysicsConstants.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DCAFitter/DCAFitterN.h" -#include "DetectorsBase/Propagator.h" -#include "EventFiltering/Zorro.h" -#include "EventFiltering/ZorroSummary.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoA.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/DCA.h" -#include "Common/DataModel/EventSelection.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/CollisionAssociationTables.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGHF/Core/SelectorCuts.h" -#include "PWGHF/Utils/utilsTrkCandHf.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -64,6 +87,8 @@ DECLARE_SOA_COLUMN(DecayLengthCharmedBaryon, decayLengthCharmedBaryon, float); DECLARE_SOA_COLUMN(DecayLengthXYCharmedBaryon, decayLengthXYCharmedBaryon, float); DECLARE_SOA_COLUMN(DecayLengthCasc, decayLengthCasc, float); DECLARE_SOA_COLUMN(DecayLengthXYCasc, decayLengthXYCasc, float); +DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int); +DECLARE_SOA_COLUMN(DecayChannel, decayChannel, int); } // namespace hf_st_charmed_baryon_gen DECLARE_SOA_TABLE(HfStChBarGens, "AOD", "HFSTCHBARGEN", @@ -78,9 +103,11 @@ DECLARE_SOA_TABLE(HfStChBarGens, "AOD", "HFSTCHBARGEN", hf_st_charmed_baryon_gen::DecayLengthCharmedBaryon, hf_st_charmed_baryon_gen::DecayLengthXYCharmedBaryon, hf_st_charmed_baryon_gen::DecayLengthCasc, - hf_st_charmed_baryon_gen::DecayLengthXYCasc); + hf_st_charmed_baryon_gen::DecayLengthXYCasc, + hf_st_charmed_baryon_gen::OriginMcGen, + hf_st_charmed_baryon_gen::DecayChannel); -// CharmedBaryon -> Casc + Pion +// CharmedBaryon -> Casc + Pion/Kaon // -> Lambda + BachPi/BachKa // -> Pr + Pi namespace hf_st_charmed_baryon @@ -90,6 +117,8 @@ DECLARE_SOA_COLUMN(MassXi, massXi, float); DECLARE_SOA_COLUMN(MassLambda, massLambda, float); DECLARE_SOA_COLUMN(NSigmaTpcPion, nSigmaTpcPion, float); DECLARE_SOA_COLUMN(NSigmaTofPion, nSigmaTofPion, float); +DECLARE_SOA_COLUMN(NSigmaTpcKaon, nSigmaTpcKaon, float); +DECLARE_SOA_COLUMN(NSigmaTofKaon, nSigmaTofKaon, float); DECLARE_SOA_COLUMN(NSigmaTpcV0Pr, nSigmaTpcV0Pr, float); DECLARE_SOA_COLUMN(NSigmaTofV0Pr, nSigmaTofV0Pr, float); DECLARE_SOA_COLUMN(NSigmaTpcV0Pi, nSigmaTpcV0Pi, float); @@ -102,11 +131,11 @@ DECLARE_SOA_COLUMN(PxCasc, pxCasc, float); DECLARE_SOA_COLUMN(PyCasc, pyCasc, float); DECLARE_SOA_COLUMN(PzCasc, pzCasc, float); DECLARE_SOA_COLUMN(IsPositiveCasc, isPositiveCasc, bool); -DECLARE_SOA_COLUMN(PxPion, pxPion, float); -DECLARE_SOA_COLUMN(PyPion, pyPion, float); -DECLARE_SOA_COLUMN(PzPion, pzPion, float); -DECLARE_SOA_COLUMN(IsPositivePion, isPositivePion, bool); -DECLARE_SOA_COLUMN(ITSClusterMapPion, itsClusterMapPion, uint8_t); +DECLARE_SOA_COLUMN(PxPionOrKaon, pxPionOrKaon, float); +DECLARE_SOA_COLUMN(PyPionOrKaon, pyPionOrKaon, float); +DECLARE_SOA_COLUMN(PzPionOrKaon, pzPionOrKaon, float); +DECLARE_SOA_COLUMN(IsPositivePionOrKaon, isPositivePionOrKaon, bool); +DECLARE_SOA_COLUMN(ItsClusterMapPionOrKaon, itsClusterMapPionOrKaon, uint8_t); DECLARE_SOA_COLUMN(CpaCharmedBaryon, cpaCharmedBaryon, float); DECLARE_SOA_COLUMN(CpaXYCharmedBaryon, cpaXYCharmedBaryon, float); DECLARE_SOA_COLUMN(CpaCasc, cpaCasc, float); @@ -115,10 +144,10 @@ DECLARE_SOA_COLUMN(DcaXYCasc, dcaXYCasc, float); DECLARE_SOA_COLUMN(DcaXYUncCasc, dcaXYUncCasc, float); DECLARE_SOA_COLUMN(DcaZCasc, dcaZCasc, float); DECLARE_SOA_COLUMN(DcaZUncCasc, dcaZUncCasc, float); -DECLARE_SOA_COLUMN(DcaXYPion, dcaXYPion, float); -DECLARE_SOA_COLUMN(DcaXYUncPion, dcaXYUncPion, float); -DECLARE_SOA_COLUMN(DcaZPion, dcaZPion, float); -DECLARE_SOA_COLUMN(DcaZUncPion, dcaZUncPion, float); +DECLARE_SOA_COLUMN(DcaXYPionOrKaon, dcaXYPionOrKaon, float); +DECLARE_SOA_COLUMN(DcaXYUncPionOrKaon, dcaXYUncPionOrKaon, float); +DECLARE_SOA_COLUMN(DcaZPionOrKaon, dcaZPionOrKaon, float); +DECLARE_SOA_COLUMN(DcaZUncPionOrKaon, dcaZUncPionOrKaon, float); DECLARE_SOA_COLUMN(DcaXYPr, dcaXYPr, float); DECLARE_SOA_COLUMN(DcaZPr, dcaZPr, float); DECLARE_SOA_COLUMN(DcaXYKa, dcaXYKa, float); @@ -134,7 +163,8 @@ DECLARE_SOA_COLUMN(DecayLengthXYCharmedBaryonUntracked, decayLengthXYCharmedBary DECLARE_SOA_COLUMN(DecayLengthCasc, decayLengthCasc, float); DECLARE_SOA_COLUMN(DecayLengthXYCasc, decayLengthXYCasc, float); DECLARE_SOA_INDEX_COLUMN_FULL(MotherCasc, motherCasc, int, HfStChBarGens, "_Casc"); -DECLARE_SOA_INDEX_COLUMN_FULL(MotherPion, motherPion, int, HfStChBarGens, "_Pion"); +DECLARE_SOA_INDEX_COLUMN_FULL(MotherPionOrKaon, motherPionOrKaon, int, HfStChBarGens, "_PionOrKaon"); +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int); } // namespace hf_st_charmed_baryon DECLARE_SOA_TABLE(HfStChBars, "AOD", "HFSTCHBAR", @@ -143,6 +173,8 @@ DECLARE_SOA_TABLE(HfStChBars, "AOD", "HFSTCHBAR", hf_st_charmed_baryon::MassLambda, hf_st_charmed_baryon::NSigmaTpcPion, hf_st_charmed_baryon::NSigmaTofPion, + hf_st_charmed_baryon::NSigmaTpcKaon, + hf_st_charmed_baryon::NSigmaTofKaon, hf_st_charmed_baryon::NSigmaTpcV0Pr, hf_st_charmed_baryon::NSigmaTofV0Pr, hf_st_charmed_baryon::NSigmaTpcV0Pi, @@ -155,11 +187,11 @@ DECLARE_SOA_TABLE(HfStChBars, "AOD", "HFSTCHBAR", hf_st_charmed_baryon::PyCasc, hf_st_charmed_baryon::PzCasc, hf_st_charmed_baryon::IsPositiveCasc, - hf_st_charmed_baryon::PxPion, - hf_st_charmed_baryon::PyPion, - hf_st_charmed_baryon::PzPion, - hf_st_charmed_baryon::IsPositivePion, - hf_st_charmed_baryon::ITSClusterMapPion, + hf_st_charmed_baryon::PxPionOrKaon, + hf_st_charmed_baryon::PyPionOrKaon, + hf_st_charmed_baryon::PzPionOrKaon, + hf_st_charmed_baryon::IsPositivePionOrKaon, + hf_st_charmed_baryon::ItsClusterMapPionOrKaon, hf_st_charmed_baryon::CpaCharmedBaryon, hf_st_charmed_baryon::CpaXYCharmedBaryon, hf_st_charmed_baryon::CpaCasc, @@ -168,10 +200,10 @@ DECLARE_SOA_TABLE(HfStChBars, "AOD", "HFSTCHBAR", hf_st_charmed_baryon::DcaXYUncCasc, hf_st_charmed_baryon::DcaZCasc, hf_st_charmed_baryon::DcaZUncCasc, - hf_st_charmed_baryon::DcaXYPion, - hf_st_charmed_baryon::DcaXYUncPion, - hf_st_charmed_baryon::DcaZPion, - hf_st_charmed_baryon::DcaZUncPion, + hf_st_charmed_baryon::DcaXYPionOrKaon, + hf_st_charmed_baryon::DcaXYUncPionOrKaon, + hf_st_charmed_baryon::DcaZPionOrKaon, + hf_st_charmed_baryon::DcaZUncPionOrKaon, hf_st_charmed_baryon::DcaXYPr, hf_st_charmed_baryon::DcaZPr, hf_st_charmed_baryon::DcaXYKa, @@ -187,16 +219,14 @@ DECLARE_SOA_TABLE(HfStChBars, "AOD", "HFSTCHBAR", hf_st_charmed_baryon::DecayLengthCasc, hf_st_charmed_baryon::DecayLengthXYCasc, hf_st_charmed_baryon::MotherCascId, - hf_st_charmed_baryon::MotherPionId); + hf_st_charmed_baryon::MotherPionOrKaonId, + hf_st_charmed_baryon::OriginMcRec); } // namespace o2::aod struct HfTreeCreatorOmegacSt { Produces outputTable; Produces outputTableGen; - Zorro zorro; - OutputObj zorroSummary{"zorroSummary"}; - Configurable materialCorrectionType{"materialCorrectionType", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrLUT), "Type of material correction"}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable grpMagPath{"grpMagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; @@ -210,8 +240,8 @@ struct HfTreeCreatorOmegacSt { Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"}; Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations if chi2/chi2old > this"}; Configurable minNoClsTrackedCascade{"minNoClsTrackedCascade", 70, "Minimum number of clusters required for daughters of tracked cascades"}; - Configurable minNoClsTrackedPion{"minNoClsTrackedPion", 70, "Minimum number of clusters required for associated pions"}; - Configurable filterCollisions{"filterCollisions", 8, "0: no filtering; 8: sel8"}; + Configurable minNoClsTrackedPionOrKaon{"minNoClsTrackedPionOrKaon", 70, "Minimum number of clusters required for associated pions/kaons"}; + Configurable useSel8Trigger{"useSel8Trigger", true, "filter collisions on sel 8 trigger"}; Configurable massWindowTrackedOmega{"massWindowTrackedOmega", 0.05, "Inv. mass window for tracked Omega"}; Configurable massWindowXiExclTrackedOmega{"massWindowXiExclTrackedOmega", 0.005, "Inv. mass window for exclusion of Xi for tracked Omega-"}; Configurable massWindowTrackedXi{"massWindowTrackedXi", 0., "Inv. mass window for tracked Xi"}; @@ -224,8 +254,14 @@ struct HfTreeCreatorOmegacSt { Configurable maxNSigmaV0Pr{"maxNSigmaV0Pr", 5., "Max Nsigma for proton from V0 from tracked cascade"}; Configurable maxNSigmaV0Pi{"maxNSigmaV0Pi", 5., "Max Nsigma for pion from V0 from tracked cascade"}; Configurable maxNSigmaPion{"maxNSigmaPion", 5., "Max Nsigma for pion to be paired with Omega"}; + Configurable maxNSigmaKaon{"maxNSigmaKaon", 5., "Max Nsigma for kaon to be paired with Omega"}; Configurable bzOnly{"bzOnly", true, "Use B_z instead of full field map"}; + const int itsNClsMin = 4; + const float tpcNclsFindableFraction = 0.8; + const float tpcChi2NclMax = 4.; + const float itsChi2NclMax = 36.; + SliceCache cache; Service ccdb; o2::vertexing::DCAFitterN<2> df2; @@ -238,14 +274,13 @@ struct HfTreeCreatorOmegacSt { using TracksExt = soa::Join; using TracksExtMc = soa::Join; - Filter collisionFilter = (filterCollisions.node() == 0) || - (filterCollisions.node() == 8 && o2::aod::evsel::sel8 == true); + Filter collisionFilter = (useSel8Trigger.node() == false) || (o2::aod::evsel::sel8 == true); // Preslice perCol = aod::track::collisionId; PresliceUnsorted trackIndicesPerCollision = aod::track_association::collisionId; PresliceUnsorted assignedTrackedCascadesPerCollision = aod::track::collisionId; - std::shared_ptr hCandidatesPrPi, hCandidatesV0Pi, hCandidatesCascPi; + std::shared_ptr hCandidatesPrPi, hCandidatesV0Pi, hCandidatesCascPiOrK; HistogramRegistry registry{ "registry", { @@ -264,14 +299,19 @@ struct HfTreeCreatorOmegacSt { {"hDecayLengthScaledId", "Decay length * M/p (true #Omega_{c});L (#mum / #it{c})", {HistType::kTH1D, {{200, 0., 500.}}}}, {"hDecayLengthScaledGen", "Decay length * M/p (MC id);L (#mum / #it{c})", {HistType::kTH1D, {{200, 0., 500.}}}}, {"hDecayLengthScaledMc", "Decay length * M/p (MC);L (#mum / #it{c})", {HistType::kTH1D, {{200, 0., 500.}}}}, - {"hMassOmegac", "inv. mass #Omega + #pi;inv. mass (GeV/#it{c}^{2})", {HistType::kTH1D, {{400, 1.5, 3.}}}}, - {"hMassOmegacVsPt", "inv. mass #Omega + #pi;inv. mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", {HistType::kTH2D, {{400, 1.5, 3.}, {10, 0., 10.}}}}, + {"hMassOmegaPi", "inv. mass #Omega + #pi;inv. mass (GeV/#it{c}^{2})", {HistType::kTH1D, {{400, 1.5, 3.}}}}, + {"hMassOmegaPiVsPt", "inv. mass #Omega + #pi;inv. mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", {HistType::kTH2D, {{400, 1.5, 3.}, {10, 0., 10.}}}}, + {"hMassOmegaK", "inv. mass #Omega + K;inv. mass (GeV/#it{c}^{2})", {HistType::kTH1D, {{400, 1.5, 3.}}}}, + {"hMassOmegaKVsPt", "inv. mass #Omega + K;inv. mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", {HistType::kTH2D, {{400, 1.5, 3.}, {10, 0., 10.}}}}, {"hMassOmegacId", "inv. mass #Omega + #pi (MC ID);inv. mass (GeV/#it{c}^{2})", {HistType::kTH1D, {{400, 1.5, 3.}}}}, {"hMassOmegacGen", "inv. mass #Omega + #pi (from MC);inv. mass (GeV/#it{c}^{2})", {HistType::kTH1D, {{400, 1.5, 3.}}}}, {"hPtVsMassOmega", "#Omega mass;p_{T} (GeV/#it{c});m (GeV/#it{c}^3)", {HistType::kTH2D, {{200, 0., 10.}, {1000, 1., 3.}}}}, {"hDeltaPtVsPt", "Delta pt;p_{T} (GeV/#it{c});#Delta p_{T} / p_{T}", {HistType::kTH2D, {{200, 0., 10.}, {200, -1., 1.}}}}, }}; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + void init(InitContext const&) { df2.setPropagateToPCA(propToDCA); @@ -294,15 +334,27 @@ struct HfTreeCreatorOmegacSt { /// candidate monitoring hCandidatesPrPi = registry.add("hCandidatesPrPi", "Pr-Pi candidates counter", {HistType::kTH1D, {axisCands}}); hCandidatesV0Pi = registry.add("hCandidatesV0Pi", "V0-Pi candidates counter", {HistType::kTH1D, {axisCands}}); - hCandidatesCascPi = registry.add("hCandidatesCascPi", "Casc-Pi candidates counter", {HistType::kTH1D, {axisCands}}); + hCandidatesCascPiOrK = registry.add("hCandidatesCascPiOrK", "Casc-Pi/K candidates counter", {HistType::kTH1D, {axisCands}}); setLabelHistoCands(hCandidatesPrPi); setLabelHistoCands(hCandidatesV0Pi); - setLabelHistoCands(hCandidatesCascPi); + setLabelHistoCands(hCandidatesCascPiOrK); } // processMC: loop over MC objects // processData: loop over reconstructed objects, no MC information // processGen: loop over reconstructed objects, use MC information (mutually exclusive? combine?) + int indexRec = -1; + int indexRecCharmBaryon = -1; + int8_t sign = -9; + int8_t signCasc = -9; + int8_t signV0 = -9; + int8_t origin = 0; // to be used for prompt/non prompt + int8_t nPiToMuV0{0}, nPiToMuCasc{0}, nPiToMuOmegac0{0}; + int8_t nKaToPiCasc{0}, nKaToPiOmegac0{0}; + std::vector idxBhadMothers{}; + int decayChannel = -1; // flag for different decay channels + bool isMatched = false; + static constexpr std::size_t NDaughters{2u}; void processMc(aod::McCollisions const&, aod::McParticles const& mcParticles) @@ -313,9 +365,10 @@ struct HfTreeCreatorOmegacSt { const bool isXiC = std::abs(mcParticle.pdgCode()) == constants::physics::Pdg::kXiC0; if (isOmegaC || isXiC) { const auto daughters = mcParticle.daughters_as(); - if (daughters.size() == 2) { + if (daughters.size() == NDaughters) { int idxPionDaughter = -1; int idxCascDaughter = -1; + int idxKaonDaughter = -1; const auto daughters = mcParticle.daughters_as(); for (const auto& daughter : daughters) { if (idxCascDaughter < 0 && (std::abs(daughter.pdgCode()) == (isOmegaC ? kOmegaMinus : kXiMinus))) { @@ -324,8 +377,22 @@ struct HfTreeCreatorOmegacSt { if (idxPionDaughter < 0 && (std::abs(daughter.pdgCode()) == kPiPlus)) { idxPionDaughter = daughter.globalIndex(); } + if (idxKaonDaughter < 0 && (std::abs(daughter.pdgCode()) == kKPlus)) { + idxKaonDaughter = daughter.globalIndex(); + } } - if ((idxPionDaughter >= 0) && (idxCascDaughter >= 0)) { + if (idxPionDaughter >= 0 && idxCascDaughter >= 0) { + decayChannel = o2::aod::hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaPi; // OmegaC -> Omega + Pi + } else if (idxKaonDaughter >= 0 && idxCascDaughter >= 0) { + decayChannel = o2::aod::hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaK; // OmegaC -> Omega + K + } else { + decayChannel = -1; // LOG(warning) << "Decay channel not recognized!"; + } + if (decayChannel != -1) { + int idxDaughter = (decayChannel == o2::aod::hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaPi) ? idxPionDaughter : idxKaonDaughter; + auto particle = mcParticles.rawIteratorAt(idxDaughter); + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + const auto& cascDaughter = mcParticles.iteratorAt(idxCascDaughter); const auto& mcColl = mcParticle.mcCollision(); std::array primaryVertexPosGen = {mcColl.posX(), mcColl.posY(), mcColl.posZ()}; @@ -353,7 +420,9 @@ struct HfTreeCreatorOmegacSt { decayLengthGen, decayLengthXYGen, decayLengthCascGen, - decayLengthXYCascGen); + decayLengthXYCascGen, + origin, + decayChannel); mapMcPartToGenTable[mcParticle.globalIndex()] = outputTableGen.lastIndex(); } } @@ -365,7 +434,8 @@ struct HfTreeCreatorOmegacSt { template void fillTable(Collisions const& collisions, aod::AssignedTrackedCascades const& trackedCascades, - aod::TrackAssoc const& trackIndices) + aod::TrackAssoc const& trackIndices, + std::optional> mcParticles = std::nullopt) { const auto matCorr = static_cast(materialCorrectionType.value); @@ -451,8 +521,8 @@ struct HfTreeCreatorOmegacSt { } hCandidatesPrPi->Fill(SVFitting::FitOk); - std::array massesV0Daughters{o2::constants::physics::MassProton, o2::constants::physics::MassPiMinus}; - std::array, 2> momentaV0Daughters; + std::array massesV0Daughters{o2::constants::physics::MassProton, o2::constants::physics::MassPiMinus}; + std::array, NDaughters> momentaV0Daughters; o2::track::TrackPar trackParV0Pr = df2.getTrackParamAtPCA(0); trackParV0Pr.getPxPyPzGlo(momentaV0Daughters[0]); o2::track::TrackPar trackParV0Pi = df2.getTrackParamAtPCA(1); @@ -477,7 +547,7 @@ struct HfTreeCreatorOmegacSt { const auto decayLengthCascXY = RecoDecay::distanceXY(secondaryVertex, primaryVertexPos); o2::track::TrackPar trackParV0 = df2.getTrackParamAtPCA(0); o2::track::TrackPar trackParBachelor = df2.getTrackParamAtPCA(1); - std::array, 2> momentaCascDaughters; + std::array, NDaughters> momentaCascDaughters; trackParV0.getPxPyPzGlo(momentaCascDaughters[0]); trackParBachelor.getPxPyPzGlo(momentaCascDaughters[1]); o2::track::TrackParCov trackParCovCascUntracked = df2.createParentTrackParCov(0); @@ -486,9 +556,9 @@ struct HfTreeCreatorOmegacSt { const auto cpaCasc = RecoDecay::cpa(primaryVertexPos, df2.getPCACandidate(), pCasc); const auto cpaXYCasc = RecoDecay::cpaXY(primaryVertexPos, df2.getPCACandidate(), pCasc); - std::array massesXiDaughters = {o2::constants::physics::MassLambda0, o2::constants::physics::MassPiPlus}; + std::array massesXiDaughters = {o2::constants::physics::MassLambda0, o2::constants::physics::MassPiPlus}; const auto massXi = RecoDecay::m(momentaCascDaughters, massesXiDaughters); - std::array massesOmegaDaughters = {o2::constants::physics::MassLambda0, o2::constants::physics::MassKPlus}; + std::array massesOmegaDaughters = {o2::constants::physics::MassLambda0, o2::constants::physics::MassKPlus}; const auto massOmega = RecoDecay::m(momentaCascDaughters, massesOmegaDaughters); registry.fill(HIST("hDca"), std::sqrt(impactParameterCasc.getR2())); @@ -505,9 +575,11 @@ struct HfTreeCreatorOmegacSt { if (((std::abs(bachelor.tpcNSigmaKa()) < maxNSigmaBachelor) || (std::abs(bachelor.tpcNSigmaPi()) < maxNSigmaBachelor)) && (std::abs(v0TrackPr.tpcNSigmaPr()) < maxNSigmaV0Pr) && (std::abs(v0TrackPi.tpcNSigmaPi()) < maxNSigmaV0Pi)) { - std::array massesOmegacDaughters{o2::constants::physics::MassOmegaMinus, o2::constants::physics::MassPiPlus}; - std::array massesXicDaughters{o2::constants::physics::MassXiMinus, o2::constants::physics::MassPiPlus}; - std::array, 2> momenta; + + std::array massesOmegacToOmegaPi{o2::constants::physics::MassOmegaMinus, o2::constants::physics::MassPiPlus}; + std::array massesOmegacToOmegaK{o2::constants::physics::MassOmegaMinus, o2::constants::physics::MassKPlus}; + std::array massesXicDaughters{o2::constants::physics::MassXiMinus, o2::constants::physics::MassPiPlus}; + std::array, NDaughters> momenta; auto trackParCovPr = getTrackParCov(v0TrackPr); auto trackParCovKa = getTrackParCov(v0TrackPi); @@ -525,21 +597,21 @@ struct HfTreeCreatorOmegacSt { o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVertex, trackParCovPi, 2.f, matCorr, &impactParameterPi); } - for (auto trackId : groupedTrackIds) { + for (const auto& trackId : groupedTrackIds) { const auto track = trackId.template track_as(); if (track.globalIndex() == v0TrackPr.globalIndex() || track.globalIndex() == v0TrackPi.globalIndex() || track.globalIndex() == bachelor.globalIndex()) { continue; } - if ((track.itsNCls() >= 4) && - (track.tpcNClsFound() >= minNoClsTrackedPion) && - (track.tpcNClsCrossedRows() >= minNoClsTrackedPion) && - (track.tpcNClsCrossedRows() >= 0.8 * track.tpcNClsFindable()) && - (track.tpcChi2NCl() <= 4.f) && - (track.itsChi2NCl() <= 36.f) && - (std::abs(track.tpcNSigmaPi()) < maxNSigmaPion)) { - LOGF(debug, " .. combining with pion candidate %d", track.globalIndex()); + if ((track.itsNCls() >= itsNClsMin) && + (track.tpcNClsFound() >= minNoClsTrackedPionOrKaon) && + (track.tpcNClsCrossedRows() >= minNoClsTrackedPionOrKaon) && + (track.tpcNClsCrossedRows() >= tpcNclsFindableFraction * track.tpcNClsFindable()) && + (track.tpcChi2NCl() <= tpcChi2NclMax) && + (track.itsChi2NCl() <= itsChi2NclMax) && + (std::abs(track.tpcNSigmaPi()) < maxNSigmaPion || std::abs(track.tpcNSigmaKa()) < maxNSigmaKaon)) { + LOGF(debug, " .. combining with pion/kaon candidate %d", track.globalIndex()); int trackMotherId = -1; if constexpr (std::is_same::value) { if (track.has_mcParticle() && track.mcParticle().has_mothers()) { @@ -549,24 +621,24 @@ struct HfTreeCreatorOmegacSt { } } auto trackParCovCasc = getTrackParCov(trackCasc); - auto trackParCovPion = getTrackParCov(track); + auto trackParCovPionOrKaon = getTrackParCov(track); o2::dataformats::DCA impactParameterPion; if (bzOnly) { - o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, trackParCovPion, bz, 2.f, matCorr, &impactParameterPion); + o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, trackParCovPionOrKaon, bz, 2.f, matCorr, &impactParameterPion); } else { - o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVertex, trackParCovPion, 2.f, matCorr, &impactParameterPion); + o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVertex, trackParCovPionOrKaon, 2.f, matCorr, &impactParameterPion); } - hCandidatesCascPi->Fill(SVFitting::BeforeFit); + hCandidatesCascPiOrK->Fill(SVFitting::BeforeFit); try { auto decayLengthUntracked = -1.; auto decayLengthXYUntracked = -1.; - if (df2.process(trackParCovCascUntracked, trackParCovPion)) { + if (df2.process(trackParCovCascUntracked, trackParCovPionOrKaon)) { const auto& secondaryVertexUntracked = df2.getPCACandidate(); decayLengthUntracked = RecoDecay::distance(secondaryVertexUntracked, primaryVertexPos); decayLengthXYUntracked = RecoDecay::distanceXY(secondaryVertexUntracked, primaryVertexPos); } - if (df2.process(trackParCovCasc, trackParCovPion)) { + if (df2.process(trackParCovCasc, trackParCovPionOrKaon)) { const auto& secondaryVertex = df2.getPCACandidate(); const auto decayLength = RecoDecay::distance(secondaryVertex, primaryVertexPos); const auto decayLengthXY = RecoDecay::distanceXY(secondaryVertex, primaryVertexPos); @@ -578,12 +650,71 @@ struct HfTreeCreatorOmegacSt { df2.getTrackParamAtPCA(0).getPxPyPzGlo(momenta[0]); df2.getTrackParamAtPCA(1).getPxPyPzGlo(momenta[1]); - const auto massOmegaC = RecoDecay::m(momenta, massesOmegacDaughters); + const auto massOmegaPi = RecoDecay::m(momenta, massesOmegacToOmegaPi); + const auto massOmegaK = RecoDecay::m(momenta, massesOmegacToOmegaK); const auto massXiC = RecoDecay::m(momenta, massesXicDaughters); - registry.fill(HIST("hMassOmegac"), massOmegaC); - registry.fill(HIST("hMassOmegacVsPt"), massOmegaC, RecoDecay::pt(momenta[0], momenta[1])); + registry.fill(HIST("hMassOmegaPi"), massOmegaPi); + registry.fill(HIST("hMassOmegaPiVsPt"), massOmegaPi, RecoDecay::pt(momenta[0], momenta[1])); + registry.fill(HIST("hMassOmegaK"), massOmegaK); + registry.fill(HIST("hMassOmegaKVsPt"), massOmegaK, RecoDecay::pt(momenta[0], momenta[1])); + + //--- do the MC Rec match + if (mcParticles) { + auto arrayDaughters = std::array{ + trackId.template track_as(), // bachelor <- charm baryon + casc.bachelor_as(), // bachelor <- cascade + v0.posTrack_as(), // p <- lambda + v0.negTrack_as()}; // pi <- lambda + + auto arrayDaughtersCasc = std::array{ + casc.bachelor_as(), // bachelor <- cascade + v0.posTrack_as(), // p <- lambda + v0.negTrack_as()}; // pi <- lambda + auto arrayDaughtersV0 = std::array{ + v0.posTrack_as(), // p <- lambda + v0.negTrack_as()}; // pi <- lambda + + if (decayChannel == o2::aod::hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaPi) { + // Match Omegac0 → Omega- + Pi+ + indexRec = RecoDecay::getMatchedMCRec(mcParticles->get(), arrayDaughters, o2::constants::physics::kOmegaC0, + std::array{+kPiPlus, +kKMinus, +kProton, +kPiMinus}, true, &sign, 3, &nPiToMuOmegac0, &nKaToPiOmegac0); + indexRecCharmBaryon = indexRec; + if (indexRec > -1) { + // Omega- → K pi p (Cascade match) + indexRec = RecoDecay::getMatchedMCRec(mcParticles->get(), arrayDaughtersCasc, +kOmegaMinus, std::array{+kKMinus, +kProton, +kPiMinus}, true, &signCasc, 2, &nPiToMuCasc, &nKaToPiCasc); + if (indexRec > -1) { + // Lambda → p pi (Lambda match) + indexRec = RecoDecay::getMatchedMCRec(mcParticles->get(), arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &signV0, 1, &nPiToMuV0); + if (indexRec > -1) { + isMatched = true; + } + } + } + } else if (decayChannel == o2::aod::hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaK) { + // Match Omegac0 → Omega- + K+ + indexRec = RecoDecay::getMatchedMCRec(mcParticles->get(), arrayDaughters, o2::constants::physics::kOmegaC0, + std::array{+kKPlus, +kKMinus, +kProton, +kPiMinus}, true, &sign, 3, &nPiToMuOmegac0, &nKaToPiOmegac0); + indexRecCharmBaryon = indexRec; + if (indexRec > -1) { + // Omega- → K pi p (Cascade match) + indexRec = RecoDecay::getMatchedMCRec(mcParticles->get(), arrayDaughtersCasc, +kOmegaMinus, std::array{+kKMinus, +kProton, +kPiMinus}, true, &signCasc, 2, &nPiToMuCasc, &nKaToPiCasc); + if (indexRec > -1) { + // Lambda → p pi (Lambda match) + indexRec = RecoDecay::getMatchedMCRec(mcParticles->get(), arrayDaughtersV0, +kLambda0, std::array{+kProton, +kPiMinus}, true, &signV0, 1, &nPiToMuV0); + if (indexRec > -1) { + isMatched = true; + } + } + } + } + if (isMatched && indexRecCharmBaryon > -1) { + auto particle = mcParticles->get().rawIteratorAt(indexRecCharmBaryon); + origin = RecoDecay::getCharmHadronOrigin(mcParticles->get(), particle, false, &idxBhadMothers); + } + } - if ((std::abs(massOmegaC - o2::constants::physics::MassOmegaC0) < massWindowOmegaC) || + if ((std::abs(massOmegaK - o2::constants::physics::MassOmegaC0) < massWindowOmegaC) || + (std::abs(massOmegaPi - o2::constants::physics::MassOmegaC0) < massWindowOmegaC) || (std::abs(massXiC - o2::constants::physics::MassXiC0) < massWindowXiC)) { registry.fill(HIST("hDecayLength"), decayLength * 1e4); registry.fill(HIST("hDecayLengthScaled"), decayLength * o2::constants::physics::MassOmegaC0 / RecoDecay::p(momenta[0], momenta[1]) * 1e4); @@ -592,6 +723,8 @@ struct HfTreeCreatorOmegacSt { massV0, track.tpcNSigmaPi(), track.tofNSigmaPi(), + track.tpcNSigmaKa(), + track.tofNSigmaKa(), v0TrackPr.tpcNSigmaPr(), v0TrackPr.tofNSigmaPr(), v0TrackPi.tpcNSigmaPi(), @@ -604,7 +737,7 @@ struct HfTreeCreatorOmegacSt { momenta[0][1], momenta[0][2], trackCasc.sign() > 0 ? true : false, - momenta[1][0], // pion momentum + momenta[1][0], // pion/kaon momentum momenta[1][1], momenta[1][2], track.sign() > 0 ? true : false, @@ -636,17 +769,18 @@ struct HfTreeCreatorOmegacSt { decayLengthCasc, decayLengthCascXY, trackCascMotherId, - trackMotherId); + trackMotherId, + origin); } } else { continue; } } catch (const std::runtime_error& error) { - LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN for Casc-Pi cannot work, skipping the candidate."; - hCandidatesCascPi->Fill(SVFitting::Fail); + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN for Casc-Pi/K cannot work, skipping the candidate."; + hCandidatesCascPiOrK->Fill(SVFitting::Fail); continue; } - hCandidatesCascPi->Fill(SVFitting::FitOk); + hCandidatesCascPiOrK->Fill(SVFitting::FitOk); } } } @@ -675,10 +809,10 @@ struct HfTreeCreatorOmegacSt { aod::V0s const&, // TracksExt const& tracks, // TODO: should be TracksExtMc TracksExtMc const&, - aod::McParticles const&, + aod::McParticles const& mcParticles, aod::BCsWithTimestamps const&) { - fillTable(collisions, trackedCascades, trackIndices); + fillTable(collisions, trackedCascades, trackIndices, mcParticles); } PROCESS_SWITCH(HfTreeCreatorOmegacSt, processMcRec, "Process MC reco", true); @@ -744,8 +878,8 @@ struct HfTreeCreatorOmegacSt { LOG(debug) << "cascade with PDG code: " << pdgCode; if (std::abs(pdgCode) == kOmegaMinus) { LOG(debug) << "found Omega, looking for pions"; - std::array masses{o2::constants::physics::MassOmegaMinus, o2::constants::physics::MassPiPlus}; - std::array, 2> momenta; + std::array masses{o2::constants::physics::MassOmegaMinus, o2::constants::physics::MassPiPlus}; + std::array, NDaughters> momenta; std::array primaryVertexPos = {primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}; const auto& mcColl = mother.mcCollision(); std::array primaryVertexPosGen = {mcColl.posX(), mcColl.posY(), mcColl.posZ()}; @@ -770,7 +904,7 @@ struct HfTreeCreatorOmegacSt { registry.fill(HIST("hDeltaPtVsPt"), mcpart.pt(), (trackParCovPion.getPt() - mcpart.pt()) / mcpart.pt()); registry.fill(HIST("hMassOmegacId"), RecoDecay::m(momenta, masses)); - hCandidatesCascPi->Fill(SVFitting::BeforeFit); + hCandidatesCascPiOrK->Fill(SVFitting::BeforeFit); try { if (df2.process(trackParCovCasc, trackParCovPion)) { const auto& secondaryVertex = df2.getPCACandidate(); @@ -791,11 +925,11 @@ struct HfTreeCreatorOmegacSt { } } } - hCandidatesCascPi->Fill(SVFitting::FitOk); + hCandidatesCascPiOrK->Fill(SVFitting::FitOk); } } catch (const std::runtime_error& error) { LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN for Casc-Pi cannot work, skipping the candidate."; - hCandidatesCascPi->Fill(SVFitting::Fail); + hCandidatesCascPiOrK->Fill(SVFitting::Fail); continue; } diff --git a/PWGHF/TableProducer/treeCreatorTccToD0D0Pi.cxx b/PWGHF/TableProducer/treeCreatorTccToD0D0Pi.cxx new file mode 100644 index 00000000000..a59713f4adf --- /dev/null +++ b/PWGHF/TableProducer/treeCreatorTccToD0D0Pi.cxx @@ -0,0 +1,754 @@ +// 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. + +/// \file treeCreatorTccToD0D0Pi.cxx +/// \brief tree creator for studying the charm exotic state Tcc to D0D0pi +/// \author Biao Zhang , Heidelberg University +/// \author Fabrizio Grosa , CERN + +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::analysis; +using namespace o2::constants::physics; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; + +namespace o2::aod +{ +namespace full +{ +DECLARE_SOA_INDEX_COLUMN(Collision, collision); +DECLARE_SOA_COLUMN(PxProng0D1, pxProng0D1, float); +DECLARE_SOA_COLUMN(PxProng1D1, pxProng1D1, float); +DECLARE_SOA_COLUMN(PyProng0D1, pyProng0D1, float); +DECLARE_SOA_COLUMN(PyProng1D1, pyProng1D1, float); +DECLARE_SOA_COLUMN(PzProng0D1, pzProng0D1, float); +DECLARE_SOA_COLUMN(PzProng1D1, pzProng1D1, float); +DECLARE_SOA_COLUMN(PxProng0D2, pxProng0D2, float); +DECLARE_SOA_COLUMN(PxProng1D2, pxProng1D2, float); +DECLARE_SOA_COLUMN(PyProng0D2, pyProng0D2, float); +DECLARE_SOA_COLUMN(PyProng1D2, pyProng1D2, float); +DECLARE_SOA_COLUMN(PzProng0D2, pzProng0D2, float); +DECLARE_SOA_COLUMN(PzProng1D2, pzProng1D2, float); +DECLARE_SOA_COLUMN(PxSoftPi, pxSoftPi, float); +DECLARE_SOA_COLUMN(PySoftPi, pySoftPi, float); +DECLARE_SOA_COLUMN(PzSoftPi, pzSoftPi, float); +DECLARE_SOA_COLUMN(SelFlagD1, selFlagD1, int8_t); +DECLARE_SOA_COLUMN(SelFlagD2, selFlagD2, int8_t); +DECLARE_SOA_COLUMN(MD1, mD1, float); +DECLARE_SOA_COLUMN(MD2, mD2, float); +DECLARE_SOA_COLUMN(DeltaMD1, deltaMD1, float); +DECLARE_SOA_COLUMN(DeltaMD2, deltaMD2, float); +DECLARE_SOA_COLUMN(MDD, mDD, float); +DECLARE_SOA_COLUMN(MDPi1, mDPi1, float); +DECLARE_SOA_COLUMN(MDPi2, mDPi2, float); +DECLARE_SOA_COLUMN(MDDPi, mDDPi, float); +DECLARE_SOA_COLUMN(DeltaMDDPi, deltaMDDPi, float); +DECLARE_SOA_COLUMN(EtaD1, etaD1, float); +DECLARE_SOA_COLUMN(EtaD2, etaD2, float); +DECLARE_SOA_COLUMN(EtaSoftPi, etaSoftPi, float); +DECLARE_SOA_COLUMN(PhiD1, phiD1, float); +DECLARE_SOA_COLUMN(PhiD2, phiD2, float); +DECLARE_SOA_COLUMN(PhiSoftPi, phiSoftPi, float); +DECLARE_SOA_COLUMN(YD1, yD1, float); +DECLARE_SOA_COLUMN(YD2, yD2, float); +DECLARE_SOA_COLUMN(YSoftPi, ySoftPi, float); +DECLARE_SOA_COLUMN(NSigTpcSoftPi, nSigTpcSoftPi, float); +DECLARE_SOA_COLUMN(NSigTofSoftPi, nSigTofSoftPi, float); +DECLARE_SOA_COLUMN(MlScoreD1, mlScoreD1, float); +DECLARE_SOA_COLUMN(MlScoreD2, mlScoreD2, float); +DECLARE_SOA_COLUMN(ImpactParameterD1, impactParameterD1, float); +DECLARE_SOA_COLUMN(ImpactParameterD2, impactParameterD2, float); +DECLARE_SOA_COLUMN(ImpactParameterSoftPi, impactParameterSoftPi, float); +DECLARE_SOA_COLUMN(CpaD1, cpaD1, float); +DECLARE_SOA_COLUMN(CpaD2, cpaD2, float); +DECLARE_SOA_COLUMN(Chi2PCA, chi2PCA, float); +DECLARE_SOA_COLUMN(SignSoftPi, signSoftPi, float); +DECLARE_SOA_COLUMN(DcaXYSoftPi, dcaXYSoftPi, float); +DECLARE_SOA_COLUMN(DcaZSoftPi, dcaZSoftPi, float); +DECLARE_SOA_COLUMN(NITSClsSoftPi, nITSClsSoftPi, float); +DECLARE_SOA_COLUMN(NTPCClsCrossedRowsSoftPi, nTPCClsCrossedRowsSoftPi, float); +DECLARE_SOA_COLUMN(NTPCChi2NClSoftPi, nTPCChi2NClSoftPi, float); +DECLARE_SOA_COLUMN(CentOfCand, centOfCand, float); +// Events +DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); +DECLARE_SOA_COLUMN(GIndexCol, gIndexCol, int); //! Global index for the collisionAdd commentMore actions +DECLARE_SOA_COLUMN(TimeStamp, timeStamp, int64_t); //! Timestamp for the collision +} // namespace full + +DECLARE_SOA_TABLE(HfCandTccLites, "AOD", "HFCANDTCCLITE", + full::PxProng0D1, + full::PxProng1D1, + full::PyProng0D1, + full::PyProng1D1, + full::PzProng0D1, + full::PzProng1D1, + full::PxProng0D2, + full::PxProng1D2, + full::PyProng0D2, + full::PyProng1D2, + full::PzProng0D2, + full::PzProng1D2, + full::PxSoftPi, + full::PySoftPi, + full::PzSoftPi, + full::SelFlagD1, + full::SelFlagD2, + full::MD1, + full::MD2, + full::DeltaMD1, + full::DeltaMD2, + full::MDPi1, + full::MDPi2, + full::MDDPi, + full::DeltaMDDPi, + full::EtaD1, + full::EtaD2, + full::EtaSoftPi, + full::PhiD1, + full::PhiD2, + full::PhiSoftPi, + full::YD1, + full::YD2, + full::YSoftPi, + full::NSigTpcSoftPi, + full::NSigTofSoftPi, + full::MlScoreD1, + full::MlScoreD2, + full::ImpactParameterD1, + full::ImpactParameterD2, + full::ImpactParameterSoftPi, + full::CpaD1, + full::CpaD2, + full::Chi2PCA, + full::SignSoftPi, + full::DcaXYSoftPi, + full::DcaZSoftPi, + full::NITSClsSoftPi, + full::NTPCClsCrossedRowsSoftPi, + full::NTPCChi2NClSoftPi, + full::CentOfCand, + full::GIndexCol, + full::TimeStamp); + +DECLARE_SOA_TABLE(HfCandDDPairs, "AOD", "HFCANDDDPAIR", + full::PxProng0D1, + full::PxProng1D1, + full::PyProng0D1, + full::PyProng1D1, + full::PzProng0D1, + full::PzProng1D1, + full::PxProng0D2, + full::PxProng1D2, + full::PyProng0D2, + full::PyProng1D2, + full::PzProng0D2, + full::PzProng1D2, + full::SelFlagD1, + full::SelFlagD2, + full::EtaD1, + full::EtaD2, + full::PhiD1, + full::PhiD2, + full::MlScoreD1, + full::MlScoreD2, + full::CentOfCand, + full::GIndexCol, + full::TimeStamp); + +DECLARE_SOA_TABLE(HfCandTccFullEvs, "AOD", "HFCANDTCCFULLEV", + full::CollisionId, + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + full::IsEventReject, + full::RunNumber); +} // namespace o2::aod + +/// Writes the full information in an output TTree +struct HfTreeCreatorTccToD0D0Pi { + Produces rowCandidateLite; + Produces rowCandidateDDPair; + Produces rowCandidateFullEvents; + + Configurable ptMinSoftPion{"ptMinSoftPion", 0.0, "Min pt for the soft pion"}; + Configurable usePionIsGlobalTrackWoDCA{"usePionIsGlobalTrackWoDCA", true, "check isGlobalTrackWoDCA status for pions"}; + + // vertexing + Configurable buildVertex{"buildVertex", false, "build vertext for Tcc"}; + Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; + Configurable useAbsDCA{"useAbsDCA", false, "Minimise abs. distance rather than chi2"}; + Configurable useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; + Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; + Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; + Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any Lb is smaller than this"}; + Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; + + Configurable softPiDcaXYMax{"softPiDcaXYMax", 0.065, "Soft pion max dcaXY (cm)"}; + Configurable softPiDcaZMax{"softPiDcaZMax", 0.065, "Soft pion max dcaZ (cm)"}; + Configurable deltaMassCanMax{"deltaMassCanMax", 2, "delta candidate max mass (DDPi-D0D0) ((GeV/c2)"}; + Configurable massCanMax{"massCanMax", 4.0, "candidate max mass (DDPi) ((GeV/c2)"}; + + // magnetic field setting from CCDB + Configurable isRun2{"isRun2", false, "enable Run 2 or Run 3 GRP objects for magnetic field"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPathLut{"ccdbPathLut", "GLO/Param/MatLUT", "Path for LUT parametrization"}; + Configurable ccdbPathGrp{"ccdbPathGrp", "GLO/GRP/GRP", "Path of the grp file (Run 2)"}; + Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; + + o2::vertexing::DCAFitterN<3> dfTcc; // Tcc vertex fitter + o2::vertexing::DCAFitterN<2> dfDD; // DD pair vertex fitter + o2::vertexing::DCAFitterN<2> dfD1; // 2-prong vertex fitter (to rebuild D01 vertex) + o2::vertexing::DCAFitterN<2> dfD2; // 2-prong vertex fitter (to rebuild D02 vertex) + + HfHelper hfHelper; + Service ccdb; + o2::base::MatLayerCylSet* lut; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + double bz{0.}; + int runNumber{0}; + + using TracksPid = soa::Join; + using TracksWPid = soa::Join; + + using Collisions = soa::Join; + using CollisionsWithFT0C = soa::Join; + using CollisionsWithFT0M = soa::Join; + + using SelectedCandidatesMl = soa::Filtered>; + + Filter filterSelectCandidates = aod::hf_sel_candidate_d0::isSelD0 >= 1 || aod::hf_sel_candidate_d0::isSelD0bar >= 1; + + Preslice candsD0PerCollisionWithMl = aod::track_association::collisionId; + Preslice trackIndicesPerCollision = aod::track_association::collisionId; + // Partition candidatesMlAll = aod::hf_sel_candidate_d0::isSelD0 >= 0; + std::shared_ptr hCandidatesD1, hCandidatesD2, hCandidatesTcc, hCandidatesDD; + HistogramRegistry registry{"registry"}; + OutputObj hCovPVXX{TH1F("hCovPVXX", "Tcc candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", 100, 0., 1.e-4)}; + OutputObj hCovSVXX{TH1F("hCovSVXX", "Tcc candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)}; + void init(InitContext const&) + { + + std::array doprocess{doprocessDataWithMl, doprocessDataWithMlWithFT0C, doprocessDataWithMlWithFT0M}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "Only one process function can be enabled at a time."); + } + if (buildVertex) { + dfD1.setPropagateToPCA(propagateToPCA); + dfD1.setMaxR(maxR); + dfD1.setMaxDZIni(maxDZIni); + dfD1.setMinParamChange(minParamChange); + dfD1.setMinRelChi2Change(minRelChi2Change); + dfD1.setUseAbsDCA(useAbsDCA); + dfD1.setWeightedFinalPCA(useWeightedFinalPCA); + + dfD2.setPropagateToPCA(propagateToPCA); + dfD2.setMaxR(maxR); + dfD2.setMaxDZIni(maxDZIni); + dfD2.setMinParamChange(minParamChange); + dfD2.setMinRelChi2Change(minRelChi2Change); + dfD2.setUseAbsDCA(useAbsDCA); + dfD2.setWeightedFinalPCA(useWeightedFinalPCA); + + dfDD.setPropagateToPCA(propagateToPCA); + dfDD.setMaxR(maxR); + dfDD.setMaxDZIni(maxDZIni); + dfDD.setMinParamChange(minParamChange); + dfDD.setMinRelChi2Change(minRelChi2Change); + dfDD.setUseAbsDCA(useAbsDCA); + dfDD.setWeightedFinalPCA(useWeightedFinalPCA); + + dfTcc.setPropagateToPCA(propagateToPCA); + dfTcc.setMaxR(maxR); + dfTcc.setMaxDZIni(maxDZIni); + dfTcc.setMinParamChange(minParamChange); + dfTcc.setMinRelChi2Change(minRelChi2Change); + dfTcc.setUseAbsDCA(useAbsDCA); + dfTcc.setWeightedFinalPCA(useWeightedFinalPCA); + + // Configure CCDB access + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); + + hCandidatesD1 = registry.add("hCandidatesD1", "D1 candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesD2 = registry.add("hCandidatesD2", "D2 candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesTcc = registry.add("hCandidatesTcc", "Tcc candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesDD = registry.add("hCandidatesDD", "DD pair candidate counter", {HistType::kTH1D, {axisCands}}); + + setLabelHistoCands(hCandidatesD1); + setLabelHistoCands(hCandidatesD2); + setLabelHistoCands(hCandidatesTcc); + setLabelHistoCands(hCandidatesDD); + } + } + + template + void fillEvent(const T& collision, int isEventReject, int runNumber) + { + rowCandidateFullEvents( + collision.globalIndex(), + collision.numContrib(), + collision.posX(), + collision.posY(), + collision.posZ(), + isEventReject, + runNumber); + } + + /// Evaluate centrality/multiplicity percentile (centrality estimator is automatically selected based on the used table) + /// \param candidate is candidate + /// \return centrality/multiplicity percentile of the collision + template + float evaluateCentralityColl(const Coll& collision) + { + return o2::hf_centrality::getCentralityColl(collision); + } + + template + void runCandCreatorData(CollType const& collisions, + CandType const& candidates, + aod::TrackAssoc const& trackIndices, + TrkType const& tracks) + { + + for (const auto& collision : collisions) { + auto primaryVertex = getPrimaryVertex(collision); + auto bc = collision.template bc_as(); + fillEvent(collision, 0, bc.runNumber()); + int64_t timeStamp = bc.timestamp(); + if (buildVertex) { + if (runNumber != bc.runNumber()) { + LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; + initCCDB(bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, isRun2); + bz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << ">>>>>>>>>>>> Magnetic field: " << bz; + } + dfTcc.setBz(bz); + dfDD.setBz(bz); + dfD1.setBz(bz); + dfD2.setBz(bz); + } + + o2::dataformats::V0 trackD1; + o2::dataformats::V0 trackD2; + auto thisCollId = collision.globalIndex(); + auto candwD0ThisColl = candidates.sliceBy(candsD0PerCollisionWithMl, thisCollId); + if (candwD0ThisColl.size() <= 1) + continue; // only loop the collision that include at least 2 D candidates + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + + for (const auto& candidateD1 : candwD0ThisColl) { + + auto trackD1Prong0 = tracks.rawIteratorAt(candidateD1.prong0Id()); // positive daughter for D1 + auto trackD1Prong1 = tracks.rawIteratorAt(candidateD1.prong1Id()); // negative daughter for D1 + std::array pVecD1Prong0{trackD1Prong0.pVector()}; + std::array pVecD1Prong1{trackD1Prong1.pVector()}; + std::array pVecD1 = RecoDecay::pVec(pVecD1Prong0, pVecD1Prong1); + + for (auto candidateD2 = candidateD1 + 1; candidateD2 != candwD0ThisColl.end(); ++candidateD2) { + // avoid shared tracks + if ( + (candidateD1.prong0Id() == candidateD2.prong0Id()) || + (candidateD1.prong0Id() == candidateD2.prong1Id()) || + (candidateD1.prong1Id() == candidateD2.prong0Id()) || + (candidateD1.prong1Id() == candidateD2.prong1Id())) { + continue; + } + + auto trackD2Prong0 = tracks.rawIteratorAt(candidateD2.prong0Id()); // positive daughter for D2 + auto trackD2Prong1 = tracks.rawIteratorAt(candidateD2.prong1Id()); // negative daughter for D2 + std::array pVecD2Prong0{trackD2Prong0.pVector()}; + std::array pVecD2Prong1{trackD2Prong1.pVector()}; + std::array pVecD2 = RecoDecay::pVec(pVecD2Prong0, pVecD2Prong1); + + if (buildVertex) { + auto trackParVarD1Prong0 = getTrackParCov(trackD1Prong0); + auto trackParVarD1Prong1 = getTrackParCov(trackD1Prong1); + auto dca0D1 = o2::dataformats::DCA(trackD1Prong0.dcaXY(), trackD1Prong0.dcaZ(), trackD1Prong0.cYY(), trackD1Prong0.cZY(), trackD1Prong0.cZZ()); + auto dca1D1 = o2::dataformats::DCA(trackD1Prong1.dcaXY(), trackD1Prong1.dcaZ(), trackD1Prong1.cYY(), trackD1Prong1.cZY(), trackD1Prong1.cZZ()); + + // repropagate tracks to this collision if needed + if (trackD1Prong0.collisionId() != thisCollId) { + trackParVarD1Prong0.propagateToDCA(primaryVertex, bz, &dca0D1); + } + + if (trackD1Prong1.collisionId() != thisCollId) { + trackParVarD1Prong1.propagateToDCA(primaryVertex, bz, &dca1D1); + } + // reconstruct the 2-prong secondary vertex + hCandidatesD1->Fill(SVFitting::BeforeFit); + try { + if (dfD1.process(trackParVarD1Prong0, trackParVarD1Prong1) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN for first D0 cannot work, skipping the candidate."; + hCandidatesD1->Fill(SVFitting::Fail); + continue; + } + hCandidatesD1->Fill(SVFitting::FitOk); + const auto& vertexD1 = dfD1.getPCACandidatePos(); + trackParVarD1Prong0.propagateTo(vertexD1[0], bz); + trackParVarD1Prong1.propagateTo(vertexD1[0], bz); + + // build a D1 neutral track + trackD1 = o2::dataformats::V0(vertexD1, pVecD1, dfD1.calcPCACovMatrixFlat(), trackParVarD1Prong0, trackParVarD1Prong1); + + auto trackParVarD2Prong0 = getTrackParCov(trackD2Prong0); + auto trackParVarD2Prong1 = getTrackParCov(trackD2Prong1); + auto dca0D2 = o2::dataformats::DCA(trackD2Prong0.dcaXY(), trackD2Prong0.dcaZ(), trackD2Prong0.cYY(), trackD2Prong0.cZY(), trackD2Prong0.cZZ()); + auto dca1D2 = o2::dataformats::DCA(trackD2Prong1.dcaXY(), trackD2Prong1.dcaZ(), trackD2Prong1.cYY(), trackD2Prong1.cZY(), trackD2Prong1.cZZ()); + + // repropagate tracks to this collision if needed + if (trackD2Prong0.collisionId() != thisCollId) { + trackParVarD2Prong0.propagateToDCA(primaryVertex, bz, &dca0D2); + } + if (trackD2Prong1.collisionId() != thisCollId) { + trackParVarD2Prong1.propagateToDCA(primaryVertex, bz, &dca1D2); + } + + // reconstruct the 2-prong secondary vertex + hCandidatesD2->Fill(SVFitting::BeforeFit); + try { + if (dfD2.process(trackParVarD2Prong0, trackParVarD2Prong1) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN for second D0 cannot work, skipping the candidate."; + hCandidatesD2->Fill(SVFitting::Fail); + continue; + } + + hCandidatesD2->Fill(SVFitting::FitOk); + const auto& vertexD2 = dfD2.getPCACandidatePos(); + trackParVarD2Prong0.propagateTo(vertexD2[0], bz); + trackParVarD2Prong1.propagateTo(vertexD2[0], bz); + // build a D2 neutral track + trackD2 = o2::dataformats::V0(vertexD2, pVecD2, dfD2.calcPCACovMatrixFlat(), trackParVarD2Prong0, trackParVarD2Prong1); + + hCandidatesDD->Fill(SVFitting::BeforeFit); + try { + if (dfDD.process(trackD1, trackD2) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN for DD cannot work, skipping the candidate."; + hCandidatesDD->Fill(SVFitting::Fail); + continue; + } + hCandidatesDD->Fill(SVFitting::FitOk); + } + + int candFlagD1 = -999; + int candFlagD2 = -999; + float cent = evaluateCentralityColl(collision); + float massD01 = -999; + float massD02 = -999; + std::vector mlScoresD1; + std::vector mlScoresD2; + + if (candidateD1.isSelD0()) { + candFlagD1 = (candidateD1.isSelD0bar()) ? 3 : 1; + std::copy(candidateD1.mlProbD0().begin(), candidateD1.mlProbD0().end(), std::back_inserter(mlScoresD1)); + massD01 = hfHelper.invMassD0ToPiK(candidateD1); + } + if (candidateD1.isSelD0bar() && !candidateD1.isSelD0()) { + candFlagD1 = 2; + std::copy(candidateD1.mlProbD0bar().begin(), candidateD1.mlProbD0bar().end(), std::back_inserter(mlScoresD1)); + massD01 = hfHelper.invMassD0barToKPi(candidateD1); + } + + if (candidateD2.isSelD0()) { + candFlagD2 = (candidateD2.isSelD0bar()) ? 3 : 1; + std::copy(candidateD2.mlProbD0().begin(), candidateD2.mlProbD0().end(), std::back_inserter(mlScoresD2)); + massD02 = hfHelper.invMassD0ToPiK(candidateD2); + } + if (candidateD2.isSelD0bar() && !candidateD2.isSelD0()) { + candFlagD2 = 2; + std::copy(candidateD2.mlProbD0bar().begin(), candidateD2.mlProbD0bar().end(), std::back_inserter(mlScoresD2)); + massD02 = hfHelper.invMassD0barToKPi(candidateD2); + } + + // const auto massD0D0Pair = RecoDecay::m(std::array{pVecD1, pVecD2}, std::array{MassD0, MassD0}); + + rowCandidateDDPair( + candidateD1.pxProng0(), + candidateD1.pxProng1(), + candidateD1.pyProng0(), + candidateD1.pyProng1(), + candidateD1.pzProng0(), + candidateD1.pzProng1(), + candidateD2.pxProng0(), + candidateD2.pxProng1(), + candidateD2.pyProng0(), + candidateD2.pyProng1(), + candidateD2.pzProng0(), + candidateD2.pzProng1(), + candFlagD1, + candFlagD2, + candidateD1.eta(), + candidateD2.eta(), + candidateD1.phi(), + candidateD2.phi(), + mlScoresD1[0], + mlScoresD2[0], + cent, + collision.globalIndex(), + timeStamp); + + // start to add the track of softpi to reconstruct Tcc + for (const auto& trackId : trackIdsThisCollision) { + + auto trackPion = trackId.template track_as(); + if (usePionIsGlobalTrackWoDCA && !trackPion.isGlobalTrackWoDCA()) { + continue; + } + // minimum pT selection + if (trackPion.pt() < ptMinSoftPion) { + continue; + } + if (std::abs(trackPion.dcaXY()) > softPiDcaXYMax || std::abs(trackPion.dcaZ()) > softPiDcaZMax) { + continue; + } + // avoid shared tracks + if ( + (candidateD1.prong0Id() == trackPion.globalIndex()) || + (candidateD1.prong1Id() == trackPion.globalIndex()) || + (candidateD2.prong0Id() == trackPion.globalIndex()) || + (candidateD2.prong1Id() == trackPion.globalIndex())) { + continue; + } + + std::array pVecSoftPi = {trackPion.pVector()}; + + float impactParameterYD1 = -999.f; + float impactParameterYD2 = -999.f; + float impactParameterYSoftPi = -999.f; + float chi2PCA = -999.f; + if (buildVertex) { + auto trackParCovPi = getTrackParCov(trackPion); + // find the DCA between the D01, D02 and the bachelor track, for Tcc + hCandidatesTcc->Fill(SVFitting::BeforeFit); + try { + if (dfTcc.process(trackD1, trackD2, trackParCovPi) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN for Tcc cannot work, skipping the candidate."; + hCandidatesTcc->Fill(SVFitting::Fail); + continue; + } + hCandidatesTcc->Fill(SVFitting::FitOk); + + dfTcc.propagateTracksToVertex(); // propagate the softpi and D0 pair to the Tcc vertex + trackD1.getPxPyPzGlo(pVecD1); // momentum of D1 at the Tcc vertex + trackD2.getPxPyPzGlo(pVecD2); // momentum of D2 at the Tcc vertex + trackParCovPi.getPxPyPzGlo(pVecSoftPi); // momentum of pi at the Tcc vertex + + chi2PCA = dfTcc.getChi2AtPCACandidate(); + auto covMatrixPCA = dfTcc.calcPCACovMatrixFlat(); + hCovSVXX->Fill(covMatrixPCA[0]); + + // get track impact parameters + // This modifies track momenta! + auto covMatrixPV = primaryVertex.getCov(); + hCovPVXX->Fill(covMatrixPV[0]); + o2::dataformats::DCA impactParameterD1; + o2::dataformats::DCA impactParameterD2; + o2::dataformats::DCA impactParameterSoftPi; + + trackD1.propagateToDCA(primaryVertex, bz, &impactParameterD1); + trackD2.propagateToDCA(primaryVertex, bz, &impactParameterD2); + trackParCovPi.propagateToDCA(primaryVertex, bz, &impactParameterSoftPi); + + impactParameterYD1 = impactParameterD1.getY(); + impactParameterYD2 = impactParameterD2.getY(); + impactParameterYSoftPi = impactParameterSoftPi.getY(); + } + // Retrieve properties of the two D0 candidates + float yD1 = hfHelper.yD0(candidateD1); + float yD2 = hfHelper.yD0(candidateD2); + float deltaMassD01 = -999; + float deltaMassD02 = -999; + + std::array massD1Daus{MassPiPlus, MassKPlus}; + std::array massD2Daus{MassPiPlus, MassKPlus}; + + if (candidateD1.isSelD0bar()) { + + massD1Daus[0] = MassKPlus; + massD1Daus[1] = MassPiPlus; + } + if (candidateD2.isSelD0bar()) { + massD2Daus[0] = MassKPlus; + massD2Daus[1] = MassPiPlus; + } + + auto massKpipi1 = RecoDecay::m(std::array{pVecD1Prong0, pVecD1Prong1, pVecSoftPi}, std::array{massD1Daus[0], massD1Daus[1], MassPiPlus}); + auto massKpipi2 = RecoDecay::m(std::array{pVecD2Prong0, pVecD2Prong1, pVecSoftPi}, std::array{massD2Daus[0], massD2Daus[1], MassPiPlus}); + auto arrayMomentaDDpi = std::array{pVecD1, pVecD2, pVecSoftPi}; + const auto massD0D0Pi = RecoDecay::m(std::move(arrayMomentaDDpi), std::array{MassD0, MassD0, MassPiPlus}); + const auto deltaMassD0D0Pi = massD0D0Pi - (massD01 + massD02); + + deltaMassD01 = massKpipi1 - massD01; + deltaMassD02 = massKpipi2 - massD02; + + if (deltaMassD0D0Pi > deltaMassCanMax || massD0D0Pi > massCanMax) { + continue; + } + + rowCandidateLite( + candidateD1.pxProng0(), + candidateD1.pxProng1(), + candidateD1.pyProng0(), + candidateD1.pyProng1(), + candidateD1.pzProng0(), + candidateD1.pzProng1(), + candidateD2.pxProng0(), + candidateD2.pxProng1(), + candidateD2.pyProng0(), + candidateD2.pyProng1(), + candidateD2.pzProng0(), + candidateD2.pzProng1(), + trackPion.px(), + trackPion.py(), + trackPion.pz(), + candFlagD1, + candFlagD2, + massD01, + massD02, + deltaMassD01, + deltaMassD02, + massKpipi1, + massKpipi2, + massD0D0Pi, + deltaMassD0D0Pi, + candidateD1.eta(), + candidateD2.eta(), + trackPion.eta(), + candidateD1.phi(), + candidateD2.phi(), + trackPion.phi(), + yD1, + yD2, + trackPion.y(), + trackPion.tpcNSigmaPi(), + trackPion.tofNSigmaPi(), + mlScoresD1[0], + mlScoresD2[0], + impactParameterYD1, + impactParameterYD2, + impactParameterYSoftPi, + candidateD1.cpa(), + candidateD2.cpa(), + chi2PCA, + trackPion.sign(), + trackPion.dcaXY(), + trackPion.dcaZ(), + trackPion.itsNCls(), + trackPion.tpcNClsCrossedRows(), + trackPion.tpcChi2NCl(), + cent, + collision.globalIndex(), + timeStamp); + } // end of loop track + } // end of loop second D0 + } // end of loop first D0 + } // end of loop collision + } + void processDataWithMl(Collisions const& collisions, + SelectedCandidatesMl const& candidates, + aod::TrackAssoc const& trackIndices, + TracksWPid const& tracks, + aod::BCsWithTimestamps const&) + { + rowCandidateFullEvents.reserve(collisions.size()); + runCandCreatorData(collisions, candidates, trackIndices, tracks); + } + PROCESS_SWITCH(HfTreeCreatorTccToD0D0Pi, processDataWithMl, "Process data with DCAFitterN with the ML method and without centrality", false); + + void processDataWithMlWithFT0C(CollisionsWithFT0C const& collisions, + SelectedCandidatesMl const& candidates, + aod::TrackAssoc const& trackIndices, + TracksWPid const& tracks, + aod::BCsWithTimestamps const&) + { + rowCandidateFullEvents.reserve(collisions.size()); + runCandCreatorData(collisions, candidates, trackIndices, tracks); + } + PROCESS_SWITCH(HfTreeCreatorTccToD0D0Pi, processDataWithMlWithFT0C, "Process data with DCAFitterN with the ML method and with FT0C centrality", true); + + void processDataWithMlWithFT0M(CollisionsWithFT0M const& collisions, + SelectedCandidatesMl const& candidates, + aod::TrackAssoc const& trackIndices, + TracksWPid const& tracks, + aod::BCsWithTimestamps const&) + { + rowCandidateFullEvents.reserve(collisions.size()); + runCandCreatorData(collisions, candidates, trackIndices, tracks); + } + PROCESS_SWITCH(HfTreeCreatorTccToD0D0Pi, processDataWithMlWithFT0M, "Process data with DCAFitterN with the ML method and with FT0M centrality", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/TableProducer/treeCreatorToXiPi.cxx b/PWGHF/TableProducer/treeCreatorToXiPi.cxx index b875db47a41..01e40cfb2c8 100644 --- a/PWGHF/TableProducer/treeCreatorToXiPi.cxx +++ b/PWGHF/TableProducer/treeCreatorToXiPi.cxx @@ -15,13 +15,25 @@ /// /// \author Federica Zanone , Heidelberg University -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include using namespace o2; using namespace o2::framework; @@ -33,6 +45,7 @@ namespace full // collision info DECLARE_SOA_COLUMN(IsEventSel8, isEventSel8, bool); DECLARE_SOA_COLUMN(IsEventSelZ, isEventSelZ, bool); +DECLARE_SOA_COLUMN(Centrality, centrality, float); // from creator DECLARE_SOA_COLUMN(XPv, xPv, float); DECLARE_SOA_COLUMN(YPv, yPv, float); @@ -86,10 +99,10 @@ DECLARE_SOA_COLUMN(CosPACasc, cosPACasc, float); DECLARE_SOA_COLUMN(CosPAXYV0, cosPAXYV0, float); DECLARE_SOA_COLUMN(CosPAXYCharmBaryon, cosPAXYCharmBaryon, float); DECLARE_SOA_COLUMN(CosPAXYCasc, cosPAXYCasc, float); -DECLARE_SOA_COLUMN(CTauOmegac, ctauOmegac, float); -DECLARE_SOA_COLUMN(CTauCascade, ctauCascade, float); -DECLARE_SOA_COLUMN(CTauV0, ctauV0, float); -DECLARE_SOA_COLUMN(CTauXic, ctauXic, float); +DECLARE_SOA_COLUMN(CTauOmegac, cTauOmegac, float); +DECLARE_SOA_COLUMN(CTauCascade, cTauCascade, float); +DECLARE_SOA_COLUMN(CTauV0, cTauV0, float); +DECLARE_SOA_COLUMN(CTauXic, cTauXic, float); DECLARE_SOA_COLUMN(EtaV0PosDau, etaV0PosDau, float); DECLARE_SOA_COLUMN(EtaV0NegDau, etaV0NegDau, float); DECLARE_SOA_COLUMN(EtaPiFromCasc, etaPiFromCasc, float); @@ -123,7 +136,7 @@ DECLARE_SOA_COLUMN(NTpcRowsNegV0Dau, nTpcRowsNegV0Dau, int16_t); // from creator - MC DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level -DECLARE_SOA_COLUMN(OriginRec, originRec, int8_t); +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); DECLARE_SOA_COLUMN(CollisionMatched, collisionMatched, bool); // from selector DECLARE_SOA_COLUMN(StatusPidLambda, statusPidLambda, bool); @@ -150,7 +163,7 @@ DECLARE_SOA_TABLE(HfToXiPiEvs, "AOD", "HFTOXIPIEV", full::IsEventSel8, full::IsEventSelZ); DECLARE_SOA_TABLE(HfToXiPiFulls, "AOD", "HFTOXIPIFULL", - full::XPv, full::YPv, full::ZPv, collision::NumContrib, collision::Chi2, + full::XPv, full::YPv, full::ZPv, full::Centrality, collision::NumContrib, collision::Chi2, full::XDecayVtxCharmBaryon, full::YDecayVtxCharmBaryon, full::ZDecayVtxCharmBaryon, full::XDecayVtxCascade, full::YDecayVtxCascade, full::ZDecayVtxCascade, full::XDecayVtxV0, full::YDecayVtxV0, full::ZDecayVtxV0, @@ -181,10 +194,10 @@ DECLARE_SOA_TABLE(HfToXiPiFulls, "AOD", "HFTOXIPIFULL", full::StatusInvMassLambda, full::StatusInvMassCascade, full::StatusInvMassCharmBaryon, full::ResultSelections, full::PidTpcInfoStored, full::PidTofInfoStored, full::TpcNSigmaPiFromCharmBaryon, full::TpcNSigmaPiFromCasc, full::TpcNSigmaPiFromLambda, full::TpcNSigmaPrFromLambda, full::TofNSigmaPiFromCharmBaryon, full::TofNSigmaPiFromCasc, full::TofNSigmaPiFromLambda, full::TofNSigmaPrFromLambda, - full::FlagMcMatchRec, full::DebugMcRec, full::OriginRec, full::CollisionMatched); + full::FlagMcMatchRec, full::DebugMcRec, full::OriginMcRec, full::CollisionMatched); DECLARE_SOA_TABLE(HfToXiPiLites, "AOD", "HFTOXIPILITE", - full::XPv, full::YPv, full::ZPv, collision::NumContrib, collision::Chi2, + full::XPv, full::YPv, full::ZPv, full::Centrality, collision::NumContrib, collision::Chi2, full::XDecayVtxCharmBaryon, full::YDecayVtxCharmBaryon, full::ZDecayVtxCharmBaryon, full::XDecayVtxCascade, full::YDecayVtxCascade, full::ZDecayVtxCascade, full::XDecayVtxV0, full::YDecayVtxV0, full::ZDecayVtxV0, @@ -206,7 +219,7 @@ DECLARE_SOA_TABLE(HfToXiPiLites, "AOD", "HFTOXIPILITE", full::PidTpcInfoStored, full::PidTofInfoStored, full::TpcNSigmaPiFromCharmBaryon, full::TpcNSigmaPiFromCasc, full::TpcNSigmaPiFromLambda, full::TpcNSigmaPrFromLambda, full::TofNSigmaPiFromCharmBaryon, full::TofNSigmaPiFromCasc, full::TofNSigmaPiFromLambda, full::TofNSigmaPrFromLambda, - full::FlagMcMatchRec, full::OriginRec, full::CollisionMatched); + full::FlagMcMatchRec, full::OriginMcRec, full::CollisionMatched); } // namespace o2::aod @@ -219,8 +232,12 @@ struct HfTreeCreatorToXiPi { Configurable zPvCut{"zPvCut", 10., "Cut on absolute value of primary vertex z coordinate"}; + using Cents = soa::Join; using MyTrackTable = soa::Join; using MyEventTable = soa::Join; + using MyEventTableWithFT0C = soa::Join; + using MyEventTableWithFT0M = soa::Join; + using MyEventTableWithNTracksPV = soa::Join; void init(InitContext const&) { @@ -229,21 +246,30 @@ struct HfTreeCreatorToXiPi { } } - template + template void fillEvent(const T& collision, float cutZPv) { - rowEv(collision.sel8(), std::abs(collision.posZ()) < cutZPv); + rowEv( + collision.sel8(), std::abs(collision.posZ()) < cutZPv); } - template + template void fillCandidate(const T& candidate, int8_t flagMc, int8_t debugMc, int8_t originMc, bool collisionMatched) { + + float centrality = -999.f; + if constexpr (useCentrality) { + auto const& collision = candidate.template collision_as(); + centrality = o2::hf_centrality::getCentralityColl(collision); + } + rowCandidateFull( candidate.xPv(), candidate.yPv(), candidate.zPv(), - candidate.template collision_as().numContrib(), - candidate.template collision_as().chi2(), + centrality, + candidate.template collision_as().numContrib(), + candidate.template collision_as().chi2(), candidate.xDecayVtxCharmBaryon(), candidate.yDecayVtxCharmBaryon(), candidate.zDecayVtxCharmBaryon(), @@ -293,10 +319,10 @@ struct HfTreeCreatorToXiPi { candidate.cosPAXYV0(), candidate.cosPAXYCharmBaryon(), candidate.cosPAXYCasc(), - candidate.ctauOmegac(), - candidate.ctauCascade(), - candidate.ctauV0(), - candidate.ctauXic(), + candidate.cTauOmegac(), + candidate.cTauCascade(), + candidate.cTauV0(), + candidate.cTauXic(), candidate.etaV0PosDau(), candidate.etaV0NegDau(), candidate.etaBachFromCasc(), @@ -350,17 +376,24 @@ struct HfTreeCreatorToXiPi { collisionMatched); } - template + template void fillCandidateLite(const T& candidate, int8_t flagMc, int8_t originMc, bool collisionMatched) { if (candidate.resultSelections() && candidate.statusPidCharmBaryon() && candidate.statusInvMassLambda() && candidate.statusInvMassCascade() && candidate.statusInvMassCharmBaryon()) { + float centrality = -999.f; + if constexpr (useCentrality) { + auto const& collision = candidate.template collision_as(); + centrality = o2::hf_centrality::getCentralityColl(collision); + } + rowCandidateLite( candidate.xPv(), candidate.yPv(), candidate.zPv(), - candidate.template collision_as().numContrib(), - candidate.template collision_as().chi2(), + centrality, + candidate.template collision_as().numContrib(), + candidate.template collision_as().chi2(), candidate.xDecayVtxCharmBaryon(), candidate.yDecayVtxCharmBaryon(), candidate.zDecayVtxCharmBaryon(), @@ -434,16 +467,16 @@ struct HfTreeCreatorToXiPi { // Filling event properties rowEv.reserve(collisions.size()); for (const auto& collision : collisions) { - fillEvent(collision, zPvCut); + fillEvent(collision, zPvCut); } // Filling candidate properties rowCandidateFull.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillCandidate(candidate, -7, -7, RecoDecay::OriginType::None, false); + fillCandidate(candidate, -7, -7, RecoDecay::OriginType::None, false); } } - PROCESS_SWITCH(HfTreeCreatorToXiPi, processDataFull, "Process data with full information", true); + PROCESS_SWITCH(HfTreeCreatorToXiPi, processDataFull, "Process data with full information w/o centrality", true); void processMcFullXic0(MyEventTable const& collisions, MyTrackTable const&, soa::Join const& candidates) @@ -451,16 +484,16 @@ struct HfTreeCreatorToXiPi { // Filling event properties rowEv.reserve(collisions.size()); for (const auto& collision : collisions) { - fillEvent(collision, zPvCut); + fillEvent(collision, zPvCut); } // Filling candidate properties rowCandidateFull.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillCandidate(candidate, candidate.flagMcMatchRec(), candidate.debugMcRec(), candidate.originRec(), candidate.collisionMatched()); + fillCandidate(candidate, candidate.flagMcMatchRec(), candidate.debugMcRec(), candidate.originMcRec(), candidate.collisionMatched()); } } - PROCESS_SWITCH(HfTreeCreatorToXiPi, processMcFullXic0, "Process MC with full information for xic0", false); + PROCESS_SWITCH(HfTreeCreatorToXiPi, processMcFullXic0, "Process MC with full information for xic0 w/o centrality", false); void processMcFullOmegac0(MyEventTable const& collisions, MyTrackTable const&, soa::Join const& candidates) @@ -468,13 +501,13 @@ struct HfTreeCreatorToXiPi { // Filling event properties rowEv.reserve(collisions.size()); for (const auto& collision : collisions) { - fillEvent(collision, zPvCut); + fillEvent(collision, zPvCut); } // Filling candidate properties rowCandidateFull.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillCandidate(candidate, candidate.flagMcMatchRec(), candidate.debugMcRec(), candidate.originRec(), candidate.collisionMatched()); + fillCandidate(candidate, candidate.flagMcMatchRec(), candidate.debugMcRec(), candidate.originMcRec(), candidate.collisionMatched()); } } PROCESS_SWITCH(HfTreeCreatorToXiPi, processMcFullOmegac0, "Process MC with full information for omegac0", false); @@ -485,47 +518,149 @@ struct HfTreeCreatorToXiPi { // Filling event properties rowEv.reserve(collisions.size()); for (const auto& collision : collisions) { - fillEvent(collision, zPvCut); + fillEvent(collision, zPvCut); } // Filling candidate properties rowCandidateLite.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillCandidateLite(candidate, -7, RecoDecay::OriginType::None, false); + fillCandidateLite(candidate, -7, RecoDecay::OriginType::None, false); } } PROCESS_SWITCH(HfTreeCreatorToXiPi, processDataLite, "Process data and produce lite table version", false); + void processDataLiteWithFT0M(MyEventTableWithFT0M const& collisions, MyTrackTable const&, + soa::Join const& candidates) + { + // Filling event properties + rowEv.reserve(collisions.size()); + for (const auto& collision : collisions) { + fillEvent(collision, zPvCut); + } + + // Filling candidate properties + rowCandidateLite.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillCandidateLite(candidate, -7, RecoDecay::OriginType::None, false); + } + } + PROCESS_SWITCH(HfTreeCreatorToXiPi, processDataLiteWithFT0M, "Process data and produce lite table version with FT0M", false); + + void processDataLiteWithFT0C(MyEventTableWithFT0C const& collisions, MyTrackTable const&, + soa::Join const& candidates) + { + // Filling event properties + rowEv.reserve(collisions.size()); + for (const auto& collision : collisions) { + fillEvent(collision, zPvCut); + } + + // Filling candidate properties + rowCandidateLite.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillCandidateLite(candidate, -7, RecoDecay::OriginType::None, false); + } + } + PROCESS_SWITCH(HfTreeCreatorToXiPi, processDataLiteWithFT0C, "Process data and produce lite table version with FT0C", false); + + void processDataLiteWithNTracksPV(MyEventTableWithNTracksPV const& collisions, MyTrackTable const&, + soa::Join const& candidates) + { + // Filling event properties + rowEv.reserve(collisions.size()); + for (const auto& collision : collisions) { + fillEvent(collision, zPvCut); + } + + // Filling candidate properties + rowCandidateLite.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillCandidateLite(candidate, -7, RecoDecay::OriginType::None, false); + } + } + PROCESS_SWITCH(HfTreeCreatorToXiPi, processDataLiteWithNTracksPV, "Process data and produce lite table version with NTracksPV", false); + void processMcLiteXic0(MyEventTable const& collisions, MyTrackTable const&, soa::Join const& candidates) { // Filling event properties rowEv.reserve(collisions.size()); for (const auto& collision : collisions) { - fillEvent(collision, zPvCut); + fillEvent(collision, zPvCut); } // Filling candidate properties rowCandidateLite.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originRec(), candidate.collisionMatched()); + fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); } } PROCESS_SWITCH(HfTreeCreatorToXiPi, processMcLiteXic0, "Process MC and produce lite table version for xic0", false); + void processMcLiteXic0WithFT0C(MyEventTableWithFT0C const& collisions, MyTrackTable const&, + soa::Join const& candidates) + { + // Filling event properties + rowEv.reserve(collisions.size()); + for (const auto& collision : collisions) { + fillEvent(collision, zPvCut); + } + + // Filling candidate properties + rowCandidateLite.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); + } + } + PROCESS_SWITCH(HfTreeCreatorToXiPi, processMcLiteXic0WithFT0C, "Process MC and produce lite table version for Xic0 with FT0C", false); + + void processMcLiteXic0WithFT0M(MyEventTableWithFT0M const& collisions, MyTrackTable const&, + soa::Join const& candidates) + { + // Filling event properties + rowEv.reserve(collisions.size()); + for (const auto& collision : collisions) { + fillEvent(collision, zPvCut); + } + + // Filling candidate properties + rowCandidateLite.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); + } + } + PROCESS_SWITCH(HfTreeCreatorToXiPi, processMcLiteXic0WithFT0M, "Process MC and produce lite table version for Xic0 with FT0M", false); + + void processMcLiteXic0WithNTracksPV(MyEventTableWithNTracksPV const& collisions, MyTrackTable const&, + soa::Join const& candidates) + { + // Filling event properties + rowEv.reserve(collisions.size()); + for (const auto& collision : collisions) { + fillEvent(collision, zPvCut); + } + + // Filling candidate properties + rowCandidateLite.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); + } + } + PROCESS_SWITCH(HfTreeCreatorToXiPi, processMcLiteXic0WithNTracksPV, "Process MC and produce lite table version for Xic0 with NTracksPV", false); + void processMcLiteOmegac0(MyEventTable const& collisions, MyTrackTable const&, soa::Join const& candidates) { // Filling event properties rowEv.reserve(collisions.size()); for (const auto& collision : collisions) { - fillEvent(collision, zPvCut); + fillEvent(collision, zPvCut); } // Filling candidate properties rowCandidateLite.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originRec(), candidate.collisionMatched()); + fillCandidateLite(candidate, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.collisionMatched()); } } PROCESS_SWITCH(HfTreeCreatorToXiPi, processMcLiteOmegac0, "Process MC and produce lite table version for omegac0", false); diff --git a/PWGHF/TableProducer/treeCreatorXic0ToXiPiKf.cxx b/PWGHF/TableProducer/treeCreatorXic0ToXiPiKf.cxx index 1e1bd4e359b..0e1c06d5965 100644 --- a/PWGHF/TableProducer/treeCreatorXic0ToXiPiKf.cxx +++ b/PWGHF/TableProducer/treeCreatorXic0ToXiPiKf.cxx @@ -15,13 +15,26 @@ /// /// \author Ran Tu , Fudan University -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include using namespace o2; using namespace o2::framework; @@ -30,6 +43,7 @@ namespace o2::aod { namespace full { +DECLARE_SOA_COLUMN(Centrality, centrality, float); DECLARE_SOA_COLUMN(InvMassLambda, invMassLambda, float); DECLARE_SOA_COLUMN(InvMassCascade, invMassCascade, float); DECLARE_SOA_COLUMN(InvMassCharmBaryon, invMassCharmBaryon, float); @@ -37,11 +51,12 @@ DECLARE_SOA_COLUMN(DcaXYToPvV0Dau0, dcaXYToPvV0Dau0, float); DECLARE_SOA_COLUMN(DcaXYToPvV0Dau1, dcaXYToPvV0Dau1, float); DECLARE_SOA_COLUMN(DcaXYToPvCascDau, dcaXYToPvCascDau, float); DECLARE_SOA_COLUMN(DcaCascDau, dcaCascDau, float); +DECLARE_SOA_COLUMN(DcaV0Dau, dcaV0Dau, float); DECLARE_SOA_COLUMN(DcaCharmBaryonDau, dcaCharmBaryonDau, float); // from creator - MC DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level -DECLARE_SOA_COLUMN(OriginRec, originRec, int8_t); +DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); DECLARE_SOA_COLUMN(CollisionMatched, collisionMatched, bool); // from selector DECLARE_SOA_COLUMN(TpcNSigmaPiFromCharmBaryon, tpcNSigmaPiFromCharmBaryon, float); @@ -62,7 +77,6 @@ DECLARE_SOA_COLUMN(Chi2MassV0, chi2MassV0, float); DECLARE_SOA_COLUMN(Chi2MassCasc, chi2MassCasc, float); DECLARE_SOA_COLUMN(V0ldl, v0ldl, float); DECLARE_SOA_COLUMN(Cascldl, cascldl, float); -DECLARE_SOA_COLUMN(Xicldl, xicldl, float); DECLARE_SOA_COLUMN(Chi2TopoV0ToPv, chi2TopoV0ToPv, float); DECLARE_SOA_COLUMN(Chi2TopoCascToPv, chi2TopoCascToPv, float); DECLARE_SOA_COLUMN(Chi2TopoPiFromXicToPv, chi2TopoPiFromXicToPv, float); @@ -76,7 +90,6 @@ DECLARE_SOA_COLUMN(CosPaV0ToCasc, cosPaV0ToCasc, float); DECLARE_SOA_COLUMN(CosPaV0ToPv, cosPaV0ToPv, float); DECLARE_SOA_COLUMN(CosPaCascToXic, cosPaCascToXic, float); DECLARE_SOA_COLUMN(CosPaCascToPv, cosPaCascToPv, float); -DECLARE_SOA_COLUMN(CosPaXicToPv, cosPaXicToPv, float); DECLARE_SOA_COLUMN(KfRapXic, kfRapXic, float); DECLARE_SOA_COLUMN(KfptPiFromXic, kfptPiFromXic, float); DECLARE_SOA_COLUMN(KfptXic, kfptXic, float); @@ -97,17 +110,18 @@ DECLARE_SOA_COLUMN(MassCascChi2OverNdf, massCascChi2OverNdf, float); } // namespace full DECLARE_SOA_TABLE(HfKfXicFulls, "AOD", "HFKFXICFULL", + full::Centrality, full::TpcNSigmaPiFromCharmBaryon, full::TofNSigmaPiFromCharmBaryon, full::TpcNSigmaPiFromCasc, full::TofNSigmaPiFromCasc, full::TpcNSigmaPiFromLambda, full::TofNSigmaPiFromLambda, full::TpcNSigmaPrFromLambda, full::TofNSigmaPrFromLambda, - full::KfDcaXYPiFromXic, full::DcaCascDau, full::DcaCharmBaryonDau, full::KfDcaXYCascToPv, + full::KfDcaXYPiFromXic, full::DcaCascDau, full::DcaV0Dau, full::DcaCharmBaryonDau, full::KfDcaXYCascToPv, full::DcaXYToPvV0Dau0, full::DcaXYToPvV0Dau1, full::DcaXYToPvCascDau, full::Chi2GeoV0, full::Chi2GeoCasc, full::Chi2GeoXic, full::Chi2MassV0, full::Chi2MassCasc, - full::V0ldl, full::Cascldl, full::Xicldl, + full::V0ldl, full::Cascldl, full::Chi2TopoV0ToPv, full::Chi2TopoCascToPv, full::Chi2TopoPiFromXicToPv, full::Chi2TopoXicToPv, full::Chi2TopoV0ToCasc, full::Chi2TopoCascToXic, full::DecayLenXYLambda, full::DecayLenXYCasc, full::DecayLenXYXic, - full::CosPaV0ToCasc, full::CosPaV0ToPv, full::CosPaCascToXic, full::CosPaCascToPv, full::CosPaXicToPv, + full::CosPaV0ToCasc, full::CosPaV0ToPv, full::CosPaCascToXic, full::CosPaCascToPv, full::InvMassLambda, full::InvMassCascade, full::InvMassCharmBaryon, full::KfRapXic, full::KfptPiFromXic, full::KfptXic, full::CosThetaStarPiFromXic, full::CtXic, full::EtaXic, @@ -115,7 +129,7 @@ DECLARE_SOA_TABLE(HfKfXicFulls, "AOD", "HFKFXICFULL", full::MassV0Ndf, full::MassCascNdf, full::V0Chi2OverNdf, full::CascChi2OverNdf, full::XicChi2OverNdf, full::MassV0Chi2OverNdf, full::MassCascChi2OverNdf, - full::FlagMcMatchRec, full::DebugMcRec, full::OriginRec, full::CollisionMatched); + full::FlagMcMatchRec, full::DebugMcRec, full::OriginMcRec, full::CollisionMatched); } // namespace o2::aod @@ -127,18 +141,38 @@ struct HfTreeCreatorXic0ToXiPiKf { Configurable zPvCut{"zPvCut", 10., "Cut on absolute value of primary vertex z coordinate"}; using MyTrackTable = soa::Join; + using MyEventTable = soa::Join; + using MyEventTableWithFT0C = soa::Join; + using MyEventTableWithFT0M = soa::Join; + using MyEventTableWithNTracksPV = soa::Join; + + HistogramRegistry registry{"registry"}; // for QA of selections void init(InitContext const&) { + registry.add("hPiFromXic0ItsChi2NCls", "hItsChi2NCls;status;entries", {HistType::kTH1D, {{1000, 0.0f, 10.0f}}}); + registry.add("hPiFromCacsItsChi2NCls", "hItsChi2NCls;status;entries", {HistType::kTH1D, {{1000, 0.0f, 10.0f}}}); + registry.add("hV0Dau0ItsChi2NCls", "hItsChi2NCls;status;entries", {HistType::kTH1D, {{1000, 0.0f, 10.0f}}}); + registry.add("hV0Dau1ItsChi2NCls", "hItsChi2NCls;status;entries", {HistType::kTH1D, {{1000, 0.0f, 10.0f}}}); } - template + template void fillKfCandidate(const T& candidate, int8_t flagMc, int8_t debugMc, int8_t originMc, bool collisionMatched) { - if (candidate.resultSelections() && candidate.statusPidCharmBaryon() && candidate.statusInvMassLambda() && candidate.statusInvMassCascade() && candidate.statusInvMassCharmBaryon()) { + if (candidate.resultSelections()) { + float centrality = -999.f; + if constexpr (useCentrality) { + auto const& collision = candidate.template collision_as(); + centrality = o2::hf_centrality::getCentralityColl(collision); + } + registry.fill(HIST("hPiFromXic0ItsChi2NCls"), candidate.template bachelorFromCharmBaryon_as().itsChi2NCl()); + registry.fill(HIST("hPiFromCacsItsChi2NCls"), candidate.template bachelor_as().itsChi2NCl()); + registry.fill(HIST("hV0Dau0ItsChi2NCls"), candidate.template posTrack_as().itsChi2NCl()); + registry.fill(HIST("hV0Dau1ItsChi2NCls"), candidate.template negTrack_as().itsChi2NCl()); rowKfCandidate( + centrality, candidate.tpcNSigmaPiFromCharmBaryon(), candidate.tofNSigmaPiFromCharmBaryon(), candidate.tpcNSigmaPiFromCasc(), @@ -149,6 +183,7 @@ struct HfTreeCreatorXic0ToXiPiKf { candidate.tofNSigmaPrFromLambda(), candidate.kfDcaXYPiFromXic(), candidate.dcaCascDau(), + candidate.dcaV0Dau(), candidate.dcaCharmBaryonDau(), candidate.kfDcaXYCascToPv(), candidate.dcaXYToPvV0Dau0(), @@ -161,7 +196,6 @@ struct HfTreeCreatorXic0ToXiPiKf { candidate.chi2MassCasc(), candidate.v0ldl(), candidate.cascldl(), - candidate.xicldl(), candidate.chi2TopoV0ToPv(), candidate.chi2TopoCascToPv(), candidate.chi2TopoPiFromXicToPv(), @@ -175,15 +209,14 @@ struct HfTreeCreatorXic0ToXiPiKf { candidate.cosPAV0(), candidate.cosPaCascToXic(), candidate.cosPACasc(), - candidate.cosPACharmBaryon(), candidate.invMassLambda(), candidate.invMassCascade(), candidate.invMassCharmBaryon(), candidate.kfRapXic(), - candidate.kfptPiFromXic(), - candidate.kfptXic(), + RecoDecay::sqrtSumOfSquares(candidate.pxBachFromCharmBaryon(), candidate.pyBachFromCharmBaryon()), + RecoDecay::sqrtSumOfSquares(candidate.pxCharmBaryon(), candidate.pyCharmBaryon()), candidate.cosThetaStarPiFromXic(), - candidate.ctauXic(), + candidate.cTauXic(), candidate.etaCharmBaryon(), candidate.v0Ndf(), candidate.cascNdf(), @@ -202,26 +235,85 @@ struct HfTreeCreatorXic0ToXiPiKf { } } - void processKfData(MyTrackTable const&, + void processKfData(MyTrackTable const&, MyEventTable const&, soa::Join const& candidates) { rowKfCandidate.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillKfCandidate(candidate, -7, -7, RecoDecay::OriginType::None, false); + fillKfCandidate(candidate, -7, -7, RecoDecay::OriginType::None, false); } } PROCESS_SWITCH(HfTreeCreatorXic0ToXiPiKf, processKfData, "Process KF data", false); + void processKfDataWithFT0C(MyTrackTable const&, MyEventTableWithFT0C const&, + soa::Join const& candidates) + { + rowKfCandidate.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillKfCandidate(candidate, -7, -7, RecoDecay::OriginType::None, false); + } + } + PROCESS_SWITCH(HfTreeCreatorXic0ToXiPiKf, processKfDataWithFT0C, "Process KF data with FT0C", false); + + void processKfDataWithFT0M(MyTrackTable const&, MyEventTableWithFT0M const&, + soa::Join const& candidates) + { + rowKfCandidate.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillKfCandidate(candidate, -7, -7, RecoDecay::OriginType::None, false); + } + } + PROCESS_SWITCH(HfTreeCreatorXic0ToXiPiKf, processKfDataWithFT0M, "Process KF data with FT0M", false); + + void processDataLiteWithNTracksPV(MyTrackTable const&, + soa::Join const& candidates) + { + rowKfCandidate.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillKfCandidate(candidate, -7, -7, RecoDecay::OriginType::None, false); + } + } + PROCESS_SWITCH(HfTreeCreatorXic0ToXiPiKf, processDataLiteWithNTracksPV, "Process KF data with Ntracks", false); + void processKfMcXic0(MyTrackTable const&, soa::Join const& candidates) { rowKfCandidate.reserve(candidates.size()); for (const auto& candidate : candidates) { - fillKfCandidate(candidate, candidate.flagMcMatchRec(), candidate.debugMcRec(), candidate.originRec(), candidate.collisionMatched()); + fillKfCandidate(candidate, candidate.flagMcMatchRec(), candidate.debugMcRec(), candidate.originMcRec(), candidate.collisionMatched()); } } PROCESS_SWITCH(HfTreeCreatorXic0ToXiPiKf, processKfMcXic0, "Process MC with information for xic0", false); + void processKfMCWithFT0C(MyTrackTable const&, + soa::Join const& candidates) + { + rowKfCandidate.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillKfCandidate(candidate, candidate.flagMcMatchRec(), candidate.debugMcRec(), candidate.originMcRec(), candidate.collisionMatched()); + } + } + PROCESS_SWITCH(HfTreeCreatorXic0ToXiPiKf, processKfMCWithFT0C, "Process MC with information for xic0 at FT0C", false); + + void processKfMCWithFT0M(MyTrackTable const&, + soa::Join const& candidates) + { + rowKfCandidate.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillKfCandidate(candidate, candidate.flagMcMatchRec(), candidate.debugMcRec(), candidate.originMcRec(), candidate.collisionMatched()); + } + } + PROCESS_SWITCH(HfTreeCreatorXic0ToXiPiKf, processKfMCWithFT0M, "Process MC with information for xic0 at FT0M", false); + + void processMCLiteWithNTracksPV(MyTrackTable const&, + soa::Join const& candidates) + { + rowKfCandidate.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillKfCandidate(candidate, candidate.flagMcMatchRec(), candidate.debugMcRec(), candidate.originMcRec(), candidate.collisionMatched()); + } + } + PROCESS_SWITCH(HfTreeCreatorXic0ToXiPiKf, processMCLiteWithNTracksPV, "Process MC with information for xic0 at Ntrack", false); }; // end of struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/treeCreatorXicToPKPi.cxx b/PWGHF/TableProducer/treeCreatorXicToPKPi.cxx index ba07e2def45..a7e592d910e 100644 --- a/PWGHF/TableProducer/treeCreatorXicToPKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorXicToPKPi.cxx @@ -16,14 +16,24 @@ /// \author Himanshu Sharma , INFN Padova /// \author Cristina Terrevoli , INFN Bari -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -60,11 +70,11 @@ DECLARE_SOA_COLUMN(NSigTpcPi2, nSigTpcPi2, float); DECLARE_SOA_COLUMN(NSigTpcPr2, nSigTpcPr2, float); DECLARE_SOA_COLUMN(NSigTofPi2, nSigTofPi2, float); DECLARE_SOA_COLUMN(NSigTofPr2, nSigTofPr2, float); -DECLARE_SOA_COLUMN(NSigTpcTofPr0, nSigTpcTofPi0, float); -DECLARE_SOA_COLUMN(NSigTpcTofPi0, nSigTpcTofPr0, float); +DECLARE_SOA_COLUMN(NSigTpcTofPr0, nSigTpcTofPr0, float); +DECLARE_SOA_COLUMN(NSigTpcTofPi0, nSigTpcTofPi0, float); DECLARE_SOA_COLUMN(NSigTpcTofKa1, nSigTpcTofKa1, float); -DECLARE_SOA_COLUMN(NSigTpcTofPr2, nSigTpcTofPi2, float); -DECLARE_SOA_COLUMN(NSigTpcTofPi2, nSigTpcTofPr2, float); +DECLARE_SOA_COLUMN(NSigTpcTofPr2, nSigTpcTofPr2, float); +DECLARE_SOA_COLUMN(NSigTpcTofPi2, nSigTpcTofPi2, float); DECLARE_SOA_COLUMN(DecayLength, decayLength, float); DECLARE_SOA_COLUMN(DecayLengthXY, decayLengthXY, float); DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float); @@ -75,6 +85,8 @@ DECLARE_SOA_COLUMN(Ct, ct, float); DECLARE_SOA_COLUMN(FlagMc, flagMc, int8_t); DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); DECLARE_SOA_COLUMN(OriginMcGen, originMcGen, int8_t); +DECLARE_SOA_COLUMN(IsCandidateSwapped, isCandidateSwapped, int); + // Events DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); DECLARE_SOA_COLUMN(RunNumber, runNumber, int); @@ -116,7 +128,8 @@ DECLARE_SOA_TABLE(HfCandXicLites, "AOD", "HFCANDXICLITE", full::Eta, full::Phi, full::FlagMc, - full::OriginMcRec) + full::OriginMcRec, + full::IsCandidateSwapped) DECLARE_SOA_TABLE(HfCandXicFulls, "AOD", "HFCANDXICFULL", collision::PosX, @@ -185,7 +198,8 @@ DECLARE_SOA_TABLE(HfCandXicFulls, "AOD", "HFCANDXICFULL", full::Y, full::E, full::FlagMc, - full::OriginMcRec); + full::OriginMcRec, + full::IsCandidateSwapped); DECLARE_SOA_TABLE(HfCandXicFullEvs, "AOD", "HFCANDXICFULLEV", collision::NumContrib, @@ -222,19 +236,18 @@ struct HfTreeCreatorXicToPKPi { HfHelper hfHelper; - using CandXicData = soa::Filtered>; - using CandXicMcReco = soa::Filtered>; + using CandXicData = soa::Filtered>; + using CandXicMcReco = soa::Filtered>; using CandXicMcGen = soa::Filtered>; - using TracksWPid = soa::Join; Filter filterSelectCandidates = aod::hf_sel_candidate_xic::isSelXicToPKPi >= selectionFlagXic || aod::hf_sel_candidate_xic::isSelXicToPiKP >= selectionFlagXic; - Filter filterMcGenMatching = nabs(o2::aod::hf_cand_3prong::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_3prong::DecayType::XicToPKPi)); + Filter filterMcGenMatching = nabs(o2::aod::hf_cand_3prong::flagMcMatchGen) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::XicToPKPi); Partition selectedXicToPKPiCand = aod::hf_sel_candidate_xic::isSelXicToPKPi >= selectionFlagXic; Partition selectedXicToPiKPCand = aod::hf_sel_candidate_xic::isSelXicToPiKP >= selectionFlagXic; - Partition reconstructedCandSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::XicToPKPi)); - Partition reconstructedCandBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_3prong::DecayType::XicToPKPi)); + Partition reconstructedCandSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::XicToPKPi); + Partition reconstructedCandBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(hf_decay::hf_cand_3prong::DecayChannelMain::XicToPKPi); void init(InitContext const&) { @@ -261,9 +274,11 @@ struct HfTreeCreatorXicToPKPi { { int8_t flagMc = 0; int8_t originMc = 0; + int candSwapped = 0; if constexpr (doMc) { flagMc = candidate.flagMcMatchRec(); originMc = candidate.originMcRec(); + candSwapped = candidate.isCandidateSwapped(); } float invMassXic = 0; @@ -273,10 +288,6 @@ struct HfTreeCreatorXicToPKPi { invMassXic = hfHelper.invMassXicToPiKP(candidate); } - auto trackPos1 = candidate.template prong0_as(); // positive daughter (negative for the antiparticles) - auto trackNeg = candidate.template prong1_as(); // negative daughter (positive for the antiparticles) - auto trackPos2 = candidate.template prong2_as(); // positive daughter (negative for the antiparticles) - if (fillCandidateLiteTable) { rowCandidateLite( candidate.chi2PCA(), @@ -290,21 +301,21 @@ struct HfTreeCreatorXicToPKPi { candidate.impactParameter0(), candidate.impactParameter1(), candidate.impactParameter2(), - trackPos1.tpcNSigmaPi(), - trackPos1.tpcNSigmaPr(), - trackPos1.tofNSigmaPi(), - trackPos1.tofNSigmaPr(), - trackNeg.tpcNSigmaKa(), - trackNeg.tofNSigmaKa(), - trackPos2.tpcNSigmaPi(), - trackPos2.tpcNSigmaPr(), - trackPos2.tofNSigmaPi(), - trackPos2.tofNSigmaPr(), - trackPos1.tpcTofNSigmaPi(), - trackPos1.tpcTofNSigmaPr(), - trackNeg.tpcTofNSigmaKa(), - trackPos2.tpcTofNSigmaPi(), - trackPos2.tpcTofNSigmaPr(), + candidate.nSigTpcPi0(), + candidate.nSigTpcPr0(), + candidate.nSigTofPi0(), + candidate.nSigTofPr0(), + candidate.nSigTpcKa1(), + candidate.nSigTofKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcPr2(), + candidate.nSigTofPi2(), + candidate.nSigTofPr2(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaPr0(), + candidate.tpcTofNSigmaKa1(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaPr2(), candidate.isSelXicToPKPi(), candidate.isSelXicToPiKP(), invMassXic, @@ -314,7 +325,8 @@ struct HfTreeCreatorXicToPKPi { candidate.eta(), candidate.phi(), flagMc, - originMc); + originMc, + candSwapped); } else { rowCandidateFull( @@ -356,21 +368,21 @@ struct HfTreeCreatorXicToPKPi { candidate.errorImpactParameter0(), candidate.errorImpactParameter1(), candidate.errorImpactParameter2(), - trackPos1.tpcNSigmaPi(), - trackPos1.tpcNSigmaPr(), - trackPos1.tofNSigmaPi(), - trackPos1.tofNSigmaPr(), - trackNeg.tpcNSigmaKa(), - trackNeg.tofNSigmaKa(), - trackPos2.tpcNSigmaPi(), - trackPos2.tpcNSigmaPr(), - trackPos2.tofNSigmaPi(), - trackPos2.tofNSigmaPr(), - trackPos1.tpcTofNSigmaPi(), - trackPos1.tpcTofNSigmaPr(), - trackNeg.tpcTofNSigmaKa(), - trackPos2.tpcTofNSigmaPi(), - trackPos2.tpcTofNSigmaPr(), + candidate.nSigTpcPi0(), + candidate.nSigTpcPr0(), + candidate.nSigTofPi0(), + candidate.nSigTofPr0(), + candidate.nSigTpcKa1(), + candidate.nSigTofKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTpcPr2(), + candidate.nSigTofPi2(), + candidate.nSigTofPr2(), + candidate.tpcTofNSigmaPi0(), + candidate.tpcTofNSigmaPr0(), + candidate.tpcTofNSigmaKa1(), + candidate.tpcTofNSigmaPi2(), + candidate.tpcTofNSigmaPr2(), candidate.isSelXicToPKPi(), candidate.isSelXicToPiKP(), invMassXic, @@ -384,13 +396,13 @@ struct HfTreeCreatorXicToPKPi { hfHelper.yXic(candidate), hfHelper.eXic(candidate), flagMc, - originMc); + originMc, + candSwapped); } } void processData(aod::Collisions const& collisions, - CandXicData const&, - TracksWPid const&) + CandXicData const&) { // Filling event properties rowCandidateFullEvents.reserve(collisions.size()); @@ -430,8 +442,7 @@ struct HfTreeCreatorXicToPKPi { void processMc(aod::Collisions const& collisions, aod::McCollisions const&, CandXicMcReco const&, - CandXicMcGen const& mcParticles, - TracksWPid const&) + CandXicMcGen const& mcParticles) { // Filling event properties rowCandidateFullEvents.reserve(collisions.size()); @@ -464,7 +475,7 @@ struct HfTreeCreatorXicToPKPi { for (const auto& candidate : reconstructedCandBkg) { if (downSampleBkgFactor < 1.) { - float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); + float pseudoRndm = candidate.ptProng0() * 1000. - static_cast(candidate.ptProng0() * 1000); if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { continue; } diff --git a/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx index de918bd9d8f..52a12a02b91 100644 --- a/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx @@ -14,16 +14,26 @@ /// /// \author Phil Lennart Stahlhut , Heidelberg University /// \author Carolina Reetz , Heidelberg University - -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +/// \author Jaeyoon Cho , Inha University #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -33,19 +43,13 @@ namespace o2::aod { namespace full { +DECLARE_SOA_COLUMN(ParticleFlag, particleFlag, int8_t); //! hf_cand_xic_to_xi_pi_pi::Sign for data, hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec for MC DECLARE_SOA_COLUMN(CandidateSelFlag, candidateSelFlag, int); //! Selection flag of candidate (output of candidateSelector) // vertices -DECLARE_SOA_COLUMN(XPvErr, xPvErr, float); -DECLARE_SOA_COLUMN(YPvErr, yPvErr, float); -DECLARE_SOA_COLUMN(ZPvErr, zPvErr, float); -DECLARE_SOA_COLUMN(XSvErr, xSvErr, float); -DECLARE_SOA_COLUMN(YSvErr, ySvErr, float); -DECLARE_SOA_COLUMN(ZSvErr, zSvErr, float); -DECLARE_SOA_COLUMN(Chi2Sv, chi2Sv, float); -DECLARE_SOA_COLUMN(Chi2XiVtx, chi2XiVtx, float); -DECLARE_SOA_COLUMN(Chi2LamVtx, chi2LamVtx, float); +DECLARE_SOA_COLUMN(Chi2SV, chi2SV, float); //! Chi2 of candidate vertex +DECLARE_SOA_COLUMN(Chi2GeoXi, chi2GeoXi, float); //! Chi2 of Xi vertex +DECLARE_SOA_COLUMN(Chi2GeoLambda, chi2GeoLambda, float); //! Chi2 of Lambda vertex // properties of XicPlus -DECLARE_SOA_COLUMN(Sign, sign, float); DECLARE_SOA_COLUMN(E, e, float); //! Energy of candidate (GeV) DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate (GeV/c2) DECLARE_SOA_COLUMN(P, p, float); //! Momentum of candidate (GeV/c) @@ -60,66 +64,25 @@ DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float); //! DECLARE_SOA_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, float); //! Normalised transverse decay length of candidate DECLARE_SOA_COLUMN(Cpa, cpa, float); //! Cosine pointing angle of candidate DECLARE_SOA_COLUMN(CpaXY, cpaXY, float); //! Cosine pointing angle of candidate in transverse plane -DECLARE_SOA_COLUMN(Chi2TopoXicPlusToPVBeforeConstraint, chi2TopoXicPlusToPVBeforeConstraint, float); -DECLARE_SOA_COLUMN(Chi2TopoXicPlusToPV, chi2TopoXicPlusToPV, float); -DECLARE_SOA_COLUMN(Chi2TopoXiToXicPlusBeforeConstraint, chi2TopoXiToXicPlusBeforeConstraint, float); -DECLARE_SOA_COLUMN(Chi2TopoXiToXicPlus, chi2TopoXiToXicPlus, float); // properties of daughter tracks -DECLARE_SOA_COLUMN(PtXi, ptXi, float); //! Transverse momentum of Xi (prong0) (GeV/c) -DECLARE_SOA_COLUMN(ImpactParameterXi, impactParameterXi, float); //! Impact parameter of Xi (prong0) -DECLARE_SOA_COLUMN(ImpactParameterNormalisedXi, impactParameterNormalisedXi, float); //! Normalised impact parameter of Xi (prong0) -DECLARE_SOA_COLUMN(PPi0, pPi0, float); +DECLARE_SOA_COLUMN(PtXi, ptXi, float); //! Transverse momentum of Xi (prong0) (GeV/c) +DECLARE_SOA_COLUMN(ImpactParameterXi, impactParameterXi, float); //! Impact parameter of Xi (prong0) +DECLARE_SOA_COLUMN(ImpactParameterNormalisedXi, impactParameterNormalisedXi, float); //! Normalised impact parameter of Xi (prong0) +DECLARE_SOA_COLUMN(PPi0, pPi0, float); //! Momentum of Pi0 (prong1) (GeV/c) DECLARE_SOA_COLUMN(PtPi0, ptPi0, float); //! Transverse momentum of Pi0 (prong1) (GeV/c) DECLARE_SOA_COLUMN(ImpactParameterPi0, impactParameterPi0, float); //! Impact parameter of Pi0 (prong1) DECLARE_SOA_COLUMN(ImpactParameterNormalisedPi0, impactParameterNormalisedPi0, float); //! Normalised impact parameter of Pi0 (prong1) -DECLARE_SOA_COLUMN(PPi1, pPi1, float); +DECLARE_SOA_COLUMN(PPi1, pPi1, float); //! Momentum of Pi1 (prong2) (GeV/c) DECLARE_SOA_COLUMN(PtPi1, ptPi1, float); //! Transverse momentum of Pi1 (prong2) (GeV/c) DECLARE_SOA_COLUMN(ImpactParameterPi1, impactParameterPi1, float); //! Normalised impact parameter of Pi1 (prong2) DECLARE_SOA_COLUMN(ImpactParameterNormalisedPi1, impactParameterNormalisedPi1, float); //! Normalised impact parameter of Pi1 (prong2) DECLARE_SOA_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float); //! Maximum normalized difference between measured and expected impact parameter of candidate prongs -DECLARE_SOA_COLUMN(CpaXi, cpaXi, float); -DECLARE_SOA_COLUMN(CpaXYXi, cpaXYXi, float); -DECLARE_SOA_COLUMN(CpaLam, cpaLam, float); -DECLARE_SOA_COLUMN(CpaXYLam, cpaXYLam, float); -DECLARE_SOA_COLUMN(CpaLamToXi, cpaLamToXi, float); -DECLARE_SOA_COLUMN(CpaXYLamToXi, cpaXYLamToXi, float); -DECLARE_SOA_COLUMN(DcaXYPi0Pi1, dcaXYPi0Pi1, float); -DECLARE_SOA_COLUMN(DcaXYPi0Xi, dcaXYPi0Xi, float); -DECLARE_SOA_COLUMN(DcaXYPi1Xi, dcaXYPi1Xi, float); -DECLARE_SOA_COLUMN(DcaPi0Pi1, dcaPi0Pi1, float); -DECLARE_SOA_COLUMN(DcaPi0Xi, dcaPi0Xi, float); -DECLARE_SOA_COLUMN(DcaPi1Xi, dcaPi1Xi, float); -DECLARE_SOA_COLUMN(DcaXiDaughters, dcaXiDaughters, float); -DECLARE_SOA_COLUMN(InvMassXi, invMassXi, float); -DECLARE_SOA_COLUMN(InvMassLambda, invMassLambda, float); -DECLARE_SOA_COLUMN(InvMassXiPi0, invMassXiPi0, float); -DECLARE_SOA_COLUMN(InvMassXiPi1, invMassXiPi1, float); -DECLARE_SOA_COLUMN(PBachelorPi, pBachelorPi, float); -DECLARE_SOA_COLUMN(PPiFromLambda, pPiFromLambda, float); -DECLARE_SOA_COLUMN(PPrFromLambda, pPrFromLambda, float); -// residuals and pulls -DECLARE_SOA_COLUMN(PtResidual, ptResidual, float); -DECLARE_SOA_COLUMN(PResidual, pResidual, float); -DECLARE_SOA_COLUMN(XPvResidual, xPvResidual, float); -DECLARE_SOA_COLUMN(YPvResidual, yPvResidual, float); -DECLARE_SOA_COLUMN(ZPvResidual, zPvResidual, float); -DECLARE_SOA_COLUMN(XPvPull, xPvPull, float); -DECLARE_SOA_COLUMN(YPvPull, yPvPull, float); -DECLARE_SOA_COLUMN(ZPvPull, zPvPull, float); -DECLARE_SOA_COLUMN(XSvResidual, xSvResidual, float); -DECLARE_SOA_COLUMN(YSvResidual, ySvResidual, float); -DECLARE_SOA_COLUMN(ZSvResidual, zSvResidual, float); -DECLARE_SOA_COLUMN(XSvPull, xSvPull, float); -DECLARE_SOA_COLUMN(YSvPull, ySvPull, float); -DECLARE_SOA_COLUMN(ZSvPull, zSvPull, float); } // namespace full DECLARE_SOA_TABLE(HfCandXicToXiPiPiLites, "AOD", "HFXICXI2PILITE", - hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec, - hf_cand_xic_to_xi_pi_pi::DebugMcRec, - hf_cand_xic_to_xi_pi_pi::OriginRec, + full::ParticleFlag, + hf_cand_xic_to_xi_pi_pi::OriginMcRec, full::CandidateSelFlag, - full::Sign, full::Y, full::Eta, full::Phi, @@ -129,11 +92,11 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiLites, "AOD", "HFXICXI2PILITE", full::PtPi0, full::PtPi1, full::M, - full::InvMassXi, - full::InvMassLambda, - full::InvMassXiPi0, - full::InvMassXiPi1, - full::Chi2Sv, + hf_cand_xic_to_xi_pi_pi::InvMassXi, + hf_cand_xic_to_xi_pi_pi::InvMassLambda, + hf_cand_xic_to_xi_pi_pi::InvMassXiPi0, + hf_cand_xic_to_xi_pi_pi::InvMassXiPi1, + full::Chi2SV, full::Ct, full::DecayLength, full::DecayLengthNormalised, @@ -141,10 +104,10 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiLites, "AOD", "HFXICXI2PILITE", full::DecayLengthXYNormalised, full::Cpa, full::CpaXY, - full::CpaXi, - full::CpaXYXi, - full::CpaLam, - full::CpaXYLam, + hf_cand_xic_to_xi_pi_pi::CpaXi, + hf_cand_xic_to_xi_pi_pi::CpaXYXi, + hf_cand_xic_to_xi_pi_pi::CpaLambda, + hf_cand_xic_to_xi_pi_pi::CpaXYLambda, full::ImpactParameterXi, full::ImpactParameterNormalisedXi, full::ImpactParameterPi0, @@ -154,24 +117,18 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiLites, "AOD", "HFXICXI2PILITE", full::MaxNormalisedDeltaIP); DECLARE_SOA_TABLE(HfCandXicToXiPiPiLiteKfs, "AOD", "HFXICXI2PILITKF", - hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec, - hf_cand_xic_to_xi_pi_pi::DebugMcRec, - hf_cand_xic_to_xi_pi_pi::OriginRec, + full::ParticleFlag, + hf_cand_xic_to_xi_pi_pi::OriginMcRec, full::CandidateSelFlag, - full::Sign, full::Y, full::Eta, full::Phi, - full::P, full::Pt, full::PtXi, full::PtPi0, full::PtPi1, full::M, - full::InvMassXi, - full::InvMassXiPi0, - full::InvMassXiPi1, - full::Chi2Sv, + full::Chi2SV, full::Ct, full::DecayLength, full::DecayLengthNormalised, @@ -179,10 +136,12 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiLiteKfs, "AOD", "HFXICXI2PILITKF", full::DecayLengthXYNormalised, full::Cpa, full::CpaXY, - full::CpaXi, - full::CpaXYXi, - full::CpaLam, - full::CpaXYLam, + hf_cand_xic_to_xi_pi_pi::CpaXi, + hf_cand_xic_to_xi_pi_pi::CpaXYXi, + hf_cand_xic_to_xi_pi_pi::CpaLambda, + hf_cand_xic_to_xi_pi_pi::CpaXYLambda, + hf_cand_xic_to_xi_pi_pi::CpaLambdaToXi, + hf_cand_xic_to_xi_pi_pi::CpaXYLambdaToXi, full::ImpactParameterXi, full::ImpactParameterNormalisedXi, full::ImpactParameterPi0, @@ -190,27 +149,46 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiLiteKfs, "AOD", "HFXICXI2PILITKF", full::ImpactParameterPi1, full::ImpactParameterNormalisedPi1, full::MaxNormalisedDeltaIP, + hf_cand_xic_to_xi_pi_pi::DcaXiDaughters, + hf_cand_xic_to_xi_pi_pi::DcaV0Daughters, + hf_cand_xic_to_xi_pi_pi::DcaXYCascToPV, + hf_cand_xic_to_xi_pi_pi::DcaZCascToPV, + hf_cand_xic_to_xi_pi_pi::DcaBachelorToPV, + hf_cand_xic_to_xi_pi_pi::DcaPosToPV, + hf_cand_xic_to_xi_pi_pi::DcaNegToPV, + // PID information + hf_cand_xic_to_xi_pi_pi::NSigTpcPiFromXicPlus0, + hf_cand_xic_to_xi_pi_pi::NSigTpcPiFromXicPlus1, + hf_cand_xic_to_xi_pi_pi::NSigTpcBachelorPi, + hf_cand_xic_to_xi_pi_pi::NSigTpcPiFromLambda, + hf_cand_xic_to_xi_pi_pi::NSigTpcPrFromLambda, + hf_cand_xic_to_xi_pi_pi::NSigTofPiFromXicPlus0, + hf_cand_xic_to_xi_pi_pi::NSigTofPiFromXicPlus1, + hf_cand_xic_to_xi_pi_pi::NSigTofBachelorPi, + hf_cand_xic_to_xi_pi_pi::NSigTofPiFromLambda, + hf_cand_xic_to_xi_pi_pi::NSigTofPrFromLambda, // KF specific columns - full::Chi2XiVtx, - full::Chi2LamVtx, - full::Chi2TopoXicPlusToPVBeforeConstraint, - full::Chi2TopoXicPlusToPV, - full::Chi2TopoXiToXicPlusBeforeConstraint, - full::Chi2TopoXiToXicPlus, - full::DcaXYPi0Pi1, - full::DcaXYPi0Xi, - full::DcaXYPi1Xi, - full::DcaPi0Pi1, - full::DcaPi0Xi, - full::DcaPi1Xi, - full::DcaXiDaughters); + full::Chi2GeoXi, + full::Chi2GeoLambda, + hf_cand_xic_to_xi_pi_pi::Chi2TopoXicPlusToPVBefConst, + hf_cand_xic_to_xi_pi_pi::Chi2TopoXicPlusToPV, + hf_cand_xic_to_xi_pi_pi::Chi2PrimXi, + hf_cand_xic_to_xi_pi_pi::Chi2PrimPi0, + hf_cand_xic_to_xi_pi_pi::Chi2PrimPi1, + hf_cand_xic_to_xi_pi_pi::Chi2DevPi0Pi1, + hf_cand_xic_to_xi_pi_pi::Chi2DevPi0Xi, + hf_cand_xic_to_xi_pi_pi::Chi2DevPi1Xi, + hf_cand_xic_to_xi_pi_pi::DcaPi0Pi1, + hf_cand_xic_to_xi_pi_pi::DcaPi0Xi, + hf_cand_xic_to_xi_pi_pi::DcaPi1Xi, + hf_cand_xic_to_xi_pi_pi::DcaXYPi0Pi1, + hf_cand_xic_to_xi_pi_pi::DcaXYPi0Xi, + hf_cand_xic_to_xi_pi_pi::DcaXYPi1Xi); DECLARE_SOA_TABLE(HfCandXicToXiPiPiFulls, "AOD", "HFXICXI2PIFULL", - hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec, - hf_cand_xic_to_xi_pi_pi::DebugMcRec, - hf_cand_xic_to_xi_pi_pi::OriginRec, + full::ParticleFlag, + hf_cand_xic_to_xi_pi_pi::OriginMcRec, full::CandidateSelFlag, - full::Sign, full::Y, full::Eta, full::Phi, @@ -220,11 +198,11 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFulls, "AOD", "HFXICXI2PIFULL", full::PtPi0, full::PtPi1, full::M, - full::InvMassXi, - full::InvMassLambda, - full::InvMassXiPi0, - full::InvMassXiPi1, - full::Chi2Sv, + hf_cand_xic_to_xi_pi_pi::InvMassXi, + hf_cand_xic_to_xi_pi_pi::InvMassLambda, + hf_cand_xic_to_xi_pi_pi::InvMassXiPi0, + hf_cand_xic_to_xi_pi_pi::InvMassXiPi1, + full::Chi2SV, full::Ct, full::DecayLength, full::DecayLengthNormalised, @@ -232,10 +210,10 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFulls, "AOD", "HFXICXI2PIFULL", full::DecayLengthXYNormalised, full::Cpa, full::CpaXY, - full::CpaXi, - full::CpaXYXi, - full::CpaLam, - full::CpaXYLam, + hf_cand_xic_to_xi_pi_pi::CpaXi, + hf_cand_xic_to_xi_pi_pi::CpaXYXi, + hf_cand_xic_to_xi_pi_pi::CpaLambda, + hf_cand_xic_to_xi_pi_pi::CpaXYLambda, full::ImpactParameterXi, full::ImpactParameterNormalisedXi, full::ImpactParameterPi0, @@ -244,19 +222,13 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFulls, "AOD", "HFXICXI2PIFULL", full::ImpactParameterNormalisedPi1, full::MaxNormalisedDeltaIP, // additional columns only stored in the full candidate table - full::XPvErr, - full::YPvErr, - full::ZPvErr, - full::XSvErr, - full::YSvErr, - full::ZSvErr, - full::CpaLamToXi, - full::CpaXYLamToXi, + hf_cand_xic_to_xi_pi_pi::CpaLambdaToXi, + hf_cand_xic_to_xi_pi_pi::CpaXYLambdaToXi, full::PPi0, full::PPi1, - full::PBachelorPi, - full::PPiFromLambda, - full::PPrFromLambda, + hf_cand_xic_to_xi_pi_pi::PBachelorPi, + hf_cand_xic_to_xi_pi_pi::PPiFromLambda, + hf_cand_xic_to_xi_pi_pi::PPrFromLambda, hf_cand_xic_to_xi_pi_pi::DcaXiDaughters, hf_cand_xic_to_xi_pi_pi::DcaV0Daughters, hf_cand_xic_to_xi_pi_pi::DcaPosToPV, @@ -276,24 +248,18 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFulls, "AOD", "HFXICXI2PIFULL", hf_cand_xic_to_xi_pi_pi::NSigTofPrFromLambda); DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", - hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec, - hf_cand_xic_to_xi_pi_pi::DebugMcRec, - hf_cand_xic_to_xi_pi_pi::OriginRec, + full::ParticleFlag, + hf_cand_xic_to_xi_pi_pi::OriginMcRec, full::CandidateSelFlag, - full::Sign, full::Y, full::Eta, full::Phi, - full::P, full::Pt, full::PtXi, full::PtPi0, full::PtPi1, full::M, - full::InvMassXi, - full::InvMassXiPi0, - full::InvMassXiPi1, - full::Chi2Sv, + full::Chi2SV, full::Ct, full::DecayLength, full::DecayLengthNormalised, @@ -301,10 +267,12 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", full::DecayLengthXYNormalised, full::Cpa, full::CpaXY, - full::CpaXi, - full::CpaXYXi, - full::CpaLam, - full::CpaXYLam, + hf_cand_xic_to_xi_pi_pi::CpaXi, + hf_cand_xic_to_xi_pi_pi::CpaXYXi, + hf_cand_xic_to_xi_pi_pi::CpaLambda, + hf_cand_xic_to_xi_pi_pi::CpaXYLambda, + hf_cand_xic_to_xi_pi_pi::CpaLambdaToXi, + hf_cand_xic_to_xi_pi_pi::CpaXYLambdaToXi, full::ImpactParameterXi, full::ImpactParameterNormalisedXi, full::ImpactParameterPi0, @@ -312,20 +280,25 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", full::ImpactParameterPi1, full::ImpactParameterNormalisedPi1, full::MaxNormalisedDeltaIP, + hf_cand_xic_to_xi_pi_pi::DcaXiDaughters, + hf_cand_xic_to_xi_pi_pi::DcaV0Daughters, + hf_cand_xic_to_xi_pi_pi::DcaXYCascToPV, + hf_cand_xic_to_xi_pi_pi::DcaZCascToPV, + hf_cand_xic_to_xi_pi_pi::DcaBachelorToPV, + hf_cand_xic_to_xi_pi_pi::DcaPosToPV, + hf_cand_xic_to_xi_pi_pi::DcaNegToPV, // additional columns only stored in the full candidate table - full::XPvErr, - full::YPvErr, - full::ZPvErr, - full::XSvErr, - full::YSvErr, - full::ZSvErr, - full::CpaLamToXi, - full::CpaXYLamToXi, + hf_cand_xic_to_xi_pi_pi::InvMassXi, + hf_cand_xic_to_xi_pi_pi::InvMassXiPi0, + hf_cand_xic_to_xi_pi_pi::InvMassXiPi1, + hf_cand_xic_to_xi_pi_pi::InvMassLambda, + full::P, full::PPi0, full::PPi1, - full::PBachelorPi, - full::PPiFromLambda, - full::PPrFromLambda, + hf_cand_xic_to_xi_pi_pi::PBachelorPi, + hf_cand_xic_to_xi_pi_pi::PPiFromLambda, + hf_cand_xic_to_xi_pi_pi::PPrFromLambda, + // PID information hf_cand_xic_to_xi_pi_pi::NSigTpcPiFromXicPlus0, hf_cand_xic_to_xi_pi_pi::NSigTpcPiFromXicPlus1, hf_cand_xic_to_xi_pi_pi::NSigTpcBachelorPi, @@ -337,45 +310,31 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", hf_cand_xic_to_xi_pi_pi::NSigTofPiFromLambda, hf_cand_xic_to_xi_pi_pi::NSigTofPrFromLambda, // KF-specific columns - full::Chi2XiVtx, - full::Chi2LamVtx, - full::Chi2TopoXicPlusToPVBeforeConstraint, - full::Chi2TopoXicPlusToPV, - full::Chi2TopoXiToXicPlusBeforeConstraint, - full::Chi2TopoXiToXicPlus, - full::DcaXYPi0Pi1, - full::DcaXYPi0Xi, - full::DcaXYPi1Xi, - full::DcaPi0Pi1, - full::DcaPi0Xi, - full::DcaPi1Xi, - full::DcaXiDaughters); + full::Chi2GeoXi, + full::Chi2GeoLambda, + hf_cand_xic_to_xi_pi_pi::Chi2TopoXicPlusToPVBefConst, + hf_cand_xic_to_xi_pi_pi::Chi2TopoXicPlusToPV, + hf_cand_xic_to_xi_pi_pi::Chi2PrimXi, + hf_cand_xic_to_xi_pi_pi::Chi2PrimPi0, + hf_cand_xic_to_xi_pi_pi::Chi2PrimPi1, + hf_cand_xic_to_xi_pi_pi::Chi2DevPi0Pi1, + hf_cand_xic_to_xi_pi_pi::Chi2DevPi0Xi, + hf_cand_xic_to_xi_pi_pi::Chi2DevPi1Xi, + hf_cand_xic_to_xi_pi_pi::DcaPi0Pi1, + hf_cand_xic_to_xi_pi_pi::DcaPi0Xi, + hf_cand_xic_to_xi_pi_pi::DcaPi1Xi, + hf_cand_xic_to_xi_pi_pi::DcaXYPi0Pi1, + hf_cand_xic_to_xi_pi_pi::DcaXYPi0Xi, + hf_cand_xic_to_xi_pi_pi::DcaXYPi1Xi); DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullPs, "AOD", "HFXICXI2PIFULLP", hf_cand_xic_to_xi_pi_pi::FlagMcMatchGen, - hf_cand_xic_to_xi_pi_pi::DebugMcGen, - hf_cand_xic_to_xi_pi_pi::OriginGen, + hf_cand_xic_to_xi_pi_pi::OriginMcGen, + hf_cand::PdgBhadMotherPart, full::Pt, full::Eta, full::Phi, full::Y); - -DECLARE_SOA_TABLE(HfCandXicToXiPiPiResiduals, "AOD", "HFXICXI2PIRESID", - hf_cand_xic_to_xi_pi_pi::OriginGen, - full::PResidual, - full::PtResidual, - full::XPvResidual, - full::YPvResidual, - full::ZPvResidual, - full::XPvPull, - full::YPvPull, - full::ZPvPull, - full::XSvResidual, - full::YSvResidual, - full::ZSvResidual, - full::XSvPull, - full::YSvPull, - full::ZSvPull); } // namespace o2::aod /// Writes the full information in an output TTree @@ -385,7 +344,6 @@ struct HfTreeCreatorXicToXiPiPi { Produces rowCandidateFull; Produces rowCandidateFullKf; Produces rowCandidateFullParticles; - Produces rowCandidateResiduals; Configurable selectionFlagXic{"selectionFlagXic", 1, "Selection Flag for Xic"}; Configurable fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"}; @@ -400,8 +358,10 @@ struct HfTreeCreatorXicToXiPiPi { using SelectedCandidatesKf = soa::Filtered>; using SelectedCandidatesMc = soa::Filtered>; using SelectedCandidatesKfMc = soa::Filtered>; + using MatchedGenXicToXiPiPi = soa::Filtered>; Filter filterSelectCandidates = aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= selectionFlagXic; + Filter filterGenXicToXiPiPi = (nabs(aod::hf_cand_xic_to_xi_pi_pi::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi)) || nabs(aod::hf_cand_xic_to_xi_pi_pi::flagMcMatchGen) == static_cast(BIT(aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi))); Partition recSig = nabs(aod::hf_cand_xic_to_xi_pi_pi::flagMcMatchRec) != int8_t(0); Partition recBg = nabs(aod::hf_cand_xic_to_xi_pi_pi::flagMcMatchRec) == int8_t(0); @@ -415,22 +375,18 @@ struct HfTreeCreatorXicToXiPiPi { template void fillCandidateTable(const T& candidate) { - int8_t flagMc = 0; - int8_t debugMc = 0; + int8_t particleFlag = candidate.sign(); int8_t originMc = 0; if constexpr (doMc) { - flagMc = candidate.flagMcMatchRec(); - debugMc = candidate.debugMcRec(); - originMc = candidate.originRec(); + particleFlag = candidate.flagMcMatchRec(); + originMc = candidate.originMcRec(); } if constexpr (!doKf) { if (fillCandidateLiteTable) { rowCandidateLite( - flagMc, - debugMc, + particleFlag, originMc, candidate.isSelXicToXiPiPi(), - candidate.sign(), candidate.y(o2::constants::physics::MassXiCPlus), candidate.eta(), candidate.phi(), @@ -452,10 +408,10 @@ struct HfTreeCreatorXicToXiPiPi { candidate.decayLengthXYNormalised(), candidate.cpa(), candidate.cpaXY(), - candidate.cosPaXi(), - candidate.cosPaXYXi(), - candidate.cosPaLambda(), - candidate.cosPaXYLambda(), + candidate.cpaXi(), + candidate.cpaXYXi(), + candidate.cpaLambda(), + candidate.cpaXYLambda(), candidate.impactParameter0(), candidate.impactParameterNormalised0(), candidate.impactParameter1(), @@ -465,11 +421,9 @@ struct HfTreeCreatorXicToXiPiPi { candidate.maxNormalisedDeltaIP()); } else { rowCandidateFull( - flagMc, - debugMc, + particleFlag, originMc, candidate.isSelXicToXiPiPi(), - candidate.sign(), candidate.y(o2::constants::physics::MassXiCPlus), candidate.eta(), candidate.phi(), @@ -491,10 +445,10 @@ struct HfTreeCreatorXicToXiPiPi { candidate.decayLengthXYNormalised(), candidate.cpa(), candidate.cpaXY(), - candidate.cosPaXi(), - candidate.cosPaXYXi(), - candidate.cosPaLambda(), - candidate.cosPaXYLambda(), + candidate.cpaXi(), + candidate.cpaXYXi(), + candidate.cpaLambda(), + candidate.cpaXYLambda(), candidate.impactParameter0(), candidate.impactParameterNormalised0(), candidate.impactParameter1(), @@ -503,14 +457,8 @@ struct HfTreeCreatorXicToXiPiPi { candidate.impactParameterNormalised2(), candidate.maxNormalisedDeltaIP(), // additional columns only stored in the full candidate table - candidate.xPvErr(), - candidate.yPvErr(), - candidate.zPvErr(), - candidate.xSvErr(), - candidate.ySvErr(), - candidate.zSvErr(), - candidate.cosPaLambdaToXi(), - candidate.cosPaXYLambdaToXi(), + candidate.cpaLambdaToXi(), + candidate.cpaXYLambdaToXi(), candidate.pProng1(), candidate.pProng2(), candidate.pBachelorPi(), @@ -522,7 +470,7 @@ struct HfTreeCreatorXicToXiPiPi { candidate.dcaNegToPV(), candidate.dcaBachelorToPV(), candidate.dcaXYCascToPV(), - candidate.dcaXCascToPV(), + candidate.dcaZCascToPV(), candidate.nSigTpcPiFromXicPlus0(), candidate.nSigTpcPiFromXicPlus1(), candidate.nSigTpcBachelorPi(), @@ -537,35 +485,31 @@ struct HfTreeCreatorXicToXiPiPi { } else { if (fillCandidateLiteTable) { rowCandidateLiteKf( - flagMc, - debugMc, + particleFlag, originMc, candidate.isSelXicToXiPiPi(), - candidate.sign(), candidate.y(o2::constants::physics::MassXiCPlus), candidate.eta(), candidate.phi(), - candidate.p(), candidate.pt(), candidate.ptProng0(), candidate.ptProng1(), candidate.ptProng2(), candidate.invMassXicPlus(), - candidate.invMassXi(), - candidate.invMassXiPi0(), - candidate.invMassXiPi1(), candidate.chi2PCA(), candidate.ct(o2::constants::physics::MassXiCPlus), - candidate.decayLength(), - candidate.decayLengthNormalised(), - candidate.decayLengthXY(), - candidate.decayLengthXYNormalised(), + candidate.kfDecayLength(), + candidate.kfDecayLengthNormalised(), + candidate.kfDecayLengthXY(), + candidate.kfDecayLengthXYNormalised(), candidate.cpa(), candidate.cpaXY(), - candidate.cosPaXi(), - candidate.cosPaXYXi(), - candidate.cosPaLambda(), - candidate.cosPaXYLambda(), + candidate.cpaXi(), + candidate.cpaXYXi(), + candidate.cpaLambda(), + candidate.cpaXYLambda(), + candidate.cpaLambdaToXi(), + candidate.cpaXYLambdaToXi(), candidate.impactParameter0(), candidate.impactParameterNormalised0(), candidate.impactParameter1(), @@ -573,51 +517,68 @@ struct HfTreeCreatorXicToXiPiPi { candidate.impactParameter2(), candidate.impactParameterNormalised2(), candidate.maxNormalisedDeltaIP(), + candidate.dcaXiDaughters(), + candidate.dcaV0Daughters(), + candidate.dcaXYCascToPV(), + candidate.dcaZCascToPV(), + candidate.dcaBachelorToPV(), + candidate.dcaPosToPV(), + candidate.dcaNegToPV(), + // PID information + candidate.nSigTpcPiFromXicPlus0(), + candidate.nSigTpcPiFromXicPlus1(), + candidate.nSigTpcBachelorPi(), + candidate.nSigTpcPiFromLambda(), + candidate.nSigTpcPrFromLambda(), + candidate.nSigTofPiFromXicPlus0(), + candidate.nSigTofPiFromXicPlus1(), + candidate.nSigTofBachelorPi(), + candidate.nSigTofPiFromLambda(), + candidate.nSigTofPrFromLambda(), // KF-specific columns candidate.kfCascadeChi2(), candidate.kfV0Chi2(), - candidate.chi2TopoXicPlusToPVBeforeConstraint(), + candidate.chi2TopoXicPlusToPVBefConst(), candidate.chi2TopoXicPlusToPV(), - candidate.chi2TopoXiToXicPlusBeforeConstraint(), - candidate.chi2TopoXiToXicPlus(), - candidate.dcaXYPi0Pi1(), - candidate.dcaXYPi0Xi(), - candidate.dcaXYPi1Xi(), + candidate.chi2PrimXi(), + candidate.chi2PrimPi0(), + candidate.chi2PrimPi1(), + candidate.chi2DevPi0Pi1(), + candidate.chi2DevPi0Xi(), + candidate.chi2DevPi1Xi(), candidate.dcaPi0Pi1(), candidate.dcaPi0Xi(), candidate.dcaPi1Xi(), - candidate.dcacascdaughters()); + candidate.dcaXYPi0Pi1(), + candidate.dcaXYPi0Xi(), + candidate.dcaXYPi1Xi()); } else { rowCandidateFullKf( - flagMc, - debugMc, + particleFlag, originMc, candidate.isSelXicToXiPiPi(), - candidate.sign(), candidate.y(o2::constants::physics::MassXiCPlus), candidate.eta(), candidate.phi(), - candidate.p(), candidate.pt(), candidate.ptProng0(), candidate.ptProng1(), candidate.ptProng2(), candidate.invMassXicPlus(), - candidate.invMassXi(), - candidate.invMassXiPi0(), - candidate.invMassXiPi1(), candidate.chi2PCA(), candidate.ct(o2::constants::physics::MassXiCPlus), - candidate.decayLength(), - candidate.decayLengthNormalised(), - candidate.decayLengthXY(), - candidate.decayLengthXYNormalised(), + candidate.kfDecayLength(), + candidate.kfDecayLengthNormalised(), + candidate.kfDecayLengthXY(), + candidate.kfDecayLengthXYNormalised(), candidate.cpa(), candidate.cpaXY(), - candidate.cosPaXi(), - candidate.cosPaXYXi(), - candidate.cosPaLambda(), - candidate.cosPaXYLambda(), + candidate.cpaXi(), + candidate.cpaXYXi(), + candidate.cpaLambda(), + candidate.cpaXYLambda(), + candidate.cpaLambdaToXi(), + candidate.cpaXYLambdaToXi(), candidate.impactParameter0(), candidate.impactParameterNormalised0(), candidate.impactParameter1(), @@ -625,20 +586,25 @@ struct HfTreeCreatorXicToXiPiPi { candidate.impactParameter2(), candidate.impactParameterNormalised2(), candidate.maxNormalisedDeltaIP(), + candidate.dcaXiDaughters(), + candidate.dcaV0Daughters(), + candidate.dcaXYCascToPV(), + candidate.dcaZCascToPV(), + candidate.dcaBachelorToPV(), + candidate.dcaPosToPV(), + candidate.dcaNegToPV(), // additional columns only stored in the full candidate table - candidate.xPvErr(), - candidate.yPvErr(), - candidate.zPvErr(), - candidate.xSvErr(), - candidate.ySvErr(), - candidate.zSvErr(), - candidate.cosPaLambdaToXi(), - candidate.cosPaXYLambdaToXi(), + candidate.invMassXi(), + candidate.invMassXiPi0(), + candidate.invMassXiPi1(), + candidate.invMassLambda(), + candidate.p(), candidate.pProng1(), candidate.pProng2(), candidate.pBachelorPi(), candidate.pPiFromLambda(), candidate.pPrFromLambda(), + // PID information candidate.nSigTpcPiFromXicPlus0(), candidate.nSigTpcPiFromXicPlus1(), candidate.nSigTpcBachelorPi(), @@ -652,17 +618,20 @@ struct HfTreeCreatorXicToXiPiPi { // KF-specific columns candidate.kfCascadeChi2(), candidate.kfV0Chi2(), - candidate.chi2TopoXicPlusToPVBeforeConstraint(), + candidate.chi2TopoXicPlusToPVBefConst(), candidate.chi2TopoXicPlusToPV(), - candidate.chi2TopoXiToXicPlusBeforeConstraint(), - candidate.chi2TopoXiToXicPlus(), - candidate.dcaXYPi0Pi1(), - candidate.dcaXYPi0Xi(), - candidate.dcaXYPi1Xi(), + candidate.chi2PrimXi(), + candidate.chi2PrimPi0(), + candidate.chi2PrimPi1(), + candidate.chi2DevPi0Pi1(), + candidate.chi2DevPi0Xi(), + candidate.chi2DevPi1Xi(), candidate.dcaPi0Pi1(), candidate.dcaPi0Xi(), candidate.dcaPi1Xi(), - candidate.dcacascdaughters()); + candidate.dcaXYPi0Pi1(), + candidate.dcaXYPi0Xi(), + candidate.dcaXYPi1Xi()); } } } @@ -708,7 +677,7 @@ struct HfTreeCreatorXicToXiPiPi { PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processDataKf, "Process data with KFParticle reconstruction", false); void processMc(SelectedCandidatesMc const& candidates, - soa::Join const& particles) + MatchedGenXicToXiPiPi const& particles) { // Filling candidate properties if (fillOnlySignal) { @@ -746,25 +715,22 @@ struct HfTreeCreatorXicToXiPiPi { if (fillGenParticleTable) { rowCandidateFullParticles.reserve(particles.size()); - for (const auto& particle : particles) { - if (TESTBIT(std::abs(particle.flagMcMatchGen()), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) || TESTBIT(std::abs(particle.flagMcMatchGen()), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi)) { - rowCandidateFullParticles( - particle.flagMcMatchGen(), - particle.debugMcGen(), - particle.originGen(), - particle.pt(), - particle.eta(), - particle.phi(), - RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus)); - } - } // loop over generated particles + rowCandidateFullParticles( + particle.flagMcMatchGen(), + particle.originMcGen(), + particle.pdgBhadMotherPart(), + particle.pt(), + particle.eta(), + particle.phi(), + RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus)); + } } } PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processMc, "Process MC with DCAFitter reconstruction", false); void processMcKf(SelectedCandidatesKfMc const& candidates, - soa::Join const& particles) + MatchedGenXicToXiPiPi const& particles) { // Filling candidate properties if (fillOnlySignal) { @@ -803,109 +769,18 @@ struct HfTreeCreatorXicToXiPiPi { if (fillGenParticleTable) { rowCandidateFullParticles.reserve(particles.size()); for (const auto& particle : particles) { - if (TESTBIT(std::abs(particle.flagMcMatchGen()), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiPiPi) || TESTBIT(std::abs(particle.flagMcMatchGen()), aod::hf_cand_xic_to_xi_pi_pi::DecayType::XicToXiResPiToXiPiPi)) { - rowCandidateFullParticles( - particle.flagMcMatchGen(), - particle.debugMcGen(), - particle.originGen(), - particle.pt(), - particle.eta(), - particle.phi(), - RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus)); - } - } // loop over generated particles + rowCandidateFullParticles( + particle.flagMcMatchGen(), + particle.originMcGen(), + particle.pdgBhadMotherPart(), + particle.pt(), + particle.eta(), + particle.phi(), + RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus)); + } } } PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processMcKf, "Process MC with KF Particle reconstruction", false); - - void processResiduals(SelectedCandidatesMc const&, - aod::TracksWMc const& tracks, - aod::McParticles const& particles) - { - rowCandidateResiduals.reserve(recSig.size()); - - recSig->bindExternalIndices(&tracks); - - std::vector arrDaughIndex; - int indexRecXicPlus; - int8_t sign; - int8_t origin; - std::array pvResiduals; - std::array svResiduals; - std::array pvPulls; - std::array svPulls; - - for (const auto& candidate : recSig) { - arrDaughIndex.clear(); - indexRecXicPlus = -1; - sign = 0; - origin = 0; - pvResiduals = {-9999.9}; - svResiduals = {-9999.9}; - pvPulls = {-9999.9}; - svPulls = {-9999.9}; - - auto arrayDaughters = std::array{candidate.pi0_as(), // pi <- Xic - candidate.pi1_as(), // pi <- Xic - candidate.bachelor_as(), // pi <- cascade - candidate.posTrack_as(), // p <- lambda - candidate.negTrack_as()}; // pi <- lambda - - // get XicPlus as MC particle - indexRecXicPlus = RecoDecay::getMatchedMCRec(particles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4); - if (indexRecXicPlus == -1) { - continue; - } - auto XicPlusGen = particles.rawIteratorAt(indexRecXicPlus); - origin = RecoDecay::getCharmHadronOrigin(particles, XicPlusGen, true); - - // get MC collision - auto mcCollision = XicPlusGen.mcCollision_as(); - - // get XicPlus daughters as MC particle - RecoDecay::getDaughters(XicPlusGen, &arrDaughIndex, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, 2); - auto XicPlusDaugh0 = particles.rawIteratorAt(arrDaughIndex[0]); - - // calculate residuals and pulls - float pResidual = candidate.p() - XicPlusGen.p(); - float ptResidual = candidate.pt() - XicPlusGen.pt(); - pvResiduals[0] = candidate.posX() - mcCollision.posX(); - pvResiduals[1] = candidate.posY() - mcCollision.posY(); - pvResiduals[2] = candidate.posZ() - mcCollision.posZ(); - svResiduals[0] = candidate.xSecondaryVertex() - XicPlusDaugh0.vx(); - svResiduals[1] = candidate.ySecondaryVertex() - XicPlusDaugh0.vy(); - svResiduals[2] = candidate.zSecondaryVertex() - XicPlusDaugh0.vz(); - try { - pvPulls[0] = pvResiduals[0] / candidate.xPvErr(); - pvPulls[1] = pvResiduals[1] / candidate.yPvErr(); - pvPulls[2] = pvResiduals[2] / candidate.zPvErr(); - svPulls[0] = svResiduals[0] / candidate.xSvErr(); - svPulls[1] = svResiduals[1] / candidate.ySvErr(); - svPulls[2] = svResiduals[2] / candidate.zSvErr(); - } catch (const std::runtime_error& error) { - LOG(info) << "Run time error found: " << error.what() << ". Set values of vertex pulls to -9999.9."; - } - - // fill table - rowCandidateResiduals( - origin, - pResidual, - ptResidual, - pvResiduals[0], - pvResiduals[1], - pvResiduals[2], - pvPulls[0], - pvPulls[1], - pvPulls[2], - svResiduals[0], - svResiduals[1], - svResiduals[2], - svPulls[0], - svPulls[1], - svPulls[2]); - } // loop over reconstructed signal - } - PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processResiduals, "Process Residuals and pulls for both DCAFitter and KFParticle reconstruction", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/treeCreatorXiccToPKPiPi.cxx b/PWGHF/TableProducer/treeCreatorXiccToPKPiPi.cxx index 2ceeb567de2..56ca3f152c6 100644 --- a/PWGHF/TableProducer/treeCreatorXiccToPKPiPi.cxx +++ b/PWGHF/TableProducer/treeCreatorXiccToPKPiPi.cxx @@ -17,14 +17,24 @@ /// /// \author Jinjoo Seo , Inha University -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/PIDResponseTOF.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + using namespace o2; using namespace o2::framework; diff --git a/PWGHF/Tasks/CMakeLists.txt b/PWGHF/Tasks/CMakeLists.txt index 9a46eeba773..b212b705b23 100644 --- a/PWGHF/Tasks/CMakeLists.txt +++ b/PWGHF/Tasks/CMakeLists.txt @@ -46,7 +46,7 @@ o2physics_add_dpl_workflow(task-multiplicity-estimator-correlation o2physics_add_dpl_workflow(task-pid-studies SOURCES taskPidStudies.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::EventFilteringUtils O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) # o2physics_add_dpl_workflow(task-sel-optimisation diff --git a/PWGHF/Tasks/taskCharmHadImpactPar.cxx b/PWGHF/Tasks/taskCharmHadImpactPar.cxx index dc37599ccff..3000d5bf8c5 100644 --- a/PWGHF/Tasks/taskCharmHadImpactPar.cxx +++ b/PWGHF/Tasks/taskCharmHadImpactPar.cxx @@ -13,19 +13,44 @@ /// \brief Analysis task to produce impact-parameter distributions of charm hadrons /// /// \author Fabrizio Grosa , CERN +/// \author Antonio Palasciano , INFN Bari -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsEvSelHf.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include using namespace o2; +using namespace o2::aod; using namespace o2::analysis; +using namespace o2::constants::math; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_centrality; +using namespace o2::hf_occupancy; enum Channel : uint8_t { DplusToKPiPi = 0, @@ -33,116 +58,327 @@ enum Channel : uint8_t { NChannels }; +namespace o2::aod +{ +namespace hf_charm_cand_lite +{ +DECLARE_SOA_COLUMN(Centrality, centrality, float); //! Centrality (or multiplicity) percentile +DECLARE_SOA_COLUMN(Occupancy, occupancy, float); //! Occupancy +DECLARE_SOA_COLUMN(M, m, float); //! Invariant mass of candidate (GeV/c2) +DECLARE_SOA_COLUMN(Pt, pt, float); //! Transverse momentum of candidate (GeV/c) +DECLARE_SOA_COLUMN(Y, y, float); //! Rapidity of candidate +DECLARE_SOA_COLUMN(Phi, phi, float); //! Azimuth angle of candidate +DECLARE_SOA_COLUMN(ImpactParameterXY, impactParameterXY, float); //! Dca XY of candidate +DECLARE_SOA_COLUMN(ImpactParameterZ, impactParameterZ, float); //! Dca Z of candidate +DECLARE_SOA_COLUMN(MlScoreBkg, mlScoreBkg, float); //! ML score for background class +DECLARE_SOA_COLUMN(MlScorePrompt, mlScorePrompt, float); //! ML Prompt score for prompt class +DECLARE_SOA_COLUMN(MlScoreNonPrompt, mlScoreNonPrompt, float); //! ML Non Prompt score for non prompt class +DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); //! Pt of the 1st daughter +DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); //! Pt of the 2nd daughter +DECLARE_SOA_COLUMN(PtProng2, ptProng2, float); //! Pt of the 3rd daughter (if present) +DECLARE_SOA_COLUMN(PhiProng0, phiProng0, float); //! Phi of the 1st daughter +DECLARE_SOA_COLUMN(PhiProng1, phiProng1, float); //! Phi of the 2nd daughter +DECLARE_SOA_COLUMN(PhiProng2, phiProng2, float); //! Phi of the 3rd daughter (if present) +DECLARE_SOA_COLUMN(EtaProng0, etaProng0, float); //! Eta of the 1st daughter +DECLARE_SOA_COLUMN(EtaProng1, etaProng1, float); //! Eta of the 2nd daughter +DECLARE_SOA_COLUMN(EtaProng2, etaProng2, float); //! Eta of the 3rd daughter (if present) +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! Flag for reconstruction level matching +} // namespace hf_charm_cand_lite + +DECLARE_SOA_TABLE(HfCharmCandLites, "AOD", "HFCHARMCANDLITE", //! Table with some charm hadron properties + collision::NumContrib, + collision::PosX, + collision::PosY, + collision::PosZ, + hf_charm_cand_lite::Centrality, + hf_charm_cand_lite::Occupancy, + hf_cand::XSecondaryVertex, + hf_cand::YSecondaryVertex, + hf_cand::ZSecondaryVertex, + hf_charm_cand_lite::M, + hf_charm_cand_lite::Pt, + hf_charm_cand_lite::Y, + hf_charm_cand_lite::Phi, + hf_charm_cand_lite::ImpactParameterXY, + hf_charm_cand_lite::ImpactParameterZ, + hf_charm_cand_lite::MlScoreBkg, + hf_charm_cand_lite::MlScorePrompt, + hf_charm_cand_lite::MlScoreNonPrompt, + hf_charm_cand_lite::PtProng0, + hf_charm_cand_lite::PtProng1, + hf_charm_cand_lite::PtProng2, + hf_charm_cand_lite::PhiProng0, + hf_charm_cand_lite::PhiProng1, + hf_charm_cand_lite::PhiProng2, + hf_charm_cand_lite::EtaProng0, + hf_charm_cand_lite::EtaProng1, + hf_charm_cand_lite::EtaProng2, + hf_charm_cand_lite::FlagMcMatchRec); +} // namespace o2::aod + struct HfTaskCharmHadImpactPar { + Produces hfCharmCandLite; + Configurable selectionFlag{"selectionFlag", 15, "Selection Flag for the considered charm hadron"}; - ConfigurableAxis axisPt{"axisPt", {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 10.f, 12.f, 16.f, 24.f, 36.f, 50.f}, "axis for pT of charm hadron"}; - ConfigurableAxis axisMass{"axisMass", {250, 1.65f, 2.15f}, "axis for mass of charm hadron"}; - ConfigurableAxis axisImpPar{"axisImpPar", {2000, -500.f, 500.f}, "axis for impact-parameter of charm hadron"}; - ConfigurableAxis axisMlScore0{"axisMlScore0", {100, 0.f, 1.f}, "axis for ML output score 0"}; - ConfigurableAxis axisMlScore1{"axisMlScore1", {100, 0.f, 1.f}, "axis for ML output score 1"}; - ConfigurableAxis axisMlScore2{"axisMlScore2", {100, 0.f, 1.f}, "axis for ML output score 2"}; + Configurable fillLightTreeCandidate{"fillLightTreeCandidate", 0, "Flag to store charm hadron features"}; + Configurable centEstimator{"centEstimator", 0, "Centrality estimation (None: 0, FT0C: 2, FT0M: 3)"}; + Configurable occEstimator{"occEstimator", 0, "Occupancy estimation (None: 0, ITS: 1, FT0C: 2)"}; + Configurable fillOnlySignal{"fillOnlySignal", false, "Flag to store only matched candidates"}; HfHelper hfHelper; + using Collisions = soa::Join; + using CollisionsCent = soa::Join; using CandDplusData = soa::Filtered>; using CandDplusDataWithMl = soa::Filtered>; + using CandDplusMC = soa::Filtered>; + using CandDplusMCWithMl = soa::Filtered>; using CandDzeroData = soa::Filtered>; using CandDzeroDataWithMl = soa::Filtered>; + using CandDzeroMc = soa::Filtered>; + using CandDzeroMcWithMl = soa::Filtered>; Filter filterDplusFlag = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlag; Filter filterDzeroFlag = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlag || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlag; + ConfigurableAxis axisPt{"axisPt", {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 10.f, 12.f, 16.f, 24.f, 36.f, 50.f}, "axis for pT of charm hadron"}; + ConfigurableAxis axisMass{"axisMass", {250, 1.65f, 2.15f}, "axis for mass of charm hadron"}; + ConfigurableAxis axisPhi{"axisPhi", {180, 0.f, TwoPI}, "axis for azimuthal angle of charm hadron"}; + ConfigurableAxis axisY{"axisY", {20, -1.f, 1.f}, "axis for rapidity of charm hadron"}; + ConfigurableAxis axisImpPar{"axisImpPar", {2000, -500.f, 500.f}, "axis for impact-parameter of charm hadron"}; + ConfigurableAxis axisMlScore0{"axisMlScore0", {100, 0.f, 1.f}, "axis for ML output score 0"}; + ConfigurableAxis axisMlScore1{"axisMlScore1", {100, 0.f, 1.f}, "axis for ML output score 1"}; + ConfigurableAxis axisMlScore2{"axisMlScore2", {100, 0.f, 1.f}, "axis for ML output score 2"}; + HistogramRegistry registry{"registry"}; void init(InitContext&) { - std::array doprocess{doprocessDplus, doprocessDplusWithMl, doprocessDzero, doprocessDzeroWithMl}; + std::array doprocess{doprocessDataDplus, doprocessDataDplusWithMl, doprocessMCDplus, doprocessMCDplusWithMl, doprocessDataDzero, doprocessDataDzeroWithMl, doprocessMCDzero, doprocessMCDzeroWithMl}; if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { LOGP(fatal, "Only one process function should be enabled! Please check your configuration!"); } - if (doprocessDplus || doprocessDzero) { - registry.add("hMassPtImpPar", ";#it{M} (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c});dca XY (#mum);", HistType::kTHnSparseF, {axisMass, axisPt, axisImpPar}); - } else if (doprocessDplusWithMl || doprocessDzeroWithMl) { - registry.add("hMassPtImpPar", ";#it{M} (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c});dca XY (#mum);ML score 0;ML score 1; ML score 2;", HistType::kTHnSparseF, {axisMass, axisPt, axisImpPar, axisMlScore0, axisMlScore1, axisMlScore2}); + if (doprocessDataDplus || doprocessDataDzero || doprocessMCDplus || doprocessMCDzero) { + registry.add("hMassPtImpParPhiY", ";#it{M} (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c});dca XY (#mum); phi; y;", HistType::kTHnSparseF, {axisMass, axisPt, axisImpPar, axisPhi, axisY}); + } else if (doprocessDataDplusWithMl || doprocessDataDzeroWithMl || doprocessMCDplusWithMl || doprocessMCDzeroWithMl) { + registry.add("hMassPtImpParPhiY", ";#it{M} (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c});dca XY (#mum); phi; y; ML score 0;ML score 1; ML score 2;", HistType::kTHnSparseF, {axisMass, axisPt, axisImpPar, axisPhi, axisY, axisMlScore0, axisMlScore1, axisMlScore2}); } } // Fill THnSparses for the ML analysis /// \param candidate is a particle candidate - template + template void fillSparse(const CCands& candidate) { std::vector outputMl = {-999., -999., -999.}; float invMass{-1.f}; + float yCand{-999.f}; if constexpr (channel == Channel::DplusToKPiPi) { // D+ -> Kpipi + if constexpr (doMc) { + if (fillOnlySignal) { + if (std::abs(candidate.flagMcMatchRec()) != o2::hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { + return; + } + } + } invMass = hfHelper.invMassDplusToPiKPi(candidate); + yCand = hfHelper.yDplus(candidate); if constexpr (withMl) { for (auto iScore{0u}; iScore < candidate.mlProbDplusToPiKPi().size(); ++iScore) { outputMl[iScore] = candidate.mlProbDplusToPiKPi()[iScore]; } - registry.fill(HIST("hMassPtImpPar"), invMass, candidate.pt(), candidate.impactParameterXY(), outputMl[0], outputMl[1], outputMl[2]); + registry.fill(HIST("hMassPtImpParPhiY"), invMass, candidate.pt(), candidate.impactParameterXY(), candidate.phi(), yCand, outputMl[0], outputMl[1], outputMl[2]); } else { - registry.fill(HIST("hMassPtImpPar"), invMass, candidate.pt(), candidate.impactParameterXY()); + registry.fill(HIST("hMassPtImpParPhiY"), invMass, candidate.pt(), candidate.impactParameterXY(), candidate.phi(), yCand); } } else if constexpr (channel == Channel::DzeroToKPi) { if (candidate.isSelD0()) { // D0 -> Kpi + if constexpr (doMc) { + if (fillOnlySignal) { + if (std::abs(candidate.flagMcMatchRec()) != o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + return; + } + } + } invMass = hfHelper.invMassD0ToPiK(candidate); + yCand = hfHelper.yD0(candidate); if constexpr (withMl) { for (auto iScore{0u}; iScore < candidate.mlProbD0().size(); ++iScore) { outputMl[iScore] = candidate.mlProbD0()[iScore]; } - registry.fill(HIST("hMassPtImpPar"), invMass, candidate.pt(), candidate.impactParameterXY(), outputMl[0], outputMl[1], outputMl[2]); + registry.fill(HIST("hMassPtImpParPhiY"), invMass, candidate.pt(), candidate.impactParameterXY(), candidate.phi(), yCand, outputMl[0], outputMl[1], outputMl[2]); } else { - registry.fill(HIST("hMassPtImpPar"), invMass, candidate.pt(), candidate.impactParameterXY()); + registry.fill(HIST("hMassPtImpParPhiY"), invMass, candidate.pt(), candidate.impactParameterXY(), candidate.phi(), yCand); } } if (candidate.isSelD0bar()) { invMass = hfHelper.invMassD0barToKPi(candidate); + yCand = hfHelper.yD0(candidate); if constexpr (withMl) { for (auto iScore{0u}; iScore < candidate.mlProbD0bar().size(); ++iScore) { outputMl[iScore] = candidate.mlProbD0bar()[iScore]; } - registry.fill(HIST("hMassPtImpPar"), invMass, candidate.pt(), candidate.impactParameterXY(), outputMl[0], outputMl[1], outputMl[2]); + registry.fill(HIST("hMassPtImpParPhiY"), invMass, candidate.pt(), candidate.impactParameterXY(), candidate.phi(), yCand, outputMl[0], outputMl[1], outputMl[2]); } else { - registry.fill(HIST("hMassPtImpPar"), invMass, candidate.pt(), candidate.impactParameterXY()); + registry.fill(HIST("hMassPtImpParPhiY"), invMass, candidate.pt(), candidate.impactParameterXY(), candidate.phi(), yCand); + } + } + } + } + + // Fill the TTree with both event and candidate properties + /// \param candidate is a particle candidate + /// \param collision is the respective collision + template + void fillTree(const CCands& candidate, const CollType& collision) + { + std::vector outputMl = {-999., -999., -999.}; + float invMass{-1.f}; + float yCand{-999.f}; + std::array ptProngs = {candidate.ptProng0(), candidate.ptProng1(), -1.}; + std::array phiProngs = {RecoDecay::phi(std::array{candidate.pxProng0(), candidate.pyProng0()}), RecoDecay::phi(std::array{candidate.pxProng1(), candidate.pyProng1()}), 99.}; + std::array etaProngs = {RecoDecay::eta(std::array{candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()}), RecoDecay::eta(std::array{candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()}), 99.}; + if constexpr (channel == Channel::DplusToKPiPi) { // D+ -> Kpipi + invMass = hfHelper.invMassDplusToPiKPi(candidate); + yCand = hfHelper.yDplus(candidate); + ptProngs[2] = candidate.ptProng2(); + phiProngs[2] = RecoDecay::phi(candidate.pxProng2(), candidate.pyProng2()); + etaProngs[2] = RecoDecay::eta(std::array{candidate.pxProng2(), candidate.pyProng2(), candidate.pzProng2()}); + if constexpr (withMl) { + for (auto iScore{0u}; iScore < candidate.mlProbDplusToPiKPi().size(); ++iScore) { + outputMl[iScore] = candidate.mlProbDplusToPiKPi()[iScore]; + } + } + } else if constexpr (channel == Channel::DzeroToKPi) { + if (candidate.isSelD0()) { // D0 -> Kpi + invMass = hfHelper.invMassD0ToPiK(candidate); + yCand = hfHelper.yD0(candidate); + if constexpr (withMl) { + for (auto iScore{0u}; iScore < candidate.mlProbD0().size(); ++iScore) { + outputMl[iScore] = candidate.mlProbD0()[iScore]; + } + } + } + if (candidate.isSelD0bar()) { + invMass = hfHelper.invMassD0barToKPi(candidate); + yCand = hfHelper.yD0(candidate); + if constexpr (withMl) { + for (auto iScore{0u}; iScore < candidate.mlProbD0bar().size(); ++iScore) { + outputMl[iScore] = candidate.mlProbD0bar()[iScore]; + } } } } + float centrality = 0.; + float occupancy = 0.; + if (centEstimator != CentralityEstimator::None) { + centrality = getCentralityColl(collision, centEstimator); + } + if (occEstimator != OccupancyEstimator::None) { + occupancy = getOccupancyColl(collision, occEstimator); + } + + int8_t flagMcMatchRec = 0; + if constexpr (doMc) { + flagMcMatchRec = candidate.flagMcMatchRec(); + } + double impParZ = candidate.impactParameterXY() * (-1) * candidate.pz() / candidate.pt(); + + hfCharmCandLite( + // Event features + collision.numContrib(), + collision.posX(), + collision.posY(), + collision.posZ(), + centrality, + occupancy, + // Charm candidate features + candidate.xSecondaryVertex(), + candidate.ySecondaryVertex(), + candidate.zSecondaryVertex(), + invMass, + candidate.pt(), + yCand, + candidate.phi(), + candidate.impactParameterXY(), + impParZ, + outputMl[0], + outputMl[1], + outputMl[2], + // Daughter features + ptProngs[0], + ptProngs[1], + ptProngs[2], + phiProngs[0], + phiProngs[1], + phiProngs[2], + etaProngs[0], + etaProngs[1], + etaProngs[2], + flagMcMatchRec); } /// \param candidates are reconstructed candidates - template - void runAnalysis(const CCands& candidates) + template + void runAnalysis(const CCands& candidates, CollisionsCent const&) { for (auto const& candidate : candidates) { - fillSparse(candidate); + auto collision = candidate.template collision_as(); + fillSparse(candidate); + if (fillLightTreeCandidate) { + fillTree(candidate, collision); + } } } // process functions - void processDplus(CandDplusData const& candidates) + void processDataDplus(CandDplusData const& candidates, CollisionsCent const& collisions) + { + runAnalysis(candidates, collisions); + } + PROCESS_SWITCH(HfTaskCharmHadImpactPar, processDataDplus, "Process Data D+ w/o ML", false); + + void processDataDplusWithMl(CandDplusDataWithMl const& candidates, CollisionsCent const& collisions) + { + runAnalysis(candidates, collisions); + } + PROCESS_SWITCH(HfTaskCharmHadImpactPar, processDataDplusWithMl, "Process Data D+ with ML", true); + + void processMCDplus(CandDplusMC const& candidates, CollisionsCent const& collisions) + { + runAnalysis(candidates, collisions); + } + PROCESS_SWITCH(HfTaskCharmHadImpactPar, processMCDplus, "Process MC D+ w/o ML", false); + + void processMCDplusWithMl(CandDplusMCWithMl const& candidates, CollisionsCent const& collisions) + { + runAnalysis(candidates, collisions); + } + PROCESS_SWITCH(HfTaskCharmHadImpactPar, processMCDplusWithMl, "Process MC D+ with ML", false); + + void processDataDzero(CandDzeroData const& candidates, CollisionsCent const& collisions) { - runAnalysis(candidates); + runAnalysis(candidates, collisions); } - PROCESS_SWITCH(HfTaskCharmHadImpactPar, processDplus, "Process D+ w/o ML", false); + PROCESS_SWITCH(HfTaskCharmHadImpactPar, processDataDzero, "Process Data D0 w/o ML", false); - void processDplusWithMl(CandDplusDataWithMl const& candidates) + void processDataDzeroWithMl(CandDzeroDataWithMl const& candidates, CollisionsCent const& collisions) { - runAnalysis(candidates); + runAnalysis(candidates, collisions); } - PROCESS_SWITCH(HfTaskCharmHadImpactPar, processDplusWithMl, "Process D+ with ML", true); + PROCESS_SWITCH(HfTaskCharmHadImpactPar, processDataDzeroWithMl, "Process Data D0 with ML", false); - void processDzero(CandDzeroData const& candidates) + void processMCDzero(CandDzeroMc const& candidates, CollisionsCent const& collisions) { - runAnalysis(candidates); + runAnalysis(candidates, collisions); } - PROCESS_SWITCH(HfTaskCharmHadImpactPar, processDzero, "Process D0 w/o ML", false); + PROCESS_SWITCH(HfTaskCharmHadImpactPar, processMCDzero, "Process MC D0 w/o ML", false); - void processDzeroWithMl(CandDzeroDataWithMl const& candidates) + void processMCDzeroWithMl(CandDzeroMcWithMl const& candidates, CollisionsCent const& collisions) { - runAnalysis(candidates); + runAnalysis(candidates, collisions); } - PROCESS_SWITCH(HfTaskCharmHadImpactPar, processDzeroWithMl, "Process D0 with ML", false); + PROCESS_SWITCH(HfTaskCharmHadImpactPar, processMCDzeroWithMl, "Process MC D0 with ML", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/Tasks/taskLcCentrality.cxx b/PWGHF/Tasks/taskLcCentrality.cxx index aafdb93b8fe..d866224d752 100644 --- a/PWGHF/Tasks/taskLcCentrality.cxx +++ b/PWGHF/Tasks/taskLcCentrality.cxx @@ -16,16 +16,28 @@ /// \author Luigi Dello Stritto , University and INFN SALERNO /// \author Vít Kučera , CERN -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" - -#include "Common/DataModel/Centrality.h" - +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + using namespace o2; using namespace o2::analysis; using namespace o2::framework; @@ -37,7 +49,7 @@ void customize(std::vector& workflowOptions) workflowOptions.push_back(optionDoMC); } -#include "Framework/runDataProcessing.h" +#include /// Λc± → p± K∓ π± analysis task struct HfTaskLcCentrality { @@ -160,7 +172,7 @@ struct HfTaskLcCentralityMc { if (yCandMax >= 0. && std::abs(hfHelper.yLc(candidate)) > yCandMax) { continue; } - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(candidate.flagMcMatchRec()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { // Get the corresponding MC particle. auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong0_as().mcParticle_as>(), o2::constants::physics::Pdg::kLambdaCPlus, true); auto particleMother = mcParticles.rawIteratorAt(indexMother); @@ -182,7 +194,7 @@ struct HfTaskLcCentralityMc { } // MC gen. for (const auto& particle : mcParticles) { - if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(particle.flagMcMatchGen()) == hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { if (yCandMax >= 0. && std::abs(RecoDecay::y(particle.pVector(), o2::constants::physics::MassLambdaCPlus)) > yCandMax) { continue; } diff --git a/PWGHF/Tasks/taskMcEfficiency.cxx b/PWGHF/Tasks/taskMcEfficiency.cxx index abdbfcd2d59..6d58957c664 100644 --- a/PWGHF/Tasks/taskMcEfficiency.cxx +++ b/PWGHF/Tasks/taskMcEfficiency.cxx @@ -14,18 +14,41 @@ /// /// \author Jan Fiete Grosse-Oetringhaus, CERN -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "Common/Core/RecoDecay.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "PWGHF/Core/HfHelper.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::analysis; @@ -293,7 +316,7 @@ struct HfTaskMcEfficiency { duplicates[hash]++; } /// end loop on pdg codes - } /// end loop over candidates + } /// end loop over candidates auto hDuplicateCount = registry.get(HIST("hDuplicateCount")); for (const auto& i : duplicates) { @@ -381,9 +404,9 @@ struct HfTaskMcEfficiency { /// put two 32-bit indices in a 64-bit integer int64_t hash = 0; if (candidate.prong0Id() < candidate.prong1Id()) { - hash = ((int64_t)candidate.prong0Id() << 32) | candidate.prong1Id(); + hash = (static_cast(candidate.prong0Id()) << 32) | candidate.prong1Id(); } else { - hash = ((int64_t)candidate.prong1Id() << 32) | candidate.prong0Id(); + hash = (static_cast(candidate.prong1Id()) << 32) | candidate.prong0Id(); } if (duplicates.find(hash) != duplicates.end()) { hCandidates->Fill(kHFStepTrackedDuplicates, pt, mass, pdgCode, cpa, collisionMatched, origin); @@ -680,7 +703,7 @@ struct HfTaskMcEfficiency { } /// end "if(selected[...])" } /// end loop over MC particles - } /// end loop over PDG codes + } /// end loop over PDG codes } /// end candidate3ProngMcLoop diff --git a/PWGHF/Tasks/taskMcEfficiencyToXiPi.cxx b/PWGHF/Tasks/taskMcEfficiencyToXiPi.cxx index ffb34743fff..0550bd5e726 100644 --- a/PWGHF/Tasks/taskMcEfficiencyToXiPi.cxx +++ b/PWGHF/Tasks/taskMcEfficiencyToXiPi.cxx @@ -14,21 +14,31 @@ /// /// \author Federica Zanone, Heidelberg University -#include "TMCProcess.h" // for VMC Particle Production Process - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include // for VMC Particle Production Process +#include + +#include using namespace o2; -using namespace o2::analysis; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; @@ -44,9 +54,6 @@ struct HfTaskMcEfficiencyToXiPi { Configurable nClustersTpcMin{"nClustersTpcMin", 70, "Minimum number of TPC clusters requirement for pion <-- charm baryon"}; Configurable nClustersItsMin{"nClustersItsMin", 3, "Minimum number of ITS clusters requirement for pion <- charm baryon"}; - ConfigurableAxis axisPt{"axisPt", {200, 0, 20}, "pT axis"}; - ConfigurableAxis axisMass{"axisMass", {900, 2.1, 3}, "m_inv axis"}; - enum HFStep { kHFStepMC = 0, // all generated mothers kHFStepMcInRapidity, // MC mother in rapidity |y| < rapidityCharmBaryonMax=0.5 kHFStepAcceptance, // MC mother where all final state candidates pass eta and pt selection @@ -72,6 +79,9 @@ struct HfTaskMcEfficiencyToXiPi { using ParticleInfoOmegac0 = soa::Join; using BCsInfo = soa::Join; + ConfigurableAxis axisPt{"axisPt", {200, 0, 20}, "pT axis"}; + ConfigurableAxis axisMass{"axisMass", {900, 2.1, 3}, "m_inv axis"}; + HistogramRegistry registry{"registry"}; void init(InitContext&) @@ -139,11 +149,11 @@ struct HfTaskMcEfficiencyToXiPi { pt = RecoDecay::sqrtSumOfSquares(candidate.pxCharmBaryon(), candidate.pyCharmBaryon()); // all candidates (candidateCreator) - hCandidates->Fill(kHFStepTracked, pt, mass, candidate.collisionMatched(), candidate.originRec()); + hCandidates->Fill(kHFStepTracked, pt, mass, candidate.collisionMatched(), candidate.originMcRec()); // check xi-pi candidate passed candidate selector cuts (except PID) if (candidate.resultSelections() && candidate.statusInvMassLambda() && candidate.statusInvMassCascade() && candidate.statusInvMassCharmBaryon()) { - hCandidates->Fill(kHFStepTrackedCuts, pt, mass, candidate.collisionMatched(), candidate.originRec()); + hCandidates->Fill(kHFStepTrackedCuts, pt, mass, candidate.collisionMatched(), candidate.originMcRec()); selectedKine = true; } if (!selectedKine) { @@ -152,7 +162,7 @@ struct HfTaskMcEfficiencyToXiPi { // check xi-pi candidate passed candidate selector cuts (PID included) if (candidate.statusPidCharmBaryon()) { - hCandidates->Fill(kHFStepTrackedSelected, pt, mass, candidate.collisionMatched(), candidate.originRec()); + hCandidates->Fill(kHFStepTrackedSelected, pt, mass, candidate.collisionMatched(), candidate.originMcRec()); selectedPid = true; } if (!selectedPid) { @@ -221,17 +231,17 @@ struct HfTaskMcEfficiencyToXiPi { } // all candidates - hCandidates->Fill(kHFStepMC, mcParticle.pt(), mass, true, mcParticle.originGen()); // set matchedCollision to true by default at gen level + hCandidates->Fill(kHFStepMC, mcParticle.pt(), mass, true, mcParticle.originMcGen()); // set matchedCollision to true by default at gen level // candidates with charm baryon within eta range if (std::abs(mcParticle.y()) < rapidityCharmBaryonMax) { - hCandidates->Fill(kHFStepMcInRapidity, mcParticle.pt(), mass, true, mcParticle.originGen()); + hCandidates->Fill(kHFStepMcInRapidity, mcParticle.pt(), mass, true, mcParticle.originMcGen()); } // exclude cases with undesired decays int cascId = -999; int pionId = -999; - for (auto& dauCharm : mcParticle.template daughters_as()) { + for (auto const& dauCharm : mcParticle.template daughters_as()) { if (std::abs(dauCharm.pdgCode()) == kXiMinus && (dauCharm.getProcess() == TMCProcess::kPDecay || dauCharm.getProcess() == TMCProcess::kPPrimary)) { cascId = dauCharm.globalIndex(); } else if (std::abs(dauCharm.pdgCode()) == kPiPlus && (dauCharm.getProcess() == TMCProcess::kPDecay || dauCharm.getProcess() == TMCProcess::kPPrimary)) { @@ -254,7 +264,7 @@ struct HfTaskMcEfficiencyToXiPi { // first create cascade daughters objects int lambdaId = -999; int pionFromCascadeId = -999; - for (auto& dauCasc : cascade.template daughters_as()) { + for (auto const& dauCasc : cascade.template daughters_as()) { if (std::abs(dauCasc.pdgCode()) == kLambda0 && dauCasc.getProcess() == TMCProcess::kPDecay) { lambdaId = dauCasc.globalIndex(); } else if (std::abs(dauCasc.pdgCode()) == kPiPlus && dauCasc.getProcess() == TMCProcess::kPDecay) { @@ -270,7 +280,7 @@ struct HfTaskMcEfficiencyToXiPi { // then create lambda daughters objects int protonId = -999; int pionFromLambdaId = -999; - for (auto& dauV0 : lambda.template daughters_as()) { + for (auto const& dauV0 : lambda.template daughters_as()) { if (std::abs(dauV0.pdgCode()) == kProton && dauV0.getProcess() == TMCProcess::kPDecay) { protonId = dauV0.globalIndex(); } else if (std::abs(dauV0.pdgCode()) == kPiPlus && dauV0.getProcess() == TMCProcess::kPDecay) { @@ -292,14 +302,14 @@ struct HfTaskMcEfficiencyToXiPi { } // final state candidates pass eta and pt selection if (inAcceptance) { - hCandidates->Fill(kHFStepAcceptance, mcParticle.pt(), mass, true, mcParticle.originGen()); + hCandidates->Fill(kHFStepAcceptance, mcParticle.pt(), mass, true, mcParticle.originMcGen()); } if (tracked[pionId] && tracked[pionFromCascadeId] && tracked[pionFromLambdaId] && tracked[protonId]) { // final state candidates have a mc particleID != 0 - hCandidates->Fill(kHFStepTrackable, mcParticle.pt(), mass, true, mcParticle.originGen()); + hCandidates->Fill(kHFStepTrackable, mcParticle.pt(), mass, true, mcParticle.originMcGen()); if (inAcceptance) { - hCandidates->Fill(kHFStepAcceptanceTrackable, mcParticle.pt(), mass, true, mcParticle.originGen()); + hCandidates->Fill(kHFStepAcceptanceTrackable, mcParticle.pt(), mass, true, mcParticle.originMcGen()); } else { LOGP(debug, "Candidate {} not in acceptance but tracked.", mcParticle.globalIndex()); LOGP(debug, "MC cascade: pt={} eta={}", cascade.pt(), cascade.eta()); @@ -355,20 +365,20 @@ struct HfTaskMcEfficiencyToXiPi { // with pion track cuts (see checkTrackGlbTrk and checkTrkItsTrk) if (selectedIts[pionId]) { - hCandidates->Fill(kHFStepItsTrackableCuts, mcParticle.pt(), mass, true, mcParticle.originGen()); + hCandidates->Fill(kHFStepItsTrackableCuts, mcParticle.pt(), mass, true, mcParticle.originMcGen()); if (!inAcceptance) { LOGP(debug, "Candidate {} has daughters not in acceptance but pion <-- charm tracked and selected (its only)", mcParticle.globalIndex()); } } if (selectedItsTpc[pionId]) { - hCandidates->Fill(kHFStepItsTpcTrackableCuts, mcParticle.pt(), mass, true, mcParticle.originGen()); + hCandidates->Fill(kHFStepItsTpcTrackableCuts, mcParticle.pt(), mass, true, mcParticle.originMcGen()); if (!inAcceptance) { LOGP(debug, "Candidate {} has daughters not in acceptance but pion <-- charm tracked and selected (its & tpc)", mcParticle.globalIndex()); } } } // close loop mcParticles - } // close candidateMcLoop + } // close candidateMcLoop // process functions void processXic0(Xic0CandidateInfo const& candidates, diff --git a/PWGHF/Tasks/taskMcGenPtRapShapes.cxx b/PWGHF/Tasks/taskMcGenPtRapShapes.cxx index 23f66a0b8ee..01c795d0461 100644 --- a/PWGHF/Tasks/taskMcGenPtRapShapes.cxx +++ b/PWGHF/Tasks/taskMcGenPtRapShapes.cxx @@ -14,14 +14,26 @@ /// \author Fabrizio Grosa , CERN -#include - #include "Common/Core/RecoDecay.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; diff --git a/PWGHF/Tasks/taskMcValidation.cxx b/PWGHF/Tasks/taskMcValidation.cxx index 38666bcba6a..97b57f150bc 100644 --- a/PWGHF/Tasks/taskMcValidation.cxx +++ b/PWGHF/Tasks/taskMcValidation.cxx @@ -18,27 +18,56 @@ /// \author Fabrizio Grosa , CERN /// \author Fabio Catalano , CERN -#include -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/StaticFor.h" - -#include "CCDB/BasicCCDBManager.h" -#include "Common/DataModel/CollisionAssociationTables.h" - #include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; -using namespace o2::analysis; using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; @@ -59,6 +88,7 @@ enum DecayChannels { DzeroToKPi = 0, D10ToDStarPi, D2Star0ToDPlusPi, B0ToDminusPi, + BplusToD0Pi, LcToPKPi, LcToPiK0s, XiCplusToPKPi, @@ -70,31 +100,31 @@ enum DecayChannels { DzeroToKPi = 0, }; // always keep nChannels at the end static constexpr int nCharmMesonChannels = 10; // number of charm meson channels -static constexpr int nBeautyChannels = 1; // number of beauty hadron channels +static constexpr int nBeautyChannels = 2; // number of beauty hadron channels static constexpr int nCharmBaryonChannels = nChannels - nCharmMesonChannels - nBeautyChannels; // number of charm baryon channels static constexpr int nOriginTypes = 2; // number of origin types (prompt, non-prompt; only for charm hadrons) static constexpr std::array PDGArrayParticle = {o2::constants::physics::Pdg::kD0, o2::constants::physics::Pdg::kDStar, o2::constants::physics::Pdg::kDPlus, o2::constants::physics::Pdg::kDPlus, o2::constants::physics::Pdg::kDS, o2::constants::physics::Pdg::kDS, o2::constants::physics::Pdg::kDS1, o2::constants::physics::Pdg::kDS2Star, - o2::constants::physics::Pdg::kD10, o2::constants::physics::Pdg::kD2Star0, o2::constants::physics::Pdg::kB0, o2::constants::physics::Pdg::kLambdaCPlus, + o2::constants::physics::Pdg::kD10, o2::constants::physics::Pdg::kD2Star0, o2::constants::physics::Pdg::kB0, o2::constants::physics::Pdg::kBPlus, o2::constants::physics::Pdg::kLambdaCPlus, o2::constants::physics::Pdg::kLambdaCPlus, o2::constants::physics::Pdg::kXiCPlus, o2::constants::physics::Pdg::kXiCPlus, o2::constants::physics::Pdg::kXiC0, o2::constants::physics::Pdg::kOmegaC0, o2::constants::physics::Pdg::kOmegaC0}; -static constexpr std::array nDaughters = {2, 3, 3, 3, 3, 3, 5, 5, 4, 4, 4, 3, 3, 3, 5, 4, 4, 4}; -static constexpr std::array maxDepthForSearch = {1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 3, 2, 4, 3, 3, 3}; +static constexpr std::array nDaughters = {2, 3, 3, 3, 3, 3, 5, 5, 4, 4, 4, 3, 3, 3, 3, 5, 4, 4, 4}; +static constexpr std::array maxDepthForSearch = {1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 3, 2, 4, 3, 3, 3}; // keep coherent indexing with PDGArrayParticle // FIXME: look for a better solution static constexpr std::array, nChannels> arrPDGFinal2Prong = {{{+kPiPlus, -kKPlus}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}}; -static constexpr std::array, nChannels> arrPDGFinal3Prong = {{{}, {+kPiPlus, -kKPlus, +kPiPlus}, {+kPiPlus, -kKPlus, +kPiPlus}, {+kKPlus, -kKPlus, +kPiPlus}, {+kKPlus, -kKPlus, +kPiPlus}, {+kKPlus, -kKPlus, +kPiPlus}, {}, {}, {}, {}, {}, {+kProton, -kKPlus, +kPiPlus}, {+kProton, -kPiPlus, +kPiPlus}, {+kProton, -kKPlus, +kPiPlus}, {}, {}, {}, {}}}; -static constexpr std::array, nChannels> arrPDGFinal4Prong = {{{}, {}, {}, {}, {}, {}, {}, {}, {+kPiPlus, -kKPlus, +kPiPlus, -kPiPlus}, {+kPiPlus, -kKPlus, +kPiPlus, -kPiPlus}, {-kPiPlus, +kKPlus, -kPiPlus, +kPiPlus}, {}, {}, {}, {}, {+kPiPlus, -kPiPlus, -kPiPlus, +kProton}, {+kPiPlus, -kKPlus, -kPiPlus, +kProton}, {+kPiPlus, -kPiPlus, -kPiPlus, +kProton}}}; -static constexpr std::array, nChannels> arrPDGFinal5Prong = {{{}, {}, {}, {}, {}, {}, {+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}, {+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}, {}, {}, {}, {}, {}, {}, {+kPiPlus, +kPiPlus, -kPiPlus, -kPiPlus, +kProton}, {}, {}, {}}}; +static constexpr std::array, nChannels> arrPDGFinal3Prong = {{{}, {+kPiPlus, -kKPlus, +kPiPlus}, {+kPiPlus, -kKPlus, +kPiPlus}, {+kKPlus, -kKPlus, +kPiPlus}, {+kKPlus, -kKPlus, +kPiPlus}, {+kKPlus, -kKPlus, +kPiPlus}, {}, {}, {}, {}, {}, {-kPiPlus, +kKPlus, +kPiPlus}, {+kProton, -kKPlus, +kPiPlus}, {+kProton, -kPiPlus, +kPiPlus}, {+kProton, -kKPlus, +kPiPlus}, {}, {}, {}, {}}}; +static constexpr std::array, nChannels> arrPDGFinal4Prong = {{{}, {}, {}, {}, {}, {}, {}, {}, {+kPiPlus, -kKPlus, +kPiPlus, -kPiPlus}, {+kPiPlus, -kKPlus, +kPiPlus, -kPiPlus}, {-kPiPlus, +kKPlus, -kPiPlus, +kPiPlus}, {}, {}, {}, {}, {}, {+kPiPlus, -kPiPlus, -kPiPlus, +kProton}, {+kPiPlus, -kKPlus, -kPiPlus, +kProton}, {+kPiPlus, -kPiPlus, -kPiPlus, +kProton}}}; +static constexpr std::array, nChannels> arrPDGFinal5Prong = {{{}, {}, {}, {}, {}, {}, {+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}, {+kPiPlus, -kKPlus, +kPiPlus, +kPiPlus, -kPiPlus}, {}, {}, {}, {}, {}, {}, {}, {+kPiPlus, +kPiPlus, -kPiPlus, -kPiPlus, +kProton}, {}, {}, {}}}; static constexpr std::string_view labels[nChannels] = {"D^{0} #rightarrow K#pi", "D*^{+} #rightarrow D^{0}#pi", "D^{+} #rightarrow K#pi#pi", "D^{+} #rightarrow KK#pi", "D_{s}^{+} #rightarrow #Phi#pi #rightarrow KK#pi", "D_{s}^{+} #rightarrow #bar{K}^{*0}K #rightarrow KK#pi", "D_{s}1 #rightarrow D*^{+}K^{0}_{s}", "D_{s}2* #rightarrow D^{+}K^{0}_{s}", "D1^{0} #rightarrow D*^{+}#pi", "D2^{*} #rightarrow D^{+}#pi", - "B^{0} #rightarrow D^{-}#pi", + "B^{0} #rightarrow D^{-}#pi", "B^{+} #rightarrow D^{0}#pi", "#Lambda_{c}^{+} #rightarrow pK#pi", "#Lambda_{c}^{+} #rightarrow pK^{0}_{s}", "#Xi_{c}^{+} #rightarrow pK#pi", "#Xi_{c}^{+} #rightarrow #Xi#pi#pi", "#Xi_{c}^{0} #rightarrow #Xi#pi", "#Omega_{c}^{0} #rightarrow #Omega#pi", "#Omega_{c}^{0} #rightarrow #Xi#pi"}; -static constexpr std::string_view particleNames[nChannels] = {"DzeroToKPi", "DstarToDzeroPi", "DplusToPiKPi", "DplusToPhiPiToKKPi", "DsToPhiPiToKKPi", "DsToK0starKToKKPi", "Ds1ToDStarK0s", "Ds2StarToDPlusK0s", "D10ToDStarPi", "D2Star0ToDPlusPi", "B0ToDminusPi", +static constexpr std::string_view particleNames[nChannels] = {"DzeroToKPi", "DstarToDzeroPi", "DplusToPiKPi", "DplusToPhiPiToKKPi", "DsToPhiPiToKKPi", "DsToK0starKToKKPi", "Ds1ToDStarK0s", "Ds2StarToDPlusK0s", "D10ToDStarPi", "D2Star0ToDPlusPi", "B0ToDminusPi", "BplusToD0Pi", "LcToPKPi", "LcToPiK0s", "XiCplusToPKPi", "XiCplusToXiPiPi", "XiCzeroToXiPi", "OmegaCToOmegaPi", "OmegaCToXiPi"}; static constexpr std::string_view originNames[nOriginTypes] = {"Prompt", "NonPrompt"}; } // namespace @@ -257,7 +287,7 @@ struct HfTaskMcValidationGen { if (storeOccupancy) { occupancy = getOccupancyGenColl(recoCollisions, OccupancyEstimator::Its); } - uint16_t rejectionMask{0}; + uint32_t rejectionMask{0u}; if constexpr (centEstimator == CentralityEstimator::FT0C) { rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, recoCollisions, centrality); } else if constexpr (centEstimator == CentralityEstimator::FT0M) { @@ -351,6 +381,10 @@ struct HfTaskMcValidationGen { !RecoDecay::isMatchedMCGen(mcParticles, particle, -PDGArrayParticle[iD], std::array{+kK0Short, -kProton}, false, nullptr, 2)) { continue; } + if (iD == BplusToD0Pi && + !RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], std::array{-o2::constants::physics::Pdg::kD0, +kPiPlus}, true)) { + continue; + } } if (nDaughters[iD] == 4) { @@ -1064,7 +1098,7 @@ struct HfTaskMcValidationRec { continue; } int whichHad = -1; - if (isD0Sel && TESTBIT(std::abs(cand2Prong.flagMcMatchRec()), hf_cand_2prong::DecayType::D0ToPiK)) { + if (isD0Sel && std::abs(cand2Prong.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { whichHad = DzeroToKPi; } int whichOrigin; @@ -1098,21 +1132,21 @@ struct HfTaskMcValidationRec { continue; } int whichHad = -1; - if (isDPlusSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::DplusToPiKPi)) { + if (isDPlusSel && std::abs(cand3Prong.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { whichHad = DplusToPiKPi; - } else if (isDsSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::DsToKKPi)) { - if (cand3Prong.flagMcDecayChanRec() == hf_cand_3prong::DecayChannelDToKKPi::DsToPhiPi) { + } else if (isDsSel && std::abs(cand3Prong.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DsToPiKK) { + if (cand3Prong.flagMcDecayChanRec() == o2::hf_decay::hf_cand_3prong::DecayChannelResonant::DsToPhiPi) { whichHad = DsToPhiPiToKKPi; } - if (cand3Prong.flagMcDecayChanRec() == hf_cand_3prong::DecayChannelDToKKPi::DsToK0starK) { + if (cand3Prong.flagMcDecayChanRec() == o2::hf_decay::hf_cand_3prong::DecayChannelResonant::DsToKstar0K) { whichHad = DsToK0starKToKKPi; } - if (cand3Prong.flagMcDecayChanRec() == hf_cand_3prong::DecayChannelDToKKPi::DplusToPhiPi) { + if (cand3Prong.flagMcDecayChanRec() == o2::hf_decay::hf_cand_3prong::DecayChannelResonant::DplusToPhiPi) { whichHad = DplusToPhiPiToKKPi; } - } else if (isLcSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::LcToPKPi)) { + } else if (isLcSel && std::abs(cand3Prong.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { whichHad = LcToPKPi; - } else if (isXicSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::XicToPKPi)) { + } else if (isXicSel && std::abs(cand3Prong.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::XicToPKPi) { whichHad = XiCplusToPKPi; } int whichOrigin; diff --git a/PWGHF/Tasks/taskMultiplicityEstimatorCorrelation.cxx b/PWGHF/Tasks/taskMultiplicityEstimatorCorrelation.cxx index a7e0515eb2f..3e8537a47d1 100644 --- a/PWGHF/Tasks/taskMultiplicityEstimatorCorrelation.cxx +++ b/PWGHF/Tasks/taskMultiplicityEstimatorCorrelation.cxx @@ -14,16 +14,28 @@ /// /// \author Fabrizio Chinu , Università and INFN Torino +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include #include +#include #include -#include - -#include "TPDGCode.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Framework/StaticFor.h" -#include "Common/DataModel/Multiplicity.h" using namespace o2; using namespace o2::framework; diff --git a/PWGHF/Tasks/taskPidStudies.cxx b/PWGHF/Tasks/taskPidStudies.cxx index ca9947202d0..805266b76a9 100644 --- a/PWGHF/Tasks/taskPidStudies.cxx +++ b/PWGHF/Tasks/taskPidStudies.cxx @@ -17,31 +17,61 @@ /// \author Marcello Di Costanzo , Politecnico and INFN Torino /// \author Luca Aglietta , Università and INFN Torino -#include "TPDGCode.h" - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/CCDB/ctpRateFetcher.h" #include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_evsel; +using namespace o2::hf_centrality; -namespace o2::aod -{ -namespace pid_studies -{ enum Particle { NotMatched = 0, K0s, Lambda, Omega }; + +enum TrackCuts { All = 0, + HasIts, + HasTpc, + TpcNClsCrossedRows, + Eta, + Pt, + TpcChi2NCls, + ItsChi2NCls, + NCuts }; + +namespace o2::aod +{ +namespace pid_studies +{ // V0s DECLARE_SOA_COLUMN(MassK0, massK0, float); //! Candidate mass DECLARE_SOA_COLUMN(MassLambda, massLambda, float); //! Candidate mass @@ -78,11 +108,12 @@ DECLARE_SOA_COLUMN(NSigmaTpcBachKa, nSigmaTpcBachKa, float); //! nSigmaTPC of ba DECLARE_SOA_COLUMN(NSigmaTofBachKa, nSigmaTofBachKa, float); //! nSigmaTOF of bachelor with kaon hypothesis // Common columns -DECLARE_SOA_COLUMN(OccupancyFt0c, occupancyFt0c, float); //! Occupancy from FT0C -DECLARE_SOA_COLUMN(OccupancyIts, occupancyIts, float); //! Occupancy from ITS -DECLARE_SOA_COLUMN(CentralityFT0C, centralityFT0C, float); //! Centrality from FT0C -DECLARE_SOA_COLUMN(CentralityFT0M, centralityFT0M, float); //! Centrality from FT0M -DECLARE_SOA_COLUMN(CandFlag, candFlag, int); //! Flag for MC matching +DECLARE_SOA_COLUMN(OccupancyFt0c, occupancyFt0c, float); //! Occupancy from FT0C +DECLARE_SOA_COLUMN(OccupancyIts, occupancyIts, float); //! Occupancy from ITS +DECLARE_SOA_COLUMN(CentralityFT0C, centralityFT0C, float); //! Centrality from FT0C +DECLARE_SOA_COLUMN(CentralityFT0M, centralityFT0M, float); //! Centrality from FT0M +DECLARE_SOA_COLUMN(InteractionRate, interactionRate, double); //! Centrality from FT0M +DECLARE_SOA_COLUMN(CandFlag, candFlag, int); //! Flag for MC matching } // namespace pid_studies DECLARE_SOA_TABLE(PidV0s, "AOD", "PIDV0S", //! Table with PID information @@ -112,6 +143,7 @@ DECLARE_SOA_TABLE(PidV0s, "AOD", "PIDV0S", //! Table with PID information pid_studies::OccupancyIts, pid_studies::CentralityFT0C, pid_studies::CentralityFT0M, + pid_studies::InteractionRate, pid_studies::CandFlag); DECLARE_SOA_TABLE(PidCascades, "AOD", "PIDCASCADES", //! Table with PID information @@ -132,6 +164,7 @@ DECLARE_SOA_TABLE(PidCascades, "AOD", "PIDCASCADES", //! Table with PID informat pid_studies::OccupancyIts, pid_studies::CentralityFT0C, pid_studies::CentralityFT0M, + pid_studies::InteractionRate, pid_studies::CandFlag); } // namespace o2::aod @@ -139,12 +172,21 @@ struct HfTaskPidStudies { Produces pidV0; Produces pidCascade; + Configurable applyEvSels{"applyEvSels", true, "Apply event selections"}; + Configurable applyTrackSels{"applyTrackSels", true, "Apply track selections"}; + Configurable tpcNClsCrossedRowsTrackMin{"tpcNClsCrossedRowsTrackMin", 70, "Minimum number of crossed rows in TPC"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "Maximum pseudorapidity"}; + Configurable ptTrackMin{"ptTrackMin", 0.1, "Minimum transverse momentum"}; + Configurable tpcChi2NClTrackMax{"tpcChi2NClTrackMax", 4, "Maximum TPC chi2 per number of TPC clusters"}; + Configurable itsChi2NClTrackMax{"itsChi2NClTrackMax", 36, "Maximum ITS chi2 per number of ITS clusters"}; Configurable massK0Min{"massK0Min", 0.4, "Minimum mass for K0"}; Configurable massK0Max{"massK0Max", 0.6, "Maximum mass for K0"}; Configurable massLambdaMin{"massLambdaMin", 1.0, "Minimum mass for lambda"}; Configurable massLambdaMax{"massLambdaMax", 1.3, "Maximum mass for lambda"}; Configurable massOmegaMin{"massOmegaMin", 1.5, "Minimum mass for omega"}; Configurable massOmegaMax{"massOmegaMax", 1.8, "Maximum mass for omega"}; + Configurable interactionRateMin{"interactionRateMin", -1, "Minimum interaction rate (kHz)"}; + Configurable interactionRateMax{"interactionRateMax", 1.e20, "Maximum interaction rate (kHz)"}; Configurable radiusMax{"radiusMax", 2.3, "Maximum decay radius (cm)"}; Configurable cosPaMin{"cosPaMin", 0.98, "Minimum cosine of pointing angle"}; Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 0.2, "Maximum DCA among the V0 daughters (cm)"}; @@ -154,22 +196,49 @@ struct HfTaskPidStudies { Configurable qtArmenterosMaxForLambda{"qtArmenterosMaxForLambda", 0.12, "Minimum Armenteros' qt for (anti)Lambda"}; Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of candidates to keep"}; Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + Configurable ctpFetcherSource{"ctpFetcherSource", "T0VTX", "Source for CTP rate fetching, e.g. T0VTX, T0CE, T0SC, ZNC (hadronic)"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; using PidTracks = soa::Join; using CollSels = soa::Join; + using CollisionsMc = soa::Join; using V0sMcRec = soa::Join; using CascsMcRec = soa::Join; + ctpRateFetcher rateFetcher; + HfEventSelection hfEvSel; + HfEventSelectionMc hfEvSelMc; + double interactionRate{-1.}; + + o2::framework::Service ccdb; + HistogramRegistry registry{"registry", {}}; + void init(InitContext&) { if ((doprocessV0Mc && doprocessV0Data) || (doprocessCascMc && doprocessCascData)) { LOGP(fatal, "Both data and MC process functions were enabled! Please check your configuration!"); } + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + hfEvSel.addHistograms(registry); + + std::shared_ptr hTrackSel = registry.add("hTrackSel", "Track selection;;Counts", {HistType::kTH1F, {{TrackCuts::NCuts, 0, TrackCuts::NCuts}}}); + + // Set Labels for hTrackSel + hTrackSel->GetXaxis()->SetBinLabel(TrackCuts::All + 1, "All"); + hTrackSel->GetXaxis()->SetBinLabel(TrackCuts::HasIts + 1, "HasITS"); + hTrackSel->GetXaxis()->SetBinLabel(TrackCuts::HasTpc + 1, "HasTPC"); + hTrackSel->GetXaxis()->SetBinLabel(TrackCuts::TpcNClsCrossedRows + 1, "TPC NCls/CrossedRows"); + hTrackSel->GetXaxis()->SetBinLabel(TrackCuts::Eta + 1, "#eta"); + hTrackSel->GetXaxis()->SetBinLabel(TrackCuts::Pt + 1, "#it{p}_{T}"); + hTrackSel->GetXaxis()->SetBinLabel(TrackCuts::TpcChi2NCls + 1, "TPC #chi^{2}/NCls"); + hTrackSel->GetXaxis()->SetBinLabel(TrackCuts::ItsChi2NCls + 1, "ITS #chi^{2}/NCls"); } - template + template void fillTree(Cand const& candidate, const int flag) { float pseudoRndm = candidate.pt() * 1000. - static_cast(candidate.pt() * 1000); @@ -177,7 +246,7 @@ struct HfTaskPidStudies { return; } - const auto& coll = candidate.template collision_as(); + const auto& coll = candidate.template collision_as(); if constexpr (isV0) { const auto& posTrack = candidate.template posTrack_as(); const auto& negTrack = candidate.template negTrack_as(); @@ -208,6 +277,7 @@ struct HfTaskPidStudies { coll.trackOccupancyInTimeRange(), coll.centFT0C(), coll.centFT0M(), + interactionRate, flag); } else { const auto& bachTrack = candidate.template bachelor_as(); @@ -229,6 +299,7 @@ struct HfTaskPidStudies { coll.trackOccupancyInTimeRange(), coll.centFT0C(), coll.centFT0M(), + interactionRate, flag); } } @@ -238,22 +309,22 @@ struct HfTaskPidStudies { { if constexpr (std::is_same::value) { if (!cand.has_v0MCCore()) { - return aod::pid_studies::Particle::NotMatched; + return Particle::NotMatched; } auto v0MC = cand.template v0MCCore_as(); if (v0MC.pdgCode() == kK0Short && v0MC.pdgCodeNegative() == -kPiPlus && v0MC.pdgCodePositive() == kPiPlus) { - return aod::pid_studies::Particle::K0s; + return Particle::K0s; } if (v0MC.pdgCode() == kLambda0 && v0MC.pdgCodeNegative() == -kPiPlus && v0MC.pdgCodePositive() == kProton) { - return aod::pid_studies::Particle::Lambda; + return Particle::Lambda; } if (v0MC.pdgCode() == -kLambda0 && v0MC.pdgCodeNegative() == -kProton && v0MC.pdgCodePositive() == kPiPlus) { - return -aod::pid_studies::Particle::Lambda; + return -Particle::Lambda; } } if constexpr (std::is_same::value) { if (!cand.has_cascMCCore()) { - return aod::pid_studies::Particle::NotMatched; + return Particle::NotMatched; } auto cascMC = cand.template cascMCCore_as(); if (cascMC.pdgCode() == kOmegaMinus && @@ -261,17 +332,102 @@ struct HfTaskPidStudies { cascMC.pdgCodeV0() == kLambda0 && cascMC.pdgCodePositive() == kProton && cascMC.pdgCodeNegative() == -kPiPlus) { - return aod::pid_studies::Particle::Omega; + return Particle::Omega; } if (cascMC.pdgCode() == -kOmegaMinus && cascMC.pdgCodeBachelor() == kKPlus && cascMC.pdgCodeV0() == -kLambda0 && cascMC.pdgCodePositive() == kPiPlus && cascMC.pdgCodeNegative() == -kProton) { - return -aod::pid_studies::Particle::Omega; + return -Particle::Omega; + } + } + return Particle::NotMatched; + } + + template + bool isCollSelected(const Coll& coll) + { + auto bc = coll.template bc_as(); + interactionRate = rateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), ctpFetcherSource.value) * 1.e-3; // convert to kHz + if (interactionRate < interactionRateMin || interactionRate > interactionRateMax) { + return false; + } + + float cent{-1.f}; + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(coll, cent, ccdb, registry); + /// monitor the satisfied event selections + hfEvSel.fillHistograms(coll, rejectionMask, cent); + return rejectionMask == 0; + } + + template + bool isTrackSelected(const T1& candidate) + { + const auto& posTrack = candidate.template posTrack_as(); + const auto& negTrack = candidate.template negTrack_as(); + registry.fill(HIST("hTrackSel"), TrackCuts::All); + if constexpr (isV0) { + if (!posTrack.hasITS() || !negTrack.hasITS()) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::HasIts); + if (!posTrack.hasTPC() || !negTrack.hasTPC()) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::HasTpc); + if (posTrack.tpcNClsCrossedRows() < tpcNClsCrossedRowsTrackMin || negTrack.tpcNClsCrossedRows() < tpcNClsCrossedRowsTrackMin) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::TpcNClsCrossedRows); + if (std::abs(posTrack.eta()) > etaTrackMax || std::abs(negTrack.eta()) > etaTrackMax) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::Eta); + if (posTrack.pt() < ptTrackMin || negTrack.pt() < ptTrackMin) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::Pt); + if (posTrack.tpcChi2NCl() > tpcChi2NClTrackMax || negTrack.tpcChi2NCl() > tpcChi2NClTrackMax) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::TpcChi2NCls); + if (posTrack.itsChi2NCl() > itsChi2NClTrackMax || negTrack.itsChi2NCl() > itsChi2NClTrackMax) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::ItsChi2NCls); + } else { + const auto& bachTrack = candidate.template bachelor_as(); + if (!posTrack.hasITS() || !negTrack.hasITS() || !bachTrack.hasITS()) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::HasIts); + if (!posTrack.hasTPC() || !negTrack.hasTPC() || !bachTrack.hasTPC()) { + return false; } + registry.fill(HIST("hTrackSel"), TrackCuts::HasTpc); + if (posTrack.tpcNClsCrossedRows() < tpcNClsCrossedRowsTrackMin || negTrack.tpcNClsCrossedRows() < tpcNClsCrossedRowsTrackMin || bachTrack.tpcNClsCrossedRows() < tpcNClsCrossedRowsTrackMin) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::TpcNClsCrossedRows); + if (std::abs(posTrack.eta()) > etaTrackMax || std::abs(negTrack.eta()) > etaTrackMax || std::abs(bachTrack.eta()) > etaTrackMax) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::Eta); + if (posTrack.pt() < ptTrackMin || negTrack.pt() < ptTrackMin || bachTrack.pt() < ptTrackMin) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::Pt); + if (posTrack.tpcChi2NCl() > tpcChi2NClTrackMax || negTrack.tpcChi2NCl() > tpcChi2NClTrackMax || bachTrack.tpcChi2NCl() > tpcChi2NClTrackMax) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::TpcChi2NCls); + if (posTrack.itsChi2NCl() > itsChi2NClTrackMax || negTrack.itsChi2NCl() > itsChi2NClTrackMax || bachTrack.itsChi2NCl() > itsChi2NClTrackMax) { + return false; + } + registry.fill(HIST("hTrackSel"), TrackCuts::ItsChi2NCls); } - return aod::pid_studies::Particle::NotMatched; + return true; } template @@ -323,7 +479,7 @@ struct HfTaskPidStudies { return true; } - template + template bool isSelectedCascAsOmega(const CascCand& casc) { if (casc.mOmega() < massOmegaMin || casc.mOmega() > massOmegaMax) { @@ -335,7 +491,7 @@ struct HfTaskPidStudies { if (casc.cascradius() > radiusMax) { return false; } - const auto& coll = casc.template collision_as(); + const auto& coll = casc.template collision_as(); if (casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()) < cosPaMin) { return false; } @@ -351,16 +507,24 @@ struct HfTaskPidStudies { return true; } - void processV0Mc(V0sMcRec const& V0s, + void processV0Mc(CollisionsMc const& /*mcCollisions*/, + V0sMcRec const& V0s, aod::V0MCCores const&, - CollSels const&, - PidTracks const&) + aod::McParticles const& /*particlesMc*/, + PidTracks const& /*tracks*/, + aod::BCsWithTimestamps const&) { for (const auto& v0 : V0s) { + if (applyEvSels && !isCollSelected(v0.collision_as())) { + continue; + } + if (applyTrackSels && !isTrackSelected(v0)) { + continue; + } if (isSelectedV0AsK0s(v0) || isSelectedV0AsLambda(v0)) { int matched = isMatched(v0); - if (matched != aod::pid_studies::Particle::NotMatched) { - fillTree(v0, matched); + if (matched != Particle::NotMatched) { + fillTree(v0, matched); } } } @@ -368,27 +532,42 @@ struct HfTaskPidStudies { PROCESS_SWITCH(HfTaskPidStudies, processV0Mc, "Process MC", true); void processV0Data(aod::V0Datas const& V0s, - CollSels const&, - PidTracks const&) + PidTracks const&, + aod::BCsWithTimestamps const&, + CollSels const&) { for (const auto& v0 : V0s) { + if (applyEvSels && !isCollSelected(v0.collision_as())) { + continue; + } + if (applyTrackSels && !isTrackSelected(v0)) { + continue; + } if (isSelectedV0AsK0s(v0) || isSelectedV0AsLambda(v0)) { - fillTree(v0, aod::pid_studies::Particle::NotMatched); + fillTree(v0, Particle::NotMatched); } } } PROCESS_SWITCH(HfTaskPidStudies, processV0Data, "Process data", false); - void processCascMc(CascsMcRec const& cascades, + void processCascMc(CollisionsMc const& /*mcCollisions*/, + CascsMcRec const& cascades, aod::CascMCCores const&, - CollSels const&, - PidTracks const&) + aod::McParticles const& /*particlesMc*/, + PidTracks const&, + aod::BCsWithTimestamps const&) { for (const auto& casc : cascades) { - if (isSelectedCascAsOmega(casc)) { + if (applyEvSels && !isCollSelected(casc.collision_as())) { + continue; + } + if (applyTrackSels && !isTrackSelected(casc)) { + continue; + } + if (isSelectedCascAsOmega(casc)) { int matched = isMatched(casc); - if (matched != aod::pid_studies::Particle::NotMatched) { - fillTree(casc, matched); + if (matched != Particle::NotMatched) { + fillTree(casc, matched); } } } @@ -396,12 +575,19 @@ struct HfTaskPidStudies { PROCESS_SWITCH(HfTaskPidStudies, processCascMc, "Process MC", true); void processCascData(aod::CascDatas const& cascades, - CollSels const&, - PidTracks const&) + PidTracks const&, + aod::BCsWithTimestamps const&, + CollSels const&) { for (const auto& casc : cascades) { - if (isSelectedCascAsOmega(casc)) { - fillTree(casc, aod::pid_studies::Particle::NotMatched); + if (applyEvSels && !isCollSelected(casc.collision_as())) { + continue; + } + if (applyTrackSels && !isTrackSelected(casc)) { + continue; + } + if (isSelectedCascAsOmega(casc)) { + fillTree(casc, Particle::NotMatched); } } } diff --git a/PWGHF/Tasks/taskSelOptimisation.cxx b/PWGHF/Tasks/taskSelOptimisation.cxx index 128ef6ac0c8..c91f5d55819 100644 --- a/PWGHF/Tasks/taskSelOptimisation.cxx +++ b/PWGHF/Tasks/taskSelOptimisation.cxx @@ -14,12 +14,30 @@ /// /// \author Fabrizio Grosa , CERN -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - #include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -269,7 +287,7 @@ struct HfSelOptimisation { bool isPrompt = false, isNonPrompt = false, isBkg = false; for (int iDecay{0}; iDecay < n2Prong; ++iDecay) { if (TESTBIT(cand2Prong.hfflag(), iDecay)) { - if (std::abs(cand2Prong.flagMcMatchRec()) == BIT(iDecay)) { + if (std::abs(cand2Prong.flagMcMatchRec()) == BIT(iDecay)) { // FIXME: Migrate to DecayChannelMain if (cand2Prong.originMcRec() == RecoDecay::OriginType::Prompt) { isPrompt = true; switch (iDecay) { @@ -325,7 +343,7 @@ struct HfSelOptimisation { bool isPrompt = false, isNonPrompt = false, isBkg = false; for (int iDecay{0}; iDecay < n3Prong; ++iDecay) { if (TESTBIT(cand3Prong.hfflag(), iDecay)) { - if (std::abs(cand3Prong.flagMcMatchRec()) == BIT(iDecay)) { + if (std::abs(cand3Prong.flagMcMatchRec()) == BIT(iDecay)) { // FIXME: Migrate to DecayChannelMain if (cand3Prong.originMcRec() == RecoDecay::OriginType::Prompt) { isPrompt = true; switch (iDecay) { diff --git a/PWGHF/Utils/utilsAnalysis.h b/PWGHF/Utils/utilsAnalysis.h index 9148076e0ec..7a2c2f45d0a 100644 --- a/PWGHF/Utils/utilsAnalysis.h +++ b/PWGHF/Utils/utilsAnalysis.h @@ -11,17 +11,23 @@ /// \file utilsAnalysis.h /// \brief Utilities for HF analyses +/// +/// \author Vít Kučera , Inha University #ifndef PWGHF_UTILS_UTILSANALYSIS_H_ #define PWGHF_UTILS_UTILSANALYSIS_H_ +#include +#include +#include + #include // std::upper_bound -#include // std::distance -#include //std::string +#include +#include // std::distance +#include //std::string namespace o2::analysis { - enum BHadMothers { NotMatched = 0, BPlus, BZero, @@ -156,26 +162,26 @@ bool isCandidateInMassRange(const float& invMass, const double& pdgMass, const f struct HfTrigger2ProngCuts : o2::framework::ConfigurableGroup { std::string prefix = "hfTrigger2ProngCuts"; // JSON group name - static constexpr float defaultDeltaMassPars[1][2] = {{-0.0025f, 0.0001f}}; - static constexpr float defaultSigmaPars[1][2] = {{0.01424f, 0.00178f}}; + static constexpr float DefaultDeltaMassPars[1][2] = {{-0.0025f, 0.0001f}}; + static constexpr float DefaultSigmaPars[1][2] = {{0.01424f, 0.00178f}}; o2::framework::Configurable nSigmaMax{"nSigmaMax", 2, "Maximum number of sigmas for pT-differential mass cut for 2-prong candidates"}; o2::framework::Configurable ptDeltaMassMax{"ptDeltaMassMax", 10., "Max pT to apply delta mass shift to PDG mass value for 2-prong candidates"}; o2::framework::Configurable ptMassCutMax{"ptMassCutMax", 9999., "Max pT to apply pT-differential cut for 2-prong candidates"}; - o2::framework::Configurable> deltaMassPars{"deltaMassPars", {defaultDeltaMassPars[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 2-prong trigger mass cut"}; - o2::framework::Configurable> sigmaPars{"sigmaPars", {defaultSigmaPars[0], 2, {"constant", "linear"}}, "sigma parameters for HF 2-prong trigger mass cut"}; + o2::framework::Configurable> deltaMassPars{"deltaMassPars", {DefaultDeltaMassPars[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 2-prong trigger mass cut"}; + o2::framework::Configurable> sigmaPars{"sigmaPars", {DefaultSigmaPars[0], 2, {"constant", "linear"}}, "sigma parameters for HF 2-prong trigger mass cut"}; }; /// Configurable group to apply trigger specific cuts for 3-prong HF analysis struct HfTrigger3ProngCuts : o2::framework::ConfigurableGroup { std::string prefix = "hfTrigger3ProngCuts"; // JSON group name - static constexpr float defaultDeltaMassPars[1][2] = {{-0.0025f, 0.0001f}}; - static constexpr float defaultSigmaPars[1][2] = {{0.00796f, 0.00176f}}; + static constexpr float DefaultDeltaMassPars[1][2] = {{-0.0025f, 0.0001f}}; + static constexpr float DefaultSigmaPars[1][2] = {{0.00796f, 0.00176f}}; o2::framework::Configurable nSigmaMax{"nSigmaMax", 2, "Maximum number of sigmas for pT-differential mass cut for 3-prong candidates"}; o2::framework::Configurable ptDeltaMassMax{"ptDeltaMassMax", 10., "Max pT to apply delta mass shift to PDG mass value for 3-prong candidates"}; o2::framework::Configurable ptMassCutMax{"ptMassCutMax", 9999., "Max pT to apply pT-differential cut for 3-prong candidates"}; - o2::framework::Configurable> deltaMassPars{"deltaMassPars", {defaultDeltaMassPars[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 3-prong trigger mass cut"}; - o2::framework::Configurable> sigmaPars{"sigmaPars", {defaultSigmaPars[0], 2, {"constant", "linear"}}, "sigma parameters for HF 3-prong trigger mass cut"}; + o2::framework::Configurable> deltaMassPars{"deltaMassPars", {DefaultDeltaMassPars[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 3-prong trigger mass cut"}; + o2::framework::Configurable> sigmaPars{"sigmaPars", {DefaultSigmaPars[0], 2, {"constant", "linear"}}, "sigma parameters for HF 3-prong trigger mass cut"}; }; } // namespace o2::analysis diff --git a/PWGHF/Utils/utilsBfieldCCDB.h b/PWGHF/Utils/utilsBfieldCCDB.h index 8e61485ae53..8d7166eca4a 100644 --- a/PWGHF/Utils/utilsBfieldCCDB.h +++ b/PWGHF/Utils/utilsBfieldCCDB.h @@ -16,11 +16,15 @@ #ifndef PWGHF_UTILS_UTILSBFIELDCCDB_H_ #define PWGHF_UTILS_UTILSBFIELDCCDB_H_ -#include // std::string +#include +#include +#include +#include +#include +#include +#include -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" +#include // std::string /// \brief Sets up the grp object for magnetic field (w/o matCorr for propagation) /// \param bc is the bunch crossing @@ -29,7 +33,8 @@ /// \param ccdbPathGrp is the path where the GRP oject is stored /// \param lut is a pointer to the o2::base::MatLayerCylSet object /// \param isRun2 tells whether we are analysing Run2 converted data or not (different GRP object type) -void initCCDB(o2::aod::BCsWithTimestamps::iterator const& bc, int& mRunNumber, +template +void initCCDB(TBc const& bc, int& mRunNumber, o2::framework::Service const& ccdb, std::string const& ccdbPathGrp, o2::base::MatLayerCylSet* lut, bool isRun2) { diff --git a/PWGHF/Utils/utilsDerivedData.h b/PWGHF/Utils/utilsDerivedData.h index c5eb6cc3b89..044abed2f90 100644 --- a/PWGHF/Utils/utilsDerivedData.h +++ b/PWGHF/Utils/utilsDerivedData.h @@ -16,18 +16,16 @@ #ifndef PWGHF_UTILS_UTILSDERIVEDDATA_H_ #define PWGHF_UTILS_UTILSDERIVEDDATA_H_ -#include -#include - -#include "fairlogger/Logger.h" - -#include "Framework/AnalysisHelpers.h" -#include "Framework/Configurable.h" -#include "Framework/ASoA.h" - #include "Common/Core/RecoDecay.h" -#include "PWGHF/DataModel/DerivedTables.h" +#include +#include +#include +#include + +#include +#include +#include // Macro to store nSigma for prong _id_ with PID hypothesis _hyp_ in an array #define GET_N_SIGMA_PRONG(_array_, _candidate_, _id_, _hyp_) \ diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index cba0f802c3d..5103d5c4d77 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -18,19 +18,32 @@ #ifndef PWGHF_UTILS_UTILSEVSELHF_H_ #define PWGHF_UTILS_UTILSEVSELHF_H_ -#include // std::shared_ptr -#include // std::string - -#include "Framework/Configurable.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/HistogramSpec.h" -#include "Framework/OutputObjHeader.h" +#include "PWGHF/Core/CentralityEstimation.h" +// +#include "PWGUD/Core/SGCutParHolder.h" +#include "PWGUD/Core/SGSelector.h" #include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/RCTSelectionFlags.h" #include "EventFiltering/Zorro.h" #include "EventFiltering/ZorroSummary.h" -#include "PWGLF/DataModel/mcCentrality.h" -#include "PWGHF/Core/CentralityEstimation.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include // std::shared_ptr +#include // std::string namespace o2::hf_occupancy { @@ -82,6 +95,7 @@ namespace o2::hf_evsel // event rejection types enum EventRejection { None = 0, + Rct, SoftwareTrigger, Centrality, Trigger, @@ -92,15 +106,17 @@ enum EventRejection { NoSameBunchPileup, Occupancy, NContrib, - Chi2, - PositionZ, NoCollInTimeRangeNarrow, NoCollInTimeRangeStandard, NoCollInRofStandard, + UpcEventCut, + Chi2, + PositionZ, NEventRejection }; o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +EventRejection::NEventRejection - 0.5f, ""}; +o2::framework::AxisSpec axisUpcEvents = {o2::aod::sgselector::DoubleGap + 1, -0.5f, +o2::aod::sgselector::DoubleGap + 0.5f, ""}; /// \brief Function to put labels on monitoring histogram /// \param hRejection monitoring histogram @@ -110,12 +126,14 @@ void setEventRejectionLabels(Histo& hRejection, std::string softwareTriggerLabel { // Puts labels on the collision monitoring histogram. hRejection->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::Rct + 1, "RCT"); hRejection->GetXaxis()->SetBinLabel(EventRejection::SoftwareTrigger + 1, softwareTriggerLabel.data()); hRejection->GetXaxis()->SetBinLabel(EventRejection::Centrality + 1, "Centrality"); hRejection->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "Trigger"); hRejection->GetXaxis()->SetBinLabel(EventRejection::TvxTrigger + 1, "TVX Trigger"); hRejection->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border"); hRejection->GetXaxis()->SetBinLabel(EventRejection::ItsRofBorderCut + 1, "ITS ROF border"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::UpcEventCut + 1, "UPC event"); hRejection->GetXaxis()->SetBinLabel(EventRejection::IsGoodZvtxFT0vsPV + 1, "PV #it{z} consistency FT0 timing"); hRejection->GetXaxis()->SetBinLabel(EventRejection::NoSameBunchPileup + 1, "No same-bunch pile-up"); // POTENTIALLY BAD FOR BEAUTY ANALYSES hRejection->GetXaxis()->SetBinLabel(EventRejection::Occupancy + 1, "Occupancy"); @@ -154,47 +172,86 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { o2::framework::Configurable bcMarginForSoftwareTrigger{"bcMarginForSoftwareTrigger", 100, "Number of BCs of margin for software triggers"}; o2::framework::Configurable ccdbPathSoftwareTrigger{"ccdbPathSoftwareTrigger", "Users/m/mpuccio/EventFiltering/OTS/Chunked/", "ccdb path for ZORRO objects"}; o2::framework::ConfigurableAxis th2ConfigAxisCent{"th2ConfigAxisCent", {100, 0., 100.}, ""}; - o2::framework::ConfigurableAxis th2ConfigAxisOccupancy{"th2ConfigAxisOccupancy", {14, 0, 140000}, ""}; + o2::framework::ConfigurableAxis th2ConfigAxisOccupancy{"th2ConfigAxisOccupancy", {100, 0, 100000}, ""}; + o2::framework::Configurable requireGoodRct{"requireGoodRct", false, "Flag to require good RCT"}; + o2::framework::Configurable rctLabel{"rctLabel", "CBT_hadronPID", "RCT selection flag (CBT, CBT_hadronPID, CBT_electronPID, CCBT_calo, CBT_muon, CBT_muon_glo)"}; + o2::framework::Configurable rctCheckZDC{"rctCheckZDC", false, "RCT flag to check whether the ZDC is present or not"}; + o2::framework::Configurable rctTreatLimitedAcceptanceAsBad{"rctTreatLimitedAcceptanceAsBad", false, "RCT flag to reject events with limited acceptance for selected detectors"}; + + // SG selector + SGSelector sgSelector; // histogram names - static constexpr char nameHistCollisions[] = "hCollisions"; - static constexpr char nameHistSelCollisionsCent[] = "hSelCollisionsCent"; - static constexpr char nameHistPosZBeforeEvSel[] = "hPosZBeforeEvSel"; - static constexpr char nameHistPosZAfterEvSel[] = "hPosZAfterEvSel"; - static constexpr char nameHistPosXAfterEvSel[] = "hPosXAfterEvSel"; - static constexpr char nameHistPosYAfterEvSel[] = "hPosYAfterEvSel"; - static constexpr char nameHistNumPvContributorsAfterSel[] = "hNumPvContributorsAfterSel"; - static constexpr char nameHistCollisionsCentOcc[] = "hCollisionsCentOcc"; - - std::shared_ptr hCollisions, hSelCollisionsCent, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel; + static constexpr char NameHistCollisions[] = "hCollisions"; + static constexpr char NameHistSelCollisionsCent[] = "hSelCollisionsCent"; + static constexpr char NameHistPosZBeforeEvSel[] = "hPosZBeforeEvSel"; + static constexpr char NameHistPosZAfterEvSel[] = "hPosZAfterEvSel"; + static constexpr char NameHistPosXAfterEvSel[] = "hPosXAfterEvSel"; + static constexpr char NameHistPosYAfterEvSel[] = "hPosYAfterEvSel"; + static constexpr char NameHistNumPvContributorsAfterSel[] = "hNumPvContributorsAfterSel"; + static constexpr char NameHistCollisionsCentOcc[] = "hCollisionsCentOcc"; + static constexpr char NameHistUpCollisions[] = "hUpCollisions"; + + std::shared_ptr hCollisions, hSelCollisionsCent, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel, hUpCollisions; std::shared_ptr hCollisionsCentOcc; + // util to retrieve the RCT info from CCDB + o2::aod::rctsel::RCTFlagsChecker rctChecker; + // util to retrieve trigger mask in case of software triggers Zorro zorro; o2::framework::OutputObj zorroSummary{"zorroSummary"}; int currentRun{-1}; + /// Set standard preselection gap trigger (values taken from UD group) + SGCutParHolder setSgPreselection() + { + SGCutParHolder sgCuts; + sgCuts.SetNDtcoll(1); // Minimum number of sigma around the collision + sgCuts.SetMinNBCs(2); // Minimum number of bunch crossings + sgCuts.SetNTracks(2, 1000); // Minimum and maximum number of PV contributors + sgCuts.SetMaxFITtime(34.f); // Maximum FIT time in ns + + // Set FIT amplitudes: FV0, FT0A, FT0C, FDDA, FDDC + sgCuts.SetFITAmpLimits({-1.f, 150.f, 50.f, -1.f, -1.f}); + + return sgCuts; + } + /// \brief Adds collision monitoring histograms in the histogram registry. /// \param registry reference to the histogram registry void addHistograms(o2::framework::HistogramRegistry& registry) { - hCollisions = registry.add(nameHistCollisions, "HF event counter;;# of accepted collisions", {o2::framework::HistType::kTH1D, {axisEvents}}); - hSelCollisionsCent = registry.add(nameHistSelCollisionsCent, "HF event counter;T0M;# of accepted collisions", {o2::framework::HistType::kTH1D, {{100, 0., 100.}}}); - hPosZBeforeEvSel = registry.add(nameHistPosZBeforeEvSel, "all events;#it{z}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{400, -20., 20.}}}); - hPosZAfterEvSel = registry.add(nameHistPosZAfterEvSel, "selected events;#it{z}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{400, -20., 20.}}}); - hPosXAfterEvSel = registry.add(nameHistPosXAfterEvSel, "selected events;#it{x}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{200, -0.5, 0.5}}}); - hPosYAfterEvSel = registry.add(nameHistPosYAfterEvSel, "selected events;#it{y}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{200, -0.5, 0.5}}}); - hNumPvContributorsAfterSel = registry.add(nameHistNumPvContributorsAfterSel, "selected events;#it{y}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{500, -0.5, 499.5}}}); + hCollisions = registry.add(NameHistCollisions, "HF event counter;;# of accepted collisions", {o2::framework::HistType::kTH1D, {axisEvents}}); + hSelCollisionsCent = registry.add(NameHistSelCollisionsCent, "HF event counter;T0M;# of accepted collisions", {o2::framework::HistType::kTH1D, {{100, 0., 100.}}}); + hPosZBeforeEvSel = registry.add(NameHistPosZBeforeEvSel, "all events;#it{z}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{400, -20., 20.}}}); + hPosZAfterEvSel = registry.add(NameHistPosZAfterEvSel, "selected events;#it{z}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{400, -20., 20.}}}); + hPosXAfterEvSel = registry.add(NameHistPosXAfterEvSel, "selected events;#it{x}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{200, -0.5, 0.5}}}); + hPosYAfterEvSel = registry.add(NameHistPosYAfterEvSel, "selected events;#it{y}_{prim. vtx.} (cm);entries", {o2::framework::HistType::kTH1D, {{200, -0.5, 0.5}}}); + hNumPvContributorsAfterSel = registry.add(NameHistNumPvContributorsAfterSel, "selected events;number of prim. vtx. contributors;entries", {o2::framework::HistType::kTH1D, {{500, -0.5, 499.5}}}); setEventRejectionLabels(hCollisions, softwareTrigger); - + hUpCollisions = registry.add(NameHistUpCollisions, "HF UPC counter;;# of UPC events", {o2::framework::HistType::kTH1D, {axisUpcEvents}}); const o2::framework::AxisSpec th2AxisCent{th2ConfigAxisCent, "Centrality"}; const o2::framework::AxisSpec th2AxisOccupancy{th2ConfigAxisOccupancy, "Occupancy"}; - hCollisionsCentOcc = registry.add(nameHistCollisionsCentOcc, "selected events;Centrality; Occupancy", {o2::framework::HistType::kTH2D, {th2AxisCent, th2AxisOccupancy}}); + hCollisionsCentOcc = registry.add(NameHistCollisionsCentOcc, "selected events;Centrality; Occupancy", {o2::framework::HistType::kTH2D, {th2AxisCent, th2AxisOccupancy}}); + } + + /// \brief Inits the HF event selection object + /// \param registry reference to the histogram registry + void init(o2::framework::HistogramRegistry& registry) + { + // we initialise the RCT checker + if (requireGoodRct) { + rctChecker.init(rctLabel.value, rctCheckZDC.value, rctTreatLimitedAcceptanceAsBad.value); + } // we initialise the summary object if (softwareTrigger.value != "") { zorroSummary.setObject(zorro.getZorroSummary()); } + + // we initialise histograms + addHistograms(registry); } /// \brief Applies event selection. @@ -205,10 +262,10 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { /// \param ccdb ccdb service needed to retrieve the needed info for zorro /// \param registry reference to the histogram registry needed for zorro /// \return bitmask with the event selection criteria not satisfied by the collision - template - uint16_t getHfCollisionRejectionMask(const Coll& collision, float& centrality, o2::framework::Service const& ccdb, o2::framework::HistogramRegistry& registry) + template + uint32_t getHfCollisionRejectionMask(const Coll& collision, float& centrality, o2::framework::Service const& ccdb, o2::framework::HistogramRegistry& registry) { - uint16_t rejectionMask{0}; // 16 bits, in case new ev. selections will be added + uint32_t rejectionMask{0}; // 32 bits, in case new ev. selections will be added if constexpr (centEstimator != o2::hf_centrality::CentralityEstimator::None) { centrality = o2::hf_centrality::getCentralityColl(collision, centEstimator); @@ -218,6 +275,10 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { } if constexpr (useEvSel) { + /// RCT condition + if (requireGoodRct && !rctChecker.checkTable(collision)) { + SETBIT(rejectionMask, EventRejection::Rct); + } /// trigger condition if ((useSel8Trigger && !collision.sel8()) || (!useSel8Trigger && triggerClass > -1 && !collision.alias_bit(triggerClass))) { SETBIT(rejectionMask, EventRejection::Trigger); @@ -280,7 +341,7 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { if (softwareTrigger.value != "") { // we might have to update it from CCDB - auto bc = collision.template bc_as(); + auto bc = collision.template bc_as(); int runNumber = bc.runNumber(); if (runNumber != currentRun) { // We might need to update Zorro from CCDB if the run number changes @@ -305,11 +366,32 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { return rejectionMask; } + template + uint32_t getHfCollisionRejectionMaskWithUpc(const Coll& collision, float& centrality, o2::framework::Service const& ccdb, o2::framework::HistogramRegistry& registry, const BCsType& bcs) + { + auto rejectionMaskWithUpc = getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + + if (useEvSel) { + SGCutParHolder sgCuts = setSgPreselection(); + auto bc = collision.template foundBC_as(); + auto bcRange = udhelpers::compatibleBCs(collision, sgCuts.NDtcoll(), bcs, sgCuts.minNBCs()); + auto sgSelectionResult = sgSelector.IsSelected(sgCuts, collision, bcRange, bc); + int upcEventType = sgSelectionResult.value; + if (upcEventType > o2::aod::sgselector::DoubleGap) { + SETBIT(rejectionMaskWithUpc, EventRejection::UpcEventCut); + } else { + hUpCollisions->Fill(upcEventType); + } + } + + return rejectionMaskWithUpc; + } + /// \brief Fills histograms for monitoring event selections satisfied by the collision. /// \param collision analysed collision /// \param rejectionMask bitmask storing the info about which ev. selections are not satisfied by the collision template - void fillHistograms(Coll const& collision, const uint16_t rejectionMask, float& centrality, float occupancy = -1) + void fillHistograms(Coll const& collision, const uint32_t rejectionMask, float& centrality, float occupancy = -1) { hCollisions->Fill(EventRejection::None); const float posZ = collision.posZ(); @@ -333,31 +415,47 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { struct HfEventSelectionMc { // event selection parameters (in chronological order of application) - bool useSel8Trigger{false}; // Apply the Sel8 selection - bool useTvxTrigger{false}; // Apply the TVX trigger - bool useTimeFrameBorderCut{true}; // Apply TF border cut - bool useItsRofBorderCut{false}; // Apply the ITS RO frame border cut - float zPvPosMin{-1000.f}; // Minimum PV posZ (cm) - float zPvPosMax{1000.f}; // Maximum PV posZ (cm) - float centralityMin{0.f}; // Minimum centrality - float centralityMax{100.f}; // Maximum centrality + bool useSel8Trigger{false}; // Apply the Sel8 selection + bool useTvxTrigger{false}; // Apply the TVX trigger + bool useTimeFrameBorderCut{true}; // Apply TF border cut + bool useItsRofBorderCut{false}; // Apply the ITS RO frame border cut + float zPvPosMin{-1000.f}; // Minimum PV posZ (cm) + float zPvPosMax{1000.f}; // Maximum PV posZ (cm) + float centralityMin{0.f}; // Minimum centrality + float centralityMax{100.f}; // Maximum centrality + bool requireGoodRct{false}; // Apply RCT selection + std::string rctLabel{""}; // RCT selection flag + bool rctCheckZDC; // require ZDC from RCT + bool rctTreatLimitedAcceptanceAsBad; // RCT flag to reject events with limited acceptance for selected detectors + + // util to retrieve the RCT info from CCDB + o2::aod::rctsel::RCTFlagsChecker rctChecker; // histogram names - static constexpr char nameHistGenCollisionsCent[] = "hGenCollisionsCent"; + static constexpr char NameHistGenCollisionsCent[] = "hGenCollisionsCent"; std::shared_ptr hGenCollisionsCent; - static constexpr char nameHistParticles[] = "hParticles"; - std::shared_ptr hParticles; + static constexpr char NameHistRecCollisionsCentMc[] = "hRecCollisionsCentMc"; + std::shared_ptr hRecCollisionsCentMc; + static constexpr char NameHistNSplitVertices[] = "hNSplitVertices"; + std::shared_ptr hNSplitVertices; + static constexpr char NameHistGenCollisions[] = "hGenCollisions"; + std::shared_ptr hGenCollisions; /// \brief Adds collision monitoring histograms in the histogram registry. /// \param registry reference to the histogram registry void addHistograms(o2::framework::HistogramRegistry& registry) { - hGenCollisionsCent = registry.add(nameHistGenCollisionsCent, "HF event counter;T0M;# of generated collisions", {o2::framework::HistType::kTH1D, {{100, 0., 100.}}}); - hParticles = registry.add(nameHistParticles, "HF particle counter;;# of accepted particles", {o2::framework::HistType::kTH1D, {axisEvents}}); + hGenCollisionsCent = registry.add(NameHistGenCollisionsCent, "HF event counter;T0M;# of generated collisions", {o2::framework::HistType::kTH1D, {{100, 0., 100.}}}); + hRecCollisionsCentMc = registry.add(NameHistRecCollisionsCentMc, "HF event counter;T0M;# of reconstructed collisions", {o2::framework::HistType::kTH1D, {{100, 0., 100.}}}); + hNSplitVertices = registry.add(NameHistNSplitVertices, "HF split vertices counter;;# of reconstructed collisions per mc collision", {o2::framework::HistType::kTH1D, {{4, 1., 5.}}}); + hGenCollisions = registry.add(NameHistGenCollisions, "HF event counter;;# of accepted collisions", {o2::framework::HistType::kTH1D, {axisEvents}}); // Puts labels on the collision monitoring histogram. - setEventRejectionLabels(hParticles); + setEventRejectionLabels(hGenCollisions); } + /// \brief Configures the object from the reco workflow + /// \param registry reference to the histogram registry + /// \param device device spec to get the configs from the reco workflow void configureFromDevice(const o2::framework::DeviceSpec& device) { for (const auto& option : device.options) { @@ -377,19 +475,44 @@ struct HfEventSelectionMc { centralityMin = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.centralityMax") == 0) { centralityMax = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.requireGoodRct") == 0) { + requireGoodRct = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.rctLabel") == 0) { + rctLabel = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.rctCheckZDC") == 0) { + rctCheckZDC = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.rctTreatLimitedAcceptanceAsBad") == 0) { + rctTreatLimitedAcceptanceAsBad = option.defaultValue.get(); } } } + /// \brief Inits the HF event selection object + /// \param device device spec to get the configs from the reco workflow + /// \param registry reference to the histogram registry + void init(const o2::framework::DeviceSpec& device, o2::framework::HistogramRegistry& registry) + { + // we get the configuration from the reco workflow + configureFromDevice(device); + + // we initialise the RCT checker + if (requireGoodRct) { + rctChecker.init(rctLabel, rctCheckZDC, rctTreatLimitedAcceptanceAsBad); + } + + // we initialise histograms + addHistograms(registry); + } + /// \brief Function to apply event selections to generated MC collisions /// \param mcCollision MC collision to test against the selection criteria /// \param collSlice collection of reconstructed collisions /// \param centrality centrality variable to be set in this function /// \return a bitmask with the event selections not satisfied by the analysed collision template - uint16_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision, CCs const& collSlice, float& centrality) + uint32_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision, CCs const& collSlice, float& centrality) { - uint16_t rejectionMask{0}; + uint32_t rejectionMask{0}; float zPv = mcCollision.posZ(); auto bc = mcCollision.template bc_as(); @@ -400,6 +523,16 @@ struct HfEventSelectionMc { SETBIT(rejectionMask, EventRejection::Centrality); } } + + /// RCT condition + if (requireGoodRct) { + for (auto const& collision : collSlice) { + if (!rctChecker.checkTable(collision)) { + SETBIT(rejectionMask, EventRejection::Rct); + break; + } + } + } /// Sel8 trigger selection if (useSel8Trigger && (!bc.selection_bit(o2::aod::evsel::kIsTriggerTVX) || !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder))) { SETBIT(rejectionMask, EventRejection::Trigger); @@ -428,18 +561,28 @@ struct HfEventSelectionMc { /// \param collision analysed collision /// \param rejectionMask bitmask storing the info about which ev. selections are not satisfied by the collision template - void fillHistograms(Coll const& mcCollision, const uint16_t rejectionMask) + void fillHistograms(Coll const& mcCollision, const uint32_t rejectionMask, int nSplitColl = 0) { + hGenCollisions->Fill(EventRejection::None); + if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0M) { - hGenCollisionsCent->Fill(mcCollision.centFT0M()); + if (!TESTBIT(rejectionMask, EventRejection::TimeFrameBorderCut) && !TESTBIT(rejectionMask, EventRejection::ItsRofBorderCut) && !TESTBIT(rejectionMask, EventRejection::PositionZ)) { + hGenCollisionsCent->Fill(mcCollision.centFT0M()); + } } - hParticles->Fill(EventRejection::None); for (std::size_t reason = 1; reason < EventRejection::NEventRejection; reason++) { if (TESTBIT(rejectionMask, reason)) { return; } - hParticles->Fill(reason); + hGenCollisions->Fill(reason); + } + + if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0M) { + hNSplitVertices->Fill(nSplitColl); + for (int nColl = 0; nColl < nSplitColl; nColl++) { + hRecCollisionsCentMc->Fill(mcCollision.centFT0M()); + } } } }; diff --git a/PWGHF/Utils/utilsMcGen.h b/PWGHF/Utils/utilsMcGen.h new file mode 100644 index 00000000000..76152505906 --- /dev/null +++ b/PWGHF/Utils/utilsMcGen.h @@ -0,0 +1,369 @@ +// 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. + +/// \file utilsMcGen.h +/// \brief utility functions for HF MC gen. workflows +/// +/// \author Nima Zardoshti, nima.zardoshti@cern.ch, CERN + +#ifndef PWGHF_UTILS_UTILSMCGEN_H_ +#define PWGHF_UTILS_UTILSMCGEN_H_ + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGHF/Utils/utilsMcMatching.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include + +#include + +#include +#include +#include +#include + +namespace hf_mc_gen +{ + +template +void fillMcMatchGen2Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V& rowMcMatchGen, bool rejectBackground, bool matchCorrelatedBackground) +{ + using namespace o2::constants::physics; + using namespace o2::hf_decay::hf_cand_2prong; + + constexpr std::size_t NDaughtersResonant{2u}; + + // Match generated particles. + for (const auto& particle : mcParticlesPerMcColl) { + int8_t flagChannelMain = 0; + int8_t flagChannelResonant = 0; + int8_t origin = 0; + int8_t sign = 0; + std::vector idxBhadMothers{}; + // Reject particles from background events + if (particle.fromBackgroundEvent() && rejectBackground) { + rowMcMatchGen(flagChannelMain, origin, flagChannelResonant, -1); + continue; + } + if (matchCorrelatedBackground) { + constexpr int DepthMainMax = 2; // Depth for final state matching + constexpr int DepthResoMax = 1; // Depth for resonant decay matching + bool matched = false; + + // TODO: J/ψ + for (const auto& [channelMain, finalState] : daughtersD0Main) { + if (finalState.size() == 3) { // o2-linter: disable=magic-number (partially reconstructed 3-prong decays) + std::array arrPdgDaughtersMain3Prongs = std::array{finalState[0], finalState[1], finalState[2]}; + o2::hf_decay::flipPdgSign(particle.pdgCode(), +kPi0, arrPdgDaughtersMain3Prongs); + matched = RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, arrPdgDaughtersMain3Prongs, true, &sign, DepthMainMax); + } else if (finalState.size() == 2) { // o2-linter: disable=magic-number (fully reconstructed 2-prong decays) + std::array arrPdgDaughtersMain2Prongs = std::array{finalState[0], finalState[1]}; + matched = RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, arrPdgDaughtersMain2Prongs, true, &sign, DepthMainMax); + } else { + LOG(fatal) << "Final state size not supported: " << finalState.size(); + return; + } + if (matched) { + flagChannelMain = sign * channelMain; + + // Flag the resonant decay channel + std::vector arrResoDaughIndex = {}; + RecoDecay::getDaughters(particle, &arrResoDaughIndex, std::array{0}, DepthResoMax); + std::array arrPdgDaughters = {}; + if (arrResoDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < arrResoDaughIndex.size(); ++iProng) { + auto daughI = mcParticles.rawIteratorAt(arrResoDaughIndex[iProng]); + arrPdgDaughters[iProng] = daughI.pdgCode(); + } + flagChannelResonant = o2::hf_decay::getDecayChannelResonant(Pdg::kD0, arrPdgDaughters); + } + break; + } + } + } else { + // D0(bar) → π± K∓ + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign)) { + flagChannelMain = sign * DecayChannelMain::D0ToPiK; + } + + // J/ψ → e+ e− + if (flagChannelMain == 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kJPsi, std::array{+kElectron, -kElectron}, true)) { + flagChannelMain = DecayChannelMain::JpsiToEE; + } + } + + // J/ψ → μ+ μ− + if (flagChannelMain == 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kJPsi, std::array{+kMuonPlus, -kMuonPlus}, true)) { + flagChannelMain = DecayChannelMain::JpsiToMuMu; + } + } + } + + // Check whether the particle is non-prompt (from a b quark). + if (flagChannelMain != 0) { + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMcMatchGen(flagChannelMain, origin, flagChannelResonant, idxBhadMothers[0]); + } else { + rowMcMatchGen(flagChannelMain, origin, flagChannelResonant, -1); + } + } +} + +template +void fillMcMatchGen3Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V& rowMcMatchGen, bool rejectBackground, std::vector const& pdgMothersCorrelBkg = {}) +{ + using namespace o2::constants::physics; + using namespace o2::hf_decay::hf_cand_3prong; + + constexpr std::size_t NDaughtersResonant{2u}; + + // Match generated particles. + for (const auto& particle : mcParticlesPerMcColl) { + int8_t flagChannelMain = 0; + int8_t flagChannelResonant = 0; + int8_t origin = 0; + int8_t sign = 0; + std::vector arrDaughIndex; + std::vector idxBhadMothers{}; + std::array arrPdgDaugResonant; + const std::array arrPdgDaugResonantLcToPKstar0{daughtersLcResonant.at(DecayChannelResonant::LcToPKstar0)}; // Λc± → p± K* + const std::array arrPdgDaugResonantLcToDeltaplusplusK{daughtersLcResonant.at(DecayChannelResonant::LcToDeltaplusplusK)}; // Λc± → Δ(1232)±± K∓ + const std::array arrPdgDaugResonantLcToL1520Pi{daughtersLcResonant.at(DecayChannelResonant::LcToL1520Pi)}; // Λc± → Λ(1520) π± + const std::array arrPdgDaugResonantDToPhiPi{daughtersDsResonant.at(DecayChannelResonant::DsToPhiPi)}; // Ds± → φ π± and D± → φ π± + const std::array arrPdgDaugResonantDToKstar0K{daughtersDsResonant.at(DecayChannelResonant::DsToKstar0K)}; // Ds± → anti-K*(892)0 K± and D± → anti-K*(892)0 K± + + // Reject particles from background events + if (particle.fromBackgroundEvent() && rejectBackground) { + rowMcMatchGen(flagChannelMain, origin, flagChannelResonant, -1); + continue; + } + + if (pdgMothersCorrelBkg.size() > 0) { + for (const auto& pdgMother : pdgMothersCorrelBkg) { + if (std::abs(particle.pdgCode()) != pdgMother) { + continue; // Skip if the particle PDG code does not match the mother PDG code + } + auto finalStates = getDecayChannelsMain(pdgMother); + constexpr int DepthMainMax = 2; // Depth for final state matching + constexpr int DepthResoMax = 1; // Depth for resonant decay matching + + int depthMainMax = DepthMainMax; + bool matched = false; + if (pdgMother == Pdg::kDStar) { + depthMainMax = DepthMainMax + 1; // D0 resonant decays are switched on + } + + std::vector arrAllDaughtersIndex; + for (const auto& [channelMain, finalState] : finalStates) { + if (finalState.size() == 5) { // o2-linter: disable=magic-number (partially reconstructed 3-prong decays from 5-prong decays) + std::array arrPdgDaughtersMain5Prongs = std::array{finalState[0], finalState[1], finalState[2], finalState[3], finalState[4]}; + o2::hf_decay::flipPdgSign(particle.pdgCode(), +kPi0, arrPdgDaughtersMain5Prongs); + RecoDecay::getDaughters(particle, &arrAllDaughtersIndex, arrPdgDaughtersMain5Prongs, depthMainMax); + matched = RecoDecay::isMatchedMCGen(mcParticles, particle, pdgMother, arrPdgDaughtersMain5Prongs, true, &sign, -1); + } else if (finalState.size() == 4) { // o2-linter: disable=magic-number (partially reconstructed 3-prong decays from 4-prong decays) + std::array arrPdgDaughtersMain4Prongs = std::array{finalState[0], finalState[1], finalState[2], finalState[3]}; + o2::hf_decay::flipPdgSign(particle.pdgCode(), +kPi0, arrPdgDaughtersMain4Prongs); + RecoDecay::getDaughters(particle, &arrAllDaughtersIndex, arrPdgDaughtersMain4Prongs, depthMainMax); + matched = RecoDecay::isMatchedMCGen(mcParticles, particle, pdgMother, arrPdgDaughtersMain4Prongs, true, &sign, -1); + } else if (finalState.size() == 3) { // o2-linter: disable=magic-number (fully reconstructed 3-prong decays) + std::array arrPdgDaughtersMain3Prongs = std::array{finalState[0], finalState[1], finalState[2]}; + RecoDecay::getDaughters(particle, &arrAllDaughtersIndex, arrPdgDaughtersMain3Prongs, depthMainMax); + matched = RecoDecay::isMatchedMCGen(mcParticles, particle, pdgMother, arrPdgDaughtersMain3Prongs, true, &sign, depthMainMax); + } else { + LOG(fatal) << "Final state size not supported: " << finalState.size(); + return; + } + if (matched) { + flagChannelMain = sign * channelMain; + // Flag the resonant decay channel + std::vector arrResoDaughIndex = {}; + if (std::abs(pdgMother) == Pdg::kDStar) { + std::vector arrResoDaughIndexDStar = {}; + RecoDecay::getDaughters(particle, &arrResoDaughIndexDStar, std::array{0}, DepthResoMax); + for (std::size_t iDaug = 0; iDaug < arrResoDaughIndexDStar.size(); iDaug++) { + auto daughDstar = mcParticles.rawIteratorAt(arrResoDaughIndexDStar[iDaug]); + if (std::abs(daughDstar.pdgCode()) == Pdg::kD0 || std::abs(daughDstar.pdgCode()) == Pdg::kDPlus) { + RecoDecay::getDaughters(daughDstar, &arrResoDaughIndex, std::array{0}, DepthResoMax); + break; + } + } + } else { + RecoDecay::getDaughters(particle, &arrResoDaughIndex, std::array{0}, DepthResoMax); + } + std::array arrPdgDaughters = {}; + if (arrResoDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < NDaughtersResonant; ++iProng) { + auto daughI = mcParticles.rawIteratorAt(arrResoDaughIndex[iProng]); + arrPdgDaughters[iProng] = daughI.pdgCode(); + } + flagChannelResonant = o2::hf_decay::getDecayChannelResonant(pdgMother, arrPdgDaughters); + } + break; // Exit loop if a match is found + } + } + if (matched) { + break; // Exit loop if a match is found + } + } + } else { + + // D± → π± K∓ π± + if (flagChannelMain == 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2)) { + flagChannelMain = sign * DecayChannelMain::DplusToPiKPi; + } + } + + // Ds± → K± K∓ π± and D± → K± K∓ π± + if (flagChannelMain == 0) { + bool isDplus = false; + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDS, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2)) { + // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π± + // TODO: move to different and explicit flags + flagChannelMain = sign * DecayChannelMain::DsToPiKK; + } else if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDPlus, std::array{+kKPlus, -kKPlus, +kPiPlus}, true, &sign, 2)) { + // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π± + // TODO: move to different and explicit flags + flagChannelMain = sign * DecayChannelMain::DplusToPiKK; + isDplus = true; + } + if (flagChannelMain != 0) { + RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{0}, 1); + if (arrDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) { + auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]); + arrPdgDaugResonant[iProng] = std::abs(daughI.pdgCode()); + } + if ((arrPdgDaugResonant[0] == arrPdgDaugResonantDToPhiPi[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantDToPhiPi[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantDToPhiPi[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantDToPhiPi[0])) { + flagChannelResonant = isDplus ? DecayChannelResonant::DplusToPhiPi : DecayChannelResonant::DsToPhiPi; + } else if ((arrPdgDaugResonant[0] == arrPdgDaugResonantDToKstar0K[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantDToKstar0K[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantDToKstar0K[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantDToKstar0K[0])) { + flagChannelResonant = isDplus ? DecayChannelResonant::DplusToKstar0K : DecayChannelResonant::DsToKstar0K; + } + } + } + } + + // D*± → D0(bar) π± + if (flagChannelMain == 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &sign, 2)) { + flagChannelMain = sign * DecayChannelMain::DstarToPiKPi; + } + } + + // Λc± → p± K∓ π± + if (flagChannelMain == 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kLambdaCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2)) { + flagChannelMain = sign * DecayChannelMain::LcToPKPi; + + // Flagging the different Λc± → p± K∓ π± decay channels + RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{0}, 1); + if (arrDaughIndex.size() == NDaughtersResonant) { + for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) { + auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]); + arrPdgDaugResonant[iProng] = std::abs(daughI.pdgCode()); + } + if ((arrPdgDaugResonant[0] == arrPdgDaugResonantLcToPKstar0[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToPKstar0[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantLcToPKstar0[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToPKstar0[0])) { + flagChannelResonant = DecayChannelResonant::LcToPKstar0; + } else if ((arrPdgDaugResonant[0] == arrPdgDaugResonantLcToDeltaplusplusK[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToDeltaplusplusK[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantLcToDeltaplusplusK[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToDeltaplusplusK[0])) { + flagChannelResonant = DecayChannelResonant::LcToDeltaplusplusK; + } else if ((arrPdgDaugResonant[0] == arrPdgDaugResonantLcToL1520Pi[0] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToL1520Pi[1]) || (arrPdgDaugResonant[0] == arrPdgDaugResonantLcToL1520Pi[1] && arrPdgDaugResonant[1] == arrPdgDaugResonantLcToL1520Pi[0])) { + flagChannelResonant = DecayChannelResonant::LcToL1520Pi; + } + } + } + } + + // Ξc± → p± K∓ π± + if (flagChannelMain == 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kXiCPlus, std::array{+kProton, -kKPlus, +kPiPlus}, true, &sign, 2)) { + flagChannelMain = sign * DecayChannelMain::XicToPKPi; + } + } + } + + // Check whether the particle is non-prompt (from a b quark). + if (flagChannelMain != 0) { + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMcMatchGen(flagChannelMain, origin, flagChannelResonant, idxBhadMothers[0]); + } else { + rowMcMatchGen(flagChannelMain, origin, flagChannelResonant, -1); + } + } +} + +template +void fillMcMatchGenBplus(T const& mcParticles, U& rowMcMatchGen) +{ + using namespace o2::constants::physics; + using namespace o2::hf_decay::hf_cand_beauty; + + // Match generated particles. + for (const auto& particle : mcParticles) { + int8_t flagChannelMain = 0; + int8_t flagChannelReso = 0; + int8_t origin = 0; + int8_t signB = 0; + int8_t signD0 = 0; + int indexGenD0 = -1; + + // B± → D0bar(D0) π± → (K± π∓) π± + std::vector arrayDaughterB; + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kBPlus, std::array{-Pdg::kD0, +kPiPlus}, true, &signB, 1, &arrayDaughterB)) { + // D0(bar) → π± K∓ + for (const auto iD : arrayDaughterB) { // o2-linter: disable=const-ref-in-for-loop (int values) + auto candDaughterMC = mcParticles.rawIteratorAt(iD); + if (std::abs(candDaughterMC.pdgCode()) == Pdg::kD0) { + indexGenD0 = RecoDecay::isMatchedMCGen(mcParticles, candDaughterMC, Pdg::kD0, std::array{-kKPlus, +kPiPlus}, true, &signD0, 1); + } + } + if (indexGenD0 > -1) { + flagChannelMain = signB * DecayChannelMain::BplusToD0Pi; + } + } + rowMcMatchGen(flagChannelMain, flagChannelReso, origin); + } // B candidate +} + +template +void fillMcMatchGenB0(T const& mcParticles, U& rowMcMatchGen) +{ + using namespace o2::constants::physics; + using namespace o2::hf_decay::hf_cand_beauty; + + // Match generated particles. + for (const auto& particle : mcParticles) { + int8_t flagChannelMain = 0; + int8_t flagChannelReso = 0; + int8_t origin = 0; + int8_t sign = 0; + // B0 → D- π+ + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kB0, std::array{-static_cast(Pdg::kDPlus), +kPiPlus}, true)) { + // D- → π- K+ π- + auto candDMC = mcParticles.rawIteratorAt(particle.daughtersIds().front()); + if (RecoDecay::isMatchedMCGen(mcParticles, candDMC, -static_cast(Pdg::kDPlus), std::array{-kPiPlus, +kKPlus, -kPiPlus}, true, &sign)) { + flagChannelMain = sign * DecayChannelMain::B0ToDminusPi; + } + } + rowMcMatchGen(flagChannelMain, flagChannelReso, origin); + } // gen +} + +} // namespace hf_mc_gen + +#endif // PWGHF_UTILS_UTILSMCGEN_H_ diff --git a/PWGHF/Utils/utilsMcMatching.h b/PWGHF/Utils/utilsMcMatching.h new file mode 100644 index 00000000000..bac650d36d4 --- /dev/null +++ b/PWGHF/Utils/utilsMcMatching.h @@ -0,0 +1,320 @@ +// 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. + +/// \file utilsMcMatching.h +/// \brief Mapping of MC flags contained in DecayChannels.h +/// \author Marcello Di Costanzo , Polytechnic University of Turin and INFN + +#ifndef PWGHF_UTILS_UTILSMCMATCHING_H_ +#define PWGHF_UTILS_UTILSMCMATCHING_H_ + +#include "PWGHF/Core/DecayChannels.h" + +#include +#include + +#include + +#include +#include +#include +#include +#include + +namespace o2::hf_decay +{ + +namespace hf_cand_2prong +{ + +// D0 + +static const std::unordered_map> daughtersD0Main{ + {DecayChannelMain::D0ToPiK, {+PDG_t::kKMinus, +PDG_t::kPiPlus}}, + {DecayChannelMain::D0ToPiKPi0, {+PDG_t::kKMinus, +PDG_t::kPiPlus, +PDG_t::kPi0}}, + {DecayChannelMain::D0ToPiPi, {+PDG_t::kPiMinus, +PDG_t::kPiPlus}}, + {DecayChannelMain::D0ToPiPiPi0, {+PDG_t::kPiMinus, +PDG_t::kPiPlus, +PDG_t::kPi0}}, + {DecayChannelMain::D0ToKK, {+PDG_t::kKMinus, +PDG_t::kKPlus}}, +}; + +static const std::unordered_map> daughtersD0Resonant{ + {DecayChannelResonant::D0ToRhoplusPi, {+PDG_t::kRho770Plus, +PDG_t::kPiMinus}}, + {DecayChannelResonant::D0ToRhoplusK, {+PDG_t::kRho770Plus, +PDG_t::kKMinus}}, + {DecayChannelResonant::D0ToKstar0Pi0, {-o2::constants::physics::Pdg::kK0Star892, +PDG_t::kPi0}}, + {DecayChannelResonant::D0ToKstarPi, {-o2::constants::physics::Pdg::kKPlusStar892, +PDG_t::kPiPlus}}, +}; + +// J/ψ + +static const std::unordered_map> daughtersJpsiMain{ + {DecayChannelMain::JpsiToEE, {+PDG_t::kElectron, +PDG_t::kPositron}}, + {DecayChannelMain::JpsiToMuMu, {+PDG_t::kMuonMinus, +PDG_t::kMuonPlus}}, +}; +} // namespace hf_cand_2prong + +namespace hf_cand_3prong +{ + +// D± + +static const std::unordered_map> daughtersDplusMain{ + {DecayChannelMain::DplusToPiKPi, {+PDG_t::kKMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus}}, + {DecayChannelMain::DplusToPiKK, {+PDG_t::kKMinus, +PDG_t::kKPlus, +PDG_t::kPiPlus}}, + {DecayChannelMain::DplusToPiKPiPi0, {+PDG_t::kKMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus, +PDG_t::kPi0}}, + {DecayChannelMain::DplusToPiPiPi, {+PDG_t::kPiMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus}}, +}; + +static const std::unordered_map> daughtersDplusResonant{ + {DecayChannelResonant::DplusToPhiPi, {+o2::constants::physics::Pdg::kPhi, +PDG_t::kPiPlus}}, + {DecayChannelResonant::DplusToKstar0K, {-o2::constants::physics::Pdg::kK0Star892, +PDG_t::kKPlus}}, + {DecayChannelResonant::DplusToKstar1430_0K, {-10311, +PDG_t::kKPlus}}, + {DecayChannelResonant::DplusToRho0Pi, {+PDG_t::kRho770_0, +PDG_t::kPiPlus}}, + {DecayChannelResonant::DplusToF2_1270Pi, {+225, +PDG_t::kPiPlus}}, +}; + +// Ds± + +static const std::unordered_map> daughtersDsMain{ + {DecayChannelMain::DsToPiKK, {+PDG_t::kKMinus, +PDG_t::kKPlus, +PDG_t::kPiPlus}}, + {DecayChannelMain::DsToPiKKPi0, {+PDG_t::kKMinus, +PDG_t::kKPlus, +PDG_t::kPiPlus, +PDG_t::kPi0}}, + {DecayChannelMain::DsToPiPiK, {+PDG_t::kKPlus, +PDG_t::kPiPlus, +PDG_t::kPiMinus}}, + {DecayChannelMain::DsToPiPiPi, {+PDG_t::kPiMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus}}, + {DecayChannelMain::DsToPiPiPiPi0, {+PDG_t::kPiMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus, +PDG_t::kPi0}}, +}; + +static const std::unordered_map> daughtersDsResonant{ + {DecayChannelResonant::DsToPhiPi, {+o2::constants::physics::Pdg::kPhi, +PDG_t::kPiPlus}}, + {DecayChannelResonant::DsToPhiRhoplus, {+o2::constants::physics::Pdg::kPhi, +PDG_t::kRho770Plus}}, + {DecayChannelResonant::DsToKstar0K, {-o2::constants::physics::Pdg::kK0Star892, +PDG_t::kKPlus}}, + {DecayChannelResonant::DsToKstar0Pi, {+o2::constants::physics::Pdg::kK0Star892, +PDG_t::kPiPlus}}, + {DecayChannelResonant::DsToRho0Pi, {+PDG_t::kRho770_0, +PDG_t::kPiPlus}}, + {DecayChannelResonant::DsToRho0K, {+PDG_t::kRho770_0, +PDG_t::kKPlus}}, + {DecayChannelResonant::DsToF2_1270Pi, {225, +PDG_t::kPiPlus}}, + {DecayChannelResonant::DsToF0_1370K, {10221, +PDG_t::kKPlus}}, + {DecayChannelResonant::DsToEtaPi, {221, +PDG_t::kPiPlus}}, +}; + +// D*+ + +static const std::unordered_map> daughtersDstarMain{ + {DecayChannelMain::DstarToPiKPi, {+PDG_t::kKMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus}}, + {DecayChannelMain::DstarToPiKPiPi0, {+PDG_t::kKMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus, +PDG_t::kPi0}}, + {DecayChannelMain::DstarToPiKPiPi0Pi0, {+PDG_t::kKMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus, +PDG_t::kPi0, +PDG_t::kPi0}}, + {DecayChannelMain::DstarToPiKK, {+PDG_t::kKMinus, +PDG_t::kKPlus, +PDG_t::kPiPlus}}, + {DecayChannelMain::DstarToPiKKPi0, {+PDG_t::kKMinus, +PDG_t::kKPlus, +PDG_t::kPiPlus, +PDG_t::kPi0}}, + {DecayChannelMain::DstarToPiPiPi, {+PDG_t::kPiMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus}}, + {DecayChannelMain::DstarToPiPiPiPi0, {+PDG_t::kPiMinus, +PDG_t::kPiPlus, +PDG_t::kPiPlus, +PDG_t::kPi0}}, +}; + +static const std::unordered_map> daughtersDstarResonant{ + {DecayChannelResonant::DstarToD0ToRhoplusPi, {+PDG_t::kRho770Plus, +PDG_t::kPiMinus}}, + {DecayChannelResonant::DstarToD0ToRhoplusK, {+PDG_t::kRho770Plus, +PDG_t::kKMinus}}, + {DecayChannelResonant::DstarToD0ToKstar0Pi0, {-o2::constants::physics::Pdg::kK0Star892, +PDG_t::kPi0}}, + {DecayChannelResonant::DstarToD0ToKstarPi, {-o2::constants::physics::Pdg::kKPlusStar892, +PDG_t::kPiPlus}}, + {DecayChannelResonant::DstarToDplusToPhiPi, {+o2::constants::physics::Pdg::kPhi, +PDG_t::kPiPlus}}, + {DecayChannelResonant::DstarToDplusToKstar0K, {-o2::constants::physics::Pdg::kK0Star892, +PDG_t::kKPlus}}, + {DecayChannelResonant::DstarToDplusToKstar1430_0K, {-10311, +PDG_t::kKPlus}}, + {DecayChannelResonant::DstarToDplusToRho0Pi, {+PDG_t::kRho770_0, +PDG_t::kPiPlus}}, + {DecayChannelResonant::DstarToDplusToF2_1270Pi, {+225, +PDG_t::kPiPlus}}, +}; + +// Λc+ + +static const std::unordered_map> daughtersLcMain{ + {DecayChannelMain::LcToPKPi, {+PDG_t::kProton, +PDG_t::kKMinus, +PDG_t::kPiPlus}}, + {DecayChannelMain::LcToPKPiPi0, {+PDG_t::kProton, +PDG_t::kKMinus, +PDG_t::kPiPlus, +PDG_t::kPi0}}, + {DecayChannelMain::LcToPPiPi, {+PDG_t::kProton, +PDG_t::kPiMinus, +PDG_t::kPiPlus}}, + {DecayChannelMain::LcToPKK, {+PDG_t::kProton, +PDG_t::kKMinus, +PDG_t::kKPlus}}}; + +static const std::unordered_map> daughtersLcResonant{ + {DecayChannelResonant::LcToPKstar0, {-o2::constants::physics::Pdg::kK0Star892, +PDG_t::kProton}}, + {DecayChannelResonant::LcToDeltaplusplusK, {+2224, +PDG_t::kKMinus}}, + {DecayChannelResonant::LcToL1520Pi, {+102134, +PDG_t::kPiPlus}}, +}; + +// Ξc+ + +static const std::unordered_map> daughtersXicMain{ + {DecayChannelMain::XicToPKPi, {+PDG_t::kProton, +PDG_t::kKMinus, +PDG_t::kPiPlus}}, + {DecayChannelMain::XicToPKK, {+PDG_t::kProton, +PDG_t::kKMinus, +PDG_t::kKPlus}}, + {DecayChannelMain::XicToSPiPi, {+PDG_t::kSigmaPlus, +PDG_t::kPiMinus, +PDG_t::kPiPlus}}, +}; + +static const std::unordered_map> daughtersXicResonant{ + {DecayChannelResonant::XicToPKstar0, {-o2::constants::physics::Pdg::kK0Star892, +PDG_t::kProton}}, + {DecayChannelResonant::XicToPPhi, {+PDG_t::kProton, +o2::constants::physics::Pdg::kPhi}}, +}; + +/// Returns a map of the possible final states for a specific 3-prong particle specie +/// \param pdgMother PDG code of the mother particle +/// \return a map of final states with their corresponding PDG codes +inline std::unordered_map> getDecayChannelsMain(int pdgMother) +{ + switch (pdgMother) { + case o2::constants::physics::Pdg::kDPlus: + return daughtersDplusMain; + case o2::constants::physics::Pdg::kDS: + return daughtersDsMain; + case o2::constants::physics::Pdg::kDStar: + return daughtersDstarMain; + case o2::constants::physics::Pdg::kLambdaCPlus: + return daughtersLcMain; + case o2::constants::physics::Pdg::kXiCPlus: + return daughtersXicMain; + default: + LOG(fatal) << "Unknown PDG code for 3-prong final states: " << pdgMother; + return {}; + } +} +} // namespace hf_cand_3prong + +namespace hf_cand_reso +{ +const std::unordered_map particlesToDstarK0s = { + {DecayChannelMain::Ds1ToDstarK0s, constants::physics::Pdg::kDS1}, + {DecayChannelMain::Ds2starToDstarK0s, constants::physics::Pdg::kDS2Star}, + {DecayChannelMain::Ds1star2700ToDstarK0s, constants::physics::Pdg::kDS1Star2700}, + {DecayChannelMain::Ds1star2860ToDstarK0s, constants::physics::Pdg::kDS1Star2860}, + {DecayChannelMain::Ds3star2860ToDstarK0s, constants::physics::Pdg::kDS3Star2860}}; +const std::unordered_map particlesToDplusK0s = { + {DecayChannelMain::Ds2starToDplusK0s, constants::physics::Pdg::kDS2Star}}; +const std::unordered_map particlesToDplusLambda = { + {DecayChannelMain::Xic3055plusToDplusLambda, constants::physics::Pdg::kXiC3055Plus}, + {DecayChannelMain::Xic3080plusToDplusLambda, constants::physics::Pdg::kXiC3080Plus}}; +const std::unordered_map particlesToD0Lambda = { + {DecayChannelMain::Xic3055zeroToD0Lambda, constants::physics::Pdg::kXiC3055_0}, + {DecayChannelMain::Xic3080zeroToD0Lambda, constants::physics::Pdg::kXiC3080_0}}; +const std::unordered_map particlesToDstarPi = { + {DecayChannelMain::D1zeroToDstarPi, constants::physics::Pdg::kD10}, + {DecayChannelMain::D2starzeroToDstarPi, constants::physics::Pdg::kD2Star0}}; +const std::unordered_map particlesToDplusPi = { + {DecayChannelMain::D2starzeroToDplusPi, constants::physics::Pdg::kD2Star0}}; +const std::unordered_map particlesToD0Pi = { + {DecayChannelMain::D2starplusToD0Pi, constants::physics::Pdg::kD2StarPlus}}; +const std::unordered_map particlesToD0Kplus = { + {DecayChannelMain::Ds2starToD0Kplus, constants::physics::Pdg::kDS2Star}}; + +enum PartialMatchMc : uint8_t { + D0Matched = 0, + DstarMatched, + DplusMatched, + K0Matched, + LambdaMatched, + PionMatched, + KaonMatched, + ProtonMatched, + ResoPartlyMatched +}; +} // namespace hf_cand_reso + +/// Compare an array of PDG codes with an expected array +/// \tparam N size of the arrays to be compared +/// \param arrPdgTested array of PDG codes to be tested +/// \param arrPdgExpected array of the expected PDG codes +/// \return true if the arrays are equal, false otherwise +template +inline bool areSamePdgArrays(std::array const& arrPdgTested, std::array arrPdgExpected) +{ + for (std::size_t i = 0; i < N; i++) { + bool foundPdg = false; + for (std::size_t j = 0; j < N; j++) { + if (std::abs(arrPdgTested[i]) == std::abs(arrPdgExpected[j])) { + arrPdgExpected[j] = -1; // Mark as found + foundPdg = true; + break; + } + } + if (!foundPdg) { + return false; + } + } + return true; +} + +/// Flag the resonant decay channel +/// \tparam N size of the array of daughter PDG codes +/// \param pdgMother PDG code of the mother particle +/// \param arrPdgDaughters array of daughter PDG codes +/// \return the channel for the matched resonant decay channel +template +inline int8_t getDecayChannelResonant(const int pdgMother, std::array const& arrPdgDaughters) +{ + switch (pdgMother) { + case o2::constants::physics::Pdg::kD0: + for (const auto& [channelResonant, arrPdgDaughtersResonant] : hf_cand_2prong::daughtersD0Resonant) { + if (areSamePdgArrays(arrPdgDaughters, arrPdgDaughtersResonant)) { + return channelResonant; + } + } + break; + case o2::constants::physics::Pdg::kDPlus: + for (const auto& [channelResonant, arrPdgDaughtersResonant] : hf_cand_3prong::daughtersDplusResonant) { + if (areSamePdgArrays(arrPdgDaughters, arrPdgDaughtersResonant)) { + return channelResonant; + } + } + break; + case o2::constants::physics::Pdg::kDS: + for (const auto& [channelResonant, arrPdgDaughtersResonant] : hf_cand_3prong::daughtersDsResonant) { + if (areSamePdgArrays(arrPdgDaughters, arrPdgDaughtersResonant)) { + return channelResonant; + } + } + break; + case o2::constants::physics::Pdg::kDStar: + for (const auto& [channelResonant, arrPdgDaughtersResonant] : hf_cand_3prong::daughtersDstarResonant) { + if (areSamePdgArrays(arrPdgDaughters, arrPdgDaughtersResonant)) { + return channelResonant; + } + } + break; + case o2::constants::physics::Pdg::kLambdaCPlus: + for (const auto& [channelResonant, arrPdgDaughtersResonant] : hf_cand_3prong::daughtersLcResonant) { + if (areSamePdgArrays(arrPdgDaughters, arrPdgDaughtersResonant)) { + return channelResonant; + } + } + break; + case o2::constants::physics::Pdg::kXiCPlus: + for (const auto& [channelResonant, arrPdgDaughtersResonant] : hf_cand_3prong::daughtersXicResonant) { + if (areSamePdgArrays(arrPdgDaughters, arrPdgDaughtersResonant)) { + return channelResonant; + } + } + break; + default: + LOG(fatal) << "Unknown PDG code for 3-prong final states: " << pdgMother; + return -1; + } + return 0; +} + +/// Flip the sign of a specific PDG code in an array +/// of PDG codes associated to an antiparticle. +/// \tparam N size of the array of PDG codes +/// \param pdgMother PDG code of the mother particle +/// \param pdgToFlip PDG code to be flipped +/// \param arrPdg array of PDG codes to be modified +template +inline void flipPdgSign(const int pdgMother, const int pdgToFlip, std::array& arrPdg) +{ + if (pdgMother >= 0) { + return; + } + for (auto& pdg : arrPdg) { // o2-linter: disable=const-ref-in-for-loop (arrPdg entries are modified) + if (pdg == pdgToFlip) { + pdg = -pdg; + } + } +} +} // namespace o2::hf_decay + +#endif // PWGHF_UTILS_UTILSMCMATCHING_H_ diff --git a/PWGHF/Utils/utilsPid.h b/PWGHF/Utils/utilsPid.h index 19325426cd6..4590bb50b2c 100644 --- a/PWGHF/Utils/utilsPid.h +++ b/PWGHF/Utils/utilsPid.h @@ -17,11 +17,30 @@ #ifndef PWGHF_UTILS_UTILSPID_H_ #define PWGHF_UTILS_UTILSPID_H_ +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" + +#include + +#include + namespace o2::aod::pid_tpc_tof_utils { -enum HfProngSpecies : uint8_t { Pion = 0, - Kaon, - Proton }; +/// @brief Species of HF-candidate daughter tracks +enum HfProngSpecies : uint8_t { + Pion = 0, + Kaon, + Proton, + NHfProngSpecies +}; + +/// @brief PID methods used for HF-candidate daughter tracks +enum PidMethod { + NoPid = 0, // none + TpcOrTof, // TPC or TOF + TpcAndTof, // TPC and TOF + NPidMethods +}; /// Function to combine TPC and TOF NSigma /// \param tiny switch between full and tiny (binned) PID tables @@ -31,21 +50,21 @@ enum HfProngSpecies : uint8_t { Pion = 0, template T1 combineNSigma(T1 tpcNSigma, T1 tofNSigma) { - static constexpr float defaultNSigmaTolerance = .1f; - static constexpr float defaultNSigma = -999.f + defaultNSigmaTolerance; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h + static constexpr float DefaultNSigmaTolerance = .1f; + static constexpr float DefaultNSigma = -999.f + DefaultNSigmaTolerance; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h if constexpr (tiny) { tpcNSigma *= aod::pidtpc_tiny::binning::bin_width; tofNSigma *= aod::pidtof_tiny::binning::bin_width; } - if ((tpcNSigma > defaultNSigma) && (tofNSigma > defaultNSigma)) { // TPC and TOF + if ((tpcNSigma > DefaultNSigma) && (tofNSigma > DefaultNSigma)) { // TPC and TOF return std::sqrt(.5f * (tpcNSigma * tpcNSigma + tofNSigma * tofNSigma)); } - if (tpcNSigma > defaultNSigma) { // only TPC + if (tpcNSigma > DefaultNSigma) { // only TPC return std::abs(tpcNSigma); } - if (tofNSigma > defaultNSigma) { // only TOF + if (tofNSigma > DefaultNSigma) { // only TOF return std::abs(tofNSigma); } return tofNSigma; // no TPC nor TOF diff --git a/PWGHF/Utils/utilsTrkCandHf.h b/PWGHF/Utils/utilsTrkCandHf.h index a1d1b41c10f..43db7a21e08 100644 --- a/PWGHF/Utils/utilsTrkCandHf.h +++ b/PWGHF/Utils/utilsTrkCandHf.h @@ -16,7 +16,13 @@ #ifndef PWGHF_UTILS_UTILSTRKCANDHF_H_ #define PWGHF_UTILS_UTILSTRKCANDHF_H_ -#include "Framework/HistogramSpec.h" +#include "PWGHF/Utils/utilsAnalysis.h" + +#include + +#include + +#include namespace o2::hf_trkcandsel { @@ -54,6 +60,29 @@ int countOnesInBinary(uint8_t num) return count; } +/// Single-track cuts on dcaXY +/// \param trackPar is the track parametrisation +/// \param dca is the 2-D array with track DCAs +/// \param binsPtTrack is the array of pt bins for track selection +/// \param cutsTrackDCA are the cuts for track DCA selection +/// \return true if track passes all cuts +template +bool isSelectedTrackDCA(const T1& trackPar, const T2& dca, const C1& binsPtTrack, const C2& cutsTrackDCA) +{ + auto binPtTrack = o2::analysis::findBin(binsPtTrack, trackPar.getPt()); + if (binPtTrack == -1) { + return false; + } + + if (std::abs(dca[0]) < cutsTrackDCA->get(binPtTrack, "min_dcaxytoprimary")) { + return false; // minimum DCAxy + } + if (std::abs(dca[0]) > cutsTrackDCA->get(binPtTrack, "max_dcaxytoprimary")) { + return false; // maximum DCAxy + } + return true; +} + } // namespace o2::hf_trkcandsel #endif // PWGHF_UTILS_UTILSTRKCANDHF_H_ diff --git a/PWGJE/Core/CMakeLists.txt b/PWGJE/Core/CMakeLists.txt index 592e1686ff5..b6ccafb2be2 100644 --- a/PWGJE/Core/CMakeLists.txt +++ b/PWGJE/Core/CMakeLists.txt @@ -14,7 +14,8 @@ o2physics_add_library(PWGJECore SOURCES FastJetUtilities.cxx JetFinder.cxx JetBkgSubUtils.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore FastJet::FastJet FastJet::Contrib) + emcalCrossTalkEmulation.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore FastJet::FastJet FastJet::Contrib ONNXRuntime::ONNXRuntime O2::EMCALBase O2::EMCALReconstruction) o2physics_target_root_dictionary(PWGJECore HEADERS JetFinder.h @@ -23,5 +24,7 @@ o2physics_target_root_dictionary(PWGJECore JetTaggingUtilities.h JetBkgSubUtils.h JetDerivedDataUtilities.h + emcalCrossTalkEmulation.h + utilsTrackMatchingEMC.h LINKDEF PWGJECoreLinkDef.h) endif() diff --git a/PWGJE/Core/FastJetUtilities.cxx b/PWGJE/Core/FastJetUtilities.cxx index ba7acabbdf3..ca5956a1554 100644 --- a/PWGJE/Core/FastJetUtilities.cxx +++ b/PWGJE/Core/FastJetUtilities.cxx @@ -11,6 +11,10 @@ #include "FastJetUtilities.h" +#include + +#include + void fastjetutilities::setFastJetUserInfo(std::vector& constituents, int index, int status) { fastjet_user_info* user_info = new fastjet_user_info(status, index); // FIXME: can setting this as a pointer be avoided? diff --git a/PWGJE/Core/FastJetUtilities.h b/PWGJE/Core/FastJetUtilities.h index 01da286521b..aebb41ab5d0 100644 --- a/PWGJE/Core/FastJetUtilities.h +++ b/PWGJE/Core/FastJetUtilities.h @@ -17,15 +17,10 @@ #ifndef PWGJE_CORE_FASTJETUTILITIES_H_ #define PWGJE_CORE_FASTJETUTILITIES_H_ +#include + #include -#include -#include -#include #include -#include - -#include "fastjet/PseudoJet.hh" -#include "fastjet/Selector.hh" enum class JetConstituentStatus { track = 0, @@ -103,11 +98,27 @@ void fillTracks(const T& constituent, std::vector& constitue */ template -void fillClusters(const T& constituent, std::vector& constituents, int index = -99999999, int status = static_cast(JetConstituentStatus::cluster)) +void fillClusters(const T& constituent, std::vector& constituents, int index = -99999999, int hadronicCorrectionType = 0, int status = static_cast(JetConstituentStatus::cluster)) { if (status == static_cast(JetConstituentStatus::cluster)) { - double clusterpt = constituent.energy() / std::cosh(constituent.eta()); - constituents.emplace_back(clusterpt * std::cos(constituent.phi()), clusterpt * std::sin(constituent.phi()), clusterpt * std::sinh(constituent.eta()), constituent.energy()); + float constituentEnergy = 0.0; + if (hadronicCorrectionType == 0) { + constituentEnergy = constituent.energy(); + } + if (hadronicCorrectionType == 1) { + constituentEnergy = constituent.energyCorrectedOneTrack1(); + } + if (hadronicCorrectionType == 2) { + constituentEnergy = constituent.energyCorrectedOneTrack2(); + } + if (hadronicCorrectionType == 3) { + constituentEnergy = constituent.energyCorrectedAllTracks1(); + } + if (hadronicCorrectionType == 4) { + constituentEnergy = constituent.energyCorrectedAllTracks2(); + } + float constituentPt = constituentEnergy / std::cosh(constituent.eta()); + constituents.emplace_back(constituentPt * std::cos(constituent.phi()), constituentPt * std::sin(constituent.phi()), constituentPt * std::sinh(constituent.eta()), constituentEnergy); } setFastJetUserInfo(constituents, index, status); } diff --git a/PWGJE/Core/JetBkgSubUtils.cxx b/PWGJE/Core/JetBkgSubUtils.cxx index 336ebf9f67c..4cc6d202130 100644 --- a/PWGJE/Core/JetBkgSubUtils.cxx +++ b/PWGJE/Core/JetBkgSubUtils.cxx @@ -12,13 +12,26 @@ // jet finder task // // Author: Hadi Hassan, Universiy of Jväskylä, hadi.hassan@cern.ch -#include -#include -#include "Framework/Logger.h" -#include "Common/Core/RecoDecay.h" -#include "PWGJE/Core/JetUtilities.h" + #include "PWGJE/Core/JetBkgSubUtils.h" -#include "PWGJE/Core/FastJetUtilities.h" + +#include "Common/Core/RecoDecay.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include JetBkgSubUtils::JetBkgSubUtils(float jetBkgR_out, float bkgEtaMin_out, float bkgEtaMax_out, float bkgPhiMin_out, float bkgPhiMax_out, float constSubAlpha_out, float constSubRMax_out, int nHardReject_out, fastjet::GhostedAreaSpec ghostAreaSpec_out) : jetBkgR(jetBkgR_out), bkgEtaMin(bkgEtaMin_out), @@ -147,7 +160,7 @@ std::tuple JetBkgSubUtils::estimateRhoPerpCone(const std::vector return std::make_tuple(perpPtDensity, perpMdDensity); } -fastjet::PseudoJet JetBkgSubUtils::doRhoAreaSub(fastjet::PseudoJet& jet, double rhoParam, double rhoMParam) +fastjet::PseudoJet JetBkgSubUtils::doRhoAreaSub(const fastjet::PseudoJet& jet, double rhoParam, double rhoMParam) { fastjet::Subtractor sub = fastjet::Subtractor(rhoParam, rhoMParam); @@ -159,7 +172,6 @@ fastjet::PseudoJet JetBkgSubUtils::doRhoAreaSub(fastjet::PseudoJet& jet, double std::vector JetBkgSubUtils::doEventConstSub(std::vector& inputParticles, double rhoParam, double rhoMParam) { - JetBkgSubUtils::initialise(); fastjet::contrib::ConstituentSubtractor constituentSub(rhoParam, rhoMParam); constituentSub.set_distance_type(fastjet::contrib::ConstituentSubtractor::deltaR); /// deltaR=sqrt((y_i-y_j)^2+(phi_i-phi_j)^2)), longitudinal Lorentz invariant diff --git a/PWGJE/Core/JetBkgSubUtils.h b/PWGJE/Core/JetBkgSubUtils.h index e74aa512b99..81a132c9af9 100644 --- a/PWGJE/Core/JetBkgSubUtils.h +++ b/PWGJE/Core/JetBkgSubUtils.h @@ -17,23 +17,16 @@ #ifndef PWGJE_CORE_JETBKGSUBUTILS_H_ #define PWGJE_CORE_JETBKGSUBUTILS_H_ -#include -#include +#include +#include +#include +#include +#include + #include #include -#include - -#include "PWGJE/Core/FastJetUtilities.h" - -#include "fastjet/PseudoJet.hh" -#include "fastjet/ClusterSequenceArea.hh" -#include "fastjet/AreaDefinition.hh" -#include "fastjet/JetDefinition.hh" -#include "fastjet/tools/JetMedianBackgroundEstimator.hh" -#include "fastjet/tools/Subtractor.hh" -#include "fastjet/contrib/ConstituentSubtractor.hh" -#include "Framework/Logger.h" +#include enum class BkgSubEstimator { none = 0, medianRho = 1, @@ -86,7 +79,7 @@ class JetBkgSubUtils /// @param rhoParam the underlying evvent density vs pT (to be set) /// @param rhoParam the underlying evvent density vs jet mass (to be set) /// @return jet, background subtracted jet - fastjet::PseudoJet doRhoAreaSub(fastjet::PseudoJet& jet, double rhoParam, double rhoMParam); + fastjet::PseudoJet doRhoAreaSub(const fastjet::PseudoJet& jet, double rhoParam, double rhoMParam); /// @brief method that subtracts the background from the input particles using the event-wise cosntituent subtractor /// @param inputParticles (all the tracks/clusters/particles in the event) diff --git a/PWGJE/Core/JetCandidateUtilities.h b/PWGJE/Core/JetCandidateUtilities.h index 6c5c0328ef5..921b88af9b8 100644 --- a/PWGJE/Core/JetCandidateUtilities.h +++ b/PWGJE/Core/JetCandidateUtilities.h @@ -17,35 +17,12 @@ #ifndef PWGJE_CORE_JETCANDIDATEUTILITIES_H_ #define PWGJE_CORE_JETCANDIDATEUTILITIES_H_ -#include -#include -#include -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include "Framework/Logger.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGJE/DataModel/EMCALClusters.h" - -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/DataModel/DerivedTables.h" - -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetHFUtilities.h" #include "PWGJE/Core/JetDQUtilities.h" +#include "PWGJE/Core/JetHFUtilities.h" #include "PWGJE/Core/JetV0Utilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/DataModel/Jet.h" + +#include +#include namespace jetcandidateutilities { @@ -166,6 +143,9 @@ bool isDaughterTrack(T& track, U& candidate, V const& tracks) template bool isDaughterParticle(const T& particle, int globalIndex) { + if (!particle.has_daughters()) { + return false; + } for (auto daughter : particle.template daughters_as::parent_t>()) { if (daughter.globalIndex() == globalIndex) { return true; @@ -225,11 +205,11 @@ auto matchedParticle(const T& candidate, const U& tracks, const V& particles) * @param candidate candidate that is being checked * @param table the table to be sliced */ -template -auto slicedPerCandidate(T const& table, U const& candidate, V const& perD0Candidate, M const& perLcCandidate, N const& perBplusCandidate, O const& perDielectronCandidate) +template +auto slicedPerCandidate(T const& table, U const& candidate, V const& perD0Candidate, M const& perDplusCandidate, N const& perDstarCandidate, O const& perLcCandidate, P const& perB0Candidate, Q const& perBplusCandidate, R const& perDielectronCandidate) { if constexpr (jethfutilities::isHFCandidate
()) { - return jethfutilities::slicedPerHFCandidate(table, candidate, perD0Candidate, perLcCandidate, perBplusCandidate); + return jethfutilities::slicedPerHFCandidate(table, candidate, perD0Candidate, perDplusCandidate, perDstarCandidate, perLcCandidate, perB0Candidate, perBplusCandidate); } else if constexpr (jetdqutilities::isDielectronCandidate()) { return jetdqutilities::slicedPerDielectronCandidate(table, candidate, perDielectronCandidate); } else { @@ -238,18 +218,18 @@ auto slicedPerCandidate(T const& table, U const& candidate, V const& perD0Candid } /** - * returns a slice of the table depending on the type of the candidate and index of the collision - * - * @param candidate candidate that is being checked + * returns a slice of the table depending on the index of the candidate + * @param CandidateTable candidtae table type + * @param jet jet that the slice is based on * @param table the table to be sliced */ -template -auto slicedPerCandidateCollision(T const& table, U const& candidates, V const& collision, M const& D0CollisionPerCollision, N const& LcCollisionPerCollision, O const& BplusCollisionPerCollision, P const& DielectronCollisionPerCollision) +template +auto slicedPerJet(T const& table, U const& jet, V const& perD0Jet, M const& perDplusJet, N const& perDstarJet, O const& perLcJet, P const& perB0Jet, Q const& perBplusJet, R const& perDielectronJet) { - if constexpr (jethfutilities::isHFTable() || jethfutilities::isHFMcTable()) { - return jethfutilities::slicedPerHFCollision(table, candidates, collision, D0CollisionPerCollision, LcCollisionPerCollision, BplusCollisionPerCollision); - } else if constexpr (jetdqutilities::isDielectronTable() || jetdqutilities::isDielectronMcTable()) { - return jetdqutilities::slicedPerDielectronCollision(table, candidates, collision, DielectronCollisionPerCollision); + if constexpr (jethfutilities::isHFTable() || jethfutilities::isHFMcTable()) { + return jethfutilities::slicedPerHFJet(table, jet, perD0Jet, perDplusJet, perDstarJet, perLcJet, perB0Jet, perBplusJet); + } else if constexpr (jetdqutilities::isDielectronTable() || jetdqutilities::isDielectronMcTable()) { + return jetdqutilities::slicedPerDielectronJet(table, jet, perDielectronJet); } else { return table; } @@ -373,42 +353,42 @@ float getCandidateInvariantMass(T const& candidate) } template -void fillCandidateCollisionTable(T const& collision, U const& /*candidates*/, V& CandiateCollisionTable, int32_t& CandidateCollisionTableIndex) +void fillCandidateCollisionTable(T const& collision, U const& /*candidates*/, V& CandiateCollisionTable) { if constexpr (jethfutilities::isHFTable()) { - jethfutilities::fillHFCollisionTable(collision, CandiateCollisionTable, CandidateCollisionTableIndex); + jethfutilities::fillHFCollisionTable(collision, CandiateCollisionTable); } else if constexpr (jetdqutilities::isDielectronTable()) { - jetdqutilities::fillDielectronCollisionTable(collision, CandiateCollisionTable, CandidateCollisionTableIndex); // if more dilepton tables are added we would need a fillDQCollisionTable + jetdqutilities::fillDielectronCollisionTable(collision, CandiateCollisionTable); // if more dilepton tables are added we would need a fillDQCollisionTable } } template -void fillCandidateMcCollisionTable(T const& mcCollision, U const& /*candidates*/, V& CandiateMcCollisionTable, int32_t& CandidateMcCollisionTableIndex) +void fillCandidateMcCollisionTable(T const& mcCollision, U const& /*candidates*/, V& CandiateMcCollisionTable) { if constexpr (jethfutilities::isHFMcTable()) { - jethfutilities::fillHFMcCollisionTable(mcCollision, CandiateMcCollisionTable, CandidateMcCollisionTableIndex); + jethfutilities::fillHFMcCollisionTable(mcCollision, CandiateMcCollisionTable); } else if constexpr (jetdqutilities::isDielectronMcTable()) { - jetdqutilities::fillDielectronMcCollisionTable(mcCollision, CandiateMcCollisionTable, CandidateMcCollisionTableIndex); + jetdqutilities::fillDielectronMcCollisionTable(mcCollision, CandiateMcCollisionTable); } } template -void fillCandidateTable(T const& candidate, int32_t collisionIndex, U& BaseTable, V& HFParTable, M& HFParETable, N& HFParDaughterTable, O& HFSelectionFlagTable, P& HFMlTable, Q& HFMlDaughterTable, S& HFMCDTable, int32_t& candidateTableIndex) +void fillCandidateTable(T const& candidate, int32_t collisionIndex, U& BaseTable, V& HFParTable, M& HFParETable, N& HFParDaughterTable, O& HFSelectionFlagTable, P& HFMlTable, Q& HFMlDaughterTable, S& HFMCDTable) { if constexpr (jethfutilities::isHFCandidate()) { - jethfutilities::fillHFCandidateTable(candidate, collisionIndex, BaseTable, HFParTable, HFParETable, HFParDaughterTable, HFSelectionFlagTable, HFMlTable, HFMlDaughterTable, HFMCDTable, candidateTableIndex); + jethfutilities::fillHFCandidateTable(candidate, collisionIndex, BaseTable, HFParTable, HFParETable, HFParDaughterTable, HFSelectionFlagTable, HFMlTable, HFMlDaughterTable, HFMCDTable); } else if constexpr (jetdqutilities::isDielectronCandidate()) { - jetdqutilities::fillDielectronCandidateTable(candidate, collisionIndex, BaseTable, candidateTableIndex); + jetdqutilities::fillDielectronCandidateTable(candidate, collisionIndex, BaseTable); } } template -void fillCandidateMcTable(T const& candidate, int32_t mcCollisionIndex, U& BaseMcTable, int32_t& candidateTableIndex) +void fillCandidateMcTable(T const& candidate, int32_t mcCollisionIndex, U& BaseMcTable) { if constexpr (jethfutilities::isHFMcCandidate()) { - jethfutilities::fillHFCandidateMcTable(candidate, mcCollisionIndex, BaseMcTable, candidateTableIndex); + jethfutilities::fillHFCandidateMcTable(candidate, mcCollisionIndex, BaseMcTable); } else if constexpr (jetdqutilities::isDielectronMcCandidate()) { - jetdqutilities::fillDielectronCandidateMcTable(candidate, mcCollisionIndex, BaseMcTable, candidateTableIndex); + jetdqutilities::fillDielectronCandidateMcTable(candidate, mcCollisionIndex, BaseMcTable); } } diff --git a/PWGJE/Core/JetDQUtilities.h b/PWGJE/Core/JetDQUtilities.h index 91b4c3cdd30..6f33ae0749d 100644 --- a/PWGJE/Core/JetDQUtilities.h +++ b/PWGJE/Core/JetDQUtilities.h @@ -17,31 +17,21 @@ #ifndef PWGJE_CORE_JETDQUTILITIES_H_ #define PWGJE_CORE_JETDQUTILITIES_H_ -#include -#include -#include -#include +#include "PWGJE/DataModel/Jet.h" -#include +#include "Common/Core/RecoDecay.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" +#include +#include -#include "Framework/Logger.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include -#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/DataModel/Jet.h" +#include +#include +#include +#include namespace jetdqutilities { @@ -165,16 +155,16 @@ auto slicedPerDielectronCandidate(T const& table, U const& candidate, V const& p } /** - * returns a slice of the table depending on the type of the Dielectron candidate and index of the collision - * - * @param candidate dielectron candidate that is being checked + * returns a slice of the table depending on the index of the Dielectron jet + * @param DielectronTable dielectron table type + * @param jet jet that the slice is based on * @param table the table to be sliced */ -template -auto slicedPerDielectronCollision(T const& table, U const& /*candidates*/, V const& collision, M const& DielectronCollisionPerCollision) +template +auto slicedPerDielectronJet(T const& table, U const& jet, V const& perDielectronJet) { - if constexpr (isDielectronTable() || isDielectronMcTable()) { - return table.sliceBy(DielectronCollisionPerCollision, collision.globalIndex()); + if constexpr (isDielectronTable() || isDielectronMcTable()) { + return table.sliceBy(perDielectronJet, jet.globalIndex()); } else { return table; } @@ -312,31 +302,27 @@ uint8_t setDielectronParticleDecayBit(T const& particles, U const& particle) } template -void fillDielectronCollisionTable(T const& collision, U& DielectronCollisionTable, int32_t& DielectronCollisionTableIndex) +void fillDielectronCollisionTable(T const& collision, U& DielectronCollisionTable) { DielectronCollisionTable(collision.tag_raw(), collision.runNumber(), collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), collision.collisionTime(), collision.collisionTimeRes()); - DielectronCollisionTableIndex = DielectronCollisionTable.lastIndex(); } template -void fillDielectronMcCollisionTable(T const& mcCollision, U& DielectronMcCollisionTable, int32_t& DielectronMcCollisionTableIndex) +void fillDielectronMcCollisionTable(T const& mcCollision, U& DielectronMcCollisionTable) { DielectronMcCollisionTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()); - DielectronMcCollisionTableIndex = DielectronMcCollisionTable.lastIndex(); } template -void fillDielectronCandidateTable(T const& candidate, int32_t collisionIndex, U& DielectronTable, int32_t& DielectronCandidateTableIndex) +void fillDielectronCandidateTable(T const& candidate, int32_t collisionIndex, U& DielectronTable) { DielectronTable(collisionIndex, candidate.mass(), candidate.pt(), candidate.eta(), candidate.phi(), candidate.sign(), candidate.filterMap_raw(), candidate.mcDecision()); - DielectronCandidateTableIndex = DielectronTable.lastIndex(); } template -void fillDielectronCandidateMcTable(T const& candidate, int32_t mcCollisionIndex, U& DielectronMcTable, int32_t& DielectronCandidateTableIndex) +void fillDielectronCandidateMcTable(T const& candidate, int32_t mcCollisionIndex, U& DielectronMcTable) { DielectronMcTable(mcCollisionIndex, candidate.pt(), candidate.eta(), candidate.phi(), candidate.y(), candidate.e(), candidate.m(), candidate.pdgCode(), candidate.getGenStatusCode(), candidate.getHepMCStatusCode(), candidate.isPhysicalPrimary(), candidate.decayFlag(), candidate.origin()); - DielectronCandidateTableIndex = DielectronMcTable.lastIndex(); } }; // namespace jetdqutilities diff --git a/PWGJE/Core/JetDerivedDataUtilities.h b/PWGJE/Core/JetDerivedDataUtilities.h index 435a362e0db..c3dc36ab18f 100644 --- a/PWGJE/Core/JetDerivedDataUtilities.h +++ b/PWGJE/Core/JetDerivedDataUtilities.h @@ -17,10 +17,17 @@ #ifndef PWGJE_CORE_JETDERIVEDDATAUTILITIES_H_ #define PWGJE_CORE_JETDERIVEDDATAUTILITIES_H_ -#include -#include -#include "Common/CCDB/TriggerAliases.h" #include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" + +#include + +#include +#include +#include +#include +#include +#include namespace jetderiveddatautilities { @@ -29,59 +36,118 @@ static constexpr float mPion = 0.139; // TDatabasePDG::Instance()->GetParticle(2 enum JCollisionSel { sel8 = 0, - sel8Full = 1, - sel8FullPbPb = 2, - selMC = 3, - selMCFull = 4, - selMCFullPbPb = 5, - selUnanchoredMC = 6, - selTVX = 7, - sel7 = 8, - sel7KINT7 = 9 + sel7 = 1, + selKINT7 = 2, + selTVX = 3, + selNoTimeFrameBorder = 4, + selNoITSROFrameBorder = 5, + selNoSameBunchPileup = 6, + selIsGoodZvtxFT0vsPV = 7, + selNoCollInTimeRangeStandard = 8, + selNoCollInRofStandard = 9 +}; + +enum JCollisionSubGeneratorId { + none = -1, + mbGap = 0 }; template -bool selectCollision(T const& collision, int eventSelection = -1) +bool selectCollision(T const& collision, std::vector eventSelectionMaskBits, bool skipMBGapEvents = true) { - if (eventSelection == -1) { + if (skipMBGapEvents && collision.subGeneratorId() == JCollisionSubGeneratorId::mbGap) { + return false; + } + if (eventSelectionMaskBits.size() == 0) { return true; } - return (collision.eventSel() & (1 << eventSelection)); + for (auto eventSelectionMaskBit : eventSelectionMaskBits) { + if (!(collision.eventSel() & (1 << eventSelectionMaskBit))) { + return false; + } + } + return true; } -int initialiseEventSelection(std::string eventSelection) +bool eventSelectionMasksContainSelection(std::string eventSelectionMasks, std::string selection) { - if (eventSelection == "sel8") { - return JCollisionSel::sel8; + size_t position = 0; + while ((position = eventSelectionMasks.find(selection, position)) != std::string::npos) { + bool validStart = (position == 0 || eventSelectionMasks[position - 1] == '+'); + bool validEnd = (position + selection.length() == eventSelectionMasks.length() || eventSelectionMasks[position + selection.length()] == '+'); + if (validStart && validEnd) { + return true; + } + position += selection.length(); } - if (eventSelection == "sel8Full") { - return JCollisionSel::sel8Full; + return false; +} + +std::vector initialiseEventSelectionBits(std::string eventSelectionMasks) +{ + std::vector eventSelectionMaskBits; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "sel8")) { + eventSelectionMaskBits.push_back(JCollisionSel::sel8); } - if (eventSelection == "sel8FullPbPb") { - return JCollisionSel::sel8FullPbPb; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "sel7")) { + eventSelectionMaskBits.push_back(JCollisionSel::sel7); } - if (eventSelection == "selMC") { - return JCollisionSel::selMC; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "selKINT7")) { + eventSelectionMaskBits.push_back(JCollisionSel::selKINT7); } - if (eventSelection == "selMCFull") { - return JCollisionSel::selMCFull; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "TVX")) { + eventSelectionMaskBits.push_back(JCollisionSel::selTVX); } - if (eventSelection == "selMCFullPbPb") { - return JCollisionSel::selMCFullPbPb; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "NoTimeFrameBorder")) { + eventSelectionMaskBits.push_back(JCollisionSel::selNoTimeFrameBorder); } - if (eventSelection == "selUnanchoredMC") { - return JCollisionSel::selUnanchoredMC; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "NoITSROFrameBorder")) { + eventSelectionMaskBits.push_back(JCollisionSel::selNoITSROFrameBorder); } - if (eventSelection == "selTVX") { - return JCollisionSel::selTVX; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "NoSameBunchPileup")) { + eventSelectionMaskBits.push_back(JCollisionSel::selNoSameBunchPileup); } - if (eventSelection == "sel7") { - return JCollisionSel::sel7; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "IsGoodZvtxFT0vsPV")) { + eventSelectionMaskBits.push_back(JCollisionSel::selIsGoodZvtxFT0vsPV); } - if (eventSelection == "sel7KINT7") { - return JCollisionSel::sel7KINT7; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "NoCollInTimeRangeStandard")) { + eventSelectionMaskBits.push_back(JCollisionSel::selNoCollInTimeRangeStandard); } - return -1; + if (eventSelectionMasksContainSelection(eventSelectionMasks, "NoCollInRofStandard")) { + eventSelectionMaskBits.push_back(JCollisionSel::selNoCollInRofStandard); + } + + if (eventSelectionMasksContainSelection(eventSelectionMasks, "sel8Full")) { + eventSelectionMaskBits.push_back(JCollisionSel::sel8); + eventSelectionMaskBits.push_back(JCollisionSel::selNoSameBunchPileup); + } + if (eventSelectionMasksContainSelection(eventSelectionMasks, "sel8FullPbPb")) { + eventSelectionMaskBits.push_back(JCollisionSel::sel8); + eventSelectionMaskBits.push_back(JCollisionSel::selNoCollInTimeRangeStandard); + eventSelectionMaskBits.push_back(JCollisionSel::selNoCollInRofStandard); + } + if (eventSelectionMasksContainSelection(eventSelectionMasks, "selUnanchoredMC")) { + eventSelectionMaskBits.push_back(JCollisionSel::selTVX); + } + if (eventSelectionMasksContainSelection(eventSelectionMasks, "selMC")) { + eventSelectionMaskBits.push_back(JCollisionSel::selTVX); + eventSelectionMaskBits.push_back(JCollisionSel::selNoTimeFrameBorder); + } + if (eventSelectionMasksContainSelection(eventSelectionMasks, "selMCFull")) { + eventSelectionMaskBits.push_back(JCollisionSel::selTVX); + eventSelectionMaskBits.push_back(JCollisionSel::selNoTimeFrameBorder); + eventSelectionMaskBits.push_back(JCollisionSel::selNoSameBunchPileup); + } + if (eventSelectionMasksContainSelection(eventSelectionMasks, "selMCFullPbPb")) { + eventSelectionMaskBits.push_back(JCollisionSel::selTVX); + eventSelectionMaskBits.push_back(JCollisionSel::selNoCollInTimeRangeStandard); + eventSelectionMaskBits.push_back(JCollisionSel::selNoCollInRofStandard); + } + if (eventSelectionMasksContainSelection(eventSelectionMasks, "sel7KINT7")) { + eventSelectionMaskBits.push_back(JCollisionSel::sel7); + eventSelectionMaskBits.push_back(JCollisionSel::selKINT7); + } + return eventSelectionMaskBits; } template @@ -90,31 +156,33 @@ uint16_t setEventSelectionBit(T const& collision) uint16_t bit = 0; if (collision.sel8()) { SETBIT(bit, JCollisionSel::sel8); - if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup) && collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - SETBIT(bit, JCollisionSel::sel8Full); - if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - SETBIT(bit, JCollisionSel::sel8FullPbPb); - } - } } if (collision.sel7()) { SETBIT(bit, JCollisionSel::sel7); - if (collision.alias_bit(kINT7)) { - SETBIT(bit, JCollisionSel::sel7KINT7); - } + } + if (collision.alias_bit(kINT7)) { + SETBIT(bit, JCollisionSel::selKINT7); } if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { SETBIT(bit, JCollisionSel::selTVX); - SETBIT(bit, JCollisionSel::selUnanchoredMC); - if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - SETBIT(bit, JCollisionSel::selMC); - if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup) && collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - SETBIT(bit, JCollisionSel::selMCFull); - if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - SETBIT(bit, JCollisionSel::selMCFullPbPb); - } - } - } + } + if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + SETBIT(bit, JCollisionSel::selNoTimeFrameBorder); + } + if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + SETBIT(bit, JCollisionSel::selNoITSROFrameBorder); + } + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + SETBIT(bit, JCollisionSel::selNoSameBunchPileup); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + SETBIT(bit, JCollisionSel::selIsGoodZvtxFT0vsPV); + } + if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + SETBIT(bit, JCollisionSel::selNoCollInTimeRangeStandard); + } + if (collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + SETBIT(bit, JCollisionSel::selNoCollInRofStandard); } return bit; } @@ -202,67 +270,67 @@ std::vector initialiseTriggerMaskBits(std::string triggerMasks) { std::vector triggerMaskBits; if (triggerMasksContainTrigger(triggerMasks, "fJetChLowPt")) { - triggerMaskBits.push_back(JetChLowPt); + triggerMaskBits.push_back(JTrigSel::JetChLowPt); } if (triggerMasksContainTrigger(triggerMasks, "fJetChHighPt")) { - triggerMaskBits.push_back(JetChHighPt); + triggerMaskBits.push_back(JTrigSel::JetChHighPt); } if (triggerMasksContainTrigger(triggerMasks, "fTrackLowPt")) { - triggerMaskBits.push_back(TrackLowPt); + triggerMaskBits.push_back(JTrigSel::TrackLowPt); } if (triggerMasksContainTrigger(triggerMasks, "fTrackHighPt")) { - triggerMaskBits.push_back(TrackHighPt); + triggerMaskBits.push_back(JTrigSel::TrackHighPt); } if (triggerMasksContainTrigger(triggerMasks, "fJetD0ChLowPt")) { - triggerMaskBits.push_back(JetD0ChLowPt); + triggerMaskBits.push_back(JTrigSel::JetD0ChLowPt); } if (triggerMasksContainTrigger(triggerMasks, "fJetD0ChHighPt")) { - triggerMaskBits.push_back(JetD0ChHighPt); + triggerMaskBits.push_back(JTrigSel::JetD0ChHighPt); } if (triggerMasksContainTrigger(triggerMasks, "fJetLcChLowPt")) { - triggerMaskBits.push_back(JetLcChLowPt); + triggerMaskBits.push_back(JTrigSel::JetLcChLowPt); } if (triggerMasksContainTrigger(triggerMasks, "fJetLcChHighPt")) { - triggerMaskBits.push_back(JetLcChHighPt); + triggerMaskBits.push_back(JTrigSel::JetLcChHighPt); } if (triggerMasksContainTrigger(triggerMasks, "fEMCALReadout")) { - triggerMaskBits.push_back(EMCALReadout); + triggerMaskBits.push_back(JTrigSel::EMCALReadout); } if (triggerMasksContainTrigger(triggerMasks, "fJetFullHighPt")) { - triggerMaskBits.push_back(JetFullHighPt); + triggerMaskBits.push_back(JTrigSel::JetFullHighPt); } if (triggerMasksContainTrigger(triggerMasks, "fJetFullLowPt")) { - triggerMaskBits.push_back(JetFullLowPt); + triggerMaskBits.push_back(JTrigSel::JetFullLowPt); } if (triggerMasksContainTrigger(triggerMasks, "fJetNeutralHighPt")) { - triggerMaskBits.push_back(JetNeutralHighPt); + triggerMaskBits.push_back(JTrigSel::JetNeutralHighPt); } if (triggerMasksContainTrigger(triggerMasks, "fJetNeutralLowPt")) { - triggerMaskBits.push_back(JetNeutralLowPt); + triggerMaskBits.push_back(JTrigSel::JetNeutralLowPt); } if (triggerMasksContainTrigger(triggerMasks, "fGammaVeryHighPtEMCAL")) { - triggerMaskBits.push_back(GammaVeryHighPtEMCAL); + triggerMaskBits.push_back(JTrigSel::GammaVeryHighPtEMCAL); } if (triggerMasksContainTrigger(triggerMasks, "fGammaVeryHighPtDCAL")) { - triggerMaskBits.push_back(GammaVeryHighPtDCAL); + triggerMaskBits.push_back(JTrigSel::GammaVeryHighPtDCAL); } if (triggerMasksContainTrigger(triggerMasks, "fGammaHighPtEMCAL")) { - triggerMaskBits.push_back(GammaHighPtEMCAL); + triggerMaskBits.push_back(JTrigSel::GammaHighPtEMCAL); } if (triggerMasksContainTrigger(triggerMasks, "fGammaHighPtDCAL")) { - triggerMaskBits.push_back(GammaHighPtDCAL); + triggerMaskBits.push_back(JTrigSel::GammaHighPtDCAL); } if (triggerMasksContainTrigger(triggerMasks, "fGammaLowPtEMCAL")) { - triggerMaskBits.push_back(GammaLowPtEMCAL); + triggerMaskBits.push_back(JTrigSel::GammaLowPtEMCAL); } if (triggerMasksContainTrigger(triggerMasks, "fGammaLowPtDCAL")) { - triggerMaskBits.push_back(GammaLowPtDCAL); + triggerMaskBits.push_back(JTrigSel::GammaLowPtDCAL); } if (triggerMasksContainTrigger(triggerMasks, "fGammaVeryLowPtEMCAL")) { - triggerMaskBits.push_back(GammaVeryLowPtEMCAL); + triggerMaskBits.push_back(JTrigSel::GammaVeryLowPtEMCAL); } if (triggerMasksContainTrigger(triggerMasks, "fGammaVeryLowPtDCAL")) { - triggerMaskBits.push_back(GammaVeryLowPtDCAL); + triggerMaskBits.push_back(JTrigSel::GammaVeryLowPtDCAL); } return triggerMaskBits; } diff --git a/PWGJE/Core/JetFinder.cxx b/PWGJE/Core/JetFinder.cxx index 03583a9e622..87a71fb19e3 100644 --- a/PWGJE/Core/JetFinder.cxx +++ b/PWGJE/Core/JetFinder.cxx @@ -15,7 +15,13 @@ /// \author Jochen Klein #include "PWGJE/Core/JetFinder.h" -#include "Framework/Logger.h" + +#include +#include +#include +#include + +#include /// Sets the jet finding parameters void JetFinder::setParams() diff --git a/PWGJE/Core/JetFinder.h b/PWGJE/Core/JetFinder.h index 26b4a3c5f0f..94afd0117ec 100644 --- a/PWGJE/Core/JetFinder.h +++ b/PWGJE/Core/JetFinder.h @@ -18,18 +18,18 @@ #ifndef PWGJE_CORE_JETFINDER_H_ #define PWGJE_CORE_JETFINDER_H_ -#include -#include +#include +#include +#include +#include +#include +#include + +#include -#include -#include -#include +#include -#include "fastjet/PseudoJet.hh" -#include "fastjet/ClusterSequenceArea.hh" -#include "fastjet/AreaDefinition.hh" -#include "fastjet/JetDefinition.hh" -#include "fastjet/tools/Subtractor.hh" +#include enum class JetType { full = 0, diff --git a/PWGJE/Core/JetFindingUtilities.h b/PWGJE/Core/JetFindingUtilities.h index c41bfbd4f0f..2bb9b8375b4 100644 --- a/PWGJE/Core/JetFindingUtilities.h +++ b/PWGJE/Core/JetFindingUtilities.h @@ -17,38 +17,31 @@ #ifndef PWGJE_CORE_JETFINDINGUTILITIES_H_ #define PWGJE_CORE_JETFINDINGUTILITIES_H_ -#include -#include -#include -#include -#include -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/HistogramRegistry.h" - -#include "Framework/Logger.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGJE/DataModel/EMCALClusters.h" - -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" - -// #include "PWGJE/Core/JetBkgSubUtils.h" #include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetCandidateUtilities.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" #include "PWGJE/Core/JetFinder.h" #include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGJE/Core/JetCandidateUtilities.h" -#include "PWGJE/Core/JetHFUtilities.h" +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include namespace jetfindingutilities { @@ -99,15 +92,14 @@ constexpr bool isEMCALClusterTable() */ template -void analyseTracks(std::vector& inputParticles, T const& tracks, int trackSelection, double trackingEfficinecy, std::optional const& candidate = std::nullopt) +void analyseTracks(std::vector& inputParticles, T const& tracks, int trackSelection, double trackingEfficinecy, const U* candidate = nullptr) { for (auto& track : tracks) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } - if (candidate != std::nullopt) { - auto cand = candidate.value(); - if (jetcandidateutilities::isDaughterTrack(track, cand, tracks)) { + if (candidate != nullptr) { + if (jetcandidateutilities::isDaughterTrack(track, *candidate, tracks)) { continue; } } @@ -159,11 +151,11 @@ void analyseTracksMultipleCandidates(std::vector& inputParti * @param clusters track table to be added */ template -void analyseClusters(std::vector& inputParticles, T const& clusters) +void analyseClusters(std::vector& inputParticles, T const& clusters, int hadronicCorrectionType = 0) { for (auto& cluster : *clusters) { // add cluster selections - fastjetutilities::fillClusters(cluster, inputParticles, cluster.globalIndex()); + fastjetutilities::fillClusters(cluster, inputParticles, cluster.globalIndex(), hadronicCorrectionType); } } @@ -226,7 +218,7 @@ bool analyseCandidateMC(std::vector& inputParticles, T const * @param v0s V0 candidates */ template -bool analyseV0s(std::vector& inputParticles, T const& v0s, float v0PtMin, float v0PtMax, float v0YMin, float v0YMax, int v0Index) +bool analyseV0s(std::vector& inputParticles, T const& v0s, float v0PtMin, float v0PtMax, float v0YMin, float v0YMax, int v0Index, bool useV0SignalFlags) { float v0Mass = 0; float v0Y = -10.0; @@ -237,6 +229,9 @@ bool analyseV0s(std::vector& inputParticles, T const& v0s, f v0Mass = v0.m(); v0Y = v0.y(); } else { + if (useV0SignalFlags && v0.isRejectedCandidate()) { + continue; + } if (v0Index == 0) { v0Mass = o2::constants::physics::MassKaonNeutral; } @@ -337,7 +332,7 @@ void findJets(JetFinder& jetFinder, std::vector& inputPartic * @param candidate optional hf candidiate */ template -void analyseParticles(std::vector& inputParticles, std::string particleSelection, int jetTypeParticleLevel, T const& particles, o2::framework::Service pdgDatabase, std::optional const& candidate = std::nullopt) +void analyseParticles(std::vector& inputParticles, std::string particleSelection, int jetTypeParticleLevel, T const& particles, o2::framework::Service pdgDatabase, const U* candidate = nullptr) { for (auto& particle : particles) { if (particleSelection == "PhysicalPrimary" && !particle.isPhysicalPrimary()) { // CHECK : Does this exclude the HF hadron? @@ -361,13 +356,12 @@ void analyseParticles(std::vector& inputParticles, std::stri continue; } if constexpr (jetcandidateutilities::isMcCandidate() && !jetv0utilities::isV0McCandidate()) { - if (candidate != std::nullopt) { - auto cand = candidate.value(); - if (cand.mcParticleId() == particle.globalIndex()) { + if (candidate != nullptr) { + if ((*candidate).mcParticleId() == particle.globalIndex()) { continue; } if constexpr (checkIsDaughter) { - auto hfParticle = cand.template mcParticle_as(); + auto hfParticle = (*candidate).template mcParticle_as(); if (jetcandidateutilities::isDaughterParticle(hfParticle, particle.globalIndex())) { continue; } @@ -375,9 +369,8 @@ void analyseParticles(std::vector& inputParticles, std::stri } } if constexpr (jetv0utilities::isV0McTable()) { // note that for V0s the candidate table is given to this function, not a single candidate - if (candidate != std::nullopt) { - auto cands = candidate.value(); - for (auto const& cand : cands) { + if (candidate != nullptr) { + for (auto const& cand : (*candidate)) { if (cand.mcParticleId() == particle.globalIndex()) { continue; } diff --git a/PWGJE/Core/JetHFUtilities.h b/PWGJE/Core/JetHFUtilities.h index 1334d8ad6f6..9c3edc54f13 100644 --- a/PWGJE/Core/JetHFUtilities.h +++ b/PWGJE/Core/JetHFUtilities.h @@ -17,33 +17,18 @@ #ifndef PWGJE_CORE_JETHFUTILITIES_H_ #define PWGJE_CORE_JETHFUTILITIES_H_ -#include -#include -#include -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include "Framework/Logger.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGJE/DataModel/EMCALClusters.h" - -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/DataModel/DerivedTables.h" - -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetFinder.h" +#include "PWGHF/Core/DecayChannels.h" #include "PWGJE/DataModel/Jet.h" +#include +#include + +#include +#include +#include +#include +#include + namespace jethfutilities { @@ -83,6 +68,78 @@ constexpr bool isD0McTable() return isD0McCandidate() || isD0McCandidate(); } +/** + * returns true if the candidate is from a D+ table + */ +template +constexpr bool isDplusCandidate() +{ + return std::is_same_v, o2::aod::CandidatesDplusData::iterator> || std::is_same_v, o2::aod::CandidatesDplusData::filtered_iterator> || std::is_same_v, o2::aod::CandidatesDplusMCD::iterator> || std::is_same_v, o2::aod::CandidatesDplusMCD::filtered_iterator>; +} + +/** + * returns true if the particle is from a D+ MC table + */ +template +constexpr bool isDplusMcCandidate() +{ + return std::is_same_v, o2::aod::CandidatesDplusMCP::iterator> || std::is_same_v, o2::aod::CandidatesDplusMCP::filtered_iterator>; +} + +/** + * returns true if the table is a D+ table + */ +template +constexpr bool isDplusTable() +{ + return isDplusCandidate() || isDplusCandidate(); +} + +/** + * returns true if the table is a D+ MC table + */ +template +constexpr bool isDplusMcTable() +{ + return isDplusMcCandidate() || isDplusMcCandidate(); +} + +/** + * returns true if the candidate is from a D* table + */ +template +constexpr bool isDstarCandidate() +{ + return std::is_same_v, o2::aod::CandidatesDstarData::iterator> || std::is_same_v, o2::aod::CandidatesDstarData::filtered_iterator> || std::is_same_v, o2::aod::CandidatesDstarMCD::iterator> || std::is_same_v, o2::aod::CandidatesDstarMCD::filtered_iterator>; +} + +/** + * returns true if the particle is from a D* MC table + */ +template +constexpr bool isDstarMcCandidate() +{ + return std::is_same_v, o2::aod::CandidatesDstarMCP::iterator> || std::is_same_v, o2::aod::CandidatesDstarMCP::filtered_iterator>; +} + +/** + * returns true if the table is a D* table + */ +template +constexpr bool isDstarTable() +{ + return isDstarCandidate() || isDstarCandidate(); +} + +/** + * returns true if the table is a D* MC table + */ +template +constexpr bool isDstarMcTable() +{ + return isDstarMcCandidate() || isDstarMcCandidate(); +} + /** * returns true if the candidate is from a Lc table */ @@ -119,6 +176,42 @@ constexpr bool isLcMcTable() return isLcMcCandidate() || isLcMcCandidate(); } +/** + * returns true if the candidate is from a B0 table + */ +template +constexpr bool isB0Candidate() +{ + return std::is_same_v, o2::aod::CandidatesB0Data::iterator> || std::is_same_v, o2::aod::CandidatesB0Data::filtered_iterator> || std::is_same_v, o2::aod::CandidatesB0MCD::iterator> || std::is_same_v, o2::aod::CandidatesB0MCD::filtered_iterator>; +} + +/** + * returns true if the particle is from a B0 MC table + */ +template +constexpr bool isB0McCandidate() +{ + return std::is_same_v, o2::aod::CandidatesB0MCP::iterator> || std::is_same_v, o2::aod::CandidatesB0MCP::filtered_iterator>; +} + +/** + * returns true if the table is a B0 table + */ +template +constexpr bool isB0Table() +{ + return isB0Candidate() || isB0Candidate(); +} + +/** + * returns true if the table is a B0 MC table + */ +template +constexpr bool isB0McTable() +{ + return isB0McCandidate() || isB0McCandidate(); +} + /** * returns true if the candidate is from a Bplus table */ @@ -164,8 +257,14 @@ constexpr bool isHFCandidate() { if constexpr (isD0Candidate()) { return true; + } else if constexpr (isDplusCandidate()) { + return true; + } else if constexpr (isDstarCandidate()) { + return true; } else if constexpr (isLcCandidate()) { return true; + } else if constexpr (isB0Candidate()) { + return true; } else if constexpr (isBplusCandidate()) { return true; } else { @@ -182,8 +281,14 @@ constexpr bool isHFMcCandidate() { if constexpr (isD0McCandidate()) { return true; + } else if constexpr (isDplusMcCandidate()) { + return true; + } else if constexpr (isDstarMcCandidate()) { + return true; } else if constexpr (isLcMcCandidate()) { return true; + } else if constexpr (isB0McCandidate()) { + return true; } else if constexpr (isBplusMcCandidate()) { return true; } else { @@ -199,8 +304,14 @@ constexpr bool isHFTable() { if constexpr (isD0Candidate() || isD0Candidate()) { return true; + } else if constexpr (isDplusCandidate() || isDplusCandidate()) { + return true; + } else if constexpr (isDstarCandidate() || isDstarCandidate()) { + return true; } else if constexpr (isLcCandidate() || isLcCandidate()) { return true; + } else if constexpr (isB0Candidate() || isB0Candidate()) { + return true; } else if constexpr (isBplusCandidate() || isBplusCandidate()) { return true; } else { @@ -216,8 +327,14 @@ constexpr bool isHFMcTable() { if constexpr (isD0McCandidate() || isD0McCandidate()) { return true; + } else if constexpr (isDplusMcCandidate() || isDplusMcCandidate()) { + return true; + } else if constexpr (isDstarMcCandidate() || isDstarMcCandidate()) { + return true; } else if constexpr (isLcMcCandidate() || isLcMcCandidate()) { return true; + } else if constexpr (isB0McCandidate() || isB0McCandidate()) { + return true; } else if constexpr (isBplusMcCandidate() || isBplusMcCandidate()) { return true; } else { @@ -233,37 +350,73 @@ template constexpr bool isMatchedHFCandidate(T const& candidate) { if constexpr (isD0Candidate()) { - if (std::abs(candidate.flagMcMatchRec()) == 1 << o2::aod::hf_cand_2prong::DecayType::D0ToPiK) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + return true; + } else { + return false; + } + } else if constexpr (isDplusCandidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { + return true; + } else { + return false; + } + } else if constexpr (isDstarCandidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { return true; } else { return false; } } else if constexpr (isLcCandidate()) { - if (std::abs(candidate.flagMcMatchRec()) == 1 << o2::aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + return true; + } else { + return false; + } + } else if constexpr (isB0Candidate()) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::B0ToDminusPi) { return true; } else { return false; } } else if constexpr (isBplusCandidate()) { - if (std::abs(candidate.flagMcMatchRec()) == 1 << o2::aod::hf_cand_bplus::DecayType::BplusToD0Pi) { + if (std::abs(candidate.flagMcMatchRec()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::BplusToD0Pi) { return true; } else { return false; } } else if constexpr (isD0McCandidate()) { - if (std::abs(candidate.flagMcMatchGen()) == 1 << o2::aod::hf_cand_2prong::DecayType::D0ToPiK) { + if (std::abs(candidate.flagMcMatchGen()) == o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK) { + return true; + } else { + return false; + } + } else if constexpr (isDplusMcCandidate()) { + if (std::abs(candidate.flagMcMatchGen()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) { + return true; + } else { + return false; + } + } else if constexpr (isDstarMcCandidate()) { + if (std::abs(candidate.flagMcMatchGen()) == o2::hf_decay::hf_cand_dstar::DecayChannelMain::DstarToPiKPi) { return true; } else { return false; } } else if constexpr (isLcMcCandidate()) { - if (std::abs(candidate.flagMcMatchGen()) == 1 << o2::aod::hf_cand_3prong::DecayType::LcToPKPi) { + if (std::abs(candidate.flagMcMatchGen()) == o2::hf_decay::hf_cand_3prong::DecayChannelMain::LcToPKPi) { + return true; + } else { + return false; + } + } else if constexpr (isB0McCandidate()) { + if (std::abs(candidate.flagMcMatchGen()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::B0ToDminusPi) { return true; } else { return false; } } else if constexpr (isBplusMcCandidate()) { - if (std::abs(candidate.flagMcMatchGen()) == 1 << o2::aod::hf_cand_bplus::DecayType::BplusToD0Pi) { + if (std::abs(candidate.flagMcMatchGen()) == o2::hf_decay::hf_cand_beauty::DecayChannelMain::BplusToD0Pi) { return true; } else { return false; @@ -289,12 +442,30 @@ bool isHFDaughterTrack(T& track, U& candidate, V const& /*tracks*/) } else { return false; } + } else if constexpr (isDplusCandidate()) { + if (candidate.prong0Id() == track.globalIndex() || candidate.prong1Id() == track.globalIndex() || candidate.prong2Id() == track.globalIndex()) { + return true; + } else { + return false; + } + } else if constexpr (isDstarCandidate()) { + if (candidate.prong0Id() == track.globalIndex() || candidate.prong1Id() == track.globalIndex() || candidate.prong2Id() == track.globalIndex()) { + return true; + } else { + return false; + } } else if constexpr (isLcCandidate()) { if (candidate.prong0Id() == track.globalIndex() || candidate.prong1Id() == track.globalIndex() || candidate.prong2Id() == track.globalIndex()) { return true; } else { return false; } + } else if constexpr (isB0Candidate()) { + if (candidate.prong0Id() == track.globalIndex() || candidate.prong1Id() == track.globalIndex() || candidate.prong2Id() == track.globalIndex() || candidate.prong3Id() == track.globalIndex()) { + return true; + } else { + return false; + } } else if constexpr (isBplusCandidate()) { if (candidate.prong0Id() == track.globalIndex() || candidate.prong1Id() == track.globalIndex() || candidate.prong2Id() == track.globalIndex()) { return true; @@ -340,13 +511,19 @@ auto matchedHFParticle(const T& candidate, const U& /*tracks*/, const V& /*parti * @param candidate HF candidate that is being checked * @param table the table to be sliced */ -template -auto slicedPerHFCandidate(T const& table, U const& candidate, V const& perD0Candidate, M const& perLcCandidate, N const& perBplusCandidate) +template +auto slicedPerHFCandidate(T const& table, U const& candidate, V const& perD0Candidate, M const& perDplusCandidate, N const& perDstarCandidate, O const& perLcCandidate, P const& perB0Candidate, Q const& perBplusCandidate) { if constexpr (isD0Candidate()) { return table.sliceBy(perD0Candidate, candidate.globalIndex()); + } else if constexpr (isDplusCandidate()) { + return table.sliceBy(perDplusCandidate, candidate.globalIndex()); + } else if constexpr (isDstarCandidate()) { + return table.sliceBy(perDstarCandidate, candidate.globalIndex()); } else if constexpr (isLcCandidate()) { return table.sliceBy(perLcCandidate, candidate.globalIndex()); + } else if constexpr (isB0Candidate()) { + return table.sliceBy(perB0Candidate, candidate.globalIndex()); } else if constexpr (isBplusCandidate()) { return table.sliceBy(perBplusCandidate, candidate.globalIndex()); } else { @@ -355,20 +532,27 @@ auto slicedPerHFCandidate(T const& table, U const& candidate, V const& perD0Cand } /** - * returns a slice of the table depending on the type of the HF candidate and index of the collision + * returns a slice of the table depending on the index of the HF candidate * - * @param candidate HF candidate that is being checked + * @param HFTable HF table type + * @param jet jet that is being sliced based on * @param table the table to be sliced */ -template -auto slicedPerHFCollision(T const& table, U const& /*candidates*/, V const& collision, M const& D0CollisionPerCollision, N const& LcCollisionPerCollision, O const& BplusCollisionPerCollision) +template +auto slicedPerHFJet(T const& table, U const& jet, V const& perD0Jet, M const& perDplusJet, N const& perDstarJet, O const& perLcJet, P const& perB0Jet, Q const& perBplusJet) { - if constexpr (isD0Table() || isD0McTable()) { - return table.sliceBy(D0CollisionPerCollision, collision.globalIndex()); - } else if constexpr (isLcTable() || isLcMcTable()) { - return table.sliceBy(LcCollisionPerCollision, collision.globalIndex()); - } else if constexpr (isBplusTable() || isBplusMcTable()) { - return table.sliceBy(BplusCollisionPerCollision, collision.globalIndex()); + if constexpr (isD0Table() || isD0McTable()) { + return table.sliceBy(perD0Jet, jet.globalIndex()); + } else if constexpr (isDplusTable() || isDplusMcTable()) { + return table.sliceBy(perDplusJet, jet.globalIndex()); + } else if constexpr (isDstarTable() || isDstarMcTable()) { + return table.sliceBy(perDstarJet, jet.globalIndex()); + } else if constexpr (isLcTable() || isLcMcTable()) { + return table.sliceBy(perLcJet, jet.globalIndex()); + } else if constexpr (isB0Table() || isB0McTable()) { + return table.sliceBy(perB0Jet, jet.globalIndex()); + } else if constexpr (isBplusTable() || isBplusMcTable()) { + return table.sliceBy(perBplusJet, jet.globalIndex()); } else { return table; } @@ -406,8 +590,14 @@ int getHFCandidatePDG(T const& /*candidate*/) { if constexpr (isD0Candidate() || isD0McCandidate()) { return static_cast(o2::constants::physics::Pdg::kD0); + } else if constexpr (isDplusCandidate() || isDplusMcCandidate()) { + return static_cast(o2::constants::physics::Pdg::kDPlus); + } else if constexpr (isDstarCandidate() || isDstarMcCandidate()) { + return static_cast(o2::constants::physics::Pdg::kDStar); } else if constexpr (isLcCandidate() || isLcMcCandidate()) { return static_cast(o2::constants::physics::Pdg::kLambdaCPlus); + } else if constexpr (isB0Candidate() || isB0McCandidate()) { + return static_cast(o2::constants::physics::Pdg::kB0); } else if constexpr (isBplusCandidate() || isBplusMcCandidate()) { return static_cast(o2::constants::physics::Pdg::kBPlus); } else { @@ -423,8 +613,14 @@ int getHFTablePDG() { if constexpr (isD0Table() || isD0McTable()) { return static_cast(o2::constants::physics::Pdg::kD0); + } else if constexpr (isDplusTable() || isDplusMcTable()) { + return static_cast(o2::constants::physics::Pdg::kDPlus); + } else if constexpr (isDstarTable() || isDstarMcTable()) { + return static_cast(o2::constants::physics::Pdg::kDStar); } else if constexpr (isLcTable() || isLcMcTable()) { return static_cast(o2::constants::physics::Pdg::kLambdaCPlus); + } else if constexpr (isB0Table() || isB0McTable()) { + return static_cast(o2::constants::physics::Pdg::kB0); } else if constexpr (isBplusTable() || isBplusMcTable()) { return static_cast(o2::constants::physics::Pdg::kBPlus); } else { @@ -442,8 +638,14 @@ float getHFCandidatePDGMass(T const& /*candidate*/) { if constexpr (isD0Candidate() || isD0McCandidate()) { return static_cast(o2::constants::physics::MassD0); + } else if constexpr (isDplusCandidate() || isDplusMcCandidate()) { + return static_cast(o2::constants::physics::MassDPlus); + } else if constexpr (isDstarCandidate() || isDstarMcCandidate()) { + return static_cast(o2::constants::physics::MassDStar); } else if constexpr (isLcCandidate() || isLcMcCandidate()) { return static_cast(o2::constants::physics::MassLambdaCPlus); + } else if constexpr (isB0Candidate() || isB0McCandidate()) { + return static_cast(o2::constants::physics::MassB0); } else if constexpr (isBplusCandidate() || isBplusMcCandidate()) { return static_cast(o2::constants::physics::MassBPlus); } else { @@ -460,8 +662,14 @@ float getHFTablePDGMass() { if constexpr (isD0Table() || isD0McTable()) { return static_cast(o2::constants::physics::MassD0); + } else if constexpr (isDplusTable() || isDplusMcTable()) { + return static_cast(o2::constants::physics::MassDPlus); + } else if constexpr (isDstarTable() || isDstarMcTable()) { + return static_cast(o2::constants::physics::MassDStar); } else if constexpr (isLcTable() || isLcMcTable()) { return static_cast(o2::constants::physics::MassLambdaCPlus); + } else if constexpr (isB0Table() || isB0McTable()) { + return static_cast(o2::constants::physics::MassB0); } else if constexpr (isBplusTable() || isBplusMcTable()) { return static_cast(o2::constants::physics::MassBPlus); } else { @@ -481,17 +689,15 @@ float getHFCandidateInvariantMass(T const& candidate) } template -void fillHFCollisionTable(T const& collision, U& HFCollisionTable, int32_t& HFCollisionTableIndex) +void fillHFCollisionTable(T const& collision, U& HFCollisionTable) { HFCollisionTable(collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), collision.centFV0A(), collision.multZeqNTracksPV()); - HFCollisionTableIndex = HFCollisionTable.lastIndex(); } template -void fillHFMcCollisionTable(T const& mcCollision, U& HFMcCollisionTable, int32_t& HFMcCollisionTableIndex) +void fillHFMcCollisionTable(T const& mcCollision, U& HFMcCollisionTable) { HFMcCollisionTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.centFT0M()); - HFMcCollisionTableIndex = HFMcCollisionTable.lastIndex(); } template @@ -557,6 +763,138 @@ void fillD0CandidateTable(T const& candidate, U& D0ParTable, V& D0ParETable, M& } } +template +void fillDplusCandidateTable(T const& candidate, U& DplusParTable, V& DplusParETable, M& DplusMlTable, N& DplusMCDTable) +{ + + DplusParTable( + candidate.chi2PCA(), + candidate.nProngsContributorsPV(), + candidate.cpa(), + candidate.cpaXY(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.ptProng2(), + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameter2(), + candidate.impactParameterNormalised0(), + candidate.impactParameterNormalised1(), + candidate.impactParameterNormalised2(), + candidate.nSigTpcPi0(), + candidate.nSigTofPi0(), + candidate.nSigTpcTofPi0(), + candidate.nSigTpcKa1(), + candidate.nSigTofKa1(), + candidate.nSigTpcTofKa1(), + candidate.nSigTpcPi2(), + candidate.nSigTofPi2(), + candidate.nSigTpcTofPi2()); + + DplusParETable( + candidate.xSecondaryVertex(), + candidate.ySecondaryVertex(), + candidate.zSecondaryVertex(), + candidate.errorDecayLength(), + candidate.errorDecayLengthXY(), + candidate.rSecondaryVertex(), + candidate.pProng0(), + candidate.pProng1(), + candidate.pProng2(), + candidate.pxProng0(), + candidate.pyProng0(), + candidate.pzProng0(), + candidate.pxProng1(), + candidate.pyProng1(), + candidate.pzProng1(), + candidate.pxProng2(), + candidate.pyProng2(), + candidate.pzProng2(), + candidate.errorImpactParameter0(), + candidate.errorImpactParameter1(), + candidate.errorImpactParameter2(), + candidate.ct()); + + std::vector mlScoresVector; + auto mlScoresSpan = candidate.mlScores(); + std::copy(mlScoresSpan.begin(), mlScoresSpan.end(), std::back_inserter(mlScoresVector)); + DplusMlTable(mlScoresVector); + + if constexpr (isMc) { + DplusMCDTable(candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.isCandidateSwapped(), candidate.flagMcDecayChanRec()); + } +} + +template +void fillDstarCandidateTable(T const& candidate, U& DstarParTable, V& DstarParDaughterTable, M& DstarMlTable, N& DstarMCDTable) +{ + + DstarParTable( + candidate.pxProng0(), + candidate.pyProng0(), + candidate.pzProng0(), + candidate.pxProng1(), + candidate.pyProng1(), + candidate.pzProng1(), + candidate.signProng1(), + candidate.impactParameter1(), + candidate.impactParameterNormalised1(), + candidate.nSigTpcPi1(), + candidate.nSigTofPi1(), + candidate.nSigTpcTofPi1()); + + DstarParDaughterTable( + candidate.chi2PCACharm(), + candidate.cpaCharm(), + candidate.cpaXYCharm(), + candidate.decayLengthCharm(), + candidate.decayLengthXYCharm(), + candidate.decayLengthNormalisedCharm(), + candidate.decayLengthXYNormalisedCharm(), + candidate.pxProng0Charm(), + candidate.pyProng0Charm(), + candidate.pzProng0Charm(), + candidate.pxProng1Charm(), + candidate.pyProng1Charm(), + candidate.pzProng1Charm(), + candidate.invMassCharm(), + candidate.impactParameter0Charm(), + candidate.impactParameter1Charm(), + candidate.impactParameterNormalised0Charm(), + candidate.impactParameterNormalised1Charm(), + candidate.nSigTpcPi0Charm(), + candidate.nSigTofPi0Charm(), + candidate.nSigTpcTofPi0Charm(), + candidate.nSigTpcKa0Charm(), + candidate.nSigTofKa0Charm(), + candidate.nSigTpcTofKa0Charm(), + candidate.nSigTpcPi1Charm(), + candidate.nSigTofPi1Charm(), + candidate.nSigTpcTofPi1Charm(), + candidate.nSigTpcKa1Charm(), + candidate.nSigTofKa1Charm(), + candidate.nSigTpcTofKa1Charm()); + + std::vector mlScoresVector; + auto mlScoresSpan = candidate.mlScores(); + std::copy(mlScoresSpan.begin(), mlScoresSpan.end(), std::back_inserter(mlScoresVector)); + DstarMlTable(mlScoresVector); + + if constexpr (isMc) { + DstarMCDTable( + candidate.flagMcMatchRec(), + candidate.flagMcMatchRecCharm(), + candidate.originMcRec(), + candidate.ptBhadMotherPart(), + candidate.pdgBhadMotherPart(), + candidate.nTracksDecayed()); + } +} + template void fillLcCandidateTable(T const& candidate, U& LcParTable, V& LcParETable, M& LcMlTable, N& LcMCDTable) { @@ -629,6 +967,91 @@ void fillLcCandidateTable(T const& candidate, U& LcParTable, V& LcParETable, M& } } +// need to update this +template +void fillB0CandidateTable(T const& candidate, U& B0ParTable, V& B0ParETable, M& B0ParD0Table, N& B0MlTable, O& B0MlD0Table, P& B0MCDTable) +{ + + B0ParTable( + candidate.chi2PCA(), + candidate.cpa(), + candidate.cpaXY(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameterNormalised0(), + candidate.impactParameterNormalised1(), + candidate.nSigTpcPiExpPi(), + candidate.nSigTofPiExpPi(), + candidate.nSigTpcTofPiExpPi(), + candidate.nSigTpcKaExpPi(), + candidate.nSigTofKaExpPi(), + candidate.nSigTpcTofKaExpPi(), + candidate.maxNormalisedDeltaIP(), + candidate.impactParameterProduct()); + + B0ParETable( + candidate.xSecondaryVertex(), + candidate.ySecondaryVertex(), + candidate.zSecondaryVertex(), + candidate.errorDecayLength(), + candidate.errorDecayLengthXY(), + candidate.rSecondaryVertex(), + candidate.pProng1(), + candidate.pxProng1(), + candidate.pyProng1(), + candidate.pzProng1(), + candidate.errorImpactParameter1(), + candidate.cosThetaStar(), + candidate.ct()); + + B0ParD0Table( + candidate.chi2PCACharm(), + candidate.nProngsContributorsPVCharm(), + candidate.cpaCharm(), + candidate.cpaXYCharm(), + candidate.decayLengthCharm(), + candidate.decayLengthXYCharm(), + candidate.decayLengthNormalisedCharm(), + candidate.decayLengthXYNormalisedCharm(), + candidate.ptProng0Charm(), + candidate.ptProng1Charm(), + candidate.ptProng2Charm(), + candidate.impactParameter0Charm(), + candidate.impactParameter1Charm(), + candidate.impactParameter2Charm(), + candidate.impactParameterNormalised0Charm(), + candidate.impactParameterNormalised1Charm(), + candidate.impactParameterNormalised2Charm(), + candidate.nSigTpcPi0Charm(), + candidate.nSigTofPi0Charm(), + candidate.nSigTpcTofPi0Charm(), + candidate.nSigTpcKa1Charm(), + candidate.nSigTofKa1Charm(), + candidate.nSigTpcTofKa1Charm(), + candidate.nSigTpcPi2Charm(), + candidate.nSigTofPi2Charm(), + candidate.nSigTpcTofPi2Charm()); + + // B0SelectionFlagTable(candidate.candidateSelFlag()); + + B0MlTable(candidate.mlScoreSig()); + + std::vector mlScoresCharmVector; + auto mlScoresCharmSpan = candidate.mlScoresCharm(); + std::copy(mlScoresCharmSpan.begin(), mlScoresCharmSpan.end(), std::back_inserter(mlScoresCharmVector)); + B0MlD0Table(mlScoresCharmVector); + + if constexpr (isMc) { + B0MCDTable(candidate.flagMcMatchRec(), candidate.originMcRec()); + } +} + // need to update this template void fillBplusCandidateTable(T const& candidate, U& BplusParTable, V& BplusParETable, M& BplusParD0Table, N& BplusMlTable, O& BplusMlD0Table, P& BplusMCDTable) @@ -706,28 +1129,35 @@ void fillBplusCandidateTable(T const& candidate, U& BplusParTable, V& BplusParET } template -void fillHFCandidateTable(T const& candidate, int32_t collisionIndex, U& HFBaseTable, V& HFParTable, M& HFParETable, N& HFParDaughterTable, O& HFSelectionFlagTable, P& HFMlTable, Q& HFMlDaughterTable, S& HFMCDTable, int32_t& HFCandidateTableIndex) +void fillHFCandidateTable(T const& candidate, int32_t collisionIndex, U& HFBaseTable, V& HFParTable, M& HFParETable, N& HFParDaughterTable, O& HFSelectionFlagTable, P& HFMlTable, Q& HFMlDaughterTable, S& HFMCDTable) { HFBaseTable(collisionIndex, candidate.pt(), candidate.eta(), candidate.phi(), candidate.m(), candidate.y()); - HFCandidateTableIndex = HFBaseTable.lastIndex(); HFSelectionFlagTable(candidate.candidateSelFlag()); if constexpr (isD0Candidate()) { fillD0CandidateTable(candidate, HFParTable, HFParETable, HFMlTable, HFMCDTable); } + if constexpr (isDplusCandidate()) { + fillDplusCandidateTable(candidate, HFParTable, HFParETable, HFMlTable, HFMCDTable); + } + if constexpr (isDstarCandidate()) { + fillDstarCandidateTable(candidate, HFParTable, HFParDaughterTable, HFMlTable, HFMCDTable); + } if constexpr (isLcCandidate()) { fillLcCandidateTable(candidate, HFParTable, HFParETable, HFMlTable, HFMCDTable); } + if constexpr (isB0Candidate()) { + fillB0CandidateTable(candidate, HFParTable, HFParETable, HFParDaughterTable, HFMlTable, HFMlDaughterTable, HFMCDTable); + } if constexpr (isBplusCandidate()) { fillBplusCandidateTable(candidate, HFParTable, HFParETable, HFParDaughterTable, HFMlTable, HFMlDaughterTable, HFMCDTable); } } template -void fillHFCandidateMcTable(T const& candidate, int32_t mcCollisionIndex, U& BaseMcTable, int32_t& candidateTableIndex) +void fillHFCandidateMcTable(T const& candidate, int32_t mcCollisionIndex, U& BaseMcTable) { BaseMcTable(mcCollisionIndex, candidate.pt(), candidate.eta(), candidate.phi(), candidate.y(), candidate.flagMcMatchGen(), candidate.originMcGen()); - candidateTableIndex = BaseMcTable.lastIndex(); } }; // namespace jethfutilities diff --git a/PWGJE/Core/JetMatchingUtilities.h b/PWGJE/Core/JetMatchingUtilities.h index 90885ca737a..cf22cad5ff9 100644 --- a/PWGJE/Core/JetMatchingUtilities.h +++ b/PWGJE/Core/JetMatchingUtilities.h @@ -20,26 +20,25 @@ #ifndef PWGJE_CORE_JETMATCHINGUTILITIES_H_ #define PWGJE_CORE_JETMATCHINGUTILITIES_H_ -#include -#include -#include -#include -#include +#include "PWGJE/Core/JetCandidateUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include + +#include + +#include + #include +#include +#include +#include +#include +#include +#include -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include "Framework/Logger.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetCandidateUtilities.h" +#include namespace jetmatchingutilities { @@ -364,8 +363,14 @@ template >& baseToTagMatchingHF, std::vector>& tagToBaseMatchingHF, V const& /*candidatesBase*/, M const& /*candidatesTag*/, N const& tracksBase, O const& tracksTag) { for (const auto& jetBase : jetsBasePerCollision) { + if (jetBase.candidatesIds().size() == 0) { + continue; + } const auto candidateBase = jetBase.template candidates_first_as(); for (const auto& jetTag : jetsTagPerCollision) { + if (jetTag.candidatesIds().size() == 0) { + continue; + } if (std::round(jetBase.r()) != std::round(jetTag.r())) { continue; } @@ -406,8 +411,8 @@ auto constexpr getConstituentId(T const& track) } } -template -float getPtSum(T const& tracksBase, U const& clustersBase, V const& tracksTag, O const& clustersTag) +template +float getPtSum(T const& tracksBase, U const& candidatesBase, V const& clustersBase, O const& tracksTag, P const& candidatesTag, Q const& clustersTag, R const& fullTracksBase, S const& fullTracksTag) { std::vector particleTracker; float ptSum = 0.; @@ -427,7 +432,7 @@ float getPtSum(T const& tracksBase, U const& clustersBase, V const& tracksTag, O if constexpr (isEMCAL) { if constexpr (jetsTagIsMc) { for (const auto& clusterBase : clustersBase) { - for (const auto& clusterBaseParticleId : clusterBase.mcParticleIds()) { + for (const auto& clusterBaseParticleId : clusterBase.mcParticlesIds()) { bool isClusterMatched = false; for (const auto& trackTag : tracksTag) { if (clusterBaseParticleId != -1 && clusterBaseParticleId == trackTag.globalIndex()) { @@ -450,7 +455,7 @@ float getPtSum(T const& tracksBase, U const& clustersBase, V const& tracksTag, O auto trackBaseId = trackBase.globalIndex(); for (const auto& clusterTag : clustersTag) { bool isClusterMatched = false; - for (const auto& clusterTagParticleId : clusterTag.mcParticleIds()) { + for (const auto& clusterTagParticleId : clusterTag.mcParticlesIds()) { if (trackBaseId != -1 && trackBaseId == clusterTagParticleId) { ptSum += trackBase.pt(); isClusterMatched = true; @@ -464,6 +469,47 @@ float getPtSum(T const& tracksBase, U const& clustersBase, V const& tracksTag, O } } } + if constexpr (isCandidate) { + if constexpr (jetsTagIsMc) { + for (auto const& candidateBase : candidatesBase) { + if (jetcandidateutilities::isMatchedCandidate(candidateBase)) { + const auto candidateBaseMcId = jetcandidateutilities::matchedParticleId(candidateBase, fullTracksBase, fullTracksTag); + for (auto const& candidateTag : candidatesTag) { + const auto candidateTagId = candidateTag.mcParticleId(); + if (candidateBaseMcId == candidateTagId) { + ptSum += candidateBase.pt(); + } + break; // should only be one + } + } + break; + } + } else if constexpr (jetsBaseIsMc) { + for (auto const& candidateTag : candidatesTag) { + if (jetcandidateutilities::isMatchedCandidate(candidateTag)) { + const auto candidateTagMcId = jetcandidateutilities::matchedParticleId(candidateTag, fullTracksTag, fullTracksBase); + for (auto const& candidateBase : candidatesBase) { + const auto candidateBaseId = candidateBase.mcParticleId(); + if (candidateTagMcId == candidateBaseId) { + ptSum += candidateTag.pt(); + } + break; // should only be one + } + } + break; + } + } else { + for (auto const& candidateBase : candidatesBase) { + for (auto const& candidateTag : candidatesTag) { + if (candidateBase.globalIndex() == candidateTag.globalIndex()) { + ptSum += candidateBase.pt(); + } + break; // should only be one + } + break; + } + } + } return ptSum; } @@ -472,30 +518,34 @@ auto getConstituents(T const& jet, U const& /*constituents*/) { if constexpr (jetfindingutilities::isEMCALClusterTable()) { return jet.template clusters_as(); - } else if constexpr (jetfindingutilities::isDummyTable()) { // this is for the case where EMCal clusters are tested but no clusters exist, like in the case of charged jet analyses + } else if constexpr (jetcandidateutilities::isCandidateTable() || jetcandidateutilities::isCandidateMcTable()) { + return jet.template candidates_as(); + } else if constexpr (jetfindingutilities::isDummyTable() || std::is_same_v || std::is_same_v) { // this is for the case where EMCal clusters or candidates are tested but no clusters or candidates exist and dummy tables are used, like in the case of charged jet analyses return nullptr; } else { return jet.template tracks_as(); } } -template -void MatchPt(T const& jetsBasePerCollision, U const& jetsTagPerCollision, std::vector>& baseToTagMatchingPt, std::vector>& tagToBaseMatchingPt, V const& tracksBase, M const& clustersBase, N const& tracksTag, O const& clustersTag, float minPtFraction) +template +void MatchPt(T const& jetsBasePerCollision, U const& jetsTagPerCollision, std::vector>& baseToTagMatchingPt, std::vector>& tagToBaseMatchingPt, V const& tracksBase, M const& candidatesBase, N const& clustersBase, O const& tracksTag, P const& candidatesTag, Q const& clustersTag, float minPtFraction) { float ptSumBase; float ptSumTag; for (const auto& jetBase : jetsBasePerCollision) { auto jetBaseTracks = getConstituents(jetBase, tracksBase); auto jetBaseClusters = getConstituents(jetBase, clustersBase); + auto jetBaseCandidates = getConstituents(jetBase, candidatesBase); for (const auto& jetTag : jetsTagPerCollision) { if (std::round(jetBase.r()) != std::round(jetTag.r())) { continue; } auto jetTagTracks = getConstituents(jetTag, tracksTag); auto jetTagClusters = getConstituents(jetTag, clustersTag); + auto jetTagCandidates = getConstituents(jetTag, candidatesTag); - ptSumBase = getPtSum < jetfindingutilities::isEMCALClusterTable() || jetfindingutilities::isEMCALClusterTable(), jetsBaseIsMc, jetsTagIsMc > (jetBaseTracks, jetBaseClusters, jetTagTracks, jetTagClusters); - ptSumTag = getPtSum < jetfindingutilities::isEMCALClusterTable() || jetfindingutilities::isEMCALClusterTable(), jetsTagIsMc, jetsBaseIsMc > (jetTagTracks, jetTagClusters, jetBaseTracks, jetBaseClusters); + ptSumBase = getPtSum < jetfindingutilities::isEMCALClusterTable() || jetfindingutilities::isEMCALClusterTable(), (jetcandidateutilities::isCandidateTable() || jetcandidateutilities::isCandidateMcTable()) && (jetcandidateutilities::isCandidateTable

() || jetcandidateutilities::isCandidateMcTable

()), jetsBaseIsMc, jetsTagIsMc > (jetBaseTracks, jetBaseCandidates, jetBaseClusters, jetTagTracks, jetTagCandidates, jetTagClusters, tracksBase, tracksTag); + ptSumTag = getPtSum < jetfindingutilities::isEMCALClusterTable() || jetfindingutilities::isEMCALClusterTable(), (jetcandidateutilities::isCandidateTable() || jetcandidateutilities::isCandidateMcTable()) && (jetcandidateutilities::isCandidateTable

() || jetcandidateutilities::isCandidateMcTable

()), jetsTagIsMc, jetsBaseIsMc > (jetTagTracks, jetTagCandidates, jetTagClusters, jetBaseTracks, jetBaseCandidates, jetBaseClusters, tracksTag, tracksBase); if (ptSumBase > jetBase.pt() * minPtFraction) { baseToTagMatchingPt[jetBase.globalIndex()].push_back(jetTag.globalIndex()); } @@ -508,7 +558,7 @@ void MatchPt(T const& jetsBasePerCollision, U const& jetsTagPerCollision, std::v // function that calls all the Match functions template -void doAllMatching(T const& jetsBasePerCollision, U const& jetsTagPerCollision, std::vector>& baseToTagMatchingGeo, std::vector>& baseToTagMatchingPt, std::vector>& baseToTagMatchingHF, std::vector>& tagToBaseMatchingGeo, std::vector>& tagToBaseMatchingPt, std::vector>& tagToBaseMatchingHF, V const& candidatesBase, M const& candidatesTag, N const& tracksBase, O const& clustersBase, P const& tracksTag, R const& clustersTag, bool doMatchingGeo, bool doMatchingHf, bool doMatchingPt, float maxMatchingDistance, float minPtFraction) +void doAllMatching(T const& jetsBasePerCollision, U const& jetsTagPerCollision, std::vector>& baseToTagMatchingGeo, std::vector>& baseToTagMatchingPt, std::vector>& baseToTagMatchingHF, std::vector>& tagToBaseMatchingGeo, std::vector>& tagToBaseMatchingPt, std::vector>& tagToBaseMatchingHF, V const& candidatesBase, M const& tracksBase, N const& clustersBase, O const& candidatesTag, P const& tracksTag, R const& clustersTag, bool doMatchingGeo, bool doMatchingHf, bool doMatchingPt, float maxMatchingDistance, float minPtFraction) { // geometric matching if (doMatchingGeo) { @@ -516,14 +566,179 @@ void doAllMatching(T const& jetsBasePerCollision, U const& jetsTagPerCollision, } // pt matching if (doMatchingPt) { - MatchPt(jetsBasePerCollision, jetsTagPerCollision, baseToTagMatchingPt, tagToBaseMatchingPt, tracksBase, clustersBase, tracksTag, clustersTag, minPtFraction); + MatchPt(jetsBasePerCollision, jetsTagPerCollision, baseToTagMatchingPt, tagToBaseMatchingPt, tracksBase, candidatesBase, clustersBase, tracksTag, candidatesTag, clustersTag, minPtFraction); } // HF matching - if constexpr (jetcandidateutilities::isCandidateTable()) { + if constexpr (jetcandidateutilities::isCandidateTable() || jetcandidateutilities::isCandidateMcTable()) { if (doMatchingHf) { MatchHF(jetsBasePerCollision, jetsTagPerCollision, baseToTagMatchingHF, tagToBaseMatchingHF, candidatesBase, candidatesTag, tracksBase, tracksTag); } } } -}; // namespace jetmatchingutilities + +// function that does pair matching +template +void doPairMatching(T const& pairsBase, U const& pairsTag, std::vector>& baseToTagMatching, std::vector>& tagToBaseMatching, V const& /*candidatesBase*/, M const& tracksBase, N const& /*candidatesTag*/, O const& tracksTag) +{ + bool hasTrackBase1 = false; + bool hasTrackBase2 = false; + bool hasCandidateBase1 = false; + bool hasCandidateBase2 = false; + std::vector pairsTagIndices; + for (auto i = 0; i < pairsTag.size(); i++) { + pairsTagIndices.push_back(i); + } + for (const auto& pairBase : pairsBase) { + if (pairBase.has_track1()) { + hasTrackBase1 = true; + } + if (pairBase.has_track2()) { + hasTrackBase2 = true; + } + if (pairBase.has_candidate1()) { + hasCandidateBase1 = true; + } + if (pairBase.has_candidate2()) { + hasCandidateBase2 = true; + } + int matchedPairTagIndex = -1; + for (auto pairTagIndex : pairsTagIndices) { + const auto& pairTag = pairsTag.iteratorAt(pairTagIndex); + if (hasTrackBase1 && !pairTag.has_track1()) { + continue; + } + if (hasTrackBase2 && !pairTag.has_track2()) { + continue; + } + if (hasCandidateBase1 && !pairTag.has_candidate1()) { + continue; + } + if (hasCandidateBase2 && !pairTag.has_candidate2()) { + continue; + } + int nMatched = 0; + bool isMatched = false; + if (hasTrackBase1) { + const auto& trackBase1 = pairBase.template track1_as(); + const auto& trackTag1 = pairTag.template track1_as(); + if constexpr (jetsTagIsMc) { + if (trackBase1.mcParticleId() == trackTag1.globalIndex()) { + nMatched++; + isMatched = true; + } + } else if constexpr (jetsBaseIsMc) { + if (trackBase1.globalIndex() == trackTag1.mcParticleId()) { + nMatched++; + isMatched = true; + } + } else { + if (trackBase1.globalIndex() == trackTag1.globalIndex()) { + nMatched++; + isMatched = true; + } + } + if (!isMatched) { + continue; + } + } + isMatched = false; + + if (hasTrackBase2) { + const auto& trackBase2 = pairBase.template track2_as(); + const auto& trackTag2 = pairTag.template track2_as(); + if constexpr (jetsTagIsMc) { + if (trackBase2.mcParticleId() == trackTag2.globalIndex()) { + nMatched++; + isMatched = true; + } + } else if constexpr (jetsBaseIsMc) { + if (trackBase2.globalIndex() == trackTag2.mcParticleId()) { + nMatched++; + isMatched = true; + } + } else { + if (trackBase2.globalIndex() == trackTag2.globalIndex()) { + nMatched++; + isMatched = true; + } + } + if (!isMatched) { + continue; + } + } + isMatched = false; + if (hasCandidateBase1) { + const auto& candidateBase1 = pairBase.template candidate1_as(); + const auto& candidateTag1 = pairTag.template candidate1_as(); + if constexpr (jetsTagIsMc) { + if (jetcandidateutilities::isMatchedCandidate(candidateBase1)) { + const auto candidateBaseMcId = jetcandidateutilities::matchedParticleId(candidateBase1, tracksBase, tracksTag); + if (candidateBaseMcId == candidateTag1.globalIndex()) { + nMatched++; + isMatched = true; + } + } + } else if constexpr (jetsBaseIsMc) { + if (jetcandidateutilities::isMatchedCandidate(candidateTag1)) { + const auto candidateTagMcId = jetcandidateutilities::matchedParticleId(candidateTag1, tracksTag, tracksBase); + if (candidateTagMcId == candidateBase1.globalIndex()) { + nMatched++; + isMatched = true; + } + } + } else { + if (candidateBase1.globalIndex() == candidateTag1.globalIndex()) { + nMatched++; + isMatched = true; + } + } + if (!isMatched) { + continue; + } + } + isMatched = false; + if (hasCandidateBase2) { + const auto& candidateBase2 = pairBase.template candidate2_as(); + const auto& candidateTag2 = pairTag.template candidate2_as(); + if constexpr (jetsTagIsMc) { + if (jetcandidateutilities::isMatchedCandidate(candidateBase2)) { + const auto candidateBaseMcId = jetcandidateutilities::matchedParticleId(candidateBase2, tracksBase, tracksTag); + if (candidateBaseMcId == candidateTag2.globalIndex()) { + nMatched++; + isMatched = true; + } + } + } else if constexpr (jetsBaseIsMc) { + if (jetcandidateutilities::isMatchedCandidate(candidateTag2)) { + const auto candidateTagMcId = jetcandidateutilities::matchedParticleId(candidateTag2, tracksTag, tracksBase); + if (candidateTagMcId == candidateBase2.globalIndex()) { + nMatched++; + isMatched = true; + } + } + } else { + if (candidateBase2.globalIndex() == candidateTag2.globalIndex()) { + nMatched++; + isMatched = true; + } + } + if (!isMatched) { + continue; + } + } + + if (nMatched == 2) { + baseToTagMatching[pairBase.globalIndex()].push_back(pairTag.globalIndex()); + tagToBaseMatching[pairTag.globalIndex()].push_back(pairBase.globalIndex()); + matchedPairTagIndex = pairTagIndex; + break; // can only be one match per jet + } + } + if (matchedPairTagIndex != -1) { + pairsTagIndices.erase(std::find(pairsTagIndices.begin(), pairsTagIndices.end(), matchedPairTagIndex)); + } + } +} + +}; // namespace jetmatchingutilities #endif // PWGJE_CORE_JETMATCHINGUTILITIES_H_ diff --git a/PWGJE/Core/JetSubstructureUtilities.h b/PWGJE/Core/JetSubstructureUtilities.h index cb714c1c5bf..089c1012656 100644 --- a/PWGJE/Core/JetSubstructureUtilities.h +++ b/PWGJE/Core/JetSubstructureUtilities.h @@ -17,28 +17,22 @@ #ifndef PWGJE_CORE_JETSUBSTRUCTUREUTILITIES_H_ #define PWGJE_CORE_JETSUBSTRUCTUREUTILITIES_H_ -#include -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include "Framework/Logger.h" -#include "PWGJE/DataModel/EMCALClusters.h" - -#include "PWGHF/DataModel/CandidateReconstructionTables.h" - #include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetFinder.h" #include "PWGJE/Core/JetCandidateUtilities.h" +#include "PWGJE/Core/JetFinder.h" #include "PWGJE/DataModel/Jet.h" -#include "fastjet/contrib/Nsubjettiness.hh" -#include "fastjet/contrib/AxesDefinition.hh" -#include "fastjet/contrib/MeasureDefinition.hh" -#include "fastjet/contrib/SoftDrop.hh" + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include namespace jetsubstructureutilities { @@ -53,7 +47,7 @@ namespace jetsubstructureutilities * @param pseudoJet converted pseudoJet object which is passed by reference */ template -fastjet::ClusterSequenceArea jetToPseudoJet(T const& jet, U const& /*tracks*/, V const& /*clusters*/, O const& /*candidates*/, fastjet::PseudoJet& pseudoJet) +fastjet::ClusterSequenceArea jetToPseudoJet(T const& jet, U const& /*tracks*/, V const& /*clusters*/, O const& /*candidates*/, fastjet::PseudoJet& pseudoJet, int hadronicCorrectionType = 0) { std::vector jetConstituents; for (auto& jetConstituent : jet.template tracks_as()) { @@ -61,7 +55,7 @@ fastjet::ClusterSequenceArea jetToPseudoJet(T const& jet, U const& /*tracks*/, V } if constexpr (std::is_same_v, o2::aod::JetClusters::iterator> || std::is_same_v, o2::aod::JetClusters::filtered_iterator>) { for (auto& jetClusterConstituent : jet.template clusters_as()) { - fastjetutilities::fillClusters(jetClusterConstituent, jetConstituents, jetClusterConstituent.globalIndex()); + fastjetutilities::fillClusters(jetClusterConstituent, jetConstituents, jetClusterConstituent.globalIndex(), hadronicCorrectionType); } } if constexpr (jetcandidateutilities::isCandidateTable() || jetcandidateutilities::isCandidateMcTable()) { @@ -96,11 +90,11 @@ fastjet::ClusterSequenceArea jetToPseudoJet(T const& jet, U const& /*tracks*/, V // function that returns the N-subjettiness ratio and the distance betewwen the two axes considered for tau2, in the form of a vector template -std::vector getNSubjettiness(T const& jet, U const& tracks, V const& clusters, O const& candidates, std::vector::size_type nMax, M const& reclusteringAlgorithm, bool doSoftDrop = false, float zCut = 0.1, float beta = 0.0) +std::vector getNSubjettiness(T const& jet, U const& tracks, V const& clusters, O const& candidates, std::vector::size_type nMax, M const& reclusteringAlgorithm, bool doSoftDrop = false, float zCut = 0.1, float beta = 0.0, int hadronicCorrectionType = 0) { std::vector result; fastjet::PseudoJet pseudoJet; - fastjet::ClusterSequenceArea clusterSeq(jetToPseudoJet(jet, tracks, clusters, candidates, pseudoJet)); + fastjet::ClusterSequenceArea clusterSeq(jetToPseudoJet(jet, tracks, clusters, candidates, pseudoJet, hadronicCorrectionType)); if (doSoftDrop) { fastjet::contrib::SoftDrop softDrop(beta, zCut); pseudoJet = softDrop(pseudoJet); diff --git a/PWGJE/Core/JetTaggingUtilities.h b/PWGJE/Core/JetTaggingUtilities.h index c607a44c6da..616929ac1ed 100644 --- a/PWGJE/Core/JetTaggingUtilities.h +++ b/PWGJE/Core/JetTaggingUtilities.h @@ -18,22 +18,31 @@ #ifndef PWGJE_CORE_JETTAGGINGUTILITIES_H_ #define PWGJE_CORE_JETTAGGINGUTILITIES_H_ -#include -#include -#include -#include -#include +#include "PWGJE/Core/JetUtilities.h" + +#include "Common/Core/RecoDecay.h" + +#include +#include + +#include +#include + +#include + #include +#include +#include +#include +#include #include +#include #include #include +#include #include - -#include "TF1.h" -#include "Framework/Logger.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGJE/Core/JetUtilities.h" +#include +#include enum JetTaggingSpecies { none = 0, @@ -44,17 +53,78 @@ enum JetTaggingSpecies { gluon = 5 }; +enum BJetTaggingMethod { + IPsN1 = 0, + IPsN2 = 1, + IPsN3 = 2, + IPs3DN1 = 3, + IPs3DN2 = 4, + IPs3DN3 = 5, + SV = 6, + SV3D = 7 +}; + namespace jettaggingutilities { const int cmTomum = 10000; // using cm -> #mum for impact parameter (dca) +struct BJetParams { + float jetpT = 0.0; + float jetEta = 0.0; + float jetPhi = 0.0; + int nTracks = -1; + int nSV = -1; + float jetMass = 0.0; +}; + +struct BJetTrackParams { + double trackpT = 0.0; + double trackEta = 0.0; + double dotProdTrackJet = 0.0; + double dotProdTrackJetOverJet = 0.0; + double deltaRJetTrack = 0.0; + double signedIP2D = 0.0; + double signedIP2DSign = 0.0; + double signedIPz = 0.0; + double signedIPzSign = 0.0; + double signedIP3D = 0.0; + double signedIP3DSign = 0.0; + double momFraction = 0.0; + double deltaRTrackVertex = 0.0; + double trackPhi = 0.0; + double trackCharge = 0.0; + double trackITSChi2NCl = 0.0; + double trackTPCChi2NCl = 0.0; + double trackITSNCls = 0.0; + double trackTPCNCls = 0.0; + double trackTPCNCrossedRows = 0.0; + int trackOrigin = -1; + int trackVtxIndex = -1; +}; + +struct BJetSVParams { + double svpT = 0.0; + double deltaRSVJet = 0.0; + double svMass = 0.0; + double svfE = 0.0; + double svIPxy = 0.0; + double svCPA = 0.0; + double svChi2PCA = 0.0; + double dispersion = 0.0; + double decayLength2D = 0.0; + double decayLength2DError = 0.0; + double decayLength3D = 0.0; + double decayLength3DError = 0.0; +}; + //________________________________________________________________________ bool isBHadron(int pc) { - std::vector bPdG = {511, 521, 10511, 10521, 513, 523, 10513, 10523, 20513, 20523, 20513, 20523, 515, 525, 531, 10531, 533, 10533, + using o2::constants::physics::Pdg; + std::vector bPdG = {Pdg::kB0, Pdg::kBPlus, 10511, 10521, 513, 523, 10513, 10523, 20513, 20523, 20513, 20523, 515, 525, Pdg::kBS, 10531, 533, 10533, 20533, 535, 541, 10541, 543, 10543, 20543, 545, 551, 10551, 100551, 110551, 200551, 210551, 553, 10553, 20553, 30553, 100553, 110553, 120553, 130553, 200553, 210553, 220553, 300553, 9000533, 9010553, 555, 10555, 20555, - 100555, 110555, 120555, 200555, 557, 100557, 5122, 5112, 5212, 5222, 5114, 5214, 5224, 5132, 5232, 5312, 5322, + 100555, 110555, 120555, 200555, 557, 100557, Pdg::kLambdaB0, 5112, 5212, 5222, 5114, 5214, 5224, 5132, Pdg::kXiB0, 5312, 5322, 5314, 5324, 5332, 5334, 5142, 5242, 5412, 5422, 5414, 5424, 5342, 5432, 5434, 5442, 5444, 5512, 5522, 5514, 5524, 5532, 5534, 5542, 5544, 5554}; @@ -63,9 +133,10 @@ bool isBHadron(int pc) //________________________________________________________________________ bool isCHadron(int pc) { - std::vector bPdG = {411, 421, 10411, 10421, 413, 423, 10413, 10423, 20431, 20423, 415, 425, 431, 10431, 433, 10433, 20433, 435, 441, - 10441, 100441, 443, 10443, 20443, 100443, 30443, 9000443, 9010443, 9020443, 445, 100445, 4122, 4222, 4212, 4112, - 4224, 4214, 4114, 4232, 4132, 4322, 4312, 4324, 4314, 4332, 4334, 4412, 4422, 4414, 4424, 4432, 4434, 4444}; + using o2::constants::physics::Pdg; + std::vector bPdG = {Pdg::kDPlus, Pdg::kD0, Pdg::kD0StarPlus, Pdg::kD0Star0, 413, 423, 10413, 10423, 20431, 20423, Pdg::kD2StarPlus, Pdg::kD2Star0, Pdg::kDS, 10431, Pdg::kDSStar, Pdg::kDS1, 20433, Pdg::kDS2Star, 441, + 10441, 100441, Pdg::kJPsi, 10443, Pdg::kChiC1, 100443, 30443, 9000443, 9010443, 9020443, 445, 100445, Pdg::kLambdaCPlus, Pdg::kSigmaCPlusPlus, 4212, Pdg::kSigmaC0, + 4224, 4214, 4114, Pdg::kXiCPlus, Pdg::kXiC0, 4322, 4312, 4324, 4314, Pdg::kOmegaC0, 4334, 4412, Pdg::kXiCCPlusPlus, 4414, 4424, 4432, 4434, 4444}; return (std::find(bPdG.begin(), bPdG.end(), std::abs(pc)) != bPdG.end()); } @@ -138,7 +209,7 @@ int jetTrackFromHFShower(T const& jet, U const& /*tracks*/, V const& particles, bool hasMcParticle = false; int origin = -1; - for (auto& track : jet.template tracks_as()) { + for (auto const& track : jet.template tracks_as()) { hftrack = track; // for init if origin is 1 or 2, the track is not hftrack if (!track.has_mcParticle()) { continue; @@ -146,12 +217,12 @@ int jetTrackFromHFShower(T const& jet, U const& /*tracks*/, V const& particles, hasMcParticle = true; auto const& particle = track.template mcParticle_as(); origin = RecoDecay::getParticleOrigin(particles, particle, searchUpToQuark); - if (origin == 1 || origin == 2) { // 1=charm , 2=beauty + if (origin == RecoDecay::OriginType::Prompt || origin == RecoDecay::OriginType::NonPrompt) { // 1=charm , 2=beauty hftrack = track; - if (origin == 1) { + if (origin == RecoDecay::OriginType::Prompt) { return JetTaggingSpecies::charm; } - if (origin == 2) { + if (origin == RecoDecay::OriginType::NonPrompt) { return JetTaggingSpecies::beauty; } } @@ -179,12 +250,12 @@ int jetParticleFromHFShower(T const& jet, U const& particles, typename U::iterat for (const auto& particle : jet.template tracks_as()) { hfparticle = particle; // for init if origin is 1 or 2, the particle is not hfparticle origin = RecoDecay::getParticleOrigin(particles, particle, searchUpToQuark); - if (origin == 1 || origin == 2) { // 1=charm , 2=beauty + if (origin == RecoDecay::OriginType::Prompt || origin == RecoDecay::OriginType::NonPrompt) { // 1=charm , 2=beauty hfparticle = particle; - if (origin == 1) { + if (origin == RecoDecay::OriginType::Prompt) { return JetTaggingSpecies::charm; } - if (origin == 2) { + if (origin == RecoDecay::OriginType::NonPrompt) { return JetTaggingSpecies::beauty; } } @@ -284,8 +355,8 @@ int jetOrigin(T const& jet, U const& particles, float dRMax = 0.25) bool firstPartonFound = false; typename U::iterator parton1; typename U::iterator parton2; - for (auto& particle : particles) { - if (std::abs(particle.getGenStatusCode() == 23)) { + for (auto const& particle : particles) { + if (std::abs(particle.getGenStatusCode()) == 23) { if (!firstPartonFound) { parton1 = particle; firstPartonFound = true; @@ -320,15 +391,15 @@ template int16_t getJetFlavor(AnyJet const& jet, AllMCParticles const& mcparticles) { bool charmQuark = false; - for (auto& mcpart : mcparticles) { + for (auto const& mcpart : mcparticles) { int pdgcode = mcpart.pdgCode(); - if (TMath::Abs(pdgcode) == 21 || (TMath::Abs(pdgcode) >= 1 && TMath::Abs(pdgcode) <= 5)) { + if (std::abs(pdgcode) == 21 || (std::abs(pdgcode) >= 1 && std::abs(pdgcode) <= 5)) { double dR = jetutilities::deltaR(jet, mcpart); if (dR < jet.r() / 100.f) { - if (TMath::Abs(pdgcode) == 5) { + if (std::abs(pdgcode) == 5) { return JetTaggingSpecies::beauty; // Beauty jet - } else if (TMath::Abs(pdgcode) == 4) { + } else if (std::abs(pdgcode) == 4) { charmQuark = true; } } @@ -353,7 +424,7 @@ int16_t getJetFlavorHadron(AnyJet const& jet, AllMCParticles const& mcparticles) { bool charmHadron = false; - for (auto& mcpart : mcparticles) { + for (auto const& mcpart : mcparticles) { int pdgcode = mcpart.pdgCode(); if (isBHadron(pdgcode) || isCHadron(pdgcode)) { double dR = jetutilities::deltaR(jet, mcpart); @@ -398,21 +469,17 @@ bool prongAcceptance(T const& prong, float prongChi2PCAMin, float prongChi2PCAMa return false; if (prong.chi2PCA() > prongChi2PCAMax) return false; + if (std::abs(prong.impactParameterXY()) < prongIPxyMin) + return false; + if (std::abs(prong.impactParameterXY()) > prongIPxyMax) + return false; + if (!doXYZ) { if (prong.errorDecayLengthXY() > prongsigmaLxyMax) return false; - if (std::abs(prong.impactParameterXY()) < prongIPxyMin) - return false; - if (std::abs(prong.impactParameterXY()) > prongIPxyMax) - return false; } else { if (prong.errorDecayLength() > prongsigmaLxyMax) return false; - // TODO - if (std::abs(prong.impactParameterXY()) < prongIPxyMin) - return false; - if (std::abs(prong.impactParameterXY()) > prongIPxyMax) - return false; } return true; } @@ -434,12 +501,12 @@ bool svAcceptance(T const& sv, float svDispersionMax) * positive value is expected from secondary vertex * * @param jet - * @param jtrack which is needed aod::JTrackExtras + * @param track which is needed aod::JTrackExtras */ template -int getGeoSign(T const& jet, U const& jtrack) +int getGeoSign(T const& jet, U const& track) { - auto sign = TMath::Sign(1, jtrack.dcaX() * jet.px() + jtrack.dcaY() * jet.py() + jtrack.dcaZ() * jet.pz()); + auto sign = TMath::Sign(1, track.dcaX() * jet.px() + track.dcaY() * jet.py() + track.dcaZ() * jet.pz()); if (sign < -1 || sign > 1) LOGF(info, Form("Sign is %d", sign)); return sign; @@ -450,17 +517,17 @@ int getGeoSign(T const& jet, U const& jtrack) * in a vector in descending order. */ template > -void orderForIPJetTracks(T const& jet, U const& /*jtracks*/, float const& trackDcaXYMax, float const& trackDcaZMax, Vec& vecSignImpSig, bool useIPxyz) +void orderForIPJetTracks(T const& jet, U const& /*tracks*/, float trackDcaXYMax, float trackDcaZMax, Vec& vecSignImpSig, bool useIPxyz) { - for (auto& jtrack : jet.template tracks_as()) { - if (!trackAcceptanceWithDca(jtrack, trackDcaXYMax, trackDcaZMax)) + for (auto const& track : jet.template tracks_as()) { + if (!trackAcceptanceWithDca(track, trackDcaXYMax, trackDcaZMax)) continue; - auto geoSign = getGeoSign(jet, jtrack); + auto geoSign = getGeoSign(jet, track); float varSignImpSig; if (!useIPxyz) { - varSignImpSig = geoSign * std::abs(jtrack.dcaXY()) / jtrack.sigmadcaXY(); + varSignImpSig = geoSign * std::abs(track.dcaXY()) / track.sigmadcaXY(); } else { - varSignImpSig = geoSign * std::abs(jtrack.dcaXYZ()) / jtrack.sigmadcaXYZ(); + varSignImpSig = geoSign * std::abs(track.dcaXYZ()) / track.sigmadcaXYZ(); } vecSignImpSig.push_back(varSignImpSig); } @@ -469,25 +536,32 @@ void orderForIPJetTracks(T const& jet, U const& /*jtracks*/, float const& trackD /** * Checks if a jet is greater than the given tagging working point based on the signed impact parameter significances + * return (true, true, true) if the jet is tagged by the 1st, 2nd and 3rd largest IPs */ template -bool isGreaterThanTaggingPoint(T const& jet, U const& jtracks, float const& trackDcaXYMax, float const& trackDcaZMax, float const& taggingPoint = 1.0, int const& cnt = 1, bool useIPxyz = false) +std::tuple isGreaterThanTaggingPoint(T const& jet, U const& tracks, float trackDcaXYMax, float trackDcaZMax, float taggingPoint = 1.0, bool useIPxyz = false) { - if (cnt == 0) { - return true; // untagged - } + bool taggedIPsN1 = false; + bool taggedIPsN2 = false; + bool taggedIPsN3 = false; std::vector vecSignImpSig; - orderForIPJetTracks(jet, jtracks, trackDcaXYMax, trackDcaZMax, vecSignImpSig, useIPxyz); - if (vecSignImpSig.size() > static_cast::size_type>(cnt) - 1) { - for (int i = 0; i < cnt; i++) { - if (vecSignImpSig[i] < taggingPoint) { // tagger point set - return false; - } + orderForIPJetTracks(jet, tracks, trackDcaXYMax, trackDcaZMax, vecSignImpSig, useIPxyz); + if (vecSignImpSig.size() > 0) { + if (vecSignImpSig[0] > taggingPoint) { // tagger point set + taggedIPsN1 = true; } - } else { - return false; } - return true; + if (vecSignImpSig.size() > 1) { + if (vecSignImpSig[1] > taggingPoint) { // tagger point set + taggedIPsN2 = true; + } + } + if (vecSignImpSig.size() > 2) { + if (vecSignImpSig[2] > taggingPoint) { // tagger point set + taggedIPsN3 = true; + } + } + return std::make_tuple(taggedIPsN1, taggedIPsN2, taggedIPsN3); } /** @@ -523,10 +597,10 @@ std::unique_ptr setResolutionFunction(T const& vecParams) * impact parameter significance. */ template -float getTrackProbability(T const& fResoFuncjet, U const& track, const float& minSignImpXYSig = -40) +float getTrackProbability(T const& fResoFuncjet, U const& track, float minSignImpXYSig = -40) { float probTrack = 0; - auto varSignImpXYSig = TMath::Abs(track.dcaXY()) / track.sigmadcaXY(); + auto varSignImpXYSig = std::abs(track.dcaXY()) / track.sigmadcaXY(); if (-varSignImpXYSig < minSignImpXYSig) varSignImpXYSig = -minSignImpXYSig - 0.01; // To avoid overflow for integral probTrack = fResoFuncjet->Integral(minSignImpXYSig, -varSignImpXYSig) / fResoFuncjet->Integral(minSignImpXYSig, 0); @@ -544,7 +618,7 @@ float getTrackProbability(T const& fResoFuncjet, U const& track, const float& mi * assess its probability based on the impact parameter significance. * @param collision: The collision event data, necessary for geometric sign calculations. * @param jet: The jet for which the probability is being calculated. - * @param jtracks: Tracks in jets + * @param tracks: Tracks in jets * @param cnt: ordering number of impact parameter cnt=0: untagged, cnt=1: first, cnt=2: seconde, cnt=3: third. * @param tagPoint: tagging working point which is selected by condiered efficiency and puriy * @param minSignImpXYSig: To avoid over fitting @@ -553,43 +627,89 @@ float getTrackProbability(T const& fResoFuncjet, U const& track, const float& mi * geometric sign. */ template -float getJetProbability(T const& fResoFuncjet, U const& jet, V const& jtracks, float const& trackDcaXYMax, float const& trackDcaZMax, const int& cnt, const float& tagPoint = 1.0, const float& minSignImpXYSig = -10, bool useIPxy = true) +float getJetProbability(T const& fResoFuncjet, U const& jet, V const& /*tracks*/, float trackDcaXYMax, float trackDcaZMax, float minSignImpXYSig = -10) { - if (!(isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPoint, cnt, useIPxy))) + std::vector jetTracksPt; + float trackjetProb = 1.; + + for (auto const& track : jet.template tracks_as()) { + if (!trackAcceptanceWithDca(track, trackDcaXYMax, trackDcaZMax)) + continue; + + float probTrack = getTrackProbability(fResoFuncjet, track, minSignImpXYSig); + + auto geoSign = getGeoSign(jet, track); + if (geoSign > 0) { // only take positive sign track for JP calculation + trackjetProb *= probTrack; + jetTracksPt.push_back(track.pt()); + } + } + + float jetProb = -1.; + if (jetTracksPt.size() < 2) return -1; + float sumjetProb = 0.; + for (std::vector::size_type i = 0; i < jetTracksPt.size(); i++) { + sumjetProb += (std::pow(-1 * std::log(trackjetProb), static_cast(i)) / TMath::Factorial(i)); + } + + jetProb = trackjetProb * sumjetProb; + return jetProb; +} + +// overloading for the case of using resolution function for each pt range +template +float getJetProbability(std::vector> const& fResoFuncjets, U const& jet, V const& /*tracks*/, float trackDcaXYMax, float trackDcaZMax, float minSignImpXYSig = -10) +{ std::vector jetTracksPt; float trackjetProb = 1.; - for (auto& jtrack : jet.template tracks_as()) { - if (!trackAcceptanceWithDca(jtrack, trackDcaXYMax, trackDcaZMax)) + for (auto const& track : jet.template tracks_as()) { + if (!trackAcceptanceWithDca(track, trackDcaXYMax, trackDcaZMax)) continue; - float probTrack = getTrackProbability(fResoFuncjet, jtrack, minSignImpXYSig); + float probTrack = -1; + // choose the proper resolution function for the track based on its pt. + if (track.pt() >= 0.0 && track.pt() < 0.5) { + probTrack = getTrackProbability(fResoFuncjets.at(0), track, minSignImpXYSig); + } else if (track.pt() >= 0.5 && track.pt() < 1.0) { + probTrack = getTrackProbability(fResoFuncjets.at(1), track, minSignImpXYSig); + } else if (track.pt() >= 1.0 && track.pt() < 2.0) { + probTrack = getTrackProbability(fResoFuncjets.at(2), track, minSignImpXYSig); + } else if (track.pt() >= 2.0 && track.pt() < 4.0) { + probTrack = getTrackProbability(fResoFuncjets.at(3), track, minSignImpXYSig); + } else if (track.pt() >= 4.0 && track.pt() < 6.0) { + probTrack = getTrackProbability(fResoFuncjets.at(4), track, minSignImpXYSig); + } else if (track.pt() >= 6.0 && track.pt() < 9.0) { + probTrack = getTrackProbability(fResoFuncjets.at(5), track, minSignImpXYSig); + } else if (track.pt() >= 9.0) { + probTrack = getTrackProbability(fResoFuncjets.at(6), track, minSignImpXYSig); + } - auto geoSign = getGeoSign(jet, jtrack); + auto geoSign = getGeoSign(jet, track); if (geoSign > 0) { // only take positive sign track for JP calculation trackjetProb *= probTrack; - jetTracksPt.push_back(jtrack.pt()); + jetTracksPt.push_back(track.pt()); } } - float JP = -1.; + float jetProb = -1.; if (jetTracksPt.size() < 2) return -1; float sumjetProb = 0.; for (std::vector::size_type i = 0; i < jetTracksPt.size(); i++) { - sumjetProb += (TMath::Power(-1 * TMath::Log(trackjetProb), static_cast(i)) / TMath::Factorial(i)); + sumjetProb += (std::pow(-1 * std::log(trackjetProb), static_cast(i)) / TMath::Factorial(i)); } - JP = trackjetProb * sumjetProb; - return JP; + jetProb = trackjetProb * sumjetProb; + return jetProb; } // For secaondy vertex method utilites template -typename ProngType::iterator jetFromProngMaxDecayLength(const JetType& jet, float const& prongChi2PCAMin, float const& prongChi2PCAMax, float const& prongsigmaLxyMax, float const& prongIPxyMin, float const& prongIPxyMax, const bool& doXYZ = false, bool* checkSv = nullptr) +typename ProngType::iterator jetFromProngMaxDecayLength(const JetType& jet, float const& prongChi2PCAMin, float prongChi2PCAMax, float prongsigmaLxyMax, float prongIPxyMin, float prongIPxyMax, bool doXYZ = false, bool* checkSv = nullptr) { if (checkSv) *checkSv = false; @@ -599,13 +719,14 @@ typename ProngType::iterator jetFromProngMaxDecayLength(const JetType& jet, floa if (!prongAcceptance(prong, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, doXYZ)) continue; *checkSv = true; - float Sxy = -1.0f; + float sxy = -1.0f; if (!doXYZ) { - Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); + sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); } else { - Sxy = prong.decayLength() / prong.errorDecayLength(); + sxy = prong.decayLength() / prong.errorDecayLength(); } - if (maxSxy < Sxy) { + if (maxSxy < sxy) { + maxSxy = sxy; bjetCand = prong; } } @@ -613,7 +734,7 @@ typename ProngType::iterator jetFromProngMaxDecayLength(const JetType& jet, floa } template -bool isTaggedJetSV(T const jet, U const& /*prongs*/, float const& prongChi2PCAMin, float const& prongChi2PCAMax, float const& prongsigmaLxyMax, float const& prongIPxyMin, float const& prongIPxyMax, float svDispersionMax, float const& doXYZ = false, float const& tagPointForSV = 15.) +bool isTaggedJetSV(T const jet, U const& /*prongs*/, float prongChi2PCAMin, float prongChi2PCAMax, float prongsigmaLxyMax, float prongIPxyMin, float prongIPxyMax, float svDispersionMax, float doXYZ = false, float tagPointForSV = 15.) { bool checkSv = false; auto bjetCand = jetFromProngMaxDecayLength(jet, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, doXYZ, &checkSv); @@ -631,6 +752,47 @@ bool isTaggedJetSV(T const jet, U const& /*prongs*/, float const& prongChi2PCAMi return true; } +template +uint16_t setTaggingIPBit(T const& jet, U const& tracks, V trackDcaXYMax, V trackDcaZMax, V tagPointForIP) +{ + uint16_t bit = 0; + auto [taggedIPsN1, taggedIPsN2, taggedIPsN3] = isGreaterThanTaggingPoint(jet, tracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, false); + if (taggedIPsN1) { + SETBIT(bit, BJetTaggingMethod::IPsN1); + } + if (taggedIPsN2) { + SETBIT(bit, BJetTaggingMethod::IPsN2); + } + if (taggedIPsN3) { + SETBIT(bit, BJetTaggingMethod::IPsN3); + } + + auto [taggedIPs3DN1, taggedIPs3DN2, taggedIPs3DN3] = isGreaterThanTaggingPoint(jet, tracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, true); + if (taggedIPs3DN1) { + SETBIT(bit, BJetTaggingMethod::IPs3DN1); + } + if (taggedIPs3DN2) { + SETBIT(bit, BJetTaggingMethod::IPs3DN2); + } + if (taggedIPs3DN3) { + SETBIT(bit, BJetTaggingMethod::IPs3DN3); + } + return bit; +} + +template +uint16_t setTaggingSVBit(T const& jet, U const& prongs, V prongChi2PCAMin, V prongChi2PCAMax, V prongsigmaLxyMax, float prongIPxyMin, float prongIPxyMax, V svDispersionMax, V tagPointForSV) +{ + uint16_t bit = 0; + if (isTaggedJetSV(jet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, svDispersionMax, false, tagPointForSV)) { + SETBIT(bit, BJetTaggingMethod::SV); + } + if (isTaggedJetSV(jet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, svDispersionMax, true, tagPointForSV)) { + SETBIT(bit, BJetTaggingMethod::SV3D); + } + return bit; +} + /** * Clusters jet constituent tracks into groups of tracks originating from same mcParticle position (trkVtxIndex), and finds each track origin (trkOrigin). (for GNN b-jet tagging) * @param trkLabels Track labels for GNN vertex and track origin predictions. trkVtxIndex: The index value of each vertex (cluster) which is determined by the function. trkOrigin: The category of the track origin (0: not physical primary, 1: charm, 2: beauty, 3: primary vertex, 4: other secondary vertex). @@ -642,7 +804,7 @@ template >& trkLabels, bool searchUpToQuark, float vtxResParam = 0.01 /* 0.01cm = 100um */, float trackPtMin = 0.5) { const auto& tracks = jet.template tracks_as(); - const int n_trks = tracks.size(); + const int nTrks = tracks.size(); // trkVtxIndex @@ -656,32 +818,32 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT tempTrkVtxIndex.push_back(i++); } tempTrkVtxIndex.push_back(i); // temporary index for PV - if (n_trks < 1) { // the process should be done for n_trks == 1 as well + if (nTrks < 1) { // the process should be done for nTrks == 1 as well trkLabels["trkVtxIndex"] = tempTrkVtxIndex; - return n_trks; + return nTrks; } - int n_pos = n_trks + 1; - std::vector dists(n_pos * (n_pos - 1) / 2); - auto trk_pair_idx = [n_pos](int ti, int tj) { - if (ti == tj || ti >= n_pos || tj >= n_pos || ti < 0 || tj < 0) { + int nPos = nTrks + 1; + std::vector dists(nPos * (nPos - 1) / 2); + auto trkPairIdx = [nPos](int ti, int tj) { + if (ti == tj || ti >= nPos || tj >= nPos || ti < 0 || tj < 0) { LOGF(info, "Track pair index out of range"); return -1; } else { - return (ti < tj) ? (ti * n_pos - (ti * (ti + 1)) / 2 + tj - ti - 1) : (tj * n_pos - (tj * (tj + 1)) / 2 + ti - tj - 1); + return (ti < tj) ? (ti * nPos - (ti * (ti + 1)) / 2 + tj - ti - 1) : (tj * nPos - (tj * (tj + 1)) / 2 + ti - tj - 1); } - }; // index n_trks is for PV + }; // index nTrks is for PV - for (int ti = 0; ti < n_pos - 1; ti++) - for (int tj = ti + 1; tj < n_pos; tj++) { + for (int ti = 0; ti < nPos - 1; ti++) + for (int tj = ti + 1; tj < nPos; tj++) { std::array posi, posj; - if (tj < n_trks) { + if (tj < nTrks) { if (tracks[tj].has_mcParticle()) { const auto& pj = tracks[tj].template mcParticle_as().template mcParticle_as(); posj = std::array{pj.vx(), pj.vy(), pj.vz()}; } else { - dists[trk_pair_idx(ti, tj)] = std::numeric_limits::max(); + dists[trkPairIdx(ti, tj)] = std::numeric_limits::max(); continue; } } else { @@ -692,24 +854,24 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT const auto& pi = tracks[ti].template mcParticle_as().template mcParticle_as(); posi = std::array{pi.vx(), pi.vy(), pi.vz()}; } else { - dists[trk_pair_idx(ti, tj)] = std::numeric_limits::max(); + dists[trkPairIdx(ti, tj)] = std::numeric_limits::max(); continue; } - dists[trk_pair_idx(ti, tj)] = RecoDecay::distance(posi, posj); + dists[trkPairIdx(ti, tj)] = RecoDecay::distance(posi, posj); } int clusteri = -1, clusterj = -1; - float min_min_dist = -1.f; // If there is an not-merge-able min_dist pair, check the 2nd-min_dist pair. + float minMinDist = -1.f; // If there is an not-merge-able minDist pair, check the 2nd-minDist pair. while (true) { - float min_dist = -1.f; // Get min_dist pair - for (int ti = 0; ti < n_pos - 1; ti++) - for (int tj = ti + 1; tj < n_pos; tj++) + float minDist = -1.f; // Get minDist pair + for (int ti = 0; ti < nPos - 1; ti++) + for (int tj = ti + 1; tj < nPos; tj++) if (tempTrkVtxIndex[ti] != tempTrkVtxIndex[tj] && tempTrkVtxIndex[ti] >= 0 && tempTrkVtxIndex[tj] >= 0) { - float dist = dists[trk_pair_idx(ti, tj)]; - if ((dist < min_dist || min_dist < 0.f) && dist > min_min_dist) { - min_dist = dist; + float dist = dists[trkPairIdx(ti, tj)]; + if ((dist < minDist || minDist < 0.f) && dist > minMinDist) { + minDist = dist; clusteri = ti; clusterj = tj; } @@ -718,59 +880,59 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT break; bool mrg = true; // Merge-ability check - for (int ti = 0; ti < n_pos && mrg; ti++) + for (int ti = 0; ti < nPos && mrg; ti++) if (tempTrkVtxIndex[ti] == tempTrkVtxIndex[clusteri] && tempTrkVtxIndex[ti] >= 0) { - for (int tj = 0; tj < n_pos && mrg; tj++) + for (int tj = 0; tj < nPos && mrg; tj++) if (tj != ti && tempTrkVtxIndex[tj] == tempTrkVtxIndex[clusterj] && tempTrkVtxIndex[tj] >= 0) { - if (dists[trk_pair_idx(ti, tj)] > vtxResParam) { // If there is more distant pair compared to vtx_res between two clusters, they cannot be merged. + if (dists[trkPairIdx(ti, tj)] > vtxResParam) { // If there is more distant pair compared to vtx_res between two clusters, they cannot be merged. mrg = false; - min_min_dist = min_dist; + minMinDist = minDist; } } } - if (min_dist > vtxResParam || min_dist < 0.f) + if (minDist > vtxResParam || minDist < 0.f) break; if (mrg) { // Merge two clusters - int old_index = tempTrkVtxIndex[clusterj]; - for (int t = 0; t < n_pos; t++) - if (tempTrkVtxIndex[t] == old_index) + int oldIndex = tempTrkVtxIndex[clusterj]; + for (int t = 0; t < nPos; t++) + if (tempTrkVtxIndex[t] == oldIndex) tempTrkVtxIndex[t] = tempTrkVtxIndex[clusteri]; } } - int n_vertices = 0; + int nVertices = 0; // Sort the indices from PV (as 0) to the most distant SV (as 1~). - int idxPV = tempTrkVtxIndex[n_trks]; - for (int t = 0; t < n_trks; t++) + int idxPV = tempTrkVtxIndex[nTrks]; + for (int t = 0; t < nTrks; t++) if (tempTrkVtxIndex[t] == idxPV) { tempTrkVtxIndex[t] = -2; - n_vertices = 1; // There is a track originating from PV + nVertices = 1; // There is a track originating from PV } std::unordered_map avgDistances; std::unordered_map count; - for (int t = 0; t < n_trks; t++) { + for (int t = 0; t < nTrks; t++) { if (tempTrkVtxIndex[t] >= 0) { - avgDistances[tempTrkVtxIndex[t]] += dists[trk_pair_idx(t, n_trks)]; + avgDistances[tempTrkVtxIndex[t]] += dists[trkPairIdx(t, nTrks)]; count[tempTrkVtxIndex[t]]++; } } - trkLabels["trkVtxIndex"] = std::vector(n_trks, -1); - if (count.size() != 0) { // If there is any SV cluster not only PV cluster - for (auto& [idx, avgDistance] : avgDistances) + trkLabels["trkVtxIndex"] = std::vector(nTrks, -1); + if (count.size() != 0) { // If there is any SV cluster not only PV cluster + for (auto& [idx, avgDistance] : avgDistances) // o2-linter: disable=const-ref-in-for-loop avgDistance /= count[idx]; - n_vertices += avgDistances.size(); + nVertices += avgDistances.size(); std::vector> sortedIndices(avgDistances.begin(), avgDistances.end()); std::sort(sortedIndices.begin(), sortedIndices.end(), [](const auto& a, const auto& b) { return a.second < b.second; }); int rank = 1; - for (const auto& [idx, avgDistance] : sortedIndices) { + for (auto const& [idx, avgDistance] : sortedIndices) { bool found = false; - for (int t = 0; t < n_trks; t++) + for (int t = 0; t < nTrks; t++) if (tempTrkVtxIndex[t] == idx) { trkLabels["trkVtxIndex"][t] = rank; found = true; @@ -779,14 +941,14 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT } } - for (int t = 0; t < n_trks; t++) + for (int t = 0; t < nTrks; t++) if (tempTrkVtxIndex[t] == -2) trkLabels["trkVtxIndex"][t] = 0; // trkOrigin int trkIdx = 0; - for (auto& constituent : jet.template tracks_as()) { + for (auto const& constituent : jet.template tracks_as()) { if (!constituent.has_mcParticle() || !constituent.template mcParticle_as().isPhysicalPrimary() || constituent.pt() < trackPtMin) { trkLabels["trkOrigin"].push_back(0); } else { @@ -799,7 +961,154 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT trkIdx++; } - return n_vertices; + return nVertices; +} + +// Looping over the SV info and putting them in the input vector +template +void analyzeJetSVInfo4ML(AnalysisJet const& myJet, AnyTracks const& /*allTracks*/, SecondaryVertices const& /*allSVs*/, std::vector& svsParams, float svPtMin = 1.0, int svReductionFactor = 3) +{ + using SVType = typename SecondaryVertices::iterator; + + // Min-heap to store the top 30 SVs by decayLengthXY/errorDecayLengthXY + auto compare = [](SVType& sv1, SVType& sv2) { + return (sv1.decayLengthXY() / sv1.errorDecayLengthXY()) > (sv2.decayLengthXY() / sv2.errorDecayLengthXY()); + }; + + auto svs = myJet.template secondaryVertices_as(); + + // Sort the SVs based on their decay length significance in descending order + // This is needed in order to select longest SVs since some jets could have thousands of SVs + std::sort(svs.begin(), svs.end(), compare); + + for (const auto& candSV : svs) { + + if (candSV.pt() < svPtMin) { + continue; + } + + double deltaRJetSV = jetutilities::deltaR(myJet, candSV); + double massSV = candSV.m(); + double energySV = candSV.e(); + + if (svsParams.size() < (svReductionFactor * myJet.template tracks_as().size())) { + svsParams.emplace_back(BJetSVParams{candSV.pt(), deltaRJetSV, massSV, energySV / myJet.energy(), candSV.impactParameterXY(), candSV.cpa(), candSV.chi2PCA(), candSV.dispersion(), candSV.decayLengthXY(), candSV.errorDecayLengthXY(), candSV.decayLength(), candSV.errorDecayLength()}); + } + } +} + +// Looping over the track info and putting them in the input vector +template +void analyzeJetTrackInfo4ML(AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, SecondaryVertices const& /*allSVs*/, std::vector& tracksParams, float trackPtMin = 0.5, float trackDcaXYMax = 10.0, float trackDcaZMax = 10.0) +{ + for (const auto& constituent : analysisJet.template tracks_as()) { + + if (constituent.pt() < trackPtMin || !trackAcceptanceWithDca(constituent, trackDcaXYMax, trackDcaZMax)) { + continue; + } + + double deltaRJetTrack = jetutilities::deltaR(analysisJet, constituent); + double dotProduct = RecoDecay::dotProd(std::array{analysisJet.px(), analysisJet.py(), analysisJet.pz()}, std::array{constituent.px(), constituent.py(), constituent.pz()}); + int sign = getGeoSign(analysisJet, constituent); + + float rClosestSV = 10.; + for (const auto& candSV : analysisJet.template secondaryVertices_as()) { + double deltaRTrackSV = jetutilities::deltaR(constituent, candSV); + if (deltaRTrackSV < rClosestSV) { + rClosestSV = deltaRTrackSV; + } + } + + tracksParams.emplace_back(BJetTrackParams{constituent.pt(), constituent.eta(), dotProduct, dotProduct / analysisJet.p(), deltaRJetTrack, std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaZ()) * sign, constituent.sigmadcaZ(), std::abs(constituent.dcaXYZ()) * sign, constituent.sigmadcaXYZ(), constituent.p() / analysisJet.p(), rClosestSV}); + } + + auto compare = [](BJetTrackParams& tr1, BJetTrackParams& tr2) { + return (tr1.signedIP2D / tr1.signedIP2DSign) > (tr2.signedIP2D / tr2.signedIP2DSign); + }; + + // Sort the tracks based on their IP significance in descending order + std::sort(tracksParams.begin(), tracksParams.end(), compare); +} + +// Looping over the track info and putting them in the input vector without using any SV info +template +void analyzeJetTrackInfo4MLnoSV(AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, std::vector& tracksParams, float trackPtMin = 0.5, float trackDcaXYMax = 10.0, float trackDcaZMax = 10.0) +{ + for (const auto& constituent : analysisJet.template tracks_as()) { + + if (constituent.pt() < trackPtMin || !trackAcceptanceWithDca(constituent, trackDcaXYMax, trackDcaZMax)) { + continue; + } + + double deltaRJetTrack = jetutilities::deltaR(analysisJet, constituent); + double dotProduct = RecoDecay::dotProd(std::array{analysisJet.px(), analysisJet.py(), analysisJet.pz()}, std::array{constituent.px(), constituent.py(), constituent.pz()}); + int sign = getGeoSign(analysisJet, constituent); + + tracksParams.emplace_back(BJetTrackParams{constituent.pt(), constituent.eta(), dotProduct, dotProduct / analysisJet.p(), deltaRJetTrack, std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaZ()) * sign, constituent.sigmadcaZ(), std::abs(constituent.dcaXYZ()) * sign, constituent.sigmadcaXYZ(), constituent.p() / analysisJet.p(), 0.0}); + } + + auto compare = [](BJetTrackParams& tr1, BJetTrackParams& tr2) { + return (tr1.signedIP2D / tr1.signedIP2DSign) > (tr2.signedIP2D / tr2.signedIP2DSign); + }; + + // Sort the tracks based on their IP significance in descending order + std::sort(tracksParams.begin(), tracksParams.end(), compare); +} + +// Looping over the track info and putting them in the input vector (for GNN b-jet tagging) +template +void analyzeJetTrackInfo4GNN(AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, AnyOriginalTracks const& /*origTracks*/, std::vector>& tracksParams, float trackPtMin = 0.5, int64_t nMaxConstit = 40) +{ + for (const auto& constituent : analysisJet.template tracks_as()) { + + if (constituent.pt() < trackPtMin) { + continue; + } + + int sign = getGeoSign(analysisJet, constituent); + + auto origConstit = constituent.template track_as(); + + if (static_cast(tracksParams.size()) < nMaxConstit) { + tracksParams.emplace_back(std::vector{constituent.pt(), origConstit.phi(), constituent.eta(), static_cast(constituent.sign()), std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaXYZ()) * sign, constituent.sigmadcaXYZ(), static_cast(origConstit.itsNCls()), static_cast(origConstit.tpcNClsFound()), static_cast(origConstit.tpcNClsCrossedRows()), origConstit.itsChi2NCl(), origConstit.tpcChi2NCl()}); + } else { + // If there are more than nMaxConstit constituents in the jet, select only nMaxConstit constituents with the highest DCA_XY significance. + size_t minIdx = 0; + for (size_t i = 0; i < tracksParams.size(); ++i) { + if (tracksParams[i][4] / tracksParams[i][5] < tracksParams[minIdx][4] / tracksParams[minIdx][5]) + minIdx = i; + } + if (std::abs(constituent.dcaXY()) * sign / constituent.sigmadcaXY() > tracksParams[minIdx][4] / tracksParams[minIdx][5]) + tracksParams[minIdx] = std::vector{constituent.pt(), origConstit.phi(), constituent.eta(), static_cast(constituent.sign()), std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaXYZ()) * sign, constituent.sigmadcaXYZ(), static_cast(origConstit.itsNCls()), static_cast(origConstit.tpcNClsFound()), static_cast(origConstit.tpcNClsCrossedRows()), origConstit.itsChi2NCl(), origConstit.tpcChi2NCl()}; + } + } +} + +// Discriminant value for GNN b-jet tagging +template +T getDb(const std::vector& logits, double fC = 0.018) +{ + auto softmax = [](const std::vector& logits) { + std::vector res; + T maxLogit = *std::max_element(logits.begin(), logits.end()); + T sumLogit = 0.; + for (size_t i = 0; i < logits.size(); ++i) { + res.push_back(std::exp(logits[i] - maxLogit)); + sumLogit += res[i]; + } + for (size_t i = 0; i < logits.size(); ++i) { + res[i] /= sumLogit; + } + return res; + }; + + std::vector softmaxLogits = softmax(logits); + + if (softmaxLogits[1] == 0. && softmaxLogits[2] == 0.) { + LOG(debug) << "jettaggingutilities::Db, Divide by zero: softmaxLogits = (" << softmaxLogits[0] << ", " << softmaxLogits[1] << ", " << softmaxLogits[2] << ")"; + } + + return std::log(softmaxLogits[0] / (fC * softmaxLogits[1] + (1. - fC) * softmaxLogits[2])); } }; // namespace jettaggingutilities diff --git a/PWGJE/Core/JetUtilities.h b/PWGJE/Core/JetUtilities.h index f1db864ef25..0efaf1fd8f9 100644 --- a/PWGJE/Core/JetUtilities.h +++ b/PWGJE/Core/JetUtilities.h @@ -18,16 +18,19 @@ #ifndef PWGJE_CORE_JETUTILITIES_H_ #define PWGJE_CORE_JETUTILITIES_H_ +#include "Common/Core/RecoDecay.h" + +#include + +#include #include +#include #include -#include +#include #include #include -#include - -#include "Framework/Logger.h" -#include "Common/Core/RecoDecay.h" +#include namespace jetutilities { @@ -73,11 +76,6 @@ std::tuple>, std::vector>> MatchCl throw std::invalid_argument("track collection eta and phi sizes don't match. Check the inputs."); } - // for (std::size_t iTrack = 0; iTrack < nTracks; iTrack++) { - // if (trackEta[iTrack] == 0) - // LOG(warning) << "Track eta is 0!"; - // } - // Build the KD-trees using vectors // We build two trees: // treeBase, which contains the base collection. diff --git a/PWGJE/Core/JetV0Utilities.h b/PWGJE/Core/JetV0Utilities.h index 3d12cd5d0a3..e7495242e01 100644 --- a/PWGJE/Core/JetV0Utilities.h +++ b/PWGJE/Core/JetV0Utilities.h @@ -17,33 +17,20 @@ #ifndef PWGJE_CORE_JETV0UTILITIES_H_ #define PWGJE_CORE_JETV0UTILITIES_H_ -#include -#include -#include -#include +#include "PWGJE/DataModel/Jet.h" + +#include "Common/Core/RecoDecay.h" + +#include #include -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include "Framework/Logger.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGJE/DataModel/EMCALClusters.h" - -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" -#include "PWGHF/DataModel/DerivedTables.h" - -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/DataModel/Jet.h" +#include + +#include +#include +#include +#include namespace jetv0utilities { diff --git a/PWGJE/Core/MlResponseHfTagging.h b/PWGJE/Core/MlResponseHfTagging.h new file mode 100644 index 00000000000..2b07e1c1c25 --- /dev/null +++ b/PWGJE/Core/MlResponseHfTagging.h @@ -0,0 +1,479 @@ +// 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. + +/// \file MlResponseHfTagging.h +/// \brief Class to compute the ML response for b-jet analysis +/// \author Hadi Hassan , University of Jyväskylä + +#ifndef PWGJE_CORE_MLRESPONSEHFTAGGING_H_ +#define PWGJE_CORE_MLRESPONSEHFTAGGING_H_ + +#include "Tools/ML/MlResponse.h" + +#include + +#include + +#include + +#include +#include +#include +#include + +// Fill the map of available input features +// the key is the feature's name (std::string) +// the value is the corresponding value in EnumInputFeatures +#define FILL_MAP_BJET(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesBTag::FEATURE) \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the VECTOR vector is filled with the FEATURE's value +// by calling the corresponding GETTER from OBJECT +#define CHECK_AND_FILL_VEC_BTAG_FULL(VECTOR, OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesBTag::FEATURE): { \ + VECTOR.emplace_back(OBJECT.GETTER); \ + break; \ + } + +// Specific case of CHECK_AND_FILL_VEC_BTAG_FULL(VECTOR, OBJECT, FEATURE, GETTER) +// where FEATURE = GETTER +#define CHECK_AND_FILL_VEC_BTAG(VECTOR, OBJECT, GETTER) \ + case static_cast(InputFeaturesBTag::GETTER): { \ + VECTOR.emplace_back(OBJECT.GETTER); \ + break; \ + } + +namespace o2::analysis +{ +enum class InputFeaturesBTag : uint8_t { + jetpT = 0, + jetEta, + jetPhi, + nTracks, + nSV, + jetMass, + trackpT, + trackEta, + dotProdTrackJet, + dotProdTrackJetOverJet, + deltaRJetTrack, + signedIP2D, + signedIP2DSign, + signedIPz, + signedIPzSign, + signedIP3D, + signedIP3DSign, + momFraction, + deltaRTrackVertex, + trackPhi, + trackCharge, + trackITSChi2NCl, + trackTPCChi2NCl, + trackITSNCls, + trackTPCNCls, + trackTPCNCrossedRows, + trackOrigin, + trackVtxIndex, + svpT, + deltaRSVJet, + svMass, + svfE, + svIPxy, + svCPA, + svChi2PCA, + dispersion, + decayLength2D, + decayLength2DError, + decayLength3D, + decayLength3DError, +}; + +template +class MlResponseHfTagging : public MlResponse +{ + public: + /// Default constructor + MlResponseHfTagging() = default; + /// Default destructor + virtual ~MlResponseHfTagging() = default; + + /// @brief Method to get the input shape of the model + /// @return A vector of input shapes + std::vector> getInputShape() const { return this->mModels[0].getInputShapes(); } + + /// @brief Method to get the output shape of a model + /// \param imod is the index of the model + /// @return number of output nodes + int getOutputNodes(int imod = 0) const { return this->mModels[imod].getNumOutputNodes(); } + + /// Method to fill the inputs of jet, tracks and secondary vertices + /// \param jet is the b-jet candidate + /// \param tracks is the vector of tracks associated to the jet + /// \param svs is the vector of secondary vertices associated to the jet + /// \param jetInput the jet input features vector to be filled + /// \param trackInput the tracks input features vector to be filled + /// \param svInput the SVs input features vector to be filled + template + void fillInputFeatures(T1 const& jet, std::vector const& tracks, std::vector const& svs, std::vector& jetInput, std::vector& trackInput, std::vector& svInput) + { + + // Jet features + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_BTAG(jetInput, jet, jetpT) + CHECK_AND_FILL_VEC_BTAG(jetInput, jet, jetEta) + CHECK_AND_FILL_VEC_BTAG(jetInput, jet, jetPhi) + CHECK_AND_FILL_VEC_BTAG(jetInput, jet, nTracks) + CHECK_AND_FILL_VEC_BTAG(jetInput, jet, nSV) + CHECK_AND_FILL_VEC_BTAG(jetInput, jet, jetMass) + + default: + break; + } + } + + // Track features + for (const auto& track : tracks) { + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackpT) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackEta) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, dotProdTrackJet) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, dotProdTrackJetOverJet) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, deltaRJetTrack) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, signedIP2D) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, signedIP2DSign) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, signedIPz) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, signedIPzSign) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, signedIP3D) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, signedIP3DSign) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, momFraction) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, deltaRTrackVertex) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackPhi) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackCharge) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackITSChi2NCl) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackTPCChi2NCl) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackITSNCls) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackTPCNCls) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackTPCNCrossedRows) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackOrigin) + CHECK_AND_FILL_VEC_BTAG(trackInput, track, trackVtxIndex) + + default: + break; + } + } + } + + // Secondary vertex features + for (const auto& sv : svs) { + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_BTAG(svInput, sv, svpT) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, deltaRSVJet) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, svMass) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, svfE) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, svIPxy) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, svCPA) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, svChi2PCA) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, dispersion) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, decayLength2D) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, decayLength2DError) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, decayLength3D) + CHECK_AND_FILL_VEC_BTAG(svInput, sv, decayLength3DError) + + default: + break; + } + } + } + } + + /// @brief Method to replace NaN and infinity values in a vector with a specified value + /// @param vec is the vector to be processed + /// @param value is the value to replace NaN values with + /// @return the number of NaN values replaced + template + static int replaceNaN(std::vector& vec, T value) + { + int numNaN = 0; + for (auto& el : vec) { + if (std::isnan(el) || std::isinf(el)) { + el = value; + ++numNaN; + } + } + return numNaN; + } + + /// Method to get the input features vector needed for ML inference in a 2D vector + /// \param jet is the b-jet candidate + /// \param tracks is the vector of tracks associated to the jet + /// \param svs is the vector of secondary vertices associated to the jet + /// \return inputFeatures vector + template + std::vector> getInputFeatures2D(T1 const& jet, std::vector const& tracks, std::vector const& svs) + { + + std::vector jetInput; + std::vector trackInput; + std::vector svInput; + + fillInputFeatures(jet, tracks, svs, jetInput, trackInput, svInput); + + std::vector> inputFeatures; + + replaceNaN(jetInput, 0.f); + replaceNaN(trackInput, 0.f); + replaceNaN(svInput, 0.f); + + inputFeatures.push_back(jetInput); + inputFeatures.push_back(trackInput); + inputFeatures.push_back(svInput); + + return inputFeatures; + } + + /// Method to get the input features vector needed for ML inference in a 1D vector + /// \param jet is the b-jet candidate + /// \param tracks is the vector of tracks associated to the jet + /// \param svs is the vector of secondary vertices associated to the jet + /// \return inputFeatures vector + template + std::vector getInputFeatures1D(T1 const& jet, std::vector const& tracks, std::vector const& svs) + { + + std::vector jetInput; + std::vector trackInput; + std::vector svInput; + + fillInputFeatures(jet, tracks, svs, jetInput, trackInput, svInput); + + std::vector inputFeatures; + + inputFeatures.insert(inputFeatures.end(), jetInput.begin(), jetInput.end()); + inputFeatures.insert(inputFeatures.end(), trackInput.begin(), trackInput.end()); + inputFeatures.insert(inputFeatures.end(), svInput.begin(), svInput.end()); + + replaceNaN(inputFeatures, 0.f); + + return inputFeatures; + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + // Jet features + FILL_MAP_BJET(jetpT), + FILL_MAP_BJET(jetEta), + FILL_MAP_BJET(jetPhi), + FILL_MAP_BJET(nTracks), + FILL_MAP_BJET(nSV), + FILL_MAP_BJET(jetMass), + + // Track features + FILL_MAP_BJET(trackpT), + FILL_MAP_BJET(trackEta), + FILL_MAP_BJET(dotProdTrackJet), + FILL_MAP_BJET(dotProdTrackJetOverJet), + FILL_MAP_BJET(deltaRJetTrack), + FILL_MAP_BJET(signedIP2D), + FILL_MAP_BJET(signedIP2DSign), + FILL_MAP_BJET(signedIPz), + FILL_MAP_BJET(signedIPzSign), + FILL_MAP_BJET(signedIP3D), + FILL_MAP_BJET(signedIP3DSign), + FILL_MAP_BJET(momFraction), + FILL_MAP_BJET(deltaRTrackVertex), + FILL_MAP_BJET(trackPhi), + FILL_MAP_BJET(trackCharge), + FILL_MAP_BJET(trackITSChi2NCl), + FILL_MAP_BJET(trackTPCChi2NCl), + FILL_MAP_BJET(trackITSNCls), + FILL_MAP_BJET(trackTPCNCls), + FILL_MAP_BJET(trackTPCNCrossedRows), + FILL_MAP_BJET(trackOrigin), + FILL_MAP_BJET(trackVtxIndex), + + // Secondary vertex features + FILL_MAP_BJET(svpT), + FILL_MAP_BJET(deltaRSVJet), + FILL_MAP_BJET(svMass), + FILL_MAP_BJET(svfE), + FILL_MAP_BJET(svIPxy), + FILL_MAP_BJET(svCPA), + FILL_MAP_BJET(svChi2PCA), + FILL_MAP_BJET(dispersion), + FILL_MAP_BJET(decayLength2D), + FILL_MAP_BJET(decayLength2DError), + FILL_MAP_BJET(decayLength3D), + FILL_MAP_BJET(decayLength3DError)}; + } +}; + +// ONNX Runtime tensor (Ort::Value) allocator for using customized inputs of ML models. +class TensorAllocator +{ + protected: + Ort::MemoryInfo memInfo; + public: + TensorAllocator() + : memInfo(Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault)) + { + } + ~TensorAllocator() = default; + template + Ort::Value createTensor(std::vector& input, std::vector& inputShape) + { + return Ort::Value::CreateTensor(memInfo, input.data(), input.size(), inputShape.data(), inputShape.size()); + } +}; + +// TensorAllocator for GNN b-jet tagger +class GNNBjetAllocator : public TensorAllocator +{ + private: + int64_t nJetFeat; + int64_t nTrkFeat; + int64_t nFlav; + int64_t nTrkOrigin; + int64_t maxNNodes; + + std::vector tfJetMean; + std::vector tfJetStdev; + std::vector tfTrkMean; + std::vector tfTrkStdev; + + std::vector> edgesList; + + // Jet feature normalization + template + T jetFeatureTransform(T feat, int idx) const + { + return (feat - tfJetMean[idx]) / tfJetStdev[idx]; + } + + // Track feature normalization + template + T trkFeatureTransform(T feat, int idx) const + { + return (feat - tfTrkMean[idx]) / tfTrkStdev[idx]; + } + + // Edge input of GNN (fully-connected graph) + void setEdgesList(void) + { + for (int64_t nNodes = 0; nNodes <= maxNNodes; ++nNodes) { + std::vector> edges; + // Generate all permutations of (i, j) where i != j + for (int64_t i = 0; i < nNodes; ++i) { + for (int64_t j = 0; j < nNodes; ++j) { + if (i != j) { + edges.emplace_back(i, j); + } + } + } + // Add self-loops (i, i) + for (int64_t i = 0; i < nNodes; ++i) { + edges.emplace_back(i, i); + } + // Flatten + std::vector flattenedEdges; + for (const auto& edge : edges) { + flattenedEdges.push_back(edge.first); + } + for (const auto& edge : edges) { + flattenedEdges.push_back(edge.second); + } + edgesList.push_back(flattenedEdges); + } + } + + // Replace NaN in a vector into value + template + static int replaceNaN(std::vector& vec, T value) + { + int numNaN = 0; + for (auto& el : vec) { // o2-linter: disable=const-ref-in-for-loop + if (std::isnan(el)) { + el = value; + ++numNaN; + } + } + return numNaN; + } + + public: + GNNBjetAllocator() : TensorAllocator(), nJetFeat(4), nTrkFeat(13), nFlav(3), nTrkOrigin(5), maxNNodes(40) {} + GNNBjetAllocator(int64_t nJetFeat, int64_t nTrkFeat, int64_t nFlav, int64_t nTrkOrigin, std::vector& tfJetMean, std::vector& tfJetStdev, std::vector& tfTrkMean, std::vector& tfTrkStdev, int64_t maxNNodes = 40) + : TensorAllocator(), nJetFeat(nJetFeat), nTrkFeat(nTrkFeat), nFlav(nFlav), nTrkOrigin(nTrkOrigin), maxNNodes(maxNNodes), tfJetMean(tfJetMean), tfJetStdev(tfJetStdev), tfTrkMean(tfTrkMean), tfTrkStdev(tfTrkStdev) + { + setEdgesList(); + } + ~GNNBjetAllocator() = default; + + // Copy operator for initializing GNNBjetAllocator using Configurable values + GNNBjetAllocator& operator=(const GNNBjetAllocator& other) + { + nJetFeat = other.nJetFeat; + nTrkFeat = other.nTrkFeat; + nFlav = other.nFlav; + nTrkOrigin = other.nTrkOrigin; + maxNNodes = other.maxNNodes; + tfJetMean = other.tfJetMean; + tfJetStdev = other.tfJetStdev; + tfTrkMean = other.tfTrkMean; + tfTrkStdev = other.tfTrkStdev; + setEdgesList(); + return *this; + } + + // Allocate & Return GNN input tensors (std::vector) + template + void getGNNInput(std::vector& jetFeat, std::vector>& trkFeat, std::vector& feat, std::vector& gnnInput) + { + int64_t nNodes = trkFeat.size(); + + std::vector edgesShape{2, nNodes * nNodes}; + gnnInput.emplace_back(createTensor(edgesList[nNodes], edgesShape)); + + std::vector featShape{nNodes, nJetFeat + nTrkFeat}; + + int numNaN = replaceNaN(jetFeat, 0.f); + for (auto& aTrkFeat : trkFeat) { // o2-linter: disable=const-ref-in-for-loop + for (size_t i = 0; i < jetFeat.size(); ++i) + feat.push_back(jetFeatureTransform(jetFeat[i], i)); + numNaN += replaceNaN(aTrkFeat, 0.f); + for (size_t i = 0; i < aTrkFeat.size(); ++i) + feat.push_back(trkFeatureTransform(aTrkFeat[i], i)); + } + + gnnInput.emplace_back(createTensor(feat, featShape)); + + if (numNaN > 0) { + LOGF(info, "NaN found in GNN input feature, number of NaN: %d", numNaN); + } + } +}; + +} // namespace o2::analysis + +#undef FILL_MAP_BJET +#undef CHECK_AND_FILL_VEC_BTAG_FULL +#undef CHECK_AND_FILL_VEC_BTAG + +#endif // PWGJE_CORE_MLRESPONSEHFTAGGING_H_ diff --git a/PWGJE/Core/emcalCrossTalkEmulation.cxx b/PWGJE/Core/emcalCrossTalkEmulation.cxx new file mode 100644 index 00000000000..9fe9b679461 --- /dev/null +++ b/PWGJE/Core/emcalCrossTalkEmulation.cxx @@ -0,0 +1,604 @@ +// 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. + +/// \file emcalCrossTalkEmulation.cxx +/// \brief emulation of emcal cross talk for simulations +/// \author Marvin Hemmer , Goethe-University + +#include "emcalCrossTalkEmulation.h" + +#include +#include +#include +#include +#include +#include +#include + +#include // std::find_if +#include +#include // size_t +#include // std::abs +#include // setw +#include // left and right +#include +#include +#include +#include +#include +// #include "Framework/OutputObjHeader.h" + +// #include "Common/CCDB/EventSelectionParams.h" +#include +#include + +#include + +using namespace o2; +using namespace o2::emccrosstalk; +using namespace o2::framework; + +template +auto printArray(std::array const& arr) +{ + std::stringstream ss; + ss << "\n[SM0: " << arr[0]; + for (auto i = 1u; i < N; ++i) { + ss << ", SM" << i << ": " << arr[i]; + } + ss << "]"; + return ss.str(); +} + +template +auto printMatrix(Array2D const& m) +{ + std::stringstream ss; + // Print column headers + ss << std::endl + << std::setw(6) << " " << std::setw(10) << "value1" + << std::setw(10) << "value2" + << std::setw(10) << "value3" + << std::setw(10) << "value4" << std::endl; + + // Print rows with SM labels + for (size_t i = 0; i < m.rows; ++i) { + ss << "SM" << std::left << std::setw(3) << i; // e.g., SM0, SM1... + for (size_t j = 0; j < m.cols; ++j) { + ss << std::right << std::setw(10) << m(i, j); + } + ss << std::endl; + } + + return ss.str(); +} + +void init2DElement(Array2D& matrix, const Array2D& config, const char* name) +{ + int rows = config.rows; + int cols = config.cols; + + if (rows == 0 && cols == 0) { + LOG(info) << name << " has size 0 x 0, so it is disabled!"; + } else if (cols != NNeighbourCases || (rows != 1 && rows != NSM)) { + LOG(error) << name << " must have 4 columns and either 1 or 20 rows!"; + } else { + for (int sm = 0; sm < NSM; ++sm) { + const int row = (rows == 1) ? 0 : sm; + + for (int i = 0; i < cols; ++i) { + matrix[sm][i] = config(row, i); + } + } + } +} + +void init1DElement(std::array& arr, const std::vector& config, const char* name) +{ + size_t confSize = config.size(); + if (confSize == 0) { + LOG(info) << name << " has size 0, so it is disabled!"; + } else if (config.size() != 1 && confSize != NSM) { + LOG(error) << name << " must have either size 1 or 20!"; + } else { + for (int sm = 0; sm < NSM; ++sm) { + const int row = (confSize == 1) ? 0 : sm; + arr[sm] = config[row]; + } + } +} + +o2::framework::AxisSpec axisEnergy = {7000, 0.f, 70.f, "#it{E}_{cell} (GeV)"}; +// For each of the following configurables we will use: +// empty vector == disabled +// vector of size 4 == same for all SM +// vector of vectors with size nSM * 4 == each SM has its own setting +// the 4 values (0-3) correspond to in relative [row,col]: 0: [+-1,0], 1: [+-1,+or-1], 2: [0,+or-1], 3: [+-2, 0 AND +or-1] +// +---+---+-----+---+---+--+--+--+ +// | 3 | 0 | Hit | 0 | 3 | | | | +// +---+---+-----+---+---+--+--+--+ +// | 3 | 1 | 2 | 1 | 3 | | | | +// +---+---+-----+---+---+--+--+--+ + +void EMCCrossTalk::initObjects(const EmcCrossTalkConf& config) +{ + const int run3RunNumber = 223409; + mGeometry = o2::emcal::Geometry::GetInstanceFromRunNumber(run3RunNumber); + if (!mGeometry) { + LOG(error) << "Failure accessing mGeometry"; + } + + // first set the simple run time variables + mTCardCorrClusEnerConserv = config.conserveEnergy.value; + mRandomizeTCard = config.randomizeTCardInducedEnergy.value; + mTCardCorrMinAmp = config.inducedTCardMinimumCellEnergy.value; + mTCardCorrMinInduced = config.inducedTCardMinimum.value; + mTCardCorrMaxInducedELeak = config.inducedTCardMaximumELeak.value; + mTCardCorrMaxInduced = config.inducedTCardMaximum.value; + + // 2nd define the NSM x NNeighbourCases matrices + mTCardCorrInduceEner = Array2D(std::vector(NSM * 4, 0.f), NSM, 4); + mTCardCorrInduceEnerFrac = Array2D(std::vector(NSM * 4, 0.f), NSM, 4); + mTCardCorrInduceEnerFracP1 = Array2D(std::vector(NSM * 4, 0.f), NSM, 4); + mTCardCorrInduceEnerFracWidth = Array2D(std::vector(NSM * 4, 0.f), NSM, 4); + + // now properly init the NSM x NNeighbourCases matrices + // ------------------------------------------------------------------------ + // mTCardCorrInduceEner + init2DElement(mTCardCorrInduceEner, config.inducedEnergyLossConstant.value, "inducedEnergyLossConstant"); + + // mTCardCorrInduceEnerFrac + init2DElement(mTCardCorrInduceEnerFrac, config.inducedEnergyLossFraction.value, "inducedEnergyLossFraction"); + + // mTCardCorrInduceEnerFracP1 + init2DElement(mTCardCorrInduceEnerFracP1, config.inducedEnergyLossFractionP1.value, "inducedEnergyLossFractionP1"); + + // mTCardCorrInduceEnerFracWidth + init2DElement(mTCardCorrInduceEnerFracWidth, config.inducedEnergyLossFractionWidth.value, "inducedEnergyLossFractionWidth"); + // ------------------------------------------------------------------------ + + init1DElement(mTCardCorrInduceEnerFracMax, config.inducedEnergyLossMaximumFraction.value, "inducedEnergyLossMaximumFraction"); + init1DElement(mTCardCorrInduceEnerFracMin, config.inducedEnergyLossMinimumFraction.value, "inducedEnergyLossMinimumFraction"); + init1DElement(mTCardCorrInduceEnerFracMinCentralEta, config.inducedEnergyLossMinimumFractionCentralEta.value, "inducedEnergyLossMinimumFractionCentralEta"); + init1DElement(mTCardCorrInduceEnerProb, config.inducedEnergyLossProbability.value, "inducedEnergyLossProbability"); + + resetArrays(); + + // Print the full matrices and vectors that will be used: + if (config.printConfiguration.value) { + LOGF(info, "inducedEnergyLossConstant: %s", printMatrix((mTCardCorrInduceEner))); + LOGF(info, "inducedEnergyLossFraction: %s", printMatrix((mTCardCorrInduceEnerFrac))); + LOGF(info, "inducedEnergyLossFractionP1: %s", printMatrix((mTCardCorrInduceEnerFracP1))); + LOGF(info, "inducedEnergyLossFractionWidth: %s", printMatrix((mTCardCorrInduceEnerFracWidth))); + LOGF(info, "inducedEnergyLossMaximumFraction: %s", printArray(mTCardCorrInduceEnerFracMax).c_str()); + LOGF(info, "inducedEnergyLossMinimumFraction: %s", printArray(mTCardCorrInduceEnerFracMin).c_str()); + LOGF(info, "inducedEnergyLossMinimumFractionCentralEta: %s", printArray(mTCardCorrInduceEnerFracMinCentralEta).c_str()); + LOGF(info, "inducedEnergyLossProbability: %s", printArray(mTCardCorrInduceEnerProb).c_str()); + } +} + +void EMCCrossTalk::resetArrays() +{ + for (size_t j = 0; j < NCells; j++) { + mTCardCorrCellsEner[j] = 0.; + mTCardCorrCellsNew[j] = false; + } + + mCellsTmp.clear(); +} + +void EMCCrossTalk::setCells(std::vector& cells, std::vector& cellLabels) +{ + mCells = &cells; + mCellsTmp = cells; // a copy since we will need one vector with the changed energies and one with the original ones + mCellLabels = &cellLabels; +} + +void EMCCrossTalk::calculateInducedEnergyInTCardCell(int absId, int absIdRef, int iSM, float ampRef, int cellCase) +{ + // Check that the cell exists + if (absId < 0) { + return; + } + + // Get the fraction + float frac = mTCardCorrInduceEnerFrac[iSM][cellCase] + ampRef * mTCardCorrInduceEnerFracP1[iSM][cellCase]; + + // Use an absolute minimum and maximum fraction if calculated one is out of range + if (frac < mTCardCorrInduceEnerFracMin[iSM]) { + frac = mTCardCorrInduceEnerFracMin[iSM]; + } else if (frac > mTCardCorrInduceEnerFracMax[iSM]) { + frac = mTCardCorrInduceEnerFracMax[iSM]; + } + + // If active, use different absolute minimum fraction for central eta, exclude DCal 2/3 SM + if (mTCardCorrInduceEnerFracMinCentralEta[iSM] > 0 && (iSM < FirstDCal23SM || iSM > LastDCal23SM)) { + // Odd SM + int ietaMin = 32; + int ietaMax = 47; + + // Even SM + if (iSM % 2) { + ietaMin = 0; + ietaMax = 15; + } + + // First get the SM, col-row of this tower + // int imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1; + auto [iSM, iMod, iIphi, iIeta] = mGeometry->GetCellIndex(absId); + auto [iphi, ieta] = mGeometry->GetCellPhiEtaIndexInSModule(iSM, iMod, iIphi, iIeta); + + if (ieta >= ietaMin && ieta <= ietaMax) { + if (frac < mTCardCorrInduceEnerFracMinCentralEta[iSM]) + frac = mTCardCorrInduceEnerFracMinCentralEta[iSM]; + } + } // central eta + + LOGF(debug, "\t fraction %2.3f", frac); + + // Randomize the induced fraction, if requested + if (mRandomizeTCard) { + frac = mRandom.Gaus(frac, mTCardCorrInduceEnerFracWidth[iSM][cellCase]); + LOGF(debug, "\t randomized fraction %2.3f", frac); + } + + // If fraction too small or negative, do nothing else + if (frac < Epsilon) { + return; + } + + // Calculate induced energy + float inducedE = mTCardCorrInduceEner[iSM][cellCase] + ampRef * frac; + + // Check if we induce too much energy, in such case use a constant value + if (mTCardCorrMaxInduced < inducedE) + inducedE = mTCardCorrMaxInduced; + + LOGF(debug, "\t induced E %2.3f", inducedE); + + // Try to find the cell that will get energy induced + float amp = 0.f; + auto itCell = std::find_if((*mCells).begin(), (*mCells).end(), [absId](const o2::emcal::Cell& cell) { + return cell.getTower() == absId; + }); + + if (itCell != (*mCells).end()) { + // We found a cell, so let's get the amplitude of that cell + amp = itCell->getAmplitude(); + } else { + amp = 0.f; // this is a new cell, so the base amp is 0.f + } + + // Check that the induced+amp is large enough to avoid extra linearity effects + // typically of the order of the clusterization cell energy cut + // if inducedTCardMaximumELeak was set to a positive value, then induce the energy as long as its smaller than that value + if ((amp + inducedE) > mTCardCorrMinInduced || inducedE < mTCardCorrMaxInducedELeak) { + mTCardCorrCellsEner[absId] += inducedE; + + // If original energy of cell was null, create new one + if (amp <= Epsilon) { + mTCardCorrCellsNew[absId] = true; + } + } else { + return; + } + + LOGF(debug, "Cell %d is with amplitude %2.3f GeV is inducing %1.3f GeV energy to cell %d which already has %2.3f GeV energy with fraction %1.5f", absIdRef, ampRef, inducedE, absId, amp, frac); + + // Subtract the added energy to main cell, if energy conservation is requested + if (mTCardCorrClusEnerConserv) { + mTCardCorrCellsEner[absIdRef] -= inducedE; + } +} + +void EMCCrossTalk::makeCellTCardCorrelation() +{ + int id = -1; + float amp = -1; + + // Loop on all cells with signal + for (const auto& cell : (*mCells)) { + id = cell.getTower(); + amp = cell.getAmplitude(); + + if (amp <= mTCardCorrMinAmp) { + continue; + } + + // First get the SM, col-row of this tower + auto [iSM, iMod, iIphi, iIeta] = mGeometry->GetCellIndex(id); + auto [iphi, ieta] = mGeometry->GetCellPhiEtaIndexInSModule(iSM, iMod, iIphi, iIeta); + + // Determine randomly if we want to create a correlation for this cell, + // depending the SM number of the cell + if (mTCardCorrInduceEnerProb[iSM] < 1) { + if (mRandom.Uniform(0, 1) > mTCardCorrInduceEnerProb[iSM]) { + continue; + } + } + + LOGF(debug, "Reference cell absId %d, iEta %d, iPhi %d, amp %2.3f", id, ieta, iphi, amp); + + // Get the absId of the cells in the cross and same T-Card + int absIDup = -1; + int absIDdo = -1; + int absIDlr = -1; + int absIDuplr = -1; + int absIDdolr = -1; + + int absIDup2 = -1; + int absIDup2lr = -1; + int absIDdo2 = -1; + int absIDdo2lr = -1; + + // Only 2 columns in the T-Card, +1 for even and -1 for odd with respect reference cell + // Sine we only have full T-Cards, we do not need to make any edge case checks + // There is always either a column (eta direction) below or above + int colShift = +1; + if (ieta % 2) { + colShift = -1; + } + + absIDlr = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphi, ieta + colShift); + + // Check if up / down cells from reference cell are not out of SM + // First check if there is space one above + if (iphi < emcal::EMCAL_ROWS - 1) { + absIDup = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphi + 1, ieta); + absIDuplr = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphi + 1, ieta + colShift); + } + + // 2nd check if there is space one below + if (iphi > 0) { + absIDdo = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphi - 1, ieta); + absIDdolr = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphi - 1, ieta + colShift); + } + + // 3rd check if there is space two above + if (iphi < emcal::EMCAL_ROWS - 2) { + absIDup2 = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphi + 2, ieta); + absIDup2lr = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphi + 2, ieta + colShift); + } + + // 4th check if there is space two below + if (iphi > 1) { + absIDdo2 = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphi - 2, ieta); + absIDdo2lr = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphi - 2, ieta + colShift); + } + + // Check if those cells are in the same T-Card + int tCard = iphi / 8; + if (tCard != (iphi + 1) / 8) { + absIDup = -1; + absIDuplr = -1; + } + if (tCard != (iphi - 1) / 8) { + absIDdo = -1; + absIDdolr = -1; + } + if (tCard != (iphi + 2) / 8) { + absIDup2 = -1; + absIDup2lr = -1; + } + if (tCard != (iphi - 2) / 8) { + absIDdo2 = -1; + absIDdo2lr = -1; + } + + // Calculate induced energy to T-Card cells + // first check if for the given cell case we actually do induce some energy + if (((std::abs(mTCardCorrInduceEner[iSM][0]) > Epsilon) || (std::abs(mTCardCorrInduceEnerFrac[iSM][0]) > Epsilon)) && (std::abs(mTCardCorrInduceEnerFracP1[iSM][0]) > Epsilon) && (std::abs(mTCardCorrInduceEnerFracWidth[iSM][0]) > Epsilon)) { + if (absIDup >= 0) { + LOGF(debug, "cell up %d:", absIDup); + calculateInducedEnergyInTCardCell(absIDup, id, iSM, amp, 0); + } + if (absIDdo >= 0) { + LOGF(debug, "cell down %d:", absIDdo); + calculateInducedEnergyInTCardCell(absIDdo, id, iSM, amp, 0); + } + } + if (((std::abs(mTCardCorrInduceEner[iSM][1]) > Epsilon) || (std::abs(mTCardCorrInduceEnerFrac[iSM][1]) > Epsilon)) && (std::abs(mTCardCorrInduceEnerFracP1[iSM][1]) > Epsilon) && (std::abs(mTCardCorrInduceEnerFracWidth[iSM][1]) > Epsilon)) { + if (absIDuplr >= 0) { + LOGF(debug, "cell up left-right %d:", absIDuplr); + calculateInducedEnergyInTCardCell(absIDuplr, id, iSM, amp, 1); + } + if (absIDdolr >= 0) { + LOGF(debug, "cell down left-right %d:", absIDdolr); + calculateInducedEnergyInTCardCell(absIDdolr, id, iSM, amp, 1); + } + } + if (((std::abs(mTCardCorrInduceEner[iSM][2]) > Epsilon) || (std::abs(mTCardCorrInduceEnerFrac[iSM][2]) > Epsilon)) && (std::abs(mTCardCorrInduceEnerFracP1[iSM][2]) > Epsilon) && (std::abs(mTCardCorrInduceEnerFracWidth[iSM][2]) > Epsilon)) { + if (absIDlr >= 0) { + LOGF(debug, "cell left-right %d:", absIDlr); + calculateInducedEnergyInTCardCell(absIDlr, id, iSM, amp, 2); + } + } + if (((std::abs(mTCardCorrInduceEner[iSM][3]) > Epsilon) || (std::abs(mTCardCorrInduceEnerFrac[iSM][3]) > Epsilon)) && (std::abs(mTCardCorrInduceEnerFracP1[iSM][3]) > Epsilon) && (std::abs(mTCardCorrInduceEnerFracWidth[iSM][3]) > Epsilon)) { + if (absIDup2 >= 0) { + LOGF(debug, "cell up 2nd row %d:", absIDup2); + calculateInducedEnergyInTCardCell(absIDup2, id, iSM, amp, 3); + } + if (absIDdo2 >= 0) { + LOGF(debug, "cell down 2nd row %d:", absIDdo2); + calculateInducedEnergyInTCardCell(absIDdo2, id, iSM, amp, 3); + } + if (absIDup2lr >= 0) { + LOGF(debug, "cell up left-right 2nd row %d:", absIDup2lr); + calculateInducedEnergyInTCardCell(absIDup2lr, id, iSM, amp, 3); + } + if (absIDdo2lr >= 0) { + LOGF(debug, "cell down left-right 2nd row %d:", absIDdo2lr); + calculateInducedEnergyInTCardCell(absIDdo2lr, id, iSM, amp, 3); + } + } + } // cell loop +} + +void EMCCrossTalk::addInducedEnergiesToExistingCells() +{ + // Add the induced energy to the cells and copy them into a new temporal container + // used in AddInducedEnergiesToNewCells() to refill the default cells list fCaloCells + // Create the data member only once. Done here, not sure where to do this properly in the framework. + + for (auto& cell : mCellsTmp) { // o2-linter: disable=const-ref-in-for-loop (we are changing a value here) + float amp = cell.getAmplitude() + mTCardCorrCellsEner[cell.getTower()]; + // Set new amplitude in new temporal container + cell.setAmplitude(amp); + } +} + +void EMCCrossTalk::addInducedEnergiesToNewCells() +{ + // count how many new cells + size_t nCells = (*mCells).size(); + int nCellsNew = 0; + for (size_t j = 0; j < NCells; j++) { + // Newly created? + if (!mTCardCorrCellsNew[j]) { + continue; + } + // Accept only if at least 10 MeV + if (mTCardCorrCellsEner[j] < MinCellEnergy) { + continue; + } + nCellsNew++; + } + + // reserve more space for new cell entries in original cells and celllabels + (*mCells).reserve(nCells + nCellsNew); + (*mCellLabels).reserve(nCells + nCellsNew); + + // change the amplitude of the original cells using + for (size_t iCell = 0; iCell < mCellsTmp.size(); ++iCell) { + (*mCells)[iCell].setAmplitude(mCellsTmp[iCell].getAmplitude()); + } + + // Add the new cells + int absId = -1; + float amp = -1; + float time = 0; + std::vector mclabel; + + for (size_t j = 0; j < NCells; j++) { + // Newly created? + if (!mTCardCorrCellsNew[j]) { + continue; + } + + // Accept only if at least 10 MeV + if (mTCardCorrCellsEner[j] < MinCellEnergy) { + continue; + } + + // Add new cell + absId = j; + amp = mTCardCorrCellsEner[j]; + time = 615.e-9f; + mclabel = {-1}; + + // Assign as MC label the label of the neighboring cell with highest energy + // within the same T-Card. Follow same approach for time. + // Simplest assumption, not fully correct. + // Still assign 0 as fraction of energy. + + // First get the iphi and ieta of this tower + auto [iSM, iMod, iIphi, iIeta] = mGeometry->GetCellIndex(absId); + auto [iphi, ieta] = mGeometry->GetCellPhiEtaIndexInSModule(iSM, iMod, iIphi, iIeta); + + LOGF(debug, "Trying to add cell %d \t ieta = %d\t iphi = %d\t amplitude = %1.3f", absId, ieta, iphi, amp); + + // Loop on the nearest cells around, check the highest energy one, + // and assign its MC label and the time + float ampMax = 0.f; + for (int ietai = ieta - 1; ietai <= ieta + 1; ++ietai) { + for (int iphii = iphi - 1; iphii <= iphi + 1; ++iphii) { + + // Avoid same cell + if (iphii == iphi && ietai == ieta) { + continue; + } + + // Avoid cells out of SM + if (ietai < 0 || ietai >= emcal::EMCAL_COLS || iphii < 0 || iphii >= emcal::EMCAL_ROWS) { + continue; + } + + int absIDi = mGeometry->GetAbsCellIdFromCellIndexes(iSM, iphii, ietai); + // Try to find the cell that will get energy induced + float ampi = 0.f; + size_t indexInCells = 0; + auto itCell = std::find_if((*mCells).begin(), (*mCells).begin() + nCells, [absIDi](const o2::emcal::Cell& cell) { + return cell.getTower() == absIDi; + }); + + if (itCell != (*mCells).begin() + nCells) { + // We found a cell, so let's get the amplitude of that cell + ampi = itCell->getAmplitude(); + if (ampi <= ampMax) { + continue; // early continue if the new amplitude is not the biggest one + } + indexInCells = std::distance((*mCells).begin(), itCell); + LOGF(debug, "Found cell with index %d", indexInCells); + } else { + continue; + } + + // Remove cells with no energy + if (ampi <= MinCellEnergy) { + continue; + } + + // Only same TCard + if (!std::get<0>(mGeometry->areAbsIDsFromSameTCard(absId, absIDi))) { + continue; + } + + std::vector mclabeli = {(*mCellLabels)[indexInCells].GetLeadingMCLabel()}; + float timei = (*mCells)[indexInCells].getTimeStamp(); + + ampMax = ampi; + mclabel = mclabeli; + time = timei; + } // loop phi + } // loop eta + // End Assign MC label + LOGF(debug, "Final ampMax %1.2f\n", ampMax); + LOGF(debug, "--- End : Added cell ID %d, ieta %d, iphi %d, E %1.3f, time %1.3e, mc label %d\n", absId, ieta, iphi, amp, time, mclabel[0]); + + // Add the new cell + (*mCells).emplace_back(absId, amp, time, o2::emcal::intToChannelType(1)); + (*mCellLabels).emplace_back(std::vector{mclabel[0]}, std::vector{0.f}); + } // loop over cells +} + +bool EMCCrossTalk::run() +{ + // START PROCESSING + // Test if cells present + if ((*mCells).size() == 0) { + LOGF(error, "No EMCAL cells found, exiting EMCCrossTalk::run()!"); + return false; + } + + // CELL CROSSTALK EMULATION + // Compute the induced cell energies by T-Card correlation emulation, ONLY MC + makeCellTCardCorrelation(); + + // Add to existing cells the found induced energies in MakeCellTCardCorrelation() if new signal is larger than 10 MeV. + addInducedEnergiesToExistingCells(); + + // Add new cells with found induced energies in MakeCellTCardCorrelation() if new signal is larger than 10 MeV. + addInducedEnergiesToNewCells(); + + resetArrays(); + + return true; +} diff --git a/PWGJE/Core/emcalCrossTalkEmulation.h b/PWGJE/Core/emcalCrossTalkEmulation.h new file mode 100644 index 00000000000..7d83b95d19e --- /dev/null +++ b/PWGJE/Core/emcalCrossTalkEmulation.h @@ -0,0 +1,210 @@ +// 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. + +/// \file emcalCrossTalkEmulation.h +/// \brief emulation of emcal cross talk for simulations +/// \author Marvin Hemmer , Goethe-University + +#ifndef PWGJE_CORE_EMCALCROSSTALKEMULATION_H_ +#define PWGJE_CORE_EMCALCROSSTALKEMULATION_H_ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +namespace o2::emccrosstalk +{ +// cell types for enegery induction +enum InductionCellType { + UpDown = 0, + UpDownLeftRight, + LeftRight, + Up2Down2, + NInductionCellType +}; + +// default values for cross talk emulation +// small value to use for comarison equal to 0, std::abs(x) > epsilon +static constexpr float Epsilon = 1e-6f; + +// default for inducedEnergyLossConstant +// static constexpr float DefaultIELC[1][4] = {{0.02f, 0.02f, 0.02f, 0.f}}; // default from https://github.com/alisw/AliPhysics/blob/master/PWG/EMCAL/config/AliEmcalCorrectionConfiguration.yaml (but is deactivated per default) +static constexpr float DefaultIELC[1][4] = {{0.f, 0.f, 0.f, 0.f}}; // default from pp 13 TeV + +// default for inducedEnergyLossFraction, default from https://github.com/alisw/AliPhysics/blob/master/PWG/EMCAL/config/AliEmcalCorrectionConfiguration.yaml same as in https://cds.cern.ch/record/2910556/ +static constexpr float DefaultIELF[20][4] = {{1.15e-02, 1.15e-02, 1.15e-02, 0.f}, + {1.20e-02, 1.20e-02, 1.20e-02, 0.f}, + {1.15e-02, 1.15e-02, 1.15e-02, 0.f}, + {1.20e-02, 1.20e-02, 1.20e-02, 0.f}, + {1.15e-02, 1.15e-02, 1.15e-02, 0.f}, + {1.15e-02, 1.15e-02, 1.15e-02, 0.f}, + {1.15e-02, 1.15e-02, 1.15e-02, 0.f}, + {1.20e-02, 1.20e-02, 1.20e-02, 0.f}, + {0.80e-02, 0.80e-02, 0.80e-02, 0.f}, + {0.80e-02, 0.80e-02, 0.80e-02, 0.f}, + {1.20e-02, 1.20e-02, 1.20e-02, 0.f}, + {1.15e-02, 1.15e-02, 1.15e-02, 0.f}, + {1.15e-02, 1.15e-02, 1.15e-02, 0.f}, + {1.15e-02, 1.15e-02, 1.15e-02, 0.f}, + {0.80e-02, 0.80e-02, 0.80e-02, 0.f}, + {0.80e-02, 0.80e-02, 0.80e-02, 0.f}, + {1.15e-02, 1.15e-02, 1.15e-02, 0.f}, + {0.80e-02, 0.80e-02, 0.80e-02, 0.f}, + {0.80e-02, 0.80e-02, 0.80e-02, 0.f}, + {0.80e-02, 0.80e-02, 0.80e-02, 0.f}}; + +// default for inducedEnergyLossFractionP1, default from https://github.com/alisw/AliPhysics/blob/master/PWG/EMCAL/config/AliEmcalCorrectionConfiguration.yaml same as in https://cds.cern.ch/record/2910556/ +static constexpr float DefaultIELFP1[1][4] = {{-1.1e-03, -1.1e-03, -1.1e-03, 0.f}}; + +// default for inducedEnergyLossFractionWidth, default from https://github.com/alisw/AliPhysics/blob/master/PWG/EMCAL/config/AliEmcalCorrectionConfiguration.yaml same as in https://cds.cern.ch/record/2910556/ +static constexpr float DefaultIELFWidth[1][4] = {{5.0e-03, 5.0e-03, 5.0e-03, 0.f}}; + +// default for inducedEnergyLossMinimumFractionCentralEta, IF someone wants to try it. This is purely to document those test numbers from AliEmcalCorrectionConfiguration.yaml! Default is to not use this! Values from default from https://github.com/alisw/AliPhysics/blob/master/PWG/EMCAL/config/AliEmcalCorrectionConfiguration.yaml +// std::vector DefaultIELMFCE = {6.8e-3, 7.5e-3, 6.8e-3, 9.0e-3, 6.8e-3, 6.8e-3, 6.8e-3, 9.0e-3, 5.2e-3, 5.2e-3, 7.5e-3, 6.8e-3, 6.8e-3, 6.8e-3, 5.2e-3, 5.2e-3, 6.8e-3, 5.2e-3, 5.2e-3, 5.2e-3}; + +struct EmcCrossTalkConf : o2::framework::ConfigurableGroup { + std::string prefix = "emccrosstalk"; + o2::framework::Configurable enableCrossTalk{"enableCrossTalk", false, "Flag to enable cross talk emulation. This should only ever be used for MC!"}; + o2::framework::Configurable createHistograms{"createHistograms", false, "Flag to enable QA histograms."}; + o2::framework::Configurable printConfiguration{"printConfiguration", true, "Flag to print the configuration after initialization."}; + o2::framework::Configurable conserveEnergy{"conserveEnergy", true, "Flag to enable cluster energy conservation."}; + o2::framework::Configurable randomizeTCardInducedEnergy{"randomizeTCardInducedEnergy", true, "Flag to randomize the energy fraction induced by the TCard."}; + o2::framework::Configurable inducedTCardMinimumCellEnergy{"inducedTCardMinimumCellEnergy", 0.01f, "Minimum cell energy in GeV induced by the TCard."}; + o2::framework::Configurable inducedTCardMaximum{"inducedTCardMaximum", 100.f, "Maximum energy in GeV induced by the TCard."}; + o2::framework::Configurable inducedTCardMinimum{"inducedTCardMinimum", 0.1f, "Minimum energy in GeV induced by the TCard + cell energy, IMPORTANT use the same value as the clusterization cell E threshold or not too far from it."}; + o2::framework::Configurable inducedTCardMaximumELeak{"inducedTCardMaximumELeak", 0.f, "Maximum energy in GeV that is going to be leaked independently of what is set with inducedTCardMinimum."}; + // For each of the following Array2D configurables we will use: + // empty vector == disabled + // vector of size 4 == same for all SM + // vector of vectors with size nSM * 4 == each SM has its own setting + // the 4 values (0-3) correspond to in relative [row,col]: 0: [+-1,0], 1: [+-1,+or-1], 2: [0,+or-1], 3: [+-2, 0 AND +or-1] + // +---+---+-----+---+---+--+--+--+ + // | 3 | 0 | Hit | 0 | 3 | | | | + // +---+---+-----+---+---+--+--+--+ + // | 3 | 1 | 2 | 1 | 3 | | | | + // +---+---+-----+---+---+--+--+--+ + // For the std::vector it is similar, empty vector means not used, single value means one value for all SM and 20 values means specifiyng a value for all SM + o2::framework::Configurable> inducedEnergyLossConstant{"inducedEnergyLossConstant", {DefaultIELC[0], 1, 4}, "Constant energy lost by max energy cell in one of T-Card cells. Empty vector == disabled, size 4 vector == enabled. For information on the exact formatting please check the header file."}; + o2::framework::Configurable> inducedEnergyLossFraction{"inducedEnergyLossFraction", {DefaultIELF[0], 20, 4}, "Fraction of energy lost by max energy cell in one of T-Card cells."}; + o2::framework::Configurable> inducedEnergyLossFractionP1{"inducedEnergyLossFractionP1", {DefaultIELFP1[0], 1, 4}, "Slope parameter of fraction of energy lost by max energy cell in one of T-Card cells."}; + o2::framework::Configurable> inducedEnergyLossFractionWidth{"inducedEnergyLossFractionWidth", {DefaultIELFWidth[0], 1, 4}, "Fraction of energy lost by max energy cell in one of T-Card cells, width of random gaussian."}; + // default from https://github.com/alisw/AliPhysics/blob/master/PWG/EMCAL/config/AliEmcalCorrectionConfiguration.yaml : + // o2::framework::Configurable> inducedEnergyLossMinimumFraction{"inducedEnergyLossMinimumFraction", {3.5e-3f, 5.0e-3f, 4.5e-3f, 6.0e-3f, 3.5e-3f, 3.5e-3f, 3.5e-3f, 6.0e-3f, 3.5e-3f, 3.5e-3f, 5.0e-3f, 5.0e-3f, 3.5e-3f, 3.5e-3f, 3.5e-3f, 3.5e-3f, 3.5e-3f, 3.5e-3f, 3.5e-3f, 3.5e-3f}, "Minimum induced energy fraction when linear dependency is set."}; + // value from https://cds.cern.ch/record/2910556/: + o2::framework::Configurable> inducedEnergyLossMinimumFraction{"inducedEnergyLossMinimumFraction", {2.35e-3f, 2.5e-3f, 2.35e-3f, 3.0e-3f, 2.35e-3f, 2.35e-3f, 2.35e-3f, 3.0e-3f, 1.75e-3f, 1.75e-3f, 2.5e-3f, 2.35e-3f, 2.35e-3f, 2.35e-3f, 1.75e-3f, 1.75e-3f, 2.35e-3f, 1.75e-3f, 1.75e-3f, 1.75e-3f}, "Minimum induced energy fraction when linear dependency is set."}; + + o2::framework::Configurable> inducedEnergyLossMinimumFractionCentralEta{"inducedEnergyLossMinimumFractionCentralEta", {}, "Minimum induced energy fraction when linear dependency is set. For |eta| < 0.22, if empty no difference in eta. NOT TUNED for TESTING!"}; + + // default from https://github.com/alisw/AliPhysics/blob/master/PWG/EMCAL/config/AliEmcalCorrectionConfiguration.yaml : + // o2::framework::Configurable> inducedEnergyLossMaximumFraction{"inducedEnergyLossMaximumFraction", {0.018f}, "Maximum induced energy fraction when linear dependency is set."}; + // value from https://cds.cern.ch/record/2910556/: + o2::framework::Configurable> inducedEnergyLossMaximumFraction{"inducedEnergyLossMaximumFraction", {0.016f, 0.016f, 0.016f, 0.018f, 0.016f, 0.016f, 0.016f, 0.018f, 0.016f, 0.016f, 0.016f, 0.016f, 0.016f, 0.016f, 0.016f, 0.016f, 0.016f, 0.016f, 0.016f, 0.016f}, "Maximum induced energy fraction when linear dependency is set."}; + o2::framework::Configurable> inducedEnergyLossProbability{"inducedEnergyLossProbability", {1.0f}, "Fraction of times max cell energy correlates with cross cells."}; +}; + +static constexpr int NSM = 20; // Number of Supermodules (12 for EMCal + 8 for DCal) +static constexpr int NCells = 17664; // Number of cells in the EMCal +static constexpr int NNeighbourCases = 4; // 0-same row, diff col, 1-up/down cells left/right col 2-left/righ col, and 2nd row cells +static constexpr int FirstDCal23SM = 12; // index of the first 2/3 DCal SM +static constexpr int LastDCal23SM = 17; // index of the last 2/3 DCal SM +static constexpr float MinCellEnergy = 0.01f; // Minimum energy a new cell needs to be added + +// these labels are for later once labeledArrays work on hyperloop. Currently they sadly only allow fixed size not variable size. +// static const std::vector labelsSM{"SM0/all", "SM1", "SM2", "SM3", "SM4", "SM5", "SM6", "SM7", "SM8", "SM9", "SM10", "SM11", "SM12", "SM13", "SM14", "SM15", "SM16", "SM17", "SM18", "SM19"}; +// static const std::vector labelsCells = {"Up&Down", "Up&Down x Left|Right", "Left|Right", "2Up&Down + 2Up&Down xLeft|Right"}; + +class EMCCrossTalk +{ + + public: + ~EMCCrossTalk() + { + LOG(info) << "Destroying EMCCrossTalk"; + } + + /// \brief Basic init function. + /// \param config configurable group containing the config for the cross talk emulation + void initObjects(const EmcCrossTalkConf& config); + + /// \brief Reset arrays containing information for all possible cells. + /// \details mTCardCorrCellsEner and mTCardCorrCellsNew + void resetArrays(); + + /// \brief Sets the pointer the current vector of cells. + /// \param cells pointer to emcal cells of the current event + /// \param cellLabels pointer to emcal cell labels of the current event + void setCells(std::vector& cells, std::vector& cellLabels); + + /// \brief Main function to call later to perform the full cross talk emulation + /// \return flag if everything went well or not + bool run(); + + /// \brief Recover each cell amplitude and absId and induce energy in cells in cross of the same T-Card + void makeCellTCardCorrelation(); + + /// \brief Add to existing cells the found induced energies in makeCellTCardCorrelation() if new signal is larger than 10 MeV. + /// \details Need to destroy/create the default cells list and do a copy from the old to the new via a temporal array fAODCellsTmp. Not too nice or fast, but it works. + void addInducedEnergiesToExistingCells(); + + /// \brief Add new cells with found induced energies in makeCellTCardCorrelation() if new signal is larger than 10 MeV. + void addInducedEnergiesToNewCells(); + + /// \brief Calculate the induced energy in a cell belonging to thesame T-Card as the reference cell. Used in makeCellTCardCorrelation() + /// \param absId Id number of cell in same T-Card as reference cell + /// \param absIdRef Id number of reference cell + /// \param iSM Supermodule number of cell + /// \param ampRef Amplitude of the reference cell + /// \param cellCase Type of cell with respect reference cell 0: up or down, 1: up or down on the diagonal, 2: left or right, 3: 2nd row up/down both left/right + void calculateInducedEnergyInTCardCell(int absId, int absIdRef, int iSM, float ampRef, int cellCase); + + private: + // T-Card correlation emulation, do on MC + bool mTCardCorrClusEnerConserv; // When making correlation, subtract from the reference cell the induced energy on the neighbour cells + std::array mTCardCorrCellsEner; // Array with induced cell energy in T-Card neighbour cells + std::array mTCardCorrCellsNew; // Array with induced cell energy in T-Card neighbour cells, that before had no signal + + o2::framework::Array2D mTCardCorrInduceEner; // Induced energy loss gauss constant on 0-same row, diff col, 1-up/down cells left/right col 2-left/righ col, and 2nd row cells, param 0 + o2::framework::Array2D mTCardCorrInduceEnerFrac; // Induced energy loss gauss fraction param0 on 0-same row, diff col, 1-up/down cells left/right col 2-left/righ col, and 2nd row cells, param 0 + o2::framework::Array2D mTCardCorrInduceEnerFracP1; // Induced energy loss gauss fraction param1 on 0-same row, diff col, 1-up/down cells left/right col 2-left/righ col, and 2nd row cells, param1 + o2::framework::Array2D mTCardCorrInduceEnerFracWidth; // Induced energy loss gauss witdth on 0-same row, diff col, 1-up/down cells left/right col 2-left/righ col, and 2nd row cells + std::array mTCardCorrInduceEnerFracMax; // In case fTCardCorrInduceEnerFracP1 is non null, restrict the maximum fraction of induced energy per SM + std::array mTCardCorrInduceEnerFracMin; // In case fTCardCorrInduceEnerFracP1 is non null, restrict the minimum fraction of induced energy per SM + std::array mTCardCorrInduceEnerFracMinCentralEta; // In case fTCardCorrInduceEnerFracP1 is non null, restrict the minimum fraction of induced energy per SM. Different at central |eta| < 0.22 + std::array mTCardCorrInduceEnerProb; // Probability to induce energy loss per SM + + TRandom3 mRandom; // Random generator + bool mRandomizeTCard; // Use random induced energy + + float mTCardCorrMinAmp; // Minimum cell energy to induce signal on adjacent cells + float mTCardCorrMinInduced; // Minimum induced energy signal on adjacent cells, sum of induced plus original energy, use same as cell energy clusterization cut + float mTCardCorrMaxInducedELeak; // Maximum value of induced energy signal that is always leaked, ~5-10 MeV + float mTCardCorrMaxInduced; // Maximum induced energy signal on adjacent cells + + std::vector* mCells = nullptr; // Pointer to the original cells of the current event + std::vector* mCellLabels = nullptr; // Pointer to the original cell labels of the current event + std::vector mCellsTmp; // Temporal vector of cells (copy) + + o2::emcal::Geometry* mGeometry; // EMCal geometry +}; + +} // namespace o2::emccrosstalk + +#endif // PWGJE_CORE_EMCALCROSSTALKEMULATION_H_ diff --git a/PWGJE/Core/utilsBcSelEMC.h b/PWGJE/Core/utilsBcSelEMC.h new file mode 100644 index 00000000000..603e5190655 --- /dev/null +++ b/PWGJE/Core/utilsBcSelEMC.h @@ -0,0 +1,154 @@ +// 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. + +/// \file utilsBcSelEMC.h +/// \brief BC selection utilities for EMCal QA +/// \author Marvin Hemmer , Goethe-University + +#ifndef PWGJE_CORE_UTILSBCSELEMC_H_ +#define PWGJE_CORE_UTILSBCSELEMC_H_ + +#include "Common/CCDB/EventSelectionParams.h" + +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include // std::shared_ptr +#include // std::string + +namespace o2::emc_evsel +{ +// event rejection types +enum EventRejection { + None = 0, + Trigger, + TvxTrigger, + TimeFrameBorderCut, + ItsRofBorderCut, + NEventRejection +}; + +inline o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +EventRejection::NEventRejection - 0.5f, ""}; + +/// \brief Function to put labels on monitoring histogram +/// \param hRejection monitoring histogram +template +void setEventRejectionLabels(Histo& hRejection) +{ + // Puts labels on the bc monitoring histogram. + hRejection->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "Sel8"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::TvxTrigger + 1, "TVX Trigger"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::ItsRofBorderCut + 1, "ITS ROF border"); +} + +struct EMCEventSelection : o2::framework::ConfigurableGroup { + std::string prefix = "emcBcSel"; // JSON group name + // event selection parameters (in chronological order of application) + o2::framework::Configurable useSel8Trigger{"useSel8Trigger", true, "Apply the sel8 event selection"}; + o2::framework::Configurable triggerClass{"triggerClass", -1, "Trigger class different from sel8 (e.g. kINT7 for Run2) used only if useSel8Trigger is false"}; + o2::framework::Configurable useTvxTrigger{"useTvxTrigger", true, "Apply TVX trigger sel"}; + o2::framework::Configurable useTimeFrameBorderCut{"useTimeFrameBorderCut", true, "Apply TF border cut"}; + o2::framework::Configurable useItsRofBorderCut{"useItsRofBorderCut", true, "Apply ITS ROF border cut"}; + // histogram names + static constexpr char NameHistBCs[] = "hBCs"; + + std::shared_ptr hBCs; + + int currentRun{-1}; + + /// \brief Adds bc monitoring histograms in the histogram registry. + /// \param registry reference to the histogram registry + void addHistograms(o2::framework::HistogramRegistry& registry) + { + hBCs = registry.add(NameHistBCs, "EMC event counter;;# of accepted collisions", {o2::framework::HistType::kTH1D, {axisEvents}}); + setEventRejectionLabels(hBCs); + } + + /// \brief Applies event selection. + /// \tparam useEvSel use information from the EvSel table + /// \param bc bc to test against the selection criteria + /// \return bitmask with the event selection criteria not satisfied by the bc + template + uint16_t getEMCCollisionRejectionMask(const Bc& bc) + { + uint16_t rejectionMask{0}; // 16 bits, in case new ev. selections will be added + + if constexpr (useEvSel) { + /// trigger condition + bool sel8 = bc.selection_bit(o2::aod::evsel::kIsTriggerTVX) && bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder); + if ((useSel8Trigger && !sel8) || (!useSel8Trigger && triggerClass > -1 && !bc.alias_bit(triggerClass))) { + SETBIT(rejectionMask, EventRejection::Trigger); + } + /// TVX trigger selection + if (useTvxTrigger && !bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + SETBIT(rejectionMask, EventRejection::TvxTrigger); + } + /// time frame border cut + if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + SETBIT(rejectionMask, EventRejection::TimeFrameBorderCut); + } + /// ITS rof border cut + if (useItsRofBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + SETBIT(rejectionMask, EventRejection::ItsRofBorderCut); + } + } + return rejectionMask; + } + + /// \brief Fills histograms for monitoring event selections satisfied by the bc. + /// \param rejectionMask bitmask storing the info about which ev. selections are not satisfied by the bc + void fillHistograms(const uint16_t rejectionMask) + { + hBCs->Fill(EventRejection::None); + for (std::size_t reason = 1; reason < EventRejection::NEventRejection; reason++) { + if (TESTBIT(rejectionMask, reason)) { + return; + } + hBCs->Fill(reason); + } + } +}; + +struct EMCEventSelectionMc { + // event selection parameters (in chronological order of application) + bool useSel8Trigger{false}; // Apply the Sel8 selection + bool useTvxTrigger{false}; // Apply the TVX trigger + bool useTimeFrameBorderCut{true}; // Apply TF border cut + bool useItsRofBorderCut{false}; // Apply the ITS RO frame border cut + + void configureFromDevice(const o2::framework::DeviceSpec& device) + { + for (const auto& option : device.options) { + if (option.name.compare("emcEvSel.useSel8Trigger") == 0) { + useSel8Trigger = option.defaultValue.get(); + } else if (option.name.compare("emcEvSel.useTvxTrigger") == 0) { + useTvxTrigger = option.defaultValue.get(); + } else if (option.name.compare("emcEvSel.useTimeFrameBorderCut") == 0) { + useTimeFrameBorderCut = option.defaultValue.get(); + } else if (option.name.compare("emcEvSel.useItsRofBorderCut") == 0) { + useItsRofBorderCut = option.defaultValue.get(); + } + } + } +}; +} // namespace o2::emc_evsel + +#endif // PWGJE_CORE_UTILSBCSELEMC_H_ diff --git a/PWGJE/Core/utilsTrackMatchingEMC.h b/PWGJE/Core/utilsTrackMatchingEMC.h new file mode 100644 index 00000000000..05790a3fb88 --- /dev/null +++ b/PWGJE/Core/utilsTrackMatchingEMC.h @@ -0,0 +1,119 @@ +// 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. + +/// \file utilsTrackMatchingEMC.h +/// \brief EMCal track matching related utils +/// \author Marvin Hemmer + +#ifndef PWGJE_CORE_UTILSTRACKMATCHINGEMC_H_ +#define PWGJE_CORE_UTILSTRACKMATCHINGEMC_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace tmemcutilities +{ + +struct MatchResult { + std::vector> matchIndexTrack; + std::vector> matchDeltaPhi; + std::vector> matchDeltaEta; +}; + +/** + * Match clusters and tracks. + * + * Match cluster with tracks, where maxNumberMatches are considered in dR=maxMatchingDistance. + * If no unique match was found for a jet, an index of -1 is stored. + * The same map is created for clusters matched to tracks e.g. for electron analyses. + * + * @param clusterPhi cluster collection phi. + * @param clusterEta cluster collection eta. + * @param trackPhi track collection phi. + * @param trackEta track collection eta. + * @param maxMatchingDistance Maximum matching distance. + * @param maxNumberMatches Maximum number of matches (e.g. 5 closest). + * + * @returns (cluster to track index map, track to cluster index map) + */ +MatchResult matchTracksToCluster( + std::span clusterPhi, + std::span clusterEta, + std::span trackPhi, + std::span trackEta, + double maxMatchingDistance, + int maxNumberMatches) +{ + const std::size_t nClusters = clusterEta.size(); + const std::size_t nTracks = trackEta.size(); + MatchResult result; + + if (nClusters == 0 || nTracks == 0) { + // There are no jets, so nothing to be done. + return result; + } + // Input sizes must match + if (clusterPhi.size() != clusterEta.size()) { + throw std::invalid_argument("cluster collection eta and phi sizes don't match. Check the inputs."); + } + if (trackPhi.size() != trackEta.size()) { + throw std::invalid_argument("track collection eta and phi sizes don't match. Check the inputs."); + } + + result.matchIndexTrack.resize(nClusters); + result.matchDeltaPhi.resize(nClusters); + result.matchDeltaEta.resize(nClusters); + + // Build the KD-trees using vectors + // We build two trees: + // treeBase, which contains the base collection. + // treeTag, which contains the tag collection. + // The trees are built to match in two dimensions (eta, phi) + TKDTree treeTrack(trackEta.size(), 2, 1); + treeTrack.SetData(0, trackEta.data()); + treeTrack.SetData(1, trackPhi.data()); + treeTrack.Build(); + + // Find the track closest to each cluster. + for (std::size_t iCluster = 0; iCluster < nClusters; iCluster++) { + float point[2] = {clusterEta[iCluster], clusterPhi[iCluster]}; + int index[50]; // size 50 for safety + float distance[50]; // size 50 for safery + std::fill_n(index, 50, -1); + std::fill_n(distance, 50, std::numeric_limits::max()); + treeTrack.FindNearestNeighbors(point, maxNumberMatches, index, distance); + + // allocate enough memory + result.matchIndexTrack[iCluster].reserve(maxNumberMatches); + result.matchDeltaPhi[iCluster].reserve(maxNumberMatches); + result.matchDeltaEta[iCluster].reserve(maxNumberMatches); + + // test whether indices are matching: + for (int m = 0; m < maxNumberMatches; m++) { + if (index[m] >= 0 && distance[m] < maxMatchingDistance) { + result.matchIndexTrack[iCluster].push_back(index[m]); + result.matchDeltaPhi[iCluster].push_back(trackPhi[index[m]] - clusterPhi[iCluster]); + result.matchDeltaEta[iCluster].push_back(trackEta[index[m]] - clusterEta[iCluster]); + } + } + } + return result; +} +}; // namespace tmemcutilities + +#endif // PWGJE_CORE_UTILSTRACKMATCHINGEMC_H_ diff --git a/PWGJE/DataModel/EMCALClusterDefinition.h b/PWGJE/DataModel/EMCALClusterDefinition.h index ead4a14dde7..41e87590449 100644 --- a/PWGJE/DataModel/EMCALClusterDefinition.h +++ b/PWGJE/DataModel/EMCALClusterDefinition.h @@ -17,7 +17,6 @@ #define PWGJE_DATAMODEL_EMCALCLUSTERDEFINITION_H_ #include -#include "Framework/AnalysisDataModel.h" namespace o2::aod { @@ -31,16 +30,16 @@ enum class ClusterAlgorithm_t { /// cell energy, gradient as well as timing cut struct EMCALClusterDefinition { ClusterAlgorithm_t algorithm; - int storageID = -1; // integer ID used to store cluster definition in a flat table - int selectedCellType = 1; // EMCal cell type (CURRENTLY NOT USED TO AVOID MULTIPLE CELL LOOPS) - std::string name = "kUndefined"; // name of the cluster definition - double seedEnergy = 0.1; // seed threshold (GeV) - double minCellEnergy = 0.05; // minimum cell energy (GeV) - double timeMin = -10000.; // minimum time (ns) - double timeMax = 10000.; // maximum time (ns) - double timeDiff = 20000.; // maximum time difference (ns) between seed cell and aggregation cell - bool doGradientCut = true; // apply gradient cut if true - double gradientCut = -1; // gradient cut + int storageID = -1; // integer ID used to store cluster definition in a flat table + int selectedCellType = 1; // EMCal cell type (CURRENTLY NOT USED TO AVOID MULTIPLE CELL LOOPS) + std::string name = "kUndefined"; // name of the cluster definition + double seedEnergy = 0.1; // seed threshold (GeV) + double minCellEnergy = 0.05; // minimum cell energy (GeV) + double timeMin = -10000.; // minimum time (ns) + double timeMax = 10000.; // maximum time (ns) + double timeDiff = 20000.; // maximum time difference (ns) between seed cell and aggregation cell + bool doGradientCut = true; // apply gradient cut if true + double gradientCut = -1; // gradient cut bool recalcShowerShape5x5 = false; // recalculate shower shape using 5x5 cells // default constructor diff --git a/PWGJE/DataModel/EMCALClusters.h b/PWGJE/DataModel/EMCALClusters.h index 1981fd635aa..56edf634628 100644 --- a/PWGJE/DataModel/EMCALClusters.h +++ b/PWGJE/DataModel/EMCALClusters.h @@ -16,10 +16,14 @@ #ifndef PWGJE_DATAMODEL_EMCALCLUSTERS_H_ #define PWGJE_DATAMODEL_EMCALCLUSTERS_H_ +#include "EMCALClusterDefinition.h" + +#include +#include // IWYU pragma: keep + +#include #include #include -#include "Framework/AnalysisDataModel.h" -#include "EMCALClusterDefinition.h" namespace o2::aod { @@ -135,6 +139,12 @@ DECLARE_SOA_TABLE(EMCALMCClusters, "AOD", "EMCALMCCLUSTERS", //! using EMCALMCCluster = EMCALMCClusters::iterator; +// table of cluster MC info that could not be matched to a collision +DECLARE_SOA_TABLE(EMCALAmbiguousMCClusters, "AOD", "EMCALAMBMCCLS", //! + emcalclustermc::McParticleIds, emcalclustermc::AmplitudeA); + +using EMCALAmbiguousMCCluster = EMCALAmbiguousMCClusters::iterator; + namespace emcalclustercell { // declare index column pointing to cluster table @@ -152,10 +162,13 @@ using EMCALClusterCell = EMCALClusterCells::iterator; using EMCALAmbiguousClusterCell = EMCALAmbiguousClusterCells::iterator; namespace emcalmatchedtrack { -DECLARE_SOA_INDEX_COLUMN(Track, track); //! linked to Track table only for tracks that were matched +DECLARE_SOA_INDEX_COLUMN(Track, track); //! linked to Track table only for tracks that were matched +DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! difference between matched track and cluster azimuthal angle +DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! difference between matched track and cluster pseudorapidity } // namespace emcalmatchedtrack -DECLARE_SOA_TABLE(EMCALMatchedTracks, "AOD", "EMCMATCHTRACKS", //! - o2::soa::Index<>, emcalclustercell::EMCALClusterId, emcalmatchedtrack::TrackId); //! +DECLARE_SOA_TABLE(EMCALMatchedTracks, "AOD", "EMCMATCHTRACKS", //! + o2::soa::Index<>, emcalclustercell::EMCALClusterId, emcalmatchedtrack::TrackId, + emcalmatchedtrack::DeltaPhi, emcalmatchedtrack::DeltaEta); //! using EMCALMatchedTrack = EMCALMatchedTracks::iterator; } // namespace o2::aod #endif // PWGJE_DATAMODEL_EMCALCLUSTERS_H_ diff --git a/PWGJE/DataModel/EMCALMatchedCollisions.h b/PWGJE/DataModel/EMCALMatchedCollisions.h index 8550bf2fe45..2e93a2c765b 100644 --- a/PWGJE/DataModel/EMCALMatchedCollisions.h +++ b/PWGJE/DataModel/EMCALMatchedCollisions.h @@ -1,4 +1,4 @@ -// Copyright 2019-2023 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -18,9 +18,8 @@ #ifndef PWGJE_DATAMODEL_EMCALMATCHEDCOLLISIONS_H_ #define PWGJE_DATAMODEL_EMCALMATCHEDCOLLISIONS_H_ -#include -#include "Framework/AnalysisDataModel.h" -#include "EMCALClusterDefinition.h" +#include +#include // IWYU pragma: keep namespace o2::aod { diff --git a/PWGJE/DataModel/EMCALMatchedTracks.h b/PWGJE/DataModel/EMCALMatchedTracks.h index 1dbbfac7b7a..840a384eba8 100644 --- a/PWGJE/DataModel/EMCALMatchedTracks.h +++ b/PWGJE/DataModel/EMCALMatchedTracks.h @@ -16,9 +16,9 @@ #ifndef PWGJE_DATAMODEL_EMCALMATCHEDTRACKS_H_ #define PWGJE_DATAMODEL_EMCALMATCHEDTRACKS_H_ -#include -#include "Framework/AnalysisDataModel.h" -#include "EMCALClusterDefinition.h" +#include + +#include namespace o2::aod { diff --git a/PWGJE/DataModel/GammaJetAnalysisTree.h b/PWGJE/DataModel/GammaJetAnalysisTree.h index 7d468a339e7..02a9602ec6e 100644 --- a/PWGJE/DataModel/GammaJetAnalysisTree.h +++ b/PWGJE/DataModel/GammaJetAnalysisTree.h @@ -17,16 +17,45 @@ #ifndef PWGJE_DATAMODEL_GAMMAJETANALYSISTREE_H_ #define PWGJE_DATAMODEL_GAMMAJETANALYSISTREE_H_ -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/EMCALClusters.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/EMCALClusters.h" #include "PWGJE/DataModel/Jet.h" +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod::gjanalysis +{ +enum class ClusterOrigin { + kUnknown = 0, + kPhoton, // dominant amount of energy from the cluster is from a photon + kPromptPhoton, + kDirectPromptPhoton, + kFragmentationPhoton, + kDecayPhoton, // the particle that produced the cluster is a decay product + kDecayPhotonPi0, // the cluster was produced by a pi0 decay + kDecayPhotonEta, // the cluster was produced by a eta decay + kMergedPi0, // the cluster was produced by a merged pi0, i.e. two photons contribute to the cluster that both come from pi0 decay + kMergedEta, // the cluster was produced by a merged eta, i.e. two photons contribute to the cluster that both come from eta decay + kConvertedPhoton, // the cluster was produced by a converted photon, i.e. a photon that converted to an electron-positron pair and one of the electrons was detected in the cluster +}; +enum class ParticleOrigin { + kUnknown = 0, + kPromptPhoton, + kDirectPromptPhoton, + kFragmentationPhoton, + kDecayPhoton, + kDecayPhotonPi0, + kDecayPhotonEta, + kDecayPhotonOther, + kPi0 +}; +} // namespace o2::aod::gjanalysis namespace o2::aod { +// Collision level information namespace gjevent -{ // TODO add rho //! event index +{ //! event index DECLARE_SOA_COLUMN(Multiplicity, multiplicity, float); DECLARE_SOA_COLUMN(Centrality, centrality, float); DECLARE_SOA_COLUMN(Rho, rho, float); @@ -38,6 +67,16 @@ DECLARE_SOA_TABLE(GjEvents, "AOD", "GJEVENT", o2::soa::Index<>, gjevent::Multipl using GjEvent = GjEvents::iterator; +// Information about the MC collision that was matched to the reconstructed collision +namespace gjmcevent +{ +DECLARE_SOA_INDEX_COLUMN(GjEvent, gjevent); +DECLARE_SOA_COLUMN(Weight, weight, double); +DECLARE_SOA_COLUMN(Rho, rho, float); // gen level rho +DECLARE_SOA_COLUMN(IsMultipleAssigned, isMultipleAssigned, bool); // if the corresponding MC collision matched to this rec collision was also matched to other rec collisions (allows to skip those on analysis level ) +} // namespace gjmcevent +DECLARE_SOA_TABLE(GjMCEvents, "AOD", "GJMCEVENT", gjmcevent::GjEventId, gjmcevent::Weight, gjmcevent::Rho, gjmcevent::IsMultipleAssigned) +// Information about EMCal clusters namespace gjgamma { DECLARE_SOA_INDEX_COLUMN(GjEvent, gjevent); //! event index @@ -52,7 +91,7 @@ DECLARE_SOA_COLUMN(Time, time, float); //! clust DECLARE_SOA_COLUMN(IsExotic, isExotic, bool); //! flag to mark cluster as exotic DECLARE_SOA_COLUMN(DistanceToBadChannel, distanceToBadChannel, float); //! distance to bad channel DECLARE_SOA_COLUMN(NLM, nlm, ushort); //! number of local maxima -DECLARE_SOA_COLUMN(IsoRaw, isoraw, ushort); //! isolation in cone not corrected for Rho +DECLARE_SOA_COLUMN(IsoRaw, isoraw, float); //! isolation in cone not corrected for Rho DECLARE_SOA_COLUMN(PerpConeRho, perpconerho, float); //! rho in perpendicular cone DECLARE_SOA_COLUMN(TMdeltaPhi, tmdeltaphi, float); //! delta phi between cluster and closest match DECLARE_SOA_COLUMN(TMdeltaEta, tmdeltaeta, float); //! delta eta between cluster and closest match @@ -60,9 +99,32 @@ DECLARE_SOA_COLUMN(TMtrackP, tmtrackp, float); //! track } // namespace gjgamma DECLARE_SOA_TABLE(GjGammas, "AOD", "GJGAMMA", gjgamma::GjEventId, gjgamma::Energy, gjgamma::Definition, gjgamma::Eta, gjgamma::Phi, gjgamma::M02, gjgamma::M20, gjgamma::NCells, gjgamma::Time, gjgamma::IsExotic, gjgamma::DistanceToBadChannel, gjgamma::NLM, gjgamma::IsoRaw, gjgamma::PerpConeRho, gjgamma::TMdeltaPhi, gjgamma::TMdeltaEta, gjgamma::TMtrackP) -namespace gjchjet + +// MC information for reconstructed EMCal clusters +namespace gjgammamcinfo +{ +DECLARE_SOA_COLUMN(Origin, origin, uint16_t); +DECLARE_SOA_COLUMN(LeadingEnergyFraction, leadingEnergyFraction, float); // fraction of energy from the leading MC particle +} // namespace gjgammamcinfo +DECLARE_SOA_TABLE(GjGammaMCInfos, "AOD", "GJGAMMAMCINFO", gjgamma::GjEventId, gjgammamcinfo::Origin, gjgammamcinfo::LeadingEnergyFraction) + +// Generator level particle information from the MC collision that was matched to the reconstructed collision +namespace gjmcparticle { DECLARE_SOA_INDEX_COLUMN(GjEvent, gjevent); +DECLARE_SOA_COLUMN(Energy, energy, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(PdgCode, pdgCode, ushort); // TODO also add smoe origin of particle? maybe only save original pi0 and eta and photon (not decay photons) +DECLARE_SOA_COLUMN(MCIsolation, mcIsolation, float); // isolation in cone on mc gen level +DECLARE_SOA_COLUMN(Origin, origin, uint16_t); // origin of particle +} // namespace gjmcparticle +DECLARE_SOA_TABLE(GjMCParticles, "AOD", "GJMCPARTICLE", gjmcparticle::GjEventId, gjmcparticle::Energy, gjmcparticle::Eta, gjmcparticle::Phi, gjmcparticle::Pt, gjmcparticle::PdgCode, gjmcparticle::MCIsolation, gjmcparticle::Origin) + +// Reconstructed charged jet information +namespace gjchjet +{ DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(Eta, eta, float); DECLARE_SOA_COLUMN(Phi, phi, float); @@ -74,7 +136,30 @@ DECLARE_SOA_COLUMN(LeadingTrackPt, leadingtrackpt, float); DECLARE_SOA_COLUMN(PerpConeRho, perpconerho, float); DECLARE_SOA_COLUMN(NConstituents, nConstituents, ushort); } // namespace gjchjet -DECLARE_SOA_TABLE(GjChargedJets, "AOD", "GJCHJET", gjchjet::GjEventId, gjchjet::Pt, gjchjet::Eta, gjchjet::Phi, gjchjet::Radius, gjchjet::Energy, gjchjet::Mass, gjchjet::Area, gjchjet::LeadingTrackPt, gjchjet::PerpConeRho, gjchjet::NConstituents) +DECLARE_SOA_TABLE(GjChargedJets, "AOD", "GJCHJET", gjgamma::GjEventId, gjchjet::Pt, gjchjet::Eta, gjchjet::Phi, gjchjet::Radius, gjchjet::Energy, gjchjet::Mass, gjchjet::Area, gjchjet::LeadingTrackPt, gjchjet::PerpConeRho, gjchjet::NConstituents) + +// MC information for reconstructed charged jet +namespace gjchjetmcinfo +{ +DECLARE_SOA_COLUMN(MatchedJetIndexGeo, matchedJetIndexGeo, int); +DECLARE_SOA_COLUMN(MatchedJetIndexPt, matchedJetIndexPt, int); +} // namespace gjchjetmcinfo +DECLARE_SOA_TABLE(GjChJetMCInfos, "AOD", "GJCHJETMCINFO", gjgamma::GjEventId, gjchjetmcinfo::MatchedJetIndexGeo, gjchjetmcinfo::MatchedJetIndexPt) + +// MC information for generator level jets of associated MC collision +namespace gjmcjet +{ +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Radius, radius, float); +DECLARE_SOA_COLUMN(Energy, energy, float); +DECLARE_SOA_COLUMN(Mass, mass, float); +DECLARE_SOA_COLUMN(Area, area, float); +DECLARE_SOA_COLUMN(PerpConeRho, perpconerho, float); +} // namespace gjmcjet +DECLARE_SOA_TABLE(GjMCJets, "AOD", "GJMCJET", gjgamma::GjEventId, gjmcjet::Pt, gjmcjet::Eta, gjmcjet::Phi, gjmcjet::Radius, gjmcjet::Energy, gjmcjet::Mass, gjmcjet::Area, gjmcjet::PerpConeRho) + } // namespace o2::aod #endif // PWGJE_DATAMODEL_GAMMAJETANALYSISTREE_H_ diff --git a/PWGJE/DataModel/Jet.h b/PWGJE/DataModel/Jet.h index 34b8359981f..52939d0b16c 100644 --- a/PWGJE/DataModel/Jet.h +++ b/PWGJE/DataModel/Jet.h @@ -23,19 +23,20 @@ #ifndef PWGJE_DATAMODEL_JET_H_ #define PWGJE_DATAMODEL_JET_H_ -#include -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "PWGHF/DataModel/DerivedTables.h" #include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetReducedDataDQ.h" #include "PWGJE/DataModel/JetReducedDataHF.h" #include "PWGJE/DataModel/JetReducedDataV0.h" -#include "PWGJE/DataModel/JetReducedDataDQ.h" #include "PWGJE/DataModel/JetSubtraction.h" - -#include "PWGHF/DataModel/DerivedTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "PWGLF/DataModel/V0SelectorTables.h" + +#include + +#include +#include namespace o2::aod { @@ -152,14 +153,14 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! absolute p DECLARE_JETMATCHING_TABLE(_jet_type_##MCParticleLevel, _jet_type_##MCDetectorLevel, _shortname_ "JETP2D") \ DECLARE_MCEVENTWEIGHT_TABLE(_jet_type_##MCDetectorLevel, _jet_type_##MCDetectorLevel, _shortname_ "DJETMW") \ DECLARE_MCEVENTWEIGHT_TABLE(_jet_type_##MCParticleLevel, _jet_type_##MCParticleLevel, _shortname_ "PETMPW") \ - DECLARE_JET_TABLES(JCollision, _jet_type_##EventWiseSubtracted, _subtracted_track_type_, _hfcand_type_, _shortname_ "JETEWS") \ + DECLARE_JET_TABLES(JCollision, _jet_type_##EventWiseSubtracted, _subtracted_track_type_, _hfcand_type_, _shortname_ "EWSJET") \ DECLARE_JETMATCHING_TABLE(_jet_type_, _jet_type_##EventWiseSubtracted, _shortname_ "JET2EWS") \ - DECLARE_JETMATCHING_TABLE(_jet_type_##EventWiseSubtracted, _jet_type_, _shortname_ "JETEWS2") \ - DECLARE_JET_TABLES(JCollision, _jet_type_##MCDetectorLevelEventWiseSubtracted, _subtracted_track_type_, _hfcand_type_, _shortname_ "DJETEWS") \ + DECLARE_JETMATCHING_TABLE(_jet_type_##EventWiseSubtracted, _jet_type_, _shortname_ "EWSJET2") \ + DECLARE_JET_TABLES(JCollision, _jet_type_##MCDetectorLevelEventWiseSubtracted, _subtracted_track_type_, _hfcand_type_, _shortname_ "DEWSJET") \ DECLARE_MCEVENTWEIGHT_TABLE(_jet_type_##MCDetectorLevelEventWiseSubtracted, _jet_type_##MCDetectorLevelEventWiseSubtracted, _shortname_ "DJETEWSW") \ DECLARE_JETMATCHING_TABLE(_jet_type_##MCDetectorLevel, _jet_type_##MCDetectorLevelEventWiseSubtracted, _shortname_ "DJET2DEWS") \ - DECLARE_JETMATCHING_TABLE(_jet_type_##MCDetectorLevelEventWiseSubtracted, _jet_type_##MCDetectorLevel, _shortname_ "JETDEWS2D") \ - DECLARE_JET_TABLES(JMcCollision, _jet_type_##MCParticleLevelEventWiseSubtracted, _subtracted_track_type_, _hfparticle_type_, _shortname_ "PJETEWS") + DECLARE_JETMATCHING_TABLE(_jet_type_##MCDetectorLevelEventWiseSubtracted, _jet_type_##MCDetectorLevel, _shortname_ "DEWSJET2D") \ + DECLARE_JET_TABLES(JMcCollision, _jet_type_##MCParticleLevelEventWiseSubtracted, _subtracted_track_type_, _hfparticle_type_, _shortname_ "PEWSJET") #define STRINGIFY(x) #x @@ -179,7 +180,10 @@ DECLARE_JET_TABLES_LEVELS(Charged, JTrackSub, HfD0Bases, HfD0PBases, "C"); DECLARE_JET_TABLES_LEVELS(Full, JTrackSub, HfD0Bases, HfD0PBases, "F"); DECLARE_JET_TABLES_LEVELS(Neutral, JTrackSub, HfD0Bases, HfD0PBases, "N"); DECLARE_JET_TABLES_LEVELS(D0Charged, JTrackD0Sub, HfD0Bases, HfD0PBases, "D0"); +DECLARE_JET_TABLES_LEVELS(DplusCharged, JTrackDplusSub, HfDplusBases, HfDplusPBases, "DP"); +DECLARE_JET_TABLES_LEVELS(DstarCharged, JTrackDstarSub, HfDstarBases, HfDstarPBases, "DST"); DECLARE_JET_TABLES_LEVELS(LcCharged, JTrackLcSub, HfLcBases, HfLcPBases, "Lc"); +DECLARE_JET_TABLES_LEVELS(B0Charged, JTrackB0Sub, HfB0Bases, HfB0PBases, "B0"); DECLARE_JET_TABLES_LEVELS(BplusCharged, JTrackBplusSub, HfBplusBases, HfBplusPBases, "BP"); DECLARE_JET_TABLES_LEVELS(V0Charged, JTrackSub, V0Cores, JV0Mcs, "V0"); DECLARE_JET_TABLES_LEVELS(DielectronCharged, JTrackSub, Dielectrons, JDielectronMcs, "DIEL"); @@ -196,15 +200,15 @@ DECLARE_JET_DUPLICATE_TABLES_LEVELS(Charged, JTrackSub, HfD0Bases, HfD0PBases, " #undef STRINGIFY #undef DECLARE_JET_DUPLICATE_TABLES_LEVELS -using JetCollisions = JCollisions; +using JetCollisions = o2::soa::Join; using JetCollision = JetCollisions::iterator; using JetCollisionsMCD = o2::soa::Join; using JetCollisionMCD = o2::soa::Join::iterator; using JetTracks = JTracks; using JetTracksMCD = o2::soa::Join; using JetTracksSub = JTrackSubs; -using JetClusters = JClusters; -using JetClustersMCD = o2::soa::Join; +using JetClusters = o2::soa::Join; +using JetClustersMCD = o2::soa::Join; using JetMcCollisions = JMcCollisions; using JetMcCollision = JetMcCollisions::iterator; @@ -219,6 +223,22 @@ using JetParticlesSubD0 = JMcParticleD0Subs; using McCollisionsD0 = o2::soa::Join; using CandidatesD0MCP = o2::soa::Join; +using CollisionsDplus = o2::soa::Join; +using CandidatesDplusData = o2::soa::Join; +using CandidatesDplusMCD = o2::soa::Join; +using JetTracksSubDplus = JTrackDplusSubs; +using JetParticlesSubDplus = JMcParticleDplusSubs; +using McCollisionsDplus = o2::soa::Join; +using CandidatesDplusMCP = o2::soa::Join; + +using CollisionsDstar = o2::soa::Join; +using CandidatesDstarData = o2::soa::Join; +using CandidatesDstarMCD = o2::soa::Join; +using JetTracksSubDstar = JTrackDstarSubs; +using JetParticlesSubDstar = JMcParticleDstarSubs; +using McCollisionsDstar = o2::soa::Join; +using CandidatesDstarMCP = o2::soa::Join; + using CollisionsLc = o2::soa::Join; using CandidatesLcData = o2::soa::Join; using CandidatesLcMCD = o2::soa::Join; @@ -227,6 +247,14 @@ using JetParticlesSubLc = JMcParticleLcSubs; using McCollisionsLc = o2::soa::Join; using CandidatesLcMCP = o2::soa::Join; +using CollisionsB0 = o2::soa::Join; +using CandidatesB0Data = o2::soa::Join; +using CandidatesB0MCD = o2::soa::Join; +using JetTracksSubB0 = JTrackB0Subs; +using JetParticlesSubB0 = JMcParticleB0Subs; +using McCollisionsB0 = o2::soa::Join; +using CandidatesB0MCP = o2::soa::Join; + using CollisionsBplus = o2::soa::Join; using CandidatesBplusData = o2::soa::Join; using CandidatesBplusMCD = o2::soa::Join; @@ -235,8 +263,8 @@ using JetParticlesSubBplus = JMcParticleBplusSubs; using McCollisionsBplus = o2::soa::Join; using CandidatesBplusMCP = o2::soa::Join; -using CandidatesV0Data = o2::soa::Join; -using CandidatesV0MCD = o2::soa::Join; +using CandidatesV0Data = o2::soa::Join; +using CandidatesV0MCD = o2::soa::Join; // using V0Daughters = DauTrackExtras; using McCollisionsV0 = o2::soa::Join; using CandidatesV0MCP = o2::soa::Join; diff --git a/PWGJE/DataModel/JetReducedData.h b/PWGJE/DataModel/JetReducedData.h index 77aa55d9c29..fcc3d581862 100644 --- a/PWGJE/DataModel/JetReducedData.h +++ b/PWGJE/DataModel/JetReducedData.h @@ -17,11 +17,15 @@ #ifndef PWGJE_DATAMODEL_JETREDUCEDDATA_H_ #define PWGJE_DATAMODEL_JETREDUCEDDATA_H_ +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/EMCALClusters.h" // IWYU pragma: keep + +#include +#include // IWYU pragma: keep + #include +#include #include -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" namespace o2::aod { @@ -67,8 +71,24 @@ DECLARE_SOA_INDEX_COLUMN(JBC, bc); DECLARE_SOA_COLUMN(PosX, posX, float); DECLARE_SOA_COLUMN(PosY, posY, float); DECLARE_SOA_COLUMN(PosZ, posZ, float); -DECLARE_SOA_COLUMN(Multiplicity, multiplicity, float); -DECLARE_SOA_COLUMN(Centrality, centrality, float); +DECLARE_SOA_COLUMN(MultFV0A, multFV0A, float); +DECLARE_SOA_COLUMN(MultFV0C, multFV0C, float); +DECLARE_SOA_DYNAMIC_COLUMN(MultFV0M, multFV0M, + [](float multFV0A, float multFV0C) -> float { return multFV0A + multFV0C; }); +DECLARE_SOA_COLUMN(MultFT0A, multFT0A, float); +DECLARE_SOA_COLUMN(MultFT0C, multFT0C, float); +DECLARE_SOA_DYNAMIC_COLUMN(MultFT0M, multFT0M, + [](float multFT0A, float multFT0C) -> float { return multFT0A + multFT0C; }); +DECLARE_SOA_COLUMN(CentFV0A, centFV0A, float); +DECLARE_SOA_COLUMN(CentFV0M, centFV0M, float); // only Run 2 +DECLARE_SOA_COLUMN(CentFT0A, centFT0A, float); +DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); +DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); +DECLARE_SOA_COLUMN(CentFT0CVariant1, centFT0CVariant1, float); +DECLARE_SOA_COLUMN(CentralityVariant1, centralityVariant1, float); +DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, float); +DECLARE_SOA_COLUMN(Weight, weight, float); +DECLARE_SOA_COLUMN(SubGeneratorId, subGeneratorId, int); DECLARE_SOA_COLUMN(EventSel, eventSel, uint16_t); DECLARE_SOA_BITMAP_COLUMN(Alias, alias, 32); DECLARE_SOA_COLUMN(TrackOccupancyInTimeRange, trackOccupancyInTimeRange, int); @@ -88,8 +108,10 @@ DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSelUnanchoredMC, readCountsWith DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSelTVX, readCountsWithTVXAndZVertexAndSelTVX, std::vector); DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSel7, readCountsWithTVXAndZVertexAndSel7, std::vector); DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSel7KINT7, readCountsWithTVXAndZVertexAndSel7KINT7, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithCustom, readCountsWithCustom, std::vector); DECLARE_SOA_COLUMN(IsAmbiguous, isAmbiguous, bool); DECLARE_SOA_COLUMN(IsEMCALReadout, isEmcalReadout, bool); +DECLARE_SOA_COLUMN(IsOutlier, isOutlier, bool); } // namespace jcollision DECLARE_SOA_TABLE_STAGED(JCollisions, "JCOLLISION", @@ -97,8 +119,19 @@ DECLARE_SOA_TABLE_STAGED(JCollisions, "JCOLLISION", jcollision::PosX, jcollision::PosY, jcollision::PosZ, - jcollision::Multiplicity, - jcollision::Centrality, + jcollision::MultFV0A, + jcollision::MultFV0C, + jcollision::MultFV0M, + jcollision::MultFT0A, + jcollision::MultFT0C, + jcollision::MultFT0M, + jcollision::CentFV0A, + jcollision::CentFV0M, + jcollision::CentFT0A, + jcollision::CentFT0C, + jcollision::CentFT0M, + jcollision::CentFT0CVariant1, + jcollision::HadronicRate, jcollision::TrackOccupancyInTimeRange, jcollision::EventSel, jcollision::Alias, @@ -107,6 +140,13 @@ DECLARE_SOA_TABLE_STAGED(JCollisions, "JCOLLISION", using JCollision = JCollisions::iterator; using StoredJCollision = StoredJCollisions::iterator; +DECLARE_SOA_TABLE_STAGED(JCollisionMcInfos, "JCOLLISIONMCINFO", + jcollision::Weight, + jcollision::SubGeneratorId); + +DECLARE_SOA_TABLE_STAGED(JCollisionOutliers, "JCOLLISIONOUTLR", + jcollision::IsOutlier); + DECLARE_SOA_TABLE_STAGED(JEMCCollisionLbs, "JEMCCOLLISIONLB", jcollision::IsAmbiguous, jcollision::IsEMCALReadout); @@ -140,7 +180,8 @@ DECLARE_SOA_TABLE_STAGED(CollisionCounts, "COLLCOUNT", jcollision::ReadCountsWithTVXAndZVertexAndSelUnanchoredMC, jcollision::ReadCountsWithTVXAndZVertexAndSelTVX, jcollision::ReadCountsWithTVXAndZVertexAndSel7, - jcollision::ReadCountsWithTVXAndZVertexAndSel7KINT7); + jcollision::ReadCountsWithTVXAndZVertexAndSel7KINT7, + jcollision::ReadCountsWithCustom); namespace jmccollision { @@ -148,14 +189,41 @@ DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); DECLARE_SOA_COLUMN(PosX, posX, float); DECLARE_SOA_COLUMN(PosY, posY, float); DECLARE_SOA_COLUMN(PosZ, posZ, float); +DECLARE_SOA_COLUMN(MultFV0A, multFV0A, float); +DECLARE_SOA_COLUMN(MultFT0A, multFT0A, float); +DECLARE_SOA_COLUMN(MultFT0C, multFT0C, float); +DECLARE_SOA_COLUMN(CentFV0A, centFV0A, float); +DECLARE_SOA_COLUMN(CentFT0A, centFT0A, float); +DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); +DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); DECLARE_SOA_COLUMN(Weight, weight, float); +DECLARE_SOA_COLUMN(SubGeneratorId, subGeneratorId, int); +DECLARE_SOA_COLUMN(Accepted, accepted, uint64_t); +DECLARE_SOA_COLUMN(Attempted, attempted, uint64_t); +DECLARE_SOA_COLUMN(XsectGen, xsectGen, float); +DECLARE_SOA_COLUMN(XsectErr, xsectErr, float); +DECLARE_SOA_COLUMN(PtHard, ptHard, float); +DECLARE_SOA_COLUMN(IsOutlier, isOutlier, bool); } // namespace jmccollision DECLARE_SOA_TABLE_STAGED(JMcCollisions, "JMCCOLLISION", o2::soa::Index<>, jmccollision::PosX, jmccollision::PosY, jmccollision::PosZ, - jmccollision::Weight); + jmccollision::MultFV0A, + jmccollision::MultFT0A, + jmccollision::MultFT0C, + jmccollision::CentFV0A, + jmccollision::CentFT0A, + jmccollision::CentFT0C, + jmccollision::CentFT0M, + jmccollision::Weight, + jmccollision::SubGeneratorId, + jmccollision::Accepted, + jmccollision::Attempted, + jmccollision::XsectGen, + jmccollision::XsectErr, + jmccollision::PtHard); using JMcCollision = JMcCollisions::iterator; using StoredJMcCollision = StoredJMcCollisions::iterator; @@ -171,6 +239,9 @@ DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision); DECLARE_SOA_TABLE_STAGED(JMcCollisionLbs, "JMCCOLLISIONLB", jmccollisionlb::JMcCollisionId); +DECLARE_SOA_TABLE_STAGED(JMcCollisionOutliers, "JMCCOLLISIONOUTLR", + jmccollision::IsOutlier); + namespace jtrack { DECLARE_SOA_INDEX_COLUMN(JCollision, collision); @@ -199,7 +270,13 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, DECLARE_SOA_DYNAMIC_COLUMN(Energy, energy, [](float pt, float eta) -> float { return std::sqrt((pt * std::cosh(eta) * pt * std::cosh(eta)) + (jetderiveddatautilities::mPion * jetderiveddatautilities::mPion)); }); DECLARE_SOA_DYNAMIC_COLUMN(Sign, sign, - [](uint8_t trackSel) -> int { if (trackSel & (1 << jetderiveddatautilities::JTrackSel::trackSign)){ return 1;} else{return -1;} }); + [](uint8_t trackSel) -> int { + if (trackSel & (1 << jetderiveddatautilities::JTrackSel::trackSign)) { + return 1; + } else { + return -1; + } + }); } // namespace jtrack DECLARE_SOA_TABLE_STAGED(JTracks, "JTRACK", @@ -348,9 +425,23 @@ DECLARE_SOA_TABLE_STAGED(JClusterPIs, "JCLUSTERPI", DECLARE_SOA_TABLE_STAGED(JClusterTracks, "JCLUSTERTRACK", //! jcluster::JTrackIds); +namespace jclusterhadroniccorrection +{ +DECLARE_SOA_COLUMN(EnergyCorrectedOneTrack1, energyCorrectedOneTrack1, float); //! with hadronic correction fraction (100%) for one matched track +DECLARE_SOA_COLUMN(EnergyCorrectedOneTrack2, energyCorrectedOneTrack2, float); //! with hadronic correction fraction (70%) for one matched track - systematic studies +DECLARE_SOA_COLUMN(EnergyCorrectedAllTracks1, energyCorrectedAllTracks1, float); //! with hadronic correction fraction (100%) for all matched tracks +DECLARE_SOA_COLUMN(EnergyCorrectedAllTracks2, energyCorrectedAllTracks2, float); //! with hadronic correction fraction (70%) for all matched tracks - for systematic studies +} // namespace jclusterhadroniccorrection + +DECLARE_SOA_TABLE_STAGED(JClustersCorrectedEnergies, "JCLUSTERCORRE", //! if this table changes it needs to be reflected in FastJetUtilities.h!! + jclusterhadroniccorrection::EnergyCorrectedOneTrack1, // corrected cluster energy for 1 matched track (f = 100%) + jclusterhadroniccorrection::EnergyCorrectedOneTrack2, // corrected cluster energy for 1 matched track (f = 70%) + jclusterhadroniccorrection::EnergyCorrectedAllTracks1, // corrected cluster energy for all matched tracks (f = 100%) + jclusterhadroniccorrection::EnergyCorrectedAllTracks2); // corrected cluster energy for all matched tracks (f = 70%) + namespace jmcclusterlb { -DECLARE_SOA_ARRAY_INDEX_COLUMN(JMcParticle, mcParticle); +DECLARE_SOA_ARRAY_INDEX_COLUMN(JMcParticle, mcParticles); DECLARE_SOA_COLUMN(AmplitudeA, amplitudeA, std::vector); } // namespace jmcclusterlb diff --git a/PWGJE/DataModel/JetReducedDataDQ.h b/PWGJE/DataModel/JetReducedDataDQ.h index a5779ebd3b4..f86754d3a84 100644 --- a/PWGJE/DataModel/JetReducedDataDQ.h +++ b/PWGJE/DataModel/JetReducedDataDQ.h @@ -17,14 +17,21 @@ #ifndef PWGJE_DATAMODEL_JETREDUCEDDATADQ_H_ #define PWGJE_DATAMODEL_JETREDUCEDDATADQ_H_ -#include -#include -#include "Framework/AnalysisDataModel.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" #include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetReducedDataHF.h" + +#include +#include // IWYU pragma: keep + +#include +#include namespace o2::aod { +namespace jdielectronmccollision +{ +DECLARE_SOA_COLUMN(DummyDQ, dummyDQ, bool); +} // namespace jdielectronmccollision DECLARE_SOA_TABLE_STAGED(JDielectronMcCollisions, "JDIELMCCOLL", o2::soa::Index<>, @@ -32,26 +39,29 @@ DECLARE_SOA_TABLE_STAGED(JDielectronMcCollisions, "JDIELMCCOLL", jmccollision::PosY, jmccollision::PosZ); +DECLARE_SOA_TABLE_STAGED(JDielectronMcRCollDummys, "JDIELMCRCOLLDUM", + jdielectronmccollision::DummyDQ); + namespace jdielectronindices { -DECLARE_SOA_INDEX_COLUMN(JCollision, collision); DECLARE_SOA_INDEX_COLUMN_CUSTOM(JDielectronMcCollision, dielectronmccollision, "JDIELMCCOLLS"); DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, JTracks, "_0"); DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, JTracks, "_1"); -DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision); -DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle); } // namespace jdielectronindices DECLARE_SOA_TABLE_STAGED(JDielectronCollisionIds, "JDIELCOLLID", - jdielectronindices::JCollisionId); + jcandidateindices::JCollisionId, + o2::soa::Marker); DECLARE_SOA_TABLE_STAGED(JDielectronMcCollisionIds, "JDIELMCCOLLID", - jdielectronindices::JMcCollisionId); + jcandidateindices::JMcCollisionId, + o2::soa::Marker); DECLARE_SOA_TABLE_STAGED(JDielectronIds, "JDIELID", - jdielectronindices::JCollisionId, + jcandidateindices::JCollisionId, jdielectronindices::Prong0Id, - jdielectronindices::Prong1Id); + jdielectronindices::Prong1Id, + o2::soa::Marker); namespace jdielectronmc { @@ -103,8 +113,8 @@ using JDielectronMc = JDielectronMcs::iterator; using StoredJDielectronMc = StoredJDielectronMcs::iterator; DECLARE_SOA_TABLE_STAGED(JDielectronMcIds, "JDIELMCID", - jdielectronindices::JMcCollisionId, - jdielectronindices::JMcParticleId, + jcandidateindices::JMcCollisionId, + jcandidateindices::JMcParticleId, jdielectronmc::MothersIds, jdielectronmc::DaughtersIdSlice); diff --git a/PWGJE/DataModel/JetReducedDataHF.h b/PWGJE/DataModel/JetReducedDataHF.h index 855746326a2..f295dbfa398 100644 --- a/PWGJE/DataModel/JetReducedDataHF.h +++ b/PWGJE/DataModel/JetReducedDataHF.h @@ -17,38 +17,57 @@ #ifndef PWGJE_DATAMODEL_JETREDUCEDDATAHF_H_ #define PWGJE_DATAMODEL_JETREDUCEDDATAHF_H_ -#include -#include -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/EMCALClusters.h" // IWYU pragma: keep #include "PWGJE/DataModel/JetReducedData.h" +#include +#include // IWYU pragma: keep + +#include + +#include + namespace o2::aod { -namespace jd0indices +constexpr uint JMarkerD0 = 1; +constexpr uint JMarkerDplus = 2; +constexpr uint JMarkerLc = 3; +constexpr uint JMarkerBplus = 4; +constexpr uint JMarkerDielectron = 5; +constexpr uint JMarkerDstar = 6; +constexpr uint JMarkerB0 = 7; + +namespace jcandidateindices { DECLARE_SOA_INDEX_COLUMN(JCollision, collision); -DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, JTracks, "_0"); -DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, JTracks, "_1"); DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision); DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle); +} // namespace jcandidateindices + +namespace jd0indices +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, JTracks, "_0"); +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, JTracks, "_1"); } // namespace jd0indices DECLARE_SOA_TABLE_STAGED(JD0CollisionIds, "JD0COLLID", - jd0indices::JCollisionId); + jcandidateindices::JCollisionId, + o2::soa::Marker); DECLARE_SOA_TABLE_STAGED(JD0McCollisionIds, "JD0MCCOLLID", - jd0indices::JMcCollisionId); + jcandidateindices::JMcCollisionId, + o2::soa::Marker); DECLARE_SOA_TABLE_STAGED(JD0Ids, "JD0ID", - jd0indices::JCollisionId, + jcandidateindices::JCollisionId, jd0indices::Prong0Id, jd0indices::Prong1Id); DECLARE_SOA_TABLE_STAGED(JD0PIds, "JD0PID", - jd0indices::JMcCollisionId, - jd0indices::JMcParticleId); + jcandidateindices::JMcCollisionId, + jcandidateindices::JMcParticleId, + o2::soa::Marker); namespace jdummyd0 { @@ -63,31 +82,113 @@ DECLARE_SOA_TABLE(JDumD0MlDaus, "AOD", "JDumD0MLDAU", jdummyd0::DummyD0, o2::soa::Marker<2>); +namespace jdplusindices +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, JTracks, "_0"); +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, JTracks, "_1"); +DECLARE_SOA_INDEX_COLUMN_FULL(Prong2, prong2, int, JTracks, "_2"); +} // namespace jdplusindices + +DECLARE_SOA_TABLE_STAGED(JDplusCollisionIds, "JDPCOLLID", + jcandidateindices::JCollisionId, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(JDplusMcCollisionIds, "JDPMCCOLLID", + jcandidateindices::JMcCollisionId, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(JDplusIds, "JDPID", + jcandidateindices::JCollisionId, + jdplusindices::Prong0Id, + jdplusindices::Prong1Id, + jdplusindices::Prong2Id); + +DECLARE_SOA_TABLE_STAGED(JDplusPIds, "JDPPID", + jcandidateindices::JMcCollisionId, + jcandidateindices::JMcParticleId, + o2::soa::Marker); + +namespace jdummydplus +{ + +DECLARE_SOA_COLUMN(DummyDplus, dummyDplus, bool); + +} // namespace jdummydplus +DECLARE_SOA_TABLE(JDumDplusParDaus, "AOD", "JDUMDPPARDAU", + jdummydplus::DummyDplus, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(JDumDplusMlDaus, "AOD", "JDUMDPMLDAU", + jdummydplus::DummyDplus, + o2::soa::Marker<2>); + +// might have to update!!!!!!!!!!!!!!!!!!!!!! + +namespace jdstarindices +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, JTracks, "_0"); +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, JTracks, "_1"); +DECLARE_SOA_INDEX_COLUMN_FULL(Prong2, prong2, int, JTracks, "_2"); +} // namespace jdstarindices + +DECLARE_SOA_TABLE_STAGED(JDstarCollisionIds, "JDSTCOLLID", + jcandidateindices::JCollisionId, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(JDstarMcCollisionIds, "JDSTMCCOLLID", + jcandidateindices::JMcCollisionId, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(JDstarIds, "JDSTID", + jcandidateindices::JCollisionId, + jdstarindices::Prong0Id, + jdstarindices::Prong1Id, + jdstarindices::Prong2Id); + +DECLARE_SOA_TABLE_STAGED(JDstarPIds, "JDSTPID", + jcandidateindices::JMcCollisionId, + jcandidateindices::JMcParticleId, + o2::soa::Marker); + +namespace jdummydstar +{ + +DECLARE_SOA_COLUMN(DummyDstar, dummyDstar, bool); + +} // namespace jdummydstar +DECLARE_SOA_TABLE(JDumDstarParEs, "AOD", "JDUMDSTPARE", + jdummydstar::DummyDstar, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(JDumDstarMlDaus, "AOD", "JDUMDSTMLDAU", + jdummydstar::DummyDstar, + o2::soa::Marker<2>); + namespace jlcindices { -DECLARE_SOA_INDEX_COLUMN(JCollision, collision); DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, JTracks, "_0"); DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, JTracks, "_1"); DECLARE_SOA_INDEX_COLUMN_FULL(Prong2, prong2, int, JTracks, "_2"); -DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision); -DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle); } // namespace jlcindices DECLARE_SOA_TABLE_STAGED(JLcCollisionIds, "JLCCOLLID", - jlcindices::JCollisionId); + jcandidateindices::JCollisionId, + o2::soa::Marker); DECLARE_SOA_TABLE_STAGED(JLcMcCollisionIds, "JLCMCCOLLID", - jlcindices::JMcCollisionId); + jcandidateindices::JMcCollisionId, + o2::soa::Marker); DECLARE_SOA_TABLE_STAGED(JLcIds, "JLCID", - jlcindices::JCollisionId, + jcandidateindices::JCollisionId, jlcindices::Prong0Id, jlcindices::Prong1Id, jlcindices::Prong2Id); DECLARE_SOA_TABLE_STAGED(JLcPIds, "JLCPID", - jlcindices::JMcCollisionId, - jlcindices::JMcParticleId); + jcandidateindices::JMcCollisionId, + jcandidateindices::JMcParticleId, + o2::soa::Marker); namespace jdummylc { @@ -103,31 +204,59 @@ DECLARE_SOA_TABLE(JDumLcMlDaus, "AOD", "JDUMLCMLDAU", jdummylc::DummyLc, o2::soa::Marker<2>); +namespace jb0indices +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, JTracks, "_0"); +DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, JTracks, "_1"); +DECLARE_SOA_INDEX_COLUMN_FULL(Prong2, prong2, int, JTracks, "_2"); +DECLARE_SOA_INDEX_COLUMN_FULL(Prong3, prong3, int, JTracks, "_3"); +} // namespace jb0indices + +DECLARE_SOA_TABLE_STAGED(JB0CollisionIds, "JB0COLLID", + jcandidateindices::JCollisionId, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(JB0McCollisionIds, "JB0MCCOLLID", + jcandidateindices::JMcCollisionId, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(JB0Ids, "JB0ID", + jcandidateindices::JCollisionId, + jb0indices::Prong0Id, + jb0indices::Prong1Id, + jb0indices::Prong2Id, + jb0indices::Prong3Id); + +DECLARE_SOA_TABLE_STAGED(JB0PIds, "JB0PID", + jcandidateindices::JMcCollisionId, + jcandidateindices::JMcParticleId, + o2::soa::Marker); + namespace jbplusindices { -DECLARE_SOA_INDEX_COLUMN(JCollision, collision); DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, JTracks, "_0"); DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, JTracks, "_1"); DECLARE_SOA_INDEX_COLUMN_FULL(Prong2, prong2, int, JTracks, "_2"); -DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision); -DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle); } // namespace jbplusindices DECLARE_SOA_TABLE_STAGED(JBplusCollisionIds, "JBPCOLLID", - jbplusindices::JCollisionId); + jcandidateindices::JCollisionId, + o2::soa::Marker); DECLARE_SOA_TABLE_STAGED(JBplusMcCollisionIds, "JBPMCCOLLID", - jbplusindices::JMcCollisionId); + jcandidateindices::JMcCollisionId, + o2::soa::Marker); DECLARE_SOA_TABLE_STAGED(JBplusIds, "JBPID", - jbplusindices::JCollisionId, + jcandidateindices::JCollisionId, jbplusindices::Prong0Id, jbplusindices::Prong1Id, jbplusindices::Prong2Id); DECLARE_SOA_TABLE_STAGED(JBplusPIds, "JBPPID", - jbplusindices::JMcCollisionId, - jbplusindices::JMcParticleId); + jcandidateindices::JMcCollisionId, + jcandidateindices::JMcParticleId, + o2::soa::Marker); } // namespace o2::aod diff --git a/PWGJE/DataModel/JetReducedDataSelector.h b/PWGJE/DataModel/JetReducedDataSelector.h new file mode 100644 index 00000000000..9529debc58e --- /dev/null +++ b/PWGJE/DataModel/JetReducedDataSelector.h @@ -0,0 +1,39 @@ +// 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. + +/// +/// \brief Table definitions for selectors for writing out reduced data model for jets +/// +/// \author Nima Zardoshti + +#ifndef PWGJE_DATAMODEL_JETREDUCEDDATASELECTOR_H_ +#define PWGJE_DATAMODEL_JETREDUCEDDATASELECTOR_H_ + +#include + +#include + +namespace o2::aod +{ +namespace jetreduceddataselector +{ +DECLARE_SOA_COLUMN(IsCollisionSelected, isCollisionSelected, bool); +DECLARE_SOA_COLUMN(IsMcCollisionSelected, isMcCollisionSelected, bool); + +} // namespace jetreduceddataselector +DECLARE_SOA_TABLE(JCollisionSelections, "AOD", "JCOLLSELECTION", + jetreduceddataselector::IsCollisionSelected); + +DECLARE_SOA_TABLE(JMcCollisionSelections, "AOD", "JMCCOLLSELECTION", + jetreduceddataselector::IsMcCollisionSelected); +} // namespace o2::aod + +#endif // PWGJE_DATAMODEL_JETREDUCEDDATASELECTOR_H_ diff --git a/PWGJE/DataModel/JetReducedDataV0.h b/PWGJE/DataModel/JetReducedDataV0.h index d904403b532..433cd885f65 100644 --- a/PWGJE/DataModel/JetReducedDataV0.h +++ b/PWGJE/DataModel/JetReducedDataV0.h @@ -17,12 +17,14 @@ #ifndef PWGJE_DATAMODEL_JETREDUCEDDATAV0_H_ #define PWGJE_DATAMODEL_JETREDUCEDDATAV0_H_ -#include -#include -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/EMCALClusters.h" #include "PWGJE/DataModel/JetReducedData.h" +#include +#include // IWYU pragma: keep + +#include +#include + namespace o2::aod { diff --git a/PWGJE/DataModel/JetSubstructure.h b/PWGJE/DataModel/JetSubstructure.h index 9b606b8dcfd..88f0578d469 100644 --- a/PWGJE/DataModel/JetSubstructure.h +++ b/PWGJE/DataModel/JetSubstructure.h @@ -17,39 +17,143 @@ #ifndef PWGJE_DATAMODEL_JETSUBSTRUCTURE_H_ #define PWGJE_DATAMODEL_JETSUBSTRUCTURE_H_ +#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGJE/DataModel/Jet.h" // IWYU pragma: keep +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetReducedDataDQ.h" + +#include + #include +#include #include -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGJE/DataModel/Jet.h" namespace o2::aod { namespace jetcollision -{ //! -DECLARE_SOA_COLUMN(PosZ, posZ, float); //! -DECLARE_SOA_COLUMN(Centrality, centrality, float); //! -DECLARE_SOA_COLUMN(EventSel, eventSel, uint8_t); //! +{ //! +DECLARE_SOA_COLUMN(PosZ, posZ, float); //! +DECLARE_SOA_COLUMN(Centrality, centrality, float); //! +DECLARE_SOA_COLUMN(EventSel, eventSel, uint8_t); //! DECLARE_SOA_COLUMN(EventWeight, eventWeight, float); //! } // namespace jetcollision +namespace jetmccollision +{ +DECLARE_SOA_COLUMN(PosZ, posZ, float); //! +DECLARE_SOA_COLUMN(Accepted, accepted, uint64_t); //! +DECLARE_SOA_COLUMN(Attempted, attempted, uint64_t); //! +DECLARE_SOA_COLUMN(XsectGen, xsectGen, float); //! +DECLARE_SOA_COLUMN(XsectErr, xsectErr, float); //! +DECLARE_SOA_COLUMN(EventWeight, eventWeight, float); //! +} // namespace jetmccollision + namespace jetsubstructure -{ //! -DECLARE_SOA_COLUMN(EnergyMother, energyMother, std::vector); //! -DECLARE_SOA_COLUMN(PtLeading, ptLeading, std::vector); //! -DECLARE_SOA_COLUMN(PtSubLeading, ptSubLeading, std::vector); //! -DECLARE_SOA_COLUMN(Theta, theta, std::vector); //! -DECLARE_SOA_COLUMN(NSub2DR, nSub2DR, float); //! -DECLARE_SOA_COLUMN(NSub1, nSub1, float); //! -DECLARE_SOA_COLUMN(NSub2, nSub2, float); //! -DECLARE_SOA_COLUMN(PairPt, pairPt, std::vector); //! -DECLARE_SOA_COLUMN(PairEnergy, pairEnergy, std::vector); //! -DECLARE_SOA_COLUMN(PairTheta, pairTheta, std::vector); //! -DECLARE_SOA_COLUMN(Angularity, angularity, float); //! +{ //! +DECLARE_SOA_COLUMN(EnergyMother, energyMother, std::vector); //! +DECLARE_SOA_COLUMN(PtLeading, ptLeading, std::vector); //! +DECLARE_SOA_COLUMN(PtSubLeading, ptSubLeading, std::vector); //! +DECLARE_SOA_COLUMN(Theta, theta, std::vector); //! +DECLARE_SOA_COLUMN(NSub2DR, nSub2DR, float); //! +DECLARE_SOA_COLUMN(NSub1, nSub1, float); //! +DECLARE_SOA_COLUMN(NSub2, nSub2, float); //! +DECLARE_SOA_COLUMN(PairJetPt, pairJetPt, std::vector); //! +DECLARE_SOA_COLUMN(PairJetEnergy, pairJetEnergy, std::vector); //! +DECLARE_SOA_COLUMN(PairJetTheta, pairJetTheta, std::vector); //! +DECLARE_SOA_COLUMN(PairJetPerpCone1Pt, pairJetPerpCone1Pt, std::vector); //! +DECLARE_SOA_COLUMN(PairJetPerpCone1Energy, pairJetPerpCone1Energy, std::vector); //! +DECLARE_SOA_COLUMN(PairJetPerpCone1Theta, pairJetPerpCone1Theta, std::vector); //! +DECLARE_SOA_COLUMN(PairPerpCone1PerpCone1Pt, pairPerpCone1PerpCone1Pt, std::vector); //! +DECLARE_SOA_COLUMN(PairPerpCone1PerpCone1Energy, pairPerpCone1PerpCone1Energy, std::vector); //! +DECLARE_SOA_COLUMN(PairPerpCone1PerpCone1Theta, pairPerpCone1PerpCone1Theta, std::vector); //! +DECLARE_SOA_COLUMN(PairPerpCone1PerpCone2Pt, pairPerpCone1PerpCone2Pt, std::vector); //! +DECLARE_SOA_COLUMN(PairPerpCone1PerpCone2Energy, pairPerpCone1PerpCone2Energy, std::vector); //! +DECLARE_SOA_COLUMN(PairPerpCone1PerpCone2Theta, pairPerpCone1PerpCone2Theta, std::vector); //! +DECLARE_SOA_COLUMN(Angularity, angularity, float); //! +DECLARE_SOA_COLUMN(PtLeadingConstituent, ptLeadingConstituent, float); //! +DECLARE_SOA_COLUMN(PerpConeRho, perpConeRho, float); //! +DECLARE_SOA_COLUMN(SplittingMatchingGeo, splittingMatchingGeo, std::vector); //! +DECLARE_SOA_COLUMN(SplittingMatchingPt, splittingMatchingPt, std::vector); //! +DECLARE_SOA_COLUMN(SplittingMatchingHF, splittingMatchingHF, std::vector); //! +DECLARE_SOA_COLUMN(PairMatching, pairMatching, std::vector); //! } // namespace jetsubstructure +namespace splitting +{ //! +DECLARE_SOA_COLUMN(Pt, pt, float); //! +DECLARE_SOA_COLUMN(Eta, eta, float); //! +DECLARE_SOA_COLUMN(Phi, phi, float); //! +DECLARE_SOA_COLUMN(R, r, int); //! +DECLARE_SOA_COLUMN(SplittingMatchingGeo, splittingMatchingGeo, std::vector); //! +DECLARE_SOA_COLUMN(SplittingMatchingPt, splittingMatchingPt, std::vector); //! +DECLARE_SOA_COLUMN(SplittingMatchingHF, splittingMatchingHF, std::vector); //! +} // namespace splitting + +// Defines the jet table definition +#define JETSPLITTING_TABLE_DEF(_jet_type_, _jet_description_, _name_, _track_type_, _cand_type_) \ + \ + namespace _name_##splitting \ + { \ + DECLARE_SOA_INDEX_COLUMN(_jet_type_##Jet, jet); \ + } \ + namespace _name_##splittingconstituents \ + { \ + DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(Tracks, tracks, int32_t, _track_type_, "_tracks"); \ + DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(Clusters, clusters, int32_t, JClusters, "_clusters"); \ + DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(Candidates, candidates, int32_t, _cand_type_, "_cand"); \ + } \ + DECLARE_SOA_TABLE(_jet_type_##SPs, "AOD", _jet_description_ "SP", \ + o2::soa::Index<>, \ + _name_##splitting::_jet_type_##JetId, \ + _name_##splittingconstituents::TracksIds, \ + _name_##splittingconstituents::ClustersIds, \ + _name_##splittingconstituents::CandidatesIds, \ + splitting::Pt, \ + splitting::Eta, \ + splitting::Phi, \ + splitting::R); + +#define JETSPLITTINGMATCHING_TABLE_DEF(_jet_type_base_, _jet_type_tag_, _description_) \ + \ + DECLARE_SOA_TABLE(_jet_type_base_##SPsMatchedTo##_jet_type_tag_##SPs, "AOD", _description_ "SP", \ + splitting::SplittingMatchingGeo, \ + splitting::SplittingMatchingPt, \ + splitting::SplittingMatchingHF); + +namespace pair +{ //! +DECLARE_SOA_COLUMN(PairMatching, pairMatching, std::vector); //! +} // namespace pair + +// Defines the jet table definition +#define JETPAIR_TABLE_DEF(_jet_type_, _jet_description_, _name_, _track_type_, _cand_type_) \ + \ + namespace _name_##pair \ + { \ + DECLARE_SOA_INDEX_COLUMN(_jet_type_##Jet, jet); \ + } \ + namespace _name_##pairconstituents \ + { \ + DECLARE_SOA_INDEX_COLUMN_FULL(Track1, track1, int32_t, _track_type_, "_track1"); \ + DECLARE_SOA_INDEX_COLUMN_FULL(Track2, track2, int32_t, _track_type_, "_track2"); \ + DECLARE_SOA_INDEX_COLUMN_FULL(Candidate1, candidate1, int32_t, _cand_type_, "_cand1"); \ + DECLARE_SOA_INDEX_COLUMN_FULL(Candidate2, candidate2, int32_t, _cand_type_, "_cand2"); \ + } \ + DECLARE_SOA_TABLE(_jet_type_##PRs, "AOD", _jet_description_ "PR", \ + o2::soa::Index<>, \ + _name_##pair::_jet_type_##JetId, \ + _name_##pairconstituents::Track1Id, \ + _name_##pairconstituents::Track2Id, \ + _name_##pairconstituents::Candidate1Id, \ + _name_##pairconstituents::Candidate2Id); + +#define JETPAIRMATCHING_TABLE_DEF(_jet_type_base_, _jet_type_tag_, _description_) \ + \ + DECLARE_SOA_TABLE(_jet_type_base_##PRsMatchedTo##_jet_type_tag_##PRs, "AOD", _description_ "PR", \ + pair::PairMatching); + namespace jetoutput { DECLARE_SOA_COLUMN(JetPt, jetPt, float); //! @@ -57,38 +161,54 @@ DECLARE_SOA_COLUMN(JetPhi, jetPhi, float); //! DECLARE_SOA_COLUMN(JetEta, jetEta, float); //! DECLARE_SOA_COLUMN(JetY, jetY, float); //! DECLARE_SOA_COLUMN(JetR, jetR, float); //! +DECLARE_SOA_COLUMN(JetArea, jetArea, float); //! +DECLARE_SOA_COLUMN(JetRho, jetRho, float); //! +DECLARE_SOA_COLUMN(JetPerpConeRho, jetPerpConeRho, float); //! DECLARE_SOA_COLUMN(JetNConstituents, jetNConstituents, int); //! - } // namespace jetoutput +#define MCCOLL_TABLE_DEF(_jet_type_, _jet_description_, _name_) \ + namespace _name_##mccollisionoutput \ + { \ + DECLARE_SOA_DYNAMIC_COLUMN(Dummy##_jet_type_, dummy##_jet_type_, []() -> int { return 0; }); \ + } \ + DECLARE_SOA_TABLE(_jet_type_##MCCOs, "AOD", _jet_description_ "MCCO", \ + jetmccollision::PosZ, \ + jetmccollision::Accepted, \ + jetmccollision::Attempted, \ + jetmccollision::XsectGen, \ + jetmccollision::XsectErr, \ + jetmccollision::EventWeight, \ + _name_##mccollisionoutput::Dummy##_jet_type_<>); + // Defines the jet substrcuture table definition -#define JETSUBSTRUCTURE_TABLE_DEF(_jet_type_, _jet_description_, _name_, _cand_type_, _cand_description_) \ - \ - namespace _name_##collisionoutput \ - { \ - DECLARE_SOA_DYNAMIC_COLUMN(Dummy##_jet_type_, dummy##_jet_type_, []() -> int { return 0; }); \ - } \ - \ - DECLARE_SOA_TABLE(_jet_type_##COs, "AOD", _jet_description_ "CO", jetcollision::PosZ, jetcollision::Centrality, jetcollision::EventSel, jetcollision::EventWeight, _name_##collisionoutput::Dummy##_jet_type_<>); \ - using _jet_type_##CO = _jet_type_##COs::iterator; \ - \ - namespace _name_##jetoutput \ - { \ - DECLARE_SOA_INDEX_COLUMN_CUSTOM(_jet_type_##CO, collision, _jet_description_ "COS"); \ - DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(Candidate, candidate, int, _cand_type_, _cand_description_ "S", "_0"); \ - } \ - DECLARE_SOA_TABLE(_jet_type_##Os, "AOD", _jet_description_ "O", _name_##jetoutput::_jet_type_##COId, _name_##jetoutput::CandidateId, jetoutput::JetPt, jetoutput::JetPhi, jetoutput::JetEta, jetoutput::JetY, jetoutput::JetR, jetoutput::JetNConstituents); \ - using _jet_type_##O = _jet_type_##Os::iterator; \ - namespace _name_##substructure \ - { \ - DECLARE_SOA_INDEX_COLUMN_CUSTOM(_jet_type_##O, outputTable, _jet_description_ "OS"); \ - DECLARE_SOA_DYNAMIC_COLUMN(Dummy##_jet_type_, dummy##_jet_type_, []() -> int { return 0; }); \ - } \ - \ - DECLARE_SOA_TABLE(_jet_type_##SSs, "AOD", _jet_description_ "SS", jetsubstructure::EnergyMother, jetsubstructure::PtLeading, jetsubstructure::PtSubLeading, jetsubstructure::Theta, jetsubstructure::NSub2DR, jetsubstructure::NSub1, jetsubstructure::NSub2, jetsubstructure::PairPt, jetsubstructure::PairEnergy, jetsubstructure::PairTheta, jetsubstructure::Angularity, _name_##substructure::Dummy##_jet_type_<>); \ - DECLARE_SOA_TABLE(_jet_type_##SSOs, "AOD", _jet_description_ "SSO", _name_##substructure::_jet_type_##OId, jetsubstructure::EnergyMother, jetsubstructure::PtLeading, jetsubstructure::PtSubLeading, jetsubstructure::Theta, jetsubstructure::NSub2DR, jetsubstructure::NSub1, jetsubstructure::NSub2, jetsubstructure::PairPt, jetsubstructure::PairEnergy, jetsubstructure::PairTheta, jetsubstructure::Angularity); \ - \ - using _jet_type_##O = _jet_type_##Os::iterator; \ +#define JETSUBSTRUCTURE_TABLE_DEF(_jet_type_, _jet_description_, _name_, _cand_type_, _cand_description_) \ + \ + namespace _name_##collisionoutput \ + { \ + DECLARE_SOA_DYNAMIC_COLUMN(Dummy##_jet_type_, dummy##_jet_type_, []() -> int { return 0; }); \ + } \ + \ + DECLARE_SOA_TABLE(_jet_type_##COs, "AOD", _jet_description_ "CO", jetcollision::PosZ, jetcollision::Centrality, jetcollision::EventSel, jetcollision::EventWeight, _name_##collisionoutput::Dummy##_jet_type_<>); \ + using _jet_type_##CO = _jet_type_##COs::iterator; \ + \ + namespace _name_##jetoutput \ + { \ + DECLARE_SOA_INDEX_COLUMN_CUSTOM(_jet_type_##CO, collision, _jet_description_ "COS"); \ + DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(Candidate, candidate, int, _cand_type_, _cand_description_ "S", "_0"); \ + } \ + DECLARE_SOA_TABLE(_jet_type_##Os, "AOD", _jet_description_ "O", _name_##jetoutput::_jet_type_##COId, _name_##jetoutput::CandidateId, jetoutput::JetPt, jetoutput::JetPhi, jetoutput::JetEta, jetoutput::JetY, jetoutput::JetR, jetoutput::JetArea, jetoutput::JetRho, jetoutput::JetPerpConeRho, jetoutput::JetNConstituents); \ + using _jet_type_##O = _jet_type_##Os::iterator; \ + namespace _name_##substructure \ + { \ + DECLARE_SOA_INDEX_COLUMN_CUSTOM(_jet_type_##O, outputTable, _jet_description_ "OS"); \ + DECLARE_SOA_DYNAMIC_COLUMN(Dummy##_jet_type_, dummy##_jet_type_, []() -> int { return 0; }); \ + } \ + \ + DECLARE_SOA_TABLE(_jet_type_##SSs, "AOD", _jet_description_ "SS", jetsubstructure::EnergyMother, jetsubstructure::PtLeading, jetsubstructure::PtSubLeading, jetsubstructure::Theta, jetsubstructure::NSub2DR, jetsubstructure::NSub1, jetsubstructure::NSub2, jetsubstructure::PairJetPt, jetsubstructure::PairJetEnergy, jetsubstructure::PairJetTheta, jetsubstructure::PairJetPerpCone1Pt, jetsubstructure::PairJetPerpCone1Energy, jetsubstructure::PairJetPerpCone1Theta, jetsubstructure::PairPerpCone1PerpCone1Pt, jetsubstructure::PairPerpCone1PerpCone1Energy, jetsubstructure::PairPerpCone1PerpCone1Theta, jetsubstructure::PairPerpCone1PerpCone2Pt, jetsubstructure::PairPerpCone1PerpCone2Energy, jetsubstructure::PairPerpCone1PerpCone2Theta, jetsubstructure::Angularity, jetsubstructure::PtLeadingConstituent, jetsubstructure::PerpConeRho, _name_##substructure::Dummy##_jet_type_<>); \ + DECLARE_SOA_TABLE(_jet_type_##SSOs, "AOD", _jet_description_ "SSO", _name_##substructure::_jet_type_##OId, jetsubstructure::EnergyMother, jetsubstructure::PtLeading, jetsubstructure::PtSubLeading, jetsubstructure::Theta, jetsubstructure::NSub2DR, jetsubstructure::NSub1, jetsubstructure::NSub2, jetsubstructure::PairJetPt, jetsubstructure::PairJetEnergy, jetsubstructure::PairJetTheta, jetsubstructure::PairJetPerpCone1Pt, jetsubstructure::PairJetPerpCone1Energy, jetsubstructure::PairJetPerpCone1Theta, jetsubstructure::PairPerpCone1PerpCone1Pt, jetsubstructure::PairPerpCone1PerpCone1Energy, jetsubstructure::PairPerpCone1PerpCone1Theta, jetsubstructure::PairPerpCone1PerpCone2Pt, jetsubstructure::PairPerpCone1PerpCone2Energy, jetsubstructure::PairPerpCone1PerpCone2Theta, jetsubstructure::Angularity, jetsubstructure::PtLeadingConstituent, jetsubstructure::SplittingMatchingGeo, jetsubstructure::SplittingMatchingPt, jetsubstructure::SplittingMatchingHF, jetsubstructure::PairMatching); \ + \ + using _jet_type_##O = _jet_type_##Os::iterator; \ using _jet_type_##SSO = _jet_type_##SSOs::iterator; // define the mathcing table definition @@ -110,21 +230,41 @@ DECLARE_SOA_COLUMN(JetNConstituents, jetNConstituents, int); //! DECLARE_SOA_TABLE(_jet_type_##MOs, "AOD", _description_ "MO", _name_##substructure::_jet_type_##OId, _name_##geomatched::_matched_jet_type_##Ids, _name_##ptmatched::_matched_jet_type_##Ids, _name_##candmatched::_matched_jet_type_##Ids); \ using _jet_type_##MO = _jet_type_##MOs::iterator; -#define JETSUBSTRUCTURE_TABLES_DEF(_jet_type_, _jet_description_, _cand_type_data_, _cand_description_data_, _cand_type_ewsdata_, _cand_description_ewsdata_, _cand_type_mcd_, _cand_description_mcd_, _hfparticle_type_, _hfparticle_description_) \ - JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##Jet, _jet_description_ "JET", _jet_type_##jet, _cand_type_data_, _cand_description_data_) \ - JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##EWSJet, _jet_description_ "EWSJET", _jet_type_##ewsjet, _cand_type_ewsdata_, _cand_description_ewsdata_) \ - JETMATCHING_TABLE_DEF(_jet_type_##Jet, _jet_type_##EWSJet, _jet_description_ "EWSJET", _jet_type_##jet, _jet_description_ "JET") \ - JETMATCHING_TABLE_DEF(_jet_type_##EWSJet, _jet_type_##Jet, _jet_description_ "JET", _jet_type_##ewsjet, _jet_description_ "EWSJET") \ - JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##MCDJet, _jet_description_ "MCDJET", _jet_type_##mcdjet, _cand_type_mcd_, _cand_description_mcd_) \ - JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##MCPJet, _jet_description_ "MCPJET", _jet_type_##mcpjet, _hfparticle_type_, _hfparticle_description_) \ - JETMATCHING_TABLE_DEF(_jet_type_##MCDJet, _jet_type_##MCPJet, _jet_description_ "MCPJET", _jet_type_##mcdjet, _jet_description_ "MCDJET") \ - JETMATCHING_TABLE_DEF(_jet_type_##MCPJet, _jet_type_##MCDJet, _jet_description_ "MCDJET", _jet_type_##mcpjet, _jet_description_ "MCPJET") - -JETSUBSTRUCTURE_TABLES_DEF(C, "C", CJetCOs, "CJETCO", CEWSJetCOs, "CEWSJETCO", CMCDJetCOs, "CMCDJETCO", CMCPJetCOs, "CMCPJETCO"); -JETSUBSTRUCTURE_TABLES_DEF(D0C, "D0C", HfD0Bases, "HFD0BASE", HfD0Bases, "HFD0BASE", HfD0Bases, "HFD0BASE", HfD0PBases, "HFD0PBASE"); -JETSUBSTRUCTURE_TABLES_DEF(LcC, "LCC", HfLcBases, "HFLcBASE", HfLcBases, "HFLcBASE", HfLcBases, "HFLcBASE", HfLcPBases, "HFLcPBASE"); -JETSUBSTRUCTURE_TABLES_DEF(BplusC, "BPC", HfBplusBases, "HFBPBASE", HfBplusBases, "HFBPBASE", HfBplusBases, "HFBPBASE", HfBplusPBases, "HFBPPBASE"); -JETSUBSTRUCTURE_TABLES_DEF(DielectronC, "DIELC", Dielectrons, "RTDIELECTRON", Dielectrons, "RTDIELECTRON", Dielectrons, "RTDIELECTRON", JDielectronMcs, "JDIELMC"); +#define JETSUBSTRUCTURE_TABLES_DEF(_jet_type_, _jet_description_, _jet_type_full_, _jet_full_description_, _track_type_data_, _cand_type_data_, _cand_description_data_, _track_type_ewsdata_, _cand_type_ewsdata_, _cand_description_ewsdata_, _track_type_mcd_, _cand_type_mcd_, _cand_description_mcd_, _particle_type_, _hfparticle_type_, _hfparticle_description_) \ + JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##Jet, _jet_description_ "JET", _jet_type_##jet, _cand_type_data_, _cand_description_data_) \ + JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##EWSJet, _jet_description_ "EWSJET", _jet_type_##ewsjet, _cand_type_ewsdata_, _cand_description_ewsdata_) \ + JETMATCHING_TABLE_DEF(_jet_type_##Jet, _jet_type_##EWSJet, _jet_description_ "EWSJET", _jet_type_##jet, _jet_description_ "JET") \ + JETMATCHING_TABLE_DEF(_jet_type_##EWSJet, _jet_type_##Jet, _jet_description_ "JET", _jet_type_##ewsjet, _jet_description_ "EWSJET") \ + JETSPLITTING_TABLE_DEF(_jet_type_full_, _jet_description_, _jet_full_description_, _track_type_data_, _cand_type_data_) \ + JETSPLITTING_TABLE_DEF(_jet_type_full_##EventWiseSubtracted, _jet_description_ "EWS", _jet_full_description_##eventwisesubtracted, _cand_type_ewsdata_, _cand_type_ewsdata_) \ + JETSPLITTINGMATCHING_TABLE_DEF(_jet_type_full_, _jet_type_full_##EventWiseSubtracted, _jet_description_ "SP2EWS") \ + JETSPLITTINGMATCHING_TABLE_DEF(_jet_type_full_##EventWiseSubtracted, _jet_type_full_, _jet_description_ "EWSSP2") \ + JETPAIR_TABLE_DEF(_jet_type_full_, _jet_description_, _jet_full_description_, _track_type_data_, _cand_type_data_) \ + JETPAIR_TABLE_DEF(_jet_type_full_##EventWiseSubtracted, _jet_description_ "EWS", _jet_full_description_##eventwisesubtracted, _cand_type_ewsdata_, _cand_type_ewsdata_) \ + JETPAIRMATCHING_TABLE_DEF(_jet_type_full_, _jet_type_full_##EventWiseSubtracted, _jet_description_ "SP2EWS") \ + JETPAIRMATCHING_TABLE_DEF(_jet_type_full_##EventWiseSubtracted, _jet_type_full_, _jet_description_ "EWSSP2") \ + JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##MCDJet, _jet_description_ "MCDJET", _jet_type_##mcdjet, _cand_type_mcd_, _cand_description_mcd_) \ + JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##MCPJet, _jet_description_ "MCPJET", _jet_type_##mcpjet, _hfparticle_type_, _hfparticle_description_) \ + MCCOLL_TABLE_DEF(_jet_type_##MCPJet, _jet_description_ "MCPJET", _jet_type_##mcpjet) \ + JETMATCHING_TABLE_DEF(_jet_type_##MCDJet, _jet_type_##MCPJet, _jet_description_ "MCPJET", _jet_type_##mcdjet, _jet_description_ "MCDJET") \ + JETMATCHING_TABLE_DEF(_jet_type_##MCPJet, _jet_type_##MCDJet, _jet_description_ "MCDJET", _jet_type_##mcpjet, _jet_description_ "MCPJET") \ + JETSPLITTING_TABLE_DEF(_jet_type_full_##MCDetectorLevel, _jet_description_ "D", _jet_full_description_##mcdetectorlevel, _track_type_mcd_, _cand_type_mcd_) \ + JETSPLITTING_TABLE_DEF(_jet_type_full_##MCParticleLevel, _jet_description_ "P", _jet_full_description_##mcparticlelevel, _particle_type_, _hfparticle_type_) \ + JETSPLITTINGMATCHING_TABLE_DEF(_jet_type_full_##MCDetectorLevel, _jet_type_full_##MCParticleLevel, _jet_description_ "DSP2P") \ + JETSPLITTINGMATCHING_TABLE_DEF(_jet_type_full_##MCParticleLevel, _jet_type_full_##MCDetectorLevel, _jet_description_ "PSP2D") \ + JETPAIR_TABLE_DEF(_jet_type_full_##MCDetectorLevel, _jet_description_ "D", _jet_full_description_##mcdetectorlevel, _track_type_mcd_, _cand_type_mcd_) \ + JETPAIR_TABLE_DEF(_jet_type_full_##MCParticleLevel, _jet_description_ "P", _jet_full_description_##mcparticlelevel, _particle_type_, _hfparticle_type_) \ + JETPAIRMATCHING_TABLE_DEF(_jet_type_full_##MCDetectorLevel, _jet_type_full_##MCParticleLevel, _jet_description_ "DSP2P") \ + JETPAIRMATCHING_TABLE_DEF(_jet_type_full_##MCParticleLevel, _jet_type_full_##MCDetectorLevel, _jet_description_ "PSP2D") + +JETSUBSTRUCTURE_TABLES_DEF(C, "C", Charged, charged, JTracks, CJetCOs, "CJETCO", JTrackSubs, CEWSJetCOs, "CEWSJETCO", JTracks, CMCDJetCOs, "CMCDJETCO", JMcParticles, CMCPJetCOs, "CMCPJETCO"); +JETSUBSTRUCTURE_TABLES_DEF(D0C, "D0C", D0Charged, d0charged, JTracks, HfD0Bases, "HFD0BASE", JTrackD0Subs, HfD0Bases, "HFD0BASE", JTracks, HfD0Bases, "HFD0BASE", JMcParticles, HfD0PBases, "HFD0PBASE"); +JETSUBSTRUCTURE_TABLES_DEF(DplusC, "DPC", DplusCharged, dpluscharged, JTracks, HfDplusBases, "HFDPBASE", JTrackDplusSubs, HfDplusBases, "HFDPBASE", JTracks, HfDplusBases, "HFDPBASE", JMcParticles, HfDplusPBases, "HFDPPBASE"); +JETSUBSTRUCTURE_TABLES_DEF(DstarC, "DSTC", DstarCharged, dstarcharged, JTracks, HfDstarBases, "HFDSTBASE", JTrackDstarSubs, HfDstarBases, "HFDSTBASE", JTracks, HfDstarBases, "HFDSTBASE", JMcParticles, HfDstarPBases, "HFDSTPBASE"); +JETSUBSTRUCTURE_TABLES_DEF(LcC, "LCC", LcCharged, lccharged, JTracks, HfLcBases, "HFLCBASE", JTrackLcSubs, HfLcBases, "HFLCBASE", JTracks, HfLcBases, "HFLCBASE", JMcParticles, HfLcPBases, "HFLCPBASE"); +JETSUBSTRUCTURE_TABLES_DEF(B0C, "B0C", B0Charged, b0charged, JTracks, HfB0Bases, "HFB0BASE", JTrackB0Subs, HfB0Bases, "HFB0BASE", JTracks, HfB0Bases, "HFB0BASE", JMcParticles, HfB0PBases, "HFB0PBASE"); +JETSUBSTRUCTURE_TABLES_DEF(BplusC, "BPC", BplusCharged, bpluscharged, JTracks, HfBplusBases, "HFBPBASE", JTrackBplusSubs, HfBplusBases, "HFBPBASE", JTracks, HfBplusBases, "HFBPBASE", JMcParticles, HfBplusPBases, "HFBPPBASE"); +JETSUBSTRUCTURE_TABLES_DEF(DielectronC, "DIELC", DielectronCharged, dielectroncharged, JTracks, Dielectrons, "RTDIELECTRON", JTrackDielectronSubs, Dielectrons, "RTDIELECTRON", JTracks, Dielectrons, "RTDIELECTRON", JMcParticles, JDielectronMcs, "JDIELMC"); } // namespace o2::aod diff --git a/PWGJE/DataModel/JetSubtraction.h b/PWGJE/DataModel/JetSubtraction.h index 3f78c05ec58..d22237380c7 100644 --- a/PWGJE/DataModel/JetSubtraction.h +++ b/PWGJE/DataModel/JetSubtraction.h @@ -18,14 +18,14 @@ #ifndef PWGJE_DATAMODEL_JETSUBTRACTION_H_ #define PWGJE_DATAMODEL_JETSUBTRACTION_H_ -#include -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "PWGHF/DataModel/DerivedTables.h" #include "PWGJE/DataModel/JetReducedData.h" #include "PWGJE/DataModel/JetReducedDataDQ.h" -#include "PWGHF/DataModel/DerivedTables.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" + +#include + +#include namespace o2::aod { @@ -52,6 +52,26 @@ namespace bkgd0mc DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfD0PBases, "_0"); } // namespace bkgd0mc +namespace bkgdplus +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfDplusBases, "_0"); +} // namespace bkgdplus + +namespace bkgdplusmc +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfDplusPBases, "_0"); +} // namespace bkgdplusmc + +namespace bkgdstar +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfDstarBases, "_0"); +} // namespace bkgdstar + +namespace bkgdstarmc +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfDstarPBases, "_0"); +} // namespace bkgdstarmc + namespace bkglc { DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfLcBases, "_0"); @@ -62,6 +82,16 @@ namespace bkglcmc DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfLcPBases, "_0"); } // namespace bkglcmc +namespace bkgb0 +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfB0Bases, "_0"); +} // namespace bkgb0 + +namespace bkgb0mc +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfB0PBases, "_0"); +} // namespace bkgb0mc + namespace bkgbplus { DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, HfBplusBases, "_0"); @@ -105,42 +135,78 @@ DECLARE_SOA_TABLE(BkgD0McRhos, "AOD", "BkgD0McRho", bkgrho::RhoM, o2::soa::Marker<3>); -DECLARE_SOA_TABLE(BkgLcRhos, "AOD", "BkgLcRho", +DECLARE_SOA_TABLE(BkgDplusRhos, "AOD", "BkgDPRho", o2::soa::Index<>, bkgrho::Rho, bkgrho::RhoM, o2::soa::Marker<4>); -DECLARE_SOA_TABLE(BkgLcMcRhos, "AOD", "BkgLcMcRho", +DECLARE_SOA_TABLE(BkgDplusMcRhos, "AOD", "BkgDPMcRho", o2::soa::Index<>, bkgrho::Rho, bkgrho::RhoM, o2::soa::Marker<5>); -DECLARE_SOA_TABLE(BkgBplusRhos, "AOD", "BkgRho", +DECLARE_SOA_TABLE(BkgDstarRhos, "AOD", "BkgDSTRho", o2::soa::Index<>, bkgrho::Rho, bkgrho::RhoM, o2::soa::Marker<6>); -DECLARE_SOA_TABLE(BkgBplusMcRhos, "AOD", "BkgBPMcRho", +DECLARE_SOA_TABLE(BkgDstarMcRhos, "AOD", "BkgDSTMcRho", o2::soa::Index<>, bkgrho::Rho, bkgrho::RhoM, o2::soa::Marker<7>); -DECLARE_SOA_TABLE(BkgDielectronRhos, "AOD", "BkgDIELRho", +DECLARE_SOA_TABLE(BkgLcRhos, "AOD", "BkgLCRho", o2::soa::Index<>, bkgrho::Rho, bkgrho::RhoM, o2::soa::Marker<8>); -DECLARE_SOA_TABLE(BkgDielectronMcRhos, "AOD", "BkgDIELMcRho", +DECLARE_SOA_TABLE(BkgLcMcRhos, "AOD", "BkgLCMcRho", o2::soa::Index<>, bkgrho::Rho, bkgrho::RhoM, o2::soa::Marker<9>); +DECLARE_SOA_TABLE(BkgB0Rhos, "AOD", "BkgB0Rho", + o2::soa::Index<>, + bkgrho::Rho, + bkgrho::RhoM, + o2::soa::Marker<10>); + +DECLARE_SOA_TABLE(BkgB0McRhos, "AOD", "BkgB0McRho", + o2::soa::Index<>, + bkgrho::Rho, + bkgrho::RhoM, + o2::soa::Marker<11>); + +DECLARE_SOA_TABLE(BkgBplusRhos, "AOD", "BkgBPRho", + o2::soa::Index<>, + bkgrho::Rho, + bkgrho::RhoM, + o2::soa::Marker<12>); + +DECLARE_SOA_TABLE(BkgBplusMcRhos, "AOD", "BkgBPMcRho", + o2::soa::Index<>, + bkgrho::Rho, + bkgrho::RhoM, + o2::soa::Marker<13>); + +DECLARE_SOA_TABLE(BkgDielectronRhos, "AOD", "BkgDIELRho", + o2::soa::Index<>, + bkgrho::Rho, + bkgrho::RhoM, + o2::soa::Marker<14>); + +DECLARE_SOA_TABLE(BkgDielectronMcRhos, "AOD", "BkgDIELMcRho", + o2::soa::Index<>, + bkgrho::Rho, + bkgrho::RhoM, + o2::soa::Marker<15>); + DECLARE_SOA_TABLE(JTrackSubs, "AOD", "JTrackSubs", o2::soa::Index<>, bkgcharged::JCollisionId, @@ -211,7 +277,77 @@ DECLARE_SOA_TABLE(JMcParticleD0Subs, "AOD", "JMcPartD0Subs", using JMcParticleD0Sub = JMcParticleD0Subs::iterator; -DECLARE_SOA_TABLE(JTrackLcSubs, "AOD", "JTrackLcSubs", +DECLARE_SOA_TABLE(JTrackDplusSubs, "AOD", "JTrackDPSubs", + o2::soa::Index<>, + bkgdplus::CandidateId, + jtrack::Pt, + jtrack::Eta, + jtrack::Phi, + jtrack::TrackSel, + jtrack::Px, + jtrack::Py, + jtrack::Pz, + jtrack::P, + jtrack::Energy); + +using JTrackDplusSub = JTrackDplusSubs::iterator; + +DECLARE_SOA_TABLE(JMcParticleDplusSubs, "AOD", "JMcPartDPSubs", + o2::soa::Index<>, + bkgdplusmc::CandidateId, + jmcparticle::Pt, + jmcparticle::Eta, + jmcparticle::Phi, + jmcparticle::Y, + jmcparticle::E, + jmcparticle::PdgCode, + jmcparticle::GenStatusCode, + jmcparticle::HepMCStatusCode, + jmcparticle::IsPhysicalPrimary, + jmcparticle::Px, + jmcparticle::Py, + jmcparticle::Pz, + jmcparticle::P, + jmcparticle::Energy); + +using JMcParticleDplusSub = JMcParticleDplusSubs::iterator; + +DECLARE_SOA_TABLE(JTrackDstarSubs, "AOD", "JTrackDSTSubs", + o2::soa::Index<>, + bkgdstar::CandidateId, + jtrack::Pt, + jtrack::Eta, + jtrack::Phi, + jtrack::TrackSel, + jtrack::Px, + jtrack::Py, + jtrack::Pz, + jtrack::P, + jtrack::Energy); + +using JTrackDstarSub = JTrackDstarSubs::iterator; + +DECLARE_SOA_TABLE(JMcParticleDstarSubs, "AOD", "JMcPartDSTSubs", + o2::soa::Index<>, + bkgdstarmc::CandidateId, + jmcparticle::Pt, + jmcparticle::Eta, + jmcparticle::Phi, + jmcparticle::Y, + jmcparticle::E, + jmcparticle::PdgCode, + jmcparticle::GenStatusCode, + jmcparticle::HepMCStatusCode, + jmcparticle::IsPhysicalPrimary, + jmcparticle::Px, + jmcparticle::Py, + jmcparticle::Pz, + jmcparticle::P, + jmcparticle::Energy); + +using JMcParticleDstarSub = JMcParticleDstarSubs::iterator; + +DECLARE_SOA_TABLE(JTrackLcSubs, "AOD", "JTrackLCSubs", o2::soa::Index<>, bkglc::CandidateId, jtrack::Pt, @@ -226,7 +362,7 @@ DECLARE_SOA_TABLE(JTrackLcSubs, "AOD", "JTrackLcSubs", using JTrackLcSub = JTrackLcSubs::iterator; -DECLARE_SOA_TABLE(JMcParticleLcSubs, "AOD", "JMcPartLcSubs", +DECLARE_SOA_TABLE(JMcParticleLcSubs, "AOD", "JMcPartLCSubs", o2::soa::Index<>, bkglcmc::CandidateId, jmcparticle::Pt, @@ -246,6 +382,41 @@ DECLARE_SOA_TABLE(JMcParticleLcSubs, "AOD", "JMcPartLcSubs", using JMcParticleLcSub = JMcParticleLcSubs::iterator; +DECLARE_SOA_TABLE(JTrackB0Subs, "AOD", "JTrackB0Subs", + o2::soa::Index<>, + bkgb0::CandidateId, + jtrack::Pt, + jtrack::Eta, + jtrack::Phi, + jtrack::TrackSel, + jtrack::Px, + jtrack::Py, + jtrack::Pz, + jtrack::P, + jtrack::Energy); + +using JTrackB0Sub = JTrackB0Subs::iterator; + +DECLARE_SOA_TABLE(JMcParticleB0Subs, "AOD", "JMcPartB0Subs", + o2::soa::Index<>, + bkgb0mc::CandidateId, + jmcparticle::Pt, + jmcparticle::Eta, + jmcparticle::Phi, + jmcparticle::Y, + jmcparticle::E, + jmcparticle::PdgCode, + jmcparticle::GenStatusCode, + jmcparticle::HepMCStatusCode, + jmcparticle::IsPhysicalPrimary, + jmcparticle::Px, + jmcparticle::Py, + jmcparticle::Pz, + jmcparticle::P, + jmcparticle::Energy); + +using JMcParticleB0Sub = JMcParticleB0Subs::iterator; + DECLARE_SOA_TABLE(JTrackBplusSubs, "AOD", "JTrackBPSubs", o2::soa::Index<>, bkgbplus::CandidateId, diff --git a/PWGJE/DataModel/JetTagging.h b/PWGJE/DataModel/JetTagging.h index cae674fd66f..9d8f5eceb80 100644 --- a/PWGJE/DataModel/JetTagging.h +++ b/PWGJE/DataModel/JetTagging.h @@ -9,18 +9,27 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// +/// \file JetTagging.h /// \brief Table definitions for hf jet tagging /// /// \author Nima Zardoshti +/// \author Hanseo Park #ifndef PWGJE_DATAMODEL_JETTAGGING_H_ #define PWGJE_DATAMODEL_JETTAGGING_H_ +#include "RecoDecay.h" + +#include "PWGJE/Core/JetTaggingUtilities.h" +#include "PWGJE/DataModel/Jet.h" // IWYU pragma: keep + +#include + +#include + +#include #include -#include -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/Jet.h" +#include namespace o2::aod { @@ -38,11 +47,11 @@ DECLARE_SOA_TABLE(JTracksTag, "AOD", "JTracksTag", using JTrackTag = JTracksTag::iterator; -namespace SecondaryVertexParams +namespace secondary_vertex_params { -DECLARE_SOA_COLUMN(XPrimaryVertex, xPVertex, float); -DECLARE_SOA_COLUMN(YPrimaryVertex, yPVertex, float); -DECLARE_SOA_COLUMN(ZPrimaryVertex, zPVertex, float); +DECLARE_SOA_COLUMN(XPrimaryVertex, xPVertex, float); // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(YPrimaryVertex, yPVertex, float); // o2-linter: disable=name/o2-column +DECLARE_SOA_COLUMN(ZPrimaryVertex, zPVertex, float); // o2-linter: disable=name/o2-column DECLARE_SOA_COLUMN(XSecondaryVertex, xSecondaryVertex, float); DECLARE_SOA_COLUMN(YSecondaryVertex, ySecondaryVertex, float); DECLARE_SOA_COLUMN(ZSecondaryVertex, zSecondaryVertex, float); @@ -66,51 +75,51 @@ DECLARE_SOA_DYNAMIC_COLUMN(DecayLength, decayLength, [](float xVtxP, float yVtxP DECLARE_SOA_DYNAMIC_COLUMN(DecayLengthXY, decayLengthXY, [](float xVtxP, float yVtxP, float xVtxS, float yVtxS) -> float { return RecoDecay::distanceXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}); }); DECLARE_SOA_DYNAMIC_COLUMN(DecayLengthNormalised, decayLengthNormalised, [](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float err) -> float { return RecoDecay::distance(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}) / err; }); DECLARE_SOA_DYNAMIC_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, [](float xVtxP, float yVtxP, float xVtxS, float yVtxS, float err) -> float { return RecoDecay::distanceXY(std::array{xVtxP, yVtxP}, std::array{xVtxS, yVtxS}) / err; }); -DECLARE_SOA_DYNAMIC_COLUMN(CPA, cpa, [](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz) -> float { return RecoDecay::cpa(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); }); +DECLARE_SOA_DYNAMIC_COLUMN(CPA, cpa, [](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz) -> float { return RecoDecay::cpa(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); }); // o2-linter: disable=name/o2-column DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterXY, impactParameterXY, [](float xVtxP, float yVtxP, float zVtxP, float xVtxS, float yVtxS, float zVtxS, float px, float py, float pz) -> float { return RecoDecay::impParXY(std::array{xVtxP, yVtxP, zVtxP}, std::array{xVtxS, yVtxS, zVtxS}, std::array{px, py, pz}); }); -} // namespace SecondaryVertexParams - -#define DECLARE_SV_TABLE(_jet_type_, _name_, _description_, _datatype_) \ - namespace _datatype_##_name_##Parameters \ - { \ - DECLARE_SOA_INDEX_COLUMN(_jet_type_, jetIndex); \ - } \ - DECLARE_SOA_TABLE(_datatype_##_name_##s, "AOD", _description_, \ - o2::soa::Index<>, \ - _datatype_##_name_##Parameters::_jet_type_##Id, \ - SecondaryVertexParams::XPrimaryVertex, \ - SecondaryVertexParams::YPrimaryVertex, \ - SecondaryVertexParams::ZPrimaryVertex, \ - SecondaryVertexParams::XSecondaryVertex, \ - SecondaryVertexParams::YSecondaryVertex, \ - SecondaryVertexParams::ZSecondaryVertex, \ - SecondaryVertexParams::Px, \ - SecondaryVertexParams::Py, \ - SecondaryVertexParams::Pz, \ - SecondaryVertexParams::E, \ - SecondaryVertexParams::M, \ - SecondaryVertexParams::Chi2PCA, \ - SecondaryVertexParams::Dispersion, \ - SecondaryVertexParams::ErrorDecayLength, \ - SecondaryVertexParams::ErrorDecayLengthXY, \ - SecondaryVertexParams::RSecondaryVertex, \ - SecondaryVertexParams::Pt, \ - SecondaryVertexParams::P, \ - SecondaryVertexParams::PVector, \ - SecondaryVertexParams::Eta, \ - SecondaryVertexParams::Phi, \ - SecondaryVertexParams::Y, \ - SecondaryVertexParams::DecayLength, \ - SecondaryVertexParams::DecayLengthXY, \ - SecondaryVertexParams::DecayLengthNormalised, \ - SecondaryVertexParams::DecayLengthXYNormalised, \ - SecondaryVertexParams::CPA, \ - SecondaryVertexParams::ImpactParameterXY); \ - namespace _name_##Indices \ - { \ - DECLARE_SOA_ARRAY_INDEX_COLUMN(_datatype_##_name_, secondaryVertices); \ - } \ - DECLARE_SOA_TABLE(_datatype_##_name_##Indices, "AOD", _description_ "SVs", _name_##Indices::_datatype_##_name_##Ids); +} // namespace secondary_vertex_params + +#define DECLARE_SV_TABLE(_jet_type_, _name_, _description_, _datatype_) \ + namespace _datatype_##_name_##parameters \ + { \ + DECLARE_SOA_INDEX_COLUMN(_jet_type_, jetIndex); \ + } \ + DECLARE_SOA_TABLE(_datatype_##_name_##s, "AOD", _description_, \ + o2::soa::Index<>, \ + _datatype_##_name_##parameters::_jet_type_##Id, \ + secondary_vertex_params::XPrimaryVertex, \ + secondary_vertex_params::YPrimaryVertex, \ + secondary_vertex_params::ZPrimaryVertex, \ + secondary_vertex_params::XSecondaryVertex, \ + secondary_vertex_params::YSecondaryVertex, \ + secondary_vertex_params::ZSecondaryVertex, \ + secondary_vertex_params::Px, \ + secondary_vertex_params::Py, \ + secondary_vertex_params::Pz, \ + secondary_vertex_params::E, \ + secondary_vertex_params::M, \ + secondary_vertex_params::Chi2PCA, \ + secondary_vertex_params::Dispersion, \ + secondary_vertex_params::ErrorDecayLength, \ + secondary_vertex_params::ErrorDecayLengthXY, \ + secondary_vertex_params::RSecondaryVertex, \ + secondary_vertex_params::Pt, \ + secondary_vertex_params::P, \ + secondary_vertex_params::PVector, \ + secondary_vertex_params::Eta, \ + secondary_vertex_params::Phi, \ + secondary_vertex_params::Y, \ + secondary_vertex_params::DecayLength, \ + secondary_vertex_params::DecayLengthXY, \ + secondary_vertex_params::DecayLengthNormalised, \ + secondary_vertex_params::DecayLengthXYNormalised, \ + secondary_vertex_params::CPA, \ + secondary_vertex_params::ImpactParameterXY); \ + namespace _name_##indices \ + { \ + DECLARE_SOA_ARRAY_INDEX_COLUMN(_datatype_##_name_, secondaryVertices); \ + } \ + DECLARE_SOA_TABLE(_datatype_##_name_##Indices, "AOD", _description_ "SVs", _name_##indices::_datatype_##_name_##Ids); #define JETSV_TABLES_DEF(_jet_type_, _name_, _description_) \ DECLARE_SV_TABLE(_jet_type_##Jet, _name_, _description_, Data) \ @@ -119,22 +128,37 @@ DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterXY, impactParameterXY, [](float xVtxP, JETSV_TABLES_DEF(Charged, SecondaryVertex3Prong, "3PRONG"); JETSV_TABLES_DEF(Charged, SecondaryVertex2Prong, "2PRONG"); -// Defines the jet substrcuture table definition -#define JETTAGGING_TABLE_DEF(_jet_type_, _name_, _description_) \ - namespace _name_##tagging \ - { \ - DECLARE_SOA_COLUMN(Origin, origin, int); \ - DECLARE_SOA_COLUMN(JetProb, jetProb, std::vector); \ - DECLARE_SOA_COLUMN(FlagtaggedjetIP, flagtaggedjetIP, bool); \ - DECLARE_SOA_COLUMN(FlagtaggedjetIPxyz, flagtaggedjetIPxyz, bool); \ - DECLARE_SOA_COLUMN(FlagtaggedjetSV, flagtaggedjetSV, bool); \ - DECLARE_SOA_COLUMN(FlagtaggedjetSVxyz, flagtaggedjetSVxyz, bool); \ - } \ - DECLARE_SOA_TABLE(_jet_type_##Tags, "AOD", _description_ "Tags", _name_##tagging::Origin, _name_##tagging::JetProb, _name_##tagging::FlagtaggedjetIP, _name_##tagging::FlagtaggedjetIPxyz, _name_##tagging::FlagtaggedjetSV, _name_##tagging::FlagtaggedjetSVxyz); - -#define JETTAGGING_TABLES_DEF(_jet_type_, _description_) \ - JETTAGGING_TABLE_DEF(_jet_type_##Jet, _jet_type_##jet, _description_) \ - JETTAGGING_TABLE_DEF(_jet_type_##MCDetectorLevelJet, _jet_type_##mcdetectorleveljet, _description_ "MCD") \ +// Defines the jet tagging table definition +namespace jettagging +{ +namespace flavourdef +{ +DECLARE_SOA_COLUMN(Origin, origin, int8_t); +} // namespace flavourdef +DECLARE_SOA_COLUMN(BitTaggedjet, bitTaggedjet, uint16_t); +DECLARE_SOA_COLUMN(JetProb, jetProb, float); +DECLARE_SOA_COLUMN(ScoreML, scoreML, float); +DECLARE_SOA_DYNAMIC_COLUMN(IsTagged, isTagged, [](uint16_t bit, BJetTaggingMethod method) -> bool { return TESTBIT(bit, method); }); +} // namespace jettagging + +#define JETFLAVOURDEF_TABLE_DEF(_jet_type_, _name_, _description_) \ + DECLARE_SOA_TABLE(_jet_type_##FlavourDef, "AOD", _description_ "FlavourDef", jettagging::flavourdef::Origin); + +#define JETTAGGING_TABLE_DEF(_jet_type_, _name_, _description_) \ + namespace _name_##util \ + { \ + DECLARE_SOA_DYNAMIC_COLUMN(Dummy##_jet_type_##tagging, dummy##_jet_type##tagging, \ + []() -> int { return 0; }); \ + } \ + DECLARE_SOA_TABLE(_jet_type_##Tags, "AOD", _description_ "Tags", \ + jettagging::BitTaggedjet, jettagging::JetProb, \ + jettagging::ScoreML, jettagging::IsTagged, _name_##util::Dummy##_jet_type_##tagging<>); + +#define JETTAGGING_TABLES_DEF(_jet_type_, _description_) \ + JETTAGGING_TABLE_DEF(_jet_type_##Jet, _jet_type_##jet, _description_) \ + JETFLAVOURDEF_TABLE_DEF(_jet_type_##MCDetectorLevelJet, _jet_type_##mcdetectorleveljet, _description_ "MCD") \ + JETTAGGING_TABLE_DEF(_jet_type_##MCDetectorLevelJet, _jet_type_##mcdetectorleveljet, _description_ "MCD") \ + JETFLAVOURDEF_TABLE_DEF(_jet_type_##MCParticleLevelJet, _jet_type_##mcparticleleveljet, _description_ "MCP") \ JETTAGGING_TABLE_DEF(_jet_type_##MCParticleLevelJet, _jet_type_##mcparticleleveljet, _description_ "MCP") JETTAGGING_TABLES_DEF(Charged, "C"); diff --git a/PWGJE/DataModel/PhotonChargedTriggerCorrelation.h b/PWGJE/DataModel/PhotonChargedTriggerCorrelation.h new file mode 100644 index 00000000000..53f5e581d82 --- /dev/null +++ b/PWGJE/DataModel/PhotonChargedTriggerCorrelation.h @@ -0,0 +1,132 @@ +// 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. + +/// +/// \brief table definitions for photon-hadron correlation analyses +/// +/// \author Julius Kinner +/// \file PhotonChargedTriggerCorrelation.h + +#ifndef PWGJE_DATAMODEL_PHOTONCHARGEDTRIGGERCORRELATION_H_ +#define PWGJE_DATAMODEL_PHOTONCHARGEDTRIGGERCORRELATION_H_ + +#include "Framework/AnalysisDataModel.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" + +namespace o2::aod +{ + +// basic correlation particle columns +namespace corr_particle +{ +DECLARE_SOA_INDEX_COLUMN_FULL(JetCollision, jetCollision, int, JCollisions, ""); +DECLARE_SOA_INDEX_COLUMN_FULL(JetMcCollision, jetMcCollision, int, JMcCollisions, ""); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +} // namespace corr_particle + +// reco + +// collision extension +namespace collision_extra_corr +{ +DECLARE_SOA_COLUMN(SelEv, selEv, bool); +DECLARE_SOA_COLUMN(TrigEv, trigEv, bool); +} // namespace collision_extra_corr +DECLARE_SOA_TABLE(CollisionsExtraCorr, "AOD", "COLLISIONSEXTRACORR", + collision_extra_corr::SelEv, collision_extra_corr::TrigEv); + +// trigger +namespace trigger +{ +DECLARE_SOA_INDEX_COLUMN_FULL(JetTrack, jetTrack, int, JetTracks, ""); +} // namespace trigger +DECLARE_SOA_TABLE(Triggers, "AOD", "TRIGGERS", + o2::soa::Index<>, corr_particle::JetCollisionId, trigger::JetTrackId, + corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); +using Trigger = Triggers::iterator; + +// hadrons (global tracks) +namespace hadron +{ +DECLARE_SOA_INDEX_COLUMN_FULL(JetTrack, jetTrack, int, JetTracks, ""); +} // namespace hadron +DECLARE_SOA_TABLE(Hadrons, "AOD", "HADRONS", + o2::soa::Index<>, corr_particle::JetCollisionId, hadron::JetTrackId, + corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); +using Hadron = Hadrons::iterator; + +// pipm +namespace pipm +{ +DECLARE_SOA_INDEX_COLUMN_FULL(JetTrack, jetTrack, int, JetTracks, ""); +} // namespace pipm +DECLARE_SOA_TABLE(Pipms, "AOD", "PIPMS", + o2::soa::Index<>, corr_particle::JetCollisionId, pipm::JetTrackId, + corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); +using Pipm = Pipms::iterator; + +// photonPCM +namespace photon_pcm +{ +DECLARE_SOA_INDEX_COLUMN_FULL(V0PhotonKF, v0PhotonKF, int, V0PhotonsKF, ""); +DECLARE_SOA_COLUMN(PosTrackId, posTrackId, int); +DECLARE_SOA_COLUMN(NegTrackId, negTrackId, int); +} // namespace photon_pcm +DECLARE_SOA_TABLE(PhotonPCMs, "AOD", "PHOTONPCMS", + o2::soa::Index<>, corr_particle::JetCollisionId, photon_pcm::V0PhotonKFId, + photon_pcm::PosTrackId, photon_pcm::NegTrackId, + corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); +using PhotonPCM = PhotonPCMs::iterator; + +// photonPCM pairs (pi0) +namespace photon_pcm_pair +{ +DECLARE_SOA_INDEX_COLUMN_FULL(V0PhotonKF1, v0PhotonKF1, int, V0PhotonsKF, "_1"); +DECLARE_SOA_INDEX_COLUMN_FULL(V0PhotonKF2, v0PhotonKF2, int, V0PhotonsKF, "_2"); +DECLARE_SOA_COLUMN(PosTrack1Id, posTrack1Id, int); +DECLARE_SOA_COLUMN(NegTrack1Id, negTrack1Id, int); +DECLARE_SOA_COLUMN(PosTrack2Id, posTrack2Id, int); +DECLARE_SOA_COLUMN(NegTrack2Id, negTrack2Id, int); +DECLARE_SOA_COLUMN(Mgg, mgg, float); +} // namespace photon_pcm_pair +DECLARE_SOA_TABLE(PhotonPCMPairs, "AOD", "PHOTONPCMPAIRS", + o2::soa::Index<>, corr_particle::JetCollisionId, photon_pcm_pair::V0PhotonKF1Id, photon_pcm_pair::V0PhotonKF2Id, + photon_pcm_pair::PosTrack1Id, photon_pcm_pair::NegTrack1Id, photon_pcm_pair::PosTrack2Id, photon_pcm_pair::NegTrack2Id, + corr_particle::Pt, corr_particle::Phi, corr_particle::Eta, photon_pcm_pair::Mgg); +using PhotonPCMPair = PhotonPCMPairs::iterator; + +// mc + +// mcCollision extension +namespace mc_collision_extra_corr +{ +DECLARE_SOA_COLUMN(TrigEv, trigEv, bool); +} // namespace mc_collision_extra_corr +DECLARE_SOA_TABLE(McCollisionsExtraCorr, "AOD", "MCCOLLISIONSEXTRACORR", + mc_collision_extra_corr::TrigEv); + +// trigger +namespace trigger_particle +{ +DECLARE_SOA_INDEX_COLUMN_FULL(JetMcParticle, jetMcParticle, int, JetParticles, ""); +} // namespace trigger_particle +DECLARE_SOA_TABLE(TriggerParticles, "AOD", "TRIGGERPARTICLES", + o2::soa::Index<>, corr_particle::JetMcCollisionId, trigger_particle::JetMcParticleId, + corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); +using TriggerParticle = TriggerParticles::iterator; +} // namespace o2::aod + +#endif // PWGJE_DATAMODEL_PHOTONCHARGEDTRIGGERCORRELATION_H_ diff --git a/PWGJE/DataModel/TrackJetQa.h b/PWGJE/DataModel/TrackJetQa.h index 913f43c29b0..2ad30d88a51 100644 --- a/PWGJE/DataModel/TrackJetQa.h +++ b/PWGJE/DataModel/TrackJetQa.h @@ -19,18 +19,12 @@ #ifndef PWGJE_DATAMODEL_TRACKJETQA_H_ #define PWGJE_DATAMODEL_TRACKJETQA_H_ -// O2 includes -#include "ReconstructionDataFormats/Track.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/Jet.h" -#include "Framework/StaticFor.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" + +#include +#include + +#include // Derived data model for track optimization (and cut variation) namespace o2::aod diff --git a/PWGJE/JetFinders/CMakeLists.txt b/PWGJE/JetFinders/CMakeLists.txt index ba4dbb132fc..86052ffbe88 100644 --- a/PWGJE/JetFinders/CMakeLists.txt +++ b/PWGJE/JetFinders/CMakeLists.txt @@ -74,6 +74,36 @@ o2physics_add_dpl_workflow(jet-finder-d0-mcp-charged PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-finder-dplus-data-charged + SOURCES jetFinderDplusDataCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-finder-dplus-mcd-charged + SOURCES jetFinderDplusMCDCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-finder-dplus-mcp-charged + SOURCES jetFinderDplusMCPCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-finder-dstar-data-charged + SOURCES jetFinderDstarDataCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-finder-dstar-mcd-charged + SOURCES jetFinderDstarMCDCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-finder-dstar-mcp-charged + SOURCES jetFinderDstarMCPCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-finder-lc-data-charged SOURCES jetFinderLcDataCharged.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport @@ -89,6 +119,21 @@ o2physics_add_dpl_workflow(jet-finder-lc-mcp-charged PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-finder-b0-data-charged + SOURCES jetFinderB0DataCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-finder-b0-mcd-charged + SOURCES jetFinderB0MCDCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-finder-b0-mcp-charged + SOURCES jetFinderB0MCPCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-finder-bplus-data-charged SOURCES jetFinderBplusDataCharged.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport diff --git a/PWGJE/JetFinders/Duplicates/jetFinderDataCharged1.cxx b/PWGJE/JetFinders/Duplicates/jetFinderDataCharged1.cxx index 46f2dd88df8..ac0363bf901 100644 --- a/PWGJE/JetFinders/Duplicates/jetFinderDataCharged1.cxx +++ b/PWGJE/JetFinders/Duplicates/jetFinderDataCharged1.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderDataCharged1 = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/Duplicates/jetFinderMCDCharged1.cxx b/PWGJE/JetFinders/Duplicates/jetFinderMCDCharged1.cxx index 4a13537a48b..49f2ce1d957 100644 --- a/PWGJE/JetFinders/Duplicates/jetFinderMCDCharged1.cxx +++ b/PWGJE/JetFinders/Duplicates/jetFinderMCDCharged1.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderMCDetectorLevelCharged1 = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/Duplicates/jetFinderMCPCharged1.cxx b/PWGJE/JetFinders/Duplicates/jetFinderMCPCharged1.cxx index 68e3f861ae6..1ae7eed6100 100644 --- a/PWGJE/JetFinders/Duplicates/jetFinderMCPCharged1.cxx +++ b/PWGJE/JetFinders/Duplicates/jetFinderMCPCharged1.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderMCParticleLevelCharged1 = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinder.cxx b/PWGJE/JetFinders/jetFinder.cxx index bbbdcb4b92c..990286c61eb 100644 --- a/PWGJE/JetFinders/jetFinder.cxx +++ b/PWGJE/JetFinders/jetFinder.cxx @@ -15,13 +15,35 @@ /// \author Jochen Klein /// \author Raymond Ehlers , ORNL -#include +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" #include "PWGJE/Core/JetFindingUtilities.h" -#include "Framework/runDataProcessing.h" +#include "PWGJE/DataModel/EMCALClusterDefinition.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export + +#include +#include + +#include +#include + +#include +#include +#include using namespace o2; -using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; @@ -41,6 +63,7 @@ struct JetFinderTask { Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; + Configurable skipMBGapEvents{"skipMBGapEvents", true, "decide to run over MB gap events or not"}; // track level configurables Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; @@ -63,7 +86,9 @@ struct JetFinderTask { Configurable clusterTimeMin{"clusterTimeMin", -25., "minimum Cluster time (ns)"}; Configurable clusterTimeMax{"clusterTimeMax", 25., "maximum Cluster time (ns)"}; Configurable clusterRejectExotics{"clusterRejectExotics", true, "Reject exotic clusters"}; - Configurable doEMCALEventSelection{"doEMCALEventSelection", true, "apply the selection to the event alias_bit"}; + Configurable hadronicCorrectionType{"hadronicCorrectionType", 0, "0 = no correction, 1 = CorrectedOneTrack1, 2 = CorrectedOneTrack2, 3 = CorrectedAllTracks1, 4 = CorrectedAllTracks2"}; + Configurable doEMCALEventSelection{"doEMCALEventSelection", true, "apply the selection to the event alias_bit for full and neutral jets"}; + Configurable doEMCALEventSelectionChargedJets{"doEMCALEventSelectionChargedJets", false, "apply the selection to the event alias_bit for charged jets"}; // jet level configurables Configurable> jetRadius{"jetRadius", {0.4}, "jet resolution parameters"}; @@ -85,7 +110,7 @@ struct JetFinderTask { Service pdgDatabase; int trackSelection = -1; - int eventSelection = -1; + std::vector eventSelectionBits; std::string particleSelection; JetFinder jetFinder; @@ -95,7 +120,7 @@ struct JetFinderTask { void init(InitContext const&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); particleSelection = static_cast(particleSelections); @@ -139,16 +164,16 @@ struct JetFinderTask { } aod::EMCALClusterDefinition clusterDefinition = aod::emcalcluster::getClusterDefinitionFromString(clusterDefinitionS.value); - Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax && aod::jcollision::trackOccupancyInTimeRange <= trackOccupancyInTimeRangeMax); + Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax && aod::jcollision::trackOccupancyInTimeRange <= trackOccupancyInTimeRangeMax && ((skipMBGapEvents.node() == false) || (aod::jcollision::subGeneratorId != static_cast(jetderiveddatautilities::JCollisionSubGeneratorId::mbGap)))); + Filter mcCollisionFilter = ((skipMBGapEvents.node() == false) || (aod::jmccollision::subGeneratorId != static_cast(jetderiveddatautilities::JCollisionSubGeneratorId::mbGap))); // should we add a posZ vtx cut here or leave it to analysers? Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta >= trackEtaMin && aod::jtrack::eta <= trackEtaMax && aod::jtrack::phi >= trackPhiMin && aod::jtrack::phi <= trackPhiMax); // do we need eta cut both here and in globalselection? - Filter partCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax && aod::jmcparticle::eta >= trackEtaMin && aod::jmcparticle::eta <= trackEtaMax && aod::jmcparticle::phi >= trackPhiMin && aod::jmcparticle::phi <= trackPhiMax); Filter clusterFilter = (aod::jcluster::definition == static_cast(clusterDefinition) && aod::jcluster::eta >= clusterEtaMin && aod::jcluster::eta <= clusterEtaMax && aod::jcluster::phi >= clusterPhiMin && aod::jcluster::phi <= clusterPhiMax && aod::jcluster::energy >= clusterEnergyMin && aod::jcluster::time > clusterTimeMin && aod::jcluster::time < clusterTimeMax && (clusterRejectExotics && aod::jcluster::isExotic != true)); void processChargedJets(soa::Filtered::iterator const& collision, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits) || (doEMCALEventSelectionChargedJets && !jetderiveddatautilities::eventEMCAL(collision))) { return; } inputParticles.clear(); @@ -161,7 +186,7 @@ struct JetFinderTask { void processChargedEvtWiseSubJets(soa::Filtered::iterator const& collision, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits) || (doEMCALEventSelectionChargedJets && !jetderiveddatautilities::eventEMCAL(collision))) { return; } inputParticles.clear(); @@ -192,12 +217,12 @@ struct JetFinderTask { } inputParticles.clear(); jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); - jetfindingutilities::analyseClusters(inputParticles, &clusters); + jetfindingutilities::analyseClusters(inputParticles, &clusters, hadronicCorrectionType); jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, fillTHnSparse ? registry.get(HIST("hJet")) : std::shared_ptr(nullptr), fillTHnSparse); } PROCESS_SWITCH(JetFinderTask, processFullJets, "Data and reco level jet finding for full and neutral jets", false); - void processParticleLevelChargedJets(aod::JetMcCollision const& collision, soa::Filtered const& particles) + void processParticleLevelChargedJets(soa::Filtered::iterator const& collision, soa::Filtered const& particles) { // TODO: MC event selection? inputParticles.clear(); @@ -206,7 +231,7 @@ struct JetFinderTask { } PROCESS_SWITCH(JetFinderTask, processParticleLevelChargedJets, "Particle level charged jet finding", false); - void processParticleLevelChargedEvtWiseSubJets(aod::JetMcCollision const& collision, soa::Filtered const& particles) + void processParticleLevelChargedEvtWiseSubJets(soa::Filtered::iterator const& collision, soa::Filtered const& particles) { // TODO: MC event selection? inputParticles.clear(); @@ -215,7 +240,7 @@ struct JetFinderTask { } PROCESS_SWITCH(JetFinderTask, processParticleLevelChargedEvtWiseSubJets, "Particle level charged with event-wise constituent subtraction jet finding", false); - void processParticleLevelNeutralJets(aod::JetMcCollision const& collision, soa::Filtered const& particles) + void processParticleLevelNeutralJets(soa::Filtered::iterator const& collision, soa::Filtered const& particles) { // TODO: MC event selection? inputParticles.clear(); @@ -224,7 +249,7 @@ struct JetFinderTask { } PROCESS_SWITCH(JetFinderTask, processParticleLevelNeutralJets, "Particle level neutral jet finding", false); - void processParticleLevelFullJets(aod::JetMcCollision const& collision, soa::Filtered const& particles) + void processParticleLevelFullJets(soa::Filtered::iterator const& collision, soa::Filtered const& particles) { // TODO: MC event selection? inputParticles.clear(); diff --git a/PWGJE/JetFinders/jetFinderB0DataCharged.cxx b/PWGJE/JetFinders/jetFinderB0DataCharged.cxx new file mode 100644 index 00000000000..9288465c677 --- /dev/null +++ b/PWGJE/JetFinders/jetFinderB0DataCharged.cxx @@ -0,0 +1,38 @@ +// 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. + +// jet finder B0 data charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetFinderHF.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + +using JetFinderB0DataCharged = JetFinderHFTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJetsData", true}}}, + TaskName{"jet-finder-b0-data-charged"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/jetFinderB0MCDCharged.cxx b/PWGJE/JetFinders/jetFinderB0MCDCharged.cxx new file mode 100644 index 00000000000..46de301e549 --- /dev/null +++ b/PWGJE/JetFinders/jetFinderB0MCDCharged.cxx @@ -0,0 +1,38 @@ +// 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. + +// jet finder B0 mcd charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetFinderHF.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + +using JetFinderB0MCDetectorLevelCharged = JetFinderHFTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJetsMCD", true}}}, + TaskName{"jet-finder-b0-mcd-charged"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/jetFinderB0MCPCharged.cxx b/PWGJE/JetFinders/jetFinderB0MCPCharged.cxx new file mode 100644 index 00000000000..2966c817cef --- /dev/null +++ b/PWGJE/JetFinders/jetFinderB0MCPCharged.cxx @@ -0,0 +1,38 @@ +// 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. + +// jet finder B0 mcp charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetFinderHF.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + +using JetFinderB0MCParticleLevelCharged = JetFinderHFTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJetsMCP", true}}}, + TaskName{"jet-finder-b0-mcp-charged"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/jetFinderBplusDataCharged.cxx b/PWGJE/JetFinders/jetFinderBplusDataCharged.cxx index 402527211fb..087fbc6b37e 100644 --- a/PWGJE/JetFinders/jetFinderBplusDataCharged.cxx +++ b/PWGJE/JetFinders/jetFinderBplusDataCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderBplusDataCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderBplusMCDCharged.cxx b/PWGJE/JetFinders/jetFinderBplusMCDCharged.cxx index 4eed52e30b3..9dba69eba51 100644 --- a/PWGJE/JetFinders/jetFinderBplusMCDCharged.cxx +++ b/PWGJE/JetFinders/jetFinderBplusMCDCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderBplusMCDetectorLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderBplusMCPCharged.cxx b/PWGJE/JetFinders/jetFinderBplusMCPCharged.cxx index 83a1e7c9d60..639b02bfe2e 100644 --- a/PWGJE/JetFinders/jetFinderBplusMCPCharged.cxx +++ b/PWGJE/JetFinders/jetFinderBplusMCPCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderBplusMCParticleLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderD0DataCharged.cxx b/PWGJE/JetFinders/jetFinderD0DataCharged.cxx index 29ab757dbce..70e00c246d4 100644 --- a/PWGJE/JetFinders/jetFinderD0DataCharged.cxx +++ b/PWGJE/JetFinders/jetFinderD0DataCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderD0DataCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderD0MCDCharged.cxx b/PWGJE/JetFinders/jetFinderD0MCDCharged.cxx index 46847bf8651..62c740a7152 100644 --- a/PWGJE/JetFinders/jetFinderD0MCDCharged.cxx +++ b/PWGJE/JetFinders/jetFinderD0MCDCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderD0MCDetectorLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderD0MCPCharged.cxx b/PWGJE/JetFinders/jetFinderD0MCPCharged.cxx index a21aceff347..34bee4644ce 100644 --- a/PWGJE/JetFinders/jetFinderD0MCPCharged.cxx +++ b/PWGJE/JetFinders/jetFinderD0MCPCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderD0MCParticleLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderDataCharged.cxx b/PWGJE/JetFinders/jetFinderDataCharged.cxx index e713eb4fa7c..016d83611bb 100644 --- a/PWGJE/JetFinders/jetFinderDataCharged.cxx +++ b/PWGJE/JetFinders/jetFinderDataCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderDataCharged = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderDataFull.cxx b/PWGJE/JetFinders/jetFinderDataFull.cxx index 07d103d93b2..acf33725099 100644 --- a/PWGJE/JetFinders/jetFinderDataFull.cxx +++ b/PWGJE/JetFinders/jetFinderDataFull.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderDataFull = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderDataNeutral.cxx b/PWGJE/JetFinders/jetFinderDataNeutral.cxx index 28a1b898a15..afb223deb74 100644 --- a/PWGJE/JetFinders/jetFinderDataNeutral.cxx +++ b/PWGJE/JetFinders/jetFinderDataNeutral.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderDataNeutral = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderDielectronDataCharged.cxx b/PWGJE/JetFinders/jetFinderDielectronDataCharged.cxx index 2b040080579..7f4657d1127 100644 --- a/PWGJE/JetFinders/jetFinderDielectronDataCharged.cxx +++ b/PWGJE/JetFinders/jetFinderDielectronDataCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderDielectronDataCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderDielectronMCDCharged.cxx b/PWGJE/JetFinders/jetFinderDielectronMCDCharged.cxx index 105b58d459a..1d14666ca10 100644 --- a/PWGJE/JetFinders/jetFinderDielectronMCDCharged.cxx +++ b/PWGJE/JetFinders/jetFinderDielectronMCDCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderDielectronMCDetectorLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderDielectronMCPCharged.cxx b/PWGJE/JetFinders/jetFinderDielectronMCPCharged.cxx index b6aa797e80e..b0be942e08e 100644 --- a/PWGJE/JetFinders/jetFinderDielectronMCPCharged.cxx +++ b/PWGJE/JetFinders/jetFinderDielectronMCPCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderDielectronMCParticleLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderDplusDataCharged.cxx b/PWGJE/JetFinders/jetFinderDplusDataCharged.cxx new file mode 100644 index 00000000000..c684fbc2e8c --- /dev/null +++ b/PWGJE/JetFinders/jetFinderDplusDataCharged.cxx @@ -0,0 +1,38 @@ +// 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. + +// jet finder D+ data charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetFinderHF.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + +using JetFinderDplusDataCharged = JetFinderHFTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJetsData", true}}}, + TaskName{"jet-finder-dplus-data-charged"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/jetFinderDplusMCDCharged.cxx b/PWGJE/JetFinders/jetFinderDplusMCDCharged.cxx new file mode 100644 index 00000000000..ebdbe27c015 --- /dev/null +++ b/PWGJE/JetFinders/jetFinderDplusMCDCharged.cxx @@ -0,0 +1,38 @@ +// 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. + +// jet finder D+ mcd charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetFinderHF.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + +using JetFinderDplusMCDetectorLevelCharged = JetFinderHFTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJetsMCD", true}}}, + TaskName{"jet-finder-dplus-mcd-charged"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/jetFinderDplusMCPCharged.cxx b/PWGJE/JetFinders/jetFinderDplusMCPCharged.cxx new file mode 100644 index 00000000000..da79b1c2c0e --- /dev/null +++ b/PWGJE/JetFinders/jetFinderDplusMCPCharged.cxx @@ -0,0 +1,38 @@ +// 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. + +// jet finder D+ mcp charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetFinderHF.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + +using JetFinderDplusMCParticleLevelCharged = JetFinderHFTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJetsMCP", true}}}, + TaskName{"jet-finder-dplus-mcp-charged"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/jetFinderDstarDataCharged.cxx b/PWGJE/JetFinders/jetFinderDstarDataCharged.cxx new file mode 100644 index 00000000000..0a1b6d104b3 --- /dev/null +++ b/PWGJE/JetFinders/jetFinderDstarDataCharged.cxx @@ -0,0 +1,38 @@ +// 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. + +// jet finder D* data charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetFinderHF.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + +using JetFinderDstarDataCharged = JetFinderHFTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJetsData", true}}}, + TaskName{"jet-finder-dstar-data-charged"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/jetFinderDstarMCDCharged.cxx b/PWGJE/JetFinders/jetFinderDstarMCDCharged.cxx new file mode 100644 index 00000000000..42e9c2fb370 --- /dev/null +++ b/PWGJE/JetFinders/jetFinderDstarMCDCharged.cxx @@ -0,0 +1,38 @@ +// 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. + +// jet finder D+ mcd charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetFinderHF.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + +using JetFinderDstarMCDetectorLevelCharged = JetFinderHFTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJetsMCD", true}}}, + TaskName{"jet-finder-dstar-mcd-charged"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/jetFinderDstarMCPCharged.cxx b/PWGJE/JetFinders/jetFinderDstarMCPCharged.cxx new file mode 100644 index 00000000000..36ce473fe3c --- /dev/null +++ b/PWGJE/JetFinders/jetFinderDstarMCPCharged.cxx @@ -0,0 +1,38 @@ +// 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. + +// jet finder D* mcp charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/JetFinders/jetFinderHF.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + +using JetFinderDstarMCParticleLevelCharged = JetFinderHFTask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{{{"processChargedJetsMCP", true}}}, + TaskName{"jet-finder-dstar-mcp-charged"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/JetFinders/jetFinderHF.cxx b/PWGJE/JetFinders/jetFinderHF.cxx index 53b6114cbe7..34409335767 100644 --- a/PWGJE/JetFinders/jetFinderHF.cxx +++ b/PWGJE/JetFinders/jetFinderHF.cxx @@ -14,21 +14,37 @@ /// \author Nima Zardoshti /// \author Jochen Klein -#include - -#include "CommonConstants/PhysicsConstants.h" - +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFinder.h" #include "PWGJE/Core/JetFindingUtilities.h" -#include "Common/Core/RecoDecay.h" +#include "PWGJE/DataModel/EMCALClusterDefinition.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export + +#include +#include + +#include +#include + +#include +#include using namespace o2; -using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; -// NB: runDataProcessing.h must be included after customize! -#include "Framework/runDataProcessing.h" - template struct JetFinderHFTask { Produces jetsTable; @@ -45,6 +61,7 @@ struct JetFinderHFTask { Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; + Configurable skipMBGapEvents{"skipMBGapEvents", true, "decide to run over MB gap events or not"}; // track level configurables Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; @@ -98,7 +115,7 @@ struct JetFinderHFTask { Service pdgDatabase; int trackSelection = -1; - int eventSelection = -1; + std::vector eventSelectionBits; std::string particleSelection; JetFinder jetFinder; @@ -110,7 +127,7 @@ struct JetFinderHFTask { { trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); particleSelection = static_cast(particleSelections); jetFinder.etaMin = trackEtaMin; @@ -151,7 +168,8 @@ struct JetFinderHFTask { } aod::EMCALClusterDefinition clusterDefinition = aod::emcalcluster::getClusterDefinitionFromString(clusterDefinitionS.value); - Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax && aod::jcollision::trackOccupancyInTimeRange <= trackOccupancyInTimeRangeMax); + Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax && aod::jcollision::trackOccupancyInTimeRange <= trackOccupancyInTimeRangeMax && ((skipMBGapEvents.node() == false) || (aod::jcollision::subGeneratorId != static_cast(jetderiveddatautilities::JCollisionSubGeneratorId::mbGap)))); + Filter mcCollisionFilter = ((skipMBGapEvents.node() == false) || (aod::jmccollision::subGeneratorId != static_cast(jetderiveddatautilities::JCollisionSubGeneratorId::mbGap))); // should we add a posZ vtx cut here or leave it to analysers? Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta >= trackEtaMin && aod::jtrack::eta <= trackEtaMax && aod::jtrack::phi >= trackPhiMin && aod::jtrack::phi <= trackPhiMax); Filter partCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax && aod::jmcparticle::eta >= trackEtaMin && aod::jmcparticle::eta <= trackEtaMax && aod::jmcparticle::phi >= trackPhiMin && aod::jmcparticle::phi <= trackPhiMax); Filter clusterFilter = (aod::jcluster::definition == static_cast(clusterDefinition) && aod::jcluster::eta >= clusterEtaMin && aod::jcluster::eta <= clusterEtaMax && aod::jcluster::phi >= clusterPhiMin && aod::jcluster::phi <= clusterPhiMax && aod::jcluster::energy >= clusterEnergyMin && aod::jcluster::time > clusterTimeMin && aod::jcluster::time < clusterTimeMax && (clusterRejectExotics && aod::jcluster::isExotic != true)); @@ -159,8 +177,14 @@ struct JetFinderHFTask { PresliceOptional> perD0Candidate = aod::bkgd0::candidateId; PresliceOptional> perD0McCandidate = aod::bkgd0mc::candidateId; + PresliceOptional> perDplusCandidate = aod::bkgdplus::candidateId; + PresliceOptional> perDplusMcCandidate = aod::bkgdplusmc::candidateId; + PresliceOptional> perDstarCandidate = aod::bkgdstar::candidateId; + PresliceOptional> perDstarMcCandidate = aod::bkgdstarmc::candidateId; PresliceOptional> perLcCandidate = aod::bkglc::candidateId; PresliceOptional> perLcMcCandidate = aod::bkglcmc::candidateId; + PresliceOptional> perB0Candidate = aod::bkgb0::candidateId; + PresliceOptional> perB0McCandidate = aod::bkgb0mc::candidateId; PresliceOptional> perBplusCandidate = aod::bkgbplus::candidateId; PresliceOptional> perBplusMcCandidate = aod::bkgbplusmc::candidateId; PresliceOptional> perDielectronCandidate = aod::bkgdielectron::candidateId; @@ -170,7 +194,7 @@ struct JetFinderHFTask { template void analyseCharged(T const& collision, U const& tracks, V const& candidate, M& jetsTableInput, N& constituentsTableInput, O& /*originalTracks*/, float minJetPt, float maxJetPt) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } inputParticles.clear(); @@ -189,7 +213,7 @@ struct JetFinderHFTask { if constexpr (isEvtWiseSub) { jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency); } else { - jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, &candidate); } jetfindingutilities::findJets(jetFinder, inputParticles, minJetPt, maxJetPt, jetRadius, jetAreaFractionMin, collision, jetsTableInput, constituentsTableInput, registry.get(HIST("hJet")), fillTHnSparse, true); } @@ -207,9 +231,9 @@ struct JetFinderHFTask { return; } if constexpr (checkIsDaughter) { - jetfindingutilities::analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, std::optional{candidate}); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, &candidate); } else { - jetfindingutilities::analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, std::optional{candidate}); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, &candidate); } jetfindingutilities::findJets(jetFinder, inputParticles, minJetPt, maxJetPt, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJetMCP")), fillTHnSparse, true); } @@ -230,7 +254,7 @@ struct JetFinderHFTask { void processChargedEvtWiseSubJetsData(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableData const& candidates) { for (typename CandidateTableData::iterator const& candidate : candidates) { - analyseCharged(collision, jetcandidateutilities::slicedPerCandidate(tracks, candidate, perD0Candidate, perLcCandidate, perBplusCandidate, perDielectronCandidate), candidate, jetsEvtWiseSubTable, constituentsEvtWiseSubTable, tracks, jetEWSPtMin, jetEWSPtMax); + analyseCharged(collision, jetcandidateutilities::slicedPerCandidate(tracks, candidate, perD0Candidate, perDplusCandidate, perDstarCandidate, perLcCandidate, perB0Candidate, perBplusCandidate, perDielectronCandidate), candidate, jetsEvtWiseSubTable, constituentsEvtWiseSubTable, tracks, jetEWSPtMin, jetEWSPtMax); } } PROCESS_SWITCH(JetFinderHFTask, processChargedEvtWiseSubJetsData, "charged hf jet finding on data with event-wise constituent subtraction", false); @@ -246,12 +270,12 @@ struct JetFinderHFTask { void processChargedEvtWiseSubJetsMCD(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableMCD const& candidates) { for (typename CandidateTableMCD::iterator const& candidate : candidates) { - analyseCharged(collision, jetcandidateutilities::slicedPerCandidate(tracks, candidate, perD0Candidate, perLcCandidate, perBplusCandidate, perDielectronCandidate), candidate, jetsEvtWiseSubTable, constituentsEvtWiseSubTable, tracks, jetEWSPtMin, jetEWSPtMax); + analyseCharged(collision, jetcandidateutilities::slicedPerCandidate(tracks, candidate, perD0Candidate, perDplusCandidate, perDstarCandidate, perLcCandidate, perB0Candidate, perBplusCandidate, perDielectronCandidate), candidate, jetsEvtWiseSubTable, constituentsEvtWiseSubTable, tracks, jetEWSPtMin, jetEWSPtMax); } } PROCESS_SWITCH(JetFinderHFTask, processChargedEvtWiseSubJetsMCD, "charged hf jet finding on MC detector level with event-wise constituent subtraction", false); - void processChargedJetsMCP(aod::JetMcCollision const& collision, + void processChargedJetsMCP(soa::Filtered::iterator const& collision, soa::Filtered const& particles, CandidateTableMCP const& candidates) { @@ -261,12 +285,12 @@ struct JetFinderHFTask { } PROCESS_SWITCH(JetFinderHFTask, processChargedJetsMCP, "hf jet finding on MC particle level", false); - void processChargedEvtWiseSubJetsMCP(aod::JetMcCollision const& collision, + void processChargedEvtWiseSubJetsMCP(soa::Filtered::iterator const& collision, soa::Filtered const& particles, CandidateTableMCP const& candidates) { for (typename CandidateTableMCP::iterator const& candidate : candidates) { - analyseMCP(collision, jetcandidateutilities::slicedPerCandidate(particles, candidate, perD0McCandidate, perLcMcCandidate, perBplusMcCandidate, perDielectronMcCandidate), candidate, 1, jetPtMin, jetPtMax); + analyseMCP(collision, jetcandidateutilities::slicedPerCandidate(particles, candidate, perD0McCandidate, perDplusMcCandidate, perDstarMcCandidate, perLcMcCandidate, perB0McCandidate, perBplusMcCandidate, perDielectronMcCandidate), candidate, 1, jetPtMin, jetPtMax); } } PROCESS_SWITCH(JetFinderHFTask, processChargedEvtWiseSubJetsMCP, "hf jet finding on MC particle level", false); diff --git a/PWGJE/JetFinders/jetFinderLcDataCharged.cxx b/PWGJE/JetFinders/jetFinderLcDataCharged.cxx index 821cbd87df8..37af66ca1b4 100644 --- a/PWGJE/JetFinders/jetFinderLcDataCharged.cxx +++ b/PWGJE/JetFinders/jetFinderLcDataCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderLcDataCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderLcMCDCharged.cxx b/PWGJE/JetFinders/jetFinderLcMCDCharged.cxx index c25f35c0efb..9172f395fb8 100644 --- a/PWGJE/JetFinders/jetFinderLcMCDCharged.cxx +++ b/PWGJE/JetFinders/jetFinderLcMCDCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderLcMCDetectorLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderLcMCPCharged.cxx b/PWGJE/JetFinders/jetFinderLcMCPCharged.cxx index 41607ed57d9..e9a1fd14346 100644 --- a/PWGJE/JetFinders/jetFinderLcMCPCharged.cxx +++ b/PWGJE/JetFinders/jetFinderLcMCPCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderHF.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderLcMCParticleLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderMCDCharged.cxx b/PWGJE/JetFinders/jetFinderMCDCharged.cxx index d8558a57770..198d1b87d98 100644 --- a/PWGJE/JetFinders/jetFinderMCDCharged.cxx +++ b/PWGJE/JetFinders/jetFinderMCDCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderMCDetectorLevelCharged = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderMCDFull.cxx b/PWGJE/JetFinders/jetFinderMCDFull.cxx index 0123b75d823..ce5b8ec42ec 100644 --- a/PWGJE/JetFinders/jetFinderMCDFull.cxx +++ b/PWGJE/JetFinders/jetFinderMCDFull.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderMCDetectorLevelFull = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderMCDNeutral.cxx b/PWGJE/JetFinders/jetFinderMCDNeutral.cxx index 9e8225b0c5f..e532c3d528b 100644 --- a/PWGJE/JetFinders/jetFinderMCDNeutral.cxx +++ b/PWGJE/JetFinders/jetFinderMCDNeutral.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderMCDetectorLevelNeutral = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderMCPCharged.cxx b/PWGJE/JetFinders/jetFinderMCPCharged.cxx index 9cba0092a53..98538de9708 100644 --- a/PWGJE/JetFinders/jetFinderMCPCharged.cxx +++ b/PWGJE/JetFinders/jetFinderMCPCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderMCParticleLevelCharged = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderMCPFull.cxx b/PWGJE/JetFinders/jetFinderMCPFull.cxx index ff9c26e4d91..217a1cfe928 100644 --- a/PWGJE/JetFinders/jetFinderMCPFull.cxx +++ b/PWGJE/JetFinders/jetFinderMCPFull.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderMCParticleLevelFull = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderMCPNeutral.cxx b/PWGJE/JetFinders/jetFinderMCPNeutral.cxx index 8593fb1f644..b2240dbe6e4 100644 --- a/PWGJE/JetFinders/jetFinderMCPNeutral.cxx +++ b/PWGJE/JetFinders/jetFinderMCPNeutral.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinder.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderMCParticleLevelNeutral = JetFinderTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderV0.cxx b/PWGJE/JetFinders/jetFinderV0.cxx index 4398a3b1a7a..6d8b94d905a 100644 --- a/PWGJE/JetFinders/jetFinderV0.cxx +++ b/PWGJE/JetFinders/jetFinderV0.cxx @@ -13,21 +13,34 @@ // /// \author Nima Zardoshti -#include +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "CommonConstants/PhysicsConstants.h" +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export -#include "PWGJE/Core/JetFindingUtilities.h" -#include "Common/Core/RecoDecay.h" +#include +#include + +#include +#include + +#include +#include using namespace o2; -using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; -// NB: runDataProcessing.h must be included after customize! -#include "Framework/runDataProcessing.h" - template struct JetFinderV0Task { @@ -43,6 +56,7 @@ struct JetFinderV0Task { Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; + Configurable skipMBGapEvents{"skipMBGapEvents", true, "decide to run over MB gap events or not"}; // track level configurables Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; @@ -78,10 +92,11 @@ struct JetFinderV0Task { Configurable jetPtBinWidth{"jetPtBinWidth", 5, "used to define the width of the jetPt bins for the THnSparse"}; Configurable fillTHnSparse{"fillTHnSparse", true, "switch to fill the THnSparse"}; Configurable jetExtraParam{"jetExtraParam", -99.0, "sets the _extra_param in fastjet"}; + Configurable useV0SignalFlags{"useV0SignalFlags", true, "use V0 signal flags table"}; Service pdgDatabase; int trackSelection = -1; - int eventSelection = -1; + std::vector eventSelectionBits; std::string particleSelection; JetFinder jetFinder; @@ -95,7 +110,7 @@ struct JetFinderV0Task { { trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); particleSelection = static_cast(particleSelections); jetFinder.etaMin = trackEtaMin; @@ -142,20 +157,20 @@ struct JetFinderV0Task { registry.add("hJetMCP", "sparse for mcp jets", {HistType::kTHnC, {{jetRadiiBins, ""}, {jetPtBinNumber, jetPtMinDouble, jetPtMaxDouble}, {40, -1.0, 1.0}, {18, 0.0, 7.0}}}); } - Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax && aod::jcollision::trackOccupancyInTimeRange <= trackOccupancyInTimeRangeMax); + Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax && aod::jcollision::trackOccupancyInTimeRange <= trackOccupancyInTimeRangeMax && ((skipMBGapEvents.node() == false) || (aod::jcollision::subGeneratorId != static_cast(jetderiveddatautilities::JCollisionSubGeneratorId::mbGap)))); + Filter mcCollisionFilter = ((skipMBGapEvents.node() == false) || (aod::jmccollision::subGeneratorId != static_cast(jetderiveddatautilities::JCollisionSubGeneratorId::mbGap))); // should we add a posZ vtx cut here or leave it to analysers? Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta >= trackEtaMin && aod::jtrack::eta <= trackEtaMax && aod::jtrack::phi >= trackPhiMin && aod::jtrack::phi <= trackPhiMax); Filter partCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax && aod::jmcparticle::eta >= trackEtaMin && aod::jmcparticle::eta <= trackEtaMax && aod::jmcparticle::phi >= trackPhiMin && aod::jmcparticle::phi <= trackPhiMax); - // Filter candidateCuts = (aod::hfcand::pt >= candPtMin && aod::hfcand::pt < candPtMax && aod::hfcand::y >= candYMin && aod::hfcand::y < candYMax); // function that generalically processes Data and reco level events template void analyseCharged(T const& collision, U const& tracks, V const& candidates, M& jetsTableInput, N& constituentsTableInput, float minJetPt, float maxJetPt) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } inputParticles.clear(); - if (!jetfindingutilities::analyseV0s(inputParticles, candidates, candPtMin, candPtMax, candYMin, candYMax, candIndex)) { + if (!jetfindingutilities::analyseV0s(inputParticles, candidates, candPtMin, candPtMax, candYMin, candYMax, candIndex, useV0SignalFlags)) { return; } @@ -176,10 +191,10 @@ struct JetFinderV0Task { { inputParticles.clear(); - if (!jetfindingutilities::analyseV0s(inputParticles, candidates, candPtMin, candPtMax, candYMin, candYMax, candIndex)) { + if (!jetfindingutilities::analyseV0s(inputParticles, candidates, candPtMin, candPtMax, candYMin, candYMax, candIndex, useV0SignalFlags)) { return; } - jetfindingutilities::analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, std::optional{candidates}); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, jetTypeParticleLevel, particles, pdgDatabase, &candidates); jetfindingutilities::findJets(jetFinder, inputParticles, minJetPt, maxJetPt, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJetMCP")), fillTHnSparse, true); } @@ -200,7 +215,7 @@ struct JetFinderV0Task { } PROCESS_SWITCH(JetFinderV0Task, processChargedJetsMCD, "charged hf jet finding on MC detector level", false); - void processChargedJetsMCP(aod::JetMcCollision const& collision, + void processChargedJetsMCP(soa::Filtered::iterator const& collision, soa::Filtered const& particles, CandidateTableMCP const& candidates) { diff --git a/PWGJE/JetFinders/jetFinderV0DataCharged.cxx b/PWGJE/JetFinders/jetFinderV0DataCharged.cxx index 7b1ac0a261f..1b239661afd 100644 --- a/PWGJE/JetFinders/jetFinderV0DataCharged.cxx +++ b/PWGJE/JetFinders/jetFinderV0DataCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderV0.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderV0DataCharged = JetFinderV0Task; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderV0MCDCharged.cxx b/PWGJE/JetFinders/jetFinderV0MCDCharged.cxx index 30442208085..890b3334776 100644 --- a/PWGJE/JetFinders/jetFinderV0MCDCharged.cxx +++ b/PWGJE/JetFinders/jetFinderV0MCDCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderV0.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderV0MCDetectorLevelCharged = JetFinderV0Task; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/JetFinders/jetFinderV0MCPCharged.cxx b/PWGJE/JetFinders/jetFinderV0MCPCharged.cxx index 27de0bdbc3c..3704f8f67b0 100644 --- a/PWGJE/JetFinders/jetFinderV0MCPCharged.cxx +++ b/PWGJE/JetFinders/jetFinderV0MCPCharged.cxx @@ -15,6 +15,15 @@ #include "PWGJE/JetFinders/jetFinderV0.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include + +#include + using JetFinderV0MCParticleLevelCharged = JetFinderV0Task; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/TableProducer/CMakeLists.txt b/PWGJE/TableProducer/CMakeLists.txt index 4e8141566f3..4644106c740 100644 --- a/PWGJE/TableProducer/CMakeLists.txt +++ b/PWGJE/TableProducer/CMakeLists.txt @@ -15,7 +15,7 @@ if(FastJet_FOUND) o2physics_add_dpl_workflow(jet-deriveddata-producer SOURCES derivedDataProducer.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2Physics::EventFilteringUtils + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2Physics::EventFilteringUtils O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-deriveddata-trigger-producer @@ -23,28 +23,8 @@ o2physics_add_dpl_workflow(jet-deriveddata-trigger-producer PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(jet-deriveddata-producer-dummy - SOURCES derivedDataProducerDummy.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(jet-deriveddata-producer-dummy-d0 - SOURCES derivedDataProducerDummyD0.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(jet-deriveddata-producer-dummy-lc - SOURCES derivedDataProducerDummyLc.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(jet-deriveddata-producer-dummy-bplus - SOURCES derivedDataProducerDummyBplus.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(jet-deriveddata-producer-dummy-dielectron - SOURCES derivedDataProducerDummyDielectron.cxx +o2physics_add_dpl_workflow(jet-deriveddata-selector + SOURCES derivedDataSelector.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -73,14 +53,24 @@ o2physics_add_dpl_workflow(jet-eventweight-mcp PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(mc-outlier-rejector + SOURCES mcOutlierRejector.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-track-derived SOURCES jetTrackDerived.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-hf-definition + SOURCES heavyFlavourDefinition.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-taggerhf SOURCES jetTaggerHF.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(estimator-rho @@ -103,10 +93,15 @@ endif() o2physics_add_dpl_workflow(emcal-correction-task SOURCES emcalCorrectionTask.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::EMCALBase O2::EMCALReconstruction + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::EMCALBase O2::EMCALReconstruction O2::EMCALCalibration O2Physics::PWGJECore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(emcal-matchedtracks-writer SOURCES emcalMatchedTracksTask.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::EMCALBase O2::EMCALReconstruction COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(emcal-cluster-hadronic-correction-task + SOURCES emcalClusterHadronicCorrectionTask.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::EMCALBase O2::EMCALReconstruction + COMPONENT_NAME Analysis) diff --git a/PWGJE/TableProducer/Matching/CMakeLists.txt b/PWGJE/TableProducer/Matching/CMakeLists.txt index a3848f352e7..e6526d90f1e 100644 --- a/PWGJE/TableProducer/Matching/CMakeLists.txt +++ b/PWGJE/TableProducer/Matching/CMakeLists.txt @@ -10,6 +10,7 @@ # or submit itself to any jurisdiction. add_subdirectory(Duplicates) +add_subdirectory(Substructure) if(FastJet_FOUND) @@ -33,11 +34,26 @@ o2physics_add_dpl_workflow(jet-matching-mc-d0-ch PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-matching-mc-dplus-ch + SOURCES jetMatchingMCDplusCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-matching-mc-dstar-ch + SOURCES jetMatchingMCDstarCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-matching-mc-lc-ch SOURCES jetMatchingMCLcCharged.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-matching-mc-b0-ch + SOURCES jetMatchingMCB0Charged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-matching-mc-bplus-ch SOURCES jetMatchingMCBplusCharged.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport @@ -63,11 +79,26 @@ o2physics_add_dpl_workflow(jet-matching-mc-sub-d0-ch PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-matching-mc-sub-dplus-ch + SOURCES jetMatchingMCSubDplusCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-matching-mc-sub-dstar-ch + SOURCES jetMatchingMCSubDstarCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-matching-mc-sub-lc-ch SOURCES jetMatchingMCSubLcCharged.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-matching-mc-sub-b0-ch + SOURCES jetMatchingMCSubB0Charged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-matching-mc-sub-bplus-ch SOURCES jetMatchingMCSubBplusCharged.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport @@ -88,6 +119,16 @@ o2physics_add_dpl_workflow(jet-matching-sub-d0-ch PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-matching-sub-dplus-ch + SOURCES jetMatchingSubDplusCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-matching-sub-dstar-ch + SOURCES jetMatchingSubDstarCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-matching-sub-lc-ch SOURCES jetMatchingSubLcCharged.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport @@ -98,6 +139,11 @@ o2physics_add_dpl_workflow(jet-matching-sub-bplus-ch PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-matching-sub-b0-ch + SOURCES jetMatchingSubB0Charged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-matching-sub-dielectron-ch SOURCES jetMatchingSubDielectronCharged.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport diff --git a/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicates.cxx b/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicates.cxx index bc4711efae3..9e7d28ef94f 100644 --- a/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicates.cxx +++ b/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicates.cxx @@ -13,18 +13,17 @@ /// \brief matching duplicate jets /// \author Nima Zardoshti -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGJE/Core/JetMatchingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + #include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include +#include // IWYU pragma: export -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/Core/JetMatchingUtilities.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include using namespace o2; using namespace o2::framework; @@ -74,7 +73,7 @@ struct JetMatchingDuplicates { const auto jetsBasePerColl = jetsBase.sliceBy(baseJetsPerCollision, collision.globalIndex()); const auto jetsTagPerColl = jetsTag.sliceBy(tagJetsPerCollision, collision.globalIndex()); // initialise template parameters as false since even if they are Mc we are not matching between detector and particle level - jetmatchingutilities::doAllMatching(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidates, candidates, tracks, tracks, tracks, tracks, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); + jetmatchingutilities::doAllMatching(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidates, tracks, tracks, candidates, tracks, tracks, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); } for (auto i = 0; i < jetsBase.size(); ++i) { diff --git a/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedData1.cxx b/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedData1.cxx index 8115c95bf04..acf6346f615 100644 --- a/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedData1.cxx +++ b/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedData1.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicates.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using Charged1JetDataMatchingDupliacates = JetMatchingDuplicates, soa::Join, aod::ChargedJetsMatchedToCharged1Jets, diff --git a/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedMCD1.cxx b/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedMCD1.cxx index 96033d17d4e..b900fb9f0c1 100644 --- a/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedMCD1.cxx +++ b/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedMCD1.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicates.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using Charged1JetMCDMatchingDupliacates = JetMatchingDuplicates, soa::Join, aod::ChargedMCDetectorLevelJetsMatchedToCharged1MCDetectorLevelJets, diff --git a/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedMCP1.cxx b/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedMCP1.cxx index 11b39822bcb..f913f810191 100644 --- a/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedMCP1.cxx +++ b/PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicatesChargedMCP1.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/Duplicates/jetMatchingDuplicates.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using Charged1JetMCPMatchingDupliacates = JetMatchingDuplicates, soa::Join, aod::ChargedMCParticleLevelJetsMatchedToCharged1MCParticleLevelJets, diff --git a/PWGJE/TableProducer/Matching/Substructure/CMakeLists.txt b/PWGJE/TableProducer/Matching/Substructure/CMakeLists.txt new file mode 100644 index 00000000000..e004a0a52ee --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/CMakeLists.txt @@ -0,0 +1,95 @@ +# 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. + + +if(FastJet_FOUND) + +o2physics_add_dpl_workflow(jet-substructure-matching-mc-ch + SOURCES jetSubstructureMatchingMCCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-mc-d0-ch + SOURCES jetSubstructureMatchingMCD0Charged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-mc-dplus-ch + SOURCES jetSubstructureMatchingMCDplusCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-mc-dstar-ch + SOURCES jetSubstructureMatchingMCDstarCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-mc-lc-ch + SOURCES jetSubstructureMatchingMCLcCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-mc-b0-ch + SOURCES jetSubstructureMatchingMCB0Charged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-mc-bplus-ch + SOURCES jetSubstructureMatchingMCBplusCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-mc-dielectron-ch + SOURCES jetSubstructureMatchingMCDielectronCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-sub-ch + SOURCES jetSubstructureMatchingSubCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-sub-d0-ch + SOURCES jetSubstructureMatchingSubD0Charged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-sub-dplus-ch + SOURCES jetSubstructureMatchingSubDplusCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-sub-dstar-ch + SOURCES jetSubstructureMatchingSubDstarCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-sub-lc-ch + SOURCES jetSubstructureMatchingSubLcCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-sub-b0-ch + SOURCES jetSubstructureMatchingSubB0Charged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-sub-bplus-ch + SOURCES jetSubstructureMatchingSubBplusCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-substructure-matching-sub-dielectron-ch + SOURCES jetSubstructureMatchingSubDielectronCharged.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2::FrameworkPhysicsSupport + COMPONENT_NAME Analysis) + +endif() diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx new file mode 100644 index 00000000000..02b4c1b87d1 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx @@ -0,0 +1,272 @@ +// 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. + +// jet analysis tasks (subscribing to jet finder task) +// +/// \author Nima Zardoshti +// + +#include "PWGJE/Core/JetMatchingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include "Framework/ASoA.h" +#include +#include +#include +#include // IWYU pragma: export + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +template +struct JetSubstructureMatching { + + Produces splittingsBasetoTagMatchingTable; + Produces splittingsTagtoBaseMatchingTable; + + Produces pairsBasetoTagMatchingTable; + Produces pairsTagtoBaseMatchingTable; + + Configurable doMatchingGeo{"doMatchingGeo", true, "Enable geometric matching"}; + Configurable doMatchingPt{"doMatchingPt", true, "Enable pt matching"}; + Configurable doMatchingHf{"doMatchingHf", false, "Enable HF matching"}; + Configurable maxMatchingDistance{"maxMatchingDistance", 0.24f, "Max matching distance"}; + Configurable minPtFraction{"minPtFraction", 0.5f, "Minimum pt fraction for pt matching"}; + Configurable requireGeoMatchedJets{"requireGeoMatchedJets", false, "require jets are geo matched as well"}; + Configurable requirePtMatchedJets{"requirePtMatchedJets", false, "require jets are pT matched as well"}; + Configurable requireHFMatchedJets{"requireHFMatchedJets", false, "require jets are HF matched as well"}; + + static constexpr bool jetsBaseIsMc = o2::soa::relatedByIndex(); + static constexpr bool jetsTagIsMc = o2::soa::relatedByIndex(); + + void init(InitContext const&) + { + } + + PresliceOptional BaseSplittingsPerBaseJetInclusive = aod::chargedmcdetectorlevelsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetInclusive = aod::chargedmcparticlelevelsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetD0 = aod::d0chargedmcdetectorlevelsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetD0 = aod::d0chargedmcparticlelevelsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetDplus = aod::dpluschargedmcdetectorlevelsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetDplus = aod::dpluschargedmcparticlelevelsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetDstar = aod::dstarchargedmcdetectorlevelsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetDstar = aod::dstarchargedmcparticlelevelsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetLc = aod::lcchargedmcdetectorlevelsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetLc = aod::lcchargedmcparticlelevelsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetB0 = aod::b0chargedmcdetectorlevelsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetB0 = aod::b0chargedmcparticlelevelsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetBplus = aod::bpluschargedmcdetectorlevelsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetBplus = aod::bpluschargedmcparticlelevelsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetDielectron = aod::dielectronchargedmcdetectorlevelsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetDielectron = aod::dielectronchargedmcparticlelevelsplitting::jetId; + + PresliceOptional BasePairsPerBaseJetInclusive = aod::chargedmcdetectorlevelpair::jetId; + PresliceOptional TagPairsPerTagJetInclusive = aod::chargedmcparticlelevelpair::jetId; + PresliceOptional BasePairsPerBaseJetD0 = aod::d0chargedmcdetectorlevelpair::jetId; + PresliceOptional TagPairsPerTagJetD0 = aod::d0chargedmcparticlelevelpair::jetId; + PresliceOptional BasePairsPerBaseJetDplus = aod::dpluschargedmcdetectorlevelpair::jetId; + PresliceOptional TagPairsPerTagJetDplus = aod::dpluschargedmcparticlelevelpair::jetId; + PresliceOptional BasePairsPerBaseJetDstar = aod::dstarchargedmcdetectorlevelpair::jetId; + PresliceOptional TagPairsPerTagJetDstar = aod::dstarchargedmcparticlelevelpair::jetId; + PresliceOptional BasePairsPerBaseJetLc = aod::lcchargedmcdetectorlevelpair::jetId; + PresliceOptional TagPairsPerTagJetLc = aod::lcchargedmcparticlelevelpair::jetId; + PresliceOptional BasePairsPerBaseJetB0 = aod::b0chargedmcdetectorlevelpair::jetId; + PresliceOptional TagPairsPerTagJetB0 = aod::b0chargedmcparticlelevelpair::jetId; + PresliceOptional BasePairsPerBaseJetBplus = aod::bpluschargedmcdetectorlevelpair::jetId; + PresliceOptional TagPairsPerTagJetBplus = aod::bpluschargedmcparticlelevelpair::jetId; + PresliceOptional BasePairsPerBaseJetDielectron = aod::dielectronchargedmcdetectorlevelpair::jetId; + PresliceOptional TagPairsPerTagJetDielectron = aod::dielectronchargedmcparticlelevelpair::jetId; + + // workaround till binding nodes can be passed as template arguments + template + auto slicedPerJetForMatching(T const& table, U const& jet, V const& perIncluisveJet, M const& perD0Jet, N const& perDplusJet, O const& perDstarJet, P const& perLcJet, Q const& perB0Jet, R const& perBplusJet, S const& perDielectronJet) + { + if constexpr (jethfutilities::isHFTable() || jethfutilities::isHFMcTable()) { + return jethfutilities::slicedPerHFJet(table, jet, perD0Jet, perDplusJet, perDstarJet, perLcJet, perB0Jet, perBplusJet); + } else if constexpr (jetdqutilities::isDielectronTable() || jetdqutilities::isDielectronMcTable()) { + return jetdqutilities::slicedPerDielectronJet(table, jet, perDielectronJet); + } else { + return table.sliceBy(perIncluisveJet, jet.globalIndex()); + } + } + + template + auto defaultMatchedJets(T const& jetTag) + { + if constexpr (jetcandidateutilities::isCandidateTable()) { + return jetTag.template matchedJetCand_as(); + } else { + return jetTag.template matchedJetGeo_as(); + } + } + + void processData(JetsTag const& jetsTag, + JetsBase const&, + SplittingsBase const& jetsBaseSplittings, + SplittingsTag const& jetsTagSplittings, + PairsBase const& jetsBasePairs, + PairsTag const& jetsTagPairs, + CandidatesBase const& candidatesBase, + CandidatesTag const& candidatesTag, + ClustersBase const& clustersBase, + TracksBase const& tracksBase, TracksTag const& tracksTag) + { + std::vector> jetsBasetoTagSplittingsMatchingGeo, jetsBasetoTagSplittingsMatchingPt, jetsBasetoTagSplittingsMatchingHF; + jetsBasetoTagSplittingsMatchingGeo.assign(jetsBaseSplittings.size(), {}); + jetsBasetoTagSplittingsMatchingPt.assign(jetsBaseSplittings.size(), {}); + jetsBasetoTagSplittingsMatchingHF.assign(jetsBaseSplittings.size(), {}); + + std::vector> jetsTagtoBaseSplittingsMatchingGeo, jetsTagtoBaseSplittingsMatchingPt, jetsTagtoBaseSplittingsMatchingHF; + jetsTagtoBaseSplittingsMatchingGeo.assign(jetsTagSplittings.size(), {}); + jetsTagtoBaseSplittingsMatchingPt.assign(jetsTagSplittings.size(), {}); + jetsTagtoBaseSplittingsMatchingHF.assign(jetsTagSplittings.size(), {}); + + std::vector jetTagSplittingsMap; + std::vector jetBaseSplittingsMap; + jetTagSplittingsMap.resize(jetsTagSplittings.size(), -1); + jetBaseSplittingsMap.resize(jetsBaseSplittings.size(), -1); + + std::vector> jetsBasetoTagPairsMatching; + std::vector> jetsTagtoBasePairsMatching; + jetsBasetoTagPairsMatching.assign(jetsBasePairs.size(), {}); + jetsTagtoBasePairsMatching.assign(jetsTagPairs.size(), {}); + + std::vector jetTagPairsMap; + std::vector jetBasePairsMap; + jetTagPairsMap.resize(jetsTagPairs.size(), -1); + jetBasePairsMap.resize(jetsBasePairs.size(), -1); + + for (auto jetTag : jetsTag) { + bool hasMatchedJet = false; + if constexpr (jetcandidateutilities::isCandidateTable()) { + hasMatchedJet = jetTag.has_matchedJetCand(); + } else { + hasMatchedJet = jetTag.has_matchedJetGeo(); + } + if (hasMatchedJet) { + // auto const& jetTagSplittings = jetsTagSplittings.sliceBy(TagSplittingsPerTagJet, jetTag.globalIndex()); + auto const& jetTagSplittings = slicedPerJetForMatching(jetsTagSplittings, jetTag, TagSplittingsPerTagJetInclusive, TagSplittingsPerTagJetD0, TagSplittingsPerTagJetDplus, TagSplittingsPerTagJetDstar, TagSplittingsPerTagJetLc, TagSplittingsPerTagJetB0, TagSplittingsPerTagJetBplus, TagSplittingsPerTagJetDielectron); + int tagSplittingIndex = 0; + for (auto const& jetTagSplitting : jetTagSplittings) { + jetTagSplittingsMap[jetTagSplitting.globalIndex()] = tagSplittingIndex; + tagSplittingIndex++; + } + // auto const& jetTagPairs = jetsTagPairs.sliceBy(TagPairsPerTagJet, jetTag.globalIndex()); + auto const& jetTagPairs = slicedPerJetForMatching(jetsTagPairs, jetTag, TagPairsPerTagJetInclusive, TagPairsPerTagJetD0, TagPairsPerTagJetDplus, TagPairsPerTagJetDstar, TagPairsPerTagJetLc, TagPairsPerTagJetB0, TagPairsPerTagJetBplus, TagPairsPerTagJetDielectron); + int tagPairIndex = 0; + for (auto const& jetTagPair : jetTagPairs) { + jetTagPairsMap[jetTagPair.globalIndex()] = tagPairIndex; + tagPairIndex++; + } + for (auto& jetBase : defaultMatchedJets(jetTag)) { + if (requireGeoMatchedJets) { + bool jetsMatchedWithGeo = false; + for (auto& jetBaseForMatchGeo : jetTag.template matchedJetGeo_as()) { + if (jetBaseForMatchGeo.globalIndex() == jetBase.globalIndex()) { + jetsMatchedWithGeo = true; + } + } + if (!jetsMatchedWithGeo) { + continue; + } + } + if (requirePtMatchedJets) { + bool jetsMatchedWithPt = false; + for (auto& jetBaseForMatchPt : jetTag.template matchedJetPt_as()) { + if (jetBaseForMatchPt.globalIndex() == jetBase.globalIndex()) { + jetsMatchedWithPt = true; + } + } + if (!jetsMatchedWithPt) { + continue; + } + } + if (requireHFMatchedJets) { + bool jetsMatchedWithHF = false; + for (auto& jetBaseForMatchHF : jetTag.template matchedJetCand_as()) { + if (jetBaseForMatchHF.globalIndex() == jetBase.globalIndex()) { + jetsMatchedWithHF = true; + } + } + if (!jetsMatchedWithHF) { + continue; + } + } + // auto const& jetBaseSplittings = jetsBaseSplittings.sliceBy(BaseSplittingsPerBaseJet, jetBase.globalIndex()); + auto const& jetBaseSplittings = slicedPerJetForMatching(jetsBaseSplittings, jetBase, BaseSplittingsPerBaseJetInclusive, BaseSplittingsPerBaseJetD0, BaseSplittingsPerBaseJetDplus, BaseSplittingsPerBaseJetDstar, BaseSplittingsPerBaseJetLc, BaseSplittingsPerBaseJetB0, BaseSplittingsPerBaseJetBplus, BaseSplittingsPerBaseJetDielectron); + int baseSplittingIndex = 0; + for (auto const& jetBaseSplitting : jetBaseSplittings) { + jetBaseSplittingsMap[jetBaseSplitting.globalIndex()] = baseSplittingIndex; + baseSplittingIndex++; + } + jetmatchingutilities::doAllMatching(jetBaseSplittings, jetTagSplittings, jetsBasetoTagSplittingsMatchingGeo, jetsBasetoTagSplittingsMatchingPt, jetsBasetoTagSplittingsMatchingHF, jetsTagtoBaseSplittingsMatchingGeo, jetsTagtoBaseSplittingsMatchingPt, jetsTagtoBaseSplittingsMatchingHF, candidatesBase, tracksBase, clustersBase, candidatesTag, tracksTag, tracksTag, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); + // auto const& jetBasePairs = jetsBasePairs.sliceBy(BasePairsPerBaseJet, jetBase.globalIndex()); + auto const& jetBasePairs = slicedPerJetForMatching(jetsBasePairs, jetBase, BasePairsPerBaseJetInclusive, BasePairsPerBaseJetD0, BasePairsPerBaseJetDplus, BasePairsPerBaseJetDstar, BasePairsPerBaseJetLc, BasePairsPerBaseJetB0, BasePairsPerBaseJetBplus, BasePairsPerBaseJetDielectron); + int basePairIndex = 0; + for (auto const& jetBasePair : jetBasePairs) { + jetBasePairsMap[jetBasePair.globalIndex()] = basePairIndex; + basePairIndex++; + } + jetmatchingutilities::doPairMatching(jetBasePairs, jetTagPairs, jetsBasetoTagPairsMatching, jetsTagtoBasePairsMatching, candidatesBase, tracksBase, candidatesTag, tracksTag); + } + } + } + for (auto jetsTagSplitting : jetsTagSplittings) { + std::vector tagToBaseMatchingGeoIndex; + std::vector tagToBaseMatchingPtIndex; + std::vector tagToBaseMatchingHFIndex; + for (auto jetBaseSplittingIndex : jetsTagtoBaseSplittingsMatchingGeo[jetsTagSplitting.globalIndex()]) { + tagToBaseMatchingGeoIndex.push_back(jetBaseSplittingsMap[jetBaseSplittingIndex]); + } + for (auto jetBaseSplittingIndex : jetsTagtoBaseSplittingsMatchingPt[jetsTagSplitting.globalIndex()]) { + tagToBaseMatchingPtIndex.push_back(jetBaseSplittingsMap[jetBaseSplittingIndex]); + } + for (auto jetBaseSplittingIndex : jetsTagtoBaseSplittingsMatchingHF[jetsTagSplitting.globalIndex()]) { + tagToBaseMatchingHFIndex.push_back(jetBaseSplittingsMap[jetBaseSplittingIndex]); + } + splittingsTagtoBaseMatchingTable(tagToBaseMatchingGeoIndex, tagToBaseMatchingPtIndex, tagToBaseMatchingHFIndex); + } + for (auto jetsBaseSplitting : jetsBaseSplittings) { + std::vector baseToTagMatchingGeoIndex; + std::vector baseToTagMatchingPtIndex; + std::vector baseToTagMatchingHFIndex; + for (auto jetTagSplittingIndex : jetsBasetoTagSplittingsMatchingGeo[jetsBaseSplitting.globalIndex()]) { + baseToTagMatchingGeoIndex.push_back(jetTagSplittingsMap[jetTagSplittingIndex]); + } + for (auto jetTagSplittingIndex : jetsBasetoTagSplittingsMatchingPt[jetsBaseSplitting.globalIndex()]) { + baseToTagMatchingPtIndex.push_back(jetTagSplittingsMap[jetTagSplittingIndex]); + } + for (auto jetTagSplittingIndex : jetsBasetoTagSplittingsMatchingHF[jetsBaseSplitting.globalIndex()]) { + baseToTagMatchingHFIndex.push_back(jetTagSplittingsMap[jetTagSplittingIndex]); + } + splittingsBasetoTagMatchingTable(baseToTagMatchingGeoIndex, baseToTagMatchingPtIndex, baseToTagMatchingHFIndex); + } + for (auto jetsTagPair : jetsTagPairs) { + std::vector tagToBaseMatchingIndex; + for (auto jetBasePairIndex : jetsTagtoBasePairsMatching[jetsTagPair.globalIndex()]) { + tagToBaseMatchingIndex.push_back(jetBasePairsMap[jetBasePairIndex]); + } + pairsTagtoBaseMatchingTable(tagToBaseMatchingIndex); + } + for (auto jetsBasePair : jetsBasePairs) { + std::vector baseToTagMatchingIndex; + for (auto jetTagPairIndex : jetsBasetoTagPairsMatching[jetsBasePair.globalIndex()]) { + baseToTagMatchingIndex.push_back(jetTagPairsMap[jetTagPairIndex]); + } + pairsBasetoTagMatchingTable(baseToTagMatchingIndex); + } + } + PROCESS_SWITCH(JetSubstructureMatching, processData, "charged jet substructure", true); +}; diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCB0Charged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCB0Charged.cxx new file mode 100644 index 00000000000..96e3e0081ec --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCB0Charged.cxx @@ -0,0 +1,51 @@ +// 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. + +// B0 substructure matching mc charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using B0ChargedJetSubstructureMatchingMC = JetSubstructureMatching, + soa::Join, + aod::B0ChargedMCDetectorLevelSPsMatchedToB0ChargedMCParticleLevelSPs, + aod::B0ChargedMCParticleLevelSPsMatchedToB0ChargedMCDetectorLevelSPs, + aod::B0ChargedMCDetectorLevelPRsMatchedToB0ChargedMCParticleLevelPRs, + aod::B0ChargedMCParticleLevelPRsMatchedToB0ChargedMCDetectorLevelPRs, + aod::B0ChargedMCDetectorLevelSPs, + aod::B0ChargedMCParticleLevelSPs, + aod::B0ChargedMCDetectorLevelPRs, + aod::B0ChargedMCParticleLevelPRs, + aod::CandidatesB0MCD, + aod::CandidatesB0MCP, + aod::JetTracksMCD, + aod::JetParticles, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-mc-b0-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCBplusCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCBplusCharged.cxx new file mode 100644 index 00000000000..27bfc4ca22f --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCBplusCharged.cxx @@ -0,0 +1,51 @@ +// 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. + +// Bplus substructure matching mc charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using BplusChargedJetSubstructureMatchingMC = JetSubstructureMatching, + soa::Join, + aod::BplusChargedMCDetectorLevelSPsMatchedToBplusChargedMCParticleLevelSPs, + aod::BplusChargedMCParticleLevelSPsMatchedToBplusChargedMCDetectorLevelSPs, + aod::BplusChargedMCDetectorLevelPRsMatchedToBplusChargedMCParticleLevelPRs, + aod::BplusChargedMCParticleLevelPRsMatchedToBplusChargedMCDetectorLevelPRs, + aod::BplusChargedMCDetectorLevelSPs, + aod::BplusChargedMCParticleLevelSPs, + aod::BplusChargedMCDetectorLevelPRs, + aod::BplusChargedMCParticleLevelPRs, + aod::CandidatesBplusMCD, + aod::CandidatesBplusMCP, + aod::JetTracksMCD, + aod::JetParticles, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-mc-bplus-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCCharged.cxx new file mode 100644 index 00000000000..e73fab8c77e --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCCharged.cxx @@ -0,0 +1,51 @@ +// 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. + +// substructure matching mc charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using ChargedJetSubstructureMatchingMC = JetSubstructureMatching, + soa::Join, + aod::ChargedMCDetectorLevelSPsMatchedToChargedMCParticleLevelSPs, + aod::ChargedMCParticleLevelSPsMatchedToChargedMCDetectorLevelSPs, + aod::ChargedMCDetectorLevelPRsMatchedToChargedMCParticleLevelPRs, + aod::ChargedMCParticleLevelPRsMatchedToChargedMCDetectorLevelPRs, + aod::ChargedMCDetectorLevelSPs, + aod::ChargedMCParticleLevelSPs, + aod::ChargedMCDetectorLevelPRs, + aod::ChargedMCParticleLevelPRs, + aod::JCollisions, + aod::JMcCollisions, + aod::JetTracksMCD, + aod::JetParticles, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-mc-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCD0Charged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCD0Charged.cxx new file mode 100644 index 00000000000..82ae0adbb91 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCD0Charged.cxx @@ -0,0 +1,51 @@ +// 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. + +// D0 substructure matching mc charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using D0ChargedJetSubstructureMatchingMC = JetSubstructureMatching, + soa::Join, + aod::D0ChargedMCDetectorLevelSPsMatchedToD0ChargedMCParticleLevelSPs, + aod::D0ChargedMCParticleLevelSPsMatchedToD0ChargedMCDetectorLevelSPs, + aod::D0ChargedMCDetectorLevelPRsMatchedToD0ChargedMCParticleLevelPRs, + aod::D0ChargedMCParticleLevelPRsMatchedToD0ChargedMCDetectorLevelPRs, + aod::D0ChargedMCDetectorLevelSPs, + aod::D0ChargedMCParticleLevelSPs, + aod::D0ChargedMCDetectorLevelPRs, + aod::D0ChargedMCParticleLevelPRs, + aod::CandidatesD0MCD, + aod::CandidatesD0MCP, + aod::JetTracksMCD, + aod::JetParticles, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-mc-d0-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCDielectronCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCDielectronCharged.cxx new file mode 100644 index 00000000000..395617bed72 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCDielectronCharged.cxx @@ -0,0 +1,51 @@ +// 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. + +// Dielectron substructure matching mc charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using DielectronChargedJetSubstructureMatchingMC = JetSubstructureMatching, + soa::Join, + aod::DielectronChargedMCDetectorLevelSPsMatchedToDielectronChargedMCParticleLevelSPs, + aod::DielectronChargedMCParticleLevelSPsMatchedToDielectronChargedMCDetectorLevelSPs, + aod::DielectronChargedMCDetectorLevelPRsMatchedToDielectronChargedMCParticleLevelPRs, + aod::DielectronChargedMCParticleLevelPRsMatchedToDielectronChargedMCDetectorLevelPRs, + aod::DielectronChargedMCDetectorLevelSPs, + aod::DielectronChargedMCParticleLevelSPs, + aod::DielectronChargedMCDetectorLevelPRs, + aod::DielectronChargedMCParticleLevelPRs, + aod::CandidatesDielectronMCD, + aod::CandidatesDielectronMCP, + aod::JetTracksMCD, + aod::JetParticles, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-mc-dielectron-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCDplusCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCDplusCharged.cxx new file mode 100644 index 00000000000..47ee3fb6757 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCDplusCharged.cxx @@ -0,0 +1,51 @@ +// 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. + +// Dplus substructure matching mc charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using DplusChargedJetSubstructureMatchingMC = JetSubstructureMatching, + soa::Join, + aod::DplusChargedMCDetectorLevelSPsMatchedToDplusChargedMCParticleLevelSPs, + aod::DplusChargedMCParticleLevelSPsMatchedToDplusChargedMCDetectorLevelSPs, + aod::DplusChargedMCDetectorLevelPRsMatchedToDplusChargedMCParticleLevelPRs, + aod::DplusChargedMCParticleLevelPRsMatchedToDplusChargedMCDetectorLevelPRs, + aod::DplusChargedMCDetectorLevelSPs, + aod::DplusChargedMCParticleLevelSPs, + aod::DplusChargedMCDetectorLevelPRs, + aod::DplusChargedMCParticleLevelPRs, + aod::CandidatesDplusMCD, + aod::CandidatesDplusMCP, + aod::JetTracksMCD, + aod::JetParticles, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-mc-dplus-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCDstarCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCDstarCharged.cxx new file mode 100644 index 00000000000..9cff34b1ce7 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCDstarCharged.cxx @@ -0,0 +1,51 @@ +// 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. + +// D* substructure matching mc charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using DstarChargedJetSubstructureMatchingMC = JetSubstructureMatching, + soa::Join, + aod::DstarChargedMCDetectorLevelSPsMatchedToDstarChargedMCParticleLevelSPs, + aod::DstarChargedMCParticleLevelSPsMatchedToDstarChargedMCDetectorLevelSPs, + aod::DstarChargedMCDetectorLevelPRsMatchedToDstarChargedMCParticleLevelPRs, + aod::DstarChargedMCParticleLevelPRsMatchedToDstarChargedMCDetectorLevelPRs, + aod::DstarChargedMCDetectorLevelSPs, + aod::DstarChargedMCParticleLevelSPs, + aod::DstarChargedMCDetectorLevelPRs, + aod::DstarChargedMCParticleLevelPRs, + aod::CandidatesDstarMCD, + aod::CandidatesDstarMCP, + aod::JetTracksMCD, + aod::JetParticles, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-mc-dstar-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCLcCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCLcCharged.cxx new file mode 100644 index 00000000000..1744d6b24fe --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingMCLcCharged.cxx @@ -0,0 +1,51 @@ +// 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. + +// Lc substructure matching mc charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatching.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using LcChargedJetSubstructureMatchingMC = JetSubstructureMatching, + soa::Join, + aod::LcChargedMCDetectorLevelSPsMatchedToLcChargedMCParticleLevelSPs, + aod::LcChargedMCParticleLevelSPsMatchedToLcChargedMCDetectorLevelSPs, + aod::LcChargedMCDetectorLevelPRsMatchedToLcChargedMCParticleLevelPRs, + aod::LcChargedMCParticleLevelPRsMatchedToLcChargedMCDetectorLevelPRs, + aod::LcChargedMCDetectorLevelSPs, + aod::LcChargedMCParticleLevelSPs, + aod::LcChargedMCDetectorLevelPRs, + aod::LcChargedMCParticleLevelPRs, + aod::CandidatesLcMCD, + aod::CandidatesLcMCP, + aod::JetTracksMCD, + aod::JetParticles, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-mc-lc-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx new file mode 100644 index 00000000000..179a4b96b05 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx @@ -0,0 +1,274 @@ +// 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. + +// jet analysis tasks (subscribing to jet finder task) +// this file should be removed once we can pass coloumns as templates!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +// +/// \author Nima Zardoshti +// + +#include "PWGJE/Core/JetMatchingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include "Framework/ASoA.h" +#include +#include +#include +#include // IWYU pragma: export + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +template +struct JetSubstructureMatchingSub { + + Produces splittingsBasetoTagMatchingTable; + Produces splittingsTagtoBaseMatchingTable; + + Produces pairsBasetoTagMatchingTable; + Produces pairsTagtoBaseMatchingTable; + + Configurable doMatchingGeo{"doMatchingGeo", true, "Enable geometric matching"}; + Configurable doMatchingPt{"doMatchingPt", true, "Enable pt matching"}; + Configurable doMatchingHf{"doMatchingHf", false, "Enable HF matching"}; + Configurable maxMatchingDistance{"maxMatchingDistance", 0.24f, "Max matching distance"}; + Configurable minPtFraction{"minPtFraction", 0.5f, "Minimum pt fraction for pt matching"}; + Configurable requireGeoMatchedJets{"requireGeoMatchedJets", false, "require jets are geo matched as well"}; + Configurable requirePtMatchedJets{"requirePtMatchedJets", false, "require jets are pT matched as well"}; + Configurable requireHFMatchedJets{"requireHFMatchedJets", false, "require jets are HF matched as well"}; + + static constexpr bool jetsBaseIsMc = o2::soa::relatedByIndex(); + static constexpr bool jetsTagIsMc = o2::soa::relatedByIndex(); + + void init(InitContext const&) + { + } + + PresliceOptional BaseSplittingsPerBaseJetInclusive = aod::chargedsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetInclusive = aod::chargedeventwisesubtractedsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetD0 = aod::d0chargedsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetD0 = aod::d0chargedeventwisesubtractedsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetDplus = aod::dpluschargedsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetDplus = aod::dpluschargedeventwisesubtractedsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetDstar = aod::dstarchargedsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetDstar = aod::dstarchargedeventwisesubtractedsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetLc = aod::lcchargedsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetLc = aod::lcchargedeventwisesubtractedsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetB0 = aod::b0chargedsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetB0 = aod::b0chargedeventwisesubtractedsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetBplus = aod::bpluschargedsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetBplus = aod::bpluschargedeventwisesubtractedsplitting::jetId; + PresliceOptional BaseSplittingsPerBaseJetDielectron = aod::dielectronchargedsplitting::jetId; + PresliceOptional TagSplittingsPerTagJetDielectron = aod::dielectronchargedeventwisesubtractedsplitting::jetId; + + PresliceOptional BasePairsPerBaseJetInclusive = aod::chargedpair::jetId; + PresliceOptional TagPairsPerTagJetInclusive = aod::chargedeventwisesubtractedpair::jetId; + PresliceOptional BasePairsPerBaseJetD0 = aod::d0chargedpair::jetId; + PresliceOptional TagPairsPerTagJetD0 = aod::d0chargedeventwisesubtractedpair::jetId; + PresliceOptional BasePairsPerBaseJetDplus = aod::dpluschargedpair::jetId; + PresliceOptional TagPairsPerTagJetDplus = aod::dpluschargedeventwisesubtractedpair::jetId; + PresliceOptional BasePairsPerBaseJetDstar = aod::dstarchargedpair::jetId; + PresliceOptional TagPairsPerTagJetDstar = aod::dstarchargedeventwisesubtractedpair::jetId; + PresliceOptional BasePairsPerBaseJetLc = aod::lcchargedpair::jetId; + PresliceOptional TagPairsPerTagJetLc = aod::lcchargedeventwisesubtractedpair::jetId; + PresliceOptional BasePairsPerBaseJetBplus = aod::bpluschargedpair::jetId; + PresliceOptional TagPairsPerTagJetBplus = aod::bpluschargedeventwisesubtractedpair::jetId; + PresliceOptional BasePairsPerBaseJetB0 = aod::b0chargedpair::jetId; + PresliceOptional TagPairsPerTagJetB0 = aod::b0chargedeventwisesubtractedpair::jetId; + PresliceOptional BasePairsPerBaseJetDielectron = aod::dielectronchargedpair::jetId; + PresliceOptional TagPairsPerTagJetDielectron = aod::dielectronchargedeventwisesubtractedpair::jetId; + + // workaround till binding nodes can be passed as template arguments + template + auto slicedPerJetForMatching(T const& table, U const& jet, V const& perIncluisveJet, M const& perD0Jet, N const& perDplusJet, O const& perDstarJet, P const& perLcJet, Q const& perB0Jet, R const& perBplusJet, S const& perDielectronJet) + { + if constexpr (jethfutilities::isHFTable() || jethfutilities::isHFMcTable()) { + return jethfutilities::slicedPerHFJet(table, jet, perD0Jet, perDplusJet, perDstarJet, perLcJet, perB0Jet, perBplusJet); + } else if constexpr (jetdqutilities::isDielectronTable() || jetdqutilities::isDielectronMcTable()) { + return jetdqutilities::slicedPerDielectronJet(table, jet, perDielectronJet); + } else { + return table.sliceBy(perIncluisveJet, jet.globalIndex()); + } + } + + template + auto defaultMatchedJets(T const& jetTag) + { + if constexpr (jetcandidateutilities::isCandidateTable()) { + return jetTag.template matchedJetCand_as(); + } else { + return jetTag.template matchedJetGeo_as(); + } + } + + void processData(JetsTag const& jetsTag, + JetsBase const&, + SplittingsBase const& jetsBaseSplittings, + SplittingsTag const& jetsTagSplittings, + PairsBase const& jetsBasePairs, + PairsTag const& jetsTagPairs, + Candidates const& candidates, + ClustersBase const& clustersBase, + TracksBase const& tracksBase, TracksTag const& tracksTag) + { + + std::vector> jetsBasetoTagSplittingsMatchingGeo, jetsBasetoTagSplittingsMatchingPt, jetsBasetoTagSplittingsMatchingHF; + jetsBasetoTagSplittingsMatchingGeo.assign(jetsBaseSplittings.size(), {}); + jetsBasetoTagSplittingsMatchingPt.assign(jetsBaseSplittings.size(), {}); + jetsBasetoTagSplittingsMatchingHF.assign(jetsBaseSplittings.size(), {}); + + std::vector> jetsTagtoBaseSplittingsMatchingGeo, jetsTagtoBaseSplittingsMatchingPt, jetsTagtoBaseSplittingsMatchingHF; + jetsTagtoBaseSplittingsMatchingGeo.assign(jetsTagSplittings.size(), {}); + jetsTagtoBaseSplittingsMatchingPt.assign(jetsTagSplittings.size(), {}); + jetsTagtoBaseSplittingsMatchingHF.assign(jetsTagSplittings.size(), {}); + + std::vector jetTagSplittingsMap; + std::vector jetBaseSplittingsMap; + jetTagSplittingsMap.resize(jetsTagSplittings.size(), -1); + jetBaseSplittingsMap.resize(jetsBaseSplittings.size(), -1); + + std::vector> jetsBasetoTagPairsMatching; + std::vector> jetsTagtoBasePairsMatching; + jetsBasetoTagPairsMatching.assign(jetsBasePairs.size(), {}); + jetsTagtoBasePairsMatching.assign(jetsTagPairs.size(), {}); + + std::vector jetTagPairsMap; + std::vector jetBasePairsMap; + jetTagPairsMap.resize(jetsTagPairs.size(), -1); + jetBasePairsMap.resize(jetsBasePairs.size(), -1); + + for (auto jetTag : jetsTag) { + bool hasMatchedJet = false; + if constexpr (jetcandidateutilities::isCandidateTable()) { + hasMatchedJet = jetTag.has_matchedJetCand(); + } else { + hasMatchedJet = jetTag.has_matchedJetGeo(); + } + if (hasMatchedJet) { + // auto const& jetTagSplittings = jetsTagSplittings.sliceBy(TagSplittingsPerTagJet, jetTag.globalIndex()); + auto const& jetTagSplittings = slicedPerJetForMatching(jetsTagSplittings, jetTag, TagSplittingsPerTagJetInclusive, TagSplittingsPerTagJetD0, TagSplittingsPerTagJetDplus, TagSplittingsPerTagJetDstar, TagSplittingsPerTagJetLc, TagSplittingsPerTagJetB0, TagSplittingsPerTagJetBplus, TagSplittingsPerTagJetDielectron); + int tagSplittingIndex = 0; + for (auto const& jetTagSplitting : jetTagSplittings) { + jetTagSplittingsMap[jetTagSplitting.globalIndex()] = tagSplittingIndex; + tagSplittingIndex++; + } + // auto const& jetTagPairs = jetsTagPairs.sliceBy(TagPairsPerTagJet, jetTag.globalIndex()); + auto const& jetTagPairs = slicedPerJetForMatching(jetsTagPairs, jetTag, TagPairsPerTagJetInclusive, TagPairsPerTagJetD0, TagPairsPerTagJetDplus, TagPairsPerTagJetDstar, TagPairsPerTagJetLc, TagPairsPerTagJetB0, TagPairsPerTagJetBplus, TagPairsPerTagJetDielectron); + int tagPairIndex = 0; + for (auto const& jetTagPair : jetTagPairs) { + jetTagPairsMap[jetTagPair.globalIndex()] = tagPairIndex; + tagPairIndex++; + } + for (auto& jetBase : defaultMatchedJets(jetTag)) { + if (requireGeoMatchedJets) { + bool jetsMatchedWithGeo = false; + for (auto& jetBaseForMatchGeo : jetTag.template matchedJetGeo_as()) { + if (jetBaseForMatchGeo.globalIndex() == jetBase.globalIndex()) { + jetsMatchedWithGeo = true; + } + } + if (!jetsMatchedWithGeo) { + continue; + } + } + if (requirePtMatchedJets) { + bool jetsMatchedWithPt = false; + for (auto& jetBaseForMatchPt : jetTag.template matchedJetPt_as()) { + if (jetBaseForMatchPt.globalIndex() == jetBase.globalIndex()) { + jetsMatchedWithPt = true; + } + } + if (!jetsMatchedWithPt) { + continue; + } + } + if (requireHFMatchedJets) { + bool jetsMatchedWithHF = false; + for (auto& jetBaseForMatchHF : jetTag.template matchedJetCand_as()) { + if (jetBaseForMatchHF.globalIndex() == jetBase.globalIndex()) { + jetsMatchedWithHF = true; + } + } + if (!jetsMatchedWithHF) { + continue; + } + } + // auto const& jetBaseSplittings = jetsBaseSplittings.sliceBy(BaseSplittingsPerBaseJet, jetBase.globalIndex()); + auto const& jetBaseSplittings = slicedPerJetForMatching(jetsBaseSplittings, jetBase, BaseSplittingsPerBaseJetInclusive, BaseSplittingsPerBaseJetD0, BaseSplittingsPerBaseJetDplus, BaseSplittingsPerBaseJetDstar, BaseSplittingsPerBaseJetLc, BaseSplittingsPerBaseJetB0, BaseSplittingsPerBaseJetBplus, BaseSplittingsPerBaseJetDielectron); + int baseSplittingIndex = 0; + for (auto const& jetBaseSplitting : jetBaseSplittings) { + jetBaseSplittingsMap[jetBaseSplitting.globalIndex()] = baseSplittingIndex; + baseSplittingIndex++; + } + jetmatchingutilities::doAllMatching(jetBaseSplittings, jetTagSplittings, jetsBasetoTagSplittingsMatchingGeo, jetsBasetoTagSplittingsMatchingPt, jetsBasetoTagSplittingsMatchingHF, jetsTagtoBaseSplittingsMatchingGeo, jetsTagtoBaseSplittingsMatchingPt, jetsTagtoBaseSplittingsMatchingHF, candidates, tracksBase, clustersBase, candidates, tracksTag, tracksTag, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); + // auto const& jetBasePairs = jetsBasePairs.sliceBy(BasePairsPerBaseJet, jetBase.globalIndex()); + auto const& jetBasePairs = slicedPerJetForMatching(jetsBasePairs, jetBase, BasePairsPerBaseJetInclusive, BasePairsPerBaseJetD0, BasePairsPerBaseJetDplus, BasePairsPerBaseJetDstar, BasePairsPerBaseJetLc, BasePairsPerBaseJetB0, BasePairsPerBaseJetBplus, BasePairsPerBaseJetDielectron); + int basePairIndex = 0; + for (auto const& jetBasePair : jetBasePairs) { + jetBasePairsMap[jetBasePair.globalIndex()] = basePairIndex; + basePairIndex++; + } + jetmatchingutilities::doPairMatching(jetBasePairs, jetTagPairs, jetsBasetoTagPairsMatching, jetsTagtoBasePairsMatching, candidates, tracksBase, candidates, tracksTag); + } + } + } + + for (auto jetsTagSplitting : jetsTagSplittings) { + std::vector tagToBaseMatchingGeoIndex; + std::vector tagToBaseMatchingPtIndex; + std::vector tagToBaseMatchingHFIndex; + for (auto jetBaseSplittingIndex : jetsTagtoBaseSplittingsMatchingGeo[jetsTagSplitting.globalIndex()]) { + tagToBaseMatchingGeoIndex.push_back(jetBaseSplittingsMap[jetBaseSplittingIndex]); + } + for (auto jetBaseSplittingIndex : jetsTagtoBaseSplittingsMatchingPt[jetsTagSplitting.globalIndex()]) { + tagToBaseMatchingPtIndex.push_back(jetBaseSplittingsMap[jetBaseSplittingIndex]); + } + for (auto jetBaseSplittingIndex : jetsTagtoBaseSplittingsMatchingHF[jetsTagSplitting.globalIndex()]) { + tagToBaseMatchingHFIndex.push_back(jetBaseSplittingsMap[jetBaseSplittingIndex]); + } + splittingsTagtoBaseMatchingTable(tagToBaseMatchingGeoIndex, tagToBaseMatchingPtIndex, tagToBaseMatchingHFIndex); + } + for (auto jetsBaseSplitting : jetsBaseSplittings) { + std::vector baseToTagMatchingGeoIndex; + std::vector baseToTagMatchingPtIndex; + std::vector baseToTagMatchingHFIndex; + for (auto jetTagSplittingIndex : jetsBasetoTagSplittingsMatchingGeo[jetsBaseSplitting.globalIndex()]) { + baseToTagMatchingGeoIndex.push_back(jetTagSplittingsMap[jetTagSplittingIndex]); + } + for (auto jetTagSplittingIndex : jetsBasetoTagSplittingsMatchingPt[jetsBaseSplitting.globalIndex()]) { + baseToTagMatchingPtIndex.push_back(jetTagSplittingsMap[jetTagSplittingIndex]); + } + for (auto jetTagSplittingIndex : jetsBasetoTagSplittingsMatchingHF[jetsBaseSplitting.globalIndex()]) { + baseToTagMatchingHFIndex.push_back(jetTagSplittingsMap[jetTagSplittingIndex]); + } + splittingsBasetoTagMatchingTable(baseToTagMatchingGeoIndex, baseToTagMatchingPtIndex, baseToTagMatchingHFIndex); + } + for (auto jetsTagPair : jetsTagPairs) { + std::vector tagToBaseMatchingIndex; + for (auto jetBasePairIndex : jetsTagtoBasePairsMatching[jetsTagPair.globalIndex()]) { + tagToBaseMatchingIndex.push_back(jetBasePairsMap[jetBasePairIndex]); + } + pairsTagtoBaseMatchingTable(tagToBaseMatchingIndex); + } + for (auto jetsBasePair : jetsBasePairs) { + std::vector baseToTagMatchingIndex; + for (auto jetTagPairIndex : jetsBasetoTagPairsMatching[jetsBasePair.globalIndex()]) { + baseToTagMatchingIndex.push_back(jetTagPairsMap[jetTagPairIndex]); + } + pairsBasetoTagMatchingTable(baseToTagMatchingIndex); + } + } + PROCESS_SWITCH(JetSubstructureMatchingSub, processData, "charged jet substructure", true); +}; diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubB0Charged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubB0Charged.cxx new file mode 100644 index 00000000000..3ed89997f58 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubB0Charged.cxx @@ -0,0 +1,50 @@ +// 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. + +// substructure matching event-wise subtracted B0 charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using B0ChargedJetSubstructureMatchingSub = JetSubstructureMatchingSub, + soa::Join, + aod::B0ChargedSPsMatchedToB0ChargedEventWiseSubtractedSPs, + aod::B0ChargedEventWiseSubtractedSPsMatchedToB0ChargedSPs, + aod::B0ChargedPRsMatchedToB0ChargedEventWiseSubtractedPRs, + aod::B0ChargedEventWiseSubtractedPRsMatchedToB0ChargedPRs, + aod::B0ChargedSPs, + aod::B0ChargedEventWiseSubtractedSPs, + aod::B0ChargedPRs, + aod::B0ChargedEventWiseSubtractedPRs, + aod::CandidatesB0Data, + aod::JetTracks, + aod::JetTracksSubB0, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-sub-b0-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubBplusCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubBplusCharged.cxx new file mode 100644 index 00000000000..fd7fecd0264 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubBplusCharged.cxx @@ -0,0 +1,50 @@ +// 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. + +// substructure matching event-wise subtracted Bplus charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using BplusChargedJetSubstructureMatchingSub = JetSubstructureMatchingSub, + soa::Join, + aod::BplusChargedSPsMatchedToBplusChargedEventWiseSubtractedSPs, + aod::BplusChargedEventWiseSubtractedSPsMatchedToBplusChargedSPs, + aod::BplusChargedPRsMatchedToBplusChargedEventWiseSubtractedPRs, + aod::BplusChargedEventWiseSubtractedPRsMatchedToBplusChargedPRs, + aod::BplusChargedSPs, + aod::BplusChargedEventWiseSubtractedSPs, + aod::BplusChargedPRs, + aod::BplusChargedEventWiseSubtractedPRs, + aod::CandidatesBplusData, + aod::JetTracks, + aod::JetTracksSubBplus, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-sub-bplus-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubCharged.cxx new file mode 100644 index 00000000000..60fe610ad61 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubCharged.cxx @@ -0,0 +1,50 @@ +// 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. + +// substructure matching event-wise subtracted charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using ChargedJetSubstructureMatchingSub = JetSubstructureMatchingSub, + soa::Join, + aod::ChargedSPsMatchedToChargedEventWiseSubtractedSPs, + aod::ChargedEventWiseSubtractedSPsMatchedToChargedSPs, + aod::ChargedPRsMatchedToChargedEventWiseSubtractedPRs, + aod::ChargedEventWiseSubtractedPRsMatchedToChargedPRs, + aod::ChargedSPs, + aod::ChargedEventWiseSubtractedSPs, + aod::ChargedPRs, + aod::ChargedEventWiseSubtractedPRs, + aod::JCollisions, + aod::JetTracks, + aod::JetTracksSub, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-sub-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubD0Charged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubD0Charged.cxx new file mode 100644 index 00000000000..45e2bcb3ef2 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubD0Charged.cxx @@ -0,0 +1,50 @@ +// 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. + +// substructure matching event-wise subtracted D0 charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using D0ChargedJetSubstructureMatchingSub = JetSubstructureMatchingSub, + soa::Join, + aod::D0ChargedSPsMatchedToD0ChargedEventWiseSubtractedSPs, + aod::D0ChargedEventWiseSubtractedSPsMatchedToD0ChargedSPs, + aod::D0ChargedPRsMatchedToD0ChargedEventWiseSubtractedPRs, + aod::D0ChargedEventWiseSubtractedPRsMatchedToD0ChargedPRs, + aod::D0ChargedSPs, + aod::D0ChargedEventWiseSubtractedSPs, + aod::D0ChargedPRs, + aod::D0ChargedEventWiseSubtractedPRs, + aod::CandidatesD0Data, + aod::JetTracks, + aod::JetTracksSubD0, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-sub-d0-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubDielectronCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubDielectronCharged.cxx new file mode 100644 index 00000000000..d9f748252f5 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubDielectronCharged.cxx @@ -0,0 +1,50 @@ +// 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. + +// substructure matching event-wise subtracted Dielectron charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using DielectronChargedJetSubstructureMatchingSub = JetSubstructureMatchingSub, + soa::Join, + aod::DielectronChargedSPsMatchedToDielectronChargedEventWiseSubtractedSPs, + aod::DielectronChargedEventWiseSubtractedSPsMatchedToDielectronChargedSPs, + aod::DielectronChargedPRsMatchedToDielectronChargedEventWiseSubtractedPRs, + aod::DielectronChargedEventWiseSubtractedPRsMatchedToDielectronChargedPRs, + aod::DielectronChargedSPs, + aod::DielectronChargedEventWiseSubtractedSPs, + aod::DielectronChargedPRs, + aod::DielectronChargedEventWiseSubtractedPRs, + aod::CandidatesDielectronData, + aod::JetTracks, + aod::JetTracksSubDielectron, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-sub-dielectron-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubDplusCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubDplusCharged.cxx new file mode 100644 index 00000000000..9d07e6a3bde --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubDplusCharged.cxx @@ -0,0 +1,50 @@ +// 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. + +// substructure matching event-wise subtracted Dplus charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using DplusChargedJetSubstructureMatchingSub = JetSubstructureMatchingSub, + soa::Join, + aod::DplusChargedSPsMatchedToDplusChargedEventWiseSubtractedSPs, + aod::DplusChargedEventWiseSubtractedSPsMatchedToDplusChargedSPs, + aod::DplusChargedPRsMatchedToDplusChargedEventWiseSubtractedPRs, + aod::DplusChargedEventWiseSubtractedPRsMatchedToDplusChargedPRs, + aod::DplusChargedSPs, + aod::DplusChargedEventWiseSubtractedSPs, + aod::DplusChargedPRs, + aod::DplusChargedEventWiseSubtractedPRs, + aod::CandidatesDplusData, + aod::JetTracks, + aod::JetTracksSubDplus, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-sub-dplus-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubDstarCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubDstarCharged.cxx new file mode 100644 index 00000000000..c301149c647 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubDstarCharged.cxx @@ -0,0 +1,50 @@ +// 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. + +// substructure matching event-wise subtracted D* charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using DstarChargedJetSubstructureMatchingSub = JetSubstructureMatchingSub, + soa::Join, + aod::DstarChargedSPsMatchedToDstarChargedEventWiseSubtractedSPs, + aod::DstarChargedEventWiseSubtractedSPsMatchedToDstarChargedSPs, + aod::DstarChargedPRsMatchedToDstarChargedEventWiseSubtractedPRs, + aod::DstarChargedEventWiseSubtractedPRsMatchedToDstarChargedPRs, + aod::DstarChargedSPs, + aod::DstarChargedEventWiseSubtractedSPs, + aod::DstarChargedPRs, + aod::DstarChargedEventWiseSubtractedPRs, + aod::CandidatesDstarData, + aod::JetTracks, + aod::JetTracksSubDstar, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-sub-dstar-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubLcCharged.cxx b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubLcCharged.cxx new file mode 100644 index 00000000000..59f994282a1 --- /dev/null +++ b/PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSubLcCharged.cxx @@ -0,0 +1,50 @@ +// 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. + +// substructure matching event-wise subtracted Lc charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/Substructure/jetSubstructureMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include +#include +#include +#include +#include + +#include + +using LcChargedJetSubstructureMatchingSub = JetSubstructureMatchingSub, + soa::Join, + aod::LcChargedSPsMatchedToLcChargedEventWiseSubtractedSPs, + aod::LcChargedEventWiseSubtractedSPsMatchedToLcChargedSPs, + aod::LcChargedPRsMatchedToLcChargedEventWiseSubtractedPRs, + aod::LcChargedEventWiseSubtractedPRsMatchedToLcChargedPRs, + aod::LcChargedSPs, + aod::LcChargedEventWiseSubtractedSPs, + aod::LcChargedPRs, + aod::LcChargedEventWiseSubtractedPRs, + aod::CandidatesLcData, + aod::JetTracks, + aod::JetTracksSubLc, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-substructure-matching-sub-lc-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingMC.cxx b/PWGJE/TableProducer/Matching/jetMatchingMC.cxx index ef56702af09..5faba83064e 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMC.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMC.cxx @@ -17,20 +17,16 @@ /// \author Aimeric Lanodu /// \author Nima Zardoshti -#include +#include "PWGJE/Core/JetMatchingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/Core/JetMatchingUtilities.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include using namespace o2; using namespace o2::framework; @@ -69,7 +65,6 @@ struct JetMatchingMc { CandidatesBase const& candidatesBase, CandidatesTag const& candidatesTag) { - // initialise objects used to store the matching index arrays (array in case a mcCollision is split) before filling the matching tables std::vector> jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF; std::vector> jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF; @@ -90,7 +85,7 @@ struct JetMatchingMc { const auto jetsBasePerColl = jetsBase.sliceBy(baseJetsPerCollision, jetsBaseIsMc ? mcCollision.globalIndex() : collision.globalIndex()); const auto jetsTagPerColl = jetsTag.sliceBy(tagJetsPerCollision, jetsTagIsMc ? mcCollision.globalIndex() : collision.globalIndex()); - jetmatchingutilities::doAllMatching(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidatesBase, candidatesTag, tracks, clusters, particles, particles, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); + jetmatchingutilities::doAllMatching(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidatesBase, tracks, clusters, candidatesTag, particles, particles, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); } } for (auto i = 0; i < jetsBase.size(); ++i) { diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCB0Charged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCB0Charged.cxx new file mode 100644 index 00000000000..27205e0c854 --- /dev/null +++ b/PWGJE/TableProducer/Matching/jetMatchingMCB0Charged.cxx @@ -0,0 +1,42 @@ +// 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. + +// jet matching mc B0 charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + +using B0ChargedJetMatchingMC = JetMatchingMc, + soa::Join, + aod::B0ChargedMCDetectorLevelJetsMatchedToB0ChargedMCParticleLevelJets, + aod::B0ChargedMCParticleLevelJetsMatchedToB0ChargedMCDetectorLevelJets, + aod::CandidatesB0MCD, + aod::CandidatesB0MCP, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-matching-mc-b0-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCBplusCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCBplusCharged.cxx index 8a5705f273f..e9066924fcc 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCBplusCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCBplusCharged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using BplusChargedJetMatchingMC = JetMatchingMc, soa::Join, aod::BplusChargedMCDetectorLevelJetsMatchedToBplusChargedMCParticleLevelJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCCharged.cxx index fe951be4566..da8a956efc6 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCCharged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using ChargedJetMatchingMC = JetMatchingMc, soa::Join, aod::ChargedMCDetectorLevelJetsMatchedToChargedMCParticleLevelJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCD0Charged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCD0Charged.cxx index 64abc51c79d..a56a9f21ff5 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCD0Charged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCD0Charged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using D0ChargedJetMatchingMC = JetMatchingMc, soa::Join, aod::D0ChargedMCDetectorLevelJetsMatchedToD0ChargedMCParticleLevelJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCDielectronCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCDielectronCharged.cxx index 7d284ecbee4..740c30d5f8b 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCDielectronCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCDielectronCharged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using DielectronChargedJetMatchingMC = JetMatchingMc, soa::Join, aod::DielectronChargedMCDetectorLevelJetsMatchedToDielectronChargedMCParticleLevelJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCDplusCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCDplusCharged.cxx new file mode 100644 index 00000000000..7032c3a42e9 --- /dev/null +++ b/PWGJE/TableProducer/Matching/jetMatchingMCDplusCharged.cxx @@ -0,0 +1,42 @@ +// 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. + +// jet matching mc D+ charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + +using DplusChargedJetMatchingMC = JetMatchingMc, + soa::Join, + aod::DplusChargedMCDetectorLevelJetsMatchedToDplusChargedMCParticleLevelJets, + aod::DplusChargedMCParticleLevelJetsMatchedToDplusChargedMCDetectorLevelJets, + aod::CandidatesDplusMCD, + aod::CandidatesDplusMCP, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-matching-mc-dplus-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCDstarCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCDstarCharged.cxx new file mode 100644 index 00000000000..8eca5d1908e --- /dev/null +++ b/PWGJE/TableProducer/Matching/jetMatchingMCDstarCharged.cxx @@ -0,0 +1,42 @@ +// 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. + +// jet matching mc D* charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + +using DstarChargedJetMatchingMC = JetMatchingMc, + soa::Join, + aod::DstarChargedMCDetectorLevelJetsMatchedToDstarChargedMCParticleLevelJets, + aod::DstarChargedMCParticleLevelJetsMatchedToDstarChargedMCDetectorLevelJets, + aod::CandidatesDstarMCD, + aod::CandidatesDstarMCP, + aod::JDummys>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-matching-mc-dstar-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCFull.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCFull.cxx index e4bf6f3979d..a98f0c7c5bb 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCFull.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCFull.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using FullJetMatchingMC = JetMatchingMc, soa::Join, aod::FullMCDetectorLevelJetsMatchedToFullMCParticleLevelJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCLcCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCLcCharged.cxx index 9be7e169e57..ef10653f179 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCLcCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCLcCharged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using LcChargedJetMatchingMC = JetMatchingMc, soa::Join, aod::LcChargedMCDetectorLevelJetsMatchedToLcChargedMCParticleLevelJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCNeutral.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCNeutral.cxx index 8af1d2513bc..204d0f4afda 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCNeutral.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCNeutral.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using NeutralJetMatchingMC = JetMatchingMc, soa::Join, aod::NeutralMCDetectorLevelJetsMatchedToNeutralMCParticleLevelJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx index 9db070ec7b6..927298a53b5 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx @@ -13,20 +13,16 @@ /// \brief matching event-wise constituent subtracted detector level and unsubtracted generated level jets (this is usseful as a template for embedding matching) /// \author Nima Zardoshti -#include +#include "PWGJE/Core/JetMatchingUtilities.h" +#include "PWGJE/DataModel/Jet.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include +#include // IWYU pragma: export -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/Core/JetMatchingUtilities.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include using namespace o2; using namespace o2::framework; @@ -78,7 +74,7 @@ struct JetMatchingMcSub { const auto jetsBasePerColl = jetsBase.sliceBy(baseJetsPerCollision, collision.globalIndex()); const auto jetsTagPerColl = jetsTag.sliceBy(tagJetsPerCollision, collision.globalIndex()); - jetmatchingutilities::doAllMatching(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidates, candidates, tracks, tracks, tracksSub, tracksSub, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); + jetmatchingutilities::doAllMatching(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidates, tracks, tracks, candidates, tracksSub, tracksSub, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); } for (auto i = 0; i < jetsBase.size(); ++i) { diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCSubB0Charged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCSubB0Charged.cxx new file mode 100644 index 00000000000..a5de8601581 --- /dev/null +++ b/PWGJE/TableProducer/Matching/jetMatchingMCSubB0Charged.cxx @@ -0,0 +1,39 @@ +// 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. + +// jet matching mc subtracted B0 charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include +#include + +#include + +using B0ChargedJetMatchingMCSub = JetMatchingMcSub, + soa::Join, + aod::B0ChargedMCDetectorLevelJetsMatchedToB0ChargedMCDetectorLevelEventWiseSubtractedJets, + aod::B0ChargedMCDetectorLevelEventWiseSubtractedJetsMatchedToB0ChargedMCDetectorLevelJets, + aod::CandidatesB0MCD>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-matching-mc-sub-b0-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCSubBplusCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCSubBplusCharged.cxx index 86db7221aa6..38e0b9034d2 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCSubBplusCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCSubBplusCharged.cxx @@ -15,6 +15,16 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include +#include + +#include + using D0ChargedJetMatchingMCSub = JetMatchingMcSub, soa::Join, aod::D0ChargedMCDetectorLevelJetsMatchedToD0ChargedMCDetectorLevelEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCSubCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCSubCharged.cxx index 2b0c5c19992..eb19ef698f3 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCSubCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCSubCharged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using ChargedJetMatchingMCSub = JetMatchingMcSub, soa::Join, aod::ChargedMCDetectorLevelJetsMatchedToChargedMCDetectorLevelEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCSubD0Charged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCSubD0Charged.cxx index 92a71c20900..31313b99421 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCSubD0Charged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCSubD0Charged.cxx @@ -15,6 +15,16 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include +#include + +#include + using D0ChargedJetMatchingMCSub = JetMatchingMcSub, soa::Join, aod::D0ChargedMCDetectorLevelJetsMatchedToD0ChargedMCDetectorLevelEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCSubDielectronCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCSubDielectronCharged.cxx index 376e904f473..8d9082f2884 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCSubDielectronCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCSubDielectronCharged.cxx @@ -15,6 +15,16 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include +#include + +#include + using DielectronChargedJetMatchingMCSub = JetMatchingMcSub, soa::Join, aod::DielectronChargedMCDetectorLevelJetsMatchedToDielectronChargedMCDetectorLevelEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCSubDplusCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCSubDplusCharged.cxx new file mode 100644 index 00000000000..936b7b8d718 --- /dev/null +++ b/PWGJE/TableProducer/Matching/jetMatchingMCSubDplusCharged.cxx @@ -0,0 +1,39 @@ +// 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. + +// jet matching mc subtracted D+ charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include +#include + +#include + +using DplusChargedJetMatchingMCSub = JetMatchingMcSub, + soa::Join, + aod::DplusChargedMCDetectorLevelJetsMatchedToDplusChargedMCDetectorLevelEventWiseSubtractedJets, + aod::DplusChargedMCDetectorLevelEventWiseSubtractedJetsMatchedToDplusChargedMCDetectorLevelJets, + aod::CandidatesDplusMCD>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-matching-mc-sub-dplus-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCSubDstarCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCSubDstarCharged.cxx new file mode 100644 index 00000000000..f2acd7aedd0 --- /dev/null +++ b/PWGJE/TableProducer/Matching/jetMatchingMCSubDstarCharged.cxx @@ -0,0 +1,39 @@ +// 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. + +// jet matching mc subtracted D* charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx" + +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include +#include + +#include + +using DstarChargedJetMatchingMCSub = JetMatchingMcSub, + soa::Join, + aod::DstarChargedMCDetectorLevelJetsMatchedToDstarChargedMCDetectorLevelEventWiseSubtractedJets, + aod::DstarChargedMCDetectorLevelEventWiseSubtractedJetsMatchedToDstarChargedMCDetectorLevelJets, + aod::CandidatesDstarMCD>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-matching-mc-sub-dstar-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCSubLcCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCSubLcCharged.cxx index 6a9456eb241..d645f297f9c 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCSubLcCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCSubLcCharged.cxx @@ -15,6 +15,16 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMCSub.cxx" +#include "PWGJE/DataModel/Jet.h" + +#include +#include +#include +#include +#include + +#include + using LcChargedJetMatchingMCSub = JetMatchingMcSub, soa::Join, aod::LcChargedMCDetectorLevelJetsMatchedToLcChargedMCDetectorLevelEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingMCV0Charged.cxx b/PWGJE/TableProducer/Matching/jetMatchingMCV0Charged.cxx index d0910abc488..35c569d4651 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingMCV0Charged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingMCV0Charged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingMC.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include +#include +#include +#include +#include + +#include + using V0ChargedJetMatchingMC = JetMatchingMc, soa::Join, aod::V0ChargedMCDetectorLevelJetsMatchedToV0ChargedMCParticleLevelJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingSub.cxx b/PWGJE/TableProducer/Matching/jetMatchingSub.cxx index 36e809b5129..97ac2461acd 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingSub.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingSub.cxx @@ -13,20 +13,17 @@ /// \brief matching event-wise constituent subtracted data jets and unsubtracted data jets /// \author Nima Zardoshti -#include +#include "PWGJE/Core/JetMatchingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include +#include // IWYU pragma: export -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/Core/JetMatchingUtilities.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include using namespace o2; using namespace o2::framework; @@ -76,7 +73,7 @@ struct JetMatchingSub { const auto jetsBasePerColl = jetsBase.sliceBy(baseJetsPerCollision, collision.globalIndex()); const auto jetsTagPerColl = jetsTag.sliceBy(tagJetsPerCollision, collision.globalIndex()); - jetmatchingutilities::doAllMatching(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidates, candidates, tracks, tracks, tracksSub, tracksSub, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); + jetmatchingutilities::doAllMatching(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidates, tracks, tracks, candidates, tracksSub, tracksSub, doMatchingGeo, doMatchingHf, doMatchingPt, maxMatchingDistance, minPtFraction); } for (auto i = 0; i < jetsBase.size(); ++i) { diff --git a/PWGJE/TableProducer/Matching/jetMatchingSubB0Charged.cxx b/PWGJE/TableProducer/Matching/jetMatchingSubB0Charged.cxx new file mode 100644 index 00000000000..87598cc0cc1 --- /dev/null +++ b/PWGJE/TableProducer/Matching/jetMatchingSubB0Charged.cxx @@ -0,0 +1,41 @@ +// 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. + +// jet matching subtracted B0 charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/jetMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using B0ChargedJetMatchingSub = JetMatchingSub, + soa::Join, + aod::B0ChargedJetsMatchedToB0ChargedEventWiseSubtractedJets, + aod::B0ChargedEventWiseSubtractedJetsMatchedToB0ChargedJets, + aod::JTrackB0Subs, + aod::CandidatesB0Data>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-matching-sub-b0-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingSubBplusCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingSubBplusCharged.cxx index a24b7c6de6f..bd8591a4340 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingSubBplusCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingSubBplusCharged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingSub.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + using BplusChargedJetMatchingSub = JetMatchingSub, soa::Join, aod::BplusChargedJetsMatchedToBplusChargedEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingSubCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingSubCharged.cxx index 4d12c3c0448..406345bc8c2 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingSubCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingSubCharged.cxx @@ -15,6 +15,18 @@ #include "PWGJE/TableProducer/Matching/jetMatchingSub.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + using ChargedJetMatchingSub = JetMatchingSub, soa::Join, aod::ChargedJetsMatchedToChargedEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingSubD0Charged.cxx b/PWGJE/TableProducer/Matching/jetMatchingSubD0Charged.cxx index d07f5186d95..2912f249d37 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingSubD0Charged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingSubD0Charged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingSub.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + using D0ChargedJetMatchingSub = JetMatchingSub, soa::Join, aod::D0ChargedJetsMatchedToD0ChargedEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingSubDielectronCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingSubDielectronCharged.cxx index 94960e214d8..1cdd5c20c54 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingSubDielectronCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingSubDielectronCharged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingSub.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + using DielectronChargedJetMatchingSub = JetMatchingSub, soa::Join, aod::DielectronChargedJetsMatchedToDielectronChargedEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/Matching/jetMatchingSubDplusCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingSubDplusCharged.cxx new file mode 100644 index 00000000000..533b129b598 --- /dev/null +++ b/PWGJE/TableProducer/Matching/jetMatchingSubDplusCharged.cxx @@ -0,0 +1,41 @@ +// 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. + +// jet matching subtracted D+ charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/jetMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using DplusChargedJetMatchingSub = JetMatchingSub, + soa::Join, + aod::DplusChargedJetsMatchedToDplusChargedEventWiseSubtractedJets, + aod::DplusChargedEventWiseSubtractedJetsMatchedToDplusChargedJets, + aod::JTrackDplusSubs, + aod::CandidatesDplusData>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-matching-sub-dplus-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingSubDstarCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingSubDstarCharged.cxx new file mode 100644 index 00000000000..e8d54a30ecb --- /dev/null +++ b/PWGJE/TableProducer/Matching/jetMatchingSubDstarCharged.cxx @@ -0,0 +1,41 @@ +// 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. + +// jet matching subtracted D* charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/TableProducer/Matching/jetMatchingSub.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using DstarChargedJetMatchingSub = JetMatchingSub, + soa::Join, + aod::DstarChargedJetsMatchedToDstarChargedEventWiseSubtractedJets, + aod::DstarChargedEventWiseSubtractedJetsMatchedToDstarChargedJets, + aod::JTrackDstarSubs, + aod::CandidatesDstarData>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-matching-sub-dstar-ch"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/Matching/jetMatchingSubLcCharged.cxx b/PWGJE/TableProducer/Matching/jetMatchingSubLcCharged.cxx index eabc5209fa8..72ac5bd7253 100644 --- a/PWGJE/TableProducer/Matching/jetMatchingSubLcCharged.cxx +++ b/PWGJE/TableProducer/Matching/jetMatchingSubLcCharged.cxx @@ -15,6 +15,17 @@ #include "PWGJE/TableProducer/Matching/jetMatchingSub.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + using LcChargedJetMatchingSub = JetMatchingSub, soa::Join, aod::LcChargedJetsMatchedToLcChargedEventWiseSubtractedJets, diff --git a/PWGJE/TableProducer/derivedDataProducer.cxx b/PWGJE/TableProducer/derivedDataProducer.cxx index 0167ceeed5b..045c2648acd 100644 --- a/PWGJE/TableProducer/derivedDataProducer.cxx +++ b/PWGJE/TableProducer/derivedDataProducer.cxx @@ -13,97 +13,122 @@ // /// \author Nima Zardoshti -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "TDatabasePDG.h" - -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsVertexing/PVertexer.h" -#include "ReconstructionDataFormats/Vertex.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" +#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGJE/Core/JetDQUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetV0Utilities.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/EMCALMatchedCollisions.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetReducedDataDQ.h" +#include "PWGJE/DataModel/JetReducedDataHF.h" +#include "PWGJE/DataModel/JetReducedDataV0.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/mcCentrality.h" + +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/Centrality.h" -#include "Common/Core/RecoDecay.h" #include "Common/DataModel/CollisionAssociationTables.h" -#include "PWGJE/DataModel/EMCALClusters.h" - -#include "EventFiltering/filterTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" #include "EventFiltering/Zorro.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/EMCALMatchedCollisions.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetHFUtilities.h" -#include "PWGJE/Core/JetV0Utilities.h" -#include "PWGJE/Core/JetDQUtilities.h" - -#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "CCDB/BasicCCDBManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "ReconstructionDataFormats/Vertex.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; struct JetDerivedDataProducerTask { - Produces bcCountsTable; - Produces collisionCountsTable; - Produces jDummysTable; - Produces jBCsTable; - Produces jBCParentIndexTable; - Produces jCollisionsTable; - Produces jCollisionsParentIndexTable; - Produces jCollisionsBunchCrossingIndexTable; - Produces jCollisionsEMCalLabelTable; - Produces jMcCollisionsLabelTable; - Produces jMcCollisionsTable; - Produces jMcCollisionsParentIndexTable; - Produces jTracksTable; - Produces jTracksExtraTable; - Produces jTracksEMCalTable; - Produces jTracksParentIndexTable; - Produces jMcTracksLabelTable; - Produces jMcParticlesTable; - Produces jParticlesParentIndexTable; - Produces jClustersTable; - Produces jClustersParentIndexTable; - Produces jClustersMatchedTracksTable; - Produces jMcClustersLabelTable; - Produces jD0CollisionIdsTable; - Produces jD0McCollisionIdsTable; - Produces jD0IdsTable; - Produces jD0ParticleIdsTable; - Produces jLcCollisionIdsTable; - Produces jLcMcCollisionIdsTable; - Produces jLcIdsTable; - Produces jLcParticleIdsTable; - Produces jBplusCollisionIdsTable; - Produces jBplusMcCollisionIdsTable; - Produces jBplusIdsTable; - Produces jBplusParticleIdsTable; - Produces jV0IdsTable; - Produces jV0McCollisionsTable; - Produces jV0McCollisionIdsTable; - Produces jV0McsTable; - Produces jV0McIdsTable; - Produces jDielectronCollisionIdsTable; - Produces jDielectronIdsTable; - Produces jDielectronMcCollisionsTable; - Produces jDielectronMcCollisionIdsTable; - Produces jDielectronMcsTable; - Produces jDielectronMcIdsTable; + struct : ProducesGroup { + Produces bcCountsTable; + Produces collisionCountsTable; + Produces jDummysTable; + Produces jBCsTable; + Produces jBCParentIndexTable; + Produces jCollisionsTable; + Produces jCollisionMcInfosTable; + Produces jCollisionsParentIndexTable; + Produces jCollisionsBunchCrossingIndexTable; + Produces jCollisionsEMCalLabelTable; + Produces jMcCollisionsLabelTable; + Produces jMcCollisionsTable; + Produces jMcCollisionsParentIndexTable; + Produces jTracksTable; + Produces jTracksExtraTable; + Produces jTracksEMCalTable; + Produces jTracksParentIndexTable; + Produces jMcTracksLabelTable; + Produces jMcParticlesTable; + Produces jParticlesParentIndexTable; + Produces jClustersTable; + Produces jClustersParentIndexTable; + Produces jClustersMatchedTracksTable; + Produces jMcClustersLabelTable; + Produces jD0CollisionIdsTable; + Produces jD0McCollisionIdsTable; + Produces jD0IdsTable; + Produces jD0ParticleIdsTable; + Produces jDplusCollisionIdsTable; + Produces jDplusMcCollisionIdsTable; + Produces jDplusIdsTable; + Produces jDplusParticleIdsTable; + Produces jDstarCollisionIdsTable; + Produces jDstarMcCollisionIdsTable; + Produces jDstarIdsTable; + Produces jDstarParticleIdsTable; + Produces jLcCollisionIdsTable; + Produces jLcMcCollisionIdsTable; + Produces jLcIdsTable; + Produces jLcParticleIdsTable; + Produces jB0CollisionIdsTable; + Produces jB0McCollisionIdsTable; + Produces jB0IdsTable; + Produces jB0ParticleIdsTable; + Produces jBplusCollisionIdsTable; + Produces jBplusMcCollisionIdsTable; + Produces jBplusIdsTable; + Produces jBplusParticleIdsTable; + Produces jV0IdsTable; + Produces jV0McCollisionsTable; + Produces jV0McCollisionIdsTable; + Produces jV0McsTable; + Produces jV0McIdsTable; + Produces jDielectronCollisionIdsTable; + Produces jDielectronIdsTable; + Produces jDielectronMcCollisionsTable; + Produces jDielectronMcCollisionIdsTable; + Produces JDielectronMcRCollDummysTable; + Produces jDielectronMcsTable; + Produces jDielectronMcIdsTable; + } products; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable ccdbPathLut{"ccdbPathLut", "GLO/Param/MatLUT", "Path for LUT parametrization"}; @@ -113,6 +138,7 @@ struct JetDerivedDataProducerTask { Configurable ccdbURL{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable includeTriggers{"includeTriggers", false, "fill the collision information with software trigger decisions"}; + Configurable includeHadronicRate{"includeHadronicRate", true, "fill the collision information with the hadronic rate"}; Preslice perClusterCells = aod::emcalclustercell::emcalclusterId; Preslice perClusterTracks = aod::emcalclustercell::emcalclusterId; @@ -125,11 +151,14 @@ struct JetDerivedDataProducerTask { Service pdgDatabase; Zorro triggerDecider; + ctpRateFetcher rateFetcher; int runNumber; + float hadronicRate; bool withCollisionAssociator; void init(InitContext const&) { - if (doprocessTracksWithCollisionAssociator || includeTriggers) { + hadronicRate = -1.0; + if (doprocessTracksWithCollisionAssociator || includeHadronicRate || includeTriggers) { ccdb->setURL(ccdbUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); @@ -143,30 +172,41 @@ struct JetDerivedDataProducerTask { } } - void processClearMaps(aod::Collisions const&) + void processClearMaps(aod::Collisions const& collisions) { trackCollisionMapping.clear(); + if (!doprocessMcCollisionLabels) { + for (int i = 0; i < collisions.size(); i++) { + products.jCollisionMcInfosTable(-1.0, jetderiveddatautilities::JCollisionSubGeneratorId::none); // fill a dummy weights table if not MC + } + } } PROCESS_SWITCH(JetDerivedDataProducerTask, processClearMaps, "clears all maps", true); void processBunchCrossings(soa::Join::iterator const& bc) { - jBCsTable(bc.runNumber(), bc.globalBC(), bc.timestamp(), bc.alias_raw(), bc.selection_raw()); - jBCParentIndexTable(bc.globalIndex()); + products.jBCsTable(bc.runNumber(), bc.globalBC(), bc.timestamp(), bc.alias_raw(), bc.selection_raw()); + products.jBCParentIndexTable(bc.globalIndex()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processBunchCrossings, "produces derived bunch crossing table", false); - void processCollisions(soa::Join::iterator const& collision, soa::Join const&) + void processCollisions(soa::Join::iterator const& collision, soa::Join const&) { + auto bc = collision.bc_as>(); + if (includeHadronicRate) { + if (runNumber != bc.runNumber()) { + runNumber = bc.runNumber(); + hadronicRate = rateFetcher.fetch(ccdb.service, bc.timestamp(), runNumber, "ZNC hadronic") * 0.001; + } + } uint64_t triggerBit = 0; if (includeTriggers) { - auto bc = collision.bc_as>(); triggerDecider.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), jetderiveddatautilities::JTriggerMasks); triggerBit = jetderiveddatautilities::setTriggerSelectionBit(triggerDecider.getTriggerOfInterestResults(bc.globalBC())); } - jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multFT0C(), collision.centFT0C(), collision.trackOccupancyInTimeRange(), jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw(), triggerBit); // note change multFT0C to multFT0M when problems with multFT0A are fixed - jCollisionsParentIndexTable(collision.globalIndex()); - jCollisionsBunchCrossingIndexTable(collision.bcId()); + products.jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.centFV0A(), -1.0, collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), collision.centFT0CVariant1(), hadronicRate, collision.trackOccupancyInTimeRange(), jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw(), triggerBit); // note change multFT0C to multFT0M when problems with multFT0A are fixed + products.jCollisionsParentIndexTable(collision.globalIndex()); + products.jCollisionsBunchCrossingIndexTable(collision.bcId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processCollisions, "produces derived collision tables", true); @@ -178,61 +218,82 @@ struct JetDerivedDataProducerTask { triggerDecider.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), jetderiveddatautilities::JTriggerMasks); triggerBit = jetderiveddatautilities::setTriggerSelectionBit(triggerDecider.getTriggerOfInterestResults(bc.globalBC())); } - jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), -1.0, -1.0, -1, jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw(), triggerBit); - jCollisionsParentIndexTable(collision.globalIndex()); - jCollisionsBunchCrossingIndexTable(collision.bcId()); + products.jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1, jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw(), triggerBit); + products.jCollisionsParentIndexTable(collision.globalIndex()); + products.jCollisionsBunchCrossingIndexTable(collision.bcId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processCollisionsWithoutCentralityAndMultiplicity, "produces derived collision tables without centrality or multiplicity", false); - void processCollisionsRun2(soa::Join::iterator const& collision) + void processCollisionsRun2(soa::Join::iterator const& collision) { - jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multFT0C(), collision.centRun2V0M(), -1, jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw(), 0); // note change multFT0C to multFT0M when problems with multFT0A are fixed - jCollisionsParentIndexTable(collision.globalIndex()); - jCollisionsBunchCrossingIndexTable(collision.bcId()); + products.jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), -1.0, -1.0, -1.0, -1.0, collision.centRun2V0A(), collision.centRun2V0M(), -1.0, -1.0, -1.0, -1.0, 1.0, -1, jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw(), 0); // note change multFT0C to multFT0M when problems with multFT0A are fixed + products.jCollisionsParentIndexTable(collision.globalIndex()); + products.jCollisionsBunchCrossingIndexTable(collision.bcId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processCollisionsRun2, "produces derived collision tables for Run 2 data", false); void processCollisionsALICE3(aod::Collision const& collision) { - jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), -1.0, -1.0, -1, -1.0, 0, 0); - jCollisionsParentIndexTable(collision.globalIndex()); - jCollisionsBunchCrossingIndexTable(-1); + products.jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1, -1.0, 0, 0); + products.jCollisionsParentIndexTable(collision.globalIndex()); + products.jCollisionsBunchCrossingIndexTable(-1); } PROCESS_SWITCH(JetDerivedDataProducerTask, processCollisionsALICE3, "produces derived collision tables for ALICE 3 simulations", false); void processWithoutEMCalCollisionLabels(aod::Collision const&) { - jCollisionsEMCalLabelTable(false, false); + products.jCollisionsEMCalLabelTable(false, false); } PROCESS_SWITCH(JetDerivedDataProducerTask, processWithoutEMCalCollisionLabels, "produces dummy derived collision labels for EMCal", true); void processEMCalCollisionLabels(aod::EMCALMatchedCollision const& collision) { - jCollisionsEMCalLabelTable(collision.ambiguous(), collision.isemcreadout()); + products.jCollisionsEMCalLabelTable(collision.ambiguous(), collision.isemcreadout()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processEMCalCollisionLabels, "produces derived collision labels for EMCal", false); - void processMcCollisionLabels(soa::Join::iterator const& collision) + void processMcCollisionLabels(soa::Join::iterator const& collision, aod::McCollisions const&) { - + products.jMcCollisionsLabelTable(collision.mcCollisionId()); // collision.mcCollisionId() returns -1 if collision has no associated mcCollision if (collision.has_mcCollision()) { - jMcCollisionsLabelTable(collision.mcCollisionId()); + products.jCollisionMcInfosTable(collision.mcCollision().weight(), collision.mcCollision().getSubGeneratorId()); } else { - jMcCollisionsLabelTable(-1); + products.jCollisionMcInfosTable(0.0, jetderiveddatautilities::JCollisionSubGeneratorId::none); } } PROCESS_SWITCH(JetDerivedDataProducerTask, processMcCollisionLabels, "produces derived MC collision labels table", false); - void processMcCollisions(aod::McCollision const& McCollision) + void processMcCollisions(soa::Join::iterator const& mcCollision) { - jMcCollisionsTable(McCollision.posX(), McCollision.posY(), McCollision.posZ(), McCollision.weight()); - jMcCollisionsParentIndexTable(McCollision.globalIndex()); + products.jMcCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.multMCFV0A(), mcCollision.multMCFT0A(), mcCollision.multMCFT0C(), mcCollision.centFV0A(), mcCollision.centFT0A(), mcCollision.centFT0C(), mcCollision.centFT0M(), mcCollision.weight(), mcCollision.getSubGeneratorId(), mcCollision.accepted(), mcCollision.attempted(), mcCollision.xsectGen(), mcCollision.xsectErr(), mcCollision.ptHard()); + products.jMcCollisionsParentIndexTable(mcCollision.globalIndex()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processMcCollisions, "produces derived MC collision table", false); + void processMcCollisionsWithoutCentralityAndMultiplicity(soa::Join::iterator const& mcCollision) + { + products.jMcCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, mcCollision.weight(), mcCollision.getSubGeneratorId(), mcCollision.accepted(), mcCollision.attempted(), mcCollision.xsectGen(), mcCollision.xsectErr(), mcCollision.ptHard()); + products.jMcCollisionsParentIndexTable(mcCollision.globalIndex()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processMcCollisionsWithoutCentralityAndMultiplicity, "produces derived MC collision table without centraility and multiplicity", false); + + void processMcCollisionsWithoutXsection(soa::Join::iterator const& mcCollision) + { + products.jMcCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.multMCFV0A(), mcCollision.multMCFT0A(), mcCollision.multMCFT0C(), mcCollision.centFV0A(), mcCollision.centFT0A(), mcCollision.centFT0C(), mcCollision.centFT0M(), mcCollision.weight(), mcCollision.getSubGeneratorId(), 1, 1, 1.0, 1.0, 999.0); + products.jMcCollisionsParentIndexTable(mcCollision.globalIndex()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processMcCollisionsWithoutXsection, "produces derived MC collision table without cross section information", false); + + void processMcCollisionsWithoutCentralityAndMultiplicityAndXsection(aod::McCollision const& mcCollision) + { + products.jMcCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, mcCollision.weight(), mcCollision.getSubGeneratorId(), 1, 1, 1.0, 1.0, 999.0); + products.jMcCollisionsParentIndexTable(mcCollision.globalIndex()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processMcCollisionsWithoutCentralityAndMultiplicityAndXsection, "produces derived MC collision table without centrality, multiplicity and cross section information", false); + void processTracks(soa::Join::iterator const& track, aod::Collisions const&) { - jTracksTable(track.collisionId(), track.pt(), track.eta(), track.phi(), jetderiveddatautilities::setTrackSelectionBit(track, track.dcaZ(), dcaZMax)); + products.jTracksTable(track.collisionId(), track.pt(), track.eta(), track.phi(), jetderiveddatautilities::setTrackSelectionBit(track, track.dcaZ(), dcaZMax)); auto trackParCov = getTrackParCov(track); auto xyzTrack = trackParCov.getXYZGlo(); float sigmaDCAXYZ2; @@ -245,26 +306,27 @@ struct JetDerivedDataProducerTask { dcaY = xyzTrack.Y() - collision.posY(); } - jTracksExtraTable(dcaX, dcaY, track.dcaZ(), track.dcaXY(), dcaXYZ, std::sqrt(track.sigmaDcaZ2()), std::sqrt(track.sigmaDcaXY2()), std::sqrt(sigmaDCAXYZ2), track.sigma1Pt()); // why is this getSigmaZY - jTracksParentIndexTable(track.globalIndex()); - trackCollisionMapping[{track.globalIndex(), track.collisionId()}] = jTracksTable.lastIndex(); + products.jTracksExtraTable(dcaX, dcaY, track.dcaZ(), track.dcaXY(), dcaXYZ, std::sqrt(track.sigmaDcaZ2()), std::sqrt(track.sigmaDcaXY2()), std::sqrt(sigmaDCAXYZ2), track.sigma1Pt()); // why is this getSigmaZY + products.jTracksParentIndexTable(track.globalIndex()); + trackCollisionMapping[{track.globalIndex(), track.collisionId()}] = products.jTracksTable.lastIndex(); } PROCESS_SWITCH(JetDerivedDataProducerTask, processTracks, "produces derived track table", true); void processTracksWithCollisionAssociator(aod::Collisions const& collisions, soa::Join const&, soa::Join const&, aod::TrackAssoc const& assocCollisions) { + runNumber = 0; for (auto const& collision : collisions) { auto collisionTrackIndices = assocCollisions.sliceBy(perCollisionTrackIndices, collision.globalIndex()); for (auto const& collisionTrackIndex : collisionTrackIndices) { auto track = collisionTrackIndex.track_as>(); auto trackParCov = getTrackParCov(track); if (track.collisionId() == collision.globalIndex()) { - jTracksTable(collision.globalIndex(), track.pt(), track.eta(), track.phi(), jetderiveddatautilities::setTrackSelectionBit(track, track.dcaZ(), dcaZMax)); - jTracksParentIndexTable(track.globalIndex()); + products.jTracksTable(collision.globalIndex(), track.pt(), track.eta(), track.phi(), jetderiveddatautilities::setTrackSelectionBit(track, track.dcaZ(), dcaZMax)); + products.jTracksParentIndexTable(track.globalIndex()); auto xyzTrack = trackParCov.getXYZGlo(); float sigmaDCAXYZ2; float dcaXYZ = getDcaXYZ(track, &sigmaDCAXYZ2); - jTracksExtraTable(xyzTrack.X() - collision.posX(), xyzTrack.Y() - collision.posY(), track.dcaZ(), track.dcaXY(), dcaXYZ, std::sqrt(track.sigmaDcaZ2()), std::sqrt(track.sigmaDcaXY2()), std::sqrt(sigmaDCAXYZ2), track.sigma1Pt()); // why is this getSigmaZY + products.jTracksExtraTable(xyzTrack.X() - collision.posX(), xyzTrack.Y() - collision.posY(), track.dcaZ(), track.dcaXY(), dcaXYZ, std::sqrt(track.sigmaDcaZ2()), std::sqrt(track.sigmaDcaXY2()), std::sqrt(sigmaDCAXYZ2), track.sigma1Pt()); // why is this getSigmaZY } else { auto bc = collision.bc_as>(); initCCDB(bc, runNumber, ccdb, doprocessCollisionsRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, doprocessCollisionsRun2); @@ -274,8 +336,8 @@ struct JetDerivedDataProducerTask { collisionInfo.setPos({collision.posX(), collision.posY(), collision.posZ()}); collisionInfo.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); o2::base::Propagator::Instance()->propagateToDCABxByBz(collisionInfo, trackParCov, 2.f, noMatCorr, &dcaCovInfo); - jTracksTable(collision.globalIndex(), trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), jetderiveddatautilities::setTrackSelectionBit(track, dcaCovInfo.getZ(), dcaZMax)); // only qualitytracksWDCA are a reliable selection - jTracksParentIndexTable(track.globalIndex()); + products.jTracksTable(collision.globalIndex(), trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), jetderiveddatautilities::setTrackSelectionBit(track, dcaCovInfo.getZ(), dcaZMax)); // only qualitytracksWDCA are a reliable selection + products.jTracksParentIndexTable(track.globalIndex()); auto xyzTrack = trackParCov.getXYZGlo(); float dcaXY = dcaCovInfo.getY(); float dcaZ = dcaCovInfo.getZ(); @@ -289,20 +351,35 @@ struct JetDerivedDataProducerTask { } else { sigmaDCAXYZ = covYY * (2.f * dcaXY / dcaXYZ) * (2.f * dcaXY / dcaXYZ) + covZZ * (2.f * dcaZ / dcaXYZ) * (2.f * dcaZ / dcaXYZ) + 2.f * covYZ * (2.f * dcaXY / dcaXYZ) * (2.f * dcaZ / dcaXYZ); } - jTracksExtraTable(xyzTrack.X() - collision.posX(), xyzTrack.Y() - collision.posY(), dcaZ, dcaXY, dcaXYZ, std::sqrt(covZZ), std::sqrt(covYY), std::sqrt(sigmaDCAXYZ), std::sqrt(trackParCov.getSigma1Pt2())); + products.jTracksExtraTable(xyzTrack.X() - collision.posX(), xyzTrack.Y() - collision.posY(), dcaZ, dcaXY, dcaXYZ, std::sqrt(covZZ), std::sqrt(covYY), std::sqrt(sigmaDCAXYZ), std::sqrt(trackParCov.getSigma1Pt2())); } - trackCollisionMapping[{track.globalIndex(), collision.globalIndex()}] = jTracksTable.lastIndex(); + trackCollisionMapping[{track.globalIndex(), collision.globalIndex()}] = products.jTracksTable.lastIndex(); } } } PROCESS_SWITCH(JetDerivedDataProducerTask, processTracksWithCollisionAssociator, "produces derived track table taking into account track-to-collision associations", false); + void processTracksRun2(soa::Join::iterator const& track) + { + // TracksDCACov table is not yet available for Run 2 converted data. Remove this process function and use only processTracks when that becomes available. + products.jTracksTable(track.collisionId(), track.pt(), track.eta(), track.phi(), jetderiveddatautilities::setTrackSelectionBit(track, track.dcaZ(), dcaZMax)); + float sigmaDCAXYZ2 = 0.0; + float dcaXYZ = getDcaXYZ(track, &sigmaDCAXYZ2); + float dcaX = -99.0; + float dcaY = -99.0; + + products.jTracksExtraTable(dcaX, dcaY, track.dcaZ(), track.dcaXY(), dcaXYZ, std::sqrt(1.), std::sqrt(1.), std::sqrt(sigmaDCAXYZ2), track.sigma1Pt()); // dummy values - will be fixed when TracksDCACov table is available for Run 2 + products.jTracksParentIndexTable(track.globalIndex()); + trackCollisionMapping[{track.globalIndex(), track.collisionId()}] = products.jTracksTable.lastIndex(); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processTracksRun2, "produces derived track table for Run2 AO2Ds", false); + void processMcTrackLabels(soa::Join::iterator const& track) { if (track.has_mcParticle()) { - jMcTracksLabelTable(track.mcParticleId()); + products.jMcTracksLabelTable(track.mcParticleId()); } else { - jMcTracksLabelTable(-1); + products.jMcTracksLabelTable(-1); } } PROCESS_SWITCH(JetDerivedDataProducerTask, processMcTrackLabels, "produces derived track labels table", false); @@ -314,9 +391,9 @@ struct JetDerivedDataProducerTask { for (auto const& collisionTrackIndex : collisionTrackIndices) { auto track = collisionTrackIndex.track_as>(); if (track.collisionId() == collision.globalIndex() && track.has_mcParticle()) { - jMcTracksLabelTable(track.mcParticleId()); + products.jMcTracksLabelTable(track.mcParticleId()); } else { - jMcTracksLabelTable(-1); + products.jMcTracksLabelTable(-1); } } } @@ -343,8 +420,8 @@ struct JetDerivedDataProducerTask { i++; } } - jMcParticlesTable(particle.mcCollisionId(), particle.pt(), particle.eta(), particle.phi(), particle.y(), particle.e(), particle.pdgCode(), particle.getGenStatusCode(), particle.getHepMCStatusCode(), particle.isPhysicalPrimary(), mothersId, daughtersId); - jParticlesParentIndexTable(particle.globalIndex()); + products.jMcParticlesTable(particle.mcCollisionId(), particle.pt(), particle.eta(), particle.phi(), particle.y(), particle.e(), particle.pdgCode(), particle.getGenStatusCode(), particle.getHepMCStatusCode(), particle.isPhysicalPrimary(), mothersId, daughtersId); + products.jParticlesParentIndexTable(particle.globalIndex()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processParticles, "produces derived parrticle table", false); @@ -374,8 +451,8 @@ struct JetDerivedDataProducerTask { } } - jClustersTable(cluster.collisionId(), cluster.id(), cluster.energy(), cluster.coreEnergy(), cluster.rawEnergy(), cluster.eta(), cluster.phi(), cluster.m02(), cluster.m20(), cluster.nCells(), cluster.time(), cluster.isExotic(), cluster.distanceToBadChannel(), cluster.nlm(), cluster.definition(), leadingCellEnergy, subleadingCellEnergy, leadingCellNumber, subleadingCellNumber); - jClustersParentIndexTable(cluster.globalIndex()); + products.jClustersTable(cluster.collisionId(), cluster.id(), cluster.energy(), cluster.coreEnergy(), cluster.rawEnergy(), cluster.eta(), cluster.phi(), cluster.m02(), cluster.m20(), cluster.nCells(), cluster.time(), cluster.isExotic(), cluster.distanceToBadChannel(), cluster.nlm(), cluster.definition(), leadingCellEnergy, subleadingCellEnergy, leadingCellNumber, subleadingCellNumber); + products.jClustersParentIndexTable(cluster.globalIndex()); auto const clusterTracks = matchedTracks.sliceBy(perClusterTracks, cluster.globalIndex()); std::vector clusterTrackIDs; @@ -383,9 +460,9 @@ struct JetDerivedDataProducerTask { auto JClusterID = trackCollisionMapping.find({clusterTrack.trackId(), cluster.collisionId()}); // does EMCal use its own associator? clusterTrackIDs.push_back(JClusterID->second); auto emcTrack = clusterTrack.track_as>(); - jTracksEMCalTable(JClusterID->second, emcTrack.trackEtaEmcal(), emcTrack.trackPhiEmcal()); + products.jTracksEMCalTable(JClusterID->second, emcTrack.trackEtaEmcal(), emcTrack.trackPhiEmcal()); } - jClustersMatchedTracksTable(clusterTrackIDs); + products.jClustersMatchedTracksTable(clusterTrackIDs); } } PROCESS_SWITCH(JetDerivedDataProducerTask, processClusters, "produces derived cluster tables", false); @@ -399,113 +476,211 @@ struct JetDerivedDataProducerTask { std::vector amplitudeA; auto amplitudeASpan = cluster.amplitudeA(); std::copy(amplitudeASpan.begin(), amplitudeASpan.end(), std::back_inserter(amplitudeA)); - jMcClustersLabelTable(particleIds, amplitudeA); + products.jMcClustersLabelTable(particleIds, amplitudeA); } PROCESS_SWITCH(JetDerivedDataProducerTask, processMcClusterLabels, "produces derived cluster particle label table", false); void processD0Collisions(aod::HfD0CollIds::iterator const& D0Collision) { - jD0CollisionIdsTable(D0Collision.collisionId()); + products.jD0CollisionIdsTable(D0Collision.collisionId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processD0Collisions, "produces derived index for D0 collisions", false); void processD0McCollisions(aod::HfD0McCollIds::iterator const& D0McCollision) { - jD0McCollisionIdsTable(D0McCollision.mcCollisionId()); + products.jD0McCollisionIdsTable(D0McCollision.mcCollisionId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processD0McCollisions, "produces derived index for D0 MC collisions", false); - void processD0(aod::HfD0Ids::iterator const& D0, aod::Tracks const&) + void processD0(aod::HfD0Ids::iterator const& D0Candidate, aod::Tracks const&) { - auto JProng0ID = trackCollisionMapping.find({D0.prong0Id(), D0.prong0_as().collisionId()}); - auto JProng1ID = trackCollisionMapping.find({D0.prong1Id(), D0.prong1_as().collisionId()}); + auto JProng0ID = trackCollisionMapping.find({D0Candidate.prong0Id(), D0Candidate.prong0_as().collisionId()}); + auto JProng1ID = trackCollisionMapping.find({D0Candidate.prong1Id(), D0Candidate.prong1_as().collisionId()}); if (withCollisionAssociator) { - JProng0ID = trackCollisionMapping.find({D0.prong0Id(), D0.collisionId()}); - JProng1ID = trackCollisionMapping.find({D0.prong1Id(), D0.collisionId()}); + JProng0ID = trackCollisionMapping.find({D0Candidate.prong0Id(), D0Candidate.collisionId()}); + JProng1ID = trackCollisionMapping.find({D0Candidate.prong1Id(), D0Candidate.collisionId()}); } - jD0IdsTable(D0.collisionId(), JProng0ID->second, JProng1ID->second); + products.jD0IdsTable(D0Candidate.collisionId(), JProng0ID->second, JProng1ID->second); } PROCESS_SWITCH(JetDerivedDataProducerTask, processD0, "produces derived index for D0 candidates", false); - void processD0MC(aod::HfD0PIds::iterator const& D0) + void processD0MC(aod::HfD0PIds::iterator const& D0Particle) { - jD0ParticleIdsTable(D0.mcCollisionId(), D0.mcParticleId()); + products.jD0ParticleIdsTable(D0Particle.mcCollisionId(), D0Particle.mcParticleId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processD0MC, "produces derived index for D0 particles", false); + void processDplusCollisions(aod::HfDplusCollIds::iterator const& DplusCollision) + { + products.jDplusCollisionIdsTable(DplusCollision.collisionId()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processDplusCollisions, "produces derived index for Dplus collisions", false); + + void processDplusMcCollisions(aod::HfDplusMcCollIds::iterator const& DplusMcCollision) + { + products.jDplusMcCollisionIdsTable(DplusMcCollision.mcCollisionId()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processDplusMcCollisions, "produces derived index for Dplus MC collisions", false); + + void processDplus(aod::HfDplusIds::iterator const& DplusCandidate, aod::Tracks const&) + { + auto JProng0ID = trackCollisionMapping.find({DplusCandidate.prong0Id(), DplusCandidate.prong0_as().collisionId()}); + auto JProng1ID = trackCollisionMapping.find({DplusCandidate.prong1Id(), DplusCandidate.prong1_as().collisionId()}); + auto JProng2ID = trackCollisionMapping.find({DplusCandidate.prong2Id(), DplusCandidate.prong2_as().collisionId()}); + if (withCollisionAssociator) { + JProng0ID = trackCollisionMapping.find({DplusCandidate.prong0Id(), DplusCandidate.collisionId()}); + JProng1ID = trackCollisionMapping.find({DplusCandidate.prong1Id(), DplusCandidate.collisionId()}); + JProng2ID = trackCollisionMapping.find({DplusCandidate.prong2Id(), DplusCandidate.collisionId()}); + } + products.jDplusIdsTable(DplusCandidate.collisionId(), JProng0ID->second, JProng1ID->second, JProng2ID->second); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processDplus, "produces derived index for Dplus candidates", false); + + void processDplusMC(aod::HfDplusPIds::iterator const& DplusParticle) + { + products.jDplusParticleIdsTable(DplusParticle.mcCollisionId(), DplusParticle.mcParticleId()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processDplusMC, "produces derived index for Dplus particles", false); + + void processDstarCollisions(aod::HfDstarCollIds::iterator const& DstarCollision) + { + products.jDstarCollisionIdsTable(DstarCollision.collisionId()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processDstarCollisions, "produces derived index for Dstar collisions", false); + + void processDstarMcCollisions(aod::HfDstarMcCollIds::iterator const& DstarMcCollision) + { + products.jDstarMcCollisionIdsTable(DstarMcCollision.mcCollisionId()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processDstarMcCollisions, "produces derived index for Dstar MC collisions", false); + + void processDstar(aod::HfDstarIds::iterator const& DstarCandidate, aod::Tracks const&) + { + auto JProng0ID = trackCollisionMapping.find({DstarCandidate.prong0Id(), DstarCandidate.prong0_as().collisionId()}); + auto JProng1ID = trackCollisionMapping.find({DstarCandidate.prong1Id(), DstarCandidate.prong1_as().collisionId()}); + auto JProng2ID = trackCollisionMapping.find({DstarCandidate.prong2Id(), DstarCandidate.prong2_as().collisionId()}); + if (withCollisionAssociator) { + JProng0ID = trackCollisionMapping.find({DstarCandidate.prong0Id(), DstarCandidate.collisionId()}); + JProng1ID = trackCollisionMapping.find({DstarCandidate.prong1Id(), DstarCandidate.collisionId()}); + JProng2ID = trackCollisionMapping.find({DstarCandidate.prong2Id(), DstarCandidate.collisionId()}); + } + products.jDstarIdsTable(DstarCandidate.collisionId(), JProng0ID->second, JProng1ID->second, JProng2ID->second); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processDstar, "produces derived index for Dstar candidates", false); + + void processDstarMC(aod::HfDstarPIds::iterator const& DstarParticle) + { + products.jDstarParticleIdsTable(DstarParticle.mcCollisionId(), DstarParticle.mcParticleId()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processDstarMC, "produces derived index for Dstar particles", false); + void processLcCollisions(aod::HfLcCollIds::iterator const& LcCollision) { - jLcCollisionIdsTable(LcCollision.collisionId()); + products.jLcCollisionIdsTable(LcCollision.collisionId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processLcCollisions, "produces derived index for Lc collisions", false); void processLcMcCollisions(aod::HfLcMcCollIds::iterator const& LcMcCollision) { - jLcMcCollisionIdsTable(LcMcCollision.mcCollisionId()); + products.jLcMcCollisionIdsTable(LcMcCollision.mcCollisionId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processLcMcCollisions, "produces derived index for Lc MC collisions", false); - void processLc(aod::HfLcIds::iterator const& Lc, aod::Tracks const&) + void processLc(aod::HfLcIds::iterator const& LcCandidate, aod::Tracks const&) { - auto JProng0ID = trackCollisionMapping.find({Lc.prong0Id(), Lc.prong0_as().collisionId()}); - auto JProng1ID = trackCollisionMapping.find({Lc.prong1Id(), Lc.prong1_as().collisionId()}); - auto JProng2ID = trackCollisionMapping.find({Lc.prong2Id(), Lc.prong2_as().collisionId()}); + auto JProng0ID = trackCollisionMapping.find({LcCandidate.prong0Id(), LcCandidate.prong0_as().collisionId()}); + auto JProng1ID = trackCollisionMapping.find({LcCandidate.prong1Id(), LcCandidate.prong1_as().collisionId()}); + auto JProng2ID = trackCollisionMapping.find({LcCandidate.prong2Id(), LcCandidate.prong2_as().collisionId()}); if (withCollisionAssociator) { - JProng0ID = trackCollisionMapping.find({Lc.prong0Id(), Lc.collisionId()}); - JProng1ID = trackCollisionMapping.find({Lc.prong1Id(), Lc.collisionId()}); - JProng2ID = trackCollisionMapping.find({Lc.prong2Id(), Lc.collisionId()}); + JProng0ID = trackCollisionMapping.find({LcCandidate.prong0Id(), LcCandidate.collisionId()}); + JProng1ID = trackCollisionMapping.find({LcCandidate.prong1Id(), LcCandidate.collisionId()}); + JProng2ID = trackCollisionMapping.find({LcCandidate.prong2Id(), LcCandidate.collisionId()}); } - jLcIdsTable(Lc.collisionId(), JProng0ID->second, JProng1ID->second, JProng2ID->second); + products.jLcIdsTable(LcCandidate.collisionId(), JProng0ID->second, JProng1ID->second, JProng2ID->second); } PROCESS_SWITCH(JetDerivedDataProducerTask, processLc, "produces derived index for Lc candidates", false); - void processLcMC(aod::HfLcPIds::iterator const& Lc) + void processLcMC(aod::HfLcPIds::iterator const& LcParticle) { - jLcParticleIdsTable(Lc.mcCollisionId(), Lc.mcParticleId()); + products.jLcParticleIdsTable(LcParticle.mcCollisionId(), LcParticle.mcParticleId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processLcMC, "produces derived index for Lc particles", false); + void processB0Collisions(aod::HfB0CollIds::iterator const& B0Collision) + { + products.jB0CollisionIdsTable(B0Collision.collisionId()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processB0Collisions, "produces derived index for B0 collisions", false); + + void processB0McCollisions(aod::HfB0McCollIds::iterator const& B0McCollision) + { + products.jB0McCollisionIdsTable(B0McCollision.mcCollisionId()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processB0McCollisions, "produces derived index for B0 MC collisions", false); + + void processB0(aod::HfB0Ids::iterator const& B0Candidate, aod::Tracks const&) + { + auto JProng0ID = trackCollisionMapping.find({B0Candidate.prong0Id(), B0Candidate.prong0_as().collisionId()}); + auto JProng1ID = trackCollisionMapping.find({B0Candidate.prong1Id(), B0Candidate.prong1_as().collisionId()}); + auto JProng2ID = trackCollisionMapping.find({B0Candidate.prong2Id(), B0Candidate.prong2_as().collisionId()}); + auto JProng3ID = trackCollisionMapping.find({B0Candidate.prong3Id(), B0Candidate.prong3_as().collisionId()}); + if (withCollisionAssociator) { + JProng0ID = trackCollisionMapping.find({B0Candidate.prong0Id(), B0Candidate.collisionId()}); + JProng1ID = trackCollisionMapping.find({B0Candidate.prong1Id(), B0Candidate.collisionId()}); + JProng2ID = trackCollisionMapping.find({B0Candidate.prong2Id(), B0Candidate.collisionId()}); + JProng3ID = trackCollisionMapping.find({B0Candidate.prong3Id(), B0Candidate.collisionId()}); + } + products.jB0IdsTable(B0Candidate.collisionId(), JProng0ID->second, JProng1ID->second, JProng2ID->second, JProng3ID->second); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processB0, "produces derived index for B0 candidates", false); + + void processB0MC(aod::HfB0PIds::iterator const& B0Particle) + { + products.jB0ParticleIdsTable(B0Particle.mcCollisionId(), B0Particle.mcParticleId()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processB0MC, "produces derived index for B0 particles", false); + void processBplusCollisions(aod::HfBplusCollIds::iterator const& BplusCollision) { - jBplusCollisionIdsTable(BplusCollision.collisionId()); + products.jBplusCollisionIdsTable(BplusCollision.collisionId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processBplusCollisions, "produces derived index for Bplus collisions", false); void processBplusMcCollisions(aod::HfBplusMcCollIds::iterator const& BplusMcCollision) { - jBplusMcCollisionIdsTable(BplusMcCollision.mcCollisionId()); + products.jBplusMcCollisionIdsTable(BplusMcCollision.mcCollisionId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processBplusMcCollisions, "produces derived index for Bplus MC collisions", false); - void processBplus(aod::HfBplusIds::iterator const& Bplus, aod::Tracks const&) + void processBplus(aod::HfBplusIds::iterator const& BplusCandidate, aod::Tracks const&) { - auto JProng0ID = trackCollisionMapping.find({Bplus.prong0Id(), Bplus.prong0_as().collisionId()}); - auto JProng1ID = trackCollisionMapping.find({Bplus.prong1Id(), Bplus.prong1_as().collisionId()}); - auto JProng2ID = trackCollisionMapping.find({Bplus.prong2Id(), Bplus.prong2_as().collisionId()}); + auto JProng0ID = trackCollisionMapping.find({BplusCandidate.prong0Id(), BplusCandidate.prong0_as().collisionId()}); + auto JProng1ID = trackCollisionMapping.find({BplusCandidate.prong1Id(), BplusCandidate.prong1_as().collisionId()}); + auto JProng2ID = trackCollisionMapping.find({BplusCandidate.prong2Id(), BplusCandidate.prong2_as().collisionId()}); if (withCollisionAssociator) { - JProng0ID = trackCollisionMapping.find({Bplus.prong0Id(), Bplus.collisionId()}); - JProng1ID = trackCollisionMapping.find({Bplus.prong1Id(), Bplus.collisionId()}); - JProng2ID = trackCollisionMapping.find({Bplus.prong2Id(), Bplus.collisionId()}); + JProng0ID = trackCollisionMapping.find({BplusCandidate.prong0Id(), BplusCandidate.collisionId()}); + JProng1ID = trackCollisionMapping.find({BplusCandidate.prong1Id(), BplusCandidate.collisionId()}); + JProng2ID = trackCollisionMapping.find({BplusCandidate.prong2Id(), BplusCandidate.collisionId()}); } - jBplusIdsTable(Bplus.collisionId(), JProng0ID->second, JProng1ID->second, JProng2ID->second); + products.jBplusIdsTable(BplusCandidate.collisionId(), JProng0ID->second, JProng1ID->second, JProng2ID->second); } PROCESS_SWITCH(JetDerivedDataProducerTask, processBplus, "produces derived index for Bplus candidates", false); - void processBplusMC(aod::HfBplusPIds::iterator const& Bplus) + void processBplusMC(aod::HfBplusPIds::iterator const& BplusParticle) { - jBplusParticleIdsTable(Bplus.mcCollisionId(), Bplus.mcParticleId()); + products.jBplusParticleIdsTable(BplusParticle.mcCollisionId(), BplusParticle.mcParticleId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processBplusMC, "produces derived index for Bplus particles", false); - void processV0(aod::V0Indices::iterator const& V0, aod::Tracks const&) + void processV0(aod::V0Indices::iterator const& V0Candidate, aod::Tracks const&) { - auto JPosTrackID = trackCollisionMapping.find({V0.posTrackId(), V0.posTrack_as().collisionId()}); - auto JNegTrackID = trackCollisionMapping.find({V0.negTrackId(), V0.negTrack_as().collisionId()}); + auto JPosTrackID = trackCollisionMapping.find({V0Candidate.posTrackId(), V0Candidate.posTrack_as().collisionId()}); + auto JNegTrackID = trackCollisionMapping.find({V0Candidate.negTrackId(), V0Candidate.negTrack_as().collisionId()}); if (withCollisionAssociator) { - JPosTrackID = trackCollisionMapping.find({V0.posTrackId(), V0.collisionId()}); - JNegTrackID = trackCollisionMapping.find({V0.negTrackId(), V0.collisionId()}); + JPosTrackID = trackCollisionMapping.find({V0Candidate.posTrackId(), V0Candidate.collisionId()}); + JNegTrackID = trackCollisionMapping.find({V0Candidate.negTrackId(), V0Candidate.collisionId()}); } - jV0IdsTable(V0.collisionId(), JPosTrackID->second, JNegTrackID->second); + products.jV0IdsTable(V0Candidate.collisionId(), JPosTrackID->second, JNegTrackID->second); } PROCESS_SWITCH(JetDerivedDataProducerTask, processV0, "produces derived index for V0 candidates", false); @@ -515,8 +690,8 @@ struct JetDerivedDataProducerTask { for (auto const& particle : particles) { if (jetv0utilities::isV0Particle(particles, particle)) { if (!filledV0McCollisionTable) { - jV0McCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()); - jV0McCollisionIdsTable(mcCollision.globalIndex()); + products.jV0McCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()); + products.jV0McCollisionIdsTable(mcCollision.globalIndex()); filledV0McCollisionTable = true; } std::vector mothersId; @@ -538,8 +713,8 @@ struct JetDerivedDataProducerTask { } } auto pdgParticle = pdgDatabase->GetParticle(particle.pdgCode()); - jV0McsTable(jV0McCollisionsTable.lastIndex(), particle.pt(), particle.eta(), particle.phi(), particle.y(), particle.e(), pdgParticle->Mass(), particle.pdgCode(), particle.getGenStatusCode(), particle.getHepMCStatusCode(), particle.isPhysicalPrimary(), jetv0utilities::setV0ParticleDecayBit(particles, particle)); - jV0McIdsTable(mcCollision.globalIndex(), particle.globalIndex(), mothersId, daughtersId); + products.jV0McsTable(products.jV0McCollisionsTable.lastIndex(), particle.pt(), particle.eta(), particle.phi(), particle.y(), particle.e(), pdgParticle->Mass(), particle.pdgCode(), particle.getGenStatusCode(), particle.getHepMCStatusCode(), particle.isPhysicalPrimary(), jetv0utilities::setV0ParticleDecayBit(particles, particle)); + products.jV0McIdsTable(mcCollision.globalIndex(), particle.globalIndex(), mothersId, daughtersId); } } } @@ -547,19 +722,19 @@ struct JetDerivedDataProducerTask { void processDielectronCollisions(aod::ReducedEventsInfo::iterator const& DielectronCollision) { - jDielectronCollisionIdsTable(DielectronCollision.collisionId()); + products.jDielectronCollisionIdsTable(DielectronCollision.collisionId()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processDielectronCollisions, "produces derived index for Dielectron collisions", false); - void processDielectron(aod::DielectronInfo const& Dielectron, aod::Tracks const&) + void processDielectron(aod::DielectronInfo const& DielectronCandidate, aod::Tracks const&) { - auto JProng0ID = trackCollisionMapping.find({Dielectron.prong0Id(), Dielectron.prong0_as().collisionId()}); - auto JProng1ID = trackCollisionMapping.find({Dielectron.prong1Id(), Dielectron.prong1_as().collisionId()}); + auto JProng0ID = trackCollisionMapping.find({DielectronCandidate.prong0Id(), DielectronCandidate.prong0_as().collisionId()}); + auto JProng1ID = trackCollisionMapping.find({DielectronCandidate.prong1Id(), DielectronCandidate.prong1_as().collisionId()}); if (withCollisionAssociator) { - JProng0ID = trackCollisionMapping.find({Dielectron.prong0Id(), Dielectron.collisionId()}); - JProng1ID = trackCollisionMapping.find({Dielectron.prong1Id(), Dielectron.collisionId()}); + JProng0ID = trackCollisionMapping.find({DielectronCandidate.prong0Id(), DielectronCandidate.collisionId()}); + JProng1ID = trackCollisionMapping.find({DielectronCandidate.prong1Id(), DielectronCandidate.collisionId()}); } - jDielectronIdsTable(Dielectron.collisionId(), JProng0ID->second, JProng1ID->second); + products.jDielectronIdsTable(DielectronCandidate.collisionId(), JProng0ID->second, JProng1ID->second); } PROCESS_SWITCH(JetDerivedDataProducerTask, processDielectron, "produces derived index for Dielectron candidates", false); @@ -569,8 +744,8 @@ struct JetDerivedDataProducerTask { for (auto const& particle : particles) { if (jetdqutilities::isDielectronParticle(particles, particle)) { if (!filledDielectronMcCollisionTable) { - jDielectronMcCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()); - jDielectronMcCollisionIdsTable(mcCollision.globalIndex()); + products.jDielectronMcCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()); + products.jDielectronMcCollisionIdsTable(mcCollision.globalIndex()); filledDielectronMcCollisionTable = true; } std::vector mothersId; @@ -592,8 +767,9 @@ struct JetDerivedDataProducerTask { } } auto pdgParticle = pdgDatabase->GetParticle(particle.pdgCode()); - jDielectronMcsTable(jDielectronMcCollisionsTable.lastIndex(), particle.pt(), particle.eta(), particle.phi(), particle.y(), particle.e(), pdgParticle->Mass(), particle.pdgCode(), particle.getGenStatusCode(), particle.getHepMCStatusCode(), particle.isPhysicalPrimary(), jetdqutilities::setDielectronParticleDecayBit(particles, particle), RecoDecay::getCharmHadronOrigin(particles, particle, false)); // Todo: should the last thing be false? - jDielectronMcIdsTable(mcCollision.globalIndex(), particle.globalIndex(), mothersId, daughtersId); + products.jDielectronMcsTable(products.jDielectronMcCollisionsTable.lastIndex(), particle.pt(), particle.eta(), particle.phi(), particle.y(), particle.e(), pdgParticle->Mass(), particle.pdgCode(), particle.getGenStatusCode(), particle.getHepMCStatusCode(), particle.isPhysicalPrimary(), jetdqutilities::setDielectronParticleDecayBit(particles, particle), RecoDecay::getCharmHadronOrigin(particles, particle, false)); // Todo: should the last thing be false? + products.jDielectronMcIdsTable(mcCollision.globalIndex(), particle.globalIndex(), mothersId, daughtersId); + products.JDielectronMcRCollDummysTable(false); } } } diff --git a/PWGJE/TableProducer/derivedDataProducerDummy.cxx b/PWGJE/TableProducer/derivedDataProducerDummy.cxx deleted file mode 100644 index c5a68c7c6b8..00000000000 --- a/PWGJE/TableProducer/derivedDataProducerDummy.cxx +++ /dev/null @@ -1,82 +0,0 @@ -// 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. - -// temporary task to produce HF and DQ tables needed when making inclusive derived data - should become obsolete when tables are able to be prouduced based on a configurable -// -/// \author Nima Zardoshti - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGHF/DataModel/DerivedTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct JetDerivedDataProducerDummyTask { - - Produces d0CollisionsTable; - Produces d0CollisionsMatchingTable; - Produces d0sTable; - Produces d0ParsTable; - Produces d0ParExtrasTable; - Produces d0SelsTable; - Produces d0MlsTable; - Produces d0McsTable; - Produces d0McCollisionsTable; - Produces d0ParticlesTable; - - Produces lcCollisionsTable; - Produces lcCollisionsMatchingTable; - Produces lcsTable; - Produces lcParsTable; - Produces lcParExtrasTable; - Produces lcSelsTable; - Produces lcMlsTable; - Produces lcMcsTable; - Produces lcMcCollisionsTable; - Produces lcParticlesTable; - - Produces bplusCollisionsTable; - Produces bplusCollisionsMatchingTable; - Produces bplussTable; - Produces bplusParsTable; - Produces bplusParExtrasTable; - Produces bplusParD0sTable; - Produces bplusSelsTable; - Produces bplusMlsTable; - Produces bplusMlD0sTable; - Produces bplusMcsTable; - Produces bplusMcCollisionsTable; - Produces bplusParticlesTable; - - Produces dielectronCollisionsTable; - Produces dielectronTable; - - void init(InitContext const&) - { - } - - void processDummy(aod::JDummys const&) - { - } - PROCESS_SWITCH(JetDerivedDataProducerDummyTask, processDummy, "leaves all tables empty", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"jet-deriveddata-producer-dummy"})}; -} diff --git a/PWGJE/TableProducer/derivedDataProducerDummyBplus.cxx b/PWGJE/TableProducer/derivedDataProducerDummyBplus.cxx deleted file mode 100644 index 8f3e238710a..00000000000 --- a/PWGJE/TableProducer/derivedDataProducerDummyBplus.cxx +++ /dev/null @@ -1,69 +0,0 @@ -// 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. - -// temporary task to produce HF and DQ tables needed when making B+ jet derived data - should become obsolete when tables are able to be prouduced based on a configurable -// -/// \author Nima Zardoshti - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGHF/DataModel/DerivedTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct JetDerivedDataProducerDummyTask { - - Produces d0CollisionsTable; - Produces d0CollisionsMatchingTable; - Produces d0sTable; - Produces d0ParsTable; - Produces d0ParExtrasTable; - Produces d0SelsTable; - Produces d0MlsTable; - Produces d0McsTable; - Produces d0McCollisionsTable; - Produces d0ParticlesTable; - - Produces lcCollisionsTable; - Produces lcCollisionsMatchingTable; - Produces lcsTable; - Produces lcParsTable; - Produces lcParExtrasTable; - Produces lcSelsTable; - Produces lcMlsTable; - Produces lcMcsTable; - Produces lcMcCollisionsTable; - Produces lcParticlesTable; - - Produces dielectronCollisionsTable; - Produces dielectronTable; - - void init(InitContext const&) - { - } - - void processDummy(aod::JDummys const&) - { - } - PROCESS_SWITCH(JetDerivedDataProducerDummyTask, processDummy, "leaves all tables empty", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"jet-deriveddata-producer-dummy"})}; -} diff --git a/PWGJE/TableProducer/derivedDataProducerDummyD0.cxx b/PWGJE/TableProducer/derivedDataProducerDummyD0.cxx deleted file mode 100644 index 4cbbfdeedea..00000000000 --- a/PWGJE/TableProducer/derivedDataProducerDummyD0.cxx +++ /dev/null @@ -1,71 +0,0 @@ -// 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. - -// temporary task to produce HF and DQ tables needed when making D0 jet derived data - should become obsolete when tables are able to be prouduced based on a configurable -// -/// \author Nima Zardoshti - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGHF/DataModel/DerivedTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct JetDerivedDataProducerDummyD0Task { - - Produces lcCollisionsTable; - Produces lcCollisionsMatchingTable; - Produces lcsTable; - Produces lcParsTable; - Produces lcParExtrasTable; - Produces lcSelsTable; - Produces lcMlsTable; - Produces lcMcsTable; - Produces lcMcCollisionsTable; - Produces lcParticlesTable; - - Produces bplusCollisionsTable; - Produces bplusCollisionsMatchingTable; - Produces bplussTable; - Produces bplusParsTable; - Produces bplusParExtrasTable; - Produces bplusParD0sTable; - Produces bplusSelsTable; - Produces bplusMlsTable; - Produces bplusMlD0sTable; - Produces bplusMcsTable; - Produces bplusMcCollisionsTable; - Produces bplusParticlesTable; - - Produces dielectronCollisionsTable; - Produces dielectronTable; - - void init(InitContext const&) - { - } - - void processDummy(aod::JDummys const&) - { - } - PROCESS_SWITCH(JetDerivedDataProducerDummyD0Task, processDummy, "leaves all tables empty", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"jet-deriveddata-producer-dummy-d0"})}; -} diff --git a/PWGJE/TableProducer/derivedDataProducerDummyDielectron.cxx b/PWGJE/TableProducer/derivedDataProducerDummyDielectron.cxx deleted file mode 100644 index c24cf13bd41..00000000000 --- a/PWGJE/TableProducer/derivedDataProducerDummyDielectron.cxx +++ /dev/null @@ -1,79 +0,0 @@ -// 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. - -// temporary task to produce HF tables needed when making dielectron jet derived data - should become obsolete when tables are able to be prouduced based on a configurable -// -/// \author Nima Zardoshti - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGHF/DataModel/DerivedTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct JetDerivedDataProducerDummyDielectronTask { - - Produces d0CollisionsTable; - Produces d0CollisionsMatchingTable; - Produces d0sTable; - Produces d0ParsTable; - Produces d0ParExtrasTable; - Produces d0SelsTable; - Produces d0MlsTable; - Produces d0McsTable; - Produces d0McCollisionsTable; - Produces d0ParticlesTable; - - Produces lcCollisionsTable; - Produces lcCollisionsMatchingTable; - Produces lcsTable; - Produces lcParsTable; - Produces lcParExtrasTable; - Produces lcSelsTable; - Produces lcMlsTable; - Produces lcMcsTable; - Produces lcMcCollisionsTable; - Produces lcParticlesTable; - - Produces bplusCollisionsTable; - Produces bplusCollisionsMatchingTable; - Produces bplussTable; - Produces bplusParsTable; - Produces bplusParExtrasTable; - Produces bplusParD0sTable; - Produces bplusSelsTable; - Produces bplusMlsTable; - Produces bplusMlD0sTable; - Produces bplusMcsTable; - Produces bplusMcCollisionsTable; - Produces bplusParticlesTable; - - void init(InitContext const&) - { - } - - void processDummy(aod::JDummys const&) - { - } - PROCESS_SWITCH(JetDerivedDataProducerDummyDielectronTask, processDummy, "leaves all tables empty", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"jet-deriveddata-producer-dummy-dielectron"})}; -} diff --git a/PWGJE/TableProducer/derivedDataProducerDummyLc.cxx b/PWGJE/TableProducer/derivedDataProducerDummyLc.cxx deleted file mode 100644 index 9913e1da37f..00000000000 --- a/PWGJE/TableProducer/derivedDataProducerDummyLc.cxx +++ /dev/null @@ -1,71 +0,0 @@ -// 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. - -// temporary task to produce HF and DQ tables needed when making Lc jet derived data - should become obsolete when tables are able to be prouduced based on a configurable -// -/// \author Nima Zardoshti - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGHF/DataModel/DerivedTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct JetDerivedDataProducerDummyLcTask { - - Produces d0CollisionsTable; - Produces d0CollisionsMatchingTable; - Produces d0sTable; - Produces d0ParsTable; - Produces d0ParExtrasTable; - Produces d0SelsTable; - Produces d0MlsTable; - Produces d0McsTable; - Produces d0McCollisionsTable; - Produces d0ParticlesTable; - - Produces bplusCollisionsTable; - Produces bplusCollisionsMatchingTable; - Produces bplussTable; - Produces bplusParsTable; - Produces bplusParExtrasTable; - Produces bplusParD0sTable; - Produces bplusSelsTable; - Produces bplusMlsTable; - Produces bplusMlD0sTable; - Produces bplusMcsTable; - Produces bplusMcCollisionsTable; - Produces bplusParticlesTable; - - Produces dielectronCollisionsTable; - Produces dielectronTable; - - void init(InitContext const&) - { - } - - void processDummy(aod::JDummys const&) - { - } - PROCESS_SWITCH(JetDerivedDataProducerDummyLcTask, processDummy, "leaves all tables empty", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"jet-deriveddata-producer-dummy-lc"})}; -} diff --git a/PWGJE/TableProducer/derivedDataSelector.cxx b/PWGJE/TableProducer/derivedDataSelector.cxx new file mode 100644 index 00000000000..9e04a6332b4 --- /dev/null +++ b/PWGJE/TableProducer/derivedDataSelector.cxx @@ -0,0 +1,378 @@ +// 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. + +/// \file jetderiveddataselector.cxx +/// \brief Task to store decision of which events to skim for producing jet framework tables (aod::JetCollisions, aod::JetTracks, aod::JetClusters, ...) +/// while adjusting indices accordingly +/// +/// \author Nima Zardoshti +/// \author Jochen Klein + +#include "JetDerivedDataUtilities.h" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetReducedDataSelector.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct JetDerivedDataSelector { + + Produces collisionSelectionsTable; + Produces mcCollisionSelectionsTable; + + struct : ConfigurableGroup { + Configurable thresholdChargedJetPtMin{"thresholdChargedJetPtMin", 0.0, "Minimum charged jet pt to accept event"}; + Configurable thresholdChargedEventWiseSubtractedJetPtMin{"thresholdChargedEventWiseSubtractedJetPtMin", 0.0, "Minimum charged event-wise subtracted jet pt to accept event"}; + Configurable thresholdChargedMCPJetPtMin{"thresholdChargedMCPJetPtMin", 0.0, "Minimum charged mcp jet pt to accept event"}; + Configurable thresholdNeutralJetPtMin{"thresholdNeutralJetPtMin", 0.0, "Minimum neutral jet pt to accept event"}; + Configurable thresholdNeutralMCPJetPtMin{"thresholdNeutralMCPJetPtMin", 0.0, "Minimum neutal mcp jet pt to accept event"}; + Configurable thresholdFullJetPtMin{"thresholdFullJetPtMin", 0.0, "Minimum full jet pt to accept event"}; + Configurable thresholdFullMCPJetPtMin{"thresholdFullMCPJetPtMin", 0.0, "Minimum full mcp jet pt to accept event"}; + Configurable thresholdChargedD0JetPtMin{"thresholdChargedD0JetPtMin", 0.0, "Minimum charged D0 jet pt to accept event"}; + Configurable thresholdChargedEventWiseSubtractedD0JetPtMin{"thresholdChargedEventWiseSubtractedD0JetPtMin", 0.0, "Minimum charged event-wise subtracted D0 jet pt to accept event"}; + Configurable thresholdChargedD0MCPJetPtMin{"thresholdChargedD0MCPJetPtMin", 0.0, "Minimum charged D0 mcp jet pt to accept event"}; + Configurable thresholdChargedDplusJetPtMin{"thresholdChargedDplusJetPtMin", 0.0, "Minimum charged Dplus jet pt to accept event"}; + Configurable thresholdChargedEventWiseSubtractedDplusJetPtMin{"thresholdChargedEventWiseSubtractedDplusJetPtMin", 0.0, "Minimum charged event-wise subtracted Dplus jet pt to accept event"}; + Configurable thresholdChargedDplusMCPJetPtMin{"thresholdChargedDplusMCPJetPtMin", 0.0, "Minimum charged Dplus mcp jet pt to accept event"}; + Configurable thresholdChargedDstarJetPtMin{"thresholdChargedDstarJetPtMin", 0.0, "Minimum charged Dstar jet pt to accept event"}; + Configurable thresholdChargedEventWiseSubtractedDstarJetPtMin{"thresholdChargedEventWiseSubtractedDstarJetPtMin", 0.0, "Minimum charged event-wise subtracted Dstar jet pt to accept event"}; + Configurable thresholdChargedDstarMCPJetPtMin{"thresholdChargedDstarMCPJetPtMin", 0.0, "Minimum charged Dstar mcp jet pt to accept event"}; + Configurable thresholdChargedLcJetPtMin{"thresholdChargedLcJetPtMin", 0.0, "Minimum charged Lc jet pt to accept event"}; + Configurable thresholdChargedEventWiseSubtractedLcJetPtMin{"thresholdChargedEventWiseSubtractedLcJetPtMin", 0.0, "Minimum charged event-wise subtracted Lc jet pt to accept event"}; + Configurable thresholdChargedLcMCPJetPtMin{"thresholdChargedLcMCPJetPtMin", 0.0, "Minimum charged Lc mcp jet pt to accept event"}; + Configurable thresholdChargedB0JetPtMin{"thresholdChargedB0JetPtMin", 0.0, "Minimum charged B0 jet pt to accept event"}; + Configurable thresholdChargedEventWiseSubtractedB0JetPtMin{"thresholdChargedEventWiseSubtractedB0JetPtMin", 0.0, "Minimum charged event-wise subtracted B0 jet pt to accept event"}; + Configurable thresholdChargedB0MCPJetPtMin{"thresholdChargedB0MCPJetPtMin", 0.0, "Minimum charged B0 mcp jet pt to accept event"}; + Configurable thresholdChargedBplusJetPtMin{"thresholdChargedBplusJetPtMin", 0.0, "Minimum charged Bplus jet pt to accept event"}; + Configurable thresholdChargedEventWiseSubtractedBplusJetPtMin{"thresholdChargedEventWiseSubtractedBplusJetPtMin", 0.0, "Minimum charged event-wise subtracted Bplus jet pt to accept event"}; + Configurable thresholdChargedBplusMCPJetPtMin{"thresholdChargedBplusMCPJetPtMin", 0.0, "Minimum charged Bplus mcp jet pt to accept event"}; + Configurable thresholdChargedDielectronJetPtMin{"thresholdChargedDielectronJetPtMin", 0.0, "Minimum charged Dielectron jet pt to accept event"}; + Configurable thresholdChargedEventWiseSubtractedDielectronJetPtMin{"thresholdChargedEventWiseSubtractedDielectronJetPtMin", 0.0, "Minimum charged event-wise subtracted Dielectron jet pt to accept event"}; + Configurable thresholdChargedDielectronMCPJetPtMin{"thresholdChargedDielectronMCPJetPtMin", 0.0, "Minimum charged Dielectron mcp jet pt to accept event"}; + Configurable thresholdTriggerTrackPtMin{"thresholdTriggerTrackPtMin", 0.0, "Minimum trigger track pt to accept event"}; + Configurable thresholdClusterEnergyMin{"thresholdClusterEnergyMin", 0.0, "Minimum cluster energy to accept event"}; + Configurable downscaleFactor{"downscaleFactor", 1, "random downscale of selected events"}; + + Configurable vertexZCut{"vertexZCut", 10.0, "z-vertex cut on event"}; + Configurable centralityMin{"centralityMin", -999.0, "minimum centrality"}; + Configurable centralityMax{"centralityMax", 999.0, "maximum centrality"}; + Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; + Configurable performTrackSelection{"performTrackSelection", true, "only save tracks that pass one of the track selections"}; + Configurable trackPtSelectionMin{"trackPtSelectionMin", 0.15, "only save tracks that have a pT larger than this pT"}; + Configurable trackEtaSelectionMax{"trackEtaSelectionMax", 0.9, "only save tracks that have an eta smaller than this eta"}; + + Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; + } config; + + std::vector collisionFlag; + std::vector McCollisionFlag; + + TRandom3 randomNumber; + + std::vector triggerMaskBits; + void init(InitContext&) + { + randomNumber.SetSeed(0); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(config.triggerMasks); + } + + PresliceUnsorted> CollisionsPerMcCollision = aod::jmccollisionlb::mcCollisionId; + + void processSetupCollisions(aod::JCollisions const& collisions) + { + collisionFlag.clear(); + collisionFlag.resize(collisions.size(), false); + } + + void processSetupMcCollisions(aod::JMcCollisions const& mcCollisions) + { + McCollisionFlag.clear(); + McCollisionFlag.resize(mcCollisions.size(), false); + } + + void processSelectMcCollisionsPerCollision(aod::JMcCollisions const& mcCollisions, soa::Join const& collisions) + { + for (auto mcCollision : mcCollisions) { + const auto collisionsPerMcCollision = collisions.sliceBy(CollisionsPerMcCollision, mcCollision.globalIndex()); + for (auto collision : collisionsPerMcCollision) { + if (collisionFlag[collision.globalIndex()]) { + McCollisionFlag[mcCollision.globalIndex()] = true; + } + } + } + } + + void processSelectCollisionsPerMcCollision(soa::Join::iterator const& collision) + { + if (McCollisionFlag[collision.mcCollisionId()]) { + collisionFlag[collision.globalIndex()] = true; + } + } + + void processSetupAllCollisionsWithDownscaling(aod::JCollisions const& collisions) + { + collisionFlag.clear(); + collisionFlag.resize(collisions.size(), false); + for (const auto& collision : collisions) { + if (randomNumber.Integer(config.downscaleFactor) == 0) { + collisionFlag[collision.globalIndex()] = true; + } + } + } + + void processSetupAllMcCollisionsWithDownscaling(aod::JMcCollisions const& mcCollisions) + { + McCollisionFlag.clear(); + McCollisionFlag.resize(mcCollisions.size(), false); + for (const auto& mcCollision : mcCollisions) { + if (randomNumber.Integer(config.downscaleFactor) == 0) { + McCollisionFlag[mcCollision.globalIndex()] = true; + } + } + } + + template + void processDoDownscaling(T const& collisions) + { + for (const auto& collision : collisions) { + if constexpr (std::is_same_v, aod::JCollisions>) { + if (collisionFlag[collision.globalIndex()] && randomNumber.Integer(config.downscaleFactor) != 0) { + collisionFlag[collision.globalIndex()] = false; + } + } + if constexpr (std::is_same_v, aod::JMcCollisions>) { + if (McCollisionFlag[collision.globalIndex()] && randomNumber.Integer(config.downscaleFactor) != 0) { + McCollisionFlag[collision.globalIndex()] = false; + } + } + } + } + + void processSetupEventTriggering(aod::JCollision const& collision) + { + if (jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + collisionFlag[collision.globalIndex()] = true; + } + } + + void processDoCollisionSelections(aod::JCollision const& collision) + { // can also add event selection like sel8 but goes a little against the derived data idea + if (collision.centFT0M() < config.centralityMin || collision.centFT0M() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { + collisionFlag[collision.globalIndex()] = false; + } + } + + template + void processSelectionObjects(T& selectionObjects) + { + float selectionObjectPtMin = 0.0; + if constexpr (std::is_same_v, aod::ChargedJets> || std::is_same_v, aod::ChargedMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdChargedJetPtMin; + } else if constexpr (std::is_same_v, aod::ChargedEventWiseSubtractedJets> || std::is_same_v, aod::ChargedMCDetectorLevelEventWiseSubtractedJets>) { + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedJetPtMin; + } else if constexpr (std::is_same_v, aod::ChargedMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdChargedMCPJetPtMin; + } else if constexpr (std::is_same_v, aod::NeutralJets> || std::is_same_v, aod::NeutralMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdNeutralJetPtMin; + } else if constexpr (std::is_same_v, aod::NeutralMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdNeutralMCPJetPtMin; + } else if constexpr (std::is_same_v, aod::FullJets> || std::is_same_v, aod::FullMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdFullJetPtMin; + } else if constexpr (std::is_same_v, aod::FullMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdFullMCPJetPtMin; + } else if constexpr (std::is_same_v, aod::D0ChargedJets> || std::is_same_v, aod::D0ChargedMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdChargedD0JetPtMin; + } else if constexpr (std::is_same_v, aod::D0ChargedEventWiseSubtractedJets> || std::is_same_v, aod::D0ChargedMCDetectorLevelEventWiseSubtractedJets>) { + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedD0JetPtMin; + } else if constexpr (std::is_same_v, aod::D0ChargedMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdChargedD0MCPJetPtMin; + } else if constexpr (std::is_same_v, aod::DplusChargedJets> || std::is_same_v, aod::DplusChargedMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdChargedDplusJetPtMin; + } else if constexpr (std::is_same_v, aod::DplusChargedEventWiseSubtractedJets> || std::is_same_v, aod::DplusChargedMCDetectorLevelEventWiseSubtractedJets>) { + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedDplusJetPtMin; + } else if constexpr (std::is_same_v, aod::DplusChargedMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdChargedDplusMCPJetPtMin; + } else if constexpr (std::is_same_v, aod::DstarChargedJets> || std::is_same_v, aod::DstarChargedMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdChargedDstarJetPtMin; + } else if constexpr (std::is_same_v, aod::DstarChargedEventWiseSubtractedJets> || std::is_same_v, aod::DstarChargedMCDetectorLevelEventWiseSubtractedJets>) { + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedDstarJetPtMin; + } else if constexpr (std::is_same_v, aod::DstarChargedMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdChargedDstarMCPJetPtMin; + } else if constexpr (std::is_same_v, aod::LcChargedJets> || std::is_same_v, aod::LcChargedMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdChargedLcJetPtMin; + } else if constexpr (std::is_same_v, aod::LcChargedEventWiseSubtractedJets> || std::is_same_v, aod::LcChargedMCDetectorLevelEventWiseSubtractedJets>) { + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedLcJetPtMin; + } else if constexpr (std::is_same_v, aod::LcChargedMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdChargedLcMCPJetPtMin; + } else if constexpr (std::is_same_v, aod::B0ChargedJets> || std::is_same_v, aod::B0ChargedMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdChargedB0JetPtMin; + } else if constexpr (std::is_same_v, aod::B0ChargedEventWiseSubtractedJets> || std::is_same_v, aod::B0ChargedMCDetectorLevelEventWiseSubtractedJets>) { + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedB0JetPtMin; + } else if constexpr (std::is_same_v, aod::B0ChargedMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdChargedB0MCPJetPtMin; + } else if constexpr (std::is_same_v, aod::BplusChargedJets> || std::is_same_v, aod::BplusChargedMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdChargedBplusJetPtMin; + } else if constexpr (std::is_same_v, aod::BplusChargedEventWiseSubtractedJets> || std::is_same_v, aod::BplusChargedMCDetectorLevelEventWiseSubtractedJets>) { + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedBplusJetPtMin; + } else if constexpr (std::is_same_v, aod::BplusChargedMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdChargedBplusMCPJetPtMin; + } else if constexpr (std::is_same_v, aod::DielectronChargedJets> || std::is_same_v, aod::DielectronChargedMCDetectorLevelJets>) { + selectionObjectPtMin = config.thresholdChargedDielectronJetPtMin; + } else if constexpr (std::is_same_v, aod::DielectronChargedEventWiseSubtractedJets> || std::is_same_v, aod::DielectronChargedMCDetectorLevelEventWiseSubtractedJets>) { + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedDielectronJetPtMin; + } else if constexpr (std::is_same_v, aod::DielectronChargedMCParticleLevelJets>) { + selectionObjectPtMin = config.thresholdChargedDielectronMCPJetPtMin; + } else if constexpr (std::is_same_v, aod::JTracks>) { + selectionObjectPtMin = config.thresholdTriggerTrackPtMin; + } else if constexpr (std::is_same_v, aod::JClusters>) { + selectionObjectPtMin = config.thresholdClusterEnergyMin; + } else { + selectionObjectPtMin = 0.0; + } + for (const auto& selectionObject : selectionObjects) { + bool isTriggerObject = false; + if constexpr (std::is_same_v, aod::JClusters>) { + if (selectionObject.energy() >= selectionObjectPtMin) { + isTriggerObject = true; + } + } else { + if constexpr (std::is_same_v, aod::JTracks>) { + if (config.performTrackSelection && !(selectionObject.trackSel() & ~(1 << jetderiveddatautilities::JTrackSel::trackSign))) { + continue; + } + if (selectionObject.pt() < config.trackPtSelectionMin || std::abs(selectionObject.eta()) > config.trackEtaSelectionMax) { + continue; + } + } + if (selectionObject.pt() >= selectionObjectPtMin) { + isTriggerObject = true; + } + } + if (isTriggerObject) { + if constexpr (std::is_same_v, aod::ChargedMCParticleLevelJets> || std::is_same_v, aod::NeutralMCParticleLevelJets> || std::is_same_v, aod::FullMCParticleLevelJets> || std::is_same_v, aod::D0ChargedMCParticleLevelJets> || std::is_same_v, aod::DplusChargedMCParticleLevelJets> || std::is_same_v, aod::DstarChargedMCParticleLevelJets> || std::is_same_v, aod::LcChargedMCParticleLevelJets> || std::is_same_v, aod::B0ChargedMCParticleLevelJets> || std::is_same_v, aod::BplusChargedMCParticleLevelJets> || std::is_same_v, aod::DielectronChargedMCParticleLevelJets>) { + if (selectionObject.mcCollisionId() >= 0) { + McCollisionFlag[selectionObject.mcCollisionId()] = true; + } + } else { + if (selectionObject.collisionId() >= 0) { + collisionFlag[selectionObject.collisionId()] = true; + } + } + } + } + } + // Todo : Check memory consumption of having so many Process Switches + PROCESS_SWITCH(JetDerivedDataSelector, processSetupCollisions, "setup the writing for data and MCD based on collisions", true); + PROCESS_SWITCH(JetDerivedDataSelector, processSetupMcCollisions, "setup the writing for MCP based on mcCollisions", false); + PROCESS_SWITCH(JetDerivedDataSelector, processSetupAllCollisionsWithDownscaling, "setup the writing of untriggered collisions with downscaling", false); + PROCESS_SWITCH(JetDerivedDataSelector, processSetupAllMcCollisionsWithDownscaling, "setup the writing of untriggered mccollisions with downscaling", false); + PROCESS_SWITCH(JetDerivedDataSelector, processSetupEventTriggering, "process software triggers", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingChargedJets, "process charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingChargedEventWiseSubtractedJets, "process charged event-wise subtracted jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingChargedMCDJets, "process charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingChargedMCDetectorLevelEventWiseSubtractedJets, "process charged event-wise subtracted mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingChargedMCPJets, "process charged mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingNeutralJets, "process neutral jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingNeutralMCDJets, "process neutral mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingNeutralMCPJets, "process neutral mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingFullJets, "process full jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingFullMCDJets, "process full mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingFullMCPJets, "process full mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingD0ChargedJets, "process D0 charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingD0ChargedEventWiseSubtractedJets, "process D0 event-wise subtracted charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingD0ChargedMCDJets, "process D0 charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingD0ChargedMCDetectorLevelEventWiseSubtractedJets, "process D0 event-wise subtracted charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingD0ChargedMCPJets, "process D0 charged mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDplusChargedJets, "process Dplus charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDplusChargedEventWiseSubtractedJets, "process Dplus event-wise subtracted charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDplusChargedMCDJets, "process Dplus charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDplusChargedMCDetectorLevelEventWiseSubtractedJets, "process Dplus event-wise subtracted charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDplusChargedMCPJets, "process Dplus charged mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDstarChargedJets, "process Dstar charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDstarChargedEventWiseSubtractedJets, "process Dstar event-wise subtracted charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDstarChargedMCDJets, "process Dstar charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDstarChargedMCDetectorLevelEventWiseSubtractedJets, "process Dstar event-wise subtracted charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDstarChargedMCPJets, "process Dstar charged mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingLcChargedJets, "process Lc charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingLcChargedEventWiseSubtractedJets, "process Lc event-wise subtracted charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingLcChargedMCDJets, "process Lc charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingLcChargedMCDetectorLevelEventWiseSubtractedJets, "process Lc event-wise subtracted charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingLcChargedMCPJets, "process Lc charged mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingB0ChargedJets, "process B0 charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingB0ChargedEventWiseSubtractedJets, "process B0 event-wise subtracted charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingB0ChargedMCDJets, "process B0 charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingB0ChargedMCDetectorLevelEventWiseSubtractedJets, "process B0 event-wise subtracted charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingB0ChargedMCPJets, "process B0 charged mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingBplusChargedJets, "process Bplus charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingBplusChargedEventWiseSubtractedJets, "process Bplus event-wise subtracted charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingBplusChargedMCDJets, "process Bplus charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingBplusChargedMCDetectorLevelEventWiseSubtractedJets, "process Bplus event-wise subtracted charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingBplusChargedMCPJets, "process Bplus charged mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDielectronChargedJets, "process Dielectron charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDielectronChargedEventWiseSubtractedJets, "process Dielectron event-wise subtracted charged jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDielectronChargedMCDJets, "process Dielectron charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDielectronChargedMCDetectorLevelEventWiseSubtractedJets, "process Dielectron event-wise subtracted charged mcd jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingDielectronChargedMCPJets, "process Dielectron charged mcp jets", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingClusters, "process EMCal clusters", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processSelectionObjects, processSelectingTracks, "process high pt tracks", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processDoDownscaling, processCollisionDownscaling, "process downsaling of triggered collisions", false); + PROCESS_SWITCH_FULL(JetDerivedDataSelector, processDoDownscaling, processMcCollisionDownscaling, "process downsaling of triggered mccollisions", false); + PROCESS_SWITCH(JetDerivedDataSelector, processDoCollisionSelections, "process event selections for saved events", false); + PROCESS_SWITCH(JetDerivedDataSelector, processSelectMcCollisionsPerCollision, "select McCollisions due to a triggered reconstructed collision", false); + PROCESS_SWITCH(JetDerivedDataSelector, processSelectCollisionsPerMcCollision, "select collisions due to a triggered McCollision", false); + + void processStoreCollisionDecision(aod::JCollision const& collision) + { + if (collisionFlag[collision.globalIndex()]) { + collisionSelectionsTable(true); + } else { + collisionSelectionsTable(false); + } + } + PROCESS_SWITCH(JetDerivedDataSelector, processStoreCollisionDecision, "write out decision of storing collision", true); + + void processStoreMcCollisionDecision(aod::JMcCollision const& mcCollision) + { + if (McCollisionFlag[mcCollision.globalIndex()]) { + mcCollisionSelectionsTable(true); + } else { + mcCollisionSelectionsTable(false); + } + } + PROCESS_SWITCH(JetDerivedDataSelector, processStoreMcCollisionDecision, "write out decision of storing mcCollision", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-deriveddata-selector"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/derivedDataTriggerProducer.cxx b/PWGJE/TableProducer/derivedDataTriggerProducer.cxx index a1a1636dd1b..b90495d0bb6 100644 --- a/PWGJE/TableProducer/derivedDataTriggerProducer.cxx +++ b/PWGJE/TableProducer/derivedDataTriggerProducer.cxx @@ -13,20 +13,20 @@ // /// \author Nima Zardoshti -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/JetReducedData.h" #include "EventFiltering/filterTables.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include + +#include using namespace o2; using namespace o2::framework; diff --git a/PWGJE/TableProducer/derivedDataWriter.cxx b/PWGJE/TableProducer/derivedDataWriter.cxx index fb70c198fbf..d583250d49f 100644 --- a/PWGJE/TableProducer/derivedDataWriter.cxx +++ b/PWGJE/TableProducer/derivedDataWriter.cxx @@ -16,20 +16,32 @@ /// \author Jochen Klein /// \author Nima Zardoshti -#include -#include - -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" +#include "JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetHFUtilities.h" +#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "PWGHF/DataModel/DerivedTables.h" #include "PWGJE/Core/JetDQUtilities.h" +#include "PWGJE/Core/JetHFUtilities.h" #include "PWGJE/DataModel/Jet.h" #include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetReducedDataDQ.h" +#include "PWGJE/DataModel/JetReducedDataHF.h" +#include "PWGJE/DataModel/JetReducedDataSelector.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -38,42 +50,9 @@ using namespace o2::framework::expressions; struct JetDerivedDataWriter { struct : ConfigurableGroup { - Configurable thresholdChargedJetPtMin{"thresholdChargedJetPtMin", 0.0, "Minimum charged jet pt to accept event"}; - Configurable thresholdChargedEventWiseSubtractedJetPtMin{"thresholdChargedEventWiseSubtractedJetPtMin", 0.0, "Minimum charged event-wise subtracted jet pt to accept event"}; - Configurable thresholdChargedMCPJetPtMin{"thresholdChargedMCPJetPtMin", 0.0, "Minimum charged mcp jet pt to accept event"}; - Configurable thresholdNeutralJetPtMin{"thresholdNeutralJetPtMin", 0.0, "Minimum neutral jet pt to accept event"}; - Configurable thresholdNeutralMCPJetPtMin{"thresholdNeutralMCPJetPtMin", 0.0, "Minimum neutal mcp jet pt to accept event"}; - Configurable thresholdFullJetPtMin{"thresholdFullJetPtMin", 0.0, "Minimum full jet pt to accept event"}; - Configurable thresholdFullMCPJetPtMin{"thresholdFullMCPJetPtMin", 0.0, "Minimum full mcp jet pt to accept event"}; - Configurable thresholdChargedD0JetPtMin{"thresholdChargedD0JetPtMin", 0.0, "Minimum charged D0 jet pt to accept event"}; - Configurable thresholdChargedEventWiseSubtractedD0JetPtMin{"thresholdChargedEventWiseSubtractedD0JetPtMin", 0.0, "Minimum charged event-wise subtracted D0 jet pt to accept event"}; - Configurable thresholdChargedD0MCPJetPtMin{"thresholdChargedD0MCPJetPtMin", 0.0, "Minimum charged D0 mcp jet pt to accept event"}; - Configurable thresholdChargedLcJetPtMin{"thresholdChargedLcJetPtMin", 0.0, "Minimum charged Lc jet pt to accept event"}; - Configurable thresholdChargedEventWiseSubtractedLcJetPtMin{"thresholdChargedEventWiseSubtractedLcJetPtMin", 0.0, "Minimum charged event-wise subtracted Lc jet pt to accept event"}; - Configurable thresholdChargedLcMCPJetPtMin{"thresholdChargedLcMCPJetPtMin", 0.0, "Minimum charged Lc mcp jet pt to accept event"}; - Configurable thresholdChargedBplusJetPtMin{"thresholdChargedBplusJetPtMin", 0.0, "Minimum charged Bplus jet pt to accept event"}; - Configurable thresholdChargedEventWiseSubtractedBplusJetPtMin{"thresholdChargedEventWiseSubtractedBplusJetPtMin", 0.0, "Minimum charged event-wise subtracted Bplus jet pt to accept event"}; - Configurable thresholdChargedBplusMCPJetPtMin{"thresholdChargedBplusMCPJetPtMin", 0.0, "Minimum charged Bplus mcp jet pt to accept event"}; - Configurable thresholdChargedDielectronJetPtMin{"thresholdChargedDielectronJetPtMin", 0.0, "Minimum charged Dielectron jet pt to accept event"}; - Configurable thresholdChargedEventWiseSubtractedDielectronJetPtMin{"thresholdChargedEventWiseSubtractedDielectronJetPtMin", 0.0, "Minimum charged event-wise subtracted Dielectron jet pt to accept event"}; - Configurable thresholdChargedDielectronMCPJetPtMin{"thresholdChargedDielectronMCPJetPtMin", 0.0, "Minimum charged Dielectron mcp jet pt to accept event"}; - Configurable thresholdTriggerTrackPtMin{"thresholdTriggerTrackPtMin", 0.0, "Minimum trigger track pt to accept event"}; - Configurable thresholdClusterEnergyMin{"thresholdClusterEnergyMin", 0.0, "Minimum cluster energy to accept event"}; - Configurable downscaleFactor{"downscaleFactor", 1, "random downscale of selected events"}; - - Configurable vertexZCut{"vertexZCut", 10.0, "z-vertex cut on event"}; - Configurable centralityMin{"centralityMin", -999.0, "minimum centrality"}; - Configurable centralityMax{"centralityMax", 999.0, "maximum centrality"}; - Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; Configurable performTrackSelection{"performTrackSelection", true, "only save tracks that pass one of the track selections"}; Configurable trackPtSelectionMin{"trackPtSelectionMin", 0.15, "only save tracks that have a pT larger than this pT"}; Configurable trackEtaSelectionMax{"trackEtaSelectionMax", 0.9, "only save tracks that have an eta smaller than this eta"}; - Configurable saveBCsTable{"saveBCsTable", true, "save the bunch crossing table to the output"}; - Configurable saveClustersTable{"saveClustersTable", false, "save the clusters table to the output"}; - Configurable saveD0Table{"saveD0Table", false, "save the D0 tables to the output"}; - Configurable saveLcTable{"saveLcTable", false, "save the Lc tables to the output"}; - Configurable saveBplusTable{"saveBplusTable", false, "save the Bplus tables to the output"}; - Configurable saveDielectronTable{"saveDielectronTable", false, "save the Dielectron tables to the output"}; Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; } config; @@ -83,6 +62,7 @@ struct JetDerivedDataWriter { Produces storedJBCsTable; Produces storedJBCParentIndexTable; Produces storedJCollisionsTable; + Produces storedJCollisionMcInfosTable; Produces storedJCollisionsParentIndexTable; Produces storedJCollisionsBunchCrossingIndexTable; Produces storedJCollisionsEMCalLabelTable; @@ -97,1056 +77,814 @@ struct JetDerivedDataWriter { Produces storedJMcParticlesTable; Produces storedJParticlesParentIndexTable; Produces storedJClustersTable; + Produces storedJClustersCorrectedEnergiesTable; Produces storedJClustersParentIndexTable; Produces storedJClustersMatchedTracksTable; Produces storedJMcClustersLabelTable; - Produces storedD0CollisionsTable; - Produces storedD0CollisionIdsTable; - Produces storedD0sTable; - Produces storedD0ParsTable; - Produces storedD0ParExtrasTable; - Produces storedD0ParDaughtersDummyTable; - Produces storedD0SelsTable; - Produces storedD0MlsTable; - Produces storedD0MlDughtersDummyTable; - Produces storedD0McsTable; - Produces storedD0IdsTable; - Produces storedD0McCollisionsTable; - Produces storedD0McCollisionIdsTable; - Produces storedD0McCollisionsMatchingTable; - Produces storedD0ParticlesTable; - Produces storedD0ParticleIdsTable; - - Produces storedLcCollisionsTable; - Produces storedLcCollisionIdsTable; - Produces storedLcsTable; - Produces storedLcParsTable; - Produces storedLcParExtrasTable; - Produces storedLcParDaughtersDummyTable; - Produces storedLcSelsTable; - Produces storedLcMlsTable; - Produces storedLcMlDughtersDummyTable; - Produces storedLcMcsTable; - Produces storedLcIdsTable; - Produces storedLcMcCollisionsTable; - Produces storedLcMcCollisionIdsTable; - Produces storedLcMcCollisionsMatchingTable; - Produces storedLcParticlesTable; - Produces storedLcParticleIdsTable; - - Produces storedBplusCollisionsTable; - Produces storedBplusCollisionIdsTable; - Produces storedBplussTable; - Produces storedBplusParsTable; - Produces storedBplusParExtrasTable; - Produces storedBplusParD0sTable; - Produces storedBplusSelsTable; - Produces storedBplusMlsTable; - Produces storedBplusMlD0sTable; - Produces storedBplusMcsTable; - Produces storedBplusIdsTable; - Produces storedBplusMcCollisionsTable; - Produces storedBplusMcCollisionIdsTable; - Produces storedBplusMcCollisionsMatchingTable; - Produces storedBplusParticlesTable; - Produces storedBplusParticleIdsTable; - - Produces storedDielectronCollisionsTable; - Produces storedDielectronCollisionIdsTable; - Produces storedDielectronsTable; - Produces storedDielectronIdsTable; - Produces storedDielectronMcCollisionsTable; - Produces storedDielectronMcCollisionIdsTable; - // Produces storedD0McCollisionsMatchingTable; //this doesnt exist for Dileptons yet - Produces storedDielectronParticlesTable; - Produces storedDielectronParticleIdsTable; + struct : ProducesGroup { + Produces storedD0CollisionsTable; + Produces storedD0CollisionIdsTable; + Produces storedD0sTable; + Produces storedD0ParsTable; + Produces storedD0ParExtrasTable; + Produces storedD0ParDaughtersDummyTable; + Produces storedD0SelsTable; + Produces storedD0MlsTable; + Produces storedD0MlDughtersDummyTable; + Produces storedD0McsTable; + Produces storedD0IdsTable; + Produces storedD0McCollisionsTable; + Produces storedD0McCollisionIdsTable; + Produces storedD0McCollisionsMatchingTable; + Produces storedD0ParticlesTable; + Produces storedD0ParticleIdsTable; + } productsD0; + + struct : ProducesGroup { + Produces storedDplusCollisionsTable; + Produces storedDplusCollisionIdsTable; + Produces storedDplussTable; + Produces storedDplusParsTable; + Produces storedDplusParExtrasTable; + Produces storedDplusParDaughtersDummyTable; + Produces storedDplusSelsTable; + Produces storedDplusMlsTable; + Produces storedDplusMlDughtersDummyTable; + Produces storedDplusMcsTable; + Produces storedDplusIdsTable; + Produces storedDplusMcCollisionsTable; + Produces storedDplusMcCollisionIdsTable; + Produces storedDplusMcCollisionsMatchingTable; + Produces storedDplusParticlesTable; + Produces storedDplusParticleIdsTable; + } productsDplus; + + struct : ProducesGroup { + Produces storedDstarCollisionsTable; + Produces storedDstarCollisionIdsTable; + Produces storedDstarsTable; + Produces storedDstarParsTable; + Produces storedDstarParExtrasDummyTable; + Produces storedDstarParD0sTable; + Produces storedDstarSelsTable; + Produces storedDstarMlsTable; + Produces storedDstarMlDaughtersDummyTable; + Produces storedDstarMcsTable; + Produces storedDstarIdsTable; + Produces storedDstarMcCollisionsTable; + Produces storedDstarMcCollisionIdsTable; + Produces storedDstarMcCollisionsMatchingTable; + Produces storedDstarParticlesTable; + Produces storedDstarParticleIdsTable; + } productsDstar; + + struct : ProducesGroup { + Produces storedLcCollisionsTable; + Produces storedLcCollisionIdsTable; + Produces storedLcsTable; + Produces storedLcParsTable; + Produces storedLcParExtrasTable; + Produces storedLcParDaughtersDummyTable; + Produces storedLcSelsTable; + Produces storedLcMlsTable; + Produces storedLcMlDughtersDummyTable; + Produces storedLcMcsTable; + Produces storedLcIdsTable; + Produces storedLcMcCollisionsTable; + Produces storedLcMcCollisionIdsTable; + Produces storedLcMcCollisionsMatchingTable; + Produces storedLcParticlesTable; + Produces storedLcParticleIdsTable; + } productsLc; + + struct : ProducesGroup { + Produces storedB0CollisionsTable; + Produces storedB0CollisionIdsTable; + Produces storedB0sTable; + Produces storedB0ParsTable; + Produces storedB0ParExtrasTable; + Produces storedB0ParDplussTable; + Produces storedB0SelsTable; + Produces storedB0MlsTable; + Produces storedB0MlDplussTable; + Produces storedB0McsTable; + Produces storedB0IdsTable; + Produces storedB0McCollisionsTable; + Produces storedB0McCollisionIdsTable; + Produces storedB0McCollisionsMatchingTable; + Produces storedB0ParticlesTable; + Produces storedB0ParticleIdsTable; + } productsB0; + + struct : ProducesGroup { + Produces storedBplusCollisionsTable; + Produces storedBplusCollisionIdsTable; + Produces storedBplussTable; + Produces storedBplusParsTable; + Produces storedBplusParExtrasTable; + Produces storedBplusParD0sTable; + Produces storedBplusSelsTable; + Produces storedBplusMlsTable; + Produces storedBplusMlD0sTable; + Produces storedBplusMcsTable; + Produces storedBplusIdsTable; + Produces storedBplusMcCollisionsTable; + Produces storedBplusMcCollisionIdsTable; + Produces storedBplusMcCollisionsMatchingTable; + Produces storedBplusParticlesTable; + Produces storedBplusParticleIdsTable; + } productsBplus; + + struct : ProducesGroup { + Produces storedDielectronCollisionsTable; + Produces storedDielectronCollisionIdsTable; + Produces storedDielectronsTable; + Produces storedDielectronIdsTable; + Produces storedDielectronMcCollisionsTable; + Produces storedDielectronMcCollisionIdsTable; + Produces storedDielectronMcRCollDummysTable; + Produces storedDielectronParticlesTable; + Produces storedDielectronParticleIdsTable; + } productsDielectron; + } products; - PresliceUnsorted> CollisionsPerMcCollision = aod::jmccollisionlb::mcCollisionId; - PresliceUnsorted> ParticlesPerMcCollision = aod::jmcparticle::mcCollisionId; - Preslice> TracksPerCollision = aod::jtrack::collisionId; - Preslice> ClustersPerCollision = aod::jcluster::collisionId; - Preslice> D0McCollisionsPerMcCollision = aod::jd0indices::mcCollisionId; - Preslice> LcMcCollisionsPerMcCollision = aod::jlcindices::mcCollisionId; - Preslice> BplusMcCollisionsPerMcCollision = aod::jbplusindices::mcCollisionId; - Preslice DielectronMcCollisionsPerMcCollision = aod::jdielectronindices::mcCollisionId; - Preslice D0CollisionsPerCollision = aod::jd0indices::collisionId; - Preslice LcCollisionsPerCollision = aod::jlcindices::collisionId; - Preslice BplusCollisionsPerCollision = aod::jbplusindices::collisionId; - Preslice DielectronCollisionsPerCollision = aod::jdielectronindices::collisionId; - Preslice D0sPerCollision = aod::jd0indices::collisionId; - Preslice LcsPerCollision = aod::jlcindices::collisionId; - Preslice BplussPerCollision = aod::jbplusindices::collisionId; - Preslice DielectronsPerCollision = aod::jdielectronindices::collisionId; - PresliceUnsorted EMCTrackPerTrack = aod::jemctrack::trackId; - - std::vector collisionFlag; - std::vector McCollisionFlag; - std::vector bcIndicies; + struct : PresliceGroup { + Preslice> TracksPerCollision = aod::jtrack::collisionId; + + Preslice> ParticlesPerMcCollision = aod::jmcparticle::mcCollisionId; + Preslice D0McCollisionsPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice DplusMcCollisionsPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice DstarMcCollisionsPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice LcMcCollisionsPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice B0McCollisionsPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice BplusMcCollisionsPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice DielectronMcCollisionsPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice D0ParticlesPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice DplusParticlesPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice DstarParticlesPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice LcParticlesPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice B0ParticlesPerMcCollision = aod::jcandidateindices::mcCollisionId; + Preslice BplusParticlesPerMcCollision = aod::jcandidateindices::mcCollisionId; + PresliceUnsorted EMCTrackPerTrack = aod::jemctrack::trackId; + } preslices; uint32_t precisionPositionMask; uint32_t precisionMomentumMask; - TRandom3 randomNumber; - - std::vector triggerMaskBits; void init(InitContext&) { precisionPositionMask = 0xFFFFFC00; // 13 bits precisionMomentumMask = 0xFFFFFC00; // 13 bits this is currently keept at 13 bits wihich gives roughly a resolution of 1/8000. This can be increased to 15 bits if really needed - randomNumber.SetSeed(0); - triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(config.triggerMasks); } - bool acceptCollision(aod::JCollision const&) + template + bool trackSelection(T const& track) { + if (config.performTrackSelection && !(track.trackSel() & ~(1 << jetderiveddatautilities::JTrackSel::trackSign))) { // skips tracks that pass no selections. This might cause a problem with tracks matched with clusters. We should generate a track selection purely for cluster matched tracks so that they are kept. This includes also the track pT selction. + return false; + } + if (track.pt() < config.trackPtSelectionMin || std::abs(track.eta()) > config.trackEtaSelectionMax) { + return false; + } return true; } - void processSetupCollisions(aod::JCollisions const& collisions) + template + void storeD0(soa::Join::iterator const& collision, aod::JTracks const&, aod::CollisionsD0 const& D0Collisions, T const& D0Candidates) { - collisionFlag.clear(); - collisionFlag.resize(collisions.size()); - std::fill(collisionFlag.begin(), collisionFlag.end(), false); - } - void processSetupMcCollisions(aod::JMcCollisions const& McCollisions) - { - McCollisionFlag.clear(); - McCollisionFlag.resize(McCollisions.size()); - std::fill(McCollisionFlag.begin(), McCollisionFlag.end(), false); - } - - void processSetupAllCollisionsWithDownscaling(aod::JCollisions const& collisions) - { - collisionFlag.clear(); - collisionFlag.resize(collisions.size()); - for (const auto& collision : collisions) { - if (randomNumber.Integer(config.downscaleFactor) == 0) { - collisionFlag[collision.globalIndex()] = true; - } else { - collisionFlag[collision.globalIndex()] = false; + if (collision.isCollisionSelected()) { + for (const auto& D0Collision : D0Collisions) { // should only ever be one + jethfutilities::fillHFCollisionTable(D0Collision, products.productsD0.storedD0CollisionsTable); + products.productsD0.storedD0CollisionIdsTable(collisionMapping[collision.globalIndex()]); + } + for (const auto& D0Candidate : D0Candidates) { + jethfutilities::fillHFCandidateTable(D0Candidate, products.productsD0.storedD0CollisionsTable.lastIndex(), products.productsD0.storedD0sTable, products.productsD0.storedD0ParsTable, products.productsD0.storedD0ParExtrasTable, products.productsD0.storedD0ParDaughtersDummyTable, products.productsD0.storedD0SelsTable, products.productsD0.storedD0MlsTable, products.productsD0.storedD0MlDughtersDummyTable, products.productsD0.storedD0McsTable); + products.productsD0.storedD0IdsTable(collisionMapping[collision.globalIndex()], trackMapping[D0Candidate.prong0Id()], trackMapping[D0Candidate.prong1Id()]); } } } - void processSetupAllMcCollisionsWithDownscaling(aod::JMcCollisions const& McCollisions) + template + void storeDplus(soa::Join::iterator const& collision, aod::JTracks const&, aod::CollisionsDplus const& DplusCollisions, T const& DplusCandidates) { - McCollisionFlag.clear(); - McCollisionFlag.resize(McCollisions.size()); - for (const auto& mcCollision : McCollisions) { - if (randomNumber.Integer(config.downscaleFactor) == 0) { - McCollisionFlag[mcCollision.globalIndex()] = true; - } else { - McCollisionFlag[mcCollision.globalIndex()] = false; + if (collision.isCollisionSelected()) { + for (const auto& DplusCollision : DplusCollisions) { // should only ever be one + jethfutilities::fillHFCollisionTable(DplusCollision, products.productsDplus.storedDplusCollisionsTable); + products.productsDplus.storedDplusCollisionIdsTable(collisionMapping[collision.globalIndex()]); + } + for (const auto& DplusCandidate : DplusCandidates) { + jethfutilities::fillHFCandidateTable(DplusCandidate, products.productsDplus.storedDplusCollisionsTable.lastIndex(), products.productsDplus.storedDplussTable, products.productsDplus.storedDplusParsTable, products.productsDplus.storedDplusParExtrasTable, products.productsDplus.storedDplusParDaughtersDummyTable, products.productsDplus.storedDplusSelsTable, products.productsDplus.storedDplusMlsTable, products.productsDplus.storedDplusMlDughtersDummyTable, products.productsDplus.storedDplusMcsTable); + products.productsDplus.storedDplusIdsTable(collisionMapping[collision.globalIndex()], trackMapping[DplusCandidate.prong0Id()], trackMapping[DplusCandidate.prong1Id()], trackMapping[DplusCandidate.prong2Id()]); } } } - template - void processDoDownscaling(T const& collisions) + template + void storeDstar(soa::Join::iterator const& collision, aod::JTracks const&, aod::CollisionsDstar const& DstarCollisions, T const& DstarCandidates) { - for (const auto& collision : collisions) { - if constexpr (std::is_same_v, aod::JCollisions>) { - if (collisionFlag[collision.globalIndex()] && randomNumber.Integer(config.downscaleFactor) != 0) { - collisionFlag[collision.globalIndex()] = false; - } + + if (collision.isCollisionSelected()) { + for (const auto& DstarCollision : DstarCollisions) { // should only ever be one + jethfutilities::fillHFCollisionTable(DstarCollision, products.productsDstar.storedDstarCollisionsTable); + products.productsDstar.storedDstarCollisionIdsTable(collisionMapping[collision.globalIndex()]); } - if constexpr (std::is_same_v, aod::JMcCollisions>) { - if (McCollisionFlag[collision.globalIndex()] && randomNumber.Integer(config.downscaleFactor) != 0) { - McCollisionFlag[collision.globalIndex()] = false; - } + for (const auto& DstarCandidate : DstarCandidates) { + jethfutilities::fillHFCandidateTable(DstarCandidate, products.productsDstar.storedDstarCollisionsTable.lastIndex(), products.productsDstar.storedDstarsTable, products.productsDstar.storedDstarParsTable, products.productsDstar.storedDstarParExtrasDummyTable, products.productsDstar.storedDstarParD0sTable, products.productsDstar.storedDstarSelsTable, products.productsDstar.storedDstarMlsTable, products.productsDstar.storedDstarMlDaughtersDummyTable, products.productsDstar.storedDstarMcsTable); + products.productsDstar.storedDstarIdsTable(collisionMapping[collision.globalIndex()], trackMapping[DstarCandidate.prong0Id()], trackMapping[DstarCandidate.prong1Id()], trackMapping[DstarCandidate.prong2Id()]); } } } - void processSetupEventTriggering(aod::JCollision const& collision) + template + void storeLc(soa::Join::iterator const& collision, aod::JTracks const&, aod::CollisionsLc const& LcCollisions, T const& LcCandidates) { - if (jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { - collisionFlag[collision.globalIndex()] = true; + if (collision.isCollisionSelected()) { + for (const auto& LcCollision : LcCollisions) { // should only ever be one + jethfutilities::fillHFCollisionTable(LcCollision, products.productsLc.storedLcCollisionsTable); + products.productsLc.storedLcCollisionIdsTable(collisionMapping[collision.globalIndex()]); + } + for (const auto& LcCandidate : LcCandidates) { + jethfutilities::fillHFCandidateTable(LcCandidate, products.productsLc.storedLcCollisionsTable.lastIndex(), products.productsLc.storedLcsTable, products.productsLc.storedLcParsTable, products.productsLc.storedLcParExtrasTable, products.productsLc.storedLcParDaughtersDummyTable, products.productsLc.storedLcSelsTable, products.productsLc.storedLcMlsTable, products.productsLc.storedLcMlDughtersDummyTable, products.productsLc.storedLcMcsTable); + products.productsLc.storedLcIdsTable(collisionMapping[collision.globalIndex()], trackMapping[LcCandidate.prong0Id()], trackMapping[LcCandidate.prong1Id()], trackMapping[LcCandidate.prong2Id()]); + } } } - void processDoCollisionSelections(aod::JCollision const& collision) - { // can also add event selection like sel8 but goes a little against the derived data idea - if (collision.centrality() < config.centralityMin || collision.centrality() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { - collisionFlag[collision.globalIndex()] = false; + template + void storeB0(soa::Join::iterator const& collision, aod::JTracks const&, aod::CollisionsB0 const& B0Collisions, T const& B0Candidates) + { + if (collision.isCollisionSelected()) { + for (const auto& B0Collision : B0Collisions) { // should only ever be one + jethfutilities::fillHFCollisionTable(B0Collision, products.productsB0.storedB0CollisionsTable); + products.productsB0.storedB0CollisionIdsTable(collisionMapping[collision.globalIndex()]); + } + for (const auto& B0Candidate : B0Candidates) { + jethfutilities::fillHFCandidateTable(B0Candidate, products.productsB0.storedB0CollisionsTable.lastIndex(), products.productsB0.storedB0sTable, products.productsB0.storedB0ParsTable, products.productsB0.storedB0ParExtrasTable, products.productsB0.storedB0ParDplussTable, products.productsB0.storedB0SelsTable, products.productsB0.storedB0MlsTable, products.productsB0.storedB0MlDplussTable, products.productsB0.storedB0McsTable); + products.productsB0.storedB0IdsTable(collisionMapping[collision.globalIndex()], trackMapping[B0Candidate.prong0Id()], trackMapping[B0Candidate.prong1Id()], trackMapping[B0Candidate.prong2Id()], trackMapping[B0Candidate.prong3Id()]); + } } } - template - void processSelectionObjects(T& selectionObjects) + template + void storeBplus(soa::Join::iterator const& collision, aod::JTracks const&, aod::CollisionsBplus const& BplusCollisions, T const& BplusCandidates) { - float selectionObjectPtMin = 0.0; - if constexpr (std::is_same_v, aod::ChargedJets> || std::is_same_v, aod::ChargedMCDetectorLevelJets>) { - selectionObjectPtMin = config.thresholdChargedJetPtMin; - } else if constexpr (std::is_same_v, aod::ChargedEventWiseSubtractedJets> || std::is_same_v, aod::ChargedMCDetectorLevelEventWiseSubtractedJets>) { - selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedJetPtMin; - } else if constexpr (std::is_same_v, aod::ChargedMCParticleLevelJets>) { - selectionObjectPtMin = config.thresholdChargedMCPJetPtMin; - } else if constexpr (std::is_same_v, aod::NeutralJets> || std::is_same_v, aod::NeutralMCDetectorLevelJets>) { - selectionObjectPtMin = config.thresholdNeutralJetPtMin; - } else if constexpr (std::is_same_v, aod::NeutralMCParticleLevelJets>) { - selectionObjectPtMin = config.thresholdNeutralMCPJetPtMin; - } else if constexpr (std::is_same_v, aod::FullJets> || std::is_same_v, aod::FullMCDetectorLevelJets>) { - selectionObjectPtMin = config.thresholdFullJetPtMin; - } else if constexpr (std::is_same_v, aod::FullMCParticleLevelJets>) { - selectionObjectPtMin = config.thresholdFullMCPJetPtMin; - } else if constexpr (std::is_same_v, aod::D0ChargedJets> || std::is_same_v, aod::D0ChargedMCDetectorLevelJets>) { - selectionObjectPtMin = config.thresholdChargedD0JetPtMin; - } else if constexpr (std::is_same_v, aod::D0ChargedEventWiseSubtractedJets> || std::is_same_v, aod::D0ChargedMCDetectorLevelEventWiseSubtractedJets>) { - selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedD0JetPtMin; - } else if constexpr (std::is_same_v, aod::D0ChargedMCParticleLevelJets>) { - selectionObjectPtMin = config.thresholdChargedD0MCPJetPtMin; - } else if constexpr (std::is_same_v, aod::LcChargedJets> || std::is_same_v, aod::LcChargedMCDetectorLevelJets>) { - selectionObjectPtMin = config.thresholdChargedLcJetPtMin; - } else if constexpr (std::is_same_v, aod::LcChargedEventWiseSubtractedJets> || std::is_same_v, aod::LcChargedMCDetectorLevelEventWiseSubtractedJets>) { - selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedLcJetPtMin; - } else if constexpr (std::is_same_v, aod::LcChargedMCParticleLevelJets>) { - selectionObjectPtMin = config.thresholdChargedLcMCPJetPtMin; - } else if constexpr (std::is_same_v, aod::BplusChargedJets> || std::is_same_v, aod::BplusChargedMCDetectorLevelJets>) { - selectionObjectPtMin = config.thresholdChargedBplusJetPtMin; - } else if constexpr (std::is_same_v, aod::BplusChargedEventWiseSubtractedJets> || std::is_same_v, aod::BplusChargedMCDetectorLevelEventWiseSubtractedJets>) { - selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedBplusJetPtMin; - } else if constexpr (std::is_same_v, aod::BplusChargedMCParticleLevelJets>) { - selectionObjectPtMin = config.thresholdChargedBplusMCPJetPtMin; - } else if constexpr (std::is_same_v, aod::DielectronChargedJets> || std::is_same_v, aod::DielectronChargedMCDetectorLevelJets>) { - selectionObjectPtMin = config.thresholdChargedDielectronJetPtMin; - } else if constexpr (std::is_same_v, aod::DielectronChargedEventWiseSubtractedJets> || std::is_same_v, aod::DielectronChargedMCDetectorLevelEventWiseSubtractedJets>) { - selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedDielectronJetPtMin; - } else if constexpr (std::is_same_v, aod::DielectronChargedMCParticleLevelJets>) { - selectionObjectPtMin = config.thresholdChargedDielectronMCPJetPtMin; - } else if constexpr (std::is_same_v, aod::JTracks>) { - selectionObjectPtMin = config.thresholdTriggerTrackPtMin; - } else if constexpr (std::is_same_v, aod::JClusters>) { - selectionObjectPtMin = config.thresholdClusterEnergyMin; - } else { - selectionObjectPtMin = 0.0; - } - for (const auto& selectionObject : selectionObjects) { - bool isTriggerObject = false; - if constexpr (std::is_same_v, aod::JClusters>) { - if (selectionObject.energy() >= selectionObjectPtMin) { - isTriggerObject = true; - } - } else { - if constexpr (std::is_same_v, aod::JTracks>) { - if (config.performTrackSelection && !(selectionObject.trackSel() & ~(1 << jetderiveddatautilities::JTrackSel::trackSign))) { - continue; - } - } - if (selectionObject.pt() >= selectionObjectPtMin) { - isTriggerObject = true; - } + if (collision.isCollisionSelected()) { + for (const auto& BplusCollision : BplusCollisions) { // should only ever be one + jethfutilities::fillHFCollisionTable(BplusCollision, products.productsBplus.storedBplusCollisionsTable); + products.productsBplus.storedBplusCollisionIdsTable(collisionMapping[collision.globalIndex()]); } - if (isTriggerObject) { - if constexpr (std::is_same_v, aod::ChargedMCParticleLevelJets> || std::is_same_v, aod::NeutralMCParticleLevelJets> || std::is_same_v, aod::FullMCParticleLevelJets> || std::is_same_v, aod::D0ChargedMCParticleLevelJets> || std::is_same_v, aod::LcChargedMCParticleLevelJets> || std::is_same_v, aod::BplusChargedMCParticleLevelJets> || std::is_same_v, aod::DielectronChargedMCParticleLevelJets>) { - if (selectionObject.mcCollisionId() >= 0) { - McCollisionFlag[selectionObject.mcCollisionId()] = true; - } - } else { - if (selectionObject.collisionId() >= 0) { - collisionFlag[selectionObject.collisionId()] = true; - } - } + for (const auto& BplusCandidate : BplusCandidates) { + jethfutilities::fillHFCandidateTable(BplusCandidate, products.productsBplus.storedBplusCollisionsTable.lastIndex(), products.productsBplus.storedBplussTable, products.productsBplus.storedBplusParsTable, products.productsBplus.storedBplusParExtrasTable, products.productsBplus.storedBplusParD0sTable, products.productsBplus.storedBplusSelsTable, products.productsBplus.storedBplusMlsTable, products.productsBplus.storedBplusMlD0sTable, products.productsBplus.storedBplusMcsTable); + products.productsBplus.storedBplusIdsTable(collisionMapping[collision.globalIndex()], trackMapping[BplusCandidate.prong0Id()], trackMapping[BplusCandidate.prong1Id()], trackMapping[BplusCandidate.prong2Id()]); } } } - // Todo : Check memory consumption of having so many Process Switches - PROCESS_SWITCH(JetDerivedDataWriter, processSetupCollisions, "setup the writing for data and MCD based on collisions", true); - PROCESS_SWITCH(JetDerivedDataWriter, processSetupMcCollisions, "setup the writing for MCP based on mcCollisions", false); - PROCESS_SWITCH(JetDerivedDataWriter, processSetupAllCollisionsWithDownscaling, "setup the writing of untriggered collisions with downscaling", false); - PROCESS_SWITCH(JetDerivedDataWriter, processSetupAllMcCollisionsWithDownscaling, "setup the writing of untriggered mccollisions with downscaling", false); - PROCESS_SWITCH(JetDerivedDataWriter, processSetupEventTriggering, "process software triggers", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingChargedJets, "process charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingChargedEventWiseSubtractedJets, "process charged event-wise subtracted jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingChargedMCDJets, "process charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingChargedMCDetectorLevelEventWiseSubtractedJets, "process charged event-wise subtracted mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingChargedMCPJets, "process charged mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingNeutralJets, "process neutral jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingNeutralMCDJets, "process neutral mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingNeutralMCPJets, "process neutral mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingFullJets, "process full jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingFullMCDJets, "process full mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingFullMCPJets, "process full mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingD0ChargedJets, "process D0 charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingD0ChargedEventWiseSubtractedJets, "process D0 event-wise subtracted charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingD0ChargedMCDJets, "process D0 charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingD0ChargedMCDetectorLevelEventWiseSubtractedJets, "process D0 event-wise subtracted charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingD0ChargedMCPJets, "process D0 charged mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingLcChargedJets, "process Lc charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingLcChargedEventWiseSubtractedJets, "process Lc event-wise subtracted charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingLcChargedMCDJets, "process Lc charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingLcChargedMCDetectorLevelEventWiseSubtractedJets, "process Lc event-wise subtracted charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingLcChargedMCPJets, "process Lc charged mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingBplusChargedJets, "process Bplus charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingBplusChargedEventWiseSubtractedJets, "process Bplus event-wise subtracted charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingBplusChargedMCDJets, "process Bplus charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingBplusChargedMCDetectorLevelEventWiseSubtractedJets, "process Bplus event-wise subtracted charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingBplusChargedMCPJets, "process Bplus charged mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingDielectronChargedJets, "process Dielectron charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingDielectronChargedEventWiseSubtractedJets, "process Dielectron event-wise subtracted charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingDielectronChargedMCDJets, "process Dielectron charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingDielectronChargedMCDetectorLevelEventWiseSubtractedJets, "process Dielectron event-wise subtracted charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingDielectronChargedMCPJets, "process Dielectron charged mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingClusters, "process EMCal clusters", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processSelectionObjects, processSelectingTracks, "process high pt tracks", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processDoDownscaling, processCollisionDownscaling, "process downsaling of triggered collisions", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processDoDownscaling, processMcCollisionDownscaling, "process downsaling of triggered mccollisions", false); - PROCESS_SWITCH(JetDerivedDataWriter, processDoCollisionSelections, "process event selections for saved events", false); - - void processStoreDummyTable(aod::JDummys const&) + + void processDummyTable(aod::JDummys const&) { products.storedJDummysTable(1); } - PROCESS_SWITCH(JetDerivedDataWriter, processStoreDummyTable, "write out dummy output table", true); - - void processStoreData(soa::Join::iterator const& collision, soa::Join const&, soa::Join const& tracks, aod::JEMCTracks const& emcTracks, soa::Join const& clusters, aod::CollisionsD0 const& D0Collisions, aod::CandidatesD0Data const& D0s, aod::CollisionsLc const& LcCollisions, aod::CandidatesLcData const& Lcs, aod::CollisionsBplus const& BplusCollisions, aod::CandidatesBplusData const& Bpluss, aod::CollisionsDielectron const& DielectronCollisions, aod::CandidatesDielectronData const& Dielectrons) + PROCESS_SWITCH(JetDerivedDataWriter, processDummyTable, "write out dummy output table", true); + + std::vector collisionMapping; + std::vector bcMapping; + std::vector trackMapping; + std::vector mcCollisionMapping; + std::vector particleMapping; + std::vector d0McCollisionMapping; + std::vector dplusMcCollisionMapping; + std::vector dstarMcCollisionMapping; + std::vector lcMcCollisionMapping; + std::vector b0McCollisionMapping; + std::vector bplusMcCollisionMapping; + std::vector dielectronMcCollisionMapping; + + void processBCs(soa::Join const& collisions, soa::Join const& bcs) { - std::map bcMapping; - std::map trackMapping; + std::vector bcIndicies; + bcMapping.clear(); + bcMapping.resize(bcs.size(), -1); - if (collisionFlag[collision.globalIndex()]) { - if (config.saveBCsTable) { + for (auto const& collision : collisions) { + if (collision.isCollisionSelected()) { auto bc = collision.bc_as>(); if (std::find(bcIndicies.begin(), bcIndicies.end(), bc.globalIndex()) == bcIndicies.end()) { products.storedJBCsTable(bc.runNumber(), bc.globalBC(), bc.timestamp(), bc.alias_raw(), bc.selection_raw()); products.storedJBCParentIndexTable(bc.bcId()); bcIndicies.push_back(bc.globalIndex()); - bcMapping.insert(std::make_pair(bc.globalIndex(), products.storedJBCsTable.lastIndex())); + bcMapping[bc.globalIndex()] = products.storedJBCsTable.lastIndex(); } } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processBCs, "write out output tables for Bunch crossings", true); - products.storedJCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multiplicity(), collision.centrality(), collision.trackOccupancyInTimeRange(), collision.eventSel(), collision.alias_raw(), collision.triggerSel()); - products.storedJCollisionsParentIndexTable(collision.collisionId()); - if (config.saveBCsTable) { - int32_t storedBCID = -1; - auto JBCIndex = bcMapping.find(collision.bcId()); - if (JBCIndex != bcMapping.end()) { - storedBCID = JBCIndex->second; - } - products.storedJCollisionsBunchCrossingIndexTable(storedBCID); - } - if (config.saveClustersTable) { - products.storedJCollisionsEMCalLabelTable(collision.isAmbiguous(), collision.isEmcalReadout()); - } + void processColllisons(soa::Join const& collisions) + { + collisionMapping.clear(); + collisionMapping.resize(collisions.size(), -1); - for (const auto& track : tracks) { - if (config.performTrackSelection && !(track.trackSel() & ~(1 << jetderiveddatautilities::JTrackSel::trackSign))) { // skips tracks that pass no selections. This might cause a problem with tracks matched with clusters. We should generate a track selection purely for cluster matched tracks so that they are kept. This includes also the track pT selction. - continue; - } - if (track.pt() < config.trackPtSelectionMin || std::abs(track.eta()) > config.trackEtaSelectionMax) { - continue; - } - products.storedJTracksTable(products.storedJCollisionsTable.lastIndex(), o2::math_utils::detail::truncateFloatFraction(track.pt(), precisionMomentumMask), o2::math_utils::detail::truncateFloatFraction(track.eta(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.phi(), precisionPositionMask), track.trackSel()); - products.storedJTracksExtraTable(o2::math_utils::detail::truncateFloatFraction(track.dcaX(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaXY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaXYZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigmadcaZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigmadcaXY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigmadcaXYZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigma1Pt(), precisionMomentumMask)); - products.storedJTracksParentIndexTable(track.trackId()); - trackMapping.insert(std::make_pair(track.globalIndex(), products.storedJTracksTable.lastIndex())); - } - if (config.saveClustersTable) { - for (const auto& cluster : clusters) { - products.storedJClustersTable(products.storedJCollisionsTable.lastIndex(), cluster.id(), cluster.energy(), cluster.coreEnergy(), cluster.rawEnergy(), - cluster.eta(), cluster.phi(), cluster.m02(), cluster.m20(), cluster.nCells(), cluster.time(), cluster.isExotic(), cluster.distanceToBadChannel(), - cluster.nlm(), cluster.definition(), cluster.leadingCellEnergy(), cluster.subleadingCellEnergy(), cluster.leadingCellNumber(), cluster.subleadingCellNumber()); - products.storedJClustersParentIndexTable(cluster.clusterId()); - - std::vector clusterStoredJTrackIDs; - for (const auto& clusterTrack : cluster.matchedTracks_as>()) { - auto JtrackIndex = trackMapping.find(clusterTrack.globalIndex()); - if (JtrackIndex != trackMapping.end()) { - clusterStoredJTrackIDs.push_back(JtrackIndex->second); - auto emcTracksPerTrack = emcTracks.sliceBy(EMCTrackPerTrack, clusterTrack.globalIndex()); - auto emcTrackPerTrack = emcTracksPerTrack.iteratorAt(0); - products.storedJTracksEMCalTable(JtrackIndex->second, emcTrackPerTrack.etaEmcal(), emcTrackPerTrack.phiEmcal()); - } - } - products.storedJClustersMatchedTracksTable(clusterStoredJTrackIDs); + for (auto const& collision : collisions) { + if (collision.isCollisionSelected()) { + + products.storedJCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), collision.centFV0A(), collision.centFV0M(), collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), collision.centFT0CVariant1(), collision.hadronicRate(), collision.trackOccupancyInTimeRange(), collision.eventSel(), collision.alias_raw(), collision.triggerSel()); + collisionMapping[collision.globalIndex()] = products.storedJCollisionsTable.lastIndex(); + products.storedJCollisionMcInfosTable(collision.weight(), collision.subGeneratorId()); + products.storedJCollisionsParentIndexTable(collision.collisionId()); + if (doprocessBCs) { + products.storedJCollisionsBunchCrossingIndexTable(bcMapping[collision.bcId()]); } } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processColllisons, "write out output tables for collisions", true); - if (config.saveD0Table) { - int32_t collisionD0Index = -1; - for (const auto& D0Collision : D0Collisions) { // should only ever be one - jethfutilities::fillHFCollisionTable(D0Collision, products.storedD0CollisionsTable, collisionD0Index); - products.storedD0CollisionIdsTable(products.storedJCollisionsTable.lastIndex()); - } - for (const auto& D0 : D0s) { - int32_t D0Index = -1; - jethfutilities::fillHFCandidateTable(D0, collisionD0Index, products.storedD0sTable, products.storedD0ParsTable, products.storedD0ParExtrasTable, products.storedD0ParDaughtersDummyTable, products.storedD0SelsTable, products.storedD0MlsTable, products.storedD0MlDughtersDummyTable, products.storedD0McsTable, D0Index); - - int32_t prong0Id = -1; - int32_t prong1Id = -1; - auto JtrackIndex = trackMapping.find(D0.prong0Id()); - if (JtrackIndex != trackMapping.end()) { - prong0Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(D0.prong1Id()); - if (JtrackIndex != trackMapping.end()) { - prong1Id = JtrackIndex->second; + void processTracks(soa::Join const& collisions, soa::Join const& tracks) + { + trackMapping.clear(); + trackMapping.resize(tracks.size(), -1); + + for (auto const& collision : collisions) { + if (collision.isCollisionSelected()) { + const auto tracksPerCollision = tracks.sliceBy(preslices.TracksPerCollision, collision.globalIndex()); + for (const auto& track : tracksPerCollision) { + if (!trackSelection(track)) { // skips tracks that pass no selections. This might cause a problem with tracks matched with clusters. We should generate a track selection purely for cluster matched tracks so that they are kept. This includes also the track pT selction. + continue; } - products.storedD0IdsTable(products.storedJCollisionsTable.lastIndex(), prong0Id, prong1Id); + products.storedJTracksTable(collisionMapping[collision.globalIndex()], o2::math_utils::detail::truncateFloatFraction(track.pt(), precisionMomentumMask), o2::math_utils::detail::truncateFloatFraction(track.eta(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.phi(), precisionPositionMask), track.trackSel()); + products.storedJTracksExtraTable(o2::math_utils::detail::truncateFloatFraction(track.dcaX(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaXY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaXYZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigmadcaZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigmadcaXY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigmadcaXYZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigma1Pt(), precisionMomentumMask)); + products.storedJTracksParentIndexTable(track.trackId()); + trackMapping[track.globalIndex()] = products.storedJTracksTable.lastIndex(); } } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processTracks, "write out output tables for tracks", true); - if (config.saveLcTable) { - int32_t collisionLcIndex = -1; - for (const auto& LcCollision : LcCollisions) { // should only ever be one - jethfutilities::fillHFCollisionTable(LcCollision, products.storedLcCollisionsTable, collisionLcIndex); - products.storedLcCollisionIdsTable(products.storedJCollisionsTable.lastIndex()); - } - for (const auto& Lc : Lcs) { - int32_t LcIndex = -1; - jethfutilities::fillHFCandidateTable(Lc, collisionLcIndex, products.storedLcsTable, products.storedLcParsTable, products.storedLcParExtrasTable, products.storedLcParDaughtersDummyTable, products.storedLcSelsTable, products.storedLcMlsTable, products.storedLcMlDughtersDummyTable, products.storedLcMcsTable, LcIndex); - - int32_t prong0Id = -1; - int32_t prong1Id = -1; - int32_t prong2Id = -1; - auto JtrackIndex = trackMapping.find(Lc.prong0Id()); - if (JtrackIndex != trackMapping.end()) { - prong0Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Lc.prong1Id()); - if (JtrackIndex != trackMapping.end()) { - prong1Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Lc.prong2Id()); - if (JtrackIndex != trackMapping.end()) { - prong2Id = JtrackIndex->second; - } - products.storedLcIdsTable(products.storedJCollisionsTable.lastIndex(), prong0Id, prong1Id, prong2Id); - } + void processClusters(soa::Join::iterator const& collision, aod::JTracks const&, aod::JEMCTracks const& emcTracks, soa::Join const& clusters) + { + if (collision.isCollisionSelected()) { + products.storedJCollisionsEMCalLabelTable(collision.isAmbiguous(), collision.isEmcalReadout()); + for (const auto& cluster : clusters) { + products.storedJClustersTable(collisionMapping[collision.globalIndex()], cluster.id(), cluster.energy(), cluster.coreEnergy(), cluster.rawEnergy(), + cluster.eta(), cluster.phi(), cluster.m02(), cluster.m20(), cluster.nCells(), cluster.time(), cluster.isExotic(), cluster.distanceToBadChannel(), + cluster.nlm(), cluster.definition(), cluster.leadingCellEnergy(), cluster.subleadingCellEnergy(), cluster.leadingCellNumber(), cluster.subleadingCellNumber()); + products.storedJClustersCorrectedEnergiesTable(cluster.energyCorrectedOneTrack1(), cluster.energyCorrectedOneTrack2(), cluster.energyCorrectedAllTracks1(), cluster.energyCorrectedAllTracks2()); + products.storedJClustersParentIndexTable(cluster.clusterId()); + + std::vector clusterStoredJTrackIDs; + for (const auto& clusterTrack : cluster.matchedTracks_as()) { + clusterStoredJTrackIDs.push_back(trackMapping[clusterTrack.globalIndex()]); + auto emcTracksPerTrack = emcTracks.sliceBy(preslices.EMCTrackPerTrack, clusterTrack.globalIndex()); + auto emcTrackPerTrack = emcTracksPerTrack.iteratorAt(0); + products.storedJTracksEMCalTable(trackMapping[clusterTrack.globalIndex()], emcTrackPerTrack.etaEmcal(), emcTrackPerTrack.phiEmcal()); + } + products.storedJClustersMatchedTracksTable(clusterStoredJTrackIDs); } - if (config.saveBplusTable) { - int32_t collisionBplusIndex = -1; - for (const auto& BplusCollision : BplusCollisions) { // should only ever be one - jethfutilities::fillHFCollisionTable(BplusCollision, products.storedBplusCollisionsTable, collisionBplusIndex); - products.storedBplusCollisionIdsTable(products.storedJCollisionsTable.lastIndex()); - } - for (const auto& Bplus : Bpluss) { - int32_t BplusIndex = -1; - jethfutilities::fillHFCandidateTable(Bplus, collisionBplusIndex, products.storedBplussTable, products.storedBplusParsTable, products.storedBplusParExtrasTable, products.storedBplusParD0sTable, products.storedBplusSelsTable, products.storedBplusMlsTable, products.storedBplusMlD0sTable, products.storedBplusMcsTable, BplusIndex); - - int32_t prong0Id = -1; - int32_t prong1Id = -1; - int32_t prong2Id = -1; - auto JtrackIndex = trackMapping.find(Bplus.prong0Id()); - if (JtrackIndex != trackMapping.end()) { - prong0Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Bplus.prong1Id()); - if (JtrackIndex != trackMapping.end()) { - prong1Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Bplus.prong2Id()); - if (JtrackIndex != trackMapping.end()) { - prong2Id = JtrackIndex->second; - } - products.storedBplusIdsTable(products.storedJCollisionsTable.lastIndex(), prong0Id, prong1Id, prong2Id); - } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processClusters, "write out output tables for clusters", false); + + //!!!!!!!!!! need to add the hadronic corrected energy and delete the new dummy process function + + void processD0Data(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsD0 const& D0Collisions, aod::CandidatesD0Data const& D0Candidates) + { + storeD0(collision, tracks, D0Collisions, D0Candidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processD0Data, "write out data output tables for D0", false); + + void processD0MCD(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsD0 const& D0Collisions, aod::CandidatesD0MCD const& D0Candidates) + { + storeD0(collision, tracks, D0Collisions, D0Candidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processD0MCD, "write out mcd output tables for D0", false); + + void processDplusData(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsDplus const& DplusCollisions, aod::CandidatesDplusData const& DplusCandidates) + { + storeDplus(collision, tracks, DplusCollisions, DplusCandidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processDplusData, "write out data output tables for Dplus", false); + + void processDplusMCD(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsDplus const& DplusCollisions, aod::CandidatesDplusMCD const& DplusCandidates) + { + storeDplus(collision, tracks, DplusCollisions, DplusCandidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processDplusMCD, "write out mcd output tables for Dplus", false); + + void processDstarData(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsDstar const& DstarCollisions, aod::CandidatesDstarData const& DstarCandidates) + { + storeDstar(collision, tracks, DstarCollisions, DstarCandidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processDstarData, "write out data output tables for Dstar", false); + + void processDstarMCD(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsDstar const& DstarCollisions, aod::CandidatesDstarMCD const& DstarCandidates) + { + storeDstar(collision, tracks, DstarCollisions, DstarCandidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processDstarMCD, "write out mcd output tables for Dstar", false); + + void processLcData(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsLc const& LcCollisions, aod::CandidatesLcData const& LcCandidates) + { + storeLc(collision, tracks, LcCollisions, LcCandidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processLcData, "write out data output tables for Lc", false); + + void processLcMCD(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsLc const& LcCollisions, aod::CandidatesLcMCD const& LcCandidates) + { + storeLc(collision, tracks, LcCollisions, LcCandidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processLcMCD, "write out mcd output tables for Lc", false); + + void processB0Data(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsB0 const& B0Collisions, aod::CandidatesB0Data const& B0Candidates) + { + storeB0(collision, tracks, B0Collisions, B0Candidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processB0Data, "write out data output tables for B0", false); + + void processB0MCD(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsB0 const& B0Collisions, aod::CandidatesB0MCD const& B0Candidates) + { + storeB0(collision, tracks, B0Collisions, B0Candidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processB0MCD, "write out mcd output tables for B0", false); + + void processBplusData(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsBplus const& BplusCollisions, aod::CandidatesBplusData const& BplusCandidates) + { + storeBplus(collision, tracks, BplusCollisions, BplusCandidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processBplusData, "write out data output tables for bplus", false); + + void processBplusMCD(soa::Join::iterator const& collision, aod::JTracks const& tracks, aod::CollisionsBplus const& BplusCollisions, aod::CandidatesBplusMCD const& BplusCandidates) + { + storeBplus(collision, tracks, BplusCollisions, BplusCandidates); + } + PROCESS_SWITCH(JetDerivedDataWriter, processBplusMCD, "write out mcd output tables for bplus", false); + + void processDielectron(soa::Join::iterator const& collision, aod::JTracks const&, aod::CollisionsDielectron const& DielectronCollisions, aod::CandidatesDielectronData const& DielectronCandidates) + { + if (collision.isCollisionSelected()) { + for (const auto& DielectronCollision : DielectronCollisions) { // should only ever be one + jetdqutilities::fillDielectronCollisionTable(DielectronCollision, products.productsDielectron.storedDielectronCollisionsTable); + products.productsDielectron.storedDielectronCollisionIdsTable(collisionMapping[collision.globalIndex()]); } - if (config.saveDielectronTable) { - int32_t collisionDielectronIndex = -1; - for (const auto& DielectronCollision : DielectronCollisions) { // should only ever be one - jetdqutilities::fillDielectronCollisionTable(DielectronCollision, products.storedDielectronCollisionsTable, collisionDielectronIndex); - products.storedDielectronCollisionIdsTable(products.storedJCollisionsTable.lastIndex()); - } - for (const auto& Dielectron : Dielectrons) { - int32_t DielectronIndex = -1; - jetdqutilities::fillDielectronCandidateTable(Dielectron, collisionDielectronIndex, products.storedDielectronsTable, DielectronIndex); - - int32_t prong0Id = -1; - int32_t prong1Id = -1; - auto JtrackIndex = trackMapping.find(Dielectron.prong0Id()); - if (JtrackIndex != trackMapping.end()) { - prong0Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Dielectron.prong1Id()); - if (JtrackIndex != trackMapping.end()) { - prong1Id = JtrackIndex->second; - } - products.storedDielectronIdsTable(products.storedJCollisionsTable.lastIndex(), prong0Id, prong1Id); - } + for (const auto& DielectronCandidate : DielectronCandidates) { + jetdqutilities::fillDielectronCandidateTable(DielectronCandidate, products.productsDielectron.storedDielectronCollisionsTable.lastIndex(), products.productsDielectron.storedDielectronsTable); + products.productsDielectron.storedDielectronIdsTable(collisionMapping[collision.globalIndex()], trackMapping[DielectronCandidate.prong0Id()], trackMapping[DielectronCandidate.prong1Id()]); } } } - // process switch for output writing must be last - // to run after all jet selections - PROCESS_SWITCH(JetDerivedDataWriter, processStoreData, "write out data output tables", false); + PROCESS_SWITCH(JetDerivedDataWriter, processDielectron, "write out data output tables for dielectrons", false); - void processStoreMC(soa::Join const& mcCollisions, soa::Join const& collisions, soa::Join const&, soa::Join const& tracks, aod::JEMCTracks const& emcTracks, soa::Join const& clusters, soa::Join const& particles, aod::CollisionsD0 const& D0Collisions, aod::CandidatesD0MCD const& D0s, soa::Join const& D0McCollisions, aod::CandidatesD0MCP const& D0Particles, aod::CollisionsLc const& LcCollisions, aod::CandidatesLcMCD const& Lcs, soa::Join const& LcMcCollisions, aod::CandidatesLcMCP const& LcParticles, aod::CollisionsBplus const& BplusCollisions, aod::CandidatesBplusMCD const& Bpluss, soa::Join const& BplusMcCollisions, aod::CandidatesBplusMCP const& BplusParticles, aod::CollisionsDielectron const& DielectronCollisions, aod::CandidatesDielectronMCD const& Dielectrons, aod::McCollisionsDielectron const& DielectronMcCollisions, aod::CandidatesDielectronMCP const& DielectronParticles) + void processMcCollisions(soa::Join const& mcCollisions) { - std::map bcMapping; - std::map paticleMapping; - std::map mcCollisionMapping; - std::map D0CollisionMapping; - std::map LcCollisionMapping; - std::map BplusCollisionMapping; - int particleTableIndex = 0; - for (auto mcCollision : mcCollisions) { - bool collisionSelected = false; - const auto collisionsPerMcCollision = collisions.sliceBy(CollisionsPerMcCollision, mcCollision.globalIndex()); - for (auto collision : collisionsPerMcCollision) { - if (collisionFlag[collision.globalIndex()]) { - collisionSelected = true; - } + mcCollisionMapping.clear(); + mcCollisionMapping.resize(mcCollisions.size(), -1); + for (auto const& mcCollision : mcCollisions) { + if (mcCollision.isMcCollisionSelected()) { + products.storedJMcCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.multFV0A(), mcCollision.multFT0A(), mcCollision.multFT0C(), mcCollision.centFV0A(), mcCollision.centFT0A(), mcCollision.centFT0C(), mcCollision.centFT0M(), mcCollision.weight(), mcCollision.subGeneratorId(), mcCollision.accepted(), mcCollision.attempted(), mcCollision.xsectGen(), mcCollision.xsectErr(), mcCollision.ptHard()); + products.storedJMcCollisionsParentIndexTable(mcCollision.mcCollisionId()); + mcCollisionMapping[mcCollision.globalIndex()] = products.storedJMcCollisionsTable.lastIndex(); } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processMcCollisions, "write out mcCollision output tables", false); - if (McCollisionFlag[mcCollision.globalIndex()] || collisionSelected) { - - const auto particlesPerMcCollision = particles.sliceBy(ParticlesPerMcCollision, mcCollision.globalIndex()); + void processMcParticles(soa::Join const& mcCollisions, soa::Join const& particles) + { + particleMapping.clear(); + particleMapping.resize(particles.size(), -1); + int particleTableIndex = 0; + for (auto const& mcCollision : mcCollisions) { + if (mcCollision.isMcCollisionSelected()) { - products.storedJMcCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.weight()); - products.storedJMcCollisionsParentIndexTable(mcCollision.mcCollisionId()); - mcCollisionMapping.insert(std::make_pair(mcCollision.globalIndex(), products.storedJMcCollisionsTable.lastIndex())); + const auto particlesPerMcCollision = particles.sliceBy(preslices.ParticlesPerMcCollision, mcCollision.globalIndex()); for (auto particle : particlesPerMcCollision) { - paticleMapping.insert(std::make_pair(particle.globalIndex(), particleTableIndex)); + particleMapping[particle.globalIndex()] = particleTableIndex; particleTableIndex++; } for (auto particle : particlesPerMcCollision) { - std::vector mothersId; + std::vector mothersIds; if (particle.has_mothers()) { auto mothersIdTemps = particle.mothersIds(); for (auto mothersIdTemp : mothersIdTemps) { - - auto JMotherIndex = paticleMapping.find(mothersIdTemp); - if (JMotherIndex != paticleMapping.end()) { - mothersId.push_back(JMotherIndex->second); - } + mothersIds.push_back(particleMapping[mothersIdTemp]); } } - int daughtersId[2] = {-1, -1}; + int daughtersIds[2] = {-1, -1}; auto i = 0; if (particle.has_daughters()) { for (auto daughterId : particle.daughtersIds()) { if (i > 1) { break; } - auto JDaughterIndex = paticleMapping.find(daughterId); - if (JDaughterIndex != paticleMapping.end()) { - daughtersId[i] = JDaughterIndex->second; - } + daughtersIds[i] = particleMapping[daughterId]; i++; } } - products.storedJMcParticlesTable(products.storedJMcCollisionsTable.lastIndex(), o2::math_utils::detail::truncateFloatFraction(particle.pt(), precisionMomentumMask), o2::math_utils::detail::truncateFloatFraction(particle.eta(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(particle.phi(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(particle.y(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(particle.e(), precisionMomentumMask), particle.pdgCode(), particle.getGenStatusCode(), particle.getHepMCStatusCode(), particle.isPhysicalPrimary(), mothersId, daughtersId); + products.storedJMcParticlesTable(mcCollisionMapping[mcCollision.globalIndex()], o2::math_utils::detail::truncateFloatFraction(particle.pt(), precisionMomentumMask), o2::math_utils::detail::truncateFloatFraction(particle.eta(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(particle.phi(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(particle.y(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(particle.e(), precisionMomentumMask), particle.pdgCode(), particle.getGenStatusCode(), particle.getHepMCStatusCode(), particle.isPhysicalPrimary(), mothersIds, daughtersIds); products.storedJParticlesParentIndexTable(particle.mcParticleId()); } + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processMcParticles, "write out mcParticle output tables", false); - if (config.saveD0Table) { - const auto d0McCollisionsPerMcCollision = D0McCollisions.sliceBy(D0McCollisionsPerMcCollision, mcCollision.globalIndex()); - int32_t mcCollisionD0Index = -1; - for (const auto& d0McCollisionPerMcCollision : d0McCollisionsPerMcCollision) { // should only ever be one - jethfutilities::fillHFMcCollisionTable(d0McCollisionPerMcCollision, products.storedD0McCollisionsTable, mcCollisionD0Index); - products.storedD0McCollisionIdsTable(products.storedJMcCollisionsTable.lastIndex()); - } - for (const auto& D0Particle : D0Particles) { - int32_t D0ParticleIndex = -1; - jethfutilities::fillHFCandidateMcTable(D0Particle, mcCollisionD0Index, products.storedD0ParticlesTable, D0ParticleIndex); - int32_t D0ParticleId = -1; - auto JParticleIndex = paticleMapping.find(D0Particle.mcParticleId()); - if (JParticleIndex != paticleMapping.end()) { - D0ParticleId = JParticleIndex->second; - } - products.storedD0ParticleIdsTable(products.storedJMcCollisionsTable.lastIndex(), D0ParticleId); - } + void processD0MCP(soa::Join const& mcCollisions, aod::McCollisionsD0 const& D0McCollisions, aod::CandidatesD0MCP const& D0Particles) + { + d0McCollisionMapping.clear(); + d0McCollisionMapping.resize(D0McCollisions.size(), -1); + for (auto const& mcCollision : mcCollisions) { + if (mcCollision.isMcCollisionSelected()) { + const auto d0McCollisionsPerMcCollision = D0McCollisions.sliceBy(preslices.D0McCollisionsPerMcCollision, mcCollision.globalIndex()); + for (const auto& d0McCollisionPerMcCollision : d0McCollisionsPerMcCollision) { + jethfutilities::fillHFMcCollisionTable(d0McCollisionPerMcCollision, products.productsD0.storedD0McCollisionsTable); + products.productsD0.storedD0McCollisionIdsTable(mcCollisionMapping[mcCollision.globalIndex()]); + d0McCollisionMapping[d0McCollisionPerMcCollision.globalIndex()] = products.productsD0.storedD0McCollisionsTable.lastIndex(); + } + const auto d0ParticlesPerMcCollision = D0Particles.sliceBy(preslices.D0ParticlesPerMcCollision, mcCollision.globalIndex()); + for (const auto& D0Particle : d0ParticlesPerMcCollision) { + jethfutilities::fillHFCandidateMcTable(D0Particle, products.productsD0.storedD0McCollisionsTable.lastIndex(), products.productsD0.storedD0ParticlesTable); + products.productsD0.storedD0ParticleIdsTable(mcCollisionMapping[mcCollision.globalIndex()], particleMapping[D0Particle.mcParticleId()]); } + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processD0MCP, "write out D0 mcp output tables", false); - if (config.saveLcTable) { - const auto lcMcCollisionsPerMcCollision = LcMcCollisions.sliceBy(LcMcCollisionsPerMcCollision, mcCollision.globalIndex()); - int32_t mcCollisionLcIndex = -1; - for (const auto& lcMcCollisionPerMcCollision : lcMcCollisionsPerMcCollision) { // should only ever be one - jethfutilities::fillHFMcCollisionTable(lcMcCollisionPerMcCollision, products.storedLcMcCollisionsTable, mcCollisionLcIndex); - products.storedLcMcCollisionIdsTable(products.storedJMcCollisionsTable.lastIndex()); - } - for (const auto& LcParticle : LcParticles) { - int32_t LcParticleIndex = -1; - jethfutilities::fillHFCandidateMcTable(LcParticle, mcCollisionLcIndex, products.storedLcParticlesTable, LcParticleIndex); - int32_t LcParticleId = -1; - auto JParticleIndex = paticleMapping.find(LcParticle.mcParticleId()); - if (JParticleIndex != paticleMapping.end()) { - LcParticleId = JParticleIndex->second; - } - products.storedLcParticleIdsTable(products.storedJMcCollisionsTable.lastIndex(), LcParticleId); - } - } - if (config.saveBplusTable) { - const auto lcMcCollisionsPerMcCollision = BplusMcCollisions.sliceBy(BplusMcCollisionsPerMcCollision, mcCollision.globalIndex()); - int32_t mcCollisionBplusIndex = -1; - for (const auto& lcMcCollisionPerMcCollision : lcMcCollisionsPerMcCollision) { // should only ever be one - jethfutilities::fillHFMcCollisionTable(lcMcCollisionPerMcCollision, products.storedBplusMcCollisionsTable, mcCollisionBplusIndex); - products.storedBplusMcCollisionIdsTable(products.storedJMcCollisionsTable.lastIndex()); - } - for (const auto& BplusParticle : BplusParticles) { - int32_t BplusParticleIndex = -1; - jethfutilities::fillHFCandidateMcTable(BplusParticle, mcCollisionBplusIndex, products.storedBplusParticlesTable, BplusParticleIndex); - int32_t BplusParticleId = -1; - auto JParticleIndex = paticleMapping.find(BplusParticle.mcParticleId()); - if (JParticleIndex != paticleMapping.end()) { - BplusParticleId = JParticleIndex->second; - } - products.storedBplusParticleIdsTable(products.storedJMcCollisionsTable.lastIndex(), BplusParticleId); - } + void processDplusMCP(soa::Join const& mcCollisions, aod::McCollisionsDplus const& DplusMcCollisions, aod::CandidatesDplusMCP const& DplusParticles) + { + dplusMcCollisionMapping.clear(); + dplusMcCollisionMapping.resize(DplusMcCollisions.size(), -1); + for (auto const& mcCollision : mcCollisions) { + if (mcCollision.isMcCollisionSelected()) { + const auto dplusMcCollisionsPerMcCollision = DplusMcCollisions.sliceBy(preslices.DplusMcCollisionsPerMcCollision, mcCollision.globalIndex()); + for (const auto& dplusMcCollisionPerMcCollision : dplusMcCollisionsPerMcCollision) { // should only ever be one + jethfutilities::fillHFMcCollisionTable(dplusMcCollisionPerMcCollision, products.productsDplus.storedDplusMcCollisionsTable); + products.productsDplus.storedDplusMcCollisionIdsTable(mcCollisionMapping[mcCollision.globalIndex()]); + dplusMcCollisionMapping[dplusMcCollisionPerMcCollision.globalIndex()] = products.productsDplus.storedDplusMcCollisionsTable.lastIndex(); + } + const auto dplusParticlesPerMcCollision = DplusParticles.sliceBy(preslices.DplusParticlesPerMcCollision, mcCollision.globalIndex()); + for (const auto& DplusParticle : dplusParticlesPerMcCollision) { + jethfutilities::fillHFCandidateMcTable(DplusParticle, products.productsDplus.storedDplusMcCollisionsTable.lastIndex(), products.productsDplus.storedDplusParticlesTable); + products.productsDplus.storedDplusParticleIdsTable(mcCollisionMapping[mcCollision.globalIndex()], particleMapping[DplusParticle.mcParticleId()]); } - if (config.saveDielectronTable) { - const auto dielectronMcCollisionsPerMcCollision = DielectronMcCollisions.sliceBy(DielectronMcCollisionsPerMcCollision, mcCollision.globalIndex()); - int32_t mcCollisionDielectronIndex = -1; - for (const auto& dielectronMcCollisionPerMcCollision : dielectronMcCollisionsPerMcCollision) { // should only ever be one - jetdqutilities::fillDielectronMcCollisionTable(dielectronMcCollisionPerMcCollision, products.storedDielectronMcCollisionsTable, mcCollisionDielectronIndex); - products.storedDielectronMcCollisionIdsTable(products.storedJMcCollisionsTable.lastIndex()); - } - for (const auto& DielectronParticle : DielectronParticles) { - int32_t DielectronParticleIndex = -1; - jetdqutilities::fillDielectronCandidateMcTable(DielectronParticle, mcCollisionDielectronIndex, products.storedDielectronParticlesTable, DielectronParticleIndex); - int32_t DielectronParticleId = -1; - auto JParticleIndex = paticleMapping.find(DielectronParticle.mcParticleId()); - if (JParticleIndex != paticleMapping.end()) { - DielectronParticleId = JParticleIndex->second; - } - std::vector DielectronMothersId; - int DielectronDaughtersId[2]; - if (DielectronParticle.has_mothers()) { - for (auto const& DielectronMother : DielectronParticle.template mothers_as>()) { - auto JDielectronMotherIndex = paticleMapping.find(DielectronMother.globalIndex()); - if (JDielectronMotherIndex != paticleMapping.end()) { - DielectronMothersId.push_back(JDielectronMotherIndex->second); - } - } - } - auto i = 0; - if (DielectronParticle.has_daughters()) { - for (auto const& DielectronDaughter : DielectronParticle.template daughters_as>()) { - if (i > 1) { - break; - } - auto JDielectronDaughterIndex = paticleMapping.find(DielectronDaughter.globalIndex()); - if (JDielectronDaughterIndex != paticleMapping.end()) { - DielectronDaughtersId[i] = JDielectronDaughterIndex->second; - } - i++; - } - } - products.storedDielectronParticleIdsTable(products.storedJMcCollisionsTable.lastIndex(), DielectronParticleId, DielectronMothersId, DielectronDaughtersId); - } + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processDplusMCP, "write out Dplus mcp output tables", false); + + void processDstarMCP(soa::Join const& mcCollisions, aod::McCollisionsDstar const& DstarMcCollisions, aod::CandidatesDstarMCP const& DstarParticles) + { + dstarMcCollisionMapping.clear(); + dstarMcCollisionMapping.resize(DstarMcCollisions.size(), -1); + for (auto const& mcCollision : mcCollisions) { + if (mcCollision.isMcCollisionSelected()) { + const auto dstarMcCollisionsPerMcCollision = DstarMcCollisions.sliceBy(preslices.DstarMcCollisionsPerMcCollision, mcCollision.globalIndex()); + for (const auto& dstarMcCollisionPerMcCollision : dstarMcCollisionsPerMcCollision) { + jethfutilities::fillHFMcCollisionTable(dstarMcCollisionPerMcCollision, products.productsDstar.storedDstarMcCollisionsTable); + products.productsDstar.storedDstarMcCollisionIdsTable(mcCollisionMapping[mcCollision.globalIndex()]); + dstarMcCollisionMapping[dstarMcCollisionPerMcCollision.globalIndex()] = products.productsDstar.storedDstarMcCollisionsTable.lastIndex(); + } + const auto dstarParticlesPerMcCollision = DstarParticles.sliceBy(preslices.DstarParticlesPerMcCollision, mcCollision.globalIndex()); + for (const auto& DstarParticle : dstarParticlesPerMcCollision) { + jethfutilities::fillHFCandidateMcTable(DstarParticle, products.productsDstar.storedDstarMcCollisionsTable.lastIndex(), products.productsDstar.storedDstarParticlesTable); + products.productsDstar.storedDstarParticleIdsTable(mcCollisionMapping[mcCollision.globalIndex()], particleMapping[DstarParticle.mcParticleId()]); } } } + } + PROCESS_SWITCH(JetDerivedDataWriter, processDstarMCP, "write out D* mcp output tables", false); - for (auto mcCollision : mcCollisions) { - bool collisionSelected = false; - const auto collisionsPerMcCollision = collisions.sliceBy(CollisionsPerMcCollision, mcCollision.globalIndex()); - for (auto collision : collisionsPerMcCollision) { - if (collisionFlag[collision.globalIndex()]) { - collisionSelected = true; + void processLcMCP(soa::Join const& mcCollisions, aod::McCollisionsLc const& LcMcCollisions, aod::CandidatesLcMCP const& LcParticles) + { + lcMcCollisionMapping.clear(); + lcMcCollisionMapping.resize(LcMcCollisions.size(), -1); + for (auto const& mcCollision : mcCollisions) { + if (mcCollision.isMcCollisionSelected()) { + const auto lcMcCollisionsPerMcCollision = LcMcCollisions.sliceBy(preslices.LcMcCollisionsPerMcCollision, mcCollision.globalIndex()); + for (const auto& lcMcCollisionPerMcCollision : lcMcCollisionsPerMcCollision) { // should only ever be one + jethfutilities::fillHFMcCollisionTable(lcMcCollisionPerMcCollision, products.productsLc.storedLcMcCollisionsTable); + products.productsLc.storedLcMcCollisionIdsTable(mcCollisionMapping[mcCollision.globalIndex()]); + lcMcCollisionMapping[lcMcCollisionPerMcCollision.globalIndex()] = products.productsLc.storedLcMcCollisionsTable.lastIndex(); + } + const auto lcParticlesPerMcCollision = LcParticles.sliceBy(preslices.LcParticlesPerMcCollision, mcCollision.globalIndex()); + for (const auto& LcParticle : lcParticlesPerMcCollision) { + jethfutilities::fillHFCandidateMcTable(LcParticle, products.productsLc.storedLcMcCollisionsTable.lastIndex(), products.productsLc.storedLcParticlesTable); + products.productsLc.storedLcParticleIdsTable(mcCollisionMapping[mcCollision.globalIndex()], particleMapping[LcParticle.mcParticleId()]); } } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processLcMCP, "write out Lc mcp output tables", false); - if (McCollisionFlag[mcCollision.globalIndex()] || collisionSelected) { - - for (auto collision : collisionsPerMcCollision) { - std::map trackMapping; - if (config.saveBCsTable) { - auto bc = collision.bc_as>(); - if (std::find(bcIndicies.begin(), bcIndicies.end(), bc.globalIndex()) == bcIndicies.end()) { - products.storedJBCsTable(bc.runNumber(), bc.globalBC(), bc.timestamp(), bc.alias_raw(), bc.selection_raw()); - products.storedJBCParentIndexTable(bc.bcId()); - bcIndicies.push_back(bc.globalIndex()); - bcMapping.insert(std::make_pair(bc.globalIndex(), products.storedJBCsTable.lastIndex())); - } - } + void processB0MCP(soa::Join const& mcCollisions, aod::McCollisionsB0 const& B0McCollisions, aod::CandidatesB0MCP const& B0Particles) + { + b0McCollisionMapping.clear(); + b0McCollisionMapping.resize(B0McCollisions.size(), -1); + for (auto const& mcCollision : mcCollisions) { + if (mcCollision.isMcCollisionSelected()) { + const auto b0McCollisionsPerMcCollision = B0McCollisions.sliceBy(preslices.B0McCollisionsPerMcCollision, mcCollision.globalIndex()); + for (const auto& b0McCollisionPerMcCollision : b0McCollisionsPerMcCollision) { // should only ever be one + jethfutilities::fillHFMcCollisionTable(b0McCollisionPerMcCollision, products.productsB0.storedB0McCollisionsTable); + products.productsB0.storedB0McCollisionIdsTable(mcCollisionMapping[mcCollision.globalIndex()]); + b0McCollisionMapping[b0McCollisionPerMcCollision.globalIndex()] = products.productsB0.storedB0McCollisionsTable.lastIndex(); + } + const auto b0ParticlesPerMcCollision = B0Particles.sliceBy(preslices.B0ParticlesPerMcCollision, mcCollision.globalIndex()); + for (const auto& B0Particle : b0ParticlesPerMcCollision) { + jethfutilities::fillHFCandidateMcTable(B0Particle, products.productsB0.storedB0McCollisionsTable.lastIndex(), products.productsB0.storedB0ParticlesTable); + products.productsB0.storedB0ParticleIdsTable(mcCollisionMapping[mcCollision.globalIndex()], particleMapping[B0Particle.mcParticleId()]); + } + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processB0MCP, "write out B0 mcp output tables", false); - products.storedJCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multiplicity(), collision.centrality(), collision.trackOccupancyInTimeRange(), collision.eventSel(), collision.alias_raw(), collision.triggerSel()); - products.storedJCollisionsParentIndexTable(collision.collisionId()); + void processBplusMCP(soa::Join const& mcCollisions, aod::McCollisionsBplus const& BplusMcCollisions, aod::CandidatesBplusMCP const& BplusParticles) + { + bplusMcCollisionMapping.clear(); + bplusMcCollisionMapping.resize(BplusMcCollisions.size(), -1); + for (auto const& mcCollision : mcCollisions) { + if (mcCollision.isMcCollisionSelected()) { + const auto bplusMcCollisionsPerMcCollision = BplusMcCollisions.sliceBy(preslices.BplusMcCollisionsPerMcCollision, mcCollision.globalIndex()); + for (const auto& bplusMcCollisionPerMcCollision : bplusMcCollisionsPerMcCollision) { // should only ever be one + jethfutilities::fillHFMcCollisionTable(bplusMcCollisionPerMcCollision, products.productsBplus.storedBplusMcCollisionsTable); + products.productsBplus.storedBplusMcCollisionIdsTable(mcCollisionMapping[mcCollision.globalIndex()]); + bplusMcCollisionMapping[bplusMcCollisionPerMcCollision.globalIndex()] = products.productsBplus.storedBplusMcCollisionsTable.lastIndex(); + } + const auto bplusParticlesPerMcCollision = BplusParticles.sliceBy(preslices.BplusParticlesPerMcCollision, mcCollision.globalIndex()); + for (const auto& BplusParticle : bplusParticlesPerMcCollision) { + jethfutilities::fillHFCandidateMcTable(BplusParticle, products.productsBplus.storedBplusMcCollisionsTable.lastIndex(), products.productsBplus.storedBplusParticlesTable); + products.productsBplus.storedBplusParticleIdsTable(mcCollisionMapping[mcCollision.globalIndex()], particleMapping[BplusParticle.mcParticleId()]); + } + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processBplusMCP, "write out Bplus mcp output tables", false); - auto JMcCollisionIndex = mcCollisionMapping.find(mcCollision.globalIndex()); - if (JMcCollisionIndex != mcCollisionMapping.end()) { - products.storedJMcCollisionsLabelTable(JMcCollisionIndex->second); - } - if (config.saveBCsTable) { - int32_t storedBCID = -1; - auto JBCIndex = bcMapping.find(collision.bcId()); - if (JBCIndex != bcMapping.end()) { - storedBCID = JBCIndex->second; - } - products.storedJCollisionsBunchCrossingIndexTable(storedBCID); - } - if (config.saveClustersTable) { - products.storedJCollisionsEMCalLabelTable(collision.isAmbiguous(), collision.isEmcalReadout()); - } + void processDielectronMCP(soa::Join::iterator const& mcCollision, aod::JMcParticles const&, soa::Join const& DielectronMcCollisions, aod::CandidatesDielectronMCP const& DielectronParticles) + { + if (mcCollision.isMcCollisionSelected()) { - const auto tracksPerCollision = tracks.sliceBy(TracksPerCollision, collision.globalIndex()); - for (const auto& track : tracksPerCollision) { - if (config.performTrackSelection && !(track.trackSel() & ~(1 << jetderiveddatautilities::JTrackSel::trackSign))) { // skips tracks that pass no selections. This might cause a problem with tracks matched with clusters. We should generate a track selection purely for cluster matched tracks so that they are kept - continue; - } - if (track.pt() < config.trackPtSelectionMin || std::abs(track.eta()) > config.trackEtaSelectionMax) { - continue; - } - products.storedJTracksTable(products.storedJCollisionsTable.lastIndex(), o2::math_utils::detail::truncateFloatFraction(track.pt(), precisionMomentumMask), o2::math_utils::detail::truncateFloatFraction(track.eta(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.phi(), precisionPositionMask), track.trackSel()); - products.storedJTracksExtraTable(o2::math_utils::detail::truncateFloatFraction(track.dcaX(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaXY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaXYZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigmadcaZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigmadcaXY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigmadcaXYZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigma1Pt(), precisionMomentumMask)); - products.storedJTracksParentIndexTable(track.trackId()); - - if (track.has_mcParticle()) { - auto JParticleIndex = paticleMapping.find(track.mcParticleId()); - if (JParticleIndex != paticleMapping.end()) { - products.storedJMcTracksLabelTable(JParticleIndex->second); - } else { - products.storedJMcTracksLabelTable(-1); // this can happen because there are some tracks that are reconstucted in a wrong collision, but their original McCollision did not pass the required cuts so that McParticle is not saved. These are very few but we should look into them further and see what to do about them - } - } else { - products.storedJMcTracksLabelTable(-1); - } - trackMapping.insert(std::make_pair(track.globalIndex(), products.storedJTracksTable.lastIndex())); + const auto dielectronMcCollisionsPerMcCollision = DielectronMcCollisions.sliceBy(preslices.DielectronMcCollisionsPerMcCollision, mcCollision.globalIndex()); + for (const auto& dielectronMcCollisionPerMcCollision : dielectronMcCollisionsPerMcCollision) { // should only ever be one + jetdqutilities::fillDielectronMcCollisionTable(dielectronMcCollisionPerMcCollision, products.productsDielectron.storedDielectronMcCollisionsTable); + products.productsDielectron.storedDielectronMcCollisionIdsTable(mcCollisionMapping[mcCollision.globalIndex()]); + products.productsDielectron.storedDielectronMcRCollDummysTable(dielectronMcCollisionPerMcCollision.dummyDQ()); + } + for (const auto& DielectronParticle : DielectronParticles) { + jetdqutilities::fillDielectronCandidateMcTable(DielectronParticle, products.productsDielectron.storedDielectronMcCollisionsTable.lastIndex(), products.productsDielectron.storedDielectronParticlesTable); + std::vector DielectronMothersIds; + int DielectronDaughtersId[2]; + if (DielectronParticle.has_mothers()) { + for (auto const& DielectronMother : DielectronParticle.template mothers_as()) { + DielectronMothersIds.push_back(particleMapping[DielectronMother.globalIndex()]); } - if (config.saveClustersTable) { - const auto clustersPerCollision = clusters.sliceBy(ClustersPerCollision, collision.globalIndex()); - for (const auto& cluster : clustersPerCollision) { - products.storedJClustersTable(products.storedJCollisionsTable.lastIndex(), cluster.id(), cluster.energy(), cluster.coreEnergy(), cluster.rawEnergy(), - cluster.eta(), cluster.phi(), cluster.m02(), cluster.m20(), cluster.nCells(), cluster.time(), cluster.isExotic(), cluster.distanceToBadChannel(), - cluster.nlm(), cluster.definition(), cluster.leadingCellEnergy(), cluster.subleadingCellEnergy(), cluster.leadingCellNumber(), cluster.subleadingCellNumber()); - products.storedJClustersParentIndexTable(cluster.clusterId()); - - std::vector clusterStoredJTrackIDs; - for (const auto& clusterTrack : cluster.matchedTracks_as>()) { - auto JtrackIndex = trackMapping.find(clusterTrack.globalIndex()); - if (JtrackIndex != trackMapping.end()) { - clusterStoredJTrackIDs.push_back(JtrackIndex->second); - const auto emcTracksPerTrack = emcTracks.sliceBy(EMCTrackPerTrack, clusterTrack.globalIndex()); - auto emcTrackPerTrack = emcTracksPerTrack.iteratorAt(0); - products.storedJTracksEMCalTable(JtrackIndex->second, emcTrackPerTrack.etaEmcal(), emcTrackPerTrack.phiEmcal()); - } - } - products.storedJClustersMatchedTracksTable(clusterStoredJTrackIDs); - - std::vector clusterStoredJParticleIDs; - for (const auto& clusterParticleId : cluster.mcParticleIds()) { - auto JParticleIndex = paticleMapping.find(clusterParticleId); - if (JParticleIndex != paticleMapping.end()) { - clusterStoredJParticleIDs.push_back(JParticleIndex->second); - } - } - std::vector amplitudeA; - auto amplitudeASpan = cluster.amplitudeA(); - std::copy(amplitudeASpan.begin(), amplitudeASpan.end(), std::back_inserter(amplitudeA)); - products.storedJMcClustersLabelTable(clusterStoredJParticleIDs, amplitudeA); + } + auto i = 0; + if (DielectronParticle.has_daughters()) { + for (auto const& DielectronDaughter : DielectronParticle.template daughters_as()) { + if (i > 1) { + break; } + DielectronDaughtersId[i] = particleMapping[DielectronDaughter.globalIndex()]; + i++; } + } + products.productsDielectron.storedDielectronParticleIdsTable(mcCollisionMapping[mcCollision.globalIndex()], particleMapping[DielectronParticle.mcParticleId()], DielectronMothersIds, DielectronDaughtersId); + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processDielectronMCP, "write out Dielectron mcp output tables", false); - if (config.saveD0Table) { - const auto d0CollisionsPerCollision = D0Collisions.sliceBy(D0CollisionsPerCollision, collision.globalIndex()); - int32_t collisionD0Index = -1; - for (const auto& d0CollisionPerCollision : d0CollisionsPerCollision) { // should only ever be one - jethfutilities::fillHFCollisionTable(d0CollisionPerCollision, products.storedD0CollisionsTable, collisionD0Index); - products.storedD0CollisionIdsTable(products.storedJCollisionsTable.lastIndex()); - D0CollisionMapping.insert(std::make_pair(d0CollisionPerCollision.globalIndex(), products.storedD0CollisionsTable.lastIndex())); - } - const auto d0sPerCollision = D0s.sliceBy(D0sPerCollision, collision.globalIndex()); - for (const auto& D0 : d0sPerCollision) { - int32_t D0Index = -1; - jethfutilities::fillHFCandidateTable(D0, collisionD0Index, products.storedD0sTable, products.storedD0ParsTable, products.storedD0ParExtrasTable, products.storedD0ParDaughtersDummyTable, products.storedD0SelsTable, products.storedD0MlsTable, products.storedD0MlDughtersDummyTable, products.storedD0McsTable, D0Index); - - int32_t prong0Id = -1; - int32_t prong1Id = -1; - auto JtrackIndex = trackMapping.find(D0.prong0Id()); - if (JtrackIndex != trackMapping.end()) { - prong0Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(D0.prong1Id()); - if (JtrackIndex != trackMapping.end()) { - prong1Id = JtrackIndex->second; - } - products.storedD0IdsTable(products.storedJCollisionsTable.lastIndex(), prong0Id, prong1Id); - } - } + void processColllisonsMcCollisionLabel(soa::Join::iterator const& collision) + { + if (collision.isCollisionSelected()) { + products.storedJMcCollisionsLabelTable(mcCollisionMapping[collision.mcCollisionId()]); + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processColllisonsMcCollisionLabel, "write out collision mcCollision label output tables", false); - if (config.saveLcTable) { - const auto lcCollisionsPerCollision = LcCollisions.sliceBy(LcCollisionsPerCollision, collision.globalIndex()); - int32_t collisionLcIndex = -1; - for (const auto& lcCollisionPerCollision : lcCollisionsPerCollision) { // should only ever be one - jethfutilities::fillHFCollisionTable(lcCollisionPerCollision, products.storedLcCollisionsTable, collisionLcIndex); - products.storedLcCollisionIdsTable(products.storedJCollisionsTable.lastIndex()); - LcCollisionMapping.insert(std::make_pair(lcCollisionPerCollision.globalIndex(), products.storedLcCollisionsTable.lastIndex())); - } - const auto lcsPerCollision = Lcs.sliceBy(LcsPerCollision, collision.globalIndex()); - for (const auto& Lc : lcsPerCollision) { - int32_t LcIndex = -1; - jethfutilities::fillHFCandidateTable(Lc, collisionLcIndex, products.storedLcsTable, products.storedLcParsTable, products.storedLcParExtrasTable, products.storedLcParDaughtersDummyTable, products.storedLcSelsTable, products.storedLcMlsTable, products.storedLcMlDughtersDummyTable, products.storedLcMcsTable, LcIndex); - - int32_t prong0Id = -1; - int32_t prong1Id = -1; - int32_t prong2Id = -1; - auto JtrackIndex = trackMapping.find(Lc.prong0Id()); - if (JtrackIndex != trackMapping.end()) { - prong0Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Lc.prong1Id()); - if (JtrackIndex != trackMapping.end()) { - prong1Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Lc.prong2Id()); - if (JtrackIndex != trackMapping.end()) { - prong2Id = JtrackIndex->second; - } - products.storedLcIdsTable(products.storedJCollisionsTable.lastIndex(), prong0Id, prong1Id, prong2Id); - } - } + void processTracksMcParticleLabel(soa::Join::iterator const& collision, soa::Join const& tracks) + { + if (collision.isCollisionSelected()) { + for (const auto& track : tracks) { + if (!trackSelection(track)) { + continue; + } + if (track.has_mcParticle()) { + products.storedJMcTracksLabelTable(particleMapping[track.mcParticleId()]); + } else { + products.storedJMcTracksLabelTable(-1); + } + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processTracksMcParticleLabel, "write out track mcParticle label output tables", false); - if (config.saveBplusTable) { - const auto lcCollisionsPerCollision = BplusCollisions.sliceBy(BplusCollisionsPerCollision, collision.globalIndex()); - int32_t collisionBplusIndex = -1; - for (const auto& lcCollisionPerCollision : lcCollisionsPerCollision) { // should only ever be one - jethfutilities::fillHFCollisionTable(lcCollisionPerCollision, products.storedBplusCollisionsTable, collisionBplusIndex); - products.storedBplusCollisionIdsTable(products.storedJCollisionsTable.lastIndex()); - BplusCollisionMapping.insert(std::make_pair(lcCollisionPerCollision.globalIndex(), products.storedBplusCollisionsTable.lastIndex())); - } - const auto lcsPerCollision = Bpluss.sliceBy(BplussPerCollision, collision.globalIndex()); - for (const auto& Bplus : lcsPerCollision) { - int32_t BplusIndex = -1; - jethfutilities::fillHFCandidateTable(Bplus, collisionBplusIndex, products.storedBplussTable, products.storedBplusParsTable, products.storedBplusParExtrasTable, products.storedBplusParD0sTable, products.storedBplusSelsTable, products.storedBplusMlsTable, products.storedBplusMlD0sTable, products.storedBplusMcsTable, BplusIndex); - - int32_t prong0Id = -1; - int32_t prong1Id = -1; - int32_t prong2Id = -1; - auto JtrackIndex = trackMapping.find(Bplus.prong0Id()); - if (JtrackIndex != trackMapping.end()) { - prong0Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Bplus.prong1Id()); - if (JtrackIndex != trackMapping.end()) { - prong1Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Bplus.prong2Id()); - if (JtrackIndex != trackMapping.end()) { - prong2Id = JtrackIndex->second; - } - products.storedBplusIdsTable(products.storedJCollisionsTable.lastIndex(), prong0Id, prong1Id, prong2Id); - } - } + void processClusterMcLabel(soa::Join::iterator const& collision, soa::Join const& clusters) + { + if (collision.isCollisionSelected()) { + for (const auto& cluster : clusters) { + std::vector clusterStoredJParticleIDs; + for (const auto& clusterParticleId : cluster.mcParticlesIds()) { + clusterStoredJParticleIDs.push_back(particleMapping[clusterParticleId]); + } + std::vector amplitudeA; + auto amplitudeASpan = cluster.amplitudeA(); + std::copy(amplitudeASpan.begin(), amplitudeASpan.end(), std::back_inserter(amplitudeA)); + products.storedJMcClustersLabelTable(clusterStoredJParticleIDs, amplitudeA); + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processClusterMcLabel, "write out cluster mc label output tables", false); - if (config.saveDielectronTable) { - const auto dielectronCollisionsPerCollision = DielectronCollisions.sliceBy(DielectronCollisionsPerCollision, collision.globalIndex()); - int32_t collisionDielectronIndex = -1; - for (const auto& dielectronCollisionPerCollision : dielectronCollisionsPerCollision) { // should only ever be one - jetdqutilities::fillDielectronCollisionTable(dielectronCollisionPerCollision, products.storedDielectronCollisionsTable, collisionDielectronIndex); - products.storedDielectronCollisionIdsTable(products.storedJCollisionsTable.lastIndex()); - // D0CollisionMapping.insert(std::make_pair(d0CollisionPerCollision.globalIndex(), products.storedD0CollisionsTable.lastIndex())); // if DielectronMCCollisions are indexed to Dielectron Collisions then this can be added - } - const auto dielectronsPerCollision = Dielectrons.sliceBy(DielectronsPerCollision, collision.globalIndex()); - for (const auto& Dielectron : dielectronsPerCollision) { - int32_t DielectronIndex = -1; - jetdqutilities::fillDielectronCandidateTable(Dielectron, collisionDielectronIndex, products.storedDielectronsTable, DielectronIndex); - - int32_t prong0Id = -1; - int32_t prong1Id = -1; - auto JtrackIndex = trackMapping.find(Dielectron.prong0Id()); - if (JtrackIndex != trackMapping.end()) { - prong0Id = JtrackIndex->second; - } - JtrackIndex = trackMapping.find(Dielectron.prong1Id()); - if (JtrackIndex != trackMapping.end()) { - prong1Id = JtrackIndex->second; - } - products.storedDielectronIdsTable(products.storedJCollisionsTable.lastIndex(), prong0Id, prong1Id); - } - } + void processD0McCollisionMatch(soa::Join::iterator const& mcCollision, soa::Join const& D0McCollisions, aod::CollisionsD0 const&) + { + if (mcCollision.isMcCollisionSelected()) { + for (const auto& D0McCollision : D0McCollisions) { // should just be one + std::vector d0CollisionIDs; + for (auto const& d0CollisionPerMcCollision : D0McCollision.hfCollBases_as()) { + d0CollisionIDs.push_back(d0McCollisionMapping[d0CollisionPerMcCollision.globalIndex()]); } + products.productsD0.storedD0McCollisionsMatchingTable(d0CollisionIDs); + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processD0McCollisionMatch, "write out D0 McCollision collision label output tables", false); - if (config.saveD0Table) { - const auto d0McCollisionsPerMcCollision = D0McCollisions.sliceBy(D0McCollisionsPerMcCollision, mcCollision.globalIndex()); - for (const auto& d0McCollisionPerMcCollision : d0McCollisionsPerMcCollision) { // should just be one - std::vector d0CollisionIDs; - for (auto const& d0CollisionPerMcCollision : d0McCollisionPerMcCollision.template hfCollBases_as()) { - auto d0CollisionIndex = D0CollisionMapping.find(d0CollisionPerMcCollision.globalIndex()); - if (d0CollisionIndex != D0CollisionMapping.end()) { - d0CollisionIDs.push_back(d0CollisionIndex->second); - } - } - products.storedD0McCollisionsMatchingTable(d0CollisionIDs); - } + void processDplusMcCollisionMatch(soa::Join::iterator const& mcCollision, soa::Join const& DplusMcCollisions, aod::CollisionsDplus const&) + { + if (mcCollision.isMcCollisionSelected()) { + for (const auto& DplusMcCollision : DplusMcCollisions) { // should just be one + std::vector dplusCollisionIDs; + for (auto const& dplusCollisionPerMcCollision : DplusMcCollision.hfCollBases_as()) { + dplusCollisionIDs.push_back(dplusMcCollisionMapping[dplusCollisionPerMcCollision.globalIndex()]); } + products.productsDplus.storedDplusMcCollisionsMatchingTable(dplusCollisionIDs); + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processDplusMcCollisionMatch, "write out Dplus McCollision collision label output tables", false); - if (config.saveLcTable) { - const auto lcMcCollisionsPerMcCollision = LcMcCollisions.sliceBy(LcMcCollisionsPerMcCollision, mcCollision.globalIndex()); - for (const auto& lcMcCollisionPerMcCollision : lcMcCollisionsPerMcCollision) { // should just be one - std::vector lcCollisionIDs; - for (auto const& lcCollisionPerMcCollision : lcMcCollisionPerMcCollision.template hfCollBases_as()) { - auto lcCollisionIndex = LcCollisionMapping.find(lcCollisionPerMcCollision.globalIndex()); - if (lcCollisionIndex != LcCollisionMapping.end()) { - lcCollisionIDs.push_back(lcCollisionIndex->second); - } - } - products.storedLcMcCollisionsMatchingTable(lcCollisionIDs); - } + void processDstarMcCollisionMatch(soa::Join::iterator const& mcCollision, soa::Join const& DstarMcCollisions, aod::CollisionsDstar const&) + { + if (mcCollision.isMcCollisionSelected()) { + for (const auto& DstarMcCollision : DstarMcCollisions) { // should just be one + std::vector dstarCollisionIDs; + for (auto const& dstarCollisionPerMcCollision : DstarMcCollision.hfCollBases_as()) { + dstarCollisionIDs.push_back(dstarMcCollisionMapping[dstarCollisionPerMcCollision.globalIndex()]); } + products.productsDstar.storedDstarMcCollisionsMatchingTable(dstarCollisionIDs); + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processDstarMcCollisionMatch, "write out D* McCollision collision label output tables", false); - if (config.saveBplusTable) { - const auto lcMcCollisionsPerMcCollision = BplusMcCollisions.sliceBy(BplusMcCollisionsPerMcCollision, mcCollision.globalIndex()); - for (const auto& lcMcCollisionPerMcCollision : lcMcCollisionsPerMcCollision) { // should just be one - std::vector lcCollisionIDs; - for (auto const& lcCollisionPerMcCollision : lcMcCollisionPerMcCollision.template hfCollBases_as()) { - auto lcCollisionIndex = BplusCollisionMapping.find(lcCollisionPerMcCollision.globalIndex()); - if (lcCollisionIndex != BplusCollisionMapping.end()) { - lcCollisionIDs.push_back(lcCollisionIndex->second); - } - } - products.storedBplusMcCollisionsMatchingTable(lcCollisionIDs); - } + void processLcMcCollisionMatch(soa::Join::iterator const& mcCollision, soa::Join const& LcMcCollisions, aod::CollisionsLc const&) + { + if (mcCollision.isMcCollisionSelected()) { + for (const auto& LcMcCollision : LcMcCollisions) { // should just be one + std::vector lcCollisionIDs; + for (auto const& lcCollisionPerMcCollision : LcMcCollision.hfCollBases_as()) { + lcCollisionIDs.push_back(lcMcCollisionMapping[lcCollisionPerMcCollision.globalIndex()]); } + products.productsLc.storedLcMcCollisionsMatchingTable(lcCollisionIDs); } } } - // process switch for output writing must be last - // to run after all jet selections - PROCESS_SWITCH(JetDerivedDataWriter, processStoreMC, "write out data output tables for mc", false); + PROCESS_SWITCH(JetDerivedDataWriter, processLcMcCollisionMatch, "write out Lc McCollision collision label output tables", false); - void processStoreMCP(soa::Join const& mcCollisions, soa::Join const& particles, aod::McCollisionsD0 const& D0McCollisions, aod::CandidatesD0MCP const& D0Particles, aod::McCollisionsLc const& LcMcCollisions, aod::CandidatesLcMCP const& LcParticles, aod::McCollisionsBplus const& BplusMcCollisions, aod::CandidatesBplusMCP const& BplusParticles, aod::McCollisionsDielectron const& DielectronMcCollisions, aod::CandidatesDielectronMCP const& DielectronParticles) + void processB0McCollisionMatch(soa::Join::iterator const& mcCollision, soa::Join const& B0McCollisions, aod::CollisionsB0 const&) { - - int particleTableIndex = 0; - for (auto mcCollision : mcCollisions) { - if (McCollisionFlag[mcCollision.globalIndex()]) { // you can also check if any of its detector level counterparts are correct - std::map paticleMapping; - - products.storedJMcCollisionsTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.weight()); - products.storedJMcCollisionsParentIndexTable(mcCollision.mcCollisionId()); - - const auto particlesPerMcCollision = particles.sliceBy(ParticlesPerMcCollision, mcCollision.globalIndex()); - - for (auto particle : particlesPerMcCollision) { - paticleMapping.insert(std::make_pair(particle.globalIndex(), particleTableIndex)); - particleTableIndex++; - } - for (auto particle : particlesPerMcCollision) { - std::vector mothersId; - int daughtersId[2]; - if (particle.has_mothers()) { - for (auto const& mother : particle.template mothers_as>()) { - auto JMotherIndex = paticleMapping.find(mother.globalIndex()); - if (JMotherIndex != paticleMapping.end()) { - mothersId.push_back(JMotherIndex->second); - } - } - } - auto i = 0; - if (particle.has_daughters()) { - for (auto const& daughter : particle.template daughters_as>()) { - if (i > 1) { - break; - } - auto JDaughterIndex = paticleMapping.find(daughter.globalIndex()); - if (JDaughterIndex != paticleMapping.end()) { - daughtersId[i] = JDaughterIndex->second; - } - i++; - } - } - products.storedJMcParticlesTable(products.storedJMcCollisionsTable.lastIndex(), o2::math_utils::detail::truncateFloatFraction(particle.pt(), precisionMomentumMask), o2::math_utils::detail::truncateFloatFraction(particle.eta(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(particle.phi(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(particle.y(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(particle.e(), precisionMomentumMask), particle.pdgCode(), particle.getGenStatusCode(), particle.getHepMCStatusCode(), particle.isPhysicalPrimary(), mothersId, daughtersId); - products.storedJParticlesParentIndexTable(particle.mcParticleId()); + if (mcCollision.isMcCollisionSelected()) { + for (const auto& B0McCollision : B0McCollisions) { // should just be one + std::vector b0CollisionIDs; + for (auto const& b0CollisionPerMcCollision : B0McCollision.hfCollBases_as()) { + b0CollisionIDs.push_back(b0McCollisionMapping[b0CollisionPerMcCollision.globalIndex()]); } + products.productsB0.storedB0McCollisionsMatchingTable(b0CollisionIDs); + } + } + } + PROCESS_SWITCH(JetDerivedDataWriter, processB0McCollisionMatch, "write out B0 McCollision collision label output tables", false); - if (config.saveD0Table) { - const auto d0McCollisionsPerMcCollision = D0McCollisions.sliceBy(D0McCollisionsPerMcCollision, mcCollision.globalIndex()); - int32_t mcCollisionD0Index = -1; - for (const auto& d0McCollisionPerMcCollision : d0McCollisionsPerMcCollision) { // should only ever be one - jethfutilities::fillHFMcCollisionTable(d0McCollisionPerMcCollision, products.storedD0McCollisionsTable, mcCollisionD0Index); - products.storedD0McCollisionIdsTable(products.storedJMcCollisionsTable.lastIndex()); - } - for (const auto& D0Particle : D0Particles) { - int32_t D0ParticleIndex = -1; - jethfutilities::fillHFCandidateMcTable(D0Particle, mcCollisionD0Index, products.storedD0ParticlesTable, D0ParticleIndex); - int32_t D0ParticleId = -1; - auto JParticleIndex = paticleMapping.find(D0Particle.mcParticleId()); - if (JParticleIndex != paticleMapping.end()) { - D0ParticleId = JParticleIndex->second; - } - products.storedD0ParticleIdsTable(products.storedJMcCollisionsTable.lastIndex(), D0ParticleId); - } - } - if (config.saveLcTable) { - const auto lcMcCollisionsPerMcCollision = LcMcCollisions.sliceBy(LcMcCollisionsPerMcCollision, mcCollision.globalIndex()); - int32_t mcCollisionLcIndex = -1; - for (const auto& lcMcCollisionPerMcCollision : lcMcCollisionsPerMcCollision) { // should only ever be one - jethfutilities::fillHFMcCollisionTable(lcMcCollisionPerMcCollision, products.storedLcMcCollisionsTable, mcCollisionLcIndex); - products.storedLcMcCollisionIdsTable(products.storedJMcCollisionsTable.lastIndex()); - } - for (const auto& LcParticle : LcParticles) { - int32_t LcParticleIndex = -1; - jethfutilities::fillHFCandidateMcTable(LcParticle, mcCollisionLcIndex, products.storedLcParticlesTable, LcParticleIndex); - int32_t LcParticleId = -1; - auto JParticleIndex = paticleMapping.find(LcParticle.mcParticleId()); - if (JParticleIndex != paticleMapping.end()) { - LcParticleId = JParticleIndex->second; - } - products.storedLcParticleIdsTable(products.storedJMcCollisionsTable.lastIndex(), LcParticleId); - } - } - if (config.saveBplusTable) { - const auto lcMcCollisionsPerMcCollision = BplusMcCollisions.sliceBy(BplusMcCollisionsPerMcCollision, mcCollision.globalIndex()); - int32_t mcCollisionBplusIndex = -1; - for (const auto& lcMcCollisionPerMcCollision : lcMcCollisionsPerMcCollision) { // should only ever be one - jethfutilities::fillHFMcCollisionTable(lcMcCollisionPerMcCollision, products.storedBplusMcCollisionsTable, mcCollisionBplusIndex); - products.storedBplusMcCollisionIdsTable(products.storedJMcCollisionsTable.lastIndex()); - } - for (const auto& BplusParticle : BplusParticles) { - int32_t BplusParticleIndex = -1; - jethfutilities::fillHFCandidateMcTable(BplusParticle, mcCollisionBplusIndex, products.storedBplusParticlesTable, BplusParticleIndex); - int32_t BplusParticleId = -1; - auto JParticleIndex = paticleMapping.find(BplusParticle.mcParticleId()); - if (JParticleIndex != paticleMapping.end()) { - BplusParticleId = JParticleIndex->second; - } - products.storedBplusParticleIdsTable(products.storedJMcCollisionsTable.lastIndex(), BplusParticleId); - } - } - if (config.saveDielectronTable) { - const auto dielectronMcCollisionsPerMcCollision = DielectronMcCollisions.sliceBy(DielectronMcCollisionsPerMcCollision, mcCollision.globalIndex()); - int32_t mcCollisionDielectronIndex = -1; - for (const auto& dielectronMcCollisionPerMcCollision : dielectronMcCollisionsPerMcCollision) { // should only ever be one - jetdqutilities::fillDielectronMcCollisionTable(dielectronMcCollisionPerMcCollision, products.storedDielectronMcCollisionsTable, mcCollisionDielectronIndex); - products.storedDielectronMcCollisionIdsTable(products.storedJMcCollisionsTable.lastIndex()); - } - for (const auto& DielectronParticle : DielectronParticles) { - int32_t DielectronParticleIndex = -1; - jetdqutilities::fillDielectronCandidateMcTable(DielectronParticle, mcCollisionDielectronIndex, products.storedDielectronParticlesTable, DielectronParticleIndex); - int32_t DielectronParticleId = -1; - auto JParticleIndex = paticleMapping.find(DielectronParticle.mcParticleId()); - if (JParticleIndex != paticleMapping.end()) { - DielectronParticleId = JParticleIndex->second; - } - std::vector DielectronMothersId; - int DielectronDaughtersId[2]; - if (DielectronParticle.has_mothers()) { - for (auto const& DielectronMother : DielectronParticle.template mothers_as>()) { - auto JDielectronMotherIndex = paticleMapping.find(DielectronMother.globalIndex()); - if (JDielectronMotherIndex != paticleMapping.end()) { - DielectronMothersId.push_back(JDielectronMotherIndex->second); - } - } - } - auto i = 0; - if (DielectronParticle.has_daughters()) { - for (auto const& DielectronDaughter : DielectronParticle.template daughters_as>()) { - if (i > 1) { - break; - } - auto JDielectronDaughterIndex = paticleMapping.find(DielectronDaughter.globalIndex()); - if (JDielectronDaughterIndex != paticleMapping.end()) { - DielectronDaughtersId[i] = JDielectronDaughterIndex->second; - } - i++; - } - } - products.storedDielectronParticleIdsTable(products.storedJMcCollisionsTable.lastIndex(), DielectronParticleId, DielectronMothersId, DielectronDaughtersId); - } + void processBplusMcCollisionMatch(soa::Join::iterator const& mcCollision, soa::Join const& BplusMcCollisions, aod::CollisionsBplus const&) + { + if (mcCollision.isMcCollisionSelected()) { + for (const auto& BplusMcCollision : BplusMcCollisions) { // should just be one + std::vector bplusCollisionIDs; + for (auto const& bplusCollisionPerMcCollision : BplusMcCollision.hfCollBases_as()) { + bplusCollisionIDs.push_back(bplusMcCollisionMapping[bplusCollisionPerMcCollision.globalIndex()]); } + products.productsBplus.storedBplusMcCollisionsMatchingTable(bplusCollisionIDs); } } } - // process switch for output writing must be last - // to run after all jet selections - PROCESS_SWITCH(JetDerivedDataWriter, processStoreMCP, "write out data output tables for mcp", false); + PROCESS_SWITCH(JetDerivedDataWriter, processBplusMcCollisionMatch, "write out Bplus McCollision collision label output tables", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/TableProducer/emcalClusterHadronicCorrectionTask.cxx b/PWGJE/TableProducer/emcalClusterHadronicCorrectionTask.cxx new file mode 100644 index 00000000000..4e4cdedd197 --- /dev/null +++ b/PWGJE/TableProducer/emcalClusterHadronicCorrectionTask.cxx @@ -0,0 +1,290 @@ +// 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. + +// **Hadronic Correction in the EMCAL framework: to avoid the double counting of the charged particles' contribution in jets** +/// \author Archita Rani Dash + +#include "PWGJE/DataModel/EMCALClusterDefinition.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include + +#include "TVector2.h" +#include + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct EmcalClusterHadronicCorrectionTask { + Produces clusterEnergyCorrectedTable; + + HistogramRegistry registry; + // Configurables for Histogram Binning + PresliceUnsorted perTrackMatchedTrack = aod::jemctrack::trackId; + + // define configurables here + Configurable clusterDefinitionS{"clusterDefinition", "kV3Default", "cluster definition to be selected, e.g. V3Default"}; + + Configurable minTime{"minTime", -25., "Minimum cluster time for time cut"}; + Configurable maxTime{"maxTime", 20., "Maximum cluster time for time cut"}; + Configurable minM02{"minM02", 0.1, "Minimum M02 for M02 cut"}; + Configurable maxM02{"maxM02", 0.9, "Maximum M02 for M02 cut"}; + Configurable minTrackPt{"minTrackPt", 0.15, "Minimum pT for tracks"}; + Configurable hadCorr1{"hadCorr1", 1., "hadronic correction fraction for complete cluster energy subtraction for one matched track"}; // 100% - default + Configurable hadCorr2{"hadCorr2", 0.7, "hadronic correction fraction for systematic studies for one matched track"}; // 70% + Configurable hadCorralltrks1{"hadCorralltrks1", 1., "hadronic correction fraction for complete cluster energy subtraction for all matched tracks"}; // 100% - all tracks + Configurable hadCorralltrks2{"hadCorralltrks2", 0.7, "hadronic correction fraction for systematic studies for all matched tracks"}; // 70% + Configurable minDEta{"minDEta", 0.01, "Minimum dEta between track and cluster"}; + Configurable minDPhi{"minDPhi", 0.01, "Minimum dPhi between track and cluster"}; + Configurable constantSubtractionValue{"constantSubtractionValue", 0.236, "Value to be used for constant MIP subtraction (only applicable if using constant subtraction in M02 scheme)"}; + + // pT-dependent track-matching configurables + Configurable eta0{"eta0", 0.04, "Param 0 in eta for pt-dependent matching"}; + Configurable eta1{"eta1", 0.010, "Param 1 in eta for pt-dependent matching"}; + Configurable eta2{"eta2", 2.5, "Param 2 in eta for pt-dependent matching"}; + Configurable phi0{"phi0", 0.09, "Param 0 in phi for pt-dependent matching"}; + Configurable phi1{"phi1", 0.015, "Param 1 in phi for pt-dependent matching"}; + Configurable phi2{"phi2", 2.0, "Param 2 in phi for pt-dependent matching"}; + + Configurable doHadCorrSyst{"doHadCorrSyst", false, "Do hadronic correction for systematic studies"}; + Configurable doMomDepMatching{"doMomDepMatching", true, "Do momentum dependent track matching"}; // to be always set to true in Run 3 + Configurable useM02SubtractionScheme1{"useM02SubtractionScheme1", false, "Flag to enable hadronic correction scheme using cluster M02 value for clusterE1 and clusterEAll1"}; + Configurable useM02SubtractionScheme2{"useM02SubtractionScheme2", false, "Flag to enable hadronic correction scheme using cluster M02 value for clusterE2 and clusterEAll2"}; + Configurable useFraction1{"useFraction1", false, "Fractional momentum subtraction for clusterE1 and clusterEAll1"}; + Configurable useFraction2{"useFraction2", false, "Fractional momentum subtraction for clusterE2 and clusterEAll2"}; + + void init(o2::framework::InitContext&) + { + // Event histograms + registry.add("h_allcollisions", "Total events; event status;entries", {HistType::kTH1F, {{1, 0.5, 1.5}}}); + + // Matched-Cluster histograms + registry.add("h_matchedclusters", "Total matched clusters; cluster status;entries", {HistType::kTH1F, {{1, 0.5, 1.5}}}); + registry.add("h_ClsE", "; Cls E w/o correction (GeV); entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_Ecluster1", "; Ecluster1 (GeV); entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_Ecluster2", "; Ecluster2 (GeV); entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_EclusterAll1", "; EclusterAll1 (GeV); entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_EclusterAll2", "; EclusterAll2 (GeV); entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_ClsTime", "Cluster time distribution of uncorrected cluster E; #it{t}_{cls} (ns); entries", {HistType::kTH1F, {{500, -250., 250.}}}); + registry.add("h_ClsM02", "Cluster M02 distribution of uncorrected cluster E; #it{M}_{02}; entries", {HistType::kTH1F, {{400, 0., 5.}}}); + registry.add("h2_ClsEvsNmatches", "Original cluster energy vs Nmatches; Cls E w/o correction (GeV); Nmatches", {HistType::kTH2F, {{350, 0., 350.}, {100, -0.5, 21.}}}); + registry.add("h2_ClsEvsEcluster1", "; Cls E w/o correction (GeV); Ecluster1 (GeV)", {HistType::kTH2F, {{350, 0., 350.}, {350, 0., 350.}}}); + registry.add("h2_ClsEvsEcluster2", "; Cls E w/o correction (GeV); Ecluster2 (GeV)", {HistType::kTH2F, {{350, 0., 350.}, {350, 0., 350.}}}); + registry.add("h2_ClsEvsEclusterAll1", "; Cls E w/o correction (GeV); EclusterAll1 (GeV)", {HistType::kTH2F, {{350, 0., 350.}, {350, 0., 350.}}}); + registry.add("h2_ClsEvsEclusterAll2", "; Cls E w/o correction (GeV); EclusterAll2 (GeV)", {HistType::kTH2F, {{350, 0., 350.}, {350, 0., 350.}}}); + + // Matched-Track histograms + registry.add("h_matchedtracks", "Total matched tracks; track status;entries", {HistType::kTH1F, {{1, 0.5, 1.5}}}); + } + + aod::EMCALClusterDefinition clusterDefinition = aod::emcalcluster::getClusterDefinitionFromString(clusterDefinitionS.value); + Filter clusterDefinitionSelection = (aod::jcluster::definition == static_cast(clusterDefinition)); + + // The matching of clusters and tracks is already centralised in the EMCAL framework. + // One only needs to apply a filter on matched clusters + // Here looping over all collisions matched to EMCAL clusters + void processMatchedCollisions(aod::JetCollision const&, soa::Filtered> const& clusters, aod::JEMCTracks const& emcTracks, aod::JetTracks const&) + { + registry.fill(HIST("h_allcollisions"), 1); + + // skip events with no clusters + if (clusters.size() == 0) { + return; + } + + // Looping over all clusters matched to the collision + for (const auto& cluster : clusters) { + registry.fill(HIST("h_matchedclusters"), 1); + + double clusterE1; + double clusterE2; + double clusterEAll1; + double clusterEAll2; + clusterE1 = clusterE2 = clusterEAll1 = clusterEAll2 = cluster.energy(); + + registry.fill(HIST("h_ClsE"), cluster.energy()); + registry.fill(HIST("h_ClsM02"), cluster.m02()); + registry.fill(HIST("h_ClsTime"), cluster.time()); + + int nMatches = 0; // counter for closest matched track + double closestTrkP = 0.0; // closest track momentum + double totalTrkP = 0.0; // total track momentum + + // pT-dependent track-matching instead of PID based track-matching to be adapted from Run 2 - suggested by Markus Fasel + + TF1 funcPtDepEta("func", "[1] + 1 / pow(x + pow(1 / ([0] - [1]), 1 / [2]), [2])"); + funcPtDepEta.SetParameters(eta0, eta1, eta2); + TF1 funcPtDepPhi("func", "[1] + 1 / pow(x + pow(1 / ([0] - [1]), 1 / [2]), [2])"); + funcPtDepEta.SetParameters(phi0, phi1, phi2); + + // No matched tracks (trackless case) + if (cluster.matchedTracks().size() == 0) { + // Use original cluster energy values, no subtraction needed. + registry.fill(HIST("h2_ClsEvsNmatches"), cluster.energy(), 0); + registry.fill(HIST("h_Ecluster1"), clusterE1); + registry.fill(HIST("h_Ecluster2"), clusterE2); + registry.fill(HIST("h_EclusterAll1"), clusterEAll1); + registry.fill(HIST("h_EclusterAll2"), clusterEAll2); + registry.fill(HIST("h2_ClsEvsEcluster1"), cluster.energy(), clusterE1); + registry.fill(HIST("h2_ClsEvsEcluster2"), cluster.energy(), clusterE2); + registry.fill(HIST("h2_ClsEvsEclusterAll1"), cluster.energy(), clusterEAll1); + registry.fill(HIST("h2_ClsEvsEclusterAll2"), cluster.energy(), clusterEAll2); + clusterEnergyCorrectedTable(clusterE1, clusterE2, clusterEAll1, clusterEAll2); + continue; + } + + // Looping over all matched tracks for the cluster + // Total number of matched tracks = 20 (hard-coded) + for (const auto& matchedTrack : cluster.matchedTracks_as()) { + if (matchedTrack.pt() < minTrackPt) { + continue; + } + double mom = abs(matchedTrack.p()); + registry.fill(HIST("h_matchedtracks"), 1); + + // CASE 1: skip tracks with a very low pT + if (mom < 1e-6) { + continue; + } // end CASE 1 + + // CASE 2: + // a) If one matched track -> 100% energy subtraction + // b) If more than one matched track -> 100% energy subtraction + // c) If you want to do systematic studies -> perform the above two checks a) and b), and then subtract 70% energy instead of 100% + + // Perform dEta/dPhi matching + auto emcTrack = (emcTracks.sliceBy(perTrackMatchedTrack, matchedTrack.globalIndex())).iteratorAt(0); + double dEta = emcTrack.etaEmcal() - cluster.eta(); + double dPhi = TVector2::Phi_mpi_pi(emcTrack.phiEmcal() - cluster.phi()); + + // Apply the eta and phi matching thresholds + // dEta and dPhi cut : ensures that the matched track is within the desired eta/phi window + + // Do pT-dependent track matching + if (doMomDepMatching) { + auto trackEtaMax = funcPtDepEta.Eval(mom); + auto trackPhiHigh = +funcPtDepPhi.Eval(mom); + auto trackPhiLow = -funcPtDepPhi.Eval(mom); + + if ((dPhi < trackPhiHigh && dPhi > trackPhiLow) && fabs(dEta) < trackEtaMax) { + if (nMatches == 0) { + closestTrkP = mom; + } + totalTrkP += mom; + nMatches++; + } + } else { + // Do fixed dEta/dPhi matching (non-pT dependent) + if (fabs(dEta) >= minDEta || fabs(dPhi) >= minDPhi) { + continue; // Skip this track if outside the fixed cut region + } + + // If track passes fixed dEta/dPhi cuts, process it + if (nMatches == 0) { + closestTrkP = mom; // Closest track match + } + totalTrkP += mom; // Accumulate momentum + nMatches++; // Count this match + } + + } // End of track loop + registry.fill(HIST("h2_ClsEvsNmatches"), cluster.energy(), nMatches); + + if (nMatches >= 1) { + if (useM02SubtractionScheme1) { + // Do M02-based correction if enabled + clusterE1 = subtractM02ClusterEnergy(cluster.m02(), clusterE1, nMatches, closestTrkP, hadCorr1, useFraction1); + clusterEAll1 = subtractM02ClusterEnergy(cluster.m02(), clusterEAll1, nMatches, totalTrkP, hadCorralltrks1, useFraction1); + } else { + // Default energy subtraction (100% and 70%) + clusterE1 = subtractClusterEnergy(clusterE1, closestTrkP, hadCorr1, nMatches, useFraction1); + clusterEAll1 = subtractClusterEnergy(clusterEAll1, totalTrkP, hadCorralltrks1, nMatches, useFraction1); + } + + if (useM02SubtractionScheme2) { + // Do M02-based correction if enabled + clusterE2 = subtractM02ClusterEnergy(cluster.m02(), clusterE2, nMatches, closestTrkP, hadCorr2, useFraction2); + clusterEAll2 = subtractM02ClusterEnergy(cluster.m02(), clusterEAll2, nMatches, totalTrkP, hadCorralltrks2, useFraction2); + } else { + // Default energy subtraction (100% and 70%) + clusterE2 = subtractClusterEnergy(clusterE2, closestTrkP, hadCorr2, nMatches, useFraction2); + clusterEAll2 = subtractClusterEnergy(clusterEAll2, totalTrkP, hadCorralltrks2, nMatches, useFraction2); + } + } + registry.fill(HIST("h_Ecluster1"), clusterE1); + registry.fill(HIST("h_Ecluster2"), clusterE2); + registry.fill(HIST("h_EclusterAll1"), clusterEAll1); + registry.fill(HIST("h_EclusterAll2"), clusterEAll2); + registry.fill(HIST("h2_ClsEvsEcluster1"), cluster.energy(), clusterE1); + registry.fill(HIST("h2_ClsEvsEcluster2"), cluster.energy(), clusterE2); + registry.fill(HIST("h2_ClsEvsEclusterAll1"), cluster.energy(), clusterEAll1); + registry.fill(HIST("h2_ClsEvsEclusterAll2"), cluster.energy(), clusterEAll2); + + // Fill the table with all four corrected energies + clusterEnergyCorrectedTable(clusterE1, clusterE2, clusterEAll1, clusterEAll2); + + } // End of cluster loop + } // process function ends + PROCESS_SWITCH(EmcalClusterHadronicCorrectionTask, processMatchedCollisions, "hadronic correction", true); + + // Helper function to prevent negative energy subtraction + double subtractClusterEnergy(double clusterE, double mom, double correctionFactor, int nMatches, bool useFraction) + { + double corrE = clusterE; + + // if (UseConstantSubtractionValue) { + if (!useFraction) { + corrE = clusterE - constantSubtractionValue * nMatches; // Use constant value for MIP-subtraction (regardless of the cluster-shape) + } else { + corrE = clusterE - correctionFactor * mom; // Fractional momentum subtraction + } + return (corrE < 0) ? 0 : corrE; + } + + // Helper function for M02-based energy subtraction (based on cluster-shape) + double subtractM02ClusterEnergy(double m02, double clusterE, int nMatches, double totalTrkP, double correctionFactor, bool useFraction) + { + double corrE = clusterE; + + // For M02 in the single photon region, the signal is primarily: Single photons, single electrons, single MIPs + if (m02 > 0.1 && m02 < 0.4) { // circular clusters(electron/photon) + corrE = 0; // Single electron, single MIP + } else if (m02 > 0.4) { + // Large M02 region (M02 > 0.4), more complex overlaps and hadronic showers. + // The signal is primarily: Single hadronic shower, photon-photon overlap, photon-MIP overlap, MIP-MIP overlap, + // MIP-hadronic shower overlap, hadronic shower - hadronic shower overlap) + + if (!useFraction) { + corrE = clusterE - constantSubtractionValue * nMatches; // Use constant value for MIP-subtraction (regardless of the cluster-shape) + } else { + corrE = clusterE - correctionFactor * totalTrkP; // Fractional momentum subtraction + } + } + return (corrE < 0) ? 0 : corrE; // Prevent negative energy + } + +}; // end of struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"emcal-cluster-hadronic-correction-task"})}; } diff --git a/PWGJE/TableProducer/emcalCorrectionTask.cxx b/PWGJE/TableProducer/emcalCorrectionTask.cxx index 2db77ca4894..1935748a4a0 100644 --- a/PWGJE/TableProducer/emcalCorrectionTask.cxx +++ b/PWGJE/TableProducer/emcalCorrectionTask.cxx @@ -18,42 +18,67 @@ /// \author Raymond Ehlers (raymond.ehlers@cern.ch) ORNL, Florian Jonas (florian.jonas@cern.ch) /// -#include -#include -#include -#include -#include -#include -#include -#include - -#include "CCDB/BasicCCDBManager.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" - -#include "DetectorsBase/GeometryManager.h" - +#include "PWGJE/Core/emcalCrossTalkEmulation.h" +#include "PWGJE/Core/utilsTrackMatchingEMC.h" +#include "PWGJE/DataModel/EMCALClusterDefinition.h" #include "PWGJE/DataModel/EMCALClusters.h" #include "PWGJE/DataModel/EMCALMatchedCollisions.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "DataFormatsEMCAL/Cell.h" -#include "DataFormatsEMCAL/CellLabel.h" -#include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" -#include "EMCALBase/Geometry.h" -#include "EMCALBase/ClusterFactory.h" -#include "EMCALBase/NonlinearityHandler.h" -#include "EMCALReconstruction/Clusterizer.h" -#include "PWGJE/Core/JetUtilities.h" -#include "TVector2.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::emccrosstalk; +using namespace tmemcutilities; using MyGlobTracks = o2::soa::Join; using BcEvSels = o2::soa::Join; using CollEventSels = o2::soa::Join; @@ -61,10 +86,18 @@ using FilteredCells = o2::soa::Filtered; using McCells = o2::soa::Join; using FilteredMcCells = o2::soa::Filtered; +enum CellScaleMode { + ModeNone = 0, + ModeSMWise = 1, + ModeColumnWise = 2, + NumberModes = 3 +}; + struct EmcalCorrectionTask { Produces clusters; Produces mcclusters; Produces clustersAmbiguous; + Produces mcclustersAmbiguous; Produces clustercells; // cells belonging to given cluster Produces clustercellsambiguous; Produces matchedTracks; @@ -82,7 +115,7 @@ struct EmcalCorrectionTask { Configurable selectedCellType{"selectedCellType", 1, "EMCAL Cell type"}; Configurable clusterDefinitions{"clusterDefinitions", "kV3Default", "cluster definition to be selected, e.g. V3Default. Multiple definitions can be specified separated by comma"}; Configurable maxMatchingDistance{"maxMatchingDistance", 0.4f, "Max matching distance track-cluster"}; - Configurable nonlinearityFunction{"nonlinearityFunction", "DATA_TestbeamFinal", "Nonlinearity correction at cluster level"}; + Configurable nonlinearityFunction{"nonlinearityFunction", "DATA_TestbeamFinal_NoScale", "Nonlinearity correction at cluster level. Default for data should be DATA_TestbeamFinal_NoScale. Default for MC should be MC_TestbeamFinal."}; Configurable disableNonLin{"disableNonLin", false, "Disable NonLin correction if set to true"}; Configurable hasShaperCorrection{"hasShaperCorrection", true, "Apply correction for shaper saturation"}; Configurable applyCellAbsScale{"applyCellAbsScale", 0, "Enable absolute cell energy scale to correct for energy loss in material in front of EMCal"}; @@ -94,7 +127,22 @@ struct EmcalCorrectionTask { Configurable exoticCellInCrossMinAmplitude{"exoticCellInCrossMinAmplitude", 0.1, "Minimum energy of cells in cross, if lower not considered in cross"}; Configurable useWeightExotic{"useWeightExotic", false, "States if weights should be used for exotic cell cut"}; Configurable isMC{"isMC", false, "States if run over MC"}; - Configurable applyCellTimeCorrection{"applyCellTimeCorrection", true, "apply a correction to the cell time for data and MC: Shift both average cell times to 0 and smear MC time distribution to fit data better"}; + Configurable applyCellTimeCorrection{"applyCellTimeCorrection", true, "apply a correction to the cell time for data and MC: Shift both average cell times to 0 and smear MC time distribution to fit data better. For MC requires isMC to be true"}; + Configurable trackMinPt{"trackMinPt", 0.3, "Minimum pT for tracks to perform track matching, to reduce computing time. Tracks below a certain pT will be loopers anyway."}; + Configurable fillQA{"fillQA", false, "Switch to turn on QA histograms."}; + Configurable useCCDBAlignment{"useCCDBAlignment", false, "EXPERTS ONLY! Switch to use the alignment object stored in CCDB instead of using the default alignment from the global geometry object."}; + Configurable applyTempCalib{"applyTempCalib", false, "Switch to turn on Temperature calibration."}; + Configurable pathTempCalibCCDB{"pathTempCalibCCDB", "Users/j/jokonig/EMCalTempCalibParams", "Path in the ccdb where slope and intercept for each cell are stored"}; // change to official path as soon as it is available + Configurable useTempCalibMean{"useTempCalibMean", false, "Switch to turn on Temperature mean calculation instead of median."}; + Configurable mcCellEnergyShift{"mcCellEnergyShift", 1., "Relative shift of the MC cell energy. 1.1 for 10% shift to higher mass, etc. Only applied to MC."}; + Configurable mcCellEnergyResolutionBroadening{"mcCellEnergyResolutionBroadening", 0., "Relative widening of the MC cell energy resolution. 0 for no widening, 0.1 for 10% widening, etc. Only applied to MC."}; + Configurable applyGainCalibShift{"applyGainCalibShift", false, "Apply shift for cell gain calibration to use values before cell format change (Sept. 2023)"}; + + // cross talk emulation configs + EmcCrossTalkConf emcCrossTalkConf; + + // cross talk emulation class for handling the cross talk + emccrosstalk::EMCCrossTalk emcCrossTalk; // Require EMCAL cells (CALO type 1) Filter emccellfilter = aod::calo::caloType == selectedCellType; @@ -124,6 +172,20 @@ struct EmcalCorrectionTask { // EMCal geometry o2::emcal::Geometry* geometry; + // EMCal cell temperature calibrator + std::unique_ptr mTempCalibExtractor; + bool mIsTempCalibInitialized = false; + + // Gain calibration + std::array mArrGainCalibDiff; + + std::vector> mExtraTimeShiftRunRanges; + + // Current run number + int runNumber{0}; + + static constexpr float TrackNotOnEMCal = -900.f; + void init(InitContext const&) { LOG(debug) << "Start init!"; @@ -144,6 +206,18 @@ struct EmcalCorrectionTask { if (!geometry) { LOG(error) << "Failure accessing geometry"; } + if (useCCDBAlignment.value) { + geometry->SetMisalMatrixFromCcdb(); + } + + if (applyTempCalib) { + mTempCalibExtractor = std::make_unique(); + } + + // gain calibration shift initialization + if (applyGainCalibShift) { + initializeGainCalibShift(); + } // read all the cluster definitions specified in the options if (clusterDefinitions->length()) { @@ -189,32 +263,41 @@ struct EmcalCorrectionTask { // Define the cell energy binning std::vector cellEnergyBins; - for (int i = 0; i < 51; i++) + for (int i = 0; i < 51; i++) { // o2-linter: disable=magic-number (just numbers for binning) cellEnergyBins.emplace_back(0.1 * (i - 0) + 0.0); // from 0 to 5 GeV/c, every 0.1 GeV - for (int i = 51; i < 76; i++) + } + for (int i = 51; i < 76; i++) { // o2-linter: disable=magic-number (just numbers for binning) cellEnergyBins.emplace_back(0.2 * (i - 51) + 5.2); // from 5.2 to 10.0 GeV, every 0.2 GeV - for (int i = 76; i < 166; i++) + } + for (int i = 76; i < 166; i++) { // o2-linter: disable=magic-number (just numbers for binning) cellEnergyBins.emplace_back(1. * (i - 76) + 11.); // from 11.0 to 100. GeV, every 1 GeV + } // Setup QA hists. // NOTE: This is not comprehensive. using O2HistType = o2::framework::HistType; - o2::framework::AxisSpec energyAxis{200, 0., 100., "E (GeV)"}, - timeAxis{300, -100, 200., "t (ns)"}, - etaAxis{160, -0.8, 0.8, "#eta"}, - phiAxis{72, 0, 2 * 3.14159, "phi"}, - nlmAxis{50, -0.5, 49.5, "NLM"}; - mHistManager.add("hCellE", "hCellE", O2HistType::kTH1F, {energyAxis}); + o2::framework::AxisSpec energyAxis{200, 0., 100., "#it{E} (GeV)"}, + timeAxis{300, -100, 200., "#it{t} (ns)"}, + etaAxis{160, -0.8, 0.8, "#it{#eta}"}, + phiAxis{72, 0, 2 * 3.14159, "#it{#varphi} (rad)"}, + nlmAxis{50, -0.5, 49.5, "NLM"}, + fCrossAxis{100, 0., 1., "F_{+}"}, + sigmaLongAxis{100, 0., 1.0, "#sigma^{2}_{long}"}, + sigmaShortAxis{100, 0., 1.0, "#sigma^{2}_{short}"}, + nCellAxis{60, -0.5, 59.5, "#it{n}_{cells}"}, + energyDenseAxis = {7000, 0.f, 70.f, "#it{E}_{cell} (GeV)"}; + mHistManager.add("hCellE", "hCellE", O2HistType::kTH1D, {energyAxis}); mHistManager.add("hCellTowerID", "hCellTowerID", O2HistType::kTH1D, {{20000, 0, 20000}}); mHistManager.add("hCellEtaPhi", "hCellEtaPhi", O2HistType::kTH2F, {etaAxis, phiAxis}); mHistManager.add("hHGCellTimeEnergy", "hCellTime", O2HistType::kTH2F, {{300, -30, 30}, cellEnergyBins}); // Cell time vs energy for high gain cells (low energies) mHistManager.add("hLGCellTimeEnergy", "hCellTime", O2HistType::kTH2F, {{300, -30, 30}, cellEnergyBins}); // Cell time vs energy for low gain cells (high energies) + mHistManager.add("hTempCalibCorrection", "hTempCalibCorrection", O2HistType::kTH1F, {{5000, 0.5, 1.5}}); // NOTE: Reversed column and row because it's more natural for presentation. mHistManager.add("hCellRowCol", "hCellRowCol;Column;Row", O2HistType::kTH2D, {{96, -0.5, 95.5}, {208, -0.5, 207.5}}); - mHistManager.add("hClusterE", "hClusterE", O2HistType::kTH1F, {energyAxis}); - mHistManager.add("hClusterNLM", "hClusterNLM", O2HistType::kTH1F, {nlmAxis}); + mHistManager.add("hClusterE", "hClusterE", O2HistType::kTH1D, {energyAxis}); + mHistManager.add("hClusterNLM", "hClusterNLM", O2HistType::kTH1D, {nlmAxis}); mHistManager.add("hClusterEtaPhi", "hClusterEtaPhi", O2HistType::kTH2F, {etaAxis, phiAxis}); - mHistManager.add("hClusterTime", "hClusterTime", O2HistType::kTH1F, {timeAxis}); + mHistManager.add("hClusterTime", "hClusterTime", O2HistType::kTH1D, {timeAxis}); mHistManager.add("hGlobalTrackEtaPhi", "hGlobalTrackEtaPhi", O2HistType::kTH2F, {etaAxis, phiAxis}); mHistManager.add("hGlobalTrackMult", "hGlobalTrackMult", O2HistType::kTH1D, {{200, -0.5, 199.5, "N_{trk}"}}); mHistManager.add("hCollisionType", "hCollisionType;;#it{count}", O2HistType::kTH1D, {{3, -0.5, 2.5}}); @@ -222,6 +305,11 @@ struct EmcalCorrectionTask { hCollisionType->GetXaxis()->SetBinLabel(1, "no collision"); hCollisionType->GetXaxis()->SetBinLabel(2, "normal collision"); hCollisionType->GetXaxis()->SetBinLabel(3, "mult. collisions"); + mHistManager.add("hBCMatchErrors", "hBCMatchErrors;;#it{N}_{BC}", O2HistType::kTH1D, {{3, -0.5, 2.5}}); + auto hBCMatchErrors = mHistManager.get(HIST("hBCMatchErrors")); + hBCMatchErrors->GetXaxis()->SetBinLabel(1, "Normal"); + hBCMatchErrors->GetXaxis()->SetBinLabel(2, "Wrong collisionID order"); + hBCMatchErrors->GetXaxis()->SetBinLabel(3, "foundBCId != globalIndex"); mHistManager.add("hClusterType", "hClusterType;;#it{count}", O2HistType::kTH1D, {{3, -0.5, 2.5}}); auto hClusterType = mHistManager.get(HIST("hClusterType")); hClusterType->GetXaxis()->SetBinLabel(1, "no collision"); @@ -239,10 +327,34 @@ struct EmcalCorrectionTask { hBC->GetXaxis()->SetBinLabel(6, "no EMCal cells and with collision"); hBC->GetXaxis()->SetBinLabel(7, "no EMCal cells and mult. collisions"); hBC->GetXaxis()->SetBinLabel(8, "all BC"); - if (isMC) { - mHistManager.add("hContributors", "hContributors;contributor per cell hit;#it{counts}", O2HistType::kTH1I, {{20, 0, 20}}); - mHistManager.add("hMCParticleEnergy", "hMCParticleEnergy;#it{E} (GeV/#it{c});#it{counts}", O2HistType::kTH1F, {energyAxis}); + if (isMC.value) { + mHistManager.add("hContributors", "hContributors;contributor per cell hit;#it{counts}", O2HistType::kTH1D, {{20, 0, 20}}); + mHistManager.add("hMCParticleEnergy", "hMCParticleEnergy;#it{E} (GeV/#it{c});#it{counts}", O2HistType::kTH1D, {energyAxis}); } + if (fillQA.value) { + mHistManager.add("hClusterNCellE", "hClusterNCellE", O2HistType::kTH2D, {energyAxis, nCellAxis}); + mHistManager.add("hClusterFCrossE", "hClusterFCrossE", O2HistType::kTH2D, {energyAxis, fCrossAxis}); + mHistManager.add("hClusterFCrossSigmaLongE", "hClusterFCrossSigmaLongE", O2HistType::kTH3F, {energyAxis, fCrossAxis, sigmaLongAxis}); + mHistManager.add("hClusterFCrossSigmaShortE", "hClusterFCrossSigmaShortE", O2HistType::kTH3F, {energyAxis, fCrossAxis, sigmaShortAxis}); + } + + if (isMC.value && emcCrossTalkConf.enableCrossTalk.value) { + emcCrossTalk.initObjects(emcCrossTalkConf); + if (emcCrossTalkConf.createHistograms.value) { + mHistManager.add("hCellEnergyDistBefore", "Cell energy before cross-talk emulation", {o2::framework::HistType::kTH1D, {energyDenseAxis}}); + mHistManager.add("hCellEnergyDistAfter", "Cell energy after cross-talk emulation", {o2::framework::HistType::kTH1D, {energyDenseAxis}}); + } + } + + // For some runs, LG cells require an extra time shift of 2 * 8.8ns due to problems in the time calibration + // Affected run ranges (inclusive) are initialised here (min,max) + mExtraTimeShiftRunRanges.emplace_back(535365, 535645); // LHC23g-LHC23h + mExtraTimeShiftRunRanges.emplace_back(535725, 536126); // LHC23h-LHC23l + mExtraTimeShiftRunRanges.emplace_back(536199, 536202); // LHC23l-LHC23m + mExtraTimeShiftRunRanges.emplace_back(536239, 536346); // LHC23m-LHC23n + mExtraTimeShiftRunRanges.emplace_back(536565, 536590); // Commisioning-LHC23r + mExtraTimeShiftRunRanges.emplace_back(542280, 543854); // LHC23zv-LHC23zy + mExtraTimeShiftRunRanges.emplace_back(559544, 559856); // PbPb 2024 } // void process(aod::Collision const& collision, soa::Filtered const& fullTracks, aod::Calos const& cells) @@ -254,12 +366,22 @@ struct EmcalCorrectionTask { { LOG(debug) << "Starting process full."; + int previousCollisionId = 0; // Collision ID of the last unique BC. Needed to skip unordered collisions to ensure ordered collisionIds in the cluster table int nBCsProcessed = 0; int nCellsProcessed = 0; std::unordered_map numberCollsInBC; // Number of collisions mapped to the global BC index of all BCs std::unordered_map numberCellsInBC; // Number of cells mapped to the global BC index of all BCs to check whether EMCal was readout for (const auto& bc : bcs) { LOG(debug) << "Next BC"; + + // get run number + runNumber = bc.runNumber(); + + if (applyTempCalib && !mIsTempCalibInitialized) { // needs to be called once + mTempCalibExtractor->InitializeFromCCDB(pathTempCalibCCDB, static_cast(runNumber)); + mIsTempCalibInitialized = true; + } + // Convert aod::Calo to o2::emcal::Cell which can be used with the clusterizer. // In particular, we need to filter only EMCAL cells. @@ -287,9 +409,17 @@ struct EmcalCorrectionTask { if (applyCellAbsScale) { amplitude *= getAbsCellScale(cell.cellNumber()); } + if (applyGainCalibShift) { + amplitude *= mArrGainCalibDiff[cell.cellNumber()]; + } + if (applyTempCalib) { + float tempCalibFactor = mTempCalibExtractor->getGainCalibFactor(static_cast(cell.cellNumber())); + amplitude /= tempCalibFactor; + mHistManager.fill(HIST("hTempCalibCorrection"), tempCalibFactor); + } cellsBC.emplace_back(cell.cellNumber(), amplitude, - cell.time() + getCellTimeShift(cell.cellNumber(), amplitude, o2::emcal::intToChannelType(cell.cellType())), + cell.time() + getCellTimeShift(cell.cellNumber(), amplitude, o2::emcal::intToChannelType(cell.cellType()), runNumber), o2::emcal::intToChannelType(cell.cellType())); cellIndicesBC.emplace_back(cell.globalIndex()); } @@ -298,12 +428,6 @@ struct EmcalCorrectionTask { fillQAHistogram(cellsBC); - // TODO: Helpful for now, but should be removed. - LOG(debug) << "Converted EMCAL cells"; - for (const auto& cell : cellsBC) { - LOG(debug) << cell.getTower() << ": E: " << cell.getEnergy() << ", time: " << cell.getTimeStamp() << ", type: " << cell.getType(); - } - LOG(debug) << "Converted cells. Contains: " << cellsBC.size() << ". Originally " << cellsInBC.size() << ". About to run clusterizer."; // this is a test // Run the clusterizers @@ -314,7 +438,13 @@ struct EmcalCorrectionTask { if (collisionsInFoundBC.size() == 1) { // dummy loop to get the first collision for (const auto& col : collisionsInFoundBC) { + if (previousCollisionId > col.globalIndex()) { + mHistManager.fill(HIST("hBCMatchErrors"), 1); + continue; + } + previousCollisionId = col.globalIndex(); if (col.foundBCId() == bc.globalIndex()) { + mHistManager.fill(HIST("hBCMatchErrors"), 0); // CollisionID ordered and foundBC matches -> Fill as healthy mHistManager.fill(HIST("hCollisionTimeReso"), col.collisionTimeRes()); mHistManager.fill(HIST("hCollPerBC"), 1); mHistManager.fill(HIST("hCollisionType"), 1); @@ -322,13 +452,15 @@ struct EmcalCorrectionTask { std::vector> clusterToTrackIndexMap; std::vector> trackToClusterIndexMap; - std::tuple>, std::vector>> indexMapPair{clusterToTrackIndexMap, trackToClusterIndexMap}; + MatchResult indexMapPair; std::vector trackGlobalIndex; - doTrackMatching(col, tracks, indexMapPair, vertexPos, trackGlobalIndex); + doTrackMatching(col, tracks, indexMapPair, trackGlobalIndex); // Store the clusters in the table where a matching collision could // be identified. - fillClusterTable(col, vertexPos, iClusterizer, cellIndicesBC, indexMapPair, trackGlobalIndex); + fillClusterTable(col, vertexPos, iClusterizer, cellIndicesBC, &indexMapPair, &trackGlobalIndex); + } else { + mHistManager.fill(HIST("hBCMatchErrors"), 2); } } } else { // ambiguous @@ -370,6 +502,7 @@ struct EmcalCorrectionTask { { LOG(debug) << "Starting process full."; + int previousCollisionId = 0; // Collision ID of the last unique BC. Needed to skip unordered collisions to ensure ordered collisionIds in the cluster table int nBCsProcessed = 0; int nCellsProcessed = 0; std::unordered_map numberCollsInBC; // Number of collisions mapped to the global BC index of all BCs @@ -379,6 +512,9 @@ struct EmcalCorrectionTask { // Convert aod::Calo to o2::emcal::Cell which can be used with the clusterizer. // In particular, we need to filter only EMCAL cells. + // get run number + runNumber = bc.runNumber(); + // Get the collisions matched to the BC using foundBCId of the collision auto collisionsInFoundBC = collisions.sliceBy(collisionsPerFoundBC, bc.globalIndex()); auto cellsInBC = cells.sliceBy(mcCellsPerFoundBC, bc.globalIndex()); @@ -400,30 +536,68 @@ struct EmcalCorrectionTask { mHistManager.fill(HIST("hContributors"), cell.mcParticle_as().size()); auto cellParticles = cell.mcParticle_as(); for (const auto& cellparticle : cellParticles) { + const auto& ids = cell.mcParticleIds(); + const auto& amps = cell.amplitudeA(); + + if (ids.empty() || amps.empty()) { + LOGF(warning, "Skipping cell with empty MC info: absId=%d", cell.cellNumber()); + continue; + } mHistManager.fill(HIST("hMCParticleEnergy"), cellparticle.e()); } auto amplitude = cell.amplitude(); if (static_cast(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude); } + if (mcCellEnergyShift != 1.) { + amplitude *= mcCellEnergyShift; // Fine tune the MC cell energy + } + if (mcCellEnergyResolutionBroadening != 0.) { + amplitude *= (1. + normalgaus(rdgen) * mcCellEnergyResolutionBroadening); // Fine tune the MC cell energy resolution + } cellsBC.emplace_back(cell.cellNumber(), amplitude, - cell.time() + getCellTimeShift(cell.cellNumber(), amplitude, o2::emcal::intToChannelType(cell.cellType())), + cell.time() + getCellTimeShift(cell.cellNumber(), amplitude, o2::emcal::intToChannelType(cell.cellType()), runNumber), o2::emcal::intToChannelType(cell.cellType())); cellIndicesBC.emplace_back(cell.globalIndex()); - cellLabels.emplace_back(cell.mcParticleIds(), cell.amplitudeA()); + cellLabels.emplace_back(std::vector{cell.mcParticleIds().begin(), cell.mcParticleIds().end()}, std::vector{cell.amplitudeA().begin(), cell.amplitudeA().end()}); + } + if (isMC.value && emcCrossTalkConf.enableCrossTalk.value) { + if (emcCrossTalkConf.createHistograms.value) { + for (const auto& cell : cellsBC) { + mHistManager.fill(HIST("hCellEnergyDistBefore"), cell.getAmplitude()); + } + } + emcCrossTalk.setCells(cellsBC, cellLabels); + bool isOkCrossTalk = emcCrossTalk.run(); + if (!isOkCrossTalk) { + LOG(info) << "Cross talk emulation failed!"; + } else { + // When we get new cells we also need to add additional entries into cellIndicesBC. + // Adding -1 and later when filling the clusterID<->cellID table skip all cases where this is -1 + if (cellIndicesBC.size() < cellsBC.size()) { + cellIndicesBC.reserve(cellsBC.size()); + size_t nMissing = cellsBC.size() - cellIndicesBC.size(); + cellIndicesBC.insert(cellIndicesBC.end(), nMissing, -1); + } + if (emcCrossTalkConf.createHistograms.value) { + for (const auto& cell : cellsBC) { + mHistManager.fill(HIST("hCellEnergyDistAfter"), cell.getAmplitude()); + } + } + } // cross talk emulation was okay + } // if (isMC.value && emcCrossTalkConf.enableCrossTalk.value) + // shaper correction has to come AFTER cross talk + for (auto& cell : cellsBC) { // o2-linter: disable=const-ref-in-for-loop (we are changing a value here) + if (cell.getLowGain()) { + cell.setAmplitude(o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(cell.getAmplitude())); + } } LOG(detail) << "Number of cells for BC (CF): " << cellsBC.size(); nCellsProcessed += cellsBC.size(); fillQAHistogram(cellsBC); - // TODO: Helpful for now, but should be removed. - LOG(debug) << "Converted EMCAL cells"; - for (const auto& cell : cellsBC) { - LOG(debug) << cell.getTower() << ": E: " << cell.getEnergy() << ", time: " << cell.getTimeStamp() << ", type: " << cell.getType(); - } - LOG(debug) << "Converted cells. Contains: " << cellsBC.size() << ". Originally " << cellsInBC.size() << ". About to run clusterizer."; // this is a test // Run the clusterizers @@ -434,20 +608,28 @@ struct EmcalCorrectionTask { if (collisionsInFoundBC.size() == 1) { // dummy loop to get the first collision for (const auto& col : collisionsInFoundBC) { + if (previousCollisionId > col.globalIndex()) { + mHistManager.fill(HIST("hBCMatchErrors"), 1); + continue; + } + previousCollisionId = col.globalIndex(); if (col.foundBCId() == bc.globalIndex()) { + mHistManager.fill(HIST("hBCMatchErrors"), 0); // CollisionID ordered and foundBC matches -> Fill as healthy mHistManager.fill(HIST("hCollPerBC"), 1); mHistManager.fill(HIST("hCollisionType"), 1); math_utils::Point3D vertexPos = {col.posX(), col.posY(), col.posZ()}; std::vector> clusterToTrackIndexMap; std::vector> trackToClusterIndexMap; - std::tuple>, std::vector>> indexMapPair{clusterToTrackIndexMap, trackToClusterIndexMap}; + MatchResult indexMapPair; std::vector trackGlobalIndex; - doTrackMatching(col, tracks, indexMapPair, vertexPos, trackGlobalIndex); + doTrackMatching(col, tracks, indexMapPair, trackGlobalIndex); // Store the clusters in the table where a matching collision could // be identified. - fillClusterTable(col, vertexPos, iClusterizer, cellIndicesBC, indexMapPair, trackGlobalIndex); + fillClusterTable(col, vertexPos, iClusterizer, cellIndicesBC, &indexMapPair, &trackGlobalIndex); + } else { + mHistManager.fill(HIST("hBCMatchErrors"), 2); } } } else { // ambiguous @@ -486,8 +668,10 @@ struct EmcalCorrectionTask { void processStandalone(aod::BCs const& bcs, aod::Collisions const& collisions, FilteredCells const& cells) { LOG(debug) << "Starting process standalone."; + int previousCollisionId = 0; // Collision ID of the last unique BC. Needed to skip unordered collisions to ensure ordered collisionIds in the cluster table int nBCsProcessed = 0; int nCellsProcessed = 0; + for (const auto& bc : bcs) { LOG(debug) << "Next BC"; // Convert aod::Calo to o2::emcal::Cell which can be used with the clusterizer. @@ -495,6 +679,15 @@ struct EmcalCorrectionTask { // Get the collisions matched to the BC using global bc index of the collision // since we do not have event selection available here! + + // get run number + runNumber = bc.runNumber(); + + if (applyTempCalib && !mIsTempCalibInitialized) { // needs to be called once + mTempCalibExtractor->InitializeFromCCDB(pathTempCalibCCDB, static_cast(runNumber)); + mIsTempCalibInitialized = true; + } + auto collisionsInBC = collisions.sliceBy(collisionsPerBC, bc.globalIndex()); auto cellsInBC = cells.sliceBy(cellsPerFoundBC, bc.globalIndex()); @@ -508,9 +701,21 @@ struct EmcalCorrectionTask { std::vector cellsBC; std::vector cellIndicesBC; for (const auto& cell : cellsInBC) { + auto amplitude = cell.amplitude(); + if (static_cast(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells + amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude); + } + if (applyGainCalibShift) { + amplitude *= mArrGainCalibDiff[cell.cellNumber()]; + } + if (applyTempCalib) { + float tempCalibFactor = mTempCalibExtractor->getGainCalibFactor(static_cast(cell.cellNumber())); + amplitude /= tempCalibFactor; + mHistManager.fill(HIST("hTempCalibCorrection"), tempCalibFactor); + } cellsBC.emplace_back(cell.cellNumber(), - cell.amplitude(), - cell.time() + getCellTimeShift(cell.cellNumber(), cell.amplitude(), o2::emcal::intToChannelType(cell.cellType())), + amplitude, + cell.time() + getCellTimeShift(cell.cellNumber(), amplitude, o2::emcal::intToChannelType(cell.cellType()), runNumber), o2::emcal::intToChannelType(cell.cellType())); cellIndicesBC.emplace_back(cell.globalIndex()); } @@ -519,12 +724,6 @@ struct EmcalCorrectionTask { fillQAHistogram(cellsBC); - // TODO: Helpful for now, but should be removed. - LOG(debug) << "Converted EMCAL cells"; - for (const auto& cell : cellsBC) { - LOG(debug) << cell.getTower() << ": E: " << cell.getEnergy() << ", time: " << cell.getTimeStamp() << ", type: " << cell.getType(); - } - LOG(debug) << "Converted cells. Contains: " << cellsBC.size() << ". Originally " << cellsInBC.size() << ". About to run clusterizer."; // this is a test @@ -536,6 +735,12 @@ struct EmcalCorrectionTask { if (collisionsInBC.size() == 1) { // dummy loop to get the first collision for (const auto& col : collisionsInBC) { + if (previousCollisionId > col.globalIndex()) { + mHistManager.fill(HIST("hBCMatchErrors"), 1); + continue; + } + previousCollisionId = col.globalIndex(); + mHistManager.fill(HIST("hBCMatchErrors"), 0); // CollisionID ordered and foundBC matches -> Fill as healthy mHistManager.fill(HIST("hCollPerBC"), 1); mHistManager.fill(HIST("hCollisionType"), 1); math_utils::Point3D vertexPos = {col.posX(), col.posY(), col.posZ()}; @@ -566,7 +771,7 @@ struct EmcalCorrectionTask { } PROCESS_SWITCH(EmcalCorrectionTask, processStandalone, "run stand alone analysis", false); - void cellsToCluster(size_t iClusterizer, const gsl::span cellsBC, std::optional> cellLabels = std::nullopt) + void cellsToCluster(size_t iClusterizer, const gsl::span cellsBC, gsl::span cellLabels = {}) { mClusterizers.at(iClusterizer)->findClusters(cellsBC); @@ -582,10 +787,10 @@ struct EmcalCorrectionTask { mClusterFactories.reset(); // in preparation for future O2 changes // mClusterFactories.setClusterizerSettings(mClusterDefinitions.at(iClusterizer).minCellEnergy, mClusterDefinitions.at(iClusterizer).timeMin, mClusterDefinitions.at(iClusterizer).timeMax, mClusterDefinitions.at(iClusterizer).recalcShowerShape5x5); - if (cellLabels) { - mClusterFactories.setContainer(*emcalClusters, cellsBC, *emcalClustersInputIndices, cellLabels); - } else { + if (cellLabels.empty()) { mClusterFactories.setContainer(*emcalClusters, cellsBC, *emcalClustersInputIndices); + } else { + mClusterFactories.setContainer(*emcalClusters, cellsBC, *emcalClustersInputIndices, cellLabels); } LOG(debug) << "Cluster factory set up."; @@ -602,24 +807,33 @@ struct EmcalCorrectionTask { } template - void fillClusterTable(Collision const& col, math_utils::Point3D const& vertexPos, size_t iClusterizer, const gsl::span cellIndicesBC, std::optional>, std::vector>>> const& indexMapPair = std::nullopt, std::optional> const& trackGlobalIndex = std::nullopt) + void fillClusterTable(Collision const& col, math_utils::Point3D const& vertexPos, size_t iClusterizer, const gsl::span cellIndicesBC, MatchResult* indexMapPair = nullptr, const std::vector* trackGlobalIndex = nullptr) { + // average number of cells per cluster, only used the reseve a reasonable amount for the clustercells table + const size_t nAvgNcells = 3; // we found a collision, put the clusters into the none ambiguous table clusters.reserve(mAnalysisClusters.size()); - if (mClusterLabels.size() > 0) { + if (!mClusterLabels.empty()) { mcclusters.reserve(mClusterLabels.size()); } + clustercells.reserve(mAnalysisClusters.size() * nAvgNcells); + + // get the clusterType once + const auto clusterType = static_cast(mClusterDefinitions[iClusterizer]); + int cellindex = -1; unsigned int iCluster = 0; + float energy = 0.f; for (const auto& cluster : mAnalysisClusters) { + energy = cluster.E(); // Determine the cluster eta, phi, correcting for the vertex position. auto pos = cluster.getGlobalPosition(); pos = pos - vertexPos; // Normalize the vector and rescale by energy. - pos *= (cluster.E() / std::sqrt(pos.Mag2())); + pos *= (energy / std::sqrt(pos.Mag2())); // Correct for nonlinear behaviour - float nonlinCorrEnergy = cluster.E(); + float nonlinCorrEnergy = energy; if (!disableNonLin) { try { nonlinCorrEnergy = mNonlinearityHandler.getCorrectedClusterEnergy(cluster); @@ -630,35 +844,44 @@ struct EmcalCorrectionTask { // save to table LOG(debug) << "Writing cluster definition " - << static_cast(mClusterDefinitions.at(iClusterizer)) + << clusterType << " to table."; mHistManager.fill(HIST("hClusterType"), 1); - clusters(col, cluster.getID(), nonlinCorrEnergy, cluster.getCoreEnergy(), cluster.E(), + clusters(col, cluster.getID(), nonlinCorrEnergy, cluster.getCoreEnergy(), energy, pos.Eta(), TVector2::Phi_0_2pi(pos.Phi()), cluster.getM02(), cluster.getM20(), cluster.getNCells(), cluster.getClusterTime(), cluster.getIsExotic(), cluster.getDistanceToBadChannel(), cluster.getNExMax(), - static_cast(mClusterDefinitions.at(iClusterizer))); - if (mClusterLabels.size() > 0) { + clusterType); + if (!mClusterLabels.empty()) { mcclusters(mClusterLabels[iCluster].getLabels(), mClusterLabels[iCluster].getEnergyFractions()); } - clustercells.reserve(cluster.getNCells()); // loop over cells in cluster and save to table for (int ncell = 0; ncell < cluster.getNCells(); ncell++) { cellindex = cluster.getCellIndex(ncell); LOG(debug) << "trying to find cell index " << cellindex << " in map"; - clustercells(clusters.lastIndex(), cellIndicesBC[cellindex]); + if (cellIndicesBC[cellindex] >= 0) { + clustercells(clusters.lastIndex(), cellIndicesBC[cellindex]); + } } // end of cells of cluser loop // fill histograms - mHistManager.fill(HIST("hClusterE"), cluster.E()); + mHistManager.fill(HIST("hClusterE"), energy); mHistManager.fill(HIST("hClusterNLM"), cluster.getNExMax()); mHistManager.fill(HIST("hClusterTime"), cluster.getClusterTime()); mHistManager.fill(HIST("hClusterEtaPhi"), pos.Eta(), TVector2::Phi_0_2pi(pos.Phi())); + if (fillQA.value) { + mHistManager.fill(HIST("hClusterNCellE"), cluster.E(), cluster.getNCells()); + mHistManager.fill(HIST("hClusterFCrossE"), cluster.E(), cluster.getFCross()); + mHistManager.fill(HIST("hClusterFCrossSigmaLongE"), cluster.E(), cluster.getFCross(), cluster.getM02()); + mHistManager.fill(HIST("hClusterFCrossSigmaShortE"), cluster.E(), cluster.getFCross(), cluster.getM20()); + } if (indexMapPair && trackGlobalIndex) { - for (unsigned int iTrack = 0; iTrack < std::get<0>(*indexMapPair)[iCluster].size(); iTrack++) { - if (std::get<0>(*indexMapPair)[iCluster][iTrack] >= 0) { - LOG(debug) << "Found track " << (*trackGlobalIndex)[std::get<0>(*indexMapPair)[iCluster][iTrack]] << " in cluster " << cluster.getID(); - matchedTracks(clusters.lastIndex(), (*trackGlobalIndex)[std::get<0>(*indexMapPair)[iCluster][iTrack]]); + if (iCluster < indexMapPair->matchIndexTrack.size() && indexMapPair->matchIndexTrack.size() > 0) { + for (unsigned int iTrack = 0; iTrack < indexMapPair->matchIndexTrack[iCluster].size(); iTrack++) { + if (indexMapPair->matchIndexTrack[iCluster][iTrack] >= 0) { + LOG(debug) << "Found track " << (*trackGlobalIndex)[indexMapPair->matchIndexTrack[iCluster][iTrack]] << " in cluster " << cluster.getID(); + matchedTracks(clusters.lastIndex(), (*trackGlobalIndex)[indexMapPair->matchIndexTrack[iCluster][iTrack]], indexMapPair->matchDeltaPhi[iCluster][iTrack], indexMapPair->matchDeltaEta[iCluster][iTrack]); + } } } } @@ -669,16 +892,25 @@ struct EmcalCorrectionTask { template void fillAmbigousClusterTable(BC const& bc, size_t iClusterizer, const gsl::span cellIndicesBC, bool hasCollision) { + // average number of cells per cluster, only used the reseve a reasonable amount for the clustercells table + const size_t nAvgNcells = 3; int cellindex = -1; clustersAmbiguous.reserve(mAnalysisClusters.size()); + if (mClusterLabels.size() > 0) { + mcclustersAmbiguous.reserve(mClusterLabels.size()); + } + clustercellsambiguous.reserve(mAnalysisClusters.size() * nAvgNcells); + unsigned int iCluster = 0; + float energy = 0.f; for (const auto& cluster : mAnalysisClusters) { + energy = cluster.E(); auto pos = cluster.getGlobalPosition(); pos = pos - math_utils::Point3D{0., 0., 0.}; // Normalize the vector and rescale by energy. - pos *= (cluster.E() / std::sqrt(pos.Mag2())); + pos *= (energy / std::sqrt(pos.Mag2())); // Correct for nonlinear behaviour - float nonlinCorrEnergy = cluster.E(); + float nonlinCorrEnergy = energy; try { nonlinCorrEnergy = mNonlinearityHandler.getCorrectedClusterEnergy(cluster); } catch (o2::emcal::NonlinearityHandler::UninitException& e) { @@ -687,34 +919,37 @@ struct EmcalCorrectionTask { // We have our necessary properties. Now we store outputs - // LOG(debug) << "Cluster E: " << cluster.E(); + // LOG(debug) << "Cluster E: " << energy; if (!hasCollision) { mHistManager.fill(HIST("hClusterType"), 0); } else { mHistManager.fill(HIST("hClusterType"), 2); } clustersAmbiguous( - bc, cluster.getID(), nonlinCorrEnergy, cluster.getCoreEnergy(), cluster.E(), + bc, cluster.getID(), nonlinCorrEnergy, cluster.getCoreEnergy(), energy, pos.Eta(), TVector2::Phi_0_2pi(pos.Phi()), cluster.getM02(), cluster.getM20(), cluster.getNCells(), cluster.getClusterTime(), cluster.getIsExotic(), cluster.getDistanceToBadChannel(), cluster.getNExMax(), static_cast(mClusterDefinitions.at(iClusterizer))); - clustercellsambiguous.reserve(cluster.getNCells()); + if (mClusterLabels.size() > 0) { + mcclustersAmbiguous(mClusterLabels[iCluster].getLabels(), mClusterLabels[iCluster].getEnergyFractions()); + } for (int ncell = 0; ncell < cluster.getNCells(); ncell++) { cellindex = cluster.getCellIndex(ncell); clustercellsambiguous(clustersAmbiguous.lastIndex(), cellIndicesBC[cellindex]); } // end of cells of cluster loop + iCluster++; } // end of cluster loop } template - void doTrackMatching(Collision const& col, MyGlobTracks const& tracks, std::tuple>, std::vector>>& indexMapPair, math_utils::Point3D& vertexPos, std::vector& trackGlobalIndex) + void doTrackMatching(Collision const& col, MyGlobTracks const& tracks, MatchResult& indexMapPair, std::vector& trackGlobalIndex) { auto groupedTracks = tracks.sliceBy(perCollision, col.globalIndex()); int nTracksInCol = groupedTracks.size(); - std::vector trackPhi; - std::vector trackEta; + std::vector trackPhi; + std::vector trackEta; // reserve memory to reduce on the fly memory allocation trackPhi.reserve(nTracksInCol); trackEta.reserve(nTracksInCol); @@ -722,8 +957,8 @@ struct EmcalCorrectionTask { fillTrackInfo(groupedTracks, trackPhi, trackEta, trackGlobalIndex); int nClusterInCol = mAnalysisClusters.size(); - std::vector clusterPhi; - std::vector clusterEta; + std::vector clusterPhi; + std::vector clusterEta; clusterPhi.reserve(nClusterInCol); clusterEta.reserve(nClusterInCol); @@ -733,32 +968,33 @@ struct EmcalCorrectionTask { // Determine the cluster eta, phi, correcting for the vertex // position. auto pos = cluster.getGlobalPosition(); - pos = pos - vertexPos; - // Normalize the vector and rescale by energy. - pos *= (cluster.E() / std::sqrt(pos.Mag2())); clusterPhi.emplace_back(TVector2::Phi_0_2pi(pos.Phi())); clusterEta.emplace_back(pos.Eta()); } - indexMapPair = - jetutilities::MatchClustersAndTracks(clusterPhi, clusterEta, - trackPhi, trackEta, - maxMatchingDistance, 20); + indexMapPair = matchTracksToCluster(clusterPhi, clusterEta, trackPhi, trackEta, maxMatchingDistance, 20); } template - void fillTrackInfo(Tracks const& tracks, std::vector& trackPhi, std::vector& trackEta, std::vector& trackGlobalIndex) + void fillTrackInfo(Tracks const& tracks, std::vector& trackPhi, std::vector& trackEta, std::vector& trackGlobalIndex) { int nTrack = 0; for (const auto& track : tracks) { - // TODO only consider tracks in current emcal/dcal acceptanc if (!track.isGlobalTrack()) { // only global tracks continue; } + // Tracks that do not point to the EMCal/DCal/PHOS get default values of -999 + // This way we can cut out tracks that do not point to the EMCal+DCal + if (track.trackEtaEmcal() < TrackNotOnEMCal || track.trackPhiEmcal() < TrackNotOnEMCal) { + continue; + } + if (trackMinPt > 0 && track.pt() < trackMinPt) { + continue; + } nTrack++; - trackPhi.emplace_back(TVector2::Phi_0_2pi(track.trackPhiEmcal())); + trackPhi.emplace_back(RecoDecay::constrainAngle(track.trackPhiEmcal())); trackEta.emplace_back(track.trackEtaEmcal()); mHistManager.fill(HIST("hGlobalTrackEtaPhi"), track.trackEtaEmcal(), - TVector2::Phi_0_2pi(track.trackPhiEmcal())); + RecoDecay::constrainAngle(track.trackPhiEmcal())); trackGlobalIndex.emplace_back(track.globalIndex()); } mHistManager.fill(HIST("hGlobalTrackMult"), nTrack); @@ -809,12 +1045,12 @@ struct EmcalCorrectionTask { { // Apply cell scale based on SM types (Full, Half (not used), EMC 1/3, DCal, DCal 1/3) // Same as in Run2 data - if (applyCellAbsScale == 1) { + if (applyCellAbsScale == CellScaleMode::ModeSMWise) { int iSM = mClusterizers.at(0)->getGeometry()->GetSuperModuleNumber(cellID); return cellAbsScaleFactors.value[mClusterizers.at(0)->getGeometry()->GetSMType(iSM)]; // Apply cell scale based on columns to accoutn for material of TRD structures - } else if (applyCellAbsScale == 2) { + } else if (applyCellAbsScale == CellScaleMode::ModeColumnWise) { auto res = mClusterizers.at(0)->getGeometry()->GlobalRowColFromIndex(cellID); return cellAbsScaleFactors.value[std::get<1>(res)]; } else { @@ -825,13 +1061,16 @@ struct EmcalCorrectionTask { // Apply shift of the cell time in data and MC // In MC this has to be done to shift the cell time, which is not calibrated to 0 due to the flight time of the particles to the EMCal surface (~15ns) // In data this is done to correct for the time walk effect - float getCellTimeShift(const int16_t cellID, const float cellEnergy, const emcal::ChannelType_t cellType) + float getCellTimeShift(const int16_t cellID, const float cellEnergy, const emcal::ChannelType_t cellType, const int runNumber) { if (!applyCellTimeCorrection) { return 0.f; } float timeshift = 0.f; float timesmear = 0.f; + const float minLeaderEnergy = 0.3f; + const float lowEnergyRegime = 4.f; + const float highEnergyRegime = 30.f; if (isMC) { // ---> MC // Shift the time to 0, as the TOF was simulated -> eta dependent shift (as larger eta values are further away from collision point) // Use distance between vertex and EMCal (at eta = 0) and distance on EMCal surface (cell size times column) to calculate distance to cell @@ -840,7 +1079,7 @@ struct EmcalCorrectionTask { timeshift = -std::sqrt(215.f + timeCol * timeCol); // 215 is 14.67ns^2 (time it takes to get the cell at eta = 0) // Also smear the time to account for the broader time resolution in data than in MC - if (cellEnergy < 0.3) // Cells with tless than 300 MeV cannot be the leading cell in the cluster, so their time does not require precise calibration + if (cellEnergy < minLeaderEnergy) // Cells with tless than 300 MeV cannot be the leading cell in the cluster, so their time does not require precise calibration timesmear = 0.; // They will therefore not be smeared and only get their shift else if (cellType == emcal::ChannelType_t::HIGH_GAIN) // High gain cells -> Low energies timesmear = normalgaus(rdgen) * (1.6 + 9.5 * std::exp(-3. * cellEnergy)); // Parameters extracted from LHC24f3b & LHC22o (pp), but also usable for other periods @@ -848,23 +1087,43 @@ struct EmcalCorrectionTask { timesmear = normalgaus(rdgen) * (5.0); // Parameters extracted from LHC24g4 & LHC24aj (pp), but also usable for other periods } else { // ---> Data - if (cellEnergy < 0.3) { // Cells with tless than 300 MeV cannot be the leading cell in the cluster, so their time does not require precise calibration + if (cellEnergy < minLeaderEnergy) { // Cells with tless than 300 MeV cannot be the leading cell in the cluster, so their time does not require precise calibration timeshift = 0.; // In data they will not be shifted (they are close to 0 anyways) } else if (cellType == emcal::ChannelType_t::HIGH_GAIN) { // High gain cells -> Low energies - if (cellEnergy < 4.) // Low energy regime + if (cellEnergy < lowEnergyRegime) // Low energy regime timeshift = 0.8 * std::log(2.7 * cellEnergy); // Parameters extracted from LHC22o (pp), but also usable for other periods else // Medium energy regime timeshift = 1.5 * std::log(0.9 * cellEnergy); // Parameters extracted from LHC22o (pp), but also usable for other periods } else if (cellType == emcal::ChannelType_t::LOW_GAIN) { // Low gain cells -> High energies - if (cellEnergy < 30.) // High energy regime + if (cellEnergy < highEnergyRegime) // High energy regime timeshift = 1.9 * std::log(0.09 * cellEnergy); // Parameters extracted from LHC24aj (pp), but also usable for other periods else // Very high energy regime timeshift = 1.9; // Parameters extracted from LHC24aj (pp), but also usable for other periods } + // Temporary extra shift for bug in time calibraiton of apass4 Pb-Pb 2024, requires pos shift of 2*8.8 ns for low gain cells + if (cellType == emcal::ChannelType_t::LOW_GAIN) { + for (const auto& range : mExtraTimeShiftRunRanges) { + if (runNumber >= range.first && runNumber <= range.second) { + timeshift += 2 * 8.8; + } + } + } LOG(debug) << "Shift the cell time by " << timeshift << " + " << timesmear << " ns"; } return timeshift + timesmear; }; + + void initializeGainCalibShift() + { + auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance(); + uint64_t tsOld = 1634853602000; // timestamp corresponding to LHC22o old gain calib object + o2::emcal::GainCalibrationFactors* paramsOld = ccdbMgr.getForTimeStamp("EMC/Calib/GainCalibFactors", tsOld); + uint64_t tsNew = 1734853602000; // timestamp corresponding to new gain calib object (new cell compression) + o2::emcal::GainCalibrationFactors* paramsNew = ccdbMgr.getForTimeStamp("EMC/Calib/GainCalibFactors", tsNew); + for (uint16_t i = 0; i < mArrGainCalibDiff.size(); ++i) { + mArrGainCalibDiff[i] = paramsNew->getGainCalibFactors(i) == 0 ? 1. : paramsOld->getGainCalibFactors(i) / paramsNew->getGainCalibFactors(i); + } + } }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/TableProducer/emcalMatchedTracksTask.cxx b/PWGJE/TableProducer/emcalMatchedTracksTask.cxx index 4134b8455e3..55781eb6bc4 100644 --- a/PWGJE/TableProducer/emcalMatchedTracksTask.cxx +++ b/PWGJE/TableProducer/emcalMatchedTracksTask.cxx @@ -9,34 +9,36 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include -#include -#include -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/HistogramRegistry.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/EMCALMatchedTracks.h" +#include "Common/CCDB/TriggerAliases.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "CommonDataFormat/InteractionRecord.h" #include "EMCALBase/Geometry.h" -#include "EMCALCalib/BadChannelMap.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "PWGJE/DataModel/EMCALMatchedTracks.h" -#include "DataFormatsEMCAL/Cell.h" -#include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include +#include -#include "CommonDataFormat/InteractionRecord.h" +#include + +#include +#include +#include +#include +#include // \struct EmcalMatchedTracksTask /// \brief Simple table producer task for EMCal matched tracks diff --git a/PWGJE/TableProducer/eventwiseConstituentSubtractor.cxx b/PWGJE/TableProducer/eventwiseConstituentSubtractor.cxx index c1c1dc19b54..f840a339534 100644 --- a/PWGJE/TableProducer/eventwiseConstituentSubtractor.cxx +++ b/PWGJE/TableProducer/eventwiseConstituentSubtractor.cxx @@ -13,17 +13,25 @@ // /// \author Nima Zardoshti -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGJE/Core/JetBkgSubUtils.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" + #include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" #include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetBkgSubUtils.h" -#include "Framework/runDataProcessing.h" +#include + +#include +#include using namespace o2; using namespace o2::framework; @@ -34,13 +42,21 @@ struct eventWiseConstituentSubtractorTask { Produces particleSubtractedTable; Produces trackSubtractedD0Table; Produces particleSubtractedD0Table; + Produces trackSubtractedDplusTable; + Produces particleSubtractedDplusTable; + Produces trackSubtractedDstarTable; + Produces particleSubtractedDstarTable; Produces trackSubtractedLcTable; Produces particleSubtractedLcTable; + Produces trackSubtractedB0Table; + Produces particleSubtractedB0Table; Produces trackSubtractedBplusTable; Produces particleSubtractedBplusTable; Produces trackSubtractedDielectronTable; Produces particleSubtractedDielectronTable; + Configurable skipMBGapEvents{"skipMBGapEvents", true, "decide to run over MB gap events or not"}; + Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; Configurable trackPtMax{"trackPtMax", 1000.0, "maximum track pT"}; Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track eta"}; @@ -86,7 +102,7 @@ struct eventWiseConstituentSubtractorTask { for (auto& candidate : candidates) { inputParticles.clear(); tracksSubtracted.clear(); - jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, &candidate); tracksSubtracted = eventWiseConstituentSubtractor.JetBkgSubUtils::doEventConstSub(inputParticles, candidate.rho(), candidate.rhoM()); for (auto const& trackSubtracted : tracksSubtracted) { @@ -101,7 +117,7 @@ struct eventWiseConstituentSubtractorTask { for (auto& candidate : candidates) { inputParticles.clear(); tracksSubtracted.clear(); - jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, std::optional{candidate}); // currently only works for charged analyses + jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, &candidate); // currently only works for charged analyses tracksSubtracted = eventWiseConstituentSubtractor.JetBkgSubUtils::doEventConstSub(inputParticles, candidate.rho(), candidate.rhoM()); for (auto const& trackSubtracted : tracksSubtracted) { @@ -112,7 +128,9 @@ struct eventWiseConstituentSubtractorTask { void processCollisions(soa::Join::iterator const& collision, soa::Filtered const& tracks) { - + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } inputParticles.clear(); tracksSubtracted.clear(); jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); @@ -127,7 +145,9 @@ struct eventWiseConstituentSubtractorTask { void processMcCollisions(soa::Join::iterator const& mcCollision, soa::Filtered const& particles) { - + if (skipMBGapEvents && mcCollision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } inputParticles.clear(); tracksSubtracted.clear(); jetfindingutilities::analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 1, particles, pdgDatabase); @@ -152,6 +172,30 @@ struct eventWiseConstituentSubtractorTask { } PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processD0McCollisions, "Fill table of subtracted tracks for collisions with D0 MCP candidates", false); + void processDplusCollisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) + { + analyseHF(tracks, candidates, trackSubtractedDplusTable); + } + PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processDplusCollisions, "Fill table of subtracted tracks for collisions with Dplus candidates", false); + + void processDplusMcCollisions(aod::JetMcCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) + { + analyseHFMc(tracks, candidates, particleSubtractedDplusTable); + } + PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processDplusMcCollisions, "Fill table of subtracted tracks for collisions with Dplus MCP candidates", false); + + void processDstarCollisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) + { + analyseHF(tracks, candidates, trackSubtractedDstarTable); + } + PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processDstarCollisions, "Fill table of subtracted tracks for collisions with D* candidates", false); + + void processDstarMcCollisions(aod::JetMcCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) + { + analyseHFMc(tracks, candidates, particleSubtractedDstarTable); + } + PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processDstarMcCollisions, "Fill table of subtracted tracks for collisions with D* MCP candidates", false); + void processLcCollisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) { analyseHF(tracks, candidates, trackSubtractedLcTable); @@ -164,17 +208,29 @@ struct eventWiseConstituentSubtractorTask { } PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processLcMcCollisions, "Fill table of subtracted tracks for collisions with Lc MCP candidates", false); - void processBplusCollisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) - { - analyseHF(tracks, candidates, trackSubtractedBplusTable); - } - PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processBplusCollisions, "Fill table of subtracted tracks for collisions with Bplus candidates", false); + void processB0Collisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) + { + analyseHF(tracks, candidates, trackSubtractedB0Table); + } + PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processB0Collisions, "Fill table of subtracted tracks for collisions with B0 candidates", false); - void processBplusMcCollisions(aod::JetMcCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) - { - analyseHFMc(tracks, candidates, particleSubtractedBplusTable); - } - PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processBplusMcCollisions, "Fill table of subtracted tracks for collisions with Bplus MCP candidates", false); + void processB0McCollisions(aod::JetMcCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) + { + analyseHFMc(tracks, candidates, particleSubtractedB0Table); + } + PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processB0McCollisions, "Fill table of subtracted tracks for collisions with B0 MCP candidates", false); + + void processBplusCollisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) + { + analyseHF(tracks, candidates, trackSubtractedBplusTable); + } + PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processBplusCollisions, "Fill table of subtracted tracks for collisions with Bplus candidates", false); + + void processBplusMcCollisions(aod::JetMcCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) + { + analyseHFMc(tracks, candidates, particleSubtractedBplusTable); + } + PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processBplusMcCollisions, "Fill table of subtracted tracks for collisions with Bplus MCP candidates", false); void processDielectronCollisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) { diff --git a/PWGJE/TableProducer/heavyFlavourDefinition.cxx b/PWGJE/TableProducer/heavyFlavourDefinition.cxx new file mode 100644 index 00000000000..a9f52f96a35 --- /dev/null +++ b/PWGJE/TableProducer/heavyFlavourDefinition.cxx @@ -0,0 +1,117 @@ +// 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. + +/// \file heavyFlavourDefinition.cxx +/// \brief Task to produce a table joinable to the jet tables for a flavour definition on MC +/// \author Hanseo Park + +#include "PWGJE/Core/JetTaggingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetTagging.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +template +struct HeavyFlavourDefinitionTask { + + Produces flavourTableMCD; + Produces flavourTableMCP; + + Configurable maxDeltaR{"maxDeltaR", 0.25, "maximum distance of jet axis from flavour initiating parton"}; + Configurable searchUpToQuark{"searchUpToQuark", true, "Finding first mother in particles to quark"}; + + using JetTracksMCD = soa::Join; + Preslice particlesPerCollision = aod::jmcparticle::mcCollisionId; + Preslice> particlesPerMcCollision = aod::jmcparticle::mcCollisionId; + + void init(InitContext const&) + { + } + + void processDummy(aod::JetCollisions const&) + { + } + PROCESS_SWITCH(HeavyFlavourDefinitionTask, processDummy, "Dummy process", true); + + void processMCDByConstituents(aod::JetCollision const& /*collision*/, JetTableMCD const& mcdjets, JetTracksMCD const& tracks, aod::JetParticles const& particles) + { + for (auto const& mcdjet : mcdjets) { + int8_t origin = jettaggingutilities::mcdJetFromHFShower(mcdjet, tracks, particles, maxDeltaR, searchUpToQuark); + flavourTableMCD(origin); + } + } + PROCESS_SWITCH(HeavyFlavourDefinitionTask, processMCDByConstituents, "Fill definition of flavour for mcd jets using constituents", false); + + void processMCDByDistance(soa::Join::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, aod::JetParticles const& particles) // it used only for charged jets now + { + for (auto const& mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + int8_t origin = -1; + if (mcdjet.has_matchedJetGeo()) { + for (auto const& mcpjet : mcdjet.template matchedJetGeo_as>()) { + if (searchUpToQuark) { + origin = jettaggingutilities::getJetFlavor(mcpjet, particlesPerColl); + } else { + origin = jettaggingutilities::getJetFlavorHadron(mcpjet, particlesPerColl); + } + } + } else { + origin = JetTaggingSpecies::none; + } + flavourTableMCD(origin); + } + } + PROCESS_SWITCH(HeavyFlavourDefinitionTask, processMCDByDistance, "Fill definition of flavour for mcd jets using distance of jet with particles", false); + + void processMCPByConstituents(JetTableMCP const& mcpjets, aod::JetParticles const& particles) + { + for (auto const& mcpjet : mcpjets) { + int8_t origin = jettaggingutilities::mcpJetFromHFShower(mcpjet, particles, maxDeltaR, searchUpToQuark); + flavourTableMCP(origin); + } + } + PROCESS_SWITCH(HeavyFlavourDefinitionTask, processMCPByConstituents, "Fill definition of flavour for mcp jets using constituents", false); + + void processMCPByDistance(aod::JetMcCollision const& /*mcCollision*/, JetTableMCP const& mcpjets, aod::JetParticles const& particles) + { + for (auto const& mcpjet : mcpjets) { + int8_t origin = -1; + if (searchUpToQuark) { + origin = jettaggingutilities::getJetFlavor(mcpjet, particles); + } else { + origin = jettaggingutilities::getJetFlavorHadron(mcpjet, particles); + } + flavourTableMCP(origin); + } + } + PROCESS_SWITCH(HeavyFlavourDefinitionTask, processMCPByDistance, "Fill definition of flavour for mcp jets using distance of jet with particles", false); +}; + +using JetHfDefinitionCharged = HeavyFlavourDefinitionTask, soa::Join, aod::ChargedMCDetectorLevelJetFlavourDef, aod::ChargedMCParticleLevelJetFlavourDef>; +// using JetHfDefinitionFull = HeavyFlavourDefinitionTask, soa::Join, aod::FullMCDetectorLevelJetFlavourDef, aod::FullMCParticleLevelJetFlavourDef>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"jet-hf-definition-charged"})}; // o2-linter: disable=name/o2-task +} diff --git a/PWGJE/TableProducer/jetEventWeightMCD.cxx b/PWGJE/TableProducer/jetEventWeightMCD.cxx index 40ce7053b8a..7036f5407f6 100644 --- a/PWGJE/TableProducer/jetEventWeightMCD.cxx +++ b/PWGJE/TableProducer/jetEventWeightMCD.cxx @@ -13,19 +13,22 @@ // /// \author Nima Zardoshti -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + #include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" - template struct JetEventWeightMCDTask { @@ -40,14 +43,14 @@ struct JetEventWeightMCDTask { void processMCDetectorLevelEventWeight(MCDetectorLevelJetTable const& jet, soa::Join const&, aod::JetMcCollisions const&) { auto collision = jet.template collision_as>(); - mcDetectorLevelWeightsTable(jet.globalIndex(), collision.mcCollision().weight()); + mcDetectorLevelWeightsTable(jet.globalIndex(), collision.weight()); } PROCESS_SWITCH(JetEventWeightMCDTask, processMCDetectorLevelEventWeight, "Fill event weight tables for detector level MC jets", false); void processMCDetectorLevelEventWiseSubtractedEventWeight(MCDetectorLevelEventWiseSubtractedJetTable const& jet, soa::Join const&, aod::JetMcCollisions const&) { auto collision = jet.template collision_as>(); - mcDetectorLevelEventWiseSubtractedWeightsTable(jet.globalIndex(), collision.mcCollision().weight()); + mcDetectorLevelEventWiseSubtractedWeightsTable(jet.globalIndex(), collision.weight()); } PROCESS_SWITCH(JetEventWeightMCDTask, processMCDetectorLevelEventWiseSubtractedEventWeight, "Fill event weight tables for detector level MC jets", false); }; @@ -56,7 +59,10 @@ using ChargedMCJetsEventWeight = JetEventWeightMCDTask; using FullMCJetsEventWeight = JetEventWeightMCDTask; using D0ChargedMCJetsEventWeight = JetEventWeightMCDTask; +using DplusChargedMCJetsEventWeight = JetEventWeightMCDTask; +using DstarChargedMCJetsEventWeight = JetEventWeightMCDTask; using LcChargedMCJetsEventWeight = JetEventWeightMCDTask; +using B0ChargedMCJetsEventWeight = JetEventWeightMCDTask; using BplusChargedMCJetsEventWeight = JetEventWeightMCDTask; using V0ChargedMCJetsEventWeight = JetEventWeightMCDTask; @@ -81,10 +87,22 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-d0-eventweight-mcd-charged"})); + tasks.emplace_back( + adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, TaskName{"jet-dplus-eventweight-mcd-charged"})); + + tasks.emplace_back( + adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, TaskName{"jet-dstar-eventweight-mcd-charged"})); + tasks.emplace_back( adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-lc-eventweight-mcd-charged"})); + tasks.emplace_back( + adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, TaskName{"jet-b0-eventweight-mcd-charged"})); + tasks.emplace_back( adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-bplus-eventweight-mcd-charged"})); diff --git a/PWGJE/TableProducer/jetEventWeightMCP.cxx b/PWGJE/TableProducer/jetEventWeightMCP.cxx index 6a3a9742546..ba2efb56ced 100644 --- a/PWGJE/TableProducer/jetEventWeightMCP.cxx +++ b/PWGJE/TableProducer/jetEventWeightMCP.cxx @@ -13,19 +13,20 @@ // /// \author Nima Zardoshti +#include "PWGJE/DataModel/Jet.h" + #include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" - template struct JetEventWeightMCPTask { @@ -47,7 +48,10 @@ using ChargedMCJetsEventWeight = JetEventWeightMCPTask; using FullMCJetsEventWeight = JetEventWeightMCPTask; using D0ChargedMCJetsEventWeight = JetEventWeightMCPTask; +using DplusChargedMCJetsEventWeight = JetEventWeightMCPTask; +using DstarChargedMCJetsEventWeight = JetEventWeightMCPTask; using LcChargedMCJetsEventWeight = JetEventWeightMCPTask; +using B0ChargedMCJetsEventWeight = JetEventWeightMCPTask; using BplusChargedMCJetsEventWeight = JetEventWeightMCPTask; using V0ChargedMCJetsEventWeight = JetEventWeightMCPTask; @@ -72,10 +76,22 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-d0-eventweight-mcp-charged"})); + tasks.emplace_back( + adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, TaskName{"jet-dplus-eventweight-mcp-charged"})); + + tasks.emplace_back( + adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, TaskName{"jet-dstar-eventweight-mcp-charged"})); + tasks.emplace_back( adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-lc-eventweight-mcp-charged"})); + tasks.emplace_back( + adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, TaskName{"jet-b0-eventweight-mcp-charged"})); + tasks.emplace_back( adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-bplus-eventweight-mcp-charged"})); diff --git a/PWGJE/TableProducer/jetTaggerHF.cxx b/PWGJE/TableProducer/jetTaggerHF.cxx index 02c1f7aad8d..6e336d9516b 100644 --- a/PWGJE/TableProducer/jetTaggerHF.cxx +++ b/PWGJE/TableProducer/jetTaggerHF.cxx @@ -9,36 +9,60 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// Task to produce a table joinable to the jet tables for hf jet tagging -// +/// \file jetTaggerHF.cxx +/// \brief Task to produce a table joinable to the jet tables for hf jet tagging +/// /// \author Nima Zardoshti /// \author Hanseo Park +/// \author Hadi Hassan , University of Jyväskylä + +#include "MlResponse.h" + +#include "PWGJE/Core/JetTaggingUtilities.h" +#include "PWGJE/Core/MlResponseHfTagging.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetTagging.h" + +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" -#include "Common/Core/trackUtilities.h" +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetTagging.h" -#include "PWGJE/Core/JetTaggingUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -template +template struct JetTaggerHFTask { + static constexpr double DefaultCutsMl[1][2] = {{0.5, 0.5}}; - Produces taggingTableData; - Produces taggingTableMCD; - Produces taggingTableMCP; + Produces taggingTable; // configuration topological cut for track and sv Configurable trackDcaXYMax{"trackDcaXYMax", 1, "minimum DCA xy acceptance for tracks [cm]"}; @@ -46,111 +70,177 @@ struct JetTaggerHFTask { Configurable prongsigmaLxyMax{"prongsigmaLxyMax", 100, "maximum sigma of decay length of prongs on xy plane"}; Configurable prongsigmaLxyzMax{"prongsigmaLxyzMax", 100, "maximum sigma of decay length of prongs on xyz plane"}; Configurable prongIPxyMin{"prongIPxyMin", 0.008, "maximum impact paramter of prongs on xy plane [cm]"}; - Configurable prongIPxyMax{"prongIpxyMax", 1, "minimum impact parmeter of prongs on xy plane [cm]"}; + Configurable prongIPxyMax{"prongIPxyMax", 1, "minimum impact parmeter of prongs on xy plane [cm]"}; Configurable prongChi2PCAMin{"prongChi2PCAMin", 4, "minimum Chi2 PCA of decay length of prongs"}; Configurable prongChi2PCAMax{"prongChi2PCAMax", 100, "maximum Chi2 PCA of decay length of prongs"}; Configurable svDispersionMax{"svDispersionMax", 1, "maximum dispersion of sv"}; - // jet flavour definition - Configurable maxDeltaR{"maxDeltaR", 0.25, "maximum distance of jet axis from flavour initiating parton"}; - Configurable removeGluonShower{"removeGluonShower", true, "find jet origin removed gluon spliting"}; // true:: remove gluon spliting - Configurable searchUpToQuark{"searchUpToQuark", true, "Finding first mother in particles to quark"}; - // configuration about IP method Configurable useJetProb{"useJetProb", false, "fill table for track counting algorithm"}; Configurable trackProbQA{"trackProbQA", false, "fill track probability histograms separately for geometric positive and negative tracks for QA"}; Configurable numCount{"numCount", 3, "number of track counting"}; Configurable resoFuncMatching{"resoFuncMatching", 0, "matching parameters of resolution function as MC samble (0: custom, 1: custom & inc, 2: MB, 3: MB & inc, 4: JJ, 5: JJ & inc)"}; - Configurable> paramsResoFuncData{"paramsResoFuncData", std::vector{1306800, -0.1049, 0.861425, 13.7547, 0.977967, 8.96823, 0.151595, 6.94499, 0.0250301}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7))"}; - Configurable> paramsResoFuncIncJetMC{"paramsResoFuncIncJetMC", std::vector{1908803.027, -0.059, 0.895, 13.467, 1.005, 8.867, 0.098, 6.929, 0.011}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"}; - Configurable> paramsResoFuncCharmJetMC{"paramsResoFuncCharmJetMC", std::vector{282119.753, -0.065, 0.893, 11.608, 0.945, 8.029, 0.131, 6.244, 0.027}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"}; - Configurable> paramsResoFuncBeautyJetMC{"paramsResoFuncBeautyJetMC", std::vector{74901.583, -0.082, 0.874, 10.332, 0.941, 7.352, 0.097, 6.220, 0.022}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"}; - Configurable> paramsResoFuncLfJetMC{"paramsResoFuncLfJetMC", std::vector{1539435.343, -0.061, 0.896, 13.272, 1.034, 5.884, 0.004, 7.843, 0.090}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"}; - Configurable minSignImpXYSig{"minsIPs", -40.0, "minimum of signed impact parameter significance"}; - Configurable minIPCount{"minIPCount", 2, "Select at least N signed impact parameter significance in jets"}; // default 2 + Configurable> pathsCCDBforIPDataparameter{"pathsCCDBforIPDataparameter", std::vector{"Users/l/leehy/LHC24g4/f_inclusive_0"}, "Paths for fitting parameters of resolution functions of data for IP method on CCDB"}; + Configurable> pathsCCDBforIPIncparameter{"pathsCCDBforIPIncparameter", std::vector{"Users/l/leehy/LHC24g4/f_inclusive_0"}, "Paths for fitting parameters of resolution functions of inclusive for IP method on CCDB"}; + Configurable> pathsCCDBforIPBeautyparameter{"pathsCCDBforIPBeautyparameter", std::vector{"Users/l/leehy/LHC24g4/f_inclusive_0"}, "Paths for fitting parameters of resolution functions of beauty for IP method on CCDB"}; + Configurable> pathsCCDBforIPCharmparameter{"pathsCCDBforIPCharmparameter", std::vector{"Users/l/leehy/LHC24g4/f_inclusive_0"}, "Paths for fitting parameters of resolution functions of charm for IP method on CCDB"}; + Configurable> pathsCCDBforIPLfparameter{"pathsCCDBforIPLfparameter", std::vector{"Users/l/leehy/LHC24g4/f_inclusive_0"}, "Paths for fitting parameters of resolution functions of light flavour for IP method on CCDB"}; + Configurable usepTcategorize{"usepTcategorize", false, "p_T categorize TF1 function with Inclusive jet"}; + Configurable> paramsResoFuncData{"paramsResoFuncData", std::vector{-1.0}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7))"}; + Configurable> paramsResoFuncIncJetMC{"paramsResoFuncIncJetMC", std::vector{-1.0}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"}; + Configurable> paramsResoFuncCharmJetMC{"paramsResoFuncCharmJetMC", std::vector{-1.0}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"}; + Configurable> paramsResoFuncBeautyJetMC{"paramsResoFuncBeautyJetMC", std::vector{-1.0}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"}; + Configurable> paramsResoFuncLfJetMC{"paramsResoFuncLfJetMC", std::vector{-1.0}, "parameters of gaus(0)+expo(3)+expo(5)+expo(7)))"}; + Configurable minSignImpXYSig{"minSignImpXYSig", -40.0, "minimum of signed impact parameter significance"}; Configurable tagPointForIP{"tagPointForIP", 2.5, "tagging working point for IP"}; Configurable tagPointForIPxyz{"tagPointForIPxyz", 2.5, "tagging working point for IP xyz"}; // configuration about SV method Configurable tagPointForSV{"tagPointForSV", 40, "tagging working point for SV"}; Configurable tagPointForSVxyz{"tagPointForSVxyz", 40, "tagging working point for SV xyz"}; + // ML configuration + Configurable nJetConst{"nJetConst", 10, "maximum number of jet consistuents to be used for ML evaluation"}; + Configurable trackPtMin{"trackPtMin", 0.5, "minimum track pT"}; + Configurable svPtMin{"svPtMin", 0.5, "minimum SV pT"}; + + Configurable svReductionFactor{"svReductionFactor", 1.0, "factor for how many SVs to keep"}; + + Configurable> binsPtMl{"binsPtMl", std::vector{5., 1000.}, "pT bin limits for ML application"}; + Configurable> cutDirMl{"cutDirMl", std::vector{cuts_ml::CutSmaller, cuts_ml::CutNot}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsMl{"cutsMl", {DefaultCutsMl[0], 1, 2, {"pT bin 0"}, {"score for default b-jet tagging", "uncer 1"}}, "ML selections per pT bin"}; + Configurable nClassesMl{"nClassesMl", 2, "Number of classes in ML model"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; + Configurable useDb{"useDb", false, "Flag to use DB for ML model instead of the score"}; + + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"Users/h/hahassan"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ML_bjets/Models/LHC24g4_70_200/model.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + + // GNN configuration + Configurable fC{"fC", 0.018, "Parameter f_c for D_b calculation"}; + Configurable nJetFeat{"nJetFeat", 4, "Number of jet GNN input features"}; + Configurable nTrkFeat{"nTrkFeat", 13, "Number of track GNN input features"}; + Configurable nTrkOrigin{"nTrkOrigin", 5, "Number of track origin categories"}; + Configurable> transformFeatureJetMean{"transformFeatureJetMean", + std::vector{-999}, + "Mean values for each GNN input feature (jet)"}; + Configurable> transformFeatureJetStdev{"transformFeatureJetStdev", + std::vector{-999}, + "Stdev values for each GNN input feature (jet)"}; + Configurable> transformFeatureTrkMean{"transformFeatureTrkMean", + std::vector{-999}, + "Mean values for each GNN input feature (track)"}; + Configurable> transformFeatureTrkStdev{"transformFeatureTrkStdev", + std::vector{-999}, + "Stdev values for each GNN input feature (track)"}; + // axis spec ConfigurableAxis binTrackProbability{"binTrackProbability", {100, 0.f, 1.f}, ""}; ConfigurableAxis binJetFlavour{"binJetFlavour", {6, -0.5, 5.5}, ""}; - using JetTagTracksData = soa::Join; - using JetTagTracksMCD = soa::Join; + o2::analysis::MlResponseHfTagging bMlResponse; + o2::ccdb::CcdbApi ccdbApi; + + using JetTracksExt = soa::Join; + using OriginalTracks = soa::Join; - std::vector vecParamsData; - std::vector vecParamsIncJetMC; - std::vector vecParamsCharmJetMC; - std::vector vecParamsBeautyJetMC; - std::vector vecParamsLfJetMC; - std::vector jetProb; bool useResoFuncFromIncJet = false; int maxOrder = -1; int resoFuncMatch = 0; + std::unique_ptr fSignImpXYSigData = nullptr; std::unique_ptr fSignImpXYSigIncJetMC = nullptr; std::unique_ptr fSignImpXYSigCharmJetMC = nullptr; std::unique_ptr fSignImpXYSigBeautyJetMC = nullptr; std::unique_ptr fSignImpXYSigLfJetMC = nullptr; + std::vector> vecParamsDataJetCCDB; + std::vector> vecParamsIncJetMcCCDB; + std::vector> vecParamsBeautyJetMcCCDB; + std::vector> vecParamsCharmJetMcCCDB; + std::vector> vecParamsLfJetMcCCDB; + + std::vector> vecfSignImpXYSigDataJetCCDB; + std::vector> vecfSignImpXYSigIncJetMcCCDB; + std::vector> vecfSignImpXYSigCharmJetMcCCDB; + std::vector> vecfSignImpXYSigBeautyJetMcCCDB; + std::vector> vecfSignImpXYSigLfJetMcCCDB; + + std::vector decisionNonML; + std::vector scoreML; + + o2::analysis::GNNBjetAllocator tensorAlloc; + template - void calculateJetProbability(int origin, T const& jet, U const& jtracks, std::vector& jetProb, bool const& isMC = true) + float calculateJetProbability(int origin, T const& jet, U const& tracks, bool const& isMC = false) { - jetProb.clear(); - jetProb.reserve(maxOrder); - for (int order = 0; order < maxOrder; order++) { - if (!isMC) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigData, jet, jtracks, trackDcaXYMax, trackDcaZMax, order, tagPointForIP, minSignImpXYSig)); + float jetProb = -1.0; + if (!isMC) { + if (usepTcategorize) { + jetProb = jettaggingutilities::getJetProbability(vecfSignImpXYSigDataJetCCDB, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); } else { - if (useResoFuncFromIncJet) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigIncJetMC, jet, jtracks, trackDcaXYMax, trackDcaZMax, order, tagPointForIP, minSignImpXYSig)); + jetProb = jettaggingutilities::getJetProbability(fSignImpXYSigData, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); + } + } else { + if (useResoFuncFromIncJet) { + if (usepTcategorize) { + jetProb = jettaggingutilities::getJetProbability(vecfSignImpXYSigIncJetMcCCDB, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); } else { - if (origin == JetTaggingSpecies::charm) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigCharmJetMC, jet, jtracks, trackDcaXYMax, trackDcaZMax, order, tagPointForIP, minSignImpXYSig)); - } - if (origin == JetTaggingSpecies::beauty) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigBeautyJetMC, jet, jtracks, trackDcaXYMax, trackDcaZMax, order, tagPointForIP, minSignImpXYSig)); + jetProb = jettaggingutilities::getJetProbability(fSignImpXYSigIncJetMC, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); + } + } else { + if (origin == JetTaggingSpecies::charm) { + if (usepTcategorize) { + jetProb = jettaggingutilities::getJetProbability(vecfSignImpXYSigCharmJetMcCCDB, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); + } else { + jetProb = jettaggingutilities::getJetProbability(fSignImpXYSigCharmJetMC, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); } - if (origin == JetTaggingSpecies::lightflavour) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigLfJetMC, jet, jtracks, trackDcaXYMax, trackDcaZMax, order, tagPointForIP, minSignImpXYSig)); + } else if (origin == JetTaggingSpecies::beauty) { + if (usepTcategorize) { + jetProb = jettaggingutilities::getJetProbability(vecfSignImpXYSigBeautyJetMcCCDB, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); + } else { + jetProb = jettaggingutilities::getJetProbability(fSignImpXYSigBeautyJetMC, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); } - if (origin != JetTaggingSpecies::charm && origin != JetTaggingSpecies::beauty && origin != JetTaggingSpecies::lightflavour) { - jetProb.push_back(-1); + } else { + if (usepTcategorize) { + jetProb = jettaggingutilities::getJetProbability(vecfSignImpXYSigLfJetMcCCDB, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); + } else { + jetProb = jettaggingutilities::getJetProbability(fSignImpXYSigLfJetMC, jet, tracks, trackDcaXYMax, trackDcaZMax, minSignImpXYSig); } } } } + return jetProb; } template - void evaluateTrackProbQA(int origin, T const& jet, U const& /*jtracks*/, bool const& isMC = true) + void evaluateTrackProbQA(int origin, T const& jet, U const& /*tracks*/, bool const& isMC = true) { - for (auto& jtrack : jet.template tracks_as()) { - if (!jettaggingutilities::trackAcceptanceWithDca(jtrack, trackDcaXYMax, trackDcaZMax)) + for (const auto& track : jet.template tracks_as()) { + if (!jettaggingutilities::trackAcceptanceWithDca(track, trackDcaXYMax, trackDcaZMax)) continue; - auto geoSign = jettaggingutilities::getGeoSign(jet, jtrack); + auto geoSign = jettaggingutilities::getGeoSign(jet, track); float probTrack = -1; if (!isMC) { - probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigData, jtrack, minSignImpXYSig); + probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigData, track, minSignImpXYSig); if (geoSign > 0) registry.fill(HIST("h_pos_track_probability"), probTrack); else registry.fill(HIST("h_neg_track_probability"), probTrack); } else { if (useResoFuncFromIncJet) { - probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigIncJetMC, jtrack, minSignImpXYSig); + probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigIncJetMC, track, minSignImpXYSig); } else { if (origin == JetTaggingSpecies::charm) { - probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigCharmJetMC, jtrack, minSignImpXYSig); + probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigCharmJetMC, track, minSignImpXYSig); } if (origin == JetTaggingSpecies::beauty) { - probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigBeautyJetMC, jtrack, minSignImpXYSig); + probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigBeautyJetMC, track, minSignImpXYSig); } if (origin == JetTaggingSpecies::lightflavour) { - probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigLfJetMC, jtrack, minSignImpXYSig); + probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigLfJetMC, track, minSignImpXYSig); } } if (geoSign > 0) @@ -161,13 +251,110 @@ struct JetTaggerHFTask { } } + template + void fillTables(T const& jet, U const& tracks) + { + int origin = -1; + float jetProb = -1.0; + if constexpr (isMC) { + origin = jet.origin(); + } + if (useJetProb) { + if constexpr (isMC) { + jetProb = calculateJetProbability(origin, jet, tracks, isMC); + if (trackProbQA) { + evaluateTrackProbQA(origin, jet, tracks, isMC); + } + } else { + jetProb = calculateJetProbability(0, jet, tracks, isMC); + if (trackProbQA) { + evaluateTrackProbQA(0, jet, tracks, isMC); + } + } + } + if (doprocessAlgorithmGNN) { + if constexpr (isMC) { + switch (origin) { + case 2: + registry.fill(HIST("h_db_b"), scoreML[jet.globalIndex()]); + break; + case 1: + registry.fill(HIST("h_db_c"), scoreML[jet.globalIndex()]); + break; + case 0: + case 3: + registry.fill(HIST("h_db_lf"), scoreML[jet.globalIndex()]); + break; + default: + LOGF(debug, "doprocessAlgorithmGNN, Unexpected origin value: %d (%d)", origin, jet.globalIndex()); + } + } + registry.fill(HIST("h2_pt_db"), jet.pt(), scoreML[jet.globalIndex()]); + } + taggingTable(decisionNonML[jet.globalIndex()], jetProb, scoreML[jet.globalIndex()]); + } + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(InitContext const&) { + std::vector vecParamsData; + std::vector vecParamsIncJetMC; + std::vector vecParamsCharmJetMC; + std::vector vecParamsBeautyJetMC; + std::vector vecParamsLfJetMC; + + std::vector resoFuncDataCCDB; + std::vector resoFuncIncCCDB; + std::vector resoFuncBeautyCCDB; + std::vector resoFuncCharmCCDB; + std::vector resoFuncLfCCDB; + + ccdbApi.init(ccdbUrl); + + std::map metadata; + resoFuncMatch = resoFuncMatching; + + const int mIPmethodResolutionFunctionSize = 7; + + auto loadCCDBforIP = [&](const std::vector& paths, std::vector& targetVec, const std::string& name) { + if (paths.size() != mIPmethodResolutionFunctionSize) { + usepTcategorize.value = false; + LOG(info) << name << " does not have 7 entries. Disabling pT categorization (usepTcategorize = false)."; + resoFuncMatch = 0; + return; + } + for (int i = 0; i < mIPmethodResolutionFunctionSize; i++) { + targetVec.push_back(ccdbApi.retrieveFromTFileAny(paths[i], metadata, -1)); + } + }; + + if (usepTcategorize) { + switch (resoFuncMatch) { + case 6: + loadCCDBforIP(pathsCCDBforIPIncparameter, resoFuncIncCCDB, "pathsCCDBforIPIncparameter"); + break; + + case 7: + loadCCDBforIP(pathsCCDBforIPBeautyparameter, resoFuncBeautyCCDB, "pathsCCDBforIPBeautyparameter"); + loadCCDBforIP(pathsCCDBforIPCharmparameter, resoFuncCharmCCDB, "pathsCCDBforIPCharmparameter"); + loadCCDBforIP(pathsCCDBforIPLfparameter, resoFuncLfCCDB, "pathsCCDBforIPLfparameter"); + break; + + case 8: + loadCCDBforIP(pathsCCDBforIPDataparameter, resoFuncDataCCDB, "pathsCCDBforIPDataparameter"); + break; + + default: + LOG(info) << "resoFuncMatching is neither 6 nor 7, although usepTcategorize is set to true. Resetting resoFuncMatching to 0."; + resoFuncMatch = 0; + break; + } + } + maxOrder = numCount + 1; // 0: untagged, >1 : N ordering + const int mIPmethodNumOfParameters = 9; // Set up the resolution function - resoFuncMatch = resoFuncMatching; switch (resoFuncMatch) { case 0: vecParamsData = (std::vector)paramsResoFuncData; @@ -208,6 +395,63 @@ struct JetTaggerHFTask { LOG(info) << "defined parameters of resolution function: PYTHIA8, JJ, weighted, LHC24g4 & use inclusive distribution"; useResoFuncFromIncJet = true; break; + case 6: // TODO + vecParamsData = (std::vector)paramsResoFuncData; + for (size_t j = 0; j < resoFuncIncCCDB.size(); j++) { + std::vector params; + if (resoFuncIncCCDB[j]) { + for (int i = 0; i < mIPmethodNumOfParameters; i++) { + params.emplace_back(resoFuncIncCCDB[j]->GetParameter(i)); + } + } + vecParamsIncJetMcCCDB.emplace_back(params); + } + LOG(info) << "defined parameters of resolution function from CCDB"; + useResoFuncFromIncJet = true; + break; + case 7: // TODO + vecParamsData = (std::vector)paramsResoFuncData; + for (size_t j = 0; j < resoFuncBeautyCCDB.size(); j++) { + std::vector params; + if (resoFuncBeautyCCDB[j]) { + for (int i = 0; i < mIPmethodNumOfParameters; i++) { + params.emplace_back(resoFuncBeautyCCDB[j]->GetParameter(i)); + } + } + vecParamsBeautyJetMcCCDB.emplace_back(params); + } + for (size_t j = 0; j < resoFuncCharmCCDB.size(); j++) { + std::vector params; + if (resoFuncCharmCCDB[j]) { + for (int i = 0; i < mIPmethodNumOfParameters; i++) { + params.emplace_back(resoFuncCharmCCDB[j]->GetParameter(i)); + } + } + vecParamsCharmJetMcCCDB.emplace_back(params); + } + for (size_t j = 0; j < resoFuncLfCCDB.size(); j++) { + std::vector params; + if (resoFuncLfCCDB[j]) { + for (int i = 0; i < mIPmethodNumOfParameters; i++) { + params.emplace_back(resoFuncLfCCDB[j]->GetParameter(i)); + } + } + vecParamsLfJetMcCCDB.emplace_back(params); + } + LOG(info) << "defined parameters of resolution function from CCDB for each flavour"; + break; + case 8: + for (size_t j = 0; j < resoFuncDataCCDB.size(); j++) { + std::vector params; + if (resoFuncDataCCDB[j]) { + for (int i = 0; i < mIPmethodNumOfParameters; i++) { + params.emplace_back(resoFuncDataCCDB[j]->GetParameter(i)); + } + } + vecParamsDataJetCCDB.emplace_back(params); + } + LOG(info) << "defined parameters of resolution function from CCDB for data"; + break; default: LOG(fatal) << "undefined parameters of resolution function. Fix it!"; break; @@ -219,187 +463,211 @@ struct JetTaggerHFTask { fSignImpXYSigBeautyJetMC = jettaggingutilities::setResolutionFunction(vecParamsBeautyJetMC); fSignImpXYSigLfJetMC = jettaggingutilities::setResolutionFunction(vecParamsLfJetMC); + for (const auto& params : vecParamsDataJetCCDB) { + vecfSignImpXYSigDataJetCCDB.emplace_back(jettaggingutilities::setResolutionFunction(params)); + } + for (const auto& params : vecParamsIncJetMcCCDB) { + vecfSignImpXYSigIncJetMcCCDB.emplace_back(jettaggingutilities::setResolutionFunction(params)); + } + for (const auto& params : vecParamsBeautyJetMcCCDB) { + vecfSignImpXYSigBeautyJetMcCCDB.emplace_back(jettaggingutilities::setResolutionFunction(params)); + } + for (const auto& params : vecParamsCharmJetMcCCDB) { + vecfSignImpXYSigCharmJetMcCCDB.emplace_back(jettaggingutilities::setResolutionFunction(params)); + } + for (const auto& params : vecParamsLfJetMcCCDB) { + vecfSignImpXYSigLfJetMcCCDB.emplace_back(jettaggingutilities::setResolutionFunction(params)); + } + // Use QA for effectivness of track probability if (trackProbQA) { AxisSpec trackProbabilityAxis = {binTrackProbability, "Track proability"}; AxisSpec jetFlavourAxis = {binJetFlavour, "Jet flavour"}; - if (doprocessData || doprocessDataWithSV) { - registry.add("h_pos_track_probability", "positive track probability", {HistType::kTH1F, {{trackProbabilityAxis}}}); - registry.add("h_neg_track_probability", "negative track probability", {HistType::kTH1F, {{trackProbabilityAxis}}}); + if (doprocessFillTables) { + if (isMCD) { + registry.add("h2_pos_track_probability_flavour", "positive track probability", {HistType::kTH2F, {{trackProbabilityAxis}, {jetFlavourAxis}}}); + registry.add("h2_neg_track_probability_flavour", "negative track probability", {HistType::kTH2F, {{trackProbabilityAxis}, {jetFlavourAxis}}}); + } else { + registry.add("h_pos_track_probability", "positive track probability", {HistType::kTH1F, {{trackProbabilityAxis}}}); + registry.add("h_neg_track_probability", "negative track probability", {HistType::kTH1F, {{trackProbabilityAxis}}}); + } } - if (doprocessMCD || doprocessMCDWithSV) { - registry.add("h2_pos_track_probability_flavour", "positive track probability", {HistType::kTH2F, {{trackProbabilityAxis}, {jetFlavourAxis}}}); - registry.add("h2_neg_track_probability_flavour", "negative track probability", {HistType::kTH2F, {{trackProbabilityAxis}, {jetFlavourAxis}}}); + } + + if (doprocessAlgorithmML || doprocessAlgorithmGNN) { + bMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + bMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + bMlResponse.setModelPathsLocal(onnxFileNames); } + bMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + bMlResponse.init(); } - } - void processDummy(aod::JetCollisions const&) - { + if (doprocessAlgorithmGNN) { + tensorAlloc = o2::analysis::GNNBjetAllocator(nJetFeat.value, nTrkFeat.value, nClassesMl.value, nTrkOrigin.value, transformFeatureJetMean.value, transformFeatureJetStdev.value, transformFeatureTrkMean.value, transformFeatureTrkStdev.value, nJetConst); + registry.add("h_db_b", "#it{D}_{b} b-jet;#it{D}_{b}", {HistType::kTH1F, {{50, -10., 35.}}}); + registry.add("h_db_c", "#it{D}_{b} c-jet;#it{D}_{b}", {HistType::kTH1F, {{50, -10., 35.}}}); + registry.add("h_db_lf", "#it{D}_{b} lf-jet;#it{D}_{b}", {HistType::kTH1F, {{50, -10., 35.}}}); + registry.add("h2_pt_db", "#it{p}_{T} vs. #it{D}_{b};#it{p}_{T}^{ch jet} (GeV/#it{c}^{2});#it{D}_{b}", {HistType::kTH2F, {{100, 0., 200.}, {50, -10., 35.}}}); + } } - PROCESS_SWITCH(JetTaggerHFTask, processDummy, "Dummy process", true); - void processData(aod::JetCollision const& /*collision*/, JetTableData const& jets, JetTagTracksData const& jtracks) + template + void analyzeJetAlgorithmML(AnyJets const& alljets, AnyTracks const& allTracks, SecondaryVertices const& allSVs) { - for (auto& jet : jets) { - bool flagtaggedjetIP = false; - bool flagtaggedjetIPxyz = false; - bool flagtaggedjetSV = false; - bool flagtaggedjetSVxyz = false; - if (useJetProb) { - calculateJetProbability(0, jet, jtracks, jetProb, false); - if (trackProbQA) { - evaluateTrackProbQA(0, jet, jtracks, false); - } + for (const auto& analysisJet : alljets) { + + std::vector tracksParams; + std::vector svsParams; + + jettaggingutilities::analyzeJetSVInfo4ML(analysisJet, allTracks, allSVs, svsParams, svPtMin, svReductionFactor); + jettaggingutilities::analyzeJetTrackInfo4ML(analysisJet, allTracks, allSVs, tracksParams, trackPtMin, trackDcaXYMax, trackDcaZMax); + + int nSVs = analysisJet.template secondaryVertices_as().size(); + + jettaggingutilities::BJetParams jetparam = {analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), static_cast(tracksParams.size()), static_cast(nSVs), analysisJet.mass()}; + tracksParams.resize(nJetConst); // resize to the number of inputs of the ML + svsParams.resize(nJetConst); // resize to the number of inputs of the ML + + std::vector output; + + if (bMlResponse.getInputShape().size() > 1) { + auto inputML = bMlResponse.getInputFeatures2D(jetparam, tracksParams, svsParams); + bMlResponse.isSelectedMl(inputML, analysisJet.pt(), output); + } else { + auto inputML = bMlResponse.getInputFeatures1D(jetparam, tracksParams, svsParams); + bMlResponse.isSelectedMl(inputML, analysisJet.pt(), output); } - if (jettaggingutilities::isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, false)) - flagtaggedjetIP = true; - if (jettaggingutilities::isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, true)) - flagtaggedjetIPxyz = true; - taggingTableData(0, jetProb, flagtaggedjetIP, flagtaggedjetIPxyz, flagtaggedjetSV, flagtaggedjetSVxyz); + if (bMlResponse.getOutputNodes() > 1) { + auto mDb = [](std::vector scores, float fC) { + return std::log(scores[2] / (fC * scores[1] + (1 - fC) * scores[0])); + }; + + scoreML[analysisJet.globalIndex()] = useDb ? mDb(output, fC) : output[2]; // 2 is the b-jet index + } else { + scoreML[analysisJet.globalIndex()] = output[0]; + } } } - PROCESS_SWITCH(JetTaggerHFTask, processData, "Fill tagging decision for data jets", false); - void processDataWithSV(aod::JetCollision const& /*collision*/, soa::Join const& jets, JetTagTracksData const& jtracks, aod::DataSecondaryVertex3Prongs const& prongs) + template + void analyzeJetAlgorithmMLnoSV(AnyJets const& alljets, AnyTracks const& allTracks) { - for (auto& jet : jets) { - bool flagtaggedjetIP = false; - bool flagtaggedjetIPxyz = false; - bool flagtaggedjetSV = false; - bool flagtaggedjetSVxyz = false; - if (useJetProb) { - calculateJetProbability(0, jet, jtracks, jetProb, false); - if (trackProbQA) { - evaluateTrackProbQA(0, jet, jtracks, false); - } + for (const auto& analysisJet : alljets) { + + std::vector tracksParams; + std::vector svsParams; + + jettaggingutilities::analyzeJetTrackInfo4MLnoSV(analysisJet, allTracks, tracksParams, trackPtMin, trackDcaXYMax, trackDcaZMax); + + jettaggingutilities::BJetParams jetparam = {analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), static_cast(tracksParams.size()), 0, analysisJet.mass()}; + tracksParams.resize(nJetConst); // resize to the number of inputs of the ML + + std::vector output; + + if (bMlResponse.getInputShape().size() > 1) { + auto inputML = bMlResponse.getInputFeatures2D(jetparam, tracksParams, svsParams); + bMlResponse.isSelectedMl(inputML, analysisJet.pt(), output); + } else { + auto inputML = bMlResponse.getInputFeatures1D(jetparam, tracksParams, svsParams); + bMlResponse.isSelectedMl(inputML, analysisJet.pt(), output); } - if (jettaggingutilities::isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, false)) - flagtaggedjetIP = true; - if (jettaggingutilities::isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, true)) - flagtaggedjetIPxyz = true; - flagtaggedjetSV = jettaggingutilities::isTaggedJetSV(jet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, svDispersionMax, false, tagPointForSV); - flagtaggedjetSVxyz = jettaggingutilities::isTaggedJetSV(jet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyzMax, svDispersionMax, true, tagPointForSV); - taggingTableData(0, jetProb, flagtaggedjetIP, flagtaggedjetIPxyz, flagtaggedjetSV, flagtaggedjetSVxyz); + + scoreML[analysisJet.globalIndex()] = output[0]; } } - PROCESS_SWITCH(JetTaggerHFTask, processDataWithSV, "Fill tagging decision for data jets", false); - void processMCD(aod::JetCollision const& /*collision*/, JetTableMCD const& mcdjets, JetTagTracksMCD const& jtracks, aod::JetParticles const& particles) + template + void analyzeJetAlgorithmGNN(AnyJets const& jets, AnyTracks const& tracks, AnyOriginalTracks const& origTracks) { - for (auto& mcdjet : mcdjets) { - bool flagtaggedjetIP = false; - bool flagtaggedjetIPxyz = false; - bool flagtaggedjetSV = false; - bool flagtaggedjetSVxyz = false; - typename JetTagTracksMCD::iterator hftrack; - int origin = 0; - if (removeGluonShower) - origin = jettaggingutilities::mcdJetFromHFShower(mcdjet, jtracks, particles, maxDeltaR, searchUpToQuark); - else - origin = jettaggingutilities::jetTrackFromHFShower(mcdjet, jtracks, particles, hftrack, searchUpToQuark); - if (useJetProb) { - calculateJetProbability(origin, mcdjet, jtracks, jetProb); - if (trackProbQA) { - evaluateTrackProbQA(origin, mcdjet, jtracks); - } + for (const auto& jet : jets) { + std::vector> trkFeat; + jettaggingutilities::analyzeJetTrackInfo4GNN(jet, tracks, origTracks, trkFeat, trackPtMin, nJetConst); + + std::vector jetFeat{jet.pt(), jet.phi(), jet.eta(), jet.mass()}; + + if (trkFeat.size() > 0) { + std::vector feat; + std::vector gnnInput; + tensorAlloc.getGNNInput(jetFeat, trkFeat, feat, gnnInput); + + auto modelOutput = bMlResponse.getModelOutput(gnnInput, 0); + scoreML[jet.globalIndex()] = jettaggingutilities::getDb(modelOutput, fC); + } else { + scoreML[jet.globalIndex()] = -999.; + LOGF(debug, "doprocessAlgorithmGNN, trkFeat.size() <= 0 (%d)", jet.globalIndex()); } - if (jettaggingutilities::isGreaterThanTaggingPoint(mcdjet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, false)) - flagtaggedjetIP = true; - if (jettaggingutilities::isGreaterThanTaggingPoint(mcdjet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, true)) - flagtaggedjetIPxyz = true; - taggingTableMCD(origin, jetProb, flagtaggedjetIP, flagtaggedjetIPxyz, flagtaggedjetSV, flagtaggedjetSVxyz); } } - PROCESS_SWITCH(JetTaggerHFTask, processMCD, "Fill tagging decision for mcd jets", false); - void processMCDWithSV(aod::JetCollision const& /*collision*/, soa::Join const& mcdjets, JetTagTracksMCD const& jtracks, aod::MCDSecondaryVertex3Prongs const& prongs, aod::JetParticles const& particles) + void processDummy(aod::JetCollisions const&) { - for (auto& mcdjet : mcdjets) { - bool flagtaggedjetIP = false; - bool flagtaggedjetIPxyz = false; - bool flagtaggedjetSV = false; - bool flagtaggedjetSVxyz = false; - typename JetTagTracksMCD::iterator hftrack; - int origin = 0; - if (removeGluonShower) - origin = jettaggingutilities::mcdJetFromHFShower(mcdjet, jtracks, particles, maxDeltaR, searchUpToQuark); - else - origin = jettaggingutilities::jetTrackFromHFShower(mcdjet, jtracks, particles, hftrack, searchUpToQuark); - if (useJetProb) { - calculateJetProbability(origin, mcdjet, jtracks, jetProb); - if (trackProbQA) { - evaluateTrackProbQA(origin, mcdjet, jtracks); - } - } - if (jettaggingutilities::isGreaterThanTaggingPoint(mcdjet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, false)) - flagtaggedjetIP = true; - if (jettaggingutilities::isGreaterThanTaggingPoint(mcdjet, jtracks, trackDcaXYMax, trackDcaZMax, tagPointForIP, minIPCount, true)) - flagtaggedjetIPxyz = true; - flagtaggedjetSV = jettaggingutilities::isTaggedJetSV(mcdjet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, svDispersionMax, false, tagPointForSV); - flagtaggedjetSVxyz = jettaggingutilities::isTaggedJetSV(mcdjet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyzMax, prongIPxyMin, prongIPxyMax, svDispersionMax, true, tagPointForSV); - taggingTableMCD(origin, jetProb, flagtaggedjetIP, flagtaggedjetIPxyz, flagtaggedjetSV, flagtaggedjetSVxyz); + } + PROCESS_SWITCH(JetTaggerHFTask, processDummy, "Dummy process", true); + + void processSetup(JetTable const& jets) + { + decisionNonML.clear(); + scoreML.clear(); + decisionNonML.resize(jets.size()); + scoreML.resize(jets.size()); + } + PROCESS_SWITCH(JetTaggerHFTask, processSetup, "Setup initialization and size of jets for filling table", false); + + void processIP(JetTable const& jets, JetTracksExt const& tracks) + { + for (const auto& jet : jets) { + uint16_t bit = jettaggingutilities::setTaggingIPBit(jet, tracks, trackDcaXYMax, trackDcaZMax, tagPointForIP); + decisionNonML[jet.globalIndex()] |= bit; } } - PROCESS_SWITCH(JetTaggerHFTask, processMCDWithSV, "Fill tagging decision for mcd jets with sv", false); + PROCESS_SWITCH(JetTaggerHFTask, processIP, "Fill tagging decision for jet with the IP algorithm", false); - void processMCP(aod::JetMcCollision const& /*collision*/, JetTableMCP const& mcpjets, aod::JetParticles const& particles) + void processSV(soa::Join const& jets, SVTable const& prongs) { - for (auto& mcpjet : mcpjets) { - bool flagtaggedjetIP = false; - bool flagtaggedjetIPxyz = false; - bool flagtaggedjetSV = false; - bool flagtaggedjetSVxyz = false; - typename aod::JetParticles::iterator hfparticle; - int origin = 0; - // TODO - if (removeGluonShower) { - if (jettaggingutilities::mcpJetFromHFShower(mcpjet, particles, maxDeltaR, searchUpToQuark)) - origin = jettaggingutilities::mcpJetFromHFShower(mcpjet, particles, maxDeltaR, searchUpToQuark); - else - origin = 0; - } else { - if (jettaggingutilities::jetParticleFromHFShower(mcpjet, particles, hfparticle, searchUpToQuark)) - origin = jettaggingutilities::jetParticleFromHFShower(mcpjet, particles, hfparticle, searchUpToQuark); - else - origin = 0; - } - jetProb.clear(); - jetProb.reserve(maxOrder); - jetProb.push_back(-1); - taggingTableMCP(origin, jetProb, flagtaggedjetIP, flagtaggedjetIPxyz, flagtaggedjetSV, flagtaggedjetSVxyz); + for (const auto& jet : jets) { + uint16_t bit = jettaggingutilities::setTaggingSVBit(jet, prongs, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, svDispersionMax, tagPointForSV); + decisionNonML[jet.globalIndex()] |= bit; } } - PROCESS_SWITCH(JetTaggerHFTask, processMCP, "Fill tagging decision for mcp jets with sv", false); + PROCESS_SWITCH(JetTaggerHFTask, processSV, "Fill tagging decision for jets with the SV", false); + + void processAlgorithmML(soa::Join const& allJets, JetTracksExt const& allTracks, SVTable const& allSVs) + { + analyzeJetAlgorithmML(allJets, allTracks, allSVs); + } + PROCESS_SWITCH(JetTaggerHFTask, processAlgorithmML, "Fill ML evaluation score for charged jets", false); + + void processAlgorithmMLnoSV(JetTable const& allJets, JetTracksExt const& allTracks) + { + analyzeJetAlgorithmMLnoSV(allJets, allTracks); + } + PROCESS_SWITCH(JetTaggerHFTask, processAlgorithmMLnoSV, "Fill ML evaluation score for charged jets but without using SVs", false); + + void processAlgorithmGNN(JetTable const& jets, JetTracksExt const& jtracks, OriginalTracks const& origTracks) + { + analyzeJetAlgorithmGNN(jets, jtracks, origTracks); + } + PROCESS_SWITCH(JetTaggerHFTask, processAlgorithmGNN, "Fill GNN evaluation score (D_b) for charged jets", false); - void processTraining(aod::JetCollision const& /*collision*/, JetTableMCD const& /*mcdjets*/, JetTagTracksMCD const& /*tracks*/) + void processFillTables(std::conditional_t, JetTable>::iterator const& jet, JetTracksExt const& tracks) { - // To create table for ML + fillTables(jet, tracks); } - PROCESS_SWITCH(JetTaggerHFTask, processTraining, "Fill tagging decision for mcd jets", false); + PROCESS_SWITCH(JetTaggerHFTask, processFillTables, "Fill Tables for tagging decision, jet probability, and ML score on charged jets", false); }; -using JetTaggerChargedJets = JetTaggerHFTask, soa::Join, soa::Join, aod::ChargedJetTags, aod::ChargedMCDetectorLevelJetTags, aod::ChargedMCParticleLevelJetTags>; -using JetTaggerFullJets = JetTaggerHFTask, soa::Join, soa::Join, aod::FullJetTags, aod::FullMCDetectorLevelJetTags, aod::FullMCParticleLevelJetTags>; -// using JetTaggerNeutralJets = JetTaggerHFTask,soa::Join, aod::NeutralJetTags, aod::NeutralMCDetectorLevelJetTags>; +using JetTaggerhfDataCharged = JetTaggerHFTask, aod::DataSecondaryVertex3ProngIndices, aod::DataSecondaryVertex3Prongs, aod::ChargedJetTags>; +using JetTaggerhfMCDCharged = JetTaggerHFTask, aod::MCDSecondaryVertex3ProngIndices, aod::MCDSecondaryVertex3Prongs, aod::ChargedMCDetectorLevelJetTags>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - std::vector tasks; - - tasks.emplace_back( - adaptAnalysisTask(cfgc, - SetDefaultProcesses{}, TaskName{"jet-taggerhf-charged"})); - - tasks.emplace_back( - adaptAnalysisTask(cfgc, - SetDefaultProcesses{}, TaskName{"jet-taggerhf-full"})); - /* - tasks.emplace_back( - adaptAnalysisTask(cfgc, - SetDefaultProcesses{}, TaskName{"jet-taggerhf-neutral"})); - */ - return WorkflowSpec{tasks}; + return WorkflowSpec{ + adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-taggerhf-data-charged"}), // o2-linter: disable=name/o2-task + adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-taggerhf-mcd-charged"})}; // o2-linter: disable=name/o2-task } diff --git a/PWGJE/TableProducer/jetTrackDerived.cxx b/PWGJE/TableProducer/jetTrackDerived.cxx index 827ec6c1c15..9111ae36c3c 100644 --- a/PWGJE/TableProducer/jetTrackDerived.cxx +++ b/PWGJE/TableProducer/jetTrackDerived.cxx @@ -17,23 +17,32 @@ /// // O2 includes -#include "ReconstructionDataFormats/Track.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/AnalysisDataModel.h" -#include "PWGJE/DataModel/Jet.h" -#include "Framework/StaticFor.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" +#include "PWGJE/DataModel/TrackJetQa.h" + #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" -#include "PWGJE/DataModel/TrackJetQa.h" #include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include using namespace o2; -using namespace o2::track; using namespace o2::framework; using namespace o2::framework::expressions; diff --git a/PWGJE/TableProducer/luminosityCalculator.cxx b/PWGJE/TableProducer/luminosityCalculator.cxx index c818ad6b3b2..8767ae604e2 100644 --- a/PWGJE/TableProducer/luminosityCalculator.cxx +++ b/PWGJE/TableProducer/luminosityCalculator.cxx @@ -14,13 +14,21 @@ /// /// \author Nima Zardoshti -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGJE/DataModel/JetReducedData.h" + #include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include -#include "PWGJE/DataModel/JetReducedData.h" +#include + +#include +#include using namespace o2; using namespace o2::framework; @@ -32,7 +40,7 @@ struct LuminosityCalculator { void init(InitContext&) { - std::vector histLabels = {"BC", "BC+TVX", "BC+TVX+NoTFB", "BC+TVX+NoTFB+NoITSROFB", "Coll", "Coll+TVX", "Coll+TVX+VtxZ+Sel8", "Coll+TVX+VtxZ+Sel8Full", "Coll+TVX+VtxZ+Sel8FullPbPb", "Coll+TVX+VtxZ+SelMC", "Coll+TVX+VtxZ+SelMCFull", "Coll+TVX+VtxZ+SelMCFullPbPb", "Coll+TVX+VtxZ+SelUnanchoredMC", "Coll+TVX+VtxZ+SelTVX", "Coll+TVX+VtxZ+Sel7", "Coll+TVX+VtxZ+Sel7KINT7"}; + std::vector histLabels = {"BC", "BC+TVX", "BC+TVX+NoTFB", "BC+TVX+NoTFB+NoITSROFB", "Coll", "Coll+TVX", "Coll+TVX+VtxZ+Sel8", "Coll+TVX+VtxZ+Sel8Full", "Coll+TVX+VtxZ+Sel8FullPbPb", "Coll+TVX+VtxZ+SelMC", "Coll+TVX+VtxZ+SelMCFull", "Coll+TVX+VtxZ+SelMCFullPbPb", "Coll+TVX+VtxZ+SelUnanchoredMC", "Coll+TVX+VtxZ+SelTVX", "Coll+TVX+VtxZ+Sel7", "Coll+TVX+VtxZ+Sel7KINT7", "custom"}; registry.add("counter", "BCs and Collisions", HistType::kTH1D, {{static_cast(histLabels.size()), -0.5, static_cast(histLabels.size()) - 0.5}}); auto counter = registry.get(HIST("counter")); for (std::vector::size_type iCounter = 0; iCounter < histLabels.size(); iCounter++) { @@ -66,6 +74,7 @@ struct LuminosityCalculator { int readCollisionWithTVXAndZVertexAndSelTVXCounter = 0; int readCollisionWithTVXAndZVertexAndSel7Counter = 0; int readCollisionWithTVXAndZVertexAndSel7KINT7Counter = 0; + int readCollisionWithCustomCounter = 0; for (const auto& collisionCount : collisionCounts) { readCollision += collisionCount.readCounts().front(); @@ -80,6 +89,7 @@ struct LuminosityCalculator { readCollisionWithTVXAndZVertexAndSelTVXCounter += collisionCount.readCountsWithTVXAndZVertexAndSelTVX().front(); readCollisionWithTVXAndZVertexAndSel7Counter += collisionCount.readCountsWithTVXAndZVertexAndSel7().front(); readCollisionWithTVXAndZVertexAndSel7KINT7Counter += collisionCount.readCountsWithTVXAndZVertexAndSel7KINT7().front(); + readCollisionWithCustomCounter += collisionCount.readCountsWithCustom().front(); } registry.get(HIST("counter"))->SetBinContent(1, registry.get(HIST("counter"))->GetBinContent(1) + readBC); @@ -98,6 +108,7 @@ struct LuminosityCalculator { registry.get(HIST("counter"))->SetBinContent(14, registry.get(HIST("counter"))->GetBinContent(14) + readCollisionWithTVXAndZVertexAndSelTVXCounter); registry.get(HIST("counter"))->SetBinContent(15, registry.get(HIST("counter"))->GetBinContent(15) + readCollisionWithTVXAndZVertexAndSel7Counter); registry.get(HIST("counter"))->SetBinContent(16, registry.get(HIST("counter"))->GetBinContent(16) + readCollisionWithTVXAndZVertexAndSel7KINT7Counter); + registry.get(HIST("counter"))->SetBinContent(16, registry.get(HIST("counter"))->GetBinContent(17) + readCollisionWithCustomCounter); } PROCESS_SWITCH(LuminosityCalculator, processCalculateLuminosity, "calculate ingredients for luminosity and fill a histogram", true); }; diff --git a/PWGJE/TableProducer/luminosityProducer.cxx b/PWGJE/TableProducer/luminosityProducer.cxx index 45592ba5d87..455ab4e5910 100644 --- a/PWGJE/TableProducer/luminosityProducer.cxx +++ b/PWGJE/TableProducer/luminosityProducer.cxx @@ -14,13 +14,27 @@ /// /// \author Nima Zardoshti -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" +#include "JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" #include "PWGJE/DataModel/JetReducedData.h" +#include "Common/CCDB/EventSelectionParams.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -31,6 +45,7 @@ struct LuminosityProducer { Produces storedCollisionCountsTable; Configurable vertexZCutForCounting{"vertexZCutForCounting", 10.0, "choose z-vertex cut for collision counter"}; + Configurable customEventSelections{"customEventSelections", "sel8", "choose custom event selection to be added"}; void init(InitContext&) { @@ -87,7 +102,7 @@ struct LuminosityProducer { } PROCESS_SWITCH(LuminosityProducer, processStoreBCCounting, "write out bc counting output table", true); - void processStoreCollisionCounting(aod::JCollisions const& collisions, aod::CollisionCounts const& collisionCounts) + void processStoreCollisionCounting(aod::JetCollisions const& collisions, aod::CollisionCounts const& collisionCounts) { int readCollisionCounter = 0; int readCollisionWithTVXCounter = 0; @@ -101,42 +116,46 @@ struct LuminosityProducer { int readCollisionWithTVXAndZVertexAndSelTVXCounter = 0; // redundant but we keep it int readCollisionWithTVXAndZVertexAndSel7Counter = 0; int readCollisionWithTVXAndZVertexAndSel7KINT7Counter = 0; + int readCollisionWithCustomCounter = 0; for (const auto& collision : collisions) { readCollisionCounter++; - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selTVX)) { // asuumes all selections include the TVX trigger + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("TVX"))) { // asuumes all selections include the TVX trigger readCollisionWithTVXCounter++; if (std::abs(collision.posZ()) > vertexZCutForCounting) { continue; } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) { + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel8"))) { readCollisionWithTVXAndZVertexAndSel8Counter++; } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8Full)) { + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("TVX"))) { + readCollisionWithTVXAndZVertexAndSelTVXCounter++; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel7"))) { + readCollisionWithTVXAndZVertexAndSel7Counter++; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel7KINT7"))) { + readCollisionWithTVXAndZVertexAndSel7KINT7Counter++; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel8Full"))) { readCollisionWithTVXAndZVertexAndSel8FullCounter++; } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8FullPbPb)) { + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel8FullPbPb"))) { readCollisionWithTVXAndZVertexAndSel8FullPbPbCounter++; } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selMC)) { + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("selMC"))) { readCollisionWithTVXAndZVertexAndSelMCCounter++; } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selMCFull)) { + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("selMCFull"))) { readCollisionWithTVXAndZVertexAndSelMCFullCounter++; } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selMCFullPbPb)) { + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("selMCFullPbPb"))) { readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounter++; } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selUnanchoredMC)) { + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("selUnanchoredMC"))) { readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounter++; } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selTVX)) { - readCollisionWithTVXAndZVertexAndSelTVXCounter++; - } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel7)) { - readCollisionWithTVXAndZVertexAndSel7Counter++; - } - if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel7KINT7)) { - readCollisionWithTVXAndZVertexAndSel7KINT7Counter++; + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits(static_cast(customEventSelections)))) { + readCollisionWithCustomCounter++; } } } @@ -152,6 +171,7 @@ struct LuminosityProducer { std::vector previousReadCountsWithTVXAndZVertexAndSelTVX; std::vector previousReadCountsWithTVXAndZVertexAndSel7; std::vector previousReadCountsWithTVXAndZVertexAndSel7KINT7; + std::vector previousReadCountsWithCustom; int iPreviousDataFrame = 0; for (const auto& collisionCount : collisionCounts) { @@ -167,6 +187,7 @@ struct LuminosityProducer { auto readCollisionWithTVXAndZVertexAndSelTVXCounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSelTVX(); auto readCollisionWithTVXAndZVertexAndSel7CounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSel7(); auto readCollisionWithTVXAndZVertexAndSel7KINT7CounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSel7KINT7(); + auto readCollisionWithCustomCounterSpan = collisionCount.readCountsWithCustom(); if (iPreviousDataFrame == 0) { std::copy(readCollisionCounterSpan.begin(), readCollisionCounterSpan.end(), std::back_inserter(previousReadCounts)); @@ -181,6 +202,7 @@ struct LuminosityProducer { std::copy(readCollisionWithTVXAndZVertexAndSelTVXCounterSpan.begin(), readCollisionWithTVXAndZVertexAndSelTVXCounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSelTVX)); std::copy(readCollisionWithTVXAndZVertexAndSel7CounterSpan.begin(), readCollisionWithTVXAndZVertexAndSel7CounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSel7)); std::copy(readCollisionWithTVXAndZVertexAndSel7KINT7CounterSpan.begin(), readCollisionWithTVXAndZVertexAndSel7KINT7CounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSel7KINT7)); + std::copy(readCollisionWithCustomCounterSpan.begin(), readCollisionWithCustomCounterSpan.end(), std::back_inserter(previousReadCountsWithCustom)); } else { for (unsigned int i = 0; i < previousReadCounts.size(); i++) { // in principle we only care about the first element, but might be interesting information to keep @@ -196,6 +218,7 @@ struct LuminosityProducer { previousReadCountsWithTVXAndZVertexAndSelTVX[i] += readCollisionWithTVXAndZVertexAndSelTVXCounterSpan[i]; previousReadCountsWithTVXAndZVertexAndSel7[i] += readCollisionWithTVXAndZVertexAndSel7CounterSpan[i]; previousReadCountsWithTVXAndZVertexAndSel7KINT7[i] += readCollisionWithTVXAndZVertexAndSel7KINT7CounterSpan[i]; + previousReadCountsWithCustom[i] += readCollisionWithCustomCounterSpan[i]; } } iPreviousDataFrame++; @@ -212,8 +235,9 @@ struct LuminosityProducer { previousReadCountsWithTVXAndZVertexAndSelTVX.push_back(readCollisionWithTVXAndZVertexAndSelTVXCounter); previousReadCountsWithTVXAndZVertexAndSel7.push_back(readCollisionWithTVXAndZVertexAndSel7Counter); previousReadCountsWithTVXAndZVertexAndSel7KINT7.push_back(readCollisionWithTVXAndZVertexAndSel7KINT7Counter); + previousReadCountsWithCustom.push_back(readCollisionWithCustomCounter); - storedCollisionCountsTable(previousReadCounts, previousReadCountsWithTVX, previousReadCountsWithTVXAndZVertexAndSel8, previousReadCountsWithTVXAndZVertexAndSel8Full, previousReadCountsWithTVXAndZVertexAndSel8FullPbPb, previousReadCountsWithTVXAndZVertexAndSelMC, previousReadCountsWithTVXAndZVertexAndSelMCFull, previousReadCountsWithTVXAndZVertexAndSelMCFullPbPb, previousReadCountsWithTVXAndZVertexAndSelUnanchoredMC, previousReadCountsWithTVXAndZVertexAndSelTVX, previousReadCountsWithTVXAndZVertexAndSel7, previousReadCountsWithTVXAndZVertexAndSel7KINT7); + storedCollisionCountsTable(previousReadCounts, previousReadCountsWithTVX, previousReadCountsWithTVXAndZVertexAndSel8, previousReadCountsWithTVXAndZVertexAndSel8Full, previousReadCountsWithTVXAndZVertexAndSel8FullPbPb, previousReadCountsWithTVXAndZVertexAndSelMC, previousReadCountsWithTVXAndZVertexAndSelMCFull, previousReadCountsWithTVXAndZVertexAndSelMCFullPbPb, previousReadCountsWithTVXAndZVertexAndSelUnanchoredMC, previousReadCountsWithTVXAndZVertexAndSelTVX, previousReadCountsWithTVXAndZVertexAndSel7, previousReadCountsWithTVXAndZVertexAndSel7KINT7, previousReadCountsWithCustom); } PROCESS_SWITCH(LuminosityProducer, processStoreCollisionCounting, "write out collision counting output table", true); }; diff --git a/PWGJE/TableProducer/mcOutlierRejector.cxx b/PWGJE/TableProducer/mcOutlierRejector.cxx new file mode 100644 index 00000000000..427a5afdfad --- /dev/null +++ b/PWGJE/TableProducer/mcOutlierRejector.cxx @@ -0,0 +1,132 @@ +// 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. + +// Task to produce a table joinable to the jcollision table which contains an outlier rejector +// +/// \author Nima Zardoshti + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct McOutlierRejectorTask { + Produces collisionOutliers; + Produces mcCollisionOutliers; + + Configurable checkmcCollisionForCollision{"checkmcCollisionForCollision", true, "additionally reject collision based on mcCollision"}; + Configurable ptHatMax{"ptHatMax", 4.0, "maximum factor of pt hat the leading jet in the event is allowed"}; + + std::vector collisionFlag; + std::vector mcCollisionFlag; + + void processSetupCollisionSelection(aod::JCollisions const& collisions) + { + collisionFlag.clear(); + collisionFlag.resize(collisions.size(), false); + } + PROCESS_SWITCH(McOutlierRejectorTask, processSetupCollisionSelection, "Setup collision processing", true); + + void processSetupMcCollisionSelection(aod::JMcCollisions const& mcCollisions) + { + mcCollisionFlag.clear(); + mcCollisionFlag.resize(mcCollisions.size(), false); + } + PROCESS_SWITCH(McOutlierRejectorTask, processSetupMcCollisionSelection, "Setup MC Collision processing", true); + + template + void collisionSelection(int32_t collisionIndex, T const& selectionObjects, float ptHard, std::vector& flagArray) + { + + if (selectionObjects.size() != 0) { + float maxSelectionObjectPt = 0.0; + if constexpr (std::is_same_v, aod::JetTracks> || std::is_same_v, aod::JetParticles>) { + for (auto selectionObject : selectionObjects) { + if (selectionObject.pt() > maxSelectionObjectPt) { + maxSelectionObjectPt = selectionObject.pt(); + } + } + } else { + maxSelectionObjectPt = selectionObjects.iteratorAt(0).pt(); + } + + if (maxSelectionObjectPt > ptHatMax * ptHard) { + flagArray[collisionIndex] = true; // Currently if running multiple different jet finders, then a single type of jet can veto an event for others. Decide if this is the best way + } + } + } + + template + void processSelectionObjects(aod::JetCollisionMCD const& collision, T const& selectionObjects, aod::JetMcCollisions const&) + { + auto mcCollision = collision.mcCollision_as(); + collisionSelection(collision.globalIndex(), selectionObjects, mcCollision.ptHard(), collisionFlag); + } + + template + void processSelectionMcObjects(aod::JetMcCollision const& mcCollision, T const& selectionMcObjects) + { + collisionSelection(mcCollision.globalIndex(), selectionMcObjects, mcCollision.ptHard(), mcCollisionFlag); + } + + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingChargedMCDetectorLevelJets, "process mc detector level charged jets", true); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingNeutralMCDetectorLevelJets, "process mc detector level neutral jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingFullMCDetectorLevelJets, "process mc detector level full jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingD0ChargedMCDetectorLevelJets, "process mc detector level D0 charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingDplusChargedMCDetectorLevelJets, "process mc detector level Dplus charged jets", false); + // PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingDstarChargedMCDetectorLevelJets, "process mc detector level Dstar charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingLcChargedMCDetectorLevelJets, "process mc detector level Lc charged jets", false); + // PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingB0ChargedMCDetectorLevelJets, "process mc detector level B0 charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingBplusChargedMCDetectorLevelJets, "process mc detector level Bplus charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingDielectronChargedMCDetectorLevelJets, "process mc detector level Dielectron charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionObjects, processSelectingTracks, "process tracks", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingChargedMCParticleLevelJets, "process mc particle level charged jets", true); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingNeutralMCParticleLevelJets, "process mc particle level neutral jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingFullMCParticleLevelJets, "process mc particle level full jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingD0ChargedMCParticleLevelJets, "process mc particle level D0 charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingDplusChargedMCParticleLevelJets, "process mc particle level Dplus charged jets", false); + // PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingDstarChargedMCParticleLevelJets, "process mc particle level Dstar charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingLcChargedMCParticleLevelJets, "process mc particle level Lc charged jets", false); + // PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingB0ChargedMCParticleLevelJets, "process mc particle level B0 charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingBplusChargedMCParticleLevelJets, "process mc particle level Bplus charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingDielectronChargedMCParticleLevelJets, "process mc particle level Dielectron charged jets", false); + PROCESS_SWITCH_FULL(McOutlierRejectorTask, processSelectionMcObjects, processSelectingParticles, "process mc particles", false); + + void processStoreCollisionDecision(aod::JetCollisionMCD const& collision) + { + bool rejectCollision = collisionFlag[collision.globalIndex()]; + if (!rejectCollision && checkmcCollisionForCollision && collision.has_mcCollision()) { + rejectCollision = mcCollisionFlag[collision.mcCollisionId()]; + } + collisionOutliers(rejectCollision); + } + PROCESS_SWITCH(McOutlierRejectorTask, processStoreCollisionDecision, "write out decision of rejecting collision", true); + + void processStoreMcCollisionDecision(aod::JetMcCollision const& mcCollision) + { + mcCollisionOutliers(mcCollisionFlag[mcCollision.globalIndex()]); + } + PROCESS_SWITCH(McOutlierRejectorTask, processStoreMcCollisionDecision, "write out decision of rejecting mcCollision", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"mc-outlier-rejector"})}; } diff --git a/PWGJE/TableProducer/rhoEstimator.cxx b/PWGJE/TableProducer/rhoEstimator.cxx index b8a74936bfd..b6026e46291 100644 --- a/PWGJE/TableProducer/rhoEstimator.cxx +++ b/PWGJE/TableProducer/rhoEstimator.cxx @@ -13,17 +13,29 @@ // /// \author Nima Zardoshti -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGJE/Core/JetBkgSubUtils.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" + #include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" #include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetBkgSubUtils.h" -#include "Framework/runDataProcessing.h" +#include +#include + +#include +#include +#include + +#include using namespace o2; using namespace o2::framework; @@ -34,81 +46,194 @@ struct RhoEstimatorTask { Produces rhoChargedMcTable; Produces rhoD0Table; Produces rhoD0McTable; + Produces rhoDplusTable; + Produces rhoDplusMcTable; + Produces rhoDstarTable; + Produces rhoDstarMcTable; Produces rhoLcTable; Produces rhoLcMcTable; Produces rhoBplusTable; Produces rhoBplusMcTable; + Produces rhoB0Table; + Produces rhoB0McTable; Produces rhoDielectronTable; Produces rhoDielectronMcTable; - Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; - Configurable trackPtMax{"trackPtMax", 1000.0, "maximum track pT"}; - Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track eta"}; - Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum track eta"}; - Configurable trackPhiMin{"trackPhiMin", -999, "minimum track phi"}; - Configurable trackPhiMax{"trackPhiMax", 999, "maximum track phi"}; - Configurable trackingEfficiency{"trackingEfficiency", 1.0, "tracking efficiency applied to jet finding"}; - Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; - - Configurable particleSelections{"particleSelections", "PhysicalPrimary", "set particle selections"}; - - Configurable bkgjetR{"bkgjetR", 0.2, "jet resolution parameter for determining background density"}; - Configurable bkgEtaMin{"bkgEtaMin", -0.9, "minimim pseudorapidity for determining background density"}; - Configurable bkgEtaMax{"bkgEtaMax", 0.9, "maximum pseudorapidity for determining background density"}; - Configurable bkgPhiMin{"bkgPhiMin", 0., "minimim phi for determining background density"}; - Configurable bkgPhiMax{"bkgPhiMax", 99.0, "maximum phi for determining background density"}; - Configurable doSparse{"doSparse", false, "perfom sparse estimation"}; + struct : ConfigurableGroup { + + Configurable skipMBGapEvents{"skipMBGapEvents", true, "decide to run over MB gap events or not"}; + + Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; + Configurable trackPtMax{"trackPtMax", 1000.0, "maximum track pT"}; + Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track eta"}; + Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum track eta"}; + Configurable trackPhiMin{"trackPhiMin", -99.0, "minimum track phi"}; + Configurable trackPhiMax{"trackPhiMax", 99.0, "maximum track phi"}; + Configurable trackingEfficiency{"trackingEfficiency", 1.0, "tracking efficiency applied to jet finding"}; + Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + + Configurable particleSelections{"particleSelections", "PhysicalPrimary", "set particle selections"}; + + Configurable jetAlgorithm{"jetAlgorithm", 0, "jet clustering algorithm. 0 = kT, 1 = C/A, 2 = Anti-kT"}; + Configurable jetRecombScheme{"jetRecombScheme", 0, "jet recombination scheme. 0 = E-scheme, 1 = pT-scheme, 2 = pT2-scheme"}; + Configurable bkgjetR{"bkgjetR", 0.2, "jet resolution parameter for determining background density"}; + Configurable bkgEtaMin{"bkgEtaMin", -0.7, "minimim pseudorapidity for determining background density"}; + Configurable bkgEtaMax{"bkgEtaMax", 0.7, "maximum pseudorapidity for determining background density"}; + Configurable bkgPhiMin{"bkgPhiMin", -99., "minimim phi for determining background density"}; + Configurable bkgPhiMax{"bkgPhiMax", 99., "maximum phi for determining background density"}; + Configurable doSparse{"doSparse", false, "perfom sparse estimation"}; + + Configurable thresholdTriggerTrackPtMin{"thresholdTriggerTrackPtMin", 0.0, "Minimum trigger track pt to accept event"}; + Configurable thresholdClusterEnergyMin{"thresholdClusterEnergyMin", 0.0, "Minimum cluster energy to accept event"}; + Configurable performTriggerTrackSelection{"performTriggerTrackSelection", false, "only accept trigger tracks that pass one of the track selections"}; + Configurable triggerTrackPtSelectionMin{"triggerTrackPtSelectionMin", 0.15, "only accept trigger tracks that have a pT larger than this pT"}; + Configurable triggerTrackEtaSelectionMax{"triggerTrackEtaSelectionMax", 0.9, "only accept trigger tracks that have an eta smaller than this eta"}; + + Configurable vertexZCut{"vertexZCut", 10.0, "z-vertex cut on event"}; + Configurable eventSelections{"eventSelections", "", "choose event selection"}; + Configurable centralityMin{"centralityMin", -999.0, "minimum centrality"}; + Configurable centralityMax{"centralityMax", 999.0, "maximum centrality"}; + Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; + + Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; + } config; JetBkgSubUtils bkgSub; float bkgPhiMax_; + float bkgPhiMin_; std::vector inputParticles; int trackSelection = -1; std::string particleSelection; - Service pdgDatabase; + std::vector collisionFlag; + Service pdgDatabase; + std::vector eventSelectionBits; + std::vector triggerMaskBits; void init(o2::framework::InitContext&) { - trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); - particleSelection = static_cast(particleSelections); - - bkgSub.setJetBkgR(bkgjetR); - bkgSub.setEtaMinMax(bkgEtaMin, bkgEtaMax); - if (bkgPhiMax > 98.0) { + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(config.trackSelections)); + particleSelection = static_cast(config.particleSelections); + + bkgSub.setJetAlgorithmAndScheme(static_cast(static_cast(config.jetAlgorithm)), static_cast(static_cast(config.jetRecombScheme))); + bkgSub.setJetBkgR(config.bkgjetR); + bkgSub.setEtaMinMax(config.bkgEtaMin, config.bkgEtaMax); + bkgPhiMax_ = config.bkgPhiMax; + bkgPhiMin_ = config.bkgPhiMin; + if (config.bkgPhiMax > 98.0) { bkgPhiMax_ = 2.0 * M_PI; } - bkgSub.setPhiMinMax(bkgPhiMin, bkgPhiMax_); + if (config.bkgPhiMin < -98.0) { + bkgPhiMin_ = -2.0 * M_PI; + } + bkgSub.setPhiMinMax(bkgPhiMin_, bkgPhiMax_); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(config.eventSelections)); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(config.triggerMasks); } - Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax && aod::jtrack::phi >= trackPhiMin && aod::jtrack::phi <= trackPhiMax); - Filter partCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax && aod::jmcparticle::eta >= trackEtaMin && aod::jmcparticle::eta <= trackEtaMax && aod::jmcparticle::phi >= trackPhiMin && aod::jmcparticle::phi <= trackPhiMax); + Filter trackCuts = (aod::jtrack::pt >= config.trackPtMin && aod::jtrack::pt < config.trackPtMax && aod::jtrack::eta > config.trackEtaMin && aod::jtrack::eta < config.trackEtaMax && aod::jtrack::phi >= config.trackPhiMin && aod::jtrack::phi <= config.trackPhiMax); + Filter partCuts = (aod::jmcparticle::pt >= config.trackPtMin && aod::jmcparticle::pt < config.trackPtMax && aod::jmcparticle::eta >= config.trackEtaMin && aod::jmcparticle::eta <= config.trackEtaMax && aod::jmcparticle::phi >= config.trackPhiMin && aod::jmcparticle::phi <= config.trackPhiMax); - void processChargedCollisions(aod::JetCollision const& /*collision*/, soa::Filtered const& tracks) + void processSetupCollisionSelection(aod::JCollisions const& collisions) { + collisionFlag.clear(); + collisionFlag.resize(collisions.size(), false); + } + + void processSetupEventTriggering(aod::JCollision const& collision) + { + if (jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + collisionFlag[collision.globalIndex()] = true; + } + } + + template + void processSelectionObjects(T& selectionObjects) + { + float selectionObjectPtMin = 0.0; + if constexpr (std::is_same_v, aod::JTracks>) { + selectionObjectPtMin = config.thresholdTriggerTrackPtMin; + } else if constexpr (std::is_same_v, aod::JClusters>) { + selectionObjectPtMin = config.thresholdClusterEnergyMin; + } else { + selectionObjectPtMin = 0.0; + } + for (const auto& selectionObject : selectionObjects) { + bool isTriggerObject = false; + if constexpr (std::is_same_v, aod::JClusters>) { + if (selectionObject.energy() >= selectionObjectPtMin) { + isTriggerObject = true; + } + } else { + if constexpr (std::is_same_v, aod::JTracks>) { + if (config.performTriggerTrackSelection && !(selectionObject.trackSel() & ~(1 << jetderiveddatautilities::JTrackSel::trackSign))) { + continue; + } + if (selectionObject.pt() < config.triggerTrackPtSelectionMin || std::abs(selectionObject.eta()) > config.triggerTrackEtaSelectionMax) { + continue; + } + } + if (selectionObject.pt() >= selectionObjectPtMin) { + isTriggerObject = true; + } + } + if (isTriggerObject) { + if (selectionObject.collisionId() >= 0) { + collisionFlag[selectionObject.collisionId()] = true; + } + } + } + } + PROCESS_SWITCH(RhoEstimatorTask, processSetupCollisionSelection, "setup the writing for data based on collisions", false); + PROCESS_SWITCH(RhoEstimatorTask, processSetupEventTriggering, "process software triggers", false); + PROCESS_SWITCH_FULL(RhoEstimatorTask, processSelectionObjects, processSelectingClusters, "process EMCal clusters", false); + PROCESS_SWITCH_FULL(RhoEstimatorTask, processSelectionObjects, processSelectingTracks, "process high pt tracks", false); + + void processChargedCollisions(aod::JetCollision const& collision, soa::Filtered const& tracks) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || collision.centFT0M() < config.centralityMin || collision.centFT0M() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { + rhoChargedTable(0.0, 0.0); + return; + } + if (collisionFlag.size() != 0 && !collisionFlag[collision.globalIndex()]) { + rhoChargedTable(0.0, 0.0); + return; + } + if (config.skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + rhoChargedTable(-1., -1.); + return; + } inputParticles.clear(); - jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); + jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, config.trackingEfficiency); + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); rhoChargedTable(rho, rhoM); } PROCESS_SWITCH(RhoEstimatorTask, processChargedCollisions, "Fill rho tables for collisions using charged tracks", true); - void processChargedMcCollisions(aod::JetMcCollision const& /*mcCollision*/, soa::Filtered const& particles) + void processChargedMcCollisions(aod::JetMcCollision const& mcCollision, soa::Filtered const& particles) { + if (config.skipMBGapEvents && mcCollision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + rhoChargedMcTable(-1., -1.); + return; + } inputParticles.clear(); jetfindingutilities::analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 1, particles, pdgDatabase); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); rhoChargedMcTable(rho, rhoM); } PROCESS_SWITCH(RhoEstimatorTask, processChargedMcCollisions, "Fill rho tables for MC collisions using charged tracks", false); - void processD0Collisions(aod::JetCollision const&, soa::Filtered const& tracks, aod::CandidatesD0Data const& candidates) + void processD0Collisions(aod::JetCollision const& collision, soa::Filtered const& tracks, aod::CandidatesD0Data const& candidates) { - inputParticles.clear(); for (auto& candidate : candidates) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || collision.centFT0M() < config.centralityMin || collision.centFT0M() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { + rhoD0Table(0.0, 0.0); + continue; + } inputParticles.clear(); - jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, config.trackingEfficiency, &candidate); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); rhoD0Table(rho, rhoM); } } @@ -116,25 +241,83 @@ struct RhoEstimatorTask { void processD0McCollisions(aod::JetMcCollision const&, soa::Filtered const& particles, aod::CandidatesD0MCP const& candidates) { - inputParticles.clear(); for (auto& candidate : candidates) { inputParticles.clear(); - jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, std::optional{candidate}); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, &candidate); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); rhoD0McTable(rho, rhoM); } } PROCESS_SWITCH(RhoEstimatorTask, processD0McCollisions, "Fill rho tables for collisions with D0 MCP candidates", false); - void processLcCollisions(aod::JetCollision const&, soa::Filtered const& tracks, aod::CandidatesLcData const& candidates) + void processDplusCollisions(aod::JetCollision const& collision, soa::Filtered const& tracks, aod::CandidatesDplusData const& candidates) + { + for (auto& candidate : candidates) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || collision.centFT0M() < config.centralityMin || collision.centFT0M() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { + rhoDplusTable(0.0, 0.0); + continue; + } + inputParticles.clear(); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, config.trackingEfficiency, &candidate); + + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); + rhoDplusTable(rho, rhoM); + } + } + PROCESS_SWITCH(RhoEstimatorTask, processDplusCollisions, "Fill rho tables for collisions with Dplus candidates", false); + + void processDplusMcCollisions(aod::JetMcCollision const&, soa::Filtered const& particles, aod::CandidatesDplusMCP const& candidates) { - inputParticles.clear(); for (auto& candidate : candidates) { inputParticles.clear(); - jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, &candidate); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); + rhoDplusMcTable(rho, rhoM); + } + } + PROCESS_SWITCH(RhoEstimatorTask, processDplusMcCollisions, "Fill rho tables for collisions with Dplus MCP candidates", false); + + void processDstarCollisions(aod::JetCollision const& collision, soa::Filtered const& tracks, aod::CandidatesDstarData const& candidates) + { + for (auto& candidate : candidates) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || collision.centFT0M() < config.centralityMin || collision.centFT0M() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { + rhoDstarTable(0.0, 0.0); + continue; + } + inputParticles.clear(); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, config.trackingEfficiency, &candidate); + + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); + rhoDstarTable(rho, rhoM); + } + } + PROCESS_SWITCH(RhoEstimatorTask, processDstarCollisions, "Fill rho tables for collisions with Dstar candidates", false); + + void processDstarMcCollisions(aod::JetMcCollision const&, soa::Filtered const& particles, aod::CandidatesDstarMCP const& candidates) + { + for (auto& candidate : candidates) { + inputParticles.clear(); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, &candidate); + + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); + rhoDstarMcTable(rho, rhoM); + } + } + PROCESS_SWITCH(RhoEstimatorTask, processDstarMcCollisions, "Fill rho tables for collisions with Dstar MCP candidates", false); + + void processLcCollisions(aod::JetCollision const& collision, soa::Filtered const& tracks, aod::CandidatesLcData const& candidates) + { + for (auto& candidate : candidates) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || collision.centFT0M() < config.centralityMin || collision.centFT0M() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { + rhoLcTable(0.0, 0.0); + continue; + } + inputParticles.clear(); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, config.trackingEfficiency, &candidate); + + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); rhoLcTable(rho, rhoM); } } @@ -142,51 +325,83 @@ struct RhoEstimatorTask { void processLcMcCollisions(aod::JetMcCollision const&, soa::Filtered const& particles, aod::CandidatesLcMCP const& candidates) { - inputParticles.clear(); for (auto& candidate : candidates) { inputParticles.clear(); - jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, std::optional{candidate}); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, &candidate); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); rhoLcMcTable(rho, rhoM); } } PROCESS_SWITCH(RhoEstimatorTask, processLcMcCollisions, "Fill rho tables for collisions with Lc MCP candidates", false); - void processBplusCollisions(aod::JetCollision const&, soa::Filtered const& tracks, aod::CandidatesBplusData const& candidates) - { + void processB0Collisions(aod::JetCollision const& collision, soa::Filtered const& tracks, aod::CandidatesB0Data const& candidates) + { + for (auto& candidate : candidates) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || collision.centFT0M() < config.centralityMin || collision.centFT0M() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { + rhoB0Table(0.0, 0.0); + continue; + } inputParticles.clear(); - for (auto& candidate : candidates) { - inputParticles.clear(); - jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, config.trackingEfficiency, &candidate); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); - rhoBplusTable(rho, rhoM); - } + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); + rhoB0Table(rho, rhoM); } - PROCESS_SWITCH(RhoEstimatorTask, processBplusCollisions, "Fill rho tables for collisions with Bplus candidates", false); + } + PROCESS_SWITCH(RhoEstimatorTask, processB0Collisions, "Fill rho tables for collisions with B0 candidates", false); - void processBplusMcCollisions(aod::JetMcCollision const&, soa::Filtered const& particles, aod::CandidatesBplusMCP const& candidates) - { + void processB0McCollisions(aod::JetMcCollision const&, soa::Filtered const& particles, aod::CandidatesB0MCP const& candidates) + { + for (auto& candidate : candidates) { inputParticles.clear(); - for (auto& candidate : candidates) { - inputParticles.clear(); - jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, std::optional{candidate}); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, &candidate); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); - rhoBplusMcTable(rho, rhoM); + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); + rhoB0McTable(rho, rhoM); + } + } + PROCESS_SWITCH(RhoEstimatorTask, processB0McCollisions, "Fill rho tables for collisions with B0 MCP candidates", false); + + void processBplusCollisions(aod::JetCollision const& collision, soa::Filtered const& tracks, aod::CandidatesBplusData const& candidates) + { + for (auto& candidate : candidates) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || collision.centFT0M() < config.centralityMin || collision.centFT0M() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { + rhoBplusTable(0.0, 0.0); + continue; } + inputParticles.clear(); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, config.trackingEfficiency, &candidate); + + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); + rhoBplusTable(rho, rhoM); } - PROCESS_SWITCH(RhoEstimatorTask, processBplusMcCollisions, "Fill rho tables for collisions with Bplus MCP candidates", false); + } + PROCESS_SWITCH(RhoEstimatorTask, processBplusCollisions, "Fill rho tables for collisions with Bplus candidates", false); - void processDielectronCollisions(aod::JetCollision const&, soa::Filtered const& tracks, aod::CandidatesDielectronData const& candidates) + void processBplusMcCollisions(aod::JetMcCollision const&, soa::Filtered const& particles, aod::CandidatesBplusMCP const& candidates) + { + for (auto& candidate : candidates) { + inputParticles.clear(); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, &candidate); + + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); + rhoBplusMcTable(rho, rhoM); + } + } + PROCESS_SWITCH(RhoEstimatorTask, processBplusMcCollisions, "Fill rho tables for collisions with Bplus MCP candidates", false); + + void processDielectronCollisions(aod::JetCollision const& collision, soa::Filtered const& tracks, aod::CandidatesDielectronData const& candidates) { - inputParticles.clear(); for (auto& candidate : candidates) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || collision.centFT0M() < config.centralityMin || collision.centFT0M() >= config.centralityMax || collision.trackOccupancyInTimeRange() > config.trackOccupancyInTimeRangeMax || std::abs(collision.posZ()) > config.vertexZCut) { + rhoDielectronTable(0.0, 0.0); + continue; + } inputParticles.clear(); - jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, config.trackingEfficiency, &candidate); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); rhoDielectronTable(rho, rhoM); } } @@ -194,12 +409,11 @@ struct RhoEstimatorTask { void processDielectronMcCollisions(aod::JetMcCollision const&, soa::Filtered const& particles, aod::CandidatesDielectronMCP const& candidates) { - inputParticles.clear(); for (auto& candidate : candidates) { inputParticles.clear(); - jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, std::optional{candidate}); + jetfindingutilities::analyseParticles(inputParticles, particleSelection, 1, particles, pdgDatabase, &candidate); - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, config.doSparse); rhoDielectronMcTable(rho, rhoM); } } diff --git a/PWGJE/TableProducer/secondaryVertexReconstruction.cxx b/PWGJE/TableProducer/secondaryVertexReconstruction.cxx index 5ed4799a80f..8bab0ea0c05 100644 --- a/PWGJE/TableProducer/secondaryVertexReconstruction.cxx +++ b/PWGJE/TableProducer/secondaryVertexReconstruction.cxx @@ -9,32 +9,46 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// Task to produce a SV indices table joinable to the jet tables and 3/2-prong SV for hf jet tagging -// +/// \file secondaryVertexReconstruction.cxx +/// \brief Task to produce a SV indices table joinable to the jet tables and 3/2-prong SV for hf jet tagging /// \author Hadi Hassan -#include +#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetTagging.h" -#include -#include +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/TrackSelectionTables.h" #include "CommonConstants/PhysicsConstants.h" #include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/RecoDecay.h" - +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "ReconstructionDataFormats/DCA.h" - -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetTagging.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" - -#include "PWGHF/Utils/utilsBfieldCCDB.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -69,6 +83,8 @@ struct SecondaryVertexReconstruction { Configurable ptMinTrack{"ptMinTrack", -1., "min. track pT"}; Configurable etaMinTrack{"etaMinTrack", -99999., "min. pseudorapidity"}; Configurable etaMaxTrack{"etaMaxTrack", 4., "max. pseudorapidity"}; + Configurable maxIPxy{"maxIPxy", 10, "maximum track DCA in xy plane"}; + Configurable maxIPz{"maxIPz", 10, "maximum track DCA in z direction"}; Configurable fillHistograms{"fillHistograms", true, "do validation plots"}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -194,8 +210,6 @@ struct SecondaryVertexReconstruction { auto chi2PCA = df.getChi2AtPCACandidate(); auto covMatrixPCA = df.calcPCACovMatrixFlat(); - registry.fill(HIST("hDispersion"), dispersion, numProngs); - // get track impact parameters // This modifies track momenta! auto primaryVertex = getPrimaryVertex(collision); @@ -269,12 +283,13 @@ struct SecondaryVertexReconstruction { // fill histograms if (fillHistograms) { - double DecayLengthNormalised = RecoDecay::distance(std::array{primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, std::array{secondaryVertex[0], secondaryVertex[1], secondaryVertex[2]}) / errorDecayLength; - double DecayLengthXYNormalised = RecoDecay::distanceXY(std::array{primaryVertex.getX(), primaryVertex.getY()}, std::array{secondaryVertex[0], secondaryVertex[1]}) / errorDecayLengthXY; + double decayLengthNormalised = RecoDecay::distance(std::array{primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, std::array{secondaryVertex[0], secondaryVertex[1], secondaryVertex[2]}) / errorDecayLength; + double decayLengthXYNormalised = RecoDecay::distanceXY(std::array{primaryVertex.getX(), primaryVertex.getY()}, std::array{secondaryVertex[0], secondaryVertex[1]}) / errorDecayLengthXY; + registry.fill(HIST("hDispersion"), dispersion, numProngs); registry.fill(HIST("hMassNProngs"), massSV, numProngs); - registry.fill(HIST("hLxySNProngs"), DecayLengthXYNormalised, numProngs); - registry.fill(HIST("hLSNProngs"), DecayLengthNormalised, numProngs); + registry.fill(HIST("hLxySNProngs"), decayLengthXYNormalised, numProngs); + registry.fill(HIST("hLSNProngs"), decayLengthNormalised, numProngs); registry.fill(HIST("hFeNProngs"), energySV / analysisJet.energy() > 1. ? 0.99 : energySV / analysisJet.energy(), numProngs); } @@ -285,7 +300,7 @@ struct SecondaryVertexReconstruction { for (size_t iprong = prongIndex; iprong < particles.size(); ++iprong) { const auto& testTrack = particles[iprong].template track_as(); - if (testTrack.pt() < ptMinTrack || testTrack.eta() < etaMinTrack || testTrack.eta() > etaMaxTrack) { + if (testTrack.pt() < ptMinTrack || testTrack.eta() < etaMinTrack || testTrack.eta() > etaMaxTrack || std::abs(testTrack.dcaXY()) > maxIPxy || std::abs(testTrack.dcaZ()) > maxIPz) { continue; } @@ -301,81 +316,81 @@ struct SecondaryVertexReconstruction { } PROCESS_SWITCH(SecondaryVertexReconstruction, processDummy, "Dummy process", true); - void processData3Prongs(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& jets, JetTracksData const& jtracks, OriginalTracks const& /*tracks*/, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) + void processData3Prongs(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& jets, JetTracksData const& tracks, OriginalTracks const& /*tracks*/, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) { - for (auto& jet : jets) { + for (const auto& jet : jets) { std::vector svIndices; - runCreatorNProng<3, false>(collision.template collision_as(), jet, jtracks, svIndices, df3); + runCreatorNProng<3, false>(collision.template collision_as(), jet, tracks, svIndices, df3); sv3prongIndicesTableData(svIndices); } } PROCESS_SWITCH(SecondaryVertexReconstruction, processData3Prongs, "Reconstruct the data 3-prong secondary vertex", false); - void processData3ProngsExternalMagneticField(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& jets, JetTracksData const& jtracks, OriginalTracks const& /*tracks*/) + void processData3ProngsExternalMagneticField(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& jets, JetTracksData const& tracks, OriginalTracks const& /*tracks*/) { - for (auto& jet : jets) { + for (const auto& jet : jets) { std::vector svIndices; - runCreatorNProng<3, true>(collision.template collision_as(), jet, jtracks, svIndices, df3); + runCreatorNProng<3, true>(collision.template collision_as(), jet, tracks, svIndices, df3); sv3prongIndicesTableData(svIndices); } } PROCESS_SWITCH(SecondaryVertexReconstruction, processData3ProngsExternalMagneticField, "Reconstruct the data 3-prong secondary vertex with external magnetic field", false); - void processData2Prongs(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& jets, JetTracksData const& jtracks, OriginalTracks const& /*tracks*/, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) + void processData2Prongs(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& jets, JetTracksData const& tracks, OriginalTracks const& /*tracks*/, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) { - for (auto& jet : jets) { + for (const auto& jet : jets) { std::vector svIndices; - runCreatorNProng<2, false>(collision.template collision_as(), jet, jtracks, svIndices, df2); + runCreatorNProng<2, false>(collision.template collision_as(), jet, tracks, svIndices, df2); sv2prongIndicesTableData(svIndices); } } PROCESS_SWITCH(SecondaryVertexReconstruction, processData2Prongs, "Reconstruct the data 2-prong secondary vertex", false); - void processData2ProngsExternalMagneticField(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& jets, JetTracksData const& jtracks, OriginalTracks const& /*tracks*/) + void processData2ProngsExternalMagneticField(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& jets, JetTracksData const& tracks, OriginalTracks const& /*tracks*/) { - for (auto& jet : jets) { + for (const auto& jet : jets) { std::vector svIndices; - runCreatorNProng<2, true>(collision.template collision_as(), jet, jtracks, svIndices, df2); + runCreatorNProng<2, true>(collision.template collision_as(), jet, tracks, svIndices, df2); sv2prongIndicesTableData(svIndices); } } PROCESS_SWITCH(SecondaryVertexReconstruction, processData2ProngsExternalMagneticField, "Reconstruct the data 2-prong secondary vertex with extrernal magnetic field", false); - void processMCD3Prongs(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& mcdjets, JetTracksMCDwPIs const& jtracks, OriginalTracks const& /*tracks*/, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) + void processMCD3Prongs(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& mcdjets, JetTracksMCDwPIs const& tracks, OriginalTracks const& /*tracks*/, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) { - for (auto& jet : mcdjets) { + for (const auto& jet : mcdjets) { std::vector svIndices; - runCreatorNProng<3, false>(collision.template collision_as(), jet, jtracks, svIndices, df3); + runCreatorNProng<3, false>(collision.template collision_as(), jet, tracks, svIndices, df3); sv3prongIndicesTableMCD(svIndices); } } PROCESS_SWITCH(SecondaryVertexReconstruction, processMCD3Prongs, "Reconstruct the MCD 3-prong secondary vertex", false); - void processMCD3ProngsExternalMagneticField(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& mcdjets, JetTracksMCDwPIs const& jtracks, OriginalTracks const& /*tracks*/) + void processMCD3ProngsExternalMagneticField(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& mcdjets, JetTracksMCDwPIs const& tracks, OriginalTracks const& /*tracks*/) { - for (auto& jet : mcdjets) { + for (const auto& jet : mcdjets) { std::vector svIndices; - runCreatorNProng<3, true>(collision.template collision_as(), jet, jtracks, svIndices, df3); + runCreatorNProng<3, true>(collision.template collision_as(), jet, tracks, svIndices, df3); sv3prongIndicesTableMCD(svIndices); } } PROCESS_SWITCH(SecondaryVertexReconstruction, processMCD3ProngsExternalMagneticField, "Reconstruct the MCD 3-prong secondary vertex with external magnetic field", false); - void processMCD2Prongs(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& mcdjets, JetTracksMCDwPIs const& jtracks, OriginalTracks const& /*tracks*/, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) + void processMCD2Prongs(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& mcdjets, JetTracksMCDwPIs const& tracks, OriginalTracks const& /*tracks*/, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) { - for (auto& jet : mcdjets) { + for (const auto& jet : mcdjets) { std::vector svIndices; - runCreatorNProng<2, false>(collision.template collision_as(), jet, jtracks, svIndices, df2); + runCreatorNProng<2, false>(collision.template collision_as(), jet, tracks, svIndices, df2); sv2prongIndicesTableMCD(svIndices); } } PROCESS_SWITCH(SecondaryVertexReconstruction, processMCD2Prongs, "Reconstruct the MCD 2-prong secondary vertex", false); - void processMCD2ProngsExternalMagneticField(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& mcdjets, JetTracksMCDwPIs const& jtracks, OriginalTracks const& /*tracks*/) + void processMCD2ProngsExternalMagneticField(JetCollisionwPIs::iterator const& collision, aod::Collisions const& /*realColl*/, soa::Join const& mcdjets, JetTracksMCDwPIs const& tracks, OriginalTracks const& /*tracks*/) { - for (auto& jet : mcdjets) { + for (const auto& jet : mcdjets) { std::vector svIndices; - runCreatorNProng<2, true>(collision.template collision_as(), jet, jtracks, svIndices, df2); + runCreatorNProng<2, true>(collision.template collision_as(), jet, tracks, svIndices, df2); sv2prongIndicesTableMCD(svIndices); } } @@ -384,5 +399,5 @@ struct SecondaryVertexReconstruction { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-sv-reconstruction-charged"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-sv-reconstruction-charged"})}; // o2-linter: disable=name/o2-task } diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 8f916dcca34..05ab2be9eea 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -26,6 +26,10 @@ o2physics_add_dpl_workflow(emc-vertexselection-qa SOURCES emcVertexSelectionQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(emcal-gamma-gamma-bc-wise + SOURCES emcalGammaGammaBcWise.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore + COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(emc-pi0-energyscale-calib SOURCES emcalPi0EnergyScaleCalib.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore @@ -46,6 +50,14 @@ o2physics_add_dpl_workflow(photon-isolation-qa SOURCES photonIsolationQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(photon-charged-trigger-correlation + SOURCES photonChargedTriggerCorrelation.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-emc-extensive-mc-qa + SOURCES taskEmcExtensiveMcQa.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2Physics::AnalysisCore O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) if(FastJet_FOUND) o2physics_add_dpl_workflow(jet-background-analysis @@ -64,11 +76,23 @@ if(FastJet_FOUND) SOURCES jetSubstructureD0.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-substructure-dplus + SOURCES jetSubstructureDplus.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-substructure-dstar + SOURCES jetSubstructureDstar.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-substructure-lc SOURCES jetSubstructureLc.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(jet-substructure-bplus + o2physics_add_dpl_workflow(jet-substructure-b0 + SOURCES jetSubstructureB0.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-substructure-bplus SOURCES jetSubstructureBplus.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -80,10 +104,22 @@ o2physics_add_dpl_workflow(jet-substructure-bplus SOURCES jetSubstructureD0Output.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-substructure-dplus-output + SOURCES jetSubstructureDplusOutput.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-substructure-dstar-output + SOURCES jetSubstructureDstarOutput.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-substructure-lc-output SOURCES jetSubstructureLcOutput.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-substructure-b0-output + SOURCES jetSubstructureB0Output.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-substructure-bplus-output SOURCES jetSubstructureBplusOutput.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore @@ -116,10 +152,22 @@ o2physics_add_dpl_workflow(jet-substructure-bplus SOURCES jetFinderD0QA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-finder-dplus-qa + SOURCES jetFinderDplusQA.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-finder-dstar-qa + SOURCES jetFinderDstarQA.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-finder-lc-qa SOURCES jetFinderLcQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-finder-b0-qa + SOURCES jetFinderB0QA.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-finder-bplus-qa SOURCES jetFinderBplusQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore @@ -144,14 +192,14 @@ o2physics_add_dpl_workflow(jet-substructure-bplus SOURCES triggerCorrelations.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(jet-charged-trigger-qa - SOURCES ChJetTriggerQATask.cxx + o2physics_add_dpl_workflow(jet-trigger-charged-qa + SOURCES jetTriggerChargedQa.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-full-trigger-qa + SOURCES fullJetTriggerQATask.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(jet-full-trigger-qa - SOURCES fullJetTriggerQATask.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore - COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-matching-qa SOURCES jetMatchingQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore @@ -195,6 +243,7 @@ o2physics_add_dpl_workflow(jet-substructure-bplus o2physics_add_dpl_workflow(nuclei-in-jets SOURCES nucleiInJets.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + O2Physics::AnalysisCCDB O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-taggerhf-qa SOURCES jetTaggerHFQA.cxx @@ -204,7 +253,7 @@ o2physics_add_dpl_workflow(jet-substructure-bplus SOURCES jetLundReclustering.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore FastJet::FastJet FastJet::Contrib COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(jet-hf-fragmentation + o2physics_add_dpl_workflow(hf-fragmentation-function SOURCES hfFragmentationFunction.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -224,8 +273,8 @@ o2physics_add_dpl_workflow(jet-substructure-bplus SOURCES statPromptPhoton.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(full-jet-spectra-pp - SOURCES fullJetSpectraPP.cxx + o2physics_add_dpl_workflow(full-jet-spectra + SOURCES fullJetSpectra.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(bjet-tagging-ml @@ -240,5 +289,16 @@ o2physics_add_dpl_workflow(jet-substructure-bplus SOURCES gammaJetTreeProducer.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) - + o2physics_add_dpl_workflow(dijet-finder-charged-qa + SOURCES dijetFinderQA.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(bjet-tagging-gnn + SOURCES bjetTaggingGnn.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-shape + SOURCES jetShape.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) endif() diff --git a/PWGJE/Tasks/bjetTaggingGnn.cxx b/PWGJE/Tasks/bjetTaggingGnn.cxx new file mode 100644 index 00000000000..1e74fb21ff3 --- /dev/null +++ b/PWGJE/Tasks/bjetTaggingGnn.cxx @@ -0,0 +1,481 @@ +// 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. + +/// \file bjetTaggingGnn.cxx +/// \brief b-jet tagging using GNN +/// +/// \author Changhwan Choi , Pusan National University + +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetTaggingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetTagging.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct BjetTaggingGnn { + + HistogramRegistry registry; + + // event level configurables + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + Configurable useEventWeight{"useEventWeight", true, "Flag whether to scale histograms with the event weight"}; + + Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; + Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; + Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; + + // track level configurables + Configurable trackPtMin{"trackPtMin", 0.5, "minimum track pT"}; + Configurable trackPtMax{"trackPtMax", 1000.0, "maximum track pT"}; + Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track eta"}; + Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum track eta"}; + + Configurable trackNppCrit{"trackNppCrit", 0.95, "track not physical primary ratio"}; + + // track level configurables + Configurable svPtMin{"svPtMin", 0.5, "minimum SV pT"}; + + // jet level configurables + Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT"}; + Configurable jetPtMax{"jetPtMax", 1000.0, "maximum jet pT"}; + Configurable jetEtaMin{"jetEtaMin", -99.0, "minimum jet pseudorapidity"}; + Configurable jetEtaMax{"jetEtaMax", 99.0, "maximum jet pseudorapidity"}; + + Configurable> jetRadii{"jetRadii", std::vector{0.4}, "jet resolution parameters"}; + + Configurable doDataDriven{"doDataDriven", false, "Flag whether to use fill THnSpase for data driven methods"}; + Configurable callSumw2{"callSumw2", false, "Flag whether to call THnSparse::Sumw2() for error calculation"}; + + std::vector eventSelectionBits; + + std::vector jetRadiiValues; + + void init(InitContext const&) + { + jetRadiiValues = (std::vector)jetRadii; + + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + + registry.add("h_vertexZ", "Vertex Z;#it{Z} (cm)", {HistType::kTH1F, {{40, -20.0, 20.0}}}); + + const AxisSpec axisJetpT{200, 0., 200., "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisDb{200, -10., 20., "#it{D}_{b}"}; + const AxisSpec axisDbFine{3000, -10., 20., "#it{D}_{b}"}; + const AxisSpec axisSVMass{200, 0., 10., "#it{m}_{SV} (GeV/#it{c}^{2})"}; + const AxisSpec axisSVEnergy{200, 0., 100., "#it{E}_{SV} (GeV)"}; + const AxisSpec axisSLxy{200, 0., 100., "#it{SL}_{xy}"}; + const AxisSpec axisJetMass{200, 0., 50., "#it{m}_{jet} (GeV/#it{c}^{2})"}; + const AxisSpec axisJetProb{200, 0., 40., "-ln(JP)"}; + const AxisSpec axisNTracks{42, 0, 42, "#it{n}_{tracks}"}; + + registry.add("h_jetpT", "", {HistType::kTH1F, {axisJetpT}}); + registry.add("h_Db", "", {HistType::kTH1F, {axisDbFine}}); + registry.add("h2_jetpT_Db", "", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h2_jetpT_SVMass", "", {HistType::kTH2F, {axisJetpT, axisSVMass}}); + registry.add("h2_jetpT_jetMass", "", {HistType::kTH2F, {axisJetpT, axisJetMass}}); + registry.add("h2_jetpT_jetProb", "", {HistType::kTH2F, {axisJetpT, axisJetProb}}); + registry.add("h2_jetpT_nTracks", "", {HistType::kTH2F, {axisJetpT, axisNTracks}}); + + if (doprocessMCJets) { + registry.add("h_jetpT_b", "b-jet", {HistType::kTH1F, {axisJetpT}}); + registry.add("h_jetpT_c", "c-jet", {HistType::kTH1F, {axisJetpT}}); + registry.add("h_jetpT_lf", "lf-jet", {HistType::kTH1F, {axisJetpT}}); + registry.add("h_Db_b", "b-jet", {HistType::kTH1F, {axisDbFine}}); + registry.add("h_Db_c", "c-jet", {HistType::kTH1F, {axisDbFine}}); + registry.add("h_Db_lf", "lf-jet", {HistType::kTH1F, {axisDbFine}}); + registry.add("h2_jetpT_Db_b", "b-jet", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h2_jetpT_Db_c", "c-jet", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h2_jetpT_Db_lf", "lf-jet", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h2_jetpT_SVMass_b", "b-jet", {HistType::kTH2F, {axisJetpT, axisSVMass}}); + registry.add("h2_jetpT_SVMass_c", "c-jet", {HistType::kTH2F, {axisJetpT, axisSVMass}}); + registry.add("h2_jetpT_SVMass_lf", "lf-jet", {HistType::kTH2F, {axisJetpT, axisSVMass}}); + registry.add("h2_jetpT_jetMass_b", "b-jet", {HistType::kTH2F, {axisJetpT, axisJetMass}}); + registry.add("h2_jetpT_jetMass_c", "c-jet", {HistType::kTH2F, {axisJetpT, axisJetMass}}); + registry.add("h2_jetpT_jetMass_lf", "lf-jet", {HistType::kTH2F, {axisJetpT, axisJetMass}}); + registry.add("h2_jetpT_jetProb_b", "b-jet", {HistType::kTH2F, {axisJetpT, axisJetProb}}); + registry.add("h2_jetpT_jetProb_c", "c-jet", {HistType::kTH2F, {axisJetpT, axisJetProb}}); + registry.add("h2_jetpT_jetProb_lf", "lf-jet", {HistType::kTH2F, {axisJetpT, axisJetProb}}); + registry.add("h2_jetpT_nTracks_b", "b-jet", {HistType::kTH2F, {axisJetpT, axisNTracks}}); + registry.add("h2_jetpT_nTracks_c", "c-jet", {HistType::kTH2F, {axisJetpT, axisNTracks}}); + registry.add("h2_jetpT_nTracks_lf", "lf-jet", {HistType::kTH2F, {axisJetpT, axisNTracks}}); + registry.add("h2_Response_DetjetpT_PartjetpT", "", {HistType::kTH2F, {axisJetpT, axisJetpT}}); + registry.add("h2_Response_DetjetpT_PartjetpT_b", "b-jet", {HistType::kTH2F, {axisJetpT, axisJetpT}}); + registry.add("h2_Response_DetjetpT_PartjetpT_c", "c-jet", {HistType::kTH2F, {axisJetpT, axisJetpT}}); + registry.add("h2_Response_DetjetpT_PartjetpT_lf", "lf-jet", {HistType::kTH2F, {axisJetpT, axisJetpT}}); + registry.add("h2_jetpT_Db_lf_none", "lf-jet (none)", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h2_jetpT_Db_lf_matched", "lf-jet (matched)", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h2_jetpT_Db_npp", "NotPhysPrim", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h2_jetpT_Db_npp_b", "NotPhysPrim b-jet", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h2_jetpT_Db_npp_c", "NotPhysPrim c-jet", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h2_jetpT_Db_npp_lf", "NotPhysPrim lf-jet", {HistType::kTH2F, {axisJetpT, axisDb}}); + registry.add("h_Db_npp", "NotPhysPrim", {HistType::kTH1F, {axisDbFine}}); + registry.add("h_Db_npp_b", "NotPhysPrim b-jet", {HistType::kTH1F, {axisDbFine}}); + registry.add("h_Db_npp_c", "NotPhysPrim c-jet", {HistType::kTH1F, {axisDbFine}}); + registry.add("h_Db_npp_lf", "NotPhysPrim lf-jet", {HistType::kTH1F, {axisDbFine}}); + // registry.add("h2_pT_dcaXY_pp", "tracks", {HistType::kTH2F, {axisJetpT, {200, 0., 1.}}}); + // registry.add("h2_pT_dcaXY_npp", "NotPhysPrim tracks", {HistType::kTH2F, {axisJetpT, {200, 0., 1.}}}); + // registry.add("h2_pT_dcaZ_pp", "tracks", {HistType::kTH2F, {axisJetpT, {200, 0., 2.}}}); + // registry.add("h2_pT_dcaZ_npp", "NotPhysPrim tracks", {HistType::kTH2F, {axisJetpT, {200, 0., 2.}}}); + } + + if (doprocessMCTruthJets) { + registry.add("h_jetpT_particle", "", {HistType::kTH1F, {axisJetpT}}); + registry.add("h_jetpT_particle_b", "particle b-jet", {HistType::kTH1F, {axisJetpT}}); + registry.add("h_jetpT_particle_c", "particle c-jet", {HistType::kTH1F, {axisJetpT}}); + registry.add("h_jetpT_particle_lf", "particle lf-jet", {HistType::kTH1F, {axisJetpT}}); + } + + if (doDataDriven) { + registry.add("hSparse_Incljets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}}, callSumw2); + if (doprocessMCJets) { + registry.add("hSparse_bjets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}}, callSumw2); + registry.add("hSparse_cjets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}}, callSumw2); + registry.add("hSparse_lfjets", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}}, callSumw2); + registry.add("hSparse_lfjets_none", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}}, callSumw2); + registry.add("hSparse_lfjets_matched", "", {HistType::kTHnSparseF, {axisJetpT, axisDbFine, axisSVMass, axisJetMass, axisNTracks}}, callSumw2); + } + } + } + + Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; + Filter trackCuts = (aod::jtrack::pt > trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); + Filter jetFilter = (aod::jet::pt >= jetPtMin && aod::jet::pt <= jetPtMax && aod::jet::eta < jetEtaMax - aod::jet::r / 100.f && aod::jet::eta > jetEtaMin + aod::jet::r / 100.f); + + using FilteredCollision = soa::Filtered>; + using DataJets = soa::Filtered>; + using JetTrackswID = soa::Filtered>; + using JetTracksMCDwID = soa::Filtered>; + using SVTable = aod::DataSecondaryVertex3Prongs; + using MCDSVTable = aod::MCDSecondaryVertex3Prongs; + + template + int analyzeJetTrackInfo(AnyCollision const& /*collision*/, AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/ /*, int8_t jetFlavor = 0, double weight = 1.0*/) + { + int nTracks = 0; + for (const auto& constituent : analysisJet.template tracks_as()) { + + if (constituent.pt() < trackPtMin) { + continue; + } + + // ... + + ++nTracks; + } + return nTracks; + } + + template + SecondaryVertices::iterator analyzeJetSVInfo(AnalysisJet const& analysisJet, SecondaryVertices const& allSVs, bool& checkSV /*, int8_t jetFlavor = 0, double weight = 1.0*/) + { + using SVType = typename SecondaryVertices::iterator; + + auto compare = [](SVType& sv1, SVType& sv2) { + return (sv1.decayLengthXY() / sv1.errorDecayLengthXY()) > (sv2.decayLengthXY() / sv2.errorDecayLengthXY()); + }; + + auto svs = analysisJet.template secondaryVertices_as(); + + std::sort(svs.begin(), svs.end(), compare); + + checkSV = false; + for (const auto& candSV : svs) { + + if (candSV.pt() < svPtMin) { + continue; + } + + checkSV = true; + return candSV; + } + + // No SV found + return *allSVs.begin(); + } + + void processDummy(FilteredCollision::iterator const& /*collision*/) + { + } + PROCESS_SWITCH(BjetTaggingGnn, processDummy, "Dummy process function turned on by default", true); + + void processDataJets(FilteredCollision::iterator const& collision, DataJets const& alljets, JetTrackswID const& allTracks, SVTable const& allSVs) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + + registry.fill(HIST("h_vertexZ"), collision.posZ()); + + for (const auto& analysisJet : alljets) { + + bool jetIncluded = false; + for (const auto& jetR : jetRadiiValues) { + if (analysisJet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } + } + + if (!jetIncluded) { + continue; + } + + int nTracks = analyzeJetTrackInfo(collision, analysisJet, allTracks); + + float mSV = -1.f; + // float eSV = -1.f; + // float slXY = -1.f; + + bool checkSV; + // auto sv = jettaggingutilities::jetFromProngMaxDecayLength(analysisJet, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, false, &checkSV); + auto sv = analyzeJetSVInfo(analysisJet, allSVs, checkSV); + + if (checkSV) { + mSV = sv.m(); + // eSV = sv.e(); + // slXY = sv.decayLengthXY() / sv.errorDecayLengthXY(); + } + + registry.fill(HIST("h_jetpT"), analysisJet.pt()); + registry.fill(HIST("h_Db"), analysisJet.scoreML()); + registry.fill(HIST("h2_jetpT_Db"), analysisJet.pt(), analysisJet.scoreML()); + registry.fill(HIST("h2_jetpT_SVMass"), analysisJet.pt(), mSV); + registry.fill(HIST("h2_jetpT_jetMass"), analysisJet.pt(), analysisJet.mass()); + registry.fill(HIST("h2_jetpT_jetProb"), analysisJet.pt(), analysisJet.jetProb()); + registry.fill(HIST("h2_jetpT_nTracks"), analysisJet.pt(), nTracks); + + if (doDataDriven) { + registry.fill(HIST("hSparse_Incljets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks); + } + } + } + PROCESS_SWITCH(BjetTaggingGnn, processDataJets, "jet information in Data", false); + + using MCDJetTable = soa::Filtered>; + using MCPJetTable = soa::Filtered>; + using FilteredCollisionMCD = soa::Filtered>; + + void processMCJets(FilteredCollisionMCD::iterator const& collision, MCDJetTable const& MCDjets, MCPJetTable const& /*MCPjets*/, JetTracksMCDwID const& /*allTracks*/, MCDSVTable const& allSVs, aod::JetParticles const& /*MCParticles*/) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + + registry.fill(HIST("h_vertexZ"), collision.posZ()); + + for (const auto& analysisJet : MCDjets) { + + bool jetIncluded = false; + for (const auto& jetR : jetRadiiValues) { + if (analysisJet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } + } + + if (!jetIncluded) { + continue; + } + + float weight = useEventWeight ? analysisJet.eventWeight() : 1.f; + float pTHat = 10. / (std::pow(analysisJet.eventWeight(), 1.0 / pTHatExponent)); + if (analysisJet.pt() > pTHatMaxMCD * pTHat) { + continue; + } + + int8_t jetFlavor = analysisJet.origin(); + + // int nTracks = analyzeJetTrackInfo(collision, analysisJet, allTracks /*, jetFlavor, weight*/); + int nTracks = 0; + + int nNppTracks = 0; + for (const auto& constituent : analysisJet.template tracks_as()) { + if (constituent.pt() < trackPtMin) { + continue; + } + if (!constituent.has_mcParticle() || !constituent.template mcParticle_as().isPhysicalPrimary()) { + // registry.fill(HIST("h2_pT_dcaXY_npp"), constituent.pt(), constituent.dcaXY()); + // registry.fill(HIST("h2_pT_dcaZ_npp"), constituent.pt(), constituent.dcaZ()); + ++nNppTracks; + } else { + // registry.fill(HIST("h2_pT_dcaXY_pp"), constituent.pt(), constituent.dcaXY()); + // registry.fill(HIST("h2_pT_dcaZ_pp"), constituent.pt(), constituent.dcaZ()); + } + ++nTracks; + } + + float mSV = -1.f; + // float eSV = -1.f; + // float slXY = -1.f; + + bool checkSV; + auto sv = analyzeJetSVInfo(analysisJet, allSVs, checkSV /*, jetFlavor, weight*/); + + if (checkSV) { + mSV = sv.m(); + // eSV = sv.e(); + // slXY = sv.decayLengthXY() / sv.errorDecayLengthXY(); + } + + registry.fill(HIST("h_jetpT"), analysisJet.pt(), weight); + registry.fill(HIST("h_Db"), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_Db"), analysisJet.pt(), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_SVMass"), analysisJet.pt(), mSV, weight); + registry.fill(HIST("h2_jetpT_jetMass"), analysisJet.pt(), analysisJet.mass(), weight); + registry.fill(HIST("h2_jetpT_jetProb"), analysisJet.pt(), analysisJet.jetProb(), weight); + registry.fill(HIST("h2_jetpT_nTracks"), analysisJet.pt(), nTracks, weight); + + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("h_jetpT_b"), analysisJet.pt(), weight); + registry.fill(HIST("h_Db_b"), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_Db_b"), analysisJet.pt(), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_SVMass_b"), analysisJet.pt(), mSV, weight); + registry.fill(HIST("h2_jetpT_jetMass_b"), analysisJet.pt(), analysisJet.mass(), weight); + registry.fill(HIST("h2_jetpT_jetProb_b"), analysisJet.pt(), analysisJet.jetProb(), weight); + registry.fill(HIST("h2_jetpT_nTracks_b"), analysisJet.pt(), nTracks, weight); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("h_jetpT_c"), analysisJet.pt(), weight); + registry.fill(HIST("h_Db_c"), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_Db_c"), analysisJet.pt(), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_SVMass_c"), analysisJet.pt(), mSV, weight); + registry.fill(HIST("h2_jetpT_jetMass_c"), analysisJet.pt(), analysisJet.mass(), weight); + registry.fill(HIST("h2_jetpT_jetProb_c"), analysisJet.pt(), analysisJet.jetProb(), weight); + registry.fill(HIST("h2_jetpT_nTracks_c"), analysisJet.pt(), nTracks, weight); + } else { + registry.fill(HIST("h_jetpT_lf"), analysisJet.pt(), weight); + registry.fill(HIST("h_Db_lf"), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_Db_lf"), analysisJet.pt(), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_SVMass_lf"), analysisJet.pt(), mSV, weight); + registry.fill(HIST("h2_jetpT_jetMass_lf"), analysisJet.pt(), analysisJet.mass(), weight); + registry.fill(HIST("h2_jetpT_jetProb_lf"), analysisJet.pt(), analysisJet.jetProb(), weight); + registry.fill(HIST("h2_jetpT_nTracks_lf"), analysisJet.pt(), nTracks, weight); + if (jetFlavor == JetTaggingSpecies::none) { + registry.fill(HIST("h2_jetpT_Db_lf_none"), analysisJet.pt(), analysisJet.scoreML(), weight); + } else { + registry.fill(HIST("h2_jetpT_Db_lf_matched"), analysisJet.pt(), analysisJet.scoreML(), weight); + } + } + + if (static_cast(nNppTracks) / nTracks > trackNppCrit) { + registry.fill(HIST("h_Db_npp"), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_Db_npp"), analysisJet.pt(), analysisJet.scoreML(), weight); + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("h_Db_npp_b"), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_Db_npp_b"), analysisJet.pt(), analysisJet.scoreML(), weight); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("h_Db_npp_c"), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_Db_npp_c"), analysisJet.pt(), analysisJet.scoreML(), weight); + } else { + registry.fill(HIST("h_Db_npp_lf"), analysisJet.scoreML(), weight); + registry.fill(HIST("h2_jetpT_Db_npp_lf"), analysisJet.pt(), analysisJet.scoreML(), weight); + } + } + + if (doDataDriven) { + registry.fill(HIST("hSparse_Incljets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight); + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("hSparse_bjets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("hSparse_cjets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight); + } else { + registry.fill(HIST("hSparse_lfjets"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight); + if (jetFlavor == JetTaggingSpecies::none) { + registry.fill(HIST("hSparse_lfjets_none"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight); + } else { + registry.fill(HIST("hSparse_lfjets_matched"), analysisJet.pt(), analysisJet.scoreML(), mSV, analysisJet.mass(), nTracks, weight); + } + } + } + + for (const auto& mcpjet : analysisJet.template matchedJetGeo_as()) { + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { + continue; + } + + registry.fill(HIST("h2_Response_DetjetpT_PartjetpT"), analysisJet.pt(), mcpjet.pt(), weight); + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_b"), analysisJet.pt(), mcpjet.pt(), weight); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_c"), analysisJet.pt(), mcpjet.pt(), weight); + } else { + registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_lf"), analysisJet.pt(), mcpjet.pt(), weight); + } + } + } + } + PROCESS_SWITCH(BjetTaggingGnn, processMCJets, "jet information in MC", false); + + Filter mccollisionFilter = nabs(aod::jmccollision::posZ) < vertexZCut; + using FilteredCollisionMCP = soa::Filtered; + + void processMCTruthJets(FilteredCollisionMCP::iterator const& /*collision*/, MCPJetTable const& MCPjets, aod::JetParticles const& /*MCParticles*/) + { + + for (const auto& mcpjet : MCPjets) { + + bool jetIncluded = false; + for (const auto& jetR : jetRadiiValues) { + if (mcpjet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } + } + + if (!jetIncluded) { + continue; + } + + float weight = useEventWeight ? mcpjet.eventWeight() : 1.0; + float pTHat = 10. / (std::pow(mcpjet.eventWeight(), 1.0 / pTHatExponent)); + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { + continue; + } + + int8_t jetFlavor = mcpjet.origin(); + + registry.fill(HIST("h_jetpT_particle"), mcpjet.pt(), weight); + + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("h_jetpT_particle_b"), mcpjet.pt(), weight); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("h_jetpT_particle_c"), mcpjet.pt(), weight); + } else { + registry.fill(HIST("h_jetpT_particle_lf"), mcpjet.pt(), weight); + } + } + } + PROCESS_SWITCH(BjetTaggingGnn, processMCTruthJets, "truth jet information", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGJE/Tasks/bjetTaggingML.cxx b/PWGJE/Tasks/bjetTaggingML.cxx index 98b3542cc09..64536cb0c15 100644 --- a/PWGJE/Tasks/bjetTaggingML.cxx +++ b/PWGJE/Tasks/bjetTaggingML.cxx @@ -14,28 +14,31 @@ /// /// \author Hadi Hassan , University of Jyväskylä -#include -#include -#include - -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoA.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "PWGJE/Core/JetUtilities.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" #include "PWGJE/Core/JetTaggingUtilities.h" -#include "PWGJE/DataModel/JetTagging.h" +#include "PWGJE/Core/JetUtilities.h" #include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetTagging.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/Core/RecoDecay.h" -#include "Tools/ML/MlResponse.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -43,52 +46,11 @@ using namespace o2::framework::expressions; struct BJetTaggingML { - struct bjetParams { - float mJetpT = 0.0; - float mJetEta = 0.0; - float mJetPhi = 0.0; - int mNTracks = -1; - int mNSV = -1; - float mJetMass = 0.0; - }; - - struct bjetTrackParams { - double mTrackpT = 0.0; - double mTrackEta = 0.0; - double mDotProdTrackJet = 0.0; - double mDotProdTrackJetOverJet = 0.0; - double mDeltaRJetTrack = 0.0; - double mSignedIP2D = 0.0; - double mSignedIP2DSign = 0.0; - double mSignedIP3D = 0.0; - double mSignedIP3DSign = 0.0; - double mMomFraction = 0.0; - double mDeltaRTrackVertex = 0.0; - }; - - struct bjetSVParams { - double mSVpT = 0.0; - double mDeltaRSVJet = 0.0; - double mSVMass = 0.0; - double mSVfE = 0.0; - double mIPXY = 0.0; - double mCPA = 0.0; - double mChi2PCA = 0.0; - double mDispersion = 0.0; - double mDecayLength2D = 0.0; - double mDecayLength2DError = 0.0; - double mDecayLength3D = 0.0; - double mDecayLength3DError = 0.0; - }; - HistogramRegistry registry; - static constexpr double defaultCutsMl[1][2] = {{0.5, 0.5}}; - // event level configurables Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; - Configurable useEventWeight{"useEventWeight", true, "Flag whether to scale histograms with the event weight"}; Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; @@ -99,6 +61,8 @@ struct BJetTaggingML { Configurable trackPtMax{"trackPtMax", 1000.0, "maximum track pT"}; Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track eta"}; Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum track eta"}; + Configurable maxIPxy{"maxIPxy", 10, "maximum track DCA in xy plane"}; + Configurable maxIPz{"maxIPz", 10, "maximum track DCA in z direction"}; // track level configurables Configurable svPtMin{"svPtMin", 0.5, "minimum SV pT"}; @@ -109,29 +73,14 @@ struct BJetTaggingML { Configurable jetEtaMin{"jetEtaMin", -99.0, "minimum jet pseudorapidity"}; Configurable jetEtaMax{"jetEtaMax", 99.0, "maximum jet pseudorapidity"}; Configurable nJetConst{"nJetConst", 10, "maximum number of jet consistuents to be used for ML evaluation"}; + Configurable useDb{"useDb", false, "Flag whether to use the Db instead of the score for tagging"}; + Configurable callSumw2{"callSumw2", false, "Flag whether to use sum weight squared for THnSparse error calculation"}; - Configurable useQuarkDef{"useQuarkDef", true, "Flag whether to use quarks or hadrons for determining the jet flavor"}; - - Configurable svReductionFactor{"svReductionFactor", 1.0, "factor for how many SVs to keep"}; + Configurable doDataDriven{"doDataDriven", false, "Flag whether to use fill THnSpase for data driven methods"}; Configurable> jetRadii{"jetRadii", std::vector{0.4}, "jet resolution parameters"}; - Configurable> binsPtMl{"binsPtMl", std::vector{5., 1000.}, "pT bin limits for ML application"}; - Configurable> cutDirMl{"cutDirMl", std::vector{cuts_ml::CutSmaller, cuts_ml::CutNot}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {defaultCutsMl[0], 1, 2, {"pT bin 0"}, {"score for default b-jet tagging", "uncer 1"}}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", 2, "Number of classes in ML model"}; - Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; - - Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"Users/h/hahassan"}, "Paths of models on CCDB"}; - Configurable> onnxFileNames{"onnxFileNames", std::vector{"ML_bjets/01-MVA/Models/LHC23d4_5_20_90Percent/model.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; - Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; - Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; - - o2::analysis::MlResponse bMlResponse; - o2::ccdb::CcdbApi ccdbApi; - - int eventSelection = -1; + std::vector eventSelectionBits; std::vector jetRadiiValues; @@ -142,11 +91,16 @@ struct BJetTaggingML { jetRadiiValues = (std::vector)jetRadii; - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + + const AxisSpec axisDb{300, -10., 20., "#it{D}_{b}"}; + const AxisSpec axisScore{120, -0.1, 1.1, "Score"}; + const AxisSpec axisLogScore{120, 0., 30, "-log(1-score)"}; registry.add("h_vertexZ", "Vertex Z;#it{Z} (cm)", {HistType::kTH1F, {{40, -20.0, 20.0}}}); - registry.add("h2_score_jetpT", "ML scores for inclusive jets;#it{p}_{T,jet} (GeV/#it{c});Score", {HistType::kTH2F, {{200, 0., 200.}, {120, -0.1, 1.1}}}); + registry.add("h2_score_jetpT", "ML scores for inclusive jets;#it{p}_{T,jet} (GeV/#it{c});Score", {HistType::kTH2F, {{200, 0., 200.}, useDb ? axisDb : axisScore}}); + registry.add("h2_logscore_jetpT", "ML scores for inclusive jets;#it{p}_{T,jet} (GeV/#it{c});- log(1 - Score)", {HistType::kTH2F, {{200, 0., 200.}, axisLogScore}}); registry.add("h2_nTracks_jetpT", "Number of tracks;#it{p}_{T,jet} (GeV/#it{c});nTracks", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 100.0}}}); registry.add("h2_nSV_jetpT", "Number of secondary vertices;#it{p}_{T,jet} (GeV/#it{c});nSVs", {HistType::kTH2F, {{200, 0., 200.}, {250, 0, 250.0}}}); @@ -158,9 +112,19 @@ struct BJetTaggingML { registry.add("h2_jetMass_jetpT", "Jet mass;#it{p}_{T,jet} (GeV/#it{c});#it{m}_{jet} (GeV/#it{c}^{2})", {HistType::kTH2F, {{200, 0., 200.}, {50, 0, 50.0}}}); registry.add("h2_SVMass_jetpT", "Secondary vertex mass;#it{p}_{T,jet} (GeV/#it{c});#it{m}_{SV} (GeV/#it{c}^{2})", {HistType::kTH2F, {{200, 0., 200.}, {50, 0, 10}}}); - if (doprocessMCJets) { + if (doDataDriven) { + registry.add("hSparse_Incljets", "Inclusive jets Info;#it{p}_{T,jet} (GeV/#it{c});Score;-log(1-score);#it{m}_{jet} (GeV/#it{c}^{2});-log(JP);#it{m}_{SV} (GeV/#it{c}^{2});SVfE;", {HistType::kTHnSparseF, {{200, 0., 200.}, useDb ? axisDb : axisScore, axisLogScore, {50, 0, 50}, {375, 0, 30}, {50, 0, 10}, {50, 0, 1}}}, callSumw2); + if (doprocessMCJets || doprocessMCJetsWeighted) { + registry.add("hSparse_bjets", "Tagged b-jets Info;#it{p}_{T,jet} (GeV/#it{c});Score;-log(1-score);#it{m}_{jet} (GeV/#it{c}^{2});-log(JP);#it{m}_{SV} (GeV/#it{c}^{2});SVfE;", {HistType::kTHnSparseF, {{200, 0., 200.}, useDb ? axisDb : axisScore, axisLogScore, {50, 0, 50}, {375, 0, 30}, {50, 0, 10}, {50, 0, 1}}}, callSumw2); + registry.add("hSparse_cjets", "Tagged c-jets Info;#it{p}_{T,jet} (GeV/#it{c});Score;-log(1-score);#it{m}_{jet} (GeV/#it{c}^{2});-log(JP);#it{m}_{SV} (GeV/#it{c}^{2});SVfE;", {HistType::kTHnSparseF, {{200, 0., 200.}, useDb ? axisDb : axisScore, axisLogScore, {50, 0, 50}, {375, 0, 30}, {50, 0, 10}, {50, 0, 1}}}, callSumw2); + registry.add("hSparse_lfjets", "Tagged lf-jets Info;#it{p}_{T,jet} (GeV/#it{c});Score;-log(1-score);#it{m}_{jet} (GeV/#it{c}^{2});-log(JP);#it{m}_{SV} (GeV/#it{c}^{2});SVfE;", {HistType::kTHnSparseF, {{200, 0., 200.}, useDb ? axisDb : axisScore, axisLogScore, {50, 0, 50}, {375, 0, 30}, {50, 0, 10}, {50, 0, 1}}}, callSumw2); + } + } - registry.add("h2_score_jetpT_bjet", "ML scores for b-jets;#it{p}_{T,jet} (GeV/#it{c});Score", {HistType::kTH2F, {{200, 0., 200.}, {120, -0.1, 1.1}}}); + if (doprocessMCJets || doprocessMCJetsWeighted || doprocessMCTruthJets || doprocessMCTruthJetsWeighted) { + + registry.add("h2_score_jetpT_bjet", "ML scores for b-jets;#it{p}_{T,jet} (GeV/#it{c});Score", {HistType::kTH2F, {{200, 0., 200.}, useDb ? axisDb : axisScore}}); + registry.add("h2_logscore_jetpT_bjet", "ML scores for b-jets;#it{p}_{T,jet} (GeV/#it{c});- log(1 - Score)", {HistType::kTH2F, {{200, 0., 200.}, axisLogScore}}); registry.add("h2_SIPs2D_jetpT_bjet", "2D IP significance b-jets;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); registry.add("h2_SIPs3D_jetpT_bjet", "3D IP significance b-jets;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); registry.add("h2_LxyS_jetpT_bjet", "Decay length in XY b-jets;#it{p}_{T,jet} (GeV/#it{c});S#it{L}_{xy}", {HistType::kTH2F, {{200, 0., 200.}, {100, 0., 100.0}}}); @@ -168,7 +132,8 @@ struct BJetTaggingML { registry.add("h2_jetMass_jetpT_bjet", "Jet mass b-jets;#it{p}_{T,jet} (GeV/#it{c});#it{m}_{jet} (GeV/#it{c}^{2})", {HistType::kTH2F, {{200, 0., 200.}, {50, 0, 50.0}}}); registry.add("h2_SVMass_jetpT_bjet", "Secondary vertex mass b-jets;#it{p}_{T,jet} (GeV/#it{c});#it{m}_{SV} (GeV/#it{c}^{2})", {HistType::kTH2F, {{200, 0., 200.}, {50, 0, 10.0}}}); - registry.add("h2_score_jetpT_cjet", "ML scores for c-jets;#it{p}_{T,jet} (GeV/#it{c});Score", {HistType::kTH2F, {{200, 0., 200.}, {120, -0.1, 1.1}}}); + registry.add("h2_score_jetpT_cjet", "ML scores for c-jets;#it{p}_{T,jet} (GeV/#it{c});Score", {HistType::kTH2F, {{200, 0., 200.}, useDb ? axisDb : axisScore}}); + registry.add("h2_logscore_jetpT_cjet", "ML scores for c-jets;#it{p}_{T,jet} (GeV/#it{c});- log(1 - Score)", {HistType::kTH2F, {{200, 0., 200.}, axisLogScore}}); registry.add("h2_SIPs2D_jetpT_cjet", "2D IP significance c-jets;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); registry.add("h2_SIPs3D_jetpT_cjet", "3D IP significance c-jets;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); registry.add("h2_LxyS_jetpT_cjet", "Decay length in XY c-jets;#it{p}_{T,jet} (GeV/#it{c});S#it{L}_{xy}", {HistType::kTH2F, {{200, 0., 200.}, {100, 0., 100.0}}}); @@ -176,7 +141,8 @@ struct BJetTaggingML { registry.add("h2_jetMass_jetpT_cjet", "Jet mass c-jets;#it{p}_{T,jet} (GeV/#it{c});#it{m}_{jet} (GeV/#it{c}^{2})", {HistType::kTH2F, {{200, 0., 200.}, {50, 0, 50.0}}}); registry.add("h2_SVMass_jetpT_cjet", "Secondary vertex mass c-jets;#it{p}_{T,jet} (GeV/#it{c});#it{m}_{SV} (GeV/#it{c}^{2})", {HistType::kTH2F, {{200, 0., 200.}, {50, 0, 10.0}}}); - registry.add("h2_score_jetpT_lfjet", "ML scores for lf-jets;#it{p}_{T,jet} (GeV/#it{c});Score", {HistType::kTH2F, {{200, 0., 200.}, {120, -0.1, 1.1}}}); + registry.add("h2_score_jetpT_lfjet", "ML scores for lf-jets;#it{p}_{T,jet} (GeV/#it{c});Score", {HistType::kTH2F, {{200, 0., 200.}, useDb ? axisDb : axisScore}}); + registry.add("h2_logscore_jetpT_lfjet", "ML scores for lf-jets;#it{p}_{T,jet} (GeV/#it{c});- log(1 - Score)", {HistType::kTH2F, {{200, 0., 200.}, axisLogScore}}); registry.add("h2_SIPs2D_jetpT_lfjet", "2D IP significance lf-jet;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); registry.add("h2_SIPs3D_jetpT_lfjet", "3D IP significance lf-jet;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); registry.add("h2_LxyS_jetpT_lfjet", "Decay length in XY lf-jet;#it{p}_{T,jet} (GeV/#it{c});S#it{L}_{xy}", {HistType::kTH2F, {{200, 0., 200.}, {100, 0., 100.0}}}); @@ -197,20 +163,10 @@ struct BJetTaggingML { registry.add("h_jetpT_particle_cjet", "Jet transverse momentum particle level c-jets;#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); registry.add("h_jetpT_particle_lfjet", "Jet transverse momentum particle level lf-jet;#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); - registry.add("h2_Response_DetjetpT_PartjetpT_bjet", "Response matrix b-jets;#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c})", {HistType::kTH2F, {{200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h2_Response_DetjetpT_PartjetpT_cjet", "Response matrix c-jets;#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c})", {HistType::kTH2F, {{200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h2_Response_DetjetpT_PartjetpT_lfjet", "Response matrix lf-jet;#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c})", {HistType::kTH2F, {{200, 0., 200.}, {200, 0., 200.}}}); + registry.add("h2_Response_DetjetpT_PartjetpT_bjet", "Response matrix b-jets;#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c})", {HistType::kTH2F, {{200, 0., 200.}, {200, 0., 200.}}}, callSumw2); + registry.add("h2_Response_DetjetpT_PartjetpT_cjet", "Response matrix c-jets;#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c})", {HistType::kTH2F, {{200, 0., 200.}, {200, 0., 200.}}}, callSumw2); + registry.add("h2_Response_DetjetpT_PartjetpT_lfjet", "Response matrix lf-jet;#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c})", {HistType::kTH2F, {{200, 0., 200.}, {200, 0., 200.}}}, callSumw2); } - - bMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); - if (loadModelsFromCCDB) { - ccdbApi.init(ccdbUrl); - bMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); - } else { - bMlResponse.setModelPathsLocal(onnxFileNames); - } - // bMlResponse.cacheInputFeaturesIndices(namesInputFeatures); - bMlResponse.init(); } // FIXME filtering only works when you loop directly over the list, but if you loop over it as a constituent they will not be filtered @@ -219,56 +175,14 @@ struct BJetTaggingML { Filter partCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax); Filter jetFilter = (aod::jet::pt >= jetPtMin && aod::jet::pt <= jetPtMax && aod::jet::eta < jetEtaMax - aod::jet::r / 100.f && aod::jet::eta > jetEtaMin + aod::jet::r / 100.f); - using FilteredCollision = soa::Filtered>; + using FilteredCollision = soa::Filtered>; using JetTrackswID = soa::Join; using JetTracksMCDwID = soa::Join; - using DataJets = soa::Filtered>; - - std::vector> getInputsForML(bjetParams jetparams, std::vector& tracksParams, std::vector& svsParams) - { - std::vector jetInput = {jetparams.mJetpT, jetparams.mJetEta, jetparams.mJetPhi, static_cast(jetparams.mNTracks), static_cast(jetparams.mNSV), jetparams.mJetMass}; - std::vector tracksInputFlat; - std::vector svsInputFlat; - - for (int iconstit = 0; iconstit < nJetConst; iconstit++) { - - tracksInputFlat.push_back(tracksParams[iconstit].mTrackpT); - tracksInputFlat.push_back(tracksParams[iconstit].mTrackEta); - tracksInputFlat.push_back(tracksParams[iconstit].mDotProdTrackJet); - tracksInputFlat.push_back(tracksParams[iconstit].mDotProdTrackJetOverJet); - tracksInputFlat.push_back(tracksParams[iconstit].mDeltaRJetTrack); - tracksInputFlat.push_back(tracksParams[iconstit].mSignedIP2D); - tracksInputFlat.push_back(tracksParams[iconstit].mSignedIP2DSign); - tracksInputFlat.push_back(tracksParams[iconstit].mSignedIP3D); - tracksInputFlat.push_back(tracksParams[iconstit].mSignedIP3DSign); - tracksInputFlat.push_back(tracksParams[iconstit].mMomFraction); - tracksInputFlat.push_back(tracksParams[iconstit].mDeltaRTrackVertex); - - svsInputFlat.push_back(svsParams[iconstit].mSVpT); - svsInputFlat.push_back(svsParams[iconstit].mDeltaRSVJet); - svsInputFlat.push_back(svsParams[iconstit].mSVMass); - svsInputFlat.push_back(svsParams[iconstit].mSVfE); - svsInputFlat.push_back(svsParams[iconstit].mIPXY); - svsInputFlat.push_back(svsParams[iconstit].mCPA); - svsInputFlat.push_back(svsParams[iconstit].mChi2PCA); - svsInputFlat.push_back(svsParams[iconstit].mDispersion); - svsInputFlat.push_back(svsParams[iconstit].mDecayLength2D); - svsInputFlat.push_back(svsParams[iconstit].mDecayLength2DError); - svsInputFlat.push_back(svsParams[iconstit].mDecayLength3D); - svsInputFlat.push_back(svsParams[iconstit].mDecayLength3DError); - } - - std::vector> totalInput; - totalInput.push_back(jetInput); - totalInput.push_back(tracksInputFlat); - totalInput.push_back(svsInputFlat); - - return totalInput; - } + using DataJets = soa::Filtered>; // Looping over the SV info and writing them to a table - template - void analyzeJetSVInfo(AnalysisJet const& myJet, AnyTracks const& /*allTracks*/, SecondaryVertices const& /*allSVs*/, std::vector& svsParams, int jetFlavor = 0, double eventweight = 1.0) + template + void analyzeJetSVInfo(AnalysisJet const& myJet, SecondaryVertices const& /*allSVs*/, std::vector& svsParams, int8_t jetFlavor = 0, double eventweight = 1.0) { using SVType = typename SecondaryVertices::iterator; @@ -293,20 +207,20 @@ struct BJetTaggingML { double massSV = candSV.m(); double energySV = candSV.e(); - if (svsParams.size() < (svReductionFactor * myJet.template tracks_as().size())) { - svsParams.emplace_back(bjetSVParams{candSV.pt(), deltaRJetSV, massSV, energySV / myJet.energy(), candSV.impactParameterXY(), candSV.cpa(), candSV.chi2PCA(), candSV.dispersion(), candSV.decayLengthXY(), candSV.errorDecayLengthXY(), candSV.decayLength(), candSV.errorDecayLength()}); + if (static_cast(svsParams.size()) < nJetConst) { + svsParams.emplace_back(jettaggingutilities::BJetSVParams{candSV.pt(), deltaRJetSV, massSV, energySV / myJet.energy(), candSV.impactParameterXY(), candSV.cpa(), candSV.chi2PCA(), candSV.dispersion(), candSV.decayLengthXY(), candSV.errorDecayLengthXY(), candSV.decayLength(), candSV.errorDecayLength()}); } registry.fill(HIST("h2_LxyS_jetpT"), myJet.pt(), candSV.decayLengthXY() / candSV.errorDecayLengthXY(), eventweight); registry.fill(HIST("h2_Dispersion_jetpT"), myJet.pt(), candSV.dispersion(), eventweight); registry.fill(HIST("h2_SVMass_jetpT"), myJet.pt(), massSV, eventweight); - if (doprocessMCJets) { - if (jetFlavor == 2) { + if (doprocessMCJets || doprocessMCJetsWeighted) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h2_LxyS_jetpT_bjet"), myJet.pt(), candSV.decayLengthXY() / candSV.errorDecayLengthXY(), eventweight); registry.fill(HIST("h2_Dispersion_jetpT_bjet"), myJet.pt(), candSV.dispersion(), eventweight); registry.fill(HIST("h2_SVMass_jetpT_bjet"), myJet.pt(), massSV, eventweight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h2_LxyS_jetpT_cjet"), myJet.pt(), candSV.decayLengthXY() / candSV.errorDecayLengthXY(), eventweight); registry.fill(HIST("h2_Dispersion_jetpT_cjet"), myJet.pt(), candSV.dispersion(), eventweight); registry.fill(HIST("h2_SVMass_jetpT_cjet"), myJet.pt(), massSV, eventweight); @@ -317,15 +231,16 @@ struct BJetTaggingML { } } } + svsParams.resize(nJetConst); } - template - void analyzeJetTrackInfo(AnyCollision const& /*collision*/, AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, SecondaryVertices const& /*allSVs*/, std::vector& tracksParams, int jetFlavor = 0, double eventweight = 1.0) + template + void analyzeJetTrackInfo(AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, std::vector& tracksParams, int8_t jetFlavor = 0, double eventweight = 1.0) { - for (auto& constituent : analysisJet.template tracks_as()) { + for (const auto& constituent : analysisJet.template tracks_as()) { - if (constituent.pt() < trackPtMin) { + if (constituent.pt() < trackPtMin || !jettaggingutilities::trackAcceptanceWithDca(constituent, maxIPxy, maxIPz)) { continue; } @@ -333,22 +248,16 @@ struct BJetTaggingML { double dotProduct = RecoDecay::dotProd(std::array{analysisJet.px(), analysisJet.py(), analysisJet.pz()}, std::array{constituent.px(), constituent.py(), constituent.pz()}); int sign = jettaggingutilities::getGeoSign(analysisJet, constituent); - float RClosestSV = 10.; - for (const auto& candSV : analysisJet.template secondaryVertices_as()) { - double deltaRTrackSV = jetutilities::deltaR(constituent, candSV); - if (deltaRTrackSV < RClosestSV) { - RClosestSV = deltaRTrackSV; - } - } + float rClosestSV = -1.0; registry.fill(HIST("h2_SIPs2D_jetpT"), analysisJet.pt(), sign * std::abs(constituent.dcaXY()) / constituent.sigmadcaXY(), eventweight); registry.fill(HIST("h2_SIPs3D_jetpT"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); - if (doprocessMCJets) { - if (jetFlavor == 2) { + if (doprocessMCJets || doprocessMCJetsWeighted) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h2_SIPs2D_jetpT_bjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXY()) / constituent.sigmadcaXY(), eventweight); registry.fill(HIST("h2_SIPs3D_jetpT_bjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h2_SIPs2D_jetpT_cjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXY()) / constituent.sigmadcaXY(), eventweight); registry.fill(HIST("h2_SIPs3D_jetpT_cjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); } else { @@ -357,15 +266,104 @@ struct BJetTaggingML { } } - tracksParams.emplace_back(bjetTrackParams{constituent.pt(), constituent.eta(), dotProduct, dotProduct / analysisJet.p(), deltaRJetTrack, std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaXYZ()) * sign, constituent.sigmadcaXYZ(), constituent.p() / analysisJet.p(), RClosestSV}); + tracksParams.emplace_back(jettaggingutilities::BJetTrackParams{constituent.pt(), constituent.eta(), dotProduct, dotProduct / analysisJet.p(), deltaRJetTrack, std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaXYZ()) * sign, constituent.sigmadcaXYZ(), constituent.p() / analysisJet.p(), rClosestSV}); } - auto compare = [](bjetTrackParams& tr1, bjetTrackParams& tr2) { - return (tr1.mSignedIP2D / tr1.mSignedIP2DSign) > (tr2.mSignedIP2D / tr2.mSignedIP2DSign); + auto compare = [](jettaggingutilities::BJetTrackParams& tr1, jettaggingutilities::BJetTrackParams& tr2) { + return (tr1.signedIP2D / tr1.signedIP2DSign) > (tr2.signedIP2D / tr2.signedIP2DSign); }; // Sort the tracks based on their IP significance in descending order std::sort(tracksParams.begin(), tracksParams.end(), compare); + tracksParams.resize(nJetConst); + } + + template + void processJetInfo(AnalysisJet const& myJet, AnyTracks const& allTracks, SecondaryVertices const& allSVs, int8_t jetFlavor = 0, double eventWeight = 1.0) + { + std::vector tracksParams; + std::vector svsParams; + + analyzeJetSVInfo(myJet, allSVs, svsParams, jetFlavor, eventWeight); + analyzeJetTrackInfo(myJet, allTracks, tracksParams, jetFlavor, eventWeight); + + int nSVs = myJet.template secondaryVertices_as().size(); + int nTracks = myJet.template tracks_as().size(); + + registry.fill(HIST("h2_nTracks_jetpT"), myJet.pt(), nTracks); + registry.fill(HIST("h2_nSV_jetpT"), myJet.pt(), nSVs < 250 ? nSVs : 249); + + registry.fill(HIST("h2_score_jetpT"), myJet.pt(), myJet.scoreML(), eventWeight); + if (!useDb) { + registry.fill(HIST("h2_logscore_jetpT"), myJet.pt(), -1 * std::log(1 - myJet.scoreML()), eventWeight); + } + registry.fill(HIST("h2_jetMass_jetpT"), myJet.pt(), myJet.mass(), eventWeight); + + if (doDataDriven) { + registry.fill(HIST("hSparse_Incljets"), myJet.pt(), myJet.scoreML(), useDb ? 0 : -1 * std::log(1 - myJet.scoreML()), myJet.mass(), -1 * std::log(myJet.jetProb()), svsParams[0].svMass, svsParams[0].svfE, eventWeight); + if (doprocessMCJets || doprocessMCJetsWeighted) { + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("hSparse_bjets"), myJet.pt(), myJet.scoreML(), useDb ? 0 : -1 * std::log(1 - myJet.scoreML()), myJet.mass(), -1 * std::log(myJet.jetProb()), svsParams[0].svMass, svsParams[0].svfE, eventWeight); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("hSparse_cjets"), myJet.pt(), myJet.scoreML(), useDb ? 0 : -1 * std::log(1 - myJet.scoreML()), myJet.mass(), -1 * std::log(myJet.jetProb()), svsParams[0].svMass, svsParams[0].svfE, eventWeight); + } else { + registry.fill(HIST("hSparse_lfjets"), myJet.pt(), myJet.scoreML(), useDb ? 0 : -1 * std::log(1 - myJet.scoreML()), myJet.mass(), -1 * std::log(myJet.jetProb()), svsParams[0].svMass, svsParams[0].svfE, eventWeight); + } + } + } + + if (doprocessMCJets || doprocessMCJetsWeighted) { + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("h2_score_jetpT_bjet"), myJet.pt(), myJet.scoreML(), eventWeight); + if (!useDb) { + registry.fill(HIST("h2_logscore_jetpT_bjet"), myJet.pt(), -1 * std::log(1 - myJet.scoreML()), eventWeight); + } + registry.fill(HIST("h2_jetMass_jetpT_bjet"), myJet.pt(), myJet.mass(), eventWeight); + registry.fill(HIST("h_jetpT_detector_bjet"), myJet.pt(), eventWeight); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("h2_score_jetpT_cjet"), myJet.pt(), myJet.scoreML(), eventWeight); + if (!useDb) { + registry.fill(HIST("h2_logscore_jetpT_cjet"), myJet.pt(), -1 * std::log(1 - myJet.scoreML()), eventWeight); + } + registry.fill(HIST("h2_jetMass_jetpT_cjet"), myJet.pt(), myJet.mass(), eventWeight); + registry.fill(HIST("h_jetpT_detector_cjet"), myJet.pt(), eventWeight); + } else { + registry.fill(HIST("h2_score_jetpT_lfjet"), myJet.pt(), myJet.scoreML(), eventWeight); + if (!useDb) { + registry.fill(HIST("h2_logscore_jetpT_lfjet"), myJet.pt(), -1 * std::log(1 - myJet.scoreML()), eventWeight); + } + registry.fill(HIST("h2_jetMass_jetpT_lfjet"), myJet.pt(), myJet.mass(), eventWeight); + registry.fill(HIST("h_jetpT_detector_lfjet"), myJet.pt(), eventWeight); + } + } + } + + template + void fillMCPHistograms(AnalysisJetMCP const& mcpjet, bool detColl = false, double eventWeight = 1.0) + { + int8_t jetFlavor = mcpjet.origin(); + + if (detColl) { + + registry.fill(HIST("h_jetpT_particle_DetColl"), mcpjet.pt(), eventWeight); + + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("h_jetpT_particle_DetColl_bjet"), mcpjet.pt(), eventWeight); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("h_jetpT_particle_DetColl_cjet"), mcpjet.pt(), eventWeight); + } else { + registry.fill(HIST("h_jetpT_particle_DetColl_lfjet"), mcpjet.pt(), eventWeight); + } + } else { + + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("h_jetpT_particle_bjet"), mcpjet.pt(), eventWeight); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("h_jetpT_particle_cjet"), mcpjet.pt(), eventWeight); + } else { + registry.fill(HIST("h_jetpT_particle_lfjet"), mcpjet.pt(), eventWeight); + } + } } void processDummy(FilteredCollision::iterator const& /*collision*/) @@ -375,7 +373,7 @@ struct BJetTaggingML { void processDataJets(FilteredCollision::iterator const& collision, DataJets const& alljets, JetTrackswID const& allTracks, aod::DataSecondaryVertex3Prongs const& allSVs) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } @@ -384,7 +382,7 @@ struct BJetTaggingML { for (const auto& analysisJet : alljets) { bool jetIncluded = false; - for (auto jetR : jetRadiiValues) { + for (const auto& jetR : jetRadiiValues) { if (analysisJet.r() == static_cast(jetR * 100)) { jetIncluded = true; break; @@ -395,56 +393,31 @@ struct BJetTaggingML { continue; } - std::vector tracksParams; - std::vector SVsParams; - - analyzeJetSVInfo(analysisJet, allTracks, allSVs, SVsParams); - analyzeJetTrackInfo(collision, analysisJet, allTracks, allSVs, tracksParams); - - int nSVs = analysisJet.template secondaryVertices_as().size(); - - registry.fill(HIST("h2_nTracks_jetpT"), analysisJet.pt(), tracksParams.size()); - registry.fill(HIST("h2_nSV_jetpT"), analysisJet.pt(), nSVs < 250 ? nSVs : 249); - - bjetParams jetparam = {analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), static_cast(tracksParams.size()), static_cast(nSVs), analysisJet.mass()}; - tracksParams.resize(nJetConst); // resize to the number of inputs of the ML - SVsParams.resize(nJetConst); // resize to the number of inputs of the ML - - auto inputML = getInputsForML(jetparam, tracksParams, SVsParams); - - std::vector output; - // bool isSelectedMl = bMlResponse.isSelectedMl(inputML, analysisJet.pt(), output); - bMlResponse.isSelectedMl(inputML, analysisJet.pt(), output); - - registry.fill(HIST("h2_score_jetpT"), analysisJet.pt(), output[0]); - - registry.fill(HIST("h2_jetMass_jetpT"), analysisJet.pt(), analysisJet.mass()); + processJetInfo(analysisJet, allTracks, allSVs); } } PROCESS_SWITCH(BJetTaggingML, processDataJets, "jet information in Data", false); - using MCDJetTable = soa::Filtered>; - using MCPJetTable = soa::Filtered>; - using FilteredCollisionMCD = soa::Filtered>; + using MCDJetTableWeighted = soa::Filtered>; + using MCPJetTableWeighted = soa::Filtered>; + using FilteredCollisionMCD = soa::Filtered>; - Preslice McParticlesPerCollision = aod::jmcparticle::mcCollisionId; - Preslice McPJetsPerCollision = aod::jet::mcCollisionId; + Preslice mcpJetsPerCollisionWeighted = aod::jet::mcCollisionId; - void processMCJets(FilteredCollisionMCD::iterator const& collision, MCDJetTable const& MCDjets, MCPJetTable const& MCPjets, JetTracksMCDwID const& allTracks, aod::JetParticles const& MCParticles, aod::MCDSecondaryVertex3Prongs const& allSVs) + void processMCJetsWeighted(FilteredCollisionMCD::iterator const& collision, MCDJetTableWeighted const& MCDjets, MCPJetTableWeighted const& MCPjets, JetTracksMCDwID const& allTracks, aod::JetParticles const& /*MCParticles*/, aod::MCDSecondaryVertex3Prongs const& allSVs) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_vertexZ"), collision.posZ()); - auto const mcParticlesPerColl = MCParticles.sliceBy(McParticlesPerCollision, collision.mcCollisionId()); - auto const mcPJetsPerColl = MCPjets.sliceBy(McPJetsPerCollision, collision.mcCollisionId()); + auto const mcPJetsPerColl = MCPjets.sliceBy(mcpJetsPerCollisionWeighted, collision.mcCollisionId()); for (const auto& analysisJet : MCDjets) { bool jetIncluded = false; - for (auto jetR : jetRadiiValues) { + for (const auto& jetR : jetRadiiValues) { if (analysisJet.r() == static_cast(jetR * 100)) { jetIncluded = true; break; @@ -455,69 +428,24 @@ struct BJetTaggingML { continue; } - float eventWeight = useEventWeight ? analysisJet.eventWeight() : 1.0; + float eventWeight = analysisJet.eventWeight(); float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); if (analysisJet.pt() > pTHatMaxMCD * pTHat) { continue; } - std::vector tracksParams; - std::vector SVsParams; - - int jetFlavor = 0; - - for (auto& mcpjet : analysisJet.template matchedJetGeo_as()) { - if (useQuarkDef) { - jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, mcParticlesPerColl); - } else { - jetFlavor = jettaggingutilities::getJetFlavorHadron(mcpjet, mcParticlesPerColl); - } - } - - analyzeJetSVInfo(analysisJet, allTracks, allSVs, SVsParams, jetFlavor, eventWeight); - analyzeJetTrackInfo(collision, analysisJet, allTracks, allSVs, tracksParams, jetFlavor, eventWeight); - - int nSVs = analysisJet.template secondaryVertices_as().size(); + int jetFlavor = analysisJet.origin(); - registry.fill(HIST("h2_nTracks_jetpT"), analysisJet.pt(), tracksParams.size()); - registry.fill(HIST("h2_nSV_jetpT"), analysisJet.pt(), nSVs < 250 ? nSVs : 249); + processJetInfo(analysisJet, allTracks, allSVs, jetFlavor, eventWeight); - bjetParams jetparam = {analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), static_cast(tracksParams.size()), static_cast(nSVs), analysisJet.mass()}; - tracksParams.resize(nJetConst); // resize to the number of inputs of the ML - SVsParams.resize(nJetConst); // resize to the number of inputs of the ML - - auto inputML = getInputsForML(jetparam, tracksParams, SVsParams); - - std::vector output; - // bool isSelectedMl = bMlResponse.isSelectedMl(inputML, analysisJet.pt(), output); - bMlResponse.isSelectedMl(inputML, analysisJet.pt(), output); - - registry.fill(HIST("h2_score_jetpT"), analysisJet.pt(), output[0], eventWeight); - - registry.fill(HIST("h2_jetMass_jetpT"), analysisJet.pt(), analysisJet.mass(), eventWeight); - - if (jetFlavor == 2) { - registry.fill(HIST("h2_score_jetpT_bjet"), analysisJet.pt(), output[0], eventWeight); - registry.fill(HIST("h2_jetMass_jetpT_bjet"), analysisJet.pt(), analysisJet.mass(), eventWeight); - registry.fill(HIST("h_jetpT_detector_bjet"), analysisJet.pt(), eventWeight); - } else if (jetFlavor == 1) { - registry.fill(HIST("h2_score_jetpT_cjet"), analysisJet.pt(), output[0], eventWeight); - registry.fill(HIST("h2_jetMass_jetpT_cjet"), analysisJet.pt(), analysisJet.mass(), eventWeight); - registry.fill(HIST("h_jetpT_detector_cjet"), analysisJet.pt(), eventWeight); - } else { - registry.fill(HIST("h2_score_jetpT_lfjet"), analysisJet.pt(), output[0], eventWeight); - registry.fill(HIST("h2_jetMass_jetpT_lfjet"), analysisJet.pt(), analysisJet.mass(), eventWeight); - registry.fill(HIST("h_jetpT_detector_lfjet"), analysisJet.pt(), eventWeight); - } - - for (auto& mcpjet : analysisJet.template matchedJetGeo_as()) { + for (const auto& mcpjet : analysisJet.template matchedJetGeo_as()) { if (mcpjet.pt() > pTHatMaxMCP * pTHat) { continue; } - if (jetFlavor == 2) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_bjet"), analysisJet.pt(), mcpjet.pt(), eventWeight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_cjet"), analysisJet.pt(), mcpjet.pt(), eventWeight); } else { registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_lfjet"), analysisJet.pt(), mcpjet.pt(), eventWeight); @@ -529,7 +457,7 @@ struct BJetTaggingML { for (const auto& mcpjet : mcPJetsPerColl) { bool jetIncluded = false; - for (auto jetR : jetRadiiValues) { + for (const auto& jetR : jetRadiiValues) { if (mcpjet.r() == static_cast(jetR * 100)) { jetIncluded = true; break; @@ -540,43 +468,91 @@ struct BJetTaggingML { continue; } - float eventWeight = useEventWeight ? mcpjet.eventWeight() : 1.0; + float eventWeight = mcpjet.eventWeight(); float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); if (mcpjet.pt() > pTHatMaxMCP * pTHat) { continue; } - int8_t jetFlavor = 0; + fillMCPHistograms(mcpjet, true, eventWeight); + } + } + PROCESS_SWITCH(BJetTaggingML, processMCJetsWeighted, "jet information in MC with event weight", false); - if (useQuarkDef) { - jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, mcParticlesPerColl); - } else { - jetFlavor = jettaggingutilities::getJetFlavorHadron(mcpjet, mcParticlesPerColl); + using MCDJetTable = soa::Filtered>; + using MCPJetTable = soa::Filtered>; + + Preslice mcpJetsPerCollision = aod::jet::mcCollisionId; + + void processMCJets(FilteredCollisionMCD::iterator const& collision, MCDJetTable const& MCDjets, MCPJetTable const& MCPjets, JetTracksMCDwID const& allTracks, aod::JetParticles const& /*MCParticles*/, aod::MCDSecondaryVertex3Prongs const& allSVs) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + + registry.fill(HIST("h_vertexZ"), collision.posZ()); + + auto const mcPJetsPerColl = MCPjets.sliceBy(mcpJetsPerCollision, collision.mcCollisionId()); + + for (const auto& analysisJet : MCDjets) { + + bool jetIncluded = false; + for (const auto& jetR : jetRadiiValues) { + if (analysisJet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } } - registry.fill(HIST("h_jetpT_particle_DetColl"), mcpjet.pt(), eventWeight); + if (!jetIncluded) { + continue; + } - if (jetFlavor == 2) { - registry.fill(HIST("h_jetpT_particle_DetColl_bjet"), mcpjet.pt(), eventWeight); - } else if (jetFlavor == 1) { - registry.fill(HIST("h_jetpT_particle_DetColl_cjet"), mcpjet.pt(), eventWeight); - } else { - registry.fill(HIST("h_jetpT_particle_DetColl_lfjet"), mcpjet.pt(), eventWeight); + int jetFlavor = analysisJet.origin(); + + processJetInfo(analysisJet, allTracks, allSVs, jetFlavor); + + for (const auto& mcpjet : analysisJet.template matchedJetGeo_as()) { + if (jetFlavor == JetTaggingSpecies::beauty) { + registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_bjet"), analysisJet.pt(), mcpjet.pt()); + } else if (jetFlavor == JetTaggingSpecies::charm) { + registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_cjet"), analysisJet.pt(), mcpjet.pt()); + } else { + registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_lfjet"), analysisJet.pt(), mcpjet.pt()); + } + } + } + + // For filling histograms used for the jet matching efficiency + for (const auto& mcpjet : mcPJetsPerColl) { + + bool jetIncluded = false; + for (const auto& jetR : jetRadiiValues) { + if (mcpjet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } + } + + if (!jetIncluded) { + continue; } + + fillMCPHistograms(mcpjet, true); } } - PROCESS_SWITCH(BJetTaggingML, processMCJets, "jet information in MC", false); + PROCESS_SWITCH(BJetTaggingML, processMCJets, "jet information in MC without event weight", false); Filter mccollisionFilter = nabs(aod::jmccollision::posZ) < vertexZCut; - using FilteredCollisionMCP = soa::Filtered; + using FilteredCollisionMCP = soa::Filtered; - void processMCTruthJets(FilteredCollisionMCP::iterator const& /*collision*/, MCPJetTable const& MCPjets, aod::JetParticles const& MCParticles) + void processMCTruthJetsWeighted(FilteredCollisionMCP::iterator const& /*collision*/, MCPJetTableWeighted const& MCPjets, aod::JetParticles const& /*MCParticles*/) { for (const auto& mcpjet : MCPjets) { bool jetIncluded = false; - for (auto jetR : jetRadiiValues) { + for (const auto& jetR : jetRadiiValues) { if (mcpjet.r() == static_cast(jetR * 100)) { jetIncluded = true; break; @@ -587,33 +563,41 @@ struct BJetTaggingML { continue; } - float eventWeight = useEventWeight ? mcpjet.eventWeight() : 1.0; + float eventWeight = mcpjet.eventWeight(); float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); if (mcpjet.pt() > pTHatMaxMCP * pTHat) { continue; } - int8_t jetFlavor = 0; + fillMCPHistograms(mcpjet, false, eventWeight); + } + } + PROCESS_SWITCH(BJetTaggingML, processMCTruthJetsWeighted, "truth jet information with event weight", false); - if (useQuarkDef) { - jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, MCParticles); - } else { - jetFlavor = jettaggingutilities::getJetFlavorHadron(mcpjet, MCParticles); + void processMCTruthJets(FilteredCollisionMCP::iterator const& /*collision*/, MCPJetTable const& MCPjets, aod::JetParticles const& /*MCParticles*/) + { + + for (const auto& mcpjet : MCPjets) { + + bool jetIncluded = false; + for (const auto& jetR : jetRadiiValues) { + if (mcpjet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } } - if (jetFlavor == 2) { - registry.fill(HIST("h_jetpT_particle_bjet"), mcpjet.pt(), eventWeight); - } else if (jetFlavor == 1) { - registry.fill(HIST("h_jetpT_particle_cjet"), mcpjet.pt(), eventWeight); - } else { - registry.fill(HIST("h_jetpT_particle_lfjet"), mcpjet.pt(), eventWeight); + if (!jetIncluded) { + continue; } + + fillMCPHistograms(mcpjet); } } - PROCESS_SWITCH(BJetTaggingML, processMCTruthJets, "truth jet information", false); + PROCESS_SWITCH(BJetTaggingML, processMCTruthJets, "truth jet information without event weight", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"bjet-tagging-ml"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"bjet-tagging-ml"})}; // o2-linter: disable=name/o2-task,name/workflow-file } diff --git a/PWGJE/Tasks/bjetTreeCreator.cxx b/PWGJE/Tasks/bjetTreeCreator.cxx index 6f9fe6a85b1..103de117469 100644 --- a/PWGJE/Tasks/bjetTreeCreator.cxx +++ b/PWGJE/Tasks/bjetTreeCreator.cxx @@ -15,30 +15,39 @@ /// /// \author Hadi Hassan , University of Jyväskylä -#include -#include -#include -#include - -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoA.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFinder.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" #include "PWGJE/Core/JetTaggingUtilities.h" +#include "PWGJE/Core/JetUtilities.h" #include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" #include "PWGJE/DataModel/JetTagging.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -82,7 +91,8 @@ DECLARE_SOA_COLUMN(DotProdTrackJetOverJet, trackdotjetoverjet, float); //! The d DECLARE_SOA_COLUMN(DeltaRJetTrack, rjettrack, float); //! The DR jet-track DECLARE_SOA_COLUMN(SignedIP2D, ip2d, float); //! The track signed 2D IP DECLARE_SOA_COLUMN(SignedIP2DSign, ip2dsigma, float); //! The track signed 2D IP significance -DECLARE_SOA_COLUMN(SignedIP3D, ip3d, float); //! The track signed 3D IP +DECLARE_SOA_COLUMN(SignedIPz, ipz, float); //! The track signed z IP +DECLARE_SOA_COLUMN(SignedIPzSign, ipzsigma, float); //! The track signed z IP significance DECLARE_SOA_COLUMN(SignedIP3DSign, ip3dsigma, float); //! The track signed 3D IP significance DECLARE_SOA_COLUMN(MomFraction, momfraction, float); //! The track momentum fraction of the jets DECLARE_SOA_COLUMN(DeltaRTrackVertex, rtrackvertex, float); //! DR between the track and the closest SV, to be decided whether to add to or not @@ -108,7 +118,8 @@ DECLARE_SOA_TABLE(bjetTracksParams, "AOD", "BJETTRACKSPARAM", trackInfo::DeltaRJetTrack, trackInfo::SignedIP2D, trackInfo::SignedIP2DSign, - trackInfo::SignedIP3D, + trackInfo::SignedIPz, + trackInfo::SignedIPzSign, trackInfo::SignedIP3DSign, trackInfo::MomFraction, trackInfo::DeltaRTrackVertex); @@ -205,6 +216,9 @@ struct BJetTreeCreator { Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track eta"}; Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum track eta"}; + Configurable maxIPxy{"maxIPxy", 10, "maximum track DCA in xy plane"}; + Configurable maxIPz{"maxIPz", 10, "maximum track DCA in z direction"}; + Configurable useQuarkDef{"useQuarkDef", true, "Flag whether to use quarks or hadrons for determining the jet flavor"}; // track level configurables @@ -227,7 +241,7 @@ struct BJetTreeCreator { Configurable vtxRes{"vtxRes", 0.01, "Vertex position resolution (cluster size) for GNN vertex predictions (cm)"}; - int eventSelection = -1; + std::vector eventSelectionBits; std::vector jetRadiiValues; std::vector jetPtBinsReduction; @@ -242,7 +256,7 @@ struct BJetTreeCreator { jetPtBinsReduction = (std::vector)jetPtBins; jetReductionFactorsPt = (std::vector)jetReductionFactors; - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); registry.add("h_vertexZ", "Vertex Z;#it{Z} (cm)", {HistType::kTH1F, {{40, -20.0, 20.0}}}); @@ -295,20 +309,20 @@ struct BJetTreeCreator { //+jet registry.add("h_jet_pt", "jet_pt;#it{p}_{T}^{ch jet} (GeV/#it{c});Entries", {HistType::kTH1F, {{200, 0., 200.}}}); registry.add("h_jet_eta", "jet_eta;#it{#eta}_{ch jet};Entries", {HistType::kTH1F, {{200, -2., 2.}}}); - registry.add("h_jet_phi", "jet_phi;#it{#phi}_{ch jet};Entries", {HistType::kTH1F, {{200, 0., 2. * M_PI}}}); + registry.add("h_jet_phi", "jet_phi;#it{#phi}_{ch jet};Entries", {HistType::kTH1F, {{200, 0., o2::constants::math::TwoPI}}}); registry.add("h_jet_flav", "jet_flav;jet flavor;Entries", {HistType::kTH1F, {{4, 0., 4.}}}); registry.add("h_n_trks", "n_trks;#it{n}_{tracks};Entries", {HistType::kTH1F, {{50, 0., 50.}}}); registry.add("h_jet_mass", "jet_mass;#it{m}_{jet} (GeV/#it{c}^2);Entries", {HistType::kTH1F, {{200, 0., 50.}}}); - auto h_jet_flav = registry.get(HIST("h_jet_flav")); - h_jet_flav->GetXaxis()->SetBinLabel(1, "no mcparticle"); // 0 - h_jet_flav->GetXaxis()->SetBinLabel(2, "c-jet"); // 1 - h_jet_flav->GetXaxis()->SetBinLabel(3, "b-jet"); // 2 - h_jet_flav->GetXaxis()->SetBinLabel(4, "lf-jet"); // 3 + auto hJetFlavor = registry.get(HIST("h_jet_flav")); + hJetFlavor->GetXaxis()->SetBinLabel(1, "no mcparticle"); // 0 + hJetFlavor->GetXaxis()->SetBinLabel(2, "c-jet"); // 1 + hJetFlavor->GetXaxis()->SetBinLabel(3, "b-jet"); // 2 + hJetFlavor->GetXaxis()->SetBinLabel(4, "lf-jet"); // 3 registry.add("h_n_vertices", "n_vertices;#it{n}_{vertex};Entries", {HistType::kTH1F, {{50, 0., 50.}}}); //+trk registry.add("h_trk_pt", "trk_pt;#it{p}_{T} (GeV/#it{c});Entries", {HistType::kTH1F, {{200, 0., 100.}}}); registry.add("h_trk_eta", "trk_eta;#it{#eta};Entries", {HistType::kTH1F, {{200, -2., 2.}}}); - registry.add("h_trk_phi", "trk_phi;#it{#phi};Entries", {HistType::kTH1F, {{200, 0., 2. * M_PI}}}); + registry.add("h_trk_phi", "trk_phi;#it{#phi};Entries", {HistType::kTH1F, {{200, 0., o2::constants::math::TwoPI}}}); registry.add("h_trk_charge", "trk_charge;#it{q};Entries", {HistType::kTH1F, {{3, -1.5, 1.5}}}); registry.add("h_trk_dcaxy", "trk_dcaxy;#it{DCA}_{xy} (cm);Entries", {HistType::kTH1F, {{200, -0.1, 0.1}}}); registry.add("h_trk_dcaxyz", "trk_dcaxyz;#it{DCA}_{xyz} (cm);Entries", {HistType::kTH1F, {{200, -0.1, 0.1}}}); @@ -322,12 +336,12 @@ struct BJetTreeCreator { registry.add("h2_trk_jtrackpt_vs_origtrackpt", "JTracks::pt vs Tracks::pt", {HistType::kTH2F, {{200, 0., 100.}, {200, 0., 100.}}}); registry.add("h_trk_vtx_index", "trk_vtx_index;Vertex index;Entries", {HistType::kTH1F, {{20, 0., 20.}}}); registry.add("h_trk_origin", "trk_origin;Track origin;Entries", {HistType::kTH1F, {{5, 0., 5.}}}); - auto h_trk_origin = registry.get(HIST("h_trk_origin")); - h_trk_origin->GetXaxis()->SetBinLabel(1, "NotPhysPrim"); - h_trk_origin->GetXaxis()->SetBinLabel(2, "Charm"); - h_trk_origin->GetXaxis()->SetBinLabel(3, "Beauty"); - h_trk_origin->GetXaxis()->SetBinLabel(4, "Primary"); - h_trk_origin->GetXaxis()->SetBinLabel(5, "OtherSecondary"); + auto hTrackOrigin = registry.get(HIST("h_trk_origin")); + hTrackOrigin->GetXaxis()->SetBinLabel(1, "NotPhysPrim"); + hTrackOrigin->GetXaxis()->SetBinLabel(2, "Charm"); + hTrackOrigin->GetXaxis()->SetBinLabel(3, "Beauty"); + hTrackOrigin->GetXaxis()->SetBinLabel(4, "Primary"); + hTrackOrigin->GetXaxis()->SetBinLabel(5, "OtherSecondary"); } } @@ -337,7 +351,7 @@ struct BJetTreeCreator { Filter partCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax); Filter jetFilter = (aod::jet::pt >= jetPtMin && aod::jet::pt <= jetPtMax && aod::jet::eta < jetEtaMax - aod::jet::r / 100.f && aod::jet::eta > jetEtaMin + aod::jet::r / 100.f); - using FilteredCollision = soa::Filtered>; + using FilteredCollision = soa::Filtered>; using JetTrackswID = soa::Filtered>; using JetTracksMCDwID = soa::Filtered>; using DataJets = soa::Filtered>; @@ -402,11 +416,11 @@ struct BJetTreeCreator { registry.fill(HIST("h2_SVMass_jetpT"), myJet.pt(), massSV, eventweight); if (doprocessMCJets) { - if (jetFlavor == 2) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h2_LxyS_jetpT_bjet"), myJet.pt(), candSV.decayLengthXY() / candSV.errorDecayLengthXY(), eventweight); registry.fill(HIST("h2_Dispersion_jetpT_bjet"), myJet.pt(), candSV.chi2PCA(), eventweight); registry.fill(HIST("h2_SVMass_jetpT_bjet"), myJet.pt(), massSV, eventweight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h2_LxyS_jetpT_cjet"), myJet.pt(), candSV.decayLengthXY() / candSV.errorDecayLengthXY(), eventweight); registry.fill(HIST("h2_Dispersion_jetpT_cjet"), myJet.pt(), candSV.chi2PCA(), eventweight); registry.fill(HIST("h2_SVMass_jetpT_cjet"), myJet.pt(), massSV, eventweight); @@ -425,9 +439,9 @@ struct BJetTreeCreator { void analyzeJetTrackInfo(AnyCollision const& /*collision*/, AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, SecondaryVertices const& /*allSVs*/, std::vector& trackIndices, int jetFlavor = 0, double eventweight = 1.0) { - for (auto& constituent : analysisJet.template tracks_as()) { + for (const auto& constituent : analysisJet.template tracks_as()) { - if (constituent.pt() < trackPtMin) { + if (constituent.pt() < trackPtMin || !jettaggingutilities::trackAcceptanceWithDca(constituent, maxIPxy, maxIPz)) { continue; } @@ -435,11 +449,11 @@ struct BJetTreeCreator { double dotProduct = RecoDecay::dotProd(std::array{analysisJet.px(), analysisJet.py(), analysisJet.pz()}, std::array{constituent.px(), constituent.py(), constituent.pz()}); int sign = jettaggingutilities::getGeoSign(analysisJet, constituent); - float RClosestSV = 10.; + float dRClosestSV = 10.; for (const auto& candSV : analysisJet.template secondaryVertices_as()) { double deltaRTrackSV = jetutilities::deltaR(constituent, candSV); - if (deltaRTrackSV < RClosestSV) { - RClosestSV = deltaRTrackSV; + if (deltaRTrackSV < dRClosestSV) { + dRClosestSV = deltaRTrackSV; } } @@ -447,10 +461,10 @@ struct BJetTreeCreator { registry.fill(HIST("h2_SIPs3D_jetpT"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); if (doprocessMCJets) { - if (jetFlavor == 2) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h2_SIPs2D_jetpT_bjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXY()) / constituent.sigmadcaXY(), eventweight); registry.fill(HIST("h2_SIPs3D_jetpT_bjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h2_SIPs2D_jetpT_cjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXY()) / constituent.sigmadcaXY(), eventweight); registry.fill(HIST("h2_SIPs3D_jetpT_cjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); } else { @@ -460,7 +474,7 @@ struct BJetTreeCreator { } if (produceTree) { - bjetTracksParamsTable(bjetParamsTable.lastIndex() + 1, constituent.pt(), constituent.eta(), dotProduct, dotProduct / analysisJet.p(), deltaRJetTrack, std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaXYZ()) * sign, constituent.sigmadcaXYZ(), constituent.p() / analysisJet.p(), RClosestSV); + bjetTracksParamsTable(bjetParamsTable.lastIndex() + 1, constituent.pt(), constituent.eta(), dotProduct, dotProduct / analysisJet.p(), deltaRJetTrack, std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaZ()) * sign, constituent.sigmadcaZ(), constituent.sigmadcaXYZ(), constituent.p() / analysisJet.p(), dRClosestSV); } trackIndices.push_back(bjetTracksParamsTable.lastIndex()); } @@ -470,7 +484,7 @@ struct BJetTreeCreator { void analyzeJetTrackInfoForGNN(AnyCollision const& /*collision*/, AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, AnyOriginalTracks const&, std::vector& trackIndices, int jetFlavor = 0, double eventweight = 1.0, TrackLabelMap* trkLabels = nullptr) { int trkIdx = -1; - for (auto& constituent : analysisJet.template tracks_as()) { + for (const auto& constituent : analysisJet.template tracks_as()) { trkIdx++; @@ -486,10 +500,10 @@ struct BJetTreeCreator { registry.fill(HIST("h2_SIPs3D_jetpT"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); if (doprocessMCJetsForGNN) { - if (jetFlavor == 2) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h2_SIPs2D_jetpT_bjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXY()) / constituent.sigmadcaXY(), eventweight); registry.fill(HIST("h2_SIPs3D_jetpT_bjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h2_SIPs2D_jetpT_cjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXY()) / constituent.sigmadcaXY(), eventweight); registry.fill(HIST("h2_SIPs3D_jetpT_cjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); } else { @@ -531,7 +545,7 @@ struct BJetTreeCreator { } if (produceTree) { - bjetTracksParamsTable(bjetParamsTable.lastIndex() + 1, constituent.pt(), constituent.eta(), dotProduct, dotProduct / analysisJet.p(), deltaRJetTrack, std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaXYZ()) * sign, constituent.sigmadcaXYZ(), constituent.p() / analysisJet.p(), 0.); + bjetTracksParamsTable(bjetParamsTable.lastIndex() + 1, constituent.pt(), constituent.eta(), dotProduct, dotProduct / analysisJet.p(), deltaRJetTrack, std::abs(constituent.dcaXY()) * sign, constituent.sigmadcaXY(), std::abs(constituent.dcaZ()) * sign, constituent.sigmadcaZ(), constituent.sigmadcaXYZ(), constituent.p() / analysisJet.p(), 0.); } trackIndices.push_back(bjetTracksParamsTable.lastIndex()); } @@ -544,7 +558,7 @@ struct BJetTreeCreator { void processDataJets(FilteredCollision::iterator const& collision, DataJets const& alljets, JetTrackswID const& allTracks, aod::DataSecondaryVertex3Prongs const& allSVs) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || (static_cast(std::rand()) / RAND_MAX < eventReductionFactor)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || (static_cast(std::rand()) / RAND_MAX < eventReductionFactor)) { return; } @@ -553,7 +567,7 @@ struct BJetTreeCreator { for (const auto& analysisJet : alljets) { bool jetIncluded = false; - for (auto jetR : jetRadiiValues) { + for (const auto& jetR : jetRadiiValues) { if (analysisJet.r() == static_cast(jetR * 100)) { jetIncluded = true; break; @@ -568,22 +582,22 @@ struct BJetTreeCreator { continue; } - std::vector tracksIndices; - std::vector SVsIndices; + std::vector indicesTracks; + std::vector indicesSVs; - analyzeJetSVInfo(analysisJet, allTracks, allSVs, SVsIndices); - analyzeJetTrackInfo(collision, analysisJet, allTracks, allSVs, tracksIndices); + analyzeJetSVInfo(analysisJet, allTracks, allSVs, indicesSVs); + analyzeJetTrackInfo(collision, analysisJet, allTracks, allSVs, indicesTracks); registry.fill(HIST("h2_jetMass_jetpT"), analysisJet.pt(), analysisJet.mass()); int nSVs = analysisJet.template secondaryVertices_as().size(); - registry.fill(HIST("h2_nTracks_jetpT"), analysisJet.pt(), tracksIndices.size()); + registry.fill(HIST("h2_nTracks_jetpT"), analysisJet.pt(), indicesTracks.size()); registry.fill(HIST("h2_nSV_jetpT"), analysisJet.pt(), nSVs < 250 ? nSVs : 249); if (produceTree) { - bjetConstituentsTable(bjetParamsTable.lastIndex() + 1, tracksIndices, SVsIndices); - bjetParamsTable(analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), tracksIndices.size(), nSVs, analysisJet.mass(), 0, analysisJet.r()); + bjetConstituentsTable(bjetParamsTable.lastIndex() + 1, indicesTracks, indicesSVs); + bjetParamsTable(analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), indicesTracks.size(), nSVs, analysisJet.mass(), 0, analysisJet.r()); } } } @@ -591,26 +605,26 @@ struct BJetTreeCreator { using MCDJetTable = soa::Filtered>; using MCPJetTable = soa::Filtered>; - using FilteredCollisionMCD = soa::Filtered>; + using FilteredCollisionMCD = soa::Filtered>; - Preslice McParticlesPerCollision = aod::jmcparticle::mcCollisionId; - Preslice McPJetsPerCollision = aod::jet::mcCollisionId; + Preslice mcParticlesPerCollision = aod::jmcparticle::mcCollisionId; + Preslice mcpJetsPerCollision = aod::jet::mcCollisionId; void processMCJets(FilteredCollisionMCD::iterator const& collision, MCDJetTable const& MCDjets, MCPJetTable const& MCPjets, JetTracksMCDwID const& allTracks, aod::JetParticles const& MCParticles, aod::MCDSecondaryVertex3Prongs const& allSVs) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || (static_cast(std::rand()) / RAND_MAX < eventReductionFactor)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || (static_cast(std::rand()) / RAND_MAX < eventReductionFactor)) { return; } registry.fill(HIST("h_vertexZ"), collision.posZ()); - auto const mcParticlesPerColl = MCParticles.sliceBy(McParticlesPerCollision, collision.mcCollisionId()); - auto const mcPJetsPerColl = MCPjets.sliceBy(McPJetsPerCollision, collision.mcCollisionId()); + auto const mcParticlesPerColl = MCParticles.sliceBy(mcParticlesPerCollision, collision.mcCollisionId()); + auto const mcPJetsPerColl = MCPjets.sliceBy(mcpJetsPerCollision, collision.mcCollisionId()); for (const auto& analysisJet : MCDjets) { bool jetIncluded = false; - for (auto jetR : jetRadiiValues) { + for (const auto& jetR : jetRadiiValues) { if (analysisJet.r() == static_cast(jetR * 100)) { jetIncluded = true; break; @@ -627,8 +641,8 @@ struct BJetTreeCreator { continue; } - std::vector tracksIndices; - std::vector SVsIndices; + std::vector indicesTracks; + std::vector indicesSVs; int16_t jetFlavor = 0; @@ -636,7 +650,7 @@ struct BJetTreeCreator { // jetFlavor = jettaggingutilities::mcdJetFromHFShower(analysisJet, allTracks, mcParticlesPerColl, (float)(analysisJet.r() / 100.)); // jetFlavor = jettaggingutilities::jetTrackFromHFShower(analysisJet, nonFilteredTracks, mcParticlesPerColl, hftrack); - for (auto& mcpjet : analysisJet.template matchedJetGeo_as()) { + for (const auto& mcpjet : analysisJet.template matchedJetGeo_as()) { if (useQuarkDef) { jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, mcParticlesPerColl); } else { @@ -649,20 +663,20 @@ struct BJetTreeCreator { continue; } - analyzeJetSVInfo(analysisJet, allTracks, allSVs, SVsIndices, jetFlavor, eventWeight); - analyzeJetTrackInfo(collision, analysisJet, allTracks, allSVs, tracksIndices, jetFlavor, eventWeight); + analyzeJetSVInfo(analysisJet, allTracks, allSVs, indicesSVs, jetFlavor, eventWeight); + analyzeJetTrackInfo(collision, analysisJet, allTracks, allSVs, indicesTracks, jetFlavor, eventWeight); int nSVs = analysisJet.template secondaryVertices_as().size(); registry.fill(HIST("h2_jetMass_jetpT"), analysisJet.pt(), analysisJet.mass(), eventWeight); - registry.fill(HIST("h2_nTracks_jetpT"), analysisJet.pt(), tracksIndices.size()); + registry.fill(HIST("h2_nTracks_jetpT"), analysisJet.pt(), indicesTracks.size()); registry.fill(HIST("h2_nSV_jetpT"), analysisJet.pt(), nSVs < 250 ? nSVs : 249); - if (jetFlavor == 2) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h2_jetMass_jetpT_bjet"), analysisJet.pt(), analysisJet.mass(), eventWeight); registry.fill(HIST("h_jetpT_detector_bjet"), analysisJet.pt(), eventWeight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h2_jetMass_jetpT_cjet"), analysisJet.pt(), analysisJet.mass(), eventWeight); registry.fill(HIST("h_jetpT_detector_cjet"), analysisJet.pt(), eventWeight); } else { @@ -670,15 +684,15 @@ struct BJetTreeCreator { registry.fill(HIST("h_jetpT_detector_lfjet"), analysisJet.pt(), eventWeight); } - for (auto& mcpjet : analysisJet.template matchedJetGeo_as()) { + for (const auto& mcpjet : analysisJet.template matchedJetGeo_as()) { if (mcpjet.pt() > pTHatMaxMCP * pTHat) { continue; } - if (jetFlavor == 2) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_bjet"), analysisJet.pt(), mcpjet.pt(), eventWeight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_cjet"), analysisJet.pt(), mcpjet.pt(), eventWeight); } else { registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_lfjet"), analysisJet.pt(), mcpjet.pt(), eventWeight); @@ -686,8 +700,8 @@ struct BJetTreeCreator { } if (produceTree) { - bjetConstituentsTable(bjetParamsTable.lastIndex() + 1, tracksIndices, SVsIndices); - bjetParamsTable(analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), tracksIndices.size(), nSVs, analysisJet.mass(), jetFlavor, analysisJet.r()); + bjetConstituentsTable(bjetParamsTable.lastIndex() + 1, indicesTracks, indicesSVs); + bjetParamsTable(analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), indicesTracks.size(), nSVs, analysisJet.mass(), jetFlavor, analysisJet.r()); } } } @@ -698,19 +712,19 @@ struct BJetTreeCreator { void processMCJetsForGNN(FilteredCollisionMCD::iterator const& collision, aod::JMcCollisions const&, MCDJetTableNoSV const& MCDjets, MCPJetTable const& MCPjets, JetTracksMCDwID const& allTracks, JetParticleswID const& MCParticles, OriginalTracks const& origTracks, aod::McParticles const& origParticles) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || (static_cast(std::rand()) / RAND_MAX < eventReductionFactor)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || (static_cast(std::rand()) / RAND_MAX < eventReductionFactor)) { return; } registry.fill(HIST("h_vertexZ"), collision.posZ()); - auto const mcParticlesPerColl = MCParticles.sliceBy(McParticlesPerCollision, collision.mcCollisionId()); - auto const mcPJetsPerColl = MCPjets.sliceBy(McPJetsPerCollision, collision.mcCollisionId()); + auto const mcParticlesPerColl = MCParticles.sliceBy(mcParticlesPerCollision, collision.mcCollisionId()); + auto const mcPJetsPerColl = MCPjets.sliceBy(mcpJetsPerCollision, collision.mcCollisionId()); for (const auto& analysisJet : MCDjets) { bool jetIncluded = false; - for (auto jetR : jetRadiiValues) { + for (const auto& jetR : jetRadiiValues) { if (analysisJet.r() == static_cast(jetR * 100)) { jetIncluded = true; break; @@ -721,12 +735,12 @@ struct BJetTreeCreator { continue; } - std::vector tracksIndices; - std::vector SVsIndices; + std::vector indicesTracks; + std::vector indicesSVs; int16_t jetFlavor = 0; - for (auto& mcpjet : analysisJet.template matchedJetGeo_as()) { + for (const auto& mcpjet : analysisJet.template matchedJetGeo_as()) { if (useQuarkDef) { jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, mcParticlesPerColl); } else { @@ -743,24 +757,24 @@ struct BJetTreeCreator { //+ TrackLabelMap trkLabels{{"trkVtxIndex", {}}, {"trkOrigin", {}}}; int nVertices = jettaggingutilities::vertexClustering(collision.template mcCollision_as(), analysisJet, allTracks, MCParticles, origParticles, trkLabels, true, vtxRes, trackPtMin); - analyzeJetTrackInfoForGNN(collision, analysisJet, allTracks, origTracks, tracksIndices, jetFlavor, eventWeight, &trkLabels); + analyzeJetTrackInfoForGNN(collision, analysisJet, allTracks, origTracks, indicesTracks, jetFlavor, eventWeight, &trkLabels); registry.fill(HIST("h2_jetMass_jetpT"), analysisJet.pt(), analysisJet.mass(), eventWeight); - registry.fill(HIST("h2_nTracks_jetpT"), analysisJet.pt(), tracksIndices.size()); + registry.fill(HIST("h2_nTracks_jetpT"), analysisJet.pt(), indicesTracks.size()); //+jet registry.fill(HIST("h_jet_pt"), analysisJet.pt()); registry.fill(HIST("h_jet_eta"), analysisJet.eta()); registry.fill(HIST("h_jet_phi"), analysisJet.phi()); registry.fill(HIST("h_jet_flav"), jetFlavor); - registry.fill(HIST("h_n_trks"), tracksIndices.size()); + registry.fill(HIST("h_n_trks"), indicesTracks.size()); registry.fill(HIST("h_jet_mass"), analysisJet.mass()); registry.fill(HIST("h_n_vertices"), nVertices); - if (jetFlavor == 2) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h2_jetMass_jetpT_bjet"), analysisJet.pt(), analysisJet.mass(), eventWeight); registry.fill(HIST("h_jetpT_detector_bjet"), analysisJet.pt(), eventWeight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h2_jetMass_jetpT_cjet"), analysisJet.pt(), analysisJet.mass(), eventWeight); registry.fill(HIST("h_jetpT_detector_cjet"), analysisJet.pt(), eventWeight); } else { @@ -769,8 +783,8 @@ struct BJetTreeCreator { } if (produceTree) { - bjetConstituentsTable(bjetParamsTable.lastIndex() + 1, tracksIndices, SVsIndices); - bjetParamsTable(analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), tracksIndices.size(), nVertices, analysisJet.mass(), jetFlavor, analysisJet.r()); + bjetConstituentsTable(bjetParamsTable.lastIndex() + 1, indicesTracks, indicesSVs); + bjetParamsTable(analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), indicesTracks.size(), nVertices, analysisJet.mass(), jetFlavor, analysisJet.r()); } } } @@ -785,7 +799,7 @@ struct BJetTreeCreator { for (const auto& mcpjet : MCPjets) { bool jetIncluded = false; - for (auto jetR : jetRadiiValues) { + for (const auto& jetR : jetRadiiValues) { if (mcpjet.r() == static_cast(jetR * 100)) { jetIncluded = true; break; @@ -810,9 +824,9 @@ struct BJetTreeCreator { // jetFlavor = jettaggingutilities::mcpJetFromHFShower(mcpjet, MCParticles, (float)(mcpjet.r() / 100.)); } - if (jetFlavor == 2) { + if (jetFlavor == JetTaggingSpecies::beauty) { registry.fill(HIST("h_jetpT_particle_bjet"), mcpjet.pt(), eventWeight); - } else if (jetFlavor == 1) { + } else if (jetFlavor == JetTaggingSpecies::charm) { registry.fill(HIST("h_jetpT_particle_cjet"), mcpjet.pt(), eventWeight); } else { registry.fill(HIST("h_jetpT_particle_lfjet"), mcpjet.pt(), eventWeight); diff --git a/PWGJE/Tasks/dijetFinderQA.cxx b/PWGJE/Tasks/dijetFinderQA.cxx new file mode 100644 index 00000000000..b5410727b7c --- /dev/null +++ b/PWGJE/Tasks/dijetFinderQA.cxx @@ -0,0 +1,463 @@ +// 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. + +// dijet finder QA task +// +/// \author Dongguk Kim + +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct DijetFinderQATask { + + HistogramRegistry registry; + + Configurable centralityMin{"centralityMin", -999.0, "minimum centrality"}; + Configurable centralityMax{"centralityMax", 999.0, "maximum centrality"}; + Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + Configurable checkMcCollisionIsMatched{"checkMcCollisionIsMatched", false, "0: count whole MCcollisions, 1: select MCcollisions which only have their correspond collisions"}; + Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + Configurable trackPtMin{"trackPtMin", 0.15, "minimum pT acceptance for tracks"}; + Configurable trackPtMax{"trackPtMax", 1000.0, "maximum pT acceptance for tracks"}; + Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum eta acceptance for tracks"}; + Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum eta acceptance for tracks"}; + Configurable leadingConstituentPtMin{"leadingConstituentPtMin", -99.0, "minimum pT selection on jet constituent"}; + Configurable leadingConstituentPtMax{"leadingConstituentPtMax", 9999.0, "maximum pT selection on jet constituent"}; + Configurable setJetPtCut{"setJetPtCut", 20., "set jet pt minimum cut"}; + Configurable setPhiCut{"setPhiCut", 0.5, "set phicut"}; + Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; + Configurable jetPtMin{"jetPtMin", 20.0, "minimum jet pT cut"}; + Configurable jetPtMax{"jetPtMax", 200., "set jet pT bin max"}; + Configurable jetEtaMin{"jetEtaMin", -0.5, "minimum jet pseudorapidity"}; + Configurable jetEtaMax{"jetEtaMax", 0.5, "maximum jet pseudorapidity"}; + Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; + + std::vector eventSelection; + int trackSelection = -1; + + std::vector dijetMassBins; + + void labelCollisionHistograms(HistogramRegistry& registry) + { + if (doprocessDijetMCP) { + auto hColCounter_MCP = registry.get(HIST("hColCounter_MCP")); + hColCounter_MCP->GetXaxis()->SetBinLabel(1, "AllMcCollisions"); + hColCounter_MCP->GetXaxis()->SetBinLabel(2, "McCollisionsWithVertexZ"); + hColCounter_MCP->GetXaxis()->SetBinLabel(3, "MatchedMcCollisions"); + } + if (doprocessDijetMCD) { + auto hColCounter_MCD = registry.get(HIST("hColCounter_MCD")); + hColCounter_MCD->GetXaxis()->SetBinLabel(1, "AllDetCollisions"); + hColCounter_MCD->GetXaxis()->SetBinLabel(2, "DetCollisionsWithVertexZ"); + hColCounter_MCD->GetXaxis()->SetBinLabel(3, "AcceptedDetCollisions"); + } + if (doprocessDijetData) { + auto hColCounter_Data = registry.get(HIST("hColCounter_Data")); + hColCounter_Data->GetXaxis()->SetBinLabel(1, "AllDataCollisions"); + hColCounter_Data->GetXaxis()->SetBinLabel(2, "DataCollisionsWithVertexZ"); + hColCounter_Data->GetXaxis()->SetBinLabel(3, "AcceptedDataCollisions"); + } + } + + void init(o2::framework::InitContext&) + { + eventSelection = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + // Add histogram for event counts + + auto dijetMassTemp = 0.0; + while (dijetMassTemp <= 2 * jetPtMax) { + dijetMassBins.push_back(dijetMassTemp); + dijetMassTemp += 5.0; + } + + AxisSpec dijetMassAxis = {dijetMassBins, "M_{jj} (GeV/#it{c}^2)"}; + + if (doprocessDijetMCP) { + registry.add("h_part_dijet_mass", "Dijet invariant mass;;entries", {HistType::kTH1F, {dijetMassAxis}}); + registry.add("hColCounter_MCP", "event status; event status;entries", {HistType::kTH1F, {{10, 0., 10.0}}}); + } + + if (doprocessDijetMCD) { + registry.add("h_detec_dijet_mass", "Dijet invariant mass;;entries", {HistType::kTH1F, {dijetMassAxis}}); + registry.add("hColCounter_MCD", "event status; event status;entries", {HistType::kTH1F, {{10, 0., 10.0}}}); + // registry.add("hColCounter_MCD", "Event count;;entries", {HistType::kTH1F, {eventCountAxis}}); + } + + if (doprocessDijetData) { + registry.add("h_data_dijet_mass", "Dijet invariant mass;;entries", {HistType::kTH1F, {dijetMassAxis}}); + registry.add("hColCounter_Data", "event status; event status;entries", {HistType::kTH1F, {{10, 0., 10.0}}}); + // registry.add("hColCounter_Data", "Event count;;entries", {HistType::kTH1F, {eventCountAxis}}); + } + + if (doprocessDijetMCPMCDMatched) { + registry.add("h_matched_dijet_mass", "M_{jj matched};M_{jj part}; M_{jj det}", {HistType::kTH2F, {dijetMassAxis, dijetMassAxis}}); + } + + labelCollisionHistograms(registry); + } + + /****************************************************************************************************************************************************************/ + Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); + Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f); + /****************************************************************************************************************************************************************/ + + template + bool isAcceptedJet(U const& jet) + { + + if (jetAreaFractionMin > -98.0) { + if (jet.area() < jetAreaFractionMin * M_PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { + return false; + } + } + bool checkConstituentPt = true; + bool checkConstituentMinPt = (leadingConstituentPtMin > -98.0); + bool checkConstituentMaxPt = (leadingConstituentPtMax < 9998.0); + if (!checkConstituentMinPt && !checkConstituentMaxPt) { + checkConstituentPt = false; + } + + if (checkConstituentPt) { + bool isMinLeadingConstituent = !checkConstituentMinPt; + bool isMaxLeadingConstituent = true; + + for (const auto& constituent : jet.template tracks_as()) { + double pt = constituent.pt(); + + if (checkConstituentMinPt && pt >= leadingConstituentPtMin) { + isMinLeadingConstituent = true; + } + if (checkConstituentMaxPt && pt > leadingConstituentPtMax) { + isMaxLeadingConstituent = false; + } + } + return isMinLeadingConstituent && isMaxLeadingConstituent; + } + + return true; + } + + template + void fillMassHistogramsMCP(T const& mass) + { + registry.fill(HIST("h_part_dijet_mass"), mass); + } + + template + void fillMassHistogramsMCD(T const& mass) + { + registry.fill(HIST("h_detec_dijet_mass"), mass); + } + + template + void fillMassHistogramsData(T const& mass) + { + registry.fill(HIST("h_data_dijet_mass"), mass); + } + + template + void fillMassHistogramsMCPMCDMatched(T const& mass_P, T const& mass_D) + { + registry.fill(HIST("h_matched_dijet_mass"), mass_P, mass_D); + } + + void processDummy(aod::JDummys const&) + { + } + PROCESS_SWITCH(DijetFinderQATask, processDummy, "dummy", false); + + void processDijetMCP(aod::JetMcCollisions::iterator const& mccollision, + soa::Filtered> const& jets, + soa::SmallGroups const& collisions) + { + registry.fill(HIST("hColCounter_MCP"), 0.5); + if (fabs(mccollision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hColCounter_MCP"), 1.5); + if (checkMcCollisionIsMatched) { + if (collisions.size() == 0) { + return; + } + for (auto& collision : collisions) { + if (fabs(collision.posZ()) > vertexZCut || !jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + } + registry.fill(HIST("hColCounter_MCP"), 2.5); + } + + std::vector> jetPtcuts; + for (auto& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + if (jet.pt() < setJetPtCut) { + continue; + } + jetPtcuts.push_back({jet.pt(), jet.eta(), jet.phi()}); + } + + if (jetPtcuts.size() >= 2) { + auto& leading_jet = jetPtcuts[0]; + + bool found_pair = false; + + for (size_t i = 1; i < jetPtcuts.size() && !found_pair; i++) { + auto& candidate_jet = jetPtcuts[i]; + Double_t dphi = fabs(leading_jet[2] - candidate_jet[2]); + Double_t deta = fabs(leading_jet[1] - candidate_jet[1]); + Double_t condition = fabs(dphi - M_PI); + + if (condition < setPhiCut * M_PI) { + Double_t pt1 = leading_jet[0]; + Double_t pt2 = candidate_jet[0]; + Double_t dijet_mass = sqrt(2 * pt1 * pt2 * (cosh(deta) - cos(dphi))); + fillMassHistogramsMCP(dijet_mass); + found_pair = true; + } + } + } + } + PROCESS_SWITCH(DijetFinderQATask, processDijetMCP, "QA for invariant mass of dijet in particle level MC", false); + + void processDijetMCD(aod::JetCollisions::iterator const& collision, + soa::Filtered> const& jets) + { + registry.fill(HIST("hColCounter_MCD"), 0.5); + if (fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hColCounter_MCD"), 1.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + registry.fill(HIST("hColCounter_MCD"), 2.5); + + std::vector> jetPtcuts; + for (auto& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + if (jet.pt() < setJetPtCut) { + continue; + } + jetPtcuts.push_back({jet.pt(), jet.eta(), jet.phi()}); + } + + if (jetPtcuts.size() >= 2) { + auto& leading_jet = jetPtcuts[0]; + + bool found_pair = false; + + for (size_t i = 1; i < jetPtcuts.size() && !found_pair; i++) { + auto& candidate_jet = jetPtcuts[i]; + Double_t dphi = fabs(leading_jet[2] - candidate_jet[2]); + Double_t deta = fabs(leading_jet[1] - candidate_jet[1]); + Double_t condition = fabs(dphi - M_PI); + + if (condition < setPhiCut * M_PI) { + Double_t pt1 = leading_jet[0]; + Double_t pt2 = candidate_jet[0]; + Double_t dijet_mass = sqrt(2 * pt1 * pt2 * (cosh(deta) - cos(dphi))); + fillMassHistogramsMCD(dijet_mass); + found_pair = true; + } + } + } + } + PROCESS_SWITCH(DijetFinderQATask, processDijetMCD, "QA for invariant mass of dijet in detector level MC", false); + + void processDijetData(aod::JetCollisions::iterator const& collision, + soa::Filtered> const& jets) + { + registry.fill(HIST("hColCounter_Data"), 0.5); + if (fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hColCounter_Data"), 1.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + registry.fill(HIST("hColCounter_Data"), 2.5); + + std::vector> jetPtcuts; + for (auto& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + if (jet.pt() < setJetPtCut) { + continue; + } + jetPtcuts.push_back({jet.pt(), jet.eta(), jet.phi()}); + } + + if (jetPtcuts.size() >= 2) { + auto& leading_jet = jetPtcuts[0]; + + bool found_pair = false; + + for (size_t i = 1; i < jetPtcuts.size() && !found_pair; i++) { + auto& candidate_jet = jetPtcuts[i]; + Double_t dphi = fabs(leading_jet[2] - candidate_jet[2]); + Double_t deta = fabs(leading_jet[1] - candidate_jet[1]); + Double_t condition = fabs(dphi - M_PI); + + if (condition < setPhiCut * M_PI) { + Double_t pt1 = leading_jet[0]; + Double_t pt2 = candidate_jet[0]; + Double_t dijet_mass = sqrt(2 * pt1 * pt2 * (cosh(deta) - cos(dphi))); + fillMassHistogramsData(dijet_mass); + found_pair = true; + } + } + } + } + PROCESS_SWITCH(DijetFinderQATask, processDijetData, "QA for invariant mass of dijet in data", false); + + using JetMCPTable = soa::Filtered>; + using JetMCDTable = soa::Filtered>; + + void processDijetMCPMCDMatched(aod::JetCollisionsMCD::iterator const& collision, + JetMCDTable const& mcdjets, + JetMCPTable const&, + aod::JetTracks const&, + aod::JetParticles const&) + { + if (fabs(collision.posZ()) > vertexZCut) { + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + + std::vector> jetPtcuts_D; + std::vector> jetPtcuts_P; + + for (auto& mcdjet : mcdjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + if (mcdjet.pt() < setJetPtCut) { + continue; + } + if (mcdjet.has_matchedJetGeo()) { + for (auto& matchedjet : mcdjet.template matchedJetPt_as()) { + if (matchedjet.pt() < setJetPtCut) { + continue; + } + if (!jetfindingutilities::isInEtaAcceptance(matchedjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(matchedjet)) { + continue; + } + jetPtcuts_D.push_back({mcdjet.pt(), mcdjet.eta(), mcdjet.phi()}); + jetPtcuts_P.push_back({matchedjet.pt(), matchedjet.eta(), matchedjet.phi()}); + } + } + } + + if (jetPtcuts_D.size() >= 2 && jetPtcuts_P.size() >= 2) { + auto& leading_jet_D = jetPtcuts_D[0]; + auto& leading_jet_P = jetPtcuts_P[0]; + + std::array candidate_jet_D{}; + std::array candidate_jet_P{}; + + auto dphi_D = 0.; + auto dphi_P = 0.; + + bool found_pair_MCD = false; + bool found_pair_MCP = false; + + for (size_t i = 1; i < jetPtcuts_D.size() && !found_pair_MCD; i++) { + candidate_jet_D = jetPtcuts_D[i]; + dphi_D = fabs(leading_jet_D[2] - candidate_jet_D[2]); + Double_t condition = fabs(dphi_D - M_PI); + if (condition > setPhiCut * M_PI) { + continue; + } + found_pair_MCD = true; + } + for (size_t i = 1; i < jetPtcuts_P.size() && !found_pair_MCP; i++) { + candidate_jet_P = jetPtcuts_P[i]; + dphi_P = fabs(leading_jet_P[2] - candidate_jet_P[2]); + Double_t condition = fabs(dphi_P - M_PI); + if (condition > setPhiCut * M_PI) { + continue; + } + found_pair_MCP = true; + } + if (found_pair_MCD && found_pair_MCP) { + Double_t deta_D = fabs(leading_jet_D[1] - candidate_jet_D[1]); + Double_t deta_P = fabs(leading_jet_P[1] - candidate_jet_P[1]); + double pt1_D = leading_jet_D[0]; + double pt2_D = candidate_jet_D[0]; + double pt1_P = leading_jet_P[0]; + double pt2_P = candidate_jet_P[0]; + double dijet_mass_D = sqrt(2 * pt1_D * pt2_D * (cosh(deta_D) - cos(dphi_D))); + double dijet_mass_P = sqrt(2 * pt1_P * pt2_P * (cosh(deta_P) - cos(dphi_P))); + fillMassHistogramsMCPMCDMatched(dijet_mass_P, dijet_mass_D); + } + } + } + PROCESS_SWITCH(DijetFinderQATask, processDijetMCPMCDMatched, "QA for invariant mass of dijet in mcmactched", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"dijet-finder-charged-qa"})}; +} diff --git a/PWGJE/Tasks/emcCellMonitor.cxx b/PWGJE/Tasks/emcCellMonitor.cxx index bb1d8fb3f9f..880ce14e490 100644 --- a/PWGJE/Tasks/emcCellMonitor.cxx +++ b/PWGJE/Tasks/emcCellMonitor.cxx @@ -9,25 +9,31 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#include "CommonDataFormat/InteractionRecord.h" +#include "DataFormatsEMCAL/Constants.h" +#include "EMCALBase/Geometry.h" +#include "EMCALCalib/BadChannelMap.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include + +#include + +#include #include #include -#include #include #include #include +#include #include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/HistogramRegistry.h" - -#include "DataFormatsEMCAL/Constants.h" -#include "EMCALBase/Geometry.h" -#include "EMCALCalib/BadChannelMap.h" -#include "CommonDataFormat/InteractionRecord.h" - /// \struct CellMonitor /// \brief Simple monitoring task for cell related quantities /// \author Markus Fasel , Oak Ridge National Laoratory diff --git a/PWGJE/Tasks/emcClusterMonitor.cxx b/PWGJE/Tasks/emcClusterMonitor.cxx index 9db525fe409..fbb8885c5be 100644 --- a/PWGJE/Tasks/emcClusterMonitor.cxx +++ b/PWGJE/Tasks/emcClusterMonitor.cxx @@ -9,33 +9,39 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include -#include -#include -#include -#include -#include -#include +#include "PWGJE/DataModel/EMCALClusters.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/EventSelection.h" + +#include "CommonDataFormat/InteractionRecord.h" +#include "EMCALBase/Geometry.h" #include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" +#include +#include +#include -#include "EMCALBase/Geometry.h" -#include "EMCALCalib/BadChannelMap.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "DataFormatsEMCAL/Cell.h" -#include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" +#include -#include "CommonDataFormat/InteractionRecord.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include // \struct ClusterMonitor /// \brief Simple monitoring task for EMCal clusters @@ -100,31 +106,31 @@ struct ClusterMonitor { const AxisSpec thAxisCellTimeMean{1500, -600, 900, "#LT#it{t}_{cell}#GT (ns)"}; // event properties - mHistManager.add("eventsAll", "Number of events", o2HistType::kTH1F, {{1, 0.5, 1.5}}); - mHistManager.add("eventsSelected", "Number of events", o2HistType::kTH1F, {{1, 0.5, 1.5}}); - mHistManager.add("eventBCAll", "Bunch crossing ID of event (all events)", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("eventBCSelected", "Bunch crossing ID of event (selected events)", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("eventVertexZAll", "z-vertex of event (all events)", o2HistType::kTH1F, {{200, -20, 20}}); - mHistManager.add("eventVertexZSelected", "z-vertex of event (selected events)", o2HistType::kTH1F, {{200, -20, 20}}); - mHistManager.add("numberOfClustersEvents", "number of clusters per event (selected events)", o2HistType::kTH1F, {numberClustersAxis}); - mHistManager.add("numberOfClustersBC", "number of clusters per bunch crossing (ambiguous BCs)", o2HistType::kTH1F, {numberClustersAxis}); - mHistManager.add("numberOfClustersEventsRejected", "number of clusters per event (rejected events)", o2HistType::kTH1F, {numberClustersAxis}); + mHistManager.add("eventsAll", "Number of events", o2HistType::kTH1D, {{1, 0.5, 1.5}}); + mHistManager.add("eventsSelected", "Number of events", o2HistType::kTH1D, {{1, 0.5, 1.5}}); + mHistManager.add("eventBCAll", "Bunch crossing ID of event (all events)", o2HistType::kTH1D, {bcAxis}); + mHistManager.add("eventBCSelected", "Bunch crossing ID of event (selected events)", o2HistType::kTH1D, {bcAxis}); + mHistManager.add("eventVertexZAll", "z-vertex of event (all events)", o2HistType::kTH1D, {{200, -20, 20}}); + mHistManager.add("eventVertexZSelected", "z-vertex of event (selected events)", o2HistType::kTH1D, {{200, -20, 20}}); + mHistManager.add("numberOfClustersEvents", "number of clusters per event (selected events)", o2HistType::kTH1D, {numberClustersAxis}); + mHistManager.add("numberOfClustersBC", "number of clusters per bunch crossing (ambiguous BCs)", o2HistType::kTH1D, {numberClustersAxis}); + mHistManager.add("numberOfClustersEventsRejected", "number of clusters per event (rejected events)", o2HistType::kTH1D, {numberClustersAxis}); mHistManager.add("numberOfClustersSMEvents", "number of clusters per supermodule per event (selected events)", o2HistType::kTH2F, {numberClustersAxis, {20, -0.5, 19.5, "SupermoduleID"}}); mHistManager.add("numberOfClustersSMBC", "number of clusters per supermodule per bunch crossing (ambiguous BCs)", o2HistType::kTH2F, {numberClustersAxis, {20, -0.5, 19.5, "SupermoduleID"}}); // cluster properties (matched clusters) - mHistManager.add("clusterE", "Energy of cluster", o2HistType::kTH1F, {energyAxis}); - mHistManager.add("clusterEMatched", "Energy of cluster (with match)", o2HistType::kTH1F, {energyAxis}); + mHistManager.add("clusterE", "Energy of cluster", o2HistType::kTH1D, {energyAxis}); + mHistManager.add("clusterEMatched", "Energy of cluster (with match)", o2HistType::kTH1D, {energyAxis}); mHistManager.add("clusterESupermodule", "Energy of the cluster vs. supermoduleID", o2HistType::kTH2F, {energyAxis, supermoduleAxis}); - mHistManager.add("clusterE_SimpleBinning", "Energy of cluster", o2HistType::kTH1F, {{2000, 0, 200}}); + mHistManager.add("clusterE_SimpleBinning", "Energy of cluster", o2HistType::kTH1D, {{2000, 0, 200}}); mHistManager.add("clusterEtaPhi", "Eta and phi of cluster", o2HistType::kTH2F, {{100, -1, 1}, {100, 0, 2 * TMath::Pi()}}); - mHistManager.add("clusterM02", "M02 of cluster", o2HistType::kTH1F, {{400, 0, 5}}); - mHistManager.add("clusterM20", "M20 of cluster", o2HistType::kTH1F, {{400, 0, 2.5}}); - mHistManager.add("clusterNLM", "Number of local maxima of cluster", o2HistType::kTH1I, {{10, 0, 10}}); - mHistManager.add("clusterNCells", "Number of cells in cluster", o2HistType::kTH1I, {{50, 0, 50}}); - mHistManager.add("clusterDistanceToBadChannel", "Distance to bad channel", o2HistType::kTH1F, {{100, 0, 100}}); + mHistManager.add("clusterM02", "M02 of cluster", o2HistType::kTH1D, {{400, 0, 5}}); + mHistManager.add("clusterM20", "M20 of cluster", o2HistType::kTH1D, {{400, 0, 2.5}}); + mHistManager.add("clusterNLM", "Number of local maxima of cluster", o2HistType::kTH1D, {{10, 0, 10}}); + mHistManager.add("clusterNCells", "Number of cells in cluster", o2HistType::kTH1D, {{50, 0, 50}}); + mHistManager.add("clusterDistanceToBadChannel", "Distance to bad channel", o2HistType::kTH1D, {{100, 0, 100}}); mHistManager.add("clusterTimeVsE", "Cluster time vs energy", o2HistType::kTH2F, {timeAxis, energyAxis}); - mHistManager.add("clusterAmpFractionLeadingCell", "Fraction of energy in leading cell", o2HistType::kTH1F, {{100, 0, 1}}); + mHistManager.add("clusterAmpFractionLeadingCell", "Fraction of energy in leading cell", o2HistType::kTH1D, {{100, 0, 1}}); mHistManager.add("clusterCellTimeDiff", "Cell time difference in clusters", o2HistType::kTH1D, {thAxisCellTimeDiff}); mHistManager.add("clusterCellTimeMean", "Mean cell time per cluster", o2HistType::kTH1D, {thAxisCellTimeMean}); diff --git a/PWGJE/Tasks/emcEventSelectionQA.cxx b/PWGJE/Tasks/emcEventSelectionQA.cxx index de4228aa70e..8ba3f5168c8 100644 --- a/PWGJE/Tasks/emcEventSelectionQA.cxx +++ b/PWGJE/Tasks/emcEventSelectionQA.cxx @@ -9,70 +9,94 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// Monitoring task for EMCAL event selection -// +/// \file emcEventSelectionQA.cxx +/// \brief Monitoring task for EMCAL event selection /// \author Markus Fasel , Oak Ridge National Laoratory -#include +#include "PWGJE/Core/utilsBcSelEMC.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/EventSelection.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include -#include "Common/DataModel/EventSelection.h" +#include + +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::emc_evsel; -using bcEvSels = o2::soa::Join; -using collEventSels = o2::soa::Join; +using BCEvSels = o2::soa::Join; +using CollEventSels = o2::soa::Join; +using FilteredCells = o2::soa::Filtered; struct EmcEventSelectionQA { + + EMCEventSelection emcEvSel; // event selection and monitoring o2::framework::HistogramRegistry mHistManager{"EMCALEventSelectionQAHistograms"}; // Require EMCAL cells (CALO type 1) Filter emccellfilter = aod::calo::caloType == 1; + const int mRun3MinNumber = 300000; + void init(o2::framework::InitContext const&) { - using o2HistType = o2::framework::HistType; - using o2Axis = o2::framework::AxisSpec; - - o2Axis matchingAxis{3, -0.5, 2.5, "Matching Status (0, 1, 2+ collisions)", "Matching status"}, // 0, no vertex,1 vertex found , 2 multiple vertices found - bcAxis{4001, -0.5, 4000.5, "bcid", "BC ID"}; - - mHistManager.add("hCollisionMatching", "Collision Status", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingReadout", "Collision Status EMCAL Readout", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingMB", "Collision Status EMCAL MB", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatching0EMC", "Collision Status EMCAL L0 trigger", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatching0DMC", "Collision Status DCAL L0 tr", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingEG1", "Collision Status EG1 trigger", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingDG1", "Collision Status DG1 trigger", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingEG2", "Collision Status EG2 trigger", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingDG2", "Collision Status DG2 trigger", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingEJ1", "Collision Status EJ1 trigger", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingDJ1", "Collision Status DJ1 trigger", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingEJ2", "Collision Status EJ2 trigger", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hCollisionMatchingDJ2", "Collision Status DJ2 trigger", o2HistType::kTH1F, {matchingAxis}); - mHistManager.add("hBCCollisions", "Bunch crossings of found collisions", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalReadout", "Bunch crossings with EMCAL trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalMB", "Bunch crossings with EMCAL MB from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcal0EMC", "Bunch crossings with EMCAL L0 from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcal0DMC", "Bunch crossings with DCAL L0 from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalEG1", "Bunch crossings with EG1 trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalDG1", "Bunch crossings with DG1 trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalEG2", "Bunch crossings with EG1 trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalDG2", "Bunch crossings with DG2 trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalEJ1", "Bunch crossings with EJ1 trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalDJ1", "Bunch crossings with DJ1 trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalEJ2", "Bunch crossings with EJ2 trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalDJ2", "Bunch crossings with DJ2 trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCTVX", "Bunch crossings with FIT TVX trigger from CTP", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCEmcalCellContent", "Bunch crossings with non-0 EMCAL cell content", o2HistType::kTH1F, {bcAxis}); - mHistManager.add("hBCCollisionCounter_TVX", "Number of BCs with a certain number of rec. colls", o2HistType::kTH2F, {bcAxis, matchingAxis}); + using O2HistType = o2::framework::HistType; + using O2Axis = o2::framework::AxisSpec; + + O2Axis matchingAxis{3, -0.5, 2.5, "Matching Status (0, 1, 2+ collisions)", "Matching status"}, // 0, no vertex,1 vertex found , 2 multiple vertices found + bcAxis{4001, -0.5, 4000.5, "bcid", "BC ID"}, + amplitudeAxisLarge{1000, 0., 100., "amplitudeLarge", "Amplitude (GeV)"}, + timeAxisLarge{1500, -600, 900, "celltime", "#it{t}_{cell} (ns)"}; + + mHistManager.add("hCollisionMatching", "Collision Status", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingReadout", "Collision Status EMCAL Readout", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingMB", "Collision Status EMCAL MB", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatching0EMC", "Collision Status EMCAL L0 trigger", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatching0DMC", "Collision Status DCAL L0 tr", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingEG1", "Collision Status EG1 trigger", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingDG1", "Collision Status DG1 trigger", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingEG2", "Collision Status EG2 trigger", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingDG2", "Collision Status DG2 trigger", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingEJ1", "Collision Status EJ1 trigger", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingDJ1", "Collision Status DJ1 trigger", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingEJ2", "Collision Status EJ2 trigger", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hCollisionMatchingDJ2", "Collision Status DJ2 trigger", O2HistType::kTH1F, {matchingAxis}); + mHistManager.add("hBCCollisions", "Bunch crossings of found collisions", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalReadout", "Bunch crossings with EMCAL trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalMB", "Bunch crossings with EMCAL MB from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcal0EMC", "Bunch crossings with EMCAL L0 from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcal0DMC", "Bunch crossings with DCAL L0 from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalEG1", "Bunch crossings with EG1 trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalDG1", "Bunch crossings with DG1 trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalEG2", "Bunch crossings with EG1 trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalDG2", "Bunch crossings with DG2 trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalEJ1", "Bunch crossings with EJ1 trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalDJ1", "Bunch crossings with DJ1 trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalEJ2", "Bunch crossings with EJ2 trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalDJ2", "Bunch crossings with DJ2 trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCTVX", "Bunch crossings with FIT TVX trigger from CTP", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCNoTVXEmcalReadout", "Bunch crossings with no FIT TVX trigger from CTP but with EMCal im readout", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCEmcalCellContent", "Bunch crossings with non-0 EMCAL cell content", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCCollisionCounter_TVX", "Number of BCs with a certain number of rec. colls", O2HistType::kTH2F, {bcAxis, matchingAxis}); + mHistManager.add("hBCEMCalReadoutAndEmcalCellContent", "Bunch crossings with EMCAL trigger from CTP and non-0 EMCAL cell content", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCNotEMCalReadoutButEmcalCellContent", "Bunch crossings without EMCAL trigger from CTP but with non-0 EMCAL cell content", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCNotAcceptedButEMCalReadout", "Bunch crossings with EMCAL trigger from CTP but not accpeted due to BC selection", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hBCNotAcceptedButEmcalCellContent", "Bunch crossings with non-0 EMCAL cell content but not accpeted due to BC selection", O2HistType::kTH1F, {bcAxis}); + mHistManager.add("hAmplitudevsCellTimeNoReadout", "Amplitude vs cell time for bunch crossings without EMCAL trigger from CTP but with non-0 EMCAL cell content", O2HistType::kTH2D, {timeAxisLarge, amplitudeAxisLarge}); initCollisionHistogram(mHistManager.get(HIST("hCollisionMatching")).get()); initCollisionHistogram(mHistManager.get(HIST("hCollisionMatchingReadout")).get()); @@ -87,17 +111,20 @@ struct EmcEventSelectionQA { initCollisionHistogram(mHistManager.get(HIST("hCollisionMatchingDJ1")).get()); initCollisionHistogram(mHistManager.get(HIST("hCollisionMatchingEJ2")).get()); initCollisionHistogram(mHistManager.get(HIST("hCollisionMatchingDJ2")).get()); + + emcEvSel.addHistograms(mHistManager); // collision monitoring } - PresliceUnsorted perFoundBC = aod::evsel::foundBCId; + PresliceUnsorted perFoundBC = aod::evsel::foundBCId; + Preslice cellsPerFoundBC = aod::calo::bcId; - void process(bcEvSels const& bcs, collEventSels const& collisions, soa::Filtered const& cells) + void process(BCEvSels const& bcs, CollEventSels const& collisions, soa::Filtered const& cells) { std::unordered_map cellGlobalBCs; // Build map of number of cells for corrected BCs using global BCs // used later in the determination whether a BC has EMC cell content (for speed reason) for (const auto& cell : cells) { - auto globalbcid = cell.bc_as().globalBC(); + auto globalbcid = cell.bc_as().globalBC(); auto found = cellGlobalBCs.find(globalbcid); if (found != cellGlobalBCs.end()) { found->second++; @@ -110,10 +137,15 @@ struct EmcEventSelectionQA { bool isEMCALreadout = false; auto bcID = bc.globalBC() % 3564; - if (bc.runNumber() > 300000) { + // get bitmask with bc selection info + const auto rejectionMask = emcEvSel.getEMCCollisionRejectionMask(bc); + // monitor the satisfied event selections + emcEvSel.fillHistograms(rejectionMask); + + if (bc.runNumber() > mRun3MinNumber) { // in case of run3 not all BCs contain EMCAL data, require trigger selection also for min. bias // in addition select also L0/L1 triggers as triggers with EMCAL in reaodut - if (bc.alias_bit(kTVXinEMC) || bc.alias_bit(kEMC7) || bc.alias_bit(kEG1) || bc.alias_bit(kEG2) || bc.alias_bit(kDG1) || bc.alias_bit(kDG2) || bc.alias_bit(kEJ1) || bc.alias_bit(kEJ2) || bc.alias_bit(kDJ1) || bc.alias_bit(kDJ2)) { + if (bc.alias_bit(kTVXinEMC) || bc.alias_bit(kEMC7) || bc.alias_bit(kDMC7) || bc.alias_bit(kEG1) || bc.alias_bit(kEG2) || bc.alias_bit(kDG1) || bc.alias_bit(kDG2) || bc.alias_bit(kEJ1) || bc.alias_bit(kEJ2) || bc.alias_bit(kDJ1) || bc.alias_bit(kDJ2)) { isEMCALreadout = true; } } else { @@ -124,6 +156,25 @@ struct EmcEventSelectionQA { } } + // lookup number of cells for global BC of this BC + // avoid iteration over cell table for speed reason + auto found = cellGlobalBCs.find(bc.globalBC()); + + if (rejectionMask != 0) { + // at least one event selection not satisfied --> reject the candidate + continue; + } else { + if (isEMCALreadout) { + mHistManager.fill(HIST("hBCNotAcceptedButEMCalReadout"), bcID); + } + if (found != cellGlobalBCs.end()) { + // require at least 1 cell for global BC + if (found->second > 0) { + mHistManager.fill(HIST("hBCNotAcceptedButEmcalCellContent"), bcID); + } + } + } + // Monitoring BCs with EMCAL trigger / readout / FIT trigger if (isEMCALreadout) { mHistManager.fill(HIST("hBCEmcalReadout"), bcID); @@ -165,11 +216,19 @@ struct EmcEventSelectionQA { // lookup number of cells for global BC of this BC // avoid iteration over cell table for speed reason - auto found = cellGlobalBCs.find(bc.globalBC()); if (found != cellGlobalBCs.end()) { // require at least 1 cell for global BC if (found->second > 0) { mHistManager.fill(HIST("hBCEmcalCellContent"), bcID); + if (isEMCALreadout) { + mHistManager.fill(HIST("hBCEMCalReadoutAndEmcalCellContent"), bcID); + } else { + mHistManager.fill(HIST("hBCNotEMCalReadoutButEmcalCellContent"), bcID); + auto cellsInBC = cells.sliceBy(cellsPerFoundBC, bc.globalIndex()); + for (const auto& cell : cellsInBC) { + mHistManager.fill(HIST("hAmplitudevsCellTimeNoReadout"), cell.time(), cell.amplitude()); + } + } } } @@ -192,6 +251,9 @@ struct EmcEventSelectionQA { mHistManager.fill(HIST("hCollisionMatching"), collisionStatus); if (isEMCALreadout) { mHistManager.fill(HIST("hCollisionMatchingReadout"), collisionStatus); + if (!bc.selection_bit(aod::evsel::kIsTriggerTVX)) { + mHistManager.fill(HIST("hBCNoTVXEmcalReadout"), bcID); + } // various triggers if (bc.alias_bit(kTVXinEMC)) { mHistManager.fill(HIST("hCollisionMatchingMB"), collisionStatus); diff --git a/PWGJE/Tasks/emcTmMonitor.cxx b/PWGJE/Tasks/emcTmMonitor.cxx index 3a191cba635..3d6baefda3b 100644 --- a/PWGJE/Tasks/emcTmMonitor.cxx +++ b/PWGJE/Tasks/emcTmMonitor.cxx @@ -9,35 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include -#include -#include -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/HistogramRegistry.h" - -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "EMCALBase/Geometry.h" -#include "EMCALCalib/BadChannelMap.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "DataFormatsEMCAL/Cell.h" -#include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" - -#include "CommonDataFormat/InteractionRecord.h" - -// \struct TrackMatchingMonitor +/// \file emcTmMonitor.cxx /// \brief Simple monitoring task for EMCal clusters /// \author Marvin Hemmer /// \since 24.02.2023 @@ -50,14 +22,41 @@ /// Simple event selection using the flag doEventSel is provided, which selects INT7 events if set to 1 /// For pilot beam data, instead of relying on the event selection, one can veto specific BC IDS using the flag /// fDoVetoBCID. + +#include "PWGJE/DataModel/EMCALClusters.h" + +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + using namespace o2::framework; using namespace o2::framework::expressions; -using collisionEvSelIt = o2::soa::Join::iterator; -using bcEvSelIt = o2::soa::Join::iterator; -using selectedClusters = o2::soa::Filtered; -using selectedAmbiguousClusters = o2::soa::Filtered; -using tracksPID = o2::soa::Join; -struct TrackMatchingMonitor { +using CollisionEvSelIt = o2::soa::Join::iterator; +using BcEvSelIt = o2::soa::Join::iterator; +using SelectedClusters = o2::soa::Filtered; +using TracksPID = o2::soa::Join; +struct EmcTmMonitor { HistogramRegistry mHistManager{"TrackMatchingMonitorHistograms", {}, OutputObjHandlingPolicy::AnalysisObject}; o2::emcal::Geometry* mGeometry = nullptr; @@ -65,14 +64,13 @@ struct TrackMatchingMonitor { Preslice perClusterAmb = o2::aod::emcalclustercell::emcalambiguousclusterId; Preslice perClusterMatchedTracks = o2::aod::emcalclustercell::emcalclusterId; // configurable parameters - // TODO adapt mDoEventSel switch to also allow selection of other triggers (e.g. EMC7) - Configurable mDoEventSel{"doEventSel", 0, "demand kINT7"}; - Configurable mVetoBCID{"vetoBCID", "", "BC ID(s) to be excluded, this should be used as an alternative to the event selection"}; - Configurable mSelectBCID{"selectBCID", "all", "BC ID(s) to be included, this should be used as an alternative to the event selection"}; - Configurable mVertexCut{"vertexCut", -1, "apply z-vertex cut with value in cm"}; - Configurable mClusterDefinition{"clusterDefinition", 10, "cluster definition to be selected, e.g. 10=kV3Default"}; - ConfigurableAxis mClusterTimeBinning{"clustertime-binning", {1500, -600, 900}, ""}; - Configurable hasPropagatedTracks{"hasPropagatedTracks", false, "temporary flag, only set to true when running over data which has the tracks propagated to EMCal/PHOS!"}; + // TODO adapt doEventSel switch to also allow selection of other triggers (e.g. EMC7) + Configurable doEventSel{"doEventSel", 0, "demand kINT7"}; + Configurable vetoBCID{"vetoBCID", "", "BC ID(s) to be excluded, this should be used as an alternative to the event selection"}; + Configurable selectBCID{"selectBCID", "all", "BC ID(s) to be included, this should be used as an alternative to the event selection"}; + Configurable vertexCut{"vertexCut", -1, "apply z-vertex cut with value in cm"}; + Configurable clusterDefinition{"clusterDefinition", 10, "cluster definition to be selected, e.g. 10=kV3Default"}; + ConfigurableAxis clusterTimeBinning{"clusterTimeBinning", {1500, -600, 900}, ""}; Configurable usePionRejection{"usePionRejection", false, "demand pion rection for electron signal with TPC PID"}; Configurable> tpcNsigmaElectron{"tpcNsigmaElectron", {-1., +3.}, "TPC PID NSigma range for electron signal (first <= NSigma <= second)"}; Configurable> tpcNsigmaBack{"tpcNsigmaBack", {-10., -4.}, "TPC PID NSigma range for electron background (first <= NSigma <= second)"}; @@ -82,7 +80,7 @@ struct TrackMatchingMonitor { Configurable minM02{"minM02", 0.1, "Minimum M02 for M02 cut"}; Configurable maxM02{"maxM02", 0.9, "Maximum M02 for M02 cut"}; Configurable maxM02HighPt{"maxM02HighPt", 0.6, "Maximum M02 for M02 cut for high pT"}; - Configurable M02highPt{"M02highPt", 15., "pT threshold for maxM02HighPt cut. Set to negative value to disable it!"}; + Configurable m02highPt{"m02highPt", 15., "pT threshold for maxM02HighPt cut. Set to negative value to disable it!"}; Configurable minDEta{"minDEta", 0.01, "Minimum dEta between track and cluster"}; Configurable minDPhi{"minDPhi", 0.01, "Minimum dPhi between track and cluster"}; Configurable> eOverPRange{"eOverPRange", {0.9, 1.2}, "E/p range where one would search for electrons (first <= E/p <= second)"}; @@ -94,101 +92,98 @@ struct TrackMatchingMonitor { /// \brief Create output histograms and initialize geometry void init(InitContext const&) { - // create histograms - using o2HistType = HistType; - using o2Axis = AxisSpec; - // load geometry just in case we need it mGeometry = o2::emcal::Geometry::GetInstanceFromRunNumber(300000); // create common axes LOG(info) << "Creating histograms"; - const o2Axis bcAxis{3501, -0.5, 3500.5}; - const o2Axis energyAxis{makeEnergyBinningAliPhysics(), "E_{clus} (GeV)"}; - const o2Axis amplitudeAxisLarge{1000, 0., 100., "amplitudeLarge", "Amplitude (GeV)"}; - const o2Axis dEtaAxis{100, -1.f * minDEta, minDEta, "d#it{#eta}"}; - const o2Axis dPhiAxis{100, -1.f * minDPhi, minDPhi, "d#it{#varphi} (rad)"}; - const o2Axis dRAxis{150, 0.0, 0.015, "d#it{R}"}; - const o2Axis eoverpAxis{500, 0, 10, "#it{E}_{cluster}/#it{p}_{track}"}; - const o2Axis nSigmaAxis{400, -10., +30., "N#sigma"}; - const o2Axis trackptAxis{makePtBinning(), "#it{p}_{T,track}"}; - const o2Axis trackpAxis{200, 0, 100, "#it{p}_{track}"}; - const o2Axis clusterptAxis{makePtBinning(), "#it{p}_{T}"}; - const o2Axis etaAxis{160, -0.8, 0.8, "#eta"}; - const o2Axis phiAxis{72, 0, 2 * 3.14159, "#varphi (rad)"}; - const o2Axis smAxis{20, -0.5, 19.5, "SM"}; - o2Axis timeAxis{mClusterTimeBinning, "t_{cl} (ns)"}; + const AxisSpec bcAxis{3501, -0.5, 3500.5}; + const AxisSpec energyAxis{makeEnergyBinningAliPhysics(), "E_{clus} (GeV)"}; + const AxisSpec amplitudeAxisLarge{1000, 0., 100., "amplitudeLarge", "Amplitude (GeV)"}; + const AxisSpec dEtaAxis{100, -1.f * minDEta, minDEta, "d#it{#eta}"}; + const AxisSpec dPhiAxis{100, -1.f * minDPhi, minDPhi, "d#it{#varphi} (rad)"}; + const AxisSpec dRAxis{150, 0.0, 0.015, "d#it{R}"}; + const AxisSpec eoverpAxis{500, 0, 10, "#it{E}_{cluster}/#it{p}_{track}"}; + const AxisSpec nSigmaAxis{400, -10., +30., "N#sigma"}; + const AxisSpec trackptAxis{makePtBinning(), "#it{p}_{T,track}"}; + const AxisSpec trackpAxis{200, 0, 100, "#it{p}_{track}"}; + const AxisSpec clusterptAxis{makePtBinning(), "#it{p}_{T}"}; + const AxisSpec etaAxis{160, -0.8, 0.8, "#eta"}; + const AxisSpec phiAxis{72, 0, 2 * 3.14159, "#varphi (rad)"}; + const AxisSpec smAxis{20, -0.5, 19.5, "SM"}; + AxisSpec timeAxis{clusterTimeBinning, "t_{cl} (ns)"}; - int MaxMatched = 20; // maximum number of matched tracks, hardcoded in emcalCorrectionTask.cxx! - const o2Axis nmatchedtrack{MaxMatched, -0.5, MaxMatched + 0.5}; + const int maxMatched = 20; // maximum number of matched tracks, hardcoded in emcalCorrectionTask.cxx! + const AxisSpec nmatchedtrack{maxMatched, -0.5, maxMatched + 0.5}; + // create histograms // event properties - mHistManager.add("eventsAll", "Number of events", o2HistType::kTH1F, {{1, 0.5, 1.5}}); - mHistManager.add("eventsSelected", "Number of events", o2HistType::kTH1F, {{1, 0.5, 1.5}}); - mHistManager.add("eventVertexZAll", "z-vertex of event (all events)", o2HistType::kTH1F, {{200, -20, 20}}); - mHistManager.add("eventVertexZSelected", "z-vertex of event (selected events)", o2HistType::kTH1F, {{200, -20, 20}}); + mHistManager.add("eventsAll", "Number of events", HistType::kTH1F, {{1, 0.5, 1.5}}); + mHistManager.add("eventsSelected", "Number of events", HistType::kTH1F, {{1, 0.5, 1.5}}); + mHistManager.add("eventVertexZAll", "z-vertex of event (all events)", HistType::kTH1F, {{200, -20, 20}}); + mHistManager.add("eventVertexZSelected", "z-vertex of event (selected events)", HistType::kTH1F, {{200, -20, 20}}); // cluster properties (matched clusters) - mHistManager.add("TrackEtaPhi", "#eta vs #varphi of all selected tracks", o2HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected tracks - mHistManager.add("TrackEtaPhi_Neg", "#eta vs #varphi of all selected negative tracks", o2HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected negative tracks - mHistManager.add("TrackEtaPhi_Pos", "#eta vs #varphi of all selected positive tracks", o2HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected positive tracks - mHistManager.add("clusterEMatched", "Energy of cluster (with match)", o2HistType::kTH1F, {energyAxis}); // energy of matched clusters - mHistManager.add("MatchedTrackEtaPhi_BeforeCut", "#eta vs #varphi of all selected matched tracks before d#eta and #dvarphi cut", o2HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected matched tracks before dEta and dPhi cut - mHistManager.add("MatchedTrackEtaPhi_Neg_BeforeCut", "#eta vs #varphi of all selected negative matched tracks before d#eta and #dvarphi cut", o2HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected negative matched tracks before dEta and dPhi cut - mHistManager.add("MatchedTrackEtaPhi_Pos_BeforeCut", "#eta vs #varphi of all selected positive matched tracks before d#eta and #dvarphi cut", o2HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected positive matched tracks before dEta and dPhi cut - mHistManager.add("MatchedTrackEtaPhi", "#eta vs #varphi of all selected matched tracks", o2HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected matched tracks - mHistManager.add("MatchedTrackEtaPhi_Neg", "#eta vs #varphi of all selected negative matched tracks", o2HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected negative matched tracks - mHistManager.add("MatchedTrackEtaPhi_Pos", "#eta vs #varphi of all selected positive matched tracks", o2HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected positive matched tracks - mHistManager.add("clusterTM_dEtadPhi", "cluster trackmatching dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM - mHistManager.add("clusterTM_dEtadPhi_ASide", "cluster trackmatching in A-Side dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM in A-Aside - mHistManager.add("clusterTM_dEtadPhi_CSide", "cluster trackmatching in C-Side tracks dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM in C-Side - mHistManager.add("clusterTM_PosdEtadPhi", "cluster trackmatching positive tracks dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM positive track - mHistManager.add("clusterTM_NegdEtadPhi", "cluster trackmatching negative tracks dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM negative track - mHistManager.add("clusterTM_PosdEtadPhi_Pl0_75", "cluster trackmatching positive tracks, p < 0.75 dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM positive track with p < 0.75 GeV/c - mHistManager.add("clusterTM_NegdEtadPhi_Pl0_75", "cluster trackmatching negative tracks, p < 0.75 dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM negative track with p < 0.75 GeV/c - mHistManager.add("clusterTM_PosdEtadPhi_0_75leqPl1_25", "cluster trackmatching positive tracks, 0.75 <= p < 1.25 dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM positive track with 0.75 <= p < 1.25 GeV/c - mHistManager.add("clusterTM_NegdEtadPhi_0_75leqPl1_25", "cluster trackmatching negative tracks, 0.75 <= p < 1.25 dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM negative track with 0.75 <= p < 1.25 GeV/c - mHistManager.add("clusterTM_PosdEtadPhi_Pgeq1_25", "cluster trackmatching positive tracks, p >= 1.25 dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM positive track with p >= 1.25 GeV/c - mHistManager.add("clusterTM_NegdEtadPhi_Pgeq1_25", "cluster trackmatching negative tracks, p >= 1.25 dEta/dPhi", o2HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM negative track with p >= 1.25 GeV/c - mHistManager.add("clusterTM_dEtaPt", "cluster trackmatching dEta/#it{p}_{T};d#it{#eta};#it{p}_{T} (GeV/#it{c})", o2HistType::kTH3F, {dEtaAxis, clusterptAxis, smAxis}); // dEta vs pT per SM - mHistManager.add("clusterTM_PosdPhiPt", "cluster trackmatching positive tracks dPhi/#it{p}_{T}", o2HistType::kTH3F, {dPhiAxis, clusterptAxis, smAxis}); // dPhi vs pT per SM positive track - mHistManager.add("clusterTM_NegdPhiPt", "cluster trackmatching negative tracks dPh/#it{p}_{T}", o2HistType::kTH3F, {dPhiAxis, clusterptAxis, smAxis}); // dPhi vs pT per SM negative track - mHistManager.add("clusterTM_dEtaTN", "cluster trackmatching dEta/TN;d#it{#eta};#it{N}_{matched tracks}", o2HistType::kTH2F, {dEtaAxis, nmatchedtrack}); // dEta compared to the Nth closest track - mHistManager.add("clusterTM_dPhiTN", "cluster trackmatching dPhi/TN;d#it{#varphi} (rad);#it{N}_{matched tracks}", o2HistType::kTH2F, {dPhiAxis, nmatchedtrack}); // dPhi compared to the Nth closest track - mHistManager.add("clusterTM_dRTN", "cluster trackmatching dR/TN;d#it{R};#it{N}_{matched tracks}", o2HistType::kTH2F, {dRAxis, nmatchedtrack}); // dR compared to the Nth closest track - mHistManager.add("clusterTM_NTrack", "cluster trackmatching NMatchedTracks", o2HistType::kTH1I, {nmatchedtrack}); // how many tracks are matched - mHistManager.add("clusterTM_EoverP_E", "E/p ", o2HistType::kTH3F, {eoverpAxis, energyAxis, nmatchedtrack}); // E/p vs p for the Nth closest track - mHistManager.add("clusterTM_EoverP_Pt", "E/p vs track pT", o2HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E/p vs track pT for the Nth closest track - mHistManager.add("clusterTM_EvsP", "cluster E/track p", o2HistType::kTH3F, {energyAxis, trackpAxis, nmatchedtrack}); // E vs p for the Nth closest track - mHistManager.add("clusterTM_EoverP_ep", "cluster E/electron p", o2HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest electron/positron track - mHistManager.add("clusterTM_EoverP_e", "cluster E/electron p", o2HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest electron track - mHistManager.add("clusterTM_EoverP_p", "cluster E/electron p", o2HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest positron track - mHistManager.add("clusterTM_EoverP_electron_ASide", "cluster E/electron p in A-Side", o2HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest electron/positron track in A-Side - mHistManager.add("clusterTM_EoverP_electron_CSide", "cluster E/electron p in C-Side", o2HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest electron/positron track in C-Side - mHistManager.add("clusterTM_NSigma_BeforeCut", "electron NSigma for matched tracks before d#eta and #dvarphi cut", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest track before dEta and dPhi cut - mHistManager.add("clusterTM_NSigma_neg_BeforeCut", "electron NSigma for matched negative tracks before d#eta and #dvarphi cut", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest negative tracks before dEta and dPhi cut - mHistManager.add("clusterTM_NSigma_pos_BeforeCut", "electron NSigma for matched positive tracks before d#eta and #dvarphi cut", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest positive tracks before dEta and dPhi cut - mHistManager.add("clusterTM_NSigma", "electron NSigma for matched track", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest track - mHistManager.add("clusterTM_NSigma_neg", "electron NSigma for matched negative track", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest negative tracks - mHistManager.add("clusterTM_NSigma_pos", "electron NSigma for matched positive track", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest positive tracks - mHistManager.add("clusterTM_NSigma_cut", "electron NSigma for matched track with cuts", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest track with cuts on E/p and cluster cuts - mHistManager.add("clusterTM_NSigma_e", "NSigma electron", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest electron track - mHistManager.add("clusterTM_NSigma_p", "NSigma positron", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest positron track - mHistManager.add("clusterTM_NSigma_e_cut", "NSigma electron with E over p cut", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest electron track with E/p cut - mHistManager.add("clusterTM_NSigma_p_cut", "NSigma positron with E over p cut", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest positron track with E/p cut - mHistManager.add("TrackTM_NSigma", "electron NSigma for global tracks", o2HistType::kTH2F, {nSigmaAxis, trackptAxis}); // NSigma_electron vs track pT for global track - mHistManager.add("TrackTM_NSigma_e", "NSigma e for global negative tracks", o2HistType::kTH2F, {nSigmaAxis, trackptAxis}); // NSigma vs track pT for negative global track - mHistManager.add("TrackTM_NSigma_p", "NSigma e for global positive tracks", o2HistType::kTH2F, {nSigmaAxis, trackptAxis}); // NSigma vs track pT for positive global track - mHistManager.add("clusterTM_NSigma_electron_ASide", "NSigma electron in A-Side", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest electron/positron track in A-Side - mHistManager.add("clusterTM_NSigma_electron_CSide", "NSigma positron in C-Side", o2HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest electron/positron track in C-Side - mHistManager.add("clusterTM_EoverP_hadron", "cluster E/hadron p", o2HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest hadron track - mHistManager.add("clusterTM_EoverP_hn", "cluster E/hadron p", o2HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest negative hadron track - mHistManager.add("clusterTM_EoverP_hp", "cluster E/hadron p", o2HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest positive hadron track - mHistManager.add("clusterTM_EoverP_hadron_ASide", "cluster E/hadron p in A-Side", o2HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest hadron track in A-Side - mHistManager.add("clusterTM_EoverP_hadron_CSide", "cluster E/hadron p in C-Side", o2HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest hadron track in C-Side + mHistManager.add("TrackEtaPhi", "#eta vs #varphi of all selected tracks", HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected tracks + mHistManager.add("TrackEtaPhi_Neg", "#eta vs #varphi of all selected negative tracks", HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected negative tracks + mHistManager.add("TrackEtaPhi_Pos", "#eta vs #varphi of all selected positive tracks", HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected positive tracks + mHistManager.add("clusterEMatched", "Energy of cluster (with match)", HistType::kTH1F, {energyAxis}); // energy of matched clusters + mHistManager.add("MatchedTrackEtaPhi_BeforeCut", "#eta vs #varphi of all selected matched tracks before d#eta and #dvarphi cut", HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected matched tracks before dEta and dPhi cut + mHistManager.add("MatchedTrackEtaPhi_Neg_BeforeCut", "#eta vs #varphi of all selected negative matched tracks before d#eta and #dvarphi cut", HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected negative matched tracks before dEta and dPhi cut + mHistManager.add("MatchedTrackEtaPhi_Pos_BeforeCut", "#eta vs #varphi of all selected positive matched tracks before d#eta and #dvarphi cut", HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected positive matched tracks before dEta and dPhi cut + mHistManager.add("MatchedTrackEtaPhi", "#eta vs #varphi of all selected matched tracks", HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected matched tracks + mHistManager.add("MatchedTrackEtaPhi_Neg", "#eta vs #varphi of all selected negative matched tracks", HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected negative matched tracks + mHistManager.add("MatchedTrackEtaPhi_Pos", "#eta vs #varphi of all selected positive matched tracks", HistType::kTH2F, {etaAxis, phiAxis}); // eta vs phi of all selected positive matched tracks + mHistManager.add("clusterTM_dEtadPhi", "cluster trackmatching dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM + mHistManager.add("clusterTM_dEtadPhi_ASide", "cluster trackmatching in A-Side dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM in A-Aside + mHistManager.add("clusterTM_dEtadPhi_CSide", "cluster trackmatching in C-Side tracks dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM in C-Side + mHistManager.add("clusterTM_PosdEtadPhi", "cluster trackmatching positive tracks dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM positive track + mHistManager.add("clusterTM_NegdEtadPhi", "cluster trackmatching negative tracks dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM negative track + mHistManager.add("clusterTM_PosdEtadPhi_Pl0_75", "cluster trackmatching positive tracks, p < 0.75 dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM positive track with p < 0.75 GeV/c + mHistManager.add("clusterTM_NegdEtadPhi_Pl0_75", "cluster trackmatching negative tracks, p < 0.75 dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM negative track with p < 0.75 GeV/c + mHistManager.add("clusterTM_PosdEtadPhi_0_75leqPl1_25", "cluster trackmatching positive tracks, 0.75 <= p < 1.25 dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM positive track with 0.75 <= p < 1.25 GeV/c + mHistManager.add("clusterTM_NegdEtadPhi_0_75leqPl1_25", "cluster trackmatching negative tracks, 0.75 <= p < 1.25 dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM negative track with 0.75 <= p < 1.25 GeV/c + mHistManager.add("clusterTM_PosdEtadPhi_Pgeq1_25", "cluster trackmatching positive tracks, p >= 1.25 dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM positive track with p >= 1.25 GeV/c + mHistManager.add("clusterTM_NegdEtadPhi_Pgeq1_25", "cluster trackmatching negative tracks, p >= 1.25 dEta/dPhi", HistType::kTH3F, {dEtaAxis, dPhiAxis, smAxis}); // dEta dPhi per SM negative track with p >= 1.25 GeV/c + mHistManager.add("clusterTM_dEtaPt", "cluster trackmatching dEta/#it{p}_{T};d#it{#eta};#it{p}_{T} (GeV/#it{c})", HistType::kTH3F, {dEtaAxis, clusterptAxis, smAxis}); // dEta vs pT per SM + mHistManager.add("clusterTM_PosdPhiPt", "cluster trackmatching positive tracks dPhi/#it{p}_{T}", HistType::kTH3F, {dPhiAxis, clusterptAxis, smAxis}); // dPhi vs pT per SM positive track + mHistManager.add("clusterTM_NegdPhiPt", "cluster trackmatching negative tracks dPh/#it{p}_{T}", HistType::kTH3F, {dPhiAxis, clusterptAxis, smAxis}); // dPhi vs pT per SM negative track + mHistManager.add("clusterTM_dEtaTN", "cluster trackmatching dEta/TN;d#it{#eta};#it{N}_{matched tracks}", HistType::kTH2F, {dEtaAxis, nmatchedtrack}); // dEta compared to the Nth closest track + mHistManager.add("clusterTM_dPhiTN", "cluster trackmatching dPhi/TN;d#it{#varphi} (rad);#it{N}_{matched tracks}", HistType::kTH2F, {dPhiAxis, nmatchedtrack}); // dPhi compared to the Nth closest track + mHistManager.add("clusterTM_dRTN", "cluster trackmatching dR/TN;d#it{R};#it{N}_{matched tracks}", HistType::kTH2F, {dRAxis, nmatchedtrack}); // dR compared to the Nth closest track + mHistManager.add("clusterTM_NTrack", "cluster trackmatching NMatchedTracks", HistType::kTH1I, {nmatchedtrack}); // how many tracks are matched + mHistManager.add("clusterTM_EoverP_E", "E/p ", HistType::kTH3F, {eoverpAxis, energyAxis, nmatchedtrack}); // E/p vs p for the Nth closest track + mHistManager.add("clusterTM_EoverP_Pt", "E/p vs track pT", HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E/p vs track pT for the Nth closest track + mHistManager.add("clusterTM_EvsP", "cluster E/track p", HistType::kTH3F, {energyAxis, trackpAxis, nmatchedtrack}); // E vs p for the Nth closest track + mHistManager.add("clusterTM_EoverP_ep", "cluster E/electron p", HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest electron/positron track + mHistManager.add("clusterTM_EoverP_e", "cluster E/electron p", HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest electron track + mHistManager.add("clusterTM_EoverP_p", "cluster E/electron p", HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest positron track + mHistManager.add("clusterTM_EoverP_electron_ASide", "cluster E/electron p in A-Side", HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest electron/positron track in A-Side + mHistManager.add("clusterTM_EoverP_electron_CSide", "cluster E/electron p in C-Side", HistType::kTH3F, {eoverpAxis, trackptAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest electron/positron track in C-Side + mHistManager.add("clusterTM_NSigma_BeforeCut", "electron NSigma for matched tracks before d#eta and #dvarphi cut", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest track before dEta and dPhi cut + mHistManager.add("clusterTM_NSigma_neg_BeforeCut", "electron NSigma for matched negative tracks before d#eta and #dvarphi cut", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest negative tracks before dEta and dPhi cut + mHistManager.add("clusterTM_NSigma_pos_BeforeCut", "electron NSigma for matched positive tracks before d#eta and #dvarphi cut", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest positive tracks before dEta and dPhi cut + mHistManager.add("clusterTM_NSigma", "electron NSigma for matched track", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest track + mHistManager.add("clusterTM_NSigma_neg", "electron NSigma for matched negative track", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest negative tracks + mHistManager.add("clusterTM_NSigma_pos", "electron NSigma for matched positive track", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest positive tracks + mHistManager.add("clusterTM_NSigma_cut", "electron NSigma for matched track with cuts", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma_electron vs track pT for the Nth closest track with cuts on E/p and cluster cuts + mHistManager.add("clusterTM_NSigma_e", "NSigma electron", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest electron track + mHistManager.add("clusterTM_NSigma_p", "NSigma positron", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest positron track + mHistManager.add("clusterTM_NSigma_e_cut", "NSigma electron with E over p cut", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest electron track with E/p cut + mHistManager.add("clusterTM_NSigma_p_cut", "NSigma positron with E over p cut", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest positron track with E/p cut + mHistManager.add("TrackTM_NSigma", "electron NSigma for global tracks", HistType::kTH2F, {nSigmaAxis, trackptAxis}); // NSigma_electron vs track pT for global track + mHistManager.add("TrackTM_NSigma_e", "NSigma e for global negative tracks", HistType::kTH2F, {nSigmaAxis, trackptAxis}); // NSigma vs track pT for negative global track + mHistManager.add("TrackTM_NSigma_p", "NSigma e for global positive tracks", HistType::kTH2F, {nSigmaAxis, trackptAxis}); // NSigma vs track pT for positive global track + mHistManager.add("clusterTM_NSigma_electron_ASide", "NSigma electron in A-Side", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest electron/positron track in A-Side + mHistManager.add("clusterTM_NSigma_electron_CSide", "NSigma positron in C-Side", HistType::kTH3F, {nSigmaAxis, trackptAxis, nmatchedtrack}); // NSigma vs track pT for the Nth closest electron/positron track in C-Side + mHistManager.add("clusterTM_EoverP_hadron", "cluster E/hadron p", HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest hadron track + mHistManager.add("clusterTM_EoverP_hn", "cluster E/hadron p", HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest negative hadron track + mHistManager.add("clusterTM_EoverP_hp", "cluster E/hadron p", HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest positive hadron track + mHistManager.add("clusterTM_EoverP_hadron_ASide", "cluster E/hadron p in A-Side", HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest hadron track in A-Side + mHistManager.add("clusterTM_EoverP_hadron_CSide", "cluster E/hadron p in C-Side", HistType::kTH3F, {eoverpAxis, trackpAxis, nmatchedtrack}); // E over p vs track pT for the Nth closest hadron track in C-Side - if (mVetoBCID->length()) { - std::stringstream parser(mVetoBCID.value); + if (vetoBCID->length()) { + std::stringstream parser(vetoBCID.value); std::string token; int bcid; while (std::getline(parser, token, ',')) { @@ -197,8 +192,8 @@ struct TrackMatchingMonitor { mVetoBCIDs.push_back(bcid); } } - if (mSelectBCID.value != "all") { - std::stringstream parser(mSelectBCID.value); + if (selectBCID.value != "all") { + std::stringstream parser(selectBCID.value); std::string token; int bcid; while (std::getline(parser, token, ',')) { @@ -212,19 +207,22 @@ struct TrackMatchingMonitor { // define cluster filter. It selects only those clusters which are of the type // sadly passing of the string at runtime is not possible for technical region so cluster definition is // an integer instead - Filter clusterDefinitionSelection = (o2::aod::emcalcluster::definition == mClusterDefinition) && (o2::aod::emcalcluster::time >= minTime) && (o2::aod::emcalcluster::time <= maxTime) && (o2::aod::emcalcluster::m02 > minM02) && (o2::aod::emcalcluster::m02 < maxM02); + Filter clusterDefinitionSelection = (o2::aod::emcalcluster::definition == clusterDefinition) && (o2::aod::emcalcluster::time >= minTime) && (o2::aod::emcalcluster::time <= maxTime) && (o2::aod::emcalcluster::m02 > minM02) && (o2::aod::emcalcluster::m02 < maxM02); /// \brief Process EMCAL clusters that are matched to a collisions - void processCollisions(collisionEvSelIt const& theCollision, selectedClusters const& clusters, o2::aod::EMCALClusterCells const&, o2::aod::Calos const&, o2::aod::EMCALMatchedTracks const& matchedtracks, tracksPID const& alltracks) + void processCollisions(CollisionEvSelIt const& theCollision, SelectedClusters const& clusters, o2::aod::EMCALClusterCells const&, o2::aod::Calos const&, o2::aod::EMCALMatchedTracks const& matchedtracks, TracksPID const& alltracks) { mHistManager.fill(HIST("eventsAll"), 1); - // do event selection if mDoEventSel is specified + // do event selection if doEventSel is specified // currently the event selection is hard coded to kINT7 // but other selections are possible that are defined in TriggerAliases.h bool isSelected = true; - if (mDoEventSel) { - if (theCollision.bc().runNumber() < 300000) { + const int beginningRun3 = 300000; + float lowP = 0.75f; + float midP = 1.25f; + if (doEventSel) { + if (theCollision.bc().runNumber() < beginningRun3) { if (!theCollision.alias_bit(kINT7)) { isSelected = false; } @@ -239,8 +237,8 @@ struct TrackMatchingMonitor { return; } mHistManager.fill(HIST("eventVertexZAll"), theCollision.posZ()); - if (mVertexCut > 0 && TMath::Abs(theCollision.posZ()) > mVertexCut) { - LOG(debug) << "Event not selected because of z-vertex cut z= " << theCollision.posZ() << " > " << mVertexCut << " cm, skipping"; + if (vertexCut > 0 && std::abs(theCollision.posZ()) > vertexCut) { + LOG(debug) << "Event not selected because of z-vertex cut z= " << theCollision.posZ() << " > " << vertexCut << " cm, skipping"; return; } mHistManager.fill(HIST("eventsSelected"), 1); @@ -248,13 +246,8 @@ struct TrackMatchingMonitor { for (const auto& alltrack : alltracks) { double trackEta, trackPhi; - if (hasPropagatedTracks) { // only temporarily while not every data has the tracks propagated to EMCal/PHOS - trackEta = alltrack.trackEtaEmcal(); - trackPhi = alltrack.trackPhiEmcal(); - } else { - trackEta = alltrack.eta(); - trackPhi = alltrack.phi(); - } + trackEta = alltrack.trackEtaEmcal(); + trackPhi = alltrack.trackPhiEmcal(); if (alltrack.isGlobalTrack()) { // NSigma of all global tracks without matching mHistManager.fill(HIST("TrackTM_NSigma"), alltrack.tpcNSigmaEl(), alltrack.pt()); mHistManager.fill(HIST("TrackEtaPhi"), trackEta, trackPhi); @@ -291,7 +284,7 @@ struct TrackMatchingMonitor { // match.track_as() with // using globTracks = o2::soa::Join; // In this example the counter t is just used to only look at the closest match - double dEta, dPhi, pT, abs_p, trackEta, trackPhi, NSigmaEl; + float dEta, dPhi, pT, abs_p, trackEta, trackPhi, nSigmaEl; int supermoduleID; try { supermoduleID = mGeometry->SuperModuleNumberFromEtaPhi(cluster.eta(), cluster.phi()); @@ -301,40 +294,35 @@ struct TrackMatchingMonitor { continue; } - pT = cluster.energy() / cosh(cluster.eta()); - if (M02highPt > 0. && cluster.m02() >= maxM02HighPt && pT >= M02highPt) { // high pT M02 cut + pT = cluster.energy() / std::cosh(cluster.eta()); + if (m02highPt > 0. && cluster.m02() >= maxM02HighPt && pT >= m02highPt) { // high pT M02 cut continue; } auto tracksofcluster = matchedtracks.sliceBy(perClusterMatchedTracks, cluster.globalIndex()); int t = 0; for (const auto& match : tracksofcluster) { - NSigmaEl = match.track_as().tpcNSigmaEl(); + nSigmaEl = match.track_as().tpcNSigmaEl(); // exmple of how to access any property of the matched tracks (tracks are sorted by how close they are to cluster) - LOG(debug) << "Pt of match" << match.track_as().pt(); - abs_p = abs(match.track_as().p()); + LOG(debug) << "Pt of match" << match.track_as().pt(); + abs_p = std::abs(match.track_as().p()); // only consider closest match - if (hasPropagatedTracks) { // only temporarily while not every data has the tracks propagated to EMCal/PHOS - trackEta = match.track_as().trackEtaEmcal(); - trackPhi = match.track_as().trackPhiEmcal(); - } else { - trackEta = match.track_as().eta(); - trackPhi = match.track_as().phi(); - } - dPhi = trackPhi - cluster.phi(); - dEta = trackEta - cluster.eta(); + trackEta = match.track_as().trackEtaEmcal(); + trackPhi = match.track_as().trackPhiEmcal(); + dPhi = match.deltaPhi(); + dEta = match.deltaEta(); mHistManager.fill(HIST("MatchedTrackEtaPhi_BeforeCut"), trackEta, trackPhi); - mHistManager.fill(HIST("clusterTM_NSigma_BeforeCut"), NSigmaEl, match.track_as().pt(), t); - if (match.track_as().sign() == -1) { + mHistManager.fill(HIST("clusterTM_NSigma_BeforeCut"), nSigmaEl, match.track_as().pt(), t); + if (match.track_as().sign() == -1) { mHistManager.fill(HIST("MatchedTrackEtaPhi_Neg_BeforeCut"), trackEta, trackPhi); - mHistManager.fill(HIST("clusterTM_NSigma_neg_BeforeCut"), NSigmaEl, match.track_as().pt(), t); - } else if (match.track_as().sign() == 1) { + mHistManager.fill(HIST("clusterTM_NSigma_neg_BeforeCut"), nSigmaEl, match.track_as().pt(), t); + } else if (match.track_as().sign() == 1) { mHistManager.fill(HIST("MatchedTrackEtaPhi_Pos_BeforeCut"), trackEta, trackPhi); - mHistManager.fill(HIST("clusterTM_NSigma_pos_BeforeCut"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_pos_BeforeCut"), nSigmaEl, match.track_as().pt(), t); } - if (fabs(dEta) >= minDEta || fabs(dPhi) >= minDPhi) { // dEta and dPhi cut + if (std::abs(dEta) >= minDEta || std::abs(dPhi) >= minDPhi) { // dEta and dPhi cut continue; } - if (hasTRD && !(match.track_as().hasTRD())) { // request TRD hit cut + if (hasTRD && !(match.track_as().hasTRD())) { // request TRD hit cut continue; } // only fill these for the first matched track: @@ -350,105 +338,105 @@ struct TrackMatchingMonitor { mHistManager.fill(HIST("clusterTM_dEtadPhi"), dEta, dPhi, t); mHistManager.fill(HIST("clusterEMatched"), cluster.energy(), t); mHistManager.fill(HIST("clusterTM_EvsP"), cluster.energy(), abs_p, t); - mHistManager.fill(HIST("clusterTM_EoverP_Pt"), eOverP, match.track_as().pt(), t); - mHistManager.fill(HIST("clusterTM_NSigma"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_EoverP_Pt"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma"), nSigmaEl, match.track_as().pt(), t); mHistManager.fill(HIST("MatchedTrackEtaPhi"), trackEta, trackPhi); if (eOverPRange->at(0) <= eOverP && eOverP <= eOverPRange->at(1)) { - mHistManager.fill(HIST("clusterTM_NSigma_cut"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_cut"), nSigmaEl, match.track_as().pt(), t); } // A- and C-side - if (match.track_as().eta() > 0.0 && t == 0) { + if (match.track_as().eta() > 0.0 && t == 0) { mHistManager.fill(HIST("clusterTM_dEtadPhi_ASide"), dEta, dPhi, supermoduleID); - } else if (match.track_as().eta() < 0.0 && t == 0) { + } else if (match.track_as().eta() < 0.0 && t == 0) { mHistManager.fill(HIST("clusterTM_dEtadPhi_CSide"), dEta, dPhi, supermoduleID); } // positive and negative tracks seperate, with three different track momentum ranges - if (match.track_as().sign() == 1) { - mHistManager.fill(HIST("clusterTM_NSigma_pos"), NSigmaEl, match.track_as().pt(), t); + if (match.track_as().sign() == 1) { + mHistManager.fill(HIST("clusterTM_NSigma_pos"), nSigmaEl, match.track_as().pt(), t); mHistManager.fill(HIST("MatchedTrackEtaPhi_Pos"), trackEta, trackPhi); if (t == 0) { mHistManager.fill(HIST("clusterTM_PosdPhiPt"), dPhi, pT, supermoduleID); mHistManager.fill(HIST("clusterTM_PosdEtadPhi"), dEta, dPhi, supermoduleID); - if (abs_p < 0.75) { + if (abs_p < lowP) { mHistManager.fill(HIST("clusterTM_PosdEtadPhi_Pl0_75"), dEta, dPhi, supermoduleID); - } else if (abs_p >= 1.25) { + } else if (abs_p >= midP) { mHistManager.fill(HIST("clusterTM_PosdEtadPhi_Pgeq1_25"), dEta, dPhi, supermoduleID); } else { mHistManager.fill(HIST("clusterTM_PosdEtadPhi_0_75leqPl1_25"), dEta, dPhi, supermoduleID); } } - } else if (match.track_as().sign() == -1) { - mHistManager.fill(HIST("clusterTM_NSigma_neg"), NSigmaEl, match.track_as().pt(), t); + } else if (match.track_as().sign() == -1) { + mHistManager.fill(HIST("clusterTM_NSigma_neg"), nSigmaEl, match.track_as().pt(), t); mHistManager.fill(HIST("MatchedTrackEtaPhi_Neg"), trackEta, trackPhi); if (t == 0) { mHistManager.fill(HIST("clusterTM_NegdPhiPt"), dPhi, pT, supermoduleID); mHistManager.fill(HIST("clusterTM_NegdEtadPhi"), dEta, dPhi, supermoduleID); - if (abs_p < 0.75) { + if (abs_p < lowP) { mHistManager.fill(HIST("clusterTM_NegdEtadPhi_Pl0_75"), dEta, dPhi, supermoduleID); - } else if (abs_p >= 1.25) { + } else if (abs_p >= midP) { mHistManager.fill(HIST("clusterTM_NegdEtadPhi_Pgeq1_25"), dEta, dPhi, supermoduleID); } else { mHistManager.fill(HIST("clusterTM_NegdEtadPhi_0_75leqPl1_25"), dEta, dPhi, supermoduleID); } } } - if (tpcNsigmaElectron->at(0) <= NSigmaEl && NSigmaEl <= tpcNsigmaElectron->at(1)) { // E/p for e+/e- - if (usePionRejection && (tpcNsigmaPion->at(0) <= match.track_as().tpcNSigmaPi() || match.track_as().tpcNSigmaPi() <= tpcNsigmaPion->at(1))) { // with pion rejection - mHistManager.fill(HIST("clusterTM_EoverP_ep"), eOverP, match.track_as().pt(), t); - if (match.track_as().eta() >= 0.) { - mHistManager.fill(HIST("clusterTM_EoverP_electron_ASide"), eOverP, match.track_as().pt(), t); - mHistManager.fill(HIST("clusterTM_NSigma_electron_ASide"), NSigmaEl, match.track_as().pt(), t); + if (tpcNsigmaElectron->at(0) <= nSigmaEl && nSigmaEl <= tpcNsigmaElectron->at(1)) { // E/p for e+/e- + if (usePionRejection && (tpcNsigmaPion->at(0) <= match.track_as().tpcNSigmaPi() || match.track_as().tpcNSigmaPi() <= tpcNsigmaPion->at(1))) { // with pion rejection + mHistManager.fill(HIST("clusterTM_EoverP_ep"), eOverP, match.track_as().pt(), t); + if (match.track_as().eta() >= 0.) { + mHistManager.fill(HIST("clusterTM_EoverP_electron_ASide"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_electron_ASide"), nSigmaEl, match.track_as().pt(), t); } else { - mHistManager.fill(HIST("clusterTM_EoverP_electron_CSide"), eOverP, match.track_as().pt(), t); - mHistManager.fill(HIST("clusterTM_NSigma_electron_CSide"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_EoverP_electron_CSide"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_electron_CSide"), nSigmaEl, match.track_as().pt(), t); } - if (match.track_as().sign() == -1) { - mHistManager.fill(HIST("clusterTM_EoverP_e"), eOverP, match.track_as().pt(), t); - mHistManager.fill(HIST("clusterTM_NSigma_e"), NSigmaEl, match.track_as().pt(), t); + if (match.track_as().sign() == -1) { + mHistManager.fill(HIST("clusterTM_EoverP_e"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_e"), nSigmaEl, match.track_as().pt(), t); if (eOverPRange->at(0) <= eOverP && eOverP <= eOverPRange->at(1)) { - mHistManager.fill(HIST("clusterTM_NSigma_e_cut"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_e_cut"), nSigmaEl, match.track_as().pt(), t); } - } else if (match.track_as().sign() == +1) { - mHistManager.fill(HIST("clusterTM_EoverP_p"), eOverP, match.track_as().pt(), t); - mHistManager.fill(HIST("clusterTM_NSigma_p"), NSigmaEl, match.track_as().pt(), t); + } else if (match.track_as().sign() == +1) { + mHistManager.fill(HIST("clusterTM_EoverP_p"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_p"), nSigmaEl, match.track_as().pt(), t); if (eOverPRange->at(0) <= eOverP && eOverP <= eOverPRange->at(1)) { - mHistManager.fill(HIST("clusterTM_NSigma_p_cut"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_p_cut"), nSigmaEl, match.track_as().pt(), t); } } } else { // without pion rejection - mHistManager.fill(HIST("clusterTM_EoverP_ep"), eOverP, match.track_as().pt(), t); - if (match.track_as().eta() >= 0.) { - mHistManager.fill(HIST("clusterTM_EoverP_electron_ASide"), eOverP, match.track_as().pt(), t); - mHistManager.fill(HIST("clusterTM_NSigma_electron_ASide"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_EoverP_ep"), eOverP, match.track_as().pt(), t); + if (match.track_as().eta() >= 0.) { + mHistManager.fill(HIST("clusterTM_EoverP_electron_ASide"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_electron_ASide"), nSigmaEl, match.track_as().pt(), t); } else { - mHistManager.fill(HIST("clusterTM_EoverP_electron_CSide"), eOverP, match.track_as().pt(), t); - mHistManager.fill(HIST("clusterTM_NSigma_electron_CSide"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_EoverP_electron_CSide"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_electron_CSide"), nSigmaEl, match.track_as().pt(), t); } - if (match.track_as().sign() == -1) { - mHistManager.fill(HIST("clusterTM_EoverP_e"), eOverP, match.track_as().pt(), t); - mHistManager.fill(HIST("clusterTM_NSigma_e"), NSigmaEl, match.track_as().pt(), t); + if (match.track_as().sign() == -1) { + mHistManager.fill(HIST("clusterTM_EoverP_e"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_e"), nSigmaEl, match.track_as().pt(), t); if (eOverPRange->at(0) <= eOverP && eOverP <= eOverPRange->at(1)) { - mHistManager.fill(HIST("clusterTM_NSigma_e_cut"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_e_cut"), nSigmaEl, match.track_as().pt(), t); } - } else if (match.track_as().sign() == +1) { - mHistManager.fill(HIST("clusterTM_EoverP_p"), eOverP, match.track_as().pt(), t); - mHistManager.fill(HIST("clusterTM_NSigma_p"), NSigmaEl, match.track_as().pt(), t); + } else if (match.track_as().sign() == +1) { + mHistManager.fill(HIST("clusterTM_EoverP_p"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_p"), nSigmaEl, match.track_as().pt(), t); if (eOverPRange->at(0) <= eOverP && eOverP <= eOverPRange->at(1)) { - mHistManager.fill(HIST("clusterTM_NSigma_p_cut"), NSigmaEl, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_NSigma_p_cut"), nSigmaEl, match.track_as().pt(), t); } } } - } else if (tpcNsigmaBack->at(0) <= NSigmaEl && NSigmaEl <= tpcNsigmaBack->at(1)) { // E/p for hadrons / background - mHistManager.fill(HIST("clusterTM_EoverP_hadron"), eOverP, match.track_as().pt(), t); - if (match.track_as().eta() >= 0.) { - mHistManager.fill(HIST("clusterTM_EoverP_hadron_ASide"), eOverP, match.track_as().pt(), t); + } else if (tpcNsigmaBack->at(0) <= nSigmaEl && nSigmaEl <= tpcNsigmaBack->at(1)) { // E/p for hadrons / background + mHistManager.fill(HIST("clusterTM_EoverP_hadron"), eOverP, match.track_as().pt(), t); + if (match.track_as().eta() >= 0.) { + mHistManager.fill(HIST("clusterTM_EoverP_hadron_ASide"), eOverP, match.track_as().pt(), t); } else { - mHistManager.fill(HIST("clusterTM_EoverP_hadron_CSide"), eOverP, match.track_as().pt(), t); + mHistManager.fill(HIST("clusterTM_EoverP_hadron_CSide"), eOverP, match.track_as().pt(), t); } - if (match.track_as().sign() == -1) { - mHistManager.fill(HIST("clusterTM_EoverP_hn"), eOverP, match.track_as().pt(), t); - } else if (match.track_as().sign() == +1) { - mHistManager.fill(HIST("clusterTM_EoverP_hp"), eOverP, match.track_as().pt(), t); + if (match.track_as().sign() == -1) { + mHistManager.fill(HIST("clusterTM_EoverP_hn"), eOverP, match.track_as().pt(), t); + } else if (match.track_as().sign() == +1) { + mHistManager.fill(HIST("clusterTM_EoverP_hp"), eOverP, match.track_as().pt(), t); } } t++; @@ -456,12 +444,11 @@ struct TrackMatchingMonitor { mHistManager.fill(HIST("clusterTM_NTrack"), t); } } - PROCESS_SWITCH(TrackMatchingMonitor, processCollisions, "Process clusters from collision", true); + PROCESS_SWITCH(EmcTmMonitor, processCollisions, "Process clusters from collision", true); /// \brief Create binning for cluster energy axis (variable bin size) /// \return vector with bin limits - std::vector - makeEnergyBinning() const + std::vector makeEnergyBinning() const { auto fillBinLimits = [](std::vector& binlimits, double max, double binwidth) { auto current = *binlimits.rbegin(); @@ -488,26 +475,27 @@ struct TrackMatchingMonitor { { std::vector result; - Int_t nBinsClusterE = 235; - for (Int_t i = 0; i < nBinsClusterE + 1; i++) { - if (i < 1) + int nBinsClusterE = 235; + for (int i = 0; i < nBinsClusterE + 1; i++) { + if (i < 1) { // o2-linter: disable=magic-number (just numbers for binning) result.emplace_back(0.3 * i); - else if (i < 55) + } else if (i < 55) { // o2-linter: disable=magic-number (just numbers for binning) result.emplace_back(0.3 + 0.05 * (i - 1)); - else if (i < 105) + } else if (i < 105) { // o2-linter: disable=magic-number (just numbers for binning) result.emplace_back(3. + 0.1 * (i - 55)); - else if (i < 140) + } else if (i < 140) { // o2-linter: disable=magic-number (just numbers for binning) result.emplace_back(8. + 0.2 * (i - 105)); - else if (i < 170) + } else if (i < 170) { // o2-linter: disable=magic-number (just numbers for binning) result.emplace_back(15. + 0.5 * (i - 140)); - else if (i < 190) + } else if (i < 190) { // o2-linter: disable=magic-number (just numbers for binning) result.emplace_back(30. + 1.0 * (i - 170)); - else if (i < 215) + } else if (i < 215) { // o2-linter: disable=magic-number (just numbers for binning) result.emplace_back(50. + 2.0 * (i - 190)); - else if (i < 235) + } else if (i < 235) { // o2-linter: disable=magic-number (just numbers for binning) result.emplace_back(100. + 5.0 * (i - 215)); - else if (i < 245) + } else if (i < 245) { // o2-linter: disable=magic-number (just numbers for binning) result.emplace_back(200. + 10.0 * (i - 235)); + } } return result; } @@ -521,20 +509,21 @@ struct TrackMatchingMonitor { result.reserve(1000); double epsilon = 1e-6; double valGammaPt = 0; - for (int i = 0; i < 1000; ++i) { + for (int i = 0; i < 1000; ++i) { // o2-linter: disable=magic-number (just numbers for binning) result.push_back(valGammaPt); - if (valGammaPt < 1.0 - epsilon) + if (valGammaPt < 1.0 - epsilon) { // o2-linter: disable=magic-number (just numbers for binning) valGammaPt += 0.1; - else if (valGammaPt < 5 - epsilon) + } else if (valGammaPt < 5 - epsilon) { // o2-linter: disable=magic-number (just numbers for binning) valGammaPt += 0.2; - else if (valGammaPt < 10 - epsilon) + } else if (valGammaPt < 10 - epsilon) { // o2-linter: disable=magic-number (just numbers for binning) valGammaPt += 0.5; - else if (valGammaPt < 50 - epsilon) + } else if (valGammaPt < 50 - epsilon) { // o2-linter: disable=magic-number (just numbers for binning) valGammaPt += 1; - else if (valGammaPt < 100 - epsilon) + } else if (valGammaPt < 100 - epsilon) { // o2-linter: disable=magic-number (just numbers for binning) valGammaPt += 5; - else + } else { break; + } } return result; } @@ -543,6 +532,6 @@ struct TrackMatchingMonitor { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{ - adaptAnalysisTask(cfgc, TaskName{"emc-tmmonitor"})}; + adaptAnalysisTask(cfgc)}; return workflow; } diff --git a/PWGJE/Tasks/emcVertexSelectionQA.cxx b/PWGJE/Tasks/emcVertexSelectionQA.cxx index 4a803adc24f..eb579326966 100644 --- a/PWGJE/Tasks/emcVertexSelectionQA.cxx +++ b/PWGJE/Tasks/emcVertexSelectionQA.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -13,18 +13,26 @@ // /// \author Nicolas Strangmann , Goethe University Frankfurt / Oak Ridge National Laoratory -#include -#include -#include +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" +#include +#include +#include +#include + +#include using namespace o2; using namespace o2::framework; diff --git a/PWGJE/Tasks/emcalGammaGammaBcWise.cxx b/PWGJE/Tasks/emcalGammaGammaBcWise.cxx new file mode 100644 index 00000000000..d9674888aed --- /dev/null +++ b/PWGJE/Tasks/emcalGammaGammaBcWise.cxx @@ -0,0 +1,262 @@ +// 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. +/// +/// \file emcalGammaGammaBcWise.cxx +/// +/// \brief This code loops over BCs to pair photons using only EMCal + TVX (no central barrel, no collisions) +/// +/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) - Goethe University Frankfurt +/// + +#include "PWGJE/DataModel/EMCALClusters.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/EventSelection.h" + +#include "EMCALBase/Geometry.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "TLorentzVector.h" +#include "TVector3.h" + +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using MyBCs = soa::Join; +using MyCollisions = soa::Join; + +using SelectedUniqueClusters = soa::Filtered; // Clusters from collisions with only one collision in the BC +using SelectedAmbiguousClusters = soa::Filtered; // Clusters from BCs with multiple collisions (no vertex assignment possible) + +struct Photon { // Struct to store photons (unique and ambiguous clusters that passed the cuts) + Photon(float eta, float phi, float energy) : eta(eta), phi(phi), e(energy), theta(2 * std::atan2(std::exp(-eta), 1)), px(e * std::sin(theta) * std::cos(phi)), py(e * std::sin(theta) * std::sin(phi)), pz(e * std::cos(theta)), pt(std::sqrt(px * px + py * py)) + { + photon.SetPxPyPzE(px, py, pz, e); + } + + TLorentzVector photon; + float eta, phi, e; + float theta; + float px, py, pz, pt; +}; + +/// \brief returns if cluster is too close to edge of EMCal (using rotation background method only for EMCal!) +bool IsTooCloseToEdge(const int cellID, const int DistanceToBorder = 1, emcal::Geometry* emcalGeom = nullptr) +{ + if (DistanceToBorder <= 0) { + return false; + } + if (cellID < 0) { + return true; + } + + int iBadCell = -1; + + // check distance to border in case the cell is okay + auto [iSupMod, iMod, iPhi, iEta] = emcalGeom->GetCellIndex(cellID); + auto [irow, icol] = emcalGeom->GetCellPhiEtaIndexInSModule(iSupMod, iMod, iPhi, iEta); + + // Check rows/phi + int iRowLast = 24; + if (emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::EMCAL_HALF) { + iRowLast /= 2; // 2/3 sm case + } else if (emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::EMCAL_THIRD) { + iRowLast /= 3; // 1/3 sm case + } else if (emcalGeom->GetSMType(iSupMod) == o2::emcal::EMCALSMType::DCAL_EXT) { + iRowLast /= 3; // 1/3 sm case + } + + if (irow < DistanceToBorder || (iRowLast - irow) <= DistanceToBorder) { + iBadCell = 1; + } + + if (iBadCell > 0) { + return true; + } + return false; +} + +bool isPhotonAccepted(Photon const& p, emcal::Geometry* emcalGeom = nullptr) +{ + int cellID = 0; + try { + cellID = emcalGeom->GetAbsCellIdFromEtaPhi(p.eta, p.phi); + if (IsTooCloseToEdge(cellID, 1, emcalGeom)) + cellID = -1; + } catch (o2::emcal::InvalidPositionException& e) { + cellID = -1; + } + + if (cellID == -1) + return false; + + return true; +} + +struct Meson { + Meson(Photon p1, Photon p2) : p1(p1), p2(p2) + { + pMeson = p1.photon + p2.photon; + } + Photon p1, p2; + TLorentzVector pMeson; + + float m() const { return pMeson.M(); } + float pT() const { return pMeson.Pt(); } + float openingAngle() const { return p1.photon.Angle(p2.photon.Vect()); } +}; + +struct EmcalGammaGammaBcWise { + HistogramRegistry mHistManager{"EmcalGammaGammaBcWiseHistograms"}; + + Configurable cfgClusterDefinition{"cfgClusterDefinition", 13, "Clusterizer to be selected, e.g. 13 for kV3MostSplitLowSeed"}; + Configurable cfgMinClusterEnergy{"cfgMinClusterEnergy", 0.7, "Minimum energy of selected clusters (GeV)"}; + Configurable cfgMinM02{"cfgMinM02", 0.1, "Minimum M02 of selected clusters"}; + Configurable cfgMaxM02{"cfgMaxM02", 0.7, "Maximum M02 of selected clusters"}; + Configurable cfgMinTime{"cfgMinTime", -15, "Minimum time of selected clusters (ns)"}; + Configurable cfgMaxTime{"cfgMaxTime", 15, "Maximum time of selected clusters (ns)"}; + Configurable cfgMinOpenAngle{"cfgMinOpenAngle", 0.0202, "Minimum opening angle between photons"}; + + Filter clusterDefinitionFilter = aod::emcalcluster::definition == cfgClusterDefinition; + Filter energyFilter = aod::emcalcluster::energy > cfgMinClusterEnergy; + Filter m02Filter = (aod::emcalcluster::nCells == 1 || (aod::emcalcluster::m02 > cfgMinM02 && aod::emcalcluster::m02 < cfgMaxM02)); + Filter timeFilter = (aod::emcalcluster::time > cfgMinTime && aod::emcalcluster::time < cfgMaxTime); + + std::vector mPhotons; + + emcal::Geometry* emcalGeom; + + void init(InitContext const&) + { + emcalGeom = emcal::Geometry::GetInstanceFromRunNumber(300000); + mHistManager.add("nBCs", "Number of BCs (with (k)TVX);#bf{TVX triggered};#bf{#it{N}_{BCs}}", HistType::kTH1F, {{3, -0.5, 2.5}}); + + mHistManager.add("nCollisionsVsClusters", "Number of collisions vs number of clusters;N_{Collisions};N_{Clusters}", HistType::kTH2F, {{4, -0.5, 3.5}, {21, -0.5, 20.5}}); + + mHistManager.add("clusterE", "Energy of cluster;#bf{#it{E} (GeV)};#bf{#it{N}_{clusters}}", HistType::kTH1F, {{200, 0, 20}}); + mHistManager.add("clusterM02", "Shape of cluster;#bf{#it{M}_{02}};#bf{#it{N}_{clusters}}", HistType::kTH1F, {{200, 0, 2}}); + mHistManager.add("clusterTime", "Time of cluster;#bf{#it{t} (ns)};#bf{#it{N}_{clusters}}", HistType::kTH1F, {{200, -100, 100}}); + + mHistManager.add("invMassVsPt", "Invariant mass and pT of meson candidates", HistType::kTH2F, {{400, 0., 0.8}, {200, 0., 20.}}); + mHistManager.add("invMassVsPtBackground", "Invariant mass and pT of background meson candidates", HistType::kTH2F, {{400, 0., 0.8}, {200, 0., 20.}}); + } + + PresliceUnsorted perFoundBC = aod::evsel::foundBCId; + Preslice perCol = aod::emcalcluster::collisionId; + Preslice perBC = aod::emcalcluster::bcId; + + void process(MyBCs const& bcs, MyCollisions const& collisions, SelectedUniqueClusters const& uClusters, SelectedAmbiguousClusters const& aClusters) + { + for (const auto& bc : bcs) { + mHistManager.fill(HIST("nBCs"), 0.); + if (!bc.selection_bit(aod::evsel::kIsTriggerTVX)) + continue; + mHistManager.fill(HIST("nBCs"), 1.); + if (!bc.alias_bit(kTVXinEMC)) + continue; + mHistManager.fill(HIST("nBCs"), 2.); + + auto collisionsInFoundBC = collisions.sliceBy(perFoundBC, bc.globalIndex()); + + if (collisionsInFoundBC.size() == 1) { // Unique + auto clustersInCollision = uClusters.sliceBy(perCol, collisionsInFoundBC.begin().globalIndex()); + processClusters(clustersInCollision); + } else { // Ambiguous + auto clustersInBC = aClusters.sliceBy(perBC, bc.globalIndex()); + processClusters(clustersInBC); + } + + mHistManager.fill(HIST("nCollisionsVsClusters"), collisionsInFoundBC.size(), mPhotons.size()); + + processMesons(); + } + } + + /// \brief Process EMCAL clusters (either ambigous or unique) + template + void processClusters(Clusters const& clusters) + { + mPhotons.clear(); + + // loop over all clusters from accepted collision + for (const auto& cluster : clusters) { + + mHistManager.fill(HIST("clusterE"), cluster.energy()); + mHistManager.fill(HIST("clusterM02"), cluster.m02()); + mHistManager.fill(HIST("clusterTime"), cluster.time()); + + mPhotons.push_back(Photon(cluster.eta(), cluster.phi(), cluster.energy())); + } + } + + /// \brief Process meson candidates, calculate invariant mass and pT and fill histograms + void processMesons() + { + if (mPhotons.size() < 2) // if less then 2 clusters are found, skip event + return; + + // loop over all photon combinations and build meson candidates + for (unsigned int ig1 = 0; ig1 < mPhotons.size(); ++ig1) { + for (unsigned int ig2 = ig1 + 1; ig2 < mPhotons.size(); ++ig2) { + // build meson from photons + if (mPhotons[ig1].photon.Angle(mPhotons[ig2].photon.Vect()) < cfgMinOpenAngle) + continue; + Meson meson(mPhotons[ig1], mPhotons[ig2]); + mHistManager.fill(HIST("invMassVsPt"), meson.m(), meson.pT()); + + calculateBackground(meson, ig1, ig2); // calculate background candidates (rotation background) + } + } + } + + /// \brief Calculate background (using rotation background method) + void calculateBackground(const Meson& meson, const unsigned int ig1, const unsigned int ig2) + { + if (mPhotons.size() < 3) // if less than 3 clusters are present, skip event + return; + + TVector3 lvRotationPion = (meson.pMeson).Vect(); // calculate rotation axis + for (unsigned int ig3 = 0; ig3 < mPhotons.size(); ++ig3) { + if (ig3 == ig1 || ig3 == ig2) // Skip if photon is one of the meson constituents + continue; + for (const unsigned int ig : {ig1, ig2}) { + TLorentzVector lvRotationPhoton(mPhotons[ig].px, mPhotons[ig].py, mPhotons[ig].pz, mPhotons[ig].e); + lvRotationPhoton.Rotate(constants::math::PIHalf, lvRotationPion); + Photon rotPhoton(lvRotationPhoton.Eta(), lvRotationPhoton.Phi(), lvRotationPhoton.E()); + if (!isPhotonAccepted(rotPhoton, emcalGeom)) + continue; + if (rotPhoton.photon.Angle(mPhotons[ig3].photon.Vect()) < cfgMinOpenAngle) + continue; + Meson mesonRotated(rotPhoton, mPhotons[ig3]); + mHistManager.fill(HIST("invMassVsPtBackground"), mesonRotated.m(), mesonRotated.pT()); + } + } + } +}; + +WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGJE/Tasks/emcalPi0EnergyScaleCalib.cxx b/PWGJE/Tasks/emcalPi0EnergyScaleCalib.cxx index 610e890cf20..273907b8056 100644 --- a/PWGJE/Tasks/emcalPi0EnergyScaleCalib.cxx +++ b/PWGJE/Tasks/emcalPi0EnergyScaleCalib.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -9,35 +9,40 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/HistogramRegistry.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/EMCALMatchedCollisions.h" +#include "Common/CCDB/TriggerAliases.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" #include "EMCALBase/Geometry.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "PWGJE/DataModel/EMCALMatchedCollisions.h" -#include "DataFormatsEMCAL/Cell.h" -#include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" - -#include "CommonDataFormat/InteractionRecord.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include #include "TLorentzVector.h" #include "TVector3.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include /// \brief Simple pi0 reconstruction task used to scale the cell energy based on the difference in mass position in data and MC /// \author Nicolas Strangmann , Goethe University Frankfurt / Oak Ridge National Laoratory diff --git a/PWGJE/Tasks/fullJetSpectra.cxx b/PWGJE/Tasks/fullJetSpectra.cxx new file mode 100644 index 00000000000..bd2deac8148 --- /dev/null +++ b/PWGJE/Tasks/fullJetSpectra.cxx @@ -0,0 +1,1797 @@ +// 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. +// +/// \file fullJetSpectra.cxx +/// \brief Task for full jet spectra studies in pp collisions. +/// \author Archita Rani Dash + +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/EMCALClusterDefinition.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include "Common/CCDB/TriggerAliases.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +using namespace std; +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct FullJetSpectra { + + HistogramRegistry registry; + + // MC Sample split configurables + /* Configurable mcSplitSeed{"mcSplitSeed", 12345, "Seed for reproducible MC event splitting"}; + Configurable mcClosureSplitFrac{"mcClosureSplitFrac", 0.2f, "Fraction of MC events for closure test (MCD)"}; + Configurable doMcClosure{"doMcClosure", false, "Enable random splitting for MC closure test"}; + */ + // Event configurables + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + Configurable centralityMin{"centralityMin", -999.0, "minimum centrality"}; + Configurable centralityMax{"centralityMax", 999.0, "maximum centrality"}; + Configurable doEMCALEventWorkaround{"doEMCALEventWorkaround", false, "apply the workaround to read the EMC trigger bit by requiring a cell content in the EMCAL"}; + Configurable doMBGapTrigger{"doMBGapTrigger", true, "set to true only when using MB-Gap Trigger JJ MC to reject MB events at the collision and track level"}; + // Configurable doMBMC{"doMBMC", false, "set to true only when using MB MC"}; + Configurable checkMcCollisionIsMatched{"checkMcCollisionIsMatched", false, "0: count whole MCcollisions, 1: select MCcollisions which only have their correspond collisions"}; + + // Jet configurables + Configurable selectedJetsRadius{"selectedJetsRadius", 0.4, "resolution parameter for histograms without radius"}; + Configurable> jetRadii{"jetRadii", std::vector{0.4}, "jet resolution parameters"}; + Configurable jetpTMin{"jetpTMin", 20.0, "minimum jet pT"}; + Configurable jetpTMax{"jetpTMax", 350., "maximum jet pT"}; + Configurable jetEtaMin{"jetEtaMin", -0.3, "minimum jet eta"}; // each of these jet configurables are for the fiducial emcal cuts + Configurable jetEtaMax{"jetEtaMax", 0.3, "maximum jet eta"}; // for R = 0.4 (EMCAL eta acceptance: eta_jet = 0.7 - R) + Configurable jetPhiMin{"jetPhiMin", 1.80, "minimum jet phi"}; // phi_jet_min for R = 0.4 is 1.80 + Configurable jetPhiMax{"jetPhiMax", 2.86, "maximum jet phi"}; // phi_jet_min for R = 0.4 is 2.86 + Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; + Configurable leadingConstituentPtMin{"leadingConstituentPtMin", -99.0, "minimum pT selection on jet constituent"}; + + // Track configurables + Configurable trackpTMin{"trackpTMin", 0.15, "minimum track pT"}; + Configurable trackpTMax{"trackpTMax", 350., "maximum track pT"}; + Configurable trackEtaMin{"trackEtaMin", -0.7, "minimum track eta"}; + Configurable trackEtaMax{"trackEtaMax", 0.7, "maximum track eta"}; + Configurable trackPhiMin{"trackPhiMin", 1.396, "minimum track phi"}; + Configurable trackPhiMax{"trackPhiMax", 3.283, "maximum track phi"}; + Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + Configurable eventSelections{"eventSelections", "selMCFull", "choose event selection"}; + Configurable particleSelections{"particleSelections", "PhysicalPrimary", "set particle selections"}; + + // Cluster configurables + Configurable clusterDefinitionS{"clusterDefinitionS", "kV3Default", "cluster definition to be selected, e.g. V3Default"}; + Configurable clusterEtaMin{"clusterEtaMin", -0.7, "minimum cluster eta"}; + Configurable clusterEtaMax{"clusterEtaMax", 0.7, "maximum cluster eta"}; + Configurable clusterPhiMin{"clusterPhiMin", 1.396, "minimum cluster phi"}; + Configurable clusterPhiMax{"clusterPhiMax", 3.283, "maximum cluster phi"}; + Configurable clusterEnergyMin{"clusterEnergyMin", 0.3, "minimum cluster energy in EMCAL (GeV)"}; + Configurable clusterTimeMin{"clusterTimeMin", -15., "minimum cluster time (ns)"}; + Configurable clusterTimeMax{"clusterTimeMax", 15., "maximum cluster time (ns)"}; + Configurable clusterRejectExotics{"clusterRejectExotics", true, "Reject exotic clusters"}; + + Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; + Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; + Configurable pTHatExponent{"pTHatExponent", 4.0, "exponent of the event weight for the calculation of pTHeventSelectionBitsat"}; // 6 for MB MC and 4 for JJ MC + Configurable pTHatAbsoluteMin{"pTHatAbsoluteMin", -99.0, "minimum value of pTHat"}; + + int trackSelection = -1; + const float kJetAreaFractionMinThreshold = -98.0f; + const float kLeadingConstituentPtMinThreshold = -98.0f; + std::vector eventSelectionBits; + std::vector filledJetR; + std::vector jetRadiiValues; + + std::string particleSelection; + + Service pdgDatabase; + + // Random splitter instance + /* TRandom3 randGen; + // float eventRandomValue = -1.0; // default invalid + // Cache to store random values per MC collision ID + std::unordered_map mcCollisionRandomValues; + */ + /* + MC CLOSURE SPLITTING LOGIC -> still not working across different process functions. Not so trivial in O2Physics Framework! + -------------------------- + • doMcClosure=true activates MC sample splitting. + • Each event gets ONE random value in [0, 1), stored in eventRandomValue. + • Events are split as: + - ≤ mcClosureSplitFrac -> Closure (MCD) + - > mcClosureSplitFrac -> Response (MCP + Matched) + • This ensures mutually exclusive processing — NO double-counting. + • eventRandomValue is reset to -1 after each event -> this is done by the `endOfEvent` defined at the end + */ + + // Add Collision Histograms' Bin Labels for clarity + void labelCollisionHistograms(HistogramRegistry& registry) + { + if (doprocessDataTracks || doprocessMCTracks) { + auto hCollisionsUnweighted = registry.get(HIST("hCollisionsUnweighted")); + hCollisionsUnweighted->GetXaxis()->SetBinLabel(1, "allDetColl"); + hCollisionsUnweighted->GetXaxis()->SetBinLabel(2, "DetCollWithVertexZ"); + hCollisionsUnweighted->GetXaxis()->SetBinLabel(3, "MBRejectedDetEvents"); + hCollisionsUnweighted->GetXaxis()->SetBinLabel(4, "EventsNotSatisfyingEventSelection"); + hCollisionsUnweighted->GetXaxis()->SetBinLabel(5, "EMCreadoutDetEventsWithkTVXinEMC"); + hCollisionsUnweighted->GetXaxis()->SetBinLabel(6, "AllRejectedEventsAfterEMCEventSelection"); + hCollisionsUnweighted->GetXaxis()->SetBinLabel(7, "EMCAcceptedDetColl"); + hCollisionsUnweighted->GetXaxis()->SetBinLabel(8, "EMCAcceptedCollAfterTrackSel"); + } + + if (doprocessTracksWeighted) { + auto hCollisionsWeighted = registry.get(HIST("hCollisionsWeighted")); + hCollisionsWeighted->GetXaxis()->SetBinLabel(1, "AllWeightedDetColl"); + hCollisionsWeighted->GetXaxis()->SetBinLabel(2, "WeightedCollWithVertexZ"); + hCollisionsWeighted->GetXaxis()->SetBinLabel(3, "MBRejectedDetEvents"); + hCollisionsWeighted->GetXaxis()->SetBinLabel(4, "EventsNotSatisfyingEventSelection"); + hCollisionsWeighted->GetXaxis()->SetBinLabel(5, "EMCreadoutDetJJEventsWithkTVXinEMC"); + hCollisionsWeighted->GetXaxis()->SetBinLabel(6, "AllRejectedEventsAfterEMCEventSelection"); + hCollisionsWeighted->GetXaxis()->SetBinLabel(7, "EMCAcceptedWeightedDetColl"); + hCollisionsWeighted->GetXaxis()->SetBinLabel(8, "EMCAcceptedWeightedCollAfterTrackSel"); + } + + if (doprocessJetsData || doprocessJetsMCD || doprocessJetsMCDWeighted) { + auto hDetcollisionCounter = registry.get(HIST("hDetcollisionCounter")); + hDetcollisionCounter->GetXaxis()->SetBinLabel(1, "allDetColl"); + hDetcollisionCounter->GetXaxis()->SetBinLabel(2, "DetCollWithVertexZ"); + hDetcollisionCounter->GetXaxis()->SetBinLabel(3, "RejectedDetCollWithOutliers"); + hDetcollisionCounter->GetXaxis()->SetBinLabel(4, "MBRejectedDetEvents"); + hDetcollisionCounter->GetXaxis()->SetBinLabel(5, "EventsNotSatisfyingEventSelection"); + hDetcollisionCounter->GetXaxis()->SetBinLabel(6, "EMCreadoutDetEventsWithkTVXinEMC"); + hDetcollisionCounter->GetXaxis()->SetBinLabel(7, "AllRejectedEventsAfterEMCEventSelection"); + hDetcollisionCounter->GetXaxis()->SetBinLabel(8, "EMCAcceptedDetColl"); + } + + if (doprocessJetsMCP || doprocessJetsMCPWeighted) { + auto hPartcollisionCounter = registry.get(HIST("hPartcollisionCounter")); + hPartcollisionCounter->GetXaxis()->SetBinLabel(1, "allMcColl"); + hPartcollisionCounter->GetXaxis()->SetBinLabel(2, "McCollWithVertexZ"); + hPartcollisionCounter->GetXaxis()->SetBinLabel(3, "PartCollWithSize>1"); + hPartcollisionCounter->GetXaxis()->SetBinLabel(4, "RejectedPartCollForDetCollWithSize0"); + hPartcollisionCounter->GetXaxis()->SetBinLabel(5, "RejectedPartCollWithOutliers"); + hPartcollisionCounter->GetXaxis()->SetBinLabel(6, "MBRejectedPartEvents"); + hPartcollisionCounter->GetXaxis()->SetBinLabel(7, "EMCreadoutDetJJEventsWithkTVXinEMC"); + hPartcollisionCounter->GetXaxis()->SetBinLabel(8, "AllRejectedPartEventsAfterEMCEventSelection"); + hPartcollisionCounter->GetXaxis()->SetBinLabel(9, "EMCAcceptedPartColl"); + } + + if (doprocessJetsMCPMCDMatched || doprocessJetsMCPMCDMatchedWeighted) { + auto hMatchedcollisionCounter = registry.get(HIST("hMatchedcollisionCounter")); + hMatchedcollisionCounter->GetXaxis()->SetBinLabel(1, "allDetColl"); + hMatchedcollisionCounter->GetXaxis()->SetBinLabel(2, "DetCollWithVertexZ"); + hMatchedcollisionCounter->GetXaxis()->SetBinLabel(3, "RejectedDetCollWithOutliers"); + hMatchedcollisionCounter->GetXaxis()->SetBinLabel(4, "RejectedPartCollWithOutliers"); + hMatchedcollisionCounter->GetXaxis()->SetBinLabel(5, "EMCMBRejectedDetColl"); + hMatchedcollisionCounter->GetXaxis()->SetBinLabel(6, "EventsNotSatisfyingEventSelection"); + hMatchedcollisionCounter->GetXaxis()->SetBinLabel(7, "EMCreadoutDetJJEventsWithkTVXinEMC"); + hMatchedcollisionCounter->GetXaxis()->SetBinLabel(8, "AllRejectedDetEventsAfterEMCEventSelection"); + hMatchedcollisionCounter->GetXaxis()->SetBinLabel(9, "EMCAcceptedDetColl"); + } + + if (doprocessMBCollisionsDATAWithMultiplicity || doprocessMBCollisionsWithMultiplicity || doprocessCollisionsWeightedWithMultiplicity) { + auto hEventmultiplicityCounter = registry.get(HIST("hEventmultiplicityCounter")); + hEventmultiplicityCounter->GetXaxis()->SetBinLabel(1, "allDetColl"); + hEventmultiplicityCounter->GetXaxis()->SetBinLabel(2, "DetCollWithVertexZ"); + hEventmultiplicityCounter->GetXaxis()->SetBinLabel(3, "MBRejectedDetEvents"); + hEventmultiplicityCounter->GetXaxis()->SetBinLabel(4, "EventsNotSatisfyingEventSelection"); + hEventmultiplicityCounter->GetXaxis()->SetBinLabel(5, "EMCreadoutDetEventsWithkTVXinEMC"); + hEventmultiplicityCounter->GetXaxis()->SetBinLabel(6, "AllRejectedEventsAfterEMCEventSelection"); + hEventmultiplicityCounter->GetXaxis()->SetBinLabel(7, "EMCAcceptedDetColl"); + } + } + + // Add Bin Labels for the MC Split Event Counter + /* void labelMCSplitHistogram(HistogramRegistry& registry) { + auto hSpliteventSelector = registry.get(HIST("hSpliteventSelector")); + hSpliteventSelector->GetXaxis()->SetBinLabel(1, "MCD"); + hSpliteventSelector->GetXaxis()->SetBinLabel(2, "MCP"); + hSpliteventSelector->GetXaxis()->SetBinLabel(3, "MatchedforRM"); +} +*/ + void init(o2::framework::InitContext&) + { + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + particleSelection = static_cast(particleSelections); + jetRadiiValues = (std::vector)jetRadii; + + /* if (doMcClosure) { + // randGen.SetSeed(mcSplitSeed); + // randGen.SetSeed(static_cast(std::time(nullptr))); + // int seed = mcSplitSeed >= 0 ? mcSplitSeed : static_cast(std::time(nullptr)); + // randGen.SetSeed(seed); + // LOGF(info, "MC closure seed = %d", seed); + + int seed = mcSplitSeed >= 0 ? mcSplitSeed : static_cast(std::time(nullptr)); + randGen.SetSeed(seed); + LOGF(info, "MC closure splitting enabled with seed = %d, split fraction = %.2f", seed, static_cast(mcClosureSplitFrac)); + + registry.add("hSpliteventSelector", "Random MC Split Selector;Split Type;Entries",{HistType::kTH1F, {{3, 0.0, 3.0}}}); // 0=MCD, 1=MCP, 2=RM + + //individual processes' event counters for sanity checks + registry.add("h_MCD_splitevent_counter", "Events into MCD split", {HistType::kTH1F, {{1, 0.0, 1.0}}}); + registry.add("h_MCP_splitevent_counter", "Events into MCP split", {HistType::kTH1F, {{1, 0.0, 1.0}}}); + registry.add("h_Matched_splitevent_counter", "Events into Matched split", {HistType::kTH1F, {{1, 0.0, 1.0}}}); + registry.add("hRandomValueDebug", "Random values for debugging;Random Value;Entries", {HistType::kTH1F, {{100, 0.0, 1.0}}}); + + // DEBUG: Add counters for total events processed (before splitting) + registry.add("h_MCD_total_events", "Total MCD events processed", {HistType::kTH1F, {{1, 0.0, 1.0}}}); + registry.add("h_MCP_total_events", "Total MCP events processed", {HistType::kTH1F, {{1, 0.0, 1.0}}}); + registry.add("h_Matched_total_events", "Total Matched events processed", {HistType::kTH1F, {{1, 0.0, 1.0}}}); + registry.add("hMCCollisionIdDebug_MCP", "MC Collision Ids being processed", {HistType::kTH1F, {{100000, 0.0, 100000.0}}}); + + } + */ + for (std::size_t iJetRadius = 0; iJetRadius < jetRadiiValues.size(); iJetRadius++) { + filledJetR.push_back(0.0); + } + auto jetRadiiBins = (std::vector)jetRadii; + if (jetRadiiBins.size() > 1) { + jetRadiiBins.push_back(jetRadiiBins[jetRadiiBins.size() - 1] + (std::abs(jetRadiiBins[jetRadiiBins.size() - 1] - jetRadiiBins[jetRadiiBins.size() - 2]))); + } else { + jetRadiiBins.push_back(jetRadiiBins[jetRadiiBins.size() - 1] + 0.1); + } + + // Track QA histograms + if (doprocessDataTracks || doprocessMCTracks || doprocessTracksWeighted) { + registry.add("hCollisionsUnweighted", "event status; event status;entries", {HistType::kTH1F, {{12, 0., 12.0}}}); + + registry.add("h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + registry.add("h_track_energy", "track energy;Energy of tracks;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + registry.add("h_track_energysum", "track energy sum;Sum of track energy per event;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + + // Cluster QA histograms + registry.add("h_clusterTime", "Time of cluster", HistType::kTH1F, {{500, -250, 250, "#it{t}_{cls} (ns)"}}); + registry.add("h_cluster_pt", "cluster pT;#it{p}_{T_cluster} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); + registry.add("h_cluster_eta", "cluster #eta;#eta_{cluster};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_cluster_phi", "cluster #varphi;#varphi_{cluster};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + registry.add("h_cluster_energy", "cluster energy;Energy of cluster;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + registry.add("h_cluster_energysum", "cluster energy sum;Sum of cluster energy per event;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + + if (doprocessTracksWeighted) { + registry.add("hCollisionsWeighted", "event status;event status;entries", {HistType::kTH1F, {{12, 0.0, 12.0}}}); + } + } + + // Jet QA histograms + if (doprocessJetsData || doprocessJetsMCD || doprocessJetsMCDWeighted) { + + registry.add("hDetcollisionCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.}}}); + + registry.add("h_full_jet_pt", "#it{p}_{T,jet};#it{p}_{T_jet} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_full_jet_pt_pTHatcut", "#it{p}_{T,jet};#it{p}_{T_jet} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_full_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_full_jet_phi", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + registry.add("h_full_jet_clusterTime", "Time of cluster", HistType::kTH1F, {{500, -250, 250, "#it{t}_{cls} (ns)"}}); + registry.add("h2_full_jet_nef", "#it{p}_{T,jet} vs nef at Det Level; #it{p}_{T,jet} (GeV/#it{c});nef", {HistType::kTH2F, {{350, 0., 350.}, {105, 0., 1.05}}}); + registry.add("h2_full_jet_nef_rejected", "#it{p}_{T,jet} vs nef at Det Level for rejected events; #it{p}_{T,jet} (GeV/#it{c});nef", {HistType::kTH2F, {{350, 0., 350.}, {105, 0., 1.05}}}); + + registry.add("h_Detjet_ntracks", "#it{p}_{T,track};#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h2_full_jet_chargedconstituents", "Number of charged constituents at Det Level;#it{p}_{T,jet} (GeV/#it{c});N_{ch}", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); + registry.add("h2_full_jet_neutralconstituents", "Number of neutral constituents at Det Level;#it{p}_{T,jet} (GeV/#it{c});N_{ne}", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); + registry.add("h_full_jet_chargedconstituents_pt", "track pT;#it{p}^{T,jet}_{track} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_full_jet_chargedconstituents_eta", "track #eta;#eta^{jet}_{track};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_full_jet_chargedconstituents_phi", "track #varphi;#varphi^{jet}_{track};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + registry.add("h_full_jet_chargedconstituents_energy", "track energy;Energy of tracks;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + registry.add("h_full_jet_chargedconstituents_energysum", "track energy sum;Sum of track energy per event;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + registry.add("h_full_jet_neutralconstituents_pt", "cluster pT;#it{p}^{T,jet}_{cluster} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); + registry.add("h_full_jet_neutralconstituents_eta", "cluster #eta;#eta^{jet}_{cluster};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_full_jet_neutralconstituents_phi", "cluster #varphi;#varphi^{jet}_{cluster};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + registry.add("h_full_jet_neutralconstituents_energy", "cluster energy;Energy of cluster;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + registry.add("h_full_jet_neutralconstituents_energysum", "cluster energy sum;Sum of cluster energy per event;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + registry.add("h2_full_jettrack_pt", "#it{p}_{T,jet} vs #it{p}_{T,track}; #it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {{350, 0., 350.}, {200, 0., 200.}}}); + registry.add("h2_full_jettrack_eta", "jet #eta vs jet_track #eta; #eta_{jet};#eta_{track}", {HistType::kTH2F, {{100, -1., 1.}, {500, -5., 5.}}}); + registry.add("h2_full_jettrack_phi", "jet #varphi vs jet_track #varphi; #varphi_{jet}; #varphi_{track}", {HistType::kTH2F, {{160, 0., 7.}, {160, -1., 7.}}}); + + registry.add("h2_track_etaphi", "jet_track #eta vs jet_track #varphi; #eta_{track};#varphi_{track}", {HistType::kTH2F, {{500, -5., 5.}, {160, -1., 7.}}}); + registry.add("h2_jet_etaphi", "jet #eta vs jet #varphi; #eta_{jet};#varphi_{jet}", {HistType::kTH2F, {{100, -1., 1.}, {160, -1., 7.}}}); + } + if (doprocessJetsMCP || doprocessJetsMCPWeighted) { + registry.add("hPartcollisionCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + + registry.add("h_full_mcpjet_tablesize", "", {HistType::kTH1F, {{4, 0., 5.}}}); + registry.add("h_full_mcpjet_ntracks", "", {HistType::kTH1F, {{200, -0.5, 200.}}}); + registry.add("h_full_jet_pt_part", "jet pT;#it{p}_{T_jet} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_full_jet_eta_part", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_full_jet_phi_part", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + registry.add("h2_full_jet_nef_part", "#it{p}_{T,jet} vs nef at Part Level;#it{p}_{T,jet} (GeV/#it{c});nef", {HistType::kTH2F, {{350, 0., 350.}, {105, 0., 1.05}}}); + + registry.add("h_Partjet_ntracks", "#it{p}_{T,constituent};#it{p}_{T_constituent} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h2_full_jet_chargedconstituents_part", "Number of charged constituents at Part Level;#it{p}_{T,jet} (GeV/#it{c});N_{ch}", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); + registry.add("h2_full_jet_neutralconstituents_part", "Number of neutral constituents at Part Level;#it{p}_{T,jet} (GeV/#it{c});N_{ne}", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); + registry.add("h_full_jet_neutralconstituents_pt_part", "#it{p}_{T} of neutral constituents at Part Level;#it{p}_{T,ne} (GeV/#it{c}); entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_full_jet_neutralconstituents_eta_part", "#eta of neutral constituents at Part Level;#eta_{ne};entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_full_jet_neutralconstituents_phi_part", "#varphi of neutral constituents at Part Level;#varphi_{ne};entries", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_full_jet_neutralconstituents_energy_part", "neutral constituents' energy;Energy of neutral constituents;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + registry.add("h_full_jet_neutralconstituents_energysum_part", "neutral constituents' energy sum;Sum of neutral constituents' energy per event;entries", {HistType::kTH1F, {{400, 0., 400.}}}); + + registry.add("h2_jettrack_pt_part", "#it{p}_{T,jet} vs #it{p}_{T_track}; #it{p}_{T_jet} (GeV/#it{c});#it{p}_{T_track} (GeV/#it{c})", {HistType::kTH2F, {{350, 0., 350.}, {200, 0., 200.}}}); + registry.add("h2_jettrack_eta_part", "jet #eta vs jet_track #eta; #eta_{jet};#eta_{track}", {HistType::kTH2F, {{100, -1., 1.}, {500, -5., 5.}}}); + registry.add("h2_jettrack_phi_part", "jet #varphi vs jet_track #varphi; #varphi_{jet}; #varphi_{track}", {HistType::kTH2F, {{160, 0., 7.}, {160, -1., 7.}}}); + + registry.add("h2_track_etaphi_part", "jet_track #eta vs jet_track #varphi; #eta_{track};#varphi_{track}", {HistType::kTH2F, {{500, -5., 5.}, {160, -1., 7.}}}); + registry.add("h2_jet_etaphi_part", "jet #eta vs jet #varphi; #eta_{jet};#varphi_{jet}", {HistType::kTH2F, {{100, -1., 1.}, {160, -1., 7.}}}); + + // registry.add("h_NOmcpemcalcollisions", "event status;entries", {HistType::kTH1F, {{100, 0., 100.}}}); + // registry.add("h_mcpemcalcollisions", "event status;entries", {HistType::kTH1F, {{100, 0., 100.}}}); + registry.add("h2_full_mcpjetOutsideFiducial_pt", "MCP jet outside EMC Fiducial Acceptance #it{p}_{T,part};#it{p}_{T,part} (GeV/c); Ncounts", {HistType::kTH2F, {{350, 0., 350.}, {10000, 0., 10000.}}}); + registry.add("h_full_mcpjetOutside_eta_part", "MCP jet #eta outside EMC Fiducial Acceptance;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_full_mcpjetOutside_phi_part", "MCP jet #varphi outside EMC Fiducial Acceptance;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + registry.add("h2_full_mcpjetInsideFiducial_pt", "MCP jet #it{p}_{T,part} inside EMC Fiducial Acceptance;#it{p}_{T,part} (GeV/c); Ncounts", {HistType::kTH2F, {{350, 0., 350.}, {10000, 0., 10000.}}}); + registry.add("h_full_mcpjetInside_eta_part", "MCP jet #eta inside EMC Fiducial Acceptance;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_full_mcpjetInside_phi_part", "MCP jet #varphi inside EMC Fiducial Acceptance;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + } + + if (doprocessJetsMCPMCDMatched || doprocessJetsMCPMCDMatchedWeighted) { + registry.add("hMatchedcollisionCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + + registry.add("h_full_matchedmcdjet_tablesize", "", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_full_matchedmcpjet_tablesize", "", {HistType::kTH1F, {{350, 0., 350.}}}); + registry.add("h_full_matchedmcdjet_ntracks", "", {HistType::kTH1F, {{200, -0.5, 200.}}}); + registry.add("h_full_matchedmcpjet_ntracks", "", {HistType::kTH1F, {{200, -0.5, 200.}}}); + registry.add("h_full_matchedmcdjet_eta", "Matched MCD jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_full_matchedmcdjet_phi", "Matched MCD jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + registry.add("h_full_matchedmcpjet_eta", "Matched MCP jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_full_matchedmcpjet_phi", "Matched MCP jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); + registry.add("h_full_jet_deltaR", "Distance between matched Det Jet and Part Jet; #Delta R; entries", {HistType::kTH1F, {{100, 0., 1.}}}); + + registry.add("h2_full_jet_energyscaleDet", "Jet Energy Scale (det); p_{T,det} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F, {{400, 0., 400.}, {200, -1., 1.}}}); + + registry.add("h2_matchedjet_etaphiDet", "Det jet #eta vs jet #varphi; #eta_{jet};#varphi_{jet}", {HistType::kTH2F, {{100, -1., 1.}, {160, -1., 7.}}}); + registry.add("h2_matchedjet_etaphiPart", "Part jet #eta vs jet #varphi; #eta_{jet};#varphi_{jet}", {HistType::kTH2F, {{100, -1., 1.}, {160, -1., 7.}}}); + registry.add("h2_matchedjet_deltaEtaCorr", "Correlation between Det Eta and Part Eta; #eta_{jet,det}; #eta_{jet,part}", {HistType::kTH2F, {{100, -1., 1.}, {100, -1., 1.}}}); + registry.add("h2_matchedjet_deltaPhiCorr", "Correlation between Det Phi and Part Phi; #varphi_{jet,det}; #varphi_{jet,part}", {HistType::kTH2F, {{160, 0., 7.}, {160, 0., 7.}}}); + + registry.add("h2_full_jet_energyscalePart", "Jet Energy Scale (part); p_{T,part} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F, {{400, 0., 400.}, {200, -1., 1.}}}); + registry.add("h3_full_jet_energyscalePart", "R dependence of Jet Energy Scale (Part); #it{R}_{jet};p_{T,det} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, 0., 400.}, {200, -1., 1.}}}); + registry.add("h2_full_jet_etaresolutionPart", ";p_{T,part} (GeV/c); (#eta_{jet,det} - #eta_{jet,part})/#eta_{jet,part}", {HistType::kTH2F, {{400, 0., 400.}, {100, -1., 1.}}}); + registry.add("h2_full_jet_phiresolutionPart", ";p_{T,part} (GeV/c); (#varphi_{jet,det} - #varphi_{jet,part})/#varphi_{jet,part}", {HistType::kTH2F, {{400, 0., 400.}, {160, -1., 7.}}}); + registry.add("h2_full_jet_energyscaleChargedPart", "Jet Energy Scale (charged part); p_{T,part} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F, {{400, 0., 400.}, {200, -1., 1.}}}); + registry.add("h2_full_jet_energyscaleNeutralPart", "Jet Energy Scale (neutral part); p_{T,part} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F, {{400, 0., 400.}, {200, -1., 1.}}}); + registry.add("h2_full_jet_energyscaleChargedVsFullPart", "Jet Energy Scale (charged part, vs. full jet pt); p_{T,part} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F, {{400, 0., 400.}, {200, -1., 1.}}}); + registry.add("h2_full_jet_energyscaleNeutralVsFullPart", "Jet Energy Scale (neutral part, vs. full jet pt); p_{T,part} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F, {{400, 0., 400.}, {200, -1., 1.}}}); + registry.add("h2_full_fakemcdjets", "Fake MCD Jets; p_{T,det} (GeV/c); NCounts", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); + registry.add("h2FullfakeMcpJets", "Fake MCP Jets; p_{T,part} (GeV/c); NCounts", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); + registry.add("h2_full_matchedmcpjet_pt", "Matched MCP jet in EMC Fiducial Acceptance #it{p}_{T,part};#it{p}_{T,part} (GeV/c); Ncounts", {HistType::kTH2F, {{350, 0., 350.}, {10000, 0., 10000.}}}); + + // Response Matrix + registry.add("h_full_jet_ResponseMatrix", "Full Jets Response Matrix; p_{T,det} (GeV/c); p_{T,part} (GeV/c)", {HistType::kTH2F, {{350, 0., 350.}, {350, 0., 350.}}}); + } + + if (doprocessCollisionsWeightedWithMultiplicity || doprocessMBCollisionsWithMultiplicity || doprocessMBCollisionsDATAWithMultiplicity) { + registry.add("hEventmultiplicityCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.add("h_FT0Mults_occupancy", "", {HistType::kTH1F, {{3500, 0., 3500.}}}); + registry.add("h2_full_jet_FT0Amplitude", "; FT0C Amplitude; Counts", {HistType::kTH1F, {{3500, 0., 3500.}}}); + registry.add("h2_full_jet_jetpTDetVsFT0Mults", "; p_{T,det} (GeV/c); FT0C Multiplicity", {HistType::kTH2F, {{350, 0., 350.}, {3500, 0., 3500.}}}); + registry.add("h3_full_jet_jetpTDet_FT0Mults_nef", "; p_{T,det} (GeV/c); FT0C Multiplicity, nef", {HistType::kTH3F, {{350, 0., 350.}, {3500, 0., 3500.}, {105, 0.0, 1.05}}}); + } + + // Label the histograms + labelCollisionHistograms(registry); + // labelMCSplitHistogram(registry); + + } // init + + // Get or generate random value for a specific MC collision + /* float getMCCollisionRandomValue(int64_t mcCollisionId) { + if (!doMcClosure) return 0.0f; + + // Check if I already have a random value for this MC collision + auto it = mcCollisionRandomValues.find(mcCollisionId); + if (it != mcCollisionRandomValues.end()) { + LOGF(debug, "Using cached random value %.4f for MC collision %lld", it->second, mcCollisionId); + return it->second; + } + + // Generate new random value for this MC collision + float randomVal = randGen.Uniform(0.0, 1.0); + mcCollisionRandomValues[mcCollisionId] = randomVal; + + // Debug histogram + registry.fill(HIST("hRandomValueDebug"), randomVal); + + LOGF(info, "Generated NEW random value %.4f for MC collision %lld", randomVal, mcCollisionId); + return randomVal; + } + */ + using EMCCollisionsData = o2::soa::Join; // JetCollisions with EMCAL Collision Labels + using EMCCollisionsMCD = o2::soa::Join; // where, JetCollisionsMCD = JetCollisions+JMcCollisionLbs + + using FullJetTableDataJoined = soa::Join; + using JetTableMCDJoined = soa::Join; + using JetTableMCDWeightedJoined = soa::Join; + using JetTableMCPJoined = soa::Join; + using JetTableMCPWeightedJoined = soa::Join; + + using JetTableMCDMatchedJoined = soa::Join; + using jetMcpPerMcCollision = soa::Join; + + using JetTableMCDMatchedWeightedJoined = soa::Join; + using JetTableMCPMatchedWeightedJoined = soa::Join; + + // Applying some cuts(filters) on collisions, tracks, clusters + + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); + // Filter EMCeventCuts = (nabs(aod::collision::posZ) < vertexZCut && aod::collision::v >= centralityMin && aod::collision::centFT0M < centralityMax); + Filter trackCuts = (aod::jtrack::pt >= trackpTMin && aod::jtrack::pt < trackpTMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax && aod::jtrack::phi >= trackPhiMin && aod::jtrack::phi <= trackPhiMax); + aod::EMCALClusterDefinition clusterDefinition = aod::emcalcluster::getClusterDefinitionFromString(clusterDefinitionS.value); + Filter clusterFilter = (aod::jcluster::definition == static_cast(clusterDefinition) && aod::jcluster::eta > clusterEtaMin && aod::jcluster::eta < clusterEtaMax && aod::jcluster::phi >= clusterPhiMin && aod::jcluster::phi <= clusterPhiMax && aod::jcluster::energy >= clusterEnergyMin && aod::jcluster::time > clusterTimeMin && aod::jcluster::time < clusterTimeMax && (clusterRejectExotics && aod::jcluster::isExotic != true)); + Preslice JetMCPPerMcCollision = aod::jet::mcCollisionId; + PresliceUnsorted> CollisionsPerMCPCollision = aod::jmccollisionlb::mcCollisionId; + + template + bool isAcceptedJet(U const& jet) + { + + if (jetAreaFractionMin > kJetAreaFractionMinThreshold) { + if (jet.area() < jetAreaFractionMin * o2::constants::math::PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { + return false; + } + } + if (leadingConstituentPtMin > kLeadingConstituentPtMinThreshold) { + bool isMinleadingConstituent = false; + for (const auto& constituent : jet.template tracks_as()) { + if (constituent.pt() >= leadingConstituentPtMin) { + isMinleadingConstituent = true; + break; + } + } + + if (!isMinleadingConstituent) { + return false; + } + } + return true; + } + template + void fillJetHistograms(T const& jet, float weight = 1.0) + { + float neutralEnergy = 0.0; + double sumtrackE = 0.0; + if (jet.r() == round(selectedJetsRadius * 100.0f)) { + registry.fill(HIST("h_full_jet_pt"), jet.pt(), weight); + registry.fill(HIST("h_full_jet_eta"), jet.eta(), weight); + registry.fill(HIST("h_full_jet_phi"), jet.phi(), weight); + registry.fill(HIST("h2_jet_etaphi"), jet.eta(), jet.phi(), weight); + + for (const auto& cluster : jet.template clusters_as()) { + registry.fill(HIST("h2_full_jet_neutralconstituents"), jet.pt(), jet.clustersIds().size(), weight); + + neutralEnergy += cluster.energy(); + double clusterpt = cluster.energy() / std::cosh(cluster.eta()); + registry.fill(HIST("h_full_jet_clusterTime"), cluster.time(), weight); + registry.fill(HIST("h_full_jet_neutralconstituents_pt"), clusterpt, weight); + registry.fill(HIST("h_full_jet_neutralconstituents_eta"), cluster.eta(), weight); + registry.fill(HIST("h_full_jet_neutralconstituents_phi"), cluster.phi(), weight); + registry.fill(HIST("h_full_jet_neutralconstituents_energy"), cluster.energy(), weight); + registry.fill(HIST("h_full_jet_neutralconstituents_energysum"), neutralEnergy, weight); + } + auto nef = neutralEnergy / jet.energy(); + registry.fill(HIST("h2_full_jet_nef"), jet.pt(), nef, weight); + + for (const auto& jettrack : jet.template tracks_as()) { + sumtrackE += jettrack.energy(); + + registry.fill(HIST("h_Detjet_ntracks"), jettrack.pt(), weight); + registry.fill(HIST("h2_full_jet_chargedconstituents"), jet.pt(), jet.tracksIds().size(), weight); + registry.fill(HIST("h2_full_jettrack_pt"), jet.pt(), jettrack.pt(), weight); + registry.fill(HIST("h2_full_jettrack_eta"), jet.eta(), jettrack.eta(), weight); + registry.fill(HIST("h2_full_jettrack_phi"), jet.phi(), jettrack.phi(), weight); + + registry.fill(HIST("h2_track_etaphi"), jettrack.eta(), jettrack.phi(), weight); + registry.fill(HIST("h_full_jet_chargedconstituents_pt"), jettrack.pt(), weight); + registry.fill(HIST("h_full_jet_chargedconstituents_eta"), jettrack.eta(), weight); + registry.fill(HIST("h_full_jet_chargedconstituents_phi"), jettrack.phi(), weight); + registry.fill(HIST("h_full_jet_chargedconstituents_energy"), jettrack.energy(), weight); + registry.fill(HIST("h_full_jet_chargedconstituents_energysum"), sumtrackE, weight); + } + } // jet.r() + } + + // check for nef distribution for rejected events + template + void fillRejectedJetHistograms(T const& jet, float weight = 1.0) + { + float neutralEnergy = 0.0; + if (jet.r() == round(selectedJetsRadius * 100.0f)) { + for (const auto& cluster : jet.template clusters_as()) { + neutralEnergy += cluster.energy(); + } + auto nef = neutralEnergy / jet.energy(); + registry.fill(HIST("h2_full_jet_nef_rejected"), jet.pt(), nef, weight); + } // jet.r() + } + + template + void fillMCPHistograms(T const& jet, float weight = 1.0) + { + float neutralEnergy = 0.0; + int neutralconsts = 0; + int chargedconsts = 0; + int mcpjetOutsideFid = 0; + int mcpjetInsideFid = 0; + + auto isInFiducial = [&](auto const& jet) { + return jet.eta() >= jetEtaMin && jet.eta() <= jetEtaMax && + jet.phi() >= jetPhiMin && jet.phi() <= jetPhiMax; + }; + + if (jet.r() == round(selectedJetsRadius * 100.0f)) { + registry.fill(HIST("h_full_mcpjet_tablesize"), jet.size(), weight); + registry.fill(HIST("h_full_mcpjet_ntracks"), jet.tracksIds().size(), weight); + registry.fill(HIST("h_full_jet_pt_part"), jet.pt(), weight); + registry.fill(HIST("h_full_jet_eta_part"), jet.eta(), weight); + registry.fill(HIST("h_full_jet_phi_part"), jet.phi(), weight); + registry.fill(HIST("h2_jet_etaphi_part"), jet.eta(), jet.phi(), weight); + + if (!isInFiducial(jet)) { + // jet is outside + mcpjetOutsideFid++; + registry.fill(HIST("h2_full_mcpjetOutsideFiducial_pt"), jet.pt(), mcpjetOutsideFid, weight); + registry.fill(HIST("h_full_mcpjetOutside_eta_part"), jet.eta(), weight); + registry.fill(HIST("h_full_mcpjetOutside_phi_part"), jet.phi(), weight); + } else { + // jet is inside + mcpjetInsideFid++; + registry.fill(HIST("h2_full_mcpjetInsideFiducial_pt"), jet.pt(), mcpjetInsideFid, weight); + registry.fill(HIST("h_full_mcpjetInside_eta_part"), jet.eta(), weight); + registry.fill(HIST("h_full_mcpjetInside_phi_part"), jet.phi(), weight); + } + + for (const auto& constituent : jet.template tracks_as()) { + auto pdgParticle = pdgDatabase->GetParticle(constituent.pdgCode()); + if (pdgParticle->Charge() == 0) { + neutralconsts++; + neutralEnergy += constituent.e(); // neutral jet constituents at particle level + double clusterpt = constituent.e() / std::cosh(constituent.eta()); + registry.fill(HIST("h2_full_jet_neutralconstituents_part"), jet.pt(), neutralconsts, weight); + registry.fill(HIST("h_full_jet_neutralconstituents_pt_part"), clusterpt, weight); + registry.fill(HIST("h_full_jet_neutralconstituents_eta_part"), constituent.eta(), weight); + registry.fill(HIST("h_full_jet_neutralconstituents_phi_part"), constituent.phi(), weight); + registry.fill(HIST("h_full_jet_neutralconstituents_energy_part"), constituent.e(), weight); + registry.fill(HIST("h_full_jet_neutralconstituents_energysum_part"), neutralEnergy, weight); + + } else { + chargedconsts++; + registry.fill(HIST("h2_full_jet_chargedconstituents_part"), jet.pt(), chargedconsts, weight); // charged jet constituents at particle level + registry.fill(HIST("h2_jettrack_pt_part"), jet.pt(), constituent.pt(), weight); + registry.fill(HIST("h2_jettrack_eta_part"), jet.eta(), constituent.eta(), weight); + registry.fill(HIST("h2_jettrack_phi_part"), jet.phi(), constituent.phi(), weight); + registry.fill(HIST("h2_track_etaphi_part"), constituent.eta(), constituent.phi(), weight); + } + } // constituent loop + auto nef = neutralEnergy / jet.energy(); + registry.fill(HIST("h2_full_jet_nef_part"), jet.pt(), nef, weight); + } // jet.r() + } + + template + void fillTrackHistograms(T const& tracks, U const& clusters, float weight = 1.0) + { + double sumtrackE = 0.0; + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + sumtrackE += track.energy(); + registry.fill(HIST("h_track_pt"), track.pt(), weight); + registry.fill(HIST("h_track_eta"), track.eta(), weight); + registry.fill(HIST("h_track_phi"), track.phi(), weight); + registry.fill(HIST("h_track_energysum"), sumtrackE, weight); + } + double sumclusterE = 0.0; + for (auto const& cluster : clusters) { + double clusterpt = cluster.energy() / std::cosh(cluster.eta()); + sumclusterE += cluster.energy(); + + registry.fill(HIST("h_clusterTime"), cluster.time(), weight); + registry.fill(HIST("h_cluster_pt"), clusterpt, weight); + registry.fill(HIST("h_cluster_eta"), cluster.eta(), weight); + registry.fill(HIST("h_cluster_phi"), cluster.phi(), weight); + registry.fill(HIST("h_cluster_energy"), cluster.energy(), weight); + registry.fill(HIST("h_cluster_energysum"), sumclusterE, weight); + } + } + + template + void fillMatchedHistograms(T const& jetBase, float weight = 1.0) + { + if (jetBase.has_matchedJetGeo()) { // geometrical jet matching only needed for pp - here,matching Base(Det.level) with Tag (Part. level) jets + registry.fill(HIST("h_full_matchedmcdjet_tablesize"), jetBase.size(), weight); + registry.fill(HIST("h_full_matchedmcdjet_ntracks"), jetBase.tracksIds().size(), weight); + registry.fill(HIST("h2_matchedjet_etaphiDet"), jetBase.eta(), jetBase.phi(), weight); + + for (const auto& jetTag : jetBase.template matchedJetGeo_as>()) { + auto deltaEta = jetBase.eta() - jetTag.eta(); + auto deltaPhi = jetBase.phi() - jetTag.phi(); + auto deltaR = jetutilities::deltaR(jetBase, jetTag); + + registry.fill(HIST("h_full_jet_deltaR"), deltaR, weight); + registry.fill(HIST("h_full_matchedmcpjet_tablesize"), jetTag.size(), weight); + registry.fill(HIST("h_full_matchedmcpjet_ntracks"), jetTag.tracksIds().size(), weight); + registry.fill(HIST("h2_matchedjet_etaphiPart"), jetTag.eta(), jetTag.phi(), weight); + registry.fill(HIST("h2_matchedjet_deltaEtaCorr"), jetBase.eta(), jetTag.eta(), weight); + registry.fill(HIST("h2_matchedjet_deltaPhiCorr"), jetBase.phi(), jetTag.phi(), weight); + + // JES for fulljets + registry.fill(HIST("h2_full_jet_energyscaleDet"), jetBase.pt(), (jetBase.pt() - jetTag.pt()) / jetTag.pt(), weight); + registry.fill(HIST("h2_full_jet_energyscalePart"), jetTag.pt(), (jetBase.pt() - jetTag.pt()) / jetTag.pt(), weight); + registry.fill(HIST("h3_full_jet_energyscalePart"), jetBase.r() / 100.0, jetTag.pt(), (jetBase.pt() - jetTag.pt()) / jetTag.pt(), weight); + registry.fill(HIST("h2_full_jet_etaresolutionPart"), jetTag.pt(), deltaEta / jetTag.eta(), weight); + registry.fill(HIST("h2_full_jet_phiresolutionPart"), jetTag.pt(), deltaPhi / jetTag.phi(), weight); + + // Response Matrix + registry.fill(HIST("h_full_jet_ResponseMatrix"), jetBase.pt(), jetTag.pt(), weight); // MCD vs MCP jet pT + } // jetTag + } // jetBase + } + + void processDummy(aod::JetCollisions const&) + { + } + PROCESS_SWITCH(FullJetSpectra, processDummy, "dummy task", true); + + void processJetsData(soa::Filtered::iterator const& collision, FullJetTableDataJoined const& jets, aod::JetTracks const&, aod::JetClusters const&) + { + bool eventAccepted = false; + + registry.fill(HIST("hDetcollisionCounter"), 0.5); // allDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hDetcollisionCounter"), 1.5); // DetCollWithVertexZ + + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hDetcollisionCounter"), 2.5); // MBRejectedDetEvents + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hDetcollisionCounter"), 3.5); // EventsNotSatisfyingEventSelection + return; + } + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hDetcollisionCounter"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hDetcollisionCounter"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + eventAccepted = true; + } + } + + if (!eventAccepted) { + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax) || !isAcceptedJet(jet)) { + fillRejectedJetHistograms(jet, 1.0); + } + } + registry.fill(HIST("hDetcollisionCounter"), 5.5); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hDetcollisionCounter"), 6.5); // EMCAcceptedDetColl + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (jet.phi() < jetPhiMin || jet.phi() > jetPhiMax) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillJetHistograms(jet); + } + } + PROCESS_SWITCH(FullJetSpectra, processJetsData, "Full Jets Data", false); + + void processJetsMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, aod::JetTracks const&, aod::JetClusters const&) + { + bool eventAccepted = false; + double weight = 1.0; + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + + /* if (doMcClosure) { + // Count total events processed (before splitting decision) + registry.fill(HIST("h_MCD_total_events"), 0.5); + + // DEBUG: Let's verify what collision IDs we're actually seeing + LOGF(info, "[MCD DEBUG] Processing MC collision ID: %lld", collision.mcCollisionId()); + + // Get random value for this MC collision + float eventRandomValue = getMCCollisionRandomValue(collision.mcCollisionId()); + + // MCD gets events with random value <= split fraction (20%) + if (eventRandomValue > mcClosureSplitFrac) { + LOGF(debug, "[MCD] Event REJECTED: rand = %.4f > split = %.2f (MC collision %d)", + eventRandomValue, static_cast(mcClosureSplitFrac), collision.mcCollisionId()); + return; // This event goes to MCP & Matched processes + } + + LOGF(info, "[MCD] Event ACCEPTED: rand = %.4f <= split = %.2f (MC collision %d)", + eventRandomValue, static_cast(mcClosureSplitFrac), collision.mcCollisionId()); + + registry.fill(HIST("hSpliteventSelector"), 0.5); // 20% Closure input for the measured spectra (reco) + registry.fill(HIST("h_MCD_splitevent_counter"), 0.5); + } + */ + registry.fill(HIST("hDetcollisionCounter"), 0.5); // allDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hDetcollisionCounter"), 1.5); // DetCollWithVertexZ + + // outlier check: for every outlier jet, reject the whole event + for (auto const& jet : jets) { + if (jet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { // for MCD jets only to remove outliers; setting pTHatMaxMCD = 1 improves purity + registry.fill(HIST("hDetcollisionCounter"), 2.5); // RejectedDetCollWithOutliers + return; + } + // this cut only to be used for calculating Jet Purity and not for Response Matrix + // this is mainly applied to remove all high weight jets causing big fluctuations + if (jet.pt() > 1 * pTHat) { + registry.fill(HIST("h_full_jet_pt_pTHatcut"), jet.pt(), weight); + } + } + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hDetcollisionCounter"), 3.5); // MBRejectedDetEvents + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hDetcollisionCounter"), 4.5); // EventsNotSatisfyingEventSelection + return; + } + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hDetcollisionCounter"), 5.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hDetcollisionCounter"), 5.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + + if (!eventAccepted) { + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax) || !isAcceptedJet(jet)) { + fillRejectedJetHistograms(jet, 1.0); + } + } + registry.fill(HIST("hDetcollisionCounter"), 6.5); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hDetcollisionCounter"), 7.5); // EMCAcceptedDetColl + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (jet.phi() < jetPhiMin || jet.phi() > jetPhiMax) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillJetHistograms(jet); + } + } + PROCESS_SWITCH(FullJetSpectra, processJetsMCD, "Full Jets at Detector Level", false); + + void processJetsMCDWeighted(soa::Filtered::iterator const& collision, JetTableMCDWeightedJoined const& jets, aod::JMcCollisions const&, aod::JetTracks const&, aod::JetClusters const&) + { + bool eventAccepted = false; + double pTHat = 10. / (std::pow(collision.mcCollision().weight(), 1.0 / pTHatExponent)); + + /* if (doMcClosure) { + // Count total events processed (before splitting decision) + registry.fill(HIST("h_MCD_total_events"), 0.5); + + // DEBUG: Let's verify what collision IDs we're actually seeing + LOGF(info, "[MCD DEBUG] Processing MC collision ID: %lld", collision.mcCollisionId()); + + // Get random value for this MC collision + float eventRandomValue = getMCCollisionRandomValue(collision.mcCollisionId()); + + // MCD gets events with random value <= split fraction (20%) + if (eventRandomValue > mcClosureSplitFrac) { + LOGF(debug, "[MCD] Event REJECTED: rand = %.4f > split = %.2f (MC collision %d)", + eventRandomValue, static_cast(mcClosureSplitFrac), collision.mcCollisionId()); + return; // This event goes to MCP & Matched processes + } + + LOGF(info, "[MCD] Event ACCEPTED: rand = %.4f <= split = %.2f (MC collision %d)", + eventRandomValue, static_cast(mcClosureSplitFrac), collision.mcCollisionId()); + + registry.fill(HIST("hSpliteventSelector"), 0.5); // 20% Closure input for the measured spectra (reco) + registry.fill(HIST("h_MCD_splitevent_counter"), 0.5); + } + */ + registry.fill(HIST("hDetcollisionCounter"), 0.5, collision.mcCollision().weight()); // allDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hDetcollisionCounter"), 1.5, collision.mcCollision().weight()); // DetCollWithVertexZ + // outlier check: for every outlier jet, reject the whole event + for (auto const& jet : jets) { + if (jet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { // for MCD jets only to remove outliers; setting pTHatMaxMCD = 1 improves purity + registry.fill(HIST("hDetcollisionCounter"), 2.5, collision.mcCollision().weight()); // RejectedDetCollWithOutliers + return; + } + // this cut only to be used for calculating Jet Purity and not for Response Matrix + // this is mainly applied to remove all high weight jets causing big fluctuations + if (jet.pt() > 1 * pTHat) { + registry.fill(HIST("h_full_jet_pt_pTHatcut"), jet.pt(), collision.mcCollision().weight()); + } + } + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hDetcollisionCounter"), 3.5, collision.mcCollision().weight()); // MBRejectedDetEvents + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hDetcollisionCounter"), 4.5, collision.mcCollision().weight()); // EventsNotSatisfyingEventSelection + return; + } + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hDetcollisionCounter"), 5.5, collision.mcCollision().weight()); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hDetcollisionCounter"), 5.5, collision.mcCollision().weight()); // EMCreadoutDetEventsWithkTVXinEMC + } + } + + if (!eventAccepted) { + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax) || !isAcceptedJet(jet)) { + fillRejectedJetHistograms(jet, collision.mcCollision().weight()); + } + } + registry.fill(HIST("hDetcollisionCounter"), 6.5, collision.mcCollision().weight()); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hDetcollisionCounter"), 7.5, collision.mcCollision().weight()); // EMCAcceptedDetColl + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (jet.phi() < jetPhiMin || jet.phi() > jetPhiMax) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillJetHistograms(jet, collision.mcCollision().weight()); + } + } + PROCESS_SWITCH(FullJetSpectra, processJetsMCDWeighted, "Full Jets at Detector Level on weighted events", false); + + void processJetsMCP(aod::JetMcCollision const& mccollision, JetTableMCPJoined const& jets, aod::JetParticles const&, soa::SmallGroups const& collisions) + { + bool eventAccepted = false; + double weight = 1.0; + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + + /* if (doMcClosure) { + // Count total events processed (before splitting decision) + registry.fill(HIST("h_MCP_total_events"), 0.5); + + // DEBUG: Let's verify what collision IDs we're actually seeing + LOGF(info, "[MCP DEBUG] Processing MC collision ID: %lld", mccollision.globalIndex()); + + // Get random value for this MC collision + float eventRandomValue = getMCCollisionRandomValue(mccollision.globalIndex()); + + // DEBUG: Track which MC collisions we're processing + registry.fill(HIST("hMCCollisionIdDebug_MCP"), static_cast(mccollision.globalIndex() % 100000)); + + // MCP gets events with random value > split fraction (80%) + if (eventRandomValue <= mcClosureSplitFrac) { + LOGF(debug, "[MCP] Event REJECTED: rand = %.4f <= split = %.2f (MC collision %lld)", + eventRandomValue, static_cast(mcClosureSplitFrac), mccollision.globalIndex()); + return; // This event goes to MCD only + } + + LOGF(info, "[MCP] Event ACCEPTED: rand = %.4f > split = %.2f (MC collision %lld)", + eventRandomValue, static_cast(mcClosureSplitFrac), mccollision.globalIndex()); + + registry.fill(HIST("hSpliteventSelector"), 1.5); // remaining 80% input for MCP + registry.fill(HIST("h_MCP_splitevent_counter"), 0.5); + } + */ + registry.fill(HIST("hPartcollisionCounter"), 0.5); // allMcColl + if (std::fabs(mccollision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hPartcollisionCounter"), 1.5); // McCollWithVertexZ + if (collisions.size() < 1) { + return; + } + registry.fill(HIST("hPartcollisionCounter"), 2.5); // PartCollWithSize>1 + + if (collisions.size() == 0) { + registry.fill(HIST("hPartcollisionCounter"), 3.5); // RejectedPartCollForDetCollWithSize0 + return; + } + + // outlier check: for every outlier jet, reject the whole event + for (auto const& jet : jets) { + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { + registry.fill(HIST("hPartcollisionCounter"), 4.5); // RejectedPartCollWithOutliers + return; + } + } + + if (doMBGapTrigger && mccollision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + // Fill rejected MB events; + registry.fill(HIST("hPartcollisionCounter"), 5.5); // MBRejectedPartEvents + return; + } + + for (auto const& collision : collisions) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + return; + } + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hPartcollisionCounter"), 6.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hPartcollisionCounter"), 6.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } + if (!eventAccepted) { + registry.fill(HIST("hPartcollisionCounter"), 7.5); // AllRejectedPartEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hPartcollisionCounter"), 8.5); // EMCAcceptedWeightedPartColl + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + if (checkMcCollisionIsMatched) { // basically checks if the same collisions are generated at the Part level as those at the Det level + auto collisionspermcpjet = collisions.sliceBy(CollisionsPerMCPCollision, jet.mcCollisionId()); + if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelectionBits)) { + // Now here for every matched collision, I fill the corresponding jet histograms. + fillMCPHistograms(jet); + } + } else { + fillMCPHistograms(jet); + } + } + } + PROCESS_SWITCH(FullJetSpectra, processJetsMCP, "Full Jets at Particle Level", false); + + void processJetsMCPWeighted(aod::JetMcCollision const& mccollision, JetTableMCPWeightedJoined const& jets, aod::JetParticles const&, soa::SmallGroups const& collisions) + { + bool eventAccepted = false; + float pTHat = 10. / (std::pow(mccollision.weight(), 1.0 / pTHatExponent)); + + /* if (doMcClosure) { + // Count total events processed (before splitting decision) + registry.fill(HIST("h_MCP_total_events"), 0.5); + + // DEBUG: Let's verify what collision IDs we're actually seeing + LOGF(info, "[MCP DEBUG] Processing MC collision ID: %lld", mccollision.globalIndex()); + + // Get random value for this MC collision + float eventRandomValue = getMCCollisionRandomValue(mccollision.globalIndex()); + + // DEBUG: Track which MC collisions we're processing + registry.fill(HIST("hMCCollisionIdDebug_MCP"), static_cast(mccollision.globalIndex() % 100000)); + + // MCP gets events with random value > split fraction (80%) + if (eventRandomValue <= mcClosureSplitFrac) { + LOGF(debug, "[MCP] Event REJECTED: rand = %.4f <= split = %.2f (MC collision %lld)", + eventRandomValue, static_cast(mcClosureSplitFrac), mccollision.globalIndex()); + return; // This event goes to MCD only + } + + LOGF(info, "[MCP] Event ACCEPTED: rand = %.4f > split = %.2f (MC collision %lld)", + eventRandomValue, static_cast(mcClosureSplitFrac), mccollision.globalIndex()); + + registry.fill(HIST("hSpliteventSelector"), 1.5); // remaining 80% input for MCP + registry.fill(HIST("h_MCP_splitevent_counter"), 0.5); + } + */ + registry.fill(HIST("hPartcollisionCounter"), 0.5, mccollision.weight()); // allMcColl + if (std::fabs(mccollision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hPartcollisionCounter"), 1.5, mccollision.weight()); // McCollWithVertexZ + if (collisions.size() < 1) { + return; + } + registry.fill(HIST("hPartcollisionCounter"), 2.5, mccollision.weight()); // PartCollWithSize>1 + + if (collisions.size() == 0) { + registry.fill(HIST("hPartcollisionCounter"), 3.5, mccollision.weight()); // RejectedPartCollForDetCollWithSize0 + return; + } + + // outlier check: for every outlier jet, reject the whole event + for (auto const& jet : jets) { + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { + registry.fill(HIST("hPartcollisionCounter"), 4.5, mccollision.weight()); // RejectedPartCollWithOutliers + return; + } + } + + if (doMBGapTrigger && mccollision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + // Fill rejected MB events + registry.fill(HIST("hPartcollisionCounter"), 5.5, mccollision.weight()); // MBRejectedPartEvents + return; + } + + for (auto const& collision : collisions) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + return; + } + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hPartcollisionCounter"), 6.5, mccollision.weight()); // EMCreadoutDetJJEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hPartcollisionCounter"), 6.5, mccollision.weight()); // EMCreadoutDetJJEventsWithkTVXinEMC + } + } + } + if (!eventAccepted) { + registry.fill(HIST("hPartcollisionCounter"), 7.5, mccollision.weight()); // AllRejectedPartEventsAfterEMCEventSelection + return; + } + // Fill EMCAL JJ Part events + registry.fill(HIST("hPartcollisionCounter"), 8.5, mccollision.weight()); // EMCAcceptedWeightedPartColl + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + return; + } + if (!isAcceptedJet(jet)) { + return; + } + if (doMBGapTrigger && jet.eventWeight() == 1) { + return; + } + + if (checkMcCollisionIsMatched) { + auto collisionspermcpjet = collisions.sliceBy(CollisionsPerMCPCollision, jet.mcCollisionId()); + + if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelectionBits)) { + fillMCPHistograms(jet, jet.eventWeight()); + } + } else { + fillMCPHistograms(jet, jet.eventWeight()); + } + } + } + PROCESS_SWITCH(FullJetSpectra, processJetsMCPWeighted, "Full Jets at Particle Level on weighted events", false); + + void processJetsMCPMCDMatched(soa::Filtered::iterator const& collision, JetTableMCDMatchedJoined const& mcdjets, jetMcpPerMcCollision const& mcpjets, aod::JMcCollisions const&, aod::JetTracks const&, aod::JetClusters const&, aod::JetParticles const&) + { + bool eventAccepted = false; + int fakeMcdJet = 0; + int fakeMcpJet = 0; + double weight = 1.0; + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + const auto mcpJetsPerMcCollision = mcpjets.sliceBy(JetMCPPerMcCollision, collision.mcCollisionId()); + + /* if (doMcClosure) { + // Count total events processed (before splitting decision) + registry.fill(HIST("h_Matched_total_events"), 0.5); + + // Use consistent MC collision ID - same as MCD + int64_t mcCollisionId = collision.mcCollisionId(); + + // DEBUG: Let's verify what collision IDs we're actually seeing + LOGF(info, "[Matched DEBUG] Processing MC collision ID: %lld", mcCollisionId); + float eventRandomValue = getMCCollisionRandomValue(mcCollisionId); + + // Matched gets events with random value > split fraction (80%) - same as MCP + if (eventRandomValue <= mcClosureSplitFrac) { + LOGF(debug, "[Matched] Event REJECTED: rand = %.4f <= split = %.2f (MC collision %lld)", + eventRandomValue, static_cast(mcClosureSplitFrac), mcCollisionId); + return; // This event goes to MCD only + } + + LOGF(info, "[Matched] Event ACCEPTED: rand = %.4f > split = %.2f (MC collision %lld)", + eventRandomValue, static_cast(mcClosureSplitFrac), mcCollisionId); + + registry.fill(HIST("hSpliteventSelector"), 2.5); // Bin for Response Matrix + registry.fill(HIST("h_Matched_splitevent_counter"), 0.5); + } + */ + registry.fill(HIST("hMatchedcollisionCounter"), 0.5); // allDetColl + + if (std::fabs(collision.posZ()) > vertexZCut) { // making double sure this condition is satisfied + return; + } + registry.fill(HIST("hMatchedcollisionCounter"), 1.5); // DetCollWithVertexZ + + // outlier check: for every outlier jet, reject the whole event + for (auto const& mcdjet : mcdjets) { + if (mcdjet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { + registry.fill(HIST("hMatchedcollisionCounter"), 2.5); // RejectedDetCollWithOutliers + return; + } + } + // //outlier check for Part collisions: commenting out this for now otherwise this rejects all Det Colls + // for (auto const& mcpjet : mcpjets) { + // if (mcpjet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { + // registry.fill(HIST("hMatchedcollisionCounter"),3.5); //RejectedPartCollWithOutliers + // return; + // } + // } + + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hMatchedcollisionCounter"), 4.5); // EMCMBRejectedDetColl + return; + } + + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hMatchedcollisionCounter"), 5.5); // EventsNotSatisfyingEventSelection + return; + } + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hMatchedcollisionCounter"), 6.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hMatchedcollisionCounter"), 6.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + if (!eventAccepted) { + registry.fill(HIST("hMatchedcollisionCounter"), 7.5); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hMatchedcollisionCounter"), 8.5); // EMCAcceptedDetColl + + for (const auto& mcdjet : mcdjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + // Check if MCD jet is within the EMCAL fiducial region; if not then flag it as a fake jet + if (mcdjet.phi() < jetPhiMin || mcdjet.phi() > jetPhiMax || mcdjet.eta() < jetEtaMin || mcdjet.eta() > jetEtaMax) { + fakeMcdJet++; + registry.fill(HIST("h2_full_fakemcdjets"), mcdjet.pt(), fakeMcdJet, 1.0); + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { + // apply emcal fiducial cuts to the matched particle level jets + if (mcpjet.eta() > jetEtaMax || mcpjet.eta() < jetEtaMin || mcpjet.phi() > jetPhiMax || mcpjet.phi() < jetPhiMin) { + fakeMcpJet++; + registry.fill(HIST("h2_full_fakemcpjets"), mcpjet.pt(), fakeMcpJet, 1.0); + continue; + } + } // mcpjet loop + fillMatchedHistograms(mcdjet); + } // mcdjet loop + } + PROCESS_SWITCH(FullJetSpectra, processJetsMCPMCDMatched, "Full Jet finder MCP matched to MCD", false); + + void processJetsMCPMCDMatchedWeighted(soa::Filtered::iterator const& collision, JetTableMCDMatchedWeightedJoined const& mcdjets, JetTableMCPMatchedWeightedJoined const& mcpjets, aod::JMcCollisions const&, aod::JetTracks const&, aod::JetClusters const&, aod::JetParticles const&) + { + bool eventAccepted = false; + int fakeMcdJet = 0; + int fakeMcpJet = 0; + int NPartJetFid = 0; + float eventWeight = collision.mcCollision().weight(); + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + const auto mcpJetsPerMcCollision = mcpjets.sliceBy(JetMCPPerMcCollision, collision.mcCollisionId()); + + /* if (doMcClosure) { + // Count total events processed (before splitting decision) + registry.fill(HIST("h_Matched_total_events"), 0.5); + + // Use consistent MC collision ID - same as MCD + int64_t mcCollisionId = collision.mcCollisionId(); + + // DEBUG: Let's verify what collision IDs we're actually seeing + LOGF(info, "[Matched DEBUG] Processing MC collision ID: %lld", mcCollisionId); + float eventRandomValue = getMCCollisionRandomValue(mcCollisionId); + + // Matched gets events with random value > split fraction (80%) - same as MCP + if (eventRandomValue <= mcClosureSplitFrac) { + LOGF(debug, "[Matched] Event REJECTED: rand = %.4f <= split = %.2f (MC collision %lld)", + eventRandomValue, static_cast(mcClosureSplitFrac), mcCollisionId); + return; // This event goes to MCD only + } + + LOGF(info, "[Matched] Event ACCEPTED: rand = %.4f > split = %.2f (MC collision %lld)", + eventRandomValue, static_cast(mcClosureSplitFrac), mcCollisionId); + + registry.fill(HIST("hSpliteventSelector"), 2.5); // Bin for Response Matrix + registry.fill(HIST("h_Matched_splitevent_counter"), 0.5); + } + */ + registry.fill(HIST("hMatchedcollisionCounter"), 0.5, eventWeight); // allDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { // making double sure this condition is satisfied + return; + } + registry.fill(HIST("hMatchedcollisionCounter"), 1.5, eventWeight); // DetCollWithVertexZ + + // outlier check: for every outlier jet, reject the whole event + for (auto const& mcdjet : mcdjets) { + if (mcdjet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { + registry.fill(HIST("hMatchedcollisionCounter"), 2.5, eventWeight); // RejectedDetCollWithOutliers + return; + } + } + // outlier check for Part collisions: commenting out this for now otherwise this rejects all Det Colls + // for (auto const& mcpjet : mcpjets) { + // if (mcpjet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { + // registry.fill(HIST("hMatchedcollisionCounter"),3.5, eventWeight); //RejectedPartCollWithOutliers + // return; + // } + // } + + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hMatchedcollisionCounter"), 4.5, eventWeight); // EMCMBRejectedDetColl + return; + } + + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hMatchedcollisionCounter"), 5.5, eventWeight); // EventsNotSatisfyingEventSelection + return; + } + + for (auto const& mcpjet : mcpJetsPerMcCollision) { + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { // outlier rejection for MCP: Should I remove this cut as I'm already doing MC outlier rejection @L1071? + return; + } + } + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hMatchedcollisionCounter"), 6.5, eventWeight); // EMCreadoutDetJJEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hMatchedcollisionCounter"), 6.5, eventWeight); // EMCreadoutDetJJEventsWithkTVXinEMC + } + } + if (!eventAccepted) { + registry.fill(HIST("hMatchedcollisionCounter"), 7.5, eventWeight); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hMatchedcollisionCounter"), 8.5, eventWeight); // EMCAcceptedDetColl + + for (const auto& mcdjet : mcdjets) { + // Check if MCD jet is within the EMCAL fiducial region; if not then flag it as a fake jet + if (mcdjet.phi() < jetPhiMin || mcdjet.phi() > jetPhiMax || mcdjet.eta() < jetEtaMin || mcdjet.eta() > jetEtaMax) { + fakeMcdJet++; + registry.fill(HIST("h2_full_fakemcdjets"), mcdjet.pt(), fakeMcdJet, eventWeight); + continue; + } + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + + for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { + // apply emcal fiducial cuts to the matched particle level jets - if the matched mcp jet lies outside of the EMCAL fiducial, flag it as a fake jet + if (mcpjet.eta() > jetEtaMax || mcpjet.eta() < jetEtaMin || mcpjet.phi() > jetPhiMax || mcpjet.phi() < jetPhiMin) { + fakeMcpJet++; + registry.fill(HIST("h2FullfakeMcpJets"), mcpjet.pt(), fakeMcpJet, eventWeight); + continue; + } else { + NPartJetFid++; + // // If both MCD-MCP matched jet pairs are within the EMCAL fiducial region, fill these histos + registry.fill(HIST("h2_full_matchedmcpjet_pt"), mcpjet.pt(), NPartJetFid, eventWeight); + registry.fill(HIST("h_full_matchedmcpjet_eta"), mcpjet.eta(), eventWeight); + registry.fill(HIST("h_full_matchedmcpjet_phi"), mcpjet.phi(), eventWeight); + } + } // mcpjet + fillMatchedHistograms(mcdjet, eventWeight); + } // mcdjet + } + PROCESS_SWITCH(FullJetSpectra, processJetsMCPMCDMatchedWeighted, "Full Jet finder MCP matched to MCD on weighted events", false); + + // Periodic cleanup to prevent unbounded memory growth + /*void processCleanup(aod::Collision const&) { + static int callCount = 0; + callCount++; + + // Clean up cache every 50000 calls to prevent memory issues + if (doMcClosure && callCount % 50000 == 0 && mcCollisionRandomValues.size() > 20000) { + LOGF(info, "Cleaning up MC collision random values cache (size: %zu)", mcCollisionRandomValues.size()); + mcCollisionRandomValues.clear(); + + // IMPROVEMENT: Add logging to verify our split ratios + float mcdCount = registry.get(HIST("h_MCD_splitevent_counter"))->GetBinContent(1); + float mcpCount = registry.get(HIST("h_MCP_splitevent_counter"))->GetBinContent(1); + float matchedCount = registry.get(HIST("h_Matched_splitevent_counter"))->GetBinContent(1); + + float totalEvents = mcdCount + mcpCount; // MCP and Matched should be the same, so don't double count + float actualSplitFrac = totalEvents > 0 ? mcdCount / totalEvents : 0.0f; + + LOGF(info, "Current split statistics: MCD=%.1f, MCP=%.1f, Matched=%.1f", mcdCount, mcpCount, matchedCount); + LOGF(info, "Actual split fraction: %.3f (target: %.3f)", actualSplitFrac, static_cast(mcClosureSplitFrac)); + } + } + PROCESS_SWITCH(FullJetSpectra, processCleanup, "Periodic cleanup", true); + */ + void processDataTracks(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, soa::Filtered const& clusters) + { + bool eventAccepted = false; + + registry.fill(HIST("hCollisionsUnweighted"), 0.5); // allDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hCollisionsUnweighted"), 1.5); // DetCollWithVertexZ + + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hCollisionsUnweighted"), 2.5); // MBRejectedDetEvents + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hCollisionsUnweighted"), 3.5); // EventsNotSatisfyingEventSelection + return; + } + // needed for the workaround to access EMCAL trigger bits. - This is needed for the MC productions in which the EMC trigger bits are missing. (MB MC LHC24f3, for ex.) + // It first requires for atleast a cell in EMCAL to have energy content. + // Once it finds a cell content, + // it then checks if the collision is not an ambiguous collision (i.e. it has to be a unique collision = no bunch pile up) + // If all of these conditions are satisfied then it checks for the required trigger bit in EMCAL. + // For LHC22o, since the EMCAL didn't have hardware triggers, one would only require MB trigger (kTVXinEMC) in the EMCAL. + + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hCollisionsUnweighted"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } else { + // Check if EMCAL was readout with the MB trigger(kTVXinEMC) fired. If not then reject the event and exit the function. + // This is the default check for the simulations with proper trigger flags not requiring the above workaround. + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hCollisionsUnweighted"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + + if (!eventAccepted) { + registry.fill(HIST("hCollisionsUnweighted"), 5.5); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hCollisionsUnweighted"), 6.5); // EMCAcceptedDetColl + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + // Fill Accepted events histos + fillTrackHistograms(tracks, clusters, 1.0); + } + registry.fill(HIST("hCollisionsUnweighted"), 7.5); // EMCAcceptedCollAfterTrackSel + } + PROCESS_SWITCH(FullJetSpectra, processDataTracks, "Full Jet tracks for Data", false); + + void processMCTracks(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, soa::Filtered const& clusters) + { + bool eventAccepted = false; + double weight = 1.0; + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + + registry.fill(HIST("hCollisionsUnweighted"), 0.5); // allDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hCollisionsUnweighted"), 1.5); // DetCollWithVertexZ + + // for (auto const& track : tracks) { + if (pTHat < pTHatAbsoluteMin) { // Track outlier rejection: should this be for every track iteration or for every collision? + return; + } + // } + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hCollisionsUnweighted"), 2.5); // MBRejectedDetEvents + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hCollisionsUnweighted"), 3.5); // EventsNotSatisfyingEventSelection + return; + } + + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hCollisionsUnweighted"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hCollisionsUnweighted"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + + if (!eventAccepted) { + registry.fill(HIST("hCollisionsUnweighted"), 5.5); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hCollisionsUnweighted"), 6.5); // EMCAcceptedDetColl + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + // Fill Accepted events histos + fillTrackHistograms(tracks, clusters, 1.0); + } + registry.fill(HIST("hCollisionsUnweighted"), 7.5); // EMCAcceptedCollAfterTrackSel + } + PROCESS_SWITCH(FullJetSpectra, processMCTracks, "Full Jet tracks for MC", false); + + void processTracksWeighted(soa::Filtered::iterator const& collision, + aod::JMcCollisions const&, + soa::Filtered const& tracks, + soa::Filtered const& clusters) + { + bool eventAccepted = false; + float eventWeight = collision.mcCollision().weight(); + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + + registry.fill(HIST("hCollisionsWeighted"), 0.5, eventWeight); // AllWeightedDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hCollisionsWeighted"), 1.5, eventWeight); // WeightedCollWithVertexZ + + // for (auto const& track : tracks) { + if (pTHat < pTHatAbsoluteMin) { // Track outlier rejection: should this be for every track iteration or for every collision? + return; + } + // } + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hCollisionsWeighted"), 2.5, eventWeight); // MBRejectedDetEvents + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hCollisionsWeighted"), 3.5, eventWeight); // EventsNotSatisfyingEventSelection + return; + } + if (doMBGapTrigger && eventWeight == 1) { + registry.fill(HIST("hCollisionsWeighted"), 2.5, eventWeight); // MBRejectedDetEvents + return; + } + + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + fillTrackHistograms(tracks, clusters, eventWeight); + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hCollisionsWeighted"), 4.5, eventWeight); // EMCreadoutDetJJEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hCollisionsWeighted"), 4.5, eventWeight); // EMCreadoutDetJJEventsWithkTVXinEMC + } + } + + if (!eventAccepted) { + registry.fill(HIST("hCollisionsWeighted"), 5.5, eventWeight); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hCollisionsWeighted"), 6.5); // EMCAcceptedWeightedDetColl + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + // Fill Accepted events histos + fillTrackHistograms(tracks, clusters, eventWeight); + } + registry.fill(HIST("hCollisionsWeighted"), 7.5, eventWeight); // EMCAcceptedWeightedCollAfterTrackSel + } + PROCESS_SWITCH(FullJetSpectra, processTracksWeighted, "Full Jet tracks weighted", false); + + void processCollisionsWeightedWithMultiplicity(soa::Filtered::iterator const& collision, JetTableMCDWeightedJoined const& mcdjets, aod::JMcCollisions const&, soa::Filtered const& tracks, soa::Filtered const& clusters) + { + bool eventAccepted = false; + float eventWeight = collision.mcCollision().weight(); + float neutralEnergy = 0.0; + + registry.fill(HIST("hEventmultiplicityCounter"), 0.5, eventWeight); // allDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { + registry.fill(HIST("hEventmultiplicityCounter"), 1.5, eventWeight); // DetCollWithVertexZ + return; + } + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hEventmultiplicityCounter"), 2.5, eventWeight); // MBRejectedDetEvents + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hEventmultiplicityCounter"), 3.5, eventWeight); // EventsNotSatisfyingEventSelection + return; + } + if (doMBGapTrigger && eventWeight == 1) { + registry.fill(HIST("hEventmultiplicityCounter"), 2.5, eventWeight); // MBRejectedDetEvents + return; + } + + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + fillTrackHistograms(tracks, clusters, eventWeight); + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hEventmultiplicityCounter"), 4.5, eventWeight); // EMCreadoutDetJJEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hEventmultiplicityCounter"), 4.5, eventWeight); // EMCreadoutDetJJEventsWithkTVXinEMC + } + } + + if (!eventAccepted) { + registry.fill(HIST("hEventmultiplicityCounter"), 5.5, eventWeight); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hCollisionsWeighted"), 6.5); // EMCAcceptedWeightedDetColl + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + } + registry.fill(HIST("hEventmultiplicityCounter"), 7.5, eventWeight); // EMCAcceptedWeightedCollAfterTrackSel + registry.fill(HIST("h_FT0Mults_occupancy"), collision.multFT0M(), eventWeight); + + for (auto const& mcdjet : mcdjets) { + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (mcdjet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { // MCD jets outlier rejection + return; + } + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (mcdjet.phi() < jetPhiMin || mcdjet.phi() > jetPhiMax) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + registry.fill(HIST("h2_full_jet_jetpTDetVsFT0Mults"), mcdjet.pt(), collision.multFT0M(), eventWeight); + + for (auto const& cluster : clusters) { + neutralEnergy += cluster.energy(); + } + auto nef = neutralEnergy / mcdjet.energy(); + registry.fill(HIST("h3_full_jet_jetpTDet_FT0Mults_nef"), mcdjet.pt(), collision.multFT0M(), nef, eventWeight); + } + } + PROCESS_SWITCH(FullJetSpectra, processCollisionsWeightedWithMultiplicity, "Weighted Collisions for Full Jets Multiplicity Studies", false); + + void processMBCollisionsWithMultiplicity(soa::Filtered::iterator const& collision, JetTableMCDJoined const& mcdjets, aod::JMcCollisions const&, soa::Filtered const& tracks, soa::Filtered const& clusters) + { + bool eventAccepted = false; + float pTHat = 10. / (std::pow(1.0, 1.0 / pTHatExponent)); + float neutralEnergy = 0.0; + + registry.fill(HIST("hEventmultiplicityCounter"), 0.5); // allDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hEventmultiplicityCounter"), 1.5); // DetCollWithVertexZ + + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hEventmultiplicityCounter"), 2.5); // MBRejectedDetEvents + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hEventmultiplicityCounter"), 3.5); // EventsNotSatisfyingEventSelection + return; + } + + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + fillTrackHistograms(tracks, clusters, 1.0); + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hEventmultiplicityCounter"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hEventmultiplicityCounter"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + + if (!eventAccepted) { + registry.fill(HIST("hEventmultiplicityCounter"), 5.5); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hEventmultiplicityCounter"), 6.5); // EMCAcceptedDetColl + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + } + registry.fill(HIST("hEventmultiplicityCounter"), 7.5); // EMCAcceptedCollAfterTrackSel + registry.fill(HIST("h_FT0Mults_occupancy"), collision.multFT0M()); + + for (auto const& mcdjet : mcdjets) { + if (mcdjet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { // MCD (Detector Level) Outlier Rejection + return; + } + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (mcdjet.phi() < jetPhiMin || mcdjet.phi() > jetPhiMax) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + registry.fill(HIST("h2_full_jet_jetpTDetVsFT0Mults"), mcdjet.pt(), collision.multFT0M(), 1.0); + + for (auto const& cluster : clusters) { + neutralEnergy += cluster.energy(); + } + auto nef = neutralEnergy / mcdjet.energy(); + registry.fill(HIST("h3_full_jet_jetpTDet_FT0Mults_nef"), mcdjet.pt(), collision.multFT0M(), nef, 1.0); + } + } + PROCESS_SWITCH(FullJetSpectra, processMBCollisionsWithMultiplicity, "MB MCD Collisions for Full Jets Multiplicity Studies", false); + + void processMBCollisionsDATAWithMultiplicity(soa::Filtered::iterator const& collision, FullJetTableDataJoined const& jets, soa::Filtered const& tracks, soa::Filtered const& clusters) + { + bool eventAccepted = false; + float neutralEnergy = 0.0; + + registry.fill(HIST("hEventmultiplicityCounter"), 0.5); // allDetColl + if (std::fabs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hEventmultiplicityCounter"), 1.5); // DetCollWithVertexZ + if (doMBGapTrigger && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + registry.fill(HIST("hEventmultiplicityCounter"), 2.5); // MBRejectedDetEvents + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, doMBGapTrigger)) { + registry.fill(HIST("hEventmultiplicityCounter"), 3.5); // EventsNotSatisfyingEventSelection + return; + } + + if (doEMCALEventWorkaround) { + if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content + eventAccepted = true; + fillTrackHistograms(tracks, clusters, 1.0); + if (collision.alias_bit(kTVXinEMC)) { + registry.fill(HIST("hEventmultiplicityCounter"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + } else { + if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { + eventAccepted = true; + registry.fill(HIST("hEventmultiplicityCounter"), 4.5); // EMCreadoutDetEventsWithkTVXinEMC + } + } + + if (!eventAccepted) { + registry.fill(HIST("hEventmultiplicityCounter"), 5.5); // AllRejectedDetEventsAfterEMCEventSelection + return; + } + registry.fill(HIST("hEventmultiplicityCounter"), 6.5); // EMCAcceptedDetColl + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + } + registry.fill(HIST("hEventmultiplicityCounter"), 7.5); // EMCAcceptedCollAfterTrackSel + registry.fill(HIST("h_FT0Mults_occupancy"), collision.multFT0M()); + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (jet.phi() < jetPhiMin || jet.phi() > jetPhiMax) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + registry.fill(HIST("h2_full_jet_jetpTDetVsFT0Mults"), jet.pt(), collision.multFT0M(), 1.0); + + for (auto const& cluster : clusters) { + neutralEnergy += cluster.energy(); + } + auto nef = neutralEnergy / jet.energy(); + registry.fill(HIST("h3_full_jet_jetpTDet_FT0Mults_nef"), jet.pt(), collision.multFT0M(), nef, 1.0); + } + } + PROCESS_SWITCH(FullJetSpectra, processMBCollisionsDATAWithMultiplicity, "MB DATA Collisions for Full Jets Multiplicity Studies", false); + +}; // struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGJE/Tasks/fullJetSpectraPP.cxx b/PWGJE/Tasks/fullJetSpectraPP.cxx deleted file mode 100644 index b683a6ef98c..00000000000 --- a/PWGJE/Tasks/fullJetSpectraPP.cxx +++ /dev/null @@ -1,897 +0,0 @@ -// 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. - -// FullJet Spectra in pp -// -// TO DO: -// 1. implement HadCorr -// -/// \author Archita Rani Dash -#include -#include -#include - -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" -#include "Framework/RunningWorkflowInfo.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGHF/Core/HfHelper.h" - -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "PWGJE/DataModel/EMCALMatchedCollisions.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" - -#include "EventFiltering/filterTables.h" - -using namespace std; -using namespace o2; -using namespace o2::analysis; -using namespace o2::framework; -using namespace o2::framework::expressions; - -using EMCCollisions = o2::soa::Join; // needed for the workaround to access EMCAL trigger bits - -struct FullJetSpectrapp { - - HistogramRegistry registry; - - // Event configurables - Configurable VertexZCut{"VertexZCut", 10.0f, "Accepted z-vertex range"}; - Configurable centralityMin{"centralityMin", -999.0, "minimum centrality"}; - Configurable centralityMax{"centralityMax", 999.0, "maximum centrality"}; - Configurable doEMCALEventWorkaround{"doEMCALEventWorkaround", false, "apply the workaround to read the EMC trigger bit by requiring a cell content in the EMCAL"}; - Configurable doMBGapTrigger{"doMBGapTrigger", false, "set to true only when using MB-Gap Trigger JJ MC"}; - Configurable doJJMC{"doJJMC", false, "set to true only when using JJ MC"}; - - // Jet configurables - Configurable selectedJetsRadius{"selectedJetsRadius", 0.4, "resolution parameter for histograms without radius"}; - Configurable> jetRadii{"jetRadii", std::vector{0.4}, "jet resolution parameters"}; - Configurable jetpTMin{"jetpTMin", 20.0, "minimum jet pT"}; - Configurable jetpTMax{"jetpTMax", 350., "maximum jet pT"}; - Configurable jetEtaMin{"jetEtaMin", -0.3, "minimum jet eta"}; // each of these jet configurables are for the fiducial emcal cuts - Configurable jetEtaMax{"jetEtaMax", 0.3, "maximum jet eta"}; // for R = 0.4 (EMCAL eta acceptance: eta_jet = 0.7 - R) - Configurable jetPhiMin{"jetPhiMin", 1.80, "minimum jet phi"}; // phi_jet_min for R = 0.4 is 1.80 - Configurable jetPhiMax{"jetPhiMax", 2.86, "maximum jet phi"}; // phi_jet_min for R = 0.4 is 2.86 - Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; - Configurable leadingConstituentPtMin{"leadingConstituentPtMin", -99.0, "minimum pT selection on jet constituent"}; - - // Track configurables - Configurable trackpTMin{"trackpTMin", 0.15, "minimum track pT"}; - Configurable trackpTMax{"trackpTMax", 350., "maximum track pT"}; - Configurable trackEtaMin{"trackEtaMin", -0.7, "minimum track eta"}; - Configurable trackEtaMax{"trackEtaMax", 0.7, "maximum track eta"}; - Configurable trackPhiMin{"trackPhiMin", 1.396, "minimum track phi"}; - Configurable trackPhiMax{"trackPhiMax", 3.283, "maximum track phi"}; - Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; - Configurable eventSelections{"eventSelections", "sel8Full", "choose event selection"}; - Configurable particleSelections{"particleSelections", "PhysicalPrimary", "set particle selections"}; - - // Cluster configurables - - Configurable clusterDefinitionS{"clusterDefinition", "kV3Default", "cluster definition to be selected, e.g. V3Default"}; - Configurable clusterEtaMin{"clusterEtaMin", -0.7, "minimum cluster eta"}; - Configurable clusterEtaMax{"clusterEtaMax", 0.7, "maximum cluster eta"}; - Configurable clusterPhiMin{"clusterPhiMin", 1.396, "minimum cluster phi"}; - Configurable clusterPhiMax{"clusterPhiMax", 3.283, "maximum cluster phi"}; - Configurable clusterEnergyMin{"clusterEnergyMin", 0.3, "minimum cluster energy in EMCAL (GeV)"}; - Configurable clusterTimeMin{"clusterTimeMin", -20., "minimum cluster time (ns)"}; - Configurable clusterTimeMax{"clusterTimeMax", 15., "maximum cluster time (ns)"}; - Configurable clusterRejectExotics{"clusterRejectExotics", true, "Reject exotic clusters"}; - - Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; - Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; - Configurable pTHatExponent{"pTHatExponent", 4.0, "exponent of the event weight for the calculation of pTHat"}; // 6 for MB MC and 4 for JJ MC - - int trackSelection = -1; - int eventSelection = -1; - std::vector filledJetR; - std::vector jetRadiiValues; - - std::string particleSelection; - - Service pdgDatabase; - - // Add Collision Histograms' Bin Labels for clarity - void labelCollisionHistograms(HistogramRegistry& registry) - { - if (doprocessTracks) { - auto h_collisions_unweighted = registry.get(HIST("h_collisions_unweighted")); - h_collisions_unweighted->GetXaxis()->SetBinLabel(1, "total events"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(2, "JetsData with kTVXinEMC"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(3, "JetsMCD with kTVXinEMC"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(4, "Tracks with kTVXinEMC"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(5, "JetsMCPMCDMatched with kTVXinEMC"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(6, "JetsData w/o kTVXinEMC"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(7, "JetsMCD w/o kTVXinEMC"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(8, "Tracks w/o kTVXinEMC"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(9, "JetsMCPMCDMatched w/o kTVXinEMC"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(10, "Fake Matched MCD Jets"); - h_collisions_unweighted->GetXaxis()->SetBinLabel(11, "Fake Matched MCP Jets"); - } - - if (doprocessTracksWeighted) { - auto h_collisions_weighted = registry.get(HIST("h_collisions_weighted")); - h_collisions_weighted->GetXaxis()->SetBinLabel(1, "total events"); - h_collisions_weighted->GetXaxis()->SetBinLabel(2, "JetsMCDWeighted with kTVXinEMC"); - h_collisions_weighted->GetXaxis()->SetBinLabel(3, "JetsMCPMCDMatchedWeighted with kTVXinEMC"); - h_collisions_weighted->GetXaxis()->SetBinLabel(4, "TracksWeighted with kTVXinEMC"); - h_collisions_weighted->GetXaxis()->SetBinLabel(5, "JetsMCDWeighted w/o kTVXinEMC"); - h_collisions_weighted->GetXaxis()->SetBinLabel(6, "JetsMCPMCDMatchedWeighted w/o kTVXinEMC"); - h_collisions_weighted->GetXaxis()->SetBinLabel(7, "TracksWeighted w/o kTVXinEMC"); - h_collisions_weighted->GetXaxis()->SetBinLabel(8, "Fake Matched Weighted MCD Jets"); - h_collisions_weighted->GetXaxis()->SetBinLabel(9, "Fake Matched Weighted MCP Jets"); - } - } - - void init(o2::framework::InitContext&) - { - trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); - particleSelection = static_cast(particleSelections); - jetRadiiValues = (std::vector)jetRadii; - - for (std::size_t iJetRadius = 0; iJetRadius < jetRadiiValues.size(); iJetRadius++) { - filledJetR.push_back(0.0); - } - auto jetRadiiBins = (std::vector)jetRadii; - if (jetRadiiBins.size() > 1) { - jetRadiiBins.push_back(jetRadiiBins[jetRadiiBins.size() - 1] + (TMath::Abs(jetRadiiBins[jetRadiiBins.size() - 1] - jetRadiiBins[jetRadiiBins.size() - 2]))); - } else { - jetRadiiBins.push_back(jetRadiiBins[jetRadiiBins.size() - 1] + 0.1); - } - - // Track QA histograms - if (doprocessTracks || doprocessTracksWeighted) { - registry.add("h_collisions_unweighted", "event status; event status;entries", {HistType::kTH1F, {{12, 0., 12.0}}}); - - registry.add("h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); - registry.add("h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - registry.add("h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - registry.add("h_track_energy", "track energy;Energy of tracks;entries", {HistType::kTH1F, {{400, 0., 400.}}}); - registry.add("h_track_energysum", "track energy sum;Sum of track energy per event;entries", {HistType::kTH1F, {{400, 0., 400.}}}); - - // registry.add("h_gaptrig_track_pt", "gap triggered track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); - // registry.add("h_gaptrig_track_eta", "gap triggered track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - // registry.add("h_gaptrig_track_phi", "gap triggered track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - - // Cluster QA histograms - registry.add("h_cluster_pt", "cluster pT;#it{p}_{T_cluster} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_cluster_eta", "cluster #eta;#eta_{cluster};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - registry.add("h_cluster_phi", "cluster #varphi;#varphi_{cluster};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - registry.add("h_cluster_energy", "cluster energy;Energy of cluster;entries", {HistType::kTH1F, {{400, 0., 400.}}}); - registry.add("h_cluster_energysum", "cluster energy sum;Sum of cluster energy per event;entries", {HistType::kTH1F, {{400, 0., 400.}}}); - - // registry.add("h_gaptrig_cluster_pt", "gap triggered cluster pT;#it{p}_{T_cluster} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - // registry.add("h_gaptrig_cluster_eta", "gap triggered cluster #eta;#eta_{cluster};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - // registry.add("h_gaptrig_cluster_phi", "gap triggered cluster #varphi;#varphi_{cluster};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - // registry.add("h_gaptrig_cluster_energy", "gap triggered cluster #varphi;#varphi_{cluster};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - - if (doprocessTracksWeighted) { - registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{12, 0.0, 12.0}}}); - registry.add("h_gaptrig_collisions", "event status; event status; entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); - - // registry.add("h_gaptrig_track_pt", "gap triggered track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); - // registry.add("h_gaptrig_track_eta", "gap triggered track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - // registry.add("h_gaptrig_track_phi", "gap triggered track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - // - // registry.add("h_gaptrig_cluster_pt", "gap triggered cluster pT;#it{p}_{T_cluster} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - // registry.add("h_gaptrig_cluster_eta", "gap triggered cluster #eta;#eta_{cluster};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - // registry.add("h_gaptrig_cluster_phi", "gap triggered cluster #varphi;#varphi_{cluster};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - // registry.add("h_gaptrig_cluster_energy", "gap triggered cluster #varphi;#varphi_{cluster};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - } - } - - // Jet QA histograms - if (doprocessJetsData || doprocessJetsMCD || doprocessJetsMCDWeighted) { - registry.add("h_full_jet_pt", "#it{p}_{T,jet};#it{p}_{T_jet} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); - registry.add("h_full_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - registry.add("h_full_jet_phi", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - registry.add("h2_full_jet_NEF", "#it{p}_{T,jet} vs NEF at Det Level; #it{p}_{T,jet} (GeV/#it{c});NEF", {HistType::kTH2F, {{350, 0., 350.}, {105, 0., 1.05}}}); - registry.add("h2_full_jet_NEF_rejected", "#it{p}_{T,jet} vs NEF at Det Level for rejected events; #it{p}_{T,jet} (GeV/#it{c});NEF", {HistType::kTH2F, {{350, 0., 350.}, {105, 0., 1.05}}}); - - registry.add("h_Detjet_ntracks", "#it{p}_{T,track};#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); - registry.add("h2_full_jet_chargedconstituents", "Number of charged constituents at Det Level;#it{p}_{T,jet} (GeV/#it{c});N_{ch}", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); - registry.add("h2_full_jet_neutralconstituents", "Number of neutral constituents at Det Level;#it{p}_{T,jet} (GeV/#it{c});N_{ne}", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); - registry.add("h2_full_jettrack_pt", "#it{p}_{T,jet} vs #it{p}_{T,track}; #it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {{350, 0., 350.}, {200, 0., 200.}}}); - registry.add("h2_full_jettrack_eta", "jet #eta vs jet_track #eta; #eta_{jet};#eta_{track}", {HistType::kTH2F, {{100, -1., 1.}, {500, -5., 5.}}}); - registry.add("h2_full_jettrack_phi", "jet #varphi vs jet_track #varphi; #varphi_{jet}; #varphi_{track}", {HistType::kTH2F, {{160, 0., 7.}, {160, -1., 7.}}}); - - registry.add("h2_track_etaphi", "jet_track #eta vs jet_track #varphi; #eta_{track};#varphi_{track}", {HistType::kTH2F, {{500, -5., 5.}, {160, -1., 7.}}}); - registry.add("h2_jet_etaphi", "jet #eta vs jet #varphi; #eta_{jet};#varphi_{jet}", {HistType::kTH2F, {{100, -1., 1.}, {160, -1., 7.}}}); - // registry.add("h_full_mcdjet_tablesize", "", {HistType::kTH1F, {{4, 0., 5.}}}); - // registry.add("h_gaptrig_full_jet_pt", "gap triggered jet pT;#it{p}_{T_jet} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); - // registry.add("h_gaptrig_full_jet_eta", "gap triggered jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - // registry.add("h_gaptrig_full_jet_phi", "gap triggered jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - } - if (doprocessJetsMCP || doprocessJetsMCPWeighted) { - registry.add("h_full_mcpjet_tablesize", "", {HistType::kTH1F, {{4, 0., 5.}}}); - registry.add("h_full_mcpjet_ntracks", "", {HistType::kTH1F, {{200, -0.5, 200.}}}); - registry.add("h_full_jet_pt_part", "jet pT;#it{p}_{T_jet} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); - registry.add("h_full_jet_eta_part", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - registry.add("h_full_jet_phi_part", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - registry.add("h2_full_jet_NEF_part", "#it{p}_{T,jet} vs NEF at Part Level;#it{p}_{T,jet} (GeV/#it{c});NEF", {HistType::kTH2F, {{350, 0., 350.}, {105, 0., 1.05}}}); - - registry.add("h_Partjet_ntracks", "#it{p}_{T,constituent};#it{p}_{T_constituent} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); - registry.add("h2_full_jet_chargedconstituents_part", "Number of charged constituents at Part Level;#it{p}_{T,jet} (GeV/#it{c});N_{ch}", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); - registry.add("h2_full_jet_neutralconstituents_part", "Number of neutral constituents at Part Level;#it{p}_{T,jet} (GeV/#it{c});N_{ne}", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); - registry.add("h2_jettrack_pt_part", "#it{p}_{T,jet} vs #it{p}_{T_track}; #it{p}_{T_jet} (GeV/#it{c});#it{p}_{T_track} (GeV/#it{c})", {HistType::kTH2F, {{350, 0., 350.}, {200, 0., 200.}}}); - registry.add("h2_jettrack_eta_part", "jet #eta vs jet_track #eta; #eta_{jet};#eta_{track}", {HistType::kTH2F, {{100, -1., 1.}, {500, -5., 5.}}}); - registry.add("h2_jettrack_phi_part", "jet #varphi vs jet_track #varphi; #varphi_{jet}; #varphi_{track}", {HistType::kTH2F, {{160, 0., 7.}, {160, -1., 7.}}}); - - registry.add("h2_track_etaphi_part", "jet_track #eta vs jet_track #varphi; #eta_{track};#varphi_{track}", {HistType::kTH2F, {{500, -5., 5.}, {160, -1., 7.}}}); - registry.add("h2_jet_etaphi_part", "jet #eta vs jet #varphi; #eta_{jet};#varphi_{jet}", {HistType::kTH2F, {{100, -1., 1.}, {160, -1., 7.}}}); - // registry.add("h_gaptrig_full_mcpjet_tablesize", "", {HistType::kTH1F, {{4, 0., 5.}}}); - // registry.add("h_gaptrig_full_mcpjet_ntracks", "", {HistType::kTH1F, {{200, -0.5, 200.}}}); - // registry.add("h_gaptrig_full_jet_pt_part", "jet pT;#it{p}_{T_jet} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0., 350.}}}); - // registry.add("h_gaptrig_full_jet_eta_part", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - // registry.add("h_gaptrig_full_jet_phi_part", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - } - - if (doprocessJetsMCPMCDMatched || doprocessJetsMCPMCDMatchedWeighted) { - registry.add("h_full_matchedmcdjet_tablesize", "", {HistType::kTH1F, {{350, 0., 350.}}}); - registry.add("h_full_matchedmcpjet_tablesize", "", {HistType::kTH1F, {{350, 0., 350.}}}); - registry.add("h_full_matchedmcdjet_ntracks", "", {HistType::kTH1F, {{200, -0.5, 200.}}}); - registry.add("h_full_matchedmcpjet_ntracks", "", {HistType::kTH1F, {{200, -0.5, 200.}}}); - registry.add("h_full_matchedmcdjet_eta", "Matched MCD jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - registry.add("h_full_matchedmcdjet_phi", "Matched MCD jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - registry.add("h_full_matchedmcpjet_eta", "Matched MCP jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); - registry.add("h_full_matchedmcpjet_phi", "Matched MCP jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., 7.}}}); - registry.add("h_full_jet_deltaR", "Distance between matched Det Jet and Part Jet; \\Delta R; entries", {HistType::kTH1F, {{100, 0., 1.}}}); - - registry.add("h2_full_jet_energyscaleDet", "Jet Energy Scale (det); p_{T,det} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F, {{400, 0., 400.}, {200, -1., 1.}}}); - - // registry.add("h2_matchedjettrack_eta", "jet #eta vs jet_track #eta; #eta_{jet};#eta_{track}", {HistType::kTH2F, {{100, -1., 1.}, {500, -5., 5.}}}); - // registry.add("h2_matchedjettrack_phi", "jet #varphi vs jet_track #varphi; #varphi_{jet}; #varphi_{track}", {HistType::kTH2F, {{160, 0., 7.}, {160, -1., 7.}}}); - - registry.add("h2_matchedjet_etaphiDet", "Det jet #eta vs jet #varphi; #eta_{jet};#varphi_{jet}", {HistType::kTH2F, {{100, -1., 1.}, {160, -1., 7.}}}); - registry.add("h2_matchedjet_etaphiPart", "Part jet #eta vs jet #varphi; #eta_{jet};#varphi_{jet}", {HistType::kTH2F, {{100, -1., 1.}, {160, -1., 7.}}}); - - // registry.add("h_full_jet_energyscaleDetCharged", "Jet Energy Scale (det, charged part); p_{t,det} (GeV/c); (p_{t,det} - p_{t,part})/p_{t,part}", {HistType::kTH2F,{{400, 0., 400., 200, -1.,1.}}}); - // registry.add("h_full_jet_energyscaleDetNeutral", "Jet Energy Scale (det, neutral part); p_{t,det} (GeV/c); (p_{t,det} - p_{t,part})/p_{t,part}", {HistType::kTH2F,{{400, 0., 400., 200, -1.,1.}}}); - // registry.add("h_full_jet_energyscaleDetChargedVsFull", "Jet Energy Scale (det, charged part, vs. full jet pt); p_{t,det} (GeV/c); (p_{t,det} - p_{t,part})/p_{t,part}", {HistType::kTH2F,{{400, 0., 400., 200, -1.,1.}}}); - // registry.add("h_full_jet_energyscaleDetNeutralVsFull", "Jet Energy Scale (det, neutral part, vs. full jet pt); p_{t,det} (GeV/c); (p_{t,det} - p_{t,part})/p_{t,part}", {HistType::kTH2F,{{400, 0., 400., 200, -1.,1.}}}); - registry.add("h2_full_jet_energyscalePart", "Jet Energy Scale (part); p_{T,part} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F, {{400, 0., 400.}, {200, -1., 1.}}}); - registry.add("h3_full_jet_energyscalePart", "R dependence of Jet Energy Scale (Part); #it{R}_{jet};p_{T,det} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, 0., 400.}, {200, -1., 1.}}}); - registry.add("h2_full_jet_etaresolutionPart", ";p_{T,part} (GeV/c); (#eta_{jet,det} - #eta_{jet,part})/#eta_{jet,part}", {HistType::kTH2F, {{400, 0., 400.}, {100, -1., 1.}}}); - registry.add("h2_full_jet_phiresolutionPart", ";p_{T,part} (GeV/c); (#varphi_{jet,det} - #varphi_{jet,part})/#varphi_{jet,part}", {HistType::kTH2F, {{400, 0., 400.}, {160, -1., 7.}}}); - // registry.add("h_full_jet_energyscaleCharged", "Jet Energy Scale (charged part); p_{t,part} (GeV/c); (p_{t,det} - p_{t,part})/p_{t,part}", {HistType::kTH2F,{{400, 0., 400., 200, -1.,1.}}}); - // registry.add("h_full_jet_energyscaleNeutral", "Jet Energy Scale (neutral part); p_{t,part} (GeV/c); (p_{t,det} - p_{t,part})/p_{t,part}", {HistType::kTH2F,{{400, 0., 400., 200, -1.,1.}}}); - // registry.add("h_full_jet_energyscaleChargedVsFull", "Jet Energy Scale (charged part, vs. full jet pt); p_{t,part} (GeV/c); (p_{t,det} - p_{t,part})/p_{t,part}", {HistType::kTH2F,{{400, 0., 400., 200, -1.,1.}}}); - // registry.add("h_full_jet_energyscaleNeutralVsFull", "Jet Energy Scale (neutral part, vs. full jet pt); p_{t,part} (GeV/c); (p_{t,det} - p_{t,part})/p_{t,part}", {HistType::kTH2F,{{400, 0., 400., 200, -1.,1.}}}); - registry.add("h2_full_fakemcdjets", "Fake MCD Jets; p_{T,det} (GeV/c); NCounts", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); - registry.add("h2_full_fakemcpjets", "Fake MCP Jets; p_{T,part} (GeV/c); NCounts", {HistType::kTH2F, {{350, 0., 350.}, {100, 0., 100.}}}); - // Response Matrix - registry.add("h_full_jet_ResponseMatrix", "Full Jets Response Matrix; p_{T,det} (GeV/c); p_{T,part} (GeV/c)", {HistType::kTH2F, {{200, 0., 200.}, {200, 0., 200.}}}); - - // registry.add("h_gaptrig_full_matchedmcdjet_tablesize", "", {HistType::kTH1F, {{4, 0., 5.}}}); - // registry.add("h_gaptrig_full_matchedmcdjet_ntracks", "", {HistType::kTH1F, {{200, -0.5, 200.}}}); - // registry.add("h_gaptrig_full_jet_energyscaleDet", "Jet Energy Scale (det); p_{T,det} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F,{{400, 0., 400.}, {200, -1.,1.}}}); - // registry.add("h_gaptrig_full_jet_energyscalePart", "Jet Energy Scale (part); p_{T,part} (GeV/c); (p_{T,det} - p_{T,part})/p_{T,part}", {HistType::kTH2F,{{400, 0., 400.}, {200, -1.,1.}}}); - // registry.add("h_gaptrig_full_jet_ResponseMatrix", "Full Jets Response Matrix; p_{T,det} (GeV/c); p_{T,part} (GeV/c)", {HistType::kTH2F,{{400, 0., 400.}, {400,0.,400.}}}); - } - - // Label the histograms - labelCollisionHistograms(registry); - - } // init - - using FullJetTableDataJoined = soa::Join; - using JetTableMCDJoined = soa::Join; - using JetTableMCDWeightedJoined = soa::Join; - using JetTableMCPJoined = soa::Join; - using JetTableMCPWeightedJoined = soa::Join; - - using JetTableMCDMatchedJoined = soa::Join; - using JetTableMCPMatchedJoined = soa::Join; - - using JetTableMCDMatchedWeightedJoined = soa::Join; - using JetTableMCPMatchedWeightedJoined = soa::Join; - - // Applying some cuts(filters) on collisions, tracks, clusters - - Filter eventCuts = (nabs(aod::jcollision::posZ) < VertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); - // Filter EMCeventCuts = (nabs(aod::collision::posZ) < VertexZCut && aod::collision::centrality >= centralityMin && aod::collision::centrality < centralityMax); - Filter trackCuts = (aod::jtrack::pt >= trackpTMin && aod::jtrack::pt < trackpTMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax && aod::jtrack::phi >= trackPhiMin && aod::jtrack::phi <= trackPhiMax); - aod::EMCALClusterDefinition clusterDefinition = aod::emcalcluster::getClusterDefinitionFromString(clusterDefinitionS.value); - Filter clusterFilter = (aod::jcluster::definition == static_cast(clusterDefinition) && aod::jcluster::eta > clusterEtaMin && aod::jcluster::eta < clusterEtaMax && aod::jcluster::phi >= clusterPhiMin && aod::jcluster::phi <= clusterPhiMax && aod::jcluster::energy >= clusterEnergyMin && aod::jcluster::time > clusterTimeMin && aod::jcluster::time < clusterTimeMax && (clusterRejectExotics && aod::jcluster::isExotic != true)); - Preslice JetMCPPerMcCollision = aod::jet::mcCollisionId; - - template - bool isAcceptedJet(U const& jet) - { - - if (jetAreaFractionMin > -98.0) { - if (jet.area() < jetAreaFractionMin * M_PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { - return false; - } - } - if (leadingConstituentPtMin > -98.0) { - bool isMinleadingConstituent = false; - for (auto& constituent : jet.template tracks_as()) { - if (constituent.pt() >= leadingConstituentPtMin) { - isMinleadingConstituent = true; - break; - } - } - - if (!isMinleadingConstituent) { - return false; - } - } - return true; - } - template - void fillJetHistograms(T const& jet, float weight = 1.0) - { - float neutralEnergy = 0.0; - if (jet.r() == round(selectedJetsRadius * 100.0f)) { - registry.fill(HIST("h_full_jet_pt"), jet.pt(), weight); - registry.fill(HIST("h_full_jet_eta"), jet.eta(), weight); - registry.fill(HIST("h_full_jet_phi"), jet.phi(), weight); - // registry.fill(HIST("h_full_mcdjet_tablesize"), jet.size(), weight); - // registry.fill(HIST("h_full_mcdjet_ntracks"), jet.tracksIds().size(), weight); - // } - registry.fill(HIST("h2_jet_etaphi"), jet.eta(), jet.phi(), weight); - - for (auto& cluster : jet.template clusters_as()) { - registry.fill(HIST("h2_full_jet_neutralconstituents"), jet.pt(), jet.clustersIds().size(), weight); - neutralEnergy += cluster.energy(); - } - auto NEF = neutralEnergy / jet.energy(); - registry.fill(HIST("h2_full_jet_NEF"), jet.pt(), NEF, weight); - - for (auto& jettrack : jet.template tracks_as()) { - registry.fill(HIST("h_Detjet_ntracks"), jettrack.pt(), weight); - registry.fill(HIST("h2_full_jet_chargedconstituents"), jet.pt(), jet.tracksIds().size(), weight); - registry.fill(HIST("h2_full_jettrack_pt"), jet.pt(), jettrack.pt(), weight); - registry.fill(HIST("h2_full_jettrack_eta"), jet.eta(), jettrack.eta(), weight); - registry.fill(HIST("h2_full_jettrack_phi"), jet.phi(), jettrack.phi(), weight); - - registry.fill(HIST("h2_track_etaphi"), jettrack.eta(), jettrack.phi(), weight); - } - } // jet.r() - } - - // check for NEF distribution for rejected events - template - void fillRejectedJetHistograms(T const& jet, float weight = 1.0) - { - float neutralEnergy = 0.0; - if (jet.r() == round(selectedJetsRadius * 100.0f)) { - for (auto& cluster : jet.template clusters_as()) { - neutralEnergy += cluster.energy(); - } - auto NEF = neutralEnergy / jet.energy(); - registry.fill(HIST("h2_full_jet_NEF_rejected"), jet.pt(), NEF, weight); - } // jet.r() - } - - template - void fillMCPHistograms(T const& jet, float weight = 1.0) - { - float neutralEnergy = 0.0; - int neutralconsts = 0; - int chargedconsts = 0; - if (jet.r() == round(selectedJetsRadius * 100.0f)) { - registry.fill(HIST("h_full_mcpjet_tablesize"), jet.size(), weight); - registry.fill(HIST("h_full_mcpjet_ntracks"), jet.tracksIds().size(), weight); - registry.fill(HIST("h_full_jet_pt_part"), jet.pt(), weight); - registry.fill(HIST("h_full_jet_eta_part"), jet.eta(), weight); - registry.fill(HIST("h_full_jet_phi_part"), jet.phi(), weight); - // registry.fill(HIST("h_full_jet_ntracks_part"), jet.tracksIds().size(), weight); - // } - registry.fill(HIST("h2_jet_etaphi_part"), jet.eta(), jet.phi(), weight); - - for (auto& constituent : jet.template tracks_as()) { - auto pdgParticle = pdgDatabase->GetParticle(constituent.pdgCode()); - if (pdgParticle->Charge() == 0) { - neutralconsts++; - neutralEnergy += constituent.e(); // neutral jet constituents at particle level - registry.fill(HIST("h2_full_jet_neutralconstituents_part"), jet.pt(), neutralconsts, weight); - } else { - chargedconsts++; - registry.fill(HIST("h2_full_jet_chargedconstituents_part"), jet.pt(), chargedconsts, weight); // charged jet constituents at particle level - registry.fill(HIST("h2_jettrack_pt_part"), jet.pt(), constituent.pt(), weight); - registry.fill(HIST("h2_jettrack_eta_part"), jet.eta(), constituent.eta(), weight); - registry.fill(HIST("h2_jettrack_phi_part"), jet.phi(), constituent.phi(), weight); - registry.fill(HIST("h2_track_etaphi_part"), constituent.eta(), constituent.phi(), weight); - } - } // constituent loop - auto NEF = neutralEnergy / jet.energy(); - registry.fill(HIST("h2_full_jet_NEF_part"), jet.pt(), NEF, weight); - } - } - - template - void fillTrackHistograms(T const& tracks, U const& clusters, float weight = 1.0) - { - double sumtrackE = 0.0; - for (auto const& track : tracks) { - if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { - continue; - } - sumtrackE += track.energy(); - registry.fill(HIST("h_track_pt"), track.pt(), weight); - registry.fill(HIST("h_track_eta"), track.eta(), weight); - registry.fill(HIST("h_track_phi"), track.phi(), weight); - registry.fill(HIST("h_track_energysum"), sumtrackE, weight); - } - double sumclusterE = 0.0; - for (auto const& cluster : clusters) { - double clusterpt = cluster.energy() / std::cosh(cluster.eta()); - sumclusterE += cluster.energy(); - - registry.fill(HIST("h_cluster_pt"), clusterpt, weight); - registry.fill(HIST("h_cluster_eta"), cluster.eta(), weight); - registry.fill(HIST("h_cluster_phi"), cluster.phi(), weight); - registry.fill(HIST("h_cluster_energy"), cluster.energy(), weight); - registry.fill(HIST("h_cluster_energysum"), sumclusterE, weight); - } - } - - template - void fillMatchedHistograms(T const& jetBase, float weight = 1.0) - { - if (doJJMC) { - - if (jetBase.has_matchedJetGeo()) { // geometrical jet matching only needed for pp - here,matching Base(Det.level) with Tag (Part. level) jets - registry.fill(HIST("h_full_matchedmcdjet_tablesize"), jetBase.size(), weight); - registry.fill(HIST("h_full_matchedmcdjet_ntracks"), jetBase.tracksIds().size(), weight); - registry.fill(HIST("h2_matchedjet_etaphiDet"), jetBase.eta(), jetBase.phi(), weight); - - for (auto& jetTag : jetBase.template matchedJetGeo_as>()) { - - auto deltaEta = jetBase.eta() - jetTag.eta(); - auto deltaPhi = jetBase.phi() - jetTag.phi(); - auto deltaR = jetutilities::deltaR(jetBase, jetTag); - - registry.fill(HIST("h_full_jet_deltaR"), deltaR, weight); - registry.fill(HIST("h_full_matchedmcpjet_tablesize"), jetTag.size(), weight); - registry.fill(HIST("h_full_matchedmcpjet_ntracks"), jetTag.tracksIds().size(), weight); - registry.fill(HIST("h2_matchedjet_etaphiPart"), jetTag.eta(), jetTag.phi(), weight); - // JES - registry.fill(HIST("h2_full_jet_energyscaleDet"), jetBase.pt(), (jetBase.pt() - jetTag.pt()) / jetTag.pt(), weight); - registry.fill(HIST("h2_full_jet_energyscalePart"), jetTag.pt(), (jetBase.pt() - jetTag.pt()) / jetTag.pt(), weight); - registry.fill(HIST("h3_full_jet_energyscalePart"), jetBase.r() / 100.0, jetTag.pt(), (jetBase.pt() - jetTag.pt()) / jetTag.pt(), weight); - registry.fill(HIST("h2_full_jet_etaresolutionPart"), jetTag.pt(), deltaEta / jetTag.eta(), weight); - registry.fill(HIST("h2_full_jet_phiresolutionPart"), jetTag.pt(), deltaPhi / jetTag.phi(), weight); - - // Response Matrix - registry.fill(HIST("h_full_jet_ResponseMatrix"), jetBase.pt(), jetTag.pt(), weight); // MCD vs MCP jet pT - } // jetTag - } // jetBase - } else { - if (jetBase.has_matchedJetGeo()) { // geometrical jet matching only needed for pp - here,matching Base(Det.level) with Tag (Part. level) jets - registry.fill(HIST("h_full_matchedmcdjet_tablesize"), jetBase.size(), weight); - registry.fill(HIST("h_full_matchedmcdjet_ntracks"), jetBase.tracksIds().size(), weight); - registry.fill(HIST("h2_matchedjet_etaphiDet"), jetBase.eta(), jetBase.phi(), weight); - - for (auto& jetTag : jetBase.template matchedJetGeo_as>()) { - - auto deltaEta = jetBase.eta() - jetTag.eta(); - auto deltaPhi = jetBase.phi() - jetTag.phi(); - auto deltaR = jetutilities::deltaR(jetBase, jetTag); - - registry.fill(HIST("h_full_jet_deltaR"), deltaR, weight); - registry.fill(HIST("h_full_matchedmcpjet_tablesize"), jetTag.size(), weight); - registry.fill(HIST("h_full_matchedmcpjet_ntracks"), jetTag.tracksIds().size(), weight); - - registry.fill(HIST("h2_matchedjet_etaphiPart"), jetTag.eta(), jetTag.phi(), weight); - // JES - registry.fill(HIST("h2_full_jet_energyscaleDet"), jetBase.pt(), (jetBase.pt() - jetTag.pt()) / jetTag.pt(), weight); - registry.fill(HIST("h2_full_jet_energyscalePart"), jetTag.pt(), (jetBase.pt() - jetTag.pt()) / jetTag.pt(), weight); - registry.fill(HIST("h3_full_jet_energyscalePart"), jetBase.r() / 100.0, jetTag.pt(), (jetBase.pt() - jetTag.pt()) / jetTag.pt(), weight); - registry.fill(HIST("h2_full_jet_etaresolutionPart"), jetTag.pt(), deltaEta / jetTag.eta(), weight); - registry.fill(HIST("h2_full_jet_phiresolutionPart"), jetTag.pt(), deltaPhi / jetTag.phi(), weight); - - // Response Matrix - registry.fill(HIST("h_full_jet_ResponseMatrix"), jetBase.pt(), jetTag.pt(), weight); // MCD vs MCP jet pT - } // jetTag - } // jetBase - } // else - } - - void processDummy(aod::JetCollisions const&) - { - } - PROCESS_SWITCH(FullJetSpectrapp, processDummy, "dummy task", true); - - void processJetsData(soa::Filtered::iterator const& collision, FullJetTableDataJoined const& jets, aod::JetTracks const&, aod::JetClusters const&) - { - registry.fill(HIST("h_collisions_unweighted"), 1.0); // total events - bool eventAccepted = false; - - if (doEMCALEventWorkaround) { - if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content - eventAccepted = true; - if (collision.alias_bit(kTVXinEMC)) { - registry.fill(HIST("h_collisions_unweighted"), 2.0); // JetsData with kTVXinEMC - } - } - } else { - if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { - eventAccepted = true; - registry.fill(HIST("h_collisions_unweighted"), 2.0); // JetsData with kTVXinEMC - } - } - - if (!eventAccepted) { - registry.fill(HIST("h_collisions_unweighted"), 6.0); // JetsData w/o kTVXinEMC - for (auto const& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax) || !isAcceptedJet(jet)) { - fillRejectedJetHistograms(jet, 1.0); - } - } - return; - } - - for (auto const& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - if (jet.phi() < jetPhiMin || jet.phi() > jetPhiMax) { - continue; - } - if (!isAcceptedJet(jet)) { - continue; - } - fillJetHistograms(jet, 1.0); - } - } - PROCESS_SWITCH(FullJetSpectrapp, processJetsData, "Full Jets Data", false); - - void processJetsMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, aod::JetTracks const&, aod::JetClusters const&) - { - registry.fill(HIST("h_collisions_unweighted"), 1.0); // total events - bool eventAccepted = false; - - if (doEMCALEventWorkaround) { - if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content - eventAccepted = true; - if (collision.alias_bit(kTVXinEMC)) { - registry.fill(HIST("h_collisions_unweighted"), 3.0); // JetsMCD with kTVXinEMC - } - } - } else { - if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { - eventAccepted = true; - registry.fill(HIST("h_collisions_unweighted"), 3.0); // JetsMCD with kTVXinEMC - } - } - - if (!eventAccepted) { - registry.fill(HIST("h_collisions_unweighted"), 7.0); // JetsMCD w/o kTVXinEMC - for (auto const& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax) || !isAcceptedJet(jet)) { - fillRejectedJetHistograms(jet, 1.0); - } - } - return; - } - - for (auto const& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - if (jet.phi() < jetPhiMin || jet.phi() > jetPhiMax) { - continue; - } - if (!isAcceptedJet(jet)) { - continue; - } - fillJetHistograms(jet, 1.0); - } - } - PROCESS_SWITCH(FullJetSpectrapp, processJetsMCD, "Full Jets at Detector Level", false); - - void processJetsMCDWeighted(soa::Filtered::iterator const& collision, JetTableMCDWeightedJoined const& jets, aod::JetTracks const&, aod::JetClusters const&) - { - registry.fill(HIST("h_collisions_weighted"), 1.0); // total events - bool eventAccepted = false; - - if (doEMCALEventWorkaround) { - if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content - eventAccepted = true; - if (collision.alias_bit(kTVXinEMC)) { - registry.fill(HIST("h_collisions_weighted"), 2.0); // JetsMCDWeighted with kTVXinEMC - } - } - } else { - if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { - eventAccepted = true; - registry.fill(HIST("h_collisions_weighted"), 2.0); // JetsMCDWeighted with kTVXinEMC - } - } - - if (!eventAccepted) { - registry.fill(HIST("h_collisions_weighted"), 5.0); // JetsMCDWeighted w/o kTVXinEMC - for (auto const& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax) || !isAcceptedJet(jet)) { - fillRejectedJetHistograms(jet, jet.eventWeight()); - } - } - return; - } - - for (auto const& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - if (jet.phi() < jetPhiMin || jet.phi() > jetPhiMax) { - continue; - } - if (!isAcceptedJet(jet)) { - continue; - } - - fillJetHistograms(jet, jet.eventWeight()); - } - } - PROCESS_SWITCH(FullJetSpectrapp, processJetsMCDWeighted, "Full Jets at Detector Level on weighted events", false); - - void processJetsMCP(typename JetTableMCPJoined::iterator const& jet, aod::JetParticles const&, aod::JetMcCollisions const&) - { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - return; - } - if (!isAcceptedJet(jet)) { - return; - } - fillMCPHistograms(jet, 1.0); - } - PROCESS_SWITCH(FullJetSpectrapp, processJetsMCP, "Full Jets at Particle Level", false); - - void processJetsMCPWeighted(typename JetTableMCPWeightedJoined::iterator const& jet, aod::JetParticles const&) - { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - return; - } - if (!isAcceptedJet(jet)) { - return; - } - - fillMCPHistograms(jet, jet.eventWeight()); - } - PROCESS_SWITCH(FullJetSpectrapp, processJetsMCPWeighted, "Full Jets at Particle Level on weighted events", false); - - void processTracks(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, soa::Filtered const& clusters) - { - registry.fill(HIST("h_collisions_unweighted"), 1.0); // total events - bool eventAccepted = false; - // needed for the workaround to access EMCAL trigger bits. - This is needed for the MC productions in which the EMC trigger bits are missing. (MB MC LHC24f3, for ex.) - // It first requires for atleast a cell in EMCAL to have energy content. - // Once it finds a cell content, - // it then checks if the collision is not an ambiguous collision (i.e. it has to be a unique collision = no bunch pile up) - // If all of these conditions are satisfied then it checks for the required trigger bit in EMCAL. - // For LHC22o, since the EMCAL didn't have hardware triggers, one would only require MB trigger (kTVXinEMC) in the EMCAL. - - if (doEMCALEventWorkaround) { - if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content - eventAccepted = true; - if (collision.alias_bit(kTVXinEMC)) { - registry.fill(HIST("h_collisions_unweighted"), 4.0); // Tracks with kTVXinEMC - } - } - } else { - // Check if EMCAL was readout with the MB trigger(kTVXinEMC) fired. If not then reject the event and exit the function. - // This is the default check for the simulations with proper trigger flags not requiring the above workaround. - if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { - eventAccepted = true; - registry.fill(HIST("h_collisions_unweighted"), 4.0); // Tracks with kTVXinEMC - } - } - - if (!eventAccepted) { - registry.fill(HIST("h_collisions_unweighted"), 8.0); // Tracks w/o kTVXinEMC - return; - } - // Fill Accepted events histos - fillTrackHistograms(tracks, clusters, 1.0); - } - PROCESS_SWITCH(FullJetSpectrapp, processTracks, "Full Jet tracks", false); - - void processJetsMCPMCDMatched(soa::Filtered>::iterator const& collision, JetTableMCDMatchedJoined const& mcdjets, JetTableMCPMatchedJoined const&, aod::JMcCollisions const&, aod::JetTracks const&, aod::JetClusters const&, aod::JetParticles const&) - { - registry.fill(HIST("h_collisions_unweighted"), 1.0); // total events - bool eventAccepted = false; - int fakemcdjet = 0; - int fakemcpjet = 0; - - if (fabs(collision.posZ()) > VertexZCut) { // making double sure this condition is satisfied - return; - } - if (!collision.has_mcCollision()) { - return; - } - //**start of event selection** - if (doEMCALEventWorkaround) { - if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content - eventAccepted = true; - if (collision.alias_bit(kTVXinEMC)) { - registry.fill(HIST("h_collisions_unweighted"), 5.0); // JetsMCPMCDMatched with kTVXinEMC - } - } - } else { - if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { - eventAccepted = true; - registry.fill(HIST("h_collisions_unweighted"), 5.0); // JetsMCPMCDMatched with kTVXinEMC - } - } - if (!eventAccepted) { - registry.fill(HIST("h_collisions_unweighted"), 9.0); // JetsMCPMCDMatched w/o kTVXinEMC - return; - } - //**end of event selection** - - for (const auto& mcdjet : mcdjets) { - // Check if MCD jet is within the EMCAL fiducial region - if (mcdjet.phi() < jetPhiMin || mcdjet.phi() > jetPhiMax || mcdjet.eta() < jetEtaMin || mcdjet.eta() > jetEtaMax) { - fakemcdjet++; - registry.fill(HIST("h_collisions_unweighted"), 10.0); // Fake Matched MCD Jets - registry.fill(HIST("h2_full_fakemcdjets"), mcdjet.pt(), fakemcdjet, 1.0); - continue; - } - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - if (!isAcceptedJet(mcdjet)) { - continue; - } - for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { - // apply emcal fiducial cuts to the matched particle level jets - if (mcpjet.eta() > jetEtaMax || mcpjet.eta() < jetEtaMin || mcpjet.phi() > jetPhiMax || mcpjet.phi() < jetPhiMin) { - fakemcpjet++; - registry.fill(HIST("h_collisions_unweighted"), 11.0); // Fake Matched MCP Jets - registry.fill(HIST("h2_full_fakemcpjets"), mcpjet.pt(), fakemcpjet, 1.0); - continue; - } - // Fill MCD jet histograms if a valid MCP jet match was found within the EMCAL region - registry.fill(HIST("h_full_matchedmcpjet_eta"), mcpjet.eta(), 1.0); - registry.fill(HIST("h_full_matchedmcpjet_phi"), mcpjet.phi(), 1.0); - fillMatchedHistograms(mcdjet); - } // mcpjet loop - registry.fill(HIST("h_full_matchedmcdjet_eta"), mcdjet.eta(), 1.0); - registry.fill(HIST("h_full_matchedmcdjet_phi"), mcdjet.phi(), 1.0); - } // mcdjet loop - } - PROCESS_SWITCH(FullJetSpectrapp, processJetsMCPMCDMatched, "Full Jet finder MCP matched to MCD", false); - - void processJetsMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, JetTableMCDMatchedWeightedJoined const& mcdjets, JetTableMCPMatchedWeightedJoined const& mcpjets, aod::JMcCollisions const&, aod::JetTracks const&, aod::JetClusters const&, aod::JetParticles const&) - { - float eventWeight = collision.mcCollision().weight(); - registry.fill(HIST("h_collisions_weighted"), 1.0, eventWeight); // total events - bool eventAccepted = false; - int fakemcdjet = 0; - int fakemcpjet = 0; - float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); - const auto mcpJetsPerMcCollision = mcpjets.sliceBy(JetMCPPerMcCollision, collision.mcCollisionId()); - - for (auto mcpjet : mcpJetsPerMcCollision) { - if (mcpjet.pt() > pTHatMaxMCP * pTHat) { // outlier rejection for MCP - return; - } - } - - if (doEMCALEventWorkaround) { - if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content - eventAccepted = true; - if (collision.alias_bit(kTVXinEMC)) { - registry.fill(HIST("h_collisions_weighted"), 3.0, eventWeight); // JetsMCPMCDMatchedWeighted with kTVXinEMC - } - } - } else { - if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { - eventAccepted = true; - registry.fill(HIST("h_collisions_weighted"), 3.0, eventWeight); // JetsMCPMCDMatchedWeighted with kTVXinEMC - } - } - - if (!eventAccepted) { - registry.fill(HIST("h_collisions_weighted"), 6.0, eventWeight); // JetsMCPMCDMatchedWeighted w/o kTVXinEMC - return; - } - - for (const auto& mcdjet : mcdjets) { - // Check if MCD jet is within the EMCAL fiducial region - if (mcdjet.phi() < jetPhiMin || mcdjet.phi() > jetPhiMax || mcdjet.eta() < jetEtaMin || mcdjet.eta() > jetEtaMax) { - fakemcdjet++; - registry.fill(HIST("h_collisions_weighted"), 8.0); // Fake Matched Weighted MCD Jets - registry.fill(HIST("h2_full_fakemcdjets"), mcdjet.pt(), fakemcdjet, eventWeight); - continue; - } - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - if (!isAcceptedJet(mcdjet)) { - continue; - } - for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { - // apply emcal fiducial cuts to the matched particle level jets - if (mcpjet.eta() > jetEtaMax || mcpjet.eta() < jetEtaMin || mcpjet.phi() > jetPhiMax || mcpjet.phi() < jetPhiMin) { - fakemcpjet++; - registry.fill(HIST("h_collisions_weighted"), 9.0); // Fake Matched Weighted MCP Jets - registry.fill(HIST("h2_full_fakemcpjets"), mcpjet.pt(), fakemcpjet, eventWeight); - continue; - } - // If both MCD-MCP matched jet pairs are within the EMCAL fiducial region, fill these histos - registry.fill(HIST("h_full_matchedmcpjet_eta"), mcpjet.eta(), eventWeight); - registry.fill(HIST("h_full_matchedmcpjet_phi"), mcpjet.phi(), eventWeight); - fillMatchedHistograms(mcdjet, eventWeight); - } // mcpjet - // Fill MCD jet histograms if a valid MCP jet match was found within the EMCAL region - registry.fill(HIST("h_full_matchedmcdjet_eta"), mcdjet.eta(), eventWeight); - registry.fill(HIST("h_full_matchedmcdjet_phi"), mcdjet.phi(), eventWeight); - } // mcdjet - } - PROCESS_SWITCH(FullJetSpectrapp, processJetsMCPMCDMatchedWeighted, "Full Jet finder MCP matched to MCD on weighted events", false); - - void processTracksWeighted(soa::Filtered>::iterator const& collision, - aod::JMcCollisions const&, - soa::Filtered const& tracks, - soa::Filtered const& clusters) - { - bool eventAccepted = false; - float eventWeight = collision.mcCollision().weight(); - registry.fill(HIST("h_collisions_weighted"), 1.0, eventWeight); // total events - - // set "doMBGapTrigger" to true only if you are testing with MB Gap-triggers - if (doMBGapTrigger && eventWeight == 1) { - return; - } - - if (doEMCALEventWorkaround) { - if (collision.isEmcalReadout() && !collision.isAmbiguous()) { // i.e. EMCAL has a cell content - eventAccepted = true; - fillTrackHistograms(tracks, clusters, eventWeight); - if (collision.alias_bit(kTVXinEMC)) { - registry.fill(HIST("h_collisions_weighted"), 4.0, eventWeight); // TracksWeighted with kTVXinEMC - } - } - } else { - // Check if EMCAL was readout with the MB trigger(kTVXinEMC) fired. If not then reject the event and exit the function. - // This is the default check for the simulations with proper trigger flags not requiring the above workaround. - if (!collision.isAmbiguous() && jetderiveddatautilities::eventEMCAL(collision) && collision.alias_bit(kTVXinEMC)) { - eventAccepted = true; - registry.fill(HIST("h_collisions_weighted"), 4.0, eventWeight); // TracksWeighted with kTVXinEMC - } - } - - if (!eventAccepted) { - registry.fill(HIST("h_collisions_weighted"), 7.0, eventWeight); // TracksWeighted w/o kTVXinEMC - return; - } - // registry.fill(HIST("h_gaptrig_collisions"), 1.0, eventWeight); - fillTrackHistograms(tracks, clusters, eventWeight); - } - PROCESS_SWITCH(FullJetSpectrapp, processTracksWeighted, "Full Jet tracks weighted", false); - -}; // struct - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"full-jet-spectra-pp"})}; -} diff --git a/PWGJE/Tasks/fullJetTriggerQATask.cxx b/PWGJE/Tasks/fullJetTriggerQATask.cxx index c9a9152381d..1831a3c3372 100644 --- a/PWGJE/Tasks/fullJetTriggerQATask.cxx +++ b/PWGJE/Tasks/fullJetTriggerQATask.cxx @@ -13,25 +13,41 @@ // /// \author Gijs van Weelden // -#include -#include +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/DataModel/EMCALClusterDefinition.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "TH1F.h" -#include "TTree.h" +#include "Common/CCDB/TriggerAliases.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/RunningWorkflowInfo.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include +#include -#include "Common/DataModel/EventSelection.h" +#include "TTree.h" +#include +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include +#include -#include "EventFiltering/filterTables.h" +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -88,6 +104,7 @@ struct JetTriggerQA { Configurable b_DoFiducialCut{"b_DoFiducialCut", false, "do a fiducial cut on jets to check if they are in the emcal"}; Configurable b_RejectExoticClusters{"b_RejectExoticClusters", true, "Reject exotic clusters"}; Configurable f_GammaObservable{"f_gammaObservable", 0, "Observable for gamma trigger (0 - energy, 1 - pt)"}; + Configurable b_doLightOutput{"b_doLightOutput", true, "do light output (disables most histograms not needed for QA)"}; Configurable cfgVertexCut{"cfgVertexCut", 10.0f, "Accepted z-vertex range"}; Configurable mClusterDefinition{"clusterDefinition", "kV3Default", "cluster definition to be selected, e.g. V3Default"}; @@ -103,18 +120,18 @@ struct JetTriggerQA { jetReclusterer.algorithm = fastjet::JetAlgorithm::cambridge_algorithm; jetReclusterer.jetR = f_jetR * 2.5; // Use larger R for CA reclustering to prevent losing particles - Int_t nPtBins = 200; - Float_t kMinPt = 0.; - Float_t kMaxPt = 201.; - Int_t nPhiBins = 18 * 8; - Float_t kMinPhi = 0.; - Float_t kMaxPhi = 2. * TMath::Pi(); - Int_t nEtaBins = 100; - Float_t kMinEta = -1.; - Float_t kMaxEta = 1.; - Int_t nRBins = 6; - Float_t kMinR = 0.05; - Float_t kMaxR = 0.65; + int nPtBins = 200; + float kMinPt = 0.; + float kMaxPt = 201.; + int nPhiBins = 18 * 8; + float kMinPhi = 0.; + float kMaxPhi = o2::constants::math::TwoPI; + int nEtaBins = 100; + float kMinEta = -1.; + float kMaxEta = 1.; + int nRBins = 6; + float kMinR = 0.05; + float kMaxR = 0.65; // EMCAL gamma observables (for histogram and axis title) std::string observableName = (f_GammaObservable == 0) ? "Energy" : "#it{p}_{T}", @@ -137,9 +154,11 @@ struct JetTriggerQA { HistogramConfigSpec hJetRMaxPtEtaPhiNoFiducial({HistType::kTHnF, {rAxis, jetPtAxis, etaAxis, phiAxis}}); registry.add("jetRPtEtaPhi", "JetRPtEtaPhi", hJetRPtEtaPhi); - registry.add("jetRMaxPtEtaPhi", "JetRMaxPtEtaPhi", hJetRMaxPtEtaPhi); + if (!b_doLightOutput) + registry.add("jetRMaxPtEtaPhi", "JetRMaxPtEtaPhi", hJetRMaxPtEtaPhi); registry.add("jetRPtEtaPhiNoFiducial", "JetRPtEtaPhiNoFiducial", hJetRPtEtaPhiNoFiducial); - registry.add("jetRMaxPtEtaPhiNoFiducial", "JetRMaxPtEtaPhiNoFiducial", hJetRMaxPtEtaPhiNoFiducial); + if (!b_doLightOutput) + registry.add("jetRMaxPtEtaPhiNoFiducial", "JetRMaxPtEtaPhiNoFiducial", hJetRMaxPtEtaPhiNoFiducial); registry.add("hProcessedEvents", "Processed events", HistType::kTH1D, {{15, -0.5, 14.5, "Trigger type"}}); auto histProcessed = registry.get(HIST("hProcessedEvents")); @@ -170,156 +189,192 @@ struct JetTriggerQA { // Histograms for events where the EMCAL is live registry.add("hJetRPtEta", "Jets #it{p}_{T} and #eta", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); registry.add("hJetRPtPhi", "Jets #it{p}_{T} and #phi", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); - registry.add("hJetRMaxPtEta", "Leading jets #it{p}_{T} and #eta", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); - registry.add("hJetRMaxPtPhi", "Leading jets #it{p}_{T} and #phi", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); - registry.add("hJetRMaxPtEtaMinBias", "Leading jets #it{p}_{T} and #eta (min. bias)", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); - registry.add("hJetRMaxPtPhiMinBias", "Leading jets #it{p}_{T} and #phi (min. bias)", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); - registry.add("hJetRMaxPtEtaLevel0", "Leading jets #it{p}_{T} and #eta (level0)", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); - registry.add("hJetRMaxPtPhiLevel0", "Leading jets #it{p}_{T} and #phi (level0)", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); + if (!b_doLightOutput) { + registry.add("hJetRMaxPtEta", "Leading jets #it{p}_{T} and #eta", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); + registry.add("hJetRMaxPtPhi", "Leading jets #it{p}_{T} and #phi", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); + registry.add("hJetRMaxPtEtaMinBias", "Leading jets #it{p}_{T} and #eta (min. bias)", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); + registry.add("hJetRMaxPtPhiMinBias", "Leading jets #it{p}_{T} and #phi (min. bias)", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); + registry.add("hJetRMaxPtEtaLevel0", "Leading jets #it{p}_{T} and #eta (level0)", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); + registry.add("hJetRMaxPtPhiLevel0", "Leading jets #it{p}_{T} and #phi (level0)", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); + } registry.add("hClusterPtEtaPhi", Form("Cluster %s, #eta and #phi", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); registry.add("hClusterPtEtaPhiMinBias", Form("Cluster %s (Min. bias trigger), #eta and #phi", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); registry.add("hClusterPtEtaPhiLevel0", Form("Cluster %s (Level-0 trigger), #eta and #phi", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hClusterEMCALMaxPtEtaPhi", Form("Leading cluster %s, #eta and #phi (EMCAL)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hClusterEMCALMaxPtEtaPhiMinBias", Form("Leading cluster %s, #eta and #phi (EMCAL, min. bias trigger)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hClusterEMCALMaxPtEtaPhiLevel0", Form("Leading cluster %s, #eta and #phi (EMCAL, Level-0 trigger)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hClusterDCALMaxPtEtaPhi", Form("Leading cluster %s, #eta and #phi (DCAL)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hClusterDCALMaxPtEtaPhiMinBias", Form("Leading cluster %s, #eta and #phi (DCAL, min, bias trigger)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hClusterDCALMaxPtEtaPhiLevel0", Form("Leading cluster %s, #eta and #phi (DCAL, Level-0 trigger)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hEventsNoMaxClusterEMCAL", "Events with no max. cluster in EMCAL", HistType::kTH1D, {{1, 0.5, 1.5}}); - registry.add("hEventsNoMaxClusterEMCALMinBias", "Events with no max. cluster in EMCAL (min. bias trigger)", HistType::kTH1D, {{1, 0.5, 1.5}}); - registry.add("hEventsNoMaxClusterEMCALLevel0", "Events with no max. cluster in EMCAL (level0 trigger)", HistType::kTH1D, {{1, 0.5, 1.5}}); - registry.add("hEventsNoMaxClusterDCAL", ("Events with no max. cluster in DCAL"), HistType::kTH1D, {{1, 0.5, 1.5}}); - registry.add("hEventsNoMaxClusterDCALMinBias", "Events with no max. cluster in DCAL (min. bias trigger)", HistType::kTH1D, {{1, 0.5, 1.5}}); - registry.add("hEventsNoMaxClusterDCALLevel0", "Events with no max. cluster in DCAL (level0 trigger)", HistType::kTH1D, {{1, 0.5, 1.5}}); - registry.add("hEventsNoMaxJet", "Events with no max. jet", HistType::kTH1D, {{rAxis}}); - registry.add("hEventsNoMaxJetMinBias", "Events with no max. jet (min. bias trigger)", HistType::kTH1D, {{rAxis}}); - registry.add("hEventsNoMaxJetLevel0", "Events with no max. jet (level0 trigger)", HistType::kTH1D, {{rAxis}}); - registry.add("hJetRPtTrackPt", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisTrackInJet}); - registry.add("hJetRPtClusterPt", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisClusterInJet}); - registry.add("hJetRPtPtd", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "p_{t,D}"}}); - registry.add("hJetRPtChargeFrag", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z"}}); - registry.add("hJetRPtNEF", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "NEF"}}); - registry.add("hJetRPtZTheta", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z#theta"}}); - registry.add("hJetRPtZSqTheta", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z^{2} #theta"}}); - registry.add("hJetRPtZThetaSq", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z #theta^{2}"}}); - registry.add("hJetRMaxPtClusterMaxPt", "Leading jets and clusters", HistType::kTH3F, {rAxis, jetPtAxis, observableAxisCluster}); + + if (!b_doLightOutput) { + registry.add("hClusterEMCALMaxPtEtaPhi", Form("Leading cluster %s, #eta and #phi (EMCAL)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + registry.add("hClusterEMCALMaxPtEtaPhiMinBias", Form("Leading cluster %s, #eta and #phi (EMCAL, min. bias trigger)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + registry.add("hClusterEMCALMaxPtEtaPhiLevel0", Form("Leading cluster %s, #eta and #phi (EMCAL, Level-0 trigger)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + registry.add("hClusterDCALMaxPtEtaPhi", Form("Leading cluster %s, #eta and #phi (DCAL)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + registry.add("hClusterDCALMaxPtEtaPhiMinBias", Form("Leading cluster %s, #eta and #phi (DCAL, min, bias trigger)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + registry.add("hClusterDCALMaxPtEtaPhiLevel0", Form("Leading cluster %s, #eta and #phi (DCAL, Level-0 trigger)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + registry.add("hEventsNoMaxClusterEMCAL", "Events with no max. cluster in EMCAL", HistType::kTH1D, {{1, 0.5, 1.5}}); + registry.add("hEventsNoMaxClusterEMCALMinBias", "Events with no max. cluster in EMCAL (min. bias trigger)", HistType::kTH1D, {{1, 0.5, 1.5}}); + registry.add("hEventsNoMaxClusterEMCALLevel0", "Events with no max. cluster in EMCAL (level0 trigger)", HistType::kTH1D, {{1, 0.5, 1.5}}); + registry.add("hEventsNoMaxClusterDCAL", ("Events with no max. cluster in DCAL"), HistType::kTH1D, {{1, 0.5, 1.5}}); + registry.add("hEventsNoMaxClusterDCALMinBias", "Events with no max. cluster in DCAL (min. bias trigger)", HistType::kTH1D, {{1, 0.5, 1.5}}); + registry.add("hEventsNoMaxClusterDCALLevel0", "Events with no max. cluster in DCAL (level0 trigger)", HistType::kTH1D, {{1, 0.5, 1.5}}); + registry.add("hEventsNoMaxJet", "Events with no max. jet", HistType::kTH1D, {{rAxis}}); + registry.add("hEventsNoMaxJetMinBias", "Events with no max. jet (min. bias trigger)", HistType::kTH1D, {{rAxis}}); + registry.add("hEventsNoMaxJetLevel0", "Events with no max. jet (level0 trigger)", HistType::kTH1D, {{rAxis}}); + + registry.add("hJetRPtTrackPt", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisTrackInJet}); + registry.add("hJetRPtClusterPt", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisClusterInJet}); + registry.add("hJetRPtPtd", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "p_{t,D}"}}); + registry.add("hJetRPtChargeFrag", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z"}}); + registry.add("hJetRPtNEF", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "NEF"}}); + registry.add("hJetRPtZTheta", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z#theta"}}); + registry.add("hJetRPtZSqTheta", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z^{2} #theta"}}); + registry.add("hJetRPtZThetaSq", "Jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z #theta^{2}"}}); + + registry.add("hJetRMaxPtClusterMaxPt", "Leading jets and clusters", HistType::kTH3F, {rAxis, jetPtAxis, observableAxisCluster}); + } // Histograms for triggered events registry.add("hSelectedClusterPtEtaPhi", Form("Selected cluster %s, #eta and #phi", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hSelectedClusterMaxPtEtaPhi", Form("Leading Selected cluster %s, #eta and #phi", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + + if (!b_doLightOutput) { + registry.add("hSelectedClusterMaxPtEtaPhi", Form("Leading Selected cluster %s, #eta and #phi", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + } // Jet high trigger - registry.add("hSelectedJetRMaxPtEta", "Leading selected jets #it{p}_{T} and #eta", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); - registry.add("hSelectedJetRMaxPtPhi", "Leading selected jets #it{p}_{T} and #phi", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); + if (!b_doLightOutput) { + registry.add("hSelectedJetRMaxPtEta", "Leading selected jets #it{p}_{T} and #eta", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); + registry.add("hSelectedJetRMaxPtPhi", "Leading selected jets #it{p}_{T} and #phi", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); + } registry.add("hSelectedJetRPtEta", "Selected jets #it{p}_{T} and #eta", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); registry.add("hSelectedJetRPtPhi", "Selected jets #it{p}_{T} and #phi", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); - registry.add("hSelectedJetRPtTrackPt", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisTrackInJet}); - registry.add("hSelectedJetRPtClusterPt", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisClusterInJet}); - registry.add("hSelectedJetRPtPtd", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "p_{t,D}"}}); - registry.add("hSelectedJetRPtChargeFrag", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z"}}); - registry.add("hSelectedJetRPtNEF", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "NEF"}}); - registry.add("hSelectedJetRPtZTheta", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z#theta"}}); - registry.add("hSelectedJetRPtZSqTheta", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z^{2} #theta"}}); - registry.add("hSelectedJetRPtZThetaSq", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z #theta^{2}"}}); + if (!b_doLightOutput) { + registry.add("hSelectedJetRPtTrackPt", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisTrackInJet}); + registry.add("hSelectedJetRPtClusterPt", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisClusterInJet}); + registry.add("hSelectedJetRPtPtd", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "p_{t,D}"}}); + registry.add("hSelectedJetRPtChargeFrag", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z"}}); + registry.add("hSelectedJetRPtNEF", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "NEF"}}); + registry.add("hSelectedJetRPtZTheta", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z#theta"}}); + registry.add("hSelectedJetRPtZSqTheta", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z^{2} #theta"}}); + registry.add("hSelectedJetRPtZThetaSq", "Selected jets", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z #theta^{2}"}}); + } // Jet low trigger - registry.add("hSelectedJetLowRMaxPtEta", "Leading selected jets (low threshold) #it{p}_{T} and #eta", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); - registry.add("hSelectedJetLowRMaxPtPhi", "Leading selected jets (low threshold) #it{p}_{T} and #phi", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); + if (!b_doLightOutput) { + registry.add("hSelectedJetLowRMaxPtEta", "Leading selected jets (low threshold) #it{p}_{T} and #eta", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); + registry.add("hSelectedJetLowRMaxPtPhi", "Leading selected jets (low threshold) #it{p}_{T} and #phi", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); + } registry.add("hSelectedJetLowRPtEta", "Selected jets (low threshold) #it{p}_{T} and #eta", HistType::kTH3F, {rAxis, jetPtAxis, etaAxis}); registry.add("hSelectedJetLowRPtPhi", "Selected jets (low threshold) #it{p}_{T} and #phi", HistType::kTH3F, {rAxis, jetPtAxis, phiAxis}); - registry.add("hSelectedJetLowRPtTrackPt", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisTrackInJet}); - registry.add("hSelectedJetLowRPtClusterPt", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisClusterInJet}); - registry.add("hSelectedJetLowRPtPtd", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "p_{t,D}"}}); - registry.add("hSelectedJetLowRPtChargeFrag", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z"}}); - registry.add("hSelectedJetLowRPtNEF", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "NEF"}}); - registry.add("hSelectedJetLowRPtZTheta", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z#theta"}}); - registry.add("hSelectedJetLowRPtZSqTheta", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z^{2} #theta"}}); - registry.add("hSelectedJetLowRPtZThetaSq", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z #theta^{2}"}}); + + if (!b_doLightOutput) { + registry.add("hSelectedJetLowRPtTrackPt", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisTrackInJet}); + registry.add("hSelectedJetLowRPtClusterPt", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, ptAxisClusterInJet}); + registry.add("hSelectedJetLowRPtPtd", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "p_{t,D}"}}); + registry.add("hSelectedJetLowRPtChargeFrag", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z"}}); + registry.add("hSelectedJetLowRPtNEF", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "NEF"}}); + registry.add("hSelectedJetLowRPtZTheta", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z#theta"}}); + registry.add("hSelectedJetLowRPtZSqTheta", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z^{2} #theta"}}); + registry.add("hSelectedJetLowRPtZThetaSq", "Selected jets (low threshold)", HistType::kTH3F, {rAxis, jetPtAxis, {nPtBins / 2, 0., 1., "z #theta^{2}"}}); + } // EMCAL gamma very-high trigger registry.add("hSelectedGammaEMCALPtEtaPhiVeryHigh", Form("Selected Gamma %s, #eta and #phi (EMCAL, very high threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hSelectedGammaEMCALMaxPtEtaPhiVeryHigh", Form("Leading selected gamma %s, #eta and #phi (EMCAL, very high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + if (!b_doLightOutput) + registry.add("hSelectedGammaEMCALMaxPtEtaPhiVeryHigh", Form("Leading selected gamma %s, #eta and #phi (EMCAL, very high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); // DCAL gamma very-high trigger registry.add("hSelectedGammaDCALPtEtaPhiVeryHigh", Form("Selected gamma %s, #eta and #phi (DCAL, very high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hSelectedGammaDCALMaxPtEtaPhiVeryHigh", Form("Leading selected gamma %s, #eta and #phi (DCAL, very high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + if (!b_doLightOutput) + registry.add("hSelectedGammaDCALMaxPtEtaPhiVeryHigh", Form("Leading selected gamma %s, #eta and #phi (DCAL, very high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); // EG1 trigger registry.add("hSelectedGammaEMCALPtEtaPhi", Form("Selected Gamma %s, #eta and #phi (EMCAL, high threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hSelectedGammaEMCALMaxPtEtaPhi", Form("Leading selected gamma %s, #eta and #phi (EMCAL, high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + if (!b_doLightOutput) + registry.add("hSelectedGammaEMCALMaxPtEtaPhi", Form("Leading selected gamma %s, #eta and #phi (EMCAL, high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); // DG1 trigger registry.add("hSelectedGammaDCALPtEtaPhi", Form("Selected gamma %s, #eta and #phi (DCAL, high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hSelectedGammaDCALMaxPtEtaPhi", Form("Leading selected gamma %s, #eta and #phi (DCAL, high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + if (!b_doLightOutput) + registry.add("hSelectedGammaDCALMaxPtEtaPhi", Form("Leading selected gamma %s, #eta and #phi (DCAL, high treshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); // EG2 trigger registry.add("hSelectedGammaEMCALPtEtaPhiLow", Form("Selected gamma %s, #eta and #phi (EMCAL, low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hSelectedGammaEMCALMaxPtEtaPhiLow", Form("Leading selected gamma %s, #eta and #phi (EMCAL, low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + if (!b_doLightOutput) + registry.add("hSelectedGammaEMCALMaxPtEtaPhiLow", Form("Leading selected gamma %s, #eta and #phi (EMCAL, low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); // DG2 trigger registry.add("hSelectedGammaDCALPtEtaPhiLow", Form("Selected gamma %s, #eta and #phi (DCAL, low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hSelectedGammaDCALMaxPtEtaPhiLow", Form("Leading selected gamma %s, #eta and #phi (DCAL, low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + if (!b_doLightOutput) + registry.add("hSelectedGammaDCALMaxPtEtaPhiLow", Form("Leading selected gamma %s, #eta and #phi (DCAL, low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); // EMCAL gamma very-low trigger registry.add("hSelectedGammaEMCALPtEtaPhiVeryLow", Form("Selected gamma %s, #eta and #phi (EMCAL, very low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hSelectedGammaEMCALMaxPtEtaPhiVeryLow", Form("Leading selected gamma %s, #eta and #phi (EMCAL, very low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + if (!b_doLightOutput) + registry.add("hSelectedGammaEMCALMaxPtEtaPhiVeryLow", Form("Leading selected gamma %s, #eta and #phi (EMCAL, very low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); // DCAL gamma very-low trigger registry.add("hSelectedGammaDCALPtEtaPhiVeryLow", Form("Selected gamma %s, #eta and #phi (DCAL, low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - registry.add("hSelectedGammaDCALMaxPtEtaPhiVeryLow", Form("Leading selected gamma %s, #eta and #phi (DCAL, low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); - - registry.add("hSelectedJetRMaxPtClusterMaxPt", "Leading selected jets and clusters", HistType::kTH3F, {rAxis, jetPtAxis, observableAxisCluster}); - registry.add("hJetRMaxPtJetPt", "Leading jet #it{p}_{T} vs jet #it{p}_{T}", HistType::kTH3F, {rAxis, jetMaxPtAxis, jetPtAxis}); - registry.add("hJetRMaxPtJetPtNoFiducial", "Leading jet #it{p}_{T} vs jet #it{p}_{T} (no fiducial cut)", HistType::kTH3F, {rAxis, jetMaxPtAxis, jetPtAxis}); - registry.add("hClusterEMCALMaxPtClusterEMCALPt", Form("Leading clusterEMCAL %s vs clusterEMCAL %s", observableName.data(), observableName.data()), HistType::kTH2F, {observableAxisMaxCluster, observableAxisCluster}); - registry.add("hClusterDCALMaxPtClusterDCALPt", Form("Leading clusterDCAL %s vs clusterDCAL %s", observableName.data(), observableName.data()), HistType::kTH2F, {observableAxisMaxCluster, observableAxisCluster}); + if (!b_doLightOutput) + registry.add("hSelectedGammaDCALMaxPtEtaPhiVeryLow", Form("Leading selected gamma %s, #eta and #phi (DCAL, low threshold)", observableName.data()), HistType::kTH3F, {observableAxisCluster, etaAxis, phiAxis}); + + if (!b_doLightOutput) { + registry.add("hSelectedJetRMaxPtClusterMaxPt", "Leading selected jets and clusters", HistType::kTH3F, {rAxis, jetPtAxis, observableAxisCluster}); + registry.add("hJetRMaxPtJetPt", "Leading jet #it{p}_{T} vs jet #it{p}_{T}", HistType::kTH3F, {rAxis, jetMaxPtAxis, jetPtAxis}); + registry.add("hJetRMaxPtJetPtNoFiducial", "Leading jet #it{p}_{T} vs jet #it{p}_{T} (no fiducial cut)", HistType::kTH3F, {rAxis, jetMaxPtAxis, jetPtAxis}); + registry.add("hClusterEMCALMaxPtClusterEMCALPt", Form("Leading clusterEMCAL %s vs clusterEMCAL %s", observableName.data(), observableName.data()), HistType::kTH2F, {observableAxisMaxCluster, observableAxisCluster}); + registry.add("hClusterDCALMaxPtClusterDCALPt", Form("Leading clusterDCAL %s vs clusterDCAL %s", observableName.data(), observableName.data()), HistType::kTH2F, {observableAxisMaxCluster, observableAxisCluster}); + } if (b_JetsInEmcalOnly) { registry.get(HIST("hJetRPtEta"))->SetTitle("Jets (in emcal only) #it{p}_{T} and #eta"); registry.get(HIST("hJetRPtPhi"))->SetTitle("Jets (in emcal only) #it{p}_{T} and #phi"); - registry.get(HIST("hJetRPtTrackPt"))->SetTitle("Jets (in emcal only)"); - registry.get(HIST("hJetRPtClusterPt"))->SetTitle("Jets (in emcal only)"); - registry.get(HIST("hJetRPtPtd"))->SetTitle("Jets (in emcal only)"); - registry.get(HIST("hJetRPtChargeFrag"))->SetTitle("Jets (in emcal only)"); - registry.get(HIST("hJetRPtNEF"))->SetTitle("Jets (in emcal only)"); - registry.get(HIST("hJetRPtZTheta"))->SetTitle("Jets (in emcal only)"); - registry.get(HIST("hJetRPtZSqTheta"))->SetTitle("Jets (in emcal only)"); - registry.get(HIST("hJetRPtZThetaSq"))->SetTitle("Jets (in emcal only)"); - registry.get(HIST("hJetRMaxPtEta"))->SetTitle("Leading jets (in emcal only) #it{p}_{T} and #eta"); - registry.get(HIST("hJetRMaxPtPhi"))->SetTitle("Leading jets (in emcal only) #it{p}_{T} and #phi"); - registry.get(HIST("hJetRMaxPtEtaMinBias"))->SetTitle("Leading jets (in emcal only, min. bias) #it{p}_{T} and #eta"); - registry.get(HIST("hJetRMaxPtPhiMinBias"))->SetTitle("Leading jets (in emcal only, min. bias) #it{p}_{T} and #phi"); - registry.get(HIST("hJetRMaxPtEtaLevel0"))->SetTitle("Leading jets (in emcal only, level-0) #it{p}_{T} and #eta"); - registry.get(HIST("hJetRMaxPtPhiLevel0"))->SetTitle("Leading jets (in emcal only, level-0) #it{p}_{T} and #phi"); - registry.get(HIST("hJetRMaxPtClusterMaxPt"))->SetTitle("Leading jets (in emcal only) and clusters"); + if (!b_doLightOutput) { + registry.get(HIST("hJetRPtTrackPt"))->SetTitle("Jets (in emcal only)"); + registry.get(HIST("hJetRPtClusterPt"))->SetTitle("Jets (in emcal only)"); + registry.get(HIST("hJetRPtPtd"))->SetTitle("Jets (in emcal only)"); + registry.get(HIST("hJetRPtChargeFrag"))->SetTitle("Jets (in emcal only)"); + registry.get(HIST("hJetRPtNEF"))->SetTitle("Jets (in emcal only)"); + registry.get(HIST("hJetRPtZTheta"))->SetTitle("Jets (in emcal only)"); + registry.get(HIST("hJetRPtZSqTheta"))->SetTitle("Jets (in emcal only)"); + registry.get(HIST("hJetRPtZThetaSq"))->SetTitle("Jets (in emcal only)"); + + registry.get(HIST("hJetRMaxPtEta"))->SetTitle("Leading jets (in emcal only) #it{p}_{T} and #eta"); + registry.get(HIST("hJetRMaxPtPhi"))->SetTitle("Leading jets (in emcal only) #it{p}_{T} and #phi"); + registry.get(HIST("hJetRMaxPtEtaMinBias"))->SetTitle("Leading jets (in emcal only, min. bias) #it{p}_{T} and #eta"); + registry.get(HIST("hJetRMaxPtPhiMinBias"))->SetTitle("Leading jets (in emcal only, min. bias) #it{p}_{T} and #phi"); + registry.get(HIST("hJetRMaxPtEtaLevel0"))->SetTitle("Leading jets (in emcal only, level-0) #it{p}_{T} and #eta"); + registry.get(HIST("hJetRMaxPtPhiLevel0"))->SetTitle("Leading jets (in emcal only, level-0) #it{p}_{T} and #phi"); + registry.get(HIST("hJetRMaxPtClusterMaxPt"))->SetTitle("Leading jets (in emcal only) and clusters"); + } registry.get(HIST("hSelectedJetRPtEta"))->SetTitle("Selected jets (in emcal only) #it{p}_{T} and #eta"); registry.get(HIST("hSelectedJetRPtPhi"))->SetTitle("Selected jets (in emcal only) #it{p}_{T} and #phi"); - registry.get(HIST("hSelectedJetRPtTrackPt"))->SetTitle("Selected jets (in emcal only)"); - registry.get(HIST("hSelectedJetRPtClusterPt"))->SetTitle("Selected jets (in emcal only)"); - registry.get(HIST("hSelectedJetRPtPtd"))->SetTitle("Selected jets (in emcal only)"); - registry.get(HIST("hSelectedJetRPtChargeFrag"))->SetTitle("Selected jets (in emcal only)"); - registry.get(HIST("hSelectedJetRPtNEF"))->SetTitle("Selected jets (in emcal only)"); - registry.get(HIST("hSelectedJetRPtZTheta"))->SetTitle("Selected jets (in emcal only)"); - registry.get(HIST("hSelectedJetRPtZSqTheta"))->SetTitle("Selected jets (in emcal only)"); - registry.get(HIST("hSelectedJetRPtZThetaSq"))->SetTitle("Selected jets (in emcal only)"); + if (!b_doLightOutput) { + registry.get(HIST("hSelectedJetRPtTrackPt"))->SetTitle("Selected jets (in emcal only)"); + registry.get(HIST("hSelectedJetRPtClusterPt"))->SetTitle("Selected jets (in emcal only)"); + registry.get(HIST("hSelectedJetRPtPtd"))->SetTitle("Selected jets (in emcal only)"); + registry.get(HIST("hSelectedJetRPtChargeFrag"))->SetTitle("Selected jets (in emcal only)"); + registry.get(HIST("hSelectedJetRPtNEF"))->SetTitle("Selected jets (in emcal only)"); + registry.get(HIST("hSelectedJetRPtZTheta"))->SetTitle("Selected jets (in emcal only)"); + registry.get(HIST("hSelectedJetRPtZSqTheta"))->SetTitle("Selected jets (in emcal only)"); + registry.get(HIST("hSelectedJetRPtZThetaSq"))->SetTitle("Selected jets (in emcal only)"); + } registry.get(HIST("hSelectedJetLowRPtEta"))->SetTitle("Selected jets (low threshold, in emcal only) #it{p}_{T} and #eta"); registry.get(HIST("hSelectedJetLowRPtPhi"))->SetTitle("Selected jets (low threshold, in emcal only) #it{p}_{T} and #phi"); - registry.get(HIST("hSelectedJetLowRPtTrackPt"))->SetTitle("Selected jets (low threshold, in emcal only)"); - registry.get(HIST("hSelectedJetLowRPtClusterPt"))->SetTitle("Selected jets (low threshold, in emcal only)"); - registry.get(HIST("hSelectedJetLowRPtPtd"))->SetTitle("Selected jets (low threshold, in emcal only)"); - registry.get(HIST("hSelectedJetLowRPtChargeFrag"))->SetTitle("Selected jets (low threshold, in emcal only)"); - registry.get(HIST("hSelectedJetLowRPtNEF"))->SetTitle("Selected jets (low threshold, in emcal only)"); - registry.get(HIST("hSelectedJetLowRPtZTheta"))->SetTitle("Selected jets (low threshold, in emcal only)"); - registry.get(HIST("hSelectedJetLowRPtZSqTheta"))->SetTitle("Selected jets (low threshold, in emcal only)"); - registry.get(HIST("hSelectedJetLowRPtZThetaSq"))->SetTitle("Selected jets (low threshold, in emcal only)"); - - registry.get(HIST("hSelectedJetRMaxPtEta"))->SetTitle("Leading selected jets (in emcal only) #it{p}_{T} and #eta"); - registry.get(HIST("hSelectedJetRMaxPtPhi"))->SetTitle("Leading selected jets (in emcal only) #it{p}_{T} and #phi"); - registry.get(HIST("hSelectedJetRMaxPtClusterMaxPt"))->SetTitle("Leading selected jets (in emcal only) and clusters"); - - registry.get(HIST("hJetRMaxPtJetPt"))->SetTitle("Leading jet #it{p}_{T} vs jet #it{p}_{T} (in emcal only)"); + if (!b_doLightOutput) { + registry.get(HIST("hSelectedJetLowRPtTrackPt"))->SetTitle("Selected jets (low threshold, in emcal only)"); + registry.get(HIST("hSelectedJetLowRPtClusterPt"))->SetTitle("Selected jets (low threshold, in emcal only)"); + registry.get(HIST("hSelectedJetLowRPtPtd"))->SetTitle("Selected jets (low threshold, in emcal only)"); + registry.get(HIST("hSelectedJetLowRPtChargeFrag"))->SetTitle("Selected jets (low threshold, in emcal only)"); + registry.get(HIST("hSelectedJetLowRPtNEF"))->SetTitle("Selected jets (low threshold, in emcal only)"); + registry.get(HIST("hSelectedJetLowRPtZTheta"))->SetTitle("Selected jets (low threshold, in emcal only)"); + registry.get(HIST("hSelectedJetLowRPtZSqTheta"))->SetTitle("Selected jets (low threshold, in emcal only)"); + registry.get(HIST("hSelectedJetLowRPtZThetaSq"))->SetTitle("Selected jets (low threshold, in emcal only)"); + + registry.get(HIST("hSelectedJetRMaxPtEta"))->SetTitle("Leading selected jets (in emcal only) #it{p}_{T} and #eta"); + registry.get(HIST("hSelectedJetRMaxPtPhi"))->SetTitle("Leading selected jets (in emcal only) #it{p}_{T} and #phi"); + registry.get(HIST("hSelectedJetRMaxPtClusterMaxPt"))->SetTitle("Leading selected jets (in emcal only) and clusters"); + + registry.get(HIST("hJetRMaxPtJetPt"))->SetTitle("Leading jet #it{p}_{T} vs jet #it{p}_{T} (in emcal only)"); + } } } // init @@ -328,16 +383,16 @@ struct JetTriggerQA { double check_dphi(double dphi) const { - if (dphi > TMath::Pi()) { - dphi -= TMath::Pi(); - } else if (dphi <= -1 * TMath::Pi()) { - dphi += TMath::Pi(); + if (dphi > o2::constants::math::PI) { + dphi -= o2::constants::math::PI; + } else if (dphi <= -1 * o2::constants::math::PI) { + dphi += o2::constants::math::PI; } return dphi; } template - Bool_t isJetInEmcal(T const& jet) + bool isJetInEmcal(T const& jet) { double emcalEtaMin = -0.7, emcalEtaMax = 0.7, emcalPhiMin = 1.40, emcalPhiMax = 3.26; // Phi: 80 - 187 deg double R = jet.r() * 1e-2; // Jet R is saved as round(100*R) @@ -351,7 +406,7 @@ struct JetTriggerQA { { std::array selectAliases = {{triggerAliases::kTVXinEMC, triggerAliases::kEMC7, triggerAliases::kDMC7, triggerAliases::kEG1, triggerAliases::kEG2, triggerAliases::kDG1, triggerAliases::kDG2, triggerAliases::kEJ1, triggerAliases::kEJ2, triggerAliases::kDJ1, triggerAliases::kDJ2}}; bool found = false; - for (auto alias : selectAliases) { + for (const auto& alias : selectAliases) { if (collision.alias_bit(alias)) { found = true; break; @@ -360,7 +415,7 @@ struct JetTriggerQA { return found; } - Bool_t isClusterInEmcal(selectedClusters::iterator const& cluster) + bool isClusterInEmcal(selectedClusters::iterator const& cluster) { if (cluster.phi() < f_PhiEmcalOrDcal) { return true; @@ -466,78 +521,79 @@ struct JetTriggerQA { registry.fill(HIST("hSelectedGammaDCALPtEtaPhiVeryLow"), clusterObservable, cluster.eta(), cluster.phi()); } } // for clusters - - if (maxClusterObservableEMCAL > 0) { - registry.fill(HIST("hClusterEMCALMaxPtEtaPhi"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); - if (hwtrg.test(EMCALHardwareTrigger::TRG_MB)) { - registry.fill(HIST("hClusterEMCALMaxPtEtaPhiMinBias"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); - } - if (hwtrg.test(EMCALHardwareTrigger::TRG_EMC7)) { - registry.fill(HIST("hClusterEMCALMaxPtEtaPhiLevel0"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); - } - for (const auto& cluster : analysedClusters) { - if (cluster.mEMCALcluster) { - registry.fill(HIST("hClusterEMCALMaxPtClusterEMCALPt"), maxClusterObservableEMCAL, cluster.mTriggerObservable); + if (!b_doLightOutput) { + if (maxClusterObservableEMCAL > 0) { + registry.fill(HIST("hClusterEMCALMaxPtEtaPhi"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); + if (hwtrg.test(EMCALHardwareTrigger::TRG_MB)) { + registry.fill(HIST("hClusterEMCALMaxPtEtaPhiMinBias"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); } - } - if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { - registry.fill(HIST("hSelectedClusterMaxPtEtaPhi"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); - } - if (isTrigger(TriggerType_t::kEmcalGammaVeryHigh)) { - registry.fill(HIST("hSelectedGammaEMCALMaxPtEtaPhiVeryHigh"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); - } - if (isTrigger(TriggerType_t::kEmcalGammaHigh)) { - registry.fill(HIST("hSelectedGammaEMCALMaxPtEtaPhi"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); - } - if (isTrigger(TriggerType_t::kEmcalGammaLow)) { - registry.fill(HIST("hSelectedGammaEMCALMaxPtEtaPhiLow"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); - } - if (isTrigger(TriggerType_t::kEmcalGammaVeryLow)) { - registry.fill(HIST("hSelectedGammaEMCALMaxPtEtaPhiVeryLow"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); - } - } else { - // count events where max. cluster has not been found - registry.fill(HIST("hEventsNoMaxClusterEMCAL"), 1.); - if (hwtrg.test(EMCALHardwareTrigger::TRG_MB)) { - registry.fill(HIST("hEventsNoMaxClusterEMCALMinBias"), 1.); - } - if (hwtrg.test(EMCALHardwareTrigger::TRG_EMC7)) { - registry.fill(HIST("hEventsNoMaxClusterEMCALLevel0"), 1.); - } - } - if (maxClusterObservableDCAL > 0) { - registry.fill(HIST("hClusterDCALMaxPtEtaPhi"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); - if (hwtrg.test(EMCALHardwareTrigger::TRG_MB)) { - registry.fill(HIST("hClusterDCALMaxPtEtaPhiMinBias"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); - } - if (hwtrg.test(EMCALHardwareTrigger::TRG_DMC7)) { - registry.fill(HIST("hClusterDCALMaxPtEtaPhiLevel0"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); - } - for (const auto& cluster : analysedClusters) { - if (!cluster.mEMCALcluster) { - registry.fill(HIST("hClusterDCALMaxPtClusterDCALPt"), maxClusterObservableDCAL, cluster.mTriggerObservable); + if (hwtrg.test(EMCALHardwareTrigger::TRG_EMC7)) { + registry.fill(HIST("hClusterEMCALMaxPtEtaPhiLevel0"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); + } + for (const auto& cluster : analysedClusters) { + if (cluster.mEMCALcluster) { + registry.fill(HIST("hClusterEMCALMaxPtClusterEMCALPt"), maxClusterObservableEMCAL, cluster.mTriggerObservable); + } + } + if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { + registry.fill(HIST("hSelectedClusterMaxPtEtaPhi"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); + } + if (isTrigger(TriggerType_t::kEmcalGammaVeryHigh)) { + registry.fill(HIST("hSelectedGammaEMCALMaxPtEtaPhiVeryHigh"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); + } + if (isTrigger(TriggerType_t::kEmcalGammaHigh)) { + registry.fill(HIST("hSelectedGammaEMCALMaxPtEtaPhi"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); + } + if (isTrigger(TriggerType_t::kEmcalGammaLow)) { + registry.fill(HIST("hSelectedGammaEMCALMaxPtEtaPhiLow"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); + } + if (isTrigger(TriggerType_t::kEmcalGammaVeryLow)) { + registry.fill(HIST("hSelectedGammaEMCALMaxPtEtaPhiVeryLow"), maxClusterObservableEMCAL, maxClusterEMCAL.eta(), maxClusterEMCAL.phi()); + } + } else { + // count events where max. cluster has not been found + registry.fill(HIST("hEventsNoMaxClusterEMCAL"), 1.); + if (hwtrg.test(EMCALHardwareTrigger::TRG_MB)) { + registry.fill(HIST("hEventsNoMaxClusterEMCALMinBias"), 1.); + } + if (hwtrg.test(EMCALHardwareTrigger::TRG_EMC7)) { + registry.fill(HIST("hEventsNoMaxClusterEMCALLevel0"), 1.); } } - if (isTrigger(TriggerType_t::kDcalGammaVeryHigh)) { - registry.fill(HIST("hSelectedGammaDCALMaxPtEtaPhiVeryHigh"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); - } - if (isTrigger(TriggerType_t::kDcalGammaHigh)) { - registry.fill(HIST("hSelectedGammaDCALMaxPtEtaPhi"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); - } - if (isTrigger(TriggerType_t::kDcalGammaLow)) { - registry.fill(HIST("hSelectedGammaDCALMaxPtEtaPhiLow"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); - } - if (isTrigger(TriggerType_t::kDcalGammaVeryLow)) { - registry.fill(HIST("hSelectedGammaDCALMaxPtEtaPhiVeryLow"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); - } - } else { - registry.fill(HIST("hEventsNoMaxClusterDCAL"), 1.); - // count events where max. cluster has not been found - if (hwtrg.test(EMCALHardwareTrigger::TRG_MB)) { - registry.fill(HIST("hEventsNoMaxClusterDCALMinBias"), 1.); - } - if (hwtrg.test(EMCALHardwareTrigger::TRG_DMC7)) { - registry.fill(HIST("hEventsNoMaxClusterDCALLevel0"), 1.); + if (maxClusterObservableDCAL > 0) { + registry.fill(HIST("hClusterDCALMaxPtEtaPhi"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); + if (hwtrg.test(EMCALHardwareTrigger::TRG_MB)) { + registry.fill(HIST("hClusterDCALMaxPtEtaPhiMinBias"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); + } + if (hwtrg.test(EMCALHardwareTrigger::TRG_DMC7)) { + registry.fill(HIST("hClusterDCALMaxPtEtaPhiLevel0"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); + } + for (const auto& cluster : analysedClusters) { + if (!cluster.mEMCALcluster) { + registry.fill(HIST("hClusterDCALMaxPtClusterDCALPt"), maxClusterObservableDCAL, cluster.mTriggerObservable); + } + } + if (isTrigger(TriggerType_t::kDcalGammaVeryHigh)) { + registry.fill(HIST("hSelectedGammaDCALMaxPtEtaPhiVeryHigh"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); + } + if (isTrigger(TriggerType_t::kDcalGammaHigh)) { + registry.fill(HIST("hSelectedGammaDCALMaxPtEtaPhi"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); + } + if (isTrigger(TriggerType_t::kDcalGammaLow)) { + registry.fill(HIST("hSelectedGammaDCALMaxPtEtaPhiLow"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); + } + if (isTrigger(TriggerType_t::kDcalGammaVeryLow)) { + registry.fill(HIST("hSelectedGammaDCALMaxPtEtaPhiVeryLow"), maxClusterObservableDCAL, maxClusterDCAL.eta(), maxClusterDCAL.phi()); + } + } else { + registry.fill(HIST("hEventsNoMaxClusterDCAL"), 1.); + // count events where max. cluster has not been found + if (hwtrg.test(EMCALHardwareTrigger::TRG_MB)) { + registry.fill(HIST("hEventsNoMaxClusterDCALMinBias"), 1.); + } + if (hwtrg.test(EMCALHardwareTrigger::TRG_DMC7)) { + registry.fill(HIST("hEventsNoMaxClusterDCALLevel0"), 1.); + } } } return std::make_pair(maxClusterObservableEMCAL, maxClusterObservableDCAL); @@ -568,80 +624,90 @@ struct JetTriggerQA { // This gives us access to all jet substructure information // auto tracksInJet = jetTrackConstituents.sliceBy(perJetTrackConstituents, jet.globalIndex()); // for (const auto& trackList : tracksInJet) { - for (auto& track : jet.template tracks_as()) { - auto trackPt = track.pt(); - auto chargeFrag = track.px() * jet.px() + track.py() * jet.py() + track.pz() * jet.pz(); - chargeFrag /= (jet.p() * jet.p()); - auto z = trackPt / jetPt; - auto dphi = jet.phi() - track.phi(); - dphi = check_dphi(dphi); - auto dR = TMath::Sqrt(dphi * dphi + TMath::Power(jet.eta() - track.eta(), 2)); - zTheta += z * dR / jetR; - zSqTheta += z * z * dR / jetR; - zThetaSq += z * dR * dR / (jetR * jetR); - ptD += z * z; - registry.fill(HIST("hJetRPtTrackPt"), jetR, jetPt, trackPt); - registry.fill(HIST("hJetRPtChargeFrag"), jetR, jetPt, chargeFrag); - if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { - registry.fill(HIST("hSelectedJetRPtTrackPt"), jetR, jetPt, trackPt); - registry.fill(HIST("hSelectedJetRPtChargeFrag"), jetR, jetPt, chargeFrag); - } - if (isTrigger(TriggerType_t::kEmcalJetFullLow) || isTrigger(TriggerType_t::kEmcalJetNeutralLow)) { - registry.fill(HIST("hSelectedJetLowRPtTrackPt"), jetR, jetPt, trackPt); - registry.fill(HIST("hSelectedJetLowRPtChargeFrag"), jetR, jetPt, chargeFrag); - } - } // for tracks in jet + if (!b_doLightOutput) { + for (const auto& track : jet.template tracks_as()) { + auto trackPt = track.pt(); + auto chargeFrag = track.px() * jet.px() + track.py() * jet.py() + track.pz() * jet.pz(); + chargeFrag /= (jet.p() * jet.p()); + auto z = trackPt / jetPt; + auto dphi = jet.phi() - track.phi(); + dphi = check_dphi(dphi); + auto dR = std::sqrt(dphi * dphi + std::pow(jet.eta() - track.eta(), 2)); + zTheta += z * dR / jetR; + zSqTheta += z * z * dR / jetR; + zThetaSq += z * dR * dR / (jetR * jetR); + ptD += z * z; + registry.fill(HIST("hJetRPtTrackPt"), jetR, jetPt, trackPt); + registry.fill(HIST("hJetRPtChargeFrag"), jetR, jetPt, chargeFrag); + if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { + registry.fill(HIST("hSelectedJetRPtTrackPt"), jetR, jetPt, trackPt); + registry.fill(HIST("hSelectedJetRPtChargeFrag"), jetR, jetPt, chargeFrag); + } + if (isTrigger(TriggerType_t::kEmcalJetFullLow) || isTrigger(TriggerType_t::kEmcalJetNeutralLow)) { + registry.fill(HIST("hSelectedJetLowRPtTrackPt"), jetR, jetPt, trackPt); + registry.fill(HIST("hSelectedJetLowRPtChargeFrag"), jetR, jetPt, chargeFrag); + } + } // for tracks in jet + } // auto clustersInJet = jetClusterConstituents.sliceBy(perJetClusterConstituents, jet.globalIndex()); // for (const auto& clusterList : clustersInJet) { - for (auto& cluster : jet.template clusters_as()) { - auto clusterPt = cluster.energy() / std::cosh(cluster.eta()); - neutralEnergyFraction += cluster.energy(); - auto z = clusterPt / jetPt; - auto dphi = jet.phi() - cluster.phi(); - dphi = check_dphi(dphi); - auto dR = TMath::Sqrt(dphi * dphi + TMath::Power(jet.eta() - cluster.eta(), 2)); - zTheta += z * dR / jetR; - zSqTheta += z * z * dR / jetR; - zThetaSq += z * dR * dR / (jetR * jetR); - ptD += z * z; - registry.fill(HIST("hJetRPtClusterPt"), jetR, jetPt, clusterPt); - if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { - registry.fill(HIST("hSelectedJetRPtClusterPt"), jetR, jetPt, clusterPt); - } - if (isTrigger(TriggerType_t::kEmcalJetFullLow) || isTrigger(TriggerType_t::kEmcalJetNeutralLow)) { - registry.fill(HIST("hSelectedJetLowRPtClusterPt"), jetR, jetPt, clusterPt); - } - } // for clusters in jet + if (!b_doLightOutput) { + for (const auto& cluster : jet.template clusters_as()) { + auto clusterPt = cluster.energy() / std::cosh(cluster.eta()); + neutralEnergyFraction += cluster.energy(); + auto z = clusterPt / jetPt; + auto dphi = jet.phi() - cluster.phi(); + dphi = check_dphi(dphi); + auto dR = std::sqrt(dphi * dphi + std::pow(jet.eta() - cluster.eta(), 2)); + zTheta += z * dR / jetR; + zSqTheta += z * z * dR / jetR; + zThetaSq += z * dR * dR / (jetR * jetR); + ptD += z * z; + registry.fill(HIST("hJetRPtClusterPt"), jetR, jetPt, clusterPt); + if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { + registry.fill(HIST("hSelectedJetRPtClusterPt"), jetR, jetPt, clusterPt); + } + if (isTrigger(TriggerType_t::kEmcalJetFullLow) || isTrigger(TriggerType_t::kEmcalJetNeutralLow)) { + registry.fill(HIST("hSelectedJetLowRPtClusterPt"), jetR, jetPt, clusterPt); + } + } // for clusters in jet + } neutralEnergyFraction /= jet.energy(); - ptD = TMath::Sqrt(ptD); + ptD = std::sqrt(ptD); // Fillng histograms registry.fill(HIST("hJetRPtEta"), jetR, jetPt, jet.eta()); registry.fill(HIST("hJetRPtPhi"), jetR, jetPt, jet.phi()); - registry.fill(HIST("hJetRPtPtd"), jetR, jetPt, ptD); - registry.fill(HIST("hJetRPtNEF"), jetR, jetPt, neutralEnergyFraction); - registry.fill(HIST("hJetRPtZTheta"), jetR, jetPt, zTheta); - registry.fill(HIST("hJetRPtZSqTheta"), jetR, jetPt, zSqTheta); - registry.fill(HIST("hJetRPtZThetaSq"), jetR, jetPt, zThetaSq); + if (!b_doLightOutput) { + registry.fill(HIST("hJetRPtPtd"), jetR, jetPt, ptD); + registry.fill(HIST("hJetRPtNEF"), jetR, jetPt, neutralEnergyFraction); + registry.fill(HIST("hJetRPtZTheta"), jetR, jetPt, zTheta); + registry.fill(HIST("hJetRPtZSqTheta"), jetR, jetPt, zSqTheta); + registry.fill(HIST("hJetRPtZThetaSq"), jetR, jetPt, zThetaSq); + } registry.get(HIST("jetRPtEtaPhi"))->Fill(jetR, jetPt, jet.eta(), jet.phi()); if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { registry.fill(HIST("hSelectedJetRPtEta"), jetR, jetPt, jet.eta()); registry.fill(HIST("hSelectedJetRPtPhi"), jetR, jetPt, jet.phi()); - registry.fill(HIST("hSelectedJetRPtPtd"), jetR, jetPt, ptD); - registry.fill(HIST("hSelectedJetRPtNEF"), jetR, jetPt, neutralEnergyFraction); - registry.fill(HIST("hSelectedJetRPtZTheta"), jetR, jetPt, zTheta); - registry.fill(HIST("hSelectedJetRPtZSqTheta"), jetR, jetPt, zSqTheta); - registry.fill(HIST("hSelectedJetRPtZThetaSq"), jetR, jetPt, zThetaSq); + if (!b_doLightOutput) { + registry.fill(HIST("hSelectedJetRPtPtd"), jetR, jetPt, ptD); + registry.fill(HIST("hSelectedJetRPtNEF"), jetR, jetPt, neutralEnergyFraction); + registry.fill(HIST("hSelectedJetRPtZTheta"), jetR, jetPt, zTheta); + registry.fill(HIST("hSelectedJetRPtZSqTheta"), jetR, jetPt, zSqTheta); + registry.fill(HIST("hSelectedJetRPtZThetaSq"), jetR, jetPt, zThetaSq); + } } if (isTrigger(TriggerType_t::kEmcalJetFullLow) || isTrigger(TriggerType_t::kEmcalJetNeutralLow)) { registry.fill(HIST("hSelectedJetLowRPtEta"), jetR, jetPt, jet.eta()); registry.fill(HIST("hSelectedJetLowRPtPhi"), jetR, jetPt, jet.phi()); - registry.fill(HIST("hSelectedJetLowRPtPtd"), jetR, jetPt, ptD); - registry.fill(HIST("hSelectedJetLowRPtNEF"), jetR, jetPt, neutralEnergyFraction); - registry.fill(HIST("hSelectedJetLowRPtZTheta"), jetR, jetPt, zTheta); - registry.fill(HIST("hSelectedJetLowRPtZSqTheta"), jetR, jetPt, zSqTheta); - registry.fill(HIST("hSelectedJetLowRPtZThetaSq"), jetR, jetPt, zThetaSq); + if (!b_doLightOutput) { + registry.fill(HIST("hSelectedJetLowRPtPtd"), jetR, jetPt, ptD); + registry.fill(HIST("hSelectedJetLowRPtNEF"), jetR, jetPt, neutralEnergyFraction); + registry.fill(HIST("hSelectedJetLowRPtZTheta"), jetR, jetPt, zTheta); + registry.fill(HIST("hSelectedJetLowRPtZSqTheta"), jetR, jetPt, zSqTheta); + registry.fill(HIST("hSelectedJetLowRPtZThetaSq"), jetR, jetPt, zThetaSq); + } } } // for jets return std::make_pair(vecMaxJet, vecMaxJetNoFiducial); @@ -761,67 +827,74 @@ struct JetTriggerQA { std::array foundMaxJet; std::fill(foundMaxJet.begin(), foundMaxJet.end(), false); - for (auto maxJet : vecMaxJet) { - double jetR = maxJet.r() * 1e-2, jetPt = maxJet.pt(), jetEta = maxJet.eta(), jetPhi = maxJet.phi(); - foundMaxJet[static_cast(maxJet.r() * 1e-1) - 2] = true; - registry.fill(HIST("hJetRMaxPtEta"), jetR, jetPt, jetEta); - registry.fill(HIST("hJetRMaxPtPhi"), jetR, jetPt, jetPhi); - if (hardwaretriggers.test(EMCALHardwareTrigger::TRG_MB)) { - registry.fill(HIST("hJetRMaxPtEtaMinBias"), jetR, jetPt, jetEta); - registry.fill(HIST("hJetRMaxPtPhiMinBias"), jetR, jetPt, jetPhi); - } - if (hardwaretriggers.test(EMCALHardwareTrigger::TRG_EMC7)) { - registry.fill(HIST("hJetRMaxPtEtaLevel0"), jetR, jetPt, jetEta); - registry.fill(HIST("hJetRMaxPtPhiLevel0"), jetR, jetPt, jetPhi); - } - // hJetRMaxPtEtaPhi->Fill(jetR, jetPt, jetEta, jetPhi); - registry.get(HIST("jetRMaxPtEtaPhi"))->Fill(jetR, jetPt, jetEta, jetPhi); - if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { - registry.fill(HIST("hSelectedJetRMaxPtEta"), jetR, jetPt, jetEta); - registry.fill(HIST("hSelectedJetRMaxPtPhi"), jetR, jetPt, jetPhi); - } - if (isTrigger(TriggerType_t::kEmcalJetFullLow) || isTrigger(TriggerType_t::kEmcalJetNeutralLow)) { - registry.fill(HIST("hSelectedJetLowRMaxPtEta"), jetR, jetPt, jetEta); - registry.fill(HIST("hSelectedJetLowRMaxPtPhi"), jetR, jetPt, jetPhi); - } - if (maxClusterObservableEMCAL > 0) { - registry.fill(HIST("hJetRMaxPtClusterMaxPt"), jetR, jetPt, maxClusterObservableEMCAL); + if (!b_doLightOutput) { + for (const auto& maxJet : vecMaxJet) { + double jetR = maxJet.r() * 1e-2, jetPt = maxJet.pt(), jetEta = maxJet.eta(), jetPhi = maxJet.phi(); + foundMaxJet[static_cast(maxJet.r() * 1e-1) - 2] = true; + registry.fill(HIST("hJetRMaxPtEta"), jetR, jetPt, jetEta); + registry.fill(HIST("hJetRMaxPtPhi"), jetR, jetPt, jetPhi); + if (hardwaretriggers.test(EMCALHardwareTrigger::TRG_MB)) { + registry.fill(HIST("hJetRMaxPtEtaMinBias"), jetR, jetPt, jetEta); + registry.fill(HIST("hJetRMaxPtPhiMinBias"), jetR, jetPt, jetPhi); + } + if (hardwaretriggers.test(EMCALHardwareTrigger::TRG_EMC7)) { + registry.fill(HIST("hJetRMaxPtEtaLevel0"), jetR, jetPt, jetEta); + registry.fill(HIST("hJetRMaxPtPhiLevel0"), jetR, jetPt, jetPhi); + } + // hJetRMaxPtEtaPhi->Fill(jetR, jetPt, jetEta, jetPhi); + registry.get(HIST("jetRMaxPtEtaPhi"))->Fill(jetR, jetPt, jetEta, jetPhi); if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { - registry.fill(HIST("hSelectedJetRMaxPtClusterMaxPt"), jetR, jetPt, maxClusterObservableEMCAL); + registry.fill(HIST("hSelectedJetRMaxPtEta"), jetR, jetPt, jetEta); + registry.fill(HIST("hSelectedJetRMaxPtPhi"), jetR, jetPt, jetPhi); } - } // if maxClusterPt - if (maxJet.r() == std::round(f_jetR * 100)) { - for (const auto& jet : jets) { - if (isJetInEmcal(jet)) { - registry.fill(HIST("hJetRMaxPtJetPt"), jet.r() * 1e-2, jetPt, jet.pt()); + if (isTrigger(TriggerType_t::kEmcalJetFullLow) || isTrigger(TriggerType_t::kEmcalJetNeutralLow)) { + registry.fill(HIST("hSelectedJetLowRMaxPtEta"), jetR, jetPt, jetEta); + registry.fill(HIST("hSelectedJetLowRMaxPtPhi"), jetR, jetPt, jetPhi); + } + if (maxClusterObservableEMCAL > 0) { + registry.fill(HIST("hJetRMaxPtClusterMaxPt"), jetR, jetPt, maxClusterObservableEMCAL); + if (isTrigger(TriggerType_t::kEmcalJetFull) || isTrigger(TriggerType_t::kEmcalJetNeutral)) { + registry.fill(HIST("hSelectedJetRMaxPtClusterMaxPt"), jetR, jetPt, maxClusterObservableEMCAL); } - } // for jets - } // if maxJet.r() == std::round(f_jetR * 100) - } // for maxJet + } // if maxClusterPt + if (maxJet.r() == std::round(f_jetR * 100)) { + for (const auto& jet : jets) { + if (isJetInEmcal(jet)) { + registry.fill(HIST("hJetRMaxPtJetPt"), jet.r() * 1e-2, jetPt, jet.pt()); + } + } // for jets + } // if maxJet.r() == std::round(f_jetR * 100) + } // for maxJet + } // Fill counters for events without max jets - for (std::size_t ir = 0; ir < foundMaxJet.size(); ir++) { - if (!foundMaxJet[ir]) { - double rval = static_cast(ir) / 10.; - registry.fill(HIST("hEventsNoMaxJet"), rval); - if (hardwaretriggers.test(EMCALHardwareTrigger::TRG_MB)) { - registry.fill(HIST("hEventsNoMaxJetMinBias"), rval); - } - if (hardwaretriggers.test(EMCALHardwareTrigger::TRG_EMC7)) { - registry.fill(HIST("hEventsNoMaxJetLevel0"), rval); + if (!b_doLightOutput) { + for (std::size_t ir = 0; ir < foundMaxJet.size(); ir++) { + if (!foundMaxJet[ir]) { + double rval = static_cast(ir) / 10.; + registry.fill(HIST("hEventsNoMaxJet"), rval); + if (hardwaretriggers.test(EMCALHardwareTrigger::TRG_MB)) { + registry.fill(HIST("hEventsNoMaxJetMinBias"), rval); + } + if (hardwaretriggers.test(EMCALHardwareTrigger::TRG_EMC7)) { + registry.fill(HIST("hEventsNoMaxJetLevel0"), rval); + } } } } - for (auto maxJet : vecMaxJetNoFiducial) { - double jetR = maxJet.r() * 1e-2, jetPt = maxJet.pt(), jetEta = maxJet.eta(), jetPhi = maxJet.phi(); - // hJetRMaxPtEtaPhiNoFiducial->Fill(jetR, jetPt, jetEta, jetPhi); - registry.get(HIST("jetRMaxPtEtaPhiNoFiducial"))->Fill(jetR, jetPt, jetEta, jetPhi); - if (maxJet.r() == std::round(f_jetR * 100)) { - for (const auto& jet : jets) { - registry.fill(HIST("hJetRMaxPtJetPtNoFiducial"), jet.r() * 1e-2, jetPt, jet.pt()); - } // for jets - } // if maxJet.r() == std::round(f_jetR * 100) - } // for maxjet no fiducial + if (!b_doLightOutput) { + for (const auto& maxJet : vecMaxJetNoFiducial) { + double jetR = maxJet.r() * 1e-2, jetPt = maxJet.pt(), jetEta = maxJet.eta(), jetPhi = maxJet.phi(); + // hJetRMaxPtEtaPhiNoFiducial->Fill(jetR, jetPt, jetEta, jetPhi); + registry.get(HIST("jetRMaxPtEtaPhiNoFiducial"))->Fill(jetR, jetPt, jetEta, jetPhi); + if (maxJet.r() == std::round(f_jetR * 100)) { + for (const auto& jet : jets) { + if (!b_doLightOutput) + registry.fill(HIST("hJetRMaxPtJetPtNoFiducial"), jet.r() * 1e-2, jetPt, jet.pt()); + } // for jets + } // if maxJet.r() == std::round(f_jetR * 100) + } // for maxjet no fiducial + } } // process void processFullJets(collisionWithTrigger const& collision, diff --git a/PWGJE/Tasks/gammaJetTreeProducer.cxx b/PWGJE/Tasks/gammaJetTreeProducer.cxx index e1ffd83887f..a054a8e97b8 100644 --- a/PWGJE/Tasks/gammaJetTreeProducer.cxx +++ b/PWGJE/Tasks/gammaJetTreeProducer.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -9,40 +9,46 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file gammaJetTreeProducer.cxx +/// \brief Task to produce a tree for gamma-jet analysis, including photons (and information of isolation) and charged jets +/// \author Florian Jonas , UC Berkeley/LBNL +/// \since 02.08.2024 + // C++ system headers first +#include + #include #include #include // Framework and other headers after -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/GammaJetAnalysisTree.h" +#include "PWGJE/DataModel/Jet.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/filterTables.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/GammaJetAnalysisTree.h" - -#include "EMCALBase/Geometry.h" -#include "EMCALCalib/BadChannelMap.h" -#include "PWGJE/DataModel/EMCALClusters.h" +#include "CommonDataFormat/InteractionRecord.h" +#include "DataFormatsEMCAL/AnalysisCluster.h" #include "DataFormatsEMCAL/Cell.h" #include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" -#include "TVector2.h" - -#include "CommonDataFormat/InteractionRecord.h" +#include "EMCALBase/Geometry.h" +#include "EMCALCalib/BadChannelMap.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" -#include "EventFiltering/filterTables.h" +#include "TVector2.h" // \struct GammaJetTreeProducer /// \brief Task to produce a tree for gamma-jet analysis, including photons (and information of isolation) and charged and full jets @@ -54,6 +60,7 @@ using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; using emcClusters = o2::soa::Join; +using emcMCClusters = o2::soa::Join; #include "Framework/runDataProcessing.h" @@ -61,12 +68,19 @@ struct GammaJetTreeProducer { // analysis tree // charged jets // photon candidates - Produces chargedJetsTable; - Produces eventsTable; - Produces gammasTable; + Produces chargedJetsTable; // detector level jets + Produces eventsTable; // rec events + Produces gammasTable; // detector level clusters + Produces mcEventsTable; // mc collisions information + Produces mcParticlesTable; // gen level particles (photons and pi0) + Produces gammaMCInfosTable; // detector level clusters MC information + Produces chJetMCInfosTable; // detector level charged jets MC information + Produces mcJetsTable; // gen level jets HistogramRegistry mHistograms{"GammaJetTreeProducerHisto"}; + Service pdg; + // --------------- // Configureables // --------------- @@ -83,20 +97,34 @@ struct GammaJetTreeProducer { Configurable perpConeJetR{"perpConeJetR", 0.4, "perpendicular cone radius used to calculate perp cone rho for jet"}; Configurable trackMatchingEoverP{"trackMatchingEoverP", 2.0, "closest track is required to have E/p < value"}; Configurable minClusterETrigger{"minClusterETrigger", 0.0, "minimum cluster energy to trigger"}; + Configurable minMCGenPt{"minMCGenPt", 0.0, "minimum pt of mc gen particles to store"}; int mRunNumber = 0; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; + const int kMaxRecursionDepth = 100; std::unordered_map collisionMapping; + std::unordered_map mcJetIndexMapping; // maps the global index to the index in the mc jets table (per event). This is because later we want to later construct all trees on a per event level, and we need to know at what position in the table per event this is stored std::vector triggerMaskBits; + std::vector mcCollisionsMultiRecCollisions; // used for MC. global index of MC collisions that have multiple matched rec collisions + + // kd tree for tracks and mc particles (used for fast isolation calculation) + std::vector trackEta; + std::vector trackPhi; + std::vector trackPt; + std::vector mcParticleEta; + std::vector mcParticlePhi; + std::vector mcParticlePt; + TKDTree* trackTree = nullptr; + TKDTree* mcParticleTree = nullptr; void init(InitContext const&) { using o2HistType = HistType; using o2Axis = AxisSpec; - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); @@ -104,25 +132,152 @@ struct GammaJetTreeProducer { LOG(info) << "Creating histograms"; const o2Axis ptAxis{100, 0, 200, "p_{T} (GeV/c)"}; + const o2Axis ptRecAxis{100, 0, 200, "p_{T}^{rec} (GeV/c)"}; + const o2Axis ptGenAxis{100, 0, 200, "p_{T}^{gen} (GeV/c)"}; const o2Axis energyAxis{100, 0, 100, "E (GeV)"}; const o2Axis m02Axis{100, 0, 3, "m02"}; const o2Axis etaAxis{100, -1, 1, "#eta"}; - const o2Axis phiAxis{100, 0, 2 * TMath::Pi(), "#phi"}; + const o2Axis phiAxis{100, 0, o2::constants::math::TwoPI, "#phi"}; + const o2Axis dRAxis{100, 0, 1, "dR"}; const o2Axis occupancyAxis{300, 0, 30000, "occupancy"}; + const o2Axis nCollisionsAxis{10, -0.5, 9.5, "nCollisions"}; mHistograms.add("clusterE", "Energy of cluster", o2HistType::kTH1F, {energyAxis}); mHistograms.add("trackPt", "pT of track", o2HistType::kTH1F, {ptAxis}); mHistograms.add("chjetPt", "pT of charged jet", o2HistType::kTH1F, {ptAxis}); mHistograms.add("chjetPtEtaPhi", "pT of charged jet", o2HistType::kTHnSparseF, {ptAxis, etaAxis, phiAxis}); - mHistograms.add("chjetpt_vs_constpt", "pT of charged jet vs pT of constituents", o2HistType::kTH2F, {ptAxis, ptAxis}); + mHistograms.add("chjetpt_vs_constpt", "pT of charged jet vs pT of constituents", o2HistType::kTH2F, {ptRecAxis, ptGenAxis}); // track QA THnSparse mHistograms.add("trackPtEtaPhi", "Track QA", o2HistType::kTHnSparseF, {ptAxis, etaAxis, phiAxis}); mHistograms.add("trackPtEtaOccupancy", "Track QA vs occupancy", o2HistType::kTHnSparseF, {ptAxis, etaAxis, occupancyAxis}); + + // QA for MC collisions to rec collision matching + // number of reconstructed and matched collisions for each MC collision vs mc gen photon energy + mHistograms.add("numberRecCollisionsVsPhotonPt", "Number of rec collisions vs photon energy", o2HistType::kTH2F, {nCollisionsAxis, energyAxis}); + + // Cluster MC histograms + mHistograms.add("clusterMC_E_All", "Cluster energy for photons", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_Photon", "Cluster energy for photons", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_PromptPhoton", "Cluster energy for prompt photons", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_DirectPromptPhoton", "Cluster energy for direct prompt photons", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_FragmentationPhoton", "Cluster energy for fragmentation photons", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_DecayPhoton", "Cluster energy for decay photons", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_DecayPhotonPi0", "Cluster energy for decay photons from pi0", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_DecayPhotonEta", "Cluster energy for decay photons from eta", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_MergedPi0", "Cluster energy for merged pi0s", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_MergedEta", "Cluster energy for merged etas", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_E_ConvertedPhoton", "Cluster energy for converted photons", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("clusterMC_m02_Photon", "M02 for photons", o2HistType::kTH1F, {m02Axis}); + mHistograms.add("clusterMC_m02_PromptPhoton", "M02 for prompt photons", o2HistType::kTH1F, {m02Axis}); + mHistograms.add("clusterMC_m02_DirectPromptPhoton", "M02 for direct prompt photons", o2HistType::kTH1F, {m02Axis}); + mHistograms.add("clusterMC_m02_FragmentationPhoton", "M02 for fragmentation photons", o2HistType::kTH1F, {m02Axis}); + mHistograms.add("clusterMC_m02_DecayPhoton", "M02 for decay photons", o2HistType::kTH1F, {m02Axis}); + mHistograms.add("clusterMC_m02_DecayPhotonPi0", "M02 for decay photons from pi0", o2HistType::kTH1F, {m02Axis}); + mHistograms.add("clusterMC_m02_DecayPhotonEta", "M02 for decay photons from eta", o2HistType::kTH1F, {m02Axis}); + mHistograms.add("clusterMC_m02_MergedPi0", "M02 for merged pi0s", o2HistType::kTH1F, {m02Axis}); + mHistograms.add("clusterMC_m02_MergedEta", "M02 for merged etas", o2HistType::kTH1F, {m02Axis}); + mHistograms.add("clusterMC_m02_ConvertedPhoton", "M02 for converted photons", o2HistType::kTH1F, {m02Axis}); + + // MC Gen trigger particle histograms + mHistograms.add("mcGenTrigger_Eta", "eta of mc gen trigger particle", o2HistType::kTH1F, {etaAxis}); + mHistograms.add("mcGenTrigger_Phi", "phi of mc gen trigger particle", o2HistType::kTH1F, {phiAxis}); + mHistograms.add("mcGenTrigger_Pt", "pT of mc gen trigger particle", o2HistType::kTH1F, {ptAxis}); + mHistograms.add("mcGenTrigger_E", "E of mc gen trigger particle", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("mcGenTrigger_E_PromptPhoton", "E of mc gen trigger prompt photon", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("mcGenTrigger_E_DirectPromptPhoton", "E of mc gen trigger direct prompt photon", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("mcGenTrigger_E_FragmentationPhoton", "E of mc gen trigger fragmentation photon", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("mcGenTrigger_E_DecayPhoton", "E of mc gen trigger decay photon", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("mcGenTrigger_E_DecayPhotonPi0", "E of mc gen trigger decay photon from pi0", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("mcGenTrigger_E_DecayPhotonEta", "E of mc gen trigger decay photon from eta", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("mcGenTrigger_E_DecayPhotonOther", "E of mc gen trigger decay photon from other", o2HistType::kTH1F, {energyAxis}); + mHistograms.add("mcGenTrigger_E_Pi0", "E of mc gen trigger pi0", o2HistType::kTH1F, {energyAxis}); + + // MC Particle level jet histograms + mHistograms.add("mcpJetPt", "pT of mc particle level jet", o2HistType::kTH1F, {ptAxis}); + + // MC Detector level jet matching jet histograms + mHistograms.add("mcdJetPtVsTrueJetPtMatchingGeo", "pT rec (x-axis) of detector level jets vs pT true (y-axis) of mc particle level jet (geo matching)", o2HistType::kTH2F, {ptRecAxis, ptGenAxis}); + mHistograms.add("mcdJetPtVsTrueJetPtMatchingPt", "pT rec (x-axis) of detector level jets vs pT true (y-axis) of mc particle level jet (pt matching)", o2HistType::kTH2F, {ptRecAxis, ptGenAxis}); + + // Event QA histogram + const int nEventBins = 8; + const TString eventLabels[nEventBins] = {"All", "AfterVertexCut", "AfterCollisionSelection", "AfterTriggerSelection", "AfterEMCALSelection", "AfterClusterESelection", "Has MC collision", "is not MB Gap"}; + mHistograms.add("eventQA", "Event QA", o2HistType::kTH1F, {{nEventBins, -0.5, 7.5}}); + for (int iBin = 0; iBin < nEventBins; iBin++) { + mHistograms.get(HIST("eventQA"))->GetXaxis()->SetBinLabel(iBin + 1, eventLabels[iBin]); + } + + // MC collisions QA histograms) + const int nRecCollisionBins = 4; + const TString recCollisionLabels[nRecCollisionBins] = {"All", "1 Rec collision", "More than 1 rec collisions", "No rec collisions"}; + mHistograms.add("mcCollisionsWithRecCollisions", "MC collisions with rec collisions", o2HistType::kTH1F, {{nRecCollisionBins, -0.5, 3.5}}); + for (int iBin = 0; iBin < nRecCollisionBins; iBin++) { + mHistograms.get(HIST("mcCollisionsWithRecCollisions"))->GetXaxis()->SetBinLabel(iBin + 1, recCollisionLabels[iBin]); + } } // --------------------- // Helper functions // --------------------- + + /// \brief Builds the kd tree for the tracks or mc particles (used for fast isolation calculation) + /// \param objects The objects to build the kd tree for (tracks or mc particles) + template + void buildKdTree(const T& objects) + { + trackEta.clear(); + trackPhi.clear(); + trackPt.clear(); + mcParticleEta.clear(); + mcParticlePhi.clear(); + mcParticlePt.clear(); + + // if the track type is aod::JetTracks, we need to build the kd tree for the tracks + if constexpr (std::is_same_v, aod::JetTracks>) { + for (const auto& track : objects) { + if (!isTrackSelected(track)) { + continue; + } + trackEta.push_back(track.eta()); + trackPhi.push_back(track.phi()); + trackPt.push_back(track.pt()); + } + if (trackEta.size() > 0) { + delete trackTree; + trackTree = new TKDTree(trackEta.size(), 2, 1); + trackTree->SetData(0, trackEta.data()); + trackTree->SetData(1, trackPhi.data()); + trackTree->Build(); + } + } + // if the track type is aod::JetParticles, we need to build the kd tree for the mc particles + if constexpr (std::is_same_v, aod::JetParticles>) { + for (const auto& particle : objects) { + if (!particle.isPhysicalPrimary()) { + continue; + } + if (!isCharged(particle)) { + continue; + } + if (particle.pt() < trackMinPt) { + continue; + } + mcParticleEta.push_back(particle.eta()); + mcParticlePhi.push_back(particle.phi()); + mcParticlePt.push_back(particle.pt()); + } + if (mcParticleEta.size() > 0) { + delete mcParticleTree; + mcParticleTree = new TKDTree(mcParticleEta.size(), 2, 1); + mcParticleTree->SetData(0, mcParticleEta.data()); + mcParticleTree->SetData(1, mcParticlePhi.data()); + mcParticleTree->Build(); + } + } + } + /// \brief Checks if a track passes the selection criteria + /// \param track The track to be checked + /// \return true if track passes all selection criteria, false otherwise bool isTrackSelected(const auto& track) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { @@ -135,6 +290,9 @@ struct GammaJetTreeProducer { return true; } + /// \brief Gets the stored collision index from the collision mapping + /// \param collision The collision to look up + /// \return The stored collision index, or -1 if not found int getStoredColIndex(const auto& collision) { int32_t storedColIndex = -1; @@ -144,50 +302,149 @@ struct GammaJetTreeProducer { return storedColIndex; } + /// \brief Checks if an event passes all selection criteria + /// \param collision The collision to check + /// \param clusters The EMCAL clusters in the event + /// \return true if event passes all selection criteria, false otherwise bool isEventAccepted(const auto& collision, const auto& clusters) { + mHistograms.fill(HIST("eventQA"), 0); if (collision.posZ() > mVertexCut) { return false; } - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + mHistograms.fill(HIST("eventQA"), 1); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return false; } + mHistograms.fill(HIST("eventQA"), 2); if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return false; } + mHistograms.fill(HIST("eventQA"), 3); if (!jetderiveddatautilities::eventEMCAL(collision)) { return false; } + mHistograms.fill(HIST("eventQA"), 4); // Check if event contains a cluster with energy > minClusterETrigger - for (auto cluster : clusters) { + for (const auto& cluster : clusters) { if (cluster.energy() > minClusterETrigger) { + mHistograms.fill(HIST("eventQA"), 5); return true; } } return false; } - double ch_iso_in_cone(const auto& cluster, aod::JetTracks const& tracks, float radius = 0.4) + /// \brief Checks if a particle is charged + /// \param particle The MC particle to check + /// \return true if particle has non-zero charge, false otherwise + bool isCharged(const auto& particle) + { + return std::abs(pdg->GetParticle(particle.pdgCode())->Charge()) >= 1.; + } + + /// \brief Calculates the charged particle isolation in a cone of given size using a pre-built kd tree + /// \param particle The particle to calculate the isolation for + /// \param radius The cone radius + /// \param mcGenIso Whether to use the mc gen particle tree (if false, use the track tree) + /// \return The charged particle isolation + template + double ch_iso_in_cone(const T& particle, float radius = 0.4, bool mcGenIso = false) { double iso = 0; - for (auto track : tracks) { - if (!isTrackSelected(track)) { - continue; + float point[2] = {particle.eta(), particle.phi()}; + std::vector indices; + + if (!mcGenIso) { + if (trackTree) { + trackTree->FindInRange(point, radius, indices); + for (const auto& index : indices) { + iso += trackPt[index]; + } + } else { + LOG(error) << "Track tree not found"; + return 0; } - // make dR function live somwhere else - float dR = jetutilities::deltaR(cluster, track); - if (dR < radius) { - iso += track.pt(); + } else { + if (mcParticleTree) { + mcParticleTree->FindInRange(point, radius, indices); + for (const auto& index : indices) { + iso += mcParticlePt[index]; + } + } else { + LOG(error) << "MC particle tree not found"; + return 0; } } return iso; } + /// \brief Calculates the charged particle density in perpendicular cones + /// \param object The reference object (cluster or jet) + /// \param tracks The tracks to check + /// \param radius The cone radius for density calculation + /// \return The average charged particle density in the perpendicular cones + template + double ch_perp_cone_rho(const T& object, float radius = 0.4, bool mcGenIso = false) + { + double ptSumLeft = 0; + double ptSumRight = 0; + + double cPhi = TVector2::Phi_0_2pi(object.phi()); + + // rotate cone left by 90 degrees + float cPhiLeft = cPhi - o2::constants::math::PIHalf; + float cPhiRight = cPhi + o2::constants::math::PIHalf; + + float pointLeft[2] = {object.eta(), cPhiLeft}; + float pointRight[2] = {object.eta(), cPhiRight}; + + std::vector indicesLeft; + std::vector indicesRight; + + if (!mcGenIso) { + if (trackTree) { + trackTree->FindInRange(pointLeft, radius, indicesLeft); + trackTree->FindInRange(pointRight, radius, indicesRight); + } else { + LOG(error) << "Track tree not found"; + return 0; + } + + for (const auto& index : indicesLeft) { + ptSumLeft += trackPt[index]; + } + for (const auto& index : indicesRight) { + ptSumRight += trackPt[index]; + } + } else { + if (mcParticleTree) { + mcParticleTree->FindInRange(pointLeft, radius, indicesLeft); + mcParticleTree->FindInRange(pointRight, radius, indicesRight); + } else { + LOG(error) << "MC particle tree not found"; + return 0; + } + for (const auto& index : indicesLeft) { + ptSumLeft += mcParticlePt[index]; + } + for (const auto& index : indicesRight) { + ptSumRight += mcParticlePt[index]; + } + } + + float rho = (ptSumLeft + ptSumRight) / (o2::constants::math::TwoPI * radius * radius); + return rho; + } + + /// \brief Fills track QA histograms for a given collision + /// \param collision The collision containing the tracks + /// \param tracks The tracks to analyze void runTrackQA(const auto& collision, aod::JetTracks const& tracks) { - for (auto track : tracks) { + for (const auto& track : tracks) { if (!isTrackSelected(track)) { continue; } @@ -197,59 +454,538 @@ struct GammaJetTreeProducer { } } - double ch_perp_cone_rho(const auto& object, aod::JetTracks const& tracks, float radius = 0.4) + /// \brief Finds the top-most copy of a particle in the decay chain (following carbon copies) + /// \param particle The particle to start from + /// \return The top-most copy of the particle + template + T iTopCopy(const T& particle) const { - double ptSumLeft = 0; - double ptSumRight = 0; + int iUp = particle.globalIndex(); + T currentParticle = particle; + int pdgCode = particle.pdgCode(); + auto mothers = particle.template mothers_as(); + while (iUp > 0 && mothers.size() == 1 && mothers[0].globalIndex() > 0 && mothers[0].pdgCode() == pdgCode) { + iUp = mothers[0].globalIndex(); + currentParticle = mothers[0]; + mothers = currentParticle.template mothers_as(); + } + return currentParticle; + } - double cPhi = TVector2::Phi_0_2pi(object.phi()); + /// \brief Checks if a particle is a prompt photon + /// \param particle The MC particle to check + /// \return true if particle is a prompt photon, false otherwise + bool isPromptPhoton(const auto& particle) + { + if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) < 90) { + return true; + } + return false; + } + /// \brief Checks if a particle is a direct prompt photon + /// \param particle The particle to check + /// \return true if particle is a direct prompt photon, false otherwise + bool isDirectPromptPhoton(const auto& particle) + { + // check if particle isa prompt photon + if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) < 90) { + // find the top carbon copy + auto topCopy = iTopCopy(particle); + if (topCopy.pdgCode() == PDG_t::kGamma && std::abs(topCopy.getGenStatusCode()) < 40) { // < 40 is particle directly produced in hard scattering + return true; + } + } + return false; + } + /// \brief Checks if a particle is a fragmentation photon + /// \param particle The particle to check + /// \return true if particle is a fragmentation photon, false otherwise + bool isFragmentationPhoton(const auto& particle) + { + if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) < 90) { + // find the top carbon copy + auto topCopy = iTopCopy(particle); + if (topCopy.pdgCode() == PDG_t::kGamma && std::abs(topCopy.getGenStatusCode()) >= 40) { // frag photon + return true; + } + } + return false; + } + /// \brief Checks if a particle is a decay photon + /// \param particle The particle to check + /// \return true if particle is a decay photon, false otherwise + bool isDecayPhoton(const auto& particle) + { + if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) >= 90) { + return true; + } + return false; + } + /// \brief Checks if a particle is a decay photon from pi0 + /// \param particle The particle to check + /// \return true if particle is a decay photon from pi0, false otherwise + template + bool isDecayPhotonPi0(const T& particle) + { + if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) >= 90) { + // check if it has mothers that are pi0s + const auto& mothers = particle.template mothers_as(); + for (const auto& mother : mothers) { + if (mother.pdgCode() == PDG_t::kPi0) { + return true; + } + } + } + return false; + } + /// \brief Checks if a particle is a decay photon from eta + /// \param particle The particle to check + /// \return true if particle is a decay photon from eta, false otherwise + template + bool isDecayPhotonEta(const T& particle) + { + if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) >= 90) { + // check if it has mothers that are etas + const auto& mothers = particle.template mothers_as(); + for (const auto& mother : mothers) { + if (mother.pdgCode() == 221) { + return true; + } + } + } + return false; + } + /// \brief Checks if a particle is a decay photon from other sources + /// \param particle The particle to check + /// \return true if particle is a decay photon from other sources, false otherwise + template + bool isDecayPhotonOther(const T& particle) + { + if (particle.pdgCode() == PDG_t::kGamma && particle.isPhysicalPrimary() && std::abs(particle.getGenStatusCode()) >= 90) { + // check if you find a pi0 mother or a eta mother + const auto& mothers = particle.template mothers_as(); + for (const auto& mother : mothers) { + if (mother.pdgCode() == PDG_t::kPi0 || mother.pdgCode() == 221) { + return false; + } + } + return true; + } + return false; + } + /// \brief Checks if a particle is a pi0 + /// \param particle The particle to check + /// \return true if particle is a pi0, false otherwise + bool isPi0(const auto& particle) + { + if (particle.pdgCode() == PDG_t::kPi0) { + return true; + } + return false; + } - // rotate cone left by 90 degrees - float cPhiLeft = cPhi - TMath::Pi() / 2; - float cPhiRight = cPhi + TMath::Pi() / 2; + /// \brief Gets the bitmap for a MC particle that indicated what type of particle it is + /// \param particle The particle to check + /// \return A bitmap indicating the particle's origin + uint16_t getMCParticleOrigin(const auto& particle) + { + uint16_t origin = 0; + if (isPromptPhoton(particle)) { + SETBIT(origin, static_cast(gjanalysis::ParticleOrigin::kPromptPhoton)); + } + if (isDirectPromptPhoton(particle)) { + SETBIT(origin, static_cast(gjanalysis::ParticleOrigin::kDirectPromptPhoton)); + } + if (isFragmentationPhoton(particle)) { + SETBIT(origin, static_cast(gjanalysis::ParticleOrigin::kFragmentationPhoton)); + } + if (isDecayPhoton(particle)) { + SETBIT(origin, static_cast(gjanalysis::ParticleOrigin::kDecayPhoton)); + } + if (isDecayPhotonPi0(particle)) { + SETBIT(origin, static_cast(gjanalysis::ParticleOrigin::kDecayPhotonPi0)); + } + if (isDecayPhotonEta(particle)) { + SETBIT(origin, static_cast(gjanalysis::ParticleOrigin::kDecayPhotonEta)); + } + if (isDecayPhotonOther(particle)) { + SETBIT(origin, static_cast(gjanalysis::ParticleOrigin::kDecayPhotonOther)); + } + if (isPi0(particle)) { + SETBIT(origin, static_cast(gjanalysis::ParticleOrigin::kPi0)); + } + return origin; + } - // loop over tracks - float dRLeft, dRRight; - for (auto track : tracks) { - if (!isTrackSelected(track)) { - continue; + /// \brief Gets the index of a mother particle with specific PDG code in the decay chain (upwards) + /// \param particle The particle to start from + /// \param mcParticles The MC particles collection + /// \param pdgCode The PDG code to search for + /// \return The index of the mother particle, or -1 if not found + template + int getIndexMotherChain(const T& particle, aod::JMcParticles const& mcParticles, int pdgCode, int depth = 0) + { + // Limit recursion depth to avoid infinite loops + if (depth > kMaxRecursionDepth) { // 100 generations should be more than enough + return -1; + } + const auto& mothers = particle.template mothers_as(); + for (const auto& mother : mothers) { + if (mother.pdgCode() == pdgCode) { + return mother.globalIndex(); + } else { + return getIndexMotherChain(mother, mcParticles, pdgCode, depth + 1); } - dRLeft = jetutilities::deltaR(object.eta(), cPhiLeft, track.eta(), track.phi()); - dRRight = jetutilities::deltaR(object.eta(), cPhiRight, track.eta(), track.phi()); + } + return -1; + } + // return recursive list of all daughter IDs + /// \brief Gets all daughter particle IDs in the decay chain + /// \param particle The particle to start from + /// \return Vector of daughter particle IDs + template + void getDaughtersInChain(const T& particle, std::vector& daughters, int depth = 0) + { + // Limit recursion depth to avoid infinite loops + if (depth > kMaxRecursionDepth) { // 100 generations should be more than enough + return; + } - if (dRLeft < radius) { - ptSumLeft += track.pt(); + if (!particle.has_daughters()) { + return; + } + + const auto& daughterParticles = particle.template daughters_as(); + for (const auto& daughter : daughterParticles) { + daughters.push_back(daughter.globalIndex()); + getDaughtersInChain(daughter, daughters, depth + 1); + } + return; + } + /// \brief Finds the first physical primary particle in the decay chain (upwards) + /// \param particle The particle to start from + /// \return The index of the first physical primary particle, or -1 if not found + template + int findPhysicalPrimaryInChain(const T& particle, int depth = 0) + { + // Limit recursion depth to avoid infinite loops + if (depth > kMaxRecursionDepth) { // 100 generations should be more than enough + return -1; + } + + // first check if current particle is physical primary + if (particle.isPhysicalPrimary()) { + return particle.globalIndex(); + } + + // check if the particle has mothers + if (!particle.has_mothers()) + return -1; + + // now get mothers + const auto mothers = particle.template mothers_as(); + if (mothers.size() == 0) + return -1; + + // get first mother + for (const auto& mother : mothers) { + int primaryIndex = findPhysicalPrimaryInChain(mother, depth + 1); + if (primaryIndex >= 0) { + return primaryIndex; } - if (dRRight < radius) { - ptSumRight += track.pt(); + break; // only check first mother + } + + return -1; + } + + /// \brief Checks if a cluster is merged from particles of a specific PDG decay to two gammas. A cluster is considered merged if the leading and subleading contribution to a cluster come from two photons that are part of a pi0 decay + /// \param cluster The cluster to check + /// \param mcParticles The MC particles collection + /// \param pdgCode The PDG code to check for + /// \return true if cluster is merged from the specified decay, false otherwise + template + bool isMergedFromPDGDecay(const T& cluster, U const& mcParticles, int pdgCode) + { + auto inducerIDs = cluster.mcParticlesIds(); + if (inducerIDs.size() < 2) { // it can not me "merged" if it has less than 2 inducers + return false; + } + + bool isMerged = false; + int motherIndex = getIndexMotherChain(mcParticles.iteratorAt(inducerIDs[0]), mcParticles, pdgCode); + if (motherIndex != -1) { + const auto& mother = mcParticles.iteratorAt(motherIndex); + + // get daughters of pi0 mother + auto daughtersMother = mother.template daughters_as(); + // check if there are two daughters that are both photons + if (daughtersMother.size() == 2) { + const auto& daughter1 = daughtersMother.iteratorAt(0); + const auto& daughter2 = daughtersMother.iteratorAt(1); + if (daughter1.pdgCode() == PDG_t::kGamma && daughter2.pdgCode() == PDG_t::kGamma) { + // get the full stack of particles that these daughters create + std::vector fullDecayChain1; + std::vector fullDecayChain2; + getDaughtersInChain(daughter1, fullDecayChain1); + getDaughtersInChain(daughter2, fullDecayChain2); + bool photon1Found = false; + bool photon2Found = false; + + // check if any of the particles in the fullDecayChain are leading or subleading in the cluster + for (const auto& particleID : fullDecayChain1) { + if (particleID == inducerIDs[0] || particleID == inducerIDs[1]) { + photon1Found = true; + } + } + for (const auto& particleID : fullDecayChain2) { + if (particleID == inducerIDs[0] || particleID == inducerIDs[1]) { + photon2Found = true; + } + } + if (photon1Found && photon2Found) { + isMerged = true; + } + } } } + return isMerged; + } - float rho = (ptSumLeft + ptSumRight) / (2 * TMath::Pi() * radius * radius); - return rho; + // determine cluster origin + /// \brief Gets the origin bitmap for a cluster + /// \param cluster The cluster to check + /// \param mcParticles The MC particles collection + /// \return A bitmap indicating the cluster's origin + template + uint16_t getClusterOrigin(const T& cluster, U const& mcParticles) + { + uint16_t origin = 0; + auto inducerIDs = cluster.mcParticlesIds(); + if (inducerIDs.size() == 0) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kUnknown)); + return origin; + } + + // loop over all inducers and print their energy + LOG(debug) << "Cluster with energy: " << cluster.energy() << " and nInducers: " << inducerIDs.size(); + LOG(debug) << "Number of stored amplitudes: " << cluster.amplitudeA().size(); + int aCounter = 0; + for (const auto& inducerID : inducerIDs) { + const auto& inducer = mcParticles.iteratorAt(inducerID); + int motherPDG = -1; + if (inducer.has_mothers()) { + motherPDG = inducer.template mothers_as()[0].pdgCode(); + } + LOG(debug) << "Inducer energy: " << inducer.energy() << " amplitude: " << cluster.amplitudeA()[aCounter] << " and PDG: " << inducer.pdgCode() << " isPhysicalPrimary: " << inducer.isPhysicalPrimary() << " motherPDG: " << motherPDG; + aCounter++; + } + + // check if leading energy contribution is from a photon + const auto& leadingParticle = mcParticles.iteratorAt(inducerIDs[0]); + LOG(debug) << "Leading particle: PDG" << leadingParticle.pdgCode(); + // leading particle primary ID + int leadingParticlePrimaryID = findPhysicalPrimaryInChain(leadingParticle); + LOG(debug) << "Leading particle primary ID: " << leadingParticlePrimaryID; + if (leadingParticlePrimaryID == -1) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kUnknown)); + return origin; + } + const auto& leadingParticlePrimary = mcParticles.iteratorAt(leadingParticlePrimaryID); + LOG(debug) << "Leading particle primary PDG: " << leadingParticlePrimary.pdgCode(); + if (leadingParticlePrimary.pdgCode() == PDG_t::kGamma) { + LOG(debug) << "Leading particle primary is a photon"; + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kPhoton)); + } + if (isPromptPhoton(leadingParticlePrimary)) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kPromptPhoton)); + LOG(debug) << "Leading particle primary is a prompt photon"; + } + if (isDirectPromptPhoton(leadingParticlePrimary)) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kDirectPromptPhoton)); + LOG(debug) << "Leading particle primary is a direct prompt photon"; + } + if (isFragmentationPhoton(leadingParticlePrimary)) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kFragmentationPhoton)); + LOG(debug) << "Leading particle primary is a fragmentation photon"; + } + if (isDecayPhoton(leadingParticlePrimary)) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kDecayPhoton)); + LOG(debug) << "Leading particle primary is a decay photon"; + } + if (isDecayPhotonPi0(leadingParticlePrimary)) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kDecayPhotonPi0)); + LOG(debug) << "Leading particle primary is a decay photon from pi0"; + } + if (isDecayPhotonEta(leadingParticlePrimary)) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kDecayPhotonEta)); + LOG(debug) << "Leading particle primary is a decay photon from eta"; + } + + // Do checks if a cluster is a merged pi0 decay + // we classify a cluster as merged pi0 if the leading and subleading contribution to a cluster come from two photons that are part of a pi0 decay + if (isMergedFromPDGDecay(cluster, mcParticles, PDG_t::kPi0)) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kMergedPi0)); + LOG(debug) << "Cluster is a merged pi0"; + } + if (isMergedFromPDGDecay(cluster, mcParticles, 221)) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kMergedEta)); + LOG(debug) << "Cluster is a merged eta"; + } + + // check if photon conversion + // check that leading contribution is an electron or positron + LOG(debug) << "Checking if cluster is a converted photon"; + if (std::abs(leadingParticle.pdgCode()) == PDG_t::kElectron) { + // make sure this electron is not a physicsl primary and has mothers + if (!leadingParticle.isPhysicalPrimary() && leadingParticle.has_mothers()) { + const auto mothers = leadingParticle.template mothers_as(); + if (mothers.size() > 0) { + LOG(debug) << "Got the mother"; + const auto& mother = mothers[0]; + if (mother.pdgCode() == PDG_t::kGamma && mother.has_daughters()) { + LOG(debug) << "Got the mother with PDG 22 and daughters"; + const auto& daughters = mother.template daughters_as(); + // check that mother has exactly two daughters which are e+ and e- + if (daughters.size() == 2) { + LOG(debug) << "Got the daughters"; + if ((daughters.iteratorAt(0).pdgCode() == PDG_t::kElectron && daughters.iteratorAt(1).pdgCode() == PDG_t::kPositron) || (daughters.iteratorAt(0).pdgCode() == -PDG_t::kPositron && daughters.iteratorAt(1).pdgCode() == PDG_t::kElectron)) { + SETBIT(origin, static_cast(gjanalysis::ClusterOrigin::kConvertedPhoton)); + LOG(debug) << "Cluster is a converted photon"; + } + } + } + } + } + } + // display bit origin + LOG(debug) << "Origin bits: " << std::bitset<16>(origin); + return origin; } // --------------------- // Processing functions // --------------------- // WARNING: This function always has to run first in the processing chain + /// \brief Clears collision mapping at the start of each dataframe + /// \param collisions The collisions collection void processClearMaps(aod::JetCollisions const&) { collisionMapping.clear(); + mcCollisionsMultiRecCollisions.clear(); + mcJetIndexMapping.clear(); } PROCESS_SWITCH(GammaJetTreeProducer, processClearMaps, "process function that clears all the maps in each dataframe", true); // WARNING: This function always has to run second in the processing chain - void processEvent(soa::Join::iterator const& collision, emcClusters const& clusters) + /// \brief Processes MC event matching QA + /// \param mcCollision The MC collision to process + /// \param collisions The rec collisions collection + /// \param mcgenparticles The MC particles collection + void processMCCollisionsMatching(aod::JetMcCollision const& mcCollision, soa::SmallGroups const& collisions, aod::JetParticles const& mcgenparticles) + { + if (mcCollision.weight() == 0) { + return; + } + + // determine number of rec collisions + int nRecCollisions = 0; + mHistograms.fill(HIST("mcCollisionsWithRecCollisions"), 0); + for (auto const& collision : collisions) { + if (collision.posZ() > mVertexCut) { + continue; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + continue; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + continue; + } + if (!jetderiveddatautilities::eventEMCAL(collision)) { + continue; + } + nRecCollisions++; + } + if (nRecCollisions == 0) { + mHistograms.fill(HIST("mcCollisionsWithRecCollisions"), 3); + } + if (nRecCollisions == 1) { + mHistograms.fill(HIST("mcCollisionsWithRecCollisions"), 1); + } + if (nRecCollisions > 1) { + mHistograms.fill(HIST("mcCollisionsWithRecCollisions"), 2); + } + if (nRecCollisions > 1) { + mcCollisionsMultiRecCollisions.push_back(mcCollision.globalIndex()); + } + + // loop over mcgenparticles + for (auto const& particle : mcgenparticles) { + if (!particle.isPhysicalPrimary()) { + continue; + } + if (particle.pdgCode() != PDG_t::kGamma) { + continue; + } + mHistograms.fill(HIST("numberRecCollisionsVsPhotonPt"), nRecCollisions, particle.pt()); + } + } + PROCESS_SWITCH(GammaJetTreeProducer, processMCCollisionsMatching, "Process MC event matching QA", false); + + /// \brief Processes data events in data fill event table + /// \param collision The collision to process + /// \param clusters The EMCAL clusters in the event + void processEventData(soa::Join::iterator const& collision, emcClusters const& clusters) { if (!isEventAccepted(collision, clusters)) { return; } - eventsTable(collision.multiplicity(), collision.centrality(), collision.rho(), collision.eventSel(), collision.trackOccupancyInTimeRange(), collision.alias_raw()); + eventsTable(collision.multFT0M(), collision.centFT0M(), collision.rho(), collision.eventSel(), collision.trackOccupancyInTimeRange(), collision.alias_raw()); collisionMapping[collision.globalIndex()] = eventsTable.lastIndex(); } - PROCESS_SWITCH(GammaJetTreeProducer, processEvent, "Process event", true); + PROCESS_SWITCH(GammaJetTreeProducer, processEventData, "Process event data", true); + + using MCCol = o2::soa::Join; + + /// \brief Processes MC events and fills rec and MC event tables (disable processEventData) + /// \param collision The collision to process + /// \param clusters The EMCAL clusters in the event + /// \param mcCollisions The MC collisions collection + void processEventMC(soa::Join::iterator const& collision, emcClusters const& clusters, MCCol const&) + { + if (!isEventAccepted(collision, clusters)) { + return; + } + + // check that this event has a MC collision + if (!collision.has_mcCollision()) { + return; + } + mHistograms.fill(HIST("eventQA"), 6); + + // check if this event is not MB gap event + if (collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + mHistograms.fill(HIST("eventQA"), 7); + + // fill rec collision table + eventsTable(collision.multFT0M(), collision.centFT0M(), collision.rho(), collision.eventSel(), collision.trackOccupancyInTimeRange(), collision.alias_raw()); + + // fill collision mapping + collisionMapping[collision.globalIndex()] = eventsTable.lastIndex(); + + auto mcCollision = collision.mcCollision_as(); + + bool isMultipleAssigned = false; + // check if we are dealing with a rec collision matched to a MC collision that was matched to multiple rec collisions + if (std::find(mcCollisionsMultiRecCollisions.begin(), mcCollisionsMultiRecCollisions.end(), mcCollision.globalIndex()) != mcCollisionsMultiRecCollisions.end()) { + isMultipleAssigned = true; + } + mcEventsTable(eventsTable.lastIndex(), mcCollision.weight(), mcCollision.rho(), isMultipleAssigned); + } + PROCESS_SWITCH(GammaJetTreeProducer, processEventMC, "Process MC event MC", false); // --------------------- // Processing functions can be safely added below this line @@ -260,6 +996,11 @@ struct GammaJetTreeProducer { // an integer instead PresliceUnsorted EMCTrackPerTrack = aod::jemctrack::trackId; // Process clusters + /// \brief Processes clusters and fills cluster table + /// \param collision The collision to process + /// \param clusters The EMCAL clusters to process + /// \param tracks The tracks collection + /// \param emctracks The EMCAL tracks collection from track matching void processClusters(soa::Join::iterator const& collision, emcClusters const& clusters, aod::JetTracks const& tracks, aod::JEMCTracks const& emctracks) { // event selection @@ -267,20 +1008,20 @@ struct GammaJetTreeProducer { if (storedColIndex == -1) return; - // eventsTable(collision.multiplicity(), collision.centrality(), collision.rho(), collision.eventSel(), collision.trackOccupancyInTimeRange(), collision.alias_raw()); - // collisionMapping[collision.globalIndex()] = eventsTable.lastIndex(); - // loop over tracks one time for QA runTrackQA(collision, tracks); + // build kd tree for tracks and mc particles + buildKdTree(tracks); + // loop over clusters - for (auto cluster : clusters) { + for (const auto& cluster : clusters) { // fill histograms mHistograms.fill(HIST("clusterE"), cluster.energy()); - double isoraw = ch_iso_in_cone(cluster, tracks, isoR); - double perpconerho = ch_perp_cone_rho(cluster, tracks, isoR); + double isoraw = ch_iso_in_cone(cluster, isoR, false); + double perpconerho = ch_perp_cone_rho(cluster, isoR, false); // find closest matched track double dEta = 0; @@ -290,7 +1031,7 @@ struct GammaJetTreeProducer { // do track matching auto tracksofcluster = cluster.matchedTracks_as(); - for (auto track : tracksofcluster) { + for (const auto& track : tracksofcluster) { if (!isTrackSelected(track)) { continue; } @@ -301,7 +1042,7 @@ struct GammaJetTreeProducer { continue; } else { dEta = cluster.eta() - emcTrack.etaEmcal(); - dPhi = RecoDecay::constrainAngle(RecoDecay::constrainAngle(emcTrack.phiEmcal(), -M_PI) - RecoDecay::constrainAngle(cluster.phi(), -M_PI), -M_PI); + dPhi = RecoDecay::constrainAngle(RecoDecay::constrainAngle(emcTrack.phiEmcal(), -o2::constants::math::PI) - RecoDecay::constrainAngle(cluster.phi(), -o2::constants::math::PI), -o2::constants::math::PI); p = track.p(); break; } @@ -310,47 +1051,262 @@ struct GammaJetTreeProducer { } // dummy loop over tracks - for (auto track : tracks) { + for (const auto& track : tracks) { mHistograms.fill(HIST("trackPt"), track.pt()); } } PROCESS_SWITCH(GammaJetTreeProducer, processClusters, "Process EMCal clusters", true); - Filter jetCuts = aod::jet::pt > jetPtMin; - // Process charged jets - void processChargedJets(soa::Join::iterator const& collision, soa::Filtered> const& chargedJets, aod::JetTracks const& tracks) + /// \brief Processes MC cluster information (rec level) + /// \param collision The collision to process + /// \param mcClusters The MC clusters to process + /// \param mcParticles The MC particles collection + void processClustersMCInfo(soa::Join::iterator const& collision, emcMCClusters const& mcClusters, aod::JMcParticles const& mcParticles) { // event selection int32_t storedColIndex = getStoredColIndex(collision); if (storedColIndex == -1) return; - float leadingTrackPt = 0; + // loop over mcClusters + // TODO: add weights + for (const auto& mcCluster : mcClusters) { + mHistograms.fill(HIST("clusterMC_E_All"), mcCluster.energy()); + uint16_t origin = getClusterOrigin(mcCluster, mcParticles); + float leadingEnergyFraction = mcCluster.amplitudeA()[0] / mcCluster.energy(); + // Fill MC origin QA histograms + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kPhoton))) { + mHistograms.fill(HIST("clusterMC_E_Photon"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_Photon"), mcCluster.m02()); + } + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kPromptPhoton))) { + mHistograms.fill(HIST("clusterMC_E_PromptPhoton"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_PromptPhoton"), mcCluster.m02()); + } + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kDirectPromptPhoton))) { + mHistograms.fill(HIST("clusterMC_E_DirectPromptPhoton"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_DirectPromptPhoton"), mcCluster.m02()); + } + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kFragmentationPhoton))) { + mHistograms.fill(HIST("clusterMC_E_FragmentationPhoton"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_FragmentationPhoton"), mcCluster.m02()); + } + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kDecayPhoton))) { + mHistograms.fill(HIST("clusterMC_E_DecayPhoton"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_DecayPhoton"), mcCluster.m02()); + } + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kDecayPhotonPi0))) { + mHistograms.fill(HIST("clusterMC_E_DecayPhotonPi0"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_DecayPhotonPi0"), mcCluster.m02()); + } + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kDecayPhotonEta))) { + mHistograms.fill(HIST("clusterMC_E_DecayPhotonEta"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_DecayPhotonEta"), mcCluster.m02()); + } + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kMergedPi0))) { + mHistograms.fill(HIST("clusterMC_E_MergedPi0"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_MergedPi0"), mcCluster.m02()); + } + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kMergedEta))) { + mHistograms.fill(HIST("clusterMC_E_MergedEta"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_MergedEta"), mcCluster.m02()); + } + if (origin & (1 << static_cast(gjanalysis::ClusterOrigin::kConvertedPhoton))) { + mHistograms.fill(HIST("clusterMC_E_ConvertedPhoton"), mcCluster.energy()); + mHistograms.fill(HIST("clusterMC_m02_ConvertedPhoton"), mcCluster.m02()); + } + // fill table + gammaMCInfosTable(storedColIndex, origin, leadingEnergyFraction); + } + } + PROCESS_SWITCH(GammaJetTreeProducer, processClustersMCInfo, "Process MC cluster information", false); + + /// \brief Fills the charged jet table with jet information and calculates jet properties + /// \param storedColIndex The stored collision index + /// \param jet The jet to process + /// \param tracks The tracks collection + template + void fillChargedJetTable(int32_t storedColIndex, T const& jet, U const& /*tracks*/) + { + if (jet.pt() < jetPtMin) { + return; + } ushort nconst = 0; + float leadingTrackPt = 0; + for (const auto& constituent : jet.template tracks_as()) { + mHistograms.fill(HIST("chjetpt_vs_constpt"), jet.pt(), constituent.pt()); + nconst++; + if (constituent.pt() > leadingTrackPt) { + leadingTrackPt = constituent.pt(); + } + } + double perpconerho = ch_perp_cone_rho(jet, perpConeJetR, false); + chargedJetsTable(storedColIndex, jet.pt(), jet.eta(), jet.phi(), jet.r(), jet.energy(), jet.mass(), jet.area(), leadingTrackPt, perpconerho, nconst); + mHistograms.fill(HIST("chjetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi()); + mHistograms.fill(HIST("chjetPt"), jet.pt()); + } + + Filter jetCuts = aod::jet::pt > jetPtMin; + /// \brief Processes charged jets and fills jet table + /// \param collision The collision to process + /// \param chargedJets The charged jets to process + /// \param tracks The tracks collection + void processChargedJetsData(soa::Join::iterator const& collision, soa::Filtered> const& chargedJets, aod::JetTracks const& tracks) + { + // event selection + int32_t storedColIndex = getStoredColIndex(collision); + if (storedColIndex == -1) + return; // loop over charged jets - for (auto jet : chargedJets) { - if (jet.pt() < jetPtMin) + for (const auto& jet : chargedJets) { + fillChargedJetTable(storedColIndex, jet, tracks); + } + } + PROCESS_SWITCH(GammaJetTreeProducer, processChargedJetsData, "Process charged jets", true); + + Preslice ParticlesPerMCCollisions = aod::jmcparticle::mcCollisionId; + /// \brief Processes MC particles and fills MC particle table + /// \param collision The collision to process + /// \param mcgenparticles The MC particles to process + void processMCParticles(soa::Join::iterator const& collision, aod::JetParticles const& mcgenparticles, MCCol const&) + { + // event selection + int32_t storedColIndex = getStoredColIndex(collision); + if (storedColIndex == -1) + return; + + if (!collision.has_mcCollision()) { + return; + } + + // only storing MC particles if we found a reconstructed collision + auto particlesPerMcCollision = mcgenparticles.sliceBy(ParticlesPerMCCollisions, collision.mcCollisionId()); + + // build kd tree for mc particles + buildKdTree(particlesPerMcCollision); + + // Now we want to store every pi0 and every prompt photon that we find on generator level + for (const auto& particle : particlesPerMcCollision) { + // only store particles above a given threshold + if (particle.pt() < minMCGenPt) { + continue; + } + // Test if a particle is a physical primary according to the following definition: + // Particles produced in the collision including products of strong and + // electromagnetic decay and excluding feed-down from weak decays of strange + // particles. + if (!(particle.isPhysicalPrimary() || particle.pdgCode() == PDG_t::kPi0)) { continue; - nconst = 0; - leadingTrackPt = 0; - // loop over constituents - for (auto& constituent : jet.template tracks_as()) { - mHistograms.fill(HIST("chjetpt_vs_constpt"), jet.pt(), constituent.pt()); - nconst++; - if (constituent.pt() > leadingTrackPt) { - leadingTrackPt = constituent.pt(); - } } - // calculate perp cone rho - double perpconerho = ch_perp_cone_rho(jet, tracks, perpConeJetR); - mHistograms.fill(HIST("chjetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi()); - chargedJetsTable(storedColIndex, jet.pt(), jet.eta(), jet.phi(), jet.r(), jet.energy(), jet.mass(), jet.area(), leadingTrackPt, perpconerho, nconst); - // fill histograms - mHistograms.fill(HIST("chjetPt"), jet.pt()); + // only store photons and pi0s in mcgen stack + if (particle.pdgCode() != PDG_t::kPi0 && particle.pdgCode() != PDG_t::kGamma) { + continue; + } + // check the origin of the particle + uint16_t origin = getMCParticleOrigin(particle); + double mcIsolation = ch_iso_in_cone(particle, isoR, true); + mcParticlesTable(storedColIndex, particle.energy(), particle.eta(), particle.phi(), particle.pt(), particle.pdgCode(), mcIsolation, origin); + + // fill mc gen trigger particle histograms + mHistograms.fill(HIST("mcGenTrigger_E"), particle.energy()); + mHistograms.fill(HIST("mcGenTrigger_Eta"), particle.eta()); + mHistograms.fill(HIST("mcGenTrigger_Phi"), particle.phi()); + mHistograms.fill(HIST("mcGenTrigger_Pt"), particle.pt()); + if (origin & (1 << static_cast(gjanalysis::ParticleOrigin::kPromptPhoton))) { + mHistograms.fill(HIST("mcGenTrigger_E_PromptPhoton"), particle.energy()); + } + if (origin & (1 << static_cast(gjanalysis::ParticleOrigin::kDirectPromptPhoton))) { + mHistograms.fill(HIST("mcGenTrigger_E_DirectPromptPhoton"), particle.energy()); + } + if (origin & (1 << static_cast(gjanalysis::ParticleOrigin::kFragmentationPhoton))) { + mHistograms.fill(HIST("mcGenTrigger_E_FragmentationPhoton"), particle.energy()); + } + if (origin & (1 << static_cast(gjanalysis::ParticleOrigin::kDecayPhoton))) { + mHistograms.fill(HIST("mcGenTrigger_E_DecayPhoton"), particle.energy()); + } + if (origin & (1 << static_cast(gjanalysis::ParticleOrigin::kDecayPhotonPi0))) { + mHistograms.fill(HIST("mcGenTrigger_E_DecayPhotonPi0"), particle.energy()); + } + if (origin & (1 << static_cast(gjanalysis::ParticleOrigin::kDecayPhotonEta))) { + mHistograms.fill(HIST("mcGenTrigger_E_DecayPhotonEta"), particle.energy()); + } + if (origin & (1 << static_cast(gjanalysis::ParticleOrigin::kDecayPhotonOther))) { + mHistograms.fill(HIST("mcGenTrigger_E_DecayPhotonOther"), particle.energy()); + } + if (origin & (1 << static_cast(gjanalysis::ParticleOrigin::kPi0))) { + mHistograms.fill(HIST("mcGenTrigger_E_Pi0"), particle.energy()); + } + } + } + PROCESS_SWITCH(GammaJetTreeProducer, processMCParticles, "Process MC particles", false); + + // NOTE: It is important that this function runs after the processMCParticles function (where the isolation tree is built ) + Preslice PJetsPerMCCollisions = aod::jmcparticle::mcCollisionId; + /// \brief Processes MC particle level charged jets and fills MC jet table + /// \param collision The collision to process + /// \param chargedJets The MC particle level charged jets to process + /// \param mcCollisions The MC collisions collection + void processChargedJetsMCP(soa::Join::iterator const& collision, soa::Filtered> const& chargedJets, MCCol const&) + { + // event selection + int32_t storedColIndex = getStoredColIndex(collision); + if (storedColIndex == -1) + return; + // loop over charged jets + if (!collision.has_mcCollision()) { + return; + } + int localIndex = 0; + auto pjetsPerMcCollision = chargedJets.sliceBy(PJetsPerMCCollisions, collision.mcCollisionId()); + for (const auto& pjet : pjetsPerMcCollision) { + // fill MC particle level jet table + float perpconerho = ch_perp_cone_rho(pjet, perpConeJetR, true); + mcJetsTable(storedColIndex, pjet.pt(), pjet.eta(), pjet.phi(), pjet.r(), pjet.energy(), pjet.mass(), pjet.area(), perpconerho); + mcJetIndexMapping[pjet.globalIndex()] = localIndex; + localIndex++; + mHistograms.fill(HIST("mcpJetPt"), pjet.pt()); } } - PROCESS_SWITCH(GammaJetTreeProducer, processChargedJets, "Process charged jets", true); + PROCESS_SWITCH(GammaJetTreeProducer, processChargedJetsMCP, "Process MC particle level jets", false); + + // NOTE: It is important that this function runs after the processChargedJetsMCP function (where the mc jet index mapping is built) + using JetMCPTable = soa::Filtered>; + Filter jetCutsMCD = aod::jet::pt > jetPtMin; + /// \brief Processes MC detector level charged jets and fills jet matching information + /// \param collision The collision to process + /// \param chargedJets The MC detector level charged jets to process + /// \param tracks The tracks collection + /// \param pjets The MC particle level jets collection (just loaded to have subscription to the table) + void processChargedJetsMCD(soa::Join::iterator const& collision, soa::Filtered> const& chargedJets, aod::JetTracks const& tracks, JetMCPTable const& /*pjets*/) + { + // event selection + int32_t storedColIndex = getStoredColIndex(collision); + if (storedColIndex == -1) + return; + // loop over charged jets + for (const auto& jet : chargedJets) { + fillChargedJetTable(storedColIndex, jet, tracks); + + // Fill Matching information + int iLocalIndexGeo = -1; + int iLocalIndexPt = -1; + // We will always store the information for both in our tree + if (jet.has_matchedJetGeo()) { + const auto& pjet = jet.template matchedJetGeo_first_as(); + iLocalIndexGeo = mcJetIndexMapping[pjet.globalIndex()]; + mHistograms.fill(HIST("mcdJetPtVsTrueJetPtMatchingGeo"), jet.pt(), pjet.pt()); + } + if (jet.has_matchedJetPt()) { + const auto& pjet = jet.template matchedJetPt_first_as(); + iLocalIndexPt = mcJetIndexMapping[pjet.globalIndex()]; + mHistograms.fill(HIST("mcdJetPtVsTrueJetPtMatchingPt"), jet.pt(), pjet.pt()); + } + chJetMCInfosTable(storedColIndex, iLocalIndexGeo, iLocalIndexPt); + } + } + PROCESS_SWITCH(GammaJetTreeProducer, processChargedJetsMCD, "Process MC detector level jets", false); }; + WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{ diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index c7198bf8414..bd6496f2296 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -16,38 +16,36 @@ /// for hadrons and photons to compute angular correlations /// -#include -#include +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "CommonConstants/MathConstants.h" #include "Framework/ASoA.h" -#include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" +#include "Framework/Configurable.h" #include "Framework/Expressions.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" +#include "Framework/HistogramRegistry.h" #include "Framework/HistogramSpec.h" -#include "Framework/Configurable.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "CommonConstants/MathConstants.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGJE/Core/JetUtilities.h" +#include -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" -#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" +#include +#include +#include +#include +#include using namespace o2; using namespace o2::aod; @@ -61,15 +59,21 @@ struct HadronPhotonCorrelation { Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + Configurable subGeneratorIdSelections{"subGeneratorIdSelections", -1, "set sub generator id"}; - Configurable etaMax{"etaMax", 0.8, "maximum eta cut"}; + Configurable tpcNClsCrossedRows{"tpcNClsCrossedRows", 70, "tpcNClsCrossedRows"}; + Configurable tpcCrossedRowsOverFindableCls{"tpcCrossedRowsOverFindableCls", 0.8, "tpcCrossedRowsOverFindableCls"}; + Configurable tpcNSigmaPi{"tpcNSigmaPi", 2., "tpcNSigmaPi"}; - AxisSpec axisPhi = {72, 0., TwoPI, "#phi"}; // Axis for phi distribution - AxisSpec axisDeltaPhi = {72, -PIHalf, 3 * PIHalf, "#Delta #phi"}; // Axis for Delta phi in correlations - AxisSpec axisDeltaPhiDecay = {100, -.5, .5, "#Delta #phi"}; // Axis for Delta phi between neutral hadrons and decay photons - AxisSpec axisEta = {40, -.8, .8, "#eta"}; // Axis for eta distribution - AxisSpec axisDeltaEta = {80, -1.6, 1.6, "#Delta #eta"}; // Axis for Delta eta in correlations - AxisSpec axisDeltaEtaDecay = {100, -.6, .6, "#Delta #eta"}; // Axis for Delta eta between neutral hadrons and decay photons + const int pidCodeHadronCut = 100; + + Configurable etaMaxTrig{"etaMaxTrig", 0.8, "maximum eta cut for triggers"}; + Configurable etaMaxAssoc{"etaMaxAssoc", 0.8, "maximum eta cut for associateds"}; + Configurable etaBinsTrig{"etaBinsTrig", 40, "number of eta bins for triggers"}; + Configurable etaBinsAssoc{"etaBinsAssoc", 40, "number of eta bins for associateds"}; + Configurable phiBins{"phiBins", 72, "number of phi bins"}; + + AxisSpec axisEventStats = {3, -.5, 2.5, "Stats"}; ConfigurableAxis axisPtTrig = {"axisPtTrig", {VARIABLE_WIDTH, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 9.0f, 11.0f, 15.0f, 20.0f}, @@ -77,10 +81,12 @@ struct HadronPhotonCorrelation { ConfigurableAxis axisPtAssoc = {"axisPtAssoc", {VARIABLE_WIDTH, 0.2, 0.5, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 9.0f, 11.0f, 15.0f}, - "p_{T, assoc} [GeV]"}; // Axis for associated particle pt distribution - AxisSpec axisDeltaPt = {200, 0., 1.2, "#Delta p_T"}; // Axis for pt ratio between neutral hadrons and decay photons - AxisSpec axisPid = {7, -1.5, 5.5, "pid"}; // Axis for PID of neutral hadrons - AxisSpec axisMult = {100, 0., 99., "N_{ch}"}; // Axis for mutplipicity + "p_{T, assoc} [GeV]"}; // Axis for associated particle pt distribution + ConfigurableAxis axisDeltaPt = {"axisDeltaPt", {200, 0., 1.2}, "#Delta p_T"}; // Axis for pt ratio between neutral hadrons and decay photons + AxisSpec axisPid = {10, -3.5, 6.5, "pid"}; // Axis for PID of neutral hadrons + ConfigurableAxis axisMult = {"axisMult", {100, 0., 99.}, "N_{ch}"}; // Axis for mutplipicity + AxisSpec axisAlpha = {100, 0., 1., "alpha"}; // Axis for decay photon pt assymetry + ConfigurableAxis axisDeltaRDecay = {"axisDeltaRDecay", {400, 0., 3.2}, "#Delta R"}; // Axis for Delta R = sqrt(Delta eta^2 + Delta phi^2) between neutral hadrons and decay photons float ptMinTrig; float ptMaxTrig; @@ -90,32 +96,18 @@ struct HadronPhotonCorrelation { HistogramRegistry registry{"histogram registry"}; // Particle ids for storing neutral hadrons - std::map pidCodes = { - {2212, -1}, - {1, -1}, - {2, -1}, - {3, -1}, - {4, -1}, - {5, -1}, - {6, -1}, - {21, -1}, // Protons, quarks, gluons (direct) - {111, 1}, // pi0 - {221, 2}, // eta - {223, 3}, // eta' - {331, 4}, // phi - {333, 5}}; // omega + std::map pidCodes = { + {"pi0", 1}, // pi0 + {"eta", 2}, // eta + {"eta'", 3}, // eta' + {"phi", 4}, // phi + {"omega", 5}, // omega + {"Sigma0", 6}, // Sigma + {"Sigma0_bar", 6}}; Service pdg; - // Calculate difference between two azimuthal angles, projecting into range [lowerPhi, lowerPhi + pi/2] - float calculateDelta(float phi1, float phi2, float lowerPhi) - { - float dphi = fmod((phi1 - phi2) + 3 * PI, TwoPI) - PI; - dphi = RecoDecay::constrainAngle(dphi, lowerPhi); - return dphi; - } - - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; void init(o2::framework::InitContext&) @@ -125,56 +117,66 @@ struct HadronPhotonCorrelation { ptMinAssoc = axisPtAssoc->at(1); ptMaxAssoc = axisPtAssoc->back(); - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + AxisSpec axisPhi = {phiBins, 0., TwoPI, "#phi"}; // Axis for phi distribution + AxisSpec axisDeltaPhi = {phiBins, -PIHalf, 3 * PIHalf, "#Delta #phi"}; // Axis for Delta phi in correlations + AxisSpec axisEtaTrig = {etaBinsTrig, -etaMaxTrig, etaMaxTrig, "#eta"}; // Axis for eta distribution + AxisSpec axisEtaAssoc = {etaBinsAssoc, -etaMaxAssoc, etaMaxAssoc, "#eta"}; // Axis for eta distribution + AxisSpec axisDeltaEta = {etaBinsTrig + etaBinsAssoc, -(etaMaxTrig + etaMaxAssoc), etaMaxTrig + etaMaxAssoc, "#Delta #eta"}; // Axis for Delta eta in correlations + + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); // Generated histograms + registry.add("generated/events/hEventStats", "Event statistics", kTH1F, {axisEventStats}); + // Triggers registry.add("generated/triggers/hTrigMultGen", "Generated Trigger Multiplicity", kTH1F, {axisMult}); - registry.add("generated/triggers/hTrigSpectrumGen", "Generated Trigger Spectrum", kTHnSparseF, {axisPtTrig, axisEta, axisPhi}); + registry.add("generated/triggers/hTrigSpectrumGen", "Generated Trigger Spectrum", kTHnSparseF, {axisPtTrig, axisEtaTrig, axisPhi}); // Hadrons registry.add("generated/hadrons/hHadronCorrelGen", "Generated Trigger-Hadron Correlation", kTHnSparseF, {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi}); registry.add("generated/hadrons/hHadronMultGen", "Generated Hadron Multiplicity", kTH1F, {axisMult}); - registry.add("generated/hadrons/hHadronSpectrumGen", "Generated Hadron Spectrum", kTHnSparseF, {axisPtAssoc, axisEta, axisPhi}); + registry.add("generated/hadrons/hHadronSpectrumGen", "Generated Hadron Spectrum", kTHnSparseF, {axisPtAssoc, axisEtaAssoc, axisPhi}); // Photons registry.add("generated/photons/hPhotonCorrelGen", "Generated Trigger-Photon Correlation", kTHnSparseF, {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi, axisPid}); registry.add("generated/photons/hPhotonMultGen", "Generated Photon Multiplicity", kTH1F, {axisMult}); - registry.add("generated/photons/hPhotonSpectrumGen", "Generated Photon Spectrum", kTHnSparseF, {axisPtAssoc, axisEta, axisPhi, axisPid}); + registry.add("generated/photons/hPhotonSpectrumGen", "Generated Photon Spectrum", kTHnSparseF, {axisPtAssoc, axisEtaAssoc, axisPhi, axisPid}); // Charged pions registry.add("generated/charged/hPionCorrelGen", "Generated Trigger-Pion Correlation", kTHnSparseF, {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi}); registry.add("generated/charged/hPionMultGen", "Generated Pion Multiplicity", kTH1F, {axisMult}); - registry.add("generated/charged/hPionSpectrumGen", "Generated Pion Spectrum", kTHnSparseF, {axisPtAssoc, axisEta, axisPhi}); + registry.add("generated/charged/hPionSpectrumGen", "Generated Pion Spectrum", kTHnSparseF, {axisPtAssoc, axisEtaAssoc, axisPhi}); ////Neutral particles registry.add("generated/neutral/hNeutralCorrelGen", "Generated Trigger-Neutral Hadron Correlation", kTHnSparseF, {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi, axisPid}); registry.add("generated/neutral/hNeutralMultGen", "Generated Neutral Hadron Multiplicity", kTH1F, {axisMult}); - registry.add("generated/neutral/hNeutralSpectrumGen", "Generated Neutral Hadron Spectrum", kTHnSparseF, {axisPtAssoc, axisEta, axisPhi, axisPid}); // Particle ID of neutral hadrons - registry.add("generated/neutral/hNeutralDecayGen", "Generated Neutral Hadron-Decay Photon Correlation", kTHnSparseF, {axisPtAssoc, axisDeltaPt, axisDeltaEtaDecay, axisDeltaPhiDecay, axisPid}); // Correlation with decay photons + registry.add("generated/neutral/hNeutralSpectrumGen", "Generated Neutral Hadron Spectrum", kTHnSparseF, {axisPtAssoc, axisEtaAssoc, axisPhi, axisPid}); + registry.add("generated/neutral/hNeutralDecayGen", "Generated Neutral Hadron-Decay Photon Correlation", kTHnSparseF, {axisPtAssoc, axisDeltaPt, axisDeltaRDecay, axisAlpha, axisPid}); // Correlation with decay photons // Reconstructed histograms + registry.add("reconstructed/events/hEventStats", "Event statistics", kTH1F, {axisEventStats}); + // Triggers registry.add("reconstructed/triggers/hTrigMultReco", "Reconstructed Trigger Multiplicity", kTH1F, {axisMult}); - registry.add("reconstructed/triggers/hTrigSpectrumReco", "Reconstructed Trigger Spectrum", kTHnSparseF, {axisPtTrig, axisEta, axisPhi}); + registry.add("reconstructed/triggers/hTrigSpectrumReco", "Reconstructed Trigger Spectrum", kTHnSparseF, {axisPtTrig, axisEtaTrig, axisPhi}); // Hadrons registry.add("reconstructed/hadrons/hHadronCorrelReco", "Reconstructed Trigger-Hadron Correlation", kTHnSparseF, {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi}); registry.add("reconstructed/hadrons/hHadronMultReco", "Reconstructed Hadron Multiplicity", kTH1F, {axisMult}); - registry.add("reconstructed/hadrons/hHadronSpectrumReco", "Reconstructed Hadron Spectrum", kTHnSparseF, {axisPtAssoc, axisEta, axisPhi}); + registry.add("reconstructed/hadrons/hHadronSpectrumReco", "Reconstructed Hadron Spectrum", kTHnSparseF, {axisPtAssoc, axisEtaAssoc, axisPhi}); registry.add("reconstructed/hadrons/hHadronPtPrimReco", "Reconstructed Primaries Spectrum", kTH1F, {axisPtAssoc}); // Primary hadron spectrum registry.add("reconstructed/hadrons/hHadronPtSecReco", "Reconstructed Secondaries Spectrum", kTH1F, {axisPtAssoc}); // Secondary hadron spectrum // Photons registry.add("reconstructed/photons/hPhotonCorrelReco", "Reconstructed Trigger-Photon Correlation", kTHnSparseF, {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi}); registry.add("reconstructed/photons/hPhotonMultReco", "Reconstructed Photon Multiplicity", kTH1F, {axisMult}); - registry.add("reconstructed/photons/hPhotonSpectrumReco", "Reconstructed Photon Spectrum", kTHnSparseF, {axisPtAssoc, axisEta, axisPhi}); + registry.add("reconstructed/photons/hPhotonSpectrumReco", "Reconstructed Photon Spectrum", kTHnSparseF, {axisPtAssoc, axisEtaAssoc, axisPhi}); // Charged Pions registry.add("reconstructed/charged/hPionCorrelReco", "Reconstructed Trigger-Pion Correlation", kTHnSparseF, {axisPtTrig, axisPtAssoc, axisDeltaEta, axisDeltaPhi}); registry.add("reconstructed/charged/hPionMultReco", "Reconstructed Pion Multiplicity", kTH1F, {axisMult}); - registry.add("reconstructed/charged/hPionSpectrumReco", "Reconstructed Pion Spectrum", kTHnSparseF, {axisPtAssoc, axisEta, axisPhi}); + registry.add("reconstructed/charged/hPionSpectrumReco", "Reconstructed Pion Spectrum", kTHnSparseF, {axisPtAssoc, axisEtaAssoc, axisPhi}); } // To check if object has has_mcParticle() (i.e. is MC Track or data track) @@ -191,13 +193,14 @@ struct HadronPhotonCorrelation { bool initTrack(const T& track) { + // if constexpr (HasHasMcParticle) { if constexpr (HasHasMcParticle::Value) { if (!track.has_mcParticle()) { return false; } } - if (std::abs(track.eta()) > etaMax) { + if (std::abs(track.eta()) > etaMaxAssoc) { return false; } @@ -217,7 +220,11 @@ struct HadronPhotonCorrelation { return false; } - if (std::abs(particle.eta()) > etaMax) { + if (particle.getGenStatusCode() == -1) { + return false; + } + + if (std::abs(particle.eta()) > etaMaxAssoc) { return false; } @@ -232,13 +239,14 @@ struct HadronPhotonCorrelation { template bool initTrig(const T& track) { + // if constexpr (HasHasMcParticle) { if constexpr (HasHasMcParticle::Value) { if (!track.has_mcParticle()) { return false; } } - if (std::abs(track.eta()) > etaMax) { + if (std::abs(track.eta()) > etaMaxTrig) { return false; } @@ -262,7 +270,7 @@ struct HadronPhotonCorrelation { return false; } - if (std::abs(particle.eta()) > etaMax) { + if (std::abs(particle.eta()) > etaMaxTrig) { return false; } @@ -297,27 +305,59 @@ struct HadronPhotonCorrelation { return false; } - if (track.tpcNClsCrossedRows() < 70) { + if (track.tpcNClsCrossedRows() < tpcNClsCrossedRows) { return false; } - if (track.tpcCrossedRowsOverFindableCls() < 0.8) { + if (track.tpcCrossedRowsOverFindableCls() < tpcCrossedRowsOverFindableCls) { return false; } return true; } + /**************************************************************************************************** + ************************************************ EVENTS ******************************************** + ****************************************************************************************************/ + + void processEventsMCGen(JetMcCollision const& collision) + { + if (collision.subGeneratorId() != subGeneratorIdSelections) { + return; + } + + registry.fill(HIST("generated/events/hEventStats"), 0); + registry.fill(HIST("generated/events/hEventStats"), 1, collision.weight()); + registry.fill(HIST("generated/events/hEventStats"), 2, collision.xsectGen()); + } + PROCESS_SWITCH(HadronPhotonCorrelation, processEventsMCGen, "event stats MC gen", true); + + void processEventsMCReco(JetCollisionMCD const& collision, + JetMcCollisions const&) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, false)) { + return; + } + if (collision.subGeneratorId() != subGeneratorIdSelections) { + return; + } + + registry.fill(HIST("reconstructed/events/hEventStats"), 0); + registry.fill(HIST("reconstructed/events/hEventStats"), 1, collision.mcCollision().weight()); + registry.fill(HIST("reconstructed/events/hEventStats"), 2, collision.mcCollision().xsectGen()); + } + PROCESS_SWITCH(HadronPhotonCorrelation, processEventsMCReco, "event stats MC reco", true); + /**************************************************************************************************** ************************************************ TRIGGER ******************************************** ****************************************************************************************************/ /********************************************** DATA ***********************************************/ - void processTrigsReco(JCollision const& collision, - JTracks const& tracks) + void processTrigsReco(JetCollision const& collision, + JetTracks const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } @@ -330,6 +370,7 @@ struct HadronPhotonCorrelation { if (!initTrig(track)) { continue; } + registry.fill(HIST("reconstructed/triggers/hTrigSpectrumReco"), track.pt(), track.eta(), track.phi()); nTrigs++; } @@ -339,11 +380,15 @@ struct HadronPhotonCorrelation { /*********************************************** MC ************************************************/ - void processTrigsMCReco(JCollision const& collision, - Join const& tracks, - JMcParticles const&) + void processTrigsMCReco(JetCollisionMCD const& collision, + JetMcCollisions const&, + Join const& tracks, + JetParticles const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, false)) { + return; + } + if (collision.subGeneratorId() != subGeneratorIdSelections) { return; } @@ -356,26 +401,29 @@ struct HadronPhotonCorrelation { if (!initTrig(track)) { continue; } - registry.fill(HIST("reconstructed/triggers/hTrigSpectrumReco"), track.pt(), track.eta(), track.phi()); + registry.fill(HIST("reconstructed/triggers/hTrigSpectrumReco"), track.pt(), track.eta(), track.phi(), collision.mcCollision().weight()); nTrigs++; } - registry.fill(HIST("reconstructed/triggers/hTrigMultReco"), nTrigs); + registry.fill(HIST("reconstructed/triggers/hTrigMultReco"), nTrigs, collision.mcCollision().weight()); } PROCESS_SWITCH(HadronPhotonCorrelation, processTrigsMCReco, "trigger particle mc properties", true); - void processTrigsMCGen(JMcCollision const&, - JMcParticles const& particles) + void processTrigsMCGen(JetMcCollision const& collision, + JetParticles const& particles) { + if (collision.subGeneratorId() != subGeneratorIdSelections) { + return; + } int nTrigs = 0; for (const auto& particle : particles) { if (!initTrigParticle(particle)) { continue; } - registry.fill(HIST("generated/triggers/hTrigSpectrumGen"), particle.pt(), particle.eta(), particle.phi()); + registry.fill(HIST("generated/triggers/hTrigSpectrumGen"), particle.pt(), particle.eta(), particle.phi(), collision.weight()); nTrigs++; } - registry.fill(HIST("generated/triggers/hTrigMultGen"), nTrigs); + registry.fill(HIST("generated/triggers/hTrigMultGen"), nTrigs, collision.weight()); } PROCESS_SWITCH(HadronPhotonCorrelation, processTrigsMCGen, "trigger particle mc properties", true); @@ -386,12 +434,12 @@ struct HadronPhotonCorrelation { /********************************************** DATA ***********************************************/ using MyTracks = soa::Join; Preslice perCol = aod::v0::collisionId; - void processPhotonCorrelations(JCollision const& collision, - JTracks const& tracks, + void processPhotonCorrelations(JetCollision const& collision, + JetTracks const& tracks, MyTracks const&, V0Datas const& v0s) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } @@ -412,8 +460,8 @@ struct HadronPhotonCorrelation { if (!initTrig(track)) { continue; } - float dphi = calculateDelta(track.phi(), v0.phi(), -PIHalf); - registry.fill(HIST("reconstructed/photons/hPhotonCorrelReco"), track.pt(), v0.pt(), track.eta() - v0.eta(), dphi); + float dphi = RecoDecay::constrainAngle(v0.phi() - track.phi(), -PIHalf); + registry.fill(HIST("reconstructed/photons/hPhotonCorrelReco"), track.pt(), v0.pt(), v0.eta() - track.eta(), dphi); } } registry.fill(HIST("reconstructed/photons/hPhotonMultReco"), nPhotons); @@ -423,14 +471,17 @@ struct HadronPhotonCorrelation { /*********************************************** MC ************************************************/ using MyTracksMC = soa::Join; - void processPhotonCorrelationsMCReco(Join::iterator const& collision_reco, - JMcCollisions const&, - JTracks const& tracks_reco, - JMcParticles const&, + void processPhotonCorrelationsMCReco(Join::iterator const& collision_reco, + JetMcCollisions const&, + JetTracks const& tracks_reco, + JetParticles const&, MyTracksMC const&, V0Datas const& v0s) { - if (!jetderiveddatautilities::selectCollision(collision_reco, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision_reco, eventSelectionBits, false)) { + return; + } + if (collision_reco.mcCollision().subGeneratorId() != subGeneratorIdSelections) { return; } @@ -441,7 +492,7 @@ struct HadronPhotonCorrelation { if (!initV0(v0)) { continue; } - registry.fill(HIST("reconstructed/photons/hPhotonSpectrumReco"), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("reconstructed/photons/hPhotonSpectrumReco"), v0.pt(), v0.eta(), v0.phi(), collision_reco.mcCollision().weight()); nPhotons++; for (const auto& track : tracks_reco) { @@ -452,36 +503,66 @@ struct HadronPhotonCorrelation { if (!initTrig(track)) { continue; } - float dphi = calculateDelta(track.phi(), v0.phi(), -PIHalf); - registry.fill(HIST("reconstructed/photons/hPhotonCorrelReco"), track.pt(), v0.pt(), track.eta() - v0.eta(), dphi); + float dphi = RecoDecay::constrainAngle(v0.phi() - track.phi(), -PIHalf); + registry.fill(HIST("reconstructed/photons/hPhotonCorrelReco"), track.pt(), v0.pt(), v0.eta() - track.eta(), dphi, collision_reco.mcCollision().weight()); } } - registry.fill(HIST("reconstructed/photons/hPhotonMultReco"), nPhotons); + registry.fill(HIST("reconstructed/photons/hPhotonMultReco"), nPhotons, collision_reco.mcCollision().weight()); } PROCESS_SWITCH(HadronPhotonCorrelation, processPhotonCorrelationsMCReco, "hadron-photon correlation", true); - void processPhotonCorrelationsMCGen(JMcCollision const&, - JMcParticles const& tracks_true) + void processPhotonCorrelationsMCGen(JetMcCollision const& collision, + JetParticles const& tracks_true) { + if (collision.subGeneratorId() != subGeneratorIdSelections) { + return; + } + int nPhotons = 0; for (const auto& track_assoc : tracks_true) { if (!initParticle(track_assoc, false)) { continue; } - if (std::abs(track_assoc.pdgCode()) != 22) { + if ((PDG_t)std::abs(track_assoc.pdgCode()) != kGamma) { continue; } - if (!track_assoc.isPhysicalPrimary() && track_assoc.getGenStatusCode() == -1) { + if (!track_assoc.isPhysicalPrimary() && track_assoc.getGenStatusCode() < 0) { continue; } // Iterate through mother particles until original mother is reached - auto mother = track_assoc.mothers_as().at(0); - while (mother.pdgCode() == 22) { - mother = mother.mothers_as().at(0); + auto origPhoton = track_assoc; + auto mother = track_assoc.mothers_as().at(0); + while ((PDG_t)mother.pdgCode() == kGamma) { + origPhoton = mother; + mother = mother.mothers_as().at(0); } - registry.fill(HIST("generated/photons/hPhotonSpectrumGen"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi(), pidCodes[mother.pdgCode()]); + auto pdgMother = pdg->GetParticle(mother.pdgCode()); + if (!pdgMother) { + continue; + } + int photonGeneration; + switch (std::abs(origPhoton.getGenStatusCode())) { + case 23: // prompt direct photons + case 33: + photonGeneration = -2; + break; + case 43: // shower photons + case 44: + case 51: + case 52: + photonGeneration = -1; + break; + case 91: // decay photons + photonGeneration = pidCodes[pdgMother->GetName()]; + break; + default: + photonGeneration = -3; + break; + } + + registry.fill(HIST("generated/photons/hPhotonSpectrumGen"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi(), photonGeneration, collision.weight()); nPhotons++; @@ -492,12 +573,12 @@ struct HadronPhotonCorrelation { if (!initParticle(track_assoc)) { continue; } - float dphi = calculateDelta(track_trig.phi(), track_assoc.phi(), -PIHalf); - registry.fill(HIST("generated/photons/hPhotonCorrelGen"), track_trig.pt(), track_assoc.pt(), track_trig.eta() - track_assoc.eta(), dphi, pidCodes[mother.pdgCode()]); + float dphi = RecoDecay::constrainAngle(track_assoc.phi() - track_trig.phi(), -PIHalf); + registry.fill(HIST("generated/photons/hPhotonCorrelGen"), track_trig.pt(), track_assoc.pt(), track_assoc.eta() - track_trig.eta(), dphi, photonGeneration, collision.weight()); } } - registry.fill(HIST("generated/photons/hPhotonMultGen"), nPhotons); + registry.fill(HIST("generated/photons/hPhotonMultGen"), nPhotons, collision.weight()); } PROCESS_SWITCH(HadronPhotonCorrelation, processPhotonCorrelationsMCGen, "mc hadron-photon correlation", true); @@ -506,10 +587,10 @@ struct HadronPhotonCorrelation { ****************************************************************************************************/ /********************************************** DATA ***********************************************/ - void processHadronCorrelations(JCollision const& collision, - Join const& tracks) + void processHadronCorrelations(JetCollision const& collision, + Join const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } @@ -529,12 +610,14 @@ struct HadronPhotonCorrelation { if (!jetderiveddatautilities::selectTrack(track_trig, trackSelection)) { continue; } - + if (track_trig == track_assoc) { + continue; + } if (!initTrig(track_trig)) { continue; } - float dphi = calculateDelta(track_trig.phi(), track_assoc.phi(), -PIHalf); - registry.fill(HIST("reconstructed/hadrons/hadrons/hHadronCorrelReco"), track_trig.pt(), track_assoc.pt(), track_trig.eta() - track_assoc.eta(), dphi); + float dphi = RecoDecay::constrainAngle(track_assoc.phi() - track_trig.phi(), -PIHalf); + registry.fill(HIST("reconstructed/hadrons/hadrons/hHadronCorrelReco"), track_trig.pt(), track_assoc.pt(), track_assoc.eta() - track_trig.eta(), dphi); } } registry.fill(HIST("reconstructed/hadrons/hHadronMultReco"), nHadrons); @@ -543,9 +626,13 @@ struct HadronPhotonCorrelation { /*********************************************** MC ************************************************/ - void processHadronCorrelationsMCGen(JMcCollision const&, - JMcParticles const& tracks_true) + void processHadronCorrelationsMCGen(JetMcCollision const& collision, + JetParticles const& tracks_true) { + if (collision.subGeneratorId() != subGeneratorIdSelections) { + return; + } + int nHadrons = 0; for (const auto& track_assoc : tracks_true) { if (!initParticle(track_assoc)) { @@ -555,32 +642,38 @@ struct HadronPhotonCorrelation { if (!pdgParticle || pdgParticle->Charge() == 0.) { continue; } - if (std::abs(track_assoc.pdgCode()) < 100) { + if (std::abs(track_assoc.pdgCode()) < pidCodeHadronCut) { continue; } - registry.fill(HIST("generated/hadrons/hHadronSpectrumGen"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi()); + registry.fill(HIST("generated/hadrons/hHadronSpectrumGen"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi(), collision.weight()); nHadrons++; for (const auto& track_trig : tracks_true) { if (!initTrigParticle(track_trig)) { continue; } - float dphi = calculateDelta(track_trig.phi(), track_assoc.phi(), -PIHalf); + if (track_trig == track_assoc) { + continue; + } + float dphi = RecoDecay::constrainAngle(track_assoc.phi() - track_trig.phi(), -PIHalf); - registry.fill(HIST("generated/hadrons/hHadronCorrelGen"), track_trig.pt(), track_assoc.pt(), track_trig.eta() - track_assoc.eta(), dphi); + registry.fill(HIST("generated/hadrons/hHadronCorrelGen"), track_trig.pt(), track_assoc.pt(), track_assoc.eta() - track_trig.eta(), dphi, collision.weight()); } } - registry.fill(HIST("generated/hadrons/hHadronMultGen"), nHadrons); + registry.fill(HIST("generated/hadrons/hHadronMultGen"), nHadrons, collision.weight()); } PROCESS_SWITCH(HadronPhotonCorrelation, processHadronCorrelationsMCGen, "mc hadron-hadron correlation", true); - void processHadronCorrelationsMCReco(Join::iterator const& collision_reco, - JMcCollisions const&, - Join const& tracks_reco, - JMcParticles const&) + void processHadronCorrelationsMCReco(JetCollisionMCD const& collision_reco, + JetMcCollisions const&, + JetTracksMCD const& tracks_reco, + JetParticles const&) { - if (!jetderiveddatautilities::selectCollision(collision_reco, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision_reco, eventSelectionBits, false)) { + return; + } + if (collision_reco.mcCollision().subGeneratorId() != subGeneratorIdSelections) { return; } @@ -598,18 +691,16 @@ struct HadronPhotonCorrelation { if (!pdgParticle || pdgParticle->Charge() == 0.) { continue; } - if (std::abs(particle.pdgCode()) < 100) { + if (std::abs(particle.pdgCode()) < pidCodeHadronCut) { continue; } - // if(particle.isPhysicalPrimary()){continue;} - // if(std::abs(particle.pdgCode())>1e9){continue;} - registry.fill(HIST("reconstructed/hadrons/hHadronSpectrumReco"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi()); + registry.fill(HIST("reconstructed/hadrons/hHadronSpectrumReco"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi(), collision_reco.mcCollision().weight()); if (particle.isPhysicalPrimary()) { - registry.fill(HIST("reconstructed/hadrons/hHadronPtPrimReco"), track_assoc.pt()); + registry.fill(HIST("reconstructed/hadrons/hHadronPtPrimReco"), track_assoc.pt(), collision_reco.mcCollision().weight()); } else { - registry.fill(HIST("reconstructed/hadrons/hHadronPtSecReco"), track_assoc.pt()); + registry.fill(HIST("reconstructed/hadrons/hHadronPtSecReco"), track_assoc.pt(), collision_reco.mcCollision().weight()); } nHadrons++; @@ -617,16 +708,18 @@ struct HadronPhotonCorrelation { if (!jetderiveddatautilities::selectTrack(track_trig, trackSelection)) { continue; } - + if (track_trig == track_assoc) { + continue; + } if (!initTrig(track_trig)) { continue; } - float dphi = calculateDelta(track_trig.phi(), track_assoc.phi(), -PIHalf); + float dphi = RecoDecay::constrainAngle(track_assoc.phi() - track_trig.phi(), -PIHalf); - registry.fill(HIST("reconstructed/hadrons/hHadronCorrelReco"), track_trig.pt(), track_assoc.pt(), track_trig.eta() - track_assoc.eta(), dphi); + registry.fill(HIST("reconstructed/hadrons/hHadronCorrelReco"), track_trig.pt(), track_assoc.pt(), track_assoc.eta() - track_trig.eta(), dphi, collision_reco.mcCollision().weight()); } } - registry.fill(HIST("reconstructed/hadrons/hHadronMultReco"), nHadrons); + registry.fill(HIST("reconstructed/hadrons/hHadronMultReco"), nHadrons, collision_reco.mcCollision().weight()); } PROCESS_SWITCH(HadronPhotonCorrelation, processHadronCorrelationsMCReco, "mc hadron-hadron correlation", true); @@ -635,10 +728,10 @@ struct HadronPhotonCorrelation { ****************************************************************************************************/ /********************************************** DATA ***********************************************/ - void processPionCorrelations(JCollision const& collision, - Join const& tracks) + void processPionCorrelations(JetCollision const& collision, + Join const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } @@ -651,7 +744,7 @@ struct HadronPhotonCorrelation { if (!initTrack(track_assoc)) { continue; } - if (std::abs(track_assoc.tpcNSigmaPi()) > 2) { + if (std::abs(track_assoc.tpcNSigmaPi()) > tpcNSigmaPi) { continue; } // remove non-pions registry.fill(HIST("reconstructed/charged/hPionSpectrumReco"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi()); @@ -661,12 +754,14 @@ struct HadronPhotonCorrelation { if (!jetderiveddatautilities::selectTrack(track_trig, trackSelection)) { continue; } - + if (track_trig == track_assoc) { + continue; + } if (!initTrig(track_trig)) { continue; } - float dphi = calculateDelta(track_trig.phi(), track_assoc.phi(), -PIHalf); - registry.fill(HIST("reconstructed/charged/hPionCorrelReco"), track_trig.pt(), track_assoc.pt(), track_trig.eta() - track_assoc.eta(), dphi); + float dphi = RecoDecay::constrainAngle(track_assoc.phi() - track_trig.phi(), -PIHalf); + registry.fill(HIST("reconstructed/charged/hPionCorrelReco"), track_trig.pt(), track_assoc.pt(), track_assoc.eta() - track_trig.eta(), dphi); } } registry.fill(HIST("reconstructed/charged/hPionMultReco"), nPions); @@ -675,40 +770,50 @@ struct HadronPhotonCorrelation { /*********************************************** MC ************************************************/ - void processPionCorrelationsMCGen(JMcCollision const&, - JMcParticles const& tracks_true) + void processPionCorrelationsMCGen(JetMcCollision const& collision, + JetParticles const& tracks_true) { + if (collision.subGeneratorId() != subGeneratorIdSelections) { + return; + } + int nPions = 0; for (const auto& track_assoc : tracks_true) { if (!initParticle(track_assoc)) { continue; } - if (std::abs(track_assoc.pdgCode()) != 211) { + if ((PDG_t)std::abs(track_assoc.pdgCode()) != kPiPlus) { continue; } - registry.fill(HIST("generated/charged/hPionSpectrumGen"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi()); + registry.fill(HIST("generated/charged/hPionSpectrumGen"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi(), collision.weight()); nPions++; for (const auto& track_trig : tracks_true) { if (!initTrigParticle(track_trig)) { continue; } - float dphi = calculateDelta(track_trig.phi(), track_assoc.phi(), -PIHalf); + if (track_trig == track_assoc) { + continue; + } + float dphi = RecoDecay::constrainAngle(track_assoc.phi() - track_trig.phi(), -PIHalf); - registry.fill(HIST("generated/charged/hPionCorrelGen"), track_trig.pt(), track_assoc.pt(), track_trig.eta() - track_assoc.eta(), dphi); + registry.fill(HIST("generated/charged/hPionCorrelGen"), track_trig.pt(), track_assoc.pt(), track_assoc.eta() - track_trig.eta(), dphi, collision.weight()); } } - registry.fill(HIST("generated/charged/hPionMultGen"), nPions); + registry.fill(HIST("generated/charged/hPionMultGen"), nPions, collision.weight()); } PROCESS_SWITCH(HadronPhotonCorrelation, processPionCorrelationsMCGen, "mc hadron-pion correlation", true); - void processPionCorrelationsMCReco(Join::iterator const& collision_reco, - JMcCollisions const&, - Join const& tracks_reco, - JMcParticles const&) + void processPionCorrelationsMCReco(JetCollisionMCD const& collision_reco, + JetMcCollisions const&, + JetTracksMCD const& tracks_reco, + JetParticles const&) { - if (!jetderiveddatautilities::selectCollision(collision_reco, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision_reco, eventSelectionBits, false)) { + return; + } + if (collision_reco.mcCollision().subGeneratorId() != subGeneratorIdSelections) { return; } @@ -721,26 +826,29 @@ struct HadronPhotonCorrelation { if (!initTrack(track_assoc)) { continue; } - if (std::abs(track_assoc.mcParticle().pdgCode()) != 211) { + if ((PDG_t)std::abs(track_assoc.mcParticle().pdgCode()) != kPiPlus) { continue; } - registry.fill(HIST("reconstructed/charged/hPionSpectrumReco"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi()); + registry.fill(HIST("reconstructed/charged/hPionSpectrumReco"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi(), collision_reco.mcCollision().weight()); nPions++; for (const auto& track_trig : tracks_reco) { if (!jetderiveddatautilities::selectTrack(track_trig, trackSelection)) { continue; } + if (track_trig == track_assoc) { + continue; + } if (!initTrig(track_trig)) { continue; } - float dphi = calculateDelta(track_trig.phi(), track_assoc.phi(), -PIHalf); - registry.fill(HIST("reconstructed/charged/hPionCorrelReco"), track_trig.pt(), track_assoc.pt(), track_trig.eta() - track_assoc.eta(), dphi); + float dphi = RecoDecay::constrainAngle(track_assoc.phi() - track_trig.phi(), -PIHalf); + registry.fill(HIST("reconstructed/charged/hPionCorrelReco"), track_trig.pt(), track_assoc.pt(), track_assoc.eta() - track_trig.eta(), dphi, collision_reco.mcCollision().weight()); } } - registry.fill(HIST("reconstructed/charged/hPionMultReco"), nPions); + registry.fill(HIST("reconstructed/charged/hPionMultReco"), nPions, collision_reco.mcCollision().weight()); } PROCESS_SWITCH(HadronPhotonCorrelation, processPionCorrelationsMCReco, "mc hadron-pion correlation", true); @@ -750,9 +858,13 @@ struct HadronPhotonCorrelation { /*********************************************** MC ************************************************/ - void processNeutralCorrelationsMCGen(JMcCollision const&, - JMcParticles const& tracks_true) + void processNeutralCorrelationsMCGen(JetMcCollision const& collision, + JetParticles const& tracks_true) { + if (collision.subGeneratorId() != subGeneratorIdSelections) { + return; + } + int nNeutrals = 0; for (const auto& track_assoc : tracks_true) { if (!initParticle(track_assoc, false)) { @@ -765,22 +877,37 @@ struct HadronPhotonCorrelation { if (pdgParticle->Charge() != 0.) { continue; } // remove charged particles - if (track_assoc.pdgCode() < 100 || track_assoc.pdgCode() == 2112) { + if (track_assoc.pdgCode() < pidCodeHadronCut || (PDG_t)track_assoc.pdgCode() == kNeutron) { continue; - } // remove non-hadrons and protons - - registry.fill(HIST("generated/neutral/hNeutralSpectrumGen"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi(), pidCodes[track_assoc.pdgCode()]); + } // remove non-hadrons and neutrons + registry.fill(HIST("generated/neutral/hNeutralSpectrumGen"), track_assoc.pt(), track_assoc.eta(), track_assoc.phi(), pidCodes[pdgParticle->GetName()], collision.weight()); nNeutrals++; // Get correlations between neutral hadrons and their respective decay photons - for (const auto& daughter : track_assoc.daughters_as()) { - if (daughter.pdgCode() != 22) - continue; - if (!initParticle(daughter, false)) + auto daughters = track_assoc.daughters_as(); + double alpha = -1; + int nPhotonsPionDecay = 2; + if (daughters.size() == nPhotonsPionDecay) { + auto daughter = daughters.begin(); + double pt1 = daughter.pt(); + ++daughter; + double pt2 = daughter.pt(); + alpha = std::abs((pt1 - pt2) / (pt1 + pt2)); + } + + for (const auto& daughter : daughters) { + if ((PDG_t)std::abs(daughter.pdgCode()) != kGamma) { continue; - if (!daughter.isPhysicalPrimary() && daughter.getGenStatusCode() == -1) + } + if (!daughter.isPhysicalPrimary() && daughter.getGenStatusCode() == -1) { continue; - registry.fill(HIST("generated/neutral/hNeutralDecayGen"), track_assoc.pt(), daughter.pt() / track_assoc.pt(), daughter.eta() - track_assoc.eta(), calculateDelta(daughter.phi(), track_assoc.phi(), -PIHalf), pidCodes[track_assoc.pdgCode()]); + } + double deltaPt = daughter.pt() / track_assoc.pt(); + double deltaEta = daughter.eta() - track_assoc.eta(); + double deltaPhi = RecoDecay::constrainAngle(daughter.phi() - track_assoc.phi(), -PIHalf); + double deltaR = std::sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi); + + registry.fill(HIST("generated/neutral/hNeutralDecayGen"), track_assoc.pt(), deltaPt, deltaR, alpha, pidCodes[pdgParticle->GetName()], collision.weight()); } // Get correlations between triggers and neutral hadrons @@ -788,11 +915,11 @@ struct HadronPhotonCorrelation { if (!initTrigParticle(track_trig)) { continue; } - float dphi = calculateDelta(track_assoc.phi(), track_trig.phi(), -PIHalf); - registry.fill(HIST("generated/neutral/hNeutralCorrelGen"), track_trig.pt(), track_assoc.pt(), track_assoc.eta() - track_trig.eta(), dphi, pidCodes[track_assoc.pdgCode()]); + float dphi = RecoDecay::constrainAngle(track_assoc.phi() - track_trig.phi(), -PIHalf); + registry.fill(HIST("generated/neutral/hNeutralCorrelGen"), track_trig.pt(), track_assoc.pt(), track_assoc.eta() - track_trig.eta(), dphi, pidCodes[pdgParticle->GetName()], collision.weight()); } } - registry.fill(HIST("generated/neutral/hNeutralMultGen"), nNeutrals); + registry.fill(HIST("generated/neutral/hNeutralMultGen"), nNeutrals, collision.weight()); } PROCESS_SWITCH(HadronPhotonCorrelation, processNeutralCorrelationsMCGen, "mc hadron-pion correlation", true); }; diff --git a/PWGJE/Tasks/hfFragmentationFunction.cxx b/PWGJE/Tasks/hfFragmentationFunction.cxx index 49e1e204358..b3790cda8cd 100644 --- a/PWGJE/Tasks/hfFragmentationFunction.cxx +++ b/PWGJE/Tasks/hfFragmentationFunction.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -9,42 +9,43 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file hfFragmentationFunction.cxx /// \brief charm hadron hadronization task /// \author Christian Reckziegel , Federal University of ABC /// \since 15.03.2024 /// /// The task store data relevant to the calculation of hadronization observables radial /// profile and/or jet momentum fraction for charmed hadrons -#include -#include -#include "TVector3.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +// +#include "PWGHF/Core/DecayChannels.h" -#include "fastjet/PseudoJet.hh" -#include "fastjet/ClusterSequenceArea.hh" +#include "Common/Core/RecoDecay.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include +#include -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include "TVector3.h" +#include -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetSubstructure.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetHFUtilities.h" -#include "PWGJE/Core/JetUtilities.h" +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -68,34 +69,34 @@ namespace o2::aod { namespace jet_distance { -DECLARE_SOA_COLUMN(JetHfDist, jethfdist, float); -DECLARE_SOA_COLUMN(JetPt, jetpt, float); -DECLARE_SOA_COLUMN(JetEta, jeteta, float); -DECLARE_SOA_COLUMN(JetPhi, jetphi, float); -DECLARE_SOA_COLUMN(JetNConst, jetnconst, int); -DECLARE_SOA_COLUMN(HfPt, hfpt, float); -DECLARE_SOA_COLUMN(HfEta, hfeta, float); -DECLARE_SOA_COLUMN(HfPhi, hfphi, float); -DECLARE_SOA_COLUMN(HfMass, hfmass, float); -DECLARE_SOA_COLUMN(HfY, hfy, float); +DECLARE_SOA_COLUMN(JetHfDist, jetHfDist, float); +DECLARE_SOA_COLUMN(JetPt, jetPt, float); +DECLARE_SOA_COLUMN(JetEta, jetEta, float); +DECLARE_SOA_COLUMN(JetPhi, jetPhi, float); +DECLARE_SOA_COLUMN(JetNConst, jetNConst, int); +DECLARE_SOA_COLUMN(HfPt, hfPt, float); +DECLARE_SOA_COLUMN(HfEta, hfEta, float); +DECLARE_SOA_COLUMN(HfPhi, hfPhi, float); +DECLARE_SOA_COLUMN(HfMass, hfMass, float); +DECLARE_SOA_COLUMN(HfY, hfY, float); DECLARE_SOA_COLUMN(HfPrompt, hfPrompt, bool); -DECLARE_SOA_COLUMN(HfMatch, hfmatch, bool); -DECLARE_SOA_COLUMN(HfMlScore0, hfmlscore0, float); -DECLARE_SOA_COLUMN(HfMlScore1, hfmlscore1, float); -DECLARE_SOA_COLUMN(HfMlScore2, hfmlscore2, float); -DECLARE_SOA_COLUMN(HfMatchedFrom, hfmatchedfrom, int); -DECLARE_SOA_COLUMN(HfSelectedAs, hfselectedas, int); -DECLARE_SOA_COLUMN(MCJetHfDist, mcjethfdist, float); -DECLARE_SOA_COLUMN(MCJetPt, mcjetpt, float); -DECLARE_SOA_COLUMN(MCJetEta, mcjeteta, float); -DECLARE_SOA_COLUMN(MCJetPhi, mcjetphi, float); -DECLARE_SOA_COLUMN(MCJetNConst, mcjetnconst, float); -DECLARE_SOA_COLUMN(MCHfPt, mchfpt, float); -DECLARE_SOA_COLUMN(MCHfEta, mchfeta, float); -DECLARE_SOA_COLUMN(MCHfPhi, mchfphi, float); -DECLARE_SOA_COLUMN(MCHfY, mchfy, float); -DECLARE_SOA_COLUMN(MCHfPrompt, mchfPrompt, bool); -DECLARE_SOA_COLUMN(MCHfMatch, mchfmatch, bool); +DECLARE_SOA_COLUMN(HfMatch, hfMatch, bool); +DECLARE_SOA_COLUMN(HfMlScore0, hfMlScore0, float); +DECLARE_SOA_COLUMN(HfMlScore1, hfMlScore1, float); +DECLARE_SOA_COLUMN(HfMlScore2, hfMlScore2, float); +DECLARE_SOA_COLUMN(HfMatchedFrom, hfMatchedFrom, int); +DECLARE_SOA_COLUMN(HfSelectedAs, hfSelectedAs, int); +DECLARE_SOA_COLUMN(McJetHfDist, mcJetHfDist, float); +DECLARE_SOA_COLUMN(McJetPt, mcJetPt, float); +DECLARE_SOA_COLUMN(McJetEta, mcJetEta, float); +DECLARE_SOA_COLUMN(McJetPhi, mcJetPhi, float); +DECLARE_SOA_COLUMN(McJetNConst, mcJetNConst, float); +DECLARE_SOA_COLUMN(McHfPt, mcHfPt, float); +DECLARE_SOA_COLUMN(McHfEta, mcHfEta, float); +DECLARE_SOA_COLUMN(McHfPhi, mcHfPhi, float); +DECLARE_SOA_COLUMN(McHfY, mcHfY, float); +DECLARE_SOA_COLUMN(McHfPrompt, mcHfPrompt, bool); +DECLARE_SOA_COLUMN(McHfMatch, mcHfMatch, bool); } // namespace jet_distance DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE", jet_distance::JetHfDist, @@ -112,17 +113,17 @@ DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE", jet_distance::HfMlScore1, jet_distance::HfMlScore2); DECLARE_SOA_TABLE(MCPJetDistanceTable, "AOD", "MCPJETDISTTABLE", - jet_distance::MCJetHfDist, - jet_distance::MCJetPt, - jet_distance::MCJetEta, - jet_distance::MCJetPhi, - jet_distance::MCJetNConst, - jet_distance::MCHfPt, - jet_distance::MCHfEta, - jet_distance::MCHfPhi, - jet_distance::MCHfY, - jet_distance::MCHfPrompt, - jet_distance::MCHfMatch); + jet_distance::McJetHfDist, + jet_distance::McJetPt, + jet_distance::McJetEta, + jet_distance::McJetPhi, + jet_distance::McJetNConst, + jet_distance::McHfPt, + jet_distance::McHfEta, + jet_distance::McHfPhi, + jet_distance::McHfY, + jet_distance::McHfPrompt, + jet_distance::McHfMatch); DECLARE_SOA_TABLE(MCDJetDistanceTable, "AOD", "MCDJETDISTTABLE", jet_distance::JetHfDist, jet_distance::JetPt, @@ -142,16 +143,16 @@ DECLARE_SOA_TABLE(MCDJetDistanceTable, "AOD", "MCDJETDISTTABLE", jet_distance::HfMatchedFrom, jet_distance::HfSelectedAs); DECLARE_SOA_TABLE(MatchJetDistanceTable, "AOD", "MATCHTABLE", - jet_distance::MCJetHfDist, - jet_distance::MCJetPt, - jet_distance::MCJetEta, - jet_distance::MCJetPhi, - jet_distance::MCJetNConst, - jet_distance::MCHfPt, - jet_distance::MCHfEta, - jet_distance::MCHfPhi, - jet_distance::MCHfY, - jet_distance::MCHfPrompt, + jet_distance::McJetHfDist, + jet_distance::McJetPt, + jet_distance::McJetEta, + jet_distance::McJetPhi, + jet_distance::McJetNConst, + jet_distance::McHfPt, + jet_distance::McHfEta, + jet_distance::McHfPhi, + jet_distance::McHfY, + jet_distance::McHfPrompt, jet_distance::JetHfDist, jet_distance::JetPt, jet_distance::JetEta, @@ -170,7 +171,7 @@ DECLARE_SOA_TABLE(MatchJetDistanceTable, "AOD", "MATCHTABLE", jet_distance::HfSelectedAs); } // namespace o2::aod -struct HfFragmentationFunctionTask { +struct HfFragmentationFunction { // producing new table Produces distJetTable; Produces mcpdistJetTable; @@ -182,9 +183,9 @@ struct HfFragmentationFunctionTask { using JetMCPTable = soa::Join; // slices for accessing proper HF mcdjets collision associated to mccollisions - PresliceUnsorted CollisionsPerMCCollision = aod::jmccollisionlb::mcCollisionId; - Preslice D0MCDJetsPerCollision = aod::jet::collisionId; - Preslice D0MCPJetsPerMCCollision = aod::jet::mcCollisionId; + PresliceUnsorted collisionsPerMCCollisionPreslice = aod::jmccollisionlb::mcCollisionId; + Preslice d0MCDJetsPerCollisionPreslice = aod::jet::collisionId; + Preslice d0MCPJetsPerMCCollisionPreslice = aod::jet::mcCollisionId; // Histogram registry: an object to hold your histograms HistogramRegistry registry{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -192,12 +193,12 @@ struct HfFragmentationFunctionTask { Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; - int eventSelection = -1; + std::vector eventSelectionBits; void init(InitContext const&) { // initialise event selection: - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); // create histograms // collision system histograms @@ -228,39 +229,40 @@ struct HfFragmentationFunctionTask { } void processDummy(aod::TracksIU const&) {} - PROCESS_SWITCH(HfFragmentationFunctionTask, processDummy, "Dummy process function turned on by default", true); + PROCESS_SWITCH(HfFragmentationFunction, processDummy, "Dummy process function turned on by default", true); void processDataChargedSubstructure(aod::JetCollision const& collision, soa::Join const& jets, - aod::CandidatesD0Data const&) + aod::CandidatesD0Data const&, + aod::JetTracks const&) { // apply event selection and fill histograms for sanity check registry.fill(HIST("h_collision_counter"), 2.0); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !(abs(collision.posZ()) < vertexZCut)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || !(std::abs(collision.posZ()) < vertexZCut)) { return; } registry.fill(HIST("h_collision_counter"), 3.0); - for (auto& jet : jets) { + for (const auto& jet : jets) { // fill jet counter histogram registry.fill(HIST("h_jet_counter"), 0.5); // obtaining jet 3-vector TVector3 jetVector(jet.px(), jet.py(), jet.pz()); - for (auto& d0Candidate : jet.candidates_as()) { + for (const auto& d0Candidate : jet.candidates_as()) { // obtaining jet 3-vector TVector3 d0Vector(d0Candidate.px(), d0Candidate.py(), d0Candidate.pz()); // calculating fraction of the jet momentum carried by the D0 along the direction of the jet axis - double z_parallel = (jetVector * d0Vector) / (jetVector * jetVector); + double zParallel = (jetVector * d0Vector) / (jetVector * jetVector); // calculating angular distance in eta-phi plane double axisDistance = jetutilities::deltaR(jet, d0Candidate); // filling histograms - registry.fill(HIST("h_d0_jet_projection"), z_parallel); - registry.fill(HIST("h_d0_jet_distance_vs_projection"), axisDistance, z_parallel); + registry.fill(HIST("h_d0_jet_projection"), zParallel); + registry.fill(HIST("h_d0_jet_distance_vs_projection"), axisDistance, zParallel); registry.fill(HIST("h_d0_jet_distance"), axisDistance); registry.fill(HIST("h_d0_jet_pt"), jet.pt()); registry.fill(HIST("h_d0_jet_eta"), jet.eta()); @@ -280,7 +282,7 @@ struct HfFragmentationFunctionTask { } // end of jets loop } // end of process function - PROCESS_SWITCH(HfFragmentationFunctionTask, processDataChargedSubstructure, "charged HF jet substructure", false); + PROCESS_SWITCH(HfFragmentationFunction, processDataChargedSubstructure, "charged HF jet substructure", false); void processMcEfficiency(aod::JetMcCollisions const& mccollisions, aod::JetCollisionsMCD const& collisions, @@ -295,23 +297,23 @@ struct HfFragmentationFunctionTask { registry.fill(HIST("h_collision_counter"), 0.0); // skip collisions outside of |z| < vertexZCut - if (abs(mccollision.posZ()) > vertexZCut) { + if (std::abs(mccollision.posZ()) > vertexZCut) { continue; } registry.fill(HIST("h_collision_counter"), 1.0); // reconstructed collisions associated to same mccollision - const auto collisionsPerMCCollision = collisions.sliceBy(CollisionsPerMCCollision, mccollision.globalIndex()); + const auto collisionsPerMCCollision = collisions.sliceBy(collisionsPerMCCollisionPreslice, mccollision.globalIndex()); for (const auto& collision : collisionsPerMCCollision) { registry.fill(HIST("h_collision_counter"), 2.0); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !(abs(collision.posZ()) < vertexZCut)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || !(std::abs(collision.posZ()) < vertexZCut)) { continue; } registry.fill(HIST("h_collision_counter"), 3.0); // d0 detector level jets associated to the current same collision - const auto d0mcdJetsPerCollision = mcdjets.sliceBy(D0MCDJetsPerCollision, collision.globalIndex()); + const auto d0mcdJetsPerCollision = mcdjets.sliceBy(d0MCDJetsPerCollisionPreslice, collision.globalIndex()); for (const auto& mcdjet : d0mcdJetsPerCollision) { registry.fill(HIST("h_jet_counter"), 0.5); @@ -325,7 +327,7 @@ struct HfFragmentationFunctionTask { // reflection information for storage: D0 = +1, D0bar = -1, neither = 0 int matchedFrom = 0; - int decayChannel = 1 << aod::hf_cand_2prong::DecayType::D0ToPiK; + int decayChannel = o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; int selectedAs = 0; if (mcdd0cand.flagMcMatchRec() == decayChannel) { // matched to D0 on truth level @@ -350,7 +352,7 @@ struct HfFragmentationFunctionTask { } // d0 particle level jets associated to same mccollision - const auto d0mcpJetsPerMCCollision = mcpjets.sliceBy(D0MCPJetsPerMCCollision, mccollision.globalIndex()); + const auto d0mcpJetsPerMCCollision = mcpjets.sliceBy(d0MCPJetsPerMCCollisionPreslice, mccollision.globalIndex()); for (const auto& mcpjet : d0mcpJetsPerMCCollision) { registry.fill(HIST("h_jet_counter"), 0.0); @@ -370,7 +372,7 @@ struct HfFragmentationFunctionTask { } } } - PROCESS_SWITCH(HfFragmentationFunctionTask, processMcEfficiency, "non-matched and matched MC HF and jets", false); + PROCESS_SWITCH(HfFragmentationFunction, processMcEfficiency, "non-matched and matched MC HF and jets", false); void processMcChargedMatched(aod::JetMcCollisions const& mccollisions, aod::JetCollisionsMCD const& collisions, @@ -386,22 +388,22 @@ struct HfFragmentationFunctionTask { registry.fill(HIST("h_collision_counter"), 0.0); // skip collisions outside of |z| < vertexZCut - if (abs(mccollision.posZ()) > vertexZCut) { + if (std::abs(mccollision.posZ()) > vertexZCut) { continue; } registry.fill(HIST("h_collision_counter"), 1.0); // reconstructed collisions associated to same mccollision - const auto collisionsPerMCCollision = collisions.sliceBy(CollisionsPerMCCollision, mccollision.globalIndex()); + const auto collisionsPerMCCollision = collisions.sliceBy(collisionsPerMCCollisionPreslice, mccollision.globalIndex()); for (const auto& collision : collisionsPerMCCollision) { registry.fill(HIST("h_collision_counter"), 2.0); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !(abs(collision.posZ()) < vertexZCut)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || !(std::abs(collision.posZ()) < vertexZCut)) { continue; } registry.fill(HIST("h_collision_counter"), 3.0); // d0 detector level jets associated to the current same collision - const auto d0mcdJetsPerCollision = mcdjets.sliceBy(D0MCDJetsPerCollision, collision.globalIndex()); + const auto d0mcdJetsPerCollision = mcdjets.sliceBy(d0MCDJetsPerCollisionPreslice, collision.globalIndex()); for (const auto& mcdjet : d0mcdJetsPerCollision) { registry.fill(HIST("h_jet_counter"), 0.5); @@ -416,7 +418,7 @@ struct HfFragmentationFunctionTask { // reflection information for storage: D0 = +1, D0bar = -1, neither = 0 int matchedFrom = 0; - int decayChannel = 1 << aod::hf_cand_2prong::DecayType::D0ToPiK; + int decayChannel = o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK; int selectedAs = 0; if (mcdd0cand.flagMcMatchRec() == decayChannel) { // matched to D0 on truth level @@ -432,7 +434,7 @@ struct HfFragmentationFunctionTask { } // loop through detector level matched to current particle level - for (auto& mcpjet : mcdjet.matchedJetCand_as()) { + for (const auto& mcpjet : mcdjet.matchedJetCand_as()) { registry.fill(HIST("h_jet_counter"), 2.5); @@ -451,11 +453,11 @@ struct HfFragmentationFunctionTask { } } } - PROCESS_SWITCH(HfFragmentationFunctionTask, processMcChargedMatched, "matched MC HF and jets", false); + PROCESS_SWITCH(HfFragmentationFunction, processMcChargedMatched, "matched MC HF and jets", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"jet-charm-hadronization"})}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGJE/Tasks/jetBackgroundAnalysis.cxx b/PWGJE/Tasks/jetBackgroundAnalysis.cxx index d951ce485ea..8e93fc305d0 100644 --- a/PWGJE/Tasks/jetBackgroundAnalysis.cxx +++ b/PWGJE/Tasks/jetBackgroundAnalysis.cxx @@ -14,32 +14,29 @@ /// \author Aimeric Landou /// \author Nima Zardoshti -#include -#include -#include -#include "TLorentzVector.h" +#include "RecoDecay.h" + +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" +#include +#include +#include +#include -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/DataModel/Jet.h" +#include +#include -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include +#include +#include -#include "EventFiltering/filterTables.h" +#include using namespace o2; using namespace o2::framework; @@ -54,6 +51,8 @@ struct JetBackgroundAnalysisTask { Configurable centralityMax{"centralityMax", 999.0, "maximum centrality for collisions"}; Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum track occupancy of collisions in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; Configurable trackOccupancyInTimeRangeMin{"trackOccupancyInTimeRangeMin", -999999, "minimum track occupancy of collisions in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "flag to choose to reject min. bias gap events"}; + Configurable nBinsFluct{"nBinsFluct", 1000, "number of bins for flucuations axes"}; Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum eta acceptance for tracks"}; Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum eta acceptance for tracks"}; @@ -68,15 +67,18 @@ struct JetBackgroundAnalysisTask { Configurable randomConeR{"randomConeR", 0.4, "size of random Cone for estimating background fluctuations"}; Configurable randomConeLeadJetDeltaR{"randomConeLeadJetDeltaR", -99.0, "min distance between leading jet axis and random cone (RC) axis; if negative, min distance is set to automatic value of R_leadJet+R_RC "}; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; void init(o2::framework::InitContext&) { // selection settings initialisation - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + // Axes definitions + AxisSpec bkgFluctuationsAxis = {nBinsFluct, -100.0, 100.0, "#delta #it{p}_{T} (GeV/#it{c})"}; + // histogram definitions if (doprocessRho) { @@ -88,16 +90,16 @@ struct JetBackgroundAnalysisTask { } if (doprocessBkgFluctuationsData || doprocessBkgFluctuationsMCD) { - registry.add("h2_centrality_rhorandomcone", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, {800, -400.0, 400.0}}}); - registry.add("h2_centrality_rhorandomconerandomtrackdirection", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, {800, -400.0, 400.0}}}); - registry.add("h2_centrality_rhorandomconewithoutleadingjet", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, {800, -400.0, 400.0}}}); - registry.add("h2_centrality_rhorandomconerandomtrackdirectionwithoutoneleadingjets", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, {800, -400.0, 400.0}}}); - registry.add("h2_centrality_rhorandomconerandomtrackdirectionwithouttwoleadingjets", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, {800, -400.0, 400.0}}}); + registry.add("h2_centrality_rhorandomcone", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, bkgFluctuationsAxis}}); + registry.add("h2_centrality_rhorandomconerandomtrackdirection", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, bkgFluctuationsAxis}}); + registry.add("h2_centrality_rhorandomconewithoutleadingjet", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, bkgFluctuationsAxis}}); + registry.add("h2_centrality_rhorandomconerandomtrackdirectionwithoutoneleadingjets", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, bkgFluctuationsAxis}}); + registry.add("h2_centrality_rhorandomconerandomtrackdirectionwithouttwoleadingjets", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, bkgFluctuationsAxis}}); } } Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); - Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); template bool trackIsInJet(TTracks const& track, TJets const& jet) @@ -113,12 +115,6 @@ struct JetBackgroundAnalysisTask { template void bkgFluctuationsRandomCone(TCollisions const& collision, TJets const& jets, TTracks const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { - return; - } - if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { - return; - } TRandom3 randomNumber(0); float randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); float randomConePhi = randomNumber.Uniform(0.0, 2 * M_PI); @@ -132,7 +128,7 @@ struct JetBackgroundAnalysisTask { } } } - registry.fill(HIST("h2_centrality_rhorandomcone"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomcone"), collision.centFT0M(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); // randomised eta,phi for tracks, to assess part of fluctuations coming from statistically independently emitted particles randomConePt = 0; @@ -145,7 +141,7 @@ struct JetBackgroundAnalysisTask { } } } - registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirection"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirection"), collision.centFT0M(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); // removing the leading jet from the random cone if (jets.size() > 0) { // if there are no jets in the acceptance (from the jetfinder cuts) then there can be no leading jet @@ -173,33 +169,34 @@ struct JetBackgroundAnalysisTask { } } } - - registry.fill(HIST("h2_centrality_rhorandomconewithoutleadingjet"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomconewithoutleadingjet"), collision.centFT0M(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); // randomised eta,phi for tracks, to assess part of fluctuations coming from statistically independently emitted particles, removing tracks from 2 leading jets double randomConePtWithoutOneLeadJet = 0; double randomConePtWithoutTwoLeadJet = 0; - for (auto const& track : tracks) { - if (jetderiveddatautilities::selectTrack(track, trackSelection)) { - float dPhi = RecoDecay::constrainAngle(randomNumber.Uniform(0.0, 2 * M_PI) - randomConePhi, static_cast(-M_PI)); // ignores actual phi of track - float dEta = randomNumber.Uniform(trackEtaMin, trackEtaMax) - randomConeEta; // ignores actual eta of track - if (TMath::Sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { - if (!trackIsInJet(track, jets.iteratorAt(0))) { - randomConePtWithoutOneLeadJet += track.pt(); - if (!trackIsInJet(track, jets.iteratorAt(1))) { - randomConePtWithoutTwoLeadJet += track.pt(); + if (jets.size() > 1) { // if there are no jets, or just one, in the acceptance (from the jetfinder cuts) then one cannot find 2 leading jets + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection)) { + float dPhi = RecoDecay::constrainAngle(randomNumber.Uniform(0.0, 2 * M_PI) - randomConePhi, static_cast(-M_PI)); // ignores actual phi of track + float dEta = randomNumber.Uniform(trackEtaMin, trackEtaMax) - randomConeEta; // ignores actual eta of track + if (TMath::Sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + if (!trackIsInJet(track, jets.iteratorAt(0))) { + randomConePtWithoutOneLeadJet += track.pt(); + if (!trackIsInJet(track, jets.iteratorAt(1))) { + randomConePtWithoutTwoLeadJet += track.pt(); + } } } } } } - registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirectionwithoutoneleadingjets"), collision.centrality(), randomConePtWithoutOneLeadJet - M_PI * randomConeR * randomConeR * collision.rho()); - registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirectionwithouttwoleadingjets"), collision.centrality(), randomConePtWithoutTwoLeadJet - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirectionwithoutoneleadingjets"), collision.centFT0M(), randomConePtWithoutOneLeadJet - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirectionwithouttwoleadingjets"), collision.centFT0M(), randomConePtWithoutTwoLeadJet - M_PI * randomConeR * randomConeR * collision.rho()); } void processRho(soa::Filtered>::iterator const& collision, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { @@ -211,22 +208,34 @@ struct JetBackgroundAnalysisTask { nTracks++; } } - registry.fill(HIST("h2_centrality_ntracks"), collision.centrality(), nTracks); + registry.fill(HIST("h2_centrality_ntracks"), collision.centFT0M(), nTracks); registry.fill(HIST("h2_ntracks_rho"), nTracks, collision.rho()); registry.fill(HIST("h2_ntracks_rhom"), nTracks, collision.rhoM()); - registry.fill(HIST("h2_centrality_rho"), collision.centrality(), collision.rho()); - registry.fill(HIST("h2_centrality_rhom"), collision.centrality(), collision.rhoM()); + registry.fill(HIST("h2_centrality_rho"), collision.centFT0M(), collision.rho()); + registry.fill(HIST("h2_centrality_rhom"), collision.centFT0M(), collision.rhoM()); } PROCESS_SWITCH(JetBackgroundAnalysisTask, processRho, "QA for rho-area subtracted jets", false); void processBkgFluctuationsData(soa::Filtered>::iterator const& collision, soa::Join const& jets, soa::Filtered const& tracks) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } bkgFluctuationsRandomCone(collision, jets, tracks); } PROCESS_SWITCH(JetBackgroundAnalysisTask, processBkgFluctuationsData, "QA for random cone estimation of background fluctuations in data", false); void processBkgFluctuationsMCD(soa::Filtered>::iterator const& collision, soa::Join const& jets, soa::Filtered const& tracks) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } bkgFluctuationsRandomCone(collision, jets, tracks); } PROCESS_SWITCH(JetBackgroundAnalysisTask, processBkgFluctuationsMCD, "QA for random cone estimation of background fluctuations in mcd", false); diff --git a/PWGJE/Tasks/jetChCorr.cxx b/PWGJE/Tasks/jetChCorr.cxx index 43486b4567c..4311fc5c7d8 100644 --- a/PWGJE/Tasks/jetChCorr.cxx +++ b/PWGJE/Tasks/jetChCorr.cxx @@ -14,38 +14,35 @@ /// Mriganka Mouli Mondal originally modified from Nima Zardoshti // -#include -#include -#include -#include -#include -#include -#include - -#include "fastjet/PseudoJet.hh" -#include "fastjet/ClusterSequenceArea.hh" +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetSubstructure.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/FastJetUtilities.h" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/PseudoJet.hh" +#include -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include +#include +#include // #include "PWGLF/DataModel/LFResonanceTables.h" -#include "Framework/runDataProcessing.h" +#include +#include +#include +#include +#include using namespace std; using namespace o2; diff --git a/PWGJE/Tasks/jetChargedV2.cxx b/PWGJE/Tasks/jetChargedV2.cxx index dc62692a2b4..4c5cd82ed25 100644 --- a/PWGJE/Tasks/jetChargedV2.cxx +++ b/PWGJE/Tasks/jetChargedV2.cxx @@ -8,80 +8,69 @@ // 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. - -// jet v2 task +// /// \author Yubiao Wang -// C++/ROOT includes. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -// o2Physics includes. - -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsParameters/GRPMagField.h" - -#include "Framework/runDataProcessing.h" - -#include "Common/DataModel/FT0Corrected.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "Common/CCDB/ctpRateFetcher.h" +/// \file jetChargedV2.cxx +/// \brief This file contains the implementation for the Charged Jet v2 analysis in the ALICE experiment -//< evt pln .h >// -#include "Framework/ASoAHelpers.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/StaticFor.h" +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/Jet.h" -#include "Common/DataModel/Qvectors.h" #include "Common/Core/EventPlaneHelper.h" -//< evt pln .h | end >// - -// o2 includes. -#include "DetectorsCommonDataFormats/AlignParam.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/filterTables.h" +#include "CommonConstants/PhysicsConstants.h" #include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/TrackSelectionDefaults.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StaticFor.h" +#include "Framework/runDataProcessing.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/DataModel/Jet.h" +#include +#include +#include +#include +#include +#include +#include +#include -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "EventFiltering/filterTables.h" +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -//=====================< evt pln >=====================// -using MyCollisions = soa::Join; -//=====================< evt pln | end >=====================// +struct JetChargedV2 { + using McParticleCollision = soa::Join; + using ChargedMCDMatchedJets = soa::Join; + using ChargedMCPMatchedJets = soa::Join; -struct Jetchargedv2Task { HistogramRegistry registry; HistogramRegistry histosQA{"histosQA", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; - Configurable> jetRadii{"jetRadii", std::vector{0.4}, "jet resolution parameters"}; Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + Configurable trackDcaZmax{"trackDcaZmax", 99, "additional cut on dcaZ to PV for tracks; uniformTracks in particular don't cut on this at all"}; Configurable centralityMin{"centralityMin", -999.0, "minimum centrality"}; Configurable centralityMax{"centralityMax", 999.0, "maximum centrality"}; Configurable trackPtMin{"trackPtMin", 0.15, "minimum pT acceptance for tracks"}; @@ -91,13 +80,21 @@ struct Jetchargedv2Task { Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; Configurable leadingConstituentPtMin{"leadingConstituentPtMin", -99.0, "minimum pT selection on jet constituent"}; + Configurable leadingConstituentPtMax{"leadingConstituentPtMax", 9999.0, "maximum pT selection on jet constituent"}; Configurable jetPtMin{"jetPtMin", 0.15, "minimum pT acceptance for jets"}; Configurable jetPtMax{"jetPtMax", 200.0, "maximum pT acceptance for jets"}; Configurable jetEtaMin{"jetEtaMin", -0.9, "minimum eta acceptance for jets"}; Configurable jetEtaMax{"jetEtaMax", 0.9, "maximum eta acceptance for jets"}; + Configurable nBinsEta{"nBinsEta", 200, "number of bins for eta axes"}; Configurable jetRadius{"jetRadius", 0.2, "jet resolution parameters"}; + Configurable randomConeLeadJetDeltaR{"randomConeLeadJetDeltaR", -99.0, "min distance between leading jet axis and random cone (RC) axis; if negative, min distance is set to automatic value of R_leadJet+R_RC "}; + + Configurable localRhoFitPtMin{"localRhoFitPtMin", 0.2, "Minimum track pT used for local rho fluctuation fit"}; + Configurable localRhoFitPtMax{"localRhoFitPtMax", 5, "Maximum track pT used for local rho fluctuation fit"}; Configurable randomConeR{"randomConeR", 0.4, "size of random Cone for estimating background fluctuations"}; + Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; + Configurable trackOccupancyInTimeRangeMin{"trackOccupancyInTimeRangeMin", -999999, "minimum occupancy of tracks in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; //=====================< evt pln >=====================// Configurable cfgAddEvtSel{"cfgAddEvtSel", true, "event selection"}; @@ -107,17 +104,31 @@ struct Jetchargedv2Task { Configurable cfgRefAName{"cfgRefAName", "TPCpos", "The name of detector for reference A"}; Configurable cfgRefBName{"cfgRefBName", "TPCneg", "The name of detector for reference B"}; - ConfigurableAxis cfgaxisQvecF{"cfgaxisQvecF", {300, -1, 1}, ""}; - ConfigurableAxis cfgaxisQvec{"cfgaxisQvec", {100, -3, 3}, ""}; - ConfigurableAxis cfgaxisCent{"cfgaxisCent", {90, 0, 90}, ""}; + ConfigurableAxis cfgAxisQvecF{"cfgAxisQvecF", {300, -1, 1}, ""}; + ConfigurableAxis cfgAxisQvec{"cfgAxisQvec", {100, -3, 3}, ""}; + ConfigurableAxis cfgAxisCent{"cfgAxisCent", {90, 0, 90}, ""}; + ConfigurableAxis cfgAxisVnCent{"cfgAxisVnCent", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 50, 70, 100}, " % "}; + + ConfigurableAxis cfgAxisEvtfit{"cfgAxisEvtfit", {10000, 0, 10000}, ""}; EventPlaneHelper helperEP; - int DetId; - int RefAId; - int RefBId; + int detId; + int refAId; + int refBId; + + //=====================< jetSpectraConfig to this analysis >=====================// + Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; + Configurable acceptSplitCollisions{"acceptSplitCollisions", 0, "0: only look at mcCollisions that are not split; 1: accept split mcCollisions, 2: accept split mcCollisions but only look at the first reco collision associated with it"}; + Configurable pTHatAbsoluteMin{"pTHatAbsoluteMin", -99.0, "minimum value of pTHat"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "flag to choose to reject min. bias gap events; jet-level rejection can also be applied at the jet finder level for jets only, here rejection is applied for collision and track process functions for the first time, and on jets in case it was set to false at the jet finder level"}; + Configurable checkMcCollisionIsMatched{"checkMcCollisionIsMatched", false, "0: count whole MCcollisions, 1: select MCcollisions which only have their correspond collisions"}; + Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; + Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; + Configurable checkLeadConstituentPtForMcpJets{"checkLeadConstituentPtForMcpJets", false, "flag to choose whether particle level jets should have their lead track pt above leadingConstituentPtMin to be accepted; off by default, as leadingConstituentPtMin cut is only applied on MCD jets for the Pb-Pb analysis using pp MC anchored to Pb-Pb for the response matrix"}; + Configurable cfgChkFitQuality{"cfgChkFitQuality", false, "check fit quality"}; template - int GetDetId(const T& name) + int getDetId(const T& name) { if (name.value == "BPos" || name.value == "BNeg" || name.value == "BTot") { LOGF(warning, "Using deprecated label: %s. Please use TPCpos, TPCneg, TPCall instead.", name.value); @@ -140,39 +151,56 @@ struct Jetchargedv2Task { return 0; } } - //=====================< evt pln | end >=====================// + //=====================< evt p615ln | end >=====================// - Configurable selectedJetsRadius{"selectedJetsRadius", 0.4, "resolution parameter for histograms without radius"}; + Configurable selectedJetsRadius{"selectedJetsRadius", 0.2, "resolution parameter for histograms without radius"}; std::vector jetPtBins; std::vector jetPtBinsRhoAreaSub; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; - double evtnum = 1; // evt sum for local rho test + double evtnum = 0; + double accptTrack = 0; + double fitTrack = 0; + float collQvecAmpDetId = 1e-8; + TH1F* hPtsumSumptFit = nullptr; + TH1F* hPtsumSumptFitMCP = nullptr; + TF1* fFitModulationV2v3 = 0x0; + TF1* fFitModulationV2v3P = 0x0; + TH1F* hPtsumSumptFitRM = nullptr; + TF1* fFitModulationRM = 0x0; void init(o2::framework::InitContext&) { - DetId = GetDetId(cfgDetName); - RefAId = GetDetId(cfgRefAName); - RefBId = GetDetId(cfgRefBName); - if (DetId == RefAId || DetId == RefBId || RefAId == RefBId) { + detId = getDetId(cfgDetName); + refAId = getDetId(cfgRefAName); + refBId = getDetId(cfgRefBName); + if (detId == refAId || detId == refBId || refAId == refBId) { LOGF(info, "Wrong detector configuration \n The FT0C will be used to get Q-Vector \n The TPCpos and TPCneg will be used as reference systems"); - DetId = 0; - RefAId = 4; - RefBId = 5; + detId = 0; + refAId = 4; + refBId = 5; + } + auto jetRadiiBins = (std::vector)jetRadii; + if (jetRadiiBins.size() > 1) { + jetRadiiBins.push_back(jetRadiiBins[jetRadiiBins.size() - 1] + (std::abs(jetRadiiBins[jetRadiiBins.size() - 1] - jetRadiiBins[jetRadiiBins.size() - 2]))); + } else { + jetRadiiBins.push_back(jetRadiiBins[jetRadiiBins.size() - 1] + 0.1); } auto jetPtTemp = 0.0; jetPtBins.push_back(jetPtTemp); jetPtBinsRhoAreaSub.push_back(jetPtTemp); while (jetPtTemp < jetPtMax) { - if (jetPtTemp < 100.0) { + double jetPtTempA = 100.0; + double jetPtTempB = 100.0; + if (jetPtTemp < jetPtTempA) { jetPtTemp += 1.0; jetPtBins.push_back(jetPtTemp); jetPtBinsRhoAreaSub.push_back(jetPtTemp); jetPtBinsRhoAreaSub.push_back(-jetPtTemp); - } else if (jetPtTemp < 200.0) { + } else if (jetPtTemp < jetPtTempB) { jetPtTemp += 5.0; jetPtBins.push_back(jetPtTemp); jetPtBinsRhoAreaSub.push_back(jetPtTemp); @@ -187,194 +215,745 @@ struct Jetchargedv2Task { } std::sort(jetPtBinsRhoAreaSub.begin(), jetPtBinsRhoAreaSub.end()); - AxisSpec jetPtAxis = {jetPtBins, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec jetPtAxisRhoAreaSub = {jetPtBinsRhoAreaSub, "#it{p}_{T} (GeV/#it{c})"}; - //< bkg sub | end >// + //< MCAxis >// + AxisSpec centralityAxis = {1200, -10., 110., "Centrality"}; + AxisSpec trackPtAxis = {200, -0.5, 199.5, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec trackEtaAxis = {nBinsEta, -1.0, 1.0, "#eta"}; + AxisSpec phiAxis = {160, -1.0, 7.0, "#varphi"}; + AxisSpec jetPtAxis = {200, 0., 200., "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec jetPtAxisRhoAreaSub = {400, -200., 200., "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec jetEtaAxis = {nBinsEta, -1.0, 1.0, "#eta"}; AxisSpec axisPt = {40, 0.0, 4.0}; AxisSpec axisEta = {32, -0.8, 0.8}; AxisSpec axixCent = {20, 0, 100}; AxisSpec axisChID = {220, 0, 220}; - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); - //< \sigma p_T at local rho test plot > - registry.add("h_ptsum_collnum", "ptsum collnum;collnum;entries", {HistType::kTH1F, {{40, 0.0, 40}}}); - registry.add("h_ptsum_sumpt", "jet sumpt;sum p_{T};entries", {HistType::kTH1F, {{160, 0., TMath::TwoPi()}}}); - registry.add("h2_phi_track_eta", "phi vs track eta; #eta (GeV/#it{c}); #varphi", {HistType::kTH2F, {{100, -1.0, 1.0}, {160, 0., TMath::TwoPi()}}}); - registry.add("h2_phi_track_pt", "phi vs track pT; #it{p}_{T,track} (GeV/#it{c}); #varphi", {HistType::kTH2F, {{200, 0., 200.}, {160, 0., TMath::TwoPi()}}}); - registry.add("h2_centrality_phi_w_pt", "centrality vs jet #varphi; centrality; entries", {HistType::kTH2F, {{100, 0.0, 100.0}, {160, 0., TMath::TwoPi()}}}); - registry.add("h2_evtnum_phi_w_pt", "eventNumber vs jet #varphi; #eventNumber; entries", {HistType::kTH2F, {{100000, 0.0, 100000}, {160, 0., TMath::TwoPi()}}}); + registry.add("h_jet_phat", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); + registry.add("h_jet_phat_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); + + if (doprocessInOutJetV2 || doprocessInOutJetV2MCD || doprocessSigmaPt || doprocessSigmaPtMCD) { + //=====================< evt pln plot >=====================// + AxisSpec axisCent{cfgAxisCent, "centrality"}; + AxisSpec axisQvec{cfgAxisQvec, "Q"}; + AxisSpec axisQvecF{cfgAxisQvecF, "Q"}; + AxisSpec axisEvtPl{360, -constants::math::PI, constants::math::PI}; + for (uint i = 0; i < cfgnMods->size(); i++) { + histosQA.add(Form("histQvecUncorV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); + histosQA.add(Form("histQvecRectrV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); + histosQA.add(Form("histQvecTwistV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); + histosQA.add(Form("histQvecFinalV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvec, axisQvec, axisCent}}); + + histosQA.add(Form("histEvtPlUncorV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("histEvtPlRectrV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("histEvtPlTwistV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("histEvtPlFinalV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + + histosQA.add(Form("histEvtPlRes_SigRefAV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("histEvtPlRes_SigRefBV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + histosQA.add(Form("histEvtPlRes_RefARefBV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + } + histosQA.add("histCent", "Centrality TrkProcess", HistType::kTH1F, {axisCent}); + //< Track efficiency plots >// + registry.add("h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + //< fit quality >// + registry.add("h_PvalueCDF_CombinFit", "cDF #chi^{2}; entries", {HistType::kTH1F, {{50, 0, 1}}}); + registry.add("h2_PvalueCDFCent_CombinFit", "p-value cDF vs centrality; centrality; p-value", {HistType::kTH2F, {{100, 0, 100}, {40, 0, 1}}}); + registry.add("h2_Chi2Cent_CombinFit", "Chi2 vs centrality; centrality; #tilde{#chi^{2}}", {HistType::kTH2F, {{100, 0, 100}, {100, 0, 5}}}); + registry.add("h2_PChi2_CombinFit", "p-value vs #tilde{#chi^{2}}; p-value; #tilde{#chi^{2}}", {HistType::kTH2F, {{100, 0, 1}, {100, 0, 5}}}); + + registry.add("h2_PChi2_CombinFitA", "p-value vs #tilde{#chi^{2}}; p-value; #tilde{#chi^{2}}", {HistType::kTH2F, {{100, 0, 1}, {100, 0, 5}}}); + registry.add("h2_PChi2_CombinFitB", "p-value vs #tilde{#chi^{2}}; p-value; #tilde{#chi^{2}}", {HistType::kTH2F, {{100, 0, 1}, {100, 0, 5}}}); + + registry.add("h_evtnum_NTrk", "eventNumber vs Number of Track ; #eventNumber", {HistType::kTH1F, {{1000, 0.0, 1000}}}); + + registry.add("h_v2obs_centrality", "fitparameter v2obs vs centrality ; #centrality", {HistType::kTProfile, {cfgAxisVnCent}}); + registry.add("h_v3obs_centrality", "fitparameter v3obs vs centrality ; #centrality", {HistType::kTProfile, {cfgAxisVnCent}}); + registry.add("h_fitparaRho_evtnum", "fitparameter #rho_{0} vs evtnum ; #eventnumber", {HistType::kTH1F, {{1000, 0.0, 1000}}}); + registry.add("h_fitparaPsi2_evtnum", "fitparameter #Psi_{2} vs evtnum ; #eventnumber", {HistType::kTH1F, {{1000, 0.0, 1000}}}); + registry.add("h_fitparaPsi3_evtnum", "fitparameter #Psi_{3} vs evtnum ; #eventnumber", {HistType::kTH1F, {{1000, 0.0, 1000}}}); + registry.add("h_evtnum_centrlity", "eventNumber vs centrality ; #eventNumber", {HistType::kTH1F, {{1000, 0.0, 1000}}}); + + registry.add("h2_phi_rholocal", "#varphi vs #rho(#varphi); #varphi - #Psi_{EP,2}; #rho(#varphi) ", {HistType::kTH2F, {{40, 0., o2::constants::math::TwoPI}, {210, -10.0, 200.0}}}); + registry.add("h2_rholocal_cent", "#varphi vs #rho(#varphi); #cent; #rho(#varphi) ", {HistType::kTH2F, {{100, 0., 100}, {210, -10.0, 200.0}}}); + //< \sigma p_T at local rho test plot | end > + + registry.add("h_jet_pt_rhoareasubtracted", "jet pT rhoareasubtracted;#it{p}_{T,jet} (GeV/#it{c}); entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + + registry.add("leadJetPt", "leadJet Pt ", {HistType::kTH1F, {{200, 0., 200.0}}}); + registry.add("leadJetPhi", "leadJet constituent #phi ", {HistType::kTH1F, {{80, -1.0, 7.}}}); + registry.add("leadJetEta", "leadJet constituent #eta ", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + + //< RC test plots >// + registry.add("h3_centrality_deltapT_RandomCornPhi_rhorandomconewithoutleadingjet", "centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho}; #Delta#varphi_{jet}", {HistType::kTH3F, {{100, 0.0, 100.0}, {400, -200.0, 200.0}, {100, 0., o2::constants::math::TwoPI}}}); + registry.add("h3_centrality_deltapT_RandomCornPhi_localrhovsphi", "centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho}; #Delta#varphi_{jet}", {HistType::kTH3F, {{100, 0.0, 100.0}, {400, -200.0, 200.0}, {100, 0., o2::constants::math::TwoPI}}}); + + registry.add("h3_centrality_deltapT_RandomCornPhi_localrhovsphiwithoutleadingjet", "centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho}(#varphi); #Delta#varphi_{jet}", {HistType::kTH3F, {{100, 0.0, 100.0}, {400, -200.0, 200.0}, {100, 0., o2::constants::math::TwoPI}}}); + //< bkg sub plot | end >// + //< median rho >// + registry.add("h_jet_pt_in_plane_v2", "jet pT;#it{p}^{in-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_pt_out_of_plane_v2", "jet pT;#it{p}^{out-of-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_pt_in_plane_v3", "jet pT;#it{p}^{in-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_pt_out_of_plane_v3", "jet pT;#it{p}^{out-of-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + + registry.add("h2_centrality_jet_pt_in_plane_v2", "centrality vs #it{p}^{in-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + registry.add("h2_centrality_jet_pt_out_of_plane_v2", "centrality vs #it{p}^{out-of-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + //< rho(phi) >// + registry.add("h_jet_pt_inclusive_v2_rho", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_pt_in_plane_v2_rho", "jet pT;#it{p}^{in-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_pt_out_of_plane_v2_rho", "jet pT;#it{p}^{out-of-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_pt_in_plane_v3_rho", "jet pT;#it{p}^{in-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_pt_out_of_plane_v3_rho", "jet pT;#it{p}^{out-of-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + + registry.add("h2_centrality_jet_pt_in_plane_v2_rho", "centrality vs #it{p}^{in-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + registry.add("h2_centrality_jet_pt_out_of_plane_v2_rho", "centrality vs #it{p}^{out-of-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + + registry.add("h2_centrality_jet_pt_rhoareasubtracted", "centrality vs. jet pT;centrality; #it{p}_{T,jet} (GeV/#it{c}); counts", {HistType::kTH2F, {centralityAxis, jetPtAxisRhoAreaSub}}); + registry.add("h2_centrality_jet_eta_rhoareasubtracted", "centrality vs. jet eta;centrality; #eta; counts", {HistType::kTH2F, {centralityAxis, jetEtaAxis}}); + registry.add("h2_centrality_jet_phi_rhoareasubtracted", "centrality vs. jet phi;centrality; #varphi; counts", {HistType::kTH2F, {centralityAxis, phiAxis}}); + registry.add("h2_jet_pt_track_pt_rhoareasubtracted", "jet #it{p}_{T,jet} vs. #it{p}_{T,track}; #it{p}_{T,jet} (GeV/#it{c}); #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, trackPtAxis}}); + } - //< \sigma p_T at local rho test plot | end > + if (doprocessSigmaPtMCP) { + registry.add("h_jet_pt_part_rhoareasubtracted", "part jet corr pT;#it{p}_{T,jet}^{part} (GeV/#it{c}); counts", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_eta_part_rhoareasubtracted", "part jet #eta;#eta^{part}; counts", {HistType::kTH1F, {jetEtaAxis}}); + registry.add("h_jet_phi_part_rhoareasubtracted", "part jet #varphi;#varphi^{part}; counts", {HistType::kTH1F, {phiAxis}}); + + registry.add("leadJetPtMCP", "MCP leadJet Pt ", {HistType::kTH1F, {{200, 0., 200.0}}}); + registry.add("leadJetPhiMCP", "MCP leadJet constituent #phi ", {HistType::kTH1F, {{80, -1.0, 7.}}}); + registry.add("leadJetEtaMCP", "MCP leadJet constituent #eta ", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + + registry.add("h2_mcp_phi_rholocal", "#varphi vs #rho(#varphi); #varphi - #Psi_{EP,2}; #rho(#varphi) ", {HistType::kTH2F, {{40, 0., o2::constants::math::TwoPI}, {210, -10.0, 200.0}}}); + registry.add("h2_mcp_centrality_rholocal", "#varphi vs #rho(#varphi); #varphi - #Psi_{EP,2}; #rho(#varphi) ", {HistType::kTH2F, {{120, -10.0, 110.0}, {210, -10.0, 200.0}}}); + registry.add("h_mcp_jet_pt_rholocal", "jet pT rholocal;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + //< MCP fit test >// + registry.add("h_mcp_evtnum_centrlity", "eventNumber vs centrality ; #eventNumber", {HistType::kTH1F, {{1000, 0.0, 1000}}}); + registry.add("h_mcp_v2obs_centrality", "fitparameter v2obs vs centrality ; #centrality", {HistType::kTProfile, {cfgAxisVnCent}}); + registry.add("h_mcp_v3obs_centrality", "fitparameter v3obs vs centrality ; #centrality", {HistType::kTProfile, {cfgAxisVnCent}}); + registry.add("h_mcp_fitparaRho_evtnum", "fitparameter #rho_{0} vs evtnum ; #eventnumber", {HistType::kTH1F, {{1000, 0.0, 1000}}}); + registry.add("h_mcp_fitparaPsi2_evtnum", "fitparameter #Psi_{2} vs evtnum ; #eventnumber", {HistType::kTH1F, {{1000, 0.0, 1000}}}); + registry.add("h_mcp_fitparaPsi3_evtnum", "fitparameter #Psi_{3} vs evtnum ; #eventnumber", {HistType::kTH1F, {{1000, 0.0, 1000}}}); + + registry.add("h_mcp_jet_pt_in_plane_v2_rho", "jet pT;#it{p}^{in-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_mcp_jet_pt_out_of_plane_v2_rho", "jet pT;#it{p}^{out-of-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_mcp_jet_pt_in_plane_v3_rho", "jet pT;#it{p}^{in-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_mcp_jet_pt_out_of_plane_v3_rho", "jet pT;#it{p}^{out-of-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + + registry.add("h2_mcp_centrality_jet_pt_in_plane_v2_rho", "centrality vs #it{p}^{in-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + registry.add("h2_mcp_centrality_jet_pt_out_of_plane_v2_rho", "centrality vs #it{p}^{out-of-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + registry.add("h2_mcp_centrality_jet_pt_in_plane_v3_rho", "centrality vs #it{p}^{in-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + registry.add("h2_mcp_centrality_jet_pt_out_of_plane_v3_rho", "centrality vs #it{p}^{out-of-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + + registry.add("h3_mcp_centrality_deltapT_RandomCornPhi_localrhovsphi", "centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho}; #Delta#varphi_{jet}", {HistType::kTH3F, {{100, 0.0, 100.0}, {400, -200.0, 200.0}, {100, 0., o2::constants::math::TwoPI}}}); + registry.add("h3_mcp_centrality_deltapT_RandomCornPhi_rhorandomconewithoutleadingjet", "centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho}; #Delta#varphi_{jet}", {HistType::kTH3F, {{100, 0.0, 100.0}, {400, -200.0, 200.0}, {100, 0., o2::constants::math::TwoPI}}}); + registry.add("h3_mcp_centrality_deltapT_RandomCornPhi_localrhovsphiwithoutleadingjet", "centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho}(#varphi); #Delta#varphi_{jet}", {HistType::kTH3F, {{100, 0.0, 100.0}, {400, -200.0, 200.0}, {100, 0., o2::constants::math::TwoPI}}}); + + registry.add("h_mcColl_counts_areasub", " number of mc events; event status; entries", {HistType::kTH1F, {{10, 0, 10}}}); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(1, "allMcColl"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(2, "vertexZ"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(3, "noRecoColl"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(4, "splitColl"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(5, "recoEvtSel"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(6, "centralitycut"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(7, "occupancycut"); + registry.add("h_mcColl_rho", "mc collision rho;#rho (GeV/#it{c}); counts", {HistType::kTH1F, {{500, 0.0, 500.0}}}); + + //< \sigma p_T at local rho test plot > + registry.add("h_accept_Track", "all and accept track;Track;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(1, "acceptTrk"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(2, "acceptTrkInFit"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(3, "beforeSumptFit"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(4, "afterSumptFit"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(5, "getNtrk"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(6, "getNtrkMCP"); + } - registry.add("h2_centrality_collisions", "centrality vs collisions; centrality; collisions", {HistType::kTH2F, {{1200, -10.0, 110.0}, {4, 0.0, 4.0}}}); - registry.add("h2_centrality_track_pt", "centrality vs track pT; centrality; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, 0., 200.}}}); - registry.add("h2_centrality_track_eta", "centrality vs track #eta; centrality; #eta_{track}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, -1.0, 1.0}}}); - registry.add("h2_centrality_track_phi", "centrality vs track #varphi; centrality; #varphi_{track}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); + if (doprocessJetsMatchedSubtracted) { + registry.add("h_mc_collisions_matched", "mc collisions status;event status;entries", {HistType::kTH1F, {{5, 0.0, 5.0}}}); + registry.add("h_mcd_events_matched", "mcd event status;event status;entries", {HistType::kTH1F, {{6, 0.0, 6.0}}}); + registry.add("h_mc_rho_matched", "mc collision rho;#rho (GeV/#it{c}); counts", {HistType::kTH1F, {{500, -100.0, 500.0}}}); + registry.add("h_accept_Track_Match", "all and accept track;Track;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_in_rhoareasubtracted_mcdetaconstraint", "corr pT mcd vs. corr cpT mcp in-plane;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, jetPtAxisRhoAreaSub}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_in_rhoareasubtracted_mcpetaconstraint", "corr pT mcd vs. corr cpT mcp in-plane;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, jetPtAxisRhoAreaSub}}); + registry.add("h2_jet_pt_mcp_jet_pt_diff_matchedgeo_in_rhoareasubtracted", "jet mcp corr pT vs. corr delta pT / jet mcp corr pt in-plane;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); (#it{p}_{T,jet}^{mcp} (GeV/#it{c}) - #it{p}_{T,jet}^{mcd} (GeV/#it{c})) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {1000, -5.0, 5.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_diff_matchedgeo_in_rhoareasubtracted", "jet mcd corr pT vs. corr delta pT / jet mcd corr pt in-plane;#it{p}_{T,jet}^{mcd} (GeV/#it{c}); (#it{p}_{T,jet}^{mcd} (GeV/#it{c}) - #it{p}_{T,jet}^{mcp} (GeV/#it{c})) / #it{p}_{T,jet}^{mcd} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {1000, -5.0, 5.0}}}); + registry.add("h2_jet_pt_mcp_jet_pt_ratio_matchedgeo_in_rhoareasubtracted", "jet mcp corr pT vs. jet mcd corr pT / jet mcp corr pt in-plane;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); #it{p}_{T,jet}^{mcd} (GeV/#it{c}) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {1000, -5.0, 5.0}}}); + + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_out_rhoareasubtracted_mcdetaconstraint", "corr pT mcd vs. corr cpT mcp out-of-plane;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, jetPtAxisRhoAreaSub}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_out_rhoareasubtracted_mcpetaconstraint", "corr pT mcd vs. corr cpT mcp out-of-plane;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, jetPtAxisRhoAreaSub}}); + registry.add("h2_jet_pt_mcp_jet_pt_diff_matchedgeo_out_rhoareasubtracted", "jet mcp corr pT vs. corr delta pT / jet mcp corr pt out-of-plane;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); (#it{p}_{T,jet}^{mcp} (GeV/#it{c}) - #it{p}_{T,jet}^{mcd} (GeV/#it{c})) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {1000, -5.0, 5.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_diff_matchedgeo_out_rhoareasubtracted", "jet mcd corr pT vs. corr delta pT / jet mcd corr pt out-of-plane;#it{p}_{T,jet}^{mcd} (GeV/#it{c}); (#it{p}_{T,jet}^{mcd} (GeV/#it{c}) - #it{p}_{T,jet}^{mcp} (GeV/#it{c})) / #it{p}_{T,jet}^{mcd} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {1000, -5.0, 5.0}}}); + registry.add("h2_jet_pt_mcp_jet_pt_ratio_matchedgeo_out_rhoareasubtracted", "jet mcp corr pT vs. jet mcd corr pT / jet mcp corr pt out-of-plane;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); #it{p}_{T,jet}^{mcd} (GeV/#it{c}) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {1000, -5.0, 5.0}}}); + } - registry.add("h_jet_pt_rhoareasubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_accept_Track", "all and accept track;Track;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(1, "acceptTrk"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(2, "acceptTrkInFit"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(3, "beforeSumptFit"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(4, "afterSumptFit"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(5, "getNtrk"); + registry.get(HIST("h_accept_Track"))->GetXaxis()->SetBinLabel(6, "getNtrkMCP"); + + //< track test >// + registry.add("h_track_pt", "track #it{p}_{T} ; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH1F, {trackPtAxis}}); + registry.add("h2_track_eta_track_phi", "track eta vs. track phi; #eta; #phi; counts", {HistType::kTH2F, {trackEtaAxis, phiAxis}}); + } + Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); + Preslice tracksPerJCollision = o2::aod::jtrack::collisionId; + Preslice mcdjetsPerJCollision = o2::aod::jet::collisionId; + PresliceUnsorted> collisionsPerMCPCollision = aod::jmccollisionlb::mcCollisionId; - registry.add("h_recoil_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_recoil_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); - registry.add("h_recoil_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); - registry.add("h_recoil_jet_dphi", "hadron-jet #Delta#phi;#Delta#phi_{jet,trigger hadron};entries", {HistType::kTH1F, {{40, -2.0, 2.0}}}); + template + bool isAcceptedJet(TJets const& jet, bool mcLevelIsParticleLevel = false) + { + double jetAreaFractionMinAcc = -98.0; + double leadingConstituentPtMinAcc = -98.0; + double leadingConstituentPtMaxAcc = 9998.0; + if (jetAreaFractionMin > jetAreaFractionMinAcc) { + if (jet.area() < jetAreaFractionMin * o2::constants::math::PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { + return false; + } + } + bool checkConstituentPt = true; + bool checkConstituentMinPt = (leadingConstituentPtMin > leadingConstituentPtMinAcc); + bool checkConstituentMaxPt = (leadingConstituentPtMax < leadingConstituentPtMaxAcc); + if (!checkConstituentMinPt && !checkConstituentMaxPt) { + checkConstituentPt = false; + } + if (mcLevelIsParticleLevel && !checkLeadConstituentPtForMcpJets) { + checkConstituentPt = false; + } - registry.add("leadJetPt", "leadJet Pt ", {HistType::kTH1F, {{200, 0., 200.0}}}); - registry.add("leadJetPhi", "leadJet constituent #phi ", {HistType::kTH1F, {{80, -1.0, 7.}}}); - registry.add("leadJetEta", "leadJet constituent #eta ", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + if (checkConstituentPt) { + bool isMinLeadingConstituent = !checkConstituentMinPt; + bool isMaxLeadingConstituent = true; - //< RC test plots >// - registry.add("h3_centrality_RCpt_RandomCornPhi_rhorandomcone", "centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho}; #Delta#varphi_{jet}", {HistType::kTH3F, {{120, -10.0, 110.0}, {800, -400.0, 400.0}, {160, 0., TMath::TwoPi()}}}); - registry.add("h3_centrality_RCpt_RandomCornPhi_rhorandomconewithoutleadingjet", "centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho}; #Delta#varphi_{jet}", {HistType::kTH3F, {{120, -10.0, 110.0}, {800, -400.0, 400.0}, {160, 0., TMath::TwoPi()}}}); - //< bkg sub plot | end >// + for (const auto& constituent : jet.template tracks_as()) { + double pt = constituent.pt(); - registry.add("h_jet_pt_in_out_plane_v2", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); - registry.add("h_jet_pt_in_plane_v2", "jet pT;#it{p}^{in-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); - registry.add("h_jet_pt_out_of_plane_v2", "jet pT;#it{p}^{out-of-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); - registry.add("h_jet_pt_in_plane_v3", "jet pT;#it{p}^{in-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); - registry.add("h_jet_pt_out_of_plane_v3", "jet pT;#it{p}^{out-of-plane}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + if (checkConstituentMinPt && pt >= leadingConstituentPtMin) { + isMinLeadingConstituent = true; + } + if (checkConstituentMaxPt && pt > leadingConstituentPtMax) { + isMaxLeadingConstituent = false; + } + } + return isMinLeadingConstituent && isMaxLeadingConstituent; + } + return true; + } - registry.add("h2_centrality_jet_pt_in_plane_v2", "centrality vs #it{p}^{in-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); - registry.add("h2_centrality_jet_pt_out_of_plane_v2", "centrality vs #it{p}^{out-of-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); - registry.add("h2_centrality_jet_pt_in_plane_v3", "centrality vs #it{p}^{in-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); - registry.add("h2_centrality_jet_pt_out_of_plane_v3", "centrality vs #it{p}^{out-of-plane}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{120, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); - //< bkg sub DeltaPhi plot | end >// + double chiSquareCDF(int nDF, double x) + { + return TMath::Gamma(nDF / 2., x / 2.); + } - //=====================< evt pln plot >=====================// - AxisSpec axisCent{cfgaxisCent, "centrality"}; - AxisSpec axisQvec{cfgaxisQvec, "Q"}; - AxisSpec axisQvecF{cfgaxisQvecF, "Q"}; + // leading jet fill + template + void fillLeadingJetQA(T const& jets, double& leadingJetPt, double& leadingJetPhi, double& leadingJetEta) + { + for (const auto& jet : jets) { + if (jet.pt() > leadingJetPt) { + leadingJetPt = jet.pt(); + leadingJetEta = jet.eta(); + leadingJetPhi = jet.phi(); + } + } + registry.fill(HIST("leadJetPt"), leadingJetPt); + registry.fill(HIST("leadJetPhi"), leadingJetPhi); + registry.fill(HIST("leadJetEta"), leadingJetEta); + } - AxisSpec axisEvtPl{360, -constants::math::PI, constants::math::PI}; + // create h_ptsum_sumpt_fit, with number of Track + template + void getNtrk(T const& tracks, U const& jets, int& nTrk, double& evtnum, double& leadingJetEta) + { + if (jets.size() > 0) { + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > jetRadius) && track.pt() >= localRhoFitPtMin && track.pt() <= localRhoFitPtMax) { + registry.fill(HIST("h_accept_Track"), 4.5); + nTrk += 1; + } + } + registry.fill(HIST("h_evtnum_NTrk"), evtnum, nTrk); + } + } - histosQA.add("histCent", "Centrality TrkProcess", HistType::kTH1F, {axisCent}); - histosQA.add("histCentTrkProcess_aftersel", "Centrality TrkProcess aft_sel", HistType::kTH1F, {axisCent}); + // fill nTrk plot for fit rho(varphi) + template + void fillNtrkCheck(U const& tracks, J const& jets, TH1F* hPtsumSumptFit, double& leadingJetEta) + { + if (jets.size() > 0) { + for (auto const& trackfit : tracks) { + registry.fill(HIST("h_accept_Track"), 0.5); + if (jetderiveddatautilities::selectTrack(trackfit, trackSelection) && (std::fabs(trackfit.eta() - leadingJetEta) > jetRadius) && trackfit.pt() >= localRhoFitPtMin && trackfit.pt() <= localRhoFitPtMax) { + registry.fill(HIST("h_accept_Track"), 1.5); + } + } - for (uint i = 0; i < cfgnMods->size(); i++) { - histosQA.add(Form("histQvecUncorV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); - histosQA.add(Form("histQvecRectrV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); - histosQA.add(Form("histQvecTwistV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); - histosQA.add(Form("histQvecFinalV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvec, axisQvec, axisCent}}); + for (auto const& track : tracks) { + registry.fill(HIST("h_accept_Track"), 2.5); + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > jetRadius) && track.pt() >= localRhoFitPtMin && track.pt() <= localRhoFitPtMax) { + registry.fill(HIST("h_accept_Track"), 3.5); + hPtsumSumptFit->Fill(track.phi(), track.pt()); + } + } + } + } - histosQA.add(Form("histEvtPlUncorV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); - histosQA.add(Form("histEvtPlRectrV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); - histosQA.add(Form("histEvtPlTwistV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); - histosQA.add(Form("histEvtPlFinalV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + // MCP leading jet fill + template + void fillLeadingJetQAMCP(T const& jets, double& leadingJetPt, double& leadingJetPhi, double& leadingJetEta) + { + for (const auto& jet : jets) { + if (jet.pt() > leadingJetPt) { + leadingJetPt = jet.pt(); + leadingJetEta = jet.eta(); + leadingJetPhi = jet.phi(); + } } - //=====================< evt pln plot | end >=====================// + registry.fill(HIST("leadJetPtMCP"), leadingJetPt); + registry.fill(HIST("leadJetPhiMCP"), leadingJetPhi); + registry.fill(HIST("leadJetEtaMCP"), leadingJetEta); } - Preslice JetsPerJCollision = aod::jet::collisionId; - Preslice tracksPerJCollision = o2::aod::jtrack::collisionId; + template + void fitFncMCP(U const& collision, T const& tracks, J const& jets, TH1F* hPtsumSumptFitMCP, double leadingJetEta, bool mcLevelIsParticleLevel, float weight = 1.0) + { + double ep2 = 0.; + double ep3 = 0.; + int cfgNmodA = 2; + int cfgNmodB = 3; + int evtPlnAngleA = 7; + int evtPlnAngleB = 3; + int evtPlnAngleC = 5; + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + if (nmode == cfgNmodA) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId) { + ep2 = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); + } + } else if (nmode == cfgNmodB) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId) { + ep3 = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); + } + } + } + + const char* fitFunctionV2v3P = "[0] * (1. + 2. * ([1] * std::cos(2. * (x - [2])) + [3] * std::cos(3. * (x - [4]))))"; + fFitModulationV2v3P = new TF1("fit_kV3", fitFunctionV2v3P, 0, o2::constants::math::TwoPI); + //=========================< set parameter >=========================// + fFitModulationV2v3P->SetParameter(0, 1.); + fFitModulationV2v3P->SetParameter(1, 0.01); + fFitModulationV2v3P->SetParameter(3, 0.01); - Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); - Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + double ep2fix = 0.; + double ep3fix = 0.; - template - bool isAcceptedJet(U const& jet) - { - if (jetAreaFractionMin > -98.0) { - if (jet.area() < jetAreaFractionMin * M_PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { - return false; + if (ep2 < 0) { + ep2fix = RecoDecay::constrainAngle(ep2); + fFitModulationV2v3P->FixParameter(2, ep2fix); + } else { + fFitModulationV2v3P->FixParameter(2, ep2); + } + if (ep3 < 0) { + ep3fix = RecoDecay::constrainAngle(ep3); + fFitModulationV2v3P->FixParameter(4, ep3fix); + } else { + fFitModulationV2v3P->FixParameter(4, ep3); + } + + hPtsumSumptFitMCP->Fit(fFitModulationV2v3P, "Q", "ep", 0, o2::constants::math::TwoPI); + + // int paraNum = 5; + double temppara[5]; + temppara[0] = fFitModulationV2v3P->GetParameter(0); + temppara[1] = fFitModulationV2v3P->GetParameter(1); + temppara[2] = fFitModulationV2v3P->GetParameter(2); + temppara[3] = fFitModulationV2v3P->GetParameter(3); + temppara[4] = fFitModulationV2v3P->GetParameter(4); + if (temppara[0] == 0) { + return; + } + registry.fill(HIST("h_mcp_fitparaRho_evtnum"), evtnum, temppara[0]); + registry.fill(HIST("h_mcp_fitparaPsi2_evtnum"), evtnum, temppara[2]); + registry.fill(HIST("h_mcp_fitparaPsi3_evtnum"), evtnum, temppara[4]); + registry.fill(HIST("h_mcp_v2obs_centrality"), collision.centFT0M(), temppara[1]); + registry.fill(HIST("h_mcp_v3obs_centrality"), collision.centFT0M(), temppara[3]); + registry.fill(HIST("h_mcp_evtnum_centrlity"), evtnum, collision.centFT0M()); + + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet, mcLevelIsParticleLevel)) { + continue; + } + if (jet.r() != round(selectedJetsRadius * 100.0f)) { + continue; + } + + double integralValue = fFitModulationV2v3P->Integral(jet.phi() - jetRadius, jet.phi() + jetRadius); + double rholocal = collision.rho() / (2 * jetRadius * temppara[0]) * integralValue; + registry.fill(HIST("h2_mcp_phi_rholocal"), jet.phi() - ep2, rholocal, weight); + registry.fill(HIST("h2_mcp_centrality_rholocal"), collision.centFT0M(), rholocal, weight); + if (nmode == cfgNmodA) { + registry.fill(HIST("h_mcp_jet_pt_rholocal"), jet.pt() - (rholocal * jet.area()), weight); + + double phiMinusPsi2; + if (collision.qvecAmp()[detId] < collQvecAmpDetId) { + continue; + } + phiMinusPsi2 = jet.phi() - ep2; + if ((phiMinusPsi2 < o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi2 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h_mcp_jet_pt_in_plane_v2_rho"), jet.pt() - (rholocal * jet.area()), weight); + registry.fill(HIST("h2_mcp_centrality_jet_pt_in_plane_v2_rho"), collision.centFT0M(), jet.pt() - (rholocal * jet.area()), weight); + } else { + registry.fill(HIST("h_mcp_jet_pt_out_of_plane_v2_rho"), jet.pt() - (rholocal * jet.area()), weight); + registry.fill(HIST("h2_mcp_centrality_jet_pt_out_of_plane_v2_rho"), collision.centFT0M(), jet.pt() - (rholocal * jet.area()), weight); + } + } else if (nmode == cfgNmodB) { + double phiMinusPsi3; + if (collision.qvecAmp()[detId] < collQvecAmpDetId) { + continue; + } + ep3 = helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode); + phiMinusPsi3 = jet.phi() - ep3; + + if ((phiMinusPsi3 < o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi3 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h_mcp_jet_pt_in_plane_v3_rho"), jet.pt() - (rholocal * jet.area()), weight); + registry.fill(HIST("h2_mcp_centrality_jet_pt_in_plane_v3_rho"), collision.centFT0M(), jet.pt() - (rholocal * jet.area()), weight); + } else { + registry.fill(HIST("h_mcp_jet_pt_out_of_plane_v3_rho"), jet.pt() - (rholocal * jet.area()), weight); + registry.fill(HIST("h2_mcp_centrality_jet_pt_out_of_plane_v3_rho"), collision.centFT0M(), jet.pt() - (rholocal * jet.area()), weight); + } + } } } - if (leadingConstituentPtMin > -98.0) { - bool isMinleadingConstituent = false; - for (auto& constituent : jet.template tracks_as()) { - if (constituent.pt() >= leadingConstituentPtMin) { - isMinleadingConstituent = true; - break; + // RCpT + for (uint i = 0; i < cfgnMods->size(); i++) { + TRandom3 randomNumber(0); + float randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); + float randomConePhi = randomNumber.Uniform(0.0, o2::constants::math::TwoPI); + float randomConePt = 0; + double integralValueRC = fFitModulationV2v3P->Integral(randomConePhi - randomConeR, randomConePhi + randomConeR); + double rholocalRC = collision.rho() / (2 * randomConeR * temppara[0]) * integralValueRC; + + int nmode = cfgnMods->at(i); + if (nmode == cfgNmodA) { + double rcPhiPsi2; + rcPhiPsi2 = randomConePhi - ep2; + + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection)) { + float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + float dEta = track.eta() - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + randomConePt += track.pt(); + } + } + } + registry.fill(HIST("h3_mcp_centrality_deltapT_RandomCornPhi_localrhovsphi"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * rholocalRC, rcPhiPsi2, weight); + + // removing the leading jet from the random cone + if (jets.size() > 0) { // if there are no jets in the acceptance (from the jetfinder cuts) then there can be no leading jet + float dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + float dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + + bool jetWasInCone = false; + while ((randomConeLeadJetDeltaR <= 0 && (std::sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < jets.iteratorAt(0).r() / 100.0 + randomConeR)) || (randomConeLeadJetDeltaR > 0 && (std::sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < randomConeLeadJetDeltaR))) { + jetWasInCone = true; + randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); + randomConePhi = randomNumber.Uniform(0.0, o2::constants::math::TwoPI); + dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + } + if (jetWasInCone) { + randomConePt = 0.0; + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > randomConeR)) { // if track selection is uniformTrack, dcaXY and dcaZ cuts need to be added as they aren't in the selection so that they can be studied here + float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + float dEta = track.eta() - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + randomConePt += track.pt(); + } + } + } + } } + registry.fill(HIST("h3_mcp_centrality_deltapT_RandomCornPhi_localrhovsphiwithoutleadingjet"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * rholocalRC, rcPhiPsi2, weight); + registry.fill(HIST("h3_mcp_centrality_deltapT_RandomCornPhi_rhorandomconewithoutleadingjet"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * collision.rho(), rcPhiPsi2, weight); + } else if (nmode == cfgNmodB) { + continue; } - if (!isMinleadingConstituent) { - return false; + } + } + + template + void fillMCPAreaSubHistograms(TJets const& jet, float rho = 0.0, float weight = 1.0) + { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { + return; + } + if (jet.r() == round(selectedJetsRadius * 100.0f)) { + // fill mcp jet histograms + double jetcorrpt = jet.pt() - (rho * jet.area()); + registry.fill(HIST("h_jet_pt_part_rhoareasubtracted"), jetcorrpt, weight); + if (jetcorrpt > 0) { + registry.fill(HIST("h_jet_eta_part_rhoareasubtracted"), jet.eta(), weight); + registry.fill(HIST("h_jet_phi_part_rhoareasubtracted"), jet.phi(), weight); } } - return true; } - void fillLeadingJetQA(double leadingJetPt, double leadingJetPhi, double leadingJetEta) + template + void fillTrackHistograms(TTracks const& track, float weight = 1.0) { - registry.fill(HIST("leadJetPt"), leadingJetPt); - registry.fill(HIST("leadJetPhi"), leadingJetPhi); - registry.fill(HIST("leadJetEta"), leadingJetEta); - } // end of fillLeadingJetQA template + registry.fill(HIST("h_track_pt"), track.pt(), weight); + registry.fill(HIST("h2_track_eta_track_phi"), track.eta(), track.phi(), weight); + } - void processjetQA(soa::Filtered>::iterator const& collision, - soa::Join const& jets, - aod::JetTracks const& tracks) + template + void fillGeoMatchedCorrHistograms(TBase const& jetMCD, TF1* fFitModulationRM, float tempparaA, double ep2, float rho, float mcrho = 0.0, float weight = 1.0) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (jetMCD.pt() > pTHatMaxMCD * pTHat) { return; } - double leadingTrackpT = 0.0; - double leadingTrackPhi = 0.0; - for (auto const& track : tracks) { - if (track.pt() > 6.0 && track.pt() < 10.0) { - if (track.pt() > leadingTrackpT) { - leadingTrackpT = track.pt(); - leadingTrackPhi = track.phi(); + if (jetMCD.has_matchedJetGeo()) { + for (const auto& jetMCP : jetMCD.template matchedJetGeo_as>()) { + if (jetMCP.pt() > pTHatMaxMCD * pTHat) { + continue; + } + if (jetMCD.r() == round(selectedJetsRadius * 100.0f)) { + int evtPlnAngleA = 7; + int evtPlnAngleB = 3; + int evtPlnAngleC = 5; + double integralValue = fFitModulationRM->Integral(jetMCD.phi() - jetRadius, jetMCD.phi() + jetRadius); + double rholocal = rho / (2 * jetRadius * tempparaA) * integralValue; + double corrTagjetpt = jetMCP.pt() - (mcrho * jetMCP.area()); + double corrBasejetpt = jetMCD.pt() - (rholocal * jetMCD.area()); + double dcorrpt = corrTagjetpt - corrBasejetpt; + double phiMinusPsi2 = jetMCD.phi() - ep2; + if (jetfindingutilities::isInEtaAcceptance(jetMCD, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + if ((phiMinusPsi2 < o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi2 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_in_rhoareasubtracted_mcdetaconstraint"), corrBasejetpt, corrTagjetpt, weight); + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_diff_matchedgeo_in_rhoareasubtracted"), corrBasejetpt, dcorrpt / corrBasejetpt, weight); + } else { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_out_rhoareasubtracted_mcdetaconstraint"), corrBasejetpt, corrTagjetpt, weight); + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_diff_matchedgeo_out_rhoareasubtracted"), corrBasejetpt, dcorrpt / corrBasejetpt, weight); + } + } + if (jetfindingutilities::isInEtaAcceptance(jetMCP, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + if ((phiMinusPsi2 < o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi2 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_in_rhoareasubtracted_mcpetaconstraint"), corrBasejetpt, corrTagjetpt, weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_diff_matchedgeo_in_rhoareasubtracted"), corrTagjetpt, dcorrpt / corrTagjetpt, weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_ratio_matchedgeo_in_rhoareasubtracted"), corrTagjetpt, corrBasejetpt / corrTagjetpt, weight); + } else { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_out_rhoareasubtracted_mcpetaconstraint"), corrBasejetpt, corrTagjetpt, weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_diff_matchedgeo_out_rhoareasubtracted"), corrTagjetpt, dcorrpt / corrTagjetpt, weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_ratio_matchedgeo_out_rhoareasubtracted"), corrTagjetpt, corrBasejetpt / corrTagjetpt, weight); + } + } } - } - } - if (leadingTrackpT == 0.0) - return; - for (auto& jet : jets) { - if (TMath::Abs(RecoDecay::constrainAngle(RecoDecay::constrainAngle(jet.phi(), -o2::constants::math::PIHalf) - RecoDecay::constrainAngle(leadingTrackPhi, -o2::constants::math::PIHalf), -o2::constants::math::PIHalf) > 0.6)) { - registry.fill(HIST("h_recoil_jet_pt"), jet.pt()); - registry.fill(HIST("h_recoil_jet_eta"), jet.eta()); - registry.fill(HIST("h_recoil_jet_phi"), jet.phi()); - registry.fill(HIST("h_recoil_jet_dphi"), jet.phi() - leadingTrackPhi); } } } - PROCESS_SWITCH(Jetchargedv2Task, processjetQA, "jet rho v2 jet QA", true); + //=======================================[ process area ]=============================================// void processInOutJetV2(soa::Filtered>::iterator const& collision, soa::Join const& jets, aod::JetTracks const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } + //=====================< evt pln [n=2->\Psi_2, n=3->\Psi_3] >=====================// + histosQA.fill(HIST("histCent"), collision.cent()); + //=====================< evt pln [n=2->\Psi_2, n=3->\Psi_3] >=====================// + int cfgNmodA = 2; + int cfgNmodB = 3; + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + int refAInd = refAId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + int refBInd = refBId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + + if (nmode == cfgNmodA) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId || collision.qvecAmp()[refAId] < collQvecAmpDetId || collision.qvecAmp()[refBId] < collQvecAmpDetId) { + histosQA.fill(HIST("histQvecUncorV2"), collision.qvecRe()[detInd], collision.qvecIm()[detInd], collision.cent()); + histosQA.fill(HIST("histQvecRectrV2"), collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], collision.cent()); + histosQA.fill(HIST("histQvecTwistV2"), collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], collision.cent()); + histosQA.fill(HIST("histQvecFinalV2"), collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], collision.cent()); + + histosQA.fill(HIST("histEvtPlUncorV2"), helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRectrV2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlTwistV2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlFinalV2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), collision.cent()); + + histosQA.fill(HIST("histEvtPlRes_SigRefAV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRes_SigRefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRes_RefARefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.cent()); + } + } else if (nmode == cfgNmodB) { + histosQA.fill(HIST("histQvecUncorV3"), collision.qvecRe()[detInd], collision.qvecIm()[detInd], collision.cent()); + histosQA.fill(HIST("histQvecRectrV3"), collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], collision.cent()); + histosQA.fill(HIST("histQvecTwistV3"), collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], collision.cent()); + histosQA.fill(HIST("histQvecFinalV3"), collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], collision.cent()); + + histosQA.fill(HIST("histEvtPlUncorV3"), helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRectrV3"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlTwistV3"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlFinalV3"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), collision.cent()); + + histosQA.fill(HIST("histEvtPlRes_SigRefAV3"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRes_SigRefBV3"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRes_RefARefBV3"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.cent()); + } + } + + int evtPlnAngleA = 7; + int evtPlnAngleB = 3; + int evtPlnAngleC = 5; + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + + if (nmode == cfgNmodA) { + double phiMinusPsi2; + if (collision.qvecAmp()[detId] < collQvecAmpDetId) { + continue; + } + float ep2 = helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode); + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + if (jet.r() != round(selectedJetsRadius * 100.0f)) { + continue; + } + registry.fill(HIST("h_jet_pt_rhoareasubtracted"), jet.pt() - (collision.rho() * jet.area()), 1.0); + + phiMinusPsi2 = jet.phi() - ep2; + if ((phiMinusPsi2 < o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi2 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h_jet_pt_in_plane_v2"), jet.pt() - (collision.rho() * jet.area()), 1.0); + registry.fill(HIST("h2_centrality_jet_pt_in_plane_v2"), collision.centFT0M(), jet.pt() - (collision.rho() * jet.area()), 1.0); + } else { + registry.fill(HIST("h_jet_pt_out_of_plane_v2"), jet.pt() - (collision.rho() * jet.area()), 1.0); + registry.fill(HIST("h2_centrality_jet_pt_out_of_plane_v2"), collision.centFT0M(), jet.pt() - (collision.rho() * jet.area()), 1.0); + } + } + } else if (nmode == cfgNmodB) { + double phiMinusPsi3; + float ep3 = helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode); + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + if (jet.r() != round(selectedJetsRadius * 100.0f)) { + continue; + } + phiMinusPsi3 = jet.phi() - ep3; + + if ((phiMinusPsi3 < o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi3 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h_jet_pt_in_plane_v3"), jet.pt() - (collision.rho() * jet.area()), 1.0); + } else { + registry.fill(HIST("h_jet_pt_out_of_plane_v3"), jet.pt() - (collision.rho() * jet.area()), 1.0); + } + } + } + } + } + PROCESS_SWITCH(JetChargedV2, processInOutJetV2, "Jet V2 in and out of plane", false); + + void processInOutJetV2MCD(soa::Filtered>::iterator const& collision, + soa::Join const& jets, + aod::JetTracks const&) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } //=====================< evt pln [n=2->\Psi_2, n=3->\Psi_3] >=====================// histosQA.fill(HIST("histCent"), collision.cent()); + //=====================< evt pln [n=2->\Psi_2, n=3->\Psi_3] >=====================// + int cfgNmodA = 2; + int cfgNmodB = 3; for (uint i = 0; i < cfgnMods->size(); i++) { int nmode = cfgnMods->at(i); - int DetInd = DetId * 4 + cfgnTotalSystem * 4 * (nmode - 2); - if (nmode == 2) { - if (collision.qvecAmp()[DetId] > 1e-8) { - histosQA.fill(HIST("histQvecUncorV2"), collision.qvecRe()[DetInd], collision.qvecIm()[DetInd], collision.cent()); - histosQA.fill(HIST("histQvecRectrV2"), collision.qvecRe()[DetInd + 1], collision.qvecIm()[DetInd + 1], collision.cent()); - histosQA.fill(HIST("histQvecTwistV2"), collision.qvecRe()[DetInd + 2], collision.qvecIm()[DetInd + 2], collision.cent()); - histosQA.fill(HIST("histQvecFinalV2"), collision.qvecRe()[DetInd + 3], collision.qvecIm()[DetInd + 3], collision.cent()); - - histosQA.fill(HIST("histEvtPlUncorV2"), helperEP.GetEventPlane(collision.qvecRe()[DetInd], collision.qvecIm()[DetInd], nmode), collision.cent()); - histosQA.fill(HIST("histEvtPlRectrV2"), helperEP.GetEventPlane(collision.qvecRe()[DetInd + 1], collision.qvecIm()[DetInd + 1], nmode), collision.cent()); - histosQA.fill(HIST("histEvtPlTwistV2"), helperEP.GetEventPlane(collision.qvecRe()[DetInd + 2], collision.qvecIm()[DetInd + 2], nmode), collision.cent()); - histosQA.fill(HIST("histEvtPlFinalV2"), helperEP.GetEventPlane(collision.qvecRe()[DetInd + 3], collision.qvecIm()[DetInd + 3], nmode), collision.cent()); - } - } else if (nmode == 3) { - histosQA.fill(HIST("histQvecUncorV3"), collision.qvecRe()[DetInd], collision.qvecIm()[DetInd], collision.cent()); - histosQA.fill(HIST("histQvecRectrV3"), collision.qvecRe()[DetInd + 1], collision.qvecIm()[DetInd + 1], collision.cent()); - histosQA.fill(HIST("histQvecTwistV3"), collision.qvecRe()[DetInd + 2], collision.qvecIm()[DetInd + 2], collision.cent()); - histosQA.fill(HIST("histQvecFinalV3"), collision.qvecRe()[DetInd + 3], collision.qvecIm()[DetInd + 3], collision.cent()); - - histosQA.fill(HIST("histEvtPlUncorV3"), helperEP.GetEventPlane(collision.qvecRe()[DetInd], collision.qvecIm()[DetInd], nmode), collision.cent()); - histosQA.fill(HIST("histEvtPlRectrV3"), helperEP.GetEventPlane(collision.qvecRe()[DetInd + 1], collision.qvecIm()[DetInd + 1], nmode), collision.cent()); - histosQA.fill(HIST("histEvtPlTwistV3"), helperEP.GetEventPlane(collision.qvecRe()[DetInd + 2], collision.qvecIm()[DetInd + 2], nmode), collision.cent()); - histosQA.fill(HIST("histEvtPlFinalV3"), helperEP.GetEventPlane(collision.qvecRe()[DetInd + 3], collision.qvecIm()[DetInd + 3], nmode), collision.cent()); - } - - if (nmode == 2) { - Double_t phiMinusPsi2; - if (collision.qvecAmp()[DetId] < 1e-8) { + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + int refAInd = refAId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + int refBInd = refBId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + + if (nmode == cfgNmodA) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId || collision.qvecAmp()[refAId] < collQvecAmpDetId || collision.qvecAmp()[refBId] < collQvecAmpDetId) { + histosQA.fill(HIST("histQvecUncorV2"), collision.qvecRe()[detInd], collision.qvecIm()[detInd], collision.cent()); + histosQA.fill(HIST("histQvecRectrV2"), collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], collision.cent()); + histosQA.fill(HIST("histQvecTwistV2"), collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], collision.cent()); + histosQA.fill(HIST("histQvecFinalV2"), collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], collision.cent()); + + histosQA.fill(HIST("histEvtPlUncorV2"), helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRectrV2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlTwistV2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlFinalV2"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), collision.cent()); + + histosQA.fill(HIST("histEvtPlRes_SigRefAV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRes_SigRefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRes_RefARefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.cent()); + } + } else if (nmode == cfgNmodB) { + histosQA.fill(HIST("histQvecUncorV3"), collision.qvecRe()[detInd], collision.qvecIm()[detInd], collision.cent()); + histosQA.fill(HIST("histQvecRectrV3"), collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], collision.cent()); + histosQA.fill(HIST("histQvecTwistV3"), collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], collision.cent()); + histosQA.fill(HIST("histQvecFinalV3"), collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], collision.cent()); + + histosQA.fill(HIST("histEvtPlUncorV3"), helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRectrV3"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlTwistV3"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2], nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlFinalV3"), helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), collision.cent()); + + histosQA.fill(HIST("histEvtPlRes_SigRefAV3"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRes_SigRefBV3"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.cent()); + histosQA.fill(HIST("histEvtPlRes_RefARefBV3"), helperEP.GetResolution(helperEP.GetEventPlane(collision.qvecRe()[refAInd + 3], collision.qvecIm()[refAInd + 3], nmode), helperEP.GetEventPlane(collision.qvecRe()[refBInd + 3], collision.qvecIm()[refBInd + 3], nmode), nmode), collision.cent()); + } + } + + int evtPlnAngleA = 7; + int evtPlnAngleB = 3; + int evtPlnAngleC = 5; + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + + if (nmode == cfgNmodA) { + double phiMinusPsi2; + if (collision.qvecAmp()[detId] < collQvecAmpDetId) { continue; } - float evtPl2 = helperEP.GetEventPlane(collision.qvecRe()[DetInd], collision.qvecIm()[DetInd], nmode); + float ep2 = helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode); for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; @@ -382,24 +961,23 @@ struct Jetchargedv2Task { if (!isAcceptedJet(jet)) { continue; } - registry.fill(HIST("h_jet_pt_rhoareasubtracted"), jet.pt() - (collision.rho() * jet.area()), 1); - if (jet.r() == round(selectedJetsRadius * 100.0f)) { - registry.fill(HIST("h_jet_pt_in_out_plane_v2"), jet.pt() - (collision.rho() * jet.area()), 1.0); + if (jet.r() != round(selectedJetsRadius * 100.0f)) { + continue; } - phiMinusPsi2 = jet.phi() - evtPl2; + registry.fill(HIST("h_jet_pt_rhoareasubtracted"), jet.pt() - (collision.rho() * jet.area()), 1.0); - if ((phiMinusPsi2 < TMath::Pi() / 4) || (phiMinusPsi2 >= 7 * TMath::Pi() / 4) || (phiMinusPsi2 >= 3 * TMath::Pi() / 4 && phiMinusPsi2 < 5 * TMath::Pi() / 4)) { + phiMinusPsi2 = jet.phi() - ep2; + if ((phiMinusPsi2 < o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi2 < evtPlnAngleC * o2::constants::math::PIQuarter)) { registry.fill(HIST("h_jet_pt_in_plane_v2"), jet.pt() - (collision.rho() * jet.area()), 1.0); - registry.fill(HIST("h2_centrality_jet_pt_in_plane_v2"), collision.centrality(), jet.pt() - (collision.rho() * jet.area()), 1.0); + registry.fill(HIST("h2_centrality_jet_pt_in_plane_v2"), collision.centFT0M(), jet.pt() - (collision.rho() * jet.area()), 1.0); } else { registry.fill(HIST("h_jet_pt_out_of_plane_v2"), jet.pt() - (collision.rho() * jet.area()), 1.0); - registry.fill(HIST("h2_centrality_jet_pt_out_of_plane_v2"), collision.centrality(), jet.pt() - (collision.rho() * jet.area()), 1.0); + registry.fill(HIST("h2_centrality_jet_pt_out_of_plane_v2"), collision.centFT0M(), jet.pt() - (collision.rho() * jet.area()), 1.0); } } - //< JetPtCorr = Jet_pT-*A in-plane and out-of-plane | end >// - } else if (nmode == 3) { - Double_t phiMinusPsi3; - float evtPl3 = helperEP.GetEventPlane(collision.qvecRe()[DetInd], collision.qvecIm()[DetInd], nmode); + } else if (nmode == cfgNmodB) { + double phiMinusPsi3; + float ep3 = helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode); for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; @@ -407,146 +985,778 @@ struct Jetchargedv2Task { if (!isAcceptedJet(jet)) { continue; } - phiMinusPsi3 = jet.phi() - evtPl3; + if (jet.r() != round(selectedJetsRadius * 100.0f)) { + continue; + } + phiMinusPsi3 = jet.phi() - ep3; - if ((phiMinusPsi3 < TMath::Pi() / 4) || (phiMinusPsi3 >= 7 * TMath::Pi() / 4) || (phiMinusPsi3 >= 3 * TMath::Pi() / 4 && phiMinusPsi3 < 5 * TMath::Pi() / 4)) { + if ((phiMinusPsi3 < o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi3 < evtPlnAngleC * o2::constants::math::PIQuarter)) { registry.fill(HIST("h_jet_pt_in_plane_v3"), jet.pt() - (collision.rho() * jet.area()), 1.0); - registry.fill(HIST("h2_centrality_jet_pt_in_plane_v3"), collision.centrality(), jet.pt() - (collision.rho() * jet.area()), 1.0); } else { registry.fill(HIST("h_jet_pt_out_of_plane_v3"), jet.pt() - (collision.rho() * jet.area()), 1.0); - registry.fill(HIST("h2_centrality_jet_pt_out_of_plane_v3"), collision.centrality(), jet.pt() - (collision.rho() * jet.area()), 1.0); } } } } } - PROCESS_SWITCH(Jetchargedv2Task, processInOutJetV2, "Jet V2 in and out of plane", true); + PROCESS_SWITCH(JetChargedV2, processInOutJetV2MCD, "Jet V2 in and out of plane MCD", false); - void processSigmaPt(soa::Filtered> const& collisions, + void processSigmaPt(soa::Filtered>::iterator const& collision, soa::Join const& jets, aod::JetTracks const& tracks) { - for (const auto& collision : collisions) { - double leadingJetPt = -1; - double leadingJetPhi = -1; - double leadingJetEta = -1; - for (auto& jet : jets) { - if (jet.pt() > leadingJetPt) { - leadingJetPt = jet.pt(); - leadingJetEta = jet.eta(); - leadingJetPhi = jet.phi(); + registry.fill(HIST("h_collisions"), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + registry.fill(HIST("h_collisions"), 1.5); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + registry.fill(HIST("h_collisions"), 2.5); + + double leadingJetPt = -1; + double leadingJetPhi = -1; + double leadingJetEta = -1; + fillLeadingJetQA(jets, leadingJetPt, leadingJetPhi, leadingJetEta); + + int nTrk = 0; + getNtrk(tracks, jets, nTrk, evtnum, leadingJetEta); + if (nTrk <= 0) { + return; + } + hPtsumSumptFit = new TH1F("h_ptsum_sumpt_fit", "h_ptsum_sumpt fit use", TMath::CeilNint(std::sqrt(nTrk)), 0., o2::constants::math::TwoPI); + + fillNtrkCheck(tracks, jets, hPtsumSumptFit, leadingJetEta); + + double ep2 = 0.; + double ep3 = 0.; + int cfgNmodA = 2; + int cfgNmodB = 3; + int evtPlnAngleA = 7; + int evtPlnAngleB = 3; + int evtPlnAngleC = 5; + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + if (nmode == cfgNmodA) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId) { + ep2 = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); + } + } else if (nmode == cfgNmodB) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId) { + ep3 = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); } } - fillLeadingJetQA(leadingJetPt, leadingJetPhi, leadingJetEta); + } - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { - return; + const char* fitFunctionV2v3 = "[0] * (1. + 2. * ([1] * std::cos(2. * (x - [2])) + [3] * std::cos(3. * (x - [4]))))"; + fFitModulationV2v3 = new TF1("fit_kV3", fitFunctionV2v3, 0, o2::constants::math::TwoPI); + //=========================< set parameter >=========================// + fFitModulationV2v3->SetParameter(0, 1.); + fFitModulationV2v3->SetParameter(1, 0.01); + fFitModulationV2v3->SetParameter(3, 0.01); + + double ep2fix = 0.; + double ep3fix = 0.; + + if (ep2 < 0) { + ep2fix = RecoDecay::constrainAngle(ep2); + fFitModulationV2v3->FixParameter(2, ep2fix); + } else { + fFitModulationV2v3->FixParameter(2, ep2); + } + if (ep3 < 0) { + ep3fix = RecoDecay::constrainAngle(ep3); + fFitModulationV2v3->FixParameter(4, ep3fix); + } else { + fFitModulationV2v3->FixParameter(4, ep3); + } + + hPtsumSumptFit->Fit(fFitModulationV2v3, "Q", "ep", 0, o2::constants::math::TwoPI); + + double temppara[5]; + temppara[0] = fFitModulationV2v3->GetParameter(0); + temppara[1] = fFitModulationV2v3->GetParameter(1); + temppara[2] = fFitModulationV2v3->GetParameter(2); + temppara[3] = fFitModulationV2v3->GetParameter(3); + temppara[4] = fFitModulationV2v3->GetParameter(4); + + registry.fill(HIST("h_fitparaRho_evtnum"), evtnum, temppara[0]); + registry.fill(HIST("h_fitparaPsi2_evtnum"), evtnum, temppara[2]); + registry.fill(HIST("h_fitparaPsi3_evtnum"), evtnum, temppara[4]); + registry.fill(HIST("h_v2obs_centrality"), collision.centFT0M(), temppara[1]); + registry.fill(HIST("h_v3obs_centrality"), collision.centFT0M(), temppara[3]); + registry.fill(HIST("h_evtnum_centrlity"), evtnum, collision.centFT0M()); + + if (temppara[0] == 0) { + return; + } + + int nDF = 1; + int numOfFreePara = 2; + nDF = static_cast(fFitModulationV2v3->GetXaxis()->GetNbins()) - numOfFreePara; + if (nDF == 0 || static_cast(nDF) <= 0.) + return; + double chi2 = 0.; + for (int i = 0; i < hPtsumSumptFit->GetXaxis()->GetNbins(); i++) { + if (hPtsumSumptFit->GetBinContent(i + 1) <= 0.) + continue; + chi2 += std::pow((hPtsumSumptFit->GetBinContent(i + 1) - fFitModulationV2v3->Eval(hPtsumSumptFit->GetXaxis()->GetBinCenter(1 + i))), 2) / hPtsumSumptFit->GetBinContent(i + 1); + } + + double chiSqr = 999.; + double cDF = 1.; + + chiSqr = chi2; + cDF = 1. - chiSquareCDF(nDF, chiSqr); + + int evtCentAreaMin = 0; + int evtCentAreaMax = 5; + int evtMidAreaMin = 30; + int evtMidAreaMax = 50; + double evtcent = collision.centFT0M(); + if (cfgChkFitQuality) { + registry.fill(HIST("h_PvalueCDF_CombinFit"), cDF); + registry.fill(HIST("h2_PvalueCDFCent_CombinFit"), collision.centFT0M(), cDF); + registry.fill(HIST("h2_Chi2Cent_CombinFit"), collision.centFT0M(), chiSqr / (static_cast(nDF))); + registry.fill(HIST("h2_PChi2_CombinFit"), cDF, chiSqr / (static_cast(nDF))); + if (evtcent >= evtCentAreaMin && evtcent <= evtCentAreaMax) { + registry.fill(HIST("h2_PChi2_CombinFitA"), cDF, chiSqr / (static_cast(nDF))); + + } else if (evtcent >= evtMidAreaMin && evtcent <= evtMidAreaMax) { + registry.fill(HIST("h2_PChi2_CombinFitB"), cDF, chiSqr / (static_cast(nDF))); } - auto collTracks = tracks.sliceBy(tracksPerJCollision, collision.globalIndex()); + if (evtcent >= evtCentAreaMin && evtcent <= evtCentAreaMax) { + registry.fill(HIST("h2_PChi2_CombinFitA"), cDF, chiSqr / (static_cast(nDF))); - if (jets.size() > 0) { - for (auto const& track : collTracks) { - if (jetderiveddatautilities::selectTrack(track, trackSelection) && (fabs(track.eta() - leadingJetEta) > jetRadius)) { - registry.fill(HIST("h2_phi_track_pt"), track.pt(), track.phi()); - registry.fill(HIST("h2_phi_track_eta"), track.eta(), track.phi()); - registry.fill(HIST("h_ptsum_sumpt"), track.phi(), track.pt()); // \sigma p_T distribution test [ && track.pt() >= 0.2 && track.pt() <= 5.] - registry.fill(HIST("h2_centrality_phi_w_pt"), collision.centrality(), track.phi(), track.pt()); // \sigma track.pt() distribution with centrality test - registry.fill(HIST("h2_evtnum_phi_w_pt"), evtnum, track.phi(), track.pt()); + } else if (evtcent >= evtMidAreaMin && evtcent <= evtMidAreaMax) { + registry.fill(HIST("h2_PChi2_CombinFitB"), cDF, chiSqr / (static_cast(nDF))); + } + } + + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + if (jet.r() != round(selectedJetsRadius * 100.0f)) { + continue; + } + + double integralValue = fFitModulationV2v3->Integral(jet.phi() - jetRadius, jet.phi() + jetRadius); + double rholocal = collision.rho() / (2 * jetRadius * temppara[0]) * integralValue; + registry.fill(HIST("h2_rholocal_cent"), collision.centFT0M(), rholocal, 1.0); + + if (nmode == cfgNmodA) { + double phiMinusPsi2; + if (collision.qvecAmp()[detId] < collQvecAmpDetId) { + continue; + } + phiMinusPsi2 = jet.phi() - ep2; + + registry.fill(HIST("h2_phi_rholocal"), jet.phi() - ep2, rholocal, 1.0); + registry.fill(HIST("h_jet_pt_inclusive_v2_rho"), jet.pt() - (rholocal * jet.area()), 1.0); + + if ((phiMinusPsi2 < o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi2 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h_jet_pt_in_plane_v2_rho"), jet.pt() - (rholocal * jet.area()), 1.0); + registry.fill(HIST("h2_centrality_jet_pt_in_plane_v2_rho"), collision.centFT0M(), jet.pt() - (rholocal * jet.area()), 1.0); + } else { + registry.fill(HIST("h_jet_pt_out_of_plane_v2_rho"), jet.pt() - (rholocal * jet.area()), 1.0); + registry.fill(HIST("h2_centrality_jet_pt_out_of_plane_v2_rho"), collision.centFT0M(), jet.pt() - (rholocal * jet.area()), 1.0); + } + } else if (nmode == cfgNmodB) { + double phiMinusPsi3; + if (collision.qvecAmp()[detId] < collQvecAmpDetId) { + continue; + } + ep3 = helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode); + phiMinusPsi3 = jet.phi() - ep3; + + if ((phiMinusPsi3 < o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi3 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h_jet_pt_in_plane_v3_rho"), jet.pt() - (rholocal * jet.area()), 1.0); + } else { + registry.fill(HIST("h_jet_pt_out_of_plane_v3_rho"), jet.pt() - (rholocal * jet.area()), 1.0); } } } - registry.fill(HIST("h_ptsum_collnum"), 0.5); - evtnum += 1; } + // RCpT + for (uint i = 0; i < cfgnMods->size(); i++) { + TRandom3 randomNumber(0); + float randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); + float randomConePhi = randomNumber.Uniform(0.0, o2::constants::math::TwoPI); + float randomConePt = 0; + double integralValueRC = fFitModulationV2v3->Integral(randomConePhi - randomConeR, randomConePhi + randomConeR); + double rholocalRC = collision.rho() / (2 * randomConeR * temppara[0]) * integralValueRC; + + int nmode = cfgnMods->at(i); + if (nmode == cfgNmodA) { + double rcPhiPsi2; + rcPhiPsi2 = randomConePhi - ep2; + + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection)) { + float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + float dEta = track.eta() - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + randomConePt += track.pt(); + } + } + } + registry.fill(HIST("h3_centrality_deltapT_RandomCornPhi_localrhovsphi"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * rholocalRC, rcPhiPsi2, 1.0); + + // removing the leading jet from the random cone + if (jets.size() > 0) { // if there are no jets in the acceptance (from the jetfinder cuts) then there can be no leading jet + float dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + float dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + + bool jetWasInCone = false; + while ((randomConeLeadJetDeltaR <= 0 && (std::sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < jets.iteratorAt(0).r() / 100.0 + randomConeR)) || (randomConeLeadJetDeltaR > 0 && (std::sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < randomConeLeadJetDeltaR))) { + jetWasInCone = true; + randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); + randomConePhi = randomNumber.Uniform(0.0, o2::constants::math::TwoPI); + dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + } + if (jetWasInCone) { + randomConePt = 0.0; + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > randomConeR)) { // if track selection is uniformTrack, dcaXY and dcaZ cuts need to be added as they aren't in the selection so that they can be studied here + float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + float dEta = track.eta() - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + randomConePt += track.pt(); + } + } + } + } + } + registry.fill(HIST("h3_centrality_deltapT_RandomCornPhi_localrhovsphiwithoutleadingjet"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * rholocalRC, rcPhiPsi2, 1.0); + registry.fill(HIST("h3_centrality_deltapT_RandomCornPhi_rhorandomconewithoutleadingjet"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * collision.rho(), rcPhiPsi2, 1.0); + } else if (nmode == cfgNmodB) { + continue; + } + } + delete hPtsumSumptFit; + delete fFitModulationV2v3; + evtnum += 1; } - PROCESS_SWITCH(Jetchargedv2Task, processSigmaPt, "Sigma pT and bkg as fcn of phi", true); + PROCESS_SWITCH(JetChargedV2, processSigmaPt, "Sigma pT and bkg as fcn of phi", false); - void processRandomConeDataV2(soa::Filtered>::iterator const& collision, - soa::Join const& jets, - soa::Filtered const& tracks) + void processSigmaPtMCD(soa::Filtered>::iterator const& collision, + soa::Join const& jets, + aod::JetTracks const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + registry.fill(HIST("h_collisions"), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + registry.fill(HIST("h_collisions"), 1.5); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } + registry.fill(HIST("h_collisions"), 2.5); + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + } + + double leadingJetPt = -1; + double leadingJetPhi = -1; + double leadingJetEta = -1; + fillLeadingJetQA(jets, leadingJetPt, leadingJetPhi, leadingJetEta); + int nTrk = 0; + getNtrk(tracks, jets, nTrk, evtnum, leadingJetEta); + if (nTrk <= 0) { + return; + } + hPtsumSumptFit = new TH1F("h_ptsum_sumpt_fit", "h_ptsum_sumpt fit use", TMath::CeilNint(std::sqrt(nTrk)), 0., o2::constants::math::TwoPI); + + fillNtrkCheck(tracks, jets, hPtsumSumptFit, leadingJetEta); + + double ep2 = 0.; + double ep3 = 0.; + int cfgNmodA = 2; + int cfgNmodB = 3; + int evtPlnAngleA = 7; + int evtPlnAngleB = 3; + int evtPlnAngleC = 5; + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + if (nmode == cfgNmodA) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId) { + ep2 = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); + } + } else if (nmode == cfgNmodB) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId) { + ep3 = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); + } + } + } + + const char* fitFunctionV2v3 = "[0] * (1. + 2. * ([1] * std::cos(2. * (x - [2])) + [3] * std::cos(3. * (x - [4]))))"; + fFitModulationV2v3 = new TF1("fit_kV3", fitFunctionV2v3, 0, o2::constants::math::TwoPI); + //=========================< set parameter >=========================// + fFitModulationV2v3->SetParameter(0, 1.); + fFitModulationV2v3->SetParameter(1, 0.01); + fFitModulationV2v3->SetParameter(3, 0.01); + + double ep2fix = 0.; + double ep3fix = 0.; + + if (ep2 < 0) { + ep2fix = RecoDecay::constrainAngle(ep2); + fFitModulationV2v3->FixParameter(2, ep2fix); + } else { + fFitModulationV2v3->FixParameter(2, ep2); + } + if (ep3 < 0) { + ep3fix = RecoDecay::constrainAngle(ep3); + fFitModulationV2v3->FixParameter(4, ep3fix); + } else { + fFitModulationV2v3->FixParameter(4, ep3); + } + + hPtsumSumptFit->Fit(fFitModulationV2v3, "Q", "ep", 0, o2::constants::math::TwoPI); + + double temppara[5]; + temppara[0] = fFitModulationV2v3->GetParameter(0); + temppara[1] = fFitModulationV2v3->GetParameter(1); + temppara[2] = fFitModulationV2v3->GetParameter(2); + temppara[3] = fFitModulationV2v3->GetParameter(3); + temppara[4] = fFitModulationV2v3->GetParameter(4); + + registry.fill(HIST("h_fitparaRho_evtnum"), evtnum, temppara[0]); + registry.fill(HIST("h_fitparaPsi2_evtnum"), evtnum, temppara[2]); + registry.fill(HIST("h_fitparaPsi3_evtnum"), evtnum, temppara[4]); + registry.fill(HIST("h_v2obs_centrality"), collision.centFT0M(), temppara[1]); + registry.fill(HIST("h_v3obs_centrality"), collision.centFT0M(), temppara[3]); + registry.fill(HIST("h_evtnum_centrlity"), evtnum, collision.centFT0M()); + + if (temppara[0] == 0) { + return; + } + + int nDF = 1; + int numOfFreePara = 2; + nDF = static_cast(fFitModulationV2v3->GetXaxis()->GetNbins()) - numOfFreePara; + if (nDF == 0 || static_cast(nDF) <= 0.) + return; + double chi2 = 0.; + for (int i = 0; i < hPtsumSumptFit->GetXaxis()->GetNbins(); i++) { + if (hPtsumSumptFit->GetBinContent(i + 1) <= 0.) + continue; + chi2 += std::pow((hPtsumSumptFit->GetBinContent(i + 1) - fFitModulationV2v3->Eval(hPtsumSumptFit->GetXaxis()->GetBinCenter(1 + i))), 2) / hPtsumSumptFit->GetBinContent(i + 1); + } + + double chiSqr = 999.; + double cDF = 1.; + + chiSqr = chi2; + cDF = 1. - chiSquareCDF(nDF, chiSqr); + + int evtCentAreaMin = 0; + int evtCentAreaMax = 5; + int evtMidAreaMin = 30; + int evtMidAreaMax = 50; + double evtcent = collision.centFT0M(); + if (cfgChkFitQuality) { + registry.fill(HIST("h_PvalueCDF_CombinFit"), cDF); + registry.fill(HIST("h2_PvalueCDFCent_CombinFit"), collision.centFT0M(), cDF); + registry.fill(HIST("h2_Chi2Cent_CombinFit"), collision.centFT0M(), chiSqr / (static_cast(nDF))); + registry.fill(HIST("h2_PChi2_CombinFit"), cDF, chiSqr / (static_cast(nDF))); + if (evtcent >= evtCentAreaMin && evtcent <= evtCentAreaMax) { + registry.fill(HIST("h2_PChi2_CombinFitA"), cDF, chiSqr / (static_cast(nDF))); + + } else if (evtcent >= evtMidAreaMin && evtcent <= evtMidAreaMax) { + registry.fill(HIST("h2_PChi2_CombinFitB"), cDF, chiSqr / (static_cast(nDF))); + } + } + + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + if (jet.r() != round(selectedJetsRadius * 100.0f)) { + continue; + } + + double integralValue = fFitModulationV2v3->Integral(jet.phi() - jetRadius, jet.phi() + jetRadius); + double rholocal = collision.rho() / (2 * jetRadius * temppara[0]) * integralValue; + registry.fill(HIST("h2_rholocal_cent"), collision.centFT0M(), rholocal, 1.0); + + if (nmode == cfgNmodA) { + double phiMinusPsi2; + if (collision.qvecAmp()[detId] < collQvecAmpDetId) { + continue; + } + phiMinusPsi2 = jet.phi() - ep2; + + registry.fill(HIST("h2_phi_rholocal"), jet.phi() - ep2, rholocal, 1.0); + registry.fill(HIST("h_jet_pt_inclusive_v2_rho"), jet.pt() - (rholocal * jet.area()), 1.0); + + if ((phiMinusPsi2 < o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi2 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi2 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h_jet_pt_in_plane_v2_rho"), jet.pt() - (rholocal * jet.area()), 1.0); + registry.fill(HIST("h2_centrality_jet_pt_in_plane_v2_rho"), collision.centFT0M(), jet.pt() - (rholocal * jet.area()), 1.0); + } else { + registry.fill(HIST("h_jet_pt_out_of_plane_v2_rho"), jet.pt() - (rholocal * jet.area()), 1.0); + registry.fill(HIST("h2_centrality_jet_pt_out_of_plane_v2_rho"), collision.centFT0M(), jet.pt() - (rholocal * jet.area()), 1.0); + } + } else if (nmode == cfgNmodB) { + double phiMinusPsi3; + if (collision.qvecAmp()[detId] < collQvecAmpDetId) { + continue; + } + ep3 = helperEP.GetEventPlane(collision.qvecRe()[detInd], collision.qvecIm()[detInd], nmode); + phiMinusPsi3 = jet.phi() - ep3; + + if ((phiMinusPsi3 < o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleA * o2::constants::math::PIQuarter) || (phiMinusPsi3 >= evtPlnAngleB * o2::constants::math::PIQuarter && phiMinusPsi3 < evtPlnAngleC * o2::constants::math::PIQuarter)) { + registry.fill(HIST("h_jet_pt_in_plane_v3_rho"), jet.pt() - (rholocal * jet.area()), 1.0); + } else { + registry.fill(HIST("h_jet_pt_out_of_plane_v3_rho"), jet.pt() - (rholocal * jet.area()), 1.0); + } + } + } + } + // RCpT for (uint i = 0; i < cfgnMods->size(); i++) { TRandom3 randomNumber(0); float randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); - float randomConePhi = randomNumber.Uniform(0.0, 2 * M_PI); + float randomConePhi = randomNumber.Uniform(0.0, o2::constants::math::TwoPI); float randomConePt = 0; + double integralValueRC = fFitModulationV2v3->Integral(randomConePhi - randomConeR, randomConePhi + randomConeR); + double rholocalRC = collision.rho() / (2 * randomConeR * temppara[0]) * integralValueRC; int nmode = cfgnMods->at(i); - int DetInd = DetId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + if (nmode == cfgNmodA) { + double rcPhiPsi2; + rcPhiPsi2 = randomConePhi - ep2; + + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection)) { + float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + float dEta = track.eta() - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + randomConePt += track.pt(); + } + } + } + registry.fill(HIST("h3_centrality_deltapT_RandomCornPhi_localrhovsphi"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * rholocalRC, rcPhiPsi2, 1.0); + + // removing the leading jet from the random cone + if (jets.size() > 0) { // if there are no jets in the acceptance (from the jetfinder cuts) then there can be no leading jet + float dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + float dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + + bool jetWasInCone = false; + while ((randomConeLeadJetDeltaR <= 0 && (std::sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < jets.iteratorAt(0).r() / 100.0 + randomConeR)) || (randomConeLeadJetDeltaR > 0 && (std::sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < randomConeLeadJetDeltaR))) { + jetWasInCone = true; + randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); + randomConePhi = randomNumber.Uniform(0.0, o2::constants::math::TwoPI); + dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + } + if (jetWasInCone) { + randomConePt = 0.0; + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > randomConeR)) { // if track selection is uniformTrack, dcaXY and dcaZ cuts need to be added as they aren't in the selection so that they can be studied here + float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, static_cast(-o2::constants::math::PI)); + float dEta = track.eta() - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + randomConePt += track.pt(); + } + } + } + } + } + registry.fill(HIST("h3_centrality_deltapT_RandomCornPhi_localrhovsphiwithoutleadingjet"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * rholocalRC, rcPhiPsi2, 1.0); + registry.fill(HIST("h3_centrality_deltapT_RandomCornPhi_rhorandomconewithoutleadingjet"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * collision.rho(), rcPhiPsi2, 1.0); + } else if (nmode == cfgNmodB) { + continue; + } + } + delete hPtsumSumptFit; + delete fFitModulationV2v3; + evtnum += 1; + } + PROCESS_SWITCH(JetChargedV2, processSigmaPtMCD, "jet spectra with rho-area subtraction for MCD", false); - Double_t RcPhiPsi2; - float evtPl2 = helperEP.GetEventPlane(collision.qvecRe()[DetInd], collision.qvecIm()[DetInd], nmode); - RcPhiPsi2 = randomConePhi - evtPl2; + void processSigmaPtMCP(McParticleCollision::iterator const& mccollision, + soa::SmallGroups> const& collisions, + soa::Join const& jets, + aod::JetTracks const& tracks, + aod::JetParticles const&) + { + bool mcLevelIsParticleLevel = true; + int acceptSplitCollInMCP = 2; - for (auto const& track : tracks) { - if (jetderiveddatautilities::selectTrack(track, trackSelection)) { - float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, static_cast(-M_PI)); - float dEta = track.eta() - randomConeEta; - if (TMath::Sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { - randomConePt += track.pt(); - } - } - } - registry.fill(HIST("h3_centrality_RCpt_RandomCornPhi_rhorandomcone"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho(), RcPhiPsi2, 1.0); - // removing the leading jet from the random cone - if (jets.size() > 0) { // if there are no jets in the acceptance (from the jetfinder cuts) then there can be no leading jet - float dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-M_PI)); - float dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; - - bool jetWasInCone = false; - while (TMath::Sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < jets.iteratorAt(0).r() / 100.0 + randomConeR) { - jetWasInCone = true; - randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); - randomConePhi = randomNumber.Uniform(0.0, 2 * M_PI); - dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-M_PI)); - dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; - } - if (jetWasInCone) { - randomConePt = 0.0; + registry.fill(HIST("h_mcColl_counts_areasub"), 0.5); + if (std::abs(mccollision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 1.5); + if (collisions.size() < 1) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 2.5); + if (acceptSplitCollisions == 0 && collisions.size() > 1) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 3.5); + + bool hasSel8Coll = false; + bool centralityIsGood = false; + bool occupancyIsGood = false; + if (acceptSplitCollisions == acceptSplitCollInMCP) { + if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelectionBits, skipMBGapEvents)) { + hasSel8Coll = true; + } + if ((centralityMin < collisions.begin().centFT0M()) && (collisions.begin().centFT0M() < centralityMax)) { + centralityIsGood = true; + } + if ((trackOccupancyInTimeRangeMin < collisions.begin().trackOccupancyInTimeRange()) && (collisions.begin().trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMax)) { + occupancyIsGood = true; + } + } else { + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + hasSel8Coll = true; + } + if ((centralityMin < collision.centFT0M()) && (collision.centFT0M() < centralityMax)) { + centralityIsGood = true; + } + if ((trackOccupancyInTimeRangeMin < collision.trackOccupancyInTimeRange()) && (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMax)) { + occupancyIsGood = true; + } + } + } + if (!hasSel8Coll) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 4.5); + + if (!centralityIsGood) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 5.5); + + if (!occupancyIsGood) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 6.5); + registry.fill(HIST("h_mcColl_rho"), mccollision.rho()); + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet, mcLevelIsParticleLevel)) { + continue; + } + fillMCPAreaSubHistograms(jet, mccollision.rho()); + } + + double leadingJetPt = -1; + double leadingJetPhi = -1; + double leadingJetEta = -1; + int nTrk = 0; + for (auto const& collision : collisions) { + auto collTracks = tracks.sliceBy(tracksPerJCollision, collision.globalIndex()); + fillLeadingJetQAMCP(jets, leadingJetPt, leadingJetPhi, leadingJetEta); + + if (jets.size() > 0) { + for (auto const& track : collTracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > jetRadius) && track.pt() >= localRhoFitPtMin && track.pt() <= localRhoFitPtMax) { + nTrk += 1; + } + } + } + if (nTrk <= 0) { + return; + } + hPtsumSumptFitMCP = new TH1F("h_ptsum_sumpt_fit", "h_ptsum_sumpt fit use", TMath::CeilNint(std::sqrt(nTrk)), 0., o2::constants::math::TwoPI); + + if (jets.size() > 0) { + for (auto const& track : collTracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > jetRadius) && track.pt() >= localRhoFitPtMin && track.pt() <= localRhoFitPtMax) { + hPtsumSumptFitMCP->Fill(track.phi(), track.pt()); + } + } + } + fitFncMCP(collision, tracks, jets, hPtsumSumptFitMCP, leadingJetEta, mcLevelIsParticleLevel); + } + + delete hPtsumSumptFitMCP; + delete fFitModulationV2v3P; + evtnum += 1; + } + PROCESS_SWITCH(JetChargedV2, processSigmaPtMCP, "jet spectra with area-based subtraction for MC particle level", false); + + void processJetsMatchedSubtracted(McParticleCollision::iterator const& mccollision, + soa::SmallGroups> const& collisions, + ChargedMCDMatchedJets const& mcdjets, + ChargedMCPMatchedJets const&, + aod::JetTracks const& tracks, aod::JetParticles const&) + { + registry.fill(HIST("h_mc_collisions_matched"), 0.5); + if (mccollision.size() < 1) { + return; + } + registry.fill(HIST("h_mc_collisions_matched"), 1.5); + if (!(std::abs(mccollision.posZ()) < vertexZCut)) { + return; + } + registry.fill(HIST("h_mc_collisions_matched"), 2.5); + double mcrho = mccollision.rho(); + registry.fill(HIST("h_mc_rho_matched"), mcrho); + for (const auto& collision : collisions) { + registry.fill(HIST("h_mcd_events_matched"), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents) || !(std::abs(collision.posZ()) < vertexZCut)) { + continue; + } + registry.fill(HIST("h_mcd_events_matched"), 1.5); + if (collision.centFT0M() < centralityMin || collision.centFT0M() > centralityMax) { + continue; + } + registry.fill(HIST("h_mcd_events_matched"), 2.5); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + registry.fill(HIST("h_mcd_events_matched"), 3.5); + + auto collmcdjets = mcdjets.sliceBy(mcdjetsPerJCollision, collision.globalIndex()); + for (const auto& mcdjet : collmcdjets) { + if (!isAcceptedJet(mcdjet)) { + continue; + } + + double leadingJetPt = -1; + double leadingJetEta = -1; + + if (mcdjet.pt() > leadingJetPt) { + leadingJetPt = mcdjet.pt(); + leadingJetEta = mcdjet.eta(); + } + int nTrk = 0; + if (mcdjet.size() > 0) { for (auto const& track : tracks) { - if (jetderiveddatautilities::selectTrack(track, trackSelection)) { // if track selection is uniformTrack, dcaXY and dcaZ cuts need to be added as they aren't in the selection so that they can be studied here - float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, static_cast(-M_PI)); - float dEta = track.eta() - randomConeEta; - if (TMath::Sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { - randomConePt += track.pt(); - } + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > jetRadius) && track.pt() >= localRhoFitPtMin && track.pt() <= localRhoFitPtMax) { + registry.fill(HIST("h_accept_Track"), 4.5); + nTrk += 1; + } + } + } + if (nTrk <= 0) { + return; + } + hPtsumSumptFitRM = new TH1F("h_ptsum_sumpt_fit_RM", "h_ptsum_sumpt_RM fit use", TMath::CeilNint(std::sqrt(nTrk)), 0., o2::constants::math::TwoPI); + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > jetRadius) && track.pt() >= localRhoFitPtMin && track.pt() <= localRhoFitPtMax) { + registry.fill(HIST("h_accept_Track_Match"), 0.5); + hPtsumSumptFitRM->Fill(track.phi(), track.pt()); + } + } + + double ep2 = 0.; + double ep3 = 0.; + int cfgNmodA = 2; + int cfgNmodB = 3; + + for (uint i = 0; i < cfgnMods->size(); i++) { + int nmode = cfgnMods->at(i); + int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + if (nmode == cfgNmodA) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId) { + ep2 = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); + } + } else if (nmode == cfgNmodB) { + if (collision.qvecAmp()[detId] > collQvecAmpDetId) { + ep3 = helperEP.GetEventPlane(collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3], nmode); } } } + + const char* fitFunctionRM = "[0] * (1. + 2. * ([1] * std::cos(2. * (x - [2])) + [3] * std::cos(3. * (x - [4]))))"; + fFitModulationRM = new TF1("fit_kV3", fitFunctionRM, 0, o2::constants::math::TwoPI); + //=========================< set parameter >=========================// + fFitModulationRM->SetParameter(0, 1.); + fFitModulationRM->SetParameter(1, 0.01); + fFitModulationRM->SetParameter(3, 0.01); + + double ep2fix = 0.; + double ep3fix = 0.; + + if (ep2 < 0) { + ep2fix = RecoDecay::constrainAngle(ep2); + fFitModulationRM->FixParameter(2, ep2fix); + } else { + fFitModulationRM->FixParameter(2, ep2); + } + if (ep3 < 0) { + ep3fix = RecoDecay::constrainAngle(ep3); + fFitModulationRM->FixParameter(4, ep3fix); + } else { + fFitModulationRM->FixParameter(4, ep3); + } + + hPtsumSumptFitRM->Fit(fFitModulationRM, "Q", "ep", 0, o2::constants::math::TwoPI); + + float tempparaA; + tempparaA = fFitModulationRM->GetParameter(0); + + if (tempparaA == 0) { + return; + } + + fillGeoMatchedCorrHistograms(mcdjet, fFitModulationRM, tempparaA, ep2, collision.rho(), mcrho); + delete hPtsumSumptFitRM; + delete fFitModulationRM; + evtnum += 1; } - registry.fill(HIST("h3_centrality_RCpt_RandomCornPhi_rhorandomconewithoutleadingjet"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho(), RcPhiPsi2, 1.0); } } - PROCESS_SWITCH(Jetchargedv2Task, processRandomConeDataV2, "QA for random cone estimation of background fluctuations in data", true); + PROCESS_SWITCH(JetChargedV2, processJetsMatchedSubtracted, "matched mcp and mcd jets after subtraction", false); void processTracksQA(soa::Filtered>::iterator const& collision, - soa::Filtered const& tracks) + soa::Filtered> const& tracks) { - // histosQA.fill(HIST("histCentTrkProcess"), collision.centrality()); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - histosQA.fill(HIST("histCentTrkProcess_aftersel"), collision.centrality()); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 1.5); - for (auto const& track : tracks) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } - registry.fill(HIST("h2_centrality_track_pt"), collision.centrality(), track.pt()); - registry.fill(HIST("h2_centrality_track_eta"), collision.centrality(), track.eta()); - registry.fill(HIST("h2_centrality_track_phi"), collision.centrality(), track.phi()); + fillTrackHistograms(track); } } - PROCESS_SWITCH(Jetchargedv2Task, processTracksQA, "QA for charged tracks", true); + PROCESS_SWITCH(JetChargedV2, processTracksQA, "QA for charged tracks", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-charged-v2"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGJE/Tasks/jetFinderB0QA.cxx b/PWGJE/Tasks/jetFinderB0QA.cxx new file mode 100644 index 00000000000..8935968ac5b --- /dev/null +++ b/PWGJE/Tasks/jetFinderB0QA.cxx @@ -0,0 +1,37 @@ +// 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. + +// jet finder B0 charged QA task +// +/// \author Nima Zardoshti + +#include "PWGJE/Tasks/jetFinderHFQA.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include + +#include + +using JetFinderB0QATask = JetFinderHFQATask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, + TaskName{"jet-finder-charged-b0-qa"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/Tasks/jetFinderBplusQA.cxx b/PWGJE/Tasks/jetFinderBplusQA.cxx index 4b7c42b4580..a713c3a767e 100644 --- a/PWGJE/Tasks/jetFinderBplusQA.cxx +++ b/PWGJE/Tasks/jetFinderBplusQA.cxx @@ -15,6 +15,16 @@ #include "PWGJE/Tasks/jetFinderHFQA.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include + +#include + using JetFinderBplusQATask = JetFinderHFQATask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/Tasks/jetFinderD0QA.cxx b/PWGJE/Tasks/jetFinderD0QA.cxx index 2db58308d87..1ebe0ec649b 100644 --- a/PWGJE/Tasks/jetFinderD0QA.cxx +++ b/PWGJE/Tasks/jetFinderD0QA.cxx @@ -15,6 +15,16 @@ #include "PWGJE/Tasks/jetFinderHFQA.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include + +#include + using JetFinderD0QATask = JetFinderHFQATask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/Tasks/jetFinderDielectronQA.cxx b/PWGJE/Tasks/jetFinderDielectronQA.cxx index 516f4501a7b..296ede5979a 100644 --- a/PWGJE/Tasks/jetFinderDielectronQA.cxx +++ b/PWGJE/Tasks/jetFinderDielectronQA.cxx @@ -15,6 +15,16 @@ #include "PWGJE/Tasks/jetFinderHFQA.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include + +#include + using JetFinderDielectronQATask = JetFinderHFQATask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/Tasks/jetFinderDplusQA.cxx b/PWGJE/Tasks/jetFinderDplusQA.cxx new file mode 100644 index 00000000000..877cbf60d8a --- /dev/null +++ b/PWGJE/Tasks/jetFinderDplusQA.cxx @@ -0,0 +1,37 @@ +// 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. + +// jet finder D+ charged QA task +// +/// \author Nima Zardoshti + +#include "PWGJE/Tasks/jetFinderHFQA.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include + +#include + +using JetFinderDplusQATask = JetFinderHFQATask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, + TaskName{"jet-finder-charged-dplus-qa"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/Tasks/jetFinderDstarQA.cxx b/PWGJE/Tasks/jetFinderDstarQA.cxx new file mode 100644 index 00000000000..b8fc0808521 --- /dev/null +++ b/PWGJE/Tasks/jetFinderDstarQA.cxx @@ -0,0 +1,37 @@ +// 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. + +// jet finder D* charged QA task +// +/// \author Nima Zardoshti + +#include "PWGJE/Tasks/jetFinderHFQA.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include + +#include + +using JetFinderDstarQATask = JetFinderHFQATask; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, + TaskName{"jet-finder-charged-dstar-qa"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/Tasks/jetFinderFullQA.cxx b/PWGJE/Tasks/jetFinderFullQA.cxx index 3899a335d4b..85989036f3e 100644 --- a/PWGJE/Tasks/jetFinderFullQA.cxx +++ b/PWGJE/Tasks/jetFinderFullQA.cxx @@ -13,28 +13,35 @@ // /// \author Nima Zardoshti -#include "CommonConstants/PhysicsConstants.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/EMCALClusterDefinition.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" +#include +#include +#include +#include +#include +#include +#include -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include -#include "PWGHF/Core/HfHelper.h" +#include +#include +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" - -#include "EventFiltering/filterTables.h" +#include using namespace o2; -using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; @@ -74,6 +81,8 @@ struct JetFinderFullQATask { Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; + Configurable pTHatAbsoluteMin{"pTHatAbsoluteMin", -99.0, "minimum value of pTHat"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "flag to choose to reject min. bias gap events; jet-level rejection applied at the jet finder level, here rejection is applied for collision and track process functions"}; std::vector filledJetR; std::vector jetRadiiValues; @@ -243,7 +252,7 @@ struct JetFinderFullQATask { using JetTableMCPMatchedWeightedJoined = soa::Join; Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); - Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); aod::EMCALClusterDefinition clusterDefinition = aod::emcalcluster::getClusterDefinitionFromString(clusterDefinitionS.value); Filter clusterFilter = (aod::jcluster::definition == static_cast(clusterDefinition) && aod::jcluster::eta > clusterEtaMin && aod::jcluster::eta < clusterEtaMax && aod::jcluster::phi >= clusterPhiMin && aod::jcluster::phi <= clusterPhiMax && aod::jcluster::energy >= clusterEnergyMin && aod::jcluster::time > clusterTimeMin && aod::jcluster::time < clusterTimeMax && (clusterRejectExotics && aod::jcluster::isExotic != true)); @@ -277,7 +286,7 @@ struct JetFinderFullQATask { { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jet.pt() > pTHatMaxMCD * pTHat) { + if (jet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { return; } registry.fill(HIST("h_jet_phat_weighted"), pTHat, weight); @@ -327,7 +336,7 @@ struct JetFinderFullQATask { { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jet.pt() > pTHatMaxMCP * pTHat) { + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { return; } registry.fill(HIST("h_jet_phat_part_weighted"), pTHat, weight); @@ -362,7 +371,7 @@ struct JetFinderFullQATask { { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jetBase.pt() > pTHatMaxMCD * pTHat) { + if (jetBase.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { return; } @@ -435,6 +444,10 @@ struct JetFinderFullQATask { template void fillTrackHistograms(T const& tracks, U const& clusters, float weight = 1.0) { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (pTHat < pTHatAbsoluteMin) { + return; + } for (auto const& track : tracks) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; @@ -467,7 +480,7 @@ struct JetFinderFullQATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality()); + fillHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetFinderFullQATask, processJetsData, "jet finder HF QA data", false); @@ -481,7 +494,7 @@ struct JetFinderFullQATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality()); + fillHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetFinderFullQATask, processJetsMCD, "jet finder HF QA mcd", false); @@ -495,7 +508,7 @@ struct JetFinderFullQATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality(), jet.eventWeight()); + fillHistograms(jet, collision.centFT0M(), jet.eventWeight()); } } PROCESS_SWITCH(JetFinderFullQATask, processJetsMCDWeighted, "jet finder HF QA mcd on weighted events", false); @@ -566,7 +579,9 @@ struct JetFinderFullQATask { void processMCCollisionsWeighted(aod::JetMcCollision const& collision) { - + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } registry.fill(HIST("h_collision_eventweight_part"), collision.weight()); } PROCESS_SWITCH(JetFinderFullQATask, processMCCollisionsWeighted, "collision QA for weighted events", false); @@ -575,23 +590,29 @@ struct JetFinderFullQATask { soa::Filtered const& tracks, soa::Filtered const& clusters) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } registry.fill(HIST("h_collisions"), 0.5); - registry.fill(HIST("h_centrality_collisions"), collision.centrality(), 0.5); + registry.fill(HIST("h_centrality_collisions"), collision.centFT0M(), 0.5); if (!jetderiveddatautilities::eventEMCAL(collision)) { return; } registry.fill(HIST("h_collisions"), 1.5); - registry.fill(HIST("h_centrality_collisions"), collision.centrality(), 1.5); + registry.fill(HIST("h_centrality_collisions"), collision.centFT0M(), 1.5); fillTrackHistograms(tracks, clusters); } PROCESS_SWITCH(JetFinderFullQATask, processTracks, "QA for charged tracks", false); - void processTracksWeighted(soa::Join::iterator const& collision, + void processTracksWeighted(soa::Join::iterator const& collision, aod::JMcCollisions const&, soa::Filtered const& tracks, soa::Filtered const& clusters) { float eventWeight = collision.mcCollision().weight(); + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); if (!jetderiveddatautilities::eventEMCAL(collision)) { diff --git a/PWGJE/Tasks/jetFinderHFQA.cxx b/PWGJE/Tasks/jetFinderHFQA.cxx index 36cf4d149d8..fee889a62ea 100644 --- a/PWGJE/Tasks/jetFinderHFQA.cxx +++ b/PWGJE/Tasks/jetFinderHFQA.cxx @@ -13,31 +13,34 @@ // /// \author Nima Zardoshti -#include +#include "RecoDecay.h" + +#include "PWGHF/Core/HfHelper.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/Core/JetHFUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" -#include "CommonConstants/PhysicsConstants.h" #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include -#include "PWGHF/Core/HfHelper.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" - -#include "PWGJE/DataModel/Jet.h" +#include +#include +#include -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetHFUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" +#include +#include +#include +#include +#include +#include -#include "EventFiltering/filterTables.h" +#include using namespace o2; using namespace o2::analysis; @@ -68,7 +71,9 @@ struct JetFinderHFQATask { Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; + Configurable pTHatAbsoluteMin{"pTHatAbsoluteMin", -99.0, "minimum value of pTHat"}; Configurable randomConeR{"randomConeR", 0.4, "size of random Cone for estimating background fluctuations"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "flag to choose to reject min. bias gap events; jet-level rejection applied at the jet finder level, here rejection is applied for collision and track process functions"}; HfHelper hfHelper; std::vector filledJetR_Both; @@ -79,7 +84,7 @@ struct JetFinderHFQATask { std::vector filledJetHFR_High; std::vector jetRadiiValues; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; std::vector jetPtBins; @@ -87,7 +92,7 @@ struct JetFinderHFQATask { void init(o2::framework::InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); jetRadiiValues = (std::vector)jetRadii; @@ -480,14 +485,17 @@ struct JetFinderHFQATask { using JetTableMCPMatchedWeightedJoined = soa::Join; Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); - Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); // Filter candidateCutsD0 = (aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar); // Filter candidateCutsLc = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLcToPKPi || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLcToPiPK); // Filter candidateCutsBplus = (aod::hf_sel_candidate_bplus::isSelBplusToD0Pi >= selectionFlagBplus); PresliceOptional> perD0CandidateTracks = aod::bkgd0::candidateId; + PresliceOptional> perDplusCandidateTracks = aod::bkgdplus::candidateId; + PresliceOptional> perDstarCandidateTracks = aod::bkgdstar::candidateId; PresliceOptional> perLcCandidateTracks = aod::bkglc::candidateId; + PresliceOptional> perB0CandidateTracks = aod::bkgb0::candidateId; PresliceOptional> perBplusCandidateTracks = aod::bkgbplus::candidateId; PresliceOptional> perDielectronCandidateTracks = aod::bkgdielectron::candidateId; @@ -526,7 +534,7 @@ struct JetFinderHFQATask { { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jet.pt() > pTHatMaxMCD * pTHat) { + if (jet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { return; } registry.fill(HIST("h_jet_phat_weighted"), pTHat, weight); @@ -655,7 +663,7 @@ struct JetFinderHFQATask { { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jet.pt() > pTHatMaxMCP * pTHat) { + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { return; } registry.fill(HIST("h_jet_phat_part_weighted"), pTHat, weight); @@ -697,7 +705,7 @@ struct JetFinderHFQATask { { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jetBase.pt() > pTHatMaxMCD * pTHat) { + if (jetBase.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { return; } auto candidateBasePt = 0.0; @@ -929,12 +937,16 @@ struct JetFinderHFQATask { template void fillTrackHistograms(T const& collision, U const& tracks, float weight = 1.0) { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (pTHat < pTHatAbsoluteMin) { + return; + } for (auto const& track : tracks) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } - registry.fill(HIST("h3_centrality_track_pt_track_phi"), collision.centrality(), track.pt(), track.phi(), weight); - registry.fill(HIST("h3_centrality_track_pt_track_eta"), collision.centrality(), track.pt(), track.eta(), weight); + registry.fill(HIST("h3_centrality_track_pt_track_phi"), collision.centFT0M(), track.pt(), track.phi(), weight); + registry.fill(HIST("h3_centrality_track_pt_track_eta"), collision.centFT0M(), track.pt(), track.eta(), weight); registry.fill(HIST("h3_track_pt_track_eta_track_phi"), track.pt(), track.eta(), track.phi(), weight); } } @@ -943,7 +955,7 @@ struct JetFinderHFQATask { void randomCone(T const& collision, U const& jets, V const& candidates, M const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto const& candidate : candidates) { @@ -960,7 +972,7 @@ struct JetFinderHFQATask { } } } - registry.fill(HIST("h2_centrality_rhorandomcone"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * candidate.rho()); + registry.fill(HIST("h2_centrality_rhorandomcone"), collision.centFT0M(), randomConePt - M_PI * randomConeR * randomConeR * candidate.rho()); // removing the leading jet from the random cone if (jets.size() > 0) { // if there are no jets in the acceptance (from the jetfinder cuts) then there can be no leading jet @@ -988,7 +1000,7 @@ struct JetFinderHFQATask { } } } - registry.fill(HIST("h2_centrality_rhorandomconewithoutleadingjet"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * candidate.rho()); + registry.fill(HIST("h2_centrality_rhorandomconewithoutleadingjet"), collision.centFT0M(), randomConePt - M_PI * randomConeR * randomConeR * candidate.rho()); break; // currently only fills it for the first candidate in the event (not pT ordered). Jet is pT ordered so results for excluding leading jet might not be as expected } } @@ -1007,7 +1019,7 @@ struct JetFinderHFQATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality()); + fillHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetFinderHFQATask, processJetsData, "jet finder HF QA data", false); @@ -1025,7 +1037,7 @@ struct JetFinderHFQATask { continue; } auto const candidate = jet.template candidates_first_as>(); - fillRhoAreaSubtractedHistograms(jet, collision.centrality(), candidate.rho()); + fillRhoAreaSubtractedHistograms(jet, collision.centFT0M(), candidate.rho()); } } PROCESS_SWITCH(JetFinderHFQATask, processJetsRhoAreaSubData, "jet finder HF QA for rho-area subtracted jets", false); @@ -1043,7 +1055,7 @@ struct JetFinderHFQATask { continue; } auto const candidate = jet.template candidates_first_as>(); - fillRhoAreaSubtractedHistograms(jet, collision.centrality(), candidate.rho()); + fillRhoAreaSubtractedHistograms(jet, collision.centFT0M(), candidate.rho()); } } PROCESS_SWITCH(JetFinderHFQATask, processJetsRhoAreaSubMCD, "jet finder HF QA for rho-area subtracted mcd jets", false); @@ -1057,7 +1069,7 @@ struct JetFinderHFQATask { if (!isAcceptedJet(jet)) { continue; } - fillEventWiseConstituentSubtractedHistograms(jet, collision.centrality()); + fillEventWiseConstituentSubtractedHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetFinderHFQATask, processEvtWiseConstSubJetsData, "jet finder HF QA for eventwise constituent-subtracted jets data", false); @@ -1088,7 +1100,7 @@ struct JetFinderHFQATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality()); + fillHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetFinderHFQATask, processJetsMCD, "jet finder HF QA mcd", false); @@ -1102,7 +1114,7 @@ struct JetFinderHFQATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality(), jet.eventWeight()); + fillHistograms(jet, collision.centFT0M(), jet.eventWeight()); } } PROCESS_SWITCH(JetFinderHFQATask, processJetsMCDWeighted, "jet finder HF QA mcd on weighted events", false); @@ -1173,6 +1185,9 @@ struct JetFinderHFQATask { void processMCCollisionsWeighted(aod::JetMcCollision const& collision) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } registry.fill(HIST("h_collision_eventweight_part"), collision.weight()); } PROCESS_SWITCH(JetFinderHFQATask, processMCCollisionsWeighted, "collision QA for weighted events", false); @@ -1187,7 +1202,7 @@ struct JetFinderHFQATask { return; } registry.fill(HIST("h_collision_trigger_events"), 1.5); // all events with z vertex cut - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collision_trigger_events"), 2.5); // events with sel8() @@ -1353,7 +1368,7 @@ struct JetFinderHFQATask { return; } registry.fill(HIST("h_collision_hftrigger_events"), 1.5); // all events with z vertex cut - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collision_hftrigger_events"), 2.5); // events with sel8() @@ -1463,13 +1478,16 @@ struct JetFinderHFQATask { void processTracks(soa::Filtered::iterator const& collision, soa::Filtered const& tracks) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } registry.fill(HIST("h_collisions"), 0.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collisions"), 1.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 1.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 1.5); fillTrackHistograms(collision, tracks); } PROCESS_SWITCH(JetFinderHFQATask, processTracks, "QA for charged tracks", false); @@ -1479,9 +1497,12 @@ struct JetFinderHFQATask { soa::Filtered const& tracks) { float eventWeight = collision.mcCollision().weight(); + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collisions"), 1.5); @@ -1494,14 +1515,17 @@ struct JetFinderHFQATask { CandidateTableData const& candidates, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto const& candidate : candidates) { - for (auto const& track : jetcandidateutilities::slicedPerCandidate(tracks, candidate, perD0CandidateTracks, perLcCandidateTracks, perBplusCandidateTracks, perDielectronCandidateTracks)) { - registry.fill(HIST("h3_centrality_track_pt_track_phi_eventwiseconstituentsubtracted"), collision.centrality(), track.pt(), track.phi()); - registry.fill(HIST("h3_centrality_track_pt_track_eta_eventwiseconstituentsubtracted"), collision.centrality(), track.pt(), track.eta()); + for (auto const& track : jetcandidateutilities::slicedPerCandidate(tracks, candidate, perD0CandidateTracks, perDplusCandidateTracks, perDstarCandidateTracks, perLcCandidateTracks, perB0CandidateTracks, perBplusCandidateTracks, perDielectronCandidateTracks)) { + registry.fill(HIST("h3_centrality_track_pt_track_phi_eventwiseconstituentsubtracted"), collision.centFT0M(), track.pt(), track.phi()); + registry.fill(HIST("h3_centrality_track_pt_track_eta_eventwiseconstituentsubtracted"), collision.centFT0M(), track.pt(), track.eta()); registry.fill(HIST("h3_track_pt_track_eta_track_phi_eventwiseconstituentsubtracted"), track.pt(), track.eta(), track.phi()); } break; // currently only fills it for the first candidate in the event (not pT ordered) @@ -1511,7 +1535,10 @@ struct JetFinderHFQATask { void processRho(aod::JetCollision const& collision, soa::Join const& candidates, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto const& candidate : candidates) { @@ -1521,11 +1548,11 @@ struct JetFinderHFQATask { nTracks++; } } - registry.fill(HIST("h2_centrality_ntracks"), collision.centrality(), nTracks); + registry.fill(HIST("h2_centrality_ntracks"), collision.centFT0M(), nTracks); registry.fill(HIST("h2_ntracks_rho"), nTracks, candidate.rho()); registry.fill(HIST("h2_ntracks_rhom"), nTracks, candidate.rhoM()); - registry.fill(HIST("h2_centrality_rho"), collision.centrality(), candidate.rho()); - registry.fill(HIST("h2_centrality_rhom"), collision.centrality(), candidate.rhoM()); + registry.fill(HIST("h2_centrality_rho"), collision.centFT0M(), candidate.rho()); + registry.fill(HIST("h2_centrality_rhom"), collision.centFT0M(), candidate.rhoM()); break; // currently only fills it for the first candidate in the event (not pT ordered) } } @@ -1539,6 +1566,9 @@ struct JetFinderHFQATask { void processRandomConeMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, soa::Join const& candidates, soa::Filtered const& tracks) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } randomCone(collision, jets, candidates, tracks); } PROCESS_SWITCH(JetFinderHFQATask, processRandomConeMCD, "QA for random cone estimation of background fluctuations in mcd", false); @@ -1546,12 +1576,15 @@ struct JetFinderHFQATask { void processCandidates(soa::Filtered::iterator const& collision, CandidateTableData const& candidates) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } for (auto const& candidate : candidates) { registry.fill(HIST("h_candidate_invmass"), jetcandidateutilities::getCandidateInvariantMass(candidate)); registry.fill(HIST("h_candidate_pt"), candidate.pt()); registry.fill(HIST("h_candidate_y"), candidate.y()); } - registry.fill(HIST("h2_centrality_ncandidates"), collision.centrality(), candidates.size()); + registry.fill(HIST("h2_centrality_ncandidates"), collision.centFT0M(), candidates.size()); } PROCESS_SWITCH(JetFinderHFQATask, processCandidates, "HF candidate QA", false); }; diff --git a/PWGJE/Tasks/jetFinderLcQA.cxx b/PWGJE/Tasks/jetFinderLcQA.cxx index 311086c86c8..4986d583707 100644 --- a/PWGJE/Tasks/jetFinderLcQA.cxx +++ b/PWGJE/Tasks/jetFinderLcQA.cxx @@ -15,6 +15,16 @@ #include "PWGJE/Tasks/jetFinderHFQA.cxx" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include + +#include + using JetFinderLcQATask = JetFinderHFQATask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/Tasks/jetFinderQA.cxx b/PWGJE/Tasks/jetFinderQA.cxx index 67806db1115..4273efd027c 100644 --- a/PWGJE/Tasks/jetFinderQA.cxx +++ b/PWGJE/Tasks/jetFinderQA.cxx @@ -13,30 +13,34 @@ // /// \author Nima Zardoshti -#include -#include +#include "RecoDecay.h" + +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" +#include +#include +#include +#include -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/DataModel/Jet.h" +#include +#include +#include -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include +#include +#include +#include +#include +#include -#include "EventFiltering/filterTables.h" +#include using namespace o2; using namespace o2::framework; @@ -60,6 +64,7 @@ struct JetFinderQATask { Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; + Configurable pTHatAbsoluteMin{"pTHatAbsoluteMin", -99.0, "minimum value of pTHat"}; Configurable jetPtMax{"jetPtMax", 200., "set jet pT bin max"}; Configurable jetEtaMin{"jetEtaMin", -99.0, "minimum jet pseudorapidity"}; Configurable jetEtaMax{"jetEtaMax", 99.0, "maximum jet pseudorapidity"}; @@ -72,13 +77,16 @@ struct JetFinderQATask { Configurable checkMcCollisionIsMatched{"checkMcCollisionIsMatched", false, "0: count whole MCcollisions, 1: select MCcollisions which only have their correspond collisions"}; Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; Configurable trackOccupancyInTimeRangeMin{"trackOccupancyInTimeRangeMin", -999999, "minimum occupancy of tracks in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "flag to choose to reject min. bias gap events; jet-level rejection applied at the jet finder level, here rejection is applied for collision and track process functions"}; + Configurable intRateNBins{"intRateNBins", 50, "number of bins for interaction rate axis"}; + Configurable intRateMax{"intRateMax", 50000.0, "maximum value of interaction rate axis"}; std::vector filledJetR_Both; std::vector filledJetR_Low; std::vector filledJetR_High; std::vector jetRadiiValues; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; std::vector jetPtBins; @@ -86,7 +94,7 @@ struct JetFinderQATask { void init(o2::framework::InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); jetRadiiValues = (std::vector)jetRadii; @@ -131,7 +139,10 @@ struct JetFinderQATask { AxisSpec jetEtaAxis = {nBinsEta, jetEtaMin, jetEtaMax, "#eta"}; AxisSpec trackEtaAxis = {nBinsEta, trackEtaMin, trackEtaMax, "#eta"}; + AxisSpec intRateAxis = {intRateNBins, 0., intRateMax, "int. rate (kHz)"}; + if (doprocessJetsData || doprocessJetsMCD || doprocessJetsMCDWeighted) { + registry.add("h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxis}}); registry.add("h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {jetEtaAxis}}); registry.add("h_jet_phi", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); @@ -154,6 +165,7 @@ struct JetFinderQATask { registry.add("h_jet_ptcut", "p_{T} cut;p_{T,jet} (GeV/#it{c});N;entries", {HistType::kTH2F, {{300, 0, 300}, {20, 0, 5}}}); registry.add("h_jet_phat_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); registry.add("h3_centrality_occupancy_jet_pt", "centrality; occupancy; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH3F, {{120, -10.0, 110.0}, {60, 0, 30000}, jetPtAxis}}); + registry.add("h2_intrate_jet_pt", "int. rate vs #it{p}_{T,jet}; int. rate (kHz); #it{p}_{T,jet} (GeV/#it{c});", {HistType::kTH2F, {intRateAxis, jetPtAxis}}); } if (doprocessJetsRhoAreaSubData || doprocessJetsRhoAreaSubMCD) { @@ -177,6 +189,7 @@ struct JetFinderQATask { registry.add("h3_jet_r_jet_pt_track_phi_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {160, -1.0, 7.}}}); registry.add("h3_jet_r_jet_pt_jet_pt_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, jetPtAxisRhoAreaSub}}); registry.add("h3_centrality_occupancy_jet_pt_rhoareasubtracted", "centrality; occupancy; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH3F, {{120, -10.0, 110.0}, {60, 0, 30000}, jetPtAxisRhoAreaSub}}); + registry.add("h2_intrate_jet_pt_rhoareasubtracted", "int. rate vs #it{p}_{T,jet}; int. rate (kHz); #it{p}_{T,jet} (GeV/#it{c});", {HistType::kTH2F, {intRateAxis, jetPtAxisRhoAreaSub}}); } if (doprocessEvtWiseConstSubJetsData || doprocessEvtWiseConstSubJetsMCD) { @@ -197,6 +210,7 @@ struct JetFinderQATask { registry.add("h3_jet_r_jet_pt_track_pt_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, jetPtAxis}}); registry.add("h3_jet_r_jet_pt_track_eta_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, trackEtaAxis}}); registry.add("h3_jet_r_jet_pt_track_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h2_intrate_jet_pt_eventwiseconstituentsubtracted", "int. rate vs #it{p}_{T,jet}; int. rate (kHz); #it{p}_{T,jet} (GeV/#it{c});", {HistType::kTH2F, {intRateAxis, jetPtAxis}}); } if (doprocessRho) { @@ -238,33 +252,45 @@ struct JetFinderQATask { registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeo", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); registry.add("h3_jet_r_jet_ntracks_tag_jet_ntracks_base_matchedgeo", "#it{R}_{jet};N_{jet tracks}^{tag};N_{jet tracks}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#it{p}_{T,jet}^{tag} (GeV/#it{c}) - #it{p}_{T,jet}^{base} (GeV/#it{c})) / #it{p}_{T,jet}^{tag} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1000, -5.0, 2.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#eta_{jet}^{tag} - #eta_{jet}^{base}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#varphi_{jet}^{tag} - #varphi_{jet}^{base}) / #varphi_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1000, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag} - #eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag} - #varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_tag_leadingtrack_pt_diff_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#it{p}{T,LT}^{tag} - #it{p}{T,LT}^{base}) / #it{p}{T,LT}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_tag_leadingtrack_fraction_diff_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#it{p}{T,LT}^{tag} - #it{p}{T,LT}^{base}) / #it{p}{T,LT}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); registry.add("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedgeo", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, jetEtaAxis, jetEtaAxis}}); registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedgeo", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag}; #varphi_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, {160, -1.0, 7.}, {160, -1.0, 7.}}}); registry.add("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedgeo", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); N_{jet tracks}^{tag}; N_{jet tracks}^{base}", {HistType::kTH3F, {jetPtAxis, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); + registry.add("h3_jet_pt_tag_jet_leadingtrack_pt_tag_jet_leadingtrack_pt_base_matchedgeo", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #it{p}_{T,LT}^{tag}; #it{p}_{T,LT}^{tag}", {HistType::kTH3F, {jetPtAxis, {200, 0., 100.}, {200, 0., 100.}}}); + registry.add("h3_jet_pt_tag_jet_leadingtrack_fraction_tag_jet_leadingtrack_fraction_base_matchedgeo", ";#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,LT}^{tag} / #it{p}_{T,jet}^{tag} ; #it{p}_{T,LT}^{tag} / #it{p}_{T,jet}^{base}", {HistType::kTH3F, {jetPtAxis, {50, 0., 1.}, {50, 0., 1.}}}); registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedpt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, jetPtAxis}}); registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedpt", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetEtaAxis, jetEtaAxis}}); registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedpt", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); registry.add("h3_jet_r_jet_ntracks_tag_jet_ntracks_base_matchedpt", "#it{R}_{jet};N_{jet tracks}^{tag};N_{jet tracks}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedpt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#it{p}_{T,jet}^{tag} (GeV/#it{c}) - #it{p}_{T,jet}^{base} (GeV/#it{c})) / #it{p}_{T,jet}^{tag} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedpt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#eta_{jet}^{tag} - #eta_{jet}^{base}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedpt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#varphi_{jet}^{tag} - #varphi_{jet}^{base}) / #varphi_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1000, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedpt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag} - #eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedpt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag} - #varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_tag_leadingtrack_pt_diff_matchedpt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#it{p}{T,LT}^{tag} - #it{p}{T,LT}^{base}) / #it{p}{T,LT}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_tag_leadingtrack_fraction_diff_matchedpt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#it{p}{T,LT}^{tag} - #it{p}{T,LT}^{base}) / #it{p}{T,LT}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); registry.add("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedpt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, jetEtaAxis, jetEtaAxis}}); registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedpt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag}; #varphi_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, {160, -1.0, 7.}, {160, -1.0, 7.}}}); registry.add("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedpt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); N_{jet tracks}^{tag}; N_{jet tracks}^{base}", {HistType::kTH3F, {jetPtAxis, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); + registry.add("h3_jet_pt_tag_jet_leadingtrack_pt_tag_jet_leadingtrack_pt_base_matchedpt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #it{p}_{T,LT}^{tag}; #it{p}_{T,LT}^{tag}", {HistType::kTH3F, {jetPtAxis, {200, 0., 100.}, {200, 0., 100.}}}); + registry.add("h3_jet_pt_tag_jet_leadingtrack_fraction_tag_jet_leadingtrack_fraction_base_matchedpt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,LT}^{tag} / #it{p}_{T,jet}^{tag} ; #it{p}_{T,LT}^{tag} / #it{p}_{T,jet}^{base}", {HistType::kTH3F, {jetPtAxis, {50, 0., 1.}, {50, 0., 1.}}}); registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedgeopt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, jetPtAxis}}); registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeopt", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetEtaAxis, jetEtaAxis}}); registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeopt", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); registry.add("h3_jet_r_jet_ntracks_tag_jet_ntracks_base_matchedgeopt", "#it{R}_{jet};N_{jet tracks}^{tag};N_{jet tracks}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedgeopt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#it{p}_{T,jet}^{tag} (GeV/#it{c}) - #it{p}_{T,jet}^{base} (GeV/#it{c})) / #it{p}_{T,jet}^{tag} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeopt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#eta_{jet}^{tag} - #eta_{jet}^{base}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeopt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#varphi_{jet}^{tag} - #varphi_{jet}^{base}) / #varphi_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1000, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeopt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag} - #eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeopt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag} - #varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_tag_leadingtrack_pt_diff_matchedgeopt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#it{p}{T,LT}^{tag} - #it{p}{T,LT}^{base}) / #it{p}{T,LT}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_tag_leadingtrack_fraction_diff_matchedgeopt", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#it{p}{T,LT}^{tag} - #it{p}{T,LT}^{base}) / #it{p}{T,LT}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {100, -1.0, 1.0}}}); registry.add("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedgeopt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, jetEtaAxis, jetEtaAxis}}); registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedgeopt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag}; #varphi_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, {160, -1.0, 7.}, {160, -1.0, 7.}}}); registry.add("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedgeopt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); N_{jet tracks}^{tag}; N_{jet tracks}^{base}", {HistType::kTH3F, {jetPtAxis, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); + registry.add("h3_jet_pt_tag_jet_leadingtrack_pt_tag_jet_leadingtrack_pt_base_matchedgeopt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #it{p}_{T,LT}^{tag}; #it{p}_{T,LT}^{tag}", {HistType::kTH3F, {jetPtAxis, {200, 0., 100.}, {200, 0., 100.}}}); + registry.add("h3_jet_pt_tag_jet_leadingtrack_fraction_tag_jet_leadingtrack_fraction_base_matchedgeopt", ";#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,LT}^{tag} / #it{p}_{T,jet}^{tag} ; #it{p}_{T,LT}^{tag} / #it{p}_{T,jet}^{base}", {HistType::kTH3F, {jetPtAxis, {50, 0., 1.}, {50, 0., 1.}}}); registry.add("h3_ptcut_jet_pt_tag_jet_pt_base_matchedgeo", "N;#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{20, 0., 5.}, {300, 0., 300.}, {300, 0., 300.}}}); } @@ -322,11 +348,31 @@ struct JetFinderQATask { if (doprocessMCCollisionsWeighted) { AxisSpec weightAxis = {{VARIABLE_WIDTH, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1.0, 10.0}, "weights"}; registry.add("h_collision_eventweight_part", "event weight;event weight;entries", {HistType::kTH1F, {weightAxis}}); + registry.add("h_accepted", "No. of Generated Events;No. of Generated Events;entries", {HistType::kTH1F, {{5000, 0., 5000.}}}); + registry.add("h_attempted", "No. of Attempted Events;No. of Attempted Events;entries", {HistType::kTH1F, {{5000, 0., 5000.}}}); + registry.add("h_xsecGen", "Cross section in pb; Cross section in pb; entries", {HistType::kTH1F, {{200000, 0., 2e11}}}); + registry.add("h_xsecErr", "Error associated with the cross section", {HistType::kTH1F, {{200000, 0., 2e11}}}); + registry.add("h_xsecGenSum", "Summed Cross section per collision in pb; Summed Cross section per collision in pb; entries", {HistType::kTH1F, {{1, 0., 1.}}}); + registry.add("h_xsecGenSumWeighted", "Summed Cross section per collision in pb with weights; Summed Cross section per collision in pb with weights; entries", {HistType::kTH1F, {{1, 0., 1.}}}); + registry.add("h_xsecErrSum", "Summed Cross section error per collision in pb; Summed Cross section error per collision in pb; entries", {HistType::kTH1F, {{1, 0., 1.}}}); + registry.add("h_xsecErrSumWeighted", "Summed Cross section error per collision in pb with weights; Summed Cross section error per collision in pb with weights; entries", {HistType::kTH1F, {{1, 0., 1.}}}); + } + + AxisSpec occupancyAxis = {142, -1.5, 14000.5, "occupancy"}; + AxisSpec nTracksAxis = {16001, -1., 16000, "n tracks"}; + + if (doprocessOccupancyQA) { + registry.add("h2_occupancy_ntracksall_presel", "occupancy vs N_{tracks}; occupancy; N_{tracks}", {HistType::kTH2I, {occupancyAxis, nTracksAxis}}); + registry.add("h2_occupancy_ntracksall_postsel", "occupancy vs N_{tracks}; occupancy; N_{tracks}", {HistType::kTH2I, {occupancyAxis, nTracksAxis}}); + registry.add("h2_occupancy_ntrackssel_presel", "occupancy vs N_{tracks}; occupancy; N_{tracks}", {HistType::kTH2I, {occupancyAxis, nTracksAxis}}); + registry.add("h2_occupancy_ntrackssel_postsel", "occupancy vs N_{tracks}; occupancy; N_{tracks}", {HistType::kTH2I, {occupancyAxis, nTracksAxis}}); + registry.add("h2_occupancy_ntracksselptetacuts_presel", "occupancy vs N_{tracks}; occupancy; N_{tracks}", {HistType::kTH2I, {occupancyAxis, nTracksAxis}}); + registry.add("h2_occupancy_ntracksselptetacuts_postsel", "occupancy vs N_{tracks}; occupancy; N_{tracks}", {HistType::kTH2I, {occupancyAxis, nTracksAxis}}); } } Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); - Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); PresliceUnsorted> CollisionsPerMCPCollision = aod::jmccollisionlb::mcCollisionId; template @@ -377,11 +423,11 @@ struct JetFinderQATask { } template - void fillHistograms(T const& jet, float centrality, float occupancy, float weight = 1.0) + void fillHistograms(T const& jet, float centrality, float occupancy, float hadronicRate, float weight = 1.0) { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jet.pt() > pTHatMaxMCD * pTHat) { + if (jet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { return; } registry.fill(HIST("h_jet_phat"), pTHat); @@ -397,6 +443,7 @@ struct JetFinderQATask { registry.fill(HIST("h2_centrality_jet_phi"), centrality, jet.phi(), weight); registry.fill(HIST("h2_centrality_jet_ntracks"), centrality, jet.tracksIds().size(), weight); registry.fill(HIST("h3_centrality_occupancy_jet_pt"), centrality, occupancy, jet.pt(), weight); + registry.fill(HIST("h2_intrate_jet_pt"), hadronicRate, jet.pt(), weight); } registry.fill(HIST("h3_jet_r_jet_pt_centrality"), jet.r() / 100.0, jet.pt(), centrality, weight); @@ -429,6 +476,7 @@ struct JetFinderQATask { registry.fill(HIST("h2_centrality_jet_phi_rhoareasubtracted"), centrality, jet.phi(), weight); registry.fill(HIST("h2_centrality_jet_ntracks_rhoareasubtracted"), centrality, jet.tracksIds().size(), weight); } + registry.fill(HIST("h2_intrate_jet_pt_rhoareasubtracted"), jet.collision().hadronicRate(), jet.pt() - (rho * jet.area()), weight); } registry.fill(HIST("h3_jet_r_jet_pt_centrality_rhoareasubtracted"), jet.r() / 100.0, jet.pt() - (rho * jet.area()), centrality, weight); @@ -459,6 +507,7 @@ struct JetFinderQATask { registry.fill(HIST("h2_centrality_jet_eta_eventwiseconstituentsubtracted"), centrality, jet.eta(), weight); registry.fill(HIST("h2_centrality_jet_phi_eventwiseconstituentsubtracted"), centrality, jet.phi(), weight); registry.fill(HIST("h2_centrality_jet_ntracks_eventwiseconstituentsubtracted"), centrality, jet.tracksIds().size(), weight); + registry.fill(HIST("h2_intrate_jet_pt_eventwiseconstituentsubtracted"), jet.collision().hadronicRate(), jet.pt(), weight); } registry.fill(HIST("h3_jet_r_jet_pt_centrality_eventwiseconstituentsubtracted"), jet.r() / 100.0, jet.pt(), centrality, weight); @@ -481,7 +530,7 @@ struct JetFinderQATask { { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jet.pt() > pTHatMaxMCP * pTHat) { + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { return; } registry.fill(HIST("h_jet_phat_part"), pTHat); @@ -508,10 +557,10 @@ struct JetFinderQATask { } template - void fillMatchedHistograms(T const& jetBase, float weight = 1.0) + void fillMatchedHistograms(T const& jetBase, float leadingTrackPtBase, float weight = 1.0) { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jetBase.pt() > pTHatMaxMCD * pTHat) { + if (jetBase.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { return; } @@ -525,8 +574,16 @@ struct JetFinderQATask { registry.fill(HIST("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeo"), jetBase.r() / 100.0, jetTag.phi(), jetBase.phi(), weight); registry.fill(HIST("h3_jet_r_jet_ntracks_tag_jet_ntracks_base_matchedgeo"), jetBase.r() / 100.0, jetTag.tracksIds().size(), jetBase.tracksIds().size(), weight); registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedgeo"), jetBase.r() / 100.0, jetTag.pt(), (jetTag.pt() - jetBase.pt()) / jetTag.pt(), weight); - registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeo"), jetBase.r() / 100.0, jetTag.pt(), (jetTag.eta() - jetBase.eta()) / jetTag.eta(), weight); - registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeo"), jetBase.r() / 100.0, jetTag.pt(), (jetTag.phi() - jetBase.phi()) / jetTag.phi(), weight); + registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeo"), jetBase.r() / 100.0, jetTag.pt(), jetTag.eta() - jetBase.eta(), weight); + registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeo"), jetBase.r() / 100.0, jetTag.pt(), jetTag.phi() - jetBase.phi(), weight); + float leadingTrackPtTag = 0.; + for (auto& constituent : jetTag.template tracks_as()) { + if (constituent.pt() > leadingTrackPtTag) { + leadingTrackPtTag = constituent.pt(); + } + } + registry.fill(HIST("h3_jet_r_jet_pt_tag_leadingtrack_pt_diff_matchedgeo"), jetBase.r() / 100.0, jetTag.pt(), (leadingTrackPtTag - leadingTrackPtBase) / leadingTrackPtTag, weight); + registry.fill(HIST("h3_jet_r_jet_pt_tag_leadingtrack_fraction_diff_matchedgeo"), jetBase.r() / 100.0, jetTag.pt(), (leadingTrackPtTag / jetTag.pt()) - (leadingTrackPtBase / jetBase.pt()), weight); for (int N = 1; N < 21; N++) { if (jetBase.pt() < N * 0.25 * pTHat && jetTag.pt() < N * 0.25 * pTHat) { @@ -538,6 +595,8 @@ struct JetFinderQATask { registry.fill(HIST("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedgeo"), jetTag.pt(), jetTag.eta(), jetBase.eta(), weight); registry.fill(HIST("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedgeo"), jetTag.pt(), jetTag.phi(), jetBase.phi(), weight); registry.fill(HIST("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedgeo"), jetTag.pt(), jetTag.tracksIds().size(), jetBase.tracksIds().size(), weight); + registry.fill(HIST("h3_jet_pt_tag_jet_leadingtrack_pt_tag_jet_leadingtrack_pt_base_matchedgeo"), jetTag.pt(), leadingTrackPtTag, leadingTrackPtBase, weight); + registry.fill(HIST("h3_jet_pt_tag_jet_leadingtrack_fraction_tag_jet_leadingtrack_fraction_base_matchedgeo"), jetTag.pt(), leadingTrackPtTag / jetTag.pt(), leadingTrackPtBase / jetBase.pt(), weight); } } } @@ -551,13 +610,23 @@ struct JetFinderQATask { registry.fill(HIST("h3_jet_r_jet_phi_tag_jet_phi_base_matchedpt"), jetBase.r() / 100.0, jetTag.phi(), jetBase.phi(), weight); registry.fill(HIST("h3_jet_r_jet_ntracks_tag_jet_ntracks_base_matchedpt"), jetBase.r() / 100.0, jetTag.tracksIds().size(), jetBase.tracksIds().size(), weight); registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedpt"), jetBase.r() / 100.0, jetTag.pt(), (jetTag.pt() - jetBase.pt()) / jetTag.pt(), weight); - registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedpt"), jetBase.r() / 100.0, jetTag.pt(), (jetTag.eta() - jetBase.eta()) / jetTag.eta(), weight); - registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedpt"), jetBase.r() / 100.0, jetTag.pt(), (jetTag.phi() - jetBase.phi()) / jetTag.phi(), weight); + registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedpt"), jetBase.r() / 100.0, jetTag.pt(), jetTag.eta() - jetBase.eta(), weight); + registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedpt"), jetBase.r() / 100.0, jetTag.pt(), jetTag.phi() - jetBase.phi(), weight); + float leadingTrackPtTag = 0.; + for (auto& constituent : jetTag.template tracks_as()) { + if (constituent.pt() > leadingTrackPtTag) { + leadingTrackPtTag = constituent.pt(); + } + } + registry.fill(HIST("h3_jet_r_jet_pt_tag_leadingtrack_pt_diff_matchedpt"), jetBase.r() / 100.0, jetTag.pt(), (leadingTrackPtTag - leadingTrackPtBase) / leadingTrackPtTag, weight); + registry.fill(HIST("h3_jet_r_jet_pt_tag_leadingtrack_fraction_diff_matchedpt"), jetBase.r() / 100.0, jetTag.pt(), (leadingTrackPtTag / jetTag.pt()) - (leadingTrackPtBase / jetBase.pt()), weight); if (jetBase.r() == round(selectedJetsRadius * 100.0f)) { registry.fill(HIST("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedpt"), jetTag.pt(), jetTag.eta(), jetBase.eta(), weight); registry.fill(HIST("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedpt"), jetTag.pt(), jetTag.phi(), jetBase.phi(), weight); registry.fill(HIST("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedpt"), jetTag.pt(), jetTag.tracksIds().size(), jetBase.tracksIds().size(), weight); + registry.fill(HIST("h3_jet_pt_tag_jet_leadingtrack_pt_tag_jet_leadingtrack_pt_base_matchedpt"), jetTag.pt(), leadingTrackPtTag, leadingTrackPtBase, weight); + registry.fill(HIST("h3_jet_pt_tag_jet_leadingtrack_fraction_tag_jet_leadingtrack_fraction_base_matchedpt"), jetTag.pt(), leadingTrackPtTag / jetTag.pt(), leadingTrackPtBase / jetBase.pt(), weight); } } } @@ -575,13 +644,23 @@ struct JetFinderQATask { registry.fill(HIST("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeopt"), jetBase.r() / 100.0, jetTag.phi(), jetBase.phi(), weight); registry.fill(HIST("h3_jet_r_jet_ntracks_tag_jet_ntracks_base_matchedgeopt"), jetBase.r() / 100.0, jetTag.tracksIds().size(), jetBase.tracksIds().size(), weight); registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedgeopt"), jetBase.r() / 100.0, jetTag.pt(), (jetTag.pt() - jetBase.pt()) / jetTag.pt(), weight); - registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeopt"), jetBase.r() / 100.0, jetTag.pt(), (jetTag.eta() - jetBase.eta()) / jetTag.eta(), weight); - registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeopt"), jetBase.r() / 100.0, jetTag.pt(), (jetTag.phi() - jetBase.phi()) / jetTag.phi(), weight); + registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeopt"), jetBase.r() / 100.0, jetTag.pt(), jetTag.eta() - jetBase.eta(), weight); + registry.fill(HIST("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeopt"), jetBase.r() / 100.0, jetTag.pt(), jetTag.phi() - jetBase.phi(), weight); + float leadingTrackPtTag = 0.; + for (auto& constituent : jetTag.template tracks_as()) { + if (constituent.pt() > leadingTrackPtTag) { + leadingTrackPtTag = constituent.pt(); + } + } + registry.fill(HIST("h3_jet_r_jet_pt_tag_leadingtrack_pt_diff_matchedgeopt"), jetBase.r() / 100.0, jetTag.pt(), (leadingTrackPtTag - leadingTrackPtBase) / leadingTrackPtTag, weight); + registry.fill(HIST("h3_jet_r_jet_pt_tag_leadingtrack_fraction_diff_matchedgeopt"), jetBase.r() / 100.0, jetTag.pt(), (leadingTrackPtTag / jetTag.pt()) - (leadingTrackPtBase / jetBase.pt()), weight); if (jetBase.r() == round(selectedJetsRadius * 100.0f)) { registry.fill(HIST("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedgeopt"), jetTag.pt(), jetTag.eta(), jetBase.eta(), weight); registry.fill(HIST("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedgeopt"), jetTag.pt(), jetTag.phi(), jetBase.phi(), weight); registry.fill(HIST("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedgeopt"), jetTag.pt(), jetTag.tracksIds().size(), jetBase.tracksIds().size(), weight); + registry.fill(HIST("h3_jet_pt_tag_jet_leadingtrack_pt_tag_jet_leadingtrack_pt_base_matchedgeopt"), jetTag.pt(), leadingTrackPtTag, leadingTrackPtBase, weight); + registry.fill(HIST("h3_jet_pt_tag_jet_leadingtrack_fraction_tag_jet_leadingtrack_fraction_base_matchedgeopt"), jetTag.pt(), leadingTrackPtTag / jetTag.pt(), leadingTrackPtBase / jetBase.pt(), weight); } } } @@ -591,13 +670,17 @@ struct JetFinderQATask { template void fillTrackHistograms(T const& collision, U const& tracks, float weight = 1.0) { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (pTHat < pTHatAbsoluteMin) { + return; + } for (auto const& track : tracks) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } - registry.fill(HIST("h3_centrality_track_pt_track_phi"), collision.centrality(), track.pt(), track.phi(), weight); - registry.fill(HIST("h3_centrality_track_pt_track_eta"), collision.centrality(), track.pt(), track.eta(), weight); - registry.fill(HIST("h3_centrality_track_pt_track_dcaxy"), collision.centrality(), track.pt(), track.dcaXY(), weight); + registry.fill(HIST("h3_centrality_track_pt_track_phi"), collision.centFT0M(), track.pt(), track.phi(), weight); + registry.fill(HIST("h3_centrality_track_pt_track_eta"), collision.centFT0M(), track.pt(), track.eta(), weight); + registry.fill(HIST("h3_centrality_track_pt_track_dcaxy"), collision.centFT0M(), track.pt(), track.dcaXY(), weight); registry.fill(HIST("h3_track_pt_track_eta_track_phi"), track.pt(), track.eta(), track.phi(), weight); } } @@ -605,7 +688,7 @@ struct JetFinderQATask { template void randomCone(T const& collision, U const& jets, V const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { @@ -624,7 +707,7 @@ struct JetFinderQATask { } } } - registry.fill(HIST("h2_centrality_rhorandomcone"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomcone"), collision.centFT0M(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); // randomised eta,phi for tracks, to assess part of fluctuations coming from statistically independently emitted particles randomConePt = 0; @@ -637,7 +720,7 @@ struct JetFinderQATask { } } } - registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirection"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirection"), collision.centFT0M(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); // removing the leading jet from the random cone if (jets.size() > 0) { // if there are no jets in the acceptance (from the jetfinder cuts) then there can be no leading jet @@ -666,7 +749,7 @@ struct JetFinderQATask { } } - registry.fill(HIST("h2_centrality_rhorandomconewithoutleadingjet"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomconewithoutleadingjet"), collision.centFT0M(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); // randomised eta,phi for tracks, to assess part of fluctuations coming from statistically independently emitted particles, removing tracks from 2 leading jets double randomConePtWithoutOneLeadJet = 0; @@ -685,8 +768,8 @@ struct JetFinderQATask { } } } - registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirectionwithoutoneleadingjets"), collision.centrality(), randomConePtWithoutOneLeadJet - M_PI * randomConeR * randomConeR * collision.rho()); - registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirectionwithouttwoleadingjets"), collision.centrality(), randomConePtWithoutTwoLeadJet - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirectionwithoutoneleadingjets"), collision.centFT0M(), randomConePtWithoutOneLeadJet - M_PI * randomConeR * randomConeR * collision.rho()); + registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirectionwithouttwoleadingjets"), collision.centFT0M(), randomConePtWithoutTwoLeadJet - M_PI * randomConeR * randomConeR * collision.rho()); } void processJetsData(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracks const&) @@ -701,7 +784,7 @@ struct JetFinderQATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange()); + fillHistograms(jet, collision.centFT0M(), collision.trackOccupancyInTimeRange(), collision.hadronicRate()); } } PROCESS_SWITCH(JetFinderQATask, processJetsData, "jet finder QA data", false); @@ -720,7 +803,7 @@ struct JetFinderQATask { if (!isAcceptedJet(jet)) { continue; } - fillRhoAreaSubtractedHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange(), collision.rho()); + fillRhoAreaSubtractedHistograms(jet, collision.centFT0M(), collision.trackOccupancyInTimeRange(), collision.rho()); } } PROCESS_SWITCH(JetFinderQATask, processJetsRhoAreaSubData, "jet finder QA for rho-area subtracted jets", false); @@ -739,7 +822,7 @@ struct JetFinderQATask { if (!isAcceptedJet(jet)) { continue; } - fillRhoAreaSubtractedHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange(), collision.rho()); + fillRhoAreaSubtractedHistograms(jet, collision.centFT0M(), collision.trackOccupancyInTimeRange(), collision.rho()); } } PROCESS_SWITCH(JetFinderQATask, processJetsRhoAreaSubMCD, "jet finder QA for rho-area subtracted mcd jets", false); @@ -756,7 +839,7 @@ struct JetFinderQATask { if (!isAcceptedJet(jet)) { continue; } - fillEventWiseConstituentSubtractedHistograms(jet, collision.centrality()); + fillEventWiseConstituentSubtractedHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetFinderQATask, processEvtWiseConstSubJetsData, "jet finder QA for eventwise constituent-subtracted jets data", false); @@ -773,7 +856,7 @@ struct JetFinderQATask { if (!isAcceptedJet(jet)) { continue; } - fillEventWiseConstituentSubtractedHistograms(jet, collision.centrality()); + fillEventWiseConstituentSubtractedHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetFinderQATask, processEvtWiseConstSubJetsMCD, "jet finder QA for eventwise constituent-subtracted mcd jets", false); @@ -793,7 +876,13 @@ struct JetFinderQATask { if (!isAcceptedJet(jet)) { continue; } - fillMatchedHistograms::iterator, soa::Join>(jet); + float leadingTrackPtBase = 0.; + for (auto& constituent : jet.template tracks_as()) { + if (constituent.pt() > leadingTrackPtBase) { + leadingTrackPtBase = constituent.pt(); + } + } + fillMatchedHistograms::iterator, soa::Join>(jet, leadingTrackPtBase); } } PROCESS_SWITCH(JetFinderQATask, processJetsSubMatched, "jet finder QA matched unsubtracted and constituent subtracted jets", false); @@ -810,7 +899,7 @@ struct JetFinderQATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange()); + fillHistograms(jet, collision.centFT0M(), collision.trackOccupancyInTimeRange(), collision.hadronicRate()); } } PROCESS_SWITCH(JetFinderQATask, processJetsMCD, "jet finder QA mcd", false); @@ -833,7 +922,7 @@ struct JetFinderQATask { registry.fill(HIST("h_jet_ptcut"), jet.pt(), N * 0.25, jet.eventWeight()); } } - fillHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange(), jet.eventWeight()); + fillHistograms(jet, collision.centFT0M(), collision.trackOccupancyInTimeRange(), collision.hadronicRate(), jet.eventWeight()); } } PROCESS_SWITCH(JetFinderQATask, processJetsMCDWeighted, "jet finder QA mcd with weighted events", false); @@ -848,7 +937,7 @@ struct JetFinderQATask { } if (checkMcCollisionIsMatched) { auto collisionspermcpjet = collisions.sliceBy(CollisionsPerMCPCollision, jet.mcCollisionId()); - if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelection)) { + if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelectionBits)) { fillMCPHistograms(jet); } } else { @@ -873,7 +962,7 @@ struct JetFinderQATask { } if (checkMcCollisionIsMatched) { auto collisionspermcpjet = collisions.sliceBy(CollisionsPerMCPCollision, jet.mcCollisionId()); - if (collisionspermcpjet.size() >= 1) { + if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelectionBits)) { fillMCPHistograms(jet, jet.eventWeight()); } } else { @@ -897,7 +986,13 @@ struct JetFinderQATask { if (!isAcceptedJet(mcdjet)) { continue; } - fillMatchedHistograms::iterator, soa::Join>(mcdjet); + float leadingTrackPtBase = 0.; + for (auto& constituent : mcdjet.template tracks_as()) { + if (constituent.pt() > leadingTrackPtBase) { + leadingTrackPtBase = constituent.pt(); + } + } + fillMatchedHistograms::iterator, soa::Join>(mcdjet, leadingTrackPtBase); } } PROCESS_SWITCH(JetFinderQATask, processJetsMCPMCDMatched, "jet finder QA matched mcp and mcd", false); @@ -917,14 +1012,31 @@ struct JetFinderQATask { if (!isAcceptedJet(mcdjet)) { continue; } - fillMatchedHistograms::iterator, soa::Join>(mcdjet, mcdjet.eventWeight()); + float leadingTrackPtBase = 0.; + for (auto& constituent : mcdjet.template tracks_as()) { + if (constituent.pt() > leadingTrackPtBase) { + leadingTrackPtBase = constituent.pt(); + } + } + fillMatchedHistograms::iterator, soa::Join>(mcdjet, leadingTrackPtBase, mcdjet.eventWeight()); } } PROCESS_SWITCH(JetFinderQATask, processJetsMCPMCDMatchedWeighted, "jet finder QA matched mcp and mcd with weighted events", false); void processMCCollisionsWeighted(aod::JetMcCollision const& collision) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } registry.fill(HIST("h_collision_eventweight_part"), collision.weight()); + registry.fill(HIST("h_accepted"), collision.accepted()); + registry.fill(HIST("h_attempted"), collision.attempted()); + registry.fill(HIST("h_xsecGen"), collision.xsectGen()); + registry.fill(HIST("h_xsecErr"), collision.xsectErr()); + registry.fill(HIST("h_xsecGenSum"), 0.5, collision.xsectGen()); + registry.fill(HIST("h_xsecGenSumWeighted"), 0.5, collision.xsectGen() * collision.weight()); + registry.fill(HIST("h_xsecErrSum"), 0.5, collision.xsectErr()); + registry.fill(HIST("h_xsecErrSumWeighted"), 0.5, collision.xsectErr() * collision.weight()); } PROCESS_SWITCH(JetFinderQATask, processMCCollisionsWeighted, "collision QA for weighted events", false); @@ -937,7 +1049,7 @@ struct JetFinderQATask { return; } registry.fill(HIST("h_collision_trigger_events"), 1.5); // all events with z vertex cut - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collision_trigger_events"), 2.5); // events with sel8() @@ -1057,18 +1169,21 @@ struct JetFinderQATask { void processTracks(soa::Filtered::iterator const& collision, soa::Filtered> const& tracks) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } registry.fill(HIST("h_collisions"), 0.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collisions"), 1.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 1.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 1.5); if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } registry.fill(HIST("h_collisions"), 2.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 2.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 2.5); fillTrackHistograms(collision, tracks); } PROCESS_SWITCH(JetFinderQATask, processTracks, "QA for charged tracks", false); @@ -1077,10 +1192,13 @@ struct JetFinderQATask { aod::JetMcCollisions const&, soa::Filtered> const& tracks) { - float eventWeight = collision.mcCollision().weight(); + float eventWeight = collision.weight(); + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collisions"), 1.5); @@ -1097,15 +1215,18 @@ struct JetFinderQATask { void processTracksSub(soa::Filtered::iterator const& collision, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } for (auto const& track : tracks) { - registry.fill(HIST("h3_centrality_track_pt_track_phi_eventwiseconstituentsubtracted"), collision.centrality(), track.pt(), track.phi()); - registry.fill(HIST("h3_centrality_track_pt_track_eta_eventwiseconstituentsubtracted"), collision.centrality(), track.pt(), track.eta()); + registry.fill(HIST("h3_centrality_track_pt_track_phi_eventwiseconstituentsubtracted"), collision.centFT0M(), track.pt(), track.phi()); + registry.fill(HIST("h3_centrality_track_pt_track_eta_eventwiseconstituentsubtracted"), collision.centFT0M(), track.pt(), track.eta()); registry.fill(HIST("h3_track_pt_track_eta_track_phi_eventwiseconstituentsubtracted"), track.pt(), track.eta(), track.phi()); } } @@ -1113,7 +1234,10 @@ struct JetFinderQATask { void processRho(soa::Filtered>::iterator const& collision, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { @@ -1125,11 +1249,11 @@ struct JetFinderQATask { nTracks++; } } - registry.fill(HIST("h2_centrality_ntracks"), collision.centrality(), nTracks); + registry.fill(HIST("h2_centrality_ntracks"), collision.centFT0M(), nTracks); registry.fill(HIST("h2_ntracks_rho"), nTracks, collision.rho()); registry.fill(HIST("h2_ntracks_rhom"), nTracks, collision.rhoM()); - registry.fill(HIST("h2_centrality_rho"), collision.centrality(), collision.rho()); - registry.fill(HIST("h2_centrality_rhom"), collision.centrality(), collision.rhoM()); + registry.fill(HIST("h2_centrality_rho"), collision.centFT0M(), collision.rho()); + registry.fill(HIST("h2_centrality_rhom"), collision.centFT0M(), collision.rhoM()); } PROCESS_SWITCH(JetFinderQATask, processRho, "QA for rho-area subtracted jets", false); @@ -1141,9 +1265,44 @@ struct JetFinderQATask { void processRandomConeMCD(soa::Filtered>::iterator const& collision, soa::Join const& jets, soa::Filtered const& tracks) { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } randomCone(collision, jets, tracks); } PROCESS_SWITCH(JetFinderQATask, processRandomConeMCD, "QA for random cone estimation of background fluctuations in mcd", false); + + void processOccupancyQA(soa::Filtered::iterator const& collision, aod::JetTracks const& tracks) + { + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + int occupancy = collision.trackOccupancyInTimeRange(); + int nTracksAll = tracks.size(); + int nTracksAllAcceptanceAndSelected = 0; + int nTracksInAcceptanceAndSelected = 0; + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection)) { + nTracksAllAcceptanceAndSelected += 1; + if (track.pt() >= trackPtMin && track.pt() < trackPtMax && track.eta() > trackEtaMin && track.eta() < trackEtaMax) { + nTracksInAcceptanceAndSelected += 1; + } + } + } + + registry.fill(HIST("h2_occupancy_ntracksall_presel"), occupancy, nTracksAll); + registry.fill(HIST("h2_occupancy_ntrackssel_presel"), occupancy, nTracksAllAcceptanceAndSelected); + registry.fill(HIST("h2_occupancy_ntracksselptetacuts_presel"), occupancy, nTracksInAcceptanceAndSelected); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + registry.fill(HIST("h2_occupancy_ntracksall_postsel"), occupancy, nTracksAll); + registry.fill(HIST("h2_occupancy_ntrackssel_postsel"), occupancy, nTracksAllAcceptanceAndSelected); + registry.fill(HIST("h2_occupancy_ntracksselptetacuts_postsel"), occupancy, nTracksInAcceptanceAndSelected); + } + } + PROCESS_SWITCH(JetFinderQATask, processOccupancyQA, "occupancy QA on jet derived data", false); }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-finder-charged-qa"})}; } +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-finder-charged-qa"})}; // o2-linter: disable=name/o2-task,name/workflow-file +} diff --git a/PWGJE/Tasks/jetFinderV0QA.cxx b/PWGJE/Tasks/jetFinderV0QA.cxx index 362239cf8e1..a80ee0eea25 100644 --- a/PWGJE/Tasks/jetFinderV0QA.cxx +++ b/PWGJE/Tasks/jetFinderV0QA.cxx @@ -13,35 +13,30 @@ // /// \author Nima Zardoshti -#include +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "CommonConstants/PhysicsConstants.h" #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include +#include +#include -#include "PWGHF/Core/HfHelper.h" -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include -#include "PWGJE/DataModel/Jet.h" - -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetHFUtilities.h" -#include "PWGJE/Core/JetV0Utilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" +#include +#include +#include +#include -#include "EventFiltering/filterTables.h" +#include using namespace o2; -using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; @@ -68,12 +63,12 @@ struct JetFinderV0QATask { Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; void init(o2::framework::InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); auto jetRadiiBins = (std::vector)jetRadii; @@ -164,7 +159,7 @@ struct JetFinderV0QATask { using JetTableMCPMatchedWeightedJoined = soa::Join; Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); - Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); template bool isAcceptedJet(V const& jet) @@ -297,10 +292,10 @@ struct JetFinderV0QATask { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } - registry.fill(HIST("h2_centrality_track_pt"), collision.centrality(), track.pt(), weight); - registry.fill(HIST("h2_centrality_track_eta"), collision.centrality(), track.eta(), weight); - registry.fill(HIST("h2_centrality_track_phi"), collision.centrality(), track.phi(), weight); - registry.fill(HIST("h2_centrality_track_energy"), collision.centrality(), track.energy(), weight); + registry.fill(HIST("h2_centrality_track_pt"), collision.centFT0M(), track.pt(), weight); + registry.fill(HIST("h2_centrality_track_eta"), collision.centFT0M(), track.eta(), weight); + registry.fill(HIST("h2_centrality_track_phi"), collision.centFT0M(), track.phi(), weight); + registry.fill(HIST("h2_centrality_track_energy"), collision.centFT0M(), track.energy(), weight); } } @@ -318,7 +313,7 @@ struct JetFinderV0QATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality()); + fillHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetFinderV0QATask, processJetsData, "jet finder HF QA data", false); @@ -332,7 +327,7 @@ struct JetFinderV0QATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality()); + fillHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetFinderV0QATask, processJetsMCD, "jet finder HF QA mcd", false); @@ -346,7 +341,7 @@ struct JetFinderV0QATask { if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality(), jet.eventWeight()); + fillHistograms(jet, collision.centFT0M(), jet.eventWeight()); } } PROCESS_SWITCH(JetFinderV0QATask, processJetsMCDWeighted, "jet finder HF QA mcd on weighted events", false); @@ -385,12 +380,12 @@ struct JetFinderV0QATask { soa::Filtered const& tracks) { registry.fill(HIST("h_collisions"), 0.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collisions"), 1.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 1.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 1.5); fillTrackHistograms(collision, tracks); } PROCESS_SWITCH(JetFinderV0QATask, processTracks, "QA for charged tracks", false); @@ -402,7 +397,7 @@ struct JetFinderV0QATask { float eventWeight = collision.mcCollision().weight(); registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collisions"), 1.5); @@ -421,7 +416,7 @@ struct JetFinderV0QATask { registry.fill(HIST("h_candidate_pt"), candidate.pt()); registry.fill(HIST("h_candidate_y"), candidate.y()); } - registry.fill(HIST("h2_centrality_ncandidates"), collision.centrality(), candidates.size()); + registry.fill(HIST("h2_centrality_ncandidates"), collision.centFT0M(), candidates.size()); } PROCESS_SWITCH(JetFinderV0QATask, processCandidates, "HF candidate QA", false); }; diff --git a/PWGJE/Tasks/jetFragmentation.cxx b/PWGJE/Tasks/jetFragmentation.cxx index 8f939d75f46..5a6104ad872 100644 --- a/PWGJE/Tasks/jetFragmentation.cxx +++ b/PWGJE/Tasks/jetFragmentation.cxx @@ -9,29 +9,40 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file jetFragmentation.cxx /// \brief Task for jet fragmentation into V0s -// +/// /// \author Gijs van Weelden -// -#include "TH1F.h" -#include "TTree.h" +#include "JetDerivedDataUtilities.h" +#include "RecoDecay.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/RunningWorkflowInfo.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" #include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -52,6 +63,10 @@ using MCPJetsWithConstituents = soa::Join; // V0 jets +using DataV0JetsWithConstituents = soa::Join; +using CandidatesV0DataWithFlags = aod::CandidatesV0Data; + +using CandidatesV0MCDWithLabelsAndFlags = soa::Join; using MCDV0Jets = aod::V0ChargedMCDetectorLevelJets; using MCDV0JetsWithConstituents = soa::Join; using MatchedMCDV0Jets = soa::Join; @@ -66,31 +81,27 @@ struct JetFragmentation { HistogramRegistry registry{"registry"}; // CallSumw2 = false? Configurable evSel{"evSel", "sel8WithoutTimeFrameBorderCut", "choose event selection"}; - Configurable vertexZCut{"vertexZCut", 10.f, "vertex z cut"}; + Configurable trackSel{"trackSel", "globalTracks", "choose track selection"}; + Configurable nV0Classes{"nV0Classes", 2, "Must be 2 or 4! Number of V0 signal/bkg classes"}; + Configurable doCorrectionWithTracks{"doCorrectionWithTracks", false, "add tracks during background subtraction"}; - Configurable matchedDetJetEtaMin{"matchedDetJetEtaMin", -0.5, "minimum matchedDetJet eta"}; - Configurable matchedDetJetEtaMax{"matchedDetJetEtaMax", 0.5, "maximum matchedDetJet eta"}; - Configurable dataJetEtaMin{"dataJetEtaMin", -0.5, "minimum data jet eta"}; - Configurable dataJetEtaMax{"dataJetEtaMax", 0.5, "maximum data jet eta"}; - Configurable v0EtaMin{"v0EtaMin", -0.75, "minimum data V0 eta"}; - Configurable v0EtaMax{"v0EtaMax", 0.75, "maximum data V0 eta"}; + Configurable> ptBinsK0S{"ptBinsK0S", {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 40.0}, "K0S pt Vals"}; + Configurable> ptBinsLambda{"ptBinsLambda", {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0}, "Lambda pt Vals"}; + Configurable> ptBinsAntiLambda{"ptBinsAntiLambda", {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0}, "AntiLambda pt Vals"}; - Configurable v0cospaMin{"v0cospaMin", 0.995, "V0 CosPA"}; - Configurable dcav0dauMax{"dcav0dauMax", 1.0, "DCA V0 Daughters"}; - Configurable dcaprMin{"dcaprMin", 0.1, "DCA proton To PV"}; - Configurable dcapiMin{"dcapiMin", 0.1, "DCA pion To PV"}; - Configurable v0radiusMin{"v0radiusMin", 1.2, "V0 Radius"}; - Configurable lifetimeK0SMax{"lifetimeK0SMax", 20., "lifetimeK0SMax"}; - Configurable lifetimeLambdaMax{"lifetimeLambdaMax", 25., "lifetimeLambdaMax"}; + // NB: these must be one shorter than ptbin vectors! + Configurable> signalProbK0S{"signalProbK0S", {0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9}, "K0S signal probability per pt bin"}; + Configurable> signalProbLambda{"signalProbLambda", {0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9}, "Lambda signal probability per pt bin"}; + Configurable> signalProbAntiLambda{"signalProbAntiLambda", {0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9}, "AntiLambda signal probability per pt bin"}; - Configurable k0sMassAccWindow{"k0sMassAccWindow", 0.03, "k0sMassAccWindow"}; - Configurable lambdaMassAccWindow{"lambdaMassAccWindow", 0.01, "lambdaMassAccWindow"}; - Configurable antilambdaMassAccWindow{"antilambdaMassAccWindow", 0.01, "antilambdaMassAccWindow"}; + Configurable vertexZCut{"vertexZCut", 10.f, "vertex z cut"}; + Configurable v0EtaMin{"v0EtaMin", -0.75, "minimum data V0 eta"}; + Configurable v0EtaMax{"v0EtaMax", 0.75, "maximum data V0 eta"}; // Binning ConfigurableAxis binJetPt{"binJetPt", {40, 0.f, 200.f}, ""}; ConfigurableAxis binEta{"binEta", {20, -1.f, 1.f}, ""}; - ConfigurableAxis binPhi{"binPhi", {18 * 8, 0.f, 2. * TMath::Pi()}, ""}; + ConfigurableAxis binPhi{"binPhi", {18 * 8, 0.f, constants::math::TwoPI}, ""}; ConfigurableAxis binZ{"binZ", {40, 0.0001f, 1.0001f}, ""}; ConfigurableAxis binXi{"binXi", {50, 0.f, 10.f}, ""}; ConfigurableAxis binTheta{"binTheta", {40, -0.05f, 0.395f}, ""}; @@ -119,7 +130,7 @@ struct JetFragmentation { ConfigurableAxis binV0Pt{"binV0Pt", {120, 0.0f, 60.0f}, ""}; ConfigurableAxis binV0Eta{"binV0Eta", {20, -1.f, 1.f}, ""}; - ConfigurableAxis binV0Phi{"binV0Phi", {18 * 8, 0.f, 2. * TMath::Pi()}, ""}; + ConfigurableAxis binV0Phi{"binV0Phi", {18 * 8, 0.f, constants::math::TwoPI}, ""}; ConfigurableAxis binV0Ctau{"binV0Ctau", {200, 0.0f, 40.0f}, ""}; ConfigurableAxis binV0Radius{"binV0Radius", {100, 0.0f, 100.0f}, ""}; ConfigurableAxis binV0CosPA{"binV0CosPA", {100, 0.95f, 1.0f}, ""}; @@ -130,7 +141,7 @@ struct JetFragmentation { ConfigurableAxis binK0SMass{"binK0SMass", {400, 0.400f, 0.600f}, "Inv. Mass (GeV/c^{2})"}; ConfigurableAxis binK0SMassWide{"binK0SMassWide", {400, 0.400f, 0.800f}, "Inv. Mass (GeV/c^{2})"}; // Wider version for high pt - ConfigurableAxis binLambdaMass{"binLambdaMass", {200, 1.015f, 1.215f}, "Inv. Mass (GeV/c^{2})"}; + ConfigurableAxis binLambdaMass{"binLambdaMass", {200, 1.075f, 1.215f}, "Inv. Mass (GeV/c^{2})"}; ConfigurableAxis binLambdaMassDiff{"binLambdaMassDiff", {200, -0.199f, 0.201f}, "M(#Lambda) - M(#bar{#Lambda})"}; ConfigurableAxis binLambdaMassRatio{"binLambdaMassRatio", {50, -0.05f, 4.95f}, "M(#bar{#Lambda}) / M(#Lambda)"}; ConfigurableAxis binLambdaMassRelDiff{"binLambdaMassRelDiff", {200, -0.995f, 1.005f}, "(M(#Lambda) - M(#bar{#Lambda})) / M(#Lambda)"}; @@ -144,27 +155,18 @@ struct JetFragmentation { ConfigurableAxis binV0DCAdCut{"binV0DCAdCut", {2, 0.5f, 1.5f}, "DCA daughters"}; ConfigurableAxis binV0PtCut{"binV0PtCut", {60, 0.0f, 60.0f}, "p_{T, V0}"}; ConfigurableAxis binK0SMassCut{"binK0SMassCut", {100, 0.4f, 0.6f}, "inv. mass, K0S hypothesis"}; - ConfigurableAxis binLambda0MassCut{"binLambda0MassCut", {100, 1.07f, 1.21f}, "inv. mass, Lambda0 hypothesis"}; - ConfigurableAxis binAntiLambda0MassCut{"binAntiLambda0MassCut", {100, 1.07f, 1.21f}, "inv. mass, AntiLambda0 hypothesis"}; + ConfigurableAxis binLambdaMassCut{"binLambdaMassCut", {100, 1.07f, 1.21f}, "inv. mass, Lambda hypothesis"}; + ConfigurableAxis binAntiLambdaMassCut{"binAntiLambdaMassCut", {100, 1.07f, 1.21f}, "inv. mass, AntiLambda hypothesis"}; Filter jetCollisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; - Filter collisionFilter = nabs(aod::collision::posZ) < vertexZCut; - - Partition detJetEtaPartition = (aod::jet::eta > matchedDetJetEtaMin) && (aod::jet::eta < matchedDetJetEtaMax); - Partition detJetEtaV0Partition = (aod::jet::eta > v0EtaMin + aod::jet::r * 0.01f) && (aod::jet::eta < v0EtaMax - aod::jet::r * 0.01f); - - Preslice TracksPerCollision = aod::track::collisionId; - Preslice V0sPerCollision = aod::v0data::collisionId; - Preslice> McV0sPerCollision = aod::v0data::collisionId; - Preslice PartJetsPerCollision = aod::jet::mcCollisionId; - Preslice JetParticlesPerCollision = aod::jmcparticle::mcCollisionId; - Preslice ParticlesPerCollision = aod::mcparticle::mcCollisionId; - int eventSelection = -1; + std::vector eventSelectionBits; + int trackSelection = -1; void init(InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(evSel)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(evSel)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSel)); // Axes AxisSpec jetPtAxis = {binJetPt, "#it{p}_{T}^{ jet}"}; // Data @@ -204,660 +206,818 @@ struct JetFragmentation { AxisSpec ptTrackRelDiffAxis = {binPtRelDiff, "(#it{p}_{T}^{track, det} - #it{p}_{T}^{track, part})/#it{p}_{T, track}^{part}"}; AxisSpec zRelDiffAxis = {binZRelDiff, "(#it{p}_{T}^{jet, det} - #it{p}_{T}^{jet, part})/#it{p}_{T, jet}^{part}"}; - AxisSpec V0PtAxis = {binV0Pt, "#it{p}_{T}^{V0}"}; - AxisSpec V0PtRatioAxis = {binPtRatio, "#it{p}_{T}^{V0, det}/#it{p}_{T, V0}^{part}"}; - AxisSpec V0PtRelDiffAxis = {binPtRelDiff, "(#it{p}_{T}^{V0, det} - #it{p}_{T}^{V0, part})/#it{p}_{T, V0}^{part}"}; - AxisSpec V0EtaAxis = {binV0Eta, "#eta^{V0}"}; - AxisSpec V0PhiAxis = {binV0Phi, "#varphi^{V0}"}; - AxisSpec V0detPtAxis = {binV0Pt, "#it{p}_{T}^{V0, det}"}; - AxisSpec V0partPtAxis = {binV0Pt, "#it{p}_{T}^{V0, part}"}; - AxisSpec V0CtauAxis = {binV0Ctau, "c#tau (cm)"}; - AxisSpec V0RadiusAxis = {binV0Radius, "R (cm)"}; - AxisSpec V0CosPAAxis = {binV0CosPA, "cos(PA)"}; - AxisSpec V0DCApAxis = {binV0DCAp, "DCA pos (cm)"}; - AxisSpec V0DCAnAxis = {binV0DCAn, "DCA neg (cm)"}; - AxisSpec V0DCAdAxis = {binV0DCAd, "DCA daughters (cm^{2})"}; - - AxisSpec K0SMassAxis = {binK0SMass, "Inv. mass (GeV/#it{c}^{2})"}; - AxisSpec K0SWideAxis = {binK0SMassWide, "Inv. mass (GeV/#it{c}^{2})"}; - AxisSpec LambdaMassAxis = {binLambdaMass, "Inv. mass (GeV/#it{c}^{2})"}; - AxisSpec LambdaMassDiffAxis = {binLambdaMassDiff, "M(#Lambda) - M(#bar{#Lambda})"}; - AxisSpec LambdaMassRatioAxis = {binLambdaMassRatio, "M(#bar{#Lambda}) / M(#Lambda)"}; - AxisSpec LambdaMassRelDiffAxis = {binLambdaMassRelDiff, "(M(#Lambda) - M(#bar{#Lambda})) / M(#Lambda)"}; + AxisSpec v0PtAxis = {binV0Pt, "#it{p}_{T}^{V0}"}; + AxisSpec v0PtRatioAxis = {binPtRatio, "#it{p}_{T}^{V0, det}/#it{p}_{T, V0}^{part}"}; + AxisSpec v0PtRelDiffAxis = {binPtRelDiff, "(#it{p}_{T}^{V0, det} - #it{p}_{T}^{V0, part})/#it{p}_{T, V0}^{part}"}; + AxisSpec v0EtaAxis = {binV0Eta, "#eta^{V0}"}; + AxisSpec v0PhiAxis = {binV0Phi, "#varphi^{V0}"}; + AxisSpec v0detPtAxis = {binV0Pt, "#it{p}_{T}^{V0, det}"}; + AxisSpec v0partPtAxis = {binV0Pt, "#it{p}_{T}^{V0, part}"}; + AxisSpec v0CtauAxis = {binV0Ctau, "c#tau (cm)"}; + AxisSpec v0RadiusAxis = {binV0Radius, "R (cm)"}; + AxisSpec v0CosPAAxis = {binV0CosPA, "cos(PA)"}; + AxisSpec v0DCApAxis = {binV0DCAp, "DCA pos (cm)"}; + AxisSpec v0DCAnAxis = {binV0DCAn, "DCA neg (cm)"}; + AxisSpec v0DCAdAxis = {binV0DCAd, "DCA daughters (cm^{2})"}; + + AxisSpec k0SMassAxis = {binK0SMass, "Inv. mass (GeV/#it{c}^{2})"}; + AxisSpec k0SWideAxis = {binK0SMassWide, "Inv. mass (GeV/#it{c}^{2})"}; + AxisSpec lambdaMassAxis = {binLambdaMass, "Inv. mass (GeV/#it{c}^{2})"}; + AxisSpec lambdaMassDiffAxis = {binLambdaMassDiff, "M(#Lambda) - M(#bar{#Lambda})"}; + AxisSpec lambdaMassRatioAxis = {binLambdaMassRatio, "M(#bar{#Lambda}) / M(#Lambda)"}; + AxisSpec lambdaMassRelDiffAxis = {binLambdaMassRelDiff, "(M(#Lambda) - M(#bar{#Lambda})) / M(#Lambda)"}; // Cut variation study - AxisSpec RcutAxis = {binV0RadiusCut, "R"}; + AxisSpec rCutAxis = {binV0RadiusCut, "R"}; AxisSpec ctauCutAxis = {binV0CtauCut, "c#tau (K0S)"}; AxisSpec cosPACutAxis = {binV0CosPACut, "cosPA"}; - AxisSpec DCApCutAxis = {binV0DCApCut, "DCA pos (cm)"}; - AxisSpec DCAnCutAxis = {binV0DCAnCut, "DCA neg (cm)"}; - AxisSpec DCAdCutAxis = {binV0DCAdCut, "DCA daughters (cm^{2})"}; - AxisSpec PtCutAxis = {binV0PtCut, "p_{T, V0}"}; - AxisSpec K0SMassCutAxis = {binK0SMassCut, "Inv. mass (GeV/#it{c}^{2})"}; - AxisSpec LambdaMassCutAxis = {binLambda0MassCut, "Inv. mass (GeV/#it{c}^{2})"}; - AxisSpec AntiLambdaMassCutAxis = {binAntiLambda0MassCut, "Inv. mass (GeV/#it{c}^{2})"}; - - if (doprocessDataRun3) { - registry.add("data/nJetsnTracks", "nJetsnTracks; nJets; nTracks", HistType::kTH2D, {jetCount, trackCount}); - registry.add("data/collision/collisionVtxZ", "Collision vertex z (cm)", HistType::kTH1D, {binVtxZ}); - registry.add("data/tracks/trackPtEtaPhi", "trackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}); - } - if (doprocessDataRun3 || doprocessDataV0Frag || doprocessDataV0JetsFrag || doprocessDataV0JetsFragWithWeights) { - registry.add("data/jets/jetPtEtaPhi", "Jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {jetPtAxis, etaAxis, phiAxis}); - } - if (doprocessDataRun3 || doprocessDataV0Frag) { - registry.add("data/jets/jetPtTrackPt", "Jet #it{p}_{T}, track #it{p}_{T}", HistType::kTH2D, {jetPtAxis, trackPtAxis}); - registry.add("data/jets/jetTrackPtEtaPhi", "Tracks in jets #it{p}_{T}, #eta, #phi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}); - registry.add("data/jets/jetPtFrag", "Jet #it{p}_{T}, #it{p}_{T,jet}/#it{p}_{T,tr}", HistType::kTH2D, {jetPtAxis, zAxis}); - registry.add("data/jets/jetPtTrackProj", "Jet #it{p}_{T}, #it{z}", HistType::kTH2D, {jetPtAxis, zAxis}); - registry.add("data/jets/jetPtXi", "Jet #it{p}_{T}, #xi", HistType::kTH2D, {jetPtAxis, xiAxis}); - registry.add("data/jets/jetPtTheta", "Jet #it{p}_{T}, #theta", HistType::kTH2D, {jetPtAxis, thetaAxis}); - registry.add("data/jets/jetPtXiTheta", "Jet #it{p}_{T}, #xi, #theta", HistType::kTH3D, {jetPtAxis, xiAxis, thetaAxis}); - registry.add("data/jets/jetPtZTheta", "Jet #it{p}_{T}, z, #theta", HistType::kTH3D, {jetPtAxis, zAxis, thetaAxis}); - } // doprocessDataRun3 || doprocessDataV0Frag - - if (doprocessDataV0 || doprocessDataV0Frag || doprocessDataV0JetsFrag || doprocessDataV0JetsFragWithWeights || doprocessDataV0PerpCone) { + AxisSpec dcapCutAxis = {binV0DCApCut, "DCA pos (cm)"}; + AxisSpec dcanCutAxis = {binV0DCAnCut, "DCA neg (cm)"}; + AxisSpec dcadCutAxis = {binV0DCAdCut, "DCA daughters (cm^{2})"}; + AxisSpec ptCutAxis = {binV0PtCut, "p_{T, V0}"}; + AxisSpec k0SMassCutAxis = {binK0SMassCut, "Inv. mass (GeV/#it{c}^{2})"}; + AxisSpec lambdaMassCutAxis = {binLambdaMassCut, "Inv. mass (GeV/#it{c}^{2})"}; + AxisSpec antiLambdaMassCutAxis = {binAntiLambdaMassCut, "Inv. mass (GeV/#it{c}^{2})"}; + + if (doprocessDataV0) { registry.add("data/V0/nV0sEvent", "nV0sEvent", HistType::kTH1D, {v0Count}); - // TODO: Does this make sense? - registry.add("data/V0/nV0sEventWeighted", "nV0s per event (weighted)", HistType::kTH1D, {v0Count}); - registry.get(HIST("data/V0/nV0sEventWeighted"))->Sumw2(); - - // Unidentified - registry.add("data/V0/V0PtEtaPhi", "V0PtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("data/V0/V0PtCtau", "V0PtCtau", HistType::kTHnSparseD, {V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("data/V0/V0PtMass", "V0PtMass", HistType::kTHnSparseD, {V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/V0/V0PtMassWide", "V0PtMassWide", HistType::kTHnSparseD, {V0PtAxis, K0SWideAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/V0/V0PtLambdaMasses", "V0PtLambdaMasses", HistType::kTHnSparseD, {V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/V0/V0PtRadiusCosPA", "V0PtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/V0/V0PtDCAposneg", "V0PtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/V0/V0PtDCAd", "V0PtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); - - // Identified - registry.add("data/V0/K0SPtEtaPhi", "K0SPtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("data/V0/K0SPtCtauMass", "K0SPtCtauMass", HistType::kTH3D, {V0partPtAxis, V0CtauAxis, K0SMassAxis}); - registry.add("data/V0/K0SPtRadiusCosPA", "K0SPtRadiusCosPA", HistType::kTH3D, {V0partPtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/V0/K0SPtDCAposneg", "K0SPtDCAposneg", HistType::kTH3D, {V0partPtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/V0/K0SPtDCAd", "K0SPtDCAd", HistType::kTH2D, {V0partPtAxis, V0DCAdAxis}); - - registry.add("data/V0/LambdaPtEtaPhi", "LambdaPtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("data/V0/LambdaPtCtauMass", "LambdaPtCtauMass", HistType::kTH3D, {V0partPtAxis, V0CtauAxis, LambdaMassAxis}); - registry.add("data/V0/LambdaPtLambdaMasses", "LambdaPtLambdaMasses", HistType::kTHnSparseD, {V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/V0/LambdaPtRadiusCosPA", "LambdaPtRadiusCosPA", HistType::kTH3D, {V0partPtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/V0/LambdaPtDCAposneg", "LambdaPtDCAposneg", HistType::kTH3D, {V0partPtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/V0/LambdaPtDCAd", "LambdaPtDCAd", HistType::kTH2D, {V0partPtAxis, V0DCAdAxis}); - - registry.add("data/V0/antiLambdaPtEtaPhi", "antiLambdaPtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("data/V0/antiLambdaPtCtauMass", "antiLambdaPtCtauMass", HistType::kTH3D, {V0partPtAxis, V0CtauAxis, LambdaMassAxis}); - registry.add("data/V0/antiLambdaPtLambdaMasses", "antiLambdaPtLambdaMasses", HistType::kTHnSparseD, {V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/V0/antiLambdaPtRadiusCosPA", "antiLambdaPtRadiusCosPA", HistType::kTH3D, {V0partPtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/V0/antiLambdaPtDCAposneg", "antiLambdaPtDCAposneg", HistType::kTH3D, {V0partPtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/V0/antiLambdaPtDCAd", "antiLambdaPtDCAd", HistType::kTH2D, {V0partPtAxis, V0DCAdAxis}); - - registry.add("data/V0/V0CutVariation", "V0CutVariation", HistType::kTHnSparseD, {PtCutAxis, K0SMassCutAxis, LambdaMassCutAxis, AntiLambdaMassCutAxis, RcutAxis, ctauCutAxis, cosPACutAxis, DCApCutAxis, DCAnCutAxis, DCAdCutAxis}); - } // doprocessDataV0 || doprocessDataV0Frag || doprocessDataV0JetsFrag - - if (doprocessDataV0Frag) { - registry.add("data/jets/V0/jetCorrectedPtEtaPhi", "Jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {jetPtAxis, etaAxis, phiAxis}); - registry.add("data/jets/V0/jetPtnV0", "jetPtnV0", HistType::kTH2D, {jetPtAxis, v0Count}); - registry.add("data/jets/V0/jetCorrectedPtV0TrackProj", "jetCorrectedPtV0TrackProj", HistType::kTH2D, {jetPtAxis, zAxis}); - } + registry.add("data/V0/nV0sEventAcc", "nV0s per event (accepted)", HistType::kTH1D, {v0Count}); + registry.add("data/V0/nV0sEventAccWeighted", "nV0s per event (accepted, weighted)", HistType::kTH1D, {v0Weight}, true); + + // Inclusive + registry.add("data/V0/V0PtEtaPhi", "V0PtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}); + registry.add("data/V0/V0PtCtau", "V0PtCtau", HistType::kTHnSparseD, {v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}); + registry.add("data/V0/V0PtMass", "V0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/V0/V0PtMassWide", "V0PtMassWide", HistType::kTHnSparseD, {v0PtAxis, k0SWideAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/V0/V0PtLambdaMasses", "V0PtLambdaMasses", HistType::kTHnSparseD, {v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}); + registry.add("data/V0/V0PtRadiusCosPA", "V0PtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/V0/V0PtDCAposneg", "V0PtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/V0/V0PtDCAd", "V0PtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}); + + // Inclusive Weighted + registry.add("data/V0/V0PtEtaPhiWeighted", "V0PtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("data/V0/V0PtCtauWeighted", "V0PtCtau", HistType::kTHnSparseD, {v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("data/V0/V0PtMassWeighted", "V0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("data/V0/V0PtMassWideWeighted", "V0PtMassWide", HistType::kTHnSparseD, {v0PtAxis, k0SWideAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("data/V0/V0PtLambdaMassesWeighted", "V0PtLambdaMasses", HistType::kTHnSparseD, {v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("data/V0/V0PtRadiusCosPAWeighted", "V0PtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("data/V0/V0PtDCAposnegWeighted", "V0PtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("data/V0/V0PtDCAdWeighted", "V0PtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}, true); + + // K0S + registry.add("data/V0/K0SPtEtaPhi", "K0SPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}); + registry.add("data/V0/K0SPtRadiusCosPA", "K0SPtRadiusCosPA", HistType::kTH3D, {v0partPtAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/V0/K0SPtDCAposneg", "K0SPtDCAposneg", HistType::kTH3D, {v0partPtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/V0/K0SPtDCAd", "K0SPtDCAd", HistType::kTH2D, {v0partPtAxis, v0DCAdAxis}); + registry.add("data/V0/K0SPtCtauMass", "K0SPtCtauMass", HistType::kTH3D, {v0partPtAxis, v0CtauAxis, k0SMassAxis}); + registry.add("data/V0/K0SPtRadiusMass", "K0SPtRadiusMass", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, k0SMassAxis}); + registry.add("data/V0/K0SPtCosPAMass", "K0SPtCosPAMass", HistType::kTH3D, {v0PtAxis, v0CosPAAxis, k0SMassAxis}); + registry.add("data/V0/K0SPtDCAposMass", "K0SPtDCAposMass", HistType::kTH3D, {v0PtAxis, v0DCApAxis, k0SMassAxis}); + registry.add("data/V0/K0SPtDCAnegMass", "K0SPtDCAnegMass", HistType::kTH3D, {v0PtAxis, v0DCAnAxis, k0SMassAxis}); + registry.add("data/V0/K0SPtDCAdMass", "K0SPtDCAdMass", HistType::kTH3D, {v0PtAxis, v0DCAdAxis, k0SMassAxis}); + + // K0S Weighted + registry.add("data/V0/K0SPtEtaPhiWeighted", "K0SPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("data/V0/K0SPtRadiusCosPAWeighted", "K0SPtRadiusCosPA", HistType::kTH3D, {v0partPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("data/V0/K0SPtDCAposnegWeighted", "K0SPtDCAposneg", HistType::kTH3D, {v0partPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("data/V0/K0SPtDCAdWeighted", "K0SPtDCAd", HistType::kTH2D, {v0partPtAxis, v0DCAdAxis}, true); + registry.add("data/V0/K0SPtCtauMassWeighted", "K0SPtCtauMass", HistType::kTH3D, {v0partPtAxis, v0CtauAxis, k0SMassAxis}, true); + registry.add("data/V0/K0SPtRadiusMassWeighted", "K0SPtRadiusMassWeighted", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, k0SMassAxis}, true); + registry.add("data/V0/K0SPtCosPAMassWeighted", "K0SPtCosPAMassWeighted", HistType::kTH3D, {v0PtAxis, v0CosPAAxis, k0SMassAxis}, true); + registry.add("data/V0/K0SPtDCAposMassWeighted", "K0SPtDCAposMassWeighted", HistType::kTH3D, {v0PtAxis, v0DCApAxis, k0SMassAxis}, true); + registry.add("data/V0/K0SPtDCAnegMassWeighted", "K0SPtDCAnegMassWeighted", HistType::kTH3D, {v0PtAxis, v0DCAnAxis, k0SMassAxis}, true); + registry.add("data/V0/K0SPtDCAdMassWeighted", "K0SPtDCAdMassWeighted", HistType::kTH3D, {v0PtAxis, v0DCAdAxis, k0SMassAxis}, true); + + // Lambda + registry.add("data/V0/LambdaPtEtaPhi", "LambdaPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}); + registry.add("data/V0/LambdaPtLambdaMasses", "LambdaPtLambdaMasses", HistType::kTHnSparseD, {v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}); + registry.add("data/V0/LambdaPtRadiusCosPA", "LambdaPtRadiusCosPA", HistType::kTH3D, {v0partPtAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/V0/LambdaPtDCAposneg", "LambdaPtDCAposneg", HistType::kTH3D, {v0partPtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/V0/LambdaPtDCAd", "LambdaPtDCAd", HistType::kTH2D, {v0partPtAxis, v0DCAdAxis}); + registry.add("data/V0/LambdaPtCtauMass", "LambdaPtCtauMass", HistType::kTH3D, {v0partPtAxis, v0CtauAxis, lambdaMassAxis}); + registry.add("data/V0/LambdaPtRadiusMass", "LambdaPtRadiusMass", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, lambdaMassAxis}); + registry.add("data/V0/LambdaPtCosPAMass", "LambdaPtCosPAMass", HistType::kTH3D, {v0PtAxis, v0CosPAAxis, lambdaMassAxis}); + registry.add("data/V0/LambdaPtDCAposMass", "LambdaPtDCAposMass", HistType::kTH3D, {v0PtAxis, v0DCApAxis, lambdaMassAxis}); + registry.add("data/V0/LambdaPtDCAnegMass", "LambdaPtDCAnegMass", HistType::kTH3D, {v0PtAxis, v0DCAnAxis, lambdaMassAxis}); + registry.add("data/V0/LambdaPtDCAdMass", "LambdaPtDCAdMass", HistType::kTH3D, {v0PtAxis, v0DCAdAxis, lambdaMassAxis}); + + // Lambda Weighted + registry.add("data/V0/LambdaPtEtaPhiWeighted", "LambdaPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("data/V0/LambdaPtLambdaMassesWeighted", "LambdaPtLambdaMasses", HistType::kTHnSparseD, {v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("data/V0/LambdaPtRadiusCosPAWeighted", "LambdaPtRadiusCosPA", HistType::kTH3D, {v0partPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("data/V0/LambdaPtDCAposnegWeighted", "LambdaPtDCAposneg", HistType::kTH3D, {v0partPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("data/V0/LambdaPtDCAdWeighted", "LambdaPtDCAd", HistType::kTH2D, {v0partPtAxis, v0DCAdAxis}, true); + registry.add("data/V0/LambdaPtCtauMassWeighted", "LambdaPtCtauMass", HistType::kTH3D, {v0partPtAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("data/V0/LambdaPtRadiusMassWeighted", "LambdaPtRadiusMassWeighted", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("data/V0/LambdaPtCosPAMassWeighted", "LambdaPtCosPAMassWeighted", HistType::kTH3D, {v0PtAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("data/V0/LambdaPtDCAposMassWeighted", "LambdaPtDCAposMassWeighted", HistType::kTH3D, {v0PtAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("data/V0/LambdaPtDCAnegMassWeighted", "LambdaPtDCAnegMassWeighted", HistType::kTH3D, {v0PtAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("data/V0/LambdaPtDCAdMassWeighted", "LambdaPtDCAdMassWeighted", HistType::kTH3D, {v0PtAxis, v0DCAdAxis, lambdaMassAxis}, true); + + // AntiLambda + registry.add("data/V0/AntiLambdaPtEtaPhi", "AntiLambdaPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}); + registry.add("data/V0/AntiLambdaPtLambdaMasses", "AntiLambdaPtLambdaMasses", HistType::kTHnSparseD, {v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}); + registry.add("data/V0/AntiLambdaPtRadiusCosPA", "AntiLambdaPtRadiusCosPA", HistType::kTH3D, {v0partPtAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/V0/AntiLambdaPtDCAposneg", "AntiLambdaPtDCAposneg", HistType::kTH3D, {v0partPtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/V0/AntiLambdaPtDCAd", "AntiLambdaPtDCAd", HistType::kTH2D, {v0partPtAxis, v0DCAdAxis}); + registry.add("data/V0/AntiLambdaPtCtauMass", "AntiLambdaPtCtauMass", HistType::kTH3D, {v0partPtAxis, v0CtauAxis, lambdaMassAxis}); + registry.add("data/V0/AntiLambdaPtRadiusMass", "AntiLambdaPtRadiusMass", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, lambdaMassAxis}); + registry.add("data/V0/AntiLambdaPtCosPAMass", "AntiLambdaPtCosPAMass", HistType::kTH3D, {v0PtAxis, v0CosPAAxis, lambdaMassAxis}); + registry.add("data/V0/AntiLambdaPtDCAposMass", "AntiLambdaPtDCAposMass", HistType::kTH3D, {v0PtAxis, v0DCApAxis, lambdaMassAxis}); + registry.add("data/V0/AntiLambdaPtDCAnegMass", "AntiLambdaPtDCAnegMass", HistType::kTH3D, {v0PtAxis, v0DCAnAxis, lambdaMassAxis}); + registry.add("data/V0/AntiLambdaPtDCAdMass", "AntiLambdaPtDCAdMass", HistType::kTH3D, {v0PtAxis, v0DCAdAxis, lambdaMassAxis}); + + // AntiLambda Weighted + registry.add("data/V0/AntiLambdaPtEtaPhiWeighted", "AntiLambdaPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("data/V0/AntiLambdaPtLambdaMassesWeighted", "AntiLambdaPtLambdaMasses", HistType::kTHnSparseD, {v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("data/V0/AntiLambdaPtRadiusCosPAWeighted", "AntiLambdaPtRadiusCosPA", HistType::kTH3D, {v0partPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("data/V0/AntiLambdaPtDCAposnegWeighted", "AntiLambdaPtDCAposneg", HistType::kTH3D, {v0partPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("data/V0/AntiLambdaPtDCAdWeighted", "AntiLambdaPtDCAd", HistType::kTH2D, {v0partPtAxis, v0DCAdAxis}, true); + registry.add("data/V0/AntiLambdaPtCtauMassWeighted", "AntiLambdaPtCtauMass", HistType::kTH3D, {v0partPtAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("data/V0/AntiLambdaPtRadiusMassWeighted", "AntiLambdaPtRadiusMassWeighted", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("data/V0/AntiLambdaPtCosPAMassWeighted", "AntiLambdaPtCosPAMassWeighted", HistType::kTH3D, {v0PtAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("data/V0/AntiLambdaPtDCAposMassWeighted", "AntiLambdaPtDCAposMassWeighted", HistType::kTH3D, {v0PtAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("data/V0/AntiLambdaPtDCAnegMassWeighted", "AntiLambdaPtDCAnegMassWeighted", HistType::kTH3D, {v0PtAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("data/V0/AntiLambdaPtDCAdMassWeighted", "AntiLambdaPtDCAdMassWeighted", HistType::kTH3D, {v0PtAxis, v0DCAdAxis, lambdaMassAxis}, true); + + // Cut variation + registry.add("data/V0/V0CutVariation", "V0CutVariation", HistType::kTHnSparseD, {ptCutAxis, k0SMassCutAxis, lambdaMassCutAxis, antiLambdaMassCutAxis, rCutAxis, ctauCutAxis, cosPACutAxis, dcapCutAxis, dcanCutAxis, dcadCutAxis}); + } // doprocessDataV0 + + if (doprocessDataV0JetsFrag) { + registry.add("data/jets/jetPtEtaPhi", "Jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {jetPtAxis, etaAxis, phiAxis}); - if (doprocessDataV0Frag || doprocessDataV0JetsFrag || doprocessDataV0JetsFragWithWeights) { registry.add("data/jets/V0/jetPtV0TrackProj", "jetPtV0TrackProj", HistType::kTH2D, {jetPtAxis, zAxis}); registry.add("data/jets/V0/jetPtnV0nK0SnLambdanAntiLambda", "jetPtnV0nK0SnLambdanAntiLambda", HistType::kTHnSparseD, {jetPtAxis, v0Count, v0Count, v0Count, v0Count}); - registry.add("data/jets/V0/jetPtV0PtEtaPhi", "jetPtV0PtEtaPhi", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("data/jets/V0/jetPtV0PtCtau", "jetPtV0PtCtau", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("data/jets/V0/jetPtV0PtMass", "jetPtV0PtMass", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtV0PtMassWide", "jetPtV0PtMassWide", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, K0SWideAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtV0PtLambdaMasses", "jetPtV0PtLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/V0/jetPtV0PtRadiusCosPA", "jetPtV0PtRadiusCosPA", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/jets/V0/jetPtV0PtDCAposneg", "jetPtV0PtDCAposneg", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/jets/V0/jetPtV0PtDCAd", "jetPtV0PtDCAd", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0DCAdAxis}); - - registry.add("data/jets/V0/jetPtV0TrackProjCtau", "jetPtV0TrackProjCtau", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("data/jets/V0/jetPtV0TrackProjMass", "jetPtV0TrackProjMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtV0TrackProjMassWide", "jetPtV0TrackProjMassWide", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SWideAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtV0TrackProjLambdaMasses", "jetPtV0TrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/V0/jetPtV0TrackProjRadiusCosPA", "jetPtV0TrackProjRadiusCosPA", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/jets/V0/jetPtV0TrackProjDCAposneg", "jetPtV0TrackProjDCAposneg", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/jets/V0/jetPtV0TrackProjDCAd", "jetPtV0TrackProjDCAd", HistType::kTH3D, {jetPtAxis, zAxis, V0DCAdAxis}); - - // Identified - registry.add("data/jets/V0/jetPtnLambda", "jetPtnLambda", HistType::kTH2D, {jetPtAxis, trackCount}); - registry.add("data/jets/V0/jetPtLambdaPtCtau", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("data/jets/V0/jetPtLambdaPtMass", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, mass", HistType::kTH3D, {jetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtLambdaPtAllMasses", "jetPtLambdaPtAllMasses", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtLambdaPtLambdaMasses", "jetPtLambdaPtLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/V0/jetPtLambdaPtRadius", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, radius", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0RadiusAxis}); - registry.add("data/jets/V0/jetPtLambdaPtCosPA", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0CosPAAxis}); - registry.add("data/jets/V0/jetPtLambdaPtDCAd", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0DCAdAxis}); - registry.add("data/jets/V0/jetPtLambdaPtDCAposneg", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - - registry.add("data/jets/V0/jetPtLambdaTrackProjCtau", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, V0CtauAxis}); - registry.add("data/jets/V0/jetPtLambdaTrackProjMass", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtLambdaTrackProjAllMasses", "jetPtLambdaTrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtLambdaTrackProjLambdaMasses", "jetPtLambdaTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/V0/jetPtLambdaTrackProjRadius", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, V0RadiusAxis}); - registry.add("data/jets/V0/jetPtLambdaTrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, V0CosPAAxis}); - registry.add("data/jets/V0/jetPtLambdaTrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, V0DCAdAxis}); - registry.add("data/jets/V0/jetPtLambdaTrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0DCApAxis, V0DCAnAxis}); - - registry.add("data/jets/V0/jetPtnAntiLambda", "jetPtnAntiLambda", HistType::kTH2D, {jetPtAxis, trackCount}); - registry.add("data/jets/V0/jetPtAntiLambdaPtCtau", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaPtMass", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, mass", HistType::kTH3D, {jetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaPtAllMasses", "jetPtAntiLambdaPtAllMasses", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaPtLambdaMasses", "jetPtAntiLambdaPtLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaPtRadius", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, radius", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0RadiusAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaPtCosPA", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0CosPAAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaPtDCAd", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0DCAdAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaPtDCAposneg", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - - registry.add("data/jets/V0/jetPtAntiLambdaTrackProjCtau", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, V0CtauAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaTrackProjMass", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaTrackProjAllMasses", "jetPtAntiLambdaTrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaTrackProjLambdaMasses", "jetPtAntiLambdaTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaTrackProjRadius", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, V0RadiusAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaTrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, V0CosPAAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaTrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, V0DCAdAxis}); - registry.add("data/jets/V0/jetPtAntiLambdaTrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0DCApAxis, V0DCAnAxis}); - - registry.add("data/jets/V0/jetPtnK0S", "jetPtnK0S", HistType::kTH2D, {jetPtAxis, trackCount}); - registry.add("data/jets/V0/jetPtK0SPtCtau", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, c#tau", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("data/jets/V0/jetPtK0SPtMass", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, mass", HistType::kTH3D, {jetPtAxis, V0PtAxis, K0SMassAxis}); - registry.add("data/jets/V0/jetPtK0SPtAllMasses", "jetPtK0SPtAllMasses", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtK0SPtRadius", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, radius", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0RadiusAxis}); - registry.add("data/jets/V0/jetPtK0SPtCosPA", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, cosPA", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0CosPAAxis}); - registry.add("data/jets/V0/jetPtK0SPtDCAd", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, DCA daughters", HistType::kTH3D, {jetPtAxis, V0PtAxis, V0DCAdAxis}); - registry.add("data/jets/V0/jetPtK0SPtDCAposneg", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - - registry.add("data/jets/V0/jetPtK0STrackProjCtau", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, V0CtauAxis}); - registry.add("data/jets/V0/jetPtK0STrackProjMass", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, K0SMassAxis}); - registry.add("data/jets/V0/jetPtK0STrackProjAllMasses", "jetPtK0STrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/V0/jetPtK0STrackProjRadius", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, V0RadiusAxis}); - registry.add("data/jets/V0/jetPtK0STrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, V0CosPAAxis}); - registry.add("data/jets/V0/jetPtK0STrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, V0DCAdAxis}); - registry.add("data/jets/V0/jetPtK0STrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0DCApAxis, V0DCAnAxis}); - } // doprocessDataV0Frag || doprocessDataV0JetsFrag - - if (doprocessDataV0JetsFragWithWeights) { - // FIXME: These hists need Sumw2 - registry.add("data/jets/weighted/jetPtEtaPhi", "Jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {jetPtAxis, etaAxis, phiAxis}); - registry.add("data/jets/weighted/V0/jetPtnV0nK0SnLambdanAntiLambda", "jetPtnV0nK0SnLambdanAntiLambda", HistType::kTHnSparseD, {jetPtAxis, v0Weight, v0Weight, v0Weight, v0Weight}); - - registry.add("data/jets/weighted/V0/jetPtV0TrackProjCtau", "jetPtV0TrackProjCtau", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("data/jets/weighted/V0/jetPtV0TrackProjMass", "jetPtV0TrackProjMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/weighted/V0/jetPtV0TrackProjMassWide", "jetPtV0TrackProjMassWide", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SWideAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/weighted/V0/jetPtV0TrackProjLambdaMasses", "jetPtV0TrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/weighted/V0/jetPtV0TrackProjRadiusCosPA", "jetPtV0TrackProjRadiusCosPA", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/jets/weighted/V0/jetPtV0TrackProjDCAposneg", "jetPtV0TrackProjDCAposneg", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/jets/weighted/V0/jetPtV0TrackProjDCAd", "jetPtV0TrackProjDCAd", HistType::kTH3D, {jetPtAxis, zAxis, V0DCAdAxis}); + // Inclusive + registry.add("data/jets/V0/jetPtV0PtEtaPhi", "jetPtV0PtEtaPhi", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0EtaAxis, v0PhiAxis}); + registry.add("data/jets/V0/jetPtV0PtCtau", "jetPtV0PtCtau", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}); + registry.add("data/jets/V0/jetPtV0PtMass", "jetPtV0PtMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtV0PtMassWide", "jetPtV0PtMassWide", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, k0SWideAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtV0PtLambdaMasses", "jetPtV0PtLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}); + registry.add("data/jets/V0/jetPtV0PtRadiusCosPA", "jetPtV0PtRadiusCosPA", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/jets/V0/jetPtV0PtDCAposneg", "jetPtV0PtDCAposneg", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/jets/V0/jetPtV0PtDCAd", "jetPtV0PtDCAd", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0DCAdAxis}); + + registry.add("data/jets/V0/jetPtV0TrackProjCtau", "jetPtV0TrackProjCtau", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}); + registry.add("data/jets/V0/jetPtV0TrackProjMass", "jetPtV0TrackProjMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtV0TrackProjMassWide", "jetPtV0TrackProjMassWide", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SWideAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtV0TrackProjLambdaMasses", "jetPtV0TrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}); + registry.add("data/jets/V0/jetPtV0TrackProjRadiusCosPA", "jetPtV0TrackProjRadiusCosPA", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/jets/V0/jetPtV0TrackProjDCAposneg", "jetPtV0TrackProjDCAposneg", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/jets/V0/jetPtV0TrackProjDCAd", "jetPtV0TrackProjDCAd", HistType::kTH3D, {jetPtAxis, zAxis, v0DCAdAxis}); + // K0S - registry.add("data/jets/weighted/V0/jetPtK0STrackProjCtau", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, V0CtauAxis}); - registry.add("data/jets/weighted/V0/jetPtK0STrackProjMass", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, K0SMassAxis}); - registry.add("data/jets/weighted/V0/jetPtK0STrackProjAllMasses", "jetPtK0STrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/weighted/V0/jetPtK0STrackProjRadius", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, V0RadiusAxis}); - registry.add("data/jets/weighted/V0/jetPtK0STrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, V0CosPAAxis}); - registry.add("data/jets/weighted/V0/jetPtK0STrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, V0DCAdAxis}); - registry.add("data/jets/weighted/V0/jetPtK0STrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0DCApAxis, V0DCAnAxis}); + registry.add("data/jets/V0/jetPtK0SPtCtau", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, c#tau", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0CtauAxis}); + registry.add("data/jets/V0/jetPtK0SPtMass", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, mass", HistType::kTH3D, {jetPtAxis, v0PtAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0SPtAllMasses", "jetPtK0SPtAllMasses", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtK0SPtRadius", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, radius", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0RadiusAxis}); + registry.add("data/jets/V0/jetPtK0SPtCosPA", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, cosPA", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0CosPAAxis}); + registry.add("data/jets/V0/jetPtK0SPtDCAd", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, DCA daughters", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0DCAdAxis}); + registry.add("data/jets/V0/jetPtK0SPtDCAposneg", "Jet #it{p}_{T}, #it{p}_{T, K^{0}_{S}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/jets/V0/jetPtK0SPtCtauMass", "jetPtK0SPtCtauMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0CtauAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0SPtRadiusMass", "jetPtK0SPtRadiusMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0RadiusAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0SPtCosPAMass", "jetPtK0SPtCosPAMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0CosPAAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0SPtDCAposMass", "jetPtK0SPtDCAposMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCApAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0SPtDCAnegMass", "jetPtK0SPtDCAnegMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCAnAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0SPtDCAdMass", "jetPtK0SPtDCAdMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCAdAxis, k0SMassAxis}); + + registry.add("data/jets/V0/jetPtK0STrackProjCtau", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, v0CtauAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjMass", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjAllMasses", "jetPtK0STrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjRadius", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, v0RadiusAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, v0CosPAAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, v0DCAdAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjCtauMass", "jetPtK0STrackProjCtauMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjRadiusMass", "jetPtK0STrackProjRadiusMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjCosPAMass", "jetPtK0STrackProjCosPAMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CosPAAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjDCAposMass", "jetPtK0STrackProjDCAposMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjDCAnegMass", "jetPtK0STrackProjDCAnegMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAnAxis, k0SMassAxis}); + registry.add("data/jets/V0/jetPtK0STrackProjDCAdMass", "jetPtK0STrackProjDCAdMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAdAxis, k0SMassAxis}); + // Lambda - registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjCtau", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, V0CtauAxis}); - registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjMass", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, LambdaMassAxis}); - registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjAllMasses", "jetPtLambdaTrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjLambdaMasses", "jetPtLambdaTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjRadius", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, V0RadiusAxis}); - registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, V0CosPAAxis}); - registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, V0DCAdAxis}); - registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0DCApAxis, V0DCAnAxis}); - // AntiLambda - registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCtau", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, V0CtauAxis}); - registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjMass", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, LambdaMassAxis}); - registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjAllMasses", "jetPtAntiLambdaTrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjLambdaMasses", "jetPtAntiLambdaTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjRadius", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, V0RadiusAxis}); - registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, V0CosPAAxis}); - registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, V0DCAdAxis}); - registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0DCApAxis, V0DCAnAxis}); - // Background - registry.add("data/jets/weighted/V0/jetPtBkgTrackProjCtau", "jetPtBkgTrackProjCtau", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("data/jets/weighted/V0/jetPtBkgTrackProjMass", "jetPtBkgTrackProjMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/jets/weighted/V0/jetPtBkgTrackProjLambdaMasses", "jetPtBkgTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("data/jets/weighted/V0/jetPtBkgTrackProjRadiusCosPA", "jetPtBkgTrackProjRadiusCosPA", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAposneg", "jetPtBkgTrackProjDCAposneg", HistType::kTHnSparseD, {jetPtAxis, zAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAd", "jetPtBkgTrackProjDCAd", HistType::kTH3D, {jetPtAxis, zAxis, V0DCAdAxis}); - } + registry.add("data/jets/V0/jetPtLambdaPtCtau", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0CtauAxis}); + registry.add("data/jets/V0/jetPtLambdaPtMass", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, mass", HistType::kTH3D, {jetPtAxis, v0PtAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaPtAllMasses", "jetPtLambdaPtAllMasses", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaPtLambdaMasses", "jetPtLambdaPtLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}); + registry.add("data/jets/V0/jetPtLambdaPtRadius", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, radius", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0RadiusAxis}); + registry.add("data/jets/V0/jetPtLambdaPtCosPA", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0CosPAAxis}); + registry.add("data/jets/V0/jetPtLambdaPtDCAd", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0DCAdAxis}); + registry.add("data/jets/V0/jetPtLambdaPtDCAposneg", "Jet #it{p}_{T}, #it{p}_{T, #Lambda^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/jets/V0/jetPtLambdaPtCtauMass", "jetPtLambdaPtCtauMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0CtauAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaPtRadiusMass", "jetPtLambdaPtRadiusMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0RadiusAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaPtCosPAMass", "jetPtLambdaPtCosPAMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0CosPAAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaPtDCAposMass", "jetPtLambdaPtDCAposMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCApAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaPtDCAnegMass", "jetPtLambdaPtDCAnegMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCAnAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaPtDCAdMass", "jetPtLambdaPtDCAdMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCAdAxis, lambdaMassAxis}); + + registry.add("data/jets/V0/jetPtLambdaTrackProjCtau", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, v0CtauAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjMass", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjAllMasses", "jetPtLambdaTrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjLambdaMasses", "jetPtLambdaTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjRadius", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, v0RadiusAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, v0CosPAAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, v0DCAdAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjCtauMass", "jetPtLambdaTrackProjCtauMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjRadiusMass", "jetPtLambdaTrackProjRadiusMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjCosPAMass", "jetPtLambdaTrackProjCosPAMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CosPAAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjDCAposMass", "jetPtLambdaTrackProjDCAposMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjDCAnegMass", "jetPtLambdaTrackProjDCAnegMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAnAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtLambdaTrackProjDCAdMass", "jetPtLambdaTrackProjDCAdMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAdAxis, lambdaMassAxis}); - if (doprocessMcP || doprocessMcMatchedV0JetsFrag) { - registry.add("particle-level/jets/partJetPtEtaPhi", "Particle level jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {partJetPtAxis, partEtaAxis, partPhiAxis}); - } - if (doprocessMcP) { - registry.add("particle-level/nJetsnTracks", "nJetsnTracks; nJets; nTracks", HistType::kTH2D, {jetCount, trackCount}); - registry.add("particle-level/collision/partCollisionVtxZ", "Collision vertex z (cm)", HistType::kTH1D, {binVtxZ}); - registry.add("particle-level/tracks/partTrackPtEtaPhi", "partTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}); - registry.add("particle-level/jets/partJetPtTrackPt", "Particle level jet #it{p}_{T}, track #it{p}_{T}", HistType::kTH2D, {partJetPtAxis, trackPtAxis}); - registry.add("particle-level/jets/partJetTrackPtEtaPhi", "Particle level tracks in jets #it{p}_{T}, #eta, #phi", HistType::kTH3D, {trackPtAxis, partEtaAxis, partPhiAxis}); - registry.add("particle-level/jets/partJetPtFrag", "Particle level jet #it{p}_{T}, #it{p}_{T,jet}/#it{p}_{T,tr}", HistType::kTH2D, {partJetPtAxis, partZAxis}); - registry.add("particle-level/jets/partJetPtTrackProj", "Particle level jet #it{p}_{T}, #it{z}", HistType::kTH2D, {partJetPtAxis, partZAxis}); - registry.add("particle-level/jets/partJetPtXi", "Particle level jet #it{p}_{T}, #xi", HistType::kTH2D, {partJetPtAxis, partXiAxis}); - registry.add("particle-level/jets/partJetPtTheta", "Particle level jet #it{p}_{T}, #theta", HistType::kTH2D, {partJetPtAxis, partThetaAxis}); - registry.add("particle-level/jets/partJetPtXiTheta", "Particle level jet #it{p}_{T}, #xi, #theta", HistType::kTH3D, {partJetPtAxis, partXiAxis, partThetaAxis}); - registry.add("particle-level/jets/partJetPtZTheta", "Particle level jet #it{p}_{T}, z, #theta", HistType::kTH3D, {partJetPtAxis, partZAxis, partThetaAxis}); - } // doprocessMcP - - if (doprocessMcD || doprocessMcMatchedV0JetsFrag) { - registry.add("detector-level/jets/detJetPtEtaPhi", "Detector level jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {detJetPtAxis, detEtaAxis, detPhiAxis}); - } - if (doprocessMcD) { - registry.add("detector-level/nJetsnTracks", "nJetsnTracks; nJets; nTracks", HistType::kTH2D, {jetCount, trackCount}); - registry.add("detector-level/collision/detCollisionVtxZ", "Collision vertex z (cm)", HistType::kTH1D, {binVtxZ}); - registry.add("detector-level/tracks/detTrackPtEtaPhi", "detTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}); - registry.add("detector-level/jets/detJetPtTrackPt", "Detector level jet #it{p}_{T}, track #it{p}_{T}", HistType::kTH2D, {detJetPtAxis, trackPtAxis}); - registry.add("detector-level/jets/detJetTrackPtEtaPhi", "Detector level tracks in jets #it{p}_{T}, #eta, #phi", HistType::kTH3D, {trackPtAxis, detEtaAxis, detPhiAxis}); - registry.add("detector-level/jets/detJetPtFrag", "Detector level jet #it{p}_{T}, #it{p}_{T,jet}/#it{p}_{T,tr}", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("detector-level/jets/detJetPtTrackProj", "Detector level jet #it{p}_{T}, #it{z}", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("detector-level/jets/detJetPtXi", "Detector level jet #it{p}_{T}, #xi", HistType::kTH2D, {detJetPtAxis, detXiAxis}); - registry.add("detector-level/jets/detJetPtTheta", "Detector level jet #it{p}_{T}, #theta", HistType::kTH2D, {detJetPtAxis, detThetaAxis}); - registry.add("detector-level/jets/detJetPtXiTheta", "Detector level jet #it{p}_{T}, #xi, #theta", HistType::kTH3D, {detJetPtAxis, detXiAxis, detThetaAxis}); - registry.add("detector-level/jets/detJetPtZTheta", "Detector level jet #it{p}_{T}, z, #theta", HistType::kTH3D, {detJetPtAxis, detZAxis, detThetaAxis}); - } // doprocessMcD - - if (doprocessMcMatched || doprocessMcMatchedV0Frag || doprocessMcMatchedV0JetsFrag) { - registry.add("matching/jets/matchDetJetPtEtaPhi", "Matched detector level jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {detJetPtAxis, detEtaAxis, detPhiAxis}); - registry.add("matching/jets/matchPartJetPtEtaPhi", "Matched particle level jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {partJetPtAxis, partEtaAxis, partPhiAxis}); - registry.add("matching/jets/matchDetJetPtPartJetPt", "matchDetJetPtPartJetPt", HistType::kTH2D, {detJetPtAxis, partJetPtAxis}); - registry.add("matching/jets/matchPartJetPtDetJetEtaPartJetEta", "matchPartJetPtDetJetEtaPartJetEta", HistType::kTH3D, {partJetPtAxis, detEtaAxis, partEtaAxis}); - registry.add("matching/jets/matchPartJetPtDetJetPhiPartJetPhi", "matchPartJetPtDetJetPhiPartJetPhi", HistType::kTH3D, {partJetPtAxis, detPhiAxis, partPhiAxis}); - registry.add("matching/jets/matchPartJetPtResolutionPt", "#it{p}_{T}^{jet, det} - #it{p}_{T}^{jet, part}", HistType::kTH2D, {partJetPtAxis, ptDiffAxis}); - registry.add("matching/jets/matchPartJetPtRelDiffPt", "#it{p}_{T}^{jet, det} - #it{p}_{T}^{jet, part}", HistType::kTH2D, {partJetPtAxis, ptJetRelDiffAxis}); - registry.add("matching/jets/matchPartJetPtResolutionEta", "#eta^{jet, det} - #eta^{jet, part}", HistType::kTH3D, {partJetPtAxis, partEtaAxis, etaDiffAxis}); - registry.add("matching/jets/matchPartJetPtResolutionPhi", "#phi^{jet, det} - #phi^{jet, part}", HistType::kTH3D, {partJetPtAxis, partPhiAxis, phiDiffAxis}); - registry.add("matching/jets/matchPartJetPtEtaPhiMatchDist", "matchJetMatchDist", HistType::kTHnSparseD, {partJetPtAxis, partEtaAxis, partPhiAxis, matchDistAxis}); - registry.add("matching/jets/matchPartJetPtEnergyScale", "jetEnergyScale", HistType::kTH2D, {partJetPtAxis, ptRatioAxis}); - } // doprocessMcMatched || doprocessMcMatchedV0Frag - - if (doprocessMcMatched) { - registry.add("matching/collision/matchCollisionVtxZ", "Collision vertex z (cm)", HistType::kTH1D, {binVtxZ}); - registry.add("matching/tracks/matchDetTrackPtEtaPhi", "matchDetTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}); - registry.add("matching/tracks/matchPartTrackPtEtaPhi", "matchPartTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}); - registry.add("matching/tracks/matchDetTrackPtPartTrackPt", "matchDetTrackPtPartTrackPt", HistType::kTH2D, {trackPtAxis, trackPtAxis}); - registry.add("matching/tracks/matchDetTrackEtaPartTrackEta", "matchDetTrackEtaPartTrackEta", HistType::kTH2D, {etaAxis, etaAxis}); - registry.add("matching/tracks/matchDetTrackPhiPartTrackPhi", "matchDetTrackPhiPartTrackPhi", HistType::kTH2D, {phiAxis, phiAxis}); - registry.add("matching/tracks/trackResolutionPt", "trackResolutionPt", HistType::kTH2D, {trackPtAxis, ptDiffAxis}); - registry.add("matching/tracks/trackResolutionEta", "trackResolutionEta", HistType::kTH2D, {etaAxis, etaDiffAxis}); - registry.add("matching/tracks/trackResolutionPhi", "trackResolutionPhi", HistType::kTH2D, {phiAxis, phiDiffAxis}); - // Detector level jets with a match - registry.add("matching/jets/matchDetJetPtTrackPt", "Matched detector level jet #it{p}_{T}, track #it{p}_{T}", HistType::kTH2D, {detJetPtAxis, trackPtAxis}); - registry.add("matching/jets/matchDetJetTrackPtEtaPhi", "Matched detector level tracks in jets #it{p}_{T}, #eta, #phi", HistType::kTH3D, {trackPtAxis, detEtaAxis, detPhiAxis}); - registry.add("matching/jets/matchDetJetPtFrag", "Matched detector level jet #it{p}_{T}, #it{p}_{T,jet}/#it{p}_{T,tr}", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("matching/jets/matchDetJetPtTrackProj", "Matched detector level jet #it{p}_{T}, #it{z}", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("matching/jets/matchDetJetPtXi", "Matched detector level jet #it{p}_{T}, #xi", HistType::kTH2D, {detJetPtAxis, detXiAxis}); - registry.add("matching/jets/matchDetJetPtTheta", "Matched detector level jet #it{p}_{T}, #theta", HistType::kTH2D, {detJetPtAxis, detThetaAxis}); - registry.add("matching/jets/matchDetJetPtXiTheta", "Matched detector level jet #it{p}_{T}, #xi, #theta", HistType::kTH3D, {detJetPtAxis, detXiAxis, detThetaAxis}); - registry.add("matching/jets/matchDetJetPtZTheta", "Matched detector level jet #it{p}_{T}, z, #theta", HistType::kTH3D, {detJetPtAxis, detZAxis, detThetaAxis}); - // Particle level jets with a match - registry.add("matching/jets/matchPartJetPtTrackPt", "Matched particle level jet #it{p}_{T}, track #it{p}_{T}", HistType::kTH2D, {partJetPtAxis, trackPtAxis}); - registry.add("matching/jets/matchPartJetTrackPtEtaPhi", "Matched particle level tracks in jets #it{p}_{T}, #eta, #phi", HistType::kTH3D, {trackPtAxis, partEtaAxis, partPhiAxis}); - registry.add("matching/jets/matchPartJetPtFrag", "Matched particle level jet #it{p}_{T}, #it{p}_{T,jet}/#it{p}_{T,tr}", HistType::kTH2D, {partJetPtAxis, partZAxis}); - registry.add("matching/jets/matchPartJetPtTrackProj", "Matched particle level jet #it{p}_{T}, #it{z}", HistType::kTH2D, {partJetPtAxis, partZAxis}); - registry.add("matching/jets/matchPartJetPtXi", "Matched particle level jet #it{p}_{T}, #xi", HistType::kTH2D, {partJetPtAxis, partXiAxis}); - registry.add("matching/jets/matchPartJetPtTheta", "Matched particle level jet #it{p}_{T}, #theta", HistType::kTH2D, {partJetPtAxis, partThetaAxis}); - registry.add("matching/jets/matchPartJetPtXiTheta", "Matched particle level jet #it{p}_{T}, #xi, #theta", HistType::kTH3D, {partJetPtAxis, partXiAxis, partThetaAxis}); - registry.add("matching/jets/matchPartJetPtZTheta", "Matched particle level jet #it{p}_{T}, z, #theta", HistType::kTH3D, {partJetPtAxis, partZAxis, partThetaAxis}); - // Combined information of matched jets - registry.add("matching/jets/matchPartJetPtResolutionChargeFrag", "Resolution #it{p}_{T}^{tr} / #it{p}_{T}^{jet}", HistType::kTH3D, {partJetPtAxis, partZAxis, zDiffAxis}); - registry.add("matching/jets/matchPartJetPtResolutionTrackPt", "Resolution #it{p}_{T}^{track}", HistType::kTH3D, {partJetPtAxis, trackPtAxis, ptTrackDiffAxis}); - registry.add("matching/jets/matching/jets/matchPartJetPtRelDiffTrackPt", "Rel. diff #it{p}_{T}^{track}", HistType::kTHnSparseD, {partJetPtAxis, ptRatioAxis, trackPtAxis, ptTrackRelDiffAxis}); - registry.add("matching/jets/matchPartJetPtResolutionTrackProj", "Resolution #it{p}^{proj} / #it{p}^{jet}", HistType::kTH3D, {partJetPtAxis, partZAxis, zDiffAxis}); - registry.add("matching/jets/matchPartJetPtRelDiffTrackProj", "Rel. diff #it{p}^{proj} / #it{p}^{jet}", HistType::kTHnSparseD, {partJetPtAxis, ptRatioAxis, partZAxis, zRelDiffAxis}); - registry.add("matching/jets/matchPartJetPtResolutionXi", "Resolution ln(1/#it{z})", HistType::kTH3D, {partJetPtAxis, partXiAxis, xiDiffAxis}); - registry.add("matching/jets/matchPartJetPtResolutionTheta", "Resolution #theta", HistType::kTH3D, {partJetPtAxis, partThetaAxis, thetaDiffAxis}); - registry.add("matching/jets/matchPartJetPtResolutionXiResolutionTheta", "Resolution #xi, #theta", HistType::kTHnSparseD, {partJetPtAxis, partXiAxis, xiDiffAxis, partThetaAxis, thetaDiffAxis}); - registry.add("matching/jets/matchPartJetPtResolutionZResolutionTheta", "Resolution #it{z}, #theta", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, zDiffAxis, partThetaAxis, thetaDiffAxis}); - // QA histograms for fakes, misses - registry.add("matching/jets/fakeDetJetPtEtaPhi", "Fakes", HistType::kTH3D, {detJetPtAxis, detEtaAxis, detPhiAxis}); - registry.add("matching/jets/missPartJetPtEtaPhi", "Misses", HistType::kTH3D, {partJetPtAxis, partEtaAxis, partPhiAxis}); - // Response matrix, fakes, misses - registry.add("matching/jets/matchDetJetPtTrackProjPartJetPtTrackProj", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, partJetPtAxis, partZAxis}); - registry.add("matching/jets/fakeDetJetPtTrackProj", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("matching/jets/missPartJetPtTrackProj", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}); - - registry.add("matching/jets/matchDetJetPtXiPartJetPtXi", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detXiAxis, partJetPtAxis, partXiAxis}); - registry.add("matching/jets/fakeDetJetPtXi", "Fakes", HistType::kTH2D, {detJetPtAxis, detXiAxis}); - registry.add("matching/jets/missPartJetPtXi", "Misses", HistType::kTH2D, {partJetPtAxis, partXiAxis}); - - registry.add("matching/jets/matchDetJetPtFragPartJetPtFrag", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, partJetPtAxis, partZAxis}); - registry.add("matching/jets/fakeDetJetPtFrag", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("matching/jets/missPartJetPtFrag", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}); - - registry.add("matching/jets/matchDetJetPtThetaPartJetPtTheta", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detThetaAxis, partJetPtAxis, partThetaAxis}); - registry.add("matching/jets/fakeDetJetPtTheta", "Fakes", HistType::kTH2D, {detJetPtAxis, detThetaAxis}); - registry.add("matching/jets/missPartJetPtTheta", "Misses", HistType::kTH2D, {partJetPtAxis, partThetaAxis}); - - registry.add("matching/jets/matchDetJetPtXiThetaPartJetPtXiTheta", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detXiAxis, detThetaAxis, partJetPtAxis, partXiAxis, partThetaAxis}); - registry.add("matching/jets/fakeDetJetPtXiTheta", "Fakes", HistType::kTH3D, {detJetPtAxis, detXiAxis, detThetaAxis}); - registry.add("matching/jets/missPartJetPtXiTheta", "Misses", HistType::kTH3D, {partJetPtAxis, partXiAxis, partThetaAxis}); - - registry.add("matching/jets/matchDetJetPtZThetaPartJetPtZTheta", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, detThetaAxis, partJetPtAxis, partZAxis, partThetaAxis}); - registry.add("matching/jets/fakeDetJetPtZTheta", "Fakes", HistType::kTH3D, {detJetPtAxis, detZAxis, detThetaAxis}); - registry.add("matching/jets/missPartJetPtZTheta", "Misses", HistType::kTH3D, {partJetPtAxis, partZAxis, partThetaAxis}); - } // doprocessMcMatched - - if (doprocessMcMatchedV0 || doprocessMcMatchedV0Frag || doprocessMcMatchedV0JetsFrag || doprocessMcV0MatchedPerpCone) { + // AntiLambda + registry.add("data/jets/V0/jetPtAntiLambdaPtCtau", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0CtauAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtMass", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, mass", HistType::kTH3D, {jetPtAxis, v0PtAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtAllMasses", "jetPtAntiLambdaPtAllMasses", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtLambdaMasses", "jetPtAntiLambdaPtLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtRadius", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, radius", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0RadiusAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtCosPA", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0CosPAAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtDCAd", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, v0PtAxis, v0DCAdAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtDCAposneg", "Jet #it{p}_{T}, #it{p}_{T, #bar{#Lambda}^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtCtauMass", "jetPtAntiLambdaPtCtauMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0CtauAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtRadiusMass", "jetPtAntiLambdaPtRadiusMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0RadiusAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtCosPAMass", "jetPtAntiLambdaPtCosPAMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0CosPAAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtDCAposMass", "jetPtAntiLambdaPtDCAposMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCApAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtDCAnegMass", "jetPtAntiLambdaPtDCAnegMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCAnAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaPtDCAdMass", "jetPtAntiLambdaPtDCAdMass", HistType::kTHnSparseD, {jetPtAxis, v0PtAxis, v0DCAdAxis, lambdaMassAxis}); + + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjCtau", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, v0CtauAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjMass", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjAllMasses", "jetPtAntiLambdaTrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjLambdaMasses", "jetPtAntiLambdaTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjRadius", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, v0RadiusAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, v0CosPAAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, v0DCAdAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjCtauMass", "jetPtAntiLambdaTrackProjCtauMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjRadiusMass", "jetPtAntiLambdaTrackProjRadiusMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjCosPAMass", "jetPtAntiLambdaTrackProjCosPAMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CosPAAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjDCAposMass", "jetPtAntiLambdaTrackProjDCAposMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjDCAnegMass", "jetPtAntiLambdaTrackProjDCAnegMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAnAxis, lambdaMassAxis}); + registry.add("data/jets/V0/jetPtAntiLambdaTrackProjDCAdMass", "jetPtAntiLambdaTrackProjDCAdMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAdAxis, lambdaMassAxis}); + + // Weighted histograms + registry.add("data/jets/weighted/jetPtEtaPhi", "Jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {jetPtAxis, etaAxis, phiAxis}, true); + registry.add("data/jets/weighted/V0/jetPtnV0nK0SnLambdanAntiLambda", "jetPtnV0nK0SnLambdanAntiLambda", HistType::kTHnSparseD, {jetPtAxis, v0Weight, v0Weight, v0Weight, v0Weight}, true); + + // Inclusive Weighted + registry.add("data/jets/weighted/V0/jetPtV0TrackProjCtau", "jetPtV0TrackProjCtau", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("data/jets/weighted/V0/jetPtV0TrackProjMass", "jetPtV0TrackProjMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtV0TrackProjMassWide", "jetPtV0TrackProjMassWide", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SWideAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtV0TrackProjLambdaMasses", "jetPtV0TrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("data/jets/weighted/V0/jetPtV0TrackProjRadiusCosPA", "jetPtV0TrackProjRadiusCosPA", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("data/jets/weighted/V0/jetPtV0TrackProjDCAposneg", "jetPtV0TrackProjDCAposneg", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("data/jets/weighted/V0/jetPtV0TrackProjDCAd", "jetPtV0TrackProjDCAd", HistType::kTH3D, {jetPtAxis, zAxis, v0DCAdAxis}, true); + + // K0S Weighted + registry.add("data/jets/weighted/V0/jetPtK0STrackProjMass", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjCtau", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, v0CtauAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjAllMasses", "jetPtK0STrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjRadius", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, v0RadiusAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, v0CosPAAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, v0DCAdAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{K^{0}_{S}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjCtauMass", "jetPtK0STrackProjCtauMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjRadiusMass", "jetPtK0STrackProjRadiusMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjCosPAMass", "jetPtK0STrackProjCosPAMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CosPAAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjDCAposMass", "jetPtK0STrackProjDCAposMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjDCAnegMass", "jetPtK0STrackProjDCAnegMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAnAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtK0STrackProjDCAdMass", "jetPtK0STrackProjDCAdMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAdAxis, k0SMassAxis}, true); + + // Lambda Weighted + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjMass", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjCtau", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, v0CtauAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjAllMasses", "jetPtLambdaTrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjLambdaMasses", "jetPtLambdaTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjRadius", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, v0RadiusAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, v0CosPAAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, v0DCAdAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{#Lambda^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjCtauMass", "jetPtLambdaTrackProjCtauMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjRadiusMass", "jetPtLambdaTrackProjRadiusMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjCosPAMass", "jetPtLambdaTrackProjCosPAMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjDCAposMass", "jetPtLambdaTrackProjDCAposMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjDCAnegMass", "jetPtLambdaTrackProjDCAnegMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtLambdaTrackProjDCAdMass", "jetPtLambdaTrackProjDCAdMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAdAxis, lambdaMassAxis}, true); + + // AntiLambda Weighted + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjMass", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, mass", HistType::kTH3D, {jetPtAxis, zAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCtau", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, c#tau", HistType::kTH3D, {jetPtAxis, zAxis, v0CtauAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjAllMasses", "jetPtAntiLambdaTrackProjAllMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjLambdaMasses", "jetPtAntiLambdaTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjRadius", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, radius", HistType::kTH3D, {jetPtAxis, zAxis, v0RadiusAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCosPA", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, cosPA", HistType::kTH3D, {jetPtAxis, zAxis, v0CosPAAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAd", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, DCA daughters", HistType::kTH3D, {jetPtAxis, zAxis, v0DCAdAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAposneg", "Jet #it{p}_{T}, #it{z}_{#bar{#Lambda}^{0}}, DCA#pm", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCtauMass", "jetPtAntiLambdaTrackProjCtauMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjRadiusMass", "jetPtAntiLambdaTrackProjRadiusMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCosPAMass", "jetPtAntiLambdaTrackProjCosPAMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAposMass", "jetPtAntiLambdaTrackProjDCAposMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAnegMass", "jetPtAntiLambdaTrackProjDCAnegMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAdMass", "jetPtAntiLambdaTrackProjDCAdMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAdAxis, lambdaMassAxis}, true); + + // Background Weighted + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjMass", "jetPtBkgTrackProjMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjCtau", "jetPtBkgTrackProjCtau", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjLambdaMasses", "jetPtBkgTrackProjLambdaMasses", HistType::kTHnSparseD, {jetPtAxis, zAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjRadiusCosPA", "jetPtBkgTrackProjRadiusCosPA", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAposneg", "jetPtBkgTrackProjDCAposneg", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAd", "jetPtBkgTrackProjDCAd", HistType::kTH3D, {jetPtAxis, zAxis, v0DCAdAxis}, true); + + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjCtauK0SMass", "jetPtBkgTrackProjCtauK0SMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjRadiusK0SMass", "jetPtBkgTrackProjRadiusK0SMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjCosPAK0SMass", "jetPtBkgTrackProjCosPAK0SMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CosPAAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAposK0SMass", "jetPtBkgTrackProjDCAposK0SMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAnegK0SMass", "jetPtBkgTrackProjDCAnegK0SMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAnAxis, k0SMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAdK0SMass", "jetPtBkgTrackProjDCAdK0SMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAdAxis, k0SMassAxis}, true); + + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjCtauLambdaMass", "jetPtBkgTrackProjCtauLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjRadiusLambdaMass", "jetPtBkgTrackProjRadiusLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjCosPALambdaMass", "jetPtBkgTrackProjCosPALambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAposLambdaMass", "jetPtBkgTrackProjDCAposLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAnegLambdaMass", "jetPtBkgTrackProjDCAnegLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAdLambdaMass", "jetPtBkgTrackProjDCAdLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAdAxis, lambdaMassAxis}, true); + + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjCtauAntiLambdaMass", "jetPtBkgTrackProjCtauAntiLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjRadiusAntiLambdaMass", "jetPtBkgTrackProjRadiusAntiLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjCosPAAntiLambdaMass", "jetPtBkgTrackProjCosPAAntiLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAposAntiLambdaMass", "jetPtBkgTrackProjDCAposAntiLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAnegAntiLambdaMass", "jetPtBkgTrackProjDCAnegAntiLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("data/jets/weighted/V0/jetPtBkgTrackProjDCAdAntiLambdaMass", "jetPtBkgTrackProjDCAdAntiLambdaMass", HistType::kTHnSparseD, {jetPtAxis, zAxis, v0DCAdAxis, lambdaMassAxis}, true); + } + + if (doprocessMcMatchedV0) { + // MCP + registry.add("mcp/V0/nV0sEventAcc", "nV0s per event (accepted)", HistType::kTH1D, {v0Count}, true); + registry.add("mcp/V0/nV0sEventAccWeighted", "nV0s per event (accepted, weighted)", HistType::kTH1D, {v0Weight}, true); + registry.add("mcp/V0/V0PtEtaPhi", "V0PtEtaPhi", HistType::kTH3D, {v0partPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("mcp/V0/K0SPtEtaPhi", "K0SPtEtaPhi", HistType::kTH3D, {v0partPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("mcp/V0/LambdaPtEtaPhi", "LambdaPtEtaPhi", HistType::kTH3D, {v0partPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("mcp/V0/AntiLambdaPtEtaPhi", "AntiLambdaPtEtaPhi", HistType::kTH3D, {v0partPtAxis, v0EtaAxis, v0PhiAxis}, true); + + // MCD Inclusive + registry.add("mcd/V0/nV0sEventAcc", "nV0s per event (accepted)", HistType::kTH1D, {v0Count}); + registry.add("mcd/V0/nV0sEventAccWeighted", "nV0s per event (accepted, weighted)", HistType::kTH1D, {v0Weight}, true); + registry.add("mcd/V0/V0PtEtaPhi", "V0PtEtaPhi", HistType::kTH3D, {v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("mcd/V0/V0PtCtau", "V0PtCtau", HistType::kTHnSparseD, {v0detPtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("mcd/V0/V0PtMass", "V0PtMass", HistType::kTHnSparseD, {v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/V0PtLambdaMasses", "V0PtLambdaMasses", HistType::kTHnSparseD, {v0detPtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("mcd/V0/V0PtRadiusCosPA", "V0PtRadiusCosPA", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("mcd/V0/V0PtDCAposneg", "V0PtDCAposneg", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("mcd/V0/V0PtDCAd", "V0PtDCAd", HistType::kTH2D, {v0detPtAxis, v0DCAdAxis}, true); + + // MCD K0S + registry.add("mcd/V0/K0SPtEtaPhi", "K0SPtEtaPhi", HistType::kTH3D, {v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("mcd/V0/K0SPtRadiusCosPA", "K0SPtRadiusCosPA", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("mcd/V0/K0SPtDCAposneg", "K0SPtDCAposneg", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("mcd/V0/K0SPtDCAd", "K0SPtDCAd", HistType::kTH2D, {v0detPtAxis, v0DCAdAxis}, true); + registry.add("mcd/V0/K0SPtCtauMass", "K0SPtCtauMass", HistType::kTH3D, {v0detPtAxis, v0CtauAxis, k0SMassAxis}, true); + registry.add("mcd/V0/K0SPtRadiusMass", "K0SPtRadiusMass", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, k0SMassAxis}, true); + registry.add("mcd/V0/K0SPtCosPAMass", "K0SPtCosPAMass", HistType::kTH3D, {v0detPtAxis, v0CosPAAxis, k0SMassAxis}, true); + registry.add("mcd/V0/K0SPtDCAposMass", "K0SPtDCAposMass", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, k0SMassAxis}, true); + registry.add("mcd/V0/K0SPtDCAnegMass", "K0SPtDCAnegMass", HistType::kTH3D, {v0detPtAxis, v0DCAnAxis, k0SMassAxis}, true); + registry.add("mcd/V0/K0SPtDCAdMass", "K0SPtDCAdMass", HistType::kTH3D, {v0detPtAxis, v0DCAdAxis, k0SMassAxis}, true); + + // MCD Lambda + registry.add("mcd/V0/LambdaPtEtaPhi", "LambdaPtEtaPhi", HistType::kTH3D, {v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("mcd/V0/LambdaPtLambdaMasses", "LambdaPtLambdaMasses", HistType::kTHnSparseD, {v0detPtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("mcd/V0/LambdaPtRadiusCosPA", "LambdaPtRadiusCosPA", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("mcd/V0/LambdaPtDCAposneg", "LambdaPtDCAposneg", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("mcd/V0/LambdaPtDCAd", "LambdaPtDCAd", HistType::kTH2D, {v0detPtAxis, v0DCAdAxis}, true); + registry.add("mcd/V0/LambdaPtCtauMass", "LambdaPtCtauMass", HistType::kTH3D, {v0detPtAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/LambdaPtRadiusMass", "LambdaPtRadiusMass", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/LambdaPtCosPAMass", "LambdaPtCosPAMass", HistType::kTH3D, {v0detPtAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/LambdaPtDCAposMass", "LambdaPtDCAposMass", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/LambdaPtDCAnegMass", "LambdaPtDCAnegMass", HistType::kTH3D, {v0detPtAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/LambdaPtDCAdMass", "LambdaPtDCAdMass", HistType::kTH3D, {v0detPtAxis, v0DCAdAxis, lambdaMassAxis}, true); + + // MCD AntiLambda + registry.add("mcd/V0/AntiLambdaPtEtaPhi", "AntiLambdaPtEtaPhi", HistType::kTH3D, {v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("mcd/V0/AntiLambdaPtLambdaMasses", "AntiLambdaPtLambdaMasses", HistType::kTHnSparseD, {v0detPtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("mcd/V0/AntiLambdaPtRadiusCosPA", "AntiLambdaPtRadiusCosPA", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("mcd/V0/AntiLambdaPtDCAposneg", "AntiLambdaPtDCAposneg", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("mcd/V0/AntiLambdaPtDCAd", "AntiLambdaPtDCAd", HistType::kTH2D, {v0detPtAxis, v0DCAdAxis}, true); + registry.add("mcd/V0/AntiLambdaPtCtauMass", "AntiLambdaPtCtauMass", HistType::kTH3D, {v0detPtAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/AntiLambdaPtRadiusMass", "AntiLambdaPtRadiusMass", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/AntiLambdaPtCosPAMass", "AntiLambdaPtCosPAMass", HistType::kTH3D, {v0detPtAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/AntiLambdaPtDCAposMass", "AntiLambdaPtDCAposMass", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/AntiLambdaPtDCAnegMass", "AntiLambdaPtDCAnegMass", HistType::kTH3D, {v0detPtAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("mcd/V0/AntiLambdaPtDCAdMass", "AntiLambdaPtDCAdMass", HistType::kTH3D, {v0detPtAxis, v0DCAdAxis, lambdaMassAxis}, true); + + // Matching - Misses + registry.add("matching/V0/missV0PtEtaPhi", "missV0PtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/missK0SPtEtaPhi", "missK0SPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/missLambdaPtEtaPhi", "missLambdaPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/missAntiLambdaPtEtaPhi", "missAntiLambdaPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + + // Matching - Fakes Inclusive + registry.add("matching/V0/fakeV0PtEtaPhi", "fakeV0PtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/fakeV0PtCtau", "fakeV0PtCtau", HistType::kTHnSparseD, {v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/V0/fakeV0PtMass", "fakeV0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeV0PtLambdaMasses", "fakeV0PtLambdaMasses", HistType::kTHnSparseD, {v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/V0/fakeV0PtRadiusCosPA", "fakeV0PtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/V0/fakeV0PtDCAposneg", "fakeV0PtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/V0/fakeV0PtDCAd", "fakeV0PtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}, true); + registry.add("matching/V0/fakeV0PosTrackPtEtaPhi", "fakeV0PosTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}, true); + registry.add("matching/V0/fakeV0NegTrackPtEtaPhi", "fakeV0NegTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}, true); + + // Matching - Fakes K0S + registry.add("matching/V0/fakeK0SPtEtaPhi", "K0SPtEtaPhi", HistType::kTH3D, {v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/fakeK0SPtRadiusCosPA", "K0SPtRadiusCosPA", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/V0/fakeK0SPtDCAposneg", "K0SPtDCAposneg", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/V0/fakeK0SPtDCAd", "K0SPtDCAd", HistType::kTH2D, {v0detPtAxis, v0DCAdAxis}, true); + registry.add("matching/V0/fakeK0SPtCtauMass", "K0SPtCtauMass", HistType::kTH3D, {v0detPtAxis, v0CtauAxis, k0SMassAxis}, true); + registry.add("matching/V0/fakeK0SPtRadiusMass", "K0SPtRadiusMass", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, k0SMassAxis}, true); + registry.add("matching/V0/fakeK0SPtCosPAMass", "K0SPtCosPAMass", HistType::kTH3D, {v0detPtAxis, v0CosPAAxis, k0SMassAxis}, true); + registry.add("matching/V0/fakeK0SPtDCAposMass", "K0SPtDCAposMass", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, k0SMassAxis}, true); + registry.add("matching/V0/fakeK0SPtDCAnegMass", "K0SPtDCAnegMass", HistType::kTH3D, {v0detPtAxis, v0DCAnAxis, k0SMassAxis}, true); + registry.add("matching/V0/fakeK0SPtDCAdMass", "K0SPtDCAdMass", HistType::kTH3D, {v0detPtAxis, v0DCAdAxis, k0SMassAxis}, true); + registry.add("matching/V0/fakeK0SPosTrackPtEtaPhi", "fakeK0SPosTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}, true); + registry.add("matching/V0/fakeK0SPosTrackPtMass", "fakeK0SPosTrackPtMass", HistType::kTH3D, {v0detPtAxis, trackPtAxis, k0SMassAxis}, true); + registry.add("matching/V0/fakeK0SNegTrackPtEtaPhi", "fakeK0SNegTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}, true); + registry.add("matching/V0/fakeK0SNegTrackPtMass", "fakeK0SNegTrackPtMass", HistType::kTH3D, {v0detPtAxis, trackPtAxis, k0SMassAxis}, true); + + // Matching - Fakes Lambda + registry.add("matching/V0/fakeLambdaPtEtaPhi", "LambdaPtEtaPhi", HistType::kTH3D, {v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/fakeLambdaPtLambdaMasses", "LambdaPtLambdaMasses", HistType::kTHnSparseD, {v0detPtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/V0/fakeLambdaPtRadiusCosPA", "LambdaPtRadiusCosPA", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/V0/fakeLambdaPtDCAposneg", "LambdaPtDCAposneg", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/V0/fakeLambdaPtDCAd", "LambdaPtDCAd", HistType::kTH2D, {v0detPtAxis, v0DCAdAxis}, true); + registry.add("matching/V0/fakeLambdaPtCtauMass", "LambdaPtCtauMass", HistType::kTH3D, {v0detPtAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeLambdaPtRadiusMass", "LambdaPtRadiusMass", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeLambdaPtCosPAMass", "LambdaPtCosPAMass", HistType::kTH3D, {v0detPtAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeLambdaPtDCAposMass", "LambdaPtDCAposMass", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeLambdaPtDCAnegMass", "LambdaPtDCAnegMass", HistType::kTH3D, {v0detPtAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeLambdaPtDCAdMass", "LambdaPtDCAdMass", HistType::kTH3D, {v0detPtAxis, v0DCAdAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeLambdaPosTrackPtEtaPhi", "fakeLambdaPosTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}, true); + registry.add("matching/V0/fakeLambdaPosTrackPtMass", "fakeLambdaPosTrackPtMass", HistType::kTH3D, {v0detPtAxis, trackPtAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeLambdaNegTrackPtEtaPhi", "fakeLambdaNegTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}, true); + registry.add("matching/V0/fakeLambdaNegTrackPtMass", "fakeLambdaNegTrackPtMass", HistType::kTH3D, {v0detPtAxis, trackPtAxis, lambdaMassAxis}, true); + + // Matching - Fakes AntiLambda + registry.add("matching/V0/fakeAntiLambdaPtEtaPhi", "AntiLambdaPtEtaPhi", HistType::kTH3D, {v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtLambdaMasses", "AntiLambdaPtLambdaMasses", HistType::kTHnSparseD, {v0detPtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtRadiusCosPA", "AntiLambdaPtRadiusCosPA", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtDCAposneg", "AntiLambdaPtDCAposneg", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtDCAd", "AntiLambdaPtDCAd", HistType::kTH2D, {v0detPtAxis, v0DCAdAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtCtauMass", "AntiLambdaPtCtauMass", HistType::kTH3D, {v0detPtAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtRadiusMass", "AntiLambdaPtRadiusMass", HistType::kTH3D, {v0detPtAxis, v0RadiusAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtCosPAMass", "AntiLambdaPtCosPAMass", HistType::kTH3D, {v0detPtAxis, v0CosPAAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtDCAposMass", "AntiLambdaPtDCAposMass", HistType::kTH3D, {v0detPtAxis, v0DCApAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtDCAnegMass", "AntiLambdaPtDCAnegMass", HistType::kTH3D, {v0detPtAxis, v0DCAnAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPtDCAdMass", "AntiLambdaPtDCAdMass", HistType::kTH3D, {v0detPtAxis, v0DCAdAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPosTrackPtEtaPhi", "fakeAntiLambdaPosTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}, true); + registry.add("matching/V0/fakeAntiLambdaPosTrackPtMass", "fakeAntiLambdaPosTrackPtMass", HistType::kTH3D, {v0detPtAxis, trackPtAxis, lambdaMassAxis}, true); + registry.add("matching/V0/fakeAntiLambdaNegTrackPtEtaPhi", "fakeAntiLambdaNegTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}, true); + registry.add("matching/V0/fakeAntiLambdaNegTrackPtMass", "fakeAntiLambdaNegTrackPtMass", HistType::kTH3D, {v0detPtAxis, trackPtAxis, lambdaMassAxis}, true); + + // Matching - Matched registry.add("matching/V0/nV0sEvent", "nV0sDet per event", HistType::kTH1D, {v0Count}); - registry.add("matching/V0/nV0sEventWeighted", "nV0sDet per event (weighted)", HistType::kTH1D, {v0Count}); - registry.get(HIST("matching/V0/nV0sEventWeighted"))->Sumw2(); - } // doprocessMcMatchedV0 || doprocessMcMatchedV0Frag - - if (doprocessMcMatchedV0 || doprocessMcMatchedV0JetsFrag) { - registry.add("matching/V0/V0PartPtDetPt", "V0PartPtDetPt", HistType::kTH2D, {V0partPtAxis, V0detPtAxis}); - registry.add("matching/V0/V0PartPtRatioPtRelDiffPt", "V0PartPtRatioRelDiffPt", HistType::kTH3D, {V0partPtAxis, V0PtRatioAxis, V0PtRelDiffAxis}); - - registry.add("matching/V0/K0SPtEtaPhi", "K0SPtEtaPhi", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/V0/K0SPtCtauMass", "K0SPtCtauMass", HistType::kTHnSparseD, {V0partPtAxis, V0partPtAxis, V0CtauAxis, K0SMassAxis}); - registry.add("matching/V0/K0SPtRadiusCosPA", "K0SPtRadiusCosPA", HistType::kTHnSparseD, {V0partPtAxis, V0partPtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/V0/K0SPtDCAposneg", "K0SPtDCAposneg", HistType::kTHnSparseD, {V0partPtAxis, V0partPtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/V0/K0SPtDCAd", "K0SPtDCAd", HistType::kTH3D, {V0partPtAxis, V0detPtAxis, V0DCAdAxis}); - registry.add("matching/V0/K0SPtMass", "K0SPtMass", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - - registry.add("matching/V0/LambdaPtEtaPhi", "LambdaPtEtaPhi", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/V0/LambdaPtCtauMass", "LambdaPtCtauMass", HistType::kTHnSparseD, {V0partPtAxis, V0partPtAxis, V0CtauAxis, LambdaMassAxis}); - registry.add("matching/V0/LambdaPtRadiusCosPA", "LambdaPtRadiusCosPA", HistType::kTHnSparseD, {V0partPtAxis, V0partPtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/V0/LambdaPtDCAposneg", "LambdaPtDCAposneg", HistType::kTHnSparseD, {V0partPtAxis, V0partPtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/V0/LambdaPtDCAd", "LambdaPtDCAd", HistType::kTH3D, {V0partPtAxis, V0detPtAxis, V0DCAdAxis}); - registry.add("matching/V0/LambdaPtMass", "LambdaPtMass", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - - registry.add("matching/V0/antiLambdaPtEtaPhi", "antiLambdaPtEtaPhi", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/V0/antiLambdaPtCtauMass", "antiLambdaPtCtauMass", HistType::kTHnSparseD, {V0partPtAxis, V0partPtAxis, V0CtauAxis, LambdaMassAxis}); - registry.add("matching/V0/antiLambdaPtRadiusCosPA", "antiLambdaPtRadiusCosPA", HistType::kTHnSparseD, {V0partPtAxis, V0partPtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/V0/antiLambdaPtDCAposneg", "antiLambdaPtDCAposneg", HistType::kTHnSparseD, {V0partPtAxis, V0partPtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/V0/antiLambdaPtDCAd", "antiLambdaPtDCAd", HistType::kTH3D, {V0partPtAxis, V0detPtAxis, V0DCAdAxis}); - registry.add("matching/V0/antiLambdaPtMass", "antiLambdaPtMass", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - - // Reflections - registry.add("matching/V0/Lambda0Reflection", "pt, pt, mK, mL, maL, Lambda0Reflection", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/V0/antiLambda0Reflection", "pt, pt, mK, mL, maL, antiLambda0Reflection", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis, LambdaMassAxis}); + registry.add("matching/V0/nV0sEventWeighted", "nV0sDet per event (weighted)", HistType::kTH1D, {v0Count}, true); + registry.add("matching/V0/nV0sEventAcc", "nV0sDet per event (accepted, matched)", HistType::kTH1D, {v0Count}, true); + registry.add("matching/V0/nV0sEventAccWeighted", "nV0sDet per event (accepted, matched, weighted)", HistType::kTH1D, {v0Weight}, true); + + // Matching - Matched Inclusive + registry.add("matching/V0/V0PartPtDetPt", "V0PartPtDetPt", HistType::kTH2D, {v0partPtAxis, v0detPtAxis}, true); + registry.add("matching/V0/V0PartPtRatioPtRelDiffPt", "V0PartPtRatioRelDiffPt", HistType::kTH3D, {v0partPtAxis, v0PtRatioAxis, v0PtRelDiffAxis}, true); + + // Matching - Matched K0S + registry.add("matching/V0/K0SPtEtaPhi", "K0SPtEtaPhi", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/K0SPtCtauMass", "K0SPtCtauMass", HistType::kTHnSparseD, {v0partPtAxis, v0partPtAxis, v0CtauAxis, k0SMassAxis}, true); + registry.add("matching/V0/K0SPtRadiusCosPA", "K0SPtRadiusCosPA", HistType::kTHnSparseD, {v0partPtAxis, v0partPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/V0/K0SPtDCAposneg", "K0SPtDCAposneg", HistType::kTHnSparseD, {v0partPtAxis, v0partPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/V0/K0SPtDCAd", "K0SPtDCAd", HistType::kTH3D, {v0partPtAxis, v0detPtAxis, v0DCAdAxis}, true); + registry.add("matching/V0/K0SPtMass", "K0SPtMass", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + + // Matching - Matched Lambda + registry.add("matching/V0/LambdaPtEtaPhi", "LambdaPtEtaPhi", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/LambdaPtCtauMass", "LambdaPtCtauMass", HistType::kTHnSparseD, {v0partPtAxis, v0partPtAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("matching/V0/LambdaPtRadiusCosPA", "LambdaPtRadiusCosPA", HistType::kTHnSparseD, {v0partPtAxis, v0partPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/V0/LambdaPtDCAposneg", "LambdaPtDCAposneg", HistType::kTHnSparseD, {v0partPtAxis, v0partPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/V0/LambdaPtDCAd", "LambdaPtDCAd", HistType::kTH3D, {v0partPtAxis, v0detPtAxis, v0DCAdAxis}, true); + registry.add("matching/V0/LambdaPtMass", "LambdaPtMass", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/V0/LambdaReflection", "pt, pt, mK, mL, maL, LambdaReflection", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + + // Matching - Matched AntiLambda + registry.add("matching/V0/AntiLambdaPtEtaPhi", "AntiLambdaPtEtaPhi", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/V0/AntiLambdaPtCtauMass", "AntiLambdaPtCtauMass", HistType::kTHnSparseD, {v0partPtAxis, v0partPtAxis, v0CtauAxis, lambdaMassAxis}, true); + registry.add("matching/V0/AntiLambdaPtRadiusCosPA", "AntiLambdaPtRadiusCosPA", HistType::kTHnSparseD, {v0partPtAxis, v0partPtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/V0/AntiLambdaPtDCAposneg", "AntiLambdaPtDCAposneg", HistType::kTHnSparseD, {v0partPtAxis, v0partPtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/V0/AntiLambdaPtDCAd", "AntiLambdaPtDCAd", HistType::kTH3D, {v0partPtAxis, v0detPtAxis, v0DCAdAxis}, true); + registry.add("matching/V0/AntiLambdaPtMass", "AntiLambdaPtMass", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/V0/AntiLambdaReflection", "pt, pt, mK, mL, maL, AntiLambdaReflection", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + + // Matching - Matched Daughters + registry.add("matching/V0/V0PosPartPtRatioPtRelDiffPt", "V0PosPartPtRatioRelDiffPt", HistType::kTH3D, {trackPtAxis, ptRatioAxis, ptTrackRelDiffAxis}, true); + registry.add("matching/V0/V0NegPartPtRatioPtRelDiffPt", "V0NegPartPtRatioRelDiffPt", HistType::kTH3D, {trackPtAxis, ptRatioAxis, ptTrackRelDiffAxis}, true); + registry.add("matching/V0/K0SPosNegPtMass", "K0SPosNegPtMass", HistType::kTHnSparseD, {v0partPtAxis, trackPtAxis, trackPtAxis, k0SMassAxis}, true); + registry.add("matching/V0/LambdaPosNegPtMass", "LambdaPosNegPtMass", HistType::kTHnSparseD, {v0partPtAxis, trackPtAxis, trackPtAxis, lambdaMassAxis}, true); + registry.add("matching/V0/AntiLambdaPosNegPtMass", "AntiLambdaPosNegPtMass", HistType::kTHnSparseD, {v0partPtAxis, trackPtAxis, trackPtAxis, lambdaMassAxis}, true); } // doprocessMcMatchedV0 - if (doprocessMcMatchedV0Frag) { - registry.add("matching/jets/V0/jetPtnV0Matched", "jet pt, nV0 matched", HistType::kTH2D, {detJetPtAxis, v0Count}); - } - if (doprocessMcMatchedV0Frag || doprocessMcMatchedV0JetsFrag) { - registry.add("matching/jets/V0/jetPtnV0MatchednK0SnLambdanAntiLambda", "jet Pt, nV0 matched, nK0S nLambdan AntiLambda", HistType::kTHnSparseD, {detJetPtAxis, v0Count, v0Count, v0Count, v0Count}); - registry.add("matching/jets/V0/partJetPtV0PtDetPt", "V0PartPtDetPt", HistType::kTH3D, {partJetPtAxis, V0partPtAxis, V0detPtAxis}); - registry.add("matching/jets/V0/partJetPtDetJetPtPartV0PtRatioPtRelDiffPt", "V0PartPtRatioRelDiffPt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0partPtAxis, V0PtRatioAxis, V0PtRelDiffAxis}); - - // ----------------------------- - // Unidentified V0s - // ----------------------------- - registry.add("matching/jets/V0/matchDetJetPtV0TrackProjPartJetPtV0TrackProj", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, partJetPtAxis, partZAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0Pt", "matched jet Pt, V0 Pt", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis}); - // Matched V0: pt - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauLambda0", "matched jet Pt, V0 Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauAntiLambda0", "matched jet Pt, V0 Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauK0S", "matched jet Pt, V0 Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassLambda0", "matched jet Pt, V0 Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassAntiLambda0", "matched jet Pt, V0 Pt, Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassK0S", "matched jet Pt, V0 Pt, MassK0S", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtRadius", "matched jet Pt, V0 Pt, Radius", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0RadiusAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCosPA", "matched jet Pt, V0 Pt, CosPA", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtDCAposneg", "matched jet Pt, V0 Pt, DCAposneg", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtDCAd", "matched jet Pt, V0 Pt, DCAd", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0DCAdAxis}); - // Matched Lambda0: z - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauLambda0", "matched jet Pt, V0 z, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauAntiLambda0", "matched jet Pt, V0 z, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauK0S", "matched jet Pt, V0 z, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassLambda0", "matched jet Pt, V0 z, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassAntiLambda0", "matched jet Pt, V0 z, Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassK0S", "matched jet Pt, V0 z, MassK0S", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, K0SMassAxis}); - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjRadius", "matched jet Pt, V0 z, Radius", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0RadiusAxis}); - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCosPA", "matched jet Pt, V0 z, CosPA", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjDCAposneg", "matched jet Pt, V0 z, DCAposneg", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjDCAd", "matched jet Pt, V0 z, DCAd", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0DCAdAxis}); - // Fakes - registry.add("matching/jets/V0/fakeJetPtV0TrackProj", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("matching/jets/V0/fakeJetPtV0PtEtaPhi", "fake jet Pt, V0 PtEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/jets/V0/fakeJetPtV0PtCtau", "fake jet Pt, V0 PtCtau", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/jets/V0/fakeJetPtV0PtMass", "fake jet Pt, V0 PtMass", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/fakeJetPtV0PtLambdaMasses", "fake jet Pt, V0 PtLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("matching/jets/V0/fakeJetPtV0PtRadiusCosPA", "fake jet Pt, V0 PtRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/fakeJetPtV0PtDCAposneg", "fake jet Pt, V0 PtDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/fakeJetPtV0PtDCAd", "fake jet Pt, V0 PtDCAd", HistType::kTH3D, {detJetPtAxis, V0PtAxis, V0DCAdAxis}); - registry.add("matching/jets/V0/fakeJetPtV0TrackProjCtau", "fake jet Pt, V0 zCtau", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/jets/V0/fakeJetPtV0TrackProjMass", "fake jet Pt, V0 zMass", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/fakeJetPtV0TrackProjLambdaMasses", "fake jet Pt, V0 zLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("matching/jets/V0/fakeJetPtV0TrackProjRadiusCosPA", "fake jet Pt, V0 zRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/fakeJetPtV0TrackProjDCAposneg", "fake jet Pt, V0 zDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/fakeJetPtV0TrackProjDCAd", "fake jet Pt, V0 zDCAd", HistType::kTH3D, {detJetPtAxis, detZAxis, V0DCAdAxis}); - // Misses - registry.add("matching/jets/V0/missJetPtV0PtEtaPhi", "miss jet Pt, V0 PtEtaPhi", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/jets/V0/missJetPtV0TrackProj", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}); - - // ----------------------------- - // Lambda0 - // ----------------------------- - registry.add("matching/jets/V0/matchDetJetPtLambda0TrackProjPartJetPtLambda0TrackProj", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, partJetPtAxis, partZAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0Pt", "matched jet Pt, #Lambda^{0} Pt", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis}); - // Matched Lambda0: pt - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtCtauLambda0", "matched jet Pt, #Lambda^{0} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtCtauAntiLambda0", "matched jet Pt, #Lambda^{0} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtMassLambda0", "matched jet Pt, #Lambda^{0} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtMassAntiLambda0", "matched jet Pt, #Lambda^{0} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtMassK0S", "matched jet Pt, #Lambda^{0} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtAllMasses", "matched jet Pt, #Lambda^{0} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtRadius", "matched jet Pt, #Lambda^{0} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0RadiusAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtCosPA", "matched jet Pt, #Lambda^{0} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtDCAposneg", "matched jet Pt, #Lambda^{0} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtDCAd", "matched jet Pt, #Lambda^{0} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0DCAdAxis}); - // Matched Lambda0: z - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjCtauLambda0", "matched jet Pt, #Lambda^{0} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjCtauAntiLambda0", "matched jet Pt, #Lambda^{0} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjMassLambda0", "matched jet Pt, #Lambda^{0} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjMassAntiLambda0", "matched jet Pt, #Lambda^{0} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjMassK0S", "matched jet Pt, #Lambda^{0} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, K0SMassAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjAllMasses", "matched jet Pt, #Lambda^{0} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjRadius", "matched jet Pt, #Lambda^{0} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0RadiusAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjCosPA", "matched jet Pt, #Lambda^{0} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjDCAposneg", "matched jet Pt, #Lambda^{0} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjDCAd", "matched jet Pt, #Lambda^{0} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0DCAdAxis}); - // Fake Lambda0 - registry.add("matching/jets/V0/fakeJetPtLambda0TrackProj", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0PtEtaPhi", "fake jet Pt, #Lambda^{0} PtEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0PtCtau", "fake jet Pt, #Lambda^{0} PtCtau", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0PtMass", "fake jet Pt, #Lambda^{0} PtMass", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0PtLambdaMasses", "fake jet Pt, #Lambda^{0} PtLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0PtRadiusCosPA", "fake jet Pt, #Lambda^{0} PtRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0PtDCAposneg", "fake jet Pt, #Lambda^{0} PtDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0PtDCAd", "fake jet Pt, #Lambda^{0} PtDCAd", HistType::kTH3D, {detJetPtAxis, V0PtAxis, V0DCAdAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0TrackProjEtaPhi", "fake jet Pt, #Lambda^{0} zEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0TrackProjCtau", "fake jet Pt, #Lambda^{0} zCtau", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0TrackProjMass", "fake jet Pt, #Lambda^{0} zMass", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0TrackProjLambdaMasses", "fake jet Pt, #Lambda^{0} zLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0TrackProjRadiusCosPA", "fake jet Pt, #Lambda^{0} zRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0TrackProjDCAposneg", "fake jet Pt, #Lambda^{0} zDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/fakeJetPtLambda0TrackProjDCAd", "fake jet Pt, #Lambda^{0} zDCAd", HistType::kTH3D, {detJetPtAxis, detZAxis, V0DCAdAxis}); - // Missed Lambda0 - registry.add("matching/jets/V0/missJetPtLambda0TrackProj", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}); - registry.add("matching/jets/V0/missJetPtLambda0PtEtaPhi", "miss jet Pt, #Lambda^{0} PtEtaPhi", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, V0EtaAxis, V0PhiAxis}); - - // ----------------------------- - // AntiLambda0 - // ----------------------------- - registry.add("matching/jets/V0/matchDetJetPtAntiLambda0TrackProjPartJetPtAntiLambda0TrackProj", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, partJetPtAxis, partZAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0Pt", "matched jet Pt, #bar{#Lambda}^{0} Pt", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis}); - // Matched AntiLambda0: pt - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtCtauLambda0", "matched jet Pt, #bar{#Lambda}^{0} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtCtauAntiLambda0", "matched jet Pt, #bar{#Lambda}^{0} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtMassLambda0", "matched jet Pt, #bar{#Lambda}^{0} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtMassAntiLambda0", "matched jet Pt, #bar{#Lambda}^{0} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtMassK0S", "matched jet Pt, #bar{#Lambda}^{0} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtAllMasses", "matched jet Pt, #bar{#Lambda}^{0} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtRadius", "matched jet Pt, #bar{#Lambda}^{0} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0RadiusAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtCosPA", "matched jet Pt, #bar{#Lambda}^{0} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtDCAposneg", "matched jet Pt, #bar{#Lambda}^{0} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtDCAd", "matched jet Pt, #bar{#Lambda}^{0} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0DCAdAxis}); - // Matched AntiLambda0: z - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjCtauLambda0", "matched jet Pt, #bar{#Lambda}^{0} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjCtauAntiLambda0", "matched jet Pt, #bar{#Lambda}^{0} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjMassLambda0", "matched jet Pt, #bar{#Lambda}^{0} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjMassAntiLambda0", "matched jet Pt, #bar{#Lambda}^{0} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjMassK0S", "matched jet Pt, #bar{#Lambda}^{0} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, K0SMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjAllMasses", "matched jet Pt, #bar{#Lambda}^{0} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjRadius", "matched jet Pt, #bar{#Lambda}^{0} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0RadiusAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjCosPA", "matched jet Pt, #bar{#Lambda}^{0} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjDCAposneg", "matched jet Pt, #bar{#Lambda}^{0} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjDCAd", "matched jet Pt, #bar{#Lambda}^{0} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0DCAdAxis}); - // Fake AntiLambda0 - registry.add("matching/jets/V0/fakeJetPtAntiLambda0TrackProj", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0PtEtaPhi", "fake jet Pt, #bar{#Lambda}^{0} PtEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0PtCtau", "fake jet Pt, #bar{#Lambda}^{0} PtCtau", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0PtMass", "fake jet Pt, #bar{#Lambda}^{0} PtMass", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0PtLambdaMasses", "fake jet Pt, #bar{#Lambda}^{0} PtLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0PtRadiusCosPA", "fake jet Pt, #bar{#Lambda}^{0} PtRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0PtDCAposneg", "fake jet Pt, #bar{#Lambda}^{0} PtDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0PtDCAd", "fake jet Pt, #bar{#Lambda}^{0} PtDCAd", HistType::kTH3D, {detJetPtAxis, V0PtAxis, V0DCAdAxis}); - - registry.add("matching/jets/V0/fakeJetPtAntiLambda0TrackProjCtau", "fake jet Pt, #bar{#Lambda}^{0} zCtau", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0TrackProjMass", "fake jet Pt, #bar{#Lambda}^{0} zMass", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0TrackProjLambdaMasses", "fake jet Pt, #bar{#Lambda}^{0} zLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0TrackProjRadiusCosPA", "fake jet Pt, #bar{#Lambda}^{0} zRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0TrackProjDCAposneg", "fake jet Pt, #bar{#Lambda}^{0} zDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/fakeJetPtAntiLambda0TrackProjDCAd", "fake jet Pt, #bar{#Lambda}^{0} zDCAd", HistType::kTH3D, {detJetPtAxis, detZAxis, V0DCAdAxis}); - // Missed AntiLambda0 - registry.add("matching/jets/V0/missJetPtAntiLambda0TrackProj", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}); - registry.add("matching/jets/V0/missJetPtAntiLambda0PtEtaPhi", "miss jet Pt, #bar{#Lambda}^{0} PtEtaPhi", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, V0EtaAxis, V0PhiAxis}); - - // ----------------------------- - // K0S - // ----------------------------- - registry.add("matching/jets/V0/matchDetJetPtK0STrackProjPartJetPtK0STrackProj", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, partJetPtAxis, partZAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPt", "matched jet Pt, K_{S}^{0} Pt", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis}); - // Matched K0S: pt - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauLambda0", "matched jet Pt, K^{0}_{S} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauAntiLambda0", "matched jet Pt, K^{0}_{S} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassLambda0", "matched jet Pt, K^{0}_{S} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassAntiLambda0", "matched jet Pt, K^{0}_{S} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassK0S", "matched jet Pt, K^{0}_{S} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtAllMasses", "matched jet Pt, K^{0}_{S} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtRadius", "matched jet Pt, K^{0}_{S} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0RadiusAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCosPA", "matched jet Pt, K^{0}_{S} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtDCAposneg", "matched jet Pt, K^{0}_{S} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtDCAd", "matched jet Pt, K^{0}_{S} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, detJetPtAxis, V0PtAxis, V0DCAdAxis}); - // Matched K0S: z - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauLambda0", "matched jet Pt, K^{0}_{S} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauAntiLambda0", "matched jet Pt, K^{0}_{S} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CtauAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassLambda0", "matched jet Pt, K^{0}_{S} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassAntiLambda0", "matched jet Pt, K^{0}_{S} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassK0S", "matched jet Pt, K^{0}_{S} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, K0SMassAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjAllMasses", "matched jet Pt, K^{0}_{S} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjRadius", "matched jet Pt, K^{0}_{S} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0RadiusAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCosPA", "matched jet Pt, K^{0}_{S} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjDCAposneg", "matched jet Pt, K^{0}_{S} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjDCAd", "matched jet Pt, K^{0}_{S} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, V0DCAdAxis}); - // Fake K0S - registry.add("matching/jets/V0/fakeJetPtK0STrackProj", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}); - registry.add("matching/jets/V0/fakeJetPtK0SPtEtaPhi", "fake jet Pt, K^{0}_{S} PtEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/jets/V0/fakeJetPtK0SPtCtau", "fake jet Pt, K^{0}_{S} PtCtau", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/jets/V0/fakeJetPtK0SPtMass", "fake jet Pt, K^{0}_{S} PtMass", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/fakeJetPtK0SPtLambdaMasses", "fake jet Pt, K^{0}_{S} PtLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("matching/jets/V0/fakeJetPtK0SPtRadiusCosPA", "fake jet Pt, K^{0}_{S} PtRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/fakeJetPtK0SPtDCAposneg", "fake jet Pt, K^{0}_{S} PtDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/fakeJetPtK0SPtDCAd", "fake jet Pt, K^{0}_{S} PtDCAd", HistType::kTH3D, {detJetPtAxis, V0PtAxis, V0DCAdAxis}); - - registry.add("matching/jets/V0/fakeJetPtK0STrackProjCtau", "fake jet Pt, K^{0}_{S} zCtau", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/jets/V0/fakeJetPtK0STrackProjMass", "fake jet Pt, K^{0}_{S} zMass", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/fakeJetPtK0STrackProjLambdaMasses", "fake jet Pt, K^{0}_{S} zLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("matching/jets/V0/fakeJetPtK0STrackProjRadiusCosPA", "fake jet Pt, K^{0}_{S} zRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/jets/V0/fakeJetPtK0STrackProjDCAposneg", "fake jet Pt, K^{0}_{S} zDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/jets/V0/fakeJetPtK0STrackProjDCAd", "fake jet Pt, K^{0}_{S} zDCAd", HistType::kTH3D, {detJetPtAxis, detZAxis, V0DCAdAxis}); - // Missed K0S - registry.add("matching/jets/V0/missJetPtK0STrackProj", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}); - registry.add("matching/jets/V0/missJetPtK0SPtEtaPhi", "miss jet Pt, K^{0}_{S} PtEtaPhi", HistType::kTHnSparseD, {partJetPtAxis, V0PtAxis, V0EtaAxis, V0PhiAxis}); - - // Reflections - registry.add("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtLambda0Reflection", "Lambda0 Reflection", HistType::kTHnSparseD, {partJetPtAxis, V0partPtAxis, detJetPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjLambda0Reflection", "Lambda0 Reflection", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtAntiLambda0Reflection", "antiLambda0 Reflection", HistType::kTHnSparseD, {partJetPtAxis, V0partPtAxis, detJetPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjAntiLambda0Reflection", "antiLambda0 Reflection", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis, LambdaMassAxis}); - } // doprocessMcMatchedV0Frag - if (doprocessMcMatchedV0JetsFrag) { - registry.add("matching/V0/fakeV0PtEtaPhi", "fakeV0PtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/V0/fakeV0PtCtau", "fakeV0PtCtau", HistType::kTHnSparseD, {V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/V0/fakeV0PtMass", "fakeV0PtMass", HistType::kTHnSparseD, {V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/V0/fakeV0PtLambdaMasses", "fakeV0PtLambdaMasses", HistType::kTHnSparseD, {V0PtAxis, LambdaMassDiffAxis, LambdaMassRatioAxis, LambdaMassRelDiffAxis}); - registry.add("matching/V0/fakeV0PtRadiusCosPA", "fakeV0PtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/V0/fakeV0PtDCAposneg", "fakeV0PtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/V0/fakeV0PtDCAd", "fakeV0PtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); - - registry.add("matching/V0/fakeV0PosTrackPtEtaPhi", "fakeV0PosTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}); - registry.add("matching/V0/fakeV0NegTrackPtEtaPhi", "fakeV0NegTrackPtEtaPhi", HistType::kTH3D, {trackPtAxis, etaAxis, phiAxis}); - - registry.add("matching/V0/V0PosPartPtRatioPtRelDiffPt", "V0PosPartPtRatioRelDiffPt", HistType::kTH3D, {trackPtAxis, ptRatioAxis, ptTrackRelDiffAxis}); - registry.add("matching/V0/V0NegPartPtRatioPtRelDiffPt", "V0NegPartPtRatioRelDiffPt", HistType::kTH3D, {trackPtAxis, ptRatioAxis, ptTrackRelDiffAxis}); - - registry.add("matching/jets/V0/partJetPtDetJetPtPartV0PtPosPtRatioPtRelDiffPt", "V0PtPosPartPtRatioRelDiffPt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0PtAxis, trackPtAxis, ptRatioAxis, ptTrackRelDiffAxis}); - registry.add("matching/jets/V0/partJetPtDetJetPtPartV0PtNegPtRatioPtRelDiffPt", "V0PtNegPartPtRatioRelDiffPt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0PtAxis, trackPtAxis, ptRatioAxis, ptTrackRelDiffAxis}); - - registry.add("matching/V0/nonedecayedFakeV0PtMass", "nonedecayedFakeV0PtMass", HistType::kTHnSparseD, {V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/V0/doubledecayedFakeV0PtMass", "doubledecayedFakeV0PtMass", HistType::kTHnSparseD, {V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/V0/decayedK0SV0PtMass", "decayedK0SV0PtMass", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/V0/decayedLambdaV0PtMass", "decayedLambdaV0PtMass", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/V0/decayedAntiLambdaV0PtMass", "decayedAntiLambdaV0PtMass", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/V0/decayedOtherPtV0PtMass", "decayedOtherPtV0PtMass", HistType::kTHnSparseD, {V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - - registry.add("matching/jets/V0/nonedecayedFakeV0PtMass", "nonedecayedFakeV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/nonedecayedFakeV0TrackProjMass", "nonedecayedFakeV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/doubledecayedFakeV0PtMass", "doubledecayedFakeV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/doubledecayedFakeV0TrackProjMass", "doubledecayedFakeV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, zAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/decayedK0SV0PtMass", "decayedK0SV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/decayedK0SV0TrackProjMass", "decayedK0SV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, partZAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/decayedLambdaV0PtMass", "decayedLambdaV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/decayedLambdaV0TrackProjMass", "decayedLambdaV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, partZAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/decayedAntiLambdaV0PtMass", "decayedAntiLambdaV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/decayedAntiLambdaV0TrackProjMass", "decayedAntiLambdaV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, partZAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/decayedOtherPtV0PtMass", "decayedOtherPtV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0partPtAxis, V0detPtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/jets/V0/decayedOtherPtV0TrackProjMass", "decayedOtherPtV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, partZAxis, detZAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); + // Matching - Jets + registry.add("mcp/jets/partJetPtEtaPhi", "Particle level jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {partJetPtAxis, partEtaAxis, partPhiAxis}, true); + registry.add("mcd/jets/detJetPtEtaPhi", "Detector level jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {detJetPtAxis, detEtaAxis, detPhiAxis}, true); + + registry.add("matching/jets/matchDetJetPtEtaPhi", "Matched detector level jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {detJetPtAxis, detEtaAxis, detPhiAxis}, true); + registry.add("matching/jets/matchPartJetPtEtaPhi", "Matched particle level jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {partJetPtAxis, partEtaAxis, partPhiAxis}, true); + registry.add("matching/jets/matchPartJetPtEtaPhiMatchDist", "matchJetMatchDist", HistType::kTHnSparseD, {partJetPtAxis, partEtaAxis, partPhiAxis, matchDistAxis}, true); + registry.add("matching/jets/matchPartJetPtEnergyScale", "jetEnergyScale", HistType::kTH2D, {partJetPtAxis, ptRatioAxis}, true); + registry.add("matching/jets/matchDetJetPtPartJetPt", "matchDetJetPtPartJetPt", HistType::kTH2D, {detJetPtAxis, partJetPtAxis}, true); + registry.add("matching/jets/matchPartJetPtDetJetEtaPartJetEta", "matchPartJetPtDetJetEtaPartJetEta", HistType::kTH3D, {partJetPtAxis, detEtaAxis, partEtaAxis}, true); + registry.add("matching/jets/matchPartJetPtDetJetPhiPartJetPhi", "matchPartJetPtDetJetPhiPartJetPhi", HistType::kTH3D, {partJetPtAxis, detPhiAxis, partPhiAxis}, true); + registry.add("matching/jets/matchPartJetPtResolutionPt", "#it{p}_{T}^{jet, det} - #it{p}_{T}^{jet, part}", HistType::kTH2D, {partJetPtAxis, ptDiffAxis}, true); + registry.add("matching/jets/matchPartJetPtResolutionEta", "#eta^{jet, det} - #eta^{jet, part}", HistType::kTH3D, {partJetPtAxis, partEtaAxis, etaDiffAxis}, true); + registry.add("matching/jets/matchPartJetPtResolutionPhi", "#phi^{jet, det} - #phi^{jet, part}", HistType::kTH3D, {partJetPtAxis, partPhiAxis, phiDiffAxis}, true); + registry.add("matching/jets/matchPartJetPtRelDiffPt", "#it{p}_{T}^{jet, det} - #it{p}_{T}^{jet, part}", HistType::kTH2D, {partJetPtAxis, ptJetRelDiffAxis}, true); + + registry.add("matching/jets/V0/jetPtnV0MatchednK0SnLambdanAntiLambda", "jet Pt, nV0 matched, nK0S nLambdan AntiLambda", HistType::kTHnSparseD, {detJetPtAxis, v0Count, v0Count, v0Count, v0Count}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetPt", "V0PartPtDetPt", HistType::kTH3D, {partJetPtAxis, v0partPtAxis, v0detPtAxis}, true); + registry.add("matching/jets/V0/partJetPtDetJetPtPartV0PtRatioPtRelDiffPt", "V0PartPtRatioRelDiffPt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0partPtAxis, v0PtRatioAxis, v0PtRelDiffAxis}, true); + + // Matching - Matched V0s + registry.add("matching/jets/V0/matchDetJetPtV0TrackProjPartJetPtV0TrackProj", "Matched", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, partJetPtAxis, partZAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0Pt", "matched jet Pt, V0 Pt", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + // Matching - Matched V0s: pt + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauK0S", "matched jet Pt, V0 Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauLambda", "matched jet Pt, V0 Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauAntiLambda", "matched jet Pt, V0 Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassK0S", "matched jet Pt, V0 Pt, MassK0S", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassLambda", "matched jet Pt, V0 Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassAntiLambda", "matched jet Pt, V0 Pt, Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtRadius", "matched jet Pt, V0 Pt, Radius", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0RadiusAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCosPA", "matched jet Pt, V0 Pt, CosPA", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtDCAposneg", "matched jet Pt, V0 Pt, DCAposneg", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/partJetPtV0PtDetJetPtV0PtDCAd", "matched jet Pt, V0 Pt, DCAd", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0DCAdAxis}, true); + // Matching - Matched V0s: z + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauK0S", "matched jet Pt, V0 z, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauLambda", "matched jet Pt, V0 z, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauAntiLambda", "matched jet Pt, V0 z, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassK0S", "matched jet Pt, V0 z, MassK0S", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, k0SMassAxis}, true); + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassLambda", "matched jet Pt, V0 z, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassAntiLambda", "matched jet Pt, V0 z, Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjRadius", "matched jet Pt, V0 z, Radius", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0RadiusAxis}, true); + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCosPA", "matched jet Pt, V0 z, CosPA", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjDCAposneg", "matched jet Pt, V0 z, DCAposneg", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjDCAd", "matched jet Pt, V0 z, DCAd", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0DCAdAxis}, true); + + // Matching - Fake V0s: pt + registry.add("matching/jets/V0/fakeJetPtV0PtEtaPhi", "fake jet Pt, V0 PtEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0TrackProj", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0PtCtau", "fake jet Pt, V0 PtCtau", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0PtMass", "fake jet Pt, V0 PtMass", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0PtLambdaMasses", "fake jet Pt, V0 PtLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0PtRadiusCosPA", "fake jet Pt, V0 PtRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0PtDCAposneg", "fake jet Pt, V0 PtDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0PtDCAd", "fake jet Pt, V0 PtDCAd", HistType::kTH3D, {detJetPtAxis, v0PtAxis, v0DCAdAxis}, true); + // Matching - Fake V0s: z + registry.add("matching/jets/V0/fakeJetPtV0TrackProjCtau", "fake jet Pt, V0 zCtau", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0TrackProjMass", "fake jet Pt, V0 zMass", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0TrackProjLambdaMasses", "fake jet Pt, V0 zLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0TrackProjRadiusCosPA", "fake jet Pt, V0 zRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0TrackProjDCAposneg", "fake jet Pt, V0 zDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/fakeJetPtV0TrackProjDCAd", "fake jet Pt, V0 zDCAd", HistType::kTH3D, {detJetPtAxis, detZAxis, v0DCAdAxis}, true); + // Matching - Missed V0s + registry.add("matching/jets/V0/missJetPtV0PtEtaPhi", "miss jet Pt, V0 PtEtaPhi", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/jets/V0/missJetPtV0TrackProj", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}, true); + + // Matching - Matched K0S + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPt", "Matched Pt and pt", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProj", "Matched pt and z", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis}, true); + + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtRightCollision", "Matched Pt, right collision", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjRightCollision", "Matched pt and z, right collision", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis}, true); + + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtWrongCollision", "Matched Pt, wrong collision", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjWrongCollision", "Matched pt and z, wrong collision", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis}, true); + + // Matching - Matched K0S: pt + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauLambda", "matched jet Pt, K^{0}_{S} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauAntiLambda", "matched jet Pt, K^{0}_{S} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassLambda", "matched jet Pt, K^{0}_{S} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassAntiLambda", "matched jet Pt, K^{0}_{S} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassK0S", "matched jet Pt, K^{0}_{S} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtAllMasses", "matched jet Pt, K^{0}_{S} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtRadius", "matched jet Pt, K^{0}_{S} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0RadiusAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCosPA", "matched jet Pt, K^{0}_{S} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtDCAposneg", "matched jet Pt, K^{0}_{S} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtDCAd", "matched jet Pt, K^{0}_{S} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0DCAdAxis}, true); + // Matching - Matched K0S: z + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauLambda", "matched jet Pt, K^{0}_{S} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauAntiLambda", "matched jet Pt, K^{0}_{S} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassLambda", "matched jet Pt, K^{0}_{S} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassAntiLambda", "matched jet Pt, K^{0}_{S} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassK0S", "matched jet Pt, K^{0}_{S} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, k0SMassAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjAllMasses", "matched jet Pt, K^{0}_{S} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjRadius", "matched jet Pt, K^{0}_{S} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0RadiusAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCosPA", "matched jet Pt, K^{0}_{S} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjDCAposneg", "matched jet Pt, K^{0}_{S} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjDCAd", "matched jet Pt, K^{0}_{S} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0DCAdAxis}, true); + // Matching - Fake K0S: pt + registry.add("matching/jets/V0/fakeJetPtK0SPtEtaPhi", "fake jet Pt, K^{0}_{S} PtEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0STrackProj", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0SPtCtau", "fake jet Pt, K^{0}_{S} PtCtau", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0SPtMass", "fake jet Pt, K^{0}_{S} PtMass", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0SPtLambdaMasses", "fake jet Pt, K^{0}_{S} PtLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0SPtRadiusCosPA", "fake jet Pt, K^{0}_{S} PtRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0SPtDCAposneg", "fake jet Pt, K^{0}_{S} PtDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0SPtDCAd", "fake jet Pt, K^{0}_{S} PtDCAd", HistType::kTH3D, {detJetPtAxis, v0PtAxis, v0DCAdAxis}, true); + // Matching - Fake K0S: z + registry.add("matching/jets/V0/fakeJetPtK0STrackProjCtau", "fake jet Pt, K^{0}_{S} zCtau", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0STrackProjMass", "fake jet Pt, K^{0}_{S} zMass", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0STrackProjLambdaMasses", "fake jet Pt, K^{0}_{S} zLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0STrackProjRadiusCosPA", "fake jet Pt, K^{0}_{S} zRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0STrackProjDCAposneg", "fake jet Pt, K^{0}_{S} zDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/fakeJetPtK0STrackProjDCAd", "fake jet Pt, K^{0}_{S} zDCAd", HistType::kTH3D, {detJetPtAxis, detZAxis, v0DCAdAxis}, true); + // Matching - Missed K0S + registry.add("matching/jets/V0/missJetPtK0SPtEtaPhi", "miss jet Pt, K^{0}_{S} PtEtaPhi", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/jets/V0/missJetPtK0STrackProj", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}, true); + + // Matching - Matched Lambda + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPt", "matched Pt", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProj", "Matched pt and z", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis}, true); + + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtRightCollision", "matched Pt, right collision", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjRightCollision", "Matched pt and z, right collision", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis}, true); + + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtWrongCollision", "matched Pt, Wrong collision", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjWrongCollision", "Matched pt and z, Wrong collision", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis}, true); + + // Matching - Matched Lambda: pt + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtCtauLambda", "matched jet Pt, #Lambda^{0} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtCtauAntiLambda", "matched jet Pt, #Lambda^{0} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtMassK0S", "matched jet Pt, #Lambda^{0} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtMassLambda", "matched jet Pt, #Lambda^{0} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtMassAntiLambda", "matched jet Pt, #Lambda^{0} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtAllMasses", "matched jet Pt, #Lambda^{0} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtRadius", "matched jet Pt, #Lambda^{0} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0RadiusAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtCosPA", "matched jet Pt, #Lambda^{0} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtDCAposneg", "matched jet Pt, #Lambda^{0} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtDCAd", "matched jet Pt, #Lambda^{0} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0DCAdAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtLambdaReflection", "Lambda Reflection", HistType::kTHnSparseD, {partJetPtAxis, v0partPtAxis, detJetPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + // Matching - Matched Lambda: z + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjCtauLambda", "matched jet Pt, #Lambda^{0} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjCtauAntiLambda", "matched jet Pt, #Lambda^{0} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjMassLambda", "matched jet Pt, #Lambda^{0} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjMassAntiLambda", "matched jet Pt, #Lambda^{0} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjMassK0S", "matched jet Pt, #Lambda^{0} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, k0SMassAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjAllMasses", "matched jet Pt, #Lambda^{0} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjRadius", "matched jet Pt, #Lambda^{0} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0RadiusAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjCosPA", "matched jet Pt, #Lambda^{0} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjDCAposneg", "matched jet Pt, #Lambda^{0} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjDCAd", "matched jet Pt, #Lambda^{0} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0DCAdAxis}, true); + registry.add("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjLambdaReflection", "Lambda Reflection", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + // Matching - Fake Lambda: pt + registry.add("matching/jets/V0/fakeJetPtLambdaPtEtaPhi", "fake jet Pt, #Lambda^{0} PtEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaTrackProj", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaPtCtau", "fake jet Pt, #Lambda^{0} PtCtau", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaPtMass", "fake jet Pt, #Lambda^{0} PtMass", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaPtLambdaMasses", "fake jet Pt, #Lambda^{0} PtLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaPtRadiusCosPA", "fake jet Pt, #Lambda^{0} PtRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaPtDCAposneg", "fake jet Pt, #Lambda^{0} PtDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaPtDCAd", "fake jet Pt, #Lambda^{0} PtDCAd", HistType::kTH3D, {detJetPtAxis, v0PtAxis, v0DCAdAxis}, true); + // Matching - Fake Lambda: z + registry.add("matching/jets/V0/fakeJetPtLambdaTrackProjEtaPhi", "fake jet Pt, #Lambda^{0} zEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaTrackProjCtau", "fake jet Pt, #Lambda^{0} zCtau", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaTrackProjMass", "fake jet Pt, #Lambda^{0} zMass", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaTrackProjLambdaMasses", "fake jet Pt, #Lambda^{0} zLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaTrackProjRadiusCosPA", "fake jet Pt, #Lambda^{0} zRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaTrackProjDCAposneg", "fake jet Pt, #Lambda^{0} zDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/fakeJetPtLambdaTrackProjDCAd", "fake jet Pt, #Lambda^{0} zDCAd", HistType::kTH3D, {detJetPtAxis, detZAxis, v0DCAdAxis}, true); + // Matching - Missed Lambda + registry.add("matching/jets/V0/missJetPtLambdaPtEtaPhi", "miss jet Pt, #Lambda^{0} PtEtaPhi", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/jets/V0/missJetPtLambdaTrackProj", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}, true); + + // Matching - Matched AntiLambda + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPt", "matched Pt", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProj", "Matched pt and z", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis}, true); + + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtRightCollision", "matched Pt, right collision", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjRightCollision", "Matched pt and z, right collision", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis}, true); + + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtWrongCollision", "matched Pt, Wrong collision", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjWrongCollision", "Matched pt and z, Wrong collision", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis}, true); + + // Matching - Matched AntiLambda: pt + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtCtauLambda", "matched jet Pt, #bar{#Lambda}^{0} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtCtauAntiLambda", "matched jet Pt, #bar{#Lambda}^{0} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtMassK0S", "matched jet Pt, #bar{#Lambda}^{0} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtMassLambda", "matched jet Pt, #bar{#Lambda}^{0} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtMassAntiLambda", "matched jet Pt, #bar{#Lambda}^{0} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtAllMasses", "matched jet Pt, #bar{#Lambda}^{0} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtRadius", "matched jet Pt, #bar{#Lambda}^{0} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0RadiusAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtCosPA", "matched jet Pt, #bar{#Lambda}^{0} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtDCAposneg", "matched jet Pt, #bar{#Lambda}^{0} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtDCAd", "matched jet Pt, #bar{#Lambda}^{0} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, detJetPtAxis, v0PtAxis, v0DCAdAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtAntiLambdaReflection", "AntiLambda Reflection", HistType::kTHnSparseD, {partJetPtAxis, v0partPtAxis, detJetPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + // Matching - Matched AntiLambda: z + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjCtauLambda", "matched jet Pt, #bar{#Lambda}^{0} Pt, Ctau #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjCtauAntiLambda", "matched jet Pt, #bar{#Lambda}^{0} Pt, Ctau #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjCtauK0S", "matched jet Pt, #{K}^{0}_{S} Pt, Ctau #{K}^{0}_{S}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjMassLambda", "matched jet Pt, #bar{#Lambda}^{0} Pt, Mass #Lambda^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjMassAntiLambda", "matched jet Pt, #bar{#Lambda}^{0} Pt Mass #bar{#Lambda}^{0}", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjMassK0S", "matched jet Pt, #bar{#Lambda}^{0} PtMassK0S", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, k0SMassAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjAllMasses", "matched jet Pt, #bar{#Lambda}^{0} Pt, Masses", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjRadius", "matched jet Pt, #bar{#Lambda}^{0} Pt Radius", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0RadiusAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjCosPA", "matched jet Pt, #bar{#Lambda}^{0} Pt CosPA", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjDCAposneg", "matched jet Pt, #bar{#Lambda}^{0} PtDCAposneg", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjDCAd", "matched jet Pt, #bar{#Lambda}^{0} PtDCAd", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, v0DCAdAxis}, true); + registry.add("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjAntiLambdaReflection", "AntiLambda Reflection", HistType::kTHnSparseD, {partJetPtAxis, partZAxis, detJetPtAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + // Matching - Fake AntiLambda: pt + registry.add("matching/jets/V0/fakeJetPtAntiLambdaPtEtaPhi", "fake jet Pt, #bar{#Lambda}^{0} PtEtaPhi", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaTrackProj", "Fakes", HistType::kTH2D, {detJetPtAxis, detZAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaPtCtau", "fake jet Pt, #bar{#Lambda}^{0} PtCtau", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaPtMass", "fake jet Pt, #bar{#Lambda}^{0} PtMass", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaPtLambdaMasses", "fake jet Pt, #bar{#Lambda}^{0} PtLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaPtRadiusCosPA", "fake jet Pt, #bar{#Lambda}^{0} PtRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaPtDCAposneg", "fake jet Pt, #bar{#Lambda}^{0} PtDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaPtDCAd", "fake jet Pt, #bar{#Lambda}^{0} PtDCAd", HistType::kTH3D, {detJetPtAxis, v0PtAxis, v0DCAdAxis}, true); + // Matching - Fake AntiLambda: z + registry.add("matching/jets/V0/fakeJetPtAntiLambdaTrackProjCtau", "fake jet Pt, #bar{#Lambda}^{0} zCtau", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaTrackProjMass", "fake jet Pt, #bar{#Lambda}^{0} zMass", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaTrackProjLambdaMasses", "fake jet Pt, #bar{#Lambda}^{0} zLambdaMasses", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, lambdaMassDiffAxis, lambdaMassRatioAxis, lambdaMassRelDiffAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaTrackProjRadiusCosPA", "fake jet Pt, #bar{#Lambda}^{0} zRadiusCosPA", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaTrackProjDCAposneg", "fake jet Pt, #bar{#Lambda}^{0} zDCAposneg", HistType::kTHnSparseD, {detJetPtAxis, detZAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/jets/V0/fakeJetPtAntiLambdaTrackProjDCAd", "fake jet Pt, #bar{#Lambda}^{0} zDCAd", HistType::kTH3D, {detJetPtAxis, detZAxis, v0DCAdAxis}, true); + // Matching - Missed AntiLambda + registry.add("matching/jets/V0/missJetPtAntiLambdaPtEtaPhi", "miss jet Pt, #bar{#Lambda}^{0} PtEtaPhi", HistType::kTHnSparseD, {partJetPtAxis, v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/jets/V0/missJetPtAntiLambdaTrackProj", "Misses", HistType::kTH2D, {partJetPtAxis, partZAxis}, true); + + // Matching - Matched V0s: daughters + registry.add("matching/jets/V0/partJetPtDetJetPtPartV0PtPosPtRatioPtRelDiffPt", "V0PtPosPartPtRatioRelDiffPt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0PtAxis, trackPtAxis, ptRatioAxis, ptTrackRelDiffAxis}, true); + registry.add("matching/jets/V0/partJetPtDetJetPtPartV0PtNegPtRatioPtRelDiffPt", "V0PtNegPartPtRatioRelDiffPt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0PtAxis, trackPtAxis, ptRatioAxis, ptTrackRelDiffAxis}, true); + // Matching - Fake V0s: daughters non-decayed (should be empty) + registry.add("matching/V0/nonedecayedFakeV0PtMass", "nonedecayedFakeV0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/nonedecayedFakeV0PtMass", "nonedecayedFakeV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/nonedecayedFakeV0TrackProjMass", "nonedecayedFakeV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + // Matching - Fake V0s: daughters both-decayed (seems unlikely: e.g. K->pi pi->mu nu mu nu) + registry.add("matching/V0/doubledecayedFakeV0PtMass", "doubledecayedFakeV0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/doubledecayedFakeV0PtMass", "doubledecayedFakeV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/doubledecayedFakeV0TrackProjMass", "doubledecayedFakeV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, zAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + // Matching - Fake V0s: daughters one-decayed (e.g. K->pi pi->pi mu nu) + // Matching - Fake K0S: daughters one-decayed + registry.add("matching/V0/decayedK0SV0PtMass", "decayedK0SV0PtMass", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/decayedK0SV0PtMass", "decayedK0SV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/decayedK0SV0TrackProjMass", "decayedK0SV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, partZAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + // Matching - Fake Lambda: daughters one-decayed + registry.add("matching/V0/decayedLambdaV0PtMass", "decayedLambdaV0PtMass", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/decayedLambdaV0PtMass", "decayedLambdaV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/decayedLambdaV0TrackProjMass", "decayedLambdaV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, partZAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + // Matching - Fake AntiLambda: daughters one-decayed + registry.add("matching/V0/decayedAntiLambdaV0PtMass", "decayedAntiLambdaV0PtMass", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/decayedAntiLambdaV0PtMass", "decayedAntiLambdaV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/decayedAntiLambdaV0TrackProjMass", "decayedAntiLambdaV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, partZAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + // Matching - Fake Other: daughters one-decayed + registry.add("matching/V0/decayedOtherPtV0PtMass", "decayedOtherPtV0PtMass", HistType::kTHnSparseD, {v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/decayedOtherPtV0PtMass", "decayedOtherPtV0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0partPtAxis, v0detPtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/jets/V0/decayedOtherPtV0TrackProjMass", "decayedOtherPtV0TrackProjMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, partZAxis, detZAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); } // doprocessMcMatchedV0JetsFrag if (doprocessDataV0PerpCone) { - registry.add("data/PC/JetPtEtaV0Pt", "JetPtEtaV0Pt", HistType::kTH3D, {jetPtAxis, etaAxis, V0PtAxis}); - registry.add("data/PC/V0PtEtaPhi", "V0 #it{p}_{T}, #eta, #phi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("data/PC/V0PtCtau", "V0PtCtau", HistType::kTHnSparseD, {V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("data/PC/V0PtMass", "V0PtMass", HistType::kTHnSparseD, {V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/PC/V0PtMassWide", "V0PtMassWide", HistType::kTHnSparseD, {V0PtAxis, K0SWideAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("data/PC/V0PtRadiusCosPA", "V0PtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/PC/V0PtDCAposneg", "V0PtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/PC/V0PtDCAd", "V0PtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); - - registry.add("data/PC/JetPtEtaLambda0Pt", "JetPtEtaLambda0Pt", HistType::kTH3D, {jetPtAxis, etaAxis, V0PtAxis}); - registry.add("data/PC/JetPtLambda0PtMass", "JetPtLambda0PtMass", HistType::kTH3D, {jetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("data/PC/LambdaPtEtaPhi", "LambdaPtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("data/PC/LambdaPtCtauMass", "LambdaPtCtauMass", HistType::kTH3D, {V0PtAxis, V0CtauAxis, LambdaMassAxis}); - registry.add("data/PC/LambdaPtRadiusCosPA", "LambdaPtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/PC/LambdaPtDCAposneg", "LambdaPtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/PC/LambdaPtDCAd", "LambdaPtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); - - registry.add("data/PC/JetPtEtaAntiLambda0Pt", "JetPtEtaAntiLambda0Pt", HistType::kTH3D, {jetPtAxis, etaAxis, V0PtAxis}); - registry.add("data/PC/JetPtAntiLambda0PtMass", "JetPtAntiLambda0PtMass", HistType::kTH3D, {jetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("data/PC/antiLambdaPtEtaPhi", "antiLambdaPtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("data/PC/antiLambdaPtCtauMass", "antiLambdaPtCtauMass", HistType::kTH3D, {V0PtAxis, V0CtauAxis, LambdaMassAxis}); - registry.add("data/PC/antiLambdaPtRadiusCosPA", "antiLambdaPtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/PC/antiLambdaPtDCAposneg", "antiLambdaPtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/PC/antiLambdaPtDCAd", "antiLambdaPtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); - - registry.add("data/PC/JetPtEtaK0SPt", "JetPtEtaK0SPt", HistType::kTH3D, {jetPtAxis, etaAxis, V0PtAxis}); - registry.add("data/PC/JetPtK0SPtMass", "JetPtK0SPtMass", HistType::kTH3D, {jetPtAxis, V0PtAxis, K0SMassAxis}); - registry.add("data/PC/K0SPtEtaPhi", "K0SPtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("data/PC/K0SPtCtauMass", "K0SPtCtauMass", HistType::kTH3D, {V0PtAxis, V0CtauAxis, K0SMassAxis}); - registry.add("data/PC/K0SPtRadiusCosPA", "K0SPtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("data/PC/K0SPtDCAposneg", "K0SPtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("data/PC/K0SPtDCAd", "K0SPtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); + registry.add("data/PC/JetPtEtaV0Pt", "JetPtEtaV0Pt", HistType::kTH3D, {jetPtAxis, etaAxis, v0PtAxis}); + registry.add("data/PC/V0PtEtaPhi", "V0 #it{p}_{T}, #eta, #phi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}); + registry.add("data/PC/V0PtCtau", "V0PtCtau", HistType::kTHnSparseD, {v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}); + registry.add("data/PC/V0PtMass", "V0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/PC/V0PtMassWide", "V0PtMassWide", HistType::kTHnSparseD, {v0PtAxis, k0SWideAxis, lambdaMassAxis, lambdaMassAxis}); + registry.add("data/PC/V0PtRadiusCosPA", "V0PtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/PC/V0PtDCAposneg", "V0PtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/PC/V0PtDCAd", "V0PtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}); + + // K0S + registry.add("data/PC/JetPtK0SPtMass", "JetPtK0SPtMass", HistType::kTH3D, {jetPtAxis, v0PtAxis, k0SMassAxis}); + registry.add("data/PC/JetPtEtaK0SPt", "JetPtEtaK0SPt", HistType::kTH3D, {jetPtAxis, etaAxis, v0PtAxis}); + registry.add("data/PC/K0SPtEtaPhi", "K0SPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}); + registry.add("data/PC/K0SPtCtauMass", "K0SPtCtauMass", HistType::kTH3D, {v0PtAxis, v0CtauAxis, k0SMassAxis}); + registry.add("data/PC/K0SPtRadiusCosPA", "K0SPtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/PC/K0SPtDCAposneg", "K0SPtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/PC/K0SPtDCAd", "K0SPtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}); + + // Lambda + registry.add("data/PC/JetPtLambdaPtMass", "JetPtLambdaPtMass", HistType::kTH3D, {jetPtAxis, v0PtAxis, lambdaMassAxis}); + registry.add("data/PC/JetPtEtaLambdaPt", "JetPtEtaLambdaPt", HistType::kTH3D, {jetPtAxis, etaAxis, v0PtAxis}); + registry.add("data/PC/LambdaPtEtaPhi", "LambdaPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}); + registry.add("data/PC/LambdaPtCtauMass", "LambdaPtCtauMass", HistType::kTH3D, {v0PtAxis, v0CtauAxis, lambdaMassAxis}); + registry.add("data/PC/LambdaPtRadiusCosPA", "LambdaPtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/PC/LambdaPtDCAposneg", "LambdaPtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/PC/LambdaPtDCAd", "LambdaPtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}); + + // AntiLambda + registry.add("data/PC/JetPtAntiLambdaPtMass", "JetPtAntiLambdaPtMass", HistType::kTH3D, {jetPtAxis, v0PtAxis, lambdaMassAxis}); + registry.add("data/PC/JetPtEtaAntiLambdaPt", "JetPtEtaAntiLambdaPt", HistType::kTH3D, {jetPtAxis, etaAxis, v0PtAxis}); + registry.add("data/PC/AntiLambdaPtEtaPhi", "AntiLambdaPtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}); + registry.add("data/PC/AntiLambdaPtCtauMass", "AntiLambdaPtCtauMass", HistType::kTH3D, {v0PtAxis, v0CtauAxis, lambdaMassAxis}); + registry.add("data/PC/AntiLambdaPtRadiusCosPA", "AntiLambdaPtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}); + registry.add("data/PC/AntiLambdaPtDCAposneg", "AntiLambdaPtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}); + registry.add("data/PC/AntiLambdaPtDCAd", "AntiLambdaPtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}); registry.add("data/PC/nV0sConePtEta", "nV0sConePtEta", HistType::kTH3D, {v0Count, jetPtAxis, etaAxis}); registry.add("data/PC/ConePtEtaPhi", "ConePtEtaPhi", HistType::kTH3D, {jetPtAxis, etaAxis, phiAxis}); @@ -865,149 +1025,209 @@ struct JetFragmentation { } // doprocessDataV0PerpCone if (doprocessMcV0PerpCone) { - registry.add("mcd/PC/jetPtEtaFakeV0Pt", "JetPtEtaFakeV0Pt", HistType::kTH3D, {detJetPtAxis, etaAxis, V0PtAxis}); - registry.add("mcd/PC/fakeV0PtEtaPhi", "fakeV0PtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("mcd/PC/fakeV0PtCtau", "fakeV0PtCtau", HistType::kTHnSparseD, {V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("mcd/PC/fakeV0PtMass", "fakeV0PtMass", HistType::kTHnSparseD, {V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("mcd/PC/fakeV0PtRadiusCosPA", "fakeV0PtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("mcd/PC/fakeV0PtDCAposneg", "fakeV0PtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("mcd/PC/fakeV0PtDCAd", "fakeV0PtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); - registry.add("mcd/PC/jetPtEtaMatchedV0Pt", "JetPtEtaMatchedV0Pt", HistType::kTH3D, {detJetPtAxis, etaAxis, V0PtAxis}); - - registry.add("mcd/PC/matchedV0PtEtaPhi", "matchedV0PtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("mcd/PC/matchedV0PtCtau", "matchedV0PtCtau", HistType::kTHnSparseD, {V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("mcd/PC/matchedV0PtMass", "matchedV0PtMass", HistType::kTHnSparseD, {V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("mcd/PC/matchedV0PtRadiusCosPA", "matchedV0PtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("mcd/PC/matchedV0PtDCAposneg", "matchedV0PtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("mcd/PC/matchedV0PtDCAd", "matchedV0PtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); - - registry.add("mcd/PC/matchedJetPtK0SPtMass", "matchedJetPtK0SPtMass", HistType::kTH3D, {detJetPtAxis, V0PtAxis, K0SMassAxis}); - registry.add("mcd/PC/matchedJetPtLambda0PtMass", "matchedJetPtLambda0PtMass", HistType::kTH3D, {detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("mcd/PC/matchedJetPtAntiLambda0PtMass", "matchedJetPtAntiLambda0PtMass", HistType::kTH3D, {detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("mcd/PC/matchednV0sConePtEta", "matchednV0sConePtEta", HistType::kTH3D, {v0Count, detJetPtAxis, etaAxis}); - registry.add("mcd/PC/matchedConePtEtaPhi", "matchedConePtEtaPhi", HistType::kTH3D, {detJetPtAxis, etaAxis, phiAxis}); - registry.add("mcd/PC/matchedJetPtEtaConePt", "matchedJetPtEtaConePt", HistType::kTH3D, {detJetPtAxis, etaAxis, detJetPtAxis}); - - registry.add("mcd/PC/fakenV0sConePtEta", "fakenV0sConePtEta", HistType::kTH3D, {v0Count, detJetPtAxis, etaAxis}); - registry.add("mcd/PC/fakeConePtEtaPhi", "fakeConePtEtaPhi", HistType::kTH3D, {detJetPtAxis, etaAxis, phiAxis}); - registry.add("mcd/PC/fakeJetPtEtaConePt", "fakeJetPtEtaConePt", HistType::kTH3D, {detJetPtAxis, etaAxis, detJetPtAxis}); + registry.add("mcd/V0/nV0sEvent", "NV0s in event", HistType::kTH1D, {v0Count}); + registry.add("mcd/V0/nV0sEventWeighted", "NV0s in event weighted", HistType::kTH1D, {v0Count}, true); + + // PerpCone - Fake V0s in MCD jets + registry.add("mcd/PC/jetPtEtaFakeV0Pt", "JetPtEtaFakeV0Pt", HistType::kTH3D, {detJetPtAxis, etaAxis, v0PtAxis}, true); + registry.add("mcd/PC/fakeV0PtEtaPhi", "fakeV0PtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("mcd/PC/fakeV0PtCtau", "fakeV0PtCtau", HistType::kTHnSparseD, {v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("mcd/PC/fakeV0PtMass", "fakeV0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("mcd/PC/fakeV0PtRadiusCosPA", "fakeV0PtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("mcd/PC/fakeV0PtDCAposneg", "fakeV0PtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("mcd/PC/fakeV0PtDCAd", "fakeV0PtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}, true); + // PerpCone - Fake V0s in cone from MCD jets + registry.add("mcd/PC/fakenV0sConePtEta", "fakenV0sConePtEta", HistType::kTH3D, {v0Count, detJetPtAxis, etaAxis}, true); + registry.add("mcd/PC/fakeConePtEtaPhi", "fakeConePtEtaPhi", HistType::kTH3D, {detJetPtAxis, etaAxis, phiAxis}, true); + registry.add("mcd/PC/fakeJetPtEtaConePt", "fakeJetPtEtaConePt", HistType::kTH3D, {detJetPtAxis, etaAxis, detJetPtAxis}, true); + // PerpCone - Matched V0s in MCD jets + registry.add("mcd/PC/jetPtEtaMatchedV0Pt", "JetPtEtaMatchedV0Pt", HistType::kTH3D, {detJetPtAxis, etaAxis, v0PtAxis}, true); + registry.add("mcd/PC/matchedV0PtEtaPhi", "matchedV0PtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("mcd/PC/matchedV0PtCtau", "matchedV0PtCtau", HistType::kTHnSparseD, {v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("mcd/PC/matchedV0PtMass", "matchedV0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("mcd/PC/matchedV0PtRadiusCosPA", "matchedV0PtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("mcd/PC/matchedV0PtDCAposneg", "matchedV0PtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("mcd/PC/matchedV0PtDCAd", "matchedV0PtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}, true); + // PerpCone - Matched V0s in cone from MCD jets + registry.add("mcd/PC/matchednV0sConePtEta", "matchednV0sConePtEta", HistType::kTH3D, {v0Count, detJetPtAxis, etaAxis}, true); + registry.add("mcd/PC/matchedConePtEtaPhi", "matchedConePtEtaPhi", HistType::kTH3D, {detJetPtAxis, etaAxis, phiAxis}, true); + registry.add("mcd/PC/matchedJetPtEtaConePt", "matchedJetPtEtaConePt", HistType::kTH3D, {detJetPtAxis, etaAxis, detJetPtAxis}, true); + // PerpCone - Matched K0S in MCD jets + registry.add("mcd/PC/matchedJetPtK0SPtMass", "matchedJetPtK0SPtMass", HistType::kTH3D, {detJetPtAxis, v0PtAxis, k0SMassAxis}, true); + // PerpCone - Matched Lambda in MCD jets + registry.add("mcd/PC/matchedJetPtLambdaPtMass", "matchedJetPtLambdaPtMass", HistType::kTH3D, {detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + // PerpCone - Matched AntiLambda in MCD jets + registry.add("mcd/PC/matchedJetPtAntiLambdaPtMass", "matchedJetPtAntiLambdaPtMass", HistType::kTH3D, {detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + // PerpCone - Fake V0s in Matched jets + registry.add("matching/PC/jetPtEtaFakeV0Pt", "JetPtEtaFakeV0Pt", HistType::kTH3D, {detJetPtAxis, etaAxis, v0PtAxis}, true); + registry.add("matching/PC/jetsPtFakeV0Pt", "jetsPtFakeV0Pt", HistType::kTH3D, {partJetPtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/PC/fakeV0PtEtaPhi", "fakeV0PtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/PC/fakeV0PtCtau", "fakeV0PtCtau", HistType::kTHnSparseD, {v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/PC/fakeV0PtMass", "fakeV0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/PC/fakeV0PtRadiusCosPA", "fakeV0PtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/PC/fakeV0PtDCAposneg", "fakeV0PtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/PC/fakeV0PtDCAd", "fakeV0PtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}, true); + // PerpCone - Fake V0s in cone from Matched jets + registry.add("matching/PC/fakenV0sConePtEta", "fakenV0sConePtEta", HistType::kTH3D, {v0Count, detJetPtAxis, etaAxis}, true); + registry.add("matching/PC/fakeConePtEtaPhi", "fakeConePtEtaPhi", HistType::kTH3D, {detJetPtAxis, etaAxis, phiAxis}, true); + registry.add("matching/PC/fakeJetPtEtaConePt", "fakeJetPtEtaConePt", HistType::kTH3D, {detJetPtAxis, etaAxis, detJetPtAxis}, true); + registry.add("matching/PC/fakeJetsPtEtaConePt", "fakeJetsPtEtaConePt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, etaAxis, detJetPtAxis}, true); + // PerpCone - Matched V0s in Matched jets + registry.add("matching/PC/jetPtEtaMatchedV0Pt", "jetPtEtaMatchedV0Pt", HistType::kTH3D, {detJetPtAxis, etaAxis, v0PtAxis}, true); + registry.add("matching/PC/jetsPtMatchedV0Pt", "jetsPtMatchedV0Pt", HistType::kTH3D, {partJetPtAxis, detJetPtAxis, v0PtAxis}, true); + registry.add("matching/PC/matchedV0PtEtaPhi", "matchedV0PtEtaPhi", HistType::kTH3D, {v0PtAxis, v0EtaAxis, v0PhiAxis}, true); + registry.add("matching/PC/matchedV0PtCtau", "matchedV0PtCtau", HistType::kTHnSparseD, {v0PtAxis, v0CtauAxis, v0CtauAxis, v0CtauAxis}, true); + registry.add("matching/PC/matchedV0PtMass", "matchedV0PtMass", HistType::kTHnSparseD, {v0PtAxis, k0SMassAxis, lambdaMassAxis, lambdaMassAxis}, true); + registry.add("matching/PC/matchedV0PtRadiusCosPA", "matchedV0PtRadiusCosPA", HistType::kTH3D, {v0PtAxis, v0RadiusAxis, v0CosPAAxis}, true); + registry.add("matching/PC/matchedV0PtDCAposneg", "matchedV0PtDCAposneg", HistType::kTH3D, {v0PtAxis, v0DCApAxis, v0DCAnAxis}, true); + registry.add("matching/PC/matchedV0PtDCAd", "matchedV0PtDCAd", HistType::kTH2D, {v0PtAxis, v0DCAdAxis}, true); + // PerpCone - Matched V0s in cone from Matched jets + registry.add("matching/PC/matchednV0sConePtEta", "matchednV0sConePtEta", HistType::kTH3D, {v0Count, detJetPtAxis, etaAxis}, true); + registry.add("matching/PC/matchedConePtEtaPhi", "matchedConePtEtaPhi", HistType::kTH3D, {detJetPtAxis, etaAxis, phiAxis}, true); + registry.add("matching/PC/matchedJetPtEtaConePt", "matchedJetPtEtaConePt", HistType::kTH3D, {detJetPtAxis, etaAxis, detJetPtAxis}, true); + registry.add("matching/PC/matchedJetsPtEtaConePt", "matchedJetsPtEtaConePt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, etaAxis, detJetPtAxis}, true); + // PerpCone - Matched K0S in Matched jets + registry.add("matching/PC/matchedJetPtK0SPtMass", "matchedJetPtK0SPtMass", HistType::kTH3D, {detJetPtAxis, v0PtAxis, k0SMassAxis}, true); + registry.add("matching/PC/matchedJetsPtK0SPtMass", "matchedJetsPtK0SPtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0PtAxis, k0SMassAxis}, true); + // PerpCone - Matched Lambda in Matched jets + registry.add("matching/PC/matchedJetPtLambdaPtMass", "matchedJetPtLambdaPtMass", HistType::kTH3D, {detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/PC/matchedJetsPtLambdaPtMass", "matchedJetsPtLambdaPtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + // PerpCone - Matched AntiLambda in Matched jets + registry.add("matching/PC/matchedJetPtAntiLambdaPtMass", "matchedJetPtAntiLambdaPtMass", HistType::kTH3D, {detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); + registry.add("matching/PC/matchedJetsPtAntiLambdaPtMass", "matchedJetsPtAntiLambdaPtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, v0PtAxis, lambdaMassAxis}, true); } // doprocessMcV0PerpCone - - if (doprocessMcV0MatchedPerpCone) { - registry.add("matching/PC/jetPtEtaFakeV0Pt", "JetPtEtaFakeV0Pt", HistType::kTH3D, {detJetPtAxis, etaAxis, V0PtAxis}); - registry.add("matching/PC/jetsPtFakeV0Pt", "jetsPtFakeV0Pt", HistType::kTH3D, {partJetPtAxis, detJetPtAxis, V0PtAxis}); - registry.add("matching/PC/fakeV0PtEtaPhi", "fakeV0PtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/PC/fakeV0PtCtau", "fakeV0PtCtau", HistType::kTHnSparseD, {V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/PC/fakeV0PtMass", "fakeV0PtMass", HistType::kTHnSparseD, {V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/PC/fakeV0PtRadiusCosPA", "fakeV0PtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/PC/fakeV0PtDCAposneg", "fakeV0PtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/PC/fakeV0PtDCAd", "fakeV0PtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); - - registry.add("matching/PC/jetPtEtaMatchedV0Pt", "jetPtEtaMatchedV0Pt", HistType::kTH3D, {detJetPtAxis, etaAxis, V0PtAxis}); - registry.add("matching/PC/jetsPtMatchedV0Pt", "jetsPtMatchedV0Pt", HistType::kTH3D, {partJetPtAxis, detJetPtAxis, V0PtAxis}); - registry.add("matching/PC/matchedV0PtEtaPhi", "matchedV0PtEtaPhi", HistType::kTH3D, {V0PtAxis, V0EtaAxis, V0PhiAxis}); - registry.add("matching/PC/matchedV0PtCtau", "matchedV0PtCtau", HistType::kTHnSparseD, {V0PtAxis, V0CtauAxis, V0CtauAxis, V0CtauAxis}); - registry.add("matching/PC/matchedV0PtMass", "matchedV0PtMass", HistType::kTHnSparseD, {V0PtAxis, K0SMassAxis, LambdaMassAxis, LambdaMassAxis}); - registry.add("matching/PC/matchedV0PtRadiusCosPA", "matchedV0PtRadiusCosPA", HistType::kTH3D, {V0PtAxis, V0RadiusAxis, V0CosPAAxis}); - registry.add("matching/PC/matchedV0PtDCAposneg", "matchedV0PtDCAposneg", HistType::kTH3D, {V0PtAxis, V0DCApAxis, V0DCAnAxis}); - registry.add("matching/PC/matchedV0PtDCAd", "matchedV0PtDCAd", HistType::kTH2D, {V0PtAxis, V0DCAdAxis}); - - registry.add("matching/PC/matchedJetPtK0SPtMass", "matchedJetPtK0SPtMass", HistType::kTH3D, {detJetPtAxis, V0PtAxis, K0SMassAxis}); - registry.add("matching/PC/matchedJetsPtK0SPtMass", "matchedJetsPtK0SPtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0PtAxis, K0SMassAxis}); - registry.add("matching/PC/matchedJetPtLambda0PtMass", "matchedJetPtLambda0PtMass", HistType::kTH3D, {detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/PC/matchedJetsPtLambda0PtMass", "matchedJetsPtLambda0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/PC/matchedJetPtAntiLambda0PtMass", "matchedJetPtAntiLambda0PtMass", HistType::kTH3D, {detJetPtAxis, V0PtAxis, LambdaMassAxis}); - registry.add("matching/PC/matchedJetsPtAntiLambda0PtMass", "matchedJetsPtAntiLambda0PtMass", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, V0PtAxis, LambdaMassAxis}); - - registry.add("matching/PC/matchednV0sConePtEta", "matchednV0sConePtEta", HistType::kTH3D, {v0Count, detJetPtAxis, etaAxis}); - registry.add("matching/PC/matchedConePtEtaPhi", "matchedConePtEtaPhi", HistType::kTH3D, {detJetPtAxis, etaAxis, phiAxis}); - registry.add("matching/PC/matchedJetPtEtaConePt", "matchedJetPtEtaConePt", HistType::kTH3D, {detJetPtAxis, etaAxis, detJetPtAxis}); - registry.add("matching/PC/matchedJetsPtEtaConePt", "matchedJetsPtEtaConePt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, etaAxis, detJetPtAxis}); - - registry.add("matching/PC/fakenV0sConePtEta", "fakenV0sConePtEta", HistType::kTH3D, {v0Count, detJetPtAxis, etaAxis}); - registry.add("matching/PC/fakeConePtEtaPhi", "fakeConePtEtaPhi", HistType::kTH3D, {detJetPtAxis, etaAxis, phiAxis}); - registry.add("matching/PC/fakeJetPtEtaConePt", "fakeJetPtEtaConePt", HistType::kTH3D, {detJetPtAxis, etaAxis, detJetPtAxis}); - registry.add("matching/PC/fakeJetsPtEtaConePt", "fakeJetsPtEtaConePt", HistType::kTHnSparseD, {partJetPtAxis, detJetPtAxis, etaAxis, detJetPtAxis}); - } // doprocessMcV0MatchedPerpCone } // init - // TODO: This should contain a lookup table or function containing the various V0 weights - // Returns a std::vector of weights for a particle - template - std::vector getV0SignalWeight(C const& coll, V const& v0) + // --------------------------------------------------- + // Implementation of background subtraction at runtime + // --------------------------------------------------- + + int getPtBin(float pt, std::vector ptBins) { - // 0: bkg, 1: K0S, 2: Lambda, 3: AntiLambda - std::vector w(4, 0.); - double purity = 0.8; // TODO: need getter to set this - - bool isK = IsK0SCandidate(coll, v0); - bool isL = IsLambdaCandidate(coll, v0); - bool isAL = IsAntiLambdaCandidate(coll, v0); - - // FIXME: Competing Mass Cut will change this approach. Only one signal type per particle - // Candidate for a single particle - switch (isK + isL + isAL) { - case 0: - break; - case 1: - w[1] = static_cast(isK) * purity; - w[2] = static_cast(isL) * purity; - w[3] = static_cast(isAL) * purity; - break; - case 2: - w[1] = static_cast(isK) * (2. / 3.) * purity; - w[2] = (isK ? 2. / 3. : 0.5) * purity; - w[3] = (isK ? 2. / 3. : 0.5) * purity; - break; - case 3: - w[1] = 0.5 * purity; - w[2] = 0.25 * purity; - w[3] = 0.25 * purity; - break; + if (pt < ptBins.at(0)) + return -1; + if (pt > ptBins.at(ptBins.size() - 1)) + return -2; + + for (unsigned int i = 0; i < ptBins.size() - 1; i++) { + if (pt >= ptBins.at(i) && pt < ptBins.at(i + 1)) { + return i; + } } - w[0] = 1. - (w[1] + w[2] + w[3]); - return w; - } // getV0SignalWeight - // Converts state from uint32_t to std::vector containing the particle classes for that weight + return -3; + } + + // Return probability for a V0 to be signal + // Assumes V0 can only be of one type! + // Assumes V0 is not rejected! + template + float getV0SignalProb(V const& v0) + { + double purity = 0.; + if (v0.isK0SCandidate()) { + int ptBin = getPtBin(v0.pt(), ptBinsK0S); + if (ptBin >= 0) { + purity = signalProbK0S->at(ptBin); + } + } else if (v0.isLambdaCandidate()) { + int ptBin = getPtBin(v0.pt(), ptBinsLambda); + if (ptBin >= 0) { + purity = signalProbLambda->at(ptBin); + } + } else if (v0.isAntiLambdaCandidate()) { + int ptBin = getPtBin(v0.pt(), ptBinsAntiLambda); + if (ptBin >= 0) { + purity = signalProbAntiLambda->at(ptBin); + } + } + return purity; + } + // Return a 2-length std::vector of probabilities for a particle to correspond to signal or background + template + std::vector getV0SignalProbVector2Classes(V const& v0) + { + // 0: bkg, 1: signal + if (v0.isRejectedCandidate()) + return {1., 0.}; + + double purity = getV0SignalProb(v0); + return {1. - purity, purity}; + } + // Return a 4-length std::vector of probabilities for a particle to correspond to signal types + template + std::vector getV0SignalProbVector4Classes(V const& v0) + { + // 0: bkg, 1: K0S, 2: Lambda, 3: AntiLambda + if (v0.isRejectedCandidate()) + return {1., 0., 0., 0.}; + + double purity = getV0SignalProb(v0); + if (v0.isK0SCandidate()) + return {1. - purity, purity, 0., 0.}; + if (v0.isLambdaCandidate()) + return {1. - purity, 0., purity, 0.}; + if (v0.isAntiLambdaCandidate()) + return {1. - purity, 0., 0., purity}; + + return {1., 0., 0., 0.}; + } + // Convert state from uint32_t to std::vector containing the particle classes for that weight std::vector convertState(uint32_t state, int nParticles, int nClasses = 4) { + // TODO: Should we cast these to uint32_t? std::vector v(nParticles, nClasses); - int nStates = pow(nClasses, nParticles); - int nBitsPerParticle = round(log2(nClasses)); + int nStates = std::round(std::pow(static_cast(nClasses), static_cast(nParticles))); + int nBitsPerParticle = std::round(std::log2(nClasses)); int nBitsPerInt = sizeof(uint32_t) * 8; - // Check if the input configuration is parseable + if (nClasses <= 0) { + LOGF(warning, "Number of classes (%d) must be greater than 0", nClasses); + return v; + } if ((nClasses & (nClasses - 1)) != 0) { // It's likely possible to make this work for non-power of 2 classes, but it's not needed and therefore not implemented LOGF(warning, "Number of classes (%d) must be a power of 2", nClasses); return v; } + // Check for overflow in number of states if (nStates <= 0) { LOGF(warning, "Illegal number of states (%d)! %s", nStates, (nStates == 0) ? "" : "Max = 2^31"); return v; } + // Check if we have enough bits to store the state if (nParticles * nBitsPerParticle > nBitsPerInt) { LOGF(warning, "Number of bits required to parse the state (%d * %d = %d) is too large for %d bits per int!", nParticles, nBitsPerParticle, nParticles * nBitsPerParticle, nBitsPerInt); return v; } - if (state >= (uint32_t)nStates) { + // Check if the state is valid. This should never be triggered + if (state >= static_cast(nStates)) { LOGF(warning, "Illegal state! State %d >= %d", state, nStates); return v; } for (int ip = 0; ip < nParticles; ip++) { - double value = 0; + int value = 0; int startBit = ip * nBitsPerParticle; for (int ib = 0; ib < nBitsPerParticle; ib++) { - int bit = startBit + ib; + uint32_t bit = startBit + ib; int bitVal = ((state & (1 << bit)) > 0); - value += bitVal * TMath::Power(2, ib); - } + value += bitVal * std::round(std::pow(2., static_cast(ib))); + } // loop over bits for particle ip v[ip] = value; } return v; - } // convertState - // Returns the corrected values for z and ptjet for a given state + } + // Return the probability associated with a given outcome + double stateWeight(std::vector state, std::vector> weights) + { + double w = 1.; + for (uint32_t ip = 0; ip < state.size(); ip++) { + w *= weights[ip][state[ip]]; + } + return w; + } + // Return the corrected values for z and ptjet for a given state + // Scale values by the fraction of jet momentum carried by removed V0s std::vector correctedValues(std::vector state, std::vector values) { // Assumes values = (z1, z2, ..., zn, ptjet) @@ -1015,7 +1235,7 @@ struct JetFragmentation { double r = 0; int nParticles = state.size(); - if (values.size() != (uint32_t)(nParticles + 1)) { + if (values.size() != static_cast(nParticles + 1)) { LOGF(warning, "Number of values (%d) must be equal to the number of particles (%d) + 1!", values.size(), nParticles); return v; } @@ -1032,395 +1252,482 @@ struct JetFragmentation { v[nParticles] = values[nParticles] * (1 - r); return v; } - double stateWeight(std::vector state, std::vector> weights) + // Return the corrected values for z and ptjet for a given state + // Take into account tracks that would have been included in the jet regardless of the V0s + template + std::vector correctedValuesPlusTracks(std::vector state, V const& jet) { - double w = 1.; - for (int ip = 0; (uint32_t)ip < state.size(); ip++) { - w *= weights[ip][state[ip]]; + int ip = 0; + double ptToSubtract = 0., ptToAdd = 0.; + + for (const auto& v0 : jet.template candidates_as()) { + if (v0.isRejectedCandidate()) + continue; + + // Background + if (state[ip] == 0) { + ptToSubtract += v0.pt(); + + // TODO: This is okay in pt-scheme jets, but should add 4-momentum for E-scheme + auto negTrack = v0.template negTrack_as(); + if (jetderiveddatautilities::selectTrack(negTrack, trackSelection) && jetutilities::deltaR(jet, negTrack) < jet.r() * 1e-2) + ptToAdd += negTrack.pt(); + + auto posTrack = v0.template posTrack_as(); + if (jetderiveddatautilities::selectTrack(posTrack, trackSelection) && jetutilities::deltaR(jet, negTrack) < jet.r() * 1e-2) + ptToAdd += posTrack.pt(); + } + ip++; } - return w; + + double ptjet = jet.pt() - ptToSubtract + ptToAdd; + std::vector values; + + ip = 0; + for (const auto& v0 : jet.template candidates_as()) { + if (v0.isRejectedCandidate()) + continue; + + if (state[ip] == 0) // Background + values.push_back(v0.pt() / jet.pt()); + else + values.push_back(v0.pt() / ptjet); + ip++; + } + values.push_back(ptjet); + return values; } + // --------------------------------------------------- + // Helper functions + // --------------------------------------------------- template - bool JetContainsV0s(JetType const& jet) + bool jetContainsV0s(JetType const& jet) { return (jet.candidatesIds().size() > 0); } template - bool V0sAreMatched(T const& v0, U const& particle, V const& /*tracks*/) + bool v0sAreMatched(T const& v0, U const& particle, V const& /*tracks*/) { - // FIXME: Can we use matchedV0Particle instead? - // https://github.com/AliceO2Group/O2Physics/blob/31ba54647675645b4669001e3ae9a99614f26d36/PWGJE/Core/JetV0Utilities.h#L131 + // FIXME: Should this check whether V0 is selected as correct species? Probably! auto negId = v0.template negTrack_as().mcParticleId(); auto posId = v0.template posTrack_as().mcParticleId(); auto daughters = particle.daughtersIds(); return ((negId == daughters[0] && posId == daughters[1]) || (posId == daughters[0] && negId == daughters[1])); } - - template - bool IsV0Candidate(V0Type const& v0) - { - if (v0.eta() < v0EtaMin || v0.eta() > v0EtaMax) { // TODO: Should be rapidity, mass matters! - return false; - } - if (v0.dcaV0daughters() > dcav0dauMax) { - return false; - } - if (v0.v0radius() < v0radiusMin) { - return false; - } - if (v0.v0cosPA() < v0cospaMin) { - return false; - } - return true; - } - template - bool IsK0SCandidate(CollisionType const& collision, V0Type const& v0) - { - if (!IsV0Candidate(v0)) { - return false; - } - if (v0.dcanegtopv() < dcapiMin || v0.dcapostopv() < dcapiMin) { - return false; - } - double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; - if (ctauK0s > lifetimeK0SMax) { - return false; - } - bool k0sMassCondition = (TMath::Abs(v0.mK0Short() - o2::constants::physics::MassK0Short) < k0sMassAccWindow); - if (!k0sMassCondition) { - return false; - } - return true; - } - template - bool IsLambdaCandidate(CollisionType const& collision, V0Type const& v0) - { - if (!IsV0Candidate(v0)) { - return false; - } - if (v0.dcanegtopv() < dcapiMin || v0.dcapostopv() < dcaprMin) { - return false; - } - double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - if (ctauLambda > lifetimeLambdaMax) { - return false; - } - bool lambdaMassCondition = (TMath::Abs(v0.mLambda() - o2::constants::physics::MassLambda0) < lambdaMassAccWindow); - if (!lambdaMassCondition) { - return false; - } - return true; - } - template - bool IsAntiLambdaCandidate(CollisionType const& collision, V0Type const& v0) - { - if (!IsV0Candidate(v0)) { - return false; - } - if (v0.dcanegtopv() < dcaprMin || v0.dcapostopv() < dcapiMin) { - return false; - } - double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; - if (ctauAntiLambda > lifetimeLambdaMax) { - return false; - } - bool antilambdaMassCondition = (TMath::Abs(v0.mAntiLambda() - o2::constants::physics::MassLambda0Bar) < antilambdaMassAccWindow); - if (!antilambdaMassCondition) { - return false; - } - return true; - } - template - double ReflectedMass(V0Type const& v0, bool isLambda) + double getReflectedMass(V0Type const& v0, bool isLambda) { // If V0 is Lambda, posTrack = proton, negTrack = pion // In that case, we assign pion mass to posTrack and proton mass to negTrack to calculate the reflection // Vice versa for AntiLambda - double negM = (isLambda ? o2::constants::physics::MassProton : o2::constants::physics::MassPionCharged); - double posM = (isLambda ? o2::constants::physics::MassPionCharged : o2::constants::physics::MassProton); - double negPsq = v0.pxneg() * v0.pxneg() + v0.pyneg() * v0.pyneg() + v0.pzneg() * v0.pzneg(); - double posPsq = v0.pxpos() * v0.pxpos() + v0.pypos() * v0.pypos() + v0.pzpos() * v0.pzpos(); - double negE = TMath::Sqrt(negM * negM + negPsq); - double posE = TMath::Sqrt(posM * posM + posPsq); - double Esquared = (negE + posE) * (negE + posE); - double psquared = v0.p() * v0.p(); - return TMath::Sqrt(Esquared - psquared); - } - - template - double ChargeFrag(Jet const& jet, Constituent const& constituent) - { - double chargeFrag = -1.; - chargeFrag = constituent.pt() / jet.pt(); - return chargeFrag; + float negM = (isLambda ? constants::physics::MassProton : constants::physics::MassPionCharged); + float posM = (isLambda ? constants::physics::MassPionCharged : constants::physics::MassProton); + std::array, 2> momenta = {std::array{v0.pxpos(), v0.pypos(), v0.pzpos()}, std::array{v0.pxneg(), v0.pyneg(), v0.pzneg()}}; + std::array masses = {posM, negM}; + return RecoDecay::m(momenta, masses); } template - double Theta(Jet const& jet, Constituent const& constituent) + double getMomFrac(Jet const& jet, Constituent const& constituent) { - double theta = -1.; - theta = jetutilities::deltaR(jet, constituent); - return theta; + double divByZeroProtect = 1e-5; + if (jet.pt() < divByZeroProtect) + return -1.; + else + return constituent.pt() / jet.pt(); } template - double TrackProj(Jet const& jet, Constituent const& constituent) + double getMomProj(Jet const& jet, Constituent const& constituent) { - double trackProj = -1.; - trackProj = constituent.px() * jet.px() + constituent.py() * jet.py() + constituent.pz() * jet.pz(); + double divByZeroProtect = 1e-5; + if (jet.p() < divByZeroProtect) + return -1.; + + double trackProj = constituent.px() * jet.px() + constituent.py() * jet.py() + constituent.pz() * jet.pz(); trackProj /= (jet.p() * jet.p()); return trackProj; } - template - double Xi(Jet const& jet, Constituent const& constituent) - { - double xi = -1., trackProj = -1.; - trackProj = TrackProj(jet, constituent); - if (trackProj > 0) { - xi = TMath::Log(1. / trackProj); - } - return xi; - } - // TODO: Can probably be made simpler/shorter by using V0MCLabels - template // Not used for V0 jets - void fillMcMatchedV0Histograms(CollisionType const& collision, V0Type const& v0, trackType const&, particleType const&, double weight = 1.) + // --------------------------------------------------- + // Histogram filling functions + // --------------------------------------------------- + // Data - Counts + template + void fillDataV0Histograms(CollisionType const& collision, V0Type const& V0s) { - auto negTrack = v0.template negTrack_as(); - auto posTrack = v0.template posTrack_as(); - if (!negTrack.has_mcParticle() || !posTrack.has_mcParticle()) { - return; - } - auto mcNegTrack = negTrack.template mcParticle_as(); - auto mcPosTrack = posTrack.template mcParticle_as(); - if (!mcNegTrack.has_mothers() || !mcPosTrack.has_mothers()) { - return; - } - double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; - // Can tracks have multiple mothers? - for (auto& particleMotherOfNeg : mcNegTrack.template mothers_as()) { - for (auto& particleMotherOfPos : mcPosTrack.template mothers_as()) { - if (particleMotherOfNeg.isPhysicalPrimary() && particleMotherOfNeg == particleMotherOfPos) { - double ptPartV0 = particleMotherOfNeg.pt(); - int pdg = particleMotherOfNeg.pdgCode(); - registry.fill(HIST("matching/V0/V0PartPtDetPt"), ptPartV0, v0.pt(), weight); - registry.fill(HIST("matching/V0/V0PartPtRatioPtRelDiffPt"), ptPartV0, v0.pt() / ptPartV0, (v0.pt() - ptPartV0) / ptPartV0, weight); - - if (TMath::Abs(pdg) == 310) { // K0S - registry.fill(HIST("matching/V0/K0SPtEtaPhi"), ptPartV0, v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/V0/K0SPtCtauMass"), ptPartV0, v0.pt(), ctauK0s, v0.mK0Short(), weight); - registry.fill(HIST("matching/V0/K0SPtRadiusCosPA"), ptPartV0, v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/V0/K0SPtDCAposneg"), ptPartV0, v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/V0/K0SPtDCAd"), ptPartV0, v0.pt(), v0.dcaV0daughters(), weight); - registry.fill(HIST("matching/V0/K0SPtMass"), ptPartV0, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } else if (pdg == 3122) { // Lambda - registry.fill(HIST("matching/V0/LambdaPtEtaPhi"), ptPartV0, v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/V0/LambdaPtCtauMass"), ptPartV0, v0.pt(), ctauLambda, v0.mLambda(), weight); - registry.fill(HIST("matching/V0/LambdaPtRadiusCosPA"), ptPartV0, v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/V0/LambdaPtDCAposneg"), ptPartV0, v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/V0/LambdaPtDCAd"), ptPartV0, v0.pt(), v0.dcaV0daughters(), weight); - registry.fill(HIST("matching/V0/LambdaPtMass"), ptPartV0, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - - // Reflection - double reflectedMass = ReflectedMass(v0, true); - registry.fill(HIST("matching/V0/Lambda0Reflection"), ptPartV0, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); - } else if (pdg == -3122) { // AntiLambda - registry.fill(HIST("matching/V0/antiLambdaPtEtaPhi"), ptPartV0, v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtCtauMass"), ptPartV0, v0.pt(), ctauAntiLambda, v0.mAntiLambda(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtRadiusCosPA"), ptPartV0, v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtDCAposneg"), ptPartV0, v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtDCAd"), ptPartV0, v0.pt(), v0.dcaV0daughters(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtMass"), ptPartV0, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - - // Reflection - double reflectedMass = ReflectedMass(v0, false); - registry.fill(HIST("matching/V0/antiLambda0Reflection"), ptPartV0, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); - } - } // if mothers match - } // for mothers of pos - } // for mothers of neg - } + // Fill histograms unweighted. Hists will be filled with V0 counts + float nV0s = 0; + for (const auto& v0 : V0s) { + if (v0.isRejectedCandidate()) + continue; + + nV0s += 1; + double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassK0Short; + double massDiff = v0.mLambda() - v0.mAntiLambda(); + double massRatio = v0.mAntiLambda() / v0.mLambda(); + double massRelDiff = (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(); + + registry.fill(HIST("data/V0/V0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("data/V0/V0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda); + registry.fill(HIST("data/V0/V0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/V0/V0PtMassWide"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/V0/V0PtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff); + registry.fill(HIST("data/V0/V0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/V0/V0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/V0/V0PtDCAd"), v0.pt(), v0.dcaV0daughters()); + + registry.fill(HIST("data/V0/V0CutVariation"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), v0.v0radius(), ctauK0s, v0.v0cosPA(), std::abs(v0.dcapostopv()), std::abs(v0.dcanegtopv()), v0.dcaV0daughters()); + + if (v0.isK0SCandidate()) { + registry.fill(HIST("data/V0/K0SPtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("data/V0/K0SPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/V0/K0SPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/V0/K0SPtDCAd"), v0.pt(), v0.dcaV0daughters()); + + registry.fill(HIST("data/V0/K0SPtCtauMass"), v0.pt(), ctauK0s, v0.mK0Short()); + registry.fill(HIST("data/V0/K0SPtRadiusMass"), v0.pt(), v0.v0radius(), v0.mK0Short()); + registry.fill(HIST("data/V0/K0SPtCosPAMass"), v0.pt(), v0.v0cosPA(), v0.mK0Short()); + registry.fill(HIST("data/V0/K0SPtDCAposMass"), v0.pt(), v0.dcapostopv(), v0.mK0Short()); + registry.fill(HIST("data/V0/K0SPtDCAnegMass"), v0.pt(), v0.dcanegtopv(), v0.mK0Short()); + registry.fill(HIST("data/V0/K0SPtDCAdMass"), v0.pt(), v0.dcaV0daughters(), v0.mK0Short()); + } + if (v0.isLambdaCandidate()) { + registry.fill(HIST("data/V0/LambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("data/V0/LambdaPtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff); + registry.fill(HIST("data/V0/LambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/V0/LambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/V0/LambdaPtDCAd"), v0.pt(), v0.dcaV0daughters()); + + registry.fill(HIST("data/V0/LambdaPtCtauMass"), v0.pt(), ctauLambda, v0.mLambda()); + registry.fill(HIST("data/V0/LambdaPtRadiusMass"), v0.pt(), v0.v0radius(), v0.mLambda()); + registry.fill(HIST("data/V0/LambdaPtCosPAMass"), v0.pt(), v0.v0cosPA(), v0.mLambda()); + registry.fill(HIST("data/V0/LambdaPtDCAposMass"), v0.pt(), v0.dcapostopv(), v0.mLambda()); + registry.fill(HIST("data/V0/LambdaPtDCAnegMass"), v0.pt(), v0.dcanegtopv(), v0.mLambda()); + registry.fill(HIST("data/V0/LambdaPtDCAdMass"), v0.pt(), v0.dcaV0daughters(), v0.mLambda()); + } + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("data/V0/AntiLambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("data/V0/AntiLambdaPtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff); + registry.fill(HIST("data/V0/AntiLambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/V0/AntiLambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/V0/AntiLambdaPtDCAd"), v0.pt(), v0.dcaV0daughters()); + + registry.fill(HIST("data/V0/AntiLambdaPtCtauMass"), v0.pt(), ctauAntiLambda, v0.mAntiLambda()); + registry.fill(HIST("data/V0/AntiLambdaPtRadiusMass"), v0.pt(), v0.v0radius(), v0.mAntiLambda()); + registry.fill(HIST("data/V0/AntiLambdaPtCosPAMass"), v0.pt(), v0.v0cosPA(), v0.mAntiLambda()); + registry.fill(HIST("data/V0/AntiLambdaPtDCAposMass"), v0.pt(), v0.dcapostopv(), v0.mAntiLambda()); + registry.fill(HIST("data/V0/AntiLambdaPtDCAnegMass"), v0.pt(), v0.dcanegtopv(), v0.mAntiLambda()); + registry.fill(HIST("data/V0/AntiLambdaPtDCAdMass"), v0.pt(), v0.dcaV0daughters(), v0.mAntiLambda()); + } + } // for v0 + registry.fill(HIST("data/V0/nV0sEventAcc"), nV0s); + } template - void fillDataJetHistograms(T const& jet, double weight = 1.) + void fillDataJetHistograms(T const& jet) { - registry.fill(HIST("data/jets/jetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi(), weight); + registry.fill(HIST("data/jets/jetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi()); } - void fillDataJetHistogramsWithWeights(double jetpt, double jeteta, double jetphi, double weight = 1.) + template + void fillDataV0FragHistograms(CollisionType const& collision, JetType const& jet, V0Type const& v0) { - registry.fill(HIST("data/jets/weighted/jetPtEtaPhi"), jetpt, jeteta, jetphi, weight); + double trackProj = getMomFrac(jet, v0); + double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassK0Short; + + double massDiff = v0.mLambda() - v0.mAntiLambda(); + double massRatio = v0.mAntiLambda() / v0.mLambda(); + double massRelDiff = (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(); + + registry.fill(HIST("data/jets/V0/jetPtV0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("data/jets/V0/jetPtV0PtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda); + registry.fill(HIST("data/jets/V0/jetPtV0PtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtV0PtMassWide"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtV0PtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff); + registry.fill(HIST("data/jets/V0/jetPtV0PtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/jets/V0/jetPtV0PtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/jets/V0/jetPtV0PtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters()); + + registry.fill(HIST("data/jets/V0/jetPtV0TrackProj"), jet.pt(), trackProj); + registry.fill(HIST("data/jets/V0/jetPtV0TrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda); + registry.fill(HIST("data/jets/V0/jetPtV0TrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtV0TrackProjMassWide"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtV0TrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff); + registry.fill(HIST("data/jets/V0/jetPtV0TrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/jets/V0/jetPtV0TrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/jets/V0/jetPtV0TrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters()); + + if (v0.isK0SCandidate()) { + registry.fill(HIST("data/jets/V0/jetPtK0SPtCtau"), jet.pt(), v0.pt(), ctauK0s); + registry.fill(HIST("data/jets/V0/jetPtK0SPtMass"), jet.pt(), v0.pt(), v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtAllMasses"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtRadius"), jet.pt(), v0.pt(), v0.v0radius()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtCosPA"), jet.pt(), v0.pt(), v0.v0cosPA()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtCtauMass"), jet.pt(), v0.pt(), ctauK0s, v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtRadiusMass"), jet.pt(), v0.pt(), v0.v0radius(), v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtCosPAMass"), jet.pt(), v0.pt(), v0.v0cosPA(), v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtDCAposMass"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtDCAnegMass"), jet.pt(), v0.pt(), v0.dcanegtopv(), v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0SPtDCAdMass"), jet.pt(), v0.pt(), v0.dcaV0daughters(), v0.mK0Short()); + + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjCtau"), jet.pt(), trackProj, ctauK0s); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjMass"), jet.pt(), trackProj, v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjAllMasses"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjRadius"), jet.pt(), trackProj, v0.v0radius()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjCosPA"), jet.pt(), trackProj, v0.v0cosPA()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjCtauMass"), jet.pt(), trackProj, ctauK0s, v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjRadiusMass"), jet.pt(), trackProj, v0.v0radius(), v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjCosPAMass"), jet.pt(), trackProj, v0.v0cosPA(), v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjDCAposMass"), jet.pt(), trackProj, v0.dcapostopv(), v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjDCAnegMass"), jet.pt(), trackProj, v0.dcanegtopv(), v0.mK0Short()); + registry.fill(HIST("data/jets/V0/jetPtK0STrackProjDCAdMass"), jet.pt(), trackProj, v0.dcaV0daughters(), v0.mK0Short()); + } + if (v0.isLambdaCandidate()) { + registry.fill(HIST("data/jets/V0/jetPtLambdaPtCtau"), jet.pt(), v0.pt(), ctauLambda); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtMass"), jet.pt(), v0.pt(), v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtAllMasses"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtRadius"), jet.pt(), v0.pt(), v0.v0radius()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtCosPA"), jet.pt(), v0.pt(), v0.v0cosPA()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtCtauMass"), jet.pt(), v0.pt(), ctauLambda, v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtRadiusMass"), jet.pt(), v0.pt(), v0.v0radius(), v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtCosPAMass"), jet.pt(), v0.pt(), v0.v0cosPA(), v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtDCAposMass"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtDCAnegMass"), jet.pt(), v0.pt(), v0.dcanegtopv(), v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaPtDCAdMass"), jet.pt(), v0.pt(), v0.dcaV0daughters(), v0.mLambda()); + + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjCtau"), jet.pt(), trackProj, ctauLambda); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjMass"), jet.pt(), trackProj, v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjAllMasses"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjRadius"), jet.pt(), trackProj, v0.v0radius()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjCosPA"), jet.pt(), trackProj, v0.v0cosPA()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjCtauMass"), jet.pt(), trackProj, ctauLambda, v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjRadiusMass"), jet.pt(), trackProj, v0.v0radius(), v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjCosPAMass"), jet.pt(), trackProj, v0.v0cosPA(), v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjDCAposMass"), jet.pt(), trackProj, v0.dcapostopv(), v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjDCAnegMass"), jet.pt(), trackProj, v0.dcanegtopv(), v0.mLambda()); + registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjDCAdMass"), jet.pt(), trackProj, v0.dcaV0daughters(), v0.mLambda()); + } + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtCtau"), jet.pt(), v0.pt(), ctauAntiLambda); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtMass"), jet.pt(), v0.pt(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtAllMasses"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtRadius"), jet.pt(), v0.pt(), v0.v0radius()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtCosPA"), jet.pt(), v0.pt(), v0.v0cosPA()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtCtauMass"), jet.pt(), v0.pt(), ctauAntiLambda, v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtRadiusMass"), jet.pt(), v0.pt(), v0.v0radius(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtCosPAMass"), jet.pt(), v0.pt(), v0.v0cosPA(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtDCAposMass"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtDCAnegMass"), jet.pt(), v0.pt(), v0.dcanegtopv(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtDCAdMass"), jet.pt(), v0.pt(), v0.dcaV0daughters(), v0.mAntiLambda()); + + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjCtau"), jet.pt(), trackProj, ctauAntiLambda); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjMass"), jet.pt(), trackProj, v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjAllMasses"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjRadius"), jet.pt(), trackProj, v0.v0radius()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjCosPA"), jet.pt(), trackProj, v0.v0cosPA()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjCtauMass"), jet.pt(), trackProj, ctauAntiLambda, v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjRadiusMass"), jet.pt(), trackProj, v0.v0radius(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjCosPAMass"), jet.pt(), trackProj, v0.v0cosPA(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjDCAposMass"), jet.pt(), trackProj, v0.dcapostopv(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjDCAnegMass"), jet.pt(), trackProj, v0.dcanegtopv(), v0.mAntiLambda()); + registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjDCAdMass"), jet.pt(), trackProj, v0.dcaV0daughters(), v0.mAntiLambda()); + } } - template // Not used for V0 jets - void fillDataFragHistograms(T const& jet, double weight = 1.) + template + void fillDataPerpConeHists(T const& coll, U const& jet, V const& v0s) { - for (const auto& track : jet.template tracks_as()) { - double chargeFrag = -1., trackProj = -1., xi = -1., theta = -1.; - chargeFrag = ChargeFrag(jet, track); - trackProj = TrackProj(jet, track); - theta = Theta(jet, track); - xi = Xi(jet, track); - - registry.fill(HIST("data/jets/jetPtTrackPt"), jet.pt(), track.pt(), weight); - registry.fill(HIST("data/jets/jetTrackPtEtaPhi"), track.pt(), track.eta(), track.phi(), weight); - registry.fill(HIST("data/jets/jetPtFrag"), jet.pt(), chargeFrag, weight); - registry.fill(HIST("data/jets/jetPtTrackProj"), jet.pt(), trackProj, weight); - registry.fill(HIST("data/jets/jetPtXi"), jet.pt(), xi, weight); - registry.fill(HIST("data/jets/jetPtTheta"), jet.pt(), theta, weight); - registry.fill(HIST("data/jets/jetPtXiTheta"), jet.pt(), xi, theta, weight); - registry.fill(HIST("data/jets/jetPtZTheta"), jet.pt(), trackProj, theta, weight); + const int nCones = 2; + double perpConeR = jet.r() * 1e-2; + double conePhi[nCones] = {RecoDecay::constrainAngle(jet.phi() - constants::math::PIHalf, -constants::math::PI), + RecoDecay::constrainAngle(jet.phi() + constants::math::PIHalf, -constants::math::PI)}; + double conePt[nCones] = {0., 0.}; + int nV0sinCone[nCones] = {0, 0}; + for (const auto& v0 : v0s) { + if (v0.isRejectedCandidate()) + continue; + + bool v0InCones = false; + double dEta = v0.eta() - jet.eta(); + double dPhi[nCones] = {RecoDecay::constrainAngle(v0.phi() - conePhi[0], -constants::math::PI), + RecoDecay::constrainAngle(v0.phi() - conePhi[1], -constants::math::PI)}; + for (int i = 0; i < nCones; i++) { + if (std::sqrt(dEta * dEta + dPhi[i] * dPhi[i]) < perpConeR) { + conePt[i] += v0.pt(); + nV0sinCone[i]++; + v0InCones = true; + } + } + if (!v0InCones) { + continue; + } + + double ctauLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassK0Short; + + registry.fill(HIST("data/PC/JetPtEtaV0Pt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("data/PC/V0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("data/PC/V0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda); + registry.fill(HIST("data/PC/V0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/PC/V0PtMassWide"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda()); + registry.fill(HIST("data/PC/V0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/PC/V0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/PC/V0PtDCAd"), v0.pt(), v0.dcaV0daughters()); + + if (v0.isLambdaCandidate()) { + registry.fill(HIST("data/PC/JetPtLambdaPtMass"), jet.pt(), v0.pt(), v0.mLambda()); + + registry.fill(HIST("data/PC/JetPtEtaLambdaPt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("data/PC/LambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("data/PC/LambdaPtCtauMass"), v0.pt(), ctauLambda, v0.mLambda()); + registry.fill(HIST("data/PC/LambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/PC/LambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/PC/LambdaPtDCAd"), v0.pt(), v0.dcaV0daughters()); + } + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("data/PC/JetPtAntiLambdaPtMass"), jet.pt(), v0.pt(), v0.mAntiLambda()); + + registry.fill(HIST("data/PC/JetPtEtaAntiLambdaPt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("data/PC/AntiLambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("data/PC/AntiLambdaPtCtauMass"), v0.pt(), ctauAntiLambda, v0.mAntiLambda()); + registry.fill(HIST("data/PC/AntiLambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/PC/AntiLambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/PC/AntiLambdaPtDCAd"), v0.pt(), v0.dcaV0daughters()); + } + if (v0.isK0SCandidate()) { + registry.fill(HIST("data/PC/JetPtK0SPtMass"), jet.pt(), v0.pt(), v0.mK0Short()); + + registry.fill(HIST("data/PC/JetPtEtaK0SPt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("data/PC/K0SPtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); + registry.fill(HIST("data/PC/K0SPtCtauMass"), v0.pt(), ctauK0s, v0.mK0Short()); + registry.fill(HIST("data/PC/K0SPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA()); + registry.fill(HIST("data/PC/K0SPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv()); + registry.fill(HIST("data/PC/K0SPtDCAd"), v0.pt(), v0.dcaV0daughters()); + } + } + // Fill hist for nCones: nv0s, conePt, coneEta, conePhi + for (int i = 0; i < nCones; i++) { + registry.fill(HIST("data/PC/nV0sConePtEta"), nV0sinCone[i], conePt[i], jet.eta()); + registry.fill(HIST("data/PC/ConePtEtaPhi"), conePt[i], jet.eta(), conePhi[i]); + registry.fill(HIST("data/PC/JetPtEtaConePt"), jet.pt(), jet.eta(), conePt[i]); } } - + // Data - Weighted template - void fillDataV0Histograms(CollisionType const& collision, V0Type const& V0s, double weight = 1.) + void fillDataV0HistogramsWeighted(CollisionType const& collision, V0Type const& V0s) { + // Fill histograms with V0 signal weights + float nV0s = 0; for (const auto& v0 : V0s) { - double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; + if (v0.isRejectedCandidate()) + continue; + + float weight = getV0SignalProb(v0); + nV0s += weight; // Sum weights (purity) of V0s + + double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassK0Short; double massDiff = v0.mLambda() - v0.mAntiLambda(); double massRatio = v0.mAntiLambda() / v0.mLambda(); double massRelDiff = (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(); - registry.fill(HIST("data/V0/V0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("data/V0/V0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("data/V0/V0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/V0/V0PtMassWide"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/V0/V0PtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("data/V0/V0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/V0/V0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/V0/V0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - - registry.fill(HIST("data/V0/V0CutVariation"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), v0.v0radius(), ctauK0s, v0.v0cosPA(), TMath::Abs(v0.dcapostopv()), TMath::Abs(v0.dcanegtopv()), v0.dcaV0daughters(), weight); - - if (IsLambdaCandidate(collision, v0)) { - registry.fill(HIST("data/V0/LambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("data/V0/LambdaPtCtauMass"), v0.pt(), ctauLambda, v0.mLambda(), weight); - registry.fill(HIST("data/V0/LambdaPtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("data/V0/LambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/V0/LambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/V0/LambdaPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + registry.fill(HIST("data/V0/V0PtEtaPhiWeighted"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("data/V0/V0PtCtauWeighted"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("data/V0/V0PtMassWeighted"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/V0/V0PtMassWideWeighted"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/V0/V0PtLambdaMassesWeighted"), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("data/V0/V0PtRadiusCosPAWeighted"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("data/V0/V0PtDCAposnegWeighted"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("data/V0/V0PtDCAdWeighted"), v0.pt(), v0.dcaV0daughters(), weight); + + if (v0.isK0SCandidate()) { + registry.fill(HIST("data/V0/K0SPtEtaPhiWeighted"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("data/V0/K0SPtRadiusCosPAWeighted"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("data/V0/K0SPtDCAposnegWeighted"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("data/V0/K0SPtDCAdWeighted"), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("data/V0/K0SPtCtauMassWeighted"), v0.pt(), ctauK0s, v0.mK0Short(), weight); + registry.fill(HIST("data/V0/K0SPtRadiusMassWeighted"), v0.pt(), v0.v0radius(), v0.mK0Short(), weight); + registry.fill(HIST("data/V0/K0SPtCosPAMassWeighted"), v0.pt(), v0.v0cosPA(), v0.mK0Short(), weight); + registry.fill(HIST("data/V0/K0SPtDCAposMassWeighted"), v0.pt(), v0.dcapostopv(), v0.mK0Short(), weight); + registry.fill(HIST("data/V0/K0SPtDCAnegMassWeighted"), v0.pt(), v0.dcanegtopv(), v0.mK0Short(), weight); + registry.fill(HIST("data/V0/K0SPtDCAdMassWeighted"), v0.pt(), v0.dcaV0daughters(), v0.mK0Short(), weight); } - if (IsAntiLambdaCandidate(collision, v0)) { - registry.fill(HIST("data/V0/antiLambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("data/V0/antiLambdaPtCtauMass"), v0.pt(), ctauAntiLambda, v0.mAntiLambda(), weight); - registry.fill(HIST("data/V0/antiLambdaPtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("data/V0/antiLambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/V0/antiLambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/V0/antiLambdaPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + if (v0.isLambdaCandidate()) { + registry.fill(HIST("data/V0/LambdaPtEtaPhiWeighted"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("data/V0/LambdaPtLambdaMassesWeighted"), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("data/V0/LambdaPtRadiusCosPAWeighted"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("data/V0/LambdaPtDCAposnegWeighted"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("data/V0/LambdaPtDCAdWeighted"), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("data/V0/LambdaPtCtauMassWeighted"), v0.pt(), ctauLambda, v0.mLambda(), weight); + registry.fill(HIST("data/V0/LambdaPtRadiusMassWeighted"), v0.pt(), v0.v0radius(), v0.mLambda(), weight); + registry.fill(HIST("data/V0/LambdaPtCosPAMassWeighted"), v0.pt(), v0.v0cosPA(), v0.mLambda(), weight); + registry.fill(HIST("data/V0/LambdaPtDCAposMassWeighted"), v0.pt(), v0.dcapostopv(), v0.mLambda(), weight); + registry.fill(HIST("data/V0/LambdaPtDCAnegMassWeighted"), v0.pt(), v0.dcanegtopv(), v0.mLambda(), weight); + registry.fill(HIST("data/V0/LambdaPtDCAdMassWeighted"), v0.pt(), v0.dcaV0daughters(), v0.mLambda(), weight); } - if (IsK0SCandidate(collision, v0)) { - registry.fill(HIST("data/V0/K0SPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("data/V0/K0SPtCtauMass"), v0.pt(), ctauK0s, v0.mK0Short(), weight); - registry.fill(HIST("data/V0/K0SPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/V0/K0SPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/V0/K0SPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("data/V0/AntiLambdaPtEtaPhiWeighted"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("data/V0/AntiLambdaPtLambdaMassesWeighted"), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("data/V0/AntiLambdaPtRadiusCosPAWeighted"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("data/V0/AntiLambdaPtDCAposnegWeighted"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("data/V0/AntiLambdaPtDCAdWeighted"), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("data/V0/AntiLambdaPtCtauMassWeighted"), v0.pt(), ctauAntiLambda, v0.mAntiLambda(), weight); + registry.fill(HIST("data/V0/AntiLambdaPtRadiusMassWeighted"), v0.pt(), v0.v0radius(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/V0/AntiLambdaPtCosPAMassWeighted"), v0.pt(), v0.v0cosPA(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/V0/AntiLambdaPtDCAposMassWeighted"), v0.pt(), v0.dcapostopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/V0/AntiLambdaPtDCAnegMassWeighted"), v0.pt(), v0.dcanegtopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/V0/AntiLambdaPtDCAdMassWeighted"), v0.pt(), v0.dcaV0daughters(), v0.mAntiLambda(), weight); } } // for v0 + registry.fill(HIST("data/V0/nV0sEventAccWeighted"), nV0s); } - - template - void fillDataV0FragHistograms(CollisionType const& collision, JetType const& jet, V0Type const& v0, double weight = 1.) + void fillDataJetHistogramsWeighted(double jetpt, double jeteta, double jetphi, double weight = 1.) { - double trackProj = TrackProj(jet, v0); - double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; - - double massDiff = v0.mLambda() - v0.mAntiLambda(); - double massRatio = v0.mAntiLambda() / v0.mLambda(); - double massRelDiff = (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(); - - registry.fill(HIST("data/jets/V0/jetPtV0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("data/jets/V0/jetPtV0PtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("data/jets/V0/jetPtV0PtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtV0PtMassWide"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtV0PtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("data/jets/V0/jetPtV0PtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/jets/V0/jetPtV0PtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/jets/V0/jetPtV0PtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - - registry.fill(HIST("data/jets/V0/jetPtV0TrackProj"), jet.pt(), trackProj, weight); - registry.fill(HIST("data/jets/V0/jetPtV0TrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("data/jets/V0/jetPtV0TrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtV0TrackProjMassWide"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtV0TrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("data/jets/V0/jetPtV0TrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/jets/V0/jetPtV0TrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/jets/V0/jetPtV0TrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); - - if (IsK0SCandidate(collision, v0)) { - registry.fill(HIST("data/jets/V0/jetPtK0SPtCtau"), jet.pt(), v0.pt(), ctauK0s, weight); - registry.fill(HIST("data/jets/V0/jetPtK0SPtMass"), jet.pt(), v0.pt(), v0.mK0Short(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0SPtAllMasses"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0SPtRadius"), jet.pt(), v0.pt(), v0.v0radius(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0SPtCosPA"), jet.pt(), v0.pt(), v0.v0cosPA(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0SPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0SPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - - registry.fill(HIST("data/jets/V0/jetPtK0STrackProjCtau"), jet.pt(), trackProj, ctauK0s, weight); - registry.fill(HIST("data/jets/V0/jetPtK0STrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0STrackProjAllMasses"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0STrackProjRadius"), jet.pt(), trackProj, v0.v0radius(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0STrackProjCosPA"), jet.pt(), trackProj, v0.v0cosPA(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0STrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); - registry.fill(HIST("data/jets/V0/jetPtK0STrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - } - if (IsLambdaCandidate(collision, v0)) { - registry.fill(HIST("data/jets/V0/jetPtLambdaPtCtau"), jet.pt(), v0.pt(), ctauLambda, weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaPtMass"), jet.pt(), v0.pt(), v0.mLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaPtAllMasses"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaPtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaPtRadius"), jet.pt(), v0.pt(), v0.v0radius(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaPtCosPA"), jet.pt(), v0.pt(), v0.v0cosPA(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - - registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjCtau"), jet.pt(), trackProj, ctauLambda, weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjMass"), jet.pt(), trackProj, v0.mLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjAllMasses"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjRadius"), jet.pt(), trackProj, v0.v0radius(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjCosPA"), jet.pt(), trackProj, v0.v0cosPA(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); - registry.fill(HIST("data/jets/V0/jetPtLambdaTrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - } - if (IsAntiLambdaCandidate(collision, v0)) { - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtCtau"), jet.pt(), v0.pt(), ctauAntiLambda, weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtMass"), jet.pt(), v0.pt(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtAllMasses"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtRadius"), jet.pt(), v0.pt(), v0.v0radius(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtCosPA"), jet.pt(), v0.pt(), v0.v0cosPA(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjCtau"), jet.pt(), trackProj, ctauAntiLambda, weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjMass"), jet.pt(), trackProj, v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjAllMasses"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjRadius"), jet.pt(), trackProj, v0.v0radius(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjCosPA"), jet.pt(), trackProj, v0.v0cosPA(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); - registry.fill(HIST("data/jets/V0/jetPtAntiLambdaTrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - } + registry.fill(HIST("data/jets/weighted/jetPtEtaPhi"), jetpt, jeteta, jetphi, weight); } template - void fillDataV0FragHistogramsWithWeights(C const& collision, J const& jet, std::vector state, std::vector values, double weight) + void fillDataV0FragHistogramsWeighted(C const& collision, J const& jet, std::vector state, std::vector values, double weight) { - // TODO: Add other histograms double jetpt = values[values.size() - 1]; int ip = 0; - for (const auto& v0 : jet.template candidates_as()) { + for (const auto& v0 : jet.template candidates_as()) { + if (v0.isRejectedCandidate()) + continue; + double z = values[ip]; ip++; - double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; - double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassK0Short; + double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0Bar; + + double massDiff = v0.mLambda() - v0.mAntiLambda(); + double massRatio = v0.mAntiLambda() / v0.mLambda(); + double massRelDiff = (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(); switch (state[ip]) { case 0: // Background @@ -1429,434 +1736,353 @@ struct JetFragmentation { registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjRadiusCosPA"), jetpt, z, v0.v0radius(), v0.v0cosPA(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAposneg"), jetpt, z, v0.dcapostopv(), v0.dcanegtopv(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAd"), jetpt, z, v0.dcaV0daughters(), weight); + + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjCtauK0SMass"), jetpt, z, ctauK0s, v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjRadiusK0SMass"), jetpt, z, v0.v0radius(), v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjCosPAK0SMass"), jetpt, z, v0.v0cosPA(), v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAposK0SMass"), jetpt, z, v0.dcapostopv(), v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAnegK0SMass"), jetpt, z, v0.dcanegtopv(), v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAdK0SMass"), jetpt, z, v0.dcaV0daughters(), v0.mK0Short(), weight); + + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjCtauLambdaMass"), jetpt, z, ctauLambda, v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjRadiusLambdaMass"), jetpt, z, v0.v0radius(), v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjCosPALambdaMass"), jetpt, z, v0.v0cosPA(), v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAposLambdaMass"), jetpt, z, v0.dcapostopv(), v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAnegLambdaMass"), jetpt, z, v0.dcanegtopv(), v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAdLambdaMass"), jetpt, z, v0.dcaV0daughters(), v0.mLambda(), weight); + + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjCtauAntiLambdaMass"), jetpt, z, ctauAntiLambda, v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjRadiusAntiLambdaMass"), jetpt, z, v0.v0radius(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjCosPAAntiLambdaMass"), jetpt, z, v0.v0cosPA(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAposAntiLambdaMass"), jetpt, z, v0.dcapostopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAnegAntiLambdaMass"), jetpt, z, v0.dcanegtopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjDCAdAntiLambdaMass"), jetpt, z, v0.dcaV0daughters(), v0.mAntiLambda(), weight); break; case 1: // K0S + registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjMass"), jetpt, z, v0.mK0Short(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjCtau"), jetpt, z, ctauK0s, weight); registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjAllMasses"), jetpt, z, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjRadius"), jetpt, z, v0.v0radius(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjCosPA"), jetpt, z, v0.v0cosPA(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjDCAd"), jetpt, z, v0.dcaV0daughters(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjDCAposneg"), jetpt, z, v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjCtauMass"), jetpt, z, ctauK0s, v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjRadiusMass"), jetpt, z, v0.v0radius(), v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjCosPAMass"), jetpt, z, v0.v0cosPA(), v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjDCAposMass"), jetpt, z, v0.dcapostopv(), v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjDCAnegMass"), jetpt, z, v0.dcanegtopv(), v0.mK0Short(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtK0STrackProjDCAdMass"), jetpt, z, v0.dcaV0daughters(), v0.mK0Short(), weight); break; case 2: // Lambda + registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjMass"), jetpt, z, v0.mLambda(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjCtau"), jetpt, z, ctauLambda, weight); registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjAllMasses"), jetpt, z, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjLambdaMasses"), jetpt, z, massDiff, massRatio, massRelDiff, weight); registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjRadius"), jetpt, z, v0.v0radius(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjCosPA"), jetpt, z, v0.v0cosPA(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjDCAd"), jetpt, z, v0.dcaV0daughters(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjDCAposneg"), jetpt, z, v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjCtauMass"), jetpt, z, ctauLambda, v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjRadiusMass"), jetpt, z, v0.v0radius(), v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjCosPAMass"), jetpt, z, v0.v0cosPA(), v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjDCAposMass"), jetpt, z, v0.dcapostopv(), v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjDCAnegMass"), jetpt, z, v0.dcanegtopv(), v0.mLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtLambdaTrackProjDCAdMass"), jetpt, z, v0.dcaV0daughters(), v0.mLambda(), weight); break; case 3: // AntiLambda + registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjMass"), jetpt, z, v0.mAntiLambda(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCtau"), jetpt, z, ctauAntiLambda, weight); registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjAllMasses"), jetpt, z, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjLambdaMasses"), jetpt, z, massDiff, massRatio, massRelDiff, weight); registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjRadius"), jetpt, z, v0.v0radius(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCosPA"), jetpt, z, v0.v0cosPA(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAd"), jetpt, z, v0.dcaV0daughters(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAposneg"), jetpt, z, v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCtauMass"), jetpt, z, ctauAntiLambda, v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjRadiusMass"), jetpt, z, v0.v0radius(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjCosPAMass"), jetpt, z, v0.v0cosPA(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAposMass"), jetpt, z, v0.dcapostopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAnegMass"), jetpt, z, v0.dcanegtopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtAntiLambdaTrackProjDCAdMass"), jetpt, z, v0.dcaV0daughters(), v0.mAntiLambda(), weight); break; } - registry.fill(HIST("data/jets/weighted/V0/jetPtV0TrackProjCtau"), jetpt, z, ctauK0s, ctauLambda, ctauAntiLambda, weight); registry.fill(HIST("data/jets/weighted/V0/jetPtV0TrackProjMass"), jetpt, z, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtV0TrackProjCtau"), jetpt, z, ctauK0s, ctauLambda, ctauAntiLambda, weight); registry.fill(HIST("data/jets/weighted/V0/jetPtV0TrackProjMassWide"), jetpt, z, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtV0TrackProjLambdaMasses"), jetpt, z, massDiff, massRatio, massRelDiff, weight); registry.fill(HIST("data/jets/weighted/V0/jetPtV0TrackProjRadiusCosPA"), jetpt, z, v0.v0radius(), v0.v0cosPA(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtV0TrackProjDCAposneg"), jetpt, z, v0.dcapostopv(), v0.dcanegtopv(), weight); registry.fill(HIST("data/jets/weighted/V0/jetPtV0TrackProjDCAd"), jetpt, z, v0.dcaV0daughters(), weight); - } + } // v0 loop } - template - void fillMatchingHistogramsJet(DetJet const& detJet, PartJet const& partJet, double weight = 1.) + // MC - Counts (or event weights) + template + void fillMCPV0Histograms(T const& pV0s, double weight = 1.) { - double deltaEta = detJet.eta() - partJet.eta(); - double deltaPhi = RecoDecay::constrainAngle(detJet.phi() - partJet.phi(), -M_PI); - double dR = jetutilities::deltaR(detJet, partJet); - - registry.fill(HIST("matching/jets/matchDetJetPtEtaPhi"), detJet.pt(), detJet.eta(), detJet.phi(), weight); - registry.fill(HIST("matching/jets/matchPartJetPtEtaPhi"), partJet.pt(), partJet.eta(), partJet.phi(), weight); - registry.fill(HIST("matching/jets/matchPartJetPtEtaPhiMatchDist"), partJet.pt(), partJet.eta(), partJet.phi(), dR, weight); - registry.fill(HIST("matching/jets/matchPartJetPtEnergyScale"), partJet.pt(), detJet.pt() / partJet.pt(), weight); - registry.fill(HIST("matching/jets/matchDetJetPtPartJetPt"), detJet.pt(), partJet.pt(), weight); - registry.fill(HIST("matching/jets/matchPartJetPtDetJetEtaPartJetEta"), partJet.pt(), detJet.eta(), partJet.eta(), weight); - registry.fill(HIST("matching/jets/matchPartJetPtDetJetPhiPartJetPhi"), partJet.pt(), detJet.phi(), partJet.phi(), weight); - registry.fill(HIST("matching/jets/matchPartJetPtResolutionPt"), partJet.pt(), (detJet.pt() - partJet.pt()), weight); - registry.fill(HIST("matching/jets/matchPartJetPtResolutionEta"), partJet.pt(), partJet.eta(), deltaEta, weight); - registry.fill(HIST("matching/jets/matchPartJetPtResolutionPhi"), partJet.pt(), partJet.phi(), deltaPhi, weight); - registry.fill(HIST("matching/jets/matchPartJetPtRelDiffPt"), partJet.pt(), (detJet.pt() - partJet.pt()) / partJet.pt(), weight); + float nV0s = 0; + for (const auto& pv0 : pV0s) { + int pdg = pv0.pdgCode(); + nV0s += 1; + registry.fill(HIST("mcp/V0/V0PtEtaPhi"), pv0.pt(), pv0.eta(), pv0.phi(), weight); + if (std::abs(pdg) == PDG_t::kK0Short) + registry.fill(HIST("mcp/V0/K0SPtEtaPhi"), pv0.pt(), pv0.eta(), pv0.phi(), weight); + + if (pdg == PDG_t::kLambda0) + registry.fill(HIST("mcp/V0/LambdaPtEtaPhi"), pv0.pt(), pv0.eta(), pv0.phi(), weight); + + if (pdg == PDG_t::kLambda0Bar) + registry.fill(HIST("mcp/V0/AntiLambdaPtEtaPhi"), pv0.pt(), pv0.eta(), pv0.phi(), weight); + } + registry.fill(HIST("mcp/V0/nV0sEventAcc"), nV0s); + registry.fill(HIST("mcp/V0/nV0sEventAccWeighted"), nV0s, weight); } - - template // Not used for V0 jets - void fillMatchingHistogramsConstituent(DetJet const& detJet, PartJet const& partJet, Track const& track, Particle const& particle, double weight = 1.) + template + void fillMCPJetHistograms(T const& jet, double weight = 1.) { - double detChargeFrag = -1., detTrackProj = -1., detTheta = -1., detXi = -1.; - double partChargeFrag = -1., partTrackProj = -1., partTheta = -1., partXi = -1.; - - detChargeFrag = ChargeFrag(detJet, track); - detTrackProj = TrackProj(detJet, track); - detTheta = Theta(detJet, track); - detXi = Xi(detJet, track); - - partChargeFrag = ChargeFrag(partJet, particle); - partTrackProj = TrackProj(partJet, particle); - partTheta = Theta(partJet, particle); - partXi = Xi(partJet, particle); - - // Detector level - registry.fill(HIST("matching/jets/matchDetJetTrackPtEtaPhi"), track.pt(), track.eta(), track.phi(), weight); - registry.fill(HIST("matching/jets/matchDetJetPtTrackPt"), detJet.pt(), track.pt(), weight); - registry.fill(HIST("matching/jets/matchDetJetPtFrag"), detJet.pt(), detChargeFrag, weight); - registry.fill(HIST("matching/jets/matchDetJetPtTrackProj"), detJet.pt(), detTrackProj, weight); - registry.fill(HIST("matching/jets/matchDetJetPtXi"), detJet.pt(), detXi, weight); - registry.fill(HIST("matching/jets/matchDetJetPtTheta"), detJet.pt(), detTheta, weight); - registry.fill(HIST("matching/jets/matchDetJetPtXiTheta"), detJet.pt(), detXi, detTheta, weight); - registry.fill(HIST("matching/jets/matchDetJetPtZTheta"), detJet.pt(), detTrackProj, detTheta, weight); - - // Particle level - registry.fill(HIST("matching/jets/matchPartJetTrackPtEtaPhi"), particle.pt(), particle.eta(), particle.phi(), weight); - registry.fill(HIST("matching/jets/matchPartJetPtTrackPt"), partJet.pt(), particle.pt(), weight); - registry.fill(HIST("matching/jets/matchPartJetPtFrag"), partJet.pt(), partChargeFrag, weight); - registry.fill(HIST("matching/jets/matchPartJetPtTrackProj"), partJet.pt(), partTrackProj, weight); - registry.fill(HIST("matching/jets/matchPartJetPtXi"), partJet.pt(), partXi, weight); - registry.fill(HIST("matching/jets/matchPartJetPtTheta"), partJet.pt(), partTheta, weight); - registry.fill(HIST("matching/jets/matchPartJetPtXiTheta"), partJet.pt(), partXi, partTheta, weight); - registry.fill(HIST("matching/jets/matchPartJetPtZTheta"), partJet.pt(), partTrackProj, partTheta, weight); - - // Resolution - registry.fill(HIST("matching/jets/matchPartJetPtResolutionTrackPt"), partJet.pt(), particle.pt(), (particle.pt() - track.pt()), weight); - registry.fill(HIST("matching/jets/matchPartJetPtResolutionChargeFrag"), partJet.pt(), partChargeFrag, (detChargeFrag - partChargeFrag), weight); - registry.fill(HIST("matching/jets/matchPartJetPtResolutionTrackProj"), partJet.pt(), partTrackProj, (detTrackProj - partTrackProj), weight); - registry.fill(HIST("matching/jets/matchPartJetPtResolutionXi"), partJet.pt(), partXi, (detXi - partXi), weight); - registry.fill(HIST("matching/jets/matchPartJetPtResolutionTheta"), partJet.pt(), partTheta, (detTheta - partTheta), weight); - registry.fill(HIST("matching/jets/matchPartJetPtResolutionXiResolutionTheta"), partJet.pt(), partXi, (detXi - partXi), partTheta, (detTheta - partTheta), weight); - registry.fill(HIST("matching/jets/matchPartJetPtResolutionZResolutionTheta"), partJet.pt(), partTrackProj, (detTrackProj - partTrackProj), partTheta, (detTheta - partTheta), weight); - - // Relative difference - registry.fill(HIST("matching/jets/matching/jets/matchPartJetPtRelDiffTrackPt"), partJet.pt(), detJet.pt() / partJet.pt(), particle.pt(), (track.pt() - particle.pt()) / particle.pt(), weight); - registry.fill(HIST("matching/jets/matchPartJetPtRelDiffTrackProj"), partJet.pt(), detJet.pt() / partJet.pt(), partTrackProj, (detTrackProj - partTrackProj) / partTrackProj, weight); - - // Response - registry.fill(HIST("matching/jets/matchDetJetPtFragPartJetPtFrag"), detJet.pt(), detChargeFrag, partJet.pt(), partChargeFrag, weight); - registry.fill(HIST("matching/jets/matchDetJetPtTrackProjPartJetPtTrackProj"), detJet.pt(), detTrackProj, partJet.pt(), partTrackProj, weight); - registry.fill(HIST("matching/jets/matchDetJetPtXiPartJetPtXi"), detJet.pt(), detXi, partJet.pt(), partXi, weight); - registry.fill(HIST("matching/jets/matchDetJetPtThetaPartJetPtTheta"), detJet.pt(), detTheta, partJet.pt(), partTheta, weight); - registry.fill(HIST("matching/jets/matchDetJetPtXiThetaPartJetPtXiTheta"), detJet.pt(), detXi, detTheta, partJet.pt(), partXi, partTheta, weight); - registry.fill(HIST("matching/jets/matchDetJetPtZThetaPartJetPtZTheta"), detJet.pt(), detTrackProj, detTheta, partJet.pt(), partTrackProj, partTheta, weight); + registry.fill(HIST("mcp/jets/partJetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi(), weight); } + template + void fillMCDV0Histograms(T const& coll, U const& V0s, double weight = 1.) + { + float nV0s = 0; + for (const auto& v0 : V0s) { + if (v0.isRejectedCandidate()) + continue; + + nV0s += 1; + double ctauLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassK0Short; + + double massDiff = v0.mLambda() - v0.mAntiLambda(); + double massRatio = v0.mAntiLambda() / v0.mLambda(); + double massRelDiff = (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(); - template // Not used for V0 jets - void fillMatchingFakeOrMiss(Jet const& jet, Constituent const& constituent, bool isFake, double weight = 1.) + registry.fill(HIST("mcd/V0/V0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("mcd/V0/V0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("mcd/V0/V0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("mcd/V0/V0PtLambdaMasses"), v0.pt(), v0.mLambda() - v0.mAntiLambda(), v0.mAntiLambda() / v0.mLambda(), (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(), weight); + registry.fill(HIST("mcd/V0/V0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("mcd/V0/V0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("mcd/V0/V0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + + if (v0.isK0SCandidate()) { + registry.fill(HIST("mcd/V0/K0SPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("mcd/V0/K0SPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("mcd/V0/K0SPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("mcd/V0/K0SPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("mcd/V0/K0SPtCtauMass"), v0.pt(), ctauK0s, v0.mK0Short(), weight); + registry.fill(HIST("mcd/V0/K0SPtRadiusMass"), v0.pt(), v0.v0radius(), v0.mK0Short(), weight); + registry.fill(HIST("mcd/V0/K0SPtCosPAMass"), v0.pt(), v0.v0cosPA(), v0.mK0Short(), weight); + registry.fill(HIST("mcd/V0/K0SPtDCAposMass"), v0.pt(), v0.dcapostopv(), v0.mK0Short(), weight); + registry.fill(HIST("mcd/V0/K0SPtDCAnegMass"), v0.pt(), v0.dcanegtopv(), v0.mK0Short(), weight); + registry.fill(HIST("mcd/V0/K0SPtDCAdMass"), v0.pt(), v0.dcaV0daughters(), v0.mK0Short(), weight); + } + if (v0.isLambdaCandidate()) { + registry.fill(HIST("mcd/V0/LambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("mcd/V0/LambdaPtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("mcd/V0/LambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("mcd/V0/LambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("mcd/V0/LambdaPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("mcd/V0/LambdaPtCtauMass"), v0.pt(), ctauLambda, v0.mLambda(), weight); + registry.fill(HIST("mcd/V0/LambdaPtRadiusMass"), v0.pt(), v0.v0radius(), v0.mLambda(), weight); + registry.fill(HIST("mcd/V0/LambdaPtCosPAMass"), v0.pt(), v0.v0cosPA(), v0.mLambda(), weight); + registry.fill(HIST("mcd/V0/LambdaPtDCAposMass"), v0.pt(), v0.dcapostopv(), v0.mLambda(), weight); + registry.fill(HIST("mcd/V0/LambdaPtDCAnegMass"), v0.pt(), v0.dcanegtopv(), v0.mLambda(), weight); + registry.fill(HIST("mcd/V0/LambdaPtDCAdMass"), v0.pt(), v0.dcaV0daughters(), v0.mLambda(), weight); + } + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("mcd/V0/AntiLambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("mcd/V0/AntiLambdaPtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("mcd/V0/AntiLambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("mcd/V0/AntiLambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("mcd/V0/AntiLambdaPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("mcd/V0/AntiLambdaPtCtauMass"), v0.pt(), ctauAntiLambda, v0.mAntiLambda(), weight); + registry.fill(HIST("mcd/V0/AntiLambdaPtRadiusMass"), v0.pt(), v0.v0radius(), v0.mAntiLambda(), weight); + registry.fill(HIST("mcd/V0/AntiLambdaPtCosPAMass"), v0.pt(), v0.v0cosPA(), v0.mAntiLambda(), weight); + registry.fill(HIST("mcd/V0/AntiLambdaPtDCAposMass"), v0.pt(), v0.dcapostopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("mcd/V0/AntiLambdaPtDCAnegMass"), v0.pt(), v0.dcanegtopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("mcd/V0/AntiLambdaPtDCAdMass"), v0.pt(), v0.dcaV0daughters(), v0.mAntiLambda(), weight); + } + } // for v0 + registry.fill(HIST("mcd/V0/nV0sEventAcc"), nV0s); + registry.fill(HIST("mcd/V0/nV0sEventAccWeighted"), nV0s, weight); + } + template + void fillMCDJetHistograms(T const& jet, double weight = 1.) { - double chargeFrag = -1., trackProj = -1., theta = -1., xi = -1.; - chargeFrag = ChargeFrag(jet, constituent); - trackProj = TrackProj(jet, constituent); - theta = Theta(jet, constituent); - xi = Xi(jet, constituent); - - if (isFake) { - registry.fill(HIST("matching/jets/fakeDetJetPtFrag"), jet.pt(), chargeFrag, weight); - registry.fill(HIST("matching/jets/fakeDetJetPtTrackProj"), jet.pt(), trackProj, weight); - registry.fill(HIST("matching/jets/fakeDetJetPtXi"), jet.pt(), xi, weight); - registry.fill(HIST("matching/jets/fakeDetJetPtTheta"), jet.pt(), theta, weight); - registry.fill(HIST("matching/jets/fakeDetJetPtXiTheta"), jet.pt(), xi, theta, weight); - registry.fill(HIST("matching/jets/fakeDetJetPtZTheta"), jet.pt(), trackProj, theta, weight); - } else { - registry.fill(HIST("matching/jets/missPartJetPtFrag"), jet.pt(), chargeFrag, weight); - registry.fill(HIST("matching/jets/missPartJetPtTrackProj"), jet.pt(), trackProj, weight); - registry.fill(HIST("matching/jets/missPartJetPtXi"), jet.pt(), xi, weight); - registry.fill(HIST("matching/jets/missPartJetPtTheta"), jet.pt(), theta, weight); - registry.fill(HIST("matching/jets/missPartJetPtXiTheta"), jet.pt(), xi, theta, weight); - registry.fill(HIST("matching/jets/missPartJetPtZTheta"), jet.pt(), trackProj, theta, weight); - } + registry.fill(HIST("mcd/jets/detJetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi(), weight); } - - template - void fillMatchingV0Miss(JetType const& jet, V0Type const& v0, double weight = 1.) + // Reconstructed V0s in the cone of MCD jets + template + void fillMcPerpConeHists(T const& coll, U const& mcdjet, V const& v0s, W const& /* V0 particles */, double weight = 1.) { - double trackProj = TrackProj(jet, v0); + const int nCones = 2; + double perpConeR = mcdjet.r() * 1e-2; + double conePhi[nCones] = {RecoDecay::constrainAngle(mcdjet.phi() - constants::math::PIHalf, -constants::math::PI), + RecoDecay::constrainAngle(mcdjet.phi() + constants::math::PIHalf, -constants::math::PI)}; + double coneMatchedPt[nCones] = {0., 0.}; + double coneFakePt[nCones] = {0., 0.}; + int nMatchedV0sinCone[nCones] = {0, 0}; + int nFakeV0sinCone[nCones] = {0, 0}; - registry.fill(HIST("matching/jets/V0/missJetPtV0TrackProj"), jet.pt(), trackProj, weight); - registry.fill(HIST("matching/jets/V0/missJetPtV0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - if (TMath::Abs(v0.pdgCode()) == 310) { // K0S - registry.fill(HIST("matching/jets/V0/missJetPtK0SPtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/jets/V0/missJetPtK0STrackProj"), jet.pt(), trackProj, weight); - } else if (v0.pdgCode() == 3122) { // Lambda - registry.fill(HIST("matching/jets/V0/missJetPtLambda0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/jets/V0/missJetPtLambda0TrackProj"), jet.pt(), trackProj, weight); - } else if (v0.pdgCode() == -3122) { // AntiLambda - registry.fill(HIST("matching/jets/V0/missJetPtAntiLambda0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/jets/V0/missJetPtAntiLambda0TrackProj"), jet.pt(), trackProj, weight); - } - } - - template - void fillMatchingV0Fake(CollisionType const& collision, JetType const& jet, V0Type const& v0, double weight = 1.) - { - double trackProj = TrackProj(jet, v0); - double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; - double massDiff = v0.mLambda() - v0.mAntiLambda(); - double massRatio = v0.mAntiLambda() / v0.mLambda(); - double massRelDiff = (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(); - - registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProj"), jet.pt(), trackProj, weight); - - registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - - registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); - - if (IsLambdaCandidate(collision, v0)) { - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0TrackProj"), jet.pt(), trackProj, weight); - - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0PtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0PtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0PtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0PtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0PtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0PtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0TrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0TrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0TrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0TrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0TrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtLambda0TrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); - } - if (IsAntiLambdaCandidate(collision, v0)) { - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0TrackProj"), jet.pt(), trackProj, weight); - - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0PtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0PtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0PtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0PtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0PtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0PtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0TrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0TrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0TrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0TrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0TrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambda0TrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); - } - if (IsK0SCandidate(collision, v0)) { - registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProj"), jet.pt(), trackProj, weight); - - registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - - registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); - } - } - - // Combinatorial background for inclusive V0s - template - void fillMatchingV0FakeHistograms(T const& coll, U const& v0, double weight = 1.) - { - double ctauLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassK0Short; - - registry.fill(HIST("matching/V0/fakeV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/V0/fakeV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/V0/fakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/V0/fakeV0PtLambdaMasses"), v0.pt(), v0.mLambda() - v0.mAntiLambda(), v0.mAntiLambda() / v0.mLambda(), (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(), weight); - registry.fill(HIST("matching/V0/fakeV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/V0/fakeV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/V0/fakeV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - } - // Check if V0 was missed because daughter decayed - template - void fillMatchingV0DecayedHistograms(V const& v0, double weight = 1.) - { - // Check if decayed daughter - auto posTrack = v0.template posTrack_as(); - auto negTrack = v0.template negTrack_as(); - - auto posPart = posTrack.template mcParticle_as(); - auto negPart = negTrack.template mcParticle_as(); + for (const auto& v0 : v0s) { + double dEta = v0.eta() - mcdjet.eta(); + double dPhi[nCones] = {RecoDecay::constrainAngle(v0.phi() - conePhi[0], -constants::math::PI), + RecoDecay::constrainAngle(v0.phi() - conePhi[1], -constants::math::PI)}; + for (int i = 0; i < nCones; i++) { + if (std::sqrt(dEta * dEta + dPhi[i] * dPhi[i]) > perpConeR) { + continue; + } - auto posMom = posPart.template mothers_first_as(); - auto negMom = negPart.template mothers_first_as(); + double ctauLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassK0Short; - bool posDecayed = false; - bool negDecayed = false; + if (!v0.has_mcParticle()) { // The V0 is combinatorial background + coneFakePt[i] += v0.pt(); + nFakeV0sinCone[i]++; + registry.fill(HIST("mcd/PC/jetPtEtaFakeV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); - // This should not happen. They should have been matched - if (posMom == negMom) { - registry.fill(HIST("matching/V0/nonedecayedFakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - return; - } + registry.fill(HIST("mcd/PC/fakeV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("mcd/PC/fakeV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("mcd/PC/fakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("mcd/PC/fakeV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("mcd/PC/fakeV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("mcd/PC/fakeV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + } else { + coneMatchedPt[i] += v0.pt(); + nMatchedV0sinCone[i]++; + registry.fill(HIST("mcd/PC/jetPtEtaMatchedV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); - if (posMom.has_mothers()) { - auto posGrandMom = posMom.template mothers_first_as(); - if (posGrandMom == negMom) { - posDecayed = true; - } - } - if (negMom.has_mothers()) { - auto negGrandMom = negMom.template mothers_first_as(); - if (negGrandMom == posMom) { - negDecayed = true; - } - } + registry.fill(HIST("mcd/PC/matchedV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("mcd/PC/matchedV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("mcd/PC/matchedV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("mcd/PC/matchedV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("mcd/PC/matchedV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("mcd/PC/matchedV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - // This shouldn't happen - if (posDecayed && negDecayed) { - registry.fill(HIST("matching/V0/doubledecayedFakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - return; - } - if (posDecayed || negDecayed) { - double pt = posDecayed ? negMom.pt() : posMom.pt(); - int pdg = posDecayed ? negMom.pdgCode() : posMom.pdgCode(); + auto particle = v0.template mcParticle_as(); + if (std::abs(particle.pdgCode()) == PDG_t::kK0Short) { // K0S + registry.fill(HIST("mcd/PC/matchedJetPtK0SPtMass"), mcdjet.pt(), v0.pt(), v0.mK0Short(), weight); + } else if (particle.pdgCode() == PDG_t::kLambda0) { // Lambda + registry.fill(HIST("mcd/PC/matchedJetPtLambdaPtMass"), mcdjet.pt(), v0.pt(), v0.mLambda(), weight); + } else if (particle.pdgCode() == PDG_t::kLambda0Bar) { + registry.fill(HIST("mcd/PC/matchedJetPtAntiLambdaPtMass"), mcdjet.pt(), v0.pt(), v0.mAntiLambda(), weight); + } + } // if v0 has mcParticle + } // for cone + } // for v0s + for (int i = 0; i < nCones; i++) { + registry.fill(HIST("mcd/PC/matchednV0sConePtEta"), nMatchedV0sinCone[i], coneMatchedPt[i], mcdjet.eta(), weight); + registry.fill(HIST("mcd/PC/matchedConePtEtaPhi"), coneMatchedPt[i], mcdjet.eta(), conePhi[i], weight); + registry.fill(HIST("mcd/PC/matchedJetPtEtaConePt"), mcdjet.pt(), mcdjet.eta(), coneMatchedPt[i], weight); - if (TMath::Abs(pdg) == 310) { - registry.fill(HIST("matching/V0/decayedK0SV0PtMass"), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } else if (pdg == 3122) { - registry.fill(HIST("matching/V0/decayedLambdaV0PtMass"), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } else if (pdg == -3122) { - registry.fill(HIST("matching/V0/decayedAntiLambdaV0PtMass"), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } else { - registry.fill(HIST("matching/V0/decayedOtherPtV0PtMass"), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } + registry.fill(HIST("mcd/PC/fakenV0sConePtEta"), nFakeV0sinCone[i], coneFakePt[i], mcdjet.eta(), weight); + registry.fill(HIST("mcd/PC/fakeConePtEtaPhi"), coneFakePt[i], mcdjet.eta(), conePhi[i], weight); + registry.fill(HIST("mcd/PC/fakeJetPtEtaConePt"), mcdjet.pt(), mcdjet.eta(), coneFakePt[i], weight); } } - // Check if V0 was missed because daughter decayed + // Reconstructed V0s in the cone of matched jets template - void fillMatchingV0DecayedHistograms(V const& partJet, W const& detJet, X const& v0, double weight = 1.) + void fillMcPerpConeHists(T const& coll, U const& mcdjet, V const& mcpjet, W const& v0s, X const& /* V0 particles */, double weight = 1.) { - // Check if decayed daughter - auto posTrack = v0.template posTrack_as(); - auto negTrack = v0.template negTrack_as(); - - auto posPart = posTrack.template mcParticle_as(); - auto negPart = negTrack.template mcParticle_as(); - - auto posMom = posPart.template mothers_first_as(); - auto negMom = negPart.template mothers_first_as(); + const int nCones = 2; + double perpConeR = mcdjet.r() * 1e-2; + double conePhi[nCones] = {RecoDecay::constrainAngle(mcdjet.phi() - constants::math::PIHalf, -constants::math::PI), + RecoDecay::constrainAngle(mcdjet.phi() + constants::math::PIHalf, -constants::math::PI)}; + double coneMatchedPt[nCones] = {0., 0.}; + double coneFakePt[nCones] = {0., 0.}; + int nMatchedV0sinCone[nCones] = {0, 0}; + int nFakeV0sinCone[nCones] = {0, 0}; - bool posDecayed = false; - bool negDecayed = false; + for (const auto& v0 : v0s) { + double dEta = v0.eta() - mcdjet.eta(); + double dPhi[nCones] = {RecoDecay::constrainAngle(v0.phi() - conePhi[0], -constants::math::PI), + RecoDecay::constrainAngle(v0.phi() - conePhi[1], -constants::math::PI)}; + for (int i = 0; i < nCones; i++) { + if (std::sqrt(dEta * dEta + dPhi[i] * dPhi[i]) > perpConeR) { + continue; + } - double zv0 = TrackProj(detJet, v0); + double ctauLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassK0Short; - // This should not happen. They should have been matched - if (posMom == negMom) { - registry.fill(HIST("matching/jets/V0/nonedecayedFakeV0PtMass"), partJet.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/nonedecayedFakeV0TrackProjMass"), partJet.pt(), detJet.pt(), zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - return; - } + if (!v0.has_mcParticle()) { // The V0 is combinatorial background + coneFakePt[i] += v0.pt(); + nFakeV0sinCone[i]++; + registry.fill(HIST("matching/PC/jetPtEtaFakeV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); + registry.fill(HIST("matching/PC/jetsPtFakeV0Pt"), mcpjet.pt(), mcdjet.pt(), v0.pt(), weight); - if (posMom.has_mothers()) { - auto posGrandMom = posMom.template mothers_first_as(); - if (posGrandMom == negMom) { - posDecayed = true; - } - } - if (negMom.has_mothers()) { - auto negGrandMom = negMom.template mothers_first_as(); - if (negGrandMom == posMom) { - negDecayed = true; - } - } + registry.fill(HIST("matching/PC/fakeV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/PC/fakeV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/PC/fakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/PC/fakeV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/PC/fakeV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/PC/fakeV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + } else { + coneMatchedPt[i] += v0.pt(); + nMatchedV0sinCone[i]++; + registry.fill(HIST("matching/PC/jetPtEtaMatchedV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); + registry.fill(HIST("matching/PC/jetsPtMatchedV0Pt"), mcpjet.pt(), mcdjet.pt(), v0.pt(), weight); - // This shouldn't happen - if (posDecayed && negDecayed) { - registry.fill(HIST("matching/jets/V0/doubledecayedFakeV0PtMass"), partJet.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/doubledecayedFakeV0TrackProjMass"), partJet.pt(), detJet.pt(), zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - return; - } - if (posDecayed || negDecayed) { - double pt = posDecayed ? negMom.pt() : posMom.pt(); - int pdg = posDecayed ? negMom.pdgCode() : posMom.pdgCode(); + registry.fill(HIST("matching/PC/matchedV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/PC/matchedV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/PC/matchedV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/PC/matchedV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/PC/matchedV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/PC/matchedV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - double z = 0.; - bool partIsInJet = false; - for (auto const& part : partJet.template candidates_as()) { - if (posDecayed && (part == negMom)) { - partIsInJet = true; - z = TrackProj(partJet, part); - break; - } - if (negDecayed && (part == posMom)) { - partIsInJet = true; - z = TrackProj(partJet, part); - break; - } - } + auto particle = v0.template mcParticle_as(); + if (std::abs(particle.pdgCode()) == PDG_t::kK0Short) { // K0S + registry.fill(HIST("matching/PC/matchedJetPtK0SPtMass"), mcdjet.pt(), v0.pt(), v0.mK0Short(), weight); + registry.fill(HIST("matching/PC/matchedJetsPtK0SPtMass"), mcpjet.pt(), mcdjet.pt(), v0.pt(), v0.mK0Short(), weight); + } else if (particle.pdgCode() == PDG_t::kLambda0) { // Lambda + registry.fill(HIST("matching/PC/matchedJetPtLambdaPtMass"), mcdjet.pt(), v0.pt(), v0.mLambda(), weight); + registry.fill(HIST("matching/PC/matchedJetsPtLambdaPtMass"), mcpjet.pt(), mcdjet.pt(), v0.pt(), v0.mLambda(), weight); + } else if (particle.pdgCode() == PDG_t::kLambda0Bar) { + registry.fill(HIST("matching/PC/matchedJetPtAntiLambdaPtMass"), mcdjet.pt(), v0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/PC/matchedJetsPtAntiLambdaPtMass"), mcpjet.pt(), mcdjet.pt(), v0.pt(), v0.mAntiLambda(), weight); + } + } // if v0 has mcParticle + } // for cone + } // for v0s + for (int i = 0; i < nCones; i++) { + registry.fill(HIST("matching/PC/matchednV0sConePtEta"), nMatchedV0sinCone[i], coneMatchedPt[i], mcdjet.eta(), weight); + registry.fill(HIST("matching/PC/matchedConePtEtaPhi"), coneMatchedPt[i], mcdjet.eta(), conePhi[i], weight); + registry.fill(HIST("matching/PC/matchedJetPtEtaConePt"), mcdjet.pt(), mcdjet.eta(), coneMatchedPt[i], weight); + registry.fill(HIST("matching/PC/matchedJetsPtEtaConePt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), coneMatchedPt[i], weight); - if (TMath::Abs(pdg) == 310) { - registry.fill(HIST("matching/jets/V0/decayedK0SV0PtMass"), partJet.pt(), detJet.pt(), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - if (partIsInJet) { - registry.fill(HIST("matching/jets/V0/decayedK0SV0TrackProjMass"), partJet.pt(), detJet.pt(), z, zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } - } else if (pdg == 3122) { - registry.fill(HIST("matching/jets/V0/decayedLambdaV0PtMass"), partJet.pt(), detJet.pt(), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - if (partIsInJet) { - registry.fill(HIST("matching/jets/V0/decayedLambdaV0TrackProjMass"), partJet.pt(), detJet.pt(), z, zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } - } else if (pdg == -3122) { - registry.fill(HIST("matching/jets/V0/decayedAntiLambdaV0PtMass"), partJet.pt(), detJet.pt(), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - if (partIsInJet) { - registry.fill(HIST("matching/jets/V0/decayedAntiLambdaV0TrackProjMass"), partJet.pt(), detJet.pt(), z, zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } - } else { - registry.fill(HIST("matching/jets/V0/decayedOtherPtV0PtMass"), partJet.pt(), detJet.pt(), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - if (partIsInJet) { - registry.fill(HIST("matching/jets/V0/decayedOtherPtV0TrackProjMass"), partJet.pt(), detJet.pt(), z, zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } - } + registry.fill(HIST("matching/PC/fakenV0sConePtEta"), nFakeV0sinCone[i], coneFakePt[i], mcdjet.eta(), weight); + registry.fill(HIST("matching/PC/fakeConePtEtaPhi"), coneFakePt[i], mcdjet.eta(), conePhi[i], weight); + registry.fill(HIST("matching/PC/fakeJetPtEtaConePt"), mcdjet.pt(), mcdjet.eta(), coneFakePt[i], weight); + registry.fill(HIST("matching/PC/fakeJetsPtEtaConePt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), coneFakePt[i], weight); } } - template - void fillMatchingFakeV0DauHistograms(U const& v0, double weight = 1.) - { - auto negTrack = v0.template negTrack_as(); - auto posTrack = v0.template posTrack_as(); - registry.fill(HIST("matching/V0/fakeV0PosTrackPtEtaPhi"), posTrack.pt(), posTrack.eta(), posTrack.phi(), weight); - registry.fill(HIST("matching/V0/fakeV0NegTrackPtEtaPhi"), negTrack.pt(), negTrack.eta(), negTrack.phi(), weight); - } - // Reconstructed signal for inclusive V0s - template + // Matched - Counts (or event weights) + template // Reconstructed signal for inclusive V0s void fillMatchingV0Histograms(CollisionType const& collision, V0Type const& v0, particleType const& particle, double weight = 1.) { - double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; + double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassK0Short; registry.fill(HIST("matching/V0/V0PartPtDetPt"), particle.pt(), v0.pt(), weight); registry.fill(HIST("matching/V0/V0PartPtRatioPtRelDiffPt"), particle.pt(), v0.pt() / particle.pt(), (v0.pt() - particle.pt()) / particle.pt(), weight); - if (TMath::Abs(particle.pdgCode()) == 310) { // K0S + if (std::abs(particle.pdgCode()) == PDG_t::kK0Short) { // K0S registry.fill(HIST("matching/V0/K0SPtEtaPhi"), particle.pt(), v0.pt(), v0.eta(), v0.phi(), weight); registry.fill(HIST("matching/V0/K0SPtCtauMass"), particle.pt(), v0.pt(), ctauK0s, v0.mK0Short(), weight); registry.fill(HIST("matching/V0/K0SPtRadiusCosPA"), particle.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); registry.fill(HIST("matching/V0/K0SPtDCAposneg"), particle.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); registry.fill(HIST("matching/V0/K0SPtDCAd"), particle.pt(), v0.pt(), v0.dcaV0daughters(), weight); registry.fill(HIST("matching/V0/K0SPtMass"), particle.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - } else if (particle.pdgCode() == 3122) { // Lambda + } else if (particle.pdgCode() == PDG_t::kLambda0) { // Lambda registry.fill(HIST("matching/V0/LambdaPtEtaPhi"), particle.pt(), v0.pt(), v0.eta(), v0.phi(), weight); registry.fill(HIST("matching/V0/LambdaPtCtauMass"), particle.pt(), v0.pt(), ctauLambda, v0.mLambda(), weight); registry.fill(HIST("matching/V0/LambdaPtRadiusCosPA"), particle.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); @@ -1865,24 +2091,23 @@ struct JetFragmentation { registry.fill(HIST("matching/V0/LambdaPtMass"), particle.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); // Reflection - double reflectedMass = ReflectedMass(v0, true); - registry.fill(HIST("matching/V0/Lambda0Reflection"), particle.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); - } else if (particle.pdgCode() == -3122) { // AntiLambda - registry.fill(HIST("matching/V0/antiLambdaPtEtaPhi"), particle.pt(), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtCtauMass"), particle.pt(), v0.pt(), ctauAntiLambda, v0.mAntiLambda(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtRadiusCosPA"), particle.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtDCAposneg"), particle.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtDCAd"), particle.pt(), v0.pt(), v0.dcaV0daughters(), weight); - registry.fill(HIST("matching/V0/antiLambdaPtMass"), particle.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + double reflectedMass = getReflectedMass(v0, true); + registry.fill(HIST("matching/V0/LambdaReflection"), particle.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); + } else if (particle.pdgCode() == PDG_t::kLambda0Bar) { // AntiLambda + registry.fill(HIST("matching/V0/AntiLambdaPtEtaPhi"), particle.pt(), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/V0/AntiLambdaPtCtauMass"), particle.pt(), v0.pt(), ctauAntiLambda, v0.mAntiLambda(), weight); + registry.fill(HIST("matching/V0/AntiLambdaPtRadiusCosPA"), particle.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/V0/AntiLambdaPtDCAposneg"), particle.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/V0/AntiLambdaPtDCAd"), particle.pt(), v0.pt(), v0.dcaV0daughters(), weight); + registry.fill(HIST("matching/V0/AntiLambdaPtMass"), particle.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); // Reflection - double reflectedMass = ReflectedMass(v0, false); - registry.fill(HIST("matching/V0/antiLambda0Reflection"), particle.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); + double reflectedMass = getReflectedMass(v0, false); + registry.fill(HIST("matching/V0/AntiLambdaReflection"), particle.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); } } - // Reconstructed signal for inclusive V0s: daughters - template - void fillMatchingV0DauHistograms(V0Type const& v0, ParticleType const& /* pv0 */, double weight = 1.) + template // Reconstructed signal for inclusive V0s: daughters + void fillMatchingV0DauHistograms(V0Type const& v0, ParticleType const& pv0, double weight = 1.) { auto negTrack = v0.template negTrack_as(); auto posTrack = v0.template posTrack_as(); @@ -1890,65 +2115,88 @@ struct JetFragmentation { auto posPart = posTrack.template mcParticle_as(); registry.fill(HIST("matching/V0/V0PosPartPtRatioPtRelDiffPt"), posPart.pt(), posTrack.pt() / posPart.pt(), (posTrack.pt() - posPart.pt()) / posPart.pt(), weight); registry.fill(HIST("matching/V0/V0NegPartPtRatioPtRelDiffPt"), negPart.pt(), negTrack.pt() / negPart.pt(), (negTrack.pt() - negPart.pt()) / negPart.pt(), weight); + + if (std::abs(v0.pdgCode()) == PDG_t::kK0Short) { // K0S + registry.fill(HIST("matching/V0/K0SPosNegPtMass"), pv0.pt(), posPart.pt(), negPart.pt(), v0.mK0Short(), weight); + } else if (v0.pdgCode() == PDG_t::kLambda0) { // Lambda + registry.fill(HIST("matching/V0/LambdaPosNegPtMass"), pv0.pt(), posPart.pt(), negPart.pt(), v0.mLambda(), weight); + } else if (v0.pdgCode() == PDG_t::kLambda0Bar) { // AntiLambda + registry.fill(HIST("matching/V0/AntiLambdaPosNegPtMass"), pv0.pt(), posPart.pt(), negPart.pt(), v0.mAntiLambda(), weight); + } } - // Reconstructed signal for in-jet V0s: daughters - template - void fillMatchingV0DauJetHistograms(DetJetType const& detJet, PartJetType const& partJet, V0Type const& v0, ParticleType const& particle, double weight = 1.) + template // Reconstructed jets + void fillMatchingHistogramsJet(DetJet const& detJet, PartJet const& partJet, double weight = 1.) { - auto negTrack = v0.template negTrack_as(); - auto posTrack = v0.template posTrack_as(); - auto negPart = negTrack.template mcParticle_as(); - auto posPart = posTrack.template mcParticle_as(); - registry.fill(HIST("matching/jets/V0/partJetPtDetJetPtPartV0PtPosPtRatioPtRelDiffPt"), partJet.pt(), detJet.pt(), particle.pt(), posPart.pt(), posTrack.pt() / posPart.pt(), (posTrack.pt() - posPart.pt()) / posPart.pt(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtDetJetPtPartV0PtNegPtRatioPtRelDiffPt"), partJet.pt(), detJet.pt(), particle.pt(), negPart.pt(), negTrack.pt() / negPart.pt(), (negTrack.pt() - negPart.pt()) / negPart.pt(), weight); + double deltaEta = detJet.eta() - partJet.eta(); + double deltaPhi = RecoDecay::constrainAngle(detJet.phi() - partJet.phi(), -constants::math::PI); + double dR = jetutilities::deltaR(detJet, partJet); + + registry.fill(HIST("matching/jets/matchDetJetPtEtaPhi"), detJet.pt(), detJet.eta(), detJet.phi(), weight); + registry.fill(HIST("matching/jets/matchPartJetPtEtaPhi"), partJet.pt(), partJet.eta(), partJet.phi(), weight); + registry.fill(HIST("matching/jets/matchPartJetPtEtaPhiMatchDist"), partJet.pt(), partJet.eta(), partJet.phi(), dR, weight); + registry.fill(HIST("matching/jets/matchPartJetPtEnergyScale"), partJet.pt(), detJet.pt() / partJet.pt(), weight); + registry.fill(HIST("matching/jets/matchDetJetPtPartJetPt"), detJet.pt(), partJet.pt(), weight); + registry.fill(HIST("matching/jets/matchPartJetPtDetJetEtaPartJetEta"), partJet.pt(), detJet.eta(), partJet.eta(), weight); + registry.fill(HIST("matching/jets/matchPartJetPtDetJetPhiPartJetPhi"), partJet.pt(), detJet.phi(), partJet.phi(), weight); + registry.fill(HIST("matching/jets/matchPartJetPtResolutionPt"), partJet.pt(), (detJet.pt() - partJet.pt()), weight); + registry.fill(HIST("matching/jets/matchPartJetPtResolutionEta"), partJet.pt(), partJet.eta(), deltaEta, weight); + registry.fill(HIST("matching/jets/matchPartJetPtResolutionPhi"), partJet.pt(), partJet.phi(), deltaPhi, weight); + registry.fill(HIST("matching/jets/matchPartJetPtRelDiffPt"), partJet.pt(), (detJet.pt() - partJet.pt()) / partJet.pt(), weight); } - // Reconstructed signal for in-jet V0s - template + template // Reconstructed signal for in-jet V0s void fillMatchingV0FragHistograms(CollisionType const& collision, DetJetType const& detJet, PartJetType const& partJet, V0Type const& v0, ParticleType const& particle, double weight = 1.) { - double detTrackProj = TrackProj(detJet, v0); - double partTrackProj = TrackProj(partJet, particle); + bool correctCollision = (collision.mcCollisionId() == particle.mcCollisionId()); + double detTrackProj = getMomFrac(detJet, v0); + double partTrackProj = getMomFrac(partJet, particle); - double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; + double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassK0Short; registry.fill(HIST("matching/jets/V0/matchDetJetPtV0TrackProjPartJetPtV0TrackProj"), detJet.pt(), detTrackProj, partJet.pt(), partTrackProj, weight); registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0Pt"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetPt"), partJet.pt(), particle.pt(), detJet.pt(), weight); registry.fill(HIST("matching/jets/V0/partJetPtDetJetPtPartV0PtRatioPtRelDiffPt"), partJet.pt(), detJet.pt(), particle.pt(), v0.pt() / particle.pt(), (v0.pt() - particle.pt()) / particle.pt(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauAntiLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauAntiLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauAntiLambda, weight); registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCtauK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauK0s, weight); - registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassAntiLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassAntiLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mAntiLambda(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtMassK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtRadius"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0radius(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtCosPA"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0cosPA(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtDCAposneg"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0PtDetJetPtV0PtDCAd"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauAntiLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauAntiLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauAntiLambda, weight); registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCtauK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauK0s, weight); - registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassAntiLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassAntiLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mAntiLambda(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjMassK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjRadius"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0radius(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjCosPA"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0cosPA(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjDCAposneg"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); registry.fill(HIST("matching/jets/V0/partJetPtV0TrackProjDetJetPtV0TrackProjDCAd"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcaV0daughters(), weight); - if (TMath::Abs(particle.pdgCode()) == 310) { // K0S - registry.fill(HIST("matching/jets/V0/matchDetJetPtK0STrackProjPartJetPtK0STrackProj"), detJet.pt(), detTrackProj, partJet.pt(), partTrackProj, weight); + if (std::abs(particle.pdgCode()) == PDG_t::kK0Short) { // K0S registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPt"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProj"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, weight); + if (correctCollision) { + registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtRightCollision"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjRightCollision"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, weight); + } else { + registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtWrongCollision"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjWrongCollision"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, weight); + } - registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauAntiLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauAntiLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauAntiLambda, weight); registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtCtauK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauK0s, weight); - registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassAntiLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassAntiLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mAntiLambda(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtMassK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtAllMasses"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtRadius"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0radius(), weight); @@ -1956,886 +2204,554 @@ struct JetFragmentation { registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtDCAposneg"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPtDCAd"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauAntiLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauAntiLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauAntiLambda, weight); registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCtauK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauK0s, weight); - registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassAntiLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassAntiLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mAntiLambda(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjMassK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjAllMasses"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjRadius"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0radius(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjCosPA"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0cosPA(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjDCAposneg"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); registry.fill(HIST("matching/jets/V0/partJetPtK0STrackProjDetJetPtK0STrackProjDCAd"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcaV0daughters(), weight); - } else if (particle.pdgCode() == 3122) { // Lambda - registry.fill(HIST("matching/jets/V0/matchDetJetPtLambda0TrackProjPartJetPtLambda0TrackProj"), detJet.pt(), detTrackProj, partJet.pt(), partTrackProj, weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0Pt"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); - - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtCtauLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtCtauAntiLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtCtauK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauK0s, weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtMassLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtMassAntiLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtMassK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtAllMasses"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtRadius"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0radius(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtCosPA"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtDCAposneg"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtDCAd"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjCtauLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjCtauAntiLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjCtauK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauK0s, weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjMassLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjMassAntiLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjMassK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjAllMasses"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjRadius"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0radius(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjCosPA"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjDCAposneg"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjDCAd"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcaV0daughters(), weight); + } else if (particle.pdgCode() == PDG_t::kLambda0) { // Lambda + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPt"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProj"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, weight); + if (correctCollision) { + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtRightCollision"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjRightCollision"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, weight); + } else { + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtWrongCollision"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjWrongCollision"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, weight); + } + + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtCtauLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtCtauAntiLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtCtauK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauK0s, weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtMassLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtMassAntiLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtMassK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtAllMasses"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtRadius"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0radius(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtCosPA"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtDCAposneg"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtDCAd"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjCtauLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjCtauAntiLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjCtauK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauK0s, weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjMassLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjMassAntiLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjMassK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjAllMasses"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjRadius"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0radius(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjCosPA"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjDCAposneg"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjDCAd"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcaV0daughters(), weight); // Reflection - double reflectedMass = ReflectedMass(v0, true); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0PtDetJetPtLambda0PtLambda0Reflection"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); - registry.fill(HIST("matching/jets/V0/partJetPtLambda0TrackProjDetJetPtLambda0TrackProjLambda0Reflection"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); - } else if (particle.pdgCode() == -3122) { // AntiLambda - registry.fill(HIST("matching/jets/V0/matchDetJetPtAntiLambda0TrackProjPartJetPtAntiLambda0TrackProj"), detJet.pt(), detTrackProj, partJet.pt(), partTrackProj, weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0Pt"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); - - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtCtauLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtCtauAntiLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtCtauK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauK0s, weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtMassLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtMassAntiLambda0"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtMassK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtAllMasses"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtRadius"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0radius(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtCosPA"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtDCAposneg"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtDCAd"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjCtauLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjCtauAntiLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauAntiLambda, weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjCtauK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauK0s, weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjMassLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjMassAntiLambda0"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjMassK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjAllMasses"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjRadius"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0radius(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjCosPA"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0cosPA(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjDCAposneg"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjDCAd"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcaV0daughters(), weight); + double reflectedMass = getReflectedMass(v0, true); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaPtDetJetPtLambdaPtLambdaReflection"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); + registry.fill(HIST("matching/jets/V0/partJetPtLambdaTrackProjDetJetPtLambdaTrackProjLambdaReflection"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); + } else if (particle.pdgCode() == PDG_t::kLambda0Bar) { // AntiLambda + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPt"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProj"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, weight); + if (correctCollision) { + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtRightCollision"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjRightCollision"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, weight); + } else { + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtWrongCollision"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjWrongCollision"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, weight); + } + + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtCtauLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtCtauAntiLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtCtauK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), ctauK0s, weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtMassLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtMassAntiLambda"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtMassK0S"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtAllMasses"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtRadius"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0radius(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtCosPA"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtDCAposneg"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtDCAd"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjCtauLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjCtauAntiLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjCtauK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, ctauK0s, weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjMassLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjMassAntiLambda"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjMassK0S"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjAllMasses"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjRadius"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0radius(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjCosPA"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjDCAposneg"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjDCAd"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.dcaV0daughters(), weight); // Reflection - double reflectedMass = ReflectedMass(v0, false); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0PtDetJetPtAntiLambda0PtAntiLambda0Reflection"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); - registry.fill(HIST("matching/jets/V0/partJetPtAntiLambda0TrackProjDetJetPtAntiLambda0TrackProjAntiLambda0Reflection"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); + double reflectedMass = getReflectedMass(v0, false); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaPtDetJetPtAntiLambdaPtAntiLambdaReflection"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); + registry.fill(HIST("matching/jets/V0/partJetPtAntiLambdaTrackProjDetJetPtAntiLambdaTrackProjAntiLambdaReflection"), partJet.pt(), partTrackProj, detJet.pt(), detTrackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), reflectedMass, weight); } // AntiLambda } - - template - void fillMCDJetHistograms(T const& jet, double weight = 1.) + template // Reconstructed signal for in-jet V0s: daughters + void fillMatchingV0DauJetHistograms(DetJetType const& detJet, PartJetType const& partJet, V0Type const& v0, ParticleType const& particle, double weight = 1.) { - registry.fill(HIST("detector-level/jets/detJetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi(), weight); + auto negTrack = v0.template negTrack_as(); + auto posTrack = v0.template posTrack_as(); + auto negPart = negTrack.template mcParticle_as(); + auto posPart = posTrack.template mcParticle_as(); + registry.fill(HIST("matching/jets/V0/partJetPtDetJetPtPartV0PtPosPtRatioPtRelDiffPt"), partJet.pt(), detJet.pt(), particle.pt(), posPart.pt(), posTrack.pt() / posPart.pt(), (posTrack.pt() - posPart.pt()) / posPart.pt(), weight); + registry.fill(HIST("matching/jets/V0/partJetPtDetJetPtPartV0PtNegPtRatioPtRelDiffPt"), partJet.pt(), detJet.pt(), particle.pt(), negPart.pt(), negTrack.pt() / negPart.pt(), (negTrack.pt() - negPart.pt()) / negPart.pt(), weight); } - template // Not used for V0 jets - void fillMCDFragHistograms(Jet const& jet, double weight = 1.) + // Misses - Counts (or event weights) + template // Missed inclusive V0s + void fillMatchingMissV0Histograms(T const& pv0, double weight = 1.) { - for (const auto& track : jet.template tracks_as()) { - double chargeFrag = -1., trackProj = -1., theta = -1., xi = -1.; - chargeFrag = ChargeFrag(jet, track); - trackProj = TrackProj(jet, track); - theta = Theta(jet, track); - xi = Xi(jet, track); - - registry.fill(HIST("detector-level/jets/detJetPtTrackPt"), jet.pt(), track.pt(), weight); - registry.fill(HIST("detector-level/jets/detJetTrackPtEtaPhi"), track.pt(), track.eta(), track.phi(), weight); - registry.fill(HIST("detector-level/jets/detJetPtFrag"), jet.pt(), chargeFrag, weight); - registry.fill(HIST("detector-level/jets/detJetPtTrackProj"), jet.pt(), trackProj, weight); - registry.fill(HIST("detector-level/jets/detJetPtXi"), jet.pt(), xi, weight); - registry.fill(HIST("detector-level/jets/detJetPtTheta"), jet.pt(), theta, weight); - registry.fill(HIST("detector-level/jets/detJetPtXiTheta"), jet.pt(), xi, theta, weight); - registry.fill(HIST("detector-level/jets/detJetPtZTheta"), jet.pt(), trackProj, theta, weight); + int pdg = pv0.pdgCode(); + registry.fill(HIST("matching/V0/missV0PtEtaPhi"), pv0.pt(), pv0.eta(), pv0.phi(), weight); + if (std::abs(pdg) == PDG_t::kK0Short) { // K0S + registry.fill(HIST("matching/V0/missK0SPtEtaPhi"), pv0.pt(), pv0.eta(), pv0.phi(), weight); + } else if (pdg == PDG_t::kLambda0) { // Lambda + registry.fill(HIST("matching/V0/missLambdaPtEtaPhi"), pv0.pt(), pv0.eta(), pv0.phi(), weight); + } else if (pdg == PDG_t::kLambda0Bar) { // AntiLambda + registry.fill(HIST("matching/V0/missAntiLambdaPtEtaPhi"), pv0.pt(), pv0.eta(), pv0.phi(), weight); } } - - template - void fillMCPJetHistograms(T const& jet, double weight = 1.) + template // Missed V0s in jets + void fillMatchingV0Miss(JetType const& jet, V0Type const& v0, double weight = 1.) { - registry.fill(HIST("particle-level/jets/partJetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi(), weight); + double trackProj = getMomFrac(jet, v0); + + registry.fill(HIST("matching/jets/V0/missJetPtV0TrackProj"), jet.pt(), trackProj, weight); + registry.fill(HIST("matching/jets/V0/missJetPtV0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); + if (std::abs(v0.pdgCode()) == PDG_t::kK0Short) { // K0S + registry.fill(HIST("matching/jets/V0/missJetPtK0SPtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/jets/V0/missJetPtK0STrackProj"), jet.pt(), trackProj, weight); + } else if (v0.pdgCode() == PDG_t::kLambda0) { // Lambda + registry.fill(HIST("matching/jets/V0/missJetPtLambdaPtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/jets/V0/missJetPtLambdaTrackProj"), jet.pt(), trackProj, weight); + } else if (v0.pdgCode() == PDG_t::kLambda0Bar) { // AntiLambda + registry.fill(HIST("matching/jets/V0/missJetPtAntiLambdaPtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/jets/V0/missJetPtAntiLambdaTrackProj"), jet.pt(), trackProj, weight); + } } - template // Not used for V0 jets - void fillMCPFragHistograms(Jet const& jet, double weight = 1.) + // Fakes - Counts (or event weights) + template // Fake inclusive V0s + void fillMatchingV0FakeHistograms(T const& coll, U const& v0, double weight = 1.) { - for (const auto& track : jet.template tracks_as()) { - double chargeFrag = -1., trackProj = -1., theta = -1., xi = -1.; - chargeFrag = ChargeFrag(jet, track); - trackProj = TrackProj(jet, track); - theta = Theta(jet, track); - xi = Xi(jet, track); - - registry.fill(HIST("particle-level/jets/partJetPtTrackPt"), jet.pt(), track.pt(), weight); - registry.fill(HIST("particle-level/jets/partJetTrackPtEtaPhi"), track.pt(), track.eta(), track.phi(), weight); - registry.fill(HIST("particle-level/jets/partJetPtFrag"), jet.pt(), chargeFrag, weight); - registry.fill(HIST("particle-level/jets/partJetPtTrackProj"), jet.pt(), trackProj, weight); - registry.fill(HIST("particle-level/jets/partJetPtXi"), jet.pt(), xi, weight); - registry.fill(HIST("particle-level/jets/partJetPtTheta"), jet.pt(), theta, weight); - registry.fill(HIST("particle-level/jets/partJetPtXiTheta"), jet.pt(), xi, theta, weight); - registry.fill(HIST("particle-level/jets/partJetPtZTheta"), jet.pt(), trackProj, theta, weight); + double ctauLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * constants::physics::MassK0Short; + + double massDiff = v0.mLambda() - v0.mAntiLambda(); + double massRatio = v0.mAntiLambda() / v0.mLambda(); + double massRelDiff = (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(); + + registry.fill(HIST("matching/V0/fakeV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/V0/fakeV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/V0/fakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/V0/fakeV0PtLambdaMasses"), v0.pt(), v0.mLambda() - v0.mAntiLambda(), v0.mAntiLambda() / v0.mLambda(), (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(), weight); + registry.fill(HIST("matching/V0/fakeV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/V0/fakeV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/V0/fakeV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + + if (v0.isK0SCandidate()) { + registry.fill(HIST("matching/V0/fakeK0SPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/V0/fakeK0SPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/V0/fakeK0SPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/V0/fakeK0SPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("matching/V0/fakeK0SPtCtauMass"), v0.pt(), ctauK0s, v0.mK0Short(), weight); + registry.fill(HIST("matching/V0/fakeK0SPtRadiusMass"), v0.pt(), v0.v0radius(), v0.mK0Short(), weight); + registry.fill(HIST("matching/V0/fakeK0SPtCosPAMass"), v0.pt(), v0.v0cosPA(), v0.mK0Short(), weight); + registry.fill(HIST("matching/V0/fakeK0SPtDCAposMass"), v0.pt(), v0.dcapostopv(), v0.mK0Short(), weight); + registry.fill(HIST("matching/V0/fakeK0SPtDCAnegMass"), v0.pt(), v0.dcanegtopv(), v0.mK0Short(), weight); + registry.fill(HIST("matching/V0/fakeK0SPtDCAdMass"), v0.pt(), v0.dcaV0daughters(), v0.mK0Short(), weight); + } + if (v0.isLambdaCandidate()) { + registry.fill(HIST("matching/V0/fakeLambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/V0/fakeLambdaPtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/V0/fakeLambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/V0/fakeLambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/V0/fakeLambdaPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("matching/V0/fakeLambdaPtCtauMass"), v0.pt(), ctauLambda, v0.mLambda(), weight); + registry.fill(HIST("matching/V0/fakeLambdaPtRadiusMass"), v0.pt(), v0.v0radius(), v0.mLambda(), weight); + registry.fill(HIST("matching/V0/fakeLambdaPtCosPAMass"), v0.pt(), v0.v0cosPA(), v0.mLambda(), weight); + registry.fill(HIST("matching/V0/fakeLambdaPtDCAposMass"), v0.pt(), v0.dcapostopv(), v0.mLambda(), weight); + registry.fill(HIST("matching/V0/fakeLambdaPtDCAnegMass"), v0.pt(), v0.dcanegtopv(), v0.mLambda(), weight); + registry.fill(HIST("matching/V0/fakeLambdaPtDCAdMass"), v0.pt(), v0.dcaV0daughters(), v0.mLambda(), weight); + } + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("matching/V0/fakeAntiLambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPtLambdaMasses"), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("matching/V0/fakeAntiLambdaPtCtauMass"), v0.pt(), ctauAntiLambda, v0.mAntiLambda(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPtRadiusMass"), v0.pt(), v0.v0radius(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPtCosPAMass"), v0.pt(), v0.v0cosPA(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPtDCAposMass"), v0.pt(), v0.dcapostopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPtDCAnegMass"), v0.pt(), v0.dcanegtopv(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPtDCAdMass"), v0.pt(), v0.dcaV0daughters(), v0.mAntiLambda(), weight); } } - - template - void fillDataPerpConeHists(T const& coll, U const& jet, V const& v0s, double weight = 1.) + template // Fake inclusive V0s daughters + void fillMatchingFakeV0DauHistograms(U const& v0, double weight = 1.) { - double perpConeR = jet.r() * 1e-2; - double conePhi[2] = {RecoDecay::constrainAngle(jet.phi() - M_PI / 2, -M_PI), - RecoDecay::constrainAngle(jet.phi() + M_PI / 2, -M_PI)}; - double conePt[2] = {0., 0.}; - int nV0sinCone[2] = {0, 0}; - for (const auto& v0 : v0s) { - // Need to check if v0 passed jet finder selection/preselector cuts - bool v0InCones = false; - double dEta = v0.eta() - jet.eta(); - double dPhi[2] = {RecoDecay::constrainAngle(v0.phi() - conePhi[0], -M_PI), - RecoDecay::constrainAngle(v0.phi() - conePhi[1], -M_PI)}; - for (int i = 0; i < 2; i++) { - if (TMath::Sqrt(dEta * dEta + dPhi[i] * dPhi[i]) < perpConeR) { - conePt[i] += v0.pt(); - nV0sinCone[i]++; - v0InCones = true; - } - } - if (!v0InCones) { - continue; - } + auto negTrack = v0.template negTrack_as(); + auto posTrack = v0.template posTrack_as(); + registry.fill(HIST("matching/V0/fakeV0PosTrackPtEtaPhi"), posTrack.pt(), posTrack.eta(), posTrack.phi(), weight); + registry.fill(HIST("matching/V0/fakeV0NegTrackPtEtaPhi"), negTrack.pt(), negTrack.eta(), negTrack.phi(), weight); - double ctauLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassK0Short; - - registry.fill(HIST("data/PC/JetPtEtaV0Pt"), jet.pt(), jet.eta(), v0.pt(), weight); - registry.fill(HIST("data/PC/V0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("data/PC/V0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("data/PC/V0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/PC/V0PtMassWide"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("data/PC/V0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/PC/V0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/PC/V0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - - if (IsLambdaCandidate(coll, v0)) { - registry.fill(HIST("data/PC/JetPtLambda0PtMass"), jet.pt(), v0.pt(), v0.mLambda(), weight); - - registry.fill(HIST("data/PC/JetPtEtaLambda0Pt"), jet.pt(), jet.eta(), v0.pt(), weight); - registry.fill(HIST("data/PC/LambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("data/PC/LambdaPtCtauMass"), v0.pt(), ctauLambda, v0.mLambda(), weight); - registry.fill(HIST("data/PC/LambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/PC/LambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/PC/LambdaPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - } - if (IsAntiLambdaCandidate(coll, v0)) { - registry.fill(HIST("data/PC/JetPtAntiLambda0PtMass"), jet.pt(), v0.pt(), v0.mAntiLambda(), weight); - - registry.fill(HIST("data/PC/JetPtEtaAntiLambda0Pt"), jet.pt(), jet.eta(), v0.pt(), weight); - registry.fill(HIST("data/PC/antiLambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("data/PC/antiLambdaPtCtauMass"), v0.pt(), ctauAntiLambda, v0.mAntiLambda(), weight); - registry.fill(HIST("data/PC/antiLambdaPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/PC/antiLambdaPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/PC/antiLambdaPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - } - if (IsK0SCandidate(coll, v0)) { - registry.fill(HIST("data/PC/JetPtK0SPtMass"), jet.pt(), v0.pt(), v0.mK0Short(), weight); - - registry.fill(HIST("data/PC/JetPtEtaK0SPt"), jet.pt(), jet.eta(), v0.pt(), weight); - registry.fill(HIST("data/PC/K0SPtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("data/PC/K0SPtCtauMass"), v0.pt(), ctauK0s, v0.mK0Short(), weight); - registry.fill(HIST("data/PC/K0SPtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("data/PC/K0SPtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("data/PC/K0SPtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - } + if (v0.isK0SCandidate()) { + registry.fill(HIST("matching/V0/fakeK0SPosTrackPtEtaPhi"), posTrack.pt(), posTrack.eta(), posTrack.phi(), weight); + registry.fill(HIST("matching/V0/fakeK0SPosTrackPtMass"), v0.pt(), posTrack.pt(), v0.mK0Short(), weight); + registry.fill(HIST("matching/V0/fakeK0SNegTrackPtEtaPhi"), negTrack.pt(), negTrack.eta(), negTrack.phi(), weight); + registry.fill(HIST("matching/V0/fakeK0SNegTrackPtMass"), v0.pt(), negTrack.pt(), v0.mK0Short(), weight); + } + if (v0.isLambdaCandidate()) { + registry.fill(HIST("matching/V0/fakeLambdaPosTrackPtEtaPhi"), posTrack.pt(), posTrack.eta(), posTrack.phi(), weight); + registry.fill(HIST("matching/V0/fakeLambdaPosTrackPtMass"), v0.pt(), posTrack.pt(), v0.mLambda(), weight); + registry.fill(HIST("matching/V0/fakeLambdaNegTrackPtEtaPhi"), negTrack.pt(), negTrack.eta(), negTrack.phi(), weight); + registry.fill(HIST("matching/V0/fakeLambdaNegTrackPtMass"), v0.pt(), negTrack.pt(), v0.mLambda(), weight); } - // Fill hist for Ncones: nv0s, conePt, coneEta, conePhi - for (int i = 0; i < 2; i++) { - registry.fill(HIST("data/PC/nV0sConePtEta"), nV0sinCone[i], conePt[i], jet.eta(), weight); - registry.fill(HIST("data/PC/ConePtEtaPhi"), conePt[i], jet.eta(), conePhi[i], weight); - registry.fill(HIST("data/PC/JetPtEtaConePt"), jet.pt(), jet.eta(), conePt[i], weight); + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("matching/V0/fakeAntiLambdaPosTrackPtEtaPhi"), posTrack.pt(), posTrack.eta(), posTrack.phi(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaPosTrackPtMass"), v0.pt(), posTrack.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaNegTrackPtEtaPhi"), negTrack.pt(), negTrack.eta(), negTrack.phi(), weight); + registry.fill(HIST("matching/V0/fakeAntiLambdaNegTrackPtMass"), v0.pt(), negTrack.pt(), v0.mAntiLambda(), weight); } } - - // Version for MCD jets - template - void fillMcPerpConeHists(T const& coll, U const& mcdjet, V const& v0s, W const& /* V0 particles */, double weight = 1.) + template // Check if inclusive V0 was missed because daughter decayed + void fillMatchingV0DecayedHistograms(V const& v0, double weight = 1.) { - double perpConeR = mcdjet.r() * 1e-2; - double conePhi[2] = {RecoDecay::constrainAngle(mcdjet.phi() - M_PI / 2, -M_PI), - RecoDecay::constrainAngle(mcdjet.phi() + M_PI / 2, -M_PI)}; - double coneMatchedPt[2] = {0., 0.}; - double coneFakePt[2] = {0., 0.}; - int nMatchedV0sinCone[2] = {0, 0}; - int nFakeV0sinCone[2] = {0, 0}; + // Check if decayed daughter + auto posTrack = v0.template posTrack_as(); + auto negTrack = v0.template negTrack_as(); - for (const auto& v0 : v0s) { - double dEta = v0.eta() - mcdjet.eta(); - double dPhi[2] = {RecoDecay::constrainAngle(v0.phi() - conePhi[0], -M_PI), - RecoDecay::constrainAngle(v0.phi() - conePhi[1], -M_PI)}; - for (int i = 0; i < 2; i++) { - if (TMath::Sqrt(dEta * dEta + dPhi[i] * dPhi[i]) > perpConeR) { - continue; - } + auto posPart = posTrack.template mcParticle_as(); + auto negPart = negTrack.template mcParticle_as(); - double ctauLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassK0Short; + auto posMom = posPart.template mothers_first_as(); + auto negMom = negPart.template mothers_first_as(); - if (!v0.has_mcParticle()) { // The V0 is combinatorial background - coneFakePt[i] += v0.pt(); - nFakeV0sinCone[i]++; - registry.fill(HIST("mcd/PC/jetPtEtaFakeV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); + bool posDecayed = false; + bool negDecayed = false; - registry.fill(HIST("mcd/PC/fakeV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("mcd/PC/fakeV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("mcd/PC/fakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("mcd/PC/fakeV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("mcd/PC/fakeV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("mcd/PC/fakeV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - } else { - coneMatchedPt[i] += v0.pt(); - nMatchedV0sinCone[i]++; - registry.fill(HIST("mcd/PC/jetPtEtaMatchedV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); + // This should not happen. They should have been matched + if (posMom == negMom) { + registry.fill(HIST("matching/V0/nonedecayedFakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + return; + } - registry.fill(HIST("mcd/PC/matchedV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("mcd/PC/matchedV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("mcd/PC/matchedV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("mcd/PC/matchedV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("mcd/PC/matchedV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("mcd/PC/matchedV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + if (posMom.has_mothers()) { + auto posGrandMom = posMom.template mothers_first_as(); + if (posGrandMom == negMom) { + posDecayed = true; + } + } + if (negMom.has_mothers()) { + auto negGrandMom = negMom.template mothers_first_as(); + if (negGrandMom == posMom) { + negDecayed = true; + } + } - auto particle = v0.template mcParticle_as(); - if (TMath::Abs(particle.pdgCode()) == 310) { // K0S - registry.fill(HIST("mcd/PC/matchedJetPtK0SPtMass"), mcdjet.pt(), v0.pt(), v0.mK0Short(), weight); - } else if (particle.pdgCode() == 3122) { // Lambda - registry.fill(HIST("mcd/PC/matchedJetPtLambda0PtMass"), mcdjet.pt(), v0.pt(), v0.mLambda(), weight); - } else if (particle.pdgCode() == -3122) { - registry.fill(HIST("mcd/PC/matchedJetPtAntiLambda0PtMass"), mcdjet.pt(), v0.pt(), v0.mAntiLambda(), weight); - } - } // if v0 has mcParticle - } // for cone - } // for v0s - for (int i = 0; i < 2; i++) { - registry.fill(HIST("mcd/PC/matchednV0sConePtEta"), nMatchedV0sinCone[i], coneMatchedPt[i], mcdjet.eta(), weight); - registry.fill(HIST("mcd/PC/matchedConePtEtaPhi"), coneMatchedPt[i], mcdjet.eta(), conePhi[i], weight); - registry.fill(HIST("mcd/PC/matchedJetPtEtaConePt"), mcdjet.pt(), mcdjet.eta(), coneMatchedPt[i], weight); + // This shouldn't happen + if (posDecayed && negDecayed) { + registry.fill(HIST("matching/V0/doubledecayedFakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + return; + } + if (posDecayed || negDecayed) { + double pt = posDecayed ? negMom.pt() : posMom.pt(); + int pdg = posDecayed ? negMom.pdgCode() : posMom.pdgCode(); - registry.fill(HIST("mcd/PC/fakenV0sConePtEta"), nFakeV0sinCone[i], coneFakePt[i], mcdjet.eta(), weight); - registry.fill(HIST("mcd/PC/fakeConePtEtaPhi"), coneFakePt[i], mcdjet.eta(), conePhi[i], weight); - registry.fill(HIST("mcd/PC/fakeJetPtEtaConePt"), mcdjet.pt(), mcdjet.eta(), coneFakePt[i], weight); + if (std::abs(pdg) == PDG_t::kK0Short) { + registry.fill(HIST("matching/V0/decayedK0SV0PtMass"), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + } else if (pdg == PDG_t::kLambda0) { + registry.fill(HIST("matching/V0/decayedLambdaV0PtMass"), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + } else if (pdg == PDG_t::kLambda0Bar) { + registry.fill(HIST("matching/V0/decayedAntiLambdaV0PtMass"), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + } else { + registry.fill(HIST("matching/V0/decayedOtherPtV0PtMass"), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + } } } - // Version for matched jets - template - void fillMcPerpConeHists(T const& coll, U const& mcdjet, V const& mcpjet, W const& v0s, X const& /* V0 particles */, double weight = 1.) + template // Fake V0s in jets + void fillMatchingV0JetFakeHistograms(CollisionType const& collision, JetType const& jet, V0Type const& v0, double weight = 1.) { - double perpConeR = mcdjet.r() * 1e-2; - double conePhi[2] = {RecoDecay::constrainAngle(mcdjet.phi() - M_PI / 2, -M_PI), - RecoDecay::constrainAngle(mcdjet.phi() + M_PI / 2, -M_PI)}; - double coneMatchedPt[2] = {0., 0.}; - double coneFakePt[2] = {0., 0.}; - int nMatchedV0sinCone[2] = {0, 0}; - int nFakeV0sinCone[2] = {0, 0}; - - for (const auto& v0 : v0s) { - double dEta = v0.eta() - mcdjet.eta(); - double dPhi[2] = {RecoDecay::constrainAngle(v0.phi() - conePhi[0], -M_PI), - RecoDecay::constrainAngle(v0.phi() - conePhi[1], -M_PI)}; - for (int i = 0; i < 2; i++) { - if (TMath::Sqrt(dEta * dEta + dPhi[i] * dPhi[i]) > perpConeR) { - continue; - } - - double ctauLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0; - double ctauAntiLambda = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0Bar; - double ctauK0s = v0.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassK0Short; - - if (!v0.has_mcParticle()) { // The V0 is combinatorial background - coneFakePt[i] += v0.pt(); - nFakeV0sinCone[i]++; - registry.fill(HIST("matching/PC/jetPtEtaFakeV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); - registry.fill(HIST("matching/PC/jetsPtFakeV0Pt"), mcpjet.pt(), mcdjet.pt(), v0.pt(), weight); - - registry.fill(HIST("matching/PC/fakeV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/PC/fakeV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/PC/fakeV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/PC/fakeV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/PC/fakeV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/PC/fakeV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); - } else { - coneMatchedPt[i] += v0.pt(); - nMatchedV0sinCone[i]++; - registry.fill(HIST("matching/PC/jetPtEtaMatchedV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); - registry.fill(HIST("matching/PC/jetsPtMatchedV0Pt"), mcpjet.pt(), mcdjet.pt(), v0.pt(), weight); - - registry.fill(HIST("matching/PC/matchedV0PtEtaPhi"), v0.pt(), v0.eta(), v0.phi(), weight); - registry.fill(HIST("matching/PC/matchedV0PtCtau"), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); - registry.fill(HIST("matching/PC/matchedV0PtMass"), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/PC/matchedV0PtRadiusCosPA"), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); - registry.fill(HIST("matching/PC/matchedV0PtDCAposneg"), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); - registry.fill(HIST("matching/PC/matchedV0PtDCAd"), v0.pt(), v0.dcaV0daughters(), weight); + double trackProj = getMomFrac(jet, v0); + double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0; + double ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassLambda0Bar; + double ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * constants::physics::MassK0Short; + double massDiff = v0.mLambda() - v0.mAntiLambda(); + double massRatio = v0.mAntiLambda() / v0.mLambda(); + double massRelDiff = (v0.mLambda() - v0.mAntiLambda()) / v0.mLambda(); - auto particle = v0.template mcParticle_as(); - if (TMath::Abs(particle.pdgCode()) == 310) { // K0S - registry.fill(HIST("matching/PC/matchedJetPtK0SPtMass"), mcdjet.pt(), v0.pt(), v0.mK0Short(), weight); - registry.fill(HIST("matching/PC/matchedJetsPtK0SPtMass"), mcpjet.pt(), mcdjet.pt(), v0.pt(), v0.mK0Short(), weight); - } else if (particle.pdgCode() == 3122) { // Lambda - registry.fill(HIST("matching/PC/matchedJetPtLambda0PtMass"), mcdjet.pt(), v0.pt(), v0.mLambda(), weight); - registry.fill(HIST("matching/PC/matchedJetsPtLambda0PtMass"), mcpjet.pt(), mcdjet.pt(), v0.pt(), v0.mLambda(), weight); - } else if (particle.pdgCode() == -3122) { - registry.fill(HIST("matching/PC/matchedJetPtAntiLambda0PtMass"), mcdjet.pt(), v0.pt(), v0.mAntiLambda(), weight); - registry.fill(HIST("matching/PC/matchedJetsPtAntiLambda0PtMass"), mcpjet.pt(), mcdjet.pt(), v0.pt(), v0.mAntiLambda(), weight); - } - } // if v0 has mcParticle - } // for cone - } // for v0s - for (int i = 0; i < 2; i++) { - registry.fill(HIST("matching/PC/matchednV0sConePtEta"), nMatchedV0sinCone[i], coneMatchedPt[i], mcdjet.eta(), weight); - registry.fill(HIST("matching/PC/matchedConePtEtaPhi"), coneMatchedPt[i], mcdjet.eta(), conePhi[i], weight); - registry.fill(HIST("matching/PC/matchedJetPtEtaConePt"), mcdjet.pt(), mcdjet.eta(), coneMatchedPt[i], weight); - registry.fill(HIST("matching/PC/matchedJetsPtEtaConePt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), coneMatchedPt[i], weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProj"), jet.pt(), trackProj, weight); - registry.fill(HIST("matching/PC/fakenV0sConePtEta"), nFakeV0sinCone[i], coneFakePt[i], mcdjet.eta(), weight); - registry.fill(HIST("matching/PC/fakeConePtEtaPhi"), coneFakePt[i], mcdjet.eta(), conePhi[i], weight); - registry.fill(HIST("matching/PC/fakeJetPtEtaConePt"), mcdjet.pt(), mcdjet.eta(), coneFakePt[i], weight); - registry.fill(HIST("matching/PC/fakeJetsPtEtaConePt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), coneFakePt[i], weight); - } - } + registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0PtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - void processDummy(aod::JetTracks const&) {} - PROCESS_SWITCH(JetFragmentation, processDummy, "Dummy process function turned on by default", true); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtV0TrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); - void processMcD(soa::Filtered::iterator const& collision, - aod::JetMcCollisions const&, - MCDJetsWithConstituents const&, - aod::JetTracks const& tracks) - { - if (!collision.has_mcCollision()) { - return; - } - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { - return; - } - double nJets = 0, nTracks = 0; - double weight = collision.mcCollision().weight(); - for (const auto& track : tracks) { - if (track.pt() > 0.1) { - nTracks++; - registry.fill(HIST("detector-level/tracks/detTrackPtEtaPhi"), track.pt(), track.eta(), track.phi(), weight); - } - } - for (const auto& jet : detJetEtaPartition) { - nJets++; - fillMCDJetHistograms(jet, weight); - fillMCDFragHistograms(jet, weight); - } - registry.fill(HIST("detector-level/nJetsnTracks"), nJets, nTracks, weight); - } - PROCESS_SWITCH(JetFragmentation, processMcD, "Monte Carlo detector level", false); + if (v0.isK0SCandidate()) { + registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProj"), jet.pt(), trackProj, weight); - void processMcP(aod::JetMcCollision const& mcCollision, - MCPJetsWithConstituents const& jets, - aod::JetParticles const& particles) - { - double nJets = 0, nTracks = 0; - double weight = mcCollision.weight(); - for (const auto& particle : particles) { - if (particle.pt() > 0.1) { - nTracks++; - registry.fill(HIST("particle-level/tracks/partTrackPtEtaPhi"), particle.pt(), particle.eta(), particle.phi(), weight); - } - } - for (const auto& jet : jets) { - nJets++; - fillMCPJetHistograms(jet, weight); - fillMCPFragHistograms(jet, weight); - } - registry.fill(HIST("particle-level/nJetsnTracks"), nJets, nTracks, weight); - } - PROCESS_SWITCH(JetFragmentation, processMcP, "Monte Carlo particle level", false); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0SPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); - void processDataRun3(soa::Filtered::iterator const& collision, - ChargedJetsWithConstituents const& jets, - aod::JetTracks const& tracks) - { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { - return; - } - double nJets = 0, nTracks = 0; - for (const auto& track : tracks) { - if (track.pt() > 0.1) { - nTracks++; - registry.fill(HIST("data/tracks/trackPtEtaPhi"), track.pt(), track.eta(), track.phi()); - } + registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtK0STrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); } - for (const auto& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, dataJetEtaMin, dataJetEtaMax)) { - continue; - } - nJets++; - fillDataJetHistograms(jet); - fillDataFragHistograms(jet); + if (v0.isLambdaCandidate()) { + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaPtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaTrackProj"), jet.pt(), trackProj, weight); + + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaPtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaPtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaPtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaPtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaTrackProjEtaPhi"), jet.pt(), trackProj, v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaTrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaTrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaTrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaTrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaTrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtLambdaTrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); + } + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaPtEtaPhi"), jet.pt(), v0.pt(), v0.eta(), v0.phi(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaTrackProj"), jet.pt(), trackProj, weight); + + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaPtCtau"), jet.pt(), v0.pt(), ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaPtMass"), jet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaPtLambdaMasses"), jet.pt(), v0.pt(), massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaPtRadiusCosPA"), jet.pt(), v0.pt(), v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaPtDCAposneg"), jet.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaPtDCAd"), jet.pt(), v0.pt(), v0.dcaV0daughters(), weight); + + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaTrackProjCtau"), jet.pt(), trackProj, ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaTrackProjMass"), jet.pt(), trackProj, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaTrackProjLambdaMasses"), jet.pt(), trackProj, massDiff, massRatio, massRelDiff, weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaTrackProjRadiusCosPA"), jet.pt(), trackProj, v0.v0radius(), v0.v0cosPA(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaTrackProjDCAposneg"), jet.pt(), trackProj, v0.dcapostopv(), v0.dcanegtopv(), weight); + registry.fill(HIST("matching/jets/V0/fakeJetPtAntiLambdaTrackProjDCAd"), jet.pt(), trackProj, v0.dcaV0daughters(), weight); } - registry.fill(HIST("data/nJetsnTracks"), nJets, nTracks); - registry.fill(HIST("data/collision/collisionVtxZ"), collision.posZ()); } - PROCESS_SWITCH(JetFragmentation, processDataRun3, "Run 3 Data", false); - - void processMcMatched(soa::Filtered::iterator const& collision, - MatchedMCDJetsWithConstituents const&, - aod::JetTracksMCD const&, - aod::JetMcCollisions const&, - MatchedMCPJetsWithConstituents const& allMcPartJets, - aod::JetParticles const&) + template // Check if V0 in jet was missed because daughter decayed + void fillMatchingV0JetDecayedHistograms(V const& partJet, W const& detJet, X const& v0, double weight = 1.) { - if (!collision.has_mcCollision()) { - return; - } - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + // Check if decayed daughter + auto posTrack = v0.template posTrack_as(); + auto negTrack = v0.template negTrack_as(); + + auto posPart = posTrack.template mcParticle_as(); + auto negPart = negTrack.template mcParticle_as(); + + auto posMom = posPart.template mothers_first_as(); + auto negMom = negPart.template mothers_first_as(); + + bool posDecayed = false; + bool negDecayed = false; + + double zv0 = getMomFrac(detJet, v0); + + // This should not happen. They should have been matched + if (posMom == negMom) { + registry.fill(HIST("matching/jets/V0/nonedecayedFakeV0PtMass"), partJet.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/nonedecayedFakeV0TrackProjMass"), partJet.pt(), detJet.pt(), zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); return; } - double weight = collision.mcCollision().weight(); - const auto& mcPartJets = allMcPartJets.sliceBy(PartJetsPerCollision, collision.mcCollision().globalIndex()); // Only jets from the same collision - bool isFake = false; - for (const auto& detJet : detJetEtaPartition) { - for (auto& partJet : detJet.template matchedJetGeo_as()) { - fillMatchingHistogramsJet(detJet, partJet, weight); - for (const auto& track : detJet.tracks_as()) { - bool isTrackMatched = false; - if (!track.has_mcParticle()) { - isFake = true; - fillMatchingFakeOrMiss(detJet, track, isFake, weight); - continue; - } - for (const auto& particle : partJet.tracks_as()) { - if (particle.globalIndex() == track.template mcParticle_as().globalIndex()) { - isTrackMatched = true; - fillMatchingHistogramsConstituent(detJet, partJet, track, particle, weight); - break; // No need to inspect other particles - } // if track has mcParticle and particle is in matched jet - } // for particle in matched partJet - if (!isTrackMatched) { - isFake = true; - fillMatchingFakeOrMiss(detJet, track, isFake, weight); - } // if track is not matched - } // for detJet tracks + if (posMom.has_mothers()) { + auto posGrandMom = posMom.template mothers_first_as(); + if (posGrandMom == negMom) { + posDecayed = true; } - if (!detJet.has_matchedJetGeo()) { - isFake = true; - registry.fill(HIST("matching/jets/fakeDetJetPtEtaPhi"), detJet.pt(), detJet.eta(), detJet.phi(), weight); - for (const auto& track : detJet.tracks_as()) { - fillMatchingFakeOrMiss(detJet, track, isFake, weight); - } - } // if detJet does not have a match - } // for det jet - for (const auto& partJet : mcPartJets) { - for (const auto& detJet : partJet.template matchedJetGeo_as()) { - // Check if the matched detector level jet is outside the allowed eta range - if ((detJet.eta() <= matchedDetJetEtaMin) || (detJet.eta() >= matchedDetJetEtaMax)) { - for (const auto& particle : partJet.tracks_as()) { - isFake = false; - fillMatchingFakeOrMiss(partJet, particle, isFake, weight); - } - continue; - } - // If the jets are properly matched, we can check the particles - for (const auto& particle : partJet.tracks_as()) { - bool isParticleMatched = false; - for (const auto& track : detJet.tracks_as()) { - if (!track.has_mcParticle()) { - continue; - } - if (particle.globalIndex() == track.template mcParticle_as().globalIndex()) { - isParticleMatched = true; - } - } - // Ignore matched particles. They have been handled in the previous loop - if (!isParticleMatched) { - isFake = false; - fillMatchingFakeOrMiss(partJet, particle, isFake, weight); - } - } // for particle - } // for matched det jet - if (!partJet.has_matchedJetGeo()) { - isFake = false; - registry.fill(HIST("matching/jets/missPartJetPtEtaPhi"), partJet.pt(), partJet.eta(), partJet.phi(), weight); - for (const auto& particle : partJet.tracks_as()) { - fillMatchingFakeOrMiss(partJet, particle, isFake, weight); - } - } // if no matched jet - } // for part jet - } - PROCESS_SWITCH(JetFragmentation, processMcMatched, "Monte Carlo particle and detector level", false); - - // Should take in JCollisions? - void processMcMatchedV0(soa::Filtered>::iterator const& collision, - aod::McCollisions const&, - soa::Join const& V0s, - soa::Join const& tracks, - aod::McParticles const& mcParticles) - { - if (!collision.has_mcCollision()) { - return; } - // if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { - // return; - // } - double weight = collision.mcCollision().weight(); - for (const auto& v0 : V0s) { - if (!v0.has_mcParticle()) { - continue; + if (negMom.has_mothers()) { + auto negGrandMom = negMom.template mothers_first_as(); + if (negGrandMom == posMom) { + negDecayed = true; } - fillMcMatchedV0Histograms(collision, v0, tracks, mcParticles, weight); } - } - PROCESS_SWITCH(JetFragmentation, processMcMatchedV0, "Monte Carlo V0", false); - void processMcMatchedV0Frag(soa::Filtered>::iterator const& jcoll, - MatchedMCDJetsWithConstituents const&, - aod::JetTracksMCD const&, - soa::Join const& allV0s, - aod::JetMcCollisions const&, - MatchedMCPJetsWithConstituents const& allMcPartJets, - aod::JetParticles const&, - aod::McCollisions const&, - aod::McParticles const& allMcParticles, - aod::Collisions const&) - { - if (!jcoll.has_mcCollision()) { - return; - } - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + // This shouldn't happen + if (posDecayed && negDecayed) { + registry.fill(HIST("matching/jets/V0/doubledecayedFakeV0PtMass"), partJet.pt(), detJet.pt(), v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + registry.fill(HIST("matching/jets/V0/doubledecayedFakeV0TrackProjMass"), partJet.pt(), detJet.pt(), zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); return; } - double weight = jcoll.mcCollision().weight(); - // This is necessary, because jets are linked to aod::JetCollisions, but V0s are linked to Collisions - const auto& collision = jcoll.collision_as(); - const auto& v0s = allV0s.sliceBy(V0sPerCollision, collision.globalIndex()); - const auto& mcPartJets = allMcPartJets.sliceBy(PartJetsPerCollision, jcoll.mcCollision().globalIndex()); - const auto& mcParticles = allMcParticles.sliceBy(ParticlesPerCollision, jcoll.mcCollision().globalIndex()); - - int kNV0s = v0s.size(); - bool isV0Used[kNV0s]; - for (int i = 0; i < kNV0s; i++) { - isV0Used[i] = false; - } - registry.fill(HIST("matching/V0/nV0sEvent"), kNV0s); - registry.fill(HIST("matching/V0/nV0sEventWeighted"), kNV0s, weight); - - int kNParticles = mcParticles.size(); - bool isParticleUsed[kNParticles]; - for (int i = 0; i < kNParticles; i++) { - isParticleUsed[i] = false; - } - - for (const auto& detJet : detJetEtaV0Partition) { - int iv0 = -1; - int nV0inJet = 0, nLambdainJet = 0, nAntiLambdainJet = 0, nK0SinJet = 0; + if (posDecayed || negDecayed) { + double pt = posDecayed ? negMom.pt() : posMom.pt(); + int pdg = posDecayed ? negMom.pdgCode() : posMom.pdgCode(); - for (auto& partJet : detJet.template matchedJetGeo_as()) { - fillMatchingHistogramsJet(detJet, partJet, weight); - // Jets are pt-sorted, so we prioritise matching V0s with high pt jets - for (const auto& v0 : v0s) { - iv0++; - if (isV0Used[iv0]) { - continue; - } - double dR = jetutilities::deltaR(detJet, v0); - if (dR >= detJet.r() * 1e-2) { - continue; - } - isV0Used[iv0] = true; - if (!v0.has_mcParticle()) { - fillMatchingV0Fake(collision, detJet, v0, weight); - continue; - } - const auto& particle = v0.template mcParticle_as(); - if (!((TMath::Abs(particle.pdgCode()) == 310) || (TMath::Abs(particle.pdgCode()) == 3122))) { - fillMatchingV0Fake(collision, detJet, v0, weight); - continue; - } - // Found a matched V0 in the jet - nV0inJet++; - fillMatchingV0FragHistograms(collision, detJet, partJet, v0, particle, weight); - if (TMath::Abs(particle.pdgCode()) == 310) { - nK0SinJet++; - } else if (particle.pdgCode() == 3122) { - nLambdainJet++; - } else if (particle.pdgCode() == -3122) { - nAntiLambdainJet++; - } - } // v0 loop - registry.fill(HIST("matching/jets/V0/jetPtnV0Matched"), partJet.pt(), nV0inJet, weight); - registry.fill(HIST("matching/jets/V0/jetPtnV0MatchednK0SnLambdanAntiLambda"), partJet.pt(), nV0inJet, nK0SinJet, nLambdainJet, nAntiLambdainJet, weight); - } // for partJet in matched detJet - iv0 = -1; - if (!detJet.has_matchedJetGeo()) { - for (const auto& v0 : v0s) { - iv0++; - if (isV0Used[iv0]) { - continue; - } - double dR = jetutilities::deltaR(detJet, v0); - if (dR >= detJet.r() * 1e-2) { - continue; - } - isV0Used[iv0] = true; - fillMatchingV0Fake(collision, detJet, v0, weight); - } // v0 loop - } // if no matched jet - } // det jet loop - for (const auto& partJet : mcPartJets) { - int iparticle = -1; - for (const auto& particle : mcParticles) { - iparticle++; - if (isParticleUsed[iparticle]) { - continue; - } - // Check if particle is primary and is a particle of interest that has not been used yet - // If it doesn't pass these selections, set isParticleUsed to true to skip it in the future - if (!particle.isPhysicalPrimary()) { - isParticleUsed[iparticle] = true; - continue; + double z = 0.; + bool partIsInJet = false; + for (auto const& part : partJet.template tracks_as()) { + if (posDecayed && (part == negMom)) { + partIsInJet = true; + z = getMomFrac(partJet, part); + break; } - if (!((TMath::Abs(particle.pdgCode()) == 310) || TMath::Abs((particle.pdgCode()) == 3122))) { - isParticleUsed[iparticle] = true; - continue; + if (negDecayed && (part == posMom)) { + partIsInJet = true; + z = getMomFrac(partJet, part); + break; } - // If the particle has been used or it is not a particle of interest, skip it - if (isParticleUsed[iparticle]) { - continue; + } + + if (std::abs(pdg) == PDG_t::kK0Short) { + registry.fill(HIST("matching/jets/V0/decayedK0SV0PtMass"), partJet.pt(), detJet.pt(), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + if (partIsInJet) { + registry.fill(HIST("matching/jets/V0/decayedK0SV0TrackProjMass"), partJet.pt(), detJet.pt(), z, zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); } - if (jetutilities::deltaR(partJet, particle) >= partJet.r() * 1e-2) { - continue; + } else if (pdg == PDG_t::kLambda0) { + registry.fill(HIST("matching/jets/V0/decayedLambdaV0PtMass"), partJet.pt(), detJet.pt(), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + if (partIsInJet) { + registry.fill(HIST("matching/jets/V0/decayedLambdaV0TrackProjMass"), partJet.pt(), detJet.pt(), z, zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); } - // Particle may be a miss, but we need to check if it is matched with a V0 in a detector level jet - // If it is, it has been treated in the loop over detector level jets above - if (!partJet.has_matchedJetGeo()) { - isParticleUsed[iparticle] = true; - fillMatchingV0Miss(partJet, particle, weight); - continue; + } else if (pdg == PDG_t::kLambda0Bar) { + registry.fill(HIST("matching/jets/V0/decayedAntiLambdaV0PtMass"), partJet.pt(), detJet.pt(), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + if (partIsInJet) { + registry.fill(HIST("matching/jets/V0/decayedAntiLambdaV0TrackProjMass"), partJet.pt(), detJet.pt(), z, zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); } - for (const auto& detJet : partJet.template matchedJetGeo_as()) { - if ((detJet.eta() <= v0EtaMin + detJet.r() * 1e-2) || (detJet.eta() >= v0EtaMax - detJet.r() * 1e-2)) { - continue; - } - for (const auto& v0 : v0s) { - if (!v0.has_mcParticle()) { - continue; - } - if (v0.template mcParticle_as().globalIndex() == particle.globalIndex()) { - if (jetutilities::deltaR(detJet, v0) < detJet.r() * 1e-2) { - // The particle is matched with a V0 and we ignore it - isParticleUsed[iparticle] = true; - } - } - } // v0 loop - } // detJet loop - if (!isParticleUsed[iparticle]) { - isParticleUsed[iparticle] = true; - fillMatchingV0Miss(partJet, particle, weight); + } else { + registry.fill(HIST("matching/jets/V0/decayedOtherPtV0PtMass"), partJet.pt(), detJet.pt(), pt, v0.pt(), v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + if (partIsInJet) { + registry.fill(HIST("matching/jets/V0/decayedOtherPtV0TrackProjMass"), partJet.pt(), detJet.pt(), z, zv0, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); } - } // particle loop - } // part jet loop + } + } } - PROCESS_SWITCH(JetFragmentation, processMcMatchedV0Frag, "Monte Carlo V0 fragmentation", false); - void processDataV0(soa::Filtered>::iterator const& collision, - aod::V0Datas const& V0s) + // --------------------------------------------------- + // Processes + // --------------------------------------------------- + void processDummy(aod::JetTracks const&) {} + PROCESS_SWITCH(JetFragmentation, processDummy, "Dummy process function turned on by default", true); + + // Data + void processDataV0(soa::Filtered::iterator const& jcoll, CandidatesV0DataWithFlags const& V0s) { - if (!collision.sel8()) { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) { return; } registry.fill(HIST("data/V0/nV0sEvent"), V0s.size()); - fillDataV0Histograms(collision, V0s); + fillDataV0Histograms(jcoll, V0s); + fillDataV0HistogramsWeighted(jcoll, V0s); } PROCESS_SWITCH(JetFragmentation, processDataV0, "Data V0", false); - void processDataV0Frag(soa::Filtered>::iterator const& jcoll, - ChargedJetsWithConstituents const& jets, - aod::JetTracks const&, - aod::Collisions const&, - aod::V0Datas const& allV0s) - { - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { - return; - } - // This is necessary, because jets are linked to aod::JetCollisions, but V0s are linked to Collisions - const auto& collision = jcoll.collision_as(); - const auto& v0s = allV0s.sliceBy(V0sPerCollision, collision.globalIndex()); - - int kNV0s = v0s.size(); - bool isV0Used[kNV0s]; - for (int i = 0; i < kNV0s; i++) { - isV0Used[i] = false; - } - registry.fill(HIST("data/V0/nV0sEvent"), kNV0s); - - fillDataV0Histograms(collision, v0s); - for (const auto& jet : jets) { - if ((jet.eta() < v0EtaMin + jet.r() * 1e-2) || (jet.eta() > v0EtaMax - jet.r() * 1e-2)) { - continue; - } - fillDataJetHistograms(jet); - fillDataFragHistograms(jet); - // fastjet::PseudoJet newjet(jet.px(), jet.py(), jet.pz(), jet.e()); // Jet with corrections from V0 - int iv0 = -1; - int nV0inJet = 0, nLambdainJet = 0, nAntiLambdainJet = 0, nK0SinJet = 0; - - // Jets are pt-sorted, so we prioritise matching V0s with high pt jets - // Correct jet momentum (currently only corrects for v0 in jet, not v0 outside jet, is this an issue?) - // for (const auto& v0 : v0s) { - // iv0++; - // if (isV0Used[iv0]) { - // continue; - // } - // double dR = jetutilities::deltaR(jet, v0); - // if (dR < jet.r() * 1e-2) { - // // fastjet::PseudoJet pjv0(v0.px(), v0.py(), v0.pz(), v0.e()); - // // newjet += pjv0; - // } - // } - // Loop over V0s and fill histograms - iv0 = -1; - for (const auto& v0 : v0s) { - iv0++; - if (isV0Used[iv0]) { - continue; - } - double dR = jetutilities::deltaR(jet, v0); - if (dR < jet.r() * 1e-2) { - isV0Used[iv0] = true; - nV0inJet++; - fillDataV0FragHistograms(collision, jet, v0); - if (IsK0SCandidate(collision, v0)) { - nK0SinJet++; - } - if (IsLambdaCandidate(collision, v0)) { - nLambdainJet++; - } - if (IsAntiLambdaCandidate(collision, v0)) { - nAntiLambdainJet++; - } - // double newTrackProj = TrackProj(newjet, v0); // TODO: Does this work? - // registry.fill(HIST("data/jets/V0/jetCorrectedPtV0TrackProj"), newjet.pt(), newTrackProj); - } - } // v0 loop - registry.fill(HIST("data/jets/V0/jetPtnV0"), jet.pt(), nV0inJet); - registry.fill(HIST("data/jets/V0/jetPtnLambda"), jet.pt(), nLambdainJet); - registry.fill(HIST("data/jets/V0/jetPtnAntiLambda"), jet.pt(), nAntiLambdainJet); - registry.fill(HIST("data/jets/V0/jetPtnK0S"), jet.pt(), nK0SinJet); - registry.fill(HIST("data/jets/V0/jetPtnV0nK0SnLambdanAntiLambda"), jet.pt(), nV0inJet, nK0SinJet, nLambdainJet, nAntiLambdainJet); - - // registry.fill(HIST("data/jets/V0/jetCorrectedPtEtaPhi"), newjet.pt(), newjet.eta(), newjet.phi()); - } - } - PROCESS_SWITCH(JetFragmentation, processDataV0Frag, "Data V0 fragmentation", false); - - // - // - // ---------------- V0 jets ---------------- - void processDataV0JetsFrag(soa::Filtered::iterator const& jcoll, soa::Join const& v0jets, aod::CandidatesV0Data const& v0s) + void processDataV0JetsFrag(soa::Filtered::iterator const& jcoll, DataV0JetsWithConstituents const& v0jets, CandidatesV0DataWithFlags const&, aod::JetTracks const&) { - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) { return; } - registry.fill(HIST("data/V0/nV0sEvent"), v0s.size()); - fillDataV0Histograms(jcoll, v0s); for (const auto& jet : v0jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, -99., -99., v0EtaMin, v0EtaMax)) { continue; } - // Double check if the jet contains V0s - if (!JetContainsV0s(jet)) { + + if (!jetContainsV0s(jet)) // Double check if the jet contains V0s continue; - } + fillDataJetHistograms(jet); - int nV0inJet = 0, nLambdainJet = 0, nAntiLambdainJet = 0, nK0SinJet = 0; - for (const auto& v0 : jet.candidates_as()) { + int nV0inJet = 0, nLambdainJet = 0, nAntiLambdainJet = 0, nK0SinJet = 0; // Counts + float wV0inJet = 0, wLambdainJet = 0, wAntiLambdainJet = 0, wK0SinJet = 0; // Weights + + std::vector values; + std::vector> weights; + for (const auto& v0 : jet.candidates_as()) { + if (v0.isRejectedCandidate()) + continue; + + float signalProb = getV0SignalProb(v0); nV0inJet++; - fillDataV0FragHistograms(jcoll, jet, v0); - if (IsK0SCandidate(jcoll, v0)) { + wV0inJet += signalProb; + if (v0.isK0SCandidate()) { nK0SinJet++; + wK0SinJet += signalProb; } - if (IsLambdaCandidate(jcoll, v0)) { + if (v0.isLambdaCandidate()) { nLambdainJet++; + wLambdainJet += signalProb; } - if (IsAntiLambdaCandidate(jcoll, v0)) { + if (v0.isAntiLambdaCandidate()) { nAntiLambdainJet++; + wAntiLambdainJet += signalProb; } - } - registry.fill(HIST("data/jets/V0/jetPtnV0nK0SnLambdanAntiLambda"), jet.pt(), nV0inJet, nK0SinJet, nLambdainJet, nAntiLambdainJet); - } // Jet loop - } - PROCESS_SWITCH(JetFragmentation, processDataV0JetsFrag, "Data V0 jets fragmentation", false); - void processDataV0JetsFragWithWeights(soa::Filtered::iterator const& jcoll, soa::Join const& v0jets, aod::CandidatesV0Data const& v0s) - { - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { - return; - } - registry.fill(HIST("data/V0/nV0sEvent"), v0s.size()); - fillDataV0Histograms(jcoll, v0s); + fillDataV0FragHistograms(jcoll, jet, v0); + double z = getMomFrac(jet, v0); + std::vector w; - for (const auto& jet : v0jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, -99., -99., v0EtaMin, v0EtaMax)) { - continue; - } - // Double check if the jet contains V0s - if (!JetContainsV0s(jet)) { - continue; - } - fillDataJetHistograms(jet); + if (nV0Classes == 2) + w = getV0SignalProbVector2Classes(v0); + else if (nV0Classes == 4) + w = getV0SignalProbVector4Classes(v0); + else + return; - std::vector values; - std::vector> weights; - int nParticles = 0; - int nClasses = 4; // Should be set globally? Maybe just a global constant? - for (const auto& v0 : jet.candidates_as()) { - nParticles++; - fillDataV0FragHistograms(jcoll, jet, v0); - double z = TrackProj(jet, v0); - std::vector w = getV0SignalWeight(jcoll, v0); values.push_back(z); weights.push_back(w); } values.push_back(jet.pt()); + registry.fill(HIST("data/jets/V0/jetPtnV0nK0SnLambdanAntiLambda"), jet.pt(), nV0inJet, nK0SinJet, nLambdainJet, nAntiLambdainJet); + registry.fill(HIST("data/jets/weighted/V0/jetPtnV0nK0SnLambdanAntiLambda"), jet.pt(), wV0inJet, wK0SinJet, wLambdainJet, wAntiLambdainJet); - int nStates = TMath::Power(nClasses, nParticles); + int nStates = std::round(std::pow(static_cast(nV0Classes), static_cast(nV0inJet))); for (int M = 0; M < nStates; M++) { - std::vector state = convertState(M, nParticles, nClasses); - std::vector corrected = correctedValues(state, values); + std::vector state = convertState(M, nV0inJet, nV0Classes); + std::vector corrected; + if (doCorrectionWithTracks) + corrected = correctedValuesPlusTracks(state, jet); + else + corrected = correctedValues(state, values); + double ws = stateWeight(state, weights); - double jetpt = corrected[nParticles]; - fillDataJetHistogramsWithWeights(jetpt, jet.eta(), jet.phi(), ws); - fillDataV0FragHistogramsWithWeights(jcoll, jet, state, corrected, ws); + double jetpt = corrected[nV0inJet]; + fillDataJetHistogramsWeighted(jetpt, jet.eta(), jet.phi(), ws); + fillDataV0FragHistogramsWeighted(jcoll, jet, state, corrected, ws); } - // TODO: Fill nV0 hist - // TODO: Fill weighted nV0 hist? } } - PROCESS_SWITCH(JetFragmentation, processDataV0JetsFragWithWeights, "Data V0 jets fragmentation with weights", false); + PROCESS_SWITCH(JetFragmentation, processDataV0JetsFrag, "Data V0 jets fragmentation with weights", false); - void processDataV0PerpCone(soa::Filtered::iterator const& jcoll, aod::V0ChargedJets const& v0jets, aod::CandidatesV0Data const& v0s) + void processDataV0PerpCone(soa::Filtered::iterator const& jcoll, aod::V0ChargedJets const& v0jets, CandidatesV0DataWithFlags const& v0s) { - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { - return; - } - if (v0s.size() == 0) { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) { return; } - registry.fill(HIST("data/V0/nV0sEvent"), v0s.size()); - fillDataV0Histograms(jcoll, v0s); for (const auto& jet : v0jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, -99., -99., v0EtaMin, v0EtaMax)) { @@ -2846,72 +2762,103 @@ struct JetFragmentation { } PROCESS_SWITCH(JetFragmentation, processDataV0PerpCone, "Perpendicular cone V0s in data", false); - void processMcMatchedV0JetsFrag(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, MatchedMCDV0JetsWithConstituents const& v0jetsMCD, MatchedMCPV0JetsWithConstituents const& v0jetsMCP, soa::Join const& v0s, aod::CandidatesV0MCP const& pv0s, aod::JetTracksMCD const& jTracks, aod::JetParticles const&) + // Matching + void processMcMatchedV0(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, CandidatesV0MCDWithLabelsAndFlags const& v0s, aod::CandidatesV0MCP const& pv0s, aod::JetTracksMCD const& jTracks, aod::JetParticles const&) { if (!jcoll.has_mcCollision()) { return; } - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) { return; } double weight = jcoll.mcCollision().weight(); registry.fill(HIST("matching/V0/nV0sEvent"), v0s.size()); registry.fill(HIST("matching/V0/nV0sEventWeighted"), v0s.size(), weight); - // TODO: This is not very efficient + // TODO: Fill mcd and mcp hists + fillMCDV0Histograms(jcoll, v0s, weight); + fillMCPV0Histograms(pv0s, weight); + + float nV0s = 0; for (const auto& v0 : v0s) { + if (v0.isRejectedCandidate()) + continue; + if (!v0.has_mcParticle()) { fillMatchingV0FakeHistograms(jcoll, v0, weight); fillMatchingFakeV0DauHistograms(v0, weight); + fillMatchingV0DecayedHistograms(v0, weight); continue; } for (const auto& pv0 : pv0s) { - if (V0sAreMatched(v0, pv0, jTracks)) { + if (v0sAreMatched(v0, pv0, jTracks)) { + nV0s += 1; fillMatchingV0Histograms(jcoll, v0, pv0, weight); fillMatchingV0DauHistograms(v0, pv0, weight); } } + } // Reconstructed V0s + for (const auto& pv0 : pv0s) { + for (const auto& v0 : v0s) { + if (v0sAreMatched(v0, pv0, jTracks)) { + continue; + } + // Fill histograms for missed V0s + } } + registry.fill(HIST("matching/V0/nV0sEventAcc"), nV0s); + registry.fill(HIST("matching/V0/nV0sEventAccWeighted"), nV0s, weight); + } + PROCESS_SWITCH(JetFragmentation, processMcMatchedV0, "Monte Carlo V0", false); + + void processMcMatchedV0JetsFrag(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, MatchedMCDV0JetsWithConstituents const& v0jetsMCD, MatchedMCPV0JetsWithConstituents const& v0jetsMCP, CandidatesV0MCDWithLabelsAndFlags const&, aod::CandidatesV0MCP const&, aod::JetTracksMCD const& jTracks, aod::JetParticles const&) + { + if (!jcoll.has_mcCollision()) + return; + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) + return; + + double weight = jcoll.mcCollision().weight(); for (const auto& detJet : v0jetsMCD) { - if (!jetfindingutilities::isInEtaAcceptance(detJet, -99., -99., v0EtaMin, v0EtaMax)) { + if (!jetfindingutilities::isInEtaAcceptance(detJet, -99., -99., v0EtaMin, v0EtaMax)) continue; - } + // Double check if the jet contains V0s - if (!JetContainsV0s(detJet)) { + if (!jetContainsV0s(detJet)) continue; - } + fillMCDJetHistograms(detJet, weight); int nV0inJet = 0, nLambdainJet = 0, nAntiLambdainJet = 0, nK0SinJet = 0; if (!detJet.has_matchedJetGeo()) { - for (const auto& detV0 : detJet.candidates_as>()) { - fillMatchingV0Fake(jcoll, detJet, detV0, weight); + for (const auto& detV0 : detJet.candidates_as()) { + fillMatchingV0JetFakeHistograms(jcoll, detJet, detV0, weight); } continue; } // if jet not matched for (const auto& partJet : detJet.template matchedJetGeo_as()) { fillMatchingHistogramsJet(detJet, partJet, weight); - for (const auto& detV0 : detJet.candidates_as>()) { + for (const auto& detV0 : detJet.candidates_as()) { if (!detV0.has_mcParticle()) { - fillMatchingV0Fake(jcoll, detJet, detV0, weight); - fillMatchingV0DecayedHistograms(partJet, detJet, detV0, weight); + fillMatchingV0JetFakeHistograms(jcoll, detJet, detV0, weight); + fillMatchingV0JetDecayedHistograms(partJet, detJet, detV0, weight); continue; } bool isV0Matched = false; for (const auto& partV0 : partJet.template candidates_as()) { - if (V0sAreMatched(detV0, partV0, jTracks)) { + if (v0sAreMatched(detV0, partV0, jTracks)) { isV0Matched = true; nV0inJet++; fillMatchingV0FragHistograms(jcoll, detJet, partJet, detV0, partV0, weight); fillMatchingV0DauJetHistograms(detJet, partJet, detV0, partV0, weight); - if (TMath::Abs(partV0.pdgCode()) == 310) { + if (std::abs(partV0.pdgCode()) == PDG_t::kK0Short) { nK0SinJet++; - } else if (partV0.pdgCode() == 3122) { + } else if (partV0.pdgCode() == PDG_t::kLambda0) { nLambdainJet++; - } else if (partV0.pdgCode() == -3122) { + } else if (partV0.pdgCode() == PDG_t::kLambda0Bar) { nAntiLambdainJet++; } break; @@ -2919,7 +2866,7 @@ struct JetFragmentation { } // partV0 loop if (!isV0Matched) { - fillMatchingV0Fake(jcoll, detJet, detV0, weight); + fillMatchingV0JetFakeHistograms(jcoll, detJet, detV0, weight); } } // detV0 loop registry.fill(HIST("matching/jets/V0/jetPtnV0MatchednK0SnLambdanAntiLambda"), partJet.pt(), nV0inJet, nK0SinJet, nLambdainJet, nAntiLambdainJet, weight); @@ -2927,7 +2874,7 @@ struct JetFragmentation { } // detJet loop for (const auto& partJet : v0jetsMCP) { - if (!JetContainsV0s(partJet)) { + if (!jetContainsV0s(partJet)) { continue; } fillMCPJetHistograms(partJet, weight); @@ -2947,8 +2894,8 @@ struct JetFragmentation { isJetMatched = true; for (const auto& partV0 : partJet.candidates_as()) { bool isV0Matched = false; - for (const auto& detV0 : detJet.candidates_as>()) { - if (V0sAreMatched(detV0, partV0, jTracks)) { + for (const auto& detV0 : detJet.candidates_as()) { + if (v0sAreMatched(detV0, partV0, jTracks)) { isV0Matched = true; break; } @@ -2969,12 +2916,9 @@ struct JetFragmentation { } PROCESS_SWITCH(JetFragmentation, processMcMatchedV0JetsFrag, "Matched V0 jets fragmentation", false); - void processMcV0PerpCone(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, MatchedMCDV0Jets const& v0jets, soa::Join const& v0s, aod::McParticles const& particles) + void processMcV0PerpCone(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, MatchedMCDV0Jets const& v0jets, CandidatesV0MCDWithLabelsAndFlags const& v0s, aod::McParticles const& particles, MatchedMCPV0Jets const&) { - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { - return; - } - if (v0s.size() == 0) { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) { return; } double weight = jcoll.mcCollision().weight(); @@ -2982,41 +2926,22 @@ struct JetFragmentation { registry.fill(HIST("mcd/V0/nV0sEventWeighted"), v0s.size(), weight); for (const auto& mcdjet : v0jets) { - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, -99., -99., v0EtaMin, v0EtaMax)) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, -99., -99., v0EtaMin, v0EtaMax)) continue; - } - fillMcPerpConeHists(jcoll, mcdjet, v0s, particles, weight); - } - } - PROCESS_SWITCH(JetFragmentation, processMcV0PerpCone, "Perpendicular cone V0s in MC", false); - void processMcV0MatchedPerpCone(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, MatchedMCDV0Jets const& v0jets, MatchedMCPV0Jets const&, soa::Join const& v0s, aod::McParticles const& particles) - { - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { - return; - } - if (v0s.size() == 0) { - return; - } - double weight = jcoll.mcCollision().weight(); - registry.fill(HIST("matching/V0/nV0sEvent"), v0s.size()); - registry.fill(HIST("matching/V0/nV0sEventWeighted"), v0s.size(), weight); + fillMcPerpConeHists(jcoll, mcdjet, v0s, particles, weight); - for (const auto& mcdjet : v0jets) { - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, -99., -99., v0EtaMin, v0EtaMax)) { - continue; - } - for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { + for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { fillMcPerpConeHists(jcoll, mcdjet, mcpjet, v0s, particles, weight); break; // Make sure we only do this once } } } - PROCESS_SWITCH(JetFragmentation, processMcV0MatchedPerpCone, "Perpendicular cone V0s in MC, matched jets", false); + PROCESS_SWITCH(JetFragmentation, processMcV0PerpCone, "Perpendicular cone V0s in MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"jet-fragmentation"})}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGJE/Tasks/jetHadronRecoil.cxx b/PWGJE/Tasks/jetHadronRecoil.cxx index c1d15537866..73128a513d8 100644 --- a/PWGJE/Tasks/jetHadronRecoil.cxx +++ b/PWGJE/Tasks/jetHadronRecoil.cxx @@ -13,33 +13,38 @@ /// \brief Task for analysing hadron triggered events. /// \author Daniel Jones -#include -#include +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" -#include "TRandom3.h" +#include "Common/Core/RecoDecay.h" +#include "CommonConstants/MathConstants.h" #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "CommonConstants/MathConstants.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/Core/RecoDecay.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include +#include +#include -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/DataModel/Jet.h" +#include "TRandom3.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include +#include +#include -#include "EventFiltering/filterTables.h" +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -47,23 +52,36 @@ using namespace o2::framework::expressions; struct JetHadronRecoil { + std::vector jetConstituents; + std::vector jetReclustered; + JetFinder jetReclusterer; + Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; Configurable trackPtMin{"trackPtMin", 0.15, "minimum pT acceptance for tracks"}; Configurable trackPtMax{"trackPtMax", 100.0, "maximum pT acceptance for tracks"}; Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum eta acceptance for tracks"}; Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum eta acceptance for tracks"}; + Configurable maxLeadingTrackPt{"maxLeadingTrackPt", 1000.0, "maximum acceptance for leading track in jets"}; + Configurable centralityMin{"centralityMin", -999.0, "minimum centrality"}; + Configurable centralityMax{"centralityMax", 999.0, "maximum centrality"}; Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; Configurable ptTTrefMin{"ptTTrefMin", 5, "reference minimum trigger track pt"}; Configurable ptTTrefMax{"ptTTrefMax", 7, "reference maximum trigger track pt"}; Configurable ptTTsigMin{"ptTTsigMin", 20, "signal minimum trigger track pt"}; Configurable ptTTsigMax{"ptTTsigMax", 50, "signal maximum trigger track pt"}; - Configurable fracSig{"fracSig", 0.5, "fraction of events to use for signal"}; + Configurable fracSig{"fracSig", 0.9, "fraction of events to use for signal"}; Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; - Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; + Configurable pTHatTrackMaxMCD{"pTHatTrackMaxMCD", 999.0, "maximum fraction of hard scattering for track acceptance in detector MC"}; + Configurable pTHatTrackMaxMCP{"pTHatTrackMaxMCP", 999.0, "maximum fraction of hard scattering for track acceptance in particle MC"}; + Configurable pTHatMinEvent{"pTHatMinEvent", -1.0, "minimum absolute event pTHat"}; + Configurable rhoReferenceShift{"rhoReferenceShift", 0.0, "shift in rho calculated in reference events for consistency with signal events"}; Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "flag to choose to reject min. bias gap events; jet-level rejection applied at the jet finder level, here rejection is applied for collision and track process functions"}; + Configurable outlierRejectEvent{"outlierRejectEvent", true, "where outliers are found, reject event (true) or just reject the single track/jet (false)"}; + Configurable wtaMethod{"wtaMethod", 1, "method for WTA axis definition: 0 = matching closest WTA jet (incorrect), 1 = recluster original jet"}; Preslice> partJetsPerCollision = aod::jet::mcCollisionId; @@ -71,61 +89,102 @@ struct JetHadronRecoil { Filter jetCuts = aod::jet::r == nround(jetR.node() * 100.0f); Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); - Filter eventTrackLevelCuts = nabs(aod::jcollision::posZ) < vertexZCut; + Filter particleCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax && aod::jmcparticle::eta > trackEtaMin && aod::jmcparticle::eta < trackEtaMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); + + std::vector ptBinningPart = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, + 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, + 65.0, 70.0, 75.0, 80.0, 90.0, 100.0, 110.0, 120.0, 130.0, + 140.0, 150.0, 160.0, 180.0, 200.0}; + std::vector ptBinningDet = {-100.0, -70.0, -60.0, -50.0, -40.0, -35.0, -30.0, -25.0, -20.0, -15.0, -10.0, -5.0, + 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, + 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, + 65.0, 70.0, 75.0, 80.0, 90.0, 100.0, 110.0, 120.0, 130.0, + 140.0, 150.0, 160.0, 180.0, 200.0}; + std::vector dRBinning = {0.0, 1.0e-9, 0.003, 0.006, 0.009, 0.012, 0.015, 0.018, 0.021, 0.024, + 0.027, 0.03, 0.033, 0.036, 0.039, 0.042, 0.045, 0.048, 0.051, 0.054, + 0.057, 0.06, 0.063, 0.066, 0.069, 0.072, 0.075, 0.078, 0.081, 0.084, + 0.087, 0.09, 0.093, 0.096, 0.099, 0.102, 0.105, 0.108, 0.111, 0.114, + 0.117, 0.12, 0.123, 0.126, 0.129, 0.132, 0.135, 0.138, 0.141, 0.144, + 0.147, 0.15, 0.153, 0.156, 0.159, 0.162, 0.165, 0.168, 0.171, 0.174, + 0.177, 0.18, 0.183, 0.186, 0.189, 0.192, 0.195, 0.198, 0.201, 0.204, + 0.207, 0.21, 0.213, 0.216, 0.219, 0.222, 0.225, 0.228, 0.231, 0.234, + 0.237, 0.24, 0.27, 0.30, 0.33, 0.36, 0.39, 0.42, 0.45, 0.48, 0.51, 0.54, + 0.57, 0.60}; + + AxisSpec dRAxis = {dRBinning, "#Delta R"}; + AxisSpec ptAxisDet = {ptBinningDet, "#it{p}_{T,det} (GeV/c)"}; + AxisSpec ptAxisPart = {ptBinningPart, "#it{p}_{T,part} (GeV/c)"}; + AxisSpec phiAxisDet = {100, 0.0, o2::constants::math::TwoPI, "#phi_{det}"}; + AxisSpec phiAxisPart = {100, 0.0, o2::constants::math::TwoPI, "#phi_{part}"}; + AxisSpec dRAxisDet = {dRBinning, "#Delta R_{det}"}; + AxisSpec dRAxisPart = {dRBinning, "#Delta R_{part}"}; HistogramRegistry registry{"registry", {{"hNtrig", "number of triggers;trigger type;entries", {HistType::kTH1F, {{2, 0, 2}}}}, + {"hSignalTriggersPtHard", "Signal triggers vs PtHard", {HistType::kTH1F, {{20, 0, 5}}}}, + {"hReferenceTriggersPtHard", "Reference triggers vs PtHard", {HistType::kTH1F, {{20, 0, 5}}}}, {"hZvtxSelected", "Z vertex position;Z_{vtx};entries", {HistType::kTH1F, {{80, -20, 20}}}}, {"hPtTrack", "Track p_{T};p_{T};entries", {HistType::kTH1F, {{200, 0, 200}}}}, {"hEtaTrack", "Track #eta;#eta;entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"hPhiTrack", "Track #phi;#phi;entries", {HistType::kTH1F, {{160, -1.0, 7.0}}}}, - {"hReferencePtDPhi", "jet p_{T} vs DPhi;#Delta#phi;p_{T,jet}", {HistType::kTH2F, {{100, 0, o2::constants::math::TwoPI}, {150, 0, 150}}}}, - {"hSignalPtDPhi", "jet p_{T} vs DPhi;#Delta#phi;p_{T,jet}", {HistType::kTH2F, {{100, 0, o2::constants::math::TwoPI}, {150, 0, 150}}}}, - {"hReferencePt", "jet p_{T};p_{T,jet};entries", {HistType::kTH1F, {{150, 0, 150}}}}, - {"hSignalPt", "jet p_{T};p_{T,jet};entries", {HistType::kTH1F, {{150, 0, 150}}}}, - {"hSignalLeadingTrack", "leading track p_{T};p_{T,jet};#Delta#phi;leading track p_{T}", {HistType::kTH3F, {{150, 0, 150}, {100, 0, o2::constants::math::TwoPI}, {150, 0, 150}}}}, - {"hReferenceLeadingTrack", "leading track p_{T};p_{T,jet};#Delta#phi;leading track p_{T}", {HistType::kTH3F, {{150, 0, 150}, {100, 0, o2::constants::math::TwoPI}, {150, 0, 150}}}}, - {"hJetSignalMultiplicity", "jet multiplicity;N_{jets};entries", {HistType::kTH1F, {{10, 0, 10}}}}, - {"hJetReferenceMultiplicity", "jet multiplicity;N_{jets};entries", {HistType::kTH1F, {{10, 0, 10}}}}, - {"hJetSignalConstituentMultiplicity", "jet constituent multiplicity;p_{T,jet};#Delta#phi;N_{constituents}", {HistType::kTH3F, {{150, 0, 150}, {100, 0, o2::constants::math::TwoPI}, {50, 0, 50}}}}, - {"hJetReferenceConstituentMultiplicity", "jet constituent multiplicity;p_{T,jet};#Delta#phi;N_{constituents}", {HistType::kTH3F, {{150, 0, 150}, {100, 0, o2::constants::math::TwoPI}, {50, 0, 50}}}}, - {"hJetSignalConstituentPt", "jet constituent p_{T};p_{T,jet};#Delta#phi;p_{T,constituent}", {HistType::kTH3F, {{150, 0, 150}, {100, 0, o2::constants::math::TwoPI}, {150, 0, 150}}}}, - {"hJetReferenceConstituentPt", "jet constituent p_{T};p_{T,jet};#Delta#phi;p_{T,constituent}", {HistType::kTH3F, {{150, 0, 150}, {100, 0, o2::constants::math::TwoPI}, {150, 0, 150}}}}, + {"hPhiTrack", "Track #phi;#phi;entries", {HistType::kTH1F, {{100, 0.0, o2::constants::math::TwoPI}}}}, + {"hTrack3D", "3D tracks histogram;p_{T};#eta;#phi", {HistType::kTH3F, {{200, 0, 200}, {100, -1.0, 1.0}, {100, 0.0, o2::constants::math::TwoPI}}}}, + {"hTrackPtHard", "Tracks vs pThard;#frac{p_{T}}{#hat{p}};p_{T}", {HistType::kTH2F, {{20, 0, 5}, {200, 0, 200}}}}, + {"hPartPtHard", "Part vs pThard;#frac{p_{T}}{#hat{p}};p_{T}", {HistType::kTH2F, {{20, 0, 5}, {200, 0, 200}}}}, + {"hConstituents3D", "3D constituents histogram;p_{T};#eta;#phi", {HistType::kTH3F, {{200, 0, 200}, {100, -1.0, 1.0}, {100, 0.0, o2::constants::math::TwoPI}}}}, + {"hReferencePtDPhi", "jet p_{T} vs DPhi;#Delta#phi;p_{T,jet}", {HistType::kTH2F, {{100, 0, o2::constants::math::TwoPI}, {500, -100, 400}}}}, + {"hReferencePtDPhiShifts", "rho shifts;#Delta#phi;p_{T,jet};shifts", {HistType::kTH3F, {{100, 0, o2::constants::math::TwoPI}, {500, -100, 400}, {20, 0.0, 2.0}}}}, + {"hSignalPtDPhi", "jet p_{T} vs DPhi;#Delta#phi;p_{T,jet}", {HistType::kTH2F, {{100, 0, o2::constants::math::TwoPI}, {500, -100, 400}}}}, + {"hReferencePt", "jet p_{T};p_{T,jet};entries", {HistType::kTH1F, {{500, -100, 400}}}}, + {"hSignalPt", "jet p_{T};p_{T,jet};entries", {HistType::kTH1F, {{500, -100, 400}}}}, + {"hSignalTriggers", "trigger p_{T};p_{T,trig};entries", {HistType::kTH1F, {{150, 0, 150}}}}, + {"hSignalPtHard", "jet p_{T} vs #hat{p};p_{T,jet};#frac{p_{T,trig}}{#hat{p}}", {HistType::kTH2F, {{500, -100, 400}, {20, 0, 5}}}}, + {"hReferenceTriggers", "trigger p_{T};p_{T,trig};entries", {HistType::kTH1F, {{150, 0, 150}}}}, + {"hReferencePtHard", "jet p_{T} vs #hat{p};p_{T,jet};#frac{p_{T,trig}}{#hat{p}}", {HistType::kTH2F, {{500, -100, 400}, {20, 0, 5}}}}, {"hSigEventTriggers", "N_{triggers};events", {HistType::kTH1F, {{10, 0, 10}}}}, {"hRefEventTriggers", "N_{triggers};events", {HistType::kTH1F, {{10, 0, 10}}}}, - {"hJetPt", "jet p_{T};p_{T,jet};entries", {HistType::kTH1F, {{200, 0, 200}}}}, + {"hJetPt", "jet p_{T};p_{T,jet};entries", {HistType::kTH1F, {{500, -100, 400}}}}, {"hJetEta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"hJetPhi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{160, -1.0, 7.0}}}}, + {"hJetPhi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{100, 0.0, o2::constants::math::TwoPI}}}}, + {"hJet3D", "3D jet distribution;p_{T};#eta;#phi", {HistType::kTH3F, {{500, -100, 400}, {100, -1.0, 1.0}, {100, 0.0, o2::constants::math::TwoPI}}}}, + {"hTracksvsJets", "comparing leading tracks and jets;p_{T,track};p_{T,jet};#hat{p}", {HistType::kTH3F, {{200, 0, 200}, {500, -100, 400}, {195, 5, 200}}}}, + {"hPartvsJets", "comparing leading particles and jets;p_{T,part};p_{T,jet};#hat{p}", {HistType::kTH3F, {{200, 0, 200}, {500, -100, 400}, {195, 5, 200}}}}, {"hPtPart", "Particle p_{T};p_{T};entries", {HistType::kTH1F, {{200, 0, 200}}}}, {"hEtaPart", "Particle #eta;#eta;entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"hPhiPart", "Particle #phi;#phi;entries", {HistType::kTH1F, {{160, -1.0, 7.0}}}}, - {"hDeltaR", "#DeltaR;#DeltaR;#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {{50, 0.0, 0.15}}}}, - {"hDeltaRPart", "Particle #DeltaR;#DeltaR;#frac{1}{N_{jets}}#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {{50, 0.0, 0.15}}}}, - {"hDeltaRpT", "jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{200, 0, 200}, {50, 0.0, 0.15}}}}, - {"hDeltaRpTPart", "Particle jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{200, 0, 200}, {50, 0.0, 0.15}}}}, - {"hDeltaRSignal", "#DeltaR;#DeltaR;#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {{50, 0.0, 0.15}}}}, - {"hDeltaRSignalPart", "Particle #DeltaR;#DeltaR;#frac{1}{N_{jets}}#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {{50, 0.0, 0.15}}}}, - {"hDeltaRpTSignal", "jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{200, 0, 200}, {50, 0.0, 0.15}}}}, - {"hDeltaRpTSignalPart", "Particle jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{200, 0, 200}, {50, 0.0, 0.15}}}}, - {"hDeltaRpTDPhiSignal", "jet p_{T} vs #DeltaR vs #Delta#phi;p_{T,jet};#Delta#phi;#DeltaR", {HistType::kTH3F, {{200, 0, 200}, {100, 0, o2::constants::math::TwoPI}, {50, 0.0, 0.15}}}}, - {"hDeltaRpTDPhiSignalPart", "Particle jet p_{T} vs #DeltaR vs #Delta#phi;p_{T,jet};#Delta#phi;#DeltaR", {HistType::kTH3F, {{200, 0, 200}, {100, 0, o2::constants::math::TwoPI}, {50, 0.0, 0.15}}}}, - {"hDeltaRReference", "#DeltaR;#DeltaR;#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {{50, 0.0, 0.15}}}}, - {"hDeltaRPartReference", "Particle #DeltaR;#DeltaR;#frac{1}{N_{jets}}#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {{50, 0.0, 0.15}}}}, - {"hDeltaRpTReference", "jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{200, 0, 200}, {50, 0.0, 0.15}}}}, - {"hDeltaRpTPartReference", "Particle jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{200, 0, 200}, {50, 0.0, 0.15}}}}, - {"hDeltaRpTDPhiReference", "jet p_{T} vs #DeltaR vs #Delta#phi;p_{T,jet};#Delta#phi;#DeltaR", {HistType::kTH3F, {{200, 0, 200}, {100, 0, o2::constants::math::TwoPI}, {50, 0.0, 0.15}}}}, - {"hDeltaRpTDPhiReferencePart", "jet p_{T} vs #DeltaR vs #Delta#phi;p_{T,jet};#Delta#phi;#DeltaR", {HistType::kTH3F, {{200, 0, 200}, {100, 0, o2::constants::math::TwoPI}, {50, 0.0, 0.15}}}}, - {"hPtMatched", "p_{T} matching;p_{T,det};p_{T,part}", {HistType::kTH2F, {{200, 0, 200}, {200, 0, 200}}}}, - {"hPhiMatched", "#phi matching;#phi_{det};#phi_{part}", {HistType::kTH2F, {{160, -1.0, 7.0}, {160, -1.0, 7.0}}}}, - {"hDeltaRMatched", "#DeltaR matching;#DeltaR_{det};#DeltaR_{part}", {HistType::kTH2F, {{50, 0.0, 0.15}, {50, 0.0, 0.15}}}}, - {"hPtMatched1d", "p_{T} matching 1d;p_{T,part}", {HistType::kTH1F, {{200, 0, 200}}}}, - {"hDeltaRMatched1d", "#DeltaR matching 1d;#DeltaR_{part}", {HistType::kTH1F, {{50, 0.0, 0.15}}}}, - {"hPtResolution", "p_{T} resolution;p_{T,part};Relative Resolution", {HistType::kTH2F, {{200, 0, 200}, {1000, -5.0, 5.0}}}}, - {"hPhiResolution", "#phi resolution;#p{T,part};Resolution", {HistType::kTH2F, {{200, 0, 200}, {1000, -7.0, 7.0}}}}, - {"hDeltaRResolution", "#DeltaR Resolution;p_{T,part};Resolution", {HistType::kTH2F, {{200, 0, 200}, {1000, -0.15, 0.15}}}}, - {"hFullMatching", "Full 6D matching;p_{T,det};p_{T,part};#phi_{det};#phi_{part};#DeltaR_{det};#DeltaR_{part}", {HistType::kTHnSparseD, {{200, 0, 200}, {200, 0, 200}, {160, -1.0, 7.0}, {160, -1.0, 7.0}, {50, 0.0, 0.15}, {50, 0.0, 0.15}}}}}}; - - int eventSelection = -1; + {"hPhiPart", "Particle #phi;#phi;entries", {HistType::kTH1F, {{100, 0.0, o2::constants::math::TwoPI}}}}, + {"hPart3D", "3D tracks histogram;p_{T};#eta;#phi", {HistType::kTH3F, {{200, 0, 200}, {100, -1.0, 1.0}, {100, 0.0, o2::constants::math::TwoPI}}}}, + {"hPtPartPtHard", "Track p_{T} vs #hat{p};p_{T};#frac{p_{T}}{#hat{p}}", {HistType::kTH2F, {{200, 0, 200}, {20, 0, 5}}}}, + {"hDeltaR", "#DeltaR;#DeltaR;#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {dRAxis}}}, + {"hDeltaRPart", "Particle #DeltaR;#DeltaR;#frac{1}{N_{jets}}#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {dRAxis}}}, + {"hDeltaRpT", "jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{500, -100, 400}, dRAxis}}}, + {"hDeltaRpTPart", "Particle jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{400, 0, 400}, dRAxis}}}, + {"hRhoSignal", "Signal Rho bkg;#rho;entries", {HistType::kTH1F, {{220, 0, 220}}}}, + {"hRhoReference", "Reference Rho bkg;#rho;entries", {HistType::kTH1F, {{220, 0, 220}}}}, + {"hRhoReferenceShift", "Testing reference shifts;#rho;shift", {HistType::kTH2F, {{220, 0, 220}, {20, 0.0, 2.0}}}}, + {"hDeltaRSignal", "#DeltaR;#DeltaR;#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {dRAxis}}}, + {"hDeltaRSignalPart", "Particle #DeltaR;#DeltaR;#frac{1}{N_{jets}}#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {dRAxis}}}, + {"hDeltaRpTSignal", "jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{500, -100, 400}, dRAxis}}}, + {"hDeltaRpTSignalPart", "Particle jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{400, 0, 400}, dRAxis}}}, + {"hDeltaRpTDPhiSignal", "jet p_{T} vs #DeltaR vs #Delta#phi;p_{T,jet};#Delta#phi;#DeltaR", {HistType::kTH3F, {{500, -100, 400}, {100, 0, o2::constants::math::TwoPI}, dRAxis}}}, + {"hDeltaRpTDPhiSignalPart", "Particle jet p_{T} vs #DeltaR vs #Delta#phi;p_{T,jet};#Delta#phi;#DeltaR", {HistType::kTH3F, {{400, 0, 400}, {100, 0, o2::constants::math::TwoPI}, dRAxis}}}, + {"hDeltaRReference", "#DeltaR;#DeltaR;#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {dRAxis}}}, + {"hDeltaRPartReference", "Particle #DeltaR;#DeltaR;#frac{1}{N_{jets}}#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {dRAxis}}}, + {"hDeltaRpTReference", "jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{500, -100, 400}, dRAxis}}}, + {"hDeltaRpTPartReference", "Particle jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{400, 0, 400}, dRAxis}}}, + {"hDeltaRpTDPhiReference", "jet p_{T} vs #DeltaR vs #Delta#phi;p_{T,jet};#Delta#phi;#DeltaR", {HistType::kTH3F, {{500, -100, 400}, {100, 0, o2::constants::math::TwoPI}, dRAxis}}}, + {"hDeltaRpTDPhiReferenceShifts", "testing shifts;p_{T,jet};#Delta#phi;#DeltaR;shifts", {HistType::kTHnSparseD, {{500, -100, 400}, {100, 0, o2::constants::math::TwoPI}, dRAxis, {20, 0.0, 2.0}}}}, + {"hDeltaRpTDPhiReferencePart", "jet p_{T} vs #DeltaR vs #Delta#phi;p_{T,jet};#Delta#phi;#DeltaR", {HistType::kTH3F, {{400, 0, 400}, {100, 0, o2::constants::math::TwoPI}, dRAxis}}}, + {"hPtMatched", "p_{T} matching;p_{T,det};p_{T,part}", {HistType::kTH2F, {{500, -100, 400}, {400, 0, 400}}}}, + {"hPhiMatched", "#phi matching;#phi_{det};#phi_{part}", {HistType::kTH2F, {{100, 0.0, o2::constants::math::TwoPI}, {100, 0.0, o2::constants::math::TwoPI}}}}, + {"hDeltaRMatched", "#DeltaR matching;#DeltaR_{det};#DeltaR_{part}", {HistType::kTH2F, {dRAxisDet, dRAxisPart}}}, + {"hPtMatched1d", "p_{T} matching 1d;p_{T,part}", {HistType::kTH1F, {{400, 0, 400}}}}, + {"hDeltaRMatched1d", "#DeltaR matching 1d;#DeltaR_{part}", {HistType::kTH1F, {dRAxisPart}}}, + {"hPtResolution", "p_{T} resolution;p_{T,part};Relative Resolution", {HistType::kTH2F, {{400, 0, 400}, {1000, -5.0, 5.0}}}}, + {"hPhiResolution", "#phi resolution;#p_{T,part};Resolution", {HistType::kTH2F, {{400, 0, 400}, {1000, -7.0, 7.0}}}}, + {"hDeltaRResolution", "#DeltaR Resolution;p_{T,part};Resolution", {HistType::kTH2F, {{400, 0, 400}, {1000, -0.15, 0.15}}}}, + {"hFullMatching", "Full 6D matching;p_{T,det};p_{T,part};#phi_{det};#phi_{part};#DeltaR_{det};#DeltaR_{part}", {HistType::kTHnSparseD, {ptAxisDet, ptAxisPart, phiAxisDet, phiAxisPart, dRAxisDet, dRAxisPart}}}}}; + + std::vector eventSelectionBits; int trackSelection = -1; std::vector triggerMaskBits; @@ -133,25 +192,35 @@ struct JetHadronRecoil { void init(InitContext const&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); Filter jetCuts = aod::jet::r == nround(jetR.node() * 100.0f); Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); + Filter particleCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax && aod::jmcparticle::eta > trackEtaMin && aod::jmcparticle::eta < trackEtaMax); Filter eventTrackLevelCuts = nabs(aod::jcollision::posZ) < vertexZCut; + + jetReclusterer.isReclustering = true; + jetReclusterer.algorithm = fastjet::JetAlgorithm::cambridge_algorithm; + jetReclusterer.jetR = 2 * jetR; + jetReclusterer.recombScheme = fastjet::WTA_pt_scheme; } template - void fillHistograms(T const& jets, W const& /*jetsWTA*/, U const& tracks, float weight = 1.0) + void fillHistograms(T const& jets, W const& jetsWTA, U const& tracks, float weight = 1.0, float rho = 0.0, float pTHat = 999.0) { bool isSigCol; std::vector phiTTAr; + std::vector ptTTAr; double phiTT = 0; + double ptTT = 0; int trigNumber = 0; int nTT = 0; double leadingPT = 0; - float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + double leadingTrackPt = 0; + double leadingJetPt = 0; + float rhoReference = rho + rhoReferenceShift; float dice = rand->Rndm(); if (dice < fracSig) @@ -163,116 +232,135 @@ struct JetHadronRecoil { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } + if (track.pt() > leadingTrackPt) { + leadingTrackPt = track.pt(); + } + if (track.pt() > pTHatTrackMaxMCD * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } if (isSigCol && track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) { phiTTAr.push_back(track.phi()); + ptTTAr.push_back(track.pt()); + registry.fill(HIST("hSignalTriggers"), track.pt(), weight); nTT++; } if (!isSigCol && track.pt() < ptTTrefMax && track.pt() > ptTTrefMin) { phiTTAr.push_back(track.phi()); + ptTTAr.push_back(track.pt()); + registry.fill(HIST("hReferenceTriggers"), track.pt(), weight); nTT++; } registry.fill(HIST("hPtTrack"), track.pt(), weight); registry.fill(HIST("hEtaTrack"), track.eta(), weight); registry.fill(HIST("hPhiTrack"), track.phi(), weight); + registry.fill(HIST("hTrack3D"), track.pt(), track.eta(), track.phi(), weight); + registry.fill(HIST("hPtTrackPtHard"), track.pt(), track.pt() / pTHat, weight); } if (nTT > 0) { trigNumber = rand->Integer(nTT); phiTT = phiTTAr[trigNumber]; + ptTT = ptTTAr[trigNumber]; if (isSigCol) { registry.fill(HIST("hNtrig"), 1.5, weight); - registry.fill(HIST("hJetSignalMultiplicity"), jets.size(), weight); registry.fill(HIST("hSigEventTriggers"), nTT, weight); + registry.fill(HIST("hRhoSignal"), rho, weight); + registry.fill(HIST("hSignalTriggersPtHard"), ptTT / pTHat, weight); } if (!isSigCol) { registry.fill(HIST("hNtrig"), 0.5, weight); - registry.fill(HIST("hJetReferenceMultiplicity"), jets.size(), weight); registry.fill(HIST("hRefEventTriggers"), nTT, weight); + registry.fill(HIST("hRhoReference"), rhoReference, weight); + for (double shift = 0.0; shift <= 2.0; shift += 0.1) { + registry.fill(HIST("hRhoReferenceShift"), rho + shift, shift, weight); + } + registry.fill(HIST("hReferenceTriggersPtHard"), ptTT / pTHat, weight); } } - for (const auto& jet : jets) { - if (jet.tracksIds().size() == 1) { - continue; + if (jet.pt() > leadingJetPt) { + leadingJetPt = jet.pt(); } if (jet.pt() > pTHatMaxMCD * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } + for (const auto& constituent : jet.template tracks_as()) { + if (constituent.pt() > leadingPT) { + leadingPT = constituent.pt(); + } + registry.fill(HIST("hConstituents3D"), constituent.pt(), constituent.eta(), constituent.phi()); + } + if (leadingPT > maxLeadingTrackPt) { continue; } - registry.fill(HIST("hJetPt"), jet.pt(), weight); + registry.fill(HIST("hJetPt"), jet.pt() - (rho * jet.area()), weight); registry.fill(HIST("hJetEta"), jet.eta(), weight); registry.fill(HIST("hJetPhi"), jet.phi(), weight); - for (const auto& jetWTA : jet.template matchedJetGeo_as>()) { - double deltaPhi = RecoDecay::constrainAngle(jetWTA.phi() - jet.phi(), -o2::constants::math::PI); - double deltaEta = jetWTA.eta() - jet.eta(); - double dR = RecoDecay::sqrtSumOfSquares(deltaPhi, deltaEta); - registry.fill(HIST("hDeltaR"), dR, weight); - registry.fill(HIST("hDeltaRpT"), jet.pt(), dR, weight); - } + registry.fill(HIST("hJet3D"), jet.pt() - (rho * jet.area()), jet.eta(), jet.phi(), weight); + + double dR = getWTAaxisDifference(jet, jetsWTA, tracks); + + registry.fill(HIST("hDeltaR"), dR, weight); + registry.fill(HIST("hDeltaRpT"), jet.pt() - (rho * jet.area()), dR, weight); + // try with fjcontrib + if (nTT > 0) { float dphi = RecoDecay::constrainAngle(jet.phi() - phiTT); if (isSigCol) { - for (const auto& jetWTA : jet.template matchedJetGeo_as>()) { - double deltaPhi = RecoDecay::constrainAngle(jetWTA.phi() - jet.phi(), -o2::constants::math::PI); - double deltaEta = jetWTA.eta() - jet.eta(); - double dR = RecoDecay::sqrtSumOfSquares(deltaPhi, deltaEta); - if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hDeltaRpTSignal"), jet.pt(), dR, weight); - registry.fill(HIST("hDeltaRSignal"), dR, weight); - } - registry.fill(HIST("hDeltaRpTDPhiSignal"), jet.pt(), dphi, dR, weight); - } - registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt(), weight); if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hSignalPt"), jet.pt(), weight); + registry.fill(HIST("hDeltaRpTSignal"), jet.pt() - (rho * jet.area()), dR, weight); + registry.fill(HIST("hDeltaRSignal"), dR, weight); } - registry.fill(HIST("hJetSignalConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size(), weight); - for (const auto& constituent : jet.template tracks_as()) { - if (constituent.pt() > leadingPT) { - leadingPT = constituent.pt(); - } - registry.fill(HIST("hJetSignalConstituentPt"), jet.pt(), dphi, constituent.pt(), weight); + registry.fill(HIST("hDeltaRpTDPhiSignal"), jet.pt() - (rho * jet.area()), dphi, dR, weight); + registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt() - (rho * jet.area()), weight); + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hSignalPt"), jet.pt() - (rho * jet.area()), weight); + registry.fill(HIST("hSignalPtHard"), jet.pt() - (rho * jet.area()), ptTT / pTHat, weight); } - registry.fill(HIST("hSignalLeadingTrack"), jet.pt(), dphi, leadingPT, weight); } if (!isSigCol) { - for (const auto& jetWTA : jet.template matchedJetGeo_as>()) { - double deltaPhi = RecoDecay::constrainAngle(jetWTA.phi() - jet.phi(), -o2::constants::math::PI); - double deltaEta = jetWTA.eta() - jet.eta(); - double dR = RecoDecay::sqrtSumOfSquares(deltaPhi, deltaEta); - if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hDeltaRpTReference"), jet.pt(), dR, weight); - registry.fill(HIST("hDeltaRReference"), dR, weight); - } - registry.fill(HIST("hDeltaRpTDPhiReference"), jet.pt(), dphi, dR, weight); - } - registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt(), weight); if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hReferencePt"), jet.pt(), weight); + registry.fill(HIST("hDeltaRpTReference"), jet.pt() - (rhoReference * jet.area()), dR, weight); + registry.fill(HIST("hDeltaRReference"), dR, weight); } - registry.fill(HIST("hJetReferenceConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size(), weight); - for (const auto& constituent : jet.template tracks_as()) { - if (constituent.pt() > leadingPT) { - leadingPT = constituent.pt(); - } - registry.fill(HIST("hJetReferenceConstituentPt"), jet.pt(), dphi, constituent.pt(), weight); + registry.fill(HIST("hDeltaRpTDPhiReference"), jet.pt() - (rhoReference * jet.area()), dphi, dR, weight); + for (double shift = 0.0; shift <= 2.0; shift += 0.1) { + registry.fill(HIST("hDeltaRpTDPhiReferenceShifts"), jet.pt() - ((rho + shift) * jet.area()), dphi, dR, shift, weight); + } + registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt() - (rhoReference * jet.area()), weight); + for (double shift = 0.0; shift <= 2.0; shift += 0.1) { + registry.fill(HIST("hReferencePtDPhiShifts"), dphi, jet.pt() - ((rho + shift) * jet.area()), shift, weight); + } + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hReferencePt"), jet.pt() - (rhoReference * jet.area()), weight); + registry.fill(HIST("hReferencePtHard"), jet.pt() - (rhoReference * jet.area()), ptTT / pTHat, weight); } - registry.fill(HIST("hReferenceLeadingTrack"), jet.pt(), dphi, leadingPT, weight); } } } + registry.fill(HIST("hTracksvsJets"), leadingTrackPt, leadingJetPt, pTHat, weight); } template - void fillMCPHistograms(T const& jets, W const& /*jetsWTA*/, U const& particles, float weight = 1.0) + void fillMCPHistograms(T const& jets, W const& jetsWTA, U const& particles, float weight = 1.0, float pTHat = 999.0) { bool isSigCol; std::vector phiTTAr; + std::vector ptTTAr; double phiTT = 0; + double ptTT = 0; int trigNumber = 0; int nTT = 0; - double leadingPT = 0; - float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - + double leadingPartPt = 0; + double leadingJetPt = 0; float dice = rand->Rndm(); if (dice < fracSig) isSigCol = true; @@ -280,6 +368,16 @@ struct JetHadronRecoil { isSigCol = false; for (const auto& particle : particles) { + if (particle.pt() > leadingPartPt) { + leadingPartPt = particle.pt(); + } + if (particle.pt() > pTHatTrackMaxMCD * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } auto pdgParticle = pdg->GetParticle(particle.pdgCode()); if (!pdgParticle) { continue; @@ -289,161 +387,213 @@ struct JetHadronRecoil { } if (isSigCol && particle.pt() < ptTTsigMax && particle.pt() > ptTTsigMin) { phiTTAr.push_back(particle.phi()); + ptTTAr.push_back(particle.pt()); nTT++; } if (!isSigCol && particle.pt() < ptTTrefMax && particle.pt() > ptTTrefMin) { phiTTAr.push_back(particle.phi()); + ptTTAr.push_back(particle.pt()); nTT++; } registry.fill(HIST("hPtPart"), particle.pt(), weight); registry.fill(HIST("hEtaPart"), particle.eta(), weight); registry.fill(HIST("hPhiPart"), particle.phi(), weight); + registry.fill(HIST("hPart3D"), particle.pt(), particle.eta(), particle.phi(), weight); + registry.fill(HIST("hPtPartPtHard"), particle.pt(), particle.pt() / pTHat, weight); } if (nTT > 0) { trigNumber = rand->Integer(nTT); phiTT = phiTTAr[trigNumber]; + ptTT = ptTTAr[trigNumber]; if (isSigCol) { registry.fill(HIST("hNtrig"), 1.5, weight); - registry.fill(HIST("hJetSignalMultiplicity"), jets.size(), weight); registry.fill(HIST("hSigEventTriggers"), nTT, weight); + registry.fill(HIST("hSignalTriggersPtHard"), ptTT / pTHat, weight); } if (!isSigCol) { registry.fill(HIST("hNtrig"), 0.5, weight); - registry.fill(HIST("hJetReferenceMultiplicity"), jets.size(), weight); registry.fill(HIST("hRefEventTriggers"), nTT, weight); + registry.fill(HIST("hReferenceTriggersPtHard"), ptTT / pTHat, weight); } } for (const auto& jet : jets) { - if (jet.tracksIds().size() == 1) { - continue; + if (jet.pt() > leadingJetPt) { + leadingJetPt = jet.pt(); } if (jet.pt() > pTHatMaxMCP * pTHat) { - continue; + if (outlierRejectEvent) { + return; + } else { + continue; + } + } + for (const auto& constituent : jet.template tracks_as()) { + registry.fill(HIST("hConstituents3D"), constituent.pt(), constituent.eta(), constituent.phi()); } registry.fill(HIST("hJetPt"), jet.pt(), weight); registry.fill(HIST("hJetEta"), jet.eta(), weight); registry.fill(HIST("hJetPhi"), jet.phi(), weight); - for (const auto& jetWTA : jet.template matchedJetGeo_as>()) { - double deltaPhi = RecoDecay::constrainAngle(jetWTA.phi() - jet.phi(), -o2::constants::math::PI); - double deltaEta = jetWTA.eta() - jet.eta(); - double dR = RecoDecay::sqrtSumOfSquares(deltaPhi, deltaEta); - registry.fill(HIST("hDeltaRPart"), dR, weight); - registry.fill(HIST("hDeltaRpTPart"), jet.pt(), dR, weight); - } + registry.fill(HIST("hJet3D"), jet.pt(), jet.eta(), jet.phi(), weight); + + double dR = getWTAaxisDifference(jet, jetsWTA, particles); + + registry.fill(HIST("hDeltaRPart"), dR, weight); + registry.fill(HIST("hDeltaRpTPart"), jet.pt(), dR, weight); if (nTT > 0) { float dphi = RecoDecay::constrainAngle(jet.phi() - phiTT); if (isSigCol) { - for (const auto& jetWTA : jet.template matchedJetGeo_as>()) { - double deltaPhi = RecoDecay::constrainAngle(jetWTA.phi() - jet.phi(), -o2::constants::math::PI); - double deltaEta = jetWTA.eta() - jet.eta(); - double dR = RecoDecay::sqrtSumOfSquares(deltaPhi, deltaEta); - if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hDeltaRpTSignalPart"), jet.pt(), dR, weight); - registry.fill(HIST("hDeltaRSignalPart"), dR, weight); - } - registry.fill(HIST("hDeltaRpTDPhiSignalPart"), jet.pt(), dphi, dR, weight); + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hDeltaRpTSignalPart"), jet.pt(), dR, weight); + registry.fill(HIST("hDeltaRSignalPart"), dR, weight); } + registry.fill(HIST("hDeltaRpTDPhiSignalPart"), jet.pt(), dphi, dR, weight); registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt(), weight); if (std::abs(dphi - o2::constants::math::PI) < 0.6) { registry.fill(HIST("hSignalPt"), jet.pt(), weight); + registry.fill(HIST("hSignalPtHard"), jet.pt(), ptTT / pTHat, weight); } - registry.fill(HIST("hJetSignalConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size(), weight); - for (const auto& constituent : jet.template tracks_as()) { - if (constituent.pt() > leadingPT) { - leadingPT = constituent.pt(); - } - registry.fill(HIST("hJetSignalConstituentPt"), jet.pt(), dphi, constituent.pt(), weight); - } - registry.fill(HIST("hSignalLeadingTrack"), jet.pt(), dphi, leadingPT, weight); } if (!isSigCol) { - for (const auto& jetWTA : jet.template matchedJetGeo_as>()) { - double deltaPhi = RecoDecay::constrainAngle(jetWTA.phi() - jet.phi(), -o2::constants::math::PI); - double deltaEta = jetWTA.eta() - jet.eta(); - double dR = RecoDecay::sqrtSumOfSquares(deltaPhi, deltaEta); - if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hDeltaRpTPartReference"), jet.pt(), dR, weight); - registry.fill(HIST("hDeltaRPartReference"), dR, weight); - } - registry.fill(HIST("hDeltaRpTDPhiReferencePart"), jet.pt(), dphi, dR, weight); + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hDeltaRpTPartReference"), jet.pt(), dR, weight); + registry.fill(HIST("hDeltaRPartReference"), dR, weight); } + registry.fill(HIST("hDeltaRpTDPhiReferencePart"), jet.pt(), dphi, dR, weight); registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt(), weight); if (std::abs(dphi - o2::constants::math::PI) < 0.6) { registry.fill(HIST("hReferencePt"), jet.pt(), weight); + registry.fill(HIST("hReferencePtHard"), jet.pt(), ptTT / pTHat, weight); } - registry.fill(HIST("hJetReferenceConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size(), weight); - for (const auto& constituent : jet.template tracks_as()) { - if (constituent.pt() > leadingPT) { - leadingPT = constituent.pt(); - } - registry.fill(HIST("hJetReferenceConstituentPt"), jet.pt(), dphi, constituent.pt(), weight); - } - registry.fill(HIST("hReferenceLeadingTrack"), jet.pt(), dphi, leadingPT, weight); } } } + registry.fill(HIST("hPartvsJets"), leadingPartPt, leadingJetPt, pTHat, weight); } - template - void fillMatchedHistograms(T const& jetBase, V const& mcdjetsWTA, W const& mcpjetsWTA, U const&, float weight = 1.0) + template + void fillMatchedHistograms(T const& jetsBase, V const& mcdjetsWTA, W const& mcpjetsWTA, U const&, X const& tracks, Y const& particles, float weight = 1.0, float rho = 0.0, float pTHat = 999.0) { - double dR = 0; - double dRp = 0; + for (const auto& jetBase : jetsBase) { + double dR = 0; + double dRp = 0; + + if (jetBase.pt() > pTHatMaxMCD * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } - float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jetBase.tracksIds().size() == 1) { - return; - } - if (jetBase.pt() > pTHatMaxMCD * pTHat) { - return; + dR = getWTAaxisDifference(jetBase, mcdjetsWTA, tracks, true); + + if (jetBase.has_matchedJetGeo()) { + for (const auto& jetTag : jetBase.template matchedJetGeo_as>()) { + if (jetTag.pt() > pTHatMaxMCP * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } + + dRp = getWTAaxisDifference(jetTag, mcpjetsWTA, particles, true); + + registry.fill(HIST("hPtMatched"), jetBase.pt() - (rho * jetBase.area()), jetTag.pt(), weight); + registry.fill(HIST("hPhiMatched"), jetBase.phi(), jetTag.phi(), weight); + registry.fill(HIST("hPtResolution"), jetTag.pt(), (jetTag.pt() - (jetBase.pt() - (rho * jetBase.area()))) / jetTag.pt(), weight); + registry.fill(HIST("hPhiResolution"), jetTag.pt(), jetTag.phi() - jetBase.phi(), weight); + registry.fill(HIST("hDeltaRMatched"), dR, dRp, weight); + registry.fill(HIST("hDeltaRResolution"), jetTag.pt(), dRp - dR, weight); + registry.fill(HIST("hFullMatching"), jetBase.pt() - (rho * jetBase.area()), jetTag.pt(), jetBase.phi(), jetTag.phi(), dR, dRp, weight); + registry.fill(HIST("hPtMatched1d"), jetTag.pt(), weight); + registry.fill(HIST("hDeltaRMatched1d"), dRp, weight); + } + } } + } + + template + void fillRecoilJetMatchedHistograms(T const& jetsBase, V const& mcdjetsWTA, W const& mcpjetsWTA, U const&, X const& tracks, Y const& particles, float weight = 1.0, float rho = 0.0, float pTHat = 999.0) + { + std::vector phiTTAr; + std::vector phiTTArPart; + double phiTT = 0; + double phiTTPart = 0; + int trigNumber = 0; + int nTT = 0; - for (const auto& mcdjetWTA : mcdjetsWTA) { - double djet = RecoDecay::sqrtSumOfSquares(RecoDecay::constrainAngle(jetBase.phi() - mcdjetWTA.phi(), -o2::constants::math::PI), jetBase.eta() - mcdjetWTA.eta()); - if (mcdjetWTA.tracksIds().size() == 1) { + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { continue; } - if (mcdjetWTA.pt() > pTHatMaxMCD * pTHat) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } - if (djet < 0.6 * jetR) { - dR = djet; - break; + if (track.pt() > pTHatTrackMaxMCD * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } + if (track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) { + phiTTAr.push_back(track.phi()); + nTT++; + auto particle = track.template mcParticle_as(); + phiTTArPart.push_back(particle.phi()); } } - if (jetBase.has_matchedJetGeo()) { - for (const auto& jetTag : jetBase.template matchedJetGeo_as>()) { - if (jetTag.tracksIds().size() == 1) { - continue; - } - if (jetTag.pt() > pTHatMaxMCP * pTHat) { + if (nTT > 0) { + trigNumber = rand->Integer(nTT); + phiTT = phiTTAr[trigNumber]; + phiTTPart = phiTTAr[trigNumber]; + } else { + return; + } + + for (const auto& jetBase : jetsBase) { + double dR = 0; + double dRp = 0; + + if (jetBase.pt() > pTHatMaxMCD * pTHat) { + if (outlierRejectEvent) { + return; + } else { continue; } - for (const auto& mcpjetWTA : mcpjetsWTA) { - double djetp = RecoDecay::sqrtSumOfSquares(RecoDecay::constrainAngle(jetTag.phi() - mcpjetWTA.phi(), -o2::constants::math::PI), jetTag.eta() - mcpjetWTA.eta()); - if (mcpjetWTA.tracksIds().size() == 1) { - continue; - } - if (mcpjetWTA.pt() > pTHatMaxMCP * pTHat) { - continue; + } + + float dphi = RecoDecay::constrainAngle(jetBase.phi() - phiTT); + dR = getWTAaxisDifference(jetBase, mcdjetsWTA, tracks, true); + + if (jetBase.has_matchedJetGeo()) { + for (const auto& jetTag : jetBase.template matchedJetGeo_as>()) { + if (jetTag.pt() > pTHatMaxMCP * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } } - if (djetp < 0.6 * jetR) { - dRp = djetp; - break; + + float dphip = RecoDecay::constrainAngle(jetTag.phi() - phiTTPart); + dRp = getWTAaxisDifference(jetTag, mcpjetsWTA, particles, true); + if ((std::abs(dphi - o2::constants::math::PI) < 0.6) || (std::abs(dphip - o2::constants::math::PI) < 0.6)) { + registry.fill(HIST("hPtMatched"), jetBase.pt() - (rho * jetBase.area()), jetTag.pt(), weight); + registry.fill(HIST("hPhiMatched"), dphi, dphip, weight); + registry.fill(HIST("hPtResolution"), jetTag.pt(), (jetTag.pt() - (jetBase.pt() - (rho * jetBase.area()))) / jetTag.pt(), weight); + registry.fill(HIST("hPhiResolution"), jetTag.pt(), dphip - dphi, weight); + registry.fill(HIST("hDeltaRMatched"), dR, dRp, weight); + registry.fill(HIST("hDeltaRResolution"), jetTag.pt(), dRp - dR, weight); + registry.fill(HIST("hFullMatching"), jetBase.pt() - (rho * jetBase.area()), jetTag.pt(), dphi, dphip, dR, dRp, weight); + registry.fill(HIST("hPtMatched1d"), jetTag.pt(), weight); + registry.fill(HIST("hDeltaRMatched1d"), dRp, weight); } } - registry.fill(HIST("hPtMatched"), jetBase.pt(), jetTag.pt(), weight); - registry.fill(HIST("hPhiMatched"), jetBase.phi(), jetTag.phi(), weight); - registry.fill(HIST("hPtResolution"), jetTag.pt(), (jetTag.pt() - jetBase.pt()) / jetTag.pt(), weight); - registry.fill(HIST("hPhiResolution"), jetTag.pt(), jetTag.phi() - jetBase.phi(), weight); - registry.fill(HIST("hDeltaRMatched"), dR, dRp, weight); - registry.fill(HIST("hDeltaRResolution"), jetTag.pt(), dRp - dR, weight); - registry.fill(HIST("hFullMatching"), jetBase.pt(), jetTag.pt(), jetBase.phi(), jetTag.phi(), dR, dRp, weight); - registry.fill(HIST("hPtMatched1d"), jetTag.pt(), weight); - registry.fill(HIST("hDeltaRMatched1d"), dRp, weight); } } } @@ -453,7 +603,7 @@ struct JetHadronRecoil { soa::Filtered> const& jetsWTA, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { @@ -464,174 +614,341 @@ struct JetHadronRecoil { } PROCESS_SWITCH(JetHadronRecoil, processData, "process data", true); - void processMCD(soa::Filtered::iterator const& collision, + void processDataWithRhoSubtraction(soa::Filtered>::iterator const& collision, + soa::Filtered> const& jets, + soa::Filtered> const& jetsWTA, + soa::Filtered const& tracks) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ()); + fillHistograms(jets, jetsWTA, tracks, 1.0, collision.rho()); + } + PROCESS_SWITCH(JetHadronRecoil, processDataWithRhoSubtraction, "process data with rho subtraction", false); + + void processMCD(soa::Filtered>::iterator const& collision, + aod::JMcCollisions const&, soa::Filtered> const& jets, soa::Filtered> const& jetsWTA, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { return; } if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } registry.fill(HIST("hZvtxSelected"), collision.posZ()); - fillHistograms(jets, jetsWTA, tracks); + fillHistograms(jets, jetsWTA, tracks, 1.0, 0.0, collision.mcCollision().ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processMCD, "process MC detector level", false); + void processMCDWithRhoSubtraction(soa::Filtered>::iterator const& collision, + aod::JMcCollisions const&, + soa::Filtered> const& jets, + soa::Filtered> const& jetsWTA, + soa::Filtered const& tracks) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ()); + fillHistograms(jets, jetsWTA, tracks, 1.0, collision.rho(), collision.mcCollision().ptHard()); + } + PROCESS_SWITCH(JetHadronRecoil, processMCDWithRhoSubtraction, "process MC detector level with rho subtraction", false); + void processMCDWeighted(soa::Filtered>::iterator const& collision, aod::JMcCollisions const&, soa::Filtered> const& jets, soa::Filtered> const& jetsWTA, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { return; } if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.mcCollision().weight()); - fillHistograms(jets, jetsWTA, tracks, collision.mcCollision().weight()); + fillHistograms(jets, jetsWTA, tracks, collision.mcCollision().weight(), 0.0, collision.mcCollision().ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processMCDWeighted, "process MC detector level with event weights", false); + void processMCDWeightedWithRhoSubtraction(soa::Filtered>::iterator const& collision, + aod::JMcCollisions const&, + soa::Filtered> const& jets, + soa::Filtered> const& jetsWTA, + soa::Filtered const& tracks) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.mcCollision().weight()); + fillHistograms(jets, jetsWTA, tracks, collision.mcCollision().weight(), collision.rho(), collision.mcCollision().ptHard()); + } + PROCESS_SWITCH(JetHadronRecoil, processMCDWeightedWithRhoSubtraction, "process MC detector level with event weights and rho subtraction", false); + void processMCP(aod::JetMcCollision const& collision, soa::Filtered> const& jets, soa::Filtered> const& jetsWTA, - aod::JetParticles const& particles) + soa::Filtered const& particles) { if (std::abs(collision.posZ()) > vertexZCut) { return; } + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + if (collision.ptHard() < pTHatMinEvent) { + return; + } registry.fill(HIST("hZvtxSelected"), collision.posZ()); - fillMCPHistograms(jets, jetsWTA, particles); + fillMCPHistograms(jets, jetsWTA, particles, 1.0, collision.ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processMCP, "process MC particle level", false); void processMCPWeighted(aod::JetMcCollision const& collision, soa::Filtered> const& jets, soa::Filtered> const& jetsWTA, - aod::JetParticles const& particles) + soa::Filtered const& particles) { if (std::abs(collision.posZ()) > vertexZCut) { return; } + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + if (collision.ptHard() < pTHatMinEvent) { + return; + } registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.weight()); - fillMCPHistograms(jets, jetsWTA, particles, collision.weight()); + fillMCPHistograms(jets, jetsWTA, particles, collision.weight(), collision.ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processMCPWeighted, "process MC particle level with event weights", false); - void processJetsMCPMCDMatched(soa::Filtered::iterator const& collision, + void processJetsMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Filtered> const& mcdjets, soa::Filtered> const& mcdjetsWTA, soa::Filtered> const& mcpjetsWTA, - aod::JetTracks const&, - aod::JetParticles const&, + aod::JetTracks const& tracks, + aod::JetParticles const& particles, aod::JetMcCollisions const&, soa::Filtered> const& mcpjets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } registry.fill(HIST("hZvtxSelected"), collision.posZ()); const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(partJetsPerCollision, collision.mcCollisionId()); - for (const auto& mcdjet : mcdjets) { - fillMatchedHistograms(mcdjet, mcdjetsWTA, mcpjetsWTACut, mcpjets); - } + fillMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles); } PROCESS_SWITCH(JetHadronRecoil, processJetsMCPMCDMatched, "process MC matched (inc jets)", false); - void processJetsMCPMCDMatchedWeighted(soa::Filtered::iterator const& collision, - soa::Filtered> const& mcdjets, + void processJetsMCPMCDMatchedWithRhoSubtraction(soa::Filtered>::iterator const& collision, + soa::Filtered> const& mcdjets, + soa::Filtered> const& mcdjetsWTA, + soa::Filtered> const& mcpjetsWTA, + aod::JetTracks const& tracks, + aod::JetParticles const& particles, + aod::JetMcCollisions const&, + soa::Filtered> const& mcpjets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ()); + const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(partJetsPerCollision, collision.mcCollisionId()); + fillMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles, 1.0, 0.0, collision.mcCollision().ptHard()); + } + PROCESS_SWITCH(JetHadronRecoil, processJetsMCPMCDMatchedWithRhoSubtraction, "process MC matched (inc jets) with rho subtraction", false); + + void processJetsMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, + soa::Filtered> const& mcdjets, soa::Filtered> const& mcdjetsWTA, soa::Filtered> const& mcpjetsWTA, - aod::JetTracks const&, - aod::JetParticles const&, + aod::JetTracks const& tracks, + aod::JetParticles const& particles, aod::JetMcCollisions const&, - soa::Filtered> const& mcpjets) + soa::Filtered> const& mcpjets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } registry.fill(HIST("hZvtxSelected"), collision.posZ()); const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(partJetsPerCollision, collision.mcCollisionId()); - for (const auto& mcdjet : mcdjets) { - fillMatchedHistograms(mcdjet, mcdjetsWTA, mcpjetsWTACut, mcpjets, mcdjet.eventWeight()); - } + fillMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles, collision.mcCollision().weight(), 0.0, collision.mcCollision().ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processJetsMCPMCDMatchedWeighted, "process MC matched with event weights (inc jets)", false); - void processRecoilJetsMCPMCDMatched(soa::Filtered::iterator const& collision, + void processJetsMCPMCDMatchedWeightedWithRhoSubtraction(soa::Filtered>::iterator const& collision, + soa::Filtered> const& mcdjets, + soa::Filtered> const& mcdjetsWTA, + soa::Filtered> const& mcpjetsWTA, + aod::JetTracks const& tracks, + aod::JetParticles const& particles, + aod::JetMcCollisions const&, + soa::Filtered> const& mcpjets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ()); + const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(partJetsPerCollision, collision.mcCollisionId()); + fillMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles, collision.mcCollision().weight(), collision.rho(), collision.mcCollision().ptHard()); + } + PROCESS_SWITCH(JetHadronRecoil, processJetsMCPMCDMatchedWeightedWithRhoSubtraction, "process MC matched with event weights (inc jets) and rho subtraction", false); + + void processRecoilJetsMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Filtered> const& mcdjets, soa::Filtered> const& mcdjetsWTA, soa::Filtered> const& mcpjetsWTA, - aod::JetTracks const& tracks, - aod::JetParticles const&, + soa::Filtered const& tracks, + soa::Filtered const& particles, aod::JetMcCollisions const&, soa::Filtered> const& mcpjets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } registry.fill(HIST("hZvtxSelected"), collision.posZ()); const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(partJetsPerCollision, collision.mcCollisionId()); - bool ishJetEvent = false; - for (const auto& track : tracks) { - if (track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) { - ishJetEvent = true; - break; - } - } - if (ishJetEvent) { - for (const auto& mcdjet : mcdjets) { - fillMatchedHistograms(mcdjet, mcdjetsWTA, mcpjetsWTACut, mcpjets); - } - } + fillRecoilJetMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles, 1.0, 0.0, collision.mcCollision().ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processRecoilJetsMCPMCDMatched, "process MC matched (recoil jets)", false); - void processRecoilJetsMCPMCDMatchedWeighted(soa::Filtered::iterator const& collision, - soa::Filtered> const& mcdjets, + void processRecoilJetsMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, + soa::Filtered> const& mcdjets, soa::Filtered> const& mcdjetsWTA, soa::Filtered> const& mcpjetsWTA, - aod::JetTracks const& tracks, - aod::JetParticles const&, + soa::Filtered const& tracks, + soa::Filtered const& particles, aod::JetMcCollisions const&, - soa::Filtered> const& mcpjets) + soa::Filtered> const& mcpjets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } + if (collision.mcCollision().ptHard() < pTHatMinEvent) { + return; + } registry.fill(HIST("hZvtxSelected"), collision.posZ()); const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(partJetsPerCollision, collision.mcCollisionId()); - bool ishJetEvent = false; - for (const auto& track : tracks) { - if (track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) { - ishJetEvent = true; - break; + fillRecoilJetMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles, collision.mcCollision().weight(), 0.0, collision.mcCollision().ptHard()); + } + PROCESS_SWITCH(JetHadronRecoil, processRecoilJetsMCPMCDMatchedWeighted, "process MC matched with event weights (recoil jets)", false); + + template + double getWTAaxisDifference(T const& jet, U const& jetsWTA, X const& /*tracks or particles*/, bool isMatched = false) + { + double deltaPhi = -1; + double deltaEta = -1; + double deltaY = -1; + double dR = -1; + if (wtaMethod == 0) { + // get WTA matched jet - should just be one jet matched geometrically + if (isMatched) { + // response - requires alternative method + for (const auto& jetWTA : jetsWTA) { + double djetp = RecoDecay::sqrtSumOfSquares(RecoDecay::constrainAngle(jet.phi() - jetWTA.phi(), -o2::constants::math::PI), jet.eta() - jetWTA.eta()); + if (djetp < 0.6 * jetR) { + dR = djetp; + break; + } + } + } else { + // MCP or MCD + for (const auto& jetWTA : jet.template matchedJetGeo_as>()) { + deltaPhi = RecoDecay::constrainAngle(jetWTA.phi() - jet.phi(), -o2::constants::math::PI); + deltaEta = jetWTA.eta() - jet.eta(); + dR = RecoDecay::sqrtSumOfSquares(deltaPhi, deltaEta); + } } - } - if (ishJetEvent) { - for (const auto& mcdjet : mcdjets) { - fillMatchedHistograms(mcdjet, mcdjetsWTA, mcpjetsWTACut, mcpjets, mcdjet.eventWeight()); + } else if (wtaMethod == 1) { + // recluster jet + jetConstituents.clear(); + for (auto& jetConstituent : jet.template tracks_as()) { + fastjetutilities::fillTracks(jetConstituent, jetConstituents, jetConstituent.globalIndex()); } - } + jetReclustered.clear(); + fastjet::ClusterSequenceArea clusterSeq(jetReclusterer.findJets(jetConstituents, jetReclustered)); + jetReclustered = sorted_by_pt(jetReclustered); + + deltaPhi = RecoDecay::constrainAngle(jet.phi() - jetReclustered[0].phi(), -o2::constants::math::PI); + deltaY = jet.y() - jetReclustered[0].rap(); + dR = RecoDecay::sqrtSumOfSquares(deltaPhi, deltaY); + LOG(debug) << "orig. jet n const = " << jet.tracksIds().size() << " pt = " << jet.pt() << " eta = " << jet.eta() << " phi = " << jet.phi(); + LOG(debug) << "recl. jet n const = " << clusterSeq.constituents(jetReclustered[0]).size() << " pt = " << jetReclustered[0].pt() << " eta = " << jetReclustered[0].eta() << " phi = " << jetReclustered[0].phi(); + LOG(debug) << "distance = " << dR; + } + return dR; } - PROCESS_SWITCH(JetHadronRecoil, processRecoilJetsMCPMCDMatchedWeighted, "process MC matched with event weights (recoil jets)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGJE/Tasks/jetLundReclustering.cxx b/PWGJE/Tasks/jetLundReclustering.cxx index 4b43b0ad2a2..b78c6f2b6ef 100644 --- a/PWGJE/Tasks/jetLundReclustering.cxx +++ b/PWGJE/Tasks/jetLundReclustering.cxx @@ -17,34 +17,30 @@ // Task performing jet reclustering and producing primary Lund Plane histograms // -#include -#include -#include -#include - -#include "fastjet/contrib/LundGenerator.hh" -#include "fastjet/PseudoJet.hh" -#include "fastjet/ClusterSequenceArea.hh" +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include "TDatabasePDG.h" +#include +#include +#include +#include -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/PseudoJet.hh" +#include -#include "Common/Core/RecoDecay.h" +#include +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/DataModel/JetSubstructure.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include using namespace o2; using namespace o2::track; @@ -67,11 +63,11 @@ struct JetLundReclustering { Configurable jet_max_eta{"jet_max_eta", 0.5, "maximum jet eta"}; Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; - int eventSelection = -1; + std::vector eventSelectionBits; void init(InitContext const&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); registry.add("PrimaryLundPlane_kT", "Primary Lund 3D plane;ln(R/Delta);ln(k_{t}/GeV);{p}_{t}", {HistType::kTH3F, {{100, 0, 10}, {100, -10, 10}, {20, 0, 200}}}); registry.add("PrimaryLundPlane_z", "Primary Lund 3D plane;ln(R/Delta);ln(1/z);{p}_{t}", {HistType::kTH3F, {{100, 0, 10}, {100, 0, 10}, {20, 0, 200}}}); @@ -122,7 +118,7 @@ struct JetLundReclustering { soa::Filtered> const& jets, aod::JetTracks const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (const auto& jet : jets) { diff --git a/PWGJE/Tasks/jetMatchingQA.cxx b/PWGJE/Tasks/jetMatchingQA.cxx index e752b47e2a5..6770d42e47e 100644 --- a/PWGJE/Tasks/jetMatchingQA.cxx +++ b/PWGJE/Tasks/jetMatchingQA.cxx @@ -15,14 +15,21 @@ /// \author Jochen Klein /// \author Aimeric Lanodu -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "PWGJE/DataModel/Jet.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include +#include + +#include + +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; diff --git a/PWGJE/Tasks/jetPlanarFlow.cxx b/PWGJE/Tasks/jetPlanarFlow.cxx index 9c2769978ca..673d4eebffe 100644 --- a/PWGJE/Tasks/jetPlanarFlow.cxx +++ b/PWGJE/Tasks/jetPlanarFlow.cxx @@ -14,25 +14,30 @@ /// \author Nima Zardoshti // -#include +#include "JetDerivedDataUtilities.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Framework/Logger.h" -#include "Framework/HistogramRegistry.h" - -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/FastJetUtilities.h" #include "PWGJE/Core/JetFindingUtilities.h" #include "PWGJE/Core/JetSubstructureUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include + +#include + #include "fastjet/contrib/AxesDefinition.hh" -#include "fastjet/contrib/MeasureDefinition.hh" + +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -106,7 +111,7 @@ struct JetPlanarFlowTask { Configurable zCutSD{"zCutSD", 0.10, "SoftDrop z cut"}; int trackSelection = -1; - int eventSelection = -1; + std::vector eventSelectionBits; std::string particleSelection; uint32_t precisionMask; @@ -120,13 +125,13 @@ struct JetPlanarFlowTask { void init(o2::framework::InitContext&) { trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); particleSelection = static_cast(particleSelections); precisionMask = 0xFFFFFC00; } // jet pT, tau2/tau1, jetdR, track pt, phi', eta', dR, isInJet - Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); template void fillHistograms(T const& collision, U const& jet, V const& tracks) @@ -282,7 +287,7 @@ struct JetPlanarFlowTask { soa::Join const& jets, aod::JetTracks const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto const& jet : jets) { @@ -300,7 +305,7 @@ struct JetPlanarFlowTask { soa::Join const& jets, aod::JetTracks const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto const& jet : jets) { @@ -318,7 +323,7 @@ struct JetPlanarFlowTask { soa::Join const& jets, aod::JetTracksSub const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto const& jet : jets) { @@ -336,7 +341,7 @@ struct JetPlanarFlowTask { soa::Join const& jets, aod::JetTracks const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto const& jet : jets) { diff --git a/PWGJE/Tasks/jetShape.cxx b/PWGJE/Tasks/jetShape.cxx new file mode 100644 index 00000000000..15dfd574c97 --- /dev/null +++ b/PWGJE/Tasks/jetShape.cxx @@ -0,0 +1,359 @@ +// 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. + +/// \file jetShape.cxx +/// \author Yuto Nishida +/// \brief Task for measuring the dependence of the jet shape function rho(r) on the distance r from the jet axis. + +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct JetShapeTask { + + Configurable nBinsNSigma{"nBinsNSigma", 101, "Number of nsigma bins"}; + Configurable nSigmaMin{"nSigmaMin", -10.1f, "Min value of nsigma"}; + Configurable nSigmaMax{"nSigmaMax", 10.1f, "Max value of nsigma"}; + Configurable nBinsPForDedx{"nBinsPForDedx", 700, "Number of p bins"}; + Configurable nBinsPForBeta{"nBinsPForBeta", 500, "Number of pT bins"}; + Configurable nBinsTpcDedx{"nBinsTpcDedx", 500, "Number of DEdx bins"}; + Configurable nBinsTofBeta{"nBinsTofBeta", 350, "Number of Beta bins"}; + Configurable pMax{"pMax", 7.0f, "Max value of p"}; + Configurable ptMax{"ptMax", 5.0f, "Max value of pT"}; + Configurable nBinsDistance{"nBinsDistance", 7, "Number of distance bins"}; + Configurable distanceMax{"distanceMax", 0.7f, "Max value of distance"}; + Configurable nSigmaTofCut{"nSigmaTofCut", 2.0f, "Number of sigma cut for TOF PID"}; + Configurable tpcNSigmaPrMin{"tpcNSigmaPrMin", -3.5f, "Min value of tpcNsigmaProton"}; + Configurable tpcNSigmaPrMax{"tpcNSigmaPrMax", 0.5f, "Max value of tpcNsigmaProton"}; + Configurable tpcNSigmaPiMin{"tpcNSigmaPiMin", -0.5f, "Min value of tpcNsigmaPion"}; + Configurable tpcNSigmaPiMax{"tpcNSigmaPiMax", 3.5f, "Max value of tpcNsigmaPion"}; + + HistogramRegistry registry{"registry", + {{"tpcTofPi", "tpcTofPi", {HistType::kTHnSparseD, {{35, 0, pMax}, {nBinsNSigma, nSigmaMin, nSigmaMax}, {nBinsDistance, 0, distanceMax}}}}, + {"tpcTofPr", "tpcTofPr", {HistType::kTHnSparseD, {{35, 0, pMax}, {nBinsNSigma, nSigmaMin, nSigmaMax}, {nBinsDistance, 0, distanceMax}}}}, + {"tpcPi", "tpcPi", {HistType::kTH2F, {{70, 0, pMax}, {nBinsNSigma, nSigmaMin, nSigmaMax}}}}, + {"tofPi", "tofPi", {HistType::kTH2F, {{50, 0, ptMax}, {nBinsNSigma, nSigmaMin, nSigmaMax}}}}, + {"tpcPr", "tpcPr", {HistType::kTH2F, {{70, 0, pMax}, {nBinsNSigma, nSigmaMin, nSigmaMax}}}}, + {"tofPr", "tofPr", {HistType::kTH2F, {{50, 0, ptMax}, {nBinsNSigma, nSigmaMin, nSigmaMax}}}}, + {"tpcDedx", "tpcDedx", {HistType::kTHnSparseD, {{nBinsPForDedx, 0, pMax}, {nBinsTpcDedx, 0, 1000}, {nBinsDistance, 0, distanceMax}}}}, + {"tpcDedxOutOfJet", "tpcDedxOutOfJet", {HistType::kTH2F, {{nBinsPForDedx, 0, pMax}, {nBinsTpcDedx, 0, 1000}}}}, + {"tofBeta", "tofBeta", {HistType::kTHnSparseD, {{nBinsPForBeta, 0, pMax}, {nBinsTofBeta, 0.4, 1.1}, {nBinsDistance, 0, distanceMax}}}}, + {"pVsPtForProton", "pVsPtForProton", {HistType::kTHnSparseD, {{70, 0, pMax}, {50, 0, ptMax}, {nBinsDistance, 0, distanceMax}}}}, + {"pVsPtForPion", "pVsPtPion", {HistType::kTHnSparseD, {{70, 0, pMax}, {50, 0, ptMax}, {nBinsDistance, 0, distanceMax}}}}, + {"tofMass", "tofMass", {HistType::kTH1F, {{300, 0, 3}}}}, + {"trackPhi", "trackPhi", {HistType::kTH1F, {{80, -1, 7}}}}, + {"trackEta", "trackEta", {HistType::kTH1F, {{100, -1, 1}}}}, + {"trackTpcNClsCrossedRows", "trackTpcNClsCrossedRows", {HistType::kTH1F, {{50, 0, 200}}}}, + {"trackDcaXY", "trackDcaXY", {HistType::kTH1F, {{40, -10, 10}}}}, + {"trackItsChi2NCl", "trackItsChi2NCl", {HistType::kTH1F, {{60, 0, 30}}}}, + {"trackTpcChi2NCl", "trackTpcChi2NCl", {HistType::kTH1F, {{100, 0, 50}}}}, + {"trackTpcNClsFound", "trackTpcNClsFound", {HistType::kTH1F, {{100, 0, 200}}}}, + {"trackItsNCls", "trackItsNCls", {HistType::kTH1F, {{10, 0, 10}}}}, + {"jetPt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"jetEta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, + {"jetPhi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, + {"area", "area", {HistType::kTH1F, {{200, 0, 4}}}}, + {"rho", "rho", {HistType::kTH1F, {{300, 0, 300}}}}, + {"ptCorr", "Corrected jet pT; p_{T}^{corr} (GeV/c); Counts", {HistType::kTH1F, {{200, 0, 200}}}}, + {"ptCorrVsDistance", "ptcorr_vs_distance", {HistType::kTH2F, {{70, 0, 0.7}, {100, 0, 100}}}}, + {"distanceVsTrackpt", "trackpt_vs_distance", {HistType::kTH2F, {{70, 0, 0.7}, {100, 0, 100}}}}, + {"ptSum", "ptSum", {HistType::kTH2F, {{14, 0, 0.7}, {300, 0, 300}}}}, + {"ptSumBg1", "ptSumBg1", {HistType::kTH2F, {{14, 0, 0.7}, {300, 0, 300}}}}, + {"ptSumBg2", "ptSumBg2", {HistType::kTH2F, {{14, 0, 0.7}, {300, 0, 300}}}}, + {"event/vertexz", ";Vtx_{z} (cm);Entries", {HistType::kTH1F, {{100, -20, 20}}}}, + {"ptVsCentrality", "ptvscentrality", {HistType::kTH2F, {{100, 0, 100}, {300, 0, 300}}}}}}; + + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + + Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; + Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; + + Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + + Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; + Configurable leadingConstituentPtMin{"leadingConstituentPtMin", 5.0, "minimum pT selection on jet constituent"}; + Configurable leadingConstituentPtMax{"leadingConstituentPtMax", 9999.0, "maximum pT selection on jet constituent"}; + + // for jet shape + Configurable> distanceCategory{"distanceCategory", {0.00f, 0.05f, 0.10f, 0.15f, 0.20f, 0.25f, 0.30f, 0.35f, 0.40f, 0.45f, 0.50f, 0.55f, 0.60f, 0.65f, 0.70f}, "distance of category"}; + + // for ppi production + Configurable etaTrUp{"etaTrUp", 0.7f, "maximum track eta"}; + Configurable dcaxyMax{"dcaxyMax", 2.0f, "mximum DCA xy"}; + Configurable chi2ItsMax{"chi2ItsMax", 15.0f, "its chi2 cut"}; + Configurable chi2TpcMax{"chi2TpcMax", 4.0f, "tpc chi2 cut"}; + Configurable nclItsMin{"nclItsMin", 2.0f, "its # of cluster cut"}; + Configurable nclTpcMin{"nclTpcMin", 100.0f, "tpc # if cluster cut"}; + Configurable nclcrossTpcMin{"nclcrossTpcMin", 70.0f, "tpc # of crossedRows cut"}; + + Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; + + std::vector eventSelectionBits; + int trackSelection = -1; + std::vector triggerMaskBits; + + void init(o2::framework::InitContext&) + { + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); + } + + template + bool isAcceptedJet(U const& jet) + { + static constexpr double kJetAreaFractionMinValue = -98.0; + if (jetAreaFractionMin > kJetAreaFractionMinValue) { + if (jet.area() < jetAreaFractionMin * o2::constants::math::PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { + return false; + } + if (jet.area() < o2::constants::math::PIHalf * (jet.r() / 100.0) * (jet.r() / 100.0)) { + return false; + } + } + static constexpr double kLeadingConstituentPtMinValue = 5.0; + static constexpr double kLeadingConstituentPtMaxValue = 9998.0; + bool checkConstituentPt = true; + bool checkConstituentMinPt = (leadingConstituentPtMin > kLeadingConstituentPtMinValue); + bool checkConstituentMaxPt = (leadingConstituentPtMax < kLeadingConstituentPtMaxValue); + if (!checkConstituentMinPt && !checkConstituentMaxPt) { + checkConstituentPt = false; + } + + if (checkConstituentPt) { + bool isMinLeadingConstituent = !checkConstituentMinPt; + bool isMaxLeadingConstituent = true; + + for (const auto& constituent : jet.template tracks_as()) { + double pt = constituent.pt(); + + if (checkConstituentMinPt && pt >= leadingConstituentPtMin) { + isMinLeadingConstituent = true; + } + if (checkConstituentMaxPt && pt > leadingConstituentPtMax) { + isMaxLeadingConstituent = false; + } + } + return isMinLeadingConstituent && isMaxLeadingConstituent; + } + + return true; + } + + Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f); + Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; + Filter mcCollisionFilter = nabs(aod::jmccollision::posZ) < vertexZCut; + + Preslice> perMcCollisionJets = aod::jet::mcCollisionId; + + void processJetShape(soa::Filtered>::iterator const& collision, aod::JetTracks const& tracks, soa::Join const& jets) + { + + std::vector ptDensity(distanceCategory->size() - 1, 0.f); + std::vector ptDensityBg1(distanceCategory->size() - 1, 0.f); + std::vector ptDensityBg2(distanceCategory->size() - 1, 0.f); + + for (auto const& jet : jets) { + if (!isAcceptedJet(jet)) { + continue; + } + + // Get underlying event subtracted jet.pt() as ptCorr + float ptCorr = jet.pt() - collision.rho() * jet.area(); + + for (const auto& track : tracks) { + + float preDeltaPhi1 = track.phi() - jet.phi(); + float deltaPhi1 = RecoDecay::constrainAngle(preDeltaPhi1); + float deltaEta = track.eta() - jet.eta(); + + // calculate distance from jet axis + float distance = std::sqrt(deltaEta * deltaEta + deltaPhi1 * deltaPhi1); + + registry.fill(HIST("ptCorrVsDistance"), distance, ptCorr); + registry.fill(HIST("ptVsCentrality"), collision.centFT0M(), track.pt()); + + // calculate compornents of jetshapefunction rho(r) + std::vector trackPtSum(distanceCategory->size() - 1, 0.f); + std::vector trackPtSumBg1(distanceCategory->size() - 1, 0.f); + std::vector trackPtSumBg2(distanceCategory->size() - 1, 0.f); + + float phiBg1 = jet.phi() + (o2::constants::math::PIHalf); + float phiBg2 = jet.phi() - (o2::constants::math::PIHalf); + + float preDeltaPhiBg1 = track.phi() - phiBg1; + float preDeltaPhiBg2 = track.phi() - phiBg2; + + float deltaPhiBg1 = RecoDecay::constrainAngle(preDeltaPhiBg1, -o2::constants::math::PI); + float deltaPhiBg2 = RecoDecay::constrainAngle(preDeltaPhiBg2, -o2::constants::math::PI); + + float distanceBg1 = std::sqrt(deltaEta * deltaEta + deltaPhiBg1 * deltaPhiBg1); + float distanceBg2 = std::sqrt(deltaEta * deltaEta + deltaPhiBg2 * deltaPhiBg2); + + for (size_t i = 0; i < distanceCategory->size() - 1; i++) { + if (distanceCategory->at(i) <= distance && distance < distanceCategory->at(i + 1)) + trackPtSum[i] += track.pt(); + if (distanceCategory->at(i) <= distanceBg1 && distanceBg1 < distanceCategory->at(i + 1)) + trackPtSumBg1[i] += track.pt(); + if (distanceCategory->at(i) <= distanceBg2 && distanceBg2 < distanceCategory->at(i + 1)) + trackPtSumBg2[i] += track.pt(); + } + + for (size_t i = 0; i < distanceCategory->size() - 1; i++) { + ptDensity[i] += trackPtSum[i] / ((distanceCategory->at(i + 1) - distanceCategory->at(i)) * ptCorr); + ptDensityBg1[i] += trackPtSumBg1[i] / ((distanceCategory->at(i + 1) - distanceCategory->at(i)) * ptCorr); + ptDensityBg2[i] += trackPtSumBg2[i] / ((distanceCategory->at(i + 1) - distanceCategory->at(i)) * ptCorr); + } + } + + registry.fill(HIST("jetPt"), jet.pt()); + registry.fill(HIST("jetEta"), jet.eta()); + registry.fill(HIST("jetPhi"), jet.phi()); + registry.fill(HIST("area"), jet.area()); + registry.fill(HIST("rho"), collision.rho()); + registry.fill(HIST("ptCorr"), ptCorr); + + for (size_t i = 0; i < distanceCategory->size() - 1; i++) { + double jetX = (distanceCategory->at(i + 1) - distanceCategory->at(i)) * i + (distanceCategory->at(i + 1) - distanceCategory->at(i)) / 2; + double jetShapeFunction = ptDensity[i]; + double jetShapeFunctionBg1 = ptDensityBg1[i]; + double jetShapeFunctionBg2 = ptDensityBg2[i]; + registry.fill(HIST("ptSum"), jetX, jetShapeFunction); + registry.fill(HIST("ptSumBg1"), jetX, jetShapeFunctionBg1); + registry.fill(HIST("ptSumBg2"), jetX, jetShapeFunctionBg2); + } + } + } + PROCESS_SWITCH(JetShapeTask, processJetShape, "JetShape", true); + + void processProductionRatio(soa::Filtered>::iterator const& collision, soa::Join const& tracks, soa::Join const& jets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + + registry.fill(HIST("event/vertexz"), collision.posZ()); + + for (auto const& jet : jets) { + if (!isAcceptedJet(jet)) { + continue; + } + + // tracks conditions + for (const auto& track : tracks) { + + registry.fill(HIST("trackTpcNClsCrossedRows"), track.tpcNClsCrossedRows()); + registry.fill(HIST("trackDcaXY"), track.dcaXY()); + registry.fill(HIST("trackItsChi2NCl"), track.itsChi2NCl()); + registry.fill(HIST("trackTpcChi2NCl"), track.tpcChi2NCl()); + registry.fill(HIST("trackTpcNClsFound"), track.tpcNClsFound()); + registry.fill(HIST("trackItsNCls"), track.itsNCls()); + registry.fill(HIST("trackEta"), track.eta()); + registry.fill(HIST("trackPhi"), track.phi()); + + if (std::abs(track.eta()) > etaTrUp) + continue; + if (track.tpcNClsCrossedRows() < nclcrossTpcMin) + continue; + if (std::abs(track.dcaXY()) > dcaxyMax) + continue; + if (track.itsChi2NCl() > chi2ItsMax) + continue; + if (track.tpcChi2NCl() > chi2TpcMax) + continue; + if (track.tpcNClsFound() < nclTpcMin) + continue; + if (track.itsNCls() < nclItsMin) + continue; + + // PID check + registry.fill(HIST("tofMass"), track.mass()); + + // for calculate purity + registry.fill(HIST("tpcPi"), track.p(), track.tpcNSigmaPi()); + registry.fill(HIST("tofPi"), track.pt(), track.tofNSigmaPi()); + registry.fill(HIST("tpcPr"), track.p(), track.tpcNSigmaPr()); + registry.fill(HIST("tofPr"), track.pt(), track.tofNSigmaPr()); + + // for calculate distance + float preDeltaPhi1 = track.phi() - jet.phi(); + float deltaPhi1 = RecoDecay::constrainAngle(preDeltaPhi1); + float deltaEta = track.eta() - jet.eta(); + + // calculate distance from jet axis + float distance = std::sqrt(deltaEta * deltaEta + deltaPhi1 * deltaPhi1); + + // Define perpendicular cone axes in phi + float phiBg1 = jet.phi() + (o2::constants::math::PIHalf); + float phiBg2 = jet.phi() - (o2::constants::math::PIHalf); + + // Calculate delta phi for background cones + float preDeltaPhiBg1 = track.phi() - phiBg1; + float preDeltaPhiBg2 = track.phi() - phiBg2; + float deltaPhiBg1 = RecoDecay::constrainAngle(preDeltaPhiBg1, -o2::constants::math::PI); + float deltaPhiBg2 = RecoDecay::constrainAngle(preDeltaPhiBg2, -o2::constants::math::PI); + + // Calculate distance to background cone axes + // Note: deltaEta is the same for all cones at the same eta + float distanceBg1 = std::sqrt(deltaEta * deltaEta + deltaPhiBg1 * deltaPhiBg1); + float distanceBg2 = std::sqrt(deltaEta * deltaEta + deltaPhiBg2 * deltaPhiBg2); + + // Fill histogram if track is inside one of the perpendicular cones + if (distanceBg1 < jetR || distanceBg2 < jetR) { + registry.fill(HIST("tpcDedxOutOfJet"), track.p(), track.tpcSignal()); + } + + registry.fill(HIST("distanceVsTrackpt"), distance, track.pt()); + registry.fill(HIST("tpcDedx"), track.p(), track.tpcSignal(), distance); + registry.fill(HIST("tofBeta"), track.p(), track.beta(), distance); + + if (std::abs(track.tofNSigmaPr()) < nSigmaTofCut) { + registry.fill(HIST("tpcTofPr"), track.p(), track.tpcNSigmaPr(), distance); + if (track.tpcNSigmaPr() > tpcNSigmaPrMin && track.tpcNSigmaPr() < tpcNSigmaPrMax) { + registry.fill(HIST("pVsPtForProton"), track.p(), track.pt(), distance); + } + } + + if (std::abs(track.tofNSigmaPi()) < nSigmaTofCut) { + registry.fill(HIST("tpcTofPi"), track.p(), track.tpcNSigmaPi(), distance); + if (track.tpcNSigmaPi() > tpcNSigmaPiMin && track.tpcNSigmaPi() < tpcNSigmaPiMax) { + registry.fill(HIST("pVsPtForPion"), track.p(), track.pt(), distance); + } + } + } + } + } + PROCESS_SWITCH(JetShapeTask, processProductionRatio, "production ratio", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGJE/Tasks/jetSpectraCharged.cxx b/PWGJE/Tasks/jetSpectraCharged.cxx index 031b10a5fc4..70f73484b79 100644 --- a/PWGJE/Tasks/jetSpectraCharged.cxx +++ b/PWGJE/Tasks/jetSpectraCharged.cxx @@ -13,33 +13,27 @@ /// \brief Charged-particle jet spectra task /// \author Nima Zardoshti , Aimeric Landou , Wenhui Feng -#include -#include -#include -#include -#include +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" - -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include +#include +#include -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/DataModel/Jet.h" - -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include -#include "EventFiltering/filterTables.h" +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -47,6 +41,7 @@ using namespace o2::framework::expressions; struct JetSpectraCharged { + using McParticleCollision = soa::Join; using ChargedMCDMatchedJets = soa::Join; using ChargedMCPMatchedJets = soa::Join; using ChargedMCDMatchedJetsWeighted = soa::Join; @@ -65,7 +60,9 @@ struct JetSpectraCharged { Configurable trackPtMax{"trackPtMax", 100.0, "maximum pT acceptance for tracks"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; + Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; + Configurable pTHatAbsoluteMin{"pTHatAbsoluteMin", -99.0, "minimum value of pTHat"}; Configurable jetPtMax{"jetPtMax", 200., "set jet pT bin max"}; Configurable jetEtaMin{"jetEtaMin", -0.7, "minimum jet pseudorapidity"}; Configurable jetEtaMax{"jetEtaMax", 0.7, "maximum jet pseudorapidity"}; @@ -76,15 +73,18 @@ struct JetSpectraCharged { Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum track occupancy of tracks in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; Configurable trackOccupancyInTimeRangeMin{"trackOccupancyInTimeRangeMin", -999999, "minimum track occupancy of tracks in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; Configurable checkGeoMatched{"checkGeoMatched", true, "0: turn off geometry matching, 1: do geometry matching "}; - Configurable checkPtMatched{"checkPtMatched", true, "0: turn off pT matching, 1: do pT matching"}; - Configurable checkGeoPtMatched{"checkGeoPtMatched", true, "0: turn off geometry and pT matching, 1: do geometry and pT matching"}; + Configurable checkPtMatched{"checkPtMatched", false, "0: turn off pT matching, 1: do pT matching"}; + Configurable checkGeoPtMatched{"checkGeoPtMatched", false, "0: turn off geometry and pT matching, 1: do geometry and pT matching"}; + Configurable acceptSplitCollisions{"acceptSplitCollisions", 0, "0: only look at mcCollisions that are not split; 1: accept split mcCollisions, 2: accept split mcCollisions but only look at the first reco collision associated with it"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "flag to choose to reject min. bias gap events; jet-level rejection can also be applied at the jet finder level for jets only, here rejection is applied for collision and track process functions for the first time, and on jets in case it was set to false at the jet finder level"}; + Configurable checkLeadConstituentPtForMcpJets{"checkLeadConstituentPtForMcpJets", false, "flag to choose whether particle level jets should have their lead track pt above leadingConstituentPtMin to be accepted; off by default, as leadingConstituentPtMin cut is only applied on MCD jets for the Pb-Pb analysis using pp MC anchored to Pb-Pb for the response matrix"}; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; void init(o2::framework::InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); AxisSpec centralityAxis = {1200, -10., 110., "Centrality"}; @@ -96,17 +96,38 @@ struct JetSpectraCharged { AxisSpec jetEtaAxis = {nBinsEta, -1.0, 1.0, "#eta"}; if (doprocessQC || doprocessQCWeighted) { + registry.add("h_track_pt", "track #it{p}_{T} ; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH1F, {trackPtAxis}}); + registry.add("h2_track_eta_track_phi", "track eta vs. track phi; #eta; #phi; counts", {HistType::kTH2F, {trackEtaAxis, phiAxis}}); + } + + if (doprocessCollisions || doprocessCollisionsWeighted) { registry.add("h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + registry.add("h_fakecollisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); registry.add("h2_centrality_occupancy", "centrality vs occupancy; centrality; occupancy", {HistType::kTH2F, {centralityAxis, {60, 0, 30000}}}); - registry.add("h_collisions_vertexZ", "position of collision ;#it{Z} (cm)", {HistType::kTH1F, {{300, -15.0, 15.0}}}); - registry.add("h_track_pt", "track pT ; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH1F, {trackPtAxis}}); - registry.add("h2_track_eta_track_phi", "track eta vs. track phi; #eta; #phi; counts", {HistType::kTH2F, {trackEtaAxis, phiAxis}}); - if (doprocessQCWeighted) { + registry.add("h_collisions_Zvertex", "position of collision ;#it{Z} (cm)", {HistType::kTH1F, {{300, -15.0, 15.0}}}); + if (doprocessCollisionsWeighted) { registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); } } if (doprocessSpectraData || doprocessSpectraMCD || doprocessSpectraMCDWeighted) { + registry.add("h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c}); counts", {HistType::kTH1F, {jetPtAxis}}); + registry.add("h_jet_eta", "jet eta;#eta; counts", {HistType::kTH1F, {jetEtaAxis}}); + registry.add("h_jet_phi", "jet phi;#phi; counts", {HistType::kTH1F, {phiAxis}}); + registry.add("h2_centrality_jet_pt", "centrality vs. jet pT;centrality; #it{p}_{T,jet} (GeV/#it{c}); counts", {HistType::kTH2F, {centralityAxis, jetPtAxis}}); + registry.add("h2_centrality_jet_eta", "centrality vs. jet eta;centrality; #eta; counts", {HistType::kTH2F, {centralityAxis, jetEtaAxis}}); + registry.add("h2_centrality_jet_phi", "centrality vs. jet phi;centrality; #varphi; counts", {HistType::kTH2F, {centralityAxis, phiAxis}}); + registry.add("h2_jet_pt_jet_area", "jet #it{p}_{T,jet} vs. Area_{jet}; #it{p}_{T,jet} (GeV/#it{c}); Area_{jet}", {HistType::kTH2F, {jetPtAxis, {150, 0., 1.5}}}); + registry.add("h2_jet_pt_jet_ntracks", "jet #it{p}_{T,jet} vs. N_{jet tracks}; #it{p}_{T,jet} (GeV/#it{c}); N_{jet, tracks}", {HistType::kTH2F, {jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h2_jet_pt_track_pt", "jet #it{p}_{T,jet} vs. #it{p}_{T,track}; #it{p}_{T,jet} (GeV/#it{c}); #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, trackPtAxis}}); + registry.add("h3_jet_pt_jet_eta_jet_phi", "jet pt vs. eta vs. phi", {HistType::kTH3F, {jetPtAxis, jetEtaAxis, phiAxis}}); + if (doprocessSpectraMCDWeighted) { + registry.add("h_jet_phat", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); + registry.add("h_jet_phat_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); + } + } + + if (doprocessSpectraAreaSubData || doprocessSpectraAreaSubMCD) { registry.add("h_jet_pt_rhoareasubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c}); counts", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); registry.add("h_jet_eta_rhoareasubtracted", "jet eta;#eta; counts", {HistType::kTH1F, {jetEtaAxis}}); registry.add("h_jet_phi_rhoareasubtracted", "jet phi;#phi; counts", {HistType::kTH1F, {phiAxis}}); @@ -117,13 +138,58 @@ struct JetSpectraCharged { registry.add("h2_jet_pt_jet_ntracks_rhoareasubtracted", "jet #it{p}_{T,jet} vs. N_{jet tracks}; #it{p}_{T,jet} (GeV/#it{c}); N_{jet, tracks}", {HistType::kTH2F, {jetPtAxis, {200, -0.5, 199.5}}}); registry.add("h2_jet_pt_jet_corr_pt_rhoareasubtracted", "jet #it{p}_{T,jet} vs. #it{p}_{T,corr}; #it{p}_{T,jet} (GeV/#it{c}); #it{p}_{T,corr} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxisRhoAreaSub}}); registry.add("h2_jet_pt_track_pt_rhoareasubtracted", "jet #it{p}_{T,jet} vs. #it{p}_{T,track}; #it{p}_{T,jet} (GeV/#it{c}); #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, trackPtAxis}}); - registry.add("h3_jet_pt_eta_phi_rhoareasubtracted", "jet_pt_eta_phi_rhoareasubtracted", {HistType::kTH3F, {jetPtAxisRhoAreaSub, jetEtaAxis, phiAxis}}); - if (doprocessSpectraMCDWeighted) { - registry.add("h_jet_phat", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); - registry.add("h_jet_phat_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); + registry.add("h3_jet_pt_jet_eta_jet_phi_rhoareasubtracted", "jet_pt_eta_phi_rhoareasubtracted", {HistType::kTH3F, {jetPtAxisRhoAreaSub, jetEtaAxis, phiAxis}}); + } + + if (doprocessSpectraMCP || doprocessSpectraMCPWeighted) { + registry.add("h_mcColl_counts", " number of mc events; event status; entries", {HistType::kTH1F, {{10, 0, 10}}}); + registry.get(HIST("h_mcColl_counts"))->GetXaxis()->SetBinLabel(1, "allMcColl"); + registry.get(HIST("h_mcColl_counts"))->GetXaxis()->SetBinLabel(2, "vertexZ"); + registry.get(HIST("h_mcColl_counts"))->GetXaxis()->SetBinLabel(3, "noRecoColl"); + registry.get(HIST("h_mcColl_counts"))->GetXaxis()->SetBinLabel(4, "recoEvtSel"); + registry.get(HIST("h_mcColl_counts"))->GetXaxis()->SetBinLabel(5, "centralitycut"); + registry.get(HIST("h_mcColl_counts"))->GetXaxis()->SetBinLabel(6, "occupancycut"); + + registry.add("h_mc_zvertex", "position of collision ;#it{Z} (cm)", {HistType::kTH1F, {{300, -15.0, 15.0}}}); + registry.add("h_jet_pt_part", "partvjet pT;#it{p}_{T,jet}^{part} (GeV/#it{c}); counts", {HistType::kTH1F, {jetPtAxis}}); + registry.add("h_jet_eta_part", "part jet #eta;#eta^{part}; counts", {HistType::kTH1F, {jetEtaAxis}}); + registry.add("h_jet_phi_part", "part jet #varphi;#phi^{part}; counts", {HistType::kTH1F, {phiAxis}}); + registry.add("h2_jet_pt_part_jet_area_part", "part jet #it{p}_{T,jet} vs. Area_{jet}; #it{p}_{T,jet}^{part} (GeV/#it{c}); Area_{jet}^{part}", {HistType::kTH2F, {jetPtAxis, {150, 0., 1.5}}}); + registry.add("h2_jet_pt_part_jet_ntracks_part", "part jet #it{p}_{T,jet} vs. N_{jet tracks}; #it{p}_{T,jet}^{part} (GeV/#it{c}); N_{jet, tracks}^{part}", {HistType::kTH2F, {jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h2_jet_pt_part_track_pt_part", "part jet #it{p}_{T,jet} vs. #it{p}_{T,track}; #it{p}_{T,jet}^{part} (GeV/#it{c}); #it{p}_{T,track}^{part} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, trackPtAxis}}); + registry.add("h3_jet_pt_jet_eta_jet_phi_part", "part jet pt vs. eta vs. phi", {HistType::kTH3F, {jetPtAxis, jetEtaAxis, phiAxis}}); + if (doprocessSpectraMCPWeighted) { + registry.add("h_mcColl_counts_weight", " number of weighted mc events; event status; entries", {HistType::kTH1F, {{10, 0, 10}}}); + registry.get(HIST("h_mcColl_counts_weight"))->GetXaxis()->SetBinLabel(1, "allMcColl"); + registry.get(HIST("h_mcColl_counts_weight"))->GetXaxis()->SetBinLabel(2, "vertexZ"); + registry.get(HIST("h_mcColl_counts_weight"))->GetXaxis()->SetBinLabel(3, "noRecoColl"); + registry.get(HIST("h_mcColl_counts_weight"))->GetXaxis()->SetBinLabel(4, "recoEvtSel"); + registry.get(HIST("h_mcColl_counts_weight"))->GetXaxis()->SetBinLabel(5, "centralitycut"); + registry.get(HIST("h_mcColl_counts_weight"))->GetXaxis()->SetBinLabel(6, "occupancycut"); + registry.add("h2_jet_ptcut_part", "p_{T} cut;p_{T,jet}^{part} (GeV/#it{c});N;entries", {HistType::kTH2F, {{300, 0, 300}, {20, 0, 5}}}); + registry.add("h_jet_phat_part_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); } } + if (doprocessSpectraAreaSubMCP) { + registry.add("h_mcColl_counts_areasub", " number of mc events; event status; entries", {HistType::kTH1F, {{10, 0, 10}}}); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(1, "allMcColl"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(2, "vertexZ"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(3, "noRecoColl"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(4, "splitColl"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(5, "recoEvtSel"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(6, "centralitycut"); + registry.get(HIST("h_mcColl_counts_areasub"))->GetXaxis()->SetBinLabel(7, "occupancycut"); + + registry.add("h_mcColl_rho", "mc collision rho;#rho (GeV/#it{c}); counts", {HistType::kTH1F, {{500, 0.0, 500.0}}}); + registry.add("h_jet_pt_part_rhoareasubtracted", "part jet corr pT;#it{p}_{T,jet}^{part} (GeV/#it{c}); counts", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_eta_part_rhoareasubtracted", "part jet #eta;#eta^{part}; counts", {HistType::kTH1F, {jetEtaAxis}}); + registry.add("h_jet_phi_part_rhoareasubtracted", "part jet #varphi;#varphi^{part}; counts", {HistType::kTH1F, {phiAxis}}); + registry.add("h2_jet_pt_part_jet_area_part_rhoareasubtracted", "part jet #it{p}_{T,jet} vs. Area_{jet}; #it{p}_{T,jet}^{part} (GeV/#it{c}); Area_{jet}^{part}", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {150, 0., 1.5}}}); + registry.add("h2_jet_pt_part_jet_ntracks_part_rhoareasubtracted", "part jet #it{p}_{T,jet} vs. N_{jet tracks}; #it{p}_{T,jet}^{part} (GeV/#it{c}); N_{jet, tracks}{part}", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {200, -0.5, 199.5}}}); + registry.add("h3_jet_pt_jet_eta_jet_phi_part_rhoareasubtracted", "part jet pt vs. eta vs.phi", {HistType::kTH3F, {jetPtAxisRhoAreaSub, jetEtaAxis, phiAxis}}); + } + if (doprocessEvtWiseConstSubJetsData || doprocessEvtWiseConstSubJetsMCD) { registry.add("h2_centrality_jet_pt_eventwiseconstituentsubtracted", "centrality vs. jet pT;centrality;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH2F, {centralityAxis, jetPtAxis}}); registry.add("jet_observables_eventwiseconstituentsubtracted", "jet_observables_eventwiseconstituentsubtracted", HistType::kTHnSparseF, {jetPtAxis, jetEtaAxis, phiAxis}); @@ -131,48 +197,59 @@ struct JetSpectraCharged { if (doprocessJetsMatched || doprocessJetsMatchedWeighted) { if (checkGeoMatched) { - registry.add("h2_jet_pt_reco_jet_pt_gen_matchedgeo", "pT reco vs. pT gen;#it{p}_{T,jet}^{reco} (GeV/#it{c});#it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); - registry.add("h2_jet_eta_reco_jet_eta_gen_matchedgeo", "Eta reco vs. Eta gen;#eta_{jet}^{reco};#eta_{jet}^{gen}", {HistType::kTH2F, {jetEtaAxis, jetEtaAxis}}); - registry.add("h2_jet_phi_reco_jet_phi_gen_matchedgeo", "Phi reco vs. Phi gen;#varphi_{jet}^{reco};#varphi_{jet}^{gen}", {HistType::kTH2F, {phiAxis, phiAxis}}); - registry.add("h2_jet_ntracks_reco_jet_ntracks_gen_matchedgeo", "Ntracks reco vs. Ntracks gen;N_{jet tracks}^{reco};N_{jet tracks}^{gen}", {HistType::kTH2F, {{200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - registry.add("h2_jet_pt_gen_jet_pt_diff_matchedgeo", "jet gen pT vs. delta pT / jet gen pt;#it{p}_{T,jet}^{gen} (GeV/#it{c}); (#it{p}_{T,jet}^{gen} (GeV/#it{c}) - #it{p}_{T,jet}^{reco} (GeV/#it{c})) / #it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); - registry.add("h2_jet_pt_reco_jet_pt_diff_matchedgeo", "jet reco pT vs. delta pT / jet reco pt;#it{p}_{T,jet}^{reco} (GeV/#it{c}); (#it{p}_{T,jet}^{reco} (GeV/#it{c}) - #it{p}_{T,jet}^{gen} (GeV/#it{c})) / #it{p}_{T,jet}^{reco} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); - registry.add("h2_jet_pt_gen_jet_pt_ratio_matchedgeo", "jet gen pT vs. jet reco pT / jet gen pt;#it{p}_{T,jet}^{gen} (GeV/#it{c}); #it{p}_{T,jet}^{reco} (GeV/#it{c}) / #it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 5.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_mcdetaconstraint", "pT mcd vs. pT mcp;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_mcpetaconstraint", "pT mcd vs. pT mcp;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); + registry.add("h2_jet_eta_mcd_jet_eta_mcp_matchedgeo", "Eta mcd vs. Eta mcp;#eta_{jet}^{mcd};#eta_{jet}^{mcp}", {HistType::kTH2F, {jetEtaAxis, jetEtaAxis}}); + registry.add("h2_jet_phi_mcd_jet_phi_mcp_matchedgeo_mcdetaconstraint", "Phi mcd vs. Phi mcp;#varphi_{jet}^{mcd};#varphi_{jet}^{mcp}", {HistType::kTH2F, {phiAxis, phiAxis}}); + registry.add("h2_jet_phi_mcd_jet_phi_mcp_matchedgeo_mcpetaconstraint", "Phi mcd vs. Phi mcp;#varphi_{jet}^{mcd};#varphi_{jet}^{mcp}", {HistType::kTH2F, {phiAxis, phiAxis}}); + registry.add("h2_jet_ntracks_mcd_jet_ntracks_mcp_matchedgeo", "Ntracks mcd vs. Ntracks mcp;N_{jet tracks}^{mcd};N_{jet tracks}^{mcp}", {HistType::kTH2F, {{200, -0.5, 199.5}, {200, -0.5, 199.5}}}); + registry.add("h2_jet_pt_mcp_jet_pt_diff_matchedgeo", "jet mcp pT vs. delta pT / jet mcp pt;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); (#it{p}_{T,jet}^{mcp} (GeV/#it{c}) - #it{p}_{T,jet}^{mcd} (GeV/#it{c})) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_diff_matchedgeo", "jet mcd pT vs. delta pT / jet mcd pt;#it{p}_{T,jet}^{mcd} (GeV/#it{c}); (#it{p}_{T,jet}^{mcd} (GeV/#it{c}) - #it{p}_{T,jet}^{mcp} (GeV/#it{c})) / #it{p}_{T,jet}^{mcd} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); + registry.add("h2_jet_pt_mcp_jet_pt_ratio_matchedgeo", "jet mcp pT vs. jet mcd pT / jet mcp pt;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); #it{p}_{T,jet}^{mcd} (GeV/#it{c}) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 5.0}}}); } if (checkPtMatched) { - registry.add("h2_jet_pt_reco_jet_pt_gen_matchedpt", "pT reco vs. pT gen;#it{p}_{T,jet}^{reco} (GeV/#it{c});#it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); - registry.add("h2_jet_eta_reco_jet_eta_gen_matchedpt", "Eta reco vs. Eta gen;#eta_{jet}^{reco};#eta_{jet}^{gen}", {HistType::kTH2F, {jetEtaAxis, jetEtaAxis}}); - registry.add("h2_jet_phi_reco_jet_phi_gen_matchedgpt", "Phi reco vs. Phi gen;#varphi_{jet}^{reco};#varphi_{jet}^{gen}", {HistType::kTH2F, {phiAxis, phiAxis}}); - registry.add("h2_jet_ntracks_reco_jet_ntracks_gen_matchedpt", "Ntracks reco vs. Ntracks gen;N_{jet tracks}^{reco};N_{jet tracks}^{gen}", {HistType::kTH2F, {{200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - registry.add("h2_jet_pt_gen_jet_pt_diff_matchedpt", "jet gen pT vs. delta pT / jet gen pt;#it{p}_{T,jet}^{gen} (GeV/#it{c}); (#it{p}_{T,jet}^{gen} (GeV/#it{c}) - #it{p}_{T,jet}^{reco} (GeV/#it{c})) / #it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); - registry.add("h2_jet_pt_reco_jet_pt_diff_matchedpt", "jet reco pT vs. delta pT / jet reco pt;#it{p}_{T,jet}^{reco} (GeV/#it{c}); (#it{p}_{T,jet}^{reco} (GeV/#it{c}) - #it{p}_{T,jet}^{gen} (GeV/#it{c})) / #it{p}_{T,jet}^{reco} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); - registry.add("h2_jet_pt_gen_jet_pt_ratio_matchedpt", "jet gen pT vs. jet reco pT / jet gen pt;#it{p}_{T,jet}^{gen} (GeV/#it{c}); #it{p}_{T,jet}^{reco} (GeV/#it{c}) / #it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 5.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedpt_mcdetaconstraint", "pT mcd vs. pT mcp;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedpt_mcpetaconstraint", "pT mcd vs. pT mcp;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); + registry.add("h2_jet_eta_mcd_jet_eta_mcp_matchedpt", "Eta mcd vs. Eta mcp;#eta_{jet}^{mcd};#eta_{jet}^{mcp}", {HistType::kTH2F, {jetEtaAxis, jetEtaAxis}}); + registry.add("h2_jet_phi_mcd_jet_phi_mcp_matchedgpt_mcdetaconstraint", "Phi mcd vs. Phi mcp;#varphi_{jet}^{mcd};#varphi_{jet}^{mcp}", {HistType::kTH2F, {phiAxis, phiAxis}}); + registry.add("h2_jet_phi_mcd_jet_phi_mcp_matchedgpt_mcpetaconstraint", "Phi mcd vs. Phi mcp;#varphi_{jet}^{mcd};#varphi_{jet}^{mcp}", {HistType::kTH2F, {phiAxis, phiAxis}}); + registry.add("h2_jet_ntracks_mcd_jet_ntracks_mcp_matchedpt", "Ntracks mcd vs. Ntracks mcp;N_{jet tracks}^{mcd};N_{jet tracks}^{mcp}", {HistType::kTH2F, {{200, -0.5, 199.5}, {200, -0.5, 199.5}}}); + registry.add("h2_jet_pt_mcp_jet_pt_diff_matchedpt", "jet mcp pT vs. delta pT / jet mcp pt;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); (#it{p}_{T,jet}^{mcp} (GeV/#it{c}) - #it{p}_{T,jet}^{mcd} (GeV/#it{c})) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_diff_matchedpt", "jet mcd pT vs. delta pT / jet mcd pt;#it{p}_{T,jet}^{mcd} (GeV/#it{c}); (#it{p}_{T,jet}^{mcd} (GeV/#it{c}) - #it{p}_{T,jet}^{mcp} (GeV/#it{c})) / #it{p}_{T,jet}^{mcd} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); + registry.add("h2_jet_pt_mcp_jet_pt_ratio_matchedpt", "jet mcp pT vs. jet mcd pT / jet mcp pt;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); #it{p}_{T,jet}^{mcd} (GeV/#it{c}) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 5.0}}}); } if (checkGeoPtMatched) { - registry.add("h2_jet_pt_reco_jet_pt_gen_matchedgeopt", "pT reco vs. pT gen;#it{p}_{T,jet}^{reco} (GeV/#it{c});#it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); - registry.add("h2_jet_eta_reco_jet_eta_gen_matchedgeopt", "Eta reco vs. Eta gen;#eta_{jet}^{reco};#eta_{jet}^{gen}", {HistType::kTH2F, {jetEtaAxis, jetEtaAxis}}); - registry.add("h2_jet_phi_reco_jet_phi_gen_matchedgeopt", "Phi reco vs. Phi gen;#varphi_{jet}^{reco};#varphi_{jet}^{gen}", {HistType::kTH2F, {phiAxis, phiAxis}}); - registry.add("h2_jet_ntracks_reco_jet_ntracks_gen_matchedgeopt", "Ntracks reco vs. Ntracks gen;N_{jet tracks}^{reco};N_{jet tracks}^{gen}", {HistType::kTH2F, {{200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - registry.add("h2_jet_pt_gen_jet_pt_diff_matchedgeopt", "jet gen pT vs. delta pT / jet gen pt;#it{p}_{T,jet}^{gen} (GeV/#it{c}); (#it{p}_{T,jet}^{gen} (GeV/#it{c}) - #it{p}_{T,jet}^{reco} (GeV/#it{c})) / #it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); - registry.add("h2_jet_pt_reco_jet_pt_diff_matchedgeopt", "jet reco pT vs. delta pT / jet reco pt;#it{p}_{T,jet}^{reco} (GeV/#it{c}); (#it{p}_{T,jet}^{reco} (GeV/#it{c}) - #it{p}_{T,jet}^{gen} (GeV/#it{c})) / #it{p}_{T,jet}^{reco} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); - registry.add("h2_jet_pt_gen_jet_pt_ratio_matchedgeopt", "jet gen pT vs. jet reco pT / jet gen pt;#it{p}_{T,jet}^{gen} (GeV/#it{c}); #it{p}_{T,jet}^{reco} (GeV/#it{c}) / #it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 5.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeopt_mcdetaconstraint", "pT mcd vs. pT mcp;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeopt_mcpetaconstraint", "pT mcd vs. pT mcp;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); + registry.add("h2_jet_eta_mcd_jet_eta_mcp_matchedgeopt", "Eta mcd vs. Eta mcp;#eta_{jet}^{mcd};#eta_{jet}^{mcp}", {HistType::kTH2F, {jetEtaAxis, jetEtaAxis}}); + registry.add("h2_jet_phi_mcd_jet_phi_mcp_matchedgeopt_mcdetaconstraint", "Phi mcd vs. Phi mcp;#varphi_{jet}^{mcd};#varphi_{jet}^{mcp}", {HistType::kTH2F, {phiAxis, phiAxis}}); + registry.add("h2_jet_phi_mcd_jet_phi_mcp_matchedgeopt_mcpetaconstraint", "Phi mcd vs. Phi mcp;#varphi_{jet}^{mcd};#varphi_{jet}^{mcp}", {HistType::kTH2F, {phiAxis, phiAxis}}); + registry.add("h2_jet_ntracks_mcd_jet_ntracks_mcp_matchedgeopt", "Ntracks mcd vs. Ntracks mcp;N_{jet tracks}^{mcd};N_{jet tracks}^{mcp}", {HistType::kTH2F, {{200, -0.5, 199.5}, {200, -0.5, 199.5}}}); + registry.add("h2_jet_pt_mcp_jet_pt_diff_matchedgeopt", "jet mcp pT vs. delta pT / jet mcp pt;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); (#it{p}_{T,jet}^{mcp} (GeV/#it{c}) - #it{p}_{T,jet}^{mcd} (GeV/#it{c})) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_diff_matchedgeopt", "jet mcd pT vs. delta pT / jet mcd pt;#it{p}_{T,jet}^{mcd} (GeV/#it{c}); (#it{p}_{T,jet}^{mcd} (GeV/#it{c}) - #it{p}_{T,jet}^{mcp} (GeV/#it{c})) / #it{p}_{T,jet}^{mcd} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); + registry.add("h2_jet_pt_mcp_jet_pt_ratio_matchedgeopt", "jet mcp pT vs. jet mcd pT / jet mcp pt;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); #it{p}_{T,jet}^{mcd} (GeV/#it{c}) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 5.0}}}); } } if (doprocessJetsMatchedSubtracted) { - registry.add("h2_jet_pt_reco_corr_jet_pt_gen_matchedgeo", "corr pT reco vs. pT gen;#it{p}_{T,jet}^{reco} (GeV/#it{c});#it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); - registry.add("h2_jet_pt_gen_jet_pt_diff_corr_matchedgeo", "jet gen pT vs. corr delta pT / jet gen pt;#it{p}_{T,jet}^{gen} (GeV/#it{c}); (#it{p}_{T,jet}^{gen} (GeV/#it{c}) - #it{p}_{T,jet}^{reco} (GeV/#it{c})) / #it{p}_{T,jet}^{gen} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); - registry.add("h2_jet_pt_reco_jet_pt_diff_corr_matchedgeo", "jet reco pT vs. corr delta pT / jet reco pt;#it{p}_{T,jet}^{reco} (GeV/#it{c}); (#it{p}_{T,jet}^{reco} (GeV/#it{c}) - #it{p}_{T,jet}^{gen} (GeV/#it{c})) / #it{p}_{T,jet}^{reco} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxis, {1000, -5.0, 2.0}}}); + registry.add("h_mc_collisions_matched", "mc collisions status;event status;entries", {HistType::kTH1F, {{5, 0.0, 5.0}}}); + registry.add("h_mcd_events_matched", "mcd event status;event status;entries", {HistType::kTH1F, {{5, 0.0, 5.0}}}); + registry.add("h_mc_rho_matched", "mc collision rho;#rho (GeV/#it{c}); counts", {HistType::kTH1F, {{500, -100.0, 500.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_rhoareasubtracted_mcdetaconstraint", "corr pT mcd vs. corr cpT mcp;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, jetPtAxisRhoAreaSub}}); + registry.add("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_rhoareasubtracted_mcpetaconstraint", "corr pT mcd vs. corr cpT mcp;#it{p}_{T,jet}^{mcd} (GeV/#it{c});#it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, jetPtAxisRhoAreaSub}}); + registry.add("h2_jet_pt_mcp_jet_pt_diff_matchedgeo_rhoareasubtracted", "jet mcp corr pT vs. corr delta pT / jet mcp corr pt;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); (#it{p}_{T,jet}^{mcp} (GeV/#it{c}) - #it{p}_{T,jet}^{mcd} (GeV/#it{c})) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {1000, -5.0, 5.0}}}); + registry.add("h2_jet_pt_mcd_jet_pt_diff_matchedgeo_rhoareasubtracted", "jet mcd corr pT vs. corr delta pT / jet mcd corr pt;#it{p}_{T,jet}^{mcd} (GeV/#it{c}); (#it{p}_{T,jet}^{mcd} (GeV/#it{c}) - #it{p}_{T,jet}^{mcp} (GeV/#it{c})) / #it{p}_{T,jet}^{mcd} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {1000, -5.0, 5.0}}}); + registry.add("h2_jet_pt_mcp_jet_pt_ratio_matchedgeo_rhoareasubtracted", "jet mcp corr pT vs. jet mcd corr pT / jet mcp corr pt;#it{p}_{T,jet}^{mcp} (GeV/#it{c}); #it{p}_{T,jet}^{mcd} (GeV/#it{c}) / #it{p}_{T,jet}^{mcp} (GeV/#it{c})", {HistType::kTH2F, {jetPtAxisRhoAreaSub, {1000, -5.0, 5.0}}}); } } Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); - Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); + Preslice mcdjetsPerJCollision = o2::aod::jet::collisionId; template - bool isAcceptedJet(TJets const& jet) + bool isAcceptedJet(TJets const& jet, bool mcLevelIsParticleLevel = false) { - if (jetAreaFractionMin > -98.0) { if (jet.area() < jetAreaFractionMin * o2::constants::math::PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { return false; @@ -184,6 +261,9 @@ struct JetSpectraCharged { if (!checkConstituentMinPt && !checkConstituentMaxPt) { checkConstituentPt = false; } + if (mcLevelIsParticleLevel && !checkLeadConstituentPtForMcpJets) { + checkConstituentPt = false; + } if (checkConstituentPt) { bool isMinLeadingConstituent = !checkConstituentMinPt; @@ -205,33 +285,108 @@ struct JetSpectraCharged { } template - void fillJetHistograms(TJets const& jet, float centrality, float rho, float weight = 1.0) + void fillJetHistograms(TJets const& jet, float centrality, float weight = 1.0) { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { + return; + } + if (jet.r() == round(selectedJetsRadius * 100.0f)) { + registry.fill(HIST("h_jet_pt"), jet.pt(), weight); + registry.fill(HIST("h_jet_eta"), jet.eta(), weight); + registry.fill(HIST("h_jet_phi"), jet.phi(), weight); + registry.fill(HIST("h2_centrality_jet_pt"), centrality, jet.pt(), weight); + registry.fill(HIST("h2_centrality_jet_eta"), centrality, jet.eta(), weight); + registry.fill(HIST("h2_centrality_jet_phi"), centrality, jet.phi(), weight); + registry.fill(HIST("h2_jet_pt_jet_area"), jet.pt(), jet.area(), weight); + registry.fill(HIST("h2_jet_pt_jet_ntracks"), jet.pt(), jet.tracksIds().size(), weight); + registry.fill(HIST("h3_jet_pt_jet_eta_jet_phi"), jet.pt(), jet.eta(), jet.phi(), weight); + } + + for (const auto& constituent : jet.template tracks_as()) { + registry.fill(HIST("h2_jet_pt_track_pt"), jet.pt(), constituent.pt(), weight); + } + } + + template + void fillJetAreaSubHistograms(TJets const& jet, float centrality, float rho, float weight = 1.0) + { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { + return; + } + double jetcorrpt = jet.pt() - (rho * jet.area()); if (jet.r() == round(selectedJetsRadius * 100.0f)) { - double jetcorrpt = jet.pt() - (rho * jet.area()); // fill jet histograms after area-based subtraction registry.fill(HIST("h_jet_pt_rhoareasubtracted"), jetcorrpt, weight); - registry.fill(HIST("h_jet_eta_rhoareasubtracted"), jet.eta(), weight); - registry.fill(HIST("h_jet_phi_rhoareasubtracted"), jet.phi(), weight); registry.fill(HIST("h2_centrality_jet_pt_rhoareasubtracted"), centrality, jetcorrpt, weight); - registry.fill(HIST("h2_centrality_jet_eta_rhoareasubtracted"), centrality, jet.eta(), weight); - registry.fill(HIST("h2_centrality_jet_phi_rhoareasubtracted"), centrality, jet.phi(), weight); registry.fill(HIST("h2_jet_pt_jet_corr_pt_rhoareasubtracted"), jet.pt(), jetcorrpt, weight); - registry.fill(HIST("h3_jet_pt_eta_phi_rhoareasubtracted"), jetcorrpt, jet.eta(), jet.phi(), weight); + registry.fill(HIST("h3_jet_pt_jet_eta_jet_phi_rhoareasubtracted"), jetcorrpt, jet.eta(), jet.phi(), weight); if (jetcorrpt > 0) { + registry.fill(HIST("h_jet_eta_rhoareasubtracted"), jet.eta(), weight); + registry.fill(HIST("h_jet_phi_rhoareasubtracted"), jet.phi(), weight); + registry.fill(HIST("h2_centrality_jet_eta_rhoareasubtracted"), centrality, jet.eta(), weight); + registry.fill(HIST("h2_centrality_jet_phi_rhoareasubtracted"), centrality, jet.phi(), weight); registry.fill(HIST("h2_jet_pt_jet_area_rhoareasubtracted"), jetcorrpt, jet.area(), weight); registry.fill(HIST("h2_jet_pt_jet_ntracks_rhoareasubtracted"), jetcorrpt, jet.tracksIds().size(), weight); } } for (const auto& constituent : jet.template tracks_as()) { - registry.fill(HIST("h2_jet_pt_track_pt_rhoareasubtracted"), jet.pt(), constituent.pt(), weight); + registry.fill(HIST("h2_jet_pt_track_pt_rhoareasubtracted"), jetcorrpt, constituent.pt(), weight); + } + } + + template + void fillMCPHistograms(TJets const& jet, float weight = 1.0) + { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { + return; + } + if (jet.r() == round(selectedJetsRadius * 100.0f)) { + // fill mcp jet histograms + registry.fill(HIST("h_jet_pt_part"), jet.pt(), weight); + registry.fill(HIST("h_jet_eta_part"), jet.eta(), weight); + registry.fill(HIST("h_jet_phi_part"), jet.phi(), weight); + registry.fill(HIST("h3_jet_pt_jet_eta_jet_phi_part"), jet.pt(), jet.eta(), jet.phi(), weight); + registry.fill(HIST("h2_jet_pt_part_jet_area_part"), jet.pt(), jet.area(), weight); + registry.fill(HIST("h2_jet_pt_part_jet_ntracks_part"), jet.pt(), jet.tracksIds().size(), weight); + } + + for (const auto& constituent : jet.template tracks_as()) { + registry.fill(HIST("h2_jet_pt_part_track_pt_part"), jet.pt(), constituent.pt(), weight); + } + } + + template + void fillMCPAreaSubHistograms(TJets const& jet, float rho = 0.0, float weight = 1.0) + { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { + return; + } + if (jet.r() == round(selectedJetsRadius * 100.0f)) { + // fill mcp jet histograms + double jetcorrpt = jet.pt() - (rho * jet.area()); + registry.fill(HIST("h_jet_pt_part_rhoareasubtracted"), jetcorrpt, weight); + registry.fill(HIST("h3_jet_pt_jet_eta_jet_phi_part_rhoareasubtracted"), jetcorrpt, jet.eta(), jet.phi(), weight); + if (jetcorrpt > 0) { + registry.fill(HIST("h_jet_eta_part_rhoareasubtracted"), jet.eta(), weight); + registry.fill(HIST("h_jet_phi_part_rhoareasubtracted"), jet.phi(), weight); + registry.fill(HIST("h2_jet_pt_part_jet_area_part_rhoareasubtracted"), jetcorrpt, jet.area(), weight); + registry.fill(HIST("h2_jet_pt_part_jet_ntracks_part_rhoareasubtracted"), jetcorrpt, jet.tracksIds().size(), weight); + } } } template void fillEventWiseConstituentSubtractedHistograms(TJets const& jet, float centrality, float weight = 1.0) { + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { + return; + } if (jet.r() == round(selectedJetsRadius * 100.0f)) { registry.fill(HIST("h2_centrality_jet_pt_eventwiseconstituentsubtracted"), centrality, jet.pt(), weight); registry.fill(HIST("jet_observables_eventwiseconstituentsubtracted"), jet.pt(), jet.eta(), jet.phi(), weight); @@ -246,68 +401,92 @@ struct JetSpectraCharged { } template - void fillMatchedHistograms(TBase const& jetBase, float weight = 1.0) + void fillMatchedHistograms(TBase const& jetMCD, float weight = 1.0) { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jetBase.pt() > pTHatMaxMCD * pTHat) { + if (jetMCD.pt() > pTHatMaxMCD * pTHat || pTHat < pTHatAbsoluteMin) { return; } // fill geometry matched histograms if (checkGeoMatched) { - if (jetBase.has_matchedJetGeo()) { - for (const auto& jetTag : jetBase.template matchedJetGeo_as>()) { - if (jetTag.pt() > pTHatMaxMCD * pTHat) { + if (jetMCD.has_matchedJetGeo()) { + for (const auto& jetMCP : jetMCD.template matchedJetGeo_as>()) { + if (jetMCP.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { continue; } - if (jetBase.r() == round(selectedJetsRadius * 100.0f)) { - double dpt = jetTag.pt() - jetBase.pt(); - registry.fill(HIST("h2_jet_pt_reco_jet_pt_gen_matchedgeo"), jetBase.pt(), jetTag.pt(), weight); - registry.fill(HIST("h2_jet_eta_reco_jet_eta_gen_matchedgeo"), jetBase.eta(), jetTag.eta(), weight); - registry.fill(HIST("h2_jet_phi_reco_jet_phi_gen_matchedgeo"), jetBase.phi(), jetTag.phi(), weight); - registry.fill(HIST("h2_jet_ntracks_reco_jet_ntracks_gen_matchedgeo"), jetBase.tracksIds().size(), jetTag.tracksIds().size(), weight); - registry.fill(HIST("h2_jet_pt_gen_jet_pt_diff_matchedgeo"), jetTag.pt(), dpt / jetTag.pt(), weight); - registry.fill(HIST("h2_jet_pt_reco_jet_pt_diff_matchedgeo"), jetBase.pt(), dpt / jetBase.pt(), weight); - registry.fill(HIST("h2_jet_pt_gen_jet_pt_ratio_matchedgeo"), jetTag.pt(), jetBase.pt() / jetTag.pt(), weight); + if (jetMCD.r() == round(selectedJetsRadius * 100.0f)) { + double dpt = jetMCP.pt() - jetMCD.pt(); + if (jetfindingutilities::isInEtaAcceptance(jetMCD, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_mcdetaconstraint"), jetMCD.pt(), jetMCP.pt(), weight); + registry.fill(HIST("h2_jet_phi_mcd_jet_phi_mcp_matchedgeo_mcdetaconstraint"), jetMCD.phi(), jetMCP.phi(), weight); + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_diff_matchedgeo"), jetMCD.pt(), dpt / jetMCD.pt(), weight); + registry.fill(HIST("h2_jet_ntracks_mcd_jet_ntracks_mcp_matchedgeo"), jetMCD.tracksIds().size(), jetMCP.tracksIds().size(), weight); + } + if (jetfindingutilities::isInEtaAcceptance(jetMCP, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_mcpetaconstraint"), jetMCD.pt(), jetMCP.pt(), weight); + registry.fill(HIST("h2_jet_phi_mcd_jet_phi_mcp_matchedgeo_mcpetaconstraint"), jetMCD.phi(), jetMCP.phi(), weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_diff_matchedgeo"), jetMCP.pt(), dpt / jetMCP.pt(), weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_ratio_matchedgeo"), jetMCP.pt(), jetMCD.pt() / jetMCP.pt(), weight); + } + registry.fill(HIST("h2_jet_eta_mcd_jet_eta_mcp_matchedgeo"), jetMCD.eta(), jetMCP.eta(), weight); } } } } // fill pt matched histograms if (checkPtMatched) { - if (jetBase.has_matchedJetPt()) { - for (const auto& jetTag : jetBase.template matchedJetPt_as>()) { - if (jetTag.pt() > pTHatMaxMCD * pTHat) { + if (jetMCD.has_matchedJetPt()) { + for (const auto& jetMCP : jetMCD.template matchedJetPt_as>()) { + if (jetMCP.pt() > pTHatMaxMCP * pTHat) { + continue; + } + if (!jetfindingutilities::isInEtaAcceptance(jetMCP, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (jetBase.r() == round(selectedJetsRadius * 100.0f)) { - double dpt = jetTag.pt() - jetBase.pt(); - registry.fill(HIST("h2_jet_pt_reco_jet_pt_gen_matchedpt"), jetBase.pt(), jetTag.pt(), weight); - registry.fill(HIST("h2_jet_eta_reco_jet_eta_gen_matchedpt"), jetBase.eta(), jetTag.eta(), weight); - registry.fill(HIST("h2_jet_phi_reco_jet_phi_gen_matchedpt"), jetBase.phi(), jetTag.phi(), weight); - registry.fill(HIST("h2_jet_ntracks_reco_jet_ntracks_gen_matchedpt"), jetBase.tracksIds().size(), jetTag.tracksIds().size(), weight); - registry.fill(HIST("h2_jet_pt_gen_jet_pt_diff_matchedpt"), jetTag.pt(), dpt / jetTag.pt(), weight); - registry.fill(HIST("h2_jet_pt_reco_jet_pt_diff_matchedpt"), jetBase.pt(), dpt / jetBase.pt(), weight); - registry.fill(HIST("h2_jet_pt_gen_jet_pt_ratio_matchedpt"), jetTag.pt(), jetBase.pt() / jetTag.pt(), weight); + if (jetMCD.r() == round(selectedJetsRadius * 100.0f)) { + double dpt = jetMCP.pt() - jetMCD.pt(); + if (jetfindingutilities::isInEtaAcceptance(jetMCD, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedpt_mcdetaconstraint"), jetMCD.pt(), jetMCP.pt(), weight); + registry.fill(HIST("h2_jet_phi_mcd_jet_phi_mcp_matchedpt_mcdetaconstraint"), jetMCD.phi(), jetMCP.phi(), weight); + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_diff_matchedpt"), jetMCD.pt(), dpt / jetMCD.pt(), weight); + registry.fill(HIST("h2_jet_ntracks_mcd_jet_ntracks_mcp_matchedpt"), jetMCD.tracksIds().size(), jetMCP.tracksIds().size(), weight); + } + if (jetfindingutilities::isInEtaAcceptance(jetMCP, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedpt_mcpetaconstraint"), jetMCD.pt(), jetMCP.pt(), weight); + registry.fill(HIST("h2_jet_phi_mcd_jet_phi_mcp_matchedpt_mcpetaconstraint"), jetMCD.phi(), jetMCP.phi(), weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_diff_matchedpt"), jetMCP.pt(), dpt / jetMCP.pt(), weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_ratio_matchedpt"), jetMCP.pt(), jetMCD.pt() / jetMCP.pt(), weight); + } + registry.fill(HIST("h2_jet_eta_mcd_jet_eta_mcp_matchedpt"), jetMCD.eta(), jetMCP.eta(), weight); } } } } // fill geometry and pt histograms if (checkGeoPtMatched) { - if (jetBase.has_matchedJetGeo() && jetBase.has_matchedJetPt()) { - for (const auto& jetTag : jetBase.template matchedJetGeo_as>()) { - if (jetTag.pt() > pTHatMaxMCD * pTHat) { + if (jetMCD.has_matchedJetGeo() && jetMCD.has_matchedJetPt()) { + for (const auto& jetMCP : jetMCD.template matchedJetGeo_as>()) { + if (jetMCP.pt() > pTHatMaxMCP * pTHat) { + continue; + } + if (!jetfindingutilities::isInEtaAcceptance(jetMCP, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (jetBase.template matchedJetGeo_first_as>().globalIndex() == jetBase.template matchedJetPt_first_as>().globalIndex()) { // not a good way to do this - double dpt = jetTag.pt() - jetBase.pt(); - registry.fill(HIST("h2_jet_pt_reco_jet_pt_gen_matchedgeopt"), jetBase.pt(), jetTag.pt(), weight); - registry.fill(HIST("h2_jet_eta_reco_jet_eta_gen_matchedgeopt"), jetBase.eta(), jetTag.eta(), weight); - registry.fill(HIST("h2_jet_phi_reco_jet_phi_gen_matchedgeopt"), jetBase.phi(), jetTag.phi(), weight); - registry.fill(HIST("h2_jet_ntracks_reco_jet_ntracks_gen_matchedgeopt"), jetBase.tracksIds().size(), jetTag.tracksIds().size(), weight); - registry.fill(HIST("h2_jet_pt_gen_jet_pt_diff_matchedgeopt"), jetTag.pt(), dpt / jetTag.pt(), weight); - registry.fill(HIST("h2_jet_pt_reco_jet_pt_diff_matchedgeopt"), jetBase.pt(), dpt / jetBase.pt(), weight); - registry.fill(HIST("h2_jet_pt_gen_jet_pt_ratio_matchedgeopt"), jetTag.pt(), jetBase.pt() / jetTag.pt(), weight); + if (jetMCD.template matchedJetGeo_first_as>().globalIndex() == jetMCD.template matchedJetPt_first_as>().globalIndex()) { // not a good way to do this + double dpt = jetMCP.pt() - jetMCD.pt(); + if (jetfindingutilities::isInEtaAcceptance(jetMCD, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeopt_mcdetaconstraint"), jetMCD.pt(), jetMCP.pt(), weight); + registry.fill(HIST("h2_jet_phi_mcd_jet_phi_mcp_matchedgeopt_mcdetaconstraint"), jetMCD.phi(), jetMCP.phi(), weight); + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_diff_matchedgeopt"), jetMCD.pt(), dpt / jetMCD.pt(), weight); + registry.fill(HIST("h2_jet_ntracks_mcd_jet_ntracks_mcp_matchedgeopt"), jetMCD.tracksIds().size(), jetMCP.tracksIds().size(), weight); + } + if (jetfindingutilities::isInEtaAcceptance(jetMCP, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeopt_mcpetaconstraint"), jetMCD.pt(), jetMCP.pt(), weight); + registry.fill(HIST("h2_jet_phi_mcd_jet_phi_mcp_matchedgeopt_mcpetaconstraint"), jetMCD.phi(), jetMCP.phi(), weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_diff_matchedgeopt"), jetMCP.pt(), dpt / jetMCP.pt(), weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_ratio_matchedgeopt"), jetMCP.pt(), jetMCD.pt() / jetMCP.pt(), weight); + } + registry.fill(HIST("h2_jet_eta_mcd_jet_eta_mcp_matchedpt"), jetMCD.eta(), jetMCP.eta(), weight); } } } @@ -315,23 +494,30 @@ struct JetSpectraCharged { } template - void fillGeoMatchedCorrHistograms(TBase const& jetBase, float rho, float weight = 1.0) + void fillGeoMatchedCorrHistograms(TBase const& jetMCD, float rho, float mcrho = 0.0, float weight = 1.0) { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); - if (jetBase.pt() > pTHatMaxMCD * pTHat) { + if (jetMCD.pt() > pTHatMaxMCD * pTHat) { return; } - if (jetBase.has_matchedJetGeo()) { - for (const auto& jetTag : jetBase.template matchedJetGeo_as>()) { - if (jetTag.pt() > pTHatMaxMCD * pTHat) { + if (jetMCD.has_matchedJetGeo()) { + for (const auto& jetMCP : jetMCD.template matchedJetGeo_as>()) { + if (jetMCP.pt() > pTHatMaxMCD * pTHat) { continue; } - if (jetBase.r() == round(selectedJetsRadius * 100.0f)) { - double corrBasejetpt = jetBase.pt() - (rho * jetBase.area()); - double dcorrpt = jetTag.pt() - corrBasejetpt; - registry.fill(HIST("h2_jet_pt_reco_corr_jet_pt_gen_matchedgeo"), corrBasejetpt, jetTag.pt(), weight); - registry.fill(HIST("h2_jet_pt_gen_jet_pt_diff_corr_matchedgeo"), jetTag.pt(), dcorrpt / jetTag.pt(), weight); - registry.fill(HIST("h2_jet_pt_reco_jet_pt_diff_corr_matchedgeo"), corrBasejetpt, dcorrpt / corrBasejetpt, weight); + if (jetMCD.r() == round(selectedJetsRadius * 100.0f)) { + double corrTagjetpt = jetMCP.pt() - (mcrho * jetMCP.area()); + double corrBasejetpt = jetMCD.pt() - (rho * jetMCD.area()); + double dcorrpt = corrTagjetpt - corrBasejetpt; + if (jetfindingutilities::isInEtaAcceptance(jetMCD, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_rhoareasubtracted_mcdetaconstraint"), corrBasejetpt, corrTagjetpt, weight); + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_diff_matchedgeo_rhoareasubtracted"), corrBasejetpt, dcorrpt / corrBasejetpt, weight); + } + if (jetfindingutilities::isInEtaAcceptance(jetMCP, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + registry.fill(HIST("h2_jet_pt_mcd_jet_pt_mcp_matchedgeo_rhoareasubtracted_mcpetaconstraint"), corrBasejetpt, corrTagjetpt, weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_diff_matchedgeo_rhoareasubtracted"), corrTagjetpt, dcorrpt / corrTagjetpt, weight); + registry.fill(HIST("h2_jet_pt_mcp_jet_pt_ratio_matchedgeo_rhoareasubtracted"), corrTagjetpt, corrBasejetpt / corrTagjetpt, weight); + } } } } @@ -340,46 +526,32 @@ struct JetSpectraCharged { void processQC(soa::Filtered::iterator const& collision, soa::Filtered> const& tracks) { - registry.fill(HIST("h_collisions"), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } - registry.fill(HIST("h_collisions"), 1.5); if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - registry.fill(HIST("h_collisions"), 2.5); - registry.fill(HIST("h2_centrality_occupancy"), collision.centrality(), collision.trackOccupancyInTimeRange()); - registry.fill(HIST("h_collisions_vertexZ"), collision.posZ()); - for (auto const& track : tracks) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } - fillTrackHistograms(track, collision.centrality()); + fillTrackHistograms(track); } } - PROCESS_SWITCH(JetSpectraCharged, processQC, "collisions and track QC for Data and MCD", true); + PROCESS_SWITCH(JetSpectraCharged, processQC, "collisions and track QC for Data and MCD", false); void processQCWeighted(soa::Join::iterator const& collision, aod::JetMcCollisions const&, soa::Filtered> const& tracks) { - float eventWeight = collision.mcCollision().weight(); - registry.fill(HIST("h_collisions"), 0.5); - registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + float eventWeight = collision.weight(); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } - registry.fill(HIST("h_collisions"), 1.5); - registry.fill(HIST("h_collisions_weighted"), 1.5, eventWeight); - if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + if (std::abs(collision.posZ()) > vertexZCut) { return; } - registry.fill(HIST("h_collisions"), 2.5); - registry.fill(HIST("h_collisions_weighted"), 2.5, eventWeight); - registry.fill(HIST("h_collisions_vertexZ"), collision.posZ(), eventWeight); - for (auto const& track : tracks) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; @@ -389,11 +561,51 @@ struct JetSpectraCharged { } PROCESS_SWITCH(JetSpectraCharged, processQCWeighted, "weighted collsions and tracks QC for MC", false); - void processSpectraData(soa::Filtered>::iterator const& collision, + void processCollisions(soa::Filtered::iterator const& collision) + { + registry.fill(HIST("h_collisions"), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + registry.fill(HIST("h_collisions"), 1.5); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + registry.fill(HIST("h_collisions"), 2.5); + registry.fill(HIST("h2_centrality_occupancy"), collision.centFT0M(), collision.trackOccupancyInTimeRange()); + registry.fill(HIST("h_collisions_Zvertex"), collision.posZ()); + } + PROCESS_SWITCH(JetSpectraCharged, processCollisions, "collisions Data and MCD", true); + + void processCollisionsWeighted(soa::Join::iterator const& collision, + aod::JetMcCollisions const&) + { + if (!collision.has_mcCollision()) { + registry.fill(HIST("h_fakecollisions"), 0.5); + } + float eventWeight = collision.weight(); + registry.fill(HIST("h_collisions"), 0.5); + registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + registry.fill(HIST("h_collisions"), 1.5); + registry.fill(HIST("h_collisions_weighted"), 1.5, eventWeight); + if (std::abs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("h_collisions"), 2.5); + registry.fill(HIST("h_collisions_weighted"), 2.5, eventWeight); + registry.fill(HIST("h2_centrality_occupancy"), collision.centFT0M(), collision.trackOccupancyInTimeRange()); + registry.fill(HIST("h_collisions_Zvertex"), collision.posZ(), eventWeight); + } + PROCESS_SWITCH(JetSpectraCharged, processCollisionsWeighted, "weighted collsions for MCD", false); + + void processSpectraData(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracks const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { @@ -406,16 +618,60 @@ struct JetSpectraCharged { if (!isAcceptedJet(jet)) { continue; } - fillJetHistograms(jet, collision.centrality(), collision.rho()); + fillJetHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetSpectraCharged, processSpectraData, "jet spectra for Data", false); - void processSpectraMCD(soa::Filtered>::iterator const& collision, + void processSpectraMCD(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracks const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillJetHistograms(jet, collision.centFT0M()); + } + } + PROCESS_SWITCH(JetSpectraCharged, processSpectraMCD, "jet spectra for MCD", false); + + void processSpectraAreaSubData(soa::Filtered>::iterator const& collision, + soa::Join const& jets, + aod::JetTracks const&) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillJetAreaSubHistograms(jet, collision.centFT0M(), collision.rho()); + } + } + PROCESS_SWITCH(JetSpectraCharged, processSpectraAreaSubData, "jet spectra with rho-area subtraction for Data", false); + + void processSpectraAreaSubMCD(soa::Filtered>::iterator const& collision, + soa::Join const& jets, + aod::JetTracks const&) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { @@ -428,16 +684,16 @@ struct JetSpectraCharged { if (!isAcceptedJet(jet)) { continue; } - fillJetHistograms(jet, collision.centrality(), collision.rho()); + fillJetAreaSubHistograms(jet, collision.centFT0M(), collision.rho()); } } - PROCESS_SWITCH(JetSpectraCharged, processSpectraMCD, "jet spectra for Data", false); + PROCESS_SWITCH(JetSpectraCharged, processSpectraAreaSubMCD, "jet spectra with rho-area subtraction for MCD", false); - void processSpectraMCDWeighted(soa::Filtered>::iterator const& collision, + void processSpectraMCDWeighted(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracks const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { @@ -457,16 +713,201 @@ struct JetSpectraCharged { } registry.fill(HIST("h_jet_phat"), pTHat); registry.fill(HIST("h_jet_phat_weighted"), pTHat, jetweight); - fillJetHistograms(jet, collision.centrality(), collision.rho(), jetweight); + fillJetHistograms(jet, collision.centFT0M(), jetweight); } } PROCESS_SWITCH(JetSpectraCharged, processSpectraMCDWeighted, "jet finder QA mcd with weighted events", false); + void processSpectraAreaSubMCP(McParticleCollision::iterator const& mccollision, + soa::SmallGroups const& collisions, + soa::Join const& jets, + aod::JetParticles const&) + { + bool mcLevelIsParticleLevel = true; + + registry.fill(HIST("h_mcColl_counts_areasub"), 0.5); + if (std::abs(mccollision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 1.5); + if (collisions.size() < 1) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 2.5); + if (acceptSplitCollisions == 0 && collisions.size() > 1) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 3.5); + + bool hasSel8Coll = false; + bool centralityIsGood = false; + bool occupancyIsGood = false; + if (acceptSplitCollisions == 2) { + if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelectionBits, skipMBGapEvents)) { + hasSel8Coll = true; + } + if ((centralityMin < collisions.begin().centFT0M()) && (collisions.begin().centFT0M() < centralityMax)) { + centralityIsGood = true; + } + if ((trackOccupancyInTimeRangeMin < collisions.begin().trackOccupancyInTimeRange()) && (collisions.begin().trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMax)) { + occupancyIsGood = true; + } + } else { + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + hasSel8Coll = true; + } + if ((centralityMin < collision.centFT0M()) && (collision.centFT0M() < centralityMax)) { + centralityIsGood = true; + } + if ((trackOccupancyInTimeRangeMin < collision.trackOccupancyInTimeRange()) && (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMax)) { + occupancyIsGood = true; + } + } + } + if (!hasSel8Coll) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 4.5); + + if (!centralityIsGood) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 5.5); + + if (!occupancyIsGood) { + return; + } + registry.fill(HIST("h_mcColl_counts_areasub"), 6.5); + registry.fill(HIST("h_mcColl_rho"), mccollision.rho()); + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet, mcLevelIsParticleLevel)) { + continue; + } + fillMCPAreaSubHistograms(jet, mccollision.rho()); + } + } + PROCESS_SWITCH(JetSpectraCharged, processSpectraAreaSubMCP, "jet spectra with area-based subtraction for MC particle level", false); + + void processSpectraMCP(aod::JetMcCollision const& mccollision, + soa::SmallGroups const& collisions, + soa::Join const& jets, + aod::JetParticles const&) + { + bool mcLevelIsParticleLevel = true; + + registry.fill(HIST("h_mcColl_counts"), 0.5); + if (std::abs(mccollision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("h_mcColl_counts"), 1.5); + if (collisions.size() < 1) { + return; + } + registry.fill(HIST("h_mcColl_counts"), 2.5); + + bool hasSel8Coll = false; + bool centralityIsGood = false; + bool occupancyIsGood = false; + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + hasSel8Coll = true; + } + if ((centralityMin < collision.centFT0M()) && (collision.centFT0M() < centralityMax)) { + centralityIsGood = true; + } + if ((trackOccupancyInTimeRangeMin < collision.trackOccupancyInTimeRange()) && (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMax)) { + occupancyIsGood = true; + } + } + if (!hasSel8Coll) { + return; + } + registry.fill(HIST("h_mcColl_counts"), 3.5); + if (!centralityIsGood) { + return; + } + registry.fill(HIST("h_mcColl_counts"), 4.5); + if (!occupancyIsGood) { + return; + } + registry.fill(HIST("h_mcColl_counts"), 5.5); + registry.fill(HIST("h_mc_zvertex"), mccollision.posZ()); + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet, mcLevelIsParticleLevel)) { + continue; + } + fillMCPHistograms(jet); + } + } + PROCESS_SWITCH(JetSpectraCharged, processSpectraMCP, "jet spectra for MC particle level", false); + + void processSpectraMCPWeighted(aod::JetMcCollision const& mccollision, + soa::SmallGroups const& collisions, + soa::Join const& jets, + aod::JetParticles const&) + { + bool mcLevelIsParticleLevel = true; + float eventWeight = mccollision.weight(); + + registry.fill(HIST("h_mcColl_counts"), 0.5); + registry.fill(HIST("h_mcColl_counts_weight"), 0.5, eventWeight); + if (std::abs(mccollision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("h_mcColl_counts"), 1.5); + registry.fill(HIST("h_mcColl_counts_weight"), 1.5, eventWeight); + if (collisions.size() < 1) { + return; + } + registry.fill(HIST("h_mcColl_counts"), 2.5); + registry.fill(HIST("h_mcColl_counts_weight"), 2.5, eventWeight); + registry.fill(HIST("h_mc_zvertex"), mccollision.posZ(), eventWeight); + + bool hasSel8Coll = false; + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + hasSel8Coll = true; + } + } + if (!hasSel8Coll) { + return; + } + registry.fill(HIST("h_mcColl_counts"), 3.5); + registry.fill(HIST("h_mcColl_counts_weight"), 3.5, eventWeight); + + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet, mcLevelIsParticleLevel)) { + continue; + } + float jetweight = jet.eventWeight(); + double pTHat = 10. / (std::pow(jetweight, 1.0 / pTHatExponent)); + for (int N = 1; N < 21; N++) { + if (jet.pt() < N * 0.25 * pTHat && jet.r() == round(selectedJetsRadius * 100.0f)) { + registry.fill(HIST("h2_jet_ptcut_part"), jet.pt(), N * 0.25, jetweight); + } + } + registry.fill(HIST("h_jet_phat_part_weighted"), pTHat, jetweight); + fillMCPHistograms(jet, jetweight); + } + } + PROCESS_SWITCH(JetSpectraCharged, processSpectraMCPWeighted, "jet spectra for MC particle level weighted", false); + void processEvtWiseConstSubJetsData(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracksSub const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { @@ -479,7 +920,7 @@ struct JetSpectraCharged { if (!isAcceptedJet(jet)) { continue; } - fillEventWiseConstituentSubtractedHistograms(jet, collision.centrality()); + fillEventWiseConstituentSubtractedHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetSpectraCharged, processEvtWiseConstSubJetsData, "jet spectrum for eventwise constituent-subtracted jets data", false); @@ -488,7 +929,7 @@ struct JetSpectraCharged { soa::Join const& jets, aod::JetTracksSub const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { @@ -501,7 +942,7 @@ struct JetSpectraCharged { if (!isAcceptedJet(jet)) { continue; } - fillEventWiseConstituentSubtractedHistograms(jet, collision.centrality()); + fillEventWiseConstituentSubtractedHistograms(jet, collision.centFT0M()); } } PROCESS_SWITCH(JetSpectraCharged, processEvtWiseConstSubJetsMCD, "jet spectrum for eventwise constituent-subtracted mcd jets", false); @@ -511,7 +952,7 @@ struct JetSpectraCharged { ChargedMCPMatchedJets const&, aod::JetTracks const&, aod::JetParticles const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { @@ -519,9 +960,6 @@ struct JetSpectraCharged { } for (const auto& mcdjet : mcdjets) { - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } if (!isAcceptedJet(mcdjet)) { continue; } @@ -535,16 +973,13 @@ struct JetSpectraCharged { ChargedMCPMatchedJetsWeighted const&, aod::JetTracks const&, aod::JetParticles const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } for (const auto& mcdjet : mcdjets) { - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } if (!isAcceptedJet(mcdjet)) { continue; } @@ -553,27 +988,45 @@ struct JetSpectraCharged { } PROCESS_SWITCH(JetSpectraCharged, processJetsMatchedWeighted, "matched mcp and mcd jets with weighted events", false); - void processJetsMatchedSubtracted(soa::Filtered>::iterator const& collision, + void processJetsMatchedSubtracted(McParticleCollision::iterator const& mccollision, + soa::SmallGroups> const& collisions, ChargedMCDMatchedJets const& mcdjets, ChargedMCPMatchedJets const&, aod::JetTracks const&, aod::JetParticles const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + registry.fill(HIST("h_mc_collisions_matched"), 0.5); + if (mccollision.size() < 1) { return; } - if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + registry.fill(HIST("h_mc_collisions_matched"), 1.5); + if (!(std::abs(mccollision.posZ()) < vertexZCut)) { return; } - - for (const auto& mcdjet : mcdjets) { - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + registry.fill(HIST("h_mc_collisions_matched"), 2.5); + double mcrho = mccollision.rho(); + registry.fill(HIST("h_mc_rho_matched"), mcrho); + for (const auto& collision : collisions) { + registry.fill(HIST("h_mcd_events_matched"), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents) || !(std::abs(collision.posZ()) < vertexZCut)) { continue; } - if (!isAcceptedJet(mcdjet)) { + registry.fill(HIST("h_mcd_events_matched"), 1.5); + if (collision.centFT0M() < centralityMin || collision.centFT0M() > centralityMax) { continue; } - // now only do subtraction for MCD jets, need to add subtraction for MCP jets - fillGeoMatchedCorrHistograms(mcdjet, collision.rho()); + registry.fill(HIST("h_mcd_events_matched"), 2.5); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + registry.fill(HIST("h_mcd_events_matched"), 3.5); + + auto collmcdjets = mcdjets.sliceBy(mcdjetsPerJCollision, collision.globalIndex()); + for (const auto& mcdjet : collmcdjets) { + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillGeoMatchedCorrHistograms(mcdjet, collision.rho(), mcrho); + } } } PROCESS_SWITCH(JetSpectraCharged, processJetsMatchedSubtracted, "matched mcp and mcd jets after subtraction", false); @@ -581,5 +1034,5 @@ struct JetSpectraCharged { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-spectra-charged"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGJE/Tasks/jetSpectraEseTask.cxx b/PWGJE/Tasks/jetSpectraEseTask.cxx index 616775758bc..007b2ea511d 100644 --- a/PWGJE/Tasks/jetSpectraEseTask.cxx +++ b/PWGJE/Tasks/jetSpectraEseTask.cxx @@ -14,58 +14,96 @@ /// /// \author Joachim C. K. B. Hansen, Lund University -#include -#include -#include - -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGJE/Core/FastJetUtilities.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" #include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/EseTable.h" #include "Common/DataModel/Qvectors.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" -#include "Framework/StaticFor.h" - struct JetSpectraEseTask { - ConfigurableAxis binJetPt{"binJetPt", {200, 0., 200.}, ""}; - ConfigurableAxis bindPhi{"bindPhi", {100, -o2::constants::math::PI - 1, o2::constants::math::PI + 1}, ""}; + ConfigurableAxis binJetPt{"binJetPt", {250, -50., 200.}, ""}; + ConfigurableAxis bindPhi{"bindPhi", {180, -o2::constants::math::PI, o2::constants::math::PI}, ""}; ConfigurableAxis binESE{"binESE", {100, 0, 100}, ""}; ConfigurableAxis binCos{"binCos", {100, -1.05, 1.05}, ""}; ConfigurableAxis binOccupancy{"binOccupancy", {5000, 0, 25000}, ""}; - ConfigurableAxis binQVec{"binQVec", {100, -3, 3}, ""}; + ConfigurableAxis binQVec{"binQVec", {500, -3, 3}, ""}; + ConfigurableAxis binCentrality{"binCentrality", {101, -1, 100}, ""}; + ConfigurableAxis binPhi{"binPhi", {60, -1.0, 7.0}, ""}; + ConfigurableAxis binEta{"binEta", {80, -0.9, 0.9}, ""}; + ConfigurableAxis binFit0{"binFit0", {100, 0, 50}, ""}; + ConfigurableAxis binFit13{"binFit13", {100, 0, 1.4}, ""}; + ConfigurableAxis binFit24{"binFit24", {100, 0, 10}, ""}; Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; Configurable jetR{"jetR", 0.2, "jet resolution parameter"}; + Configurable randomConeR{"randomConeR", 0.4, "size of random Cone for estimating background fluctuations"}; + Configurable randomConeLeadJetDeltaR{"randomConeLeadJetDeltaR", -99.0, "min distance between leading jet axis and random cone (RC) axis; if negative, min distance is set to automatic value of R_leadJet+R_RC "}; Configurable vertexZCut{"vertexZCut", 10.0, "vertex z cut"}; - Configurable> centRange{"centRange", {30, 50}, "centrality region of interest"}; - Configurable leadingJetPtCut{"leadingJetPtCut", 5.0, "leading jet pT cut"}; - - Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + Configurable> centRange{"centRange", {0, 90}, "centrality region of interest"}; + Configurable cfgSelCentrality{"cfgSelCentrality", true, "Flag for centrality selection"}; + // Configurable leadingTrackPtCut{"leadingTrackPtCut", 5.0, "leading jet pT cut"}; + Configurable jetAreaFractionMin{"jetAreaFractionMin", -99, "used to make a cut on the jet areas"}; + Configurable cfgCentVariant{"cfgCentVariant", false, "Flag for centrality variant 1"}; + Configurable cfgisPbPb{"cfgisPbPb", false, "Flag for using MC centrality in PbPb"}; + Configurable cfgbkgSubMC{"cfgbkgSubMC", true, "Flag for MC background subtraction"}; + Configurable cfgUseMCEventWeights{"cfgUseMCEventWeights", false, "Flag for using MC event weights"}; + Configurable leadingConstituentPtMin{"leadingConstituentPtMin", -99.0, "minimum pT selection on jet constituent"}; + Configurable leadingConstituentPtMax{"leadingConstituentPtMax", 9999.0, "maximum pT selection on jet constituent"}; + Configurable checkLeadConstituentMinPtForMcpJets{"checkLeadConstituentMinPtForMcpJets", false, "flag to choose whether particle level jets should have their lead track pt above leadingConstituentPtMin to be accepted; off by default, as leadingConstituentPtMin cut is only applied on MCD jets for the Pb-Pb analysis using pp MC anchored to Pb-Pb for the response matrix"}; + Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; + Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; + Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; + + Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum eta acceptance for tracks"}; + Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum eta acceptance for tracks"}; + Configurable trackPtMin{"trackPtMin", 0.15, "minimum pT acceptance for tracks"}; + Configurable trackPtMax{"trackPtMax", 200.0, "maximum pT acceptance for tracks"}; + + Configurable jetEtaMin{"jetEtaMin", -0.7, "minimum jet pseudorapidity"}; + Configurable jetEtaMax{"jetEtaMax", 0.7, "maximum jet pseudorapidity"}; + + Configurable eventSelections{"eventSelections", "sel8FullPbPb", "choose event selection"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; - Configurable fColSwitch{"fColSwitch", 0, "collision switch"}; + Configurable cfgEvSelOccupancy{"cfgEvSelOccupancy", true, "Flag for occupancy cut"}; - Configurable cfgEvSelOccupancy{"cfgEvSelOccupancy", false, "Flag for occupancy cut"}; - Configurable> cfgCutOccupancy{"cfgCutOccupancy", {0, 500}, "Occupancy cut"}; + Configurable> cfgCutOccupancy{"cfgCutOccupancy", {0, 1000}, "Occupancy cut"}; Configurable> cfgOccupancyPtCut{"cfgOccupancyPtCut", {0, 100}, "pT cut"}; + Configurable cfgrhoPhi{"cfgrhoPhi", true, "Flag for rho(phi)"}; + Configurable cfgnTotalSystem{"cfgnTotalSystem", 7, "total qvector number // look in Qvector table for this number"}; Configurable cfgnCorrLevel{"cfgnCorrLevel", 3, "QVector step: 0 = no corr, 1 = rect, 2 = twist, 3 = full"}; @@ -79,11 +117,24 @@ struct JetSpectraEseTask { AxisSpec cosAxis = {binCos, ""}; AxisSpec occAxis = {binOccupancy, "Occupancy"}; AxisSpec qvecAxis = {binQVec, "Q-vector"}; + AxisSpec centAxis = {binCentrality, "Centrality"}; + AxisSpec phiAxis = {binPhi, "#phi"}; + AxisSpec etaAxis = {binEta, "#eta"}; + AxisSpec fitAxis0 = {binFit0, "Fit0"}; + AxisSpec fitAxis13 = {binFit13, "Fit13"}; + AxisSpec fitAxis24 = {binFit24, "Fit24"}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - int eventSelection = -1; - int trackSelection = -1; + std::vector eventSelectionBits; + int trackSelection{-1}; + + Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); + Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f) && nabs(aod::jet::eta) < 0.9f - jetR; + Filter colFilter = nabs(aod::jcollision::posZ) < vertexZCut; + Filter mcCollisionFilter = nabs(aod::jmccollision::posZ) < vertexZCut; + using ChargedMCDJets = soa::Filtered>; + Preslice mcdjetsPerJCollision = o2::aod::jet::collisionId; enum class DetID { FT0C, FT0A, @@ -93,141 +144,260 @@ struct JetSpectraEseTask { TPCneg, TPCall }; + struct EventPlane { + float psi2; + float psi3; + }; + + struct EventPlaneFiller { + bool psi; + bool hist; + }; + + static constexpr EventPlaneFiller PsiFillerEP = {true, true}; + static constexpr EventPlaneFiller PsiFillerEse = {true, false}; + static constexpr EventPlaneFiller PsiFillerOcc = {false, false}; + void init(o2::framework::InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); LOGF(info, "jetSpectraEse::init()"); - switch (fColSwitch) { - case 0: - LOGF(info, "JetSpectraEseTask::init() - using data"); - registry.add("hEventCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); - registry.add("hJetPt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); - registry.add("hJetPt_bkgsub", "jet pT background sub;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); - registry.add("hJetEta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); - registry.add("hJetPhi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); - registry.add("hRho", ";#rho;entries", {HistType::kTH1F, {{100, 0, 200.}}}); - registry.add("hJetArea", ";area_{jet};entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("hdPhi", "#Delta#phi;entries;", {HistType::kTH1F, {{dPhiAxis}}}); - registry.add("hCentJetPtdPhiq2", "", {HistType::kTHnSparseF, {{100, 0, 100}, {jetPtAxis}, {dPhiAxis}, {eseAxis}}}); - registry.add("hPsi2FT0C", ";Centrality; #Psi_{2}", {HistType::kTH2F, {{100, 0, 100}, {150, -2.5, 2.5}}}); - registry.addClone("hPsi2FT0C", "hPsi2FT0A"); - registry.addClone("hPsi2FT0C", "hPsi2FV0A"); - registry.addClone("hPsi2FT0C", "hPsi2TPCpos"); - registry.addClone("hPsi2FT0C", "hPsi2TPCneg"); - - registry.add("hCosPsi2AmC", ";Centrality;cos(2(#Psi_{2}^{A}-#Psi_{2}^{B}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); - registry.addClone("hCosPsi2AmC", "hCosPsi2AmB"); - registry.addClone("hCosPsi2AmC", "hCosPsi2BmC"); - - registry.add("hQvecUncorV2", ";Centrality;Q_x;Q_y", {HistType::kTH3F, {{100, 0, 100}, {qvecAxis}, {qvecAxis}}}); - registry.addClone("hQvecUncorV2", "hQvecRectrV2"); - registry.addClone("hQvecUncorV2", "hQvecTwistV2"); - registry.addClone("hQvecUncorV2", "hQvecFinalV2"); - - registry.addClone("hPsi2FT0C", "hEPUncorV2"); - registry.addClone("hPsi2FT0C", "hEPRectrV2"); - registry.addClone("hPsi2FT0C", "hEPTwistV2"); - break; - case 1: - LOGF(info, "JetSpectraEseTask::init() - using MC"); - registry.add("hMCEventCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); - registry.add("hPartJetPt", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); - registry.add("hPartJetEta", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); - registry.add("hPartJetPhi", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); - registry.add("hPartJetPtMatch", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); - registry.add("hPartJetEtaMatch", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); - registry.add("hPartJetPhiMatch", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); - registry.add("hDetectorJetPt", "detector level jet pT;#it{p}_{T,jet det} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); - registry.add("hDetectorJetEta", "detector level jet #eta;#eta_{jet det};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); - registry.add("hDetectorJetPhi", "detector level jet #phi;#phi_{jet det};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); - registry.add("hMatchedJetsPtDelta", "#it{p}_{T,jet part}; det - part", {HistType::kTH2F, {{jetPtAxis}, {200, -20., 20.0}}}); - registry.add("hMatchedJetsEtaDelta", "#eta_{jet part}; det - part", {HistType::kTH2F, {{100, -1.0, 1.0}, {200, -20.0, 20.0}}}); - registry.add("hMatchedJetsPhiDelta", "#phi_{jet part}; det - part", {HistType::kTH2F, {{80, -1.0, 7.}, {200, -20.0, 20.}}}); - registry.add("hResponseMatrixMatch", "#it{p}_{T, jet det}; #it{p}_{T, jet part}", HistType::kTH2F, {jetPtAxis, jetPtAxis}); - break; - case 2: - LOGF(info, "JetSpectraEseTask::init() - using Occupancy processing"); - registry.add("hEventCounterOcc", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); - registry.add("hTrackPt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTHnSparseF, {{100, 0, 100}, {100, 0, 100}, {eseAxis}, {occAxis}}}); - registry.add("hTrackEta", "track #eta;#eta_{track};entries", {HistType::kTH3F, {{100, 0, 100}, {100, -1.0, 1.0}, {occAxis}}}); - registry.add("hTrackPhi", "track #phi;#phi_{track};entries", {HistType::kTH3F, {{100, 0, 100}, {80, -1.0, 7.}, {occAxis}}}); - registry.add("hOccupancy", "Occupancy;Occupancy;entries", {HistType::kTH1F, {{occAxis}}}); - registry.add("hPsiOccupancy", "Occupancy;#Psi_{2};entries", {HistType::kTH3F, {{100, 0, 100}, {150, -2.5, 2.5}, {occAxis}}}); - break; + if (doprocessESEDataCharged) { + LOGF(info, "JetSpectraEseTask::init() - ESE Data Process"); + registry.add("hEventCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.add("hCentralitySel", ";Centrality;entries", {HistType::kTH1F, {{centAxis}}}); + registry.add("hCentralityAnalyzed", ";Centrality;entries", {HistType::kTH1F, {{centAxis}}}); + registry.add("hTrackCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.add("hJetPt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); + registry.add("hJetPt_bkgsub", "jet pT background sub;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); + registry.add("hJetEta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{etaAxis}}}); + registry.add("hJetPhi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{phiAxis}}}); + registry.add("hRho", ";#rho;entries", {HistType::kTH2F, {{centAxis}, {100, 0, 200.}}}); + registry.add("hRhoPhi", ";#rho;entries", {HistType::kTH2F, {{centAxis}, {100, 0, 200.}}}); + registry.add("hJetArea", ";area_{jet};entries", {HistType::kTH1F, {{80, 0, 10.}}}); + registry.add("hCentJetPtdPhiq2", "", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {dPhiAxis}, {eseAxis}}}); + registry.add("hCentJetPtdPhiq2RhoPhi", "", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {dPhiAxis}, {eseAxis}}}); + + registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(1, "Input event"); + registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(2, "Event selection"); + registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(3, "Occupancy cut"); + registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(4, "ESE available"); + registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(5, "Lead track"); + registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(6, "Jet loop"); + registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(7, "Centrality analyzed"); + + registry.add("hPhiPtsum", "jet sumpt;sum p_{T};entries", {HistType::kTH1F, {{40, 0., o2::constants::math::TwoPI}}}); + registry.add("hfitPar0", "", {HistType::kTH2F, {{centAxis}, {fitAxis0}}}); + registry.add("hfitPar1", "", {HistType::kTH2F, {{centAxis}, {fitAxis13}}}); + registry.add("hfitPar2", "", {HistType::kTH2F, {{centAxis}, {fitAxis24}}}); + registry.add("hfitPar3", "", {HistType::kTH2F, {{centAxis}, {fitAxis13}}}); + registry.add("hfitPar4", "", {HistType::kTH2F, {{centAxis}, {fitAxis24}}}); + registry.add("hPValueCentCDF", "p-value cDF vs centrality; centrality; p-value", {HistType::kTH2F, {{centAxis}, {40, 0, 1}}}); + registry.add("hCentChi2Ndf", "Chi2 vs centrality; centrality; #tilde{#chi^{2}}", {HistType::kTH2F, {{centAxis}, {100, 0, 5}}}); + registry.add("hCentPhi", "centrality vs #rho(#varphi); centrality; #rho(#varphi) ", {HistType::kTH2F, {{centAxis}, {210, -10.0, 200.0}}}); + registry.add("hdPhiRhoPhi", "#varphi vs #rho(#varphi); #varphi - #Psi_{EP,2}; #rho(#varphi) ", {HistType::kTH2F, {{40, -o2::constants::math::PI, o2::constants::math::PI}, {210, -10.0, 200.0}}}); + } + if (doprocessESEEPData) { + LOGF(info, "JetSpectraEseTask::init() - Event Plane Process"); + registry.add("hPsi2FT0C", ";Centrality; #Psi_{2}", {HistType::kTH2F, {{centAxis}, {150, -2.5, 2.5}}}); + registry.addClone("hPsi2FT0C", "hPsi2FT0A"); + registry.addClone("hPsi2FT0C", "hPsi2FV0A"); + registry.addClone("hPsi2FT0C", "hPsi2TPCpos"); + registry.addClone("hPsi2FT0C", "hPsi2TPCneg"); + registry.add("hCosPsi2AmC", ";Centrality;cos(2(#Psi_{2}^{A}-#Psi_{2}^{B}));#it{q}_{2}", {HistType::kTH3F, {{centAxis}, {cosAxis}, {eseAxis}}}); + registry.addClone("hCosPsi2AmC", "hCosPsi2AmB"); + registry.addClone("hCosPsi2AmC", "hCosPsi2BmC"); + registry.add("hQvecUncorV2", ";Centrality;Q_x;Q_y", {HistType::kTH3F, {{centAxis}, {qvecAxis}, {qvecAxis}}}); + registry.addClone("hQvecUncorV2", "hQvecRectrV2"); + registry.addClone("hQvecUncorV2", "hQvecTwistV2"); + registry.addClone("hQvecUncorV2", "hQvecFinalV2"); + registry.addClone("hPsi2FT0C", "hEPUncorV2"); + registry.addClone("hPsi2FT0C", "hEPRectrV2"); + registry.addClone("hPsi2FT0C", "hEPTwistV2"); + } + if (doprocessESEBackground) { + LOGF(info, "JetSpectraEseTask::init() - Background Process"); + registry.add("hCentRhoRandomCone", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, {800, -400.0, 400.0}}}); + registry.add("hCentRhoRandomConeRandomTrackDir", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTH2F, {{1100, 0., 110.}, {800, -400.0, 400.0}}}); + registry.add("hCentRhoRandomConewoLeadingJet", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTHnSparseF, {{centAxis}, {800, -400.0, 400.0}, {dPhiAxis}, {eseAxis}}}); + registry.add("hCentRhoRandomConeRndTrackDirwoOneLeadingJet", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTHnSparseF, {{centAxis}, {800, -400.0, 400.0}, {dPhiAxis}, {eseAxis}}}); + registry.add("hCentRhoRandomConeRndTrackDirwoTwoLeadingJet", "; centrality; #it{p}_{T,random cone} - #it{area, random cone} * #it{rho} (GeV/c);", {HistType::kTHnSparseF, {{centAxis}, {800, -400.0, 400.0}, {dPhiAxis}, {eseAxis}}}); + } + if (doprocessMCParticleLevel) { + LOGF(info, "JetSpectraEseTask::init() - MC Particle level"); + registry.add("mcp/hEventCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.add("mcp/hCentralitySel", ";centr;entries", {HistType::kTH1F, {{centAxis}}}); + // registry.add("mcp/hJetSparse", ";Centrality;#it{p}_{T,jet part}; #eta; #phi", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {etaAxis}, {phiAxis}}}); + registry.add("mcp/hJetSparse", ";Centrality;#it{p}_{T,jet part}; #eta; #phi", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {etaAxis}, {phiAxis}}}); + // registry.add("mcp/hJetPt", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); + // registry.add("mcp/hJetEta", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{etaAxis}}}); + // registry.add("mcp/hJetPhi", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{phiAxis}}}); + + registry.get(HIST("mcp/hEventCounter"))->GetXaxis()->SetBinLabel(1, "Input event"); + registry.get(HIST("mcp/hEventCounter"))->GetXaxis()->SetBinLabel(2, "Collision size < 1"); + registry.get(HIST("mcp/hEventCounter"))->GetXaxis()->SetBinLabel(3, "MCD size != 1"); + registry.get(HIST("mcp/hEventCounter"))->GetXaxis()->SetBinLabel(4, "Occupancy cut"); + } + if (doprocessMCDetectorLevel) { + LOGF(info, "JetSpectraEseTask::init() - MC Detector level"); + registry.add("mcd/hEventCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.add("mcd/hCentralitySel", ";centr;entries", {HistType::kTH1F, {{centAxis}}}); + // registry.add("mcd/hJetPt", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); + // registry.add("mcd/hJetSparse", ";Centrality;#it{p}_{T,jet det}; #eta; #phi", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {etaAxis}, {phiAxis}}}); + registry.add("mcd/hJetSparse", ";Centrality;#it{p}_{T,jet det}; #eta; #phi", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {etaAxis}, {phiAxis}}}); + // registry.add("mcd/hJetEta", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{etaAxis}}}); + // registry.add("mcd/hJetPhi", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{phiAxis}}}); + + registry.get(HIST("mcd/hEventCounter"))->GetXaxis()->SetBinLabel(1, "Input event"); + registry.get(HIST("mcd/hEventCounter"))->GetXaxis()->SetBinLabel(2, "Collision size < 1"); + registry.get(HIST("mcd/hEventCounter"))->GetXaxis()->SetBinLabel(3, "Occupancy cut"); + } + if (doprocessMCChargedMatched) { + LOGF(info, "JetSpectraEseTask::init() - MC Charged Matched"); + + registry.add("mcm/hJetSparse", ";Centrality;#it{p}_{T,jet det}; #eta; #phi", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {etaAxis}, {phiAxis}}}); /* detector level */ + // registry.add("mcm/hPartSparseMatch", ";Centrality;#it{p}_{T,jet part}; #eta; #phi", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {etaAxis}, {phiAxis}}}); + registry.addClone("mcm/hJetSparse", "mcm/hDetSparseMatch"); + registry.addClone("mcm/hJetSparse", "mcm/hPartSparseMatch"); + + registry.add("mcm/hMCEventCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.add("mcm/hMCDMatchedEventCounter", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.add("mcm/hCentralityAnalyzed", ";Centrality;entries", {HistType::kTH1F, {{centAxis}}}); + + registry.add("mcm/hMatchedJetsPtDelta", "#it{p}_{T,jet part}; det - part", {HistType::kTH2F, {{jetPtAxis}, {100, -20., 20.0}}}); + registry.add("mcm/hGenMatchedJetsPtDeltadPt", "#it{p}_{T,jet part}; det - part / part", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {200, -20., 20.0}}}); + registry.add("mcm/hRecoMatchedJetsPtDeltadPt", "#it{p}_{T,jet det}; det - part / det", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {200, -20., 20.0}}}); + registry.add("mcm/hMatchedJetsEtaDelta", "#eta_{jet part}; det - part", {HistType::kTH2F, {{etaAxis}, {200, -0.8, 0.8}}}); + registry.add("mcm/hMatchedJetsPhiDelta", "#phi_{jet part}; det - part", {HistType::kTH2F, {{phiAxis}, {200, -10.0, 10.}}}); + + registry.add("mcm/hRespMcDMcPMatch", ";Centrality,#it{p}_{T, jet det}; #it{p}_{T, jet part}", {HistType::kTHnSparseF, {{centAxis}, {jetPtAxis}, {jetPtAxis}}}); + + registry.get(HIST("mcm/hMCEventCounter"))->GetXaxis()->SetBinLabel(1, "Input event"); + registry.get(HIST("mcm/hMCEventCounter"))->GetXaxis()->SetBinLabel(2, "Collision size < 1"); + registry.get(HIST("mcm/hMCEventCounter"))->GetXaxis()->SetBinLabel(3, "Vertex cut"); + registry.get(HIST("mcm/hMCEventCounter"))->GetXaxis()->SetBinLabel(4, "After analysis"); + registry.get(HIST("mcm/hMCDMatchedEventCounter"))->GetXaxis()->SetBinLabel(1, "Input event"); + registry.get(HIST("mcm/hMCDMatchedEventCounter"))->GetXaxis()->SetBinLabel(2, "Vertex cut"); + registry.get(HIST("mcm/hMCDMatchedEventCounter"))->GetXaxis()->SetBinLabel(3, "Event selection"); + registry.get(HIST("mcm/hMCDMatchedEventCounter"))->GetXaxis()->SetBinLabel(4, "Occupancy cut"); + registry.get(HIST("mcm/hMCDMatchedEventCounter"))->GetXaxis()->SetBinLabel(5, "Centrality cut1:cut2"); + registry.get(HIST("mcm/hMCDMatchedEventCounter"))->GetXaxis()->SetBinLabel(6, "After analysis"); + } + if (doprocessESEOccupancy) { + LOGF(info, "JetSpectraEseTask::init() - Occupancy QA"); + registry.add("hEventCounterOcc", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.add("hTrackPt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTHnSparseF, {{centAxis}, {100, 0, 100}, {eseAxis}, {occAxis}}}); + registry.add("hTrackEta", "track #eta;#eta_{track};entries", {HistType::kTH3F, {{centAxis}, {etaAxis}, {occAxis}}}); + registry.add("hTrackPhi", "track #phi;#phi_{track};entries", {HistType::kTH3F, {{centAxis}, {phiAxis}, {occAxis}}}); + registry.add("hOccupancy", "Occupancy;Occupancy;entries", {HistType::kTH1F, {{occAxis}}}); + registry.add("hPsiOccupancy", "Occupancy;#Psi_{2};entries", {HistType::kTH3F, {{centAxis}, {150, -2.5, 2.5}, {occAxis}}}); } } - Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f) && nabs(aod::jet::eta) < 0.9f - jetR; - Filter colFilter = nabs(aod::jcollision::posZ) < vertexZCut; - Filter mcCollisionFilter = nabs(aod::jmccollision::posZ) < vertexZCut; - void processESEDataCharged(soa::Join::iterator const& collision, - soa::Filtered const& jets, + soa::Filtered> const& jets, aod::JetTracks const& tracks) { float counter{0.5f}; registry.fill(HIST("hEventCounter"), counter++); - registry.fill(HIST("hEventCounter"), counter++); - - const auto vPsi2 = procEP(collision); - const auto qPerc = collision.qPERCFT0C(); - if (qPerc[0] < 0) + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) return; registry.fill(HIST("hEventCounter"), counter++); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) + if (cfgEvSelOccupancy && !isOccupancyAccepted(collision)) return; - registry.fill(HIST("hEventCounter"), counter++); - if (!isAcceptedLeadTrack(tracks)) + auto centrality = cfgCentVariant ? collision.centFT0CVariant1() : collision.centFT0M(); + if (cfgSelCentrality && !isCentralitySelected(centrality)) return; + registry.fill(HIST("hCentralitySel"), centrality); - if (cfgEvSelOccupancy) { - auto occupancy = collision.trackOccupancyInTimeRange(); - if (occupancy < cfgCutOccupancy->at(0) || occupancy > cfgCutOccupancy->at(1)) - registry.fill(HIST("hEventCounter"), counter++); + const auto psi{procEP(collision)}; + const auto qPerc{collision.qPERCFT0C()}; + if (qPerc[0] < 0) return; + registry.fill(HIST("hEventCounter"), counter++); + std::unique_ptr rhoFit{nullptr}; + if (cfgrhoPhi) { + rhoFit = fitRho(collision, psi, tracks, jets); + if (!rhoFit) + return; } registry.fill(HIST("hEventCounter"), counter++); - registry.fill(HIST("hRho"), collision.rho()); + registry.fill(HIST("hRho"), centrality, collision.rho()); + registry.fill(HIST("hCentralityAnalyzed"), centrality); for (auto const& jet : jets) { - float jetpTbkgsub = jet.pt() - (collision.rho() * jet.area()); + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) + continue; + if (!isAcceptedJet(jet)) { + continue; + } registry.fill(HIST("hJetPt"), jet.pt()); - registry.fill(HIST("hJetPt_bkgsub"), jetpTbkgsub); + registry.fill(HIST("hJetPt_bkgsub"), jet.pt() - collision.rho() * jet.area()); registry.fill(HIST("hJetEta"), jet.eta()); registry.fill(HIST("hJetPhi"), jet.phi()); registry.fill(HIST("hJetArea"), jet.area()); - float dPhi = RecoDecay::constrainAngle(jet.phi() - vPsi2, -o2::constants::math::PI); - registry.fill(HIST("hdPhi"), dPhi); - registry.fill(HIST("hCentJetPtdPhiq2"), collision.centrality(), jetpTbkgsub, dPhi, qPerc[0]); + float dPhi{RecoDecay::constrainAngle(jet.phi() - psi.psi2, -o2::constants::math::PI)}; + registry.fill(HIST("hCentJetPtdPhiq2"), centrality, jet.pt() - (collision.rho() * jet.area()), dPhi, qPerc[0]); + + if (cfgrhoPhi) { + auto rhoLocal = evalRho(rhoFit.get(), jetR, jet.phi(), collision.rho()); + registry.fill(HIST("hRhoPhi"), centrality, rhoLocal); + registry.fill(HIST("hCentJetPtdPhiq2RhoPhi"), centrality, jet.pt() - (rhoLocal * jet.area()), dPhi, qPerc[0]); + registry.fill(HIST("hCentPhi"), centrality, rhoFit->Eval(jet.phi())); + registry.fill(HIST("hdPhiRhoPhi"), dPhi, rhoLocal); + } } registry.fill(HIST("hEventCounter"), counter++); - if (collision.centrality() < centRange->at(0) || collision.centrality() > centRange->at(1)) /* for counting */ + if (centrality < 30 || centrality > 50) return; registry.fill(HIST("hEventCounter"), counter++); } PROCESS_SWITCH(JetSpectraEseTask, processESEDataCharged, "process ese collisions", true); + void processESEEPData(soa::Join::iterator const& collision, + soa::Filtered const&, + aod::JetTracks const&) + { + + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) + return; + + if (cfgEvSelOccupancy && !isOccupancyAccepted(collision)) + return; + + [[maybe_unused]] const auto psi{procEP(collision)}; + } + PROCESS_SWITCH(JetSpectraEseTask, processESEEPData, "process ese collisions for filling EP and EPR", false); + + void processESEBackground(soa::Filtered>::iterator const& collision, + soa::Join const& jets, + aod::JetTracks const& tracks) + { + bkgFluctuationsRandomCone(collision, jets, tracks); + } + PROCESS_SWITCH(JetSpectraEseTask, processESEBackground, "process random cones with event plane and ESE", false); + void processESEOccupancy(soa::Join::iterator const& collision, soa::Join const& tracks) { float count{0.5}; registry.fill(HIST("hEventCounterOcc"), count++); - const auto vPsi2 = procEP(collision); - const auto qPerc = collision.qPERCFT0C(); + const auto psi{procEP(collision)}; + const auto qPerc{collision.qPERCFT0C()}; - auto occupancy = collision.trackOccupancyInTimeRange(); - registry.fill(HIST("hPsiOccupancy"), collision.centrality(), vPsi2, occupancy); + auto occupancy{collision.trackOccupancyInTimeRange()}; + registry.fill(HIST("hPsiOccupancy"), collision.centFT0M(), psi.psi2, occupancy); registry.fill(HIST("hOccupancy"), occupancy); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) return; registry.fill(HIST("hEventCounterOcc"), count++); @@ -235,103 +405,176 @@ struct JetSpectraEseTask { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) continue; - registry.fill(HIST("hTrackPt"), collision.centrality(), track.pt(), qPerc[0], occupancy); + registry.fill(HIST("hTrackPt"), collision.centFT0M(), track.pt(), qPerc[0], occupancy); if (track.pt() < cfgOccupancyPtCut->at(0) || track.pt() > cfgOccupancyPtCut->at(1)) continue; - registry.fill(HIST("hTrackEta"), collision.centrality(), track.eta(), occupancy); - registry.fill(HIST("hTrackPhi"), collision.centrality(), track.phi(), occupancy); + registry.fill(HIST("hTrackEta"), collision.centFT0M(), track.eta(), occupancy); + registry.fill(HIST("hTrackPhi"), collision.centFT0M(), track.phi(), occupancy); } } PROCESS_SWITCH(JetSpectraEseTask, processESEOccupancy, "process occupancy", false); - void processMCParticleLevel(soa::Filtered::iterator const& jet) + void processMCParticleLevel(soa::Filtered>::iterator const& mcCollision, + soa::SmallGroups const& collisions, + soa::Filtered> const& jets, + aod::JetParticles const&) { - registry.fill(HIST("hPartJetPt"), jet.pt()); - registry.fill(HIST("hPartJetEta"), jet.eta()); - registry.fill(HIST("hPartJetPhi"), jet.phi()); + float counter{0.5f}; + registry.fill(HIST("mcp/hEventCounter"), counter++); + if (mcCollision.size() < 1) { + return; + } + registry.fill(HIST("mcp/hEventCounter"), counter++); + if (collisions.size() != 1) { + return; + } + + registry.fill(HIST("mcp/hEventCounter"), counter++); + auto centrality{-1}; + bool fOccupancy = true; + bool eventSel = true; + for (const auto& col : collisions) { + if (cfgisPbPb) + centrality = col.centFT0M(); + if (cfgEvSelOccupancy && !isOccupancyAccepted(col)) + fOccupancy = false; + if (!jetderiveddatautilities::selectCollision(col, eventSelectionBits)) + eventSel = false; + } + if (cfgEvSelOccupancy && !fOccupancy) + return; + if (!(std::abs(mcCollision.posZ()) < vertexZCut)) { + return; + } + if (!eventSel) + return; + + registry.fill(HIST("mcp/hEventCounter"), counter++); + + registry.fill(HIST("mcp/hCentralitySel"), centrality); + jetLoopMCP(jets, centrality, mcCollision.rho()); } PROCESS_SWITCH(JetSpectraEseTask, processMCParticleLevel, "jets on particle level MC", false); + void processMCDetectorLevel(soa::Filtered>::iterator const& collision, + ChargedMCDJets const& mcdjets, + aod::JetTracks const&, + aod::JetParticles const&) + { + float counter{0.5f}; + registry.fill(HIST("mcd/hEventCounter"), counter++); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) + return; + registry.fill(HIST("mcd/hEventCounter"), counter++); + if (cfgEvSelOccupancy && !isOccupancyAccepted(collision)) + return; + registry.fill(HIST("mcd/hEventCounter"), counter++); + + if (!(std::abs(collision.posZ()) < vertexZCut)) { + return; + } + + auto centrality = cfgisPbPb ? collision.centFT0M() : -1; + + registry.fill(HIST("mcd/hCentralitySel"), centrality); + jetLoopMCD(mcdjets, centrality, collision.rho()); + } + PROCESS_SWITCH(JetSpectraEseTask, processMCDetectorLevel, "jets on detector level", false); + using JetMCPTable = soa::Filtered>; - void processMCChargedMatched(soa::Filtered::iterator const& collision, - soa::Filtered> const& mcdjets, + void processMCChargedMatched(soa::Filtered>::iterator const& mcCol, + soa::SmallGroups> const& collisions, + ChargedMCDJets const& mcdjets, JetMCPTable const&, aod::JetTracks const&, aod::JetParticles const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) + float counter{0.5f}; + registry.fill(HIST("mcm/hMCEventCounter"), counter++); + if (mcCol.size() < 1) { return; + } + if (collisions.size() != 1) { + return; + } + registry.fill(HIST("mcm/hMCEventCounter"), counter++); + if (!(std::abs(mcCol.posZ()) < vertexZCut)) { + return; + } + registry.fill(HIST("mcm/hMCEventCounter"), counter++); - float counter{0.5f}; - registry.fill(HIST("hMCEventCounter"), counter++); - for (const auto& mcdjet : mcdjets) { + for (const auto& collision : collisions) { + float secCount{0.5f}; + registry.fill(HIST("mcm/hMCDMatchedEventCounter"), secCount++); + if (!(std::abs(collision.posZ()) < vertexZCut)) { + return; + } + registry.fill(HIST("mcm/hMCDMatchedEventCounter"), secCount++); - registry.fill(HIST("hDetectorJetPt"), mcdjet.pt()); - registry.fill(HIST("hDetectorJetEta"), mcdjet.eta()); - registry.fill(HIST("hDetectorJetPhi"), mcdjet.phi()); - for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) + return; + registry.fill(HIST("mcm/hMCDMatchedEventCounter"), secCount++); - registry.fill(HIST("hPartJetPtMatch"), mcpjet.pt()); - registry.fill(HIST("hPartJetEtaMatch"), mcpjet.eta()); - registry.fill(HIST("hPartJetPhiMatch"), mcpjet.phi()); + if (cfgEvSelOccupancy && !isOccupancyAccepted(collision)) + return; + registry.fill(HIST("mcm/hMCDMatchedEventCounter"), secCount++); - registry.fill(HIST("hMatchedJetsPtDelta"), mcpjet.pt(), mcdjet.pt() - mcpjet.pt()); - registry.fill(HIST("hMatchedJetsPhiDelta"), mcpjet.phi(), mcdjet.phi() - mcpjet.phi()); - registry.fill(HIST("hMatchedJetsEtaDelta"), mcpjet.eta(), mcdjet.eta() - mcpjet.eta()); + auto centrality = cfgisPbPb ? collision.centFT0M() : -1; + if (cfgisPbPb) + if (centrality < centRange->at(0) || centrality > centRange->at(1)) + registry.fill(HIST("mcm/hMCDMatchedEventCounter"), secCount++); - registry.fill(HIST("hResponseMatrixMatch"), mcdjet.pt(), mcpjet.pt()); - } - } - registry.fill(HIST("hMCEventCounter"), counter++); - } - PROCESS_SWITCH(JetSpectraEseTask, processMCChargedMatched, "jet matched mcp and mcd", false); + registry.fill(HIST("mcm/hCentralityAnalyzed"), centrality); + matchedJetLoop(mcdjets.sliceBy(mcdjetsPerJCollision, collision.globalIndex()), centrality, collision.rho(), mcCol.rho()); - template - bool isAcceptedLeadTrack(T const& tracks) - { - double leadingTrackpT{0.0}; - for (const auto& track : tracks) { - if (track.pt() > leadingJetPtCut) { - if (track.pt() > leadingTrackpT) { - leadingTrackpT = track.pt(); - } - } + registry.fill(HIST("mcm/hMCDMatchedEventCounter"), secCount++); } - if (leadingTrackpT == 0.0) - return false; - else - return true; + registry.fill(HIST("mcm/hMCEventCounter"), counter++); } - template - float procEP(EPCol const& vec) + PROCESS_SWITCH(JetSpectraEseTask, processMCChargedMatched, "jet MC process: geometrically matched MCP and MCD for response matrix and efficiency", false); + + // template + template + EventPlane procEP(EPCol const& vec) { constexpr std::array AmpCut{1e-8, 0.0}; - auto computeEP = [&AmpCut](std::vector vec, auto det) { return vec[2] > AmpCut[det] ? 0.5 * std::atan2(vec[1], vec[0]) : 999.; }; + auto computeEP = [&AmpCut](std::vector vec, auto det, float n) { return vec[2] > AmpCut[det] ? (1.0 / n) * std::atan2(vec[1], vec[0]) : 999.; }; std::map epMap; - epMap["FT0A"] = computeEP(qVecNoESE(vec), 0); - if constexpr (Fill) { - epMap["FT0C"] = computeEP(qVecNoESE(vec), 0); - epMap["FV0A"] = computeEP(qVecNoESE(vec), 0); - epMap["TPCpos"] = computeEP(qVecNoESE(vec), 1); - epMap["TPCneg"] = computeEP(qVecNoESE(vec), 1); - fillEP(/*std::make_index_sequence<5>{},*/ vec, epMap); + std::map ep3Map; + auto vec1{qVecNoESE(vec)}; + epMap["FT0A"] = computeEP(vec1, 0, 2.0); + ep3Map["FT0A"] = computeEP(vec1, 0, 3.0); + if constexpr (P.psi) { + auto vec2{qVecNoESE(vec)}; + epMap["FT0C"] = computeEP(vec2, 0, 2.0); + ep3Map["FT0C"] = computeEP(vec2, 0, 3.0); + epMap["FV0A"] = computeEP(qVecNoESE(vec), 0, 2.0); + epMap["TPCpos"] = computeEP(qVecNoESE(vec), 1, 2.0); + epMap["TPCneg"] = computeEP(qVecNoESE(vec), 1, 2.0); + if constexpr (P.hist) + fillEP(/*std::make_index_sequence<5>{},*/ vec, epMap); auto cosPsi = [](float psiX, float psiY) { return (static_cast(psiX) == 999. || static_cast(psiY) == 999.) ? 999. : std::cos(2.0 * (psiX - psiY)); }; std::array epCorrContainer{}; - epCorrContainer[0] = cosPsi(epMap[cfgEPRefA], epMap[cfgEPRefC]); - epCorrContainer[1] = cosPsi(epMap[cfgEPRefA], epMap[cfgEPRefB]); - epCorrContainer[2] = cosPsi(epMap[cfgEPRefB], epMap[cfgEPRefC]); - fillEPCos(/*std::make_index_sequence<3>{},*/ vec, epCorrContainer); + epCorrContainer[0] = cosPsi(epMap.at(cfgEPRefA), epMap.at(cfgEPRefC)); + epCorrContainer[1] = cosPsi(epMap.at(cfgEPRefA), epMap.at(cfgEPRefB)); + epCorrContainer[2] = cosPsi(epMap.at(cfgEPRefB), epMap.at(cfgEPRefC)); + if constexpr (P.hist) + fillEPCos(/*std::make_index_sequence<3>{},*/ vec, epCorrContainer); } - return epMap["FT0A"]; + EventPlane localPlane; + localPlane.psi2 = epMap.at(cfgEPRefA); + localPlane.psi3 = ep3Map.at(cfgEPRefA); + return localPlane; + // return epMap.at(cfgEPRefA); } template void fillEPCos(/*const std::index_sequence&,*/ const collision& col, const std::array& Corr) { // static constexpr std::string CosList[] = {"hCosPsi2AmC", "hCosPsi2AmB", "hCosPsi2BmC"}; // (registry.fill(HIST(CosList[Idx]), col.centrality(), Corr[Idx], col.qPERCFT0C()[0]), ...); - registry.fill(HIST("hCosPsi2AmC"), col.centrality(), Corr[0], col.qPERCFT0C()[0]); - registry.fill(HIST("hCosPsi2AmB"), col.centrality(), Corr[1], col.qPERCFT0C()[0]); - registry.fill(HIST("hCosPsi2BmC"), col.centrality(), Corr[2], col.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2AmC"), col.centFT0M(), Corr[0], col.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2AmB"), col.centFT0M(), Corr[1], col.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2BmC"), col.centFT0M(), Corr[2], col.qPERCFT0C()[0]); } template @@ -339,15 +582,15 @@ struct JetSpectraEseTask { { // static constexpr std::string_view EpList[] = {"hPsi2FT0A", "hPsi2FV0A", "hPsi2FT0C", "hPsi2TPCpos", "hPsi2TPCneg"}; // (registry.fill(HIST(EpList[Idx]), col.centrality(), epMap.at(std::string(RemovePrefix(EpList[Idx])))), ...); - registry.fill(HIST("hPsi2FT0A"), col.centrality(), epMap.at("FT0A")); - registry.fill(HIST("hPsi2FV0A"), col.centrality(), epMap.at("FV0A")); - registry.fill(HIST("hPsi2FT0C"), col.centrality(), epMap.at("FT0C")); - registry.fill(HIST("hPsi2TPCpos"), col.centrality(), epMap.at("TPCpos")); - registry.fill(HIST("hPsi2TPCneg"), col.centrality(), epMap.at("TPCneg")); + registry.fill(HIST("hPsi2FT0A"), col.centFT0M(), epMap.at("FT0A")); + registry.fill(HIST("hPsi2FV0A"), col.centFT0M(), epMap.at("FV0A")); + registry.fill(HIST("hPsi2FT0C"), col.centFT0M(), epMap.at("FT0C")); + registry.fill(HIST("hPsi2TPCpos"), col.centFT0M(), epMap.at("TPCpos")); + registry.fill(HIST("hPsi2TPCneg"), col.centFT0M(), epMap.at("TPCneg")); } constexpr std::string_view RemovePrefix(std::string_view str) { - constexpr std::string_view Prefix = "hPsi2"; + constexpr std::string_view Prefix{"hPsi2"}; return str.substr(Prefix.size()); } @@ -375,18 +618,18 @@ struct JetSpectraEseTask { template std::vector qVecNoESE(Col collision) { - const int nmode = 2; - int detId = detIDN(id); - int detInd = detId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + const int nmode{2}; + int detId{detIDN(id)}; + int detInd{detId * 4 + cfgnTotalSystem * 4 * (nmode - 2)}; if constexpr (fill) { if (collision.qvecAmp()[detInd] > 1e-8) { - registry.fill(HIST("hQvecUncorV2"), collision.centrality(), collision.qvecRe()[detInd], collision.qvecIm()[detInd]); - registry.fill(HIST("hQvecRectrV2"), collision.centrality(), collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1]); - registry.fill(HIST("hQvecTwistV2"), collision.centrality(), collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2]); - registry.fill(HIST("hQvecFinalV2"), collision.centrality(), collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3]); - registry.fill(HIST("hEPUncorV2"), collision.centrality(), 0.5 * std::atan2(collision.qvecIm()[detInd], collision.qvecRe()[detInd])); - registry.fill(HIST("hEPRectrV2"), collision.centrality(), 0.5 * std::atan2(collision.qvecIm()[detInd + 1], collision.qvecRe()[detInd + 1])); - registry.fill(HIST("hEPTwistV2"), collision.centrality(), 0.5 * std::atan2(collision.qvecIm()[detInd + 2], collision.qvecRe()[detInd + 2])); + registry.fill(HIST("hQvecUncorV2"), collision.centFT0M(), collision.qvecRe()[detInd], collision.qvecIm()[detInd]); + registry.fill(HIST("hQvecRectrV2"), collision.centFT0M(), collision.qvecRe()[detInd + 1], collision.qvecIm()[detInd + 1]); + registry.fill(HIST("hQvecTwistV2"), collision.centFT0M(), collision.qvecRe()[detInd + 2], collision.qvecIm()[detInd + 2]); + registry.fill(HIST("hQvecFinalV2"), collision.centFT0M(), collision.qvecRe()[detInd + 3], collision.qvecIm()[detInd + 3]); + registry.fill(HIST("hEPUncorV2"), collision.centFT0M(), 0.5 * std::atan2(collision.qvecIm()[detInd], collision.qvecRe()[detInd])); + registry.fill(HIST("hEPRectrV2"), collision.centFT0M(), 0.5 * std::atan2(collision.qvecIm()[detInd + 1], collision.qvecRe()[detInd + 1])); + registry.fill(HIST("hEPTwistV2"), collision.centFT0M(), 0.5 * std::atan2(collision.qvecIm()[detInd + 2], collision.qvecRe()[detInd + 2])); } } std::vector qVec{}; @@ -395,6 +638,355 @@ struct JetSpectraEseTask { qVec.push_back(collision.qvecAmp()[detId]); return qVec; } -}; + template + bool isOccupancyAccepted(const col& collision) + { + auto occupancy{collision.trackOccupancyInTimeRange()}; + if (occupancy < cfgCutOccupancy->at(0) || occupancy > cfgCutOccupancy->at(1)) + return false; + else + return true; + } + + template + bool isCentralitySelected(const Cent& centrality) + { + if (centrality < centRange->at(0) || centrality > centRange->at(1)) + return false; + else + return true; + } + + template + std::unique_ptr fitRho(const Col& col, const EventPlane& ep, TTracks const& tracks, Jets const& jets) + { + float leadingJetPt = 0.0; + float leadingJetEta = 0.0; + // float leadingJetPhi = 0.0; + for (const auto& jet : jets) { + if (jet.pt() > leadingJetPt) { + leadingJetPt = jet.pt(); + leadingJetEta = jet.eta(); + // leadingJetPhi = jet.phi(); + } + } + + int nTrk{0}; + if (jets.size() > 0) { + for (const auto& track : tracks) { + if constexpr (fillHist) + registry.fill(HIST("hTrackCounter"), 0.5); + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > jetR) && track.pt() >= 0.2 && track.pt() <= 5) { + nTrk++; + if constexpr (fillHist) + registry.fill(HIST("hTrackCounter"), 1.5); + } + } + } + if (nTrk < 1) + return nullptr; + + auto hPhiPt = std::unique_ptr(new TH1F("h_ptsum_sumpt_fit", "h_ptsum_sumpt fit use", TMath::CeilNint(std::sqrt(nTrk)), 0., o2::constants::math::TwoPI)); + for (const auto& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (std::fabs(track.eta() - leadingJetEta) > jetR) && track.pt() >= 0.2 && track.pt() <= 5) { + hPhiPt->Fill(track.phi(), track.pt()); + if constexpr (fillHist) { + registry.fill(HIST("hTrackCounter"), 2.5); + registry.fill(HIST("hPhiPtsum"), track.phi(), track.pt()); + } + } + } + auto modulationFit = std::unique_ptr(new TF1("fit_rholoc", "[0] * (1. + 2. * ([1] * std::cos(2. * (x - [2])) + [3] * std::cos(3. * (x - [4]))))", 0, o2::constants::math::TwoPI)); + + modulationFit->SetParameter(0, 1.0); + modulationFit->SetParameter(1, 0.01); + modulationFit->SetParameter(3, 0.01); + + modulationFit->FixParameter(2, (ep.psi2 < 0) ? RecoDecay::constrainAngle(ep.psi2) : ep.psi2); + modulationFit->FixParameter(4, (ep.psi3 < 0) ? RecoDecay::constrainAngle(ep.psi3) : ep.psi3); + + hPhiPt->Fit(modulationFit.get(), "Q", "", 0, o2::constants::math::TwoPI); + + if constexpr (fillHist) { + registry.fill(HIST("hfitPar0"), col.centFT0M(), modulationFit->GetParameter(0)); + registry.fill(HIST("hfitPar1"), col.centFT0M(), modulationFit->GetParameter(1)); + registry.fill(HIST("hfitPar2"), col.centFT0M(), modulationFit->GetParameter(2)); + registry.fill(HIST("hfitPar3"), col.centFT0M(), modulationFit->GetParameter(3)); + registry.fill(HIST("hfitPar4"), col.centFT0M(), modulationFit->GetParameter(4)); + } + + if (modulationFit->GetParameter(0) <= 0) + return nullptr; + + double chi2{0.}; + for (int i{0}; i < hPhiPt->GetXaxis()->GetNbins(); i++) { + if (hPhiPt->GetBinContent(i + 1) <= 0.) + continue; + chi2 += std::pow((hPhiPt->GetBinContent(i + 1) - modulationFit->Eval(hPhiPt->GetXaxis()->GetBinCenter(1 + i))), 2) / hPhiPt->GetBinContent(i + 1); + } + + int nDF{1}; + int numParams{2}; + nDF = static_cast(modulationFit->GetXaxis()->GetNbins()) - numParams; + if (nDF <= 0) + return nullptr; + + auto cDF = 1. - TMath::Gamma(nDF, chi2); + + if constexpr (fillHist) { + registry.fill(HIST("hPValueCentCDF"), col.centFT0M(), cDF); + registry.fill(HIST("hCentChi2Ndf"), col.centFT0M(), chi2 / (static_cast(nDF))); + } + + return modulationFit; + } + + template + double evalRho(TF1* fit, const float& radius, phiT const& jetPhi, rhoT const& colRho) + { + double integralValue{fit->Integral(jetPhi - radius, jetPhi + radius)}; + double rhoLocal{colRho / (2 * radius * fit->GetParameter(0)) * integralValue}; + return rhoLocal; + } + + template + void bkgFluctuationsRandomCone(TCollisions const& collision, TJets const& jets, TTracks const& tracks) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + if (cfgEvSelOccupancy && !isOccupancyAccepted(collision)) + return; + + const auto psi{procEP(collision)}; + auto qPerc{collision.qPERCFT0C()}; + if (qPerc[0] < 0) + return; + + TRandom3 randomNumber(0); + float randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); + float randomConePhi = randomNumber.Uniform(0.0, o2::constants::math::TwoPI); + float randomConePt = 0; + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection)) { + float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, -o2::constants::math::PI); + float dEta = track.eta() - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + randomConePt += track.pt(); + } + } + } + registry.fill(HIST("hCentRhoRandomCone"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * collision.rho()); + + randomConePt = 0; + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection)) { + float dPhi = RecoDecay::constrainAngle(randomNumber.Uniform(0.0, o2::constants::math::TwoPI) - randomConePhi, -o2::constants::math::PI); + float dEta = randomNumber.Uniform(trackEtaMin, trackEtaMax) - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + randomConePt += track.pt(); + } + } + } + registry.fill(HIST("hCentRhoRandomConeRandomTrackDir"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * collision.rho()); + + if (jets.size() > 0) { + float dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, -o2::constants::math::PI); + float dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + + bool jetWasInCone = false; + while ((randomConeLeadJetDeltaR <= 0 && (std::sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < jets.iteratorAt(0).r() / 100.0 + randomConeR)) || (randomConeLeadJetDeltaR > 0 && (std::sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < randomConeLeadJetDeltaR))) { + jetWasInCone = true; + randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); + randomConePhi = randomNumber.Uniform(0.0, o2::constants::math::TwoPI); + dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, -o2::constants::math::PI); + dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + } + if (jetWasInCone) { + randomConePt = 0.0; + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection)) { + float dPhi = RecoDecay::constrainAngle(track.phi() - randomConePhi, -o2::constants::math::PI); + float dEta = track.eta() - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + randomConePt += track.pt(); + } + } + } + } + } + auto rho = collision.rho(); + std::unique_ptr rhoFit{nullptr}; + if (cfgrhoPhi) { + rhoFit = fitRho(collision, psi, tracks, jets); + if (!rhoFit) + return; + rho = evalRho(rhoFit.get(), randomConeR, randomConePhi, rho); + } + float dPhi{RecoDecay::constrainAngle(randomConePhi - psi.psi2, -o2::constants::math::PI)}; + registry.fill(HIST("hCentRhoRandomConewoLeadingJet"), collision.centFT0M(), randomConePt - o2::constants::math::PI * randomConeR * randomConeR * rho, dPhi, qPerc[0]); + + double randomConePtWithoutOneLeadJet = 0; + double randomConePtWithoutTwoLeadJet = 0; + if (jets.size() > 1) { // if there are no jets, or just one, in the acceptance (from the jetfinder cuts) then one cannot find 2 leading jets + for (auto const& track : tracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection)) { + float dPhi = RecoDecay::constrainAngle(randomNumber.Uniform(0.0, o2::constants::math::TwoPI) - randomConePhi, -o2::constants::math::PI); + float dEta = randomNumber.Uniform(trackEtaMin, trackEtaMax) - randomConeEta; + if (std::sqrt(dEta * dEta + dPhi * dPhi) < randomConeR) { + if (!isTrackInJet(track, jets.iteratorAt(0))) { + randomConePtWithoutOneLeadJet += track.pt(); + if (!isTrackInJet(track, jets.iteratorAt(1))) { + randomConePtWithoutTwoLeadJet += track.pt(); + } + } + } + } + } + } + registry.fill(HIST("hCentRhoRandomConeRndTrackDirwoOneLeadingJet"), collision.centFT0M(), randomConePtWithoutOneLeadJet - o2::constants::math::PI * randomConeR * randomConeR * rho, dPhi, qPerc[0]); + registry.fill(HIST("hCentRhoRandomConeRndTrackDirwoTwoLeadingJet"), collision.centFT0M(), randomConePtWithoutTwoLeadJet - o2::constants::math::PI * randomConeR * randomConeR * rho, dPhi, qPerc[0]); + } + template + bool isTrackInJet(TTracks const& track, TJets const& jet) + { + for (auto const& constituentId : jet.tracksIds()) { + if (constituentId == track.globalIndex()) { + return true; + } + } + return false; + } + + // static constexpr std::string_view LevelJets[] = {"mcd/", "mcp/"}; + // enum JetType { MCP = 0, + // MCD = 1 + // }; + // template + template + void jetLoopMCD(const Jets& jets, const float& centrality, const float& rho) + { + float weight = 1.0; + for (const auto& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + auto pt = jet.pt(); + if (cfgbkgSubMC) { + pt = jet.pt() - (rho * jet.area()); + } + if (cfgUseMCEventWeights) { + weight = jet.eventWeight(); + } + registry.fill(/*HIST(LevelJets[jetLvl]) +*/ HIST("mcd/hJetSparse"), centrality, pt, jet.eta(), jet.phi(), weight); /* detector level mcm*/ + } + } + + template + void jetLoopMCP(const Jets& jets, const float& centrality, const float& rho) + { + bool mcLevelIsParticleLevel = true; + float weight = 1.0; + for (const auto& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet, mcLevelIsParticleLevel)) { + continue; + } + auto pt = jet.pt(); + if (cfgbkgSubMC) { + pt = jet.pt() - (rho * jet.area()); + } + if (cfgUseMCEventWeights) { + weight = jet.eventWeight(); + } + registry.fill(/*HIST(LevelJets[jetLvl]) +*/ HIST("mcp/hJetSparse"), centrality, pt, jet.eta(), jet.phi(), weight); /* detector level mcm*/ + } + } + + template + void matchedJetLoop(const Jets& jets, const float& centrality, const float& rho, const float& rho2) + { + float weight = 1.0; + for (const auto& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCD * pTHat) { + return; + } + + auto pt = jet.pt(); + if (cfgbkgSubMC) { + pt = jet.pt() - (rho * jet.area()); + } + if (cfgUseMCEventWeights) { + weight = jet.eventWeight(); + } + registry.fill(HIST("mcm/hJetSparse"), centrality, pt, jet.eta(), jet.phi(), weight); /* detector level mcm*/ + + if (jet.has_matchedJetGeo()) { + registry.fill(HIST("mcm/hDetSparseMatch"), centrality, pt, jet.eta(), jet.phi(), weight); + for (const auto& matchedJet : jet.template matchedJetGeo_as()) { + if (matchedJet.pt() > pTHatMaxMCD * pTHat) + continue; + auto matchedpt = matchedJet.pt(); + if (cfgbkgSubMC) { + matchedpt = matchedJet.pt() - (rho2 * matchedJet.area()); + } + registry.fill(HIST("mcm/hPartSparseMatch"), centrality, matchedpt, matchedJet.eta(), matchedJet.phi(), weight); + registry.fill(HIST("mcm/hMatchedJetsPtDelta"), matchedJet.pt(), jet.pt() - matchedJet.pt(), weight); + registry.fill(HIST("mcm/hMatchedJetsPhiDelta"), matchedJet.phi(), jet.phi() - matchedJet.phi(), weight); + registry.fill(HIST("mcm/hMatchedJetsEtaDelta"), matchedJet.eta(), jet.eta() - matchedJet.eta(), weight); + registry.fill(HIST("mcm/hGenMatchedJetsPtDeltadPt"), centrality, matchedpt, (pt - matchedpt) / matchedpt, weight); + registry.fill(HIST("mcm/hRecoMatchedJetsPtDeltadPt"), centrality, pt, (pt - matchedpt) / pt, weight); + registry.fill(HIST("mcm/hRespMcDMcPMatch"), centrality, pt, matchedpt, weight); + } + } + } + } + + template + bool isAcceptedJet(TJets const& jet, bool mcLevelIsParticleLevel = false) + { + if (jetAreaFractionMin > -98.0) { + if (jet.area() < jetAreaFractionMin * o2::constants::math::PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { + return false; + } + } + bool checkConstituentPt = true; + bool checkConstituentMinPt = (leadingConstituentPtMin > -98.0); + bool checkConstituentMaxPt = (leadingConstituentPtMax < 9998.0); + if (!checkConstituentMinPt && !checkConstituentMaxPt) { + checkConstituentPt = false; + } + + if (checkConstituentPt) { + bool isMinLeadingConstituent = !checkConstituentMinPt; + bool isMaxLeadingConstituent = true; + + for (const auto& constituent : jet.template tracks_as()) { + double pt = constituent.pt(); + + if ((!checkLeadConstituentMinPtForMcpJets && mcLevelIsParticleLevel) || (checkConstituentMinPt && pt >= leadingConstituentPtMin)) { // if the jet is mcp level and checkLeadConstituentMinPtForMcpJets is true, then the pt of the leading track of that jet does not need to be below the defined leadingConstituentPtMin cut + isMinLeadingConstituent = true; + } + if (checkConstituentMaxPt && pt > leadingConstituentPtMax) { + isMaxLeadingConstituent = false; + } + } + return isMinLeadingConstituent && isMaxLeadingConstituent; + } + return true; + } +}; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGJE/Tasks/jetSubstructure.cxx b/PWGJE/Tasks/jetSubstructure.cxx index b99d2b6ed33..9980893e4e5 100644 --- a/PWGJE/Tasks/jetSubstructure.cxx +++ b/PWGJE/Tasks/jetSubstructure.cxx @@ -14,43 +14,65 @@ /// \author Nima Zardoshti // -#include "fastjet/PseudoJet.hh" -#include "fastjet/ClusterSequenceArea.hh" +#include "PWGJE/DataModel/JetSubstructure.h" + +#include "RecoDecay.h" + +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/Core/JetSubstructureUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include +#include -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetSubstructure.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetSubstructureUtilities.h" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/PseudoJet.hh" +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" - struct JetSubstructureTask { Produces jetSubstructureDataTable; Produces jetSubstructureMCDTable; Produces jetSubstructureMCPTable; Produces jetSubstructureDataSubTable; + Produces jetSplittingsDataTable; + Produces jetSplittingsMCDTable; + Produces jetSplittingsMCPTable; + Produces jetSplittingsDataSubTable; + + Produces jetPairsDataTable; + Produces jetPairsMCDTable; + Produces jetPairsMCPTable; + Produces jetPairsDataSubTable; + Configurable zCut{"zCut", 0.1, "soft drop z cut"}; Configurable beta{"beta", 0.0, "soft drop beta"}; Configurable kappa{"kappa", 1.0, "angularity kappa"}; Configurable alpha{"alpha", 1.0, "angularity alpha"}; + Configurable doPairBkg{"doPairBkg", true, "save bkg pairs"}; Configurable pairConstituentPtMin{"pairConstituentPtMin", 1.0, "pt cut off for constituents going into pairs"}; Service pdg; @@ -63,10 +85,21 @@ struct JetSubstructureTask { std::vector ptSubLeadingVec; std::vector thetaVec; std::vector nSub; - std::vector pairPtVec; - std::vector pairEnergyVec; - std::vector pairThetaVec; + std::vector pairJetPtVec; + std::vector pairJetEnergyVec; + std::vector pairJetThetaVec; + std::vector pairJetPerpCone1PtVec; + std::vector pairJetPerpCone1EnergyVec; + std::vector pairJetPerpCone1ThetaVec; + std::vector pairPerpCone1PerpCone1PtVec; + std::vector pairPerpCone1PerpCone1EnergyVec; + std::vector pairPerpCone1PerpCone1ThetaVec; + std::vector pairPerpCone1PerpCone2PtVec; + std::vector pairPerpCone1PerpCone2EnergyVec; + std::vector pairPerpCone1PerpCone2ThetaVec; float angularity; + float leadingConstituentPt; + float perpConeRho; HistogramRegistry registry; @@ -88,8 +121,12 @@ struct JetSubstructureTask { jetReclusterer.algorithm = fastjet::JetAlgorithm::cambridge_algorithm; } - template - void jetReclustering(T const& jet) + Preslice TracksPerCollision = aod::jtrack::collisionId; + Preslice TracksPerCollisionDataSub = aod::bkgcharged::collisionId; + Preslice ParticlesPerMcCollision = aod::jmcparticle::mcCollisionId; + + template + void jetReclustering(T const& jet, U& splittingTable) { energyMotherVec.clear(); ptLeadingVec.clear(); @@ -110,6 +147,15 @@ struct JetSubstructureTask { if (parentSubJet1.perp() < parentSubJet2.perp()) { std::swap(parentSubJet1, parentSubJet2); } + std::vector tracks; + std::vector candidates; + std::vector clusters; + for (const auto& constituent : sorted_by_pt(parentSubJet2.constituents())) { + if (constituent.template user_info().getStatus() == static_cast(JetConstituentStatus::track)) { + tracks.push_back(constituent.template user_info().getIndex()); + } + } + splittingTable(jet.globalIndex(), tracks, clusters, candidates, parentSubJet2.perp(), parentSubJet2.eta(), parentSubJet2.phi(), 0); auto z = parentSubJet2.perp() / (parentSubJet1.perp() + parentSubJet2.perp()); auto theta = parentSubJet1.delta_R(parentSubJet2); energyMotherVec.push_back(daughterSubJet.e()); @@ -150,24 +196,108 @@ struct JetSubstructureTask { } } - template - void jetPairing(T const& jet, U const& /*tracks*/) + template + void jetPairing(T const& jet, U const& tracks, V const& slicer, M& pairTable) { - pairPtVec.clear(); - pairEnergyVec.clear(); - pairThetaVec.clear(); + pairJetPtVec.clear(); + pairJetEnergyVec.clear(); + pairJetThetaVec.clear(); std::vector tracksVec; + std::vector tracksVecIds; for (auto const& constituent : jet.template tracks_as()) { if (constituent.pt() >= pairConstituentPtMin) { tracksVec.push_back(constituent); + tracksVecIds.push_back(constituent.globalIndex()); } } if (tracksVec.size() >= 1) { for (typename std::vector::size_type track1Index = 0; track1Index < tracksVec.size(); track1Index++) { - for (typename std::vector::size_type track2Index = 0; track2Index < tracksVec.size(); track2Index++) { - pairPtVec.push_back(tracksVec.at(track1Index).pt() * tracksVec.at(track2Index).pt()); - pairEnergyVec.push_back(tracksVec.at(track1Index).energy() * tracksVec.at(track2Index).energy()); - pairThetaVec.push_back(jetutilities::deltaR(tracksVec.at(track1Index), tracksVec.at(track2Index))); + for (typename std::vector::size_type track2Index = track1Index + 1; track2Index < tracksVec.size(); track2Index++) { + pairJetPtVec.push_back(tracksVec.at(track1Index).pt() * tracksVec.at(track2Index).pt()); + pairJetEnergyVec.push_back(2.0 * tracksVec.at(track1Index).energy() * tracksVec.at(track2Index).energy()); + pairJetThetaVec.push_back(jetutilities::deltaR(tracksVec.at(track1Index), tracksVec.at(track2Index))); + pairTable(jet.globalIndex(), tracksVecIds.at(track1Index), tracksVecIds.at(track2Index), -1, -1); + } + } + } + + pairJetPerpCone1PtVec.clear(); + pairJetPerpCone1EnergyVec.clear(); + pairJetPerpCone1ThetaVec.clear(); + pairPerpCone1PerpCone1PtVec.clear(); + pairPerpCone1PerpCone1EnergyVec.clear(); + pairPerpCone1PerpCone1ThetaVec.clear(); + pairPerpCone1PerpCone2PtVec.clear(); + pairPerpCone1PerpCone2EnergyVec.clear(); + pairPerpCone1PerpCone2ThetaVec.clear(); + + int32_t collisionId = -1; + if constexpr (!isMC) { + collisionId = jet.collisionId(); + } else { + collisionId = jet.mcCollisionId(); + } + auto tracksPerCollision = tracks.sliceBy(slicer, collisionId); + + float perpCone1Phi = RecoDecay::constrainAngle(jet.phi() + (M_PI / 2.)); + float perpCone2Phi = RecoDecay::constrainAngle(jet.phi() - (M_PI / 2.)); + float perpCone1Pt = 0.0; + float perpCone2Pt = 0.0; + std::vector tracksPerpCone1Vec; + std::vector tracksPerpCone2Vec; + for (auto const& track : tracksPerCollision) { + float deltaPhi1 = track.phi() - perpCone1Phi; + deltaPhi1 = RecoDecay::constrainAngle(deltaPhi1, -M_PI); + float deltaPhi2 = track.phi() - perpCone2Phi; + deltaPhi2 = RecoDecay::constrainAngle(deltaPhi2, -M_PI); + float deltaEta = jet.eta() - track.eta(); + + if (TMath::Sqrt((deltaPhi1 * deltaPhi1) + (deltaEta * deltaEta)) <= jet.r() / 100.0) { + if (track.pt() >= pairConstituentPtMin) { + tracksPerpCone1Vec.push_back(track); + } + perpCone1Pt += track.pt(); + } + if (TMath::Sqrt((deltaPhi2 * deltaPhi2) + (deltaEta * deltaEta)) <= jet.r() / 100.0) { + if (track.pt() >= pairConstituentPtMin) { + tracksPerpCone2Vec.push_back(track); + } + perpCone2Pt += track.pt(); + } + } + perpConeRho = (perpCone1Pt + perpCone2Pt) / (2 * M_PI * (jet.r() / 100.0) * (jet.r() / 100.0)); // currently done per jet - could be better to do for leading jet if pushing to very low pT + if (doPairBkg) { + if (tracksVec.size() >= 1 && tracksPerpCone1Vec.size() >= 1) { + for (typename std::vector::size_type track1Index = 0; track1Index < tracksVec.size(); track1Index++) { + for (typename std::vector::size_type track2Index = 0; track2Index < tracksPerpCone1Vec.size(); track2Index++) { + pairJetPerpCone1PtVec.push_back(tracksVec.at(track1Index).pt() * tracksPerpCone1Vec.at(track2Index).pt()); + pairJetPerpCone1EnergyVec.push_back(2.0 * tracksVec.at(track1Index).energy() * tracksPerpCone1Vec.at(track2Index).energy()); + float dPhi = RecoDecay::constrainAngle(tracksVec.at(track1Index).phi() - (tracksPerpCone1Vec.at(track2Index).phi() - (M_PI / 2.)), -M_PI); + float dEta = tracksVec.at(track1Index).eta() - tracksPerpCone1Vec.at(track2Index).eta(); + pairJetPerpCone1ThetaVec.push_back(std::sqrt(dEta * dEta + dPhi * dPhi)); + } + } + } + + if (tracksPerpCone1Vec.size() >= 1) { + for (typename std::vector::size_type track1Index = 0; track1Index < tracksPerpCone1Vec.size(); track1Index++) { + for (typename std::vector::size_type track2Index = track1Index + 1; track2Index < tracksPerpCone1Vec.size(); track2Index++) { + pairPerpCone1PerpCone1PtVec.push_back(tracksPerpCone1Vec.at(track1Index).pt() * tracksPerpCone1Vec.at(track2Index).pt()); + pairPerpCone1PerpCone1EnergyVec.push_back(2.0 * tracksPerpCone1Vec.at(track1Index).energy() * tracksPerpCone1Vec.at(track2Index).energy()); + pairPerpCone1PerpCone1ThetaVec.push_back(jetutilities::deltaR(tracksPerpCone1Vec.at(track1Index), tracksPerpCone1Vec.at(track2Index))); + } + } + } + + if (tracksPerpCone1Vec.size() >= 1 && tracksPerpCone2Vec.size() >= 1) { + for (typename std::vector::size_type track1Index = 0; track1Index < tracksPerpCone1Vec.size(); track1Index++) { + for (typename std::vector::size_type track2Index = 0; track2Index < tracksPerpCone2Vec.size(); track2Index++) { + pairPerpCone1PerpCone2PtVec.push_back(tracksPerpCone1Vec.at(track1Index).pt() * tracksPerpCone2Vec.at(track2Index).pt()); + pairPerpCone1PerpCone2EnergyVec.push_back(2.0 * tracksPerpCone1Vec.at(track1Index).energy() * tracksPerpCone2Vec.at(track2Index).energy()); + float dPhi = RecoDecay::constrainAngle((tracksPerpCone1Vec.at(track1Index).phi() - (M_PI / 2.)) - (tracksPerpCone2Vec.at(track2Index).phi() + (M_PI / 2.)), -M_PI); + float dEta = tracksPerpCone1Vec.at(track1Index).eta() - tracksPerpCone2Vec.at(track2Index).eta(); + pairPerpCone1PerpCone2ThetaVec.push_back(std::sqrt(dEta * dEta + dPhi * dPhi)); + } } } } @@ -177,24 +307,28 @@ struct JetSubstructureTask { void jetSubstructureSimple(T const& jet, U const& /*tracks*/) { angularity = 0.0; + leadingConstituentPt = 0.0; for (auto& constituent : jet.template tracks_as()) { + if (constituent.pt() >= leadingConstituentPt) { + leadingConstituentPt = constituent.pt(); + } angularity += std::pow(constituent.pt(), kappa) * std::pow(jetutilities::deltaR(jet, constituent), alpha); } angularity /= (jet.pt() * (jet.r() / 100.f)); } - template - void analyseCharged(T const& jet, U const& tracks, V& outputTable) + template + void analyseCharged(T const& jet, U const& tracks, V const& trackSlicer, M& outputTable, N& splittingTable, O& pairTable) { jetConstituents.clear(); for (auto& jetConstituent : jet.template tracks_as()) { fastjetutilities::fillTracks(jetConstituent, jetConstituents, jetConstituent.globalIndex()); } nSub = jetsubstructureutilities::getNSubjettiness(jet, tracks, tracks, tracks, 2, fastjet::contrib::CA_Axes(), true, zCut, beta); - jetReclustering(jet); - jetPairing(jet, tracks); + jetReclustering(jet, splittingTable); + jetPairing(jet, tracks, trackSlicer, pairTable); jetSubstructureSimple(jet, tracks); - outputTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec, angularity); + outputTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairJetPtVec, pairJetEnergyVec, pairJetThetaVec, pairJetPerpCone1PtVec, pairJetPerpCone1EnergyVec, pairJetPerpCone1ThetaVec, pairPerpCone1PerpCone1PtVec, pairPerpCone1PerpCone1EnergyVec, pairPerpCone1PerpCone1ThetaVec, pairPerpCone1PerpCone2PtVec, pairPerpCone1PerpCone2EnergyVec, pairPerpCone1PerpCone2ThetaVec, angularity, leadingConstituentPt, perpConeRho); } void processDummy(aod::JetTracks const&) @@ -205,21 +339,21 @@ struct JetSubstructureTask { void processChargedJetsData(soa::Join::iterator const& jet, aod::JetTracks const& tracks) { - analyseCharged(jet, tracks, jetSubstructureDataTable); + analyseCharged(jet, tracks, TracksPerCollision, jetSubstructureDataTable, jetSplittingsDataTable, jetPairsDataTable); } PROCESS_SWITCH(JetSubstructureTask, processChargedJetsData, "charged jet substructure", false); void processChargedJetsEventWiseSubData(soa::Join::iterator const& jet, aod::JetTracksSub const& tracks) { - analyseCharged(jet, tracks, jetSubstructureDataSubTable); + analyseCharged(jet, tracks, TracksPerCollisionDataSub, jetSubstructureDataSubTable, jetSplittingsDataSubTable, jetPairsDataSubTable); } PROCESS_SWITCH(JetSubstructureTask, processChargedJetsEventWiseSubData, "eventwise-constituent subtracted charged jet substructure", false); void processChargedJetsMCD(typename soa::Join::iterator const& jet, aod::JetTracks const& tracks) { - analyseCharged(jet, tracks, jetSubstructureMCDTable); + analyseCharged(jet, tracks, TracksPerCollision, jetSubstructureMCDTable, jetSplittingsMCDTable, jetPairsMCDTable); } PROCESS_SWITCH(JetSubstructureTask, processChargedJetsMCD, "charged jet substructure", false); @@ -231,10 +365,10 @@ struct JetSubstructureTask { fastjetutilities::fillTracks(jetConstituent, jetConstituents, jetConstituent.globalIndex(), static_cast(JetConstituentStatus::track), pdg->Mass(jetConstituent.pdgCode())); } nSub = jetsubstructureutilities::getNSubjettiness(jet, particles, particles, particles, 2, fastjet::contrib::CA_Axes(), true, zCut, beta); - jetReclustering(jet); - jetPairing(jet, particles); + jetReclustering(jet, jetSplittingsMCPTable); + jetPairing(jet, particles, ParticlesPerMcCollision, jetPairsMCPTable); jetSubstructureSimple(jet, particles); - jetSubstructureMCPTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec, angularity); + jetSubstructureMCPTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairJetPtVec, pairJetEnergyVec, pairJetThetaVec, pairJetPerpCone1PtVec, pairJetPerpCone1EnergyVec, pairJetPerpCone1ThetaVec, pairPerpCone1PerpCone1PtVec, pairPerpCone1PerpCone1EnergyVec, pairPerpCone1PerpCone1ThetaVec, pairPerpCone1PerpCone2PtVec, pairPerpCone1PerpCone2EnergyVec, pairPerpCone1PerpCone2ThetaVec, angularity, leadingConstituentPt, perpConeRho); } PROCESS_SWITCH(JetSubstructureTask, processChargedJetsMCP, "charged jet substructure on MC particle level", false); }; diff --git a/PWGJE/Tasks/jetSubstructureB0.cxx b/PWGJE/Tasks/jetSubstructureB0.cxx new file mode 100644 index 00000000000..aedac757bf8 --- /dev/null +++ b/PWGJE/Tasks/jetSubstructureB0.cxx @@ -0,0 +1,39 @@ +// 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. + +// jet substructure B0 charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/Tasks/jetSubstructureHF.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureB0 = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesB0Data, aod::CandidatesB0MCP, aod::B0CJetSSs, aod::B0ChargedSPs, aod::B0ChargedPRs, aod::B0CMCDJetSSs, aod::B0ChargedMCDetectorLevelSPs, aod::B0ChargedMCDetectorLevelPRs, aod::B0CMCPJetSSs, aod::B0ChargedMCParticleLevelSPs, aod::B0ChargedMCParticleLevelPRs, aod::B0CEWSJetSSs, aod::B0ChargedEventWiseSubtractedSPs, aod::B0ChargedEventWiseSubtractedPRs, aod::JTrackB0Subs>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, + TaskName{"jet-substructure-b0"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/Tasks/jetSubstructureB0Output.cxx b/PWGJE/Tasks/jetSubstructureB0Output.cxx new file mode 100644 index 00000000000..4cac5ffcf2c --- /dev/null +++ b/PWGJE/Tasks/jetSubstructureB0Output.cxx @@ -0,0 +1,39 @@ +// 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. + +// jet substructure output B0 charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/Tasks/jetSubstructureHFOutput.cxx" + +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureOutputB0 = JetSubstructureHFOutputTask, aod::McCollisionsB0, aod::CandidatesB0Data, aod::CandidatesB0MCD, aod::CandidatesB0MCP, aod::BkgB0Rhos, aod::BkgB0McRhos, aod::JTrackB0Subs, soa::Join, soa::Join, soa::Join, soa::Join, aod::B0CJetCOs, aod::B0CJetOs, aod::B0CJetSSOs, aod::B0CJetMOs, soa::Join, soa::Join, soa::Join, aod::B0CMCDJetCOs, aod::B0CMCDJetOs, aod::B0CMCDJetSSOs, aod::B0CMCDJetMOs, soa::Join, soa::Join, soa::Join, soa::Join, aod::B0CMCPJetCOs, aod::B0CMCPJetMCCOs, aod::B0CMCPJetOs, aod::B0CMCPJetSSOs, aod::B0CMCPJetMOs, soa::Join, soa::Join, soa::Join, aod::B0CEWSJetCOs, aod::B0CEWSJetOs, aod::B0CEWSJetSSOs, aod::B0CEWSJetMOs, aod::StoredHfB0CollBase, aod::StoredHfB0Bases, aod::StoredHfB0Pars, aod::StoredHfB0ParEs, aod::StoredHfB0ParDpluss, aod::StoredHfB0Sels, aod::StoredHfB0Mls, aod::StoredHfB0MlDpluss, aod::StoredHfB0Mcs, aod::StoredHfB0McCollBases, aod::StoredHfB0McRCollIds, aod::StoredHfB0PBases>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-substructure-b0-output"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/Tasks/jetSubstructureBplus.cxx b/PWGJE/Tasks/jetSubstructureBplus.cxx index 61228fe5b19..527429af742 100644 --- a/PWGJE/Tasks/jetSubstructureBplus.cxx +++ b/PWGJE/Tasks/jetSubstructureBplus.cxx @@ -15,7 +15,19 @@ #include "PWGJE/Tasks/jetSubstructureHF.cxx" -using JetSubstructureBplus = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesBplusData, aod::CandidatesBplusMCP, aod::BplusCJetSSs, aod::BplusCMCDJetSSs, aod::BplusCMCPJetSSs, aod::BplusCEWSJetSSs, aod::JTrackBplusSubs>; +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureBplus = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesBplusData, aod::CandidatesBplusMCP, aod::BplusCJetSSs, aod::BplusChargedSPs, aod::BplusChargedPRs, aod::BplusCMCDJetSSs, aod::BplusChargedMCDetectorLevelSPs, aod::BplusChargedMCDetectorLevelPRs, aod::BplusCMCPJetSSs, aod::BplusChargedMCParticleLevelSPs, aod::BplusChargedMCParticleLevelPRs, aod::BplusCEWSJetSSs, aod::BplusChargedEventWiseSubtractedSPs, aod::BplusChargedEventWiseSubtractedPRs, aod::JTrackBplusSubs>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetSubstructureBplusOutput.cxx b/PWGJE/Tasks/jetSubstructureBplusOutput.cxx index e81e12566fa..04a2585d5bc 100644 --- a/PWGJE/Tasks/jetSubstructureBplusOutput.cxx +++ b/PWGJE/Tasks/jetSubstructureBplusOutput.cxx @@ -15,7 +15,20 @@ #include "PWGJE/Tasks/jetSubstructureHFOutput.cxx" -using JetSubstructureOutputBplus = JetSubstructureHFOutputTask, aod::CandidatesBplusData, aod::CandidatesBplusMCD, aod::CandidatesBplusMCP, aod::JTrackBplusSubs, soa::Join, soa::Join, aod::BplusCJetCOs, aod::BplusCJetOs, aod::BplusCJetSSOs, aod::BplusCJetMOs, soa::Join, aod::BplusCMCDJetCOs, aod::BplusCMCDJetOs, aod::BplusCMCDJetSSOs, aod::BplusCMCDJetMOs, soa::Join, aod::BplusCMCPJetCOs, aod::BplusCMCPJetOs, aod::BplusCMCPJetSSOs, aod::BplusCMCPJetMOs, soa::Join, aod::BplusCEWSJetCOs, aod::BplusCEWSJetOs, aod::BplusCEWSJetSSOs, aod::BplusCEWSJetMOs, aod::StoredHfBplusCollBase, aod::StoredHfBplusBases, aod::StoredHfBplusPars, aod::StoredHfBplusParEs, aod::StoredHfBplusParD0s, aod::StoredHfBplusSels, aod::StoredHfBplusMls, aod::StoredHfBplusMlD0s, aod::StoredHfBplusMcs, aod::StoredHfBplusMcCollBases, aod::StoredHfBplusMcRCollIds, aod::StoredHfBplusPBases>; // all the 3P tables have been made into Bplus but they might be made common +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureOutputBplus = JetSubstructureHFOutputTask, aod::McCollisionsBplus, aod::CandidatesBplusData, aod::CandidatesBplusMCD, aod::CandidatesBplusMCP, aod::BkgBplusRhos, aod::BkgBplusMcRhos, aod::JTrackBplusSubs, soa::Join, soa::Join, soa::Join, soa::Join, aod::BplusCJetCOs, aod::BplusCJetOs, aod::BplusCJetSSOs, aod::BplusCJetMOs, soa::Join, soa::Join, soa::Join, aod::BplusCMCDJetCOs, aod::BplusCMCDJetOs, aod::BplusCMCDJetSSOs, aod::BplusCMCDJetMOs, soa::Join, soa::Join, soa::Join, soa::Join, aod::BplusCMCPJetCOs, aod::BplusCMCPJetMCCOs, aod::BplusCMCPJetOs, aod::BplusCMCPJetSSOs, aod::BplusCMCPJetMOs, soa::Join, soa::Join, soa::Join, aod::BplusCEWSJetCOs, aod::BplusCEWSJetOs, aod::BplusCEWSJetSSOs, aod::BplusCEWSJetMOs, aod::StoredHfBplusCollBase, aod::StoredHfBplusBases, aod::StoredHfBplusPars, aod::StoredHfBplusParEs, aod::StoredHfBplusParD0s, aod::StoredHfBplusSels, aod::StoredHfBplusMls, aod::StoredHfBplusMlD0s, aod::StoredHfBplusMcs, aod::StoredHfBplusMcCollBases, aod::StoredHfBplusMcRCollIds, aod::StoredHfBplusPBases>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetSubstructureD0.cxx b/PWGJE/Tasks/jetSubstructureD0.cxx index 96760654a3a..cf77baa7ffd 100644 --- a/PWGJE/Tasks/jetSubstructureD0.cxx +++ b/PWGJE/Tasks/jetSubstructureD0.cxx @@ -15,7 +15,19 @@ #include "PWGJE/Tasks/jetSubstructureHF.cxx" -using JetSubstructureD0 = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesD0Data, aod::CandidatesD0MCP, aod::D0CJetSSs, aod::D0CMCDJetSSs, aod::D0CMCPJetSSs, aod::D0CEWSJetSSs, aod::JTrackD0Subs>; +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureD0 = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesD0Data, aod::CandidatesD0MCP, aod::D0CJetSSs, aod::D0ChargedSPs, aod::D0ChargedPRs, aod::D0CMCDJetSSs, aod::D0ChargedMCDetectorLevelSPs, aod::D0ChargedMCDetectorLevelPRs, aod::D0CMCPJetSSs, aod::D0ChargedMCParticleLevelSPs, aod::D0ChargedMCParticleLevelPRs, aod::D0CEWSJetSSs, aod::D0ChargedEventWiseSubtractedSPs, aod::D0ChargedEventWiseSubtractedPRs, aod::JTrackD0Subs>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetSubstructureD0Output.cxx b/PWGJE/Tasks/jetSubstructureD0Output.cxx index 7eb6b474eaf..d8bdaaf06d1 100644 --- a/PWGJE/Tasks/jetSubstructureD0Output.cxx +++ b/PWGJE/Tasks/jetSubstructureD0Output.cxx @@ -15,7 +15,21 @@ #include "PWGJE/Tasks/jetSubstructureHFOutput.cxx" -using JetSubstructureOutputD0 = JetSubstructureHFOutputTask, aod::CandidatesD0Data, aod::CandidatesD0MCD, aod::CandidatesD0MCP, aod::JTrackD0Subs, soa::Join, soa::Join, aod::D0CJetCOs, aod::D0CJetOs, aod::D0CJetSSOs, aod::D0CJetMOs, soa::Join, aod::D0CMCDJetCOs, aod::D0CMCDJetOs, aod::D0CMCDJetSSOs, aod::D0CMCDJetMOs, soa::Join, aod::D0CMCPJetCOs, aod::D0CMCPJetOs, aod::D0CMCPJetSSOs, aod::D0CMCPJetMOs, soa::Join, aod::D0CEWSJetCOs, aod::D0CEWSJetOs, aod::D0CEWSJetSSOs, aod::D0CEWSJetMOs, aod::StoredHfD0CollBase, aod::StoredHfD0Bases, aod::StoredHfD0Pars, aod::StoredHfD0ParEs, aod::JDumD0ParDaus, aod::StoredHfD0Sels, aod::StoredHfD0Mls, aod::JDumD0MlDaus, aod::StoredHfD0Mcs, aod::StoredHfD0McCollBases, aod::StoredHfD0McRCollIds, aod::StoredHfD0PBases>; +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedDataHF.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureOutputD0 = JetSubstructureHFOutputTask, aod::McCollisionsD0, aod::CandidatesD0Data, aod::CandidatesD0MCD, aod::CandidatesD0MCP, aod::BkgD0Rhos, aod::BkgD0McRhos, aod::JTrackD0Subs, soa::Join, soa::Join, soa::Join, soa::Join, aod::D0CJetCOs, aod::D0CJetOs, aod::D0CJetSSOs, aod::D0CJetMOs, soa::Join, soa::Join, soa::Join, aod::D0CMCDJetCOs, aod::D0CMCDJetOs, aod::D0CMCDJetSSOs, aod::D0CMCDJetMOs, soa::Join, soa::Join, soa::Join, soa::Join, aod::D0CMCPJetCOs, aod::D0CMCPJetMCCOs, aod::D0CMCPJetOs, aod::D0CMCPJetSSOs, aod::D0CMCPJetMOs, soa::Join, soa::Join, soa::Join, aod::D0CEWSJetCOs, aod::D0CEWSJetOs, aod::D0CEWSJetSSOs, aod::D0CEWSJetMOs, aod::StoredHfD0CollBase, aod::StoredHfD0Bases, aod::StoredHfD0Pars, aod::StoredHfD0ParEs, aod::JDumD0ParDaus, aod::StoredHfD0Sels, aod::StoredHfD0Mls, aod::JDumD0MlDaus, aod::StoredHfD0Mcs, aod::StoredHfD0McCollBases, aod::StoredHfD0McRCollIds, aod::StoredHfD0PBases>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetSubstructureDielectron.cxx b/PWGJE/Tasks/jetSubstructureDielectron.cxx index e5532cce52e..5ba3468727c 100644 --- a/PWGJE/Tasks/jetSubstructureDielectron.cxx +++ b/PWGJE/Tasks/jetSubstructureDielectron.cxx @@ -15,7 +15,19 @@ #include "PWGJE/Tasks/jetSubstructureHF.cxx" -using JetSubstructureDielectron = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesDielectronData, aod::CandidatesDielectronMCP, aod::DielectronCJetSSs, aod::DielectronCMCDJetSSs, aod::DielectronCMCPJetSSs, aod::DielectronCEWSJetSSs, aod::JTrackDielectronSubs>; +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureDielectron = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesDielectronData, aod::CandidatesDielectronMCP, aod::DielectronCJetSSs, aod::DielectronChargedSPs, aod::DielectronChargedPRs, aod::DielectronCMCDJetSSs, aod::DielectronChargedMCDetectorLevelSPs, aod::DielectronChargedMCDetectorLevelPRs, aod::DielectronCMCPJetSSs, aod::DielectronChargedMCParticleLevelSPs, aod::DielectronChargedMCParticleLevelPRs, aod::DielectronCEWSJetSSs, aod::DielectronChargedEventWiseSubtractedSPs, aod::DielectronChargedEventWiseSubtractedPRs, aod::JTrackDielectronSubs>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetSubstructureDielectronOutput.cxx b/PWGJE/Tasks/jetSubstructureDielectronOutput.cxx index 76cdd6e7643..84ef77afc4e 100644 --- a/PWGJE/Tasks/jetSubstructureDielectronOutput.cxx +++ b/PWGJE/Tasks/jetSubstructureDielectronOutput.cxx @@ -15,7 +15,21 @@ #include "PWGJE/Tasks/jetSubstructureHFOutput.cxx" -using JetSubstructureOutputDielectron = JetSubstructureHFOutputTask, soa::Join, aod::DielectronCJetCOs, aod::DielectronCJetOs, aod::DielectronCJetSSOs, aod::DielectronCJetMOs, soa::Join, aod::DielectronCMCDJetCOs, aod::DielectronCMCDJetOs, aod::DielectronCMCDJetSSOs, aod::DielectronCMCDJetMOs, soa::Join, aod::DielectronCMCPJetCOs, aod::DielectronCMCPJetOs, aod::DielectronCMCPJetSSOs, aod::DielectronCMCPJetMOs, soa::Join, aod::DielectronCEWSJetCOs, aod::DielectronCEWSJetOs, aod::DielectronCEWSJetSSOs, aod::DielectronCEWSJetMOs, aod::StoredReducedEvents, aod::StoredDielectrons, aod::JDielectron1Dummys, aod::JDielectron2Dummys, aod::JDielectron3Dummys, aod::JDielectron4Dummys, aod::JDielectron5Dummys, aod::JDielectron6Dummys, aod::JDielectron7Dummys, aod::StoredJDielectronMcCollisions, aod::JDielectron8Dummys, aod::StoredJDielectronMcs>; +#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedDataDQ.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureOutputDielectron = JetSubstructureHFOutputTask, aod::McCollisionsDielectron, aod::CandidatesDielectronData, aod::CandidatesDielectronMCD, aod::CandidatesDielectronMCP, aod::BkgDielectronRhos, aod::BkgDielectronMcRhos, aod::JTrackDielectronSubs, soa::Join, soa::Join, soa::Join, soa::Join, aod::DielectronCJetCOs, aod::DielectronCJetOs, aod::DielectronCJetSSOs, aod::DielectronCJetMOs, soa::Join, soa::Join, soa::Join, aod::DielectronCMCDJetCOs, aod::DielectronCMCDJetOs, aod::DielectronCMCDJetSSOs, aod::DielectronCMCDJetMOs, soa::Join, soa::Join, soa::Join, soa::Join, aod::DielectronCMCPJetCOs, aod::DielectronCMCPJetMCCOs, aod::DielectronCMCPJetOs, aod::DielectronCMCPJetSSOs, aod::DielectronCMCPJetMOs, soa::Join, soa::Join, soa::Join, aod::DielectronCEWSJetCOs, aod::DielectronCEWSJetOs, aod::DielectronCEWSJetSSOs, aod::DielectronCEWSJetMOs, aod::StoredReducedEvents, aod::StoredDielectrons, aod::JDielectron1Dummys, aod::JDielectron2Dummys, aod::JDielectron3Dummys, aod::JDielectron4Dummys, aod::JDielectron5Dummys, aod::JDielectron6Dummys, aod::JDielectron7Dummys, aod::StoredJDielectronMcCollisions, aod::JDielectronMcRCollDummys, aod::StoredJDielectronMcs>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetSubstructureDplus.cxx b/PWGJE/Tasks/jetSubstructureDplus.cxx new file mode 100644 index 00000000000..e1550673039 --- /dev/null +++ b/PWGJE/Tasks/jetSubstructureDplus.cxx @@ -0,0 +1,39 @@ +// 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. + +// jet substructure D+ charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/Tasks/jetSubstructureHF.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureDplus = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesDplusData, aod::CandidatesDplusMCP, aod::DplusCJetSSs, aod::DplusChargedSPs, aod::DplusChargedPRs, aod::DplusCMCDJetSSs, aod::DplusChargedMCDetectorLevelSPs, aod::DplusChargedMCDetectorLevelPRs, aod::DplusCMCPJetSSs, aod::DplusChargedMCParticleLevelSPs, aod::DplusChargedMCParticleLevelPRs, aod::DplusCEWSJetSSs, aod::DplusChargedEventWiseSubtractedSPs, aod::DplusChargedEventWiseSubtractedPRs, aod::JTrackDplusSubs>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, + TaskName{"jet-substructure-dplus"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/Tasks/jetSubstructureDplusOutput.cxx b/PWGJE/Tasks/jetSubstructureDplusOutput.cxx new file mode 100644 index 00000000000..22a869bfcfa --- /dev/null +++ b/PWGJE/Tasks/jetSubstructureDplusOutput.cxx @@ -0,0 +1,40 @@ +// 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. + +// jet substructure output D+ charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/Tasks/jetSubstructureHFOutput.cxx" + +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedDataHF.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureOutputDplus = JetSubstructureHFOutputTask, aod::McCollisionsDplus, aod::CandidatesDplusData, aod::CandidatesDplusMCD, aod::CandidatesDplusMCP, aod::BkgDplusRhos, aod::BkgDplusMcRhos, aod::JTrackDplusSubs, soa::Join, soa::Join, soa::Join, soa::Join, aod::DplusCJetCOs, aod::DplusCJetOs, aod::DplusCJetSSOs, aod::DplusCJetMOs, soa::Join, soa::Join, soa::Join, aod::DplusCMCDJetCOs, aod::DplusCMCDJetOs, aod::DplusCMCDJetSSOs, aod::DplusCMCDJetMOs, soa::Join, soa::Join, soa::Join, soa::Join, aod::DplusCMCPJetCOs, aod::DplusCMCPJetMCCOs, aod::DplusCMCPJetOs, aod::DplusCMCPJetSSOs, aod::DplusCMCPJetMOs, soa::Join, soa::Join, soa::Join, aod::DplusCEWSJetCOs, aod::DplusCEWSJetOs, aod::DplusCEWSJetSSOs, aod::DplusCEWSJetMOs, aod::StoredHfDplusCollBase, aod::StoredHfDplusBases, aod::StoredHfDplusPars, aod::StoredHfDplusParEs, aod::JDumDplusParDaus, aod::StoredHfDplusSels, aod::StoredHfDplusMls, aod::JDumDplusMlDaus, aod::StoredHfDplusMcs, aod::StoredHfDplusMcCollBases, aod::StoredHfDplusMcRCollIds, aod::StoredHfDplusPBases>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-substructure-dplus-output"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/Tasks/jetSubstructureDstar.cxx b/PWGJE/Tasks/jetSubstructureDstar.cxx new file mode 100644 index 00000000000..02c95adbbda --- /dev/null +++ b/PWGJE/Tasks/jetSubstructureDstar.cxx @@ -0,0 +1,39 @@ +// 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. + +// jet substructure D* charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/Tasks/jetSubstructureHF.cxx" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureDstar = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesDstarData, aod::CandidatesDstarMCP, aod::DstarCJetSSs, aod::DstarChargedSPs, aod::DstarChargedPRs, aod::DstarCMCDJetSSs, aod::DstarChargedMCDetectorLevelSPs, aod::DstarChargedMCDetectorLevelPRs, aod::DstarCMCPJetSSs, aod::DstarChargedMCParticleLevelSPs, aod::DstarChargedMCParticleLevelPRs, aod::DstarCEWSJetSSs, aod::DstarChargedEventWiseSubtractedSPs, aod::DstarChargedEventWiseSubtractedPRs, aod::JTrackDstarSubs>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, + SetDefaultProcesses{}, + TaskName{"jet-substructure-dstar"})); + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/Tasks/jetSubstructureDstarOutput.cxx b/PWGJE/Tasks/jetSubstructureDstarOutput.cxx new file mode 100644 index 00000000000..d7ced94f0ad --- /dev/null +++ b/PWGJE/Tasks/jetSubstructureDstarOutput.cxx @@ -0,0 +1,40 @@ +// 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. + +// jet substructure output D* charged task +// +/// \author Nima Zardoshti + +#include "PWGJE/Tasks/jetSubstructureHFOutput.cxx" + +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedDataHF.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureOutputDstar = JetSubstructureHFOutputTask, aod::McCollisionsDstar, aod::CandidatesDstarData, aod::CandidatesDstarMCD, aod::CandidatesDstarMCP, aod::BkgDstarRhos, aod::BkgDstarMcRhos, aod::JTrackDstarSubs, soa::Join, soa::Join, soa::Join, soa::Join, aod::DstarCJetCOs, aod::DstarCJetOs, aod::DstarCJetSSOs, aod::DstarCJetMOs, soa::Join, soa::Join, soa::Join, aod::DstarCMCDJetCOs, aod::DstarCMCDJetOs, aod::DstarCMCDJetSSOs, aod::DstarCMCDJetMOs, soa::Join, soa::Join, soa::Join, soa::Join, aod::DstarCMCPJetCOs, aod::DstarCMCPJetMCCOs, aod::DstarCMCPJetOs, aod::DstarCMCPJetSSOs, aod::DstarCMCPJetMOs, soa::Join, soa::Join, soa::Join, aod::DstarCEWSJetCOs, aod::DstarCEWSJetOs, aod::DstarCEWSJetSSOs, aod::DstarCEWSJetMOs, aod::StoredHfDstarCollBase, aod::StoredHfDstarBases, aod::StoredHfDstarPars, aod::JDumDstarParEs, aod::HfDstarParD0s, aod::StoredHfDstarSels, aod::StoredHfDstarMls, aod::JDumDstarMlDaus, aod::StoredHfDstarMcs, aod::StoredHfDstarMcCollBases, aod::StoredHfDstarMcRCollIds, aod::StoredHfDstarPBases>; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + tasks.emplace_back(adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-substructure-dstar-output"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/Tasks/jetSubstructureHF.cxx b/PWGJE/Tasks/jetSubstructureHF.cxx index 46572c17f07..c098236dae7 100644 --- a/PWGJE/Tasks/jetSubstructureHF.cxx +++ b/PWGJE/Tasks/jetSubstructureHF.cxx @@ -14,49 +14,68 @@ /// \author Nima Zardoshti // -#include +#include "RecoDecay.h" -#include "fastjet/PseudoJet.hh" -#include "fastjet/ClusterSequenceArea.hh" +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDQUtilities.h" +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/Core/JetHFUtilities.h" +#include "PWGJE/Core/JetSubstructureUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetSubstructure.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetSubstructureUtilities.h" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/PseudoJet.hh" +#include + +#include +#include +#include +#include + +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; // NB: runDataProcessing.h must be included after customize! -#include "Framework/runDataProcessing.h" -template +template struct JetSubstructureHFTask { Produces jetSubstructureDataTable; Produces jetSubstructureMCDTable; Produces jetSubstructureMCPTable; Produces jetSubstructureDataSubTable; + Produces jetSplittingsDataTable; + Produces jetSplittingsMCDTable; + Produces jetSplittingsMCPTable; + Produces jetSplittingsDataSubTable; + + Produces jetPairsDataTable; + Produces jetPairsMCDTable; + Produces jetPairsMCPTable; + Produces jetPairsDataSubTable; + // Jet level configurables Configurable zCut{"zCut", 0.1, "soft drop z cut"}; Configurable beta{"beta", 0.0, "soft drop beta"}; Configurable kappa{"kappa", 1.0, "angularity kappa"}; Configurable alpha{"alpha", 1.0, "angularity alpha"}; + Configurable doPairBkg{"doPairBkg", true, "save bkg pairs"}; Configurable pairConstituentPtMin{"pairConstituentPtMin", 1.0, "pt cut off for constituents going into pairs"}; Service pdg; @@ -71,10 +90,21 @@ struct JetSubstructureHFTask { std::vector ptSubLeadingVec; std::vector thetaVec; std::vector nSub; - std::vector pairPtVec; - std::vector pairEnergyVec; - std::vector pairThetaVec; + std::vector pairJetPtVec; + std::vector pairJetEnergyVec; + std::vector pairJetThetaVec; + std::vector pairJetPerpCone1PtVec; + std::vector pairJetPerpCone1EnergyVec; + std::vector pairJetPerpCone1ThetaVec; + std::vector pairPerpCone1PerpCone1PtVec; + std::vector pairPerpCone1PerpCone1EnergyVec; + std::vector pairPerpCone1PerpCone1ThetaVec; + std::vector pairPerpCone1PerpCone2PtVec; + std::vector pairPerpCone1PerpCone2EnergyVec; + std::vector pairPerpCone1PerpCone2ThetaVec; float angularity; + float leadingConstituentPt; + float perpConeRho; HistogramRegistry registry; void init(InitContext const&) @@ -97,8 +127,40 @@ struct JetSubstructureHFTask { candMass = jetcandidateutilities::getTablePDGMass(); } - template - void jetReclustering(T const& jet) + Preslice TracksPerCollision = aod::jtrack::collisionId; + PresliceOptional TracksPerD0DataSub = aod::bkgd0::candidateId; + PresliceOptional TracksPerDplusDataSub = aod::bkgdplus::candidateId; + PresliceOptional TracksPerDstarDataSub = aod::bkgdstar::candidateId; + PresliceOptional TracksPerLcDataSub = aod::bkglc::candidateId; + PresliceOptional TracksPerB0DataSub = aod::bkgb0::candidateId; + PresliceOptional TracksPerBplusDataSub = aod::bkgbplus::candidateId; + PresliceOptional TracksPerDielectronDataSub = aod::bkgdielectron::candidateId; + Preslice ParticlesPerMcCollision = aod::jmcparticle::mcCollisionId; + + template + auto selectSlicer(T const& D0Slicer, U const& DplusSlicer, V const& DstarSlicer, M const& LcSlicer, N const& B0Slicer, O const& BplusSlicer, P const& DielectronSlicer) + { + if constexpr (jethfutilities::isD0Table()) { + return D0Slicer; + } else if constexpr (jethfutilities::isDplusTable()) { + return DplusSlicer; + } else if constexpr (jethfutilities::isDstarTable()) { + return DstarSlicer; + } else if constexpr (jethfutilities::isLcTable()) { + return LcSlicer; + } else if constexpr (jethfutilities::isB0Table()) { + return B0Slicer; + } else if constexpr (jethfutilities::isBplusTable()) { + return BplusSlicer; + } else if constexpr (jetdqutilities::isDielectronTable()) { + return DielectronSlicer; + } else { + return D0Slicer; + } + } + + template + void jetReclustering(T const& jet, U& splittingTable) { energyMotherVec.clear(); ptLeadingVec.clear(); @@ -126,6 +188,18 @@ struct JetSubstructureHFTask { if (!isHFInSubjet1) { std::swap(parentSubJet1, parentSubJet2); } + std::vector tracks; + std::vector candidates; + std::vector clusters; + for (const auto& constituent : sorted_by_pt(parentSubJet2.constituents())) { + if (constituent.template user_info().getStatus() == static_cast(JetConstituentStatus::track)) { + tracks.push_back(constituent.template user_info().getIndex()); + } + if (constituent.template user_info().getStatus() == static_cast(JetConstituentStatus::candidate)) { + candidates.push_back(constituent.template user_info().getIndex()); + } + } + splittingTable(jet.globalIndex(), tracks, clusters, candidates, parentSubJet2.perp(), parentSubJet2.eta(), parentSubJet2.phi(), 0); auto z = parentSubJet2.perp() / (parentSubJet1.perp() + parentSubJet2.perp()); auto theta = parentSubJet1.delta_R(parentSubJet2); energyMotherVec.push_back(daughterSubJet.e()); @@ -165,49 +239,154 @@ struct JetSubstructureHFTask { } } - template - void jetPairing(T const& jet, U const& /*tracks*/, V const& /*candidates*/) + template + void jetPairing(T const& jet, U const& tracks, V const& /*candidates*/, M const& slicer, N& pairTable) { - pairPtVec.clear(); - pairEnergyVec.clear(); - pairThetaVec.clear(); + pairJetPtVec.clear(); + pairJetEnergyVec.clear(); + pairJetThetaVec.clear(); std::vector> tracksVec; std::vector> candidatesVec; + std::vector tracksVecIds; + std::vector candidatesVecIds; for (auto& constituent : jet.template tracks_as()) { if (constituent.pt() >= pairConstituentPtMin) { tracksVec.push_back(constituent); + tracksVecIds.push_back(constituent.globalIndex()); } } for (auto& candidate : jet.template candidates_as()) { candidatesVec.push_back(candidate); + candidatesVecIds.push_back(candidate.globalIndex()); } if (tracksVec.size() >= 1) { for (typename std::vector>::size_type track1Index = 0; track1Index < tracksVec.size(); track1Index++) { - for (typename std::vector>::size_type track2Index = 0; track2Index < tracksVec.size(); track2Index++) { - pairPtVec.push_back(tracksVec.at(track1Index).pt() * tracksVec.at(track2Index).pt()); - pairEnergyVec.push_back(tracksVec.at(track1Index).energy() * tracksVec.at(track2Index).energy()); - pairThetaVec.push_back(jetutilities::deltaR(tracksVec.at(track1Index), tracksVec.at(track2Index))); + for (typename std::vector>::size_type track2Index = track1Index + 1; track2Index < tracksVec.size(); track2Index++) { + pairJetPtVec.push_back(tracksVec.at(track1Index).pt() * tracksVec.at(track2Index).pt()); + pairJetEnergyVec.push_back(2.0 * tracksVec.at(track1Index).energy() * tracksVec.at(track2Index).energy()); + pairJetThetaVec.push_back(jetutilities::deltaR(tracksVec.at(track1Index), tracksVec.at(track2Index))); + pairTable(jet.globalIndex(), tracksVecIds.at(track1Index), tracksVecIds.at(track2Index), -1, -1); } } } if (candidatesVec.size() >= 1) { for (typename std::vector>::size_type candidate1Index = 0; candidate1Index < candidatesVec.size(); candidate1Index++) { - for (typename std::vector>::size_type candidate2Index = 0; candidate2Index < candidatesVec.size(); candidate2Index++) { - pairPtVec.push_back(candidatesVec.at(candidate1Index).pt() * candidatesVec.at(candidate2Index).pt()); + for (typename std::vector>::size_type candidate2Index = candidate1Index + 1; candidate2Index < candidatesVec.size(); candidate2Index++) { + pairJetPtVec.push_back(candidatesVec.at(candidate1Index).pt() * candidatesVec.at(candidate2Index).pt()); auto candidate1Energy = std::sqrt((candidatesVec.at(candidate1Index).p() * candidatesVec.at(candidate1Index).p()) + (candMass * candMass)); auto candidate2Energy = std::sqrt((candidatesVec.at(candidate2Index).p() * candidatesVec.at(candidate2Index).p()) + (candMass * candMass)); - pairEnergyVec.push_back(candidate1Energy * candidate2Energy); - pairThetaVec.push_back(jetutilities::deltaR(candidatesVec.at(candidate1Index), candidatesVec.at(candidate2Index))); + pairJetEnergyVec.push_back(2.0 * candidate1Energy * candidate2Energy); + pairJetThetaVec.push_back(jetutilities::deltaR(candidatesVec.at(candidate1Index), candidatesVec.at(candidate2Index))); + pairTable(jet.globalIndex(), -1, -1, candidatesVecIds.at(candidate1Index), candidatesVecIds.at(candidate2Index)); } } } if (candidatesVec.size() >= 1 && tracksVec.size() >= 1) { for (typename std::vector>::size_type candidateIndex = 0; candidateIndex < candidatesVec.size(); candidateIndex++) { // could just directly get the candidate and tracks here but keeping it consistent with above for (typename std::vector>::size_type trackIndex = 0; trackIndex < tracksVec.size(); trackIndex++) { - pairPtVec.push_back(candidatesVec.at(candidateIndex).pt() * tracksVec.at(trackIndex).pt()); + pairJetPtVec.push_back(candidatesVec.at(candidateIndex).pt() * tracksVec.at(trackIndex).pt()); auto candidateEnergy = std::sqrt((candidatesVec.at(candidateIndex).p() * candidatesVec.at(candidateIndex).p()) + (candMass * candMass)); - pairEnergyVec.push_back(candidateEnergy * tracksVec.at(trackIndex).energy()); - pairThetaVec.push_back(jetutilities::deltaR(candidatesVec.at(candidateIndex), tracksVec.at(trackIndex))); + pairJetEnergyVec.push_back(2.0 * candidateEnergy * tracksVec.at(trackIndex).energy()); + pairJetThetaVec.push_back(jetutilities::deltaR(candidatesVec.at(candidateIndex), tracksVec.at(trackIndex))); + pairTable(jet.globalIndex(), tracksVecIds.at(trackIndex), -1, candidatesVecIds.at(candidateIndex), -1); + } + } + } + + pairJetPerpCone1PtVec.clear(); + pairJetPerpCone1EnergyVec.clear(); + pairJetPerpCone1ThetaVec.clear(); + pairPerpCone1PerpCone1PtVec.clear(); + pairPerpCone1PerpCone1EnergyVec.clear(); + pairPerpCone1PerpCone1ThetaVec.clear(); + pairPerpCone1PerpCone2PtVec.clear(); + pairPerpCone1PerpCone2EnergyVec.clear(); + pairPerpCone1PerpCone2ThetaVec.clear(); + int32_t slicerId = -1; + if constexpr (isSubtracted) { + auto const& candidate = jet.template candidates_first_as(); + slicerId = candidate.globalIndex(); + } else { + if constexpr (!isMC) { + slicerId = jet.collisionId(); + } else { + slicerId = jet.mcCollisionId(); + } + } + auto tracksPerCollision = tracks.sliceBy(slicer, slicerId); + + float perpCone1Phi = RecoDecay::constrainAngle(jet.phi() + (M_PI / 2.)); + float perpCone2Phi = RecoDecay::constrainAngle(jet.phi() - (M_PI / 2.)); + float perpCone1Pt = 0.0; + float perpCone2Pt = 0.0; + std::vector tracksPerpCone1Vec; + std::vector tracksPerpCone2Vec; + for (auto const& track : tracksPerCollision) { + float deltaPhi1 = track.phi() - perpCone1Phi; + deltaPhi1 = RecoDecay::constrainAngle(deltaPhi1, -M_PI); + float deltaPhi2 = track.phi() - perpCone2Phi; + deltaPhi2 = RecoDecay::constrainAngle(deltaPhi2, -M_PI); + float deltaEta = jet.eta() - track.eta(); + + if (TMath::Sqrt((deltaPhi1 * deltaPhi1) + (deltaEta * deltaEta)) <= jet.r() / 100.0) { + if (track.pt() >= pairConstituentPtMin) { + tracksPerpCone1Vec.push_back(track); + } + perpCone1Pt += track.pt(); + } + if (TMath::Sqrt((deltaPhi2 * deltaPhi2) + (deltaEta * deltaEta)) <= jet.r() / 100.0) { + if (track.pt() >= pairConstituentPtMin) { + tracksPerpCone2Vec.push_back(track); + } + perpCone2Pt += track.pt(); + } + } + perpConeRho = (perpCone1Pt + perpCone2Pt) / (2 * M_PI * (jet.r() / 100.0) * (jet.r() / 100.0)); // currently done per jet - could be better to do for leading jet if pushing to very low pT + if (doPairBkg) { + if (tracksVec.size() >= 1 && tracksPerpCone1Vec.size() >= 1) { + for (typename std::vector::size_type track1Index = 0; track1Index < tracksVec.size(); track1Index++) { + for (typename std::vector::size_type track2Index = 0; track2Index < tracksPerpCone1Vec.size(); track2Index++) { + pairJetPerpCone1PtVec.push_back(tracksVec.at(track1Index).pt() * tracksPerpCone1Vec.at(track2Index).pt()); + pairJetPerpCone1EnergyVec.push_back(2.0 * tracksVec.at(track1Index).energy() * tracksPerpCone1Vec.at(track2Index).energy()); + float dPhi = RecoDecay::constrainAngle(tracksVec.at(track1Index).phi() - (tracksPerpCone1Vec.at(track2Index).phi() - (M_PI / 2.)), -M_PI); + float dEta = tracksVec.at(track1Index).eta() - tracksPerpCone1Vec.at(track2Index).eta(); + pairJetPerpCone1ThetaVec.push_back(std::sqrt(dEta * dEta + dPhi * dPhi)); + } + } + } + + if (candidatesVec.size() >= 1 && tracksPerpCone1Vec.size() >= 1) { + for (typename std::vector>::size_type candidate1Index = 0; candidate1Index < candidatesVec.size(); candidate1Index++) { + for (typename std::vector::size_type track2Index = 0; track2Index < tracksPerpCone1Vec.size(); track2Index++) { + pairJetPerpCone1PtVec.push_back(candidatesVec.at(candidate1Index).pt() * tracksPerpCone1Vec.at(track2Index).pt()); + auto candidate1Energy = std::sqrt((candidatesVec.at(candidate1Index).p() * candidatesVec.at(candidate1Index).p()) + (candMass * candMass)); + pairJetPerpCone1EnergyVec.push_back(2.0 * candidate1Energy * tracksPerpCone1Vec.at(track2Index).energy()); + float dPhi = RecoDecay::constrainAngle(candidatesVec.at(candidate1Index).phi() - (tracksPerpCone1Vec.at(track2Index).phi() - (M_PI / 2.)), -M_PI); + float dEta = candidatesVec.at(candidate1Index).eta() - tracksPerpCone1Vec.at(track2Index).eta(); + pairJetPerpCone1ThetaVec.push_back(std::sqrt(dEta * dEta + dPhi * dPhi)); + } + } + } + + if (tracksPerpCone1Vec.size() >= 1) { + for (typename std::vector::size_type track1Index = 0; track1Index < tracksPerpCone1Vec.size(); track1Index++) { + for (typename std::vector::size_type track2Index = track1Index + 1; track2Index < tracksPerpCone1Vec.size(); track2Index++) { + pairPerpCone1PerpCone1PtVec.push_back(tracksPerpCone1Vec.at(track1Index).pt() * tracksPerpCone1Vec.at(track2Index).pt()); + pairPerpCone1PerpCone1EnergyVec.push_back(2.0 * tracksPerpCone1Vec.at(track1Index).energy() * tracksPerpCone1Vec.at(track2Index).energy()); + pairPerpCone1PerpCone1ThetaVec.push_back(jetutilities::deltaR(tracksPerpCone1Vec.at(track1Index), tracksPerpCone1Vec.at(track2Index))); + } + } + } + + if (tracksPerpCone1Vec.size() >= 1 && tracksPerpCone2Vec.size() >= 1) { + for (typename std::vector::size_type track1Index = 0; track1Index < tracksPerpCone1Vec.size(); track1Index++) { + for (typename std::vector::size_type track2Index = 0; track2Index < tracksPerpCone2Vec.size(); track2Index++) { + pairPerpCone1PerpCone2PtVec.push_back(tracksPerpCone1Vec.at(track1Index).pt() * tracksPerpCone2Vec.at(track2Index).pt()); + pairPerpCone1PerpCone2EnergyVec.push_back(2.0 * tracksPerpCone1Vec.at(track1Index).energy() * tracksPerpCone2Vec.at(track2Index).energy()); + float dPhi = RecoDecay::constrainAngle((tracksPerpCone1Vec.at(track1Index).phi() - (M_PI / 2.)) - (tracksPerpCone2Vec.at(track2Index).phi() + (M_PI / 2.)), -M_PI); + float dEta = tracksPerpCone1Vec.at(track1Index).eta() - tracksPerpCone2Vec.at(track2Index).eta(); + pairPerpCone1PerpCone2ThetaVec.push_back(std::sqrt(dEta * dEta + dPhi * dPhi)); + } } } } @@ -217,17 +396,24 @@ struct JetSubstructureHFTask { void jetSubstructureSimple(T const& jet, U const& /*tracks*/, V const& /*candidates*/) { angularity = 0.0; + leadingConstituentPt = 0.0; for (auto& candidate : jet.template candidates_as()) { + if (candidate.pt() >= leadingConstituentPt) { + leadingConstituentPt = candidate.pt(); + } angularity += std::pow(candidate.pt(), kappa) * std::pow(jetutilities::deltaR(jet, candidate), alpha); } for (auto& constituent : jet.template tracks_as()) { + if (constituent.pt() >= leadingConstituentPt) { + leadingConstituentPt = constituent.pt(); + } angularity += std::pow(constituent.pt(), kappa) * std::pow(jetutilities::deltaR(jet, constituent), alpha); } angularity /= (jet.pt() * (jet.r() / 100.f)); } - template - void analyseCharged(T const& jet, U const& tracks, V const& candidates, M& outputTable) + template + void analyseCharged(T const& jet, U const& tracks, V const& candidates, M const& trackSlicer, N& outputTable, O& splittingTable, P& pairTable) { jetConstituents.clear(); for (auto& jetConstituent : jet.template tracks_as()) { @@ -237,17 +423,17 @@ struct JetSubstructureHFTask { fastjetutilities::fillTracks(jetHFCandidate, jetConstituents, jetHFCandidate.globalIndex(), static_cast(JetConstituentStatus::candidate), candMass); } nSub = jetsubstructureutilities::getNSubjettiness(jet, tracks, tracks, candidates, 2, fastjet::contrib::CA_Axes(), true, zCut, beta); - jetReclustering(jet); - jetPairing(jet, tracks, candidates); + jetReclustering(jet, splittingTable); + jetPairing(jet, tracks, candidates, trackSlicer, pairTable); jetSubstructureSimple(jet, tracks, candidates); - outputTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec, angularity); + outputTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairJetPtVec, pairJetEnergyVec, pairJetThetaVec, pairJetPerpCone1PtVec, pairJetPerpCone1EnergyVec, pairJetPerpCone1ThetaVec, pairPerpCone1PerpCone1PtVec, pairPerpCone1PerpCone1EnergyVec, pairPerpCone1PerpCone1ThetaVec, pairPerpCone1PerpCone2PtVec, pairPerpCone1PerpCone2EnergyVec, pairPerpCone1PerpCone2ThetaVec, angularity, leadingConstituentPt, perpConeRho); } void processChargedJetsData(typename JetTableData::iterator const& jet, CandidateTable const& candidates, aod::JetTracks const& tracks) { - analyseCharged(jet, tracks, candidates, jetSubstructureDataTable); + analyseCharged(jet, tracks, candidates, TracksPerCollision, jetSubstructureDataTable, jetSplittingsDataTable, jetPairsDataTable); } PROCESS_SWITCH(JetSubstructureHFTask, processChargedJetsData, "HF jet substructure on data", false); @@ -255,7 +441,7 @@ struct JetSubstructureHFTask { CandidateTable const& candidates, TracksSub const& tracks) { - analyseCharged(jet, tracks, candidates, jetSubstructureDataSubTable); + analyseCharged(jet, tracks, candidates, selectSlicer(TracksPerD0DataSub, TracksPerDplusDataSub, TracksPerDstarDataSub, TracksPerLcDataSub, TracksPerB0DataSub, TracksPerBplusDataSub, TracksPerDielectronDataSub), jetSubstructureDataSubTable, jetSplittingsDataSubTable, jetPairsDataSubTable); } PROCESS_SWITCH(JetSubstructureHFTask, processChargedJetsDataSub, "HF jet substructure on data", false); @@ -263,7 +449,7 @@ struct JetSubstructureHFTask { CandidateTable const& candidates, aod::JetTracks const& tracks) { - analyseCharged(jet, tracks, candidates, jetSubstructureMCDTable); + analyseCharged(jet, tracks, candidates, TracksPerCollision, jetSubstructureMCDTable, jetSplittingsMCDTable, jetPairsMCDTable); } PROCESS_SWITCH(JetSubstructureHFTask, processChargedJetsMCD, "HF jet substructure on data", false); @@ -279,10 +465,10 @@ struct JetSubstructureHFTask { fastjetutilities::fillTracks(jetHFCandidate, jetConstituents, jetHFCandidate.globalIndex(), static_cast(JetConstituentStatus::candidate), candMass); } nSub = jetsubstructureutilities::getNSubjettiness(jet, particles, particles, candidates, 2, fastjet::contrib::CA_Axes(), true, zCut, beta); - jetReclustering(jet); - jetPairing(jet, particles, candidates); + jetReclustering(jet, jetSplittingsMCPTable); + jetPairing(jet, particles, candidates, ParticlesPerMcCollision, jetPairsMCPTable); jetSubstructureSimple(jet, particles, candidates); - jetSubstructureMCPTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec, angularity); + jetSubstructureMCPTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairJetPtVec, pairJetEnergyVec, pairJetThetaVec, pairJetPerpCone1PtVec, pairJetPerpCone1EnergyVec, pairJetPerpCone1ThetaVec, pairPerpCone1PerpCone1PtVec, pairPerpCone1PerpCone1EnergyVec, pairPerpCone1PerpCone1ThetaVec, pairPerpCone1PerpCone2PtVec, pairPerpCone1PerpCone2EnergyVec, pairPerpCone1PerpCone2ThetaVec, angularity, leadingConstituentPt, perpConeRho); } PROCESS_SWITCH(JetSubstructureHFTask, processChargedJetsMCP, "HF jet substructure on MC particle level", false); }; diff --git a/PWGJE/Tasks/jetSubstructureHFOutput.cxx b/PWGJE/Tasks/jetSubstructureHFOutput.cxx index d651f2d8e5b..ee3aaebc142 100644 --- a/PWGJE/Tasks/jetSubstructureHFOutput.cxx +++ b/PWGJE/Tasks/jetSubstructureHFOutput.cxx @@ -14,76 +14,77 @@ /// \author Nima Zardoshti // -#include - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "TDatabasePDG.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGHF/DataModel/CandidateReconstructionTables.h" -#include "PWGHF/DataModel/CandidateSelectionTables.h" - +#include "PWGJE/Core/JetFindingUtilities.h" #include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetReducedDataHF.h" #include "PWGJE/DataModel/JetSubstructure.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" + +#include "Framework/ASoA.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; // NB: runDataProcessing.h must be included after customize! -#include "Framework/runDataProcessing.h" -template +template struct JetSubstructureHFOutputTask { - Produces collisionOutputTableData; - Produces jetOutputTableData; - Produces jetSubstructureOutputTableData; - Produces jetMatchingOutputTableData; - Produces collisionOutputTableDataSub; - Produces jetOutputTableDataSub; - Produces jetSubstructureOutputTableDataSub; - Produces jetMatchingOutputTableDataSub; - Produces collisionOutputTableMCD; - Produces jetOutputTableMCD; - Produces jetSubstructureOutputTableMCD; - Produces jetMatchingOutputTableMCD; - Produces collisionOutputTableMCP; - Produces jetOutputTableMCP; - Produces jetSubstructureOutputTableMCP; - Produces jetMatchingOutputTableMCP; - Produces hfCollisionsTable; - Produces candidateTable; - Produces candidateParsTable; - Produces candidateParExtrasTable; - Produces candidateParsDaughterTable; - Produces candidateSelsTable; - Produces candidateMlsTable; - Produces candidateMlsDaughterTable; - Produces candidateMcsTable; - Produces hfMcCollisionsTable; - Produces hfMcCollisionsMatchingTable; - Produces hfParticlesTable; - - Configurable jetPtMinData{"jetPtMinData", 0.0, "minimum jet pT cut for data jets"}; - Configurable jetPtMinDataSub{"jetPtMinDataSub", 0.0, "minimum jet pT cut for eventwise constituent subtracted data jets"}; - Configurable jetPtMinMCD{"jetPtMinMCD", 0.0, "minimum jet pT cut for mcd jets"}; - Configurable jetPtMinMCP{"jetPtMinMCP", 0.0, "minimum jet pT cut for mcp jets"}; - Configurable> jetRadii{"jetRadii", std::vector{0.4}, "jet resolution parameters"}; - Configurable jetEtaMin{"jetEtaMin", -99.0, "minimum jet pseudorapidity"}; - Configurable jetEtaMax{"jetEtaMax", 99.0, "maximum jet pseudorapidity"}; - - Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track pseudorapidity"}; - Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum track pseudorapidity"}; + struct : ProducesGroup { + Produces collisionOutputTableData; + Produces jetOutputTableData; + Produces jetSubstructureOutputTableData; + Produces jetMatchingOutputTableData; + Produces collisionOutputTableDataSub; + Produces jetOutputTableDataSub; + Produces jetSubstructureOutputTableDataSub; + Produces jetMatchingOutputTableDataSub; + Produces collisionOutputTableMCD; + Produces jetOutputTableMCD; + Produces jetSubstructureOutputTableMCD; + Produces jetMatchingOutputTableMCD; + Produces collisionOutputTableMCP; + Produces hfMcOnlyCollisionsTable; + Produces jetOutputTableMCP; + Produces jetSubstructureOutputTableMCP; + Produces jetMatchingOutputTableMCP; + Produces hfCollisionsTable; + Produces candidateTable; + Produces candidateParsTable; + Produces candidateParExtrasTable; + Produces candidateParsDaughterTable; + Produces candidateSelsTable; + Produces candidateMlsTable; + Produces candidateMlsDaughterTable; + Produces candidateMcsTable; + Produces hfMcCollisionsTable; + Produces hfMcCollisionsMatchingTable; + Produces hfParticlesTable; + } products; + + struct : ConfigurableGroup { + Configurable jetPtMinData{"jetPtMinData", 0.0, "minimum jet pT cut for data jets"}; + Configurable jetPtMinDataSub{"jetPtMinDataSub", 0.0, "minimum jet pT cut for eventwise constituent subtracted data jets"}; + Configurable jetPtMinMCD{"jetPtMinMCD", 0.0, "minimum jet pT cut for mcd jets"}; + Configurable jetPtMinMCP{"jetPtMinMCP", 0.0, "minimum jet pT cut for mcp jets"}; + Configurable> jetRadii{"jetRadii", std::vector{0.4}, "jet resolution parameters"}; + Configurable jetEtaMin{"jetEtaMin", -99.0, "minimum jet pseudorapidity"}; + Configurable jetEtaMax{"jetEtaMax", 99.0, "maximum jet pseudorapidity"}; + Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track pseudorapidity"}; + Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum track pseudorapidity"}; + } configs; // need to add selection on pThat to post processing @@ -96,57 +97,216 @@ struct JetSubstructureHFOutputTask { std::map candidateCollisionMapping; std::map candidateMcCollisionMapping; + std::vector> splittingMatchesGeoVecVecData; + std::vector> splittingMatchesPtVecVecData; + std::vector> splittingMatchesHFVecVecData; + std::vector> splittingMatchesGeoVecVecDataSub; + std::vector> splittingMatchesPtVecVecDataSub; + std::vector> splittingMatchesHFVecVecDataSub; + std::vector> splittingMatchesGeoVecVecMCD; + std::vector> splittingMatchesPtVecVecMCD; + std::vector> splittingMatchesHFVecVecMCD; + std::vector> splittingMatchesGeoVecVecMCP; + std::vector> splittingMatchesPtVecVecMCP; + std::vector> splittingMatchesHFVecVecMCP; + + std::vector> pairMatchesVecVecData; + std::vector> pairMatchesVecVecDataSub; + std::vector> pairMatchesVecVecMCD; + std::vector> pairMatchesVecVecMCP; + std::vector jetRadiiValues; std::vector collisionFlag; std::vector mcCollisionFlag; - PresliceUnsorted> CollisionsPerMcCollision = aod::jmccollisionlb::mcCollisionId; - PresliceOptional D0CollisionsPerCollision = aod::jd0indices::collisionId; - PresliceOptional LcCollisionsPerCollision = aod::jlcindices::collisionId; - PresliceOptional BplusCollisionsPerCollision = aod::jbplusindices::collisionId; - PresliceOptional DielectronCollisionsPerCollision = aod::jdielectronindices::collisionId; - PresliceOptional> D0McCollisionsPerMcCollision = aod::jd0indices::mcCollisionId; - PresliceOptional> LcMcCollisionsPerMcCollision = aod::jlcindices::mcCollisionId; - PresliceOptional> BplusMcCollisionsPerMcCollision = aod::jbplusindices::mcCollisionId; - PresliceOptional DielectronMcCollisionsPerMcCollision = aod::jdielectronindices::mcCollisionId; - void init(InitContext const&) { - jetRadiiValues = (std::vector)jetRadii; + jetRadiiValues = (std::vector)configs.jetRadii; + } + + struct : PresliceGroup { + PresliceUnsorted> CollisionsPerMcCollision = aod::jmccollisionlb::mcCollisionId; + PresliceOptional CandidateCollisionsPerCollision = aod::jcandidateindices::collisionId; + PresliceOptional CandidateMcCollisionsPerMcCollision = aod::jcandidateindices::mcCollisionId; + PresliceOptional CandidateMcCollisionsPerMcCollisionMCPOnly = aod::jcandidateindices::mcCollisionId; + + PresliceOptional> D0SplittingsPerJetData = aod::d0chargedsplitting::jetId; + PresliceOptional> D0SplittingsPerJetDataSub = aod::d0chargedeventwisesubtractedsplitting::jetId; + PresliceOptional> D0SplittingsPerJetMCD = aod::d0chargedmcdetectorlevelsplitting::jetId; + PresliceOptional> D0SplittingsPerJetMCP = aod::d0chargedmcparticlelevelsplitting::jetId; + + PresliceOptional> D0PairsPerJetData = aod::d0chargedpair::jetId; + PresliceOptional> D0PairsPerJetDataSub = aod::d0chargedeventwisesubtractedpair::jetId; + PresliceOptional> D0PairsPerJetMCD = aod::d0chargedmcdetectorlevelpair::jetId; + PresliceOptional> D0PairsPerJetMCP = aod::d0chargedmcparticlelevelpair::jetId; + + PresliceOptional> DplusSplittingsPerJetData = aod::dpluschargedsplitting::jetId; + PresliceOptional> DplusSplittingsPerJetDataSub = aod::dpluschargedeventwisesubtractedsplitting::jetId; + PresliceOptional> DplusSplittingsPerJetMCD = aod::dpluschargedmcdetectorlevelsplitting::jetId; + PresliceOptional> DplusSplittingsPerJetMCP = aod::dpluschargedmcparticlelevelsplitting::jetId; + + PresliceOptional> DplusPairsPerJetData = aod::dpluschargedpair::jetId; + PresliceOptional> DplusPairsPerJetDataSub = aod::dpluschargedeventwisesubtractedpair::jetId; + PresliceOptional> DplusPairsPerJetMCD = aod::dpluschargedmcdetectorlevelpair::jetId; + PresliceOptional> DplusPairsPerJetMCP = aod::dpluschargedmcparticlelevelpair::jetId; + + PresliceOptional> DstarSplittingsPerJetData = aod::dstarchargedsplitting::jetId; + PresliceOptional> DstarSplittingsPerJetDataSub = aod::dstarchargedeventwisesubtractedsplitting::jetId; + PresliceOptional> DstarSplittingsPerJetMCD = aod::dstarchargedmcdetectorlevelsplitting::jetId; + PresliceOptional> DstarSplittingsPerJetMCP = aod::dstarchargedmcparticlelevelsplitting::jetId; + + PresliceOptional> DstarPairsPerJetData = aod::dstarchargedpair::jetId; + PresliceOptional> DstarPairsPerJetDataSub = aod::dstarchargedeventwisesubtractedpair::jetId; + PresliceOptional> DstarPairsPerJetMCD = aod::dstarchargedmcdetectorlevelpair::jetId; + PresliceOptional> DstarPairsPerJetMCP = aod::dstarchargedmcparticlelevelpair::jetId; + + PresliceOptional> LcSplittingsPerJetData = aod::lcchargedsplitting::jetId; + PresliceOptional> LcSplittingsPerJetDataSub = aod::lcchargedeventwisesubtractedsplitting::jetId; + PresliceOptional> LcSplittingsPerJetMCD = aod::lcchargedmcdetectorlevelsplitting::jetId; + PresliceOptional> LcSplittingsPerJetMCP = aod::lcchargedmcparticlelevelsplitting::jetId; + + PresliceOptional> LcPairsPerJetData = aod::lcchargedpair::jetId; + PresliceOptional> LcPairsPerJetDataSub = aod::lcchargedeventwisesubtractedpair::jetId; + PresliceOptional> LcPairsPerJetMCD = aod::lcchargedmcdetectorlevelpair::jetId; + PresliceOptional> LcPairsPerJetMCP = aod::lcchargedmcparticlelevelpair::jetId; + + PresliceOptional> B0SplittingsPerJetData = aod::b0chargedsplitting::jetId; + PresliceOptional> B0SplittingsPerJetDataSub = aod::b0chargedeventwisesubtractedsplitting::jetId; + PresliceOptional> B0SplittingsPerJetMCD = aod::b0chargedmcdetectorlevelsplitting::jetId; + PresliceOptional> B0SplittingsPerJetMCP = aod::b0chargedmcparticlelevelsplitting::jetId; + + PresliceOptional> B0PairsPerJetData = aod::b0chargedpair::jetId; + PresliceOptional> B0PairsPerJetDataSub = aod::b0chargedeventwisesubtractedpair::jetId; + PresliceOptional> B0PairsPerJetMCD = aod::b0chargedmcdetectorlevelpair::jetId; + PresliceOptional> B0PairsPerJetMCP = aod::b0chargedmcparticlelevelpair::jetId; + + PresliceOptional> BplusSplittingsPerJetData = aod::bpluschargedsplitting::jetId; + PresliceOptional> BplusSplittingsPerJetDataSub = aod::bpluschargedeventwisesubtractedsplitting::jetId; + PresliceOptional> BplusSplittingsPerJetMCD = aod::bpluschargedmcdetectorlevelsplitting::jetId; + PresliceOptional> BplusSplittingsPerJetMCP = aod::bpluschargedmcparticlelevelsplitting::jetId; + + PresliceOptional> BplusPairsPerJetData = aod::bpluschargedpair::jetId; + PresliceOptional> BplusPairsPerJetDataSub = aod::bpluschargedeventwisesubtractedpair::jetId; + PresliceOptional> BplusPairsPerJetMCD = aod::bpluschargedmcdetectorlevelpair::jetId; + PresliceOptional> BplusPairsPerJetMCP = aod::bpluschargedmcparticlelevelpair::jetId; + + PresliceOptional> DielectronSplittingsPerJetData = aod::dielectronchargedsplitting::jetId; + PresliceOptional> DielectronSplittingsPerJetDataSub = aod::dielectronchargedeventwisesubtractedsplitting::jetId; + PresliceOptional> DielectronSplittingsPerJetMCD = aod::dielectronchargedmcdetectorlevelsplitting::jetId; + PresliceOptional> DielectronSplittingsPerJetMCP = aod::dielectronchargedmcparticlelevelsplitting::jetId; + + PresliceOptional> DielectronPairsPerJetData = aod::dielectronchargedpair::jetId; + PresliceOptional> DielectronPairsPerJetDataSub = aod::dielectronchargedeventwisesubtractedpair::jetId; + PresliceOptional> DielectronPairsPerJetMCD = aod::dielectronchargedmcdetectorlevelpair::jetId; + PresliceOptional> DielectronPairsPerJetMCP = aod::dielectronchargedmcparticlelevelpair::jetId; + + } preslices; + + template + auto candidateMCCollisionSlicer(T const& McCollisionsPerMcCollision, U const& McCollisionsPerMcCollisionMCPOnly) + { + if constexpr (isMCP) { + return McCollisionsPerMcCollisionMCPOnly; + } else { + return McCollisionsPerMcCollision; + } + } + + template + void fillSplittingMatchingVectors(T const& splittingsMatches, int jetIndex, std::vector>& splittingMatchesGeoVecVec, std::vector>& splittingMatchesPtVecVec, std::vector>& splittingMatchesHFVecVec) + { + for (auto const& splittingMatches : splittingsMatches) { + auto splittingMatchesGeoSpan = splittingMatches.splittingMatchingGeo(); + auto splittingMatchesPtSpan = splittingMatches.splittingMatchingPt(); + auto splittingMatchesHFSpan = splittingMatches.splittingMatchingHF(); + std::copy(splittingMatchesGeoSpan.begin(), splittingMatchesGeoSpan.end(), std::back_inserter(splittingMatchesGeoVecVec[jetIndex])); + std::copy(splittingMatchesPtSpan.begin(), splittingMatchesPtSpan.end(), std::back_inserter(splittingMatchesPtVecVec[jetIndex])); + std::copy(splittingMatchesHFSpan.begin(), splittingMatchesHFSpan.end(), std::back_inserter(splittingMatchesHFVecVec[jetIndex])); + } + } + + template + void fillPairMatchingVectors(T const& pairsMatches, int jetIndex, std::vector>& pairMatchesVecVec) + { + for (auto const& pairMatches : pairsMatches) { + auto pairMatchesSpan = pairMatches.pairMatching(); + std::copy(pairMatchesSpan.begin(), pairMatchesSpan.end(), std::back_inserter(pairMatchesVecVec[jetIndex])); + } } template - void fillJetTables(T const& jet, U const& /*cand*/, int32_t collisionIndex, int32_t candidateIndex, V& jetOutputTable, M& jetSubstructureOutputTable, std::map& jetMap) + void fillJetTables(T const& jet, U const& /*cand*/, int32_t collisionIndex, int32_t candidateIndex, V& jetOutputTable, M& jetSubstructureOutputTable, std::vector>& splittingMatchesGeoVecVec, std::vector>& splittingMatchesPtVecVec, std::vector>& splittingMatchesHFVecVec, std::vector>& pairMatchesVecVec, float rho, std::map& jetMap) { std::vector energyMotherVec; std::vector ptLeadingVec; std::vector ptSubLeadingVec; std::vector thetaVec; - std::vector pairPtVec; - std::vector pairEnergyVec; - std::vector pairThetaVec; + std::vector pairJetPtVec; + std::vector pairJetEnergyVec; + std::vector pairJetThetaVec; + std::vector pairJetPerpCone1PtVec; + std::vector pairJetPerpCone1EnergyVec; + std::vector pairJetPerpCone1ThetaVec; + std::vector pairPerpCone1PerpCone1PtVec; + std::vector pairPerpCone1PerpCone1EnergyVec; + std::vector pairPerpCone1PerpCone1ThetaVec; + std::vector pairPerpCone1PerpCone2PtVec; + std::vector pairPerpCone1PerpCone2EnergyVec; + std::vector pairPerpCone1PerpCone2ThetaVec; + auto energyMotherSpan = jet.energyMother(); auto ptLeadingSpan = jet.ptLeading(); auto ptSubLeadingSpan = jet.ptSubLeading(); auto thetaSpan = jet.theta(); - auto pairPtSpan = jet.pairPt(); - auto pairEnergySpan = jet.pairEnergy(); - auto pairThetaSpan = jet.pairTheta(); + auto pairJetPtSpan = jet.pairJetPt(); + auto pairJetEnergySpan = jet.pairJetEnergy(); + auto pairJetThetaSpan = jet.pairJetTheta(); + auto pairJetPerpCone1PtSpan = jet.pairJetPerpCone1Pt(); + auto pairJetPerpCone1EnergySpan = jet.pairJetPerpCone1Energy(); + auto pairJetPerpCone1ThetaSpan = jet.pairJetPerpCone1Theta(); + auto pairPerpCone1PerpCone1PtSpan = jet.pairPerpCone1PerpCone1Pt(); + auto pairPerpCone1PerpCone1EnergySpan = jet.pairPerpCone1PerpCone1Energy(); + auto pairPerpCone1PerpCone1ThetaSpan = jet.pairPerpCone1PerpCone1Theta(); + auto pairPerpCone1PerpCone2PtSpan = jet.pairPerpCone1PerpCone2Pt(); + auto pairPerpCone1PerpCone2EnergySpan = jet.pairPerpCone1PerpCone2Energy(); + auto pairPerpCone1PerpCone2ThetaSpan = jet.pairPerpCone1PerpCone2Theta(); + std::copy(energyMotherSpan.begin(), energyMotherSpan.end(), std::back_inserter(energyMotherVec)); std::copy(ptLeadingSpan.begin(), ptLeadingSpan.end(), std::back_inserter(ptLeadingVec)); std::copy(ptSubLeadingSpan.begin(), ptSubLeadingSpan.end(), std::back_inserter(ptSubLeadingVec)); std::copy(thetaSpan.begin(), thetaSpan.end(), std::back_inserter(thetaVec)); - std::copy(pairPtSpan.begin(), pairPtSpan.end(), std::back_inserter(pairPtVec)); - std::copy(pairEnergySpan.begin(), pairEnergySpan.end(), std::back_inserter(pairEnergyVec)); - std::copy(pairThetaSpan.begin(), pairThetaSpan.end(), std::back_inserter(pairThetaVec)); - jetOutputTable(collisionIndex, candidateIndex, jet.pt(), jet.phi(), jet.eta(), jet.y(), jet.r(), jet.tracksIds().size() + jet.candidatesIds().size()); // here we take the decision to keep the collision index consistent with the JE framework in case it is later needed to join to other tables. The candidate Index however can be linked to the HF tables - jetSubstructureOutputTable(jetOutputTable.lastIndex(), energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, jet.nSub2DR(), jet.nSub1(), jet.nSub2(), pairPtVec, pairEnergyVec, pairThetaVec, jet.angularity()); + std::copy(pairJetPtSpan.begin(), pairJetPtSpan.end(), std::back_inserter(pairJetPtVec)); + std::copy(pairJetEnergySpan.begin(), pairJetEnergySpan.end(), std::back_inserter(pairJetEnergyVec)); + std::copy(pairJetThetaSpan.begin(), pairJetThetaSpan.end(), std::back_inserter(pairJetThetaVec)); + std::copy(pairJetPerpCone1PtSpan.begin(), pairJetPerpCone1PtSpan.end(), std::back_inserter(pairJetPerpCone1PtVec)); + std::copy(pairJetPerpCone1EnergySpan.begin(), pairJetPerpCone1EnergySpan.end(), std::back_inserter(pairJetPerpCone1EnergyVec)); + std::copy(pairJetPerpCone1ThetaSpan.begin(), pairJetPerpCone1ThetaSpan.end(), std::back_inserter(pairJetPerpCone1ThetaVec)); + std::copy(pairPerpCone1PerpCone1PtSpan.begin(), pairPerpCone1PerpCone1PtSpan.end(), std::back_inserter(pairPerpCone1PerpCone1PtVec)); + std::copy(pairPerpCone1PerpCone1EnergySpan.begin(), pairPerpCone1PerpCone1EnergySpan.end(), std::back_inserter(pairPerpCone1PerpCone1EnergyVec)); + std::copy(pairPerpCone1PerpCone1ThetaSpan.begin(), pairPerpCone1PerpCone1ThetaSpan.end(), std::back_inserter(pairPerpCone1PerpCone1ThetaVec)); + std::copy(pairPerpCone1PerpCone2PtSpan.begin(), pairPerpCone1PerpCone2PtSpan.end(), std::back_inserter(pairPerpCone1PerpCone2PtVec)); + std::copy(pairPerpCone1PerpCone2EnergySpan.begin(), pairPerpCone1PerpCone2EnergySpan.end(), std::back_inserter(pairPerpCone1PerpCone2EnergyVec)); + std::copy(pairPerpCone1PerpCone2ThetaSpan.begin(), pairPerpCone1PerpCone2ThetaSpan.end(), std::back_inserter(pairPerpCone1PerpCone2ThetaVec)); + + std::vector splittingMatchesGeoVec; + std::vector splittingMatchesPtVec; + std::vector splittingMatchesHFVec; + std::vector pairMatchesVec; + if (doprocessOutputSubstructureMatchingData || doprocessOutputSubstructureMatchingMC) { + splittingMatchesGeoVec = splittingMatchesGeoVecVec[jet.globalIndex()]; + splittingMatchesPtVec = splittingMatchesPtVecVec[jet.globalIndex()]; + splittingMatchesHFVec = splittingMatchesHFVecVec[jet.globalIndex()]; + pairMatchesVec = pairMatchesVecVec[jet.globalIndex()]; + } + + jetOutputTable(collisionIndex, candidateIndex, jet.pt(), jet.phi(), jet.eta(), jet.y(), jet.r(), jet.area(), rho, jet.perpConeRho(), jet.tracksIds().size() + jet.candidatesIds().size()); // here we take the decision to keep the collision index consistent with the JE framework in case it is later needed to join to other tables. The candidate Index however can be linked to the HF tables + jetSubstructureOutputTable(jetOutputTable.lastIndex(), energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, jet.nSub2DR(), jet.nSub1(), jet.nSub2(), pairJetPtVec, pairJetEnergyVec, pairJetThetaVec, pairJetPerpCone1PtVec, pairJetPerpCone1EnergyVec, pairJetPerpCone1ThetaVec, pairPerpCone1PerpCone1PtVec, pairPerpCone1PerpCone1EnergyVec, pairPerpCone1PerpCone1ThetaVec, pairPerpCone1PerpCone2PtVec, pairPerpCone1PerpCone2EnergyVec, pairPerpCone1PerpCone2ThetaVec, jet.angularity(), jet.ptLeadingConstituent(), splittingMatchesGeoVec, splittingMatchesPtVec, splittingMatchesHFVec, pairMatchesVec); jetMap.insert(std::make_pair(jet.globalIndex(), jetOutputTable.lastIndex())); } template - void analyseCharged(T const& collision, U const& jets, V const& /*candidates*/, M& collisionOutputTable, N& jetOutputTable, O& jetSubstructureOutputTable, std::map& jetMap, std::map& candidateMap, float jetPtMin, float eventWeight) + void analyseCharged(T const& collision, U const& jets, V const& /*candidates*/, M& collisionOutputTable, N& jetOutputTable, O& jetSubstructureOutputTable, std::vector>& splittingMatchesGeoVecVec, std::vector>& splittingMatchesPtVecVec, std::vector>& splittingMatchesHFVecVec, std::vector>& pairMatchesVecVec, std::map& jetMap, std::map& candidateMap, float jetPtMin, float eventWeight) { int nJetInCollision = 0; @@ -155,7 +315,7 @@ struct JetSubstructureHFOutputTask { if (jet.pt() < jetPtMin) { continue; } - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + if (!jetfindingutilities::isInEtaAcceptance(jet, configs.jetEtaMin, configs.jetEtaMax, configs.trackEtaMin, configs.trackEtaMax)) { continue; } for (const auto& jetRadiiValue : jetRadiiValues) { @@ -166,14 +326,18 @@ struct JetSubstructureHFOutputTask { if (candidateTableIndex != candidateMap.end()) { candidateIndex = candidateTableIndex->second; } - if constexpr (!isMCP) { - if (nJetInCollision == 0) { - collisionOutputTable(collision.posZ(), collision.centrality(), collision.eventSel(), eventWeight); - collisionIndex = collisionOutputTable.lastIndex(); + if (nJetInCollision == 0) { + float centrality = -1.0; + uint8_t eventSel = 0.0; + if constexpr (!isMCP) { + centrality = collision.centFT0M(); + eventSel = collision.eventSel(); } - nJetInCollision++; + collisionOutputTable(collision.posZ(), centrality, eventSel, eventWeight); + collisionIndex = collisionOutputTable.lastIndex(); } - fillJetTables(jet, candidate, collisionIndex, candidateIndex, jetOutputTable, jetSubstructureOutputTable, jetMap); + nJetInCollision++; + fillJetTables(jet, candidate, collisionIndex, candidateIndex, jetOutputTable, jetSubstructureOutputTable, splittingMatchesGeoVecVec, splittingMatchesPtVecVec, splittingMatchesHFVecVec, pairMatchesVecVec, candidate.rho(), jetMap); } } } @@ -186,7 +350,7 @@ struct JetSubstructureHFOutputTask { if (jet.pt() < jetPtMin) { continue; } - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + if (!jetfindingutilities::isInEtaAcceptance(jet, configs.jetEtaMin, configs.jetEtaMax, configs.trackEtaMin, configs.trackEtaMax)) { continue; } for (const auto& jetRadiiValue : jetRadiiValues) { @@ -199,34 +363,55 @@ struct JetSubstructureHFOutputTask { continue; } int32_t candidateCollisionIndex = -1; - int32_t candidateIndex = -1; if constexpr (isMCP) { auto hfMcCollisionIndex = candidateMcCollisionMapping.find(jetcandidateutilities::getMcCandidateCollisionId(candidate)); if (hfMcCollisionIndex != candidateMcCollisionMapping.end()) { candidateCollisionIndex = hfMcCollisionIndex->second; } - jetcandidateutilities::fillCandidateMcTable(candidate, candidateCollisionIndex, hfParticlesTable, candidateIndex); + jetcandidateutilities::fillCandidateMcTable(candidate, candidateCollisionIndex, products.hfParticlesTable); + candidateMap.insert(std::make_pair(candidate.globalIndex(), products.hfParticlesTable.lastIndex())); } else { auto hfCollisionIndex = candidateCollisionMapping.find(jetcandidateutilities::getCandidateCollisionId(candidate)); if (hfCollisionIndex != candidateCollisionMapping.end()) { candidateCollisionIndex = hfCollisionIndex->second; } - jetcandidateutilities::fillCandidateTable(candidate, candidateCollisionIndex, candidateTable, candidateParsTable, candidateParExtrasTable, candidateParsDaughterTable, candidateSelsTable, candidateMlsTable, candidateMlsDaughterTable, candidateMcsTable, candidateIndex); + jetcandidateutilities::fillCandidateTable(candidate, candidateCollisionIndex, products.candidateTable, products.candidateParsTable, products.candidateParExtrasTable, products.candidateParsDaughterTable, products.candidateSelsTable, products.candidateMlsTable, products.candidateMlsDaughterTable, products.candidateMcsTable); + candidateMap.insert(std::make_pair(candidate.globalIndex(), products.candidateTable.lastIndex())); } - candidateMap.insert(std::make_pair(candidate.globalIndex(), candidateIndex)); } } } } - template - void analyseMatched(T const& jets, U const& /*jetsTag*/, std::map& jetMapping, std::map& jetTagMapping, V& matchingOutputTable, float jetPtMin) + template + void analyseSubstructureMatched(T const& jets, U const& allSplittings, V const& allPairs, M const& D0SplittingsPerJet, N const DplusSplittingsPerJet, O const DstarSplittingsPerJet, P const& LcSplittingsPerJet, Q const& B0SplittingsPerJet, R const& BplusSplittingsPerJet, S const& DielectronSplittingsPerJet, A const& D0PairsPerJet, B const DplusPairsPerJet, C const& DstarPairsPerJet, D const& LcPairsPerJet, E const& B0PairsPerJet, F const& BplusPairsPerJet, G const& DielectronPairsPerJet, std::vector>& splittingMatchesGeoVecVec, std::vector>& splittingMatchesPtVecVec, std::vector>& splittingMatchesHFVecVec, std::vector>& pairMatchesVecVec, float jetPtMin) { for (const auto& jet : jets) { if (jet.pt() < jetPtMin) { continue; } - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + if (!jetfindingutilities::isInEtaAcceptance(jet, configs.jetEtaMin, configs.jetEtaMax, configs.trackEtaMin, configs.trackEtaMax)) { + continue; + } + for (const auto& jetRadiiValue : jetRadiiValues) { + if (jet.r() == round(jetRadiiValue * 100.0f)) { + auto splittings = jetcandidateutilities::slicedPerJet(allSplittings, jet, D0SplittingsPerJet, DplusSplittingsPerJet, DstarSplittingsPerJet, LcSplittingsPerJet, B0SplittingsPerJet, BplusSplittingsPerJet, DielectronSplittingsPerJet); + fillSplittingMatchingVectors(splittings, jet.globalIndex(), splittingMatchesGeoVecVec, splittingMatchesPtVecVec, splittingMatchesHFVecVec); + auto pairs = jetcandidateutilities::slicedPerJet(allPairs, jet, D0PairsPerJet, DplusPairsPerJet, DstarPairsPerJet, LcPairsPerJet, B0PairsPerJet, BplusPairsPerJet, DielectronPairsPerJet); + fillPairMatchingVectors(pairs, jet.globalIndex(), pairMatchesVecVec); + } + } + } + } + + template + void analyseJetMatched(T const& jets, std::map& jetMapping, std::map& jetTagMapping, U& matchingOutputTable, float jetPtMin) + { + for (const auto& jet : jets) { + if (jet.pt() < jetPtMin) { + continue; + } + if (!jetfindingutilities::isInEtaAcceptance(jet, configs.jetEtaMin, configs.jetEtaMax, configs.trackEtaMin, configs.trackEtaMax)) { continue; } for (const auto& jetRadiiValue : jetRadiiValues) { @@ -285,7 +470,7 @@ struct JetSubstructureHFOutputTask { if (jet.pt() < jetPtMin) { continue; } - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + if (!jetfindingutilities::isInEtaAcceptance(jet, configs.jetEtaMin, configs.jetEtaMax, configs.trackEtaMin, configs.trackEtaMax)) { continue; } for (const auto& jetRadiiValue : jetRadiiValues) { @@ -306,7 +491,7 @@ struct JetSubstructureHFOutputTask { if (jetMCP.pt() < jetPtMinMCP) { continue; } - if (!jetfindingutilities::isInEtaAcceptance(jetMCP, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + if (!jetfindingutilities::isInEtaAcceptance(jetMCP, configs.jetEtaMin, configs.jetEtaMax, configs.trackEtaMin, configs.trackEtaMax)) { continue; } for (const auto& jetRadiiValue : jetRadiiValues) { @@ -314,7 +499,7 @@ struct JetSubstructureHFOutputTask { mcCollisionFlag[jetMCP.mcCollisionId()] = true; if constexpr (!isMCPOnly) { - const auto collisionsPerMcCollision = collisions.sliceBy(CollisionsPerMcCollision, jetMCP.mcCollisionId()); + const auto collisionsPerMcCollision = collisions.sliceBy(preslices.CollisionsPerMcCollision, jetMCP.mcCollisionId()); for (auto collision : collisionsPerMcCollision) { collisionFlag[collision.globalIndex()] = true; } @@ -326,15 +511,14 @@ struct JetSubstructureHFOutputTask { if constexpr (!isMCPOnly) { for (const auto& collision : collisions) { if (collisionFlag[collision.globalIndex()]) { - const auto hfCollisionsPerCollision = jetcandidateutilities::slicedPerCandidateCollision(hfCollisions, candidates, collision, D0CollisionsPerCollision, LcCollisionsPerCollision, BplusCollisionsPerCollision, DielectronCollisionsPerCollision); // add Bplus later - int32_t candidateCollisionIndex = -1; + const auto hfCollisionsPerCollision = hfCollisions.sliceBy(preslices.CandidateCollisionsPerCollision, collision.globalIndex()); for (const auto& hfCollisionPerCollision : hfCollisionsPerCollision) { // should only ever be one auto hfCollisionTableIndex = candidateCollisionMapping.find(hfCollisionPerCollision.globalIndex()); if (hfCollisionTableIndex != candidateCollisionMapping.end()) { continue; } - jetcandidateutilities::fillCandidateCollisionTable(hfCollisionPerCollision, candidates, hfCollisionsTable, candidateCollisionIndex); - candidateCollisionMapping.insert(std::make_pair(hfCollisionPerCollision.globalIndex(), hfCollisionsTable.lastIndex())); + jetcandidateutilities::fillCandidateCollisionTable(hfCollisionPerCollision, candidates, products.hfCollisionsTable); + candidateCollisionMapping.insert(std::make_pair(hfCollisionPerCollision.globalIndex(), products.hfCollisionsTable.lastIndex())); } } } @@ -342,15 +526,14 @@ struct JetSubstructureHFOutputTask { if constexpr (isMC) { for (const auto& mcCollision : mcCollisions) { if (mcCollisionFlag[mcCollision.globalIndex()]) { - const auto hfMcCollisionsPerMcCollision = jetcandidateutilities::slicedPerCandidateCollision(hfMcCollisions, candidatesMCP, mcCollision, D0McCollisionsPerMcCollision, LcMcCollisionsPerMcCollision, BplusMcCollisionsPerMcCollision, DielectronMcCollisionsPerMcCollision); // add Bplus later - int32_t candidateMcCollisionIndex = -1; + const auto hfMcCollisionsPerMcCollision = hfMcCollisions.sliceBy(candidateMCCollisionSlicer(preslices.CandidateMcCollisionsPerMcCollision, preslices.CandidateMcCollisionsPerMcCollisionMCPOnly), mcCollision.globalIndex()); for (const auto& hfMcCollisionPerMcCollision : hfMcCollisionsPerMcCollision) { // should only ever be one auto hfMcCollisionTableIndex = candidateMcCollisionMapping.find(hfMcCollisionPerMcCollision.globalIndex()); if (hfMcCollisionTableIndex != candidateMcCollisionMapping.end()) { continue; } - jetcandidateutilities::fillCandidateMcCollisionTable(hfMcCollisionPerMcCollision, candidatesMCP, hfMcCollisionsTable, candidateMcCollisionIndex); - candidateMcCollisionMapping.insert(std::make_pair(hfMcCollisionPerMcCollision.globalIndex(), hfMcCollisionsTable.lastIndex())); + jetcandidateutilities::fillCandidateMcCollisionTable(hfMcCollisionPerMcCollision, candidatesMCP, products.hfMcCollisionsTable); + candidateMcCollisionMapping.insert(std::make_pair(hfMcCollisionPerMcCollision.globalIndex(), products.hfMcCollisionsTable.lastIndex())); if constexpr (!isMCPOnly && (jethfutilities::isHFTable

() || jethfutilities::isHFMcTable())) { // the matching of mcCollision to Collision is only done for HF tables std::vector hfCollisionIDs; for (auto const& hfCollisionPerMcCollision : hfMcCollisionPerMcCollision.template hfCollBases_as()) { // if added for others this line needs to be templated per type @@ -359,7 +542,7 @@ struct JetSubstructureHFOutputTask { hfCollisionIDs.push_back(hfCollisionIndex->second); } } - hfMcCollisionsMatchingTable(hfCollisionIDs); + products.hfMcCollisionsMatchingTable(hfCollisionIDs); } } } @@ -370,23 +553,30 @@ struct JetSubstructureHFOutputTask { void processClearMaps(aod::JetCollisions const&) { candidateMapping.clear(); - candidateCollisionMapping.clear(); - candidateMappingMCP.clear(); jetMappingData.clear(); jetMappingDataSub.clear(); jetMappingMCD.clear(); - jetMappingMCP.clear(); candidateCollisionMapping.clear(); + } + PROCESS_SWITCH(JetSubstructureHFOutputTask, processClearMaps, "process function that clears all the non-mcp maps in each dataframe", true); + + void processClearMapsMCP(aod::JetMcCollisions const& mcCollisions) + { + candidateMappingMCP.clear(); + jetMappingMCP.clear(); candidateMcCollisionMapping.clear(); + for (auto mcCollision : mcCollisions) { + products.hfMcOnlyCollisionsTable(mcCollision.posZ(), mcCollision.accepted(), mcCollision.attempted(), mcCollision.xsectGen(), mcCollision.xsectErr(), mcCollision.weight()); + } } - PROCESS_SWITCH(JetSubstructureHFOutputTask, processClearMaps, "process function that clears all the maps in each dataframe", true); + PROCESS_SWITCH(JetSubstructureHFOutputTask, processClearMapsMCP, "process function that clears all the mcp maps in each dataframe", true); void processOutputCollisionsData(aod::JetCollisions const& collisions, JetTableData const& jets, CandidateCollisionTable const& canidateCollisions, CandidateTable const& candidates) { - analyseHFCollisions(collisions, collisions, canidateCollisions, canidateCollisions, jets, jets, candidates, candidates, jetPtMinData); + analyseHFCollisions(collisions, collisions, canidateCollisions, canidateCollisions, jets, jets, candidates, candidates, configs.jetPtMinData); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCollisionsData, "hf collision output data", false); @@ -395,29 +585,29 @@ struct JetSubstructureHFOutputTask { CandidateCollisionTable const& canidateCollisions, CandidateTable const& candidates) { - analyseHFCollisions(collisions, collisions, canidateCollisions, canidateCollisions, jets, jets, candidates, candidates, jetPtMinDataSub); + analyseHFCollisions(collisions, collisions, canidateCollisions, canidateCollisions, jets, jets, candidates, candidates, configs.jetPtMinDataSub); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCollisionsDataSub, "hf collision output data eventwise constituent subtracted", false); void processOutputCollisionsMc(soa::Join const& collisions, aod::JetMcCollisions const& mcCollisions, JetTableMCD const& jetsMCD, - JetTableMCP const& jetsMCP, + JetTableMatchedMCP const& jetsMCP, CandidateCollisionTable const& canidateCollisions, CandidateMcCollisionTable const& canidateMcCollisions, CandidateTableMCD const& candidatesMCD, CandidateTableMCP const& candidatesMCP) { - analyseHFCollisions(collisions, mcCollisions, canidateCollisions, canidateMcCollisions, jetsMCD, jetsMCP, candidatesMCD, candidatesMCP, jetPtMinMCD, jetPtMinMCP); + analyseHFCollisions(collisions, mcCollisions, canidateCollisions, canidateMcCollisions, jetsMCD, jetsMCP, candidatesMCD, candidatesMCP, configs.jetPtMinMCD, configs.jetPtMinMCP); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCollisionsMc, "hf collision output MC", false); void processOutputCollisionsMCPOnly(aod::JetMcCollisions const& mcCollisions, JetTableMCP const& jetsMCP, - CandidateMcCollisionTable const& canidateMcCollisions, + CandidateMcOnlyCollisionTable const& canidateMcCollisions, CandidateTableMCP const& candidatesMCP) { - analyseHFCollisions(mcCollisions, mcCollisions, canidateMcCollisions, canidateMcCollisions, jetsMCP, jetsMCP, candidatesMCP, candidatesMCP, 0.0, jetPtMinMCP); + analyseHFCollisions(mcCollisions, mcCollisions, canidateMcCollisions, canidateMcCollisions, jetsMCP, jetsMCP, candidatesMCP, candidatesMCP, 0.0, configs.jetPtMinMCP); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCollisionsMCPOnly, "hf collision output MCP only", false); @@ -425,7 +615,7 @@ struct JetSubstructureHFOutputTask { JetTableData const& jets, CandidateTable const& candidates) { - analyseCandidates(jets, candidates, candidateMapping, jetPtMinData); + analyseCandidates(jets, candidates, candidateMapping, configs.jetPtMinData); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCandidatesData, "hf candidate output data", false); @@ -433,7 +623,7 @@ struct JetSubstructureHFOutputTask { JetTableDataSub const& jets, CandidateTable const& candidates) { - analyseCandidates(jets, candidates, candidateMapping, jetPtMinDataSub); + analyseCandidates(jets, candidates, candidateMapping, configs.jetPtMinDataSub); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCandidatesDataSub, "hf candidate output data eventwise constituent subtracted", false); @@ -442,7 +632,7 @@ struct JetSubstructureHFOutputTask { CandidateTableMCD const& candidates) { - analyseCandidates(jets, candidates, candidateMapping, jetPtMinMCD); + analyseCandidates(jets, candidates, candidateMapping, configs.jetPtMinMCD); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCandidatesMCD, "hf candidate output MCD", false); @@ -450,56 +640,98 @@ struct JetSubstructureHFOutputTask { JetTableMCP const& jets, CandidateTableMCP const& candidates) { - analyseCandidates(jets, candidates, candidateMappingMCP, jetPtMinMCP); + analyseCandidates(jets, candidates, candidateMappingMCP, configs.jetPtMinMCP); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCandidatesMCP, "hf candidate output MCP", false); + void processOutputSubstructureMatchingData(JetMatchedTableData const& jets, + JetTableDataSub const& jetsSub, + CandidateTable const&, + SplittingTableData const& splittingsData, + SplittingTableDataSub const& splittingsDataSub, + PairTableData const& pairsData, + PairTableDataSub const& pairsDataSub) + { + splittingMatchesGeoVecVecData.assign(jets.size(), {}); + splittingMatchesPtVecVecData.assign(jets.size(), {}); + splittingMatchesHFVecVecData.assign(jets.size(), {}); + pairMatchesVecVecData.assign(jets.size(), {}); + analyseSubstructureMatched(jets, splittingsData, pairsData, preslices.D0SplittingsPerJetData, preslices.DplusSplittingsPerJetData, preslices.DstarSplittingsPerJetData, preslices.LcSplittingsPerJetData, preslices.B0SplittingsPerJetData, preslices.BplusSplittingsPerJetData, preslices.DielectronSplittingsPerJetData, preslices.D0PairsPerJetData, preslices.DplusPairsPerJetData, preslices.DstarPairsPerJetData, preslices.LcPairsPerJetData, preslices.B0PairsPerJetData, preslices.BplusPairsPerJetData, preslices.DielectronPairsPerJetData, splittingMatchesGeoVecVecData, splittingMatchesPtVecVecData, splittingMatchesHFVecVecData, pairMatchesVecVecData, configs.jetPtMinData); + splittingMatchesGeoVecVecDataSub.assign(jetsSub.size(), {}); + splittingMatchesPtVecVecDataSub.assign(jetsSub.size(), {}); + splittingMatchesHFVecVecDataSub.assign(jetsSub.size(), {}); + pairMatchesVecVecDataSub.assign(jetsSub.size(), {}); + analyseSubstructureMatched(jetsSub, splittingsDataSub, pairsDataSub, preslices.D0SplittingsPerJetDataSub, preslices.DplusSplittingsPerJetDataSub, preslices.DstarSplittingsPerJetDataSub, preslices.LcSplittingsPerJetDataSub, preslices.B0SplittingsPerJetDataSub, preslices.BplusSplittingsPerJetDataSub, preslices.DielectronSplittingsPerJetDataSub, preslices.D0PairsPerJetDataSub, preslices.DplusPairsPerJetDataSub, preslices.DstarPairsPerJetDataSub, preslices.LcPairsPerJetDataSub, preslices.B0PairsPerJetDataSub, preslices.BplusPairsPerJetDataSub, preslices.DielectronPairsPerJetDataSub, splittingMatchesGeoVecVecDataSub, splittingMatchesPtVecVecDataSub, splittingMatchesHFVecVecDataSub, pairMatchesVecVecDataSub, configs.jetPtMinDataSub); + } + PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputSubstructureMatchingData, "jet substructure matching output Data", false); + void processOutputJetsData(aod::JetCollision const& collision, JetTableData const& jets, - CandidateTable const& candidates) + soa::Join const& candidates) { - analyseCharged(collision, jets, candidates, collisionOutputTableData, jetOutputTableData, jetSubstructureOutputTableData, jetMappingData, candidateMapping, jetPtMinData, 1.0); + analyseCharged(collision, jets, candidates, products.collisionOutputTableData, products.jetOutputTableData, products.jetSubstructureOutputTableData, splittingMatchesGeoVecVecData, splittingMatchesPtVecVecData, splittingMatchesHFVecVecData, pairMatchesVecVecData, jetMappingData, candidateMapping, configs.jetPtMinData, 1.0); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetsData, "hf jet substructure output Data", false); void processOutputJetsDataSub(aod::JetCollision const& collision, JetTableDataSub const& jets, - CandidateTable const& candidates) + soa::Join const& candidates) { - analyseCharged(collision, jets, candidates, collisionOutputTableDataSub, jetOutputTableDataSub, jetSubstructureOutputTableDataSub, jetMappingDataSub, candidateMapping, jetPtMinDataSub, 1.0); + analyseCharged(collision, jets, candidates, products.collisionOutputTableDataSub, products.jetOutputTableDataSub, products.jetSubstructureOutputTableDataSub, splittingMatchesGeoVecVecDataSub, splittingMatchesPtVecVecDataSub, splittingMatchesHFVecVecDataSub, pairMatchesVecVecDataSub, jetMappingDataSub, candidateMapping, configs.jetPtMinDataSub, 1.0); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetsDataSub, "hf jet substructure output event-wise subtracted Data", false); - void processOutputMatchingData(JetMatchedTableData const& jets, - JetTableDataSub const& jetsSub) + void processOutputJetMatchingData(JetMatchedTableData const& jets, + JetTableDataSub const& jetsSub) + { + analyseJetMatched(jets, jetMappingData, jetMappingDataSub, products.jetMatchingOutputTableData, configs.jetPtMinData); + analyseJetMatched(jetsSub, jetMappingDataSub, jetMappingData, products.jetMatchingOutputTableDataSub, configs.jetPtMinDataSub); + } + PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetMatchingData, "jet matching output Data", false); + + void processOutputSubstructureMatchingMC(JetTableMCD const& jetsMCD, + JetTableMatchedMCP const& jetsMCP, + CandidateTableMCD const&, + CandidateTableMCP const&, + SplittingTableMCD const& splittingsMCD, + SplittingTableMCP const& splittingsMCP, + PairTableMCD const& pairsMCD, + PairTableMCP const& pairsMCP) { - analyseMatched(jets, jetsSub, jetMappingData, jetMappingDataSub, jetMatchingOutputTableData, jetPtMinData); - analyseMatched(jetsSub, jets, jetMappingDataSub, jetMappingData, jetMatchingOutputTableDataSub, jetPtMinDataSub); + splittingMatchesGeoVecVecMCD.assign(jetsMCD.size(), {}); + splittingMatchesPtVecVecMCD.assign(jetsMCD.size(), {}); + splittingMatchesHFVecVecMCD.assign(jetsMCD.size(), {}); + pairMatchesVecVecMCD.assign(jetsMCD.size(), {}); + analyseSubstructureMatched(jetsMCD, splittingsMCD, pairsMCD, preslices.D0SplittingsPerJetMCD, preslices.DplusSplittingsPerJetMCD, preslices.DstarSplittingsPerJetMCD, preslices.LcSplittingsPerJetMCD, preslices.B0SplittingsPerJetMCD, preslices.BplusSplittingsPerJetMCD, preslices.DielectronSplittingsPerJetMCD, preslices.D0PairsPerJetMCD, preslices.DplusPairsPerJetMCD, preslices.DstarPairsPerJetMCD, preslices.LcPairsPerJetMCD, preslices.B0PairsPerJetMCD, preslices.BplusPairsPerJetMCD, preslices.DielectronPairsPerJetMCD, splittingMatchesGeoVecVecMCD, splittingMatchesPtVecVecMCD, splittingMatchesHFVecVecMCD, pairMatchesVecVecMCD, configs.jetPtMinMCD); + splittingMatchesGeoVecVecMCP.assign(jetsMCP.size(), {}); + splittingMatchesPtVecVecMCP.assign(jetsMCP.size(), {}); + splittingMatchesHFVecVecMCP.assign(jetsMCP.size(), {}); + pairMatchesVecVecMCP.assign(jetsMCP.size(), {}); + analyseSubstructureMatched(jetsMCP, splittingsMCP, pairsMCP, preslices.D0SplittingsPerJetMCP, preslices.DplusSplittingsPerJetMCP, preslices.DstarSplittingsPerJetMCP, preslices.LcSplittingsPerJetMCP, preslices.B0SplittingsPerJetMCP, preslices.BplusSplittingsPerJetMCP, preslices.DielectronSplittingsPerJetMCP, preslices.D0PairsPerJetMCP, preslices.DplusPairsPerJetMCP, preslices.DstarPairsPerJetMCP, preslices.LcPairsPerJetMCP, preslices.B0PairsPerJetMCP, preslices.BplusPairsPerJetMCP, preslices.DielectronPairsPerJetMCP, splittingMatchesGeoVecVecMCP, splittingMatchesPtVecVecMCP, splittingMatchesHFVecVecMCP, pairMatchesVecVecMCP, configs.jetPtMinMCP); } - PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputMatchingData, "jet matching output Data", false); + PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputSubstructureMatchingMC, "jet substructure matching output MC", false); void processOutputJetsMCD(aod::JetCollisionMCD const& collision, - aod::JetMcCollisions const&, JetTableMCD const& jets, - CandidateTableMCD const& candidates) + soa::Join const& candidates) { - analyseCharged(collision, jets, candidates, collisionOutputTableMCD, jetOutputTableMCD, jetSubstructureOutputTableMCD, jetMappingMCD, candidateMapping, jetPtMinMCD, collision.mcCollision().weight()); + analyseCharged(collision, jets, candidates, products.collisionOutputTableMCD, products.jetOutputTableMCD, products.jetSubstructureOutputTableMCD, splittingMatchesGeoVecVecMCD, splittingMatchesPtVecVecMCD, splittingMatchesHFVecVecMCD, pairMatchesVecVecMCD, jetMappingMCD, candidateMapping, configs.jetPtMinMCD, collision.weight()); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetsMCD, "hf jet substructure output MCD", false); void processOutputJetsMCP(aod::JetMcCollision const& collision, JetTableMCP const& jets, - CandidateTableMCP const& candidates) + soa::Join const& candidates) { - analyseCharged(collision, jets, candidates, collisionOutputTableMCP, jetOutputTableMCP, jetSubstructureOutputTableMCP, jetMappingMCP, candidateMappingMCP, jetPtMinMCP, collision.weight()); + analyseCharged(collision, jets, candidates, products.collisionOutputTableMCP, products.jetOutputTableMCP, products.jetSubstructureOutputTableMCP, splittingMatchesGeoVecVecMCP, splittingMatchesPtVecVecMCP, splittingMatchesHFVecVecMCP, pairMatchesVecVecMCP, jetMappingMCP, candidateMappingMCP, configs.jetPtMinMCP, collision.weight()); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetsMCP, "hf jet substructure output MCP", false); - void processOutputMatchingMC(JetTableMCD const& jetsMCD, - JetTableMCP const& jetsMCP) + void processOutputJetMatchingMC(JetTableMCD const& jetsMCD, + JetTableMatchedMCP const& jetsMCP) { - analyseMatched(jetsMCD, jetsMCP, jetMappingMCD, jetMappingMCP, jetMatchingOutputTableMCD, jetPtMinMCD); - analyseMatched(jetsMCP, jetsMCD, jetMappingMCP, jetMappingMCD, jetMatchingOutputTableMCP, jetPtMinMCP); + analyseJetMatched(jetsMCD, jetMappingMCD, jetMappingMCP, products.jetMatchingOutputTableMCD, configs.jetPtMinMCD); + analyseJetMatched(jetsMCP, jetMappingMCP, jetMappingMCD, products.jetMatchingOutputTableMCP, configs.jetPtMinMCP); } - PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputMatchingMC, "jet matching output MC", false); + PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetMatchingMC, "jet matching output MC", false); }; diff --git a/PWGJE/Tasks/jetSubstructureLc.cxx b/PWGJE/Tasks/jetSubstructureLc.cxx index dc985515164..6f8260ab2c5 100644 --- a/PWGJE/Tasks/jetSubstructureLc.cxx +++ b/PWGJE/Tasks/jetSubstructureLc.cxx @@ -15,7 +15,19 @@ #include "PWGJE/Tasks/jetSubstructureHF.cxx" -using JetSubstructureLc = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesLcData, aod::CandidatesLcMCP, aod::LcCJetSSs, aod::LcCMCDJetSSs, aod::LcCMCPJetSSs, aod::LcCEWSJetSSs, aod::JTrackLcSubs>; +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureLc = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesLcData, aod::CandidatesLcMCP, aod::LcCJetSSs, aod::LcChargedSPs, aod::LcChargedPRs, aod::LcCMCDJetSSs, aod::LcChargedMCDetectorLevelSPs, aod::LcChargedMCDetectorLevelPRs, aod::LcCMCPJetSSs, aod::LcChargedMCParticleLevelSPs, aod::LcChargedMCParticleLevelPRs, aod::LcCEWSJetSSs, aod::LcChargedEventWiseSubtractedSPs, aod::LcChargedEventWiseSubtractedPRs, aod::JTrackLcSubs>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetSubstructureLcOutput.cxx b/PWGJE/Tasks/jetSubstructureLcOutput.cxx index dad7b2a52b5..e25c204b580 100644 --- a/PWGJE/Tasks/jetSubstructureLcOutput.cxx +++ b/PWGJE/Tasks/jetSubstructureLcOutput.cxx @@ -15,7 +15,21 @@ #include "PWGJE/Tasks/jetSubstructureHFOutput.cxx" -using JetSubstructureOutputLc = JetSubstructureHFOutputTask, aod::CandidatesLcData, aod::CandidatesLcMCD, aod::CandidatesLcMCP, aod::JTrackLcSubs, soa::Join, soa::Join, aod::LcCJetCOs, aod::LcCJetOs, aod::LcCJetSSOs, aod::LcCJetMOs, soa::Join, aod::LcCMCDJetCOs, aod::LcCMCDJetOs, aod::LcCMCDJetSSOs, aod::LcCMCDJetMOs, soa::Join, aod::LcCMCPJetCOs, aod::LcCMCPJetOs, aod::LcCMCPJetSSOs, aod::LcCMCPJetMOs, soa::Join, aod::LcCEWSJetCOs, aod::LcCEWSJetOs, aod::LcCEWSJetSSOs, aod::LcCEWSJetMOs, aod::StoredHfLcCollBase, aod::StoredHfLcBases, aod::StoredHfLcPars, aod::StoredHfLcParEs, aod::JDumLcParDaus, aod::StoredHfLcSels, aod::StoredHfLcMls, aod::JDumLcMlDaus, aod::StoredHfLcMcs, aod::StoredHfLcMcCollBases, aod::StoredHfLcMcRCollIds, aod::StoredHfLcPBases>; +#include "PWGHF/DataModel/DerivedTables.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedDataHF.h" +#include "PWGJE/DataModel/JetSubstructure.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include +#include +#include +#include +#include + +#include + +using JetSubstructureOutputLc = JetSubstructureHFOutputTask, aod::McCollisionsLc, aod::CandidatesLcData, aod::CandidatesLcMCD, aod::CandidatesLcMCP, aod::BkgLcRhos, aod::BkgLcMcRhos, aod::JTrackLcSubs, soa::Join, soa::Join, soa::Join, soa::Join, aod::LcCJetCOs, aod::LcCJetOs, aod::LcCJetSSOs, aod::LcCJetMOs, soa::Join, soa::Join, soa::Join, aod::LcCMCDJetCOs, aod::LcCMCDJetOs, aod::LcCMCDJetSSOs, aod::LcCMCDJetMOs, soa::Join, soa::Join, soa::Join, soa::Join, aod::LcCMCPJetCOs, aod::LcCMCPJetMCCOs, aod::LcCMCPJetOs, aod::LcCMCPJetSSOs, aod::LcCMCPJetMOs, soa::Join, soa::Join, soa::Join, aod::LcCEWSJetCOs, aod::LcCEWSJetOs, aod::LcCEWSJetSSOs, aod::LcCEWSJetMOs, aod::StoredHfLcCollBase, aod::StoredHfLcBases, aod::StoredHfLcPars, aod::StoredHfLcParEs, aod::JDumLcParDaus, aod::StoredHfLcSels, aod::StoredHfLcMls, aod::JDumLcMlDaus, aod::StoredHfLcMcs, aod::StoredHfLcMcCollBases, aod::StoredHfLcMcRCollIds, aod::StoredHfLcPBases>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetSubstructureOutput.cxx b/PWGJE/Tasks/jetSubstructureOutput.cxx index 695afef9e35..39f1e1518cd 100644 --- a/PWGJE/Tasks/jetSubstructureOutput.cxx +++ b/PWGJE/Tasks/jetSubstructureOutput.cxx @@ -14,30 +14,31 @@ /// \author Nima Zardoshti // -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "TDatabasePDG.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/CCDB/EventSelectionParams.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGJE/Core/JetFinder.h" #include "PWGJE/Core/JetFindingUtilities.h" #include "PWGJE/DataModel/Jet.h" #include "PWGJE/DataModel/JetSubstructure.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; // NB: runDataProcessing.h must be included after customize! -#include "Framework/runDataProcessing.h" struct JetSubstructureOutputTask { @@ -57,6 +58,7 @@ struct JetSubstructureOutputTask { Produces jetOutputTableMCP; Produces jetSubstructureOutputTableMCP; Produces jetMatchingOutputTableMCP; + Produces mcCollisionOutputTable; Configurable jetPtMinData{"jetPtMinData", 0.0, "minimum jet pT cut for data jets"}; Configurable jetPtMinDataSub{"jetPtMinDataSub", 0.0, "minimum jet pT cut for eventwise constituent subtracted data jets"}; @@ -74,6 +76,24 @@ struct JetSubstructureOutputTask { std::map jetMappingMCD; std::map jetMappingMCP; + std::vector> splittingMatchesGeoVecVecData; + std::vector> splittingMatchesPtVecVecData; + std::vector> splittingMatchesHFVecVecData; + std::vector> splittingMatchesGeoVecVecDataSub; + std::vector> splittingMatchesPtVecVecDataSub; + std::vector> splittingMatchesHFVecVecDataSub; + std::vector> splittingMatchesGeoVecVecMCD; + std::vector> splittingMatchesPtVecVecMCD; + std::vector> splittingMatchesHFVecVecMCD; + std::vector> splittingMatchesGeoVecVecMCP; + std::vector> splittingMatchesPtVecVecMCP; + std::vector> splittingMatchesHFVecVecMCP; + + std::vector> pairMatchesVecVecData; + std::vector> pairMatchesVecVecDataSub; + std::vector> pairMatchesVecVecMCD; + std::vector> pairMatchesVecVecMCP; + std::vector jetRadiiValues; void init(InitContext const&) @@ -81,37 +101,109 @@ struct JetSubstructureOutputTask { jetRadiiValues = (std::vector)jetRadii; } + Preslice> splittingsPerJetData = aod::chargedsplitting::jetId; + Preslice> splittingsPerJetDataSub = aod::chargedeventwisesubtractedsplitting::jetId; + Preslice> splittingsPerJetMCD = aod::chargedmcdetectorlevelsplitting::jetId; + Preslice> splittingsPerJetMCP = aod::chargedmcparticlelevelsplitting::jetId; + + Preslice> pairsPerJetData = aod::chargedpair::jetId; + Preslice> pairsPerJetDataSub = aod::chargedeventwisesubtractedpair::jetId; + Preslice> pairsPerJetMCD = aod::chargedmcdetectorlevelpair::jetId; + Preslice> pairsPerJetMCP = aod::chargedmcparticlelevelpair::jetId; + + template + void fillSplittingMatchingVectors(T const& splittingsMatches, int jetIndex, std::vector>& splittingMatchesGeoVecVec, std::vector>& splittingMatchesPtVecVec, std::vector>& splittingMatchesHFVecVec) + { + for (auto const& splittingMatches : splittingsMatches) { + auto splittingMatchesGeoSpan = splittingMatches.splittingMatchingGeo(); + auto splittingMatchesPtSpan = splittingMatches.splittingMatchingPt(); + auto splittingMatchesHFSpan = splittingMatches.splittingMatchingHF(); + std::copy(splittingMatchesGeoSpan.begin(), splittingMatchesGeoSpan.end(), std::back_inserter(splittingMatchesGeoVecVec[jetIndex])); + std::copy(splittingMatchesPtSpan.begin(), splittingMatchesPtSpan.end(), std::back_inserter(splittingMatchesPtVecVec[jetIndex])); + std::copy(splittingMatchesHFSpan.begin(), splittingMatchesHFSpan.end(), std::back_inserter(splittingMatchesHFVecVec[jetIndex])); + } + } + + template + void fillPairMatchingVectors(T const& pairsMatches, int jetIndex, std::vector>& pairMatchesVecVec) + { + for (auto const& pairMatches : pairsMatches) { + auto pairMatchesSpan = pairMatches.pairMatching(); + std::copy(pairMatchesSpan.begin(), pairMatchesSpan.end(), std::back_inserter(pairMatchesVecVec[jetIndex])); + } + } + template - void fillJetTables(T const& jet, int32_t collisionIndex, U& jetOutputTable, V& jetSubstructureOutputTable, std::map& jetMapping) + void fillJetTables(T const& jet, int32_t collisionIndex, U& jetOutputTable, V& jetSubstructureOutputTable, std::vector>& splittingMatchesGeoVecVec, std::vector>& splittingMatchesPtVecVec, std::vector>& splittingMatchesHFVecVec, std::vector>& pairMatchesVecVec, float rho, std::map& jetMapping) { std::vector energyMotherVec; std::vector ptLeadingVec; std::vector ptSubLeadingVec; std::vector thetaVec; - std::vector pairPtVec; - std::vector pairEnergyVec; - std::vector pairThetaVec; + std::vector pairJetPtVec; + std::vector pairJetEnergyVec; + std::vector pairJetThetaVec; + std::vector pairJetPerpCone1PtVec; + std::vector pairJetPerpCone1EnergyVec; + std::vector pairJetPerpCone1ThetaVec; + std::vector pairPerpCone1PerpCone1PtVec; + std::vector pairPerpCone1PerpCone1EnergyVec; + std::vector pairPerpCone1PerpCone1ThetaVec; + std::vector pairPerpCone1PerpCone2PtVec; + std::vector pairPerpCone1PerpCone2EnergyVec; + std::vector pairPerpCone1PerpCone2ThetaVec; + auto energyMotherSpan = jet.energyMother(); auto ptLeadingSpan = jet.ptLeading(); auto ptSubLeadingSpan = jet.ptSubLeading(); auto thetaSpan = jet.theta(); - auto pairPtSpan = jet.pairPt(); - auto pairEnergySpan = jet.pairEnergy(); - auto pairThetaSpan = jet.pairTheta(); + auto pairJetPtSpan = jet.pairJetPt(); + auto pairJetEnergySpan = jet.pairJetEnergy(); + auto pairJetThetaSpan = jet.pairJetTheta(); + auto pairJetPerpCone1PtSpan = jet.pairJetPerpCone1Pt(); + auto pairJetPerpCone1EnergySpan = jet.pairJetPerpCone1Energy(); + auto pairJetPerpCone1ThetaSpan = jet.pairJetPerpCone1Theta(); + auto pairPerpCone1PerpCone1PtSpan = jet.pairPerpCone1PerpCone1Pt(); + auto pairPerpCone1PerpCone1EnergySpan = jet.pairPerpCone1PerpCone1Energy(); + auto pairPerpCone1PerpCone1ThetaSpan = jet.pairPerpCone1PerpCone1Theta(); + auto pairPerpCone1PerpCone2PtSpan = jet.pairPerpCone1PerpCone2Pt(); + auto pairPerpCone1PerpCone2EnergySpan = jet.pairPerpCone1PerpCone2Energy(); + auto pairPerpCone1PerpCone2ThetaSpan = jet.pairPerpCone1PerpCone2Theta(); + std::copy(energyMotherSpan.begin(), energyMotherSpan.end(), std::back_inserter(energyMotherVec)); std::copy(ptLeadingSpan.begin(), ptLeadingSpan.end(), std::back_inserter(ptLeadingVec)); std::copy(ptSubLeadingSpan.begin(), ptSubLeadingSpan.end(), std::back_inserter(ptSubLeadingVec)); std::copy(thetaSpan.begin(), thetaSpan.end(), std::back_inserter(thetaVec)); - std::copy(pairPtSpan.begin(), pairPtSpan.end(), std::back_inserter(pairPtVec)); - std::copy(pairEnergySpan.begin(), pairEnergySpan.end(), std::back_inserter(pairEnergyVec)); - std::copy(pairThetaSpan.begin(), pairThetaSpan.end(), std::back_inserter(pairThetaVec)); - jetOutputTable(collisionIndex, collisionIndex, jet.pt(), jet.phi(), jet.eta(), jet.y(), jet.r(), jet.tracksIds().size()); // second collision index is a dummy coloumn mirroring the hf candidate - jetSubstructureOutputTable(jetOutputTable.lastIndex(), energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, jet.nSub2DR(), jet.nSub1(), jet.nSub2(), pairPtVec, pairEnergyVec, pairThetaVec, jet.angularity()); + std::copy(pairJetPtSpan.begin(), pairJetPtSpan.end(), std::back_inserter(pairJetPtVec)); + std::copy(pairJetEnergySpan.begin(), pairJetEnergySpan.end(), std::back_inserter(pairJetEnergyVec)); + std::copy(pairJetThetaSpan.begin(), pairJetThetaSpan.end(), std::back_inserter(pairJetThetaVec)); + std::copy(pairJetPerpCone1PtSpan.begin(), pairJetPerpCone1PtSpan.end(), std::back_inserter(pairJetPerpCone1PtVec)); + std::copy(pairJetPerpCone1EnergySpan.begin(), pairJetPerpCone1EnergySpan.end(), std::back_inserter(pairJetPerpCone1EnergyVec)); + std::copy(pairJetPerpCone1ThetaSpan.begin(), pairJetPerpCone1ThetaSpan.end(), std::back_inserter(pairJetPerpCone1ThetaVec)); + std::copy(pairPerpCone1PerpCone1PtSpan.begin(), pairPerpCone1PerpCone1PtSpan.end(), std::back_inserter(pairPerpCone1PerpCone1PtVec)); + std::copy(pairPerpCone1PerpCone1EnergySpan.begin(), pairPerpCone1PerpCone1EnergySpan.end(), std::back_inserter(pairPerpCone1PerpCone1EnergyVec)); + std::copy(pairPerpCone1PerpCone1ThetaSpan.begin(), pairPerpCone1PerpCone1ThetaSpan.end(), std::back_inserter(pairPerpCone1PerpCone1ThetaVec)); + std::copy(pairPerpCone1PerpCone2PtSpan.begin(), pairPerpCone1PerpCone2PtSpan.end(), std::back_inserter(pairPerpCone1PerpCone2PtVec)); + std::copy(pairPerpCone1PerpCone2EnergySpan.begin(), pairPerpCone1PerpCone2EnergySpan.end(), std::back_inserter(pairPerpCone1PerpCone2EnergyVec)); + std::copy(pairPerpCone1PerpCone2ThetaSpan.begin(), pairPerpCone1PerpCone2ThetaSpan.end(), std::back_inserter(pairPerpCone1PerpCone2ThetaVec)); + + std::vector splittingMatchesGeoVec; + std::vector splittingMatchesPtVec; + std::vector splittingMatchesHFVec; + std::vector pairMatchesVec; + if (doprocessOutputSubstructureMatchingData || doprocessOutputSubstructureMatchingMC) { + splittingMatchesGeoVec = splittingMatchesGeoVecVec[jet.globalIndex()]; + splittingMatchesPtVec = splittingMatchesPtVecVec[jet.globalIndex()]; + splittingMatchesHFVec = splittingMatchesHFVecVec[jet.globalIndex()]; + pairMatchesVec = pairMatchesVecVec[jet.globalIndex()]; + } + jetOutputTable(collisionIndex, collisionIndex, jet.pt(), jet.phi(), jet.eta(), jet.y(), jet.r(), jet.area(), rho, jet.perpConeRho(), jet.tracksIds().size()); // second collision index is a dummy coloumn mirroring the hf candidate + jetSubstructureOutputTable(jetOutputTable.lastIndex(), energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, jet.nSub2DR(), jet.nSub1(), jet.nSub2(), pairJetPtVec, pairJetEnergyVec, pairJetThetaVec, pairJetPerpCone1PtVec, pairJetPerpCone1EnergyVec, pairJetPerpCone1ThetaVec, pairPerpCone1PerpCone1PtVec, pairPerpCone1PerpCone1EnergyVec, pairPerpCone1PerpCone1ThetaVec, pairPerpCone1PerpCone2PtVec, pairPerpCone1PerpCone2EnergyVec, pairPerpCone1PerpCone2ThetaVec, jet.angularity(), jet.ptLeadingConstituent(), splittingMatchesGeoVec, splittingMatchesPtVec, splittingMatchesHFVec, pairMatchesVec); jetMapping.insert(std::make_pair(jet.globalIndex(), jetOutputTable.lastIndex())); } - template - void analyseCharged(T const& collision, U const& jets, V& collisionOutputTable, M& jetOutputTable, N& jetSubstructureOutputTable, std::map& jetMapping, float jetPtMin, float eventWeight) + template + void analyseCharged(T const& collision, U const& jets, V& collisionOutputTable, M& jetOutputTable, N& jetSubstructureOutputTable, std::vector>& splittingMatchesGeoVecVec, std::vector>& splittingMatchesPtVecVec, std::vector>& splittingMatchesHFVecVec, std::vector>& pairMatchesVecVec, std::map& jetMapping, float jetPtMin, float eventWeight) { int nJetInCollision = 0; int32_t collisionIndex = -1; @@ -124,21 +216,48 @@ struct JetSubstructureOutputTask { } for (const auto& jetRadiiValue : jetRadiiValues) { if (jet.r() == round(jetRadiiValue * 100.0f)) { - if constexpr (!isMc) { - if (nJetInCollision == 0) { - collisionOutputTable(collision.posZ(), collision.centrality(), collision.eventSel(), eventWeight); - collisionIndex = collisionOutputTable.lastIndex(); + if (nJetInCollision == 0) { + float centrality = -1.0; + uint8_t eventSel = 0.0; + if constexpr (!isMCP) { + centrality = collision.centFT0M(); + eventSel = collision.eventSel(); } - nJetInCollision++; + collisionOutputTable(collision.posZ(), centrality, eventSel, eventWeight); + collisionIndex = collisionOutputTable.lastIndex(); } - fillJetTables(jet, collisionIndex, jetOutputTable, jetSubstructureOutputTable, jetMapping); + nJetInCollision++; + fillJetTables(jet, collisionIndex, jetOutputTable, jetSubstructureOutputTable, splittingMatchesGeoVecVec, splittingMatchesPtVecVec, splittingMatchesHFVecVec, pairMatchesVecVec, collision.rho(), jetMapping); } } } } - template - void analyseMatched(T const& jets, U const& /*jetsTag*/, std::map& jetMapping, std::map& jetTagMapping, V& matchingOutputTable, float jetPtMin) + template + void analyseSubstructureMatched(T const& jets, U const& allSplittings, V const& allPairs, M const& splittingsSlicer, N const& pairsSlicer, std::vector>& splittingMatchesGeoVecVec, std::vector>& splittingMatchesPtVecVec, std::vector>& splittingMatchesHFVecVec, std::vector>& pairMatchesVecVec, float jetPtMin) + { + for (const auto& jet : jets) { + if (jet.pt() < jetPtMin) { + continue; + } + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + for (const auto& jetRadiiValue : jetRadiiValues) { + if (jet.r() == round(jetRadiiValue * 100.0f)) { + + auto splittings = allSplittings.sliceBy(splittingsSlicer, jet.globalIndex()); + fillSplittingMatchingVectors(splittings, jet.globalIndex(), splittingMatchesGeoVecVec, splittingMatchesPtVecVec, splittingMatchesHFVecVec); + + auto pairs = allPairs.sliceBy(pairsSlicer, jet.globalIndex()); + fillPairMatchingVectors(pairs, jet.globalIndex(), pairMatchesVecVec); + } + } + } + } + + template + void analyseJetMatched(T const& jets, std::map& jetMapping, std::map& jetTagMapping, U& matchingOutputTable, float jetPtMin) { std::vector candMatching; for (const auto& jet : jets) { @@ -184,53 +303,101 @@ struct JetSubstructureOutputTask { jetMappingData.clear(); jetMappingDataSub.clear(); jetMappingMCD.clear(); + } + PROCESS_SWITCH(JetSubstructureOutputTask, processClearMaps, "process function that clears all the non-mcp maps in each dataframe", true); + + void processClearMapsMCP(aod::JetMcCollisions const& mcCollisions) + { jetMappingMCP.clear(); + for (auto mcCollision : mcCollisions) { + mcCollisionOutputTable(mcCollision.posZ(), mcCollision.accepted(), mcCollision.attempted(), mcCollision.xsectGen(), mcCollision.xsectErr(), mcCollision.weight()); + } } - PROCESS_SWITCH(JetSubstructureOutputTask, processClearMaps, "process function that clears all the maps in each dataframe", true); + PROCESS_SWITCH(JetSubstructureOutputTask, processClearMapsMCP, "process function that clears all the mcp maps in each dataframe", true); - void processOutputData(aod::JetCollision const& collision, + void processOutputSubstructureMatchingData(soa::Join const& jets, + soa::Join const& jetsSub, + soa::Join const& splittingsData, + soa::Join const& splittingsDataSub, + soa::Join const& pairsData, + soa::Join const& pairsDataSub) + { + splittingMatchesGeoVecVecData.assign(jets.size(), {}); + splittingMatchesPtVecVecData.assign(jets.size(), {}); + splittingMatchesHFVecVecData.assign(jets.size(), {}); + pairMatchesVecVecData.assign(jets.size(), {}); + analyseSubstructureMatched(jets, splittingsData, pairsData, splittingsPerJetData, pairsPerJetData, splittingMatchesGeoVecVecData, splittingMatchesPtVecVecData, splittingMatchesHFVecVecData, pairMatchesVecVecData, jetPtMinData); + splittingMatchesGeoVecVecDataSub.assign(jetsSub.size(), {}); + splittingMatchesPtVecVecDataSub.assign(jetsSub.size(), {}); + splittingMatchesHFVecVecDataSub.assign(jetsSub.size(), {}); + pairMatchesVecVecDataSub.assign(jetsSub.size(), {}); + analyseSubstructureMatched(jetsSub, splittingsDataSub, pairsDataSub, splittingsPerJetDataSub, pairsPerJetDataSub, splittingMatchesGeoVecVecDataSub, splittingMatchesPtVecVecDataSub, splittingMatchesHFVecVecDataSub, pairMatchesVecVecDataSub, jetPtMinDataSub); + } + PROCESS_SWITCH(JetSubstructureOutputTask, processOutputSubstructureMatchingData, "substructure matching output Data", false); + + void processOutputData(soa::Join::iterator const& collision, soa::Join const& jets) { - analyseCharged(collision, jets, collisionOutputTableData, jetOutputTableData, jetSubstructureOutputTableData, jetMappingData, jetPtMinData, 1.0); + analyseCharged(collision, jets, collisionOutputTableData, jetOutputTableData, jetSubstructureOutputTableData, splittingMatchesGeoVecVecData, splittingMatchesPtVecVecData, splittingMatchesHFVecVecData, pairMatchesVecVecData, jetMappingData, jetPtMinData, 1.0); } PROCESS_SWITCH(JetSubstructureOutputTask, processOutputData, "jet substructure output Data", false); - void processOutputDataSub(aod::JetCollision const& collision, + void processOutputDataSub(soa::Join::iterator const& collision, soa::Join const& jets) { - analyseCharged(collision, jets, collisionOutputTableDataSub, jetOutputTableDataSub, jetSubstructureOutputTableDataSub, jetMappingDataSub, jetPtMinDataSub, 1.0); + analyseCharged(collision, jets, collisionOutputTableDataSub, jetOutputTableDataSub, jetSubstructureOutputTableDataSub, splittingMatchesGeoVecVecDataSub, splittingMatchesPtVecVecDataSub, splittingMatchesHFVecVecDataSub, pairMatchesVecVecDataSub, jetMappingDataSub, jetPtMinDataSub, 1.0); } PROCESS_SWITCH(JetSubstructureOutputTask, processOutputDataSub, "jet substructure output event-wise subtracted Data", false); - void processOutputMatchingData(soa::Join const& jets, - soa::Join const& jetsSub) + void processOutputJetMatchingData(soa::Join const& jets, + soa::Join const& jetsSub) + { + analyseJetMatched(jets, jetMappingData, jetMappingDataSub, jetMatchingOutputTableData, jetPtMinData); + analyseJetMatched(jetsSub, jetMappingDataSub, jetMappingData, jetMatchingOutputTableDataSub, jetPtMinDataSub); + } + PROCESS_SWITCH(JetSubstructureOutputTask, processOutputJetMatchingData, "jet matching output Data", false); + + void processOutputSubstructureMatchingMC(soa::Join const& jetsMCD, + soa::Join const& jetsMCP, + soa::Join const& splittingsMCD, + soa::Join const& splittingsMCP, + soa::Join const& pairsMCD, + soa::Join const& pairsMCP) { - analyseMatched(jets, jetsSub, jetMappingData, jetMappingDataSub, jetMatchingOutputTableData, jetPtMinData); - analyseMatched(jetsSub, jets, jetMappingDataSub, jetMappingData, jetMatchingOutputTableDataSub, jetPtMinDataSub); + splittingMatchesGeoVecVecMCD.assign(jetsMCD.size(), {}); + splittingMatchesPtVecVecMCD.assign(jetsMCD.size(), {}); + splittingMatchesHFVecVecMCD.assign(jetsMCD.size(), {}); + pairMatchesVecVecMCD.assign(jetsMCD.size(), {}); + analyseSubstructureMatched(jetsMCD, splittingsMCD, pairsMCD, splittingsPerJetMCD, pairsPerJetMCD, splittingMatchesGeoVecVecMCD, splittingMatchesPtVecVecMCD, splittingMatchesHFVecVecMCD, pairMatchesVecVecMCD, jetPtMinMCD); + splittingMatchesGeoVecVecMCP.assign(jetsMCP.size(), {}); + splittingMatchesPtVecVecMCP.assign(jetsMCP.size(), {}); + splittingMatchesHFVecVecMCP.assign(jetsMCP.size(), {}); + pairMatchesVecVecMCP.assign(jetsMCP.size(), {}); + analyseSubstructureMatched(jetsMCP, splittingsMCP, pairsMCP, splittingsPerJetMCP, pairsPerJetMCP, splittingMatchesGeoVecVecMCP, splittingMatchesPtVecVecMCP, splittingMatchesHFVecVecMCP, pairMatchesVecVecMCP, jetPtMinMCP); } - PROCESS_SWITCH(JetSubstructureOutputTask, processOutputMatchingData, "jet matching output Data", false); + PROCESS_SWITCH(JetSubstructureOutputTask, processOutputSubstructureMatchingMC, "substructure matching output MC", false); - void processOutputMCD(aod::JetCollisionMCD const& collision, aod::JetMcCollisions const&, + void processOutputMCD(soa::Join::iterator const& collision, soa::Join const& jets) { - analyseCharged(collision, jets, collisionOutputTableMCD, jetOutputTableMCD, jetSubstructureOutputTableMCD, jetMappingMCD, jetPtMinMCD, collision.mcCollision().weight()); + analyseCharged(collision, jets, collisionOutputTableMCD, jetOutputTableMCD, jetSubstructureOutputTableMCD, splittingMatchesGeoVecVecMCD, splittingMatchesPtVecVecMCD, splittingMatchesHFVecVecMCD, pairMatchesVecVecMCD, jetMappingMCD, jetPtMinMCD, collision.weight()); } PROCESS_SWITCH(JetSubstructureOutputTask, processOutputMCD, "jet substructure output MCD", false); - void processOutputMCP(aod::JetMcCollision const& collision, + void processOutputMCP(soa::Join::iterator const& collision, soa::Join const& jets) { - analyseCharged(collision, jets, collisionOutputTableMCP, jetOutputTableMCP, jetSubstructureOutputTableMCP, jetMappingMCP, jetPtMinMCP, collision.weight()); + analyseCharged(collision, jets, collisionOutputTableMCP, jetOutputTableMCP, jetSubstructureOutputTableMCP, splittingMatchesGeoVecVecMCP, splittingMatchesPtVecVecMCP, splittingMatchesHFVecVecMCP, pairMatchesVecVecMCP, jetMappingMCP, jetPtMinMCP, collision.weight()); } PROCESS_SWITCH(JetSubstructureOutputTask, processOutputMCP, "jet substructure output MCP", false); - void processOutputMatchingMC(soa::Join const& jetsMCD, - soa::Join const& jetsMCP) + void processOutputJetMatchingMC(soa::Join const& jetsMCD, + soa::Join const& jetsMCP) { - analyseMatched(jetsMCD, jetsMCP, jetMappingMCD, jetMappingMCP, jetMatchingOutputTableMCD, jetPtMinMCD); - analyseMatched(jetsMCP, jetsMCD, jetMappingMCP, jetMappingMCD, jetMatchingOutputTableMCP, jetPtMinMCP); + analyseJetMatched(jetsMCD, jetMappingMCD, jetMappingMCP, jetMatchingOutputTableMCD, jetPtMinMCD); + analyseJetMatched(jetsMCP, jetMappingMCP, jetMappingMCD, jetMatchingOutputTableMCP, jetPtMinMCP); } - PROCESS_SWITCH(JetSubstructureOutputTask, processOutputMatchingMC, "jet matching output MC", false); + PROCESS_SWITCH(JetSubstructureOutputTask, processOutputJetMatchingMC, "jet matching output MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/Tasks/jetTaggerHFQA.cxx b/PWGJE/Tasks/jetTaggerHFQA.cxx index d3bc15e3d5b..52a36b2c6e5 100644 --- a/PWGJE/Tasks/jetTaggerHFQA.cxx +++ b/PWGJE/Tasks/jetTaggerHFQA.cxx @@ -9,34 +9,41 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file jettaggerhfQA.cxx +/// \file jetTaggerHFQA.cxx /// \brief Jet tagging general QA /// /// \author Hanseo Park -#include "TF1.h" - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/runDataProcessing.h" -#include "Common/Core/trackUtilities.h" - -#include "PWGHF/DataModel/CandidateReconstructionTables.h" - -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetTagging.h" -#include "PWGJE/Core/JetFindingUtilities.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/Core/JetFindingUtilities.h" #include "PWGJE/Core/JetTaggingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetTagging.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -template +template struct JetTaggerHFQA { // task on/off configuration @@ -54,6 +61,7 @@ struct JetTaggerHFQA { Configurable trackPtMax{"trackPtMax", 100.0, "maximum pT acceptance for tracks"}; Configurable trackDcaXYMax{"trackDcaXYMax", 1, "minimum DCA xy acceptance for tracks [cm]"}; Configurable trackDcaZMax{"trackDcaZMax", 2, "minimum DCA z acceptance for tracks [cm]"}; + Configurable maxDeltaR{"maxDeltaR", 0.25, "maximum distance of jet axis from flavour initiating parton"}; Configurable jetEtaMin{"jetEtaMin", -99.0, "minimum jet pseudorapidity"}; Configurable jetEtaMax{"jetEtaMax", 99.0, "maximum jet pseudorapidity"}; Configurable prongChi2PCAMin{"prongChi2PCAMin", 1, "minimum Chi2 PCA of decay length of prongs"}; @@ -62,7 +70,7 @@ struct JetTaggerHFQA { Configurable prongsigmaLxyzMax{"prongsigmaLxyzMax", 100, "maximum sigma of decay length of prongs on xyz plane"}; Configurable prongIPxyMin{"prongIPxyMin", 0.008, "maximum impact paramter of prongs on xy plane"}; Configurable prongIPxyMax{"prongIPxyMax", 1, "minimum impact parmeter of prongs on xy plane"}; - Configurable svDispersionMax{"svDispersionMax", 1, "maximum dispersion of sv"}; + Configurable svDispersionMax{"svDispersionMax", 0.03f, "maximum dispersion of sv"}; Configurable numFlavourSpecies{"numFlavourSpecies", 6, "number of jet flavour species"}; Configurable numOrder{"numOrder", 6, "number of ordering"}; Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; @@ -74,6 +82,7 @@ struct JetTaggerHFQA { Configurable checkMcCollisionIsMatched{"checkMcCollisionIsMatched", false, "0: count whole MCcollisions, 1: select MCcollisions which only have their correspond collisions"}; Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; Configurable trackOccupancyInTimeRangeMin{"trackOccupancyInTimeRangeMin", -999999, "minimum occupancy of tracks in neighbouring collisions in a given time range; only applied to reconstructed collisions (data and mcd jets), not mc collisions (mcp jets)"}; + Configurable useQuarkDef{"useQuarkDef", true, "Flag whether to use quarks or hadrons for determining the jet flavor"}; Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; @@ -81,11 +90,11 @@ struct JetTaggerHFQA { ConfigurableAxis binJetFlavour{"binJetFlavour", {6, -0.5, 5.5}, ""}; ConfigurableAxis binJetPt{"binJetPt", {200, 0., 200.}, ""}; ConfigurableAxis binEta{"binEta", {100, -1.f, 1.f}, ""}; - ConfigurableAxis binPhi{"binPhi", {18 * 8, 0.f, 2. * TMath::Pi()}, ""}; + ConfigurableAxis binPhi{"binPhi", {18 * 8, 0.f, o2::constants::math::TwoPI}, ""}; ConfigurableAxis binNtracks{"binNtracks", {100, 0., 100.}, ""}; ConfigurableAxis binTrackPt{"binTrackPt", {200, 0.f, 100.f}, ""}; ConfigurableAxis binImpactParameterXY{"binImpactParameterXY", {801, -400.5f, 400.5f}, ""}; - ConfigurableAxis binSigmaImpactParameterXY{"binImpactSigmaParameterXY", {800, 0.f, 100.f}, ""}; + ConfigurableAxis binSigmaImpactParameterXY{"binSigmaImpactParameterXY", {800, 0.f, 100.f}, ""}; ConfigurableAxis binImpactParameterXYSignificance{"binImpactParameterXYSignificance", {801, -40.5f, 40.5f}, ""}; ConfigurableAxis binImpactParameterZ{"binImpactParameterZ", {801, -400.5f, 400.5f}, ""}; ConfigurableAxis binImpactParameterZSignificance{"binImpactParameterZSignificance", {801, -40.5f, 40.5f}, ""}; @@ -104,7 +113,7 @@ struct JetTaggerHFQA { ConfigurableAxis binSigmaLxyz{"binSigmaLxyz", {100, 0., 0.1}, ""}; int numberOfJetFlavourSpecies = 6; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -113,302 +122,306 @@ struct JetTaggerHFQA { { numberOfJetFlavourSpecies = static_cast(numFlavourSpecies); - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); // Axis - AxisSpec jetFlavourAxis = {binJetFlavour, "Jet flavour"}; - AxisSpec jetPtAxis = {binJetPt, "#it{p}_{T, jet}"}; - AxisSpec etaAxis = {binEta, "#eta"}; - AxisSpec phiAxis = {binPhi, "#phi"}; - AxisSpec ntracksAxis = {binNtracks, "#it{N}_{tracks}"}; - AxisSpec trackPtAxis = {binTrackPt, "#it{p}_{T}^{track}"}; - AxisSpec impactParameterXYAxis = {binImpactParameterXY, "IP_{XY} [#mum]"}; - AxisSpec sigmaImpactParameterXYAxis = {binSigmaImpactParameterXY, "#sigma_{XY} [#mum]"}; - AxisSpec sigmaImpactParameterXYZAxis = {binSigmaImpactParameterXY, "#sigma_{XYZ} [#mum]"}; - AxisSpec impactParameterXYSignificanceAxis = {binImpactParameterXYSignificance, "IPs_{XY}"}; - AxisSpec impactParameterZAxis = {binImpactParameterZ, "IP_{Z} [#mum]"}; - AxisSpec impactParameterZSignificanceAxis = {binImpactParameterZSignificance, "IPs_{Z}"}; - AxisSpec impactParameterXYZAxis = {binImpactParameterXYZ, "IP_{XYZ} [#mum]"}; - AxisSpec impactParameterXYZSignificanceAxis = {binImpactParameterXYZSignificance, "IPs_{XYZ}"}; - AxisSpec numOrderAxis = {binNumOrder, "N_{order}"}; - AxisSpec JetProbabilityAxis = {binJetProbability, "JP"}; - AxisSpec JetProbabilityLogAxis = {binJetProbabilityLog, "-Log(JP)"}; - AxisSpec nprongsAxis = {binNprongs, "#it{N}_{SV}"}; - AxisSpec LxyAxis = {binLxy, "L_{XY} [cm]"}; - AxisSpec SxyAxis = {binSxy, "S_{XY}"}; - AxisSpec LxyzAxis = {binLxyz, "L_{XYZ} [cm]"}; - AxisSpec SxyzAxis = {binSxyz, "S_{XYZ}"}; - AxisSpec massAxis = {binMass, "#it{m}_{SV}"}; - AxisSpec sigmaLxyAxis = {binSigmaLxy, "#sigma_{L_{XY}} [cm]"}; - AxisSpec sigmaLxyzAxis = {binSigmaLxyz, "#sigma_{L_{XYZ}} [cm]"}; + AxisSpec axisJetFlavour = {binJetFlavour, "Jet flavour"}; + AxisSpec axisJetPt = {binJetPt, "#it{p}_{T, jet}"}; + AxisSpec axisEta = {binEta, "#eta"}; + AxisSpec axisPhi = {binPhi, "#phi"}; + AxisSpec axisNTracks = {binNtracks, "#it{N}_{tracks}"}; + AxisSpec axisTrackPt = {binTrackPt, "#it{p}_{T}^{track}"}; + AxisSpec axisImpactParameterXY = {binImpactParameterXY, "IP_{XY} [#mum]"}; + AxisSpec axisSigmaImpactParameterXY = {binSigmaImpactParameterXY, "#sigma_{XY} [#mum]"}; + AxisSpec axisImpactParameterXYSignificance = {binImpactParameterXYSignificance, "IPs_{XY}"}; + AxisSpec axisImpactParameterZ = {binImpactParameterZ, "IP_{Z} [#mum]"}; + AxisSpec axisImpactParameterZSignificance = {binImpactParameterZSignificance, "IPs_{Z}"}; + AxisSpec axisImpactParameterXYZ = {binImpactParameterXYZ, "IP_{XYZ} [#mum]"}; + AxisSpec axisImpactParameterXYZSignificance = {binImpactParameterXYZSignificance, "IPs_{XYZ}"}; + AxisSpec axisNumOrder = {binNumOrder, "N_{order}"}; + AxisSpec axisJetProbability = {binJetProbability, "JP"}; + AxisSpec axisJetProbabilityLog = {binJetProbabilityLog, "-Log(JP)"}; + AxisSpec axisNprongs = {binNprongs, "#it{N}_{SV}"}; + AxisSpec axisLxy = {binLxy, "L_{XY} [cm]"}; + AxisSpec axisSxy = {binSxy, "S_{XY}"}; + AxisSpec axisLxyz = {binLxyz, "L_{XYZ} [cm]"}; + AxisSpec axisSxyz = {binSxyz, "S_{XYZ}"}; + AxisSpec axisMass = {binMass, "#it{m}_{SV}"}; + AxisSpec axisSigmaLxy = {binSigmaLxy, "#sigma_{L_{XY}} [cm]"}; + AxisSpec axisSigmaLxyz = {binSigmaLxyz, "#sigma_{L_{XYZ}} [cm]"}; if (doprocessTracksDca) { - registry.add("h_impact_parameter_xy", "", {HistType::kTH1F, {{impactParameterXYAxis}}}); - registry.add("h_impact_parameter_xy_significance", "", {HistType::kTH1F, {{impactParameterXYSignificanceAxis}}}); - registry.add("h_impact_parameter_z", "", {HistType::kTH1F, {{impactParameterZAxis}}}); - registry.add("h_impact_parameter_z_significance", "", {HistType::kTH1F, {{impactParameterZSignificanceAxis}}}); - registry.add("h_impact_parameter_xyz", "", {HistType::kTH1F, {{impactParameterXYZAxis}}}); - registry.add("h_impact_parameter_xyz_significance", "", {HistType::kTH1F, {{impactParameterXYZSignificanceAxis}}}); + if (fillIPxy) { + registry.add("h_impact_parameter_xy", "", {HistType::kTH1F, {{axisImpactParameterXY}}}); + registry.add("h_impact_parameter_xy_significance", "", {HistType::kTH1F, {{axisImpactParameterXYSignificance}}}); + } + if (fillIPz) { + registry.add("h_impact_parameter_z", "", {HistType::kTH1F, {{axisImpactParameterZ}}}); + registry.add("h_impact_parameter_z_significance", "", {HistType::kTH1F, {{axisImpactParameterZSignificance}}}); + } + if (fillIPxyz) { + registry.add("h_impact_parameter_xyz", "", {HistType::kTH1F, {{axisImpactParameterXYZ}}}); + registry.add("h_impact_parameter_xyz_significance", "", {HistType::kTH1F, {{axisImpactParameterXYZSignificance}}}); + } + } + if (doprocessValFlavourDefMCD) { + registry.add("h2_flavour_dist_quark_flavour_dist_hadron", "", {HistType::kTH2F, {{axisJetFlavour}, {axisJetFlavour}}}); + registry.add("h2_flavour_const_quark_flavour_const_hadron", "", {HistType::kTH2F, {{axisJetFlavour}, {axisJetFlavour}}}); + registry.add("h2_flavour_const_hadron_flavour_dist_hadron", "", {HistType::kTH2F, {{axisJetFlavour}, {axisJetFlavour}}}); + registry.add("h2_flavour_const_quark_flavour_dist_quark", "", {HistType::kTH2F, {{axisJetFlavour}, {axisJetFlavour}}}); + } + if (doprocessValFlavourDefMCP) { + registry.add("h2_part_flavour_dist_quark_part_flavour_dist_hadron", "", {HistType::kTH2F, {{axisJetFlavour}, {axisJetFlavour}}}); + registry.add("h2_part_flavour_const_quark_part_flavour_const_hadron", "", {HistType::kTH2F, {{axisJetFlavour}, {axisJetFlavour}}}); + registry.add("h2_part_flavour_const_hadron_part_flavour_dist_hadron", "", {HistType::kTH2F, {{axisJetFlavour}, {axisJetFlavour}}}); + registry.add("h2_part_flavour_const_quark_part_flavour_dist_quark", "", {HistType::kTH2F, {{axisJetFlavour}, {axisJetFlavour}}}); } if (doprocessIPsData) { - registry.add("h3_jet_pt_track_pt_track_eta", "", {HistType::kTH3F, {{jetPtAxis}, {trackPtAxis}, {etaAxis}}}); - registry.add("h3_jet_pt_track_pt_track_phi", "", {HistType::kTH3F, {{jetPtAxis}, {trackPtAxis}, {phiAxis}}}); + registry.add("h_jet_pt", "", {HistType::kTH1F, {{axisJetPt}}}); + registry.add("h_jet_eta", "", {HistType::kTH1F, {{axisEta}}}); + registry.add("h_jet_phi", "", {HistType::kTH1F, {{axisPhi}}}); + registry.add("h3_jet_pt_track_pt_track_eta", "", {HistType::kTH3F, {{axisJetPt}, {axisTrackPt}, {axisEta}}}); + registry.add("h3_jet_pt_track_pt_track_phi", "", {HistType::kTH3F, {{axisJetPt}, {axisTrackPt}, {axisPhi}}}); if (fillIPxy) { - registry.add("h2_jet_pt_impact_parameter_xy", "", {HistType::kTH2F, {{jetPtAxis}, {impactParameterXYAxis}}}); - registry.add("h2_jet_pt_sign_impact_parameter_xy", "", {HistType::kTH2F, {{jetPtAxis}, {impactParameterXYAxis}}}); - registry.add("h2_jet_pt_impact_parameter_xy_significance", "", {HistType::kTH2F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}}}); - registry.add("h3_jet_pt_track_pt_sign_impact_parameter_xy_significance", "", {HistType::kTH3F, {{jetPtAxis}, {trackPtAxis}, {impactParameterXYSignificanceAxis}}}); + registry.add("h2_jet_pt_impact_parameter_xy", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXY}}}); + registry.add("h2_jet_pt_sign_impact_parameter_xy", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXY}}}); + registry.add("h2_jet_pt_impact_parameter_xy_significance", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h3_jet_pt_track_pt_sign_impact_parameter_xy_significance", "", {HistType::kTH3F, {{axisJetPt}, {axisTrackPt}, {axisImpactParameterXYSignificance}}}); } if (fillIPz) { - registry.add("h2_jet_pt_impact_parameter_z", "", {HistType::kTH2F, {{jetPtAxis}, {impactParameterZAxis}}}); - registry.add("h2_jet_pt_sign_impact_parameter_z", "", {HistType::kTH2F, {{jetPtAxis}, {impactParameterZAxis}}}); - registry.add("h2_jet_pt_impact_parameter_z_significance", "", {HistType::kTH2F, {{jetPtAxis}, {impactParameterZSignificanceAxis}}}); - registry.add("h3_jet_pt_track_pt_sign_impact_parameter_z_significance", "", {HistType::kTH3F, {{jetPtAxis}, {trackPtAxis}, {impactParameterZSignificanceAxis}}}); + registry.add("h2_jet_pt_impact_parameter_z", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterZ}}}); + registry.add("h2_jet_pt_sign_impact_parameter_z", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterZ}}}); + registry.add("h2_jet_pt_impact_parameter_z_significance", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterZSignificance}}}); + registry.add("h3_jet_pt_track_pt_sign_impact_parameter_z_significance", "", {HistType::kTH3F, {{axisJetPt}, {axisTrackPt}, {axisImpactParameterZSignificance}}}); } if (fillIPxyz) { - registry.add("h2_jet_pt_impact_parameter_xyz", "", {HistType::kTH2F, {{jetPtAxis}, {impactParameterXYZAxis}}}); - registry.add("h2_jet_pt_sign_impact_parameter_xyz", "", {HistType::kTH2F, {{jetPtAxis}, {impactParameterXYZAxis}}}); - registry.add("h2_jet_pt_impact_parameter_xyz_significance", "", {HistType::kTH2F, {{jetPtAxis}, {impactParameterXYZSignificanceAxis}}}); - registry.add("h3_jet_pt_track_pt_sign_impact_parameter_xyz_significance", "", {HistType::kTH3F, {{jetPtAxis}, {trackPtAxis}, {impactParameterXYZSignificanceAxis}}}); + registry.add("h2_jet_pt_impact_parameter_xyz", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYZ}}}); + registry.add("h2_jet_pt_sign_impact_parameter_xyz", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYZ}}}); + registry.add("h2_jet_pt_impact_parameter_xyz_significance", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYZSignificance}}}); + registry.add("h3_jet_pt_track_pt_sign_impact_parameter_xyz_significance", "", {HistType::kTH3F, {{axisJetPt}, {axisTrackPt}, {axisImpactParameterXYZSignificance}}}); } if (fillTrackCounting) { - registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_tc", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {numOrderAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_z_significance_tc", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterZSignificanceAxis}, {numOrderAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_tc", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYZSignificanceAxis}, {numOrderAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_xy_significance_tc", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYSignificanceAxis}, {numOrderAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_z_significance_tc", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterZSignificanceAxis}, {numOrderAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_xyz_significance_tc", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYZSignificanceAxis}, {numOrderAxis}}}); - } - } - if (doprocessIPsMCD || doprocessIPsMCDWeighted) { - registry.add("h2_jet_pt_flavour", "", {HistType::kTH2F, {{jetPtAxis}, {jetFlavourAxis}}}); - registry.add("h2_jet_eta_flavour", "", {HistType::kTH2F, {{etaAxis}, {jetFlavourAxis}}}); - registry.add("h2_jet_phi_flavour", "", {HistType::kTH2F, {{phiAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_track_pt_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {trackPtAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_track_eta_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {etaAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_track_phi_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {phiAxis}, {jetFlavourAxis}}}); + if (fillIPxy) { + registry.add("h2_jet_pt_sign_impact_parameter_xy_significance_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h2_jet_pt_sign_impact_parameter_xy_significance_N2", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h2_jet_pt_sign_impact_parameter_xy_significance_N3", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_tc", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYSignificance}, {axisNumOrder}}}); + registry.add("h3_track_pt_sign_impact_parameter_xy_significance_tc", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXYSignificance}, {axisNumOrder}}}); + } + if (fillIPz) { + registry.add("h2_jet_pt_sign_impact_parameter_z_significance_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h2_jet_pt_sign_impact_parameter_z_significance_N2", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h2_jet_pt_sign_impact_parameter_z_significance_N3", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h3_jet_pt_sign_impact_parameter_z_significance_tc", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterZSignificance}, {axisNumOrder}}}); + registry.add("h3_track_pt_sign_impact_parameter_z_significance_tc", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterZSignificance}, {axisNumOrder}}}); + } + if (fillIPxyz) { + registry.add("h2_jet_pt_sign_impact_parameter_xyz_significance_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h2_jet_pt_sign_impact_parameter_xyz_significance_N2", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h2_jet_pt_sign_impact_parameter_xyz_significance_N3", "", {HistType::kTH2F, {{axisJetPt}, {axisImpactParameterXYSignificance}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_tc", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYZSignificance}, {axisNumOrder}}}); + registry.add("h3_track_pt_sign_impact_parameter_xyz_significance_tc", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXYZSignificance}, {axisNumOrder}}}); + } + } + } + if (doprocessIPsMCD || doprocessIPsMCDWeighted || doprocessIPsMCPMCDMatched || doprocessIPsMCPMCDMatchedWeighted) { + registry.add("h2_jet_pt_flavour", "", {HistType::kTH2F, {{axisJetPt}, {axisJetFlavour}}}); + registry.add("h2_jet_eta_flavour", "", {HistType::kTH2F, {{axisEta}, {axisJetFlavour}}}); + registry.add("h2_jet_phi_flavour", "", {HistType::kTH2F, {{axisPhi}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_track_pt_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisTrackPt}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_track_eta_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisEta}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_track_phi_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisPhi}, {axisJetFlavour}}}); if (fillIPxy) { - registry.add("h3_jet_pt_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sigma_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaImpactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_impact_parameter_xy_significance_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_impact_parameter_xy_significance_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_xy_significance_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); + registry.add("h3_jet_pt_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXY}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sigma_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSigmaImpactParameterXY}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXY}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_impact_parameter_xy_significance_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYSignificance}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYSignificance}, {axisJetFlavour}}}); + registry.add("h3_track_pt_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXY}, {axisJetFlavour}}}); + registry.add("h3_track_pt_sign_impact_parameter_xy_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXY}, {axisJetFlavour}}}); + registry.add("h3_track_pt_impact_parameter_xy_significance_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXYSignificance}, {axisJetFlavour}}}); + registry.add("h3_track_pt_sign_impact_parameter_xy_significance_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXYSignificance}, {axisJetFlavour}}}); } if (fillIPz) { - registry.add("h3_jet_pt_impact_parameter_z_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterZAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_z_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterZAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_impact_parameter_z_significance_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_z_significance_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_impact_parameter_z_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterZAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_z_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterZAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_impact_parameter_z_significance_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_z_significance_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterZSignificanceAxis}, {jetFlavourAxis}}}); + registry.add("h3_jet_pt_impact_parameter_z_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterZ}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_z_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterZ}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_impact_parameter_z_significance_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterZSignificance}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_z_significance_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterZSignificance}, {axisJetFlavour}}}); + registry.add("h3_track_pt_impact_parameter_z_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterZ}, {axisJetFlavour}}}); + registry.add("h3_track_pt_sign_impact_parameter_z_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterZ}, {axisJetFlavour}}}); + registry.add("h3_track_pt_impact_parameter_z_significance_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterZSignificance}, {axisJetFlavour}}}); + registry.add("h3_track_pt_sign_impact_parameter_z_significance_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterZSignificance}, {axisJetFlavour}}}); } if (fillIPxyz) { - registry.add("h3_jet_pt_impact_parameter_xyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYZAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYZAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_impact_parameter_xyz_significance_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_impact_parameter_xyz_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYZAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_xyz_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYZAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_impact_parameter_xyz_significance_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_xyz_significance_flavour", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYZSignificanceAxis}, {jetFlavourAxis}}}); + registry.add("h3_jet_pt_impact_parameter_xyz_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYZ}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xyz_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYZ}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_impact_parameter_xyz_significance_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYZSignificance}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYZSignificance}, {axisJetFlavour}}}); + registry.add("h3_track_pt_impact_parameter_xyz_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXYZ}, {axisJetFlavour}}}); + registry.add("h3_track_pt_sign_impact_parameter_xyz_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXYZ}, {axisJetFlavour}}}); + registry.add("h3_track_pt_impact_parameter_xyz_significance_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXYZSignificance}, {axisJetFlavour}}}); + registry.add("h3_track_pt_sign_impact_parameter_xyz_significance_flavour", "", {HistType::kTH3F, {{axisTrackPt}, {axisImpactParameterXYZSignificance}, {axisJetFlavour}}}); } if (fillTrackCounting) { - registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N1", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N2", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N3", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N1", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N2", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N3", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N1", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N2", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N3", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYZSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_sign_impact_parameter_xy_significance_tc_flavour", "", {HistType::kTH3F, {{impactParameterXYSignificanceAxis}, {numOrderAxis}, {jetFlavourAxis}}}); - registry.add("h3_sign_impact_parameter_z_significance_tc_flavour", "", {HistType::kTH3F, {{impactParameterZSignificanceAxis}, {numOrderAxis}, {jetFlavourAxis}}}); - registry.add("h3_sign_impact_parameter_xyz_significance_tc_flavour", "", {HistType::kTH3F, {{impactParameterXYZSignificanceAxis}, {numOrderAxis}, {jetFlavourAxis}}}); + if (fillIPxy) { + registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N1", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYSignificance}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N2", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYSignificance}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N3", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYSignificance}, {axisJetFlavour}}}); + registry.add("h3_sign_impact_parameter_xy_significance_tc_flavour", "", {HistType::kTH3F, {{axisImpactParameterXYSignificance}, {axisNumOrder}, {axisJetFlavour}}}); + } + if (fillIPz) { + registry.add("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N1", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterZSignificance}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N2", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterZSignificance}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N3", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterZSignificance}, {axisJetFlavour}}}); + registry.add("h3_sign_impact_parameter_z_significance_tc_flavour", "", {HistType::kTH3F, {{axisImpactParameterZSignificance}, {axisNumOrder}, {axisJetFlavour}}}); + } + if (fillIPxyz) { + registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N1", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYZSignificance}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N2", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYZSignificance}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N3", "", {HistType::kTH3F, {{axisJetPt}, {axisImpactParameterXYZSignificance}, {axisJetFlavour}}}); + registry.add("h3_sign_impact_parameter_xyz_significance_tc_flavour", "", {HistType::kTH3F, {{axisImpactParameterXYZSignificance}, {axisNumOrder}, {axisJetFlavour}}}); + } } } if (doprocessIPsMCP || doprocessIPsMCPWeighted) { - registry.add("h2_jet_pt_part_flavour", "", {HistType::kTH2F, {{jetPtAxis}, {jetFlavourAxis}}}); - registry.add("h2_jet_eta_part_flavour", "", {HistType::kTH2F, {{etaAxis}, {jetFlavourAxis}}}); - registry.add("h2_jet_phi_part_flavour", "", {HistType::kTH2F, {{phiAxis}, {jetFlavourAxis}}}); + registry.add("h2_jet_pt_part_flavour", "", {HistType::kTH2F, {{axisJetPt}, {axisJetFlavour}}}); + registry.add("h2_jet_eta_part_flavour", "", {HistType::kTH2F, {{axisEta}, {axisJetFlavour}}}); + registry.add("h2_jet_phi_part_flavour", "", {HistType::kTH2F, {{axisPhi}, {axisJetFlavour}}}); } - if (doprocessIPsMCPMCDMatched || doprocessIPsMCPMCDMatchedWeighted) { - registry.add("h3_jet_pt_jet_pt_part_matchedgeo_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {jetPtAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_jet_pt_part_matchedgeo_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {jetPtAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_flavour_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {jetFlavourAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_eta_flavour_flavour_run2", "", {HistType::kTH3F, {{etaAxis}, {jetFlavourAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_phi_flavour_flavour_run2", "", {HistType::kTH3F, {{phiAxis}, {jetFlavourAxis}, {jetFlavourAxis}}}); - registry.add("h_compare_flavour_flavour_run2", "", {HistType::kTH1F, {{2, 0, 2}}}); - if (fillIPxy) { - registry.add("h3_jet_pt_impact_parameter_xy_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sigma_impact_parameter_xy_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaImpactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xy_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_impact_parameter_xy_significance_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_impact_parameter_xy_flavour_run2", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_xy_flavour_run2", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_impact_parameter_xy_significance_flavour_run2", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_track_pt_sign_impact_parameter_xy_significance_flavour_run2", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - } - if (fillTrackCounting) { - registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_run2_N1", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_run2_N2", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_run2_N3", "", {HistType::kTH3F, {{jetPtAxis}, {impactParameterXYSignificanceAxis}, {jetFlavourAxis}}}); - } + registry.add("h3_jet_pt_jet_pt_part_matchedgeo_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisJetPt}, {axisJetFlavour}}}); } - if (doprocessJPData) { - registry.add("h2_jet_pt_JP", "jet pt jet probability untagged", {HistType::kTH2F, {{jetPtAxis}, {JetProbabilityAxis}}}); - registry.add("h2_jet_pt_neg_log_JP", "jet pt jet probabilityun tagged", {HistType::kTH2F, {{jetPtAxis}, {JetProbabilityLogAxis}}}); - registry.add("h2_jet_pt_JP_N1", "jet pt jet probability N1", {HistType::kTH2F, {{jetPtAxis}, {JetProbabilityAxis}}}); - registry.add("h2_jet_pt_neg_log_JP_N1", "jet pt jet probabilityun N1", {HistType::kTH2F, {{jetPtAxis}, {JetProbabilityLogAxis}}}); - registry.add("h2_jet_pt_JP_N2", "jet pt jet probability N2", {HistType::kTH2F, {{jetPtAxis}, {JetProbabilityAxis}}}); - registry.add("h2_jet_pt_neg_log_JP_N2", "jet pt jet probabilityun N2", {HistType::kTH2F, {{jetPtAxis}, {JetProbabilityLogAxis}}}); - registry.add("h2_jet_pt_JP_N3", "jet pt jet probability N3", {HistType::kTH2F, {{jetPtAxis}, {JetProbabilityAxis}}}); - registry.add("h2_jet_pt_neg_log_JP_N3", "jet pt jet probabilityun N3", {HistType::kTH2F, {{jetPtAxis}, {JetProbabilityLogAxis}}}); - } - if (doprocessJPMCD || doprocessJPMCDWeighted) { - registry.add("h3_jet_pt_JP_flavour", "jet pt jet probability flavour untagged", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_neg_log_JP_flavour", "jet pt log jet probability flavour untagged", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityLogAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_JP_N1_flavour", "jet pt jet probability flavour N1", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_neg_log_JP_N1_flavour", "jet pt log jet probability flavour N1", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityLogAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_JP_N2_flavour", "jet pt jet probability flavour N2", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_neg_log_JP_N2_flavour", "jet pt log jet probability flavour N2", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityLogAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_JP_N3_flavour", "jet pt jet probability flavour N3", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_neg_log_JP_N3_flavour", "jet pt log jet probability flavour N3", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityLogAxis}, {jetFlavourAxis}}}); - } - if (doprocessJPMCPMCDMatched || doprocessJPMCPMCDMatchedWeighted) { - registry.add("h3_jet_pt_JP_flavour_run2", "jet pt jet probability flavour untagged", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_neg_log_JP_flavour_run2", "jet pt log jet probability flavour untagged", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityLogAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_JP_N1_flavour_run2", "jet pt jet probability flavour N1", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_neg_log_JP_N1_flavour_run2", "jet pt log jet probability flavour N1", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityLogAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_JP_N2_flavour_run2", "jet pt jet probability flavour N2", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_neg_log_JP_N2_flavour_run2", "jet pt log jet probability flavour N2", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityLogAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_JP_N3_flavour_run2", "jet pt jet probability flavour N3", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_neg_log_JP_N3_flavour_run2", "jet pt log jet probability flavour N3", {HistType::kTH3F, {{jetPtAxis}, {JetProbabilityLogAxis}, {jetFlavourAxis}}}); + if (!doprocessIPsData && !doprocessSV2ProngData && !doprocessSV3ProngData) { + registry.add("h_jet_pt", "", {HistType::kTH1F, {{axisJetPt}}}); + registry.add("h_jet_eta", "", {HistType::kTH1F, {{axisEta}}}); + registry.add("h_jet_phi", "", {HistType::kTH1F, {{axisPhi}}}); + } + registry.add("h2_jet_pt_JP", "jet pt jet probability untagged", {HistType::kTH2F, {{axisJetPt}, {axisJetProbability}}}); + registry.add("h2_jet_pt_neg_log_JP", "jet pt jet probabilityun tagged", {HistType::kTH2F, {{axisJetPt}, {axisJetProbabilityLog}}}); + registry.add("h2_taggedjet_pt_JP_N1", "jet pt jet probability N1", {HistType::kTH2F, {{axisJetPt}, {axisJetProbability}}}); + registry.add("h2_taggedjet_pt_neg_log_JP_N1", "jet pt jet probabilityun N1", {HistType::kTH2F, {{axisJetPt}, {axisJetProbabilityLog}}}); + registry.add("h2_taggedjet_pt_JP_N2", "jet pt jet probability N2", {HistType::kTH2F, {{axisJetPt}, {axisJetProbability}}}); + registry.add("h2_taggedjet_pt_neg_log_JP_N2", "jet pt jet probabilityun N2", {HistType::kTH2F, {{axisJetPt}, {axisJetProbabilityLog}}}); + registry.add("h2_taggedjet_pt_JP_N3", "jet pt jet probability N3", {HistType::kTH2F, {{axisJetPt}, {axisJetProbability}}}); + registry.add("h2_taggedjet_pt_neg_log_JP_N3", "jet pt jet probabilityun N3", {HistType::kTH2F, {{axisJetPt}, {axisJetProbabilityLog}}}); + } + if (doprocessJPMCD || doprocessJPMCDWeighted || doprocessJPMCPMCDMatched || doprocessJPMCPMCDMatchedWeighted) { + if (!(doprocessIPsMCD || doprocessIPsMCDWeighted || doprocessIPsMCPMCDMatched || doprocessIPsMCPMCDMatchedWeighted) && !(doprocessSV2ProngMCD || doprocessSV2ProngMCDWeighted || doprocessSV2ProngMCPMCDMatched || doprocessSV2ProngMCPMCDMatchedWeighted) && !(doprocessSV3ProngMCD || doprocessSV3ProngMCDWeighted || doprocessSV3ProngMCPMCDMatched || doprocessSV3ProngMCPMCDMatchedWeighted)) { + registry.add("h2_jet_pt_flavour", "", {HistType::kTH2F, {{axisJetPt}, {axisJetFlavour}}}); + registry.add("h2_jet_eta_flavour", "", {HistType::kTH2F, {{axisEta}, {axisJetFlavour}}}); + registry.add("h2_jet_phi_flavour", "", {HistType::kTH2F, {{axisPhi}, {axisJetFlavour}}}); + } + registry.add("h3_jet_pt_JP_flavour", "jet pt jet probability flavour untagged", {HistType::kTH3F, {{axisJetPt}, {axisJetProbability}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_neg_log_JP_flavour", "jet pt log jet probability flavour untagged", {HistType::kTH3F, {{axisJetPt}, {axisJetProbabilityLog}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_JP_N1_flavour", "jet pt jet probability flavour N1", {HistType::kTH3F, {{axisJetPt}, {axisJetProbability}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_neg_log_JP_N1_flavour", "jet pt log jet probability flavour N1", {HistType::kTH3F, {{axisJetPt}, {axisJetProbabilityLog}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_JP_N2_flavour", "jet pt jet probability flavour N2", {HistType::kTH3F, {{axisJetPt}, {axisJetProbability}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_neg_log_JP_N2_flavour", "jet pt log jet probability flavour N2", {HistType::kTH3F, {{axisJetPt}, {axisJetProbabilityLog}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_JP_N3_flavour", "jet pt jet probability flavour N3", {HistType::kTH3F, {{axisJetPt}, {axisJetProbability}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_neg_log_JP_N3_flavour", "jet pt log jet probability flavour N3", {HistType::kTH3F, {{axisJetPt}, {axisJetProbabilityLog}, {axisJetFlavour}}}); } if (doprocessSV2ProngData) { + if (!doprocessIPsData && !doprocessJPData && !doprocessSV3ProngData) { + registry.add("h_jet_pt", "", {HistType::kTH1F, {{axisJetPt}}}); + registry.add("h_jet_eta", "", {HistType::kTH1F, {{axisEta}}}); + registry.add("h_jet_phi", "", {HistType::kTH1F, {{axisPhi}}}); + } if (fillGeneralSVQA) { - registry.add("h_2prong_nprongs", "", {HistType::kTH1F, {{nprongsAxis}}}); - registry.add("h2_jet_pt_2prong_Lxy", "", {HistType::kTH2F, {{jetPtAxis}, {LxyAxis}}}); - registry.add("h2_jet_pt_2prong_sigmaLxy", "", {HistType::kTH2F, {{jetPtAxis}, {sigmaLxyAxis}}}); - registry.add("h2_jet_pt_2prong_Sxy", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_2prong_Lxyz", "", {HistType::kTH2F, {{jetPtAxis}, {LxyzAxis}}}); - registry.add("h2_jet_pt_2prong_sigmaLxyz", "", {HistType::kTH2F, {{jetPtAxis}, {sigmaLxyzAxis}}}); - registry.add("h2_jet_pt_2prong_Sxyz", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); - } - registry.add("h2_jet_pt_2prong_Sxy_N1", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_2prong_Sxyz_N1", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); - registry.add("h2_jet_pt_2prong_mass_N1", "", {HistType::kTH2F, {{jetPtAxis}, {massAxis}}}); - registry.add("h2_jet_pt_2prong_mass_xyz_N1", "", {HistType::kTH2F, {{jetPtAxis}, {massAxis}}}); - registry.add("h2_taggedjet_pt_2prong_Sxy_N1", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_taggedjet_pt_2prong_Sxyz_N1", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); - registry.add("h2_taggedjet_pt_2prong_mass_N1", "", {HistType::kTH2F, {{jetPtAxis}, {massAxis}}}); - registry.add("h2_taggedjet_pt_2prong_mass_xyz_N1", "", {HistType::kTH2F, {{jetPtAxis}, {massAxis}}}); + registry.add("h_2prong_nprongs", "", {HistType::kTH1F, {{axisNprongs}}}); + registry.add("h2_jet_pt_2prong_Lxy", "", {HistType::kTH2F, {{axisJetPt}, {axisLxy}}}); + registry.add("h2_jet_pt_2prong_sigmaLxy", "", {HistType::kTH2F, {{axisJetPt}, {axisSigmaLxy}}}); + registry.add("h2_jet_pt_2prong_Sxy", "", {HistType::kTH2F, {{axisJetPt}, {axisSxy}}}); + registry.add("h2_jet_pt_2prong_Lxyz", "", {HistType::kTH2F, {{axisJetPt}, {axisLxyz}}}); + registry.add("h2_jet_pt_2prong_sigmaLxyz", "", {HistType::kTH2F, {{axisJetPt}, {axisSigmaLxyz}}}); + registry.add("h2_jet_pt_2prong_Sxyz", "", {HistType::kTH2F, {{axisJetPt}, {axisSxyz}}}); + } + registry.add("h2_jet_pt_2prong_Sxy_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisSxy}}}); + registry.add("h2_jet_pt_2prong_Sxyz_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisSxyz}}}); + registry.add("h2_jet_pt_2prong_mass_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisMass}}}); + registry.add("h2_jet_pt_2prong_mass_xyz_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisMass}}}); + registry.add("h2_taggedjet_pt_2prong_Sxy_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisSxy}}}); + registry.add("h2_taggedjet_pt_2prong_Sxyz_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisSxyz}}}); + registry.add("h2_taggedjet_pt_2prong_mass_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisMass}}}); + registry.add("h2_taggedjet_pt_2prong_mass_xyz_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisMass}}}); } if (doprocessSV3ProngData) { + if (!doprocessIPsData && !doprocessJPData && !doprocessSV2ProngData) { + registry.add("h_jet_pt", "", {HistType::kTH1F, {{axisJetPt}}}); + registry.add("h_jet_eta", "", {HistType::kTH1F, {{axisEta}}}); + registry.add("h_jet_phi", "", {HistType::kTH1F, {{axisPhi}}}); + } if (fillGeneralSVQA) { - registry.add("h_3prong_nprongs", "", {HistType::kTH1F, {{nprongsAxis}}}); - registry.add("h2_jet_pt_3prong_Lxy", "", {HistType::kTH2F, {{jetPtAxis}, {LxyAxis}}}); - registry.add("h2_jet_pt_3prong_sigmaLxy", "", {HistType::kTH2F, {{jetPtAxis}, {sigmaLxyAxis}}}); - registry.add("h2_jet_pt_3prong_Sxy", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_3prong_Lxyz", "", {HistType::kTH2F, {{jetPtAxis}, {LxyzAxis}}}); - registry.add("h2_jet_pt_3prong_sigmaLxyz", "", {HistType::kTH2F, {{jetPtAxis}, {sigmaLxyzAxis}}}); - registry.add("h2_jet_pt_3prong_Sxyz", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); - } - registry.add("h2_jet_pt_3prong_Sxy_N1", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_3prong_Sxyz_N1", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); - registry.add("h2_jet_pt_3prong_mass_N1", "", {HistType::kTH2F, {{jetPtAxis}, {massAxis}}}); - registry.add("h2_jet_pt_3prong_mass_xyz_N1", "", {HistType::kTH2F, {{jetPtAxis}, {massAxis}}}); - registry.add("h2_taggedjet_pt_3prong_Sxy_N1", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_taggedjet_pt_3prong_Sxyz_N1", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); - registry.add("h2_taggedjet_pt_3prong_mass_N1", "", {HistType::kTH2F, {{jetPtAxis}, {massAxis}}}); - registry.add("h2_taggedjet_pt_3prong_mass_xyz_N1", "", {HistType::kTH2F, {{jetPtAxis}, {massAxis}}}); - } - if (doprocessSV2ProngMCD || doprocessSV2ProngMCDWeighted) { - if (fillGeneralSVQA) { - registry.add("h2_2prong_nprongs_flavour", "", {HistType::kTH2F, {{nprongsAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Lxy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {LxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_sigmaLxy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Lxyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {LxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_sigmaLxyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - } - registry.add("h3_jet_pt_2prong_Sxy_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxyz_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_mass_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_mass_xyz_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_2prong_Sxy_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_2prong_Sxyz_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_2prong_mass_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_2prong_mass_xyz_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - } - if (doprocessSV3ProngMCD || doprocessSV3ProngMCDWeighted) { + registry.add("h_3prong_nprongs", "", {HistType::kTH1F, {{axisNprongs}}}); + registry.add("h2_jet_pt_3prong_Lxy", "", {HistType::kTH2F, {{axisJetPt}, {axisLxy}}}); + registry.add("h2_jet_pt_3prong_sigmaLxy", "", {HistType::kTH2F, {{axisJetPt}, {axisSigmaLxy}}}); + registry.add("h2_jet_pt_3prong_Sxy", "", {HistType::kTH2F, {{axisJetPt}, {axisSxy}}}); + registry.add("h2_jet_pt_3prong_Lxyz", "", {HistType::kTH2F, {{axisJetPt}, {axisLxyz}}}); + registry.add("h2_jet_pt_3prong_sigmaLxyz", "", {HistType::kTH2F, {{axisJetPt}, {axisSigmaLxyz}}}); + registry.add("h2_jet_pt_3prong_Sxyz", "", {HistType::kTH2F, {{axisJetPt}, {axisSxyz}}}); + } + registry.add("h2_jet_pt_3prong_Sxy_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisSxy}}}); + registry.add("h2_jet_pt_3prong_Sxyz_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisSxyz}}}); + registry.add("h2_jet_pt_3prong_mass_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisMass}}}); + registry.add("h2_jet_pt_3prong_mass_xyz_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisMass}}}); + registry.add("h2_taggedjet_pt_3prong_Sxy_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisSxy}}}); + registry.add("h2_taggedjet_pt_3prong_Sxyz_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisSxyz}}}); + registry.add("h2_taggedjet_pt_3prong_mass_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisMass}}}); + registry.add("h2_taggedjet_pt_3prong_mass_xyz_N1", "", {HistType::kTH2F, {{axisJetPt}, {axisMass}}}); + } + if (doprocessSV2ProngMCD || doprocessSV2ProngMCDWeighted || doprocessSV2ProngMCPMCDMatched || doprocessSV2ProngMCPMCDMatchedWeighted) { + if (!(doprocessIPsMCD || doprocessIPsMCDWeighted || doprocessIPsMCPMCDMatched || doprocessIPsMCPMCDMatchedWeighted) && !(doprocessJPMCD || doprocessJPMCDWeighted || doprocessJPMCPMCDMatched || doprocessJPMCPMCDMatchedWeighted) && !(doprocessSV3ProngMCD || doprocessSV3ProngMCDWeighted || doprocessSV3ProngMCPMCDMatched || doprocessSV3ProngMCPMCDMatchedWeighted)) { + registry.add("h2_jet_pt_flavour", "", {HistType::kTH2F, {{axisJetPt}, {axisJetFlavour}}}); + registry.add("h2_jet_eta_flavour", "", {HistType::kTH2F, {{axisEta}, {axisJetFlavour}}}); + registry.add("h2_jet_phi_flavour", "", {HistType::kTH2F, {{axisPhi}, {axisJetFlavour}}}); + } if (fillGeneralSVQA) { - registry.add("h2_3prong_nprongs_flavour", "", {HistType::kTH2F, {{nprongsAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Lxy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {LxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_sigmaLxy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Lxyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {LxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_sigmaLxyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - } - registry.add("h3_jet_pt_3prong_Sxy_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxyz_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_mass_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_mass_xyz_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_3prong_Sxy_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_3prong_Sxyz_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_3prong_mass_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_3prong_mass_xyz_N1_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - } - if (doprocessSV2ProngMCPMCDMatched || doprocessSV2ProngMCPMCDMatchedWeighted) { + registry.add("h2_2prong_nprongs_flavour", "", {HistType::kTH2F, {{axisNprongs}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_2prong_Lxy_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisLxy}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_2prong_sigmaLxy_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSigmaLxy}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_2prong_Sxy_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxy}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_2prong_Lxyz_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisLxyz}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_2prong_sigmaLxyz_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSigmaLxyz}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_2prong_Sxyz_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxyz}, {axisJetFlavour}}}); + } + registry.add("h3_jet_pt_2prong_Sxy_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxy}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_2prong_Sxyz_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxyz}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_2prong_mass_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisMass}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_2prong_mass_xyz_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisMass}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_2prong_Sxy_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxy}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_2prong_Sxyz_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxyz}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_2prong_mass_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisMass}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_2prong_mass_xyz_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisMass}, {axisJetFlavour}}}); + } + if (doprocessSV3ProngMCD || doprocessSV3ProngMCDWeighted || doprocessSV3ProngMCPMCDMatched || doprocessSV3ProngMCPMCDMatchedWeighted) { + if (!(doprocessIPsMCD || doprocessIPsMCDWeighted || doprocessIPsMCPMCDMatched || doprocessIPsMCPMCDMatchedWeighted) && !(doprocessJPMCD || doprocessJPMCDWeighted || doprocessJPMCPMCDMatched || doprocessJPMCPMCDMatchedWeighted) && !(doprocessSV2ProngMCD || doprocessSV2ProngMCDWeighted || doprocessSV2ProngMCPMCDMatched || doprocessSV2ProngMCPMCDMatchedWeighted)) { + registry.add("h2_jet_pt_flavour", "", {HistType::kTH2F, {{axisJetPt}, {axisJetFlavour}}}); + registry.add("h2_jet_eta_flavour", "", {HistType::kTH2F, {{axisEta}, {axisJetFlavour}}}); + registry.add("h2_jet_phi_flavour", "", {HistType::kTH2F, {{axisPhi}, {axisJetFlavour}}}); + } if (fillGeneralSVQA) { - registry.add("h3_jet_pt_2prong_Lxy_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {LxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_sigmaLxy_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxy_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Lxyz_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {LxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_sigmaLxyz_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxyz_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - } - registry.add("h3_taggedjet_pt_2prong_Sxy_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_2prong_Sxyz_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_2prong_mass_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_2prong_mass_xyz_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxy_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxyz_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_mass_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_mass_xyz_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - } - if (doprocessSV3ProngMCPMCDMatched || doprocessSV3ProngMCPMCDMatchedWeighted) { - registry.add("h3_jet_pt_3prong_Lxy_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {LxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_sigmaLxy_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxy_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Lxyz_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {LxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_sigmaLxyz_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxyz_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxy_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxyz_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_mass_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_mass_xyz_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_3prong_Sxy_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_3prong_Sxyz_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_3prong_mass_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); - registry.add("h3_taggedjet_pt_3prong_mass_xyz_N1_flavour_run2", "", {HistType::kTH3F, {{jetPtAxis}, {massAxis}, {jetFlavourAxis}}}); + registry.add("h2_3prong_nprongs_flavour", "", {HistType::kTH2F, {{axisNprongs}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_3prong_Lxy_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisLxy}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_3prong_sigmaLxy_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSigmaLxy}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_3prong_Sxy_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxy}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_3prong_Lxyz_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisLxyz}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_3prong_sigmaLxyz_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSigmaLxyz}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_3prong_Sxyz_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxyz}, {axisJetFlavour}}}); + } + registry.add("h3_jet_pt_3prong_Sxy_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxy}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_3prong_Sxyz_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxyz}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_3prong_mass_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisMass}, {axisJetFlavour}}}); + registry.add("h3_jet_pt_3prong_mass_xyz_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisMass}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_3prong_Sxy_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxy}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_3prong_Sxyz_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisSxyz}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_3prong_mass_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisMass}, {axisJetFlavour}}}); + registry.add("h3_taggedjet_pt_3prong_mass_xyz_N1_flavour", "", {HistType::kTH3F, {{axisJetPt}, {axisMass}, {axisJetFlavour}}}); } } // Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut); - PresliceUnsorted> CollisionsPerMCPCollision = aod::jmccollisionlb::mcCollisionId; + PresliceUnsorted> collisionsPerMCPCollision = aod::jmccollisionlb::mcCollisionId; Preslice particlesPerCollision = aod::jmcparticle::mcCollisionId; using JetTagTracksData = soa::Join; @@ -423,7 +436,7 @@ struct JetTaggerHFQA { bool isAcceptedJet(U const& jet) { if (jetAreaFractionMin > -98.0) { - if (jet.area() < jetAreaFractionMin * M_PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { + if (jet.area() < jetAreaFractionMin * o2::constants::math::PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { return false; } } @@ -463,16 +476,60 @@ struct JetTaggerHFQA { return true; } + template + void fillValidationFlavourDefMCD(T const& mcdjet, V const& tracks, W const& particles, X const& particlesPerColl, float eventWeight = 1.0) + { + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (mcdjet.pt() > pTHatMaxMCD * pTHat) { + return; + } + typename V::iterator hftrack; + int jetflavourConstQuark = jettaggingutilities::mcdJetFromHFShower(mcdjet, tracks, particles, maxDeltaR, true); + int jetflavourConstHadron = jettaggingutilities::mcdJetFromHFShower(mcdjet, tracks, particles, maxDeltaR, false); + int jetflavourDistQuark = -1; + int jetflavourDistHadron = -1; + for (auto const& mcpjet : mcdjet.template matchedJetGeo_as()) { + jetflavourDistQuark = jettaggingutilities::getJetFlavor(mcpjet, particlesPerColl); + jetflavourDistHadron = jettaggingutilities::getJetFlavorHadron(mcpjet, particlesPerColl); + } + if (jetflavourDistQuark < 0 || jetflavourDistHadron < 0) + return; + registry.fill(HIST("h2_flavour_dist_quark_flavour_dist_hadron"), jetflavourDistQuark, jetflavourDistHadron, eventWeight); + registry.fill(HIST("h2_flavour_const_quark_flavour_const_hadron"), jetflavourConstQuark, jetflavourConstHadron, eventWeight); + registry.fill(HIST("h2_flavour_const_hadron_flavour_dist_hadron"), jetflavourConstHadron, jetflavourDistHadron, eventWeight); + registry.fill(HIST("h2_flavour_const_quark_flavour_dist_quark"), jetflavourConstQuark, jetflavourDistQuark, eventWeight); + } + + template + void fillValidationFlavourDefMCP(T const& mcpjet, U const& particles, V const& particlesPerColl, float eventWeight = 1.0) + { + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { + return; + } + int jetflavourConstQuark = jettaggingutilities::mcpJetFromHFShower(mcpjet, particles, maxDeltaR, true); + int jetflavourConstHadron = jettaggingutilities::mcpJetFromHFShower(mcpjet, particles, maxDeltaR, false); + int jetflavourDistQuark = jettaggingutilities::getJetFlavor(mcpjet, particlesPerColl); + int jetflavourDistHadron = jettaggingutilities::getJetFlavorHadron(mcpjet, particlesPerColl); + registry.fill(HIST("h2_part_flavour_dist_quark_part_flavour_dist_hadron"), jetflavourDistQuark, jetflavourDistHadron, eventWeight); + registry.fill(HIST("h2_part_flavour_const_quark_part_flavour_const_hadron"), jetflavourConstQuark, jetflavourConstHadron, eventWeight); + registry.fill(HIST("h2_part_flavour_const_hadron_part_flavour_dist_hadron"), jetflavourConstHadron, jetflavourDistHadron, eventWeight); + registry.fill(HIST("h2_part_flavour_const_quark_part_flavour_dist_quark"), jetflavourConstQuark, jetflavourDistQuark, eventWeight); + } + template - void fillHistogramIPsData(T const& jet, U const& /*jtracks*/) + void fillHistogramIPsData(T const& jet, U const& /*tracks*/) { float eventWeight = 1.0; float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); if (jet.pt() > pTHatMaxMCD * pTHat) { return; } + registry.fill(HIST("h_jet_pt"), jet.pt()); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); std::vector> vecSignImpXYSig, vecSignImpZSig, vecSignImpXYZSig; - for (auto& track : jet.template tracks_as()) { + for (auto const& track : jet.template tracks_as()) { if (!trackAcceptance(track)) continue; if (!jettaggingutilities::trackAcceptanceWithDca(track, trackDcaXYMax, trackDcaZMax)) @@ -527,22 +584,51 @@ struct JetTaggerHFQA { std::sort(vecSignImpZSig.begin(), vecSignImpZSig.end(), sortImp); if (fillIPxyz) std::sort(vecSignImpXYZSig.begin(), vecSignImpXYZSig.end(), sortImp); + + if (vecSignImpXYSig.size() > 0) { // N1 + if (fillIPxy) + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xy_significance_N1"), jet.pt(), vecSignImpXYSig[0][0]); + if (fillIPz) + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_z_significance_N1"), jet.pt(), vecSignImpZSig[0][0]); + if (fillIPxyz) + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xyz_significance_N1"), jet.pt(), vecSignImpXYZSig[0][0]); + } + if (vecSignImpXYSig.size() > 1) { // N2 + if (fillIPxy) + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xy_significance_N2"), jet.pt(), vecSignImpXYSig[1][0]); + if (fillIPz) + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_z_significance_N2"), jet.pt(), vecSignImpZSig[1][0]); + if (fillIPxyz) + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xyz_significance_N2"), jet.pt(), vecSignImpXYZSig[1][0]); + } + if (vecSignImpXYSig.size() > 2) { // N3 + if (fillIPxy) + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xy_significance_N3"), jet.pt(), vecSignImpXYSig[2][0]); + if (fillIPz) + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_z_significance_N3"), jet.pt(), vecSignImpZSig[2][0]); + if (fillIPxyz) + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xyz_significance_N3"), jet.pt(), vecSignImpXYZSig[2][0]); + } if (fillIPxy && vecSignImpXYSig.empty()) return; - if (fillIPz && vecSignImpZSig.empty()) - return; - if (fillIPxyz && vecSignImpXYZSig.empty()) - return; for (int order = 1; order <= numOrder; order++) { if (fillIPxy && static_cast>::size_type>(order) < vecSignImpXYSig.size()) { registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_tc"), jet.pt(), vecSignImpXYSig[order - 1][0], order); registry.fill(HIST("h3_track_pt_sign_impact_parameter_xy_significance_tc"), vecSignImpXYSig[order - 1][1], vecSignImpXYSig[order - 1][0], order); } - if (fillIPz && static_cast>::size_type>(order) < vecSignImpZSig.size()) { + } + if (fillIPz && vecSignImpZSig.empty()) + return; + for (int order = 1; order <= numOrder; order++) { + if (fillIPz && static_cast>::size_type>(order) < vecSignImpXYSig.size()) { registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_significance_tc"), jet.pt(), vecSignImpZSig[order - 1][0], order); registry.fill(HIST("h3_track_pt_sign_impact_parameter_z_significance_tc"), vecSignImpZSig[order - 1][1], vecSignImpZSig[order - 1][0], order); } - if (fillIPxyz && static_cast>::size_type>(order) < vecSignImpXYZSig.size()) { + } + if (fillIPxyz && vecSignImpXYZSig.empty()) + return; + for (int order = 1; order <= numOrder; order++) { + if (fillIPxyz && static_cast>::size_type>(order) < vecSignImpXYSig.size()) { registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_tc"), jet.pt(), vecSignImpXYZSig[order - 1][0], order); registry.fill(HIST("h3_track_pt_sign_impact_parameter_xyz_significance_tc"), vecSignImpXYZSig[order - 1][1], vecSignImpXYZSig[order - 1][0], order); } @@ -550,7 +636,7 @@ struct JetTaggerHFQA { } template - void fillHistogramIPsMCD(T const& mcdjet, U const& /*jtracks*/, float eventWeight = 1.0) + void fillHistogramIPsMCD(T const& mcdjet, U const& /*tracks*/, float eventWeight = 1.0) { float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); if (mcdjet.pt() > pTHatMaxMCD * pTHat) { @@ -564,10 +650,13 @@ struct JetTaggerHFQA { if (jetflavour == JetTaggingSpecies::none) { LOGF(debug, "NOT DEFINE JET FLAVOR"); } + if (jetflavour == -1) { + jetflavour = JetTaggingSpecies::none; + } registry.fill(HIST("h2_jet_pt_flavour"), mcdjet.pt(), jetflavour, eventWeight); registry.fill(HIST("h2_jet_eta_flavour"), mcdjet.eta(), jetflavour, eventWeight); registry.fill(HIST("h2_jet_phi_flavour"), mcdjet.phi(), jetflavour, eventWeight); - for (auto& track : mcdjet.template tracks_as()) { + for (auto const& track : mcdjet.template tracks_as()) { if (!trackAcceptance(track)) continue; if (!jettaggingutilities::trackAcceptanceWithDca(track, trackDcaXYMax, trackDcaZMax)) @@ -646,17 +735,8 @@ struct JetTaggerHFQA { if (!fillTrackCounting) return; - sort(vecImpXY[jetflavour].begin(), vecImpXY[jetflavour].end(), std::greater()); - sort(vecSignImpXY[jetflavour].begin(), vecSignImpXY[jetflavour].end(), std::greater()); - sort(vecImpXYSig[jetflavour].begin(), vecImpXYSig[jetflavour].end(), std::greater()); sort(vecSignImpXYSig[jetflavour].begin(), vecSignImpXYSig[jetflavour].end(), std::greater()); - sort(vecImpZ[jetflavour].begin(), vecImpZ[jetflavour].end(), std::greater()); - sort(vecSignImpZ[jetflavour].begin(), vecSignImpZ[jetflavour].end(), std::greater()); - sort(vecImpZSig[jetflavour].begin(), vecImpZSig[jetflavour].end(), std::greater()); sort(vecSignImpZSig[jetflavour].begin(), vecSignImpZSig[jetflavour].end(), std::greater()); - sort(vecImpXYZ[jetflavour].begin(), vecImpXYZ[jetflavour].end(), std::greater()); - sort(vecSignImpXYZ[jetflavour].begin(), vecSignImpXYZ[jetflavour].end(), std::greater()); - sort(vecImpXYZSig[jetflavour].begin(), vecImpXYZSig[jetflavour].end(), std::greater()); sort(vecSignImpXYZSig[jetflavour].begin(), vecSignImpXYZSig[jetflavour].end(), std::greater()); if (vecImpXY[jetflavour].size() > 0) { // N1 @@ -683,7 +763,6 @@ struct JetTaggerHFQA { if (fillIPxyz) registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N3"), mcdjet.pt(), vecSignImpXYZSig[jetflavour][2], jetflavour, eventWeight); } - std::sort(vecSignImpXYSigTC.begin(), vecSignImpXYSigTC.end(), sortImp); std::sort(vecSignImpZSigTC.begin(), vecSignImpZSigTC.end(), sortImp); std::sort(vecSignImpXYZSigTC.begin(), vecSignImpXYZSigTC.end(), sortImp); @@ -698,7 +777,7 @@ struct JetTaggerHFQA { if (vecSignImpZSigTC.empty()) return; for (int order = 1; order <= numOrder; order++) { - if (fillIPxy && static_cast>::size_type>(order) < vecSignImpZSigTC.size()) { + if (fillIPz && static_cast>::size_type>(order) < vecSignImpXYSigTC.size()) { registry.fill(HIST("h3_sign_impact_parameter_z_significance_tc_flavour"), vecSignImpZSigTC[order - 1][0], order, jetflavour, eventWeight); } } @@ -706,7 +785,7 @@ struct JetTaggerHFQA { if (vecSignImpXYZSigTC.empty()) return; for (int order = 1; order <= numOrder; order++) { - if (fillIPxy && static_cast>::size_type>(order) < vecSignImpXYZSigTC.size()) { + if (fillIPxyz && static_cast>::size_type>(order) < vecSignImpXYSigTC.size()) { registry.fill(HIST("h3_sign_impact_parameter_xyz_significance_tc_flavour"), vecSignImpXYZSigTC[order - 1][0], order, jetflavour, eventWeight); } } @@ -716,7 +795,7 @@ struct JetTaggerHFQA { void fillHistogramIPsMCP(T const& mcpjet, float eventWeight = 1.0) { float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); - if (mcpjet.pt() > pTHatMaxMCD * pTHat) { + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { return; } int jetflavour = mcpjet.origin(); @@ -728,77 +807,6 @@ struct JetTaggerHFQA { registry.fill(HIST("h2_jet_phi_part_flavour"), mcpjet.phi(), jetflavour, eventWeight); } - template - void fillHistogramIPsMatched(T const& mcdjet, U const&, V const&, W const& particlesPerColl, float eventWeight = 1.0) - { - float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); - if (mcdjet.pt() > pTHatMaxMCD * pTHat) { - return; - } - std::vector vecImpXY[numberOfJetFlavourSpecies], vecSignImpXY[numberOfJetFlavourSpecies], vecImpXYSig[numberOfJetFlavourSpecies], vecSignImpXYSig[numberOfJetFlavourSpecies]; - int jetflavour = mcdjet.origin(); - if (jetflavour == JetTaggingSpecies::none) - jetflavour = JetTaggingSpecies::lightflavour; // TODO - int jetflavourRun2Def = -1; - // if (!mcdjet.has_matchedJetGeo()) continue; - for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { - jetflavourRun2Def = jettaggingutilities::getJetFlavor(mcpjet, particlesPerColl); - registry.fill(HIST("h3_jet_pt_jet_pt_part_matchedgeo_flavour"), mcpjet.pt(), mcdjet.pt(), jetflavour, eventWeight); - registry.fill(HIST("h3_jet_pt_jet_pt_part_matchedgeo_flavour_run2"), mcpjet.pt(), mcdjet.pt(), jetflavourRun2Def, eventWeight); - } - if (jetflavourRun2Def < 0) - return; - if (jetflavour == jetflavourRun2Def) - registry.fill(HIST("h_compare_flavour_flavour_run2"), 0.5); - else - registry.fill(HIST("h_compare_flavour_flavour_run2"), 1.5); - registry.fill(HIST("h3_jet_pt_flavour_flavour_run2"), mcdjet.pt(), jetflavour, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_eta_flavour_flavour_run2"), mcdjet.eta(), jetflavour, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_phi_flavour_flavour_run2"), mcdjet.phi(), jetflavour, jetflavourRun2Def, eventWeight); - for (auto& track : mcdjet.template tracks_as()) { - int geoSign = jettaggingutilities::getGeoSign(mcdjet, track); - if (fillIPxy) { - float varImpXY, varSignImpXY, varImpXYSig, varSignImpXYSig; - varImpXY = track.dcaXY() * jettaggingutilities::cmTomum; - float varSigmaImpXY = track.dcaXY() * jettaggingutilities::cmTomum; - varSignImpXY = geoSign * std::abs(track.dcaXY()) * jettaggingutilities::cmTomum; - varImpXYSig = track.dcaXY() / track.sigmadcaXY(); - varSignImpXYSig = geoSign * std::abs(track.dcaXY()) / track.sigmadcaXY(); - registry.fill(HIST("h3_jet_pt_impact_parameter_xy_flavour_run2"), mcdjet.pt(), varImpXY, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_sigma_impact_parameter_xy_flavour_run2"), mcdjet.pt(), varSigmaImpXY, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_flavour_run2"), mcdjet.pt(), varSignImpXY, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_impact_parameter_xy_significance_flavour_run2"), mcdjet.pt(), varImpXYSig, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_run2"), mcdjet.pt(), varSignImpXYSig, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_track_pt_impact_parameter_xy_flavour_run2"), track.pt(), varImpXY, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_track_pt_sign_impact_parameter_xy_flavour_run2"), track.pt(), varSignImpXY, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_track_pt_impact_parameter_xy_significance_flavour_run2"), track.pt(), varImpXYSig, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_track_pt_sign_impact_parameter_xy_significance_flavour_run2"), track.pt(), varSignImpXYSig, jetflavourRun2Def, eventWeight); - vecImpXY[jetflavour].push_back(varImpXY); - vecSignImpXY[jetflavour].push_back(varSignImpXY); - vecImpXYSig[jetflavour].push_back(varImpXYSig); - vecSignImpXYSig[jetflavour].push_back(varSignImpXYSig); - } - } - if (!fillTrackCounting) - return; - sort(vecImpXY[jetflavour].begin(), vecImpXY[jetflavour].end(), std::greater()); - sort(vecSignImpXY[jetflavour].begin(), vecSignImpXY[jetflavour].end(), std::greater()); - sort(vecImpXYSig[jetflavour].begin(), vecImpXYSig[jetflavour].end(), std::greater()); - sort(vecSignImpXYSig[jetflavour].begin(), vecSignImpXYSig[jetflavour].end(), std::greater()); - if (vecImpXY[jetflavour].size() > 0) { // N1 - if (fillIPxy) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_run2_N1"), mcdjet.pt(), vecSignImpXYSig[jetflavour][0], jetflavourRun2Def, eventWeight); - } - if (vecImpXY[jetflavour].size() > 1) { // N2 - if (fillIPxy) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_run2_N2"), mcdjet.pt(), vecSignImpXYSig[jetflavour][1], jetflavourRun2Def, eventWeight); - } - if (vecImpXY[jetflavour].size() > 2) { // N3 - if (fillIPxy) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_run2_N3"), mcdjet.pt(), vecSignImpXYSig[jetflavour][2], jetflavourRun2Def, eventWeight); - } - } - template void fillHistogramJPData(T const& jet) { @@ -807,14 +815,19 @@ struct JetTaggerHFQA { if (jet.pt() > pTHatMaxMCD * pTHat) { return; } - registry.fill(HIST("h2_jet_pt_JP"), jet.pt(), jet.jetProb()[0]); - registry.fill(HIST("h2_jet_pt_neg_log_JP"), jet.pt(), -1 * std::log(jet.jetProb()[0])); - registry.fill(HIST("h2_jet_pt_JP_N1"), jet.pt(), jet.jetProb()[1]); - registry.fill(HIST("h2_jet_pt_neg_log_JP_N1"), jet.pt(), -1 * TMath::Log(jet.jetProb()[1])); - registry.fill(HIST("h2_jet_pt_JP_N2"), jet.pt(), jet.jetProb()[2]); - registry.fill(HIST("h2_jet_pt_neg_log_JP_N2"), jet.pt(), -1 * TMath::Log(jet.jetProb()[2])); - registry.fill(HIST("h2_jet_pt_JP_N3"), jet.pt(), jet.jetProb()[3]); - registry.fill(HIST("h2_jet_pt_neg_log_JP_N3"), jet.pt(), -1 * TMath::Log(jet.jetProb()[3])); + if (!doprocessIPsData && !doprocessSV2ProngData && !doprocessSV3ProngData) { + registry.fill(HIST("h_jet_pt"), jet.pt()); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); + } + registry.fill(HIST("h2_jet_pt_JP"), jet.pt(), jet.jetProb()); + registry.fill(HIST("h2_jet_pt_neg_log_JP"), jet.pt(), -1 * std::log(jet.jetProb())); + registry.fill(HIST("h2_taggedjet_pt_JP_N1"), jet.pt(), jet.isTagged(BJetTaggingMethod::IPsN1) ? jet.jetProb() : -1); + registry.fill(HIST("h2_taggedjet_pt_neg_log_JP_N1"), jet.pt(), jet.isTagged(BJetTaggingMethod::IPsN1) ? -1 * std::log(jet.jetProb()) : -1); + registry.fill(HIST("h2_taggedjet_pt_JP_N2"), jet.pt(), jet.isTagged(BJetTaggingMethod::IPsN2) ? jet.jetProb() : -1); + registry.fill(HIST("h2_taggedjet_pt_neg_log_JP_N2"), jet.pt(), jet.isTagged(BJetTaggingMethod::IPsN2) ? -1 * std::log(jet.jetProb()) : -1); + registry.fill(HIST("h2_taggedjet_pt_JP_N3"), jet.pt(), jet.isTagged(BJetTaggingMethod::IPsN3) ? jet.jetProb() : -1); + registry.fill(HIST("h2_taggedjet_pt_neg_log_JP_N3"), jet.pt(), jet.isTagged(BJetTaggingMethod::IPsN3) ? -1 * std::log(jet.jetProb()) : -1); } template @@ -824,40 +837,19 @@ struct JetTaggerHFQA { if (mcdjet.pt() > pTHatMaxMCD * pTHat) { return; } - registry.fill(HIST("h3_jet_pt_JP_flavour"), mcdjet.pt(), mcdjet.jetProb()[0], mcdjet.origin(), eventWeight); - registry.fill(HIST("h3_jet_pt_neg_log_JP_flavour"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[0]), mcdjet.origin(), eventWeight); - registry.fill(HIST("h3_jet_pt_JP_N1_flavour"), mcdjet.pt(), mcdjet.jetProb()[1], mcdjet.origin(), eventWeight); - registry.fill(HIST("h3_jet_pt_neg_log_JP_N1_flavour"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[1]), mcdjet.origin(), eventWeight); - registry.fill(HIST("h3_jet_pt_JP_N2_flavour"), mcdjet.pt(), mcdjet.jetProb()[2], mcdjet.origin(), eventWeight); - registry.fill(HIST("h3_jet_pt_neg_log_JP_N2_flavour"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[2]), mcdjet.origin(), eventWeight); - registry.fill(HIST("h3_jet_pt_JP_N3_flavour"), mcdjet.pt(), mcdjet.jetProb()[3], mcdjet.origin(), eventWeight); - registry.fill(HIST("h3_jet_pt_neg_log_JP_N3_flavour"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[3]), mcdjet.origin(), eventWeight); - } - - template - void fillHistogramJPMatched(T const& mcdjet, U const&, V const& particlesPerColl, float eventWeight = 1.0) - { - float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); - if (mcdjet.pt() > pTHatMaxMCD * pTHat) { - return; - } - int jetflavour = mcdjet.origin(); - if (jetflavour == JetTaggingSpecies::none) - jetflavour = JetTaggingSpecies::lightflavour; // TODO - int jetflavourRun2Def = -1; - for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { - jetflavourRun2Def = jettaggingutilities::getJetFlavor(mcpjet, particlesPerColl); - } - if (jetflavourRun2Def < 0) - return; - registry.fill(HIST("h3_jet_pt_JP_flavour_run2"), mcdjet.pt(), mcdjet.jetProb()[0], jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_neg_log_JP_flavour_run2"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[0]), jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_JP_N1_flavour_run2"), mcdjet.pt(), mcdjet.jetProb()[1], jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_neg_log_JP_N1_flavour_run2"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[1]), jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_JP_N2_flavour_run2"), mcdjet.pt(), mcdjet.jetProb()[2], jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_neg_log_JP_N2_flavour_run2"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[2]), jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_JP_N3_flavour_run2"), mcdjet.pt(), mcdjet.jetProb()[3], jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_neg_log_JP_N3_flavour_run2"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[3]), jetflavourRun2Def, eventWeight); + if (!((doprocessIPsMCD || doprocessIPsMCDWeighted || doprocessIPsMCPMCDMatched || doprocessIPsMCPMCDMatchedWeighted) && (doprocessSV2ProngMCD || doprocessSV2ProngMCDWeighted || doprocessSV2ProngMCPMCDMatched || doprocessSV2ProngMCPMCDMatchedWeighted) && (doprocessSV3ProngMCD || doprocessSV3ProngMCDWeighted || doprocessSV3ProngMCPMCDMatched || doprocessSV3ProngMCPMCDMatchedWeighted))) { + registry.fill(HIST("h2_jet_pt_flavour"), mcdjet.pt(), mcdjet.origin(), eventWeight); + registry.fill(HIST("h2_jet_eta_flavour"), mcdjet.eta(), mcdjet.origin(), eventWeight); + registry.fill(HIST("h2_jet_phi_flavour"), mcdjet.phi(), mcdjet.origin(), eventWeight); + } + registry.fill(HIST("h3_jet_pt_JP_flavour"), mcdjet.pt(), mcdjet.jetProb(), mcdjet.origin(), eventWeight); + registry.fill(HIST("h3_jet_pt_neg_log_JP_flavour"), mcdjet.pt(), -1 * std::log(mcdjet.jetProb()), mcdjet.origin(), eventWeight); + registry.fill(HIST("h3_taggedjet_pt_JP_N1_flavour"), mcdjet.pt(), mcdjet.isTagged(BJetTaggingMethod::IPsN1) ? mcdjet.jetProb() : -1, mcdjet.origin(), eventWeight); + registry.fill(HIST("h3_taggedjet_pt_neg_log_JP_N1_flavour"), mcdjet.pt(), mcdjet.isTagged(BJetTaggingMethod::IPsN1) ? -1 * std::log(mcdjet.jetProb()) : -1, mcdjet.origin(), eventWeight); + registry.fill(HIST("h3_taggedjet_pt_JP_N2_flavour"), mcdjet.pt(), mcdjet.isTagged(BJetTaggingMethod::IPsN2) ? mcdjet.jetProb() : -1, mcdjet.origin(), eventWeight); + registry.fill(HIST("h3_taggedjet_pt_neg_log_JP_N2_flavour"), mcdjet.pt(), mcdjet.isTagged(BJetTaggingMethod::IPsN2) ? -1 * std::log(mcdjet.jetProb()) : -1, mcdjet.origin(), eventWeight); + registry.fill(HIST("h3_taggedjet_pt_JP_N3_flavour"), mcdjet.pt(), mcdjet.isTagged(BJetTaggingMethod::IPsN3) ? mcdjet.jetProb() : -1, mcdjet.origin(), eventWeight); + registry.fill(HIST("h3_taggedjet_pt_neg_log_JP_N3_flavour"), mcdjet.pt(), mcdjet.isTagged(BJetTaggingMethod::IPsN3) ? -1 * std::log(mcdjet.jetProb()) : -1, mcdjet.origin(), eventWeight); } template @@ -870,17 +862,18 @@ struct JetTaggerHFQA { } if (jet.template secondaryVertices_as().size() < 1) return; + if (!doprocessIPsData && !doprocessJPData && !doprocessSV3ProngData) { + registry.fill(HIST("h_jet_pt"), jet.pt(), eventWeight); + registry.fill(HIST("h_jet_eta"), jet.eta(), eventWeight); + registry.fill(HIST("h_jet_phi"), jet.phi(), eventWeight); + } if (fillGeneralSVQA) { registry.fill(HIST("h_2prong_nprongs"), jet.template secondaryVertices_as().size()); for (const auto& prong : jet.template secondaryVertices_as()) { - auto Lxy = prong.decayLengthXY(); - auto Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); - auto Lxyz = prong.decayLength(); - auto Sxyz = prong.decayLength() / prong.errorDecayLength(); - registry.fill(HIST("h2_jet_pt_2prong_Lxy"), jet.pt(), Lxy); - registry.fill(HIST("h2_jet_pt_2prong_Sxy"), jet.pt(), Sxy); - registry.fill(HIST("h2_jet_pt_2prong_Lxyz"), jet.pt(), Lxyz); - registry.fill(HIST("h2_jet_pt_2prong_Sxyz"), jet.pt(), Sxyz); + registry.fill(HIST("h2_jet_pt_2prong_Lxy"), jet.pt(), prong.decayLengthXY()); + registry.fill(HIST("h2_jet_pt_2prong_Sxy"), jet.pt(), prong.decayLengthXY() / prong.errorDecayLengthXY()); + registry.fill(HIST("h2_jet_pt_2prong_Lxyz"), jet.pt(), prong.decayLength()); + registry.fill(HIST("h2_jet_pt_2prong_Sxyz"), jet.pt(), prong.decayLength() / prong.errorDecayLength()); registry.fill(HIST("h2_jet_pt_2prong_sigmaLxy"), jet.pt(), prong.errorDecayLengthXY()); registry.fill(HIST("h2_jet_pt_2prong_sigmaLxyz"), jet.pt(), prong.errorDecayLength()); } @@ -892,7 +885,7 @@ struct JetTaggerHFQA { auto massSV = bjetCand.m(); registry.fill(HIST("h2_jet_pt_2prong_Sxy_N1"), jet.pt(), maxSxy); registry.fill(HIST("h2_jet_pt_2prong_mass_N1"), jet.pt(), massSV); - if (jet.flagtaggedjetSV()) { + if (jet.isTagged(BJetTaggingMethod::SV)) { registry.fill(HIST("h2_taggedjet_pt_2prong_Sxy_N1"), jet.pt(), maxSxy); registry.fill(HIST("h2_taggedjet_pt_2prong_mass_N1"), jet.pt(), massSV); } @@ -903,7 +896,7 @@ struct JetTaggerHFQA { auto massSV = bjetCandXYZ.m(); registry.fill(HIST("h2_jet_pt_2prong_Sxyz_N1"), jet.pt(), maxSxyz); registry.fill(HIST("h2_jet_pt_2prong_mass_xyz_N1"), jet.pt(), massSV); - if (jet.flagtaggedjetSVxyz()) { + if (jet.isTagged(BJetTaggingMethod::SV3D)) { registry.fill(HIST("h2_taggedjet_pt_2prong_Sxyz_N1"), jet.pt(), maxSxyz); registry.fill(HIST("h2_taggedjet_pt_2prong_mass_xyz_N1"), jet.pt(), massSV); } @@ -920,17 +913,18 @@ struct JetTaggerHFQA { } if (jet.template secondaryVertices_as().size() < 1) return; + if (!doprocessIPsData && !doprocessJPData && !doprocessSV2ProngData) { + registry.fill(HIST("h_jet_pt"), jet.pt(), eventWeight); + registry.fill(HIST("h_jet_eta"), jet.eta(), eventWeight); + registry.fill(HIST("h_jet_phi"), jet.phi(), eventWeight); + } if (fillGeneralSVQA) { registry.fill(HIST("h_3prong_nprongs"), jet.template secondaryVertices_as().size()); for (const auto& prong : jet.template secondaryVertices_as()) { - auto Lxy = prong.decayLengthXY(); - auto Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); - auto Lxyz = prong.decayLength(); - auto Sxyz = prong.decayLength() / prong.errorDecayLength(); - registry.fill(HIST("h2_jet_pt_3prong_Lxy"), jet.pt(), Lxy); - registry.fill(HIST("h2_jet_pt_3prong_Sxy"), jet.pt(), Sxy); - registry.fill(HIST("h2_jet_pt_3prong_Lxyz"), jet.pt(), Lxyz); - registry.fill(HIST("h2_jet_pt_3prong_Sxyz"), jet.pt(), Sxyz); + registry.fill(HIST("h2_jet_pt_3prong_Lxy"), jet.pt(), prong.decayLengthXY()); + registry.fill(HIST("h2_jet_pt_3prong_Sxy"), jet.pt(), prong.decayLengthXY() / prong.errorDecayLengthXY()); + registry.fill(HIST("h2_jet_pt_3prong_Lxyz"), jet.pt(), prong.decayLength()); + registry.fill(HIST("h2_jet_pt_3prong_Sxyz"), jet.pt(), prong.decayLength() / prong.errorDecayLength()); registry.fill(HIST("h2_jet_pt_3prong_sigmaLxy"), jet.pt(), prong.errorDecayLengthXY()); registry.fill(HIST("h2_jet_pt_3prong_sigmaLxyz"), jet.pt(), prong.errorDecayLength()); } @@ -942,7 +936,7 @@ struct JetTaggerHFQA { auto massSV = bjetCand.m(); registry.fill(HIST("h2_jet_pt_3prong_Sxy_N1"), jet.pt(), maxSxy); registry.fill(HIST("h2_jet_pt_3prong_mass_N1"), jet.pt(), massSV); - if (jet.flagtaggedjetSV()) { + if (jet.isTagged(BJetTaggingMethod::SV)) { registry.fill(HIST("h2_taggedjet_pt_3prong_Sxy_N1"), jet.pt(), maxSxy); registry.fill(HIST("h2_taggedjet_pt_3prong_mass_N1"), jet.pt(), massSV); } @@ -953,7 +947,7 @@ struct JetTaggerHFQA { auto massSV = bjetCandXYZ.m(); registry.fill(HIST("h2_jet_pt_3prong_Sxyz_N1"), jet.pt(), maxSxyz); registry.fill(HIST("h2_jet_pt_3prong_mass_xyz_N1"), jet.pt(), massSV); - if (jet.flagtaggedjetSVxyz()) { + if (jet.isTagged(BJetTaggingMethod::SV3D)) { registry.fill(HIST("h2_taggedjet_pt_3prong_Sxyz_N1"), jet.pt(), maxSxyz); registry.fill(HIST("h2_taggedjet_pt_3prong_mass_xyz_N1"), jet.pt(), massSV); } @@ -970,17 +964,18 @@ struct JetTaggerHFQA { auto origin = mcdjet.origin(); if (mcdjet.template secondaryVertices_as().size() < 1) return; + if (!((doprocessIPsMCD || doprocessIPsMCDWeighted || doprocessIPsMCPMCDMatched || doprocessIPsMCPMCDMatchedWeighted) && (doprocessJPMCD || doprocessJPMCDWeighted || doprocessJPMCPMCDMatched || doprocessJPMCPMCDMatchedWeighted) && (doprocessSV3ProngMCD || doprocessSV3ProngMCDWeighted || doprocessSV3ProngMCPMCDMatched || doprocessSV3ProngMCPMCDMatchedWeighted))) { + registry.fill(HIST("h2_jet_pt_flavour"), mcdjet.pt(), origin, eventWeight); + registry.fill(HIST("h2_jet_eta_flavour"), mcdjet.eta(), origin, eventWeight); + registry.fill(HIST("h2_jet_phi_flavour"), mcdjet.phi(), origin, eventWeight); + } if (fillGeneralSVQA) { registry.fill(HIST("h2_2prong_nprongs_flavour"), mcdjet.template secondaryVertices_as().size(), origin, eventWeight); for (const auto& prong : mcdjet.template secondaryVertices_as()) { - auto Lxy = prong.decayLengthXY(); - auto Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); - auto Lxyz = prong.decayLength(); - auto Sxyz = prong.decayLength() / prong.errorDecayLength(); - registry.fill(HIST("h3_jet_pt_2prong_Lxy_flavour"), mcdjet.pt(), Lxy, origin, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_Sxy_flavour"), mcdjet.pt(), Sxy, origin, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_Lxyz_flavour"), mcdjet.pt(), Lxyz, origin, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_Sxyz_flavour"), mcdjet.pt(), Sxyz, origin, eventWeight); + registry.fill(HIST("h3_jet_pt_2prong_Lxy_flavour"), mcdjet.pt(), prong.decayLengthXY(), origin, eventWeight); + registry.fill(HIST("h3_jet_pt_2prong_Sxy_flavour"), mcdjet.pt(), prong.decayLengthXY() / prong.errorDecayLengthXY(), origin, eventWeight); + registry.fill(HIST("h3_jet_pt_2prong_Lxyz_flavour"), mcdjet.pt(), prong.decayLength(), origin, eventWeight); + registry.fill(HIST("h3_jet_pt_2prong_Sxyz_flavour"), mcdjet.pt(), prong.decayLength() / prong.errorDecayLength(), origin, eventWeight); registry.fill(HIST("h3_jet_pt_2prong_sigmaLxy_flavour"), mcdjet.pt(), prong.errorDecayLengthXY(), origin, eventWeight); registry.fill(HIST("h3_jet_pt_2prong_sigmaLxyz_flavour"), mcdjet.pt(), prong.errorDecayLength(), origin, eventWeight); } @@ -992,7 +987,7 @@ struct JetTaggerHFQA { auto massSV = bjetCand.m(); registry.fill(HIST("h3_jet_pt_2prong_Sxy_N1_flavour"), mcdjet.pt(), maxSxy, origin, eventWeight); registry.fill(HIST("h3_jet_pt_2prong_mass_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); - if (mcdjet.flagtaggedjetSV()) { + if (mcdjet.isTagged(BJetTaggingMethod::SV)) { registry.fill(HIST("h3_taggedjet_pt_2prong_Sxy_N1_flavour"), mcdjet.pt(), maxSxy, origin, eventWeight); registry.fill(HIST("h3_taggedjet_pt_2prong_mass_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); } @@ -1003,69 +998,16 @@ struct JetTaggerHFQA { auto massSV = bjetCandXYZ.m(); registry.fill(HIST("h3_jet_pt_2prong_Sxyz_N1_flavour"), mcdjet.pt(), maxSxyz, origin, eventWeight); registry.fill(HIST("h3_jet_pt_2prong_mass_xyz_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); - if (mcdjet.flagtaggedjetSVxyz()) { + if (mcdjet.isTagged(BJetTaggingMethod::SV3D)) { registry.fill(HIST("h3_taggedjet_pt_2prong_Sxyz_N1_flavour"), mcdjet.pt(), maxSxyz, origin, eventWeight); registry.fill(HIST("h3_taggedjet_pt_2prong_mass_xyz_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); } } } - template - void fillHistogramSV2ProngMCPMCDMatched(T const& mcdjet, U const& /*mcpjets*/, V const& /*prongs*/, W const& particlesPerColl, float eventWeight = 1.0) - { - float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); - if (mcdjet.pt() > pTHatMaxMCD * pTHat) { - return; - } - int jetflavourRun2Def = -1; - for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { - jetflavourRun2Def = jettaggingutilities::getJetFlavor(mcpjet, particlesPerColl); - } - if (jetflavourRun2Def < 0) - return; - if (mcdjet.template secondaryVertices_as().size() < 1) - return; - for (const auto& prong : mcdjet.template secondaryVertices_as()) { - auto Lxy = prong.decayLengthXY(); - auto Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); - auto Lxyz = prong.decayLength(); - auto Sxyz = prong.decayLength() / prong.errorDecayLength(); - registry.fill(HIST("h3_jet_pt_2prong_Lxy_flavour_run2"), mcdjet.pt(), Lxy, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_Sxy_flavour_run2"), mcdjet.pt(), Sxy, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_Lxyz_flavour_run2"), mcdjet.pt(), Lxyz, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_Sxyz_flavour_run2"), mcdjet.pt(), Sxyz, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_sigmaLxy_flavour_run2"), mcdjet.pt(), prong.errorDecayLengthXY(), jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_sigmaLxyz_flavour_run2"), mcdjet.pt(), prong.errorDecayLength(), jetflavourRun2Def, eventWeight); - } - bool checkSv = false; - auto bjetCand = jettaggingutilities::jetFromProngMaxDecayLength(mcdjet, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, false, &checkSv); - if (checkSv && jettaggingutilities::svAcceptance(bjetCand, svDispersionMax)) { - auto maxSxy = bjetCand.decayLengthXY() / bjetCand.errorDecayLengthXY(); - auto massSV = bjetCand.m(); - registry.fill(HIST("h3_jet_pt_2prong_Sxy_N1_flavour_run2"), mcdjet.pt(), maxSxy, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_mass_N1_flavour_run2"), mcdjet.pt(), massSV, jetflavourRun2Def, eventWeight); - if (mcdjet.flagtaggedjetSV()) { - registry.fill(HIST("h3_taggedjet_pt_2prong_Sxy_N1_flavour_run2"), mcdjet.pt(), maxSxy, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_taggedjet_pt_2prong_mass_N1_flavour_run2"), mcdjet.pt(), massSV, jetflavourRun2Def, eventWeight); - } - } - auto bjetCandXYZ = jettaggingutilities::jetFromProngMaxDecayLength(mcdjet, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyzMax, prongIPxyMin, prongIPxyMax, true, &checkSv); - if (checkSv && jettaggingutilities::svAcceptance(bjetCand, svDispersionMax)) { - auto maxSxyz = bjetCandXYZ.decayLength() / bjetCandXYZ.errorDecayLength(); - auto massSV = bjetCandXYZ.m(); - registry.fill(HIST("h3_jet_pt_2prong_Sxyz_N1_flavour_run2"), mcdjet.pt(), maxSxyz, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_2prong_mass_xyz_N1_flavour_run2"), mcdjet.pt(), massSV, jetflavourRun2Def, eventWeight); - if (mcdjet.flagtaggedjetSVxyz()) { - registry.fill(HIST("h3_taggedjet_pt_2prong_Sxyz_N1_flavour_run2"), mcdjet.pt(), maxSxyz, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_taggedjet_pt_2prong_mass_xyz_N1_flavour_run2"), mcdjet.pt(), massSV, jetflavourRun2Def, eventWeight); - } - } - } - template void fillHistogramSV3ProngMCD(T const& mcdjet, U const& /*prongs*/, float eventWeight = 1.0) { - // std::cout << "weight: " << eventWeight << std::endl; float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); if (mcdjet.pt() > pTHatMaxMCD * pTHat) { return; @@ -1073,17 +1015,18 @@ struct JetTaggerHFQA { auto origin = mcdjet.origin(); if (mcdjet.template secondaryVertices_as().size() < 1) return; + if (!((doprocessIPsMCD || doprocessIPsMCDWeighted || doprocessIPsMCPMCDMatched || doprocessIPsMCPMCDMatchedWeighted) && (doprocessJPMCD || doprocessJPMCDWeighted || doprocessJPMCPMCDMatched || doprocessJPMCPMCDMatchedWeighted) && (doprocessSV2ProngMCD || doprocessSV2ProngMCDWeighted || doprocessSV2ProngMCPMCDMatched || doprocessSV2ProngMCPMCDMatchedWeighted))) { + registry.fill(HIST("h2_jet_pt_flavour"), mcdjet.pt(), origin, eventWeight); + registry.fill(HIST("h2_jet_eta_flavour"), mcdjet.eta(), origin, eventWeight); + registry.fill(HIST("h2_jet_phi_flavour"), mcdjet.phi(), origin, eventWeight); + } if (fillGeneralSVQA) { registry.fill(HIST("h2_3prong_nprongs_flavour"), mcdjet.template secondaryVertices_as().size(), origin); for (const auto& prong : mcdjet.template secondaryVertices_as()) { - auto Lxy = prong.decayLengthXY(); - auto Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); - auto Lxyz = prong.decayLength(); - auto Sxyz = prong.decayLength() / prong.errorDecayLength(); - registry.fill(HIST("h3_jet_pt_3prong_Lxy_flavour"), mcdjet.pt(), Lxy, origin, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_Sxy_flavour"), mcdjet.pt(), Sxy, origin, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_Lxyz_flavour"), mcdjet.pt(), Lxyz, origin, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_Sxyz_flavour"), mcdjet.pt(), Sxyz, origin, eventWeight); + registry.fill(HIST("h3_jet_pt_3prong_Lxy_flavour"), mcdjet.pt(), prong.decayLengthXY(), origin, eventWeight); + registry.fill(HIST("h3_jet_pt_3prong_Sxy_flavour"), mcdjet.pt(), prong.decayLengthXY() / prong.errorDecayLengthXY(), origin, eventWeight); + registry.fill(HIST("h3_jet_pt_3prong_Lxyz_flavour"), mcdjet.pt(), prong.decayLength(), origin, eventWeight); + registry.fill(HIST("h3_jet_pt_3prong_Sxyz_flavour"), mcdjet.pt(), prong.decayLength() / prong.errorDecayLength(), origin, eventWeight); registry.fill(HIST("h3_jet_pt_3prong_sigmaLxy_flavour"), mcdjet.pt(), prong.errorDecayLengthXY(), origin, eventWeight); registry.fill(HIST("h3_jet_pt_3prong_sigmaLxyz_flavour"), mcdjet.pt(), prong.errorDecayLength(), origin, eventWeight); } @@ -1095,7 +1038,7 @@ struct JetTaggerHFQA { auto massSV = bjetCand.m(); registry.fill(HIST("h3_jet_pt_3prong_Sxy_N1_flavour"), mcdjet.pt(), maxSxy, origin, eventWeight); registry.fill(HIST("h3_jet_pt_3prong_mass_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); - if (mcdjet.flagtaggedjetSV()) { + if (mcdjet.isTagged(BJetTaggingMethod::SV)) { registry.fill(HIST("h3_taggedjet_pt_3prong_Sxy_N1_flavour"), mcdjet.pt(), maxSxy, origin, eventWeight); registry.fill(HIST("h3_taggedjet_pt_3prong_mass_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); } @@ -1106,158 +1049,148 @@ struct JetTaggerHFQA { auto massSV = bjetCandXYZ.m(); registry.fill(HIST("h3_jet_pt_3prong_Sxyz_N1_flavour"), mcdjet.pt(), maxSxyz, origin, eventWeight); registry.fill(HIST("h3_jet_pt_3prong_mass_xyz_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); - if (mcdjet.flagtaggedjetSV()) { + if (mcdjet.isTagged(BJetTaggingMethod::SV3D)) { registry.fill(HIST("h3_taggedjet_pt_3prong_Sxyz_N1_flavour"), mcdjet.pt(), maxSxyz, origin, eventWeight); registry.fill(HIST("h3_taggedjet_pt_3prong_mass_xyz_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); } } } - template - void fillHistogramSV3ProngMCPMCDMatched(T const& mcdjet, U const& /*mcpjets*/, V const& /*prongs*/, W const& particlesPerColl, float eventWeight = 1.0) - { - float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); - if (mcdjet.pt() > pTHatMaxMCD * pTHat) { - return; - } - int jetflavourRun2Def = -1; - for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { - jetflavourRun2Def = jettaggingutilities::getJetFlavor(mcpjet, particlesPerColl); - } - if (jetflavourRun2Def < 0) - return; - if (mcdjet.template secondaryVertices_as().size() < 1) - return; - if (fillGeneralSVQA) { - for (const auto& prong : mcdjet.template secondaryVertices_as()) { - auto Lxy = prong.decayLengthXY(); - auto Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); - auto Lxyz = prong.decayLength(); - auto Sxyz = prong.decayLength() / prong.errorDecayLength(); - registry.fill(HIST("h3_jet_pt_3prong_Lxy_flavour_run2"), mcdjet.pt(), Lxy, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_Sxy_flavour_run2"), mcdjet.pt(), Sxy, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_Lxyz_flavour_run2"), mcdjet.pt(), Lxyz, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_Sxyz_flavour_run2"), mcdjet.pt(), Sxyz, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_sigmaLxy_flavour_run2"), mcdjet.pt(), prong.errorDecayLengthXY(), jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_sigmaLxyz_flavour_run2"), mcdjet.pt(), prong.errorDecayLength(), jetflavourRun2Def, eventWeight); - } - } - bool checkSv = false; - auto bjetCand = jettaggingutilities::jetFromProngMaxDecayLength(mcdjet, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, false, &checkSv); - if (checkSv && jettaggingutilities::svAcceptance(bjetCand, svDispersionMax)) { - auto maxSxy = bjetCand.decayLengthXY() / bjetCand.errorDecayLengthXY(); - auto massSV = bjetCand.m(); - registry.fill(HIST("h3_jet_pt_3prong_Sxy_N1_flavour_run2"), mcdjet.pt(), maxSxy, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_mass_N1_flavour_run2"), mcdjet.pt(), massSV, jetflavourRun2Def, eventWeight); - if (mcdjet.flagtaggedjetSV()) { - registry.fill(HIST("h3_taggedjet_pt_3prong_Sxy_N1_flavour_run2"), mcdjet.pt(), maxSxy, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_taggedjet_pt_3prong_mass_N1_flavour_run2"), mcdjet.pt(), massSV, jetflavourRun2Def, eventWeight); - } - } - auto bjetCandXYZ = jettaggingutilities::jetFromProngMaxDecayLength(mcdjet, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyzMax, prongIPxyMin, prongIPxyMax, true, &checkSv); - if (checkSv && jettaggingutilities::svAcceptance(bjetCand, svDispersionMax)) { - auto maxSxyz = bjetCandXYZ.decayLength() / bjetCandXYZ.errorDecayLength(); - auto massSV = bjetCand.m(); - registry.fill(HIST("h3_jet_pt_3prong_Sxyz_N1_flavour_run2"), mcdjet.pt(), maxSxyz, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_jet_pt_3prong_mass_xyz_N1_flavour_run2"), mcdjet.pt(), massSV, jetflavourRun2Def, eventWeight); - if (mcdjet.flagtaggedjetSVxyz()) { - registry.fill(HIST("h3_taggedjet_pt_3prong_Sxyz_N1_flavour_run2"), mcdjet.pt(), maxSxyz, jetflavourRun2Def, eventWeight); - registry.fill(HIST("h3_taggedjet_pt_3prong_mass_xyz_N1_flavour_run2"), mcdjet.pt(), massSV, jetflavourRun2Def, eventWeight); - } - } - } - void processDummy(aod::Collision const&, aod::Tracks const&) { } PROCESS_SWITCH(JetTaggerHFQA, processDummy, "Dummy process", true); - void processTracksDca(JetTagTracksData& jtracks) + void processTracksDca(JetTagTracksData const& tracks) { - for (auto const& jtrack : jtracks) { - if (!jetderiveddatautilities::selectTrack(jtrack, trackSelection)) { + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } float varImpXY, varImpXYSig, varImpZ, varImpZSig, varImpXYZ, varImpXYZSig; - varImpXY = jtrack.dcaXY() * jettaggingutilities::cmTomum; - varImpXYSig = jtrack.dcaXY() / jtrack.sigmadcaXY(); - varImpZ = jtrack.dcaZ() * jettaggingutilities::cmTomum; - varImpZSig = jtrack.dcaZ() / jtrack.sigmadcaZ(); - float dcaXYZ = jtrack.dcaXYZ(); - float sigmadcaXYZ = jtrack.sigmadcaXYZ(); + varImpXY = track.dcaXY() * jettaggingutilities::cmTomum; + varImpXYSig = track.dcaXY() / track.sigmadcaXY(); + varImpZ = track.dcaZ() * jettaggingutilities::cmTomum; + varImpZSig = track.dcaZ() / track.sigmadcaZ(); + float dcaXYZ = track.dcaXYZ(); + float sigmadcaXYZ = track.sigmadcaXYZ(); varImpXYZ = dcaXYZ * jettaggingutilities::cmTomum; varImpXYZSig = dcaXYZ / sigmadcaXYZ; - registry.fill(HIST("h_impact_parameter_xy"), varImpXY); - registry.fill(HIST("h_impact_parameter_xy_significance"), varImpXYSig); - registry.fill(HIST("h_impact_parameter_z"), varImpZ); - registry.fill(HIST("h_impact_parameter_z_significance"), varImpZSig); - registry.fill(HIST("h_impact_parameter_xyz"), varImpXYZ); - registry.fill(HIST("h_impact_parameter_xyz_significance"), varImpXYZSig); + if (fillIPxy) { + registry.fill(HIST("h_impact_parameter_xy"), varImpXY); + registry.fill(HIST("h_impact_parameter_xy_significance"), varImpXYSig); + } + if (fillIPz) { + registry.fill(HIST("h_impact_parameter_z"), varImpZ); + registry.fill(HIST("h_impact_parameter_z_significance"), varImpZSig); + } + if (fillIPxyz) { + registry.fill(HIST("h_impact_parameter_xyz"), varImpXYZ); + registry.fill(HIST("h_impact_parameter_xyz_significance"), varImpXYZSig); + } } } PROCESS_SWITCH(JetTaggerHFQA, processTracksDca, "Fill inclusive tracks' imformation for data", false); - void processIPsData(soa::Filtered::iterator const& collision, soa::Join const& jets, JetTagTracksData const& jtracks) + void processValFlavourDefMCD(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, JetTagTracksMCD const& tracks, aod::JetParticles const& particles) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto const& mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillValidationFlavourDefMCD>(mcdjet, tracks, particles, particlesPerColl, mcdjet.eventWeight()); + } + } + PROCESS_SWITCH(JetTaggerHFQA, processValFlavourDefMCD, "to check the validation of jet-flavour definition when compared to distance for mcd jets", false); + + void processValFlavourDefMCP(soa::Join const& mcpjets, aod::JetParticles const& particles, aod::JetMcCollisions const&) + { + for (auto const& mcpjet : mcpjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, mcpjet.globalIndex()); + if (!jetfindingutilities::isInEtaAcceptance(mcpjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcpjet)) { + continue; + } + int eventWeight = mcpjet.eventWeight(); + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (mcpjet.pt() > pTHatMaxMCD * pTHat) { + return; + } + fillValidationFlavourDefMCP(mcpjet, particles, particlesPerColl); + } + } + PROCESS_SWITCH(JetTaggerHFQA, processValFlavourDefMCP, "to check the validation of jet-flavour definition when compared to distance for mcp jets", false); + + void processIPsData(soa::Filtered::iterator const& collision, soa::Join const& jets, JetTagTracksData const& tracks) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto jet : jets) { + for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(jet)) { continue; } - fillHistogramIPsData(jet, jtracks); + fillHistogramIPsData(jet, tracks); } } PROCESS_SWITCH(JetTaggerHFQA, processIPsData, "Fill impact parameter imformation for data jets", false); - void processIPsMCD(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, JetTagTracksMCD const& jtracks, aod::JetParticles&) + void processIPsMCD(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, JetTagTracksMCD const& tracks, aod::JetParticles const&) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(mcdjet)) { continue; } - fillHistogramIPsMCD(mcdjet, jtracks); + fillHistogramIPsMCD(mcdjet, tracks); } } PROCESS_SWITCH(JetTaggerHFQA, processIPsMCD, "Fill impact parameter imformation for mcd jets", false); - void processIPsMCDWeighted(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, JetTagTracksMCD const& jtracks, aod::JetParticles&) + void processIPsMCDWeighted(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, JetTagTracksMCD const& tracks, aod::JetParticles const&) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - fillHistogramIPsMCD(mcdjet, jtracks, mcdjet.eventWeight()); + fillHistogramIPsMCD(mcdjet, tracks, mcdjet.eventWeight()); } } PROCESS_SWITCH(JetTaggerHFQA, processIPsMCDWeighted, "Fill impact parameter imformation for mcd jets", false); - void processIPsMCP(soa::Join const& mcpjets, aod::JetParticles&, aod::JetMcCollisions const&, soa::Filtered const& collisions) + void processIPsMCP(JetTableMCP const& mcpjets, aod::JetParticles const&, aod::JetMcCollisions const&, soa::Filtered const& collisions) { - for (auto mcpjet : mcpjets) { + for (auto const& mcpjet : mcpjets) { if (!jetfindingutilities::isInEtaAcceptance(mcpjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(mcpjet)) { - return; + continue; } if (checkMcCollisionIsMatched) { - auto collisionspermcpjet = collisions.sliceBy(CollisionsPerMCPCollision, mcpjet.mcCollisionId()); - if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelection)) { + auto collisionspermcpjet = collisions.sliceBy(collisionsPerMCPCollision, mcpjet.mcCollisionId()); + if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelectionBits)) { fillHistogramIPsMCP(mcpjet); } } else { @@ -1267,33 +1200,33 @@ struct JetTaggerHFQA { } PROCESS_SWITCH(JetTaggerHFQA, processIPsMCP, "Fill impact parameter imformation for mcp jets", false); - void processIPsMCPWeighted(soa::Filtered const& collisions, soa::Join const& mcpjets, aod::JetParticles&) + void processIPsMCPWeighted(soa::Join const& mcpjets, soa::Filtered const& collisions, aod::JetParticles const&) { - for (auto mcpjet : mcpjets) { + for (auto const& mcpjet : mcpjets) { if (!jetfindingutilities::isInEtaAcceptance(mcpjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(mcpjet)) { - return; + continue; } if (checkMcCollisionIsMatched) { - auto collisionspermcpjet = collisions.sliceBy(CollisionsPerMCPCollision, mcpjet.mcCollisionId()); - if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelection)) { - fillHistogramIPsMCP(mcpjet, mcpjet.eventWeight()); - } else { + auto collisionspermcpjet = collisions.sliceBy(collisionsPerMCPCollision, mcpjet.mcCollisionId()); + if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelectionBits)) { fillHistogramIPsMCP(mcpjet, mcpjet.eventWeight()); } + } else { + fillHistogramIPsMCP(mcpjet, mcpjet.eventWeight()); } } } PROCESS_SWITCH(JetTaggerHFQA, processIPsMCPWeighted, "Fill impact parameter imformation for mcp jets weighted", false); - void processIPsMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& mcpjets, JetTagTracksMCD const& jtracks, aod::JetParticles& particles) + void processIPsMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, JetTagTracksMCD const& tracks, aod::JetParticles const& particles) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto& mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; @@ -1301,17 +1234,23 @@ struct JetTaggerHFQA { if (!isAcceptedJet(mcdjet)) { continue; } - fillHistogramIPsMatched(mcdjet, mcpjets, jtracks, particlesPerColl); + if (!mcdjet.has_matchedJetGeo()) + continue; + for (auto const& mcpjet : mcdjet.template matchedJetGeo_as>()) { + registry.fill(HIST("h3_jet_pt_jet_pt_part_matchedgeo_flavour"), mcdjet.pt(), mcpjet.pt(), mcdjet.origin()); + } + if (!doprocessIPsMCD) + fillHistogramIPsMCD(mcdjet, tracks); } } PROCESS_SWITCH(JetTaggerHFQA, processIPsMCPMCDMatched, "Fill impact parameter imformation for mcp mcd matched jets", false); - void processIPsMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& mcpjets, JetTagTracksMCD const& jtracks, aod::JetParticles& particles) + void processIPsMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, JetTagTracksMCD const& tracks, aod::JetParticles const& particles) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto& mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; @@ -1319,7 +1258,20 @@ struct JetTaggerHFQA { if (!isAcceptedJet(mcdjet)) { continue; } - fillHistogramIPsMatched(mcdjet, mcpjets, jtracks, particlesPerColl, mcdjet.eventWeight()); + if (!mcdjet.has_matchedJetGeo()) + continue; + float pTHat = 10. / (std::pow(mcdjet.eventWeight(), 1.0 / pTHatExponent)); + if (mcdjet.pt() > pTHatMaxMCD * pTHat) { + continue; + } + for (auto const& mcpjet : mcdjet.template matchedJetGeo_as>()) { + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { + continue; + } + registry.fill(HIST("h3_jet_pt_jet_pt_part_matchedgeo_flavour"), mcdjet.pt(), mcpjet.pt(), mcdjet.origin(), mcdjet.eventWeight()); + } + if (!doprocessIPsMCDWeighted) + fillHistogramIPsMCD(mcdjet, tracks, mcdjet.eventWeight()); } } PROCESS_SWITCH(JetTaggerHFQA, processIPsMCPMCDMatchedWeighted, "Fill impact parameter imformation for mcp mcd matched jets", false); @@ -1329,7 +1281,7 @@ struct JetTaggerHFQA { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto jet : jets) { + for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } @@ -1346,7 +1298,7 @@ struct JetTaggerHFQA { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } @@ -1363,7 +1315,7 @@ struct JetTaggerHFQA { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } @@ -1375,38 +1327,42 @@ struct JetTaggerHFQA { } PROCESS_SWITCH(JetTaggerHFQA, processJPMCDWeighted, "Fill jet probability imformation for mcd jets", false); - void processJPMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& mcpjets, JetTagTracksMCD const&, aod::JetParticles& particles) + void processJPMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, JetTagTracksMCD const&) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { - auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(mcdjet)) { continue; } - fillHistogramJPMatched(mcdjet, mcpjets, particlesPerColl); + if (!mcdjet.has_matchedJetGeo()) + return; + if (!doprocessJPMCD) + fillHistogramJPMCD(mcdjet); } } PROCESS_SWITCH(JetTaggerHFQA, processJPMCPMCDMatched, "Fill jet probability imformation for mcd jets", false); - void processJPMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& mcpjets, JetTagTracksMCD const&, aod::JetParticles& particles) + void processJPMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, JetTagTracksMCD const&) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { - auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(mcdjet)) { continue; } - fillHistogramJPMatched(mcdjet, mcpjets, particlesPerColl, mcdjet.eventWeight()); + if (!mcdjet.has_matchedJetGeo()) + return; + if (!doprocessJPMCDWeighted) + fillHistogramJPMCD(mcdjet, mcdjet.eventWeight()); } } PROCESS_SWITCH(JetTaggerHFQA, processJPMCPMCDMatchedWeighted, "Fill jet probability imformation for mcd jets", false); @@ -1416,7 +1372,7 @@ struct JetTaggerHFQA { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto jet : jets) { + for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } @@ -1433,7 +1389,7 @@ struct JetTaggerHFQA { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto jet : jets) { + for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } @@ -1450,7 +1406,7 @@ struct JetTaggerHFQA { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } @@ -1467,7 +1423,7 @@ struct JetTaggerHFQA { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } @@ -1479,48 +1435,54 @@ struct JetTaggerHFQA { } PROCESS_SWITCH(JetTaggerHFQA, processSV2ProngMCDWeighted, "Fill 2prong imformation for mcd jets", false); - void processSV2ProngMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& mcpjets, aod::MCDSecondaryVertex2Prongs const& prongs, aod::JetParticles& particles) + void processSV2ProngMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, aod::MCDSecondaryVertex2Prongs const& prongs) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { - auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(mcdjet)) { continue; } - fillHistogramSV2ProngMCPMCDMatched(mcdjet, mcpjets, prongs, particlesPerColl); + if (!mcdjet.has_matchedJetGeo()) { + continue; + } + if (!doprocessSV2ProngMCD) + fillHistogramSV2ProngMCD(mcdjet, prongs); } } PROCESS_SWITCH(JetTaggerHFQA, processSV2ProngMCPMCDMatched, "Fill 2prong imformation for mcd jets", false); - void processSV2ProngMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& mcpjets, aod::MCDSecondaryVertex2Prongs const& prongs, aod::JetParticles& particles) + void processSV2ProngMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, aod::MCDSecondaryVertex2Prongs const& prongs) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { - auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(mcdjet)) { continue; } - fillHistogramSV2ProngMCPMCDMatched(mcdjet, mcpjets, prongs, particlesPerColl, mcdjet.eventWeight()); + if (!mcdjet.has_matchedJetGeo()) { + continue; + } + if (!doprocessSV2ProngMCDWeighted) + fillHistogramSV2ProngMCD(mcdjet, prongs, mcdjet.eventWeight()); } } PROCESS_SWITCH(JetTaggerHFQA, processSV2ProngMCPMCDMatchedWeighted, "Fill 2prong imformation for mcd jets", false); - void processSV3ProngMCD(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, aod::MCDSecondaryVertex3Prongs const& prongs) + void processSV3ProngMCD(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, aod::MCDSecondaryVertex3Prongs const& prongs) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } @@ -1537,7 +1499,7 @@ struct JetTaggerHFQA { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } @@ -1549,65 +1511,57 @@ struct JetTaggerHFQA { } PROCESS_SWITCH(JetTaggerHFQA, processSV3ProngMCDWeighted, "Fill 3prong imformation for mcd jets", false); - void processSV3ProngMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& mcpjets, aod::MCDSecondaryVertex3Prongs const& prongs, aod::JetParticles& particles) + void processSV3ProngMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, aod::MCDSecondaryVertex3Prongs const& prongs) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { - auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(mcdjet)) { continue; } - fillHistogramSV3ProngMCPMCDMatched(mcdjet, mcpjets, prongs, particlesPerColl); + if (!mcdjet.has_matchedJetGeo()) { + continue; + } + if (!doprocessSV3ProngMCD) + fillHistogramSV3ProngMCD(mcdjet, prongs); } } PROCESS_SWITCH(JetTaggerHFQA, processSV3ProngMCPMCDMatched, "Fill 3prong imformation for mcd jets", false); - void processSV3ProngMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& mcpjets, aod::MCDSecondaryVertex3Prongs const& prongs, aod::JetParticles& particles) + void processSV3ProngMCPMCDMatchedWeighted(soa::Filtered>::iterator const& collision, soa::Join const& mcdjets, soa::Join const& /*mcpjets*/, aod::MCDSecondaryVertex3Prongs const& prongs) { if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } - for (auto mcdjet : mcdjets) { - auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + for (auto const& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } if (!isAcceptedJet(mcdjet)) { continue; } - fillHistogramSV3ProngMCPMCDMatched(mcdjet, mcpjets, prongs, particlesPerColl, mcdjet.eventWeight()); + if (!mcdjet.has_matchedJetGeo()) { + continue; + } + if (!doprocessSV3ProngMCDWeighted) + fillHistogramSV3ProngMCD(mcdjet, prongs, mcdjet.eventWeight()); } } PROCESS_SWITCH(JetTaggerHFQA, processSV3ProngMCPMCDMatchedWeighted, "Fill 3prong imformation for mcd jets", false); }; using JetTaggerQAChargedDataJets = soa::Join; -using JetTaggerQAChargedMCDJets = soa::Join; -using JetTaggerQAChargedMCPJets = soa::Join; +using JetTaggerQAChargedMCDJets = soa::Join; +using JetTaggerQAChargedMCPJets = soa::Join; -using JetTaggerQACharged = JetTaggerHFQA; +using JetTaggerhfQACharged = JetTaggerHFQA; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - - std::vector tasks; - - tasks.emplace_back( - adaptAnalysisTask(cfgc, - SetDefaultProcesses{}, TaskName{"jet-taggerhf-qa-charged"})); - /* - tasks.emplace_back( - adaptAnalysisTask(cfgc, - SetDefaultProcesses{}, TaskName{"jet-taggerhf-qa-full"})); - - tasks.emplace_back( - adaptAnalysisTask(cfgc, - SetDefaultProcesses{}, TaskName{"jet-taggerhf-qa-neutral"})); - */ - return WorkflowSpec{tasks}; + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"jet-taggerhf-qa-charged"})}; // o2-linter: disable=name/o2-task } diff --git a/PWGJE/Tasks/ChJetTriggerQATask.cxx b/PWGJE/Tasks/jetTriggerChargedQa.cxx similarity index 51% rename from PWGJE/Tasks/ChJetTriggerQATask.cxx rename to PWGJE/Tasks/jetTriggerChargedQa.cxx index 7b8331706bc..f1cb9309cd1 100644 --- a/PWGJE/Tasks/ChJetTriggerQATask.cxx +++ b/PWGJE/Tasks/jetTriggerChargedQa.cxx @@ -9,49 +9,44 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// jet Trigger QA Task -// -/// \author Filip Krizek -#include -#include -#include -#include -#include -#include +/// \author Filip Krizek +/// \author Kotliarov Artem +/// \file jetTriggerChargedQa.cxx +/// \brief QA of trigger performance for charged jets -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" - -#include "EventFiltering/filterTables.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/EMCALClusters.h" #include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/DataModel/EventSelection.h" +#include "CommonConstants/MathConstants.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include + +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using filteredColl = soa::Filtered>::iterator; -using filteredJTracks = soa::Filtered>; -using filteredJets = soa::Filtered>; -using joinedTracks = soa::Join; +using FilteredColl = soa::Filtered>::iterator; +using FilteredJTracks = soa::Filtered>; +using FilteredJets = soa::Filtered>; +using JoinedTracks = soa::Join; -float DcaXYPtCut(float tracPt) +float dcaXYPtCut(float tracPt) { - return 0.0105f + 0.0350f / pow(tracPt, 1.1f); + return 0.0105f + 0.0350f / std::pow(tracPt, 1.1f); } // What this task should do @@ -64,7 +59,7 @@ float DcaXYPtCut(float tracPt) // b) from events selected by EPN // It would be good to run it for several jet radii e.g. 0.2, 0.4, 0.6 -struct ChJetTriggerQATask { +struct JetTriggerChargedQa { Configurable evSel{"evSel", "sel8", "choose event selection"}; Configurable cfgVertexCut{"cfgVertexCut", 10.0, "Accepted z-vertex range"}; @@ -80,73 +75,78 @@ struct ChJetTriggerQATask { Configurable bHighPtTrigger{"bHighPtTrigger", false, "charged jet high pT trigger selection"}; Configurable bTrackLowPtTrigger{"bTrackLowPtTrigger", false, "track low pT trigger selection"}; Configurable bTrackHighPtTrigger{"bTrackHighPtTrigger", false, "track high pT trigger selection"}; - Configurable bAddSupplementHistosToOutput{"bAddAdditionalHistosToOutput", false, "add supplementary histos to the output"}; + Configurable bAddSupplementHistosToOutput{"bAddSupplementHistosToOutput", false, "add supplementary histos to the output"}; + Configurable bStudyPhiTrack{"bStudyPhiTrack", false, "add histos for detailed study of track phi distribution"}; Configurable phiAngleRestriction{"phiAngleRestriction", 0.3, "angle to restrict track phi for plotting tpc momentum"}; - Configurable dcaXY_multFact{"dcaXY_multFact", 3., "mult factor to relax pT dependent dcaXY cut for quality tracks"}; - Configurable dcaZ_cut{"dcaZ_cut", 3., "cut on dcaZ for quality tracks"}; + Configurable dcaXYMultFact{"dcaXYMultFact", 3., "mult factor to relax pT dependent dcaXY cut for quality tracks"}; + Configurable dcaZCut{"dcaZCut", 3., "cut on dcaZ for quality tracks"}; - ConfigurableAxis dcaXY_Binning{"dcaXY_Binning", {100, -5., 5.}, ""}; - ConfigurableAxis dcaZ_Binning{"dcaZ_Binning", {100, -3., 3.}, ""}; + float twoPi = constants::math::TwoPI; + ConfigurableAxis dcaXYBinning{"dcaXYBinning", {100, -5., 5.}, ""}; + ConfigurableAxis dcaZBinning{"dcaZBinning", {100, -3., 3.}, ""}; - ConfigurableAxis xPhiAxis{"xPhiAxis", {180, 0., TMath::TwoPi()}, ""}; + ConfigurableAxis xPhiAxis{"xPhiAxis", {40, 0., twoPi}, ""}; ConfigurableAxis yQ1pTAxis{"yQ1pTAxis", {200, -0.5, 0.5}, ""}; - float fiducialVolume; // 0.9 - jetR + float fiducialVolume = 0.0; // 0.9 - jetR HistogramRegistry spectra; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; void init(InitContext&) { fiducialVolume = static_cast(cfgTPCVolume) - static_cast(cfgJetR); - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(evSel)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(evSel)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); // Basic histos - spectra.add("vertexZ", "z vertex", {HistType::kTH1F, {{400, -20., +20.}}}); - spectra.add("ptphiTrackInclGood", "pT vs phi inclusive good tracks", {HistType::kTH2F, {{100, 0., +100.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("ptetaTrackInclGood", "pT vs eta inclusive good tracks", {HistType::kTH2F, {{100, 0., +100.}, {80, -1., 1.}}}); - spectra.add("ptLeadingTrack", "pT leading track", {HistType::kTH1F, {{100, 0., +100.}}}); - spectra.add("ptJetChInclFidVol", "inclusive charged jet pT in fiducial volume", {HistType::kTH1F, {{200, 0., +200.}}}); - spectra.add("ptphiJetChInclFidVol", "inclusive charged jet pT vs phi in fiducial volume", {HistType::kTH2F, {{100, 0., +100.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("ptphiJetChInclFullVol", "inclusive charged jet pT vs phi in full TPC volume", {HistType::kTH2F, {{100, 0., +100.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("ptetaJetChInclFidVol", "inclusive charged jet pT vs eta in fiducial volume", {HistType::kTH2F, {{100, 0., +100.}, {80, -1., 1.}}}); - spectra.add("ptetaJetChInclFullVol", "inclusive charged jet pT vs eta in full TPC volume", {HistType::kTH2F, {{100, 0., +100.}, {80, -1., 1.}}}); - spectra.add("ptetaLeadingJetFullVol", "pT vs eta leading jet", {HistType::kTH2F, {{100, 0., +100.}, {80, -1., 1.}}}); - spectra.add("ptphiLeadingJetFullVol", "pT vs phi leading jet", {HistType::kTH2F, {{100, 0., +100.}, {60, 0, TMath::TwoPi()}}}); - - spectra.add("globalP_tpcglobalPDiff_withoutcuts", "difference of global and TPC inner momentum vs global momentum without any selection applied", {HistType::kTH2F, {{100, 0., +100.}, {200, -100., +100.}}}); - spectra.add("globalP_tpcglobalPDiff", "difference of global and TPC inner momentum vs global momentum with selection applied", {HistType::kTH2F, {{100, 0., +100.}, {200, -100., +100.}}}); - spectra.add("global1overP_tpcglobalPDiff", "difference of global and TPC inner momentum vs global momentum with selection applied", {HistType::kTH2F, {{100, 0., +100.}, {500, -8., +8.}}}); - - spectra.add("globalP_tpcglobalPDiff_withoutcuts_phirestrict", "difference of global and TPC inner momentum vs global momentum without any selection applied in a restricted phi", {HistType::kTH2F, {{100, 0., +100.}, {200, -100., +100.}}}); - spectra.add("globalP_tpcglobalPDiff_phirestrict", "difference of global and TPC inner momentum vs global momentum with selection applied restricted phi", {HistType::kTH2F, {{100, 0., +100.}, {200, -100., +100.}}}); - spectra.add("global1overP_tpcglobalPDiff_phirestrict", "difference of 1/p global and TPC inner momentum vs global momentum with selection applied restricted phi", {HistType::kTH2F, {{100, 0., +100.}, {500, -8., +8.}}}); - - spectra.add("DCAxy_track_Phi_pT", "track DCAxy vs phi & pT of tracks w. nITSClusters #geq 4", kTH3F, {dcaXY_Binning, {60, 0., TMath::TwoPi()}, {100, 0., 100.}}); - spectra.add("DCAz_track_Phi_pT", "track DCAz vs phi & pT of tracks w. nITSClusters #geq 4", kTH3F, {dcaZ_Binning, {60, 0., TMath::TwoPi()}, {100, 0., 100.}}); - spectra.add("nITSClusters_TrackPt", "Number of ITS hits vs phi & pT of tracks", kTH3F, {{7, 1., 8.}, {60, 0., TMath::TwoPi()}, {100, 0., 100.}}); - spectra.add("ptphiQualityTracks", "pT vs phi of quality tracks", {HistType::kTH2F, {{100, 0., 100.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("ptphiAllTracks", "pT vs phi of all tracks", {HistType::kTH2F, {{100, 0., +100.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("phi_Q1pT", "Track phi vs. q/pT", kTH2F, {xPhiAxis, yQ1pTAxis}); + spectra.add("vertexZ", "z vertex", kTH1F, {{60, -12., 12.}}); + spectra.add("ptphiTrackInclGood", "pT vs phi inclusive good tracks", kTH2F, {{100, 0., 100.}, {40, 0, twoPi}}); + spectra.add("ptetaTrackInclGood", "pT vs eta inclusive good tracks", kTH2F, {{100, 0., 100.}, {40, -1., 1.}}); + spectra.add("ptLeadingTrack", "pT leading track", kTH1F, {{100, 0., 100.}}); + spectra.add("ptJetChInclFidVol", "inclusive charged jet pT in fiducial volume", kTH1F, {{200, 0., 200.}}); + spectra.add("ptphiJetChInclFidVol", "inclusive charged jet pT vs phi in fiducial volume", kTH2F, {{100, 0., 100.}, {40, 0, twoPi}}); + spectra.add("ptphiJetChInclFullVol", "inclusive charged jet pT vs phi in full TPC volume", kTH2F, {{100, 0., 100.}, {40, 0, twoPi}}); + spectra.add("ptetaJetChInclFidVol", "inclusive charged jet pT vs eta in fiducial volume", kTH2F, {{100, 0., 100.}, {40, -1., 1.}}); + spectra.add("ptetaJetChInclFullVol", "inclusive charged jet pT vs eta in full TPC volume", kTH2F, {{100, 0., 100.}, {40, -1., 1.}}); + spectra.add("ptetaLeadingJetFullVol", "pT vs eta leading jet", kTH2F, {{100, 0., 100.}, {40, -1., 1.}}); + spectra.add("ptphiLeadingJetFullVol", "pT vs phi leading jet", kTH2F, {{100, 0., 100.}, {40, 0, twoPi}}); // Supplementary plots if (bAddSupplementHistosToOutput) { - spectra.add("ptJetChInclFullVol", "inclusive charged jet pT in full volume", {HistType::kTH1F, {{200, 0., +200.}}}); - spectra.add("phietaTrackAllInclGood", "phi vs eta all inclusive good tracks", {HistType::kTH2F, {{80, -1., 1.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("phietaTrackHighPtInclGood", "phi vs eta inclusive good tracks with pT > 10 GeV", {HistType::kTH2F, {{80, -1., 1.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("phietaJetChInclFidVol", "inclusive charged jet phi vs eta in fiducial volume", {HistType::kTH2F, {{80, -1., 1.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("phietaJetChInclFullVol", "inclusive charged jet phi vs eta in full TPC volume", {HistType::kTH2F, {{80, -1., 1.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("phietaJetChInclHighPtFidVol", "inclusive charged jet phi vs eta in fiducial volume", {HistType::kTH2F, {{80, -1., 1.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("phietaJetChInclHighPtFullVol", "inclusive charged jet phi vs eta in full TPC volume", {HistType::kTH2F, {{80, -1., 1.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("ptetaLeadingTrack", "pT vs eta leading tracks", {HistType::kTH2F, {{100, 0., +100.}, {80, -1., 1.}}}); - spectra.add("ptphiLeadingTrack", "pT vs phi leading tracks", {HistType::kTH2F, {{100, 0., +100.}, {60, 0, TMath::TwoPi()}}}); - spectra.add("jetAreaFullVol", "area of all jets in full TPC volume", {HistType::kTH2F, {{100, 0., +100.}, {50, 0., 2.}}}); - spectra.add("jetAreaFidVol", "area of all jets in fiducial volume", {HistType::kTH2F, {{100, 0., +100.}, {50, 0., 2.}}}); - spectra.add("fLeadJetChPtVsLeadingTrack", "inclusive charged jet pT in TPC volume", {HistType::kTH2F, {{100, 0., +100.}, {100, 0., +100.}}}); + spectra.add("ptJetChInclFullVol", "inclusive charged jet pT in full volume", kTH1F, {{200, 0., 200.}}); + spectra.add("phietaTrackAllInclGood", "phi vs eta all inclusive good tracks", kTH2F, {{80, -1., 1.}, {40, 0, twoPi}}); + spectra.add("phietaTrackHighPtInclGood", "phi vs eta inclusive good tracks with pT > 10 GeV", kTH2F, {{40, -1., 1.}, {40, 0, twoPi}}); + spectra.add("phietaJetChInclFidVol", "inclusive charged jet phi vs eta in fiducial volume", kTH2F, {{40, -1., 1.}, {40, 0, twoPi}}); + spectra.add("phietaJetChInclFullVol", "inclusive charged jet phi vs eta in full TPC volume", kTH2F, {{40, -1., 1.}, {40, 0, twoPi}}); + spectra.add("phietaJetChInclHighPtFidVol", "inclusive charged jet phi vs eta in fiducial volume", kTH2F, {{40, -1., 1.}, {40, 0, twoPi}}); + spectra.add("phietaJetChInclHighPtFullVol", "inclusive charged jet phi vs eta in full TPC volume", kTH2F, {{40, -1., 1.}, {40, 0, twoPi}}); + spectra.add("ptetaLeadingTrack", "pT vs eta leading tracks", kTH2F, {{100, 0., 100.}, {40, -1., 1.}}); + spectra.add("ptphiLeadingTrack", "pT vs phi leading tracks", kTH2F, {{100, 0., 100.}, {40, 0, twoPi}}); + spectra.add("jetAreaFullVol", "area of all jets in full TPC volume", kTH2F, {{100, 0., 100.}, {50, 0., 2.}}); + spectra.add("jetAreaFidVol", "area of all jets in fiducial volume", kTH2F, {{100, 0., 100.}, {50, 0., 2.}}); + spectra.add("fLeadJetChPtVsLeadingTrack", "inclusive charged jet pT in TPC volume", kTH2F, {{100, 0., 100.}, {100, 0., 100.}}); + } + + // Study of non-uniformity of phi distribution of tracks + if (bStudyPhiTrack) { + spectra.add("globalP_tpcglobalPDiff_withoutcuts", "difference of global and TPC inner momentum vs global momentum without any selection applied", kTH2F, {{100, 0., 100.}, {200, -100., 100.}}); + spectra.add("globalP_tpcglobalPDiff", "difference of global and TPC inner momentum vs global momentum with selection applied", kTH2F, {{100, 0., 100.}, {200, -100., 100.}}); + spectra.add("global1overP_tpcglobalPDiff", "difference of global and TPC inner momentum vs global momentum with selection applied", kTH2F, {{100, 0., 100.}, {125, -8., 8.}}); + + spectra.add("globalP_tpcglobalPDiff_withoutcuts_phirestrict", "difference of global and TPC inner momentum vs global momentum without any selection applied in a restricted phi", kTH2F, {{100, 0., 100.}, {200, -100., 100.}}); + spectra.add("globalP_tpcglobalPDiff_phirestrict", "difference of global and TPC inner momentum vs global momentum with selection applied restricted phi", kTH2F, {{100, 0., 100.}, {200, -100., 100.}}); + spectra.add("global1overP_tpcglobalPDiff_phirestrict", "difference of 1/p global and TPC inner momentum vs global momentum with selection applied restricted phi", kTH2F, {{100, 0., 100.}, {500, -8., 8.}}); + + spectra.add("DCAxy_track_Phi_pT", "track DCAxy vs phi & pT of tracks w. nITSClusters #geq 4", kTH3F, {dcaXYBinning, {40, 0., twoPi}, {100, 0., 100.}}); + spectra.add("DCAz_track_Phi_pT", "track DCAz vs phi & pT of tracks w. nITSClusters #geq 4", kTH3F, {dcaZBinning, {40, 0., twoPi}, {100, 0., 100.}}); + spectra.add("nITSClusters_TrackPt", "Number of ITS hits vs phi & pT of tracks", kTH3F, {{7, 1., 8.}, {40, 0., twoPi}, {100, 0., 100.}}); + spectra.add("ptphiQualityTracks", "pT vs phi of quality tracks", kTH2F, {{100, 0., 100.}, {40, 0, twoPi}}); + spectra.add("ptphiAllTracks", "pT vs phi of all tracks", kTH2F, {{100, 0., 100.}, {40, 0, twoPi}}); + spectra.add("phi_Q1pT", "Track phi vs. q/pT", kTH2F, {xPhiAxis, yQ1pTAxis}); } } @@ -159,14 +159,14 @@ struct ChJetTriggerQATask { // declare filters on jets Filter jetRadiusSelection = (aod::jet::r == nround(cfgJetR.node() * 100.0f)); - void process(filteredColl const& collision, filteredJTracks const& tracks, filteredJets const& jets, joinedTracks const&) + void process(FilteredColl const& collision, FilteredJTracks const& tracks, FilteredJets const& jets, JoinedTracks const&) { if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { return; } - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } @@ -191,72 +191,70 @@ struct ChJetTriggerQATask { float leadingTrackEta = -2.0; float leadingTrackPhi = -1.0; - spectra.fill(HIST("vertexZ"), - collision.posZ()); // Inclusive Track Cross TPC Rows + spectra.fill(HIST("vertexZ"), collision.posZ()); // Inclusive Track Cross TPC Rows - for (auto const& track : tracks) { // loop over filtered tracks in full TPC volume having pT > 100 MeV + // loop over filtered tracks in full TPC volume having pT > 100 MeV + for (auto const& track : tracks) { - auto const& originalTrack = track.track_as(); + auto const& originalTrack = track.track_as(); - spectra.fill(HIST("globalP_tpcglobalPDiff_withoutcuts"), track.p(), track.p() - originalTrack.tpcInnerParam()); + if (bStudyPhiTrack) { - if (TMath::Abs(track.phi() - TMath::Pi()) < phiAngleRestriction) { - spectra.fill(HIST("globalP_tpcglobalPDiff_withoutcuts_phirestrict"), track.p(), track.p() - originalTrack.tpcInnerParam()); - } + spectra.fill(HIST("globalP_tpcglobalPDiff_withoutcuts"), track.p(), track.p() - originalTrack.tpcInnerParam()); + spectra.fill(HIST("ptphiAllTracks"), track.pt(), track.phi()); - spectra.fill(HIST("ptphiAllTracks"), track.pt(), track.phi()); + if (std::fabs(track.phi() - constants::math::PI) < phiAngleRestriction) { + spectra.fill(HIST("globalP_tpcglobalPDiff_withoutcuts_phirestrict"), track.p(), track.p() - originalTrack.tpcInnerParam()); + } + } - if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) continue; - } - spectra.fill(HIST("phi_Q1pT"), originalTrack.phi(), originalTrack.sign() / originalTrack.pt()); - spectra.fill(HIST("ptphiQualityTracks"), track.pt(), track.phi()); + spectra.fill(HIST("ptphiTrackInclGood"), track.pt(), track.phi()); // Inclusive Track pT vs phi spectrum in TPC volume + spectra.fill(HIST("ptetaTrackInclGood"), track.pt(), track.eta()); // Inclusive Track pT vs eta spectrum in TPC volume - bool bDcaCondition = (fabs(track.dcaZ()) < dcaZ_cut) && (fabs(track.dcaXY()) < dcaXY_multFact * DcaXYPtCut(track.pt())); - if (originalTrack.itsNCls() >= 4 && bDcaCondition) { // correspond to number of track hits in ITS layers - spectra.fill(HIST("DCAxy_track_Phi_pT"), track.dcaXY(), track.phi(), track.pt()); - spectra.fill(HIST("DCAz_track_Phi_pT"), track.dcaZ(), track.phi(), track.pt()); - } + if (bAddSupplementHistosToOutput) { + spectra.fill(HIST("phietaTrackAllInclGood"), track.eta(), track.phi()); // Inclusive Track pT vs eta spectrum in TPC volume - spectra.fill(HIST("nITSClusters_TrackPt"), originalTrack.itsNCls(), track.phi(), track.pt()); + float trackPtCut = 5.0; + if (track.pt() > trackPtCut) { + spectra.fill(HIST("phietaTrackHighPtInclGood"), track.eta(), track.phi()); // Inclusive Track pT vs eta spectrum in TPC volume + } + } - spectra.fill(HIST("globalP_tpcglobalPDiff"), track.p(), track.p() - originalTrack.tpcInnerParam()); - if (track.p() > 0 && originalTrack.tpcInnerParam() > 0) { - spectra.fill(HIST("global1overP_tpcglobalPDiff"), track.p(), 1. / track.p() - 1. / originalTrack.tpcInnerParam()); + if (track.pt() > leadingTrackPt) { // Find leading track pT in full TPC volume + leadingTrackPt = track.pt(); + leadingTrackEta = track.eta(); + leadingTrackPhi = track.phi(); } - if (TMath::Abs(track.phi() - TMath::Pi()) < phiAngleRestriction) { - spectra.fill(HIST("globalP_tpcglobalPDiff_phirestrict"), track.p(), track.p() - originalTrack.tpcInnerParam()); - if (track.p() > 0 && originalTrack.tpcInnerParam() > 0) { - spectra.fill(HIST("global1overP_tpcglobalPDiff_phirestrict"), track.p(), 1. / track.p() - 1. / originalTrack.tpcInnerParam()); + if (bStudyPhiTrack) { + spectra.fill(HIST("phi_Q1pT"), originalTrack.phi(), originalTrack.sign() / originalTrack.pt()); + spectra.fill(HIST("ptphiQualityTracks"), track.pt(), track.phi()); + + bool bDcaCondition = (std::fabs(track.dcaZ()) < dcaZCut) && (std::fabs(track.dcaXY()) < dcaXYMultFact * dcaXYPtCut(track.pt())); + + int nITSClusters = 4; + if (originalTrack.itsNCls() >= nITSClusters && bDcaCondition) { // correspond to number of track hits in ITS layers + spectra.fill(HIST("DCAxy_track_Phi_pT"), track.dcaXY(), track.phi(), track.pt()); + spectra.fill(HIST("DCAz_track_Phi_pT"), track.dcaZ(), track.phi(), track.pt()); } - } - spectra.fill( - HIST("ptphiTrackInclGood"), track.pt(), - track.phi()); // Inclusive Track pT vs phi spectrum in TPC volume - spectra.fill( - HIST("ptetaTrackInclGood"), track.pt(), - track.eta()); // Inclusive Track pT vs eta spectrum in TPC volume + spectra.fill(HIST("nITSClusters_TrackPt"), originalTrack.itsNCls(), track.phi(), track.pt()); - if (bAddSupplementHistosToOutput) { - spectra.fill( - HIST("phietaTrackAllInclGood"), track.eta(), - track.phi()); // Inclusive Track pT vs eta spectrum in TPC volume - - if (track.pt() > 5.0) { - spectra.fill( - HIST("phietaTrackHighPtInclGood"), track.eta(), - track.phi()); // Inclusive Track pT vs eta spectrum in TPC volume + spectra.fill(HIST("globalP_tpcglobalPDiff"), track.p(), track.p() - originalTrack.tpcInnerParam()); + if (track.p() > 0 && originalTrack.tpcInnerParam() > 0) { + spectra.fill(HIST("global1overP_tpcglobalPDiff"), track.p(), 1. / track.p() - 1. / originalTrack.tpcInnerParam()); } - } - if (track.pt() > - leadingTrackPt) { // Find leading track pT in full TPC volume - leadingTrackPt = track.pt(); - leadingTrackEta = track.eta(); - leadingTrackPhi = track.phi(); + if (std::fabs(track.phi() - constants::math::PI) < phiAngleRestriction) { + spectra.fill(HIST("globalP_tpcglobalPDiff_phirestrict"), track.p(), track.p() - originalTrack.tpcInnerParam()); + + if (track.p() > 0 && originalTrack.tpcInnerParam() > 0) { + spectra.fill(HIST("global1overP_tpcglobalPDiff_phirestrict"), track.p(), 1. / track.p() - 1. / originalTrack.tpcInnerParam()); + } + } } } @@ -266,16 +264,14 @@ struct ChJetTriggerQATask { if (bAddSupplementHistosToOutput) { if (leadingTrackPt > -1.) { - spectra.fill(HIST("ptphiLeadingTrack"), leadingTrackPt, - leadingTrackPhi); - spectra.fill(HIST("ptetaLeadingTrack"), leadingTrackPt, - leadingTrackEta); + spectra.fill(HIST("ptphiLeadingTrack"), leadingTrackPt, leadingTrackPhi); + spectra.fill(HIST("ptetaLeadingTrack"), leadingTrackPt, leadingTrackEta); } } // Find leading jet pT in full TPC volume - for (auto& jet : jets) { - if (fabs(jet.eta()) < static_cast(cfgTPCVolume)) { + for (const auto& jet : jets) { + if (std::fabs(jet.eta()) < static_cast(cfgTPCVolume)) { if (jet.pt() > leadingJetPt) { leadingJetPt = jet.pt(); @@ -292,28 +288,29 @@ struct ChJetTriggerQATask { if (bAddSupplementHistosToOutput) { if (leadingJetPt > -1. && leadingTrackPt > -1.) { - spectra.fill(HIST("fLeadJetChPtVsLeadingTrack"), leadingTrackPt, - leadingJetPt); // leading jet pT versus leading track pT + spectra.fill(HIST("fLeadJetChPtVsLeadingTrack"), leadingTrackPt, leadingJetPt); // leading jet pT versus leading track pT } } // Inclusive Jet pT spectrum in Fiducial volume - for (auto& jet : jets) { - if (fabs(jet.eta()) < fiducialVolume) { + for (const auto& jet : jets) { + if (std::fabs(jet.eta()) < fiducialVolume) { spectra.fill(HIST("ptJetChInclFidVol"), jet.pt()); spectra.fill(HIST("ptphiJetChInclFidVol"), jet.pt(), jet.phi()); spectra.fill(HIST("ptetaJetChInclFidVol"), jet.pt(), jet.eta()); if (bAddSupplementHistosToOutput) { spectra.fill(HIST("phietaJetChInclFidVol"), jet.eta(), jet.phi()); - if (jet.pt() > 10.0) { + + float jetPtCut = 10.0; + if (jet.pt() > jetPtCut) { spectra.fill(HIST("phietaJetChInclHighPtFidVol"), jet.eta(), jet.phi()); } spectra.fill(HIST("jetAreaFidVol"), jet.pt(), jet.area()); } } - if (fabs(jet.eta()) < static_cast(cfgTPCVolume)) { + if (std::fabs(jet.eta()) < static_cast(cfgTPCVolume)) { spectra.fill(HIST("ptphiJetChInclFullVol"), jet.pt(), jet.phi()); spectra.fill(HIST("ptetaJetChInclFullVol"), jet.pt(), jet.eta()); @@ -321,7 +318,9 @@ struct ChJetTriggerQATask { spectra.fill(HIST("ptJetChInclFullVol"), jet.pt()); spectra.fill(HIST("phietaJetChInclFullVol"), jet.eta(), jet.phi()); - if (jet.pt() > 10.0) { + + float jetPtCut = 10.0; + if (jet.pt() > jetPtCut) { spectra.fill(HIST("phietaJetChInclHighPtFullVol"), jet.eta(), jet.phi()); } spectra.fill(HIST("jetAreaFullVol"), jet.pt(), jet.area()); @@ -332,9 +331,4 @@ struct ChJetTriggerQATask { } }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - - return WorkflowSpec{adaptAnalysisTask( - cfgc, TaskName{"jet-charged-trigger-qa"})}; -} +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGJE/Tasks/jetTutorial.cxx b/PWGJE/Tasks/jetTutorial.cxx index 230aaa53aaa..42f3153dc65 100644 --- a/PWGJE/Tasks/jetTutorial.cxx +++ b/PWGJE/Tasks/jetTutorial.cxx @@ -14,28 +14,34 @@ /// \author Nima Zardoshti // +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" + #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include -#include "Common/Core/RecoDecay.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/Jet.h" +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" - struct JetTutorialTask { HistogramRegistry registry{"registry", {{"h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}}, @@ -82,13 +88,13 @@ struct JetTutorialTask { Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; std::vector triggerMaskBits; void init(o2::framework::InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); } @@ -103,7 +109,7 @@ struct JetTutorialTask { { registry.fill(HIST("h_collisions"), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collisions"), 1.5); @@ -122,7 +128,7 @@ struct JetTutorialTask { { registry.fill(HIST("h_collisions"), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } registry.fill(HIST("h_collisions"), 1.5); @@ -141,7 +147,7 @@ struct JetTutorialTask { void processDataCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto& jet : jets) { @@ -154,7 +160,7 @@ struct JetTutorialTask { void processMCDetectorLevelCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto& jet : jets) { @@ -167,7 +173,7 @@ struct JetTutorialTask { void processMCDetectorLevelWeightedCharged(soa::Filtered::iterator const& collision, aod::JetMcCollisions const&, soa::Filtered const& jets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto& jet : jets) { @@ -190,7 +196,7 @@ struct JetTutorialTask { void processMCCharged(soa::Filtered::iterator const& collision, aod::JetMcCollisions const&, soa::Filtered const& mcdjets, soa::Filtered const& mcpjets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto& mcdjet : mcdjets) { @@ -214,7 +220,7 @@ struct JetTutorialTask { aod::JetTracks const&, aod::JetParticles const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (const auto& mcdjet : mcdjets) { @@ -229,7 +235,7 @@ struct JetTutorialTask { void processDataSubstructureCharged(soa::Filtered::iterator const& collision, soa::Filtered> const& jets, aod::JetTracks const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto& jet : jets) { @@ -270,7 +276,7 @@ struct JetTutorialTask { angularity += std::pow(jetConstituent.pt(), kappa) * std::pow(jetutilities::deltaR(jet, jetConstituent), alpha); } - for (auto& jetCluster : jet.tracks_as()) { + for (auto& jetCluster : jet.clusters_as()) { angularity += std::pow(jetCluster.energy(), kappa) * std::pow(jetutilities::deltaR(jet, jetCluster), alpha); } @@ -294,7 +300,7 @@ struct JetTutorialTask { void processRecoilDataCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets, aod::JetTracks const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } bool selectedEvent = false; @@ -325,7 +331,7 @@ struct JetTutorialTask { void processDataRhoAreaSubtractedCharged(soa::Filtered>::iterator const& collision, soa::Filtered const& jets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto jet : jets) { @@ -339,7 +345,7 @@ struct JetTutorialTask { void processDataConstituentSubtractedCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto jet : jets) { @@ -352,7 +358,7 @@ struct JetTutorialTask { void processDataConstituentSubtractedSubstructureCharged(soa::Filtered::iterator const& collision, soa::Filtered> const& jets, aod::JetTracksSub const&) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; } for (auto jet : jets) { @@ -372,7 +378,7 @@ struct JetTutorialTask { void processDataTriggered(soa::Filtered::iterator const& collision, soa::Filtered const& jets) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } for (auto& jet : jets) { diff --git a/PWGJE/Tasks/jetTutorialSkeleton.cxx b/PWGJE/Tasks/jetTutorialSkeleton.cxx index 70fc22ec736..eeccd409d26 100644 --- a/PWGJE/Tasks/jetTutorialSkeleton.cxx +++ b/PWGJE/Tasks/jetTutorialSkeleton.cxx @@ -14,28 +14,24 @@ /// \author Nima Zardoshti // +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include -#include "Common/Core/RecoDecay.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/Jet.h" - +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" - struct JetTutorialSkeletonTask { HistogramRegistry registry{"registry", {{"h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}}, @@ -82,13 +78,13 @@ struct JetTutorialSkeletonTask { Configurable triggerMasks{"triggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; std::vector triggerMaskBits; void init(o2::framework::InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); } diff --git a/PWGJE/Tasks/jetValidationQA.cxx b/PWGJE/Tasks/jetValidationQA.cxx index 261bea68571..bf4c8348c10 100644 --- a/PWGJE/Tasks/jetValidationQA.cxx +++ b/PWGJE/Tasks/jetValidationQA.cxx @@ -12,18 +12,23 @@ /// \author Johanna Lömker // \since Dec 2022 -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include "Common/DataModel/TrackSelectionTables.h" + #include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" - -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" +#include +#include using namespace o2; using namespace o2::framework; @@ -175,7 +180,7 @@ struct jetTrackCollisionQa { { mHistManager.fill(HIST("controlCollisionVtxZ"), collision.posZ()); if (evSel == true) { - if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel7) || fabs(collision.posZ()) > 10) { + if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel7")) || fabs(collision.posZ()) > 10) { return; } } else { @@ -242,7 +247,7 @@ struct jetTrackCollisionQa { void processRun3AOD(aod::JetCollision const& collision, soa::Join const& jets, TracksJE const& tracks, Tracks const&) { if (evSel == true) { - if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8) || fabs(collision.posZ()) > 10) { + if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel8")) || fabs(collision.posZ()) > 10) { return; } } else { diff --git a/PWGJE/Tasks/mcGeneratorStudies.cxx b/PWGJE/Tasks/mcGeneratorStudies.cxx index 98ec04f3341..c783a0a8c09 100644 --- a/PWGJE/Tasks/mcGeneratorStudies.cxx +++ b/PWGJE/Tasks/mcGeneratorStudies.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -13,19 +13,29 @@ // /// \author Nicolas Strangmann , Goethe University Frankfurt / Oak Ridge National Laoratory -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/HistogramRegistry.h" - #include "PWGJE/DataModel/EMCALMatchedCollisions.h" -#include "DetectorsBase/GeometryManager.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/EventSelection.h" + #include "EMCALBase/Geometry.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" +#include "TDatabasePDG.h" +#include +#include + +#include +#include using namespace o2; using namespace o2::framework; @@ -40,9 +50,17 @@ struct MCGeneratorStudies { Configurable mVertexCut{"vertexCut", 10.f, "apply z-vertex cut with value in cm"}; Configurable mRapidityCut{"rapidityCut", 0.9f, "Maximum absolute rapidity of counted generated particles"}; Configurable mSelectedParticleCode{"particlePDGCode", 111, "PDG code of the particle to be investigated (0 for all)"}; + Configurable mSelectOnlyChargedParticles{"mSelectOnlyChargedParticles", false, "set true to only count charged particles"}; + Configurable mRequireGammaGammaDecay{"requireGammaGammaDecay", false, "Only count generated particles that decayed into two photons"}; Configurable mRequireEMCCellContent{"requireEMCCellContent", false, "Ask forEMCal cell content instead of the kTVXinEMC trigger"}; + Configurable mRequireTVX{"mRequireTVX", true, "require FT0AND in event cut"}; + Configurable mRequireSel8{"mRequireSel8", true, "require sel8 in event cut"}; + Configurable mRequireNoSameBunchPileup{"mRequireNoSameBunchPileup", true, "require no same bunch pileup in event cut"}; + Configurable mRequireGoodZvtxFT0vsPV{"mRequireGoodZvtxFT0vsPV", true, "require good Zvtx between FT0 vs. PV in event cut"}; + Configurable mRequireEMCReadoutInMB{"mRequireEMCReadoutInMB", true, "require the EMC to be read out in an MB collision (kTVXinEMC)"}; + void init(InitContext const&) { AxisSpec pTAxis{250, 0., 25., "#it{p}_{T} (GeV/#it{c})"}; @@ -121,7 +139,7 @@ struct MCGeneratorStudies { mHistManager.fill(HIST("NCollisionsMCCollisions"), collisionsInFoundBC.size(), MCCollisionsBC.size()); mHistManager.fill(HIST("hBCCounter"), 1); - if (bc.selection_bit(aod::evsel::kIsTriggerTVX)) { // Count BCs with TVX trigger with and without a collision, as well as the generated particles within + if (!mRequireTVX || bc.selection_bit(aod::evsel::kIsTriggerTVX)) { // Count BCs with TVX trigger with and without a collision, as well as the generated particles within mHistManager.fill(HIST("NTVXCollisionsMCCollisions"), collisionsInFoundBC.size(), mcCollisions.size()); @@ -137,7 +155,9 @@ struct MCGeneratorStudies { auto mcParticles_inColl = mcParticles.sliceBy(perMcCollision, mcCollision.globalIndex()); for (auto& mcParticle : mcParticles_inColl) { - if (mcParticle.pdgCode() != 0 && mcParticle.pdgCode() != mSelectedParticleCode) + if (mSelectedParticleCode != 0 && mcParticle.pdgCode() != mSelectedParticleCode) + continue; + else if (mSelectOnlyChargedParticles && TDatabasePDG::Instance()->GetParticle(mcParticle.pdgCode())->Charge()) continue; if (fabs(mcParticle.y()) > mRapidityCut) continue; @@ -162,7 +182,9 @@ struct MCGeneratorStudies { auto mcParticles_inColl = mcParticles.sliceBy(perMcCollision, mcCollision.globalIndex()); for (auto& mcParticle : mcParticles_inColl) { - if (mcParticle.pdgCode() != 0 && mcParticle.pdgCode() != mSelectedParticleCode) + if (mSelectedParticleCode != 0 && mcParticle.pdgCode() != mSelectedParticleCode) + continue; + else if (mSelectOnlyChargedParticles && TDatabasePDG::Instance()->GetParticle(mcParticle.pdgCode())->Charge()) continue; if (fabs(mcParticle.y()) > mRapidityCut) continue; @@ -174,17 +196,17 @@ struct MCGeneratorStudies { mHistManager.fill(HIST("Yield"), mcParticle.pt()); if (isAccepted(mcParticle, mcParticles)) mHistManager.fill(HIST("Yield_Accepted"), mcParticle.pt()); - if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + if (!mRequireTVX || collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { mHistManager.fill(HIST("Yield_T"), mcParticle.pt()); if (abs(collision.posZ()) < mVertexCut) { mHistManager.fill(HIST("Yield_TZ"), mcParticle.pt()); - if (collision.sel8()) { + if (!mRequireSel8 || collision.sel8()) { mHistManager.fill(HIST("Yield_TZS"), mcParticle.pt()); - if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + if (!mRequireGoodZvtxFT0vsPV || collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { mHistManager.fill(HIST("Yield_TZSG"), mcParticle.pt()); - if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + if (!mRequireNoSameBunchPileup || collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { mHistManager.fill(HIST("Yield_TZSGU"), mcParticle.pt()); - if (mRequireEMCCellContent ? collision.isemcreadout() : collision.alias_bit(kTVXinEMC)) { + if (!mRequireEMCReadoutInMB || (mRequireEMCCellContent ? collision.isemcreadout() : collision.alias_bit(kTVXinEMC))) { mHistManager.fill(HIST("Yield_TZSGUE"), mcParticle.pt()); if (isAccepted(mcParticle, mcParticles)) mHistManager.fill(HIST("Yield_TZSGUE_Accepted"), mcParticle.pt()); @@ -260,17 +282,17 @@ struct MCGeneratorStudies { fRegistry->fill(HIST("hEMCollisionCounter"), 13.0); fRegistry->fill(HIST("hCollisionCounter"), 1); - if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + if (!mRequireTVX || collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { fRegistry->fill(HIST("hCollisionCounter"), 2); if (abs(collision.posZ()) < mVertexCut) { fRegistry->fill(HIST("hCollisionCounter"), 3); - if (collision.sel8()) { + if (!mRequireSel8 || collision.sel8()) { fRegistry->fill(HIST("hCollisionCounter"), 4); - if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + if (!mRequireGoodZvtxFT0vsPV || collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { fRegistry->fill(HIST("hCollisionCounter"), 5); - if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + if (!mRequireNoSameBunchPileup || collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { fRegistry->fill(HIST("hCollisionCounter"), 6); - if (mRequireEMCCellContent ? collision.isemcreadout() : collision.alias_bit(kTVXinEMC)) + if (!mRequireEMCReadoutInMB || (mRequireEMCCellContent ? collision.isemcreadout() : collision.alias_bit(kTVXinEMC))) fRegistry->fill(HIST("hCollisionCounter"), 7); } } diff --git a/PWGJE/Tasks/nsubjettiness.cxx b/PWGJE/Tasks/nsubjettiness.cxx index 1eabf7c6c50..133e1e6323b 100644 --- a/PWGJE/Tasks/nsubjettiness.cxx +++ b/PWGJE/Tasks/nsubjettiness.cxx @@ -15,23 +15,27 @@ /// \author Aimeric Landou /// \author Nima Zardoshti -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGJE/Core/JetFinder.h" +#include "PWGJE/Core/JetSubstructureUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + #include "Framework/ASoA.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Framework/Logger.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include + +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/Core/JetSubstructureUtilities.h" #include "fastjet/contrib/AxesDefinition.hh" -#include "fastjet/contrib/MeasureDefinition.hh" +#include + +#include using namespace o2; using namespace o2::framework; @@ -177,7 +181,7 @@ struct NSubjettinessTask { } Filter jetCuts = aod::jet::r == nround(jetR.node() * 100.0f); - Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); template void processJet(T const& jet, U const& tracks, float weight = 1.0) diff --git a/PWGJE/Tasks/nucleiInJets.cxx b/PWGJE/Tasks/nucleiInJets.cxx index 212c167fced..e02381a61fe 100644 --- a/PWGJE/Tasks/nucleiInJets.cxx +++ b/PWGJE/Tasks/nucleiInJets.cxx @@ -11,33 +11,50 @@ // author: Arvind Khuntia (arvind.khuntia@cern.ch) INFN Bologna, Italy -#include -#include -#include -#include +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "CCDB/BasicCCDBManager.h" #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" -#include "CommonConstants/PhysicsConstants.h" -#include "ReconstructionDataFormats/Track.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include -#include "PWGLF/DataModel/LFParticleIdentification.h" +#include +#include +#include +#include +#include +#include +#include +#include -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/Jet.h" +#include using namespace o2; using namespace o2::framework; @@ -90,13 +107,12 @@ struct nucleiInJets { } } - Configurable cfgeventSelections{"cfgeventSelections", "sel8", "choose event selection"}; Configurable cfgtrackSelections{"cfgtrackSelections", "globalTracks", "set track selections"}; - Configurable isMC{"isMC", false, "flag for the MC"}; Configurable isWithJetEvents{"isWithJetEvents", true, "Events with at least one jet"}; Configurable isWithLeadingJet{"isWithLeadingJet", true, "Events with leading jet"}; Configurable useLfTpcPid{"useLfTpcPid", true, "Events with custom TPC parameters"}; + Configurable centralityType{"centralityType", 0, "0: FT0M, 1: FT0C, 2: FV0A"}; Configurable cfgtrkMinPt{"cfgtrkMinPt", 0.15, "set track min pT"}; Configurable cfgtrkMaxEta{"cfgtrkMaxEta", 0.8, "set track max Eta"}; @@ -121,15 +137,25 @@ struct nucleiInJets { Configurable cfgnTPCPIDHe{"cfgnTPCPIDHe", 3, "nTPC PID He"}; Configurable cfgnTPCPIDTr{"cfgnTPCPIDTr", 3, "nTPC PID Tr"}; + Configurable cfgnTPCPIDPrTOF{"cfgnTPCPIDPrTOF", 3, "nTPC PID Pr"}; + Configurable cfgnTPCPIDDeTOF{"cfgnTPCPIDDeTOF", 3, "nTPC PID De"}; + Configurable cfgnTPCPIDHeTOF{"cfgnTPCPIDHeTOF", 3, "nTPC PID He"}; + Configurable cfgnTPCPIDTrTOF{"cfgnTPCPIDTrTOF", 3, "nTPC PID Tr"}; + Configurable cEnableProtonQA{"cEnableProtonQA", true, "nTPC PID Pr"}; Configurable cEnableDeuteronQA{"cEnableDeuteronQA", true, "nTPC PID De"}; Configurable cEnableHeliumQA{"cEnableHeliumQA", true, "nTPC PID He"}; Configurable cEnableTritonQA{"cEnableTritonQA", true, "nTPC PID Tr"}; Configurable addTOFplots{"addTOFplots", true, "add TOF plots"}; Configurable useTPCpreSel{"useTPCpreSel", 3, "add TPC nsgma preselection for TOF: (0) no selection (!0) selction on TPC"}; + Configurable useLeadingJetDetLevelValue{"useLeadingJetDetLevelValue", false, "true: use det level value for leading jet, false: use part level value"}; + Configurable useDcaxyPtDepCut{"useDcaxyPtDepCut", true, "true: use pt dependent DCAxy cut, false: use constant DCAxy cut"}; + Configurable useTOFNsigmaPreSel{"useTOFNsigmaPreSel", true, "true: use TOF nsgma preselection, false: no TOF nsgma preselection"}; + Configurable useTOFVeto{"useTOFVeto", false, "true: use TOF veto, false: no TOF veto"}; + Configurable isRequireHitsInITSLayers{"isRequireHitsInITSLayers", true, "true: at least one hit in the its inner layes"}; + Configurable useMcC{"useMcC", true, "use mcC"}; Configurable addpik{"addpik", true, "add pion and kaon hist"}; - ConfigurableAxis binsDCA{"binsDCA", {400, -1.f, 1.f}, ""}; ConfigurableAxis binsdEdx{"binsdEdx", {1000, 0.f, 1000.f}, ""}; ConfigurableAxis binsBeta{"binsBeta", {120, 0.0, 1.2}, ""}; @@ -141,16 +167,12 @@ struct nucleiInJets { ConfigurableAxis binsPtZHe{"binsPtZHe", {VARIABLE_WIDTH, 0.5, 0.625, 0.75, 0.875, 1.0, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2.0, 2.25, 2.5, 3.0, 3.5, 4.0}, ""}; - static constexpr float gMassProton = 0.93827208f; - static constexpr float gMassDeuteron = 1.87561f; - static constexpr float gMassTriton = 2.80892f; - static constexpr float gMassHelium = 2.80839f; - static constexpr int PDGProton = 2212; - static constexpr int PDGDeuteron = 1000010020; - static constexpr int PDGTriton = 1000010030; - static constexpr int PDGHelium = 1000020030; + Configurable applySkim{"applySkim", false, "Apply skimming"}; + Configurable cfgSkim{"cfgSkim", "fHighFt0Mult", "Configurable for skimming"}; - using EventCandidates = soa::Join; // , aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs + // using EventTable = soa::Join; + using EventTable = aod::JetCollisions; + using EventTableMC = soa::Join; using TrackCandidates = soa::Join; @@ -162,6 +184,11 @@ struct nucleiInJets { aod::pidTOFFullKa, aod::pidTOFFullPr, aod::pidTOFFullDe, aod::pidTOFFullTr, aod::pidTOFFullHe, aod::TOFSignal /*, aod::McTrackLabels*/>; + using TrackCandidatesIncMC = soa::Join; + Filter jetCuts = aod::jet::pt > cfgjetPtMin&& aod::jet::r == nround(cfgjetR.node() * 100.0f); using chargedJetstrack = soa::Filtered>; @@ -171,15 +198,25 @@ struct nucleiInJets { SliceCache cache; HistogramRegistry jetHist{"jetHist", {}, OutputObjHandlingPolicy::AnalysisObject}; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + Service ccdb; + TRandom3 randUniform; void init(o2::framework::InitContext&) { + + if (doprocessJetTracksData && doprocessJetTracksDataLfPid) { + LOGP(fatal, "only one process function should be enabled!!!"); + } const AxisSpec PtAxis = {100, 0, 10.0}; - const AxisSpec PtJetAxis = {300, 0, 30.0}; + const AxisSpec PtJetAxis = {100, 0, 100.0}; const AxisSpec MultAxis = {100, 0, 100}; const AxisSpec dRAxis = {100, 0, 3.6}; + const AxisSpec CentAxis = {100, 0, 100}; const AxisSpec dcaxyAxis{binsDCA, "DCAxy (cm)"}; const AxisSpec dcazAxis{binsDCA, "DCAz (cm)"}; const AxisSpec dedxAxis{binsdEdx, "d#it{E}/d#it{x} A.U."}; + const AxisSpec vzAxis{{300, -15.f, 15.f}, "Vz (cm)"}; const AxisSpec betaAxis{binsBeta, "TOF #beta"}; const AxisSpec ptZHeAxis{binsPtZHe, "#it{p}_{T}"}; @@ -189,6 +226,26 @@ struct nucleiInJets { const AxisSpec massTrAxis{binsMassTr, ""}; const AxisSpec massHeAxis{binsMassHe, ""}; + jetHist.add("hNEvents", "hNEvents", {HistType::kTH1D, {{6, 0.f, 6.f}}}); + jetHist.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "All"); + jetHist.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "Skimmed"); + jetHist.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "|Vz|<10"); + jetHist.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(4, "Sel8+|Vz|<10"); + jetHist.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(5, "nJets>0"); + + jetHist.add("hNEventsInc", "hNEventsInc", {HistType::kTH1D, {{4, 0.f, 4.f}}}); + jetHist.get(HIST("hNEventsInc"))->GetXaxis()->SetBinLabel(1, "All"); + jetHist.get(HIST("hNEventsInc"))->GetXaxis()->SetBinLabel(2, "Sel8"); + jetHist.get(HIST("hNEventsInc"))->GetXaxis()->SetBinLabel(3, "|Vz|<10"); + + jetHist.add("hNEventsIncVsCent", "hNEventsIncVsCent", {HistType::kTH2D, {{vzAxis}, {CentAxis}}}); + + // TPC nSigma vs pT (inclusive) + jetHist.add("tracksInc/proton/h3PtVsProtonNSigmaTPCVsPt", "pT(p) vs NSigmaTPC (p) vs centrality; #it{p}_{T} (GeV/#it{c}); NSigmaTPC; centrality", HistType::kTH3F, {PtAxis, {200, -10, 10}, CentAxis}); + jetHist.add("tracksInc/antiProton/h3PtVsantiProtonNSigmaTPCVsPt", "pT(#bar{p}) vs NSigmaTPC (#bar{p}) vs centrality; #it{p}_{T} (GeV/#it{c}); NSigmaTPC; centrality", HistType::kTH3F, {PtAxis, {200, -10, 10}, CentAxis}); + jetHist.add("tracksInc/deuteron/h3PtVsDeuteronNSigmaTPCVsPt", "pT(d) vs NSigmaTPC (d) vs centrality; #it{p}_{T} (GeV/#it{c}); NSigmaTPC; centrality", HistType::kTH3F, {PtAxis, {200, -10, 10}, CentAxis}); + jetHist.add("tracksInc/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPt", "pT(#bar{d}) vs NSigmaTPC (#bar{d}) vs centrality; #it{p}_{T} (GeV/#it{c}); NSigmaTPC; centrality", HistType::kTH3F, {PtAxis, {200, -10, 10}, CentAxis}); + // jet property jetHist.add("jet/h1JetPt", "jet_{p_{T}}", kTH1F, {PtJetAxis}); jetHist.add("jet/h1JetEvents", "NumbeOfJetEvents", kTH1F, {{1, 0, 1}}); @@ -197,9 +254,9 @@ struct nucleiInJets { jetHist.add("jet/nJetsPerEvent", "nJetsPerEvent", kTH1F, {{15, .0, 15.}}); jetHist.add("mcpJet/nJetsPerEvent", "nJetsPerEvent", kTH1F, {{15, .0, 15.}}); jetHist.add("mcdJet/nJetsPerEvent", "nJetsPerEvent", kTH1F, {{15, .0, 15.}}); - jetHist.add("jet/vertexZ", "vertexZ (Jet flag)", kTH1F, {{100, -15.0, 15.0}}); - jetHist.add("vertexZ", "vertexZ (all)", kTH1F, {{100, -15.0, 15.0}}); - jetHist.add("jetOut/vertexZ", "vertexZ (without z-flag)", kTH1F, {{100, -15.0, 15.0}}); + jetHist.add("jet/vertexZ", "vertexZ (Jet flag)", kTH1F, {{vzAxis}}); + jetHist.add("vertexZ", "vertexZ (all)", kTH1F, {{vzAxis}}); + jetHist.add("jetOut/vertexZ", "vertexZ (without z-flag)", kTH1F, {{vzAxis}}); //////////////////////////// // MC //////////////////////////// @@ -210,8 +267,8 @@ struct nucleiInJets { h->GetXaxis()->SetBinLabel(3, "vz < 10"); h->GetXaxis()->SetBinLabel(4, "ingt0"); - jetHist.add("mcpJet/vertexZ", "vertexZ (All)", kTH1F, {{100, -15.0, 15.0}}); - jetHist.add("mcdJet/vertexZ", "vertexZ (All)", kTH1F, {{100, -15.0, 15.0}}); + jetHist.add("mcpJet/vertexZ", "vertexZ (All)", kTH1F, {{vzAxis}}); + jetHist.add("mcdJet/vertexZ", "vertexZ (All)", kTH1F, {{vzAxis}}); jetHist.add("mcdJet/eventStat", "vertexZ (All)", kTH1F, {{5, .0, 5.0}}); auto h1 = jetHist.get(HIST("mcdJet/eventStat")); h1->GetXaxis()->SetBinLabel(1, "All"); @@ -219,8 +276,8 @@ struct nucleiInJets { h1->GetXaxis()->SetBinLabel(3, "vz< 10"); h1->GetXaxis()->SetBinLabel(4, "ingt0"); - jetHist.add("recmatched/vertexZ", "vertexZ (All)", kTH1F, {{100, -15.0, 15.0}}); - jetHist.add("genmatched/vertexZ", "vertexZ (All)", kTH1F, {{100, -15.0, 15.0}}); + jetHist.add("recmatched/vertexZ", "vertexZ (All)", kTH1F, {{vzAxis}}); + jetHist.add("genmatched/vertexZ", "vertexZ (All)", kTH1F, {{vzAxis}}); ////////////////////////////////////////////// // inside jet @@ -312,6 +369,12 @@ struct nucleiInJets { jetHist.add("tracks/antiTriton/h2TofNsigmaantiTritonVsPt_jet", "h2TofNsigmaantiTritonVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); jetHist.add("tracks/helium/h2TofNsigmaHeliumVsPt_jet", "h2TofNsigmaHeliumVsPt_jet; TofNsigma; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); jetHist.add("tracks/antiHelium/h2TofNsigmaantiHeliumVsPt_jet", "h2TofNsigmaantiHeliumVsPt_jet; TofNsigma; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + + jetHist.add("tracks/proton/h3TpcNsigmaTofNsigmaProtonVsPt_jet", "h3TpcNsigmaTofNsigmaProtonVsPt_jet; TpcNsigma; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH3F, {{100, -5., 5.}, {100, -5., 5.}, {50, 0., 5.}}); + jetHist.add("tracks/antiProton/h3TpcNsigmaTofNsigmaantiProtonVsPt_jet", "h3TpcNsigmaTofNsigmaantiProtonVsPt_jet; TpcNsigma; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH3F, {{100, -5., 5.}, {100, -5., 5.}, {50, 0., 5.}}); + jetHist.add("tracks/deuteron/h3TpcNsigmaTofNsigmaDeuteronVsPt_jet", "h3TpcNsigmaTofNsigmaDeuteronVsPt_jet; TpcNsigma; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH3F, {{100, -5., 5.}, {100, -5., 5.}, {50, 0., 5.}}); + jetHist.add("tracks/antiDeuteron/h3TpcNsigmaTofNsigmaantiDeuteronVsPt_jet", "h3TpcNsigmaTofNsigmaantiDeuteronVsPt_jet; TpcNsigma; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH3F, {{100, -5., 5.}, {100, -5., 5.}, {50, 0., 5.}}); + ///////////// // perp cone ///////////// @@ -346,14 +409,18 @@ struct nucleiInJets { if (cEnableProtonQA) { jetHist.add("tracks/proton/dca/after/hDCAxyVsPtProton", "DCAxy vs Pt (p)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracksInc/proton/dca/after/hDCAxyVsPtProton", "DCAxy vs Pt (p)", HistType::kTH3F, {{dcaxyAxis}, {PtAxis}, {CentAxis}}); jetHist.add("tracks/antiProton/dca/after/hDCAxyVsPtantiProton", "DCAxy vs Pt (#bar{p})", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); jetHist.add("tracks/proton/dca/after/hDCAzVsPtProton", "DCAz vs Pt (p)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracksInc/proton/dca/after/hDCAzVsPtProton", "DCAz vs Pt (p)", HistType::kTH3F, {{dcazAxis}, {PtAxis}, {CentAxis}}); jetHist.add("tracks/antiProton/dca/after/hDCAzVsPtantiProton", "DCAz vs Pt (#bar{p})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); } if (cEnableDeuteronQA) { jetHist.add("tracks/deuteron/dca/after/hDCAxyVsPtDeuteron", "DCAxy vs Pt (d)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracksInc/deuteron/dca/after/hDCAxyVsPtDeuteron", "DCAxy vs Pt (d)", HistType::kTH3F, {{dcaxyAxis}, {PtAxis}, {CentAxis}}); jetHist.add("tracks/antiDeuteron/dca/after/hDCAxyVsPtantiDeuteron", "DCAxy vs Pt (#bar{d})", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); jetHist.add("tracks/deuteron/dca/after/hDCAzVsPtDeuteron", "DCAz vs Pt (d)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracksInc/deuteron/dca/after/hDCAzVsPtDeuteron", "DCAz vs Pt (d)", HistType::kTH3F, {{dcazAxis}, {PtAxis}, {CentAxis}}); jetHist.add("tracks/antiDeuteron/dca/after/hDCAzVsPtantiDeuteron", "DCAz vs Pt (#bar{d})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); } if (cEnableTritonQA) { @@ -390,6 +457,21 @@ struct nucleiInJets { jetHist.add("tracks/helium/h2TOFmass2HeliumVsPt", "#Delta M^{2} (t) vs #it{p}_{T}t; TOFmass2; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{massHeAxis}, {ptZHeAxis}}); jetHist.add("tracks/antiHelium/h2TOFmass2antiHeliumVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{massHeAxis}, {ptZHeAxis}}); + jetHist.add("tracksInc/proton/h2TOFmassProtonVsPt", "h2TOFmassProtonVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH3F, {{80, 0.4, 4.}, {50, 0., 5.}, {CentAxis}}); + jetHist.add("tracksInc/antiProton/h2TOFmassantiProtonVsPt", "h2TOFmassantiProtonVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH3F, {{80, 0.4, 4.}, {50, 0., 5.}, {CentAxis}}); + jetHist.add("tracksInc/deuteron/h2TOFmassDeuteronVsPt", "h2TOFmassDeuteronVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH3F, {{80, 0.4, 4.}, {50, 0., 5.}, {CentAxis}}); + jetHist.add("tracksInc/antiDeuteron/h2TOFmassantiDeuteronVsPt", "h2TOFmassantiDeuteronVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH3F, {{80, 0.4, 4.}, {50, 0., 5.}, {CentAxis}}); + + jetHist.add("tracksInc/proton/h2TOFmass2ProtonVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH3F, {{massPrAxis}, {250, 0., 5.}, {CentAxis}}); + jetHist.add("tracksInc/antiProton/h2TOFmass2antiProtonVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH3F, {{massPrAxis}, {250, 0., 5.}, {CentAxis}}); + jetHist.add("tracksInc/deuteron/h2TOFmass2DeuteronVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH3F, {{massDeAxis}, {250, 0., 5.}, {CentAxis}}); + jetHist.add("tracksInc/antiDeuteron/h2TOFmass2antiDeuteronVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH3F, {{massDeAxis}, {250, 0., 5.}, {CentAxis}}); + + jetHist.add("tracksInc/proton/h2TofNsigmaProtonVsPt", "h2TofNsigmaProtonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH3F, {{100, -5, 5}, {100, 0., 10.}, {CentAxis}}); + jetHist.add("tracksInc/antiProton/h2TofNsigmaantiProtonVsPt", "h2TofNsigmaantiProtonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH3F, {{100, -5, 5}, {100, 0., 10.}, {CentAxis}}); + jetHist.add("tracksInc/deuteron/h2TofNsigmaDeuteronVsPt", "h2TofNsigmaDeuteronVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH3F, {{100, -5, 5}, {100, 0., 10.}, {CentAxis}}); + jetHist.add("tracksInc/antiDeuteron/h2TofNsigmaantiDeuteronVsPt", "h2TofNsigmaantiDeuteronVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH3F, {{100, -5, 5}, {100, 0., 10.}, {CentAxis}}); + // TOF hist nSigma jetHist.add("tracks/proton/h2TofNsigmaProtonVsPt", "h2TofNsigmaProtonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); jetHist.add("tracks/antiProton/h2TofNsigmaantiProtonVsPt", "h2TofNsigmaantiProtonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); @@ -401,6 +483,17 @@ struct nucleiInJets { jetHist.add("tracks/antiHelium/h2TofNsigmaantiHeliumVsPt", "h2TofNsigmaantiHeliumVsPt; TofNsigma; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); if (isMC) { + // inc + jetHist.add("recInc/eventStat", "Event statistics (inclusive)", HistType::kTH1F, {{6, 0.f, 6.f}}); + jetHist.get(HIST("recInc/eventStat"))->GetXaxis()->SetBinLabel(1, "All"); + jetHist.get(HIST("recInc/eventStat"))->GetXaxis()->SetBinLabel(2, "Sel8"); + jetHist.get(HIST("recInc/eventStat"))->GetXaxis()->SetBinLabel(3, "|Vz|<10"); + + jetHist.add("recInc/vertexZ", "vertexZ (inclusive)", HistType::kTH2F, {{vzAxis}, {CentAxis}}); + jetHist.add("recInc/pt/PtParticleTypeTPC", "Pt vs ParticleType vs Centrality (TPC)", HistType::kTH3F, {{100, 0.f, 10.f}, {14, -7, 7}, {100, 0, 100}}); + jetHist.add("recInc/pt/PtParticleTypeTPCTOF", "Pt vs ParticleType vs Centrality (TPC+TOF)", HistType::kTH3F, {{100, 0.f, 10.f}, {14, -7, 7}, {100, 0, 100}}); + jetHist.add("recInc/pt/PtParticleTypeTPCTOFVeto", "Pt vs ParticleType vs Centrality (TPC+TOF Veto)", HistType::kTH3F, {{100, 0.f, 10.f}, {14, -7, 7}, {100, 0, 100}}); + jetHist.add("genInc/pt/PtParticleType", "Pt vs ParticleType vs Centrality (gen)", HistType::kTH3F, {{100, 0.f, 10.f}, {14, -7, 7}, {100, 0, 100}}); // inside jet jetHist.add("tracks/mc/proton/h3PtVsProtonNSigmaTPCVsPtJet_jet", "pT(p) vs NSigmaTPC (p) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); jetHist.add("tracks/mc/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet_jet", "pT(#bar{p}) vs NSigmaTPC (#bar{p}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); @@ -484,51 +577,104 @@ struct nucleiInJets { // rec matched jetHist.add("recmatched/hRecMatchedJetPt", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH2F, {{100, 0., 100.}, {400, -20., 20.}}); + jetHist.add("recmatched/hRecMatchedVsGenJetPtVsEta", "matched jet pT vs #eta (Rec level); #it{p}_{T,jet det}; #eta_{jet}", HistType::kTH2F, {{100, 0., 100.}, {200, -1., 1.}}); jetHist.add("recmatched/hRecMatchedJetPhi", "matched jet #varphi (Rec level);#varphi_{T,jet part}; #varphi_{jet part}-#varphi_{jet det}", HistType::kTH2F, {{700, 0., 7.}, {200, -5., 5.}}); jetHist.add("recmatched/hRecMatchedJetEta", "matched jet #eta (Rec level);#eta_{T,jet part}; #eta_{jet part}-#eta_{jet det} ", HistType::kTH2F, {{200, -1., 1.}, {500, -2.5, 2.5}}); - jetHist.add("recmatched/h2ResponseMatrix", "matched jet pT;#it{p}_{T} (true); #it{p}_{T} (measured)", HistType::kTH2F, {{40, 0., 100.}, {40, 0., 100.}}); + jetHist.add("recmatched/h2ResponseMatrix", "matched jet pT;#it{p}_{T} (mes.); #it{p}_{T} (true)", HistType::kTH2F, {{100, 0., 100.}, {100, 0., 100.}}); + jetHist.add("recmatched/h2ResponseMatrixLeadingJet", "matched jet rec pT vs true pt;#it{p}_{T} (mes.); #it{p}_{T} (true)", HistType::kTH2F, {{100, 0., 100.}, {100, 0., 100.}}); + jetHist.add("recmatched/mcC/h2ResponseMatrixLeadingJet", "matched jet rec pT vs true pt;#it{p}_{T} (mes.); #it{p}_{T} (true)", HistType::kTH2F, {{100, 0., 100.}, {100, 0., 100.}}); + ///////// jetHist.add("recmatched/hRecJetPt", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH1F, {{100, 0., 100.}}); jetHist.add("recmatched/hGenJetPt", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH1F, {{100, 0., 100.}}); - jetHist.add("recmatched/pt/PtParticleType", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + jetHist.add("eff/recmatched/pt/PtParticleType", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + jetHist.add("eff/recmatched/mcC/pt/PtParticleType", "Pt (pt, rec) vs Pt (pt, true) vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {100, 0.f, 10.f}, {14, -7, 7}}); + jetHist.add("eff/recmatched/mcCSpectra/pt/PtParticleType", "Pt (pt) vs Pt (pt, true) vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {100, 0.f, 10.f}, {14, -7, 7}}); + jetHist.add("eff/recmatched/pt/PtParticleTypeTPC", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + jetHist.add("eff/recmatched/pt/PtParticleTypeTOF", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + jetHist.add("eff/recmatched/pt/PtParticleTypeTPCTOF", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + jetHist.add("eff/recmatched/pt/PtParticleTypeTPCTOFVeto", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + + jetHist.add("eff/recmatched/perpCone/pt/PtParticleType", "Pt (p) vs particletype", HistType::kTH2D, {{100, 0.f, 10.f}, {14, -7, 7}}); + jetHist.add("eff/recmatched/perpCone/mcC/pt/PtParticleType", "Pt (rec) vs Pt (true) vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {100, 0.f, 10.f}, {14, -7, 7}}); + jetHist.add("eff/recmatched/perpCone/mcCSpectra/pt/PtParticleType", "Pt (rec) vs Pt (true) vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {100, 0.f, 10.f}, {14, -7, 7}}); + jetHist.add("eff/recmatched/perpCone/pt/PtParticleTypeTPC", "Pt (p) vs particletype", HistType::kTH2D, {{100, 0.f, 10.f}, {14, -7, 7}}); + jetHist.add("eff/recmatched/perpCone/pt/PtParticleTypeTOF", "Pt (p) vs particletype", HistType::kTH2D, {{100, 0.f, 10.f}, {14, -7, 7}}); + jetHist.add("eff/recmatched/perpCone/pt/PtParticleTypeTPCTOF", "Pt (p) vs particletype", HistType::kTH2D, {{100, 0.f, 10.f}, {14, -7, 7}}); + jetHist.add("eff/recmatched/perpCone/pt/PtParticleTypeTPCTOFVeto", "Pt (p) vs particletype", HistType::kTH2D, {{100, 0.f, 10.f}, {14, -7, 7}}); + jetHist.add("eff/recmatched/gen/pt/PtParticleType", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + jetHist.add("eff/recmatched/gen/perpCone/pt/PtParticleType", "Pt (p) vs particletype", HistType::kTH2D, {{100, 0.f, 10.f}, {14, -7, 7}}); // gen matched jetHist.add("genmatched/hRecMatchedJetPt", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH2F, {{100, 0., 100.}, {400, -20., 20.}}); + jetHist.add("genmatched/hRecMatchedVsGenJetPt", "matched jet pT (Rec level);#it{p}_{T,jet det}; #it{p}_{T,jet part} (GeV/#it{c})", HistType::kTH2F, {{100, 0., 100.}, {100, 0., 100.}}); + jetHist.add("genmatched/mcC/hRecMatchedVsGenJetPt", "matched jet pT (Rec level); #it{p}_{T,jet det}; #it{p}_{T,jet part} (GeV/#it{c})", HistType::kTH2F, {{100, 0., 100.}, {100, 0., 100.}}); + jetHist.add("genmatched/hRecMatchedVsGenJetPtVsEta", "matched jet pT (Rec level) vs Eta (rec); #it{p}_{T,jet} ; #eta_{jet}", HistType::kTH2F, {{100, 0., 100.}, {200, -1., 1.}}); + jetHist.add("genmatched/hRecMatchedJetPhi", "matched jet #varphi (Rec level);#varphi_{T,jet part}; #varphi_{jet part}-#varphi_{jet det}", HistType::kTH2F, {{700, 0., 7.}, {200, -5., 5.}}); jetHist.add("genmatched/hRecMatchedJetEta", "matched jet #eta (Rec level);#eta_{T,jet part}; #eta_{jet part}-#eta_{jet det} ", HistType::kTH2F, {{200, -1., 1.}, {500, -2.5, 2.5}}); - - ///////// jetHist.add("genmatched/hRecJetPt", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH1F, {{100, 0., 100.}}); jetHist.add("genmatched/hGenJetPt", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH1F, {{100, 0., 100.}}); + jetHist.add("genmatched/leadingJet/hGenJetPt", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH1F, {{100, 0., 100.}}); jetHist.add("genmatched/hRecJetWithGenPt", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH1F, {{100, 0., 100.}}); jetHist.add("genmatched/hGenJetPtMatched", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH1F, {{100, 0., 100.}}); - + jetHist.add("genmatched/leadingJet/hGenJetPtMatched", "matched jet pT (Rec level);#it{p}_{T,jet part} (GeV/#it{c}); #it{p}_{T,jet part} - #it{p}_{T,jet det}", HistType::kTH1F, {{100, 0., 100.}}); jetHist.add("genmatched/pt/PtParticleType", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); } } + template + void initCCDB(const BCType& bc) + { + if (applySkim) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), cfgSkim.value); + zorro.populateHistRegistry(jetHist, bc.runNumber()); + } + } std::array getPerpendicuarPhi(float jetPhi) { std::array PerpendicularConeAxisPhi = {-999.0f, -999.0f}; // build 2 perp cones in phi around the leading jet (right and left of the jet) - PerpendicularConeAxisPhi[0] = RecoDecay::constrainAngle(jetPhi + (M_PI / 2.)); // This will contrain the angel between 0-2Pi - PerpendicularConeAxisPhi[1] = RecoDecay::constrainAngle(jetPhi - (M_PI / 2.)); // This will contrain the angel between 0-2Pi + PerpendicularConeAxisPhi[0] = RecoDecay::constrainAngle(jetPhi + (o2::constants::math::PIHalf)); // This will contrain the angel between 0-2Pi + PerpendicularConeAxisPhi[1] = RecoDecay::constrainAngle(jetPhi - (o2::constants::math::PIHalf)); // This will contrain the angel between 0-2Pi return PerpendicularConeAxisPhi; } + float dcaXYPtDepCut(float trackPt) + { + return 0.0105f + 0.0350f / std::pow(trackPt, 1.1f); + } + + // Check hits on ITS Layers + bool hasHitOnITSLayer(uint8_t itsClsmap, int layer) + { + unsigned char test_bit = 1 << layer; + return (itsClsmap & test_bit); + } + template bool isTrackSelected(const TrackType track) { // standard track selection if (track.pt() < cfgtrkMinPt) return false; - if (std::abs(track.eta()) > cfgtrkMaxEta) + if (isRequireHitsInITSLayers) { + if (!track.hasITS()) + return false; + if (!hasHitOnITSLayer(track.itsClusterMap(), 0) && + !hasHitOnITSLayer(track.itsClusterMap(), 1) && + !hasHitOnITSLayer(track.itsClusterMap(), 2)) + return false; + } + if (std::fabs(track.eta()) > cfgtrkMaxEta) + return false; + if (std::fabs(track.dcaXY()) > cfgMaxDCArToPVcut && !useDcaxyPtDepCut) return false; - if (std::abs(track.dcaXY()) > cfgMaxDCArToPVcut) + if (std::fabs(track.dcaXY()) > dcaXYPtDepCut(track.pt()) && useDcaxyPtDepCut) return false; - if (std::abs(track.dcaZ()) > cfgMaxDCAzToPVcut) + if (std::fabs(track.dcaZ()) > cfgMaxDCAzToPVcut) return false; if (track.tpcNClsFindable() < cfgnFindableTPCClusters) return false; @@ -559,7 +705,7 @@ struct nucleiInJets { if (isWithLeadingJet) { double delPhi = TVector2::Phi_mpi_pi(leadingJetPtEtaPhi[2] - trk.phi()); double delEta = leadingJetPtEtaPhi[1] - trk.eta(); - double R = TMath::Sqrt((delEta * delEta) + (delPhi * delPhi)); + double R = RecoDecay::sumOfSquares(delEta, delPhi); if (R < cfgjetR) jetFlag = true; jetPt = leadingJetPtEtaPhi[0]; @@ -567,15 +713,15 @@ struct nucleiInJets { std::array perpConePhiJet = getPerpendicuarPhi(leadingJetPtEtaPhi[2]); double delPhiPerpCone1 = TVector2::Phi_mpi_pi(perpConePhiJet[0] - trk.phi()); double delPhiPerpCone2 = TVector2::Phi_mpi_pi(perpConePhiJet[1] - trk.phi()); - double RPerpCone1 = TMath::Sqrt((delEta * delEta) + (delPhiPerpCone1 * delPhiPerpCone1)); - double RPerpCone2 = TMath::Sqrt((delEta * delEta) + (delPhiPerpCone2 * delPhiPerpCone2)); + double RPerpCone1 = RecoDecay::sumOfSquares(delEta, delPhiPerpCone1); + double RPerpCone2 = RecoDecay::sumOfSquares(delEta, delPhiPerpCone2); if (RPerpCone1 < cfgjetR || RPerpCone2 < cfgjetR) jetFlagPerpCone = true; } else { for (auto const& jet : jets) { double delPhi = TVector2::Phi_mpi_pi(jet.phi() - trk.phi()); double delEta = jet.eta() - trk.eta(); - double R = TMath::Sqrt((delEta * delEta) + (delPhi * delPhi)); + double R = RecoDecay::sumOfSquares(delEta, delPhi); if (R < cfgjetR) jetFlag = true; jetPt = jet.pt(); @@ -583,11 +729,9 @@ struct nucleiInJets { } } // tof - // float gamma =-999; float massTOF = -999; if (trk.hasTOF()) { - // gamma = 1.f / TMath::Sqrt(1.f - (trk.beta() * trk.beta())); - massTOF = trk.p() * TMath::Sqrt(1.f / (trk.beta() * trk.beta()) - 1.f); + massTOF = trk.p() * std::sqrt(1.f / (trk.beta() * trk.beta()) - 1.f); } if (addTOFplots && trk.hasTOF()) { @@ -603,10 +747,51 @@ struct nucleiInJets { jetHist.fill(HIST("tracks/pion/h3PtVsPionNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPi(), jetPt); jetHist.fill(HIST("tracks/kaon/h3PtVsKaonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaKa(), jetPt); } - jetHist.fill(HIST("tracks/proton/h3PtVsProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); - jetHist.fill(HIST("tracks/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); - jetHist.fill(HIST("tracks/helium/h3PtVsHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); - jetHist.fill(HIST("tracks/triton/h3PtVsTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + + if (useTOFNsigmaPreSel && trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) + jetHist.fill(HIST("tracks/proton/h3PtVsProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) + jetHist.fill(HIST("tracks/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); + if (std::abs(trk.tofNSigmaHe()) < cfgnTPCPIDHeTOF) + jetHist.fill(HIST("tracks/helium/h3PtVsHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); + if (std::abs(trk.tofNSigmaTr()) < cfgnTPCPIDTrTOF) + jetHist.fill(HIST("tracks/triton/h3PtVsTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + } else if (!useTOFNsigmaPreSel && !useTOFVeto) { + jetHist.fill(HIST("tracks/proton/h3PtVsProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); + jetHist.fill(HIST("tracks/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); + jetHist.fill(HIST("tracks/helium/h3PtVsHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); + jetHist.fill(HIST("tracks/triton/h3PtVsTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + } else if (!useTOFNsigmaPreSel && useTOFVeto) { + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) { + jetHist.fill(HIST("tracks/proton/h3PtVsProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); + } + } else { + jetHist.fill(HIST("tracks/proton/h3PtVsProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) { + jetHist.fill(HIST("tracks/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); + } + } else { + jetHist.fill(HIST("tracks/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaHe()) < cfgnTPCPIDHeTOF) { + jetHist.fill(HIST("tracks/helium/h3PtVsHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); + } + } else { + jetHist.fill(HIST("tracks/helium/h3PtVsHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaTr()) < cfgnTPCPIDTrTOF) { + jetHist.fill(HIST("tracks/triton/h3PtVsTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + } + } else { + jetHist.fill(HIST("tracks/triton/h3PtVsTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + } + } if (cEnableProtonQA && std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { jetHist.fill(HIST("tracks/proton/dca/after/hDCAxyVsPtProton_jet"), trk.dcaXY(), trk.pt()); @@ -616,7 +801,7 @@ struct nucleiInJets { jetHist.fill(HIST("tracks/deuteron/dca/after/hDCAxyVsPtDeuteron_jet"), trk.dcaXY(), trk.pt()); jetHist.fill(HIST("tracks/deuteron/dca/after/hDCAzVsPtDeuteron_jet"), trk.dcaZ(), trk.pt()); } - if (cEnableTritonQA && std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDTr) { + if (cEnableTritonQA && std::abs(trk.tpcNSigmaTr()) < cfgnTPCPIDTr) { jetHist.fill(HIST("tracks/triton/dca/after/hDCAxyVsPtTriton_jet"), trk.dcaXY(), trk.pt()); jetHist.fill(HIST("tracks/triton/dca/after/hDCAzVsPtTriton_jet"), trk.dcaZ(), trk.pt()); } @@ -628,43 +813,41 @@ struct nucleiInJets { if (addTOFplots && trk.hasTOF()) { if (!useTPCpreSel) { jetHist.fill(HIST("tracks/proton/h2TOFmassProtonVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt_jet"), massTOF * massTOF - gMassProton * gMassProton, trk.pt()); - + jetHist.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt()); jetHist.fill(HIST("tracks/deuteron/h2TOFmassDeuteronVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt_jet"), massTOF * massTOF - gMassDeuteron * gMassDeuteron, trk.pt()); - + jetHist.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt()); jetHist.fill(HIST("tracks/triton/h2TOFmassTritonVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt_jet"), massTOF * massTOF - gMassTriton * gMassTriton, trk.pt()); - + jetHist.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassTriton * o2::constants::physics::MassTriton, trk.pt()); jetHist.fill(HIST("tracks/helium/h2TOFmassHeliumVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt_jet"), massTOF * massTOF - gMassHelium * gMassHelium, trk.pt()); - + jetHist.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassHelium3 * o2::constants::physics::MassHelium3, trk.pt()); jetHist.fill(HIST("tracks/proton/h2TofNsigmaProtonVsPt_jet"), trk.tofNSigmaPr(), trk.pt()); jetHist.fill(HIST("tracks/deuteron/h2TofNsigmaDeuteronVsPt_jet"), trk.tofNSigmaDe(), trk.pt()); jetHist.fill(HIST("tracks/helium/h2TofNsigmaHeliumVsPt_jet"), trk.tofNSigmaHe(), trk.pt()); jetHist.fill(HIST("tracks/triton/h2TofNsigmaTritonVsPt_jet"), trk.tofNSigmaTr(), trk.pt()); - + jetHist.fill(HIST("tracks/proton/h3TpcNsigmaTofNsigmaProtonVsPt_jet"), trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.pt()); + jetHist.fill(HIST("tracks/deuteron/h3TpcNsigmaTofNsigmaDeuteronVsPt_jet"), trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.pt()); } else { - if (trk.tpcNSigmaPr() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { jetHist.fill(HIST("tracks/proton/h2TOFmassProtonVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt_jet"), massTOF * massTOF - gMassProton * gMassProton, trk.pt()); + jetHist.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt()); jetHist.fill(HIST("tracks/proton/h2TofNsigmaProtonVsPt_jet"), trk.tofNSigmaPr(), trk.pt()); + jetHist.fill(HIST("tracks/proton/h3TpcNsigmaTofNsigmaProtonVsPt_jet"), trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.pt()); } - - if (trk.tpcNSigmaDe() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { jetHist.fill(HIST("tracks/deuteron/h2TOFmassDeuteronVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt_jet"), massTOF * massTOF - gMassDeuteron * gMassDeuteron, trk.pt()); + jetHist.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt()); jetHist.fill(HIST("tracks/deuteron/h2TofNsigmaDeuteronVsPt_jet"), trk.tofNSigmaDe(), trk.pt()); + jetHist.fill(HIST("tracks/deuteron/h3TpcNsigmaTofNsigmaDeuteronVsPt_jet"), trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.pt()); } - if (trk.tpcNSigmaTr() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaTr()) < cfgnTPCPIDTr) { jetHist.fill(HIST("tracks/triton/h2TOFmassTritonVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt_jet"), massTOF * massTOF - gMassTriton * gMassTriton, trk.pt()); - jetHist.fill(HIST("tracks/helium/h2TofNsigmaHeliumVsPt_jet"), trk.tofNSigmaHe(), trk.pt()); + jetHist.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassTriton * o2::constants::physics::MassTriton, trk.pt()); + jetHist.fill(HIST("tracks/triton/h2TofNsigmaTritonVsPt_jet"), trk.tofNSigmaTr(), trk.pt()); } - if (trk.tpcNSigmaHe() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { jetHist.fill(HIST("tracks/helium/h2TOFmassHeliumVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt_jet"), massTOF * massTOF - gMassHelium * gMassHelium, trk.pt()); - jetHist.fill(HIST("tracks/triton/h2TofNsigmaTritonVsPt_jet"), trk.tofNSigmaTr(), trk.pt()); + jetHist.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassHelium3 * o2::constants::physics::MassHelium3, trk.pt()); + jetHist.fill(HIST("tracks/helium/h2TofNsigmaHeliumVsPt_jet"), trk.tofNSigmaHe(), trk.pt()); } } // nSigma @@ -680,10 +863,51 @@ struct nucleiInJets { jetHist.fill(HIST("tracks/antiPion/h3PtVsPionNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPi(), jetPt); jetHist.fill(HIST("tracks/antiKaon/h3PtVsKaonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaKa(), jetPt); } - jetHist.fill(HIST("tracks/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); - jetHist.fill(HIST("tracks/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); - jetHist.fill(HIST("tracks/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); - jetHist.fill(HIST("tracks/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + + if (useTOFNsigmaPreSel && trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) + jetHist.fill(HIST("tracks/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) + jetHist.fill(HIST("tracks/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); + if (std::abs(trk.tofNSigmaHe()) < cfgnTPCPIDHeTOF) + jetHist.fill(HIST("tracks/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); + if (std::abs(trk.tofNSigmaTr()) < cfgnTPCPIDTrTOF) + jetHist.fill(HIST("tracks/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + } else if (!useTOFNsigmaPreSel && !useTOFVeto) { + jetHist.fill(HIST("tracks/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); + jetHist.fill(HIST("tracks/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); + jetHist.fill(HIST("tracks/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); + jetHist.fill(HIST("tracks/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + } else if (!useTOFNsigmaPreSel && useTOFVeto) { + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) { + jetHist.fill(HIST("tracks/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); + } + } else { + jetHist.fill(HIST("tracks/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) { + jetHist.fill(HIST("tracks/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); + } + } else { + jetHist.fill(HIST("tracks/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaHe()) < cfgnTPCPIDHeTOF) { + jetHist.fill(HIST("tracks/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); + } + } else { + jetHist.fill(HIST("tracks/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaTr()) < cfgnTPCPIDTrTOF) { + jetHist.fill(HIST("tracks/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + } + } else { + jetHist.fill(HIST("tracks/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet_jet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); + } + } if (cEnableProtonQA && std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { jetHist.fill(HIST("tracks/antiProton/dca/after/hDCAxyVsPtantiProton_jet"), trk.dcaXY(), trk.pt()); @@ -693,7 +917,7 @@ struct nucleiInJets { jetHist.fill(HIST("tracks/antiDeuteron/dca/after/hDCAxyVsPtantiDeuteron_jet"), trk.dcaXY(), trk.pt()); jetHist.fill(HIST("tracks/antiDeuteron/dca/after/hDCAzVsPtantiDeuteron_jet"), trk.dcaZ(), trk.pt()); } - if (cEnableHeliumQA && std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { + if (cEnableHeliumQA && std::abs(trk.tpcNSigmaTr()) < cfgnTPCPIDTr) { jetHist.fill(HIST("tracks/antiTriton/dca/after/hDCAxyVsPtantiTriton_jet"), trk.dcaXY(), trk.pt()); jetHist.fill(HIST("tracks/antiTriton/dca/after/hDCAzVsPtantiTriton_jet"), trk.dcaZ(), trk.pt()); } @@ -705,52 +929,55 @@ struct nucleiInJets { if (addTOFplots && trk.hasTOF()) { if (!useTPCpreSel) { jetHist.fill(HIST("tracks/antiProton/h2TOFmassantiProtonVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiProton/h2TOFmass2antiProtonVsPt_jet"), massTOF * massTOF - gMassProton * gMassProton, trk.pt()); + jetHist.fill(HIST("tracks/antiProton/h2TOFmass2antiProtonVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt()); jetHist.fill(HIST("tracks/antiProton/h2TofNsigmaantiProtonVsPt_jet"), trk.tofNSigmaPr(), trk.pt()); + jetHist.fill(HIST("tracks/antiProton/h3TpcNsigmaTofNsigmaantiProtonVsPt_jet"), trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.pt()); jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmassantiDeuteronVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt_jet"), massTOF * massTOF - gMassDeuteron * gMassDeuteron, trk.pt()); + jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt()); jetHist.fill(HIST("tracks/antiDeuteron/h2TofNsigmaantiDeuteronVsPt_jet"), trk.tofNSigmaDe(), trk.pt()); + jetHist.fill(HIST("tracks/antiDeuteron/h3TpcNsigmaTofNsigmaantiDeuteronVsPt_jet"), trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.pt()); jetHist.fill(HIST("tracks/antiTriton/h2TOFmassantiTritonVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiTriton/h2TOFmass2antiTritonVsPt_jet"), massTOF * massTOF - gMassTriton * gMassTriton, trk.pt()); + jetHist.fill(HIST("tracks/antiTriton/h2TOFmass2antiTritonVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassTriton * o2::constants::physics::MassTriton, trk.pt()); jetHist.fill(HIST("tracks/antiTriton/h2TofNsigmaantiTritonVsPt_jet"), trk.tofNSigmaTr(), trk.pt()); jetHist.fill(HIST("tracks/antiHelium/h2TOFmassantiHeliumVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiHelium/h2TOFmass2antiHeliumVsPt_jet"), massTOF * massTOF - gMassHelium * gMassHelium, trk.pt()); + jetHist.fill(HIST("tracks/antiHelium/h2TOFmass2antiHeliumVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassHelium3 * o2::constants::physics::MassHelium3, trk.pt()); jetHist.fill(HIST("tracks/antiHelium/h2TofNsigmaantiHeliumVsPt_jet"), trk.tofNSigmaHe(), trk.pt()); } else { - if (trk.tpcNSigmaPr() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { jetHist.fill(HIST("tracks/antiProton/h2TOFmassantiProtonVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiProton/h2TOFmass2antiProtonVsPt_jet"), massTOF * massTOF - gMassProton * gMassProton, trk.pt()); + jetHist.fill(HIST("tracks/antiProton/h2TOFmass2antiProtonVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt()); jetHist.fill(HIST("tracks/antiProton/h2TofNsigmaantiProtonVsPt_jet"), trk.tofNSigmaPr(), trk.pt()); + jetHist.fill(HIST("tracks/antiProton/h3TpcNsigmaTofNsigmaantiProtonVsPt_jet"), trk.tpcNSigmaPr(), trk.tofNSigmaPr(), trk.pt()); } - if (trk.tpcNSigmaDe() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmassantiDeuteronVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt_jet"), massTOF * massTOF - gMassDeuteron * gMassDeuteron, trk.pt()); + jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt()); jetHist.fill(HIST("tracks/antiDeuteron/h2TofNsigmaantiDeuteronVsPt_jet"), trk.tofNSigmaDe(), trk.pt()); + jetHist.fill(HIST("tracks/antiDeuteron/h3TpcNsigmaTofNsigmaantiDeuteronVsPt_jet"), trk.tpcNSigmaDe(), trk.tofNSigmaDe(), trk.pt()); } - if (trk.tpcNSigmaTr() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaTr()) < cfgnTPCPIDTr) { jetHist.fill(HIST("tracks/antiTriton/h2TOFmassantiTritonVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiTriton/h2TOFmass2antiTritonVsPt_jet"), massTOF * massTOF - gMassTriton * gMassTriton, trk.pt()); + jetHist.fill(HIST("tracks/antiTriton/h2TOFmass2antiTritonVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassTriton * o2::constants::physics::MassTriton, trk.pt()); jetHist.fill(HIST("tracks/antiTriton/h2TofNsigmaantiTritonVsPt_jet"), trk.tofNSigmaTr(), trk.pt()); } - if (trk.tpcNSigmaHe() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { jetHist.fill(HIST("tracks/antiHelium/h2TOFmassantiHeliumVsPt_jet"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiHelium/h2TOFmass2antiHeliumVsPt_jet"), massTOF * massTOF - gMassHelium * gMassHelium, trk.pt()); + jetHist.fill(HIST("tracks/antiHelium/h2TOFmass2antiHeliumVsPt_jet"), massTOF * massTOF - o2::constants::physics::MassHelium3 * o2::constants::physics::MassHelium3, trk.pt()); jetHist.fill(HIST("tracks/antiHelium/h2TofNsigmaantiHeliumVsPt_jet"), trk.tofNSigmaHe(), trk.pt()); } } - if (addpik) { if (!useTPCpreSel) { jetHist.fill(HIST("tracks/antiPion/h2TofNsigmaantiPionVsPt_jet"), trk.tofNSigmaPi(), trk.pt()); jetHist.fill(HIST("tracks/antiKaon/h2TofNsigmaantiKaonVsPt_jet"), trk.tofNSigmaKa(), trk.pt()); } else { - if (trk.tpcNSigmaPi() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaPi()) < useTPCpreSel) { jetHist.fill(HIST("tracks/antiPion/h2TofNsigmaantiPionVsPt_jet"), trk.tofNSigmaPi(), trk.pt()); } - if (trk.tpcNSigmaKa() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaKa()) < useTPCpreSel) { jetHist.fill(HIST("tracks/antiKaon/h2TofNsigmaantiKaonVsPt_jet"), trk.tofNSigmaKa(), trk.pt()); } } @@ -775,10 +1002,50 @@ struct nucleiInJets { jetHist.fill(HIST("tracks/triton/h3PtVsTritonNSigmaTPC"), trk.pt(), trk.tpcNSigmaTr()); // Tr // perpCone if (jetFlagPerpCone && isWithLeadingJet) { - jetHist.fill(HIST("tracks/perpCone/proton/h3PtVsProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr - jetHist.fill(HIST("tracks/perpCone/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De - jetHist.fill(HIST("tracks/perpCone/helium/h3PtVsHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He - jetHist.fill(HIST("tracks/perpCone/triton/h3PtVsTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + if (useTOFNsigmaPreSel && trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) + jetHist.fill(HIST("tracks/perpCone/proton/h3PtVsProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) + jetHist.fill(HIST("tracks/perpCone/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De + if (std::abs(trk.tofNSigmaHe()) < cfgnTPCPIDHeTOF) + jetHist.fill(HIST("tracks/perpCone/helium/h3PtVsHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He + if (std::abs(trk.tofNSigmaTr()) < cfgnTPCPIDTrTOF) + jetHist.fill(HIST("tracks/perpCone/triton/h3PtVsTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + } else if (!useTOFNsigmaPreSel && !useTOFVeto) { + jetHist.fill(HIST("tracks/perpCone/proton/h3PtVsProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr + jetHist.fill(HIST("tracks/perpCone/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De + jetHist.fill(HIST("tracks/perpCone/helium/h3PtVsHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He + jetHist.fill(HIST("tracks/perpCone/triton/h3PtVsTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + } else if (!useTOFNsigmaPreSel && useTOFVeto) { + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) { + jetHist.fill(HIST("tracks/perpCone/proton/h3PtVsProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr + } + } else { + jetHist.fill(HIST("tracks/perpCone/proton/h3PtVsProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) { + jetHist.fill(HIST("tracks/perpCone/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De + } + } else { + jetHist.fill(HIST("tracks/perpCone/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaHe()) < cfgnTPCPIDHeTOF) { + jetHist.fill(HIST("tracks/perpCone/helium/h3PtVsHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He + } + } else { + jetHist.fill(HIST("tracks/perpCone/helium/h3PtVsHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaTr()) < cfgnTPCPIDTrTOF) { + jetHist.fill(HIST("tracks/perpCone/triton/h3PtVsTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + } + } else { + jetHist.fill(HIST("tracks/perpCone/triton/h3PtVsTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + } + } } if (cEnableProtonQA && std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { @@ -789,7 +1056,7 @@ struct nucleiInJets { jetHist.fill(HIST("tracks/deuteron/dca/after/hDCAxyVsPtDeuteron"), trk.dcaXY(), trk.pt()); jetHist.fill(HIST("tracks/deuteron/dca/after/hDCAzVsPtDeuteron"), trk.dcaZ(), trk.pt()); } - if (cEnableTritonQA && std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDTr) { + if (cEnableTritonQA && std::abs(trk.tpcNSigmaTr()) < cfgnTPCPIDTr) { jetHist.fill(HIST("tracks/triton/dca/after/hDCAxyVsPtTriton"), trk.dcaXY(), trk.pt()); jetHist.fill(HIST("tracks/triton/dca/after/hDCAzVsPtTriton"), trk.dcaZ(), trk.pt()); } @@ -800,65 +1067,103 @@ struct nucleiInJets { if (addTOFplots && trk.hasTOF()) { if (!useTPCpreSel) { jetHist.fill(HIST("tracks/proton/h2TOFmassProtonVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt"), massTOF * massTOF - gMassProton * gMassProton, trk.pt()); + jetHist.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt()); jetHist.fill(HIST("tracks/proton/h2TofNsigmaProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); jetHist.fill(HIST("tracks/deuteron/h2TOFmassDeuteronVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt"), massTOF * massTOF - gMassDeuteron * gMassDeuteron, trk.pt()); + jetHist.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt()); jetHist.fill(HIST("tracks/deuteron/h2TofNsigmaDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); jetHist.fill(HIST("tracks/triton/h2TOFmassTritonVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt"), massTOF * massTOF - gMassTriton * gMassTriton, trk.pt()); + jetHist.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt"), massTOF * massTOF - o2::constants::physics::MassTriton * o2::constants::physics::MassTriton, trk.pt()); jetHist.fill(HIST("tracks/helium/h2TofNsigmaHeliumVsPt"), trk.tofNSigmaHe(), trk.pt()); jetHist.fill(HIST("tracks/helium/h2TOFmassHeliumVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt"), massTOF * massTOF - gMassHelium * gMassHelium, trk.pt()); + jetHist.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt"), massTOF * massTOF - o2::constants::physics::MassHelium3 * o2::constants::physics::MassHelium3, trk.pt()); jetHist.fill(HIST("tracks/triton/h2TofNsigmaTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); } else { - if (trk.tpcNSigmaPr() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { jetHist.fill(HIST("tracks/proton/h2TOFmassProtonVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt"), massTOF * massTOF - gMassProton * gMassProton, trk.pt()); + jetHist.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt()); jetHist.fill(HIST("tracks/proton/h2TofNsigmaProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); if (jetFlagPerpCone && isWithLeadingJet) jetHist.fill(HIST("tracks/perpCone/proton/h2TofNsigmaProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); } - if (trk.tpcNSigmaDe() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { jetHist.fill(HIST("tracks/deuteron/h2TOFmassDeuteronVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt"), massTOF * massTOF - gMassDeuteron * gMassDeuteron, trk.pt()); + jetHist.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt()); jetHist.fill(HIST("tracks/deuteron/h2TofNsigmaDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); if (jetFlagPerpCone && isWithLeadingJet) jetHist.fill(HIST("tracks/perpCone/deuteron/h2TofNsigmaDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); } - if (trk.tpcNSigmaTr() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaTr()) < cfgnTPCPIDTr) { jetHist.fill(HIST("tracks/triton/h2TOFmassTritonVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt"), massTOF * massTOF - gMassTriton * gMassTriton, trk.pt()); + jetHist.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt"), massTOF * massTOF - o2::constants::physics::MassTriton * o2::constants::physics::MassTriton, trk.pt()); jetHist.fill(HIST("tracks/triton/h2TofNsigmaTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); if (jetFlagPerpCone && isWithLeadingJet) jetHist.fill(HIST("tracks/perpCone/triton/h2TofNsigmaTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); } - if (trk.tpcNSigmaHe() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { jetHist.fill(HIST("tracks/helium/h2TOFmassHeliumVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt"), massTOF * massTOF - gMassHelium * gMassHelium, trk.pt()); + jetHist.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt"), massTOF * massTOF - o2::constants::physics::MassHelium3 * o2::constants::physics::MassHelium3, trk.pt()); jetHist.fill(HIST("tracks/helium/h2TofNsigmaHeliumVsPt"), trk.tofNSigmaHe(), trk.pt()); if (jetFlagPerpCone && isWithLeadingJet) jetHist.fill(HIST("tracks/perpCone/helium/h2TofNsigmaHeliumVsPt"), trk.tofNSigmaHe(), trk.pt()); } } - } // tof info } else { jetHist.fill(HIST("tracks/antiProton/h3PtVsantiProtonNSigmaTPC"), trk.pt(), trk.tpcNSigmaPr()); // Pr jetHist.fill(HIST("tracks/antiDeuteron/h3PtVsantiDeuteronNSigmaTPC"), trk.pt(), trk.tpcNSigmaDe()); // De jetHist.fill(HIST("tracks/antiHelium/h3PtVsantiHeliumNSigmaTPC"), trk.pt(), trk.tpcNSigmaHe()); // He jetHist.fill(HIST("tracks/antiTriton/h3PtVsantiTritonNSigmaTPC"), trk.pt(), trk.tpcNSigmaTr()); // Tr - // perpCone if (jetFlagPerpCone && isWithLeadingJet) { // antiparticle info - jetHist.fill(HIST("tracks/perpCone/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr - jetHist.fill(HIST("tracks/perpCone/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De - jetHist.fill(HIST("tracks/perpCone/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He - jetHist.fill(HIST("tracks/perpCone/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + if (useTOFNsigmaPreSel && trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) + jetHist.fill(HIST("tracks/perpCone/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) + jetHist.fill(HIST("tracks/perpCone/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De + if (std::abs(trk.tofNSigmaHe()) < cfgnTPCPIDHeTOF) + jetHist.fill(HIST("tracks/perpCone/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He + if (std::abs(trk.tofNSigmaTr()) < cfgnTPCPIDTrTOF) + jetHist.fill(HIST("tracks/perpCone/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + } else if (!useTOFNsigmaPreSel && !useTOFVeto) { + jetHist.fill(HIST("tracks/perpCone/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr + jetHist.fill(HIST("tracks/perpCone/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De + jetHist.fill(HIST("tracks/perpCone/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He + jetHist.fill(HIST("tracks/perpCone/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + } else if (!useTOFNsigmaPreSel && useTOFVeto) { + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) { + jetHist.fill(HIST("tracks/perpCone/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr + } + } else { + jetHist.fill(HIST("tracks/perpCone/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaPr(), jetPt); // Pr + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) { + jetHist.fill(HIST("tracks/perpCone/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De + } + } else { + jetHist.fill(HIST("tracks/perpCone/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaDe(), jetPt); // De + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaHe()) < cfgnTPCPIDHeTOF) { + jetHist.fill(HIST("tracks/perpCone/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He + } + } else { + jetHist.fill(HIST("tracks/perpCone/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaHe(), jetPt); // He + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaTr()) < cfgnTPCPIDTrTOF) { + jetHist.fill(HIST("tracks/perpCone/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + } + } else { + jetHist.fill(HIST("tracks/perpCone/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet"), trk.pt(), trk.tpcNSigmaTr(), jetPt); // Tr + } + } } if (cEnableProtonQA && std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { @@ -877,49 +1182,48 @@ struct nucleiInJets { jetHist.fill(HIST("tracks/antiHelium/dca/after/hDCAxyVsPtantiHelium"), trk.dcaXY(), trk.pt()); jetHist.fill(HIST("tracks/antiHelium/dca/after/hDCAzVsPtantiHelium"), trk.dcaZ(), trk.pt()); } - if (addTOFplots && trk.hasTOF()) { if (!useTPCpreSel) { jetHist.fill(HIST("tracks/antiProton/h2TOFmassantiProtonVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiProton/h2TOFmass2antiProtonVsPt"), massTOF * massTOF - gMassProton * gMassProton, trk.pt()); + jetHist.fill(HIST("tracks/antiProton/h2TOFmass2antiProtonVsPt"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt()); jetHist.fill(HIST("tracks/antiProton/h2TofNsigmaantiProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmassantiDeuteronVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt"), massTOF * massTOF - gMassDeuteron * gMassDeuteron, trk.pt()); + jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt()); jetHist.fill(HIST("tracks/antiDeuteron/h2TofNsigmaantiDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); jetHist.fill(HIST("tracks/antiTriton/h2TOFmassantiTritonVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiTriton/h2TOFmass2antiTritonVsPt"), massTOF * massTOF - gMassTriton * gMassTriton, trk.pt()); + jetHist.fill(HIST("tracks/antiTriton/h2TOFmass2antiTritonVsPt"), massTOF * massTOF - o2::constants::physics::MassTriton * o2::constants::physics::MassTriton, trk.pt()); jetHist.fill(HIST("tracks/antiHelium/h2TofNsigmaantiHeliumVsPt"), trk.tofNSigmaHe(), trk.pt()); jetHist.fill(HIST("tracks/antiHelium/h2TOFmassantiHeliumVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiHelium/h2TOFmass2antiHeliumVsPt"), massTOF * massTOF - gMassHelium * gMassHelium, trk.pt()); + jetHist.fill(HIST("tracks/antiHelium/h2TOFmass2antiHeliumVsPt"), massTOF * massTOF - o2::constants::physics::MassHelium3 * o2::constants::physics::MassHelium3, trk.pt()); jetHist.fill(HIST("tracks/antiTriton/h2TofNsigmaantiTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); } else { - if (trk.tpcNSigmaPr() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { jetHist.fill(HIST("tracks/antiProton/h2TOFmassantiProtonVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiProton/h2TOFmass2antiProtonVsPt"), massTOF * massTOF - gMassProton * gMassProton, trk.pt()); + jetHist.fill(HIST("tracks/antiProton/h2TOFmass2antiProtonVsPt"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt()); jetHist.fill(HIST("tracks/antiProton/h2TofNsigmaantiProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); if (jetFlagPerpCone && isWithLeadingJet) jetHist.fill(HIST("tracks/perpCone/antiProton/h2TofNsigmaantiProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); } - if (trk.tpcNSigmaDe() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmassantiDeuteronVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt"), massTOF * massTOF - gMassDeuteron * gMassDeuteron, trk.pt()); + jetHist.fill(HIST("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt()); jetHist.fill(HIST("tracks/antiDeuteron/h2TofNsigmaantiDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); if (jetFlagPerpCone && isWithLeadingJet) jetHist.fill(HIST("tracks/perpCone/antiDeuteron/h2TofNsigmaantiDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); } - if (trk.tpcNSigmaTr() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaTr()) < cfgnTPCPIDTr) { jetHist.fill(HIST("tracks/antiTriton/h2TOFmassantiTritonVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiTriton/h2TOFmass2antiTritonVsPt"), massTOF * massTOF - gMassTriton * gMassTriton, trk.pt()); + jetHist.fill(HIST("tracks/antiTriton/h2TOFmass2antiTritonVsPt"), massTOF * massTOF - o2::constants::physics::MassTriton * o2::constants::physics::MassTriton, trk.pt()); jetHist.fill(HIST("tracks/antiTriton/h2TofNsigmaantiTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); if (jetFlagPerpCone && isWithLeadingJet) jetHist.fill(HIST("tracks/perpCone/antiTriton/h2TofNsigmaantiTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); } - if (trk.tpcNSigmaHe() < useTPCpreSel) { + if (std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { jetHist.fill(HIST("tracks/antiHelium/h2TOFmassantiHeliumVsPt"), massTOF, trk.pt()); - jetHist.fill(HIST("tracks/antiHelium/h2TOFmass2antiHeliumVsPt"), massTOF * massTOF - gMassHelium * gMassHelium, trk.pt()); + jetHist.fill(HIST("tracks/antiHelium/h2TOFmass2antiHeliumVsPt"), massTOF * massTOF - o2::constants::physics::MassHelium3 * o2::constants::physics::MassHelium3, trk.pt()); jetHist.fill(HIST("tracks/antiHelium/h2TofNsigmaantiHeliumVsPt"), trk.tofNSigmaHe(), trk.pt()); if (jetFlagPerpCone && isWithLeadingJet) jetHist.fill(HIST("tracks/perpCone/antiHelium/h2TofNsigmaantiHeliumVsPt"), trk.tofNSigmaHe(), trk.pt()); @@ -927,20 +1231,30 @@ struct nucleiInJets { } } } - } //////////////////////////////////////// // outside jet end //////////////////////////////////////// } - void processJetTracksData(aod::JCollision const& collision, chargedJetstrack const& chargedjets, soa::Join const& tracks, TrackCandidates const&) + void processJetTracksData(soa::Join::iterator const& collision, + chargedJetstrack const& chargedjets, soa::Join const& tracks, TrackCandidates const&, aod::JBCs const&) { - - if (fabs(collision.posZ()) > 10) + auto bc = collision.bc_as(); + initCCDB(bc); + if (applySkim) { + jetHist.fill(HIST("hNEvents"), 0.5); + bool zorroSelected = zorro.isSelected(bc.globalBC()); + if (!zorroSelected) { + return; + } + jetHist.fill(HIST("hNEvents"), 1.5); + } + if (std::abs(collision.posZ()) > 10) return; - if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) + jetHist.fill(HIST("hNEvents"), 2.5); + if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel8"))) return; - + jetHist.fill(HIST("hNEvents"), 3.5); int nJets = 0; std::vector leadingJetWithPtEtaPhi(3); float leadingJetPt = -1.0f; @@ -956,36 +1270,230 @@ struct nucleiInJets { } nJets++; } - jetHist.fill(HIST("jet/nJetsPerEvent"), nJets); jetHist.fill(HIST("vertexZ"), collision.posZ()); - - if (nJets > 0) + if (nJets > 0) { jetHist.fill(HIST("jet/vertexZ"), collision.posZ()); - else + jetHist.fill(HIST("hNEvents"), 4.5); + } else { jetHist.fill(HIST("jetOut/vertexZ"), collision.posZ()); - + } if (isWithJetEvents && nJets == 0) return; jetHist.fill(HIST("jet/h1JetEvents"), 0.5); + for (const auto& track : tracks) { + auto trk = track.track_as(); + fillTrackInfo(trk, chargedjets, leadingJetWithPtEtaPhi); + } + } - for (auto& track : tracks) { - if (useLfTpcPid) { - auto trk = track.track_as(); - fillTrackInfo(trk, chargedjets, leadingJetWithPtEtaPhi); - } else { - auto trk = track.track_as(); - fillTrackInfo(trk, chargedjets, leadingJetWithPtEtaPhi); + void processJetTracksDataLfPid(soa::Join::iterator const& collision, + chargedJetstrack const& chargedjets, soa::Join const& tracks, TrackCandidatesLfPid const&, aod::JBCs const&) + { + auto bc = collision.bc_as(); + initCCDB(bc); + if (applySkim) { + jetHist.fill(HIST("hNEvents"), 0.5); + bool zorroSelected = zorro.isSelected(bc.globalBC()); + if (!zorroSelected) { + return; + } + jetHist.fill(HIST("hNEvents"), 1.5); + } + if (std::abs(collision.posZ()) > 10) + return; + jetHist.fill(HIST("hNEvents"), 2.5); + + if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel8"))) + return; + jetHist.fill(HIST("hNEvents"), 3.5); + int nJets = 0; + std::vector leadingJetWithPtEtaPhi(3); + float leadingJetPt = -1.0f; + for (const auto& chargedjet : chargedjets) { + jetHist.fill(HIST("jet/h1JetPt"), chargedjet.pt()); + jetHist.fill(HIST("jet/h1JetEta"), chargedjet.eta()); + jetHist.fill(HIST("jet/h1JetPhi"), chargedjet.phi()); + if (chargedjet.pt() > leadingJetPt) { + leadingJetWithPtEtaPhi[0] = chargedjet.pt(); + leadingJetWithPtEtaPhi[1] = chargedjet.eta(); + leadingJetWithPtEtaPhi[2] = chargedjet.phi(); } + nJets++; + } + jetHist.fill(HIST("jet/nJetsPerEvent"), nJets); + jetHist.fill(HIST("vertexZ"), collision.posZ()); + if (nJets > 0) { + jetHist.fill(HIST("jet/vertexZ"), collision.posZ()); + jetHist.fill(HIST("hNEvents"), 4.5); + } else { + jetHist.fill(HIST("jetOut/vertexZ"), collision.posZ()); + } + if (isWithJetEvents && nJets == 0) + return; + jetHist.fill(HIST("jet/h1JetEvents"), 0.5); + for (auto& track : tracks) { + auto trk = track.track_as(); + fillTrackInfo(trk, chargedjets, leadingJetWithPtEtaPhi); } } - void processMCGen(o2::aod::JMcCollision const& collision, /*soa::SmallGroups> const& recoColls,*/ aod::JMcParticles const& mcParticles, soa::Filtered const& mcpjets) + void processDataInc(EventTable::iterator const& coll, soa::Join const& tracks, TrackCandidates const&) + { + jetHist.fill(HIST("hNEventsInc"), 0.5); + + if (!jetderiveddatautilities::selectCollision(coll, jetderiveddatautilities::initialiseEventSelectionBits("sel8"))) + return; + + jetHist.fill(HIST("hNEventsInc"), 1.5); + if (std::abs(coll.posZ()) > 10) // bad vertex + return; + jetHist.fill(HIST("hNEventsInc"), 2.5); + float centrality = -999; + switch (centralityType) { + case 0: // FT0M + centrality = coll.centFT0M(); + break; + case 1: // FT0C + centrality = coll.centFT0C(); + break; + case 2: // V0A + centrality = coll.centFV0A(); + break; + default: + centrality = -999; + } + jetHist.fill(HIST("hNEventsIncVsCent"), coll.posZ(), centrality); + for (const auto& track : tracks) { + auto trk = track.track_as(); + if (!isTrackSelected(trk)) { + continue; + } + if (std::fabs(trk.eta()) > cfgtrkMaxEta) + continue; + if (trk.sign() > 0) { // particle info + if (useTOFNsigmaPreSel && trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) + jetHist.fill(HIST("tracksInc/proton/h3PtVsProtonNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaPr(), centrality); + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) + jetHist.fill(HIST("tracksInc/deuteron/h3PtVsDeuteronNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaDe(), centrality); + } else if (!useTOFNsigmaPreSel && !useTOFVeto) { + jetHist.fill(HIST("tracksInc/proton/h3PtVsProtonNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaPr(), centrality); + jetHist.fill(HIST("tracksInc/deuteron/h3PtVsDeuteronNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaDe(), centrality); + + } else if (!useTOFNsigmaPreSel && useTOFVeto) { + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) { + jetHist.fill(HIST("tracksInc/proton/h3PtVsProtonNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaPr(), centrality); + } + } else { + jetHist.fill(HIST("tracksInc/proton/h3PtVsProtonNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaPr(), centrality); + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) { + jetHist.fill(HIST("tracksInc/deuteron/h3PtVsDeuteronNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaDe(), centrality); + } + } else { + jetHist.fill(HIST("tracksInc/deuteron/h3PtVsDeuteronNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaDe(), centrality); + } + } + float massTOF = -999; + if (addTOFplots && trk.hasTOF()) { + massTOF = trk.p() * std::sqrt(1.f / (trk.beta() * trk.beta()) - 1.f); + if (!useTPCpreSel) { + jetHist.fill(HIST("tracksInc/proton/h2TOFmassProtonVsPt"), massTOF, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/proton/h2TOFmass2ProtonVsPt"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/proton/h2TofNsigmaProtonVsPt"), trk.tofNSigmaPr(), trk.pt(), centrality); + + jetHist.fill(HIST("tracksInc/deuteron/h2TOFmassDeuteronVsPt"), massTOF, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/deuteron/h2TOFmass2DeuteronVsPt"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/deuteron/h2TofNsigmaDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt(), centrality); + } else { + if (std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { + jetHist.fill(HIST("tracksInc/proton/h2TOFmassProtonVsPt"), massTOF, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/proton/h2TOFmass2ProtonVsPt"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/proton/h2TofNsigmaProtonVsPt"), trk.tofNSigmaPr(), trk.pt(), centrality); + } + if (std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { + jetHist.fill(HIST("tracksInc/deuteron/h2TOFmassDeuteronVsPt"), massTOF, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/deuteron/h2TOFmass2DeuteronVsPt"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/deuteron/h2TofNsigmaDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt(), centrality); + } + } + } + + if (cEnableProtonQA && std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { + jetHist.fill(HIST("tracksInc/proton/dca/after/hDCAxyVsPtProton"), trk.dcaXY(), trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/proton/dca/after/hDCAzVsPtProton"), trk.dcaZ(), trk.pt(), centrality); + } + if (cEnableDeuteronQA && std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { + jetHist.fill(HIST("tracksInc/deuteron/dca/after/hDCAxyVsPtDeuteron"), trk.dcaXY(), trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/deuteron/dca/after/hDCAzVsPtDeuteron"), trk.dcaZ(), trk.pt(), centrality); + } + + } else { // anti-particle info + if (useTOFNsigmaPreSel && trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) + jetHist.fill(HIST("tracksInc/antiProton/h3PtVsantiProtonNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaPr(), centrality); + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) + jetHist.fill(HIST("tracksInc/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaDe(), centrality); + } else if (!useTOFNsigmaPreSel && !useTOFVeto) { + jetHist.fill(HIST("tracksInc/antiProton/h3PtVsantiProtonNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaPr(), centrality); + jetHist.fill(HIST("tracksInc/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaDe(), centrality); + } else if (!useTOFNsigmaPreSel && useTOFVeto) { + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaPr()) < cfgnTPCPIDPrTOF) { + jetHist.fill(HIST("tracksInc/antiProton/h3PtVsantiProtonNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaPr(), centrality); + } + } else { + jetHist.fill(HIST("tracksInc/antiProton/h3PtVsantiProtonNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaPr(), centrality); + } + if (trk.hasTOF()) { + if (std::abs(trk.tofNSigmaDe()) < cfgnTPCPIDDeTOF) { + jetHist.fill(HIST("tracksInc/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaDe(), centrality); + } + } else { + jetHist.fill(HIST("tracksInc/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPt"), trk.pt(), trk.tpcNSigmaDe(), centrality); + } + } + float massTOF = -999; + if (addTOFplots && trk.hasTOF()) { + massTOF = trk.p() * std::sqrt(1.f / (trk.beta() * trk.beta()) - 1.f); + if (!useTPCpreSel) { + jetHist.fill(HIST("tracksInc/antiProton/h2TOFmassantiProtonVsPt"), massTOF, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiProton/h2TOFmass2antiProtonVsPt"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiProton/h2TofNsigmaantiProtonVsPt"), trk.tofNSigmaPr(), trk.pt(), centrality); + + jetHist.fill(HIST("tracksInc/antiDeuteron/h2TOFmassantiDeuteronVsPt"), massTOF, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiDeuteron/h2TOFmass2antiDeuteronVsPt"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiDeuteron/h2TofNsigmaantiDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt(), centrality); + } else { + if (std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { + jetHist.fill(HIST("tracksInc/antiProton/h2TOFmassantiProtonVsPt"), massTOF, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiProton/h2TOFmass2antiProtonVsPt"), massTOF * massTOF - o2::constants::physics::MassProton * o2::constants::physics::MassProton, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiProton/h2TofNsigmaantiProtonVsPt"), trk.tofNSigmaPr(), trk.pt(), centrality); + } + if (std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { + jetHist.fill(HIST("tracksInc/antiDeuteron/h2TOFmassantiDeuteronVsPt"), massTOF, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiDeuteron/h2TOFmass2antiDeuteronVsPt"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiDeuteron/h2TofNsigmaantiDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt(), centrality); + } else { + jetHist.fill(HIST("tracksInc/antiDeuteron/h2TOFmassantiDeuteronVsPt"), massTOF, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiDeuteron/h2TOFmass2antiDeuteronVsPt"), massTOF * massTOF - o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron, trk.pt(), centrality); + jetHist.fill(HIST("tracksInc/antiDeuteron/h2TofNsigmaantiDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt(), centrality); + } + } + } + } // anti-particle info end + } // track + } + + void processMCGen(o2::aod::JetMcCollision const& collision, /*soa::SmallGroups> const& recoColls,*/ aod::JetParticles const& mcParticles, soa::Filtered const& mcpjets) { jetHist.fill(HIST("mcpJet/eventStat"), 0.5); jetHist.fill(HIST("mcpJet/eventStat"), 1.5); - if (fabs(collision.posZ()) > 10) // bad vertex + if (std::abs(collision.posZ()) > 10) // bad vertex return; jetHist.fill(HIST("mcpJet/eventStat"), 2.5); @@ -994,18 +1502,17 @@ struct nucleiInJets { bool INELgt0 = false; for (const auto& mcParticle : mcParticles) { - if (fabs(mcParticle.eta()) < cfgtrkMaxEta) { + if (std::fabs(mcParticle.eta()) < cfgtrkMaxEta) { INELgt0 = true; break; } } if (!INELgt0) // not true INEL return; - jetHist.fill(HIST("mcpJet/eventStat"), 3.5); int nJets = 0; - for (auto& mcpjet : mcpjets) { + for (const auto& mcpjet : mcpjets) { jetHist.fill(HIST("mcpJet/hJetPt"), mcpjet.pt()); jetHist.fill(HIST("mcpJet/hJetEta"), mcpjet.eta()); jetHist.fill(HIST("mcpJet/hJetPhi"), mcpjet.phi()); @@ -1014,20 +1521,19 @@ struct nucleiInJets { jetHist.fill(HIST("mcpJet/nJetsPerEvent"), nJets); for (const auto& mcParticle : mcParticles) { - if (!mcParticle.isPhysicalPrimary()) continue; - if (fabs(mcParticle.eta()) > cfgtrkMaxEta) + if (std::fabs(mcParticle.eta()) > cfgtrkMaxEta) continue; - if (fabs(mcParticle.y()) > cfgtrkMaxRap) + if (std::fabs(mcParticle.y()) > cfgtrkMaxRap) continue; bool jetFlag = false; // float jetPt = -999.; - for (auto& mcpjet : mcpjets) { + for (const auto& mcpjet : mcpjets) { double delPhi = TVector2::Phi_mpi_pi(mcpjet.phi() - mcParticle.phi()); double delEta = mcpjet.eta() - mcParticle.eta(); - double R = TMath::Sqrt((delEta * delEta) + (delPhi * delPhi)); + double R = RecoDecay::sqrtSumOfSquares(delEta, delPhi); if (R < cfgjetR) jetFlag = true; // jetPt = mcpjet.pt(); @@ -1036,29 +1542,25 @@ struct nucleiInJets { if (mapPDGToValue(mcParticle.pdgCode()) != 0) { jetHist.fill(HIST("mcpJet/pt/PtParticleType"), mcParticle.pt(), jetFlag, mapPDGToValue(mcParticle.pdgCode())); } - } // track } // process mc - void processMCRec(o2::aod::JCollision const& collisionJet, soa::Join const& tracks, + void processMCRec(o2::aod::JetCollision const& collisionJet, soa::Join const& tracks, soa::Filtered const& mcdjets, TrackCandidatesMC const&, aod::JetParticles const&) { jetHist.fill(HIST("mcdJet/eventStat"), 0.5); - // JEhistos.fill(HIST("nEvents_MCRec"), 0.5); - - if (!jetderiveddatautilities::selectCollision(collisionJet, jetderiveddatautilities::JCollisionSel::sel8)) + if (!jetderiveddatautilities::selectCollision(collisionJet, jetderiveddatautilities::initialiseEventSelectionBits("sel8"))) return; // bool jetFlag = kFALSE; - jetHist.fill(HIST("mcdJet/eventStat"), 1.5); - if (fabs(collisionJet.posZ()) > 10) + if (std::abs(collisionJet.posZ()) > 10) return; jetHist.fill(HIST("mcdJet/eventStat"), 2.5); bool INELgt0 = false; for (const auto& track : tracks) { - if (fabs(track.eta()) < cfgtrkMaxEta) { + if (std::fabs(track.eta()) < cfgtrkMaxEta) { INELgt0 = true; break; } @@ -1080,75 +1582,70 @@ struct nucleiInJets { } nJets++; } - jetHist.fill(HIST("mcdJet/vertexZ"), collisionJet.posZ()); jetHist.fill(HIST("mcdJet/nJetsPerEvent"), nJets); - if (isWithJetEvents && nJets == 0) return; - - for (auto& track : tracks) { + for (const auto& track : tracks) { auto fullTrack = track.track_as(); if (!isTrackSelected(fullTrack)) continue; if (!track.has_mcParticle()) continue; auto mcTrack = track.mcParticle_as(); - if (fabs(mcTrack.eta()) > cfgtrkMaxEta) + if (std::fabs(mcTrack.eta()) > cfgtrkMaxEta) continue; if (!mcTrack.isPhysicalPrimary()) continue; - bool jetFlag = false; bool jetFlagPerpCone = false; // float jetPt = -999.; if (isWithLeadingJet) { double delPhi = TVector2::Phi_mpi_pi(leadingJetWithPtEtaPhi[2] - track.phi()); double delEta = leadingJetWithPtEtaPhi[1] - track.eta(); - double R = TMath::Sqrt((delEta * delEta) + (delPhi * delPhi)); + double R = RecoDecay::sqrtSumOfSquares(delEta, delPhi); if (R < cfgjetR) jetFlag = true; std::array perpConePhiJet = getPerpendicuarPhi(leadingJetWithPtEtaPhi[2]); double delPhiPerpCone1 = TVector2::Phi_mpi_pi(perpConePhiJet[0] - track.phi()); double delPhiPerpCone2 = TVector2::Phi_mpi_pi(perpConePhiJet[1] - track.phi()); - double RPerpCone1 = TMath::Sqrt((delEta * delEta) + (delPhiPerpCone1 * delPhiPerpCone1)); - double RPerpCone2 = TMath::Sqrt((delEta * delEta) + (delPhiPerpCone2 * delPhiPerpCone2)); + double RPerpCone1 = RecoDecay::sqrtSumOfSquares(delEta, delPhiPerpCone1); + double RPerpCone2 = RecoDecay::sqrtSumOfSquares(delEta, delPhiPerpCone2); if (RPerpCone1 < cfgjetR || RPerpCone2 < cfgjetR) jetFlagPerpCone = true; } else { - for (auto& mcdjet : mcdjets) { + for (const auto& mcdjet : mcdjets) { double delPhi = TVector2::Phi_mpi_pi(mcdjet.phi() - track.phi()); double delEta = mcdjet.eta() - track.eta(); - double R = TMath::Sqrt((delEta * delEta) + (delPhi * delPhi)); + double R = RecoDecay::sqrtSumOfSquares(delEta, delPhi); if (R < cfgjetR) jetFlag = true; // jetPt = mcdjet.pt(); break; } // jet } - if (mapPDGToValue(mcTrack.pdgCode()) != 0) { jetHist.fill(HIST("mcdJet/pt/PtParticleType"), mcTrack.pt(), jetFlag, mapPDGToValue(mcTrack.pdgCode())); if (jetFlagPerpCone) jetHist.fill(HIST("mcdJet/pt/perpCone/PtParticleType"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); } - } // tracks } - void processRecMatched(aod::JCollision const& collision, JetMCDetTable const& mcdjets, - soa::Join const& tracks, - JetMCPartTable const&, TrackCandidatesMC const&, aod::JMcParticles const&) + Preslice> perMCCol = aod::jmcparticle::mcCollisionId; + void processRecMatched(aod::JetCollisionMCD const& collision, JetMCDetTable const& mcdjets, + soa::Join const& tracks, + JetMCPartTable const&, TrackCandidatesMC const&, aod::JetParticles const& particleTracks, aod::JMcCollisions const&) { - if (fabs(collision.posZ()) > 10) + if (std::abs(collision.posZ()) > 10) return; - if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) + if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel8"))) return; jetHist.fill(HIST("recmatched/vertexZ"), collision.posZ()); bool INELgt0 = false; for (const auto& track : tracks) { - if (fabs(track.eta()) < cfgtrkMaxEta) { + if (std::fabs(track.eta()) < cfgtrkMaxEta) { INELgt0 = true; break; } @@ -1163,11 +1660,17 @@ struct nucleiInJets { std::vector mcpJetPhi{}; std::vector mcpJetEta{}; - for (auto& mcdjet : mcdjets) { + if (mcdjets.size() == 0) + return; + // LOG(info) <<" size(mcd) "< leadingJetWithPtEtaPhi(3); + for (const auto& mcdjet : mcdjets) { if (!mcdjet.has_matchedJetGeo()) continue; - for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { + for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { if (!mcpjet.has_matchedJetGeo()) continue; @@ -1182,69 +1685,194 @@ struct nucleiInJets { jetHist.fill(HIST("recmatched/hRecMatchedJetPhi"), mcpjet.phi(), mcpjet.phi() - mcdjet.phi()); jetHist.fill(HIST("recmatched/hRecMatchedJetEta"), mcpjet.eta(), mcpjet.eta() - mcdjet.eta()); + jetHist.fill(HIST("recmatched/hRecMatchedVsGenJetPtVsEta"), mcdjet.pt(), mcdjet.eta()); jetHist.fill(HIST("recmatched/hRecJetPt"), mcdjet.pt()); jetHist.fill(HIST("recmatched/hGenJetPt"), mcpjet.pt()); - jetHist.fill(HIST("recmatched/h2ResponseMatrix"), mcpjet.pt(), mcdjet.pt()); - + jetHist.fill(HIST("recmatched/h2ResponseMatrix"), mcdjet.pt(), mcpjet.pt()); } // mcpJet - } // mcdJet + if (mcdJetPt.size() == 0) + return; // no matched jet + auto itLeadPtJet = std::max_element(mcdJetPt.begin(), mcdJetPt.end()); + size_t indexJet = 0; // safe to be initialised with 0 + if (itLeadPtJet != mcdJetPt.end()) { + indexJet = std::distance(mcdJetPt.begin(), itLeadPtJet); + } else { + LOGP(fatal, "Error: Index {} is out of range for vectors!", indexJet); + } + if (useMcC) { + if (randUniform.Uniform(0, 1) < 0.5) + jetHist.fill(HIST("recmatched/h2ResponseMatrixLeadingJet"), mcdJetPt.at(indexJet), mcpJetPt.at(indexJet)); + else + jetHist.fill(HIST("recmatched/mcC/h2ResponseMatrixLeadingJet"), mcdJetPt.at(indexJet), mcpJetPt.at(indexJet)); + } else { + jetHist.fill(HIST("recmatched/h2ResponseMatrixLeadingJet"), mcdJetPt.at(indexJet), mcpJetPt.at(indexJet)); + } + if (useLeadingJetDetLevelValue) { + leadingJetWithPtEtaPhi[0] = mcdJetPt.at(indexJet); + leadingJetWithPtEtaPhi[1] = mcdJetEta.at(indexJet); + leadingJetWithPtEtaPhi[2] = mcdJetPhi.at(indexJet); + } else { + leadingJetWithPtEtaPhi[0] = mcpJetPt.at(indexJet); + leadingJetWithPtEtaPhi[1] = mcpJetEta.at(indexJet); + leadingJetWithPtEtaPhi[2] = mcpJetPhi.at(indexJet); + } + for (const auto& track : tracks) { auto completeTrack = track.track_as(); - if (fabs(completeTrack.eta()) > cfgtrkMaxEta) + if (std::fabs(completeTrack.eta()) > cfgtrkMaxEta) continue; if (!isTrackSelected(completeTrack)) continue; if (!track.has_mcParticle()) continue; auto mcTrack = track.mcParticle_as(); - // add pid later + if (!mcTrack.isPhysicalPrimary()) + continue; + if (std::fabs(mcTrack.y()) > cfgtrkMaxRap) + continue; - bool jetFlag = false; - for (std::size_t iDJet = 0; iDJet < mcdJetPt.size(); iDJet++) { - double delPhi = TVector2::Phi_mpi_pi(mcdJetPhi[iDJet] - track.phi()); - double delEta = mcdJetEta[iDJet] - track.eta(); - double R = TMath::Sqrt((delEta * delEta) + (delPhi * delPhi)); + bool isTpcPassed(true); + bool isTof(completeTrack.hasTOF()); + bool isTOFAndTPCPreSel(completeTrack.hasTOF() && + (std::abs(completeTrack.tpcNSigmaPr()) < cfgnTPCPIDPrTOF || std::abs(completeTrack.tpcNSigmaDe()) < cfgnTPCPIDDeTOF || + std::abs(completeTrack.tpcNSigmaHe()) < cfgnTPCPIDHeTOF || std::abs(completeTrack.tpcNSigmaTr()) < cfgnTPCPIDTrTOF)); - if (R < cfgjetR) { + bool jetFlag = false; + bool jetFlagPerpCone = false; + if (isWithLeadingJet) { + double delPhi = TVector2::Phi_mpi_pi(leadingJetWithPtEtaPhi[2] - track.phi()); + double delEta = leadingJetWithPtEtaPhi[1] - track.eta(); + double R = RecoDecay::sqrtSumOfSquares(delEta, delPhi); + if (R < cfgjetR) jetFlag = true; - break; + std::array perpConePhiJet = getPerpendicuarPhi(leadingJetWithPtEtaPhi[2]); + double delPhiPerpCone1 = TVector2::Phi_mpi_pi(perpConePhiJet[0] - track.phi()); + double delPhiPerpCone2 = TVector2::Phi_mpi_pi(perpConePhiJet[1] - track.phi()); + double RPerpCone1 = RecoDecay::sqrtSumOfSquares(delEta, delPhiPerpCone1); + double RPerpCone2 = RecoDecay::sqrtSumOfSquares(delEta, delPhiPerpCone2); + if (RPerpCone1 < cfgjetR || RPerpCone2 < cfgjetR) + jetFlagPerpCone = true; + } else { + for (std::size_t iDJet = 0; iDJet < mcdJetPt.size(); iDJet++) { + double delPhi = TVector2::Phi_mpi_pi(mcdJetPhi[iDJet] - track.phi()); + double delEta = mcdJetEta[iDJet] - track.eta(); + double R = RecoDecay::sqrtSumOfSquares(delEta, delPhi); + + if (R < cfgjetR) { + jetFlag = true; + break; + } } - } + } // jet if (mapPDGToValue(mcTrack.pdgCode()) != 0) { - jetHist.fill(HIST("recmatched/pt/PtParticleType"), mcTrack.pt(), jetFlag, mapPDGToValue(mcTrack.pdgCode())); + jetHist.fill(HIST("eff/recmatched/pt/PtParticleType"), mcTrack.pt(), jetFlag, mapPDGToValue(mcTrack.pdgCode())); + if (useMcC) { + if (randUniform.Uniform(0, 1) < 0.5) + jetHist.fill(HIST("eff/recmatched/mcC/pt/PtParticleType"), track.pt(), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + else + jetHist.fill(HIST("eff/recmatched/mcCSpectra/pt/PtParticleType"), track.pt(), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + } + if (isTpcPassed) + jetHist.fill(HIST("eff/recmatched/pt/PtParticleTypeTPC"), mcTrack.pt(), jetFlag, mapPDGToValue(mcTrack.pdgCode())); + if (isTof) + jetHist.fill(HIST("eff/recmatched/pt/PtParticleTypeTOF"), mcTrack.pt(), jetFlag, mapPDGToValue(mcTrack.pdgCode())); + if (isTOFAndTPCPreSel) { + jetHist.fill(HIST("eff/recmatched/pt/PtParticleTypeTPCTOF"), mcTrack.pt(), jetFlag, mapPDGToValue(mcTrack.pdgCode())); + jetHist.fill(HIST("eff/recmatched/pt/PtParticleTypeTPCTOFVeto"), mcTrack.pt(), jetFlag, mapPDGToValue(mcTrack.pdgCode())); + } else { + jetHist.fill(HIST("eff/recmatched/pt/PtParticleTypeTPCTOFVeto"), mcTrack.pt(), jetFlag, mapPDGToValue(mcTrack.pdgCode())); + } + + if (jetFlagPerpCone) { + jetHist.fill(HIST("eff/recmatched/perpCone/pt/PtParticleType"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + if (useMcC) { + if (randUniform.Uniform(0, 1) < 0.5) + jetHist.fill(HIST("eff/recmatched/perpCone/mcC/pt/PtParticleType"), track.pt(), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + else + jetHist.fill(HIST("eff/recmatched/perpCone/mcCSpectra/pt/PtParticleType"), track.pt(), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + } + if (isTpcPassed) + jetHist.fill(HIST("eff/recmatched/perpCone/pt/PtParticleTypeTPC"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + if (isTof) + jetHist.fill(HIST("eff/recmatched/perpCone/pt/PtParticleTypeTOF"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + if (isTOFAndTPCPreSel) { + jetHist.fill(HIST("eff/recmatched/perpCone/pt/PtParticleTypeTPCTOF"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + jetHist.fill(HIST("eff/recmatched/perpCone/pt/PtParticleTypeTPCTOFVeto"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + } + } else { + jetHist.fill(HIST("eff/recmatched/perpCone/pt/PtParticleTypeTPCTOFVeto"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode())); + } } } // tracks + + auto mcParticles_per_coll = particleTracks.sliceBy(perMCCol, collision.mcCollision().globalIndex()); + for (const auto& mcParticle : mcParticles_per_coll) { + if (!mcParticle.isPhysicalPrimary()) + continue; + if (std::fabs(mcParticle.eta()) > cfgtrkMaxEta) + continue; + if (std::fabs(mcParticle.y()) > cfgtrkMaxRap) + continue; + bool jetFlagMC = false; + bool jetFlagPerpConeMC = false; + if (isWithLeadingJet) { + double delPhi = TVector2::Phi_mpi_pi(leadingJetWithPtEtaPhi[2] - mcParticle.phi()); + double delEta = leadingJetWithPtEtaPhi[1] - mcParticle.eta(); + double R = RecoDecay::sqrtSumOfSquares(delEta, delPhi); + if (R < cfgjetR) + jetFlagMC = true; + std::array perpConePhiJet = getPerpendicuarPhi(leadingJetWithPtEtaPhi[2]); + double delPhiPerpCone1 = TVector2::Phi_mpi_pi(perpConePhiJet[0] - mcParticle.phi()); + double delPhiPerpCone2 = TVector2::Phi_mpi_pi(perpConePhiJet[1] - mcParticle.phi()); + double RPerpCone1 = RecoDecay::sqrtSumOfSquares(delEta, delPhiPerpCone1); + double RPerpCone2 = RecoDecay::sqrtSumOfSquares(delEta, delPhiPerpCone2); + if (RPerpCone1 < cfgjetR || RPerpCone2 < cfgjetR) + jetFlagPerpConeMC = true; + } else { + + for (std::size_t iDJet = 0; iDJet < mcdJetPt.size(); iDJet++) { + double delPhi = TVector2::Phi_mpi_pi(mcdJetPhi[iDJet] - mcParticle.phi()); + double delEta = mcdJetEta[iDJet] - mcParticle.eta(); + double R = RecoDecay::sqrtSumOfSquares(delEta, delPhi); + if (R < cfgjetR) { + jetFlagMC = true; + break; + } + } + } // jet + + if (mapPDGToValue(mcParticle.pdgCode()) != 0) { + jetHist.fill(HIST("eff/recmatched/gen/pt/PtParticleType"), mcParticle.pt(), jetFlagMC, mapPDGToValue(mcParticle.pdgCode())); + if (jetFlagPerpConeMC) { + jetHist.fill(HIST("eff/recmatched/gen/perpCone/pt/PtParticleType"), mcParticle.pt(), mapPDGToValue(mcParticle.pdgCode())); + } + } + } // mcParticle } // process int nprocessSimJEEvents = 0; - void processGenMatched(aod::JMcCollision const& collision, - /*soa::SmallGroups> const& recocolls,*/ - JetMCDetTable const&, JetMCPartTable const& mcpjets, aod::JMcParticles const& mcParticles) + void processGenMatched(aod::JetMcCollision const& collision, + soa::SmallGroups> const& recocolls, + JetMCDetTable const&, JetMCPartTable const& mcpjets, aod::JetParticles const& mcParticles) { - if (cDebugLevel > 0) { nprocessSimJEEvents++; if ((nprocessSimJEEvents + 1) % 100000 == 0) LOG(debug) << "Jet Events: " << nprocessSimJEEvents; } - if (fabs(collision.posZ()) > 10) + if (recocolls.size() <= 0) // not reconstructed return; - jetHist.fill(HIST("genmatched/vertexZ"), collision.posZ()); - - bool INELgt0 = false; - for (const auto& mcParticle : mcParticles) { - if (fabs(mcParticle.eta()) < cfgtrkMaxEta) { - INELgt0 = true; - break; - } + for (const auto& recocoll : recocolls) { // return if not reconstructed event based on our selection + if (!jetderiveddatautilities::selectCollision(recocoll, jetderiveddatautilities::initialiseEventSelectionBits("sel8"))) + return; } - if (!INELgt0) + if (std::abs(collision.posZ()) > 10) return; - + jetHist.fill(HIST("genmatched/vertexZ"), collision.posZ()); std::vector mcdJetPt{}; std::vector mcdJetPhi{}; std::vector mcdJetEta{}; @@ -1252,32 +1880,63 @@ struct nucleiInJets { std::vector mcpJetPhi{}; std::vector mcpJetEta{}; - for (auto& mcpjet : mcpjets) { + // Find the mcpjet with the highest pt + auto itLeadPtJet = mcpjets.begin(); + float maxPt = -1.0f; + + for (auto it = mcpjets.begin(); it != mcpjets.end(); ++it) { + if (it.pt() > maxPt) { + maxPt = it.pt(); + itLeadPtJet = it; + LOG(debug) << " mcp jet pT " << it.pt() << " " << __LINE__; + } + } + // Process all MCP jets for general histograms + for (const auto& mcpjet : mcpjets) { jetHist.fill(HIST("genmatched/hGenJetPt"), mcpjet.pt()); if (!mcpjet.has_matchedJetGeo()) continue; jetHist.fill(HIST("genmatched/hGenJetPtMatched"), mcpjet.pt()); - for (auto& mcdjet : mcpjet.template matchedJetGeo_as()) { - if (!mcdjet.has_matchedJetGeo()) - continue; - mcdJetPt.push_back(mcdjet.pt()); - mcdJetPhi.push_back(mcdjet.phi()); - mcdJetEta.push_back(mcdjet.eta()); - mcpJetPt.push_back(mcpjet.pt()); - mcpJetPhi.push_back(mcpjet.phi()); - mcpJetEta.push_back(mcpjet.eta()); + } - jetHist.fill(HIST("genmatched/hRecJetPt"), mcpjet.pt()); - jetHist.fill(HIST("genmatched/hRecJetWithGenPt"), mcdjet.pt()); - jetHist.fill(HIST("genmatched/hRecMatchedJetPt"), mcpjet.pt(), mcpjet.pt() - mcdjet.pt()); - jetHist.fill(HIST("genmatched/hRecMatchedJetPhi"), mcpjet.phi(), mcpjet.phi() - mcdjet.phi()); - jetHist.fill(HIST("genmatched/hRecMatchedJetEta"), mcpjet.eta(), mcpjet.eta() - mcdjet.eta()); + // Process ONLY the leading jet's matched detector jets (if valid) + if (itLeadPtJet != mcpjets.end()) { + const auto& leadingMCPJet = *itLeadPtJet; + jetHist.fill(HIST("genmatched/leadingJet/hGenJetPt"), leadingMCPJet.pt()); + if (leadingMCPJet.has_matchedJetGeo()) { + jetHist.fill(HIST("genmatched/leadingJet/hGenJetPtMatched"), leadingMCPJet.pt()); + for (const auto& mcdjet : leadingMCPJet.template matchedJetGeo_as()) { + // Assuming matchedJetGeo_as returns valid MCD jets; no redundant has check needed + // Store jet properties + mcdJetPt.push_back(mcdjet.pt()); + mcdJetPhi.push_back(mcdjet.phi()); + mcdJetEta.push_back(mcdjet.eta()); + mcpJetPt.push_back(leadingMCPJet.pt()); + mcpJetPhi.push_back(leadingMCPJet.phi()); + mcpJetEta.push_back(leadingMCPJet.eta()); + // Fill histograms with MCD (reco) and MCP (gen) properties + jetHist.fill(HIST("genmatched/hRecJetPt"), mcdjet.pt()); + jetHist.fill(HIST("genmatched/hRecJetWithGenPt"), leadingMCPJet.pt()); + // Resolution plots: Gen - Reco + jetHist.fill(HIST("genmatched/hRecMatchedJetPt"), leadingMCPJet.pt(), leadingMCPJet.pt() - mcdjet.pt()); + jetHist.fill(HIST("genmatched/hRecMatchedJetPhi"), leadingMCPJet.phi(), leadingMCPJet.phi() - mcdjet.phi()); + jetHist.fill(HIST("genmatched/hRecMatchedJetEta"), leadingMCPJet.eta(), leadingMCPJet.eta() - mcdjet.eta()); + + if (useMcC) { + if (randUniform.Uniform(0, 1) < 0.5) { + jetHist.fill(HIST("genmatched/hRecMatchedVsGenJetPt"), mcdjet.pt(), leadingMCPJet.pt()); + } else { + jetHist.fill(HIST("genmatched/mcC/hRecMatchedVsGenJetPt"), mcdjet.pt(), leadingMCPJet.pt()); + } + } + jetHist.fill(HIST("genmatched/hRecMatchedVsGenJetPtVsEta"), mcdjet.pt(), mcdjet.eta()); - } // mcdJet - } // mcpJet + } // End loop over mcdjet + } + } // leading jet only for (const auto& mcParticle : mcParticles) { - if (fabs(mcParticle.eta()) > cfgtrkMaxEta) + if (std::fabs(mcParticle.eta()) > cfgtrkMaxEta) continue; // add pid later @@ -1285,7 +1944,7 @@ struct nucleiInJets { for (std::size_t iDJet = 0; iDJet < mcpJetPt.size(); iDJet++) { double delPhi = TVector2::Phi_mpi_pi(mcpJetPhi[iDJet] - mcParticle.phi()); double delEta = mcpJetEta[iDJet] - mcParticle.eta(); - double R = TMath::Sqrt((delEta * delEta) + (delPhi * delPhi)); + double R = RecoDecay::sqrtSumOfSquares(delEta, delPhi); if (R < cfgjetR) { jetFlag = true; @@ -1296,11 +1955,79 @@ struct nucleiInJets { jetHist.fill(HIST("genmatched/pt/PtParticleType"), mcParticle.pt(), jetFlag, mapPDGToValue(mcParticle.pdgCode())); } } // jet constituents - } // process + void processRecInc(EventTableMC::iterator const& coll, TrackCandidatesIncMC const& tracks, aod::JetParticles const& particleTracks, aod::JMcCollisions const&) + { + jetHist.fill(HIST("recInc/eventStat"), 0.5); + if (!jetderiveddatautilities::selectCollision(coll, jetderiveddatautilities::initialiseEventSelectionBits("sel8"))) + return; + jetHist.fill(HIST("recInc/eventStat"), 1.5); + if (std::abs(coll.posZ()) > 10) // bad vertex + return; + jetHist.fill(HIST("recInc/eventStat"), 2.5); + + float centrality = -999; + switch (centralityType) { + case 0: // FT0M + centrality = coll.centFT0M(); + break; + case 1: // FT0C + centrality = coll.centFT0C(); + break; + case 2: // FV0A + centrality = coll.centFV0A(); + break; + default: + centrality = -999; + } + jetHist.fill(HIST("recInc/vertexZ"), coll.posZ(), centrality); + for (const auto& track : tracks) { + if (!isTrackSelected(track)) { + continue; + } + if (!track.has_mcParticle()) + continue; + if (std::fabs(track.eta()) > cfgtrkMaxEta) + continue; + auto mcTrack = track.mcParticle_as(); + if (!mcTrack.isPhysicalPrimary()) + continue; + bool isTOFAndTPCPreSel(track.hasTOF() && + (std::abs(track.tpcNSigmaPr()) < cfgnTPCPIDPrTOF || std::abs(track.tpcNSigmaDe()) < cfgnTPCPIDDeTOF)); + + if (mapPDGToValue(mcTrack.pdgCode()) != 0) { + jetHist.fill(HIST("recInc/pt/PtParticleTypeTPC"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode()), centrality); + + if (isTOFAndTPCPreSel) { + jetHist.fill(HIST("recInc/pt/PtParticleTypeTPCTOF"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode()), centrality); + jetHist.fill(HIST("recInc/pt/PtParticleTypeTPCTOFVeto"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode()), centrality); + } else { + jetHist.fill(HIST("recInc/pt/PtParticleTypeTPCTOFVeto"), mcTrack.pt(), mapPDGToValue(mcTrack.pdgCode()), centrality); + } + } + } // track + + // loop over particles + auto mcParticles_per_coll = particleTracks.sliceBy(perMCCol, coll.mcCollision().globalIndex()); + for (const auto& mcParticle : mcParticles_per_coll) { + if (!mcParticle.isPhysicalPrimary()) + continue; + if (std::fabs(mcParticle.eta()) > cfgtrkMaxEta) + continue; + if (std::fabs(mcParticle.y()) > cfgtrkMaxRap) + continue; + if (mapPDGToValue(mcParticle.pdgCode()) != 0) { + jetHist.fill(HIST("genInc/pt/PtParticleType"), mcParticle.pt(), mapPDGToValue(mcParticle.pdgCode()), centrality); + } + } // mc particles + } + PROCESS_SWITCH(nucleiInJets, processJetTracksData, "nuclei in Jets data", true); - PROCESS_SWITCH(nucleiInJets, processMCRec, "nuclei in Jets for detectorlevel Jets", true); + PROCESS_SWITCH(nucleiInJets, processJetTracksDataLfPid, "nuclei in Jets data", false); + PROCESS_SWITCH(nucleiInJets, processDataInc, "nuclei-data", false); + PROCESS_SWITCH(nucleiInJets, processRecInc, "nuclei MC", false); + PROCESS_SWITCH(nucleiInJets, processMCRec, "nuclei in Jets for detectorlevel Jets", false); PROCESS_SWITCH(nucleiInJets, processMCGen, "nuclei in Jets MC particlelevel Jets", false); PROCESS_SWITCH(nucleiInJets, processRecMatched, "nuclei in Jets rec matched", false); PROCESS_SWITCH(nucleiInJets, processGenMatched, "nuclei in Jets gen matched", false); diff --git a/PWGJE/Tasks/phiInJets.cxx b/PWGJE/Tasks/phiInJets.cxx index 09206a3cf4b..821169310b0 100644 --- a/PWGJE/Tasks/phiInJets.cxx +++ b/PWGJE/Tasks/phiInJets.cxx @@ -15,31 +15,46 @@ /// /// \author Adrian Fereydon Nassirpour -#include -#include +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/PhysicsConstants.h" #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/Track.h" +#include +#include +#include +#include +#include +#include + +#include "TRandom.h" +#include +#include +#include +#include -#include "Common/Core/RecoDecay.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" -#include "CommonConstants/PhysicsConstants.h" +#include -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/Jet.h" +#include +#include +#include +#include +#include +#include +#include +#include -#include "PWGLF/DataModel/LFResonanceTables.h" +#include using namespace o2; using namespace o2::framework; @@ -76,14 +91,25 @@ struct phiInJets { Configurable cfgIsKstar{"cfgIsKstar", false, "Swaps Phi for Kstar analysis"}; Configurable cfgDataHists{"cfgDataHists", false, "Enables DataHists"}; Configurable cfgMCRecHists{"cfgMCRecHists", false, "Enables MCRecHists"}; + Configurable cfgMCRecMBHists{"cfgMCRecMBHists", false, "Enables MCRec MB Hists"}; + Configurable cfgMCRecInsideHists{"cfgMCRecInsideHists", false, "Enables MCRec Inside Hists"}; + Configurable cfgMCRecRotationalHists{"cfgMCRecRotationalHists", false, "Enables MCRotational Hists"}; + Configurable cfgPIDQAHists{"cfgPIDQAHists", false, "Enables PIDQA Hists"}; + Configurable cfgDaughterQAHists{"cfgDaughterQAHists", false, "Enables DaughterQA Hists"}; + Configurable cfgJetQAHists{"cfgJetQAHists", false, "Enables JetQA Hists"}; + Configurable cfgMCGenHists{"cfgMCGenHists", false, "Enables MCGenHists"}; Configurable cfgMCGenMATCHEDHists{"cfgMCGenMATCHEDHists", false, "Enables MCGenMATCHEDHists"}; Configurable cfgMCRecMATCHEDHists{"cfgMCRecMATCHEDHists", false, "Enables MCRecMATCHEDHists"}; + Configurable cfgMinvNBins{"cfgMinvNBins", 300, "Number of bins for Minv axis"}; + Configurable cfgMinvMin{"cfgMinvMin", 0.60, "Minimum Minv value"}; + Configurable cfgMinvMax{"cfgMinvMax", 1.20, "Maximum Minv value"}; + // CONFIG DONE ///////////////////////////////////////// //INIT - int eventSelection = -1; + std::vector eventSelectionBits; void init(o2::framework::InitContext&) { @@ -91,7 +117,7 @@ struct phiInJets { 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.75, 1.25}; + const AxisSpec MinvAxis = {cfgMinvNBins, cfgMinvMin, cfgMinvMax}; const AxisSpec PtAxis = {200, 0, 20.0}; const AxisSpec MultAxis = {100, 0, 100}; const AxisSpec dRAxis = {100, 0, 100}; @@ -100,7 +126,6 @@ struct phiInJets { if (cfgDataHists) { JEhistos.add("nEvents", "nEvents", kTH1F, {{4, 0.0, 4.0}}); - 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}}); @@ -125,45 +150,70 @@ struct phiInJets { JEhistos.add("FJptHistogram", "FJptHistogram", kTH1F, {axisPt}); JEhistos.add("nJetsPerEvent", "nJetsPerEvent", kTH1F, {{10, 0.0, 10.0}}); - JEhistos.add("hUSS", "hUSS", kTH3F, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hUSS", "hUSS", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); JEhistos.add("hUSS_1D", "hUSS_1D", kTH1F, {MinvAxis}); JEhistos.add("hUSS_1D_2_3", "hUSS_1D_2_3", kTH1F, {MinvAxis}); - JEhistos.add("hLSS", "hLSS", kTH3F, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hLSS", "hLSS", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); JEhistos.add("hLSS_1D", "hLSS_1D", kTH1F, {MinvAxis}); JEhistos.add("hLSS_1D_2_3", "hLSS_1D_2_3", kTH1F, {MinvAxis}); - JEhistos.add("hUSS_INSIDE", "hUSS_INSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hUSS_INSIDE", "hUSS_INSIDE", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); JEhistos.add("hUSS_INSIDE_1D", "hUSS_INSIDE_1D", kTH1F, {MinvAxis}); JEhistos.add("hUSS_INSIDE_1D_2_3", "hUSS_INSIDE_1D_2_3", kTH1F, {MinvAxis}); - JEhistos.add("hLSS_INSIDE", "hLSS_INSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hLSS_INSIDE", "hLSS_INSIDE", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); JEhistos.add("hLSS_INSIDE_1D", "hLSS_INSIDE_1D", kTH1F, {MinvAxis}); JEhistos.add("hLSS_INSIDE_1D_2_3", "hLSS_INSIDE_1D_2_3", kTH1F, {MinvAxis}); } if (cfgMCRecHists) { JEhistos.add("nEvents_MCRec", "nEvents_MCRec", kTH1F, {{4, 0.0, 4.0}}); + if (cfgJetQAHists) { + JEhistos.add("h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{4000, 0., 200.}}}); + JEhistos.add("h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + JEhistos.add("h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); + } + if (cfgPIDQAHists) { + JEhistos.add("ptJEHistogramPion", "ptJEHistogramPion", kTH1F, {PtAxis}); + JEhistos.add("ptJEHistogramKaon", "ptJEHistogramKaon", kTH1F, {PtAxis}); + JEhistos.add("ptJEHistogramProton", "ptJEHistogramProton", kTH1F, {PtAxis}); + JEhistos.add("ptJEHistogramPhi", "ptJEHistogramPhi", kTH1F, {PtAxis}); + JEhistos.add("ptJEHistogramPhi_JetTrigger", "ptJEHistogramPhi_JetTrigger", kTH1F, {PtAxis}); + } + if (cfgDaughterQAHists) { + JEhistos.add("hNRealPhiVPhiCand", "hNRealPhiVPhiCand", kTH2F, {{10, 0, 10}, {10, 0, 10}}); + JEhistos.add("hNRealPhiWithJetVPhiCand", "hNRealPhiWithJetVPhiCand", kTH2F, {{10, 0, 10}, {10, 0, 10}}); + JEhistos.add("hNRealPhiInJetVPhiCand", "hNRealPhiInJetVPhiCand", kTH2F, {{10, 0, 10}, {10, 0, 10}}); + JEhistos.add("hMCRec_nonmatch_hUSS_KtoKangle_v_pt", "hMCRec_nonmatch_hUSS_KtoKangle_v_pt", kTH2F, {axisEta, PtAxis}); + JEhistos.add("hMCRec_nonmatch_hUSS_Kangle_v_pt", "hMCRec_nonmatch_hUSS_Kangle_v_pt", kTH2F, {axisEta, PtAxis}); + JEhistos.add("hMCRec_nonmatch_hUSS_INSIDE_pt_v_eta", "hMCRec_nonmatch_hUSS_INSIDE_pt_v_eta", kTH2F, {PtAxis, axisEta}); + } + // used for Minv closure tests + // MB + if (cfgMCRecMBHists) { + JEhistos.add("hMCRec_hUSS", "hMCRec_hUSS", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hMCRec_hLSS", "hMCRec_hLSS", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hMCRecTrue_hUSS", "hMCRecTrue_hUSS", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); + } + + if (cfgMCRecRotationalHists) { + JEhistos.add("hMCRec_R_distribution", "hMCRec_R_distribution", kTH1F, {{100, 0.0, 2 * TMath::Pi()}}); + JEhistos.add("hMCRec_dPhi_distribution", "hMCRec_dPhi_distribution", kTH1F, {{80, -5.0, 7.0}}); + JEhistos.add("hMCRec_dEta_distribution", "hMCRec_dEta_distribution", kTH1F, {{100, -2.0, 2.0}}); + JEhistos.add("hMCRec_hUSS_Rotational", "hMCRec_hUSS_Rotational", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hMCRec_R_Rotation_distribution", "hMCRec_R_Rotation_distribution", HistType::kTH1F, {{100, 0.0, 2 * TMath::Pi()}}); + JEhistos.add("hMCRec_dPhi_rot_distribution", "hMCRec_dPhi_rot_distribution", kTH1F, {{80, -5.0, 7.0}}); + JEhistos.add("hMCRec_dEta_rot_distribution", "hMCRec_dEta_rot_distribution", kTH1F, {{100, -2.0, 2.0}}); + JEhistos.add("hMCRec_dEta_qa_rot_distribution", "hMCRec_dEta_qa_rot_distribution", kTH1F, {{100, -4.0, 2.0}}); + } - JEhistos.add("h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{4000, 0., 200.}}}); - JEhistos.add("h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); - JEhistos.add("h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); - - JEhistos.add("ptJEHistogramPion", "ptJEHistogramPion", kTH1F, {PtAxis}); - JEhistos.add("ptJEHistogramKaon", "ptJEHistogramKaon", kTH1F, {PtAxis}); - JEhistos.add("ptJEHistogramProton", "ptJEHistogramProton", kTH1F, {PtAxis}); - JEhistos.add("ptJEHistogramPhi", "ptJEHistogramPhi", kTH1F, {PtAxis}); - JEhistos.add("ptJEHistogramPhi_JetTrigger", "ptJEHistogramPhi_JetTrigger", kTH1F, {PtAxis}); - JEhistos.add("minvJEHistogramPhi", "minvJEHistogramPhi", kTH1F, {MinvAxis}); - JEhistos.add("hNRealPhiVPhiCand", "hNRealPhiVPhiCand", kTH2F, {{10, 0, 10}, {10, 0, 10}}); - JEhistos.add("hNRealPhiWithJetVPhiCand", "hNRealPhiWithJetVPhiCand", kTH2F, {{10, 0, 10}, {10, 0, 10}}); - JEhistos.add("hNRealPhiInJetVPhiCand", "hNRealPhiInJetVPhiCand", kTH2F, {{10, 0, 10}, {10, 0, 10}}); - - JEhistos.add("hMCRec_nonmatch_hUSS_KtoKangle_v_pt", "hMCRec_nonmatch_hUSS_KtoKangle_v_pt", kTH2F, {axisEta, PtAxis}); - JEhistos.add("hMCRec_nonmatch_hUSS_Kangle_v_pt", "hMCRec_nonmatch_hUSS_Kangle_v_pt", kTH2F, {axisEta, PtAxis}); - JEhistos.add("hMCRec_nonmatch_hUSS_INSIDE_pt_v_eta", "hMCRec_nonmatch_hUSS_INSIDE_pt_v_eta", kTH2F, {PtAxis, axisEta}); - JEhistos.add("JetVsPhi_REC", "JetVsPhi_REC", kTH2F, {{4000, 0., 200.}, {200, 0, 20.0}}); - - JEhistos.add("hMCRec_nonmatch_hUSS_INSIDE", "hMCRec_nonmatch_hUSS_INSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); - JEhistos.add("hMCRec_nonmatch_hUSS_INSIDE_1D", "hMCRec_nonmatch_hUSS_INSIDE_1D", kTH1F, {MinvAxis}); - JEhistos.add("hMCRec_nonmatch_hUSS_INSIDE_1D_2_3", "hMCRec_nonmatch_hUSS_INSIDE_1D_2_3", kTH1F, {MinvAxis}); + // INSIDE + if (cfgMCRecInsideHists) { + JEhistos.add("hMCRec_hUSS_INSIDE", "hMCRec_hUSS_INSIDE", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hMCRec_hLSS_INSIDE", "hMCRec_hLSS_INSIDE", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hMCRecTrue_hUSS_INSIDE", "hMCRecTrue_hUSS_INSIDE", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hMCRec_nonmatch_hUSS_INSIDE", "hMCRec_nonmatch_hUSS_INSIDE", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("JetVsPhi_REC", "JetVsPhi_REC", kTH2F, {{4000, 0., 200.}, {200, 0, 20.0}}); + JEhistos.add("minvJEHistogramPhi", "minvJEHistogramPhi", kTH1F, {MinvAxis}); + } } if (cfgMCGenHists) { @@ -186,7 +236,7 @@ struct phiInJets { JEhistos.add("hMCTrue_nonmatch_hUSS_INSIDE_pt_v_eta", "hMCTrue_nonmatch_hUSS_INSIDE_pt_v_eta", kTH2F, {PtAxis, axisEta}); JEhistos.add("JetVsPhi_GEN", "JetVsPhi_GEN", kTH2F, {{4000, 0., 200.}, {200, 0, 20.0}}); - JEhistos.add("hMCTrue_nonmatch_hUSS_INSIDE", "hMCTrue_nonmatch_hUSS_INSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hMCTrue_nonmatch_hUSS_INSIDE", "hMCTrue_nonmatch_hUSS_INSIDE", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); JEhistos.add("hMCTrue_nonmatch_hUSS_INSIDE_1D", "hMCTrue_nonmatch_hUSS_INSIDE_1D", kTH1F, {MinvAxis}); JEhistos.add("hMCTrue_nonmatch_hUSS_INSIDE_1D_2_3", "hMCTrue_nonmatch_hUSS_INSIDE_1D_2_3", kTH1F, {MinvAxis}); } @@ -204,7 +254,7 @@ struct phiInJets { JEhistos.add("RespGen_Matrix_MATCHED_rand0", "RespGen_Matrix_MATCHED_rand0", HistType::kTHnSparseD, {PtAxis, axisPt, PtAxis, axisPt}); // REC(Phi,Jet), GEN(Phi,Jet) JEhistos.add("RespGen_Matrix_MATCHED_rand1", "RespGen_Matrix_MATCHED_rand1", HistType::kTHnSparseD, {PtAxis, axisPt, PtAxis, axisPt}); // REC(Phi,Jet), GEN(Phi,Jet) - JEhistos.add("hMCTrue_hUSS_INSIDE", "hMCTrue_hUSS_INSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hMCTrue_hUSS_INSIDE", "hMCTrue_hUSS_INSIDE", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); JEhistos.add("hMCTrue_hUSS_INSIDE_1D", "hMCTrue_hUSS_INSIDE_1D", kTH1F, {MinvAxis}); JEhistos.add("hMCTrue_hUSS_INSIDE_1D_2_3", "hMCTrue_hUSS_INSIDE_1D_2_3", kTH1F, {MinvAxis}); } @@ -223,55 +273,12 @@ struct phiInJets { JEhistos.add("2DRecToGen", "2DRecToGen", kTH2F, {PtAxis, axisPt}); JEhistos.add("2DRecToGen_constrained", "2DRecToGen_constrained", kTH2F, {PtAxis, axisPt}); - JEhistos.add("hMCRec_hUSS_INSIDE", "hMCRec_hUSS_INSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); + JEhistos.add("hMCRec_hUSS_INSIDE", "hMCRec_hUSS_INSIDE", kTHnSparseF, {dRAxis, PtAxis, MinvAxis}); JEhistos.add("hMCRec_hUSS_INSIDE_1D", "hMCRec_hUSS_INSIDE_1D", kTH1F, {MinvAxis}); JEhistos.add("hMCRec_hUSS_INSIDE_1D_2_3", "hMCRec_hUSS_INSIDE_1D_2_3", kTH1F, {MinvAxis}); } - // JEhistos.add("FJetaHistogram_MCRec", "FJetaHistogram_MCRec", kTH1F, {axisEta}); - // JEhistos.add("FJphiHistogram_MCRec", "FJphiHistogram_MCRec", kTH1F, {axisPhi}); - // JEhistos.add("FJptHistogram_MCRec", "FJptHistogram_MCRec", kTH1F, {axisPt}); - // JEhistos.add("FJetaHistogram_MCTrue", "FJetaHistogram_MCTrue", kTH1F, {axisEta}); - // JEhistos.add("FJphiHistogram_MCTrue", "FJphiHistogram_MCTrue", kTH1F, {axisPhi}); - // JEhistos.add("FJptHistogram_MCTrue", "FJptHistogram_MCTrue", kTH1F, {axisPt}); - // JEhistos.add("hUSS_OUTSIDE", "hUSS_OUTSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hUSS_OUTSIDE_1D", "hUSS_OUTSIDE_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hUSS_OUTSIDE_1D_2_3", "hUSS_OUTSIDE_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hLSS_OUTSIDE", "hLSS_OUTSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hLSS_OUTSIDE_1D", "hLSS_OUTSIDE_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hLSS_OUTSIDE_1D_2_3", "hLSS_OUTSIDE_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCTrue_hUSS_OUTSIDE", "hMCTrue_hUSS_OUTSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCTrue_hUSS_OUTSIDE_1D", "hMCTrue_hUSS_OUTSIDE_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCTrue_hUSS_OUTSIDE_1D_2_3", "hMCTrue_hUSS_OUTSIDE_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCTrue_hUSS_OUTSIDE_TRIG", "hMCTrue_hUSS_OUTSIDE_TRIG", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCTrue_hUSS_OUTSIDE_TRIG_1D", "hMCTrue_hUSS_OUTSIDE_TRIG_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCTrue_hUSS_OUTSIDE_TRIG_1D_2_3", "hMCTrue_hUSS_OUTSIDE_TRIG_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCTrue_nonmatch_hUSS_OUTSIDE", "hMCTrue_nonmatch_hUSS_OUTSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCTrue_nonmatch_hUSS_OUTSIDE_1D", "hMCTrue_nonmatch_hUSS_OUTSIDE_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCTrue_nonmatch_hUSS_OUTSIDE_1D_2_3", "hMCTrue_nonmatch_hUSS_OUTSIDE_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG", "hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG_1D", "hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG_1D_2_3", "hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_hUSS", "hMCRec_hUSS", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCRec_hUSS_1D", "hMCRec_hUSS_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_hUSS_1D_2_3", "hMCRec_hUSS_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_hUSS_OUTSIDE", "hMCRec_hUSS_OUTSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCRec_hUSS_OUTSIDE_1D", "hMCRec_hUSS_OUTSIDE_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_hUSS_OUTSIDE_1D_2_3", "hMCRec_hUSS_OUTSIDE_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_hUSS_OUTSIDE_TRIG", "hMCRec_hUSS_OUTSIDE_TRIG", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCRec_hUSS_OUTSIDE_TRIG_1D", "hMCRec_hUSS_OUTSIDE_TRIG_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_hUSS_OUTSIDE_TRIG_1D_2_3", "hMCRec_hUSS_OUTSIDE_TRIG_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_nonmatch_hUSS", "hMCRec_nonmatch_hUSS", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCRec_nonmatch_hUSS_1D", "hMCRec_nonmatch_hUSS_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_nonmatch_hUSS_1D_2_3", "hMCRec_nonmatch_hUSS_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_nonmatch_hUSS_OUTSIDE", "hMCRec_nonmatch_hUSS_OUTSIDE", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCRec_nonmatch_hUSS_OUTSIDE_1D", "hMCRec_nonmatch_hUSS_OUTSIDE_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_nonmatch_hUSS_OUTSIDE_1D_2_3", "hMCRec_nonmatch_hUSS_OUTSIDE_1D_2_3", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_nonmatch_hUSS_OUTSIDE_TRIG", "hMCRec_nonmatch_hUSS_OUTSIDE_TRIG", kTH3F, {dRAxis, PtAxis, MinvAxis}); - // JEhistos.add("hMCRec_nonmatch_hUSS_OUTSIDE_TRIG_1D", "hMCRec_nonmatch_hUSS_OUTSIDE_TRIG_1D", kTH1F, {MinvAxis}); - // JEhistos.add("hMCRec_nonmatch_hUSS_OUTSIDE_TRIG_1D_2_3", "hMCRec_nonmatch_hUSS_OUTSIDE_TRIG_1D_2_3", kTH1F, {MinvAxis}); - // EVENT SELECTION - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(cfgeventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(cfgeventSelections)); } // end of init @@ -439,7 +446,9 @@ struct phiInJets { template int minvReconstruction(double mult, const TracksType& trk1, const TracksType& trk2, const JetType& jets) { + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + //==================================================== if (!trackSelection(trk1) || !trackSelection(trk2)) return -1; @@ -463,6 +472,8 @@ struct phiInJets { lResonance = lDecayDaughter1 + lDecayDaughter2; + //================================================== + if (std::abs(lResonance.Eta()) > cfgtrkMaxEta) return -1; @@ -497,10 +508,11 @@ struct phiInJets { } } - if (cfgSingleJet) - if (goodjets > 1) + if (cfgSingleJet) { + if (goodjets > 1) { jetpt = DistinguishJets(jets, lResonance); - + } + } ///////////////////////////////////////////////////////////////////////////// // Fill inside Jet if (jetFlag) { @@ -520,33 +532,6 @@ struct phiInJets { } // jetflag ///////////////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////////// - // Fill outside Jet - // if (!jetFlag) { - // if (trk1.sign() * trk2.sign() < 0) { - // if (!IsMC) { - // JEhistos.fill(HIST("hUSS_OUTSIDE_1D"), lResonance.M()); - // if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - // JEhistos.fill(HIST("hUSS_OUTSIDE_1D_2_3"), lResonance.M()); - // JEhistos.fill(HIST("hUSS_OUTSIDE"), jetpt, lResonance.Pt(), lResonance.M()); - // } - - // if (IsMC) { - // JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE_1D"), lResonance.M()); - // if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - // JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE_1D_2_3"), lResonance.M()); - // JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE"), jetpt, lResonance.Pt(), lResonance.M()); - // } - - // } else if (trk1.sign() * trk2.sign() > 0) { - - // JEhistos.fill(HIST("hLSS_OUTSIDE_1D"), lResonance.M()); - // if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - // JEhistos.fill(HIST("hLSS_OUTSIDE_1D_2_3"), lResonance.M()); - // JEhistos.fill(HIST("hLSS_OUTSIDE"), jetpt, lResonance.Pt(), lResonance.M()); - // } - // } //! jetflag - ///////////////////////////////////////////////////////////////////////////// if (!cfgIsKstar) { if (lResonance.M() > 1.005 && lResonance.M() < 1.035) { if (jetFlag) @@ -573,22 +558,19 @@ struct phiInJets { ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// int nEvents = 0; - void processJetTracks(aod::JCollision const& collision, soa::Filtered> const& chargedjets, soa::Join const& tracks, TrackCandidates const&) + void processJetTracks(aod::JetCollision const& collision, soa::Filtered> const& chargedjets, soa::Join const& tracks, TrackCandidates const&) { if (cDebugLevel > 0) { nEvents++; if ((nEvents + 1) % 10000 == 0) { - std::cout << "Ay Lmao" << std::endl; - double histmem = JEhistos.getSize(); - std::cout << histmem << std::endl; std::cout << "Processed Data Events: " << nEvents << std::endl; } } JEhistos.fill(HIST("nEvents"), 0.5); - if (fabs(collision.posZ()) > cfgVtxCut) + if (std::fabs(collision.posZ()) > cfgVtxCut) return; - if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) return; int nReso = 0; @@ -655,10 +637,10 @@ struct phiInJets { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// using myCompleteTracks = soa::Join; - using myCompleteJetTracks = soa::Join; + using myCompleteJetTracks = soa::Join; int nJEEvents = 0; int nprocessRecEvents = 0; - void processRec(o2::aod::JCollision const& collision, myCompleteJetTracks const& tracks, soa::Filtered const& mcdjets, aod::McParticles const&, myCompleteTracks const& /*originalTracks*/) + void processRec(o2::aod::JetCollision const& collision, myCompleteJetTracks const& tracks, soa::Filtered const& mcdjets, aod::McParticles const&, myCompleteTracks const& /*originalTracks*/) { if (cDebugLevel > 0) { nprocessRecEvents++; @@ -668,16 +650,18 @@ struct phiInJets { std::cout << "processRec: " << nprocessRecEvents << std::endl; } } - + //================= + // # of Events + //================= JEhistos.fill(HIST("nEvents_MCRec"), 0.5); - if (fabs(collision.posZ()) > cfgVtxCut) + if (std::fabs(collision.posZ()) > cfgVtxCut) return; - if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) return; bool INELgt0 = false; for (const auto& track : tracks) { - if (fabs(track.eta()) < cfgtrkMaxEta) { + if (std::fabs(track.eta()) < cfgtrkMaxEta) { INELgt0 = true; break; } @@ -697,9 +681,11 @@ struct phiInJets { mcd_pt.push_back(mcdjet.pt()); mcd_eta.push_back(mcdjet.eta()); mcd_phi.push_back(mcdjet.phi()); - JEhistos.fill(HIST("h_jet_pt"), mcdjet.pt()); - JEhistos.fill(HIST("h_jet_eta"), mcdjet.eta()); - JEhistos.fill(HIST("h_jet_phi"), mcdjet.phi()); + if (cfgJetQAHists) { + JEhistos.fill(HIST("h_jet_pt"), mcdjet.pt()); + JEhistos.fill(HIST("h_jet_eta"), mcdjet.eta()); + JEhistos.fill(HIST("h_jet_phi"), mcdjet.phi()); + } } if (hasJets) JEhistos.fill(HIST("nEvents_MCRec"), 2.5); @@ -708,7 +694,8 @@ struct phiInJets { double RealPhiCand = 0; double RealPhiCandWithJet = 0; double RealPhiCandInJet = 0; - // Track Eff + //============ + // Track Effl for (const auto& track : tracks) { auto originalTrack = track.track_as(); if (!trackSelection(originalTrack)) @@ -719,14 +706,15 @@ struct phiInJets { if (track.has_mcParticle()) { auto mcParticle = track.mcParticle(); - - if (mcParticle.isPhysicalPrimary() && fabs(mcParticle.eta()) <= cfgtrkMaxEta) { - if (abs(mcParticle.pdgCode()) == 211) - JEhistos.fill(HIST("ptJEHistogramPion"), mcParticle.pt()); - if (abs(mcParticle.pdgCode()) == 321) - JEhistos.fill(HIST("ptJEHistogramKaon"), mcParticle.pt()); - if (abs(mcParticle.pdgCode()) == 2212) - JEhistos.fill(HIST("ptJEHistogramProton"), mcParticle.pt()); + if (cfgPIDQAHists) { + if (mcParticle.isPhysicalPrimary() && std::fabs(mcParticle.eta()) <= cfgtrkMaxEta) { + if (abs(mcParticle.pdgCode()) == 211) + JEhistos.fill(HIST("ptJEHistogramPion"), mcParticle.pt()); + if (abs(mcParticle.pdgCode()) == 321) + JEhistos.fill(HIST("ptJEHistogramKaon"), mcParticle.pt()); + if (abs(mcParticle.pdgCode()) == 2212) + JEhistos.fill(HIST("ptJEHistogramProton"), mcParticle.pt()); + } } } for (const auto& track2 : tracks) { @@ -743,34 +731,139 @@ struct phiInJets { if (originalTrack.globalIndex() == originalTrack2.globalIndex()) continue; } - if (fabs(originalTrack.eta()) > cfgtrkMaxEta || fabs(originalTrack2.eta()) > cfgtrkMaxEta) + if (std::fabs(originalTrack.eta()) > cfgtrkMaxEta || std::fabs(originalTrack2.eta()) > cfgtrkMaxEta) continue; - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance, lRotationalTrack, lRotationalResonance; lDecayDaughter1.SetXYZM(originalTrack.px(), originalTrack.py(), originalTrack.pz(), massKa); - if (!cfgIsKstar) + + if (cfgMCRecRotationalHists) { + double dPhi = TVector2::Phi_mpi_pi(originalTrack.phi() - originalTrack2.phi()); + double dEta = originalTrack.eta() - originalTrack2.eta(); + + JEhistos.fill(HIST("hMCRec_dPhi_distribution"), dPhi); + JEhistos.fill(HIST("hMCRec_dEta_distribution"), dEta); + double dR = TMath::Sqrt(dPhi * dPhi + dEta * dEta); + double dR_rot = 0; + + //----------------------------------------------------------------------- + TRandom* trand = new TRandom(); + double shift = trand->Uniform(TMath::Pi() - TMath::Pi() / 10.0, TMath::Pi() + TMath::Pi() / 10.0); + // double shift = TMath::Pi(); + if (!cfgIsKstar) { + lDecayDaughter2.SetXYZM(originalTrack2.px(), originalTrack2.py(), originalTrack2.pz(), massKa); + } else { + lDecayDaughter2.SetXYZM(originalTrack2.px(), originalTrack2.py(), originalTrack2.pz(), massPi); + } + lRotationalTrack = lDecayDaughter2; + lRotationalTrack.RotateZ(shift); + + double dPhi_rot = TVector2::Phi_mpi_pi(lDecayDaughter1.Phi() - lRotationalTrack.Phi()); + double dEta_rot = lDecayDaughter1.Eta() - lRotationalTrack.Eta(); + double dEta_rot_qa = TMath::Abs(lDecayDaughter2.Eta()) - TMath::Abs(lRotationalTrack.Eta()); + + dR_rot = TMath::Sqrt(dPhi_rot * dPhi_rot + dEta_rot * dEta_rot); + JEhistos.fill(HIST("hMCRec_dPhi_rot_distribution"), dPhi_rot); + JEhistos.fill(HIST("hMCRec_dEta_rot_distribution"), dEta_rot); + JEhistos.fill(HIST("hMCRec_dEta_qa_rot_distribution"), dEta_rot_qa); + + lResonance = lDecayDaughter1 + lDecayDaughter2; + if (cfgIsKstar) + lRotationalResonance = lDecayDaughter1 + lRotationalTrack; + + if (cfgIsKstar) { + JEhistos.fill(HIST("hMCRec_R_distribution"), dR); + JEhistos.fill(HIST("hMCRec_hUSS_Rotational"), 1.0, lRotationalResonance.Pt(), lResonance.M()); + JEhistos.fill(HIST("hMCRec_R_Rotation_distribution"), dR_rot); + } + } + //----------------------------------------------------------------------- + if (!cfgIsKstar) { lDecayDaughter2.SetXYZM(originalTrack2.px(), originalTrack2.py(), originalTrack2.pz(), massKa); - else + } else { lDecayDaughter2.SetXYZM(originalTrack2.px(), originalTrack2.py(), originalTrack2.pz(), massPi); + } lResonance = lDecayDaughter1 + lDecayDaughter2; - if (fabs(lResonance.Eta()) > cfgtrkMaxEta) + if (std::fabs(lResonance.Eta()) > cfgtrkMaxEta) continue; - if (lResonance.M() > 1.005 && lResonance.M() < 1.035) - PhiCand++; + if (cfgDaughterQAHists) { + if (lResonance.M() > 1.005 && lResonance.M() < 1.035) + PhiCand++; + } + //================== + // 1.MB REC Closure + //================== + if (cfgMCRecMBHists) { + if (originalTrack.sign() * originalTrack2.sign() < 0) { + JEhistos.fill(HIST("hMCRec_hUSS"), 1.0, lResonance.Pt(), lResonance.M()); + + } else if (originalTrack.sign() * originalTrack2.sign() > 0) { + JEhistos.fill(HIST("hMCRec_hLSS"), 1.0, lResonance.Pt(), lResonance.M()); + } + } + //============================================ + // 2.Check if particle is inside a jet or not + //============================================ + bool jetFlag = false; + int goodjets = 0; + double jetpt = 0; + + for (std::size_t i = 0; i < mcd_pt.size(); i++) { + if (cfgDaughterQAHists) { + if (i == 0) { + if (lResonance.M() > 1.005 && lResonance.M() < 1.035) { + RealPhiCandWithJet++; + } + } + } + double phidiff = TVector2::Phi_mpi_pi(mcd_phi[i] - lResonance.Phi()); + double etadiff = mcd_eta[i] - lResonance.Eta(); + double R = TMath::Sqrt((etadiff * etadiff) + (phidiff * phidiff)); + + if (cfgDaughterQAHists && R < cfgjetR) { + double phidiff_K1 = TVector2::Phi_mpi_pi(mcd_phi[i] - lDecayDaughter1.Phi()); + double etadiff_K1 = mcd_eta[i] - lDecayDaughter1.Eta(); + double R_K1 = TMath::Sqrt((etadiff_K1 * etadiff_K1) + (phidiff_K1 * phidiff_K1)); + + double phidiff_K2 = TVector2::Phi_mpi_pi(mcd_phi[i] - lDecayDaughter2.Phi()); + double etadiff_K2 = mcd_eta[i] - lDecayDaughter2.Eta(); + double R_K2 = TMath::Sqrt((etadiff_K2 * etadiff_K2) + (phidiff_K2 * phidiff_K2)); + + JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_Kangle_v_pt"), R_K1, lResonance.Pt()); + JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_Kangle_v_pt"), R_K2, lResonance.Pt()); + } + if (R < cfgjetR) { + jetFlag = true; + jetpt = mcd_pt[i]; + goodjets++; + } + } // R check for jets + //====================== + // 3.INSIDE REC Closure + //====================== + if (cfgMCRecInsideHists) { + if (jetFlag) { + if (originalTrack.sign() * originalTrack2.sign() < 0) { + JEhistos.fill(HIST("hMCRec_hUSS_INSIDE"), 1.0, lResonance.Pt(), lResonance.M()); + } else if (originalTrack.sign() * originalTrack2.sign() > 0) { + JEhistos.fill(HIST("hMCRec_hLSS_INSIDE"), 1.0, lResonance.Pt(), lResonance.M()); + } + } + } // check PID if (track.has_mcParticle() && track2.has_mcParticle()) { auto part1 = track.mcParticle(); auto part2 = track2.mcParticle(); - if (fabs(part1.pdgCode()) != 321) + if (std::fabs(part1.pdgCode()) != 321) continue; // Not Kaon if (!cfgIsKstar) { - if (fabs(part2.pdgCode()) != 321) + if (std::fabs(part2.pdgCode()) != 321) continue; // Not Kaon } else { - if (fabs(part2.pdgCode()) != 211) + if (std::fabs(part2.pdgCode()) != 211) continue; // Not Kaon } @@ -807,75 +900,79 @@ struct phiInJets { if (mothers1[0] != mothers2[0]) continue; // Kaons not from the same phi - double phidiff_Kaons = TVector2::Phi_mpi_pi(lDecayDaughter2.Phi() - lDecayDaughter1.Phi()); - double etadiff_Kaons = lDecayDaughter2.Eta() - lDecayDaughter1.Eta(); - double R_Kaons = TMath::Sqrt((etadiff_Kaons * etadiff_Kaons) + (phidiff_Kaons * phidiff_Kaons)); - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_KtoKangle_v_pt"), R_Kaons, lResonance.Pt()); - JEhistos.fill(HIST("ptJEHistogramPhi"), lResonance.Pt()); - - if (lResonance.M() > 1.005 && lResonance.M() < 1.035) - RealPhiCand++; + if (cfgDaughterQAHists) { + double phidiff_Kaons = TVector2::Phi_mpi_pi(lDecayDaughter2.Phi() - lDecayDaughter1.Phi()); + double etadiff_Kaons = lDecayDaughter2.Eta() - lDecayDaughter1.Eta(); + double R_Kaons = TMath::Sqrt((etadiff_Kaons * etadiff_Kaons) + (phidiff_Kaons * phidiff_Kaons)); + JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_KtoKangle_v_pt"), R_Kaons, lResonance.Pt()); + } + if (cfgPIDQAHists) { + JEhistos.fill(HIST("ptJEHistogramPhi"), lResonance.Pt()); + } + //===================== + // 4.MB True Closure + //===================== + if (cfgMCRecMBHists) { + if (originalTrack.sign() * originalTrack2.sign() < 0) { + JEhistos.fill(HIST("hMCRecTrue_hUSS"), 1.0, lResonance.Pt(), lResonance.M()); + } + } + //=========================== + // 5.INSIDE REC True Closure + //=========================== + if (cfgMCRecInsideHists) { + if (jetFlag) { + if (originalTrack.sign() * originalTrack2.sign() < 0) { + JEhistos.fill(HIST("hMCRecTrue_hUSS_INSIDE"), 1.0, lResonance.Pt(), lResonance.M()); + } + } + } + if (cfgDaughterQAHists) { + if (lResonance.M() > 1.005 && lResonance.M() < 1.035) + RealPhiCand++; + } // Now we do jets - bool jetFlag = false; - int goodjets = 0; - double jetpt = 0; + if (cfgMCRecInsideHists) { + if (cfgSingleJet) + if (goodjets > 1) + jetpt = DistinguishJetsMC(mcd_pt, mcd_phi, mcd_eta, lResonance); - for (std::size_t i = 0; i < mcd_pt.size(); i++) { - if (i == 0) { - if (lResonance.M() > 1.005 && lResonance.M() < 1.035) { - RealPhiCandWithJet++; + if (jetFlag) { + if (cfgDaughterQAHists) { + if (lResonance.M() > 1.005 && lResonance.M() < 1.035) + RealPhiCandInJet++; + } + if (cfgDaughterQAHists) { + JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_INSIDE_pt_v_eta"), lResonance.Pt(), lResonance.Eta()); + // if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) + // JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_INSIDE_1D_2_3"), lResonance.M()); + JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_INSIDE"), jetpt, lResonance.Pt(), lResonance.M()); } } - double phidiff = TVector2::Phi_mpi_pi(mcd_phi[i] - lResonance.Phi()); - double etadiff = mcd_eta[i] - lResonance.Eta(); - double R = TMath::Sqrt((etadiff * etadiff) + (phidiff * phidiff)); - double phidiff_K1 = TVector2::Phi_mpi_pi(mcd_phi[i] - lDecayDaughter1.Phi()); - double etadiff_K1 = mcd_eta[i] - lDecayDaughter1.Eta(); - double R_K1 = TMath::Sqrt((etadiff_K1 * etadiff_K1) + (phidiff_K1 * phidiff_K1)); - double phidiff_K2 = TVector2::Phi_mpi_pi(mcd_phi[i] - lDecayDaughter2.Phi()); - double etadiff_K2 = mcd_eta[i] - lDecayDaughter2.Eta(); - double R_K2 = TMath::Sqrt((etadiff_K2 * etadiff_K2) + (phidiff_K2 * phidiff_K2)); - if (R < cfgjetR) { - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_Kangle_v_pt"), R_K1, lResonance.Pt()); - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_Kangle_v_pt"), R_K2, lResonance.Pt()); + if (hasJets) { + if (cfgPIDQAHists) + JEhistos.fill(HIST("ptJEHistogramPhi_JetTrigger"), lResonance.Pt()); + + auto triggerjet = std::min_element(mcd_pt.begin(), mcd_pt.end()); + double triggerjet_pt = *triggerjet; + if (!cfgIsKstar) { + JEhistos.fill(HIST("JetVsPhi_REC"), triggerjet_pt, lResonance.Pt()); + } } - if (R < cfgjetR) { - jetFlag = true; - jetpt = mcd_pt[i]; - goodjets++; + if (cfgDaughterQAHists) { + JEhistos.fill(HIST("minvJEHistogramPhi"), lResonance.M()); } - } // R check for jets - - if (cfgSingleJet) - if (goodjets > 1) - jetpt = DistinguishJetsMC(mcd_pt, mcd_phi, mcd_eta, lResonance); - - if (jetFlag) { - if (lResonance.M() > 1.005 && lResonance.M() < 1.035) - RealPhiCandInJet++; - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_INSIDE_pt_v_eta"), lResonance.Pt(), lResonance.Eta()); - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_INSIDE_1D"), lResonance.M()); - if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_INSIDE_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_INSIDE"), jetpt, lResonance.Pt(), lResonance.M()); } - - if (hasJets) { - JEhistos.fill(HIST("ptJEHistogramPhi_JetTrigger"), lResonance.Pt()); - auto triggerjet = std::min_element(mcd_pt.begin(), mcd_pt.end()); - double triggerjet_pt = *triggerjet; - JEhistos.fill(HIST("JetVsPhi_REC"), triggerjet_pt, lResonance.Pt()); - } - JEhistos.fill(HIST("minvJEHistogramPhi"), lResonance.M()); } // mcpart check - } // tracks2 - } // tracks1 - JEhistos.fill(HIST("hNRealPhiVPhiCand"), PhiCand, RealPhiCand); - JEhistos.fill(HIST("hNRealPhiWithJetVPhiCand"), PhiCand, RealPhiCandWithJet); - JEhistos.fill(HIST("hNRealPhiInJetVPhiCand"), PhiCand, RealPhiCandInJet); - + } // tracks2 + } // tracks1 + if (cfgDaughterQAHists) { + JEhistos.fill(HIST("hNRealPhiVPhiCand"), PhiCand, RealPhiCand); + JEhistos.fill(HIST("hNRealPhiWithJetVPhiCand"), PhiCand, RealPhiCandWithJet); + JEhistos.fill(HIST("hNRealPhiInJetVPhiCand"), PhiCand, RealPhiCandInJet); + } // Jet Eff } PROCESS_SWITCH(phiInJets, processRec, "pikp detector level MC JE", true); @@ -884,7 +981,7 @@ struct phiInJets { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int nprocessSimEvents = 0; // Preslice slice = o2::aod::JCollision::collisionId; - void processSim(o2::aod::JMcCollision const& collision, soa::SmallGroups> const& recocolls, aod::JMcParticles const& mcParticles, soa::Filtered const& mcpjets) + void processSim(o2::aod::JetMcCollision const& collision, soa::SmallGroups> const& recocolls, aod::JetParticles const& mcParticles, soa::Filtered const& mcpjets) { if (cDebugLevel > 0) { nprocessSimEvents++; @@ -901,15 +998,15 @@ struct phiInJets { return; for (auto& recocoll : recocolls) { // poorly reconstructed - if (!jetderiveddatautilities::selectCollision(recocoll, jetderiveddatautilities::JCollisionSel::sel8)) + if (!jetderiveddatautilities::selectCollision(recocoll, eventSelectionBits)) return; } - if (fabs(collision.posZ()) > cfgVtxCut) // bad vertex + if (std::fabs(collision.posZ()) > cfgVtxCut) // bad vertex return; bool INELgt0 = false; for (const auto& mcParticle : mcParticles) { - if (fabs(mcParticle.eta()) < cfgtrkMaxEta) { + if (std::fabs(mcParticle.eta()) < cfgtrkMaxEta) { INELgt0 = true; break; } @@ -939,7 +1036,7 @@ struct phiInJets { // Check pikp and phi for (const auto& mcParticle : mcParticles) { - if (mcParticle.isPhysicalPrimary() && fabs(mcParticle.eta()) <= cfgtrkMaxEta) { // watch out for context!!! + if (mcParticle.isPhysicalPrimary() && std::fabs(mcParticle.eta()) <= cfgtrkMaxEta) { // watch out for context!!! if (abs(mcParticle.pdgCode()) == 211) JEhistos.fill(HIST("ptGeneratedPion"), mcParticle.pt()); if (abs(mcParticle.pdgCode()) == 321) @@ -947,7 +1044,7 @@ struct phiInJets { if (abs(mcParticle.pdgCode()) == 2212) JEhistos.fill(HIST("ptGeneratedProton"), mcParticle.pt()); } - if (fabs(mcParticle.eta()) <= cfgtrkMaxEta) { // watch out for context!!! + if (std::fabs(mcParticle.eta()) <= cfgtrkMaxEta) { // watch out for context!!! TLorentzVector lResonance; lResonance.SetPxPyPzE(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); @@ -966,13 +1063,13 @@ struct phiInJets { // if we check for Phi if (!cfgIsKstar) { if (mcParticle.has_daughters()) - for (auto& dgth : mcParticle.daughters_as()) - if (fabs(dgth.pdgCode()) != 321) + for (auto& dgth : mcParticle.daughters_as()) + if (std::fabs(dgth.pdgCode()) != 321) skip = true; } else { if (mcParticle.has_daughters()) - for (auto& dgth : mcParticle.daughters_as()) - if (fabs(dgth.pdgCode()) != 321 || fabs(dgth.pdgCode()) != 211) + for (auto& dgth : mcParticle.daughters_as()) + if (std::fabs(dgth.pdgCode()) != 321 || std::fabs(dgth.pdgCode()) != 211) skip = true; } @@ -993,7 +1090,7 @@ struct phiInJets { double etadiff = mcp_eta[i] - lResonance.Eta(); double R = TMath::Sqrt((etadiff * etadiff) + (phidiff * phidiff)); if (mcParticle.has_daughters()) { - for (auto& dgth : mcParticle.daughters_as()) { + for (auto& dgth : mcParticle.daughters_as()) { double phidiff_K = TVector2::Phi_mpi_pi(mcp_phi[i] - dgth.phi()); double etadiff_K = mcp_eta[i] - dgth.eta(); double R_K = TMath::Sqrt((etadiff_K * etadiff_K) + (phidiff_K * phidiff_K)); @@ -1018,23 +1115,6 @@ struct phiInJets { JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_INSIDE_1D_2_3"), lResonance.M()); JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_INSIDE"), jetpt, lResonance.Pt(), lResonance.M()); } - // else if (!jetFlag && mcp_pt.size() > 0) { - // JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG_1D"), lResonance.M()); - - // if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - // JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG_1D_2_3"), lResonance.M()); - - // JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG"), jetpt, lResonance.Pt(), lResonance.M()); - - // } else if (!jetFlag) { - // JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_OUTSIDE_1D"), lResonance.M()); - - // if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - // JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_OUTSIDE_1D_2_3"), lResonance.M()); - - // JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_OUTSIDE"), jetpt, lResonance.Pt(), lResonance.M()); - - // } //! jetflag ////////////////////////////Phi found if (hasJets) { @@ -1045,9 +1125,9 @@ struct phiInJets { } // check for jets } // check for phi - } // check for rapidity - } // loop over particles - } // process switch + } // check for rapidity + } // loop over particles + } // process switch PROCESS_SWITCH(phiInJets, processSim, "pikp particle level MC", true); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1057,13 +1137,13 @@ struct phiInJets { using JetMCDTable = soa::Filtered>; int nprocessSimJEEvents = 0; - void processMatchedGen(aod::JMcCollision const& collision, - soa::SmallGroups> const& recocolls, + void processMatchedGen(aod::JetMcCollision const& collision, + soa::SmallGroups> const& recocolls, JetMCDTable const& /*mcdjets*/, JetMCPTable const& mcpjets, myCompleteJetTracks const& tracks, myCompleteTracks const&, - aod::JMcParticles const& mcParticles, + aod::JetParticles const& mcParticles, aod::McParticles const&) { @@ -1078,13 +1158,13 @@ struct phiInJets { JEhistos.fill(HIST("nEvents_MCGen_MATCHED"), 0.5); - if (fabs(collision.posZ()) > cfgVtxCut) + if (std::fabs(collision.posZ()) > cfgVtxCut) return; if (recocolls.size() <= 0) // not reconstructed return; for (auto& recocoll : recocolls) { // poorly reconstructed - if (!jetderiveddatautilities::selectCollision(recocoll, jetderiveddatautilities::JCollisionSel::sel8)) + if (!jetderiveddatautilities::selectCollision(recocoll, eventSelectionBits)) return; } @@ -1128,14 +1208,14 @@ struct phiInJets { mcp_eta.push_back(mcpjet.eta()); mcp_phi.push_back(mcpjet.phi()); } // mcpjets - } // mcdjets + } // mcdjets if (hasJets) JEhistos.fill(HIST("nEvents_MCGen_MATCHED"), 2.5); // First we do GEN part for (const auto& mcParticle : mcParticles) { - if (fabs(mcParticle.eta()) > cfgtrkMaxEta) + if (std::fabs(mcParticle.eta()) > cfgtrkMaxEta) continue; int GenPID = 0; @@ -1145,7 +1225,7 @@ struct phiInJets { else GenPID = 313; - if (fabs(mcParticle.pdgCode()) == GenPID) { + if (std::fabs(mcParticle.pdgCode()) == GenPID) { bool skip = false; double phi_dgth_px[2] = {0}; double phi_dgth_py[2] = {0}; @@ -1160,8 +1240,8 @@ struct phiInJets { // if we check for Phi if (!cfgIsKstar) { if (mcParticle.has_daughters()) { - for (auto& dgth : mcParticle.daughters_as()) { - if (fabs(dgth.pdgCode()) != 321) { + for (auto& dgth : mcParticle.daughters_as()) { + if (std::fabs(dgth.pdgCode()) != 321) { skip = true; break; } @@ -1169,7 +1249,7 @@ struct phiInJets { auto trk = track.track_as(); if (!trackSelection(trk)) continue; - if (fabs(trk.eta()) > cfgtrkMaxEta) + if (std::fabs(trk.eta()) > cfgtrkMaxEta) continue; if (cfgSimPID) { if (!trackPID(trk, true)) @@ -1194,13 +1274,13 @@ struct phiInJets { break; } } // index check - } // track loop - } // mc daughter loop - } // check if particle has daughters - } else { // check for kstar + } // track loop + } // mc daughter loop + } // check if particle has daughters + } else { // check for kstar if (mcParticle.has_daughters()) - for (auto& dgth : mcParticle.daughters_as()) - if (fabs(dgth.pdgCode()) != 321 || fabs(dgth.pdgCode()) != 211) + for (auto& dgth : mcParticle.daughters_as()) + if (std::fabs(dgth.pdgCode()) != 321 || std::fabs(dgth.pdgCode()) != 211) skip = true; } @@ -1218,9 +1298,6 @@ struct phiInJets { lDecayDaughter1_REC.SetXYZM(phi_dgth_px[0], phi_dgth_py[0], phi_dgth_pz[0], massKa); lDecayDaughter2_REC.SetXYZM(phi_dgth_px[1], phi_dgth_py[1], phi_dgth_pz[1], massKa); lResonance_REC = lDecayDaughter1_REC + lDecayDaughter2_REC; - // if (cDebugLevel > 0) - // if (good_daughter[0] && good_daughter[1]) - // std::cout << "Reconstructed level phi pT: " << lResonance_REC.Pt() << std::endl; bool jetFlag = false; for (std::vector::size_type i = 0; i < mcp_pt.size(); i++) { @@ -1272,33 +1349,16 @@ struct phiInJets { JEhistos.fill(HIST("hMCTrue_hUSS_INSIDE_1D_2_3"), lResonance.M()); JEhistos.fill(HIST("hMCTrue_hUSS_INSIDE"), jetpt_mcp, lResonance.Pt(), lResonance.M()); } - // else if (!jetFlag && mcp_pt.size() > 0) { - // JEhistos.fill(HIST("hMCTrue_hUSS_OUTSIDE_TRIG_1D"), lResonance.M()); - - // if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - // JEhistos.fill(HIST("hMCTrue_hUSS_OUTSIDE_TRIG_1D_2_3"), lResonance.M()); - - // JEhistos.fill(HIST("hMCTrue_hUSS_OUTSIDE_TRIG"), jetpt_mcp, lResonance.Pt(), lResonance.M()); - - // } else if (!jetFlag) { - // JEhistos.fill(HIST("hMCTrue_hUSS_OUTSIDE_1D"), lResonance.M()); - - // if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - // JEhistos.fill(HIST("hMCTrue_hUSS_OUTSIDE_1D_2_3"), lResonance.M()); - - // JEhistos.fill(HIST("hMCTrue_hUSS_OUTSIDE"), jetpt_mcp, lResonance.Pt(), lResonance.M()); - - // } //! jetflag - } // chech for phi - } // MC Particles - } // main fcn + } // chech for phi + } // MC Particles + } // main fcn PROCESS_SWITCH(phiInJets, processMatchedGen, "phi matched level MC", true); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int nprocessRecJEEvents = 0; // void processMatchedRec(o2::aod::JCollision const& collision, myCompleteJetTracks const& tracks, soa::Filtered const& mcdjets, aod::McParticles const&, myCompleteTracks const& originalTracks) - void processMatchedRec(aod::JCollision const& collision, + void processMatchedRec(aod::JetCollision const& collision, JetMCDTable const& mcdjets, JetMCPTable const&, myCompleteJetTracks const& tracks, @@ -1311,19 +1371,19 @@ struct phiInJets { if ((nprocessRecJEEvents + 1) % 10000 == 0) { double histmem = JEhistos.getSize(); std::cout << histmem << std::endl; - std::cout << "processMatched Rec Events: " << nprocessRecJEEvents << std::endl; + std::cout << "processMatchedRec: " << nprocessRecEvents << std::endl; } } JEhistos.fill(HIST("nEvents_MCRec_MATCHED"), 0.5); - if (fabs(collision.posZ()) > cfgVtxCut) + if (std::fabs(collision.posZ()) > cfgVtxCut) return; - if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) return; bool INELgt0 = false; for (const auto& track : tracks) { - if (fabs(track.eta()) < cfgtrkMaxEta) { + if (std::fabs(track.eta()) < cfgtrkMaxEta) { INELgt0 = true; break; } @@ -1359,7 +1419,7 @@ struct phiInJets { mcp_eta.push_back(mcpjet.eta()); mcp_phi.push_back(mcpjet.phi()); } // mcpjets - } // mcdjets + } // mcdjets // Now we do REC part if (hasJets) JEhistos.fill(HIST("nEvents_MCRec_MATCHED"), 2.5); @@ -1375,7 +1435,7 @@ struct phiInJets { if (trk1.globalIndex() == trk2.globalIndex()) continue; } - if (fabs(trk1.eta()) > cfgtrkMaxEta || fabs(trk2.eta()) > cfgtrkMaxEta) + if (std::fabs(trk1.eta()) > cfgtrkMaxEta || std::fabs(trk2.eta()) > cfgtrkMaxEta) continue; if ((trk1.sign() * trk2.sign()) > 0) continue; // Not K+K- @@ -1389,13 +1449,13 @@ struct phiInJets { if (track1.has_mcParticle() && track2.has_mcParticle()) { auto part1 = track1.mcParticle(); auto part2 = track2.mcParticle(); - if (fabs(part1.pdgCode()) != 321) + if (std::fabs(part1.pdgCode()) != 321) continue; // Not Kaon if (!cfgIsKstar) { - if (fabs(part2.pdgCode()) != 321) + if (std::fabs(part2.pdgCode()) != 321) continue; // Not Kaon } else { - if (fabs(part2.pdgCode()) != 211) + if (std::fabs(part2.pdgCode()) != 211) continue; // Not Kaon } if (!part1.has_mothers()) @@ -1442,7 +1502,7 @@ struct phiInJets { lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi); lResonance = lDecayDaughter1 + lDecayDaughter2; - if (fabs(lResonance.Eta()) > cfgtrkMaxEta) + if (std::fabs(lResonance.Eta()) > cfgtrkMaxEta) continue; bool jetFlag = false; @@ -1517,12 +1577,12 @@ struct phiInJets { // } //! jetflag } // pass track cut - } // has mc particle + } // has mc particle } // tracks 2 - } // tracks 1 + } // tracks 1 // } // tracks - } // main fcn + } // main fcn PROCESS_SWITCH(phiInJets, processMatchedRec, "phi matched Rec level MC", true); }; // end of main struct diff --git a/PWGJE/Tasks/photonChargedTriggerCorrelation.cxx b/PWGJE/Tasks/photonChargedTriggerCorrelation.cxx new file mode 100644 index 00000000000..8c62845a145 --- /dev/null +++ b/PWGJE/Tasks/photonChargedTriggerCorrelation.cxx @@ -0,0 +1,1618 @@ +// 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. + +/// \file photonChargedTriggerCorrelation.cxx +/// \author Julius Kinner +/// \brief photon-jet correlation analysis +/// +/// Analysis for angular correlations between jets and photons via two-particle correlations with charged high-pt triggers +/// Associated hadrons (tracks), pipm, photons (PCM), pi0 (PCM) +/// Also contains checks and monte-carlo (efficiency, purity, mc-true correlation,...) +/// End goal of studying correlations between direct photons and jets + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "TMath.h" +#include "Math/Vector4D.h" + +#include "CCDB/BasicCCDBManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/TableHelper.h" + +#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" +#include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" + +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/PhotonChargedTriggerCorrelation.h" + +const double absEtaMax = 0.8; +#define DPHI_SCALE constants::math::TwoPI - constants::math::PIHalf +#define DETA_SCALE 4 * absEtaMax - 2 * absEtaMax + +using namespace o2; +using namespace o2::framework; + +using CorrCollisions = soa::Join; +using CorrCollision = CorrCollisions::iterator; +using CorrMcDCollisions = soa::Join; +using CorrMcDCollision = CorrMcDCollisions::iterator; +using CorrMcCollisions = soa::Join; +using CorrMcCollision = CorrMcCollisions::iterator; + +using BinningZPvMult = ColumnBinningPolicy; + +// correlation derived data =================================================================================================================================================================== + +struct CorrelationTableProducer { + // reco + Produces collisionExtraCorrTable; + Produces triggerTable; + Produces hadronTable; + Produces pipmTable; + Produces photonPCMTable; + Produces photonPCMPairTable; + // mc + Produces mcCollisionExtraCorrTable; + Produces triggerParticleTable; + + Configurable zPvMax{"zPvMax", 7, "maximum absZ primary-vertex cut"}; + Configurable occupancyMin{"occupancyMin", 0, "minimum occupancy cut"}; + Configurable occupancyMax{"occupancyMax", 2000, "maximum occupancy cut"}; + Configurable etaMax{"etaMax", 1 * absEtaMax, "maximum absEta cut"}; + + Configurable eventSelections{"eventSelections", "sel8", "JE framework - event selection"}; + Configurable trackSelections{"trackSelections", "globalTracks", "JE framework - track selections"}; + Configurable triggerMasks{"triggerMasks", "", "JE framework - skimmed data trigger masks (relevent for correlation: fTrackLowPt,fTrackHighPt)"}; + + Configurable piPIDLowPt{"piPIDLowPt", 0.5, "max pt value for pipm PID without tof"}; + Configurable piPIDHighPt{"piPIDHighPt", 2.5, "min pt value for pipm PID without tof in relativistic rise of Bethe-Bloch"}; + Configurable> nSigmaPiTpcLowPt{"nSigmaPiTpcLowPt", {-2, 2}, "minimum-maximum nSigma for pipm in tpc at low pt"}; + Configurable> nSigmaPiTpcMidPt{"nSigmaPiTpcMidPt", {-1, 1}, "minimum-maximum nSigma for pipm in tpc at mid pt"}; + Configurable> nSigmaPiTof{"nSigmaPiTof", {-1, 2}, "minimum-maximum nSigma for pipm in tof"}; + Configurable> nSigmaPiRelRise{"nSigmaPiRelRise", {0, 2}, "minimum-maximum nSigma pipm tpc at high pt"}; + + Configurable ptTrigMin{"ptTrigMin", 5, "minimum pT of triggers"}; + + // derivatives of configurables + + std::vector eventSelectionBits; + int trackSelection = -1; + std::vector triggerMaskBits; + + // for mc + Service pdg; + + // partitions++ + SliceCache cache; + Partition partitionTriggerTracks = aod::jtrack::pt > ptTrigMin; + Partition partitionTriggerParticles = aod::jmcparticle::pt > ptTrigMin; + + Preslice perColTracks = aod::jtrack::collisionId; + Preslice perColMcParticles = aod::jmcparticle::mcCollisionId; + + Preslice perColV0Photons = aod::v0photonkf::collisionId; + + // functions ================================================================================================================================================================================ + + // selections /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // event selection + template + bool checkEventSelection(T_collision const& collision) + { + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) + return false; + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) + return false; + if (std::abs(collision.posZ()) > zPvMax) + return false; + if (collision.trackOccupancyInTimeRange() < occupancyMin || collision.trackOccupancyInTimeRange() > occupancyMax) + return false; + return true; + } + + // checks global track cuts + template + bool checkGlobalTrackEta(T_track const& track) + { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) + return false; + if (!jetderiveddatautilities::applyTrackKinematics(track, 0.1, 1000, -1 * etaMax, etaMax)) + return false; + return true; + } + + // checks pipm selection (just PID (no additional track cuts)) + template + bool checkPipmTPCTOF(T_track const& track) + { + // too low for tof + if (track.pt() < piPIDLowPt) { + if (track.tpcNSigmaPi() > nSigmaPiTpcLowPt.value[0] && track.tpcNSigmaPi() < nSigmaPiTpcLowPt.value[1]) { + return true; + } + return false; + } + // Bethe-Bloch overlap (-> tpc + tof) + if (track.pt() < piPIDHighPt) { + if (track.hasTOF()) { // has to stay inside pt-if due to return-layout of function + if (track.tpcNSigmaPi() > nSigmaPiTpcMidPt.value[0] && track.tpcNSigmaPi() < nSigmaPiTpcMidPt.value[1] && + track.tofNSigmaPi() > nSigmaPiTof.value[0] && track.tofNSigmaPi() < nSigmaPiTof.value[1]) { + return true; + } + } + return false; + } + // Bethe-Bloch rel rise (too high for tof) + if (track.tpcNSigmaPi() > nSigmaPiRelRise.value[0] && track.tpcNSigmaPi() < nSigmaPiRelRise.value[1]) { + return true; + } + return false; + } + + // checks pipm selection (just PID (no additional track cuts)) + template + bool checkPipmTPC(T_track const& track) + { + // Bethe-Bloch rel rise + if (track.pt() > piPIDHighPt) { + if (track.tpcNSigmaPi() > nSigmaPiRelRise.value[0] && track.tpcNSigmaPi() < nSigmaPiRelRise.value[1]) { + return true; + } + } + return false; + } + + // analysis ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + void init(InitContext const&) + { + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); + } + + void processRecoCollisionTrigger(aod::JetCollision const& collision, aod::JetTracks const&) + { + // event selection + const bool isSelectedEvent = checkEventSelection(collision); + // trigger event check + bool isTriggerEvent = false; + + if (isSelectedEvent) { + // group collision + auto const triggers = partitionTriggerTracks->sliceByCached(aod::jtrack::collisionId, collision.globalIndex(), cache); + + // trigger loop + for (auto const& trigger : triggers) { + // track selection + if (!checkGlobalTrackEta(trigger)) + continue; + + // detect trigger event + isTriggerEvent = true; + + // trigger info + triggerTable(trigger.collisionId(), trigger.globalIndex(), trigger.pt(), trigger.phi(), trigger.eta()); + } + } + + // collision info + collisionExtraCorrTable(isSelectedEvent, isTriggerEvent); + } + PROCESS_SWITCH(CorrelationTableProducer, processRecoCollisionTrigger, "process correlation collision_extra and trigger table (reconstructed)", false); + + void processRecoPipmTPCTOF(aod::JetCollision const& collision, + soa::Join const& tracks, soa::Join const&) + { + // event selection + if (!checkEventSelection(collision)) + return; + + // hadron/pipm + for (auto const& track : tracks) { + // track selection + if (!checkGlobalTrackEta(track)) + continue; + + // hadron + hadronTable(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); + + // pipm selection + auto const& trackPID = track.track_as>(); + if (!checkPipmTPCTOF(trackPID)) + continue; + + // pipm + pipmTable(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); + } + } + PROCESS_SWITCH(CorrelationTableProducer, processRecoPipmTPCTOF, "process pipm (TPC-TOF) table (reconstructed)", false); + + void processRecoPipmTPC(aod::JetCollision const& collision, + soa::Join const& tracks, soa::Join const&) + { + // event selection + if (!checkEventSelection(collision)) + return; + + // hadron/pipm + for (auto const& track : tracks) { + // track selection + if (!checkGlobalTrackEta(track)) + continue; + + // hadron + hadronTable(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); + + // pipm selection + auto const& trackPID = track.track_as>(); + if (!checkPipmTPC(trackPID)) + continue; + + // pipm + pipmTable(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); + } + } + PROCESS_SWITCH(CorrelationTableProducer, processRecoPipmTPC, "process pipm (TPC) table (reconstructed)", false); + + void processRecoPhotonPCM(soa::Join::iterator const& collision, aod::Collisions const&, + aod::V0PhotonsKF const& v0Photons, aod::V0Legs const&) + { + // event selection + if (!checkEventSelection(collision)) + return; + + // photonsPCM (for some reason collsionId not an index column (?)) + auto const v0PhotonsThisEvent = v0Photons.sliceBy(perColV0Photons, collision.collisionId()); + + // photonPCM + for (auto const& v0Photon : v0PhotonsThisEvent) { + // photon selection + if (std::abs(v0Photon.eta()) > etaMax) + continue; + + // photon PCM + photonPCMTable(v0Photon.collisionId(), v0Photon.globalIndex(), + v0Photon.posTrack().trackId(), v0Photon.negTrack().trackId(), v0Photon.pt(), v0Photon.phi(), v0Photon.eta()); + } + + // photonPCm pairs + for (auto const& [v0Photon1, v0Photon2] : soa::combinations(soa::CombinationsStrictlyUpperIndexPolicy(v0PhotonsThisEvent, v0PhotonsThisEvent))) { + // get kinematics + ROOT::Math::PtEtaPhiMVector const p4V0PCM1(v0Photon1.pt(), v0Photon1.eta(), v0Photon1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector const p4V0PCM2(v0Photon2.pt(), v0Photon2.eta(), v0Photon2.phi(), 0.); + ROOT::Math::PtEtaPhiMVector const p4V0PCMPair = p4V0PCM1 + p4V0PCM2; + + // pi0 selection + if (std::abs(p4V0PCMPair.Eta()) > etaMax) + continue; + + // save info + photonPCMPairTable(v0Photon1.collisionId(), v0Photon1.globalIndex(), v0Photon2.globalIndex(), + v0Photon1.posTrack().trackId(), v0Photon1.negTrack().trackId(), v0Photon2.posTrack().trackId(), v0Photon2.negTrack().trackId(), + p4V0PCMPair.Pt(), p4V0PCMPair.Phi() + constants::math::PI, p4V0PCMPair.Eta(), p4V0PCMPair.M()); + } + } + PROCESS_SWITCH(CorrelationTableProducer, processRecoPhotonPCM, "process photonPCM table (reconstructed)", false); + + void processMcCorrTables(aod::JetMcCollision const& mcCollision, aod::JetParticles const&) + { + // group collision + auto const triggers = partitionTriggerParticles->sliceByCached(aod::jmcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + // trigger event check + bool isTriggerEvent = false; + + // trigger loop + for (auto const& trigger : triggers) { + // track selection + auto const pdgParticle = pdg->GetParticle(trigger.pdgCode()); + if (!pdgParticle || pdgParticle->Charge() == 0) + continue; + if (!trigger.isPhysicalPrimary()) + continue; + if (std::abs(trigger.eta()) > etaMax) + continue; + + // detect trigger event + isTriggerEvent = true; + + // trigger info + triggerParticleTable(mcCollision.globalIndex(), trigger.globalIndex(), trigger.pt(), trigger.phi(), trigger.eta()); + } + + // collision info + mcCollisionExtraCorrTable(isTriggerEvent); + } + PROCESS_SWITCH(CorrelationTableProducer, processMcCorrTables, "process table production (mc)", false); +}; + +// correlation analysis ======================================================================================================================================================================= + +struct PhotonChargedTriggerCorrelation { + // configurables + + // general (kenobi) + Configurable pathCcdbEff{"pathCcdbEff", "Users/j/jkinner/efficiency/set_in_config", "base path to the ccdb efficiencies"}; + Configurable urlCcdb{"urlCcdb", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable noLaterThanCcdb{"noLaterThanCcdb", + std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), + "latest acceptable timestamp of creation for the object"}; + + // analysis + Configurable doEffCorrectionTrigger{"doEffCorrectionTrigger", false, "whether to do on-the-fly mixing correction for triggers"}; + Configurable doEffCorrectionHadron{"doEffCorrectionHadron", false, "whether to do on-the-fly mixing correction for hadrons"}; + Configurable doEffCorrectionPipm{"doEffCorrectionPipm", false, "whether to do on-the-fly mixing correction for pipm"}; + Configurable doEffCorrectionPhotonPCM{"doEffCorrectionPhotonPCM", false, "whether to do on-the-fly mixing correction for photonPCM"}; + + Configurable doTrigEvMixing{"doTrigEvMixing", false, "whether to use trigger events for trigger mixing"}; + Configurable doTrigEvEff{"doTrigEvEff", false, "whether to use trigger events for efficiency histograms"}; + Configurable nTriggerSavedForMixing{"nTriggerSavedForMixing", 2048, "number of triggers that are saved for mixing with other events"}; + Configurable nTriggerMixingHadron{"nTriggerMixingHadron", 64, "number of triggers that are used for hadron mixing"}; + Configurable nTriggerMixingPipm{"nTriggerMixingPipm", 64, "number of triggers that are used for pipm mixing"}; + Configurable nTriggerMixingPhotonPCM{"nTriggerMixingPhotonPCM", 64, "number of triggers that are saved for photonPCM mixing"}; + Configurable nTriggerMixingPi0PCM{"nTriggerMixingPi0PCM", 64, "number of triggers that are saved for pi0PCM mixing"}; + Configurable nNeighboursMixingPi0PCMPair{"nNeighboursMixingPi0PCMPair", 64, "number neighbours used for for pi0PCM pair mixing"}; + Configurable> pi0PCMMassRange{"pi0PCMMassRange", {0.10, 0.15}, "photon-pair mass integration range for pi0PCM"}; + Configurable> pi0PCMSideMassRange{"pi0PCMSideMassRange", {0.16, 0.24}, "photon-pair mass integration range outside outside pi0PCM region"}; + + Configurable requireSingleCollisionPurity{"requireSingleCollisionPurity", true, "whether particle from single chosen MC-col associated to reco-col (else just type/kin match)"}; + + // for histograms + Configurable nBinsZPv{"nBinsZPv", 100, "number zPv bins in histos for QA"}; + Configurable nBinsZPvSmol{"nBinsZPvSmol", 28, "number zPv bins but smaller"}; + Configurable nBinsMult{"nBinsMult", 200, "number multiplicity bins in histos for QA"}; + Configurable nBinsMultSmol{"nBinsMultSmol", 20, "number multiplicity bins but smaller"}; + Configurable nBinsOccupancy{"nBinsOccupancy", 2000, "number occupancy bins in histos for QA"}; + + Configurable nBinsPhi{"nBinsPhi", 72, "number phi bins"}; + Configurable nBinsEta{"nBinsEta", 40, "number eta bins"}; + Configurable nBinsMgg{"nBinsMgg", 160, "number mass-photon-pair bins"}; + + Configurable> binsPtTrig{"binsPtTrig", {5, 10, 25, 50}, "correlation ptTrig bins"}; + Configurable> binsPtAssoc{"binsPtAssoc", + {0.2, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10, 12.5, 15, 17.5, 20, 30, 40}, + "correlation ptAssoc bins"}; + Configurable> binsDPhi{"binsDPhi", + {0.00 * DPHI_SCALE, + 0.04 * DPHI_SCALE, 0.08 * DPHI_SCALE, 0.11 * DPHI_SCALE, 0.14 * DPHI_SCALE, + 0.16 * DPHI_SCALE, 0.18 * DPHI_SCALE, 0.20 * DPHI_SCALE, 0.22 * DPHI_SCALE, + 0.23 * DPHI_SCALE, 0.24 * DPHI_SCALE, 0.25 * DPHI_SCALE, 0.26 * DPHI_SCALE, 0.27 * DPHI_SCALE, 0.28 * DPHI_SCALE, + 0.30 * DPHI_SCALE, 0.32 * DPHI_SCALE, 0.34 * DPHI_SCALE, 0.36 * DPHI_SCALE, + 0.39 * DPHI_SCALE, 0.42 * DPHI_SCALE, 0.46 * DPHI_SCALE, 0.50 * DPHI_SCALE, + 0.54 * DPHI_SCALE, 0.58 * DPHI_SCALE, 0.61 * DPHI_SCALE, 0.64 * DPHI_SCALE, + 0.66 * DPHI_SCALE, 0.68 * DPHI_SCALE, 0.70 * DPHI_SCALE, 0.72 * DPHI_SCALE, + 0.74 * DPHI_SCALE, 0.76 * DPHI_SCALE, 0.78 * DPHI_SCALE, + 0.80 * DPHI_SCALE, 0.82 * DPHI_SCALE, 0.84 * DPHI_SCALE, 0.86 * DPHI_SCALE, + 0.89 * DPHI_SCALE, 0.92 * DPHI_SCALE, 0.96 * DPHI_SCALE, 1.00 * DPHI_SCALE}, + "correlation bins DeltaPhi"}; + Configurable> binsDEta{"binsDEta", + {0 / 32. * DETA_SCALE, + 1 / 32. * DETA_SCALE, 2 / 32. * DETA_SCALE, 3 / 32. * DETA_SCALE, 4 / 32. * DETA_SCALE, + 5 / 32. * DETA_SCALE, 6 / 32. * DETA_SCALE, 7 / 32. * DETA_SCALE, 8 / 32. * DETA_SCALE, + 9 / 32. * DETA_SCALE, 10 / 32. * DETA_SCALE, 11 / 32. * DETA_SCALE, 12 / 32. * DETA_SCALE, 13 / 32. * DETA_SCALE, 14 / 32. * DETA_SCALE, + 59 / 128. * DETA_SCALE, 62 / 128. * DETA_SCALE, 64 / 128. * DETA_SCALE, 66 / 128. * DETA_SCALE, 69 / 128. * DETA_SCALE, 18 / 32. * DETA_SCALE, + 19 / 32. * DETA_SCALE, 20 / 32. * DETA_SCALE, 21 / 32. * DETA_SCALE, 22 / 32. * DETA_SCALE, 23 / 32. * DETA_SCALE, 24 / 32. * DETA_SCALE, + 25 / 32. * DETA_SCALE, 26 / 32. * DETA_SCALE, 27 / 32. * DETA_SCALE, 28 / 32. * DETA_SCALE, + 29 / 32. * DETA_SCALE, 30 / 32. * DETA_SCALE, 31 / 32. * DETA_SCALE, 32 / 32. * DETA_SCALE}, + "correlation bins DeltaEta"}; + Configurable> binsZPv{"binsZPv", + {-7, -5, -3, -1, 1, 3, 5, 7}, + "zPv mixing bins"}; + Configurable> binsMult{"binsMult", + {-0.5, 9.5, 14.5, 19.5, 25.5, 32}, + "multiplicity mixing bins"}; + + // configurables from other tasks + + double etaMax; + + // objects to hold histograms + HistogramRegistry histos{"histogramRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + // ccdb calls + Service ccdb; + // for mc + Service pdg; + + // random number generation + static constexpr unsigned int SeedRandomEngine = 12345; + std::mt19937 randomEngine{SeedRandomEngine}; + + // partitions + SliceCache cache; + + // prepare for per collision slicing + Preslice perColTracks = aod::jtrack::collisionId; + Preslice perColTriggers = aod::corr_particle::jetCollisionId; + Preslice perColHadrons = aod::corr_particle::jetCollisionId; + Preslice perColPipms = aod::corr_particle::jetCollisionId; + Preslice perColPhotonPCMs = aod::corr_particle::jetCollisionId; + Preslice perColMcParticles = aod::jmcparticle::mcCollisionId; + Preslice perColTriggerParticles = aod::corr_particle::jetMcCollisionId; + + // combinations binning + // cumbersome, but still better than having extra configurable or figuring out how to init binningZPvMult later while declaring it here + std::function(std::vector const&, double)> prependValueToVector = + [](std::vector const& vec, double const value) { + std::vector resultVec = {value}; + resultVec.insert(resultVec.end(), vec.begin(), vec.end()); + return resultVec; + }; + BinningZPvMult binningZPvMult{{prependValueToVector(binsZPv.value, VARIABLE_WIDTH), prependValueToVector(binsMult.value, VARIABLE_WIDTH)}, true}; + + // declare analysis variables + + // efficiency histograms + TH1D* h1PtInvEffTrigger; + TH1D* h1PtInvEffHadron; + TH1D* h1PtInvEffPipm; + TH1D* h1PtInvEffPhotonPCM; + + // mixing trigger memory + int nTriggersThisDataFrame; + // organised as zPv- and mult-bin matrix of deques to save trigger info beyond single dataframe + // extra bin for mult overflow + // with ajusted zVtx (see triggerBinValuesZPv in init) and mult overflow -> all events accounted for + // (possibly replace by some advanced derived data method and O2 event mixing in future?) + std::vector triggerBinValuesZPv; + std::vector triggerBinValuesMult; + std::vector>> savedTriggersZPvMultPt; + std::vector>> savedTriggersZPvMultPhi; + std::vector>> savedTriggersZPvMultEta; + + // functions ================================================================================================================================================================================ + + // general (kenobi) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // get histograms from ccdb + // save efficiencies from ccdb in histogram registry + void initCcdbHistograms() + { + // trigger + h1PtInvEffTrigger = nullptr; + if (doEffCorrectionTrigger) { + h1PtInvEffTrigger = ccdb->getForTimeStamp(pathCcdbEff.value + "/trigger", noLaterThanCcdb.value); + + const double* effBinsTrigger = h1PtInvEffTrigger->GetXaxis()->GetXbins()->GetArray(); + const AxisSpec axisPtEffTrigger{std::vector(effBinsTrigger, effBinsTrigger + h1PtInvEffTrigger->GetNbinsX() + 1), "#it{p}_{T}"}; + histos.add("usedEff/h1_pt_invEff_trigger_ccdb", "h1_pt_invEff_trigger_ccdb", kTH1D, {axisPtEffTrigger}, true); + for (int iBin = 1; iBin <= h1PtInvEffTrigger->GetNbinsX(); iBin++) { + histos.get(HIST("usedEff/h1_pt_invEff_trigger_ccdb"))->SetBinContent(iBin, h1PtInvEffTrigger->GetBinContent(iBin)); + histos.get(HIST("usedEff/h1_pt_invEff_trigger_ccdb"))->SetBinError(iBin, h1PtInvEffTrigger->GetBinError(iBin)); + } + } + // hadron + h1PtInvEffHadron = nullptr; + if (doEffCorrectionHadron) { + h1PtInvEffHadron = ccdb->getForTimeStamp(pathCcdbEff.value + "/hadron", noLaterThanCcdb.value); + + const double* effBinsHadron = h1PtInvEffHadron->GetXaxis()->GetXbins()->GetArray(); + const AxisSpec axisPtEffHadron{std::vector(effBinsHadron, effBinsHadron + h1PtInvEffHadron->GetNbinsX() + 1), "#it{p}_{T}"}; + histos.add("usedEff/h1_pt_invEff_hadron_ccdb", "h1_pt_invEff_hadron_ccdb", kTH1D, {axisPtEffHadron}, true); + for (int iBin = 1; iBin <= h1PtInvEffHadron->GetNbinsX(); iBin++) { + histos.get(HIST("usedEff/h1_pt_invEff_hadron_ccdb"))->SetBinContent(iBin, h1PtInvEffHadron->GetBinContent(iBin)); + histos.get(HIST("usedEff/h1_pt_invEff_hadron_ccdb"))->SetBinError(iBin, h1PtInvEffHadron->GetBinError(iBin)); + } + } + // pipm + h1PtInvEffPipm = nullptr; + if (doEffCorrectionPipm) { + h1PtInvEffPipm = ccdb->getForTimeStamp(pathCcdbEff.value + "/pipm", noLaterThanCcdb.value); + + const double* effBinsPipm = h1PtInvEffPipm->GetXaxis()->GetXbins()->GetArray(); + const AxisSpec axisPtEffPipm{std::vector(effBinsPipm, effBinsPipm + h1PtInvEffPipm->GetNbinsX() + 1), "#it{p}_{T}"}; + histos.add("usedEff/h1_pt_invEff_pipm_ccdb", "h1_pt_invEff_pipm_ccdb", kTH1D, {axisPtEffPipm}, true); + for (int iBin = 1; iBin <= h1PtInvEffPipm->GetNbinsX(); iBin++) { + histos.get(HIST("usedEff/h1_pt_invEff_pipm_ccdb"))->SetBinContent(iBin, h1PtInvEffPipm->GetBinContent(iBin)); + histos.get(HIST("usedEff/h1_pt_invEff_pipm_ccdb"))->SetBinError(iBin, h1PtInvEffPipm->GetBinError(iBin)); + } + } + // photonPCM + h1PtInvEffPhotonPCM = nullptr; + if (doEffCorrectionPhotonPCM) { + h1PtInvEffPhotonPCM = ccdb->getForTimeStamp(pathCcdbEff.value + "/photonPCM", noLaterThanCcdb.value); + + const double* effBinsPhotonPCM = h1PtInvEffPhotonPCM->GetXaxis()->GetXbins()->GetArray(); + const AxisSpec axisPtEffPhotonPCM{std::vector(effBinsPhotonPCM, effBinsPhotonPCM + h1PtInvEffPhotonPCM->GetNbinsX() + 1), "#it{p}_{T}"}; + histos.add("usedEff/h1_pt_invEff_photonPCM_ccdb", "h1_pt_invEff_photonPCM_ccdb", kTH1D, {axisPtEffPhotonPCM}, true); + for (int iBin = 1; iBin <= h1PtInvEffPhotonPCM->GetNbinsX(); iBin++) { + histos.get(HIST("usedEff/h1_pt_invEff_photonPCM_ccdb"))->SetBinContent(iBin, h1PtInvEffPhotonPCM->GetBinContent(iBin)); + histos.get(HIST("usedEff/h1_pt_invEff_photonPCM_ccdb"))->SetBinError(iBin, h1PtInvEffPhotonPCM->GetBinError(iBin)); + } + } + } + + // create histograms + void initHistograms() + { + // define axes + const AxisSpec axisN{1, 0., 1., "#it{N}_{something}"}; + const AxisSpec axisCategories{16, 0., 16., "categories"}; + + const AxisSpec axisZPv{nBinsZPv, -10, 10, "#it{z}_{pv}"}; + const AxisSpec axisZPvSmol{nBinsZPvSmol, -7, 7, "#it{z}_{pv}"}; + const AxisSpec axisMult{nBinsMult + 1, -0.5, nBinsMult + 0.5, "multiplicity"}; + const AxisSpec axisMultSmol{nBinsMultSmol + 1, -0.5, nBinsMultSmol + 0.5, "multiplicity"}; + const AxisSpec axisOccupancy{nBinsOccupancy + 1, -0.5, nBinsOccupancy + 0.5, "occupancy"}; + + const AxisSpec axisPhi{nBinsPhi, 0, constants::math::TwoPI, "#it{#varphi}"}; + const AxisSpec axisEta{nBinsEta, -etaMax, etaMax, "#it{#eta}"}; + const AxisSpec axisMgg{nBinsMgg, 0, 0.8, "#it{m}_{#gamma#gamma}"}; + + const AxisSpec axisPtTrig{binsPtTrig, "#it{p}_{T}^{trig}"}; + const AxisSpec axisPtAssoc{binsPtAssoc, "#it{p}_{T}^{assoc}"}; + const AxisSpec axisDPhi{binsDPhi, "#Delta#it{#varphi}"}; + const AxisSpec axisDEta{binsDEta, "#Delta#it{#eta}"}; + const AxisSpec axisZPvBinning{binsZPv, "#it{z}_{pv} correlation binning"}; + const AxisSpec axisMultBinning{binsMult, "multiplicity correlation binning"}; + + // reco info + histos.add("reco/info/h1_nEvents", "h1_nEvents", kTH1D, {axisCategories}); + histos.get(HIST("reco/info/h1_nEvents"))->GetXaxis()->SetBinLabel(1, "#it{N}_{ev}^{sel}"); + histos.get(HIST("reco/info/h1_nEvents"))->GetXaxis()->SetBinLabel(2, "#it{N}_{ev}"); + histos.get(HIST("reco/info/h1_nEvents"))->GetXaxis()->SetBinLabel(3, "#it{N}_{ev}^{trig}"); + + histos.add("reco/info/h2_zPvMult", "h2_zPvMult", kTHnSparseD, {axisZPv, axisMult}, true); + histos.add("reco/info/h1_occupancy", "h1_occupancy", kTH1D, {axisOccupancy}, true); + + // reco (correlation) analysis + histos.add("reco/info/h2_zPvMult_trigEv", "h2_zPvMult_trigEv", kTHnSparseD, {axisZPv, axisMult}, true); + histos.add("reco/info/h1_occupancy_trigEv", "h1_occupancy_trigEv", kTH1D, {axisOccupancy}, true); + histos.add("reco/corr/h3_ptPhiEta_trig", "h3_ptPhiEta_trig", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + + // hadron + histos.add("reco/plain/h3_ptPhiEta_hadron", "h3_ptPhiEta_hadron", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add("reco/corr/h3_ptPhiEta_assoc_hadron", "h3_ptPhiEta_assoc_hadron", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add("reco/corr/h6_corr_hadron", "h6_corr_hadron", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/corr/h6_mix_hadron", "h6_mix_hadron", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + // pipm + histos.add("reco/plain/h3_ptPhiEta_pipm", "h3_ptPhiEta_pipm", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add("reco/corr/h3_ptPhiEta_assoc_pipm", "h3_ptPhiEta_assoc_pipm", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add("reco/corr/h6_corr_pipm", "h6_corr_pipm", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/corr/h6_mix_pipm", "h6_mix_pipm", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + // photonPCM + histos.add("reco/plain/h3_ptPhiEta_photonPCM", "h3_ptPhiEta_photonPCM", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add("reco/corr/h3_ptPhiEta_assoc_photonPCM", "h3_ptPhiEta_assoc_photonPCM", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add("reco/corr/h6_corr_photonPCM", "h6_corr_photonPCM", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/corr/h6_mix_photonPCM", "h6_mix_photonPCM", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + // photonPCM pairs + histos.add("reco/plain/h4_ptMggZPvMult_photonPCMPair", "h4_ptMggZPvMult_photonPCMPair", kTHnSparseD, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/plain/h3_ptPhiEta_pi0PCMPeak", "h3_ptPhiEta_pi0PCMPeak", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add("reco/corr/h4_ptMggZPvMult_assoc_photonPCMPair", "h4_ptMggZPvMult_assoc_photonPCMPair", kTHnSparseD, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/corr/h3_ptPhiEta_assoc_pi0PCMPeak", "h3_ptPhiEta_assoc_pi0PCMPeak", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + // peak (mgg) + histos.add("reco/corr/h6_corr_pi0PCMPeak", "h6_corr_pi0PCMPeak", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/corr/h6_mix_pi0PCMPeak", "h6_mix_pi0PCMPeak", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + // side (mgg) + histos.add("reco/corr/h6_corr_pi0PCMSide", "h6_corr_pi0PCMSide", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/corr/h6_mix_pi0PCMSide", "h6_mix_pi0PCMSide", + kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + // event mixing for photon pairs + histos.add("reco/plain/h2_zPvMult_photonPCMPair_evMix", "h2_zPvMult_photonPCMPair_evMix", kTHnSparseD, {axisZPv, axisMult}, true); + histos.add("reco/plain/h4_ptMggZPvMult_photonPCMPair_evMix", "h4_ptMggZPvMult_photonPCMPair_evMix", kTHnSparseD, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/plain/h3_ptPhiEta_pi0PCMPeak_evMix", "h3_ptPhiEta_pi0PCMPeak_evMix", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + + // mc info + histos.add("mc/info/h1_nEvents_mcTrue", "h1_nEvents_mcTrue", kTH1D, {axisN}); + histos.add("mc/info/h1_nTriggerEvents_mcTrue", "h1_nTriggerEvents_mcTrue", kTH1D, {axisN}); + + histos.add("mc/info/h1_zPv_mcTrue", "h1_zPv_mcTrue", kTH1D, {axisZPv}, true); + histos.add("mc/info/h1_mult_mcTrue", "h1_mult_mcTrue", kTH1D, {axisMult}, true); + + // reco and true collision correlations + for (auto const& collision_type : {"true", "true_reco"}) { + histos.add(std::format("mc/{}/corr/h3_ptPhiEta_trig", collision_type).data(), "h3_ptPhiEta_trig", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + // hadron + histos.add(std::format("mc/{}/corr/h3_ptPhiEta_assoc_hadron", collision_type).data(), "h3_ptPhiEta_assoc_hadron", + kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add(std::format("mc/{}/corr/h4_corr_hadron", collision_type).data(), "h4_corr_hadron", + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc}, true); + // pipm + histos.add(std::format("mc/{}/corr/h3_ptPhiEta_assoc_pipm", collision_type).data(), "h3_ptPhiEta_assoc_pipm", + kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add(std::format("mc/{}/corr/h4_corr_pipm", collision_type).data(), "h4_corr_pipm", + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc}, true); + // photon + histos.add(std::format("mc/{}/corr/h3_ptPhiEta_assoc_photon", collision_type).data(), "h3_ptPhiEta_assoc_photon", + kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add(std::format("mc/{}/corr/h4_corr_photon", collision_type).data(), "h4_corr_photon", + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc}, true); + // pi0 + histos.add(std::format("mc/{}/corr/h3_ptPhiEta_assoc_pi0", collision_type).data(), "h3_ptPhiEta_assoc_pi0", + kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add(std::format("mc/{}/corr/h4_corr_pi0", collision_type).data(), "h4_corr_pi0", + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc}, true); + } + + // mc efficiency/purity + std::function add_effHists = + [&](std::string name_id) { + histos.add(std::format("mc/eff/h3_ptPhiEta_{}", name_id).data(), "h3_ptPhiEta_mcReco_hadron", + kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add(std::format("mc/eff/h3_ptZPvMult_{}", name_id).data(), "h3_ptZPvMult_mcReco_hadron", + kTHnSparseD, {axisPtAssoc, axisZPvSmol, axisMultSmol}, true); + }; + // mc tracks + add_effHists("mcReco_hadron"); + add_effHists("mcReco_hasCorrectMc_hadron"); + add_effHists("mcTrue_hadron"); + add_effHists("mcTrue_recoCol_hadron"); + // mc pipm PID + add_effHists("mcReco_pipm"); + add_effHists("mcReco_hasCorrectMc_pipm"); + add_effHists("mcTrue_pipm"); + add_effHists("mcTrue_recoCol_pipm"); + // mc photonPCM + add_effHists("mcReco_photonPCM"); + add_effHists("mcReco_hasCorrectMc_photonPCM"); + add_effHists("mcTrue_photon"); + add_effHists("mcTrue_recoCol_photon"); + // mc pi0PCM + add_effHists("mcReco_pi0PCM"); + add_effHists("mcReco_hasCorrectMc_pi0PCM"); + add_effHists("mcTrue_pi0"); + add_effHists("mcTrue_recoCol_pi0"); + + // test of the test while testing another test. featuring a test + histos.add("test/h2_mult_comp", "h2_mult_comp", kTH2D, {axisMult, axisMult}, true); + histos.add("test/h2_tracks_zPvMultDep", "h2_tracks_zPvMultDep", kTH2D, {axisZPv, axisMult}, true); + histos.add("test/h2_globalTracks_zPvMultDep", "h2_globalTracks_zPvMultDep", kTH2D, {axisZPv, axisMult}, true); + } + + // selections /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // checks if mcParticle is charged + template + bool checkChargedMc(T_mcParticle const& mcParticle) + { + auto const pdgParticle = pdg->GetParticle(mcParticle.pdgCode()); + if (!pdgParticle || pdgParticle->Charge() == 0) + return false; + return true; + } + // checks if mcParticle should be detected (physicalPrimary, |eta|) + template + bool checkPrimaryEtaMc(T_mcParticle const& mcParticle) + { + if (!mcParticle.isPhysicalPrimary()) + return false; + if (std::abs(mcParticle.eta()) > etaMax) + return false; + return true; + } + // checks if mcParticle should be detected as primary track (physicalPrimary, charge, |eta|) + template + bool checkPrimaryTrackMc(T_mcParticle const& mcParticle) + { + if (!checkPrimaryEtaMc(mcParticle)) + return false; + if (!checkChargedMc(mcParticle)) + return false; + return true; + } + // checks if mcParticle should be detected as 'primary' pi0->gg (|eta| not checked) + template + bool checkPi0ToGG(T_mcParticle const& mcParticle) + { + if (mcParticle.pdgCode() != PDG_t::kPi0) + return false; + // identify primary pi0 (account for 0 daughters for some reason) + if (mcParticle.template daughters_as().size() == 0) + return false; + for (auto const& pi0_daughter : mcParticle.template daughters_as()) { + if (!pi0_daughter.isPhysicalPrimary()) + return false; + } + // select pi0 -> gg + constexpr int NDaughtersPi0ToGG = 2; + if (mcParticle.template daughters_as().size() != NDaughtersPi0ToGG) + return false; + return true; + } + + // analysis helpers ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + template + double getH1ValueAt(T_h1 const* const h1, double const value) + { + return h1->GetBinContent(h1->FindFixBin(value)); + } + // efficiency helpers + // define enum class for particle type + enum class ParticleType { Trigger, + Hadron, + Pipm, + PhotonPCM }; + // efficiency function + template + double getInvEff(double const value) + { + if constexpr (T == ParticleType::Trigger) { + return doEffCorrectionTrigger ? getH1ValueAt(h1PtInvEffTrigger, value) : 1; + } else if constexpr (T == ParticleType::Hadron) { + return doEffCorrectionHadron ? getH1ValueAt(h1PtInvEffHadron, value) : 1; + } else if constexpr (T == ParticleType::Pipm) { + return doEffCorrectionPipm ? getH1ValueAt(h1PtInvEffPipm, value) : 1; + } else if constexpr (T == ParticleType::PhotonPCM) { + return doEffCorrectionPhotonPCM ? getH1ValueAt(h1PtInvEffPhotonPCM, value) : 1; + } else { + return 1; + } + } + + // performs 'phi1 - phi2' and pushes it into the interval [-pi/2, 3pi/2] + inline double getDeltaPhi(double const phi1, double const phi2) + { + return RecoDecay::constrainAngle(phi1 - phi2, -1 * constants::math::PIHalf); + } + + // finds bin that value belongs to (assumes ordered bins) (starts at 0; includes underflow (return -1) and overlflow (return bins.size() - 1)) + // should be faster than some std binary search due to small number of bins (zPv, mult) + int findIntervalBin(double value, const std::vector& bins) + { + const int n = bins.size() - 1; + if (value < bins[0]) + return -1; // underflow + for (int i_bin = 0; i_bin < n; i_bin++) + if (value < bins[i_bin + 1]) + return i_bin; + return n; // overflow + } + + // checks that two values belong to the same category (assumes ordered bins) + // returns -1 for negative result (also for under/overflow values) and bin number (starting at 0) otherwise + int checkSameBin(double const value1, double const value2, std::vector const& bins) + { + // reject underflow + if (value1 < bins[0]) + return -1; + // loop over bins + const int n = bins.size() - 1; + for (int i_bin = 0; i_bin < n; i_bin++) { + if (value1 < bins[i_bin + 1]) { + if (value2 < bins[i_bin + 1] && value2 >= bins[i_bin]) { + return i_bin; + } + return -1; + } + } + // reject overflow + return -1; + } + + // analysis ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // generalised correlation functions + // per collision + + // plain info + template + void corrProcessPlain(T_collision const& collision, T_associatedThisEvent const& associatedThisEvent, + T_funcPlain&& funcPlain) + { + // normal spectra (per event - not per trigger) + for (auto const& associated : associatedThisEvent) { + funcPlain(collision, associated); + } + } + + // correlation + template + void corrProcessCorrelation(T_collision const& collision, T_triggersThisEvent const& triggersThisEvent, T_associatedThisEvent const& associatedThisEvent, + T_funcCorrelation&& funcCorrelation) + { + // correlation combinations + for (auto const& [trigger, associated] : soa::combinations(soa::CombinationsFullIndexPolicy(triggersThisEvent, associatedThisEvent))) { + funcCorrelation(collision, trigger, associated); + } + } + + // mixing + template + void corrProcessMixing(T_collision const& collision, T_associatedThisEvent const& associatedThisEvent, + T_funcMixing&& funcMixing, + size_t const nTriggerMixing) + { + // skip if event does not contain valid trigger + if (doTrigEvMixing && !collision.trigEv()) + return; + + // mixing loops (more efficient than O2 mixing (for now)) + // prepare zPv-mult binned saved triggers + const int iBinCorrZPv = findIntervalBin(collision.posZ(), triggerBinValuesZPv); + const int iBinCorrMult = findIntervalBin(collision.multNTracksGlobal(), triggerBinValuesMult); + auto const& savedTriggersPt = savedTriggersZPvMultPt[iBinCorrZPv][iBinCorrMult]; + auto const& savedTriggersPhi = savedTriggersZPvMultPhi[iBinCorrZPv][iBinCorrMult]; + auto const& savedTriggersEta = savedTriggersZPvMultEta[iBinCorrZPv][iBinCorrMult]; + // number of triggers + const int mixUpToTriggerN = std::min(savedTriggersPt.size(), nTriggerMixing + nTriggersThisDataFrame); + const float perTriggerWeight = 1. / (mixUpToTriggerN - nTriggersThisDataFrame); // mixUpToTriggerN <= nTriggersThisDataFrame not problematic since no loop then + // mixing loops + for (int i_mixingTrigger = nTriggersThisDataFrame; i_mixingTrigger < mixUpToTriggerN; i_mixingTrigger++) { + for (auto const& associated : associatedThisEvent) { + funcMixing(collision, savedTriggersPt[i_mixingTrigger], savedTriggersPhi[i_mixingTrigger], savedTriggersEta[i_mixingTrigger], associated, perTriggerWeight); + } + } + } + + void init(InitContext& initContext) + { + // analysis info + ccdb->setURL(urlCcdb.value); + // enabling object caching (otherwise each call goes to CCDB server) + ccdb->setCaching(true); + // ccdb->setLocalObjectValidityChecking(); + // not later than now, will be replaced by the value of train creation (avoids replacing objects while a train is running) + ccdb->setCreatedNotAfter(noLaterThanCcdb.value); + + // init analysis variables + + // get variabels from other tasks + getTaskOptionValue(initContext, "correlation-table-producer", "etaMax", etaMax, false); + + // mixing trigger memory + triggerBinValuesZPv = binsZPv; + triggerBinValuesMult = binsMult; + // prevent rounding errors in bin finding (multiplicity accounted for by it going to 0 and already considering overflow separately) + triggerBinValuesZPv.front() *= 1.0001; + triggerBinValuesZPv.back() *= 1.0001; + // init correct size of zPv-mult matrix + savedTriggersZPvMultPt.resize(binsZPv.value.size() - 1); + savedTriggersZPvMultPhi.resize(binsZPv.value.size() - 1); + savedTriggersZPvMultEta.resize(binsZPv.value.size() - 1); + for (size_t i_zPv = 0; i_zPv < binsZPv.value.size() - 1; i_zPv++) { + savedTriggersZPvMultPt[i_zPv].resize(binsMult.value.size()); + savedTriggersZPvMultPhi[i_zPv].resize(binsMult.value.size()); + savedTriggersZPvMultEta[i_zPv].resize(binsMult.value.size()); + } + + // histograms from ccdb + initCcdbHistograms(); + + // create analysis histograms + initHistograms(); + } + + // reconstructed //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + void processInfo(CorrCollision const& collision) + { + // trigger events + if (collision.trigEv()) { + histos.fill(HIST("reco/info/h1_nEvents"), 2.5); + } + + // event selection + histos.fill(HIST("reco/info/h1_nEvents"), 1.5); + if (!collision.selEv()) + return; + histos.fill(HIST("reco/info/h1_nEvents"), 0.5); + + // QA + histos.fill(HIST("reco/info/h2_zPvMult"), collision.posZ(), collision.multNTracksGlobal()); + histos.fill(HIST("reco/info/h1_occupancy"), collision.trackOccupancyInTimeRange()); + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processInfo, "process general info on collisions and tracks for analysis and qa", false); + + void processCorrFirst(CorrCollisions const& collisions, aod::Triggers const& triggers) + { + // do at beginning of each data frame (before other correlation process functions) + // (PROCESS_SWITCH of this process has to be declared first) + + // set trigger counter + nTriggersThisDataFrame = triggers.size(); + + for (auto const& collision : collisions) { + // event selection + if (!collision.selEv()) + continue; + + // group collision + auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); + + // trigger loop + for (auto const& trigger : triggersThisEvent) { + // trigger info + histos.fill(HIST("reco/corr/h3_ptPhiEta_trig"), trigger.pt(), trigger.phi(), trigger.eta(), + getInvEff(trigger.pt())); + + // save triggers for mixing + const int iBinCorrZPv = findIntervalBin(collision.posZ(), triggerBinValuesZPv); + const int iBinCorrMult = findIntervalBin(collision.multNTracksGlobal(), triggerBinValuesMult); + // special cases (floating point precision errors, mult overflow) should be taken care of by triggerBinValuesZPv and triggerBinValuesMult + savedTriggersZPvMultPt[iBinCorrZPv][iBinCorrMult].push_front(trigger.pt()); + savedTriggersZPvMultPhi[iBinCorrZPv][iBinCorrMult].push_front(trigger.phi()); + savedTriggersZPvMultEta[iBinCorrZPv][iBinCorrMult].push_front(trigger.eta()); + if (static_cast(savedTriggersZPvMultPt[iBinCorrZPv][iBinCorrMult].size()) > nTriggerSavedForMixing) { + savedTriggersZPvMultPt[iBinCorrZPv][iBinCorrMult].pop_back(); + savedTriggersZPvMultPhi[iBinCorrZPv][iBinCorrMult].pop_back(); + savedTriggersZPvMultEta[iBinCorrZPv][iBinCorrMult].pop_back(); + } + } + + // trigger event info + if (collision.trigEv()) { + histos.fill(HIST("reco/info/h2_zPvMult_trigEv"), collision.posZ(), collision.multNTracksGlobal()); + histos.fill(HIST("reco/info/h1_occupancy_trigEv"), collision.trackOccupancyInTimeRange()); + } + } + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrFirst, "process to gather info before correlation processes", false); + + void processCorrHadron(CorrCollision const& collision, aod::Triggers const& triggers, aod::Hadrons const& hadrons) + { + // event selection + if (!collision.selEv()) + return; + + auto const funcPlain = [this]([[maybe_unused]] auto const& collision, auto const& associated) { + histos.fill(HIST("reco/plain/h3_ptPhiEta_hadron"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(associated.pt())); + }; + corrProcessPlain(collision, hadrons, funcPlain); + + auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + // exclude self correlation + if (trigger.jetTrackId() == associated.jetTrackId()) + return; + + histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_hadron"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + histos.fill(HIST("reco/corr/h6_corr_hadron"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + }; + corrProcessCorrelation(collision, triggers, hadrons, funcCorrelation); + + auto const funcMixing = [this](auto const& collision, + float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { + histos.fill(HIST("reco/corr/h6_mix_hadron"), + getDeltaPhi(mixingTriggerPhi, associated.phi()), + mixingTriggerEta - associated.eta(), + mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + perTriggerWeight * getInvEff(mixingTriggerPt) * getInvEff(associated.pt())); + }; + corrProcessMixing(collision, hadrons, funcMixing, nTriggerMixingHadron); + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrHadron, "process standard correlation for associated hardons", false); + + void processCorrPipm(CorrCollision const& collision, aod::Triggers const& triggers, aod::Pipms const& pipms) + { + // event selection + if (!collision.selEv()) + return; + + auto const funcPlain = [this]([[maybe_unused]] auto const& collision, auto const& associated) { + histos.fill(HIST("reco/plain/h3_ptPhiEta_pipm"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(associated.pt())); + }; + corrProcessPlain(collision, pipms, funcPlain); + + auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + // exclude self correlation + if (trigger.jetTrackId() == associated.jetTrackId()) + return; + + histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_pipm"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + histos.fill(HIST("reco/corr/h6_corr_pipm"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + }; + corrProcessCorrelation(collision, triggers, pipms, funcCorrelation); + + auto const funcMixing = [this](auto const& collision, + float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { + histos.fill(HIST("reco/corr/h6_mix_pipm"), + getDeltaPhi(mixingTriggerPhi, associated.phi()), + mixingTriggerEta - associated.eta(), + mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + perTriggerWeight * getInvEff(mixingTriggerPt) * getInvEff(associated.pt())); + }; + corrProcessMixing(collision, pipms, funcMixing, nTriggerMixingPipm); + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPipm, "process standard correlation for associated pipm", false); + + void processCorrPhotonPCM(CorrCollision const& collision, aod::Triggers const& triggers, aod::PhotonPCMs const& photonPCMs) + { + // event selection + if (!collision.selEv()) + return; + + auto const funcPlain = [this]([[maybe_unused]] auto const& collision, auto const& associated) { + histos.fill(HIST("reco/plain/h3_ptPhiEta_photonPCM"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(associated.pt())); + }; + corrProcessPlain(collision, photonPCMs, funcPlain); + + auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + // exclude self correlation + if (trigger.jetTrackId() == associated.posTrackId() || trigger.jetTrackId() == associated.negTrackId()) + return; + + histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_photonPCM"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + histos.fill(HIST("reco/corr/h6_corr_photonPCM"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + }; + corrProcessCorrelation(collision, triggers, photonPCMs, funcCorrelation); + + auto const funcMixing = [this](auto const& collision, + float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { + histos.fill(HIST("reco/corr/h6_mix_photonPCM"), + getDeltaPhi(mixingTriggerPhi, associated.phi()), + mixingTriggerEta - associated.eta(), + mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + perTriggerWeight * getInvEff(mixingTriggerPt) * getInvEff(associated.pt())); + }; + corrProcessMixing(collision, photonPCMs, funcMixing, nTriggerMixingPhotonPCM); + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPhotonPCM, "process standard correlation for associated photonPCM", false); + + void processCorrPi0PCM(CorrCollision const& collision, aod::Triggers const& triggers, aod::PhotonPCMPairs const& photonPCMPairs) + { + // event selection + if (!collision.selEv()) + return; + + auto const funcPlain = [this](auto const& collision, auto const& associated) { + histos.fill(HIST("reco/plain/h4_ptMggZPvMult_photonPCMPair"), associated.pt(), associated.mgg(), collision.posZ(), collision.multNTracksGlobal()); + // pi0 mass range + if (associated.mgg() > pi0PCMMassRange.value[0] && associated.mgg() < pi0PCMMassRange.value[1]) { + histos.fill(HIST("reco/plain/h3_ptPhiEta_pi0PCMPeak"), associated.pt(), associated.phi(), associated.eta()); + } + }; + corrProcessPlain(collision, photonPCMPairs, funcPlain); + + auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + // exclude self correlation + if (trigger.jetTrackId() == associated.posTrack1Id() || trigger.jetTrackId() == associated.negTrack1Id() || + trigger.jetTrackId() == associated.negTrack2Id() || trigger.jetTrackId() == associated.posTrack2Id()) + return; + + histos.fill(HIST("reco/corr/h4_ptMggZPvMult_assoc_photonPCMPair"), + associated.pt(), associated.mgg(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt())); + + if (associated.mgg() > pi0PCMMassRange.value[0] && associated.mgg() < pi0PCMMassRange.value[1]) { + // pi0 mass range + histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_pi0PCMPeak"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(trigger.pt())); + histos.fill(HIST("reco/corr/h6_corr_pi0PCMPeak"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt())); + } else if (associated.mgg() > pi0PCMSideMassRange.value[0] && associated.mgg() < pi0PCMSideMassRange.value[1]) { + // pi0 mass side range + histos.fill(HIST("reco/corr/h6_corr_pi0PCMSide"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt())); + } + }; + corrProcessCorrelation(collision, triggers, photonPCMPairs, funcCorrelation); + + auto const funcMixing = [this](auto const& collision, + float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { + if (associated.mgg() > pi0PCMMassRange.value[0] && associated.mgg() < pi0PCMMassRange.value[1]) { + // pi0 mass range + histos.fill(HIST("reco/corr/h6_mix_pi0PCMPeak"), + getDeltaPhi(mixingTriggerPhi, associated.phi()), + mixingTriggerEta - associated.eta(), + mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + perTriggerWeight * getInvEff(mixingTriggerPt)); + } else if (associated.mgg() > pi0PCMSideMassRange.value[0] && associated.mgg() < pi0PCMSideMassRange.value[1]) { + // pi0 mass side range + histos.fill(HIST("reco/corr/h6_mix_pi0PCMSide"), + getDeltaPhi(mixingTriggerPhi, associated.phi()), + mixingTriggerEta - associated.eta(), + mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + perTriggerWeight * getInvEff(mixingTriggerPt)); + } + }; + corrProcessMixing(collision, photonPCMPairs, funcMixing, nTriggerMixingPi0PCM); + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPi0PCM, "process standard correlation for associated pi0PCM", false); + + void processCorrPi0PCMMix(CorrCollisions const& collisions, aod::PhotonPCMs const& photonPCMs) + { + auto photonPCMsTuple = std::make_tuple(photonPCMs); + SameKindPair pairs{binningZPvMult, nNeighboursMixingPi0PCMPair, -1, collisions, photonPCMsTuple, &cache}; + + // mixed events + for (auto pair = pairs.begin(); pair != pairs.end(); pair++) { + auto const& [collision1, photonPCMs1, collision2, photonPCMs2] = *pair; + + // // check that current und mixing-trigger event are from the same zPv/mult bins + // if (checkSameBin(collision1.posZ(), collision2.posZ(), binsZPv) == -1) { + // std::printf("ERROR: zPv bins do not match\n"); continue; + // } + // if (checkSameBin(collision1.multNTracksGlobal(), collision2.multNTracksGlobal(), binsMult) == -1) { + // std::printf("ERROR: multiplicity bins do not match\n"); continue; + // } + + // event selection + if (!collision1.selEv()) + continue; + if (!collision2.selEv()) + continue; + + // event info + histos.fill(HIST("reco/plain/h2_zPvMult_photonPCMPair_evMix"), collision1.posZ(), collision1.multNTracksGlobal()); + + // mixing loop + for (auto const& [photonPCM1, photonPCM2] : soa::combinations(soa::CombinationsFullIndexPolicy(photonPCMs1, photonPCMs2))) { + ROOT::Math::PtEtaPhiMVector const p4photonPCM1(photonPCM1.pt(), photonPCM1.eta(), photonPCM1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector const p4photonPCM2(photonPCM2.pt(), photonPCM2.eta(), photonPCM2.phi(), 0.); + ROOT::Math::PtEtaPhiMVector const p4photonPCMPair = p4photonPCM1 + p4photonPCM2; + + // plain + histos.fill(HIST("reco/plain/h4_ptMggZPvMult_photonPCMPair_evMix"), p4photonPCMPair.pt(), p4photonPCMPair.M(), collision1.posZ(), collision1.multNTracksGlobal()); + // pi0 mass range + if (p4photonPCMPair.M() > pi0PCMMassRange.value[0] && p4photonPCMPair.M() < pi0PCMMassRange.value[1]) { + histos.fill(HIST("reco/plain/h3_ptPhiEta_pi0PCMPeak_evMix"), p4photonPCMPair.pt(), p4photonPCMPair.phi() + constants::math::PI, p4photonPCMPair.eta()); + } + } + } + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPi0PCMMix, "process gamma-gamma mixing for photonPCM", false); + + // mc /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + void processMcInfo(CorrMcCollision const& mcCollision) + { + // event counter + histos.fill(HIST("mc/info/h1_nEvents_mcTrue"), 0.5); + // trigger events + if (mcCollision.trigEv()) { + histos.fill(HIST("mc/info/h1_nTriggerEvents_mcTrue"), 0.5); + } + + // QA + histos.fill(HIST("mc/info/h1_zPv_mcTrue"), mcCollision.posZ()); + histos.fill(HIST("mc/info/h1_mult_mcTrue"), mcCollision.multMCNParticlesEta08()); + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcInfo, "process general info on mc collisions and tracks for analysis and qa", false); + + void processMcTrueCorr(CorrMcCollision const&, aod::TriggerParticles const& triggerParticles, aod::JetParticles const& mcParticles) + { + // trigger pairing loop + for (auto const& trigger : triggerParticles) { + // trigger info + histos.fill(HIST("mc/true/corr/h3_ptPhiEta_trig"), trigger.pt(), trigger.phi(), trigger.eta()); + + // hadrons (tracks) and pipm + for (auto const& associated : mcParticles) { + // exclude self correlation + if (trigger.jetMcParticleId() == associated.globalIndex()) + continue; + + // standard particles (marked physical primary) + if (checkPrimaryEtaMc(associated)) { + // charged primary ('hadron') selection + if (checkChargedMc(associated)) { + histos.fill(HIST("mc/true/corr/h3_ptPhiEta_assoc_hadron"), associated.pt(), associated.phi(), associated.eta()); + histos.fill(HIST("mc/true/corr/h4_corr_hadron"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt()); + } + + // pipm selection + if (std::abs(associated.pdgCode()) == PDG_t::kPiPlus) { + histos.fill(HIST("mc/true/corr/h3_ptPhiEta_assoc_pipm"), associated.pt(), associated.phi(), associated.eta()); + histos.fill(HIST("mc/true/corr/h4_corr_pipm"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt()); + } + + // photon selection + if (associated.pdgCode() == PDG_t::kGamma) { + histos.fill(HIST("mc/true/corr/h3_ptPhiEta_assoc_photon"), associated.pt(), associated.phi(), associated.eta()); + histos.fill(HIST("mc/true/corr/h4_corr_photon"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt()); + } + } + + // decaying particles (not marked physical primary) + if ((std::abs(associated.eta()) < etaMax)) { + // pi0 selection + if (checkPi0ToGG(associated)) { + histos.fill(HIST("mc/true/corr/h3_ptPhiEta_assoc_pi0"), associated.pt(), associated.phi(), associated.eta()); + histos.fill(HIST("mc/true/corr/h4_corr_pi0"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt()); + } + } + } + } + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueCorr, "process mc-true (all collisions) correlation for multiple associated particles", false); + + void processMcTrueRecoColCorr(CorrMcDCollision const& collision, aod::JetMcCollisions const&, aod::TriggerParticles const& triggerParticles, aod::JetParticles const& mcParticles) + { + // event selection + if (!collision.selEv()) + return; + + // group collision + auto const triggerParticlesThisEvent = triggerParticles.sliceBy(perColTriggerParticles, collision.mcCollisionId()); + auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.mcCollisionId()); + + // trigger pairing loop + for (auto const& trigger : triggerParticlesThisEvent) { + // trigger info + histos.fill(HIST("mc/true_reco/corr/h3_ptPhiEta_trig"), trigger.pt(), trigger.phi(), trigger.eta()); + + // hadrons (tracks) and pipm + for (auto const& associated : mcParticlesThisEvent) { + // exclude self correlation + if (trigger.jetMcParticleId() == associated.globalIndex()) + continue; + + // standard particles (marked physical primary) + if (checkPrimaryEtaMc(associated)) { + // charged primary ('hadron') selection + if (checkChargedMc(associated)) { + histos.fill(HIST("mc/true_reco/corr/h3_ptPhiEta_assoc_hadron"), associated.pt(), associated.phi(), associated.eta()); + histos.fill(HIST("mc/true_reco/corr/h4_corr_hadron"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt()); + } + + // pipm selection + if (std::abs(associated.pdgCode()) == PDG_t::kPiPlus) { + histos.fill(HIST("mc/true_reco/corr/h3_ptPhiEta_assoc_pipm"), associated.pt(), associated.phi(), associated.eta()); + histos.fill(HIST("mc/true_reco/corr/h4_corr_pipm"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt()); + } + + // photon selection + if (associated.pdgCode() == PDG_t::kGamma) { + histos.fill(HIST("mc/true_reco/corr/h3_ptPhiEta_assoc_photon"), associated.pt(), associated.phi(), associated.eta()); + histos.fill(HIST("mc/true_reco/corr/h4_corr_photon"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt()); + } + } + + // decaying particles (not marked physical primary) + if ((std::abs(associated.eta()) < etaMax)) { + // pi0 selection + if (checkPi0ToGG(associated)) { + histos.fill(HIST("mc/true_reco/corr/h3_ptPhiEta_assoc_pi0"), associated.pt(), associated.phi(), associated.eta()); + histos.fill(HIST("mc/true_reco/corr/h4_corr_pi0"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt()); + } + } + } + } + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueRecoColCorr, "process mc-true (reco collisions) correlation for multiple associated particles", false); + + void processMcTrueEff(CorrMcCollision const& mcCollision, aod::JetParticles const& mcParticles) + { + // event selection + if (doTrigEvEff && !mcCollision.trigEv()) + return; + + for (auto const& mcParticle : mcParticles) { + // standard particles (marked physical primary) + if (checkPrimaryEtaMc(mcParticle)) { + // hadrons + if (checkChargedMc(mcParticle)) { + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcTrue_hadron"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcTrue_hadron"), mcParticle.pt(), mcCollision.posZ(), mcCollision.multMCNParticlesEta08()); + } + // pipm + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus) { + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcTrue_pipm"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcTrue_pipm"), mcParticle.pt(), mcCollision.posZ(), mcCollision.multMCNParticlesEta08()); + } + // photons + if (mcParticle.pdgCode() == PDG_t::kGamma) { + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcTrue_photon"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcTrue_photon"), mcParticle.pt(), mcCollision.posZ(), mcCollision.multMCNParticlesEta08()); + } + } + + // decaying particles (not marked physical primary) + if ((std::abs(mcParticle.eta()) < etaMax)) { + // pi0 + if (checkPi0ToGG(mcParticle)) { + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcTrue_pi0"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcTrue_pi0"), mcParticle.pt(), mcCollision.posZ(), mcCollision.multMCNParticlesEta08()); + } + } + } + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueEff, "process MC-true data (all collisions) to calculate efficiencies", false); + + void processMcRecoColEff(CorrMcDCollision const& collision, aod::JetMcCollisions const&, aod::JetTracksMCD const& tracks, + aod::Triggers const& triggers, aod::Hadrons const& hadrons, aod::Pipms const& pipms, + aod::PhotonPCMs const& photonPCMs, aod::PhotonPCMPairs const& photonPCMPairs, + aod::JetParticles const& mcParticles) + { + int excludeTriggerTrackId = -1; + int excludeTriggerParticleId = -1; + + // event selection + if (!collision.selEv()) + return; + if (doTrigEvEff && !collision.trigEv()) + return; + + auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.mcCollisionId()); + + // random trigger + if (doTrigEvEff) { + std::uniform_int_distribution intDistribution(0, static_cast(triggers.size()) - 1); + auto const& excludeTrigger = triggers.rawIteratorAt(intDistribution(randomEngine)); + if (excludeTrigger.jetTrack_as().has_mcParticle()) { + excludeTriggerParticleId = excludeTrigger.jetTrack_as().mcParticleId(); + excludeTriggerTrackId = excludeTrigger.jetTrack_as().globalIndex(); + } + } + + // hadrons + for (auto const& hadron : hadrons) { + if (doTrigEvEff && hadron.jetTrackId() == excludeTriggerTrackId) + continue; + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hadron"), hadron.pt(), hadron.phi(), hadron.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hadron"), hadron.pt(), collision.posZ(), collision.multNTracksGlobal()); + // purity + if (!hadron.jetTrack_as().has_mcParticle()) + continue; + auto const hadronParticle = hadron.jetTrack_as().mcParticle(); + if (!checkPrimaryTrackMc(hadronParticle)) + continue; + if (requireSingleCollisionPurity && hadronParticle.mcCollisionId() != collision.mcCollisionId()) + continue; + + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hasCorrectMc_hadron"), hadron.pt(), hadron.phi(), hadron.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hasCorrectMc_hadron"), hadron.pt(), collision.posZ(), collision.multNTracksGlobal()); + } + + // pipm + for (auto const& pipm : pipms) { + if (doTrigEvEff && pipm.jetTrackId() == excludeTriggerTrackId) + continue; + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_pipm"), pipm.pt(), pipm.phi(), pipm.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_pipm"), pipm.pt(), collision.posZ(), collision.multNTracksGlobal()); + // purity + if (!pipm.jetTrack_as().has_mcParticle()) + continue; + auto const pipmParticle = pipm.jetTrack_as().mcParticle(); + if (std::abs(pipmParticle.pdgCode()) != PDG_t::kPiPlus || !checkPrimaryEtaMc(pipmParticle)) + continue; + if (requireSingleCollisionPurity && pipmParticle.mcCollisionId() != collision.mcCollisionId()) + continue; + + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hasCorrectMc_pipm"), pipm.pt(), pipm.phi(), pipm.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hasCorrectMc_pipm"), pipm.pt(), collision.posZ(), collision.multNTracksGlobal()); + } + + // photon mc checks + + auto const isConversionPhoton = [&](auto const& posTrack, auto const& negTrack) { + // check same mother + auto const& posMothers = posTrack.mcParticle().template mothers_as(); + auto const& negMothers = negTrack.mcParticle().template mothers_as(); + if (posMothers.size() != 1 || negMothers.size() != 1) + return false; + if (posMothers.begin()->globalIndex() != negMothers.begin()->globalIndex()) + return false; + // check photon + if (posMothers.begin()->pdgCode() != PDG_t::kGamma) + return false; + + return true; + }; + auto const isGGFromPi0 = [&](auto const& posTrack1, auto const& negTrack1, auto const& posTrack2, auto const& negTrack2) { + if (!isConversionPhoton(posTrack1, negTrack1) || !isConversionPhoton(posTrack2, negTrack2)) + return false; + // check same mother + auto const& mothers1 = (*(posTrack1.mcParticle().template mothers_as().begin())).template mothers_as(); + auto const& mothers2 = (*(posTrack2.mcParticle().template mothers_as().begin())).template mothers_as(); + constexpr int NMothersPhotonFromPi0 = 2; // for some reason two mothers (same particle) for pi0 decays (contradicts PYTHIA documentation, but whatever) + if (mothers1.size() != NMothersPhotonFromPi0 || mothers2.size() != NMothersPhotonFromPi0) + return false; + if (mothers1.begin()->globalIndex() != mothers2.begin()->globalIndex()) + return false; + // check pi0 + if (mothers1.begin()->pdgCode() != PDG_t::kPi0) + return false; + + return true; + }; + + // photonPCM + for (auto const& photonPCM : photonPCMs) { + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_photonPCM"), photonPCM.pt(), photonPCM.phi(), photonPCM.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_photonPCM"), photonPCM.pt(), collision.posZ(), collision.multNTracksGlobal()); + + // purity + // (V0Legs does not have the tracks reference as index column (just int)??) + auto const& posTrack = tracks.rawIteratorAt(photonPCM.posTrackId() - tracks.offset()); + auto const& negTrack = tracks.rawIteratorAt(photonPCM.negTrackId() - tracks.offset()); + if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) + continue; + if (!isConversionPhoton(posTrack, negTrack) || !checkPrimaryEtaMc(*(posTrack.mcParticle().mothers_as().begin()))) + continue; + if (requireSingleCollisionPurity && posTrack.mcParticle().mcCollisionId() != collision.mcCollisionId()) + continue; + + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hasCorrectMc_photonPCM"), photonPCM.pt(), photonPCM.phi(), photonPCM.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hasCorrectMc_photonPCM"), photonPCM.pt(), collision.posZ(), collision.multNTracksGlobal()); + } + + // pi0PCM + for (auto const& photonPCMPair : photonPCMPairs) { + if (photonPCMPair.mgg() < pi0PCMMassRange.value[0] || photonPCMPair.mgg() > pi0PCMMassRange.value[1]) + continue; + + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_pi0PCM"), photonPCMPair.pt(), photonPCMPair.phi(), photonPCMPair.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_pi0PCM"), photonPCMPair.pt(), collision.posZ(), collision.multNTracksGlobal()); + + // purity + auto const& posTrack1 = tracks.rawIteratorAt(photonPCMPair.posTrack1Id() - tracks.offset()); + auto const& negTrack1 = tracks.rawIteratorAt(photonPCMPair.negTrack1Id() - tracks.offset()); + auto const& posTrack2 = tracks.rawIteratorAt(photonPCMPair.posTrack2Id() - tracks.offset()); + auto const& negTrack2 = tracks.rawIteratorAt(photonPCMPair.negTrack2Id() - tracks.offset()); + if (!posTrack1.has_mcParticle() || !negTrack1.has_mcParticle() || !posTrack2.has_mcParticle() || !negTrack2.has_mcParticle()) + continue; + if (!isGGFromPi0(posTrack1, negTrack1, posTrack2, negTrack2) || + std::abs((*(posTrack1.mcParticle().mothers_as().begin())).mothers_as().begin()->eta()) > etaMax) + continue; + if (requireSingleCollisionPurity && + (posTrack1.mcParticle().mcCollisionId() != collision.mcCollisionId() || posTrack2.mcParticle().mcCollisionId() != collision.mcCollisionId())) + continue; + + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hasCorrectMc_pi0PCM"), photonPCMPair.pt(), photonPCMPair.phi(), photonPCMPair.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hasCorrectMc_pi0PCM"), photonPCMPair.pt(), collision.posZ(), collision.multNTracksGlobal()); + } + + // mcParticle loop + for (auto const& mcParticle : mcParticlesThisEvent) { + // standard particles (marked physical primary) + if (checkPrimaryEtaMc(mcParticle)) { + // hadrons + if (checkChargedMc(mcParticle) && (!doTrigEvEff || mcParticle.globalIndex() != excludeTriggerParticleId)) { + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcTrue_recoCol_hadron"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcTrue_recoCol_hadron"), mcParticle.pt(), collision.mcCollision().posZ(), collision.multNTracksGlobal()); + } + // pipm + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus && (!doTrigEvEff || mcParticle.globalIndex() != excludeTriggerParticleId)) { + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcTrue_recoCol_pipm"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcTrue_recoCol_pipm"), mcParticle.pt(), collision.mcCollision().posZ(), collision.multNTracksGlobal()); + } + // photons + if (mcParticle.pdgCode() == PDG_t::kGamma) { + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcTrue_recoCol_photon"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcTrue_recoCol_photon"), mcParticle.pt(), collision.mcCollision().posZ(), collision.multNTracksGlobal()); + } + } + + // decaying particles (not marked physical primary) + if ((std::abs(mcParticle.eta()) < etaMax)) { + // pi0 + if (checkPi0ToGG(mcParticle)) { + histos.fill(HIST("mc/eff/h3_ptPhiEta_mcTrue_recoCol_pi0"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + histos.fill(HIST("mc/eff/h3_ptZPvMult_mcTrue_recoCol_pi0"), mcParticle.pt(), collision.mcCollision().posZ(), collision.multNTracksGlobal()); + } + } + } + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcRecoColEff, "process MC data to calculate efficiencies and purities", false); + + // test ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + void processTest(CorrCollision const& collision, + soa::Join const& tracks, soa::Join const&, + aod::Hadrons const& hadrons) + { + // event selection + if (!collision.selEv()) + return; + + histos.fill(HIST("test/h2_mult_comp"), collision.multNTracksGlobal(), hadrons.size()); + + for (auto const& track : tracks) { + auto const fullTrack = track.track_as>(); + + constexpr float Mincrossedrows = 40; + constexpr float Maxchi2tpc = 5.0; + constexpr float Maxchi2its = 6.0; + constexpr float MaxR = 83.1; + constexpr float MinPtTrackiu = 0.1; + + if (!fullTrack.hasITS() && !fullTrack.hasTPC()) + continue; + if (fullTrack.x() * fullTrack.x() + fullTrack.y() * fullTrack.y() > MaxR * MaxR || fullTrack.pt() < MinPtTrackiu) + continue; + if (fullTrack.hasTPC()) { + if (fullTrack.tpcNClsCrossedRows() < Mincrossedrows || fullTrack.tpcChi2NCl() > Maxchi2tpc) + continue; + } + if (fullTrack.hasITS()) { + if (fullTrack.itsChi2NCl() > Maxchi2its) + continue; + } + + histos.fill(HIST("test/h2_tracks_zPvMultDep"), collision.posZ(), collision.multNTracksGlobal()); + } + + histos.fill(HIST("test/h2_globalTracks_zPvMultDep"), collision.posZ(), collision.multNTracksGlobal(), hadrons.size()); + } + PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processTest, "process just to test things", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& configContext) +{ + return WorkflowSpec{ + adaptAnalysisTask(configContext), + adaptAnalysisTask(configContext)}; +} diff --git a/PWGJE/Tasks/photonIsolationQA.cxx b/PWGJE/Tasks/photonIsolationQA.cxx index 03b8e4f1fe6..1738fef952f 100644 --- a/PWGJE/Tasks/photonIsolationQA.cxx +++ b/PWGJE/Tasks/photonIsolationQA.cxx @@ -9,38 +9,37 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/HistogramRegistry.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/EMCALClusters.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" #include "EMCALBase/Geometry.h" #include "EMCALCalib/BadChannelMap.h" -#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include -#include "DataFormatsEMCAL/Cell.h" -#include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" -#include "CommonDataFormat/InteractionRecord.h" +#include // \struct PhotonIsolationQA /// \brief Task to select emcal clusters originating from promt photons @@ -101,11 +100,11 @@ struct PhotonIsolationQA { Preslice ClustersPerCol = aod::emcalcluster::collisionId; Preslice CellsPerCluster = aod::emcalclustercell::emcalclusterId; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; void init(o2::framework::InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); mGeometry = o2::emcal::Geometry::GetInstanceFromRunNumber(300000); diff --git a/PWGJE/Tasks/recoilJets.cxx b/PWGJE/Tasks/recoilJets.cxx index 4b2dd5589e9..8b6d2b952ea 100644 --- a/PWGJE/Tasks/recoilJets.cxx +++ b/PWGJE/Tasks/recoilJets.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// Copyright 2020-2022 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. // @@ -13,96 +13,132 @@ /// \file recoilJets.cxx /// \brief hadron-jet correlation analysis -#include -#include -#include +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" -#include "TRandom3.h" -#include "TVector2.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Multiplicity.h" +#include "CommonConstants/MathConstants.h" #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "CommonConstants/MathConstants.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/Core/RecoDecay.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/DataModel/Jet.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include +#include +#include -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "TRandom3.h" +#include +#include -#include "EventFiltering/filterTables.h" +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; // Shorthand notations -using FilteredColl = soa::Filtered>::iterator; -using FilteredCollPartLevel = soa::Filtered>::iterator; -using FilteredCollDetLevelGetWeight = soa::Filtered>::iterator; - -using FilteredJets = soa::Filtered>; -using FilteredJetsDetLevel = soa::Filtered>; -using FilteredJetsPartLevel = soa::Filtered>; - -using FilteredMatchedJetsDetLevel = soa::Filtered>; -using FilteredMatchedJetsPartLevel = soa::Filtered>; +using FilteredColl = + soa::Filtered>::iterator; +using FilteredCollPartLevel = + soa::Filtered>::iterator; +using FilteredCollDetLevelGetWeight = + soa::Filtered>::iterator; +using FilteredEventMultiplicity = + soa::Filtered>::iterator; + +using FilteredJets = + soa::Filtered>; +using FilteredJetsDetLevel = + soa::Filtered>; +using FilteredJetsPartLevel = + soa::Filtered>; + +using FilteredMatchedJetsDetLevel = soa::Filtered>; +using FilteredMatchedJetsPartLevel = soa::Filtered>; using FilteredTracks = soa::Filtered; +using FilteredParticles = soa::Filtered; struct RecoilJets { // List of configurable parameters Configurable evSel{"evSel", "sel8", "Choose event selection"}; - Configurable trkSel{"trkSel", "globalTracks", "Set track selection"}; + Configurable trkSel{"trkSel", "globalTracks", + "Set track selection"}; Configurable vertexZCut{"vertexZCut", 10., "Accepted z-vertex range"}; - Configurable fracSig{"fracSig", 0.9, "Fraction of events to use for signal TT"}; + Configurable fracSig{"fracSig", 0.9, + "Fraction of events to use for signal TT"}; - Configurable trkPtMin{"trkPtMin", 0.15, "Minimum pT of acceptanced tracks"}; - Configurable trkPtMax{"trkPtMax", 100., "Maximum pT of acceptanced tracks"}; - - Configurable trkPhiMin{"trkPhiMin", -7., "Minimum phi angle of acceptanced tracks"}; - Configurable trkPhiMax{"trkPhiMax", 7., "Maximum phi angle of acceptanced tracks"}; + Configurable trkPtMin{"trkPtMin", 0.15, + "Minimum pT of acceptanced tracks"}; + Configurable trkPtMax{"trkPtMax", 100., + "Maximum pT of acceptanced tracks"}; Configurable trkEtaCut{"trkEtaCut", 0.9, "Eta acceptance of TPC"}; Configurable jetR{"jetR", 0.4, "Jet cone radius"}; - Configurable triggerMasks{"triggerMasks", "", "Relevant trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt"}; + Configurable triggerMasks{"triggerMasks", "", + "Relevant trigger masks: fTrackLowPt,fTrackHighPt"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, + "flag to choose to reject min. bias gap events; jet-level rejection " + "applied at the jet finder level, here rejection is applied for " + "collision and track process functions"}; // List of configurable parameters for MC - Configurable pTHatExponent{"pTHatExponent", 4.0, "Exponent of the event weight for the calculation of pTHat"}; - Configurable pTHatMax{"pTHatMax", 999.0, "Maximum fraction of hard scattering for jet acceptance in MC"}; + Configurable pTHatExponent{"pTHatExponent", 4.0, + "Exponent of the event weight for the calculation of pTHat"}; + Configurable pTHatMax{"pTHatMax", 999.0, + "Maximum fraction of hard scattering for jet acceptance in MC"}; // Parameters for recoil jet selection - Configurable ptTTrefMin{"ptTTrefMin", 5., "Minimum pT of reference TT"}; - Configurable ptTTrefMax{"ptTTrefMax", 7., "Maximum pT of reference TT"}; + Configurable ptTTrefMin{"ptTTrefMin", 5., + "Minimum pT of reference TT"}; + Configurable ptTTrefMax{"ptTTrefMax", 7., + "Maximum pT of reference TT"}; Configurable ptTTsigMin{"ptTTsigMin", 20., "Minimum pT of signal TT"}; Configurable ptTTsigMax{"ptTTsigMax", 50., "Maximum pT of signal TT"}; - Configurable recoilRegion{"recoilRegion", 0.6, "Width of recoil acceptance"}; + Configurable recoilRegion{"recoilRegion", 0.6, + "Width of recoil acceptance"}; // List of configurable parameters for histograms - Configurable histJetPt{"histJetPt", 100, "Maximum value of jet pT shown in histograms"}; + Configurable histJetPt{"histJetPt", 100, + "Maximum value of jet pT shown in histograms"}; // Axes specification AxisSpec pT{histJetPt, 0.0, histJetPt * 1.0, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec jetPTcorr{histJetPt + 20, -20., histJetPt * 1.0, "#it{p}_{T, jet}^{ch, corr} (GeV/#it{c})"}; - AxisSpec phiAngle{40, 0.0, constants::math::TwoPI, "#varphi (rad)"}; - AxisSpec deltaPhiAngle{52, 0.0, constants::math::PI, "#Delta#varphi (rad)"}; - AxisSpec pseudorap{40, -1., 1., "#eta"}; - AxisSpec rhoArea{60, 0.0, 30., "#rho #times #A_{jet}"}; - - Preslice partJetsPerCollision = aod::jet::mcCollisionId; + AxisSpec jetPTcorr{histJetPt + 20, -20., histJetPt * 1.0, + "#it{p}_{T, jet}^{ch, corr} (GeV/#it{c})"}; + AxisSpec phiAngle{40, 0.0, constants::math::TwoPI, "#it{#varphi} (rad)"}; + AxisSpec deltaPhiAngle{52, 0.0, constants::math::PI, + "#Delta#it{#varphi} (rad)"}; + AxisSpec pseudorap{40, -1., 1., "#it{#eta}"}; + AxisSpec pseudorapJets{20, -0.5, 0.5, "#it{#eta}_{jet}"}; + AxisSpec jetArea{50, 0.0, 5., "Area_{jet}"}; + AxisSpec rhoArea{60, 0.0, 60., "#it{#rho} #times Area_{jet}"}; + AxisSpec rho{50, 0.0, 50., "#it{#rho}"}; + + Preslice partJetsPerCollision = + aod::jet::mcCollisionId; TRandom3* rand = new TRandom3(0); @@ -110,121 +146,319 @@ struct RecoilJets { Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; Filter collisionFilterMC = nabs(aod::jmccollision::posZ) < vertexZCut; - // Declare filters on accepted tracks - Filter trackFilter = aod::jtrack::pt > trkPtMin&& aod::jtrack::pt < trkPtMax&& nabs(aod::jtrack::eta) < trkEtaCut; + // Declare filters on accepted tracks and MC particles (settings for jet reco + // are provided in the jet finder wagon) + Filter trackFilter = aod::jtrack::pt > trkPtMin&& aod::jtrack::pt < + trkPtMax&& nabs(aod::jtrack::eta) < trkEtaCut; + Filter partFilter = nabs(aod::jmcparticle::eta) < trkEtaCut; // Declare filter on jets Filter jetRadiusFilter = aod::jet::r == nround(jetR.node() * 100.); HistogramRegistry spectra; - int eventSelection = -1; + std::vector eventSelectionBits; int trackSelection = -1; std::vector triggerMaskBits; + Service pdg; + void init(InitContext const&) { + std::string evSelToString = static_cast(evSel); + std::string trkSelToString = static_cast(trkSel); + + eventSelectionBits = + jetderiveddatautilities::initialiseEventSelectionBits(evSelToString); + trackSelection = + jetderiveddatautilities::initialiseTrackSelection(trkSelToString); + triggerMaskBits = + jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); + + // List of raw and MC det. distributions + if (doprocessData || doprocessMCDetLevel || doprocessMCDetLevelWeighted) { + spectra.add("hEventSelectionCount", "Count # of events in the analysis", + kTH1F, {{3, 0.0, 3.}}); + spectra.get(HIST("hEventSelectionCount")) + ->GetXaxis() + ->SetBinLabel(1, "Total # of events"); + spectra.get(HIST("hEventSelectionCount")) + ->GetXaxis() + ->SetBinLabel( + 2, Form("# of events after sel. %s", evSelToString.data())); + spectra.get(HIST("hEventSelectionCount")) + ->GetXaxis() + ->SetBinLabel(3, "# of events w. outlier"); + + spectra.add("vertexZ", "Z vertex of collisions", kTH1F, + {{60, -12., 12.}}); + spectra.add("hHasAssocMcCollision", + "Has det. level coll. associat. MC coll.", kTH1F, + {{2, 0.0, 2.}}); + spectra.get(HIST("hHasAssocMcCollision")) + ->GetXaxis() + ->SetBinLabel(1, "Yes"); + spectra.get(HIST("hHasAssocMcCollision")) + ->GetXaxis() + ->SetBinLabel(2, "No"); + + spectra.add("hTrackSelectionCount", "Count # of tracks in the analysis", + kTH1F, {{2, 0.0, 2.}}); + spectra.get(HIST("hTrackSelectionCount")) + ->GetXaxis() + ->SetBinLabel(1, "Total # of tracks"); + spectra.get(HIST("hTrackSelectionCount")) + ->GetXaxis() + ->SetBinLabel( + 2, Form("# of tracks after sel. %s", trkSelToString.data())); + + spectra.add("hTrackPtEtaPhi", "Charact. of tracks", kTH3F, + {pT, pseudorap, phiAngle}); + + spectra.add( + "hTTSig_pT", "pT spectrum of all found TT_{Sig} cand.", kTH1F, + {{40, 10., + 50.}}); // needed to distinguish merged data from diff. wagons + + spectra.add("hNtrig", "Total number of selected triggers per class", + kTH1F, {{2, 0.0, 2.}}); + spectra.get(HIST("hNtrig"))->GetXaxis()->SetBinLabel(1, "TT_{ref}"); + spectra.get(HIST("hNtrig"))->GetXaxis()->SetBinLabel(2, "TT_{sig}"); + + spectra.add("hTTRef_per_event", "Number of TT_{Ref} per event", kTH1F, + {{15, 0.5, 15.5}}); + spectra.add("hTTSig_per_event", "Number of TT_{Sig} per event", kTH1F, + {{10, 0.5, 10.5}}); + + spectra.add("hJetPtEtaPhiRhoArea", "Charact. of inclusive jets", + kTHnSparseF, {pT, pseudorapJets, phiAngle, rho, jetArea}); + + spectra.add("hDPhi_JetPt_Corr_TTRef", + "Events w. TT_{Ref}: #Delta#varphi & #it{p}_{T, jet}^{ch}", + kTH2F, {deltaPhiAngle, jetPTcorr}); + spectra.add("hDPhi_JetPt_Corr_TTSig", + "Events w. TT_{Sig}: #Delta#varphi & #it{p}_{T, jet}^{ch}", + kTH2F, {deltaPhiAngle, jetPTcorr}); + spectra.add("hDPhi_JetPt_TTRef", + "Events w. TT_{Ref}: #Delta#varphi & #it{p}_{T, jet}^{ch}", + kTH2F, {deltaPhiAngle, pT}); + spectra.add("hDPhi_JetPt_TTSig", + "Events w. TT_{Sig}: #Delta#varphi & #it{p}_{T, jet}^{ch}", + kTH2F, {deltaPhiAngle, pT}); + + spectra.add("hRecoil_JetPt_Corr_TTRef", + "Events w. TT_{Ref}: #it{p}_{T} of recoil jets", kTH1F, + {jetPTcorr}); + spectra.add("hRecoil_JetPt_Corr_TTSig", + "Events w. TT_{Sig}: #it{p}_{T} of recoil jets", kTH1F, + {jetPTcorr}); + spectra.add("hRecoil_JetPt_TTRef", + "Events w. TT_{Ref}: #it{p}_{T} of recoil jets", kTH1F, {pT}); + spectra.add("hRecoil_JetPt_TTSig", + "Events w. TT_{Sig}: #it{p}_{T} of recoil jets", kTH1F, {pT}); + + spectra.add("hJetArea_JetPt_Rho_TTRef", + "Events w. TT_{Ref}: A_{jet} & jet pT & #rho", kTH3F, + {jetArea, pT, rho}); + spectra.add("hJetArea_JetPt_Rho_TTSig", + "Events w. TT_{Sig}: A_{jet} & jet pT & #rho", kTH3F, + {jetArea, pT, rho}); + } - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(evSel)); - trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trkSel)); - triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); - - // List of raw distributions - spectra.add("vertexZ", "Z vertex of collisions", kTH1F, {{60, -12., 12.}}); - - spectra.add("hTrackPtEtaPhi", "Charact. of tracks", kTH3F, {pT, pseudorap, phiAngle}); - spectra.add("hNtrig", "Total number of selected triggers per class", kTH1F, {{2, 0.0, 2.}}); - spectra.get(HIST("hNtrig"))->GetXaxis()->SetBinLabel(1, "TT_{ref}"); - spectra.get(HIST("hNtrig"))->GetXaxis()->SetBinLabel(2, "TT_{sig}"); - - spectra.add("hTTRef_per_event", "Number of TT_{Ref} per event", kTH1F, {{10, 0.0, 10.}}); - spectra.add("hTTSig_per_event", "Number of TT_{Sig} per event", kTH1F, {{5, 0.0, 5.}}); - - spectra.add("hJetPtEtaPhiRhoArea", "Charact. of inclusive jets", kTHnSparseF, {pT, pseudorap, phiAngle, rhoArea}); - - spectra.add("hDPhi_JetPt_Corr_TTRef", "Events w. TT_{Ref}: #Delta#varphi & #it{p}_{T, jet}^{ch}", kTH2F, {deltaPhiAngle, jetPTcorr}); - spectra.add("hDPhi_JetPt_Corr_TTSig", "Events w. TT_{Sig}: #Delta#varphi & #it{p}_{T, jet}^{ch}", kTH2F, {deltaPhiAngle, jetPTcorr}); - spectra.add("hDPhi_JetPt_TTRef", "Events w. TT_{Ref}: #Delta#varphi & #it{p}_{T, jet}^{ch}", kTH2F, {deltaPhiAngle, pT}); - spectra.add("hDPhi_JetPt_TTSig", "Events w. TT_{Sig}: #Delta#varphi & #it{p}_{T, jet}^{ch}", kTH2F, {deltaPhiAngle, pT}); - - spectra.add("hRecoil_JetPt_Corr_TTRef", "Events w. TT_{Ref}: #it{p}_{T} of recoil jets", kTH1F, {jetPTcorr}); - spectra.add("hRecoil_JetPt_Corr_TTSig", "Events w. TT_{Sig}: #it{p}_{T} of recoil jets", kTH1F, {jetPTcorr}); - spectra.add("hRecoil_JetPt_TTRef", "Events w. TT_{Ref}: #it{p}_{T} of recoil jets", kTH1F, {pT}); - spectra.add("hRecoil_JetPt_TTSig", "Events w. TT_{Sig}: #it{p}_{T} of recoil jets", kTH1F, {pT}); + // List of MC particle level distributions + if (doprocessMCPartLevel || doprocessMCPartLevelWeighted) { + spectra.add("vertexZMC", "Z vertex of jmccollision", kTH1F, + {{60, -12., 12.}}); + spectra.add("ptHat", "Distribution of pT hat", kTH1F, {{500, 0.0, 100.}}); + + spectra.add("hEventSelectionCountPartLevel", + "Count # of events in the part. level analysis", kTH1F, + {{2, 0.0, 2.}}); + spectra.get(HIST("hEventSelectionCountPartLevel")) + ->GetXaxis() + ->SetBinLabel(1, "Total # of events"); + spectra.get(HIST("hEventSelectionCountPartLevel")) + ->GetXaxis() + ->SetBinLabel(2, "# of events w. outlier"); + + spectra.add("hCountNumberOutliersFrameWork", + "Count # of outlier events based on flag from JE fw", kTH1F, + {{1, 0.0, 1.}}); + spectra.get(HIST("hCountNumberOutliersFrameWork")) + ->GetXaxis() + ->SetBinLabel(1, "Oulier flag true"); + + spectra.add("hPartPtEtaPhi", "Charact. of particles", kTH3F, + {pT, pseudorap, phiAngle}); + spectra.add("hNtrig_Part", "Total number of selected triggers per class", + kTH1F, {{2, 0.0, 2.}}); + spectra.get(HIST("hNtrig_Part")) + ->GetXaxis() + ->SetBinLabel(1, "TT_{ref}"); + spectra.get(HIST("hNtrig_Part")) + ->GetXaxis() + ->SetBinLabel(2, "TT_{sig}"); + + spectra.add("hTTRef_per_event_Part", "Number of TT_{Ref} per event", + kTH1F, {{15, 0.5, 15.5}}); + spectra.add("hTTSig_per_event_Part", "Number of TT_{Sig} per event", + kTH1F, {{10, 0.5, 10.5}}); + + spectra.add("hJetPtEtaPhiRhoArea_Part", + "Charact. of inclusive part. level jets", kTHnSparseF, + {pT, pseudorapJets, phiAngle, rho, jetArea}); + + spectra.add("hDPhi_JetPt_Corr_TTRef_Part", + "Events w. TT_{Ref}: #Delta#varphi & #it{p}_{T, jet}^{ch}", + kTH2F, {deltaPhiAngle, jetPTcorr}); + spectra.add("hDPhi_JetPt_Corr_TTSig_Part", + "Events w. TT_{Sig}: #Delta#varphi & #it{p}_{T, jet}^{ch}", + kTH2F, {deltaPhiAngle, jetPTcorr}); + spectra.add("hDPhi_JetPt_TTRef_Part", + "Events w. TT_{Ref}: #Delta#varphi & #it{p}_{T, jet}^{ch}", + kTH2F, {deltaPhiAngle, pT}); + spectra.add("hDPhi_JetPt_TTSig_Part", + "Events w. TT_{Sig}: #Delta#varphi & #it{p}_{T, jet}^{ch}", + kTH2F, {deltaPhiAngle, pT}); + + spectra.add("hRecoil_JetPt_Corr_TTRef_Part", + "Events w. TT_{Ref}: #it{p}_{T} of recoil jets", kTH1F, + {jetPTcorr}); + spectra.add("hRecoil_JetPt_Corr_TTSig_Part", + "Events w. TT_{Sig}: #it{p}_{T} of recoil jets", kTH1F, + {jetPTcorr}); + spectra.add("hRecoil_JetPt_TTRef_Part", + "Events w. TT_{Ref}: #it{p}_{T} of recoil jets", kTH1F, {pT}); + spectra.add("hRecoil_JetPt_TTSig_Part", + "Events w. TT_{Sig}: #it{p}_{T} of recoil jets", kTH1F, {pT}); + + spectra.add("hJetArea_JetPt_Rho_TTRef_Part", + "Events w. TT_{Ref}: A_{jet} & jet pT & #rho", kTH3F, + {jetArea, pT, rho}); + spectra.add("hJetArea_JetPt_Rho_TTSig_Part", + "Events w. TT_{Sig}: A_{jet} & jet pT & #rho", kTH3F, + {jetArea, pT, rho}); + + spectra.add("hDiffInOutlierRemove", + "Difference between pT hat from code and fw", kTH1F, + {{502, -0.2, 50.}}); + } - spectra.add("hDPhi_JetPt_RhoArea_TTRef", "Events w. TT_{Ref}: #Delta#varphi & jet pT & #rho #times A_{jet}", kTH3F, {deltaPhiAngle, pT, rhoArea}); - spectra.add("hDPhi_JetPt_RhoArea_TTSig", "Events w. TT_{Sig}: #Delta#varphi & jet pT & #rho #times A_{jet}", kTH3F, {deltaPhiAngle, pT, rhoArea}); + // Jet matching: part. vs. det. + if (doprocessJetsMatched || doprocessJetsMatchedWeighted) { + spectra.add("hJetPt_DetLevel_vs_PartLevel", + "Correlation jet pT at det. vs. part. levels", kTH2F, + {{200, 0.0, 200.}, {200, 0.0, 200.}}); + // spectra.add("hJetPt_Corr_PartLevel_vs_DetLevel", "Correlation jet pT at + // part. vs. det. levels", kTH2F, {jetPTcorr, jetPTcorr}); + spectra.add("hJetPt_DetLevel_vs_PartLevel_RecoilJets", + "Correlation recoil jet pT at part. vs. det. levels", kTH2F, + {{200, 0.0, 200.}, {200, 0.0, 200.}}); + // spectra.add("hJetPt_Corr_PartLevel_vs_DetLevel_RecoilJets", + // "Correlation recoil jet pT at part. vs. det. levels", kTH2F, + // {jetPTcorr, jetPTcorr}); + + spectra.add("hMissedJets_pT", "Part. level jets w/o matched pair", kTH1F, + {{200, 0.0, 200.}}); + // spectra.add("hMissedJets_Corr_pT", "Part. level jets w/o matched pair", + // kTH1F, {jetPTcorr}); + spectra.add("hMissedJets_pT_RecoilJets", + "Part. level jets w/o matched pair", kTH1F, + {{200, 0.0, 200.}}); + // spectra.add("hMissedJets_Corr_pT_RecoilJets", "Part. level jets w/o + // matched pair", kTH1F, {jetPTcorr}); + spectra.add("hFakeJets_pT", "Det. level jets w/o matched pair", kTH1F, + {{200, 0.0, 200.}}); + // spectra.add("hFakeJets_Corr_pT", "Det. level jets w/o matched pair", + // kTH1F, {jetPTcorr}); + spectra.add("hFakeJets_pT_RecoilJets", "Det. level jets w/o matched pair", + kTH1F, {{200, 0.0, 200.}}); + // spectra.add("hFakeJets_Corr_pT_RecoilJets", "Det. level jets w/o + // matched pair", kTH1F, {jetPTcorr}); + + spectra.add( + "hJetPt_resolution", + "Jet p_{T} relative resolution as a func. of jet #it{p}_{T, part}", + kTH2F, {{100, -5., 5.}, pT}); + spectra.add( + "hJetPt_resolution_RecoilJets", + "Jet p_{T} relative resolution as a func. of jet #it{p}_{T, part}", + kTH2F, {{100, -5., 5.}, pT}); + + spectra.add("hJetPhi_resolution", + "#varphi resolution as a func. of jet #it{p}_{T, part}", + kTH2F, {{40, -1., 1.}, pT}); + spectra.add("hJetPhi_resolution_RecoilJets", + "#varphi resolution as a func. of jet #it{p}_{T, part}", + kTH2F, {{40, -1., 1.}, pT}); + + spectra.add("hNumberMatchedJetsPerOneBaseJet", + "# of taged jets per 1 base jet vs. jet pT", kTH2F, + {{10, 0.5, 10.5}, {100, 0.0, 100.}}); + } - // List of MC particle level distributions - spectra.add("hPartPtEtaPhi", "Charact. of particles", kTH3F, {pT, pseudorap, phiAngle}); - spectra.add("hNtrig_Part", "Total number of selected triggers per class", kTH1F, {{2, 0.0, 2.}}); - spectra.add("hTTRef_per_event_Part", "Number of TT_{Ref} per event", kTH1F, {{10, 0.0, 10.}}); - spectra.add("hTTSig_per_event_Part", "Number of TT_{Sig} per event", kTH1F, {{5, 0.0, 5.}}); - - spectra.add("hJetPtEtaPhiRhoArea_Part", "Charact. of inclusive part. level jets", kTHnSparseF, {pT, pseudorap, phiAngle, rhoArea}); - - spectra.add("hDPhi_JetPt_Corr_TTRef_Part", "Events w. TT_{Ref}: #Delta#varphi & #it{p}_{T, jet}^{ch}", kTH2F, {deltaPhiAngle, jetPTcorr}); - spectra.add("hDPhi_JetPt_Corr_TTSig_Part", "Events w. TT_{Sig}: #Delta#varphi & #it{p}_{T, jet}^{ch}", kTH2F, {deltaPhiAngle, jetPTcorr}); - spectra.add("hDPhi_JetPt_TTRef_Part", "Events w. TT_{Ref}: #Delta#varphi & #it{p}_{T, jet}^{ch}", kTH2F, {deltaPhiAngle, pT}); - spectra.add("hDPhi_JetPt_TTSig_Part", "Events w. TT_{Sig}: #Delta#varphi & #it{p}_{T, jet}^{ch}", kTH2F, {deltaPhiAngle, pT}); - - spectra.add("hRecoil_JetPt_Corr_TTRef_Part", "Events w. TT_{Ref}: #it{p}_{T} of recoil jets", kTH1F, {jetPTcorr}); - spectra.add("hRecoil_JetPt_Corr_TTSig_Part", "Events w. TT_{Sig}: #it{p}_{T} of recoil jets", kTH1F, {jetPTcorr}); - spectra.add("hRecoil_JetPt_TTRef_Part", "Events w. TT_{Ref}: #it{p}_{T} of recoil jets", kTH1F, {pT}); - spectra.add("hRecoil_JetPt_TTSig_Part", "Events w. TT_{Sig}: #it{p}_{T} of recoil jets", kTH1F, {pT}); - - spectra.add("hDPhi_JetPt_RhoArea_TTRef_Part", "Events w. TT_{Ref}: #Delta#varphi & jet pT & #rho #times A_{jet}", kTH3F, {deltaPhiAngle, pT, rhoArea}); - spectra.add("hDPhi_JetPt_RhoArea_TTSig_Part", "Events w. TT_{Sig}: #Delta#varphi & jet pT & #rho #times A_{jet}", kTH3F, {deltaPhiAngle, pT, rhoArea}); - - // Response matrices, jet pT & jet phi resolution - spectra.add("hJetPt_PartLevel_vs_DetLevel", "Correlation jet pT at part. vs. det. levels", kTH2F, {pT, pT}); - // spectra.add("hJetPt_Corr_PartLevel_vs_DetLevel", "Correlation jet pT at part. vs. det. levels", kTH2F, {jetPTcorr, jetPTcorr}); - spectra.add("hJetPt_PartLevel_vs_DetLevel_RecoilJets", "Correlation recoil jet pT at part. vs. det. levels", kTH2F, {pT, pT}); - // spectra.add("hJetPt_Corr_PartLevel_vs_DetLevel_RecoilJets", "Correlation recoil jet pT at part. vs. det. levels", kTH2F, {jetPTcorr, jetPTcorr}); - - spectra.add("hMissedJets_pT", "Part. level jets w/o matched pair", kTH1F, {pT}); - // spectra.add("hMissedJets_Corr_pT", "Part. level jets w/o matched pair", kTH1F, {jetPTcorr}); - spectra.add("hMissedJets_pT_RecoilJets", "Part. level jets w/o matched pair", kTH1F, {pT}); - // spectra.add("hMissedJets_Corr_pT_RecoilJets", "Part. level jets w/o matched pair", kTH1F, {jetPTcorr}); - - spectra.add("hFakeJets_pT", "Det. level jets w/o matched pair", kTH1F, {pT}); - // spectra.add("hFakeJets_Corr_pT", "Det. level jets w/o matched pair", kTH1F, {jetPTcorr}); - spectra.add("hFakeJets_pT_RecoilJets", "Det. level jets w/o matched pair", kTH1F, {pT}); - // spectra.add("hFakeJets_Corr_pT_RecoilJets", "Det. level jets w/o matched pair", kTH1F, {jetPTcorr}); - - spectra.add("hJetPt_resolution", "Jet p_{T} relative resolution as a func. of jet #it{p}_{T, part}", kTH2F, {{60, -1., 2.}, pT}); - spectra.add("hJetPt_resolution_RecoilJets", "Jet p_{T} relative resolution as a func. of jet #it{p}_{T, part}", kTH2F, {{60, -1., 2.}, pT}); - - spectra.add("hJetPhi_resolution", "#varphi resolution as a func. of jet #it{p}_{T, part}", kTH2F, {{40, -1., 1.}, pT}); - spectra.add("hJetPhi_resolution_RecoilJets", "#varphi resolution as a func. of jet #it{p}_{T, part}", kTH2F, {{40, -1., 1.}, pT}); + if (doprocessMultiplicity) { + spectra.add("hMultFT0A", "Mult. signal from FTOA", kTH1F, + {{1500, 0.0, 30000.}}); + spectra.add("hMultFT0C", "Mult. signal from FTOC", kTH1F, + {{1500, 0.0, 30000.}}); + spectra.add("hMultFT0M", "Total mult. signal from FT0A & FTOC", kTH1F, + {{3000, 0.0, 60000.}}); + + spectra.add("hMultZNA", "Mult. signal from ZDC A-side", kTH1F, + {{500, 0.0, 10000.}}); + spectra.add("hMultZNC", "Mult. signal from ZDC C-side", kTH1F, + {{500, 0.0, 10000.}}); + spectra.add("hMultZNM", "Total mult. signal from ZDCs", kTH1F, + {{1000, 0.0, 20000.}}); + + // Correlations + spectra.add("hMultFT0A_vs_ZNA", "Correlation of signals FTOA vs ZNA", + kTH2F, {{1500, 0.0, 30000.}, {500, 0.0, 10000.}}); + spectra.add("hMultFT0C_vs_ZNC", "Correlation of signals FTOC vs ZNC", + kTH2F, {{1500, 0.0, 30000.}, {500, 0.0, 10000.}}); + spectra.add("hMultFT0M_vs_ZNM", "Correlation of signals FTOM vs ZNM", + kTH2F, {{3000, 0.0, 60000.}, {1000, 0.0, 20000.}}); + } } // Fill histograms with raw or MC det. level data template - void fillHistograms(Collision const& collision, Jets const& jets, Tracks const& tracks, bool bIsMC = false, float weight = 1.) + void fillHistograms(Collision const& collision, Jets const& jets, + Tracks const& tracks, float weight = 1.) { - bool bSigEv = false; std::vector vPhiOfTT; double phiTT = 0.; int nTT = 0; - float pTHat = 0.; - if (bIsMC) - pTHat = getPtHat(weight); + float pTHat = getPtHat(weight); auto dice = rand->Rndm(); if (dice < fracSig) bSigEv = true; + // Remove whole event if jet passes the outlier removal condition + for (const auto& jet : jets) { + if (jet.pt() > pTHatMax * pTHat) { + spectra.fill(HIST("hEventSelectionCount"), 2.5); + return; + } + } + for (const auto& track : tracks) { - if (!jetderiveddatautilities::selectTrack(track, trackSelection)) + spectra.fill(HIST("hTrackSelectionCount"), 0.5); + + if (skipTrack(track)) continue; - spectra.fill(HIST("hTrackPtEtaPhi"), track.pt(), track.eta(), track.phi(), weight); + spectra.fill(HIST("hTrackSelectionCount"), 1.5); + spectra.fill(HIST("hTrackPtEtaPhi"), track.pt(), track.eta(), track.phi(), + weight); // Search for TT candidate if (bSigEv && (track.pt() > ptTTsigMin && track.pt() < ptTTsigMax)) { vPhiOfTT.push_back(track.phi()); + spectra.fill(HIST("hTTSig_pT"), track.pt(), weight); ++nTT; } @@ -248,33 +482,36 @@ struct RecoilJets { } for (const auto& jet : jets) { - - if (bIsMC && (jet.pt() > pTHatMax * pTHat)) - continue; - - spectra.fill(HIST("hJetPtEtaPhiRhoArea"), jet.pt(), jet.eta(), jet.phi(), collision.rho() * jet.area(), weight); + spectra.fill(HIST("hJetPtEtaPhiRhoArea"), jet.pt(), jet.eta(), jet.phi(), + collision.rho(), jet.area(), weight); if (nTT > 0) { - auto [dphi, bRecoil] = isRecoilJet(jet, phiTT); + auto [dphi, bRecoilJet] = isRecoilJet(jet, phiTT); if (bSigEv) { - spectra.fill(HIST("hDPhi_JetPt_Corr_TTSig"), dphi, jet.pt() - collision.rho() * jet.area(), weight); + spectra.fill(HIST("hDPhi_JetPt_Corr_TTSig"), dphi, + jet.pt() - collision.rho() * jet.area(), weight); spectra.fill(HIST("hDPhi_JetPt_TTSig"), dphi, jet.pt(), weight); - spectra.fill(HIST("hDPhi_JetPt_RhoArea_TTSig"), dphi, jet.pt(), collision.rho() * jet.area(), weight); + spectra.fill(HIST("hJetArea_JetPt_Rho_TTSig"), jet.area(), jet.pt(), + collision.rho(), weight); - if (bRecoil) { - spectra.fill(HIST("hRecoil_JetPt_Corr_TTSig"), jet.pt() - collision.rho() * jet.area(), weight); + if (bRecoilJet) { + spectra.fill(HIST("hRecoil_JetPt_Corr_TTSig"), + jet.pt() - collision.rho() * jet.area(), weight); spectra.fill(HIST("hRecoil_JetPt_TTSig"), jet.pt(), weight); } } else { - spectra.fill(HIST("hDPhi_JetPt_Corr_TTRef"), dphi, jet.pt() - collision.rho() * jet.area(), weight); + spectra.fill(HIST("hDPhi_JetPt_Corr_TTRef"), dphi, + jet.pt() - collision.rho() * jet.area(), weight); spectra.fill(HIST("hDPhi_JetPt_TTRef"), dphi, jet.pt(), weight); - spectra.fill(HIST("hDPhi_JetPt_RhoArea_TTRef"), dphi, jet.pt(), collision.rho() * jet.area(), weight); + spectra.fill(HIST("hJetArea_JetPt_Rho_TTRef"), jet.area(), jet.pt(), + collision.rho(), weight); - if (bRecoil) { - spectra.fill(HIST("hRecoil_JetPt_Corr_TTRef"), jet.pt() - collision.rho() * jet.area(), weight); + if (bRecoilJet) { + spectra.fill(HIST("hRecoil_JetPt_Corr_TTRef"), + jet.pt() - collision.rho() * jet.area(), weight); spectra.fill(HIST("hRecoil_JetPt_TTRef"), jet.pt(), weight); } } @@ -283,33 +520,48 @@ struct RecoilJets { } template - void fillMCPHistograms(Collision const& collision, Jets const& jets, Particles const& particles, float weight = 1.) + void fillMCPHistograms(Collision const& collision, Jets const& jets, + Particles const& particles, float weight = 1.) { bool bSigEv = false; std::vector vPhiOfTT; double phiTT = 0.; int nTT = 0; float pTHat = getPtHat(weight); + spectra.fill(HIST("ptHat"), pTHat, weight); auto dice = rand->Rndm(); if (dice < fracSig) bSigEv = true; + for (const auto& jet : jets) { + if (jet.pt() > pTHatMax * pTHat) { + spectra.fill(HIST("hEventSelectionCountPartLevel"), 1.5); + return; + } + } + for (const auto& particle : particles) { + auto pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (!pdgParticle) + continue; - // Need charge and primary particles - bool bParticleNeutral = (static_cast(particle.e()) == 0); - if (bParticleNeutral || (!particle.isPhysicalPrimary())) + // Need charge and physical primary particles + bool bParticleNeutral = (static_cast(pdgParticle->Charge()) == 0); + if (bParticleNeutral || !particle.isPhysicalPrimary()) continue; - spectra.fill(HIST("hPartPtEtaPhi"), particle.pt(), particle.eta(), particle.phi(), weight); + spectra.fill(HIST("hPartPtEtaPhi"), particle.pt(), particle.eta(), + particle.phi(), weight); - if (bSigEv && (particle.pt() > ptTTsigMin && particle.pt() < ptTTsigMax)) { + if (bSigEv && + (particle.pt() > ptTTsigMin && particle.pt() < ptTTsigMax)) { vPhiOfTT.push_back(particle.phi()); ++nTT; } - if (!bSigEv && (particle.pt() > ptTTrefMin && particle.pt() < ptTTrefMax)) { + if (!bSigEv && + (particle.pt() > ptTTrefMin && particle.pt() < ptTTrefMax)) { vPhiOfTT.push_back(particle.phi()); ++nTT; } @@ -329,35 +581,38 @@ struct RecoilJets { } for (const auto& jet : jets) { - - if (jet.pt() > pTHatMax * pTHat) - continue; - - spectra.fill(HIST("hJetPtEtaPhiRhoArea_Part"), jet.pt(), jet.eta(), jet.phi(), collision.rho() * jet.area(), weight); + spectra.fill(HIST("hJetPtEtaPhiRhoArea_Part"), jet.pt(), jet.eta(), + jet.phi(), collision.rho(), jet.area(), weight); if (nTT > 0) { - auto [dphi, bRecoil] = isRecoilJet(jet, phiTT); + auto [dphi, bRecoilJet] = isRecoilJet(jet, phiTT); if (bSigEv) { - spectra.fill(HIST("hDPhi_JetPt_Corr_TTSig_Part"), dphi, jet.pt() - collision.rho() * jet.area(), weight); + spectra.fill(HIST("hDPhi_JetPt_Corr_TTSig_Part"), dphi, + jet.pt() - collision.rho() * jet.area(), weight); spectra.fill(HIST("hDPhi_JetPt_TTSig_Part"), dphi, jet.pt(), weight); - spectra.fill(HIST("hDPhi_JetPt_RhoArea_TTSig_Part"), dphi, jet.pt(), collision.rho() * jet.area(), weight); + spectra.fill(HIST("hJetArea_JetPt_Rho_TTSig_Part"), jet.area(), + jet.pt(), collision.rho(), weight); - if (bRecoil) { - spectra.fill(HIST("hRecoil_JetPt_Corr_TTSig_Part"), jet.pt() - collision.rho() * jet.area(), weight); + if (bRecoilJet) { + spectra.fill(HIST("hRecoil_JetPt_Corr_TTSig_Part"), + jet.pt() - collision.rho() * jet.area(), weight); spectra.fill(HIST("hRecoil_JetPt_TTSig_Part"), jet.pt(), weight); } } else { - spectra.fill(HIST("hDPhi_JetPt_Corr_TTRef_Part"), dphi, jet.pt() - collision.rho() * jet.area(), weight); + spectra.fill(HIST("hDPhi_JetPt_Corr_TTRef_Part"), dphi, + jet.pt() - collision.rho() * jet.area(), weight); spectra.fill(HIST("hDPhi_JetPt_TTRef_Part"), dphi, jet.pt(), weight); - spectra.fill(HIST("hDPhi_JetPt_RhoArea_TTRef_Part"), dphi, jet.pt(), collision.rho() * jet.area(), weight); + spectra.fill(HIST("hJetArea_JetPt_Rho_TTRef_Part"), jet.area(), + jet.pt(), collision.rho(), weight); - if (bRecoil) { - spectra.fill(HIST("hRecoil_JetPt_Corr_TTRef_Part"), jet.pt() - collision.rho() * jet.area(), weight); + if (bRecoilJet) { + spectra.fill(HIST("hRecoil_JetPt_Corr_TTRef_Part"), + jet.pt() - collision.rho() * jet.area(), weight); spectra.fill(HIST("hRecoil_JetPt_TTRef_Part"), jet.pt(), weight); } } @@ -365,16 +620,22 @@ struct RecoilJets { } } - /// TODO: Add functionality to get rho for particle and detector level - template - void fillMatchedHistograms(Tracks const& tracks, DetLevelJets const& jets_det_level, PartLevelJets const& jets_part_level, float weight = 1.) + template + void fillMatchedHistograms(TracksTable const& tracks, + JetsBase const& jetsBase, JetsTag const& jetsTag, + float weight = 1.) { std::vector vPhiOfTT; - double phiTT = 0.; + double phiTTSig = 0.; float pTHat = getPtHat(weight); + for (const auto& jetBase : jetsBase) { + if (jetBase.pt() > pTHatMax * pTHat) + return; + } + for (const auto& track : tracks) { - if (!jetderiveddatautilities::selectTrack(track, trackSelection)) + if (skipTrack(track)) continue; if (track.pt() > ptTTsigMin && track.pt() < ptTTsigMax) { @@ -382,113 +643,136 @@ struct RecoilJets { } } - bool bTT = vPhiOfTT.size() > 0; - if (bTT) - phiTT = getPhiTT(vPhiOfTT); - - for (const auto& jet_det_level : jets_det_level) { - if (jet_det_level.pt() > pTHatMax * pTHat) - continue; - - bool bRecoil = get<1>(isRecoilJet(jet_det_level, phiTT)) && bTT; - - if (jet_det_level.has_matchedJetGeo()) { + bool bIsThereTTSig = vPhiOfTT.size() > 0; - const auto jetsMatchedPartLevel = jet_det_level.template matchedJetGeo_as>(); // we can add "matchedJetPt_as" later + if (bIsThereTTSig) + phiTTSig = getPhiTT(vPhiOfTT); - for (const auto& jet_matched_part_level : jetsMatchedPartLevel) { - - /* - Which histos we want: - 1) det pT vs. part. pT for inclusive jets (corrected for rho*A and not) - 2) det pT vs. part. pT for recoil jets - 3) same as (1) and (2) but 4D with dphi parts - 4) distribution of fake and miss jets - 5) pT and phi resolutions - */ - - spectra.fill(HIST("hJetPt_PartLevel_vs_DetLevel"), jet_det_level.pt(), jet_matched_part_level.pt(), weight); - spectra.fill(HIST("hJetPt_resolution"), (jet_matched_part_level.pt() - jet_det_level.pt()) / jet_matched_part_level.pt(), jet_matched_part_level.pt(), weight); - spectra.fill(HIST("hJetPhi_resolution"), jet_matched_part_level.phi() - jet_det_level.phi(), jet_matched_part_level.pt(), weight); - - if (bRecoil) { - spectra.fill(HIST("hJetPt_PartLevel_vs_DetLevel_RecoilJets"), jet_det_level.pt(), jet_matched_part_level.pt(), weight); - spectra.fill(HIST("hJetPt_resolution_RecoilJets"), (jet_matched_part_level.pt() - jet_det_level.pt()) / jet_matched_part_level.pt(), jet_matched_part_level.pt(), weight); - spectra.fill(HIST("hJetPhi_resolution_RecoilJets"), jet_matched_part_level.phi() - jet_det_level.phi(), jet_matched_part_level.pt(), weight); - } - } - } else { - spectra.fill(HIST("hFakeJets_pT"), jet_det_level.pt(), weight); - if (bRecoil) - spectra.fill(HIST("hFakeJets_pT_RecoilJets"), jet_det_level.pt(), weight); - } + for (const auto& jetBase : jetsBase) { + bool bIsBaseJetRecoil = + get<1>(isRecoilJet(jetBase, phiTTSig)) && bIsThereTTSig; + dataForUnfolding(jetBase, jetsTag, bIsBaseJetRecoil, weight); } + } - // Missed jets - for (const auto& jet_part_level : jets_part_level) { - if (!jet_part_level.has_matchedJetGeo()) { - spectra.fill(HIST("hMissedJets_pT"), jet_part_level.pt(), weight); - } - } + template + void fillMultiplicityHistograms(Collision const& collision, + float weight = 1.0) + { + + spectra.fill(HIST("hMultFT0A"), collision.multFT0A(), weight); + spectra.fill(HIST("hMultFT0C"), collision.multFT0C(), weight); + spectra.fill(HIST("hMultFT0M"), collision.multFT0M(), weight); + + spectra.fill(HIST("hMultZNA"), collision.multZNA(), weight); + spectra.fill(HIST("hMultZNC"), collision.multZNC(), weight); + spectra.fill(HIST("hMultZNM"), collision.multZNA() + collision.multZNC(), + weight); + + // Correlations + spectra.fill(HIST("hMultFT0A_vs_ZNA"), collision.multFT0A(), + collision.multZNA(), weight); + spectra.fill(HIST("hMultFT0C_vs_ZNC"), collision.multFT0C(), + collision.multZNC(), weight); + spectra.fill(HIST("hMultFT0M_vs_ZNM"), collision.multFT0M(), + collision.multZNA() + collision.multZNC(), weight); } - void processData(FilteredColl const& collision, - FilteredTracks const& tracks, + //------------------------------------------------------------------------------ + // Process functions + void processData(FilteredColl const& collision, FilteredTracks const& tracks, FilteredJets const& jets) { + spectra.fill(HIST("hEventSelectionCount"), 0.5); + if (skipEvent(collision)) return; + spectra.fill(HIST("hEventSelectionCount"), 1.5); + spectra.fill(HIST("vertexZ"), collision.posZ()); fillHistograms(collision, jets, tracks); } PROCESS_SWITCH(RecoilJets, processData, "process data", true); void processMCDetLevel(FilteredColl const& collision, - FilteredJetsDetLevel const& jets, - FilteredTracks const& tracks) + FilteredTracks const& tracks, + FilteredJetsDetLevel const& jets) { - if (skipEvent(collision)) + spectra.fill(HIST("hEventSelectionCount"), 0.5); + if (skipEvent(collision) || skipMBGapEvent(collision)) return; + spectra.fill(HIST("hEventSelectionCount"), 1.5); + spectra.fill(HIST("vertexZ"), collision.posZ()); - fillHistograms(collision, jets, tracks, true); + fillHistograms(collision, jets, tracks); } - PROCESS_SWITCH(RecoilJets, processMCDetLevel, "process MC detector level", false); + PROCESS_SWITCH(RecoilJets, processMCDetLevel, "process MC detector level", + false); void processMCDetLevelWeighted(FilteredCollDetLevelGetWeight const& collision, aod::JetMcCollisions const&, - FilteredJetsDetLevel const& jets, - FilteredTracks const& tracks) + FilteredTracks const& tracks, + FilteredJetsDetLevel const& jets) { - if (skipEvent(collision)) + spectra.fill(HIST("hEventSelectionCount"), 0.5); + if (skipEvent(collision) || skipMBGapEvent(collision)) return; - /// \TODO: should we implement function to check whether Collision was reconstructed (has_mcCollision() function)? Example: https://github.com/AliceO2Group/O2Physics/blob/1cba330514ab47c15c0095d8cee9633723d8e2a7/PWGJE/Tasks/v0qa.cxx#L166? - auto weight = collision.mcCollision().weight(); // "mcCollision" where is defined? + spectra.fill(HIST("hEventSelectionCount"), 1.5); + + auto weight = collision.mcCollision().weight(); spectra.fill(HIST("vertexZ"), collision.posZ(), weight); - fillHistograms(collision, jets, tracks, true, weight); + + if (collision.has_mcCollision()) { + spectra.fill(HIST("hHasAssocMcCollision"), 0.5, weight); + } else { + spectra.fill(HIST("hHasAssocMcCollision"), 1.5, weight); + } + + fillHistograms(collision, jets, tracks, weight); } - PROCESS_SWITCH(RecoilJets, processMCDetLevelWeighted, "process MC detector level with event weight", false); + PROCESS_SWITCH(RecoilJets, processMCDetLevelWeighted, + "process MC detector level with event weight", false); void processMCPartLevel(FilteredCollPartLevel const& collision, - FilteredJetsPartLevel const& jets, - aod::JetParticles const& particles) + FilteredParticles const& particles, + FilteredJetsPartLevel const& jets) { - spectra.fill(HIST("vertexZ"), collision.posZ()); + spectra.fill(HIST("hEventSelectionCountPartLevel"), 0.5); + if (skipMBGapEvent(collision)) + return; + + spectra.fill(HIST("vertexZMC"), collision.posZ()); fillMCPHistograms(collision, jets, particles); } - PROCESS_SWITCH(RecoilJets, processMCPartLevel, "process MC particle level", false); + PROCESS_SWITCH(RecoilJets, processMCPartLevel, "process MC particle level", + false); void processMCPartLevelWeighted(FilteredCollPartLevel const& collision, - FilteredJetsPartLevel const& jets, - aod::JetParticles const& particles) + FilteredParticles const& particles, + FilteredJetsPartLevel const& jets) { + spectra.fill(HIST("hEventSelectionCountPartLevel"), 0.5); + if (skipMBGapEvent(collision)) + return; + auto weight = collision.weight(); - spectra.fill(HIST("vertexZ"), collision.posZ(), weight); + + auto calcPtHat = getPtHat(weight); + auto pThatFromFW = collision.ptHard(); + spectra.fill(HIST("hDiffInOutlierRemove"), calcPtHat - pThatFromFW); + if (collision.isOutlier()) + spectra.fill(HIST("hCountNumberOutliersFrameWork"), 0.5); + + // LOG(debug) << "Difference between pT hat: " << calcPtHat - pThatFromFW; + + spectra.fill(HIST("vertexZMC"), collision.posZ(), weight); fillMCPHistograms(collision, jets, particles, weight); } - PROCESS_SWITCH(RecoilJets, processMCPartLevelWeighted, "process MC particle level with event weight", false); + PROCESS_SWITCH(RecoilJets, processMCPartLevelWeighted, + "process MC particle level with event weight", false); void processJetsMatched(FilteredCollDetLevelGetWeight const& collision, aod::JetMcCollisions const&, @@ -496,28 +780,45 @@ struct RecoilJets { FilteredMatchedJetsDetLevel const& mcdjets, FilteredMatchedJetsPartLevel const& mcpjets) { - if (skipEvent(collision)) + if (skipEvent(collision) || skipMBGapEvent(collision)) return; - auto mcpjetsPerMCCollision = mcpjets.sliceBy(partJetsPerCollision, collision.mcCollisionId()); - fillMatchedHistograms(tracks, mcdjets, mcpjetsPerMCCollision); - } - PROCESS_SWITCH(RecoilJets, processJetsMatched, "process matching of MC jets (no weight)", false); - void processJetsMatchedWeighted(FilteredCollDetLevelGetWeight const& collision, - aod::JetMcCollisions const&, - FilteredTracks const& tracks, - FilteredMatchedJetsDetLevel const& mcdjets, - FilteredMatchedJetsPartLevel const& mcpjets) + auto mcpjetsPerMCCollision = + mcpjets.sliceBy(partJetsPerCollision, collision.mcCollisionId()); + + fillMatchedHistograms(tracks, mcpjetsPerMCCollision, mcdjets); + } + PROCESS_SWITCH(RecoilJets, processJetsMatched, + "process matching of MC jets (no weight)", false); + + void + processJetsMatchedWeighted(FilteredCollDetLevelGetWeight const& collision, + aod::JetMcCollisions const&, + FilteredTracks const& tracks, + FilteredMatchedJetsDetLevel const& mcdjets, + FilteredMatchedJetsPartLevel const& mcpjets) { - if (skipEvent(collision)) + if (skipEvent(collision) || skipMBGapEvent(collision)) return; - auto mcpjetsPerMCCollision = mcpjets.sliceBy(partJetsPerCollision, collision.mcCollisionId()); + auto mcpjetsPerMCCollision = + mcpjets.sliceBy(partJetsPerCollision, collision.mcCollisionId()); auto weight = collision.mcCollision().weight(); - fillMatchedHistograms(tracks, mcdjets, mcpjetsPerMCCollision, weight); + fillMatchedHistograms(tracks, mcpjetsPerMCCollision, mcdjets, weight); } - PROCESS_SWITCH(RecoilJets, processJetsMatchedWeighted, "process matching of MC jets (weighted)", false); + PROCESS_SWITCH(RecoilJets, processJetsMatchedWeighted, + "process matching of MC jets (weighted)", false); + + void processMultiplicity(FilteredEventMultiplicity const& collision) + { + if (skipEvent(collision)) + return; + + fillMultiplicityHistograms(collision); + } + PROCESS_SWITCH(RecoilJets, processMultiplicity, "process multiplicity", + false); //------------------------------------------------------------------------------ // Auxiliary functions @@ -525,14 +826,30 @@ struct RecoilJets { bool skipEvent(const Collision& coll) { /// \brief: trigger cut is needed for pp data - return !jetderiveddatautilities::selectCollision(coll, eventSelection) || !jetderiveddatautilities::selectTrigger(coll, triggerMaskBits); + return !jetderiveddatautilities::selectCollision(coll, + eventSelectionBits) || + !jetderiveddatautilities::selectTrigger(coll, triggerMaskBits); + } + + template + bool skipMBGapEvent(const Collision& coll) + { + return skipMBGapEvents && + coll.subGeneratorId() == + jetderiveddatautilities::JCollisionSubGeneratorId::mbGap; + } + + template + bool skipTrack(const Track& track) + { + return !jetderiveddatautilities::selectTrack(track, trackSelection); } template - std::tuple isRecoilJet(const Jet& jet, - double phiTT) + std::tuple isRecoilJet(const Jet& jet, double phiTT) { - double dphi = std::fabs(RecoDecay::constrainAngle(jet.phi() - phiTT, -constants::math::PI)); + double dphi = std::fabs( + RecoDecay::constrainAngle(jet.phi() - phiTT, -constants::math::PI)); return {dphi, (constants::math::PI - recoilRegion) < dphi}; } @@ -546,6 +863,59 @@ struct RecoilJets { { return 10. / (std::pow(weight, 1.0 / pTHatExponent)); } + + template + void dataForUnfolding(PartJet const& partJet, DetJet const& detJets, + bool bIsBaseJetRecoil, float weight = 1.0) + { + + bool bIsThereMatchedJet = partJet.has_matchedJetGeo(); + + if (bIsThereMatchedJet) { + const auto& jetsMatched = + partJet.template matchedJetGeo_as>(); + + for (const auto& jetMatched : jetsMatched) { + spectra.fill(HIST("hNumberMatchedJetsPerOneBaseJet"), + jetsMatched.size(), jetMatched.pt(), weight); + spectra.fill(HIST("hJetPt_DetLevel_vs_PartLevel"), jetMatched.pt(), + partJet.pt(), weight); + spectra.fill(HIST("hJetPt_resolution"), + (partJet.pt() - jetMatched.pt()) / partJet.pt(), + partJet.pt(), weight); + spectra.fill(HIST("hJetPhi_resolution"), + partJet.phi() - jetMatched.phi(), partJet.pt(), weight); + + if (bIsBaseJetRecoil) { + spectra.fill(HIST("hJetPt_DetLevel_vs_PartLevel_RecoilJets"), + jetMatched.pt(), partJet.pt(), weight); + spectra.fill(HIST("hJetPt_resolution_RecoilJets"), + (partJet.pt() - jetMatched.pt()) / partJet.pt(), + partJet.pt(), weight); + spectra.fill(HIST("hJetPhi_resolution_RecoilJets"), + partJet.phi() - jetMatched.phi(), partJet.pt(), weight); + } + } + } else { + // Miss jets + spectra.fill(HIST("hMissedJets_pT"), partJet.pt(), weight); + if (bIsBaseJetRecoil) + spectra.fill(HIST("hMissedJets_pT_RecoilJets"), partJet.pt(), weight); + } + + // Fake jets + for (const auto& detJet : detJets) { + bIsThereMatchedJet = detJet.has_matchedJetGeo(); + if (!bIsThereMatchedJet) { + spectra.fill(HIST("hFakeJets_pT"), detJet.pt(), weight); + if (bIsBaseJetRecoil) + spectra.fill(HIST("hFakeJets_pT_RecoilJets"), detJet.pt(), weight); + } + } + } }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGJE/Tasks/statPromptPhoton.cxx b/PWGJE/Tasks/statPromptPhoton.cxx index b3d1aaaffa9..977b94741c5 100644 --- a/PWGJE/Tasks/statPromptPhoton.cxx +++ b/PWGJE/Tasks/statPromptPhoton.cxx @@ -13,46 +13,54 @@ /// \brief Reconstruction of Phi yield through track-track Minv correlations for resonance hadrochemistry analysis. /// /// -/// \author Adrian Fereydon Nassirpour +/// \author Adrian Fereydon Nassirpour -#include -#include - -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/Track.h" +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/Jet.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" -#include "CommonConstants/PhysicsConstants.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/EMCALClusters.h" +#include "CommonConstants/PhysicsConstants.h" +#include "CommonDataFormat/InteractionRecord.h" +#include "DataFormatsEMCAL/AnalysisCluster.h" +#include "DataFormatsEMCAL/Cell.h" +#include "DataFormatsEMCAL/Constants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/Propagator.h" #include "EMCALBase/Geometry.h" #include "EMCALCalib/BadChannelMap.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" +#include -#include "DataFormatsEMCAL/Cell.h" -#include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" +#include +#include -#include "CommonDataFormat/InteractionRecord.h" +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; struct statPromptPhoton { + SliceCache cache; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; @@ -79,6 +87,23 @@ struct statPromptPhoton { Configurable cfgMinTrig{"MinTrig", 1, "Min. Trigger energy/momentum"}; Configurable cfgMaxTrig{"MaxTrig", 5, "Max. Trigger energy/momentum"}; Configurable cfgVtxCut{"cfgVtxCut", 10.0, "V_z cut selection"}; + Configurable cfgLowM02{"cfgLowM02", 0.1, "Lower-bound M02 cut"}; + Configurable cfgHighM02{"cfgHighM02", 0.3, "Higher-bound M02 cut"}; + Configurable cfgLowClusterE{"cfgLowClusterE", 0.5, "Higher-bound Cluster E cut"}; + Configurable cfgHighClusterE{"cfgHighClusterE", 500, "Lower-bound Cluster E cut"}; + Configurable cfgEmcTrigger{"cfgEmcTrigger", true, "Require EMC readout for event"}; + Configurable cfgGeoCut{"cfgGeoCut", true, "Performs Geometric TPC cut"}; + Configurable cfgPtClusterCut{"cfgPtClusterCut", true, "Performs Pt-dependent cluster-track matching"}; + Configurable cfgTrackFilter{"cfgTrackFilter", "globalTracks", "set track selections"}; + Configurable cfgJETracks{"cfgJETracks", false, "Enables running on derived JE data"}; + Configurable cfgGenHistograms{"cfgGenHistograms", false, "Enables Generated histograms"}; + Configurable cfgRecHistograms{"cfgRecHistograms", false, "Enables Reconstructed histograms"}; + Configurable cfgDataHistograms{"cfgDataHistograms", false, "Enables Data histograms"}; + Configurable cfgTriggerMasks{"cfgTriggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; + Configurable cfgDebug{"cfgDebug", false, "Enables debug information for local running"}; + + int trackFilter = -1; + std::vector triggerMaskBits; // INIT void init(InitContext const&) @@ -86,67 +111,155 @@ struct statPromptPhoton { 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.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 8.0, 12.0, 16.0, 20.0, 25.0, 30.0, 40.0, 50.0, 75.0, 100.0, 150.0, 200.0, 300.0, 500.0}; AxisSpec pthadAxis = {ptBinning, "#it{p}_{T}^{had sum} [GeV/c]"}; - histos.add("REC_nEvents", "REC_nEvents", kTH1F, {{4, 0.0, 4.0}}); - histos.add("REC_Cluster_QA", "REC_Cluster_QA", kTH1F, {{10, -0.5, 9.5}}); - histos.add("REC_PtHadSum_Photon", "REC_PtHadSum_Photon", kTH1F, {pthadAxis}); - histos.add("REC_TrackPhi_photontrigger", "REC_TrackPhi_photontrigger", kTH1F, {{64, 0, 2 * TMath::Pi()}}); - histos.add("REC_TrackEta_photontrigger", "REC_TrackEta_photontrigger", kTH1F, {{100, -1, 1}}); - histos.add("REC_True_v_Cluster_Phi", "REC_True_v_Cluster_Phi", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - histos.add("REC_True_v_Cluster_Eta", "REC_True_v_Cluster_Eta", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - histos.add("REC_Track_v_Cluster_Phi", "REC_Track_v_Cluster_Phi", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - histos.add("REC_Track_v_Cluster_Eta", "REC_Track_v_Cluster_Eta", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - histos.add("REC_Track_v_Cluster_Phi_AC", "REC_Track_v_Cluster_Phi_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - histos.add("REC_Track_v_Cluster_Eta_AC", "REC_Track_v_Cluster_Eta_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - histos.add("REC_SumPt_BC", "REC_SumPt_BC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - histos.add("REC_SumPt_AC", "REC_SumPt_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - histos.add("REC_M02_BC", "REC_M02_BC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - histos.add("REC_M02_AC", "REC_M02_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); - - histos.add("REC_Trigger_Purity", "REC_Trigger_Purity", kTH1F, {{4, 0.0, 4.0}}); - histos.add("REC_Trigger_Energy", "REC_Trigger_Energy", kTH1F, {{82, -1.0, 40.0}}); - - histos.add("REC_Trigger_Energy_GOOD", "REC_Trigger_Energy_GOOD", kTH1F, {{82, -1.0, 40.0}}); - histos.add("REC_Trigger_Energy_MISS", "REC_Trigger_Energy_MISS", kTH1F, {{82, -1.0, 40.0}}); - histos.add("REC_Trigger_Energy_FAKE", "REC_Trigger_Energy_FAKE", kTH1F, {{82, -1.0, 40.0}}); - - histos.add("REC_All_Energy", "REC_All_Energy", kTH1F, {{82, -1.0, 40.0}}); - histos.add("REC_True_Trigger_Energy", "REC_True_Trigger_Energy", kTH1F, {{82, -1.0, 40.0}}); - histos.add("REC_True_Prompt_Trigger_Energy", "REC_True_Prompt_Trigger_Energy", kTH1F, {{82, -1.0, 40.0}}); - - histos.add("REC_Trigger_V_PtHadSum_Stern", "REC_Trigger_V_PtHadSum_Stern", kTH2F, {{100, 0, 100}, pthadAxis}); - histos.add("REC_Trigger_V_PtHadSum_Photon", "REC_Trigger_V_PtHadSum_Photon", kTH2F, {{100, 0, 100}, pthadAxis}); - histos.add("REC_TrueTrigger_V_PtHadSum_Photon", "REC_Trigger_V_PtHadSum_Photon", kTH2F, {{100, 0, 100}, pthadAxis}); - histos.add("REC_dR_Photon", "REC_dR_Photon", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); - histos.add("REC_dR_Stern", "REC_dR_Stern", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); - - histos.add("GEN_nEvents", "GEN_nEvents", kTH1F, {{4, 0.0, 4.0}}); - histos.add("GEN_True_Photon_Energy", "GEN_True_Photon_Energy", kTH1F, {{8200, -1.0, 40.0}}); - histos.add("GEN_True_Prompt_Photon_Energy", "GEN_True_Prompt_Photon_Energy", kTH1F, {{8200, -1.0, 40.0}}); - histos.add("GEN_Trigger_V_PtHadSum_Stern", "GEN_Trigger_V_PtHadSum_Stern", kTH2F, {{100, 0, 100}, pthadAxis}); - histos.add("GEN_Trigger_V_PtHadSum_Photon", "GEN_Trigger_V_PtHadSum_Photon", kTH2F, {{100, 0, 100}, pthadAxis}); - histos.add("GEN_TrueTrigger_V_PtHadSum_Photon", "GEN_Trigger_V_PtHadSum_Photon", kTH2F, {{100, 0, 100}, pthadAxis}); - histos.add("GEN_dR_Photon", "GEN_dR_Photon", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); - histos.add("GEN_dR_Stern", "GEN_dR_Stern", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(cfgTriggerMasks); + if (cfgJETracks) { + trackFilter = jetderiveddatautilities::initialiseTrackSelection(static_cast(cfgTrackFilter)); + } + if (cfgRecHistograms) { + histos.add("REC_nEvents", "REC_nEvents", kTH1F, {{4, 0.0, 4.0}}); + histos.add("REC_Cluster_QA", "REC_Cluster_QA", kTH1F, {{10, -0.5, 9.5}}); + histos.add("REC_PtHadSum_Photon", "REC_PtHadSum_Photon", kTH1F, {pthadAxis}); + histos.add("REC_TrackPhi_photontrigger", "REC_TrackPhi_photontrigger", kTH1F, {{64, 0, 2 * TMath::Pi()}}); + histos.add("REC_TrackEta_photontrigger", "REC_TrackEta_photontrigger", kTH1F, {{100, -1, 1}}); + histos.add("REC_ClusterPhi", "REC_ClusterPhi", kTH1F, {{640 * 2, 0, 2 * TMath::Pi()}}); + histos.add("REC_ClusterEta", "REC_ClusterEta", kTH1F, {{100, -1, 1}}); + histos.add("REC_Track_Pt", "REC_Track_Pt", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Track_Phi", "REC_Track_Phi", kTH1F, {{640 * 2, 0, 2 * TMath::Pi()}}); + histos.add("REC_Track_PhiPrime_Pt", "REC_Track_PhiPrime_Pt", kTH2F, {{640, 0, 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("REC_Cluster_PhiPrime_Pt", "REC_Cluster_PhiPrime_Pt", kTH2F, {{640, 0, 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("REC_Cluster_PhiPrime_Pt_AC", "REC_Cluster_PhiPrime_Pt_AC", kTH2F, {{640, 0, 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("REC_Cluster_PhiPrime_Pt_C", "REC_Cluster_PhiPrime_Pt_C", kTH2F, {{640, 0, 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("REC_Cluster_Particle_Pt", "REC_Cluster_Particle_Pt", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Cluster_ParticleWITHtrack_Pt", "REC_Cluster_ParticleWITHtrack_Pt", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Cluster_ParticleWITHtrack_Phi", "REC_Cluster_ParticleWITHtrack_Phi", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Cluster_ParticleWITHtrack_Eta", "REC_Cluster_ParticleWITHtrack_Eta", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Cluster_ParticleWITHtrack_TrackPt", "REC_Cluster_ParticleWITHtrack_TrackPt", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Cluster_ParticleWITHtrack_Pt_Phi", "REC_Cluster_ParticleWITHtrack_Pt_Phi", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Cluster_ParticleWITHtrack_Pt_PhiPrime", "REC_Cluster_ParticleWITHtrack_Pt_PhiPrime", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Impurity_ParticleWITHtrack_Pt_PhiPrime", "REC_Impurity_ParticleWITHtrack_Pt_PhiPrime", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Cluster_ParticleWITHtrack_Pt_Eta", "REC_Cluster_ParticleWITHtrack_Pt_Eta", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Cluster_ParticleWITHOUTtrack_Pt", "REC_Cluster_ParticleWITHOUTtrack_Pt", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Cluster_ParticleWITHOUTtrack_Phi", "REC_Cluster_ParticleWITHOUTtrack_Phi", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Cluster_ParticleWITHOUTtrack_Eta", "REC_Cluster_ParticleWITHOUTtrack_Eta", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Cluster_ParticleWITHOUTtrack_Pt_Phi", "REC_Cluster_ParticleWITHOUTtrack_Pt_Phi", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Cluster_ParticleWITHOUTtrack_Pt_PhiPrime", "REC_Cluster_ParticleWITHOUTtrack_Pt_PhiPrime", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Cluster_ParticleWITHOUTtrack_Pt_Eta", "REC_Cluster_ParticleWITHOUTtrack_Pt_Eta", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Impurity_ParticleWITHOUTtrack_Pt_PhiPrime", "REC_Impurity_ParticleWITHOUTtrack_Pt_PhiPrime", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_TrackPt_ClusterE", "REC_TrackPt_ClusterE", kTH2F, {{82, -1.0, 40.0}, {82, -1.0, 40.0}}); + histos.add("REC_ParticlePt_ClusterE", "REC_ParticlePt_ClusterE", kTH2F, {{82, -1.0, 40.0}, {82, -1.0, 40.0}}); + histos.add("REC_TrackPt_Phi_Eta", "REC_TrackPt_Phi_Eta", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_ParticlePt_Phi_Eta", "REC_ParticlePt_Phi_Eta", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_True_v_Cluster_Phi", "REC_True_v_Cluster_Phi", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_True_v_Cluster_Eta", "REC_True_v_Cluster_Eta", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_TrueImpurity_v_Cluster_Phi", "REC_TrueImpurity_v_Cluster_Phi", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_TrueImpurity_v_Cluster_Eta", "REC_TrueImpurity_v_Cluster_Eta", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_TrueImpurity_v_Cluster_PhiAbs", "REC_TrueImpurity_v_Cluster_PhiAbs", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_TrueImpurity_v_Cluster_EtaAbs", "REC_TrueImpurity_v_Cluster_EtaAbs", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_TrueImpurity_v_Cluster_Phi_Eta", "REC_TrueImpurity_v_Cluster_Phi_Eta", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Track_v_Cluster_Phi", "REC_Track_v_Cluster_Phi", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Track_v_Cluster_Eta", "REC_Track_v_Cluster_Eta", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Track_v_Cluster_Phi_Pt", "REC_Track_v_Cluster_Phi_Pt", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("REC_Track_v_Cluster_Eta_Pt", "REC_Track_v_Cluster_Eta_Pt", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("REC_Track_v_Cluster_Phi_Eta", "REC_Track_v_Cluster_Phi_Eta", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Track_v_Cluster_Phi_AC", "REC_Track_v_Cluster_Phi_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Track_v_Cluster_Eta_AC", "REC_Track_v_Cluster_Eta_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Track_v_Cluster_Phi_Eta_AC", "REC_Track_v_Cluster_Phi_Eta_AC", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Track_v_Cluster_Phi_C", "REC_Track_v_Cluster_Phi_C", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Track_v_Cluster_Eta_C", "REC_Track_v_Cluster_Eta_C", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Track_v_Cluster_Phi_Eta_C", "REC_Track_v_Cluster_Phi_Eta_C", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_SumPt_BC", "REC_SumPt_BC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_SumPt_AC", "REC_SumPt_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_M02_BC", "REC_M02_BC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_M02_AC", "REC_M02_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Trigger_Purity", "REC_Trigger_Purity", kTH1F, {{4, 0.0, 4.0}}); + histos.add("REC_Trigger_Energy", "REC_Trigger_Energy", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Trigger_Purity_v_Energy", "REC_Trigger_Purity_v_Energy", kTH2F, {{4, 0.0, 4.0}, {82, -1.0, 40.0}}); + histos.add("REC_Trigger_Energy_GOOD", "REC_Trigger_Energy_GOOD", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Trigger_Energy_MISS", "REC_Trigger_Energy_MISS", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Trigger_Energy_FAKE", "REC_Trigger_Energy_FAKE", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_All_Energy", "REC_All_Energy", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Impurity_Energy", "REC_Impurity_Energy", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Impurity_Energy_v_Cluster_Phi", "REC_Impurity_Energy_v_Cluster_Phi", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Impurity_Energy_v_ClusterE_Phi", "REC_Impurity_Energy_v_ClusterE_Phi", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Impurity_Energy_v_ClusterEoP_Phi", "REC_Impurity_Energy_v_ClusterEoP_Phi", kTH2F, {{82, -1.0, 40.0}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("REC_Impurity_Energy_v_Cluster_Energy", "REC_Impurity_Energy_v_Cluster_Energy", kTH2F, {{82, -1.0, 40.0}, {82, -1.0, 40.0}}); + histos.add("REC_True_Trigger_Energy", "REC_True_Trigger_Energy", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_True_Prompt_Trigger_Energy", "REC_True_Prompt_Trigger_Energy", kTH1F, {{82, -1.0, 40.0}}); + histos.add("REC_Trigger_V_PtHadSum_Stern", "REC_Trigger_V_PtHadSum_Stern", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("REC_Trigger_V_PtHadSum_Nch", "REC_Trigger_V_PtHadSum_Nch", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("REC_Trigger_V_PtHadSum_Photon", "REC_Trigger_V_PtHadSum_Photon", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("REC_TrueTrigger_V_PtHadSum_Photon", "REC_Trigger_V_PtHadSum_Photon", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("REC_dR_Photon", "REC_dR_Photon", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); + histos.add("REC_dR_Stern", "REC_dR_Stern", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); + } + if (cfgGenHistograms) { + histos.add("GEN_nEvents", "GEN_nEvents", kTH1F, {{4, 0.0, 4.0}}); + histos.add("GEN_True_Trigger_Energy", "GEN_True_Trigger_Energy", kTH1F, {{82, -1.0, 40.0}}); + histos.add("GEN_Particle_Pt", "GEN_Particle_Pt", kTH1F, {{82, -1.0, 40.0}}); + histos.add("GEN_True_Photon_Energy", "GEN_True_Photon_Energy", kTH1F, {{8200, -1.0, 40.0}}); + histos.add("GEN_True_Prompt_Photon_Energy", "GEN_True_Prompt_Photon_Energy", kTH1F, {{8200, -1.0, 40.0}}); + histos.add("GEN_Trigger_V_PtHadSum_Stern", "GEN_Trigger_V_PtHadSum_Stern", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("GEN_Trigger_V_PtHadSum_Photon", "GEN_Trigger_V_PtHadSum_Photon", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("GEN_TrueTrigger_V_PtHadSum_Photon", "GEN_Trigger_V_PtHadSum_Photon", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("GEN_dR_Photon", "GEN_dR_Photon", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); + histos.add("GEN_dR_Stern", "GEN_dR_Stern", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); + } + if (cfgDataHistograms) { + histos.add("DATA_nEvents", "DATA_nEvents", kTH1F, {{4, 0.0, 4.0}}); + histos.add("DATA_M02_BC", "DATA_M02_BC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("DATA_M02_AC", "DATA_M02_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("DATA_Cluster_QA", "DATA_Cluster_QA", kTH1F, {{10, -0.5, 9.5}}); + histos.add("DATA_ClusterPhi", "DATA_ClusterPhi", kTH1F, {{640 * 2, 0, 2 * TMath::Pi()}}); + histos.add("DATA_ClusterEta", "DATA_ClusterEta", kTH1F, {{100, -1, 1}}); + histos.add("DATA_All_Energy", "DATA_All_Energy", kTH1F, {{82, -1.0, 40.0}}); + histos.add("DATA_Cluster_PhiPrime_Pt", "DATA_Cluster_PhiPrime_Pt", kTH2F, {{640, 0, 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("DATA_Cluster_PhiPrime_Pt_AC", "DATA_Cluster_PhiPrime_Pt_AC", kTH2F, {{640, 0, 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("DATA_Cluster_PhiPrime_Pt_C", "DATA_Cluster_PhiPrime_Pt_C", kTH2F, {{640, 0, 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("DATA_Track_v_Cluster_Phi", "DATA_Track_v_Cluster_Phi", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("DATA_Track_v_Cluster_Eta", "DATA_Track_v_Cluster_Eta", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("DATA_Track_v_Cluster_Phi_Pt", "DATA_Track_v_Cluster_Phi_Pt", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("DATA_Track_v_Cluster_Phi_Eta", "DATA_Track_v_Cluster_Phi_Eta", kTH2F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}, {628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("DATA_SumPt_BC", "DATA_SumPt_BC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("DATA_SumPt_AC", "DATA_SumPt_AC", kTH1F, {{628, -2 * TMath::Pi(), 2 * TMath::Pi()}}); + histos.add("DATA_Trigger_V_PtHadSum_Photon", "DATA_Trigger_V_PtHadSum_Photon", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("DATA_PtHadSum_Photon", "DATA_PtHadSum_Photon", kTH1F, {pthadAxis}); + histos.add("DATA_Trigger_Energy", "DATA_Trigger_Energy", kTH1F, {{82, -1.0, 40.0}}); + histos.add("DATA_Track_PhiPrime_Pt", "DATA_Track_PhiPrime_Pt", kTH2F, {{640, 0, 2 * TMath::Pi()}, {82, -1.0, 40.0}}); + histos.add("DATA_Track_Pt", "DATA_Track_Pt", kTH1F, {{82, -1.0, 40.0}}); + histos.add("DATA_Track_Phi", "DATA_Track_Phi", kTH1F, {{640 * 2, 0, 2 * TMath::Pi()}}); + histos.add("DATA_TrackPhi_photontrigger", "DATA_TrackPhi_photontrigger", kTH1F, {{64, 0, 2 * TMath::Pi()}}); + histos.add("DATA_TrackEta_photontrigger", "DATA_TrackEta_photontrigger", kTH1F, {{100, -1, 1}}); + histos.add("DATA_Trigger_V_PtHadSum_Stern", "DATA_Trigger_V_PtHadSum_Stern", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("DATA_Trigger_V_PtHadSum_Nch", "DATA_Trigger_V_PtHadSum_Nch", kTH2F, {{100, 0, 100}, pthadAxis}); + histos.add("DATA_dR_Photon", "DATA_dR_Photon", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); + histos.add("DATA_dR_Stern", "DATA_dR_Stern", kTH1F, {{628, 0.0, 2 * TMath::Pi()}}); + } } // end of init - Filter clusterDefinitionSelection = (o2::aod::emcalcluster::definition == cfgClusterDefinition) && (o2::aod::emcalcluster::time >= cfgMinTime) && (o2::aod::emcalcluster::time <= cfgMaxTime) && (o2::aod::emcalcluster::energy > cfgMinClusterEnergy) && (o2::aod::emcalcluster::nCells >= cfgMinNCells) && (o2::aod::emcalcluster::nlm <= cfgMaxNLM) && (o2::aod::emcalcluster::isExotic == cfgExoticContribution); - Filter emccellfilter = aod::calo::caloType == 1; // mc emcal cell - Filter PosZFilter = nabs(aod::collision::posZ) < cfgVtxCut; - Filter mcPosZFilter = nabs(aod::mccollision::posZ) < cfgVtxCut; + Filter PosZFilter_JE = nabs(aod::jcollision::posZ) < cfgVtxCut; + Filter mcPosZFilter = nabs(aod::jmccollision::posZ) < cfgVtxCut; + Filter clusterDefinitionSelection_JE = (o2::aod::jcluster::definition == cfgClusterDefinition) && (o2::aod::jcluster::time >= cfgMinTime) && (o2::aod::jcluster::time <= cfgMaxTime) && (o2::aod::jcluster::energy > cfgMinClusterEnergy) && (o2::aod::jcluster::nCells >= cfgMinNCells) && (o2::aod::jcluster::nlm <= cfgMaxNLM) && (o2::aod::jcluster::isExotic == cfgExoticContribution); - using MCCells = o2::soa::Join; + using selectedMCCollisions = aod::JMcCollisions; + using filteredMCCollisions = soa::Filtered; + using TrackCandidates = soa::Join; + using BcCandidates = soa::Join; - using MCClusters = o2::soa::Join; - using selectedCollisions = soa::Join; - using selectedMCCollisions = aod::McCollisions; + using jTrackCandidates = soa::Join; + using jEMCtracks = aod::JEMCTracks; - using TrackCandidates = soa::Join; + using jDataTrackCandidates = soa::Join; - using filteredMCCells = o2::soa::Filtered; - using filteredMCClusters = soa::Filtered; - using filteredCollisions = soa::Filtered; - using filteredMCCollisions = soa::Filtered; + using jMCClusters = o2::soa::Join; + using jClusters = o2::soa::Join; + using jselectedCollisions = soa::Join; + using jselectedDataCollisions = soa::Join; + // using jselectedDataCollisions = soa::Join; + using jfilteredCollisions = soa::Filtered; + using jfilteredDataCollisions = soa::Filtered; + using jfilteredMCClusters = soa::Filtered; + using jfilteredClusters = soa::Filtered; Preslice perClusterMatchedTracks = o2::aod::emcalclustercell::emcalclusterId; @@ -178,14 +291,25 @@ struct statPromptPhoton { if (!IsParticle) { if constexpr (requires { track.trackId(); }) { - auto originaltrack = track.template track_as>(); - if (!trackSelection(originaltrack)) { - continue; + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(track, trackFilter)) { + continue; + } + } else { + auto originaltrack = track.template track_as>(); + if (!trackSelection(originaltrack)) { + continue; + } } // reject track } else if constexpr (requires { track.sign(); }) { // checking for JTrack - // done checking for JTrack, now default to normal tracks - if (!trackSelection(track)) { - continue; + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(track, trackFilter)) { + continue; + } + } else { + if (!trackSelection(track)) { + continue; + } } // reject track } // done checking for JTrack } else { @@ -221,11 +345,20 @@ struct statPromptPhoton { if (DodR) { if (dR > MinR && dR < MaxR) { if (!IsParticle) { - if (IsStern) { - histos.fill(HIST("REC_dR_Stern"), dR); - } - if (!IsStern) { - histos.fill(HIST("REC_dR_Photon"), dR); + if (cfgRecHistograms) { + if (IsStern) { + histos.fill(HIST("REC_dR_Stern"), dR); + } + if (!IsStern) { + histos.fill(HIST("REC_dR_Photon"), dR); + } + } else if (cfgDataHistograms) { + if (IsStern) { + histos.fill(HIST("DATA_dR_Stern"), dR); + } + if (!IsStern) { + histos.fill(HIST("DATA_dR_Photon"), dR); + } } } else { if (IsStern) { @@ -296,11 +429,14 @@ struct statPromptPhoton { ///////////////////////////////////////////////////////////////////////////// int nEventsGenMC = 0; - void processMCGen(filteredMCCollisions::iterator const& collision, soa::SmallGroups> const& recocolls, aod::McParticles const& mcParticles, filteredMCClusters const&) + // void processMCGen(filteredMCCollisions::iterator const& collision, soa::SmallGroups> const& recocolls, aod::McParticles const& mcParticles, filteredMCClusters const&) + void processMCGen(filteredMCCollisions::iterator const& collision, soa::SmallGroups> const& recocolls, aod::JMcParticles const& mcParticles, jfilteredMCClusters const&) { nEventsGenMC++; - if ((nEventsGenMC + 1) % 10000 == 0) { - std::cout << "Processed Gen MC Events: " << nEventsGenMC << std::endl; + if (cfgDebug) { + if ((nEventsGenMC + 1) % 10000 == 0) { + std::cout << "Processed Gen MC Events: " << nEventsGenMC << std::endl; + } } histos.fill(HIST("GEN_nEvents"), 0.5); if (fabs(collision.posZ()) > cfgVtxCut) @@ -315,8 +451,11 @@ struct statPromptPhoton { return; histos.fill(HIST("GEN_nEvents"), 1.5); - if (!recocoll.alias_bit(kTVXinEMC)) - return; + + if (cfgEmcTrigger) { + if (!recocoll.isEmcalReadout()) + return; + } histos.fill(HIST("GEN_nEvents"), 2.5); } @@ -326,6 +465,12 @@ struct statPromptPhoton { continue; if (std::abs(mcPhoton.eta()) > cfgtrkMaxEta) continue; + double pdgcode = fabs(mcPhoton.pdgCode()); + if (mcPhoton.isPhysicalPrimary()) { + if (pdgcode == 211 || pdgcode == 321 || pdgcode == 2212 || pdgcode == 11) { + histos.fill(HIST("GEN_Particle_Pt"), mcPhoton.pt()); + } + } if (mcPhoton.getGenStatusCode() < 20) continue; @@ -374,8 +519,75 @@ struct statPromptPhoton { double truepthadsum = GetPtHadSum(mcParticles, lRealPhoton, cfgMinR, cfgMaxR, false, true, false); histos.fill(HIST("GEN_Trigger_V_PtHadSum_Photon"), mcPhoton.e(), truepthadsum); } + // now we do all PROMPT photons - if (std::abs(mcPhoton.getGenStatusCode()) > 19 && std::abs(mcPhoton.getGenStatusCode()) < 70) { + histos.fill(HIST("GEN_True_Trigger_Energy"), mcPhoton.e()); + + int mompdg1 = 0; + int momindex1 = 0; + int momstatus1 = 0; + for (auto& photon_mom : mcPhoton.mothers_as()) { + if (mompdg1 == 0) { + mompdg1 = photon_mom.pdgCode(); + momindex1 = photon_mom.globalIndex(); + momstatus1 = photon_mom.getGenStatusCode(); + } + } // first photon loop + + if (std::fabs(mompdg1) < 40 && std::fabs(mompdg1) > 0) { + int mompdg2 = 0; + int momindex2 = 0; + int momstatus2 = 0; + int mompdg3 = 0; + int momindex3 = 0; + int momstatus3 = 0; + for (auto& mcPhoton_mom : mcParticles) { + if (mcPhoton_mom.globalIndex() == momindex1) { + for (auto& photon_momom : mcPhoton_mom.mothers_as()) { + if (mompdg2 == 0) { + mompdg2 = photon_momom.pdgCode(); + momindex2 = photon_momom.globalIndex(); + momstatus2 = photon_momom.getGenStatusCode(); + } + } + break; + } + } // 2nd photon loop + if (std::fabs(mompdg2) < 40 && std::fabs(mompdg2) > 0) { + for (auto& mcPhoton_mom : mcParticles) { + if (mcPhoton_mom.globalIndex() == momindex2) { + for (auto& photon_momom : mcPhoton_mom.mothers_as()) { + if (mompdg3 == 0) { + mompdg3 = photon_momom.pdgCode(); + momindex3 = photon_momom.globalIndex(); + momstatus3 = photon_momom.getGenStatusCode(); + } + } + break; + } + } // 3rd photon loop + } // 2nd photon check + + if (cfgDebug) { + std::cout << "We have a GEN prompt photon" << std::endl; + std::cout << "Photon gen status code chain: " << std::endl; + std::cout << "Photon stat: " << mcPhoton.getGenStatusCode() << std::endl; + std::cout << "Photon index: " << mcPhoton.globalIndex() << std::endl; + std::cout << "Photon mompdg 1: " << mompdg1 << std::endl; + std::cout << "Photon momstatus 1: " << momstatus1 << std::endl; + std::cout << "Photon momindex 1: " << momindex1 << std::endl; + std::cout << "Photon mompdg 2: " << mompdg2 << std::endl; + std::cout << "Photon momstatus 2: " << momstatus2 << std::endl; + std::cout << "Photon momindex 2: " << momindex2 << std::endl; + std::cout << "Photon mompdg 3: " << mompdg3 << std::endl; + std::cout << "Photon momstatus 3: " << momstatus3 << std::endl; + std::cout << "Photon momindex 3: " << momindex3 << std::endl; + } + } else { + continue; + } + + if (std::abs(mcPhoton.getGenStatusCode()) > 19 && std::abs(mcPhoton.getGenStatusCode()) < 90) { if (mcPhoton.isPhysicalPrimary()) { histos.fill(HIST("GEN_True_Prompt_Photon_Energy"), mcPhoton.e()); if (photontrigger) { @@ -395,26 +607,20 @@ struct statPromptPhoton { PROCESS_SWITCH(statPromptPhoton, processMCGen, "process MC Gen", true); - Filter PosZFilter_JE = nabs(aod::jcollision::posZ) < cfgVtxCut; - Filter clusterDefinitionSelection_JE = (o2::aod::jcluster::definition == cfgClusterDefinition) && (o2::aod::jcluster::time >= cfgMinTime) && (o2::aod::jcluster::time <= cfgMaxTime) && (o2::aod::jcluster::energy > cfgMinClusterEnergy) && (o2::aod::jcluster::nCells >= cfgMinNCells) && (o2::aod::jcluster::nlm <= cfgMaxNLM) && (o2::aod::jcluster::isExotic == cfgExoticContribution); - - using jTrackCandidates = soa::Join; - using jMCClusters = o2::soa::Join; - using jselectedCollisions = soa::Join; - using jfilteredCollisions = soa::Filtered; - using jfilteredMCClusters = soa::Filtered; - + PresliceUnsorted EMCTrackPerTrack = aod::jemctrack::trackId; int nEventsRecMC_JE = 0; - void processMCRec_JE(jfilteredCollisions::iterator const& collision, jfilteredMCClusters const& mcclusters, jTrackCandidates const& tracks, soa::Join const& /*caltracks*/, aod::JMcParticles const&, TrackCandidates const&) + void processMCRec_JE(jfilteredCollisions::iterator const& collision, jfilteredMCClusters const& mcclusters, jTrackCandidates const& tracks, soa::Join const&, TrackCandidates const&, aod::JMcParticles const&, BcCandidates const&, jEMCtracks const& emctracks, aod::JetMcCollisions const&) { nEventsRecMC_JE++; - if ((nEventsRecMC_JE + 1) % 10000 == 0) { - std::cout << "Processed JE Rec MC Events: " << nEventsRecMC_JE << std::endl; + if (cfgDebug) { + if ((nEventsRecMC_JE + 1) % 10000 == 0) { + std::cout << "Processed JE Rec MC Events: " << nEventsRecMC_JE << std::endl; + } } - histos.fill(HIST("REC_nEvents"), 0.5); + // required cuts if (fabs(collision.posZ()) > cfgVtxCut) return; if (!collision.sel8()) @@ -422,64 +628,112 @@ struct statPromptPhoton { histos.fill(HIST("REC_nEvents"), 1.5); - if (!collision.isEmcalReadout()) + if (cfgEmcTrigger) { + if (!collision.isEmcalReadout()) + return; + } + histos.fill(HIST("REC_nEvents"), 2.5); + + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; + } - histos.fill(HIST("REC_nEvents"), 2.5); + histos.fill(HIST("REC_nEvents"), 3.5); + + double weight = 1; + if (collision.has_mcCollision()) { + weight = collision.mcCollision().weight(); + } + + bool noTrk = true; + for (auto& track : tracks) { + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(track, trackFilter)) { + continue; + } + } else { + auto ogtrack = track.track_as(); + if (!trackSelection(ogtrack)) { + continue; + } + if (!ogtrack.isGlobalTrack()) { + continue; + } + } + noTrk = false; + break; + } + + if (noTrk) + return; // now we do clusters bool clustertrigger = false; for (auto& mccluster : mcclusters) { - histos.fill(HIST("REC_M02_BC"), mccluster.energy()); - if (mccluster.m02() < 0.1) + histos.fill(HIST("REC_M02_BC"), mccluster.m02()); + if (mccluster.m02() < cfgLowM02) + continue; + if (mccluster.m02() > cfgHighM02) + continue; + if (mccluster.energy() < cfgLowClusterE) continue; + if (mccluster.energy() > cfgHighClusterE) + continue; + if (fabs(mccluster.eta()) > cfgtrkMaxEta) + continue; + histos.fill(HIST("REC_Cluster_QA"), 0.5); - histos.fill(HIST("REC_M02_AC"), mccluster.energy()); + histos.fill(HIST("REC_M02_AC"), mccluster.m02()); histos.fill(HIST("REC_All_Energy"), mccluster.energy()); - bool photontrigger = false; // is a neutral cluster - bool vetotrigger = false; // might be a neutral cluster - bool chargetrigger = false; // is definitely not a neutral cluster - double photonPt = 0.0; + histos.fill(HIST("REC_ClusterPhi"), mccluster.phi()); + histos.fill(HIST("REC_ClusterEta"), mccluster.eta()); + + bool photontrigger = false; // is a neutral cluster + bool chargetrigger = false; // is definitely not a neutral cluster + // double photonPt = 0.0; double truephotonPt = 0.0; auto tracksofcluster = mccluster.matchedTracks_as>(); + /////////////// + /////////////// + /////////////// + + double phiPrimeC = mccluster.phi(); + phiPrimeC = phiPrimeC + TMath::Pi() / 18.; + phiPrimeC = fmod(phiPrimeC, 2 * TMath::Pi() / 18.); + double ptC = mccluster.energy(); + bool geocut = false; + histos.fill(HIST("REC_Cluster_PhiPrime_Pt"), phiPrimeC, mccluster.energy()); + if (phiPrimeC > (0.12 / ptC + TMath::Pi() / 18. + 0.035) || + phiPrimeC < (0.1 / ptC / ptC + TMath::Pi() / 18. - 0.025)) { + geocut = false; + } else { + geocut = true; + } - // first, we check if veto is required - double sumptT = 0; - double sumptTAC = 0; - for (auto& ctrack : tracksofcluster) { - auto ogtrack = ctrack.track_as(); - if (!trackSelection(ogtrack)) { - continue; - } - if (!ogtrack.isGlobalTrack()) { + if (cfgGeoCut) { + if (geocut) { + histos.fill(HIST("REC_Cluster_PhiPrime_Pt_C"), phiPrimeC, mccluster.energy()); continue; } - - double ptT = ctrack.pt(); - sumptT += ptT; - double phidiff = TVector2::Phi_mpi_pi(mccluster.phi() - ctrack.phi()); - double etadiff = mccluster.eta() - ctrack.eta(); - histos.fill(HIST("REC_Track_v_Cluster_Phi"), phidiff); - histos.fill(HIST("REC_Track_v_Cluster_Eta"), etadiff); } - if (sumptT > 0) { - double mccluster_over_sumptT = mccluster.energy() / sumptT; - histos.fill(HIST("REC_SumPt_BC"), mccluster_over_sumptT); - if (mccluster_over_sumptT < 1.7) { - histos.fill(HIST("REC_Cluster_QA"), 2.5); - vetotrigger = true; - } else { - photontrigger = true; - histos.fill(HIST("REC_Cluster_QA"), 1.5); - } - } else { - photontrigger = true; - } + histos.fill(HIST("REC_Cluster_PhiPrime_Pt_AC"), phiPrimeC, mccluster.energy()); - // veto is required - if (vetotrigger) { - for (auto& ctrack : tracksofcluster) { + // first, we check if veto is required + double sumptT = 0; + bool clusterqa = false; + for (auto& ctrack : tracksofcluster) { + double etaT, phiT; + + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(ctrack, trackFilter)) { + continue; + } + auto emctracksPerTrack = emctracks.sliceBy(EMCTrackPerTrack, ctrack.globalIndex()); + auto emctrack = emctracksPerTrack.iteratorAt(0); + etaT = emctrack.etaEmcal(); + phiT = emctrack.phiEmcal(); + } else { auto ogtrack = ctrack.track_as(); if (!trackSelection(ogtrack)) { continue; @@ -487,29 +741,80 @@ struct statPromptPhoton { if (!ogtrack.isGlobalTrack()) { continue; } + etaT = ogtrack.trackEtaEmcal(); + phiT = ogtrack.trackPhiEmcal(); + } - double etaT = ctrack.eta(); - double etaC = mccluster.eta(); - double phiT = ctrack.phi(); - double phiC = mccluster.phi(); - double ptT = ctrack.pt(); + double etaC = mccluster.eta(); + double phiC = mccluster.phi(); + double ptT = ctrack.pt(); + bool etatrigger = false; + bool phitrigger = false; + double phidiff = TVector2::Phi_mpi_pi(mccluster.phi() - ctrack.phi()); + double etadiff = mccluster.eta() - ctrack.eta(); + if (cfgPtClusterCut) { if (fabs(etaT - etaC) < (0.010 + pow(ptT + 4.07, -2.5))) { - chargetrigger = true; + etatrigger = true; } + if (fabs(TVector2::Phi_mpi_pi(phiT - phiC)) < (0.015 + pow(ptT + 3.65, -2.0))) { - chargetrigger = true; + phitrigger = true; } - if (chargetrigger) { - histos.fill(HIST("REC_Cluster_QA"), 3.5); - break; + } else { + if (fabs(etadiff) < 0.05) { + etatrigger = true; } - } // tracks - } // veto - // check if cluster is good + if (fabs(phidiff) < 0.05) { + phitrigger = true; + } + } + + if (etatrigger && phitrigger) { + chargetrigger = true; + sumptT += ptT; + } + if (chargetrigger) { + if (!clusterqa) { + histos.fill(HIST("REC_Cluster_QA"), 1.5); + clusterqa = true; + } + } + histos.fill(HIST("REC_Track_v_Cluster_Phi"), phidiff); + histos.fill(HIST("REC_Track_v_Cluster_Eta"), etadiff); + + histos.fill(HIST("REC_Track_v_Cluster_Phi_Eta"), phidiff, etadiff); + + } // track of cluster loop + + if (chargetrigger && sumptT > 0) { + double mccluster_over_sumptT = mccluster.energy() / sumptT; + histos.fill(HIST("REC_SumPt_BC"), mccluster_over_sumptT); + if (mccluster_over_sumptT < 1.7) { + histos.fill(HIST("REC_Cluster_QA"), 2.5); // veto fails, cluster is charged + } else { + histos.fill(HIST("REC_Cluster_QA"), 3.5); // veto is good, cluster is converted to neutral cluster + // chargetrigger = false; + histos.fill(HIST("REC_SumPt_AC"), mccluster_over_sumptT); + } + } // sumptT check + if (!chargetrigger) { - for (auto& ctrack : tracksofcluster) { + photontrigger = true; + } + + /////////////// + /////////////// + /////////////// + + // check if cluster is good + for (auto& ctrack : tracksofcluster) { + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(ctrack, trackFilter)) { + continue; + } + } else { auto ogtrack = ctrack.track_as(); if (!trackSelection(ogtrack)) { continue; @@ -517,42 +822,143 @@ struct statPromptPhoton { if (!ogtrack.isGlobalTrack()) { continue; } + } + bool etatrigger = false; + bool phitrigger = false; + // double ptT = ctrack.pt(); + double phidiff = TVector2::Phi_mpi_pi(mccluster.phi() - ctrack.phi()); + double etadiff = mccluster.eta() - ctrack.eta(); + if (fabs(etadiff) < 0.05) { + etatrigger = true; + } + + if (fabs(phidiff) < 0.05) { + phitrigger = true; + } - double ptT = ctrack.pt(); - sumptTAC += ptT; - double phidiff = TVector2::Phi_mpi_pi(mccluster.phi() - ctrack.phi()); - double etadiff = mccluster.eta() - ctrack.eta(); + if (chargetrigger) { + histos.fill(HIST("REC_Track_v_Cluster_Phi_C"), phidiff); + histos.fill(HIST("REC_Track_v_Cluster_Eta_C"), etadiff); + histos.fill(HIST("REC_Track_v_Cluster_Phi_Eta_C"), phidiff, etadiff); + } else { + if ((etatrigger || phitrigger) && chargetrigger) { + if (cfgDebug) { + std::cout << "????????????????????" << std::endl; + } + } histos.fill(HIST("REC_Track_v_Cluster_Phi_AC"), phidiff); histos.fill(HIST("REC_Track_v_Cluster_Eta_AC"), etadiff); - } // tracks - - if (sumptTAC > 0) { - double mccluster_over_sumptTAC = mccluster.energy() / sumptTAC; - histos.fill(HIST("REC_SumPt_AC"), mccluster_over_sumptTAC); + histos.fill(HIST("REC_Track_v_Cluster_Phi_Eta_AC"), phidiff, etadiff); } + } // tracks - photontrigger = true; - } // check if there is no charge trigger + /////////////// + /////////////// + /////////////// if (photontrigger) { // if no charge trigger, cluster is good! histos.fill(HIST("REC_Cluster_QA"), 4.5); clustertrigger = true; double pthadsum = GetPtHadSum(tracks, mccluster, cfgMinR, cfgMaxR, false, false, true); - histos.fill(HIST("REC_Trigger_V_PtHadSum_Photon"), photonPt, pthadsum); - histos.fill(HIST("REC_PtHadSum_Photon"), pthadsum); - histos.fill(HIST("REC_Trigger_Energy"), mccluster.energy()); + histos.fill(HIST("REC_Trigger_V_PtHadSum_Photon"), mccluster.energy(), pthadsum, weight); + histos.fill(HIST("REC_PtHadSum_Photon"), pthadsum, weight); + histos.fill(HIST("REC_Trigger_Energy"), mccluster.energy(), weight); } + auto ClusterParticles = mccluster.mcParticles_as(); + // now we check the realness of our prompt photons - auto ClusterParticles = mccluster.mcParticle_as(); bool goodgentrigger = true; + double chPe = 0; for (auto& clusterparticle : ClusterParticles) { - if (clusterparticle.pdgCode() == 211 || clusterparticle.pdgCode() == 321 || clusterparticle.pdgCode() == 2212) { - goodgentrigger = false; + int cindex = clusterparticle.globalIndex(); + double pdgcode = fabs(clusterparticle.pdgCode()); + if (!clusterparticle.isPhysicalPrimary()) { + continue; } + if (pdgcode == 211 || pdgcode == 321 || pdgcode == 2212 || pdgcode == 11) { + bool notrack = true; + histos.fill(HIST("REC_Cluster_Particle_Pt"), clusterparticle.pt()); + + double phiPrimeP = clusterparticle.phi(); + if (clusterparticle.pdgCode() < 0) { + phiPrimeP = 2 * TMath::Pi() - phiPrimeP; + } + phiPrimeP = phiPrimeP + TMath::Pi() / 18.; + phiPrimeP = fmod(phiPrimeP, 2 * TMath::Pi() / 18.); + double ptP = clusterparticle.pt(); + for (auto& track : tracks) { + if (!track.has_mcParticle()) + continue; + + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(track, trackFilter)) { + continue; + } + } else { + auto ogtrack = track.track_as(); + if (!trackSelection(ogtrack)) { + continue; + } + if (!ogtrack.isGlobalTrack()) { + continue; + } + } + + int tindex = track.mcParticleId(); + if (tindex == cindex) { + histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Pt"), clusterparticle.pt()); + histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Phi"), clusterparticle.phi()); + histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Eta"), clusterparticle.eta()); + histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Pt_Phi"), clusterparticle.pt(), clusterparticle.phi()); + histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Pt_PhiPrime"), ptP, phiPrimeP); + if (photontrigger) { + histos.fill(HIST("REC_Impurity_ParticleWITHtrack_Pt_PhiPrime"), ptP, phiPrimeP); + } + // }//geo cut + histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Pt_Eta"), clusterparticle.pt(), clusterparticle.eta()); + + histos.fill(HIST("REC_Cluster_ParticleWITHtrack_TrackPt"), track.pt()); + notrack = false; + break; + } + } // track loop + + if (notrack) { + histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Pt"), clusterparticle.pt()); + histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Phi"), clusterparticle.phi()); + histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Eta"), clusterparticle.eta()); + histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Pt_Phi"), clusterparticle.pt(), clusterparticle.phi()); + histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Pt_PhiPrime"), ptP, phiPrimeP); + if (photontrigger) { + histos.fill(HIST("REC_Impurity_ParticleWITHOUTtrack_Pt_PhiPrime"), ptP, phiPrimeP); + } + // }//geo cut + histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Pt_Eta"), clusterparticle.pt(), clusterparticle.eta()); + } + } // pdg code check double phidiff = TVector2::Phi_mpi_pi(mccluster.phi() - clusterparticle.phi()); double etadiff = mccluster.eta() - clusterparticle.eta(); + + if (pdgcode == 211 || pdgcode == 321 || pdgcode == 2212 || pdgcode == 11) { + if (clusterparticle.e() > 0.01) { + chPe += clusterparticle.e(); + goodgentrigger = false; + if (photontrigger) { + histos.fill(HIST("REC_Impurity_Energy_v_Cluster_Phi"), clusterparticle.e(), phidiff); + histos.fill(HIST("REC_Impurity_Energy_v_ClusterE_Phi"), mccluster.energy(), phidiff); + histos.fill(HIST("REC_Impurity_Energy_v_ClusterEoP_Phi"), mccluster.energy() / clusterparticle.e(), phidiff); + histos.fill(HIST("REC_Impurity_Energy_v_Cluster_Energy"), mccluster.energy(), clusterparticle.e()); + + histos.fill(HIST("REC_TrueImpurity_v_Cluster_Phi"), phidiff); + histos.fill(HIST("REC_TrueImpurity_v_Cluster_PhiAbs"), clusterparticle.phi()); + histos.fill(HIST("REC_TrueImpurity_v_Cluster_Eta"), etadiff); + histos.fill(HIST("REC_TrueImpurity_v_Cluster_EtaAbs"), clusterparticle.eta()); + histos.fill(HIST("REC_TrueImpurity_v_Cluster_Phi_Eta"), phidiff, etadiff); + } + } + } histos.fill(HIST("REC_True_v_Cluster_Phi"), phidiff); histos.fill(HIST("REC_True_v_Cluster_Eta"), etadiff); @@ -561,27 +967,59 @@ struct statPromptPhoton { } if (clusterparticle.pdgCode() == 22) { histos.fill(HIST("REC_True_Trigger_Energy"), clusterparticle.e()); - if (std::abs(clusterparticle.getGenStatusCode()) > 19 && std::abs(clusterparticle.getGenStatusCode()) < 70) { - histos.fill(HIST("REC_True_Prompt_Trigger_Energy"), clusterparticle.e()); + int mom1 = 0; + int mom2 = 0; + for (auto& photon_mom : clusterparticle.mothers_as()) { + if (mom1 == 0) { + mom1 = photon_mom.pdgCode(); + } + if (mom1 != 0) { + mom2 = photon_mom.pdgCode(); + } + } + if (std::fabs(mom1) > 40 && std::fabs(mom1) > 0) + continue; + + if (cfgDebug) { + std::cout << "We have a REC prompt photon" << std::endl; + std::cout << "Photon gen status code: " << clusterparticle.getGenStatusCode() << std::endl; + std::cout << "Photon mom 1: " << mom1 << std::endl; + std::cout << "Photon mom 2: " << mom2 << std::endl; + } + if (std::abs(clusterparticle.getGenStatusCode()) > 19 && std::abs(clusterparticle.getGenStatusCode()) < 90) { + histos.fill(HIST("REC_True_Prompt_Trigger_Energy"), clusterparticle.e(), weight); TLorentzVector lRealPhoton; lRealPhoton.SetPxPyPzE(clusterparticle.px(), clusterparticle.py(), clusterparticle.pz(), clusterparticle.e()); double truepthadsum = GetPtHadSum(tracks, lRealPhoton, cfgMinR, cfgMaxR, false, false, false); truephotonPt = clusterparticle.e(); - histos.fill(HIST("REC_TrueTrigger_V_PtHadSum_Photon"), truephotonPt, truepthadsum); + histos.fill(HIST("REC_TrueTrigger_V_PtHadSum_Photon"), truephotonPt, truepthadsum, weight); } } // photon check } // clusterparticle loop + + if (cfgDebug) { + if (chPe > 0) { + if (photontrigger) { + if (chPe / mccluster.energy() < 0.50) { + goodgentrigger = true; + } + } + } + } if (goodgentrigger && photontrigger) { histos.fill(HIST("REC_Trigger_Purity"), 0.5); histos.fill(HIST("REC_Trigger_Energy_GOOD"), mccluster.energy()); + histos.fill(HIST("REC_Trigger_Purity_v_Energy"), 0.5, mccluster.energy()); } if (goodgentrigger && !photontrigger) { histos.fill(HIST("REC_Trigger_Purity"), 1.5); histos.fill(HIST("REC_Trigger_Energy_MISS"), mccluster.energy()); + histos.fill(HIST("REC_Trigger_Purity_v_Energy"), 1.5, mccluster.energy()); } if (!goodgentrigger && photontrigger) { histos.fill(HIST("REC_Trigger_Purity"), 2.5); histos.fill(HIST("REC_Trigger_Energy_FAKE"), mccluster.energy()); + histos.fill(HIST("REC_Trigger_Purity_v_Energy"), 2.5, mccluster.energy()); } } // cluster loop @@ -589,10 +1027,31 @@ struct statPromptPhoton { for (auto& track : tracks) { bool sterntrigger = false; double sternPt = 0.0; - auto ogtrack = track.track_as(); - if (!trackSelection(ogtrack)) { - continue; + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(track, trackFilter)) { + continue; + } + } else { + auto ogtrack = track.track_as(); + if (!trackSelection(ogtrack)) { + continue; + } + if (!ogtrack.isGlobalTrack()) { + continue; + } + } + + // Do stuff with geometric cuts + double phiPrime = track.phi(); + if (track.sign() < 0) { + phiPrime = 2 * TMath::Pi() - phiPrime; } + + phiPrime = phiPrime + TMath::Pi() / 18.; + phiPrime = fmod(phiPrime, 2 * TMath::Pi() / 18.); + histos.fill(HIST("REC_Track_PhiPrime_Pt"), phiPrime, track.pt()); + histos.fill(HIST("REC_Track_Pt"), track.pt()); + histos.fill(HIST("REC_Track_Phi"), track.phi()); if (clustertrigger) { histos.fill(HIST("REC_TrackPhi_photontrigger"), track.phi()); histos.fill(HIST("REC_TrackEta_photontrigger"), track.eta()); @@ -603,13 +1062,294 @@ struct statPromptPhoton { sternPt = track.pt(); } } + double pthadsum = GetPtHadSum(tracks, track, cfgMinR, cfgMaxR, true, false, true); + histos.fill(HIST("REC_Trigger_V_PtHadSum_Nch"), sternPt, pthadsum, weight); + if (sterntrigger) { + bool doStern = true; + double sterncount = 1.0; + while (doStern) { + histos.fill(HIST("REC_Trigger_V_PtHadSum_Stern"), sterncount, pthadsum, (2.0 / sternPt) * weight); + if (sterncount < sternPt) { + sterncount++; + } else { + doStern = false; + } + } // While sternin' + } // stern trigger loop + } // track loop + + } // end of process + + PROCESS_SWITCH(statPromptPhoton, processMCRec_JE, "processJE MC data", false); + + int nEventsData = 0; + void processData(jfilteredDataCollisions::iterator const& collision, jfilteredClusters const& clusters, jDataTrackCandidates const& tracks, soa::Join const&, TrackCandidates const&, BcCandidates const&, jEMCtracks const& emctracks) + { + nEventsData++; + if (cfgDebug) { + if (nEventsData == 1) { + std::cout << "Starting Data Processing: " << nEventsData << std::endl; + } + if ((nEventsData + 1) % 10000 == 0) { + std::cout << "Processed Data Events: " << nEventsData << std::endl; + std::cout << "Events Trigger Bit: " << collision.triggerSel() << std::endl; + std::cout << "Trigger Mask Bit: " << triggerMaskBits[0] << std::endl; + std::cout << "Trigger Mask Cfg Line: " << cfgTriggerMasks << std::endl; + } + } + + histos.fill(HIST("DATA_nEvents"), 0.5); + + // required cuts + if (fabs(collision.posZ()) > cfgVtxCut) + return; + if (!collision.sel8()) + return; + + histos.fill(HIST("DATA_nEvents"), 1.5); + if (cfgEmcTrigger) { + if (!collision.isEmcalReadout()) + return; + } + + histos.fill(HIST("DATA_nEvents"), 2.5); + + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + + histos.fill(HIST("DATA_nEvents"), 3.5); + + bool noTrk = true; + for (auto& track : tracks) { + + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(track, trackFilter)) { + continue; + } + } else { + auto ogtrack = track.track_as(); + if (!trackSelection(ogtrack)) { + continue; + } + if (!ogtrack.isGlobalTrack()) { + continue; + } + } + noTrk = false; + break; + } + if (noTrk) + return; + + // now we do clusters + bool clustertrigger = false; + for (auto& cluster : clusters) { + histos.fill(HIST("DATA_M02_BC"), cluster.m02()); + if (cluster.m02() < cfgLowM02) + continue; + if (cluster.m02() > cfgHighM02) + continue; + if (cluster.energy() < cfgLowClusterE) + continue; + if (cluster.energy() > cfgHighClusterE) + continue; + if (fabs(cluster.eta()) > cfgtrkMaxEta) + continue; + + histos.fill(HIST("DATA_Cluster_QA"), 0.5); + histos.fill(HIST("DATA_M02_AC"), cluster.m02()); + histos.fill(HIST("DATA_All_Energy"), cluster.energy()); + histos.fill(HIST("DATA_ClusterPhi"), cluster.phi()); + histos.fill(HIST("DATA_ClusterEta"), cluster.eta()); + + bool photontrigger = false; // is a neutral cluster + bool chargetrigger = false; // is definitely not a neutral cluster + auto tracksofcluster = cluster.matchedTracks_as>(); + + ///*GEOMETRICAL CUT*/// + + double phiPrimeC = cluster.phi(); + phiPrimeC = phiPrimeC + TMath::Pi() / 18.; + phiPrimeC = fmod(phiPrimeC, 2 * TMath::Pi() / 18.); + double ptC = cluster.energy(); + bool geocut = false; + histos.fill(HIST("DATA_Cluster_PhiPrime_Pt"), phiPrimeC, cluster.energy()); + if (phiPrimeC > (0.12 / ptC + TMath::Pi() / 18. + 0.035) || + phiPrimeC < (0.1 / ptC / ptC + TMath::Pi() / 18. - 0.025)) { + geocut = false; + } else { + geocut = true; + } + + if (cfgGeoCut) { + if (geocut) { + histos.fill(HIST("DATA_Cluster_PhiPrime_Pt_C"), phiPrimeC, cluster.energy()); + continue; + } + } + + histos.fill(HIST("DATA_Cluster_PhiPrime_Pt_AC"), phiPrimeC, cluster.energy()); + + ///*GEOMETRICAL CUT*/// + + ///*CHECK FOR PHOTON CANDIDATE*/// + + // first, we check if veto is required + double sumptT = 0; + bool clusterqa = false; + for (auto& ctrack : tracksofcluster) { + double etaT, phiT; + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(ctrack, trackFilter)) { + continue; + } + auto emctracksPerTrack = emctracks.sliceBy(EMCTrackPerTrack, ctrack.globalIndex()); + auto emctrack = emctracksPerTrack.iteratorAt(0); + etaT = emctrack.etaEmcal(); + phiT = emctrack.phiEmcal(); + } else { + auto ogtrack = ctrack.track_as(); + if (!trackSelection(ogtrack)) { + continue; + } + if (!ogtrack.isGlobalTrack()) { + continue; + } + etaT = ogtrack.trackEtaEmcal(); + phiT = ogtrack.trackPhiEmcal(); + } + + double etaC = cluster.eta(); + double phiC = cluster.phi(); + double ptT = ctrack.pt(); + bool etatrigger = false; + bool phitrigger = false; + double phidiff = TVector2::Phi_mpi_pi(cluster.phi() - ctrack.phi()); + double etadiff = cluster.eta() - ctrack.eta(); + + if (cfgPtClusterCut) { + if (fabs(etaT - etaC) < (0.010 + pow(ptT + 4.07, -2.5))) { + etatrigger = true; + } + + if (fabs(TVector2::Phi_mpi_pi(phiT - phiC)) < (0.015 + pow(ptT + 3.65, -2.0))) { + phitrigger = true; + } + } else { + if (fabs(etadiff) < 0.05) { + etatrigger = true; + } + + if (fabs(phidiff) < 0.05) { + phitrigger = true; + } + } + + if (etatrigger && phitrigger) { + chargetrigger = true; + sumptT += ptT; + } + if (chargetrigger) { + if (!clusterqa) { + histos.fill(HIST("DATA_Cluster_QA"), 1.5); + clusterqa = true; + } + } + histos.fill(HIST("DATA_Track_v_Cluster_Phi"), phidiff); + histos.fill(HIST("DATA_Track_v_Cluster_Eta"), etadiff); + histos.fill(HIST("DATA_Track_v_Cluster_Phi_Eta"), phidiff, etadiff); + + } // track of cluster loop + + if (chargetrigger && sumptT > 0) { + double cluster_over_sumptT = cluster.energy() / sumptT; + histos.fill(HIST("DATA_SumPt_BC"), cluster_over_sumptT); + if (cluster_over_sumptT < 1.7) { + histos.fill(HIST("DATA_Cluster_QA"), 2.5); // veto fails, cluster is charged + } else { + histos.fill(HIST("DATA_Cluster_QA"), 3.5); // veto is good, cluster is converted to neutral cluster + chargetrigger = false; + histos.fill(HIST("DATA_SumPt_AC"), cluster_over_sumptT); + } + } // sumptT check + + if (!chargetrigger) { + photontrigger = true; + } + + ///*CHECK FOR PHOTON CANDIDATE*/// + + ///*CALCULATE PTHAD SUM*/// + + if (photontrigger) { // if no charge trigger, cluster is good! + histos.fill(HIST("DATA_Cluster_QA"), 4.5); + clustertrigger = true; + double pthadsum = GetPtHadSum(tracks, cluster, cfgMinR, cfgMaxR, false, false, true); + histos.fill(HIST("DATA_Trigger_V_PtHadSum_Photon"), cluster.energy(), pthadsum); + histos.fill(HIST("DATA_PtHadSum_Photon"), pthadsum); + histos.fill(HIST("DATA_Trigger_Energy"), cluster.energy()); + } + + ///*CALCULATE PTHAD SUM*/// + + } // cluster loop + + ///*CALCULATE STERNHEIMER*/// + + for (auto& track : tracks) { + bool sterntrigger = false; + double sternPt = 0.0; + if (cfgJETracks) { + if (!jetderiveddatautilities::selectTrack(track, trackFilter)) { + continue; + } + } else { + auto ogtrack = track.track_as(); + if (!trackSelection(ogtrack)) { + continue; + } + if (!ogtrack.isGlobalTrack()) { + continue; + } + } + + // Do stuff with geometric cuts + double phiPrime = track.phi(); + if (track.sign() < 0) { + phiPrime = 2 * TMath::Pi() - phiPrime; + } + + phiPrime = phiPrime + TMath::Pi() / 18.; + phiPrime = fmod(phiPrime, 2 * TMath::Pi() / 18.); + double pt = track.pt(); + if (phiPrime > (0.12 / pt + TMath::Pi() / 18. + 0.035) || + phiPrime < (0.1 / pt / pt + TMath::Pi() / 18. - 0.025)) { + histos.fill(HIST("DATA_Track_PhiPrime_Pt"), phiPrime, track.pt()); + } // geo cut + // Done with geometric cuts + + histos.fill(HIST("DATA_Track_Pt"), track.pt()); + histos.fill(HIST("DATA_Track_Phi"), track.phi()); + if (clustertrigger) { + histos.fill(HIST("DATA_TrackPhi_photontrigger"), track.phi()); + histos.fill(HIST("DATA_TrackEta_photontrigger"), track.eta()); + } + if (track.pt() > cfgMinTrig && track.pt() < cfgMaxTrig) { + if (fabs(track.eta()) <= cfgtrkMaxEta) { + sterntrigger = true; + sternPt = track.pt(); + } + } if (sterntrigger) { bool doStern = true; double sterncount = 1.0; + double pthadsum = GetPtHadSum(tracks, track, cfgMinR, cfgMaxR, true, false, true); + histos.fill(HIST("DATA_Trigger_V_PtHadSum_Nch"), sternPt, pthadsum); while (doStern) { double pthadsum = GetPtHadSum(tracks, track, cfgMinR, cfgMaxR, true, false, true); - histos.fill(HIST("REC_Trigger_V_PtHadSum_Stern"), sterncount, pthadsum, 2.0 / sternPt); + histos.fill(HIST("DATA_Trigger_V_PtHadSum_Stern"), sterncount, pthadsum, 2.0 / sternPt); if (sterncount < sternPt) { sterncount++; } else { @@ -619,9 +1359,11 @@ struct statPromptPhoton { } // stern trigger loop } // track loop + ///*CALCULATE STERNHEIMER*/// + } // end of process - PROCESS_SWITCH(statPromptPhoton, processMCRec_JE, "processJE MC data", false); + PROCESS_SWITCH(statPromptPhoton, processData, "processJE data", false); }; // end of main struct diff --git a/PWGJE/Tasks/taskEmcExtensiveMcQa.cxx b/PWGJE/Tasks/taskEmcExtensiveMcQa.cxx new file mode 100644 index 00000000000..002e2f3c711 --- /dev/null +++ b/PWGJE/Tasks/taskEmcExtensiveMcQa.cxx @@ -0,0 +1,195 @@ +// 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. + +/// \file taskEmcExtensiveMcQa.cxx +/// \brief Exensive monitoring task for EMCal clusters in MC +/// \author Marvin Hemmer , Goethe University Frankfurt +/// \since 31.07.2025 + +#include "PWGJE/DataModel/EMCALClusters.h" +// HF headers for event selection +#include "PWGHF/Core/CentralityEstimation.h" +#include "PWGHF/Utils/utilsEvSelHf.h" + +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/DataModel/EventSelection.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::hf_evsel; +using namespace o2::hf_centrality; +using CollisionEvSels = o2::soa::Join; +using BcEvSelIt = o2::soa::Join::iterator; +using SelectedClusters = o2::soa::Filtered>; + +enum PoI { + kPhoton = 0, + kElectron = 1, + kHadron = 2, + kNPoI = 3 +}; + +/// \struct TaskEmcExtensiveMcQa +struct TaskEmcExtensiveMcQa { + + static constexpr int NSM = 20; // there 20 supermodlues for the EMCal + std::array arrPoIPDG = {22, 11}; + + SliceCache cache; + Preslice psClusterPerCollision = o2::aod::emcalcluster::collisionId; + Preslice perCluster = o2::aod::emcalclustercell::emcalclusterId; + + HistogramRegistry mHistManager{"EMCalExtensiveMCQAHistograms"}; + + o2::emcal::Geometry* mGeometry = nullptr; + o2::framework::Service ccdb; + + ctpRateFetcher rateFetcher; + HfEventSelection hfEvSel; + HfEventSelectionMc hfEvSelMc; + + // configurable parameters + Configurable applyEvSels{"applyEvSels", true, "Flag to apply event selection."}; + Configurable clusterDefinition{"clusterDefinition", 10, "cluster definition to be selected, e.g. 10=kV3Default"}; + Configurable ctpFetcherSource{"ctpFetcherSource", "T0VTX", "Source for CTP rate fetching, e.g. T0VTX, T0CE, T0SC, ZNC (hadronic)"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + // configurable axis + ConfigurableAxis nClustersBinning{"nClustersBinning", {201, -0.5, 200.5}, "binning for the number of clusters"}; + + ConfigurableAxis clusterEnergy{"clusterEnergy", {100, 0., 10}, "binning for the cluster energy in GeV"}; + ConfigurableAxis clusterTimeBinning{"clusterTimeBinning", {1500, -600, 900}, "binning for the cluster time in ns"}; + ConfigurableAxis clusterM02{"clusterM02", {100, 0., 2.0}, "binning for the cluster M02"}; + ConfigurableAxis clusterNCellBinning{"clusterNCellBinning", {100, 0.5, 100.5}, "binning for the number of cells per cluster"}; + ConfigurableAxis clusterOriginRadius{"clusterOriginRadius", {225, 0., 450}, "binning for the radial original point of the main contributor of a cluster"}; + + std::vector mCellTime; + + /// \brief Create output histograms and initialize geometry + void init(InitContext const&) + { + // load geometry just in case we need it + mGeometry = o2::emcal::Geometry::GetInstanceFromRunNumber(300000); + + // create common axes + const AxisSpec numberClustersAxis{nClustersBinning, "#it{N}_{cl}/ #it{N}_{event}"}; + const AxisSpec axisParticle = {PoI::kNPoI, -0.5f, +PoI::kNPoI - 0.5f, ""}; + const AxisSpec axisEnergy{clusterEnergy, "#it{E}_{cl} (GeV)"}; + const AxisSpec axisTime{clusterTimeBinning, "#it{t}_{cl} (ns)"}; + const AxisSpec axisM02{clusterM02, "#it{M}_{02}"}; + const AxisSpec axisNCell{clusterNCellBinning, "#it{N}_{cells}"}; + const AxisSpec axisRadius{clusterOriginRadius, "#it{R}_{origin} (cm)"}; + + // create histograms + + // event properties + mHistManager.add("numberOfClustersEvents", "number of clusters per event (selected events)", HistType::kTH1D, {numberClustersAxis}); + + // cluster properties (matched clusters) + mHistManager.add("hSparseClusterQA", "THn for Cluster QA", HistType::kTHnSparseF, {axisEnergy, axisTime, axisM02, axisNCell, axisRadius, axisParticle}); + mHistManager.add("clusterEtaPhi", "Eta and phi of cluster", HistType::kTH2F, {{140, -0.7, 0.7}, {360, 0, o2::constants::math::TwoPI}}); + + hfEvSel.addHistograms(mHistManager); + + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + } + + template + bool isCollSelected(const Coll& coll) + { + float cent{-1.f}; + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(coll, cent, ccdb, mHistManager); + /// monitor the satisfied event selections + hfEvSel.fillHistograms(coll, rejectionMask, cent); + return rejectionMask == 0; + } + + /// \brief returns the PoI type of a mcparticle + /// \param mcparticle is the mcparticle we want to find the PoI type + /// \param mcparticles table containing the mcparticles + /// \return PoI type of the given mcparticle + template + int findPoIType(T const& mcparticle, TMCs const& mcparticles) + { + if (!mcparticle.has_mothers()) { + return -1; + } + + int motherid = mcparticle.mothersIds()[0]; + auto mother = mcparticles.iteratorAt(motherid); + auto it = std::find(arrPoIPDG.begin(), arrPoIPDG.end(), std::abs(mother.pdgCode())); + if (it != arrPoIPDG.end()) { + return *it; + } else { + return PoI::kHadron; + } + } + + Filter clusterDefinitionSelection = (o2::aod::emcalcluster::definition == clusterDefinition); + + /// \brief Process EMCAL clusters that are matched to a collisions + void processCollisions(CollisionEvSels const& collisions, SelectedClusters const& clusters, McParticles const& mcparticles) + { + + for (const auto& collision : collisions) { + if (applyEvSels && !isCollSelected(collision)) { + continue; + } + + auto groupedClusters = clusters.sliceBy(psClusterPerCollision, collision.globalIndex()); + mHistManager.fill(HIST("numberOfClustersEvents"), groupedClusters.size()); + + for (const auto& cluster : groupedClusters) { + mHistManager.fill(HIST("clusterEtaPhi"), cluster.eta(), cluster.phi()); + // axisEnergy, axisTime, axisM02, axisNCell, axisRadius, axisParticle + if (cluster.mcParticle().size() == 0) { + LOG(info) << "Somehow cluster.mcParticle().size() == 0!"; + continue; + } + auto mainMcParticle = cluster.mcParticle_as()[0]; + float radius = std::hypot(mainMcParticle.px(), mainMcParticle.py()); + mHistManager.fill(HIST("hSparseClusterQA"), cluster.energy(), cluster.time(), cluster.m02(), cluster.nCells(), radius, findPoIType(mainMcParticle, mcparticles)); + } + } + } + PROCESS_SWITCH(TaskEmcExtensiveMcQa, processCollisions, "Process clusters from collision", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{ + adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/PWGJE/Tasks/trackEfficiency.cxx b/PWGJE/Tasks/trackEfficiency.cxx index 47d5ce4ea17..b82a1ee229a 100644 --- a/PWGJE/Tasks/trackEfficiency.cxx +++ b/PWGJE/Tasks/trackEfficiency.cxx @@ -9,39 +9,37 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// track efficiency task (global tracks) -// +/// \file trackEfficiency.cxx /// \author Aimeric Landou +/// \brief task that creates the histograms necessary for computation of efficiency and purity functions in offline postprocess macros; also can make mcparticle and track QC histograms -#include -#include -#include +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include +#include +#include +#include +#include +#include -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGJE/DataModel/Jet.h" - -#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -struct TrackEfficiencyJets { +struct TrackEfficiency { Service pdg; using JetParticlesWithOriginal = soa::Join; @@ -50,10 +48,12 @@ struct TrackEfficiencyJets { Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections; other option: uniformTracks"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "flag to choose to reject min. bias gap events"}; // Tracking efficiency process function configurables: Configurable checkPrimaryPart{"checkPrimaryPart", true, "0: doesn't check mcparticle.isPhysicalPrimary() - 1: checks particle.isPhysicalPrimary()"}; Configurable checkCentrality{"checkCentrality", false, ""}; + Configurable checkOccupancy{"checkOccupancy", false, "check occupancy only in general purpose Pb-Pb MC, default as false"}; Configurable acceptSplitCollisions{"acceptSplitCollisions", 0, "0: only look at mcCollisions that are not split; 1: accept split mcCollisions, 2: accept split mcCollisions but only look at the first reco collision associated with it"}; Configurable trackEtaAcceptanceCountQA{"trackEtaAcceptanceCountQA", 0.9, "eta acceptance"}; // removed from actual cuts for now because all the histograms have an eta axis Configurable centralityMin{"centralityMin", -999, ""}; @@ -70,54 +70,92 @@ struct TrackEfficiencyJets { Configurable trackOccupancyInTimeRangeMax{"trackOccupancyInTimeRangeMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range; only applied for reconstructed tracks, not mc particles"}; Configurable trackOccupancyInTimeRangeMin{"trackOccupancyInTimeRangeMin", -999999, "minimum occupancy of tracks in neighbouring collisions in a given time range; only applied for reconstructed tracks, not mc particles"}; - int eventSelection = -1; + Configurable> centralityBinning{"centralityBinning", {0., 10., 50., 70.}, "binning of centrality histograms"}; + Configurable intRateNBins{"intRateNBins", 50, "number of bins for interaction rate axis"}; + Configurable intRateMax{"intRateMax", 50000.0, "maximum value of interaction rate axis"}; + Configurable phiEffNBins{"phiEffNBins", 200, "number of bins for phi axis in efficiency plots"}; + Configurable etaEffNBins{"etaEffNBins", 200, "number of bins for eta axis in efficiency plots"}; + + Configurable ptHatMin{"ptHatMin", 5, "min pT hat of collisions"}; + Configurable ptHatMax{"ptHatMax", 300, "max pT hat of collisions"}; + Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; + Configurable pTHatMaxFractionMCD{"pTHatMaxFractionMCD", 999.0, "maximum fraction of hard scattering for reconstructed track acceptance in MC"}; + + Configurable getPtHatFromHepMCXSection{"getPtHatFromHepMCXSection", true, "test configurable, configurable should be removed once well tested"}; + Configurable useTrueTrackWeight{"useTrueTrackWeight", true, "test configurable, should be set to 1 then config removed once well tested"}; + + std::vector eventSelectionBits; int trackSelection = -1; + enum AcceptSplitCollisionsOptions { + NonSplitOnly = 0, + SplitOkCheckAnyAssocColl, // 1 + SplitOkCheckFirstAssocCollOnly // 2 + }; + bool isChargedParticle(int code) { + const float chargeUnit = 3.; auto p = pdg->GetParticle(code); auto charge = 0.; if (p != nullptr) { charge = p->Charge(); } - return std::abs(charge) >= 3.; + return std::abs(charge) >= chargeUnit; } - template - void fillTrackHistograms(T const& collision, U const& tracks, float weight = 1.0) + template + void fillTrackHistograms(TCollision const& collision, TTracks const& tracks, float weight = 1.0) { for (auto const& track : tracks) { if (!(jetderiveddatautilities::selectTrack(track, trackSelection) && jetderiveddatautilities::selectTrackDcaZ(track, trackDcaZmax))) { continue; } - registry.fill(HIST("h2_centrality_track_pt"), collision.centrality(), track.pt(), weight); - registry.fill(HIST("h2_centrality_track_eta"), collision.centrality(), track.eta(), weight); - registry.fill(HIST("h2_centrality_track_phi"), collision.centrality(), track.phi(), weight); - registry.fill(HIST("h2_centrality_track_energy"), collision.centrality(), track.energy(), weight); + + float simPtRef = 10.; + float pTHat = simPtRef / (std::pow(weight, 1.0 / pTHatExponent)); + if (track.pt() > pTHatMaxFractionMCD * pTHat) { + continue; + } + + registry.fill(HIST("h2_centrality_track_pt"), collision.centFT0M(), track.pt(), weight); + registry.fill(HIST("h2_centrality_track_eta"), collision.centFT0M(), track.eta(), weight); + registry.fill(HIST("h2_centrality_track_phi"), collision.centFT0M(), track.phi(), weight); + registry.fill(HIST("h2_centrality_track_energy"), collision.centFT0M(), track.energy(), weight); registry.fill(HIST("h2_track_pt_track_sigma1overpt"), track.pt(), track.sigma1Pt(), weight); registry.fill(HIST("h2_track_pt_track_sigmapt"), track.pt(), track.sigma1Pt() * track.pt(), weight); registry.fill(HIST("h2_track_pt_high_track_sigma1overpt"), track.pt(), track.sigma1Pt(), weight); registry.fill(HIST("h2_track_pt_high_track_sigmapt"), track.pt(), track.sigma1Pt() * track.pt(), weight); + registry.fill(HIST("h3_intrate_centrality_track_pt"), collision.hadronicRate(), collision.centFT0M(), track.pt(), weight); } } - template - void fillParticlesHistograms(T const& collision, U const& mcparticles, float weight = 1.0) + template + void fillParticlesHistograms(TCollision const& collision, TParticles const& mcparticles, TTracks tracks, float weight = 1.0) { for (auto const& mcparticle : mcparticles) { - registry.fill(HIST("h2_centrality_particle_pt"), collision.centrality(), mcparticle.pt(), weight); - registry.fill(HIST("h2_centrality_particle_eta"), collision.centrality(), mcparticle.eta(), weight); - registry.fill(HIST("h2_centrality_particle_phi"), collision.centrality(), mcparticle.phi(), weight); - registry.fill(HIST("h2_centrality_particle_energy"), collision.centrality(), mcparticle.energy(), weight); + registry.fill(HIST("h2_centrality_particle_pt"), collision.centFT0M(), mcparticle.pt(), weight); + registry.fill(HIST("h2_centrality_particle_eta"), collision.centFT0M(), mcparticle.eta(), weight); + registry.fill(HIST("h2_centrality_particle_phi"), collision.centFT0M(), mcparticle.phi(), weight); + registry.fill(HIST("h2_centrality_particle_energy"), collision.centFT0M(), mcparticle.energy(), weight); + registry.fill(HIST("h3_intrate_centrality_particle_pt"), collision.hadronicRate(), collision.centFT0M(), mcparticle.pt(), weight); + for (auto const& track : tracks) { + registry.fill(HIST("h2_particle_pt_track_pt_deltapt"), mcparticle.pt(), mcparticle.pt() - track.pt(), weight); + registry.fill(HIST("h2_particle_pt_track_pt_deltaptoverparticlept"), mcparticle.pt(), (mcparticle.pt() - track.pt()) / mcparticle.pt(), weight); + } } } void init(o2::framework::InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + if (!(acceptSplitCollisions == NonSplitOnly || acceptSplitCollisions == SplitOkCheckAnyAssocColl || acceptSplitCollisions == SplitOkCheckFirstAssocCollOnly)) { + LOGF(fatal, "Configurable acceptSplitCollisions has wrong input value; stopping workflow"); + } + + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); - if (doprocessEFficiencyPurity) { + if (doprocessEFficiencyPurity || doprocessEFficiencyPurityWeighted) { registry.add("hMcCollCutsCounts", "McColl cuts count checks", {HistType::kTH1F, {{10, 0., 10.}}}); registry.get(HIST("hMcCollCutsCounts"))->GetXaxis()->SetBinLabel(1, "allMcColl"); @@ -126,6 +164,10 @@ struct TrackEfficiencyJets { registry.get(HIST("hMcCollCutsCounts"))->GetXaxis()->SetBinLabel(4, "splitColl"); registry.get(HIST("hMcCollCutsCounts"))->GetXaxis()->SetBinLabel(5, "recoCollEvtSel"); registry.get(HIST("hMcCollCutsCounts"))->GetXaxis()->SetBinLabel(6, "centralityCut"); + registry.get(HIST("hMcCollCutsCounts"))->GetXaxis()->SetBinLabel(7, "ptHatCut"); + if (checkOccupancy) { + registry.get(HIST("hMcCollCutsCounts"))->GetXaxis()->SetBinLabel(8, "occupancyCut"); + } registry.add("hMcPartCutsCounts", "McPart cuts count checks", {HistType::kTH1F, {{10, 0., 10.}}}); registry.get(HIST("hMcPartCutsCounts"))->GetXaxis()->SetBinLabel(1, "allPartsInSelMcColl"); @@ -137,50 +179,59 @@ struct TrackEfficiencyJets { registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(1, "allTracksInSelColl"); registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(2, "trackSel"); registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(3, "hasMcParticle"); - registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(4, "mcPartIsPrimary"); - registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(5, "etaAcc"); // not actually applied here but it will give an idea of what will be done in the post processing - AxisSpec ptAxis_eff = {nBinsLowPt, 0., 10., "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec ptAxisHigh_eff = {18, 10., 100., "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec etaAxis_eff = {100, -1.0, 1.0, "#eta"}; - AxisSpec phiAxis_eff = {200, -1.0, 7., "#phi"}; + if (doprocessEFficiencyPurity) { + registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(4, "mcPartIsPrimary"); + registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(5, "etaAcc"); // not actually applied here but it will give an idea of what will be done in the post processing + } + if (doprocessEFficiencyPurityWeighted) { + registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(4, "ptHatMaxFraction"); + registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(5, "mcPartIsPrimary"); + registry.get(HIST("hTrackCutsCounts"))->GetXaxis()->SetBinLabel(6, "etaAcc"); // not actually applied here but it will give an idea of what will be done in the post processing + } + + AxisSpec ptAxisEff = {nBinsLowPt, 0., 10., "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec ptAxisHighEff = {18, 10., 100., "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec etaAxisEff = {etaEffNBins, -1.0, 1.0, "#eta"}; + AxisSpec phiAxisEff = {phiEffNBins, -1.0, 7., "#phi"}; // ptAxisLow - registry.add("h3_particle_pt_particle_eta_particle_phi_mcpartofinterest", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_particle_pt_particle_eta_particle_phi_mcpart_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); + registry.add("h3_particle_pt_particle_eta_particle_phi_mcpartofinterest", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_particle_pt_particle_eta_particle_phi_mcpart_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); - registry.add("h3_track_pt_track_eta_track_phi_nonassociatedtrack", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_track_pt_track_eta_track_phi_associatedtrack_primary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_track_pt_track_eta_track_phi_associatedtrack_nonprimary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_track_pt_track_eta_track_phi_associatedtrack_split_primary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_track_pt_track_eta_track_phi_associatedtrack_split_nonprimary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); + registry.add("h3_track_pt_track_eta_track_phi_nonassociatedtrack", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_track_pt_track_eta_track_phi_associatedtrack_primary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_track_pt_track_eta_track_phi_associatedtrack_nonprimary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_track_pt_track_eta_track_phi_associatedtrack_split_primary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_track_pt_track_eta_track_phi_associatedtrack_split_nonprimary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); - registry.add("h3_particle_pt_particle_eta_particle_phi_associatedtrack_primary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_particle_pt_particle_eta_particle_phi_associatedtrack_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_particle_pt_particle_eta_particle_phi_associatedtrack_split_primary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_particle_pt_particle_eta_particle_phi_associatedtrack_split_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxis_eff, etaAxis_eff, phiAxis_eff}}); + registry.add("h3_particle_pt_particle_eta_particle_phi_associatedtrack_primary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_particle_pt_particle_eta_particle_phi_associatedtrack_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_particle_pt_particle_eta_particle_phi_associatedtrack_split_primary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_particle_pt_particle_eta_particle_phi_associatedtrack_split_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisEff, etaAxisEff, phiAxisEff}}); - registry.add("h2_particle_pt_track_pt_residual_associatedtrack_primary", "(#it{p}_{T, mcpart} - #it{p}_{T, track}) / #it{p}_{T, mcpart}; #it{p}_{T, mcpart} (GeV/#it{c})", {HistType::kTH2F, {ptAxis_eff, {200, -1., 1.}}}); + registry.add("h2_particle_pt_track_pt_residual_associatedtrack_primary", "(#it{p}_{T, mcpart} - #it{p}_{T, track}) / #it{p}_{T, mcpart}; #it{p}_{T, mcpart} (GeV/#it{c})", {HistType::kTH2F, {ptAxisEff, {200, -1., 1.}}}); // ptAxisHigh - registry.add("h3_particle_pt_high_particle_eta_particle_phi_mcpartofinterest", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); + registry.add("h3_particle_pt_high_particle_eta_particle_phi_mcpartofinterest", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); - registry.add("h3_track_pt_high_track_eta_track_phi_nonassociatedtrack", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_track_pt_high_track_eta_track_phi_associatedtrack_primary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_track_pt_high_track_eta_track_phi_associatedtrack_nonprimary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_track_pt_high_track_eta_track_phi_associatedtrack_split_primary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_track_pt_high_track_eta_track_phi_associatedtrack_split_nonprimary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); + registry.add("h3_track_pt_high_track_eta_track_phi_nonassociatedtrack", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_track_pt_high_track_eta_track_phi_associatedtrack_primary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_track_pt_high_track_eta_track_phi_associatedtrack_nonprimary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_track_pt_high_track_eta_track_phi_associatedtrack_split_primary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_track_pt_high_track_eta_track_phi_associatedtrack_split_nonprimary", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); - registry.add("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_primary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_split_primary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); - registry.add("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_split_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHigh_eff, etaAxis_eff, phiAxis_eff}}); + registry.add("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_primary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_split_primary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); + registry.add("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_split_nonprimary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxisHighEff, etaAxisEff, phiAxisEff}}); - registry.add("h2_particle_pt_high_track_pt_high_residual_associatedtrack_primary", "(#it{p}_{T, mcpart} - #it{p}_{T, track}) / #it{p}_{T, mcpart}; #it{p}_{T, mcpart} (GeV/#it{c})", {HistType::kTH2F, {ptAxisHigh_eff, {200, -1., 1.}}}); + registry.add("h2_particle_pt_high_track_pt_high_residual_associatedtrack_primary", "(#it{p}_{T, mcpart} - #it{p}_{T, track}) / #it{p}_{T, mcpart}; #it{p}_{T, mcpart} (GeV/#it{c})", {HistType::kTH2F, {ptAxisHighEff, {200, -1., 1.}}}); } - if (doprocessTracks || doprocessTracksWeighted) { - AxisSpec centAxis = {121, -10., 111., "centrality (%)"}; + if (doprocessTracksFromData || doprocessTracksFromMc || doprocessTracksFromMcWeighted) { + AxisSpec centAxis = {centralityBinning, "centrality (%)"}; + AxisSpec intRateAxis = {intRateNBins, 0., intRateMax, "int. rate (kHz)"}; registry.add("h2_centrality_track_pt", "centrality vs track pT; centrality; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {centAxis, {200, 0., 200.}}}); registry.add("h2_centrality_track_eta", "centrality vs track #eta; centrality; #eta_{track}", {HistType::kTH2F, {centAxis, {100, -1.0, 1.0}}}); registry.add("h2_centrality_track_phi", "centrality vs track #varphi; centrality; #varphi_{track}", {HistType::kTH2F, {centAxis, {160, -1.0, 7.}}}); @@ -189,31 +240,44 @@ struct TrackEfficiencyJets { registry.add("h2_track_pt_high_track_sigmapt", "#sigma(#it{p}_{T})/#it{p}_{T}; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {{90, 10., 100.}, {100000, 0.0, 100.0}}}); registry.add("h2_track_pt_track_sigma1overpt", "#sigma(1/#it{p}_{T}); #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {{100, 0., 10.}, {1000, 0.0, 10.0}}}); registry.add("h2_track_pt_high_track_sigma1overpt", "#sigma(1/#it{p}_{T}); #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {{90, 10., 100.}, {1000, 0.0, 10.0}}}); + registry.add("h3_intrate_centrality_track_pt", "interaction rate vs centrality vs track pT; int. rate; centrality; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH3F, {intRateAxis, centAxis, {200, 0., 200.}}}); } if (doprocessParticles || doprocessParticlesWeighted) { - AxisSpec centAxis = {121, -10., 111., "centrality (%)"}; - registry.add("h2_centrality_particle_pt", "centrality vs track pT; centrality; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {centAxis, {200, 0., 200.}}}); - registry.add("h2_centrality_particle_eta", "centrality vs track #eta; centrality; #eta_{track}", {HistType::kTH2F, {centAxis, {100, -1.0, 1.0}}}); - registry.add("h2_centrality_particle_phi", "centrality vs track #varphi; centrality; #varphi_{track}", {HistType::kTH2F, {centAxis, {160, -1.0, 7.}}}); - registry.add("h2_centrality_particle_energy", "centrality vs track energy; centrality; Energy GeV", {HistType::kTH2F, {centAxis, {100, 0.0, 100.0}}}); + AxisSpec centAxis = {centralityBinning, "centrality (%)"}; + AxisSpec intRateAxis = {intRateNBins, 0., intRateMax, "int. rate (kHz)"}; + registry.add("h2_centrality_particle_pt", "centrality vs particle pT; centrality; #it{p}_{T,part} (GeV/#it{c})", {HistType::kTH2F, {centAxis, {200, 0., 200.}}}); + registry.add("h2_centrality_particle_eta", "centrality vs particle #eta; centrality; #eta_{part}", {HistType::kTH2F, {centAxis, {100, -1.0, 1.0}}}); + registry.add("h2_centrality_particle_phi", "centrality vs particle #varphi; centrality; #varphi_{part}", {HistType::kTH2F, {centAxis, {160, -1.0, 7.}}}); + registry.add("h2_centrality_particle_energy", "centrality vs particle energy; centrality; Energy GeV", {HistType::kTH2F, {centAxis, {100, 0.0, 100.0}}}); + registry.add("h3_intrate_centrality_particle_pt", "interaction rate vs centrality vs particle pT; int. rate; centrality; #it{p}_{T,part} (GeV/#it{c})", {HistType::kTH3F, {intRateAxis, centAxis, {200, 0., 200.}}}); } - if (doprocessTracks || doprocessTracksWeighted) { - AxisSpec centAxis = {121, -10., 111., "centrality (%)"}; + if (doprocessCollisionsFromData || doprocessCollisionsFromMc || doprocessCollisionsFromMcWeighted) { + AxisSpec centAxis = {centralityBinning, "centrality (%)"}; registry.add("h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); registry.add("h2_centrality_collisions", "centrality vs collisions; centrality; collisions", {HistType::kTH2F, {centAxis, {4, 0.0, 4.0}}}); } - if (doprocessParticles || doprocessParticlesWeighted) { - AxisSpec centAxis = {121, -10., 111., "centrality (%)"}; + if (doprocessMcCollisions || doprocessMcCollisionsWeighted) { + AxisSpec centAxis = {centralityBinning, "centrality (%)"}; registry.add("h_mccollisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); registry.add("h2_centrality_mccollisions", "centrality vs mccollisions; centrality; collisions", {HistType::kTH2F, {centAxis, {4, 0.0, 4.0}}}); + registry.add("h2_mccollision_pthardfromweight_pthardfromhepmcxsection", "ptHard from weight vs ptHard from HepMCXSections; ptHard_weight; ptHard_hepmcxsections", {HistType::kTH2F, {{200, 0.0, 200.0}, {200, 0.0, 200.0}}}); } - if (doprocessTracksWeighted) { + + if (doprocessCollisionsFromMc || doprocessCollisionsFromMcWeighted) { + registry.add("h_fakecollisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + } + if (doprocessCollisionsFromMcWeighted) { + AxisSpec centAxis = {centralityBinning, "centrality (%)"}; registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + registry.add("h2_centrality_collisions_weighted", "centrality vs mccollisions; centrality; collisions", {HistType::kTH2F, {centAxis, {4, 0.0, 4.0}}}); } - if (doprocessParticlesWeighted) { + if (doprocessMcCollisionsWeighted) { + AxisSpec centAxis = {centralityBinning, "centrality (%)"}; registry.add("h_mccollisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + registry.add("h2_centrality_mccollisions_weighted", "centrality vs mccollisions; centrality; collisions", {HistType::kTH2F, {centAxis, {4, 0.0, 4.0}}}); + registry.add("h2_mccollision_pthardfromweight_pthardfromhepmcxsection_weighted", "ptHard from weight vs ptHard from HepMCXSections; ptHard_weight; ptHard_hepmcxsections", {HistType::kTH2F, {{200, 0.0, 200.0}, {200, 0.0, 200.0}}}); } } @@ -222,9 +286,10 @@ struct TrackEfficiencyJets { // filters for processTracks QA functions only: Filter trackCuts = (aod::jtrack::pt >= trackQAPtMin && aod::jtrack::pt < trackQAPtMax && aod::jtrack::eta > trackQAEtaMin && aod::jtrack::eta < trackQAEtaMax); Filter particleCuts = (aod::jmcparticle::pt >= trackQAPtMin && aod::jmcparticle::pt < trackQAPtMax && aod::jmcparticle::eta > trackQAEtaMin && aod::jmcparticle::eta < trackQAEtaMax); - Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centFT0M >= centralityMin && aod::jcollision::centFT0M < centralityMax); - void processEFficiencyPurity(aod::JetMcCollision const& mcCollision, + void processEFficiencyPurity(soa::Join::iterator const& mcCollision, + soa::Join const&, soa::SmallGroups const& collisions, // smallgroups gives only the collisions associated to the current mccollision, thanks to the mccollisionlabel pre-integrated in jetcollisionsmcd soa::Join const& jetTracks, JetParticlesWithOriginal const& jMcParticles) @@ -237,7 +302,7 @@ struct TrackEfficiencyJets { registry.fill(HIST("hMcCollCutsCounts"), 0.5); // all mcCollisions - if (!(abs(mcCollision.posZ()) < vertexZCut)) { + if (!(std::abs(mcCollision.posZ()) < vertexZCut)) { return; } registry.fill(HIST("hMcCollCutsCounts"), 1.5); // mcCollision.posZ() condition @@ -247,28 +312,35 @@ struct TrackEfficiencyJets { } registry.fill(HIST("hMcCollCutsCounts"), 2.5); // mcCollisions with at least one reconstructed collision - if (acceptSplitCollisions == 0 && collisions.size() > 1) { + if (acceptSplitCollisions == NonSplitOnly && collisions.size() > 1) { return; } registry.fill(HIST("hMcCollCutsCounts"), 3.5); // split mcCollisions condition bool hasSel8Coll = false; bool centralityCheck = false; - if (acceptSplitCollisions == 2) { // check only that the first reconstructed collision passes the check - if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelection)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + bool occupancyCheck = false; + if (acceptSplitCollisions == SplitOkCheckFirstAssocCollOnly || acceptSplitCollisions == NonSplitOnly) { // check only that the first reconstructed collision passes the check (for the NonSplitOnly case, there's only one associated collision) + if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split hasSel8Coll = true; } - if (!checkCentrality || ((centralityMin < collisions.begin().centrality()) && (collisions.begin().centrality() < centralityMax))) { // effect unclear if mcColl is split + if (!checkCentrality || ((centralityMin < collisions.begin().centFT0M()) && (collisions.begin().centFT0M() < centralityMax))) { // effect unclear if mcColl is split centralityCheck = true; } - } else { // check that at least one of the reconstructed collisions passes the checks - for (auto& collision : collisions) { - if (jetderiveddatautilities::selectCollision(collision, eventSelection)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + if (!checkOccupancy || ((trackOccupancyInTimeRangeMin < collisions.begin().trackOccupancyInTimeRange()) && (collisions.begin().trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMax))) { // check occupancy only in GP Pb-Pb MC + occupancyCheck = true; + } + } else if (acceptSplitCollisions == SplitOkCheckAnyAssocColl) { // check that at least one of the reconstructed collisions passes the checks + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split hasSel8Coll = true; } - if (!checkCentrality || ((centralityMin < collision.centrality()) && (collision.centrality() < centralityMax))) { // effect unclear if mcColl is split + if (!checkCentrality || ((centralityMin < collision.centFT0M()) && (collision.centFT0M() < centralityMax))) { // effect unclear if mcColl is split centralityCheck = true; } + if (!checkOccupancy || ((trackOccupancyInTimeRangeMin < collisions.begin().trackOccupancyInTimeRange()) && (collisions.begin().trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMax))) { // check occupancy only in GP Pb-Pb MC + occupancyCheck = true; + } } } if (!hasSel8Coll) { @@ -281,7 +353,20 @@ struct TrackEfficiencyJets { } registry.fill(HIST("hMcCollCutsCounts"), 5.5); // at least one of the reconstructed collisions associated with this mcCollision is selected with regard to centrality - for (auto& jMcParticle : jMcParticles) { + float pTHat = getPtHatFromHepMCXSection ? mcCollision.mcCollision_as>().ptHard() : 10. / (std::pow(mcCollision.weight(), 1.0 / pTHatExponent)); + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + registry.fill(HIST("hMcCollCutsCounts"), 6.5); // ptHat condition + + if (checkOccupancy) { + if (!occupancyCheck) { + return; + } + registry.fill(HIST("hMcCollCutsCounts"), 7.5); + } + + for (auto const& jMcParticle : jMcParticles) { registry.fill(HIST("hMcPartCutsCounts"), 0.5); // allPartsInSelMcColl if (!isChargedParticle(jMcParticle.pdgCode())) { @@ -300,26 +385,26 @@ struct TrackEfficiencyJets { registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_mcpartofinterest"), jMcParticle.pt(), jMcParticle.eta(), jMcParticle.phi()); - if ((abs(jMcParticle.eta()) < trackEtaAcceptanceCountQA)) { // removed from actual cuts for now because all the histograms have an eta axis - registry.fill(HIST("hMcPartCutsCounts"), 3.5); // etaAccept // not actually applied here but it will give an idea of what will be done in the post processing + if ((std::abs(jMcParticle.eta()) < trackEtaAcceptanceCountQA)) { // removed from actual cuts for now because all the histograms have an eta axis + registry.fill(HIST("hMcPartCutsCounts"), 3.5); // etaAccept // not actually applied here but it will give an idea of what will be done in the post processing } } std::vector seenMcParticlesVector; // is reset every mc collision int splitCollCounter = 0; - for (auto& collision : collisions) { + for (auto const& collision : collisions) { splitCollCounter++; - if (acceptSplitCollisions == 2 && splitCollCounter > 1) { + if (acceptSplitCollisions == SplitOkCheckFirstAssocCollOnly && splitCollCounter > 1) { return; } - if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !(abs(collision.posZ()) < vertexZCut)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents) || !(std::abs(collision.posZ()) < vertexZCut)) { continue; } auto collTracks = jetTracks.sliceBy(tracksPerJCollision, collision.globalIndex()); - for (auto& track : collTracks) { + for (auto const& track : collTracks) { registry.fill(HIST("hTrackCutsCounts"), 0.5); if (!(jetderiveddatautilities::selectTrack(track, trackSelection) && jetderiveddatautilities::selectTrackDcaZ(track, trackDcaZmax))) { // if track selection is uniformTrack, dcaZ cuts need to be added as they aren't in the selection so that they can be studied here @@ -376,41 +461,423 @@ struct TrackEfficiencyJets { seenMcParticlesVector.push_back(jMcParticleFromTrack.globalIndex()); } - if (abs(jMcParticleFromTrack.eta()) < trackEtaAcceptanceCountQA) { // not actually applied here but it will give an idea of what will be done in the post processing + if (std::abs(jMcParticleFromTrack.eta()) < trackEtaAcceptanceCountQA) { // not actually applied here but it will give an idea of what will be done in the post processing registry.fill(HIST("hTrackCutsCounts"), 4.5); } } } } - PROCESS_SWITCH(TrackEfficiencyJets, processEFficiencyPurity, "Histograms for efficiency and purity quantities", true); + PROCESS_SWITCH(TrackEfficiency, processEFficiencyPurity, "Histograms for efficiency and purity quantities", true); + + void processEFficiencyPurityWeighted(soa::Join::iterator const& mcCollision, + soa::Join const&, + soa::SmallGroups const& collisions, // smallgroups gives only the collisions associated to the current mccollision, thanks to the mccollisionlabel pre-integrated in jetcollisionsmcd + soa::Join const& jetTracks, + JetParticlesWithOriginal const& jMcParticles) + { + // missing: + // * constexpr auto hasCentrality = CollisionMCRecTableCentFT0C::template contains(); + // if constexpr (hasCentrality) { + // * dividing in centrality bins + // I should maybe introduce the sel8 cuts on the collisoins (reco, but what about mccoll? maybe not htat way included in efficiency) + + registry.fill(HIST("hMcCollCutsCounts"), 0.5, mcCollision.weight()); // all mcCollisions + + if (!(std::abs(mcCollision.posZ()) < vertexZCut)) { + return; + } + registry.fill(HIST("hMcCollCutsCounts"), 1.5, mcCollision.weight()); // mcCollision.posZ() condition + + if (collisions.size() < 1) { + return; + } + registry.fill(HIST("hMcCollCutsCounts"), 2.5, mcCollision.weight()); // mcCollisions with at least one reconstructed collision + + if (acceptSplitCollisions == NonSplitOnly && collisions.size() > 1) { + return; + } + registry.fill(HIST("hMcCollCutsCounts"), 3.5, mcCollision.weight()); // split mcCollisions condition + + bool hasSel8Coll = false; + bool centralityCheck = false; + if (acceptSplitCollisions == SplitOkCheckFirstAssocCollOnly || acceptSplitCollisions == NonSplitOnly) { // check only that the first reconstructed collision passes the check (for the NonSplitOnly case, there's only one associated collision) + if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collisions.begin().centFT0M()) && (collisions.begin().centFT0M() < centralityMax))) { // effect unclear if mcColl is split + centralityCheck = true; + } + } else if (acceptSplitCollisions == SplitOkCheckAnyAssocColl) { // check that at least one of the reconstructed collisions passes the checks + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collision.centFT0M()) && (collision.centFT0M() < centralityMax))) { // effect unclear if mcColl is split + centralityCheck = true; + } + } + } + if (!hasSel8Coll) { + return; + } + registry.fill(HIST("hMcCollCutsCounts"), 4.5, mcCollision.weight()); // at least one of the reconstructed collisions associated with this mcCollision is selected + + if (!centralityCheck) { + return; + } + registry.fill(HIST("hMcCollCutsCounts"), 5.5, mcCollision.weight()); // at least one of the reconstructed collisions associated with this mcCollision is selected with regard to centrality + + float simPtRef = 10.; + float mcCollEventWeight = mcCollision.weight(); + float pTHat = simPtRef / (std::pow(mcCollEventWeight, 1.0 / pTHatExponent)); + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + registry.fill(HIST("hMcCollCutsCounts"), 6.5, mcCollision.weight()); // ptHat condition + + for (auto const& jMcParticle : jMcParticles) { + registry.fill(HIST("hMcPartCutsCounts"), 0.5, mcCollision.weight()); // allPartsInSelMcColl + + if (!isChargedParticle(jMcParticle.pdgCode())) { + continue; + } + registry.fill(HIST("hMcPartCutsCounts"), 1.5, mcCollision.weight()); // isCharged + + registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_mcpart_nonprimary"), jMcParticle.pt(), jMcParticle.eta(), jMcParticle.phi(), mcCollEventWeight); + + if (checkPrimaryPart && !jMcParticle.isPhysicalPrimary()) { // global tracks should be mostly primaries + continue; + } + registry.fill(HIST("hMcPartCutsCounts"), 2.5, mcCollision.weight()); // isPrimary + + registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_mcpartofinterest"), jMcParticle.pt(), jMcParticle.eta(), jMcParticle.phi(), mcCollEventWeight); + + registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_mcpartofinterest"), jMcParticle.pt(), jMcParticle.eta(), jMcParticle.phi(), mcCollEventWeight); + + if ((std::abs(jMcParticle.eta()) < trackEtaAcceptanceCountQA)) { // removed from actual cuts for now because all the histograms have an eta axis + registry.fill(HIST("hMcPartCutsCounts"), 3.5, mcCollision.weight()); // etaAccept // not actually applied here but it will give an idea of what will be done in the post processing + } + } + + std::vector seenMcParticlesVector; // is reset every mc collision + + int splitCollCounter = 0; + for (auto const& collision : collisions) { + splitCollCounter++; + if (acceptSplitCollisions == SplitOkCheckFirstAssocCollOnly && splitCollCounter > 1) { + return; + } + + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents) || !(std::abs(collision.posZ()) < vertexZCut)) { + continue; + } + + auto collTracks = jetTracks.sliceBy(tracksPerJCollision, collision.globalIndex()); + for (auto const& track : collTracks) { + registry.fill(HIST("hTrackCutsCounts"), 0.5, mcCollision.weight()); + + if (!(jetderiveddatautilities::selectTrack(track, trackSelection) && jetderiveddatautilities::selectTrackDcaZ(track, trackDcaZmax))) { // if track selection is uniformTrack, dcaZ cuts need to be added as they aren't in the selection so that they can be studied here + continue; + } + registry.fill(HIST("hTrackCutsCounts"), 1.5, mcCollision.weight()); + + if (!track.has_mcParticle()) { + registry.fill(HIST("h3_track_pt_track_eta_track_phi_nonassociatedtrack"), track.pt(), track.eta(), track.phi(), mcCollEventWeight); // weight attribution here not trivial; I use the one of the current mcCollision, but track belongs to no collision; what should be its weight? could be a moot point but algo has complained about invalid index for mcParticle if I put th etrueTrackCollEventWeight before this cut + + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_nonassociatedtrack"), track.pt(), track.eta(), track.phi(), mcCollEventWeight); + continue; + } + registry.fill(HIST("hTrackCutsCounts"), 2.5, mcCollision.weight()); + + if (track.pt() > pTHatMaxFractionMCD * pTHat) { + continue; + } + registry.fill(HIST("hTrackCutsCounts"), 3.5, mcCollision.weight()); + + auto mcParticle = track.mcParticle_as(); + auto trueTrackMcCollision = mcParticle.mcCollision_as(); + float trueTrackCollEventWeight = useTrueTrackWeight ? trueTrackMcCollision.weight() : mcCollEventWeight; // test1 + + auto jMcParticleFromTrack = track.mcParticle_as(); + if (!jMcParticleFromTrack.isPhysicalPrimary()) { + registry.fill(HIST("h3_track_pt_track_eta_track_phi_associatedtrack_nonprimary"), track.pt(), track.eta(), track.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_associatedtrack_nonprimary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi(), trueTrackCollEventWeight); + + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_associatedtrack_nonprimary"), track.pt(), track.eta(), track.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_nonprimary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi(), trueTrackCollEventWeight); + + if (std::find(seenMcParticlesVector.begin(), seenMcParticlesVector.end(), jMcParticleFromTrack.globalIndex()) != seenMcParticlesVector.end()) { + registry.fill(HIST("h3_track_pt_track_eta_track_phi_associatedtrack_split_nonprimary"), track.pt(), track.eta(), track.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_associatedtrack_split_nonprimary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi(), trueTrackCollEventWeight); + + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_associatedtrack_split_nonprimary"), track.pt(), track.eta(), track.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_split_nonprimary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi(), trueTrackCollEventWeight); + } else { + seenMcParticlesVector.push_back(jMcParticleFromTrack.globalIndex()); + } + + continue; + } + + registry.fill(HIST("hTrackCutsCounts"), 4.5, mcCollision.weight()); + + registry.fill(HIST("h3_track_pt_track_eta_track_phi_associatedtrack_primary"), track.pt(), track.eta(), track.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_associatedtrack_primary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h2_particle_pt_track_pt_residual_associatedtrack_primary"), jMcParticleFromTrack.pt(), (jMcParticleFromTrack.pt() - track.pt()) / jMcParticleFromTrack.pt(), trueTrackCollEventWeight); + + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_associatedtrack_primary"), track.pt(), track.eta(), track.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_primary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h2_particle_pt_high_track_pt_high_residual_associatedtrack_primary"), jMcParticleFromTrack.pt(), (jMcParticleFromTrack.pt() - track.pt()) / jMcParticleFromTrack.pt(), trueTrackCollEventWeight); + + if (std::find(seenMcParticlesVector.begin(), seenMcParticlesVector.end(), jMcParticleFromTrack.globalIndex()) != seenMcParticlesVector.end()) { + registry.fill(HIST("h3_track_pt_track_eta_track_phi_associatedtrack_split_primary"), track.pt(), track.eta(), track.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_associatedtrack_split_primary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi(), trueTrackCollEventWeight); + + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_associatedtrack_split_primary"), track.pt(), track.eta(), track.phi(), trueTrackCollEventWeight); + registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_split_primary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi(), trueTrackCollEventWeight); + } else { + seenMcParticlesVector.push_back(jMcParticleFromTrack.globalIndex()); + } + + if (std::abs(jMcParticleFromTrack.eta()) < trackEtaAcceptanceCountQA) { // not actually applied here but it will give an idea of what will be done in the post processing + registry.fill(HIST("hTrackCutsCounts"), 5.5, mcCollision.weight()); + } + } + } + } + PROCESS_SWITCH(TrackEfficiency, processEFficiencyPurityWeighted, "Histograms for efficiency and purity quantities for weighted simulations", false); + + void processTracksFromData(soa::Filtered::iterator const& collision, + soa::Filtered> const& tracks) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + + fillTrackHistograms(collision, tracks); + } + PROCESS_SWITCH(TrackEfficiency, processTracksFromData, "QA for charged tracks in data", false); + + void processTracksFromMc(soa::Join::iterator const& collision, + soa::Join const&, + soa::Join const&, + soa::Filtered> const& tracks) + { + if (!collision.has_mcCollision()) { // the collision is fake and has no associated mc coll; skip as .mccollision() cannot be called + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + + float pTHat = getPtHatFromHepMCXSection ? collision.mcCollision_as>().mcCollision_as>().ptHard() : 10. / (std::pow(collision.mcCollision().weight(), 1.0 / pTHatExponent)); + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + + fillTrackHistograms(collision, tracks); + } + PROCESS_SWITCH(TrackEfficiency, processTracksFromMc, "QA for charged tracks in MC without weights", false); + + void processTracksFromMcWeighted(soa::Join::iterator const& collision, + soa::Join const&, + soa::Join const&, + soa::Filtered> const& tracks) + { + if (!collision.has_mcCollision()) { // the collision is fake and has no associated mc coll; skip as .mccollision() cannot be called + return; + } + float eventWeight = collision.mcCollision().weight(); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + + float pTHat = getPtHatFromHepMCXSection ? collision.mcCollision_as>().mcCollision_as>().ptHard() : 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + + fillTrackHistograms(collision, tracks, eventWeight); + } + PROCESS_SWITCH(TrackEfficiency, processTracksFromMcWeighted, "QA for charged tracks in weighted MC", false); + + void processParticles(soa::Join::iterator const& mcCollision, + soa::Join const&, + soa::SmallGroups const& collisions, + soa::Filtered const& mcparticles, + soa::Filtered const& tracks) + { + + if (!(std::abs(mcCollision.posZ()) < vertexZCut)) { + return; + } + if (collisions.size() < 1) { + return; + } + if (acceptSplitCollisions == NonSplitOnly && collisions.size() > 1) { + return; + } + + float pTHat = getPtHatFromHepMCXSection ? mcCollision.mcCollision_as>().ptHard() : 10. / (std::pow(mcCollision.weight(), 1.0 / pTHatExponent)); + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + + bool hasSel8Coll = false; + bool centralityCheck = false; + if (acceptSplitCollisions == SplitOkCheckFirstAssocCollOnly || acceptSplitCollisions == NonSplitOnly) { // check only that the first reconstructed collision passes the check (for the NonSplitOnly case, there's only one associated collision) + if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collisions.begin().centFT0M()) && (collisions.begin().centFT0M() < centralityMax))) { // effect unclear if mcColl is split + centralityCheck = true; + } + } else if (acceptSplitCollisions == SplitOkCheckAnyAssocColl) { // check that at least one of the reconstructed collisions passes the checks + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collision.centFT0M()) && (collision.centFT0M() < centralityMax))) { // effect unclear if mcColl is split + centralityCheck = true; + } + } + } + if (!hasSel8Coll) { + return; + } + if (!centralityCheck) { + return; + } + + fillParticlesHistograms(collisions.begin(), mcparticles, tracks); + } + PROCESS_SWITCH(TrackEfficiency, processParticles, "QA for charged particles", false); + + void processParticlesWeighted(soa::Join::iterator const& mcCollision, + soa::Join const&, + soa::SmallGroups const& collisions, + soa::Filtered const& mcparticles, + soa::Filtered const& tracks) + { + if (skipMBGapEvents && mcCollision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + + float eventWeight = mcCollision.weight(); + + if (!(std::abs(mcCollision.posZ()) < vertexZCut)) { + return; + } + if (collisions.size() < 1) { + return; + } + if (acceptSplitCollisions == NonSplitOnly && collisions.size() > 1) { + return; + } + + float pTHat = getPtHatFromHepMCXSection ? mcCollision.mcCollision_as>().ptHard() : 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + + bool hasSel8Coll = false; + bool centralityCheck = false; + if (acceptSplitCollisions == SplitOkCheckFirstAssocCollOnly || acceptSplitCollisions == NonSplitOnly) { // check only that the first reconstructed collision passes the check (for the NonSplitOnly case, there's only one associated collision) + if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collisions.begin().centFT0M()) && (collisions.begin().centFT0M() < centralityMax))) { // effect unclear if mcColl is split + centralityCheck = true; + } + } else if (acceptSplitCollisions == SplitOkCheckAnyAssocColl) { // check that at least one of the reconstructed collisions passes the checks + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collision.centFT0M()) && (collision.centFT0M() < centralityMax))) { // effect unclear if mcColl is split + centralityCheck = true; + } + } + } + if (!hasSel8Coll) { + return; + } + if (!centralityCheck) { + return; + } + + fillParticlesHistograms(collisions.begin(), mcparticles, tracks, eventWeight); + } + PROCESS_SWITCH(TrackEfficiency, processParticlesWeighted, "QA for charged particles weighted", false); - void processTracks(soa::Filtered::iterator const& collision, - soa::Filtered> const& tracks) + void processCollisionsFromData(soa::Filtered::iterator const& collision) { registry.fill(HIST("h_collisions"), 0.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } registry.fill(HIST("h_collisions"), 1.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 1.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 1.5); if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { return; } registry.fill(HIST("h_collisions"), 2.5); - registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 2.5); - fillTrackHistograms(collision, tracks); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 2.5); } - PROCESS_SWITCH(TrackEfficiencyJets, processTracks, "QA for charged tracks", false); + PROCESS_SWITCH(TrackEfficiency, processCollisionsFromData, "QA for reconstructed collisions in data", false); - void processTracksWeighted(soa::Join::iterator const& collision, - aod::JetMcCollisions const&, - soa::Filtered> const& tracks) + void processCollisionsFromMc(soa::Join::iterator const& collision, + soa::Join const&, + soa::Join const&) { + if (!collision.has_mcCollision()) { // the collision is fake and has no associated mc coll; skip as .mccollision() cannot be called + registry.fill(HIST("h_fakecollisions"), 0.5); + return; + } + registry.fill(HIST("h_collisions"), 0.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { + return; + } + registry.fill(HIST("h_collisions"), 1.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 1.5); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + registry.fill(HIST("h_collisions"), 2.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 2.5); + + float pTHat = getPtHatFromHepMCXSection ? collision.mcCollision_as>().mcCollision_as>().ptHard() : 10. / (std::pow(collision.mcCollision().weight(), 1.0 / pTHatExponent)); + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + registry.fill(HIST("h_collisions"), 3.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 3.5); + } + PROCESS_SWITCH(TrackEfficiency, processCollisionsFromMc, "QA for reconstructed collisions in MC without weights", false); + + void processCollisionsFromMcWeighted(soa::Join::iterator const& collision, + soa::Join const&, + soa::Join const&) + { + if (!collision.has_mcCollision()) { // the collision is fake and has no associated mc coll; skip as .mccollision() cannot be called + registry.fill(HIST("h_fakecollisions"), 0.5); + return; + } float eventWeight = collision.mcCollision().weight(); registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { return; } registry.fill(HIST("h_collisions"), 1.5); @@ -420,42 +887,58 @@ struct TrackEfficiencyJets { } registry.fill(HIST("h_collisions"), 2.5); registry.fill(HIST("h_collisions_weighted"), 2.5, eventWeight); - fillTrackHistograms(collision, tracks, eventWeight); + + float pTHat = getPtHatFromHepMCXSection ? collision.mcCollision_as>().mcCollision_as>().ptHard() : 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + registry.fill(HIST("h_collisions"), 3.5); + registry.fill(HIST("h2_centrality_collisions"), collision.centFT0M(), 3.5, eventWeight); } - PROCESS_SWITCH(TrackEfficiencyJets, processTracksWeighted, "QA for charged tracks weighted", false); + PROCESS_SWITCH(TrackEfficiency, processCollisionsFromMcWeighted, "QA for reconstructed collisions in weighted MC", false); - void processParticles(aod::JetMcCollision const& mcCollision, - soa::SmallGroups const& collisions, - soa::Filtered const& mcparticles) + void processMcCollisions(soa::Join::iterator const& mcCollision, + soa::Join const&, + soa::SmallGroups const& collisions) { + float eventWeight = mcCollision.weight(); + float pTHat = getPtHatFromHepMCXSection ? mcCollision.mcCollision_as>().ptHard() : 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + registry.fill(HIST("h2_mccollision_pthardfromweight_pthardfromhepmcxsection"), 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)), mcCollision.mcCollision_as>().ptHard()); + registry.fill(HIST("h_mccollisions"), 0.5); - registry.fill(HIST("h2_centrality_mccollisions"), collisions.begin().centrality(), 0.5); + registry.fill(HIST("h2_centrality_mccollisions"), collisions.begin().centFT0M(), 0.5); - if (!(abs(mcCollision.posZ()) < vertexZCut)) { + if (!(std::abs(mcCollision.posZ()) < vertexZCut)) { return; } if (collisions.size() < 1) { return; } - if (acceptSplitCollisions == 0 && collisions.size() > 1) { + if (acceptSplitCollisions == NonSplitOnly && collisions.size() > 1) { return; } + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + registry.fill(HIST("h_mccollisions"), 1.5); + registry.fill(HIST("h2_centrality_mccollisions"), collisions.begin().centFT0M(), 1.5); + bool hasSel8Coll = false; bool centralityCheck = false; - if (acceptSplitCollisions == 2) { // check only that the first reconstructed collision passes the check - if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelection)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + if (acceptSplitCollisions == SplitOkCheckFirstAssocCollOnly || acceptSplitCollisions == NonSplitOnly) { // check only that the first reconstructed collision passes the check (for the NonSplitOnly case, there's only one associated collision) + if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split hasSel8Coll = true; } - if (!checkCentrality || ((centralityMin < collisions.begin().centrality()) && (collisions.begin().centrality() < centralityMax))) { // effect unclear if mcColl is split + if (!checkCentrality || ((centralityMin < collisions.begin().centFT0M()) && (collisions.begin().centFT0M() < centralityMax))) { // effect unclear if mcColl is split centralityCheck = true; } - } else { // check that at least one of the reconstructed collisions passes the checks - for (auto& collision : collisions) { - if (jetderiveddatautilities::selectCollision(collision, eventSelection)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + } else if (acceptSplitCollisions == SplitOkCheckAnyAssocColl) { // check that at least one of the reconstructed collisions passes the checks + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split hasSel8Coll = true; } - if (!checkCentrality || ((centralityMin < collision.centrality()) && (collision.centrality() < centralityMax))) { // effect unclear if mcColl is split + if (!checkCentrality || ((centralityMin < collision.centFT0M()) && (collision.centFT0M() < centralityMax))) { // effect unclear if mcColl is split centralityCheck = true; } } @@ -466,46 +949,58 @@ struct TrackEfficiencyJets { if (!centralityCheck) { return; } - - registry.fill(HIST("h_mccollisions"), 1.5); - registry.fill(HIST("h2_centrality_mccollisions"), collisions.begin().centrality(), 1.5); - fillParticlesHistograms(collisions.begin(), mcparticles); + registry.fill(HIST("h_mccollisions"), 2.5); + registry.fill(HIST("h2_centrality_mccollisions"), collisions.begin().centFT0M(), 2.5); } - PROCESS_SWITCH(TrackEfficiencyJets, processParticles, "QA for charged particles", false); + PROCESS_SWITCH(TrackEfficiency, processMcCollisions, "QA for McCollisions in MC without weights", false); - void processParticlesWeighted(aod::JetMcCollision const& mcCollision, - soa::SmallGroups const& collisions, - soa::Filtered const& mcparticles) + void processMcCollisionsWeighted(soa::Join::iterator const& mcCollision, + soa::Join const&, + soa::SmallGroups const& collisions) { + if (skipMBGapEvents && mcCollision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + float eventWeight = mcCollision.weight(); + float pTHat = getPtHatFromHepMCXSection ? mcCollision.mcCollision_as>().ptHard() : 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + registry.fill(HIST("h2_mccollision_pthardfromweight_pthardfromhepmcxsection"), 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)), mcCollision.mcCollision_as>().ptHard()); + registry.fill(HIST("h2_mccollision_pthardfromweight_pthardfromhepmcxsection_weighted"), 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)), mcCollision.mcCollision_as>().ptHard(), eventWeight); + registry.fill(HIST("h_mccollisions"), 0.5); registry.fill(HIST("h_mccollisions_weighted"), 0.5, eventWeight); - if (!(abs(mcCollision.posZ()) < vertexZCut)) { + if (!(std::abs(mcCollision.posZ()) < vertexZCut)) { return; } if (collisions.size() < 1) { return; } - if (acceptSplitCollisions == 0 && collisions.size() > 1) { + if (acceptSplitCollisions == NonSplitOnly && collisions.size() > 1) { return; } + if (pTHat < ptHatMin || pTHat > ptHatMax) { // only allows mcCollisions with weight in between min and max + return; + } + registry.fill(HIST("h_mccollisions"), 1.5); + registry.fill(HIST("h_mccollisions_weighted"), 1.5, eventWeight); + bool hasSel8Coll = false; bool centralityCheck = false; - if (acceptSplitCollisions == 2) { // check only that the first reconstructed collision passes the check - if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelection)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + if (acceptSplitCollisions == SplitOkCheckFirstAssocCollOnly || acceptSplitCollisions == NonSplitOnly) { // check only that the first reconstructed collision passes the check (for the NonSplitOnly case, there's only one associated collision) + if (jetderiveddatautilities::selectCollision(collisions.begin(), eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split hasSel8Coll = true; } - if (!checkCentrality || ((centralityMin < collisions.begin().centrality()) && (collisions.begin().centrality() < centralityMax))) { // effect unclear if mcColl is split + if (!checkCentrality || ((centralityMin < collisions.begin().centFT0M()) && (collisions.begin().centFT0M() < centralityMax))) { // effect unclear if mcColl is split centralityCheck = true; } - } else { // check that at least one of the reconstructed collisions passes the checks - for (auto& collision : collisions) { - if (jetderiveddatautilities::selectCollision(collision, eventSelection)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split + } else if (acceptSplitCollisions == SplitOkCheckAnyAssocColl) { // check that at least one of the reconstructed collisions passes the checks + for (auto const& collision : collisions) { + if (jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents)) { // Skipping MC events that have not a single selected reconstructed collision ; effect unclear if mcColl is split hasSel8Coll = true; } - if (!checkCentrality || ((centralityMin < collision.centrality()) && (collision.centrality() < centralityMax))) { // effect unclear if mcColl is split + if (!checkCentrality || ((centralityMin < collision.centFT0M()) && (collision.centFT0M() < centralityMax))) { // effect unclear if mcColl is split centralityCheck = true; } } @@ -516,12 +1011,13 @@ struct TrackEfficiencyJets { if (!centralityCheck) { return; } - - registry.fill(HIST("h_mccollisions"), 1.5); - registry.fill(HIST("h_mccollisions_weighted"), 1.5, eventWeight); - fillParticlesHistograms(collisions.begin(), mcparticles, eventWeight); + registry.fill(HIST("h_mccollisions"), 2.5); + registry.fill(HIST("h_mccollisions_weighted"), 2.5, eventWeight); } - PROCESS_SWITCH(TrackEfficiencyJets, processParticlesWeighted, "QA for charged particles weighted", false); + PROCESS_SWITCH(TrackEfficiency, processMcCollisionsWeighted, "QA for McCollisions in weighted MC", false); }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"track-efficiency"})}; } +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGJE/Tasks/trackJetQA.cxx b/PWGJE/Tasks/trackJetQA.cxx index 437fdd914a0..2f3c9a51eb6 100644 --- a/PWGJE/Tasks/trackJetQA.cxx +++ b/PWGJE/Tasks/trackJetQA.cxx @@ -15,27 +15,29 @@ /// \since 2023-10-02 /// \brief Task producing jet tracking qa histograms /// -#include - -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Framework/ASoA.h" +#include "PWGJE/DataModel/TrackJetQa.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" - -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/TrackJetQa.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" - #include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include + +#include using namespace o2; -using namespace o2::track; using namespace o2::framework; using namespace o2::framework::expressions; @@ -82,6 +84,9 @@ struct TrackJetQa { ConfigurableAxis binsDcaZ{"binsDcaZ", {100, -5, 5}, "Binning for the dcaXY axis"}; ConfigurableAxis binsLength{"binsLength", {200, 0, 1000}, "Binning for the track length axis"}; + Filter ptFilter = (aod::track::pt >= minPt) && (aod::track::pt <= maxPt); + Filter etaFilter = (aod::track::eta <= ValCutEta) && (aod::track::eta >= -ValCutEta); + void init(o2::framework::InitContext&) { if (customTrack) { @@ -171,7 +176,7 @@ struct TrackJetQa { histos.add("TrackPar/xyz", "track #it{x}, #it{y}, #it{z} position at dca in local coordinate system", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisTrackX, axisTrackY, axisTrackZ, axisPercentileFT0A, axisPercentileFT0C}); histos.add("TrackPar/alpha", "rotation angle of local wrt. global coordinate system", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisRotation, axisPercentileFT0A, axisPercentileFT0C}); histos.add("TrackPar/signed1Pt", "track signed 1/#it{p}_{T}", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisSignedPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/snp", "sinus of track momentum azimuthal angle (snp)", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, {11, -0.5, 0.5, "snp"}, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/snp", "sinus of track momentum azimuthal angle (snp)", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, {50, -0.5, 0.5, "snp"}, axisPercentileFT0A, axisPercentileFT0C}); histos.add("TrackPar/tgl", "tangent of the track momentum dip angle (tgl)", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, {200, -1., 1., "tgl"}, axisPercentileFT0A, axisPercentileFT0C}); histos.add("TrackPar/flags", "track flag;#it{p}_{T} [GeV/c];flag bit", {HistType::kTH2F, {{200, 0, 200}, {64, -0.5, 63.5}}}); histos.add("TrackPar/dcaXY", "distance of closest approach in #it{xy} plane", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisDcaXY, axisPercentileFT0A, axisPercentileFT0C}); @@ -180,16 +185,21 @@ struct TrackJetQa { histos.add("TrackPar/Sigma1Pt", "uncertainty over #it{p}_{T}", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); histos.add("TrackPar/Sigma1Pt_hasTRD", "uncertainty over #it{p}_{T} for tracks with TRD", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); histos.add("TrackPar/Sigma1Pt_hasNoTRD", "uncertainty over #it{p}_{T} for tracks without TRD", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layer1", "uncertainty over #it{p}_{T} with only 1st ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layer2", "uncertainty over #it{p}_{T} with only 2nd ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layers12", "uncertainty over #it{p}_{T} with only 1st and 2nd ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layer4", "uncertainty over #it{p}_{T} with only 4th ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layer5", "uncertainty over #it{p}_{T} with only 5th ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layer6", "uncertainty over #it{p}_{T} with only 6th ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layers45", "uncertainty over #it{p}_{T} with only 4th and 5th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layers56", "uncertainty over #it{p}_{T} with only 5th and 6th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layers46", "uncertainty over #it{p}_{T} with only 4th and 6th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); - histos.add("TrackPar/Sigma1Pt_Layers456", "uncertainty over #it{p}_{T} with only 4th, 5th and 6th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layer1", "uncertainty over #it{p}_{T} with 1st ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layer2", "uncertainty over #it{p}_{T} with 2nd ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layer3", "uncertainty over #it{p}_{T} with 3rd ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layer4", "uncertainty over #it{p}_{T} with 4th ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layer5", "uncertainty over #it{p}_{T} with 5th ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layer6", "uncertainty over #it{p}_{T} with 6th ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layer7", "uncertainty over #it{p}_{T} with 7th ITS layer active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layers12", "uncertainty over #it{p}_{T} with 1st and 2nd ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layers34", "uncertainty over #it{p}_{T} with 3rd and 4th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layers45", "uncertainty over #it{p}_{T} with 4th and 5th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layers56", "uncertainty over #it{p}_{T} with 5th and 6th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layers67", "uncertainty over #it{p}_{T} with 6th and 7th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layers1or2and7", "uncertainty over #it{p}_{T} with 1st or 2nd and 7th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layers1or2and6or7", "uncertainty over #it{p}_{T} with 1st or 2nd and 6th or 7th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); + histos.add("TrackPar/Sigma1Pt_Layers456", "uncertainty over #it{p}_{T} with 4th, 5th and 6th ITS layers active", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, axisPercentileFT0A, axisPercentileFT0C}); // ITS histograms histos.add("ITS/itsNCls", "number of found ITS clusters", HistType::kTHnSparseD, {axisPt, axisSigma1OverPt, {8, -0.5, 7.5, "# clusters ITS"}, axisPercentileFT0A, axisPercentileFT0C}); @@ -264,7 +274,7 @@ struct TrackJetQa { histos.fill(HIST("TrackPar/signed1Pt"), track.pt(), track.sigma1Pt() * track.pt(), track.signed1Pt(), collision.centFT0A(), collision.centFT0C()); histos.fill(HIST("TrackPar/snp"), track.pt(), track.sigma1Pt() * track.pt(), track.snp(), collision.centFT0A(), collision.centFT0C()); histos.fill(HIST("TrackPar/tgl"), track.pt(), track.sigma1Pt() * track.pt(), track.tgl(), collision.centFT0A(), collision.centFT0C()); - for (unsigned int i = 0; i < 64; i++) { + for (unsigned int i = 0; i < 32; i++) { if (track.flags() & (1 << i)) { histos.fill(HIST("TrackPar/flags"), track.pt(), track.sigma1Pt() * track.pt(), i); } @@ -276,17 +286,20 @@ struct TrackJetQa { //// check the uncertainty over pT activating several ITS layers bool firstLayerActive = track.itsClusterMap() & (1 << 0); bool secondLayerActive = track.itsClusterMap() & (1 << 1); + bool thirdLayerActive = track.itsClusterMap() & (1 << 2); bool fourthLayerActive = track.itsClusterMap() & (1 << 3); bool fifthLayerActive = track.itsClusterMap() & (1 << 4); bool sixthLayerActive = track.itsClusterMap() & (1 << 5); + bool seventhLayerActive = track.itsClusterMap() & (1 << 6); + if (firstLayerActive) { histos.fill(HIST("TrackPar/Sigma1Pt_Layer1"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); } if (secondLayerActive) { histos.fill(HIST("TrackPar/Sigma1Pt_Layer2"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); } - if (firstLayerActive && secondLayerActive) { - histos.fill(HIST("TrackPar/Sigma1Pt_Layers12"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); + if (thirdLayerActive) { + histos.fill(HIST("TrackPar/Sigma1Pt_Layer3"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); } if (fourthLayerActive) { histos.fill(HIST("TrackPar/Sigma1Pt_Layer4"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); @@ -297,14 +310,29 @@ struct TrackJetQa { if (sixthLayerActive) { histos.fill(HIST("TrackPar/Sigma1Pt_Layer6"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); } + if (seventhLayerActive) { + histos.fill(HIST("TrackPar/Sigma1Pt_Layer7"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); + } + if (firstLayerActive && secondLayerActive) { + histos.fill(HIST("TrackPar/Sigma1Pt_Layers12"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); + } + if (thirdLayerActive && fourthLayerActive) { + histos.fill(HIST("TrackPar/Sigma1Pt_Layers34"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); + } if (fourthLayerActive && fifthLayerActive) { histos.fill(HIST("TrackPar/Sigma1Pt_Layers45"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); } if (fifthLayerActive && sixthLayerActive) { histos.fill(HIST("TrackPar/Sigma1Pt_Layers56"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); } - if (fourthLayerActive && sixthLayerActive) { - histos.fill(HIST("TrackPar/Sigma1Pt_Layers46"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); + if (sixthLayerActive && seventhLayerActive) { + histos.fill(HIST("TrackPar/Sigma1Pt_Layers67"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); + } + if ((firstLayerActive || secondLayerActive) && seventhLayerActive) { + histos.fill(HIST("TrackPar/Sigma1Pt_Layers1or2and7"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); + } + if ((firstLayerActive || secondLayerActive) && (sixthLayerActive || seventhLayerActive)) { + histos.fill(HIST("TrackPar/Sigma1Pt_Layers1or2and6or7"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); } if (fourthLayerActive && fifthLayerActive && sixthLayerActive) { histos.fill(HIST("TrackPar/Sigma1Pt_Layers456"), track.pt(), track.sigma1Pt() * track.pt(), collision.centFT0A(), collision.centFT0C()); @@ -332,7 +360,7 @@ struct TrackJetQa { using TrackCandidates = soa::Join; void processFull(CollisionCandidate const& collisions, - TrackCandidates const& tracks) + soa::Filtered const& tracks) { for (const auto& collision : collisions) { auto tracksInCollision = tracks.sliceBy(trackPerColl, collision.globalIndex()); diff --git a/PWGJE/Tasks/triggerCorrelations.cxx b/PWGJE/Tasks/triggerCorrelations.cxx index bb2d43e1f95..2d7b54707bb 100644 --- a/PWGJE/Tasks/triggerCorrelations.cxx +++ b/PWGJE/Tasks/triggerCorrelations.cxx @@ -13,33 +13,26 @@ // /// \author Nima Zardoshti -#include +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "EMCALBase/Geometry.h" #include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/HistogramRegistry.h" +#include +#include +#include +#include -#include "Common/Core/TrackSelection.h" -#include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/CCDB/TriggerAliases.h" +#include -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/DataModel/Jet.h" +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -#include "Framework/runDataProcessing.h" - struct TriggerCorrelationsTask { HistogramRegistry registry; @@ -79,6 +72,12 @@ struct TriggerCorrelationsTask { fillCorrelationsHistogram(collision); } PROCESS_SWITCH(TriggerCorrelationsTask, processTriggeredCorrelations, "QA for trigger correlations", true); + + void processTriggeredCorrelationsOffline(aod::JCollision const& collision) + { + fillCorrelationsHistogram(collision); + } + PROCESS_SWITCH(TriggerCorrelationsTask, processTriggeredCorrelationsOffline, "QA for trigger correlations in offline analysis", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/Tasks/v0JetSpectra.cxx b/PWGJE/Tasks/v0JetSpectra.cxx index cbf39c5b057..95081bad725 100644 --- a/PWGJE/Tasks/v0JetSpectra.cxx +++ b/PWGJE/Tasks/v0JetSpectra.cxx @@ -14,24 +14,23 @@ /// \author Gijs van Weelden // -#include "TH1F.h" -#include "TTree.h" +#include "JetDerivedDataUtilities.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/RunningWorkflowInfo.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/PIDResponse.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include -#include "CommonConstants/PhysicsConstants.h" +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" +#include +#include using namespace o2; using namespace o2::framework; @@ -63,13 +62,13 @@ struct V0JetSpectra { Configurable evSel{"evSel", "sel8WithoutTimeFrameBorderCut", "choose event selection"}; Configurable vertexZCut{"vertexZCut", 10.f, "vertex z cut"}; - int eventSelection = -1; + std::vector eventSelectionBits; Filter jetCollisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; void init(InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(evSel)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(evSel)); registry.add("jetPtEtaPhi", "Jets; #it{p}_{T}; #eta; #phi", HistType::kTH3D, {{200, 0., 200.}, {20, -1.f, 1.f}, {18 * 8, 0.f, 2. * TMath::Pi()}}); registry.add("mcpJetPtEtaPhi", "Jets; #it{p}_{T}; #eta; #phi", HistType::kTH3D, {{200, 0., 200.}, {20, -1.f, 1.f}, {18 * 8, 0.f, 2. * TMath::Pi()}}); } @@ -91,7 +90,7 @@ struct V0JetSpectra { void processData(soa::Filtered::iterator const& jcoll, aod::ChargedJets const& chjets, aod::V0ChargedJets const& v0jets) { - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) { return; } if (v0jets.size() == 0) { @@ -105,7 +104,7 @@ struct V0JetSpectra { if (!jcoll.has_mcCollision()) { return; } - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) { return; } double weight = jcoll.mcCollision().weight(); @@ -126,7 +125,7 @@ struct V0JetSpectra { void processMcMatched(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, MatchedMCDJets const& chjetsMCD, MatchedMCPJets const& chjetsMCP, MatchedMCDV0Jets const& v0jetsMCD, MatchedMCPV0Jets const& v0jetsMCP) { - if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) { return; } // TODO: Need to add checker to only count matched jets (?) diff --git a/PWGJE/Tasks/v0QA.cxx b/PWGJE/Tasks/v0QA.cxx index e4de0088ccf..26adc61d820 100644 --- a/PWGJE/Tasks/v0QA.cxx +++ b/PWGJE/Tasks/v0QA.cxx @@ -9,30 +9,36 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file v0QA.cxx /// \brief QA task for V0s in the jets framework, based on the LF v0cascadesqa task -// +/// /// \author Gijs van Weelden -// -#include "TH1F.h" -#include "TTree.h" +#include "JetDerivedDataUtilities.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/RunningWorkflowInfo.h" +#include "PWGJE/Core/JetFindingUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/V0SelectorTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include +#include +#include +#include +#include +#include -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/Core/JetFinder.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/Core/JetFindingUtilities.h" -#include "PWGLF/DataModel/V0SelectorTables.h" +#include + +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -44,58 +50,54 @@ using MCDV0JetsWithConstituents = soa::Join; using MatchedMCDV0JetsWithConstituents = soa::Join; +using CandidatesV0MCDWithFlags = soa::Join; + using MCPV0Jets = aod::V0ChargedMCParticleLevelJets; using MCPV0JetsWithConstituents = soa::Join; using MatchedMCPV0Jets = soa::Join; using MatchedMCPV0JetsWithConstituents = soa::Join; struct V0QA { - HistogramRegistry registry{"registry"}; // CallSumw2 = false? + HistogramRegistry registry{"registry"}; Configurable evSel{"evSel", "sel8WithoutTimeFrameBorderCut", "choose event selection"}; - Configurable v0cospaMin{"v0cospaMin", 0.995, "Minimum V0 cosine of pointing angle"}; - Configurable v0radiusMin{"v0radiusMin", 0.5, "Minimum V0 radius (cm)"}; - Configurable dcav0dauMax{"dcav0dauMax", 1.0, "Maximum DCA between V0 daughters (cm)"}; - Configurable dcapiMin{"dcapiMin", 0.1, "Minimum DCA of pion daughter to PV (cm)"}; - Configurable dcaprMin{"dcaprMin", 0.1, "Minimum DCA of proton daughter to PV (cm)"}; - Configurable yK0SMax{"yK0SMax", 0.5, "Maximum rapidity of K0S"}; - Configurable yLambdaMax{"yLambdaMax", 0.5, "Maximum rapidity of Lambda(bar)"}; - Configurable lifetimeK0SMax{"lifetimeK0SMax", 20.0, "Maximum lifetime of K0S (cm)"}; - Configurable lifetimeLambdaMax{"lifetimeLambdaMax", 30.0, "Maximum lifetime of Lambda (cm)"}; Configurable yPartMax{"yPartMax", 0.5, "Maximum rapidity of particles"}; Configurable vertexZCut{"vertexZCut", 10.0, "Vertex Z cut"}; Filter jetCollisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; - ConfigurableAxis binPtJet{"ptJet", {100., 0.0f, 50.0f}, ""}; - ConfigurableAxis binPtV0{"ptV0", {100., 0.0f, 50.0f}, ""}; + ConfigurableAxis binPtJet{"binPtJet", {100., 0.0f, 50.0f}, ""}; + ConfigurableAxis binPtV0{"binPtV0", {100., 0.0f, 50.0f}, ""}; + ConfigurableAxis binZV0{"binZV0", {100., 1e-3f, 1 + 1e-3f}, ""}; ConfigurableAxis binEta{"binEta", {100, -1.0f, 1.0f}, ""}; - ConfigurableAxis binPhi{"binPhi", {static_cast(TMath::Pi()) * 10 / 2, 0.0f, 2. * static_cast(TMath::Pi())}, ""}; + ConfigurableAxis binPhi{"binPhi", {constants::math::PI * 10 / 2, 0.0f, constants::math::TwoPI}, ""}; ConfigurableAxis binInvMassK0S{"binInvMassK0S", {200, 0.4f, 0.6f}, ""}; ConfigurableAxis binInvMassLambda{"binInvMassLambda", {200, 1.07f, 1.17f}, ""}; - ConfigurableAxis binV0Radius{"R", {100., 0.0f, 50.0f}, ""}; - ConfigurableAxis binV0CosPA{"cosPA", {50., 0.95f, 1.0f}, ""}; + ConfigurableAxis binV0Radius{"binV0Radius", {100., 0.0f, 50.0f}, ""}; + ConfigurableAxis binV0CosPA{"binV0CosPA", {50., 0.95f, 1.0f}, ""}; ConfigurableAxis binsDcaXY{"binsDcaXY", {100, -0.5f, 0.5f}, ""}; ConfigurableAxis binsDcaZ{"binsDcaZ", {100, -5.f, 5.f}, ""}; - ConfigurableAxis binPtDiff{"ptdiff", {200., -49.5f, 50.5f}, ""}; - ConfigurableAxis binITSNCl{"ITSNCl", {8, -0.5, 7.5}, ""}; - ConfigurableAxis binITSChi2NCl{"ITSChi2NCl", {100, 0, 40}, ""}; + ConfigurableAxis binPtDiff{"binPtDiff", {200., -49.5f, 50.5f}, ""}; + ConfigurableAxis binPtRelDiff{"binPtRelDiff", {100., -1.0f, 1.0f}, ""}; + ConfigurableAxis binITSNCl{"binITSNCl", {8, -0.5, 7.5}, ""}; + ConfigurableAxis binITSChi2NCl{"binITSChi2NCl", {100, 0, 40}, ""}; - ConfigurableAxis binTPCNCl{"TPCNCl", {165, -0.5, 164.5}, ""}; - ConfigurableAxis binTPCChi2NCl{"TPCChi2NCl", {100, 0, 10}, ""}; - ConfigurableAxis binTPCNClSharedFraction{"sharedFraction", {100, 0., 1.}, ""}; - ConfigurableAxis binTPCCrossedRowsOverFindableCl{"crossedOverFindable", {120, 0.0, 1.2}, ""}; + ConfigurableAxis binTPCNCl{"binTPCNCl", {165, -0.5, 164.5}, ""}; + ConfigurableAxis binTPCChi2NCl{"binTPCChi2NCl", {100, 0, 10}, ""}; + ConfigurableAxis binTPCNClSharedFraction{"binTPCNClSharedFraction", {100, 0., 1.}, ""}; + ConfigurableAxis binTPCCrossedRowsOverFindableCl{"binTPCCrossedRowsOverFindableCl", {120, 0.0, 1.2}, ""}; - int eventSelection = -1; + std::vector eventSelectionBits; void init(InitContext&) { - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(evSel)); + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(evSel)); const AxisSpec axisJetPt{binPtJet, "Jet Pt (GeV/c)"}; const AxisSpec axisV0Pt{binPtV0, "V0 Pt (GeV/c)"}; + const AxisSpec axisV0Z{binZV0, "z_{V0} = #it{p}_{T, V0} / #it{p}_{T, jet}"}; const AxisSpec axisEta{binEta, "Eta"}; const AxisSpec axisPhi{binPhi, "Phi"}; const AxisSpec axisV0Radius{binV0Radius, "V0 Radius (cm)"}; @@ -105,6 +107,7 @@ struct V0QA { const AxisSpec axisAntiLambdaM{binInvMassLambda, "M(#bar{p} #pi^{+}) (GeV/c^{2})"}; const AxisSpec axisPtDiff{binPtDiff, "Pt difference (GeV/c)"}; + const AxisSpec axisPtRelDiff{binPtRelDiff, "Pt relative difference"}; const AxisSpec axisDcaXY{binsDcaXY, "DCA_{xy} (cm)"}; const AxisSpec axisDcaZ{binsDcaZ, "DCA_{z} (cm)"}; const AxisSpec axisITSNCl{binITSNCl, "# clusters ITS"}; @@ -119,7 +122,7 @@ struct V0QA { const AxisSpec axisCrossedRowsOverFindable{binTPCCrossedRowsOverFindableCl, "Crossed rows / findable clusters TPC"}; if (doprocessFlags) { - registry.add("inclusive/V0Flags", "V0Flags", HistType::kTH2D, {{4, -0.5, 3.5}, {4, -0.5, 3.5}}); + registry.add("inclusive/V0Flags", "V0Flags", HistType::kTH2D, {{5, -0.5, 4.5}, {5, -0.5, 4.5}}); } if (doprocessMcD) { registry.add("inclusive/hEvents", "Events", {HistType::kTH1D, {{2, 0.0f, 2.0f}}}); @@ -157,8 +160,11 @@ struct V0QA { if (doprocessMcPJets) { registry.add("jets/hMcJetEvents", "MC Jet Events", {HistType::kTH1D, {{2, 0.0f, 2.0f}}}); registry.add("jets/GeneratedJetK0S", "Generated Jet K0S", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/GeneratedJetK0SFrag", "Generated Jet K0S", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); registry.add("jets/GeneratedJetLambda", "Generated Jet Lambda", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/GeneratedJetLambdaFrag", "Generated Jet Lambda", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); registry.add("jets/GeneratedJetAntiLambda", "Generated Jet AntiLambda", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/GeneratedJetAntiLambdaFrag", "Generated Jet AntiLambda", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); } if (doprocessCollisionAssociation) { registry.add("collisions/V0PtEta", "V0 Pt, Eta", HistType::kTH2D, {axisV0Pt, axisEta}); @@ -179,11 +185,17 @@ struct V0QA { registry.add("collisions/JetPtEtaV0Pt", "Jet Pt, Eta, V0 Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); registry.add("collisions/JetPtEtaV0PtWrongColl", "Jet Pt, Eta, V0 Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); registry.add("collisions/JetPtEtaK0SPtMass", "Jet Pt, Eta, K0S Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisK0SM}); + registry.add("collisions/JetPtEtaK0SFragMass", "Jet Pt, Eta, K0S Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Z, axisK0SM}); registry.add("collisions/JetPtEtaK0SPtMassWrongColl", "Jet Pt, Eta, K0S Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisK0SM}); + registry.add("collisions/JetPtEtaK0SFragMassWrongColl", "Jet Pt, Eta, K0S Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Z, axisK0SM}); registry.add("collisions/JetPtEtaLambdaPtMass", "Jet Pt, Eta, Lambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisLambdaM}); + registry.add("collisions/JetPtEtaLambdaFragMass", "Jet Pt, Eta, Lambda Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Z, axisLambdaM}); registry.add("collisions/JetPtEtaLambdaPtMassWrongColl", "Jet Pt, Eta, Lambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisLambdaM}); + registry.add("collisions/JetPtEtaLambdaFragMassWrongColl", "Jet Pt, Eta, Lambda Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Z, axisLambdaM}); registry.add("collisions/JetPtEtaAntiLambdaPtMass", "Jet Pt, Eta, AntiLambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisAntiLambdaM}); + registry.add("collisions/JetPtEtaAntiLambdaFragMass", "Jet Pt, Eta, AntiLambda Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Z, axisAntiLambdaM}); registry.add("collisions/JetPtEtaAntiLambdaPtMassWrongColl", "Jet Pt, Eta, AntiLambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisAntiLambdaM}); + registry.add("collisions/JetPtEtaAntiLambdaFragMassWrongColl", "Jet Pt, Eta, AntiLambda Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Z, axisAntiLambdaM}); registry.add("collisions/JetPtEtaXiMinusPtLambdaPt", "Jet Pt, #Xi^{-} Pt, #Lambda Pt", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisV0Pt}); registry.add("collisions/JetPtEtaXiMinusPtLambdaPtWrongColl", "Jet Pt, #Xi^{-} Pt, #Lambda Pt", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisV0Pt}); @@ -194,11 +206,16 @@ struct V0QA { registry.add("collisions/JetsPtEtaV0Pt", "Jets Pt, Eta, V0 Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt}); registry.add("collisions/JetsPtEtaV0PtWrongColl", "Jets Pt, Eta, V0 Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt}); registry.add("collisions/JetsPtEtaK0SPtMass", "Jets Pt, Eta, K0S Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisK0SM}); - registry.add("collisions/JetsPtEtaK0SPtMassWrongColl", "Jets Pt, Eta, K0S Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisK0SM}); + registry.add("collisions/JetsPtEtaK0SFragMass", "Jets Pt, Eta, K0S Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Z, axisK0SM}); + registry.add("collisions/JetsPtEtaK0SFragMassWrongColl", "Jets Pt, Eta, K0S Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Z, axisK0SM}); registry.add("collisions/JetsPtEtaLambdaPtMass", "Jets Pt, Eta, Lambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisLambdaM}); + registry.add("collisions/JetsPtEtaLambdaFragMass", "Jets Pt, Eta, Lambda Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Z, axisLambdaM}); registry.add("collisions/JetsPtEtaLambdaPtMassWrongColl", "Jets Pt, Eta, Lambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisLambdaM}); + registry.add("collisions/JetsPtEtaLambdaFragMassWrongColl", "Jets Pt, Eta, Lambda Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Z, axisLambdaM}); registry.add("collisions/JetsPtEtaAntiLambdaPtMass", "Jets Pt, Eta, AntiLambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisAntiLambdaM}); + registry.add("collisions/JetsPtEtaAntiLambdaFragMass", "Jets Pt, Eta, AntiLambda Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Z, axisAntiLambdaM}); registry.add("collisions/JetsPtEtaAntiLambdaPtMassWrongColl", "Jets Pt, Eta, AntiLambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisAntiLambdaM}); + registry.add("collisions/JetsPtEtaAntiLambdaFragMassWrongColl", "Jets Pt, Eta, AntiLambda Frag Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Z, axisAntiLambdaM}); registry.add("collisions/JetsPtEtaXiMinusPtLambdaPt", "Jets Pt, Eta, #Xi^{-} Pt, #Lambda Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisV0Pt}); registry.add("collisions/JetsPtEtaXiMinusPtLambdaPtWrongColl", "Jets Pt, Eta, #Xi^{-} Pt, #Lambda Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisV0Pt}); @@ -217,10 +234,42 @@ struct V0QA { registry.add("feeddown/JetsPtXiMinusPtLambdaPt", "Jets Pt, #Xi^{-} Pt, #Lambda Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisV0Pt, axisV0Pt}); registry.add("feeddown/JetsPtXiPlusPtAntiLambdaPt", "Jets Pt, #Xi^{+} Pt, #bar{#Lambda} Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisV0Pt, axisV0Pt}); } + if (doprocessTestWeightedJetFinder) { + registry.add("tests/weighted/JetPtEtaPhi", "Jet Pt, Eta, Phi", HistType::kTH3D, {axisJetPt, axisEta, axisPhi}); + registry.add("tests/weighted/JetPtEtaV0Pt", "Jet Pt, Eta, V0 Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/weighted/JetPtEtaV0Z", "Jet Pt, Eta, V0 Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + registry.add("tests/weighted/JetPtEtaK0SPt", "Jet Pt, Eta, K0S Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/weighted/JetPtEtaK0SZ", "Jet Pt, Eta, K0S Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + registry.add("tests/weighted/JetPtEtaLambdaPt", "Jet Pt, Eta, Lambda Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/weighted/JetPtEtaLambdaZ", "Jet Pt, Eta, Lambda Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + registry.add("tests/weighted/JetPtEtaAntiLambdaPt", "Jet Pt, Eta, AntiLambda Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/weighted/JetPtEtaAntiLambdaZ", "Jet Pt, Eta, AntiLambda Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + } + if (doprocessTestSubtractedJetFinder) { + registry.add("tests/nosub/JetPtEtaPhi", "Jet Pt, Eta, Phi", HistType::kTH3D, {axisJetPt, axisEta, axisPhi}); + registry.add("tests/nosub/JetPtEtaV0Pt", "Jet Pt, Eta, V0 Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/nosub/JetPtEtaV0Z", "Jet Pt, Eta, V0 Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + registry.add("tests/nosub/JetPtEtaK0SPt", "Jet Pt, Eta, K0S Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/nosub/JetPtEtaK0SZ", "Jet Pt, Eta, K0S Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + registry.add("tests/nosub/JetPtEtaLambdaPt", "Jet Pt, Eta, Lambda Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/nosub/JetPtEtaLambdaZ", "Jet Pt, Eta, Lambda Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + registry.add("tests/nosub/JetPtEtaAntiLambdaPt", "Jet Pt, Eta, AntiLambda Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/nosub/JetPtEtaAntiLambdaZ", "Jet Pt, Eta, AntiLambda Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + + registry.add("tests/sub/JetPtEtaPhi", "Jet Pt, Eta, Phi", HistType::kTH3D, {axisJetPt, axisEta, axisPhi}); + registry.add("tests/sub/JetPtEtaV0Pt", "Jet Pt, Eta, V0 Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/sub/JetPtEtaV0Z", "Jet Pt, Eta, V0 Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + registry.add("tests/sub/JetPtEtaK0SPt", "Jet Pt, Eta, K0S Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/sub/JetPtEtaK0SZ", "Jet Pt, Eta, K0S Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + registry.add("tests/sub/JetPtEtaLambdaPt", "Jet Pt, Eta, Lambda Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/sub/JetPtEtaLambdaZ", "Jet Pt, Eta, Lambda Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + registry.add("tests/sub/JetPtEtaAntiLambdaPt", "Jet Pt, Eta, AntiLambda Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("tests/sub/JetPtEtaAntiLambdaZ", "Jet Pt, Eta, AntiLambda Z", HistType::kTH3D, {axisJetPt, axisEta, axisV0Z}); + } if (doprocessV0TrackQA) { registry.add("tracks/Pos", "pos", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisEta, axisPhi}); registry.add("tracks/Neg", "neg", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisEta, axisPhi}); - registry.add("tracks/Pt", "pt", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/Pt", "pt", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff, axisPtRelDiff}); registry.add("tracks/PtMass", "pt mass", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM, axisLambdaM, axisAntiLambdaM}); registry.add("tracks/PtDiffMass", "ptdiff mass", HistType::kTHnSparseD, {axisV0Pt, axisPtDiff, axisK0SM, axisLambdaM, axisAntiLambdaM}); @@ -393,18 +442,18 @@ struct V0QA { } // init template - bool isCollisionReconstructed(T const& collision, U const& eventSelection) + bool isCollisionReconstructed(T const& collision, U const& eventSelectionBits) { if (!collision.has_mcCollision()) { return false; } - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return false; } return true; } template - bool V0sAreMatched(T const& v0, U const& particle, V const& /*tracks*/) + bool v0sAreMatched(T const& v0, U const& particle, V const& /*tracks*/) { // This is necessary, because the V0Labels table points to aod::McParticles, not to aod::CandidatesV0MCP auto negId = v0.template negTrack_as().mcParticleId(); @@ -412,54 +461,6 @@ struct V0QA { auto daughters = particle.daughtersIds(); return ((negId == daughters[0] && posId == daughters[1]) || (posId == daughters[0] && negId == daughters[1])); } - template - bool isV0Reconstructed(T collision, U const& v0, int pdg) - { - // TODO: This should use the JE V0 selector once it it ready! - if (v0.v0cosPA() < v0cospaMin) - return false; - if (v0.v0radius() < v0radiusMin) - return false; - if (v0.dcaV0daughters() > dcav0dauMax) - return false; - - // K0S - if (TMath::Abs(pdg) == 310) { - if (TMath::Abs(v0.dcapostopv()) < dcapiMin) - return false; - if (TMath::Abs(v0.dcanegtopv()) < dcapiMin) - return false; - if (TMath::Abs(v0.yK0Short()) > yK0SMax) - return false; - float ctauK0S = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; - if (ctauK0S > lifetimeK0SMax) - return false; - } - // Lambda - if (pdg == 3122) { - if (TMath::Abs(v0.dcapostopv()) < dcaprMin) - return false; - if (TMath::Abs(v0.dcanegtopv()) < dcapiMin) - return false; - if (TMath::Abs(v0.yLambda()) > yLambdaMax) - return false; - float ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - if (ctauLambda > lifetimeLambdaMax) - return false; - } - if (pdg == -3122) { - if (TMath::Abs(v0.dcapostopv()) < dcapiMin) - return false; - if (TMath::Abs(v0.dcanegtopv()) < dcaprMin) - return false; - if (TMath::Abs(v0.yLambda()) > yLambdaMax) - return false; - float ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; - if (ctauAntiLambda > lifetimeLambdaMax) - return false; - } - return true; - } template bool hasITSHit(T const& track, int layer) @@ -485,7 +486,7 @@ struct V0QA { registry.fill(HIST("tracks/Pos"), vPt, pPt, posTrack.eta(), posTrack.phi()); registry.fill(HIST("tracks/Neg"), vPt, nPt, negTrack.eta(), negTrack.phi()); - registry.fill(HIST("tracks/Pt"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/Pt"), vPt, pPt, nPt, dPt, dPt / vPt); registry.fill(HIST("tracks/PtMass"), vPt, pPt, nPt, mK, mL, mAL); registry.fill(HIST("tracks/PtDiffMass"), vPt, dPt, mK, mL, mAL); @@ -682,8 +683,6 @@ struct V0QA { registry.fill(HIST("tracks/TPC/negNClsCrossedRowsOverFindableCls"), vPt, pPt, nPt, negTrack.tpcCrossedRowsOverFindableCls()); } - using CandidatesV0MCDWithFlags = soa::Join; - void processDummy(aod::CandidatesV0MCD const&) {} PROCESS_SWITCH(V0QA, processDummy, "Dummy process function turned on by default", true); @@ -694,58 +693,66 @@ struct V0QA { int isAntiLambda = static_cast(v0.isAntiLambdaCandidate()); int isRejected = static_cast(v0.isRejectedCandidate()); - registry.fill(HIST("inclusive/V0Flags"), 0, 0, isK0S); - registry.fill(HIST("inclusive/V0Flags"), 1, 1, isLambda); - registry.fill(HIST("inclusive/V0Flags"), 2, 2, isAntiLambda); - registry.fill(HIST("inclusive/V0Flags"), 3, 3, isRejected); - - registry.fill(HIST("inclusive/V0Flags"), 0, 1, isK0S * isLambda); - registry.fill(HIST("inclusive/V0Flags"), 1, 0, isK0S * isLambda); - registry.fill(HIST("inclusive/V0Flags"), 0, 2, isK0S * isAntiLambda); - registry.fill(HIST("inclusive/V0Flags"), 2, 0, isK0S * isAntiLambda); - registry.fill(HIST("inclusive/V0Flags"), 0, 3, isK0S * isRejected); - registry.fill(HIST("inclusive/V0Flags"), 3, 0, isK0S * isRejected); - - registry.fill(HIST("inclusive/V0Flags"), 1, 2, isLambda * isAntiLambda); - registry.fill(HIST("inclusive/V0Flags"), 2, 1, isLambda * isAntiLambda); - registry.fill(HIST("inclusive/V0Flags"), 1, 3, isLambda * isRejected); - registry.fill(HIST("inclusive/V0Flags"), 3, 1, isLambda * isRejected); - - registry.fill(HIST("inclusive/V0Flags"), 2, 3, isAntiLambda * isRejected); - registry.fill(HIST("inclusive/V0Flags"), 3, 2, isAntiLambda * isRejected); + registry.fill(HIST("inclusive/V0Flags"), 0, 0, isRejected); + registry.fill(HIST("inclusive/V0Flags"), 1, 1, isK0S); + registry.fill(HIST("inclusive/V0Flags"), 2, 2, isLambda); + registry.fill(HIST("inclusive/V0Flags"), 3, 3, isAntiLambda); + + registry.fill(HIST("inclusive/V0Flags"), 0, 1, isRejected * isK0S); + registry.fill(HIST("inclusive/V0Flags"), 1, 0, isRejected * isK0S); + registry.fill(HIST("inclusive/V0Flags"), 0, 2, isRejected * isLambda); + registry.fill(HIST("inclusive/V0Flags"), 2, 0, isRejected * isLambda); + registry.fill(HIST("inclusive/V0Flags"), 0, 3, isRejected * isAntiLambda); + registry.fill(HIST("inclusive/V0Flags"), 3, 0, isRejected * isAntiLambda); + + registry.fill(HIST("inclusive/V0Flags"), 1, 2, isK0S * isLambda); + registry.fill(HIST("inclusive/V0Flags"), 2, 1, isK0S * isLambda); + registry.fill(HIST("inclusive/V0Flags"), 1, 3, isK0S * isAntiLambda); + registry.fill(HIST("inclusive/V0Flags"), 3, 1, isK0S * isAntiLambda); + + registry.fill(HIST("inclusive/V0Flags"), 2, 3, isLambda * isAntiLambda); + registry.fill(HIST("inclusive/V0Flags"), 3, 2, isLambda * isAntiLambda); + + // V0 satisfies 3+ classes + registry.fill(HIST("inclusive/V0Flags"), 0, 4, isRejected * isK0S * isLambda); + registry.fill(HIST("inclusive/V0Flags"), 4, 0, isRejected * isK0S * isLambda); + registry.fill(HIST("inclusive/V0Flags"), 1, 4, isRejected * isK0S * isAntiLambda); + registry.fill(HIST("inclusive/V0Flags"), 4, 1, isRejected * isK0S * isAntiLambda); + registry.fill(HIST("inclusive/V0Flags"), 2, 4, isRejected * isLambda * isAntiLambda); + registry.fill(HIST("inclusive/V0Flags"), 4, 2, isRejected * isLambda * isAntiLambda); + registry.fill(HIST("inclusive/V0Flags"), 3, 4, isRejected * isK0S * isLambda * isAntiLambda); + registry.fill(HIST("inclusive/V0Flags"), 4, 3, isRejected * isK0S * isLambda * isAntiLambda); + registry.fill(HIST("inclusive/V0Flags"), 4, 4, isK0S * isLambda * isAntiLambda); } PROCESS_SWITCH(V0QA, processFlags, "V0 flags", false); void processMcD(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, CandidatesV0MCDWithFlags const& v0s, aod::McParticles const&) { registry.fill(HIST("inclusive/hEvents"), 0.5); - if (!isCollisionReconstructed(jcoll, eventSelection)) { + if (!isCollisionReconstructed(jcoll, eventSelectionBits)) { return; } registry.fill(HIST("inclusive/hEvents"), 1.5); double weight = jcoll.mcCollision().weight(); for (const auto& v0 : v0s) { - if (!v0.has_mcParticle()) { + if (!v0.has_mcParticle()) continue; - } - int pdg = v0.mcParticle().pdgCode(); - // Check V0 decay kinematics if (v0.isRejectedCandidate()) continue; - // K0S - if (TMath::Abs(pdg) == 310) { + int pdg = v0.mcParticle().pdgCode(); + if (std::abs(pdg) == PDG_t::kK0Short) { registry.fill(HIST("inclusive/K0SPtEtaMass"), v0.pt(), v0.eta(), v0.mK0Short(), weight); registry.fill(HIST("inclusive/InvMassK0STrue"), v0.pt(), v0.v0radius(), v0.mK0Short(), weight); } // Lambda - if (pdg == 3122) { + if (pdg == PDG_t::kLambda0) { registry.fill(HIST("inclusive/LambdaPtEtaMass"), v0.pt(), v0.eta(), v0.mLambda(), weight); registry.fill(HIST("inclusive/InvMassLambdaTrue"), v0.pt(), v0.v0radius(), v0.mLambda(), weight); } - if (pdg == -3122) { + if (pdg == PDG_t::kLambda0Bar) { registry.fill(HIST("inclusive/AntiLambdaPtEtaMass"), v0.pt(), v0.eta(), v0.mAntiLambda(), weight); registry.fill(HIST("inclusive/InvMassAntiLambdaTrue"), v0.pt(), v0.v0radius(), v0.mAntiLambda(), weight); } @@ -758,42 +765,41 @@ struct V0QA { registry.fill(HIST("inclusive/hMcEvents"), 0.5); bool isReconstructed = false; - for (auto collision : collisions) { - if (!isCollisionReconstructed(collision, eventSelection)) { + for (const auto& collision : collisions) { + if (!isCollisionReconstructed(collision, eventSelectionBits)) continue; - } - if (collision.mcCollision().globalIndex() != mccoll.globalIndex()) { + + if (collision.mcCollision().globalIndex() != mccoll.globalIndex()) continue; - } + isReconstructed = true; break; } - if (!isReconstructed) { + if (!isReconstructed) return; - } registry.fill(HIST("inclusive/hMcEvents"), 1.5); double weight = mccoll.weight(); - for (auto& pv0 : pv0s) { + for (const auto& pv0 : pv0s) { if (!pv0.has_daughters()) continue; if (!pv0.isPhysicalPrimary()) continue; - if (TMath::Abs(pv0.y() > yPartMax)) + if (std::abs(pv0.y()) > yPartMax) continue; // Can calculate this from aod::CandidatesV0MCD (contains decay vertex) - double R_Decay = 1.0; + double rDecay = 1.0; - if (pv0.pdgCode() == 310) { - registry.fill(HIST("inclusive/GeneratedK0S"), pv0.pt(), pv0.eta(), R_Decay, weight); + if (pv0.pdgCode() == PDG_t::kK0Short) { + registry.fill(HIST("inclusive/GeneratedK0S"), pv0.pt(), pv0.eta(), rDecay, weight); } - if (pv0.pdgCode() == 3122) { - registry.fill(HIST("inclusive/GeneratedLambda"), pv0.pt(), pv0.eta(), R_Decay, weight); + if (pv0.pdgCode() == PDG_t::kLambda0) { + registry.fill(HIST("inclusive/GeneratedLambda"), pv0.pt(), pv0.eta(), rDecay, weight); } - if (pv0.pdgCode() == -3122) { - registry.fill(HIST("inclusive/GeneratedAntiLambda"), pv0.pt(), pv0.eta(), R_Decay, weight); + if (pv0.pdgCode() == PDG_t::kLambda0Bar) { + registry.fill(HIST("inclusive/GeneratedAntiLambda"), pv0.pt(), pv0.eta(), rDecay, weight); } } } @@ -802,18 +808,18 @@ struct V0QA { void processMcDJets(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, MCDV0JetsWithConstituents const& mcdjets, CandidatesV0MCDWithFlags const&, aod::McParticles const&) { registry.fill(HIST("jets/hJetEvents"), 0.5); - if (!isCollisionReconstructed(jcoll, eventSelection)) { + if (!isCollisionReconstructed(jcoll, eventSelectionBits)) return; - } + registry.fill(HIST("jets/hJetEvents"), 1.5); double weight = jcoll.mcCollision().weight(); for (const auto& mcdjet : mcdjets) { // if (!jetfindingutilities::isInEtaAcceptance(jet, -99., -99., v0EtaMin, v0EtaMax)) for (const auto& v0 : mcdjet.template candidates_as()) { - if (!v0.has_mcParticle()) { + if (!v0.has_mcParticle()) continue; - } + int pdg = v0.mcParticle().pdgCode(); // Check V0 decay kinematics @@ -821,16 +827,16 @@ struct V0QA { continue; // K0S - if (TMath::Abs(pdg) == 310) { + if (std::abs(pdg) == PDG_t::kK0Short) { registry.fill(HIST("jets/JetPtEtaK0SPt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); registry.fill(HIST("jets/InvMassJetK0STrue"), mcdjet.pt(), v0.pt(), v0.mK0Short(), weight); } // Lambda - if (pdg == 3122) { + if (pdg == PDG_t::kLambda0) { registry.fill(HIST("jets/JetPtEtaLambdaPt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); registry.fill(HIST("jets/InvMassJetLambdaTrue"), mcdjet.pt(), v0.pt(), v0.mLambda(), weight); } - if (pdg == -3122) { + if (pdg == PDG_t::kLambda0Bar) { registry.fill(HIST("jets/JetPtEtaAntiLambdaPt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); registry.fill(HIST("jets/InvMassJetAntiLambdaTrue"), mcdjet.pt(), v0.pt(), v0.mAntiLambda(), weight); } @@ -842,9 +848,9 @@ struct V0QA { void processMcDMatchedJets(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, MatchedMCDV0JetsWithConstituents const& mcdjets, MatchedMCPV0JetsWithConstituents const&, CandidatesV0MCDWithFlags const&, aod::CandidatesV0MCP const&, aod::JetTracksMCD const& jTracks, aod::McParticles const&) { registry.fill(HIST("jets/hMatchedJetEvents"), 0.5); - if (!isCollisionReconstructed(jcoll, eventSelection)) { + if (!isCollisionReconstructed(jcoll, eventSelectionBits)) return; - } + registry.fill(HIST("jets/hMatchedJetEvents"), 1.5); double weight = jcoll.mcCollision().weight(); @@ -856,7 +862,7 @@ struct V0QA { continue; for (const auto& pv0 : mcpjet.template candidates_as()) { - if (!V0sAreMatched(v0, pv0, jTracks)) + if (!v0sAreMatched(v0, pv0, jTracks)) continue; int pdg = pv0.pdgCode(); @@ -865,16 +871,16 @@ struct V0QA { continue; // K0S - if (TMath::Abs(pdg) == 310) { + if (std::abs(pdg) == PDG_t::kK0Short) { registry.fill(HIST("jets/JetsPtEtaK0SPt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); registry.fill(HIST("jets/InvMassJetsK0STrue"), mcpjet.pt(), mcdjet.pt(), v0.pt(), v0.mK0Short(), weight); } // Lambda - if (pdg == 3122) { + if (pdg == PDG_t::kLambda0) { registry.fill(HIST("jets/JetsPtEtaLambdaPt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); registry.fill(HIST("jets/InvMassJetsLambdaTrue"), mcpjet.pt(), mcdjet.pt(), v0.pt(), v0.mLambda(), weight); } - if (pdg == -3122) { + if (pdg == PDG_t::kLambda0Bar) { registry.fill(HIST("jets/JetsPtEtaAntiLambdaPt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); registry.fill(HIST("jets/InvMassJetsAntiLambdaTrue"), mcpjet.pt(), mcdjet.pt(), v0.pt(), v0.mAntiLambda(), weight); } @@ -890,41 +896,43 @@ struct V0QA { registry.fill(HIST("jets/hMcJetEvents"), 0.5); bool isReconstructed = false; - for (auto collision : collisions) { - if (!isCollisionReconstructed(collision, eventSelection)) { + for (const auto& collision : collisions) { + if (!isCollisionReconstructed(collision, eventSelectionBits)) continue; - } - if (collision.mcCollision().globalIndex() != mccoll.globalIndex()) { + + if (collision.mcCollision().globalIndex() != mccoll.globalIndex()) continue; - } + isReconstructed = true; break; } - if (!isReconstructed) { + if (!isReconstructed) return; - } registry.fill(HIST("jets/hMcJetEvents"), 1.5); double weight = mccoll.weight(); - for (auto& jet : jets) { - // if (!jetfindingutilities::isInEtaAcceptance(jet, -99., -99., v0EtaMin, v0EtaMax)) + for (const auto& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, -99., -99., -1. * yPartMax, yPartMax)) + continue; + for (const auto& pv0 : jet.template candidates_as()) { if (!pv0.has_daughters()) continue; if (!pv0.isPhysicalPrimary()) continue; - if (TMath::Abs(pv0.y() > yPartMax)) - continue; // TODO: Should actually check the jets - if (pv0.pdgCode() == 310) { + if (pv0.pdgCode() == PDG_t::kK0Short) { registry.fill(HIST("jets/GeneratedJetK0S"), jet.pt(), jet.eta(), pv0.pt(), weight); + registry.fill(HIST("jets/GeneratedJetK0SFrag"), jet.pt(), jet.eta(), pv0.pt() / jet.pt(), weight); } - if (pv0.pdgCode() == 3122) { + if (pv0.pdgCode() == PDG_t::kLambda0) { registry.fill(HIST("jets/GeneratedJetLambda"), jet.pt(), jet.eta(), pv0.pt(), weight); + registry.fill(HIST("jets/GeneratedJetLambdaFrag"), jet.pt(), jet.eta(), pv0.pt() / jet.pt(), weight); } - if (pv0.pdgCode() == -3122) { + if (pv0.pdgCode() == PDG_t::kLambda0Bar) { registry.fill(HIST("jets/GeneratedJetAntiLambda"), jet.pt(), jet.eta(), pv0.pt(), weight); + registry.fill(HIST("jets/GeneratedJetAntiLambdaFrag"), jet.pt(), jet.eta(), pv0.pt() / jet.pt(), weight); } } } @@ -934,16 +942,15 @@ struct V0QA { void processCollisionAssociation(soa::Filtered::iterator const& jcoll, CandidatesV0MCDWithFlags const& v0s, soa::Join const&, aod::McCollisions const&, aod::McParticles const&) { // Based on PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx - if (!jcoll.has_mcCollision()) { + if (!jcoll.has_mcCollision()) return; - } + auto mcColl = jcoll.template mcCollision_as>(); double weight = mcColl.weight(); for (const auto& v0 : v0s) { - if (!v0.has_mcParticle()) { + if (!v0.has_mcParticle()) continue; - } auto pv0 = v0.mcParticle(); bool correctCollision = (mcColl.mcCollisionId() == v0.mcParticle().mcCollisionId()); @@ -957,39 +964,39 @@ struct V0QA { if (!correctCollision) { registry.fill(HIST("collisions/V0PtEtaWrongColl"), pv0.pt(), pv0.eta(), weight); } - if (TMath::Abs(pdg) == 310) { + if (std::abs(pdg) == PDG_t::kK0Short) { registry.fill(HIST("collisions/K0SPtEtaMass"), pv0.pt(), pv0.eta(), v0.mK0Short(), weight); if (!correctCollision) { registry.fill(HIST("collisions/K0SPtEtaMassWrongColl"), pv0.pt(), pv0.eta(), v0.mK0Short(), weight); } } - if (pdg == 3122) { + if (pdg == PDG_t::kLambda0) { registry.fill(HIST("collisions/LambdaPtEtaMass"), pv0.pt(), pv0.eta(), v0.mLambda(), weight); if (!correctCollision) { registry.fill(HIST("collisions/LambdaPtEtaMassWrongColl"), pv0.pt(), pv0.eta(), v0.mLambda(), weight); } } - if (pdg == -3122) { + if (pdg == PDG_t::kLambda0Bar) { registry.fill(HIST("collisions/AntiLambdaPtEtaMass"), pv0.pt(), pv0.eta(), v0.mAntiLambda(), weight); if (!correctCollision) { registry.fill(HIST("collisions/AntiLambdaPtEtaMassWrongColl"), pv0.pt(), pv0.eta(), v0.mAntiLambda(), weight); } } // Feed-down from Xi - if (!v0.has_mcMotherParticle()) { + if (!v0.has_mcMotherParticle()) continue; - } + auto mother = v0.mcMotherParticle(); pdg = mother.pdgCode(); correctCollision = (mcColl.mcCollisionId() == mother.mcCollisionId()); - if (pdg == 3312) { // Xi- + if (pdg == PDG_t::kXiMinus) { registry.fill(HIST("collisions/XiMinusPtYLambdaPt"), mother.pt(), mother.y(), pv0.pt(), weight); if (!correctCollision) { registry.fill(HIST("collisions/XiMinusPtYLambdaPtWrongColl"), mother.pt(), mother.y(), pv0.pt(), weight); } } - if (pdg == -3312) { // Xi+ + if (pdg == PDG_t::kXiPlusBar) { registry.fill(HIST("collisions/XiPlusPtYAntiLambdaPt"), mother.pt(), mother.y(), pv0.pt(), weight); if (!correctCollision) { registry.fill(HIST("collisions/XiPlusPtYAntiLambdaPtWrongColl"), mother.pt(), mother.y(), pv0.pt(), weight); @@ -999,68 +1006,74 @@ struct V0QA { } PROCESS_SWITCH(V0QA, processCollisionAssociation, "V0 collision association", false); - void processCollisionAssociationJets(soa::Filtered::iterator const& jcoll, MCDV0JetsWithConstituents const& mcdjets, soa::Join const&, soa::Join const&, aod::McCollisions const&, aod::McParticles const&) + void processCollisionAssociationJets(soa::Filtered::iterator const& jcoll, MCDV0JetsWithConstituents const& mcdjets, CandidatesV0MCDWithFlags const&, soa::Join const&, aod::McCollisions const&, aod::McParticles const&) { - if (!jcoll.has_mcCollision()) { + if (!isCollisionReconstructed(jcoll, eventSelectionBits)) return; - } + auto mcColl = jcoll.template mcCollision_as>(); double weight = mcColl.weight(); for (const auto& mcdjet : mcdjets) { // Eta cut? - for (const auto& v0 : mcdjet.template candidates_as>()) { - if (!v0.has_mcParticle()) { + for (const auto& v0 : mcdjet.template candidates_as()) { + if (!v0.has_mcParticle()) continue; - } auto pv0 = v0.mcParticle(); bool correctCollision = (mcColl.mcCollisionId() == pv0.mcCollisionId()); int pdg = pv0.pdgCode(); + double z = v0.pt() / mcdjet.pt(); // Check V0 decay kinematics - if (!isV0Reconstructed(jcoll, v0, pdg)) + if (v0.isRejectedCandidate()) continue; - registry.fill(HIST("collisions/JetPtEtaV0Pt"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), weight); + registry.fill(HIST("collisions/JetPtEtaV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetPtEtaV0PtWrongColl"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), weight); + registry.fill(HIST("collisions/JetPtEtaV0PtWrongColl"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); } - if (TMath::Abs(pdg) == 310) { - registry.fill(HIST("collisions/JetPtEtaK0SPtMass"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mK0Short(), weight); + if (std::abs(pdg) == PDG_t::kK0Short) { + registry.fill(HIST("collisions/JetPtEtaK0SPtMass"), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mK0Short(), weight); + registry.fill(HIST("collisions/JetPtEtaK0SFragMass"), mcdjet.pt(), mcdjet.eta(), z, v0.mK0Short(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetPtEtaK0SPtMassWrongColl"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mK0Short(), weight); + registry.fill(HIST("collisions/JetPtEtaK0SPtMassWrongColl"), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mK0Short(), weight); + registry.fill(HIST("collisions/JetPtEtaK0SFragMassWrongColl"), mcdjet.pt(), mcdjet.eta(), z, v0.mK0Short(), weight); } } - if (pdg == 3122) { - registry.fill(HIST("collisions/JetPtEtaLambdaPtMass"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mLambda(), weight); + if (pdg == PDG_t::kLambda0) { + registry.fill(HIST("collisions/JetPtEtaLambdaPtMass"), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mLambda(), weight); + registry.fill(HIST("collisions/JetPtEtaLambdaFragMass"), mcdjet.pt(), mcdjet.eta(), z, v0.mLambda(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetPtEtaLambdaPtMassWrongColl"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mLambda(), weight); + registry.fill(HIST("collisions/JetPtEtaLambdaPtMassWrongColl"), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mLambda(), weight); + registry.fill(HIST("collisions/JetPtEtaLambdaFragMassWrongColl"), mcdjet.pt(), mcdjet.eta(), z, v0.mLambda(), weight); } } - if (pdg == -3122) { - registry.fill(HIST("collisions/JetPtEtaAntiLambdaPtMass"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mAntiLambda(), weight); + if (pdg == PDG_t::kLambda0Bar) { + registry.fill(HIST("collisions/JetPtEtaAntiLambdaPtMass"), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("collisions/JetPtEtaAntiLambdaFragMass"), mcdjet.pt(), mcdjet.eta(), z, v0.mAntiLambda(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetPtEtaAntiLambdaPtMassWrongColl"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("collisions/JetPtEtaAntiLambdaPtMassWrongColl"), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("collisions/JetPtEtaAntiLambdaFragMassWrongColl"), mcdjet.pt(), mcdjet.eta(), z, v0.mAntiLambda(), weight); } } - if (!v0.has_mcMotherParticle()) { + if (!v0.has_mcMotherParticle()) continue; - } + auto mother = v0.mcMotherParticle(); pdg = mother.pdgCode(); correctCollision = (mcColl.mcCollisionId() == mother.mcCollisionId()); - if (pdg == 3312) { // Xi- - registry.fill(HIST("collisions/JetPtEtaXiMinusPtLambdaPt"), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + if (pdg == PDG_t::kXiMinus) { + registry.fill(HIST("collisions/JetPtEtaXiMinusPtLambdaPt"), mcdjet.pt(), mcdjet.eta(), mother.pt(), v0.pt(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetPtEtaXiMinusPtLambdaPtWrongColl"), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + registry.fill(HIST("collisions/JetPtEtaXiMinusPtLambdaPtWrongColl"), mcdjet.pt(), mcdjet.eta(), mother.pt(), v0.pt(), weight); } } - if (pdg == -3312) { // Xi+ - registry.fill(HIST("collisions/JetPtEtaXiPlusPtAntiLambdaPt"), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + if (pdg == PDG_t::kXiPlusBar) { + registry.fill(HIST("collisions/JetPtEtaXiPlusPtAntiLambdaPt"), mcdjet.pt(), mcdjet.eta(), mother.pt(), v0.pt(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetPtEtaXiPlusPtAntiLambdaPtWrongColl"), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + registry.fill(HIST("collisions/JetPtEtaXiPlusPtAntiLambdaPtWrongColl"), mcdjet.pt(), mcdjet.eta(), mother.pt(), v0.pt(), weight); } } } // for v0s @@ -1068,69 +1081,77 @@ struct V0QA { } PROCESS_SWITCH(V0QA, processCollisionAssociationJets, "V0 in jets collision association", false); - void processCollisionAssociationMatchedJets(soa::Filtered::iterator const& jcoll, MatchedMCDV0JetsWithConstituents const& mcdjets, MatchedMCPV0JetsWithConstituents const&, soa::Join const&, soa::Join const&, aod::McCollisions const&, aod::McParticles const&, aod::JetTracksMCD const& jTracks) + void processCollisionAssociationMatchedJets(soa::Filtered::iterator const& jcoll, MatchedMCDV0JetsWithConstituents const& mcdjets, MatchedMCPV0JetsWithConstituents const&, CandidatesV0MCDWithFlags const&, aod::CandidatesV0MCP const&, soa::Join const&, aod::McCollisions const&, aod::McParticles const&, aod::JetTracksMCD const& jTracks) { - if (!jcoll.has_mcCollision()) { + if (!jcoll.has_mcCollision()) return; - } + auto mcColl = jcoll.template mcCollision_as>(); double weight = mcColl.weight(); for (const auto& mcdjet : mcdjets) { for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { - for (const auto& v0 : mcdjet.template candidates_as>()) { + for (const auto& v0 : mcdjet.template candidates_as()) { if (!v0.has_mcParticle()) continue; for (const auto& pv0 : mcpjet.template candidates_as()) { - if (!V0sAreMatched(v0, pv0, jTracks)) + if (!v0sAreMatched(v0, pv0, jTracks)) continue; + int pdg = pv0.pdgCode(); bool correctCollision = (mcColl.mcCollisionId() == pv0.mcCollisionId()); + double z = v0.pt() / mcdjet.pt(); // Check V0 decay kinematics - if (!isV0Reconstructed(jcoll, v0, pdg)) + if (v0.isRejectedCandidate()) continue; - registry.fill(HIST("collisions/JetsPtEtaV0Pt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), weight); + registry.fill(HIST("collisions/JetsPtEtaV0Pt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetsPtEtaV0PtWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), weight); + registry.fill(HIST("collisions/JetsPtEtaV0PtWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); } - if (TMath::Abs(pdg) == 310) { - registry.fill(HIST("collisions/JetsPtEtaK0SPtMass"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mK0Short(), weight); + if (std::abs(pdg) == PDG_t::kK0Short) { + registry.fill(HIST("collisions/JetsPtEtaK0SPtMass"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mK0Short(), weight); + registry.fill(HIST("collisions/JetsPtEtaK0SFragMass"), mcpjet.pt(), mcdjet.eta(), z, v0.mK0Short(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetsPtEtaK0SPtMassWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mK0Short(), weight); + registry.fill(HIST("collisions/JetsPtEtaK0SPtMassWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mK0Short(), weight); + registry.fill(HIST("collisions/JetsPtEtaK0SFragMassWrongColl"), mcpjet.pt(), mcdjet.eta(), z, v0.mK0Short(), weight); } } - if (pdg == 3122) { - registry.fill(HIST("collisions/JetsPtEtaLambdaPtMass"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mLambda(), weight); + if (pdg == PDG_t::kLambda0) { + registry.fill(HIST("collisions/JetsPtEtaLambdaPtMass"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mLambda(), weight); + registry.fill(HIST("collisions/JetsPtEtaLambdaFragMass"), mcpjet.pt(), mcdjet.eta(), z, v0.mLambda(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetsPtEtaLambdaPtMassWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mLambda(), weight); + registry.fill(HIST("collisions/JetsPtEtaLambdaPtMassWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mLambda(), weight); + registry.fill(HIST("collisions/JetsPtEtaLambdaFragMassWrongColl"), mcpjet.pt(), mcdjet.eta(), z, v0.mLambda(), weight); } } - if (pdg == -3122) { - registry.fill(HIST("collisions/JetsPtEtaAntiLambdaPtMass"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mAntiLambda(), weight); + if (pdg == PDG_t::kLambda0Bar) { + registry.fill(HIST("collisions/JetsPtEtaAntiLambdaPtMass"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("collisions/JetsPtEtaAntiLambdaFragMass"), mcpjet.pt(), mcdjet.eta(), z, v0.mAntiLambda(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetsPtEtaAntiLambdaPtMassWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("collisions/JetsPtEtaAntiLambdaPtMassWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), v0.pt(), v0.mAntiLambda(), weight); + registry.fill(HIST("collisions/JetsPtEtaAntiLambdaFragMassWrongColl"), mcpjet.pt(), mcdjet.eta(), z, v0.mAntiLambda(), weight); } } - if (!v0.has_mcMotherParticle()) { + if (!v0.has_mcMotherParticle()) continue; - } + auto mother = v0.mcMotherParticle(); pdg = mother.pdgCode(); correctCollision = (mcColl.mcCollisionId() == mother.mcCollisionId()); - if (pdg == 3312) { // Xi- - registry.fill(HIST("collisions/JetsPtEtaXiMinusPtLambdaPt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + if (pdg == PDG_t::kXiMinus) { + registry.fill(HIST("collisions/JetsPtEtaXiMinusPtLambdaPt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), v0.pt(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetsPtEtaXiMinusPtLambdaPtWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + registry.fill(HIST("collisions/JetsPtEtaXiMinusPtLambdaPtWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), v0.pt(), weight); } } - if (pdg == -3312) { // Xi+ - registry.fill(HIST("collisions/JetsPtEtaXiPlusPtAntiLambdaPt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + if (pdg == PDG_t::kXiPlusBar) { + registry.fill(HIST("collisions/JetsPtEtaXiPlusPtAntiLambdaPt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), v0.pt(), weight); if (!correctCollision) { - registry.fill(HIST("collisions/JetsPtEtaXiPlusPtAntiLambdaPtWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + registry.fill(HIST("collisions/JetsPtEtaXiPlusPtAntiLambdaPtWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), v0.pt(), weight); } } } // for pv0 @@ -1143,16 +1164,16 @@ struct V0QA { void processFeeddown(soa::Filtered::iterator const& jcoll, CandidatesV0MCDWithFlags const& v0s, aod::CandidatesV0MCP const&, soa::Join const&, aod::McCollisions const&, aod::McParticles const&) { // Based on PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx - if (!jcoll.has_mcCollision()) { + if (!jcoll.has_mcCollision()) return; - } + auto mcColl = jcoll.template mcCollision_as>(); double weight = mcColl.weight(); for (const auto& v0 : v0s) { - if (!v0.has_mcParticle()) { + if (!v0.has_mcParticle()) continue; - } + int pdg = v0.mcParticle().pdgCode(); // Check V0 decay kinematics @@ -1166,10 +1187,10 @@ struct V0QA { auto mother = v0.mcMotherParticle(); pdg = mother.pdgCode(); - if (pdg == 3312) { // Xi- + if (pdg == PDG_t::kXiMinus) { registry.fill(HIST("feeddown/XiMinusPtYLambdaPt"), mother.pt(), mother.y(), pv0.pt(), weight); } - if (pdg == -3312) { // Xi+ + if (pdg == PDG_t::kXiPlusBar) { registry.fill(HIST("feeddown/XiPlusPtYAntiLambdaPt"), mother.pt(), mother.y(), pv0.pt(), weight); } } @@ -1179,17 +1200,17 @@ struct V0QA { void processFeeddownJets(soa::Filtered::iterator const& jcoll, MCDV0JetsWithConstituents const& mcdjets, CandidatesV0MCDWithFlags const&, aod::CandidatesV0MCP const&, soa::Join const&, aod::McCollisions const&, aod::McParticles const&) { // Based on PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx - if (!jcoll.has_mcCollision()) { + if (!jcoll.has_mcCollision()) return; - } + auto mcColl = jcoll.template mcCollision_as>(); double weight = mcColl.weight(); for (const auto& mcdjet : mcdjets) { for (const auto& v0 : mcdjet.template candidates_as()) { - if (!v0.has_mcParticle()) { + if (!v0.has_mcParticle()) continue; - } + int pdg = v0.mcParticle().pdgCode(); // Check V0 decay kinematics @@ -1203,10 +1224,10 @@ struct V0QA { auto mother = v0.mcMotherParticle(); pdg = mother.pdgCode(); - if (pdg == 3312) { // Xi- + if (pdg == PDG_t::kXiMinus) { registry.fill(HIST("feeddown/JetPtXiMinusPtLambdaPt"), mcdjet.pt(), mother.pt(), pv0.pt(), weight); } - if (pdg == -3312) { // Xi+ + if (pdg == PDG_t::kXiPlusBar) { registry.fill(HIST("feeddown/JetPtXiPlusPtAntiLambdaPt"), mcdjet.pt(), mother.pt(), pv0.pt(), weight); } } @@ -1217,9 +1238,9 @@ struct V0QA { void processFeeddownMatchedJets(soa::Filtered::iterator const& jcoll, MatchedMCDV0JetsWithConstituents const& mcdjets, aod::JetTracksMCD const& jTracks, MatchedMCPV0JetsWithConstituents const&, CandidatesV0MCDWithFlags const&, aod::CandidatesV0MCP const&, soa::Join const&, aod::McCollisions const&, aod::McParticles const&) { // Based on PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx - if (!jcoll.has_mcCollision()) { + if (!jcoll.has_mcCollision()) return; - } + auto mcColl = jcoll.template mcCollision_as>(); double weight = mcColl.weight(); @@ -1232,7 +1253,7 @@ struct V0QA { continue; for (const auto& pv0 : mcpjet.template candidates_as()) { - if (!V0sAreMatched(v0, pv0, jTracks)) + if (!v0sAreMatched(v0, pv0, jTracks)) continue; int pdg = v0.mcParticle().pdgCode(); @@ -1243,10 +1264,10 @@ struct V0QA { auto mother = v0.mcMotherParticle(); pdg = mother.pdgCode(); - if (pdg == 3312) { // Xi- + if (pdg == PDG_t::kXiMinus) { registry.fill(HIST("feeddown/JetsPtXiMinusPtLambdaPt"), mcpjet.pt(), mcdjet.pt(), mother.pt(), pv0.pt(), weight); } - if (pdg == -3312) { // Xi+ + if (pdg == PDG_t::kXiPlusBar) { registry.fill(HIST("feeddown/JetsPtXiPlusPtAntiLambdaPt"), mcpjet.pt(), mcdjet.pt(), mother.pt(), pv0.pt(), weight); } } @@ -1256,17 +1277,121 @@ struct V0QA { } PROCESS_SWITCH(V0QA, processFeeddownMatchedJets, "Jets feeddown", false); + // Test the difference between excluding V0s from jet finding and subtracting V0s from jets afterwards + void processTestWeightedJetFinder(soa::Filtered::iterator const& jcoll, soa::Join const& jets, aod::CandidatesV0Data const&) + { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) + return; + + for (const auto& jet : jets) { + registry.fill(HIST("tests/weighted/JetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi()); + + for (const auto& v0 : jet.template candidates_as()) { + if (v0.isRejectedCandidate()) + continue; + + double z = v0.pt() / jet.pt(); + + registry.fill(HIST("tests/weighted/JetPtEtaV0Pt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("tests/weighted/JetPtEtaV0Z"), jet.pt(), jet.eta(), z); + + if (v0.isK0SCandidate()) { + registry.fill(HIST("tests/weighted/JetPtEtaK0SPt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("tests/weighted/JetPtEtaK0SZ"), jet.pt(), jet.eta(), z); + } + if (v0.isLambdaCandidate()) { + registry.fill(HIST("tests/weighted/JetPtEtaLambdaPt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("tests/weighted/JetPtEtaLambdaZ"), jet.pt(), jet.eta(), z); + } + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("tests/weighted/JetPtEtaAntiLambdaPt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("tests/weighted/JetPtEtaAntiLambdaZ"), jet.pt(), jet.eta(), z); + } + } + } + } + PROCESS_SWITCH(V0QA, processTestWeightedJetFinder, "Test weighted jet finder", false); + + void processTestSubtractedJetFinder(soa::Filtered::iterator const& jcoll, soa::Join const& jets, aod::CandidatesV0Data const&) + { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) + return; + + for (const auto& jet : jets) { + registry.fill(HIST("tests/nosub/JetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi()); + + std::vector v0Pt; + std::vector v0Type; + double ptjetsub = jet.pt(); + + for (const auto& v0 : jet.template candidates_as()) { + double z = v0.pt() / jet.pt(); + + registry.fill(HIST("tests/nosub/JetPtEtaV0Pt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("tests/nosub/JetPtEtaV0Z"), jet.pt(), jet.eta(), z); + + if (v0.isK0SCandidate()) { + registry.fill(HIST("tests/nosub/JetPtEtaK0SPt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("tests/nosub/JetPtEtaK0SZ"), jet.pt(), jet.eta(), z); + } + if (v0.isLambdaCandidate()) { + registry.fill(HIST("tests/nosub/JetPtEtaLambdaPt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("tests/nosub/JetPtEtaLambdaZ"), jet.pt(), jet.eta(), z); + } + if (v0.isAntiLambdaCandidate()) { + registry.fill(HIST("tests/nosub/JetPtEtaAntiLambdaPt"), jet.pt(), jet.eta(), v0.pt()); + registry.fill(HIST("tests/nosub/JetPtEtaAntiLambdaZ"), jet.pt(), jet.eta(), z); + } + + if (v0.isRejectedCandidate()) { + ptjetsub -= v0.pt(); + } else { // Accepted V0 + v0Pt.push_back(v0.pt()); + if (v0.isK0SCandidate()) { + v0Type.push_back(PDG_t::kK0Short); + } else if (v0.isLambdaCandidate()) { + v0Type.push_back(PDG_t::kLambda0); + } else if (v0.isAntiLambdaCandidate()) { + v0Type.push_back(PDG_t::kLambda0Bar); + } + } + } // V0s in jet loop + + registry.fill(HIST("tests/sub/JetPtEtaPhi"), ptjetsub, jet.eta(), jet.phi()); + for (unsigned int i = 0; i < v0Pt.size(); ++i) { + int type = v0Type[i]; + double pt = v0Pt[i]; + double z = pt / ptjetsub; + + registry.fill(HIST("tests/sub/JetPtEtaV0Pt"), ptjetsub, jet.eta(), pt); + registry.fill(HIST("tests/sub/JetPtEtaV0Z"), ptjetsub, jet.eta(), z); + + if (type == PDG_t::kK0Short) { + registry.fill(HIST("tests/sub/JetPtEtaK0SPt"), ptjetsub, jet.eta(), pt); + registry.fill(HIST("tests/sub/JetPtEtaK0SZ"), ptjetsub, jet.eta(), z); + } else if (type == PDG_t::kLambda0) { + registry.fill(HIST("tests/sub/JetPtEtaLambdaPt"), ptjetsub, jet.eta(), pt); + registry.fill(HIST("tests/sub/JetPtEtaLambdaZ"), ptjetsub, jet.eta(), z); + } else if (type == PDG_t::kLambda0Bar) { + registry.fill(HIST("tests/sub/JetPtEtaAntiLambdaPt"), ptjetsub, jet.eta(), pt); + registry.fill(HIST("tests/sub/JetPtEtaAntiLambdaZ"), ptjetsub, jet.eta(), z); + } + } // Accepted V0s in jet loop + } // Jets loop + } + PROCESS_SWITCH(V0QA, processTestSubtractedJetFinder, "Test subtracted jet finder", false); + using DaughterJTracks = soa::Join; using DaughterTracks = soa::Join; - void processV0TrackQA(aod::JetCollision const& /*jcoll*/, soa::Join const& v0s, DaughterJTracks const&, DaughterTracks const&) + void processV0TrackQA(aod::JetCollision const& /*jcoll*/, aod::CandidatesV0Data const& v0s, DaughterJTracks const&, DaughterTracks const&) { - // if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + // if (!jetderiveddatautilities::selectCollision(jcoll, eventSelectionBits)) { // return; // } for (const auto& v0 : v0s) { - if (v0.isRejectedCandidate()) { + if (v0.isRejectedCandidate()) continue; - } + fillTrackQa(v0); } } diff --git a/PWGLF/DataModel/LFCKSSpinalignmentTables.h b/PWGLF/DataModel/LFCKSSpinalignmentTables.h new file mode 100644 index 00000000000..7e6447459cc --- /dev/null +++ b/PWGLF/DataModel/LFCKSSpinalignmentTables.h @@ -0,0 +1,101 @@ +// 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. + +/// \file LFCKSSpinalignmentTables.h +/// \brief DataModel for Charged KStar spin alignment +/// +/// \author Prottay Das + +#ifndef PWGLF_DATAMODEL_LFCKSSPINALIGNMENTTABLES_H_ +#define PWGLF_DATAMODEL_LFCKSSPINALIGNMENTTABLES_H_ + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" + +#include + +namespace o2::aod +{ +namespace kshortpionevent +{ +DECLARE_SOA_COLUMN(Cent, cent, float); +DECLARE_SOA_COLUMN(CollIndex, collIndex, float); +DECLARE_SOA_COLUMN(PsiFT0C, psiFT0C, float); +DECLARE_SOA_COLUMN(PsiFT0A, psiFT0A, float); +DECLARE_SOA_COLUMN(PsiTPC, psiTPC, float); +} // namespace kshortpionevent +DECLARE_SOA_TABLE(KShortpionEvents, "AOD", "KSHORTPIONEVENT", + o2::soa::Index<>, + kshortpionevent::Cent, + kshortpionevent::CollIndex, + kshortpionevent::PsiFT0C, + kshortpionevent::PsiFT0A, + kshortpionevent::PsiTPC) +using KShortpionEvent = KShortpionEvents::iterator; + +namespace kshortpionpair +{ +DECLARE_SOA_INDEX_COLUMN(KShortpionEvent, kshortpionevent); +DECLARE_SOA_COLUMN(V0Cospa, v0Cospa, float); //! V0 Cospa +DECLARE_SOA_COLUMN(V0Radius, v0Radius, float); //! V0 Radius +DECLARE_SOA_COLUMN(DcaPositive, dcaPositive, float); //! DCA Positive +DECLARE_SOA_COLUMN(DcaNegative, dcaNegative, float); //! DCA Negative +DECLARE_SOA_COLUMN(DcaBetweenDaughter, dcaBetweenDaughter, float); //! DCA between daughters +DECLARE_SOA_COLUMN(V0Lifetime, v0Lifetime, float); //! KShort lifetime +DECLARE_SOA_COLUMN(KShortPx, kShortPx, float); //! KShort Px +DECLARE_SOA_COLUMN(KShortPy, kShortPy, float); //! KShort Py +DECLARE_SOA_COLUMN(KShortPz, kShortPz, float); //! KShort Pz +DECLARE_SOA_COLUMN(KShortMass, kShortMass, float); //! KShort Mass +DECLARE_SOA_COLUMN(PionBachPx, pionBachPx, float); //! Bachelor Pion Px +DECLARE_SOA_COLUMN(PionBachPy, pionBachPy, float); //! Bachelor Pion Py +DECLARE_SOA_COLUMN(PionBachPz, pionBachPz, float); //! Bachelor Pion Pz +DECLARE_SOA_COLUMN(PionBachSign, pionBachSign, int); //! Bachelor Pion Sign +DECLARE_SOA_COLUMN(PionBachTPC, pionBachTPC, float); //! Bachelor Pion nsigmatpc +DECLARE_SOA_COLUMN(PionBachTOFHit, pionBachTOFHit, int); //! Bachelor Pion tof hit availability +DECLARE_SOA_COLUMN(PionBachTOF, pionBachTOF, float); //! Bachelor Pion nsigmatof +DECLARE_SOA_COLUMN(PionBachIndex, pionBachIndex, int); //! Bachelor Pion index +DECLARE_SOA_COLUMN(PionIndex1, pionIndex1, int); //! Daughter Pion index1 +DECLARE_SOA_COLUMN(PionIndex2, pionIndex2, int); //! Daughter Pion index2 +} // namespace kshortpionpair +DECLARE_SOA_TABLE(KShortpionPairs, "AOD", "KSHORTPIONPAIR", + o2::soa::Index<>, + kshortpionpair::KShortpionEventId, + kshortpionpair::V0Cospa, + kshortpionpair::V0Radius, + kshortpionpair::DcaPositive, + kshortpionpair::DcaNegative, + kshortpionpair::DcaBetweenDaughter, + kshortpionpair::V0Lifetime, + // kshortpionpair::Armenteros, + kshortpionpair::KShortPx, + kshortpionpair::KShortPy, + kshortpionpair::KShortPz, + kshortpionpair::KShortMass, + kshortpionpair::PionBachPx, + kshortpionpair::PionBachPy, + kshortpionpair::PionBachPz, + kshortpionpair::PionBachSign, + kshortpionpair::PionBachTPC, + kshortpionpair::PionBachTOFHit, + kshortpionpair::PionBachTOF, + kshortpionpair::PionBachIndex, + kshortpionpair::PionIndex1, + kshortpionpair::PionIndex2); + +using KShortpionPair = KShortpionPairs::iterator; +} // namespace o2::aod +#endif // PWGLF_DATAMODEL_LFCKSSPINALIGNMENTTABLES_H_ diff --git a/PWGLF/DataModel/LFClusterStudiesTable.h b/PWGLF/DataModel/LFClusterStudiesTable.h index 88ca35a85d3..5c4755bbfcc 100644 --- a/PWGLF/DataModel/LFClusterStudiesTable.h +++ b/PWGLF/DataModel/LFClusterStudiesTable.h @@ -11,8 +11,8 @@ // // Author: Giorgio Alberto Lucia -#include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" #ifndef PWGLF_DATAMODEL_LFCLUSTERSTUDIESTABLE_H_ #define PWGLF_DATAMODEL_LFCLUSTERSTUDIESTABLE_H_ @@ -79,36 +79,10 @@ DECLARE_SOA_TABLE( DECLARE_SOA_TABLE( ClStTableMc, "AOD", "CLSTTABLEMC", - LFClusterStudiesTables::P, - LFClusterStudiesTables::Eta, - LFClusterStudiesTables::Phi, - LFClusterStudiesTables::ItsClusterSize, - LFClusterStudiesTables::PartID, LFClusterStudiesTables::PartIDMc); DECLARE_SOA_TABLE( ClStTableExtra, "AOD", "CLSTTABLEEXTRA", - LFClusterStudiesTables::P, - LFClusterStudiesTables::Eta, - LFClusterStudiesTables::Phi, - LFClusterStudiesTables::ItsClusterSize, - LFClusterStudiesTables::PartID, - LFClusterStudiesTables::PTPC, - LFClusterStudiesTables::PIDinTrk, - LFClusterStudiesTables::TpcNSigma, - LFClusterStudiesTables::TofNSigma, - LFClusterStudiesTables::TofMass, - LFClusterStudiesTables::CosPAMother, - LFClusterStudiesTables::MassMother); - -DECLARE_SOA_TABLE( - ClStTableMcExt, "AOD", "CLSTTABLEMCEXT", - LFClusterStudiesTables::P, - LFClusterStudiesTables::Eta, - LFClusterStudiesTables::Phi, - LFClusterStudiesTables::ItsClusterSize, - LFClusterStudiesTables::PartID, - LFClusterStudiesTables::PartIDMc, LFClusterStudiesTables::PTPC, LFClusterStudiesTables::PIDinTrk, LFClusterStudiesTables::TpcNSigma, diff --git a/PWGLF/DataModel/LFEbyeTables.h b/PWGLF/DataModel/LFEbyeTables.h index d7ff437ece4..59876ae59c1 100644 --- a/PWGLF/DataModel/LFEbyeTables.h +++ b/PWGLF/DataModel/LFEbyeTables.h @@ -24,8 +24,8 @@ DECLARE_SOA_COLUMN(Centrality, centrality, uint8_t); DECLARE_SOA_COLUMN(Zvtx, zvtx, float); DECLARE_SOA_COLUMN(ZvtxMask, zvtxMask, int8_t); DECLARE_SOA_COLUMN(TriggerMask, triggerMask, uint8_t); -DECLARE_SOA_COLUMN(Ntracklets, ntracklets, uint8_t); -DECLARE_SOA_COLUMN(V0Multiplicity, v0Multiplicity, uint8_t); +DECLARE_SOA_COLUMN(CBMultiplicity, cbMultiplicity, uint8_t); +DECLARE_SOA_COLUMN(Ntracks, ntracks, uint8_t); } // namespace LFEbyeCollTable DECLARE_SOA_TABLE(CollEbyeTables, "AOD", "COLLEBYETABLE", @@ -38,8 +38,9 @@ DECLARE_SOA_TABLE(MiniCollTables, "AOD", "MINICOLLTABLE", o2::soa::Index<>, LFEbyeCollTable::ZvtxMask, LFEbyeCollTable::TriggerMask, - LFEbyeCollTable::Ntracklets, - LFEbyeCollTable::V0Multiplicity); + LFEbyeCollTable::CBMultiplicity, + LFEbyeCollTable::Centrality, + LFEbyeCollTable::Ntracks); using MiniCollTable = MiniCollTables::iterator; namespace LFEbyeTable diff --git a/PWGLF/DataModel/LFHStrangeCorrelationTables.h b/PWGLF/DataModel/LFHStrangeCorrelationTables.h index 7f7578b3632..cbeedbdb66c 100644 --- a/PWGLF/DataModel/LFHStrangeCorrelationTables.h +++ b/PWGLF/DataModel/LFHStrangeCorrelationTables.h @@ -22,10 +22,15 @@ #ifndef PWGLF_DATAMODEL_LFHSTRANGECORRELATIONTABLES_H_ #define PWGLF_DATAMODEL_LFHSTRANGECORRELATIONTABLES_H_ -#include -#include "Framework/AnalysisDataModel.h" +/// this data model uses the LF one, add here +#include "PWGLF/DataModel/LFStrangenessTables.h" + #include "Common/Core/RecoDecay.h" + #include "CommonConstants/PhysicsConstants.h" +#include "Framework/AnalysisDataModel.h" + +#include // Simple checker #define bitcheck(var, nbit) ((var) & (1 << (nbit))) @@ -42,21 +47,36 @@ DECLARE_SOA_INDEX_COLUMN_FULL(Track, track, int, Tracks, "_Trigger"); //! DECLARE_SOA_COLUMN(MCOriginalPt, mcOriginalPt, float); // true generated pt } // namespace triggerTracks DECLARE_SOA_TABLE(TriggerTracks, "AOD", "TRIGGERTRACKS", o2::soa::Index<>, triggerTracks::CollisionId, triggerTracks::MCPhysicalPrimary, triggerTracks::TrackId, triggerTracks::MCOriginalPt); +namespace triggerTrackExtras +{ +DECLARE_SOA_COLUMN(Extra, extra, int); // true physical primary flag +} // namespace triggerTrackExtras +DECLARE_SOA_TABLE(TriggerTrackExtras, "AOD", "TRIGGERTRACKEXTRAs", triggerTrackExtras::Extra); /// _________________________________________ /// Table for storing assoc track indices -namespace assocPions -{ -DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! -DECLARE_SOA_INDEX_COLUMN_FULL(Track, track, int, Tracks, "_Assoc"); //! -} // namespace assocPions -DECLARE_SOA_TABLE(AssocPions, "AOD", "ASSOCPIONS", o2::soa::Index<>, assocPions::CollisionId, assocPions::TrackId); - namespace assocHadrons { DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! +DECLARE_SOA_COLUMN(MCPhysicalPrimary, mcPhysicalPrimary, bool); // true physical primary flag DECLARE_SOA_INDEX_COLUMN_FULL(Track, track, int, Tracks, "_Assoc"); //! +DECLARE_SOA_COLUMN(MCOriginalPt, mcOriginalPt, float); // true generated pt } // namespace assocHadrons -DECLARE_SOA_TABLE(AssocHadrons, "AOD", "ASSOCHADRONS", o2::soa::Index<>, assocHadrons::CollisionId, assocHadrons::TrackId); +DECLARE_SOA_TABLE(AssocHadrons, "AOD", "ASSOCHADRONS", o2::soa::Index<>, assocHadrons::CollisionId, assocHadrons::MCPhysicalPrimary, assocHadrons::TrackId, assocHadrons::MCOriginalPt); +/// _________________________________________ +/// Table for storing assoc track PID +namespace assocPID +{ +DECLARE_SOA_COLUMN(NSigmaTPCPi, nSigmaTPCPi, float); +DECLARE_SOA_COLUMN(NSigmaTPCKa, nSigmaTPCKa, float); +DECLARE_SOA_COLUMN(NSigmaTPCPr, nSigmaTPCPr, float); +DECLARE_SOA_COLUMN(NSigmaTPCEl, nSigmaTPCEl, float); +DECLARE_SOA_COLUMN(NSigmaTOFPi, nSigmaTOFPi, float); +DECLARE_SOA_COLUMN(NSigmaTOFKa, nSigmaTOFKa, float); +DECLARE_SOA_COLUMN(NSigmaTOFPr, nSigmaTOFPr, float); +DECLARE_SOA_COLUMN(NSigmaTOFEl, nSigmaTOFEl, float); +} // namespace assocPID +DECLARE_SOA_TABLE(AssocPID, "AOD", "ASSOCPID", assocPID::NSigmaTPCPi, assocPID::NSigmaTPCKa, assocPID::NSigmaTPCPr, assocPID::NSigmaTPCEl, assocPID::NSigmaTOFPi, assocPID::NSigmaTOFKa, assocPID::NSigmaTOFPr, assocPID::NSigmaTOFEl); + /// _________________________________________ /// Table for storing associated V0 indices namespace assocV0s diff --git a/PWGLF/DataModel/LFHyperNucleiKinkTables.h b/PWGLF/DataModel/LFHyperNucleiKinkTables.h new file mode 100644 index 00000000000..3f064f5225f --- /dev/null +++ b/PWGLF/DataModel/LFHyperNucleiKinkTables.h @@ -0,0 +1,124 @@ +// 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. +// +/// \file LFHyperNucleiKinkTables.h +/// \brief Slim hypernuclei kink tables +/// \author Yuanzhe Wang + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" + +#ifndef PWGLF_DATAMODEL_LFHYPERNUCLEIKINKTABLES_H_ +#define PWGLF_DATAMODEL_LFHYPERNUCLEIKINKTABLES_H_ + +namespace o2::aod +{ + +namespace hyperkink +{ +DECLARE_SOA_COLUMN(MagPolarity, magPolarity, int8_t); //! Magnetic field polarity +DECLARE_SOA_COLUMN(XPV, xPV, float); //! Primary vertex of the candidate (x direction) +DECLARE_SOA_COLUMN(YPV, yPV, float); //! Primary vertex of the candidate (y direction) +DECLARE_SOA_COLUMN(ZPV, zPV, float); //! Primary vertex of the candidate (z direction) +DECLARE_SOA_COLUMN(XSV, xSV, float); //! Decay vertex of the candidate (x direction) +DECLARE_SOA_COLUMN(YSV, ySV, float); //! Decay vertex of the candidate (y direction) +DECLARE_SOA_COLUMN(ZSV, zSV, float); //! Decay vertex of the candidate (z direction) +DECLARE_SOA_COLUMN(XMothIU, xMothIU, float); //! X of the mother track at the radii of ITS layer which has the outermost update +DECLARE_SOA_COLUMN(YMothIU, yMothIU, float); //! Y of the mother track at the radii of ITS layer which has the outermost update +DECLARE_SOA_COLUMN(ZMothIU, zMothIU, float); //! Z of the mother track at the radii of ITS layer which has the outermost update +DECLARE_SOA_COLUMN(PxMothSV, pxMothSV, float); //! Px of the mother track at the decay vertex +DECLARE_SOA_COLUMN(PyMothSV, pyMothSV, float); //! Py of the mother track at the decay vertex +DECLARE_SOA_COLUMN(PzMothSV, pzMothSV, float); //! Pz of the mother track at the decay vertex +DECLARE_SOA_COLUMN(RefitPxMothPV, refitPxMothPV, float); //! Refit Px of the mother track at the primary vertex +DECLARE_SOA_COLUMN(RefitPyMothPV, refitPyMothPV, float); //! Refit Py of the mother track at the primary vertex +DECLARE_SOA_COLUMN(RefitPzMothPV, refitPzMothPV, float); //! Refit Pz of the mother track at the primary vertex +DECLARE_SOA_COLUMN(RefitPxMothSV, refitPxMothSV, float); //! Refit Px of the mother track at the decay vertex +DECLARE_SOA_COLUMN(RefitPyMothSV, refitPyMothSV, float); //! Refit Py of the mother track at the decay vertex +DECLARE_SOA_COLUMN(RefitPzMothSV, refitPzMothSV, float); //! Refit Pz of the mother track at the decay vertex +DECLARE_SOA_COLUMN(PxDaugSV, pxDaugSV, float); //! Px of the daughter track at the decay vertex +DECLARE_SOA_COLUMN(PyDaugSV, pyDaugSV, float); //! Py of the daughter track at the decay vertex +DECLARE_SOA_COLUMN(PzDaugSV, pzDaugSV, float); //! Pz of the daughter track at the decay vertex +DECLARE_SOA_COLUMN(IsMatter, isMatter, bool); //! bool: true for matter +DECLARE_SOA_COLUMN(DcaMothPv, dcaMothPv, float); //! DCA of the mother to the primary vertex +DECLARE_SOA_COLUMN(DcaDaugPv, dcaDaugPv, float); //! DCA of the daughter kink to the primary vertex +DECLARE_SOA_COLUMN(DcaKinkTopo, dcaKinkTopo, float); //! DCA of the kink topology +DECLARE_SOA_COLUMN(ItsChi2Moth, itsChi2Moth, float); //! ITS chi2 of the mother track +DECLARE_SOA_COLUMN(ItsClusterSizesMoth, itsClusterSizesMoth, uint32_t); //! ITS cluster size of the mother track +DECLARE_SOA_COLUMN(ItsClusterSizesDaug, itsClusterSizesDaug, uint32_t); //! ITS cluster size of the daughter track +DECLARE_SOA_COLUMN(NSigmaTPCDaug, nSigmaTPCDaug, float); //! Number of tpc sigmas of the daughter track +DECLARE_SOA_COLUMN(NSigmaITSDaug, nSigmaITSDaug, float); //! Number of ITS sigmas of the daughter track +DECLARE_SOA_COLUMN(NSigmaTOFDaug, nSigmaTOFDaug, float); //! Number of TOF sigmas of the daughter track + +DECLARE_SOA_COLUMN(IsSignal, isSignal, bool); //! bool: true for hyperhelium4signal +DECLARE_SOA_COLUMN(IsSignalReco, isSignalReco, bool); //! bool: true if the signal is reconstructed +DECLARE_SOA_COLUMN(IsCollReco, isCollReco, bool); //! bool: true if the collision is reconstructed +DECLARE_SOA_COLUMN(IsSurvEvSelection, isSurvEvSelection, bool); //! bool: true for the collision passed the event selection +DECLARE_SOA_COLUMN(TrueXSV, trueXSV, float); //! true x decay vertex +DECLARE_SOA_COLUMN(TrueYSV, trueYSV, float); //! true y decay vertex +DECLARE_SOA_COLUMN(TrueZSV, trueZSV, float); //! true z decay vertex +DECLARE_SOA_COLUMN(TruePxMothPV, truePxMothPV, float); //! Generated px of the mother track +DECLARE_SOA_COLUMN(TruePyMothPV, truePyMothPV, float); //! Generated py of the mother track +DECLARE_SOA_COLUMN(TruePzMothPV, truePzMothPV, float); //! Generated pz of the mother track +DECLARE_SOA_COLUMN(TruePxMothSV, truePxMothSV, float); //! true px of the mother track at the decay vertex +DECLARE_SOA_COLUMN(TruePyMothSV, truePyMothSV, float); //! true py of the mother track at the decay vertex +DECLARE_SOA_COLUMN(TruePzMothSV, truePzMothSV, float); //! true pz of the mother track at the decay vertex +DECLARE_SOA_COLUMN(TruePxDaugSV, truePxDaugSV, float); //! true px of the daughter track at the decay vertex +DECLARE_SOA_COLUMN(TruePyDaugSV, truePyDaugSV, float); //! true py of the daughter track at the decay vertex +DECLARE_SOA_COLUMN(TruePzDaugSV, truePzDaugSV, float); //! true pz of the daughter track at the decay vertex +DECLARE_SOA_COLUMN(IsMothReco, isMothReco, bool); //! bool: true if the mother track is reconstructed +DECLARE_SOA_COLUMN(PxMothPV, pxMothPV, float); //! reconstructed px of the mother track at the primary vertex +DECLARE_SOA_COLUMN(PyMothPV, pyMothPV, float); //! reconstructed py of the mother track at the primary vertex +DECLARE_SOA_COLUMN(PzMothPV, pzMothPV, float); //! reconstructed pz of the mother track at the primary vertex +DECLARE_SOA_COLUMN(UpdatePxMothPV, updatePxMothPV, float); //! updated px of the mother track at the primary vertex after update using PV +DECLARE_SOA_COLUMN(UpdatePyMothPV, updatePyMothPV, float); //! updated py of the mother track at the primary vertex after update using PV +DECLARE_SOA_COLUMN(UpdatePzMothPV, updatePzMothPV, float); //! updated pz of the mother track at the primary vertex after update using PV +} // namespace hyperkink + +DECLARE_SOA_TABLE(HypKinkCand, "AOD", "HYPKINKCANDS", + o2::soa::Index<>, + hyperkink::MagPolarity, + hyperkink::XPV, hyperkink::YPV, hyperkink::ZPV, + hyperkink::XSV, hyperkink::YSV, hyperkink::ZSV, + hyperkink::IsMatter, + hyperkink::XMothIU, hyperkink::YMothIU, hyperkink::ZMothIU, + hyperkink::PxMothSV, hyperkink::PyMothSV, hyperkink::PzMothSV, + hyperkink::RefitPxMothPV, hyperkink::RefitPyMothPV, hyperkink::RefitPzMothPV, + hyperkink::RefitPxMothSV, hyperkink::RefitPyMothSV, hyperkink::RefitPzMothSV, + hyperkink::PxDaugSV, hyperkink::PyDaugSV, hyperkink::PzDaugSV, + hyperkink::DcaMothPv, hyperkink::DcaDaugPv, hyperkink::DcaKinkTopo, + hyperkink::ItsChi2Moth, hyperkink::ItsClusterSizesMoth, hyperkink::ItsClusterSizesDaug, + hyperkink::NSigmaTPCDaug, hyperkink::NSigmaITSDaug, hyperkink::NSigmaTOFDaug); + +DECLARE_SOA_TABLE(MCHypKinkCand, "AOD", "MCHYPKINKCANDS", + o2::soa::Index<>, + hyperkink::MagPolarity, + hyperkink::XPV, hyperkink::YPV, hyperkink::ZPV, + hyperkink::XSV, hyperkink::YSV, hyperkink::ZSV, + hyperkink::IsMatter, + hyperkink::XMothIU, hyperkink::YMothIU, hyperkink::ZMothIU, + hyperkink::PxMothSV, hyperkink::PyMothSV, hyperkink::PzMothSV, + hyperkink::RefitPxMothPV, hyperkink::RefitPyMothPV, hyperkink::RefitPzMothPV, + hyperkink::RefitPxMothSV, hyperkink::RefitPyMothSV, hyperkink::RefitPzMothSV, + hyperkink::PxDaugSV, hyperkink::PyDaugSV, hyperkink::PzDaugSV, + hyperkink::DcaMothPv, hyperkink::DcaDaugPv, hyperkink::DcaKinkTopo, + hyperkink::ItsChi2Moth, hyperkink::ItsClusterSizesMoth, hyperkink::ItsClusterSizesDaug, + hyperkink::NSigmaTPCDaug, hyperkink::NSigmaITSDaug, hyperkink::NSigmaTOFDaug, + hyperkink::IsSignal, hyperkink::IsSignalReco, hyperkink::IsCollReco, hyperkink::IsSurvEvSelection, + hyperkink::TrueXSV, hyperkink::TrueYSV, hyperkink::TrueZSV, + hyperkink::TruePxMothPV, hyperkink::TruePyMothPV, hyperkink::TruePzMothPV, + hyperkink::TruePxMothSV, hyperkink::TruePyMothSV, hyperkink::TruePzMothSV, + hyperkink::TruePxDaugSV, hyperkink::TruePyDaugSV, hyperkink::TruePzDaugSV, + hyperkink::IsMothReco, hyperkink::PxMothPV, hyperkink::PyMothPV, hyperkink::PzMothPV, + hyperkink::UpdatePxMothPV, hyperkink::UpdatePyMothPV, hyperkink::UpdatePzMothPV); + +} // namespace o2::aod + +#endif // PWGLF_DATAMODEL_LFHYPERNUCLEIKINKTABLES_H_ diff --git a/PWGLF/DataModel/LFHypernucleiKfTables.h b/PWGLF/DataModel/LFHypernucleiKfTables.h index 98f8076b2f6..0e2424f3bb5 100644 --- a/PWGLF/DataModel/LFHypernucleiKfTables.h +++ b/PWGLF/DataModel/LFHypernucleiKfTables.h @@ -45,6 +45,7 @@ DECLARE_SOA_COLUMN(Svx, svx, float); //! DECLARE_SOA_COLUMN(Svy, svy, float); //! DECLARE_SOA_COLUMN(Svz, svz, float); //! DECLARE_SOA_COLUMN(Occupancy, occupancy, int); //! +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); //! DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float px, float py) { return RecoDecay::pt(std::array{px, py}); }); DECLARE_SOA_DYNAMIC_COLUMN(Y, y, [](float E, float pz) { return 0.5 * std::log((E + pz) / (E - pz)); }); DECLARE_SOA_DYNAMIC_COLUMN(Mass, mass, [](float E, float px, float py, float pz) { return std::sqrt(E * E - px * px - py * py - pz * pz); }); @@ -80,7 +81,8 @@ DECLARE_SOA_TABLE(HypKfColls, "AOD", "HYPKFCOLL", cent::CentFT0A, cent::CentFT0C, cent::CentFT0M, - hykfmc::Occupancy); + hykfmc::Occupancy, + hykfmc::RunNumber); using HypKfColl = HypKfColls::iterator; namespace hykftrk @@ -102,14 +104,14 @@ DECLARE_SOA_DYNAMIC_COLUMN(Y, y, [](float pt, float eta, float mass) { return st DECLARE_SOA_DYNAMIC_COLUMN(Lambda, lambda, [](float eta) { return 1. / std::cosh(eta); }); DECLARE_SOA_DYNAMIC_COLUMN(ItsNcluster, itsNcluster, [](uint32_t itsClusterSizes) { uint8_t n = 0; - for (uint8_t i = 0; i < 7; i++) { + for (uint8_t i = 0; i < 0x08; i++) { if (itsClusterSizes >> (4 * i) & 15) n++; } return n; }); DECLARE_SOA_DYNAMIC_COLUMN(ItsFirstLayer, itsFirstLayer, [](uint32_t itsClusterSizes) { - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 0x08; i++) { if (itsClusterSizes >> (4 * i) & 15) return i; } @@ -117,7 +119,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(ItsFirstLayer, itsFirstLayer, [](uint32_t itsClusterS }); DECLARE_SOA_DYNAMIC_COLUMN(ItsMeanClsSize, itsMeanClsSize, [](uint32_t itsClusterSizes) { int sum = 0, n = 0; - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 0x08; i++) { sum += (itsClusterSizes >> (4 * i) & 15); if (itsClusterSizes >> (4 * i) & 15) n++; @@ -194,9 +196,9 @@ DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](float px, float py, float pz) { return R DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, [](float px, float py) { return RecoDecay::phi(std::array{px, py}); }); DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float px, float py, float pz) { return RecoDecay::p(px, py, pz); }); // DECLARE_SOA_DYNAMIC_COLUMN(Y, y, [](float px, float py, float pz, float mass) { return RecoDecay::y(std::array{px, py, pz}, mass); }); -DECLARE_SOA_DYNAMIC_COLUMN(McTrue, mcTrue, [](int hypKfMcPartId) { return hypKfMcPartId > 0; }); +DECLARE_SOA_DYNAMIC_COLUMN(McTrue, mcTrue, [](int hypKfMcPartId) { return hypKfMcPartId >= 0; }); DECLARE_SOA_DYNAMIC_COLUMN(IsMatter, isMatter, [](int8_t species) { return species > 0; }); -DECLARE_SOA_DYNAMIC_COLUMN(Cascade, cascade, [](int hypDaughter) { return hypDaughter > 0; }); +DECLARE_SOA_DYNAMIC_COLUMN(Cascade, cascade, [](int hypDaughter) { return hypDaughter >= 0; }); } // namespace hykfhyp DECLARE_SOA_TABLE(HypKfHypNucs, "AOD", "HYPKFHYPNUC", diff --git a/PWGLF/DataModel/LFHypernucleiTables.h b/PWGLF/DataModel/LFHypernucleiTables.h index e86ae9e42c7..f144daccba6 100644 --- a/PWGLF/DataModel/LFHypernucleiTables.h +++ b/PWGLF/DataModel/LFHypernucleiTables.h @@ -30,6 +30,7 @@ DECLARE_SOA_COLUMN(CentralityFT0M, centralityFT0M, float); // centrality with FT DECLARE_SOA_COLUMN(PsiFT0A, psiFT0A, float); // Psi with FT0A estimator DECLARE_SOA_COLUMN(MultFT0A, multFT0A, float); // Multiplicity with FT0A estimator DECLARE_SOA_COLUMN(PsiFT0C, psiFT0C, float); // Psi with FT0C estimator +DECLARE_SOA_COLUMN(QFT0C, qFT0C, float); // Amplitude with FT0C estimator DECLARE_SOA_COLUMN(MultFT0C, multFT0C, float); // Multiplicity with FT0C estimator DECLARE_SOA_COLUMN(PsiTPC, psiTPC, float); // Psi with TPC estimator DECLARE_SOA_COLUMN(MultTPC, multTPC, float); // Multiplicity with TPC estimator @@ -54,6 +55,8 @@ DECLARE_SOA_COLUMN(CosPA, cosPA, double); // Cosine DECLARE_SOA_COLUMN(NSigmaHe, nSigmaHe, float); // Number of sigmas of the He daughter DECLARE_SOA_COLUMN(NTPCclusHe, nTPCclusHe, uint8_t); // Number of TPC clusters of the He daughter DECLARE_SOA_COLUMN(NTPCclusPi, nTPCclusPi, uint8_t); // Number of TPC clusters of the Pi daughter +DECLARE_SOA_COLUMN(NTPCpidClusHe, nTPCpidClusHe, uint8_t); // Number of TPC clusters with PID information of the He daughter +DECLARE_SOA_COLUMN(NTPCpidClusPi, nTPCpidClusPi, uint8_t); // Number of TPC clusters with PID information of the Pi daughter DECLARE_SOA_COLUMN(TPCsignalHe, tpcSignalHe, uint16_t); // TPC signal of the He daughter DECLARE_SOA_COLUMN(TPCsignalPi, tpcSignalPi, uint16_t); // TPC signal of the Pi daughter DECLARE_SOA_COLUMN(TPCChi2He, tpcChi2He, float); // TPC chi2 of the He daughter @@ -90,7 +93,7 @@ DECLARE_SOA_TABLE(DataHypCands, "AOD", "HYPCANDS", hyperrec::PtPi, hyperrec::PhiPi, hyperrec::EtaPi, hyperrec::XDecVtx, hyperrec::YDecVtx, hyperrec::ZDecVtx, hyperrec::DcaV0Daug, hyperrec::DcaHe, hyperrec::DcaPi, - hyperrec::NSigmaHe, hyperrec::NTPCclusHe, hyperrec::NTPCclusPi, + hyperrec::NSigmaHe, hyperrec::NTPCclusHe, hyperrec::NTPCclusPi, hyperrec::NTPCpidClusHe, hyperrec::NTPCpidClusPi, hyperrec::TPCmomHe, hyperrec::TPCmomPi, hyperrec::TPCsignalHe, hyperrec::TPCsignalPi, hyperrec::TPCChi2He, hyperrec::TOFMass, hyperrec::ITSclusterSizesHe, hyperrec::ITSclusterSizesPi, @@ -100,7 +103,7 @@ DECLARE_SOA_TABLE(DataHypCandsFlow, "AOD", "HYPCANDSFLOW", o2::soa::Index<>, hyperrec::CentralityFT0A, hyperrec::CentralityFT0C, hyperrec::CentralityFT0M, hyperrec::PsiFT0A, hyperrec::MultFT0A, - hyperrec::PsiFT0C, hyperrec::MultFT0C, + hyperrec::PsiFT0C, hyperrec::MultFT0C, hyperrec::QFT0C, hyperrec::PsiTPC, hyperrec::MultTPC, hyperrec::XPrimVtx, hyperrec::YPrimVtx, hyperrec::ZPrimVtx, @@ -109,7 +112,7 @@ DECLARE_SOA_TABLE(DataHypCandsFlow, "AOD", "HYPCANDSFLOW", hyperrec::PtPi, hyperrec::PhiPi, hyperrec::EtaPi, hyperrec::XDecVtx, hyperrec::YDecVtx, hyperrec::ZDecVtx, hyperrec::DcaV0Daug, hyperrec::DcaHe, hyperrec::DcaPi, - hyperrec::NSigmaHe, hyperrec::NTPCclusHe, hyperrec::NTPCclusPi, + hyperrec::NSigmaHe, hyperrec::NTPCclusHe, hyperrec::NTPCclusPi, hyperrec::NTPCpidClusHe, hyperrec::NTPCpidClusPi, hyperrec::TPCmomHe, hyperrec::TPCmomPi, hyperrec::TPCsignalHe, hyperrec::TPCsignalPi, hyperrec::TPCChi2He, hyperrec::TOFMass, hyperrec::ITSclusterSizesHe, hyperrec::ITSclusterSizesPi, @@ -125,7 +128,7 @@ DECLARE_SOA_TABLE(MCHypCands, "AOD", "MCHYPCANDS", hyperrec::PtPi, hyperrec::PhiPi, hyperrec::EtaPi, hyperrec::XDecVtx, hyperrec::YDecVtx, hyperrec::ZDecVtx, hyperrec::DcaV0Daug, hyperrec::DcaHe, hyperrec::DcaPi, - hyperrec::NSigmaHe, hyperrec::NTPCclusHe, hyperrec::NTPCclusPi, + hyperrec::NSigmaHe, hyperrec::NTPCclusHe, hyperrec::NTPCclusPi, hyperrec::NTPCpidClusHe, hyperrec::NTPCpidClusPi, hyperrec::TPCmomHe, hyperrec::TPCmomPi, hyperrec::TPCsignalHe, hyperrec::TPCsignalPi, hyperrec::TPCChi2He, hyperrec::TOFMass, hyperrec::ITSclusterSizesHe, hyperrec::ITSclusterSizesPi, diff --git a/PWGLF/DataModel/LFKinkDecayTables.h b/PWGLF/DataModel/LFKinkDecayTables.h index 5f8798856d5..d8df2eb865f 100644 --- a/PWGLF/DataModel/LFKinkDecayTables.h +++ b/PWGLF/DataModel/LFKinkDecayTables.h @@ -15,10 +15,11 @@ /// \author Francesco Mazzaschi /// -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" #include "Common/Core/RecoDecay.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" + #ifndef PWGLF_DATAMODEL_LFKINKDECAYTABLES_H_ #define PWGLF_DATAMODEL_LFKINKDECAYTABLES_H_ @@ -46,6 +47,21 @@ DECLARE_SOA_COLUMN(DcaMothPv, dcaMothPv, float); //! DCA of the mother to th DECLARE_SOA_COLUMN(DcaDaugPv, dcaDaugPv, float); //! DCA of the daughter kink to the primary vertex DECLARE_SOA_COLUMN(DcaKinkTopo, dcaKinkTopo, float); //! DCA of the kink topology +DECLARE_SOA_COLUMN(NSigmaTPCPi, nSigmaTPCPi, float); //! Number of sigmas for the pion candidate from Sigma kink in TPC +DECLARE_SOA_COLUMN(NSigmaTPCPr, nSigmaTPCPr, float); //! Number of sigmas for the proton candidate from Sigma kink in TPC +DECLARE_SOA_COLUMN(NSigmaTPCKa, nSigmaTPCKa, float); //! Number of sigmas for the kaon candidate from Sigma kink in TPC +DECLARE_SOA_COLUMN(NSigmaTOFPi, nSigmaTOFPi, float); //! Number of sigmas for the pion candidate from Sigma kink in TOF +DECLARE_SOA_COLUMN(NSigmaTOFPr, nSigmaTOFPr, float); //! Number of sigmas for the proton candidate from Sigma kink in TOF +DECLARE_SOA_COLUMN(NSigmaTOFKa, nSigmaTOFKa, float); //! Number of sigmas for the kaon candidate from Sigma kink in TOF + +// MC Columns +DECLARE_SOA_COLUMN(MothPdgCode, mothPdgCode, int); //! PDG code of the Sigma daughter +DECLARE_SOA_COLUMN(DaugPdgCode, daugPdgCode, int); //! PDG code of the kink daughter +DECLARE_SOA_COLUMN(PtMC, ptMC, float); //! pT of the candidate in MC +DECLARE_SOA_COLUMN(MassMC, massMC, float); //! Invariant mass of the candidate in MC +DECLARE_SOA_COLUMN(DecayRadiusMC, decayRadiusMC, float); //! Decay radius of the candidate in MC +DECLARE_SOA_COLUMN(CollisionIdCheck, collisionIdCheck, bool); //! Check if mcDaughter collision ID matches the reconstructed collision ID + // DYNAMIC COLUMNS DECLARE_SOA_DYNAMIC_COLUMN(PxDaugNeut, pxDaugNeut, //! Px of the daughter neutral particle @@ -77,6 +93,13 @@ DECLARE_SOA_DYNAMIC_COLUMN(MSigmaPlus, mSigmaPlus, //! mass under sigma plus hyp float pzneut = pzmoth - pzch; return RecoDecay::m(std::array{std::array{pxch, pych, pzch}, std::array{pxneut, pyneut, pzneut}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionNeutral}); }); +DECLARE_SOA_DYNAMIC_COLUMN(MXiMinus, mXiMinus, //! mass under Xi minus hypothesis + [](float pxmoth, float pymoth, float pzmoth, float pxch, float pych, float pzch) -> float { + float pxneut = pxmoth - pxch; + float pyneut = pymoth - pych; + float pzneut = pzmoth - pzch; + return RecoDecay::m(std::array{std::array{pxch, pych, pzch}, std::array{pxneut, pyneut, pzneut}}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassLambda}); }); + } // namespace kinkcand DECLARE_SOA_TABLE(KinkCands, "AOD", "KINKCANDS", @@ -93,7 +116,44 @@ DECLARE_SOA_TABLE(KinkCands, "AOD", "KINKCANDS", kinkcand::PtMoth, kinkcand::PtDaug, kinkcand::MSigmaMinus, - kinkcand::MSigmaPlus); + kinkcand::MSigmaPlus, + kinkcand::MXiMinus); + +DECLARE_SOA_TABLE(KinkCandsUnbound, "AOD", "UBKINKCANDS", + o2::soa::Index<>, kinkcand::XDecVtx, kinkcand::YDecVtx, kinkcand::ZDecVtx, + kinkcand::MothSign, kinkcand::PxMoth, kinkcand::PyMoth, kinkcand::PzMoth, + kinkcand::PxDaug, kinkcand::PyDaug, kinkcand::PzDaug, + kinkcand::DcaMothPv, kinkcand::DcaDaugPv, kinkcand::DcaKinkTopo, + + // dynamic columns + kinkcand::PxDaugNeut, + kinkcand::PyDaugNeut, + kinkcand::PzDaugNeut, + kinkcand::PtMoth, + kinkcand::PtDaug, + kinkcand::MSigmaMinus, + kinkcand::MSigmaPlus, + kinkcand::MXiMinus); + +DECLARE_SOA_TABLE(SlimKinkCands, "AOD", "SLIMKINKCANDS", + kinkcand::XDecVtx, kinkcand::YDecVtx, kinkcand::ZDecVtx, + kinkcand::PxMoth, kinkcand::PyMoth, kinkcand::PzMoth, + kinkcand::PxDaug, kinkcand::PyDaug, kinkcand::PzDaug, + kinkcand::DcaMothPv, kinkcand::DcaDaugPv, kinkcand::DcaKinkTopo, + kinkcand::MothSign, + kinkcand::NSigmaTPCPi, kinkcand::NSigmaTPCPr, kinkcand::NSigmaTPCKa, + kinkcand::NSigmaTOFPi, kinkcand::NSigmaTOFPr, kinkcand::NSigmaTOFKa); + +DECLARE_SOA_TABLE(SlimKinkCandsMC, "AOD", "SLIMKINKCANDSMC", + kinkcand::XDecVtx, kinkcand::YDecVtx, kinkcand::ZDecVtx, + kinkcand::PxMoth, kinkcand::PyMoth, kinkcand::PzMoth, + kinkcand::PxDaug, kinkcand::PyDaug, kinkcand::PzDaug, + kinkcand::DcaMothPv, kinkcand::DcaDaugPv, kinkcand::DcaKinkTopo, + kinkcand::MothSign, + kinkcand::NSigmaTPCPi, kinkcand::NSigmaTPCPr, kinkcand::NSigmaTPCKa, + kinkcand::NSigmaTOFPi, kinkcand::NSigmaTOFPr, kinkcand::NSigmaTOFKa, + kinkcand::MothPdgCode, kinkcand::DaugPdgCode, + kinkcand::PtMC, kinkcand::MassMC, kinkcand::DecayRadiusMC, kinkcand::CollisionIdCheck); } // namespace o2::aod diff --git a/PWGLF/DataModel/LFLambda1405Table.h b/PWGLF/DataModel/LFLambda1405Table.h new file mode 100644 index 00000000000..1425a345375 --- /dev/null +++ b/PWGLF/DataModel/LFLambda1405Table.h @@ -0,0 +1,88 @@ +// 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. + +/// +/// \file LFLambda1405Tables.h +/// \brief Slim tables for Lambda(1405) candidates +/// \author Francesco Mazzaschi +/// + +#include "Common/Core/RecoDecay.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" + +#ifndef PWGLF_DATAMODEL_LFLAMBDA1405TABLES_H_ +#define PWGLF_DATAMODEL_LFLAMBDA1405TABLES_H_ + +namespace o2::aod +{ + +namespace lambda1405 +{ + +DECLARE_SOA_COLUMN(Px, px, float); //! Px of the candidate +DECLARE_SOA_COLUMN(Py, py, float); //! Py of the candidate +DECLARE_SOA_COLUMN(Pz, pz, float); //! Pz of the candidate +DECLARE_SOA_COLUMN(Mass, mass, float); //! Invariant mass of the candidate +DECLARE_SOA_COLUMN(MassXi1530, massXi1530, float); //! Invariant mass of the Xi(1530) candidate +DECLARE_SOA_COLUMN(SigmaMinusMass, sigmaMinusMass, float); //! Invariant mass of the Sigma- candidate +DECLARE_SOA_COLUMN(SigmaPlusMass, sigmaPlusMass, float); //! Invariant mass of the Sigma+ candidate +DECLARE_SOA_COLUMN(XiMinusMass, xiMinusMass, float); //! Invariant mass of the Xi- candidate +DECLARE_SOA_COLUMN(PtSigma, ptSigma, float); //! Signed pT of the Sigma daughter +DECLARE_SOA_COLUMN(AlphaAPSigma, alphaAPSigma, float); //! Alpha of the Sigma +DECLARE_SOA_COLUMN(QtAPSigma, qtAPSigma, float); //! qT of the Sigma +DECLARE_SOA_COLUMN(RadiusSigma, radiusSigma, float); //! Radius of the Sigma decay vertex +DECLARE_SOA_COLUMN(PtKink, ptKink, float); //! pT of the kink daughter +DECLARE_SOA_COLUMN(NSigmaTPCPiKink, nSigmaTPCPiKink, float); //! Number of sigmas for the pion candidate from Sigma kink in TPC +DECLARE_SOA_COLUMN(NSigmaTOFPiKink, nSigmaTOFPiKink, float); //! Number of sigmas for the pion candidate from Sigma kink in TOF +DECLARE_SOA_COLUMN(NSigmaTPCPrKink, nSigmaTPCPrKink, float); //! Number of sigmas for the proton candidate from Sigma kink in TPC +DECLARE_SOA_COLUMN(NSigmaTOFPrKink, nSigmaTOFPrKink, float); //! Number of sigmas for the proton candidate from Sigma kink in TOF +DECLARE_SOA_COLUMN(DCAKinkDauToPV, dcaKinkDauToPV, float); //! DCA of the kink daughter to the primary vertex +DECLARE_SOA_COLUMN(NSigmaTPCPiDau, nSigmaTPCPiDau, float); //! Number of sigmas for the lambda1405 pion daughter in TPC +DECLARE_SOA_COLUMN(NSigmaTOFPiDau, nSigmaTOFPiDau, float); //! Number of sigmas for the lambda1405 pion daughter in TOF + +// MC Columns +DECLARE_SOA_COLUMN(PtMC, ptMC, float); //! pT of the candidate in MC +DECLARE_SOA_COLUMN(MassMC, massMC, float); //! Invariant mass of the candidate in MC +DECLARE_SOA_COLUMN(SigmaPdgCode, sigmaPdgCode, int); //! PDG code of the Sigma daughter +DECLARE_SOA_COLUMN(KinkDauPdgCode, kinkDauPdgCode, int); //! PDG code of the kink daughter + +} // namespace lambda1405 + +DECLARE_SOA_TABLE(Lambda1405Cands, "AOD", "LAMBDA1405", + o2::soa::Index<>, + lambda1405::Px, lambda1405::Py, lambda1405::Pz, + lambda1405::Mass, lambda1405::MassXi1530, + lambda1405::SigmaMinusMass, lambda1405::SigmaPlusMass, lambda1405::XiMinusMass, + lambda1405::PtSigma, lambda1405::AlphaAPSigma, lambda1405::QtAPSigma, lambda1405::RadiusSigma, + lambda1405::PtKink, + lambda1405::NSigmaTPCPiKink, lambda1405::NSigmaTOFPiKink, + lambda1405::NSigmaTPCPrKink, lambda1405::NSigmaTOFPrKink, + lambda1405::DCAKinkDauToPV, + lambda1405::NSigmaTPCPiDau, lambda1405::NSigmaTOFPiDau); + +DECLARE_SOA_TABLE(Lambda1405CandsMC, "AOD", "MCLAMBDA1405", + o2::soa::Index<>, + lambda1405::Px, lambda1405::Py, lambda1405::Pz, + lambda1405::Mass, lambda1405::MassXi1530, + lambda1405::SigmaMinusMass, lambda1405::SigmaPlusMass, lambda1405::XiMinusMass, + lambda1405::PtSigma, lambda1405::AlphaAPSigma, lambda1405::QtAPSigma, lambda1405::RadiusSigma, + lambda1405::PtKink, + lambda1405::NSigmaTPCPiKink, lambda1405::NSigmaTOFPiKink, + lambda1405::NSigmaTPCPrKink, lambda1405::NSigmaTOFPrKink, + lambda1405::DCAKinkDauToPV, + lambda1405::NSigmaTPCPiDau, lambda1405::NSigmaTOFPiDau, + lambda1405::PtMC, lambda1405::MassMC, lambda1405::SigmaPdgCode, lambda1405::KinkDauPdgCode); + +} // namespace o2::aod + +#endif // PWGLF_DATAMODEL_LFLAMBDA1405TABLES_H_ diff --git a/PWGLF/DataModel/LFNonPromptCascadeTables.h b/PWGLF/DataModel/LFNonPromptCascadeTables.h index e6ed9470c46..b698164abd4 100644 --- a/PWGLF/DataModel/LFNonPromptCascadeTables.h +++ b/PWGLF/DataModel/LFNonPromptCascadeTables.h @@ -26,6 +26,7 @@ namespace NPCascadeTable { DECLARE_SOA_COLUMN(MatchingChi2, matchingChi2, float); DECLARE_SOA_COLUMN(DeltaPtITSCascade, deltaPtITSCascade, float); +DECLARE_SOA_COLUMN(DeltaPtCascade, deltaPtCascade, float); DECLARE_SOA_COLUMN(ITSClusSize, itsClusSize, float); DECLARE_SOA_COLUMN(HasReassociatedCluster, hasReassociatedCluster, bool); DECLARE_SOA_COLUMN(IsGoodMatch, isGoodMatch, bool); @@ -39,6 +40,8 @@ DECLARE_SOA_COLUMN(PvX, pvX, float); DECLARE_SOA_COLUMN(PvY, pvY, float); DECLARE_SOA_COLUMN(PvZ, pvZ, float); +DECLARE_SOA_COLUMN(CascPVContribs, cascPVContribs, uint8_t); + DECLARE_SOA_COLUMN(CascPt, cascPt, float); DECLARE_SOA_COLUMN(CascEta, cascEta, float); DECLARE_SOA_COLUMN(CascPhi, cascPhi, float); @@ -72,16 +75,14 @@ DECLARE_SOA_COLUMN(V0Radius, v0Radius, float); DECLARE_SOA_COLUMN(CascLenght, cascLenght, float); DECLARE_SOA_COLUMN(V0Lenght, v0Lenght, float); -DECLARE_SOA_COLUMN(CascNClusITS, cascNClusITS, int); -DECLARE_SOA_COLUMN(ProtonNClusITS, protonNClusITS, int); -DECLARE_SOA_COLUMN(PionNClusITS, pionNClusITS, int); -DECLARE_SOA_COLUMN(BachKaonNClusITS, bachKaonNClusITS, int); -DECLARE_SOA_COLUMN(BachPionNClusITS, bachPionNClusITS, int); +DECLARE_SOA_COLUMN(CascNClusITS, cascNClusITS, int16_t); +DECLARE_SOA_COLUMN(ProtonNClusITS, protonNClusITS, int16_t); +DECLARE_SOA_COLUMN(PionNClusITS, pionNClusITS, int16_t); +DECLARE_SOA_COLUMN(BachNClusITS, bachNClusITS, int16_t); -DECLARE_SOA_COLUMN(ProtonNClusTPC, protonNClusTPC, int); -DECLARE_SOA_COLUMN(PionNClusTPC, pionNClusTPC, int); -DECLARE_SOA_COLUMN(BachKaonNClusTPC, bachKaonNClusTPC, int); -DECLARE_SOA_COLUMN(BachPionNClusTPC, bachPionNClusTPC, int); +DECLARE_SOA_COLUMN(ProtonNClusTPC, protonNClusTPC, int16_t); +DECLARE_SOA_COLUMN(PionNClusTPC, pionNClusTPC, int16_t); +DECLARE_SOA_COLUMN(BachNClusTPC, bachNClusTPC, int16_t); DECLARE_SOA_COLUMN(ProtonTPCNSigma, protonTPCNSigma, float); DECLARE_SOA_COLUMN(PionTPCNSigma, pionTPCNSigma, float); @@ -90,8 +91,7 @@ DECLARE_SOA_COLUMN(BachPionTPCNSigma, bachPionTPCNSigma, float); DECLARE_SOA_COLUMN(ProtonHasTOF, protonHasTOF, bool); DECLARE_SOA_COLUMN(PionHasTOF, pionHasTOF, bool); -DECLARE_SOA_COLUMN(BachKaonHasTOF, bachKaonHasTOF, bool); -DECLARE_SOA_COLUMN(BachPionHasTOF, bachPionHasTOF, bool); +DECLARE_SOA_COLUMN(BachHasTOF, bachHasTOF, bool); DECLARE_SOA_COLUMN(ProtonTOFNSigma, protonTOFNSigma, float); DECLARE_SOA_COLUMN(PionTOFNSigma, pionTOFNSigma, float); @@ -101,19 +101,102 @@ DECLARE_SOA_COLUMN(BachPionTOFNSigma, bachPionTOFNSigma, float); DECLARE_SOA_COLUMN(gPt, genPt, float); DECLARE_SOA_COLUMN(gEta, genEta, float); DECLARE_SOA_COLUMN(gPhi, genPhi, float); +DECLARE_SOA_COLUMN(gVx, genVx, float); +DECLARE_SOA_COLUMN(gVy, genVy, float); +DECLARE_SOA_COLUMN(gVz, genVz, float); DECLARE_SOA_COLUMN(PDGcode, pdgCode, int); DECLARE_SOA_COLUMN(DCAxMC, dcaXmc, float); DECLARE_SOA_COLUMN(DCAyMC, dcaYmc, float); DECLARE_SOA_COLUMN(DCAzMC, dcaZmc, float); DECLARE_SOA_COLUMN(MCcollisionMatch, mcCollisionMatch, bool); +DECLARE_SOA_COLUMN(HasFakeReassociation, hasFakeReassociation, bool); +DECLARE_SOA_COLUMN(MotherDecayDaughters, motherDecayDaughters, int8_t); + +DECLARE_SOA_COLUMN(Sel8, sel8, bool); +DECLARE_SOA_COLUMN(MultFT0C, multFT0C, float); +DECLARE_SOA_COLUMN(MultFT0A, multFT0A, float); +DECLARE_SOA_COLUMN(MultFT0M, multFT0M, float); +DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); +DECLARE_SOA_COLUMN(CentFT0A, centFT0A, float); +DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); +DECLARE_SOA_COLUMN(MultNTracksGlobal, multNTracksGlobal, int); +DECLARE_SOA_COLUMN(ToiMask, toiMask, uint32_t); } // namespace NPCascadeTable DECLARE_SOA_TABLE(NPCascTable, "AOD", "NPCASCTABLE", NPCascadeTable::MatchingChi2, NPCascadeTable::DeltaPtITSCascade, + NPCascadeTable::DeltaPtCascade, + NPCascadeTable::ITSClusSize, + NPCascadeTable::HasReassociatedCluster, + aod::collision::NumContrib, + NPCascadeTable::CascPVContribs, + aod::collision::CollisionTimeRes, + NPCascadeTable::PvX, + NPCascadeTable::PvY, + NPCascadeTable::PvZ, + NPCascadeTable::CascPt, + NPCascadeTable::CascEta, + NPCascadeTable::CascPhi, + NPCascadeTable::ProtonPt, + NPCascadeTable::ProtonEta, + NPCascadeTable::PionPt, + NPCascadeTable::PionEta, + NPCascadeTable::BachPt, + NPCascadeTable::BachEta, + NPCascadeTable::CascDCAxy, + NPCascadeTable::CascDCAz, + NPCascadeTable::ProtonDCAxy, + NPCascadeTable::ProtonDCAz, + NPCascadeTable::PionDCAxy, + NPCascadeTable::PionDCAz, + NPCascadeTable::BachDCAxy, + NPCascadeTable::BachDCAz, + NPCascadeTable::CascCosPA, + NPCascadeTable::V0CosPA, + NPCascadeTable::MassXi, + NPCascadeTable::MassOmega, + NPCascadeTable::MassV0, + NPCascadeTable::CascRadius, + NPCascadeTable::V0Radius, + NPCascadeTable::CascLenght, + NPCascadeTable::V0Lenght, + NPCascadeTable::CascNClusITS, + NPCascadeTable::ProtonNClusITS, + NPCascadeTable::PionNClusITS, + NPCascadeTable::BachNClusITS, + NPCascadeTable::ProtonNClusTPC, + NPCascadeTable::PionNClusTPC, + NPCascadeTable::BachNClusTPC, + NPCascadeTable::ProtonTPCNSigma, + NPCascadeTable::PionTPCNSigma, + NPCascadeTable::BachKaonTPCNSigma, + NPCascadeTable::BachPionTPCNSigma, + NPCascadeTable::ProtonHasTOF, + NPCascadeTable::PionHasTOF, + NPCascadeTable::BachHasTOF, + NPCascadeTable::ProtonTOFNSigma, + NPCascadeTable::PionTOFNSigma, + NPCascadeTable::BachKaonTOFNSigma, + NPCascadeTable::BachPionTOFNSigma, + NPCascadeTable::Sel8, + NPCascadeTable::MultFT0C, + NPCascadeTable::MultFT0A, + NPCascadeTable::MultFT0M, + NPCascadeTable::CentFT0C, + NPCascadeTable::CentFT0A, + NPCascadeTable::CentFT0M, + NPCascadeTable::MultNTracksGlobal, + NPCascadeTable::ToiMask) + +DECLARE_SOA_TABLE(NPCascTableNT, "AOD", "NPCASCTABLENT", + NPCascadeTable::MatchingChi2, + NPCascadeTable::DeltaPtITSCascade, + NPCascadeTable::DeltaPtCascade, NPCascadeTable::ITSClusSize, NPCascadeTable::HasReassociatedCluster, aod::collision::NumContrib, + NPCascadeTable::CascPVContribs, aod::collision::CollisionTimeRes, NPCascadeTable::PvX, NPCascadeTable::PvY, @@ -147,28 +230,35 @@ DECLARE_SOA_TABLE(NPCascTable, "AOD", "NPCASCTABLE", NPCascadeTable::CascNClusITS, NPCascadeTable::ProtonNClusITS, NPCascadeTable::PionNClusITS, - NPCascadeTable::BachKaonNClusITS, - NPCascadeTable::BachPionNClusITS, + NPCascadeTable::BachNClusITS, NPCascadeTable::ProtonNClusTPC, NPCascadeTable::PionNClusTPC, - NPCascadeTable::BachKaonNClusTPC, - NPCascadeTable::BachPionNClusTPC, + NPCascadeTable::BachNClusTPC, NPCascadeTable::ProtonTPCNSigma, NPCascadeTable::PionTPCNSigma, NPCascadeTable::BachKaonTPCNSigma, NPCascadeTable::BachPionTPCNSigma, NPCascadeTable::ProtonHasTOF, NPCascadeTable::PionHasTOF, - NPCascadeTable::BachKaonHasTOF, - NPCascadeTable::BachPionHasTOF, + NPCascadeTable::BachHasTOF, NPCascadeTable::ProtonTOFNSigma, NPCascadeTable::PionTOFNSigma, NPCascadeTable::BachKaonTOFNSigma, - NPCascadeTable::BachPionTOFNSigma) + NPCascadeTable::BachPionTOFNSigma, + NPCascadeTable::Sel8, + NPCascadeTable::MultFT0C, + NPCascadeTable::MultFT0A, + NPCascadeTable::MultFT0M, + NPCascadeTable::CentFT0C, + NPCascadeTable::CentFT0A, + NPCascadeTable::CentFT0M, + NPCascadeTable::MultNTracksGlobal, + NPCascadeTable::ToiMask) DECLARE_SOA_TABLE(NPCascTableMC, "AOD", "NPCASCTABLEMC", NPCascadeTable::MatchingChi2, NPCascadeTable::DeltaPtITSCascade, + NPCascadeTable::DeltaPtCascade, NPCascadeTable::ITSClusSize, NPCascadeTable::HasReassociatedCluster, NPCascadeTable::IsGoodMatch, @@ -178,6 +268,7 @@ DECLARE_SOA_TABLE(NPCascTableMC, "AOD", "NPCASCTABLEMC", NPCascadeTable::IsFromBeauty, NPCascadeTable::IsFromCharm, aod::collision::NumContrib, + NPCascadeTable::CascPVContribs, aod::collision::CollisionTimeRes, NPCascadeTable::PvX, NPCascadeTable::PvY, @@ -211,32 +302,128 @@ DECLARE_SOA_TABLE(NPCascTableMC, "AOD", "NPCASCTABLEMC", NPCascadeTable::CascNClusITS, NPCascadeTable::ProtonNClusITS, NPCascadeTable::PionNClusITS, - NPCascadeTable::BachKaonNClusITS, - NPCascadeTable::BachPionNClusITS, + NPCascadeTable::BachNClusITS, NPCascadeTable::ProtonNClusTPC, NPCascadeTable::PionNClusTPC, - NPCascadeTable::BachKaonNClusTPC, - NPCascadeTable::BachPionNClusTPC, + NPCascadeTable::BachNClusTPC, NPCascadeTable::ProtonTPCNSigma, NPCascadeTable::PionTPCNSigma, NPCascadeTable::BachKaonTPCNSigma, NPCascadeTable::BachPionTPCNSigma, NPCascadeTable::ProtonHasTOF, NPCascadeTable::PionHasTOF, - NPCascadeTable::BachKaonHasTOF, - NPCascadeTable::BachPionHasTOF, + NPCascadeTable::BachHasTOF, NPCascadeTable::ProtonTOFNSigma, NPCascadeTable::PionTOFNSigma, NPCascadeTable::BachKaonTOFNSigma, NPCascadeTable::BachPionTOFNSigma, + NPCascadeTable::Sel8, + NPCascadeTable::MultFT0C, + NPCascadeTable::MultFT0A, + NPCascadeTable::MultFT0M, + NPCascadeTable::CentFT0C, + NPCascadeTable::CentFT0A, + NPCascadeTable::CentFT0M, NPCascadeTable::gPt, NPCascadeTable::gEta, NPCascadeTable::gPhi, + NPCascadeTable::gVx, + NPCascadeTable::gVy, + NPCascadeTable::gVz, NPCascadeTable::PDGcode, NPCascadeTable::DCAxMC, NPCascadeTable::DCAyMC, NPCascadeTable::DCAzMC, - NPCascadeTable::MCcollisionMatch) + NPCascadeTable::MCcollisionMatch, + NPCascadeTable::HasFakeReassociation, + NPCascadeTable::MotherDecayDaughters, + NPCascadeTable::MultNTracksGlobal, + NPCascadeTable::ToiMask) + +DECLARE_SOA_TABLE(NPCascTableMCNT, "AOD", "NPCASCTABLEMCNT", + NPCascadeTable::MatchingChi2, + NPCascadeTable::DeltaPtITSCascade, + NPCascadeTable::DeltaPtCascade, + NPCascadeTable::ITSClusSize, + NPCascadeTable::HasReassociatedCluster, + NPCascadeTable::IsGoodMatch, + NPCascadeTable::IsGoodCascade, + NPCascadeTable::PdgCodeMom, + NPCascadeTable::PdgCodeITStrack, + NPCascadeTable::IsFromBeauty, + NPCascadeTable::IsFromCharm, + aod::collision::NumContrib, + NPCascadeTable::CascPVContribs, + aod::collision::CollisionTimeRes, + NPCascadeTable::PvX, + NPCascadeTable::PvY, + NPCascadeTable::PvZ, + NPCascadeTable::CascPt, + NPCascadeTable::CascEta, + NPCascadeTable::CascPhi, + NPCascadeTable::ProtonPt, + NPCascadeTable::ProtonEta, + NPCascadeTable::PionPt, + NPCascadeTable::PionEta, + NPCascadeTable::BachPt, + NPCascadeTable::BachEta, + NPCascadeTable::CascDCAxy, + NPCascadeTable::CascDCAz, + NPCascadeTable::ProtonDCAxy, + NPCascadeTable::ProtonDCAz, + NPCascadeTable::PionDCAxy, + NPCascadeTable::PionDCAz, + NPCascadeTable::BachDCAxy, + NPCascadeTable::BachDCAz, + NPCascadeTable::CascCosPA, + NPCascadeTable::V0CosPA, + NPCascadeTable::MassXi, + NPCascadeTable::MassOmega, + NPCascadeTable::MassV0, + NPCascadeTable::CascRadius, + NPCascadeTable::V0Radius, + NPCascadeTable::CascLenght, + NPCascadeTable::V0Lenght, + NPCascadeTable::CascNClusITS, + NPCascadeTable::ProtonNClusITS, + NPCascadeTable::PionNClusITS, + NPCascadeTable::BachNClusITS, + NPCascadeTable::ProtonNClusTPC, + NPCascadeTable::PionNClusTPC, + NPCascadeTable::BachNClusTPC, + NPCascadeTable::ProtonTPCNSigma, + NPCascadeTable::PionTPCNSigma, + NPCascadeTable::BachKaonTPCNSigma, + NPCascadeTable::BachPionTPCNSigma, + NPCascadeTable::ProtonHasTOF, + NPCascadeTable::PionHasTOF, + NPCascadeTable::BachHasTOF, + NPCascadeTable::ProtonTOFNSigma, + NPCascadeTable::PionTOFNSigma, + NPCascadeTable::BachKaonTOFNSigma, + NPCascadeTable::BachPionTOFNSigma, + NPCascadeTable::Sel8, + NPCascadeTable::MultFT0C, + NPCascadeTable::MultFT0A, + NPCascadeTable::MultFT0M, + NPCascadeTable::CentFT0C, + NPCascadeTable::CentFT0A, + NPCascadeTable::CentFT0M, + NPCascadeTable::gPt, + NPCascadeTable::gEta, + NPCascadeTable::gPhi, + NPCascadeTable::gVx, + NPCascadeTable::gVy, + NPCascadeTable::gVz, + NPCascadeTable::PDGcode, + NPCascadeTable::DCAxMC, + NPCascadeTable::DCAyMC, + NPCascadeTable::DCAzMC, + NPCascadeTable::MCcollisionMatch, + NPCascadeTable::HasFakeReassociation, + NPCascadeTable::MotherDecayDaughters, + NPCascadeTable::MultNTracksGlobal, + NPCascadeTable::ToiMask) DECLARE_SOA_TABLE(NPCascTableGen, "AOD", "NPCASCTABLEGen", NPCascadeTable::gPt, @@ -248,7 +435,8 @@ DECLARE_SOA_TABLE(NPCascTableGen, "AOD", "NPCASCTABLEGen", NPCascadeTable::DCAyMC, NPCascadeTable::DCAzMC, NPCascadeTable::IsFromBeauty, - NPCascadeTable::IsFromCharm) + NPCascadeTable::IsFromCharm, + NPCascadeTable::MotherDecayDaughters) } // namespace o2::aod diff --git a/PWGLF/DataModel/LFNucleiTables.h b/PWGLF/DataModel/LFNucleiTables.h index 2fcd940d070..1cd9ba76c93 100644 --- a/PWGLF/DataModel/LFNucleiTables.h +++ b/PWGLF/DataModel/LFNucleiTables.h @@ -62,6 +62,8 @@ DECLARE_SOA_DYNAMIC_COLUMN(Rapidity, rapidity, const auto energy = sqrt(p * p + mass * mass); return 0.5f * log((energy + pz) / (energy - pz)); }); +// ITS +DECLARE_SOA_COLUMN(ITSClusterSizes, itsClusterSizes, uint32_t); //! ITS cluster sizes per layer // TPC DECLARE_SOA_COLUMN(TPCNSigmaPi, tpcNSigmaPi, float); DECLARE_SOA_COLUMN(TPCNSigmaKa, tpcNSigmaKa, float); @@ -181,6 +183,7 @@ DECLARE_SOA_TABLE(LfCandNucleus, "AOD", "LFNUCL", full::IsPVContributor, full::P, full::Rapidity, + full::ITSClusterSizes, track::TPCNClsFound, track::TPCNClsCrossedRows, track::TPCCrossedRowsOverFindableCls, @@ -211,6 +214,7 @@ DECLARE_SOA_TABLE_VERSIONED(LfCandNucleusDummy, "AOD", "LFNUCL", 1, track::ITSClusterMap, full::IsPVContributor, full::P, + full::ITSClusterSizes, dummy::TPCNSigmaPi, dummy::TPCNSigmaKa, dummy::TPCNSigmaPr, dummy::TPCNSigmaTr, dummy::TPCNSigmaAl, dummy::TOFNSigmaPi, dummy::TOFNSigmaKa, dummy::TOFNSigmaPr, diff --git a/PWGLF/DataModel/LFPIDTOFGenericTables.h b/PWGLF/DataModel/LFPIDTOFGenericTables.h new file mode 100644 index 00000000000..3a52a8a8ca5 --- /dev/null +++ b/PWGLF/DataModel/LFPIDTOFGenericTables.h @@ -0,0 +1,59 @@ +// 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. +// +/// \file LFPIDTOFGenericTables.h +/// \brief Table for event time without remving track bias +/// \author Yuanzhe Wang + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" + +#ifndef PWGLF_DATAMODEL_LFPIDTOFGENERICTABLES_H_ +#define PWGLF_DATAMODEL_LFPIDTOFGENERICTABLES_H_ +#include "Common/Core/PID/PIDTOF.h" + +#include "CommonDataFormat/InteractionRecord.h" + +namespace o2::aod +{ +namespace evtime +{ + +DECLARE_SOA_COLUMN(EvTime, evTime, float); //! Event time. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C +DECLARE_SOA_COLUMN(EvTimeErr, evTimeErr, float); //! Error of event time. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C +DECLARE_SOA_COLUMN(EvTimeTOF, evTimeTOF, float); //! Event time computed with the TOF detector +DECLARE_SOA_COLUMN(EvTimeTOFErr, evTimeTOFErr, float); //! Error of the event time computed with the TOF detector +DECLARE_SOA_COLUMN(EvTimeFT0, evTimeFT0, float); //! Event time computed with the FT0 detector +DECLARE_SOA_COLUMN(EvTimeFT0Err, evTimeFT0Err, float); //! Error of the event time computed with the FT0 detector +} // namespace evtime + +DECLARE_SOA_TABLE(EvTimeTOFFT0, "AOD", "EvTimeTOFFT0", //! Table of the event time. One entry per collision. + evtime::EvTime, + evtime::EvTimeErr, + evtime::EvTimeTOF, + evtime::EvTimeTOFErr, + evtime::EvTimeFT0, + evtime::EvTimeFT0Err); + +namespace tracktime +{ + +DECLARE_SOA_COLUMN(EvTimeForTrack, evTimeForTrack, float); //! Event time. Removed the bias for the specific track +DECLARE_SOA_COLUMN(EvTimeErrForTrack, evTimeErrForTrack, float); //! Error of event time. Removed the bias for the specific track +} // namespace tracktime + +DECLARE_SOA_TABLE(EvTimeTOFFT0ForTrack, "AOD", "EvTimeForTrack", //! Table of the event time. One entry per track. + tracktime::EvTimeForTrack, + tracktime::EvTimeErrForTrack); + +} // namespace o2::aod + +#endif // PWGLF_DATAMODEL_LFPIDTOFGENERICTABLES_H_ diff --git a/PWGLF/DataModel/LFResonanceTables.h b/PWGLF/DataModel/LFResonanceTables.h index c2a13c35270..67e1fb013c5 100644 --- a/PWGLF/DataModel/LFResonanceTables.h +++ b/PWGLF/DataModel/LFResonanceTables.h @@ -16,12 +16,14 @@ /// /// \author Bong-Hwi Lim /// \author Nasir Mehdi Malik +/// \author Minjae Kim /// #ifndef PWGLF_DATAMODEL_LFRESONANCETABLES_H_ #define PWGLF_DATAMODEL_LFRESONANCETABLES_H_ #include +#include #include "Common/DataModel/PIDResponse.h" #include "Common/Core/RecoDecay.h" @@ -74,23 +76,19 @@ DECLARE_SOA_COLUMN(ImpactParameter, impactParameter, float); //! ImpactParamete } // namespace resocollision DECLARE_SOA_TABLE(ResoCollisions, "AOD", "RESOCOLLISION", o2::soa::Index<>, - resocollision::CollisionId, o2::aod::mult::MultNTracksPV, collision::PosX, collision::PosY, collision::PosZ, resocollision::Cent, - resocollision::Spherocity, - resocollision::EvtPl, - resocollision::EvtPlResAB, - resocollision::EvtPlResAC, - resocollision::EvtPlResBC, - resocollision::BMagField, - timestamp::Timestamp, - evsel::NumTracksInTimeRange); + resocollision::BMagField); using ResoCollision = ResoCollisions::iterator; -DECLARE_SOA_TABLE(ResoMCCollisions, "AOD", "RESOMCCOL", +DECLARE_SOA_TABLE(ResoCollisionColls, "AOD", "RESOCOLLISIONCOL", + resocollision::CollisionId); +using ResoCollisionColl = ResoCollisionColls::iterator; + +DECLARE_SOA_TABLE(ResoMCCollisions, "AOD", "RESOMCCOLLISION", o2::soa::Index<>, resocollision::IsVtxIn10, resocollision::IsINELgt0, @@ -100,15 +98,13 @@ DECLARE_SOA_TABLE(ResoMCCollisions, "AOD", "RESOMCCOL", resocollision::ImpactParameter); using ResoMCCollision = ResoMCCollisions::iterator; -DECLARE_SOA_TABLE(ResoSpheroCollisions, "AOD", "RESOSPHEROCOLL", +DECLARE_SOA_TABLE(ResoSpheroCollisions, "AOD", "RESOSPHEROCOLLISION", o2::soa::Index<>, - resocollision::CollisionId, resocollision::Spherocity); using ResoSpheroCollision = ResoSpheroCollisions::iterator; -DECLARE_SOA_TABLE(ResoEvtPlCollisions, "AOD", "RESOEVTPLCOLL", +DECLARE_SOA_TABLE(ResoEvtPlCollisions, "AOD", "RESOEVTPLCOLLISION", o2::soa::Index<>, - resocollision::CollisionId, resocollision::EvtPl, resocollision::EvtPlResAB, resocollision::EvtPlResAC, @@ -118,7 +114,6 @@ using ResoEvtPlCollision = ResoEvtPlCollisions::iterator; // For DF mixing study DECLARE_SOA_TABLE(ResoCollisionDFs, "AOD", "RESOCOLLISIONDF", o2::soa::Index<>, - resocollision::CollisionId, o2::aod::mult::MultNTracksPV, collision::PosX, collision::PosY, @@ -138,64 +133,93 @@ using ResoCollisionDF = ResoCollisionDFs::iterator; // inspired from PWGCF/DataModel/FemtoDerived.h namespace resodaughter { +struct ResoTrackFlags { + public: + typedef uint8_t flagtype; + static constexpr flagtype kPassedITSRefit = 1 << 0; + static constexpr flagtype kPassedTPCRefit = 1 << 1; + static constexpr flagtype kIsGlobalTrackWoDCA = 1 << 2; + static constexpr flagtype kIsGlobalTrack = 1 << 3; + static constexpr flagtype kIsPrimaryTrack = 1 << 4; + static constexpr flagtype kIsPVContributor = 1 << 5; + static constexpr flagtype kHasTOF = 1 << 6; + static constexpr flagtype kSign = 1 << 7; + /// @brief check if the flag is set + static bool checkFlag(const flagtype flags, const flagtype mask) + { + return (flags & mask) == mask; + } +}; +#define requireTrackFlag(mask) ((o2::aod::resodaughter::trackFlags & o2::aod::resodaughter::mask) == o2::aod::resodaughter::mask) + +#define requirePassedITSRefit() requireTrackFlag(ResoTrackFlags::kPassedITSRefit) +#define requirePassedTPCRefit() requireTrackFlag(ResoTrackFlags::kPassedTPCRefit) +#define requireGlobalTrack() requireTrackFlag(ResoTrackFlags::kIsGlobalTrack) +#define requireGlobalTrackWoDCA() requireTrackFlag(ResoTrackFlags::kIsGlobalTrackWoDCA) +#define requirePrimaryTrack() requireTrackFlag(ResoTrackFlags::kIsPrimaryTrack) +#define requirePVContributor() requireTrackFlag(ResoTrackFlags::kIsPVContributor) +#define requireHasTOF() requireTrackFlag(ResoTrackFlags::kHasTOF) +#define requireSign() requireTrackFlag(ResoTrackFlags::kSign) + +#define DECLARE_DYN_TRKSEL_COLUMN(name, getter, mask) \ + DECLARE_SOA_DYNAMIC_COLUMN(name, getter, [](ResoTrackFlags::flagtype flags) -> bool { return ResoTrackFlags::checkFlag(flags, mask); }); DECLARE_SOA_INDEX_COLUMN(ResoCollision, resoCollision); -DECLARE_SOA_INDEX_COLUMN_FULL(Track, track, int, Tracks, "_Trk"); //! -DECLARE_SOA_INDEX_COLUMN_FULL(V0, v0, int, V0s, "_V0"); //! -DECLARE_SOA_INDEX_COLUMN_FULL(Cascade, cascade, int, Cascades, "_Cas"); //! -DECLARE_SOA_COLUMN(Pt, pt, float); //! p_T (GeV/c) -DECLARE_SOA_COLUMN(Px, px, float); //! p_x (GeV/c) -DECLARE_SOA_COLUMN(Py, py, float); //! p_y (GeV/c) -DECLARE_SOA_COLUMN(Pz, pz, float); //! p_z (GeV/c) -DECLARE_SOA_COLUMN(Eta, eta, float); //! Eta -DECLARE_SOA_COLUMN(Phi, phi, float); //! Phi -DECLARE_SOA_COLUMN(PartType, partType, uint8_t); //! Type of the particle, according to resodaughter::ParticleType -DECLARE_SOA_COLUMN(TempFitVar, tempFitVar, float); //! Observable for the template fitting (Track: DCA_xy, V0: CPA) -DECLARE_SOA_COLUMN(Indices, indices, int[2]); //! Field for the track indices to remove auto-correlations -DECLARE_SOA_COLUMN(CascadeIndices, cascadeIndices, int[3]); //! Field for the track indices to remove auto-correlations (ordered: positive, negative, bachelor) -DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of the track charge -DECLARE_SOA_COLUMN(TPCNClsCrossedRows, tpcNClsCrossedRows, uint8_t); //! Number of TPC crossed rows -DECLARE_SOA_COLUMN(TPCNClsFound, tpcNClsFound, uint8_t); //! Number of TPC clusters found -DECLARE_SOA_COLUMN(ITSNCls, itsNCls, uint8_t); //! Number of ITS clusters found -DECLARE_SOA_COLUMN(IsGlobalTrackWoDCA, isGlobalTrackWoDCA, bool); //! Is global track without DCA -DECLARE_SOA_COLUMN(IsGlobalTrack, isGlobalTrack, bool); //! Is global track -DECLARE_SOA_COLUMN(IsPrimaryTrack, isPrimaryTrack, bool); //! Is primary track -DECLARE_SOA_COLUMN(IsPVContributor, isPVContributor, bool); //! Is primary vertex contributor -DECLARE_SOA_COLUMN(HasITS, hasITS, bool); //! Has ITS -DECLARE_SOA_COLUMN(HasTPC, hasTPC, bool); //! Has TPC -DECLARE_SOA_COLUMN(HasTOF, hasTOF, bool); //! Has TOF -DECLARE_SOA_COLUMN(TPCCrossedRowsOverFindableCls, tpcCrossedRowsOverFindableCls, float); -DECLARE_SOA_COLUMN(DaughDCA, daughDCA, float); //! DCA between daughters -DECLARE_SOA_COLUMN(CascDaughDCA, cascDaughDCA, float); //! DCA between daughters from cascade -DECLARE_SOA_COLUMN(V0CosPA, v0CosPA, float); //! V0 Cosine of Pointing Angle -DECLARE_SOA_COLUMN(CascCosPA, cascCosPA, float); //! Cascade Cosine of Pointing Angle -DECLARE_SOA_COLUMN(MLambda, mLambda, float); //! The invariant mass of V0 candidate, assuming lambda -DECLARE_SOA_COLUMN(MAntiLambda, mAntiLambda, float); //! The invariant mass of V0 candidate, assuming antilambda -DECLARE_SOA_COLUMN(MK0Short, mK0Short, float); //! The invariant mass of V0 candidate, assuming k0s -DECLARE_SOA_COLUMN(MXi, mXi, float); //! The invariant mass of Xi candidate -DECLARE_SOA_COLUMN(TransRadius, transRadius, float); //! Transverse radius of the decay vertex -DECLARE_SOA_COLUMN(CascTransRadius, cascTransRadius, float); //! Transverse radius of the decay vertex from cascade -DECLARE_SOA_COLUMN(DecayVtxX, decayVtxX, float); //! X position of the decay vertex -DECLARE_SOA_COLUMN(DecayVtxY, decayVtxY, float); //! Y position of the decay vertex -DECLARE_SOA_COLUMN(DecayVtxZ, decayVtxZ, float); //! Z position of the decay vertex -DECLARE_SOA_COLUMN(DaughterTPCNSigmaPosPi, daughterTPCNSigmaPosPi, float); //! TPC PID of the positive daughter as Pion -DECLARE_SOA_COLUMN(DaughterTPCNSigmaPosKa, daughterTPCNSigmaPosKa, float); //! TPC PID of the positive daughter as Kaon -DECLARE_SOA_COLUMN(DaughterTPCNSigmaPosPr, daughterTPCNSigmaPosPr, float); //! TPC PID of the positive daughter as Proton -DECLARE_SOA_COLUMN(DaughterTPCNSigmaNegPi, daughterTPCNSigmaNegPi, float); //! TPC PID of the negative daughter as Pion -DECLARE_SOA_COLUMN(DaughterTPCNSigmaNegKa, daughterTPCNSigmaNegKa, float); //! TPC PID of the negative daughter as Kaon -DECLARE_SOA_COLUMN(DaughterTPCNSigmaNegPr, daughterTPCNSigmaNegPr, float); //! TPC PID of the negative daughter as Proton -DECLARE_SOA_COLUMN(DaughterTPCNSigmaBachPi, daughterTPCNSigmaBachPi, float); //! TPC PID of the bachelor daughter as Pion -DECLARE_SOA_COLUMN(DaughterTPCNSigmaBachKa, daughterTPCNSigmaBachKa, float); //! TPC PID of the bachelor daughter as Kaon -DECLARE_SOA_COLUMN(DaughterTPCNSigmaBachPr, daughterTPCNSigmaBachPr, float); //! TPC PID of the bachelor daughter as Proton -DECLARE_SOA_COLUMN(DaughterTOFNSigmaPosPi, daughterTOFNSigmaPosPi, float); //! TOF PID of the positive daughter as Pion -DECLARE_SOA_COLUMN(DaughterTOFNSigmaPosKa, daughterTOFNSigmaPosKa, float); //! TOF PID of the positive daughter as Kaon -DECLARE_SOA_COLUMN(DaughterTOFNSigmaPosPr, daughterTOFNSigmaPosPr, float); //! TOF PID of the positive daughter as Proton -DECLARE_SOA_COLUMN(DaughterTOFNSigmaNegPi, daughterTOFNSigmaNegPi, float); //! TOF PID of the negative daughter as Pion -DECLARE_SOA_COLUMN(DaughterTOFNSigmaNegKa, daughterTOFNSigmaNegKa, float); //! TOF PID of the negative daughter as Kaon -DECLARE_SOA_COLUMN(DaughterTOFNSigmaNegPr, daughterTOFNSigmaNegPr, float); //! TOF PID of the negative daughter as Proton -DECLARE_SOA_COLUMN(DaughterTOFNSigmaBachPi, daughterTOFNSigmaBachPi, float); //! TOF PID of the bachelor daughter as Pion -DECLARE_SOA_COLUMN(DaughterTOFNSigmaBachKa, daughterTOFNSigmaBachKa, float); //! TOF PID of the bachelor daughter as Kaon -DECLARE_SOA_COLUMN(DaughterTOFNSigmaBachPr, daughterTOFNSigmaBachPr, float); //! TOF PID of the bachelor daughter as Proton +DECLARE_SOA_INDEX_COLUMN(ResoCollisionDF, resoCollisionDF); +DECLARE_SOA_INDEX_COLUMN_FULL(Track, track, int, Tracks, "_Trk"); //! +DECLARE_SOA_INDEX_COLUMN_FULL(V0, v0, int, V0s, "_V0"); //! +DECLARE_SOA_INDEX_COLUMN_FULL(Cascade, cascade, int, Cascades, "_Cas"); //! +DECLARE_SOA_COLUMN(Pt, pt, float); //! p_t (GeV/c) +DECLARE_SOA_COLUMN(Px, px, float); //! p_x (GeV/c) +DECLARE_SOA_COLUMN(Py, py, float); //! p_y (GeV/c) +DECLARE_SOA_COLUMN(Pz, pz, float); //! p_z (GeV/c) +DECLARE_SOA_COLUMN(PartType, partType, uint8_t); //! Type of the particle, according to resodaughter::ParticleType +DECLARE_SOA_COLUMN(TempFitVar, tempFitVar, float); //! Observable for the template fitting (Track: DCA_xy, V0: CPA) +DECLARE_SOA_COLUMN(Indices, indices, int[2]); //! Field for the track indices to remove auto-correlations +DECLARE_SOA_COLUMN(CascadeIndices, cascadeIndices, int[3]); //! Field for the track indices to remove auto-correlations (ordered: positive, negative, bachelor) +DECLARE_SOA_COLUMN(TpcNClsCrossedRows, tpcNClsCrossedRows, uint8_t); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(TpcNClsFound, tpcNClsFound, uint8_t); //! Number of TPC clusters found +DECLARE_SOA_COLUMN(DcaXY10000, dcaXY10000, int16_t); //! DCA_xy x10,000 in int16_t, resolution 10 um +DECLARE_SOA_COLUMN(DcaZ10000, dcaZ10000, int16_t); //! DCA_z x10,000 in int16_t, resolution 10 um +DECLARE_SOA_COLUMN(TrackFlags, trackFlags, uint8_t); //! Track flags +DECLARE_SOA_COLUMN(TpcNSigmaPi10, tpcNSigmaPi10, int8_t); //! TPC PID x10 of the track as Pion +DECLARE_SOA_COLUMN(TpcNSigmaKa10, tpcNSigmaKa10, int8_t); //! TPC PID x10 of the track as Kaon +DECLARE_SOA_COLUMN(TpcNSigmaPr10, tpcNSigmaPr10, int8_t); //! TPC PID x10 of the track as Proton +DECLARE_SOA_COLUMN(TofNSigmaPi10, tofNSigmaPi10, int8_t); //! TOF PID x10 of the track as Pion +DECLARE_SOA_COLUMN(TofNSigmaKa10, tofNSigmaKa10, int8_t); //! TOF PID x10 of the track as Kaon +DECLARE_SOA_COLUMN(TofNSigmaPr10, tofNSigmaPr10, int8_t); //! TOF PID x10 of the track as Proton +DECLARE_SOA_COLUMN(DaughDCA, daughDCA, float); //! DCA between daughters +DECLARE_SOA_COLUMN(CascDaughDCA, cascDaughDCA, float); //! DCA between daughters from cascade +DECLARE_SOA_COLUMN(V0CosPA, v0CosPA, float); //! V0 Cosine of Pointing Angle +DECLARE_SOA_COLUMN(CascCosPA, cascCosPA, float); //! Cascade Cosine of Pointing Angle +DECLARE_SOA_COLUMN(MLambda, mLambda, float); //! The invariant mass of V0 candidate, assuming lambda +DECLARE_SOA_COLUMN(MAntiLambda, mAntiLambda, float); //! The invariant mass of V0 candidate, assuming antilambda +DECLARE_SOA_COLUMN(MK0Short, mK0Short, float); //! The invariant mass of V0 candidate, assuming k0s +DECLARE_SOA_COLUMN(MXi, mXi, float); //! The invariant mass of Xi candidate +DECLARE_SOA_COLUMN(TransRadius, transRadius, float); //! Transverse radius of the decay vertex +DECLARE_SOA_COLUMN(CascTransRadius, cascTransRadius, float); //! Transverse radius of the decay vertex from cascade +DECLARE_SOA_COLUMN(DecayVtxX, decayVtxX, float); //! X position of the decay vertex +DECLARE_SOA_COLUMN(DecayVtxY, decayVtxY, float); //! Y position of the decay vertex +DECLARE_SOA_COLUMN(DecayVtxZ, decayVtxZ, float); //! Z position of the decay vertex +DECLARE_SOA_COLUMN(TpcSignal10, tpcSignal10, int8_t); //! TPC signal of the track x10 +DECLARE_SOA_COLUMN(DaughterTPCNSigmaPosPi10, daughterTPCNSigmaPosPi10, int8_t); //! TPC PID x10 of the positive daughter as Pion +DECLARE_SOA_COLUMN(DaughterTPCNSigmaPosKa10, daughterTPCNSigmaPosKa10, int8_t); //! TPC PID x10 of the positive daughter as Kaon +DECLARE_SOA_COLUMN(DaughterTPCNSigmaPosPr10, daughterTPCNSigmaPosPr10, int8_t); //! TPC PID x10 of the positive daughter as Proton +DECLARE_SOA_COLUMN(DaughterTPCNSigmaNegPi10, daughterTPCNSigmaNegPi10, int8_t); //! TPC PID x10 of the negative daughter as Pion +DECLARE_SOA_COLUMN(DaughterTPCNSigmaNegKa10, daughterTPCNSigmaNegKa10, int8_t); //! TPC PID x10 of the negative daughter as Kaon +DECLARE_SOA_COLUMN(DaughterTPCNSigmaNegPr10, daughterTPCNSigmaNegPr10, int8_t); //! TPC PID x10 of the negative daughter as Proton +DECLARE_SOA_COLUMN(DaughterTPCNSigmaBachPi10, daughterTPCNSigmaBachPi10, int8_t); //! TPC PID x10 of the bachelor daughter as Pion +DECLARE_SOA_COLUMN(DaughterTPCNSigmaBachKa10, daughterTPCNSigmaBachKa10, int8_t); //! TPC PID x10 of the bachelor daughter as Kaon +DECLARE_SOA_COLUMN(DaughterTPCNSigmaBachPr10, daughterTPCNSigmaBachPr10, int8_t); //! TPC PID x10 of the bachelor daughter as Proton +DECLARE_SOA_COLUMN(DaughterTOFNSigmaPosPi10, daughterTOFNSigmaPosPi10, int8_t); //! TOF PID x10 of the positive daughter as Pion +DECLARE_SOA_COLUMN(DaughterTOFNSigmaPosKa10, daughterTOFNSigmaPosKa10, int8_t); //! TOF PID x10 of the positive daughter as Kaon +DECLARE_SOA_COLUMN(DaughterTOFNSigmaPosPr10, daughterTOFNSigmaPosPr10, int8_t); //! TOF PID x10 of the positive daughter as Proton +DECLARE_SOA_COLUMN(DaughterTOFNSigmaNegPi10, daughterTOFNSigmaNegPi10, int8_t); //! TOF PID x10 of the negative daughter as Pion +DECLARE_SOA_COLUMN(DaughterTOFNSigmaNegKa10, daughterTOFNSigmaNegKa10, int8_t); //! TOF PID x10 of the negative daughter as Kaon +DECLARE_SOA_COLUMN(DaughterTOFNSigmaNegPr10, daughterTOFNSigmaNegPr10, int8_t); //! TOF PID x10 of the negative daughter as Proton +DECLARE_SOA_COLUMN(DaughterTOFNSigmaBachPi10, daughterTOFNSigmaBachPi10, int8_t); //! TOF PID x10 of the bachelor daughter as Pion +DECLARE_SOA_COLUMN(DaughterTOFNSigmaBachKa10, daughterTOFNSigmaBachKa10, int8_t); //! TOF PID x10 of the bachelor daughter as Kaon +DECLARE_SOA_COLUMN(DaughterTOFNSigmaBachPr10, daughterTOFNSigmaBachPr10, int8_t); //! TOF PID x10 of the bachelor daughter as Proton // For MC DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! Index of the corresponding MC particle DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); @@ -209,113 +233,384 @@ DECLARE_SOA_COLUMN(DaughterID2, daughterID2, int); //! Id of the second Daught DECLARE_SOA_COLUMN(SiblingIds, siblingIds, int[2]); //! Index of the particles with the same mother DECLARE_SOA_COLUMN(BachTrkID, bachTrkID, int); //! Id of the bach track from cascade DECLARE_SOA_COLUMN(V0ID, v0ID, int); //! Id of the V0 from cascade +// Dynamic columns +// DCA_xy x10,000 +DECLARE_SOA_DYNAMIC_COLUMN(DcaXY, dcaXY, + [](int16_t dcaXY10000) { return (float)dcaXY10000 / 10000.f; }); +// DCA_z x10,000 +DECLARE_SOA_DYNAMIC_COLUMN(DcaZ, dcaZ, + [](int16_t dcaZ10000) { return (float)dcaZ10000 / 10000.f; }); +// TPC PID return value/10 +DECLARE_SOA_DYNAMIC_COLUMN(TpcNSigmaPi, tpcNSigmaPi, + [](int8_t tpcNSigmaPi10) { return (float)tpcNSigmaPi10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcNSigmaKa, tpcNSigmaKa, + [](int8_t tpcNSigmaKa10) { return (float)tpcNSigmaKa10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcNSigmaPr, tpcNSigmaPr, + [](int8_t tpcNSigmaPr10) { return (float)tpcNSigmaPr10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(TofNSigmaPi, tofNSigmaPi, + [](int8_t tofNSigmaPi10) { return (float)tofNSigmaPi10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(TofNSigmaKa, tofNSigmaKa, + [](int8_t tofNSigmaKa10) { return (float)tofNSigmaKa10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(TofNSigmaPr, tofNSigmaPr, + [](int8_t tofNSigmaPr10) { return (float)tofNSigmaPr10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTPCNSigmaPosPi, daughterTPCNSigmaPosPi, + [](int8_t daughterTPCNSigmaPosPi10) { return (float)daughterTPCNSigmaPosPi10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTPCNSigmaPosKa, daughterTPCNSigmaPosKa, + [](int8_t daughterTPCNSigmaPosKa10) { return (float)daughterTPCNSigmaPosKa10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTPCNSigmaPosPr, daughterTPCNSigmaPosPr, + [](int8_t daughterTPCNSigmaPosPr10) { return (float)daughterTPCNSigmaPosPr10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTPCNSigmaNegPi, daughterTPCNSigmaNegPi, + [](int8_t daughterTPCNSigmaNegPi10) { return (float)daughterTPCNSigmaNegPi10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTPCNSigmaNegKa, daughterTPCNSigmaNegKa, + [](int8_t daughterTPCNSigmaNegKa10) { return (float)daughterTPCNSigmaNegKa10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTPCNSigmaNegPr, daughterTPCNSigmaNegPr, + [](int8_t daughterTPCNSigmaNegPr10) { return (float)daughterTPCNSigmaNegPr10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTPCNSigmaBachPi, daughterTPCNSigmaBachPi, + [](int8_t daughterTPCNSigmaBachPi10) { return (float)daughterTPCNSigmaBachPi10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTPCNSigmaBachKa, daughterTPCNSigmaBachKa, + [](int8_t daughterTPCNSigmaBachKa10) { return (float)daughterTPCNSigmaBachKa10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTPCNSigmaBachPr, daughterTPCNSigmaBachPr, + [](int8_t daughterTPCNSigmaBachPr10) { return (float)daughterTPCNSigmaBachPr10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTOFNSigmaPosPi, daughterTOFNSigmaPosPi, + [](int8_t daughterTOFNSigmaPosPi10) { return (float)daughterTOFNSigmaPosPi10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTOFNSigmaPosKa, daughterTOFNSigmaPosKa, + [](int8_t daughterTOFNSigmaPosKa10) { return (float)daughterTOFNSigmaPosKa10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTOFNSigmaPosPr, daughterTOFNSigmaPosPr, + [](int8_t daughterTOFNSigmaPosPr10) { return (float)daughterTOFNSigmaPosPr10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTOFNSigmaNegPi, daughterTOFNSigmaNegPi, + [](int8_t daughterTOFNSigmaNegPi10) { return (float)daughterTOFNSigmaNegPi10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTOFNSigmaNegKa, daughterTOFNSigmaNegKa, + [](int8_t daughterTOFNSigmaNegKa10) { return (float)daughterTOFNSigmaNegKa10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTOFNSigmaNegPr, daughterTOFNSigmaNegPr, + [](int8_t daughterTOFNSigmaNegPr10) { return (float)daughterTOFNSigmaNegPr10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTOFNSigmaBachPi, daughterTOFNSigmaBachPi, + [](int8_t daughterTOFNSigmaBachPi10) { return (float)daughterTOFNSigmaBachPi10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTOFNSigmaBachKa, daughterTOFNSigmaBachKa, + [](int8_t daughterTOFNSigmaBachKa10) { return (float)daughterTOFNSigmaBachKa10 / 10.f; }); +DECLARE_SOA_DYNAMIC_COLUMN(DaughterTOFNSigmaBachPr, daughterTOFNSigmaBachPr, + [](int8_t daughterTOFNSigmaBachPr10) { return (float)daughterTOFNSigmaBachPr10 / 10.f; }); +// TPC signal x10 +DECLARE_SOA_DYNAMIC_COLUMN(TpcSignal, tpcSignal, + [](int8_t tpcSignal10) { return (float)tpcSignal10 / 10.f; }); +// pT, Eta, Phi +// DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float px, float py) -> float { return RecoDecay::sqrtSumOfSquares(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](float px, float py, float pz) -> float { return RecoDecay::eta(std::array{px, py, pz}); }); +DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, [](float px, float py) -> float { return RecoDecay::phi(px, py); }); +// Track flags +DECLARE_SOA_DYNAMIC_COLUMN(PassedITSRefit, passedITSRefit, + [](ResoTrackFlags::flagtype trackFlags) -> bool { + return ResoTrackFlags::checkFlag(trackFlags, ResoTrackFlags::kPassedITSRefit); + }); +DECLARE_SOA_DYNAMIC_COLUMN(PassedTPCRefit, passedTPCRefit, + [](ResoTrackFlags::flagtype trackFlags) -> bool { + return ResoTrackFlags::checkFlag(trackFlags, ResoTrackFlags::kPassedTPCRefit); + }); +DECLARE_SOA_DYNAMIC_COLUMN(IsGlobalTrackWoDCA, isGlobalTrackWoDCA, + [](ResoTrackFlags::flagtype trackFlags) -> bool { + return ResoTrackFlags::checkFlag(trackFlags, ResoTrackFlags::kIsGlobalTrackWoDCA); + }); +DECLARE_SOA_DYNAMIC_COLUMN(IsGlobalTrack, isGlobalTrack, + [](ResoTrackFlags::flagtype trackFlags) -> bool { + return ResoTrackFlags::checkFlag(trackFlags, ResoTrackFlags::kIsGlobalTrack); + }); +DECLARE_SOA_DYNAMIC_COLUMN(IsPrimaryTrack, isPrimaryTrack, + [](ResoTrackFlags::flagtype trackFlags) -> bool { + return ResoTrackFlags::checkFlag(trackFlags, ResoTrackFlags::kIsPrimaryTrack); + }); +DECLARE_SOA_DYNAMIC_COLUMN(IsPVContributor, isPVContributor, + [](ResoTrackFlags::flagtype trackFlags) -> bool { + return ResoTrackFlags::checkFlag(trackFlags, ResoTrackFlags::kIsPVContributor); + }); +DECLARE_SOA_DYNAMIC_COLUMN(HasTOF, hasTOF, + [](ResoTrackFlags::flagtype trackFlags) -> bool { + return ResoTrackFlags::checkFlag(trackFlags, ResoTrackFlags::kHasTOF); + }); +DECLARE_SOA_DYNAMIC_COLUMN(Sign, sign, + [](ResoTrackFlags::flagtype trackFlags) -> int8_t { + return (trackFlags & ResoTrackFlags::kSign) ? 1 : -1; + }); + } // namespace resodaughter -DECLARE_SOA_TABLE(ResoTracks, "AOD", "RESOTRACKS", + +namespace resomicrodaughter +{ +// micro track for primary pion + +/// @brief Save TPC & TOF nSigma info with 8-bit variable +struct PidNSigma { + uint8_t flag; + + /// @brief Constructor: Convert TPC & TOF values and save + PidNSigma(float TPCnSigma, float TOFnSigma, bool hasTOF) + { + uint8_t TPCencoded = encodeNSigma(TPCnSigma); + uint8_t TOFencoded = hasTOF ? encodeNSigma(TOFnSigma) : 0x0F; // If TOF is not available, set all 4 bits to 1 + flag = (TPCencoded << 4) | TOFencoded; // Upper 4 bits = TPC, Lower 4 bits = TOF + } + + /// @brief Encode 0.2 sigma interval to 0~10 range + static uint8_t encodeNSigma(float nSigma) + { + float encoded = std::abs((nSigma - 1.5) / 0.2); // Convert to 0~10 range + encoded = std::min(std::max(encoded, 0.f), 10.f); // Clamp to 0~10 range + return (uint8_t)round(encoded); + } + + /// @brief Decode 0~10 value to original 1.5~3.5 sigma range + static float decodeNSigma(uint8_t encoded) + { + encoded = std::min(encoded, (uint8_t)10); // Safety check, should not be needed if encode is used properly + return (encoded * 0.2) + 1.5; + } + + /// @brief Check if TOF info is available + bool hasTOF() const + { + return (flag & 0x0F) != 0x0F; // Check if lower 4 bits are not all 1 + } + + /// @brief Restore TPC nSigma value + static float getTPCnSigma(uint8_t encoded) + { + return decodeNSigma((encoded >> 4) & 0x0F); // Extract upper 4 bits + } + + /// @brief Restore TOF nSigma value (if not available, return NAN) + static float getTOFnSigma(uint8_t encoded) + { + uint8_t TOFencoded = encoded & 0x0F; // Extract lower 4 bits + return (TOFencoded == 0x0F) ? NAN : decodeNSigma(TOFencoded); + } + + /// @brief Operator to convert to uint8_t (automatic conversion support) + operator uint8_t() const + { + return flag; + } +}; + +DECLARE_SOA_COLUMN(PidNSigmaPiFlag, pidNSigmaPiFlag, uint8_t); //! Pid flag for the track as Pion +DECLARE_SOA_COLUMN(PidNSigmaKaFlag, pidNSigmaKaFlag, uint8_t); //! Pid flag for the track as Kaon +DECLARE_SOA_COLUMN(PidNSigmaPrFlag, pidNSigmaPrFlag, uint8_t); //! Pid flag for the track as Proton +DECLARE_SOA_COLUMN(TrackSelectionFlags, trackSelectionFlags, int8_t); //! Track selection flags +DECLARE_SOA_DYNAMIC_COLUMN(HasTOF, hasTOF, + [](uint8_t pidNSigmaFlags) -> bool { + return (pidNSigmaFlags & 0x0F) != 0x0F; + }); + +/// @brief DCAxy & DCAz selection flag +struct ResoMicroTrackSelFlag { + uint8_t flag; // Flag for DCAxy & DCAz selection (8-bit variable) + + /// @brief Default constructor + ResoMicroTrackSelFlag() + { + flag = 0x00; + } + + /// @brief Constructor: Convert DCAxy/DCAz and save (default 1~15 values) + ResoMicroTrackSelFlag(float DCAxy, float DCAz) + { + uint8_t DCAxyEncoded = encodeDCA(DCAxy); + uint8_t DCAzEncoded = encodeDCA(DCAz); + flag = (DCAxyEncoded << 4) | DCAzEncoded; // Upper 4 bits = DCAxy, Lower 4 bits = DCAz + } + + /// @brief Convert DCA to 1~15 steps (0 value is not used) + static uint8_t encodeDCA(float DCA) + { + for (uint8_t i = 1; i < 15; i++) { + if (DCA < i * 0.1f) + return i; + } + return 15; + } + + /// @brief Operator to convert to `uint8_t` (for SOA storage) + operator uint8_t() const + { + return flag; + } + + /// @brief Get DCAxy value + uint8_t getDCAxyFlag() const + { + return (flag >> 4) & 0x0F; // Extract upper 4 bits + } + + /// @brief Get DCAz value + uint8_t getDCAzFlag() const + { + return flag & 0x0F; // Extract lower 4 bits + } + + /// @brief Apply DCAxy tight cut (0 value) + void setDCAxy0() + { + flag &= 0x0F; // Set DCAxy to 0 (delete upper 4 bits) + } + + /// @brief Apply DCAz tight cut (0 value) + void setDCAz0() + { + flag &= 0xF0; // Set DCAz to 0 (delete lower 4 bits) + } + /// @brief Decode DCAxy + static float decodeDCAxy(uint8_t flag_saved) + { + uint8_t DCAxyFlag = (flag_saved >> 4) & 0x0F; // Extract upper 4 bits + return (DCAxyFlag == 0) ? 0.0f : DCAxyFlag * 0.1f; // Tight cut(0) is 0.0, otherwise flag * 0.1 cm + } + + /// @brief Decode DCAz + static float decodeDCAz(uint8_t flag_saved) + { + uint8_t DCAzFlag = flag_saved & 0x0F; // Extract lower 4 bits + return (DCAzFlag == 0) ? 0.0f : DCAzFlag * 0.1f; // Tight cut(0) is 0.0, otherwise flag * 0.1 cm + } +}; + +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float px, float py) -> float { return RecoDecay::sqrtSumOfSquares(px, py); }); +} // namespace resomicrodaughter + +DECLARE_SOA_TABLE(ResoTracks, "AOD", "RESOTRACK", o2::soa::Index<>, resodaughter::ResoCollisionId, - resodaughter::TrackId, resodaughter::Pt, resodaughter::Px, resodaughter::Py, resodaughter::Pz, - resodaughter::Eta, - resodaughter::Phi, - resodaughter::Sign, - resodaughter::TPCNClsCrossedRows, - resodaughter::TPCNClsFound, - resodaughter::ITSNCls, - o2::aod::track::DcaXY, - o2::aod::track::DcaZ, - o2::aod::track::X, - o2::aod::track::Alpha, - resodaughter::HasITS, - resodaughter::HasTPC, - resodaughter::HasTOF, - o2::aod::pidtpc::TPCNSigmaPi, - o2::aod::pidtpc::TPCNSigmaKa, - o2::aod::pidtpc::TPCNSigmaPr, - o2::aod::pidtpc::TPCNSigmaEl, - o2::aod::pidtof::TOFNSigmaPi, - o2::aod::pidtof::TOFNSigmaKa, - o2::aod::pidtof::TOFNSigmaPr, - o2::aod::pidtof::TOFNSigmaEl, - o2::aod::track::TPCSignal, - o2::aod::track::PassedITSRefit, - o2::aod::track::PassedTPCRefit, - resodaughter::IsGlobalTrackWoDCA, - resodaughter::IsGlobalTrack, - resodaughter::IsPrimaryTrack, - resodaughter::IsPVContributor, - resodaughter::TPCCrossedRowsOverFindableCls, - o2::aod::track::ITSChi2NCl, - o2::aod::track::TPCChi2NCl); + resodaughter::TpcNClsCrossedRows, + resodaughter::TpcNClsFound, + resodaughter::DcaXY10000, + resodaughter::DcaZ10000, + resodaughter::TpcNSigmaPi10, + resodaughter::TpcNSigmaKa10, + resodaughter::TpcNSigmaPr10, + resodaughter::TofNSigmaPi10, + resodaughter::TofNSigmaKa10, + resodaughter::TofNSigmaPr10, + resodaughter::TpcSignal10, + resodaughter::TrackFlags, + // Dynamic columns + resodaughter::TpcNSigmaPi, + resodaughter::TpcNSigmaKa, + resodaughter::TpcNSigmaPr, + resodaughter::TofNSigmaPi, + resodaughter::TofNSigmaKa, + resodaughter::TofNSigmaPr, + resodaughter::TpcSignal, + // resodaughter::Pt, + resodaughter::DcaXY, + resodaughter::DcaZ, + resodaughter::Eta, + resodaughter::Phi, + resodaughter::PassedITSRefit, + resodaughter::PassedTPCRefit, + resodaughter::IsGlobalTrackWoDCA, + resodaughter::IsGlobalTrack, + resodaughter::IsPrimaryTrack, + resodaughter::IsPVContributor, + resodaughter::HasTOF, + resodaughter::Sign); using ResoTrack = ResoTracks::iterator; -// For DF mixing study -DECLARE_SOA_TABLE(ResoTrackDFs, "AOD", "RESOTRACKDFs", +DECLARE_SOA_TABLE(ResoTrackTracks, "AOD", "RESOTRACKTRACK", + resodaughter::TrackId); +using ResoTrackTrack = ResoTrackTracks::iterator; + +DECLARE_SOA_TABLE(ResoMicroTracks, "AOD", "RESOMICROTRACK", o2::soa::Index<>, resodaughter::ResoCollisionId, - resodaughter::TrackId, + resodaughter::Px, + resodaughter::Py, + resodaughter::Pz, + resomicrodaughter::PidNSigmaPiFlag, + resomicrodaughter::PidNSigmaKaFlag, + resomicrodaughter::PidNSigmaPrFlag, + resomicrodaughter::TrackSelectionFlags, + resodaughter::TrackFlags, + // Dynamic columns + resomicrodaughter::Pt, + resodaughter::Eta, + resodaughter::Phi, + resodaughter::PassedITSRefit, + resodaughter::PassedTPCRefit, + resodaughter::IsGlobalTrackWoDCA, + resodaughter::IsGlobalTrack, + resodaughter::IsPrimaryTrack, + resodaughter::IsPVContributor, + resomicrodaughter::HasTOF, + resodaughter::Sign); +using ResoMicroTrack = ResoMicroTracks::iterator; + +DECLARE_SOA_TABLE(ResoMicroTrackTracks, "AOD", "RESOMICROTRACKTRACK", + resodaughter::TrackId); +using ResoMicroTrackTrack = ResoMicroTrackTracks::iterator; + +// For DF mixing study +DECLARE_SOA_TABLE(ResoTrackDFs, "AOD", "RESOTRACKDF", + o2::soa::Index<>, + resodaughter::ResoCollisionDFId, resodaughter::Pt, resodaughter::Px, resodaughter::Py, resodaughter::Pz, - resodaughter::Eta, - resodaughter::Phi, - resodaughter::Sign, - resodaughter::TPCNClsCrossedRows, - resodaughter::TPCNClsFound, - resodaughter::ITSNCls, - o2::aod::track::DcaXY, - o2::aod::track::DcaZ, - o2::aod::track::X, - o2::aod::track::Alpha, - resodaughter::HasITS, - resodaughter::HasTPC, - resodaughter::HasTOF, - o2::aod::pidtpc::TPCNSigmaPi, - o2::aod::pidtpc::TPCNSigmaKa, - o2::aod::pidtpc::TPCNSigmaPr, - o2::aod::pidtpc::TPCNSigmaEl, - o2::aod::pidtof::TOFNSigmaPi, - o2::aod::pidtof::TOFNSigmaKa, - o2::aod::pidtof::TOFNSigmaPr, - o2::aod::pidtof::TOFNSigmaEl, - o2::aod::track::TPCSignal, - o2::aod::track::PassedITSRefit, - o2::aod::track::PassedTPCRefit, - resodaughter::IsGlobalTrackWoDCA, - resodaughter::IsGlobalTrack, - resodaughter::IsPrimaryTrack, - resodaughter::IsPVContributor, - resodaughter::TPCCrossedRowsOverFindableCls, - o2::aod::track::ITSChi2NCl, - o2::aod::track::TPCChi2NCl); + resodaughter::TpcNClsCrossedRows, + resodaughter::TpcNClsFound, + resodaughter::DcaXY10000, + resodaughter::DcaZ10000, + resodaughter::TpcNSigmaPi10, + resodaughter::TpcNSigmaKa10, + resodaughter::TpcNSigmaPr10, + resodaughter::TofNSigmaPi10, + resodaughter::TofNSigmaKa10, + resodaughter::TofNSigmaPr10, + resodaughter::TpcSignal10, + resodaughter::TrackFlags, + // Dynamic columns + resodaughter::TpcNSigmaPi, + resodaughter::TpcNSigmaKa, + resodaughter::TpcNSigmaPr, + resodaughter::TofNSigmaPi, + resodaughter::TofNSigmaKa, + resodaughter::TofNSigmaPr, + resodaughter::TpcSignal, + // resodaughter::Pt, + resodaughter::DcaXY, + resodaughter::DcaZ, + resodaughter::Eta, + resodaughter::Phi, + resodaughter::PassedITSRefit, + resodaughter::PassedTPCRefit, + resodaughter::IsGlobalTrackWoDCA, + resodaughter::IsGlobalTrack, + resodaughter::IsPrimaryTrack, + resodaughter::IsPVContributor, + resodaughter::HasTOF, + resodaughter::Sign); using ResoTrackDF = ResoTrackDFs::iterator; -DECLARE_SOA_TABLE(ResoV0s, "AOD", "RESOV0S", +DECLARE_SOA_TABLE(ResoV0s, "AOD", "RESOV0", o2::soa::Index<>, resodaughter::ResoCollisionId, - resodaughter::V0Id, resodaughter::Pt, resodaughter::Px, resodaughter::Py, resodaughter::Pz, - resodaughter::Eta, - resodaughter::Phi, resodaughter::Indices, - resodaughter::DaughterTPCNSigmaPosPi, - resodaughter::DaughterTPCNSigmaPosKa, - resodaughter::DaughterTPCNSigmaPosPr, - resodaughter::DaughterTPCNSigmaNegPi, - resodaughter::DaughterTPCNSigmaNegKa, - resodaughter::DaughterTPCNSigmaNegPr, - resodaughter::DaughterTOFNSigmaPosPi, - resodaughter::DaughterTOFNSigmaPosKa, - resodaughter::DaughterTOFNSigmaPosPr, - resodaughter::DaughterTOFNSigmaNegPi, - resodaughter::DaughterTOFNSigmaNegKa, - resodaughter::DaughterTOFNSigmaNegPr, + resodaughter::DaughterTPCNSigmaPosPi10, + resodaughter::DaughterTPCNSigmaPosKa10, + resodaughter::DaughterTPCNSigmaPosPr10, + resodaughter::DaughterTPCNSigmaNegPi10, + resodaughter::DaughterTPCNSigmaNegKa10, + resodaughter::DaughterTPCNSigmaNegPr10, + resodaughter::DaughterTOFNSigmaPosPi10, + resodaughter::DaughterTOFNSigmaPosKa10, + resodaughter::DaughterTOFNSigmaPosPr10, + resodaughter::DaughterTOFNSigmaNegPi10, + resodaughter::DaughterTOFNSigmaNegKa10, + resodaughter::DaughterTOFNSigmaNegPr10, resodaughter::V0CosPA, resodaughter::DaughDCA, v0data::DCAPosToPV, @@ -327,38 +622,54 @@ DECLARE_SOA_TABLE(ResoV0s, "AOD", "RESOV0S", resodaughter::TransRadius, resodaughter::DecayVtxX, resodaughter::DecayVtxY, - resodaughter::DecayVtxZ); + resodaughter::DecayVtxZ, + // resodaughter::Pt, + resodaughter::Eta, + resodaughter::Phi, + resodaughter::DaughterTPCNSigmaPosPi, + resodaughter::DaughterTPCNSigmaPosKa, + resodaughter::DaughterTPCNSigmaPosPr, + resodaughter::DaughterTPCNSigmaNegPi, + resodaughter::DaughterTPCNSigmaNegKa, + resodaughter::DaughterTPCNSigmaNegPr, + resodaughter::DaughterTOFNSigmaPosPi, + resodaughter::DaughterTOFNSigmaPosKa, + resodaughter::DaughterTOFNSigmaPosPr, + resodaughter::DaughterTOFNSigmaNegPi, + resodaughter::DaughterTOFNSigmaNegKa, + resodaughter::DaughterTOFNSigmaNegPr); using ResoV0 = ResoV0s::iterator; -DECLARE_SOA_TABLE(ResoCascades, "AOD", "RESOCASCADES", +DECLARE_SOA_TABLE(ResoV0V0s, "AOD", "RESOV0V0", + resodaughter::V0Id); +using ResoV0V0 = ResoV0V0s::iterator; + +DECLARE_SOA_TABLE(ResoCascades, "AOD", "RESOCASCADE", o2::soa::Index<>, resodaughter::ResoCollisionId, - resodaughter::CascadeId, resodaughter::Pt, resodaughter::Px, resodaughter::Py, resodaughter::Pz, - resodaughter::Eta, - resodaughter::Phi, resodaughter::CascadeIndices, - resodaughter::DaughterTPCNSigmaPosPi, - resodaughter::DaughterTPCNSigmaPosKa, - resodaughter::DaughterTPCNSigmaPosPr, - resodaughter::DaughterTPCNSigmaNegPi, - resodaughter::DaughterTPCNSigmaNegKa, - resodaughter::DaughterTPCNSigmaNegPr, - resodaughter::DaughterTPCNSigmaBachPi, - resodaughter::DaughterTPCNSigmaBachKa, - resodaughter::DaughterTPCNSigmaBachPr, - resodaughter::DaughterTOFNSigmaPosPi, - resodaughter::DaughterTOFNSigmaPosKa, - resodaughter::DaughterTOFNSigmaPosPr, - resodaughter::DaughterTOFNSigmaNegPi, - resodaughter::DaughterTOFNSigmaNegKa, - resodaughter::DaughterTOFNSigmaNegPr, - resodaughter::DaughterTOFNSigmaBachPi, - resodaughter::DaughterTOFNSigmaBachKa, - resodaughter::DaughterTOFNSigmaBachPr, + resodaughter::DaughterTPCNSigmaPosPi10, + resodaughter::DaughterTPCNSigmaPosKa10, + resodaughter::DaughterTPCNSigmaPosPr10, + resodaughter::DaughterTPCNSigmaNegPi10, + resodaughter::DaughterTPCNSigmaNegKa10, + resodaughter::DaughterTPCNSigmaNegPr10, + resodaughter::DaughterTPCNSigmaBachPi10, + resodaughter::DaughterTPCNSigmaBachKa10, + resodaughter::DaughterTPCNSigmaBachPr10, + resodaughter::DaughterTOFNSigmaPosPi10, + resodaughter::DaughterTOFNSigmaPosKa10, + resodaughter::DaughterTOFNSigmaPosPr10, + resodaughter::DaughterTOFNSigmaNegPi10, + resodaughter::DaughterTOFNSigmaNegKa10, + resodaughter::DaughterTOFNSigmaNegPr10, + resodaughter::DaughterTOFNSigmaBachPi10, + resodaughter::DaughterTOFNSigmaBachKa10, + resodaughter::DaughterTOFNSigmaBachPr10, resodaughter::V0CosPA, resodaughter::CascCosPA, resodaughter::DaughDCA, @@ -376,10 +687,102 @@ DECLARE_SOA_TABLE(ResoCascades, "AOD", "RESOCASCADES", resodaughter::CascTransRadius, resodaughter::DecayVtxX, resodaughter::DecayVtxY, - resodaughter::DecayVtxZ); + resodaughter::DecayVtxZ, + // resodaughter::Pt, + resodaughter::Eta, + resodaughter::Phi, + resodaughter::DaughterTPCNSigmaPosPi, + resodaughter::DaughterTPCNSigmaPosKa, + resodaughter::DaughterTPCNSigmaPosPr, + resodaughter::DaughterTPCNSigmaNegPi, + resodaughter::DaughterTPCNSigmaNegKa, + resodaughter::DaughterTPCNSigmaNegPr, + resodaughter::DaughterTPCNSigmaBachPi, + resodaughter::DaughterTPCNSigmaBachKa, + resodaughter::DaughterTPCNSigmaBachPr, + resodaughter::DaughterTOFNSigmaPosPi, + resodaughter::DaughterTOFNSigmaPosKa, + resodaughter::DaughterTOFNSigmaPosPr, + resodaughter::DaughterTOFNSigmaNegPi, + resodaughter::DaughterTOFNSigmaNegKa, + resodaughter::DaughterTOFNSigmaNegPr, + resodaughter::DaughterTOFNSigmaBachPi, + resodaughter::DaughterTOFNSigmaBachKa, + resodaughter::DaughterTOFNSigmaBachPr); using ResoCascade = ResoCascades::iterator; -DECLARE_SOA_TABLE(ResoMCTracks, "AOD", "RESOMCTRACKS", +DECLARE_SOA_TABLE(ResoCascadeCascades, "AOD", "RESOCASCADECASCADE", + resodaughter::CascadeId); +using ResoCascadeCascade = ResoCascadeCascades::iterator; + +DECLARE_SOA_TABLE(ResoCascadeDFs, "AOD", "RESOCASCADEDF", + o2::soa::Index<>, + resodaughter::ResoCollisionDFId, + resodaughter::Pt, + resodaughter::Px, + resodaughter::Py, + resodaughter::Pz, + resodaughter::CascadeIndices, + resodaughter::DaughterTPCNSigmaPosPi10, + resodaughter::DaughterTPCNSigmaPosKa10, + resodaughter::DaughterTPCNSigmaPosPr10, + resodaughter::DaughterTPCNSigmaNegPi10, + resodaughter::DaughterTPCNSigmaNegKa10, + resodaughter::DaughterTPCNSigmaNegPr10, + resodaughter::DaughterTPCNSigmaBachPi10, + resodaughter::DaughterTPCNSigmaBachKa10, + resodaughter::DaughterTPCNSigmaBachPr10, + resodaughter::DaughterTOFNSigmaPosPi10, + resodaughter::DaughterTOFNSigmaPosKa10, + resodaughter::DaughterTOFNSigmaPosPr10, + resodaughter::DaughterTOFNSigmaNegPi10, + resodaughter::DaughterTOFNSigmaNegKa10, + resodaughter::DaughterTOFNSigmaNegPr10, + resodaughter::DaughterTOFNSigmaBachPi10, + resodaughter::DaughterTOFNSigmaBachKa10, + resodaughter::DaughterTOFNSigmaBachPr10, + resodaughter::V0CosPA, + resodaughter::CascCosPA, + resodaughter::DaughDCA, + resodaughter::CascDaughDCA, + cascdata::DCAPosToPV, + cascdata::DCANegToPV, + cascdata::DCABachToPV, + v0data::DCAV0ToPV, + cascdata::DCAXYCascToPV, + cascdata::DCAZCascToPV, + cascdata::Sign, + resodaughter::MLambda, + resodaughter::MXi, + resodaughter::TransRadius, + resodaughter::CascTransRadius, + resodaughter::DecayVtxX, + resodaughter::DecayVtxY, + resodaughter::DecayVtxZ, + // resodaughter::Pt, + resodaughter::Eta, + resodaughter::Phi, + resodaughter::DaughterTPCNSigmaPosPi, + resodaughter::DaughterTPCNSigmaPosKa, + resodaughter::DaughterTPCNSigmaPosPr, + resodaughter::DaughterTPCNSigmaNegPi, + resodaughter::DaughterTPCNSigmaNegKa, + resodaughter::DaughterTPCNSigmaNegPr, + resodaughter::DaughterTPCNSigmaBachPi, + resodaughter::DaughterTPCNSigmaBachKa, + resodaughter::DaughterTPCNSigmaBachPr, + resodaughter::DaughterTOFNSigmaPosPi, + resodaughter::DaughterTOFNSigmaPosKa, + resodaughter::DaughterTOFNSigmaPosPr, + resodaughter::DaughterTOFNSigmaNegPi, + resodaughter::DaughterTOFNSigmaNegKa, + resodaughter::DaughterTOFNSigmaNegPr, + resodaughter::DaughterTOFNSigmaBachPi, + resodaughter::DaughterTOFNSigmaBachKa, + resodaughter::DaughterTOFNSigmaBachPr); +using ResoCascadeDF = ResoCascadeDFs::iterator; + +DECLARE_SOA_TABLE(ResoMCTracks, "AOD", "RESOMCTRACK", mcparticle::PdgCode, resodaughter::MotherId, resodaughter::MotherPDG, @@ -388,7 +791,7 @@ DECLARE_SOA_TABLE(ResoMCTracks, "AOD", "RESOMCTRACKS", resodaughter::ProducedByGenerator); using ResoMCTrack = ResoMCTracks::iterator; -DECLARE_SOA_TABLE(ResoMCV0s, "AOD", "RESOMCV0S", +DECLARE_SOA_TABLE(ResoMCV0s, "AOD", "RESOMCV0", mcparticle::PdgCode, resodaughter::MotherId, resodaughter::MotherPDG, @@ -400,7 +803,7 @@ DECLARE_SOA_TABLE(ResoMCV0s, "AOD", "RESOMCV0S", resodaughter::ProducedByGenerator); using ResoMCV0 = ResoMCV0s::iterator; -DECLARE_SOA_TABLE(ResoMCCascades, "AOD", "RESOMCCASCADES", +DECLARE_SOA_TABLE(ResoMCCascades, "AOD", "RESOMCCASCADE", mcparticle::PdgCode, resodaughter::MotherId, resodaughter::MotherPDG, @@ -412,7 +815,7 @@ DECLARE_SOA_TABLE(ResoMCCascades, "AOD", "RESOMCCASCADES", resodaughter::ProducedByGenerator); using ResoMCCascade = ResoMCCascades::iterator; -DECLARE_SOA_TABLE(ResoMCParents, "AOD", "RESOMCPARENTS", +DECLARE_SOA_TABLE(ResoMCParents, "AOD", "RESOMCPARENT", o2::soa::Index<>, resodaughter::ResoCollisionId, resodaughter::McParticleId, @@ -425,19 +828,20 @@ DECLARE_SOA_TABLE(ResoMCParents, "AOD", "RESOMCPARENTS", resodaughter::Px, resodaughter::Py, resodaughter::Pz, - resodaughter::Eta, - resodaughter::Phi, mcparticle::Y, mcparticle::E, - mcparticle::StatusCode); + mcparticle::StatusCode, + // resodaughter::Pt, + resodaughter::Eta, + resodaughter::Phi); using ResoMCParent = ResoMCParents::iterator; using Reso2TracksExt = soa::Join; // without Extra using Reso2TracksMC = soa::Join; -using Reso2TracksPID = soa::Join; +using Reso2TracksPID = soa::Join; using Reso2TracksPIDExt = soa::Join; // Without Extra -using ResoCollisionCandidates = soa::Join; +using ResoCollisionCandidates = soa::Join; using ResoRun2CollisionCandidates = soa::Join; using ResoCollisionCandidatesMC = soa::Join; using ResoRun2CollisionCandidatesMC = soa::Join; diff --git a/PWGLF/DataModel/LFSigmaTables.h b/PWGLF/DataModel/LFSigmaTables.h index 7da34376055..bd808cef106 100644 --- a/PWGLF/DataModel/LFSigmaTables.h +++ b/PWGLF/DataModel/LFSigmaTables.h @@ -34,6 +34,8 @@ DECLARE_SOA_COLUMN(SigmaMass, sigmaMass, float); DECLARE_SOA_COLUMN(SigmaRapidity, sigmaRapidity, float); DECLARE_SOA_COLUMN(SigmaOPAngle, sigmaOPAngle, float); DECLARE_SOA_COLUMN(SigmaCentrality, sigmaCentrality, float); +DECLARE_SOA_COLUMN(SigmaRunNumber, sigmaRunNumber, int); +DECLARE_SOA_COLUMN(SigmaTimestamp, sigmaTimestamp, uint64_t); } // namespace sigma0Core @@ -42,7 +44,9 @@ DECLARE_SOA_TABLE(Sigma0Cores, "AOD", "SIGMA0CORES", sigma0Core::SigmaMass, sigma0Core::SigmaRapidity, sigma0Core::SigmaOPAngle, - sigma0Core::SigmaCentrality); + sigma0Core::SigmaCentrality, + sigma0Core::SigmaRunNumber, + sigma0Core::SigmaTimestamp); // For Photon extra info namespace sigmaPhotonExtra @@ -60,8 +64,10 @@ DECLARE_SOA_COLUMN(PhotonZconv, photonZconv, float); DECLARE_SOA_COLUMN(PhotonEta, photonEta, float); DECLARE_SOA_COLUMN(PhotonY, photonY, float); DECLARE_SOA_COLUMN(PhotonPhi, photonPhi, float); -DECLARE_SOA_COLUMN(PhotonPosTPCNSigma, photonPosTPCNSigma, float); -DECLARE_SOA_COLUMN(PhotonNegTPCNSigma, photonNegTPCNSigma, float); +DECLARE_SOA_COLUMN(PhotonPosTPCNSigmaEl, photonPosTPCNSigmaEl, float); +DECLARE_SOA_COLUMN(PhotonNegTPCNSigmaEl, photonNegTPCNSigmaEl, float); +DECLARE_SOA_COLUMN(PhotonPosTPCNSigmaPi, photonPosTPCNSigmaPi, float); +DECLARE_SOA_COLUMN(PhotonNegTPCNSigmaPi, photonNegTPCNSigmaPi, float); DECLARE_SOA_COLUMN(PhotonPosTPCCrossedRows, photonPosTPCCrossedRows, uint8_t); DECLARE_SOA_COLUMN(PhotonNegTPCCrossedRows, photonNegTPCCrossedRows, uint8_t); DECLARE_SOA_COLUMN(PhotonPosPt, photonPosPt, float); @@ -73,8 +79,10 @@ DECLARE_SOA_COLUMN(PhotonNegY, photonNegY, float); DECLARE_SOA_COLUMN(PhotonPsiPair, photonPsiPair, float); DECLARE_SOA_COLUMN(PhotonPosITSCls, photonPosITSCls, int); DECLARE_SOA_COLUMN(PhotonNegITSCls, photonNegITSCls, int); -DECLARE_SOA_COLUMN(PhotonPosITSClSize, photonPosITSClSize, uint32_t); -DECLARE_SOA_COLUMN(PhotonNegITSClSize, photonNegITSClSize, uint32_t); +DECLARE_SOA_COLUMN(PhotonPosITSChi2PerNcl, photonPosITSChi2PerNcl, float); +DECLARE_SOA_COLUMN(PhotonNegITSChi2PerNcl, photonNegITSChi2PerNcl, float); +DECLARE_SOA_COLUMN(PhotonPosTrackCode, photonPosTrackCode, uint8_t); +DECLARE_SOA_COLUMN(PhotonNegTrackCode, photonNegTrackCode, uint8_t); DECLARE_SOA_COLUMN(PhotonV0Type, photonV0Type, uint8_t); DECLARE_SOA_COLUMN(GammaBDTScore, gammaBDTScore, float); @@ -94,8 +102,10 @@ DECLARE_SOA_TABLE(SigmaPhotonExtras, "AOD", "SIGMA0PHOTON", sigmaPhotonExtra::PhotonEta, sigmaPhotonExtra::PhotonY, sigmaPhotonExtra::PhotonPhi, - sigmaPhotonExtra::PhotonPosTPCNSigma, - sigmaPhotonExtra::PhotonNegTPCNSigma, + sigmaPhotonExtra::PhotonPosTPCNSigmaEl, + sigmaPhotonExtra::PhotonNegTPCNSigmaEl, + sigmaPhotonExtra::PhotonPosTPCNSigmaPi, + sigmaPhotonExtra::PhotonNegTPCNSigmaPi, sigmaPhotonExtra::PhotonPosTPCCrossedRows, sigmaPhotonExtra::PhotonNegTPCCrossedRows, sigmaPhotonExtra::PhotonPosPt, @@ -107,8 +117,10 @@ DECLARE_SOA_TABLE(SigmaPhotonExtras, "AOD", "SIGMA0PHOTON", sigmaPhotonExtra::PhotonPsiPair, sigmaPhotonExtra::PhotonPosITSCls, sigmaPhotonExtra::PhotonNegITSCls, - sigmaPhotonExtra::PhotonPosITSClSize, - sigmaPhotonExtra::PhotonNegITSClSize, + sigmaPhotonExtra::PhotonPosITSChi2PerNcl, + sigmaPhotonExtra::PhotonNegITSChi2PerNcl, + sigmaPhotonExtra::PhotonPosTrackCode, + sigmaPhotonExtra::PhotonNegTrackCode, sigmaPhotonExtra::PhotonV0Type, sigmaPhotonExtra::GammaBDTScore); @@ -120,6 +132,7 @@ DECLARE_SOA_COLUMN(LambdaMass, lambdaMass, float); DECLARE_SOA_COLUMN(AntiLambdaMass, antilambdaMass, float); DECLARE_SOA_COLUMN(LambdaQt, lambdaQt, float); DECLARE_SOA_COLUMN(LambdaAlpha, lambdaAlpha, float); +DECLARE_SOA_COLUMN(LambdaLifeTime, lambdaLifeTime, float); DECLARE_SOA_COLUMN(LambdaRadius, lambdaRadius, float); DECLARE_SOA_COLUMN(LambdaCosPA, lambdaCosPA, float); DECLARE_SOA_COLUMN(LambdaDCADau, lambdaDCADau, float); @@ -148,8 +161,10 @@ DECLARE_SOA_COLUMN(LambdaNegPrY, lambdaNegPrY, float); DECLARE_SOA_COLUMN(LambdaNegPiY, lambdaNegPiY, float); DECLARE_SOA_COLUMN(LambdaPosITSCls, lambdaPosITSCls, int); DECLARE_SOA_COLUMN(LambdaNegITSCls, lambdaNegITSCls, int); -DECLARE_SOA_COLUMN(LambdaPosITSClSize, lambdaPosITSClSize, uint32_t); -DECLARE_SOA_COLUMN(LambdaNegITSClSize, lambdaNegITSClSize, uint32_t); +DECLARE_SOA_COLUMN(LambdaPosITSChi2PerNcl, lambdaPosChi2PerNcl, float); +DECLARE_SOA_COLUMN(LambdaNegITSChi2PerNcl, lambdaNegChi2PerNcl, float); +DECLARE_SOA_COLUMN(LambdaPosTrackCode, lambdaPosTrackCode, uint8_t); +DECLARE_SOA_COLUMN(LambdaNegTrackCode, lambdaNegTrackCode, uint8_t); DECLARE_SOA_COLUMN(LambdaV0Type, lambdaV0Type, uint8_t); DECLARE_SOA_COLUMN(LambdaBDTScore, lambdaBDTScore, float); DECLARE_SOA_COLUMN(AntiLambdaBDTScore, antilambdaBDTScore, float); @@ -162,6 +177,7 @@ DECLARE_SOA_TABLE(SigmaLambdaExtras, "AOD", "SIGMA0LAMBDA", sigmaLambdaExtra::AntiLambdaMass, sigmaLambdaExtra::LambdaQt, sigmaLambdaExtra::LambdaAlpha, + sigmaLambdaExtra::LambdaLifeTime, sigmaLambdaExtra::LambdaRadius, sigmaLambdaExtra::LambdaCosPA, sigmaLambdaExtra::LambdaDCADau, @@ -190,8 +206,10 @@ DECLARE_SOA_TABLE(SigmaLambdaExtras, "AOD", "SIGMA0LAMBDA", sigmaLambdaExtra::LambdaNegPiY, sigmaLambdaExtra::LambdaPosITSCls, sigmaLambdaExtra::LambdaNegITSCls, - sigmaLambdaExtra::LambdaPosITSClSize, - sigmaLambdaExtra::LambdaNegITSClSize, + sigmaLambdaExtra::LambdaPosITSChi2PerNcl, + sigmaLambdaExtra::LambdaNegITSChi2PerNcl, + sigmaLambdaExtra::LambdaPosTrackCode, + sigmaLambdaExtra::LambdaNegTrackCode, sigmaLambdaExtra::LambdaV0Type, sigmaLambdaExtra::LambdaBDTScore, sigmaLambdaExtra::AntiLambdaBDTScore); @@ -201,24 +219,34 @@ namespace sigmaMCCore { DECLARE_SOA_COLUMN(IsSigma, isSigma, bool); // TODO: include PDG + IsPhysicalPrimary DECLARE_SOA_COLUMN(IsAntiSigma, isAntiSigma, bool); +DECLARE_SOA_COLUMN(SigmaMCPt, sigmaMCPt, float); DECLARE_SOA_COLUMN(PhotonCandPDGCode, photonCandPDGCode, int); DECLARE_SOA_COLUMN(PhotonCandPDGCodeMother, photonCandPDGCodeMother, int); DECLARE_SOA_COLUMN(IsPhotonCandPrimary, isPhotonCandPrimary, bool); +DECLARE_SOA_COLUMN(PhotonMCPt, photonMCPt, float); +DECLARE_SOA_COLUMN(PhotonIsCorrectlyAssoc, photonIsCorrectlyAssoc, bool); DECLARE_SOA_COLUMN(LambdaCandPDGCode, lambdaCandPDGCode, int); DECLARE_SOA_COLUMN(LambdaCandPDGCodeMother, lambdaCandPDGCodeMother, int); DECLARE_SOA_COLUMN(IsLambdaCandPrimary, isLambdaCandPrimary, bool); +DECLARE_SOA_COLUMN(LambdaMCPt, lambdaMCPt, float); +DECLARE_SOA_COLUMN(LambdaIsCorrectlyAssoc, lambdaIsCorrectlyAssoc, bool); } // namespace sigmaMCCore DECLARE_SOA_TABLE(SigmaMCCores, "AOD", "SIGMA0MCCORES", sigmaMCCore::IsSigma, sigmaMCCore::IsAntiSigma, + sigmaMCCore::SigmaMCPt, sigmaMCCore::PhotonCandPDGCode, sigmaMCCore::PhotonCandPDGCodeMother, sigmaMCCore::IsPhotonCandPrimary, + sigmaMCCore::PhotonMCPt, + sigmaMCCore::PhotonIsCorrectlyAssoc, sigmaMCCore::LambdaCandPDGCode, sigmaMCCore::LambdaCandPDGCodeMother, - sigmaMCCore::IsLambdaCandPrimary); + sigmaMCCore::IsLambdaCandPrimary, + sigmaMCCore::LambdaMCPt, + sigmaMCCore::LambdaIsCorrectlyAssoc); } // namespace o2::aod #endif // PWGLF_DATAMODEL_LFSIGMATABLES_H_ diff --git a/PWGLF/DataModel/LFSlimHeLambda.h b/PWGLF/DataModel/LFSlimHeLambda.h new file mode 100644 index 00000000000..8745ac1838a --- /dev/null +++ b/PWGLF/DataModel/LFSlimHeLambda.h @@ -0,0 +1,88 @@ +// 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. + +/// +/// \file LFSlimNucleiTables.h +/// \brief Slim nuclei tables +/// + +#ifndef PWGLF_DATAMODEL_LFSLIMNUCLEITABLES_H_ +#define PWGLF_DATAMODEL_LFSLIMNUCLEITABLES_H_ + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" + +#include + +namespace o2::aod +{ +namespace lfv0he3 +{ +DECLARE_SOA_COLUMN(Z, z, float); +DECLARE_SOA_COLUMN(CentT0C, centT0C, float); +} // namespace lfv0he3 +DECLARE_SOA_TABLE(LFEvents, "AOD", "LFEVENT", o2::soa::Index<>, lfv0he3::Z, lfv0he3::CentT0C); + +namespace lfv0he3 +{ +DECLARE_SOA_INDEX_COLUMN(LFEvent, lfEvent); // Collision ID for the event +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Mass, mass, float); +DECLARE_SOA_COLUMN(CosPA, cosPA, float); +DECLARE_SOA_COLUMN(DCAxy, dcaXY, float); +DECLARE_SOA_COLUMN(DCAz, dcaZ, float); +DECLARE_SOA_COLUMN(TPCnCls, tpcNCls, int); +DECLARE_SOA_COLUMN(TPCnClsPID, tpcNClsPID, int); +DECLARE_SOA_COLUMN(ITSClusterSizes, itsClusterSizes, uint32_t); +DECLARE_SOA_COLUMN(NsigmaTPCPion, nSigmaTPCPion, float); +DECLARE_SOA_COLUMN(NsigmaTPCProton, nSigmaTPCProton, float); +DECLARE_SOA_COLUMN(NsigmaTPC, nSigmaTPC, float); +DECLARE_SOA_COLUMN(DCAdaughters, dcaDaughters, float); +DECLARE_SOA_COLUMN(DCAPVProton, dcaPVProton, float); +DECLARE_SOA_COLUMN(DCAPVPion, dcaPVPion, float); +DECLARE_SOA_COLUMN(V0Radius, v0Radius, float); +DECLARE_SOA_COLUMN(Sign, sign, int8_t); +} // namespace lfv0he3 +DECLARE_SOA_TABLE_VERSIONED(LFHe3_000, "AOD", "LFHE3V0", 0, lfv0he3::LFEventId, lfv0he3::Pt, lfv0he3::Eta, lfv0he3::Phi, lfv0he3::DCAxy, lfv0he3::DCAz, lfv0he3::TPCnCls, lfv0he3::ITSClusterSizes, lfv0he3::NsigmaTPC, lfv0he3::Sign); +DECLARE_SOA_TABLE_VERSIONED(LFLambda_000, "AOD", "LFLAMBDA", 0, lfv0he3::LFEventId, lfv0he3::Pt, lfv0he3::Eta, lfv0he3::Phi, lfv0he3::Mass, lfv0he3::CosPA, lfv0he3::DCAdaughters, lfv0he3::DCAPVProton, lfv0he3::DCAPVPion, lfv0he3::V0Radius, lfv0he3::Sign); + +DECLARE_SOA_TABLE_VERSIONED(LFHe3_001, "AOD", "LFHE3V0", 1, lfv0he3::LFEventId, lfv0he3::Pt, lfv0he3::Eta, lfv0he3::Phi, lfv0he3::DCAxy, lfv0he3::DCAz, lfv0he3::TPCnCls, lfv0he3::TPCnClsPID, lfv0he3::ITSClusterSizes, lfv0he3::NsigmaTPC, lfv0he3::Sign); +DECLARE_SOA_TABLE_VERSIONED(LFLambda_001, "AOD", "LFLAMBDA", 1, lfv0he3::LFEventId, lfv0he3::Pt, lfv0he3::Eta, lfv0he3::Phi, lfv0he3::Mass, lfv0he3::CosPA, lfv0he3::DCAdaughters, lfv0he3::DCAPVProton, lfv0he3::DCAPVPion, lfv0he3::V0Radius, lfv0he3::NsigmaTPCProton, lfv0he3::NsigmaTPCPion, lfv0he3::Sign); +} // namespace o2::aod + +struct he3Candidate { + ROOT::Math::LorentzVector> momentum; // 4-momentum of the He3 candidate + float nSigmaTPC = -999.f; // TPC nSigma for He3 + float dcaXY = -999.f; + float dcaZ = -999.f; + int tpcNClsFound = 0; // Number of TPC clusters found + int tpcNClsPID = 0; // Number of TPC clusters used for PID + int itsNCls = 0; // Number of ITS clusters + uint32_t itsClusterSizes = 0; // ITS cluster sizes + int8_t sign = 0; // Charge sign of the He3 candidate +}; + +struct lambdaCandidate { + ROOT::Math::LorentzVector> momentum; + float mass = -1.f; // Lambda mass + float cosPA = -2.f; // Cosine of pointing angle + float dcaV0Daughters = -999.f; // DCA between V0 daughters + float dcaProtonToPV = -999.f; // DCA of the proton to primary vertex + float dcaPionToPV = -999.f; // DCA of the pion to primary vertex + float v0Radius = -1.f; // V0 radius + float protonNSigmaTPC = -999.f; // Proton TPC nSigma + float pionNSigmaTPC = -999.f; // Pion TPC nSigma + int8_t sign = 0; // Charge sign of the Lambda candidate +}; + +#endif // PWGLF_DATAMODEL_LFSLIMNUCLEITABLES_H_ diff --git a/PWGLF/DataModel/LFSlimNucleiTables.h b/PWGLF/DataModel/LFSlimNucleiTables.h index 2ceba88be7d..e1c0e0eb364 100644 --- a/PWGLF/DataModel/LFSlimNucleiTables.h +++ b/PWGLF/DataModel/LFSlimNucleiTables.h @@ -14,10 +14,11 @@ /// \brief Slim nuclei tables /// -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" #include "Common/DataModel/Centrality.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" + #ifndef PWGLF_DATAMODEL_LFSLIMNUCLEITABLES_H_ #define PWGLF_DATAMODEL_LFSLIMNUCLEITABLES_H_ @@ -31,6 +32,7 @@ DECLARE_SOA_COLUMN(Phi, phi, float); DECLARE_SOA_COLUMN(TPCInnerParam, tpcInnerParam, float); DECLARE_SOA_COLUMN(Beta, beta, float); DECLARE_SOA_COLUMN(Zvertex, zVertex, float); +DECLARE_SOA_COLUMN(NContrib, nContrib, int); DECLARE_SOA_COLUMN(DCAxy, dcaxy, float); DECLARE_SOA_COLUMN(DCAz, dcaz, float); DECLARE_SOA_COLUMN(TPCsignal, tpcSignal, float); @@ -44,15 +46,39 @@ DECLARE_SOA_COLUMN(ITSclsMap, itsClsMap, uint8_t); DECLARE_SOA_COLUMN(TPCnCls, tpcNCls, uint8_t); DECLARE_SOA_COLUMN(TPCnClsShared, tpcNClsShared, uint8_t); DECLARE_SOA_COLUMN(ITSclusterSizes, itsClusterSizes, uint32_t); +DECLARE_SOA_COLUMN(SurvivedEventSelection, survivedEventSelection, bool); DECLARE_SOA_COLUMN(gPt, genPt, float); DECLARE_SOA_COLUMN(gEta, genEta, float); DECLARE_SOA_COLUMN(gPhi, genPhi, float); DECLARE_SOA_COLUMN(PDGcode, pdgCode, int); DECLARE_SOA_COLUMN(MotherPDGcode, MotherpdgCode, int); -DECLARE_SOA_COLUMN(SurvivedEventSelection, survivedEventSelection, bool); +DECLARE_SOA_COLUMN(MotherDecRad, motherDecRad, float); DECLARE_SOA_COLUMN(AbsoDecL, absoDecL, float); } // namespace NucleiTableNS + +namespace NucleiPairTableNS +{ +DECLARE_SOA_COLUMN(Pt1, pt1, float); // first particle pt +DECLARE_SOA_COLUMN(Eta1, eta1, float); // first particle eta +DECLARE_SOA_COLUMN(Phi1, phi1, float); // first particle phi +DECLARE_SOA_COLUMN(TPCInnerParam1, tpcInnerParam1, float); // first particle TPC inner param +DECLARE_SOA_COLUMN(TPCsignal1, tpcSignal1, float); // first particle TPC signal +DECLARE_SOA_COLUMN(DCAxy1, dcaxy1, float); // first particle DCA xy +DECLARE_SOA_COLUMN(DCAz1, dcaz1, float); // first particle DCA z +DECLARE_SOA_COLUMN(ClusterSizesITS1, clusterSizesITS1, uint32_t); // first particle ITS cluster sizes +DECLARE_SOA_COLUMN(Flags1, flags1, uint16_t); // first particle flags +DECLARE_SOA_COLUMN(Pt2, pt2, float); // second particle pt +DECLARE_SOA_COLUMN(Eta2, eta2, float); // second particle eta +DECLARE_SOA_COLUMN(Phi2, phi2, float); // second particle phi +DECLARE_SOA_COLUMN(TPCInnerParam2, tpcInnerParam2, float); // second particle TPC inner param +DECLARE_SOA_COLUMN(TPCsignal2, tpcSignal2, float); // second particle TPC signal +DECLARE_SOA_COLUMN(DCAxy2, dcaxy2, float); // second particle DCA xy +DECLARE_SOA_COLUMN(DCAz2, dcaz2, float); // second particle DCA z +DECLARE_SOA_COLUMN(ClusterSizesITS2, clusterSizesITS2, uint32_t); // second particle ITS cluster sizes +DECLARE_SOA_COLUMN(Flags2, flags2, uint16_t); // second particle flags +} // namespace NucleiPairTableNS + namespace NucleiFlowTableNS { DECLARE_SOA_COLUMN(CentFV0A, centFV0A, float); // centrality with FT0A estimator @@ -60,13 +86,15 @@ DECLARE_SOA_COLUMN(CentFT0A, centFT0A, float); // centrality with FT0A estimator DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); // centrality with FT0C estimator DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); // centrality with FT0M estimator DECLARE_SOA_COLUMN(PsiFT0A, psiFT0A, float); // Psi with FT0A estimator -DECLARE_SOA_COLUMN(MultFT0A, multFT0A, float); // Multiplicity with FT0A estimator DECLARE_SOA_COLUMN(PsiFT0C, psiFT0C, float); // Psi with FT0C estimator -DECLARE_SOA_COLUMN(MultFT0C, multFT0C, float); // Multiplicity with FT0C estimator DECLARE_SOA_COLUMN(PsiTPC, psiTPC, float); // Psi with TPC estimator DECLARE_SOA_COLUMN(PsiTPCl, psiTPCl, float); // Psi with TPC estimator (left) DECLARE_SOA_COLUMN(PsiTPCr, psiTPCr, float); // Psi with TPC estimator (right) -DECLARE_SOA_COLUMN(MultTPC, multTPC, int); // Multiplicity with TPC estimator +DECLARE_SOA_COLUMN(QFT0A, qFT0A, float); // Amplitude with FT0A estimator +DECLARE_SOA_COLUMN(QFT0C, qFT0C, float); // Amplitude with FT0C estimator +DECLARE_SOA_COLUMN(QTPC, qTPC, float); // Amplitude with TPC estimator +DECLARE_SOA_COLUMN(QTPCl, qTPCl, float); // Amplitude with TPC estimator (left) +DECLARE_SOA_COLUMN(QTPCr, qTPCr, float); // Amplitude with TPC estimator (right) } // namespace NucleiFlowTableNS DECLARE_SOA_TABLE(NucleiTable, "AOD", "NUCLEITABLE", @@ -76,6 +104,7 @@ DECLARE_SOA_TABLE(NucleiTable, "AOD", "NUCLEITABLE", NucleiTableNS::TPCInnerParam, NucleiTableNS::Beta, NucleiTableNS::Zvertex, + NucleiTableNS::NContrib, NucleiTableNS::DCAxy, NucleiTableNS::DCAz, NucleiTableNS::TPCsignal, @@ -96,13 +125,15 @@ DECLARE_SOA_TABLE(NucleiTableFlow, "AOD", "NUCLEITABLEFLOW", NucleiFlowTableNS::CentFT0A, NucleiFlowTableNS::CentFT0C, NucleiFlowTableNS::PsiFT0A, - NucleiFlowTableNS::MultFT0A, NucleiFlowTableNS::PsiFT0C, - NucleiFlowTableNS::MultFT0C, NucleiFlowTableNS::PsiTPC, NucleiFlowTableNS::PsiTPCl, NucleiFlowTableNS::PsiTPCr, - NucleiFlowTableNS::MultTPC); + NucleiFlowTableNS::QFT0A, + NucleiFlowTableNS::QFT0C, + NucleiFlowTableNS::QTPC, + NucleiFlowTableNS::QTPCl, + NucleiFlowTableNS::QTPCr); DECLARE_SOA_TABLE(NucleiTableMC, "AOD", "NUCLEITABLEMC", NucleiTableNS::Pt, @@ -111,6 +142,7 @@ DECLARE_SOA_TABLE(NucleiTableMC, "AOD", "NUCLEITABLEMC", NucleiTableNS::TPCInnerParam, NucleiTableNS::Beta, NucleiTableNS::Zvertex, + NucleiTableNS::NContrib, NucleiTableNS::DCAxy, NucleiTableNS::DCAz, NucleiTableNS::TPCsignal, @@ -124,14 +156,35 @@ DECLARE_SOA_TABLE(NucleiTableMC, "AOD", "NUCLEITABLEMC", NucleiTableNS::TPCnCls, NucleiTableNS::TPCnClsShared, NucleiTableNS::ITSclusterSizes, + NucleiTableNS::SurvivedEventSelection, NucleiTableNS::gPt, NucleiTableNS::gEta, NucleiTableNS::gPhi, NucleiTableNS::PDGcode, NucleiTableNS::MotherPDGcode, - NucleiTableNS::SurvivedEventSelection, + NucleiTableNS::MotherDecRad, NucleiTableNS::AbsoDecL); +DECLARE_SOA_TABLE(NucleiPairTable, "AOD", "NUCLEIPAIRTABLE", + NucleiPairTableNS::Pt1, + NucleiPairTableNS::Eta1, + NucleiPairTableNS::Phi1, + NucleiPairTableNS::TPCInnerParam1, + NucleiPairTableNS::TPCsignal1, + NucleiPairTableNS::DCAxy1, + NucleiPairTableNS::DCAz1, + NucleiPairTableNS::ClusterSizesITS1, + NucleiPairTableNS::Flags1, + NucleiPairTableNS::Pt2, + NucleiPairTableNS::Eta2, + NucleiPairTableNS::Phi2, + NucleiPairTableNS::TPCInnerParam2, + NucleiPairTableNS::TPCsignal2, + NucleiPairTableNS::DCAxy2, + NucleiPairTableNS::DCAz2, + NucleiPairTableNS::ClusterSizesITS2, + NucleiPairTableNS::Flags2); + } // namespace o2::aod #endif // PWGLF_DATAMODEL_LFSLIMNUCLEITABLES_H_ diff --git a/PWGLF/DataModel/LFSpincorrelationTables.h b/PWGLF/DataModel/LFSpincorrelationTables.h new file mode 100644 index 00000000000..f875736d794 --- /dev/null +++ b/PWGLF/DataModel/LFSpincorrelationTables.h @@ -0,0 +1,138 @@ +// 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 Sourav Kundu + +#ifndef PWGLF_DATAMODEL_LFSPINCORRELATIONTABLES_H_ +#define PWGLF_DATAMODEL_LFSPINCORRELATIONTABLES_H_ + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" + +#include + +namespace o2::aod +{ +namespace lambdaevent +{ +DECLARE_SOA_COLUMN(Cent, cent, float); +DECLARE_SOA_COLUMN(Posz, posz, float); +} // namespace lambdaevent +DECLARE_SOA_TABLE(LambdaEvents, "AOD", "LAMBDAEVENT", + o2::soa::Index<>, + lambdaevent::Cent, + lambdaevent::Posz) +using LambdaEvent = LambdaEvents::iterator; + +namespace lambdapair +{ +DECLARE_SOA_INDEX_COLUMN(LambdaEvent, lambdaevent); +DECLARE_SOA_COLUMN(V0Status, v0Status, int); //! Lambda or Anti-Lambda status +DECLARE_SOA_COLUMN(DoubleStatus, doubleStatus, bool); //! Double status +DECLARE_SOA_COLUMN(V0Cospa, v0Cospa, float); //! V0 Cospa +DECLARE_SOA_COLUMN(V0Radius, v0Radius, float); //! V0 Radius +DECLARE_SOA_COLUMN(DcaPositive, dcaPositive, float); //! DCA Positive +DECLARE_SOA_COLUMN(DcaNegative, dcaNegative, float); //! DCA Negative +DECLARE_SOA_COLUMN(DcaBetweenDaughter, dcaBetweenDaughter, float); //! DCA between daughters +DECLARE_SOA_COLUMN(LambdaPt, lambdaPt, float); //! Lambda Pt +DECLARE_SOA_COLUMN(LambdaEta, lambdaEta, float); //! Lambda Eta +DECLARE_SOA_COLUMN(LambdaPhi, lambdaPhi, float); //! Lambda Phi +DECLARE_SOA_COLUMN(LambdaMass, lambdaMass, float); //! Lambda Mass +DECLARE_SOA_COLUMN(ProtonPt, protonPt, float); //! Proton Pt +DECLARE_SOA_COLUMN(ProtonEta, protonEta, float); //! Proton Eta +DECLARE_SOA_COLUMN(ProtonPhi, protonPhi, float); //! Proton Phi +DECLARE_SOA_COLUMN(ProtonIndex, protonIndex, int); //! Proton index +DECLARE_SOA_COLUMN(PionIndex, pionIndex, int); //! Pion index +} // namespace lambdapair +DECLARE_SOA_TABLE(LambdaPairs, "AOD", "LAMBDAPAIR", + o2::soa::Index<>, + lambdapair::LambdaEventId, + lambdapair::V0Status, + lambdapair::DoubleStatus, + lambdapair::V0Cospa, + lambdapair::V0Radius, + lambdapair::DcaPositive, + lambdapair::DcaNegative, + lambdapair::DcaBetweenDaughter, + lambdapair::LambdaPt, + lambdapair::LambdaEta, + lambdapair::LambdaPhi, + lambdapair::LambdaMass, + lambdapair::ProtonPt, + lambdapair::ProtonEta, + lambdapair::ProtonPhi, + lambdapair::ProtonIndex, + lambdapair::PionIndex); + +using LambdaPair = LambdaPairs::iterator; + +namespace lambdaeventmc +{ +DECLARE_SOA_COLUMN(Centmc, centmc, float); +DECLARE_SOA_COLUMN(Poszmc, poszmc, float); +} // namespace lambdaeventmc +DECLARE_SOA_TABLE(LambdaEventmcs, "AOD", "LAMBDAEVENTMC", + o2::soa::Index<>, + lambdaeventmc::Centmc, + lambdaeventmc::Poszmc) +using LambdaEventmc = LambdaEventmcs::iterator; + +namespace lambdapairmc +{ +DECLARE_SOA_INDEX_COLUMN(LambdaEventmc, lambdaeventmc); +DECLARE_SOA_COLUMN(V0Statusmc, v0Statusmc, int); //! Lambda or Anti-Lambda status in montecarlo +DECLARE_SOA_COLUMN(DoubleStatusmc, doubleStatusmc, bool); //! Double status in montecarlo +DECLARE_SOA_COLUMN(V0Cospamc, v0Cospamc, float); //! V0 Cospa in montecarlo +DECLARE_SOA_COLUMN(V0Radiusmc, v0Radiusmc, float); //! V0 Radius in montecarlo +DECLARE_SOA_COLUMN(DcaPositivemc, dcaPositivemc, float); //! DCA Positive in montecarlo +DECLARE_SOA_COLUMN(DcaNegativemc, dcaNegativemc, float); //! DCA Negative in montecarlo +DECLARE_SOA_COLUMN(DcaBetweenDaughtermc, dcaBetweenDaughtermc, float); //! DCA between daughters in montecarlo +DECLARE_SOA_COLUMN(LambdaPtmc, lambdaPtmc, float); //! Lambda Pt in montecarlo +DECLARE_SOA_COLUMN(LambdaEtamc, lambdaEtamc, float); //! Lambda Eta in montecarlo +DECLARE_SOA_COLUMN(LambdaPhimc, lambdaPhimc, float); //! Lambda Phi in montecarlo +DECLARE_SOA_COLUMN(LambdaMassmc, lambdaMassmc, float); //! Lambda Mass in montecarlo +DECLARE_SOA_COLUMN(ProtonPtmc, protonPtmc, float); //! Proton Pt in montecarlo +DECLARE_SOA_COLUMN(ProtonEtamc, protonEtamc, float); //! Proton Eta in montecarlo +DECLARE_SOA_COLUMN(ProtonPhimc, protonPhimc, float); //! Proton Phi in montecarlo +DECLARE_SOA_COLUMN(ProtonIndexmc, protonIndexmc, int); //! Proton index in montecarlo +DECLARE_SOA_COLUMN(PionIndexmc, pionIndexmc, int); //! Pion index in montecarlo +} // namespace lambdapairmc +DECLARE_SOA_TABLE(LambdaPairmcs, "AOD", "LAMBDAPAIRMC", + o2::soa::Index<>, + lambdapairmc::LambdaEventmcId, + lambdapairmc::V0Statusmc, + lambdapairmc::DoubleStatusmc, + lambdapairmc::V0Cospamc, + lambdapairmc::V0Radiusmc, + lambdapairmc::DcaPositivemc, + lambdapairmc::DcaNegativemc, + lambdapairmc::DcaBetweenDaughtermc, + lambdapairmc::LambdaPtmc, + lambdapairmc::LambdaEtamc, + lambdapairmc::LambdaPhimc, + lambdapairmc::LambdaMassmc, + lambdapairmc::ProtonPtmc, + lambdapairmc::ProtonEtamc, + lambdapairmc::ProtonPhimc, + lambdapairmc::ProtonIndexmc, + lambdapairmc::PionIndexmc); + +using LambdaPairmc = LambdaPairmcs::iterator; + +} // namespace o2::aod +#endif // PWGLF_DATAMODEL_LFSPINCORRELATIONTABLES_H_ diff --git a/PWGLF/DataModel/LFStrangenessTables.h b/PWGLF/DataModel/LFStrangenessTables.h index 58913d404c4..3ee36c7c54a 100644 --- a/PWGLF/DataModel/LFStrangenessTables.h +++ b/PWGLF/DataModel/LFStrangenessTables.h @@ -8,22 +8,29 @@ // 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. + #ifndef PWGLF_DATAMODEL_LFSTRANGENESSTABLES_H_ #define PWGLF_DATAMODEL_LFSTRANGENESSTABLES_H_ -#include -#include -#include "Framework/AnalysisDataModel.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/SPCalibrationTables.h" +#include "PWGUD/DataModel/UDTables.h" + #include "Common/Core/RecoDecay.h" -#include "CommonConstants/PhysicsConstants.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/McCollisionExtra.h" // IWYU pragma: keep (FIXME: not used, remove asap) #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" #include "Common/DataModel/Qvectors.h" -#include "Common/DataModel/McCollisionExtra.h" -#include "PWGLF/DataModel/EPCalibrationTables.h" -#include "PWGLF/DataModel/SPCalibrationTables.h" -#include "PWGUD/DataModel/UDTables.h" + +#include +#include +#include + +#include +#include +#include +#include namespace o2::aod { @@ -63,9 +70,19 @@ DECLARE_SOA_DYNAMIC_COLUMN(EnergyCommonZNC, energyCommonZNC, //! get the total s // if required (for 2pc, etc) DECLARE_SOA_TABLE(StraCollisions, "AOD", "STRACOLLISION", //! basic collision properties: position o2::soa::Index<>, collision::PosX, collision::PosY, collision::PosZ); -DECLARE_SOA_TABLE(StraCents, "AOD", "STRACENTS", //! centrality percentiles +DECLARE_SOA_TABLE(StraCents_000, "AOD", "STRACENTS", //! centrality percentiles cent::CentFT0M, cent::CentFT0A, cent::CentFT0C, cent::CentFV0A); +DECLARE_SOA_TABLE_VERSIONED(StraCents_001, "AOD", "STRACENTS", 1, //! centrality percentiles in Run 3 + cent::CentFT0M, cent::CentFT0A, + cent::CentFT0C, cent::CentFV0A, + cent::CentFT0CVariant1, cent::CentMFT, + cent::CentNGlobal); + +DECLARE_SOA_TABLE(StraCentsRun2, "AOD", "STRACENTSRUN2", //! centrality percentiles in Run 2 + cent::CentRun2V0M, cent::CentRun2V0A, + cent::CentRun2SPDTracklets, cent::CentRun2SPDClusters); + // !!! DEPRECATED TABLE: StraRawCents_000 !!! All info in StraEvSels_001, in order to group all event characteristics in a unique table. Please use StraEvSels_001 DECLARE_SOA_TABLE(StraRawCents_000, "AOD", "STRARAWCENTS", //! debug information mult::MultFT0A, mult::MultFT0C, mult::MultFV0A, mult::MultNTracksPVeta1); @@ -216,6 +233,60 @@ DECLARE_SOA_TABLE_VERSIONED(StraEvSels_004, "AOD", "STRAEVSELS", 4, //! // stracollision::EnergyCommonZNC, stracollision::IsUPC); +DECLARE_SOA_TABLE_VERSIONED(StraEvSels_005, "AOD", "STRAEVSELS", 5, //! debug information + evsel::Sel8, evsel::Selection, //! event selection: sel8 + mult::MultFT0A, mult::MultFT0C, mult::MultFV0A, // FIT detectors + mult::MultFDDA, mult::MultFDDC, + mult::MultNTracksPVeta1, // track multiplicities with eta cut for INEL>0 + mult::MultPVTotalContributors, // number of PV contribs total + mult::MultNTracksGlobal, // global track multiplicities + mult::MultNTracksITSTPC, // track multiplicities, PV contribs, no eta cut + mult::MultAllTracksTPCOnly, // TPConly track multiplicities, all, no eta cut + mult::MultAllTracksITSTPC, // ITSTPC track multiplicities, all, no eta cut + mult::MultZNA, mult::MultZNC, mult::MultZEM1, // ZDC signals + mult::MultZEM2, mult::MultZPA, mult::MultZPC, + evsel::NumTracksInTimeRange, // add occupancy in specified time interval by a number of tracks from nearby collisions + evsel::SumAmpFT0CInTimeRange, // add occupancy in specified time interval by a sum of FT0C amplitudes from nearby collisions + udcollision::GapSide, // UPC info: 0 for side A, 1 for side C, 2 for both sides, 3 neither A or C, 4 not enough or too many pv contributors + udcollision::TotalFT0AmplitudeA, // UPC info: re-assigned FT0-A amplitude, in case of SG event, from the most active bc + udcollision::TotalFT0AmplitudeC, // UPC info: re-assigned FT0-C amplitude, in case of SG event, from the most active bc + udcollision::TotalFV0AmplitudeA, // UPC info: re-assigned FV0-A amplitude, in case of SG event, from the most active bc + udcollision::TotalFDDAmplitudeA, // UPC info: re-assigned FDD-A amplitude, in case of SG event, from the most active bc + udcollision::TotalFDDAmplitudeC, // UPC info: re-assigned FDD-C amplitude, in case of SG event, from the most active bc + udzdc::EnergyCommonZNA, // UPC info: re-assigned ZN-A amplitude, in case of SG event, from the most active bc + udzdc::EnergyCommonZNC, // UPC info: re-assigned ZN-C amplitude, in case of SG event, from the most active bc + + collision::Flags, // Contains Vertex::Flags, with most notably the UPCMode to know whether the vertex has been found using UPC settings + evsel::Alias, // trigger aliases (e.g. kTVXinTRD for v2) + evsel::Rct, // Bitmask of RCT flags + + // Dynamic columns for manipulating information + // stracollision::TotalFV0AmplitudeA, + // stracollision::TotalFT0AmplitudeA, + // stracollision::TotalFT0AmplitudeC, + // stracollision::TotalFDDAmplitudeA, + // stracollision::TotalFDDAmplitudeC, + // stracollision::EnergyCommonZNA, + // stracollision::EnergyCommonZNC, + stracollision::IsUPC); + +DECLARE_SOA_TABLE(StraEvSelsRun2, "AOD", "STRAEVSELSRUN2", //! debug information + evsel::Sel8, evsel::Sel7, evsel::Selection, //! event selection: sel8 + mult::MultFT0A, mult::MultFT0C, // FIT detectors + mult::MultFV0A, mult::MultFV0C, + mult::MultFDDA, mult::MultFDDC, + run2::SPDClustersL0, run2::SPDClustersL1, // SPD detectors + mult::MultNTracksPVeta1, // track multiplicities with eta cut for INEL>0 + mult::MultTracklets, // multiplicity with tracklets (only Run2) + mult::MultPVTotalContributors, // number of PV contribs total + mult::MultNTracksGlobal, // global track multiplicities + mult::MultNTracksITSTPC, // track multiplicities, PV contribs, no eta cut + mult::MultAllTracksTPCOnly, // TPConly track multiplicities, all, no eta cut + mult::MultAllTracksITSTPC, // ITSTPC track multiplicities, all, no eta cut + mult::MultZNA, mult::MultZNC, mult::MultZEM1, // ZDC signals + mult::MultZEM2, mult::MultZPA, mult::MultZPC, + evsel::Alias); // trigger aliases (e.g. kTVXinTRD for v2) + DECLARE_SOA_TABLE(StraFT0AQVs, "AOD", "STRAFT0AQVS", //! t0a Qvec qvec::QvecFT0ARe, qvec::QvecFT0AIm, qvec::SumAmplFT0A); DECLARE_SOA_TABLE(StraFT0CQVs, "AOD", "STRAFT0CQVS", //! t0c Qvec @@ -231,17 +302,23 @@ DECLARE_SOA_TABLE(StraFT0CQVsEv, "AOD", "STRAFT0CQVSEv", //! events used to comp epcalibrationtable::TriggerEventEP); DECLARE_SOA_TABLE(StraZDCSP, "AOD", "STRAZDCSP", //! ZDC SP information spcalibrationtable::TriggerEventSP, - spcalibrationtable::PsiZDCA, spcalibrationtable::PsiZDCC); + spcalibrationtable::PsiZDCA, spcalibrationtable::PsiZDCC, spcalibrationtable::QXZDCA, spcalibrationtable::QXZDCC, spcalibrationtable::QYZDCA, spcalibrationtable::QYZDCC); DECLARE_SOA_TABLE(StraStamps_000, "AOD", "STRASTAMPS", //! information for ID-ing mag field if needed bc::RunNumber, timestamp::Timestamp); DECLARE_SOA_TABLE_VERSIONED(StraStamps_001, "AOD", "STRASTAMPS", 1, //! information for ID-ing mag field if needed bc::RunNumber, timestamp::Timestamp, bc::GlobalBC); using StraRawCents = StraRawCents_004; -using StraEvSels = StraEvSels_004; +using StraCents = StraCents_001; +using StraEvSels = StraEvSels_005; using StraStamps = StraStamps_001; using StraCollision = StraCollisions::iterator; -using StraCent = StraCents::iterator; +using StraCent = StraCents_001::iterator; + +namespace stramccollision +{ +DECLARE_SOA_COLUMN(TotalMultMCParticles, totalMultMCParticles, int); //! total number of MC particles in a generated collision +} // namespace stramccollision //______________________________________________________ // for correlating information with MC @@ -252,12 +329,18 @@ DECLARE_SOA_TABLE(StraMCCollisions_000, "AOD", "STRAMCCOLLISION", //! MC collisi DECLARE_SOA_TABLE_VERSIONED(StraMCCollisions_001, "AOD", "STRAMCCOLLISION", 1, //! debug information o2::soa::Index<>, mccollision::PosX, mccollision::PosY, mccollision::PosZ, mccollision::ImpactParameter, mccollision::EventPlaneAngle); -using StraMCCollisions = StraMCCollisions_001; +DECLARE_SOA_TABLE_VERSIONED(StraMCCollisions_002, "AOD", "STRAMCCOLLISION", 2, //! debug information + o2::soa::Index<>, mccollision::PosX, mccollision::PosY, mccollision::PosZ, + mccollision::ImpactParameter, mccollision::EventPlaneAngle, mccollision::GeneratorsID); +using StraMCCollisions = StraMCCollisions_002; +using StraMCCollision = StraMCCollisions::iterator; -DECLARE_SOA_TABLE(StraMCCollMults, "AOD", "STRAMCCOLLMULTS", //! MC collision multiplicities +DECLARE_SOA_TABLE(StraMCCollMults_000, "AOD", "STRAMCCOLLMULTS", //! MC collision multiplicities mult::MultMCFT0A, mult::MultMCFT0C, mult::MultMCNParticlesEta05, mult::MultMCNParticlesEta08, mult::MultMCNParticlesEta10, o2::soa::Marker<2>); +DECLARE_SOA_TABLE_VERSIONED(StraMCCollMults_001, "AOD", "STRAMCCOLLMULTS", 1, //! MC collision multiplicities + mult::MultMCFT0A, mult::MultMCFT0C, mult::MultMCNParticlesEta05, mult::MultMCNParticlesEta08, mult::MultMCNParticlesEta10, stramccollision::TotalMultMCParticles); -using StraMCCollision = StraMCCollisions::iterator; +using StraMCCollMults = StraMCCollMults_001; namespace dautrack { @@ -384,10 +467,45 @@ DECLARE_SOA_TABLE_VERSIONED(DauTrackExtras_002, "AOD", "DAUTRACKEXTRA", 2, //! d dautrack::HasTRD, dautrack::HasTOF); +DECLARE_SOA_TABLE_VERSIONED(DauTrackExtras_003, "AOD", "DAUTRACKEXTRA", 3, //! detector properties of decay daughters + track::ITSChi2NCl, + track::TPCChi2NCl, + dautrack::DetectorMap, // here we don´t save everything so we simplify this + track::ITSClusterSizes, + track::TPCNClsFindable, + track::TPCNClsFindableMinusFound, + track::TPCNClsFindableMinusCrossedRows, + track::TPCNClsShared, + + // Dynamics for ITS matching TracksExtra + track::v001::ITSNClsInnerBarrel, + track::v001::ITSClsSizeInLayer, + track::v001::ITSClusterMap, + track::v001::ITSNCls, + track::v001::IsITSAfterburner, + /*compatibility*/ dautrack::HasITSTracker, + /*compatibility*/ dautrack::HasITSAfterburner, + + // dynamics for TPC tracking properties matching main data model + track::TPCCrossedRowsOverFindableCls, + track::TPCFoundOverFindableCls, + track::TPCNClsFound, + track::TPCNClsCrossedRows, + track::TPCFractionSharedCls, + /*compatibility*/ dautrack::compatibility::TPCClusters, + /*compatibility*/ dautrack::compatibility::TPCCrossedRows, + /*compatibility*/ dautrack::compatibility::ITSChi2PerNcl, + + // dynamics to identify detectors + dautrack::HasITS, + dautrack::HasTPC, + dautrack::HasTRD, + dautrack::HasTOF); + DECLARE_SOA_TABLE(DauTrackMCIds, "AOD", "DAUTRACKMCID", // index table when using AO2Ds dautrack::ParticleMCId); -using DauTrackExtras = DauTrackExtras_002; +using DauTrackExtras = DauTrackExtras_003; using DauTrackExtra = DauTrackExtras::iterator; namespace motherParticle @@ -464,7 +582,7 @@ DECLARE_SOA_COLUMN(DCAV0Daughters, dcaV0daughters, float); //! DCA between V0 da DECLARE_SOA_COLUMN(DCAPosToPV, dcapostopv, float); //! DCA positive prong to PV DECLARE_SOA_COLUMN(DCANegToPV, dcanegtopv, float); //! DCA negative prong to PV DECLARE_SOA_COLUMN(V0CosPA, v0cosPA, float); //! V0 CosPA -DECLARE_SOA_COLUMN(DCAV0ToPV, dcav0topv, float); //! DCA V0 to PV +DECLARE_SOA_COLUMN(DCAV0ToPV, dcav0topv, float); //! DCA V0 to PV (3D) // Type of V0 from the svertexer (photon, regular, from cascade) DECLARE_SOA_COLUMN(V0Type, v0Type, uint8_t); //! type of V0. 0: built solely for cascades (does not pass standard V0 cuts), 1: standard 2, 3: photon-like with TPC-only use. Regular analysis should always use type 1. @@ -507,42 +625,28 @@ DECLARE_SOA_COLUMN(GeneratedK0Short, generatedK0Short, std::vector); DECLARE_SOA_COLUMN(GeneratedLambda, generatedLambda, std::vector); //! Lambda binned generated data DECLARE_SOA_COLUMN(GeneratedAntiLambda, generatedAntiLambda, std::vector); //! AntiLambda binned generated data -//______________________________________________________ -// EXPRESSION COLUMNS -DECLARE_SOA_EXPRESSION_COLUMN(Px, px, //! V0 px - float, 1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg); -DECLARE_SOA_EXPRESSION_COLUMN(Py, py, //! V0 py - float, 1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg); -DECLARE_SOA_EXPRESSION_COLUMN(Pz, pz, //! V0 pz - float, 1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg); -DECLARE_SOA_EXPRESSION_COLUMN(Pt, pt, float, //! Transverse momentum in GeV/c - nsqrt((1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) * - (1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) + - (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg) * (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg))); -DECLARE_SOA_EXPRESSION_COLUMN(P, p, float, //! Total momentum in GeV/c - nsqrt((1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) * - (1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) + - (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg) * (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg) + - (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg) * (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg))); -DECLARE_SOA_EXPRESSION_COLUMN(Phi, phi, float, //! Phi in the range [0, 2pi) - o2::constants::math::PI + natan2(-1.0f * (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg), -1.0f * (1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg))); -DECLARE_SOA_EXPRESSION_COLUMN(Eta, eta, float, //! Pseudorapidity, conditionally defined to avoid FPEs - ifnode((nsqrt((1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) * (1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) + - (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg) * (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg) + - (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg) * (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg)) - - (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg)) < static_cast(1e-7), - ifnode((1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg) < 0.f, -100.f, 100.f), - 0.5f * nlog((nsqrt((1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) * (1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) + - (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg) * (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg) + - (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg) * (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg)) + - (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg)) / - (nsqrt((1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) * (1.f * aod::v0data::pxpos + 1.f * aod::v0data::pxneg) + - (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg) * (1.f * aod::v0data::pypos + 1.f * aod::v0data::pyneg) + - (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg) * (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg)) - - (1.f * aod::v0data::pzpos + 1.f * aod::v0data::pzneg))))); - //______________________________________________________ // DYNAMIC COLUMNS +DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! V0 px + [](float pxPos, float pxNeg) -> float { return pxPos + pxNeg; }); +DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! V0 py + [](float pyPos, float pyNeg) -> float { return pyPos + pyNeg; }); +DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //! V0 pz + [](float pzPos, float pzNeg) -> float { return pzPos + pzNeg; }); +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! Transverse momentum in GeV/c + [](float pxPos, float pyPos, float pxNeg, float pyNeg) -> float { + return RecoDecay::sqrtSumOfSquares(pxPos + pxNeg, pyPos + pyNeg); + }); +DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! Total momentum in GeV/c + [](float pxPos, float pyPos, float pzPos, float pxNeg, float pyNeg, float pzNeg) -> float { + return RecoDecay::sqrtSumOfSquares(pxPos + pxNeg, pyPos + pyNeg, pzPos + pzNeg); + }); +DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, //! Phi in the range [0, 2pi) + [](float pxPos, float pyPos, float pxNeg, float pyNeg) -> float { return RecoDecay::phi(pxPos + pxNeg, pyPos + pyNeg); }); +DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, //! Pseudorapidity, conditionally defined to avoid FPEs + [](float pxPos, float pyPos, float pzPos, float pxNeg, float pyNeg, float pzNeg) -> float { + return RecoDecay::eta(std::array{pxPos + pxNeg, pyPos + pyNeg, pzPos + pzNeg}); + }); // Account for rigidity in case of hypertriton DECLARE_SOA_DYNAMIC_COLUMN(PtHypertriton, ptHypertriton, //! V0 pT [](float pxpos, float pypos, float pxneg, float pyneg) -> float { return RecoDecay::sqrtSumOfSquares(2.0f * pxpos + pxneg, 2.0f * pypos + pyneg); }); @@ -555,8 +659,8 @@ DECLARE_SOA_DYNAMIC_COLUMN(V0Radius, v0radius, //! V0 decay radius (2D, centered // Distance Over To Mom DECLARE_SOA_DYNAMIC_COLUMN(DistOverTotMom, distovertotmom, //! PV to V0decay distance over total momentum - [](float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) { - float P = RecoDecay::sqrtSumOfSquares(Px, Py, Pz); + [](float X, float Y, float Z, float pxPos, float pyPos, float pzPos, float pxNeg, float pyNeg, float pzNeg, float pvX, float pvY, float pvZ) { + float P = RecoDecay::sqrtSumOfSquares(pxPos + pxNeg, pyPos + pyNeg, pzPos + pzNeg); return std::sqrt(std::pow(X - pvX, 2) + std::pow(Y - pvY, 2) + std::pow(Z - pvZ, 2)) / (P + 1E-10); }); @@ -635,19 +739,23 @@ DECLARE_SOA_DYNAMIC_COLUMN(M, m, //! mass under a certain hypothesis (0:K0, 1:L, }); DECLARE_SOA_DYNAMIC_COLUMN(YK0Short, yK0Short, //! V0 y with K0short hypothesis - [](float Px, float Py, float Pz) -> float { return RecoDecay::y(std::array{Px, Py, Pz}, o2::constants::physics::MassKaonNeutral); }); + [](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg) -> float { + return RecoDecay::y(std::array{pxpos + pxneg, pypos + pyneg, pzpos + pzneg}, o2::constants::physics::MassKaonNeutral); + }); DECLARE_SOA_DYNAMIC_COLUMN(YLambda, yLambda, //! V0 y with lambda or antilambda hypothesis - [](float Px, float Py, float Pz) -> float { return RecoDecay::y(std::array{Px, Py, Pz}, o2::constants::physics::MassLambda); }); + [](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg) -> float { + return RecoDecay::y(std::array{pxpos + pxneg, pypos + pyneg, pzpos + pzneg}, o2::constants::physics::MassLambda); + }); DECLARE_SOA_DYNAMIC_COLUMN(YHypertriton, yHypertriton, //! V0 y with hypertriton hypothesis [](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg) -> float { return RecoDecay::y(std::array{2.0f * pxpos + pxneg, 2.0f * pypos + pyneg, 2.0f * pzpos + pzneg}, o2::constants::physics::MassHyperTriton); }); DECLARE_SOA_DYNAMIC_COLUMN(YAntiHypertriton, yAntiHypertriton, //! V0 y with antihypertriton hypothesis [](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg) -> float { return RecoDecay::y(std::array{pxpos + 2.0f * pxneg, pypos + 2.0f * pyneg, pzpos + 2.0f * pzneg}, o2::constants::physics::MassHyperTriton); }); DECLARE_SOA_DYNAMIC_COLUMN(Rapidity, rapidity, //! rapidity (0:K0, 1:L, 2:Lbar) - [](float Px, float Py, float Pz, int value) -> float { + [](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg, int value) -> float { if (value == 0) - return RecoDecay::y(std::array{Px, Py, Pz}, o2::constants::physics::MassKaonNeutral); + return RecoDecay::y(std::array{pxpos + pxneg, pypos + pyneg, pzpos + pzneg}, o2::constants::physics::MassKaonNeutral); if (value == 1 || value == 2) - return RecoDecay::y(std::array{Px, Py, Pz}, o2::constants::physics::MassLambda); + return RecoDecay::y(std::array{pxpos + pxneg, pypos + pyneg, pzpos + pzneg}, o2::constants::physics::MassLambda); return 0.0f; }); @@ -709,10 +817,17 @@ DECLARE_SOA_TABLE_STAGED(V0CoresBase, "V0CORE", //! core information about decay v0data::V0CosPA, v0data::DCAV0ToPV, v0data::V0Type, // Dynamic columns + v0data::Px, + v0data::Py, + v0data::Pz, + v0data::Pt, + v0data::P, + v0data::Phi, + v0data::Eta, v0data::PtHypertriton, v0data::PtAntiHypertriton, v0data::V0Radius, - v0data::DistOverTotMom, + v0data::DistOverTotMom, v0data::Alpha, v0data::QtArm, v0data::PsiPair, @@ -729,11 +844,11 @@ DECLARE_SOA_TABLE_STAGED(V0CoresBase, "V0CORE", //! core information about decay v0data::M, // Longitudinal - v0data::YK0Short, - v0data::YLambda, + v0data::YK0Short, + v0data::YLambda, v0data::YHypertriton, v0data::YAntiHypertriton, - v0data::Rapidity, + v0data::Rapidity, v0data::NegativePt, v0data::PositivePt, v0data::NegativeEta, @@ -744,8 +859,8 @@ DECLARE_SOA_TABLE_STAGED(V0CoresBase, "V0CORE", //! core information about decay v0data::IsPhotonTPConly); // extended table with expression columns that can be used as arguments of dynamic columns -DECLARE_SOA_EXTENDED_TABLE_USER(V0Cores, V0CoresBase, "V0COREEXT", //! - v0data::Px, v0data::Py, v0data::Pz, v0data::Pt, v0data::P, v0data::Phi, v0data::Eta); // the table name has here to be the one with EXT which is not nice and under study +// DECLARE_SOA_EXTENDED_TABLE_USER(V0Cores, V0CoresBase, "V0COREEXT", //! +// v0data::Px, v0data::Py, v0data::Pz, v0data::Pt, v0data::P, v0data::Phi, v0data::Eta); // the table name has here to be the one with EXT which is not nice and under study // // extended table with expression columns that can be used as arguments of dynamic columns // DECLARE_SOA_EXTENDED_TABLE_USER(StoredV0Cores, StoredV0CoresBase, "V0COREEXT", //! @@ -783,10 +898,17 @@ DECLARE_SOA_TABLE_FULL(StoredV0fCCores, "V0fCCores", "AOD", "V0FCCORE", //! core v0data::V0CosPA, v0data::DCAV0ToPV, v0data::V0Type, // Dynamic columns + v0data::Px, + v0data::Py, + v0data::Pz, + v0data::Pt, + v0data::P, + v0data::Phi, + v0data::Eta, v0data::PtHypertriton, v0data::PtAntiHypertriton, v0data::V0Radius, - v0data::DistOverTotMom, + v0data::DistOverTotMom, v0data::Alpha, v0data::QtArm, v0data::PsiPair, @@ -803,11 +925,11 @@ DECLARE_SOA_TABLE_FULL(StoredV0fCCores, "V0fCCores", "AOD", "V0FCCORE", //! core v0data::M, // Longitudinal - v0data::YK0Short, - v0data::YLambda, + v0data::YK0Short, + v0data::YLambda, v0data::YHypertriton, v0data::YAntiHypertriton, - v0data::Rapidity, + v0data::Rapidity, v0data::NegativePt, v0data::PositivePt, v0data::NegativeEta, @@ -819,8 +941,8 @@ DECLARE_SOA_TABLE_FULL(StoredV0fCCores, "V0fCCores", "AOD", "V0FCCORE", //! core o2::soa::Marker<2>); // extended table with expression columns that can be used as arguments of dynamic columns -DECLARE_SOA_EXTENDED_TABLE_USER(V0fCCores, StoredV0fCCores, "V0FCCOREEXT", //! - v0data::Px, v0data::Py, v0data::Pz, v0data::Pt, v0data::P, v0data::Phi, v0data::Eta); // the table name has here to be the one with EXT which is not nice and under study +// DECLARE_SOA_EXTENDED_TABLE_USER(V0fCCores, StoredV0fCCores, "V0FCCOREEXT", //! +// v0data::Px, v0data::Py, v0data::Pz, v0data::Pt, v0data::P, v0data::Phi, v0data::Eta); // the table name has here to be the one with EXT which is not nice and under study DECLARE_SOA_TABLE_FULL(V0fCCovs, "V0fCCovs", "AOD", "V0FCCOVS", //! V0 covariance matrices v0data::PositionCovMat, v0data::MomentumCovMat, o2::soa::Marker<2>); @@ -890,6 +1012,9 @@ DECLARE_SOA_TABLE(GeAntiLambda, "AOD", "GeAntiLambda", v0data::GeneratedAntiLamb DECLARE_SOA_TABLE_STAGED(V0MCMothers, "V0MCMOTHER", //! optional table for MC mothers o2::soa::Index<>, v0data::MotherMCPartId); +using V0fCCores = StoredV0fCCores; +using V0Cores = V0CoresBase; + using V0MCCores = V0MCCores_002; using StoredV0MCCores = StoredV0MCCores_002; @@ -1152,13 +1277,20 @@ DECLARE_SOA_DYNAMIC_COLUMN(CascRadius, cascradius, //! // CosPAs DECLARE_SOA_DYNAMIC_COLUMN(V0CosPA, v0cosPA, //! - [](float Xlambda, float Ylambda, float Zlambda, float PxLambda, float PyLambda, float PzLambda, float pvX, float pvY, float pvZ) -> float { return RecoDecay::cpa(std::array{pvX, pvY, pvZ}, std::array{Xlambda, Ylambda, Zlambda}, std::array{PxLambda, PyLambda, PzLambda}); }); + [](float Xlambda, float Ylambda, float Zlambda, float pxPos, float pyPos, float pzPos, float pxNeg, float pyNeg, float pzNeg, float pvX, float pvY, float pvZ) -> float { + return RecoDecay::cpa(std::array{pvX, pvY, pvZ}, std::array{Xlambda, Ylambda, Zlambda}, std::array{pxPos + pxNeg, pyPos + pyNeg, pzPos + pzNeg}); + }); // DECLARE_SOA_DYNAMIC_COLUMN(CascCosPA, casccosPA, //! // [](float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) -> float { return RecoDecay::cpa(std::array{pvX, pvY, pvZ}, std::array{X, Y, Z}, std::array{Px, Py, Pz}); }); DECLARE_SOA_DYNAMIC_COLUMN(CascCosPA, casccosPA, //! [](float X, float Y, float Z, float PxBach, float PxPos, float PxNeg, float PyBach, float PyPos, float PyNeg, float PzBach, float PzPos, float PzNeg, float pvX, float pvY, float pvZ) -> float { return RecoDecay::cpa(std::array{pvX, pvY, pvZ}, std::array{X, Y, Z}, std::array{PxBach + PxPos + PxNeg, PyBach + PyPos + PyNeg, PzBach + PzPos + PzNeg}); }); DECLARE_SOA_DYNAMIC_COLUMN(DCAV0ToPV, dcav0topv, //! - [](float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) -> float { return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz)); }); + [](float X, float Y, float Z, float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg, float pvX, float pvY, float pvZ) -> float { + float px = pxpos + pxneg; + float py = pypos + pyneg; + float pz = pzpos + pzneg; + return std::sqrt((std::pow((pvY - Y) * pz - (pvZ - Z) * py, 2) + std::pow((pvX - X) * pz - (pvZ - Z) * px, 2) + std::pow((pvX - X) * py - (pvY - Y) * px, 2)) / (px * px + py * py + pz * pz)); + }); // Calculated on the fly with mass assumption + dynamic tables DECLARE_SOA_DYNAMIC_COLUMN(MLambda, mLambda, //! @@ -1221,42 +1353,22 @@ DECLARE_SOA_DYNAMIC_COLUMN(BachelorPtMC, bachelorptMC, //! bachelor daughter pT [](float pxBachMC, float pyBachMC) -> float { return RecoDecay::sqrtSumOfSquares(pxBachMC, pyBachMC); }); DECLARE_SOA_DYNAMIC_COLUMN(PtMC, ptMC, //! cascade pT [](float pxMC, float pyMC) -> float { return RecoDecay::sqrtSumOfSquares(pxMC, pyMC); }); -} // namespace cascdata -//______________________________________________________ -// EXPRESSION COLUMNS FOR TRACASCCORES -namespace cascdataext -{ -DECLARE_SOA_EXPRESSION_COLUMN(PxLambda, pxlambda, //! - float, 1.f * aod::cascdata::pxpos + 1.f * aod::cascdata::pxneg); -DECLARE_SOA_EXPRESSION_COLUMN(PyLambda, pylambda, //! - float, 1.f * aod::cascdata::pypos + 1.f * aod::cascdata::pyneg); -DECLARE_SOA_EXPRESSION_COLUMN(PzLambda, pzlambda, //! - float, 1.f * aod::cascdata::pzpos + 1.f * aod::cascdata::pzneg); -DECLARE_SOA_EXPRESSION_COLUMN(Pt, pt, float, //! Transverse momentum in GeV/c - nsqrt(aod::cascdata::px* aod::cascdata::px + - aod::cascdata::py * aod::cascdata::py)); -DECLARE_SOA_EXPRESSION_COLUMN(P, p, float, //! Total momentum in GeV/c - nsqrt(aod::cascdata::px* aod::cascdata::px + - aod::cascdata::py * aod::cascdata::py + - aod::cascdata::pz * aod::cascdata::pz)); -DECLARE_SOA_EXPRESSION_COLUMN(Phi, phi, float, //! Phi in the range [0, 2pi) - o2::constants::math::PI + natan2(-1.0f * aod::cascdata::py, -1.0f * aod::cascdata::px)); -DECLARE_SOA_EXPRESSION_COLUMN(Eta, eta, float, //! Pseudorapidity, conditionally defined to avoid FPEs - ifnode((nsqrt(aod::cascdata::px * aod::cascdata::px + - aod::cascdata::py * aod::cascdata::py + - aod::cascdata::pz * aod::cascdata::pz) - - aod::cascdata::pz) < static_cast(1e-7), - ifnode(aod::cascdata::pz < 0.f, -100.f, 100.f), - 0.5f * nlog((nsqrt(aod::cascdata::px * aod::cascdata::px + - aod::cascdata::py * aod::cascdata::py + - aod::cascdata::pz * aod::cascdata::pz) + - aod::cascdata::pz) / - (nsqrt(aod::cascdata::px * aod::cascdata::px + - aod::cascdata::py * aod::cascdata::py + - aod::cascdata::pz * aod::cascdata::pz) - - aod::cascdata::pz)))); -} // namespace cascdataext +DECLARE_SOA_DYNAMIC_COLUMN(PxLambda, pxlambda, //! Lambda daughter px + [](float pxPos, float pxNeg) -> float { return pxPos + pxNeg; }); +DECLARE_SOA_DYNAMIC_COLUMN(PyLambda, pylambda, //! Lambda daughter py + [](float pyPos, float pyNeg) -> float { return pyPos + pyNeg; }); +DECLARE_SOA_DYNAMIC_COLUMN(PzLambda, pzlambda, //! Lambda daughter pz + [](float pzPos, float pzNeg) -> float { return pzPos + pzNeg; }); +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! Cascade transverse momentum in GeV/c + [](float px, float py) -> float { return RecoDecay::sqrtSumOfSquares(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! Cascade total momentum in GeV/c + [](float px, float py, float pz) -> float { return RecoDecay::sqrtSumOfSquares(px, py, pz); }); +DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, //! Cascade phi in the range [0, 2pi) + [](float px, float py) -> float { return RecoDecay::phi(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, //! Cascade pseudorapidity + [](float px, float py, float pz) -> float { return RecoDecay::eta(std::array{px, py, pz}); }); +} // namespace cascdata //______________________________________________________ // Cascade data model: @@ -1302,11 +1414,18 @@ DECLARE_SOA_TABLE(StoredCascCores, "AOD", "CASCCORE", //! core information about cascdata::DCAPosToPV, cascdata::DCANegToPV, cascdata::DCABachToPV, cascdata::DCAXYCascToPV, cascdata::DCAZCascToPV, // Dynamic columns + cascdata::PxLambda, + cascdata::PyLambda, + cascdata::PzLambda, + cascdata::Pt, + cascdata::P, + cascdata::Phi, + cascdata::Eta, cascdata::V0Radius, cascdata::CascRadius, - cascdata::V0CosPA, + cascdata::V0CosPA, cascdata::CascCosPA, - cascdata::DCAV0ToPV, + cascdata::DCAV0ToPV, // Invariant masses cascdata::MLambda, @@ -1345,11 +1464,18 @@ DECLARE_SOA_TABLE(StoredKFCascCores, "AOD", "KFCASCCORE", //! kfcascdata::MLambda, cascdata::KFV0Chi2, cascdata::KFCascadeChi2, // Dynamic columns + cascdata::PxLambda, + cascdata::PyLambda, + cascdata::PzLambda, + cascdata::Pt, + cascdata::P, + cascdata::Phi, + cascdata::Eta, cascdata::V0Radius, cascdata::CascRadius, - cascdata::V0CosPA, + cascdata::V0CosPA, cascdata::CascCosPA, - cascdata::DCAV0ToPV, + cascdata::DCAV0ToPV, // Invariant masses cascdata::M, @@ -1383,11 +1509,18 @@ DECLARE_SOA_TABLE(StoredTraCascCores, "AOD", "TRACASCCORE", //! cascdata::MatchingChi2, cascdata::TopologyChi2, cascdata::ItsClsSize, // Dynamic columns + cascdata::PxLambda, + cascdata::PyLambda, + cascdata::PzLambda, + cascdata::Pt, + cascdata::P, + cascdata::Phi, + cascdata::Eta, cascdata::V0Radius, cascdata::CascRadius, - cascdata::V0CosPA, + cascdata::V0CosPA, cascdata::CascCosPA, - cascdata::DCAV0ToPV, + cascdata::DCAV0ToPV, // Invariant masses cascdata::MLambda, @@ -1457,19 +1590,9 @@ DECLARE_SOA_TABLE(TraCascCovs, "AOD", "TRACASCCOVS", //! cascdata::MomentumCovMat, o2::soa::Marker<2>); -// extended table with expression columns that can be used as arguments of dynamic columns -DECLARE_SOA_EXTENDED_TABLE_USER(CascCores, StoredCascCores, "CascDATAEXT", //! - cascdataext::PxLambda, cascdataext::PyLambda, cascdataext::PzLambda, cascdataext::Pt, cascdataext::P, cascdataext::Eta, cascdataext::Phi); - -// extended table with expression columns that can be used as arguments of dynamic columns -DECLARE_SOA_EXTENDED_TABLE_USER(KFCascCores, StoredKFCascCores, "KFCascDATAEXT", //! - cascdataext::PxLambda, cascdataext::PyLambda, cascdataext::PzLambda, - cascdataext::Pt, cascdataext::P, cascdataext::Eta, cascdataext::Phi); - -// extended table with expression columns that can be used as arguments of dynamic columns -DECLARE_SOA_EXTENDED_TABLE_USER(TraCascCores, StoredTraCascCores, "TraCascDATAEXT", //! - cascdataext::PxLambda, cascdataext::PyLambda, cascdataext::PzLambda, - cascdataext::Pt, cascdataext::P, cascdataext::Eta, cascdataext::Phi); +using CascCores = StoredCascCores; +using KFCascCores = StoredKFCascCores; +using TraCascCores = StoredTraCascCores; namespace cascdata { @@ -1651,6 +1774,38 @@ DECLARE_SOA_TABLE(Tracked3BodyColls, "AOD", "TRA3BODYCOLL", //! Table joinable w using Tracked3BodyColl = Tracked3BodyColls::iterator; using AssignedTracked3Bodys = soa::Join; using AssignedTracked3Body = AssignedTracked3Bodys::iterator; + +namespace zdcneutrons +{ +// FOR DERIVED +DECLARE_SOA_INDEX_COLUMN(StraMCCollision, straMCCollision); //! +// DYNAMIC COLUMNS +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! neutron transverse momentum (GeV/c) + [](float px, float py) -> float { return RecoDecay::sqrtSumOfSquares(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! neutron total momentum (GeV/c) + [](float px, float py, float pz) -> float { return RecoDecay::sqrtSumOfSquares(px, py, pz); }); +DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, //! neutron phi in the range [0, 2pi) + [](float px, float py) -> float { return RecoDecay::phi(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, //! neutron pseudorapidity + [](float px, float py, float pz) -> float { return RecoDecay::eta(std::array{px, py, pz}); }); +DECLARE_SOA_DYNAMIC_COLUMN(Y, y, //! neutron rapidity + [](float pz, float e) -> float { return std::atanh(pz / e); }); +} // namespace zdcneutrons + +DECLARE_SOA_TABLE(ZDCNeutrons, "AOD", "ZDCNEUTRON", //! MC properties of the neutrons within ZDC acceptance (for UPC analysis) + mcparticle::PdgCode, mcparticle::StatusCode, mcparticle::Flags, + mcparticle::Vx, mcparticle::Vy, mcparticle::Vz, mcparticle::Vt, + mcparticle::Px, mcparticle::Py, mcparticle::Pz, mcparticle::E, + // Dynamic columns for manipulating information + zdcneutrons::Pt, + zdcneutrons::P, + zdcneutrons::Phi, + zdcneutrons::Eta, + zdcneutrons::Y); + +DECLARE_SOA_TABLE(ZDCNMCCollRefs, "AOD", "ZDCNMCCOLLREF", //! refers MC candidate back to proper MC Collision + o2::soa::Index<>, zdcneutrons::StraMCCollisionId, o2::soa::Marker<4>); + } // namespace o2::aod //______________________________________________________ diff --git a/PWGLF/DataModel/LFhe3HadronTables.h b/PWGLF/DataModel/LFhe3HadronTables.h index 9074fb8b20c..07ce17853ea 100644 --- a/PWGLF/DataModel/LFhe3HadronTables.h +++ b/PWGLF/DataModel/LFhe3HadronTables.h @@ -36,6 +36,7 @@ DECLARE_SOA_COLUMN(DCAxyHe3, dcaxyHe3, float); DECLARE_SOA_COLUMN(DCAzHe3, dcazHe3, float); DECLARE_SOA_COLUMN(DCAxyHad, dcaxyHad, float); DECLARE_SOA_COLUMN(DCAzHad, dcazHad, float); +DECLARE_SOA_COLUMN(DCApair, dcapair, float); DECLARE_SOA_COLUMN(SignalTPCHe3, signalTPCHe3, float); DECLARE_SOA_COLUMN(InnerParamTPCHe3, innerParamTPCHe3, float); @@ -75,6 +76,13 @@ DECLARE_SOA_COLUMN(Multiplicity, multiplicity, uint16_t); DECLARE_SOA_COLUMN(CentralityFT0C, centFT0C, float); DECLARE_SOA_COLUMN(MultiplicityFT0C, multiplicityFT0C, float); +/* Flags: 0 - both primary, + 1 - both from Li4, + 2 - both from hypertriton, + 3 - mixed pair (a primary and one from Li4/hypertriton/material/other decays or any other combination) +*/ +DECLARE_SOA_COLUMN(Flags, flags, uint8_t); + } // namespace he3HadronTablesNS DECLARE_SOA_TABLE(he3HadronTable, "AOD", "HE3HADTABLE", @@ -88,6 +96,7 @@ DECLARE_SOA_TABLE(he3HadronTable, "AOD", "HE3HADTABLE", he3HadronTablesNS::DCAzHe3, he3HadronTablesNS::DCAxyHad, he3HadronTablesNS::DCAzHad, + he3HadronTablesNS::DCApair, he3HadronTablesNS::SignalTPCHe3, he3HadronTablesNS::InnerParamTPCHe3, he3HadronTablesNS::SignalTPCHad, @@ -115,7 +124,8 @@ DECLARE_SOA_TABLE(he3HadronTableMC, "AOD", "HE3HADTABLEMC", he3HadronTablesNS::EtaMCHad, he3HadronTablesNS::PhiMCHad, he3HadronTablesNS::SignedPtMC, - he3HadronTablesNS::MassMC) + he3HadronTablesNS::MassMC, + he3HadronTablesNS::Flags) DECLARE_SOA_TABLE(he3HadronMult, "AOD", "HE3HADMULT", he3HadronTablesNS::CollisionId, he3HadronTablesNS::ZVertex, diff --git a/PWGLF/DataModel/Reduced3BodyTables.h b/PWGLF/DataModel/Reduced3BodyTables.h new file mode 100644 index 00000000000..3b221d17539 --- /dev/null +++ b/PWGLF/DataModel/Reduced3BodyTables.h @@ -0,0 +1,144 @@ +// 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. + +/// \file Reduced3BodyTables.h +/// \brief Definitions of tables for reduced data of 3body decayed hypertriton analysis +/// \author Carolina Reetz +/// \author Yuanzhe Wang + +#ifndef PWGLF_DATAMODEL_REDUCED3BODYTABLES_H_ +#define PWGLF_DATAMODEL_REDUCED3BODYTABLES_H_ + +#include +#include "Framework/AnalysisDataModel.h" +#include "Common/Core/RecoDecay.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "PWGLF/DataModel/Vtx3BodyTables.h" + +namespace o2::aod +{ + +DECLARE_SOA_TABLE(RedCollisions, "AOD", "REDCOLLISION", //! reduced collision table (same structure as the original collision table) + o2::soa::Index<>, + collision::PosX, collision::PosY, collision::PosZ, + collision::CovXX, collision::CovXY, collision::CovYY, collision::CovXZ, collision::CovYZ, collision::CovZZ, + collision::Flags, collision::Chi2, collision::NumContrib, + collision::CollisionTime, collision::CollisionTimeRes, + bc::RunNumber); + +DECLARE_SOA_TABLE(RedPVMults, "AOD", "REDPVMULT", //! Multiplicity from the PV contributors, joinable with reducedCollisions + mult::MultNTracksPV); + +DECLARE_SOA_TABLE(RedCentFT0Cs, "AOD", "REDCENTFT0C", //! Reduced Run 3 FT0C centrality table, joinable with reducedCollisions + cent::CentFT0C); + +namespace reducedtracks3body +{ +// track parameter definition +DECLARE_SOA_INDEX_COLUMN_FULL(Collision, collision, int, RedCollisions, ""); //! Collision index + +// track PID definition +DECLARE_SOA_COLUMN(TPCNSigmaPr, tpcNSigmaPr, float); //! Nsigma separation with the TPC detector for proton +DECLARE_SOA_COLUMN(TPCNSigmaDe, tpcNSigmaDe, float); //! Nsigma separation with the TPC detector for deuteron +DECLARE_SOA_COLUMN(TPCNSigmaPi, tpcNSigmaPi, float); //! Nsigma separation with the TPC detector for pion +DECLARE_SOA_COLUMN(TOFNSigmaDe, tofNSigmaDe, float); //! Nsigma separation with the TOF detector for deuteron (recalculated) + +} // namespace reducedtracks3body + +DECLARE_SOA_TABLE_FULL(StoredRedIUTracks, "RedIUTracks", "AOD", "REDIUTRACK", //! On disk version of the track parameters at inner most update (e.g. ITS) as it comes from the tracking + o2::soa::Index<>, reducedtracks3body::CollisionId, + track::X, track::Alpha, + track::Y, track::Z, track::Snp, track::Tgl, + track::Signed1Pt, + // cov matrix + track::SigmaY, track::SigmaZ, track::SigmaSnp, track::SigmaTgl, track::Sigma1Pt, + track::RhoZY, track::RhoSnpY, track::RhoSnpZ, track::RhoTglY, track::RhoTglZ, + track::RhoTglSnp, track::Rho1PtY, track::Rho1PtZ, track::Rho1PtSnp, track::Rho1PtTgl, + // tracks extra + track::TPCInnerParam, track::Flags, track::ITSClusterSizes, + track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, + track::TRDPattern, track::TPCChi2NCl, track::TOFChi2, + track::TPCSignal, track::TOFExpMom, + // TPC PID + reducedtracks3body::TPCNSigmaPr, reducedtracks3body::TPCNSigmaPi, reducedtracks3body::TPCNSigmaDe, + reducedtracks3body::TOFNSigmaDe, + + // ----------- dynmaic columns ------------ + // tracks IU + track::Px, + track::Py, + track::Pz, + track::Rapidity, + track::Sign, + // tracks extra + track::PIDForTracking, + track::IsPVContributor, + track::HasITS, + track::HasTPC, + track::HasTOF, + track::HasTRD, + track::TPCNClsFound, + track::TPCNClsCrossedRows, + track::v001::ITSClsSizeInLayer, + track::TPCCrossedRowsOverFindableCls); + +DECLARE_SOA_EXTENDED_TABLE_USER(RedIUTracks, StoredRedIUTracks, "REDIUTRACKEXT", //! Track parameters at inner most update (e.g. ITS) as it comes from the tracking + track::Pt, + track::P, + track::Eta, + track::Phi, + // cov matrix + track::CYY, + track::CZY, + track::CZZ, + track::CSnpY, + track::CSnpZ, + track::CSnpSnp, + track::CTglY, + track::CTglZ, + track::CTglSnp, + track::CTglTgl, + track::C1PtY, + track::C1PtZ, + track::C1PtSnp, + track::C1PtTgl, + track::C1Pt21Pt2, + // tracks extra + track::v001::DetectorMap); + +namespace reduceddecay3body +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Track0, track0, int, RedIUTracks, "_0"); //! Track 0 index +DECLARE_SOA_INDEX_COLUMN_FULL(Track1, track1, int, RedIUTracks, "_1"); //! Track 1 index +DECLARE_SOA_INDEX_COLUMN_FULL(Track2, track2, int, RedIUTracks, "_2"); //! Track 2 index +DECLARE_SOA_INDEX_COLUMN_FULL(Collision, collision, int, RedCollisions, ""); //! Collision index +DECLARE_SOA_COLUMN(RadiusKF, radiusKF, float); //! phi of momentum of mother particle calculated by KF +DECLARE_SOA_COLUMN(PhiKF, phiKF, float); //! SV radius in x-y plane calculated by KF +DECLARE_SOA_COLUMN(PosZKF, poszKF, float); //! z position of SV calculated by KF +DECLARE_SOA_COLUMN(RadiusDCA, radiusDCA, float); //! phi of momentum of mother particle calculated by dcaFitter +DECLARE_SOA_COLUMN(PhiDCA, phiDCA, float); //! SV radius in x-y plane calculated by dcaFitter +DECLARE_SOA_COLUMN(PosZDCA, poszDCA, float); //! z position of SV calculated by dcaFitter +DECLARE_SOA_COLUMN(TrackedClSize, trackedClSize, float); //! average ITS cluster size (if tracked) +} // namespace reduceddecay3body + +DECLARE_SOA_TABLE(RedDecay3Bodys, "AOD", "REDDECAY3BODY", //! reduced 3-body decay table + o2::soa::Index<>, reduceddecay3body::CollisionId, reduceddecay3body::Track0Id, reduceddecay3body::Track1Id, reduceddecay3body::Track2Id); + +DECLARE_SOA_TABLE(Red3BodyInfo, "AOD", "RED3BODYINFO", //! joinable with RedDecay3Bodys + reduceddecay3body::RadiusKF, reduceddecay3body::PhiKF, reduceddecay3body::PosZKF, + reduceddecay3body::RadiusDCA, reduceddecay3body::PhiDCA, reduceddecay3body::PosZDCA, + reduceddecay3body::TrackedClSize); + +} // namespace o2::aod + +#endif // PWGLF_DATAMODEL_REDUCED3BODYTABLES_H_ diff --git a/PWGLF/DataModel/ReducedHeptaQuarkTables.h b/PWGLF/DataModel/ReducedHeptaQuarkTables.h new file mode 100644 index 00000000000..a8dd487fe9c --- /dev/null +++ b/PWGLF/DataModel/ReducedHeptaQuarkTables.h @@ -0,0 +1,101 @@ +// 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 Junlee Kim + +#ifndef PWGLF_DATAMODEL_REDUCEDHEPTAQUARKTABLES_H_ +#define PWGLF_DATAMODEL_REDUCEDHEPTAQUARKTABLES_H_ + +#include + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" + +namespace o2::aod +{ +namespace redhqevent +{ +DECLARE_SOA_COLUMN(NumPhi, numPhi, int); //! Number of negative K +DECLARE_SOA_COLUMN(NumLambda, numLambda, int); //! Number of lambda +DECLARE_SOA_COLUMN(Centrality, centrality, float); //! +} // namespace redhqevent +DECLARE_SOA_TABLE(RedHQEvents, "AOD", "REDHQEVENT", + o2::soa::Index<>, + bc::GlobalBC, + bc::RunNumber, + timestamp::Timestamp, + collision::PosZ, + collision::NumContrib, + redhqevent::Centrality, + redhqevent::NumPhi, + redhqevent::NumLambda); +using RedHQEvent = RedHQEvents::iterator; + +namespace hqtrack +{ +DECLARE_SOA_INDEX_COLUMN(RedHQEvent, redHQEvent); +DECLARE_SOA_COLUMN(HQId, hqId, int); //! HQ ID +DECLARE_SOA_COLUMN(HQPx, hqPx, float); //! HQ Px +DECLARE_SOA_COLUMN(HQPy, hqPy, float); //! HQ Py +DECLARE_SOA_COLUMN(HQPz, hqPz, float); //! HQ Pz +DECLARE_SOA_COLUMN(HQd1Px, hqd1Px, float); //! HQ d1 Px +DECLARE_SOA_COLUMN(HQd1Py, hqd1Py, float); //! HQ d1 Py +DECLARE_SOA_COLUMN(HQd1Pz, hqd1Pz, float); //! HQ d1 Pz +DECLARE_SOA_COLUMN(HQd2Px, hqd2Px, float); //! HQ d2 Px +DECLARE_SOA_COLUMN(HQd2Py, hqd2Py, float); //! HQ d2 Py +DECLARE_SOA_COLUMN(HQd2Pz, hqd2Pz, float); //! HQ d2 Pz +DECLARE_SOA_COLUMN(HQMass, hqMass, float); //! HQ Mass +DECLARE_SOA_COLUMN(HQd1Index, hqd1Index, int64_t); //! HQ d1 index +DECLARE_SOA_COLUMN(HQd2Index, hqd2Index, int64_t); //! HQ d2 index +DECLARE_SOA_COLUMN(HQd1Charge, hqd1Charge, float); //! HQ d1 charge +DECLARE_SOA_COLUMN(HQd2Charge, hqd2Charge, float); //! HQ d1 charge +DECLARE_SOA_COLUMN(HQd1TPC, hqd1TPC, float); //! TPC nsigma d1 +DECLARE_SOA_COLUMN(HQd2TPC, hqd2TPC, float); //! TPC nsigma d2 +DECLARE_SOA_COLUMN(HQd1TOFHit, hqd1TOFHit, int); //! TOF hit d1 +DECLARE_SOA_COLUMN(HQd2TOFHit, hqd2TOFHit, int); //! TOF hit d2 +DECLARE_SOA_COLUMN(HQd1TOF, hqd1TOF, float); //! TOF nsigma d1 +DECLARE_SOA_COLUMN(HQd2TOF, hqd2TOF, float); //! TOF nsigma d2 + +} // namespace hqtrack +DECLARE_SOA_TABLE(HQTracks, "AOD", "HQTRACK", + o2::soa::Index<>, + hqtrack::RedHQEventId, + hqtrack::HQId, + hqtrack::HQPx, + hqtrack::HQPy, + hqtrack::HQPz, + hqtrack::HQd1Px, + hqtrack::HQd1Py, + hqtrack::HQd1Pz, + hqtrack::HQd2Px, + hqtrack::HQd2Py, + hqtrack::HQd2Pz, + hqtrack::HQMass, + hqtrack::HQd1Index, + hqtrack::HQd2Index, + hqtrack::HQd1Charge, + hqtrack::HQd2Charge, + hqtrack::HQd1TPC, + hqtrack::HQd2TPC, + hqtrack::HQd1TOFHit, + hqtrack::HQd2TOFHit, + hqtrack::HQd1TOF, + hqtrack::HQd2TOF); + +using HQTrack = HQTracks::iterator; +} // namespace o2::aod +#endif // PWGLF_DATAMODEL_REDUCEDHEPTAQUARKTABLES_H_ diff --git a/PWGLF/DataModel/ReducedLambdaLambdaTables.h b/PWGLF/DataModel/ReducedLambdaLambdaTables.h new file mode 100644 index 00000000000..88ea8fb0530 --- /dev/null +++ b/PWGLF/DataModel/ReducedLambdaLambdaTables.h @@ -0,0 +1,81 @@ +// 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 Junlee Kim + +#ifndef PWGLF_DATAMODEL_REDUCEDLAMBDALAMBDATABLES_H_ +#define PWGLF_DATAMODEL_REDUCEDLAMBDALAMBDATABLES_H_ + +#include + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" + +namespace o2::aod +{ +namespace redllevent +{ +DECLARE_SOA_COLUMN(NumLambda, numLambda, int); //! Number of lambda +DECLARE_SOA_COLUMN(Centrality, centrality, float); //! +} // namespace redllevent +DECLARE_SOA_TABLE(RedLLEvents, "AOD", "REDLLEVENT", + o2::soa::Index<>, + bc::GlobalBC, + bc::RunNumber, + timestamp::Timestamp, + collision::PosZ, + collision::NumContrib, + redllevent::Centrality, + redllevent::NumLambda); +using RedLLEvent = RedLLEvents::iterator; + +namespace lltrack +{ +DECLARE_SOA_INDEX_COLUMN(RedLLEvent, redLLEvent); +DECLARE_SOA_COLUMN(LLdId, lldId, int); //! LL PID +DECLARE_SOA_COLUMN(LLdPx, lldPx, float); //! LL d Px +DECLARE_SOA_COLUMN(LLdPy, lldPy, float); //! LL d Py +DECLARE_SOA_COLUMN(LLdPz, lldPz, float); //! LL d Pz +DECLARE_SOA_COLUMN(LLdx, lldx, float); //! LL d x +DECLARE_SOA_COLUMN(LLdy, lldy, float); //! LL d y +DECLARE_SOA_COLUMN(LLdz, lldz, float); //! LL d z +DECLARE_SOA_COLUMN(LLdMass, lldMass, float); //! LL d Mass +DECLARE_SOA_COLUMN(LLdd1TPC, lldd1TPC, float); //! LL dd1 TPC nsigma +DECLARE_SOA_COLUMN(LLdd2TPC, lldd2TPC, float); //! LL dd2 TPC nsigma +DECLARE_SOA_COLUMN(LLdd1Index, lldd1Index, int64_t); //! LL dd1 global index +DECLARE_SOA_COLUMN(LLdd2Index, lldd2Index, int64_t); //! LL dd2 global index + +} // namespace lltrack +DECLARE_SOA_TABLE(LLTracks, "AOD", "LLTRACK", + o2::soa::Index<>, + lltrack::RedLLEventId, + lltrack::LLdId, + lltrack::LLdPx, + lltrack::LLdPy, + lltrack::LLdPz, + lltrack::LLdx, + lltrack::LLdy, + lltrack::LLdz, + lltrack::LLdMass, + lltrack::LLdd1TPC, + lltrack::LLdd2TPC, + lltrack::LLdd1Index, + lltrack::LLdd2Index); + +using LLTrack = LLTracks::iterator; +} // namespace o2::aod +#endif // PWGLF_DATAMODEL_REDUCEDLAMBDALAMBDATABLES_H_ diff --git a/PWGLF/DataModel/Vtx3BodyTables.h b/PWGLF/DataModel/Vtx3BodyTables.h index 51e155206bd..55bdea60789 100644 --- a/PWGLF/DataModel/Vtx3BodyTables.h +++ b/PWGLF/DataModel/Vtx3BodyTables.h @@ -9,60 +9,143 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file Vtx3BodyTables.h +/// \brief Definitions of analysis tables for 3body decayed hypertriton +/// \author Yuanzhe Wang +/// \author Carolina Reetz + #ifndef PWGLF_DATAMODEL_VTX3BODYTABLES_H_ #define PWGLF_DATAMODEL_VTX3BODYTABLES_H_ -#include -#include "Framework/AnalysisDataModel.h" #include "Common/Core/RecoDecay.h" + #include "CommonConstants/PhysicsConstants.h" +#include "Framework/AnalysisDataModel.h" + +#include namespace o2::aod { namespace vtx3body { -DECLARE_SOA_INDEX_COLUMN_FULL(Track0, track0, int, Tracks, "_0"); //! -DECLARE_SOA_INDEX_COLUMN_FULL(Track1, track1, int, Tracks, "_1"); //! -DECLARE_SOA_INDEX_COLUMN_FULL(Track2, track2, int, Tracks, "_2"); //! -DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! -DECLARE_SOA_INDEX_COLUMN(Decay3Body, decay3body); //! - -// General 3 body Vtx properties: position, momentum -DECLARE_SOA_COLUMN(PxTrack0, pxtrack0, float); //! track0 px at min -DECLARE_SOA_COLUMN(PyTrack0, pytrack0, float); //! track0 py at min -DECLARE_SOA_COLUMN(PzTrack0, pztrack0, float); //! track0 pz at min -DECLARE_SOA_COLUMN(PxTrack1, pxtrack1, float); //! track1 px at min -DECLARE_SOA_COLUMN(PyTrack1, pytrack1, float); //! track1 py at min -DECLARE_SOA_COLUMN(PzTrack1, pztrack1, float); //! track1 pz at min -DECLARE_SOA_COLUMN(PxTrack2, pxtrack2, float); //! track2 px at min -DECLARE_SOA_COLUMN(PyTrack2, pytrack2, float); //! track2 py at min -DECLARE_SOA_COLUMN(PzTrack2, pztrack2, float); //! track2 pz at min -DECLARE_SOA_COLUMN(X, x, float); //! decay position X -DECLARE_SOA_COLUMN(Y, y, float); //! decay position Y -DECLARE_SOA_COLUMN(Z, z, float); //! decay position Z - -// Saved from finding: DCAs -DECLARE_SOA_COLUMN(DCAVtxDaughters, dcaVtxdaughters, float); //! DCA among daughters -DECLARE_SOA_COLUMN(DCAXYTrack0ToPV, dcaXYtrack0topv, float); //! DCAXY of prong0 to PV -DECLARE_SOA_COLUMN(DCAXYTrack1ToPV, dcaXYtrack1topv, float); //! DCAXY of prong1 to PV -DECLARE_SOA_COLUMN(DCAXYTrack2ToPV, dcaXYtrack2topv, float); //! DCAXY of prong2 to PV -DECLARE_SOA_COLUMN(DCATrack0ToPV, dcatrack0topv, float); //! DCA of prong0 to PV -DECLARE_SOA_COLUMN(DCATrack1ToPV, dcatrack1topv, float); //! DCA of prong1 to PV -DECLARE_SOA_COLUMN(DCATrack2ToPV, dcatrack2topv, float); //! DCA of prong2 to PV - -// Recalculated TOF PID information of bachelor -DECLARE_SOA_COLUMN(TOFNSigmaBachDe, tofNSigmaBachDe, float); //! Recalculated Nsigma seperation with TOF for deuteron +// indices +DECLARE_SOA_INDEX_COLUMN_FULL(TrackPr, trackPr, int, Tracks, "_pr"); //! +DECLARE_SOA_INDEX_COLUMN_FULL(TrackPi, trackPi, int, Tracks, "_pi"); //! +DECLARE_SOA_INDEX_COLUMN_FULL(TrackDe, trackDe, int, Tracks, "_de"); //! +DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! +DECLARE_SOA_INDEX_COLUMN(Decay3Body, decay3body); //! + +// General 3 body Vtx properties +DECLARE_SOA_COLUMN(Mass, mass, float); //! candidate mass (with H3L or Anti-H3L mass hypothesis depending on deuteron charge) +DECLARE_SOA_COLUMN(Sign, sign, float); //! candidate sign +DECLARE_SOA_COLUMN(X, x, float); //! decay position X +DECLARE_SOA_COLUMN(Y, y, float); //! decay position Y +DECLARE_SOA_COLUMN(Z, z, float); //! decay position Z +DECLARE_SOA_COLUMN(Px, px, float); //! momentum X +DECLARE_SOA_COLUMN(Py, py, float); //! momentum Y +DECLARE_SOA_COLUMN(Pz, pz, float); //! momentum Z +DECLARE_SOA_COLUMN(Chi2, chi2, float); //! KFParticle: chi2geo/ndf or chi2topo/ndf of vertex fit, DCA fitter: Chi2AtPCACandidate value + +// daughter properties +DECLARE_SOA_COLUMN(MassV0, massV0, float); //! V0 mass (with H3L or Anti-H3L mass hypothesis depending on deuteron charge) +DECLARE_SOA_COLUMN(PxTrackPr, pxTrackPr, float); //! track0 px at min +DECLARE_SOA_COLUMN(PyTrackPr, pyTrackPr, float); //! track0 py at min +DECLARE_SOA_COLUMN(PzTrackPr, pzTrackPr, float); //! track0 pz at min +DECLARE_SOA_COLUMN(PxTrackPi, pxTrackPi, float); //! track1 px at min +DECLARE_SOA_COLUMN(PyTrackPi, pyTrackPi, float); //! track1 py at min +DECLARE_SOA_COLUMN(PzTrackPi, pzTrackPi, float); //! track1 pz at min +DECLARE_SOA_COLUMN(PxTrackDe, pxTrackDe, float); //! track2 px at min +DECLARE_SOA_COLUMN(PyTrackDe, pyTrackDe, float); //! track2 py at min +DECLARE_SOA_COLUMN(PzTrackDe, pzTrackDe, float); //! track2 pz at min + +// DCAs to PV +DECLARE_SOA_COLUMN(DCAXYTrackPrToPV, dcaXYtrackPrToPv, float); //! DCAXY of proton to PV +DECLARE_SOA_COLUMN(DCAXYTrackPiToPV, dcaXYtrackPiToPv, float); //! DCAXY of pion to PV +DECLARE_SOA_COLUMN(DCAXYTrackDeToPV, dcaXYtrackDeToPv, float); //! DCAXY of deuteron to PV +DECLARE_SOA_COLUMN(DCAZTrackPrToPV, dcaZtrackPrToPv, float); //! DCAZ of proton to PV +DECLARE_SOA_COLUMN(DCAZTrackPiToPV, dcaZtrackPiToPv, float); //! DCAZ of pion to PV +DECLARE_SOA_COLUMN(DCAZTrackDeToPV, dcaZtrackDeToPv, float); //! DCAZ of deuteron to PV + +// DCAs to SV +DECLARE_SOA_COLUMN(DCATrackPrToSV, dcaTrackPrToSv, float); //! DCA of proton to SV +DECLARE_SOA_COLUMN(DCATrackPiToSV, dcaTrackPiToSv, float); //! DCA of pion to SV +DECLARE_SOA_COLUMN(DCATrackDeToSV, dcaTrackDeToSv, float); //! DCA of deuteron to SV +DECLARE_SOA_COLUMN(DCAVtxToDaughtersAv, dcaVtxToDaughtersAv, float); //! Quadratic sum of DCA between daughters at SV + +// CosPA +DECLARE_SOA_COLUMN(CosPA, cosPA, float); //! Cosine of pointing angle of the 3body candidate + +// Ct +DECLARE_SOA_COLUMN(Ct, ct, float); //! Reconstruction Ct of 3body candidate + +// Strangeness tracking +DECLARE_SOA_COLUMN(TrackedClSize, trackedClSize, float); //! Average ITS cluster size of strangeness tracked 3body + +// PID +DECLARE_SOA_COLUMN(TPCNSigmaPr, tpcNSigmaPr, float); //! nsigma proton of TPC PID of the proton daughter +DECLARE_SOA_COLUMN(TPCNSigmaPi, tpcNSigmaPi, float); //! nsigma pion of TPC PID of the pion daughter +DECLARE_SOA_COLUMN(TPCNSigmaDe, tpcNSigmaDe, float); //! nsigma deuteron of TPC PID of the bachelor daughter +DECLARE_SOA_COLUMN(TPCNSigmaPiBach, tpcNSigmaPiBach, float); //! nsigma pion of TPC PID of the bachelor daughter +DECLARE_SOA_COLUMN(TOFNSigmaDe, tofNSigmaDe, float); //! nsigma deuteron of TOF PID of the bachelor daughter +DECLARE_SOA_COLUMN(PIDTrackingDe, pidTrackingDe, uint32_t); //! PID during tracking of bachelor daughter + +// Daughter track quality +DECLARE_SOA_COLUMN(TPCNClTrackPr, tpcNClTrackPr, int); //! Number of TPC clusters of proton daughter +DECLARE_SOA_COLUMN(TPCNClTrackPi, tpcNClTrackPi, int); //! Number of TPC clusters of pion daughter +DECLARE_SOA_COLUMN(TPCNClTrackDe, tpcNClTrackDe, int); //! Number of TPC clusters of deuteron daughter +DECLARE_SOA_COLUMN(ITSClSizePr, itsClsizePr, double); //! average ITS cluster size of proton daughter +DECLARE_SOA_COLUMN(ITSClSizePi, itsClsizePi, double); //! average ITS cluster size of pion daughter +DECLARE_SOA_COLUMN(ITSClSizeDe, itsClsizeDe, double); //! average ITS cluster size of deuteron daughter + +// Covariance matrices +DECLARE_SOA_COLUMN(CovProton, covProton, float[21]); //! covariance matrix elements of proton daughter track +DECLARE_SOA_COLUMN(CovPion, covPion, float[21]); //! covariance matrix elements of pion daughter track +DECLARE_SOA_COLUMN(CovDeuteron, covDeuteron, float[21]); //! covariance matrix elements of deuteron daughter track +DECLARE_SOA_COLUMN(VtxCovMat, vtxCovMat, float[21]); //! covariance matrix elements of candidate + +// Monte Carlo info +DECLARE_SOA_COLUMN(GenPx, genPx, float); // generated Px of the hypertriton in GeV/c +DECLARE_SOA_COLUMN(GenPy, genPy, float); // generated Py of the hypertriton in GeV/c +DECLARE_SOA_COLUMN(GenPz, genPz, float); // generated Pz of the hypertriton in GeV/c +DECLARE_SOA_COLUMN(GenX, genX, float); // generated decay vtx position X of the hypertriton +DECLARE_SOA_COLUMN(GenY, genY, float); // generated decay vtx position Y of the hypertriton +DECLARE_SOA_COLUMN(GenZ, genZ, float); // generated decay vtx position Z of the hypertriton +DECLARE_SOA_COLUMN(GenCt, genCt, float); // generated Ct of the hypertriton +DECLARE_SOA_COLUMN(GenPhi, genPhi, float); // generated Phi of the hypertriton +DECLARE_SOA_COLUMN(GenEta, genEta, float); // Eta of the hypertriton +DECLARE_SOA_COLUMN(GenRap, genRap, float); // generated rapidity of the hypertriton +DECLARE_SOA_COLUMN(GenPPr, genPPr, float); //! generated momentum proton daughter particle +DECLARE_SOA_COLUMN(GenPPi, genPPi, float); //! generated momentum pion daughter particle +DECLARE_SOA_COLUMN(GenPDe, genPDe, float); //! generated momentum deuteron daughter particle +DECLARE_SOA_COLUMN(GenPtPr, genPtPr, float); //! generated transverse momentum proton daughter particle +DECLARE_SOA_COLUMN(GenPtPi, genPtPi, float); //! generated transverse momentum pion daughter particle +DECLARE_SOA_COLUMN(GenPtDe, genPtDe, float); //! generated transverse momentum deuteron daughter particle +DECLARE_SOA_COLUMN(IsTrueH3L, isTrueH3l, bool); //! flag for true hypertriton candidate +DECLARE_SOA_COLUMN(IsTrueAntiH3L, isTrueAntiH3l, bool); //! flag for true anti-hypertriton candidate +DECLARE_SOA_COLUMN(MotherPdgCode, motherPdgCode, int); //! PDG code of the mother particle +DECLARE_SOA_COLUMN(PrPdgCode, prPdgCode, int); //! MC particle proton PDG code +DECLARE_SOA_COLUMN(PiPdgCode, piPdgCode, int); //! MC particle pion PDG code +DECLARE_SOA_COLUMN(DePdgCode, dePdgCode, int); //! MC particle deuteron PDG code +DECLARE_SOA_COLUMN(IsDePrimary, isDePrimary, bool); //! flag for deuteron daughter primary +DECLARE_SOA_COLUMN(IsSurvEvSel, isSurvEvSel, int); //! flag if reco collision survived event selection +DECLARE_SOA_COLUMN(IsReco, isreco, int); //! flag if candidate was reconstructed // Derived expressions // Momenta -DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! 3 body p - [](float pxtrack0, float pytrack0, float pztrack0, float pxtrack1, float pytrack1, float pztrack1, float pxtrack2, float pytrack2, float pztrack2) -> float { return RecoDecay::sqrtSumOfSquares(pxtrack0 + pxtrack1 + pxtrack2, pytrack0 + pytrack1 + pytrack2, pztrack0 + pztrack1 + pztrack2); }); -DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! 3 body pT - [](float pxtrack0, float pytrack0, float pxtrack1, float pytrack1, float pxtrack2, float pytrack2) -> float { return RecoDecay::sqrtSumOfSquares(pxtrack0 + pxtrack1 + pxtrack2, pytrack0 + pytrack1 + pytrack2); }); +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! 3 body pT in GeV/c + [](float px, float py) -> float { return RecoDecay::sqrtSumOfSquares(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! 3 body total momentum in GeV/c + [](float px, float py, float pz) -> float { return RecoDecay::sqrtSumOfSquares(px, py, pz); }); +DECLARE_SOA_DYNAMIC_COLUMN(GenPt, genPt, //! 3 body pT in GeV/c + [](float genPx, float genPy) -> float { return RecoDecay::sqrtSumOfSquares(genPx, genPy); }); +DECLARE_SOA_DYNAMIC_COLUMN(GenP, genP, //! 3 body total momentum in GeV/c + [](float genPx, float genPy, float genPz) -> float { return RecoDecay::sqrtSumOfSquares(genPx, genPy, genPz); }); // Length quantities DECLARE_SOA_DYNAMIC_COLUMN(VtxRadius, vtxradius, //! 3 body decay radius (2D, centered at zero) [](float x, float y) -> float { return RecoDecay::sqrtSumOfSquares(x, y); }); +DECLARE_SOA_DYNAMIC_COLUMN(GenRadius, genRadius, //! 3 body decay radius (2D, centered at zero) + [](float genX, float genY) -> float { return RecoDecay::sqrtSumOfSquares(genX, genY); }); // Distance Over To Mom DECLARE_SOA_DYNAMIC_COLUMN(DistOverTotMom, distovertotmom, //! PV to 3 body decay distance over total momentum @@ -71,9 +154,6 @@ DECLARE_SOA_DYNAMIC_COLUMN(DistOverTotMom, distovertotmom, //! PV to 3 body deca return std::sqrt(std::pow(X - pvX, 2) + std::pow(Y - pvY, 2) + std::pow(Z - pvZ, 2)) / (P + 1E-10); }); -// CosPA -DECLARE_SOA_DYNAMIC_COLUMN(VtxCosPA, vtxcosPA, //! 3 body vtx CosPA - [](float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) -> float { return RecoDecay::cpa(std::array{pvX, pvY, pvZ}, std::array{X, Y, Z}, std::array{Px, Py, Pz}); }); // Dca to PV DECLARE_SOA_DYNAMIC_COLUMN(DCAVtxToPV, dcavtxtopv, //! DCA of 3 body vtx to PV [](float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) -> float { return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz)); }); @@ -84,509 +164,152 @@ DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, //! 3 body vtx eta DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, //! 3 body vtx phi [](float Px, float Py) -> float { return RecoDecay::phi(Px, Py); }); -// Calculated on the fly with mother particle hypothesis -DECLARE_SOA_DYNAMIC_COLUMN(MHypertriton, mHypertriton, //! mass under Hypertriton hypothesis - [](float pxtrack0, float pytrack0, float pztrack0, float pxtrack1, float pytrack1, float pztrack1, float pxtrack2, float pytrack2, float pztrack2) -> float { return RecoDecay::m(std::array{std::array{pxtrack0, pytrack0, pztrack0}, std::array{pxtrack1, pytrack1, pztrack1}, std::array{pxtrack2, pytrack2, pztrack2}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); }); -DECLARE_SOA_DYNAMIC_COLUMN(MAntiHypertriton, mAntiHypertriton, //! mass under antiHypertriton hypothesis - [](float pxtrack0, float pytrack0, float pztrack0, float pxtrack1, float pytrack1, float pztrack1, float pxtrack2, float pytrack2, float pztrack2) -> float { return RecoDecay::m(std::array{std::array{pxtrack0, pytrack0, pztrack0}, std::array{pxtrack1, pytrack1, pztrack1}, std::array{pxtrack2, pytrack2, pztrack2}}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}); }); - -DECLARE_SOA_DYNAMIC_COLUMN(MHyperHelium4, mHyperHelium4, //! mass under HyperHelium4 hypothesis - [](float pxtrack0, float pytrack0, float pztrack0, float pxtrack1, float pytrack1, float pztrack1, float pxtrack2, float pytrack2, float pztrack2) -> float { return RecoDecay::m(std::array{std::array{pxtrack0, pytrack0, pztrack0}, std::array{pxtrack1, pytrack1, pztrack1}, std::array{pxtrack2, pytrack2, pztrack2}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassHelium3}); }); -DECLARE_SOA_DYNAMIC_COLUMN(MAntiHyperHelium4, mAntiHyperHelium4, //! mass under antiHyperHelium4 hypothesis - [](float pxtrack0, float pytrack0, float pztrack0, float pxtrack1, float pytrack1, float pztrack1, float pxtrack2, float pytrack2, float pztrack2) -> float { return RecoDecay::m(std::array{std::array{pxtrack0, pytrack0, pztrack0}, std::array{pxtrack1, pytrack1, pztrack1}, std::array{pxtrack2, pytrack2, pztrack2}}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, o2::constants::physics::MassHelium3}); }); - -DECLARE_SOA_DYNAMIC_COLUMN(YHypertriton, yHypertriton, //! 3 body vtx y with hypertriton or antihypertriton hypothesis +// Rapidity +DECLARE_SOA_DYNAMIC_COLUMN(Rap, rap, //! 3 body vtx y with hypertriton or antihypertriton hypothesis [](float Px, float Py, float Pz) -> float { return RecoDecay::y(std::array{Px, Py, Pz}, o2::constants::physics::MassHyperTriton); }); -DECLARE_SOA_DYNAMIC_COLUMN(YHyperHelium4, yHyperHelium4, //! 3 body vtx y with hyperhelium4 or antihyperhelium4 hypothesis - [](float Px, float Py, float Pz) -> float { return RecoDecay::y(std::array{Px, Py, Pz}, o2::constants::physics::MassHyperHelium4); }); - -// kinematic information of daughter tracks -DECLARE_SOA_DYNAMIC_COLUMN(Track0Pt, track0pt, //! daughter0 pT - [](float pxtrack0, float pytrack0) -> float { return RecoDecay::sqrtSumOfSquares(pxtrack0, pytrack0); }); -DECLARE_SOA_DYNAMIC_COLUMN(Track1Pt, track1pt, //! daughter1 pT - [](float pxtrack1, float pytrack1) -> float { return RecoDecay::sqrtSumOfSquares(pxtrack1, pytrack1); }); -DECLARE_SOA_DYNAMIC_COLUMN(Track2Pt, track2pt, //! daughter2 pT - [](float pxtrack2, float pytrack2) -> float { return RecoDecay::sqrtSumOfSquares(pxtrack2, pytrack2); }); -DECLARE_SOA_DYNAMIC_COLUMN(Track0Eta, track0eta, //! daughter0 eta - [](float pxtrack0, float pytrack0, float pztrack0) -> float { return RecoDecay::eta(std::array{pxtrack0, pytrack0, pztrack0}); }); -DECLARE_SOA_DYNAMIC_COLUMN(Track0Phi, track0phi, //! daughter0 phi - [](float pxtrack0, float pytrack0) -> float { return RecoDecay::phi(pxtrack0, pytrack0); }); -DECLARE_SOA_DYNAMIC_COLUMN(Track1Eta, track1eta, //! daughter1 eta - [](float pxtrack1, float pytrack1, float pztrack1) -> float { return RecoDecay::eta(std::array{pxtrack1, pytrack1, pztrack1}); }); -DECLARE_SOA_DYNAMIC_COLUMN(Track1Phi, track1phi, //! daughter1 phi - [](float pxtrack1, float pytrack1) -> float { return RecoDecay::phi(pxtrack1, pytrack1); }); -DECLARE_SOA_DYNAMIC_COLUMN(Track2Eta, track2eta, //! daughter2 eta - [](float pxtrack2, float pytrack2, float pztrack2) -> float { return RecoDecay::eta(std::array{pxtrack2, pytrack2, pztrack2}); }); -DECLARE_SOA_DYNAMIC_COLUMN(Track2Phi, track2phi, //! daughter2 phi - [](float pxtrack2, float pytrack2) -> float { return RecoDecay::phi(pxtrack2, pytrack2); }); - -DECLARE_SOA_EXPRESSION_COLUMN(Px, px, //! 3 body vtx px - float, 1.f * aod::vtx3body::pxtrack0 + 1.f * aod::vtx3body::pxtrack1 + 1.f * aod::vtx3body::pxtrack2); -DECLARE_SOA_EXPRESSION_COLUMN(Py, py, //! 3 body vtx py - float, 1.f * aod::vtx3body::pytrack0 + 1.f * aod::vtx3body::pytrack1 + 1.f * aod::vtx3body::pytrack2); -DECLARE_SOA_EXPRESSION_COLUMN(Pz, pz, //! 3 body vtx pz - float, 1.f * aod::vtx3body::pztrack0 + 1.f * aod::vtx3body::pztrack1 + 1.f * aod::vtx3body::pztrack2); -} // namespace vtx3body -DECLARE_SOA_TABLE_FULL(StoredVtx3BodyDatas, "Vtx3BodyDatas", "AOD", "Vtx3BodyDATA", //! - o2::soa::Index<>, vtx3body::Track0Id, vtx3body::Track1Id, vtx3body::Track2Id, vtx3body::CollisionId, vtx3body::Decay3BodyId, - vtx3body::X, vtx3body::Y, vtx3body::Z, - vtx3body::PxTrack0, vtx3body::PyTrack0, vtx3body::PzTrack0, - vtx3body::PxTrack1, vtx3body::PyTrack1, vtx3body::PzTrack1, - vtx3body::PxTrack2, vtx3body::PyTrack2, vtx3body::PzTrack2, - vtx3body::DCAVtxDaughters, - vtx3body::DCAXYTrack0ToPV, vtx3body::DCAXYTrack1ToPV, vtx3body::DCAXYTrack2ToPV, - vtx3body::DCATrack0ToPV, vtx3body::DCATrack1ToPV, vtx3body::DCATrack2ToPV, - vtx3body::TOFNSigmaBachDe, - - // Dynamic columns - vtx3body::P, - vtx3body::Pt, - vtx3body::VtxRadius, - vtx3body::DistOverTotMom, - vtx3body::VtxCosPA, - vtx3body::DCAVtxToPV, - - // Invariant masses - vtx3body::MHypertriton, - vtx3body::MAntiHypertriton, - vtx3body::MHyperHelium4, - vtx3body::MAntiHyperHelium4, - - // Longitudinal - vtx3body::YHypertriton, - vtx3body::YHyperHelium4, - vtx3body::Eta, - vtx3body::Phi, - vtx3body::Track0Pt, - vtx3body::Track0Eta, - vtx3body::Track0Phi, - vtx3body::Track1Pt, - vtx3body::Track1Eta, - vtx3body::Track1Phi, - vtx3body::Track2Pt, - vtx3body::Track2Eta, - vtx3body::Track2Phi); - -// extended table with expression columns that can be used as arguments of dynamic columns -DECLARE_SOA_EXTENDED_TABLE_USER(Vtx3BodyDatas, StoredVtx3BodyDatas, "Vtx3BodyDATAEXT", //! - vtx3body::Px, vtx3body::Py, vtx3body::Pz); - -using Vtx3BodyData = Vtx3BodyDatas::iterator; -namespace vtx3body -{ -DECLARE_SOA_INDEX_COLUMN(Vtx3BodyData, vtx3BodyData); //! Index to Vtx3BodyData entry -} - -DECLARE_SOA_TABLE(Decay3BodyDataLink, "AOD", "DECAY3BODYLINK", //! Joinable table with Decay3bodys which links to Vtx3BodyData which is not produced for all entries - vtx3body::Vtx3BodyDataId); - -using Decay3BodysLinked = soa::Join; -using Decay3BodyLinked = Decay3BodysLinked::iterator; - -// Definition of labels for Vtx3BodyDatas -namespace mcvtx3bodylabel -{ -DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! MC particle for Vtx3BodyDatas -} // namespace mcvtx3bodylabel - -DECLARE_SOA_TABLE(McVtx3BodyLabels, "AOD", "MCVTXLABEL", //! Table joinable with Vtx3BodyData containing the MC labels - mcvtx3bodylabel::McParticleId); -using McVtx3BodyLabel = McVtx3BodyLabels::iterator; - -// Definition of labels for Decay3Bodys // Full table, joinable with Decay3Bodys (CAUTION: NOT WITH Vtx3BodyDATA) -namespace mcfullvtx3bodylabel -{ -DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! MC particle for Decay3Bodys -} // namespace mcfullvtx3bodylabel - -DECLARE_SOA_TABLE(McFullVtx3BodyLabels, "AOD", "MCFULLVTXLABEL", //! Table joinable with Decay3Bodys - mcfullvtx3bodylabel::McParticleId); -using McFullVtx3BodyLabel = McFullVtx3BodyLabels::iterator; +// Kinematic information of daughter tracks +DECLARE_SOA_DYNAMIC_COLUMN(TrackPrPt, trackPrPt, //! daughter0 pT + [](float pxTrackPr, float pyTrackPr) -> float { return RecoDecay::sqrtSumOfSquares(pxTrackPr, pyTrackPr); }); +DECLARE_SOA_DYNAMIC_COLUMN(TrackPiPt, trackPiPt, //! daughter1 pT + [](float pxTrackPi, float pyTrackPi) -> float { return RecoDecay::sqrtSumOfSquares(pxTrackPi, pyTrackPi); }); +DECLARE_SOA_DYNAMIC_COLUMN(TrackDePt, trackDePt, //! daughter2 pT + [](float pxTrackDe, float pyTrackDe) -> float { return RecoDecay::sqrtSumOfSquares(pxTrackDe, pyTrackDe); }); +DECLARE_SOA_DYNAMIC_COLUMN(TrackPrEta, trackPrEta, //! daughter0 eta + [](float pxTrackPr, float pyTrackPr, float pzTrackPr) -> float { return RecoDecay::eta(std::array{pxTrackPr, pyTrackPr, pzTrackPr}); }); +DECLARE_SOA_DYNAMIC_COLUMN(TrackPrPhi, trackPrPhi, //! daughter0 phi + [](float pxTrackPr, float pyTrackPr) -> float { return RecoDecay::phi(pxTrackPr, pyTrackPr); }); +DECLARE_SOA_DYNAMIC_COLUMN(TrackPiEta, trackPiEta, //! daughter1 eta + [](float pxTrackPi, float pyTrackPi, float pzTrackPi) -> float { return RecoDecay::eta(std::array{pxTrackPi, pyTrackPi, pzTrackPi}); }); +DECLARE_SOA_DYNAMIC_COLUMN(TrackPiPhi, trackPiPhi, //! daughter1 phi + [](float pxTrackPi, float pyTrackPi) -> float { return RecoDecay::phi(pxTrackPi, pyTrackPi); }); +DECLARE_SOA_DYNAMIC_COLUMN(TrackDeEta, trackDeEta, //! daughter2 eta + [](float pxTrackDe, float pyTrackDe, float pzTrackDe) -> float { return RecoDecay::eta(std::array{pxTrackDe, pyTrackDe, pzTrackDe}); }); +DECLARE_SOA_DYNAMIC_COLUMN(TrackDePhi, trackDePhi, //! daughter2 phi + [](float pxTrackDe, float pyTrackDe) -> float { return RecoDecay::phi(pxTrackDe, pyTrackDe); }); +} // namespace vtx3body -// output table for ML studies -namespace hyp3body -{ -// collision -DECLARE_SOA_COLUMN(Centrality, centrality, float); //! centrality -// reconstruced candidate -DECLARE_SOA_COLUMN(IsMatter, isMatter, bool); //! bool: true for matter -DECLARE_SOA_COLUMN(M, m, float); //! invariant mass -DECLARE_SOA_COLUMN(P, p, float); //! p -DECLARE_SOA_COLUMN(Pt, pt, float); //! pT -DECLARE_SOA_COLUMN(Ct, ct, float); //! ct -DECLARE_SOA_COLUMN(CosPA, cospa, float); -DECLARE_SOA_COLUMN(DCADaughters, dcaDaughters, float); //! DCA among daughters -DECLARE_SOA_COLUMN(DCACandToPV, dcaCandtopv, float); //! DCA of the reconstructed track to pv -DECLARE_SOA_COLUMN(VtxRadius, vtxRadius, float); //! Radius of SV -// kinematic infomation of daughter tracks -DECLARE_SOA_COLUMN(PtProton, ptProton, float); //! pT of the proton daughter -DECLARE_SOA_COLUMN(EtaProton, etaProton, float); //! eta of the proton daughter -DECLARE_SOA_COLUMN(PhiProton, phiProton, float); //! phi of the proton daughter -DECLARE_SOA_COLUMN(RadiusProton, radiusProton, float); //! radius of innermost hit of the proton daughter -DECLARE_SOA_COLUMN(PtPion, ptPion, float); //! pT of the pion daughter -DECLARE_SOA_COLUMN(EtaPion, etaPion, float); //! eta of the pion daughter -DECLARE_SOA_COLUMN(PhiPion, phiPion, float); //! phi of the pion daughter -DECLARE_SOA_COLUMN(RadiusPion, radiusPion, float); //! radius of innermost hit of the pion daughter -DECLARE_SOA_COLUMN(PtBachelor, ptBachelor, float); //! pT of the bachelor daughter -DECLARE_SOA_COLUMN(EtaBachelor, etaBachelor, float); //! eta of the bachelor daughter -DECLARE_SOA_COLUMN(PhiBachelor, phiBachelor, float); //! phi of the bachelor daughter -DECLARE_SOA_COLUMN(RadiusBachelor, radiusBachelor, float); //! radius of innermost hit of the bachelor daughter -// track quality -DECLARE_SOA_COLUMN(TPCNclusProton, tpcNclusProton, uint8_t); //! number of TPC clusters of the proton daughter -DECLARE_SOA_COLUMN(TPCNclusPion, tpcNclusPion, uint8_t); //! number of TPC clusters of the pion daughter -DECLARE_SOA_COLUMN(TPCNclusBachelor, tpcNclusBachelor, uint8_t); //! number of TPC clusters of the bachelor daughter -DECLARE_SOA_COLUMN(ITSNclusSizeProton, itsNclusSizeProton, uint8_t); //! average ITS cluster size of the proton daughter -DECLARE_SOA_COLUMN(ITSNclusSizePion, itsNclusSizePion, uint8_t); //! average ITS cluster size of the pion daughter -DECLARE_SOA_COLUMN(ITSNclusSizeBachelor, itsNclusSizeBachelor, uint8_t); //! average ITS cluster size of the bachelor daughter -// PID -DECLARE_SOA_COLUMN(TPCNSigmaProton, tpcNSigmaProton, float); //! nsigma of TPC PID of the proton daughter -DECLARE_SOA_COLUMN(TPCNSigmaPion, tpcNSigmaPion, float); //! nsigma of TPC PID of the pion daughter -DECLARE_SOA_COLUMN(TPCNSigmaBachelor, tpcNSigmaBachelor, float); //! nsigma of TPC PID of the bachelor daughter -DECLARE_SOA_COLUMN(TOFNSigmaBachelor, tofNSigmaBachelor, float); //! nsigma of TOF PID of the bachelor daughter -// DCA to PV -DECLARE_SOA_COLUMN(DCAXYProtonToPV, dcaxyProtontoPV, float); //! DCAXY of the proton daughter to pv -DECLARE_SOA_COLUMN(DCAXYPionToPV, dcaxyPiontoPV, float); //! DCAXY of the pion daughter to pv -DECLARE_SOA_COLUMN(DCAXYBachelorToPV, dcaxyBachelortoPV, float); //! DCAXY of the bachelor daughter to pv -DECLARE_SOA_COLUMN(DCAProtonToPV, dcaProtontoPV, float); //! DCA of the proton daughter to pv -DECLARE_SOA_COLUMN(DCAPionToPV, dcaPiontoPV, float); //! DCA of the pion daughter to pv -DECLARE_SOA_COLUMN(DCABachelorToPV, dcaBachelortoPV, float); //! DCA of the bachelor daughter to pv -// for MC -DECLARE_SOA_COLUMN(GenP, genP, float); // P of the hypertriton -DECLARE_SOA_COLUMN(GenPt, genPt, float); // pT of the hypertriton -DECLARE_SOA_COLUMN(GenCt, genCt, float); // ct of the hypertriton -DECLARE_SOA_COLUMN(GenPhi, genPhi, float); // Phi of the hypertriton -DECLARE_SOA_COLUMN(GenEta, genEta, float); // Eta of the hypertriton -DECLARE_SOA_COLUMN(GenRapidity, genRapidity, float); // Rapidity of the hypertriton -DECLARE_SOA_COLUMN(IsReco, isReco, bool); // bool: true for reco -DECLARE_SOA_COLUMN(IsSignal, isSignal, bool); // bool: true for signal -DECLARE_SOA_COLUMN(PdgCode, pdgCode, int); // pdgCode of the mcparticle, -1 for fake pair -DECLARE_SOA_COLUMN(SurvivedEventSelection, survivedEventSelection, bool); // bool: true for survived event selection -} // namespace hyp3body - -// output table for data -DECLARE_SOA_TABLE(Hyp3BodyCands, "AOD", "HYP3BODYCANDS", - o2::soa::Index<>, - hyp3body::Centrality, - // secondary vertex and reconstruced candidate - hyp3body::IsMatter, - hyp3body::M, - hyp3body::P, - hyp3body::Pt, - hyp3body::Ct, - hyp3body::CosPA, - hyp3body::DCADaughters, - hyp3body::DCACandToPV, - hyp3body::VtxRadius, - // daughter tracks - hyp3body::PtProton, hyp3body::EtaProton, hyp3body::PhiProton, hyp3body::RadiusProton, - hyp3body::PtPion, hyp3body::EtaPion, hyp3body::PhiPion, hyp3body::RadiusPion, - hyp3body::PtBachelor, hyp3body::EtaBachelor, hyp3body::PhiBachelor, hyp3body::RadiusBachelor, - hyp3body::TPCNclusProton, hyp3body::TPCNclusPion, hyp3body::TPCNclusBachelor, - hyp3body::ITSNclusSizeProton, hyp3body::ITSNclusSizePion, hyp3body::ITSNclusSizeBachelor, - hyp3body::TPCNSigmaProton, hyp3body::TPCNSigmaPion, hyp3body::TPCNSigmaBachelor, - hyp3body::TOFNSigmaBachelor, - hyp3body::DCAXYProtonToPV, hyp3body::DCAXYPionToPV, hyp3body::DCAXYBachelorToPV, - hyp3body::DCAProtonToPV, hyp3body::DCAPionToPV, hyp3body::DCABachelorToPV); - -// output table for MC -DECLARE_SOA_TABLE(MCHyp3BodyCands, "AOD", "MCHYP3BODYCANDS", +// index table +DECLARE_SOA_TABLE(Decay3BodyIndices, "AOD", "3BodyINDEX", //! o2::soa::Index<>, - hyp3body::Centrality, - // secondary vertex and reconstruced candidate - hyp3body::IsMatter, - hyp3body::M, - hyp3body::P, - hyp3body::Pt, - hyp3body::Ct, - hyp3body::CosPA, - hyp3body::DCADaughters, - hyp3body::DCACandToPV, - hyp3body::VtxRadius, - // daughter tracks - hyp3body::PtProton, hyp3body::EtaProton, hyp3body::PhiProton, hyp3body::RadiusProton, - hyp3body::PtPion, hyp3body::EtaPion, hyp3body::PhiPion, hyp3body::RadiusPion, - hyp3body::PtBachelor, hyp3body::EtaBachelor, hyp3body::PhiBachelor, hyp3body::RadiusBachelor, - hyp3body::TPCNclusProton, hyp3body::TPCNclusPion, hyp3body::TPCNclusBachelor, - hyp3body::ITSNclusSizeProton, hyp3body::ITSNclusSizePion, hyp3body::ITSNclusSizeBachelor, - hyp3body::TPCNSigmaProton, hyp3body::TPCNSigmaPion, hyp3body::TPCNSigmaBachelor, - hyp3body::TOFNSigmaBachelor, - hyp3body::DCAXYProtonToPV, hyp3body::DCAXYPionToPV, hyp3body::DCAXYBachelorToPV, - hyp3body::DCAProtonToPV, hyp3body::DCAPionToPV, hyp3body::DCABachelorToPV, - // MC information - hyp3body::GenP, - hyp3body::GenPt, - hyp3body::GenCt, - hyp3body::GenPhi, - hyp3body::GenEta, - hyp3body::GenRapidity, - hyp3body::IsSignal, - hyp3body::IsReco, - hyp3body::PdgCode, - hyp3body::SurvivedEventSelection); - -//______________________________________________________ -// DATAMODEL FOR KFPARTICLE DECAY3BODYS - -namespace kfvtx3body -{ -// General 3 body Vtx properties: mass, momentum, charge -DECLARE_SOA_COLUMN(Mass, mass, float); //! candidate mass (PID hypothesis depending on bachelor charge) -DECLARE_SOA_COLUMN(XErr, xerr, float); //! candidate position x error at decay position -DECLARE_SOA_COLUMN(YErr, yerr, float); //! candidate position y error at decay position -DECLARE_SOA_COLUMN(ZErr, zerr, float); //! candidate position z error at decay position -DECLARE_SOA_COLUMN(Px, px, float); //! candidate px at decay position -DECLARE_SOA_COLUMN(Py, py, float); //! candidate py at decay position -DECLARE_SOA_COLUMN(Pz, pz, float); //! candidate pz at decay position -DECLARE_SOA_COLUMN(Pt, pt, float); //! candidate pt at decay position -DECLARE_SOA_COLUMN(PxErr, pxerr, float); //! candidate px error at decay position -DECLARE_SOA_COLUMN(PyErr, pyerr, float); //! candidate py error at decay position -DECLARE_SOA_COLUMN(PzErr, pzerr, float); //! candidate pz error at decay position -DECLARE_SOA_COLUMN(PtErr, pterr, float); //! candidate pt error at decay position -DECLARE_SOA_COLUMN(Sign, sign, float); //! candidate sign - -// topological properties -DECLARE_SOA_COLUMN(VtxCosPAKF, vtxcospakf, float); //! 3 body vtx CosPA from KFParticle (using kfpPV) -DECLARE_SOA_COLUMN(VtxCosXYPAKF, vtxcosxypakf, float); //! 3 body vtx CosPA from KFParticle (using kfpPV) -DECLARE_SOA_COLUMN(VtxCosPAKFtopo, vtxcospakftopo, float); //! 3 body vtx CosPA from KFParticle after topological constraint (using kfpPV) -DECLARE_SOA_COLUMN(VtxCosXYPAKFtopo, vtxcosxypakftopo, float); //! 3 body vtx CosPA from KFParticle after topological constraint (using kfpPV) -DECLARE_SOA_COLUMN(DCAVtxToPVKF, dcavtxtopvkf, float); //! 3 body vtx DCA to PV from KFParticle (using kfpPV) -DECLARE_SOA_COLUMN(DCAXYVtxToPVKF, dcaxyvtxtopvkf, float); //! 3 body vtx DCAxy to PV from KFParticle (using kfpPV) -DECLARE_SOA_COLUMN(DecayLKF, decaylkf, float); //! 3 body vtx decay length from KFParticle (using kfpPV after topological constraint) -DECLARE_SOA_COLUMN(DecayLXYKF, decaylxykf, float); //! 3 body vtx decay length XY from KFParticle (using kfpPV after topological constraint) -DECLARE_SOA_COLUMN(DecayLDeltaL, decayldeltal, float); //! 3 body vtx l/dl from KFParticle (using kfpPV after topological constraint) -DECLARE_SOA_COLUMN(Chi2geoNDF, chi2geondf, float); //! 3 body vtx chi2geo from geometrical KFParticle fit -DECLARE_SOA_COLUMN(Chi2topoNDF, chi2topondf, float); //! 3 body vtx chi2topo from KFParticle topological constraint to the PV (using kfpPV) -DECLARE_SOA_COLUMN(CTauKFtopo, ctaukftopo, float); //! 3 body vtx ctau from KFParticle after topological constraint - -// daughters -DECLARE_SOA_COLUMN(DCATrack0ToPVKF, dcatrack0topvkf, float); //! DCA of proton prong to PV from KFParticle -DECLARE_SOA_COLUMN(DCATrack1ToPVKF, dcatrack1topvkf, float); //! DCA of pion prong to PV from KFParticle -DECLARE_SOA_COLUMN(DCATrack2ToPVKF, dcatrack2topvkf, float); //! DCA of deuteron prong to PV from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack0ToPVKF, dcaxytrack0topvkf, float); //! DCAxy of proton prong to PV from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack1ToPVKF, dcaxytrack1topvkf, float); //! DCAxy of pion prong to PV from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack2ToPVKF, dcaxytrack2topvkf, float); //! DCAxy of deuteron prong to PV from KFParticle -DECLARE_SOA_COLUMN(DCATrackPosToPV, dcatrackpostopv, float); //! DCA of positive track to PV (propagated before vtx fit) -DECLARE_SOA_COLUMN(DCATrackNegToPV, dcatracknegtopv, float); //! DCA of negative track to PV (propagated before vtx fit) -DECLARE_SOA_COLUMN(DCATrackBachToPV, dcatrackbachtopv, float); //! DCA of bachelor track to PV (propagated before vtx fit) -DECLARE_SOA_COLUMN(DCAxyTrackPosToPV, dcaxytrackpostopv, float); //! DCAxy of positive track to PV (propagated before vtx fit) -DECLARE_SOA_COLUMN(DCAxyTrackNegToPV, dcaxytracknegtopv, float); //! DCAxy of negative track to PV (propagated before vtx fit) -DECLARE_SOA_COLUMN(DCAxyTrackBachToPV, dcaxytrackbachtopv, float); //! DCAxy of bachelor track to PV (propagated before vtx fit) -DECLARE_SOA_COLUMN(DCAxyTrack0ToSVKF, dcaxytrack0tosvkf, float); //! DCAxy of proton prong to SV from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack1ToSVKF, dcaxytrack1tosvkf, float); //! DCAxy of pion prong to SV from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack2ToSVKF, dcaxytrack2tosvkf, float); //! DCAxy of deuteron prong to SV from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack0ToTrack1KF, dcaxytrack0totrack1kf, float); //! DCAxy of proton prong to pion from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack0ToTrack2KF, dcaxytrack0totrack2kf, float); //! DCAxy of proton prong to deuteron from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack1ToTrack2KF, dcaxytrack1totrack2kf, float); //! DCAxy of pion prong to deuteron from KFParticle -DECLARE_SOA_COLUMN(DCAVtxDaughtersKF, dcavtxdaughterskf, float); //! sum of DCAs between daughters in 3D from KFParticle -DECLARE_SOA_COLUMN(Track0Sign, track0sign, float); //! sign of proton daughter track -DECLARE_SOA_COLUMN(Track1Sign, track1sign, float); //! sign of pion daughter track -DECLARE_SOA_COLUMN(Track2Sign, track2sign, float); //! sign of deuteron daughter track -DECLARE_SOA_COLUMN(TPCInnerParamTrack0, tpcinnerparamtrack0, float); //! momentum at inner wall of TPC of proton daughter -DECLARE_SOA_COLUMN(TPCInnerParamTrack1, tpcinnerparamtrack1, float); //! momentum at inner wall of TPC of pion daughter -DECLARE_SOA_COLUMN(TPCInnerParamTrack2, tpcinnerparamtrack2, float); //! momentum at inner wall of TPC of deuteron daughter -// PID -DECLARE_SOA_COLUMN(TPCNSigmaProton, tpcnsigmaproton, float); //! nsigma proton of TPC PID of the proton daughter -DECLARE_SOA_COLUMN(TPCNSigmaPion, tpcnsigmapion, float); //! nsigma pion of TPC PID of the pion daughter -DECLARE_SOA_COLUMN(TPCNSigmaDeuteron, tpcnsigmadeuteron, float); //! nsigma deuteron of TPC PID of the bachelor daughter -DECLARE_SOA_COLUMN(TPCNSigmaPionBach, tpcnsigmapionbach, float); //! nsigma pion of TPC PID of the bachelor daughter -DECLARE_SOA_COLUMN(TPCdEdxProton, tpcdedxproton, float); //! TPC dEdx of the proton daughter -DECLARE_SOA_COLUMN(TPCdEdxPion, tpcdedxpion, float); //! TPC dEdx of the pion daughter -DECLARE_SOA_COLUMN(TPCdEdxDeuteron, tpcdedxdeuteron, float); //! TPC dEdx of the bachelor daughter -DECLARE_SOA_COLUMN(TOFNSigmaDeuteron, tofnsigmadeuteron, float); //! nsigma of TOF PID of the bachelor daughter -DECLARE_SOA_COLUMN(ITSClusSizeDeuteron, itsclussizedeuteron, double); //! average ITS cluster size of bachelor daughter -DECLARE_SOA_COLUMN(PIDTrackingDeuteron, pidtrackingdeuteron, uint32_t); //! PID during tracking of bachelor daughter - -// Monte Carlo -DECLARE_SOA_COLUMN(GenP, genp, float); //! generated momentum -DECLARE_SOA_COLUMN(GenPt, genpt, float); //! generated transverse momentum -DECLARE_SOA_COLUMN(GenDecVtxX, gendecvtxx, double); //! generated decay vertex position x -DECLARE_SOA_COLUMN(GenDecVtxY, gendecvtxy, double); //! generated decay vertex position y -DECLARE_SOA_COLUMN(GenDecVtxZ, gendecvtxz, double); //! generated decay vertex position z -DECLARE_SOA_COLUMN(GenCtau, genctau, double); //! generated ctau -DECLARE_SOA_COLUMN(GenPhi, genphi, float); //! generated phi -DECLARE_SOA_COLUMN(GenEta, geneta, float); //! generated eta -DECLARE_SOA_COLUMN(GenRapidity, genrapidity, float); //! generated rapidity -DECLARE_SOA_COLUMN(GenPosP, genposp, float); //! generated momentum pos daughter particle -DECLARE_SOA_COLUMN(GenPosPt, genpospt, float); //! generated transverse momentum pos daughter particle -DECLARE_SOA_COLUMN(GenNegP, gennegp, float); //! generated momentum neg daughter particle -DECLARE_SOA_COLUMN(GenNegPt, gennegpt, float); //! generated transverse momentum neg daughter particle -DECLARE_SOA_COLUMN(GenBachP, genbachp, float); //! generated momentum bachelor daughter particle -DECLARE_SOA_COLUMN(GenBachPt, genbachpt, float); //! generated transverse momentum bachelor daughter particle -DECLARE_SOA_COLUMN(IsTrueH3L, istrueh3l, bool); //! flag for true hypertriton candidate -DECLARE_SOA_COLUMN(IsTrueAntiH3L, istrueantih3l, bool); //! flag for true anti-hypertriton candidate -DECLARE_SOA_COLUMN(PdgCode, pdgcode, int); //! MC particle PDG code -DECLARE_SOA_COLUMN(SurvEvSel, survevsel, int); //! flag if reco collision survived event selection -DECLARE_SOA_COLUMN(IsReco, isreco, int); //! flag if candidate was reconstructed - -// V0 -DECLARE_SOA_COLUMN(MassV0, massv0, float); //! proton, pion vertex mass -DECLARE_SOA_COLUMN(Chi2MassV0, chi2massv0, float); //! chi2 of proton, pion mass constraint to Lambda mass -DECLARE_SOA_COLUMN(CosPAV0, cospav0, float); //! proton, pion vertex mass + vtx3body::Decay3BodyId, + vtx3body::TrackPrId, vtx3body::TrackPiId, vtx3body::TrackDeId, + vtx3body::CollisionId); -} // namespace kfvtx3body - -DECLARE_SOA_TABLE(KFVtx3BodyDatas, "AOD", "KFVTX3BODYDATA", - o2::soa::Index<>, vtx3body::CollisionId, vtx3body::Track0Id, vtx3body::Track1Id, vtx3body::Track2Id, vtx3body::Decay3BodyId, - - // hypertriton candidate - kfvtx3body::Mass, - vtx3body::X, vtx3body::Y, vtx3body::Z, - kfvtx3body::XErr, kfvtx3body::YErr, kfvtx3body::ZErr, - kfvtx3body::Px, kfvtx3body::Py, kfvtx3body::Pz, kfvtx3body::Pt, - kfvtx3body::PxErr, kfvtx3body::PyErr, kfvtx3body::PzErr, kfvtx3body::PtErr, - kfvtx3body::Sign, - kfvtx3body::DCAVtxToPVKF, kfvtx3body::DCAXYVtxToPVKF, - kfvtx3body::VtxCosPAKF, kfvtx3body::VtxCosXYPAKF, - kfvtx3body::VtxCosPAKFtopo, kfvtx3body::VtxCosXYPAKFtopo, - kfvtx3body::DecayLKF, kfvtx3body::DecayLXYKF, kfvtx3body::DecayLDeltaL, - kfvtx3body::Chi2geoNDF, kfvtx3body::Chi2topoNDF, - kfvtx3body::CTauKFtopo, - - // V0 - kfvtx3body::MassV0, kfvtx3body::Chi2MassV0, - kfvtx3body::CosPAV0, - - // daughters - vtx3body::PxTrack0, vtx3body::PyTrack0, vtx3body::PzTrack0, // proton - vtx3body::PxTrack1, vtx3body::PyTrack1, vtx3body::PzTrack1, // pion - vtx3body::PxTrack2, vtx3body::PyTrack2, vtx3body::PzTrack2, // deuteron - kfvtx3body::TPCInnerParamTrack0, kfvtx3body::TPCInnerParamTrack1, kfvtx3body::TPCInnerParamTrack2, // proton, pion, deuteron - kfvtx3body::DCATrack0ToPVKF, kfvtx3body::DCATrack1ToPVKF, kfvtx3body::DCATrack2ToPVKF, kfvtx3body::DCAxyTrack0ToPVKF, kfvtx3body::DCAxyTrack1ToPVKF, kfvtx3body::DCAxyTrack2ToPVKF, - kfvtx3body::DCAxyTrack0ToSVKF, kfvtx3body::DCAxyTrack1ToSVKF, kfvtx3body::DCAxyTrack2ToSVKF, - kfvtx3body::DCAxyTrack0ToTrack1KF, kfvtx3body::DCAxyTrack0ToTrack2KF, kfvtx3body::DCAxyTrack1ToTrack2KF, - kfvtx3body::DCAVtxDaughtersKF, - kfvtx3body::DCAxyTrackPosToPV, kfvtx3body::DCAxyTrackNegToPV, kfvtx3body::DCAxyTrackBachToPV, - kfvtx3body::DCATrackPosToPV, kfvtx3body::DCATrackNegToPV, kfvtx3body::DCATrackBachToPV, - kfvtx3body::Track0Sign, kfvtx3body::Track1Sign, kfvtx3body::Track2Sign, // track sing: proton, pion, deuteron - kfvtx3body::TPCNSigmaProton, kfvtx3body::TPCNSigmaPion, kfvtx3body::TPCNSigmaDeuteron, kfvtx3body::TPCNSigmaPionBach, - kfvtx3body::TPCdEdxProton, kfvtx3body::TPCdEdxPion, kfvtx3body::TPCdEdxDeuteron, - kfvtx3body::TOFNSigmaDeuteron, - kfvtx3body::ITSClusSizeDeuteron, - kfvtx3body::PIDTrackingDeuteron); - -using KFVtx3BodyData = KFVtx3BodyDatas::iterator; -namespace kfvtx3body -{ -DECLARE_SOA_INDEX_COLUMN(KFVtx3BodyData, kfvtx3BodyData); //! Index to KFVtx3BodyData entry -} - -DECLARE_SOA_TABLE(KFDecay3BodyDataLink, "AOD", "KF3BODYLINK", //! Joinable table with Decay3bodys which links to KFVtx3BodyData which is not produced for all entries - kfvtx3body::KFVtx3BodyDataId); - -using KFDecay3BodysLinked = soa::Join; -using KFDecay3BodyLinked = KFDecay3BodysLinked::iterator; - -// Lite data candidate table for analysis -DECLARE_SOA_TABLE(KFVtx3BodyDatasLite, "AOD", "KF3BODYLITE", +// reconstructed candidate table for analysis +DECLARE_SOA_TABLE(Vtx3BodyDatas, "AOD", "VTX3BODYDATA", //! o2::soa::Index<>, - // hypertriton candidate - kfvtx3body::Mass, + vtx3body::Sign, + vtx3body::Mass, vtx3body::MassV0, vtx3body::X, vtx3body::Y, vtx3body::Z, - kfvtx3body::Px, kfvtx3body::Py, kfvtx3body::Pz, kfvtx3body::Pt, - kfvtx3body::Sign, - kfvtx3body::DCAVtxToPVKF, kfvtx3body::DCAXYVtxToPVKF, - kfvtx3body::VtxCosPAKF, kfvtx3body::VtxCosXYPAKF, - kfvtx3body::DecayLKF, kfvtx3body::DecayLXYKF, kfvtx3body::DecayLDeltaL, - kfvtx3body::Chi2geoNDF, kfvtx3body::Chi2topoNDF, - kfvtx3body::CTauKFtopo, - - // V0 - kfvtx3body::MassV0, kfvtx3body::Chi2MassV0, - kfvtx3body::CosPAV0, - - // daughters - vtx3body::PxTrack0, vtx3body::PyTrack0, vtx3body::PzTrack0, // proton - vtx3body::PxTrack1, vtx3body::PyTrack1, vtx3body::PzTrack1, // pion - vtx3body::PxTrack2, vtx3body::PyTrack2, vtx3body::PzTrack2, // deuteron - kfvtx3body::TPCInnerParamTrack0, kfvtx3body::TPCInnerParamTrack1, kfvtx3body::TPCInnerParamTrack2, // proton, pion, deuteron - kfvtx3body::DCATrack0ToPVKF, kfvtx3body::DCATrack1ToPVKF, kfvtx3body::DCATrack2ToPVKF, kfvtx3body::DCAxyTrack0ToPVKF, kfvtx3body::DCAxyTrack1ToPVKF, kfvtx3body::DCAxyTrack2ToPVKF, - kfvtx3body::DCAxyTrack0ToSVKF, kfvtx3body::DCAxyTrack1ToSVKF, kfvtx3body::DCAxyTrack2ToSVKF, - kfvtx3body::DCAxyTrack0ToTrack1KF, kfvtx3body::DCAxyTrack0ToTrack2KF, kfvtx3body::DCAxyTrack1ToTrack2KF, - kfvtx3body::DCAVtxDaughtersKF, - kfvtx3body::Track0Sign, kfvtx3body::Track1Sign, kfvtx3body::Track2Sign, // track sing: proton, pion, deuteron - kfvtx3body::TPCNSigmaProton, kfvtx3body::TPCNSigmaPion, kfvtx3body::TPCNSigmaDeuteron, kfvtx3body::TPCNSigmaPionBach, - kfvtx3body::TPCdEdxProton, kfvtx3body::TPCdEdxPion, kfvtx3body::TPCdEdxDeuteron, - kfvtx3body::TOFNSigmaDeuteron, - kfvtx3body::ITSClusSizeDeuteron, - kfvtx3body::PIDTrackingDeuteron); - -using KFVtx3BodyDataLite = KFVtx3BodyDatasLite::iterator; + vtx3body::Px, vtx3body::Py, vtx3body::Pz, + vtx3body::Chi2, + vtx3body::TrackedClSize, + vtx3body::PxTrackPr, vtx3body::PyTrackPr, vtx3body::PzTrackPr, + vtx3body::PxTrackPi, vtx3body::PyTrackPi, vtx3body::PzTrackPi, + vtx3body::PxTrackDe, vtx3body::PyTrackDe, vtx3body::PzTrackDe, + vtx3body::DCAXYTrackPrToPV, vtx3body::DCAXYTrackPiToPV, vtx3body::DCAXYTrackDeToPV, + vtx3body::DCAZTrackPrToPV, vtx3body::DCAZTrackPiToPV, vtx3body::DCAZTrackDeToPV, + vtx3body::DCATrackPrToSV, vtx3body::DCATrackPiToSV, vtx3body::DCATrackDeToSV, + vtx3body::DCAVtxToDaughtersAv, + vtx3body::CosPA, vtx3body::Ct, + vtx3body::TPCNSigmaPr, vtx3body::TPCNSigmaPi, vtx3body::TPCNSigmaDe, vtx3body::TPCNSigmaPiBach, + vtx3body::TOFNSigmaDe, + vtx3body::ITSClSizePr, vtx3body::ITSClSizePi, vtx3body::ITSClSizeDe, + vtx3body::TPCNClTrackPr, vtx3body::TPCNClTrackPi, vtx3body::TPCNClTrackDe, + vtx3body::PIDTrackingDe, + + // Dynamic columns + vtx3body::P, + vtx3body::Pt, + vtx3body::VtxRadius, + vtx3body::DistOverTotMom, + vtx3body::DCAVtxToPV, + + // Longitudinal + vtx3body::Rap, + vtx3body::Eta, + vtx3body::Phi, + vtx3body::TrackPrPt, + vtx3body::TrackPrEta, + vtx3body::TrackPrPhi, + vtx3body::TrackPiPt, + vtx3body::TrackPiEta, + vtx3body::TrackPiPhi, + vtx3body::TrackDePt, + vtx3body::TrackDeEta, + vtx3body::TrackDePhi); + +// covariance matrix table +DECLARE_SOA_TABLE(Vtx3BodyCovs, "AOD", "VTX3BODYCOV", //! + vtx3body::CovProton, vtx3body::CovPion, vtx3body::CovDeuteron, + vtx3body::VtxCovMat); // MC candidate table for analysis -DECLARE_SOA_TABLE(McKFVtx3BodyDatas, "AOD", "MCKF3BODYDATAS", +DECLARE_SOA_TABLE(McVtx3BodyDatas, "AOD", "MC3BODYDATA", //! o2::soa::Index<>, - // hypertriton candidate - kfvtx3body::Mass, + vtx3body::Sign, + vtx3body::Mass, vtx3body::MassV0, vtx3body::X, vtx3body::Y, vtx3body::Z, - kfvtx3body::XErr, kfvtx3body::YErr, kfvtx3body::ZErr, - kfvtx3body::Px, kfvtx3body::Py, kfvtx3body::Pz, kfvtx3body::Pt, - kfvtx3body::PxErr, kfvtx3body::PyErr, kfvtx3body::PzErr, kfvtx3body::PtErr, - kfvtx3body::Sign, - kfvtx3body::DCAVtxToPVKF, kfvtx3body::DCAXYVtxToPVKF, - kfvtx3body::VtxCosPAKF, kfvtx3body::VtxCosXYPAKF, - kfvtx3body::VtxCosPAKFtopo, kfvtx3body::VtxCosXYPAKFtopo, - kfvtx3body::DecayLKF, kfvtx3body::DecayLXYKF, kfvtx3body::DecayLDeltaL, - kfvtx3body::Chi2geoNDF, kfvtx3body::Chi2topoNDF, - kfvtx3body::CTauKFtopo, - - // V0 - kfvtx3body::MassV0, kfvtx3body::Chi2MassV0, - kfvtx3body::CosPAV0, - - // daughters - vtx3body::PxTrack0, vtx3body::PyTrack0, vtx3body::PzTrack0, // proton - vtx3body::PxTrack1, vtx3body::PyTrack1, vtx3body::PzTrack1, // pion - vtx3body::PxTrack2, vtx3body::PyTrack2, vtx3body::PzTrack2, // deuteron - kfvtx3body::TPCInnerParamTrack0, kfvtx3body::TPCInnerParamTrack1, kfvtx3body::TPCInnerParamTrack2, // proton, pion, deuteron - kfvtx3body::DCATrack0ToPVKF, kfvtx3body::DCATrack1ToPVKF, kfvtx3body::DCATrack2ToPVKF, kfvtx3body::DCAxyTrack0ToPVKF, kfvtx3body::DCAxyTrack1ToPVKF, kfvtx3body::DCAxyTrack2ToPVKF, - kfvtx3body::DCAxyTrack0ToSVKF, kfvtx3body::DCAxyTrack1ToSVKF, kfvtx3body::DCAxyTrack2ToSVKF, - kfvtx3body::DCAxyTrack0ToTrack1KF, kfvtx3body::DCAxyTrack0ToTrack2KF, kfvtx3body::DCAxyTrack1ToTrack2KF, - kfvtx3body::DCAVtxDaughtersKF, - kfvtx3body::DCAxyTrackPosToPV, kfvtx3body::DCAxyTrackNegToPV, kfvtx3body::DCAxyTrackBachToPV, - kfvtx3body::DCATrackPosToPV, kfvtx3body::DCATrackNegToPV, kfvtx3body::DCATrackBachToPV, - kfvtx3body::Track0Sign, kfvtx3body::Track1Sign, kfvtx3body::Track2Sign, // track sing: proton, pion, deuteron - kfvtx3body::TPCNSigmaProton, kfvtx3body::TPCNSigmaPion, kfvtx3body::TPCNSigmaDeuteron, kfvtx3body::TPCNSigmaPionBach, - kfvtx3body::TPCdEdxProton, kfvtx3body::TPCdEdxPion, kfvtx3body::TPCdEdxDeuteron, - kfvtx3body::TOFNSigmaDeuteron, - kfvtx3body::ITSClusSizeDeuteron, - kfvtx3body::PIDTrackingDeuteron, - - // MC information - kfvtx3body::GenP, - kfvtx3body::GenPt, - kfvtx3body::GenDecVtxX, kfvtx3body::GenDecVtxY, kfvtx3body::GenDecVtxZ, - kfvtx3body::GenCtau, - kfvtx3body::GenPhi, - kfvtx3body::GenEta, - kfvtx3body::GenRapidity, - kfvtx3body::GenPosP, kfvtx3body::GenPosPt, - kfvtx3body::GenNegP, kfvtx3body::GenNegPt, - kfvtx3body::GenBachP, kfvtx3body::GenBachPt, - kfvtx3body::IsTrueH3L, kfvtx3body::IsTrueAntiH3L, - kfvtx3body::PdgCode, - kfvtx3body::IsReco, - kfvtx3body::SurvEvSel); - -// Definition of labels for KFVtx3BodyDatas -namespace mckfvtx3bodylabel -{ -DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! MC particle for KF Vtx3BodyDatas -} // namespace mckfvtx3bodylabel - -DECLARE_SOA_TABLE(McKFVtx3BodyLabels, "AOD", "MCKFVTXLABEL", //! Table joinable with KFVtx3BodyData containing the MC labels - mckfvtx3bodylabel::McParticleId); -using McKFVtx3BodyLabel = McKFVtx3BodyLabels::iterator; - -// Definition of labels for KFDecay3Bodys // Full table, joinable with KFDecay3Bodys (CAUTION: NOT WITH Vtx3BodyDATA) -namespace mcfullkfvtx3bodylabel -{ -DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! MC particle for Decay3Bodys -} // namespace mcfullkfvtx3bodylabel + vtx3body::Px, vtx3body::Py, vtx3body::Pz, + vtx3body::Chi2, + vtx3body::TrackedClSize, + vtx3body::PxTrackPr, vtx3body::PyTrackPr, vtx3body::PzTrackPr, + vtx3body::PxTrackPi, vtx3body::PyTrackPi, vtx3body::PzTrackPi, + vtx3body::PxTrackDe, vtx3body::PyTrackDe, vtx3body::PzTrackDe, + vtx3body::DCAXYTrackPrToPV, vtx3body::DCAXYTrackPiToPV, vtx3body::DCAXYTrackDeToPV, + vtx3body::DCAZTrackPrToPV, vtx3body::DCAZTrackPiToPV, vtx3body::DCAZTrackDeToPV, + vtx3body::DCATrackPrToSV, vtx3body::DCATrackPiToSV, vtx3body::DCATrackDeToSV, + vtx3body::DCAVtxToDaughtersAv, + vtx3body::CosPA, vtx3body::Ct, + vtx3body::TPCNSigmaPr, vtx3body::TPCNSigmaPi, vtx3body::TPCNSigmaDe, vtx3body::TPCNSigmaPiBach, + vtx3body::TOFNSigmaDe, + vtx3body::ITSClSizePr, vtx3body::ITSClSizePi, vtx3body::ITSClSizeDe, + vtx3body::TPCNClTrackPr, vtx3body::TPCNClTrackPi, vtx3body::TPCNClTrackDe, + vtx3body::PIDTrackingDe, + + // Monte Carlo information + vtx3body::GenPx, vtx3body::GenPy, vtx3body::GenPz, + vtx3body::GenX, vtx3body::GenY, vtx3body::GenZ, + vtx3body::GenCt, + vtx3body::GenPhi, vtx3body::GenEta, vtx3body::GenRap, + vtx3body::GenPPr, vtx3body::GenPPi, vtx3body::GenPDe, + vtx3body::GenPtPr, vtx3body::GenPtPi, vtx3body::GenPtDe, + vtx3body::IsTrueH3L, vtx3body::IsTrueAntiH3L, + vtx3body::IsReco, + vtx3body::MotherPdgCode, + vtx3body::PrPdgCode, vtx3body::PiPdgCode, vtx3body::DePdgCode, + vtx3body::IsDePrimary, + vtx3body::IsSurvEvSel, + + // Dynamic columns + vtx3body::P, + vtx3body::Pt, + vtx3body::GenP, + vtx3body::GenPt, + vtx3body::VtxRadius, + vtx3body::GenRadius, + vtx3body::DistOverTotMom, + vtx3body::DCAVtxToPV, + + // Longitudinal + vtx3body::Rap, + vtx3body::Eta, + vtx3body::Phi, + vtx3body::TrackPrPt, + vtx3body::TrackPrEta, + vtx3body::TrackPrPhi, + vtx3body::TrackPiPt, + vtx3body::TrackPiEta, + vtx3body::TrackPiPhi, + vtx3body::TrackDePt, + vtx3body::TrackDeEta, + vtx3body::TrackDePhi); + +// Define joins +using Vtx3BodyDatasCovs = soa::Join; +using Vtx3BodyDatasCovsIndexed = soa::Join; -DECLARE_SOA_TABLE(McFullKFVtx3BodyLabels, "AOD", "MCFULLKFLABEL", //! Table joinable with Decay3Bodys (CAUTION: NOT WITH Vtx3BodyDATA) - mcfullkfvtx3bodylabel::McParticleId); -using McFullKFVtx3BodyLabel = McFullKFVtx3BodyLabels::iterator; } // namespace o2::aod #endif // PWGLF_DATAMODEL_VTX3BODYTABLES_H_ diff --git a/PWGLF/DataModel/cascqaanalysis.h b/PWGLF/DataModel/cascqaanalysis.h index ea451559da5..efe98908517 100644 --- a/PWGLF/DataModel/cascqaanalysis.h +++ b/PWGLF/DataModel/cascqaanalysis.h @@ -100,6 +100,8 @@ DECLARE_SOA_COLUMN(IsPrimary, isPrimary, int); //! -1 unkn DECLARE_SOA_COLUMN(BachBaryonCosPA, bachBaryonCosPA, float); //! avoid bach-baryon correlated inv mass structure in analysis DECLARE_SOA_COLUMN(BachBaryonDCAxyToPV, bachBaryonDCAxyToPV, float); //! avoid bach-baryon correlated inv mass structure in analysis DECLARE_SOA_COLUMN(EventSelFilterBitMask, eventSelFilterBitMask, uint8_t); +DECLARE_SOA_COLUMN(GenPt, genPt, float); +DECLARE_SOA_COLUMN(GenY, genY, float); DECLARE_SOA_DYNAMIC_COLUMN(IsINEL, isINEL, //! True if the Event belongs to the INEL event class [](uint8_t flags) -> bool { return (flags & EvFlags::EvINEL) == EvFlags::EvINEL; }); @@ -117,14 +119,19 @@ DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); DECLARE_SOA_COLUMN(IsNoCollInTimeRange, isNoCollInTimeRange, bool); DECLARE_SOA_COLUMN(IsNoCollInRof, isNoCollInRof, bool); +DECLARE_SOA_COLUMN(HasEventPlane, hasEventPlane, bool); +DECLARE_SOA_COLUMN(HasSpectatorPlane, hasSpectatorPlane, bool); DECLARE_SOA_COLUMN(Sign, sign, int16_t); DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(Eta, eta, float); DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(MassLambda, masslambda, float); DECLARE_SOA_COLUMN(MassXi, massxi, float); DECLARE_SOA_COLUMN(MassOmega, massomega, float); DECLARE_SOA_COLUMN(V2CEP, v2CEP, float); DECLARE_SOA_COLUMN(V2CSP, v2CSP, float); +DECLARE_SOA_COLUMN(V1SPzdcA, v1SPzdcA, float); +DECLARE_SOA_COLUMN(V1SPzdcC, v1SPzdcC, float); DECLARE_SOA_COLUMN(PsiT0C, psiT0C, float); DECLARE_SOA_COLUMN(BDTResponseXi, bdtResponseXi, float); DECLARE_SOA_COLUMN(BDTResponseOmega, bdtResponseOmega, float); @@ -153,6 +160,8 @@ DECLARE_SOA_TABLE(MyCascades, "AOD", "MYCASCADES", o2::soa::Index<>, mycascades::McPdgCode, mycascades::IsPrimary, mycascades::BachBaryonCosPA, mycascades::BachBaryonDCAxyToPV, mycascades::EventSelFilterBitMask, + mycascades::GenPt, + mycascades::GenY, mycascades::IsINEL, mycascades::IsINELgt0, mycascades::IsINELgt1); @@ -162,7 +171,7 @@ DECLARE_SOA_TABLE(CascTraining, "AOD", "CascTraining", o2::soa::Index<>, mycascades::DCABachToPV, mycascades::DCACascDaughters, mycascades::DCAV0Daughters, mycascades::DCAV0ToPV, mycascades::BachBaryonCosPA, mycascades::BachBaryonDCAxyToPV, mycascades::McPdgCode); DECLARE_SOA_TABLE(CascAnalysis, "AOD", "CascAnalysis", o2::soa::Index<>, - cascadesflow::CentFT0C, cascadesflow::IsNoCollInTimeRange, cascadesflow::IsNoCollInRof, cascadesflow::Sign, cascadesflow::Pt, cascadesflow::Eta, cascadesflow::Phi, cascadesflow::MassXi, cascadesflow::MassOmega, cascadesflow::V2CSP, cascadesflow::V2CEP, cascadesflow::PsiT0C, cascadesflow::BDTResponseXi, cascadesflow::BDTResponseOmega, cascadesflow::CosThetaStarLambdaFromOmega, cascadesflow::CosThetaStarLambdaFromXi, cascadesflow::CosThetaStarProton, mycascades::McPdgCode); + cascadesflow::CentFT0C, cascadesflow::IsNoCollInTimeRange, cascadesflow::IsNoCollInRof, cascadesflow::HasEventPlane, cascadesflow::HasSpectatorPlane, cascadesflow::Sign, cascadesflow::Pt, cascadesflow::Eta, cascadesflow::Phi, cascadesflow::MassLambda, cascadesflow::MassXi, cascadesflow::MassOmega, cascadesflow::V2CSP, cascadesflow::V2CEP, cascadesflow::V1SPzdcA, cascadesflow::V1SPzdcC, cascadesflow::PsiT0C, cascadesflow::BDTResponseXi, cascadesflow::BDTResponseOmega, cascadesflow::CosThetaStarLambdaFromOmega, cascadesflow::CosThetaStarLambdaFromXi, cascadesflow::CosThetaStarProton, mycascades::McPdgCode); namespace myMCcascades { diff --git a/PWGLF/DataModel/lambdaJetpolarization.h b/PWGLF/DataModel/lambdaJetpolarization.h new file mode 100644 index 00000000000..41bd7e26b15 --- /dev/null +++ b/PWGLF/DataModel/lambdaJetpolarization.h @@ -0,0 +1,81 @@ +// 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. +/// +/// \brief QA task for lambda polarization induced by jet analysis using derived data +/// +/// \author Youpeng Su (yousu@cern.ch) + +#ifndef PWGLF_DATAMODEL_LAMBDAJETPOLARIZATION_H_ +#define PWGLF_DATAMODEL_LAMBDAJETPOLARIZATION_H_ + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "TRandom.h" +#include "Math/Vector4D.h" +#include "Math/Boost.h" + +namespace o2::aod +{ +DECLARE_SOA_TABLE(MyCollisions, "AOD", "MYCOLLISION", //! vertex information of collision + o2::soa::Index<>, collision::PosZ); +using MyCollision = MyCollisions::iterator; + +DECLARE_SOA_TABLE(MyCollisionsV0, "AOD", "MYCOLLISIONV0", //! vertex information of collision + o2::soa::Index<>, collision::PosX); +using MyCollisionV0s = MyCollisionsV0::iterator; + +namespace myTable +{ +DECLARE_SOA_INDEX_COLUMN(MyCollision, mycollision); +DECLARE_SOA_COLUMN(MyCollisionV0, mycollisionv0, 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(V0pT, v0pt, 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); +DECLARE_SOA_COLUMN(MyCollisionJet, mycollisionjet, Int_t); +DECLARE_SOA_COLUMN(Jetpx, jetpx, Float_t); +DECLARE_SOA_COLUMN(Jetpy, jetpy, Float_t); +DECLARE_SOA_COLUMN(Jetpz, jetpz, Float_t); +DECLARE_SOA_COLUMN(JetpT, jetpt, Float_t); +DECLARE_SOA_COLUMN(MyCollisionLeadingJet, mycollisionleadingjet, Int_t); +DECLARE_SOA_COLUMN(LeadingJetpx, leadingjetpx, Float_t); +DECLARE_SOA_COLUMN(LeadingJetpy, leadingjetpy, Float_t); +DECLARE_SOA_COLUMN(LeadingJetpz, leadingjetpz, Float_t); +DECLARE_SOA_COLUMN(LeadingJetpT, leadingjetpt, Float_t); + +} // namespace myTable + +DECLARE_SOA_TABLE(MyTable, "AOD", "MYTABLE", o2::soa::Index<>, + myTable::MyCollisionId, myTable::MyCollisionV0, myTable::V0px, myTable::V0py, myTable::V0pz, myTable::V0pT, myTable::V0Lambdamass, + myTable::V0protonpx, myTable::V0protonpy, myTable::V0protonpz); + +DECLARE_SOA_TABLE(MyTableAnti, "AOD", "MYTABLEAnti", o2::soa::Index<>, + myTable::MyCollisionId, myTable::MyCollisionV0, myTable::V0px, myTable::V0py, myTable::V0pz, myTable::V0pT, myTable::V0Lambdamass, + myTable::V0protonpx, myTable::V0protonpy, myTable::V0protonpz); + +DECLARE_SOA_TABLE(MyTableJet, "AOD", "MYTABLEJet", o2::soa::Index<>, + myTable::MyCollisionId, myTable::MyCollisionJet, myTable::Jetpx, myTable::Jetpy, myTable::Jetpz, myTable::JetpT); + +DECLARE_SOA_TABLE(MyTableLeadingJet, "AOD", "LeadingJet", o2::soa::Index<>, myTable::MyCollisionId, myTable::MyCollisionLeadingJet, myTable::LeadingJetpx, myTable::LeadingJetpy, myTable::LeadingJetpz, myTable::LeadingJetpT); + +} // namespace o2::aod + +#endif // PWGLF_DATAMODEL_LAMBDAJETPOLARIZATION_H_ diff --git a/PWGLF/DataModel/pidTOFGeneric.h b/PWGLF/DataModel/pidTOFGeneric.h deleted file mode 100644 index b43d4ecc9ff..00000000000 --- a/PWGLF/DataModel/pidTOFGeneric.h +++ /dev/null @@ -1,179 +0,0 @@ -// 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. - -#ifndef PWGLF_DATAMODEL_PIDTOFGENERIC_H_ -#define PWGLF_DATAMODEL_PIDTOFGENERIC_H_ -#include "CommonDataFormat/InteractionRecord.h" -#include "Common/Core/PID/PIDTOF.h" - -namespace o2::aod -{ -namespace evtime -{ - -DECLARE_SOA_COLUMN(EvTime, evTime, float); //! Event time. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C -DECLARE_SOA_COLUMN(EvTimeErr, evTimeErr, float); //! Error of event time. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C -DECLARE_SOA_COLUMN(EvTimeTOF, evTimeTOF, float); //! Event time computed with the TOF detector -DECLARE_SOA_COLUMN(EvTimeTOFErr, evTimeTOFErr, float); //! Error of the event time computed with the TOF detector -DECLARE_SOA_COLUMN(EvTimeFT0, evTimeFT0, float); //! Event time computed with the FT0 detector -DECLARE_SOA_COLUMN(EvTimeFT0Err, evTimeFT0Err, float); //! Error of the event time computed with the FT0 detector -} // namespace evtime - -DECLARE_SOA_TABLE(EvTimeTOFFT0, "AOD", "EvTimeTOFFT0", //! Table of the event time. One entry per collision. - evtime::EvTime, - evtime::EvTimeErr, - evtime::EvTimeTOF, - evtime::EvTimeTOFErr, - evtime::EvTimeFT0, - evtime::EvTimeFT0Err); - -namespace tracktime -{ - -DECLARE_SOA_COLUMN(EvTimeForTrack, evTimeForTrack, float); //! Event time. Removed the bias for the specific track -DECLARE_SOA_COLUMN(EvTimeErrForTrack, evTimeErrForTrack, float); //! Error of event time. Removed the bias for the specific track -} // namespace tracktime - -DECLARE_SOA_TABLE(EvTimeTOFFT0ForTrack, "AOD", "EvTimeForTrack", //! Table of the event time. One entry per track. - tracktime::EvTimeForTrack, - tracktime::EvTimeErrForTrack); - -namespace pidtofgeneric -{ - -static constexpr float kCSPEED = TMath::C() * 1.0e2f * 1.0e-12f; // c in cm/ps - -template -class TofPidNewCollision -{ - public: - TofPidNewCollision() = default; - ~TofPidNewCollision() = default; - - o2::pid::tof::TOFResoParamsV2 mRespParamsV2; - o2::track::PID::ID pidType; - - template - using ResponseImplementation = o2::pid::tof::ExpTimes; - static constexpr auto responseEl = ResponseImplementation(); - static constexpr auto responseMu = ResponseImplementation(); - static constexpr auto responsePi = ResponseImplementation(); - static constexpr auto responseKa = ResponseImplementation(); - static constexpr auto responsePr = ResponseImplementation(); - static constexpr auto responseDe = ResponseImplementation(); - static constexpr auto responseTr = ResponseImplementation(); - static constexpr auto responseHe = ResponseImplementation(); - static constexpr auto responseAl = ResponseImplementation(); - - void SetParams(o2::pid::tof::TOFResoParamsV2 const& para) - { - mRespParamsV2.setParameters(para); - } - - void SetPidType(o2::track::PID::ID pidId) - { - pidType = pidId; - } - - template - float GetTOFNSigma(o2::track::PID::ID pidId, TTrack const& track, TCollision const& originalcol, TCollision const& correctedcol, bool EnableBCAO2D = true); - - template - float GetTOFNSigma(TTrack const& track, TCollision const& originalcol, TCollision const& correctedcol, bool EnableBCAO2D = true); -}; - -template -template -float TofPidNewCollision::GetTOFNSigma(o2::track::PID::ID pidId, TTrack const& track, TCollision const& originalcol, TCollision const& correctedcol, bool EnableBCAO2D) -{ - float mMassHyp = o2::track::pid_constants::sMasses2Z[track.pidForTracking()]; - float expTime = track.length() * sqrt((mMassHyp * mMassHyp) + (track.tofExpMom() * track.tofExpMom())) / (kCSPEED * track.tofExpMom()); // L*E/(p*c) = L/v - - float evTime = correctedcol.evTime(); - float evTimeErr = correctedcol.evTimeErr(); - float tofsignal = track.trackTime() * 1000 + expTime; // in ps - float expSigma, tofNsigma; - - if (originalcol.globalIndex() == correctedcol.globalIndex()) { - evTime = track.evTimeForTrack(); - evTimeErr = track.evTimeErrForTrack(); - } else { - if (EnableBCAO2D) { - auto originalbc = originalcol.template bc_as(); - auto correctedbc = correctedcol.template bc_as(); - o2::InteractionRecord originalIR = o2::InteractionRecord::long2IR(originalbc.globalBC()); - o2::InteractionRecord correctedIR = o2::InteractionRecord::long2IR(correctedbc.globalBC()); - tofsignal += originalIR.differenceInBCNS(correctedIR) * 1000; - } else { - auto originalbc = originalcol.template foundBC_as(); - auto correctedbc = correctedcol.template foundBC_as(); - o2::InteractionRecord originalIR = o2::InteractionRecord::long2IR(originalbc.globalBC()); - o2::InteractionRecord correctedIR = o2::InteractionRecord::long2IR(correctedbc.globalBC()); - tofsignal += originalIR.differenceInBCNS(correctedIR) * 1000; - } - } - - switch (pidId) { - case 0: - expSigma = responseEl.GetExpectedSigma(mRespParamsV2, track, tofsignal, evTimeErr); - tofNsigma = (tofsignal - evTime - responseEl.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - break; - case 1: - expSigma = responseMu.GetExpectedSigma(mRespParamsV2, track, tofsignal, evTimeErr); - tofNsigma = (tofsignal - evTime - responseMu.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - break; - case 2: - expSigma = responsePi.GetExpectedSigma(mRespParamsV2, track, tofsignal, evTimeErr); - tofNsigma = (tofsignal - evTime - responsePi.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - break; - case 3: - expSigma = responseKa.GetExpectedSigma(mRespParamsV2, track, tofsignal, evTimeErr); - tofNsigma = (tofsignal - evTime - responseKa.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - break; - case 4: - expSigma = responsePr.GetExpectedSigma(mRespParamsV2, track, tofsignal, evTimeErr); - tofNsigma = (tofsignal - evTime - responsePr.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - break; - case 5: - expSigma = responseDe.GetExpectedSigma(mRespParamsV2, track, tofsignal, evTimeErr); - tofNsigma = (tofsignal - evTime - responseDe.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - break; - case 6: - expSigma = responseTr.GetExpectedSigma(mRespParamsV2, track, tofsignal, evTimeErr); - tofNsigma = (tofsignal - evTime - responseTr.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - break; - case 7: - expSigma = responseHe.GetExpectedSigma(mRespParamsV2, track, tofsignal, evTimeErr); - tofNsigma = (tofsignal - evTime - responseHe.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - break; - case 8: - expSigma = responseAl.GetExpectedSigma(mRespParamsV2, track, tofsignal, evTimeErr); - tofNsigma = (tofsignal - evTime - responseAl.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - break; - default: - LOG(fatal) << "Wrong particle ID in TofPidSecondary class"; - return -999; - } - - return tofNsigma; -} - -template -template -float TofPidNewCollision::GetTOFNSigma(TTrack const& track, TCollision const& originalcol, TCollision const& correctedcol, bool EnableBCAO2D) -{ - return GetTOFNSigma(pidType, track, originalcol, correctedcol, EnableBCAO2D); -} - -} // namespace pidtofgeneric -} // namespace o2::aod - -#endif // PWGLF_DATAMODEL_PIDTOFGENERIC_H_ diff --git a/PWGLF/DataModel/spectraTOF.h b/PWGLF/DataModel/spectraTOF.h index d6cf346b862..9cf4b789295 100644 --- a/PWGLF/DataModel/spectraTOF.h +++ b/PWGLF/DataModel/spectraTOF.h @@ -48,6 +48,8 @@ static constexpr const char* pN[Np] = {"el", "mu", "pi", "ka", "pr", "de", "tr", static constexpr const char* cN[NCharges] = {"pos", "neg"}; static constexpr const char* pTCharge[NpCharge] = {"e^{-}", "#mu^{-}", "#pi^{+}", "K^{+}", "p", "d", "t", "{}^{3}He", "#alpha", "e^{+}", "#mu^{+}", "#pi^{-}", "K^{-}", "#bar{p}", "#bar{d}", "#bar{t}", "{}^{3}#bar{He}", "#bar{#alpha}"}; +static constexpr const char* pNCharge[NpCharge] = {"pos/el", "pos/mu", "pos/pi", "pos/ka", "pos/pr", "pos/de", "pos/tr", "pos/he", "pos/al", + "neg/el", "neg/mu", "neg/pi", "neg/ka", "neg/pr", "neg/de", "neg/tr", "neg/he", "neg/al"}; static constexpr int PDGs[NpCharge] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton, 1000010020, 1000010030, 1000020030, 1000020040, -kElectron, -kMuonMinus, -kPiPlus, -kKPlus, -kProton, -1000010020, -1000010030, -1000020030, -1000020040}; diff --git a/PWGLF/DataModel/v0qaanalysis.h b/PWGLF/DataModel/v0qaanalysis.h index 9e4efd7c3c6..c2b26d3054f 100644 --- a/PWGLF/DataModel/v0qaanalysis.h +++ b/PWGLF/DataModel/v0qaanalysis.h @@ -10,7 +10,6 @@ // or submit itself to any jurisdiction. /// /// \brief QA task for V0 analysis using derived data -/// /// \author Francesca Ercolessi (francesca.ercolessi@cern.ch) #ifndef PWGLF_DATAMODEL_V0QAANALYSIS_H_ @@ -22,8 +21,9 @@ namespace o2::aod namespace myv0candidates { -DECLARE_SOA_INDEX_COLUMN(Collision, collision); DECLARE_SOA_COLUMN(V0Pt, v0pt, float); +DECLARE_SOA_COLUMN(V0MotherPt, v0motherpt, float); +DECLARE_SOA_COLUMN(V0MCRap, v0mcrap, float); DECLARE_SOA_COLUMN(RapLambda, raplambda, float); DECLARE_SOA_COLUMN(RapK0Short, rapk0short, float); DECLARE_SOA_COLUMN(MassLambda, masslambda, float); @@ -36,8 +36,6 @@ DECLARE_SOA_COLUMN(V0DCANegToPV, v0dcanegtopv, float); DECLARE_SOA_COLUMN(V0DCAV0Daughters, v0dcav0daughters, float); DECLARE_SOA_COLUMN(V0PosEta, v0poseta, float); DECLARE_SOA_COLUMN(V0NegEta, v0negeta, float); -DECLARE_SOA_COLUMN(V0PosPhi, v0posphi, float); -DECLARE_SOA_COLUMN(V0NegPhi, v0negphi, float); DECLARE_SOA_COLUMN(V0PosITSHits, v0positshits, float); DECLARE_SOA_COLUMN(V0NegITSHits, v0negitshits, float); DECLARE_SOA_COLUMN(CtauLambda, ctaulambda, float); @@ -54,28 +52,44 @@ DECLARE_SOA_COLUMN(NTOFSigmaPosPi, ntofsigmapospi, float); DECLARE_SOA_COLUMN(PosHasTOF, poshastof, float); DECLARE_SOA_COLUMN(NegHasTOF, neghastof, float); DECLARE_SOA_COLUMN(PDGCode, pdgcode, int); +DECLARE_SOA_COLUMN(PDGCodeMother, pdgcodemother, int); +DECLARE_SOA_COLUMN(IsDauK0Short, isdauk0short, bool); +DECLARE_SOA_COLUMN(IsDauLambda, isdaulambda, bool); +DECLARE_SOA_COLUMN(IsDauAntiLambda, isdauantilambda, bool); DECLARE_SOA_COLUMN(IsPhysicalPrimary, isphysprimary, bool); DECLARE_SOA_COLUMN(MultFT0M, multft0m, float); -DECLARE_SOA_COLUMN(MultFV0A, multfv0a, float); +DECLARE_SOA_COLUMN(MultNGlobals, multnglobals, float); DECLARE_SOA_COLUMN(EvFlag, evflag, int); DECLARE_SOA_COLUMN(Alpha, alpha, float); DECLARE_SOA_COLUMN(QtArm, qtarm, float); +DECLARE_SOA_COLUMN(V0PosTPCCrossedRows, v0postpcCrossedRows, float); +DECLARE_SOA_COLUMN(V0PosTPCNClsShared, v0postpcNClsShared, float); +DECLARE_SOA_COLUMN(V0PosITSChi2NCl, v0positsChi2NCl, float); +DECLARE_SOA_COLUMN(V0PosTPCChi2NCl, v0postpcChi2NCl, float); +DECLARE_SOA_COLUMN(V0NegTPCCrossedRows, v0negtpcCrossedRows, float); +DECLARE_SOA_COLUMN(V0NegTPCNClsShared, v0negtpcNClsShared, float); +DECLARE_SOA_COLUMN(V0NegITSChi2NCl, v0negitsChi2NCl, float); +DECLARE_SOA_COLUMN(V0NegTPCChi2NCl, v0negtpcChi2NCl, float); } // namespace myv0candidates -DECLARE_SOA_TABLE(MyV0Candidates, "AOD", "MYV0CANDIDATES", o2::soa::Index<>, - myv0candidates::CollisionId, myv0candidates::V0Pt, myv0candidates::RapLambda, myv0candidates::RapK0Short, +DECLARE_SOA_TABLE(MyV0Candidates, "AOD", "MYV0CANDIDATES", + myv0candidates::V0Pt, myv0candidates::V0MotherPt, myv0candidates::V0MCRap, myv0candidates::RapLambda, myv0candidates::RapK0Short, myv0candidates::MassLambda, myv0candidates::MassAntiLambda, myv0candidates::MassK0Short, myv0candidates::V0Radius, myv0candidates::V0CosPA, myv0candidates::V0DCAPosToPV, myv0candidates::V0DCANegToPV, myv0candidates::V0DCAV0Daughters, - myv0candidates::V0PosEta, myv0candidates::V0NegEta, myv0candidates::V0PosPhi, myv0candidates::V0NegPhi, + myv0candidates::V0PosEta, myv0candidates::V0NegEta, myv0candidates::V0PosITSHits, myv0candidates::V0NegITSHits, myv0candidates::CtauLambda, myv0candidates::CtauAntiLambda, myv0candidates::CtauK0Short, myv0candidates::NTPCSigmaNegPr, myv0candidates::NTPCSigmaPosPr, myv0candidates::NTPCSigmaNegPi, myv0candidates::NTPCSigmaPosPi, myv0candidates::NTOFSigmaNegPr, myv0candidates::NTOFSigmaPosPr, myv0candidates::NTOFSigmaNegPi, myv0candidates::NTOFSigmaPosPi, myv0candidates::PosHasTOF, myv0candidates::NegHasTOF, - myv0candidates::PDGCode, myv0candidates::IsPhysicalPrimary, - myv0candidates::MultFT0M, myv0candidates::MultFV0A, - myv0candidates::EvFlag, myv0candidates::Alpha, myv0candidates::QtArm); + myv0candidates::PDGCode, myv0candidates::PDGCodeMother, myv0candidates::IsDauK0Short, myv0candidates::IsDauLambda, myv0candidates::IsDauAntiLambda, myv0candidates::IsPhysicalPrimary, + myv0candidates::MultFT0M, myv0candidates::MultNGlobals, + myv0candidates::EvFlag, myv0candidates::Alpha, myv0candidates::QtArm, + myv0candidates::V0PosTPCCrossedRows, myv0candidates::V0PosTPCNClsShared, + myv0candidates::V0PosITSChi2NCl, myv0candidates::V0PosTPCChi2NCl, + myv0candidates::V0NegTPCCrossedRows, myv0candidates::V0NegTPCNClsShared, + myv0candidates::V0NegITSChi2NCl, myv0candidates::V0NegTPCChi2NCl); } // namespace o2::aod diff --git a/PWGLF/TableProducer/Common/epvector.cxx b/PWGLF/TableProducer/Common/epvector.cxx index c5ceda81949..6b79401dcd7 100644 --- a/PWGLF/TableProducer/Common/epvector.cxx +++ b/PWGLF/TableProducer/Common/epvector.cxx @@ -19,42 +19,46 @@ /// // C++/ROOT includes. +#include #include +#include + #include +#include #include #include -#include -#include -#include // o2Physics includes. -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/Core/TrackSelection.h" -#include "Framework/ASoAHelpers.h" #include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/PhysicsConstants.h" #include "FT0Base/Geometry.h" #include "FV0Base/Geometry.h" -#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + #include "TF1.h" // #include "Common/Core/EventPlaneHelper.h" // #include "Common/DataModel/Qvectors.h" // o2 includes. -#include "CCDB/CcdbApi.h" #include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" #include "DetectorsCommonDataFormats/AlignParam.h" using namespace o2; @@ -93,10 +97,16 @@ struct epvector { Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; Configurable cfgITScluster{"cfgITScluster", 4, "Number of ITS cluster"}; // Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; + Configurable cfgHarmonic{"cfgHarmonic", 2, "Harmonic for event plane calculation"}; Configurable useGainCallib{"useGainCallib", true, "use gain calibration"}; Configurable useRecentere{"useRecentere", true, "use Recentering"}; Configurable useShift{"useShift", false, "use Shift"}; Configurable useShift2{"useShift2", false, "use Shift for others"}; + Configurable useEventSelection{"useEventSelection", true, "Apply event selection centrality wise"}; + Configurable useTimeFrameCut{"useTimeFrameCut", true, "Reject Time Frame border events"}; + Configurable useITSFrameCut{"useITSFrameCut", true, "Reject ITS RO Frame border events"}; + Configurable usePileupCut{"usePileupCut", false, "Reject same bunch pileup"}; + Configurable useITSLayerCut{"useITSLayerCut", false, "Require good ITS layers"}; Configurable ConfGainPath{"ConfGainPath", "Users/s/skundu/My/Object/test100", "Path to gain calibration"}; Configurable ConfRecentere{"ConfRecentere", "Users/s/skundu/My/Object/Finaltest2/recenereall", "Path for recentere"}; Configurable ConfShift{"ConfShift", "Users/s/skundu/My/Object/Finaltest2/recenereall", "Path for Shift"}; @@ -114,7 +124,7 @@ struct epvector { void init(o2::framework::InitContext&) { - std::vector occupancyBinning = {0.0, 500.0, 1000.0, 1500.0, 2000.0, 3000.0, 4000.0, 5000.0, 50000.0}; + std::vector occupancyBinning = {-0.5, 500.0, 1000.0, 1500.0, 2000.0, 3000.0, 4000.0, 5000.0, 50000.0}; const AxisSpec centAxis{configAxisCentrality, "V0M (%)"}; // AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; @@ -228,26 +238,28 @@ struct epvector { return TMath::ATan2(chPos.Y() + offsetY, chPos.X() + offsetX); } - double GetPhiInRange(double phi) + double GetPhiInRange(double phi, double harmonic = 2) { double result = phi; + double period = 2. * TMath::Pi() / harmonic; while (result < 0) { - result = result + 2. * TMath::Pi() / 2; + result = result + period; } - while (result > 2. * TMath::Pi() / 2) { - result = result - 2. * TMath::Pi() / 2; + while (result > period) { + result = result - period; } return result; } - double GetDeltaPsiSubInRange(double psi1, double psi2) + double GetDeltaPsiSubInRange(double psi1, double psi2, double harmonic = 2) { double delta = psi1 - psi2; - if (TMath::Abs(delta) > TMath::Pi() / 2) { + double period = TMath::Pi() / harmonic; + if (TMath::Abs(delta) > period) { if (delta > 0.) - delta -= 2. * TMath::Pi() / 2; + delta -= 2. * period; else - delta += 2. * TMath::Pi() / 2; + delta += 2. * period; } return delta; } @@ -297,7 +309,7 @@ struct epvector { auto qyTPCL = 0.0; auto qxTPCR = 0.0; auto qyTPCR = 0.0; - if (coll.sel8() && centrality < cfgCutCentrality && TMath::Abs(vz) < cfgCutVertex && coll.has_foundFT0() && eventSelected(coll, centrality) && coll.selection_bit(aod::evsel::kNoTimeFrameBorder) && coll.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + if (coll.sel8() && centrality < cfgCutCentrality && TMath::Abs(vz) < cfgCutVertex && coll.has_foundFT0() && (!useEventSelection || eventSelected(coll, centrality)) && (!useTimeFrameCut || coll.selection_bit(aod::evsel::kNoTimeFrameBorder)) && (!useITSFrameCut || coll.selection_bit(aod::evsel::kNoITSROFrameBorder)) && (!usePileupCut || coll.selection_bit(aod::evsel::kNoSameBunchPileup)) && (!useITSLayerCut || coll.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll))) { triggerevent = true; if (useGainCallib && (currentRunNumber != lastRunNumber)) { gainprofile = ccdb->getForTimeStamp(ConfGainPath.value, bc.timestamp()); @@ -320,12 +332,11 @@ struct epvector { float ampl = gainequal * ft0.amplitudeA()[iChA]; histos.fill(HIST("FT0Amp"), chanelid, ampl); auto phiA = GetPhiFT0(chanelid, offsetFT0Ax, offsetFT0Ay); - qxFT0A = qxFT0A + ampl * TMath::Cos(2.0 * phiA); - qyFT0A = qyFT0A + ampl * TMath::Sin(2.0 * phiA); + qxFT0A = qxFT0A + ampl * TMath::Cos(cfgHarmonic.value * phiA); + qyFT0A = qyFT0A + ampl * TMath::Sin(cfgHarmonic.value * phiA); } for (std::size_t iChC = 0; iChC < ft0.channelC().size(); iChC++) { auto chanelid = ft0.channelC()[iChC] + 96; - // printf("Offset for FT0A: x = %d y = %d\n", chanelid, chanelid-96); auto gainequal = 1.0; if (useGainCallib) { gainequal = 1 / gainprofile->GetBinContent(gainprofile->FindBin(chanelid)); @@ -333,23 +344,23 @@ struct epvector { float ampl = gainequal * ft0.amplitudeC()[iChC]; histos.fill(HIST("FT0Amp"), chanelid, ampl); auto phiC = GetPhiFT0(chanelid, offsetFT0Cx, offsetFT0Cy); - qxFT0C = qxFT0C + ampl * TMath::Cos(2.0 * phiC); - qyFT0C = qyFT0C + ampl * TMath::Sin(2.0 * phiC); + qxFT0C = qxFT0C + ampl * TMath::Cos(cfgHarmonic.value * phiC); + qyFT0C = qyFT0C + ampl * TMath::Sin(cfgHarmonic.value * phiC); } for (auto& trk : tracks) { if (!selectionTrack(trk) || TMath::Abs(trk.eta()) > 0.8 || trk.pt() > cfgCutPTMax || TMath::Abs(trk.eta()) < cfgMinEta) { continue; } - qxTPC = qxTPC + trk.pt() * TMath::Cos(2.0 * trk.phi()); - qyTPC = qyTPC + trk.pt() * TMath::Sin(2.0 * trk.phi()); + qxTPC = qxTPC + trk.pt() * TMath::Cos(cfgHarmonic.value * trk.phi()); + qyTPC = qyTPC + trk.pt() * TMath::Sin(cfgHarmonic.value * trk.phi()); if (trk.eta() < 0.0) { - qxTPCL = qxTPCL + trk.pt() * TMath::Cos(2.0 * trk.phi()); - qyTPCL = qyTPCL + trk.pt() * TMath::Sin(2.0 * trk.phi()); + qxTPCL = qxTPCL + trk.pt() * TMath::Cos(cfgHarmonic.value * trk.phi()); + qyTPCL = qyTPCL + trk.pt() * TMath::Sin(cfgHarmonic.value * trk.phi()); } if (trk.eta() > 0.0) { - qxTPCR = qxTPCR + trk.pt() * TMath::Cos(2.0 * trk.phi()); - qyTPCR = qyTPCR + trk.pt() * TMath::Sin(2.0 * trk.phi()); + qxTPCR = qxTPCR + trk.pt() * TMath::Cos(cfgHarmonic.value * trk.phi()); + qyTPCR = qyTPCR + trk.pt() * TMath::Sin(cfgHarmonic.value * trk.phi()); } } if (useRecentere && (currentRunNumber != lastRunNumber)) { @@ -367,11 +378,11 @@ struct epvector { qxTPCR = (qxTPCR - hrecentere->GetBinContent(hrecentere->FindBin(centrality, 8.5))) / hrecentere->GetBinError(hrecentere->FindBin(centrality, 8.5)); qyTPCR = (qyTPCR - hrecentere->GetBinContent(hrecentere->FindBin(centrality, 9.5))) / hrecentere->GetBinError(hrecentere->FindBin(centrality, 9.5)); } - psiFT0C = 0.5 * TMath::ATan2(qyFT0C, qxFT0C); - psiFT0A = 0.5 * TMath::ATan2(qyFT0A, qxFT0A); - psiTPC = 0.5 * TMath::ATan2(qyTPC, qxTPC); - psiTPCL = 0.5 * TMath::ATan2(qyTPCL, qxTPCL); - psiTPCR = 0.5 * TMath::ATan2(qyTPCR, qxTPCR); + psiFT0C = (1.0 / cfgHarmonic.value) * TMath::ATan2(qyFT0C, qxFT0C); + psiFT0A = (1.0 / cfgHarmonic.value) * TMath::ATan2(qyFT0A, qxFT0A); + psiTPC = (1.0 / cfgHarmonic.value) * TMath::ATan2(qyTPC, qxTPC); + psiTPCL = (1.0 / cfgHarmonic.value) * TMath::ATan2(qyTPCL, qxTPCL); + psiTPCR = (1.0 / cfgHarmonic.value) * TMath::ATan2(qyTPCR, qxTPCR); if (useShift && (currentRunNumber != lastRunNumber)) { shiftprofile = ccdb->getForTimeStamp(ConfShift.value, bc.timestamp()); @@ -391,7 +402,7 @@ struct epvector { for (int ishift = 1; ishift <= 10; ishift++) { auto coeffshiftxFT0C = shiftprofile->GetBinContent(shiftprofile->FindBin(centrality, 0.5, ishift - 0.5)); auto coeffshiftyFT0C = shiftprofile->GetBinContent(shiftprofile->FindBin(centrality, 1.5, ishift - 0.5)); - deltapsiFT0C = deltapsiFT0C + ((1 / (1.0 * ishift)) * (-coeffshiftxFT0C * TMath::Cos(ishift * 2.0 * psiFT0C) + coeffshiftyFT0C * TMath::Sin(ishift * 2.0 * psiFT0C))); + deltapsiFT0C = deltapsiFT0C + ((1 / (1.0 * ishift)) * (-coeffshiftxFT0C * TMath::Cos(ishift * cfgHarmonic.value * psiFT0C) + coeffshiftyFT0C * TMath::Sin(ishift * cfgHarmonic.value * psiFT0C))); if (useShift2) { auto coeffshiftxFT0A = shiftprofile2->GetBinContent(shiftprofile2->FindBin(centrality, 0.5, ishift - 0.5)); auto coeffshiftyFT0A = shiftprofile2->GetBinContent(shiftprofile2->FindBin(centrality, 1.5, ishift - 0.5)); @@ -404,10 +415,10 @@ struct epvector { auto coeffshiftxTPCR = shiftprofile5->GetBinContent(shiftprofile5->FindBin(centrality, 0.5, ishift - 0.5)); auto coeffshiftyTPCR = shiftprofile5->GetBinContent(shiftprofile5->FindBin(centrality, 1.5, ishift - 0.5)); - deltapsiFT0A = deltapsiFT0A + ((1 / (1.0 * ishift)) * (-coeffshiftxFT0A * TMath::Cos(ishift * 2.0 * psiFT0A) + coeffshiftyFT0A * TMath::Sin(ishift * 2.0 * psiFT0A))); - deltapsiTPC = deltapsiTPC + ((1 / (1.0 * ishift)) * (-coeffshiftxTPC * TMath::Cos(ishift * 2.0 * psiTPC) + coeffshiftyTPC * TMath::Sin(ishift * 2.0 * psiTPC))); - deltapsiTPCL = deltapsiTPCL + ((1 / (1.0 * ishift)) * (-coeffshiftxTPCL * TMath::Cos(ishift * 2.0 * psiTPCL) + coeffshiftyTPCL * TMath::Sin(ishift * 2.0 * psiTPCL))); - deltapsiTPCR = deltapsiTPCR + ((1 / (1.0 * ishift)) * (-coeffshiftxTPCR * TMath::Cos(ishift * 2.0 * psiTPCR) + coeffshiftyTPCR * TMath::Sin(ishift * 2.0 * psiTPCR))); + deltapsiFT0A = deltapsiFT0A + ((1 / (1.0 * ishift)) * (-coeffshiftxFT0A * TMath::Cos(ishift * cfgHarmonic.value * psiFT0A) + coeffshiftyFT0A * TMath::Sin(ishift * cfgHarmonic.value * psiFT0A))); + deltapsiTPC = deltapsiTPC + ((1 / (1.0 * ishift)) * (-coeffshiftxTPC * TMath::Cos(ishift * cfgHarmonic.value * psiTPC) + coeffshiftyTPC * TMath::Sin(ishift * cfgHarmonic.value * psiTPC))); + deltapsiTPCL = deltapsiTPCL + ((1 / (1.0 * ishift)) * (-coeffshiftxTPCL * TMath::Cos(ishift * cfgHarmonic.value * psiTPCL) + coeffshiftyTPCL * TMath::Sin(ishift * cfgHarmonic.value * psiTPCL))); + deltapsiTPCR = deltapsiTPCR + ((1 / (1.0 * ishift)) * (-coeffshiftxTPCR * TMath::Cos(ishift * cfgHarmonic.value * psiTPCR) + coeffshiftyTPCR * TMath::Sin(ishift * cfgHarmonic.value * psiTPCR))); } } psiFT0C = psiFT0C + deltapsiFT0C; @@ -432,12 +443,12 @@ struct epvector { histos.fill(HIST("QyTPCR"), centrality, qyTPCR); histos.fill(HIST("PsiTPCR"), centrality, psiTPCR); - histos.fill(HIST("ResFT0CFT0A"), centrality, TMath::Cos(2.0 * (psiFT0C - psiFT0A)), occupancy); - histos.fill(HIST("ResFT0CTPC"), centrality, TMath::Cos(2.0 * (psiFT0C - psiTPC)), occupancy); - histos.fill(HIST("ResFT0ATPC"), centrality, TMath::Cos(2.0 * (psiFT0A - psiTPC)), occupancy); - histos.fill(HIST("ResFT0CTPCL"), centrality, TMath::Cos(2.0 * (psiFT0C - psiTPCL)), occupancy); - histos.fill(HIST("ResFT0CTPCR"), centrality, TMath::Cos(2.0 * (psiFT0C - psiTPCR)), occupancy); - histos.fill(HIST("ResTPCRTPCL"), centrality, TMath::Cos(2.0 * (psiTPCR - psiTPCL)), occupancy); + histos.fill(HIST("ResFT0CFT0A"), centrality, TMath::Cos(cfgHarmonic.value * (psiFT0C - psiFT0A)), occupancy); + histos.fill(HIST("ResFT0CTPC"), centrality, TMath::Cos(cfgHarmonic.value * (psiFT0C - psiTPC)), occupancy); + histos.fill(HIST("ResFT0ATPC"), centrality, TMath::Cos(cfgHarmonic.value * (psiFT0A - psiTPC)), occupancy); + histos.fill(HIST("ResFT0CTPCL"), centrality, TMath::Cos(cfgHarmonic.value * (psiFT0C - psiTPCL)), occupancy); + histos.fill(HIST("ResFT0CTPCR"), centrality, TMath::Cos(cfgHarmonic.value * (psiFT0C - psiTPCR)), occupancy); + histos.fill(HIST("ResTPCRTPCL"), centrality, TMath::Cos(cfgHarmonic.value * (psiTPCR - psiTPCL)), occupancy); double qFT0Cmag = TMath::Sqrt(qxFT0C * qxFT0C + qyFT0C * qyFT0C); double qFT0Amag = TMath::Sqrt(qxFT0A * qxFT0A + qyFT0A * qyFT0A); @@ -451,28 +462,28 @@ struct epvector { histos.fill(HIST("QFT0C"), centrality, qFT0Cmag, occupancy); histos.fill(HIST("QFT0A"), centrality, qFT0Amag, occupancy); - histos.fill(HIST("ResFT0CFT0ASP"), centrality, qFT0Cmag * qFT0Amag * TMath::Cos(2.0 * (psiFT0C - psiFT0A)), occupancy); - histos.fill(HIST("ResFT0CTPCSP"), centrality, qFT0Cmag * qTPCmag * TMath::Cos(2.0 * (psiFT0C - psiTPC)), occupancy); - histos.fill(HIST("ResFT0ATPCSP"), centrality, qFT0Amag * qTPCmag * TMath::Cos(2.0 * (psiFT0A - psiTPC)), occupancy); - histos.fill(HIST("ResFT0CTPCLSP"), centrality, qFT0Cmag * qTPCLmag * TMath::Cos(2.0 * (psiFT0C - psiTPCL)), occupancy); - histos.fill(HIST("ResFT0CTPCRSP"), centrality, qFT0Cmag * qTPCRmag * TMath::Cos(2.0 * (psiFT0C - psiTPCR)), occupancy); - histos.fill(HIST("ResTPCRTPCLSP"), centrality, qTPCRmag * qTPCLmag * TMath::Cos(2.0 * (psiTPCR - psiTPCL)), occupancy); + histos.fill(HIST("ResFT0CFT0ASP"), centrality, qFT0Cmag * qFT0Amag * TMath::Cos(cfgHarmonic.value * (psiFT0C - psiFT0A)), occupancy); + histos.fill(HIST("ResFT0CTPCSP"), centrality, qFT0Cmag * qTPCmag * TMath::Cos(cfgHarmonic.value * (psiFT0C - psiTPC)), occupancy); + histos.fill(HIST("ResFT0ATPCSP"), centrality, qFT0Amag * qTPCmag * TMath::Cos(cfgHarmonic.value * (psiFT0A - psiTPC)), occupancy); + histos.fill(HIST("ResFT0CTPCLSP"), centrality, qFT0Cmag * qTPCLmag * TMath::Cos(cfgHarmonic.value * (psiFT0C - psiTPCL)), occupancy); + histos.fill(HIST("ResFT0CTPCRSP"), centrality, qFT0Cmag * qTPCRmag * TMath::Cos(cfgHarmonic.value * (psiFT0C - psiTPCR)), occupancy); + histos.fill(HIST("ResTPCRTPCLSP"), centrality, qTPCRmag * qTPCLmag * TMath::Cos(cfgHarmonic.value * (psiTPCR - psiTPCL)), occupancy); for (int ishift = 1; ishift <= 10; ishift++) { - histos.fill(HIST("ShiftFT0C"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * 2.0 * psiFT0C)); - histos.fill(HIST("ShiftFT0C"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * 2.0 * psiFT0C)); + histos.fill(HIST("ShiftFT0C"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * cfgHarmonic.value * psiFT0C)); + histos.fill(HIST("ShiftFT0C"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * cfgHarmonic.value * psiFT0C)); - histos.fill(HIST("ShiftFT0A"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * 2.0 * psiFT0A)); - histos.fill(HIST("ShiftFT0A"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * 2.0 * psiFT0A)); + histos.fill(HIST("ShiftFT0A"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * cfgHarmonic.value * psiFT0A)); + histos.fill(HIST("ShiftFT0A"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * cfgHarmonic.value * psiFT0A)); - histos.fill(HIST("ShiftTPC"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * 2.0 * psiTPC)); - histos.fill(HIST("ShiftTPC"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * 2.0 * psiTPC)); + histos.fill(HIST("ShiftTPC"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * cfgHarmonic.value * psiTPC)); + histos.fill(HIST("ShiftTPC"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * cfgHarmonic.value * psiTPC)); - histos.fill(HIST("ShiftTPCL"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * 2.0 * psiTPCL)); - histos.fill(HIST("ShiftTPCL"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * 2.0 * psiTPCL)); + histos.fill(HIST("ShiftTPCL"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * cfgHarmonic.value * psiTPCL)); + histos.fill(HIST("ShiftTPCL"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * cfgHarmonic.value * psiTPCL)); - histos.fill(HIST("ShiftTPCR"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * 2.0 * psiTPCR)); - histos.fill(HIST("ShiftTPCR"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * 2.0 * psiTPCR)); + histos.fill(HIST("ShiftTPCR"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * cfgHarmonic.value * psiTPCR)); + histos.fill(HIST("ShiftTPCR"), centrality, 1.5, ishift - 0.5, TMath::Cos(ishift * cfgHarmonic.value * psiTPCR)); } lastRunNumber = currentRunNumber; } diff --git a/PWGLF/TableProducer/Common/kinkBuilder.cxx b/PWGLF/TableProducer/Common/kinkBuilder.cxx index fde62514a60..eb68fe85b39 100644 --- a/PWGLF/TableProducer/Common/kinkBuilder.cxx +++ b/PWGLF/TableProducer/Common/kinkBuilder.cxx @@ -13,30 +13,31 @@ /// \brief Builder task for kink decay topologies using ITS standalone tracks for the mother /// \author Francesco Mazzaschi -#include -#include -#include -#include -#include +#include "PWGLF/DataModel/LFKinkDecayTables.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "PWGLF/Utils/svPoolCreator.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" + #include "CCDB/BasicCCDBManager.h" #include "DCAFitter/DCAFitterN.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" -#include "PWGLF/DataModel/LFParticleIdentification.h" -#include "PWGLF/Utils/svPoolCreator.h" -#include "PWGLF/DataModel/LFKinkDecayTables.h" +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -56,7 +57,7 @@ std::shared_ptr h2ClsMapPtMoth; std::shared_ptr h2ClsMapPtDaug; std::shared_ptr h2DeDxDaugSel; std::shared_ptr h2KinkAnglePt; -std::shared_ptr h2SigmaMinusMassPt; +std::shared_ptr h2MothMassPt; } // namespace struct kinkCandidate { @@ -89,9 +90,17 @@ struct kinkCandidate { struct kinkBuilder { + enum PartType { kSigmaMinus = 0, + kHypertriton, + kHyperhelium4sigma }; + Produces outputDataTable; + Produces outputDataTableUB; + Service ccdb; + Configurable hypoMoth{"hypoMoth", kSigmaMinus, "Mother particle hypothesis"}; + Configurable fillDebugTable{"fillDebugTable", false, "If true, fill the debug table with all candidates unbound"}; // Selection criteria Configurable maxDCAMothToPV{"maxDCAMothToPV", 0.1, "Max DCA of the mother to the PV"}; Configurable minDCADaugToPV{"minDCADaugToPV", 0., "Min DCA of the daughter to the PV"}; @@ -102,12 +111,14 @@ struct kinkBuilder { Configurable etaMax{"etaMax", 1., "eta daughter"}; Configurable nTPCClusMinDaug{"nTPCClusMinDaug", 80, "daug NTPC clusters cut"}; Configurable askTOFforDaug{"askTOFforDaug", false, "If true, ask for TOF signal"}; + Configurable doSVRadiusCut{"doSVRadiusCut", true, "If true, apply the cut on the radius of the secondary vertex and tracksIU"}; + Configurable updateMothTrackUsePV{"updateMothTrackUsePV", false, "If true, update the mother track parameters using the primary vertex"}; o2::vertexing::DCAFitterN<2> fitter; o2::base::MatLayerCylSet* lut = nullptr; // constants - float radToDeg = 180. / M_PI; + float radToDeg = o2::constants::math::Rad2Deg; svPoolCreator svCreator; // bethe bloch parameters @@ -118,12 +129,9 @@ struct kinkBuilder { Configurable unlikeSignBkg{"unlikeSignBkg", false, "Use unlike sign background"}; // CCDB options - Configurable inputBz{"inputBz", -999, "bz field, -999 is automatic"}; Configurable ccdbPath{"ccdbPath", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; // PDG codes @@ -141,8 +149,30 @@ struct kinkBuilder { float mBz; std::array mBBparamsDaug; + // mother and daughter tracks' properties (absolute charge and mass) + int charge = 1; + float mothMass = o2::constants::physics::MassSigmaMinus; + float chargedDauMass = o2::constants::physics::MassPiMinus; + float neutDauMass = o2::constants::physics::MassNeutron; + void init(InitContext const&) { + if (hypoMoth == kSigmaMinus) { + charge = 1; + mothMass = o2::constants::physics::MassSigmaMinus; + chargedDauMass = o2::constants::physics::MassPiMinus; + neutDauMass = o2::constants::physics::MassNeutron; + } else if (hypoMoth == kHypertriton) { + charge = 1; + mothMass = o2::constants::physics::MassHyperTriton; + chargedDauMass = o2::constants::physics::MassTriton; + neutDauMass = o2::constants::physics::MassPi0; + } else if (hypoMoth == kHyperhelium4sigma) { + charge = 2; + mothMass = o2::constants::physics::MassHyperHelium4; + chargedDauMass = o2::constants::physics::MassAlpha; + neutDauMass = o2::constants::physics::MassPi0; + } // dummy values, 1 for mother, 0 for daughter svCreator.setPDGs(1, 0); @@ -153,7 +183,6 @@ struct kinkBuilder { ccdb->setURL(ccdbPath); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); fitter.setPropagateToPCA(true); fitter.setMaxR(200.); fitter.setMinParamChange(1e-3); @@ -162,10 +191,6 @@ struct kinkBuilder { fitter.setMaxChi2(1e9); fitter.setUseAbsDCA(true); - lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); - int mat{static_cast(cfgMaterialCorrection)}; - fitter.setMatCorrType(static_cast(mat)); - svCreator.setTimeMargin(customVertexerTimeMargin); if (skipAmbiTracks) { svCreator.setSkipAmbiTracks(); @@ -174,15 +199,28 @@ struct kinkBuilder { const AxisSpec itsClusterMapAxis(128, 0, 127, "ITS cluster map"); const AxisSpec rigidityAxis{rigidityBins, "#it{p}^{TPC}/#it{z}"}; const AxisSpec ptAxis{rigidityBins, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec sigmaMassAxis{100, 1.1, 1.4, "m (GeV/#it{c}^{2})"}; const AxisSpec kinkAngleAxis{100, 0, 180, "#theta_{kink} (deg)"}; const AxisSpec dedxAxis{dedxBins, "d#it{E}/d#it{x}"}; + AxisSpec massAxis(100, 1.1, 1.4, "m (GeV/#it{c}^{2})"); + if (hypoMoth == kSigmaMinus) { + massAxis = AxisSpec{100, 1.1, 1.4, "m (GeV/#it{c}^{2})"}; + } else if (hypoMoth == kHypertriton) { + massAxis = AxisSpec{100, 2.94, 3.2, "m (GeV/#it{c}^{2})"}; + } else if (hypoMoth == kHyperhelium4sigma) { + massAxis = AxisSpec{100, 3.85, 4.25, "m (GeV/#it{c}^{2})"}; + } + h2DeDxDaugSel = qaRegistry.add("h2DeDxDaugSel", ";p_{TPC}/z (GeV/#it{c}); dE/dx", HistType::kTH2F, {rigidityAxis, dedxAxis}); h2KinkAnglePt = qaRegistry.add("h2KinkAnglePt", "; p_{T} (GeV/#it{c}); #theta_{kink} (deg)", HistType::kTH2F, {ptAxis, kinkAngleAxis}); - h2SigmaMinusMassPt = qaRegistry.add("h2SigmaMinusMassPt", "; p_{T} (GeV/#it{c}); m (GeV/#it{c}^{2})", HistType::kTH2F, {ptAxis, sigmaMassAxis}); + h2MothMassPt = qaRegistry.add("h2MothMassPt", "; p_{T} (GeV/#it{c}); m (GeV/#it{c}^{2})", HistType::kTH2F, {ptAxis, massAxis}); h2ClsMapPtMoth = qaRegistry.add("h2ClsMapPtMoth", "; p_{T} (GeV/#it{c}); ITS cluster map", HistType::kTH2F, {ptAxis, itsClusterMapAxis}); h2ClsMapPtDaug = qaRegistry.add("h2ClsMapPtDaug", "; p_{T} (GeV/#it{c}); ITS cluster map", HistType::kTH2F, {ptAxis, itsClusterMapAxis}); + + for (int i = 0; i < 5; i++) { + mBBparamsDaug[i] = cfgBetheBlochParams->get("Daughter", Form("p%i", i)); + } + mBBparamsDaug[5] = cfgBetheBlochParams->get("Daughter", "resolution"); } template @@ -220,12 +258,12 @@ struct kinkBuilder { } template - void fillCandidateData(const Tcolls& collisions, const Ttracks& tracks, aod::AmbiguousTracks const& ambiguousTracks, aod::BCsWithTimestamps const& bcs) + void fillCandidateData(const Tcolls& collisions, const Ttracks& tracks, aod::AmbiguousTracks const& ambiguousTracks, aod::BCs const& bcs) { svCreator.clearPools(); svCreator.fillBC2Coll(collisions, bcs); - for (auto& track : tracks) { + for (const auto& track : tracks) { if (std::abs(track.eta()) > etaMax) continue; @@ -240,14 +278,14 @@ struct kinkBuilder { } auto& kinkPool = svCreator.getSVCandPool(collisions, !unlikeSignBkg); - for (auto& svCand : kinkPool) { + for (const auto& svCand : kinkPool) { kinkCandidate kinkCand; auto trackMoth = tracks.rawIteratorAt(svCand.tr0Idx); auto trackDaug = tracks.rawIteratorAt(svCand.tr1Idx); auto const& collision = trackMoth.template collision_as(); - auto const& bc = collision.template bc_as(); + auto const& bc = collision.template bc_as(); initCCDB(bc); o2::dataformats::VertexBase primaryVertex; @@ -256,10 +294,10 @@ struct kinkBuilder { kinkCand.primVtx = {primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}; o2::track::TrackParCov trackParCovMoth = getTrackParCov(trackMoth); + o2::track::TrackParCov trackParCovMothPV{trackParCovMoth}; o2::base::Propagator::Instance()->PropagateToXBxByBz(trackParCovMoth, LayerRadii[trackMoth.itsNCls() - 1]); - o2::track::TrackParCov trackParCovMothPV = getTrackParCov(trackMoth); - gpu::gpustd::array dcaInfoMoth; + std::array dcaInfoMoth; o2::base::Propagator::Instance()->propagateToDCABxByBz({primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, trackParCovMothPV, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfoMoth); if (std::abs(dcaInfoMoth[0]) > maxDCAMothToPV) { @@ -278,12 +316,20 @@ struct kinkBuilder { } // propagate to PV - gpu::gpustd::array dcaInfoDaug; + std::array dcaInfoDaug; o2::base::Propagator::Instance()->propagateToDCABxByBz({primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, trackParCovDaug, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfoDaug); if (std::abs(dcaInfoDaug[0]) < minDCADaugToPV) { continue; } + if (updateMothTrackUsePV) { + // update the mother track parameters using the primary vertex + trackParCovMoth = trackParCovMothPV; + if (!trackParCovMoth.update(primaryVertex)) { + continue; + } + } + int nCand = 0; try { nCand = fitter.process(trackParCovMoth, trackParCovDaug); @@ -305,7 +351,7 @@ struct kinkBuilder { // cut on decay radius to 17 cm float decRad2 = kinkCand.decVtx[0] * kinkCand.decVtx[0] + kinkCand.decVtx[1] * kinkCand.decVtx[1]; - if (decRad2 < LayerRadii[3] * LayerRadii[3]) { + if (doSVRadiusCut && decRad2 < LayerRadii[3] * LayerRadii[3]) { continue; } @@ -324,11 +370,11 @@ struct kinkBuilder { } } - if (lastLayerMoth >= firstLayerDaug) { + if (doSVRadiusCut && lastLayerMoth >= firstLayerDaug) { continue; } - if (decRad2 < LayerRadii[lastLayerMoth] * LayerRadii[lastLayerMoth]) { + if (doSVRadiusCut && decRad2 < LayerRadii[lastLayerMoth] * LayerRadii[lastLayerMoth]) { continue; } @@ -338,8 +384,12 @@ struct kinkBuilder { propMothTrack.getPxPyPzGlo(kinkCand.momMoth); propDaugTrack.getPxPyPzGlo(kinkCand.momDaug); - float pMoth = propMothTrack.getP(); - float pDaug = propDaugTrack.getP(); + for (int i = 0; i < 3; i++) { + kinkCand.momMoth[i] *= charge; + kinkCand.momDaug[i] *= charge; + } + float pMoth = propMothTrack.getP() * charge; + float pDaug = propDaugTrack.getP() * charge; float spKink = kinkCand.momMoth[0] * kinkCand.momDaug[0] + kinkCand.momMoth[1] * kinkCand.momDaug[1] + kinkCand.momMoth[2] * kinkCand.momDaug[2]; kinkCand.kinkAngle = std::acos(spKink / (pMoth * pDaug)); @@ -348,15 +398,15 @@ struct kinkBuilder { neutDauMom[i] = kinkCand.momMoth[i] - kinkCand.momDaug[i]; } - float piMinusE = std::sqrt(neutDauMom[0] * neutDauMom[0] + neutDauMom[1] * neutDauMom[1] + neutDauMom[2] * neutDauMom[2] + 0.13957 * 0.13957); - float neutronE = std::sqrt(pDaug * pDaug + 0.93957 * 0.93957); - float invMass = std::sqrt((piMinusE + neutronE) * (piMinusE + neutronE) - (pMoth * pMoth)); + float chargedDauE = std::sqrt(pDaug * pDaug + chargedDauMass * chargedDauMass); + float neutE = std::sqrt(neutDauMom[0] * neutDauMom[0] + neutDauMom[1] * neutDauMom[1] + neutDauMom[2] * neutDauMom[2] + neutDauMass * neutDauMass); + float invMass = std::sqrt((chargedDauE + neutE) * (chargedDauE + neutE) - (pMoth * pMoth)); h2DeDxDaugSel->Fill(trackDaug.tpcInnerParam() * trackDaug.sign(), trackDaug.tpcSignal()); - h2KinkAnglePt->Fill(trackMoth.pt() * trackMoth.sign(), kinkCand.kinkAngle * radToDeg); - h2SigmaMinusMassPt->Fill(trackMoth.pt() * trackMoth.sign(), invMass); - h2ClsMapPtMoth->Fill(trackMoth.pt() * trackMoth.sign(), trackMoth.itsClusterMap()); - h2ClsMapPtDaug->Fill(trackDaug.pt() * trackDaug.sign(), trackDaug.itsClusterMap()); + h2KinkAnglePt->Fill(trackMoth.pt() * charge * trackMoth.sign(), kinkCand.kinkAngle * radToDeg); + h2MothMassPt->Fill(trackMoth.pt() * charge * trackMoth.sign(), invMass); + h2ClsMapPtMoth->Fill(trackMoth.pt() * charge * trackMoth.sign(), trackMoth.itsClusterMap()); + h2ClsMapPtDaug->Fill(trackDaug.pt() * charge * trackDaug.sign(), trackDaug.itsClusterMap()); kinkCand.collisionID = collision.globalIndex(); kinkCand.mothTrackID = trackMoth.globalIndex(); @@ -370,51 +420,28 @@ struct kinkBuilder { } } - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + void initCCDB(aod::BCs::iterator const& bc) { if (mRunNumber == bc.runNumber()) { return; } - auto run3grp_timestamp = bc.timestamp(); - - o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); - o2::parameters::GRPMagField* grpmag = 0x0; - if (grpo) { - o2::base::Propagator::initFieldFromGRP(grpo); - if (inputBz < -990) { - // Fetch magnetic field from ccdb for current collision - mBz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << mBz << " kZG"; - } else { - mBz = inputBz; - } - } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); - if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; - } - o2::base::Propagator::initFieldFromGRP(grpmag); - if (inputBz < -990) { - // Fetch magnetic field from ccdb for current collision - mBz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << mBz << " kZG"; - } else { - mBz = inputBz; - } - } + mRunNumber = bc.runNumber(); + LOG(info) << "Initializing CCDB for run " << mRunNumber; + o2::parameters::GRPMagField* grpmag = ccdb->getForRun(grpmagPath, mRunNumber); + o2::base::Propagator::initFieldFromGRP(grpmag); + mBz = grpmag->getNominalL3Field(); + fitter.setBz(mBz); - for (int i = 0; i < 5; i++) { - mBBparamsDaug[i] = cfgBetheBlochParams->get("Daughter", Form("p%i", i)); + if (!lut) { + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); + int mat{static_cast(cfgMaterialCorrection)}; + fitter.setMatCorrType(static_cast(mat)); } - mBBparamsDaug[5] = cfgBetheBlochParams->get("Daughter", "resolution"); - - fitter.setBz(mBz); - mRunNumber = bc.runNumber(); o2::base::Propagator::Instance()->setMatLUT(lut); LOG(info) << "Task initialized for run " << mRunNumber << " with magnetic field " << mBz << " kZG"; } - void process(aod::Collisions const& collisions, TracksFull const& tracks, aod::AmbiguousTracks const& ambiTracks, aod::BCsWithTimestamps const& bcs) + void process(aod::Collisions const& collisions, TracksFull const& tracks, aod::AmbiguousTracks const& ambiTracks, aod::BCs const& bcs) { kinkCandidates.clear(); @@ -423,12 +450,19 @@ struct kinkBuilder { // sort kinkCandidates by collisionID to allow joining with collision table std::sort(kinkCandidates.begin(), kinkCandidates.end(), [](const kinkCandidate& a, const kinkCandidate& b) { return a.collisionID < b.collisionID; }); - for (auto& kinkCand : kinkCandidates) { - outputDataTable(kinkCand.collisionID, kinkCand.mothTrackID, kinkCand.daugTrackID, - kinkCand.decVtx[0], kinkCand.decVtx[1], kinkCand.decVtx[2], - kinkCand.mothSign, kinkCand.momMoth[0], kinkCand.momMoth[1], kinkCand.momMoth[2], - kinkCand.momDaug[0], kinkCand.momDaug[1], kinkCand.momDaug[2], - kinkCand.dcaXYmoth, kinkCand.dcaXYdaug, kinkCand.dcaKinkTopo); + for (const auto& kinkCand : kinkCandidates) { + if (fillDebugTable) { + outputDataTableUB(kinkCand.decVtx[0], kinkCand.decVtx[1], kinkCand.decVtx[2], + kinkCand.mothSign, kinkCand.momMoth[0], kinkCand.momMoth[1], kinkCand.momMoth[2], + kinkCand.momDaug[0], kinkCand.momDaug[1], kinkCand.momDaug[2], + kinkCand.dcaXYmoth, kinkCand.dcaXYdaug, kinkCand.dcaKinkTopo); + } else { + outputDataTable(kinkCand.collisionID, kinkCand.mothTrackID, kinkCand.daugTrackID, + kinkCand.decVtx[0], kinkCand.decVtx[1], kinkCand.decVtx[2], + kinkCand.mothSign, kinkCand.momMoth[0], kinkCand.momMoth[1], kinkCand.momMoth[2], + kinkCand.momDaug[0], kinkCand.momDaug[1], kinkCand.momDaug[2], + kinkCand.dcaXYmoth, kinkCand.dcaXYdaug, kinkCand.dcaKinkTopo); + } } } }; diff --git a/PWGLF/TableProducer/Common/spvector.cxx b/PWGLF/TableProducer/Common/spvector.cxx index 20f5f738255..e5940962e1f 100644 --- a/PWGLF/TableProducer/Common/spvector.cxx +++ b/PWGLF/TableProducer/Common/spvector.cxx @@ -13,59 +13,64 @@ // \email: prottay.das@cern.ch // C++/ROOT includes. -#include -#include -#include -#include +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TRandom3.h" #include +#include #include + #include +#include #include -#include "Math/Vector4D.h" -#include "TRandom3.h" -#include "TF1.h" +#include +#include +#include // o2Physics includes. -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "CommonConstants/PhysicsConstants.h" +#include "PWGLF/DataModel/SPCalibrationTables.h" + +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/PID/PIDTOF.h" #include "Common/Core/TrackSelection.h" -#include "Common/DataModel/FT0Corrected.h" -#include "FT0Base/Geometry.h" -#include "FV0Base/Geometry.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" -#include "Common/Core/PID/PIDTOF.h" -#include "Common/TableProducer/PID/pidTOFBase.h" -#include "Common/Core/EventPlaneHelper.h" #include "Common/DataModel/Qvectors.h" -#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/TableProducer/PID/pidTOFBase.h" + +#include "CommonConstants/PhysicsConstants.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" #include "DataFormatsTPC/BetheBlochAleph.h" #include "DetectorsBase/GeometryManager.h" #include "DetectorsBase/Propagator.h" +#include "FT0Base/Geometry.h" +#include "FV0Base/Geometry.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" -#include "PWGLF/DataModel/SPCalibrationTables.h" // #include "SPCalibrationTableswrite.h" // o2 includes. -#include "CCDB/CcdbApi.h" #include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" #include "DetectorsCommonDataFormats/AlignParam.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::constants::physics; +using namespace o2::aod::rctsel; using BCsRun3 = soa::Join; @@ -87,35 +92,39 @@ struct spvector { Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgCutCentralityMax{"cfgCutCentralityMax", 80.0f, "Centrality cut Max"}; Configurable cfgCutCentralityMin{"cfgCutCentralityMin", 0.0f, "Centrality cut Min"}; + Configurable additionalEvSel{"additionalEvSel", false, "additionalEvSel"}; + + struct : ConfigurableGroup { + Configurable QxyNbins{"QxyNbins", 100, "Number of bins in QxQy histograms"}; + Configurable PhiNbins{"PhiNbins", 100, "Number of bins in phi histogram"}; + Configurable lbinQxy{"lbinQxy", -5.0, "lower bin value in QxQy histograms"}; + Configurable hbinQxy{"hbinQxy", 5.0, "higher bin value in QxQy histograms"}; + Configurable VxNbins{"VxNbins", 25, "Number of bins in Vx histograms"}; + Configurable lbinVx{"lbinVx", -0.05, "lower bin value in Vx histograms"}; + Configurable hbinVx{"hbinVx", 0.0, "higher bin value in Vx histograms"}; + Configurable VyNbins{"VyNbins", 25, "Number of bins in Vy histograms"}; + Configurable lbinVy{"lbinVy", -0.02, "lower bin value in Vy histograms"}; + Configurable hbinVy{"hbinVy", 0.02, "higher bin value in Vy histograms"}; + Configurable VzNbins{"VzNbins", 20, "Number of bins in Vz histograms"}; + Configurable lbinVz{"lbinVz", -10.0, "lower bin value in Vz histograms"}; + Configurable hbinVz{"hbinVz", 10.0, "higher bin value in Vz histograms"}; + Configurable CentNbins{"CentNbins", 16, "Number of bins in cent histograms"}; + Configurable lbinCent{"lbinCent", 0.0, "lower bin value in cent histograms"}; + Configurable hbinCent{"hbinCent", 80.0, "higher bin value in cent histograms"}; + Configurable VxfineNbins{"VxfineNbins", 25, "Number of bins in Vx fine histograms"}; + Configurable lfinebinVx{"lfinebinVx", -0.05, "lower bin value in Vx fine histograms"}; + Configurable hfinebinVx{"hfinebinVx", 0.0, "higher bin value in Vx fine histograms"}; + Configurable VyfineNbins{"VyfineNbins", 25, "Number of bins in Vy fine histograms"}; + Configurable lfinebinVy{"lfinebinVy", -0.02, "lower bin value in Vy fine histograms"}; + Configurable hfinebinVy{"hfinebinVy", 0.02, "higher bin value in Vy fine histograms"}; + Configurable VzfineNbins{"VzfineNbins", 20, "Number of bins in Vz fine histograms"}; + Configurable lfinebinVz{"lfinebinVz", -10.0, "lower bin value in Vz fine histograms"}; + Configurable hfinebinVz{"hfinebinVz", 10.0, "higher bin value in Vz fine histograms"}; + Configurable CentfineNbins{"CentfineNbins", 16, "Number of bins in cent fine histograms"}; + Configurable lfinebinCent{"lfinebinCent", 0.0, "lower bin value in cent fine histograms"}; + Configurable hfinebinCent{"hfinebinCent", 80.0, "higher bin value in cent fine histograms"}; + } configbins; - Configurable QxyNbins{"QxyNbins", 100, "Number of bins in QxQy histograms"}; - Configurable PhiNbins{"PhiNbins", 100, "Number of bins in phi histogram"}; - Configurable lbinQxy{"lbinQxy", -5.0, "lower bin value in QxQy histograms"}; - Configurable hbinQxy{"hbinQxy", 5.0, "higher bin value in QxQy histograms"}; - Configurable VxNbins{"VxNbins", 25, "Number of bins in Vx histograms"}; - Configurable lbinVx{"lbinVx", -0.05, "lower bin value in Vx histograms"}; - Configurable hbinVx{"hbinVx", 0.0, "higher bin value in Vx histograms"}; - Configurable VyNbins{"VyNbins", 25, "Number of bins in Vy histograms"}; - Configurable lbinVy{"lbinVy", -0.02, "lower bin value in Vy histograms"}; - Configurable hbinVy{"hbinVy", 0.02, "higher bin value in Vy histograms"}; - Configurable VzNbins{"VzNbins", 20, "Number of bins in Vz histograms"}; - Configurable lbinVz{"lbinVz", -10.0, "lower bin value in Vz histograms"}; - Configurable hbinVz{"hbinVz", 10.0, "higher bin value in Vz histograms"}; - Configurable CentNbins{"CentNbins", 16, "Number of bins in cent histograms"}; - Configurable lbinCent{"lbinCent", 0.0, "lower bin value in cent histograms"}; - Configurable hbinCent{"hbinCent", 80.0, "higher bin value in cent histograms"}; - Configurable VxfineNbins{"VxfineNbins", 25, "Number of bins in Vx fine histograms"}; - Configurable lfinebinVx{"lfinebinVx", -0.05, "lower bin value in Vx fine histograms"}; - Configurable hfinebinVx{"hfinebinVx", 0.0, "higher bin value in Vx fine histograms"}; - Configurable VyfineNbins{"VyfineNbins", 25, "Number of bins in Vy fine histograms"}; - Configurable lfinebinVy{"lfinebinVy", -0.02, "lower bin value in Vy fine histograms"}; - Configurable hfinebinVy{"hfinebinVy", 0.02, "higher bin value in Vy fine histograms"}; - Configurable VzfineNbins{"VzfineNbins", 20, "Number of bins in Vz fine histograms"}; - Configurable lfinebinVz{"lfinebinVz", -10.0, "lower bin value in Vz fine histograms"}; - Configurable hfinebinVz{"hfinebinVz", 10.0, "higher bin value in Vz fine histograms"}; - Configurable CentfineNbins{"CentfineNbins", 16, "Number of bins in cent fine histograms"}; - Configurable lfinebinCent{"lfinebinCent", 0.0, "lower bin value in cent fine histograms"}; - Configurable hfinebinCent{"hfinebinCent", 80.0, "higher bin value in cent fine histograms"}; Configurable useShift{"useShift", false, "shift histograms"}; Configurable ispolarization{"ispolarization", false, "Flag to check polarization"}; Configurable followpub{"followpub", true, "flag to use alphaZDC"}; @@ -132,6 +141,7 @@ struct spvector { Configurable coarse5{"coarse5", false, "RE5"}; Configurable fine5{"fine5", false, "REfine5"}; Configurable coarse6{"coarse6", false, "RE6"}; + Configurable fine6{"fine6", false, "REfine6"}; Configurable useRecentereSp{"useRecentereSp", false, "use Recentering with Sparse or THn"}; Configurable useRecenterefineSp{"useRecenterefineSp", false, "use fine Recentering with THn"}; Configurable ConfGainPath{"ConfGainPath", "Users/p/prottay/My/Object/NewPbPbpass4_10092024/gaincallib", "Path to gain calibration"}; @@ -162,6 +172,10 @@ struct spvector { Configurable ConfRecenterevxSp5{"ConfRecenterevxSp5", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for vx recentere5"}; Configurable ConfRecenterevySp5{"ConfRecenterevySp5", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for vy recentere5"}; Configurable ConfRecenterevzSp5{"ConfRecenterevzSp5", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for vz recentere5"}; + Configurable ConfRecenterecentSp6{"ConfRecenterecentSp6", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for cent recentere6"}; + Configurable ConfRecenterevxSp6{"ConfRecenterevxSp6", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for vx recentere6"}; + Configurable ConfRecenterevySp6{"ConfRecenterevySp6", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for vy recentere6"}; + Configurable ConfRecenterevzSp6{"ConfRecenterevzSp6", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for vz recentere6"}; Configurable ConfShiftC{"ConfShiftC", "Users/p/prottay/My/Object/Testinglocaltree/shiftcallib2", "Path to shift C"}; Configurable ConfShiftA{"ConfShiftA", "Users/p/prottay/My/Object/Testinglocaltree/shiftcallib2", "Path to shift A"}; @@ -186,24 +200,37 @@ struct spvector { return 1; } */ + + struct : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", true, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", false, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } rctCut; + + RCTFlagsChecker rctChecker; + void init(o2::framework::InitContext&) { + rctChecker.init(rctCut.cfgEvtRCTFlagCheckerLabel, rctCut.cfgEvtRCTFlagCheckerZDCCheck, rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + AxisSpec channelZDCAxis = {8, 0.0, 8.0, "ZDC tower"}; - AxisSpec qxZDCAxis = {QxyNbins, lbinQxy, hbinQxy, "Qx"}; - AxisSpec phiAxis = {PhiNbins, -6.28, 6.28, "phi"}; - AxisSpec vzAxis = {VzNbins, lbinVz, hbinVz, "vz"}; - AxisSpec vxAxis = {VxNbins, lbinVx, hbinVx, "vx"}; - AxisSpec vyAxis = {VyNbins, lbinVy, hbinVy, "vy"}; - AxisSpec centAxis = {CentNbins, lbinCent, hbinCent, "V0M (%)"}; - AxisSpec vzfineAxis = {VzfineNbins, lfinebinVz, hfinebinVz, "vzfine"}; - AxisSpec vxfineAxis = {VxfineNbins, lfinebinVx, hfinebinVx, "vxfine"}; - AxisSpec vyfineAxis = {VyfineNbins, lfinebinVy, hfinebinVy, "vyfine"}; - AxisSpec centfineAxis = {CentfineNbins, lfinebinCent, hfinebinCent, "V0M (%) fine"}; + AxisSpec qxZDCAxis = {configbins.QxyNbins, configbins.lbinQxy, configbins.hbinQxy, "Qx"}; + AxisSpec phiAxis = {configbins.PhiNbins, -6.28, 6.28, "phi"}; + AxisSpec vzAxis = {configbins.VzNbins, configbins.lbinVz, configbins.hbinVz, "vz"}; + AxisSpec vxAxis = {configbins.VxNbins, configbins.lbinVx, configbins.hbinVx, "vx"}; + AxisSpec vyAxis = {configbins.VyNbins, configbins.lbinVy, configbins.hbinVy, "vy"}; + AxisSpec centAxis = {configbins.CentNbins, configbins.lbinCent, configbins.hbinCent, "V0M (%)"}; + AxisSpec vzfineAxis = {configbins.VzfineNbins, configbins.lfinebinVz, configbins.hfinebinVz, "vzfine"}; + AxisSpec vxfineAxis = {configbins.VxfineNbins, configbins.lfinebinVx, configbins.hfinebinVx, "vxfine"}; + AxisSpec vyfineAxis = {configbins.VyfineNbins, configbins.lfinebinVy, configbins.hfinebinVy, "vyfine"}; + AxisSpec centfineAxis = {configbins.CentfineNbins, configbins.lfinebinCent, configbins.hfinebinCent, "V0M (%) fine"}; AxisSpec shiftAxis = {10, 0, 10, "shift"}; AxisSpec basisAxis = {2, 0, 2, "basis"}; AxisSpec VxyAxis = {2, 0, 2, "Vxy"}; + histos.add("hEvtSelInfo", "hEvtSelInfo", kTH1F, {{10, 0, 10.0}}); histos.add("hCentrality", "hCentrality", kTH1F, {{centfineAxis}}); histos.add("Vz", "Vz", kTH1F, {vzfineAxis}); histos.add("hpQxZDCAC", "hpQxZDCAC", kTProfile, {centfineAxis}); @@ -278,10 +305,10 @@ struct spvector { TH2F* hrecenterevySp; TH2F* hrecenterevzSp;*/ std::array hrecentereSpA; // Array of 6 histograms - std::array hrecenterecentSpA; // Array of 5 histograms - std::array hrecenterevxSpA; // Array of 5 histograms - std::array hrecenterevySpA; // Array of 5 histograms - std::array hrecenterevzSpA; // Array of 5 histograms + std::array hrecenterecentSpA; // Array of 5 histograms + std::array hrecenterevxSpA; // Array of 5 histograms + std::array hrecenterevySpA; // Array of 5 histograms + std::array hrecenterevzSpA; // Array of 5 histograms TProfile3D* shiftprofileA; TProfile3D* shiftprofileC; @@ -305,11 +332,11 @@ struct spvector { TAxis* channelAxis = hrecentereSp->GetAxis(4); // Axis 4: channel // Find bin indices for centrality, vx, vy, vz, and channel (for meanxA, 0.5) - binCoords[0] = centralityAxis->FindBin(centrality); // Centrality - binCoords[1] = vxAxis->FindBin(vx); // vx - binCoords[2] = vyAxis->FindBin(vy); // vy - binCoords[3] = vzAxis->FindBin(vz); // vz - binCoords[4] = channelAxis->FindBin(0.5); // Channel for meanxA + binCoords[0] = centralityAxis->FindBin(centrality + 0.00001); // Centrality + binCoords[1] = vxAxis->FindBin(vx + 0.00001); // vx + binCoords[2] = vyAxis->FindBin(vy + 0.00001); // vy + binCoords[3] = vzAxis->FindBin(vz + 0.00001); // vz + binCoords[4] = channelAxis->FindBin(0.5); // Channel for meanxA // Get the global bin for meanxA int globalBinMeanxA = hrecentereSp->GetBin(binCoords); @@ -353,25 +380,25 @@ struct spvector { hrecenterevzSp = ccdb->getForTimeStamp(ConfRecenterevzSpp.value, ts); }*/ - double meanxAcent = hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality, 0.5)); - double meanyAcent = hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality, 1.5)); - double meanxCcent = hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality, 2.5)); - double meanyCcent = hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality, 3.5)); + double meanxAcent = hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality + 0.00001, 0.5)); + double meanyAcent = hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality + 0.00001, 1.5)); + double meanxCcent = hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality + 0.00001, 2.5)); + double meanyCcent = hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality + 0.00001, 3.5)); - double meanxAvx = hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx, 0.5)); - double meanyAvx = hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx, 1.5)); - double meanxCvx = hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx, 2.5)); - double meanyCvx = hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx, 3.5)); + double meanxAvx = hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx + 0.00001, 0.5)); + double meanyAvx = hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx + 0.00001, 1.5)); + double meanxCvx = hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx + 0.00001, 2.5)); + double meanyCvx = hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx + 0.00001, 3.5)); - double meanxAvy = hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy, 0.5)); - double meanyAvy = hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy, 1.5)); - double meanxCvy = hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy, 2.5)); - double meanyCvy = hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy, 3.5)); + double meanxAvy = hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy + 0.00001, 0.5)); + double meanyAvy = hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy + 0.00001, 1.5)); + double meanxCvy = hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy + 0.00001, 2.5)); + double meanyCvy = hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy + 0.00001, 3.5)); - double meanxAvz = hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz, 0.5)); - double meanyAvz = hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz, 1.5)); - double meanxCvz = hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz, 2.5)); - double meanyCvz = hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz, 3.5)); + double meanxAvz = hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz + 0.00001, 0.5)); + double meanyAvz = hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz + 0.00001, 1.5)); + double meanxCvz = hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz + 0.00001, 2.5)); + double meanyCvz = hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz + 0.00001, 3.5)); qxZDCA = qxZDCA - meanxAcent - meanxAvx - meanxAvy - meanxAvz; qyZDCA = qyZDCA - meanyAcent - meanyAvx - meanyAvy - meanyAvz; @@ -387,6 +414,7 @@ struct spvector { void process(MyCollisions::iterator const& collision, aod::FT0s const& /*ft0s*/, aod::FV0As const& /*fv0s*/, BCsRun3 const& bcs, aod::Zdcs const&) { + histos.fill(HIST("hEvtSelInfo"), 0.5); auto centrality = collision.centFT0C(); bool triggerevent = false; @@ -416,6 +444,8 @@ struct spvector { return; } + histos.fill(HIST("hEvtSelInfo"), 1.5); + auto zdc = bc.zdc(); auto zncEnergy = zdc.energySectorZNC(); auto znaEnergy = zdc.energySectorZNA(); @@ -428,24 +458,47 @@ struct spvector { return; } + histos.fill(HIST("hEvtSelInfo"), 2.5); + if (znaEnergy[0] <= 0.0 || znaEnergy[1] <= 0.0 || znaEnergy[2] <= 0.0 || znaEnergy[3] <= 0.0) { triggerevent = false; spcalibrationtable(triggerevent, currentRunNumber, centrality, vx, vy, vz, znaEnergycommon, zncEnergycommon, znaEnergy[0], znaEnergy[1], znaEnergy[2], znaEnergy[3], zncEnergy[0], zncEnergy[1], zncEnergy[2], zncEnergy[3], qxZDCA, qxZDCC, qyZDCA, qyZDCC, psiZDCC, psiZDCA); return; } + histos.fill(HIST("hEvtSelInfo"), 3.5); + if (zncEnergy[0] <= 0.0 || zncEnergy[1] <= 0.0 || zncEnergy[2] <= 0.0 || zncEnergy[3] <= 0.0) { triggerevent = false; spcalibrationtable(triggerevent, currentRunNumber, centrality, vx, vy, vz, znaEnergycommon, zncEnergycommon, znaEnergy[0], znaEnergy[1], znaEnergy[2], znaEnergy[3], zncEnergy[0], zncEnergy[1], zncEnergy[2], zncEnergy[3], qxZDCA, qxZDCC, qyZDCA, qyZDCC, psiZDCC, psiZDCA); return; } - // if (collision.sel8() && centrality > cfgCutCentralityMin && centrality < cfgCutCentralityMax && TMath::Abs(vz) < cfgCutVertex && collision.has_foundFT0() && eventSelected(collision, centrality) && collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + histos.fill(HIST("hEvtSelInfo"), 4.5); + + if (rctCut.requireRCTFlagChecker && !rctChecker(collision)) { + triggerevent = false; + spcalibrationtable(triggerevent, currentRunNumber, centrality, vx, vy, vz, znaEnergycommon, zncEnergycommon, znaEnergy[0], znaEnergy[1], znaEnergy[2], znaEnergy[3], zncEnergy[0], zncEnergy[1], zncEnergy[2], zncEnergy[3], qxZDCA, qxZDCC, qyZDCA, qyZDCC, psiZDCC, psiZDCA); + return; + } + + histos.fill(HIST("hEvtSelInfo"), 5.5); + + if (additionalEvSel && (!collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + triggerevent = false; + spcalibrationtable(triggerevent, currentRunNumber, centrality, vx, vy, vz, znaEnergycommon, zncEnergycommon, znaEnergy[0], znaEnergy[1], znaEnergy[2], znaEnergy[3], zncEnergy[0], zncEnergy[1], zncEnergy[2], zncEnergy[3], qxZDCA, qxZDCC, qyZDCA, qyZDCC, psiZDCC, psiZDCA); + return; + } + + histos.fill(HIST("hEvtSelInfo"), 6.5); + if (collision.sel8() && centrality > cfgCutCentralityMin && centrality < cfgCutCentralityMax && TMath::Abs(vz) < cfgCutVertex && collision.has_foundFT0() && collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { triggerevent = true; if (useGainCallib && (currentRunNumber != lastRunNumber)) { gainprofile = ccdb->getForTimeStamp(ConfGainPath.value, bc.timestamp()); } + histos.fill(HIST("hEvtSelInfo"), 7.5); + auto gainequal = 1.0; auto alphaZDC = 0.395; constexpr double x[4] = {-1.75, 1.75, -1.75, 1.75}; @@ -457,7 +510,7 @@ struct spvector { for (std::size_t iChA = 0; iChA < 8; iChA++) { auto chanelid = iChA; if (useGainCallib && gainprofile) { - gainequal = gainprofile->GetBinContent(gainprofile->FindBin(vz, chanelid + 0.5)); + gainequal = gainprofile->GetBinContent(gainprofile->FindBin(vz + 0.00001, chanelid + 0.5)); } if (iChA < 4) { @@ -513,6 +566,7 @@ struct spvector { return; } + histos.fill(HIST("hEvtSelInfo"), 8.5); histos.fill(HIST("hCentrality"), centrality); histos.fill(HIST("Vz"), vz); @@ -530,6 +584,7 @@ struct spvector { Bool_t res = 0; Bool_t resfine = 0; + Int_t check = 1; if (coarse1) { if (useRecentereSp && (currentRunNumber != lastRunNumber)) { @@ -624,7 +679,18 @@ struct spvector { res = Correctcoarse(hrecentereSpA[5], centrality, vx, vy, vz, qxZDCA, qyZDCA, qxZDCC, qyZDCC); } - if (res == 0 || resfine == 0) { + if (fine6) { + if (useRecenterefineSp && (currentRunNumber != lastRunNumber)) { + hrecenterecentSpA[5] = ccdb->getForTimeStamp(ConfRecenterecentSp6.value, bc.timestamp()); + hrecenterevxSpA[5] = ccdb->getForTimeStamp(ConfRecenterevxSp6.value, bc.timestamp()); + hrecenterevySpA[5] = ccdb->getForTimeStamp(ConfRecenterevySp6.value, bc.timestamp()); + hrecenterevzSpA[5] = ccdb->getForTimeStamp(ConfRecenterevzSp6.value, bc.timestamp()); + } + resfine = Correctfine(hrecenterecentSpA[5], hrecenterevxSpA[5], hrecenterevySpA[5], hrecenterevzSpA[5], centrality, vx, vy, vz, qxZDCA, qyZDCA, qxZDCC, qyZDCC); + } + + if (res == 0 && resfine == 0 && check == 0) { + LOG(info) << "Histograms are null"; } psiZDCC = 1.0 * TMath::ATan2(qyZDCC, qxZDCC); psiZDCA = 1.0 * TMath::ATan2(qyZDCA, qxZDCA); diff --git a/PWGLF/TableProducer/Nuspex/CMakeLists.txt b/PWGLF/TableProducer/Nuspex/CMakeLists.txt index 243160a04e4..98dac784da5 100644 --- a/PWGLF/TableProducer/Nuspex/CMakeLists.txt +++ b/PWGLF/TableProducer/Nuspex/CMakeLists.txt @@ -11,7 +11,7 @@ o2physics_add_dpl_workflow(decay3bodybuilder SOURCES decay3bodybuilder.cxx - PUBLIC_LINK_LIBRARIES O2::DCAFitter KFParticle::KFParticle O2Physics::AnalysisCore O2::TOFBase + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2::TOFBase O2Physics::EventFilteringUtils O2::DetectorsVertexing COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(hyhefour-builder @@ -29,11 +29,6 @@ o2physics_add_dpl_workflow(lnn-reco-task PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(hypertriton3bodyfinder - SOURCES hypertriton3bodyfinder.cxx - PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(nucleustreecreator SOURCES LFTreeCreatorNuclei.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -59,11 +54,6 @@ o2physics_add_dpl_workflow(threebodymcfinder PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(threebody-reco-task - SOURCES threebodyRecoTask.cxx - PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore O2Physics::EventFilteringUtils - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(ebye-maker SOURCES ebyeMaker.cxx PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore @@ -79,11 +69,6 @@ o2physics_add_dpl_workflow(pidtof-generic PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::TOFBase COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(threebody-kf-task - SOURCES threebodyKFTask.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(hypernuclei-kf-reco-task SOURCES hypKfRecoTask.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore KFParticle::KFParticle @@ -93,3 +78,28 @@ o2physics_add_dpl_workflow(hypernuclei-kf-tree-creator SOURCES hypKfTreeCreator.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(tr-he-analysis + SOURCES trHeAnalysis.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(reduced3body-creator + SOURCES reduced3bodyCreator.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore KFParticle::KFParticle O2Physics::EventFilteringUtils O2::TOFBase + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(nuclei-flow-trees + SOURCES nucleiFlowTree.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(hyperkink-reco-task + SOURCES hyperkinkRecoTask.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::TOFBase + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(he3-lambda-analysis + SOURCES he3LambdaAnalysis.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) diff --git a/PWGLF/TableProducer/Nuspex/LFTreeCreatorClusterStudies.cxx b/PWGLF/TableProducer/Nuspex/LFTreeCreatorClusterStudies.cxx index 237b4538a2d..ffa41989881 100644 --- a/PWGLF/TableProducer/Nuspex/LFTreeCreatorClusterStudies.cxx +++ b/PWGLF/TableProducer/Nuspex/LFTreeCreatorClusterStudies.cxx @@ -14,45 +14,45 @@ // // Author: Giorgio Alberto Lucia -#include -#include -#include -#include -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFClusterStudiesTable.h" #include "PWGLF/DataModel/LFStrangenessTables.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" #include "Common/Core/PID/PIDTOF.h" -#include "Common/TableProducer/PID/pidTOFBase.h" #include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/PIDResponseITS.h" -#include "DCAFitter/DCAFitterN.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/TableProducer/PID/pidTOFBase.h" -#include "PWGLF/DataModel/LFClusterStudiesTable.h" +#include "CCDB/BasicCCDBManager.h" +#include "DCAFitter/DCAFitterN.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" #include "TDatabasePDG.h" #include "TPDGCode.h" +#include +#include +#include +#include +#include +#include +#include + using namespace ::o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -138,6 +138,22 @@ enum PartID { he }; +struct Candidate { + float p = -999.f; // momentum * charge + float eta = -999.f; + float phi = -999.f; + uint32_t itsClusterSize = 0; + uint8_t partID = PartID::none; + float pTPC = -999.f; + uint32_t pidInTrk = 0; // PID in tracking + float nsigmaTPC = -999.f; + float nsigmaTOF = -999.f; + float tofMass = -999.f; + float cosPAMother = -999.f; // Cosine of the pointing angle of the mother + float massMother = -999.f; // Invariant mass of the mother + int pdgCode = 0; +}; + struct LfTreeCreatorClusterStudies { Service m_ccdb; @@ -180,6 +196,8 @@ struct LfTreeCreatorClusterStudies { Configurable v0setting_nsigmatpcPr{"v0setting_nsigmaTPCPr", 2.f, "Number of sigmas for the TPC PID for protons"}; Configurable lambdasetting_qtAPcut{"lambdasetting_qtAPcut", 0.02f, "Cut on the qt for the Armenteros-Podolanski plot for photon rejection"}; Configurable lambdasetting_pmin{"lambdasetting_pmin", 0.0f, "Minimum momentum for the V0 daughters"}; + Configurable electronsetting_conversion_rmin{"electron_conversion_rmin", 1.76f, "Minimum radius for the photon conversion (cm)"}; + Configurable electronsetting_conversion_rmax{"electron_conversion_rmax", 19.77f, "Maximum radius for the photon conversion (cm)"}; Configurable cascsetting_dcaCascDaughters{"casc_setting_dcaV0daughters", 0.1f, "DCA between the V0 daughters"}; Configurable cascsetting_cosPA{"casc_setting_cosPA", 0.99f, "Cosine of the pointing angle of the V0"}; @@ -223,6 +241,7 @@ struct LfTreeCreatorClusterStudies { {"photon_radiusV0", "Photon conversion radius (xy) V0; radius (cm); counts", {HistType::kTH1F, {{100, 0., 100.}}}}, {"photon_conversion_position", "Photon conversion position; x (cm); y (cm)", {HistType::kTH2F, {{250, -5.f, 5.f}, {250, -5.f, 5.f}}}}, {"photon_conversion_position_layer", "Photon conversion position (ITS layers); x (cm); y (cm)", {HistType::kTH2F, {{100, -5.f, 5.f}, {100, -5.f, 5.f}}}}, + {"casc_dca_daughter_pairs", "DCA (xy) for cascade daughter pairs; DCAxy (cm); counts", {HistType::kTH1F, {{100, -0.1, 0.1}}}}, {"Xi_vs_Omega", "Mass Xi vs Omega; mass Omega (GeV/#it{c}^{2}); mass Xi (GeV/#it{c}^{2})", {HistType::kTH2F, {{50, 1.f, 2.f}, {50, 1.f, 2.f}}}}, {"massOmega", "Mass #Omega; signed #it{p}_{T} (GeV/#it{c}); mass (GeV/#it{c}^{2})", {HistType::kTH2F, {{100, -5.f, 5.f}, {100, 1.62f, 1.72f}}}}, {"massOmegaWithBkg", "Mass Omega with Background; mass Omega (GeV/#it{c}^{2}); counts", {HistType::kTH1F, {{100, 1.62f, 1.72f}}}}, @@ -256,7 +275,6 @@ struct LfTreeCreatorClusterStudies { Produces m_ClusterStudiesTable; Produces m_ClusterStudiesTableExtra; Produces m_ClusterStudiesTableMc; - Produces m_ClusterStudiesTableMcExtra; struct V0TrackParCov { int64_t globalIndex; @@ -331,7 +349,7 @@ struct LfTreeCreatorClusterStudies { } template - float dcaToPV(const std::array& PV, T& trackParCov, gpu::gpustd::array& dcaInfo) + float dcaToPV(const std::array& PV, T& trackParCov, std::array& dcaInfo) { o2::base::Propagator::Instance()->propagateToDCABxByBz({PV[0], PV[1], PV[2]}, trackParCov, 2.f, m_fitter.getMatCorrType(), &dcaInfo); return std::hypot(dcaInfo[0], dcaInfo[1]); @@ -403,6 +421,7 @@ struct LfTreeCreatorClusterStudies { bool qualitySelectionCascade(const double dcaCascDaughters, const double cosPA) { + m_hAnalysis.fill(HIST("casc_dca_daughter_pairs"), dcaCascDaughters); if (std::abs(dcaCascDaughters) > cascsetting_dcaCascDaughters) { return false; } @@ -414,6 +433,155 @@ struct LfTreeCreatorClusterStudies { return true; } + uint8_t selectV0MotherHypothesis(float massK0sV0, float massLambdaV0, float massAntiLambdaV0, float alphaAP, const o2::aod::V0& v0) + { + uint8_t v0Bitmask(0); + if (v0.isPhotonV0()) { + SETBIT(v0Bitmask, Photon); + } + if (std::abs(massK0sV0 - o2::constants::physics::MassK0Short) < v0setting_massWindowK0s) { + SETBIT(v0Bitmask, K0s); + } + if ((std::abs(massLambdaV0 - o2::constants::physics::MassLambda0) < v0setting_massWindowLambda) && (alphaAP > 0)) { + SETBIT(v0Bitmask, Lambda); + } + if ((std::abs(massAntiLambdaV0 - o2::constants::physics::MassLambda0) < v0setting_massWindowLambda) && (alphaAP < 0)) { + SETBIT(v0Bitmask, AntiLambda); + } + return v0Bitmask; + } + + template + bool selectPidV0Daughters(Candidate& candidatePos, Candidate& candidateNeg, const T& posTrack, + const T& negTrack, const std::array& momMother, const std::array& decayVtx, + float qtAP, float radiusV0, uint8_t v0Bitmask) + { + if (TESTBIT(v0Bitmask, Lambda)) { + if (qtAP < lambdasetting_qtAPcut) + return false; + if (std::abs(posTrack.tpcNSigmaPr()) > v0setting_nsigmatpcPr || std::abs(negTrack.tpcNSigmaPi()) > v0setting_nsigmatpcPi) + return false; + if (std::hypot(momMother[0], momMother[1], momMother[2]) < lambdasetting_pmin) + return false; + candidatePos.partID = PartID::pr; + candidateNeg.partID = PartID::pi; + candidatePos.nsigmaTPC = posTrack.tpcNSigmaPr(); + candidateNeg.nsigmaTPC = negTrack.tpcNSigmaPi(); + m_hAnalysis.fill(HIST("v0_type"), V0Type::Lambda); + + } else if (TESTBIT(v0Bitmask, AntiLambda)) { + if (qtAP < lambdasetting_qtAPcut) + return false; + if (std::abs(posTrack.tpcNSigmaPi()) > v0setting_nsigmatpcPi || std::abs(negTrack.tpcNSigmaPr()) > v0setting_nsigmatpcPr) + return false; + if (std::hypot(momMother[0], momMother[1], momMother[2]) < lambdasetting_pmin) + return false; + candidatePos.partID = PartID::pi; + candidateNeg.partID = PartID::pr; + candidatePos.nsigmaTPC = posTrack.tpcNSigmaPi(); + candidateNeg.nsigmaTPC = negTrack.tpcNSigmaPr(); + m_hAnalysis.fill(HIST("v0_type"), V0Type::AntiLambda); + + } else if (TESTBIT(v0Bitmask, K0s)) { + m_hAnalysis.fill(HIST("v0_type"), V0Type::K0s); + return false; // K0s not implemented + + } else if (TESTBIT(v0Bitmask, Photon)) { + // require photon conversion to happen in one of the Inner Tracker layers (± 0.5 cm resolution) + m_hAnalysis.fill(HIST("photon_conversion_position"), decayVtx[0], decayVtx[1]); + m_hAnalysis.fill(HIST("photon_radiusV0"), radiusV0); + if (!(radiusV0 > electronsetting_conversion_rmin && radiusV0 < electronsetting_conversion_rmax)) + return false; + if (std::abs(posTrack.tpcNSigmaEl()) > v0setting_nsigmatpcEl || std::abs(negTrack.tpcNSigmaEl()) > v0setting_nsigmatpcEl) + return false; + m_hAnalysis.fill(HIST("photon_conversion_position_layer"), decayVtx[0], decayVtx[1]); + candidatePos.partID = PartID::el; + candidateNeg.partID = PartID::el; + candidatePos.nsigmaTPC = posTrack.tpcNSigmaEl(); + candidateNeg.nsigmaTPC = negTrack.tpcNSigmaEl(); + m_hAnalysis.fill(HIST("v0_type"), V0Type::Photon); + + } else { + return false; + } + + return true; + } + + /** + * Fill the histograms for the V0 candidate and return the mass of the V0 + */ + float fillHistogramsV0(float massLambdaV0, float massAntiLambdaV0, + const std::array& momMother, + const Candidate& candidatePos, const Candidate& candidateNeg, float alphaAP, float qtAP, float radiusV0, uint8_t v0Bitmask) + { + float massV0{0.f}; + m_hAnalysis.fill(HIST("v0_selections"), V0Selections::kV0DaughterDCAtoPV); + if (TESTBIT(v0Bitmask, Lambda)) { + massV0 = massLambdaV0; + m_hAnalysis.fill(HIST("massLambda"), std::hypot(momMother[0], momMother[1], momMother[2]), massLambdaV0); + m_hAnalysis.fill(HIST("armenteros_plot_lambda"), alphaAP, qtAP); + m_hAnalysis.fill(HIST("nSigmaTPCPr"), candidatePos.p, candidatePos.nsigmaTPC); + m_hAnalysis.fill(HIST("nSigmaITSPr"), candidatePos.p, m_responseITS.nSigmaITS(candidatePos.itsClusterSize, candidatePos.p, candidatePos.eta)); + m_hAnalysis.fill(HIST("nSigmaTPCPi"), candidateNeg.p, candidateNeg.nsigmaTPC); + m_hAnalysis.fill(HIST("nSigmaITSPi"), candidateNeg.p, m_responseITS.nSigmaITS(candidateNeg.itsClusterSize, candidateNeg.p, candidateNeg.eta)); + m_hAnalysis.fill(HIST("pmatchingPr"), candidatePos.pTPC, (candidatePos.pTPC - candidatePos.p) / candidatePos.pTPC); + m_hAnalysis.fill(HIST("pmatchingPi"), -candidateNeg.pTPC, (candidateNeg.pTPC - candidateNeg.p) / candidateNeg.pTPC); + + } else if (TESTBIT(v0Bitmask, AntiLambda)) { + massV0 = massAntiLambdaV0; + m_hAnalysis.fill(HIST("massLambda"), std::hypot(momMother[0], momMother[1], momMother[2]) * -1.f, massAntiLambdaV0); + // "signed" pt for antimatter + m_hAnalysis.fill(HIST("armenteros_plot_lambda"), alphaAP, qtAP); + m_hAnalysis.fill(HIST("nSigmaTPCPi"), candidatePos.p, candidatePos.nsigmaTPC); + m_hAnalysis.fill(HIST("nSigmaITSPi"), candidatePos.p, m_responseITS.nSigmaITS(candidatePos.itsClusterSize, candidatePos.p, candidatePos.eta)); + m_hAnalysis.fill(HIST("nSigmaTPCPr"), candidateNeg.p, candidateNeg.nsigmaTPC); + m_hAnalysis.fill(HIST("nSigmaITSPr"), candidateNeg.p, m_responseITS.nSigmaITS(candidateNeg.itsClusterSize, candidateNeg.p, candidateNeg.eta)); + m_hAnalysis.fill(HIST("pmatchingPi"), candidatePos.pTPC, (candidatePos.pTPC - candidatePos.p) / candidatePos.pTPC); + m_hAnalysis.fill(HIST("pmatchingPr"), -candidateNeg.pTPC, (candidateNeg.pTPC - candidateNeg.p) / candidateNeg.pTPC); + + } else if (TESTBIT(v0Bitmask, Photon)) { + massV0 = 0.f; + m_hAnalysis.fill(HIST("nSigmaTPCEl"), candidatePos.p, candidatePos.nsigmaTPC); + m_hAnalysis.fill(HIST("nSigmaTPCEl"), candidateNeg.p, candidateNeg.nsigmaTPC); + m_hAnalysis.fill(HIST("nSigmaITSEl"), candidatePos.p, m_responseITS.nSigmaITS(candidatePos.itsClusterSize, candidatePos.p, candidatePos.eta)); + m_hAnalysis.fill(HIST("nSigmaITSEl"), candidateNeg.p, m_responseITS.nSigmaITS(candidateNeg.itsClusterSize, candidateNeg.p, candidateNeg.eta)); + m_hAnalysis.fill(HIST("armenteros_plot_gamma"), alphaAP, qtAP); + m_hAnalysis.fill(HIST("pmatchingEl"), candidatePos.pTPC, (candidatePos.pTPC - candidatePos.p) / candidatePos.pTPC); + m_hAnalysis.fill(HIST("pmatchingEl"), -candidateNeg.pTPC, (candidateNeg.pTPC - candidateNeg.p) / candidateNeg.pTPC); + } + m_hAnalysis.fill(HIST("radiusV0"), radiusV0); + m_hAnalysis.fill(HIST("armenteros_plot"), alphaAP, qtAP); + + return massV0; + } + + template + void fillTable(const Candidate& candidate) + { + m_ClusterStudiesTable( + candidate.p, // p + candidate.eta, // eta + candidate.phi, // phi + candidate.itsClusterSize, // itsClsize + static_cast(candidate.partID)); // partID + if (!setting_smallTable) { + m_ClusterStudiesTableExtra( + candidate.pTPC, // pTPC + candidate.pidInTrk, // pidInTrk + candidate.nsigmaTPC, // TpcNSigma + candidate.nsigmaTOF, // TofNSigma + candidate.tofMass, // TofMass + candidate.cosPAMother, // cosPA + candidate.massMother); // massMother + } + + if constexpr (isMC) { + m_ClusterStudiesTableMc( + candidate.pdgCode); // pdgCod + } + } + // ========================================================================================================= template @@ -450,7 +618,7 @@ struct LfTreeCreatorClusterStudies { { float beta = o2::pid::tof::Beta::GetBeta(candidate); beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked - return candidate.tpcInnerParam() * 2.f * std::sqrt(1.f / (beta * beta) - 1.f); + return candidate.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f); } // ========================================================================================================= @@ -605,7 +773,7 @@ struct LfTreeCreatorClusterStudies { float qtAP = computeQtAP(momMother, momPos); m_hAnalysis.fill(HIST("armenteros_plot_before_selections"), alphaAP, qtAP); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; V0TrackParCov v0TrackParCov{v0.globalIndex(), m_fitter.createParentTrackParCov()}; float dcaV0daughters = std::sqrt(std::abs(m_fitter.getChi2AtPCACandidate())); float radiusV0 = std::hypot(decayVtx[0], decayVtx[1]); @@ -622,61 +790,22 @@ struct LfTreeCreatorClusterStudies { m_hAnalysis.fill(HIST("Lambda_vs_K0s"), massK0sV0, massLambdaV0); // float massPhotonV0 = computeMassMother(o2::constants::physics::MassElectron, o2::constants::physics::MassElectron, momPos, momNeg, momMother); - uint8_t v0Bitmask(0); - if (v0.isPhotonV0()) { - SETBIT(v0Bitmask, Photon); - } - if (std::abs(massK0sV0 - o2::constants::physics::MassK0Short) < v0setting_massWindowK0s) { - SETBIT(v0Bitmask, K0s); - } - if ((std::abs(massLambdaV0 - o2::constants::physics::MassLambda0) < v0setting_massWindowLambda) && (alphaAP > 0)) { - SETBIT(v0Bitmask, Lambda); - } - if ((std::abs(massAntiLambdaV0 - o2::constants::physics::MassLambda0) < v0setting_massWindowLambda) && (alphaAP < 0)) { - SETBIT(v0Bitmask, AntiLambda); - } + uint8_t v0Bitmask = selectV0MotherHypothesis(massK0sV0, massLambdaV0, massAntiLambdaV0, alphaAP, v0); if (v0Bitmask == 0 || (v0Bitmask & (v0Bitmask - 1)) != 0) { return; } m_hAnalysis.fill(HIST("v0_selections"), V0Selections::kV0PID); - uint8_t partID_pos{0}, partID_neg{0}; - if (TESTBIT(v0Bitmask, Lambda)) { - if (qtAP < lambdasetting_qtAPcut) - return; - if (std::abs(posTrack.tpcNSigmaPr()) > v0setting_nsigmatpcPr || std::abs(negTrack.tpcNSigmaPi()) > v0setting_nsigmatpcPi) - return; - if (std::hypot(momMother[0], momMother[1], momMother[2]) < lambdasetting_pmin) - return; - partID_pos = PartID::pr; - partID_neg = PartID::pi; - m_hAnalysis.fill(HIST("v0_type"), V0Type::Lambda); - } else if (TESTBIT(v0Bitmask, AntiLambda)) { - if (qtAP < lambdasetting_qtAPcut) - return; - if (std::abs(posTrack.tpcNSigmaPi()) > v0setting_nsigmatpcPr || std::abs(negTrack.tpcNSigmaPr()) > v0setting_nsigmatpcPi) - return; - if (std::hypot(momMother[0], momMother[1], momMother[2]) < lambdasetting_pmin) - return; - partID_pos = PartID::pi; - partID_neg = PartID::pr; - m_hAnalysis.fill(HIST("v0_type"), V0Type::AntiLambda); - } else if (TESTBIT(v0Bitmask, K0s)) { - m_hAnalysis.fill(HIST("v0_type"), V0Type::K0s); - return; // K0s not implemented - } else if (TESTBIT(v0Bitmask, Photon)) { - // require photon conversion to happen in one of the Inner Tracker layers (± 0.5 cm resolution) - m_hAnalysis.fill(HIST("photon_conversion_position"), decayVtx[0], decayVtx[1]); - m_hAnalysis.fill(HIST("photon_radiusV0"), radiusV0); - if (!(radiusV0 > 1.76 && radiusV0 < 4.71)) - return; - if (std::abs(posTrack.tpcNSigmaEl()) > v0setting_nsigmatpcEl || std::abs(negTrack.tpcNSigmaEl()) > v0setting_nsigmatpcEl) - return; - m_hAnalysis.fill(HIST("photon_conversion_position_layer"), decayVtx[0], decayVtx[1]); - partID_pos = PartID::el; - partID_neg = PartID::el; - m_hAnalysis.fill(HIST("v0_type"), V0Type::Photon); - } else { + Candidate candidatePos(std::hypot(momPos[0], momPos[1], momPos[2]) * posTrack.sign(), + RecoDecay::eta(momPos), RecoDecay::phi(momPos), posTrack.itsClusterSizes(), + 0, posTrack.tpcInnerParam() * posTrack.sign(), posTrack.pidForTracking(), + -999.f, -999.f, -999.f, cosPA, -999.f, 0); + Candidate candidateNeg(std::hypot(momNeg[0], momNeg[1], momNeg[2]) * negTrack.sign(), + RecoDecay::eta(momNeg), RecoDecay::phi(momNeg), negTrack.itsClusterSizes(), + 0, negTrack.tpcInnerParam() * negTrack.sign(), negTrack.pidForTracking(), + -999.f, -999.f, -999.f, cosPA, -999.f, 0); + + if (!selectPidV0Daughters(candidatePos, candidateNeg, posTrack, negTrack, momMother, decayVtx, qtAP, radiusV0, v0Bitmask)) { return; } @@ -689,44 +818,10 @@ struct LfTreeCreatorClusterStudies { return; } - float massV0{0.f}; - m_hAnalysis.fill(HIST("v0_selections"), V0Selections::kV0DaughterDCAtoPV); - if (TESTBIT(v0Bitmask, Lambda)) { - massV0 = massLambdaV0; - m_hAnalysis.fill(HIST("massLambda"), std::hypot(momMother[0], momMother[1], momMother[2]), massLambdaV0); - m_hAnalysis.fill(HIST("armenteros_plot_lambda"), alphaAP, qtAP); - m_hAnalysis.fill(HIST("nSigmaTPCPr"), std::hypot(momPos[0], momPos[1], momPos[2]), posTrack.tpcNSigmaPr()); - m_hAnalysis.fill(HIST("nSigmaITSPr"), std::hypot(momPos[0], momPos[1], momPos[2]), m_responseITS.nSigmaITS(posTrack.itsClusterSizes(), posTrack.p(), posTrack.eta())); - m_hAnalysis.fill(HIST("nSigmaTPCPi"), std::hypot(momNeg[0], momNeg[1], momNeg[2]) * -1.f, negTrack.tpcNSigmaPi()); - m_hAnalysis.fill(HIST("nSigmaITSPi"), std::hypot(momNeg[0], momNeg[1], momNeg[2]) * -1.f, m_responseITS.nSigmaITS(negTrack.itsClusterSizes(), negTrack.p(), negTrack.eta())); - m_hAnalysis.fill(HIST("pmatchingPr"), posTrack.tpcInnerParam(), (posTrack.tpcInnerParam() - posTrack.p()) / posTrack.tpcInnerParam()); - m_hAnalysis.fill(HIST("pmatchingPi"), -negTrack.tpcInnerParam(), (negTrack.tpcInnerParam() - negTrack.p()) / negTrack.tpcInnerParam()); - - } else if (TESTBIT(v0Bitmask, AntiLambda)) { - massV0 = massAntiLambdaV0; - m_hAnalysis.fill(HIST("massLambda"), std::hypot(momMother[0], momMother[1], momMother[2]) * -1.f, massAntiLambdaV0); - // "signed" pt for antimatter - m_hAnalysis.fill(HIST("armenteros_plot_lambda"), alphaAP, qtAP); - m_hAnalysis.fill(HIST("nSigmaTPCPi"), std::hypot(momPos[0], momPos[1], momPos[2]), posTrack.tpcNSigmaPi()); - m_hAnalysis.fill(HIST("nSigmaITSPi"), std::hypot(momPos[0], momPos[1], momPos[2]), m_responseITS.nSigmaITS(posTrack.itsClusterSizes(), posTrack.p(), posTrack.eta())); - m_hAnalysis.fill(HIST("nSigmaTPCPr"), std::hypot(momNeg[0], momNeg[1], momNeg[2]) * -1.f, negTrack.tpcNSigmaPr()); - m_hAnalysis.fill(HIST("nSigmaITSPr"), std::hypot(momNeg[0], momNeg[1], momNeg[2]) * -1.f, m_responseITS.nSigmaITS(negTrack.itsClusterSizes(), negTrack.p(), negTrack.eta())); - m_hAnalysis.fill(HIST("pmatchingPi"), posTrack.tpcInnerParam(), (posTrack.tpcInnerParam() - posTrack.p()) / posTrack.tpcInnerParam()); - m_hAnalysis.fill(HIST("pmatchingPr"), -negTrack.tpcInnerParam(), (negTrack.tpcInnerParam() - negTrack.p()) / negTrack.tpcInnerParam()); - - } else if (TESTBIT(v0Bitmask, Photon)) { - massV0 = 0.f; - m_hAnalysis.fill(HIST("nSigmaTPCEl"), std::hypot(momPos[0], momPos[1], momPos[2]), posTrack.tpcNSigmaEl()); - m_hAnalysis.fill(HIST("nSigmaTPCEl"), std::hypot(momNeg[0], momNeg[1], momNeg[2]) * -1.f, negTrack.tpcNSigmaEl()); - m_hAnalysis.fill(HIST("nSigmaITSEl"), std::hypot(momPos[0], momPos[1], momPos[2]), m_responseITS.nSigmaITS(posTrack.itsClusterSizes(), posTrack.p(), posTrack.eta())); - m_hAnalysis.fill(HIST("nSigmaITSEl"), std::hypot(momNeg[0], momNeg[1], momNeg[2]) * -1.f, m_responseITS.nSigmaITS(negTrack.itsClusterSizes(), negTrack.p(), negTrack.eta())); - m_hAnalysis.fill(HIST("armenteros_plot_gamma"), alphaAP, qtAP); - m_hAnalysis.fill(HIST("pmatchingEl"), posTrack.tpcInnerParam(), (posTrack.tpcInnerParam() - posTrack.p()) / posTrack.tpcInnerParam()); - m_hAnalysis.fill(HIST("pmatchingEl"), -negTrack.tpcInnerParam(), (negTrack.tpcInnerParam() - negTrack.p()) / negTrack.tpcInnerParam()); - } - m_hAnalysis.fill(HIST("radiusV0"), radiusV0); - m_hAnalysis.fill(HIST("armenteros_plot"), alphaAP, qtAP); - m_v0TrackParCovs.push_back(v0TrackParCov); + m_v0TrackParCovs.emplace_back(v0TrackParCov); + float massV0 = fillHistogramsV0(massLambdaV0, massAntiLambdaV0, momMother, candidatePos, candidateNeg, alphaAP, qtAP, radiusV0, v0Bitmask); + candidatePos.massMother = massV0; + candidateNeg.massMother = massV0; if (!setting_fillV0) { return; @@ -740,95 +835,13 @@ struct LfTreeCreatorClusterStudies { auto posMcParticle = posTrack.mcParticle(); auto negMcParticle = negTrack.mcParticle(); - if (setting_smallTable) { - m_ClusterStudiesTableMc( - std::hypot(momPos[0], momPos[1], momPos[2]) * posTrack.sign(), // p_pos - RecoDecay::eta(momPos), // eta_pos - RecoDecay::phi(momPos), // phi_pos - posTrack.itsClusterSizes(), // itsClsize_pos - partID_pos, // partID_pos - posMcParticle.pdgCode()); // pdgCode_pos - m_ClusterStudiesTableMc( - std::hypot(momNeg[0], momNeg[1], momNeg[2]) * negTrack.sign(), // p_neg - RecoDecay::eta(momNeg), // eta_neg - RecoDecay::phi(momNeg), // phi_neg - negTrack.itsClusterSizes(), // itsClsize_neg - partID_neg, // partID_neg - negMcParticle.pdgCode()); // pdgCode_neg - } else { - m_ClusterStudiesTableMcExtra( - std::hypot(momPos[0], momPos[1], momPos[2]) * posTrack.sign(), // p_pos - RecoDecay::eta(momPos), // eta_pos - RecoDecay::phi(momPos), // phi_pos - posTrack.itsClusterSizes(), // itsClsize_pos - partID_pos, // partID_pos - posMcParticle.pdgCode(), // pdgCode_pos - posTrack.tpcInnerParam() * posTrack.sign(), // pTPC_pos - posTrack.pidForTracking(), // pidInTrk_pos - -999.f, // TpcNSigma_pos - -999.f, // TofNSigma_pos - -999.f, // TofMass_pos - cosPA, // cosPA - massV0); // massV0 - m_ClusterStudiesTableMcExtra( - std::hypot(momNeg[0], momNeg[1], momNeg[2]) * negTrack.sign(), // p_neg - RecoDecay::eta(momNeg), // eta_neg - RecoDecay::phi(momNeg), // phi_neg - negTrack.itsClusterSizes(), // itsClsize_neg - partID_neg, // partID_neg - negMcParticle.pdgCode(), // pdgCode_pos - negTrack.tpcInnerParam() * negTrack.sign(), // pTPC_neg - negTrack.pidForTracking(), // pidInTrk_neg - -999.f, // TpcNSigma_neg - -999.f, // TofNSigma_neg - -999.f, // TofMass_neg - cosPA, // cosPA - massV0); // massV0 - } - } else { // data - if (setting_smallTable) { - m_ClusterStudiesTable( - std::hypot(momPos[0], momPos[1], momPos[2]) * posTrack.sign(), // p_pos - RecoDecay::eta(momPos), // eta_pos - RecoDecay::phi(momPos), // phi_pos - posTrack.itsClusterSizes(), // itsClsize_pos - partID_pos); // partID_pos - m_ClusterStudiesTable( - std::hypot(momNeg[0], momNeg[1], momNeg[2]) * negTrack.sign(), // p_neg - RecoDecay::eta(momNeg), // eta_neg - RecoDecay::phi(momNeg), // phi_neg - negTrack.itsClusterSizes(), // itsClsize_neg - partID_neg); // partID_neg - } else { - m_ClusterStudiesTableExtra( - std::hypot(momPos[0], momPos[1], momPos[2]) * posTrack.sign(), // p_pos - RecoDecay::eta(momPos), // eta_pos - RecoDecay::phi(momPos), // phi_pos - posTrack.itsClusterSizes(), // itsClsize_pos - partID_pos, // partID_pos - posTrack.tpcInnerParam() * posTrack.sign(), // pTPC_pos - posTrack.pidForTracking(), // pidInTrk_pos - -999.f, // TpcNSigma_pos - -999.f, // TofNSigma_pos - -999.f, // TofMass_pos - cosPA, // cosPA - massV0); // massV0 - m_ClusterStudiesTableExtra( - std::hypot(momNeg[0], momNeg[1], momNeg[2]) * negTrack.sign(), // p_neg - RecoDecay::eta(momNeg), // eta_neg - RecoDecay::phi(momNeg), // phi_neg - negTrack.itsClusterSizes(), // itsClsize_neg - partID_neg, // partID_neg - negTrack.tpcInnerParam() * negTrack.sign(), // pTPC_neg - negTrack.pidForTracking(), // pidInTrk_neg - -999.f, // TpcNSigma_neg - -999.f, // TofNSigma_neg - -999.f, // TofMass_neg - cosPA, // cosPA - massV0); // massV0 - } + candidatePos.pdgCode = posMcParticle.pdgCode(); + candidateNeg.pdgCode = negMcParticle.pdgCode(); } + fillTable(candidatePos); + fillTable(candidateNeg); + m_hAnalysis.fill(HIST("isPositive"), true); m_hAnalysis.fill(HIST("isPositive"), false); } @@ -866,7 +879,7 @@ struct LfTreeCreatorClusterStudies { if (!qualitySelectionCascade(dcaV0daughters, cosPA)) { return; } - // gpu::gpustd::array dcaInfo; + // std::array dcaInfo; // float dcaToPVbachelor = dcaToPV(PV, bachelorTrackCovariance, dcaInfo); float massXi = computeMassMother(o2::constants::physics::MassLambda0, o2::constants::physics::MassPionCharged, momV0, momBachelor, momMother); @@ -891,59 +904,31 @@ struct LfTreeCreatorClusterStudies { uint8_t partID_bachelor = PartID::ka; + m_ClusterStudiesTable( + std::hypot(momBachelor[0], momBachelor[1], momBachelor[2]) * bachelorTrack.sign(), // p_K + RecoDecay::eta(momBachelor), // eta_K + RecoDecay::phi(momBachelor), // phi_K + bachelorTrack.itsClusterSizes(), // itsClSize_K + partID_bachelor); // partID_K + if (!setting_smallTable) { + m_ClusterStudiesTableExtra( + bachelorTrack.tpcInnerParam() * bachelorTrack.sign(), // pTPC_K + bachelorTrack.pidForTracking(), // PIDinTrk_K + -999.f, // TpcNSigma_K + -999.f, // TofNSigma_K + -999.f, // TofMass_K + cosPA, // cosPA + massOmega); + } + if constexpr (isMC) { if (!bachelorTrack.has_mcParticle()) { return; } auto mcParticle = bachelorTrack.mcParticle(); - if (setting_smallTable) { - m_ClusterStudiesTableMc( - std::hypot(momBachelor[0], momBachelor[1], momBachelor[2]) * bachelorTrack.sign(), // p_K - RecoDecay::eta(momBachelor), // eta_K - RecoDecay::phi(momBachelor), // phi_K - bachelorTrack.itsClusterSizes(), // itsClSize_K - partID_bachelor, // partID_K - mcParticle.pdgCode()); // pdgCode_K - } else { - m_ClusterStudiesTableMcExtra( - std::hypot(momBachelor[0], momBachelor[1], momBachelor[2]) * bachelorTrack.sign(), // p_K - RecoDecay::eta(momBachelor), // eta_K - RecoDecay::phi(momBachelor), // phi_K - bachelorTrack.itsClusterSizes(), // itsClSize_K - partID_bachelor, // partID_K - mcParticle.pdgCode(), // pdgCode_K - bachelorTrack.tpcInnerParam() * bachelorTrack.sign(), // pTPC_K - bachelorTrack.pidForTracking(), // PIDinTrk_K - -999.f, // TpcNSigma_K - -999.f, // TofNSigma_K - -999.f, // TofMass_K - cosPA, // cosPA - massOmega); // massMother - } - } else { - if (setting_smallTable) { - m_ClusterStudiesTable( - std::hypot(momBachelor[0], momBachelor[1], momBachelor[2]) * bachelorTrack.sign(), // p_K - RecoDecay::eta(momBachelor), // eta_K - RecoDecay::phi(momBachelor), // phi_K - bachelorTrack.itsClusterSizes(), // itsClSize_K - partID_bachelor); // partID_K - } else { - m_ClusterStudiesTableExtra( - std::hypot(momBachelor[0], momBachelor[1], momBachelor[2]) * bachelorTrack.sign(), // p_K - RecoDecay::eta(momBachelor), // eta_K - RecoDecay::phi(momBachelor), // phi_K - bachelorTrack.itsClusterSizes(), // itsClSize_K - partID_bachelor, // partID_K - bachelorTrack.tpcInnerParam() * bachelorTrack.sign(), // pTPC_K - bachelorTrack.pidForTracking(), // PIDinTrk_K - -999.f, // TpcNSigma_K - -999.f, // TofNSigma_K - -999.f, // TofMass_K - cosPA, // cosPA - massOmega); - } + m_ClusterStudiesTableMc( + mcParticle.pdgCode()); // pdgCode_K } m_hAnalysis.fill(HIST("isPositive"), bachelorTrack.p() > 0); @@ -960,7 +945,7 @@ struct LfTreeCreatorClusterStudies { return; } m_hAnalysis.fill(HIST("de_selections"), DeSelections::kDeNClsIts); - if (!selectionPIDtpcDe(track)) { + if (std::abs(track.tpcNSigmaDe()) > desetting_nsigmatpc) { return; } m_hAnalysis.fill(HIST("de_selections"), DeSelections::kDePIDtpc); @@ -968,7 +953,7 @@ struct LfTreeCreatorClusterStudies { return; } m_hAnalysis.fill(HIST("de_selections"), DeSelections::kDePIDtof); - m_hAnalysis.fill(HIST("nSigmaTPCDe"), track.p() * track.sign(), computeNSigmaDe(track)); + m_hAnalysis.fill(HIST("nSigmaTPCDe"), track.p() * track.sign(), track.tpcNSigmaDe()); m_hAnalysis.fill(HIST("nSigmaITSDe"), track.p() * track.sign(), m_responseITS.nSigmaITS(track.itsClusterSizes(), track.p(), track.eta())); m_hAnalysis.fill(HIST("nSigmaTOFDe"), track.p() * track.sign(), track.tofNSigmaDe()); m_hAnalysis.fill(HIST("TOFmassDe"), track.p() * track.sign(), computeTOFmassDe(track)); @@ -976,6 +961,23 @@ struct LfTreeCreatorClusterStudies { uint8_t partID = PartID::de; + m_ClusterStudiesTable( + track.p() * track.sign(), // p_De, + track.eta(), // eta_De, + track.phi(), // phi_De, + track.itsClusterSizes(), // itsClSize_De, + partID); // partID_De + if (!setting_smallTable) { + m_ClusterStudiesTableExtra( + track.tpcInnerParam() * track.sign(), // pTPC_De, + track.pidForTracking(), // PIDinTrk_De, + track.tpcNSigmaDe(), // TpcNSigma_De, + track.tofNSigmaDe(), // TofNSigma_De, + computeTOFmassDe(track), // TofMass_De, + -999.f, // cosPA, + -999.f); // massMother + } + if constexpr (isMC) { if (!track.has_mcParticle() || track.sign() > 0) { return; @@ -983,53 +985,8 @@ struct LfTreeCreatorClusterStudies { auto mcParticle = track.mcParticle(); - if (setting_smallTable) { - m_ClusterStudiesTableMc( - track.p() * track.sign(), // p_De, - track.eta(), // eta_De, - track.phi(), // phi_De, - track.itsClusterSizes(), // itsClSize_De, - partID, // pdgCode_De, - mcParticle.pdgCode()); // pdgCodeMc_De - } else { - m_ClusterStudiesTableMcExtra( - track.p() * track.sign(), // p_De, - track.eta(), // eta_De, - track.phi(), // phi_De, - track.itsClusterSizes(), // itsClSize_De, - partID, // pdgCode_De, - mcParticle.pdgCode(), // pdgCodeMc_De - track.tpcInnerParam() * track.sign(), // pTPC_De, - track.pidForTracking(), // PIDinTrk_De, - computeNSigmaDe(track), // TpcNSigma_De, - track.tofNSigmaDe(), // TofNSigma_De, - computeTOFmassDe(track), // TofMass_De, - -999.f, // cosPA, - -999.f); // massMother - } - } else { - if (setting_smallTable) { - m_ClusterStudiesTable( - track.p() * track.sign(), // p_De, - track.eta(), // eta_De, - track.phi(), // phi_De, - track.itsClusterSizes(), // itsClSize_De, - partID); // pdgCode_De - } else { - m_ClusterStudiesTableExtra( - track.p() * track.sign(), // p_De, - track.eta(), // eta_De, - track.phi(), // phi_De, - track.itsClusterSizes(), // itsClSize_De, - partID, // pdgCode_De, - track.tpcInnerParam() * track.sign(), // pTPC_De, - track.pidForTracking(), // PIDinTrk_De, - computeNSigmaDe(track), // TpcNSigma_De, - track.tofNSigmaDe(), // TofNSigma_De, - computeTOFmassDe(track), // TofMass_De, - -999.f, // cosPA, - -999.f); // massMother - } + m_ClusterStudiesTableMc( + mcParticle.pdgCode()); // pdgCode_De } m_hAnalysis.fill(HIST("isPositive"), track.sign() > 0); @@ -1062,60 +1019,31 @@ struct LfTreeCreatorClusterStudies { m_hAnalysis.fill(HIST("TOFmassHe"), track.p() * track.sign(), tofMass); m_hAnalysis.fill(HIST("pmatchingHe"), track.sign() * correctedTPCinnerParam, (correctedTPCinnerParam - track.p()) / correctedTPCinnerParam); + m_ClusterStudiesTable( + track.p() * track.sign(), // p_He3, + track.eta(), // eta_He3, + track.phi(), // phi_He3, + track.itsClusterSizes(), // itsClSize_He3, + partID); // partID_He3 + if (!setting_smallTable) { + m_ClusterStudiesTableExtra( + correctedTPCinnerParam * track.sign(), // pTPC_He3, + track.pidForTracking(), // PIDinTrk_He3, + computeNSigmaHe3(track), // TpcNSigma_He3, + -999.f, // TofNSigma_He3, + tofMass, // TofMass_He3, + -999.f, // cosPA, + -999.f); // massMother + } + if constexpr (isMC) { if (!track.has_mcParticle()) { return; } auto mcParticle = track.mcParticle(); - if (setting_smallTable) { - m_ClusterStudiesTableMc( - track.p() * track.sign(), // p_He3, - track.eta(), // eta_He3, - track.phi(), // phi_He3, - track.itsClusterSizes(), // itsClSize_He3, - partID, // pdgCode_He3, - mcParticle.pdgCode()); // pdgCodeMc_He3 - } else { - m_ClusterStudiesTableMcExtra( - track.p() * track.sign(), // p_He3 - track.eta(), // eta_He3 - track.phi(), // phi_He3 - track.itsClusterSizes(), // itsClSize_He3 - partID, // pdgCode_He3 - mcParticle.pdgCode(), // pdgCodeMc_He3 - correctedTPCinnerParam * track.sign(), // pTPC_He3 - track.pidForTracking(), // PIDinTrk_He3 - computeNSigmaHe3(track), // TpcNSigma_He3 - -999.f, // TofNSigma_He3 - tofMass, // TofMass_He3 - -999.f, // cosPA_He3 - -999.f); // massMother_He3 - } - - } else { - if (setting_smallTable) { - m_ClusterStudiesTable( - track.p() * track.sign(), // p_He3, - track.eta(), // eta_He3, - track.phi(), // phi_He3, - track.itsClusterSizes(), // itsClSize_He3, - partID); // pdgCode_He3 - } else { - m_ClusterStudiesTableExtra( - track.p() * track.sign(), // p_He3, - track.eta(), // eta_He3, - track.phi(), // phi_He3, - track.itsClusterSizes(), // itsClSize_He3, - partID, // pdgCode_He3, - correctedTPCinnerParam * track.sign(), // pTPC_He3, - track.pidForTracking(), // PIDinTrk_He3, - computeNSigmaHe3(track), // TpcNSigma_He3, - -999.f, // TofNSigma_He3, - tofMass, // TofMass_He3, - -999.f, // cosPA, - -999.f); // massMother - } + m_ClusterStudiesTableMc( + mcParticle.pdgCode()); // pdgCodeMc_He3 } m_hAnalysis.fill(HIST("isPositive"), track.sign() > 0); @@ -1141,20 +1069,14 @@ struct LfTreeCreatorClusterStudies { return; } - if (setting_smallTable) { - m_ClusterStudiesTable( - track.p() * track.sign(), - track.eta(), - track.phi(), - track.itsClusterSizes(), - partID); - } else { + m_ClusterStudiesTable( + track.p() * track.sign(), + track.eta(), + track.phi(), + track.itsClusterSizes(), + partID); + if (!setting_smallTable) { m_ClusterStudiesTableExtra( - track.p() * track.sign(), // p, - track.eta(), // eta, - track.phi(), // phi, - track.itsClusterSizes(), // itsClSize, - partID, // pdgCode, track.tpcInnerParam() * track.sign(), // pTPC, track.pidForTracking(), // PIDinTrk, tpcNSigma, // TpcNSigma, diff --git a/PWGLF/TableProducer/Nuspex/LFTreeCreatorNuclei.cxx b/PWGLF/TableProducer/Nuspex/LFTreeCreatorNuclei.cxx index dda78a26c64..ca3f8a525b2 100644 --- a/PWGLF/TableProducer/Nuspex/LFTreeCreatorNuclei.cxx +++ b/PWGLF/TableProducer/Nuspex/LFTreeCreatorNuclei.cxx @@ -20,26 +20,27 @@ #include "PWGLF/DataModel/LFNucleiTables.h" #include "PWGLF/DataModel/LFParticleIdentification.h" -#include -#include -#include - -#include "ReconstructionDataFormats/Track.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/CCDB/EventSelectionParams.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" #include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include // #include @@ -249,6 +250,7 @@ struct LfTreeCreatorNuclei { track.tpcSignal(), track.pt(), track.eta(), track.phi(), track.sign(), + track.itsClusterSizes(), track.itsNCls(), track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), diff --git a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx index 980c3cee06f..7757cbc72a1 100644 --- a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx +++ b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx @@ -8,456 +8,509 @@ // 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. - -/// \brief Builder task for 3-body decay reconstruction (p + pion + bachelor) +// ======================== +/// \file decay3bodybuilder.cxx +/// \brief Builder task for 3-body hypertriton decay reconstruction (proton + pion + deuteron) /// \author Yuanzhe Wang -/// \author Carolina Reetz (KFParticle specific part) +/// \author Carolina Reetz +// ======================== -#include -#include -#include -#include -#include -#include +#include "TableHelper.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "DCAFitter/DCAFitterN.h" -#include "ReconstructionDataFormats/Track.h" +#include "PWGLF/DataModel/LFPIDTOFGenericTables.h" +#include "PWGLF/DataModel/Reduced3BodyTables.h" +#include "PWGLF/DataModel/Vtx3BodyTables.h" +#include "PWGLF/Utils/decay3bodyBuilderHelper.h" +#include "PWGLF/Utils/pidTOFGeneric.h" + +#include "Common/Core/PID/PIDTOF.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/Vtx3BodyTables.h" -#include "PWGLF/DataModel/pidTOFGeneric.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/PIDResponse.h" -#include "Common/Core/PID/PIDTOF.h" -#include "TableHelper.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" #include "Tools/KFparticle/KFUtilities.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" -#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include +#include +#include +#include +#include #ifndef HomogeneousField #define HomogeneousField #endif // includes KFParticle -#include "KFParticle.h" #include "KFPTrack.h" #include "KFPVertex.h" +#include "KFParticle.h" #include "KFParticleBase.h" #include "KFVertex.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using std::array; - -using FullTracksExtIU = soa::Join; -using FullTracksExtPIDIU = soa::Join; - -using ColwithEvTimes = o2::soa::Join; -using FullCols = o2::soa::Join; -using ColwithEvTimesMults = o2::soa::Join; -using TrackExtIUwithEvTimes = soa::Join; -using TrackExtPIDIUwithEvTimes = soa::Join; - -using MCLabeledTracksIU = soa::Join; - -struct vtxCandidate { - int track0Id; - int track1Id; - int track2Id; - int collisionId; - int decay3bodyId; - float vtxPos[3]; - float track0P[3]; - float track1P[3]; - float track2P[3]; - float dcadaughters; - float daudcaxytopv[3]; // 0 - proton, 1 - pion, 2 - bachelor - float daudcatopv[3]; // 0 - proton, 1 - pion, 2 - bachelor - float bachelortofNsigma; + +o2::common::core::MetadataHelper metadataInfo; + +static constexpr int nParameters = 1; +static const std::vector tableNames{ + "Decay3BodyIndices", + "Vtx3BodyDatas", + "Vtx3BodyCovs", + "McVtx3BodyDatas"}; + +static constexpr int nTablesConst = 4; + +static const std::vector parameterNames{"enable"}; +static const int defaultParameters[nTablesConst][nParameters]{ + {0}, // Decay3BodyIndices + {0}, // Vtx3BodyDatas + {0}, // Vtx3BodyCovs + {0} // McVtx3BodyDatas }; -struct decay3bodyBuilder { +using TracksExtPIDIUwithEvTimes = soa::Join; +using TracksExtPIDIUwithEvTimesLabeled = soa::Join; - Produces vtx3bodydata; - Produces kfvtx3bodydata; - Produces kfvtx3bodydatalite; - Service ccdb; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - std::vector vtxCandidates; - - // Configurables - Configurable d_UseAbsDCA{"d_UseAbsDCA", true, "Use Abs DCAs"}; - - enum hyp3body { kH3L = 0, - kH4L, - kHe4L, - kHe5L, - kNHyp3body }; - - enum vtxstep { kVtxAll = 0, - kVtxTPCNcls, - kVtxPIDCut, - kVtxhasSV, - kVtxDcaDau, - kVtxCosPA, - kNVtxSteps }; - - enum kfvtxstep { kKfVtxAll = 0, - kKfVtxCharge, - kKfVtxEta, - kKfVtxTPCNcls, - kKfVtxTPCRows, - kKfVtxTPCPID, - kKfVtxDCAxyPV, - kKfVtxDCAzPV, - kKfVtxV0MassConst, - kKfVtxhasSV, - kKfVtxDcaDau, - kKfVtxDcaDauVtx, - kKfVtxDauPt, - kKfVtxRap, - kKfVtxPt, - kKfVtxMass, - kKfVtxCosPA, - kKfVtxCosPAXY, - kKfVtxChi2geo, - kKfVtxTopoConstr, - kKfVtxChi2topo, - kKfNVtxSteps }; - - HistogramRegistry registry{"registry", {}}; - - // hypothesis - Configurable motherhyp{"motherhyp", 0, "hypothesis of the 3body decayed particle"}; // corresponds to hyp3body - int bachelorcharge = 1; // to be updated in Init base on the hypothesis - // o2::aod::pidtofgeneric::TofPidNewCollision bachelorTOFPID; // to be updated in Init base on the hypothesis - o2::aod::pidtofgeneric::TofPidNewCollision bachelorTOFPID; // to be updated in Init base on the hypothesis - - // Selection criteria - Configurable d_bz_input{"d_bz", -999, "bz field, -999 is automatic"}; - Configurable mintpcNCls{"mintpcNCls", 70, "min tpc Nclusters"}; - Configurable minCosPA3body{"minCosPA3body", 0.9, "minCosPA3body"}; - Configurable dcavtxdau{"dcavtxdau", 1.0, "DCA Vtx Daughters"}; - Configurable enablePidCut{"enablePidCut", 0, "enable function checkPIDH3L"}; - Configurable TofPidNsigmaMin{"TofPidNsigmaMin", -5, "TofPidNsigmaMin"}; - Configurable TofPidNsigmaMax{"TofPidNsigmaMax", 5, "TofPidNsigmaMax"}; - Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; - Configurable minBachPUseTOF{"minBachPUseTOF", 1, "minBachP Enable TOF PID"}; +using ColswithEvTimes = o2::soa::Join; +using ColswithEvTimesLabeled = o2::soa::Join; + +struct decay3bodyBuilder { + // helper object + o2::pwglf::decay3bodyBuilderHelper helper; + + // table index : match order above + enum tableIndex { kDecay3BodyIndices = 0, + kVtx3BodyDatas, + kVtx3BodyCovs, + kMcVtx3BodyDatas, + nTables }; + + struct : ProducesGroup { + Produces decay3bodyindices; + Produces vtx3bodydatas; + Produces vtx3bodycovs; + Produces mcvtx3bodydatas; + } products; + + // enablde tables + Configurable> enabledTables{"enabledTables", + {defaultParameters[0], nTables, nParameters, tableNames, parameterNames}, + "Produce this table: 0 - false, 1 - true"}; + std::vector mEnabledTables; // Vector of enabled tables + + // general options Configurable useMatCorrType{"useMatCorrType", 0, "0: none, 1: TGeo, 2: LUT"}; + Configurable doTrackQA{"doTrackQA", false, "Flag to fill QA histograms for daughter tracks of (selected) decay3body candidates."}; + Configurable doVertexQA{"doVertexQA", false, "Flag to fill QA histograms for PV of (selected) events."}; + Configurable doSel8selection{"doSel8selection", true, "flag for sel8 event selection"}; + Configurable doPosZselection{"doPosZselection", true, "flag for posZ event selection"}; + + // data processing options + Configurable doSkimmedProcessing{"doSkimmedProcessing", false, "Apply Zoroo counting in case of skimmed data input"}; + Configurable triggerList{"triggerList", "fTriggerEventF1Proton, fTrackedOmega, fTrackedXi, fOmegaLargeRadius, fDoubleOmega, fOmegaHighMult, fSingleXiYN, fQuadrupleXi, fDoubleXi, fhadronOmega, fOmegaXi, fTripleXi, fOmega, fGammaVeryLowPtEMCAL, fGammaVeryLowPtDCAL, fGammaHighPtEMCAL, fGammaLowPtEMCAL, fGammaVeryHighPtDCAL, fGammaVeryHighPtEMCAL, fGammaLowPtDCAL, fJetNeutralLowPt, fJetNeutralHighPt, fGammaHighPtDCAL, fJetFullLowPt, fJetFullHighPt, fEMCALReadout, fPCMandEE, fPHOSnbar, fPCMHighPtPhoton, fPHOSPhoton, fLD, fPPPHI, fPD, fLLL, fPLL, fPPL, fPPP, fLeadingPtTrack, fHighFt0cFv0Flat, fHighFt0cFv0Mult, fHighFt0Flat, fHighFt0Mult, fHighMultFv0, fHighTrackMult, fHfSingleNonPromptCharm3P, fHfSingleNonPromptCharm2P, fHfSingleCharm3P, fHfPhotonCharm3P, fHfHighPt2P, fHfSigmaC0K0, fHfDoubleCharm2P, fHfBeauty3P, fHfFemto3P, fHfFemto2P, fHfHighPt3P, fHfSigmaCPPK, fHfDoubleCharm3P, fHfDoubleCharmMix, fHfPhotonCharm2P, fHfV0Charm2P, fHfBeauty4P, fHfV0Charm3P, fHfSingleCharm2P, fHfCharmBarToXiBach, fSingleMuHigh, fSingleMuLow, fLMeeHMR, fDiMuon, fDiElectron, fLMeeIMR, fSingleE, fTrackHighPt, fTrackLowPt, fJetChHighPt, fJetChLowPt, fUDdiffLarge, fUDdiffSmall, fITSextremeIonisation, fITSmildIonisation, fH3L3Body, fHe, fH2", "List of triggers used to select events"}; + Configurable onlyKeepInterestedTrigger{"onlyKeepInterestedTrigger", false, "Flag to keep only interested trigger"}; + Configurable doLikeSign{"doLikeSign", false, "Flag to produce like-sign background. If true, require the sign of pion is as same as deuteron but not proton."}; + // CCDB options - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - // CCDB TOF PID paras - Configurable timestamp{"ccdb-timestamp", -1, "timestamp of the object"}; - Configurable paramFileName{"paramFileName", "", "Path to the parametrization object. If empty the parametrization is not taken from file"}; - Configurable parametrizationPath{"parametrizationPath", "TOF/Calib/Params", "Path of the TOF parametrization on the CCDB or in the file, if the paramFileName is not empty"}; - Configurable passName{"passName", "", "Name of the pass inside of the CCDB parameter collection. If empty, the automatically deceted from metadata (to be implemented!!!)"}; - Configurable timeShiftCCDBPath{"timeShiftCCDBPath", "", "Path of the TOF time shift vs eta. If empty none is taken"}; - Configurable loadResponseFromCCDB{"loadResponseFromCCDB", false, "Flag to load the response from the CCDB"}; - Configurable fatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"}; - // for KFParticle reconstruction struct : ConfigurableGroup { - Configurable fillCandidateLiteTable{"kfparticleConfigurations.fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"}; - Configurable doSel8selection{"kfparticleConfigurations.doSel8selection", true, "flag for sel8 event selection"}; - Configurable doPosZselection{"kfparticleConfigurations.doPosZselection", true, "flag for posZ event selection"}; - Configurable doDCAFitterPreMinimum{"kfparticleConfigurations.doDCAFitterPreMinimum", false, "do DCAFitter pre-optimization before KF fit to include material corrections for decay3body vertex"}; - Configurable doTrackQA{"kfparticleConfigurations.doTrackQA", false, "Flag to fill QA histograms for daughter tracks."}; - Configurable doVertexQA{"kfparticleConfigurations.doVertexQA", false, "Flag to fill QA histograms for KFParticle PV."}; - Configurable useLambdaMassConstraint{"kfparticleConfigurations.useLambdaMassConstraint", false, "Apply Lambda mass constraint on proton-pion vertex"}; - Configurable maxEta{"kfparticleConfigurations.maxEta", 0.9, "Maximum eta for daughter tracks"}; - Configurable useTPCforPion{"kfparticleConfigurations.useTPCforPion", true, "Flag to ask for TPC info for pion track (PID, nClusters), false: pion track can be ITS only"}; - Configurable mintpcNClsProton{"kfparticleConfigurations.mintpcNClsProton", 70, "Minimum number of TPC clusters for proton track"}; - Configurable mintpcNClsPion{"kfparticleConfigurations.mintpcNClsPion", 70, "Minimum number of TPC clusters for pion track"}; - Configurable mintpcNClsBach{"kfparticleConfigurations.mintpcNClsBach", 70, "Minimum number of TPC clusters for bachelor track"}; - Configurable mintpcCrossedRows{"kfparticleConfigurations.mintpcCrossedRows", 70, "Minimum number of TPC crossed rows for proton and deuteron track"}; - Configurable mintpcCrossedRowsPion{"kfparticleConfigurations.mintpcCrossedRowsPion", 70, "Minimum number of TPC crossed rows for pion track"}; - Configurable minPtProton{"kfparticleConfigurations.minPtProton", 0.1, "Minimum pT of proton track"}; - Configurable maxPtProton{"kfparticleConfigurations.maxPtProton", 10, "Maximum pT of proton track"}; - Configurable minPtPion{"kfparticleConfigurations.minPtPion", 0.1, "Minimum pT of pion track"}; - Configurable maxPtPion{"kfparticleConfigurations.maxPtPion", 10, "Maximum pT of pion track"}; - Configurable minPtDeuteron{"kfparticleConfigurations.minPtDeuteron", 0.1, "Minimum pT of deuteron track"}; - Configurable maxPtDeuteron{"kfparticleConfigurations.maxPtDeuteron", 10, "Maximum pT of deuteron track"}; - Configurable mindcaXYPionPV{"kfparticleConfigurations.mindcaXYPionPV", 0.1, "Minimum DCA XY of the pion daughter track to the PV"}; - Configurable mindcaXYProtonPV{"kfparticleConfigurations.mindcaXYProtonPV", 0.1, "Minimum DCA XY of the proton daughter track to the PV"}; - Configurable mindcaZPionPV{"kfparticleConfigurations.mindcaZPionPV", 0.1, "Minimum DCA Z of the pion daughter track to the PV"}; - Configurable mindcaZProtonPV{"kfparticleConfigurations.mindcaZProtonPV", 0.1, "Minimum DCA Z of the proton daughter track to the PV"}; - Configurable maxtpcnSigma{"kfparticleConfigurations.maxtpcnSigma", 5., "Maximum nSigma TPC for daughter tracks"}; - Configurable maxDcaProDeu{"kfparticleConfigurations.maxDcaProDeu", 1000., "Maximum geometrical distance between proton and deuteron at the SV in 3D with KFParticle"}; - Configurable maxDcaProPi{"kfparticleConfigurations.maxDcaProPi", 1000., "Maximum geometrical distance between proton and pion at the SV in 3D with KFParticle"}; - Configurable maxDcaPiDe{"kfparticleConfigurations.maxDcaPiDe", 1000., "Maximum geometrical distance between pion and deuteron at the SV in 3D with KFParticle"}; - Configurable maxDcaXYSVDau{"kfparticleConfigurations.maxDcaXYSVDau", 1.0, "Maximum geometrical distance of daughter tracks from the SV in XY with KFParticle"}; - Configurable maxRapidityHt{"kfparticleConfigurations.maxRapidityHt", 1., "Maximum rapidity for Hypertriton candidates with KFParticle"}; - Configurable minPtHt{"kfparticleConfigurations.minPtHt", 0.01, "Minimum momentum for Hypertriton candidates with KFParticle (0.01 applied in SVertexer)"}; - Configurable maxPtHt{"kfparticleConfigurations.maxPtHt", 36., "Maximum momentum for Hypertriton candidates with KFParticle"}; - Configurable minMassHt{"kfparticleConfigurations.minMassHt", 2.96, "Minimum candidate mass with KFParticle"}; - Configurable maxMassHt{"kfparticleConfigurations.maxMassHt", 3.05, "Maximum candidate mass with KFParticle"}; - Configurable maxctauHt{"kfparticleConfigurations.maxctauHt", 40., "Maximum candidate ctau with KFParticle before topological constraint"}; - Configurable maxChi2geo{"kfparticleConfigurations.maxChi2geo", 1000., "Maximum chi2 geometrical with KFParticle"}; - Configurable minCosPA{"kfparticleConfigurations.minCosPA", 0.8, "Minimum cosine pointing angle with KFParticle (0.8 applied in SVertexer)"}; - Configurable minCosPAxy{"kfparticleConfigurations.minCosPAxy", 0.8, "Minimum cosine pointing angle in xy with KFParticle"}; - Configurable applyTopoSel{"kfparticleConfigurations.applyTopoSel", false, "Apply selection constraining the mother to the PV with KFParticle"}; - Configurable maxChi2topo{"kfparticleConfigurations.maxChi2topo", 1000., "Maximum chi2 topological with KFParticle"}; - Configurable nEvtMixing{"kfparticleConfigurations.nEvtMixing", 5, "Number of events to mix"}; - Configurable applySVertexerCuts{"kfparticleConfigurations.applySVertexerCuts", true, "Apply SVertexer selections in event mixing case"}; - ConfigurableAxis binsVtxZ{"kfparticleConfigurations.binsVtxZ", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; - ConfigurableAxis binsMultiplicity{"kfparticleConfigurations.binsMultiplicity", {VARIABLE_WIDTH, 0.0f, 1.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - multiplicity"}; - } kfparticleConfigurations; - - //------------------------------------------------------------------ - // Sets for event mixing + std::string prefix = "ccdb"; + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + } ccdbConfigurations; + + // Decay3body building options struct : ConfigurableGroup { - Configurable nUseMixedEvent{"nUseMixedEvent", 5, "nUseMixedEvent"}; - Configurable em_event_sel8_selection{"em_event_sel8_selection", true, "event selection count post sel8 cut"}; - Configurable etacut{"etacut", 0.9, "etacut"}; - Configurable minProtonPt{"minProtonPt", 0.3, "minProtonPt"}; - Configurable maxProtonPt{"maxProtonPt", 5, "maxProtonPt"}; - Configurable minPionPt{"minPionPt", 0.1, "minPionPt"}; - Configurable maxPionPt{"maxPionPt", 1.2, "maxPionPt"}; - Configurable minDeuteronPt{"minDeuteronPt", 0.6, "minDeuteronPt"}; - Configurable maxDeuteronPt{"maxDeuteronPt", 10, "maxDeuteronPt"}; - Configurable mintpcNClsproton{"mintpcNClsproton", 90, "min tpc Nclusters for proton"}; - Configurable mintpcNClspion{"mintpcNClspion", 70, "min tpc Nclusters for pion"}; - Configurable mintpcNClsbachelor{"mintpcNClsbachelor", 100, "min tpc Nclusters for bachelor"}; - Configurable emTpcPidNsigmaCut{"emTpcPidNsigmaCut", 5, "emTpcPidNsigmaCut"}; - } EMTrackSel; - - Preslice tracksperCol = aod::track::collisionId; - SliceCache cache; - ConfigurableAxis axisPosZ{"axisPosZ", {40, -10, 10}, "Mixing bins - posZ"}; - ConfigurableAxis axisCentrality{"axisCentrality", {10, 0, 100}, "Mixing bins - centrality"}; - using BinningType = ColumnBinningPolicy; - - // KF event mixing - using BinningTypeKF = ColumnBinningPolicy; - BinningTypeKF binningOnPosAndMult{{kfparticleConfigurations.binsVtxZ, kfparticleConfigurations.binsMultiplicity}, true}; - - // Filters and slices - // Filter collisionFilter = (aod::evsel::sel8 == true && nabs(aod::collision::posZ) < 10.f); - Preslice perCollision = o2::aod::decay3body::collisionId; + std::string prefix = "decay3bodyBuilderOpts"; + // building options + Configurable useKFParticle{"useKFParticle", false, "Use KFParticle for decay3body building"}; + Configurable kfSetTopologicalConstraint{"kfSetTopologicalConstraint", false, "Set topological vertex constraint in case of KFParticle reconstruction"}; + Configurable buildOnlyTracked{"buildOnlyTracked", false, "Build only tracked decay3bodys"}; + Configurable useSelections{"useSelections", true, "Apply selections during decay3body building"}; + Configurable useChi2Selection{"useChi2Selection", true, "Apply chi2 selection during decay3body building"}; + Configurable useTPCforPion{"useTPCforPion", false, "Flag to ask for TPC info for pion track (PID, nClusters), false: pion track can be ITS only"}; + Configurable acceptTPCOnly{"acceptTPCOnly", false, "Accept TPC only tracks as daughters"}; + Configurable askOnlyITSMatch{"askOnlyITSMatch", true, "ask only ITS match to distinguish TPC only tracks"}; + Configurable calculateCovariance{"calculateCovariance", true, "Calculate candidate and daughter covariance matrices"}; + // daughter track selections + Configurable maxEtaDaughters{"maxEtaDaughters", 0.9, "Max eta of daughters"}; + Configurable minTPCNClProton{"minTPCNClProton", 90, "Min TPC NClusters of proton daughter"}; + Configurable minTPCNClPion{"minTPCNClPion", 70, "Min TPC NClusters of pion daughter"}; + Configurable minTPCNClDeuteron{"minTPCNClDeuteron", 100, "Min TPC NClusters of deuteron daughter"}; + Configurable minDCAProtonToPV{"minDCAProtonToPV", 0.1, "Min DCA of proton to PV"}; + Configurable minDCAPionToPV{"minDCAPionToPV", 0.1, "Min DCA of pion to PV"}; + Configurable minDCADeuteronToPV{"minDCADeuteronToPV", 0.1, "Min DCA of deuteron to PV"}; + Configurable minPtProton{"minPtProton", 0.3, "Min Pt of proton daughter"}; + Configurable minPtPion{"minPtPion", 0.1, "Min Pt of pion daughter"}; + Configurable minPtDeuteron{"minPtDeuteron", 0.6, "Min Pt of deuteron daughter"}; + Configurable maxPtProton{"maxPtProton", 5.0, "Max Pt of proton daughter"}; + Configurable maxPtPion{"maxPtPion", 1.2, "Max Pt of pion daughter"}; + Configurable maxPtDeuteron{"maxPtDeuteron", 10.0, "Max Pt of deuteron daughter"}; + Configurable maxTPCnSigma{"maxTPCnSigma", 5.0, "Min/max TPC nSigma of daughter tracks"}; + Configurable minTOFnSigmaDeuteron{"minTOFnSigmaDeuteron", -5.0, "Min TOF nSigma of deuteron daughter"}; + Configurable maxTOFnSigmaDeuteron{"maxTOFnSigmaDeuteron", 5.0, "Max TOF nSigma of deuteron daughter"}; + Configurable minPDeuteronUseTOF{"minPDeuteronUseTOF", 1.0, "Min P of deuteron to use TOF PID"}; + Configurable maxDCADauToSVaverage{"maxDCADauToSVaverage", 0.5, "Max DCA of daughters to SV (quadratic sum of daughter DCAs to SV / 3)"}; + // candidate selections + Configurable maxRapidity{"maxRapidity", 1.0, "Max rapidity of decay3body vertex"}; + Configurable minPt{"minPt", 2.0, "Min Pt of decay3body candidate"}; + Configurable maxPt{"maxPt", 5.0, "Max Pt of decay3body candidate"}; + Configurable minMass{"minMass", 2.96, "Min mass of decay3body candidate"}; + Configurable maxMass{"maxMass", 3.04, "Max mass of decay3body candidate"}; + Configurable minCtau{"minCtau", 0.0, "Min ctau of decay3body candidate"}; + Configurable maxCtau{"maxCtau", 100.0, "Max ctau of decay3body candidate"}; + Configurable minCosPA{"minCosPA", 0.9, "Min cosPA of decay3body candidate"}; + Configurable maxChi2{"maxChi2", 100.0, "Max chi2 of decay3body candidate"}; + } decay3bodyBuilderOpts; + struct : ConfigurableGroup { + std::string prefix = "mixingOpts"; + Configurable n3bodyMixing{"n3bodyMixing", 0, "Number of decay3bodys to mix: 0 - value set to maximum bin entry in hDecay3BodyRadiusPhi, > 0 - manual setting"}; + Configurable mixingType{"mixingType", 0, "0: mix V0 from one event with bachelor from another, 1: mix pion and bachelor from one event with proton from another, 1: mix proton and bachelor from one event with pion from another "}; + ConfigurableAxis bins3BodyRadius{"mixingOpts.bins3BodyRadius", {VARIABLE_WIDTH, 0.0f, 2.0f, 4.0f, 7.0f, 10.0f, 14.0f, 18.0f, 22.0f, 30.0f, 40.0f}, "Mixing bins - 3body radius"}; + ConfigurableAxis bins3BodyPhi{"mixingOpts.bins3BodyPhi", {VARIABLE_WIDTH, -180 * o2::constants::math::Deg2Rad, -120 * o2::constants::math::Deg2Rad, -60 * o2::constants::math::Deg2Rad, 0, 60 * o2::constants::math::Deg2Rad, 120 * o2::constants::math::Deg2Rad, 180 * o2::constants::math::Deg2Rad}, "Mixing bins - 3body phi (rad)"}; + ConfigurableAxis bins3BodyPhiDegree{"mixingOpts.bins3BodyPhiDegree", {VARIABLE_WIDTH, -180, -120, -60, 0, 60, 120, 180}, "Mixing bins - 3body phi (degree)"}; + ConfigurableAxis bins3BodyPosZ{"mixingOpts.bins3BodyPosZ", {VARIABLE_WIDTH, -500.0f, -200.0f, -100.0f, -70.0f, -60.0f, -50.0f, -40.0f, -35.0f, -30.0f, -25.0f, -20.0f, -15.0f, -13.0f, -10.0f, -8.0f, -6.0f, -4.0f, -2.0f, 0.0f, 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 13.0f, 15.0f, 20.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f, 60.0f, 70.0f, 100.0f, 200.0f, 500.0f}, "3body SV z position"}; + Configurable selectPVPosZ3bodyMixing{"selectPVPosZ3bodyMixing", true, "Select same pvPosZ events in case of 3body mixing"}; + Configurable maxDeltaPVPosZ3bodyMixing{"maxDeltaPVPosZ3bodyMixing", 1., "max difference between PV z position in case of 3body mixing"}; + // SVertexer selections + Configurable minPt2V0{"minPt2V0", 0.5, "Min Pt squared of V0"}; + Configurable maxTgl2V0{"maxTgl2V0", 4, "Max tgl squared of V0"}; + Configurable maxDCAXY2ToMeanVertex3bodyV0{"maxDCAXY2ToMeanVertex3bodyV0", 4, "Max DCA XY squared of V0 to mean vertex"}; + Configurable minCosPAXYMeanVertex3bodyV0{"minCosPAXYMeanVertex3bodyV0", 0.9, "Min cosPA XY of V0 to mean vertex"}; + Configurable minCosPA3bodyV0{"minCosPA3bodyV0", 0.8, "Min cosPA of V0"}; + Configurable maxRDiffV03body{"maxRDiffV03body", 3, "Max RDiff of V0 to 3body"}; + Configurable minPt3Body{"minPt3Body", 0.5, "Min Pt of 3body"}; + Configurable maxTgl3Body{"maxTgl3Body", 0.01, "Max tgl of 3body"}; + Configurable maxDCAXY3Body{"maxDCAXY3Body", 0.5, "Max DCA XY of 3body"}; + Configurable maxDCAZ3Body{"maxDCAZ3Body", 1.0, "Max DCA Z of 3body"}; + } mixingOpts; + + // Helper struct to contain MC information prior to filling + struct mc3Bodyinfo { + int label; + std::array genDecVtx{0.f}; + std::array genMomentum{0.f}; + float genCt; + float genPhi; + float genEta; + float genRapidity; + float genMomProton; + float genMomPion; + float genMomDeuteron; + float genPtProton; + float genPtPion; + float genPtDeuteron; + bool isTrueH3L; + bool isTrueAntiH3L; + bool isReco; + int motherPdgCode; + int daughterPrPdgCode; + int daughterPiPdgCode; + int daughterDePdgCode; + bool isDeuteronPrimary; + bool survivedEventSel; + }; + mc3Bodyinfo this3BodyMCInfo; + + // CCDB and magnetic field int mRunNumber; float d_bz; - float maxSnp; // max sine phi for propagation - float maxStep; // max step size (cm) for propagation + Service ccdb; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + std::unordered_map ccdbCache; // Maps runNumber -> d_bz o2::base::MatLayerCylSet* lut = nullptr; - o2::vertexing::DCAFitterN<3> fitter3body; - o2::pid::tof::TOFResoParamsV2 mRespParamsV2; - void init(InitContext&) + // histogram registry + HistogramRegistry registry{"Registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // bachelor TOF PID + o2::aod::pidtofgeneric::TofPidNewCollision bachelorTOFPID; // to be updated in Init based on the hypothesis + o2::aod::pidtofgeneric::TofPidNewCollision bachelorTOFPIDLabeled; // to be updated in Init based on the hypothesis + // TOF response and input parameters + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + o2::aod::pidtofgeneric::TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration + + // 3body mixing + using Binning3BodyKF = ColumnBinningPolicy; + using Binning3BodyDCAfitter = ColumnBinningPolicy; + + // skimmed processing + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + + // tracked cluster size + std::vector fTrackedClSizeVector; + + // trigger info + std::vector isTriggeredCollision; + // MC info + std::vector isGoodCollision; + + void init(InitContext& initContext) { + zorroSummary.setObject(zorro.getZorroSummary()); + mRunNumber = 0; d_bz = 0; - maxSnp = 0.85f; // could be changed later - maxStep = 2.00f; // could be changed later - - // set hypothesis corresponds to hyp3body, tpcpid to be implemented - switch (motherhyp) { - case hyp3body::kH3L: - bachelorcharge = 1; - bachelorTOFPID.SetPidType(o2::track::PID::Deuteron); - break; - case hyp3body::kH4L: - bachelorcharge = 1; - bachelorTOFPID.SetPidType(o2::track::PID::Triton); - break; - case hyp3body::kHe4L: - bachelorcharge = 2; - bachelorTOFPID.SetPidType(o2::track::PID::Helium3); - break; - case hyp3body::kHe5L: - bachelorcharge = 2; - bachelorTOFPID.SetPidType(o2::track::PID::Alpha); - break; - default: - LOG(fatal) << "Wrong hypothesis for decay3body"; - return; - } - fitter3body.setPropagateToPCA(true); - fitter3body.setMaxR(200.); //->maxRIni3body - fitter3body.setMinParamChange(1e-3); - fitter3body.setMinRelChi2Change(0.9); - fitter3body.setMaxDZIni(1e9); - fitter3body.setMaxChi2(1e9); - fitter3body.setUseAbsDCA(d_UseAbsDCA); + mEnabledTables.resize(nTables, 0); - // Material correction in the DCA fitter - ccdb->setURL(ccdburl); + // CCDB options + ccdb->setURL(ccdbConfigurations.ccdburl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); + // TOF PID parameters initialization + mTOFCalibConfig.metadataInfo = metadataInfo; + mTOFCalibConfig.inheritFromBaseTask(initContext); + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); + + // Set material correction if (useMatCorrType == 1) { LOGF(info, "TGeo correction requested, loading geometry"); if (!o2::base::GeometryManager::isGeometryLoaded()) { - ccdb->get(geoPath); + ccdb->get(ccdbConfigurations.geoPath); } + matCorr = o2::base::Propagator::MatCorrType::USEMatCorrTGeo; } if (useMatCorrType == 2) { LOGF(info, "LUT correction requested, loading LUT"); - lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbConfigurations.lutPath)); + matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; } - // Material correction in the DCA fitter - if (useMatCorrType == 1) - matCorr = o2::base::Propagator::MatCorrType::USEMatCorrTGeo; - if (useMatCorrType == 2) - matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + helper.fitterV0.setMatCorrType(matCorr); + helper.fitter3body.setMatCorrType(matCorr); + + // set bachelor PID + bachelorTOFPID.SetPidType(o2::track::PID::Deuteron); + bachelorTOFPIDLabeled.SetPidType(o2::track::PID::Deuteron); + + // set decay3body parameters in the helper + helper.decay3bodyselections.maxEtaDaughters = decay3bodyBuilderOpts.maxEtaDaughters; + helper.decay3bodyselections.minTPCNClProton = decay3bodyBuilderOpts.minTPCNClProton; + helper.decay3bodyselections.minTPCNClPion = decay3bodyBuilderOpts.minTPCNClPion; + helper.decay3bodyselections.minTPCNClDeuteron = decay3bodyBuilderOpts.minTPCNClDeuteron; + helper.decay3bodyselections.minDCAProtonToPV = decay3bodyBuilderOpts.minDCAProtonToPV; + helper.decay3bodyselections.minDCAPionToPV = decay3bodyBuilderOpts.minDCAPionToPV; + helper.decay3bodyselections.minDCADeuteronToPV = decay3bodyBuilderOpts.minDCADeuteronToPV; + helper.decay3bodyselections.minPtProton = decay3bodyBuilderOpts.minPtProton; + helper.decay3bodyselections.minPtPion = decay3bodyBuilderOpts.minPtPion; + helper.decay3bodyselections.minPtDeuteron = decay3bodyBuilderOpts.minPtDeuteron; + helper.decay3bodyselections.maxPtProton = decay3bodyBuilderOpts.maxPtProton; + helper.decay3bodyselections.maxPtPion = decay3bodyBuilderOpts.maxPtPion; + helper.decay3bodyselections.maxPtDeuteron = decay3bodyBuilderOpts.maxPtDeuteron; + helper.decay3bodyselections.maxTPCnSigma = decay3bodyBuilderOpts.maxTPCnSigma; + helper.decay3bodyselections.minTOFnSigmaDeuteron = decay3bodyBuilderOpts.minTOFnSigmaDeuteron; + helper.decay3bodyselections.maxTOFnSigmaDeuteron = decay3bodyBuilderOpts.maxTOFnSigmaDeuteron; + helper.decay3bodyselections.minPDeuteronUseTOF = decay3bodyBuilderOpts.minPDeuteronUseTOF; + helper.decay3bodyselections.maxDCADauToSVaverage = decay3bodyBuilderOpts.maxDCADauToSVaverage; + helper.decay3bodyselections.maxRapidity = decay3bodyBuilderOpts.maxRapidity; + helper.decay3bodyselections.minPt = decay3bodyBuilderOpts.minPt; + helper.decay3bodyselections.maxPt = decay3bodyBuilderOpts.maxPt; + helper.decay3bodyselections.minMass = decay3bodyBuilderOpts.minMass; + helper.decay3bodyselections.maxMass = decay3bodyBuilderOpts.maxMass; + helper.decay3bodyselections.minCtau = decay3bodyBuilderOpts.minCtau; + helper.decay3bodyselections.maxCtau = decay3bodyBuilderOpts.maxCtau; + helper.decay3bodyselections.minCosPA = decay3bodyBuilderOpts.minCosPA; + helper.decay3bodyselections.maxChi2 = decay3bodyBuilderOpts.maxChi2; + + // set SVertexer selection parameters in the helper + helper.svertexerselections.minPt2V0 = mixingOpts.minPt2V0; + helper.svertexerselections.maxTgl2V0 = mixingOpts.maxTgl2V0; + helper.svertexerselections.maxDCAXY2ToMeanVertex3bodyV0 = mixingOpts.maxDCAXY2ToMeanVertex3bodyV0; + helper.svertexerselections.minCosPAXYMeanVertex3bodyV0 = mixingOpts.minCosPAXYMeanVertex3bodyV0; + helper.svertexerselections.minCosPA3bodyV0 = mixingOpts.minCosPA3bodyV0; + helper.svertexerselections.maxRDiffV03body = mixingOpts.maxRDiffV03body; + helper.svertexerselections.minPt3Body = mixingOpts.minPt3Body; + helper.svertexerselections.maxTgl3Body = mixingOpts.maxTgl3Body; + helper.svertexerselections.maxDCAXY3Body = mixingOpts.maxDCAXY3Body; + helper.svertexerselections.maxDCAZ3Body = mixingOpts.maxDCAZ3Body; + + // list enabled process functions + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + LOGF(info, " Decay3body builder: basic configuration listing"); + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + + if (doprocessRealData) { + LOGF(info, " ===> process function enabled: processRealData"); + } + if (doprocessRealDataReduced) { + LOGF(info, " ===> process function enabled: processRealDataReduced"); + } + if (doprocessRealDataReduced3bodyMixing) { + LOGF(info, " ===> process function enabled: processRealDataReduced3bodyMixing"); + } + if (doprocessMonteCarlo) { + LOGF(info, " ===> process function enabled: processMonteCarlo"); + } + + // list enabled tables + for (int i = 0; i < nTables; i++) { + if (mEnabledTables[i]) { + LOGF(info, " -~> Table enabled: %s", tableNames[i]); + } + } - fitter3body.setMatCorrType(matCorr); + // print base cuts + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + LOGF(info, "-~> max daughter eta ..............: %f", decay3bodyBuilderOpts.maxEtaDaughters.value); + LOGF(info, "-~> min TPC ncls proton ...........: %i", decay3bodyBuilderOpts.minTPCNClProton.value); + LOGF(info, "-~> min TPC ncls pion .............: %i", decay3bodyBuilderOpts.minTPCNClPion.value); + LOGF(info, "-~> min TPC ncls bach .............: %i", decay3bodyBuilderOpts.minTPCNClDeuteron.value); + LOGF(info, "-~> min DCA proton to PV ..........: %f", decay3bodyBuilderOpts.minDCAProtonToPV.value); + LOGF(info, "-~> min DCA pion to PV ............: %f", decay3bodyBuilderOpts.minDCAPionToPV.value); + LOGF(info, "-~> min DCA bach to PV ............: %f", decay3bodyBuilderOpts.minDCADeuteronToPV.value); + LOGF(info, "-~> min pT proton .................: %f", decay3bodyBuilderOpts.minPtProton.value); + LOGF(info, "-~> min pT pion ...................: %f", decay3bodyBuilderOpts.minPtPion.value); + LOGF(info, "-~> min pT bach ...................: %f", decay3bodyBuilderOpts.minPtDeuteron.value); + LOGF(info, "-~> max pT proton .................: %f", decay3bodyBuilderOpts.maxPtProton.value); + LOGF(info, "-~> max pT pion ...................: %f", decay3bodyBuilderOpts.maxPtPion.value); + LOGF(info, "-~> max pT bach ...................: %f", decay3bodyBuilderOpts.maxPtDeuteron.value); + LOGF(info, "-~> max TPC nSigma ...............: %f", decay3bodyBuilderOpts.maxTPCnSigma.value); + LOGF(info, "-~> min TOF nSigma deuteron ......: %f", decay3bodyBuilderOpts.minTOFnSigmaDeuteron.value); + LOGF(info, "-~> max TOF nSigma deuteron ......: %f", decay3bodyBuilderOpts.maxTOFnSigmaDeuteron.value); + LOGF(info, "-~> min p bach use TOF ...........: %f", decay3bodyBuilderOpts.minPDeuteronUseTOF.value); + LOGF(info, "-~> max DCA dau at SV ............: %f", decay3bodyBuilderOpts.maxDCADauToSVaverage.value); + LOGF(info, "-~> max rapidity .................: %f", decay3bodyBuilderOpts.maxRapidity.value); + LOGF(info, "-~> min pT .......................: %f", decay3bodyBuilderOpts.minPt.value); + LOGF(info, "-~> max pT .......................: %f", decay3bodyBuilderOpts.maxPt.value); + LOGF(info, "-~> min mass .....................: %f", decay3bodyBuilderOpts.minMass.value); + LOGF(info, "-~> max mass .....................: %f", decay3bodyBuilderOpts.maxMass.value); + LOGF(info, "-~> min ctau .....................: %f", decay3bodyBuilderOpts.minCtau.value); + LOGF(info, "-~> max ctau .....................: %f", decay3bodyBuilderOpts.maxCtau.value); + LOGF(info, "-~> min cosPA ....................: %f", decay3bodyBuilderOpts.minCosPA.value); + LOGF(info, "-~> max chi2 .....................: %f", decay3bodyBuilderOpts.maxChi2.value); + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + + // bookkeeping histograms + auto h = registry.add("Counters/hTableBuildingStatistics", "hTableBuildingStatistics", kTH1D, {{nTablesConst, -0.5f, static_cast(nTablesConst)}}); + auto h2 = registry.add("Counters/hInputStatistics", "hInputStatistics", kTH1D, {{nTablesConst, -0.5f, static_cast(nTablesConst)}}); + h2->SetTitle("Input table sizes"); + + // configure tables to generate + for (int i = 0; i < nTables; i++) { + h->GetXaxis()->SetBinLabel(i + 1, tableNames[i].c_str()); + h2->GetXaxis()->SetBinLabel(i + 1, tableNames[i].c_str()); + h->SetBinContent(i + 1, 0); // mark all as disabled to start + + int f = enabledTables->get(tableNames[i].c_str(), "enable"); + if (f == 1) { + mEnabledTables[i] = 1; + h->SetBinContent(i + 1, 1); // mark enabled + } + } - // Add histograms separately for different process functions - if (doprocessRun3 == true || doprocessRun3EM == true || doprocessRun3EMLikeSign == true) { - registry.add("hEventCounter", "hEventCounter", HistType::kTH1F, {{1, 0.0f, 1.0f}}); - auto hVtx3BodyCounter = registry.add("hVtx3BodyCounter", "hVtx3BodyCounter", HistType::kTH1F, {{6, 0.0f, 6.0f}}); - hVtx3BodyCounter->GetXaxis()->SetBinLabel(1, "Total"); - hVtx3BodyCounter->GetXaxis()->SetBinLabel(2, "TPCNcls"); - hVtx3BodyCounter->GetXaxis()->SetBinLabel(3, "PIDCut"); - hVtx3BodyCounter->GetXaxis()->SetBinLabel(4, "HasSV"); - hVtx3BodyCounter->GetXaxis()->SetBinLabel(5, "DcaDau"); - hVtx3BodyCounter->GetXaxis()->SetBinLabel(6, "CosPA"); - registry.add("hBachelorTOFNSigmaDe", "", HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}); + if (mEnabledTables[kVtx3BodyDatas] && mEnabledTables[kMcVtx3BodyDatas]) { + LOG(fatal) << "Tables Vtx3BodyDatas and McVtx3BodyDatas cannot both be enabled at the same time. Choose one!"; } - if (doprocessRun3withKFParticle == true || doprocessRun3EMwithKFParticle == true) { - auto hEventCounterKFParticle = registry.add("hEventCounterKFParticle", "hEventCounterKFParticle", HistType::kTH1F, {{4, 0.0f, 4.0f}}); - hEventCounterKFParticle->GetXaxis()->SetBinLabel(1, "total"); - hEventCounterKFParticle->GetXaxis()->SetBinLabel(2, "sel8"); - hEventCounterKFParticle->GetXaxis()->SetBinLabel(3, "vertexZ"); - hEventCounterKFParticle->GetXaxis()->SetBinLabel(4, "has candidate"); - hEventCounterKFParticle->LabelsOption("v"); - auto hVtx3BodyCounterKFParticle = registry.add("hVtx3BodyCounterKFParticle", "hVtx3BodyCounterKFParticle", HistType::kTH1F, {{21, 0.0f, 21.0f}}); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(1, "Total"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(2, "Charge"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(3, "Eta"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(4, "TPCNcls"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(5, "TPCRows"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(6, "TPCpid"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(7, "DCAxyPV"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(8, "DCAzPV"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(9, "V0MassConst"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(10, "HasSV"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(11, "DcaDau"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(12, "DCADauVtx"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(13, "DauPt"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(14, "Rapidity"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(15, "Pt"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(16, "Mass"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(17, "CosPA"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(18, "CosPAXY"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(19, "Chi2geo"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(20, "TopoConstr"); - hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(21, "Chi2topo"); - hVtx3BodyCounterKFParticle->LabelsOption("v"); - - registry.add("QA/Tracks/hTrackPosTPCNcls", "hTrackPosTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); - registry.add("QA/Tracks/hTrackNegTPCNcls", "hTrackNegTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); - registry.add("QA/Tracks/hTrackBachTPCNcls", "hTrackBachTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); - registry.add("QA/Tracks/hTrackPosHasTPC", "hTrackPosHasTPC", HistType::kTH1F, {{2, -0.5, 1.5, "has TPC"}}); - registry.add("QA/Tracks/hTrackNegHasTPC", "hTrackNegHasTPC", HistType::kTH1F, {{2, -0.5, 1.5, "has TPC"}}); - registry.add("QA/Tracks/hTrackBachHasTPC", "hTrackBachHasTPC", HistType::kTH1F, {{2, -0.5, 1.5, "has TPC"}}); - registry.add("QA/Tracks/hTrackBachITSClusSizes", "hTrackBachITSClusSizes", HistType::kTH1F, {{10, 0., 10., "ITS cluster sizes"}}); - registry.add("QA/Tracks/hTrackProtonTPCPID", "hTrackProtonTPCPID", HistType::kTH2F, {{100, -10.0f, 10.0f, "p/z (GeV/c)"}, {100, -10.0f, 10.0f, "TPC n#sigma"}}); - registry.add("QA/Tracks/hTrackPionTPCPID", "hTrackPionTPCPID", HistType::kTH2F, {{100, -10.0f, 10.0f, "p/z (GeV/c)"}, {100, -10.0f, 10.0f, "TPC n#sigma"}}); - registry.add("QA/Tracks/hTrackBachTPCPID", "hTrackBachTPCPID", HistType::kTH2F, {{100, -10.0f, 10.0f, "p/z (GeV/c)"}, {100, -10.0f, 10.0f, "TPC n#sigma"}}); - registry.add("QA/Tracks/hTrackProtonPt", "hTrackProtonPt", HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}); - registry.add("QA/Tracks/hTrackPionPt", "hTrackPionPt", HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}); - registry.add("QA/Tracks/hTrackBachPt", "hTrackBachPt", HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}); - registry.add("QA/Event/hVtxXKF", "hVtxXKF", HistType::kTH1F, {{500, -0.1f, 0.1f, "PV X (cm)"}}); - registry.add("QA/Event/hVtxYKF", "hVtxYKF", HistType::kTH1F, {{500, -0.1f, 0.1f, "PV Y (cm)"}}); - registry.add("QA/Event/hVtxZKF", "hVtxZKF", HistType::kTH1F, {{500, -15.0f, 15.0f, "PV Z (cm)"}}); - registry.add("QA/Event/hVtxCovXXKF", "hVtxCovXXKF", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(XX) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovYYKF", "hVtxCovYYKF", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(YY) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovZZKF", "hVtxCovZZKF", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(ZZ) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovXYKF", "hVtxCovXYKF", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(XY) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovXZKF", "hVtxCovXZKF", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(XZ) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovYZKF", "hVtxCovYZKF", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(YZ) (cm^{2})"}}); - registry.add("QA/Event/hVtxX", "hVtxX", HistType::kTH1F, {{500, -0.1f, 0.1f, "PV X (cm)"}}); - registry.add("QA/Event/hVtxY", "hVtxY", HistType::kTH1F, {{500, -0.1f, 0.1f, "PV Y (cm)"}}); - registry.add("QA/Event/hVtxZ", "hVtxZ", HistType::kTH1F, {{500, -15.0f, 15.0f, "PV Z (cm)"}}); - registry.add("QA/Event/hVtxCovXX", "hVtxCovXX", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(XX) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovYY", "hVtxCovYY", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(YY) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovZZ", "hVtxCovZZ", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(ZZ) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovXY", "hVtxCovXY", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(XY) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovXZ", "hVtxCovXZ", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(XZ) (cm^{2})"}}); - registry.add("QA/Event/hVtxCovYZ", "hVtxCovYZ", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(YZ) (cm^{2})"}}); + // Add histograms separately for different process functions + if (doprocessRealData == true || doprocessMonteCarlo == true) { + auto hEventCounter = registry.add("Counters/hEventCounter", "hEventCounter", HistType::kTH1D, {{3, 0.0f, 3.0f}}); + hEventCounter->GetXaxis()->SetBinLabel(1, "total"); + hEventCounter->GetXaxis()->SetBinLabel(2, "sel8"); + hEventCounter->GetXaxis()->SetBinLabel(3, "vertexZ"); + hEventCounter->LabelsOption("v"); + } + + if (doprocessRealData == true || doprocessRealDataReduced == true || doprocessMonteCarlo == true) { + if (doTrackQA) { // histograms for all daughter tracks of (selected) 3body candidates + registry.add("QA/Tracks/hTrackProtonTPCNcls", "hTrackProtonTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); + registry.add("QA/Tracks/hTrackPionTPCNcls", "hTrackPionTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); + registry.add("QA/Tracks/hTrackDeuteronTPCNcls", "hTrackDeuteronTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); + registry.add("QA/Tracks/hTrackProtonHasTPC", "hTrackProtonHasTPC", HistType::kTH1F, {{2, -0.5, 1.5, "has TPC"}}); + registry.add("QA/Tracks/hTrackPionHasTPC", "hTrackPionHasTPC", HistType::kTH1F, {{2, -0.5, 1.5, "has TPC"}}); + registry.add("QA/Tracks/hTrackDeuteronHasTPC", "hTrackDeuteronHasTPC", HistType::kTH1F, {{2, -0.5, 1.5, "has TPC"}}); + registry.add("QA/Tracks/hTrackDeuteronITSClusSizes", "hTrackDeuteronITSClusSizes", HistType::kTH1F, {{10, 0., 10., "ITS cluster sizes"}}); + registry.add("QA/Tracks/hTrackProtonTPCPID", "hTrackProtonTPCPID", HistType::kTH2F, {{100, -10.0f, 10.0f, "p/z (GeV/c)"}, {100, -10.0f, 10.0f, "TPC n#sigma"}}); + registry.add("QA/Tracks/hTrackPionTPCPID", "hTrackPionTPCPID", HistType::kTH2F, {{100, -10.0f, 10.0f, "p/z (GeV/c)"}, {100, -10.0f, 10.0f, "TPC n#sigma"}}); + registry.add("QA/Tracks/hTrackDeuteronTPCPID", "hTrackDeuteronTPCPID", HistType::kTH2F, {{100, -10.0f, 10.0f, "p/z (GeV/c)"}, {100, -10.0f, 10.0f, "TPC n#sigma"}}); + registry.add("QA/Tracks/hTrackProtonPt", "hTrackProtonPt", HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}); + registry.add("QA/Tracks/hTrackPionPt", "hTrackPionPt", HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}); + registry.add("QA/Tracks/hTrackDeuteronPt", "hTrackDeuteronPt", HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}); + } + if (doVertexQA) { + registry.add("QA/Event/hAllSelEventsVtxZ", "hAllSelEventsVtxZ", HistType::kTH1F, {{500, -15.0f, 15.0f, "PV Z (cm)"}}); + registry.add("QA/Event/hVtxX", "hVtxX", HistType::kTH1F, {{500, -0.1f, 0.1f, "PV X (cm)"}}); + registry.add("QA/Event/hVtxY", "hVtxY", HistType::kTH1F, {{500, -0.1f, 0.1f, "PV Y (cm)"}}); + registry.add("QA/Event/hVtxZ", "hVtxZ", HistType::kTH1F, {{500, -15.0f, 15.0f, "PV Z (cm)"}}); + registry.add("QA/Event/hVtxCovXX", "hVtxCovXX", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(XX) (cm^{2})"}}); + registry.add("QA/Event/hVtxCovYY", "hVtxCovYY", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(YY) (cm^{2})"}}); + registry.add("QA/Event/hVtxCovZZ", "hVtxCovZZ", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(ZZ) (cm^{2})"}}); + registry.add("QA/Event/hVtxCovXY", "hVtxCovXY", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(XY) (cm^{2})"}}); + registry.add("QA/Event/hVtxCovXZ", "hVtxCovXZ", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(XZ) (cm^{2})"}}); + registry.add("QA/Event/hVtxCovYZ", "hVtxCovYZ", HistType::kTH1F, {{200, -0.0001f, 0.0001f, "PV cov(YZ) (cm^{2})"}}); + } } - if (doprocessRun3EMwithKFParticle == true) { - auto hPairCounterMixing = registry.add("QA/EM/hPairCounterMixing", "hPairCounterMixing", HistType::kTH1F, {{3, 0.0f, 3.0f}}); - hPairCounterMixing->GetXaxis()->SetBinLabel(1, "total"); - hPairCounterMixing->GetXaxis()->SetBinLabel(2, "sel8"); - hPairCounterMixing->GetXaxis()->SetBinLabel(3, "vertexZ"); - hPairCounterMixing->LabelsOption("v"); - auto hCombinationCounterMixing = registry.add("QA/EM/hCombinationCounterMixing", "hCombinationCounterMixing", HistType::kTH1F, {{3, 0.0f, 3.0f}}); - hCombinationCounterMixing->GetXaxis()->SetBinLabel(1, "total"); - hCombinationCounterMixing->GetXaxis()->SetBinLabel(2, "bach sign/ID"); - hCombinationCounterMixing->GetXaxis()->SetBinLabel(3, "bach pT"); - hCombinationCounterMixing->LabelsOption("v"); + if (doprocessRealDataReduced3bodyMixing == true) { + auto h3bodyCombinationCounter = registry.add("Mixing/h3bodyCombinationCounter", "h3bodyCombinationCounter", HistType::kTH1D, {{4, 0.0f, 4.0f}}); + h3bodyCombinationCounter->GetXaxis()->SetBinLabel(1, "total"); + h3bodyCombinationCounter->GetXaxis()->SetBinLabel(2, "not same collision"); + h3bodyCombinationCounter->GetXaxis()->SetBinLabel(3, "collision VtxZ"); + h3bodyCombinationCounter->GetXaxis()->SetBinLabel(4, "bach sign/ID"); + h3bodyCombinationCounter->LabelsOption("v"); + registry.add("Mixing/hDecay3BodyRadiusPhi", "hDecay3BodyRadiusPhi", HistType::kTH2F, {mixingOpts.bins3BodyRadius, mixingOpts.bins3BodyPhi}); + registry.add("Mixing/hDecay3BodyPosZ", "hDecay3BodyPosZ", HistType::kTH1F, {mixingOpts.bins3BodyPosZ}); } } - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + template + bool initCCDB(aod::BCsWithTimestamps const& bcs, TCollisions const& collisions) { + auto bc = collisions.size() ? collisions.begin().template bc_as() : bcs.begin(); + if (!bcs.size()) { + LOGF(warn, "No BC found, skipping this DF."); + return false; // signal to skip this DF + } + if (mRunNumber == bc.runNumber()) { - return; + return true; } - // In case override, don't proceed, please - no CCDB access required - if (d_bz_input > -990) { - d_bz = d_bz_input; - fitter3body.setBz(d_bz); -#ifdef HomogeneousField - KFParticle::SetField(d_bz); -#endif - o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { - grpmag.setL3Current(30000.f / (d_bz / 5.0f)); - } - o2::base::Propagator::initFieldFromGRP(&grpmag); - mRunNumber = bc.runNumber(); - return; + if (doSkimmedProcessing) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), triggerList); + zorro.populateHistRegistry(registry, bc.runNumber()); } - auto run3grp_timestamp = bc.timestamp(); - o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + auto timestamp = bc.timestamp(); o2::parameters::GRPMagField* grpmag = 0x0; - if (grpo) { - o2::base::Propagator::initFieldFromGRP(grpo); - // Fetch magnetic field from ccdb for current collision - d_bz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); - if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; - } - o2::base::Propagator::initFieldFromGRP(grpmag); - // Fetch magnetic field from ccdb for current collision - // d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - d_bz = o2::base::Propagator::Instance()->getNominalBz(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } - mRunNumber = bc.runNumber(); - // Set magnetic field value once known - fitter3body.setBz(d_bz); + grpmag = ccdb->getForTimeStamp(ccdbConfigurations.grpmagPath, timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << ccdbConfigurations.grpmagPath << " of object GRPMagField for timestamp " << timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + // Fetch magnetic field from ccdb for current collision + auto d_bz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << d_bz << " kG"; + + // set magnetic field value for DCA fitter + helper.fitterV0.setBz(d_bz); + helper.fitter3body.setBz(d_bz); // Set magnetic field for KF vertexing #ifdef HomogeneousField KFParticle::SetField(d_bz); @@ -466,1211 +519,813 @@ struct decay3bodyBuilder { if (useMatCorrType == 2) { // setMatLUT only after magfield has been initalized // (setMatLUT has implicit and problematic init field call if not) + LOG(info) << "Loading material look-up table for timestamp: " << timestamp; + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(ccdbConfigurations.lutPath, timestamp)); o2::base::Propagator::Instance()->setMatLUT(lut); } - // Initial TOF PID Paras, copied from PIDTOF.h - timestamp.value = bc.timestamp(); - ccdb->setTimestamp(timestamp.value); - // Not later than now objects - ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - // TODO: implement the automatic pass name detection from metadata - if (passName.value == "") { - passName.value = "unanchored"; // temporary default - LOG(warning) << "Passed autodetect mode for pass, not implemented yet, waiting for metadata. Taking '" << passName.value << "'"; - } - LOG(info) << "Using parameter collection, starting from pass '" << passName.value << "'"; - - const std::string fname = paramFileName.value; - if (!fname.empty()) { // Loading the parametrization from file - LOG(info) << "Loading exp. sigma parametrization from file " << fname << ", using param: " << parametrizationPath.value; - if (1) { - o2::tof::ParameterCollection paramCollection; - paramCollection.loadParamFromFile(fname, parametrizationPath.value); - LOG(info) << "+++ Loaded parameter collection from file +++"; - if (!paramCollection.retrieveParameters(mRespParamsV2, passName.value)) { - if (fatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } - } else { - mRespParamsV2.setShiftParameters(paramCollection.getPars(passName.value)); - mRespParamsV2.printShiftParameters(); - } - } else { - mRespParamsV2.loadParamFromFile(fname.data(), parametrizationPath.value); - } - } else if (loadResponseFromCCDB) { // Loading it from CCDB - LOG(info) << "Loading exp. sigma parametrization from CCDB, using path: " << parametrizationPath.value << " for timestamp " << timestamp.value; - o2::tof::ParameterCollection* paramCollection = ccdb->getForTimeStamp(parametrizationPath.value, timestamp.value); - paramCollection->print(); - if (!paramCollection->retrieveParameters(mRespParamsV2, passName.value)) { // Attempt at loading the parameters with the pass defined - if (fatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } - } else { // Pass is available, load non standard parameters - mRespParamsV2.setShiftParameters(paramCollection->getPars(passName.value)); - mRespParamsV2.printShiftParameters(); - } - } - mRespParamsV2.print(); - if (timeShiftCCDBPath.value != "") { - if (timeShiftCCDBPath.value.find(".root") != std::string::npos) { - mRespParamsV2.setTimeShiftParameters(timeShiftCCDBPath.value, "gmean_Pos", true); - mRespParamsV2.setTimeShiftParameters(timeShiftCCDBPath.value, "gmean_Neg", false); - } else { - mRespParamsV2.setTimeShiftParameters(ccdb->getForTimeStamp(Form("%s/pos", timeShiftCCDBPath.value.c_str()), timestamp.value), true); - mRespParamsV2.setTimeShiftParameters(ccdb->getForTimeStamp(Form("%s/neg", timeShiftCCDBPath.value.c_str()), timestamp.value), false); - } - } - - bachelorTOFPID.SetParams(mRespParamsV2); - } + // mark run as configured + mRunNumber = bc.runNumber(); - //------------------------------------------------------------------ - // Select decay3body candidate based on daughter track PID - template - bool checkPID(TTrack const& trackProton, TTrack const& trackPion, TTrack const& trackBachelor, const double& tofNSigmaBach) - { - if ((tofNSigmaBach < TofPidNsigmaMin || tofNSigmaBach > TofPidNsigmaMax) && trackBachelor.p() > minBachPUseTOF) { - return false; - } - if (std::abs(trackProton.tpcNSigmaPr()) > TpcPidNsigmaCut) { - return false; - } - if (std::abs(trackPion.tpcNSigmaPi()) > TpcPidNsigmaCut) { - return false; - } - return true; - } - // PID check for H3L - template - bool checkPIDH3L(TTrack const& trackProton, TTrack const& trackPion, TTrack const& trackBachelor, const double& tofNSigmaBach) - { - if ((std::abs(trackBachelor.tpcNSigmaDe()) > TpcPidNsigmaCut) || !checkPID(trackProton, trackPion, trackBachelor, tofNSigmaBach)) { - return false; - } - return true; - } + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, bc); - //------------------------------------------------------------------ - // function to select daughter track PID - template - bool selectTPCPID(TTrack const& trackProton, TTrack const& trackPion, TTrack const& trackDeuteron) - { - if (std::abs(trackProton.tpcNSigmaPr()) > kfparticleConfigurations.maxtpcnSigma) { - return false; - } - if (std::abs(trackDeuteron.tpcNSigmaDe()) > kfparticleConfigurations.maxtpcnSigma) { - return false; - } - if (kfparticleConfigurations.useTPCforPion && std::abs(trackPion.tpcNSigmaPi()) > kfparticleConfigurations.maxtpcnSigma) { - return false; - } return true; } - //------------------------------------------------------------------ - // 3body candidate builder - template - void fillVtxCand(TCollisionTable const& collision, TTrackTable const& t0, TTrackTable const& t1, TTrackTable const& t2, int64_t decay3bodyId, int bachelorcharge = 1) + float getMagFieldFromRunNumber(int runNumber) { - - registry.fill(HIST("hVtx3BodyCounter"), kVtxAll); - - if (t0.tpcNClsFound() < mintpcNCls || t1.tpcNClsFound() < mintpcNCls || t2.tpcNClsFound() < mintpcNCls) { - return; - } - registry.fill(HIST("hVtx3BodyCounter"), kVtxTPCNcls); - - // Recalculate the TOF PID - double tofNSigmaBach = -999; - if (t2.has_collision() && t2.hasTOF()) { - if (decay3bodyId == -1) { - // for event-mixing, the collisionId of tracks not equal to global index - tofNSigmaBach = bachelorTOFPID.GetTOFNSigma(t2, collision, collision); - } else { - auto originalcol = t2.template collision_as(); - tofNSigmaBach = bachelorTOFPID.GetTOFNSigma(t2, originalcol, collision); + float magField; + // Check if the CCDB data for this run is already cached + if (ccdbCache.find(runNumber) != ccdbCache.end()) { + LOG(debug) << "CCDB data already cached for run " << runNumber; + magField = ccdbCache[runNumber]; + // if not, retrieve it from CCDB + } else { + std::shared_ptr grpmag = std::make_shared(*ccdb->getForRun(ccdbConfigurations.grpmagPath, runNumber)); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << ccdbConfigurations.grpmagPath << " of object GRPMagField and " << ccdbConfigurations.grpPath << " of object GRPObject for run number " << runNumber; } - } + o2::base::Propagator::initFieldFromGRP(grpmag.get()); + // Fetch magnetic field from ccdb for current collision + magField = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for run number " << runNumber << " with magnetic field of " << d_bz << " kZG"; - if (enablePidCut) { - if (t2.sign() > 0) { - if (!checkPIDH3L(t0, t1, t2, tofNSigmaBach)) - return; - } else { - if (!checkPIDH3L(t1, t0, t2, tofNSigmaBach)) - return; - } + // cache magnetic field info + ccdbCache[runNumber] = magField; } + return magField; + } - registry.fill(HIST("hVtx3BodyCounter"), kVtxPIDCut); - - // Calculate DCA with respect to the collision associated to the V0, not individual tracks - gpu::gpustd::array dcaInfo; - - auto Track0Par = getTrackPar(t0); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, Track0Par, 2.f, fitter3body.getMatCorrType(), &dcaInfo); - auto Track0dcaXY = dcaInfo[0]; - auto Track0dca = std::sqrt(Track0dcaXY * Track0dcaXY + dcaInfo[1] * dcaInfo[1]); - - auto Track1Par = getTrackPar(t1); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, Track1Par, 2.f, fitter3body.getMatCorrType(), &dcaInfo); - auto Track1dcaXY = dcaInfo[0]; - auto Track1dca = std::sqrt(Track1dcaXY * Track1dcaXY + dcaInfo[1] * dcaInfo[1]); - - auto Track2Par = getTrackPar(t2); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, Track2Par, 2.f, fitter3body.getMatCorrType(), &dcaInfo); - auto Track2dcaXY = dcaInfo[0]; - auto Track2dca = std::sqrt(Track2dcaXY * Track2dcaXY + dcaInfo[1] * dcaInfo[1]); - - auto Track0 = getTrackParCov(t0); - auto Track1 = getTrackParCov(t1); - auto Track2 = getTrackParCov(t2); - int n3bodyVtx = fitter3body.process(Track0, Track1, Track2); - if (n3bodyVtx == 0) { // discard this pair + void initFittersWithMagField(int runNumber, float magField) + { + // set magnetic field only when run number changes + if (mRunNumber == runNumber) { + LOG(debug) << "CCDB initialized for run " << mRunNumber; return; } - registry.fill(HIST("hVtx3BodyCounter"), kVtxhasSV); + mRunNumber = runNumber; // Update the last run number - std::array pos = {0.}; - const auto& vtxXYZ = fitter3body.getPCACandidate(); - for (int i = 0; i < 3; i++) { - pos[i] = vtxXYZ[i]; - } - - std::array p0 = {0.}, p1 = {0.}, p2{0.}; - const auto& propagatedTrack0 = fitter3body.getTrack(0); - const auto& propagatedTrack1 = fitter3body.getTrack(1); - const auto& propagatedTrack2 = fitter3body.getTrack(2); - propagatedTrack0.getPxPyPzGlo(p0); - propagatedTrack1.getPxPyPzGlo(p1); - propagatedTrack2.getPxPyPzGlo(p2); - for (int i = 0; i < 3; i++) { - p2[i] *= bachelorcharge; - } - std::array p3B = {p0[0] + p1[0] + p2[0], p0[1] + p1[1] + p2[1], p0[2] + p1[2] + p2[2]}; + // update propagator + o2::base::Propagator::Instance()->setNominalBz(magField); - if (fitter3body.getChi2AtPCACandidate() > dcavtxdau) { - return; - } - registry.fill(HIST("hVtx3BodyCounter"), kVtxDcaDau); + // Set magnetic field for KF vertexing +#ifdef HomogeneousField + KFParticle::SetField(magField); +#endif + // Set field for DCAfitter + helper.fitterV0.setBz(magField); + helper.fitter3body.setBz(magField); - float VtxcosPA = RecoDecay::cpa(array{collision.posX(), collision.posY(), collision.posZ()}, array{pos[0], pos[1], pos[2]}, array{p3B[0], p3B[1], p3B[2]}); - if (VtxcosPA < minCosPA3body) { - return; + if (useMatCorrType == 2) { + // setMatLUT only after magfield has been initalized (setMatLUT has implicit and problematic init field call if not) + o2::base::Propagator::Instance()->setMatLUT(lut); } - registry.fill(HIST("hVtx3BodyCounter"), kVtxCosPA); - - registry.fill(HIST("hBachelorTOFNSigmaDe"), t2.sign() * t2.p(), tofNSigmaBach); - - vtxCandidate candVtx; - candVtx.track0Id = t0.globalIndex(); - candVtx.track1Id = t1.globalIndex(); - candVtx.track2Id = t2.globalIndex(); - candVtx.collisionId = collision.globalIndex(); - candVtx.decay3bodyId = decay3bodyId; - candVtx.vtxPos[0] = pos[0]; - candVtx.vtxPos[1] = pos[1]; - candVtx.vtxPos[2] = pos[2]; - candVtx.track0P[0] = p0[0]; - candVtx.track0P[1] = p0[1]; - candVtx.track0P[2] = p0[2]; - candVtx.track1P[0] = p1[0]; - candVtx.track1P[1] = p1[1]; - candVtx.track1P[2] = p1[2]; - candVtx.track2P[0] = p2[0]; - candVtx.track2P[1] = p2[1]; - candVtx.track2P[2] = p2[2]; - candVtx.dcadaughters = fitter3body.getChi2AtPCACandidate(); - candVtx.daudcaxytopv[0] = Track0dcaXY; - candVtx.daudcaxytopv[1] = Track1dcaXY; - candVtx.daudcaxytopv[2] = Track2dcaXY; - candVtx.daudcatopv[0] = Track0dca; - candVtx.daudcatopv[1] = Track1dca; - candVtx.daudcatopv[2] = Track2dca; - candVtx.bachelortofNsigma = tofNSigmaBach; - vtxCandidates.push_back(candVtx); - } - //------------------------------------------------------------------ - // fill the StoredVtx3BodyDatas table - void fillVtx3BodyTable(vtxCandidate const& candVtx) - { - vtx3bodydata( - candVtx.track0Id, candVtx.track1Id, candVtx.track2Id, candVtx.collisionId, candVtx.decay3bodyId, - candVtx.vtxPos[0], candVtx.vtxPos[1], candVtx.vtxPos[2], - candVtx.track0P[0], candVtx.track0P[1], candVtx.track0P[2], candVtx.track1P[0], candVtx.track1P[1], candVtx.track1P[2], candVtx.track2P[0], candVtx.track2P[1], candVtx.track2P[2], - candVtx.dcadaughters, - candVtx.daudcaxytopv[0], candVtx.daudcaxytopv[1], candVtx.daudcaxytopv[2], - candVtx.daudcatopv[0], candVtx.daudcatopv[1], candVtx.daudcatopv[2], - candVtx.bachelortofNsigma); } - //------------------------------------------------------------------ - // 3body candidate builder with KFParticle - template - void buildVtx3BodyDataTableKFParticle(TCollision const& collision, TTrack const& trackPos, TTrack const& trackNeg, TTrack const& trackBach, int64_t decay3bodyID, int bachelorcharge = 1) + // ______________________________________________________________ + // function to build decay3body candidates + template + void buildCandidates(TBCs const&, + TCollisions const& collisions, + T3Bodys const& decay3bodys, + TMCParticles const& mcParticles, + TMCCollisions const& mcCollisions) { - LOG(debug) << "buildVtx3BodyDataTableKFParticle called."; - - bool isEventMixing = false; - if (decay3bodyID == -1) { - isEventMixing = true; + if (!(mEnabledTables[kVtx3BodyDatas] || mEnabledTables[kMcVtx3BodyDatas])) { + LOG(info) << "No request for candidate analysis table in place, skipping candidate building." << std::endl; + return; // don't do if no request for decay3bodys in place } - // initialise KF primary vertex - KFPVertex kfpVertex = createKFPVertexFromCollision(collision); - KFParticle kfpv(kfpVertex); - LOG(debug) << "Created KF PV."; - - // fill event QA histograms - if (kfparticleConfigurations.doVertexQA) { - registry.fill(HIST("QA/Event/hVtxXKF"), kfpv.GetX()); - registry.fill(HIST("QA/Event/hVtxYKF"), kfpv.GetY()); - registry.fill(HIST("QA/Event/hVtxZKF"), kfpv.GetZ()); - registry.fill(HIST("QA/Event/hVtxCovXXKF"), kfpv.GetCovariance(0)); - registry.fill(HIST("QA/Event/hVtxCovYYKF"), kfpv.GetCovariance(2)); - registry.fill(HIST("QA/Event/hVtxCovZZKF"), kfpv.GetCovariance(5)); - registry.fill(HIST("QA/Event/hVtxCovXYKF"), kfpv.GetCovariance(1)); - registry.fill(HIST("QA/Event/hVtxCovXZKF"), kfpv.GetCovariance(3)); - registry.fill(HIST("QA/Event/hVtxCovYZKF"), kfpv.GetCovariance(4)); - registry.fill(HIST("QA/Event/hVtxX"), collision.posX()); - registry.fill(HIST("QA/Event/hVtxY"), collision.posY()); - registry.fill(HIST("QA/Event/hVtxZ"), collision.posZ()); - registry.fill(HIST("QA/Event/hVtxCovXX"), collision.covXX()); - registry.fill(HIST("QA/Event/hVtxCovYY"), collision.covYY()); - registry.fill(HIST("QA/Event/hVtxCovZZ"), collision.covZZ()); - registry.fill(HIST("QA/Event/hVtxCovXY"), collision.covXY()); - registry.fill(HIST("QA/Event/hVtxCovXZ"), collision.covXZ()); - registry.fill(HIST("QA/Event/hVtxCovYZ"), collision.covYZ()); - } + // prepare MC container (not necessarily used) + std::vector mcParticleIsReco; - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxAll); - - auto trackParCovPos = getTrackParCov(trackPos); - auto trackParCovNeg = getTrackParCov(trackNeg); - auto trackParCovBach = getTrackParCov(trackBach); - LOG(debug) << "Got all daughter tracks."; - - bool isMatter = trackBach.sign() > 0 ? true : false; - - // ---------- fill track QA histograms ---------- - if (kfparticleConfigurations.doTrackQA) { - registry.fill(HIST("QA/Tracks/hTrackPosTPCNcls"), trackPos.tpcNClsFound()); - registry.fill(HIST("QA/Tracks/hTrackNegTPCNcls"), trackNeg.tpcNClsFound()); - registry.fill(HIST("QA/Tracks/hTrackBachTPCNcls"), trackBach.tpcNClsFound()); - registry.fill(HIST("QA/Tracks/hTrackPosHasTPC"), trackPos.hasTPC()); - registry.fill(HIST("QA/Tracks/hTrackNegHasTPC"), trackNeg.hasTPC()); - registry.fill(HIST("QA/Tracks/hTrackBachHasTPC"), trackBach.hasTPC()); - registry.fill(HIST("QA/Tracks/hTrackBachITSClusSizes"), trackBach.itsClusterSizes()); - if (isMatter) { - registry.fill(HIST("QA/Tracks/hTrackProtonTPCPID"), trackPos.sign() * trackPos.tpcInnerParam(), trackPos.tpcNSigmaPr()); - registry.fill(HIST("QA/Tracks/hTrackPionTPCPID"), trackNeg.sign() * trackNeg.tpcInnerParam(), trackNeg.tpcNSigmaPi()); - registry.fill(HIST("QA/Tracks/hTrackProtonPt"), trackPos.pt()); - registry.fill(HIST("QA/Tracks/hTrackPionPt"), trackNeg.pt()); - } else { - registry.fill(HIST("QA/Tracks/hTrackProtonTPCPID"), trackNeg.sign() * trackNeg.tpcInnerParam(), trackNeg.tpcNSigmaPr()); - registry.fill(HIST("QA/Tracks/hTrackPionTPCPID"), trackPos.sign() * trackPos.tpcInnerParam(), trackPos.tpcNSigmaPi()); - registry.fill(HIST("QA/Tracks/hTrackProtonPt"), trackNeg.pt()); - registry.fill(HIST("QA/Tracks/hTrackPionPt"), trackPos.pt()); - } - registry.fill(HIST("QA/Tracks/hTrackBachTPCPID"), trackBach.sign() * trackBach.tpcInnerParam(), trackBach.tpcNSigmaDe()); - registry.fill(HIST("QA/Tracks/hTrackBachPt"), trackBach.pt()); + if constexpr (soa::is_table) { + isTriggeredCollision.clear(); + isTriggeredCollision.resize(collisions.size(), false); } - - // -------- STEP 1: track selection -------- - // collision ID --> not correct? tracks can have different collisions, but belong to one 3prong vertex! - // if (trackPos.collisionId() != trackNeg.collisionId() || trackPos.collisionId() != trackBach.collisionId() || trackNeg.collisionId() != trackBach.collisionId()) { - // continue; - // } - // track IDs --> already checked in SVertexer! - - // track signs (pos, neg, bach) --> sanity check, should already be in SVertexer - if (trackPos.sign() != +1 || trackNeg.sign() != -1) { - return; + // clear and reserve size for MC info vectors + if constexpr (soa::is_table) { + isGoodCollision.clear(); + mcParticleIsReco.clear(); + isGoodCollision.resize(mcCollisions.size(), false); + mcParticleIsReco.resize(mcParticles.size(), false); } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxCharge); - // track eta - if (abs(trackPos.eta()) > kfparticleConfigurations.maxEta || abs(trackNeg.eta()) > kfparticleConfigurations.maxEta || abs(trackBach.eta()) > kfparticleConfigurations.maxEta) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxEta); + // Loop over collisions for vertex QA + for (const auto& collision : collisions) { + if constexpr (soa::is_table) { // only do if NOT running over reduced data (already done in reducedCreator) + // Zorro event counting + bool isZorroSelected = false; + if (doSkimmedProcessing) { + isZorroSelected = zorro.isSelected(collision.template bc_as().globalBC()); + if (!isZorroSelected && onlyKeepInterestedTrigger) { + continue; + } + } - // number of TPC clusters - if (trackBach.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsBach) { - return; - } - if (isMatter && ((kfparticleConfigurations.useTPCforPion && trackNeg.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsPion) || trackPos.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsProton)) { - return; - } else if (!isMatter && ((kfparticleConfigurations.useTPCforPion && trackPos.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsPion) || trackNeg.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsProton)) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxTPCNcls); + isTriggeredCollision[collision.globalIndex()] = true; + // event counting + registry.fill(HIST("Counters/hEventCounter"), 0.5); + if (doSel8selection && !collision.sel8()) { + continue; + } + registry.fill(HIST("Counters/hEventCounter"), 1.5); + if (doPosZselection && (collision.posZ() >= 10.0f || collision.posZ() <= -10.0f)) { + continue; + } + registry.fill(HIST("Counters/hEventCounter"), 2.5); + } - // number of TPC crossed rows - if (trackBach.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRows) { - return; - } - if (isMatter && ((kfparticleConfigurations.useTPCforPion && trackNeg.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRowsPion) || trackPos.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRows)) { - return; - } else if (!isMatter && ((kfparticleConfigurations.useTPCforPion && trackPos.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRowsPion) || trackNeg.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRows)) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxTPCRows); - - // TPC PID - float tpcNsigmaProton; - float tpcNsigmaPion; - float dEdxProton; - float dEdxPion; - float tpcNsigmaDeuteron = trackBach.tpcNSigmaDe(); - float tpcNsigmaPionBach = trackBach.tpcNSigmaPi(); - float dEdxDeuteron = trackBach.tpcSignal(); - if (isMatter) { // hypertriton (proton, pi-, deuteron) - tpcNsigmaProton = trackPos.tpcNSigmaPr(); - tpcNsigmaPion = trackNeg.tpcNSigmaPi(); - dEdxProton = trackPos.tpcSignal(); - dEdxPion = trackNeg.tpcSignal(); - if (!selectTPCPID(trackPos, trackNeg, trackBach)) { - return; + // vertex QA and counting + if (doVertexQA) { + registry.fill(HIST("QA/Event/hAllSelEventsVtxZ"), collision.posZ()); + registry.fill(HIST("QA/Event/hVtxX"), collision.posX()); + registry.fill(HIST("QA/Event/hVtxY"), collision.posY()); + registry.fill(HIST("QA/Event/hVtxZ"), collision.posZ()); + registry.fill(HIST("QA/Event/hVtxCovXX"), collision.covXX()); + registry.fill(HIST("QA/Event/hVtxCovYY"), collision.covYY()); + registry.fill(HIST("QA/Event/hVtxCovZZ"), collision.covZZ()); + registry.fill(HIST("QA/Event/hVtxCovXY"), collision.covXY()); + registry.fill(HIST("QA/Event/hVtxCovXZ"), collision.covXZ()); + registry.fill(HIST("QA/Event/hVtxCovYZ"), collision.covYZ()); } - } else if (!isMatter) { // anti-hypertriton (anti-proton, pi+, deuteron) - tpcNsigmaProton = trackNeg.tpcNSigmaPr(); - tpcNsigmaPion = trackPos.tpcNSigmaPi(); - dEdxProton = trackNeg.tpcSignal(); - dEdxPion = trackPos.tpcSignal(); - if (!selectTPCPID(trackNeg, trackPos, trackBach)) { - return; + + // In case of MC: reco collision survived event selection filter --> fill value for MC collision if collision is "true" MC collision + if constexpr (soa::is_table) { + if (collision.mcCollisionId() >= 0) { + isGoodCollision[collision.mcCollisionId()] = true; + } } - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxTPCPID); - LOG(debug) << "Basic track selections done."; - - // TOF PID of deuteron (set motherhyp correctly) - double tofNSigmaDeuteron = -999; - if (trackBach.has_collision() && trackBach.hasTOF()) { - if (isEventMixing) { - tofNSigmaDeuteron = bachelorTOFPID.GetTOFNSigma(trackBach, collision, collision); - } else { - auto originalcol = trackBach.template collision_as(); - tofNSigmaDeuteron = bachelorTOFPID.GetTOFNSigma(trackBach, originalcol, collision); + } // loop over collisions + + // Loop over all decay3bodys in same time frame + registry.fill(HIST("Counters/hInputStatistics"), kVtx3BodyDatas, decay3bodys.size()); + int lastRunNumber = -1; + for (const auto& decay3body : decay3bodys) { + // only build tracked decay3body if aksed + if (decay3bodyBuilderOpts.buildOnlyTracked && fTrackedClSizeVector[decay3body.globalIndex()] == 0) { + continue; } - } - // Average ITS cluster size of deuteron track - double averageClusterSizeDeuteron(0); - int nCls(0); - for (int i = 0; i < 7; i++) { - int clusterSize = trackBach.itsClsSizeInLayer(i); - averageClusterSizeDeuteron += static_cast(clusterSize); - if (clusterSize > 0) - nCls++; - } - averageClusterSizeDeuteron = averageClusterSizeDeuteron / static_cast(nCls); - - /// TODO: check to which PV bachelor DCA has to be calculated in event mixing case and add it here - // track DCAxy and DCAz to PV associated with decay3body - o2::dataformats::VertexBase mPV; - o2::dataformats::DCA mDcaInfoCovPos; - o2::dataformats::DCA mDcaInfoCovNeg; - o2::dataformats::DCA mDcaInfoCovBach; - auto trackParCovPVPos = trackParCovPos; - auto trackParCovPVNeg = trackParCovNeg; - auto trackParCovPVBach = trackParCovBach; - mPV.setPos({collision.posX(), collision.posY(), collision.posZ()}); - mPV.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); - o2::base::Propagator::Instance()->propagateToDCABxByBz(mPV, trackParCovPVPos, 2.f, matCorr, &mDcaInfoCovPos); - o2::base::Propagator::Instance()->propagateToDCABxByBz(mPV, trackParCovPVNeg, 2.f, matCorr, &mDcaInfoCovNeg); - o2::base::Propagator::Instance()->propagateToDCABxByBz(mPV, trackParCovPVBach, 2.f, matCorr, &mDcaInfoCovBach); - auto TrackPosDcaXY = mDcaInfoCovPos.getY(); - auto TrackNegDcaXY = mDcaInfoCovNeg.getY(); - auto TrackBachDcaXY = mDcaInfoCovBach.getY(); - auto TrackPosDcaZ = mDcaInfoCovPos.getZ(); - auto TrackNegDcaZ = mDcaInfoCovNeg.getZ(); - auto TrackBachDcaZ = mDcaInfoCovBach.getZ(); - // calculate 3D track DCA - auto TrackPosDca = std::sqrt(TrackPosDcaXY * TrackPosDcaXY + TrackPosDcaZ * TrackPosDcaZ); - auto TrackNegDca = std::sqrt(TrackNegDcaXY * TrackNegDcaXY + TrackNegDcaZ * TrackNegDcaZ); - auto TrackBachDca = std::sqrt(TrackBachDcaXY * TrackBachDcaXY + TrackBachDcaZ * TrackBachDcaZ); - // selection - if (isMatter && (fabs(TrackNegDcaXY) <= kfparticleConfigurations.mindcaXYPionPV || fabs(TrackPosDcaXY) <= kfparticleConfigurations.mindcaXYProtonPV)) { - return; - } else if (!isMatter && (fabs(TrackPosDcaXY) <= kfparticleConfigurations.mindcaXYPionPV || fabs(TrackNegDcaXY) <= kfparticleConfigurations.mindcaXYProtonPV)) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxDCAxyPV); - if (isMatter && (fabs(TrackNegDcaZ) <= kfparticleConfigurations.mindcaZPionPV || fabs(TrackPosDcaZ) <= kfparticleConfigurations.mindcaZProtonPV)) { - return; - } else if (!isMatter && (fabs(TrackPosDcaZ) <= kfparticleConfigurations.mindcaZPionPV || fabs(TrackNegDcaZ) <= kfparticleConfigurations.mindcaZProtonPV)) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxDCAzPV); - // SVertexer selection bachelor track for event mixing - if (isEventMixing && kfparticleConfigurations.applySVertexerCuts && TrackBachDca < 0.05) { - return; - } + // skip decay3body without assigned collision + /// TODO: do we want this?? + if (decay3body.collisionId() < 0) { + continue; + } - // daughter track momentum at inner wall of TPC - float tpcInnerParamProton; - float tpcInnerParamPion; - float tpcInnerParamDeuteron = trackBach.tpcInnerParam(); - if (isMatter) { // hypertriton (proton, pi-, deuteron) - tpcInnerParamProton = trackPos.tpcInnerParam(); - tpcInnerParamPion = trackNeg.tpcInnerParam(); - } else if (!isMatter) { // anti-hypertriton (anti-proton, pi+, deuteron) - tpcInnerParamProton = trackNeg.tpcInnerParam(); - tpcInnerParamPion = trackPos.tpcInnerParam(); - } + // aquire collision + auto const& collision = collisions.rawIteratorAt(decay3body.collisionId()); - // -------- STEP 2: fit vertex with proton and pion -------- - // Fit vertex with DCA fitter to find minimization point --> uses material corrections implicitly - if (kfparticleConfigurations.doDCAFitterPreMinimum) { - try { - fitter3body.process(trackParCovPos, trackParCovNeg, trackParCovBach); - } catch (std::runtime_error& e) { - LOG(error) << "Exception caught in DCA fitter process call: Not able to fit decay3body vertex!"; - return; + // initialise CCDB from run number saved in reduced collisions table when running over reduced data + if constexpr (!soa::is_table) { // only do if running over reduced data (otherwise CCDB is initialised in process function) + if (collision.runNumber() != lastRunNumber) { + initFittersWithMagField(collision.runNumber(), getMagFieldFromRunNumber(collision.runNumber())); + lastRunNumber = collision.runNumber(); // Update the last run number + LOG(debug) << "CCDB initialized for run " << lastRunNumber; + } } - // re-acquire tracks at vertex position from DCA fitter - trackParCovPos = fitter3body.getTrack(0); - trackParCovNeg = fitter3body.getTrack(1); - trackParCovBach = fitter3body.getTrack(2); - - LOG(debug) << "Minimum found with DCA fitter for decay3body."; - } - // create KFParticle objects from tracks - KFParticle kfpProton, kfpPion; - if (isMatter) { - kfpProton = createKFParticleFromTrackParCov(trackParCovPos, trackPos.sign(), constants::physics::MassProton); - kfpPion = createKFParticleFromTrackParCov(trackParCovNeg, trackNeg.sign(), constants::physics::MassPionCharged); - } else if (!isMatter) { - kfpProton = createKFParticleFromTrackParCov(trackParCovNeg, trackNeg.sign(), constants::physics::MassProton); - kfpPion = createKFParticleFromTrackParCov(trackParCovPos, trackPos.sign(), constants::physics::MassPionCharged); - } - LOG(debug) << "KFParticle objects created from daughter tracks."; - - // Construct V0 as intermediate step - KFParticle KFV0; - int nDaughtersV0 = 2; - const KFParticle* DaughtersV0[2] = {&kfpProton, &kfpPion}; - KFV0.SetConstructMethod(2); - try { - KFV0.Construct(DaughtersV0, nDaughtersV0); - } catch (std::runtime_error& e) { - LOG(debug) << "Failed to create V0 vertex from daughter tracks." << e.what(); - return; - } - KFV0.TransportToDecayVertex(); - LOG(debug) << "V0 constructed."; - - // check V0 mass and set mass constraint - float massV0, sigmaMassV0; - KFV0.GetMass(massV0, sigmaMassV0); - KFParticle KFV0Mass = KFV0; - KFV0Mass.SetNonlinearMassConstraint(o2::constants::physics::MassLambda); - float chi2massV0 = KFV0Mass.GetChi2() / KFV0Mass.GetNDF(); - if (kfparticleConfigurations.useLambdaMassConstraint) { - LOG(debug) << "V0 mass constraint applied."; - KFV0 = KFV0Mass; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxV0MassConst); - - // -------- STEP 3: fit three body vertex -------- - // Create KFParticle object from deuteron track - KFParticle kfpDeuteron; - kfpDeuteron = createKFParticleFromTrackParCov(trackParCovBach, trackBach.sign() * bachelorcharge, constants::physics::MassDeuteron); - LOG(debug) << "KFParticle created from deuteron track."; - // Construct 3body vertex - int nDaughters3body = 3; - const KFParticle* Daughters3body[3] = {&kfpProton, &kfpPion, &kfpDeuteron}; - KFParticle KFHt; - KFHt.SetConstructMethod(2); - try { - KFHt.Construct(Daughters3body, nDaughters3body); - } catch (std::runtime_error& e) { - LOG(debug) << "Failed to create Hyper triton 3-body vertex." << e.what(); - return; - } - // transport all daughter tracks to hypertriton vertex - float HtVtx[3] = {0.}; - HtVtx[0] = KFHt.GetX(); - HtVtx[1] = KFHt.GetY(); - HtVtx[2] = KFHt.GetZ(); - kfpProton.TransportToPoint(HtVtx); - kfpPion.TransportToPoint(HtVtx); - kfpDeuteron.TransportToPoint(HtVtx); - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxhasSV); - LOG(debug) << "Hypertriton vertex constructed."; - - // -------- STEP 4: daughter selections after geometrical vertex fit -------- - // daughter DCAs with KF - if ((kfpProton.GetDistanceFromParticle(kfpPion) >= kfparticleConfigurations.maxDcaProPi) || (kfpProton.GetDistanceFromParticle(kfpDeuteron) >= kfparticleConfigurations.maxDcaProDeu) || (kfpPion.GetDistanceFromParticle(kfpDeuteron) >= kfparticleConfigurations.maxDcaPiDe)) { - return; - } - float DCAvtxDaughters3D = kfpProton.GetDistanceFromParticle(kfpPion) + kfpProton.GetDistanceFromParticle(kfpDeuteron) + kfpPion.GetDistanceFromParticle(kfpDeuteron); - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxDcaDau); - LOG(debug) << "DCA selection after vertex fit applied."; + // event selection + if constexpr (soa::is_table) { // only when NOT running over reduced data + if (doSel8selection && !collision.sel8()) { + continue; + } + if (onlyKeepInterestedTrigger && !isTriggeredCollision[collision.globalIndex()]) { + continue; + } + } + if (doPosZselection && (collision.posZ() >= 10.0f || collision.posZ() <= -10.0f)) { + continue; + } - // daughter DCAs to vertex - if (kfpProton.GetDistanceFromVertexXY(KFHt) >= kfparticleConfigurations.maxDcaXYSVDau || kfpPion.GetDistanceFromVertexXY(KFHt) >= kfparticleConfigurations.maxDcaXYSVDau || kfpDeuteron.GetDistanceFromVertexXY(KFHt) >= kfparticleConfigurations.maxDcaXYSVDau) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxDcaDauVtx); - LOG(debug) << "DCA to vertex selection after vertex fit applied."; + // aquire tracks + auto trackPos = decay3body.template track0_as(); + auto trackNeg = decay3body.template track1_as(); + auto trackDeuteron = decay3body.template track2_as(); + int protonSign = doLikeSign ? -trackDeuteron.sign() : trackDeuteron.sign(); + auto trackProton = protonSign > 0 ? trackPos : trackNeg; + auto trackPion = protonSign > 0 ? trackNeg : trackPos; + + // get deuteron TOF PID + float tofNSigmaDeuteron; + if constexpr (!soa::is_table) { // running over derived data + tofNSigmaDeuteron = trackDeuteron.tofNSigmaDe(); + } else if constexpr (soa::is_table) { // running over AO2Ds + if constexpr (soa::is_table) { // running over MC (track table with labels) + tofNSigmaDeuteron = getTOFnSigma(mRespParamsV3, collision, trackDeuteron); + } else { // running over real data + tofNSigmaDeuteron = getTOFnSigma(mRespParamsV3, collision, trackDeuteron); + } + } - // daughter pT - if (kfpProton.GetPt() < kfparticleConfigurations.minPtProton || kfpProton.GetPt() > kfparticleConfigurations.maxPtProton || kfpPion.GetPt() < kfparticleConfigurations.minPtPion || kfpPion.GetPt() > kfparticleConfigurations.maxPtPion || kfpDeuteron.GetPt() < kfparticleConfigurations.minPtDeuteron || kfpDeuteron.GetPt() > kfparticleConfigurations.maxPtDeuteron) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxDauPt); - LOG(debug) << "Daughter pT selection applied."; + /// build Decay3body candidate + if (!helper.buildDecay3BodyCandidate(collision, + trackProton, + trackPion, + trackDeuteron, + decay3body.globalIndex(), + tofNSigmaDeuteron, + fTrackedClSizeVector[decay3body.globalIndex()], + decay3bodyBuilderOpts.useKFParticle, + decay3bodyBuilderOpts.kfSetTopologicalConstraint, + decay3bodyBuilderOpts.useSelections, + decay3bodyBuilderOpts.useChi2Selection, + decay3bodyBuilderOpts.useTPCforPion, + decay3bodyBuilderOpts.acceptTPCOnly, + decay3bodyBuilderOpts.askOnlyITSMatch, + decay3bodyBuilderOpts.calculateCovariance, + false /*isEventMixing*/)) { + continue; + } - // -------- STEP 5: candidate selection after geometrical vertex fit -------- - // Rapidity - float rapHt = RecoDecay::y(std::array{KFHt.GetPx(), KFHt.GetPy(), KFHt.GetPz()}, o2::constants::physics::MassHyperTriton); - if (std::abs(rapHt) > kfparticleConfigurations.maxRapidityHt) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxRap); + // fill QA histograms + if (doTrackQA) { // histograms filled for daughter tracks of (selected) 3body candidates + registry.fill(HIST("QA/Tracks/hTrackProtonTPCNcls"), trackProton.tpcNClsFound()); + registry.fill(HIST("QA/Tracks/hTrackPionTPCNcls"), trackPion.tpcNClsFound()); + registry.fill(HIST("QA/Tracks/hTrackDeuteronTPCNcls"), trackDeuteron.tpcNClsFound()); + registry.fill(HIST("QA/Tracks/hTrackProtonHasTPC"), trackProton.hasTPC()); + registry.fill(HIST("QA/Tracks/hTrackPionHasTPC"), trackPion.hasTPC()); + registry.fill(HIST("QA/Tracks/hTrackDeuteronHasTPC"), trackDeuteron.hasTPC()); + registry.fill(HIST("QA/Tracks/hTrackDeuteronITSClusSizes"), trackDeuteron.itsClusterSizes()); + registry.fill(HIST("QA/Tracks/hTrackProtonTPCPID"), trackProton.sign() * trackProton.tpcInnerParam(), trackProton.tpcNSigmaPr()); + registry.fill(HIST("QA/Tracks/hTrackPionTPCPID"), trackPion.sign() * trackPion.tpcInnerParam(), trackPion.tpcNSigmaPi()); + registry.fill(HIST("QA/Tracks/hTrackDeuteronTPCPID"), trackDeuteron.sign() * trackDeuteron.tpcInnerParam(), trackDeuteron.tpcNSigmaDe()); + registry.fill(HIST("QA/Tracks/hTrackProtonPt"), trackProton.pt()); + registry.fill(HIST("QA/Tracks/hTrackPionPt"), trackPion.pt()); + registry.fill(HIST("QA/Tracks/hTrackDeuteronPt"), trackDeuteron.pt()); + } - // Pt selection - if (KFHt.GetPt() <= kfparticleConfigurations.minPtHt || KFHt.GetPt() >= kfparticleConfigurations.maxPtHt) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxPt); + // generate analysis tables with current candidate (only Vtx3BodyDatas is filled here, McVtx3BodyDatas table is filled later) + if (!mEnabledTables[kMcVtx3BodyDatas]) { + fillAnalysisTables(); + } - // Mass window - float massHt, sigmaMassHt; - KFHt.GetMass(massHt, sigmaMassHt); - if (massHt <= kfparticleConfigurations.minMassHt || massHt >= kfparticleConfigurations.maxMassHt) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxMass); + // ___________________________________________________________ + // MC handling part: matching of reconstructed candidates + // ___________________________________________________________ + // fill MC table with reco MC candidate information and gen information if matched to MC particle + if constexpr (soa::is_table) { + // MC info + resetMCInfo(this3BodyMCInfo); + this3BodyMCInfo.isReco = true; + + // check if daughters have MC particle + if (!trackProton.has_mcParticle() || !trackPion.has_mcParticle() || !trackDeuteron.has_mcParticle()) { + continue; + } - // cos(PA) to PV - if (std::abs(cpaFromKF(KFHt, kfpv)) <= kfparticleConfigurations.minCosPA) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxCosPA); + // get MC daughter particles + auto mcTrackProton = trackProton.template mcParticle_as(); + auto mcTrackPion = trackPion.template mcParticle_as(); + auto mcTrackDeuteron = trackDeuteron.template mcParticle_as(); + + // set daughter MC info (also for non-matched candidates) + this3BodyMCInfo.daughterPrPdgCode = mcTrackProton.pdgCode(); + this3BodyMCInfo.daughterPiPdgCode = mcTrackPion.pdgCode(); + this3BodyMCInfo.daughterDePdgCode = mcTrackDeuteron.pdgCode(); + this3BodyMCInfo.isDeuteronPrimary = mcTrackDeuteron.isPhysicalPrimary(); + this3BodyMCInfo.genMomProton = mcTrackProton.p(); + this3BodyMCInfo.genMomPion = mcTrackPion.p(); + this3BodyMCInfo.genMomDeuteron = mcTrackDeuteron.p(); + this3BodyMCInfo.genPtProton = mcTrackProton.pt(); + this3BodyMCInfo.genPtPion = mcTrackPion.pt(); + this3BodyMCInfo.genPtDeuteron = mcTrackDeuteron.pt(); + + // check if reco mother is true H3L/Anti-H3l + bool isMuonReco; + int motherID = checkH3LTruth(mcTrackProton, mcTrackPion, mcTrackDeuteron, isMuonReco); + + // get generated mother MC info + if (motherID > 0) { + auto mcTrackH3L = mcParticles.rawIteratorAt(motherID); + this3BodyMCInfo.motherPdgCode = mcTrackH3L.pdgCode(); + this3BodyMCInfo.label = motherID; + this3BodyMCInfo.genMomentum = {mcTrackH3L.px(), mcTrackH3L.py(), mcTrackH3L.pz()}; + this3BodyMCInfo.genDecVtx = {mcTrackProton.vx(), mcTrackProton.vy(), mcTrackProton.vz()}; + this3BodyMCInfo.genCt = RecoDecay::sqrtSumOfSquares(mcTrackProton.vx() - mcTrackH3L.vx(), mcTrackProton.vy() - mcTrackH3L.vy(), mcTrackProton.vz() - mcTrackH3L.vz()) * o2::constants::physics::MassHyperTriton / mcTrackH3L.p(); + this3BodyMCInfo.genPhi = mcTrackH3L.phi(); + this3BodyMCInfo.genEta = mcTrackH3L.eta(); + this3BodyMCInfo.genRapidity = mcTrackH3L.y(); + this3BodyMCInfo.isTrueH3L = this3BodyMCInfo.motherPdgCode > 0 ? true : false; + this3BodyMCInfo.isTrueAntiH3L = this3BodyMCInfo.motherPdgCode < 0 ? true : false; + } - // cos(PA) xy to PV - if (std::abs(cpaXYFromKF(KFHt, kfpv)) <= kfparticleConfigurations.minCosPAxy) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxCosPAXY); + // fill analysis tables (only McVtx3BodyDatas is filled here) + fillAnalysisTables(); - // chi2 geometrical - float chi2geoNDF = KFHt.GetChi2() / KFHt.GetNDF(); - if (chi2geoNDF >= kfparticleConfigurations.maxChi2geo) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxChi2geo); - LOG(debug) << "Basic selections after vertex fit done."; + // mark mcParticle as reconstructed + if (this3BodyMCInfo.label > -1) { + mcParticleIsReco[this3BodyMCInfo.label] = true; + } + } // constexpr requires mcParticles check + } // decay3body loop + + // ____________________________________________________________________ + // MC handling part: generated information of non-reco candidates + // ____________________________________________________________________ + if constexpr (soa::is_table) { + for (const auto& mcparticle : mcParticles) { + // MC info + resetMCInfo(this3BodyMCInfo); + + // skip MC particle if reconstructed and already filled previously + if (mcParticleIsReco[mcparticle.globalIndex()] == true) { + continue; + } + this3BodyMCInfo.isReco = false; - // ctau before topo constraint - if (KFHt.GetLifeTime() > kfparticleConfigurations.maxctauHt) { - return; - } + // set flag if corresponding MC collision has matched reconstructed collision which passed event selection + this3BodyMCInfo.survivedEventSel = isGoodCollision[mcparticle.mcCollisionId()]; - // -------- STEP 6: topological constraint -------- - /// Set vertex constraint and topological selection - KFParticle KFHtPV = KFHt; - try { - KFHtPV.SetProductionVertex(kfpv); - } catch (std::runtime_error& e) { - LOG(error) << "Exception caught KFParticle process call: Topological constraint failed"; - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxTopoConstr); // to check if topo constraint fails - // get topological chi2 - float chi2topoNDF = KFHtPV.GetChi2() / KFHtPV.GetNDF(); - KFHtPV.TransportToDecayVertex(); - if (kfparticleConfigurations.applyTopoSel && chi2topoNDF >= kfparticleConfigurations.maxChi2topo) { - return; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxChi2topo); + // check if MC particle is hypertriton + if (std::abs(mcparticle.pdgCode()) != o2::constants::physics::Pdg::kHyperTriton) { + continue; + } - // additional selections from SVertexer for event mixing - float radius3body = sqrt(KFHt.GetX() * KFHt.GetX() + KFHt.GetY() * KFHt.GetY()); - float radiusV0 = sqrt(KFV0.GetX() * KFV0.GetX() + KFV0.GetY() * KFV0.GetY()); - float radiusTrackBachIU = sqrt(trackBach.x() * trackBach.x() + trackBach.y() * trackBach.y()); - if (isEventMixing && kfparticleConfigurations.applySVertexerCuts && (abs(radiusV0 - radius3body) > 3 || (radiusTrackBachIU - radius3body) > 50 || (radius3body - radiusTrackBachIU) > 1)) { - return; - } + // check daughter identities + bool haveProton = false, havePion = false, haveDeuteron = false; + bool haveAntiProton = false, haveAntiPion = false, haveAntiDeuteron = false; + for (const auto& mcparticleDaughter : mcparticle.template daughters_as()) { + if (mcparticleDaughter.pdgCode() == PDG_t::kProton) + haveProton = true; + if (mcparticleDaughter.pdgCode() == PDG_t::kProtonBar) + haveAntiProton = true; + if (mcparticleDaughter.pdgCode() == PDG_t::kPiPlus) + havePion = true; + if (mcparticleDaughter.pdgCode() == PDG_t::kPiMinus) + haveAntiPion = true; + if (mcparticleDaughter.pdgCode() == o2::constants::physics::Pdg::kDeuteron) + haveDeuteron = true; + if (mcparticleDaughter.pdgCode() == -o2::constants::physics::Pdg::kDeuteron) + haveAntiDeuteron = true; + } - //------------------------------------------------------------------ - // table filling - kfvtx3bodydata( - collision.globalIndex(), trackPos.globalIndex(), trackNeg.globalIndex(), trackBach.globalIndex(), decay3bodyID, - // hypertriton - massHt, - KFHt.GetX(), KFHt.GetY(), KFHt.GetZ(), - KFHt.GetErrX(), KFHt.GetErrY(), KFHt.GetErrZ(), - KFHt.GetPx(), KFHt.GetPy(), KFHt.GetPz(), KFHt.GetPt(), - KFHt.GetErrPx(), KFHt.GetErrPy(), KFHt.GetErrPz(), KFHt.GetErrPt(), - KFHt.GetQ(), - KFHt.GetDistanceFromVertex(kfpv), KFHt.GetDistanceFromVertexXY(kfpv), - cpaFromKF(KFHt, kfpv), // before topo constraint - cpaXYFromKF(KFHt, kfpv), - cpaFromKF(KFHtPV, kfpv), // after topo constraint - cpaXYFromKF(KFHtPV, kfpv), - KFHtPV.GetDecayLength(), KFHtPV.GetDecayLengthXY(), // decay length defined after topological constraint - KFHtPV.GetDecayLength() / KFHtPV.GetErrDecayLength(), // ldl - chi2geoNDF, chi2topoNDF, - KFHtPV.GetLifeTime(), - // V0 - massV0, chi2massV0, - cpaFromKF(KFV0, kfpv), - // daughter momenta at vertex - kfpProton.GetPx(), kfpProton.GetPy(), kfpProton.GetPz(), - kfpPion.GetPx(), kfpPion.GetPy(), kfpPion.GetPz(), - kfpDeuteron.GetPx(), kfpDeuteron.GetPy(), kfpDeuteron.GetPz(), - // daughter momenta at inner wall of TPC - tpcInnerParamProton, tpcInnerParamPion, tpcInnerParamDeuteron, - // daughter DCAs KF - kfpProton.GetDistanceFromVertex(kfpv), - kfpPion.GetDistanceFromVertex(kfpv), - kfpDeuteron.GetDistanceFromVertex(kfpv), - kfpProton.GetDistanceFromVertexXY(kfpv), - kfpPion.GetDistanceFromVertexXY(kfpv), - kfpDeuteron.GetDistanceFromVertexXY(kfpv), - kfpProton.GetDistanceFromVertexXY(KFHt), - kfpPion.GetDistanceFromVertexXY(KFHt), - kfpDeuteron.GetDistanceFromVertexXY(KFHt), - kfpProton.GetDistanceFromParticle(kfpPion), - kfpProton.GetDistanceFromParticle(kfpDeuteron), - kfpPion.GetDistanceFromParticle(kfpDeuteron), - DCAvtxDaughters3D, - // daughter DCAs to PV in XY propagated with material - TrackPosDcaXY, TrackNegDcaXY, TrackBachDcaXY, - // daughter DCAs to PV in 3D propagated with material - TrackPosDca, TrackNegDca, TrackBachDca, - // daughter signs - kfpProton.GetQ(), - kfpPion.GetQ(), - trackBach.sign(), - // daughter PID - tpcNsigmaProton, tpcNsigmaPion, tpcNsigmaDeuteron, tpcNsigmaPionBach, - dEdxProton, dEdxPion, dEdxDeuteron, - tofNSigmaDeuteron, - averageClusterSizeDeuteron, - trackBach.pidForTracking()); - - if (kfparticleConfigurations.fillCandidateLiteTable) { - kfvtx3bodydatalite( - // hypertriton - massHt, - KFHt.GetX(), KFHt.GetY(), KFHt.GetZ(), - KFHt.GetPx(), KFHt.GetPy(), KFHt.GetPz(), KFHt.GetPt(), - KFHt.GetQ(), - KFHt.GetDistanceFromVertex(kfpv), KFHt.GetDistanceFromVertexXY(kfpv), - cpaFromKF(KFHt, kfpv), // before topo constraint - cpaXYFromKF(KFHt, kfpv), - KFHtPV.GetDecayLength(), KFHtPV.GetDecayLengthXY(), // decay length defined after topological constraint - KFHtPV.GetDecayLength() / KFHtPV.GetErrDecayLength(), // ldl - chi2geoNDF, chi2topoNDF, - KFHtPV.GetLifeTime(), - // V0 - massV0, chi2massV0, - cpaFromKF(KFV0, kfpv), - // daughter momenta at vertex - kfpProton.GetPx(), kfpProton.GetPy(), kfpProton.GetPz(), - kfpPion.GetPx(), kfpPion.GetPy(), kfpPion.GetPz(), - kfpDeuteron.GetPx(), kfpDeuteron.GetPy(), kfpDeuteron.GetPz(), - // daughter momenta at inner wall of TPC - tpcInnerParamProton, tpcInnerParamPion, tpcInnerParamDeuteron, - // daughter DCAs KF - kfpProton.GetDistanceFromVertex(kfpv), - kfpPion.GetDistanceFromVertex(kfpv), - kfpDeuteron.GetDistanceFromVertex(kfpv), - kfpProton.GetDistanceFromVertexXY(kfpv), - kfpPion.GetDistanceFromVertexXY(kfpv), - kfpDeuteron.GetDistanceFromVertexXY(kfpv), - kfpProton.GetDistanceFromVertexXY(KFHt), - kfpPion.GetDistanceFromVertexXY(KFHt), - kfpDeuteron.GetDistanceFromVertexXY(KFHt), - kfpProton.GetDistanceFromParticle(kfpPion), - kfpProton.GetDistanceFromParticle(kfpDeuteron), - kfpPion.GetDistanceFromParticle(kfpDeuteron), - DCAvtxDaughters3D, - // daughter signs - kfpProton.GetQ(), - kfpPion.GetQ(), - trackBach.sign(), - // daughter PID - tpcNsigmaProton, tpcNsigmaPion, tpcNsigmaDeuteron, tpcNsigmaPionBach, - dEdxProton, dEdxPion, dEdxDeuteron, - tofNSigmaDeuteron, - averageClusterSizeDeuteron, - trackBach.pidForTracking()); - } - LOG(debug) << "Table filled."; + // check if hypertriton decayed via 3-body decay and is particle or anti-particle + if ((haveProton && haveAntiPion && haveDeuteron && !(haveAntiProton || havePion || haveAntiDeuteron)) || (haveAntiProton && havePion && haveAntiDeuteron && !(haveProton || haveAntiPion || haveDeuteron))) { + if (mcparticle.pdgCode() > 0) { + this3BodyMCInfo.isTrueH3L = true; + } else if (mcparticle.pdgCode() < 0) { + this3BodyMCInfo.isTrueAntiH3L = true; + } + // get daughters + for (const auto& mcparticleDaughter : mcparticle.template daughters_as()) { + if (std::abs(mcparticleDaughter.pdgCode()) == PDG_t::kProton) { // proton + this3BodyMCInfo.genMomProton = mcparticleDaughter.p(); + this3BodyMCInfo.genPtProton = mcparticleDaughter.pt(); + this3BodyMCInfo.daughterPrPdgCode = mcparticleDaughter.pdgCode(); + this3BodyMCInfo.genDecVtx = {mcparticleDaughter.vx(), mcparticleDaughter.vy(), mcparticleDaughter.vz()}; + } else if (std::abs(mcparticleDaughter.pdgCode()) == PDG_t::kPiPlus) { // pion + this3BodyMCInfo.genMomPion = mcparticleDaughter.p(); + this3BodyMCInfo.genPtPion = mcparticleDaughter.pt(); + this3BodyMCInfo.daughterPiPdgCode = mcparticleDaughter.pdgCode(); + } else if (std::abs(mcparticleDaughter.pdgCode()) == o2::constants::physics::Pdg::kDeuteron) { // deuteron + this3BodyMCInfo.genMomDeuteron = mcparticleDaughter.p(); + this3BodyMCInfo.genPtDeuteron = mcparticleDaughter.pt(); + this3BodyMCInfo.daughterDePdgCode = mcparticleDaughter.pdgCode(); + this3BodyMCInfo.isDeuteronPrimary = mcparticleDaughter.isPhysicalPrimary(); + } + } + } else { + continue; // stop if particle is not decayed via 3-body decay + } - // fill event counter hist (has selected candidate) - registry.fill(HIST("hEventCounterKFParticle"), 3.5); + // calculate ctau + this3BodyMCInfo.genCt = RecoDecay::sqrtSumOfSquares(this3BodyMCInfo.genDecVtx[0] - mcparticle.vx(), this3BodyMCInfo.genDecVtx[1] - mcparticle.vy(), this3BodyMCInfo.genDecVtx[2] - mcparticle.vz()) * o2::constants::physics::MassHyperTriton / mcparticle.p(); + + // fill MCDecay3BodyCores table if requested + if (mEnabledTables[kMcVtx3BodyDatas]) { + products.mcvtx3bodydatas(-1, // sign + -1., -1., // mass, massV0 + -1., -1., -1., // position + -1., -1., -1., // momentum + -1., // chi2 + -1., // trackedClSize + -1., -1., -1., // momProton + -1., -1., -1., // momPion + -1., -1., -1., // momDeuteron + -1., -1., -1., // trackDCAxyToPV: 0 - proton, 1 - pion, 2 - deuteron + -1., -1., -1., // trackDCAzToPV: 0 - proton, 1 - pion, 2 - deuteron + -1., -1., -1., // daughterDCAtoSV: 0 - proton, 1 - pion, 2 - deuteron + -1., // daughterDCAtoSVaverage + -1., -1., // cosPA, ctau + -1., -1., -1., -1., // tpcNsigma: 0 - proton, 1 - pion, 2 - deuteron, 3 - bach with pion hyp + -1., // tofNsigmaDeuteron + -1., -1., -1., // average ITS cluster sizes: proton, pion, deuteron + -1., -1., -1., // TPCNCl: proton, pion, deuteron + -1., // pidForTrackingDeuteron + // MC information + mcparticle.px(), mcparticle.py(), mcparticle.pz(), + this3BodyMCInfo.genDecVtx[0], this3BodyMCInfo.genDecVtx[1], this3BodyMCInfo.genDecVtx[2], + this3BodyMCInfo.genCt, + mcparticle.phi(), mcparticle.eta(), mcparticle.y(), + this3BodyMCInfo.genMomProton, this3BodyMCInfo.genMomPion, this3BodyMCInfo.genMomDeuteron, + this3BodyMCInfo.genPtProton, this3BodyMCInfo.genPtPion, this3BodyMCInfo.genPtDeuteron, + this3BodyMCInfo.isTrueH3L, this3BodyMCInfo.isTrueAntiH3L, + this3BodyMCInfo.isReco, + mcparticle.pdgCode(), + this3BodyMCInfo.daughterPrPdgCode, this3BodyMCInfo.daughterPiPdgCode, this3BodyMCInfo.daughterDePdgCode, + this3BodyMCInfo.isDeuteronPrimary, + this3BodyMCInfo.survivedEventSel); + } // enabled table check + } // mcParticles loop + } // constexpr requires mcParticles check } - //------------------------------------------------------------------ - void processRun3(ColwithEvTimes const& collisions, TrackExtPIDIUwithEvTimes const& /*tracksIU*/, aod::Decay3Bodys const& decay3bodys, aod::BCsWithTimestamps const&) + // ______________________________________________________________ + // function to build mixed decay3body candidates + template + void buildMixedCandidates(TRedDecay3Bodys const& decay3bodys, TBinningType const& binningType) { - vtxCandidates.clear(); - - for (const auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - registry.fill(HIST("hEventCounter"), 0.5); - - const auto& d3bodysInCollision = decay3bodys.sliceBy(perCollision, collision.globalIndex()); - for (auto& d3body : d3bodysInCollision) { - auto t0 = d3body.template track0_as(); - auto t1 = d3body.template track1_as(); - auto t2 = d3body.template track2_as(); - fillVtxCand(collision, t0, t1, t2, d3body.globalIndex(), bachelorcharge); + if (!mEnabledTables[kVtx3BodyDatas]) { + return; // don't do if no request for decay3bodys in place + } + + // Strictly upper index policy for decay3body objects binned by radius, phi + for (const auto& [decay3body0, decay3body1] : selfPairCombinations(binningType, mixingOpts.n3bodyMixing, -1, decay3bodys)) { + auto trackPos0 = decay3body0.template track0_as(); + auto trackNeg0 = decay3body0.template track1_as(); + auto trackDeuteron0 = decay3body0.template track2_as(); + auto trackPos1 = decay3body1.template track0_as(); + auto trackNeg1 = decay3body1.template track1_as(); + auto trackDeuteron1 = decay3body1.template track2_as(); + + // assign tracks + auto trackProton0 = trackPos0; + auto trackPion0 = trackNeg0; + auto trackProton1 = trackPos1; + auto trackPion1 = trackNeg1; + if (trackDeuteron0.sign() < 0) { + trackProton0 = trackNeg0; + trackPion0 = trackPos0; + } + if (trackDeuteron1.sign() < 0) { + trackProton1 = trackNeg1; + trackPion1 = trackPos1; } - } - for (auto& candVtx : vtxCandidates) { - fillVtx3BodyTable(candVtx); - } - } - PROCESS_SWITCH(decay3bodyBuilder, processRun3, "Produce DCA fitter decay3body tables", true); + registry.fill(HIST("Mixing/h3bodyCombinationCounter"), 0.5); - //------------------------------------------------------------------ - // Event-mixing background - void processRun3EM(FullCols const& collisions, TrackExtPIDIUwithEvTimes const& tracksIU, aod::BCsWithTimestamps const&) - { - - vtxCandidates.clear(); - - auto tracksTuple = std::make_tuple(tracksIU); - BinningType binningEvent{{axisPosZ, axisCentrality}, true}; - SameKindPair pair{binningEvent, EMTrackSel.nUseMixedEvent, -1, collisions, tracksTuple, &cache}; - - Partition candProtons = aod::track::signed1Pt > 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minProtonPt && aod::track::pt <= EMTrackSel.maxProtonPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClsproton && nabs(aod::pidtpc::tpcNSigmaPr) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candAntiProtons = aod::track::signed1Pt < 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minProtonPt && aod::track::pt <= EMTrackSel.maxProtonPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClsproton && nabs(aod::pidtpc::tpcNSigmaPr) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candPionPlus = aod::track::signed1Pt > 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minPionPt && aod::track::pt <= EMTrackSel.maxPionPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClspion && nabs(aod::pidtpc::tpcNSigmaPi) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candPionMinus = aod::track::signed1Pt < 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minPionPt && aod::track::pt <= EMTrackSel.maxPionPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClspion && nabs(aod::pidtpc::tpcNSigmaPi) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candBachelors = aod::track::signed1Pt > 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minDeuteronPt && aod::track::pt <= EMTrackSel.maxDeuteronPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClsbachelor && nabs(aod::pidtpc::tpcNSigmaDe) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candAntiBachelors = aod::track::signed1Pt < 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minDeuteronPt && aod::track::pt <= EMTrackSel.maxDeuteronPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClsbachelor && nabs(aod::pidtpc::tpcNSigmaDe) <= EMTrackSel.emTpcPidNsigmaCut; - candProtons.bindTable(tracksIU); - candPionPlus.bindTable(tracksIU); - candAntiProtons.bindTable(tracksIU); - candPionMinus.bindTable(tracksIU); - candBachelors.bindTable(tracksIU); - candAntiBachelors.bindTable(tracksIU); - - for (auto& [c1, tracks1, c2, tracks2] : pair) { - if (EMTrackSel.em_event_sel8_selection && (!c1.sel8() || !c2.sel8())) { + // only combine if from different event + if (decay3body0.collisionId() == decay3body1.collisionId()) { continue; } - auto bc = c1.bc_as(); - initCCDB(bc); - auto protons = candProtons->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto pionsplus = candPionPlus->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto antiprotons = candAntiProtons->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto pionsminus = candPionMinus->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto bachelors = candBachelors->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); - auto antibachelors = candAntiBachelors->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); - - for (auto const& [tpos, tneg, tbach] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(protons, pionsminus, bachelors))) { - fillVtxCand(c1, tpos, tneg, tbach, -1, bachelorcharge); - } - for (auto const& [tpos, tneg, tbach] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(pionsplus, antiprotons, antibachelors))) { - fillVtxCand(c1, tpos, tneg, tbach, -1, bachelorcharge); - } - } + registry.fill(HIST("Mixing/h3bodyCombinationCounter"), 1.5); - // Aviod break of preslice in following workflow - std::sort(vtxCandidates.begin(), vtxCandidates.end(), [](const vtxCandidate a, const vtxCandidate b) { - return a.collisionId < b.collisionId; - }); + // collision vertex selection + auto collision0 = decay3body0.template collision_as(); + auto collision1 = decay3body1.template collision_as(); - for (auto& candVtx : vtxCandidates) { - fillVtx3BodyTable(candVtx); - } - } - PROCESS_SWITCH(decay3bodyBuilder, processRun3EM, "Produce event-mix background", false); - - //------------------------------------------------------------------ - // Event-mixing background + like-sign (to aviod deuteron with wrong collisionId) - void processRun3EMLikeSign(FullCols const& collisions, TrackExtPIDIUwithEvTimes const& tracksIU, aod::BCsWithTimestamps const&) - { + // get b_z value for each collision (from CCDB or cache) and cache it for that run number + float magFieldCol0 = getMagFieldFromRunNumber(collision0.runNumber()); + float magFieldCol1 = getMagFieldFromRunNumber(collision1.runNumber()); - vtxCandidates.clear(); - - auto tracksTuple = std::make_tuple(tracksIU); - BinningType binningEvent{{axisPosZ, axisCentrality}, true}; - SameKindPair pair{binningEvent, 5, -1, collisions, tracksTuple, &cache}; - - Partition candProtons = aod::track::signed1Pt > 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minProtonPt && aod::track::pt <= EMTrackSel.maxProtonPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClsproton && nabs(aod::pidtpc::tpcNSigmaPr) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candPionPlus = aod::track::signed1Pt > 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minPionPt && aod::track::pt <= EMTrackSel.maxPionPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClspion && nabs(aod::pidtpc::tpcNSigmaPi) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candAntiProtons = aod::track::signed1Pt < 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minProtonPt && aod::track::pt <= EMTrackSel.maxProtonPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClsproton && nabs(aod::pidtpc::tpcNSigmaPr) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candPionMinus = aod::track::signed1Pt < 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minPionPt && aod::track::pt <= EMTrackSel.maxPionPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClspion && nabs(aod::pidtpc::tpcNSigmaPi) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candBachelors = aod::track::signed1Pt > 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minDeuteronPt && aod::track::pt <= EMTrackSel.maxDeuteronPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClsbachelor && nabs(aod::pidtpc::tpcNSigmaDe) <= EMTrackSel.emTpcPidNsigmaCut; - Partition candAntiBachelors = aod::track::signed1Pt < 0.f && nabs(aod::track::eta) <= EMTrackSel.etacut && aod::track::pt >= EMTrackSel.minDeuteronPt && aod::track::pt <= EMTrackSel.maxDeuteronPt && aod::track::tpcNClsFindable >= (uint8_t)EMTrackSel.mintpcNClsbachelor && nabs(aod::pidtpc::tpcNSigmaDe) <= EMTrackSel.emTpcPidNsigmaCut; - candProtons.bindTable(tracksIU); - candPionPlus.bindTable(tracksIU); - candAntiProtons.bindTable(tracksIU); - candPionMinus.bindTable(tracksIU); - candBachelors.bindTable(tracksIU); - candAntiBachelors.bindTable(tracksIU); - - for (auto& [c1, tracks1, c2, tracks2] : pair) { - if (EMTrackSel.em_event_sel8_selection && (!c1.sel8() || !c2.sel8())) { + // only combine if collision similar in VtxZ + if (mixingOpts.selectPVPosZ3bodyMixing && std::abs(collision0.posZ() - collision1.posZ()) > mixingOpts.maxDeltaPVPosZ3bodyMixing) { continue; } - auto bc = c1.bc_as(); - initCCDB(bc); - auto protons = candProtons->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto pionsplus = candPionPlus->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto antiprotons = candAntiProtons->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto pionsminus = candPionMinus->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto bachelors = candBachelors->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); - auto antibachelors = candAntiBachelors->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); - - for (auto const& [tpos, tneg, tbach] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(protons, pionsminus, antibachelors))) { - fillVtxCand(c1, tpos, tneg, tbach, -1, bachelorcharge); + registry.fill(HIST("Mixing/h3bodyCombinationCounter"), 2.5); + + // Charge selections + // same magnetic fields --> mix matter with matter + if ((magFieldCol0 / std::abs(magFieldCol0)) == (magFieldCol1 / std::abs(magFieldCol1))) { + if (trackDeuteron0.sign() != trackDeuteron1.sign()) { + continue; + } } - for (auto const& [tpos, tneg, tbach] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(pionsplus, antiprotons, bachelors))) { - fillVtxCand(c1, tpos, tneg, tbach, -1, bachelorcharge); + // opposite magnetic fields --> mix matter with anti-matter + if ((magFieldCol0 / std::abs(magFieldCol0)) != (magFieldCol1 / std::abs(magFieldCol1))) { + if (trackDeuteron0.sign() == trackDeuteron1.sign()) { + continue; + } } - } - // Aviod break of preslice in following workflow - std::sort(vtxCandidates.begin(), vtxCandidates.end(), [](const vtxCandidate a, const vtxCandidate b) { - return a.collisionId < b.collisionId; - }); - - for (auto& candVtx : vtxCandidates) { - fillVtx3BodyTable(candVtx); - } - } - PROCESS_SWITCH(decay3bodyBuilder, processRun3EMLikeSign, "Produce event-mix background with like-sign method", false); - //------------------------------------------------------------------ - - void processRun3withKFParticle(ColwithEvTimes const& collisions, TrackExtPIDIUwithEvTimes const&, aod::Decay3Bodys const& decay3bodys, aod::BCsWithTimestamps const&) - { - for (const auto& collision : collisions) { - // event selection - registry.fill(HIST("hEventCounterKFParticle"), 0.5); - if (kfparticleConfigurations.doSel8selection && !collision.sel8()) { - continue; - } - registry.fill(HIST("hEventCounterKFParticle"), 1.5); - if (kfparticleConfigurations.doPosZselection && abs(collision.posZ()) > 10.f) { + // don't mix 3body with itself + if ((trackDeuteron0.globalIndex() == trackDeuteron1.globalIndex()) || (trackProton0.globalIndex() == trackProton1.globalIndex()) || (trackPion0.globalIndex() == trackPion1.globalIndex())) { continue; } - registry.fill(HIST("hEventCounterKFParticle"), 2.5); - - auto bc = collision.bc_as(); - initCCDB(bc); - LOG(debug) << "CCDB initialised."; - - // slice Decay3Body table by collision - const uint64_t collIdx = collision.globalIndex(); - // LOG(debug) << "Collision index: " << collIdx; - auto Decay3BodyTable_thisCollision = decay3bodys.sliceBy(perCollision, collIdx); - // LOG(debug) << "Decay3Body tables sliced per collision. Calling buildVtx3BodyDataTableKFParticle function..."; - for (auto& vtx3body : Decay3BodyTable_thisCollision) { - auto trackPos = vtx3body.template track0_as(); - auto trackNeg = vtx3body.template track1_as(); - auto trackBach = vtx3body.template track2_as(); - buildVtx3BodyDataTableKFParticle(collision, trackPos, trackNeg, trackBach, vtx3body.globalIndex(), bachelorcharge); - } - LOG(debug) << "End of processKFParticle."; - } - } - PROCESS_SWITCH(decay3bodyBuilder, processRun3withKFParticle, "Produce KFParticle decay3body tables", false); - - void processRun3EMwithKFParticle(ColwithEvTimesMults const& collisions, TrackExtPIDIUwithEvTimes const& tracksIU, aod::Decay3Bodys const& decay3bodys, aod::BCsWithTimestamps const&) - { - auto tuple = std::make_tuple(decay3bodys, tracksIU); - Pair pair{binningOnPosAndMult, kfparticleConfigurations.nEvtMixing, -1, collisions, tuple, &cache}; // indicates that under/overflow (-1) to be ignored + registry.fill(HIST("Mixing/h3bodyCombinationCounter"), 3.5); - for (auto& [c1, decays3body, c2, tracks] : pair) { - registry.fill(HIST("QA/EM/hPairCounterMixing"), 0.5); - // event selection - if (kfparticleConfigurations.doSel8selection && (!c1.sel8() || !c2.sel8())) { - continue; + // candidate analysis + // mix deuteron + if (mixingOpts.mixingType == 0) { + doMixing(collision0, trackProton0, trackPion0, trackDeuteron1, magFieldCol0); + doMixing(collision1, trackProton1, trackPion1, trackDeuteron0, magFieldCol1); } - registry.fill(HIST("QA/EM/hPairCounterMixing"), 1.5); - if (kfparticleConfigurations.doPosZselection && (abs(c1.posZ()) > 10.f || abs(c2.posZ()) > 10.f)) { - continue; + // mix proton + if (mixingOpts.mixingType == 1) { + doMixing(collision0, trackProton1, trackPion0, trackDeuteron0, magFieldCol0); + doMixing(collision1, trackProton0, trackPion1, trackDeuteron1, magFieldCol1); } - registry.fill(HIST("QA/EM/hPairCounterMixing"), 2.5); - auto bc = c1.bc_as(); - initCCDB(bc); - LOG(debug) << "CCDB initialised."; - - for (auto& [decay3body, track] : soa::combinations(soa::CombinationsFullIndexPolicy(decays3body, tracks))) { - auto trackPos = decay3body.template track0_as(); - auto trackNeg = decay3body.template track1_as(); - auto trackBach = decay3body.template track2_as(); - - registry.fill(HIST("QA/EM/hCombinationCounterMixing"), 0.5); - - // selections bachelor track - if ((trackBach.sign() > 0 && !(track.sign() > 0)) || (trackBach.sign() < 0 && !(track.sign() < 0)) || trackBach.globalIndex() == track.globalIndex()) { // only combine if track has correct sign and is not same as trackBach - continue; - } - registry.fill(HIST("QA/EM/hCombinationCounterMixing"), 1.5); - if (track.pt() < 0.6) { // SVertexer selection - continue; - } - registry.fill(HIST("QA/EM/hCombinationCounterMixing"), 2.5); - buildVtx3BodyDataTableKFParticle(c1, trackPos, trackNeg, track, -1, bachelorcharge); - LOG(debug) << "buildVtx3BodyDataTableKFParticle called."; + // mix pion + if (mixingOpts.mixingType == 2) { + doMixing(collision0, trackProton0, trackPion1, trackDeuteron0, magFieldCol0); + doMixing(collision1, trackProton1, trackPion0, trackDeuteron1, magFieldCol1); } - } + } // end decay3body combinations loop } - PROCESS_SWITCH(decay3bodyBuilder, processRun3EMwithKFParticle, "Produce KFParticle decay3body mixed event tables", false); -}; - -// build link from decay3body -> vtx3body -struct decay3bodyDataLinkBuilder { - Produces vtxdataLink; - - void init(InitContext const&) {} - void process(aod::Decay3Bodys const& decay3bodytable, aod::Vtx3BodyDatas const& vtxdatatable) + // ______________________________________________________________ + // function to calculate correct TOF nSigma for deuteron track + template + double getTOFnSigma(o2::pid::tof::TOFResoParamsV3 const& parameters, TCollision const& collision, TTrack const& track) { - std::vector lIndices; - lIndices.reserve(decay3bodytable.size()); - for (int ii = 0; ii < decay3bodytable.size(); ii++) - lIndices[ii] = -1; - for (auto& vtxdata : vtxdatatable) { - if (vtxdata.decay3bodyId() != -1) { - lIndices[vtxdata.decay3bodyId()] = vtxdata.globalIndex(); + // TOF PID of deuteron + if (track.has_collision() && track.hasTOF()) { + auto originalcol = track.template collision_as(); + if constexpr (isMC) { + return bachelorTOFPIDLabeled.GetTOFNSigma(parameters, track, originalcol, collision); + } else { + return bachelorTOFPID.GetTOFNSigma(parameters, track, originalcol, collision); } } - for (int ii = 0; ii < decay3bodytable.size(); ii++) { - vtxdataLink(lIndices[ii]); - } + return -999; } -}; -struct kfdecay3bodyDataLinkBuilder { - Produces kfvtxdataLink; - - void init(InitContext const&) {} - - void processDoNotBuildLink(aod::Collisions::iterator const&) + // ______________________________________________________________ + // function to fill analysis tables + void fillAnalysisTables() { - // dummy process function + // generate analysis tables + if (mEnabledTables[kDecay3BodyIndices]) { + products.decay3bodyindices(helper.decay3body.decay3bodyID, + helper.decay3body.protonID, helper.decay3body.pionID, helper.decay3body.deuteronID, + helper.decay3body.collisionID); + registry.fill(HIST("Counters/hTableBuildingStatistics"), kDecay3BodyIndices); + } + if (mEnabledTables[kVtx3BodyDatas]) { + products.vtx3bodydatas(helper.decay3body.sign, + helper.decay3body.mass, helper.decay3body.massV0, + helper.decay3body.position[0], helper.decay3body.position[1], helper.decay3body.position[2], + helper.decay3body.momentum[0], helper.decay3body.momentum[1], helper.decay3body.momentum[2], + helper.decay3body.chi2, + helper.decay3body.trackedClSize, + helper.decay3body.momProton[0], helper.decay3body.momProton[1], helper.decay3body.momProton[2], + helper.decay3body.momPion[0], helper.decay3body.momPion[1], helper.decay3body.momPion[2], + helper.decay3body.momDeuteron[0], helper.decay3body.momDeuteron[1], helper.decay3body.momDeuteron[2], + helper.decay3body.trackDCAxyToPV[0], helper.decay3body.trackDCAxyToPV[1], helper.decay3body.trackDCAxyToPV[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.trackDCAzToPV[0], helper.decay3body.trackDCAzToPV[1], helper.decay3body.trackDCAzToPV[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.daughterDCAtoSV[0], helper.decay3body.daughterDCAtoSV[1], helper.decay3body.daughterDCAtoSV[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.daughterDCAtoSVaverage, + helper.decay3body.cosPA, helper.decay3body.ctau, + helper.decay3body.tpcNsigma[0], helper.decay3body.tpcNsigma[1], helper.decay3body.tpcNsigma[2], helper.decay3body.tpcNsigma[2], // 0 - proton, 1 - pion, 2 - deuteron, 3 - bach with pion hyp + helper.decay3body.tofNsigmaDeuteron, + helper.decay3body.averageITSClSize[0], helper.decay3body.averageITSClSize[1], helper.decay3body.averageITSClSize[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.tpcNCl[0], helper.decay3body.tpcNCl[1], helper.decay3body.tpcNCl[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.pidForTrackingDeuteron); + registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyDatas); + } + if (mEnabledTables[kVtx3BodyCovs]) { + products.vtx3bodycovs(helper.decay3body.covProton, + helper.decay3body.covPion, + helper.decay3body.covDeuteron, + helper.decay3body.covariance); + registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyCovs); + } + if (mEnabledTables[kMcVtx3BodyDatas]) { + products.mcvtx3bodydatas(helper.decay3body.sign, + helper.decay3body.mass, helper.decay3body.massV0, + helper.decay3body.position[0], helper.decay3body.position[1], helper.decay3body.position[2], + helper.decay3body.momentum[0], helper.decay3body.momentum[1], helper.decay3body.momentum[2], + helper.decay3body.chi2, + helper.decay3body.trackedClSize, + helper.decay3body.momProton[0], helper.decay3body.momProton[1], helper.decay3body.momProton[2], + helper.decay3body.momPion[0], helper.decay3body.momPion[1], helper.decay3body.momPion[2], + helper.decay3body.momDeuteron[0], helper.decay3body.momDeuteron[1], helper.decay3body.momDeuteron[2], + helper.decay3body.trackDCAxyToPV[0], helper.decay3body.trackDCAxyToPV[1], helper.decay3body.trackDCAxyToPV[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.trackDCAzToPV[0], helper.decay3body.trackDCAzToPV[1], helper.decay3body.trackDCAzToPV[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.daughterDCAtoSV[0], helper.decay3body.daughterDCAtoSV[1], helper.decay3body.daughterDCAtoSV[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.daughterDCAtoSVaverage, + helper.decay3body.cosPA, helper.decay3body.ctau, + helper.decay3body.tpcNsigma[0], helper.decay3body.tpcNsigma[1], helper.decay3body.tpcNsigma[2], helper.decay3body.tpcNsigma[2], // 0 - proton, 1 - pion, 2 - deuteron, 3 - bach with pion hyp + helper.decay3body.tofNsigmaDeuteron, + helper.decay3body.averageITSClSize[0], helper.decay3body.averageITSClSize[1], helper.decay3body.averageITSClSize[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.tpcNCl[0], helper.decay3body.tpcNCl[1], helper.decay3body.tpcNCl[2], // 0 - proton, 1 - pion, 2 - deuteron + helper.decay3body.pidForTrackingDeuteron, + // MC information + this3BodyMCInfo.genMomentum[0], this3BodyMCInfo.genMomentum[1], this3BodyMCInfo.genMomentum[2], + this3BodyMCInfo.genDecVtx[0], this3BodyMCInfo.genDecVtx[1], this3BodyMCInfo.genDecVtx[2], + this3BodyMCInfo.genCt, + this3BodyMCInfo.genPhi, this3BodyMCInfo.genEta, this3BodyMCInfo.genRapidity, + this3BodyMCInfo.genMomProton, this3BodyMCInfo.genMomPion, this3BodyMCInfo.genMomDeuteron, + this3BodyMCInfo.genPtProton, this3BodyMCInfo.genPtPion, this3BodyMCInfo.genPtDeuteron, + this3BodyMCInfo.isTrueH3L, this3BodyMCInfo.isTrueAntiH3L, + this3BodyMCInfo.isReco, + this3BodyMCInfo.motherPdgCode, + this3BodyMCInfo.daughterPrPdgCode, this3BodyMCInfo.daughterPiPdgCode, this3BodyMCInfo.daughterDePdgCode, + this3BodyMCInfo.isDeuteronPrimary, + this3BodyMCInfo.survivedEventSel); + registry.fill(HIST("Counters/hTableBuildingStatistics"), kMcVtx3BodyDatas); + } } - PROCESS_SWITCH(kfdecay3bodyDataLinkBuilder, processDoNotBuildLink, "Do not build data link table.", false); - // build Decay3Body -> KFDecay3BodyData link table - void processBuildLink(aod::Decay3Bodys const& decay3bodytable, aod::KFVtx3BodyDatas const& vtxdatatable) + // ______________________________________________________________ + // function to build mixed 3body candidate from selected tracks + template + void doMixing(TCollision const& collision, TTrack const& trackProton, TTrack const& trackPion, TTrack const& trackDeuteron, float magField) { - std::vector lIndices; - lIndices.reserve(decay3bodytable.size()); - for (int ii = 0; ii < decay3bodytable.size(); ii++) - lIndices[ii] = -1; - for (auto& vtxdata : vtxdatatable) { - lIndices[vtxdata.decay3bodyId()] = vtxdata.globalIndex(); - } - for (int ii = 0; ii < decay3bodytable.size(); ii++) { - kfvtxdataLink(lIndices[ii]); + // set vertexers and propagator with correct mag field of this collision (only if run number changed compared to previous candidate build) + initFittersWithMagField(collision.runNumber(), magField); + if (helper.buildDecay3BodyCandidate(collision, trackProton, trackPion, trackDeuteron, + -1 /*decay3bodyIndex*/, + trackDeuteron.tofNSigmaDe(), + 0 /*trackedClSize*/, + decay3bodyBuilderOpts.useKFParticle, + decay3bodyBuilderOpts.kfSetTopologicalConstraint, + decay3bodyBuilderOpts.useSelections, + decay3bodyBuilderOpts.useChi2Selection, + decay3bodyBuilderOpts.useTPCforPion, + decay3bodyBuilderOpts.acceptTPCOnly, + decay3bodyBuilderOpts.askOnlyITSMatch, + decay3bodyBuilderOpts.calculateCovariance, + true /*isEventMixing*/)) { + // fill analysis tables with built candidate + fillAnalysisTables(); + return; + } else { + return; } } - PROCESS_SWITCH(kfdecay3bodyDataLinkBuilder, processBuildLink, "Build data link table.", true); -}; - -struct decay3bodyLabelBuilder { - - Produces vtxlabels; - Produces vtxfulllabels; - Produces kfvtxlabels; - Produces kfvtxfulllabels; - - HistogramRegistry registry{"registry", {}}; - void init(InitContext const&) + // ______________________________________________________________ + // function to check if a reconstructed mother is a true H3L/Anti-H3L (returns -1 if not) + template + int checkH3LTruth(MCTrack3B const& mcParticlePr, MCTrack3B const& mcParticlePi, MCTrack3B const& mcParticleDe, bool& isMuonReco) { - if (doprocessDoNotBuildLabels == false) { - auto hLabelCounter = registry.add("hLabelCounter", "hLabelCounter", HistType::kTH1D, {{3, 0.0f, 3.0f}}); - hLabelCounter->GetXaxis()->SetBinLabel(1, "Total"); - hLabelCounter->GetXaxis()->SetBinLabel(2, "Have Same MotherTrack"); - hLabelCounter->GetXaxis()->SetBinLabel(3, "True H3L"); - - registry.add("hHypertritonMCPt", "hHypertritonMCPt", HistType::kTH1F, {{100, 0.0f, 10.0f}}); - registry.add("hAntiHypertritonMCPt", "hAntiHypertritonMCPt", HistType::kTH1F, {{100, 0.0f, 10.0f}}); - registry.add("hHypertritonMCMass", "hHypertritonMCMass", HistType::kTH1F, {{40, 2.95f, 3.05f, "Inv. Mass (GeV/c^{2})"}}); - registry.add("hAntiHypertritonMCMass", "hAntiHypertritonMCMass", HistType::kTH1F, {{40, 2.95f, 3.05f, "Inv. Mass (GeV/c^{2})"}}); - registry.add("hHypertritonMCLifetime", "hHypertritonMCLifetime", HistType::kTH1F, {{50, 0.0f, 50.0f, "ct(cm)"}}); - registry.add("hAntiHypertritonMCLifetime", "hAntiHypertritonMCLifetime", HistType::kTH1F, {{50, 0.0f, 50.0f, "ct(cm)"}}); + if (std::abs(mcParticlePr.pdgCode()) != PDG_t::kProton || std::abs(mcParticleDe.pdgCode()) != o2::constants::physics::Pdg::kDeuteron) { + return -1; + } + // check proton and deuteron mother + int prDeMomID = -1; + for (const auto& motherPr : mcParticlePr.template mothers_as()) { + for (const auto& motherDe : mcParticleDe.template mothers_as()) { + if (motherPr.globalIndex() == motherDe.globalIndex() && std::abs(motherPr.pdgCode()) == o2::constants::physics::Pdg::kHyperTriton) { + prDeMomID = motherPr.globalIndex(); + break; + } + } + } + if (prDeMomID == -1) { + return -1; } + if (std::abs(mcParticlePi.pdgCode()) != PDG_t::kPiPlus && std::abs(mcParticlePi.pdgCode()) != PDG_t::kMuonMinus) { + return -1; + } + // check if the pion track is a muon coming from a pi -> mu + vu decay, if yes, take the mother pi + auto mcParticlePiTmp = mcParticlePi; + if (std::abs(mcParticlePiTmp.pdgCode()) == PDG_t::kMuonMinus) { + for (const auto& motherPi : mcParticlePiTmp.template mothers_as()) { + if (std::abs(motherPi.pdgCode()) == PDG_t::kPiPlus) { + mcParticlePiTmp = motherPi; + isMuonReco = true; + break; + } + } + } + // now loop over the pion mother + for (const auto& motherPi : mcParticlePiTmp.template mothers_as()) { + if (motherPi.globalIndex() == prDeMomID) { + return motherPi.globalIndex(); + } + } + return -1; } - Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; - - void processDoNotBuildLabels(aod::Collisions::iterator const&) + // ______________________________________________________________ + // function to reset MCInfo + void resetMCInfo(mc3Bodyinfo& mcInfo) { - // dummy process function - should not be required in the future + mcInfo.label = -1; + mcInfo.genMomentum[0] = -1., mcInfo.genMomentum[1] = -1., mcInfo.genMomentum[2] = -1.; + mcInfo.genDecVtx[0] = -1., mcInfo.genDecVtx[1] = -1., mcInfo.genDecVtx[2] = -1.; + mcInfo.genCt = -1.; + mcInfo.genPhi = -1., mcInfo.genEta = -1., mcInfo.genRapidity = -1.; + mcInfo.genMomProton = -1., mcInfo.genMomPion = -1., mcInfo.genMomDeuteron = -1.; + mcInfo.genPtProton = -1., mcInfo.genPtPion = -1., mcInfo.genPtDeuteron = -1.; + mcInfo.isTrueH3L = false, mcInfo.isTrueAntiH3L = false; + mcInfo.isReco = false; + mcInfo.motherPdgCode = -1; + mcInfo.daughterPrPdgCode = -1, mcInfo.daughterPiPdgCode = -1, mcInfo.daughterDePdgCode = -1; + mcInfo.isDeuteronPrimary = false; + mcInfo.survivedEventSel = false; + return; } - PROCESS_SWITCH(decay3bodyLabelBuilder, processDoNotBuildLabels, "Do not produce MC label tables", true); - void processBuildLabels(aod::Decay3BodysLinked const& decay3bodys, aod::Vtx3BodyDatas const& vtx3bodydatas, MCLabeledTracksIU const&, aod::McParticles const&) + // ______________________________________________________________ + // process functions + void processRealData(ColswithEvTimes const& collisions, + aod::Decay3Bodys const& decay3bodys, + aod::Tracked3Bodys const& tracked3bodys, + TracksExtPIDIUwithEvTimes const&, + aod::BCsWithTimestamps const& bcs) { - std::vector lIndices; - lIndices.reserve(vtx3bodydatas.size()); - for (int ii = 0; ii < vtx3bodydatas.size(); ii++) { - lIndices[ii] = -1; + // initialise CCDB from BCs + if (!initCCDB(bcs, collisions)) { + LOG(info) << "CCDB initialisation failed, skipping candidate building." << std::endl; + return; } - for (auto& decay3body : decay3bodys) { - - int lLabel = -1; - int lPDG = -1; - float lPt = -1; - double MClifetime = -1; - bool is3bodyDecay = false; - int lGlobalIndex = -1; - - auto lTrack0 = decay3body.track0_as(); - auto lTrack1 = decay3body.track1_as(); - auto lTrack2 = decay3body.track2_as(); - registry.fill(HIST("hLabelCounter"), 0.5); + // get tracked cluster size info + fTrackedClSizeVector.clear(); + fTrackedClSizeVector.resize(decay3bodys.size(), 0); + for (const auto& tvtx3body : tracked3bodys) { + fTrackedClSizeVector[tvtx3body.decay3BodyId()] = tvtx3body.itsClsSize(); + } - // Association check - // There might be smarter ways of doing this in the future - if (!lTrack0.has_mcParticle() || !lTrack1.has_mcParticle() || !lTrack2.has_mcParticle()) { - vtxfulllabels(-1); - continue; - } - auto lMCTrack0 = lTrack0.mcParticle_as(); - auto lMCTrack1 = lTrack1.mcParticle_as(); - auto lMCTrack2 = lTrack2.mcParticle_as(); - if (!lMCTrack0.has_mothers() || !lMCTrack1.has_mothers() || !lMCTrack2.has_mothers()) { - vtxfulllabels(-1); - continue; - } + // do candidate analysis without MC processing + buildCandidates(bcs, // bc table + collisions, // collision table + decay3bodys, // decay3body table + static_cast(nullptr), // MC particle table + static_cast(nullptr)); // MC collision table + } - for (auto& lMother0 : lMCTrack0.mothers_as()) { - for (auto& lMother1 : lMCTrack1.mothers_as()) { - for (auto& lMother2 : lMCTrack2.mothers_as()) { - if (lMother0.globalIndex() == lMother1.globalIndex() && lMother0.globalIndex() == lMother2.globalIndex()) { - lGlobalIndex = lMother1.globalIndex(); - lPt = lMother1.pt(); - lPDG = lMother1.pdgCode(); - MClifetime = RecoDecay::sqrtSumOfSquares(lMCTrack2.vx() - lMother2.vx(), lMCTrack2.vy() - lMother2.vy(), lMCTrack2.vz() - lMother2.vz()) * o2::constants::physics::MassHyperTriton / lMother2.p(); // only for hypertriton - is3bodyDecay = true; // vtxs with the same mother - } - } - } - } // end association check - if (!is3bodyDecay) { - vtxfulllabels(-1); - continue; - } - registry.fill(HIST("hLabelCounter"), 1.5); - - // Intended for hypertriton cross-checks only - if (lPDG == 1010010030 && lMCTrack0.pdgCode() == 2212 && lMCTrack1.pdgCode() == -211 && lMCTrack2.pdgCode() == 1000010020) { - lLabel = lGlobalIndex; - double hypertritonMCMass = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}, array{lMCTrack2.px(), lMCTrack2.py(), lMCTrack2.pz()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); - registry.fill(HIST("hLabelCounter"), 2.5); - registry.fill(HIST("hHypertritonMCPt"), lPt); - registry.fill(HIST("hHypertritonMCLifetime"), MClifetime); - registry.fill(HIST("hHypertritonMCMass"), hypertritonMCMass); - } - if (lPDG == -1010010030 && lMCTrack0.pdgCode() == 211 && lMCTrack1.pdgCode() == -2212 && lMCTrack2.pdgCode() == -1000010020) { - lLabel = lGlobalIndex; - double antiHypertritonMCMass = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}, array{lMCTrack2.px(), lMCTrack2.py(), lMCTrack2.pz()}}, array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}); - registry.fill(HIST("hLabelCounter"), 2.5); - registry.fill(HIST("hAntiHypertritonMCPt"), lPt); - registry.fill(HIST("hAntiHypertritonMCLifetime"), MClifetime); - registry.fill(HIST("hAntiHypertritonMCMass"), antiHypertritonMCMass); - } + void processRealDataReduced(aod::RedCollisions const& collisions, + soa::Join const& decay3bodys, + aod::RedIUTracks const&) + { + // get tracked cluster size info (saved in aod::Red3BodyInfo) + fTrackedClSizeVector.clear(); + fTrackedClSizeVector.resize(decay3bodys.size(), 0); + for (const auto& vtx3body : decay3bodys) { + fTrackedClSizeVector[vtx3body.globalIndex()] = vtx3body.trackedClSize(); + } + + // do candidate analysis without MC processing + buildCandidates(static_cast(nullptr), // bc table + collisions, // collision table + decay3bodys, // decay3body table + static_cast(nullptr), // MC particle table + static_cast(nullptr)); // MC collision table + } - // Construct label table, only vtx which corresponds to true mother and true daughters with a specified order is labeled - // for matter: track0->p, track1->pi, track2->bachelor - // for antimatter: track0->pi, track1->p, track2->bachelor - vtxfulllabels(lLabel); - if (decay3body.vtx3BodyDataId() != -1) { - lIndices[decay3body.vtx3BodyDataId()] = lLabel; + void processRealDataReduced3bodyMixing(aod::RedCollisions const&, + soa::Join const& decay3bodys, + aod::RedIUTracks const&) + { + auto xAxis = registry.get(HIST("Mixing/hDecay3BodyRadiusPhi"))->GetXaxis(); + auto yAxis = registry.get(HIST("Mixing/hDecay3BodyRadiusPhi"))->GetYaxis(); + + for (const auto& decay3body : decay3bodys) { + int bin_Radius, bin_Phi; + if (decay3bodyBuilderOpts.useKFParticle) { + bin_Radius = xAxis->FindBin(decay3body.radiusKF()); + bin_Phi = yAxis->FindBin(decay3body.phiKF()); + registry.fill(HIST("Mixing/hDecay3BodyPosZ"), decay3body.poszKF()); + } else { + bin_Radius = xAxis->FindBin(decay3body.radiusDCA()); + bin_Phi = yAxis->FindBin(decay3body.phiDCA()); + registry.fill(HIST("Mixing/hDecay3BodyPosZ"), decay3body.poszDCA()); } + registry.fill(HIST("Mixing/hDecay3BodyRadiusPhi"), xAxis->GetBinCenter(bin_Radius), yAxis->GetBinCenter(bin_Phi)); } - for (int ii = 0; ii < vtx3bodydatas.size(); ii++) { - vtxlabels(lIndices[ii]); + + if (decay3bodyBuilderOpts.useKFParticle) { + Binning3BodyKF binningOnRadPhiKF{{mixingOpts.bins3BodyRadius, mixingOpts.bins3BodyPhi}, true}; + buildMixedCandidates(decay3bodys, binningOnRadPhiKF); + } else { + Binning3BodyDCAfitter binningOnRadPhiDCA{{mixingOpts.bins3BodyRadius, mixingOpts.bins3BodyPhi}, true}; + buildMixedCandidates(decay3bodys, binningOnRadPhiDCA); } } - PROCESS_SWITCH(decay3bodyLabelBuilder, processBuildLabels, "Produce MC label tables", false); - void processBuildKFLabels(aod::KFDecay3BodysLinked const& decay3bodys, aod::KFVtx3BodyDatas const& vtx3bodydatas, MCLabeledTracksIU const&, aod::McParticles const&) + void processMonteCarlo(ColswithEvTimesLabeled const& collisions, + aod::Decay3Bodys const& decay3bodys, + aod::Tracked3Bodys const& tracked3bodys, + TracksExtPIDIUwithEvTimesLabeled const&, + aod::BCsWithTimestamps const& bcs, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcCollisions) { - std::vector lIndices; - lIndices.reserve(vtx3bodydatas.size()); - for (int ii = 0; ii < vtx3bodydatas.size(); ii++) { - lIndices[ii] = -1; + // initialise CCDB from BCs + if (!initCCDB(bcs, collisions)) { + LOG(info) << "CCDB initialisation failed, skipping candidate building." << std::endl; + return; } - for (auto& decay3body : decay3bodys) { - - int lLabel = -1; - - auto lTrack0 = decay3body.track0_as(); - auto lTrack1 = decay3body.track1_as(); - auto lTrack2 = decay3body.track2_as(); - - // counter total - registry.fill(HIST("hLabelCounter"), 0.5); - - // Association check - if (lTrack0.has_mcParticle() && lTrack1.has_mcParticle() && lTrack2.has_mcParticle()) { - auto lMCTrack0 = lTrack0.mcParticle_as(); - auto lMCTrack1 = lTrack1.mcParticle_as(); - auto lMCTrack2 = lTrack2.mcParticle_as(); - // check if mother is the same - if (lMCTrack0.has_mothers() && lMCTrack1.has_mothers() && lMCTrack2.has_mothers()) { - for (auto& lMother0 : lMCTrack0.mothers_as()) { - for (auto& lMother1 : lMCTrack1.mothers_as()) { - for (auto& lMother2 : lMCTrack2.mothers_as()) { - if (lMother0.globalIndex() == lMother1.globalIndex() && lMother0.globalIndex() == lMother2.globalIndex()) { - lLabel = lMother1.globalIndex(); - // fill counter same mother - registry.fill(HIST("hLabelCounter"), 1.5); - } // end same mother conditional - } - } - } // end loop over daughters - } // end conditional of mothers existing - } // end association check - - // Construct label table, only vtx which corresponds to true mother and true daughters with a specified order is labeled - // for matter: track0->p, track1->pi, track2->bachelor - // for antimatter: track0->pi, track1->p, track2->bachelor - kfvtxfulllabels(lLabel); - if (decay3body.kfvtx3BodyDataId() != -1) { - lIndices[decay3body.kfvtx3BodyDataId()] = lLabel; - } - } - for (int ii = 0; ii < vtx3bodydatas.size(); ii++) { - kfvtxlabels(lIndices[ii]); + // get tracked cluster size info + fTrackedClSizeVector.clear(); + fTrackedClSizeVector.resize(decay3bodys.size(), 0); + for (const auto& tvtx3body : tracked3bodys) { + fTrackedClSizeVector[tvtx3body.decay3BodyId()] = tvtx3body.itsClsSize(); } + + // do candidate analysis with MC processing + buildCandidates(bcs, // bc table + collisions, // collision table + decay3bodys, // decay3body table + mcParticles, // MC particle table + mcCollisions); // MC collision table } - PROCESS_SWITCH(decay3bodyLabelBuilder, processBuildKFLabels, "Produce MC KF label tables", false); -}; -struct decay3bodyInitializer { - Spawns vtx3bodydatas; - void init(InitContext const&) {} + PROCESS_SWITCH(decay3bodyBuilder, processRealData, "process real data", true); + PROCESS_SWITCH(decay3bodyBuilder, processRealDataReduced, "process real reduced data", false); + PROCESS_SWITCH(decay3bodyBuilder, processRealDataReduced3bodyMixing, "process real reduced data", false); + PROCESS_SWITCH(decay3bodyBuilder, processMonteCarlo, "process monte carlo", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { + metadataInfo.initMetadata(cfgc); return WorkflowSpec{ - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - }; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Nuspex/ebyeMaker.cxx b/PWGLF/TableProducer/Nuspex/ebyeMaker.cxx index fdbc58ad7e9..bdb0c4a2058 100644 --- a/PWGLF/TableProducer/Nuspex/ebyeMaker.cxx +++ b/PWGLF/TableProducer/Nuspex/ebyeMaker.cxx @@ -9,65 +9,68 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include -#include -#include -#include -#include +/// \file ebyeMaker.cxx +/// \brief table producer for e-by-e analysis in LF +/// \author Mario Ciacco -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" +#include "PWGLF/DataModel/LFEbyeTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/PID/PIDTOF.h" +#include "Common/Core/PID/TPCPIDResponse.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsTPC/BetheBlochAleph.h" -#include "Common/Core/PID/PIDTOF.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" #include "Common/TableProducer/PID/pidTOFBase.h" -#include "CCDB/CcdbApi.h" -#include "Common/Core/PID/TPCPIDResponse.h" -#include "Common/DataModel/PIDResponse.h" +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" #include "DCAFitter/DCAFitterN.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" -#include "PWGLF/DataModel/LFEbyeTables.h" - -#include "TDatabasePDG.h" #include "TFormula.h" +#include +#include +#include +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using TracksFull = soa::Join; using TracksFullPID = soa::Join; -using TracksFullIU = soa::Join; +using TracksFullIUPID = soa::Join; using BCsWithRun2Info = soa::Join; namespace { constexpr int kNpart = 2; -constexpr float trackSels[12]{/* 60, */ 80, 100, 2, 3, /* 4, */ 0.05, 0.1, /* 0.15, */ 0.5, 1, /* 1.5, */ 2, 3 /* , 4 */, 2, 3, /*, 4 */}; -constexpr float dcaSels[3]{10., 10., 10.}; -constexpr double betheBlochDefault[kNpart][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}, {-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}}; -constexpr double betheBlochDefaultITS[6]{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}; -constexpr double estimatorsCorrelationCoef[2]{-0.669108, 1.04489}; -constexpr double estimatorsSigmaPars[4]{0.933321, 0.0416976, -0.000936344, 8.92179e-06}; -constexpr double deltaEstimatorNsigma[2]{5.5, 5.}; -constexpr double partMass[kNpart]{o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}; -constexpr double partPdg[kNpart]{2212, o2::constants::physics::kDeuteron}; +constexpr float kTrackSels[12]{/* 60, */ 80, 100, 2, 3, /* 4, */ 0.05, 0.1, /* 0.15, */ 0.5, 1, /* 1.5, */ 2, 3 /* , 4 */, 2, 3, /*, 4 */}; +constexpr float kDcaSels[3]{10., 10., 10.}; +constexpr double kBetheBlochDefault[kNpart][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}, {-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}}; +constexpr double kBetheBlochDefaultITS[6]{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}; +constexpr double kEstimatorsCorrelationCoef[2]{-0.669108, 1.04489}; +constexpr double kEstimatorsSigmaPars[4]{0.933321, 0.0416976, -0.000936344, 8.92179e-06}; +constexpr double kDeltaEstimatorNsigma[2]{5.5, 5.}; +constexpr double kPartMass[kNpart]{o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}; +constexpr double kPartPdg[kNpart]{PDG_t::kProton, o2::constants::physics::kDeuteron}; static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; static const std::vector particleNamesPar{"p", "d"}; static const std::vector trackSelsNames{"tpcClsMid", "tpcClsTight", "chi2TpcTight", "chi2TpcMid", "dcaxyTight", "dcaxyMid", "dcazTight", "dcazMid", "tpcNsigmaTight", "tpcNsigmaMid", "itsNsigmaTight", "itsNsigmaMid"}; @@ -76,20 +79,10 @@ static const std::vector particleName{"p"}; std::array, kNpart> tofMass; void momTotXYZ(std::array& momA, std::array const& momB, std::array const& momC) { - for (int i = 0; i < 3; ++i) { + for (uint64_t i = 0; i < momA.size(); ++i) { momA[i] = momB[i] + momC[i]; } } -float invMass2Body(std::array const& momA, std::array const& momB, std::array const& momC, float const& massB, float const& massC) -{ - float p2B = momB[0] * momB[0] + momB[1] * momB[1] + momB[2] * momB[2]; - float p2C = momC[0] * momC[0] + momC[1] * momC[1] + momC[2] * momC[2]; - float eB = std::sqrt(p2B + massB * massB); - float eC = std::sqrt(p2C + massC * massC); - float eA = eB + eC; - float massA = std::sqrt(eA * eA - momA[0] * momA[0] - momA[1] * momA[1] - momA[2] * momA[2]); - return massA; -} float alphaAP(std::array const& momA, std::array const& momB, std::array const& momC) { float momTot = std::sqrt(std::pow(momA[0], 2.) + std::pow(momA[1], 2.) + std::pow(momA[2], 2.)); @@ -97,27 +90,7 @@ float alphaAP(std::array const& momA, std::array const& momB float lQlNeg = (momC[0] * momA[0] + momC[1] * momA[1] + momC[2] * momA[2]) / momTot; return (lQlPos - lQlNeg) / (lQlPos + lQlNeg); } -float etaFromMom(std::array const& momA, std::array const& momB) -{ - if (std::sqrt((1.f * momA[0] + 1.f * momB[0]) * (1.f * momA[0] + 1.f * momB[0]) + - (1.f * momA[1] + 1.f * momB[1]) * (1.f * momA[1] + 1.f * momB[1]) + - (1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) - - (1.f * momA[2] + 1.f * momB[2]) < - static_cast(1e-7)) { - if ((1.f * momA[2] + 1.f * momB[2]) < 0.f) - return -100.f; - return 100.f; - } - return 0.5f * std::log((std::sqrt((1.f * momA[0] + 1.f * momB[0]) * (1.f * momA[0] + 1.f * momB[0]) + - (1.f * momA[1] + 1.f * momB[1]) * (1.f * momA[1] + 1.f * momB[1]) + - (1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) + - (1.f * momA[2] + 1.f * momB[2])) / - (std::sqrt((1.f * momA[0] + 1.f * momB[0]) * (1.f * momA[0] + 1.f * momB[0]) + - (1.f * momA[1] + 1.f * momB[1]) * (1.f * momA[1] + 1.f * momB[1]) + - (1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) - - (1.f * momA[2] + 1.f * momB[2]))); -} -float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) +float calculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) { return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz)); } @@ -159,12 +132,13 @@ struct CandidateTrack { float genpt = -999.f; float geneta = -999.f; int pdgcode = -999; + int pdgcodemoth = -999; bool isreco = 0; int64_t mcIndex = -999; int64_t globalIndex = -999; }; -enum selBits { +enum SelBits { kTPCclsTight = BIT(0), kTPCclsMid = BIT(1), kChi2TPCTight = BIT(2), @@ -179,22 +153,12 @@ enum selBits { kTPCPIDMid = BIT(11) }; -struct tagRun2V0MCalibration { - bool mCalibrationStored = false; - TH1* mhVtxAmpCorrV0A = nullptr; - TH1* mhVtxAmpCorrV0C = nullptr; - TH1* mhMultSelCalib = nullptr; - float mMCScalePars[6] = {0.0}; - TFormula* mMCScale = nullptr; -} Run2V0MInfo; - -struct tagRun2CL0Calibration { - bool mCalibrationStored = false; - TH1* mhVtxAmpCorr = nullptr; - TH1* mhMultSelCalib = nullptr; -} Run2CL0Info; - -struct ebyeMaker { +enum PartTypes { + kLa = BIT(20), + kPhysPrim = BIT(22) +}; + +struct EbyeMaker { Produces collisionEbyeTable; Produces miniCollTable; Produces nucleiEbyeTable; @@ -211,18 +175,18 @@ struct ebyeMaker { std::vector classIds; int mRunNumber; - float d_bz; + float dBz; uint8_t nTrackletsColl; - // o2::base::MatLayerCylSet* lut = nullptr; + uint8_t nTracksColl; + uint8_t nChPartGen; Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"}; - Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 2, 6, particleNamesPar, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for deuteron"}; - Configurable> cfgBetheBlochParamsITS{"cfgBetheBlochParamsITS", {betheBlochDefaultITS, 1, 6, particleName, betheBlochParNames}, "ITS Bethe-Bloch parameterisation for deuteron"}; + Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {kBetheBlochDefault[0], 2, 6, particleNamesPar, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for deuteron"}; + Configurable> cfgBetheBlochParamsITS{"cfgBetheBlochParamsITS", {kBetheBlochDefaultITS, 1, 6, particleName, betheBlochParNames}, "ITS Bethe-Bloch parameterisation for deuteron"}; ConfigurableAxis centAxis{"centAxis", {106, 0, 106}, "binning for the centrality"}; ConfigurableAxis zVtxAxis{"zVtxBins", {100, -20.f, 20.f}, "Binning for the vertex z in cm"}; ConfigurableAxis multAxis{"multAxis", {100, 0, 10000}, "Binning for the multiplicity axis"}; - ConfigurableAxis multFt0Axis{"multFt0Axis", {100, 0, 100000}, "Binning for the ft0 multiplicity axis"}; // binning of (anti)lambda mass QA histograms ConfigurableAxis massLambdaAxis{"massLambdaAxis", {400, o2::constants::physics::MassLambda0 - 0.03f, o2::constants::physics::MassLambda0 + 0.03f}, "binning for the lambda invariant-mass"}; @@ -237,12 +201,10 @@ struct ebyeMaker { Configurable etaMaxV0dau{"etaMaxV0dau", 0.8f, "maximum eta V0 daughters"}; Configurable outerPIDMin{"outerPIDMin", -4.f, "minimum outer PID"}; - Configurable fillOnlySignal{"fillOnlySignal", false, "fill histograms only for true signal candidates (MC)"}; - Configurable genName{"genname", "", "Genearator name: HIJING, PYTHIA8, ... Default: \"\""}; - + Configurable useAllEvSel{"useAllEvSel", false, "use additional event selections fo run 3 analyses"}; Configurable triggerCut{"triggerCut", 0x0, "trigger cut to select"}; Configurable kINT7Intervals{"kINT7Intervals", false, "toggle kINT7 trigger selection in the 10-30% and 50-90% centrality intervals (2018 Pb-Pb)"}; - Configurable kUseTPCPileUpCut{"kUseTPCPileUpCut", false, "toggle strong correlation cuts (Run 2)"}; + Configurable kUsePileUpCut{"kUsePileUpCut", false, "toggle strong correlation cuts (Run 2)"}; Configurable kUseEstimatorsCorrelationCut{"kUseEstimatorsCorrelationCut", false, "toggle cut on the correlation between centrality estimators (2018 Pb-Pb)"}; Configurable antidPtMin{"antidPtMin", 0.6f, "minimum antideuteron pT (GeV/c)"}; @@ -260,7 +222,7 @@ struct ebyeMaker { Configurable trackNclusItsCut{"trackNclusITScut", 2, "Minimum number of ITS clusters"}; Configurable trackNclusTpcCut{"trackNclusTPCcut", 60, "Minimum number of TPC clusters"}; Configurable trackChi2Cut{"trackChi2Cut", 4.f, "Maximum chi2/ncls in TPC"}; - Configurable> cfgDcaSels{"cfgDcaSels", {dcaSels, 1, 3, particleName, dcaSelsNames}, "DCA selections"}; + Configurable> cfgDcaSels{"cfgDcaSels", {kDcaSels, 1, 3, particleName, dcaSelsNames}, "DCA selections"}; Configurable v0trackNcrossedRows{"v0trackNcrossedRows", 100, "Minimum number of crossed TPC rows for V0 daughter"}; Configurable v0trackNclusItsCut{"v0trackNclusITScut", 0, "Minimum number of ITS clusters for V0 daughter"}; @@ -281,21 +243,21 @@ struct ebyeMaker { Configurable antipTofMassMax{"antipTofMassMax", 0.3f, "(temporary) tof mass cut"}; Configurable tofMassMaxQA{"tofMassMaxQA", 0.6f, "(temporary) tof mass cut (for QA histograms)"}; - Configurable v0setting_dcav0dau{"v0setting_dcav0dau", 0.5f, "DCA V0 Daughters"}; - Configurable v0setting_dcav0pv{"v0setting_dcav0pv", 1.f, "DCA V0 to Pv"}; - Configurable v0setting_dcadaughtopv{"v0setting_dcadaughtopv", 0.1f, "DCA Pos To PV"}; - Configurable v0setting_cospa{"v0setting_cospa", 0.99f, "V0 CosPA"}; - Configurable v0setting_radius{"v0setting_radius", 5.f, "v0radius"}; - Configurable v0setting_lifetime{"v0setting_lifetime", 40.f, "v0 lifetime cut"}; - Configurable v0setting_nsigmatpc{"v0setting_nsigmatpc", 4.f, "nsigmatpc"}; + Configurable v0settingDcaV0Dau{"v0setting_dcav0dau", 0.5f, "DCA V0 Daughters"}; + Configurable v0settingDcaV0Pv{"v0setting_dcav0pv", 1.f, "DCA V0 to Pv"}; + Configurable v0settingDcaDaughToPv{"v0setting_dcadaughtopv", 0.1f, "DCA Pos To PV"}; + Configurable v0settingCosPa{"v0setting_cospa", 0.99f, "V0 CosPA"}; + Configurable v0settingRadius{"v0setting_radius", 5.f, "v0radius"}; + Configurable v0settingLifetime{"v0setting_lifetime", 40.f, "v0 lifetime cut"}; + Configurable v0settingNSigmaTpc{"v0setting_nsigmatpc", 4.f, "nsigmatpc"}; Configurable lambdaMassCut{"lambdaMassCut", 0.02f, "maximum deviation from PDG mass (for QA histograms)"}; Configurable constDCASel{"constDCASel", true, "use DCA selections independent of pt"}; - Configurable antidItsClsSizeCut{"antidItsClsSizeCut", 1.e-10f, "cluster size cut for antideuterons"}; Configurable antidPtItsClsSizeCut{"antidPtItsClsSizeCut", 10.f, "pt for cluster size cut for antideuterons"}; - Configurable> cfgTrackSels{"cfgTrackSels", {trackSels, 1, 12, particleName, trackSelsNames}, "Track selections"}; + Configurable trklEtaMax{"trklEtaMax", 0.8f, "maximum eta for run 2 tracklets"}; + Configurable> cfgTrackSels{"cfgTrackSels", {kTrackSels, 1, 12, particleName, trackSelsNames}, "Track selections"}; std::array ptMin; std::array ptTof; @@ -309,20 +271,48 @@ struct ebyeMaker { Preslice perCollisionTracksFull = o2::aod::track::collisionId; Preslice perCollisionTracksFullPID = o2::aod::track::collisionId; - Preslice perCollisionTracksFullIU = o2::aod::track::collisionId; + Preslice perCollisionTracksFullIUPID = o2::aod::track::collisionId; Preslice perCollisionV0 = o2::aod::v0::collisionId; Preslice perCollisionMcParts = o2::aod::mcparticle::mcCollisionId; + template + int getPartTypeMother(P const& mcPart) + { + for (const auto& mother : mcPart.template mothers_as()) { + if (!mother.isPhysicalPrimary()) + return -1; + int pdgCode = mother.pdgCode(); + switch (std::abs(pdgCode)) { + case PDG_t::kLambda0: { + int foundPi = 0; + for (const auto& mcDaught : mother.template daughters_as()) { + if (std::abs(mcDaught.pdgCode()) == PDG_t::kPiPlus) { + foundPi = mcDaught.pdgCode(); + break; + } + } + if (foundPi * mcPart.pdgCode() < 0) + return PartTypes::kLa; + return -1; + } + default: + return -1; + } + } + return -1; + } + template bool selectV0Daughter(T const& track) { + const float defNClCROverFind = 0.8f; if (std::abs(track.eta()) > etaMaxV0dau) { return false; } if (track.itsNCls() < v0trackNclusItsCut || track.tpcNClsFound() < v0trackNclusTpcCut || track.tpcNClsCrossedRows() < v0trackNclusTpcCut || - track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || + track.tpcNClsCrossedRows() < defNClCROverFind * track.tpcNClsFindable() || track.tpcNClsShared() > v0trackNsharedClusTpc) { return false; } @@ -341,6 +331,8 @@ struct ebyeMaker { template bool selectTrack(T const& track) { + const float defItsChi2NClCut = 36.f; + const float defNClCROverFind = 0.8f; if (std::abs(track.eta()) > etaMax) { return false; } @@ -350,9 +342,9 @@ struct ebyeMaker { if (track.itsNCls() < trackNclusItsCut || track.tpcNClsFound() < trackNclusTpcCut || track.tpcNClsCrossedRows() < trackNcrossedRows || - track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || + track.tpcNClsCrossedRows() < defNClCROverFind * track.tpcNClsFindable() || track.tpcChi2NCl() > trackChi2Cut || - track.itsChi2NCl() > 36.f) { + track.itsChi2NCl() > defItsChi2NClCut) { return false; } if (doprocessRun2 || doprocessMiniRun2 || doprocessMcRun2 || doprocessMiniMcRun2) { @@ -369,7 +361,8 @@ struct ebyeMaker { float getITSClSize(T const& track) { float sum{0.f}; - for (int iL{0}; iL < 6; ++iL) { + const int nLayers = 7; + for (int iL{0}; iL < nLayers; ++iL) { sum += (track.itsClusterSizes() >> (iL * 4)) & 0xf; } return sum / track.itsNCls(); @@ -397,44 +390,6 @@ struct ebyeMaker { LOG(fatal) << "Got nullptr from CCDB for path " << grpPath << " of object GRPObject for timestamp " << timestamp; } o2::base::Propagator::initFieldFromGRP(grpo); - TList* callst = ccdb->getForTimeStamp("Centrality/Estimators", bc.timestamp()); - if (callst != nullptr) { - auto getccdb = [callst](const char* ccdbhname) { - TH1* h = reinterpret_cast(callst->FindObject(ccdbhname)); - return h; - }; - auto getformulaccdb = [callst](const char* ccdbhname) { - TFormula* f = reinterpret_cast(callst->FindObject(ccdbhname)); - return f; - }; - Run2V0MInfo.mhVtxAmpCorrV0A = getccdb("hVtx_fAmplitude_V0A_Normalized"); - Run2V0MInfo.mhVtxAmpCorrV0C = getccdb("hVtx_fAmplitude_V0C_Normalized"); - Run2V0MInfo.mhMultSelCalib = getccdb("hMultSelCalib_V0M"); - Run2V0MInfo.mMCScale = getformulaccdb(TString::Format("%s-V0M", genName->c_str()).Data()); - if ((Run2V0MInfo.mhVtxAmpCorrV0A != nullptr) && (Run2V0MInfo.mhVtxAmpCorrV0C != nullptr) && (Run2V0MInfo.mhMultSelCalib != nullptr)) { - if (genName->length() != 0) { - if (Run2V0MInfo.mMCScale != nullptr) { - for (int ixpar = 0; ixpar < 6; ++ixpar) { - Run2V0MInfo.mMCScalePars[ixpar] = Run2V0MInfo.mMCScale->GetParameter(ixpar); - } - } else { - LOGF(fatal, "MC Scale information from V0M for run %d not available", bc.runNumber()); - } - } - Run2V0MInfo.mCalibrationStored = true; - } else { - LOGF(fatal, "Calibration information from V0M for run %d corrupted", bc.runNumber()); - } - if (doprocessRun2) { - Run2CL0Info.mhVtxAmpCorr = getccdb("hVtx_fnSPDClusters0_Normalized"); - Run2CL0Info.mhMultSelCalib = getccdb("hMultSelCalib_CL0"); - if ((Run2CL0Info.mhVtxAmpCorr != nullptr) && (Run2CL0Info.mhMultSelCalib != nullptr)) { - Run2CL0Info.mCalibrationStored = true; - } else { - LOGF(fatal, "Calibration information from CL0 multiplicity for run %d corrupted", bc.runNumber()); - } - } - } } else { auto grpmagPath{"GLO/Config/GRPMagField"}; grpmag = ccdb->getForTimeStamp("GLO/Config/GRPMagField", timestamp); @@ -444,10 +399,10 @@ struct ebyeMaker { o2::base::Propagator::initFieldFromGRP(grpmag); } // Fetch magnetic field from ccdb for current collision - d_bz = o2::base::Propagator::Instance()->getNominalBz(); - LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << d_bz << " kG"; + dBz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << dBz << " kG"; mRunNumber = bc.runNumber(); - if (doprocessMiniRun2) { + if (doprocessMiniRun2) { // get class id for HMV0M trigger classes o2::ccdb::CcdbApi ccdbApi; ccdbApi.init("http://alice-ccdb.cern.ch"); std::map metadata; @@ -461,9 +416,7 @@ struct ebyeMaker { classIds.push_back(classId); } } - fitter.setBz(d_bz); - - // o2::base::Propagator::Instance()->setMatLUT(lut); + fitter.setBz(dBz); } template @@ -471,7 +424,7 @@ struct ebyeMaker { { if ((doprocessMiniRun2 || doprocessMiniMcRun2) && track.hasITS()) { auto extra = trackExtraRun2.rawIteratorAt(track.globalIndex()); - double expBethe{tpc::BetheBlochAleph(static_cast(track.p() / partMass[0]), cfgBetheBlochParamsITS->get("p0"), cfgBetheBlochParamsITS->get("p1"), cfgBetheBlochParamsITS->get("p2"), cfgBetheBlochParamsITS->get("p3"), cfgBetheBlochParamsITS->get("p4"))}; + double expBethe{tpc::BetheBlochAleph(static_cast(track.p() / kPartMass[0]), cfgBetheBlochParamsITS->get("p0"), cfgBetheBlochParamsITS->get("p1"), cfgBetheBlochParamsITS->get("p2"), cfgBetheBlochParamsITS->get("p3"), cfgBetheBlochParamsITS->get("p4"))}; double expSigma{expBethe * cfgBetheBlochParamsITS->get("resolution")}; auto nSigmaITS = static_cast((extra.itsSignal() - expBethe) / expSigma); return std::make_pair(extra.itsSignal(), nSigmaITS); @@ -480,41 +433,19 @@ struct ebyeMaker { } template - float getOuterPID(T const& track) + float getCustomTPCPID(T const& track, float const mass, int const ip = 0) { - if ((doprocessMiniRun2 || doprocessMiniMcRun2) && track.hasTOF() && track.pt() > antipPtTof) - return track.tofNSigmaPr(); - return -999.f; + double expBethe{tpc::BetheBlochAleph(static_cast(track.tpcInnerParam() / mass), cfgBetheBlochParams->get(ip, "p0"), cfgBetheBlochParams->get(ip, "p1"), cfgBetheBlochParams->get(ip, "p2"), cfgBetheBlochParams->get(ip, "p3"), cfgBetheBlochParams->get(ip, "p4"))}; + double expSigma{expBethe * cfgBetheBlochParams->get(ip, "resolution")}; + return static_cast((track.tpcSignal() - expBethe) / expSigma); } - float getV0M(int64_t const id, float const zvtx, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs) + template + float getOuterPID(T const& track) { - auto fv0a = fv0as.rawIteratorAt(id); - auto fv0c = fv0cs.rawIteratorAt(id); - float multFV0A = 0; - float multFV0C = 0; - for (float amplitude : fv0a.amplitude()) { - multFV0A += amplitude; - } - - for (float amplitude : fv0c.amplitude()) { - multFV0C += amplitude; - } - - float v0m = -1; - auto scaleMC = [](float x, float pars[6]) { - return pow(((pars[0] + pars[1] * pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); - }; - - if (Run2V0MInfo.mMCScale != nullptr) { - float multFV0M = multFV0A + multFV0C; - v0m = scaleMC(multFV0M, Run2V0MInfo.mMCScalePars); - LOGF(debug, "Unscaled v0m: %f, scaled v0m: %f", multFV0M, v0m); - } else if (Run2V0MInfo.mCalibrationStored) { - v0m = multFV0A * Run2V0MInfo.mhVtxAmpCorrV0A->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0A->FindFixBin(zvtx)) + - multFV0C * Run2V0MInfo.mhVtxAmpCorrV0C->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0C->FindFixBin(zvtx)); - } - return v0m; + if (!(doprocessRun2 || doprocessMcRun2) && track.hasTOF() && track.pt() > antipPtTof) + return track.tofNSigmaPr(); + return -999.f; } template @@ -550,15 +481,13 @@ struct ebyeMaker { void init(o2::framework::InitContext&) { - mRunNumber = 0; - d_bz = 0; + dBz = 0; ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); - // lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); fitter.setPropagateToPCA(true); fitter.setMaxR(200.); @@ -576,12 +505,9 @@ struct ebyeMaker { histos.add("QA/zVtx", ";#it{z}_{vtx} (cm);Entries", HistType::kTH1F, {zVtxAxis}); if (doprocessRun3) { histos.add("QA/PvMultVsCent", ";Centrality T0C (%);#it{N}_{PV contributors};", HistType::kTH2F, {centAxis, multAxis}); - histos.add("QA/MultVsCent", ";Centrality T0C (%);Multiplicity T0C;", HistType::kTH2F, {centAxis, multFt0Axis}); } else if (doprocessRun2 || doprocessMiniRun2 || doprocessMcRun2 || doprocessMiniMcRun2) { histos.add("QA/V0MvsCL0", ";Centrality CL0 (%);Centrality V0M (%)", HistType::kTH2F, {centAxis, centAxis}); histos.add("QA/trackletsVsV0M", ";Centrality CL0 (%);Centrality V0M (%)", HistType::kTH2F, {centAxis, multAxis}); - histos.add("QA/nTrklCorrelation", ";Tracklets |#eta| < 0.6; Tracklets |#eta| > 0.7", HistType::kTH2D, {{201, -0.5, 200.5}, {201, -0.5, 200.5}}); - histos.add("QA/TrklEta", ";Tracklets #eta; Entries", HistType::kTH1D, {{100, -3., 3.}}); } // v0 QA @@ -608,7 +534,7 @@ struct ebyeMaker { auto tracksSlice(T const& tracksAll, uint64_t const& collId) { if (doprocessRun3 || doprocessMcRun3) - return tracksAll.sliceBy(perCollisionTracksFullIU, collId); + return tracksAll.sliceBy(perCollisionTracksFullIUPID, collId); else if (doprocessRun2 || doprocessMcRun2) return tracksAll.sliceBy(perCollisionTracksFull, collId); else @@ -622,18 +548,16 @@ struct ebyeMaker { candidateTracks[0].clear(); candidateTracks[1].clear(); candidateV0s.clear(); + nTrackletsColl = 0u; + nTracksColl = 0u; - gpu::gpustd::array dcaInfo; - uint8_t nTracklets[2]{0, 0}; + std::array dcaInfo; for (const auto& track : tracks) { - - if (track.trackType() == 255 && std::abs(track.eta()) < 1.2) { // tracklet - if (std::abs(track.eta()) < 0.6) - nTracklets[0]++; - else if (std::abs(track.eta()) > 0.7) - nTracklets[1]++; + if (track.trackType() == o2::aod::track::TrackTypeEnum::Run2Tracklet && std::abs(track.eta()) < trklEtaMax && !(doprocessRun3 || doprocessMcRun3)) { // tracklet + nTrackletsColl++; + } else if (std::abs(track.eta()) < trklEtaMax && track.itsNCls() > 3 && (doprocessRun3 || doprocessMcRun3)) { // ITS only + global tracks + nTrackletsColl++; } - if (!selectTrack(track)) { continue; } @@ -643,16 +567,12 @@ struct ebyeMaker { auto dca = std::hypot(dcaInfo[0], dcaInfo[1]); auto trackPt = trackParCov.getPt(); auto trackEta = trackParCov.getEta(); - if (dca > cfgDcaSels->get("dca")) { // dca - continue; - } - if (std::abs(dcaInfo[1]) > cfgDcaSels->get("dcaz")) { // dcaz - continue; - } - if (std::abs(dcaInfo[0]) > cfgDcaSels->get("dcaxy") * (constDCASel ? 1. : dcaSigma(track.pt()))) { // dcaxy + if (std::abs(dcaInfo[0]) > cfgDcaSels->get("dcaxy") * (constDCASel ? 1. : dcaSigma(track.pt())) || std::abs(dcaInfo[1]) > cfgDcaSels->get("dcaz") || dca > cfgDcaSels->get("dca")) { // dcaxy continue; } histos.fill(HIST("QA/tpcSignal"), track.tpcInnerParam(), track.tpcSignal()); + if (trackPt > ptMin[0] && trackPt < ptMax[0]) + nTracksColl++; for (int iP{0}; iP < kNpart; ++iP) { if (trackPt < ptMin[iP] || trackPt > ptMax[iP]) { @@ -666,19 +586,16 @@ struct ebyeMaker { } } - double expBethe{tpc::BetheBlochAleph(static_cast(track.tpcInnerParam() / partMass[iP]), cfgBetheBlochParams->get(iP, "p0"), cfgBetheBlochParams->get(iP, "p1"), cfgBetheBlochParams->get(iP, "p2"), cfgBetheBlochParams->get(iP, "p3"), cfgBetheBlochParams->get(iP, "p4"))}; - double expSigma{expBethe * cfgBetheBlochParams->get(iP, "resolution")}; - auto nSigmaTPC = static_cast((track.tpcSignal() - expBethe) / expSigma); + auto nSigmaTPC = getCustomTPCPID(track, kPartMass[iP], iP); - float beta{track.hasTOF() ? track.length() / (track.tofSignal() - track.tofEvTime()) * o2::pid::tof::kCSPEDDInv : -999.f}; + float beta{track.hasTOF() ? track.length() / (track.tofSignal() - track.tofEvTime()) * o2::constants::physics::invLightSpeedCm2PS : -999.f}; beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); float mass{track.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f)}; - bool hasTof = track.hasTOF() && track.tofChi2() < 3; + const float maxTofChi2 = 3.f; // TODO: check if this is still needed + bool hasTof = track.hasTOF() && track.tofChi2() < maxTofChi2; - if (trackPt <= ptTof[iP] || (trackPt > ptTof[iP] && hasTof && std::abs(mass - partMass[iP]) < tofMassMaxQA)) { // for QA histograms - if (nSigmaTPC > nSigmaTpcCutLow[iP] && nSigmaTPC < nSigmaTpcCutUp[iP]) { - tofMass[iP]->Fill(centrality, trackPt, mass); - } + if ((trackPt <= ptTof[iP] || (trackPt > ptTof[iP] && hasTof && std::abs(mass - kPartMass[iP]) < tofMassMaxQA)) && nSigmaTPC > nSigmaTpcCutLow[iP] && nSigmaTPC < nSigmaTpcCutUp[iP]) { // for QA histograms + tofMass[iP]->Fill(centrality, trackPt, mass); } if (nSigmaTPC < nSigmaTpcCutLow[iP] || nSigmaTPC > nSigmaTpcCutUp[iP]) { @@ -693,7 +610,7 @@ struct ebyeMaker { continue; } - if (trackPt <= ptTof[iP] || (trackPt > ptTof[iP] && hasTof && std::abs(mass - partMass[iP]) < tofMassMax[iP])) { + if (trackPt <= ptTof[iP] || (trackPt > ptTof[iP] && hasTof && std::abs(mass - kPartMass[iP]) < tofMassMax[iP])) { CandidateTrack candTrack; candTrack.pt = track.sign() > 0. ? trackPt : -trackPt; candTrack.eta = trackEta; @@ -711,10 +628,6 @@ struct ebyeMaker { } } } - if (doprocessRun2 || doprocessMcRun2 || doprocessMiniRun2 || doprocessMiniMcRun2) { - histos.fill(HIST("QA/nTrklCorrelation"), nTracklets[0], nTracklets[1]); - nTrackletsColl = nTracklets[1]; - } if (lambdaPtMax > lambdaPtMin) { std::vector trkId; @@ -764,7 +677,7 @@ struct ebyeMaker { continue; } - auto etaV0 = etaFromMom(momPos, momNeg); + auto etaV0 = RecoDecay::eta(momV0); if (std::abs(etaV0) > etaMax) { continue; } @@ -773,19 +686,15 @@ struct ebyeMaker { bool matter = alpha > 0; auto massPos = matter ? o2::constants::physics::MassProton : o2::constants::physics::MassPionCharged; auto massNeg = matter ? o2::constants::physics::MassPionCharged : o2::constants::physics::MassProton; - auto mLambda = invMass2Body(momV0, momPos, momNeg, massPos, massNeg); - auto mK0Short = invMass2Body(momV0, momPos, momNeg, o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged); + auto mLambda = RecoDecay::m(std::array, 2>{momPos, momNeg}, std::array{massPos, massNeg}); + auto mK0Short = RecoDecay::m(std::array, 2>{momPos, momNeg}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged}); // pid selections - double expBethePos{tpc::BetheBlochAleph(static_cast(posTrack.tpcInnerParam() / massPos), cfgBetheBlochParams->get("p0"), cfgBetheBlochParams->get("p1"), cfgBetheBlochParams->get("p2"), cfgBetheBlochParams->get("p3"), cfgBetheBlochParams->get("p4"))}; - double expSigmaPos{expBethePos * cfgBetheBlochParams->get("resolution")}; - auto nSigmaTPCPos = static_cast((posTrack.tpcSignal() - expBethePos) / expSigmaPos); - double expBetheNeg{tpc::BetheBlochAleph(static_cast(negTrack.tpcInnerParam() / massNeg), cfgBetheBlochParams->get("p0"), cfgBetheBlochParams->get("p1"), cfgBetheBlochParams->get("p2"), cfgBetheBlochParams->get("p3"), cfgBetheBlochParams->get("p4"))}; - double expSigmaNeg{expBetheNeg * cfgBetheBlochParams->get("resolution")}; - auto nSigmaTPCNeg = static_cast((negTrack.tpcSignal() - expBetheNeg) / expSigmaNeg); + float nSigmaTPCPos = getCustomTPCPID(posTrack, massPos); + float nSigmaTPCNeg = getCustomTPCPID(negTrack, massNeg); float tpcSigPr = matter ? posTrack.tpcSignal() : negTrack.tpcSignal(); - if (std::abs(nSigmaTPCPos) > v0setting_nsigmatpc || std::abs(nSigmaTPCNeg) > v0setting_nsigmatpc) { + if (std::abs(nSigmaTPCPos) > v0settingNSigmaTpc || std::abs(nSigmaTPCNeg) > v0settingNSigmaTpc) { continue; } @@ -795,7 +704,7 @@ struct ebyeMaker { } float dcaV0dau = std::sqrt(fitter.getChi2AtPCACandidate()); - if (dcaV0dau > v0setting_dcav0dau) { + if (dcaV0dau > v0settingDcaV0Dau) { continue; } @@ -803,41 +712,37 @@ struct ebyeMaker { const auto& vtx = fitter.getPCACandidate(); float radiusV0 = std::hypot(vtx[0], vtx[1]); - if (radiusV0 < v0setting_radius || radiusV0 > v0radiusMax) { + if (radiusV0 < v0settingRadius || radiusV0 > v0radiusMax) { continue; } - float dcaV0Pv = CalculateDCAStraightToPV( + float dcaV0Pv = calculateDCAStraightToPV( vtx[0], vtx[1], vtx[2], momPos[0] + momNeg[0], momPos[1] + momNeg[1], momPos[2] + momNeg[2], collision.posX(), collision.posY(), collision.posZ()); - if (std::abs(dcaV0Pv) > v0setting_dcav0pv) { + if (std::abs(dcaV0Pv) > v0settingDcaV0Pv) { continue; } double cosPA = RecoDecay::cpa(primVtx, vtx, momV0); - if (cosPA < v0setting_cospa) { + if (cosPA < v0settingCosPa) { continue; } auto ptotal = RecoDecay::sqrtSumOfSquares(momV0[0], momV0[1], momV0[2]); auto lengthTraveled = RecoDecay::sqrtSumOfSquares(vtx[0] - primVtx[0], vtx[1] - primVtx[1], vtx[2] - primVtx[2]); - float ML2P_Lambda = o2::constants::physics::MassLambda * lengthTraveled / ptotal; - if (ML2P_Lambda > v0setting_lifetime) { + float mL2PLambda = o2::constants::physics::MassLambda * lengthTraveled / ptotal; + if (mL2PLambda > v0settingLifetime) { continue; } o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, posTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); auto posDcaToPv = std::hypot(dcaInfo[0], dcaInfo[1]); - if (posDcaToPv < v0setting_dcadaughtopv && std::abs(dcaInfo[0]) < v0setting_dcadaughtopv) { - continue; - } - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, negTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); auto negDcaToPv = std::hypot(dcaInfo[0], dcaInfo[1]); - if (negDcaToPv < v0setting_dcadaughtopv && std::abs(dcaInfo[0]) < v0setting_dcadaughtopv) { + if ((posDcaToPv < v0settingDcaDaughToPv && std::abs(dcaInfo[0]) < v0settingDcaDaughToPv) || (negDcaToPv < v0settingDcaDaughToPv && std::abs(dcaInfo[0]) < v0settingDcaDaughToPv)) { continue; } @@ -845,7 +750,6 @@ struct ebyeMaker { continue; } histos.fill(HIST("QA/massLambda"), centrality, ptV0, mLambda); - histos.fill(HIST("QA/tpcSignalPr"), matter > 0. ? posTrack.tpcInnerParam() : negTrack.tpcInnerParam(), tpcSigPr); CandidateV0 candV0; @@ -867,23 +771,32 @@ struct ebyeMaker { } template - void fillMcEvent(C const& collision, T const& tracks, aod::V0s const& V0s, float const& centrality, aod::McParticles const&, aod::McTrackLabels const& mcLabels) + void fillMcEvent(C const& collision, T const& tracks, aod::V0s const& V0s, float const& centrality, aod::McParticles const& particlesMC, aod::McTrackLabels const& mcLabels) { fillRecoEvent(collision, tracks, V0s, centrality); for (int iP{0}; iP < kNpart; ++iP) { - for (auto& candidateTrack : candidateTracks[iP]) { + for (auto& candidateTrack : candidateTracks[iP]) { // o2-linter: disable=const-ref-in-for-loop (not a const ref) candidateTrack.isreco = true; auto mcLab = mcLabels.rawIteratorAt(candidateTrack.globalIndex); + + if (mcLab.mcParticleId() < -1 || mcLab.mcParticleId() >= particlesMC.size()) { + continue; + } if (mcLab.has_mcParticle()) { auto mcTrack = mcLab.template mcParticle_as(); - if (std::abs(mcTrack.pdgCode()) != partPdg[iP]) + if (std::abs(mcTrack.pdgCode()) != kPartPdg[iP]) continue; - if (((mcTrack.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcTrack.flags() & 0x2) || (mcTrack.flags() & 0x1)) + if ((((mcTrack.flags() & 0x8) || (mcTrack.flags() & 0x2)) && (doprocessMcRun2 || doprocessMiniMcRun2)) || ((mcTrack.flags() & 0x1) && !doprocessMiniMcRun2)) continue; - if (!mcTrack.isPhysicalPrimary()) + + if (!mcTrack.isPhysicalPrimary() && !doprocessMiniMcRun2) continue; + if (mcTrack.isPhysicalPrimary()) + candidateTrack.pdgcodemoth = PartTypes::kPhysPrim; + else if (mcTrack.has_mothers() && iP == 0) + candidateTrack.pdgcodemoth = getPartTypeMother(mcTrack); auto genPt = std::hypot(mcTrack.px(), mcTrack.py()); candidateTrack.pdgcode = mcTrack.pdgCode(); @@ -893,7 +806,7 @@ struct ebyeMaker { } } } - for (auto& candidateV0 : candidateV0s) { + for (auto& candidateV0 : candidateV0s) { // o2-linter: disable=const-ref-in-for-loop (not a const ref) candidateV0.isreco = true; auto mcLabPos = mcLabels.rawIteratorAt(candidateV0.globalIndexPos); auto mcLabNeg = mcLabels.rawIteratorAt(candidateV0.globalIndexNeg); @@ -902,18 +815,18 @@ struct ebyeMaker { auto mcTrackPos = mcLabPos.template mcParticle_as(); auto mcTrackNeg = mcLabNeg.template mcParticle_as(); if (mcTrackPos.has_mothers() && mcTrackNeg.has_mothers()) { - for (auto& negMother : mcTrackNeg.template mothers_as()) { - for (auto& posMother : mcTrackPos.template mothers_as()) { + for (const auto& negMother : mcTrackNeg.template mothers_as()) { + for (const auto& posMother : mcTrackPos.template mothers_as()) { if (posMother.globalIndex() != negMother.globalIndex()) continue; - if (!((mcTrackPos.pdgCode() == 2212 && mcTrackNeg.pdgCode() == -211) || (mcTrackPos.pdgCode() == 211 && mcTrackNeg.pdgCode() == -2212))) + if (!((mcTrackPos.pdgCode() == PDG_t::kProton && mcTrackNeg.pdgCode() == PDG_t::kPiMinus) || (mcTrackPos.pdgCode() == PDG_t::kPiPlus && mcTrackNeg.pdgCode() == PDG_t::kProtonBar))) continue; - if (std::abs(posMother.pdgCode()) != 3122) { + if (std::abs(posMother.pdgCode()) != PDG_t::kLambda0) { continue; } if (!posMother.isPhysicalPrimary() && !posMother.has_mothers()) continue; - if (((posMother.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (posMother.flags() & 0x2) || (posMother.flags() & 0x1)) + if (((posMother.flags() & 0x8) || (posMother.flags() & 0x2) || (posMother.flags() & 0x1)) && (doprocessMcRun2 || doprocessMiniMcRun2)) continue; auto genPt = std::hypot(posMother.px(), posMother.py()); @@ -930,21 +843,25 @@ struct ebyeMaker { void fillMcGen(aod::McParticles const& mcParticles, aod::McTrackLabels const& /*mcLab*/, uint64_t const& collisionId) { - auto mcParticles_thisCollision = mcParticles.sliceBy(perCollisionMcParts, collisionId); - for (auto& mcPart : mcParticles_thisCollision) { + nChPartGen = 0u; + auto mcParticlesThisCollision = mcParticles.sliceBy(perCollisionMcParts, collisionId); + for (const auto& mcPart : mcParticlesThisCollision) { auto genEta = mcPart.eta(); if (std::abs(genEta) > etaMax) { continue; } - if (((mcPart.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcPart.flags() & 0x2) || (mcPart.flags() & 0x1)) + if ((((mcPart.flags() & 0x8) || (mcPart.flags() & 0x2)) && (doprocessMcRun2 || doprocessMiniMcRun2)) || ((mcPart.flags() & 0x1) && !doprocessMiniMcRun2)) continue; auto pdgCode = mcPart.pdgCode(); - if (std::abs(pdgCode) == 3122) { + auto genPt = std::hypot(mcPart.px(), mcPart.py()); + if ((std::abs(pdgCode) == PDG_t::kPiPlus || std::abs(pdgCode) == PDG_t::kElectron || std::abs(pdgCode) == PDG_t::kMuonMinus || std::abs(pdgCode) == PDG_t::kKPlus || std::abs(pdgCode) == PDG_t::kProton) && mcPart.isPhysicalPrimary() && genPt > ptMin[0] && genPt < ptMax[0]) + nChPartGen++; + if (std::abs(pdgCode) == PDG_t::kLambda0) { if (!mcPart.isPhysicalPrimary() && !mcPart.has_mothers()) continue; bool foundPr = false; - for (auto& mcDaught : mcPart.daughters_as()) { - if (std::abs(mcDaught.pdgCode()) == 2212) { + for (const auto& mcDaught : mcPart.daughters_as()) { + if (std::abs(mcDaught.pdgCode()) == PDG_t::kProton) { foundPr = true; break; } @@ -952,7 +869,6 @@ struct ebyeMaker { if (!foundPr) { continue; } - auto genPt = std::hypot(mcPart.px(), mcPart.py()); CandidateV0 candV0; candV0.genpt = genPt; candV0.geneta = mcPart.eta(); @@ -964,18 +880,23 @@ struct ebyeMaker { LOGF(debug, "not found!"); candidateV0s.emplace_back(candV0); } - } else if (std::abs(pdgCode) == partPdg[0] || std::abs(pdgCode) == partPdg[1]) { + } else if (std::abs(pdgCode) == kPartPdg[0] || std::abs(pdgCode) == kPartPdg[1]) { int iP = 1; - if (std::abs(pdgCode) == partPdg[0]) { + if (std::abs(pdgCode) == kPartPdg[0]) { iP = 0; } - if (!mcPart.isPhysicalPrimary() && !mcPart.has_mothers()) + if ((!mcPart.isPhysicalPrimary() && !doprocessMiniMcRun2)) continue; auto genPt = std::hypot(mcPart.px(), mcPart.py()); CandidateTrack candTrack; candTrack.genpt = genPt; candTrack.geneta = mcPart.eta(); candTrack.pdgcode = pdgCode; + if (mcPart.isPhysicalPrimary()) + candTrack.pdgcodemoth = PartTypes::kPhysPrim; + else if (mcPart.has_mothers() && iP == 0) + candTrack.pdgcodemoth = getPartTypeMother(mcPart); + auto it = find_if(candidateTracks[iP].begin(), candidateTracks[iP].end(), [&](CandidateTrack trk) { return trk.mcIndex == mcPart.globalIndex(); }); if (it != candidateTracks[iP].end()) { continue; @@ -986,71 +907,47 @@ struct ebyeMaker { } } - void processRun3(soa::Join const& collisions, TracksFullIU const& tracks, aod::V0s const& V0s, aod::BCsWithTimestamps const&) + void processRun3(soa::Join const& collisions, TracksFullIUPID const& tracks, aod::V0s const& V0s, aod::BCsWithTimestamps const&) { for (const auto& collision : collisions) { auto bc = collision.bc_as(); initCCDB(bc); - if (!collision.sel8()) - continue; - - if (std::abs(collision.posZ()) > zVtxMax) - continue; - - if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) + if (std::abs(collision.posZ()) > zVtxMax || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kIsTriggerTVX) || ((!collision.selection_bit(aod::evsel::kIsGoodITSLayersAll) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) && useAllEvSel)) continue; histos.fill(HIST("QA/zVtx"), collision.posZ()); const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); + auto v0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + v0TableThisCollision.bindExternalIndices(&tracks); - auto multiplicity = collision.multFT0C(); auto centrality = collision.centFT0C(); - fillRecoEvent(collision, tracks, V0Table_thisCollision, centrality); - histos.fill(HIST("QA/PvMultVsCent"), centrality, collision.numContrib()); - histos.fill(HIST("QA/MultVsCent"), centrality, multiplicity); + fillRecoEvent(collision, tracks, v0TableThisCollision, centrality); - collisionEbyeTable(centrality, collision.posZ()); - - for (auto& candidateV0 : candidateV0s) { - lambdaEbyeTable( - collisionEbyeTable.lastIndex(), - candidateV0.pt, - candidateV0.eta, - candidateV0.mass, - candidateV0.dcav0pv, - // candidateV0.dcanegpv, - // candidateV0.dcapospv, - candidateV0.dcav0daugh, - candidateV0.cpa, - // candidateV0.tpcnsigmaneg, - // candidateV0.tpcnsigmapos, - candidateV0.globalIndexNeg, - candidateV0.globalIndexPos); - } + miniCollTable(static_cast(collision.posZ() * 10), 0x0, nTrackletsColl, centrality, nTracksColl); - for (int iP{0}; iP < kNpart; ++iP) { - for (auto& candidateTrack : candidateTracks[iP]) { // deuterons + protons - nucleiEbyeTable( - collisionEbyeTable.lastIndex(), - candidateTrack.pt, - candidateTrack.eta, - candidateTrack.mass, - candidateTrack.dcapv, - candidateTrack.tpcncls, - candidateTrack.tpcnsigma, - candidateTrack.tofmass); - } + for (auto& candidateTrack : candidateTracks[0]) { // o2-linter: disable=const-ref-in-for-loop (not a const ref) + auto tk = tracks.rawIteratorAt(candidateTrack.globalIndex); + float outerPID = getOuterPID(tk); + candidateTrack.itsnsigma = -999.f; + candidateTrack.outerPID = tk.pt() < antipPtTof ? candidateTrack.outerPID : outerPID; + int selMask = getTrackSelMask(candidateTrack); + if (candidateTrack.outerPID < outerPIDMin) + continue; + miniTrkTable( + miniCollTable.lastIndex(), + candidateTrack.pt, + static_cast(candidateTrack.eta * 100), + selMask, + candidateTrack.outerPID); } } } - PROCESS_SWITCH(ebyeMaker, processRun3, "process (Run 3)", false); + PROCESS_SWITCH(EbyeMaker, processRun3, "process (Run 3)", false); - void processRun2(soa::Join const& collisions, TracksFull const& tracks, aod::V0s const& V0s, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, BCsWithRun2Info const&) + void processRun2(soa::Join const& collisions, TracksFull const& tracks, aod::V0s const& V0s, BCsWithRun2Info const&) { for (const auto& collision : collisions) { auto bc = collision.bc_as(); @@ -1062,27 +959,20 @@ struct ebyeMaker { if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) continue; - if (kUseTPCPileUpCut && !(bc.eventCuts() & BIT(aod::Run2EventCuts::kTPCPileUp))) + if (kUsePileUpCut && !(bc.eventCuts() & BIT(aod::Run2EventCuts::kTPCPileUp))) continue; - float v0m = getV0M(bc.globalIndex(), collision.posZ(), fv0as, fv0cs); - float cV0M = 105.f; - if (Run2V0MInfo.mCalibrationStored) { - cV0M = Run2V0MInfo.mhMultSelCalib->GetBinContent(Run2V0MInfo.mhMultSelCalib->FindFixBin(v0m)); - if (!(collision.sel7() && collision.alias_bit(kINT7)) && (!kINT7Intervals || (kINT7Intervals && ((cV0M >= 10 && cV0M < 30) || cV0M > 50)))) - continue; - } + float centrality = collision.centRun2V0M(); + const float centTriggerEdges[]{10.f, 30.f, 50.f}; + if (!(collision.sel7() && collision.alias_bit(kINT7)) && (!kINT7Intervals || (kINT7Intervals && ((centrality >= centTriggerEdges[0] && centrality < centTriggerEdges[1]) || centrality > centTriggerEdges[2])))) + continue; - auto centralityCl0 = 105.0f; - if (Run2CL0Info.mCalibrationStored) { - float cl0m = bc.spdClustersL0() * Run2CL0Info.mhVtxAmpCorr->GetBinContent(Run2CL0Info.mhVtxAmpCorr->FindFixBin(collision.posZ())); - centralityCl0 = Run2CL0Info.mhMultSelCalib->GetBinContent(Run2CL0Info.mhMultSelCalib->FindFixBin(cl0m)); - } + float centralityCl0 = collision.centRun2CL0(); if (kUseEstimatorsCorrelationCut) { const auto& x = centralityCl0; - const double center = estimatorsCorrelationCoef[0] + estimatorsCorrelationCoef[1] * x; - const double sigma = estimatorsSigmaPars[0] + estimatorsSigmaPars[1] * x + estimatorsSigmaPars[2] * std::pow(x, 2) + estimatorsSigmaPars[3] * std::pow(x, 3); - if (cV0M < center - deltaEstimatorNsigma[0] * sigma || cV0M > center + deltaEstimatorNsigma[1] * sigma) { + const double center = kEstimatorsCorrelationCoef[0] + kEstimatorsCorrelationCoef[1] * x; + const double sigma = kEstimatorsSigmaPars[0] + kEstimatorsSigmaPars[1] * x + kEstimatorsSigmaPars[2] * std::pow(x, 2) + kEstimatorsSigmaPars[3] * std::pow(x, 3); + if (centrality < center - kDeltaEstimatorNsigma[0] * sigma || centrality > center + kDeltaEstimatorNsigma[1] * sigma) { continue; } } @@ -1090,36 +980,32 @@ struct ebyeMaker { histos.fill(HIST("QA/zVtx"), collision.posZ()); const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); + auto v0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + v0TableThisCollision.bindExternalIndices(&tracks); auto multTracklets = collision.multTracklets(); - fillRecoEvent(collision, tracks, V0Table_thisCollision, cV0M); + fillRecoEvent(collision, tracks, v0TableThisCollision, centrality); - histos.fill(HIST("QA/V0MvsCL0"), centralityCl0, cV0M); - histos.fill(HIST("QA/trackletsVsV0M"), cV0M, multTracklets); + histos.fill(HIST("QA/V0MvsCL0"), centralityCl0, centrality); + histos.fill(HIST("QA/trackletsVsV0M"), centrality, multTracklets); - collisionEbyeTable(cV0M, collision.posZ()); + collisionEbyeTable(centrality, collision.posZ()); - for (auto& candidateV0 : candidateV0s) { + for (const auto& candidateV0 : candidateV0s) { lambdaEbyeTable( collisionEbyeTable.lastIndex(), candidateV0.pt, candidateV0.eta, candidateV0.mass, candidateV0.dcav0pv, - // candidateV0.dcanegpv, - // candidateV0.dcapospv, candidateV0.dcav0daugh, candidateV0.cpa, - // candidateV0.tpcnsigmaneg, - // candidateV0.tpcnsigmapos, candidateV0.globalIndexNeg, candidateV0.globalIndexPos); } for (int iP{0}; iP < kNpart; ++iP) { - for (auto& candidateTrack : candidateTracks[iP]) { // deuterons + protons + for (const auto& candidateTrack : candidateTracks[iP]) { // deuterons + protons nucleiEbyeTable( collisionEbyeTable.lastIndex(), candidateTrack.pt, @@ -1133,11 +1019,10 @@ struct ebyeMaker { } } } - PROCESS_SWITCH(ebyeMaker, processRun2, "process (Run 2)", false); + PROCESS_SWITCH(EbyeMaker, processRun2, "process (Run 2)", false); - void processMiniRun2(soa::Join const& collisions, TracksFullPID const& tracks, aod::Run2TrackExtras const& trackExtraRun2, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, aod::V0s const& V0s, BCsWithRun2Info const&) + void processMiniRun2(soa::Join const& collisions, TracksFullPID const& tracks, aod::Run2TrackExtras const& trackExtraRun2, aod::V0s const& V0s, BCsWithRun2Info const&) { - for (const auto& collision : collisions) { auto bc = collision.bc_as(); initCCDB(bc); @@ -1151,25 +1036,23 @@ struct ebyeMaker { if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) continue; - float v0m = getV0M(bc.globalIndex(), collision.posZ(), fv0as, fv0cs); - float cV0M = 105.f; - if (Run2V0MInfo.mCalibrationStored) { - cV0M = Run2V0MInfo.mhMultSelCalib->GetBinContent(Run2V0MInfo.mhMultSelCalib->FindFixBin(v0m)); - } + if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kPileUpMV) || bc.eventCuts() & BIT(aod::Run2EventCuts::kTPCPileUp)) && kUsePileUpCut) + continue; + float centrality = collision.centRun2V0M(); histos.fill(HIST("QA/zVtx"), collision.posZ()); const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); + auto v0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + v0TableThisCollision.bindExternalIndices(&tracks); - fillRecoEvent(collision, tracks, V0Table_thisCollision, cV0M); + fillRecoEvent(collision, tracks, v0TableThisCollision, centrality); uint8_t trigger = collision.alias_bit(kINT7) ? 0x1 : 0x0; - for (auto& classId : classIds) { + for (const auto& classId : classIds) { if (bc.triggerMask() & BIT(classId)) { trigger |= 0x2; - cV0M = cV0M < 104.f ? cV0M * 100. : cV0M; + centrality = centrality * 100.; break; } } @@ -1179,9 +1062,9 @@ struct ebyeMaker { if (triggerCut != 0x0 && (trigger & triggerCut) != triggerCut) { continue; } - miniCollTable(static_cast(collision.posZ() * 10), trigger, nTrackletsColl, cV0M); + miniCollTable(static_cast(collision.posZ() * 10), trigger, nTrackletsColl, centrality, nTracksColl); - for (auto& candidateTrack : candidateTracks[0]) { // protons + for (auto& candidateTrack : candidateTracks[0]) { // o2-linter: disable=const-ref-in-for-loop (not a const ref) auto tk = tracks.rawIteratorAt(candidateTrack.globalIndex); float outerPID = getOuterPID(tk); auto [itsSignal, nSigmaITS] = getITSSignal(tk, trackExtraRun2); @@ -1200,21 +1083,15 @@ struct ebyeMaker { } } } - PROCESS_SWITCH(ebyeMaker, processMiniRun2, "process mini tables(Run 2)", false); + PROCESS_SWITCH(EbyeMaker, processMiniRun2, "process mini tables(Run 2)", false); - void processMcRun3(soa::Join const& collisions, aod::McCollisions const& /*mcCollisions*/, TracksFullIU const& tracks, aod::V0s const& V0s, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, aod::BCsWithTimestamps const&) + void processMcRun3(soa::Join const& collisions, aod::McCollisions const& /*mcCollisions*/, TracksFullIUPID const& tracks, aod::V0s const& V0s, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, aod::BCsWithTimestamps const&) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto bc = collision.bc_as(); initCCDB(bc); - if (!collision.sel8()) - continue; - - if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) - continue; - - if (std::abs(collision.posZ()) > zVtxMax) + if (std::abs(collision.posZ()) > zVtxMax || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kIsTriggerTVX) || ((!collision.selection_bit(aod::evsel::kIsGoodITSLayersAll) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) && useAllEvSel)) continue; auto centrality = collision.centFT0C(); @@ -1222,59 +1099,46 @@ struct ebyeMaker { histos.fill(HIST("QA/zVtx"), collision.posZ()); const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); + auto v0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + v0TableThisCollision.bindExternalIndices(&tracks); - fillMcEvent(collision, tracks, V0Table_thisCollision, centrality, mcParticles, mcLab); + fillMcEvent(collision, tracks, v0TableThisCollision, centrality, mcParticles, mcLab); fillMcGen(mcParticles, mcLab, collision.mcCollisionId()); - collisionEbyeTable(centrality, collision.posZ()); - - for (auto& candidateV0 : candidateV0s) { - mcLambdaEbyeTable( - collisionEbyeTable.lastIndex(), - candidateV0.pt, - candidateV0.eta, - candidateV0.mass, - candidateV0.dcav0pv, - // candidateV0.dcanegpv, - // candidateV0.dcapospv, - candidateV0.dcav0daugh, - candidateV0.cpa, - // candidateV0.tpcnsigmaneg, - // candidateV0.tpcnsigmapos, - candidateV0.globalIndexNeg, - candidateV0.globalIndexPos, - candidateV0.genpt, - candidateV0.geneta, - candidateV0.pdgcode, - candidateV0.isreco); - } + miniCollTable(static_cast(collision.posZ() * 10), nChPartGen, nTrackletsColl, centrality, nTracksColl); - for (int iP{0}; iP < kNpart; ++iP) { - for (auto& candidateTrack : candidateTracks[iP]) { // deuterons + protons - mcNucleiEbyeTable( - collisionEbyeTable.lastIndex(), - candidateTrack.pt, - candidateTrack.eta, - candidateTrack.mass, - candidateTrack.dcapv, - candidateTrack.tpcncls, - candidateTrack.tpcnsigma, - candidateTrack.tofmass, - candidateTrack.genpt, - candidateTrack.geneta, - candidateTrack.pdgcode, - candidateTrack.isreco); + for (auto& candidateTrack : candidateTracks[0]) { // o2-linter: disable=const-ref-in-for-loop (not a const ref) + int selMask = -1; + if (candidateTrack.isreco) { + auto tk = tracks.rawIteratorAt(candidateTrack.globalIndex); + float outerPID = getOuterPID(tk); + candidateTrack.itsnsigma = -999.f; + candidateTrack.outerPID = tk.pt() < antipPtTof ? candidateTrack.outerPID : outerPID; + selMask = getTrackSelMask(candidateTrack); + if (candidateTrack.pdgcodemoth > 0) + selMask |= candidateTrack.pdgcodemoth; + } else if (candidateTrack.pdgcodemoth > 0) { + selMask = candidateTrack.pdgcodemoth; } + if (selMask < 0) + continue; + mcMiniTrkTable( + miniCollTable.lastIndex(), + candidateTrack.pt, + static_cast(candidateTrack.eta * 100), + selMask, + candidateTrack.outerPID, + candidateTrack.pdgcode > 0 ? candidateTrack.genpt : -candidateTrack.genpt, + static_cast(candidateTrack.geneta * 100), + candidateTrack.isreco); } } } - PROCESS_SWITCH(ebyeMaker, processMcRun3, "process MC (Run 3)", false); + PROCESS_SWITCH(EbyeMaker, processMcRun3, "process MC (Run 3)", false); - void processMcRun2(soa::Join const& collisions, aod::McCollisions const& /*mcCollisions*/, TracksFull const& tracks, aod::V0s const& V0s, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, BCsWithRun2Info const&) + void processMcRun2(soa::Join const& collisions, aod::McCollisions const& /*mcCollisions*/, TracksFull const& tracks, aod::V0s const& V0s, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, BCsWithRun2Info const&) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto bc = collision.bc_as(); initCCDB(bc); @@ -1284,36 +1148,27 @@ struct ebyeMaker { if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) continue; - float v0m = getV0M(bc.globalIndex(), collision.posZ(), fv0as, fv0cs); - float cV0M = 105.f; - if (Run2V0MInfo.mCalibrationStored) { - cV0M = Run2V0MInfo.mhMultSelCalib->GetBinContent(Run2V0MInfo.mhMultSelCalib->FindFixBin(v0m)); - } - + float centrality = collision.centRun2V0M(); histos.fill(HIST("QA/zVtx"), collision.posZ()); const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); + auto v0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + v0TableThisCollision.bindExternalIndices(&tracks); - fillMcEvent(collision, tracks, V0Table_thisCollision, cV0M, mcParticles, mcLab); + fillMcEvent(collision, tracks, v0TableThisCollision, centrality, mcParticles, mcLab); fillMcGen(mcParticles, mcLab, collision.mcCollisionId()); - collisionEbyeTable(cV0M, collision.posZ()); + collisionEbyeTable(centrality, collision.posZ()); - for (auto& candidateV0 : candidateV0s) { + for (const auto& candidateV0 : candidateV0s) { mcLambdaEbyeTable( collisionEbyeTable.lastIndex(), candidateV0.pt, candidateV0.eta, candidateV0.mass, candidateV0.dcav0pv, - // candidateV0.dcanegpv, - // candidateV0.dcapospv, candidateV0.dcav0daugh, candidateV0.cpa, - // candidateV0.tpcnsigmaneg, - // candidateV0.tpcnsigmapos, candidateV0.globalIndexNeg, candidateV0.globalIndexPos, candidateV0.genpt, @@ -1323,7 +1178,7 @@ struct ebyeMaker { } for (int iP{0}; iP < kNpart; ++iP) { - for (auto& candidateTrack : candidateTracks[iP]) { // deuterons + protons + for (const auto& candidateTrack : candidateTracks[iP]) { // deuterons + protons mcNucleiEbyeTable( collisionEbyeTable.lastIndex(), candidateTrack.pt, @@ -1341,11 +1196,10 @@ struct ebyeMaker { } } } - PROCESS_SWITCH(ebyeMaker, processMcRun2, "process MC (Run 2)", false); + PROCESS_SWITCH(EbyeMaker, processMcRun2, "process MC (Run 2)", false); - void processMiniMcRun2(soa::Join const& collisions, aod::McCollisions const& /*mcCollisions*/, TracksFullPID const& tracks, aod::Run2TrackExtras const& trackExtraRun2, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, aod::V0s const& V0s, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, BCsWithRun2Info const&) + void processMiniMcRun2(soa::Join const& collisions, aod::McCollisions const& /*mcCollisions*/, TracksFullPID const& tracks, aod::Run2TrackExtras const& trackExtraRun2, aod::V0s const& V0s, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, BCsWithRun2Info const&) { - for (const auto& collision : collisions) { auto bc = collision.bc_as(); initCCDB(bc); @@ -1356,24 +1210,19 @@ struct ebyeMaker { if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) continue; - float v0m = getV0M(bc.globalIndex(), collision.posZ(), fv0as, fv0cs); - float cV0M = 105.f; - if (Run2V0MInfo.mCalibrationStored) { - cV0M = Run2V0MInfo.mhMultSelCalib->GetBinContent(Run2V0MInfo.mhMultSelCalib->FindFixBin(v0m)); - } - + float centrality = collision.centRun2V0M(); histos.fill(HIST("QA/zVtx"), collision.posZ()); const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); + auto v0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + v0TableThisCollision.bindExternalIndices(&tracks); - fillMcEvent(collision, tracks, V0Table_thisCollision, cV0M, mcParticles, mcLab); + fillMcEvent(collision, tracks, v0TableThisCollision, centrality, mcParticles, mcLab); fillMcGen(mcParticles, mcLab, collision.mcCollisionId()); - miniCollTable(static_cast(collision.posZ() * 10), 0x0, nTrackletsColl, cV0M); + miniCollTable(static_cast(collision.posZ() * 10), nChPartGen, nTrackletsColl, centrality, nTracksColl); - for (auto& candidateTrack : candidateTracks[0]) { // protons + for (auto& candidateTrack : candidateTracks[0]) { // o2-linter: disable=const-ref-in-for-loop (not a const ref) int selMask = -1; if (candidateTrack.isreco) { auto tk = tracks.rawIteratorAt(candidateTrack.globalIndex); @@ -1383,9 +1232,13 @@ struct ebyeMaker { candidateTrack.itsnsigma = nSigmaITS; candidateTrack.outerPID = tk.pt() < antipPtTof ? candidateTrack.outerPID : outerPID; selMask = getTrackSelMask(candidateTrack); - // if (candidateTrack.outerPID < -4) - // continue; + if (candidateTrack.pdgcodemoth > 0) + selMask |= candidateTrack.pdgcodemoth; + } else if (candidateTrack.pdgcodemoth > 0) { + selMask = candidateTrack.pdgcodemoth; } + if (selMask < 0) + continue; mcMiniTrkTable( miniCollTable.lastIndex(), candidateTrack.pt, @@ -1398,11 +1251,11 @@ struct ebyeMaker { } } } - PROCESS_SWITCH(ebyeMaker, processMiniMcRun2, "process mini tables for mc(Run 2)", false); + PROCESS_SWITCH(EbyeMaker, processMiniMcRun2, "process mini tables for mc(Run 2)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx index 016dec7e81d..f50262bd998 100644 --- a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -10,32 +10,14 @@ // or submit itself to any jurisdiction. // Analysis task for he3-hadron femto analysis -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +/// \file he3HadronFemto.cxx +/// \brief Femto analysis task for He3-hadron correlation +/// \author Your Name (your.email@cern.ch) +/// \since April 2025 -#include -#include -#include -#include -#include -#include -#include // std::prev - -#include "Framework/ASoAHelpers.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/LFhe3HadronTables.h" +#include "PWGLF/Utils/svPoolCreator.h" #include "Common/Core/PID/PIDTOF.h" #include "Common/Core/PID/TPCPIDResponse.h" @@ -49,21 +31,40 @@ #include "Common/DataModel/PIDResponseITS.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/TableProducer/PID/pidTOFBase.h" - #include "EventFiltering/Zorro.h" #include "EventFiltering/ZorroSummary.h" #include "CCDB/BasicCCDBManager.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsTPC/BetheBlochAleph.h" -#include "DataFormatsParameters/GRPObject.h" #include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" -#include "PWGLF/DataModel/EPCalibrationTables.h" -#include "PWGLF/DataModel/LFhe3HadronTables.h" -#include "PWGLF/Utils/svPoolCreator.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include // std::prev +#include +#include using namespace o2; using namespace o2::framework; @@ -73,8 +74,8 @@ using CollBracket = o2::math_utils::Bracket; using McIter = aod::McParticles::iterator; using CollBracket = o2::math_utils::Bracket; -using CollisionsFull = soa::Join; -using CollisionsFullMC = soa::Join; +using CollisionsFull = soa::Join; +using CollisionsFullMC = soa::Join; using TrackCandidates = soa::Join; using TrackCandidatesMC = soa::Join; @@ -83,13 +84,12 @@ namespace constexpr double betheBlochDefault[1][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}}; static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; -// constexpr float he3Mass = o2::constants::physics::MassHelium3; -// constexpr float protonMass = o2::constants::physics::MassProton; -// constexpr float pionchargedMass = o2::constants::physics::MassPiPlus; -constexpr int li4PDG = 1000030040; -constexpr int prPDG = 2212; -constexpr int hePDG = 1000020030; -// constexpr int pichargedPDG = 211; +constexpr int Li4PDG = o2::constants::physics::Pdg::kLithium4; +constexpr int H3LPDG = o2::constants::physics::Pdg::kHyperTriton; +constexpr int ProtonPDG = PDG_t::kProton; +constexpr int PionPDG = PDG_t::kPiPlus; +constexpr int He3PDG = o2::constants::physics::Pdg::kHelium3; +constexpr float CommonInite = 0.0f; enum Selections { kNoCuts = 0, @@ -98,9 +98,24 @@ enum Selections { kAll }; +enum Flags { + kBothPrimaries = BIT(0), + kBothFromLi4 = BIT(1), + kBothFromHypertriton = BIT(2), + kMixedPair = BIT(3), // a primary and one from Li4/hypertriton/material/other decays (or any other combination) +}; + +enum ParticleFlags { + kPhysicalPrimary = BIT(0), // primary particle + kFromLi4 = BIT(1), // from Li4 decay + kFromHypertriton = BIT(2), // from hypertriton decay + kFromMaterial = BIT(3), // from material + kFromOtherDecays = BIT(4), // from other decays +}; + } // namespace -struct he3HadCandidate { +struct He3HadCandidate { float recoPtHe3() const { return signHe3 * std::hypot(momHe3[0], momHe3[1]); } float recoPhiHe3() const { return std::atan2(momHe3[1], momHe3[0]); } @@ -115,10 +130,11 @@ struct he3HadCandidate { float signHe3 = 1.f; float signHad = 1.f; float invMass = -10.f; - float DCAxyHe3 = -10.f; - float DCAzHe3 = -10.f; - float DCAxyHad = -10.f; - float DCAzHad = -10.f; + float dcaxyHe3 = -10.f; + float dcazHe3 = -10.f; + float dcaxyHad = -10.f; + float dcazHad = -10.f; + float dcaPair = -10.f; // DCA between the two tracks uint16_t tpcSignalHe3 = 0u; uint16_t tpcSignalHad = 0u; @@ -131,13 +147,18 @@ struct he3HadCandidate { float chi2TPCHad = -10.f; float nSigmaHe3 = -10.f; float nSigmaHad = -10.f; - uint32_t PIDtrkHe3 = 0xFFFFF; // PID in tracking - uint32_t PIDtrkHad = 0xFFFFF; + uint32_t pidtrkHe3 = 0xFFFFF; // PID in tracking + uint32_t pidtrkHad = 0xFFFFF; float massTOFHe3 = -10; float massTOFHad = -10; uint32_t itsClSizeHe3 = 0u; uint32_t itsClSizeHad = 0u; + uint8_t nclsITSHe3 = 0u; + uint8_t nclsITSHad = 0u; + float chi2nclITSHe3 = -10.f; + float chi2nclITSHad = -10.f; + bool isBkgUS = false; // unlike sign bool isBkgEM = false; // event mixing @@ -153,59 +174,67 @@ struct he3HadCandidate { float etaHadMC = -99.f; float phiHadMC = -99.f; + uint8_t flagsHe3 = 0; // flags for He3 + uint8_t flagsHad = 0; // flags for hadron + uint8_t flags = 0; // flags for the pair + // collision information int32_t collisionID = 0; }; -struct he3hadronfemto { +struct he3HadronFemto { - Produces m_outputDataTable; - Produces m_outputMCTable; - Produces m_outputMultiplicityTable; + Produces outputDataTable; + Produces outputMcTable; + Produces outputMultiplicityTable; // Selections - Configurable setting_HadPDGCode{"setting_HadPDGCode", 211, "Hadron - PDG code"}; - Configurable setting_cutVertex{"setting_cutVertex", 10.0f, "Accepted z-vertex range"}; - Configurable setting_cutRigidityMinHe3{"setting_cutRigidityMinHe3", 0.8f, "Minimum rigidity for He3"}; - Configurable setting_cutEta{"setting_cutEta", 0.9f, "Eta cut on daughter track"}; - Configurable setting_cutDCAxy{"setting_cutDCAxy", 2.0f, "DCAxy range for tracks"}; - Configurable setting_cutDCAz{"setting_cutDCAz", 2.0f, "DCAz range for tracks"}; - Configurable setting_cutChi2tpcLow{"setting_cutChi2tpcLow", 0.5f, "Low cut on TPC chi2"}; - Configurable setting_cutInvMass{"setting_cutInvMass", 0.0f, "Invariant mass upper limit"}; - Configurable setting_cutPtMinhe3Had{"setting_cutPtMinhe3Had", 0.0f, "Minimum PT cut on he3Had4"}; - Configurable setting_cutClSizeItsHe3{"setting_cutClSizeItsHe3", 4.0f, "Minimum ITS cluster size for He3"}; - Configurable setting_cutNsigmaTPC{"setting_cutNsigmaTPC", 3.0f, "Value of the TPC Nsigma cut"}; - Configurable setting_cutNsigmaITS{"setting_cutNsigmaITS", -1.5f, "Value of the TPC Nsigma cut"}; - Configurable setting_cutPtMinTOFHad{"setting_cutPtMinTOFHad", 0.4f, "Minimum pT to apply the TOF cut on hadrons"}; - Configurable setting_cutNsigmaTOF{"setting_cutNsigmaTOF", 3.0f, "Value of the TOF Nsigma cut"}; - Configurable setting_noMixedEvents{"setting_noMixedEvents", 5, "Number of mixed events per event"}; - Configurable setting_enableBkgUS{"setting_enableBkgUS", false, "Enable US background"}; - Configurable setting_saveUSandLS{"setting_saveUSandLS", true, "Save All Pairs"}; - Configurable setting_isMC{"setting_isMC", false, "Run MC"}; - Configurable setting_fillMultiplicity{"setting_fillMultiplicity", false, "Fill multiplicity table"}; + Configurable settingHadPDGCode{"settingHadPDGCode", 211, "Hadron - PDG code"}; + Configurable settingCutVertex{"settingCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable settingCutRigidityMinHe3{"settingCutRigidityMinHe3", 0.8f, "Minimum rigidity for He3"}; + Configurable settingCutEta{"settingCutEta", 0.9f, "Eta cut on daughter track"}; + Configurable settingCutDCAxy{"settingCutDCAxy", 2.0f, "DCAxy range for tracks"}; + Configurable settingCutDCAz{"settingCutDCAz", 2.0f, "DCAz range for tracks"}; + Configurable settingCutChi2tpcLow{"settingCutChi2tpcLow", 0.5f, "Low cut on TPC chi2"}; + Configurable settingCutInvMass{"settingCutInvMass", 0.0f, "Invariant mass upper limit"}; + Configurable settingCutPtMinhe3Had{"settingCutPtMinhe3Had", 0.0f, "Minimum PT cut on he3Had4"}; + Configurable settingCutClSizeItsHe3{"settingCutClSizeItsHe3", 4.0f, "Minimum ITS cluster size for He3"}; + Configurable settingCutNCls{"settingCutNCls", 5.0f, "Minimum ITS Ncluster for tracks"}; + Configurable settingCutChi2NClITS{"settingCutChi2NClITS", 36.f, "Maximum ITS Chi2 for tracks"}; + Configurable settingCutNsigmaTPC{"settingCutNsigmaTPC", 3.0f, "Value of the TPC Nsigma cut"}; + Configurable settingCutNsigmaITS{"settingCutNsigmaITS", -1.5f, "Value of the TPC Nsigma cut"}; + Configurable settingCutPtMinTOFHad{"settingCutPtMinTOFHad", 0.4f, "Minimum pT to apply the TOF cut on hadrons"}; + Configurable settingCutNsigmaTOF{"settingCutNsigmaTOF", 3.0f, "Value of the TOF Nsigma cut"}; + Configurable settingNoMixedEvents{"settingNoMixedEvents", 5, "Number of mixed events per event"}; + Configurable settingEnableBkgUS{"settingEnableBkgUS", false, "Enable US background"}; + Configurable settingEnableDCAfitter{"settingEnableDCAfitter", false, "Enable DCA fitter"}; + Configurable settingSaveUSandLS{"settingSaveUSandLS", true, "Save All Pairs"}; + Configurable settingIsMC{"settingIsMC", false, "Run MC"}; + Configurable settingFillMultiplicity{"settingFillMultiplicity", false, "Fill multiplicity table"}; + Configurable settingFillPrimariesAndMixedMc{"settingFillPrimariesAndMixedMc", false, "Fill primary MC tracks and mixed tracks (e.g. a primary track and one from Li4)"}; // Zorro - Configurable setting_skimmedProcessing{"setting_skimmedProcessing", false, "Skimmed dataset processing"}; + Configurable settingSkimmedProcessing{"settingSkimmedProcessing", false, "Skimmed dataset processing"}; // svPool - Configurable setting_skipAmbiTracks{"setting_skipAmbiTracks", false, "Skip ambiguous tracks"}; - Configurable setting_customVertexerTimeMargin{"setting_customVertexerTimeMargin", 800, "Time margin for custom vertexer (ns)"}; + Configurable settingSkipAmbiTracks{"settingSkipAmbiTracks", false, "Skip ambiguous tracks"}; + Configurable settingCustomVertexerTimeMargin{"settingCustomVertexerTimeMargin", 800, "Time margin for custom vertexer (ns)"}; // CCDB options - Configurable setting_d_bz_input{"setting_d_bz", -999, "bz field, -999 is automatic"}; - Configurable setting_ccdburl{"setting_ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable setting_grpPath{"setting_grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable setting_grpmagPath{"setting_grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable setting_lutPath{"setting_lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable setting_geoPath{"setting_geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - Configurable setting_pidPath{"setting_pidPath", "", "Path to the PID response object"}; + Configurable settingDbz{"settingDbz", -999, "bz field, -999 is automatic"}; + Configurable settingCcdburl{"settingCcdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable settingGrpPath{"settingGrpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable settingGrpmagPath{"settingGrpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable settingLutPath{"settingLutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable settingGeoPath{"settingGeoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable settingPidPath{"settingPidPath", "", "Path to the PID response object"}; - Configurable> setting_BetheBlochParams{"setting_BetheBlochParams", {betheBlochDefault[0], 1, 6, {"He3"}, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for He3"}; - Configurable setting_compensatePIDinTracking{"setting_compensatePIDinTracking", false, "If true, divide tpcInnerParam by the electric charge"}; - Configurable setting_materialCorrection{"setting_materialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Material correction type"}; + Configurable> settingBetheBlochParams{"settingBetheBlochParams", {betheBlochDefault[0], 1, 6, {"He3"}, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for He3"}; + Configurable settingCompensatePIDinTracking{"settingCompensatePIDinTracking", false, "If true, divide tpcInnerParam by the electric charge"}; + Configurable settingMaterialCorrection{"settingMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Material correction type"}; - Preslice m_perCol = aod::track::collisionId; - Preslice m_perColMC = aod::track::collisionId; + Preslice mPerCol = aod::track::collisionId; + Preslice mPerColMC = aod::track::collisionId; // binning for EM background ConfigurableAxis axisVertex{"axisVertex", {30, -10, 10}, "Binning for multiplicity"}; @@ -213,44 +242,50 @@ struct he3hadronfemto { using BinningType = ColumnBinningPolicy; BinningType binningPolicy{{axisVertex, axisCentrality}, true}; SliceCache cache; - SameKindPair m_pair{binningPolicy, setting_noMixedEvents, -1, &cache}; - - std::array m_BBparamsHe; - - std::vector m_recoCollisionIDs; - std::vector m_goodCollisions; - std::vector m_trackPairs; - o2::vertexing::DCAFitterN<2> m_fitter; - svPoolCreator m_svPoolCreator{hePDG, prPDG}; - - int m_runNumber; - float m_d_bz; - Service m_ccdb; - Zorro m_zorro; - OutputObj m_zorroSummary{"zorroSummary"}; - - HistogramRegistry m_qaRegistry{ + SameKindPair mPair{binningPolicy, settingNoMixedEvents, -1, &cache}; + + std::array mBBparamsHe; + + std::vector mRecoCollisionIDs; + std::vector mGoodCollisions; + std::vector mTrackPairs; + o2::vertexing::DCAFitterN<2> mFitter; + svPoolCreator mSvPoolCreator{He3PDG, ProtonPDG}; + int mRunNumber; + float mDbz; + Service mCcdb; + Zorro mZorro; + OutputObj mZorroSummary{"zorroSummary"}; + + HistogramRegistry mQaRegistry{ "QA", { + {"hVtxZBefore", "Vertex distribution in Z before selections;Z (cm)", {HistType::kTH1F, {{400, -20.0, 20.0}}}}, {"hVtxZ", "Vertex distribution in Z;Z (cm)", {HistType::kTH1F, {{400, -20.0, 20.0}}}}, + {"hCentralityFT0A", ";Centrality FT0A (%)", {HistType::kTH1F, {{100, 0, 100.0}}}}, + {"hCentralityFT0C", ";Centrality FT0C (%)", {HistType::kTH1F, {{100, 0, 100.0}}}}, {"hNcontributor", "Number of primary vertex contributor", {HistType::kTH1F, {{2000, 0.0f, 2000.0f}}}}, {"hTrackSel", "Accepted tracks", {HistType::kTH1F, {{Selections::kAll, -0.5, static_cast(Selections::kAll) - 0.5}}}}, {"hEvents", "; Events;", {HistType::kTH1F, {{3, -0.5, 2.5}}}}, {"hEmptyPool", "svPoolCreator did not find track pairs false/true", {HistType::kTH1F, {{2, -0.5, 1.5}}}}, - {"hDCAxyHe3", ";DCA_{xy} (cm)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, - {"hDCAzHe3", ";DCA_{z} (cm)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, + {"hDCAxyHe3", "^{3}He;DCA_{xy} (cm)", {HistType::kTH1F, {{200, -5.0f, 5.0f}}}}, + {"hDCAzHe3", "^{3}He;DCA_{z} (cm)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, + {"hNClsHe3ITS", "^{3}He;N_{ITS} Cluster", {HistType::kTH1F, {{20, -10.0f, 10.0f}}}}, + {"hNClsHadITS", "had;N_{ITS} Cluster", {HistType::kTH1F, {{20, -10.0f, 10.0f}}}}, + {"hChi2NClHe3ITS", "^{3}He;Chi2_{ITS} Ncluster", {HistType::kTH1F, {{100, 0, 100.0f}}}}, + {"hChi2NClHadITS", "had;Chi2_{ITS} Ncluster", {HistType::kTH1F, {{100, 0, 100.0f}}}}, {"hhe3HadtInvMass", "; M(^{3}He + p) (GeV/#it{c}^{2})", {HistType::kTH1F, {{300, 3.74f, 4.34f}}}}, - {"hHe3Pt", "#it{p}_{T} distribution; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{240, -6.0f, 6.0f}}}}, - {"hHadronPt", "Pt distribution; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{120, -3.0f, 3.0f}}}}, + {"hHe3Pt", "^{3}He; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{240, -6.0f, 6.0f}}}}, + {"hHadronPt", "had; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{120, -3.0f, 3.0f}}}}, {"h2dEdxHe3candidates", "dEdx distribution; #it{p} (GeV/#it{c}); dE/dx (a.u.)", {HistType::kTH2F, {{200, -5.0f, 5.0f}, {100, 0.0f, 2000.0f}}}}, {"h2NsigmaHe3TPC", "NsigmaHe3 TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(^{3}He)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, {"h2NsigmaHe3TPC_preselection", "NsigmaHe3 TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(^{3}He)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, {"h2NSigmaHe3ITS_preselection", "NsigmaHe3 ITS distribution; signed #it{p}_{T} (GeV/#it{c}); n#sigma_{ITS} ^{3}He", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {120, -3.0f, 3.0f}}}}, {"h2NSigmaHe3ITS", "NsigmaHe3 ITS distribution; signed #it{p}_{T} (GeV/#it{c}); n#sigma_{ITS} ^{3}He", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {120, -3.0f, 3.0f}}}}, - {"h2NsigmaHadronTPC", "NsigmaHadron TPC distribution; #it{p}_{T}(GeV/#it{c}); n#sigma_{TPC}(p)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, - {"h2NsigmaHadronTPC_preselection", "NsigmaHe3 TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(^{3}He)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, - {"h2NsigmaHadronTOF", "NsigmaHadron TOF distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(p)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, - {"h2NsigmaHadronTOF_preselection", "NsigmaHadron TOF distribution; #iit{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(p)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, + {"h2NsigmaHadronTPC", "NsigmaHadron TPC distribution; #it{p}_{T}(GeV/#it{c}); n#sigma_{TPC}(had)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, + {"h2NsigmaHadronTPC_preselection", "NsigmaHe3 TPC distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TPC}(had)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, + {"h2NsigmaHadronTOF", "NsigmaHadron TOF distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(had)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, + {"h2NsigmaHadronTOF_preselection", "NsigmaHadron TOF distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(had)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}}}}, }, OutputObjHandlingPolicy::AnalysisObject, false, @@ -258,83 +293,83 @@ struct he3hadronfemto { void init(o2::framework::InitContext&) { - m_zorroSummary.setObject(m_zorro.getZorroSummary()); - m_runNumber = 0; - - m_ccdb->setURL(setting_ccdburl); - m_ccdb->setCaching(true); - m_ccdb->setLocalObjectValidityChecking(); - m_ccdb->setFatalWhenNull(false); - - m_fitter.setPropagateToPCA(true); - m_fitter.setMaxR(200.); - m_fitter.setMinParamChange(1e-3); - m_fitter.setMinRelChi2Change(0.9); - m_fitter.setMaxDZIni(1e9); - m_fitter.setMaxChi2(1e9); - m_fitter.setUseAbsDCA(true); - int mat{static_cast(setting_materialCorrection)}; - m_fitter.setMatCorrType(static_cast(mat)); - - m_svPoolCreator.setTimeMargin(setting_customVertexerTimeMargin); - if (setting_skipAmbiTracks) { - m_svPoolCreator.setSkipAmbiTracks(); + mZorroSummary.setObject(mZorro.getZorroSummary()); + mRunNumber = 0; + + mCcdb->setURL(settingCcdburl); + mCcdb->setCaching(true); + mCcdb->setLocalObjectValidityChecking(); + mCcdb->setFatalWhenNull(false); + + mFitter.setPropagateToPCA(true); + mFitter.setMaxR(200.); + mFitter.setMinParamChange(1e-3); + mFitter.setMinRelChi2Change(0.9); + mFitter.setMaxDZIni(1e9); + mFitter.setMaxChi2(1e9); + mFitter.setUseAbsDCA(true); + int mat{static_cast(settingMaterialCorrection)}; + mFitter.setMatCorrType(static_cast(mat)); + + mSvPoolCreator.setTimeMargin(settingCustomVertexerTimeMargin); + if (settingSkipAmbiTracks) { + mSvPoolCreator.setSkipAmbiTracks(); } - - for (int i = 0; i < 5; i++) { - m_BBparamsHe[i] = setting_BetheBlochParams->get("He3", Form("p%i", i)); + const int numberParticle = 5; + for (int i = 0; i < numberParticle; i++) { + mBBparamsHe[i] = settingBetheBlochParams->get("He3", Form("p%i", i)); } - m_BBparamsHe[5] = setting_BetheBlochParams->get("He3", "resolution"); + mBBparamsHe[5] = settingBetheBlochParams->get("He3", "resolution"); - std::vector selection_labels = {"All", "Track selection", "PID"}; + std::vector selectionLabels = {"All", "Track selection", "PID"}; for (int i = 0; i < Selections::kAll; i++) { - m_qaRegistry.get(HIST("hTrackSel"))->GetXaxis()->SetBinLabel(i + 1, selection_labels[i].c_str()); + mQaRegistry.get(HIST("hTrackSel"))->GetXaxis()->SetBinLabel(i + 1, selectionLabels[i].c_str()); } - std::vector events_labels = {"All", "Selected", "Zorro He events"}; + std::vector eventsLabels = {"All", "Selected", "Zorro He events"}; for (int i = 0; i < Selections::kAll; i++) { - m_qaRegistry.get(HIST("hEvents"))->GetXaxis()->SetBinLabel(i + 1, events_labels[i].c_str()); + mQaRegistry.get(HIST("hEvents"))->GetXaxis()->SetBinLabel(i + 1, eventsLabels[i].c_str()); } - m_qaRegistry.get(HIST("hEmptyPool"))->GetXaxis()->SetBinLabel(1, "False"); - m_qaRegistry.get(HIST("hEmptyPool"))->GetXaxis()->SetBinLabel(2, "True"); + mQaRegistry.get(HIST("hEmptyPool"))->GetXaxis()->SetBinLabel(1, "False"); + mQaRegistry.get(HIST("hEmptyPool"))->GetXaxis()->SetBinLabel(2, "True"); } void initCCDB(const aod::BCsWithTimestamps::iterator& bc) { - if (m_runNumber == bc.runNumber()) { + if (mRunNumber == bc.runNumber()) { return; } - if (setting_skimmedProcessing) { - m_zorro.initCCDB(m_ccdb.service, bc.runNumber(), bc.timestamp(), "fHe"); - m_zorro.populateHistRegistry(m_qaRegistry, bc.runNumber()); + if (settingSkimmedProcessing) { + mZorro.initCCDB(mCcdb.service, bc.runNumber(), bc.timestamp(), "fHe"); + mZorro.populateHistRegistry(mQaRegistry, bc.runNumber()); } - m_runNumber = bc.runNumber(); - - auto run3grp_timestamp = bc.timestamp(); - o2::parameters::GRPObject* grpo = m_ccdb->getForTimeStamp(setting_grpPath, run3grp_timestamp); + mRunNumber = bc.runNumber(); + const float defaultBzValue = -999.0f; + auto run3GrpTimestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = mCcdb->getForTimeStamp(settingGrpPath, run3GrpTimestamp); o2::parameters::GRPMagField* grpmag = 0x0; if (grpo) { o2::base::Propagator::initFieldFromGRP(grpo); - if (setting_d_bz_input < -990) { + if (settingDbz < defaultBzValue) { // Fetch magnetic field from ccdb for current collision - m_d_bz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << m_d_bz << " kZG"; + mDbz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3GrpTimestamp << " with magnetic field of " << mDbz << " kZG"; } else { - m_d_bz = setting_d_bz_input; + mDbz = settingDbz; } } else { - grpmag = m_ccdb->getForTimeStamp(setting_grpmagPath, run3grp_timestamp); + grpmag = mCcdb->getForTimeStamp(settingGrpmagPath, run3GrpTimestamp); if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << setting_grpmagPath << " of object GRPMagField and " << setting_grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + LOG(fatal) << "Got nullptr from CCDB for path " << settingGrpmagPath << " of object GRPMagField and " << settingGrpPath << " of object GRPObject for timestamp " << run3GrpTimestamp; } o2::base::Propagator::initFieldFromGRP(grpmag); - if (setting_d_bz_input < -990) { + if (settingDbz < defaultBzValue) { // Fetch magnetic field from ccdb for current collision - m_d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << m_d_bz << " kZG"; + mDbz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3GrpTimestamp << " with magnetic field of " << mDbz << " kZG"; } else { - m_d_bz = setting_d_bz_input; + mDbz = settingDbz; } } } @@ -344,46 +379,54 @@ struct he3hadronfemto { template bool selectCollision(const Tcollision& collision, const aod::BCsWithTimestamps&) { - m_qaRegistry.fill(HIST("hEvents"), 0); + mQaRegistry.fill(HIST("hEvents"), 0); + mQaRegistry.fill(HIST("hVtxZBefore"), collision.posZ()); + + auto bc = collision.template bc_as(); + initCCDB(bc); if constexpr (isMC) { - if (/*!collision.sel8() ||*/ std::abs(collision.posZ()) > setting_cutVertex) { + if (/*!collision.sel8() ||*/ std::abs(collision.posZ()) > settingCutVertex) { return false; } } else { - auto bc = collision.template bc_as(); - initCCDB(bc); - if (!collision.sel8() || std::abs(collision.posZ()) > setting_cutVertex) { + if (!collision.sel8() || std::abs(collision.posZ()) > settingCutVertex) { return false; } - if (setting_skimmedProcessing) { - bool zorroSelected = m_zorro.isSelected(collision.template bc_as().globalBC()); + if (settingSkimmedProcessing) { + bool zorroSelected = mZorro.isSelected(collision.template bc_as().globalBC()); if (zorroSelected) { - m_qaRegistry.fill(HIST("hEvents"), 2); + mQaRegistry.fill(HIST("hEvents"), 2); } } } - m_qaRegistry.fill(HIST("hEvents"), 1); - m_qaRegistry.fill(HIST("hNcontributor"), collision.numContrib()); - m_qaRegistry.fill(HIST("hVtxZ"), collision.posZ()); + mQaRegistry.fill(HIST("hEvents"), 1); + mQaRegistry.fill(HIST("hNcontributor"), collision.numContrib()); + mQaRegistry.fill(HIST("hVtxZ"), collision.posZ()); + mQaRegistry.fill(HIST("hCentralityFT0A"), collision.centFT0A()); + mQaRegistry.fill(HIST("hCentralityFT0C"), collision.centFT0C()); return true; } template bool selectTrack(const Ttrack& candidate) { - if (std::abs(candidate.eta()) > setting_cutEta) { + if (std::abs(candidate.eta()) > settingCutEta) { return false; } - if (candidate.itsNCls() < 5 || - candidate.tpcNClsFound() < 90 || - candidate.tpcNClsCrossedRows() < 70 || - candidate.tpcNClsCrossedRows() < 0.8 * candidate.tpcNClsFindable() || - candidate.tpcChi2NCl() > 4.f || - candidate.tpcChi2NCl() < setting_cutChi2tpcLow || - candidate.itsChi2NCl() > 36.f) { + const int minTPCNClsFound = 90; + const int minTPCNClsCrossedRows = 70; + const float crossedRowsToFindableRatio = 0.8f; + const float maxChi2NCl = 4.f; + if (candidate.itsNCls() < settingCutNCls || + candidate.tpcNClsFound() < minTPCNClsFound || + candidate.tpcNClsCrossedRows() < minTPCNClsCrossedRows || + candidate.tpcNClsCrossedRows() < crossedRowsToFindableRatio * candidate.tpcNClsFindable() || + candidate.tpcChi2NCl() > maxChi2NCl || + candidate.tpcChi2NCl() < settingCutChi2tpcLow || + candidate.itsChi2NCl() > settingCutChi2NClITS) { return false; } @@ -393,10 +436,10 @@ struct he3hadronfemto { template float computeTPCNSigmaHadron(const Ttrack& candidate) { - float tpcNSigmaHad = 0; - if (setting_HadPDGCode == 211) { + float tpcNSigmaHad = CommonInite; + if (settingHadPDGCode == PDG_t::kPiPlus) { tpcNSigmaHad = candidate.tpcNSigmaPi(); - } else if (setting_HadPDGCode == 2212) { + } else if (settingHadPDGCode == PDG_t::kProton) { tpcNSigmaHad = candidate.tpcNSigmaPr(); } else { LOG(info) << "invalid PDG code for TPC"; @@ -407,10 +450,10 @@ struct he3hadronfemto { template float computeTOFNSigmaHadron(const Ttrack& candidate) { - float tofNSigmaHad = 0; - if (setting_HadPDGCode == 211) { + float tofNSigmaHad = CommonInite; + if (settingHadPDGCode == PDG_t::kPiPlus) { tofNSigmaHad = candidate.tofNSigmaPi(); - } else if (setting_HadPDGCode == 2212) { + } else if (settingHadPDGCode == PDG_t::kProton) { tofNSigmaHad = candidate.tofNSigmaPr(); } else { LOG(info) << "invalid PDG code for TOF"; @@ -422,22 +465,22 @@ struct he3hadronfemto { bool selectionPIDHadron(const Ttrack& candidate) { auto tpcNSigmaHad = computeTPCNSigmaHadron(candidate); - m_qaRegistry.fill(HIST("h2NsigmaHadronTPC_preselection"), candidate.tpcInnerParam(), tpcNSigmaHad); - if (candidate.hasTOF() && candidate.pt() > setting_cutPtMinTOFHad) { + mQaRegistry.fill(HIST("h2NsigmaHadronTPC_preselection"), candidate.tpcInnerParam(), tpcNSigmaHad); + if (candidate.hasTOF() && candidate.pt() > settingCutPtMinTOFHad) { auto tofNSigmaHad = computeTOFNSigmaHadron(candidate); - if (std::abs(tpcNSigmaHad) > setting_cutNsigmaTPC) { + if (std::abs(tpcNSigmaHad) > settingCutNsigmaTPC) { return false; } - m_qaRegistry.fill(HIST("h2NsigmaHadronTOF_preselection"), candidate.pt(), tofNSigmaHad); - if (std::abs(tofNSigmaHad) > setting_cutNsigmaTOF) { + mQaRegistry.fill(HIST("h2NsigmaHadronTOF_preselection"), candidate.pt(), tofNSigmaHad); + if (std::abs(tofNSigmaHad) > settingCutNsigmaTOF) { return false; } - m_qaRegistry.fill(HIST("h2NsigmaHadronTPC"), candidate.pt(), tpcNSigmaHad); - m_qaRegistry.fill(HIST("h2NsigmaHadronTOF"), candidate.pt(), tofNSigmaHad); + mQaRegistry.fill(HIST("h2NsigmaHadronTPC"), candidate.pt(), tpcNSigmaHad); + mQaRegistry.fill(HIST("h2NsigmaHadronTOF"), candidate.pt(), tofNSigmaHad); return true; - } else if (std::abs(tpcNSigmaHad) < setting_cutNsigmaTPC) { - m_qaRegistry.fill(HIST("h2NsigmaHadronTPC"), candidate.pt(), tpcNSigmaHad); + } else if (std::abs(tpcNSigmaHad) < settingCutNsigmaTPC) { + mQaRegistry.fill(HIST("h2NsigmaHadronTPC"), candidate.pt(), tpcNSigmaHad); return true; } return false; @@ -447,10 +490,10 @@ struct he3hadronfemto { float computeNSigmaHe3(const Ttrack& candidate) { bool heliumPID = candidate.pidForTracking() == o2::track::PID::Helium3 || candidate.pidForTracking() == o2::track::PID::Alpha; - float correctedTPCinnerParam = (heliumPID && setting_compensatePIDinTracking) ? candidate.tpcInnerParam() / 2.f : candidate.tpcInnerParam(); - float expTPCSignal = o2::tpc::BetheBlochAleph(static_cast(correctedTPCinnerParam * 2.f / constants::physics::MassHelium3), m_BBparamsHe[0], m_BBparamsHe[1], m_BBparamsHe[2], m_BBparamsHe[3], m_BBparamsHe[4]); + float correctedTPCinnerParam = (heliumPID && settingCompensatePIDinTracking) ? candidate.tpcInnerParam() / 2.f : candidate.tpcInnerParam(); + float expTPCSignal = o2::tpc::BetheBlochAleph(static_cast(correctedTPCinnerParam * 2.f / constants::physics::MassHelium3), mBBparamsHe[0], mBBparamsHe[1], mBBparamsHe[2], mBBparamsHe[3], mBBparamsHe[4]); - double resoTPC{expTPCSignal * m_BBparamsHe[5]}; + double resoTPC{expTPCSignal * mBBparamsHe[5]}; return static_cast((candidate.tpcSignal() - expTPCSignal) / resoTPC); } @@ -458,109 +501,133 @@ struct he3hadronfemto { bool selectionPIDHe3(const Ttrack& candidate) { bool heliumPID = candidate.pidForTracking() == o2::track::PID::Helium3 || candidate.pidForTracking() == o2::track::PID::Alpha; - float correctedTPCinnerParam = (heliumPID && setting_compensatePIDinTracking) ? candidate.tpcInnerParam() / 2.f : candidate.tpcInnerParam(); + float correctedTPCinnerParam = (heliumPID && settingCompensatePIDinTracking) ? candidate.tpcInnerParam() / 2.f : candidate.tpcInnerParam(); - if (correctedTPCinnerParam < setting_cutRigidityMinHe3) { + if (correctedTPCinnerParam < settingCutRigidityMinHe3) { return false; } auto nSigmaHe3 = computeNSigmaHe3(candidate); - m_qaRegistry.fill(HIST("h2NsigmaHe3TPC_preselection"), candidate.sign() * 2 * candidate.pt(), nSigmaHe3); - if (std::abs(nSigmaHe3) > setting_cutNsigmaTPC) { + mQaRegistry.fill(HIST("h2NsigmaHe3TPC_preselection"), candidate.sign() * 2 * candidate.pt(), nSigmaHe3); + if (std::abs(nSigmaHe3) > settingCutNsigmaTPC) { return false; } // - o2::aod::ITSResponse m_responseITS; - auto ITSnSigmaHe3 = m_responseITS.nSigmaITS(candidate.itsClusterSizes(), 2 * candidate.p(), candidate.eta()); + o2::aod::ITSResponse mResponseITS; + auto itsNsigmaHe3 = mResponseITS.nSigmaITS(candidate.itsClusterSizes(), 2 * candidate.p(), candidate.eta()); // - m_qaRegistry.fill(HIST("h2NSigmaHe3ITS_preselection"), candidate.sign() * 2 * candidate.pt(), ITSnSigmaHe3); - if (ITSnSigmaHe3 < setting_cutNsigmaITS) { + mQaRegistry.fill(HIST("h2NSigmaHe3ITS_preselection"), candidate.sign() * 2 * candidate.pt(), itsNsigmaHe3); + if (itsNsigmaHe3 < settingCutNsigmaITS) { return false; } - m_qaRegistry.fill(HIST("h2dEdxHe3candidates"), candidate.sign() * correctedTPCinnerParam, candidate.tpcSignal()); - m_qaRegistry.fill(HIST("h2NsigmaHe3TPC"), candidate.sign() * 2 * candidate.pt(), nSigmaHe3); - m_qaRegistry.fill(HIST("h2NSigmaHe3ITS"), candidate.sign() * 2 * candidate.pt(), ITSnSigmaHe3); + mQaRegistry.fill(HIST("h2dEdxHe3candidates"), candidate.sign() * correctedTPCinnerParam, candidate.tpcSignal()); + mQaRegistry.fill(HIST("h2NsigmaHe3TPC"), candidate.sign() * 2 * candidate.pt(), nSigmaHe3); + mQaRegistry.fill(HIST("h2NSigmaHe3ITS"), candidate.sign() * 2 * candidate.pt(), itsNsigmaHe3); return true; } // ================================================================================================================== - template - bool fillCandidateInfo(const Ttrack& trackHe3, const Ttrack& trackHad, const CollBracket& collBracket, const Tcollisions& collisions, he3HadCandidate& he3Hadcand, const Ttracks& /*trackTable*/, bool isMixedEvent) + template + std::array getCollisionVertex(const Tcollisions& collisions, int32_t collisionID) { - if (!isMixedEvent) { - auto trackCovHe3 = getTrackParCov(trackHe3); - auto trackCovHad = getTrackParCov(trackHad); - int nCand = 0; - try { - nCand = m_fitter.process(trackCovHe3, trackCovHad); - } catch (...) { - LOG(error) << "Exception caught in DCA fitter process call!"; - return false; - } - if (nCand == 0) { - return false; - } + auto collision = collisions.rawIteratorAt(collisionID); + std::array collisionVertex = {collision.posX(), collision.posY(), collision.posZ()}; + return collisionVertex; + } - // associate collision id as the one that minimises the distance between the vertex and the PCAs of the daughters - double distanceMin = -1; - unsigned int collIdxMin = 0; - - for (int collIdx = collBracket.getMin(); collIdx <= collBracket.getMax(); collIdx++) { - auto collision = collisions.rawIteratorAt(collIdx); - std::array collVtx = {collision.posX(), collision.posY(), collision.posZ()}; - const auto& PCA = m_fitter.getPCACandidate(); - float distance = 0; - for (int i = 0; i < 3; i++) { - distance += (PCA[i] - collVtx[i]) * (PCA[i] - collVtx[i]); - } - if (distanceMin < 0 || distance < distanceMin) { - distanceMin = distance; - collIdxMin = collIdx; - } - } + template + int32_t getCollisionID(const Ttrack& trackHe3, const Ttrack& trackHad, const CollBracket& collBracket, const Tcollisions& collisions, bool isMixedEvent) + { + if (isMixedEvent) { + return collBracket.getMin(); + } - if (!m_goodCollisions[collIdxMin]) { - return false; + auto trackCovHe3 = getTrackParCov(trackHe3); + auto trackCovHad = getTrackParCov(trackHad); + int nCand = CommonInite; + try { + nCand = mFitter.process(trackCovHe3, trackCovHad); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + return false; + } + if (nCand == 0) { + return false; + } + + // associate collision id as the one that minimises the distance between the vertex and the PCAs of the daughters + double distanceMin = -1; + unsigned int collIdxMin = 0; + const float defaultTodistance = 0.0f; + for (int collIdx = collBracket.getMin(); collIdx <= collBracket.getMax(); collIdx++) { + std::array collisionVertex = getCollisionVertex(collisions, collIdx); + const auto& pca = mFitter.getPCACandidate(); + float distance = defaultTodistance; + for (int i = 0; i < 3; i++) { + distance += (pca[i] - collisionVertex[i]) * (pca[i] - collisionVertex[i]); } - he3Hadcand.collisionID = collIdxMin; - } else { - he3Hadcand.collisionID = collBracket.getMin(); + if (distanceMin < 0 || distance < distanceMin) { + distanceMin = distance; + collIdxMin = collIdx; + } + } + + if (!mGoodCollisions[collIdxMin]) { + return false; } + return collIdxMin; + } + + template + bool fillCandidateInfo(const Ttrack& trackHe3, const Ttrack& trackHad, const CollBracket& collBracket, const Tcollisions& collisions, He3HadCandidate& he3Hadcand, const Ttracks& /*trackTable*/, bool isMixedEvent) + { + he3Hadcand.collisionID = getCollisionID(trackHe3, trackHad, collBracket, collisions, isMixedEvent); + std::array collisionVertex = getCollisionVertex(collisions, he3Hadcand.collisionID); he3Hadcand.momHe3 = std::array{trackHe3.px(), trackHe3.py(), trackHe3.pz()}; for (int i = 0; i < 3; i++) he3Hadcand.momHe3[i] = he3Hadcand.momHe3[i] * 2; he3Hadcand.momHad = std::array{trackHad.px(), trackHad.py(), trackHad.pz()}; - float invMass = 0; - if (setting_HadPDGCode == 211) { + float invMass = CommonInite; + if (settingHadPDGCode == PDG_t::kPiPlus) { invMass = RecoDecay::m(std::array{he3Hadcand.momHe3, he3Hadcand.momHad}, std::array{o2::constants::physics::MassHelium3, o2::constants::physics::MassPiPlus}); - } else if (setting_HadPDGCode == 2212) { + } else if (settingHadPDGCode == PDG_t::kProton) { invMass = RecoDecay::m(std::array{he3Hadcand.momHe3, he3Hadcand.momHad}, std::array{o2::constants::physics::MassHelium3, o2::constants::physics::MassProton}); } else { LOG(info) << "invalid PDG code for invMass"; } // float invMass = RecoDecay::m(std::array{he3Hadcand.momHe3, he3Hadcand.momHad}, std::array{o2::constants::physics::MassHelium3, o2::constants::physics::MassPiPlus}); - if (setting_cutInvMass > 0 && invMass > setting_cutInvMass) { + if (settingCutInvMass > 0 && invMass > settingCutInvMass) { return false; } float pthe3Had = std::hypot(he3Hadcand.momHe3[0] + he3Hadcand.momHad[0], he3Hadcand.momHe3[1] + he3Hadcand.momHad[1]); - if (pthe3Had < setting_cutPtMinhe3Had) { + if (pthe3Had < settingCutPtMinhe3Had) { return false; } he3Hadcand.signHe3 = trackHe3.sign(); he3Hadcand.signHad = trackHad.sign(); - he3Hadcand.DCAxyHe3 = trackHe3.dcaXY(); - he3Hadcand.DCAzHe3 = trackHe3.dcaZ(); - he3Hadcand.DCAxyHad = trackHad.dcaXY(); - he3Hadcand.DCAzHad = trackHad.dcaZ(); + // he3Hadcand.dcaxyHe3 = trackHe3.dcaXY(); + // he3Hadcand.dcaxyHad = trackHad.dcaXY(); + // he3Hadcand.dcazHe3 = trackHe3.dcaZ(); + // he3Hadcand.dcazHad = trackHad.dcaZ(); + auto trackCovHe3 = getTrackParCov(trackHe3); + auto trackCovHad = getTrackParCov(trackHad); + std::array dcaInfo; + o2::base::Propagator::Instance()->propagateToDCABxByBz({collisionVertex[0], collisionVertex[1], collisionVertex[2]}, trackCovHe3, 2.f, mFitter.getMatCorrType(), &dcaInfo); + he3Hadcand.dcaxyHe3 = dcaInfo[0]; + he3Hadcand.dcazHe3 = dcaInfo[1]; + o2::base::Propagator::Instance()->propagateToDCABxByBz({collisionVertex[0], collisionVertex[1], collisionVertex[2]}, trackCovHad, 2.f, mFitter.getMatCorrType(), &dcaInfo); + he3Hadcand.dcaxyHad = dcaInfo[0]; + he3Hadcand.dcazHad = dcaInfo[1]; + he3Hadcand.dcaPair = std::sqrt(std::abs(mFitter.getChi2AtPCACandidate())); he3Hadcand.tpcSignalHe3 = trackHe3.tpcSignal(); bool heliumPID = trackHe3.pidForTracking() == o2::track::PID::Helium3 || trackHe3.pidForTracking() == o2::track::PID::Alpha; - float correctedTPCinnerParamHe3 = (heliumPID && setting_compensatePIDinTracking) ? trackHe3.tpcInnerParam() / 2.f : trackHe3.tpcInnerParam(); + float correctedTPCinnerParamHe3 = (heliumPID && settingCompensatePIDinTracking) ? trackHe3.tpcInnerParam() / 2.f : trackHe3.tpcInnerParam(); he3Hadcand.momHe3TPC = correctedTPCinnerParamHe3; he3Hadcand.tpcSignalHad = trackHad.tpcSignal(); he3Hadcand.momHadTPC = trackHad.tpcInnerParam(); @@ -572,12 +639,17 @@ struct he3hadronfemto { he3Hadcand.chi2TPCHe3 = trackHe3.tpcChi2NCl(); he3Hadcand.chi2TPCHad = trackHad.tpcChi2NCl(); - he3Hadcand.PIDtrkHe3 = trackHe3.pidForTracking(); - he3Hadcand.PIDtrkHad = trackHad.pidForTracking(); + he3Hadcand.pidtrkHe3 = trackHe3.pidForTracking(); + he3Hadcand.pidtrkHad = trackHad.pidForTracking(); he3Hadcand.itsClSizeHe3 = trackHe3.itsClusterSizes(); he3Hadcand.itsClSizeHad = trackHad.itsClusterSizes(); + he3Hadcand.nclsITSHe3 = trackHe3.itsNCls(); + he3Hadcand.nclsITSHad = trackHad.itsNCls(); + he3Hadcand.chi2nclITSHe3 = trackHe3.itsChi2NCl(); + he3Hadcand.chi2nclITSHad = trackHad.itsChi2NCl(); + he3Hadcand.sharedClustersHe3 = trackHe3.tpcNClsShared(); he3Hadcand.sharedClustersHad = trackHad.tpcNClsShared(); @@ -593,7 +665,7 @@ struct he3hadronfemto { float beta = o2::pid::tof::Beta::GetBeta(trackHe3); beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked bool heliumPID = trackHe3.pidForTracking() == o2::track::PID::Helium3 || trackHe3.pidForTracking() == o2::track::PID::Alpha; - float correctedTPCinnerParamHe3 = (heliumPID && setting_compensatePIDinTracking) ? trackHe3.tpcInnerParam() / 2.f : trackHe3.tpcInnerParam(); + float correctedTPCinnerParamHe3 = (heliumPID && settingCompensatePIDinTracking) ? trackHe3.tpcInnerParam() / 2.f : trackHe3.tpcInnerParam(); he3Hadcand.massTOFHe3 = correctedTPCinnerParamHe3 * 2.f * std::sqrt(1.f / (beta * beta) - 1.f); } if (trackHad.hasTOF()) { @@ -606,7 +678,7 @@ struct he3hadronfemto { } template - void fillCandidateInfoMC(const Mc& mctrackHe3, const Mc& mctrackHad, const Mc& mctrackMother, he3HadCandidate& he3Hadcand) + void fillCandidateInfoMC(const Mc& mctrackHe3, const Mc& mctrackHad, He3HadCandidate& he3Hadcand) { he3Hadcand.momHe3MC = mctrackHe3.pt() * (mctrackHe3.pdgCode() > 0 ? 1 : -1); he3Hadcand.etaHe3MC = mctrackHe3.eta(); @@ -614,6 +686,11 @@ struct he3hadronfemto { he3Hadcand.momHadMC = mctrackHad.pt() * (mctrackHad.pdgCode() > 0 ? 1 : -1); he3Hadcand.etaHadMC = mctrackHad.eta(); he3Hadcand.phiHadMC = mctrackHad.phi(); + } + + template + void fillMotherInfoMC(const Mc& mctrackHe3, const Mc& mctrackHad, const Mc& mctrackMother, He3HadCandidate& he3Hadcand) + { he3Hadcand.l4PtMC = mctrackMother.pt() * (mctrackMother.pdgCode() > 0 ? 1 : -1); const double eLit = mctrackHe3.e() + mctrackHad.e(); he3Hadcand.l4MassMC = std::sqrt(eLit * eLit - mctrackMother.p() * mctrackMother.p()); @@ -622,31 +699,31 @@ struct he3hadronfemto { template void pairTracksSameEvent(const Ttrack& tracks) { - for (auto track0 : tracks) { + for (const auto& track0 : tracks) { - m_qaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); + mQaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); if (!selectTrack(track0)) { continue; } - m_qaRegistry.fill(HIST("hTrackSel"), Selections::kTrackCuts); + mQaRegistry.fill(HIST("hTrackSel"), Selections::kTrackCuts); if (!selectionPIDHe3(track0)) { continue; } - m_qaRegistry.fill(HIST("hTrackSel"), Selections::kPID); + mQaRegistry.fill(HIST("hTrackSel"), Selections::kPID); - for (auto track1 : tracks) { + for (const auto& track1 : tracks) { if (track0 == track1) { continue; } - if (!setting_saveUSandLS) { - if (!setting_enableBkgUS && (track0.sign() * track1.sign() < 0)) { + if (!settingSaveUSandLS) { + if (!settingEnableBkgUS && (track0.sign() * track1.sign() < 0)) { continue; } - if (setting_enableBkgUS && (track0.sign() * track1.sign() > 0)) { + if (settingEnableBkgUS && (track0.sign() * track1.sign() > 0)) { continue; } } @@ -661,7 +738,7 @@ struct he3hadronfemto { const int collIdx = track0.collisionId(); CollBracket collBracket{collIdx, collIdx}; trackPair.collBracket = collBracket; - m_trackPairs.push_back(trackPair); + mTrackPairs.push_back(trackPair); } } } @@ -669,11 +746,11 @@ struct he3hadronfemto { template void pairTracksEventMixing(T& he3Cands, T& hadronCands) { - for (auto& he3Cand : he3Cands) { + for (const auto& he3Cand : he3Cands) { if (!selectTrack(he3Cand) || !selectionPIDHe3(he3Cand)) { continue; } - for (auto& hadronCand : hadronCands) { + for (const auto& hadronCand : hadronCands) { if (!selectTrack(hadronCand) || !selectionPIDHadron(hadronCand)) { continue; } @@ -684,25 +761,26 @@ struct he3hadronfemto { const int collIdx = he3Cand.collisionId(); CollBracket collBracket{collIdx, collIdx}; trackPair.collBracket = collBracket; - m_trackPairs.push_back(trackPair); + mTrackPairs.push_back(trackPair); } } } template - void fillTable(const he3HadCandidate& he3Hadcand, const Tcoll& collision, bool isMC = false) + void fillTable(const He3HadCandidate& he3Hadcand, const Tcoll& collision, bool isMC = false) { - m_outputDataTable( + outputDataTable( he3Hadcand.recoPtHe3(), he3Hadcand.recoEtaHe3(), he3Hadcand.recoPhiHe3(), he3Hadcand.recoPtHad(), he3Hadcand.recoEtaHad(), he3Hadcand.recoPhiHad(), - he3Hadcand.DCAxyHe3, - he3Hadcand.DCAzHe3, - he3Hadcand.DCAxyHad, - he3Hadcand.DCAzHad, + he3Hadcand.dcaxyHe3, + he3Hadcand.dcazHe3, + he3Hadcand.dcaxyHad, + he3Hadcand.dcazHad, + he3Hadcand.dcaPair, he3Hadcand.tpcSignalHe3, he3Hadcand.momHe3TPC, he3Hadcand.tpcSignalHad, @@ -714,8 +792,8 @@ struct he3hadronfemto { he3Hadcand.chi2TPCHad, he3Hadcand.massTOFHe3, he3Hadcand.massTOFHad, - he3Hadcand.PIDtrkHe3, - he3Hadcand.PIDtrkHad, + he3Hadcand.pidtrkHe3, + he3Hadcand.pidtrkHad, he3Hadcand.itsClSizeHe3, he3Hadcand.itsClSizeHad, he3Hadcand.sharedClustersHe3, @@ -723,7 +801,7 @@ struct he3hadronfemto { he3Hadcand.isBkgUS, he3Hadcand.isBkgEM); if (isMC) { - m_outputMCTable( + outputMcTable( he3Hadcand.momHe3MC, he3Hadcand.etaHe3MC, he3Hadcand.phiHe3MC, @@ -731,10 +809,11 @@ struct he3hadronfemto { he3Hadcand.etaHadMC, he3Hadcand.phiHadMC, he3Hadcand.l4PtMC, - he3Hadcand.l4MassMC); + he3Hadcand.l4MassMC, + he3Hadcand.flags); } - if (setting_fillMultiplicity) { - m_outputMultiplicityTable( + if (settingFillMultiplicity) { + outputMultiplicityTable( collision.globalIndex(), collision.posZ(), collision.numContrib(), @@ -743,13 +822,17 @@ struct he3hadronfemto { } } - void fillHistograms(const he3HadCandidate& he3Hadcand) + void fillHistograms(const He3HadCandidate& he3Hadcand) { - m_qaRegistry.fill(HIST("hHe3Pt"), he3Hadcand.recoPtHe3()); - m_qaRegistry.fill(HIST("hHadronPt"), he3Hadcand.recoPtHad()); - m_qaRegistry.fill(HIST("hhe3HadtInvMass"), he3Hadcand.invMass); - m_qaRegistry.fill(HIST("hDCAxyHe3"), he3Hadcand.DCAxyHe3); - m_qaRegistry.fill(HIST("hDCAzHe3"), he3Hadcand.DCAzHe3); + mQaRegistry.fill(HIST("hHe3Pt"), he3Hadcand.recoPtHe3()); + mQaRegistry.fill(HIST("hHadronPt"), he3Hadcand.recoPtHad()); + mQaRegistry.fill(HIST("hhe3HadtInvMass"), he3Hadcand.invMass); + mQaRegistry.fill(HIST("hDCAxyHe3"), he3Hadcand.dcaxyHe3); + mQaRegistry.fill(HIST("hDCAzHe3"), he3Hadcand.dcazHe3); + mQaRegistry.fill(HIST("hNClsHe3ITS"), he3Hadcand.nclsITSHe3); + mQaRegistry.fill(HIST("hNClsHadITS"), he3Hadcand.nclsITSHad); + mQaRegistry.fill(HIST("hChi2NClHe3ITS"), he3Hadcand.chi2nclITSHe3); + mQaRegistry.fill(HIST("hChi2NClHadITS"), he3Hadcand.chi2nclITSHad); } // ================================================================================================================== @@ -757,13 +840,13 @@ struct he3hadronfemto { template void fillPairs(const Tcollisions& collisions, const Ttracks& tracks, const bool isMixedEvent) { - for (auto& trackPair : m_trackPairs) { + for (const auto& trackPair : mTrackPairs) { auto heTrack = tracks.rawIteratorAt(trackPair.tr0Idx); auto hadTrack = tracks.rawIteratorAt(trackPair.tr1Idx); auto collBracket = trackPair.collBracket; - he3HadCandidate he3Hadcand; + He3HadCandidate he3Hadcand; if (!fillCandidateInfo(heTrack, hadTrack, collBracket, collisions, he3Hadcand, tracks, isMixedEvent)) { continue; } @@ -773,12 +856,73 @@ struct he3hadronfemto { } } + template + void setMcParticleFlag(const TmcParticle& mcParticle, std::vector& mothers, uint8_t& flag) + { + if (mcParticle.isPhysicalPrimary()) { + + flag |= ParticleFlags::kPhysicalPrimary; + if (!mcParticle.has_mothers()) { + return; + } + + for (const auto& mother : mcParticle.template mothers_as()) { + mothers.push_back(mother.globalIndex()); + if (std::abs(mother.pdgCode()) == Li4PDG) { + flag |= ParticleFlags::kFromLi4; + } else if (std::abs(mother.pdgCode()) == H3LPDG) { + flag |= ParticleFlags::kFromHypertriton; + } else { + flag |= ParticleFlags::kFromOtherDecays; + } + } + + } else { + + if (!mcParticle.has_mothers()) { + flag |= ParticleFlags::kFromMaterial; + return; + } + + for (const auto& mother : mcParticle.template mothers_as()) { + mothers.push_back(mother.globalIndex()); + if (std::abs(mother.pdgCode()) == Li4PDG) { + flag |= ParticleFlags::kFromLi4; + } else if (std::abs(mother.pdgCode()) == H3LPDG) { + flag |= ParticleFlags::kFromHypertriton; + } else { + flag |= ParticleFlags::kFromOtherDecays; + } + } + } + } + + void searchForCommonMotherTrack(const std::vector& motherHe3Idxs, const std::vector& motherHadIdxs, const aod::McParticles& mcParticles, McIter& motherParticle, He3HadCandidate& he3Hadcand, bool& isMixedPair, const int motherPdgCode) + { + std::unordered_set motherHe3SetIdxs(motherHe3Idxs.begin(), motherHe3Idxs.end()); + for (const auto& motherHadIdx : motherHadIdxs) { + if (!motherHe3SetIdxs.contains(motherHadIdx)) { + continue; + } + + motherParticle = mcParticles.rawIteratorAt(motherHadIdx); + if (std::abs(motherParticle.pdgCode()) != motherPdgCode || std::abs(motherParticle.y()) > 1) { + continue; + } + isMixedPair = false; + break; + } + if (!isMixedPair) { + he3Hadcand.flags |= Flags::kBothFromLi4; + } + } + template void fillMcParticles(const Tcollisions& collisions, const TmcParticles& mcParticles, std::vector& filledMothers) { - for (auto& mcParticle : mcParticles) { + for (const auto& mcParticle : mcParticles) { - if (std::abs(mcParticle.pdgCode()) != li4PDG || std::abs(mcParticle.y()) > 1 || mcParticle.isPhysicalPrimary() == false) { + if (std::abs(mcParticle.pdgCode()) != Li4PDG || std::abs(mcParticle.y()) > 1 || mcParticle.isPhysicalPrimary() == false) { continue; } @@ -789,18 +933,19 @@ struct he3hadronfemto { auto kDaughters = mcParticle.template daughters_as(); bool daughtHe3(false), daughtHad(false); McIter mcHe3, mcHad; - for (auto kCurrentDaughter : kDaughters) { - if (std::abs(kCurrentDaughter.pdgCode()) == hePDG) { + for (const auto& kCurrentDaughter : kDaughters) { + if (std::abs(kCurrentDaughter.pdgCode()) == He3PDG) { daughtHe3 = true; mcHe3 = kCurrentDaughter; - } else if (std::abs(kCurrentDaughter.pdgCode()) == prPDG) { + } else if (std::abs(kCurrentDaughter.pdgCode()) == ProtonPDG) { daughtHad = true; mcHad = kCurrentDaughter; } } if (daughtHe3 && daughtHad) { - he3HadCandidate he3Hadcand; - fillCandidateInfoMC(mcHe3, mcHad, mcParticle, he3Hadcand); + He3HadCandidate he3Hadcand; + fillCandidateInfoMC(mcHe3, mcHad, he3Hadcand); + fillMotherInfoMC(mcHe3, mcHad, mcParticle, he3Hadcand); auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); fillTable(he3Hadcand, collision, /*isMC*/ true); } @@ -811,45 +956,45 @@ struct he3hadronfemto { void processSameEvent(const CollisionsFull& collisions, const TrackCandidates& tracks, const aod::BCsWithTimestamps& bcs) { - m_goodCollisions.clear(); - m_goodCollisions.resize(collisions.size(), false); + mGoodCollisions.clear(); + mGoodCollisions.resize(collisions.size(), false); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { - m_trackPairs.clear(); + mTrackPairs.clear(); if (!selectCollision(collision, bcs)) { continue; } - m_goodCollisions[collision.globalIndex()] = true; + mGoodCollisions[collision.globalIndex()] = true; const uint64_t collIdx = collision.globalIndex(); - auto TrackTable_thisCollision = tracks.sliceBy(m_perCol, collIdx); - TrackTable_thisCollision.bindExternalIndices(&tracks); + auto trackTableThisCollision = tracks.sliceBy(mPerCol, collIdx); + trackTableThisCollision.bindExternalIndices(&tracks); - pairTracksSameEvent(TrackTable_thisCollision); + pairTracksSameEvent(trackTableThisCollision); - if (m_trackPairs.size() == 0) { + if (mTrackPairs.size() == 0) { continue; } fillPairs(collisions, tracks, /*isMixedEvent*/ false); } } - PROCESS_SWITCH(he3hadronfemto, processSameEvent, "Process Same event", false); + PROCESS_SWITCH(he3HadronFemto, processSameEvent, "Process Same event", false); void processMixedEvent(const CollisionsFull& collisions, const TrackCandidates& tracks) { LOG(debug) << "Processing mixed event"; - m_trackPairs.clear(); + mTrackPairs.clear(); - for (auto& [c1, tracks1, c2, tracks2] : m_pair) { + for (const auto& [c1, tracks1, c2, tracks2] : mPair) { if (!c1.sel8() || !c2.sel8()) { continue; } - m_qaRegistry.fill(HIST("hNcontributor"), c1.numContrib()); - m_qaRegistry.fill(HIST("hVtxZ"), c1.posZ()); + mQaRegistry.fill(HIST("hNcontributor"), c1.numContrib()); + mQaRegistry.fill(HIST("hVtxZ"), c1.posZ()); pairTracksEventMixing(tracks1, tracks2); pairTracksEventMixing(tracks2, tracks1); @@ -857,31 +1002,31 @@ struct he3hadronfemto { fillPairs(collisions, tracks, /*isMixedEvent*/ true); } - PROCESS_SWITCH(he3hadronfemto, processMixedEvent, "Process Mixed event", false); + PROCESS_SWITCH(he3HadronFemto, processMixedEvent, "Process Mixed event", false); void processMC(const CollisionsFullMC& collisions, const aod::BCsWithTimestamps& bcs, const TrackCandidatesMC& tracks, const aod::McParticles& mcParticles) { std::vector filledMothers; - m_goodCollisions.clear(); - m_goodCollisions.resize(collisions.size(), false); + mGoodCollisions.clear(); + mGoodCollisions.resize(collisions.size(), false); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { - m_trackPairs.clear(); + mTrackPairs.clear(); if (!selectCollision(collision, bcs)) { continue; } const uint64_t collIdx = collision.globalIndex(); - m_goodCollisions[collIdx] = true; - auto TrackTable_thisCollision = tracks.sliceBy(m_perColMC, collIdx); - TrackTable_thisCollision.bindExternalIndices(&tracks); + mGoodCollisions[collIdx] = true; + auto trackTableThisCollision = tracks.sliceBy(mPerColMC, collIdx); + trackTableThisCollision.bindExternalIndices(&tracks); - pairTracksSameEvent(TrackTable_thisCollision); + pairTracksSameEvent(trackTableThisCollision); - for (auto& trackPair : m_trackPairs) { + for (const auto& trackPair : mTrackPairs) { auto heTrack = tracks.rawIteratorAt(trackPair.tr0Idx); auto prTrack = tracks.rawIteratorAt(trackPair.tr1Idx); @@ -894,121 +1039,206 @@ struct he3hadronfemto { auto mctrackHe3 = heTrack.mcParticle(); auto mctrackHad = prTrack.mcParticle(); - if (std::abs(mctrackHe3.pdgCode()) != hePDG || std::abs(mctrackHad.pdgCode()) != prPDG) { + if (std::abs(mctrackHe3.pdgCode()) != He3PDG || std::abs(mctrackHad.pdgCode()) != settingHadPDGCode) { continue; } - for (auto& mothertrack : mctrackHe3.mothers_as()) { - for (auto& mothertrackHad : mctrackHad.mothers_as()) { - - if (mothertrack != mothertrackHad || std::abs(mothertrack.pdgCode()) != li4PDG || std::abs(mothertrack.y()) > 1) { - continue; - } - - he3HadCandidate he3Hadcand; - if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) { - continue; - } - fillCandidateInfoMC(mctrackHe3, mctrackHad, mothertrack, he3Hadcand); - fillHistograms(he3Hadcand); - auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); - fillTable(he3Hadcand, collision, /*isMC*/ true); - filledMothers.push_back(mothertrack.globalIndex()); + He3HadCandidate he3Hadcand; + McIter motherParticle; + std::vector motherHe3Idxs, motherHadIdxs; + setMcParticleFlag(mctrackHe3, motherHe3Idxs, he3Hadcand.flagsHe3); + setMcParticleFlag(mctrackHad, motherHadIdxs, he3Hadcand.flagsHad); + + bool isMixedPair = true; + + if ((he3Hadcand.flagsHe3 == ParticleFlags::kPhysicalPrimary && he3Hadcand.flagsHad == ParticleFlags::kPhysicalPrimary)) { + he3Hadcand.flags |= Flags::kBothPrimaries; + isMixedPair = false; + + } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromLi4) && (he3Hadcand.flagsHad & ParticleFlags::kFromLi4)) { + + searchForCommonMotherTrack(motherHe3Idxs, motherHadIdxs, mcParticles, motherParticle, he3Hadcand, isMixedPair, Li4PDG); + if (!isMixedPair) { + he3Hadcand.flags |= Flags::kBothFromLi4; + } + + } else if ((he3Hadcand.flagsHe3 & ParticleFlags::kFromHypertriton) && (he3Hadcand.flagsHad & ParticleFlags::kFromHypertriton)) { + + searchForCommonMotherTrack(motherHe3Idxs, motherHadIdxs, mcParticles, motherParticle, he3Hadcand, isMixedPair, H3LPDG); + if (!isMixedPair) { + he3Hadcand.flags |= Flags::kBothFromHypertriton; } } + + if (isMixedPair) { + he3Hadcand.flags |= Flags::kMixedPair; + } + + if (!settingFillPrimariesAndMixedMc && ((he3Hadcand.flags == Flags::kMixedPair) || he3Hadcand.flags == Flags::kBothPrimaries)) { + continue; + } + + if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) { + continue; + } + fillCandidateInfoMC(mctrackHe3, mctrackHad, he3Hadcand); + + if ((he3Hadcand.flags == Flags::kBothFromLi4) || (he3Hadcand.flags == Flags::kBothFromHypertriton)) { + fillMotherInfoMC(mctrackHe3, mctrackHad, motherParticle, he3Hadcand); + filledMothers.push_back(motherParticle.globalIndex()); + } + + fillHistograms(he3Hadcand); + auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); + fillTable(he3Hadcand, collision, /*isMC*/ true); } } fillMcParticles(collisions, mcParticles, filledMothers); } - PROCESS_SWITCH(he3hadronfemto, processMC, "Process MC", false); + PROCESS_SWITCH(he3HadronFemto, processMC, "Process MC", false); + + void processPiHe3MC(const CollisionsFullMC& collisions, const aod::BCsWithTimestamps& bcs, const TrackCandidatesMC& tracks, const aod::McParticles& /* mcParticles */) + { + mGoodCollisions.clear(); + mGoodCollisions.resize(collisions.size(), false); + + LOG(info) << "processPiHe3MC begin"; + + for (const auto& collision : collisions) { + + mTrackPairs.clear(); + + if (!selectCollision(collision, bcs)) { + continue; + } + + const uint64_t collIdx = collision.globalIndex(); + mGoodCollisions[collIdx] = true; + auto trackTableThisCollision = tracks.sliceBy(mPerColMC, collIdx); + trackTableThisCollision.bindExternalIndices(&tracks); + + pairTracksSameEvent(trackTableThisCollision); + + for (const auto& trackPair : mTrackPairs) { + + auto heTrack = tracks.rawIteratorAt(trackPair.tr0Idx); + auto piTrack = tracks.rawIteratorAt(trackPair.tr1Idx); + auto collBracket = trackPair.collBracket; + + if (!heTrack.has_mcParticle() || !piTrack.has_mcParticle()) { + continue; + } + + auto mctrackHe3 = heTrack.mcParticle(); + auto mctrackHad = piTrack.mcParticle(); + + if (std::abs(mctrackHe3.pdgCode()) != He3PDG || std::abs(mctrackHad.pdgCode()) != PionPDG) { + continue; + } + LOG(info) << "only pi-He3"; + + He3HadCandidate he3Hadcand; + if (!fillCandidateInfo(heTrack, piTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) { + continue; + } + + fillCandidateInfoMC(mctrackHe3, mctrackHad, he3Hadcand); + fillHistograms(he3Hadcand); + LOG(info) << "fillHistograms done"; + auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); + fillTable(he3Hadcand, collision, /*isMC*/ true); + } + } + } + PROCESS_SWITCH(he3HadronFemto, processPiHe3MC, "Process pi-He3 MC", false); void processSameEventPools(const CollisionsFull& collisions, const TrackCandidates& tracks, const aod::AmbiguousTracks& ambiguousTracks, const aod::BCsWithTimestamps& bcs) { - m_goodCollisions.clear(); - m_goodCollisions.resize(collisions.size(), false); + mGoodCollisions.clear(); + mGoodCollisions.resize(collisions.size(), false); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { if (selectCollision(collision, bcs)) { - m_goodCollisions[collision.globalIndex()] = true; + mGoodCollisions[collision.globalIndex()] = true; } } - m_svPoolCreator.clearPools(); - m_svPoolCreator.fillBC2Coll(collisions, bcs); + mSvPoolCreator.clearPools(); + mSvPoolCreator.fillBC2Coll(collisions, bcs); - for (auto& track : tracks) { + for (const auto& track : tracks) { - m_qaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); + mQaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); if (!selectTrack(track)) continue; - m_qaRegistry.fill(HIST("hTrackSel"), Selections::kTrackCuts); + mQaRegistry.fill(HIST("hTrackSel"), Selections::kTrackCuts); bool selHad = selectionPIDHadron(track); bool selHe = selectionPIDHe3(track); if ((!selHad && !selHe) || (selHad && selHe)) { continue; } - m_qaRegistry.fill(HIST("hTrackSel"), Selections::kPID); + mQaRegistry.fill(HIST("hTrackSel"), Selections::kPID); - int pdgHypo = selHe ? hePDG : prPDG; + int pdgHypo = selHe ? He3PDG : ProtonPDG; - m_svPoolCreator.appendTrackCand(track, collisions, pdgHypo, ambiguousTracks, bcs); + mSvPoolCreator.appendTrackCand(track, collisions, pdgHypo, ambiguousTracks, bcs); } - m_trackPairs = m_svPoolCreator.getSVCandPool(collisions, true); - if (m_trackPairs.size() == 0) { - m_qaRegistry.fill(HIST("hEmptyPool"), 1); + mTrackPairs = mSvPoolCreator.getSVCandPool(collisions, true); + if (mTrackPairs.size() == 0) { + mQaRegistry.fill(HIST("hEmptyPool"), 1); return; } - m_qaRegistry.fill(HIST("hEmptyPool"), 0); + mQaRegistry.fill(HIST("hEmptyPool"), 0); fillPairs(collisions, tracks, /*isMixedEvent*/ false); } - PROCESS_SWITCH(he3hadronfemto, processSameEventPools, "Process Same event pools", false); + PROCESS_SWITCH(he3HadronFemto, processSameEventPools, "Process Same event pools", false); void processMcPools(const CollisionsFullMC& collisions, const TrackCandidatesMC& tracks, const aod::AmbiguousTracks& ambiguousTracks, const aod::BCsWithTimestamps& bcs, const aod::McParticles& mcParticles, const aod::McTrackLabels& mcTrackLabels) { std::vector filledMothers; - m_goodCollisions.clear(); - m_goodCollisions.resize(collisions.size(), false); + mGoodCollisions.clear(); + mGoodCollisions.resize(collisions.size(), false); - for (auto& collision : collisions) { + for (const auto& collision : collisions) { if (selectCollision(collision, bcs)) { - m_goodCollisions[collision.globalIndex()] = true; + mGoodCollisions[collision.globalIndex()] = true; } } - m_svPoolCreator.clearPools(); - m_svPoolCreator.fillBC2Coll(collisions, bcs); + mSvPoolCreator.clearPools(); + mSvPoolCreator.fillBC2Coll(collisions, bcs); - for (auto& track : tracks) { + for (const auto& track : tracks) { - m_qaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); + mQaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); if (!selectTrack(track)) continue; - m_qaRegistry.fill(HIST("hTrackSel"), Selections::kTrackCuts); + mQaRegistry.fill(HIST("hTrackSel"), Selections::kTrackCuts); bool selHad = selectionPIDHadron(track); bool selHe = selectionPIDHe3(track); if ((!selHad && !selHe) || (selHad && selHe)) continue; - m_qaRegistry.fill(HIST("hTrackSel"), Selections::kPID); + mQaRegistry.fill(HIST("hTrackSel"), Selections::kPID); - int pdgHypo = selHe ? hePDG : prPDG; + int pdgHypo = selHe ? He3PDG : ProtonPDG; - m_svPoolCreator.appendTrackCand(track, collisions, pdgHypo, ambiguousTracks, bcs); + mSvPoolCreator.appendTrackCand(track, collisions, pdgHypo, ambiguousTracks, bcs); } - auto& svPool = m_svPoolCreator.getSVCandPool(collisions, true); + auto& svPool = mSvPoolCreator.getSVCandPool(collisions, true); if (svPool.size() == 0) { - m_qaRegistry.fill(HIST("hEmptyPool"), 1); + mQaRegistry.fill(HIST("hEmptyPool"), 1); return; } - m_qaRegistry.fill(HIST("hEmptyPool"), 0); + mQaRegistry.fill(HIST("hEmptyPool"), 0); - for (auto& svCand : svPool) { + for (const auto& svCand : svPool) { auto heTrack = tracks.rawIteratorAt(svCand.tr0Idx); auto prTrack = tracks.rawIteratorAt(svCand.tr1Idx); auto heTrackLabel = mcTrackLabels.rawIteratorAt(svCand.tr0Idx); @@ -1022,22 +1252,23 @@ struct he3hadronfemto { auto mctrackHe3 = heTrackLabel.mcParticle_as(); auto mctrackHad = prTrackLabel.mcParticle_as(); - if (std::abs(mctrackHe3.pdgCode()) != hePDG || std::abs(mctrackHad.pdgCode()) != prPDG || !mctrackHe3.has_mothers() || !mctrackHad.has_mothers()) { + if (std::abs(mctrackHe3.pdgCode()) != He3PDG || std::abs(mctrackHad.pdgCode()) != ProtonPDG || !mctrackHe3.has_mothers() || !mctrackHad.has_mothers()) { continue; } - for (auto& mothertrackHe : mctrackHe3.mothers_as()) { - for (auto& mothertrackHad : mctrackHad.mothers_as()) { + for (const auto& mothertrackHe : mctrackHe3.mothers_as()) { + for (const auto& mothertrackHad : mctrackHad.mothers_as()) { - if (mothertrackHe.globalIndex() != mothertrackHad.globalIndex() || std::abs(mothertrackHe.pdgCode()) != li4PDG || std::abs(mothertrackHe.y()) > 1) { + if (mothertrackHe.globalIndex() != mothertrackHad.globalIndex() || std::abs(mothertrackHe.pdgCode()) != Li4PDG || std::abs(mothertrackHe.y()) > 1) { continue; } - he3HadCandidate he3Hadcand; + He3HadCandidate he3Hadcand; if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) { continue; } - fillCandidateInfoMC(mctrackHe3, mctrackHad, mothertrackHe, he3Hadcand); + fillCandidateInfoMC(mctrackHe3, mctrackHad, he3Hadcand); + fillMotherInfoMC(mctrackHe3, mctrackHad, mothertrackHe, he3Hadcand); fillHistograms(he3Hadcand); auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); fillTable(he3Hadcand, collision, /*isMC*/ true); @@ -1048,11 +1279,11 @@ struct he3hadronfemto { fillMcParticles(collisions, mcParticles, filledMothers); } - PROCESS_SWITCH(he3hadronfemto, processMcPools, "Process MC pools", false); + PROCESS_SWITCH(he3HadronFemto, processMcPools, "Process MC pools", false); }; WorkflowSpec defineDataProcessing(const ConfigContext& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"he3hadronfemto"})}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Nuspex/he3LambdaAnalysis.cxx b/PWGLF/TableProducer/Nuspex/he3LambdaAnalysis.cxx new file mode 100644 index 00000000000..9482de6d51e --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/he3LambdaAnalysis.cxx @@ -0,0 +1,401 @@ +// 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. + +#include "PWGLF/DataModel/LFSlimHeLambda.h" + +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +namespace +{ +constexpr double betheBlochDefault[1][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}}; +static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; +static const std::vector particleName{"He3"}; +o2::base::MatLayerCylSet* matLUT = nullptr; + +float alphaAP(std::array const& momA, std::array const& momB, std::array const& momC) +{ + const float lQlPos = (momB[0] * momA[0] + momB[1] * momA[1] + momB[2] * momA[2]); + const float lQlNeg = (momC[0] * momA[0] + momC[1] * momA[1] + momC[2] * momA[2]); + return (lQlPos - lQlNeg) / (lQlPos + lQlNeg); +} + +float qtAP(std::array const& momA, std::array const& momB) +{ + const float dp = momA[0] * momB[0] + momA[1] * momB[1] + momA[2] * momB[2]; + const float p2A = momA[0] * momA[0] + momA[1] * momA[1] + momA[2] * momA[2]; + const float p2B = momB[0] * momB[0] + momB[1] * momB[1] + momB[2] * momB[2]; + return std::sqrt(p2B - dp * dp / p2A); +} + +std::shared_ptr hTPCsignalAll; +std::shared_ptr hTPCsignalHe3; +std::shared_ptr hTPCnSigmaAll; +std::shared_ptr hTPCnSigmaHe3; +std::shared_ptr hArmenterosPodolanskiAll; +std::shared_ptr hArmenterosPodolanskiSelected; +std::shared_ptr hInvariantMassUS; +std::shared_ptr hInvariantMassLS; + +}; // namespace + +using TracksFull = soa::Join; +using CollisionsFull = soa::Join; + +struct he3LambdaAnalysis { + + // Services + Service ccdb; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + o2::vertexing::DCAFitterN<2> fitter; + + Produces lfHe3V0Collision; + Produces lfHe3; + Produces lfLambda; + + // Configurables for event selection + struct : ConfigurableGroup { + std::string prefix = "cfgEventSelection"; + Configurable zVertexMax{"zVertexMax", 10.0f, "Accepted z-vertex range"}; + Configurable useSel8{"useSel8", true, "Use Sel8 event selection"}; + Configurable skimmedProcessing{"skimmedProcessing", false, "Skimmed dataset processing"}; + } cfgEventSelection; + + // He3 selection criteria + struct : ConfigurableGroup { + std::string prefix = "cfgHe3"; + Configurable ptMin{"ptMin", 1.0f, "Minimum He3 pT"}; + Configurable ptMax{"ptMax", 10.0f, "Maximum He3 pT"}; + Configurable etaMax{"etaMax", 0.9f, "Maximum He3 pseudorapidity"}; + Configurable minTPCrigidity{"minTPCrigidity", 0.5f, "Minimum He3 rigidity"}; + Configurable nSigmaTPCMax{"nSigmaTPCMax", 4.0f, "Maximum He3 TPC nSigma"}; + Configurable dcaxyMax{"dcaxyMax", 0.5f, "Maximum He3 DCA xy"}; + Configurable dcazMax{"dcazMax", 0.5f, "Maximum He3 DCA z"}; + Configurable tpcClusMin{"tpcClusMin", 100, "Minimum He3 TPC clusters"}; + Configurable itsClusMin{"itsClusMin", 5, "Minimum He3 ITS clusters"}; + Configurable> betheBlochParams{"betheBlochParams", {betheBlochDefault[0], 1, 6, particleName, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for He3"}; + } cfgHe3; + + // Lambda selection criteria + struct : ConfigurableGroup { + std::string prefix = "cfgLambda"; + Configurable ptMin{"ptMin", 0.5f, "Minimum Lambda pT"}; + Configurable ptMax{"ptMax", 10.0f, "Maximum Lambda pT"}; + Configurable massWindow{"massWindow", 0.015f, "Lambda mass window"}; + Configurable cosPAMin{"cosPAMin", 0.99f, "Minimum Lambda cosPA"}; + Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 0.5f, "Maximum Lambda DCA V0 daughters"}; + Configurable v0RadiusMin{"v0RadiusMin", 0.5f, "Minimum Lambda V0 radius"}; + Configurable v0RadiusMax{"v0RadiusMax", 35.0f, "Maximum Lambda V0 radius"}; + Configurable tpcNClsMin{"tpcNClsMin", 70, "Minimum TPC clusters for Lambda daughters"}; + Configurable protonNSigmaTPCMax{"protonNSigmaTPCMax", 4.0f, "Maximum proton TPC nSigma"}; + Configurable pionNSigmaTPCMax{"pionNSigmaTPCMax", 4.0f, "Maximum pion TPC nSigma"}; + } cfgLambda; + + // Pair selection criteria + struct : ConfigurableGroup { + std::string prefix = "cfgPair"; + Configurable ptMin{"PtMin", 1.0f, "Minimum pair pT"}; + Configurable ptMax{"PtMax", 20.0f, "Maximum pair pT"}; + Configurable rapidityMax{"RapidityMax", 0.5f, "Maximum pair rapidity"}; + } cfgPair; + + // CCDB options + struct : ConfigurableGroup { + std::string prefix = "ccdb"; + Configurable url{"url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + } ccdbOptions; + + std::array mBBparamsHe; + float mBz = 0.0f; // Magnetic field in T + HistogramRegistry mRegistry{"He3LambdaAnalysis"}; + int mRunNumber = 0; // Current run number + + void init(InitContext const&) + { + // Initialize CCDB + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(true); + + for (int i = 0; i < 5; i++) { + mBBparamsHe[i] = cfgHe3.betheBlochParams->get("He3", Form("p%i", i)); + } + mBBparamsHe[5] = cfgHe3.betheBlochParams->get("He3", "resolution"); + matLUT = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); + + fitter.setPropagateToPCA(true); + fitter.setMaxR(200.); + fitter.setMinParamChange(1e-3); + fitter.setMinRelChi2Change(0.9); + fitter.setMaxDZIni(1e9); + fitter.setMaxChi2(1e9); + fitter.setUseAbsDCA(true); + fitter.setMatCorrType(o2::base::Propagator::MatCorrType::USEMatCorrLUT); + + zorroSummary.setObject(zorro.getZorroSummary()); + + mRegistry.add("hEventSelection", "Event Selection", {HistType::kTH1L, {{6, -.5, 5.5}}}); + std::vector labels{"Total Events", "Sel8 Events", "Z-Vertex OK", "Additional Event Selections", "He3 Candidates Found", "He3 and Lambda Candidates Found"}; + for (size_t i = 1; i <= labels.size(); ++i) { + mRegistry.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(i, labels[i - 1].c_str()); + } + + mRegistry.add("hCentralityAll", "Centrality All", {HistType::kTH1L, {{100, 0., 100.}}}); + mRegistry.add("hCentralitySelected", "Centrality Selected", {HistType::kTH1L, {{100, 0., 100.}}}); + + hTPCsignalAll = mRegistry.add("hTPCsignalAll", "TPC Signal All", {HistType::kTH2D, {{400, -10, 10}, {1000, 0, 2000}}}); + hTPCsignalHe3 = mRegistry.add("hTPCsignalHe3", "TPC Signal He3", {HistType::kTH2D, {{400, -10, 10}, {1000, 0, 2000}}}); + + hTPCnSigmaAll = mRegistry.add("hTPCnSigmaAll", "TPC nSigma All", {HistType::kTH2D, {{400, -10, 10}, {100, -5., 5.}}}); + hTPCnSigmaHe3 = mRegistry.add("hTPCnSigmaHe3", "TPC nSigma He3", {HistType::kTH2D, {{400, -10, 10}, {100, -5., 5.}}}); + + hArmenterosPodolanskiAll = mRegistry.add("hArmenterosPodolanskiAll", "Armenteros-Podolanski All", {HistType::kTH2D, {{100, -1., 1.}, {100, 0., 0.5}}}); + hArmenterosPodolanskiSelected = mRegistry.add("hArmenterosPodolanskiSelected", "Armenteros-Podolanski Selected", {HistType::kTH2D, {{100, -1., 1.}, {100, 0., 0.5}}}); + + constexpr double ConstituentsMass = o2::constants::physics::MassProton + o2::constants::physics::MassNeutron * 2 + o2::constants::physics::MassSigmaPlus; + hInvariantMassUS = mRegistry.add("hInvariantMassUS", "Invariant Mass", {HistType::kTH2D, {{45, 1., 10}, {100, ConstituentsMass - 0.05, ConstituentsMass + 0.05}}}); + hInvariantMassLS = mRegistry.add("hInvariantMassLS", "Invariant Mass", {HistType::kTH2D, {{45, 1., 10}, {100, ConstituentsMass - 0.05, ConstituentsMass + 0.05}}}); + + LOGF(info, "He3-Lambda analysis initialized"); + } + + void initCCDB(const auto& bc) + { + int runNumber = bc.runNumber(); + if (runNumber == mRunNumber) { + return; // Already initialized for this run + } + mRunNumber = runNumber; + if (cfgEventSelection.skimmedProcessing) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), "fHe"); + zorro.populateHistRegistry(mRegistry, bc.runNumber()); + } + o2::parameters::GRPMagField* grpmag = ccdb->getForRun("GLO/Config/GRPMagField", runNumber); + o2::base::Propagator::initFieldFromGRP(grpmag); + mBz = static_cast(grpmag->getNominalL3Field()); + fitter.setBz(mBz); + o2::base::Propagator::Instance()->setMatLUT(matLUT); + } + + void processData(CollisionsFull::iterator const& collision, + TracksFull const& tracks, + aod::V0s const& v0s, + aod::BCsWithTimestamps const&) + { + const auto& bc = collision.bc_as(); + initCCDB(bc); + + mRegistry.get(HIST("hEventSelection"))->Fill(0); // Total events + mRegistry.get(HIST("hCentralityAll"))->Fill(collision.centFT0C()); + if (cfgEventSelection.useSel8 && !collision.sel8()) { + return; // Skip events not passing Sel8 selection + } + mRegistry.get(HIST("hEventSelection"))->Fill(1); // Sel8 events + if (std::abs(collision.posZ()) > cfgEventSelection.zVertexMax) { + return; // Skip events with z-vertex outside range + } + mRegistry.get(HIST("hEventSelection"))->Fill(2); // Z-vertex OK + + // Additional event selections not implemented, but can be added here + if (cfgEventSelection.skimmedProcessing) { + if (!zorro.isSelected(bc.globalBC())) { + return; // Skip events not passing Zorro selection + } + } + mRegistry.get(HIST("hEventSelection"))->Fill(3); // Additional event selections + + // Process He3 candidates + std::vector he3Candidates; + o2::track::TrackParCov trackParCov; + trackParCov.setPID(o2::track::PID::Helium3); + const o2::math_utils::Point3D collVtx{collision.posX(), collision.posY(), collision.posZ()}; + + for (auto const& track : tracks) { + if (track.tpcNClsFound() < cfgHe3.tpcClusMin || track.itsNCls() < cfgHe3.itsClusMin) { + continue; // Skip tracks with insufficient clusters + } + hTPCsignalAll->Fill(track.tpcInnerParam() * track.sign(), track.tpcSignal()); + const float pt = track.pt() * 2.0f; + float expTPCSignal = o2::tpc::BetheBlochAleph(track.tpcInnerParam() * 2.0f / constants::physics::MassHelium3, mBBparamsHe[0], mBBparamsHe[1], mBBparamsHe[2], mBBparamsHe[3], mBBparamsHe[4]); + double nSigmaTPC = (track.tpcSignal() - expTPCSignal) / (expTPCSignal * mBBparamsHe[5]); + hTPCnSigmaAll->Fill(track.tpcInnerParam() * track.sign(), nSigmaTPC); + if (pt < cfgHe3.ptMin || pt > cfgHe3.ptMax || std::abs(track.eta()) > cfgHe3.etaMax || track.tpcInnerParam() < cfgHe3.minTPCrigidity || std::abs(nSigmaTPC) > cfgHe3.nSigmaTPCMax) { + continue; // Skip tracks outside He3 PID+kinematics selection criteria + } + setTrackParCov(track, trackParCov); + std::array dcaInfo; + o2::base::Propagator::Instance()->propagateToDCA(collVtx, trackParCov, mBz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrLUT, &dcaInfo); + if (std::abs(dcaInfo[0]) > cfgHe3.dcaxyMax || std::abs(dcaInfo[1]) > cfgHe3.dcazMax) { + continue; // Skip tracks with DCA outside range + } + hTPCsignalHe3->Fill(track.tpcInnerParam() * track.sign(), track.tpcSignal()); + hTPCnSigmaHe3->Fill(track.tpcInnerParam() * track.sign(), nSigmaTPC); + he3Candidate candidate; + candidate.momentum.SetCoordinates(track.pt() * 2.0f, track.eta(), track.phi(), o2::constants::physics::MassHelium3); + candidate.nSigmaTPC = nSigmaTPC; + candidate.dcaXY = dcaInfo[0]; + candidate.dcaZ = dcaInfo[1]; + candidate.tpcNClsFound = track.tpcNClsFound(); + candidate.tpcNClsPID = track.tpcNClsPID(); + candidate.itsNCls = track.itsNCls(); + candidate.itsClusterSizes = track.itsClusterSizes(); + candidate.sign = track.sign() > 0 ? 1 : -1; + he3Candidates.push_back(candidate); + } + if (he3Candidates.empty()) { + return; // No valid He3 candidates found + } + mRegistry.get(HIST("hEventSelection"))->Fill(4); // He3 candidates found + + // Process Lambda candidates + std::vector lambdaCandidates; + for (auto const& v0 : v0s) { + if (v0.v0Type() != 1) { + continue; + } + const auto posTrack = v0.posTrack_as(); + const auto negTrack = v0.negTrack_as(); + + if (posTrack.tpcNClsFound() < cfgLambda.tpcNClsMin || negTrack.tpcNClsFound() < cfgLambda.tpcNClsMin) { + continue; // Skip V0s with insufficient TPC clusters + } + auto trackParPos = getTrackParCov(posTrack); + auto trackParNeg = getTrackParCov(negTrack); + int nCand = 0; + try { + nCand = fitter.process(trackParPos, trackParNeg); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + return; + } + if (nCand == 0) { + continue; + } + auto& propParPos = fitter.getTrack(0); + auto& propParNeg = fitter.getTrack(1); + std::array momPos, momNeg; + propParPos.getPxPyPzGlo(momPos); + propParNeg.getPxPyPzGlo(momNeg); + const std::array momV0{momPos[0] + momNeg[0], momPos[1] + momNeg[1], momPos[2] + momNeg[2]}; + float alpha = alphaAP(momV0, momPos, momNeg); + float qt = qtAP(momV0, momPos); + hArmenterosPodolanskiAll->Fill(alpha, qt); + + bool matter = alpha > 0; + const auto& protonTrack = matter ? posTrack : negTrack; + const auto& pionTrack = matter ? negTrack : posTrack; + const auto& protonMom = matter ? momPos : momNeg; + const auto& pionMom = matter ? momNeg : momPos; + + if (std::abs(protonTrack.tpcNSigmaPr()) > cfgLambda.protonNSigmaTPCMax || + std::abs(pionTrack.tpcNSigmaPi()) > cfgLambda.pionNSigmaTPCMax) { + continue; // Skip V0s with TPC nSigma outside range + } + ROOT::Math::LorentzVector> protonMom4D(protonMom[0], protonMom[1], protonMom[2], o2::constants::physics::MassProton); + ROOT::Math::LorentzVector> pionMom4D(pionMom[0], pionMom[1], pionMom[2], o2::constants::physics::MassPionCharged); + auto lambdaMom4D = protonMom4D + pionMom4D; + float massLambda = lambdaMom4D.M(); + + if (std::abs(massLambda - o2::constants::physics::MassLambda0) > cfgLambda.massWindow) { + continue; // Skip V0s outside mass window + } + hArmenterosPodolanskiSelected->Fill(alpha, qt); + + std::array dcaInfoProton, dcaInfoPion; + o2::base::Propagator::Instance()->propagateToDCA(collVtx, matter ? trackParPos : trackParNeg, mBz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrLUT, &dcaInfoProton); + o2::base::Propagator::Instance()->propagateToDCA(collVtx, matter ? trackParNeg : trackParPos, mBz, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrLUT, &dcaInfoPion); + + const auto sv = fitter.getPCACandidate(0); + + lambdaCandidate candidate; + candidate.momentum.SetCoordinates(lambdaMom4D.Pt(), lambdaMom4D.Eta(), lambdaMom4D.Phi(), o2::constants::physics::MassLambda0); + candidate.mass = massLambda; + candidate.cosPA = (sv[0] - collVtx.x()) * lambdaMom4D.Px() + + (sv[1] - collVtx.y()) * lambdaMom4D.Py() + + (sv[2] - collVtx.z()) * lambdaMom4D.Pz(); + candidate.cosPA /= std::hypot(sv[0] - collVtx.x(), sv[1] - collVtx.y(), sv[2] - collVtx.z()) * lambdaMom4D.P(); + candidate.dcaV0Daughters = std::sqrt(fitter.getChi2AtPCACandidate(0)); + candidate.dcaProtonToPV = std::hypot(dcaInfoProton[0], dcaInfoProton[1]); + candidate.dcaPionToPV = std::hypot(dcaInfoPion[0], dcaInfoPion[1]); + candidate.v0Radius = std::hypot(sv[0], sv[1]); + candidate.protonNSigmaTPC = protonTrack.tpcNSigmaPr(); + candidate.pionNSigmaTPC = pionTrack.tpcNSigmaPi(); + candidate.sign = matter ? 1 : -1; // Positive sign for Lambda, negative for anti-Lambda + lambdaCandidates.push_back(candidate); + } + if (lambdaCandidates.empty()) { + return; // No valid Lambda candidates found + } + mRegistry.get(HIST("hEventSelection"))->Fill(5); // He3 and Lambda candidates found + mRegistry.get(HIST("hCentralitySelected"))->Fill(collision.centFT0C()); + + // Fill output tables + lfHe3V0Collision(collision.posZ(), collision.centFT0C()); + for (const auto& he3 : he3Candidates) { + lfHe3(lfHe3V0Collision.lastIndex(), he3.momentum.Pt(), he3.momentum.Eta(), he3.momentum.Phi(), + he3.dcaXY, he3.dcaZ, he3.tpcNClsFound, he3.tpcNClsPID, he3.itsClusterSizes, he3.nSigmaTPC, he3.sign); + } + for (const auto& lambda : lambdaCandidates) { + lfLambda(lfHe3V0Collision.lastIndex(), lambda.momentum.Pt(), lambda.momentum.Eta(), lambda.momentum.Phi(), + lambda.mass, lambda.cosPA, lambda.dcaV0Daughters, lambda.dcaProtonToPV, lambda.dcaPionToPV, lambda.v0Radius, lambda.protonNSigmaTPC, lambda.pionNSigmaTPC, lambda.sign); + } + + for (const auto& he3 : he3Candidates) { + for (const auto& lambda : lambdaCandidates) { + auto pairMomentum = lambda.momentum + he3.momentum; // Calculate invariant mass + (he3.sign * lambda.sign > 0 ? hInvariantMassLS : hInvariantMassUS)->Fill(pairMomentum.Pt(), pairMomentum.M()); + } + } + } + PROCESS_SWITCH(he3LambdaAnalysis, processData, "Process data", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Nuspex/hyhe4builder.cxx b/PWGLF/TableProducer/Nuspex/hyhe4builder.cxx index ea733209de8..66fe812f7a2 100644 --- a/PWGLF/TableProducer/Nuspex/hyhe4builder.cxx +++ b/PWGLF/TableProducer/Nuspex/hyhe4builder.cxx @@ -249,7 +249,7 @@ struct hyhefourbuilder { //---/---/---/---/---/---/---/---/---/---/---/---/---/ // Calculate DCA with respect to the collision associated to the V0, not individual tracks - gpu::gpustd::array dcaInfo; + std::array dcaInfo; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, lHelium3TrackForDCA, 2.f, fitter.getMatCorrType(), &dcaInfo); hyHe4Candidate.dcaXY3He = dcaInfo[0]; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, lProtonTrackForDCA, 2.f, fitter.getMatCorrType(), &dcaInfo); diff --git a/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx b/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx index dd86e4e7fc6..160310d5bd8 100644 --- a/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -39,10 +40,14 @@ #include "PWGLF/DataModel/LFHypernucleiKfTables.h" #include "TRandom3.h" #include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/TableProducer/PID/pidTPCBase.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "ReconstructionDataFormats/PID.h" +#include "MetadataHelper.h" // KFParticle #ifndef HomogeneousField -#define HomogeneousField // o2-linter: disable=[name/macro] +#define HomogeneousField // o2-linter: disable=name/macro (Name is defined in KFParticle package) #endif #include "KFParticle.h" #include "KFPTrack.h" @@ -54,10 +59,11 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using CollisionsFull = soa::Join; +using CollisionsFull = soa::Join; using CollisionsFullMC = soa::Join; -using TracksFull = soa::Join; +using TracksFull = soa::Join; +o2::common::core::MetadataHelper metadataInfo; // Metadata helper //---------------------------------------------------------------------------------------------------------------- namespace @@ -148,7 +154,7 @@ static const std::vector cascadeNames{"4LLH->4LHe+pi", "4XHe->4LHe+ constexpr int cascadeEnabled[nCascades][1]{{0}, {0}, {0}, {0}, {0}, {0}}; constexpr int cascadePdgCodes[nCascades][1]{ {1020010040}, - {1120010040}, + {1120020040}, {0}, {0}, {0}, @@ -167,33 +173,32 @@ constexpr double preSelectionsCascades[nCascades][nSelCas]{ {0.00, 9.90, 0, 100, -1., 100., 10., 10.}, {0.00, 9.90, 0, 100, -1., 100., 10., 10.}, {0.00, 9.90, 0, 100, -1., 100., 10., 10.}}; - //---------------------------------------------------------------------------------------------------------------- struct DaughterParticle { TString name; int pdgCode, charge; double mass, resolution; - std::vector betheParams; + std::array betheParams; bool active; DaughterParticle(std::string name_, int pdgCode_, double mass_, int charge_, LabeledArray bethe) : name(name_), pdgCode(pdgCode_), charge(charge_), mass(mass_), active(false) { resolution = bethe.get(name, "resolution"); - betheParams.clear(); - for (unsigned int i = 0; i < 5; i++) - betheParams.push_back(bethe.get(name, i)); + for (unsigned int i = 0; i < betheParams.size(); i++) + betheParams[i] = bethe.get(name, i); } + int getCentralPIDIndex() { return getPIDIndex(pdgCode); } }; // struct DaughterParticle struct HyperNucleus { TString name; int pdgCode; - bool active; + bool active, savePrimary; std::vector daughters, daughterTrackSigns; - HyperNucleus(std::string name_, int pdgCode_, bool active_, std::vector daughters_, std::vector daughterTrackSigns_) : pdgCode(pdgCode_), active(active_) + HyperNucleus(std::string name_, int pdgCode_, bool active_, std::vector daughters_, std::vector daughterTrackSigns_) : pdgCode(pdgCode_), active(active_), savePrimary(active_) { init(name_, daughters_, daughterTrackSigns_); } - HyperNucleus(std::string name_, int pdgCode_, bool active_, int hypDaughter, std::vector daughters_, std::vector daughterTrackSigns_) : pdgCode(pdgCode_), active(active_) + HyperNucleus(std::string name_, int pdgCode_, bool active_, int hypDaughter, std::vector daughters_, std::vector daughterTrackSigns_) : pdgCode(pdgCode_), active(active_), savePrimary(active_) { daughters.push_back(hypDaughter); init(name_, daughters_, daughterTrackSigns_); @@ -213,16 +218,22 @@ struct HyperNucleus { struct DaughterKf { int64_t daughterTrackId; - int hypNucId; + int species, hypNucId; KFParticle daughterKfp; - float dcaToPv, dcaToPvXY, dcaToPvZ; - DaughterKf(int64_t daughterTrackId_, KFParticle daughterKfp_, std::vector vtx) : daughterTrackId(daughterTrackId_), hypNucId(-1), daughterKfp(daughterKfp_) + float dcaToPv, dcaToPvXY, dcaToPvZ, tpcNsigma, tpcNsigmaNLP, tpcNsigmaNHP; + bool active; + std::vector vtx; + DaughterKf(int species_, int64_t daughterTrackId_, std::vector vtx_, float tpcNsigma_, float tpcNsigmaNLP_, float tpcNsigmaNHP_) : daughterTrackId(daughterTrackId_), species(species_), hypNucId(-1), tpcNsigma(tpcNsigma_), tpcNsigmaNLP(tpcNsigmaNLP_), tpcNsigmaNHP(tpcNsigmaNHP_), vtx(vtx_) {} + DaughterKf(int species_, KFParticle daughterKfp_, int hypNucId_) : daughterTrackId(-999), species(species_), hypNucId(hypNucId_), daughterKfp(daughterKfp_), dcaToPv(-999), dcaToPvXY(-999), dcaToPvZ(-999) {} + void addKfp(KFParticle daughterKfp_) { + daughterKfp = daughterKfp_; dcaToPvXY = daughterKfp.GetDistanceFromVertexXY(&vtx[0]); dcaToPv = daughterKfp.GetDistanceFromVertex(&vtx[0]); dcaToPvZ = std::sqrt(dcaToPv * dcaToPv - dcaToPvXY * dcaToPvXY); } - DaughterKf(KFParticle daughterKfp_, int hypNucId_) : daughterTrackId(-999), hypNucId(hypNucId_), daughterKfp(daughterKfp_), dcaToPv(-999), dcaToPvXY(-999), dcaToPvZ(-999) {} + + bool isTrack() { return daughterTrackId >= 0; } }; // struct DaughterKf struct HyperNucCandidate { @@ -231,6 +242,7 @@ struct HyperNucCandidate { HyperNucCandidate* hypNucDaughter; std::vector daughters; std::vector recoSV; + std::vector> daughterPosMoms; float mass, px, py, pz; float devToPvXY, dcaToPvXY, dcaToPvZ, dcaToVtxXY, dcaToVtxZ, chi2; bool mcTrue, isPhysPrimary, isPrimaryCandidate, isSecondaryCandidate, isUsedSecondary; @@ -274,13 +286,15 @@ struct HyperNucCandidate { return kfp.GetQ() / std::abs(kfp.GetQ()); } int getNdaughters() { return static_cast(daughters.size()); } - float getDcaTracks() { return getNdaughters() == 2 ? getDcaTracks2() : getMaxDcaToSv(); } - float getDcaTracks2() { return daughters.at(0)->daughterKfp.GetDistanceFromParticleXY(daughters.at(1)->daughterKfp); } - float getMaxDcaToSv() + float getDcaTracks() { + if (!daughterPosMoms.size()) + setDaughterPosMoms(); float maxDca = std::numeric_limits::lowest(); for (size_t i = 0; i < daughters.size(); i++) { - float dca = daughters.at(i)->daughterKfp.GetDistanceFromVertexXY(&recoSV[0]); + float dx = daughterPosMoms.at(i).at(0) - recoSV[0]; + float dy = daughterPosMoms.at(i).at(1) - recoSV[1]; + const float dca = std::sqrt(dx * dx + dy * dy); if (dca > maxDca) maxDca = dca; } @@ -289,9 +303,7 @@ struct HyperNucCandidate { float getDcaMotherToVertex(std::vector vtx) { return kfp.GetDistanceFromVertex(&vtx[0]); } double getCpa(std::vector vtx) { - kfp.TransportToDecayVertex(); return RecoDecay::cpa(std::array{vtx[0], vtx[1], vtx[2]}, std::array{recoSV[0], recoSV[1], recoSV[2]}, std::array{px, py, pz}); - ; } float getCt(std::vector vtx) { @@ -302,11 +314,19 @@ struct HyperNucCandidate { } return std::sqrt(dl) * mass / std::sqrt(px * px + py * py + pz * pz); } - void getDaughterPosMom(int daughter, std::vector& posMom) + void setDaughterPosMoms() { + for (size_t i = 0; i < daughters.size(); i++) { + daughterPosMoms.push_back(getDaughterPosMom(i)); + } + } + std::vector getDaughterPosMom(int daughter) + { + std::vector posMom; auto kfpDaughter = daughters.at(daughter)->daughterKfp; kfpDaughter.TransportToPoint(&recoSV[0]); posMom.assign({kfpDaughter.GetX(), kfpDaughter.GetY(), kfpDaughter.GetZ(), kfpDaughter.GetPx(), kfpDaughter.GetPy(), kfpDaughter.GetPz()}); + return posMom; } float getDcaMotherToVtxXY(std::vector vtx) { return kfp.GetDistanceFromVertexXY(&vtx[0]); } float getDcaMotherToVtxZ(std::vector vtx) @@ -316,7 +336,7 @@ struct HyperNucCandidate { } void calcDcaToVtx(KFPVertex& vtx) { - if (devToPvXY != 999) + if (devToPvXY != 999) // o2-linter: disable=magic-number (To be checked) return; devToPvXY = kfp.GetDeviationFromVertexXY(vtx); dcaToPvXY = kfp.GetDistanceFromVertexXY(vtx); @@ -329,11 +349,23 @@ struct HyperNucCandidate { dcaToVtxZ = getDcaMotherToVtxZ(cand.recoSV); } float getSubDaughterMass(int d1, int d2) + { + return calcSubDaughterMass(daughters.at(d1)->daughterKfp, daughters.at(d2)->daughterKfp); + } + float getSubDaughterMassCascade(int d1, int d2) + { + if (!isCascade()) { + LOGF(warning, "Primary hypernucleus has no hypernucleus daughter!"); + return -999; + } + return calcSubDaughterMass(daughters.at(d1)->daughterKfp, hypNucDaughter->daughters.at(d2)->daughterKfp); + } + float calcSubDaughterMass(KFParticle d1, KFParticle d2) { KFParticle subDaughter; subDaughter.SetConstructMethod(2); - subDaughter.AddDaughter(daughters.at(d1)->daughterKfp); - subDaughter.AddDaughter(daughters.at(d2)->daughterKfp); + subDaughter.AddDaughter(d1); + subDaughter.AddDaughter(d2); subDaughter.TransportToDecayVertex(); return subDaughter.GetMass(); } @@ -354,6 +386,14 @@ struct IndexPairs { } return false; } + bool hasIndex(int64_t a) + { + for (const auto& pair : pairs) { + if (pair.first == a) + return true; + } + return false; + } }; // struct IndexPairs struct McCollInfo { @@ -410,6 +450,12 @@ struct HypKfRecoTask { Configurable> cfgPreSelectionsSecondaries{"cfgPreSelectionsSecondaries", {preSelectionsSecondaries[0], nHyperNuclei, nSelSec, hyperNucNames, preSelectionSecNames}, "selection criteria for secondary hypernuclei"}; Configurable> cfgPreSelectionsCascades{"cfgPreSelectionsCascades", {preSelectionsCascades[0], nCascades, nSelCas, cascadeNames, preSelectionCascadeNames}, "selection criteria for cascade hypernuclei"}; + // TPC PID Response + bool usePidResponse; + o2::pid::tpc::Response* response; + std::map metadata; + std::array betheParams; + // CCDB Service ccdb; Configurable bField{"bField", -999, "bz field, -999 is automatic"}; @@ -418,10 +464,10 @@ struct HypKfRecoTask { Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - Configurable pidPath{"pidPath", "", "Path to the PID response object"}; + Configurable pidPath{"pidPath", "Analysis/PID/TPC/Response", "Path to the PID response object"}; + std::vector activePdgs; std::vector daughterParticles; - std::vector> foundDaughters; std::vector> foundDaughterKfs, hypNucDaughterKfs; std::vector> singleHyperNucCandidates, cascadeHyperNucCandidates; std::vector singleHyperNuclei, cascadeHyperNuclei; @@ -429,7 +475,7 @@ struct HypKfRecoTask { std::vector mcCollInfos; IndexPairs trackIndices, mcPartIndices; KFPVertex kfPrimVtx; - bool collHasCandidate, collHasMcTrueCandidate, collPassedEvSel, activeCascade; + bool collHasCandidate, collHasMcTrueCandidate, collPassedEvSel, activeCascade, isMC; int64_t mcCollTableIndex; int mRunNumber, occupancy; float dBz; @@ -438,6 +484,7 @@ struct HypKfRecoTask { void init(InitContext const&) { + isMC = false; mRunNumber = 0; dBz = 0; rand.SetSeed(0); @@ -447,18 +494,37 @@ struct HypKfRecoTask { ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); - for (int i = 0; i < nDaughterParticles; i++) { // create daughterparticles + usePidResponse = false; + for (unsigned int i = 0; i < nDaughterParticles; i++) { // create daughterparticles daughterParticles.push_back(DaughterParticle(particleNames.at(i), particlePdgCodes.at(i), particleMasses.at(i), particleCharge.at(i), cfgBetheBlochParams)); + if (cfgTrackPIDsettings->get(i, "useBBparams") == 2 || cfgTrackPIDsettings->get(i, "useBBparams") == 0) // o2-linter: disable=magic-number (To be checked) + usePidResponse = true; } + for (unsigned int i = 0; i < nHyperNuclei; i++) { // create hypernuclei - singleHyperNuclei.push_back(HyperNucleus(hyperNucNames.at(i), cfgHyperNucPdg->get(i, 0u), cfgHyperNucsActive->get(i, 0u), getDaughterVec(i, cfgHyperNucDaughters), getDaughterSignVec(i, cfgHyperNucSigns))); + auto active = cfgHyperNucsActive->get(i, 0u); + auto pdg = cfgHyperNucPdg->get(i, 0u); + singleHyperNuclei.push_back(HyperNucleus(hyperNucNames.at(i), pdg, active, getDaughterVec(i, cfgHyperNucDaughters), getDaughterSignVec(i, cfgHyperNucSigns))); + if (active) + activePdgs.push_back(pdg); } + activeCascade = false; for (unsigned int i = 0; i < nCascades; i++) { // create cascades - cascadeHyperNuclei.push_back(HyperNucleus(cascadeNames.at(i), cfgCascadesPdg->get(i, 0u), cfgCascadesActive->get(i, 0u), getHypDaughterVec(i, cfgCascadeHypDaughter), getDaughterVec(i, cfgCascadeDaughters), getDaughterSignVec(i, cfgCascadeSigns))); - if (cfgCascadesActive->get(i, 0u)) + auto active = cfgCascadesActive->get(i, 0u); + auto pdg = cfgCascadesPdg->get(i, 0u); + auto hypDaughter = getHypDaughterVec(i, cfgCascadeHypDaughter); + cascadeHyperNuclei.push_back(HyperNucleus(cascadeNames.at(i), pdg, active, hypDaughter, getDaughterVec(i, cfgCascadeDaughters), getDaughterSignVec(i, cfgCascadeSigns))); + if (active) { + activePdgs.push_back(pdg); + if (!singleHyperNuclei.at(hypDaughter).active) { + singleHyperNuclei.at(hypDaughter).active = true; + activePdgs.push_back(singleHyperNuclei.at(hypDaughter).pdgCode); + } activeCascade = true; + } } + // define histogram axes const AxisSpec axisMagField{10, -10., 10., "magnetic field"}; const AxisSpec axisNev{3, 0., 3., "Number of events"}; @@ -466,6 +532,7 @@ struct HypKfRecoTask { const AxisSpec axisdEdx{2000, 0, 2000, "d#it{E}/d#it{x}"}; const AxisSpec axisInvMass{1000, 1, 6, "inv mass"}; const AxisSpec axisCent{100, 0, 100, "centrality"}; + const AxisSpec axisOccupancy{5000, 0, 50000, "occupancy"}; const AxisSpec axisVtxZ{100, -10, 10, "z"}; // create histograms histos.add("histMagField", "histMagField", kTH1F, {axisMagField}); @@ -474,6 +541,7 @@ struct HypKfRecoTask { histos.add("histCentFT0A", "histCentFT0A", kTH1F, {axisCent}); histos.add("histCentFT0C", "histCentFT0C", kTH1F, {axisCent}); histos.add("histCentFT0M", "histCentFT0M", kTH1F, {axisCent}); + histos.add("histEvents", "histEvents", kTH2F, {axisCent, axisOccupancy}); hDeDx.resize(2 * nDaughterParticles + 2); for (int i = 0; i < nDaughterParticles + 1; i++) { TString histName = i < nDaughterParticles ? daughterParticles[i].name : "all"; @@ -495,7 +563,7 @@ struct HypKfRecoTask { } //---------------------------------------------------------------------------------------------------------------- - void findDaughterParticles(aod::TrackAssoc const& tracksByColl, TracksFull const& tracks) + void findDaughterParticles(aod::TrackAssoc const& tracksByColl, TracksFull const& tracks, CollisionsFull::iterator const& coll) { // track loop, store daughter candidates in std::vector for (const auto& trackId : tracksByColl) { @@ -514,63 +582,69 @@ struct HypKfRecoTask { continue; if (track.itsChi2NCl() > cfgTrackPIDsettings->get(i, "maxITSchi2")) continue; - if (std::abs(getTPCnSigma(track, daughterParticles.at(i))) > cfgTrackPIDsettings->get(i, "maxTPCnSigma")) + if (getRigidity(track) < cfgTrackPIDsettings->get(i, "minRigidity") || getRigidity(track) > cfgTrackPIDsettings->get(i, "maxRigidity")) + continue; + float tpcNsigma = getTPCnSigma(track, coll, daughterParticles.at(i)); + if (std::abs(tpcNsigma) > cfgTrackPIDsettings->get(i, "maxTPCnSigma")) continue; filldedx(track, i); if (getMeanItsClsSize(track) < cfgTrackPIDsettings->get(i, "minITSclsSize")) continue; if (getMeanItsClsSize(track) > cfgTrackPIDsettings->get(i, "maxITSclsSize")) continue; - if (getRigidity(track) < cfgTrackPIDsettings->get(i, "minRigidity") || getRigidity(track) > cfgTrackPIDsettings->get(i, "maxRigidity")) - continue; if (cfgTrackPIDsettings->get(i, "TOFrequiredabove") >= 0 && getRigidity(track) > cfgTrackPIDsettings->get(i, "TOFrequiredabove") && (track.mass() < cfgTrackPIDsettings->get(i, "minTOFmass") || track.mass() > cfgTrackPIDsettings->get(i, "maxTOFmass"))) continue; - foundDaughters.at(i).push_back(track.globalIndex()); + float tpcNsigmaNHP = (i == kAlpha ? -999 : getTPCnSigma(track, coll, daughterParticles.at(i + 1))); + float tpcNsigmaNLP = (i == kPion ? 999 : getTPCnSigma(track, coll, daughterParticles.at(i - 1))); + foundDaughterKfs.at(i).push_back(DaughterKf(i, track.globalIndex(), primVtx, tpcNsigma, tpcNsigmaNLP, tpcNsigmaNHP)); } } // track loop } - //---------------------------------------------------------------------------------------------------------------- - void checkMCTrueTracks(aod::McTrackLabels const& trackLabels, aod::McParticles const&) + + void checkMCTrueTracks(aod::McTrackLabels const& trackLabels, aod::McParticles const&, TracksFull const& tracks, CollisionsFull::iterator const& coll) { - std::vector activePdgs; - std::vector*> hypNucVectors = {&singleHyperNuclei, &cascadeHyperNuclei}; - for (int vec = 0; vec < 2; vec++) { - for (size_t hyperNucIter = 0; hyperNucIter < hypNucVectors.at(vec)->size(); hyperNucIter++) { - HyperNucleus* hyperNuc = &(hypNucVectors.at(vec)->at(hyperNucIter)); - if (!hyperNuc->active) - continue; - activePdgs.push_back(std::abs(hyperNuc->pdgCode)); - } - } for (int i = 0; i < nDaughterParticles; i++) { - auto& daughterVec = foundDaughters.at(i); + auto& daughterVec = foundDaughterKfs.at(i); if (!daughterVec.size()) continue; for (auto it = daughterVec.end() - 1; it >= daughterVec.begin(); it--) { - const auto& mcLab = trackLabels.rawIteratorAt(*it); + const auto& mcLab = trackLabels.rawIteratorAt(it->daughterTrackId); if (!mcLab.has_mcParticle()) { daughterVec.erase(it); continue; } const auto& mcPart = mcLab.mcParticle_as(); - if (std::abs(mcPart.pdgCode()) != daughterParticles.at(i).pdgCode) { - daughterVec.erase(it); - continue; - } - if (!mcPart.has_mothers()) { - daughterVec.erase(it); - continue; - } - bool isDaughter = false; - for (const auto& mother : mcPart.mothers_as()) { - if (std::find(activePdgs.begin(), activePdgs.end(), std::abs(mother.pdgCode())) != activePdgs.end()) { - isDaughter = true; + if (cfgSaveOnlyMcTrue) { + if (std::abs(mcPart.pdgCode()) != daughterParticles.at(i).pdgCode) { + daughterVec.erase(it); + continue; + } + if (!mcPart.has_mothers()) { + daughterVec.erase(it); + continue; + } + bool isDaughter = false; + for (const auto& mother : mcPart.mothers_as()) { + if (std::find(activePdgs.begin(), activePdgs.end(), std::abs(mother.pdgCode())) != activePdgs.end()) { + isDaughter = true; + } + } + if (!isDaughter) { + daughterVec.erase(it); + continue; } } - if (!isDaughter) { - daughterVec.erase(it); - continue; + if (cfgTrackPIDsettings->get(i, "useBBparams") == 0) { + const auto& trk = tracks.rawIteratorAt(it->daughterTrackId); + const auto tpcNsigmaMC = getTPCnSigmaMC(trk, coll, daughterParticles.at(i), daughterParticles.at(i)); + if (std::abs(tpcNsigmaMC) <= cfgTrackPIDsettings->get(i, "maxTPCnSigma")) { + it->tpcNsigma = tpcNsigmaMC; + it->tpcNsigmaNHP = (i == kAlpha ? -999 : getTPCnSigmaMC(trk, coll, daughterParticles.at(i), daughterParticles.at(i + 1))); + it->tpcNsigmaNLP = (i == kPion ? 999 : getTPCnSigmaMC(trk, coll, daughterParticles.at(i), daughterParticles.at(i - 1))); + } else { + daughterVec.erase(it); + } } } } @@ -578,33 +652,42 @@ struct HypKfRecoTask { //---------------------------------------------------------------------------------------------------------------- void createKFDaughters(TracksFull const& tracks) { + for (size_t daughterCount = 0; daughterCount < daughterParticles.size(); daughterCount++) { + daughterParticles.at(daughterCount).active = false; + } std::vector*> hypNucVectors = {&singleHyperNuclei, &cascadeHyperNuclei}; - for (size_t vec = 0; vec < 2; vec++) { + bool singleHypNucActive = false; + for (size_t vec = 0; vec < hypNucVectors.size(); vec++) { for (const auto& hyperNuc : *(hypNucVectors.at(vec))) { if (!hyperNuc.active) continue; for (size_t i = vec; i < hyperNuc.daughters.size(); i++) { - if (foundDaughters.at(hyperNuc.daughters.at(i)).size() > 0) + if (foundDaughterKfs.at(hyperNuc.daughters.at(i)).size() > 0) daughterParticles.at(hyperNuc.daughters.at(i)).active = true; else break; + if (i == hyperNuc.daughters.size() - 1) + singleHypNucActive = true; } } + if (!singleHypNucActive) + break; } + for (size_t daughterCount = 0; daughterCount < daughterParticles.size(); daughterCount++) { const auto& daughterParticle = daughterParticles.at(daughterCount); - if (!daughterParticle.active) + if (!daughterParticle.active) { + foundDaughterKfs.at(daughterCount).clear(); continue; + } const auto& daughterMass = daughterParticle.mass; const auto& daughterCharge = daughterParticle.charge; - for (const auto& daughterId : foundDaughters.at(daughterCount)) { - const auto& daughterTrack = tracks.rawIteratorAt(daughterId); - DaughterKf daughter(daughterId, createKFParticle(daughterTrack, daughterMass, daughterCharge), primVtx); - if (std::abs(daughter.dcaToPvXY) < cfgTrackPIDsettings->get(daughterCount, "minDcaToPvXY")) - continue; - if (std::abs(daughter.dcaToPvZ) < cfgTrackPIDsettings->get(daughterCount, "minDcaToPvZ")) - continue; - foundDaughterKfs.at(daughterCount).push_back(daughter); + auto& daughterVec = foundDaughterKfs.at(daughterCount); + for (auto it = daughterVec.end() - 1; it >= daughterVec.begin(); it--) { + const auto& daughterTrack = tracks.rawIteratorAt(it->daughterTrackId); + it->addKfp(createKFParticle(daughterTrack, daughterMass, daughterCharge)); + if (std::abs(it->dcaToPvXY) < cfgTrackPIDsettings->get(daughterCount, "minDcaToPvXY") || std::abs(it->dcaToPvZ) < cfgTrackPIDsettings->get(daughterCount, "minDcaToPvZ")) + daughterVec.erase(it); } } } @@ -674,7 +757,7 @@ struct HypKfRecoTask { candidate.calcDcaToVtx(kfPrimVtx); candidate.isSecondaryCandidate = true; } - if (candidate.isPrimaryCandidate || candidate.isSecondaryCandidate) + if ((candidate.isPrimaryCandidate && hyperNuc->savePrimary) || (candidate.isSecondaryCandidate && activeCascade)) singleHyperNucCandidates.at(hyperNucIter).push_back(candidate); } } @@ -700,7 +783,7 @@ struct HypKfRecoTask { for (int64_t i = 0; i < static_cast(nHypNucDaughters); i++) { if (singleHyperNucCandidates.at(hyperNuc->daughters.at(0)).at(i).isSecondaryCandidate) { auto hypNucDaughter = &(singleHyperNucCandidates.at(hyperNuc->daughters.at(0)).at(i)); - hypNucDaughterKfs.at(hyperNucIter).push_back(DaughterKf(hypNucDaughter->kfp, i)); + hypNucDaughterKfs.at(hyperNucIter).push_back(DaughterKf(hyperNuc->daughters.at(0), hypNucDaughter->kfp, i)); } } int nCombinations = hypNucDaughterKfs.at(hyperNucIter).size(); @@ -720,11 +803,11 @@ struct HypKfRecoTask { const float maxDcaTracksCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxDcaTracks"); const float maxDcaMotherToPvXYCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxDcaMotherToPvXY"); const float maxDcaMotherToPvZCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxDcaMotherToPvZ"); - const float minCtSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "minCt"); - const float maxCtSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "maxCt"); - const float minCosPaSvSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "minCosPaSv"); - const float maxDcaMotherToSvXYSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "maxDcaMotherToSvXY"); - const float maxDcaMotherToSvZSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "maxDcaMotherToSvZ"); + const float minCtSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "minCt"); + const float maxCtSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "maxCt"); + const float minCosPaSvSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "minCosPaSv"); + const float maxDcaMotherToSvXYSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "maxDcaMotherToSvXY"); + const float maxDcaMotherToSvZSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "maxDcaMotherToSvZ"); while (it[0] != hypNucDaughterKfs.at(hyperNucIter).end()) { // select hypernuclei daughter KFParticle @@ -785,9 +868,8 @@ struct HypKfRecoTask { HyperNucleus* hyperNuc = &(hypNucVectors.at(vec)->at(hyperNucIter)); if (!hyperNuc->active) continue; - for (auto& hypCand : candidateVector->at(hyperNucIter)) { // o2-linter: disable=[const-ref-in-for-loop] + for (auto& hypCand : candidateVector->at(hyperNucIter)) { // o2-linter: disable=[const-ref-in-for-loop] (Object is non const and modified in loop) std::vector motherIds; - int daughterCount = 0; if (hypCand.isCascade()) { if (!hypCand.hypNucDaughter->mcTrue) continue; @@ -800,14 +882,15 @@ struct HypKfRecoTask { break; } } - daughterCount++; } for (const auto& daughter : hypCand.daughters) { + if (!daughter->isTrack()) + continue; const auto& mcLab = trackLabels.rawIteratorAt(daughter->daughterTrackId); if (!mcLab.has_mcParticle()) continue; const auto& mcPart = mcLab.mcParticle_as(); - if (std::abs(mcPart.pdgCode()) != daughterParticles.at(hyperNuc->daughters.at(daughterCount++)).pdgCode) + if (std::abs(mcPart.pdgCode()) != daughterParticles.at(daughter->species).pdgCode) continue; if (!mcPart.has_mothers()) continue; @@ -827,6 +910,8 @@ struct HypKfRecoTask { for (auto iter = motherIds.begin(); iter != motherIds.end() - 1; iter++) if (*iter != *(iter + 1)) hypCand.mcTrue = false; + if (!mcPartIndices.hasIndex(motherIds.front())) + hypCand.mcTrue = false; if (hypCand.mcTrue) { hypCand.mcParticleId = motherIds.front(); collHasMcTrueCandidate = true; @@ -845,56 +930,47 @@ struct HypKfRecoTask { outputCollisionTable( collPassedEvSel, mcCollTableIndex, primVtx.at(0), primVtx.at(1), primVtx.at(2), - cents.at(0), cents.at(1), cents.at(2), occupancy); + cents.at(0), cents.at(1), cents.at(2), occupancy, mRunNumber); std::vector*> hypNucVectors = {&singleHyperNuclei, &cascadeHyperNuclei}; std::vector>*> candidateVectors = {&singleHyperNucCandidates, &cascadeHyperNucCandidates}; - for (int vec = 0; vec < 2; vec++) { + for (unsigned int vec = 0; vec < candidateVectors.size(); vec++) { auto candidateVector = candidateVectors.at(vec); for (size_t hyperNucIter = 0; hyperNucIter < hypNucVectors.at(vec)->size(); hyperNucIter++) { HyperNucleus* hyperNuc = &(hypNucVectors.at(vec)->at(hyperNucIter)); if (!hyperNuc->active) continue; - for (auto& hypCand : candidateVector->at(hyperNucIter)) { // o2-linter: disable=[const-ref-in-for-loop] + for (auto& hypCand : candidateVector->at(hyperNucIter)) { // o2-linter: disable=const-ref-in-for-loop (Object is non const and modified in loop) if (!hypCand.isPrimaryCandidate && !hypCand.isUsedSecondary && !hypCand.isCascade()) continue; - if (saveOnlyMcTrue && !hypCand.mcTrue) + if (saveOnlyMcTrue && !hypCand.mcTrue && !hypCand.isCascade()) continue; hInvMass[vec * nHyperNuclei + hyperNucIter]->Fill(hypCand.mass); std::vector vecDaugtherTracks, vecAddons, vecSubDaughters; - int daughterCount = 0; for (const auto& daughter : hypCand.daughters) { + if (!daughter->isTrack()) + continue; const auto& daughterTrackId = daughter->daughterTrackId; int trackTableId; if (!trackIndices.getIndex(daughterTrackId, trackTableId)) { - auto daught = hyperNuc->daughters.at(daughterCount); const auto& track = tracks.rawIteratorAt(daughterTrackId); outputTrackTable( - hyperNuc->daughters.at(daughterCount) * track.sign(), - track.pt(), track.eta(), track.phi(), - daughter->dcaToPvXY, daughter->dcaToPvZ, - track.tpcNClsFound(), track.tpcChi2NCl(), - track.itsClusterSizes(), track.itsChi2NCl(), - getRigidity(track), track.tpcSignal(), getTPCnSigma(track, daughterParticles.at(daught)), - daught == kAlpha ? -999 : getTPCnSigma(track, daughterParticles.at(daught + 1)), - daught == kPion ? 999 : getTPCnSigma(track, daughterParticles.at(daught - 1)), - track.mass(), - track.isPVContributor()); + daughter->species * track.sign(), track.pt(), track.eta(), track.phi(), daughter->dcaToPvXY, daughter->dcaToPvZ, track.tpcNClsFound(), track.tpcChi2NCl(), + track.itsClusterSizes(), track.itsChi2NCl(), getRigidity(track), track.tpcSignal(), daughter->tpcNsigma, daughter->tpcNsigmaNHP, daughter->tpcNsigmaNLP, + track.mass(), track.isPVContributor()); trackTableId = outputTrackTable.lastIndex(); trackIndices.add(daughterTrackId, trackTableId); } vecDaugtherTracks.push_back(trackTableId); - daughterCount++; } for (int i = 0; i < hypCand.getNdaughters(); i++) { - std::vector posMom; - hypCand.getDaughterPosMom(i, posMom); + std::vector& posMom = hypCand.daughterPosMoms.at(i); outputDaughterAddonTable( posMom.at(0), posMom.at(1), posMom.at(2), posMom.at(3), posMom.at(4), posMom.at(5)); vecAddons.push_back(outputDaughterAddonTable.lastIndex()); } - if (hypCand.getNdaughters() > 2) { + if (hypCand.getNdaughters() > 2) { // o2-linter: disable=magic-number (To be checked) for (int i = 0; i < hypCand.getNdaughters(); i++) { for (int j = i + 1; j < hypCand.getNdaughters(); j++) { outputSubDaughterTable(hypCand.getSubDaughterMass(i, j)); @@ -902,18 +978,23 @@ struct HypKfRecoTask { } } } + if (hypCand.isCascade()) { + for (int i = 1; i < hypCand.getNdaughters(); i++) { + for (int j = 0; j < hypCand.hypNucDaughter->getNdaughters(); j++) { + outputSubDaughterTable(hypCand.getSubDaughterMassCascade(i, j)); + vecSubDaughters.push_back(outputSubDaughterTable.lastIndex()); + } + } + } hypCand.kfp.TransportToDecayVertex(); int mcPartTableId; outputHypNucTable( mcPartIndices.getIndex(hypCand.mcParticleId, mcPartTableId) ? mcPartTableId : -1, outputCollisionTable.lastIndex(), vecDaugtherTracks, vecAddons, hypCand.getDaughterTableId(), vecSubDaughters, - (vec * nHyperNuclei + hyperNucIter + 1) * hypCand.getSign(), - hypCand.isPrimaryCandidate, hypCand.mass, - hypCand.px, hypCand.py, hypCand.pz, - hypCand.dcaToPvXY, hypCand.dcaToPvZ, hypCand.devToPvXY, - hypCand.dcaToVtxXY, hypCand.dcaToVtxZ, hypCand.chi2, - hypCand.recoSV.at(0), hypCand.recoSV.at(1), hypCand.recoSV.at(2)); + (vec * nHyperNuclei + hyperNucIter + 1) * hypCand.getSign(), hypCand.isPrimaryCandidate, hypCand.mass, + hypCand.px, hypCand.py, hypCand.pz, hypCand.dcaToPvXY, hypCand.dcaToPvZ, hypCand.devToPvXY, + hypCand.dcaToVtxXY, hypCand.dcaToVtxZ, hypCand.chi2, hypCand.recoSV.at(0), hypCand.recoSV.at(1), hypCand.recoSV.at(2)); hypCand.tableId = outputHypNucTable.lastIndex(); } } @@ -921,21 +1002,23 @@ struct HypKfRecoTask { } //---------------------------------------------------------------------------------------------------------------- - void processMC(CollisionsFullMC const& collisions, aod::McCollisions const& mcColls, TracksFull const& tracks, aod::BCsWithTimestamps const&, aod::McParticles const& particlesMC, aod::McTrackLabels const& trackLabelsMC, aod::McCollisionLabels const& collLabels, aod::TrackAssoc const& tracksColl) + void processMC(CollisionsFullMC const& collisions, aod::McCollisions const& mcColls, TracksFull const& tracks, aod::BCsWithTimestamps const&, aod::McParticles const& particlesMC, aod::McTrackLabels const& trackLabelsMC, aod::McCollisionLabels const& collLabels, aod::TrackAssoc const& tracksColl, CollisionsFull const& colls) { - + isMC = true; mcCollInfos.clear(); mcCollInfos.resize(mcColls.size()); mcPartIndices.clear(); for (const auto& collision : collisions) { if (!collision.has_mcCollision()) continue; - if (collision.sel8() && std::abs(collision.posZ()) < 10) + if (collision.sel8() && std::abs(collision.posZ()) < 10) // o2-linter: disable=magic-number (To be checked) mcCollInfos.at(collision.mcCollisionId()).passedEvSel = true; } std::vector*> hypNucVectors = {&singleHyperNuclei, &cascadeHyperNuclei}; for (const auto& mcPart : particlesMC) { - for (int vec = 0; vec < 2; vec++) { + if (!mcCollInfos.at(mcPart.mcCollisionId()).passedEvSel) + continue; + for (unsigned int vec = 0; vec < hypNucVectors.size(); vec++) { for (size_t hyperNucIter = 0; hyperNucIter < hypNucVectors.at(vec)->size(); hyperNucIter++) { HyperNucleus* hyperNuc = &(hypNucVectors.at(vec)->at(hyperNucIter)); if (!hyperNuc->active) @@ -944,11 +1027,7 @@ struct HypKfRecoTask { continue; bool isDecayMode = false; float svx, svy, svz; - int daughterPdg; - if (vec == 0) - daughterPdg = daughterParticles.at(hyperNuc->daughters.at(0)).pdgCode; - else - daughterPdg = singleHyperNuclei.at(hyperNuc->daughters.at(0)).pdgCode; + int daughterPdg = vec ? singleHyperNuclei.at(hyperNuc->daughters.at(0)).pdgCode : daughterParticles.at(hyperNuc->daughters.at(0)).pdgCode; for (const auto& mcDaught : mcPart.daughters_as()) { if (std::abs(mcDaught.pdgCode()) == daughterPdg) { isDecayMode = true; @@ -985,11 +1064,14 @@ struct HypKfRecoTask { auto bc = collision.bc_as(); initCCDB(bc); initCollision(collision); + if (!collision.has_mcCollision() || !mcCollInfos.at(collision.mcCollisionId()).passedEvSel) + continue; + const uint64_t collIdx = collision.globalIndex(); auto tracksByColl = tracksColl.sliceBy(perCollision, collIdx); - findDaughterParticles(tracksByColl, tracks); - if (cfgSaveOnlyMcTrue) - checkMCTrueTracks(trackLabelsMC, particlesMC); + findDaughterParticles(tracksByColl, tracks, colls.rawIteratorAt(collision.globalIndex())); + if (cfgSaveOnlyMcTrue || usePidResponse) + checkMCTrueTracks(trackLabelsMC, particlesMC, tracks, colls.rawIteratorAt(collision.globalIndex())); createKFDaughters(tracks); createKFHypernuclei(tracks); createMCinfo(trackLabelsMC, collLabels, particlesMC, mcColls); @@ -1001,16 +1083,13 @@ struct HypKfRecoTask { if (cfgSaveOnlyMcTrue && !collHasMcTrueCandidate) continue; - mcCollTableIndex = -1; - if (collision.has_mcCollision()) { - mcCollTableIndex = mcCollInfos.at(collision.mcCollisionId()).tableIndex; - if (mcCollTableIndex < 0) { - outputMcCollisionTable( - mcCollInfos.at(collision.mcCollisionId()).passedEvSel, - collision.mcCollision().posX(), collision.mcCollision().posY(), collision.mcCollision().posZ()); - mcCollTableIndex = outputMcCollisionTable.lastIndex(); - mcCollInfos.at(collision.mcCollisionId()).tableIndex = mcCollTableIndex; - } + mcCollTableIndex = mcCollInfos.at(collision.mcCollisionId()).tableIndex; + if (mcCollTableIndex < 0) { + outputMcCollisionTable( + mcCollInfos.at(collision.mcCollisionId()).passedEvSel, + collision.mcCollision().posX(), collision.mcCollision().posY(), collision.mcCollision().posZ()); + mcCollTableIndex = outputMcCollisionTable.lastIndex(); + mcCollInfos.at(collision.mcCollisionId()).tableIndex = mcCollTableIndex; } fillTree(tracks, cfgSaveOnlyMcTrue); } @@ -1028,7 +1107,7 @@ struct HypKfRecoTask { continue; const uint64_t collIdx = collision.globalIndex(); auto tracksByColl = tracksColl.sliceBy(perCollision, collIdx); - findDaughterParticles(tracksByColl, tracks); + findDaughterParticles(tracksByColl, tracks, collision); createKFDaughters(tracks); createKFHypernuclei(tracks); createKFCascades(tracks); @@ -1051,7 +1130,7 @@ struct HypKfRecoTask { o2::parameters::GRPMagField* grpmag = 0x0; if (grpo) { o2::base::Propagator::initFieldFromGRP(grpo); - if (bField < -990) { + if (bField < -990) { // o2-linter: disable=magic-number (To be checked) // Fetch magnetic field from ccdb for current collision dBz = grpo->getNominalL3Field(); LOG(info) << "Retrieved GRP for timestamp " << run3grpTimestamp << " with magnetic field of " << dBz << " kZG"; @@ -1064,7 +1143,7 @@ struct HypKfRecoTask { LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grpTimestamp; } o2::base::Propagator::initFieldFromGRP(grpmag); - if (bField < -990) { + if (bField < -990) { // o2-linter: disable=magic-number (To be checked) // Fetch magnetic field from ccdb for current collision dBz = std::lround(5.f * grpmag->getL3Current() / 30000.f); LOG(info) << "Retrieved GRP for timestamp " << run3grpTimestamp << " with magnetic field of " << dBz << " kZG"; @@ -1074,13 +1153,35 @@ struct HypKfRecoTask { } mRunNumber = bc.runNumber(); KFParticle::SetField(dBz); + + // PID response + if (!usePidResponse) + return; + if (metadataInfo.isFullyDefined()) { + metadata["RecoPassName"] = metadataInfo.get("RecoPassName"); + LOGP(info, "Automatically setting reco pass for TPC Response to {} from AO2D", metadata["RecoPassName"]); + } else { + LOG(info) << "Setting reco pass for TPC response to default name"; + metadata["RecoPassName"] = "apass5"; + } + const std::string path = pidPath.value; + ccdb->setTimestamp(run3grpTimestamp); + response = ccdb->getSpecific(path, run3grpTimestamp, metadata); + if (!response) { + LOGF(warning, "Unable to find TPC parametrisation for specified pass name - falling back to latest object"); + response = ccdb->getForTimeStamp(path, run3grpTimestamp); + if (!response) { + LOGF(fatal, "Unable to find any TPC object corresponding to timestamp {}!", run3grpTimestamp); + } + } + LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << run3grpTimestamp << ", recoPass " << metadata["RecoPassName"]; + response->PrintAll(); + betheParams = response->GetBetheBlochParams(); } //---------------------------------------------------------------------------------------------------------------- template void initCollision(const T& collision) { - foundDaughters.clear(); - foundDaughters.resize(nDaughterParticles); foundDaughterKfs.clear(); foundDaughterKfs.resize(nDaughterParticles); hypNucDaughterKfs.clear(); @@ -1094,15 +1195,16 @@ struct HypKfRecoTask { collHasMcTrueCandidate = false; histos.fill(HIST("histMagField"), dBz); histos.fill(HIST("histNev"), 0.5); - collPassedEvSel = collision.sel8() && std::abs(collision.posZ()) < 10; + collPassedEvSel = collision.sel8() && std::abs(collision.posZ()) < 10; // o2-linter: disable=magic-number (To be checked) + occupancy = collision.trackOccupancyInTimeRange(); if (collPassedEvSel) { histos.fill(HIST("histNev"), 1.5); histos.fill(HIST("histVtxZ"), collision.posZ()); histos.fill(HIST("histCentFT0A"), collision.centFT0A()); histos.fill(HIST("histCentFT0C"), collision.centFT0C()); histos.fill(HIST("histCentFT0M"), collision.centFT0M()); + histos.fill(HIST("histEvents"), collision.centFT0C(), occupancy); } - occupancy = collision.trackOccupancyInTimeRange(); kfPrimVtx = createKFPVertexFromCollision(collision); primVtx.assign({collision.posX(), collision.posY(), collision.posZ()}); cents.assign({collision.centFT0A(), collision.centFT0C(), collision.centFT0M()}); @@ -1114,45 +1216,63 @@ struct HypKfRecoTask { { const float rigidity = getRigidity(track); hDeDx[2 * species]->Fill(track.sign() * rigidity, track.tpcSignal()); - if (track.tpcNClsFound() < 100 || track.itsNCls() < 2) + if (track.tpcNClsFound() < 100 || track.itsNCls() < 2) // o2-linter: disable=magic-number (To be checked) return; hDeDx[2 * species + 1]->Fill(track.sign() * rigidity, track.tpcSignal()); } //---------------------------------------------------------------------------------------------------------------- - template - float getTPCnSigma(T const& track, DaughterParticle const& particle) + template + float getTPCnSigma(T const& track, C const& coll, DaughterParticle& particle) { const float rigidity = getRigidity(track); if (!track.hasTPC()) return -999; + float mMip = 1, chargeFactor = 1; + float* parBB; - if (particle.name == "pion" && cfgTrackPIDsettings->get("pion", "useBBparams") == 0) - return track.tpcNSigmaPi(); - if (particle.name == "proton" && cfgTrackPIDsettings->get("proton", "useBBparams") == 0) - return track.tpcNSigmaPr(); - if (particle.name == "deuteron" && cfgTrackPIDsettings->get("deuteron", "useBBparams") == 0) - return track.tpcNSigmaDe(); - if (particle.name == "triton" && cfgTrackPIDsettings->get("triton", "useBBparams") == 0) - return track.tpcNSigmaTr(); - if (particle.name == "helion" && cfgTrackPIDsettings->get("helion", "useBBparams") == 0) - return track.tpcNSigmaHe(); - if (particle.name == "alpha" && cfgTrackPIDsettings->get("alpha", "useBBparams") == 0) - return track.tpcNSigmaAl(); - - double expBethe{tpc::BetheBlochAleph(static_cast(particle.charge * rigidity / particle.mass), particle.betheParams[0], particle.betheParams[1], particle.betheParams[2], particle.betheParams[3], particle.betheParams[4])}; + switch (static_cast(cfgTrackPIDsettings->get(particle.name, "useBBparams"))) { + case -1: + return 0; + case 0: + return isMC ? 0 : response->GetNumberOfSigma(coll, track, particle.getCentralPIDIndex()); + case 1: + parBB = &particle.betheParams[0]; + break; + case 2: + mMip = response->GetMIP(); + chargeFactor = std::pow(particle.charge, response->GetChargeFactor()); + parBB = &betheParams[0]; + break; + default: + return -999; + } + double expBethe{mMip * chargeFactor * o2::tpc::BetheBlochAleph(static_cast(particle.charge * rigidity / particle.mass), parBB[0], parBB[1], parBB[2], parBB[3], parBB[4])}; double expSigma{expBethe * particle.resolution}; float sigmaTPC = static_cast((track.tpcSignal() - expBethe) / expSigma); return sigmaTPC; } //---------------------------------------------------------------------------------------------------------------- + + template + float getTPCnSigmaMC(T const& trk, C const& coll, DaughterParticle& particle1, DaughterParticle& particle2) + { + const float pidval1 = particle1.getCentralPIDIndex(); + const float pidval2 = particle2.getCentralPIDIndex(); + const auto expSignal = response->GetExpectedSignal(trk, pidval2); + const auto expSigma = response->GetExpectedSigma(coll, trk, pidval2); + const auto mcTunedTPCSignal = gRandom->Gaus(expSignal, expSigma); + return response->GetNumberOfSigmaMCTuned(coll, trk, pidval1, mcTunedTPCSignal); + } + //---------------------------------------------------------------------------------------------------------------- + template float getMeanItsClsSize(T const& track) { int sum = 0, n = 0; - for (int i = 0; i < 8; i++) { - sum += (track.itsClusterSizes() >> (4 * i) & 15); - if (track.itsClusterSizes() >> (4 * i) & 15) + for (int i = 0; i < 0x08; i++) { + sum += (track.itsClusterSizes() >> (0x04 * i) & 0x0f); + if (track.itsClusterSizes() >> (0x04 * i) & 0x0f) n++; } return n > 0 ? static_cast(sum) / n : 0.f; @@ -1177,7 +1297,7 @@ struct HypKfRecoTask { trackparCov.getXYZGlo(fP); trackparCov.getPxPyPzGlo(fM); float fPM[6]; - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 0x03; i++) { fPM[i] = fP[i]; fPM[i + 3] = fM[i] * std::abs(charge); } @@ -1213,7 +1333,7 @@ struct HypKfRecoTask { std::vector getDaughterVec(unsigned int hypNuc, LabeledArray cfg) { std::vector vec; - for (unsigned int i = 0; i < 4; i++) { + for (unsigned int i = 0; i < 0x04; i++) { std::string daughter = cfg.get(hypNuc, i); if (std::find(particleNames.begin(), particleNames.end(), daughter) == particleNames.end()) break; @@ -1226,7 +1346,7 @@ struct HypKfRecoTask { std::vector getDaughterSignVec(unsigned int hypNuc, LabeledArray cfg) { std::vector vec; - for (unsigned int i = 0; i < 4; i++) { + for (unsigned int i = 0; i < 0x04; i++) { std::string sign = cfg.get(hypNuc, i); if (sign != "+" && sign != "-") break; @@ -1241,6 +1361,7 @@ struct HypKfRecoTask { //---------------------------------------------------------------------------------------------------------------- WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { + metadataInfo.initMetadata(cfgc); // Parse AO2D metadata return WorkflowSpec{ adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx b/PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx index bcd2dbe227c..246a67f57d6 100644 --- a/PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx +++ b/PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx @@ -56,15 +56,15 @@ struct TrackProperties { }; struct HyperNucleus { - HyperNucleus() : pdgCode(0), isReconstructed(0), globalIndex(0), species(0), isMatter(0), passedEvSel(0), isMatterMC(0), passedEvSelMC(0), isPhysicalPrimary(0), collisionMcTrue(0), mass(0), y(0), pt(0), ct(0), yGen(0), ptGen(0), ctGen(0), cpaPvGen(0), cpaPv(0), cpaSv(0), maxDcaTracks(0), maxDcaTracksSV(0), dcaToPvXY(0), dcaToPvZ(0), dcaToVtxXY(0), dcaToVtxZ(0), devToPvXY(0), chi2(0), pvx(0), pvy(0), pvz(0), svx(0), svy(0), svz(0), px(0), py(0), pz(0), pvxGen(0), pvyGen(0), pvzGen(0), svxGen(0), svyGen(0), svzGen(0), pxGen(0), pyGen(0), pzGen(0), nSingleDaughters(0), nCascadeDaughters(0), mcTrue(0), mcTrueVtx(0), mcPhysicalPrimary(0), hypNucDaughter(0) {} + HyperNucleus() : pdgCode(0), isReconstructed(0), globalIndex(0), species(0), speciesMC(0), isPrimaryCandidate(0), isMatter(0), isCascade(0), isCascadeMC(0), passedEvSel(0), isMatterMC(0), passedEvSelMC(0), isPhysicalPrimary(0), collisionMcTrue(0), mass(0), y(0), pt(0), ct(0), yGen(0), ptGen(0), ctGen(0), cpaPvGen(0), cpaPv(0), cpaSv(0), maxDcaTracks(0), maxDcaTracksSv(0), dcaToPvXY(0), dcaToPvZ(0), dcaToVtxXY(0), dcaToVtxZ(0), devToPvXY(0), chi2(0), pvx(0), pvy(0), pvz(0), svx(0), svy(0), svz(0), px(0), py(0), pz(0), pvxGen(0), pvyGen(0), pvzGen(0), svxGen(0), svyGen(0), svzGen(0), pxGen(0), pyGen(0), pzGen(0), nSingleDaughters(0), nCascadeDaughters(0), mcTrue(0), mcTrueVtx(0), mcPhysicalPrimary(0), hypNucDaughter(0) {} int pdgCode, isReconstructed, globalIndex; - uint8_t species; - bool isMatter, passedEvSel, isMatterMC, passedEvSelMC, isPhysicalPrimary, collisionMcTrue; - float mass, y, pt, ct, yGen, ptGen, ctGen, cpaPvGen, cpaPv, cpaSv, maxDcaTracks, maxDcaTracksSV; + uint8_t species, speciesMC; + bool isPrimaryCandidate, isMatter, isCascade, isCascadeMC, passedEvSel, isMatterMC, passedEvSelMC, isPhysicalPrimary, collisionMcTrue; + float mass, y, pt, ct, yGen, ptGen, ctGen, cpaPvGen, cpaPv, cpaSv, maxDcaTracks, maxDcaTracksSv; float dcaToPvXY, dcaToPvZ, dcaToVtxXY, dcaToVtxZ, devToPvXY, chi2; float pvx, pvy, pvz, svx, svy, svz, px, py, pz; float pvxGen, pvyGen, pvzGen, svxGen, svyGen, svzGen, pxGen, pyGen, pzGen; - int nSingleDaughters, nCascadeDaughters, cent, occu; + int nSingleDaughters, nCascadeDaughters, cent, occu, runNumber; bool mcTrue, mcTrueVtx, mcPhysicalPrimary; std::vector daughterTracks; std::vector subDaughterMassVec; @@ -110,10 +110,12 @@ DECLARE_SOA_COLUMN(TvyGen, tvyGen, float); DECLARE_SOA_COLUMN(TvzGen, tvzGen, float); DECLARE_SOA_COLUMN(Centrality, centrality, int); DECLARE_SOA_COLUMN(Occupancy, occupancy, int); +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); DECLARE_SOA_COLUMN(PassedEvSelMC, passedEvSelMC, bool); +DECLARE_SOA_COLUMN(SpeciesMC, speciesMC, int8_t); //! DECLARE_SOA_COLUMN(IsMatter, isMatter, bool); DECLARE_SOA_COLUMN(IsMatterGen, isMatterGen, bool); -DECLARE_SOA_COLUMN(IsReconstructed, isReconstructed, bool); +DECLARE_SOA_COLUMN(IsReconstructed, isReconstructed, int); DECLARE_SOA_COLUMN(CollMcTrue, collMcTrue, bool); DECLARE_SOA_COLUMN(D1X, d1X, float); DECLARE_SOA_COLUMN(D1Y, d1Y, float); @@ -263,15 +265,18 @@ DECLARE_SOA_COLUMN(Sd3IsPvContributor, sd3IsPvContributor, bool); DECLARE_SOA_COLUMN(Sd1sd2Mass, sd1sd2Mass, float); DECLARE_SOA_COLUMN(Sd1sd3Mass, sd1sd3Mass, float); DECLARE_SOA_COLUMN(Sd2sd3Mass, sd2sd3Mass, float); +DECLARE_SOA_COLUMN(D1sd1Mass, d1sd1Mass, float); +DECLARE_SOA_COLUMN(D1sd2Mass, d1sd2Mass, float); +DECLARE_SOA_COLUMN(D1sd3Mass, d1sd3Mass, float); } // namespace hypkftree -#define HYPKFGENBASE mcparticle::PdgCode, hypkftree::IsMatterGen, hypkftree::IsReconstructed, hykfmc::IsPhysicalPrimary, hypkftree::PassedEvSelMC, hypkftree::YGen, hypkftree::PtGen, hypkftree::CtGen +#define HYPKFGENBASE hypkftree::SpeciesMC, mcparticle::PdgCode, hypkftree::IsMatterGen, hypkftree::IsReconstructed, hykfmc::IsPhysicalPrimary, hypkftree::PassedEvSelMC, hypkftree::YGen, hypkftree::PtGen, hypkftree::CtGen #define HYPKFGENEXT hypkftree::CpaPvGen, hypkftree::PxGen, hypkftree::PyGen, hypkftree::PzGen, hypkftree::PvxGen, hypkftree::PvyGen, hypkftree::PvzGen, hypkftree::SvxGen, hypkftree::SvyGen, hypkftree::SvzGen #define HYPKFGENCAS hypkftree::TvxGen, hypkftree::TvyGen, hypkftree::TvzGen -#define HYPKFHYPNUC hykfmc::Species, hypkftree::IsMatter, hypkftree::Centrality, hypkftree::Occupancy, hykfmccoll::PassedEvSel, hykfhyp::Mass, hypkftree::Y, track::Pt, hypkftree::Ct, hypkftree::CosPa, hypkftree::DcaTracks, hykfhyp::DcaToPvXY, hykfhyp::DcaToPvZ, hykfhyp::DevToPvXY, hykfhyp::Chi2, hypkftree::Pvx, hypkftree::Pvy, hypkftree::Pvz, hykfmc::Svx, hykfmc::Svy, hykfmc::Svz, hykfhyp::Px, hykfhyp::Py, hykfhyp::Pz, hypkftree::CollMcTrue +#define HYPKFHYPNUC hykfmc::Species, hypkftree::IsMatter, hypkftree::Centrality, hypkftree::Occupancy, hypkftree::RunNumber, hykfmccoll::PassedEvSel, hykfhyp::Mass, hypkftree::Y, track::Pt, hypkftree::Ct, hypkftree::CosPa, hypkftree::DcaTracks, hypkftree::DcaTrackSv, hykfhyp::DcaToPvXY, hykfhyp::DcaToPvZ, hykfhyp::DevToPvXY, hykfhyp::Chi2, hypkftree::Pvx, hypkftree::Pvy, hypkftree::Pvz, hykfmc::Svx, hykfmc::Svy, hykfmc::Svz, hykfhyp::Px, hykfhyp::Py, hykfhyp::Pz, hypkftree::CollMcTrue #define HYPKFHYPNUCMC hypkftree::McTrue, hykfmc::IsPhysicalPrimary @@ -291,6 +296,7 @@ DECLARE_SOA_COLUMN(Sd2sd3Mass, sd2sd3Mass, float); #define HYPKFSDMASS hypkftree::D1d2Mass, hypkftree::D1d3Mass, hypkftree::D2d3Mass #define HYPKFSSDMASS hypkftree::Sd1sd2Mass, hypkftree::Sd1sd3Mass, hypkftree::Sd2sd3Mass +#define HYPKFCSDMASS hypkftree::D1sd1Mass, hypkftree::D1sd2Mass, hypkftree::D1sd3Mass DECLARE_SOA_TABLE(HypKfGens, "AOD", "HYPKFGEN", HYPKFGENBASE); using HypKfGen = HypKfGens::iterator; @@ -307,10 +313,10 @@ using HypKfSingleThreeBodyCandidate = HypKfSingleThreeBodyCandidates::iterator; DECLARE_SOA_TABLE(HypKfMcSingleThreeBodyCandidates, "AOD", "HYPKFMCCAND3", HYPKFGENBASE, HYPKFGENEXT, HYPKFHYPNUC, HYPKFD1, HYPKFD2, HYPKFD3, HYPKFSDMASS); using HypKfMcSingleThreeBodyCandidate = HypKfMcSingleThreeBodyCandidates::iterator; -DECLARE_SOA_TABLE(HypKfCascadeTwoThreeCandidates, "AOD", "HYPKFCAND23", HYPKFHYPNUC, HYPKFHYPNUCMC, HYPKFD0, HYPKFD1, HYPKFSD1, HYPKFSD2, HYPKFSD3, HYPKFSSDMASS); +DECLARE_SOA_TABLE(HypKfCascadeTwoThreeCandidates, "AOD", "HYPKFCAND23", HYPKFHYPNUC, HYPKFHYPNUCMC, HYPKFD0, HYPKFD1, HYPKFSD1, HYPKFSD2, HYPKFSD3, HYPKFSSDMASS, HYPKFCSDMASS); using HypKfCascadeTwoThreeCandidate = HypKfCascadeTwoThreeCandidates::iterator; -DECLARE_SOA_TABLE(HypKfMcCascadeTwoThreeCandidates, "AOD", "HYPKFMCCAND23", HYPKFGENBASE, HYPKFGENEXT, HYPKFHYPNUC, HYPKFD0, HYPKFD1, HYPKFSD1, HYPKFSD2, HYPKFSD3, HYPKFSSDMASS); +DECLARE_SOA_TABLE(HypKfMcCascadeTwoThreeCandidates, "AOD", "HYPKFMCCAND23", HYPKFGENBASE, HYPKFGENEXT, HYPKFHYPNUC, HYPKFD0, HYPKFD1, HYPKFSD1, HYPKFSD2, HYPKFSD3, HYPKFSSDMASS, HYPKFCSDMASS); using HypKfMcCascadeTwoThreeCandidate = HypKfMcCascadeTwoThreeCandidates::iterator; DECLARE_SOA_TABLE(HypKfCascadeThreeTwoCandidates, "AOD", "HYPKFCAND32", HYPKFHYPNUC, HYPKFHYPNUCMC, HYPKFD0, HYPKFD1, HYPKFD2, HYPKFSDMASS, HYPKFSD1, HYPKFSD2); @@ -360,14 +366,14 @@ struct HypKfTreeCreator { void processData(aod::HypKfHypNucs const& hypNucs, aod::HypKfColls const& hypKfColls, aod::HypKfTracks const& hypKfTrks, aod::HypKfDaughtAdds const& hypKfDAdd, aod::HypKfSubDs const& hypKfDSub) { for (const auto& hypNuc : hypNucs) { - if (std::abs(hypNuc.species()) != cfgSpecies) + if (cfgSpecies && std::abs(hypNuc.species()) != cfgSpecies) continue; - HyperNucleus candidate, hypDaughter, dummy; - fillCandidate(candidate, hypDaughter, hypNuc, hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); - if (cfgNsecDaughters) { - fillCandidate(hypDaughter, dummy, hypNucs.rawIteratorAt(hypNuc.hypDaughterId()), hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); + HyperNucleus candidate, hypNucDaughter; + fillCandidatePrim(candidate, hypNuc, hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); + if (hypNuc.hypDaughterId() >= 0) { + fillCandidateSec(hypNucDaughter, hypNucs.rawIteratorAt(hypNuc.hypDaughterId()), hypNuc, hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); } - fillTable(candidate, hypDaughter); + fillTable(candidate, hypNucDaughter); } } PROCESS_SWITCH(HypKfTreeCreator, processData, "single tree", false); @@ -376,22 +382,22 @@ struct HypKfTreeCreator { { if (isMC && cfgMCGenerated) outputMcGenTable( - cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen); + cand.speciesMC, cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen); if (!cand.isReconstructed) { cand.daughterTracks.resize(4); cand.subDaughterMassVec.resize(4); hypDaughter.daughterTracks.resize(4); - hypDaughter.subDaughterMassVec.resize(4); + hypDaughter.subDaughterMassVec.resize(8); } - if (cfgNprimDaughters == 2 && cfgNsecDaughters == 0) { + if (cfgNprimDaughters == 2 && cfgNsecDaughters == 0) { // o2-linter: disable=magic-number (To be checked) const auto& d1 = cand.daughterTracks.at(0); const auto& d2 = cand.daughterTracks.at(1); if (!isMC || (isMC && cfgMCReconstructed && cand.isReconstructed)) outputTableTwo( - cand.species, cand.isMatter, cand.cent, cand.occu, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.dcaToPvXY, - cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, + cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, + cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, cand.mcTrue, cand.mcPhysicalPrimary, d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, d1.rigidity, d1.tpcSignal, d1.tpcNsigma, d1.tpcNsigmaNhp, d1.tpcNsigmaNlp, d1.tofMass, d1.dcaXY, d1.dcaZ, d1.isPvContributor, @@ -399,24 +405,24 @@ struct HypKfTreeCreator { d2.rigidity, d2.tpcSignal, d2.tpcNsigma, d2.tpcNsigmaNhp, d2.tpcNsigmaNlp, d2.tofMass, d2.dcaXY, d2.dcaZ, d2.isPvContributor); if (isMC && cfgMCCombined) outputTableMcTwo( - cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, + cand.speciesMC, cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, cand.cpaPvGen, cand.pxGen, cand.pyGen, cand.pzGen, cand.pvxGen, cand.pvyGen, cand.pvzGen, cand.svxGen, cand.svyGen, cand.svzGen, - cand.species, cand.isMatter, cand.cent, cand.occu, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, - cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, + cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, + cand.maxDcaTracksSv, cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, d1.rigidity, d1.tpcSignal, d1.tpcNsigma, d1.tpcNsigmaNhp, d1.tpcNsigmaNlp, d1.tofMass, d1.dcaXY, d1.dcaZ, d1.isPvContributor, d2.x, d2.y, d2.z, d2.px, d2.py, d2.pz, d2.tpcNcls, d2.tpcChi2, d2.itsNcls, d2.itsChi2, d2.itsMeanClsSizeL, d2.rigidity, d2.tpcSignal, d2.tpcNsigma, d2.tpcNsigmaNhp, d2.tpcNsigmaNlp, d2.tofMass, d2.dcaXY, d2.dcaZ, d2.isPvContributor); } - if (cfgNprimDaughters == 3 && cfgNsecDaughters == 0) { + if (((!isMC && cand.isPrimaryCandidate) || (isMC && cand.isPhysicalPrimary)) && ((cfgNprimDaughters == 3 && cfgNsecDaughters == 0) || (cfgNsecDaughters == 3 && cfgSpecies == 0))) { // o2-linter: disable=magic-number (To be checked) const auto& d1 = cand.daughterTracks.at(0); const auto& d2 = cand.daughterTracks.at(1); const auto& d3 = cand.daughterTracks.at(2); if (!isMC || (isMC && cfgMCReconstructed && cand.isReconstructed)) outputTableThree( - cand.species, cand.isMatter, cand.cent, cand.occu, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.dcaToPvXY, - cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, + cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, + cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, cand.mcTrue, cand.mcPhysicalPrimary, d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, d1.rigidity, d1.tpcSignal, d1.tpcNsigma, d1.tpcNsigmaNhp, d1.tpcNsigmaNlp, d1.tofMass, d1.dcaXY, d1.dcaZ, d1.isPvContributor, @@ -427,10 +433,10 @@ struct HypKfTreeCreator { d1.subMass, d2.subMass, d3.subMass); if (isMC && cfgMCCombined) outputTableMcThree( - cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, + cand.speciesMC, cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, cand.cpaPvGen, cand.pxGen, cand.pyGen, cand.pzGen, cand.pvxGen, cand.pvyGen, cand.pvzGen, cand.svxGen, cand.svyGen, cand.svzGen, - cand.species, cand.isMatter, cand.cent, cand.occu, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, - cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, + cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, + cand.maxDcaTracksSv, cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, d1.rigidity, d1.tpcSignal, d1.tpcNsigma, d1.tpcNsigmaNhp, d1.tpcNsigmaNlp, d1.tofMass, d1.dcaXY, d1.dcaZ, d1.isPvContributor, @@ -440,7 +446,9 @@ struct HypKfTreeCreator { d3.rigidity, d3.tpcSignal, d3.tpcNsigma, d3.tpcNsigmaNhp, d3.tpcNsigmaNlp, d3.tofMass, d3.dcaXY, d3.dcaZ, d3.isPvContributor, d1.subMass, d2.subMass, d3.subMass); } - if (cfgNprimDaughters == 2 && cfgNsecDaughters == 3) { + if ((!isMC && !cand.isCascade) || (isMC && !cand.isCascadeMC)) + return; + if (cfgNprimDaughters == 2 && cfgNsecDaughters == 3) { // o2-linter: disable=magic-number (To be checked) const auto& d0 = cand.daughterTracks.at(0); const auto& d1 = cand.daughterTracks.at(1); const auto& sd1 = hypDaughter.daughterTracks.at(0); @@ -448,8 +456,8 @@ struct HypKfTreeCreator { const auto& sd3 = hypDaughter.daughterTracks.at(2); if (!isMC || (isMC && cfgMCReconstructed && cand.isReconstructed)) outputTableTwoThree( - cand.species, cand.isMatter, cand.cent, cand.occu, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.dcaToPvXY, - cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, + cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, + cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, cand.mcTrue, cand.mcPhysicalPrimary, hypDaughter.svx, hypDaughter.svy, hypDaughter.svz, d0.x, d0.y, d0.z, d0.px, d0.py, d0.pz, hypDaughter.mass, hypDaughter.ct, hypDaughter.cpaPv, hypDaughter.maxDcaTracks, hypDaughter.dcaToPvXY, hypDaughter.dcaToPvZ, hypDaughter.dcaToVtxXY, hypDaughter.dcaToVtxZ, hypDaughter.chi2, @@ -461,13 +469,13 @@ struct HypKfTreeCreator { sd2.rigidity, sd2.tpcSignal, sd2.tpcNsigma, sd2.tpcNsigmaNhp, sd2.tpcNsigmaNlp, sd2.tofMass, sd2.dcaXY, sd2.dcaZ, sd2.isPvContributor, sd3.x, sd3.y, sd3.z, sd3.px, sd3.py, sd3.pz, sd3.tpcNcls, sd3.tpcChi2, sd3.itsNcls, sd3.itsChi2, sd3.itsMeanClsSizeL, sd3.rigidity, sd3.tpcSignal, sd3.tpcNsigma, sd3.tpcNsigmaNhp, sd3.tpcNsigmaNlp, sd3.tofMass, sd3.dcaXY, sd3.dcaZ, sd3.isPvContributor, - sd1.subMass, sd2.subMass, sd3.subMass); + sd1.subMass, sd2.subMass, sd3.subMass, cand.subDaughterMassVec.at(0), cand.subDaughterMassVec.at(1), cand.subDaughterMassVec.at(2)); if (isMC && cfgMCCombined) outputTableMcTwoThree( - cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, + cand.speciesMC, cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, cand.cpaPvGen, cand.pxGen, cand.pyGen, cand.pzGen, cand.pvxGen, cand.pvyGen, cand.pvzGen, cand.svxGen, cand.svyGen, cand.svzGen, - cand.species, cand.isMatter, cand.cent, cand.occu, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.dcaToPvXY, - cand.dcaToPvZ, cand.devToPvXY, + cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, + cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, hypDaughter.svx, hypDaughter.svy, hypDaughter.svz, d0.x, d0.y, d0.z, d0.px, d0.py, d0.pz, hypDaughter.mass, hypDaughter.ct, hypDaughter.cpaPv, hypDaughter.maxDcaTracks, hypDaughter.dcaToPvXY, hypDaughter.dcaToPvZ, hypDaughter.dcaToVtxXY, hypDaughter.dcaToVtxZ, hypDaughter.chi2, @@ -479,18 +487,18 @@ struct HypKfTreeCreator { sd2.rigidity, sd2.tpcSignal, sd2.tpcNsigma, sd2.tpcNsigmaNhp, sd2.tpcNsigmaNlp, sd2.tofMass, sd2.dcaXY, sd2.dcaZ, sd2.isPvContributor, sd3.x, sd3.y, sd3.z, sd3.px, sd3.py, sd3.pz, sd3.tpcNcls, sd3.tpcChi2, sd3.itsNcls, sd3.itsChi2, sd3.itsMeanClsSizeL, sd3.rigidity, sd3.tpcSignal, sd3.tpcNsigma, sd3.tpcNsigmaNhp, sd3.tpcNsigmaNlp, sd3.tofMass, sd3.dcaXY, sd3.dcaZ, sd3.isPvContributor, - sd1.subMass, sd2.subMass, sd3.subMass); + sd1.subMass, sd2.subMass, sd3.subMass, cand.subDaughterMassVec.at(0), cand.subDaughterMassVec.at(1), cand.subDaughterMassVec.at(2)); } - if (cfgNprimDaughters == 3 && cfgNsecDaughters == 1) { + if (cfgNprimDaughters == 3 && cfgNsecDaughters == 1) { // o2-linter: disable=magic-number (To be checked) const auto& d0 = cand.daughterTracks.at(0); const auto& d1 = cand.daughterTracks.at(1); const auto& d2 = cand.daughterTracks.at(2); const auto& sd1 = hypDaughter.daughterTracks.at(0); const auto& sd2 = hypDaughter.daughterTracks.at(1); if (!isMC || (isMC && cfgMCReconstructed && cand.isReconstructed)) - outputTableTwoThree( - cand.species, cand.isMatter, cand.cent, cand.occu, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.dcaToPvXY, - cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, + outputTableThreeTwo( + cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, + cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, cand.mcTrue, cand.mcPhysicalPrimary, hypDaughter.svx, hypDaughter.svy, hypDaughter.svz, d0.x, d0.y, d0.z, d0.px, d0.py, d0.pz, hypDaughter.mass, hypDaughter.ct, hypDaughter.cpaPv, hypDaughter.maxDcaTracks, hypDaughter.dcaToPvXY, hypDaughter.dcaToPvZ, hypDaughter.dcaToVtxXY, hypDaughter.dcaToVtxZ, hypDaughter.chi2, d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, @@ -503,11 +511,11 @@ struct HypKfTreeCreator { sd2.x, sd2.y, sd2.z, sd2.px, sd2.py, sd2.pz, sd2.tpcNcls, sd2.tpcChi2, sd2.itsNcls, sd2.itsChi2, sd2.itsMeanClsSizeL, sd2.rigidity, sd2.tpcSignal, sd2.tpcNsigma, sd2.tpcNsigmaNhp, sd2.tpcNsigmaNlp, sd2.tofMass, sd2.dcaXY, sd2.dcaZ, sd2.isPvContributor); if (isMC && cfgMCCombined) - outputTableMcTwoThree( - cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, + outputTableMcThreeTwo( + cand.speciesMC, cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, cand.cpaPvGen, cand.pxGen, cand.pyGen, cand.pzGen, cand.pvxGen, cand.pvyGen, cand.pvzGen, cand.svxGen, cand.svyGen, cand.svzGen, - cand.species, cand.isMatter, cand.cent, cand.occu, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.dcaToPvXY, - cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, + cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, + cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, hypDaughter.svx, hypDaughter.svy, hypDaughter.svz, d0.x, d0.y, d0.z, d0.px, d0.py, d0.pz, hypDaughter.mass, hypDaughter.ct, hypDaughter.cpaPv, hypDaughter.maxDcaTracks, hypDaughter.dcaToPvXY, hypDaughter.dcaToPvZ, hypDaughter.dcaToVtxXY, hypDaughter.dcaToVtxZ, hypDaughter.chi2, d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, @@ -522,8 +530,22 @@ struct HypKfTreeCreator { } } //___________________________________________________________________________________________________________________________________________________________ - - void fillCandidate(HyperNucleus& cand, HyperNucleus& /*hypDaughter*/, aod::HypKfHypNuc const& hypNuc, aod::HypKfHypNucs const&, aod::HypKfColls const&, aod::HypKfTracks const&, aod::HypKfDaughtAdds const&, aod::HypKfSubDs const&) + void fillCandidatePrim(HyperNucleus& cand, aod::HypKfHypNuc const& hypNuc, aod::HypKfHypNucs const& hypNucs, aod::HypKfColls const& colls, aod::HypKfTracks const& tracks, aod::HypKfDaughtAdds const& daughterAdds, aod::HypKfSubDs const& subDs) + { + auto coll = hypNuc.hypKfColl(); + cand.ct = ct(coll, hypNuc); + cand.cpaPv = cpa(coll, hypNuc); + fillCandidate(cand, hypNuc, hypNucs, colls, tracks, daughterAdds, subDs); + } + //___________________________________________________________________________________________________________________________________________________________ + void fillCandidateSec(HyperNucleus& cand, aod::HypKfHypNuc const& hypNuc, aod::HypKfHypNuc const& mother, aod::HypKfHypNucs const& hypNucs, aod::HypKfColls const& colls, aod::HypKfTracks const& tracks, aod::HypKfDaughtAdds const& daughterAdds, aod::HypKfSubDs const& subDs) + { + cand.ct = ct(mother, hypNuc); + cand.cpaPv = cpa(mother, hypNuc); + fillCandidate(cand, hypNuc, hypNucs, colls, tracks, daughterAdds, subDs); + } + //___________________________________________________________________________________________________________________________________________________________ + void fillCandidate(HyperNucleus& cand, aod::HypKfHypNuc const& hypNuc, aod::HypKfHypNucs const&, aod::HypKfColls const&, aod::HypKfTracks const&, aod::HypKfDaughtAdds const&, aod::HypKfSubDs const&) { cand.daughterTracks.clear(); cand.subDaughterMassVec.clear(); @@ -531,16 +553,19 @@ struct HypKfTreeCreator { auto addOns = hypNuc.hypKfDaughtAdd_as(); auto posVec = posVector(addOns); cand.species = std::abs(hypNuc.species()); + cand.isPrimaryCandidate = hypNuc.primary(); cand.isMatter = hypNuc.isMatter(); + cand.mcTrue = hypNuc.mcTrue(); + cand.isCascade = cand.species > 10; // o2-linter: disable=magic-number (To be checked) cand.cent = coll.centFT0C(); cand.occu = coll.occupancy(); + cand.runNumber = coll.runNumber(); cand.passedEvSel = coll.passedEvSel(); cand.mass = hypNuc.mass(); cand.y = hypNuc.y(); cand.pt = hypNuc.pt(); - cand.ct = ct(coll, hypNuc); - cand.cpaPv = cpa(coll, hypNuc); - cand.maxDcaTracks = maxValue(dcaTrackSvAll(posVec, hypNuc, "XY")); + cand.maxDcaTracks = maxValue(dcaTracksAll(posVec, "XY")); + cand.maxDcaTracksSv = maxValue(dcaTrackSvAll(posVec, hypNuc, "XY")); cand.dcaToPvXY = hypNuc.dcaToPvXY(); cand.dcaToPvZ = hypNuc.dcaToPvZ(); cand.dcaToVtxXY = hypNuc.dcaToVtxXY(); @@ -556,7 +581,7 @@ struct HypKfTreeCreator { cand.px = hypNuc.px(); cand.py = hypNuc.py(); cand.pz = hypNuc.pz(); - if (cfgNsecDaughters) { + if (hypNuc.hypDaughterId() >= 0) { TrackProperties hypDaughter; cand.daughterTracks.push_back(hypDaughter); } @@ -587,11 +612,19 @@ struct HypKfTreeCreator { cand.daughterTracks.at(trackCount).z = addOn.z(); cand.daughterTracks.at(trackCount).px = addOn.px(); cand.daughterTracks.at(trackCount).py = addOn.py(); - cand.daughterTracks.at(trackCount).pz = addOn.py(); + cand.daughterTracks.at(trackCount).pz = addOn.pz(); trackCount++; } + + if (cand.isCascade) { + auto subDaughters = hypNuc.hypKfSubD_as(); + for (const auto& subDaughter : subDaughters) { + cand.subDaughterMassVec.push_back(subDaughter.subMass()); + } + } + cand.nSingleDaughters = trackCount; - if (cand.nSingleDaughters < 3) + if (cand.nSingleDaughters < 3) // o2-linter: disable=magic-number (To be checked) return; trackCount = 0; @@ -606,15 +639,18 @@ struct HypKfTreeCreator { { isMC = true; for (const auto& mcHypNuc : mcHypNucs) { - if (std::abs(mcHypNuc.species()) != cfgSpecies) + if (cfgSpecies && std::abs(mcHypNuc.species()) != cfgSpecies) continue; auto mcColl = mcHypNuc.hypKfMcColl(); const auto mcParticleIdx = mcHypNuc.globalIndex(); auto hypNucsByMc = hypNucs.sliceBy(perMcParticle, mcParticleIdx); - HyperNucleus candidate, hypDaughter, dummy; + HyperNucleus candidate, hypNucDaughter; + candidate.speciesMC = mcHypNuc.species(); + candidate.isCascadeMC = candidate.speciesMC > 10; // o2-linter: disable=magic-number (To be checked) candidate.pdgCode = mcHypNuc.pdgCode(); candidate.isMatterMC = mcHypNuc.isMatter(); candidate.isPhysicalPrimary = mcHypNuc.isPhysicalPrimary(); + candidate.mcPhysicalPrimary = mcHypNuc.isPhysicalPrimary(); candidate.passedEvSelMC = mcColl.passedEvSel(); candidate.yGen = mcHypNuc.y(); candidate.ptGen = mcHypNuc.pt(); @@ -636,12 +672,12 @@ struct HypKfTreeCreator { candidate.collisionMcTrue = true; } candidate.isReconstructed++; - fillCandidate(candidate, hypDaughter, hypNucs.rawIteratorAt(hypNuc.globalIndex()), hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); - if (cfgNsecDaughters) { - fillCandidate(hypDaughter, dummy, hypNucs.rawIteratorAt(hypNuc.hypDaughterId()), hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); + fillCandidatePrim(candidate, hypNucs.rawIteratorAt(hypNuc.globalIndex()), hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); + if (hypNuc.hypDaughterId() >= 0) { + fillCandidateSec(hypNucDaughter, hypNucs.rawIteratorAt(hypNuc.hypDaughterId()), hypNucs.rawIteratorAt(hypNuc.globalIndex()), hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); } } - fillTable(candidate, hypDaughter); + fillTable(candidate, hypNucDaughter); hPt[0]->Fill(mcHypNuc.pt()); if (candidate.isReconstructed) hPt[1]->Fill(candidate.pt); diff --git a/PWGLF/TableProducer/Nuspex/hyperRecoTask.cxx b/PWGLF/TableProducer/Nuspex/hyperRecoTask.cxx index 25f883bf1e3..ebf9943064d 100644 --- a/PWGLF/TableProducer/Nuspex/hyperRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/hyperRecoTask.cxx @@ -11,35 +11,39 @@ // // Build hypertriton candidates from V0s and tracks -#include +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/LFHypernucleiTables.h" +#include "PWGLF/Utils/svPoolCreator.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" +#include "Common/Core/PID/PIDTOF.h" +#include "Common/Core/PID/TPCPIDResponse.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "PWGLF/DataModel/EPCalibrationTables.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" - +#include "Common/TableProducer/PID/pidTOFBase.h" #include "EventFiltering/Zorro.h" #include "EventFiltering/ZorroSummary.h" -#include "Common/Core/PID/TPCPIDResponse.h" -#include "Common/Core/PID/PIDTOF.h" -#include "Common/TableProducer/PID/pidTOFBase.h" -#include "DataFormatsTPC/BetheBlochAleph.h" +#include "CCDB/BasicCCDBManager.h" #include "DCAFitter/DCAFitterN.h" -#include "PWGLF/Utils/svPoolCreator.h" -#include "PWGLF/DataModel/LFHypernucleiTables.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -58,6 +62,7 @@ constexpr double betheBlochDefault[1][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32 static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; static const std::vector particleName{"He3"}; std::shared_ptr hEvents; +std::shared_ptr hEventsZorro; std::shared_ptr hZvtx; std::shared_ptr hCentFT0A; std::shared_ptr hCentFT0C; @@ -108,6 +113,8 @@ struct hyperCandidate { float massTOFHe3 = 0.f; uint8_t nTPCClustersHe3 = 0u; uint8_t nTPCClustersPi = 0u; + uint8_t nTPCpidClusHe3 = 0u; + uint8_t nTPCpidClusPi = 0u; uint32_t clusterSizeITSHe3 = 0u; uint32_t clusterSizeITSPi = 0u; @@ -150,6 +157,7 @@ struct hyperRecoTask { Configurable nTPCClusMinPi{"nTPCClusMinPi", -1., "pion NTPC clusters cut"}; Configurable mcSignalOnly{"mcSignalOnly", true, "If true, save only signal in MC"}; Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "Skimmed dataset processing"}; + Configurable isEventUsedForEPCalibration{"isEventUsedForEPCalibration", 1, "Event is used for EP calibration"}; // Define o2 fitter, 2-prong, active memory (no need to redefine per event) o2::vertexing::DCAFitterN<2> fitter; @@ -162,6 +170,7 @@ struct hyperRecoTask { Configurable useCustomVertexer{"useCustomVertexer", false, "Use custom vertexer"}; Configurable skipAmbiTracks{"skipAmbiTracks", false, "Skip ambiguous tracks"}; + Configurable disableITSROFCut{"disableITSROFCut", false, "Disable ITS ROC cut for event selection"}; Configurable customVertexerTimeMargin{"customVertexerTimeMargin", 800, "Time margin for custom vertexer (ns)"}; Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 1, 6, particleName, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for He3"}; Configurable cfgCompensatePIDinTracking{"cfgCompensatePIDinTracking", true, "If true, divide tpcInnerParam by the electric charge"}; @@ -243,11 +252,15 @@ struct hyperRecoTask { hH4LMassBefSel = qaRegistry.add("hH4LMassBefSel", ";M (GeV/#it{c}^{2}); ", HistType::kTH1D, {{60, 3.76, 3.84}}); hH4LMassTracked = qaRegistry.add("hH4LMassTracked", ";M (GeV/#it{c}^{2}); ", HistType::kTH1D, {{60, 3.76, 3.84}}); - hEvents = qaRegistry.add("hEvents", ";Events; ", HistType::kTH1D, {{3, -0.5, 2.5}}); + hEvents = qaRegistry.add("hEvents", ";Events; ", HistType::kTH1D, {{2, -0.5, 1.5}}); hEvents->GetXaxis()->SetBinLabel(1, "All"); hEvents->GetXaxis()->SetBinLabel(2, "Selected"); - hEvents->GetXaxis()->SetBinLabel(3, "Zorro He events"); - if (doprocessMC) { + + hEventsZorro = qaRegistry.add("hEventsZorro", ";Events; ", HistType::kTH1D, {{2, -0.5, 1.5}}); + hEventsZorro->GetXaxis()->SetBinLabel(1, "Zorro before evsel"); + hEventsZorro->GetXaxis()->SetBinLabel(2, "Zorro after evsel"); + + if (doprocessMC || doprocessMCTracked) { hDecayChannel = qaRegistry.add("hDecayChannel", ";Decay channel; ", HistType::kTH1D, {{2, -0.5, 1.5}}); hDecayChannel->GetXaxis()->SetBinLabel(1, "2-body"); hDecayChannel->GetXaxis()->SetBinLabel(2, "3-body"); @@ -331,17 +344,27 @@ struct hyperRecoTask { initCCDB(bc); hEvents->Fill(0.); - if (!collision.sel8() || std::abs(collision.posZ()) > 10) { + if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder) && !disableITSROFCut) { continue; } + bool zorroSelected = false; if (cfgSkimmedProcessing) { - bool zorroSelected = zorro.isSelected(collision.template bc_as().globalBC()); /// Just let Zorro do the accounting + // accounting done after ITS border cut, to properly correct with the MC + zorroSelected = zorro.isSelected(collision.template bc_as().globalBC()); if (zorroSelected) { - hEvents->Fill(2.); + hEventsZorro->Fill(0.); } } + if (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || std::abs(collision.posZ()) > 10) { + continue; + } + + if (zorroSelected) { + hEventsZorro->Fill(1.); + } + goodCollision[collision.globalIndex()] = true; hEvents->Fill(1.); hZvtx->Fill(collision.posZ()); @@ -384,8 +407,10 @@ struct hyperRecoTask { hypCand.nSigmaHe3 = computeNSigmaHe3(heTrack); hypCand.nTPCClustersHe3 = heTrack.tpcNClsFound(); hypCand.tpcSignalHe3 = heTrack.tpcSignal(); + hypCand.nTPCpidClusHe3 = (int16_t)heTrack.tpcNClsFindable() - heTrack.tpcNClsFindableMinusPID(); hypCand.clusterSizeITSHe3 = heTrack.itsClusterSizes(); hypCand.nTPCClustersPi = piTrack.tpcNClsFound(); + hypCand.nTPCpidClusPi = (int16_t)piTrack.tpcNClsFindable() - piTrack.tpcNClsFindableMinusPID(); hypCand.tpcSignalPi = piTrack.tpcSignal(); hypCand.tpcChi2He3 = heTrack.tpcChi2NCl(); hypCand.clusterSizeITSPi = piTrack.itsClusterSizes(); @@ -487,7 +512,7 @@ struct hyperRecoTask { } // if survived all selections, propagate decay daughters to PV - gpu::gpustd::array dcaInfo; + std::array dcaInfo; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, heTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); hypCand.he3DCAXY = dcaInfo[0]; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, piTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); @@ -661,6 +686,7 @@ struct hyperRecoTask { hypCand.decVtx[0], hypCand.decVtx[1], hypCand.decVtx[2], hypCand.dcaV0dau, hypCand.he3DCAXY, hypCand.piDCAXY, hypCand.nSigmaHe3, hypCand.nTPCClustersHe3, hypCand.nTPCClustersPi, + hypCand.nTPCpidClusHe3, hypCand.nTPCpidClusPi, hypCand.momHe3TPC, hypCand.momPiTPC, hypCand.tpcSignalHe3, hypCand.tpcSignalPi, hypCand.tpcChi2He3, hypCand.massTOFHe3, hypCand.clusterSizeITSHe3, hypCand.clusterSizeITSPi, hypCand.flags, trackedHypClSize); @@ -680,10 +706,13 @@ struct hyperRecoTask { for (auto& hypCand : hyperCandidates) { auto collision = collisions.rawIteratorAt(hypCand.collisionID); + if (isEventUsedForEPCalibration && !collision.triggereventep()) { + return; + } float trackedHypClSize = !trackedClSize.empty() ? trackedClSize[hypCand.v0ID] : 0; outputDataTableWithFlow(collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), collision.psiFT0A(), collision.multFT0A(), - collision.psiFT0C(), collision.multFT0C(), + collision.psiFT0C(), collision.multFT0C(), collision.qFT0C(), collision.psiTPC(), collision.multTPC(), collision.posX(), collision.posY(), collision.posZ(), hypCand.isMatter, @@ -692,6 +721,7 @@ struct hyperRecoTask { hypCand.decVtx[0], hypCand.decVtx[1], hypCand.decVtx[2], hypCand.dcaV0dau, hypCand.he3DCAXY, hypCand.piDCAXY, hypCand.nSigmaHe3, hypCand.nTPCClustersHe3, hypCand.nTPCClustersPi, + hypCand.nTPCpidClusHe3, hypCand.nTPCpidClusPi, hypCand.momHe3TPC, hypCand.momPiTPC, hypCand.tpcSignalHe3, hypCand.tpcSignalPi, hypCand.tpcChi2He3, hypCand.massTOFHe3, hypCand.clusterSizeITSHe3, hypCand.clusterSizeITSPi, hypCand.flags, trackedHypClSize); @@ -726,7 +756,7 @@ struct hyperRecoTask { hypCand.recoPtPi(), hypCand.recoPhiPi(), hypCand.recoEtaPi(), hypCand.decVtx[0], hypCand.decVtx[1], hypCand.decVtx[2], hypCand.dcaV0dau, hypCand.he3DCAXY, hypCand.piDCAXY, - hypCand.nSigmaHe3, hypCand.nTPCClustersHe3, hypCand.nTPCClustersPi, + hypCand.nSigmaHe3, hypCand.nTPCClustersHe3, hypCand.nTPCClustersPi, hypCand.nTPCpidClusHe3, hypCand.nTPCpidClusPi, hypCand.momHe3TPC, hypCand.momPiTPC, hypCand.tpcSignalHe3, hypCand.tpcSignalPi, hypCand.tpcChi2He3, hypCand.massTOFHe3, hypCand.clusterSizeITSHe3, hypCand.clusterSizeITSPi, hypCand.flags, trackedHypClSize, @@ -801,7 +831,7 @@ struct hyperRecoTask { -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, false, chargeFactor * hypCand.genPt(), hypCand.genPhi(), hypCand.genEta(), hypCand.genPtHe3(), hypCand.gDecVtx[0], hypCand.gDecVtx[1], hypCand.gDecVtx[2], diff --git a/PWGLF/TableProducer/Nuspex/hyperkinkRecoTask.cxx b/PWGLF/TableProducer/Nuspex/hyperkinkRecoTask.cxx new file mode 100644 index 00000000000..7d2d3fe82e6 --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/hyperkinkRecoTask.cxx @@ -0,0 +1,1337 @@ +// 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. +// +/// \file hyperkinkRecoTask.cxx +/// \brief QA and analysis task for kink decay of hypernuclei +/// \author Yuanzhe Wang + +#include "PWGLF/DataModel/LFHyperNucleiKinkTables.h" +#include "PWGLF/DataModel/LFKinkDecayTables.h" +#include "PWGLF/DataModel/LFPIDTOFGenericTables.h" +#include "PWGLF/Utils/pidTOFGeneric.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +o2::common::core::MetadataHelper metadataInfo; + +using CollisionsFull = soa::Join; +using MCLabeledCollisionsFull = soa::Join; +using FullTracksExtIU = soa::Join; +using MCLabeledTracksIU = soa::Join; + +enum PartType { + kHypertriton = 0, + kHyperhelium4sigma +}; + +enum DaughterType { + kDaugCharged = 0, + kDaugNeutral, + kNDaughterType +}; + +namespace +{ +constexpr std::array LayerRadii{2.33959f, 3.14076f, 3.91924f, 19.6213f, 24.5597f, 34.388f, 39.3329f}; +constexpr int kITSLayers = 7; +constexpr int kITSInnerBarrelLayers = 3; +// constexpr int kITSOuterBarrelLayers = 4; + +const std::array covPosSV{6.4462712107237135f, 0.1309793068144521f, 6.626654155592929f, -0.4510297694023185f, 0.16996629627762413f, 4.109195981415627f}; + +std::shared_ptr hMothCounter; +std::shared_ptr hDaugCounter; +std::shared_ptr hDaugTPCNSigma; +std::shared_ptr hRecoMothCounter; +std::shared_ptr hRecoDaugCounter; +} // namespace + +//-------------------------------------------------------------- +struct H3LDecay { + enum Channel { + k2bodyNeutral = 0, // triton, pion0 + k2bodyCharged, + k3bodyCharged, + kNChannel + }; + + template + static Channel getDecayChannel(TMCParticle const& particle, std::vector& list) + { + if (std::abs(particle.pdgCode()) != o2::constants::physics::Pdg::kHyperTriton) { + return kNChannel; + } + + list.clear(); + list.resize(2, -1); + + bool haveHelium3 = false, haveAntiHelium3 = false, haveDeuteron = false, haveAntiDeuteron = false; + bool haveProton = false, haveAntiProton = false, havePionPlus = false, havePionMinus = false; + bool haveTriton = false, haveAntiTriton = false, havePion0 = false; + for (const auto& mcDaughter : particle.template daughters_as()) { + if (mcDaughter.pdgCode() == o2::constants::physics::Pdg::kTriton) { + haveTriton = true; + list[0] = mcDaughter.globalIndex(); + } + if (mcDaughter.pdgCode() == -o2::constants::physics::Pdg::kTriton) { + haveAntiTriton = true; + list[0] = mcDaughter.globalIndex(); + } + if (mcDaughter.pdgCode() == PDG_t::kPi0) { + havePion0 = true; + list[1] = mcDaughter.globalIndex(); + } + if (mcDaughter.pdgCode() == o2::constants::physics::Pdg::kHelium3) { + haveHelium3 = true; + } + if (mcDaughter.pdgCode() == -o2::constants::physics::Pdg::kHelium3) { + haveAntiHelium3 = true; + } + if (mcDaughter.pdgCode() == o2::constants::physics::Pdg::kDeuteron) { + haveDeuteron = true; + } + if (mcDaughter.pdgCode() == -o2::constants::physics::Pdg::kDeuteron) { + haveAntiDeuteron = true; + } + if (mcDaughter.pdgCode() == PDG_t::kProton) { + haveProton = true; + } + if (mcDaughter.pdgCode() == -PDG_t::kProton) { + haveAntiProton = true; + } + if (mcDaughter.pdgCode() == PDG_t::kPiPlus) { + havePionPlus = true; + } + if (mcDaughter.pdgCode() == -PDG_t::kPiPlus) { + havePionMinus = true; + } + } + + if ((haveTriton && havePion0) || (haveAntiTriton && havePion0)) { + return H3LDecay::k2bodyNeutral; + } else if ((haveHelium3 && havePion0) || (haveAntiHelium3 && havePion0)) { + return H3LDecay::k2bodyCharged; + } else if ((haveDeuteron && haveProton && havePionPlus) || (haveAntiDeuteron && haveAntiProton && havePionMinus)) { + return H3LDecay::k3bodyCharged; + } else { + return kNChannel; + } + } +}; + +//-------------------------------------------------------------- +// Check the decay channel of hyperhelium4sigma +struct He4SDecay { + enum Channel { + k2body = 0, // helium4, pion0 + k3body_p, // triton, proton, pion0 + k3body_n, // triton, neutron, pion+ + kNChannel + }; + + template + static Channel getDecayChannel(TMCParticle const& particle, std::vector& list) + { + if (std::abs(particle.pdgCode()) != o2::constants::physics::Pdg::kHyperHelium4Sigma) { + return kNChannel; + } + + list.clear(); + list.resize(2, -1); + + bool haveAlpha = false, haveTriton = false, haveProton = false, haveNeuteron = false; + bool haveAntiAlpha = false, haveAntiTriton = false, haveAntiProton = false, haveAntiNeuteron = false; + bool havePionPlus = false, havePionMinus = false, havePion0 = false; + for (const auto& mcDaughter : particle.template daughters_as()) { + if (mcDaughter.pdgCode() == o2::constants::physics::Pdg::kAlpha) { + haveAlpha = true; + list[0] = mcDaughter.globalIndex(); + } + if (mcDaughter.pdgCode() == -o2::constants::physics::Pdg::kAlpha) { + haveAntiAlpha = true; + list[0] = mcDaughter.globalIndex(); + } + if (mcDaughter.pdgCode() == o2::constants::physics::Pdg::kTriton) { + haveTriton = true; + } + if (mcDaughter.pdgCode() == -o2::constants::physics::Pdg::kTriton) { + haveAntiTriton = true; + } + if (mcDaughter.pdgCode() == PDG_t::kProton) { + haveProton = true; + } + if (mcDaughter.pdgCode() == -PDG_t::kProton) { + haveAntiProton = true; + } + if (mcDaughter.pdgCode() == PDG_t::kNeutron) { + haveNeuteron = true; + } + if (mcDaughter.pdgCode() == -PDG_t::kNeutron) { + haveAntiNeuteron = true; + } + if (mcDaughter.pdgCode() == PDG_t::kPiPlus) { + havePionPlus = true; + } + if (mcDaughter.pdgCode() == -PDG_t::kPiPlus) { + havePionMinus = true; + } + if (mcDaughter.pdgCode() == PDG_t::kPi0) { + havePion0 = true; + list[1] = mcDaughter.globalIndex(); + } + } + + if ((haveAlpha && havePion0) || (haveAntiAlpha && havePion0)) { + return He4SDecay::k2body; + } else if ((haveTriton && haveProton && havePion0) || (haveAntiTriton && haveAntiProton && havePion0)) { + return He4SDecay::k3body_p; + } else if ((haveTriton && haveNeuteron && havePionPlus) || (haveAntiTriton && haveAntiNeuteron && havePionMinus)) { + return He4SDecay::k3body_n; + } + + return kNChannel; + } +}; + +//-------------------------------------------------------------- +// Extract track parameters from a mcparticle, use global coordinates as the local one +template +o2::track::TrackParametrization getTrackParFromMC(const T& mcparticle, int charge = 1) +{ + int sign = mcparticle.pdgCode() > 0 ? 1 : -1; // ok for hypernuclei + TrackPrecision snp = mcparticle.py() / (mcparticle.pt() + 1.e-10f); + TrackPrecision tgl = mcparticle.pz() / (mcparticle.pt() + 1.e-10f); + std::array arraypar = {mcparticle.vy(), mcparticle.vz(), snp, + tgl, charge * sign / (mcparticle.pt() + 1.e-10f)}; + return o2::track::TrackParametrization(mcparticle.vx(), 0, std::move(arraypar)); +} + +//-------------------------------------------------------------- +// construct index array from mcParticle to track +template +void setTrackIDForMC(std::vector& mcPartIndices, aod::McParticles const& particlesMC, TTrackTable const& tracks) +{ + mcPartIndices.clear(); + mcPartIndices.resize(particlesMC.size()); + std::fill(mcPartIndices.begin(), mcPartIndices.end(), -1); + for (const auto& track : tracks) { + if (track.has_mcParticle()) { + auto mcparticle = track.template mcParticle_as(); + if (mcPartIndices[mcparticle.globalIndex()] == -1) { + mcPartIndices[mcparticle.globalIndex()] = track.globalIndex(); + } else { + auto candTrack = tracks.rawIteratorAt(mcPartIndices[mcparticle.globalIndex()]); + // Use the track which has innest information (also best quality? + if (track.x() < candTrack.x()) { + mcPartIndices[mcparticle.globalIndex()] = track.globalIndex(); + } + } + } + } +} + +//-------------------------------------------------------------- +// get ITSNSigma for daughter track +template +float getITSNSigma(const TTrack& track, o2::aod::ITSResponse& itsResponse, o2::track::PID partType) +{ + float nSigma = -999.f; + switch (partType) { + case o2::track::PID::Alpha: + nSigma = itsResponse.nSigmaITS(track); + break; + case o2::track::PID::Triton: + nSigma = itsResponse.nSigmaITS(track); + break; + default: + break; + } + return nSigma; +} + +//-------------------------------------------------------------- +// get default TOFNSigma for daughter track +template +float getDefaultTOFNSigma(const TTrack& track, o2::track::PID partType) +{ + float nSigma = -999.f; + switch (partType) { + case o2::track::PID::Alpha: + nSigma = track.tofNSigmaAl(); + break; + case o2::track::PID::Triton: + nSigma = track.tofNSigmaTr(); + break; + default: + break; + } + return nSigma; +} + +//-------------------------------------------------------------- +// get TPCNSigma for daughter track +template +float getTPCNSigma(const TTrack& track, o2::track::PID partType) +{ + float nSigma = -999.f; + switch (partType) { + case o2::track::PID::Alpha: + nSigma = track.tpcNSigmaAl(); + break; + case o2::track::PID::Triton: + nSigma = track.tpcNSigmaTr(); + break; + default: + break; + } + return nSigma; +} + +//-------------------------------------------------------------- +// Refit the momentum of the mother track +template +bool refitMotherTrack(const TTrack& track, o2::track::TrackParametrizationWithError& trackPar, const o2::dataformats::VertexBase& primaryVtx, const o2::dataformats::VertexBase& secondaryVtx) +{ + float trackIUPos[2] = {track.y(), track.z()}; + float trackIUCov[3] = {track.cYY(), track.cZY(), track.cZZ()}; + + o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVtx, trackPar, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrLUT); + + trackPar.resetCovariance(1e15); + if (!trackPar.update(primaryVtx)) { + return false; + } + + trackPar.rotate(track.alpha()); + o2::base::Propagator::Instance()->PropagateToXBxByBz(trackPar, track.x()); + if (!trackPar.update(trackIUPos, trackIUCov)) { + return false; + } + + o2::base::Propagator::Instance()->propagateToDCABxByBz(secondaryVtx, trackPar, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrLUT); + if (!trackPar.update(secondaryVtx)) { + return false; + } + + return true; +} + +//-------------------------------------------------------------- +struct HypKinkCandidate { + + bool isMatter = false; + + std::array posPV = {0.0f, 0.0f, 0.0f}; + std::array posSV = {0.0f, 0.0f, 0.0f}; + std::array lastPosMoth = {0.0f, 0.0f, 0.0f}; // last position of mother track at the radii of ITS layer which has the outermost update + std::array momMothSV = {0.0f, 0.0f, 0.0f}; + std::array momDaugSV = {0.0f, 0.0f, 0.0f}; + + float dcaXYMothPv = -999.f; + float dcaXYDaugPv = -999.f; + float dcaKinkTopo = -999.f; + + float chi2ITSMoth = 0.0f; + uint32_t itsClusterSizeMoth = 0u; + uint32_t itsClusterSizeDaug = 0u; + float nSigmaTPCDaug = -999.f; + float nSigmaITSDaug = -999.f; + float nSigmaTOFDaug = -999.f; // recalculated TOF NSigma + + // mc information + bool isSignal = false; + bool isSignalReco = false; + bool isCollReco = false; + bool isSurvEvSelection = false; + + std::array truePosSV = {0.0f, 0.0f, 0.0f}; + std::array trueMomMothPV = {0.0f, 0.0f, 0.0f}; // generated mother momentum at primary vertex + std::array trueMomMothSV = {0.0f, 0.0f, 0.0f}; // true mother momentum at decay vertex + std::array trueMomDaugSV = {0.0f, 0.0f, 0.0f}; // true daughter momentum at decay vertex + + bool isMothReco = false; + std::array momMothPV = {0.0f, 0.0f, 0.0f}; + std::array updateMomMothPV = {0.0f, 0.0f, 0.0f}; // mother momentum at primary vertex after update using PV +}; + +//-------------------------------------------------------------- +// analysis task for 2-body kink decay +struct HyperkinkRecoTask { + + Produces outputDataTable; + Produces outputMCTable; + + Service ccdb; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + + std::vector mcPartIndices; + + // Histograms are defined with HistogramRegistry + HistogramRegistry registry{"registry", {}}; + + Configurable hypoMoth{"hypoMoth", kHypertriton, "Mother particle hypothesis"}; + // Configurable for event selection + Configurable doEventCut{"doEventCut", true, "Apply event selection"}; + Configurable maxZVertex{"maxZVertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable cutTPCNSigmaDaug{"cutTPCNSigmaDaug", 5, "TPC NSigma cut for daughter tracks"}; + Configurable cutTOFNSigmaDaug{"cutTOFNSigmaDaug", 1000, "TOF NSigma cut for daughter tracks"}; + + // CCDB options + Configurable inputBz{"inputBz", -999, "bz field, -999 is automatic"}; + Configurable ccdbPath{"ccdbPath", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + + int mRunNumber; + float mBz; + o2::base::MatLayerCylSet* lut = nullptr; + + o2::aod::ITSResponse itsResponse; + + float massChargedDaug = 999.f; + float massNeutralDaug = 999.f; + int pdgMoth = 0; + std::array pdgDaug = {o2::constants::physics::Pdg::kTriton, PDG_t::kPi0}; // pdgcode of charged (0) and neutral (1) daughter particles + o2::track::PID pidTypeDaug = o2::track::PID::Triton; + + // secondary TOF PID + o2::aod::pidtofgeneric::TofPidNewCollision secondaryTOFPID; // to be updated in Init based on the hypothesis + o2::aod::pidtofgeneric::TofPidNewCollision secondaryTOFPIDLabeled; // to be updated in Init based on the hypothesis + // TOF response and input parameters + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + o2::aod::pidtofgeneric::TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration + + void init(InitContext& initContext) + { + if (hypoMoth == kHypertriton) { + massChargedDaug = o2::constants::physics::MassTriton; + massNeutralDaug = o2::constants::physics::MassPi0; + pdgMoth = o2::constants::physics::Pdg::kHyperTriton; + pdgDaug[kDaugCharged] = o2::constants::physics::Pdg::kTriton; + pdgDaug[kDaugNeutral] = PDG_t::kPi0; + pidTypeDaug = o2::track::PID::Triton; + } else if (hypoMoth == kHyperhelium4sigma) { + massChargedDaug = o2::constants::physics::MassAlpha; + massNeutralDaug = o2::constants::physics::MassPi0; + pdgMoth = o2::constants::physics::Pdg::kHyperHelium4Sigma; + pdgDaug[kDaugCharged] = o2::constants::physics::Pdg::kAlpha; + pdgDaug[kDaugNeutral] = PDG_t::kPi0; + pidTypeDaug = o2::track::PID::Alpha; + } else { + LOG(fatal) << "Unknown mother particle hypothesis"; + } + + // Axes + const AxisSpec vertexZAxis{100, -15., 15., "vtx_{Z} [cm]"}; + const AxisSpec ptAxis{50, -10, 10, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec nSigmaAxis{120, -6.f, 6.f, "n#sigma"}; + const AxisSpec massAxis{100, 3.85, 4.25, "m (GeV/#it{c}^{2})"}; + const AxisSpec diffPtAxis{200, -10.f, 10.f, "#Delta #it{p}_{T} (GeV/#it{c})"}; + const AxisSpec diffPzAxis{200, -10.f, 10.f, "#Delta #it{p}_{z} (GeV/#it{c})"}; + const AxisSpec radiusAxis{40, 0.f, 40.f, "R (cm)"}; + + registry.add("hEventCounter", "hEventCounter", HistType::kTH1F, {{2, 0, 2}}); + registry.add("hVertexZCollision", "hVertexZCollision", HistType::kTH1F, {vertexZAxis}); + registry.add("hCandidateCounter", "hCandidateCounter", HistType::kTH1F, {{3, 0, 3}}); + + if (doprocessMC == true) { + itsResponse.setMCDefaultParameters(); + + registry.add("hTrueCandidateCounter", "hTrueCandidateCounter", HistType::kTH1F, {{3, 0, 3}}); + registry.add("hDiffSVx", ";#Delta x (cm);", HistType::kTH1F, {{200, -10, 10}}); + registry.add("hDiffSVy", ";#Delta y (cm);", HistType::kTH1F, {{200, -10, 10}}); + registry.add("hDiffSVz", ";#Delta z (cm);", HistType::kTH1F, {{200, -10, 10}}); + registry.add("h2RecSVRVsTrueSVR", ";Reconstruced SV R (cm);True SV R (cm);", HistType::kTH2F, {radiusAxis, radiusAxis}); + registry.add("h2TrueMotherDiffPtVsRecSVR", ";Reconstruced SV R (cm);#Delta #it{p}_{T} (GeV/#it{c});", HistType::kTH2F, {radiusAxis, diffPtAxis}); + registry.add("h2TrueMotherDiffEtaVsRecSVR", ";Reconstruced SV R (cm);#Delta #eta;", HistType::kTH2F, {radiusAxis, {200, -0.1, 0.1}}); + registry.add("hDiffDauPx", ";#Delta p_{x} (GeV/#it{c}); ", HistType::kTH1D, {{200, -10, 10}}); + registry.add("hDiffDauPy", ";#Delta p_{y} (GeV/#it{c}); ", HistType::kTH1D, {{200, -10, 10}}); + registry.add("hDiffDauPz", ";#Delta p_{z} (GeV/#it{c}); ", HistType::kTH1D, {{200, -10, 10}}); + registry.add("h2TrueSignalMassPt", "h2TrueSignalMassPt", HistType::kTH2F, {{ptAxis, massAxis}}); + registry.add("h2TrueDaugTPCNSigmaPt", "h2TrueDaugTPCNSigmaPt", HistType::kTH2F, {{ptAxis, nSigmaAxis}}); + + registry.add("hDCAXYMothToRecSV", "hDCAXYMothToRecSV", HistType::kTH1F, {{200, -10, 10}}); + registry.add("hDCAZMothToRecSV", "hDCAZMothToRecSV", HistType::kTH1F, {{200, -10, 10}}); + + registry.add("hDaugOldTOFNSigma_CorrectCol", "hDaugOldTOFNSigma_CorrectCol", HistType::kTH1F, {{600, -300, 300}}); + registry.add("hDaugOldTOFNSigma_WrongCol", "hDaugOldTOFNSigma_WrongCol", HistType::kTH1F, {{600, -300, 300}}); + registry.add("hDaugNewTOFNSigma_CorrectCol", "hDaugNewTOFNSigma_CorrectCol", HistType::kTH1F, {{600, -300, 300}}); + registry.add("hDaugNewTOFNSigma_WrongCol", "hDaugNewTOFNSigma_WrongCol", HistType::kTH1F, {{600, -300, 300}}); + } + + registry.add("h2MothMassPt", "h2MothMassPt", HistType::kTH2F, {{ptAxis, massAxis}}); + registry.add("h2DaugTPCNSigmaPt", "h2DaugTPCNSigmaPt", HistType::kTH2F, {{ptAxis, nSigmaAxis}}); + + ccdb->setURL(ccdbPath); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + mTOFCalibConfig.metadataInfo = metadataInfo; + mTOFCalibConfig.inheritFromBaseTask(initContext); + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); + secondaryTOFPID.SetPidType(pidTypeDaug); + secondaryTOFPIDLabeled.SetPidType(pidTypeDaug); + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + ccdb->clearCache(grpmagPath.value.data()); + LOG(info) << "Initializing CCDB for run " << mRunNumber; + o2::parameters::GRPMagField* grpmag = ccdb->getForRun(grpmagPath, mRunNumber); + o2::base::Propagator::initFieldFromGRP(grpmag); + mBz = grpmag->getNominalL3Field(); + + if (!lut) { + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); + } + o2::base::Propagator::Instance()->setMatLUT(lut); + LOG(info) << "Task initialized for run " << mRunNumber << " with magnetic field " << mBz << " kZG"; + + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, bc); + } + + // ______________________________________________________________ + // get recalulate TOFNSigma for daughter track + template + double getTOFNSigma(o2::pid::tof::TOFResoParamsV3 const& parameters, TTrack const& track, TCollision const& collision, TCollision const& originalcol) + { + // TOF PID of deuteron + if (track.has_collision() && track.hasTOF()) { + if constexpr (isMC) { + return secondaryTOFPIDLabeled.GetTOFNSigma(parameters, track, originalcol, collision); + } else { + return secondaryTOFPID.GetTOFNSigma(parameters, track, originalcol, collision); + } + } + return -999; + } + + template + void fillCandidate(HypKinkCandidate& hypkinkCand, TCollision const& collision, TKindCandidate const& kinkCand, TTrack const& trackMoth, TTrack const& trackDaug) + { + hypkinkCand.isMatter = kinkCand.mothSign() > 0; + hypkinkCand.posPV[0] = collision.posX(); + hypkinkCand.posPV[1] = collision.posY(); + hypkinkCand.posPV[2] = collision.posZ(); + hypkinkCand.posSV[0] = kinkCand.xDecVtx() + collision.posX(); + hypkinkCand.posSV[1] = kinkCand.yDecVtx() + collision.posY(); + hypkinkCand.posSV[2] = kinkCand.zDecVtx() + collision.posZ(); + + hypkinkCand.momMothSV[0] = kinkCand.pxMoth(); + hypkinkCand.momMothSV[1] = kinkCand.pyMoth(); + hypkinkCand.momMothSV[2] = kinkCand.pzMoth(); + hypkinkCand.momDaugSV[0] = kinkCand.pxDaug(); + hypkinkCand.momDaugSV[1] = kinkCand.pyDaug(); + hypkinkCand.momDaugSV[2] = kinkCand.pzDaug(); + + hypkinkCand.dcaXYMothPv = kinkCand.dcaMothPv(); + hypkinkCand.dcaXYDaugPv = kinkCand.dcaDaugPv(); + hypkinkCand.dcaKinkTopo = kinkCand.dcaKinkTopo(); + + fillCandidateRecoMoth(hypkinkCand, collision, trackMoth); + + hypkinkCand.itsClusterSizeDaug = trackDaug.itsClusterSizes(); + hypkinkCand.nSigmaTPCDaug = getTPCNSigma(trackDaug, pidTypeDaug); + hypkinkCand.nSigmaITSDaug = getITSNSigma(trackDaug, itsResponse, pidTypeDaug); + + int lastLayerMoth = 0; + for (int i = 6; i >= 0; i--) { + if (trackMoth.itsClusterMap() & (1 << i)) { + lastLayerMoth = i; + break; + } + } + auto trackparMother = getTrackParCov(trackMoth); + o2::base::Propagator::Instance()->PropagateToXBxByBz(trackparMother, LayerRadii[lastLayerMoth]); + std::array posLastHit{-999.f}; + trackparMother.getXYZGlo(posLastHit); + hypkinkCand.lastPosMoth[0] = posLastHit[0]; + hypkinkCand.lastPosMoth[1] = posLastHit[1]; + hypkinkCand.lastPosMoth[2] = posLastHit[2]; + } + + template + void fillCandidateRecoMoth(HypKinkCandidate& hypkinkCand, TCollision const& collision, TTrack const& trackMoth) + { + hypkinkCand.isMothReco = true; + hypkinkCand.chi2ITSMoth = trackMoth.itsChi2NCl(); + hypkinkCand.itsClusterSizeMoth = trackMoth.itsClusterSizes(); + + auto motherTrackPar = getTrackParCov(trackMoth); + o2::dataformats::VertexBase primaryVtx = {{collision.posX(), collision.posY(), collision.posZ()}, {collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}}; + std::array pMotherPv = {-999.f}; + if (o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVtx, motherTrackPar, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrLUT)) { + motherTrackPar.getPxPyPzGlo(pMotherPv); + } + hypkinkCand.momMothPV[0] = pMotherPv[0]; + hypkinkCand.momMothPV[1] = pMotherPv[1]; + hypkinkCand.momMothPV[2] = pMotherPv[2]; + + std::array updatePMotherPv = {-999.f}; + if (motherTrackPar.update(primaryVtx)) { + motherTrackPar.getPxPyPzGlo(updatePMotherPv); + } + hypkinkCand.updateMomMothPV[0] = updatePMotherPv[0]; + hypkinkCand.updateMomMothPV[1] = updatePMotherPv[1]; + hypkinkCand.updateMomMothPV[2] = updatePMotherPv[2]; + } + + template + void fillCandidateMCInfo(HypKinkCandidate& hypkinkCand, TMCParticle const& mcMothTrack, TMCParticle const& mcDaugTrack, TMCParticle const& mcNeutDaugTrack) + { + hypkinkCand.truePosSV[0] = mcDaugTrack.vx(); + hypkinkCand.truePosSV[1] = mcDaugTrack.vy(); + hypkinkCand.truePosSV[2] = mcDaugTrack.vz(); + hypkinkCand.trueMomMothPV[0] = mcMothTrack.px(); + hypkinkCand.trueMomMothPV[1] = mcMothTrack.py(); + hypkinkCand.trueMomMothPV[2] = mcMothTrack.pz(); + hypkinkCand.trueMomMothSV[0] = mcDaugTrack.px() + mcNeutDaugTrack.px(); + hypkinkCand.trueMomMothSV[1] = mcDaugTrack.py() + mcNeutDaugTrack.py(); + hypkinkCand.trueMomMothSV[2] = mcDaugTrack.pz() + mcNeutDaugTrack.pz(); + hypkinkCand.trueMomDaugSV[0] = mcDaugTrack.px(); + hypkinkCand.trueMomDaugSV[1] = mcDaugTrack.py(); + hypkinkCand.trueMomDaugSV[2] = mcDaugTrack.pz(); + } + + void processData(CollisionsFull const& collisions, aod::KinkCands const& KinkCands, FullTracksExtIU const&, aod::BCsWithTimestamps const&) + { + for (const auto& collision : collisions) { + registry.fill(HIST("hEventCounter"), 0); + if (doEventCut && (std::abs(collision.posZ()) > maxZVertex || !collision.sel8())) { + continue; + } + registry.fill(HIST("hEventCounter"), 1); + registry.fill(HIST("hVertexZCollision"), collision.posZ()); + } + + for (const auto& kinkCand : KinkCands) { + registry.fill(HIST("hCandidateCounter"), 0); + auto collision = kinkCand.collision_as(); + if (doEventCut && (std::abs(collision.posZ()) > maxZVertex || !collision.sel8())) { + continue; + } + registry.fill(HIST("hCandidateCounter"), 1); + + auto daugTrack = kinkCand.trackDaug_as(); + float tpcNSigmaDaug = getTPCNSigma(daugTrack, pidTypeDaug); + if (std::abs(tpcNSigmaDaug) > cutTPCNSigmaDaug) { + continue; + } + float invMass = RecoDecay::m(std::array{std::array{kinkCand.pxDaug(), kinkCand.pyDaug(), kinkCand.pzDaug()}, std::array{kinkCand.pxDaugNeut(), kinkCand.pyDaugNeut(), kinkCand.pzDaugNeut()}}, std::array{massChargedDaug, massNeutralDaug}); + registry.fill(HIST("hCandidateCounter"), 2); + registry.fill(HIST("h2MothMassPt"), kinkCand.mothSign() * kinkCand.ptMoth(), invMass); + registry.fill(HIST("h2DaugTPCNSigmaPt"), kinkCand.mothSign() * kinkCand.ptDaug(), tpcNSigmaDaug); + + auto bc = collision.bc_as(); + initCCDB(bc); + auto motherTrack = kinkCand.trackMoth_as(); + HypKinkCandidate hypkinkCand; + fillCandidate(hypkinkCand, collision, kinkCand, motherTrack, daugTrack); + float nSigmaTOF = -999.f; + if (daugTrack.hasTOF() && daugTrack.has_collision()) { + auto originalDaugCol = daugTrack.collision_as(); + nSigmaTOF = getTOFNSigma(mRespParamsV3, daugTrack, collision, originalDaugCol); + } + if (std::abs(nSigmaTOF) > cutTOFNSigmaDaug) { + continue; + } + hypkinkCand.nSigmaTOFDaug = nSigmaTOF; + + o2::dataformats::VertexBase primaryVtx = {{collision.posX(), collision.posY(), collision.posZ()}, {collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}}; + o2::dataformats::VertexBase secondaryVtx = {{kinkCand.xDecVtx() + collision.posX(), kinkCand.yDecVtx() + collision.posY(), kinkCand.zDecVtx() + collision.posZ()}, {covPosSV[0], covPosSV[1], covPosSV[2], covPosSV[3], covPosSV[4], covPosSV[5]}}; + std::array refitPPV = {-999.f}; + std::array refitPSV = {-999.f}; + auto motherTrackPar = getTrackParCov(motherTrack); + if (refitMotherTrack(motherTrack, motherTrackPar, primaryVtx, secondaryVtx)) { + motherTrackPar.getPxPyPzGlo(refitPSV); + o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVtx, motherTrackPar, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrLUT); + motherTrackPar.getPxPyPzGlo(refitPPV); + } + + outputDataTable( + mBz > 0 ? 1 : -1, + hypkinkCand.posPV[0], hypkinkCand.posPV[1], hypkinkCand.posPV[2], + hypkinkCand.posSV[0], hypkinkCand.posSV[1], hypkinkCand.posSV[2], + hypkinkCand.isMatter, + hypkinkCand.lastPosMoth[0], hypkinkCand.lastPosMoth[1], hypkinkCand.lastPosMoth[2], + hypkinkCand.momMothSV[0], hypkinkCand.momMothSV[1], hypkinkCand.momMothSV[2], + refitPPV[0], refitPPV[1], refitPPV[2], + refitPSV[0], refitPSV[1], refitPSV[2], + hypkinkCand.momDaugSV[0], hypkinkCand.momDaugSV[1], hypkinkCand.momDaugSV[2], + hypkinkCand.dcaXYMothPv, hypkinkCand.dcaXYDaugPv, hypkinkCand.dcaKinkTopo, + hypkinkCand.chi2ITSMoth, hypkinkCand.itsClusterSizeMoth, hypkinkCand.itsClusterSizeDaug, + hypkinkCand.nSigmaTPCDaug, hypkinkCand.nSigmaITSDaug, hypkinkCand.nSigmaTOFDaug); + } + } + PROCESS_SWITCH(HyperkinkRecoTask, processData, "process data", true); + + void processMC(MCLabeledCollisionsFull const& collisions, aod::KinkCands const& KinkCands, MCLabeledTracksIU const& tracks, aod::McParticles const& particlesMC, aod::McCollisions const& mcCollisions, aod::BCsWithTimestamps const&) + { + mcPartIndices.clear(); + std::vector mcPartIndices; + setTrackIDForMC(mcPartIndices, particlesMC, tracks); + std::vector isReconstructedMCCollisions(mcCollisions.size(), false); + std::vector isSelectedMCCollisions(mcCollisions.size(), false); + std::vector isGoodCollisions(collisions.size(), false); + std::vector dauIDList(2, -1); + + for (const auto& collision : collisions) { + isReconstructedMCCollisions[collision.mcCollisionId()] = true; + registry.fill(HIST("hEventCounter"), 0); + if (doEventCut && (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || std::abs(collision.posZ()) > maxZVertex)) { + continue; + } + registry.fill(HIST("hEventCounter"), 1); + registry.fill(HIST("hVertexZCollision"), collision.posZ()); + isSelectedMCCollisions[collision.mcCollisionId()] = true; + isGoodCollisions[collision.globalIndex()] = true; + } + + for (const auto& kinkCand : KinkCands) { + auto motherTrack = kinkCand.trackMoth_as(); + auto daugTrack = kinkCand.trackDaug_as(); + + bool isKinkSignal = false; + if (motherTrack.has_mcParticle() && daugTrack.has_mcParticle()) { + auto mcMothTrack = motherTrack.mcParticle_as(); + auto mcDaugTrack = daugTrack.mcParticle_as(); + if (hypoMoth == kHypertriton) { + auto dChannel = H3LDecay::getDecayChannel(mcMothTrack, dauIDList); + if (dChannel == H3LDecay::k2bodyNeutral && dauIDList[0] == mcDaugTrack.globalIndex()) { + isKinkSignal = true; + } + } else if (hypoMoth == kHyperhelium4sigma) { + auto dChannel = He4SDecay::getDecayChannel(mcMothTrack, dauIDList); + if (dChannel == He4SDecay::k2body && dauIDList[0] == mcDaugTrack.globalIndex()) { + isKinkSignal = true; + } + } + } + + registry.fill(HIST("hCandidateCounter"), 0); + if (isKinkSignal) { + registry.fill(HIST("hTrueCandidateCounter"), 0); + } + auto collision = kinkCand.collision_as(); + if (!isGoodCollisions[collision.globalIndex()]) { + continue; + } + registry.fill(HIST("hCandidateCounter"), 1); + if (isKinkSignal) { + registry.fill(HIST("hTrueCandidateCounter"), 1); + } + + float tpcNSigmaDaug = getTPCNSigma(daugTrack, pidTypeDaug); + if (std::abs(tpcNSigmaDaug) > cutTPCNSigmaDaug) { + continue; + } + float invMass = RecoDecay::m(std::array{std::array{kinkCand.pxDaug(), kinkCand.pyDaug(), kinkCand.pzDaug()}, std::array{kinkCand.pxDaugNeut(), kinkCand.pyDaugNeut(), kinkCand.pzDaugNeut()}}, std::array{massChargedDaug, massNeutralDaug}); + registry.fill(HIST("hCandidateCounter"), 2); + if (isKinkSignal) { + registry.fill(HIST("hTrueCandidateCounter"), 2); + } + registry.fill(HIST("h2MothMassPt"), kinkCand.mothSign() * kinkCand.ptMoth(), invMass); + registry.fill(HIST("h2DaugTPCNSigmaPt"), kinkCand.mothSign() * kinkCand.ptDaug(), tpcNSigmaDaug); + + auto bc = collision.bc_as(); + initCCDB(bc); + HypKinkCandidate hypkinkCand; + fillCandidate(hypkinkCand, collision, kinkCand, motherTrack, daugTrack); + float nSigmaTOF = -999.f; + if (daugTrack.hasTOF() && daugTrack.has_collision()) { + auto originalDaugCol = daugTrack.collision_as(); + float defaultNSigmaTOF = getDefaultTOFNSigma(daugTrack, pidTypeDaug); + nSigmaTOF = getTOFNSigma(mRespParamsV3, daugTrack, collision, originalDaugCol); + if (originalDaugCol.globalIndex() == collision.globalIndex()) { + registry.fill(HIST("hDaugOldTOFNSigma_CorrectCol"), defaultNSigmaTOF); + registry.fill(HIST("hDaugNewTOFNSigma_CorrectCol"), nSigmaTOF); + } else { + registry.fill(HIST("hDaugOldTOFNSigma_WrongCol"), defaultNSigmaTOF); + registry.fill(HIST("hDaugNewTOFNSigma_WrongCol"), nSigmaTOF); + } + } + if (std::abs(nSigmaTOF) > cutTOFNSigmaDaug) { + continue; + } + hypkinkCand.nSigmaTOFDaug = nSigmaTOF; + + std::array posDecVtx = {kinkCand.xDecVtx() + collision.posX(), kinkCand.yDecVtx() + collision.posY(), kinkCand.zDecVtx() + collision.posZ()}; + + o2::dataformats::VertexBase primaryVtx = {{collision.posX(), collision.posY(), collision.posZ()}, {collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}}; + o2::dataformats::VertexBase secondaryVtx = {{posDecVtx[0], posDecVtx[1], posDecVtx[2]}, {covPosSV[0], covPosSV[1], covPosSV[2], covPosSV[3], covPosSV[4], covPosSV[5]}}; + std::array refitPPV = {-999.f}; + std::array refitPSV = {-999.f}; + auto motherTrackPar = getTrackParCov(motherTrack); + if (refitMotherTrack(motherTrack, motherTrackPar, primaryVtx, secondaryVtx)) { + motherTrackPar.getPxPyPzGlo(refitPSV); + o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVtx, motherTrackPar, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrLUT); + motherTrackPar.getPxPyPzGlo(refitPPV); + } + + // QA, store mcInfo for true signals + if (isKinkSignal) { + auto mcMothTrack = motherTrack.mcParticle_as(); + auto mcDaugTrack = daugTrack.mcParticle_as(); + auto mcNeutTrack = particlesMC.rawIteratorAt(dauIDList[1]); + float recSVR = std::sqrt(posDecVtx[0] * posDecVtx[0] + posDecVtx[1] * posDecVtx[1]); + registry.fill(HIST("hDiffSVx"), posDecVtx[0] - mcDaugTrack.vx()); + registry.fill(HIST("hDiffSVy"), posDecVtx[1] - mcDaugTrack.vy()); + registry.fill(HIST("hDiffSVz"), posDecVtx[2] - mcDaugTrack.vz()); + registry.fill(HIST("h2RecSVRVsTrueSVR"), recSVR, std::hypot(mcDaugTrack.vx(), mcDaugTrack.vy())); + registry.fill(HIST("h2TrueMotherDiffPtVsRecSVR"), recSVR, mcMothTrack.pt() - kinkCand.ptMoth()); + registry.fill(HIST("h2TrueMotherDiffEtaVsRecSVR"), recSVR, mcMothTrack.eta() - motherTrack.eta()); + registry.fill(HIST("hDiffDauPx"), kinkCand.pxDaug() - mcDaugTrack.px()); + registry.fill(HIST("hDiffDauPy"), kinkCand.pyDaug() - mcDaugTrack.py()); + registry.fill(HIST("hDiffDauPz"), kinkCand.pzDaug() - mcDaugTrack.pz()); + registry.fill(HIST("h2TrueSignalMassPt"), kinkCand.mothSign() * kinkCand.ptMoth(), invMass); + registry.fill(HIST("h2TrueDaugTPCNSigmaPt"), kinkCand.mothSign() * kinkCand.ptDaug(), tpcNSigmaDaug); + + hypkinkCand.isSignal = true; + hypkinkCand.isSignalReco = true; + hypkinkCand.isCollReco = true; + hypkinkCand.isSurvEvSelection = true; + fillCandidateMCInfo(hypkinkCand, mcMothTrack, mcDaugTrack, mcNeutTrack); + mcPartIndices.push_back(mcMothTrack.globalIndex()); + + std::array dcaInfo; + auto mcMothTrackPar = getTrackParFromMC(mcMothTrack, 2); + o2::base::Propagator::Instance()->propagateToDCABxByBz({posDecVtx[0], posDecVtx[1], posDecVtx[2]}, mcMothTrackPar, 2.f, matCorr, &dcaInfo); + registry.fill(HIST("hDCAXYMothToRecSV"), dcaInfo[0]); + registry.fill(HIST("hDCAZMothToRecSV"), dcaInfo[1]); + } + + outputMCTable( + mBz > 0 ? 1 : -1, + hypkinkCand.posPV[0], hypkinkCand.posPV[1], hypkinkCand.posPV[2], + hypkinkCand.posSV[0], hypkinkCand.posSV[1], hypkinkCand.posSV[2], + hypkinkCand.isMatter, + hypkinkCand.lastPosMoth[0], hypkinkCand.lastPosMoth[1], hypkinkCand.lastPosMoth[2], + hypkinkCand.momMothSV[0], hypkinkCand.momMothSV[1], hypkinkCand.momMothSV[2], + refitPPV[0], refitPPV[1], refitPPV[2], + refitPSV[0], refitPSV[1], refitPSV[2], + hypkinkCand.momDaugSV[0], hypkinkCand.momDaugSV[1], hypkinkCand.momDaugSV[2], + hypkinkCand.dcaXYMothPv, hypkinkCand.dcaXYDaugPv, hypkinkCand.dcaKinkTopo, + hypkinkCand.chi2ITSMoth, hypkinkCand.itsClusterSizeMoth, hypkinkCand.itsClusterSizeDaug, + hypkinkCand.nSigmaTPCDaug, hypkinkCand.nSigmaITSDaug, hypkinkCand.nSigmaTOFDaug, + hypkinkCand.isSignal, hypkinkCand.isSignalReco, hypkinkCand.isCollReco, hypkinkCand.isSurvEvSelection, + hypkinkCand.truePosSV[0], hypkinkCand.truePosSV[1], hypkinkCand.truePosSV[2], + hypkinkCand.trueMomMothPV[0], hypkinkCand.trueMomMothPV[1], hypkinkCand.trueMomMothPV[2], + hypkinkCand.trueMomMothSV[0], hypkinkCand.trueMomMothSV[1], hypkinkCand.trueMomMothSV[2], + hypkinkCand.trueMomDaugSV[0], hypkinkCand.trueMomDaugSV[1], hypkinkCand.trueMomDaugSV[2], + hypkinkCand.isMothReco, hypkinkCand.momMothPV[0], hypkinkCand.momMothPV[1], hypkinkCand.momMothPV[2], + hypkinkCand.updateMomMothPV[0], hypkinkCand.updateMomMothPV[1], hypkinkCand.updateMomMothPV[2]); + } + + // fill kink signals which are not reconstructed + for (auto const& mcparticle : particlesMC) { + auto dChannel = He4SDecay::getDecayChannel(mcparticle, dauIDList); + if (dChannel != He4SDecay::k2body) { + continue; + } + if (std::find(mcPartIndices.begin(), mcPartIndices.end(), mcparticle.globalIndex()) != mcPartIndices.end()) { + continue; + } + + HypKinkCandidate hypkinkCand; + auto mcDaugTrack = particlesMC.rawIteratorAt(dauIDList[0]); + auto mcNeutTrack = particlesMC.rawIteratorAt(dauIDList[1]); + fillCandidateMCInfo(hypkinkCand, mcparticle, mcDaugTrack, mcNeutTrack); + + if (mcPartIndices[mcparticle.globalIndex()] != -1) { + auto mothTrack = tracks.rawIteratorAt(mcPartIndices[mcparticle.globalIndex()]); + if (mothTrack.has_collision()) { + auto collision = mothTrack.collision_as(); + auto bc = collision.template bc_as(); + initCCDB(bc); + fillCandidateRecoMoth(hypkinkCand, collision, mothTrack); + } + } + + outputMCTable( + mBz > 0 ? 1 : -1, + -1, -1, -1, + -1, -1, -1, + -1, + -1, -1, -1, + -1, -1, -1, + -1, -1, -1, + -1, -1, -1, + -1, -1, -1, + -1, -1, -1, + -1, -1, -1, + -1, -1, -1, + true, false, isReconstructedMCCollisions[mcparticle.mcCollisionId()], isSelectedMCCollisions[mcparticle.mcCollisionId()], + hypkinkCand.truePosSV[0], hypkinkCand.truePosSV[1], hypkinkCand.truePosSV[2], + hypkinkCand.trueMomMothPV[0], hypkinkCand.trueMomMothPV[1], hypkinkCand.trueMomMothPV[2], + hypkinkCand.trueMomMothSV[0], hypkinkCand.trueMomMothSV[1], hypkinkCand.trueMomMothSV[2], + hypkinkCand.trueMomDaugSV[0], hypkinkCand.trueMomDaugSV[1], hypkinkCand.trueMomDaugSV[2], + hypkinkCand.isMothReco, hypkinkCand.momMothPV[0], hypkinkCand.momMothPV[1], hypkinkCand.momMothPV[2], + hypkinkCand.updateMomMothPV[0], hypkinkCand.updateMomMothPV[1], hypkinkCand.updateMomMothPV[2]); + } + } + PROCESS_SWITCH(HyperkinkRecoTask, processMC, "process MC", false); +}; + +//-------------------------------------------------------------- +// check the performance of mcparticle +struct HyperkinkQa { + + Configurable hypoMoth{"hypoMoth", kHypertriton, "Mother particle hypothesis"}; + + HistogramRegistry genQAHist{"genQAHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry recoQAHist{"recoQAHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + ConfigurableAxis ptBins{"ptBins", {200, 0.f, 10.f}, "Binning for #it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis ctBins{"ctBins", {100, 0.f, 25.f}, "Binning for c#it{t} (cm)"}; + ConfigurableAxis rigidityBins{"rigidityBins", {200, -10.f, 10.f}, "Binning for #it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis nsigmaBins{"nsigmaBins", {120, -6.f, 6.f}, "Binning for n sigma"}; + ConfigurableAxis invMassBins{"invMassBins", {100, 3.85f, 4.15f}, "Binning for invariant mass (GeV/#it{c}^{2})"}; + ConfigurableAxis radiusBins{"radiusBins", {40, 0.f, 40.f}, "Binning for radius in xy plane (cm)"}; + + o2::aod::ITSResponse itsResponse; + + float massMoth = 999.f; + float massChargedDaug = 999.f; + float massNeutralDaug = 999.f; + int pdgMoth = 0; + std::array pdgDaug = {o2::constants::physics::Pdg::kTriton, PDG_t::kPi0}; // pdgcode of charged (0) and neutral (1) daughter particles + o2::track::PID pidTypeDaug = o2::track::PID::Triton; + + void init(InitContext&) + { + if (doprocessMC == true) { + itsResponse.setMCDefaultParameters(); + + if (hypoMoth == kHypertriton) { + massMoth = o2::constants::physics::MassHyperTriton; + massChargedDaug = o2::constants::physics::MassTriton; + massNeutralDaug = o2::constants::physics::MassPi0; + pdgMoth = o2::constants::physics::Pdg::kHyperTriton; + pdgDaug[kDaugCharged] = o2::constants::physics::Pdg::kTriton; + pdgDaug[kDaugNeutral] = PDG_t::kPi0; + pidTypeDaug = o2::track::PID::Triton; + } else if (hypoMoth == kHyperhelium4sigma) { + massMoth = o2::constants::physics::MassHyperHelium4Sigma; + massChargedDaug = o2::constants::physics::MassAlpha; + massNeutralDaug = o2::constants::physics::MassPi0; + pdgMoth = o2::constants::physics::Pdg::kHyperHelium4Sigma; + pdgDaug[kDaugCharged] = o2::constants::physics::Pdg::kAlpha; + pdgDaug[kDaugNeutral] = PDG_t::kPi0; + pidTypeDaug = o2::track::PID::Alpha; + } else { + LOG(fatal) << "Unknown mother particle hypothesis"; + } + + const AxisSpec pAxis{ptBins, "#it{p} (GeV/#it{c})"}; + const AxisSpec ptAxis{ptBins, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec ctAxis{ctBins, "c#it{t} (cm)"}; + const AxisSpec rigidityAxis{rigidityBins, "p/z (GeV/#it{c})"}; + const AxisSpec nsigmaAxis{nsigmaBins, "TPC n#sigma"}; + const AxisSpec itsnsigmaAxis{nsigmaBins, "ITS n#sigma"}; + const AxisSpec invMassAxis{invMassBins, "Inv Mass (GeV/#it{c}^{2})"}; + const AxisSpec diffPtAxis{200, -10.f, 10.f, "#Delta p_{T} (GeV/#it{c})"}; + const AxisSpec diffPzAxis{200, -10.f, 10.f, "#Delta p_{z} (GeV/#it{c})"}; + const AxisSpec itsRadiusAxis{radiusBins, "ITS R (cm)"}; + const AxisSpec svRadiuAxis{radiusBins, "Decay Vertex R (cm)"}; + + auto hCollCounter = genQAHist.add("hCollCounter", "hCollCounter", HistType::kTH1F, {{2, 0.0f, 2.0f}}); + hCollCounter->GetXaxis()->SetBinLabel(1, "Reconstructed Collisions"); + hCollCounter->GetXaxis()->SetBinLabel(2, "Selected"); + auto hMcCollCounter = genQAHist.add("hMcCollCounter", "hMcCollCounter", HistType::kTH1F, {{2, 0.0f, 2.0f}}); + hMcCollCounter->GetXaxis()->SetBinLabel(1, "MC Collisions"); + hMcCollCounter->GetXaxis()->SetBinLabel(2, "Reconstructed"); + + if (hypoMoth == kHypertriton) { + auto hGenHyperMothCounter = genQAHist.add("hGenHyperMothCounter", "", HistType::kTH1F, {{10, 0.f, 10.f}}); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(1, "H3L All"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(2, "Matter"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(3, "AntiMatter"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(4, "t + #pi^{0}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(5, "#bar{t} + #pi^{0}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(6, "he3 + #pi^{-}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(7, "#bar{he3} + #pi^{+}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(8, "d + p + #pi^{-}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(9, "#bar{d} + #bar{p} + #pi^{+}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(10, "Others"); + } else if (hypoMoth == kHyperhelium4sigma) { + auto hGenHyperMothCounter = genQAHist.add("hGenHyperMothCounter", "", HistType::kTH1F, {{10, 0.f, 10.f}}); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(1, "He4S All"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(2, "Matter"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(3, "AntiMatter"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(4, "#alpha + #pi^{0}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(5, "#bar{#alpha} + #pi^{0}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(6, "t + p + #pi^{0}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(7, "#bar{t} + #bar{p} + #pi^{0}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(8, "t + n + #pi^{+}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(9, "#bar{t} + #bar{n} + #pi^{+}"); + hGenHyperMothCounter->GetXaxis()->SetBinLabel(10, "Others"); + } + + auto hEvtSelectedHyperMothCounter = genQAHist.add("hEvtSelectedHyperMothCounter", "", HistType::kTH1F, {{2, 0.f, 2.f}}); + hEvtSelectedHyperMothCounter->GetXaxis()->SetBinLabel(1, "Generated"); + hEvtSelectedHyperMothCounter->GetXaxis()->SetBinLabel(2, "Survived"); + + genQAHist.add("hGenHyperMothP", "", HistType::kTH1F, {pAxis}); + genQAHist.add("hGenHyperMothPt", "", HistType::kTH1F, {ptAxis}); + genQAHist.add("hGenHyperMothCt", "", HistType::kTH1F, {ctAxis}); + genQAHist.add("hMcRecoInvMass", "", HistType::kTH1F, {invMassAxis}); + + // efficiency/criteria studies for tracks which are true candidates + hMothCounter = recoQAHist.add("hMothCounter", "", HistType::kTH1F, {{9, 0.f, 9.f}}); + hMothCounter->GetXaxis()->SetBinLabel(1, "Generated"); + hMothCounter->GetXaxis()->SetBinLabel(2, "Reconstructed"); + hMothCounter->GetXaxis()->SetBinLabel(3, "eta"); + hMothCounter->GetXaxis()->SetBinLabel(4, "has collision"); + hMothCounter->GetXaxis()->SetBinLabel(5, "ITSonly"); + hMothCounter->GetXaxis()->SetBinLabel(6, "ITS hits"); + hMothCounter->GetXaxis()->SetBinLabel(7, "ITS IR"); + hMothCounter->GetXaxis()->SetBinLabel(8, "ITS chi2"); + hMothCounter->GetXaxis()->SetBinLabel(9, "pt"); + recoQAHist.add("h2TrueMotherDiffPtVsTrueSVR", ";Decay Vertex R (cm);#Delta p_{T} (GeV/#it{c});", HistType::kTH2F, {svRadiuAxis, diffPtAxis}); + recoQAHist.add("h2TrueMotherDiffEtaVsTrueSVR", ";Decay Vertex R (cm);#Delta #eta;", HistType::kTH2F, {svRadiuAxis, {200, -1.f, 1.f}}); + recoQAHist.add("h2GoodMotherDiffPtVsTrueSVR", ";Decay Vertex R (cm);#Delta p_{T} (GeV/#it{c});", HistType::kTH2F, {svRadiuAxis, diffPtAxis}); + + hDaugCounter = recoQAHist.add("hDaugCounter", "", HistType::kTH1F, {{9, 0.f, 9.f}}); + hDaugTPCNSigma = recoQAHist.add("hDaugTPCNSigma", "", HistType::kTH2F, {rigidityAxis, nsigmaAxis}); + + hRecoMothCounter = recoQAHist.add("hRecoMothCounter", "", HistType::kTH1F, {{9, 0.f, 9.f}}); + hRecoDaugCounter = recoQAHist.add("hRecoDaugCounter", "", HistType::kTH1F, {{9, 0.f, 9.f}}); + for (const auto& hist : {hDaugCounter, hRecoMothCounter, hRecoDaugCounter}) { + hist->GetXaxis()->SetBinLabel(1, "Generated"); + hist->GetXaxis()->SetBinLabel(2, "Reconstructed"); + hist->GetXaxis()->SetBinLabel(3, "eta"); + hist->GetXaxis()->SetBinLabel(4, "has ITS&TPC"); + hist->GetXaxis()->SetBinLabel(5, "TPC crossed rows"); + hist->GetXaxis()->SetBinLabel(6, "TPC Ncls"); + hist->GetXaxis()->SetBinLabel(7, "TPC n#sigma"); + hist->GetXaxis()->SetBinLabel(8, "ITS hits"); + hist->GetXaxis()->SetBinLabel(9, "has TOF)"); + } + + recoQAHist.add("hMothIsPVContributer", "", HistType::kTH1F, {{2, 0.f, 2.f}}); + recoQAHist.add("hMothITSCls", "", HistType::kTH1F, {{8, 0.f, 8.f}}); + recoQAHist.add("hDaugIsPVContributer", "", HistType::kTH1F, {{2, 0.f, 2.f}}); + recoQAHist.add("hDaugITSCls", "", HistType::kTH1F, {{8, 0.f, 8.f}}); + recoQAHist.add("hDaugITSNSigma", "", HistType::kTH2F, {rigidityAxis, itsnsigmaAxis}); + recoQAHist.add("hRecoDaugPVsITSNSigma", "", HistType::kTH2F, {rigidityAxis, itsnsigmaAxis}); + recoQAHist.add("hRecoCandidateCount", "", HistType::kTH1F, {{4, 0.f, 4.f}}); + } + } + + Configurable skipRejectedEvents{"skipRejectedEvents", false, "Flag to skip events that fail event selection cuts"}; + Configurable doEventCut{"doEventCut", true, "Apply event selection"}; + Configurable maxZVertex{"maxZVertex", 10.0f, "Accepted z-vertex range (cm)"}; + + Configurable etaMax{"etaMax", 1., "eta cut for tracks"}; + Configurable minPtMoth{"minPtMoth", 0.5, "Minimum pT/z of the mother track"}; + Configurable tpcPidNsigmaCut{"tpcPidNsigmaCut", 5, "tpcPidNsigmaCut"}; + Configurable nTPCClusMinDaug{"nTPCClusMinDaug", 80, "daug NTPC clusters cut"}; + Configurable itsMaxChi2{"itsMaxChi2", 36, "max chi2 for ITS"}; + Configurable minRatioTPCNCls{"minRatioTPCNCls", 0.8, "min ratio of TPC crossed rows to findable clusters"}; + + Preslice permcCollision = o2::aod::mcparticle::mcCollisionId; + + // QA for mother track selection + template + bool motherTrackCheck(const TTrack& track, const std::shared_ptr hist) + { + hist->Fill(1); + + if (std::abs(track.eta()) > etaMax) { + return false; + } + hist->Fill(2); + + if (!track.has_collision()) { + return false; + } + hist->Fill(3); + + if (!track.hasITS() || track.hasTPC() || track.hasTOF()) { + return false; + } + hist->Fill(4); + + if (track.itsNCls() >= kITSLayers - 1) { + return false; + } + hist->Fill(5); + + if (track.itsNClsInnerBarrel() != kITSInnerBarrelLayers) { + return false; + } + hist->Fill(6); + + if (track.itsChi2NCl() >= itsMaxChi2) { + return false; + } + hist->Fill(7); + + if (track.pt() <= minPtMoth) { + return false; + } + hist->Fill(8); + + return true; + } + + // qa for daughter track selection + template + bool daughterTrackCheck(const TTrack& track, const std::shared_ptr hist, float tpcNSigma) + { + hist->Fill(1); + + if (std::abs(track.eta()) > etaMax) { + return false; + } + hist->Fill(2); + + if (!track.hasITS() || !track.hasTPC()) { + return false; + } + hist->Fill(3); + + if (track.tpcNClsCrossedRows() <= minRatioTPCNCls * track.tpcNClsFindable()) { + return false; + } + hist->Fill(4); + + if (track.tpcNClsFound() <= nTPCClusMinDaug) { + return false; + } + hist->Fill(5); + + if (std::abs(tpcNSigma) > tpcPidNsigmaCut) { + return false; + } + hist->Fill(6); + + if (track.itsNClsInnerBarrel() != 0 || track.itsNCls() > kITSInnerBarrelLayers) { + return false; + } + hist->Fill(7); + + if (track.hasTOF()) { + return false; + } + hist->Fill(8); + + return true; + } + + void processData(o2::aod::Collisions const&) + { + // dummy process function; + } + PROCESS_SWITCH(HyperkinkQa, processData, "process data", true); + + void processMC(aod::McCollisions const& mcCollisions, aod::McParticles const& particlesMC, MCLabeledCollisionsFull const& collisions, MCLabeledTracksIU const& tracks, aod::BCsWithTimestamps const&) + { + std::vector mcPartIndices; + setTrackIDForMC(mcPartIndices, particlesMC, tracks); + std::vector isSelectedMCCollisions(mcCollisions.size(), false); + std::vector dauIDList(2, -1); + for (const auto& collision : collisions) { + genQAHist.fill(HIST("hCollCounter"), 0.5); + if (doEventCut && (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || std::abs(collision.posZ()) > maxZVertex)) { + continue; + } + genQAHist.fill(HIST("hCollCounter"), 1.5); + isSelectedMCCollisions[collision.mcCollisionId()] = true; + } + + for (const auto& mcCollision : mcCollisions) { + genQAHist.fill(HIST("hMcCollCounter"), 0.5); + if (isSelectedMCCollisions[mcCollision.globalIndex()]) { // Check that the event is reconstructed and that the reconstructed events pass the selection + genQAHist.fill(HIST("hMcCollCounter"), 1.5); + } else { + if (skipRejectedEvents) { + continue; + } + } + + const auto& dparticlesMC = particlesMC.sliceBy(permcCollision, mcCollision.globalIndex()); + + for (const auto& mcparticle : dparticlesMC) { + if (std::abs(mcparticle.pdgCode()) != pdgMoth) { + continue; + } + bool isMatter = mcparticle.pdgCode() > 0; + genQAHist.fill(HIST("hGenHyperMothCounter"), 0.5); + genQAHist.fill(HIST("hGenHyperMothCounter"), isMatter ? 1.5 : 2.5); + + // QA for decay channels + bool isKinkSignal = false; + if (hypoMoth == kHypertriton) { + auto dChannel = H3LDecay::getDecayChannel(mcparticle, dauIDList); + if (dChannel == H3LDecay::k2bodyNeutral) { + genQAHist.fill(HIST("hGenHyperMothCounter"), isMatter ? 3.5 : 4.5); + isKinkSignal = true; + } else if (dChannel == H3LDecay::k2bodyCharged) { + genQAHist.fill(HIST("hGenHyperMothCounter"), isMatter ? 5.5 : 6.5); + } else if (dChannel == H3LDecay::k3bodyCharged) { + genQAHist.fill(HIST("hGenHyperMothCounter"), isMatter ? 7.5 : 8.5); + } else if (dChannel == H3LDecay::kNChannel) { + genQAHist.fill(HIST("hGenHyperMothCounter"), 9.5); + continue; + } + } else if (hypoMoth == kHyperhelium4sigma) { + auto dChannel = He4SDecay::getDecayChannel(mcparticle, dauIDList); + if (dChannel == He4SDecay::k2body) { + genQAHist.fill(HIST("hGenHyperMothCounter"), isMatter ? 3.5 : 4.5); + isKinkSignal = true; + } else if (dChannel == He4SDecay::k3body_p) { + genQAHist.fill(HIST("hGenHyperMothCounter"), isMatter ? 5.5 : 6.5); + } else if (dChannel == He4SDecay::k3body_n) { + genQAHist.fill(HIST("hGenHyperMothCounter"), isMatter ? 7.5 : 8.5); + } else if (dChannel == He4SDecay::kNChannel) { + genQAHist.fill(HIST("hGenHyperMothCounter"), 9.5); + continue; + } + } + + if (!isKinkSignal) { + continue; + } + recoQAHist.fill(HIST("hMothCounter"), 0); + + genQAHist.fill(HIST("hEvtSelectedHyperMothCounter"), 0.5); + if (isSelectedMCCollisions[mcCollision.globalIndex()]) { + genQAHist.fill(HIST("hEvtSelectedHyperMothCounter"), 1.5); + } + + float svPos[3] = {-999, -999, -999}; + std::vector> dauMom(kNDaughterType, std::vector(3, -999.0f)); + for (const auto& mcparticleDaughter : mcparticle.daughters_as()) { + for (int type = 0; type < kNDaughterType; type++) { + if (std::abs(mcparticleDaughter.pdgCode()) == pdgDaug[type]) { + dauMom[type][0] = mcparticleDaughter.px(); + dauMom[type][1] = mcparticleDaughter.py(); + dauMom[type][2] = mcparticleDaughter.pz(); + + if (type == kDaugCharged) { + svPos[0] = mcparticleDaughter.vx(); + svPos[1] = mcparticleDaughter.vy(); + svPos[2] = mcparticleDaughter.vz(); + + // if daughter track is reconstructed + if (mcPartIndices[mcparticleDaughter.globalIndex()] != -1) { + hDaugCounter->Fill(0.f); + auto track = tracks.rawIteratorAt(mcPartIndices[mcparticleDaughter.globalIndex()]); + float tpcNSigma = getTPCNSigma(track, pidTypeDaug); + daughterTrackCheck(track, hDaugCounter, tpcNSigma); + if (track.hasTPC()) { + hDaugTPCNSigma->Fill(track.p() * track.sign(), tpcNSigma); + } + } + } + } + } + } + + genQAHist.fill(HIST("hGenHyperMothP"), mcparticle.p()); + genQAHist.fill(HIST("hGenHyperMothPt"), mcparticle.pt()); + float ct = RecoDecay::sqrtSumOfSquares(svPos[0] - mcparticle.vx(), svPos[1] - mcparticle.vy(), svPos[2] - mcparticle.vz()) * massMoth / mcparticle.p(); + genQAHist.fill(HIST("hGenHyperMothCt"), ct); + float hypermothMCMass = RecoDecay::m(std::array{std::array{dauMom[kDaugCharged][0], dauMom[kDaugCharged][1], dauMom[kDaugCharged][2]}, std::array{dauMom[kDaugNeutral][0], dauMom[kDaugNeutral][1], dauMom[kDaugNeutral][2]}}, std::array{massChargedDaug, massNeutralDaug}); + genQAHist.fill(HIST("hMcRecoInvMass"), hypermothMCMass); + + // if mother track is reconstructed + if (mcPartIndices[mcparticle.globalIndex()] != -1) { + auto motherTrack = tracks.rawIteratorAt(mcPartIndices[mcparticle.globalIndex()]); + bool isGoodMother = motherTrackCheck(motherTrack, hMothCounter); + float svR = RecoDecay::sqrtSumOfSquares(svPos[0], svPos[1]); + float diffpt = mcparticle.pt() - 2 * motherTrack.pt(); + + recoQAHist.fill(HIST("h2TrueMotherDiffPtVsTrueSVR"), svR, diffpt); + recoQAHist.fill(HIST("h2TrueMotherDiffEtaVsTrueSVR"), svR, mcparticle.eta() - motherTrack.eta()); + if (isGoodMother) { + recoQAHist.fill(HIST("h2GoodMotherDiffPtVsTrueSVR"), svR, diffpt); + } + + // if mother track and charged daughters are all reconstructed + bool isDauReconstructed = mcPartIndices[dauIDList[0]] != -1; + if (isDauReconstructed) { + auto daughterTrack = tracks.rawIteratorAt(mcPartIndices[dauIDList[0]]); + bool isMoth = motherTrackCheck(motherTrack, hRecoMothCounter); + bool isDaug = daughterTrackCheck(daughterTrack, hRecoDaugCounter, getTPCNSigma(daughterTrack, pidTypeDaug)); + + recoQAHist.fill(HIST("hRecoCandidateCount"), 0.5); + recoQAHist.fill(HIST("hRecoMothCounter"), 0.5); + recoQAHist.fill(HIST("hMothITSCls"), motherTrack.itsNCls()); + recoQAHist.fill(HIST("hRecoDaugCounter"), 0.5); + recoQAHist.fill(HIST("hMothIsPVContributer"), motherTrack.isPVContributor() ? 1.5 : 0.5); + recoQAHist.fill(HIST("hDaugIsPVContributer"), daughterTrack.isPVContributor() ? 1.5 : 0.5); + + float itsNSigma = getITSNSigma(daughterTrack, itsResponse, pidTypeDaug); + if (daughterTrack.hasITS()) { + recoQAHist.fill(HIST("hDaugITSNSigma"), daughterTrack.sign() * daughterTrack.p(), itsNSigma); + recoQAHist.fill(HIST("hDaugITSCls"), daughterTrack.itsNCls()); + } + + if (motherTrack.has_collision() && daughterTrack.has_collision()) { + recoQAHist.fill(HIST("hRecoCandidateCount"), 1.5); + if (motherTrack.collisionId() == daughterTrack.collisionId()) { + recoQAHist.fill(HIST("hRecoCandidateCount"), 2.5); + } + } + + if (isMoth && isDaug) { + recoQAHist.fill(HIST("hRecoCandidateCount"), 3.5); + recoQAHist.fill(HIST("hRecoDaugPVsITSNSigma"), daughterTrack.sign() * daughterTrack.p(), itsNSigma); + } + } + } + } + } + } + PROCESS_SWITCH(HyperkinkQa, processMC, "do QA for MC prodcutions", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + metadataInfo.initMetadata(cfgc); + return WorkflowSpec{ + // Parse the metadata + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGLF/TableProducer/Nuspex/hypertriton3bodyfinder.cxx b/PWGLF/TableProducer/Nuspex/hypertriton3bodyfinder.cxx deleted file mode 100644 index b4445a5619a..00000000000 --- a/PWGLF/TableProducer/Nuspex/hypertriton3bodyfinder.cxx +++ /dev/null @@ -1,1197 +0,0 @@ -// 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. - -// This 3-body method is not recommended due to high cost of computing resources -// author: yuanzhe.wang@cern.ch - -#include -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "DCAFitter/DCAFitterN.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/Vtx3BodyTables.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "EventFiltering/filterTables.h" - -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using std::array; - -using FullTracksExtIU = soa::Join; -using MCLabeledTracksIU = soa::Join; - -template -bool is3bodyDecayedH3L(TMCParticle const& particle) -{ - if (particle.pdgCode() != 1010010030 && particle.pdgCode() != -1010010030) { - return false; - } - bool haveProton = false, havePionPlus = false, haveDeuteron = false; - bool haveAntiProton = false, havePionMinus = false, haveAntiDeuteron = false; - for (auto& mcparticleDaughter : particle.template daughters_as()) { - if (mcparticleDaughter.pdgCode() == 2212) - haveProton = true; - if (mcparticleDaughter.pdgCode() == -2212) - haveAntiProton = true; - if (mcparticleDaughter.pdgCode() == 211) - havePionPlus = true; - if (mcparticleDaughter.pdgCode() == -211) - havePionMinus = true; - if (mcparticleDaughter.pdgCode() == 1000010020) - haveDeuteron = true; - if (mcparticleDaughter.pdgCode() == -1000010020) - haveAntiDeuteron = true; - } - if (haveProton && havePionMinus && haveDeuteron && particle.pdgCode() == 1010010030) { - return true; - } else if (haveAntiProton && havePionPlus && haveAntiDeuteron && particle.pdgCode() == -1010010030) { - return true; - } - return false; -} - -namespace o2::aod -{ -namespace v0goodpostrack -{ -DECLARE_SOA_INDEX_COLUMN_FULL(GoodTrack, goodTrack, int, Tracks, "_GoodTrack"); -DECLARE_SOA_INDEX_COLUMN(Collision, collision); -} // namespace v0goodpostrack -DECLARE_SOA_TABLE(V0GoodPosTracks, "AOD", "V0GOODPOSTRACKS", o2::soa::Index<>, v0goodpostrack::GoodTrackId, v0goodpostrack::CollisionId); -namespace v0goodnegtrack -{ -DECLARE_SOA_INDEX_COLUMN_FULL(GoodTrack, goodTrack, int, Tracks, "_GoodTrack"); -DECLARE_SOA_INDEX_COLUMN(Collision, collision); -} // namespace v0goodnegtrack -DECLARE_SOA_TABLE(V0GoodNegTracks, "AOD", "V0GOODNEGTRACKS", o2::soa::Index<>, v0goodnegtrack::GoodTrackId, v0goodnegtrack::CollisionId); -namespace v0goodtrack -{ -DECLARE_SOA_INDEX_COLUMN_FULL(GoodTrack, goodTrack, int, Tracks, "_GoodTrack"); -DECLARE_SOA_INDEX_COLUMN(Collision, collision); -} // namespace v0goodtrack -DECLARE_SOA_TABLE(V0GoodTracks, "AOD", "V0GOODTRACKS", o2::soa::Index<>, v0goodtrack::GoodTrackId, v0goodtrack::CollisionId); -} // namespace o2::aod - -struct trackprefilter { - HistogramRegistry registry{ - "registry", - { - {"hCrossedRows", "hCrossedRows", {HistType::kTH1F, {{50, 0.0f, 200.0f}}}}, - {"hGoodTrackCount", "hGoodTrackCount", {HistType::kTH1F, {{4, 0.0f, 4.0f}}}}, - {"hGoodPosTrackCount", "hGoodPosTrackCount", {HistType::kTH1F, {{1, 0.0f, 1.0f}}}}, - {"hGoodNegTrackCount", "hGoodNegTrackCount", {HistType::kTH1F, {{1, 0.0f, 1.0f}}}}, - {"h3bodyCounter", "h3bodyCounter", {HistType::kTH1F, {{6, 0.0f, 6.0f}}}}, - }, - }; - - // change the dca cut for helium3 - Configurable mintpcNCls{"mintpcNCls", 70, "min tpc Nclusters"}; - Configurable tpcrefit{"tpcrefit", 0, "demand TPC refit"}; - - Produces v0GoodPosTracks; - Produces v0GoodNegTracks; - Produces v0GoodTracks; - - // Fix: Add PID and pt cuts to tracks - void processDefault(aod::Collision const& /*collision*/, - FullTracksExtIU const& tracks) - { - for (auto& t0 : tracks) { - registry.fill(HIST("hGoodTrackCount"), 0.5); - registry.fill(HIST("hCrossedRows"), t0.tpcNClsCrossedRows()); - if (tpcrefit) { - if (!(t0.trackType() & o2::aod::track::TPCrefit)) { - continue; // TPC refit - } - } - registry.fill(HIST("hGoodTrackCount"), 1.5); - if (t0.tpcNClsFound() < mintpcNCls) { - continue; - } - registry.fill(HIST("hGoodTrackCount"), 2.5); - if (t0.signed1Pt() > 0.0f) { - v0GoodPosTracks(t0.globalIndex(), t0.collisionId()); - registry.fill(HIST("hGoodPosTrackCount"), 0.5); - registry.fill(HIST("hGoodTrackCount"), 3.5); - } - if (t0.signed1Pt() < 0.0f) { - v0GoodNegTracks(t0.globalIndex(), t0.collisionId()); - registry.fill(HIST("hGoodNegTrackCount"), 0.5); - registry.fill(HIST("hGoodTrackCount"), 3.5); - } - v0GoodTracks(t0.globalIndex(), t0.collisionId()); - } - } - PROCESS_SWITCH(trackprefilter, processDefault, "Default process function", true); - - // process function for MC d3body check - // void processCheck(aod::Collision const& collision, aod::Decay3Bodys const& decay3bodys, - void processCheck(aod::Decay3Bodys const& decay3bodys, - MCLabeledTracksIU const& /*tracks*/, aod::McParticles const& /*particlesMC*/) - { - for (auto& d3body : decay3bodys) { - registry.fill(HIST("h3bodyCounter"), 0.5); - auto lTrack0 = d3body.track0_as(); - auto lTrack1 = d3body.track1_as(); - auto lTrack2 = d3body.track2_as(); - if (!lTrack0.has_mcParticle() || !lTrack1.has_mcParticle() || !lTrack2.has_mcParticle()) { - continue; - } - registry.fill(HIST("h3bodyCounter"), 1.5); - auto lMCTrack0 = lTrack0.mcParticle_as(); - auto lMCTrack1 = lTrack1.mcParticle_as(); - auto lMCTrack2 = lTrack2.mcParticle_as(); - if (!lMCTrack0.has_mothers() || !lMCTrack1.has_mothers() || !lMCTrack2.has_mothers()) { - continue; - } - registry.fill(HIST("h3bodyCounter"), 2.5); - - int lPDG = -1; - bool is3bodyDecay = false; - for (auto& lMother0 : lMCTrack0.mothers_as()) { - for (auto& lMother1 : lMCTrack1.mothers_as()) { - for (auto& lMother2 : lMCTrack2.mothers_as()) { - if (lMother0.globalIndex() == lMother1.globalIndex() && lMother0.globalIndex() == lMother2.globalIndex()) { - lPDG = lMother1.pdgCode(); - if (lPDG == 1010010030 && lMCTrack0.pdgCode() == 2212 && lMCTrack1.pdgCode() == -211 && lMCTrack2.pdgCode() == 1000010020) { - is3bodyDecay = true; // vtxs with the same mother - } - if (lPDG == -1010010030 && lMCTrack0.pdgCode() == 211 && lMCTrack1.pdgCode() == -2212 && lMCTrack2.pdgCode() == -1000010020) { - is3bodyDecay = true; // vtxs with the same mother - } - } - } - } - } // end association check - - if (!is3bodyDecay || std::abs(lPDG) != 1010010030) { - continue; - } - registry.fill(HIST("h3bodyCounter"), 3.5); - if (lTrack0.collisionId() != lTrack1.collisionId() || lTrack0.collisionId() != lTrack2.collisionId()) { - continue; - } - registry.fill(HIST("h3bodyCounter"), 4.5); - - if (lTrack0.collisionId() != d3body.collisionId()) { - continue; - } - registry.fill(HIST("h3bodyCounter"), 5.5); - - // LOG(info) << "; Track0ID: " << lTrack0.globalIndex() << "; Track1ID:" << lTrack1.globalIndex() << "; Track2ID:" << lTrack2.globalIndex(); - v0GoodPosTracks(lTrack0.globalIndex(), lTrack0.collisionId()); - v0GoodNegTracks(lTrack1.globalIndex(), lTrack1.collisionId()); - v0GoodTracks(lTrack2.globalIndex(), lTrack2.collisionId()); - } - } - PROCESS_SWITCH(trackprefilter, processCheck, "Check specific paired tracks", false); -}; - -struct hypertriton3bodyFinder { - - Produces vtx3bodydata; - Service ccdb; - - // Configurables - Configurable UseCFFilter{"UseCFFilter", true, "Reject event without CF LD trigger"}; - Configurable RejectBkgInMC{"RejectBkgInMC", false, "Reject fake 3-body pairs in MC check"}; - - Configurable d_UseAbsDCA{"d_UseAbsDCA", true, "Use Abs DCAs"}; - Configurable d_bz_input{"d_bz", -999, "bz field, -999 is automatic"}; - - // Selection criteria - Configurable minRToMeanVertex = {"minRToMeanVertex", 0.5, ""}; ///< min radial distance of V0 from beam line (mean vertex) - // Configurable causalityRTolerance = {"causalityRTolerance", 1., ""}; ///< V0 radius cannot exceed its contributors minR by more than this value - Configurable maxV0ToProngsRDiff = {"maxV0ToProngsRDiff", 50., ""}; ///< V0 radius cannot be lower than this ammount wrt minR of contributors - Configurable minPtV0 = {"minPtV0", 0.5, ""}; ///< v0 minimum pT - Configurable maxTglV0 = {"maxTglV0", 2., ""}; ///< maximum tgLambda of V0 - Configurable maxDCAXY2ToMeanVertex3bodyV0 = {"maxDCAXY2ToMeanVertex3bodyV0", 2 * 2, ""}; - Configurable minCosPAXYMeanVertex3bodyV0 = {"minCosPAXYMeanVertex3bodyV0", 0.9, ""}; ///< min cos of PA to beam line (mean vertex) in tr. plane for 3body V0 cand. - Configurable minCosPA3bodyV0 = {"minCosPA3bodyV0", 0.8, ""}; // min cos of PA to PV for 3body V0 - - // for 3 body reconstructed Vertex - Configurable minbachPt = {"minbachPt", 0.6, ""}; ///< Minimum bachelor Pt - Configurable maxRDiff3bodyV0 = {"maxRDiff3bodyV0", 3, ""}; ///< Maximum difference between V0 and 3body radii - Configurable minPt3Body = {"minPt3Body", 0.01, ""}; // minimum pT of 3body Vertex - Configurable maxTgl3Body = {"maxTgl3Body", 2, ""}; // maximum tgLambda of 3body Vertex - Configurable minCosPA3body = {"minCosPA3body", 0.8, ""}; // min cos of PA to PV for 3body Vertex - - // for DCA - Configurable dcavtxdau{"dcavtxdau", 2.0, "DCA Vtx Daughters"}; - Configurable d_UseH3LDCACut{"d_UseH3LDCACut", true, "Use Cuts for H3L DCA to PV"}; - Configurable maxDCAXY3Body{"maxDCAXY3Body", 0.5, "DCAXY H3L to PV"}; // max DCA of 3 body decay to PV in XY - Configurable maxDCAZ3Body{"maxDCAZ3Body", 1.0, "DCAZ H3L to PV"}; // max DCA of 3 body decay to PV in Z - - Configurable useMatCorrType{"useMatCorrType", 2, "0: none, 1: TGeo, 2: LUT"}; - // CCDB options - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - - Preslice perCollisionGoodPosTracks = o2::aod::v0goodpostrack::collisionId; - Preslice perCollisionGoodNegTracks = o2::aod::v0goodnegtrack::collisionId; - Preslice perCollisionGoodTracks = o2::aod::v0goodtrack::collisionId; - Preslice perCollisionV0s = o2::aod::v0::collisionId; - Preslice perCollisionV0Datas = o2::aod::v0data::collisionId; - - // Helper struct to pass V0 information - HistogramRegistry registry{ - "registry", - { - {"hEventCounter", "hEventCounter", {HistType::kTH1F, {{2, 0.0f, 2.0f}}}}, - {"hDauTrackCounter", "hDauTrackCounter", {HistType::kTH1F, {{3, 0.0f, 3.0f}}}}, - {"hV0Counter", "hV0Counter", {HistType::kTH1F, {{8, -0.5f, 7.5f}}}}, - {"hTrueV0Counter", "hTrueV0Counter", {HistType::kTH1F, {{8, -0.5f, 7.5f}}}}, - {"hVtx3BodyCounter", "hVtx3BodyCounter", {HistType::kTH1F, {{9, -0.5f, 8.5f}}}}, - {"hTrueVtx3BodyCounter", "hTrueVtx3BodyCounter", {HistType::kTH1F, {{9, -0.5f, 8.5f}}}}, - {"hVirtLambaCounter", "hVirtualLambaCounter", {HistType::kTH1F, {{6, -0.5f, 5.5f}}}}, - {"hCFFilteredVirtLambaCounter", "hCFFilteredVirtLambaCounter", {HistType::kTH1F, {{6, -0.5f, 5.5f}}}}, - }, - }; - - //------------------------------------------------------------------ - // Fill stats histograms - enum v0step { kV0All = 0, - kV0hasSV, - kV0Radius, - kV0Pt, - kV0TgLamda, - kV0InvMass, - kV0DcaXY, - kV0CosPA, - kNV0Steps }; - enum vtxstep { kVtxAll = 0, - kVtxbachPt, - kVtxhasSV, - kVtxRadius, - kVtxPt, - kVtxTgLamda, - kVtxCosPA, - kVtxDcaDau, - kVtxDcaH3L, - kNVtxSteps }; - - // Helper struct to do bookkeeping of building parameters - struct { - std::array v0stats; - std::array truev0stats; - std::array vtxstats; - std::array truevtxstats; - std::array virtLambdastats; - } statisticsRegistry; - - void resetHistos() - { - for (Int_t ii = 0; ii < kNV0Steps; ii++) { - statisticsRegistry.v0stats[ii] = 0; - statisticsRegistry.truev0stats[ii] = 0; - } - for (Int_t ii = 0; ii < kNVtxSteps; ii++) { - statisticsRegistry.vtxstats[ii] = 0; - statisticsRegistry.truevtxstats[ii] = 0; - } - for (Int_t ii = 0; ii < 12; ii++) { - statisticsRegistry.virtLambdastats[ii] = 0; - } - } - - void fillHistos() - { - for (Int_t ii = 0; ii < kNV0Steps; ii++) { - registry.fill(HIST("hV0Counter"), ii, statisticsRegistry.v0stats[ii]); - registry.fill(HIST("hTrueV0Counter"), ii, statisticsRegistry.truev0stats[ii]); - } - for (Int_t ii = 0; ii < kNVtxSteps; ii++) { - registry.fill(HIST("hVtx3BodyCounter"), ii, statisticsRegistry.vtxstats[ii]); - registry.fill(HIST("hTrueVtx3BodyCounter"), ii, statisticsRegistry.truevtxstats[ii]); - } - for (Int_t ii = 0; ii < 3; ii++) { - registry.fill(HIST("hVirtLambaCounter"), ii, statisticsRegistry.virtLambdastats[ii]); - registry.fill(HIST("hVirtLambaCounter"), ii + 3, statisticsRegistry.virtLambdastats[ii + 3]); - registry.fill(HIST("hCFFilteredVirtLambaCounter"), ii, statisticsRegistry.virtLambdastats[ii + 6]); - registry.fill(HIST("hCFFilteredVirtLambaCounter"), ii + 3, statisticsRegistry.virtLambdastats[ii + 9]); - } - } - - // v0, vtx, and virtual Lambda statiscs - void FillV0Counter(int kn, bool istrue = false) - { - statisticsRegistry.v0stats[kn]++; - if (istrue) { - statisticsRegistry.truev0stats[kn]++; - } - } - void FillVtxCounter(int kn, bool istrue = false) - { - statisticsRegistry.vtxstats[kn]++; - if (istrue) { - statisticsRegistry.truevtxstats[kn]++; - } - } - //------------------------------------------------------------------ - - int mRunNumber; - float d_bz; - float maxSnp; // max sine phi for propagation - float maxStep; // max step size (cm) for propagation - o2::base::MatLayerCylSet* lut = nullptr; - o2::vertexing::DCAFitterN<2> fitter; - o2::vertexing::DCAFitterN<3> fitter3body; - - void init(InitContext&) - { - resetHistos(); - mRunNumber = 0; - d_bz = 0; - maxSnp = 0.85f; // could be changed later - maxStep = 2.00f; // could be changed later - - TString DauCounterbinLabel[3] = {"Proton", "Pion", "Deuteron"}; - TString V0CounterbinLabel[8] = {"Total", "hasSV", "V0R", "V0Pt", "TgLambda", "V0Mass", "DcaXY", "CosPA"}; - TString VtxCounterbinLabel[9] = {"Total", "bachPt", "hasSV", "VtxR", "VtxPt", "TgLambda", "CosPA", "DcaDau", "DcaH3L"}; - for (int i{0}; i < 3; i++) { - registry.get(HIST("hDauTrackCounter"))->GetXaxis()->SetBinLabel(i + 1, DauCounterbinLabel[i]); - } - for (int i{0}; i < kNV0Steps; i++) { - registry.get(HIST("hV0Counter"))->GetXaxis()->SetBinLabel(i + 1, V0CounterbinLabel[i]); - registry.get(HIST("hTrueV0Counter"))->GetXaxis()->SetBinLabel(i + 1, V0CounterbinLabel[i]); - } - for (int i{0}; i < kNVtxSteps; i++) { - registry.get(HIST("hVtx3BodyCounter"))->GetXaxis()->SetBinLabel(i + 1, VtxCounterbinLabel[i]); - registry.get(HIST("hTrueVtx3BodyCounter"))->GetXaxis()->SetBinLabel(i + 1, VtxCounterbinLabel[i]); - } - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - // Set 2-body fitter and 3-body fitter3body - fitter.setPropagateToPCA(true); - fitter.setMaxR(200.); //->maxRIni3body - fitter.setMinParamChange(1e-3); - fitter.setMinRelChi2Change(0.9); - fitter.setMaxDZIni(1e9); - fitter.setMaxChi2(1e9); - fitter.setUseAbsDCA(d_UseAbsDCA); - fitter3body.setPropagateToPCA(true); - fitter3body.setMaxR(200.); //->maxRIni3body - fitter3body.setMinParamChange(1e-3); - fitter3body.setMinRelChi2Change(0.9); - fitter3body.setMaxDZIni(1e9); - fitter3body.setMaxChi2(1e9); - fitter3body.setUseAbsDCA(d_UseAbsDCA); - - // Material correction in the DCA fitter - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - if (useMatCorrType == 1) { - LOGF(info, "TGeo correction requested, loading geometry"); - if (!o2::base::GeometryManager::isGeometryLoaded()) { - ccdb->get(geoPath); - } - matCorr = o2::base::Propagator::MatCorrType::USEMatCorrTGeo; - } - if (useMatCorrType == 2) { - LOGF(info, "LUT correction requested, loading LUT"); - lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); - matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; - } - fitter.setMatCorrType(matCorr); - fitter3body.setMatCorrType(matCorr); - } - - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) - { - if (mRunNumber == bc.runNumber()) { - return; - } - - // In case override, don't proceed, please - no CCDB access required - if (d_bz_input > -990) { - d_bz = d_bz_input; - fitter.setBz(d_bz); - fitter3body.setBz(d_bz); - o2::parameters::GRPMagField grpmag; - if (fabs(d_bz) > 1e-5) { - grpmag.setL3Current(30000.f / (d_bz / 5.0f)); - } - o2::base::Propagator::initFieldFromGRP(&grpmag); - mRunNumber = bc.runNumber(); - return; - } - - auto run3grp_timestamp = bc.timestamp(); - o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); - o2::parameters::GRPMagField* grpmag = 0x0; - if (grpo) { - o2::base::Propagator::initFieldFromGRP(grpo); - // Fetch magnetic field from ccdb for current collision - d_bz = grpo->getNominalL3Field(); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); - if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; - } - o2::base::Propagator::initFieldFromGRP(grpmag); - // Fetch magnetic field from ccdb for current collision - d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; - } - mRunNumber = bc.runNumber(); - // Set magnetic field value once known - fitter.setBz(d_bz); - fitter3body.setBz(d_bz); - - if (useMatCorrType == 2) { - // setMatLUT only after magfield has been initalized - // (setMatLUT has implicit and problematic init field call if not) - o2::base::Propagator::Instance()->setMatLUT(lut); - } - } - - //------------------------------------------------------------------ - // Check the info of good tracks - template - void CheckGoodTracks(TGoodTrackTable const& dGoodtracks, aod::McParticles const& /*particlesMC*/) - { - for (auto& goodtrackid : dGoodtracks) { - auto goodtrack = goodtrackid.template goodTrack_as(); - if (!goodtrack.has_mcParticle()) { - continue; - } - auto mcgoodtrack = goodtrack.template mcParticle_as(); - if (!mcgoodtrack.has_mothers()) { - continue; - } - bool flag_H3L = false; - for (auto& mothertrack : mcgoodtrack.template mothers_as()) { - if (is3bodyDecayedH3L(mothertrack)) { - flag_H3L = true; - } - } - if (flag_H3L && std::abs(mcgoodtrack.pdgCode()) == 2212) { - registry.fill(HIST("hDauTrackCounter"), 0.5); - } - if (flag_H3L && std::abs(mcgoodtrack.pdgCode()) == 211) { - registry.fill(HIST("hDauTrackCounter"), 1.5); - } - if (flag_H3L && std::abs(mcgoodtrack.pdgCode()) == 1000010020) { - registry.fill(HIST("hDauTrackCounter"), 2.5); - } - } - } - - o2::dataformats::VertexBase mMeanVertex{{0., 0., 0.}, {0.1 * 0.1, 0., 0.1 * 0.1, 0., 0., 6. * 6.}}; - //------------------------------------------------------------------ - // Virtual Lambda V0 finder - template - bool DecayV0Finder(TCollisionTable const& dCollision, TTrackTable const& dPtrack, TTrackTable const& dNtrack, float& rv0, bool isTrue3bodyV0 = false) - { - if (dPtrack.collisionId() != dNtrack.collisionId()) { - return false; - } - FillV0Counter(kV0All, isTrue3bodyV0); - if (!isTrue3bodyV0 && RejectBkgInMC) { - return false; - } - - auto Track0 = getTrackParCov(dPtrack); - auto Track1 = getTrackParCov(dNtrack); - int nCand = fitter.process(Track0, Track1); - if (nCand == 0) { - return false; - } - FillV0Counter(kV0hasSV, isTrue3bodyV0); - - // validate V0 radial position - // First check closeness to the beam-line as same as SVertexer - const auto& v0XYZ = fitter.getPCACandidate(); - float dxv0 = v0XYZ[0] - mMeanVertex.getX(), dyv0 = v0XYZ[1] - mMeanVertex.getY(), r2v0 = dxv0 * dxv0 + dyv0 * dyv0; - // float rv0 = std::sqrt(r2v0); - rv0 = std::sqrt(r2v0); - if (rv0 < minRToMeanVertex) { - return false; - } - FillV0Counter(kV0Radius, isTrue3bodyV0); - - // Not involved: Get minR with same way in SVertexer - // float drv0P = rv0 - Track0minR, drv0N = rv0 - Track1minR; - - // check: if the process function finish the propagation - if (!fitter.isPropagateTracksToVertexDone() && !fitter.propagateTracksToVertex()) { - return false; - } - - auto& trPProp = fitter.getTrack(0); - auto& trNProp = fitter.getTrack(1); - std::array pP, pN; - trPProp.getPxPyPzGlo(pP); - trNProp.getPxPyPzGlo(pN); - // estimate DCA of neutral V0 track to beamline: straight line with parametric equation - // x = X0 + pV0[0]*t, y = Y0 + pV0[1]*t reaches DCA to beamline (Xv, Yv) at - // t = -[ (x0-Xv)*pV0[0] + (y0-Yv)*pV0[1]) ] / ( pT(pV0)^2 ) - // Similar equation for 3D distance involving pV0[2] - std::array pV0 = {pP[0] + pN[0], pP[1] + pN[1], pP[2] + pN[2]}; - float pt2V0 = pV0[0] * pV0[0] + pV0[1] * pV0[1], prodXYv0 = dxv0 * pV0[0] + dyv0 * pV0[1], tDCAXY = prodXYv0 / pt2V0; - float p2V0 = pt2V0 + pV0[2] * pV0[2], ptV0 = std::sqrt(pt2V0); - if (ptV0 < minPtV0) { // pt cut - return false; - } - FillV0Counter(kV0Pt, isTrue3bodyV0); - - if (pV0[2] / ptV0 > maxTglV0) { // tgLambda cut - return false; - } - FillV0Counter(kV0TgLamda, isTrue3bodyV0); - - // apply mass selections - float massV0LambdaHyp = RecoDecay::m(array{array{pP[0], pP[1], pP[2]}, array{pN[0], pN[1], pN[2]}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); - float massV0AntiLambdaHyp = RecoDecay::m(array{array{pP[0], pP[1], pP[2]}, array{pN[0], pN[1], pN[2]}}, array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton}); - float massMargin = 20 * (0.001 * (1. + 0.5 * ptV0)) + 0.07; - if (massV0LambdaHyp - o2::constants::physics::MassLambda > massMargin && massV0AntiLambdaHyp - o2::constants::physics::MassLambda > massMargin) { - return false; - } - FillV0Counter(kV0InvMass, isTrue3bodyV0); - - float dcaX = dxv0 - pV0[0] * tDCAXY, dcaY = dyv0 - pV0[1] * tDCAXY, dca2 = dcaX * dcaX + dcaY * dcaY; - float cosPAXY = prodXYv0 / std::sqrt(r2v0 * pt2V0); - if (dca2 > maxDCAXY2ToMeanVertex3bodyV0) { - return false; - } - FillV0Counter(kV0DcaXY, isTrue3bodyV0); - - if (cosPAXY < minCosPAXYMeanVertex3bodyV0) { - return false; - } - float dx = v0XYZ[0] - dCollision.posX(), dy = v0XYZ[1] - dCollision.posY(), dz = v0XYZ[2] - dCollision.posZ(), prodXYZv0 = dx * pV0[0] + dy * pV0[1] + dz * pV0[2]; - float cosPA = prodXYZv0 / std::sqrt((dx * dx + dy * dy + dz * dz) * p2V0); - if (cosPA < minCosPA3bodyV0) { - return false; - } - FillV0Counter(kV0CosPA, isTrue3bodyV0); - return true; - } - //------------------------------------------------------------------ - // 3body decay vertex finder - template - void Decay3bodyFinder(TCollisionTable const& dCollision, TTrackTable const& dPtrack, TTrackTable const& dNtrack, TTrackTable const& dBachtrack, float const& rv0, bool isTrue3bodyVtx = false) - { - if (dPtrack.collisionId() != dBachtrack.collisionId()) { - return; - } - if (dPtrack.globalIndex() == dBachtrack.globalIndex()) { - return; // skip the track used by V0 - } - FillVtxCounter(kVtxAll, isTrue3bodyVtx); - if (!isTrue3bodyVtx && RejectBkgInMC) { - return; - } - - auto track0 = getTrackParCov(dPtrack); - auto track1 = getTrackParCov(dNtrack); - auto bach = getTrackParCov(dBachtrack); - - if (bach.getPt() < minbachPt) { - return; - } - FillVtxCounter(kVtxbachPt, isTrue3bodyVtx); - - int n3bodyVtx = fitter3body.process(track0, track1, bach); - if (n3bodyVtx == 0) { // discard this pair - return; - } - FillVtxCounter(kVtxhasSV, isTrue3bodyVtx); - - const auto& vertexXYZ = fitter3body.getPCACandidatePos(); - // make sure the cascade radius is smaller than that of the vertex - float dxc = vertexXYZ[0] - dCollision.posX(), dyc = vertexXYZ[1] - dCollision.posY(), dzc = vertexXYZ[2] - dCollision.posZ(), r2vertex = dxc * dxc + dyc * dyc; - float rvertex = std::sqrt(r2vertex); - if (std::abs(rv0 - rvertex) > maxRDiff3bodyV0 || rvertex < minRToMeanVertex) { - return; - } - FillVtxCounter(kVtxRadius, isTrue3bodyVtx); - - // Not involved: bach.minR - rveretx check - - // check: if the process function finish the propagation - if (!fitter3body.isPropagateTracksToVertexDone() && !fitter3body.propagateTracksToVertex()) { - return; - } - - auto& tr0 = fitter3body.getTrack(0); - auto& tr1 = fitter3body.getTrack(1); - auto& tr2 = fitter3body.getTrack(2); - std::array p0, p1, p2; - tr0.getPxPyPzGlo(p0); - tr1.getPxPyPzGlo(p1); - tr2.getPxPyPzGlo(p2); - std::array p3B = {p0[0] + p1[0] + p2[0], p0[1] + p1[1] + p2[1], p0[2] + p1[2] + p2[2]}; - - float pt2 = p3B[0] * p3B[0] + p3B[1] * p3B[1], p2candidate = pt2 + p3B[2] * p3B[2]; - float pt = std::sqrt(pt2); - if (pt < minPt3Body) { // pt cut - return; - } - FillVtxCounter(kVtxPt, isTrue3bodyVtx); - - if (p3B[2] / pt > maxTgl3Body) { // tgLambda cut - return; - } - FillVtxCounter(kVtxTgLamda, isTrue3bodyVtx); - - float cosPA = (p3B[0] * dxc + p3B[1] * dyc + p3B[2] * dzc) / std::sqrt(p2candidate * (r2vertex + dzc * dzc)); - if (cosPA < minCosPA3body) { - return; - } - FillVtxCounter(kVtxCosPA, isTrue3bodyVtx); - - if (fitter3body.getChi2AtPCACandidate() > dcavtxdau) { - return; - } - FillVtxCounter(kVtxDcaDau, isTrue3bodyVtx); - - // Calculate DCA with respect to the collision associated to the V0, not individual tracks - gpu::gpustd::array dcaInfo; - - auto Track0Par = getTrackPar(dPtrack); - o2::base::Propagator::Instance()->propagateToDCABxByBz({dCollision.posX(), dCollision.posY(), dCollision.posZ()}, Track0Par, 2.f, fitter3body.getMatCorrType(), &dcaInfo); - auto Track0dcaXY = dcaInfo[0]; - auto Track0dca = std::sqrt(Track0dcaXY * Track0dcaXY + dcaInfo[1] * dcaInfo[1]); - - auto Track1Par = getTrackPar(dNtrack); - o2::base::Propagator::Instance()->propagateToDCABxByBz({dCollision.posX(), dCollision.posY(), dCollision.posZ()}, Track1Par, 2.f, fitter3body.getMatCorrType(), &dcaInfo); - auto Track1dcaXY = dcaInfo[0]; - auto Track1dca = std::sqrt(Track1dcaXY * Track1dcaXY + dcaInfo[1] * dcaInfo[1]); - - auto Track2Par = getTrackPar(dBachtrack); - o2::base::Propagator::Instance()->propagateToDCABxByBz({dCollision.posX(), dCollision.posY(), dCollision.posZ()}, Track2Par, 2.f, fitter3body.getMatCorrType(), &dcaInfo); - auto Track2dcaXY = dcaInfo[0]; - auto Track2dca = std::sqrt(Track2dcaXY * Track2dcaXY + dcaInfo[1] * dcaInfo[1]); - - // H3L DCA Check - // auto track3B = o2::track::TrackParCov(vertexXYZ, p3B, fitter3body.calcPCACovMatrixFlat(), t2.sign()); - auto track3B = o2::track::TrackParCov(vertexXYZ, p3B, dBachtrack.sign()); - o2::dataformats::DCA dca; - if (d_UseH3LDCACut && (!track3B.propagateToDCA({{dCollision.posX(), dCollision.posY(), dCollision.posZ()}, {dCollision.covXX(), dCollision.covXY(), dCollision.covYY(), dCollision.covXZ(), dCollision.covYZ(), dCollision.covZZ()}}, fitter3body.getBz(), &dca, 5.) || - std::abs(dca.getY()) > maxDCAXY3Body || std::abs(dca.getZ()) > maxDCAZ3Body)) { - return; - } - FillVtxCounter(kVtxDcaH3L, isTrue3bodyVtx); - - vtx3bodydata( - dPtrack.globalIndex(), dNtrack.globalIndex(), dBachtrack.globalIndex(), dCollision.globalIndex(), 0, - vertexXYZ[0], vertexXYZ[1], vertexXYZ[2], - p0[0], p0[1], p0[2], p1[0], p1[1], p1[2], p2[0], p2[1], p2[2], - fitter3body.getChi2AtPCACandidate(), - Track0dcaXY, Track1dcaXY, Track2dcaXY, - Track0dca, Track1dca, Track2dca, - 0); // To be fixed - } - //------------------------------------------------------------------ - // 3body decay finder for a collsion - template - void DecayFinder(TCollisionTable const& dCollision, TPosTrackTable const& dPtracks, TNegTrackTable const& dNtracks, TGoodTrackTable const& dGoodtracks) - { - for (auto& t0id : dPtracks) { // FIXME: turn into combination(...) - auto t0 = t0id.template goodTrack_as(); - - for (auto& t1id : dNtracks) { - auto t1 = t1id.template goodTrack_as(); - float rv0; - if (!DecayV0Finder(dCollision, t0, t1, rv0)) { - continue; - } - - for (auto& t2id : dGoodtracks) { - auto t2 = t2id.template goodTrack_as(); - Decay3bodyFinder(dCollision, t0, t1, t2, rv0); - } - } - } - fillHistos(); - resetHistos(); - } - //------------------------------------------------------------------ - // MC 3body decay vertex finder - template - void DecayFinderMC(TCollisionTable const& dCollision, TPosTrackTable const& dPtracks, TNegTrackTable const& dNtracks, TGoodTrackTable const& dGoodtracks) - { - for (auto& t0id : dPtracks) { // FIXME: turn into combination(...) - auto t0 = t0id.template goodTrack_as(); - for (auto& t1id : dNtracks) { - auto t1 = t1id.template goodTrack_as(); - if (t0.collisionId() != t1.collisionId()) { - continue; - } - - bool isTrue3bodyV0 = false; - if (t0.has_mcParticle() && t1.has_mcParticle()) { - auto t0mc = t0.template mcParticle_as(); - auto t1mc = t1.template mcParticle_as(); - if ((t0mc.pdgCode() == 2212 && t1mc.pdgCode() == -211) || (t0mc.pdgCode() == 211 && t1mc.pdgCode() == -2212)) { - if (t0mc.has_mothers() && t1mc.has_mothers()) { - for (auto& t0mother : t0mc.template mothers_as()) { - for (auto& t1mother : t1mc.template mothers_as()) { - if (t0mother.globalIndex() == t1mother.globalIndex() && std::abs(t0mother.pdgCode()) == 1010010030) { - isTrue3bodyV0 = true; - } - } - } - } - } - } - - float rv0; - if (!DecayV0Finder(dCollision, t0, t1, rv0, isTrue3bodyV0)) { - continue; - } - - for (auto& t2id : dGoodtracks) { - auto t2 = t2id.template goodTrack_as(); - - bool isTrue3bodyVtx = false; - if (t0.has_mcParticle() && t1.has_mcParticle() && t2.has_mcParticle()) { - auto t0mc = t0.template mcParticle_as(); - auto t1mc = t1.template mcParticle_as(); - auto t2mc = t2.template mcParticle_as(); - if ((t0mc.pdgCode() == 2212 && t1mc.pdgCode() == -211 && t2mc.pdgCode() == 1000010020) || (t0mc.pdgCode() == 211 && t1mc.pdgCode() == -2212 && t2mc.pdgCode() == -1000010020)) { - if (t0mc.has_mothers() && t1mc.has_mothers() && t2mc.has_mothers()) { - for (auto& t0mother : t0mc.template mothers_as()) { - for (auto& t1mother : t1mc.template mothers_as()) { - for (auto& t2mother : t2mc.template mothers_as()) { - if (t0mother.globalIndex() == t1mother.globalIndex() && t0mother.globalIndex() == t2mother.globalIndex() && std::abs(t0mother.pdgCode()) == 1010010030) { - isTrue3bodyVtx = true; - } - } - } - } - } - } - } - - Decay3bodyFinder(dCollision, t0, t1, t2, rv0, isTrue3bodyVtx); - } - } - } - fillHistos(); - resetHistos(); - } - //------------------------------------------------------------------ - // MC virtual lambda check - template - void VirtualLambdaCheck(TCollisionTable const& /*dCollision*/, TV0DataTable const& fullV0s, int bin) - { - for (auto& v0 : fullV0s) { - statisticsRegistry.virtLambdastats[bin]++; - auto postrack = v0.template posTrack_as(); - auto negtrack = v0.template negTrack_as(); - if (postrack.has_mcParticle() && negtrack.has_mcParticle()) { - auto postrackmc = postrack.template mcParticle_as(); - auto negtrackmc = negtrack.template mcParticle_as(); - - if ((postrackmc.pdgCode() == 2212 && negtrackmc.pdgCode() == -211) || (postrackmc.pdgCode() == 211 && negtrackmc.pdgCode() == -2212)) { - if (postrackmc.has_mothers() && negtrackmc.has_mothers()) { - for (auto& posmother : postrackmc.template mothers_as()) { - for (auto& negmother : negtrackmc.template mothers_as()) { - if (posmother.globalIndex() == negmother.globalIndex()) { - if (posmother.pdgCode() == 1010010030) - statisticsRegistry.virtLambdastats[bin + 1]++; - else if (posmother.pdgCode() == -1010010030) - statisticsRegistry.virtLambdastats[bin + 2]++; - } - } - } - } - } - } - } - fillHistos(); - resetHistos(); - } - - //------------------------------------------------------------------ - // Process Function - void processData(aod::Collision const& collision, aod::V0GoodPosTracks const& ptracks, aod::V0GoodNegTracks const& ntracks, aod::V0GoodTracks const& goodtracks, FullTracksExtIU const&, aod::BCsWithTimestamps const&) - { - auto bc = collision.bc_as(); - initCCDB(bc); - registry.fill(HIST("hEventCounter"), 0.5); - - DecayFinder(collision, ptracks, ntracks, goodtracks); - } - PROCESS_SWITCH(hypertriton3bodyFinder, processData, "Produce StoredVtx3BodyDatas with data", true); - - void processCFFilteredData(aod::Collisions const& collisions, aod::CFFilters const& cffilters, aod::V0GoodPosTracks const& Ptracks, aod::V0GoodNegTracks const& Ntracks, aod::V0GoodTracks const& Goodtracks, FullTracksExtIU const&, aod::BCsWithTimestamps const&) - { - for (int i{0}; i < collisions.size(); i++) { - auto collision = collisions.iteratorAt(i); - auto cffilter = cffilters.iteratorAt(i); - auto bc = collision.bc_as(); - initCCDB(bc); - registry.fill(HIST("hEventCounter"), 0.5); - - auto ptracks = Ptracks.sliceBy(perCollisionGoodPosTracks, collision.globalIndex()); - auto ntracks = Ntracks.sliceBy(perCollisionGoodNegTracks, collision.globalIndex()); - auto goodtracks = Goodtracks.sliceBy(perCollisionGoodTracks, collision.globalIndex()); - - if (!cffilter.hasLD() && UseCFFilter) { - continue; - } - registry.fill(HIST("hEventCounter"), 1.5); - - DecayFinder(collision, ptracks, ntracks, goodtracks); - } - } - PROCESS_SWITCH(hypertriton3bodyFinder, processCFFilteredData, "Produce StoredVtx3BodyDatas with data using CFtriggers", false); - - void processMC(aod::Collision const& collision, aod::V0GoodPosTracks const& ptracks, aod::V0GoodNegTracks const& ntracks, aod::V0GoodTracks const& goodtracks, aod::McParticles const& particlesMC, MCLabeledTracksIU const&, aod::BCsWithTimestamps const&) - { - auto bc = collision.bc_as(); - initCCDB(bc); - registry.fill(HIST("hEventCounter"), 0.5); - - CheckGoodTracks(goodtracks, particlesMC); - DecayFinderMC(collision, ptracks, ntracks, goodtracks); - } - PROCESS_SWITCH(hypertriton3bodyFinder, processMC, "Produce StoredVtx3BodyDatas with MC", false); - - void processCFFilteredMC(aod::Collisions const& collisions, aod::CFFilters const& cffilters, aod::V0GoodPosTracks const& Ptracks, aod::V0GoodNegTracks const& Ntracks, aod::V0GoodTracks const& Goodtracks, aod::V0s const& V0s, aod::V0Datas const& fullV0s, aod::McParticles const& particlesMC, MCLabeledTracksIU const&, aod::BCsWithTimestamps const&) - { - for (int i{0}; i < collisions.size(); i++) { - auto collision = collisions.iteratorAt(i); - auto cffilter = cffilters.iteratorAt(i); - auto bc = collision.bc_as(); - initCCDB(bc); - registry.fill(HIST("hEventCounter"), 0.5); - - auto goodtracks = Goodtracks.sliceBy(perCollisionGoodTracks, collision.globalIndex()); - CheckGoodTracks(goodtracks, particlesMC); - auto v0s = V0s.sliceBy(perCollisionV0s, collision.globalIndex()); - auto fullv0s = fullV0s.sliceBy(perCollisionV0Datas, collision.globalIndex()); - VirtualLambdaCheck(collision, v0s, 0); - VirtualLambdaCheck(collision, fullv0s, 3); - - if (!cffilter.hasLD() && UseCFFilter) { - continue; - } - registry.fill(HIST("hEventCounter"), 1.5); - - auto ptracks = Ptracks.sliceBy(perCollisionGoodPosTracks, collision.globalIndex()); - auto ntracks = Ntracks.sliceBy(perCollisionGoodNegTracks, collision.globalIndex()); - - VirtualLambdaCheck(collision, v0s, 6); - VirtualLambdaCheck(collision, fullv0s, 9); - DecayFinderMC(collision, ptracks, ntracks, goodtracks); - } - } - PROCESS_SWITCH(hypertriton3bodyFinder, processCFFilteredMC, "Produce StoredVtx3BodyDatas with MC using CFtriggers", false); -}; - -struct hypertriton3bodyLabelBuilder { - - Produces vtxlabels; - - // for bookkeeping purposes: how many V0s come from same mother etc - HistogramRegistry registry{ - "registry", - { - {"hLabelCounter", "hLabelCounter", {HistType::kTH1F, {{3, 0.0f, 3.0f}}}}, - {"hHypertritonMCPt", "hHypertritonMCPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}}, - {"hAntiHypertritonMCPt", "hAntiHypertritonMCPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}}, - {"hHypertritonMCMass", "hHypertritonMCMass", {HistType::kTH1F, {{40, 2.95f, 3.05f, "Inv. Mass (GeV/c^{2})"}}}}, - {"hAntiHypertritonMCMass", "hAntiHypertritonMCMass", {HistType::kTH1F, {{40, 2.95f, 3.05f, "Inv. Mass (GeV/c^{2})"}}}}, - {"hHypertritonMCLifetime", "hHypertritonMCLifetime", {HistType::kTH1F, {{50, 0.0f, 50.0f, "ct(cm)"}}}}, - {"hAntiHypertritonMCLifetime", "hAntiHypertritonMCLifetime", {HistType::kTH1F, {{50, 0.0f, 50.0f, "ct(cm)"}}}}, - }, - }; - - void init(InitContext const&) - { - registry.get(HIST("hLabelCounter"))->GetXaxis()->SetBinLabel(1, "Total"); - registry.get(HIST("hLabelCounter"))->GetXaxis()->SetBinLabel(2, "Same MotherParticle"); - registry.get(HIST("hLabelCounter"))->GetXaxis()->SetBinLabel(3, "True H3L"); - } - - Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; - - void processDoNotBuildLabels(aod::Collisions::iterator const&) - { - // dummy process function - should not be required in the future - } - PROCESS_SWITCH(hypertriton3bodyLabelBuilder, processDoNotBuildLabels, "Do not produce MC label tables", true); - - void processBuildLabels(aod::Vtx3BodyDatas const& vtx3bodydatas, MCLabeledTracksIU const&, aod::McParticles const& /*particlesMC*/) - { - std::vector lIndices; - lIndices.reserve(vtx3bodydatas.size()); - for (int ii = 0; ii < vtx3bodydatas.size(); ii++) { - lIndices[ii] = -1; - } - - for (auto& vtx3body : vtx3bodydatas) { - - int lLabel = -1; - int lPDG = -1; - float lPt = -1; - double MClifetime = -1; - bool is3bodyDecay = false; - int lGlobalIndex = -1; - - auto lTrack0 = vtx3body.track0_as(); - auto lTrack1 = vtx3body.track1_as(); - auto lTrack2 = vtx3body.track2_as(); - registry.fill(HIST("hLabelCounter"), 0.5); - - // Association check - // There might be smarter ways of doing this in the future - if (!lTrack0.has_mcParticle() || !lTrack1.has_mcParticle() || !lTrack2.has_mcParticle()) { - vtxlabels(-1); - continue; - } - auto lMCTrack0 = lTrack0.mcParticle_as(); - auto lMCTrack1 = lTrack1.mcParticle_as(); - auto lMCTrack2 = lTrack2.mcParticle_as(); - if (!lMCTrack0.has_mothers() || !lMCTrack1.has_mothers() || !lMCTrack2.has_mothers()) { - vtxlabels(-1); - continue; - } - - for (auto& lMother0 : lMCTrack0.mothers_as()) { - for (auto& lMother1 : lMCTrack1.mothers_as()) { - for (auto& lMother2 : lMCTrack2.mothers_as()) { - if (lMother0.globalIndex() == lMother1.globalIndex() && lMother0.globalIndex() == lMother2.globalIndex()) { - lGlobalIndex = lMother1.globalIndex(); - lPt = lMother1.pt(); - lPDG = lMother1.pdgCode(); - MClifetime = RecoDecay::sqrtSumOfSquares(lMCTrack2.vx() - lMother2.vx(), lMCTrack2.vy() - lMother2.vy(), lMCTrack2.vz() - lMother2.vz()) * o2::constants::physics::MassHyperTriton / lMother2.p(); - is3bodyDecay = true; // vtxs with the same mother - } - } - } - } // end association check - if (!is3bodyDecay) { - vtxlabels(-1); - continue; - } - registry.fill(HIST("hLabelCounter"), 1.5); - - // Intended for cross-checks only - // N.B. no rapidity cut! - if (lPDG == 1010010030 && lMCTrack0.pdgCode() == 2212 && lMCTrack1.pdgCode() == -211 && lMCTrack2.pdgCode() == 1000010020) { - lLabel = lGlobalIndex; - double hypertritonMCMass = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}, array{lMCTrack2.px(), lMCTrack2.py(), lMCTrack2.pz()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); - registry.fill(HIST("hLabelCounter"), 2.5); - registry.fill(HIST("hHypertritonMCPt"), lPt); - registry.fill(HIST("hHypertritonMCLifetime"), MClifetime); - registry.fill(HIST("hHypertritonMCMass"), hypertritonMCMass); - } - if (lPDG == -1010010030 && lMCTrack0.pdgCode() == 211 && lMCTrack1.pdgCode() == -2212 && lMCTrack2.pdgCode() == -1000010020) { - lLabel = lGlobalIndex; - double antiHypertritonMCMass = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}, array{lMCTrack2.px(), lMCTrack2.py(), lMCTrack2.pz()}}, array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}); - registry.fill(HIST("hLabelCounter"), 2.5); - registry.fill(HIST("hAntiHypertritonMCPt"), lPt); - registry.fill(HIST("hAntiHypertritonMCLifetime"), MClifetime); - registry.fill(HIST("hAntiHypertritonMCMass"), antiHypertritonMCMass); - } - - // Construct label table, only true hypertriton and true daughters with a specified order is labeled - // for matter: track0->p, track1->pi, track2->d - // for antimatter: track0->pi, track1->p, track2->d - vtxlabels(lLabel); - } - } - PROCESS_SWITCH(hypertriton3bodyLabelBuilder, processBuildLabels, "Produce MC label tables", false); -}; - -struct hypertriton3bodyComparewithDecay3body { - - HistogramRegistry registry{ - "registry", - { - {"hMCInfoCounter", "hMCInfoCounter", {HistType::kTH1F, {{8, 0.0f, 8.0f}}}}, - {"hCheckCounter", "hCheckCounter", {HistType::kTH1F, {{5, 0.0f, 5.0f}}}}, - {"hHypertritonMCPtTotal", "hHypertritonMCPtTotal", {HistType::kTH1F, {{20, 0.0f, 10.0f}}}}, - {"hHypertritonMCPt", "hHypertritonMCPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}}, - {"hAntiHypertritonMCPt", "hAntiHypertritonMCPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}}, - {"hHypertritonMCMass", "hHypertritonMCMass", {HistType::kTH1F, {{40, 2.95f, 3.05f}}}}, - {"hAntiHypertritonMCMass", "hAntiHypertritonMCMass", {HistType::kTH1F, {{40, 2.95f, 3.05f}}}}, - {"hPairedHypertritonMCPt", "hPairedHypertritonMCPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}}, - {"hPairedAntiHypertritonMCPt", "hPairedAntiHypertritonMCPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}}, - {"hSameMcIndexCounter", "hSameMcIndexCounter", {HistType::kTH1F, {{2, 0.0f, 2.0f}}}}, - }, - }; - - void init(InitContext const&) - { - registry.get(HIST("hCheckCounter"))->GetXaxis()->SetBinLabel(1, "Total"); - registry.get(HIST("hCheckCounter"))->GetXaxis()->SetBinLabel(2, "Sig in Decay3body"); - registry.get(HIST("hCheckCounter"))->GetXaxis()->SetBinLabel(3, "Sig SameCol"); - registry.get(HIST("hCheckCounter"))->GetXaxis()->SetBinLabel(4, "Sig contained by finder"); - registry.get(HIST("hCheckCounter"))->GetXaxis()->SetBinLabel(5, "Sig SameIndex"); - } - struct Indexdaughters { // check duplicated paired daughters - int64_t index0; - int64_t index1; - int64_t index2; - bool operator==(const Indexdaughters& t) const - { - return (this->index0 == t.index0 && this->index1 == t.index1 && this->index2 == t.index2); - } - }; - - void processDoNotCompare(aod::Collisions::iterator const&) - { - // dummy process function - should not be required in the future - } - PROCESS_SWITCH(hypertriton3bodyComparewithDecay3body, processDoNotCompare, "Do not do comparison", true); - - void processDoComparison(aod::Decay3Bodys const& decay3bodytable, soa::Join const& vtx3bodydatas, MCLabeledTracksIU const&, aod::McParticles const& /*particlesMC*/) - { - std::vector set_pair; - for (auto d3body : decay3bodytable) { - registry.fill(HIST("hCheckCounter"), 0.5); - registry.fill(HIST("hMCInfoCounter"), 0.5); - auto lTrack0 = d3body.track0_as(); - auto lTrack1 = d3body.track1_as(); - auto lTrack2 = d3body.track2_as(); - if (!lTrack0.has_mcParticle() || !lTrack1.has_mcParticle() || !lTrack2.has_mcParticle()) { - continue; - } - registry.fill(HIST("hMCInfoCounter"), 1.5); - auto lMCTrack0 = lTrack0.mcParticle_as(); - auto lMCTrack1 = lTrack1.mcParticle_as(); - auto lMCTrack2 = lTrack2.mcParticle_as(); - if (lMCTrack0.isPhysicalPrimary() || lMCTrack1.isPhysicalPrimary() || lMCTrack2.isPhysicalPrimary()) { - continue; - } - if (lMCTrack0.producedByGenerator() || lMCTrack1.producedByGenerator() || lMCTrack2.producedByGenerator()) { - continue; - } - registry.fill(HIST("hMCInfoCounter"), 2.5); - - if (!lMCTrack0.has_mothers() || !lMCTrack1.has_mothers() || !lMCTrack2.has_mothers()) { - continue; - } - registry.fill(HIST("hMCInfoCounter"), 3.5); - - int lPDG = -1; - float lPt = -1; - bool is3bodyDecayedH3L = false; - int lGlobalIndex = -1; - - for (auto& lMother0 : lMCTrack0.mothers_as()) { - for (auto& lMother1 : lMCTrack1.mothers_as()) { - for (auto& lMother2 : lMCTrack2.mothers_as()) { - registry.fill(HIST("hMCInfoCounter"), 4.5); - if (lMother0.globalIndex() == lMother1.globalIndex() && lMother0.globalIndex() == lMother2.globalIndex()) { // vtxs with the same mother - registry.fill(HIST("hMCInfoCounter"), 7.5); - lGlobalIndex = lMother1.globalIndex(); - lPDG = lMother1.pdgCode(); - lPt = lMother1.pt(); - if (lPDG == 1010010030 && lMCTrack0.pdgCode() == 2212 && lMCTrack1.pdgCode() == -211 && lMCTrack2.pdgCode() == 1000010020) { - is3bodyDecayedH3L = true; - double hypertritonMCMass = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}, array{lMCTrack2.px(), lMCTrack2.py(), lMCTrack2.pz()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); - registry.fill(HIST("hHypertritonMCPt"), lPt); - registry.fill(HIST("hHypertritonMCMass"), hypertritonMCMass); - } - if (lPDG == -1010010030 && lMCTrack0.pdgCode() == 211 && lMCTrack1.pdgCode() == -2212 && lMCTrack2.pdgCode() == -1000010020) { - is3bodyDecayedH3L = true; - double antiHypertritonMCMass = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}, array{lMCTrack2.px(), lMCTrack2.py(), lMCTrack2.pz()}}, array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}); - registry.fill(HIST("hAntiHypertritonMCPt"), lPt); - registry.fill(HIST("hAntiHypertritonMCMass"), antiHypertritonMCMass); - } - } - } - } - } // end association check - - if (!is3bodyDecayedH3L) { - continue; - } - - registry.fill(HIST("hCheckCounter"), 1.5); - registry.fill(HIST("hMCInfoCounter"), 5.5); - // for check - registry.fill(HIST("hHypertritonMCPtTotal"), lPt); - - Indexdaughters temp = {lMCTrack0.globalIndex(), lMCTrack1.globalIndex(), lMCTrack2.globalIndex()}; - auto p = std::find(set_pair.begin(), set_pair.end(), temp); - if (p == set_pair.end()) { - set_pair.push_back(temp); - registry.fill(HIST("hMCInfoCounter"), 6.5); - } - - if (lTrack0.collisionId() != lTrack1.collisionId() || lTrack0.collisionId() != lTrack2.collisionId()) { - continue; - } - registry.fill(HIST("hCheckCounter"), 2.5); - - for (auto vtx : vtx3bodydatas) { - if (vtx.mcParticleId() == -1) { - continue; - } - auto mcparticle = vtx.mcParticle_as(); - if (mcparticle.globalIndex() == lGlobalIndex) { - registry.fill(HIST("hCheckCounter"), 4.5); // rare case check: if motherId matches but daughters not - if (lTrack0.globalIndex() == vtx.track0Id() && lTrack1.globalIndex() == vtx.track1Id() && lTrack2.globalIndex() == vtx.track2Id()) { - registry.fill(HIST("hCheckCounter"), 3.5); - if (lPDG > 0) { - registry.fill(HIST("hPairedHypertritonMCPt"), lPt); - } else { - registry.fill(HIST("hPairedAntiHypertritonMCPt"), lPt); - } - break; - } - } - } - } - } - PROCESS_SWITCH(hypertriton3bodyComparewithDecay3body, processDoComparison, "Compare decay3bodys and finder method with MC", false); -}; - -struct hypertriton3bodyInitializer { - Spawns vtx3bodydatas; - void init(InitContext const&) {} -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - }; -} diff --git a/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx b/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx index 6d8e13e69a6..e607057e5c6 100644 --- a/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx @@ -159,6 +159,7 @@ struct lnnRecoTask { Configurable nSigmaCutMinTPC{"nSigmaCutMinTPC", -5, "triton dEdx cut (n sigma)"}; Configurable nSigmaCutMaxTPC{"nSigmaCutMaxTPC", 5, "triton dEdx cut (n sigma)"}; Configurable nTPCClusMin3H{"nTPCClusMin3H", 80, "triton NTPC clusters cut"}; + Configurable nTPCClusMinPi{"nTPCClusMinPi", 60, "pion NTPC clusters cut"}; Configurable ptMinTOF{"ptMinTOF", 0.8, "minimum pt for TOF cut"}; Configurable TrTOFMass2Cut{"TrTOFMass2Cut", 5.5, "minimum Triton mass square to TOF"}; Configurable BetaTrTOF{"BetaTrTOF", 0.4, "minimum beta TOF cut"}; @@ -207,6 +208,7 @@ struct lnnRecoTask { std::vector filledMothers; // vector to keep track of the collisions passing the event selection in the MC std::vector isGoodCollision; + std::vector collisionFT0Ccent; // vector to armazenade h3Track Preslice perCollision = o2::aod::v0::collisionId; @@ -349,7 +351,8 @@ struct lnnRecoTask { auto posTrack = v0.posTrack_as(); auto negTrack = v0.negTrack_as(); - if (std::abs(posTrack.eta()) > etaMax || std::abs(negTrack.eta()) > etaMax) { + /// remove tracks wo TPC information, too much bkg for Lnn analysis + if (std::abs(posTrack.eta()) > etaMax || std::abs(negTrack.eta()) > etaMax || !posTrack.hasTPC() || !negTrack.hasTPC()) { continue; } @@ -368,8 +371,8 @@ struct lnnRecoTask { hdEdxTot->Fill(-negRigidity, negTrack.tpcSignal()); // ITS only tracks do not have TPC information. TPCnSigma: only lower cut to allow for triton reconstruction - bool is3H = posTrack.hasTPC() && nSigmaTPCpos > nSigmaCutMinTPC && nSigmaTPCpos < nSigmaCutMaxTPC; - bool isAnti3H = negTrack.hasTPC() && nSigmaTPCneg > nSigmaCutMinTPC && nSigmaTPCneg < nSigmaCutMaxTPC; + bool is3H = nSigmaTPCpos > nSigmaCutMinTPC && nSigmaTPCpos < nSigmaCutMaxTPC; + bool isAnti3H = nSigmaTPCneg > nSigmaCutMinTPC && nSigmaTPCneg < nSigmaCutMaxTPC; if (!is3H && !isAnti3H) // discard if both tracks are not 3H candidates continue; @@ -391,13 +394,15 @@ struct lnnRecoTask { continue; } auto& h3track = lnnCand.isMatter ? posTrack : negTrack; + auto& pitrack = lnnCand.isMatter ? negTrack : posTrack; auto& h3Rigidity = lnnCand.isMatter ? posRigidity : negRigidity; if (h3Rigidity < TPCRigidityMin3H || h3track.tpcNClsFound() < nTPCClusMin3H || h3track.tpcChi2NCl() < Chi2nClusTPCMin || h3track.tpcChi2NCl() > Chi2nClusTPCMax || - h3track.itsChi2NCl() > Chi2nClusITS) { + h3track.itsChi2NCl() > Chi2nClusITS || + pitrack.tpcNClsFound() < nTPCClusMinPi) { continue; } @@ -503,7 +508,7 @@ struct lnnRecoTask { } // if survived all selections, propagate decay daughters to PV - gpu::gpustd::array dcaInfo; + std::array dcaInfo; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, h3PropTrack, 2.f, fitter.getMatCorrType(), &dcaInfo); lnnCand.h3DCAXY = dcaInfo[0]; @@ -623,6 +628,8 @@ struct lnnRecoTask { isGoodCollision.clear(); isGoodCollision.resize(mcCollisions.size(), false); + collisionFT0Ccent.clear(); + collisionFT0Ccent.resize(mcCollisions.size(), -1.f); for (const auto& collision : collisions) { lnnCandidates.clear(); @@ -643,6 +650,7 @@ struct lnnRecoTask { if (collision.has_mcCollision()) { isGoodCollision[collision.mcCollisionId()] = true; + collisionFT0Ccent[collision.mcCollisionId()] = collision.centFT0C(); } const uint64_t collIdx = collision.globalIndex(); @@ -727,7 +735,7 @@ struct lnnRecoTask { lnnCand.posTrackID = -1; lnnCand.negTrackID = -1; lnnCand.isSignal = true; - outputMCTable(-1, -1, -1, + outputMCTable(-1, collisionFT0Ccent[mcPart.mcCollisionId()], -1, -1, -1, -1, 0, -1, -1, -1, diff --git a/PWGLF/TableProducer/Nuspex/nucleiFlowTree.cxx b/PWGLF/TableProducer/Nuspex/nucleiFlowTree.cxx new file mode 100644 index 00000000000..14192166fae --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/nucleiFlowTree.cxx @@ -0,0 +1,489 @@ +// 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. +// +// Nuclei spectra analysis task +// ======================== +// +// Executable + dependencies: +// +// Data (run3): +// o2-analysis-lf-nuclei-spectra, o2-analysis-timestamp +// o2-analysis-pid-tof-base, o2-analysis-multiplicity-table, o2-analysis-event-selection +// (to add flow: o2-analysis-qvector-table, o2-analysis-centrality-table) + +#include +#include +#include +#include +#include + +#include "Math/Vector4D.h" + +#include "CCDB/BasicCCDBManager.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/PID/PIDTOF.h" +#include "Common/TableProducer/PID/pidTOFBase.h" +#include "Common/Core/EventPlaneHelper.h" +#include "Common/DataModel/Qvectors.h" +#include "Common/Tools/TrackTuner.h" +#include "Common/Core/RecoDecay.h" + +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" + +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "ReconstructionDataFormats/Track.h" + +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/LFSlimNucleiTables.h" + +#include "TRandom3.h" + +#include "nucleiUtils.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +struct nucleiFlowTree { + enum { + kProton = BIT(0), + kDeuteron = BIT(1), + kTriton = BIT(2), + kHe3 = BIT(3), + kHe4 = BIT(4), + kHasTOF = BIT(5), + kHasTRD = BIT(6), + kIsAmbiguous = BIT(7), /// just a placeholder now + kITSrof = BIT(8), + kIsPhysicalPrimary = BIT(9), /// MC flags starting from the second half of the short + kIsSecondaryFromMaterial = BIT(10), + kIsSecondaryFromWeakDecay = BIT(11) /// the last 4 bits are reserved for the PID in tracking + }; + + Produces nucleiTable; + Produces nucleiTableMC; + Produces nucleiTableFlow; + Service ccdb; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + + Configurable cfgCompensatePIDinTracking{"cfgCompensatePIDinTracking", false, "If true, divide tpcInnerParam by the electric charge"}; + + Configurable cfgCentralityEstimator{"cfgCentralityEstimator", 0, "Centrality estimator (FV0A: 0, FT0M: 1, FT0A: 2, FT0C: 3)"}; + Configurable cfgCMrapidity{"cfgCMrapidity", 0.f, "Rapidity of the center of mass (only for p-Pb)"}; + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"}; + Configurable cfgCutTpcMom{"cfgCutTpcMom", 0.2f, "Minimum TPC momentum for tracks"}; + Configurable cfgCutRapidityMin{"cfgCutRapidityMin", -0.5, "Minimum rapidity for tracks"}; + Configurable cfgCutRapidityMax{"cfgCutRapidityMax", 0.5, "Maximum rapidity for tracks"}; + Configurable cfgCutOnReconstructedRapidity{"cfgCutOnReconstructedRapidity", false, "Cut on reconstructed rapidity"}; + Configurable cfgCutNclusITS{"cfgCutNclusITS", 5, "Minimum number of ITS clusters"}; + Configurable cfgCutNclusTPC{"cfgCutNclusTPC", 70, "Minimum number of TPC clusters"}; + Configurable cfgCutPtMinTree{"cfgCutPtMinTree", 0.2f, "Minimum track transverse momentum for tree saving"}; + Configurable cfgCutPtMaxTree{"cfgCutPtMaxTree", 15.0f, "Maximum track transverse momentum for tree saving"}; + + Configurable> cfgEventSelections{"cfgEventSelections", {nuclei::EvSelDefault[0], 8, 1, nuclei::eventSelectionLabels, nuclei::eventSelectionTitle}, "Event selections"}; + + Configurable> cfgMomentumScalingBetheBloch{"cfgMomentumScalingBetheBloch", {nuclei::bbMomScalingDefault[0], 5, 2, nuclei::names, nuclei::chargeLabelNames}, "TPC Bethe-Bloch momentum scaling for light nuclei"}; + Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {nuclei::betheBlochDefault[0], 5, 6, nuclei::names, nuclei::betheBlochParNames}, "TPC Bethe-Bloch parameterisation for light nuclei"}; + Configurable> cfgNsigmaTPC{"cfgNsigmaTPC", {nuclei::nSigmaTPCdefault[0], 5, 2, nuclei::names, nuclei::nSigmaConfigName}, "TPC nsigma selection for light nuclei"}; + Configurable> cfgDCAcut{"cfgDCAcut", {nuclei::DCAcutDefault[0], 5, 2, nuclei::names, nuclei::nDCAConfigName}, "Max DCAxy and DCAz for light nuclei"}; + Configurable> cfgDownscaling{"cfgDownscaling", {nuclei::DownscalingDefault[0], 5, 1, nuclei::names, nuclei::DownscalingConfigName}, "Fraction of kept candidates for light nuclei"}; + Configurable> cfgTreeConfig{"cfgTreeConfig", {nuclei::TreeConfigDefault[0], 5, 2, nuclei::names, nuclei::treeConfigNames}, "Filtered trees configuration"}; + + ConfigurableAxis cfgNITSClusBins{"cfgNITSClusBins", {3, 4.5, 7.5}, "N ITS clusters binning"}; + ConfigurableAxis cfgNTPCClusBins{"cfgNTPCClusBins", {3, 89.5, 159.5}, "N TPC clusters binning"}; + + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "Skimmed dataset processing"}; + + o2::track::TrackParametrizationWithError mTrackParCov; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + + // CCDB options + Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrLUT), "Type of material correction"}; + Configurable cfgCCDBurl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable cfgZorroCCDBpath{"cfgZorroCCDBpath", "/Users/m/mpuccio/EventFiltering/OTS/", "path to the zorro ccdb objects"}; + int mRunNumber = 0; + float mBz = 0.f; + + using TrackCandidates = soa::Join; + + // Configurable Harmonics index + Configurable cfgHarmonics{"cfgHarmonics", 2, "Harmonics index for flow analysis"}; + + // Collisions with chentrality + using CollWithCent = soa::Join::iterator; + + // Flow analysis + using CollWithEP = soa::Join::iterator; + + using CollWithQvec = soa::Join::iterator; + + HistogramRegistry spectra{"spectra", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + float computeEventPlane(float y, float x) + { + return 0.5 * std::atan2(y, x); + } + + template + bool eventSelectionWithHisto(Tcoll& collision) + { + spectra.fill(HIST("hEventSelections"), 0); + + if (cfgEventSelections->get(nuclei::evSel::kTVX) && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kTVX + 1); + + if (cfgEventSelections->get(nuclei::evSel::kZvtx) && std::abs(collision.posZ()) > cfgCutVertex) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kZvtx + 1); + + if (cfgEventSelections->get(nuclei::evSel::kTFborder) && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kTFborder + 1); + + if (cfgEventSelections->get(nuclei::evSel::kITSROFborder) && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kITSROFborder + 1); + + if (cfgEventSelections->get(nuclei::evSel::kNoSameBunchPileup) && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kNoSameBunchPileup + 1); + + if (cfgEventSelections->get(nuclei::evSel::kIsGoodZvtxFT0vsPV) && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kIsGoodZvtxFT0vsPV + 1); + + if (cfgEventSelections->get(nuclei::evSel::kIsGoodITSLayersAll) && !collision.selection_bit(aod::evsel::kIsGoodITSLayersAll)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kIsGoodITSLayersAll + 1); + + if constexpr ( + requires { + collision.triggereventep(); + }) { + if (cfgEventSelections->get(nuclei::evSel::kIsEPtriggered) && !collision.triggereventep()) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kIsEPtriggered + 1); + } + + float centrality = getCentrality(collision); + spectra.fill(HIST("hCentrality"), centrality); + + return true; + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + if (cfgSkimmedProcessing) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), "fHe"); + zorro.populateHistRegistry(spectra, bc.runNumber()); + } + auto timestamp = bc.timestamp(); + mRunNumber = bc.runNumber(); + + o2::parameters::GRPMagField* grpmag = ccdb->getForTimeStamp("GLO/Config/GRPMagField", timestamp); + o2::base::Propagator::initFieldFromGRP(grpmag); + o2::base::Propagator::Instance()->setMatLUT(nuclei::lut); + mBz = static_cast(grpmag->getNominalL3Field()); + LOGF(info, "Retrieved GRP for timestamp %ull (%i) with magnetic field of %1.2f kZG", timestamp, mRunNumber, mBz); + } + + void init(o2::framework::InitContext&) + { + zorroSummary.setObject(zorro.getZorroSummary()); + zorro.setBaseCCDBPath(cfgZorroCCDBpath.value); + ccdb->setURL(cfgCCDBurl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + spectra.add("hEventSelections", "hEventSelections", {HistType::kTH1D, {{nuclei::evSel::kNevSels + 1, -0.5f, static_cast(nuclei::evSel::kNevSels) + 0.5f}}}); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(1, "all"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kTVX + 2, "TVX"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kZvtx + 2, "Zvtx"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kTFborder + 2, "TFborder"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kITSROFborder + 2, "ITSROFborder"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kNoSameBunchPileup + 2, "kNoSameBunchPileup"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kIsGoodZvtxFT0vsPV + 2, "isGoodZvtxFT0vsPV"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kIsGoodITSLayersAll + 2, "IsGoodITSLayersAll"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kIsEPtriggered + 2, "IsEPtriggered"); + + spectra.add("hCentrality", "hCentrality", HistType::kTH1D, {{100, 0., 100., "Centrality (%)"}}); + + spectra.add("hRecVtxZData", "collision z position", HistType::kTH1F, {{200, -20., 20., "z position (cm)"}}); + spectra.add("hTpcSignalData", "Specific energy loss", HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {1400, 0, 1400, "d#it{E} / d#it{X} (a. u.)"}}); + spectra.add("hTpcSignalDataSelected", "Specific energy loss for selected particles", HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {1400, 0, 1400, "d#it{E} / d#it{X} (a. u.)"}}); + spectra.add("hTofSignalData", "TOF beta", HistType::kTH2F, {{500, 0., 5., "#it{p} (GeV/#it{c})"}, {750, 0, 1.5, "TOF #beta"}}); + + for (int iS{0}; iS < nuclei::species; ++iS) { + for (int iMax{0}; iMax < 2; ++iMax) { + nuclei::pidCutTPC[iS][iMax] = cfgNsigmaTPC->get(iS, iMax); // changed pidCut to pidCutTPC so that it compiles TODO: check if it is correct + } + } + + nuclei::lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); + } + + template + float getCentrality(Tcoll const& collision) + { + float centrality = 1.; + if constexpr (o2::aod::HasCentrality) { + if (cfgCentralityEstimator == nuclei::centDetectors::kFV0A) { + centrality = collision.centFV0A(); + } else if (cfgCentralityEstimator == nuclei::centDetectors::kFT0M) { + centrality = collision.centFT0M(); + } else if (cfgCentralityEstimator == nuclei::centDetectors::kFT0A) { + centrality = collision.centFT0A(); + } else if (cfgCentralityEstimator == nuclei::centDetectors::kFT0C) { + centrality = collision.centFT0C(); + } else { + LOG(warning) << "Centrality estimator not valid. Possible values: (FV0A: 0, FT0M: 1, FT0A: 2, FT0C: 3). Centrality set to 1."; + } + } + return centrality; + } + + template + void fillDataInfo(Tcoll const& collision, Ttrks const& tracks) + { + auto bc = collision.template bc_as(); + initCCDB(bc); + if (cfgSkimmedProcessing) { + zorro.isSelected(bc.globalBC()); /// Just let Zorro do the accounting + } + gRandom->SetSeed(bc.timestamp()); + + spectra.fill(HIST("hRecVtxZData"), collision.posZ()); + + const o2::math_utils::Point3D collVtx{collision.posX(), collision.posY(), collision.posZ()}; + + const double bgScalings[5][2]{ + {nuclei::charges[0] * cfgMomentumScalingBetheBloch->get(0u, 0u) / nuclei::masses[0], nuclei::charges[0] * cfgMomentumScalingBetheBloch->get(0u, 1u) / nuclei::masses[0]}, + {nuclei::charges[1] * cfgMomentumScalingBetheBloch->get(1u, 0u) / nuclei::masses[1], nuclei::charges[1] * cfgMomentumScalingBetheBloch->get(1u, 1u) / nuclei::masses[1]}, + {nuclei::charges[2] * cfgMomentumScalingBetheBloch->get(2u, 0u) / nuclei::masses[2], nuclei::charges[2] * cfgMomentumScalingBetheBloch->get(2u, 1u) / nuclei::masses[2]}, + {nuclei::charges[3] * cfgMomentumScalingBetheBloch->get(3u, 0u) / nuclei::masses[3], nuclei::charges[3] * cfgMomentumScalingBetheBloch->get(3u, 1u) / nuclei::masses[3]}, + {nuclei::charges[4] * cfgMomentumScalingBetheBloch->get(3u, 0u) / nuclei::masses[4], nuclei::charges[4] * cfgMomentumScalingBetheBloch->get(3u, 1u) / nuclei::masses[4]}}; + + for (auto& track : tracks) { // start loop over tracks + if (std::abs(track.eta()) > cfgCutEta || + track.tpcInnerParam() < cfgCutTpcMom || + track.itsNCls() < cfgCutNclusITS || + track.tpcNClsFound() < cfgCutNclusTPC || + track.tpcNClsCrossedRows() < 70 || + track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || + track.tpcChi2NCl() > 4.f || + track.itsChi2NCl() > 36.f) { + continue; + } + // temporary fix: tpcInnerParam() returns the momentum in all the software tags before + bool heliumPID = track.pidForTracking() == o2::track::PID::Helium3 || track.pidForTracking() == o2::track::PID::Alpha; + float correctedTpcInnerParam = (heliumPID && cfgCompensatePIDinTracking) ? track.tpcInnerParam() / 2 : track.tpcInnerParam(); + + spectra.fill(HIST("hTpcSignalData"), correctedTpcInnerParam * track.sign(), track.tpcSignal()); + const int iC{track.sign() < 0}; + + bool selectedTPC[5]{false}, goodToAnalyse{false}; + std::array nSigmaTPC; + + for (int iS{0}; iS < nuclei::species; ++iS) { + + double expBethe{tpc::BetheBlochAleph(static_cast(correctedTpcInnerParam * bgScalings[iS][iC]), cfgBetheBlochParams->get(iS, 0u), cfgBetheBlochParams->get(iS, 1u), cfgBetheBlochParams->get(iS, 2u), cfgBetheBlochParams->get(iS, 3u), cfgBetheBlochParams->get(iS, 4u))}; + + double expSigma{expBethe * cfgBetheBlochParams->get(iS, 5u)}; + + nSigmaTPC[iS] = static_cast((track.tpcSignal() - expBethe) / expSigma); + + selectedTPC[iS] = (nSigmaTPC[iS] > nuclei::pidCutTPC[iS][0] && nSigmaTPC[iS] < nuclei::pidCutTPC[iS][1]); + + goodToAnalyse = goodToAnalyse || selectedTPC[iS]; + } + if (!goodToAnalyse) { + continue; + } + + setTrackParCov(track, mTrackParCov); + mTrackParCov.setPID(track.pidForTracking()); + + std::array dcaInfo; + o2::base::Propagator::Instance()->propagateToDCA(collVtx, mTrackParCov, mBz, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfo); + + float beta{o2::pid::tof::Beta::GetBeta(track)}; + spectra.fill(HIST("hTpcSignalDataSelected"), correctedTpcInnerParam * track.sign(), track.tpcSignal()); + spectra.fill(HIST("hTofSignalData"), correctedTpcInnerParam, beta); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + uint16_t flag = static_cast((track.pidForTracking() & 0xF) << 12); + std::array tofMasses{-3.f, -3.f, -3.f, -3.f, -3.f}; + bool fillTree{true}; // set to true and never used again + bool fillDCAHist{false}; + bool correctPV{false}; + bool isSecondary{false}; + bool fromWeakDecay{false}; + + if (track.hasTOF()) { + flag |= kHasTOF; + } + if (track.hasTRD()) { + flag |= kHasTRD; + } + if (!collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + flag |= kITSrof; + } + for (int iS{0}; iS < nuclei::species; ++iS) { + bool selectedTOF{false}; + if (std::abs(dcaInfo[1]) > cfgDCAcut->get(iS, 1)) { + continue; + } + ROOT::Math::LorentzVector> fvector{mTrackParCov.getPt() * nuclei::charges[iS], mTrackParCov.getEta(), mTrackParCov.getPhi(), nuclei::masses[iS]}; + if (selectedTPC[iS]) { + if (track.hasTOF()) { + selectedTOF = true; /// temporarly skipped + float charge{1.f + static_cast(iS == 3 || iS == 4)}; + tofMasses[iS] = correctedTpcInnerParam * charge * std::sqrt(1.f / (beta * beta) - 1.f) - nuclei::masses[iS]; + } + if (cfgTreeConfig->get(iS, 1u) && !selectedTOF) { + continue; + } + bool setPartFlag = cfgTreeConfig->get(iS, 0u); + if (setPartFlag) { + if (cfgDownscaling->get(iS) < 1. && gRandom->Rndm() > cfgDownscaling->get(iS)) { + continue; + } + flag |= BIT(iS); + } + } + } + if (flag & (kProton | kDeuteron | kTriton | kHe3 | kHe4) /*|| doprocessMC*/) { /// ignore PID pre-selections for the MC + if constexpr (requires { + collision.psiFT0A(); + }) { + nuclei::candidates_flow.emplace_back(NucleusCandidateFlow{ + collision.centFV0A(), + collision.centFT0M(), + collision.centFT0A(), + collision.centFT0C(), + collision.psiFT0A(), + collision.psiFT0C(), + collision.psiTPC(), + collision.psiTPCL(), + collision.psiTPCR(), + collision.qFT0A(), + collision.qFT0C(), + collision.qTPC(), + collision.qTPCL(), + collision.qTPCR(), + }); + } else if constexpr (requires { + collision.qvecFT0AImVec()[cfgHarmonics - 2]; + }) { + nuclei::candidates_flow.emplace_back(NucleusCandidateFlow{ + collision.centFV0A(), + collision.centFT0M(), + collision.centFT0A(), + collision.centFT0C(), + computeEventPlane(collision.qvecFT0AImVec()[cfgHarmonics - 2], collision.qvecFT0AReVec()[cfgHarmonics - 2]), + computeEventPlane(collision.qvecFT0CImVec()[cfgHarmonics - 2], collision.qvecFT0CReVec()[cfgHarmonics - 2]), + computeEventPlane(collision.qvecTPCallImVec()[cfgHarmonics - 2], collision.qvecTPCallReVec()[cfgHarmonics - 2]), + computeEventPlane(collision.qvecTPCnegImVec()[cfgHarmonics - 2], collision.qvecTPCnegReVec()[cfgHarmonics - 2]), + computeEventPlane(collision.qvecTPCposImVec()[cfgHarmonics - 2], collision.qvecTPCposReVec()[cfgHarmonics - 2]), + std::hypot(collision.qvecFT0AImVec()[cfgHarmonics - 2], collision.qvecFT0AReVec()[cfgHarmonics - 2]), + std::hypot(collision.qvecFT0CImVec()[cfgHarmonics - 2], collision.qvecFT0CReVec()[cfgHarmonics - 2]), + std::hypot(collision.qvecTPCallImVec()[cfgHarmonics - 2], collision.qvecTPCallReVec()[cfgHarmonics - 2]), + std::hypot(collision.qvecTPCnegImVec()[cfgHarmonics - 2], collision.qvecTPCnegReVec()[cfgHarmonics - 2]), + std::hypot(collision.qvecTPCposImVec()[cfgHarmonics - 2], collision.qvecTPCposReVec()[cfgHarmonics - 2])}); + } + if (flag & kTriton) { + if (track.pt() < cfgCutPtMinTree || track.pt() > cfgCutPtMaxTree || track.sign() > 0) + continue; + } + nuclei::candidates.emplace_back(NucleusCandidate{ + static_cast(track.globalIndex()), static_cast(track.collisionId()), (1 - 2 * iC) * mTrackParCov.getPt(), mTrackParCov.getEta(), mTrackParCov.getPhi(), + correctedTpcInnerParam, beta, collision.posZ(), collision.numContrib(), dcaInfo[0], dcaInfo[1], track.tpcSignal(), track.itsChi2NCl(), track.tpcChi2NCl(), track.tofChi2(), + nSigmaTPC, tofMasses, fillTree, fillDCAHist, correctPV, isSecondary, fromWeakDecay, flag, track.tpcNClsFindable(), static_cast(track.tpcNClsCrossedRows()), track.itsClusterMap(), + static_cast(track.tpcNClsFound()), static_cast(track.tpcNClsShared()), static_cast(track.itsNCls()), static_cast(track.itsClusterSizes())}); + } + } // end loop over tracks + } + + void processDataFlow(CollWithEP const& collision, TrackCandidates const& tracks, aod::BCsWithTimestamps const&) + { + nuclei::candidates.clear(); + nuclei::candidates_flow.clear(); + if (!eventSelectionWithHisto(collision)) { + return; + } + fillDataInfo(collision, tracks); + for (auto& c : nuclei::candidates) { + nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS); + } + for (auto& c : nuclei::candidates_flow) { + nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.psiFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.qFT0A, c.qFT0C, c.qTPC, c.qTPCl, c.qTPCr); + } + } + PROCESS_SWITCH(nucleiFlowTree, processDataFlow, "Data analysis with flow", true); + + void processDataFlowAlternative(CollWithQvec const& collision, TrackCandidates const& tracks, aod::BCsWithTimestamps const&) + { + nuclei::candidates.clear(); + nuclei::candidates_flow.clear(); + if (!eventSelectionWithHisto(collision)) { + return; + } + fillDataInfo(collision, tracks); + for (auto& c : nuclei::candidates) { + nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS); + } + for (auto& c : nuclei::candidates_flow) { + nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.psiFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.qFT0A, c.qFT0C, c.qTPC, c.qTPCl, c.qTPCr); + } + } + PROCESS_SWITCH(nucleiFlowTree, processDataFlowAlternative, "Data analysis with flow - alternative framework", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"nuclei-flow-trees"})}; +} diff --git a/PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx b/PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx index 574fea93669..5891997bc54 100644 --- a/PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx +++ b/PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx @@ -19,52 +19,47 @@ // o2-analysis-pid-tof-base, o2-analysis-multiplicity-table, o2-analysis-event-selection // (to add flow: o2-analysis-qvector-table, o2-analysis-centrality-table) -#include -#include -#include -#include -#include - -#include "Math/Vector4D.h" - -#include "CCDB/BasicCCDBManager.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/LFSlimNucleiTables.h" +#include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/PID/PIDTOF.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/Qvectors.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/PID/PIDTOF.h" #include "Common/TableProducer/PID/pidTOFBase.h" -#include "Common/Core/EventPlaneHelper.h" -#include "Common/DataModel/Qvectors.h" -#include "Common/Tools/TrackTuner.h" -#include "Common/Core/RecoDecay.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" +#include "CCDB/BasicCCDBManager.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" #include "DataFormatsTPC/BetheBlochAleph.h" #include "DetectorsBase/GeometryManager.h" #include "DetectorsBase/Propagator.h" - -#include "EventFiltering/Zorro.h" -#include "EventFiltering/ZorroSummary.h" - +#include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" - #include "ReconstructionDataFormats/Track.h" -#include "PWGLF/DataModel/EPCalibrationTables.h" -#include "PWGLF/DataModel/LFSlimNucleiTables.h" - +#include "Math/Vector4D.h" #include "TRandom3.h" +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -80,6 +75,7 @@ struct NucleusCandidate { float tpcInnerParam; float beta; float zVertex; + int nContrib; float DCAxy; float DCAz; float TPCsignal; @@ -109,13 +105,15 @@ struct NucleusCandidateFlow { float centFT0A; float centFT0C; float psiFT0A; - float multFT0A; float psiFT0C; - float multFT0C; float psiTPC; float psiTPCl; float psiTPCr; - int multTPC; + float qFT0A; + float qFT0C; + float qTPC; + float qTPCl; + float qTPCr; }; namespace nuclei @@ -181,6 +179,7 @@ constexpr float charges[5]{1.f, 1.f, 1.f, 2.f, 2.f}; constexpr float masses[5]{MassProton, MassDeuteron, MassTriton, MassHelium3, MassAlpha}; static const std::vector matter{"M", "A"}; static const std::vector pidName{"TPC", "TOF"}; +static const std::vector hfMothCodes{511, 521, 531, 541, 5122}; // b-mesons + Lambda_b static const std::vector names{"proton", "deuteron", "triton", "He3", "alpha"}; static const std::vector treeConfigNames{"Filter trees", "Use TOF selection"}; static const std::vector flowConfigNames{"Save flow hists"}; @@ -220,6 +219,31 @@ enum centDetectors { }; static const std::vector centDetectorNames{"FV0A", "FT0M", "FT0A", "FT0C"}; + +enum evSel { + kTVX = 0, + kZvtx, + kTFborder, + kITSROFborder, + kNoSameBunchPileup, + kIsGoodZvtxFT0vsPV, + kIsGoodITSLayersAll, + kIsEPtriggered, + kNevSels +}; + +static const std::vector eventSelectionTitle{"Event selections"}; +static const std::vector eventSelectionLabels{"TVX", "Z vtx", "TF border", "ITS ROF border", "No same-bunch pile-up", "kIsGoodZvtxFT0vsPV", "isGoodITSLayersAll", "isEPtriggered"}; + +constexpr int EvSelDefault[8][1]{ + {1}, + {1}, + {0}, + {0}, + {0}, + {0}, + {0}, + {0}}; } // namespace nuclei struct nucleiSpectra { @@ -239,12 +263,12 @@ struct nucleiSpectra { }; Produces nucleiTable; + Produces nucleiPairTable; Produces nucleiTableMC; Produces nucleiTableFlow; Service ccdb; Zorro zorro; OutputObj zorroSummary{"zorroSummary"}; - TrackTuner trackTunerObj; Configurable cfgCompensatePIDinTracking{"cfgCompensatePIDinTracking", false, "If true, divide tpcInnerParam by the electric charge"}; @@ -253,20 +277,24 @@ struct nucleiSpectra { Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"}; Configurable cfgCutTpcMom{"cfgCutTpcMom", 0.2f, "Minimum TPC momentum for tracks"}; - Configurable cfgCutRapidityMin{"cfgCutRapidityMin", -0.5, "Minimum rapidity for tracks"}; - Configurable cfgCutRapidityMax{"cfgCutRapidityMax", 0.5, "Maximum rapidity for tracks"}; + Configurable cfgCutRapidityMin{"cfgCutRapidityMin", -1., "Minimum rapidity for tracks"}; + Configurable cfgCutRapidityMax{"cfgCutRapidityMax", 1., "Maximum rapidity for tracks"}; Configurable cfgCutOnReconstructedRapidity{"cfgCutOnReconstructedRapidity", false, "Cut on reconstructed rapidity"}; Configurable cfgCutNclusITS{"cfgCutNclusITS", 5, "Minimum number of ITS clusters"}; Configurable cfgCutNclusTPC{"cfgCutNclusTPC", 70, "Minimum number of TPC clusters"}; Configurable cfgCutPtMinTree{"cfgCutPtMinTree", 0.2f, "Minimum track transverse momentum for tree saving"}; Configurable cfgCutPtMaxTree{"cfgCutPtMaxTree", 15.0f, "Maximum track transverse momentum for tree saving"}; + Configurable> cfgEventSelections{"cfgEventSelections", {nuclei::EvSelDefault[0], 8, 1, nuclei::eventSelectionLabels, nuclei::eventSelectionTitle}, "Event selections"}; + Configurable> cfgMomentumScalingBetheBloch{"cfgMomentumScalingBetheBloch", {nuclei::bbMomScalingDefault[0], 5, 2, nuclei::names, nuclei::chargeLabelNames}, "TPC Bethe-Bloch momentum scaling for light nuclei"}; Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {nuclei::betheBlochDefault[0], 5, 6, nuclei::names, nuclei::betheBlochParNames}, "TPC Bethe-Bloch parameterisation for light nuclei"}; Configurable> cfgNsigmaTPC{"cfgNsigmaTPC", {nuclei::nSigmaTPCdefault[0], 5, 2, nuclei::names, nuclei::nSigmaConfigName}, "TPC nsigma selection for light nuclei"}; Configurable> cfgDCAcut{"cfgDCAcut", {nuclei::DCAcutDefault[0], 5, 2, nuclei::names, nuclei::nDCAConfigName}, "Max DCAxy and DCAz for light nuclei"}; Configurable> cfgDownscaling{"cfgDownscaling", {nuclei::DownscalingDefault[0], 5, 1, nuclei::names, nuclei::DownscalingConfigName}, "Fraction of kept candidates for light nuclei"}; Configurable> cfgTreeConfig{"cfgTreeConfig", {nuclei::TreeConfigDefault[0], 5, 2, nuclei::names, nuclei::treeConfigNames}, "Filtered trees configuration"}; + Configurable cfgFillPairTree{"cfgFillPairTree", true, "Fill trees for pairs of light nuclei"}; + Configurable cfgFillGenSecondaries{"cfgFillGenSecondaries", 0, "Fill generated secondaries (0: no, 1: only weak decays, 2: all of them)"}; Configurable> cfgDCAHists{"cfgDCAHists", {nuclei::DCAHistDefault[0], 5, 2, nuclei::names, nuclei::DCAConfigNames}, "DCA hist configuration"}; Configurable> cfgFlowHist{"cfgFlowHist", {nuclei::FlowHistDefault[0], 5, 1, nuclei::names, nuclei::flowConfigNames}, "Flow hist configuration"}; @@ -295,9 +323,6 @@ struct nucleiSpectra { Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "Skimmed dataset processing"}; - // configurables for track tuner - Configurable cfgUseTrackTuner{"cfgUseTrackTuner", false, "Apply track tuner corrections to MC tracks"}; - Configurable cfgTrackTunerParams{"cfgTrackTunerParams", "debugInfo=0|updateTrackDCAs=1|updateTrackCovMat=1|updateCurvature=0|updateCurvatureIU=0|updatePulls=1|isInputFileFromCCDB=1|pathInputFile=Users/m/mfaggin/test/inputsTrackTuner/pp2023/smoothHighPtMC|nameInputFile=trackTuner_DataLHC23fPass1_McLHC23k4b_run535085.root|pathFileQoverPt=Users/h/hsharma/qOverPtGraphs|nameFileQoverPt=D0sigma_Data_removal_itstps_MC_LHC22b1b.root|usePvRefitCorrections=0|qOverPtMC=-1.|qOverPtData=-1.", "TrackTuner parameter initialization (format: =|=)"}; // running variables for track tuner o2::dataformats::DCA mDcaInfoCov; o2::track::TrackParametrizationWithError mTrackParCov; @@ -318,7 +343,7 @@ struct nucleiSpectra { // Flow analysis using CollWithEP = soa::Join::iterator; - using CollWithQvec = soa::Join::iterator; + using CollWithQvec = soa::Join::iterator; HistogramRegistry spectra{"spectra", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; @@ -352,6 +377,59 @@ struct nucleiSpectra { return collision.selection_bit(aod::evsel::kIsTriggerTVX) && collision.posZ() > -cfgCutVertex && collision.posZ() < cfgCutVertex && collision.selection_bit(aod::evsel::kNoTimeFrameBorder); } + template + bool eventSelectionWithHisto(Tcoll& collision) + { + spectra.fill(HIST("hEventSelections"), 0); + + if (cfgEventSelections->get(nuclei::evSel::kTVX) && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kTVX + 1); + + if (cfgEventSelections->get(nuclei::evSel::kZvtx) && std::abs(collision.posZ()) > cfgCutVertex) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kZvtx + 1); + + if (cfgEventSelections->get(nuclei::evSel::kTFborder) && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kTFborder + 1); + + if (cfgEventSelections->get(nuclei::evSel::kITSROFborder) && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kITSROFborder + 1); + + if (cfgEventSelections->get(nuclei::evSel::kNoSameBunchPileup) && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kNoSameBunchPileup + 1); + + if (cfgEventSelections->get(nuclei::evSel::kIsGoodZvtxFT0vsPV) && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kIsGoodZvtxFT0vsPV + 1); + + if (cfgEventSelections->get(nuclei::evSel::kIsGoodITSLayersAll) && !collision.selection_bit(aod::evsel::kIsGoodITSLayersAll)) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kIsGoodITSLayersAll + 1); + + if constexpr ( + requires { + collision.triggereventep(); + }) { + if (cfgEventSelections->get(nuclei::evSel::kIsEPtriggered) && !collision.triggereventep()) { + return false; + } + spectra.fill(HIST("hEventSelections"), nuclei::evSel::kIsEPtriggered + 1); + } + + return true; + } + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) { if (mRunNumber == bc.runNumber()) { @@ -412,6 +490,17 @@ struct nucleiSpectra { {cfgDCAxyBinsAlpha, "DCA_{z} (cm)"}}; const AxisSpec etaAxis{40, -1., 1., "#eta"}; + spectra.add("hEventSelections", "hEventSelections", {HistType::kTH1D, {{nuclei::evSel::kNevSels + 1, -0.5f, static_cast(nuclei::evSel::kNevSels) + 0.5f}}}); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(1, "all"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kTVX + 2, "TVX"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kZvtx + 2, "Zvtx"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kTFborder + 2, "TFborder"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kITSROFborder + 2, "ITSROFborder"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kNoSameBunchPileup + 2, "kNoSameBunchPileup"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kIsGoodZvtxFT0vsPV + 2, "isGoodZvtxFT0vsPV"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kIsGoodITSLayersAll + 2, "IsGoodITSLayersAll"); + spectra.get(HIST("hEventSelections"))->GetXaxis()->SetBinLabel(nuclei::evSel::kIsEPtriggered + 2, "IsEPtriggered"); + spectra.add("hRecVtxZData", "collision z position", HistType::kTH1F, {{200, -20., +20., "z position (cm)"}}); if (doprocessMC) { spectra.add("hGenVtxZ", " generated collision z position", HistType::kTH1F, {{200, -20., +20., "z position (cm)"}}); @@ -420,6 +509,7 @@ struct nucleiSpectra { spectra.add("hTpcSignalData", "Specific energy loss", HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {1400, 0, 1400, "d#it{E} / d#it{X} (a. u.)"}}); spectra.add("hTpcSignalDataSelected", "Specific energy loss for selected particles", HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {1400, 0, 1400, "d#it{E} / d#it{X} (a. u.)"}}); spectra.add("hTofSignalData", "TOF beta", HistType::kTH2F, {{500, 0., 5., "#it{p} (GeV/#it{c})"}, {750, 0, 1.5, "TOF #beta"}}); + for (int iC{0}; iC < 2; ++iC) { nuclei::hGloTOFtracks[iC] = spectra.add(fmt::format("hTPCTOFtracks{}", nuclei::matter[iC]).data(), fmt::format("Global vs TOF matched {} tracks in a collision", nuclei::chargeLabelNames[iC]).data(), HistType::kTH2D, {{300, -0.5, 300.5, "Number of global tracks"}, {300, -0.5, 300.5, "Number of TOF matched tracks"}}); @@ -456,26 +546,22 @@ struct nucleiSpectra { } if (doprocessMatching) { + std::vector occBins{-0.5, 499.5, 999.5, 1999.5, 2999.5, 3999.5, 4999.5, 10000., 50000.}; + AxisSpec occAxis{occBins, "Occupancy"}; for (int iC{0}; iC < 2; ++iC) { nuclei::hMatchingStudy[iC] = spectra.add(fmt::format("hMatchingStudy{}", nuclei::matter[iC]).data(), ";#it{p}_{T};#phi;#eta;n#sigma_{ITS};n#sigma{TPC};n#sigma_{TOF};Centrality", HistType::kTHnSparseF, {{20, 1., 9.}, {10, 0., o2::constants::math::TwoPI}, {10, -1., 1.}, {50, -5., 5.}, {50, -5., 5.}, {50, 0., 1.}, {8, 0., 80.}}); - nuclei::hMatchingStudyHadrons[iC] = spectra.add(fmt::format("hMatchingStudyHadrons{}", nuclei::matter[iC]).data(), ";#it{p}_{T};#phi;#eta;Centrality;Track type", HistType::kTHnF, {{23, 0.4, 5.}, {20, 0., o2::constants::math::TwoPI}, {10, -1., 1.}, {8, 0., 80.}, {2, -0.5, 1.5}}); + nuclei::hMatchingStudyHadrons[iC] = spectra.add(fmt::format("hMatchingStudyHadrons{}", nuclei::matter[iC]).data(), ";#it{p}_{T};#phi;#eta;Centrality;Track type; Occupancy", HistType::kTHnF, {{23, 0.4, 5.}, {20, 0., o2::constants::math::TwoPI}, {10, -1., 1.}, {8, 0., 80.}, {2, -0.5, 1.5}, occAxis}); } } nuclei::lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); - // TrackTuner initialization - if (cfgUseTrackTuner) { - std::string outputStringParams = trackTunerObj.configParams(cfgTrackTunerParams); - spectra.add("hTrackTunedTracks", outputStringParams.c_str(), HistType::kTH1F, {{1, 0.5, 1.5, ""}}); - trackTunerObj.getDcaGraphs(); - } } template float getCentrality(Tcoll const& collision) { float centrality = 1.; - if constexpr (std::is_same::value || std::is_same::value || std::is_same::value) { + if constexpr (o2::aod::HasCentrality) { if (cfgCentralityEstimator == nuclei::centDetectors::kFV0A) { centrality = collision.centFV0A(); } else if (cfgCentralityEstimator == nuclei::centDetectors::kFT0M) { @@ -566,21 +652,7 @@ struct nucleiSpectra { mDcaInfoCov.set(999, 999, 999, 999, 999); setTrackParCov(track, mTrackParCov); mTrackParCov.setPID(track.pidForTracking()); - if constexpr ( - requires { - track.has_mcParticle(); - }) { - if (cfgUseTrackTuner) { - bool hasMcParticle = track.has_mcParticle(); - if (hasMcParticle) { - spectra.get(HIST("hTrackTunedTracks"))->Fill(1); // all tracks - auto mcParticle = track.mcParticle(); - trackTunerObj.tuneTrackParams(mcParticle, mTrackParCov, matCorr, &mDcaInfoCov, spectra.get(HIST("hTrackTunedTracks"))); - } - } - } - - gpu::gpustd::array dcaInfo; + std::array dcaInfo; o2::base::Propagator::Instance()->propagateToDCA(collVtx, mTrackParCov, mBz, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfo); float beta{o2::pid::tof::Beta::GetBeta(track)}; @@ -636,13 +708,18 @@ struct nucleiSpectra { } if (cfgFlowHist->get(iS) && doprocessDataFlow) { - if constexpr (std::is_same::value) { + if constexpr (requires { + collision.psiFT0C(); + }) { auto deltaPhiInRange = RecoDecay::constrainAngle(fvector.phi() - collision.psiFT0C(), 0.f, 2); auto v2 = std::cos(2.0 * deltaPhiInRange); nuclei::hFlowHists[iC][iS]->Fill(collision.centFT0C(), fvector.pt(), nSigma[0][iS], tofMasses[iS], v2, track.itsNCls(), track.tpcNClsFound()); } } else if (cfgFlowHist->get(iS) && doprocessDataFlowAlternative) { - if constexpr (std::is_same::value) { + if constexpr (requires { + collision.qvecFT0CIm(); + collision.qvecFT0CRe(); + }) { auto deltaPhiInRange = RecoDecay::constrainAngle(fvector.phi() - computeEventPlane(collision.qvecFT0CIm(), collision.qvecFT0CRe()), 0.f, 2); auto v2 = std::cos(2.0 * deltaPhiInRange); nuclei::hFlowHists[iC][iS]->Fill(collision.centFT0C(), fvector.pt(), nSigma[0][iS], tofMasses[iS], v2, track.itsNCls(), track.tpcNClsFound()); @@ -668,44 +745,53 @@ struct nucleiSpectra { } } if (flag & (kProton | kDeuteron | kTriton | kHe3 | kHe4) || doprocessMC) { /// ignore PID pre-selections for the MC - if constexpr (std::is_same::value) { + if constexpr (requires { + collision.psiFT0A(); + }) { nuclei::candidates_flow.emplace_back(NucleusCandidateFlow{ collision.centFV0A(), collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.psiFT0A(), - collision.multFT0A(), collision.psiFT0C(), - collision.multFT0C(), collision.psiTPC(), collision.psiTPCL(), collision.psiTPCR(), - collision.multTPC()}); - } else if constexpr (std::is_same::value) { + collision.qFT0A(), + collision.qFT0C(), + collision.qTPC(), + collision.qTPCL(), + collision.qTPCR(), + }); + } else if constexpr (requires { + collision.qvecFT0AIm(); + }) { nuclei::candidates_flow.emplace_back(NucleusCandidateFlow{ collision.centFV0A(), collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), computeEventPlane(collision.qvecFT0AIm(), collision.qvecFT0ARe()), - collision.multFT0A(), computeEventPlane(collision.qvecFT0CIm(), collision.qvecFT0CRe()), - collision.multFT0C(), - -999., + computeEventPlane(collision.qvecBTotIm(), collision.qvecBTotRe()), computeEventPlane(collision.qvecBNegIm(), collision.qvecBNegRe()), computeEventPlane(collision.qvecBPosIm(), collision.qvecBPosRe()), - collision.multTPC()}); + std::hypot(collision.qvecFT0AIm(), collision.qvecFT0ARe()), + std::hypot(collision.qvecFT0CIm(), collision.qvecFT0CRe()), + std::hypot(collision.qvecBTotIm(), collision.qvecBTotRe()), + std::hypot(collision.qvecBNegIm(), collision.qvecBNegRe()), + std::hypot(collision.qvecBPosIm(), collision.qvecBPosRe())}); } if (fillTree) { - if (flag & BIT(2)) { + if (flag & kTriton) { if (track.pt() < cfgCutPtMinTree || track.pt() > cfgCutPtMaxTree || track.sign() > 0) continue; } } nuclei::candidates.emplace_back(NucleusCandidate{ static_cast(track.globalIndex()), static_cast(track.collisionId()), (1 - 2 * iC) * mTrackParCov.getPt(), mTrackParCov.getEta(), mTrackParCov.getPhi(), - correctedTpcInnerParam, beta, collision.posZ(), dcaInfo[0], dcaInfo[1], track.tpcSignal(), track.itsChi2NCl(), track.tpcChi2NCl(), track.tofChi2(), + correctedTpcInnerParam, beta, collision.posZ(), collision.numContrib(), dcaInfo[0], dcaInfo[1], track.tpcSignal(), track.itsChi2NCl(), track.tpcChi2NCl(), track.tofChi2(), nSigmaTPC, tofMasses, fillTree, fillDCAHist, correctPV, isSecondary, fromWeakDecay, flag, track.tpcNClsFindable(), static_cast(track.tpcNClsCrossedRows()), track.itsClusterMap(), static_cast(track.tpcNClsFound()), static_cast(track.tpcNClsShared()), static_cast(track.itsNCls()), static_cast(track.itsClusterSizes())}); } @@ -723,14 +809,24 @@ struct nucleiSpectra { } fillDataInfo(collision, tracks); - for (auto& c : nuclei::candidates) { - if (c.fillTree) { - nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS); + for (size_t i1{0}; i1 < nuclei::candidates.size(); ++i1) { + auto& c1 = nuclei::candidates[i1]; + if (c1.fillTree) { + nucleiTable(c1.pt, c1.eta, c1.phi, c1.tpcInnerParam, c1.beta, c1.zVertex, c1.nContrib, c1.DCAxy, c1.DCAz, c1.TPCsignal, c1.ITSchi2, c1.TPCchi2, c1.TOFchi2, c1.flags, c1.TPCfindableCls, c1.TPCcrossedRows, c1.ITSclsMap, c1.TPCnCls, c1.TPCnClsShared, c1.clusterSizesITS); + if (cfgFillPairTree) { + for (size_t i2{i1 + 1}; i2 < nuclei::candidates.size(); ++i2) { + auto& c2 = nuclei::candidates[i2]; + if (!c2.fillTree || ((c1.flags & c2.flags) & 0x1F) == 0) { + continue; + } + nucleiPairTable(c1.pt, c1.eta, c1.phi, c1.tpcInnerParam, c1.TPCsignal, c1.DCAxy, c1.DCAz, c1.clusterSizesITS, c1.flags, c2.pt, c2.eta, c2.phi, c2.tpcInnerParam, c2.TPCsignal, c2.DCAxy, c2.DCAz, c2.clusterSizesITS, c2.flags); + } + } } - if (c.fillDCAHist) { + if (c1.fillDCAHist) { for (int iS{0}; iS < nuclei::species; ++iS) { - if (c.flags & BIT(iS)) { - nuclei::hDCAHists[c.pt < 0][iS]->Fill(std::abs(c.pt), c.DCAxy, c.DCAz, c.nSigmaTPC[iS], c.tofMasses[iS], c.ITSnCls, c.TPCnCls); + if (c1.flags & BIT(iS)) { + nuclei::hDCAHists[c1.pt < 0][iS]->Fill(std::abs(c1.pt), c1.DCAxy, c1.DCAz, c1.nSigmaTPC[iS], c1.tofMasses[iS], c1.ITSnCls, c1.TPCnCls); } } } @@ -742,7 +838,7 @@ struct nucleiSpectra { { nuclei::candidates.clear(); nuclei::candidates_flow.clear(); - if (!eventSelection(collision)) { + if (!eventSelectionWithHisto(collision)) { return; } if (!collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { @@ -751,7 +847,7 @@ struct nucleiSpectra { fillDataInfo(collision, tracks); for (auto& c : nuclei::candidates) { if (c.fillTree) { - nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS); + nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS); } if (c.fillDCAHist) { for (int iS{0}; iS < nuclei::species; ++iS) { @@ -762,7 +858,7 @@ struct nucleiSpectra { } } for (auto& c : nuclei::candidates_flow) { - nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.multFT0A, c.psiFT0C, c.multFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.multTPC); + nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.psiFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.qFT0A, c.qFT0C, c.qTPC, c.qTPCl, c.qTPCr); } } PROCESS_SWITCH(nucleiSpectra, processDataFlow, "Data analysis with flow", false); @@ -771,7 +867,7 @@ struct nucleiSpectra { { nuclei::candidates.clear(); nuclei::candidates_flow.clear(); - if (!eventSelection(collision)) { + if (!eventSelectionWithHisto(collision)) { return; } if (!collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { @@ -780,7 +876,7 @@ struct nucleiSpectra { fillDataInfo(collision, tracks); for (auto& c : nuclei::candidates) { if (c.fillTree) { - nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS); + nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS); } if (c.fillDCAHist) { for (int iS{0}; iS < nuclei::species; ++iS) { @@ -791,7 +887,7 @@ struct nucleiSpectra { } } for (auto& c : nuclei::candidates_flow) { - nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.multFT0A, c.psiFT0C, c.multFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.multTPC); + nucleiTableFlow(c.centFV0A, c.centFT0M, c.centFT0A, c.centFT0C, c.psiFT0A, c.psiFT0C, c.psiTPC, c.psiTPCl, c.psiTPCr, c.qFT0A, c.qFT0C, c.qTPC, c.qTPCl, c.qTPCr); } } PROCESS_SWITCH(nucleiSpectra, processDataFlowAlternative, "Data analysis with flow - alternative framework", false); @@ -834,13 +930,6 @@ struct nucleiSpectra { if (!c.correctPV) { c.flags |= kIsAmbiguous; } - if (!particle.isPhysicalPrimary()) { - c.isSecondary = true; - if (particle.getProcess() == 4) { - c.fromWeakDecay = true; - } - } - if (c.fillDCAHist && cfgDCAHists->get(iS, c.pt < 0)) { nuclei::hDCAHists[c.pt < 0][iS]->Fill(std::abs(c.pt), c.DCAxy, c.DCAz, c.nSigmaTPC[iS], c.tofMasses[iS], c.ITSnCls, c.TPCnCls, c.correctPV, c.isSecondary, c.fromWeakDecay); } @@ -849,20 +938,38 @@ struct nucleiSpectra { if (!storeIt) { continue; } - int MotherpdgCode = 0; + if (particle.y() < cfgCutRapidityMin || particle.y() > cfgCutRapidityMax) { + continue; + } + + int motherPdgCode = 0; + float motherDecRadius = -1; isReconstructed[particle.globalIndex()] = true; if (particle.isPhysicalPrimary()) { c.flags |= kIsPhysicalPrimary; + if (particle.has_mothers()) { + for (auto& motherparticle : particle.mothers_as()) { + if (std::find(nuclei::hfMothCodes.begin(), nuclei::hfMothCodes.end(), std::abs(motherparticle.pdgCode())) != nuclei::hfMothCodes.end()) { + c.flags |= kIsSecondaryFromWeakDecay; + motherPdgCode = motherparticle.pdgCode(); + motherDecRadius = std::hypot(particle.vx() - motherparticle.vx(), particle.vy() - motherparticle.vy()); + break; + } + } + } } else if (particle.has_mothers()) { c.flags |= kIsSecondaryFromWeakDecay; for (auto& motherparticle : particle.mothers_as()) { - MotherpdgCode = motherparticle.pdgCode(); + motherPdgCode = motherparticle.pdgCode(); + motherDecRadius = std::hypot(particle.vx() - motherparticle.vx(), particle.vy() - motherparticle.vy()); } } else { c.flags |= kIsSecondaryFromMaterial; } + + isReconstructed[particle.globalIndex()] = true; float absoDecL = computeAbsoDecL(particle); - nucleiTableMC(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS, particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), MotherpdgCode, goodCollisions[particle.mcCollisionId()], absoDecL); + nucleiTableMC(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS, goodCollisions[particle.mcCollisionId()], particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), motherPdgCode, motherDecRadius, absoDecL); } int index{0}; @@ -872,18 +979,49 @@ struct nucleiSpectra { if (pdg != nuclei::codes[iS]) { continue; } - uint16_t flags{kIsPhysicalPrimary}; + if (particle.y() < cfgCutRapidityMin || particle.y() > cfgCutRapidityMax) { + continue; + } + + uint16_t flags = 0; + int motherPdgCode = 0; + float motherDecRadius = -1; if (particle.isPhysicalPrimary()) { - if (particle.y() > cfgCutRapidityMin && particle.y() < cfgCutRapidityMax) { - nuclei::hGenNuclei[iS][particle.pdgCode() < 0]->Fill(1., particle.pt()); + flags |= kIsPhysicalPrimary; + nuclei::hGenNuclei[iS][particle.pdgCode() < 0]->Fill(1., particle.pt()); + // antinuclei from B hadrons are classified as physical primaries + if (particle.has_mothers()) { + for (auto& motherparticle : particle.mothers_as()) { + if (std::find(nuclei::hfMothCodes.begin(), nuclei::hfMothCodes.end(), std::abs(motherparticle.pdgCode())) != nuclei::hfMothCodes.end()) { + flags |= kIsSecondaryFromWeakDecay; + motherPdgCode = motherparticle.pdgCode(); + motherDecRadius = std::hypot(particle.vx() - motherparticle.vx(), particle.vy() - motherparticle.vy()); + break; + } + } + } + } else if (particle.getProcess() == TMCProcess::kPDecay) { + if (!particle.has_mothers()) { + continue; // skip secondaries from weak decay without mothers + } + flags |= kIsSecondaryFromWeakDecay; + for (auto& motherparticle : particle.mothers_as()) { + motherPdgCode = motherparticle.pdgCode(); + motherDecRadius = std::hypot(particle.vx() - motherparticle.vx(), particle.vy() - motherparticle.vy()); } } else { - continue; /// for not-reconstructed particles we store only the primaries + flags |= kIsSecondaryFromMaterial; } if (!isReconstructed[index] && (cfgTreeConfig->get(iS, 0u) || cfgTreeConfig->get(iS, 1u))) { + if ((flags & kIsPhysicalPrimary) == 0 && cfgFillGenSecondaries == 0) { + continue; // skip secondaries if not requested + } + if ((flags & (kIsPhysicalPrimary | kIsSecondaryFromWeakDecay)) == 0 && cfgFillGenSecondaries == 1) { + continue; // skip secondaries from material if not requested + } float absDecL = computeAbsoDecL(particle); - nucleiTableMC(999., 999., 999., 0., 0., 999., 999., 999., -1, -1, -1, -1, flags, 0, 0, 0, 0, 0, 0, particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), 0, goodCollisions[particle.mcCollisionId()], absDecL); + nucleiTableMC(999., 999., 999., 0., 0., 999., -1, 999., 999., -1, -1, -1, -1, flags, 0, 0, 0, 0, 0, 0, goodCollisions[particle.mcCollisionId()], particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), motherPdgCode, motherDecRadius, absDecL); } break; } @@ -911,7 +1049,7 @@ struct nucleiSpectra { int iC = track.signed1Pt() > 0; const float pt = track.pt(); const float phi = 2.f * RecoDecay::constrainAngle(track.phi() - collision.psiFT0C(), 0.f, 2); - nuclei::hMatchingStudyHadrons[iC]->Fill(pt, phi, track.eta(), centrality, track.hasTPC()); + nuclei::hMatchingStudyHadrons[iC]->Fill(pt, phi, track.eta(), centrality, track.hasTPC(), collision.trackOccupancyInTimeRange()); if (itsResponse.nSigmaITS(track) > -1.) { nuclei::hMatchingStudy[iC]->Fill(pt * 2, phi, track.eta(), itsResponse.nSigmaITS(track), nSigmaTPC, o2::pid::tof::Beta::GetBeta(track), centrality); } @@ -919,6 +1057,61 @@ struct nucleiSpectra { } PROCESS_SWITCH(nucleiSpectra, processMatching, "Matching analysis", false); + + void processMCasData(soa::Join const& collisions, aod::McCollisions const& mcCollisions, soa::Join const& tracks, aod::McParticles const& particlesMC, aod::BCsWithTimestamps const&) + { + nuclei::candidates.clear(); + std::vector goodCollisions(mcCollisions.size(), false); + for (auto& collision : collisions) { + if (!eventSelection(collision)) { + continue; + } + goodCollisions[collision.mcCollisionId()] = true; + const auto& slicedTracks = tracks.sliceBy(tracksPerCollisions, collision.globalIndex()); + fillDataInfo(collision, slicedTracks); + } + std::vector isReconstructed(particlesMC.size(), false); + for (size_t i{0}; i < nuclei::candidates.size(); ++i) { + auto& c = nuclei::candidates[i]; + if (c.fillTree) { + auto label = tracks.iteratorAt(c.globalIndex); + if (label.mcParticleId() < -1 || label.mcParticleId() >= particlesMC.size()) { + continue; + } + auto particle = particlesMC.iteratorAt(label.mcParticleId()); + int motherPdgCode = 0; + float motherDecRadius = -1; + isReconstructed[particle.globalIndex()] = true; + if (particle.isPhysicalPrimary()) { + c.flags |= kIsPhysicalPrimary; + if (particle.has_mothers()) { + for (auto& motherparticle : particle.mothers_as()) { + if (std::find(nuclei::hfMothCodes.begin(), nuclei::hfMothCodes.end(), std::abs(motherparticle.pdgCode())) != nuclei::hfMothCodes.end()) { + c.flags |= kIsSecondaryFromWeakDecay; + motherPdgCode = motherparticle.pdgCode(); + motherDecRadius = std::hypot(particle.vx() - motherparticle.vx(), particle.vy() - motherparticle.vy()); + break; + } + } + } + } else if (particle.has_mothers()) { + c.flags |= kIsSecondaryFromWeakDecay; + for (auto& motherparticle : particle.mothers_as()) { + motherPdgCode = motherparticle.pdgCode(); + motherDecRadius = std::hypot(particle.vx() - motherparticle.vx(), particle.vy() - motherparticle.vy()); + } + } else { + c.flags |= kIsSecondaryFromMaterial; + } + + isReconstructed[particle.globalIndex()] = true; + float absoDecL = computeAbsoDecL(particle); + + nucleiTableMC(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.nContrib, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.TOFchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.TPCnClsShared, c.clusterSizesITS, goodCollisions[particle.mcCollisionId()], particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), motherPdgCode, motherDecRadius, absoDecL); + } + } + } + PROCESS_SWITCH(nucleiSpectra, processMCasData, "MC as data analysis", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/TableProducer/Nuspex/nucleiUtils.h b/PWGLF/TableProducer/Nuspex/nucleiUtils.h new file mode 100644 index 00000000000..29cd489768d --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/nucleiUtils.h @@ -0,0 +1,187 @@ +// 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. + +#ifndef PWGLF_TABLEPRODUCER_NUSPEX_NUCLEIUTILS_H_ +#define PWGLF_TABLEPRODUCER_NUSPEX_NUCLEIUTILS_H_ + +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +struct NucleusCandidate { + int globalIndex; + int collTrackIndex; + float pt; + float eta; + float phi; + float tpcInnerParam; + float beta; + float zVertex; + int nContrib; + float DCAxy; + float DCAz; + float TPCsignal; + float ITSchi2; + float TPCchi2; + float TOFchi2; + std::array nSigmaTPC; + std::array tofMasses; + bool fillTree; + bool fillDCAHist; + bool correctPV; + bool isSecondary; + bool fromWeakDecay; + uint16_t flags; + uint8_t TPCfindableCls; + uint8_t TPCcrossedRows; + uint8_t ITSclsMap; + uint8_t TPCnCls; + uint8_t TPCnClsShared; + uint8_t ITSnCls; + uint32_t clusterSizesITS; +}; + +struct NucleusCandidateFlow { + float centFV0A; + float centFT0M; + float centFT0A; + float centFT0C; + float psiFT0A; + float psiFT0C; + float psiTPC; + float psiTPCl; + float psiTPCr; + float qFT0A; + float qFT0C; + float qTPC; + float qTPCl; + float qTPCr; +}; + +namespace nuclei +{ +constexpr double bbMomScalingDefault[5][2]{ + {1., 1.}, + {1., 1.}, + {1., 1.}, + {1., 1.}, + {1., 1.}}; +constexpr double betheBlochDefault[5][6]{ + {-136.71, 0.441, 0.2269, 1.347, 0.8035, 0.09}, + {-136.71, 0.441, 0.2269, 1.347, 0.8035, 0.09}, + {-239.99, 1.155, 1.099, 1.137, 1.006, 0.09}, + {-321.34, 0.6539, 1.591, 0.8225, 2.363, 0.09}, + {-586.66, 1.859, 4.435, 0.282, 3.201, 0.09}}; +constexpr double nSigmaTPCdefault[5][2]{ + {-5., 5.}, + {-5., 5.}, + {-5., 5.}, + {-5., 5.}, + {-5., 5.}}; +// constexpr double nSigmaTOFdefault[5][2]{ +// {-5., 5.}, +// {-5., 5.}, +// {-5., 5.}, +// {-5., 5.}, +// {-5., 5.}}; +constexpr double DCAcutDefault[5][2]{ + {1., 1.}, + {1., 1.}, + {1., 1.}, + {1., 1.}, + {1., 1.}}; +constexpr int TreeConfigDefault[5][2]{ + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}}; +constexpr int FlowHistDefault[5][1]{ + {0}, + {0}, + {0}, + {0}, + {0}}; +constexpr int DCAHistDefault[5][2]{ + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}}; +constexpr double DownscalingDefault[5][1]{ + {1.}, + {1.}, + {1.}, + {1.}, + {1.}}; +// constexpr bool storeTreesDefault[5]{false, false, false, false, false}; +constexpr int species{5}; +constexpr float charges[5]{1.f, 1.f, 1.f, 2.f, 2.f}; +constexpr float masses[5]{MassProton, MassDeuteron, MassTriton, MassHelium3, MassAlpha}; +static const std::vector matter{"M", "A"}; +static const std::vector pidName{"TPC", "TOF"}; +static const std::vector names{"proton", "deuteron", "triton", "He3", "alpha"}; +static const std::vector treeConfigNames{"Filter trees", "Use TOF selection"}; +static const std::vector flowConfigNames{"Save flow hists"}; +static const std::vector DCAConfigNames{"Save DCA hist", "Matter/Antimatter"}; +static const std::vector nSigmaConfigName{"nsigma_min", "nsigma_max"}; +static const std::vector nDCAConfigName{"max DCAxy", "max DCAz"}; +static const std::vector DownscalingConfigName{"Fraction of kept candidates"}; +static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; +static const std::vector chargeLabelNames{"Positive", "Negative"}; + +float pidCutTPC[5][2]; //[species][lower/upper limit] + +o2::base::MatLayerCylSet* lut = nullptr; + +std::vector candidates; +std::vector candidates_flow; + +enum centDetectors { + kFV0A = 0, + kFT0M = 1, + kFT0A = 2, + kFT0C = 3 +}; + +static const std::vector centDetectorNames{"FV0A", "FT0M", "FT0A", "FT0C"}; + +enum evSel { + kTVX = 0, + kZvtx, + kTFborder, + kITSROFborder, + kNoSameBunchPileup, + kIsGoodZvtxFT0vsPV, + kIsGoodITSLayersAll, + kIsEPtriggered, + kNevSels +}; + +static const std::vector eventSelectionTitle{"Event selections"}; +static const std::vector eventSelectionLabels{"TVX", "Z vtx", "TF border", "ITS ROF border", "No same-bunch pile-up", "kIsGoodZvtxFT0vsPV", "isGoodITSLayersAll", "isEPtriggered"}; + +constexpr int EvSelDefault[8][1]{ + {1}, + {1}, + {0}, + {0}, + {0}, + {0}, + {0}, + {0}}; +} // namespace nuclei + +#endif // PWGLF_TABLEPRODUCER_NUSPEX_NUCLEIUTILS_H_ diff --git a/PWGLF/TableProducer/Nuspex/pidTOFGeneric.cxx b/PWGLF/TableProducer/Nuspex/pidTOFGeneric.cxx index 9997d4d27c8..7a3afb2b71d 100644 --- a/PWGLF/TableProducer/Nuspex/pidTOFGeneric.cxx +++ b/PWGLF/TableProducer/Nuspex/pidTOFGeneric.cxx @@ -11,33 +11,37 @@ /// /// \file pidTOFGeneric.cxx -/// \origin Based on pidTOFBase.cxx +/// \origin Based on pidTOFMerged.cxx /// \brief Task to produce event Time obtained from TOF and FT0. -/// In order to redo TOF PID for tracks which are linked to wrong collisions +/// In order to redo TOF PID for secondary tracks which are linked to wrong collisions +/// \author Yuanzhe Wang /// +#include #include #include -#include // O2 includes #include "CCDB/BasicCCDBManager.h" -#include "TOFBase/EventTimeMaker.h" #include "Framework/AnalysisTask.h" #include "ReconstructionDataFormats/Track.h" +#include "TOFBase/EventTimeMaker.h" // O2Physics includes +#include "PWGLF/DataModel/LFPIDTOFGenericTables.h" +#include "PWGLF/Utils/pidTOFGeneric.h" + #include "Common/Core/TableHelper.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/FT0Corrected.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" -#include "PID/ParamBase.h" #include "PID/PIDTOF.h" -#include "PWGLF/DataModel/pidTOFGeneric.h" +#include "PID/ParamBase.h" using namespace o2; using namespace o2::framework; @@ -45,13 +49,19 @@ using namespace o2::pid; using namespace o2::framework::expressions; using namespace o2::track; +o2::common::core::MetadataHelper metadataInfo; + /// Selection criteria for tracks used for TOF event time float trackSampleMinMomentum = 0.5f; float trackSampleMaxMomentum = 2.f; template bool filterForTOFEventTime(const trackType& tr) { - return (tr.hasTOF() && tr.p() > trackSampleMinMomentum && tr.p() < trackSampleMaxMomentum && (tr.trackType() == o2::aod::track::TrackTypeEnum::Track || tr.trackType() == o2::aod::track::TrackTypeEnum::TrackIU)); + return (tr.hasTOF() && + tr.p() > trackSampleMinMomentum && tr.p() < trackSampleMaxMomentum && + tr.hasITS() && + tr.hasTPC() && + (tr.trackType() == o2::aod::track::TrackTypeEnum::Track || tr.trackType() == o2::aod::track::TrackTypeEnum::TrackIU)); } // accept all /// Specialization of TOF event time maker @@ -69,342 +79,275 @@ o2::tof::eventTimeContainer evTimeMakerForTracks(const trackTypeContainer& track } /// Task to produce the event time tables for generic TOF PID +/// Modified based on pidTOFMerge.cxx struct pidTOFGeneric { // Tables to produce Produces tableEvTime; // Table for global event time Produces tableEvTimeForTrack; // Table for event time after removing bias from the track - static constexpr float diamond = 6.0; // Collision diamond used in the estimation of the TOF event time - static constexpr float errDiamond = diamond * 33.356409f; - static constexpr float weightDiamond = 1.f / (errDiamond * errDiamond); + static constexpr bool kRemoveTOFEvTimeBias = true; // Flag to subtract the Ev. Time bias for low multiplicity events with TOF + static constexpr float kDiamond = 6.0; // Collision diamond used in the estimation of the TOF event time + static constexpr float kErrDiamond = kDiamond * 33.356409f; + static constexpr float kWeightDiamond = 1.f / (kErrDiamond * kErrDiamond); bool enableTable = false; - // Detector response and input parameters - o2::pid::tof::TOFResoParamsV2 mRespParamsV2; - Service ccdb; - Configurable inheritFromBaseTask{"inheritFromBaseTask", true, "Flag to iherit all common configurables from the TOF base task"}; + Configurable fastTOFPID{"fastTOFPID", false, "Flag to enable computeEvTimeFast for evTimeMaker"}; - // CCDB configuration (inherited from TOF signal task) - Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable timestamp{"ccdb-timestamp", -1, "timestamp of the object"}; // Event time configurations Configurable minMomentum{"minMomentum", 0.5f, "Minimum momentum to select track sample for TOF event time"}; Configurable maxMomentum{"maxMomentum", 2.0f, "Maximum momentum to select track sample for TOF event time"}; Configurable maxEvTimeTOF{"maxEvTimeTOF", 100000.0f, "Maximum value of the TOF event time"}; Configurable sel8TOFEvTime{"sel8TOFEvTime", false, "Flag to compute the ev. time only for events that pass the sel8 ev. selection"}; + Configurable mComputeEvTimeWithTOF{"computeEvTimeWithTOF", -1, "Compute ev. time with TOF. -1 (autoset), 0 no, 1 yes"}; + Configurable mComputeEvTimeWithFT0{"computeEvTimeWithFT0", -1, "Compute ev. time with FT0. -1 (autoset), 0 no, 1 yes"}; Configurable maxNtracksInSet{"maxNtracksInSet", 10, "Size of the set to consider for the TOF ev. time computation"}; - // TOF Calib configuration - Configurable paramFileName{"paramFileName", "", "Path to the parametrization object. If empty the parametrization is not taken from file"}; - Configurable parametrizationPath{"parametrizationPath", "TOF/Calib/Params", "Path of the TOF parametrization on the CCDB or in the file, if the paramFileName is not empty"}; - Configurable passName{"passName", "", "Name of the pass inside of the CCDB parameter collection. If empty, the automatically deceted from metadata (to be implemented!!!)"}; - Configurable loadResponseFromCCDB{"loadResponseFromCCDB", false, "Flag to load the response from the CCDB"}; - Configurable enableTimeDependentResponse{"enableTimeDependentResponse", false, "Flag to use the collision timestamp to fetch the PID Response"}; - Configurable fatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"}; + + // TOF response and input parameters + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + Service ccdb; + o2::aod::pidtofgeneric::TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration void init(o2::framework::InitContext& initContext) { - if (inheritFromBaseTask.value) { - if (!getTaskOptionValue(initContext, "tof-signal", "ccdb-url", url.value, true)) { - LOG(fatal) << "Could not get ccdb-url from tof-signal task"; - } - if (!getTaskOptionValue(initContext, "tof-signal", "ccdb-timestamp", timestamp.value, true)) { - LOG(fatal) << "Could not get ccdb-timestamp from tof-signal task"; - } - } - - trackSampleMinMomentum = minMomentum; - trackSampleMaxMomentum = maxMomentum; - LOG(info) << "Configuring track sample for TOF ev. time: " << trackSampleMinMomentum << " < p < " << trackSampleMaxMomentum; - // Check that both processes are not enabled - int nEnabled = 0; - if (doprocessNoFT0 == true) { - LOGF(info, "Enabling process function: processNoFT0"); - nEnabled++; - } - if (doprocessFT0 == true) { - LOGF(info, "Enabling process function: processFT0"); - nEnabled++; - } - if (doprocessOnlyFT0 == true) { - LOGF(info, "Enabling process function: processOnlyFT0"); - nEnabled++; - } - if (nEnabled > 1) { - LOGF(fatal, "Cannot enable more process functions at the same time. Please choose one."); - } + mTOFCalibConfig.metadataInfo = metadataInfo; + mTOFCalibConfig.inheritFromBaseTask(initContext); // Checking that the table is requested in the workflow and enabling it enableTable = isTableRequiredInWorkflow(initContext, "EvTimeTOFFT0") || isTableRequiredInWorkflow(initContext, "EvTimeTOFFT0ForTrack"); if (!enableTable) { LOG(info) << "Table for global Event time is not required, disabling it"; - return; + // return; //TODO: uncomment this line } + enableTable = true; // Force enabling the table for now LOG(info) << "Table EvTimeTOFFT0 enabled!"; - if (sel8TOFEvTime.value == true) { - LOG(info) << "TOF event time will be computed for collisions that pass the event selection only!"; - } - // Getting the parametrization parameters - ccdb->setURL(url.value); - ccdb->setTimestamp(timestamp.value); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - // Not later than now objects - ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - // - - // TODO: implement the automatic pass name detection from metadata - if (passName.value == "") { - passName.value = "unanchored"; // temporary default - LOG(warning) << "Passed autodetect mode for pass, not implemented yet, waiting for metadata. Taking '" << passName.value << "'"; - } - LOG(info) << "Using parameter collection, starting from pass '" << passName.value << "'"; - - const std::string fname = paramFileName.value; - if (!fname.empty()) { // Loading the parametrization from file - LOG(info) << "Loading exp. sigma parametrization from file " << fname << ", using param: " << parametrizationPath.value; - if (1) { - o2::tof::ParameterCollection paramCollection; - paramCollection.loadParamFromFile(fname, parametrizationPath.value); - LOG(info) << "+++ Loaded parameter collection from file +++"; - if (!paramCollection.retrieveParameters(mRespParamsV2, passName.value)) { - if (fatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } - } else { - mRespParamsV2.setShiftParameters(paramCollection.getPars(passName.value)); - mRespParamsV2.printShiftParameters(); - } - } else { - mRespParamsV2.loadParamFromFile(fname.data(), parametrizationPath.value); - } - } else if (loadResponseFromCCDB) { // Loading it from CCDB - LOG(info) << "Loading exp. sigma parametrization from CCDB, using path: " << parametrizationPath.value << " for timestamp " << timestamp.value; - - o2::tof::ParameterCollection* paramCollection = ccdb->getForTimeStamp(parametrizationPath.value, timestamp.value); - paramCollection->print(); - if (!paramCollection->retrieveParameters(mRespParamsV2, passName.value)) { - if (fatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); + if (mTOFCalibConfig.autoSetProcessFunctions()) { + LOG(info) << "Autodetecting process functions"; + if (metadataInfo.isFullyDefined()) { + if (metadataInfo.isRun3()) { + doprocessRun3.value = true; } - } else { - mRespParamsV2.setShiftParameters(paramCollection->getPars(passName.value)); - mRespParamsV2.printShiftParameters(); } } - mRespParamsV2.print(); - o2::tof::eventTimeContainer::setMaxNtracksInSet(maxNtracksInSet.value); - o2::tof::eventTimeContainer::printConfig(); - } - /// - /// Process function to prepare the event time on Run 3 data without the FT0 - using TrksEvTime = soa::Join; - // Define slice per collision - Preslice perCollision = aod::track::collisionId; - template - using ResponseImplementationEvTime = o2::pid::tof::ExpTimes; - using EvTimeCollisions = soa::Join; - void processNoFT0(TrksEvTime& tracks, - EvTimeCollisions const& collisions) - { - if (!enableTable) { - return; - } - tableEvTime.reserve(collisions.size()); - tableEvTimeForTrack.reserve(tracks.size()); - - // for tracks not assigned to a collision - for (auto track : tracks) { - if (!track.has_collision()) { - tableEvTimeForTrack(0.f, 999.f); + if (metadataInfo.isFullyDefined()) { + if (!metadataInfo.isRun3()) { + LOG(fatal) << "Run3 process not supported in pidTOFGeneric task"; } } - for (auto const& collision : collisions) { // Loop on collisions - const auto& tracksInCollision = tracks.sliceBy(perCollision, collision.globalIndex()); - if ((sel8TOFEvTime.value == true) && !collision.sel8()) { - tableEvTime(0.f, 999.f, 0.f, 999.f, 0.f, 999.f); - for (int i = 0; i < tracksInCollision.size(); i++) { - tableEvTimeForTrack(0.f, 999.f); - } - continue; - } - - // First make table for event time - const auto evTimeTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV2, diamond, fastTOFPID); - int nGoodTracksForTOF = 0; // count for ntrackIndex for removeBias() - float et = evTimeTOF.mEventTime; - float erret = evTimeTOF.mEventTimeError; + trackSampleMinMomentum = minMomentum; + trackSampleMaxMomentum = maxMomentum; + LOG(info) << "Configuring track sample for TOF ev. time: " << trackSampleMinMomentum << " < p < " << trackSampleMaxMomentum; - if (erret < errDiamond && (maxEvTimeTOF <= 0.f || abs(et) < maxEvTimeTOF)) { - } else { - et = 0.f; - erret = errDiamond; - } - tableEvTime(et, erret, et, erret, 0.f, 999.f); - for (auto const& track : tracksInCollision) { - evTimeTOF.removeBias(track, nGoodTracksForTOF, et, erret, 2); - if (erret < errDiamond && (maxEvTimeTOF <= 0.f || abs(et) < maxEvTimeTOF)) { - } else { - et = 0.f; - erret = errDiamond; - } - tableEvTimeForTrack(et, erret); - } + if (sel8TOFEvTime.value == true) { + LOG(info) << "TOF event time will be computed for collisions that pass the event selection only!"; } + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters + + o2::tof::eventTimeContainer::setMaxNtracksInSet(maxNtracksInSet.value); + o2::tof::eventTimeContainer::printConfig(); } - PROCESS_SWITCH(pidTOFGeneric, processNoFT0, "Process without FT0", false); + + void process(aod::BCs const&) {} /// - /// Process function to prepare the event for each track on Run 3 data with the FT0 + /// Process function to prepare the event for each track on Run 3 data without the FT0 + // Define slice per collision + using Run3Cols = aod::Collisions; + using EvTimeCollisions = soa::Join; using EvTimeCollisionsFT0 = soa::Join; - void processFT0(TrksEvTime& tracks, - aod::FT0s const&, - EvTimeCollisionsFT0 const& collisions) + using Run3Trks = o2::soa::Join; + using Run3TrksWtof = soa::Join; + Preslice perCollision = aod::track::collisionId; + template + using ResponseImplementationEvTime = o2::pid::tof::ExpTimes; + + void processRun3(Run3TrksWtof const& tracks, + aod::FT0s const&, + EvTimeCollisionsFT0 const& collisions, + aod::BCsWithTimestamps const& bcs) { if (!enableTable) { return; } + LOG(debug) << "Processing Run3 data for TOF event time"; + tableEvTime.reserve(collisions.size()); tableEvTimeForTrack.reserve(tracks.size()); - std::vector tEvTimeForTrack; - std::vector tEvTimeErrForTrack; - tEvTimeForTrack.resize(tracks.size()); - tEvTimeErrForTrack.resize(tracks.size()); - - // for tracks not assigned to a collision - for (auto track : tracks) { - if (!track.has_collision()) { - tEvTimeForTrack[track.globalIndex()] = 0.f; - tEvTimeErrForTrack[track.globalIndex()] = 999.f; + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, bcs.iteratorAt(0)); // Update the calibration parameters + + // Autoset the processing mode for the event time computation + if (mComputeEvTimeWithTOF == -1 || mComputeEvTimeWithFT0 == -1) { + switch (mTOFCalibConfig.collisionSystem()) { + case CollisionSystemType::kCollSyspp: // pp + mComputeEvTimeWithTOF.value = ((mComputeEvTimeWithTOF == -1) ? 0 : mComputeEvTimeWithTOF.value); + mComputeEvTimeWithFT0.value = ((mComputeEvTimeWithFT0 == -1) ? 1 : mComputeEvTimeWithFT0.value); + break; + case CollisionSystemType::kCollSysPbPb: // PbPb + mComputeEvTimeWithTOF.value = ((mComputeEvTimeWithTOF == -1) ? 1 : mComputeEvTimeWithTOF.value); + mComputeEvTimeWithFT0.value = ((mComputeEvTimeWithFT0 == -1) ? 0 : mComputeEvTimeWithFT0.value); + break; + default: + LOG(fatal) << "Collision system " << mTOFCalibConfig.collisionSystem() << " " << CollisionSystemType::getCollisionSystemName(mTOFCalibConfig.collisionSystem()) << " not supported for TOF event time computation"; + break; } } + LOG(debug) << "Running on " << CollisionSystemType::getCollisionSystemName(mTOFCalibConfig.collisionSystem()) << " mComputeEvTimeWithTOF " << mComputeEvTimeWithTOF.value << " mComputeEvTimeWithFT0 " << mComputeEvTimeWithFT0.value; - for (auto const& collision : collisions) { // Loop on collisions - const auto& tracksInCollision = tracks.sliceBy(perCollision, collision.globalIndex()); - if ((sel8TOFEvTime.value == true) && !collision.sel8()) { - tableEvTime(0.f, 999.f, 0.f, 999.f, 0.f, 999.f); - for (auto track : tracksInCollision) { - tEvTimeForTrack[track.globalIndex()] = 0.f; - tEvTimeErrForTrack[track.globalIndex()] = 999.f; + if (mComputeEvTimeWithTOF == 1 && mComputeEvTimeWithFT0 == 1) { + int lastCollisionId = -1; // Last collision ID analysed + for (auto const& t : tracks) { // Loop on collisions + if (!t.has_collision() || ((sel8TOFEvTime.value == true) && !t.collision_as().sel8())) { // Track was not assigned, cannot compute event time or event did not pass the event selection + tableEvTimeForTrack(0.f, 999.f); + continue; } - continue; - } - - // Compute the TOF event time - const auto evTimeTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV2, diamond, fastTOFPID); - - float t0TOF[2] = {static_cast(evTimeTOF.mEventTime), static_cast(evTimeTOF.mEventTimeError)}; // Value and error of TOF - float t0AC[2] = {.0f, 999.f}; // Value and error of T0A or T0C or T0AC + if (t.collisionId() == lastCollisionId) { // Event time from this collision is already in the table + continue; + } + /// Create new table for the tracks in a collision + lastCollisionId = t.collisionId(); /// Cache last collision ID - float eventTime = 0.f; - float sumOfWeights = 0.f; - float weight = 0.f; + const auto& tracksInCollision = tracks.sliceBy(perCollision, lastCollisionId); + const auto& collision = t.collision_as(); - if (t0TOF[1] < errDiamond && (maxEvTimeTOF <= 0 || abs(t0TOF[0]) < maxEvTimeTOF)) { - weight = 1.f / (t0TOF[1] * t0TOF[1]); - eventTime += t0TOF[0] * weight; - sumOfWeights += weight; - } + // Compute the TOF event time + const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, kDiamond, fastTOFPID); - if (collision.has_foundFT0()) { // T0 measurement is available - // const auto& ft0 = collision.foundFT0(); - if (collision.t0ACValid()) { - t0AC[0] = collision.t0AC() * 1000.f; - t0AC[1] = collision.t0resolution() * 1000.f; - } + float t0AC[2] = {.0f, 999.f}; // Value and error of T0A or T0C or T0AC + float t0TOF[2] = {static_cast(evTimeMakerTOF.mEventTime), static_cast(evTimeMakerTOF.mEventTimeError)}; // Value and error of TOF - weight = 1.f / (t0AC[1] * t0AC[1]); - eventTime += t0AC[0] * weight; - sumOfWeights += weight; - } + int nGoodTracksForTOF = 0; + float eventTime = 0.f; + float sumOfWeights = 0.f; + float weight = 0.f; - if (sumOfWeights < weightDiamond) { // avoiding sumOfWeights = 0 or worse that diamond - eventTime = 0; - sumOfWeights = weightDiamond; - } - tableEvTime(eventTime / sumOfWeights, sqrt(1. / sumOfWeights), t0TOF[0], t0TOF[1], t0AC[0], t0AC[1]); - - int nGoodTracksForTOF = 0; // count for ntrackIndex for removeBias() - for (auto const& track : tracksInCollision) { - // Reset the event time - eventTime = 0.f; - sumOfWeights = 0.f; - weight = 0.f; - // Remove the bias on TOF ev. time - evTimeTOF.removeBias(track, nGoodTracksForTOF, t0TOF[0], t0TOF[1], 2); - if (t0TOF[1] < errDiamond && (maxEvTimeTOF <= 0 || abs(t0TOF[0]) < maxEvTimeTOF)) { + if (t0TOF[1] < kErrDiamond && (maxEvTimeTOF <= 0 || std::abs(t0TOF[0]) < maxEvTimeTOF)) { weight = 1.f / (t0TOF[1] * t0TOF[1]); eventTime += t0TOF[0] * weight; sumOfWeights += weight; } - // Add the contribution from FT0 if it is available, t0AC is already calculated - if (collision.has_foundFT0()) { + if (collision.has_foundFT0()) { // T0 measurement is available + // const auto& ft0 = collision.foundFT0(); + if (collision.t0ACValid()) { + t0AC[0] = collision.t0AC() * 1000.f; + t0AC[1] = collision.t0resolution() * 1000.f; + } + weight = 1.f / (t0AC[1] * t0AC[1]); eventTime += t0AC[0] * weight; sumOfWeights += weight; } - if (sumOfWeights < weightDiamond) { // avoiding sumOfWeights = 0 or worse that diamond - eventTime = 0; - sumOfWeights = weightDiamond; + tableEvTime(eventTime / sumOfWeights, std::sqrt(1. / sumOfWeights), t0TOF[0], t0TOF[1], t0AC[0], t0AC[1]); + + for (auto const& trk : tracksInCollision) { // Loop on Tracks + // Reset the event time + eventTime = 0.f; + sumOfWeights = 0.f; + weight = 0.f; + // Remove the bias on TOF ev. time + if constexpr (kRemoveTOFEvTimeBias) { + evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, t0TOF[0], t0TOF[1], 2); + } + if (t0TOF[1] < kErrDiamond && (maxEvTimeTOF <= 0 || std::abs(t0TOF[0]) < maxEvTimeTOF)) { + weight = 1.f / (t0TOF[1] * t0TOF[1]); + eventTime += t0TOF[0] * weight; + sumOfWeights += weight; + } + + if (collision.has_foundFT0()) { // T0 measurement is available + // const auto& ft0 = collision.foundFT0(); + if (collision.t0ACValid()) { + t0AC[0] = collision.t0AC() * 1000.f; + t0AC[1] = collision.t0resolution() * 1000.f; + } + + weight = 1.f / (t0AC[1] * t0AC[1]); + eventTime += t0AC[0] * weight; + sumOfWeights += weight; + } + + if (sumOfWeights < kWeightDiamond) { // avoiding sumOfWeights = 0 or worse that kDiamond + eventTime = 0; + sumOfWeights = kWeightDiamond; + } + tableEvTimeForTrack(eventTime / sumOfWeights, std::sqrt(1. / sumOfWeights)); } - tEvTimeForTrack[track.globalIndex()] = eventTime / sumOfWeights; - tEvTimeErrForTrack[track.globalIndex()] = sqrt(1. / sumOfWeights); } - } - for (int i = 0; i < tracks.size(); i++) { - tableEvTimeForTrack(tEvTimeForTrack[i], tEvTimeErrForTrack[i]); - } - } - PROCESS_SWITCH(pidTOFGeneric, processFT0, "Process with FT0", true); + } else if (mComputeEvTimeWithTOF == 1 && mComputeEvTimeWithFT0 == 0) { + int lastCollisionId = -1; // Last collision ID analysed + for (auto const& t : tracks) { // Loop on collisions + if (!t.has_collision() || ((sel8TOFEvTime.value == true) && !t.collision_as().sel8())) { // Track was not assigned, cannot compute event time or event did not pass the event selection + tableEvTimeForTrack(0.f, 999.f); + continue; + } + if (t.collisionId() == lastCollisionId) { // Event time from this collision is already in the table + continue; + } + /// Create new table for the tracks in a collision + lastCollisionId = t.collisionId(); /// Cache last collision ID - /// - /// Process function to prepare the event time on Run 3 data with only the FT0 - void processOnlyFT0(EvTimeCollisionsFT0 const& collisions, - TrksEvTime& tracks, - aod::FT0s const&) - { - if (!enableTable) { - return; - } - tableEvTime.reserve(collisions.size()); - tableEvTimeForTrack.reserve(tracks.size()); + const auto& tracksInCollision = tracks.sliceBy(perCollision, lastCollisionId); - // for tracks not assigned to a collision - for (auto track : tracks) { - if (!track.has_collision()) { - tableEvTimeForTrack(0.f, 999.f); - } - } + // First make table for event time + const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, kDiamond, fastTOFPID); + int nGoodTracksForTOF = 0; + float et = evTimeMakerTOF.mEventTime; + float erret = evTimeMakerTOF.mEventTimeError; - for (auto const& collision : collisions) { - const auto& tracksInCollision = tracks.sliceBy(perCollision, collision.globalIndex()); - if (collision.has_foundFT0()) { // T0 measurement is available - // const auto& ft0 = collision.foundFT0(); - if (collision.t0ACValid()) { - tableEvTime(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f, 0.f, 999.f, collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f); - for (int i = 0; i < tracks.size(); i++) { - tableEvTimeForTrack(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f); + if (erret < kErrDiamond && (maxEvTimeTOF <= 0.f || std::abs(et) < maxEvTimeTOF)) { + } else { + et = 0.f; + erret = kErrDiamond; + } + tableEvTime(et, erret, et, erret, 0.f, 999.f); + + for (auto const& trk : tracksInCollision) { // Loop on Tracks + if constexpr (kRemoveTOFEvTimeBias) { + evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, et, erret, 2); + } + if (erret < kErrDiamond && (maxEvTimeTOF <= 0.f || std::abs(et) < maxEvTimeTOF)) { + } else { + et = 0.f; + erret = kErrDiamond; } - return; + tableEvTimeForTrack(et, erret); + } + } + } else if (mComputeEvTimeWithTOF == 0 && mComputeEvTimeWithFT0 == 1) { + for (const auto& track : tracks) { + if (!track.has_collision()) { + tableEvTimeForTrack(0.f, 999.f); } } - tableEvTime(0.f, 999.f, 0.f, 999.f, 0.f, 999.f); - for (int i = 0; i < tracksInCollision.size(); i++) { - tableEvTimeForTrack(0.f, 999.f); + + for (auto const& collision : collisions) { + const auto& tracksInCollision = tracks.sliceBy(perCollision, collision.globalIndex()); + if (collision.has_foundFT0()) { // T0 measurement is available + // const auto& ft0 = collision.foundFT0(); + if (collision.t0ACValid()) { + tableEvTime(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f, 0.f, 999.f, collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f); + for (int i = 0; i < tracksInCollision.size(); i++) { + tableEvTimeForTrack(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f); + } + continue; + } + } + tableEvTime(0.f, 999.f, 0.f, 999.f, 0.f, 999.f); + for (int i = 0; i < tracksInCollision.size(); i++) { + tableEvTimeForTrack(0.f, 999.f); + } } + } else { + LOG(fatal) << "Invalid configuration for TOF event time computation"; } } - PROCESS_SWITCH(pidTOFGeneric, processOnlyFT0, "Process only with FT0", false); + PROCESS_SWITCH(pidTOFGeneric, processRun3, "Process the Run3 data", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { + metadataInfo.initMetadata(cfgc); return WorkflowSpec{ adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Nuspex/reduced3bodyCreator.cxx b/PWGLF/TableProducer/Nuspex/reduced3bodyCreator.cxx new file mode 100644 index 00000000000..e164dc2794c --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/reduced3bodyCreator.cxx @@ -0,0 +1,429 @@ +// 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. + +/// \file reduced3bodyCreator.cxx +/// \brief Task to produce reduced AO2Ds for use in the hypertriton 3body reconstruction with the decay3bodybuilder.cxx +/// \author Yuanzhe Wang +/// \author Carolina Reetz + +#include "TableHelper.h" + +#include "PWGLF/DataModel/LFPIDTOFGenericTables.h" +#include "PWGLF/DataModel/Reduced3BodyTables.h" +#include "PWGLF/Utils/pidTOFGeneric.h" + +#include "Common/Core/PID/PIDTOF.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" +#include "Tools/KFparticle/KFUtilities.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DCAFitter/DCAFitterN.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include +#include +#include + +#ifndef HomogeneousField +#define HomogeneousField +#endif + +// includes KFParticle +#include "KFPTrack.h" +#include "KFPVertex.h" +#include "KFParticle.h" +#include "KFParticleBase.h" +#include "KFVertex.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +o2::common::core::MetadataHelper metadataInfo; + +using FullTracksExtIU = soa::Join; +using FullTracksExtPIDIU = soa::Join; + +using ColwithEvTimes = o2::soa::Join; +using ColwithEvTimesMultsCents = o2::soa::Join; +using TrackExtIUwithEvTimes = soa::Join; +using TrackExtPIDIUwithEvTimes = soa::Join; + +struct reduced3bodyCreator { + + Produces reducedCollisions; + Produces reducedPVMults; + Produces reducedCentFT0Cs; + Produces reducedDecay3Bodys; + Produces reduced3BodyInfo; + Produces reducedFullTracksPIDIU; + + Service ccdb; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + + o2::vertexing::DCAFitterN<3> fitter3body; + o2::aod::pidtofgeneric::TofPidNewCollision bachelorTOFPID; + + Configurable doSel8selection{"doSel8selection", true, "flag for sel8 event selection"}; + Configurable doPosZselection{"doPosZselection", true, "flag for posZ event selection"}; + // CCDB options + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + // CCDB TOF PID paras + Configurable timestamp{"ccdb-timestamp", -1, "timestamp of the object"}; + Configurable paramFileName{"paramFileName", "", "Path to the parametrization object. If empty the parametrization is not taken from file"}; + Configurable parametrizationPath{"parametrizationPath", "TOF/Calib/Params", "Path of the TOF parametrization on the CCDB or in the file, if the paramFileName is not empty"}; + Configurable passName{"passName", "", "Name of the pass inside of the CCDB parameter collection. If empty, the automatically deceted from metadata (to be implemented!!!)"}; + Configurable timeShiftCCDBPath{"timeShiftCCDBPath", "", "Path of the TOF time shift vs eta. If empty none is taken"}; + Configurable loadResponseFromCCDB{"loadResponseFromCCDB", false, "Flag to load the response from the CCDB"}; + Configurable fatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"}; + // Zorro counting + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "Skimmed dataset processing"}; + // Flag for trigger + Configurable cfgOnlyKeepInterestedTrigger{"cfgOnlyKeepInterestedTrigger", false, "Flag to keep only interested trigger"}; + Configurable triggerList{"triggerList", "fH3L3Body", "List of triggers used to select events"}; + + Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction for DCAFitter"}; + + int mRunNumber; + float mBz; + // TOF response and input parameters + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + o2::aod::pidtofgeneric::TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration + + // tracked cluster size + std::vector fTrackedClSizeVector; + + HistogramRegistry registry{"registry", {}}; + + void init(InitContext& initContext) + { + mRunNumber = 0; + zorroSummary.setObject(zorro.getZorroSummary()); + bachelorTOFPID.SetPidType(o2::track::PID::Deuteron); + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + // TOF PID parameters initialization + mTOFCalibConfig.metadataInfo = metadataInfo; + mTOFCalibConfig.inheritFromBaseTask(initContext); + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); + + fitter3body.setPropagateToPCA(true); + fitter3body.setMaxR(200.); //->maxRIni3body + fitter3body.setMinParamChange(1e-3); + fitter3body.setMinRelChi2Change(0.9); + fitter3body.setMaxDZIni(1e9); + fitter3body.setMaxChi2(1e9); + fitter3body.setUseAbsDCA(true); + int mat{static_cast(cfgMaterialCorrection)}; + fitter3body.setMatCorrType(static_cast(mat)); + + registry.add("hAllSelEventsVtxZ", "hAllSelEventsVtxZ", HistType::kTH1F, {{500, -15.0f, 15.0f, "PV Z (cm)"}}); + + auto hEventCounter = registry.add("hEventCounter", "hEventCounter", HistType::kTH1D, {{4, 0.0f, 4.0f}}); + hEventCounter->GetXaxis()->SetBinLabel(1, "total"); + hEventCounter->GetXaxis()->SetBinLabel(2, "sel8"); + hEventCounter->GetXaxis()->SetBinLabel(3, "vertexZ"); + hEventCounter->GetXaxis()->SetBinLabel(4, "reduced"); + hEventCounter->LabelsOption("v"); + + auto hEventCounterZorro = registry.add("hEventCounterZorro", "hEventCounterZorro", HistType::kTH1D, {{2, 0, 2}}); + hEventCounterZorro->GetXaxis()->SetBinLabel(1, "Zorro before evsel"); + hEventCounterZorro->GetXaxis()->SetBinLabel(2, "Zorro after evsel"); + } + + void initZorroBC(aod::BCsWithTimestamps::iterator const& bc) + { + if (cfgSkimmedProcessing) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), triggerList); + zorro.populateHistRegistry(registry, bc.runNumber()); + } + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + // In case override, don't proceed, please - no CCDB access required + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + + // In case override, don't proceed, please - no CCDB access required + auto run3grp_timestamp = bc.timestamp(); + o2::parameters::GRPMagField* grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + // Fetch magnetic field from ccdb for current collision + // mBz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + mBz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << mBz << " kZG"; +// Set magnetic field for KF vertexing +#ifdef HomogeneousField + KFParticle::SetField(mBz); +#endif + + fitter3body.setBz(mBz); + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, bc); + } + + //------------------------------------------------------------------ + // function to fill reduced track table + template + void fillTrackTable(TTrack const& daughter, double tofNSigmaTrack, auto collisionIndex) + { + reducedFullTracksPIDIU( + // TrackIU + collisionIndex, + daughter.x(), daughter.alpha(), + daughter.y(), daughter.z(), daughter.snp(), daughter.tgl(), + daughter.signed1Pt(), + // TracksCovIU + daughter.sigmaY(), daughter.sigmaZ(), daughter.sigmaSnp(), daughter.sigmaTgl(), daughter.sigma1Pt(), + daughter.rhoZY(), daughter.rhoSnpY(), daughter.rhoSnpZ(), daughter.rhoTglY(), daughter.rhoTglZ(), + daughter.rhoTglSnp(), daughter.rho1PtY(), daughter.rho1PtZ(), daughter.rho1PtSnp(), daughter.rho1PtTgl(), + // TracksExtra + daughter.tpcInnerParam(), daughter.flags(), daughter.itsClusterSizes(), + daughter.tpcNClsFindable(), daughter.tpcNClsFindableMinusFound(), daughter.tpcNClsFindableMinusCrossedRows(), + daughter.trdPattern(), daughter.tpcChi2NCl(), daughter.tofChi2(), + daughter.tpcSignal(), daughter.tofExpMom(), + // PID + daughter.tpcNSigmaPr(), daughter.tpcNSigmaPi(), daughter.tpcNSigmaDe(), + tofNSigmaTrack); + } + + //------------------------------------------------------------------ + // function to fit KFParticle 3body vertex + template + bool fit3bodyVertex(TKFParticle& kfpProton, TKFParticle& kfpPion, TKFParticle& kfpDeuteron, TKFParticle& KFHt) + { + // Construct 3body vertex + int nDaughters3body = 3; + const KFParticle* Daughters3body[3] = {&kfpProton, &kfpPion, &kfpDeuteron}; + KFHt.SetConstructMethod(2); + try { + KFHt.Construct(Daughters3body, nDaughters3body); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to create Hyper triton 3-body vertex." << e.what(); + return false; + } + LOG(debug) << "Hypertriton vertex constructed."; + return true; + } + + void process(ColwithEvTimesMultsCents const& collisions, TrackExtPIDIUwithEvTimes const&, aod::Decay3Bodys const& decay3bodys, aod::Tracked3Bodys const& tracked3bodys, aod::BCsWithTimestamps const&) + { + std::vector isTriggeredCollision(collisions.size(), false); + + int lastRunNumber = -1; // RunNumber of last collision, used for zorro counting + // Event counting + for (const auto& collision : collisions) { + + auto bc = collision.bc_as(); + if (bc.runNumber() != lastRunNumber) { + initZorroBC(bc); + lastRunNumber = bc.runNumber(); // Update the last run number + } + + // Zorro event counting + bool isZorroSelected = false; + if (cfgSkimmedProcessing) { + isZorroSelected = zorro.isSelected(bc.globalBC()); + if (isZorroSelected) { + registry.fill(HIST("hEventCounterZorro"), 0.5); + isTriggeredCollision[collision.globalIndex()] = true; + } + } + + // Event selection + registry.fill(HIST("hEventCounter"), 0.5); + if (doSel8selection && !collision.sel8()) { + continue; + } + registry.fill(HIST("hEventCounter"), 1.5); + if (doPosZselection && (collision.posZ() >= 10.0f || collision.posZ() <= -10.0f)) { // 10cm + continue; + } + registry.fill(HIST("hEventCounter"), 2.5); + registry.fill(HIST("hAllSelEventsVtxZ"), collision.posZ()); + + if (cfgSkimmedProcessing && isZorroSelected) { + registry.fill(HIST("hEventCounterZorro"), 1.5); + } + } + + int lastCollisionID = -1; // collisionId of last analysed decay3body. Table is sorted. + + // get tracked cluster size info + fTrackedClSizeVector.clear(); + fTrackedClSizeVector.resize(decay3bodys.size(), 0); + for (const auto& tvtx3body : tracked3bodys) { + fTrackedClSizeVector[tvtx3body.decay3BodyId()] = tvtx3body.itsClsSize(); + } + + // Create reduced table + for (const auto& d3body : decay3bodys) { + + auto collision = d3body.template collision_as(); + + if (doSel8selection && !collision.sel8()) { + continue; + } + if (doPosZselection && (collision.posZ() >= 10.0f || collision.posZ() <= -10.0f)) { // 10cm + continue; + } + + auto bc = collision.bc_as(); + initCCDB(bc); + if (cfgSkimmedProcessing && cfgOnlyKeepInterestedTrigger) { + if (isTriggeredCollision[collision.globalIndex()] == false) { + continue; + } + } + + // Save the collision + if (collision.globalIndex() != lastCollisionID) { + int runNumber = bc.runNumber(); + reducedCollisions( + collision.posX(), collision.posY(), collision.posZ(), + collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ(), + collision.flags(), collision.chi2(), collision.numContrib(), + collision.collisionTime(), collision.collisionTimeRes(), + runNumber); + reducedPVMults(collision.multNTracksPV()); + reducedCentFT0Cs(collision.centFT0C()); + + lastCollisionID = collision.globalIndex(); + } + + // Precompute collision index + const auto collisionIndex = reducedCollisions.lastIndex(); + + // Save daughter tracks + const auto daughter0 = d3body.template track0_as(); + const auto daughter1 = d3body.template track1_as(); + const auto daughter2 = d3body.template track2_as(); + + // TOF PID of bachelor must be calcualted here + // ---------------------------------------------- + auto originalcol = daughter2.template collision_as(); + double tofNSigmaBach = bachelorTOFPID.GetTOFNSigma(mRespParamsV3, daughter2, originalcol, collision); + // ---------------------------------------------- + + // -------- save reduced track table with decay3body daughters ---------- + fillTrackTable(daughter0, -999, collisionIndex); + fillTrackTable(daughter1, -999, collisionIndex); + fillTrackTable(daughter2, tofNSigmaBach, collisionIndex); + + // -------- save reduced decay3body table -------- + const auto trackStartIndex = reducedFullTracksPIDIU.lastIndex(); + reducedDecay3Bodys(collisionIndex, trackStartIndex - 2, trackStartIndex - 1, trackStartIndex); + + // -------- get decay3body info with KF -------- + // get trackParCov daughters + auto trackParCovPos = getTrackParCov(daughter0); + auto trackParCovNeg = getTrackParCov(daughter1); + auto trackParCovBach = getTrackParCov(daughter2); + // create KFParticle daughters + KFParticle kfpProton, kfpPion, kfpDeuteron; + if (daughter2.sign() > 0) { + kfpProton = createKFParticleFromTrackParCov(trackParCovPos, daughter0.sign(), constants::physics::MassProton); + kfpPion = createKFParticleFromTrackParCov(trackParCovNeg, daughter1.sign(), constants::physics::MassPionCharged); + } else if (!(daughter2.sign() > 0)) { + kfpProton = createKFParticleFromTrackParCov(trackParCovNeg, daughter1.sign(), constants::physics::MassProton); + kfpPion = createKFParticleFromTrackParCov(trackParCovPos, daughter0.sign(), constants::physics::MassPionCharged); + } + kfpDeuteron = createKFParticleFromTrackParCov(trackParCovBach, daughter2.sign(), constants::physics::MassDeuteron); + // fit 3body vertex and caclulate radius, phi, z position + float radius, phi, posZ; + KFParticle KFHt; + if (fit3bodyVertex(kfpProton, kfpPion, kfpDeuteron, KFHt)) { + radius = std::hypot(KFHt.GetX(), KFHt.GetY()); + phi = std::atan2(KFHt.GetPx(), KFHt.GetPy()); + posZ = KFHt.GetZ(); + } else { + radius = -999.; + phi = -999.; + posZ = -999.; + } + + // -------- get decay3body info with DCA fitter -------- + auto Track0 = getTrackParCov(daughter0); + auto Track1 = getTrackParCov(daughter1); + auto Track2 = getTrackParCov(daughter2); + int n3bodyVtx = fitter3body.process(Track0, Track1, Track2); + float phiVtx, rVtx, zVtx; + if (n3bodyVtx == 0) { // discard this pair + phiVtx = -999.; + rVtx = -999.; + zVtx = -999.; + } else { + const auto& vtxXYZ = fitter3body.getPCACandidate(); + + std::array p0 = {0.}, p1 = {0.}, p2{0.}; + const auto& propagatedTrack0 = fitter3body.getTrack(0); + const auto& propagatedTrack1 = fitter3body.getTrack(1); + const auto& propagatedTrack2 = fitter3body.getTrack(2); + propagatedTrack0.getPxPyPzGlo(p0); + propagatedTrack1.getPxPyPzGlo(p1); + propagatedTrack2.getPxPyPzGlo(p2); + std::array p3B = {p0[0] + p1[0] + p2[0], p0[1] + p1[1] + p2[1], p0[2] + p1[2] + p2[2]}; + phiVtx = std::atan2(p3B[1], p3B[0]); + rVtx = std::hypot(vtxXYZ[0], vtxXYZ[1]); + zVtx = vtxXYZ[2]; + } + + // fill 3body info table (KF and DCA fitter info) + reduced3BodyInfo(radius, phi, posZ, rVtx, phiVtx, zVtx, fTrackedClSizeVector[d3body.globalIndex()]); + } // end decay3body loop + + registry.fill(HIST("hEventCounter"), 3.5, reducedCollisions.lastIndex() + 1); + } +}; + +struct reduced3bodyInitializer { + Spawns reducedTracksIU; + void init(InitContext const&) {} +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + metadataInfo.initMetadata(cfgc); + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGLF/TableProducer/Nuspex/threebodyKFTask.cxx b/PWGLF/TableProducer/Nuspex/threebodyKFTask.cxx deleted file mode 100644 index 7dad8981ee7..00000000000 --- a/PWGLF/TableProducer/Nuspex/threebodyKFTask.cxx +++ /dev/null @@ -1,450 +0,0 @@ -// 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. -// -/// \brief Analysis task for KFVtx3BodyDatas (3body candidates reconstructed with KF) -/// \author Carolina Reetz --> partly copied from threebodyRecoTask.cxx -// ======================== - -#include -#include -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/Vtx3BodyTables.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "CommonConstants/PhysicsConstants.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using std::array; - -using MCLabeledTracksIU = soa::Join; - -struct threebodyKFTask { - - Produces outputMCTable; - std::vector filledMothers; - std::vector isGoodCollision; - - // Configurables - Configurable bachelorPdgCode{"bachelorPdgCode", 1000010020, "pdgCode of bachelor daughter"}; - Configurable motherPdgCode{"motherPdgCode", 1010010030, "pdgCode of mother"}; - - ConfigurableAxis m2PrPiBins{"m2PrPiBins", {60, 1., 3.3}, "Binning for m2(p,pi) axis"}; - ConfigurableAxis m2PiDeBins{"m2PiDeBins", {120, 4.0, 8.0}, "Binning for m2(pi,d) axis"}; - - // collision filter and preslice - Filter collisionFilter = (aod::evsel::sel8 == true && nabs(aod::collision::posZ) < 10.f); - Preslice> perCollisionVtx3BodyDatas = o2::aod::vtx3body::collisionId; - - HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; - - void init(InitContext const&) - { - const AxisSpec axisM2PrPi{m2PrPiBins, "#it{m}^{2}(p,#pi^{-}) ((GeV/#it{c}^{2})^{2})"}; - const AxisSpec axisM2PiDe{m2PiDeBins, "#it{m}^{2}(#pi^{+},#bar{d}) ((GeV/#it{c}^{2})^{2})"}; - - registry.add("hCentFT0C", "hCentFT0C", HistType::kTH1F, {{100, 0.0f, 100.0f, "FT0C Centrality"}}); - - // mass spectrum of reco candidates - registry.add("hMassHypertriton", "Mass hypertriton", HistType::kTH1F, {{80, 2.96f, 3.04f, "#it{m}(p,#pi^{-},d) (GeV/#it{c}^{2})"}}); - registry.add("hMassAntiHypertriton", "Mass anti-hypertriton", HistType::kTH1F, {{80, 2.96f, 3.04f, "#it{m}(#bar{p},#pi^{+},#bar{d}) (GeV/#it{c}^{2})"}}); - - // Dalitz diagrams of reco candidates - registry.add("hDalitzHypertriton", "Dalitz diagram", HistType::kTH2F, {axisM2PrPi, axisM2PiDe})->GetYaxis()->SetTitle("#it{m}^{2}(#pi^{-},d) ((GeV/#it{c}^{2})^{2})"); - registry.add("hDalitzAntiHypertriton", "Dalitz diagram", HistType::kTH2F, {axisM2PrPi, axisM2PiDe})->GetXaxis()->SetTitle("#it{m}^{2}(#bar{p},#pi^{+}) ((GeV/#it{c}^{2})^{2})"); - - // bachelor histgrams - registry.add("hAverageITSClusterSizeBachelor", "Average ITS cluster size bachelor track", HistType::kTH1F, {{15, 0.5, 15.5, "#langle ITS cluster size #rangle"}}); - registry.add("hdEdxBachelor", "TPC dE/dx bachelor track", HistType::kTH1F, {{200, 0.0f, 200.0f, "Average ITS cluster size"}}); - registry.add("hPIDTrackingBachelor", "Tracking PID bachelor track", HistType::kTH1F, {{20, 0.5, 20.5, "Tracking PID identifier"}}); - - // for gen information of reco candidates - auto LabelHist = registry.add("hLabelCounter", "Reco MC candidate counter", HistType::kTH1F, {{3, 0.0f, 3.0f}}); - LabelHist->GetXaxis()->SetBinLabel(1, "Total"); - LabelHist->GetXaxis()->SetBinLabel(2, "Have Same MotherTrack"); - LabelHist->GetXaxis()->SetBinLabel(3, "True H3L/Anti-H3L"); - registry.add("hTrueHypertritonMCPt", "pT gen. of reco. H3L", HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}}); - registry.add("hTrueAntiHypertritonMCPt", "pT gen. of reco. Anti-H3L", HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}}); - registry.add("hTrueHypertritonMCMass", "mass gen. of reco. H3L", HistType::kTH1F, {{40, 2.96f, 3.04f, "#it{m}(p,#pi^{-},d) (GeV/#it{c}^{2})"}}); - registry.add("hTrueAntiHypertritonMCMass", "mass gen. of reco. Anti-H3L", HistType::kTH1F, {{40, 2.96f, 3.04f, "#it{m}(#bar{p},#pi^{+},#bar{d}) (GeV/#it{c}^{2})"}}); - registry.add("hTrueHypertritonMCCTau", "#it{c}#tau gen. of reco. H3L", HistType::kTH1F, {{50, 0.0f, 50.0f, "#it{c}#tau(cm)"}}); - registry.add("hTrueAntiHypertritonMCCTau", "#it{c}#tau gen. of reco. Anti-H3L", HistType::kTH1F, {{50, 0.0f, 50.0f, "#it{c}#tau(cm)"}}); - registry.add("hTrueHypertritonMCMassPrPi", "inv. mass gen. of reco. V0 pair (H3L)", HistType::kTH1F, {{100, 0.0f, 6.0f, "#it{m}(p,#pi^{-}) (GeV/#it{c}^{2})"}}); - registry.add("hTrueAntiHypertritonMCMassPrPi", "inv. mass gen. of reco. V0 pair (Anti-H3L)", HistType::kTH1F, {{100, 0.0f, 6.0f, "#it{m}(#bar{p},#pi^{+}) (GeV/#it{c}^{2})"}}); - - // for gen information of non reco candidates - registry.add("hTrueHypertritonMCMassPrPi_nonReco", "inv. mass gen. of non-reco. V0 pair (H3L)", HistType::kTH1F, {{100, 0.0f, 6.0f, "#it{m}(p,#pi^{-}) (GeV/#it{c}^{2})"}}); - registry.add("hTrueAntiHypertritonMCMassPrPi_nonReco", "inv. mass gen. of non-reco. V0 pair (Anti-H3L)", HistType::kTH1F, {{100, 0.0f, 6.0f, "#it{m}(#bar{p},#pi^{+}) (GeV/#it{c}^{2})"}}); - registry.add("hTrueHypertritonMCPtProton_nonReco", "Proton #it{p}_{T} gen. of non-reco. H3L", HistType::kTH1F, {{100, 0.0f, 6.0f, "#it{p}_{T}(p) (GeV/#it{c})"}}); - registry.add("hTrueHypertritonMCPtPion_nonReco", "Pion #it{p}_{T} gen. of non-reco. H3L", HistType::kTH1F, {{100, 0.0f, 6.0f, "#it{p}_{T}(#pi) (GeV/#it{c})"}}); - registry.add("hTrueAntiHypertritonMCPtProton_nonReco", "Proton #it{p}_{T} gen. of non-reco. Anti-H3L", HistType::kTH1F, {{100, 0.0f, 6.0f, "#it{p}_{T}(p) (GeV/#it{c})"}}); - registry.add("hTrueAntiHypertritonMCPtPion_nonReco", "Pion #it{p}_{T} gen. of non-reco. Anti- H3L", HistType::kTH1F, {{100, 0.0f, 6.0f, "#it{p}_{T}(#pi) (GeV/#it{c})"}}); - } - - template - void fillQAPlots(TCand const& vtx3body) - { - // Mass plot - if (vtx3body.track2sign() > 0) { // hypertriton - registry.fill(HIST("hMassHypertriton"), vtx3body.mass()); - } else if (vtx3body.track2sign() < 0) { // anti-hypertriton - registry.fill(HIST("hMassAntiHypertriton"), vtx3body.mass()); - } - - // Dalitz plot - auto m2prpi = RecoDecay::m2(array{array{vtx3body.pxtrack0(), vtx3body.pytrack0(), vtx3body.pztrack0()}, array{vtx3body.pxtrack1(), vtx3body.pytrack1(), vtx3body.pztrack1()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); - auto m2pide = RecoDecay::m2(array{array{vtx3body.pxtrack1(), vtx3body.pytrack1(), vtx3body.pztrack1()}, array{vtx3body.pxtrack2(), vtx3body.pytrack2(), vtx3body.pztrack2()}}, array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); - if (std::abs(vtx3body.mass() - o2::constants::physics::MassHyperTriton) <= 0.005) { - if (vtx3body.track2sign() > 0) { // hypertriton - registry.fill(HIST("hDalitzHypertriton"), m2prpi, m2pide); - } else if (vtx3body.track2sign() < 0) { // anti-hypertriton - registry.fill(HIST("hDalitzAntiHypertriton"), m2prpi, m2pide); - } - } - - // ITS cluster sizes - registry.fill(HIST("hAverageITSClusterSizeBachelor"), vtx3body.itsclussizedeuteron()); - registry.fill(HIST("hdEdxBachelor"), vtx3body.tpcdedxdeuteron()); - registry.fill(HIST("hPIDTrackingBachelor"), vtx3body.pidtrackingdeuteron()); - } - - //------------------------------------------------------------------ - // process real data analysis - void processData(soa::Filtered>::iterator const& collision, - aod::KFVtx3BodyDatas const& vtx3bodydatas) - { - registry.fill(HIST("hCentFT0C"), collision.centFT0C()); - - for (auto& vtx3bodydata : vtx3bodydatas) { - // QA histograms - fillQAPlots(vtx3bodydata); - } - } - PROCESS_SWITCH(threebodyKFTask, processData, "Data analysis", true); - - //------------------------------------------------------------------ - // process mc analysis - void processMC(soa::Join const& collisions, - soa::Join const& vtx3bodydatas, - aod::McParticles const& particlesMC, - MCLabeledTracksIU const&, - aod::McCollisions const& mcCollisions) - { - filledMothers.clear(); - isGoodCollision.resize(mcCollisions.size(), false); - - // loop over collisions - for (const auto& collision : collisions) { - // event selection - if (!collision.sel8() || abs(collision.posZ()) > 10.f) { - continue; - } - // reco collision survived event selection filter --> fill value for MC collision if collision is "true" MC collision - if (collision.mcCollisionId() >= 0) { - isGoodCollision[collision.mcCollisionId()] = true; - } - - // fill MC table with reco MC candidate information and gen information if matched to MC particle - auto Decay3BodyTable_thisCollision = vtx3bodydatas.sliceBy(perCollisionVtx3BodyDatas, collision.globalIndex()); - for (auto& vtx3bodydata : Decay3BodyTable_thisCollision) { - registry.fill(HIST("hLabelCounter"), 0.5); - - // fill QA histograms for all reco candidates - fillQAPlots(vtx3bodydata); - - double MClifetime = -1.; - bool isTrueH3L = false; - bool isTrueAntiH3L = false; - float genPhi = -1.; - float genEta = -1.; - float genRap = -1.; - float genP = -1.; - float genPt = -1.; - std::array genDecVtx{-1.f}; - int vtx3bodyPDGcode = -1; - double MCmassPrPi = -1.; - float genPosP = -1.; - float genPosPt = -1.; - float genNegP = -1.; - float genNegPt = -1.; - float genBachP = -1.; - float genBachPt = -1.; - - auto track0 = vtx3bodydata.track0_as(); - auto track1 = vtx3bodydata.track1_as(); - auto track2 = vtx3bodydata.track2_as(); - - if (vtx3bodydata.has_mcParticle() && vtx3bodydata.mcParticleId() > -1 && vtx3bodydata.mcParticleId() <= particlesMC.size()) { // mother to daughter association already checked in decay3bodybuilder - auto MCvtx3body = vtx3bodydata.mcParticle(); - registry.fill(HIST("hLabelCounter"), 1.5); - if (MCvtx3body.has_daughters()) { - auto lMCTrack0 = track0.mcParticle_as(); - auto lMCTrack1 = track1.mcParticle_as(); - auto lMCTrack2 = track2.mcParticle_as(); - // check PDG codes - if ((MCvtx3body.pdgCode() == motherPdgCode && lMCTrack0.pdgCode() == 2212 && lMCTrack1.pdgCode() == -211 && lMCTrack2.pdgCode() == bachelorPdgCode) || - (MCvtx3body.pdgCode() == -motherPdgCode && lMCTrack0.pdgCode() == 211 && lMCTrack1.pdgCode() == -2212 && lMCTrack2.pdgCode() == -bachelorPdgCode)) { - vtx3bodyPDGcode = MCvtx3body.pdgCode(); - genDecVtx = {lMCTrack0.vx(), lMCTrack0.vy(), lMCTrack0.vz()}; - MClifetime = RecoDecay::sqrtSumOfSquares(lMCTrack2.vx() - MCvtx3body.vx(), lMCTrack2.vy() - MCvtx3body.vy(), lMCTrack2.vz() - MCvtx3body.vz()) * o2::constants::physics::MassHyperTriton / MCvtx3body.p(); - genPhi = MCvtx3body.phi(); - genEta = MCvtx3body.eta(); - genRap = MCvtx3body.y(); - genP = MCvtx3body.p(); - genPt = MCvtx3body.pt(); - genPosP = lMCTrack0.p(); - genPosPt = lMCTrack0.pt(); - genNegP = lMCTrack1.p(); - genNegPt = lMCTrack1.pt(); - genBachP = lMCTrack2.p(); - genBachPt = lMCTrack2.pt(); - filledMothers.push_back(MCvtx3body.globalIndex()); - } // end is H3L or Anti-H3L - if (MCvtx3body.pdgCode() == motherPdgCode && lMCTrack0.pdgCode() == 2212 && lMCTrack1.pdgCode() == -211 && lMCTrack2.pdgCode() == bachelorPdgCode) { - isTrueH3L = true; - double hypertritonMCMass = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}, array{lMCTrack2.px(), lMCTrack2.py(), lMCTrack2.pz()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); - MCmassPrPi = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); - registry.fill(HIST("hLabelCounter"), 2.5); - registry.fill(HIST("hTrueHypertritonMCPt"), MCvtx3body.pt()); - registry.fill(HIST("hTrueHypertritonMCCTau"), MClifetime); - registry.fill(HIST("hTrueHypertritonMCMass"), hypertritonMCMass); - registry.fill(HIST("hTrueHypertritonMCMassPrPi"), MCmassPrPi); - } // end is H3L - if (MCvtx3body.pdgCode() == -motherPdgCode && lMCTrack0.pdgCode() == 211 && lMCTrack1.pdgCode() == -2212 && lMCTrack2.pdgCode() == -bachelorPdgCode) { - isTrueAntiH3L = true; - double antiHypertritonMCMass = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}, array{lMCTrack2.px(), lMCTrack2.py(), lMCTrack2.pz()}}, array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}); - MCmassPrPi = RecoDecay::m(array{array{lMCTrack0.px(), lMCTrack0.py(), lMCTrack0.pz()}, array{lMCTrack1.px(), lMCTrack1.py(), lMCTrack1.pz()}}, array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton}); - registry.fill(HIST("hLabelCounter"), 2.5); - registry.fill(HIST("hTrueAntiHypertritonMCPt"), MCvtx3body.pt()); - registry.fill(HIST("hTrueAntiHypertritonMCCTau"), MClifetime); - registry.fill(HIST("hTrueAntiHypertritonMCMass"), antiHypertritonMCMass); - registry.fill(HIST("hTrueAntiHypertritonMCMassPrPi"), MCmassPrPi); - } // end is Anti-H3L - } // end has daughters - } // end has matched MC particle - - outputMCTable( // filled for each reconstructed candidate (in KFVtx3BodyDatas) - vtx3bodydata.mass(), - vtx3bodydata.x(), vtx3bodydata.y(), vtx3bodydata.z(), - vtx3bodydata.xerr(), vtx3bodydata.yerr(), vtx3bodydata.zerr(), - vtx3bodydata.px(), vtx3bodydata.py(), vtx3bodydata.pz(), vtx3bodydata.pt(), - vtx3bodydata.pxerr(), vtx3bodydata.pyerr(), vtx3bodydata.pzerr(), vtx3bodydata.pterr(), - vtx3bodydata.sign(), - vtx3bodydata.dcavtxtopvkf(), vtx3bodydata.dcaxyvtxtopvkf(), - vtx3bodydata.vtxcospakf(), vtx3bodydata.vtxcosxypakf(), - vtx3bodydata.vtxcospakftopo(), vtx3bodydata.vtxcosxypakftopo(), - vtx3bodydata.decaylkf(), vtx3bodydata.decaylxykf(), vtx3bodydata.decayldeltal(), - vtx3bodydata.chi2geondf(), vtx3bodydata.chi2topondf(), - vtx3bodydata.ctaukftopo(), - vtx3bodydata.massv0(), vtx3bodydata.chi2massv0(), - vtx3bodydata.cospav0(), - vtx3bodydata.pxtrack0(), vtx3bodydata.pytrack0(), vtx3bodydata.pztrack0(), // proton - vtx3bodydata.pxtrack1(), vtx3bodydata.pytrack1(), vtx3bodydata.pztrack1(), // pion - vtx3bodydata.pxtrack2(), vtx3bodydata.pytrack2(), vtx3bodydata.pztrack2(), // deuteron - vtx3bodydata.tpcinnerparamtrack0(), vtx3bodydata.tpcinnerparamtrack1(), vtx3bodydata.tpcinnerparamtrack2(), // proton, pion, deuteron - vtx3bodydata.dcatrack0topvkf(), vtx3bodydata.dcatrack1topvkf(), vtx3bodydata.dcatrack2topvkf(), // proton, pion, deuteron - vtx3bodydata.dcaxytrack0topvkf(), vtx3bodydata.dcaxytrack1topvkf(), vtx3bodydata.dcaxytrack2topvkf(), // proton, pion, deuteron - vtx3bodydata.dcaxytrack0tosvkf(), vtx3bodydata.dcaxytrack1tosvkf(), vtx3bodydata.dcaxytrack2tosvkf(), // proton, pion, deuteron - vtx3bodydata.dcaxytrack0totrack1kf(), vtx3bodydata.dcaxytrack0totrack2kf(), vtx3bodydata.dcaxytrack1totrack2kf(), - vtx3bodydata.dcavtxdaughterskf(), - vtx3bodydata.dcaxytrackpostopv(), vtx3bodydata.dcaxytracknegtopv(), vtx3bodydata.dcaxytrackbachtopv(), - vtx3bodydata.dcatrackpostopv(), vtx3bodydata.dcatracknegtopv(), vtx3bodydata.dcatrackbachtopv(), - vtx3bodydata.track0sign(), vtx3bodydata.track1sign(), vtx3bodydata.track2sign(), // proton, pion, deuteron - vtx3bodydata.tpcnsigmaproton(), vtx3bodydata.tpcnsigmapion(), vtx3bodydata.tpcnsigmadeuteron(), vtx3bodydata.tpcnsigmapionbach(), - vtx3bodydata.tpcdedxproton(), vtx3bodydata.tpcdedxpion(), vtx3bodydata.tpcdedxdeuteron(), - vtx3bodydata.tofnsigmadeuteron(), - vtx3bodydata.itsclussizedeuteron(), - vtx3bodydata.pidtrackingdeuteron(), - // MC info (-1 if not matched to MC particle) - genP, - genPt, - genDecVtx[0], genDecVtx[1], genDecVtx[2], - MClifetime, - genPhi, - genEta, - genRap, - genPosP, genPosPt, genNegP, genNegPt, genBachP, genBachPt, - isTrueH3L, isTrueAntiH3L, - vtx3bodyPDGcode, - true, // is reconstructed - true); // reco event passed event selection - } // end vtx3bodydatas loop - } // end collision loop - - // generated MC particle analysis - // fill MC table with gen information for all generated but not reconstructed particles - for (auto& mcparticle : particlesMC) { - - double genMCmassPrPi = -1.; - bool isTrueGenH3L = false; - bool isTrueGenAntiH3L = false; - float genPBach = -1.; - float genPtBach = -1.; - float genPPos = -1.; - float genPtPos = -1.; - float genPNeg = -1.; - float genPtNeg = -1.; - - // check if mcparticle was reconstructed and already filled in the table - if (std::find(filledMothers.begin(), filledMothers.end(), mcparticle.globalIndex()) != std::end(filledMothers)) { - continue; - } - - // set flag if corresponding reco collision survived event selection - bool survEvSel = isGoodCollision[mcparticle.mcCollisionId()]; - - // check if MC particle is hypertriton with 3-body decay - if (std::abs(mcparticle.pdgCode()) != motherPdgCode) { - continue; - } - bool haveProton = false, havePion = false, haveBachelor = false; - bool haveAntiProton = false, haveAntiPion = false, haveAntiBachelor = false; - for (auto& mcparticleDaughter : mcparticle.template daughters_as()) { - if (mcparticleDaughter.pdgCode() == 2212) - haveProton = true; - if (mcparticleDaughter.pdgCode() == -2212) - haveAntiProton = true; - if (mcparticleDaughter.pdgCode() == 211) - havePion = true; - if (mcparticleDaughter.pdgCode() == -211) - haveAntiPion = true; - if (mcparticleDaughter.pdgCode() == bachelorPdgCode) - haveBachelor = true; - if (mcparticleDaughter.pdgCode() == -bachelorPdgCode) - haveAntiBachelor = true; - } - - // check if particle or anti-particle - if (haveProton && haveAntiPion && haveBachelor && mcparticle.pdgCode() > 0) { - isTrueGenH3L = true; - // get proton and pion daughter - std::array protonMom{0.f}; - std::array piMinusMom{0.f}; - for (auto& mcparticleDaughter : mcparticle.template daughters_as()) { - if (mcparticleDaughter.pdgCode() == 2212) { - protonMom = {mcparticleDaughter.px(), mcparticleDaughter.py(), mcparticleDaughter.pz()}; - genPPos = mcparticleDaughter.p(); - genPtPos = mcparticleDaughter.pt(); - } else if (mcparticleDaughter.pdgCode() == -211) { - piMinusMom = {mcparticleDaughter.px(), mcparticleDaughter.py(), mcparticleDaughter.pz()}; - genPNeg = mcparticleDaughter.p(); - genPtNeg = mcparticleDaughter.pt(); - } - } - genMCmassPrPi = RecoDecay::m(array{protonMom, piMinusMom}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); - registry.fill(HIST("hTrueHypertritonMCMassPrPi_nonReco"), genMCmassPrPi); - registry.fill(HIST("hTrueHypertritonMCPtProton_nonReco"), RecoDecay::sqrtSumOfSquares(protonMom[0], protonMom[1])); - registry.fill(HIST("hTrueHypertritonMCPtPion_nonReco"), RecoDecay::sqrtSumOfSquares(piMinusMom[0], piMinusMom[1])); - } else if (haveAntiProton && havePion && haveAntiBachelor && mcparticle.pdgCode() < 0) { - isTrueGenAntiH3L = true; - // get anti-proton and pion daughter - std::array antiProtonMom{0.f}; - std::array piPlusMom{0.f}; - for (auto& mcparticleDaughter : mcparticle.template daughters_as()) { - if (mcparticleDaughter.pdgCode() == -2212) { - antiProtonMom = {mcparticleDaughter.px(), mcparticleDaughter.py(), mcparticleDaughter.pz()}; - genPNeg = mcparticleDaughter.p(); - genPtNeg = mcparticleDaughter.pt(); - } else if (mcparticleDaughter.pdgCode() == 211) { - piPlusMom = {mcparticleDaughter.px(), mcparticleDaughter.py(), mcparticleDaughter.pz()}; - genPPos = mcparticleDaughter.p(); - genPtPos = mcparticleDaughter.pt(); - } - } - genMCmassPrPi = RecoDecay::m(array{antiProtonMom, piPlusMom}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); - registry.fill(HIST("hTrueAntiHypertritonMCMassPrPi_nonReco"), genMCmassPrPi); - registry.fill(HIST("hTrueAntiHypertritonMCPtProton_nonReco"), RecoDecay::sqrtSumOfSquares(antiProtonMom[0], antiProtonMom[1])); - registry.fill(HIST("hTrueAntiHypertritonMCPtPion_nonReco"), RecoDecay::sqrtSumOfSquares(piPlusMom[0], piPlusMom[1])); - } else { - continue; // stop if particle is no true H3L or Anti-H3L - } - - // get gen decay vertex and calculate ctau - std::array genDecayVtx{0.f}; - for (auto& mcDaughter : mcparticle.daughters_as()) { - if (std::abs(mcDaughter.pdgCode()) == bachelorPdgCode) { - genDecayVtx = {mcDaughter.vx(), mcDaughter.vy(), mcDaughter.vz()}; - genPBach = mcDaughter.p(); - genPtBach = mcDaughter.pt(); - } - } - double genMClifetime = RecoDecay::sqrtSumOfSquares(genDecayVtx[0] - mcparticle.vx(), genDecayVtx[1] - mcparticle.vy(), genDecayVtx[2] - mcparticle.vz()) * o2::constants::physics::MassHyperTriton / mcparticle.p(); - outputMCTable( // reco information (-1) - -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, -1, - -1, -1, -1, -1, - -1, - -1, -1, - -1, -1, - -1, -1, - -1, -1, -1, - -1, -1, - -1, - -1, -1, - -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, -1, - -1, -1, -1, - -1, - -1, - -1, - // gen information - mcparticle.p(), - mcparticle.pt(), - genDecayVtx[0], genDecayVtx[1], genDecayVtx[2], - genMClifetime, - mcparticle.phi(), - mcparticle.eta(), - mcparticle.y(), - genPPos, genPtPos, genPNeg, genPtNeg, genPBach, genPtBach, - isTrueGenH3L, isTrueGenAntiH3L, - mcparticle.pdgCode(), - false, // is reconstructed - survEvSel); - } // end mcparticles loop - } - PROCESS_SWITCH(threebodyKFTask, processMC, "MC analysis", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc), - }; -} diff --git a/PWGLF/TableProducer/Nuspex/threebodyRecoTask.cxx b/PWGLF/TableProducer/Nuspex/threebodyRecoTask.cxx deleted file mode 100644 index 624ab1efa1b..00000000000 --- a/PWGLF/TableProducer/Nuspex/threebodyRecoTask.cxx +++ /dev/null @@ -1,808 +0,0 @@ -// 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. -// -/// \file threebodyRecoTask.cxx -/// \brief Analysis task for 3-body decay process (now mainly for hypertriton) -/// \author Yuanzhe Wang - -#include -#include -#include -#include -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/Vtx3BodyTables.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "CommonConstants/PhysicsConstants.h" -#include "CCDB/BasicCCDBManager.h" - -#include "EventFiltering/Zorro.h" -#include "EventFiltering/ZorroSummary.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -using FullTracksExtIU = soa::Join; -using MCLabeledTracksIU = soa::Join; - -struct Candidate3body { - // Index - int mcmotherId; - int track0Id; - int track1Id; - int track2Id; - // sv and candidate - bool isMatter; - float invmass; - float ct; - float cosPA; - float dcadaughters; - float dcacandtopv; - float vtxradius; - // daughter tracks - TLorentzVector lcand; - TLorentzVector lproton; - TLorentzVector lpion; - TLorentzVector lbachelor; - uint8_t dautpcNclusters[3]; // 0 - proton, 1 - pion, 2 - bachelor - uint32_t dauitsclussize[3]; // 0 - proton, 1 - pion, 2 - bachelor - float daudcaxytopv[3]; // 0 - proton, 1 - pion, 2 - bachelor - float daudcatopv[3]; // 0 - proton, 1 - pion, 2 - bachelor - float dautpcNsigma[3]; // 0 - proton, 1 - pion, 2 - bachelor - float dauinnermostR[3]; // 0 - proton, 1 - pion, 2 - bachelor !!! TracksIU required !!! - float bachelortofNsigma; - // MC infomartion - TLorentzVector lgencand = {0, 0, 0, 0}; - float genct = -1; - float genrapidity = -999; - bool isSignal = false; - bool isReco = false; - int pdgCode = -1; - bool survivedEventSelection = false; -}; - -struct ThreebodyRecoTask { - - Produces outputDataTable; - Produces outputMCTable; - std::vector candidates3body; - std::vector filledMothers; - std::vector isGoodCollision; - - Service ccdb; - Zorro zorro; - OutputObj zorroSummary{"zorroSummary"}; - - //------------------------------------------------------------------ - Preslice perCollisionVtx3BodyDatas = o2::aod::vtx3body::collisionId; - - // Selection criteria - Configurable vtxcospa{"vtxcospa", 0.99, "Vtx CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0) - Configurable dcavtxdau{"dcavtxdau", 1.0, "DCA Vtx Daughters"}; // loose cut - Configurable dcapiontopv{"dcapiontopv", .05, "DCA Pion To PV"}; - Configurable etacut{"etacut", 0.9, "etacut"}; - Configurable rapiditycut{"rapiditycut", 1, "rapiditycut"}; - Configurable tofPIDNSigmaMin{"tofPIDNSigmaMin", -5, "tofPIDNSigmaMin"}; - Configurable tofPIDNSigmaMax{"tofPIDNSigmaMax", 5, "tofPIDNSigmaMax"}; - Configurable tpcPIDNSigmaCut{"tpcPIDNSigmaCut", 5, "tpcPIDNSigmaCut"}; - Configurable event_sel8_selection{"event_sel8_selection", true, "event selection count post sel8 cut"}; - Configurable mc_event_selection{"mc_event_selection", true, "mc event selection count post kIsTriggerTVX and kNoTimeFrameBorder"}; - Configurable event_posZ_selection{"event_posZ_selection", true, "event selection count post poZ cut"}; - Configurable lifetimecut{"lifetimecut", 40., "lifetimecut"}; // ct - Configurable minProtonPt{"minProtonPt", 0.3, "minProtonPt"}; - Configurable maxProtonPt{"maxProtonPt", 5, "maxProtonPt"}; - Configurable minPionPt{"minPionPt", 0.1, "minPionPt"}; - Configurable maxPionPt{"maxPionPt", 1.2, "maxPionPt"}; - Configurable minDeuteronPt{"minDeuteronPt", 0.6, "minDeuteronPt"}; - Configurable maxDeuteronPt{"maxDeuteronPt", 10, "maxDeuteronPt"}; - Configurable minDeuteronPUseTOF{"minDeuteronPUseTOF", 1, "minDeuteronPt Enable TOF PID"}; - Configurable h3LMassLowerlimit{"h3LMassLowerlimit", 2.96, "Hypertriton mass lower limit"}; - Configurable h3LMassUpperlimit{"h3LMassUpperlimit", 3.04, "Hypertriton mass upper limit"}; - Configurable mintpcNClsproton{"mintpcNClsproton", 90, "min tpc Nclusters for proton"}; - Configurable mintpcNClspion{"mintpcNClspion", 70, "min tpc Nclusters for pion"}; - Configurable mintpcNClsdeuteron{"mintpcNClsdeuteron", 100, "min tpc Nclusters for deuteron"}; - - Configurable mcsigma{"mcsigma", 0.0015, "sigma of mc invariant mass fit"}; // obtained from MC - Configurable bachelorPdgCode{"bachelorPdgCode", 1000010020, "pdgCode of bachelor daughter"}; - Configurable motherPdgCode{"motherPdgCode", 1010010030, "pdgCode of mother track"}; - - // 3sigma region for Dalitz plot - float lowersignallimit = o2::constants::physics::MassHyperTriton - 3 * mcsigma; - float uppersignallimit = o2::constants::physics::MassHyperTriton + 3 * mcsigma; - - // CCDB options - Configurable d_bz_input{"d_bz", -999, "bz field, -999 is automatic"}; - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - Configurable pidPath{"pidPath", "", "Path to the PID response object"}; - - // Zorro counting - Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "Skimmed dataset processing"}; - - HistogramRegistry registry{ - "registry", - { - {"hEventCounter", "hEventCounter", {HistType::kTH1F, {{5, 0.0f, 5.0f}}}}, - {"hCentFT0C", "hCentFT0C", {HistType::kTH1F, {{100, 0.0f, 100.0f, "FT0C Centrality"}}}}, - {"hCandidatesCounter", "hCandidatesCounter", {HistType::kTH1F, {{12, 0.0f, 12.0f}}}}, - {"hMassHypertriton", "hMassHypertriton", {HistType::kTH1F, {{80, 2.96f, 3.04f}}}}, - {"hMassAntiHypertriton", "hMassAntiHypertriton", {HistType::kTH1F, {{80, 2.96f, 3.04f}}}}, - {"hMassHypertritonTotal", "hMassHypertritonTotal", {HistType::kTH1F, {{300, 2.9f, 3.2f}}}}, - {"hTOFPIDDeuteron", "hTOFPIDDeuteron", {HistType::kTH1F, {{2000, -100.0f, 100.0f}}}}, - {"hProtonTPCBB", "hProtonTPCBB", {HistType::kTH2F, {{160, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hPionTPCBB", "hPionTPCBB", {HistType::kTH2F, {{160, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hDeuteronTPCBB", "hDeuteronTPCBB", {HistType::kTH2F, {{160, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hProtonTPCVsPt", "hProtonTPCVsPt", {HistType::kTH2F, {{50, 0.0f, 5.0f, "#it{p}_{T} (GeV/c)"}, {240, -6.0f, 6.0f, "TPC n#sigma"}}}}, - {"hPionTPCVsPt", "hPionTPCVsPt", {HistType::kTH2F, {{20, 0.0f, 2.0f, "#it{p}_{T} (GeV/c)"}, {240, -6.0f, 6.0f, "TPC n#sigma"}}}}, - {"hDeuteronTPCVsPt", "hDeuteronTPCVsPt", {HistType::kTH2F, {{80, 0.0f, 8.0f, "#it{p}_{T} (GeV/c)"}, {240, -6.0f, 6.0f, "TPC n#sigma"}}}}, - {"hDeuteronTOFVsPBeforeTOFCut", "hDeuteronTOFVsPBeforeTOFCut", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"hDeuteronTOFVsPAtferTOFCut", "hDeuteronTOFVsPAtferTOFCut", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - - {"hDalitz", "hDalitz", {HistType::kTH2F, {{120, 7.85, 8.45, "M^{2}(dp) (GeV^{2}/c^{4})"}, {60, 1.1, 1.4, "M^{2}(p#pi) (GeV^{2}/c^{4})"}}}}, - }, - }; - - //------------------------------------------------------------------ - // Fill stats histograms - enum Vtxstep { kCandAll = 0, - kCandDauEta, - kCandDauPt, - kCandTPCNcls, - kCandTPCPID, - kCandTOFPID, - kCandDcaToPV, - kCandRapidity, - kCandct, - kCandCosPA, - kCandDcaDau, - kCandInvMass, - kNCandSteps }; - - struct { - std::array candstats; - std::array truecandstats; - } statisticsRegistry; - - void resetHistos() - { - for (int ii = 0; ii < kNCandSteps; ii++) { - statisticsRegistry.candstats[ii] = 0; - statisticsRegistry.truecandstats[ii] = 0; - } - } - void fillCandCounter(int kn, bool istrue = false) - { - statisticsRegistry.candstats[kn]++; - if (istrue) { - statisticsRegistry.truecandstats[kn]++; - } - } - void fillHistos() - { - for (int ii = 0; ii < kNCandSteps; ii++) { - registry.fill(HIST("hCandidatesCounter"), ii, statisticsRegistry.candstats[ii]); - if (doprocessMC == true) { - registry.fill(HIST("hTrueHypertritonCounter"), ii, statisticsRegistry.truecandstats[ii]); - } - } - } - - int mRunNumber; - - void init(InitContext const&) - { - - zorroSummary.setObject(zorro.getZorroSummary()); - mRunNumber = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(1, "total"); - registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(2, "sel8"); - registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(3, "vertexZ"); - registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(4, "Zorro H3L 3body event"); - registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(5, "has Candidate"); - - // Check for selection criteria !!! TracksIU required !!! - registry.add("hDiffRVtxProton", "hDiffRVtxProton", HistType::kTH1F, {{100, -10, 10}}); // difference between the radius of decay vertex and minR of proton - registry.add("hDiffRVtxPion", "hDiffRVtxPion", HistType::kTH1F, {{100, -10, 10}}); // difference between the radius of decay vertex and minR of pion - registry.add("hDiffRVtxDeuteron", "hDiffRVtxDeuteron", HistType::kTH1F, {{100, -10, 10}}); // difference between the radius of decay vertex and minR of deuteron - registry.add("hDiffDaughterR", "hDiffDaughterR", HistType::kTH1F, {{10000, -100, 100}}); // difference between minR of pion&proton and R of deuteron(bachelor) - - if (doprocessDataLikeSign == true) { - registry.add("hCorrectMassHypertriton", "hCorrectMassHypertriton", HistType::kTH1F, {{80, 2.96f, 3.04f}}); // check if there are contamination of possible signals which are caused by unexpected PID - } - - if (doprocessMC == true) { - registry.add("hTrueHypertritonCounter", "hTrueHypertritonCounter", HistType::kTH1F, {{12, 0.0f, 12.0f}}); - auto hGeneratedHypertritonCounter = registry.add("hGeneratedHypertritonCounter", "hGeneratedHypertritonCounter", HistType::kTH1F, {{2, 0.0f, 2.0f}}); - hGeneratedHypertritonCounter->GetXaxis()->SetBinLabel(1, "Total"); - hGeneratedHypertritonCounter->GetXaxis()->SetBinLabel(2, "3-body decay"); - registry.add("hPtGeneratedHypertriton", "hPtGeneratedHypertriton", HistType::kTH1F, {{200, 0.0f, 10.0f}}); - registry.add("hctGeneratedHypertriton", "hctGeneratedHypertriton", HistType::kTH1F, {{50, 0, 50, "ct(cm)"}}); - registry.add("hEtaGeneratedHypertriton", "hEtaGeneratedHypertriton", HistType::kTH1F, {{40, -2.0f, 2.0f}}); - registry.add("hRapidityGeneratedHypertriton", "hRapidityGeneratedHypertriton", HistType::kTH1F, {{40, -2.0f, 2.0f}}); - registry.add("hPtGeneratedAntiHypertriton", "hPtGeneratedAntiHypertriton", HistType::kTH1F, {{200, 0.0f, 10.0f}}); - registry.add("hctGeneratedAntiHypertriton", "hctGeneratedAntiHypertriton", HistType::kTH1F, {{50, 0, 50, "ct(cm)"}}); - registry.add("hEtaGeneratedAntiHypertriton", "hEtaGeneratedAntiHypertriton", HistType::kTH1F, {{40, -2.0f, 2.0f}}); - registry.add("hRapidityGeneratedAntiHypertriton", "hRapidityGeneratedAntiHypertriton", HistType::kTH1F, {{40, -2.0f, 2.0f}}); - } - - TString candCounterbinLabel[kNCandSteps] = {"Total", "TrackEta", "DauPt", "TPCNcls", "TPCPID", "d TOFPID", "PionDcatoPV", "MomRapidity", "Lifetime", "VtxCosPA", "VtxDcaDau", "InvMass"}; - for (int i{0}; i < kNCandSteps; i++) { - registry.get(HIST("hCandidatesCounter"))->GetXaxis()->SetBinLabel(i + 1, candCounterbinLabel[i]); - if (doprocessMC == true) { - registry.get(HIST("hTrueHypertritonCounter"))->GetXaxis()->SetBinLabel(i + 1, candCounterbinLabel[i]); - } - } - } - - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) - { - if (mRunNumber == bc.runNumber()) { - return; - } - - if (cfgSkimmedProcessing) { - zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), "fH3L3Body"); - zorro.populateHistRegistry(registry, bc.runNumber()); - } - - mRunNumber = bc.runNumber(); - } - - //------------------------------------------------------------------ - // Check if the mcparticle is hypertriton which decays into 3 daughters - template - bool is3bodyDecayed(TMCParticle const& particle) - { - if (std::abs(particle.pdgCode()) != motherPdgCode) { - return false; - } - bool haveProton = false, havePion = false, haveBachelor = false; - bool haveAntiProton = false, haveAntiPion = false, haveAntiBachelor = false; - for (const auto& mcparticleDaughter : particle.template daughters_as()) { - if (mcparticleDaughter.pdgCode() == 2212) - haveProton = true; - if (mcparticleDaughter.pdgCode() == -2212) - haveAntiProton = true; - if (mcparticleDaughter.pdgCode() == 211) - havePion = true; - if (mcparticleDaughter.pdgCode() == -211) - haveAntiPion = true; - if (mcparticleDaughter.pdgCode() == bachelorPdgCode) - haveBachelor = true; - if (mcparticleDaughter.pdgCode() == -bachelorPdgCode) - haveAntiBachelor = true; - } - if (haveProton && haveAntiPion && haveBachelor && particle.pdgCode() > 0) { - return true; - } else if (haveAntiProton && havePion && haveAntiBachelor && particle.pdgCode() < 0) { - return true; - } - return false; - } - - //------------------------------------------------------------------ - // Fill candidate table - template - void fillCand(TCollisionTable const& collision, TCandTable const& candData, TTrackTable const& trackProton, TTrackTable const& trackPion, TTrackTable const& trackDeuteron, bool isMatter, bool isTrueCand = false, int lLabel = -1, TLorentzVector lmother = {0, 0, 0, 0}, double MClifetime = -1) - { - - double cospa = candData.vtxcosPA(collision.posX(), collision.posY(), collision.posZ()); - double ct = candData.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassHyperTriton; - - Candidate3body cand3body; - cand3body.isMatter = isMatter; - if (isMatter == true) { - cand3body.lproton.SetXYZM(candData.pxtrack0(), candData.pytrack0(), candData.pztrack0(), o2::constants::physics::MassProton); - cand3body.lpion.SetXYZM(candData.pxtrack1(), candData.pytrack1(), candData.pztrack1(), o2::constants::physics::MassPionCharged); - } else { - cand3body.lproton.SetXYZM(candData.pxtrack1(), candData.pytrack1(), candData.pztrack1(), o2::constants::physics::MassPionCharged); - cand3body.lpion.SetXYZM(candData.pxtrack0(), candData.pytrack0(), candData.pztrack0(), o2::constants::physics::MassProton); - } - - cand3body.mcmotherId = lLabel; - cand3body.track0Id = candData.track0Id(); - cand3body.track1Id = candData.track1Id(); - cand3body.track2Id = candData.track2Id(); - cand3body.invmass = cand3body.isMatter ? candData.mHypertriton() : candData.mAntiHypertriton(); - cand3body.lcand.SetXYZM(candData.px(), candData.py(), candData.pz(), o2::constants::physics::MassHyperTriton); - cand3body.ct = ct; - cand3body.cosPA = cospa; - cand3body.dcadaughters = candData.dcaVtxdaughters(); - cand3body.dcacandtopv = candData.dcavtxtopv(collision.posX(), collision.posY(), collision.posZ()); - cand3body.vtxradius = candData.vtxradius(); - cand3body.lbachelor.SetXYZM(candData.pxtrack2(), candData.pytrack2(), candData.pztrack2(), o2::constants::physics::MassDeuteron); - cand3body.dautpcNclusters[0] = trackProton.tpcNClsFound(); - cand3body.dautpcNclusters[1] = trackPion.tpcNClsFound(); - cand3body.dautpcNclusters[2] = trackDeuteron.tpcNClsFound(); - cand3body.dauitsclussize[0] = trackProton.itsClusterSizes(); - cand3body.dauitsclussize[1] = trackPion.itsClusterSizes(); - cand3body.dauitsclussize[2] = trackDeuteron.itsClusterSizes(); - cand3body.dautpcNsigma[0] = trackProton.tpcNSigmaPr(); - cand3body.dautpcNsigma[1] = trackPion.tpcNSigmaPi(); - cand3body.dautpcNsigma[2] = trackDeuteron.tpcNSigmaDe(); - cand3body.daudcaxytopv[0] = cand3body.isMatter ? candData.dcaXYtrack0topv() : candData.dcaXYtrack1topv(); - cand3body.daudcaxytopv[1] = cand3body.isMatter ? candData.dcaXYtrack1topv() : candData.dcaXYtrack0topv(); - cand3body.daudcaxytopv[2] = candData.dcaXYtrack2topv(); - cand3body.daudcatopv[0] = cand3body.isMatter ? candData.dcatrack0topv() : candData.dcatrack1topv(); - cand3body.daudcatopv[1] = cand3body.isMatter ? candData.dcatrack1topv() : candData.dcatrack0topv(); - cand3body.daudcatopv[2] = candData.dcatrack2topv(); - cand3body.dauinnermostR[0] = trackProton.x(); - cand3body.dauinnermostR[1] = trackPion.x(); - cand3body.dauinnermostR[2] = trackDeuteron.x(); - - cand3body.bachelortofNsigma = candData.tofNSigmaBachDe(); - if (isTrueCand) { - cand3body.mcmotherId = lLabel; - cand3body.lgencand = lmother; - cand3body.genct = MClifetime; - cand3body.genrapidity = lmother.Rapidity(); - cand3body.isSignal = true; - cand3body.isReco = true; - cand3body.pdgCode = cand3body.isMatter ? motherPdgCode : -motherPdgCode; - cand3body.survivedEventSelection = true; - filledMothers.push_back(lLabel); - } - - candidates3body.push_back(cand3body); - - registry.fill(HIST("hProtonTPCBB"), trackProton.sign() * trackProton.p(), trackProton.tpcSignal()); - registry.fill(HIST("hPionTPCBB"), trackPion.sign() * trackPion.p(), trackPion.tpcSignal()); - registry.fill(HIST("hDeuteronTPCBB"), trackDeuteron.sign() * trackDeuteron.p(), trackDeuteron.tpcSignal()); - registry.fill(HIST("hProtonTPCVsPt"), trackProton.pt(), trackProton.tpcNSigmaPr()); - registry.fill(HIST("hPionTPCVsPt"), trackProton.pt(), trackPion.tpcNSigmaPi()); - registry.fill(HIST("hDeuteronTPCVsPt"), trackDeuteron.pt(), trackDeuteron.tpcNSigmaDe()); - registry.fill(HIST("hTOFPIDDeuteron"), candData.tofNSigmaBachDe()); - registry.fill(HIST("hDiffRVtxProton"), trackProton.x() - candData.vtxradius()); - registry.fill(HIST("hDiffRVtxPion"), trackPion.x() - candData.vtxradius()); - registry.fill(HIST("hDiffRVtxDeuteron"), trackDeuteron.x() - candData.vtxradius()); - float diffTrackR = trackDeuteron.x() - std::min(trackProton.x(), trackPion.x()); - registry.fill(HIST("hDiffDaughterR"), diffTrackR); - } - - //------------------------------------------------------------------ - // Selections for candidates - template - bool selectCand(TCollisionTable const& collision, TCandTable const& candData, TTrackTable const& trackProton, TTrackTable const& trackPion, TTrackTable const& trackDeuteron, bool isMatter, bool isTrueCand = false) - { - fillCandCounter(kCandAll, isTrueCand); - - // Selection on daughters - if (std::abs(trackProton.eta()) > etacut || std::abs(trackPion.eta()) > etacut || std::abs(trackDeuteron.eta()) > etacut) { - return false; - } - fillCandCounter(kCandDauEta, isTrueCand); - - if (trackProton.pt() < minProtonPt || trackProton.pt() > maxProtonPt || trackPion.pt() < minPionPt || trackPion.pt() > maxPionPt || trackDeuteron.pt() < minDeuteronPt || trackDeuteron.pt() > maxDeuteronPt) { - return false; - } - fillCandCounter(kCandDauPt, isTrueCand); - - if (trackProton.tpcNClsFound() < mintpcNClsproton || trackPion.tpcNClsFound() < mintpcNClspion || trackDeuteron.tpcNClsFound() < mintpcNClsdeuteron) { - return false; - } - fillCandCounter(kCandTPCNcls, isTrueCand); - - if (std::abs(trackProton.tpcNSigmaPr()) > tpcPIDNSigmaCut || std::abs(trackPion.tpcNSigmaPi()) > tpcPIDNSigmaCut || std::abs(trackDeuteron.tpcNSigmaDe()) > tpcPIDNSigmaCut) { - return false; - } - fillCandCounter(kCandTPCPID, isTrueCand); - - registry.fill(HIST("hDeuteronTOFVsPBeforeTOFCut"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - if ((candData.tofNSigmaBachDe() < tofPIDNSigmaMin || candData.tofNSigmaBachDe() > tofPIDNSigmaMax) && trackDeuteron.p() > minDeuteronPUseTOF) { - return false; - } - fillCandCounter(kCandTOFPID, isTrueCand); - registry.fill(HIST("hDeuteronTOFVsPAtferTOFCut"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - - double dcapion = isMatter ? candData.dcatrack1topv() : candData.dcatrack0topv(); - if (std::abs(dcapion) < dcapiontopv) { - return false; - } - fillCandCounter(kCandDcaToPV, isTrueCand); - - // Selection on candidate hypertriton - if (std::abs(candData.yHypertriton()) > rapiditycut) { - return false; - } - fillCandCounter(kCandRapidity, isTrueCand); - - double ct = candData.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassHyperTriton; - if (ct > lifetimecut) { - return false; - } - fillCandCounter(kCandct, isTrueCand); - - double cospa = candData.vtxcosPA(collision.posX(), collision.posY(), collision.posZ()); - if (cospa < vtxcospa) { - return false; - } - fillCandCounter(kCandCosPA, isTrueCand); - - if (candData.dcaVtxdaughters() > dcavtxdau) { - return false; - } - fillCandCounter(kCandDcaDau, isTrueCand); - - if ((isMatter && candData.mHypertriton() > h3LMassLowerlimit && candData.mHypertriton() < h3LMassUpperlimit)) { - // Hypertriton - registry.fill(HIST("hMassHypertriton"), candData.mHypertriton()); - registry.fill(HIST("hMassHypertritonTotal"), candData.mHypertriton()); - if (candData.mHypertriton() > lowersignallimit && candData.mHypertriton() < uppersignallimit) { - registry.fill(HIST("hDalitz"), RecoDecay::m2(std::array{std::array{candData.pxtrack0(), candData.pytrack0(), candData.pztrack0()}, std::array{candData.pxtrack2(), candData.pytrack2(), candData.pztrack2()}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}), RecoDecay::m2(std::array{std::array{candData.pxtrack0(), candData.pytrack0(), candData.pztrack0()}, std::array{candData.pxtrack1(), candData.pytrack1(), candData.pztrack1()}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged})); - } - } else if ((!isMatter && candData.mAntiHypertriton() > h3LMassLowerlimit && candData.mAntiHypertriton() < h3LMassUpperlimit)) { - // AntiHypertriton - registry.fill(HIST("hMassAntiHypertriton"), candData.mAntiHypertriton()); - registry.fill(HIST("hMassHypertritonTotal"), candData.mAntiHypertriton()); - if (candData.mAntiHypertriton() > lowersignallimit && candData.mAntiHypertriton() < uppersignallimit) { - registry.fill(HIST("hDalitz"), RecoDecay::m2(std::array{std::array{candData.pxtrack1(), candData.pytrack1(), candData.pztrack1()}, std::array{candData.pxtrack2(), candData.pytrack2(), candData.pztrack2()}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}), RecoDecay::m2(std::array{std::array{candData.pxtrack1(), candData.pytrack1(), candData.pztrack1()}, std::array{candData.pxtrack0(), candData.pytrack0(), candData.pztrack0()}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged})); - } - } else { - return false; - } - fillCandCounter(kCandInvMass, isTrueCand); - - return true; - } - - //------------------------------------------------------------------ - // Analysis process for a single candidate - template - void candidateAnalysis(TCollisionTable const& collision, TCandTable const& candData, bool& if_hasvtx, bool isTrueCand = false, int lLabel = -1, TLorentzVector lmother = {0, 0, 0, 0}, double MClifetime = -1) - { - - auto track0 = candData.template track0_as(); - auto track1 = candData.template track1_as(); - auto track2 = candData.template track2_as(); - - bool isMatter = track2.sign() > 0; // true if the candidate is hypertriton (p pi- d) - - auto& trackProton = isMatter ? track0 : track1; - auto& trackPion = isMatter ? track1 : track0; - auto& trackDeuteron = track2; - - if (selectCand(collision, candData, trackProton, trackPion, trackDeuteron, isMatter, isTrueCand)) { - if_hasvtx = true; - fillCand(collision, candData, trackProton, trackPion, trackDeuteron, isMatter, isTrueCand, lLabel, lmother, MClifetime); - } - } - - //------------------------------------------------------------------ - // Analysis process for like-sign background : (p pi- anti-d) or (anti-p pi+ d) - template - void likeSignAnalysis(TCollisionTable const& collision, TCandTable const& candData, bool& if_hasvtx, bool isTrueCand = false, int lLabel = -1, TLorentzVector lmother = {0, 0, 0, 0}, double MClifetime = -1) - { - - auto track0 = candData.template track0_as(); - auto track1 = candData.template track1_as(); - auto track2 = candData.template track2_as(); - - bool isMatter = track2.sign() < 0; // true if seach for background consists of (p pi- anti-d) - - // Assume proton has an oppisite charge with deuteron - auto& trackProton = isMatter ? track0 : track1; - auto& trackPion = isMatter ? track1 : track0; - auto& trackDeuteron = track2; - - if (selectCand(collision, candData, trackProton, trackPion, trackDeuteron, isMatter, isTrueCand)) { - if_hasvtx = true; - fillCand(collision, candData, trackProton, trackPion, trackDeuteron, isMatter, isTrueCand, lLabel, lmother, MClifetime); - // QA for if signals have the possibility to be reconginzed as a like-sign background - if (isMatter) { - registry.fill(HIST("hCorrectMassHypertriton"), candData.mHypertriton()); - } else { - registry.fill(HIST("hCorrectMassHypertriton"), candData.mAntiHypertriton()); - } - } - } - - //------------------------------------------------------------------ - // collect information for generated hypertriton (should be called after event selection) - void getGeneratedH3LInfo(aod::McParticles const& particlesMC) - { - for (const auto& mcparticle : particlesMC) { - if (std::abs(mcparticle.pdgCode()) != motherPdgCode) { - continue; - } - registry.fill(HIST("hGeneratedHypertritonCounter"), 0.5); - - bool haveProton = false, havePionPlus = false, haveDeuteron = false; - bool haveAntiProton = false, havePionMinus = false, haveAntiDeuteron = false; - double MClifetime = -1; - for (const auto& mcparticleDaughter : mcparticle.template daughters_as()) { - if (mcparticleDaughter.pdgCode() == 2212) - haveProton = true; - if (mcparticleDaughter.pdgCode() == -2212) - haveAntiProton = true; - if (mcparticleDaughter.pdgCode() == 211) - havePionPlus = true; - if (mcparticleDaughter.pdgCode() == -211) - havePionMinus = true; - if (mcparticleDaughter.pdgCode() == bachelorPdgCode) { - haveDeuteron = true; - MClifetime = RecoDecay::sqrtSumOfSquares(mcparticleDaughter.vx() - mcparticle.vx(), mcparticleDaughter.vy() - mcparticle.vy(), mcparticleDaughter.vz() - mcparticle.vz()) * o2::constants::physics::MassHyperTriton / mcparticle.p(); - } - if (mcparticleDaughter.pdgCode() == -bachelorPdgCode) { - haveAntiDeuteron = true; - MClifetime = RecoDecay::sqrtSumOfSquares(mcparticleDaughter.vx() - mcparticle.vx(), mcparticleDaughter.vy() - mcparticle.vy(), mcparticleDaughter.vz() - mcparticle.vz()) * o2::constants::physics::MassHyperTriton / mcparticle.p(); - } - } - if (haveProton && havePionMinus && haveDeuteron && mcparticle.pdgCode() == motherPdgCode) { - registry.fill(HIST("hGeneratedHypertritonCounter"), 1.5); - registry.fill(HIST("hPtGeneratedHypertriton"), mcparticle.pt()); - registry.fill(HIST("hctGeneratedHypertriton"), MClifetime); - registry.fill(HIST("hEtaGeneratedHypertriton"), mcparticle.eta()); - registry.fill(HIST("hRapidityGeneratedHypertriton"), mcparticle.y()); - } else if (haveAntiProton && havePionPlus && haveAntiDeuteron && mcparticle.pdgCode() == -motherPdgCode) { - registry.fill(HIST("hGeneratedHypertritonCounter"), 1.5); - registry.fill(HIST("hPtGeneratedAntiHypertriton"), mcparticle.pt()); - registry.fill(HIST("hctGeneratedAntiHypertriton"), MClifetime); - registry.fill(HIST("hEtaGeneratedAntiHypertriton"), mcparticle.eta()); - registry.fill(HIST("hRapidityGeneratedAntiHypertriton"), mcparticle.y()); - } - } - } - - //------------------------------------------------------------------ - // process real data analysis - void processData(soa::Join const& collisions, aod::Vtx3BodyDatas const& vtx3bodydatas, FullTracksExtIU const&, aod::BCsWithTimestamps const&) - { - for (const auto& collision : collisions) { - candidates3body.clear(); - - auto bc = collision.bc_as(); - initCCDB(bc); - registry.fill(HIST("hEventCounter"), 0.5); - if (event_sel8_selection && !collision.sel8()) { - continue; - } - registry.fill(HIST("hEventCounter"), 1.5); - if (event_posZ_selection && std::abs(collision.posZ()) > 10.f) { // 10cm - continue; - } - registry.fill(HIST("hEventCounter"), 2.5); - registry.fill(HIST("hCentFT0C"), collision.centFT0C()); - - if (cfgSkimmedProcessing) { - bool zorroSelected = zorro.isSelected(collision.bc_as().globalBC()); /// Just let Zorro do the accounting - if (zorroSelected) { - registry.fill(HIST("hEventCounter"), 3.5); - } - } - - bool if_hasvtx = false; - auto d3bodyCands = vtx3bodydatas.sliceBy(perCollisionVtx3BodyDatas, collision.globalIndex()); - for (const auto& vtx : d3bodyCands) { - candidateAnalysis(collision, vtx, if_hasvtx); - } - if (if_hasvtx) - registry.fill(HIST("hEventCounter"), 4.5); - fillHistos(); - resetHistos(); - - for (const auto& cand3body : candidates3body) { - outputDataTable(collision.centFT0C(), - cand3body.isMatter, cand3body.invmass, cand3body.lcand.P(), cand3body.lcand.Pt(), cand3body.ct, - cand3body.cosPA, cand3body.dcadaughters, cand3body.dcacandtopv, cand3body.vtxradius, - cand3body.lproton.Pt(), cand3body.lproton.Eta(), cand3body.lproton.Phi(), cand3body.dauinnermostR[0], - cand3body.lpion.Pt(), cand3body.lpion.Eta(), cand3body.lpion.Phi(), cand3body.dauinnermostR[1], - cand3body.lbachelor.Pt(), cand3body.lbachelor.Eta(), cand3body.lbachelor.Phi(), cand3body.dauinnermostR[2], - cand3body.dautpcNclusters[0], cand3body.dautpcNclusters[1], cand3body.dautpcNclusters[2], - cand3body.dauitsclussize[0], cand3body.dauitsclussize[1], cand3body.dauitsclussize[2], - cand3body.dautpcNsigma[0], cand3body.dautpcNsigma[1], cand3body.dautpcNsigma[2], cand3body.bachelortofNsigma, - cand3body.daudcaxytopv[0], cand3body.daudcaxytopv[1], cand3body.daudcaxytopv[2], - cand3body.daudcatopv[0], cand3body.daudcatopv[1], cand3body.daudcatopv[2]); - } - } - } - PROCESS_SWITCH(ThreebodyRecoTask, processData, "Real data reconstruction", true); - - //------------------------------------------------------------------ - // process like-sign signal - void processDataLikeSign(soa::Join const& collisions, aod::Vtx3BodyDatas const& vtx3bodydatas, FullTracksExtIU const& /*tracks*/) - { - for (const auto& collision : collisions) { - candidates3body.clear(); - registry.fill(HIST("hEventCounter"), 0.5); - if (event_sel8_selection && !collision.sel8()) { - continue; - } - registry.fill(HIST("hEventCounter"), 1.5); - if (event_posZ_selection && std::abs(collision.posZ()) > 10.f) { // 10cm - continue; - } - registry.fill(HIST("hEventCounter"), 2.5); - registry.fill(HIST("hCentFT0C"), collision.centFT0C()); - - if (cfgSkimmedProcessing) { - bool zorroSelected = zorro.isSelected(collision.bc_as().globalBC()); /// Just let Zorro do the accounting - if (zorroSelected) { - registry.fill(HIST("hEventCounter"), 3.5); - } - } - - bool if_hasvtx = false; - auto d3bodyCands = vtx3bodydatas.sliceBy(perCollisionVtx3BodyDatas, collision.globalIndex()); - for (const auto& vtx : d3bodyCands) { - likeSignAnalysis(collision, vtx, if_hasvtx); - } - if (if_hasvtx) - registry.fill(HIST("hEventCounter"), 4.5); - fillHistos(); - resetHistos(); - - for (const auto& cand3body : candidates3body) { - outputDataTable(collision.centFT0C(), - cand3body.isMatter, cand3body.invmass, cand3body.lcand.P(), cand3body.lcand.Pt(), cand3body.ct, - cand3body.cosPA, cand3body.dcadaughters, cand3body.dcacandtopv, cand3body.vtxradius, - cand3body.lproton.Pt(), cand3body.lproton.Eta(), cand3body.lproton.Phi(), cand3body.dauinnermostR[0], - cand3body.lpion.Pt(), cand3body.lpion.Eta(), cand3body.lpion.Phi(), cand3body.dauinnermostR[1], - cand3body.lbachelor.Pt(), cand3body.lbachelor.Eta(), cand3body.lbachelor.Phi(), cand3body.dauinnermostR[2], - cand3body.dautpcNclusters[0], cand3body.dautpcNclusters[1], cand3body.dautpcNclusters[2], - cand3body.dauitsclussize[0], cand3body.dauitsclussize[1], cand3body.dauitsclussize[2], - cand3body.dautpcNsigma[0], cand3body.dautpcNsigma[1], cand3body.dautpcNsigma[2], cand3body.bachelortofNsigma, - cand3body.daudcaxytopv[0], cand3body.daudcaxytopv[1], cand3body.daudcaxytopv[2], - cand3body.daudcatopv[0], cand3body.daudcatopv[1], cand3body.daudcatopv[2]); - } - } - } - PROCESS_SWITCH(ThreebodyRecoTask, processDataLikeSign, "Like-sign signal reconstruction", false); - - //------------------------------------------------------------------ - // process mc analysis - void processMC(soa::Join const& collisions, aod::Vtx3BodyDatas const& vtx3bodydatas, aod::McParticles const& particlesMC, MCLabeledTracksIU const& /*tracks*/, aod::McCollisions const& mcCollisions) - { - filledMothers.clear(); - getGeneratedH3LInfo(particlesMC); - isGoodCollision.resize(mcCollisions.size(), false); - - for (const auto& collision : collisions) { - candidates3body.clear(); - registry.fill(HIST("hEventCounter"), 0.5); - if (mc_event_selection && (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { - continue; - } - registry.fill(HIST("hEventCounter"), 1.5); - if (event_posZ_selection && std::abs(collision.posZ()) > 10.f) { // 10cm - continue; - } - registry.fill(HIST("hEventCounter"), 2.5); - registry.fill(HIST("hCentFT0C"), collision.centFT0C()); - - if (collision.mcCollisionId() >= 0) { - isGoodCollision[collision.mcCollisionId()] = true; - } - - bool if_hasvtx = false; - auto vtxsthiscol = vtx3bodydatas.sliceBy(perCollisionVtx3BodyDatas, collision.globalIndex()); - - for (const auto& vtx : vtxsthiscol) { - int lLabel = -1; - int lPDG = -1; - double MClifetime = -1; - TLorentzVector lmother; - bool isTrueCand = false; - auto track0 = vtx.track0_as(); - auto track1 = vtx.track1_as(); - auto track2 = vtx.track2_as(); - if (track0.has_mcParticle() && track1.has_mcParticle() && track2.has_mcParticle()) { - auto lMCTrack0 = track0.mcParticle_as(); - auto lMCTrack1 = track1.mcParticle_as(); - auto lMCTrack2 = track2.mcParticle_as(); - if (lMCTrack0.has_mothers() && lMCTrack1.has_mothers() && lMCTrack2.has_mothers()) { - for (const auto& lMother0 : lMCTrack0.mothers_as()) { - for (const auto& lMother1 : lMCTrack1.mothers_as()) { - for (const auto& lMother2 : lMCTrack2.mothers_as()) { - if (lMother0.globalIndex() == lMother1.globalIndex() && lMother0.globalIndex() == lMother2.globalIndex()) { - lLabel = lMother0.globalIndex(); - lPDG = lMother0.pdgCode(); - if ((lPDG == motherPdgCode && lMCTrack0.pdgCode() == 2212 && lMCTrack1.pdgCode() == -211 && lMCTrack2.pdgCode() == bachelorPdgCode) || - (lPDG == -motherPdgCode && lMCTrack0.pdgCode() == 211 && lMCTrack1.pdgCode() == -2212 && lMCTrack2.pdgCode() == -bachelorPdgCode)) { - isTrueCand = true; - MClifetime = RecoDecay::sqrtSumOfSquares(lMCTrack2.vx() - lMother2.vx(), lMCTrack2.vy() - lMother2.vy(), lMCTrack2.vz() - lMother2.vz()) * o2::constants::physics::MassHyperTriton / lMother2.p(); - lmother.SetXYZM(lMother0.px(), lMother0.py(), lMother0.pz(), o2::constants::physics::MassHyperTriton); - } - } - } - } - } - } - } - - candidateAnalysis(collision, vtx, if_hasvtx, isTrueCand, lLabel, lmother, MClifetime); - } - - if (if_hasvtx) - registry.fill(HIST("hEventCounter"), 4.5); - fillHistos(); - resetHistos(); - - for (const auto& cand3body : candidates3body) { - outputMCTable(collision.centFT0C(), - cand3body.isMatter, cand3body.invmass, cand3body.lcand.P(), cand3body.lcand.Pt(), cand3body.ct, - cand3body.cosPA, cand3body.dcadaughters, cand3body.dcacandtopv, cand3body.vtxradius, - cand3body.lproton.Pt(), cand3body.lproton.Eta(), cand3body.lproton.Phi(), cand3body.dauinnermostR[0], - cand3body.lpion.Pt(), cand3body.lpion.Eta(), cand3body.lpion.Phi(), cand3body.dauinnermostR[1], - cand3body.lbachelor.Pt(), cand3body.lbachelor.Eta(), cand3body.lbachelor.Phi(), cand3body.dauinnermostR[2], - cand3body.dautpcNclusters[0], cand3body.dautpcNclusters[1], cand3body.dautpcNclusters[2], - cand3body.dauitsclussize[0], cand3body.dauitsclussize[1], cand3body.dauitsclussize[2], - cand3body.dautpcNsigma[0], cand3body.dautpcNsigma[1], cand3body.dautpcNsigma[2], cand3body.bachelortofNsigma, - cand3body.daudcaxytopv[0], cand3body.daudcaxytopv[1], cand3body.daudcaxytopv[2], - cand3body.daudcatopv[0], cand3body.daudcatopv[1], cand3body.daudcatopv[2], - cand3body.lgencand.P(), cand3body.lgencand.Pt(), cand3body.genct, cand3body.lgencand.Phi(), cand3body.lgencand.Eta(), cand3body.lgencand.Rapidity(), - cand3body.isSignal, cand3body.isReco, cand3body.pdgCode, cand3body.survivedEventSelection); - } - } - - // now we fill only the signal candidates that were not reconstructed - for (const auto& mcparticle : particlesMC) { - if (!is3bodyDecayed(mcparticle)) { - continue; - } - if (std::find(filledMothers.begin(), filledMothers.end(), mcparticle.globalIndex()) != std::end(filledMothers)) { - continue; - } - bool isSurEvSelection = isGoodCollision[mcparticle.mcCollisionId()]; - std::array posSV{0.f}; - for (const auto& mcDaughter : mcparticle.daughters_as()) { - if (std::abs(mcDaughter.pdgCode()) == bachelorPdgCode) { - posSV = {mcDaughter.vx(), mcDaughter.vy(), mcDaughter.vz()}; - } - } - double MClifetime = RecoDecay::sqrtSumOfSquares(posSV[0] - mcparticle.vx(), posSV[1] - mcparticle.vy(), posSV[2] - mcparticle.vz()) * o2::constants::physics::MassHyperTriton / mcparticle.p(); - outputMCTable(-1, - -1, -1, -1, -1, -1, - -1, -1, -1, -1, - -1, -1, -1, -1, - -1, -1, -1, -1, - -1, -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - mcparticle.p(), mcparticle.pt(), MClifetime, mcparticle.phi(), mcparticle.eta(), mcparticle.y(), - true, false, mcparticle.pdgCode(), isSurEvSelection); - } - } - PROCESS_SWITCH(ThreebodyRecoTask, processMC, "MC reconstruction", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc), - }; -} diff --git a/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx b/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx new file mode 100644 index 00000000000..7fe17c42d4a --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx @@ -0,0 +1,766 @@ +// 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. + +/// +/// \file trHeAnalysis.cxx +/// +/// \brief Triton and Helion Analysis on pp Data +/// +/// \author Matthias Herzer , Goethe University Frankfurt +/// +#include "PWGLF/DataModel/LFNucleiTables.h" +#include "PWGLF/DataModel/LFPIDTOFGenericTables.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "PWGLF/Utils/pidTOFGeneric.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/PID.h" +#include "ReconstructionDataFormats/Track.h" + +#include + +#include +#include + +namespace o2::aod +{ +namespace h3_data +{ +DECLARE_SOA_COLUMN(TPt, tPt, float); +DECLARE_SOA_COLUMN(TEta, tEta, float); +DECLARE_SOA_COLUMN(TPhi, tPhi, float); +DECLARE_SOA_COLUMN(TCharge, tCharge, int8_t); +DECLARE_SOA_COLUMN(TP, tP, float); +DECLARE_SOA_COLUMN(TH3DeDx, tH3DeDx, float); +DECLARE_SOA_COLUMN(TnSigmaTpc, tnSigmaTpc, float); +DECLARE_SOA_COLUMN(TTofSignalH3, tTofSignalH3, float); +DECLARE_SOA_COLUMN(TDcaXY, tDcaXY, float); +DECLARE_SOA_COLUMN(TDcaZ, tDcaZ, float); +DECLARE_SOA_COLUMN(TSigmaYX, tSigmaYX, float); +DECLARE_SOA_COLUMN(TSigmaXYZ, tSigmaXYZ, float); +DECLARE_SOA_COLUMN(TSigmaZ, tSigmaZ, float); +DECLARE_SOA_COLUMN(TnTpcCluster, tnTpcCluster, int); +DECLARE_SOA_COLUMN(TnItsCluster, tnItsCluster, int); +DECLARE_SOA_COLUMN(TTpcChi2NCl, tTpcChi2NCl, float); +DECLARE_SOA_COLUMN(TItsChi2NCl, tItsChi2NCl, float); +DECLARE_SOA_COLUMN(TRigidity, tRigidity, float); +DECLARE_SOA_COLUMN(TItsClusterSize, tItsClusterSize, float); +DECLARE_SOA_COLUMN(THasTof, tHasTof, bool); +DECLARE_SOA_COLUMN(TDetectorMap, tDetectorMap, int8_t); +} // namespace h3_data +DECLARE_SOA_TABLE(H3Data, "AOD", "h3_data", h3_data::TPt, h3_data::TEta, + h3_data::TPhi, h3_data::TCharge, h3_data::TH3DeDx, + h3_data::TnSigmaTpc, h3_data::TTofSignalH3, h3_data::TDcaXY, + h3_data::TDcaZ, h3_data::TSigmaYX, h3_data::TSigmaXYZ, + h3_data::TSigmaZ, h3_data::TnTpcCluster, + h3_data::TnItsCluster, h3_data::TTpcChi2NCl, + h3_data::TItsChi2NCl, h3_data::TRigidity, + h3_data::TItsClusterSize, h3_data::THasTof, h3_data::TDetectorMap); +namespace he_data +{ +DECLARE_SOA_COLUMN(TPt, tPt, float); +DECLARE_SOA_COLUMN(TEta, tEta, float); +DECLARE_SOA_COLUMN(TPhi, tPhi, float); +DECLARE_SOA_COLUMN(TCharge, tCharge, int8_t); +DECLARE_SOA_COLUMN(TP, tP, float); +DECLARE_SOA_COLUMN(THeDeDx, tHeDeDx, float); +DECLARE_SOA_COLUMN(TnSigmaTpc, tnSigmaTpc, float); +DECLARE_SOA_COLUMN(TTofSignalHe, tTofSignalHe, float); +DECLARE_SOA_COLUMN(TDcaXY, tDcaXY, float); +DECLARE_SOA_COLUMN(TDcaZ, tDcaZ, float); +DECLARE_SOA_COLUMN(TSigmaYX, tSigmaYX, float); +DECLARE_SOA_COLUMN(TSigmaXYZ, tSigmaXYZ, float); +DECLARE_SOA_COLUMN(TSigmaZ, tSigmaZ, float); +DECLARE_SOA_COLUMN(TnTpcCluster, tnTpcCluster, int); +DECLARE_SOA_COLUMN(TnItsCluster, tnItsCluster, int); +DECLARE_SOA_COLUMN(TTpcChi2NCl, tTpcChi2NCl, float); +DECLARE_SOA_COLUMN(TItsChi2NCl, tItsChi2NCl, float); +DECLARE_SOA_COLUMN(TRigidity, tRigidity, float); +DECLARE_SOA_COLUMN(TItsClusterSize, tItsClusterSize, float); +DECLARE_SOA_COLUMN(THasTof, tHasTof, bool); +DECLARE_SOA_COLUMN(TDetectorMap, tDetectorMap, int8_t); +} // namespace he_data +DECLARE_SOA_TABLE(HeData, "AOD", "he_data", he_data::TPt, he_data::TEta, + he_data::TPhi, he_data::TCharge, he_data::THeDeDx, + he_data::TnSigmaTpc, he_data::TTofSignalHe, he_data::TDcaXY, + he_data::TDcaZ, he_data::TSigmaYX, he_data::TSigmaXYZ, + he_data::TSigmaZ, he_data::TnTpcCluster, + he_data::TnItsCluster, he_data::TTpcChi2NCl, + he_data::TItsChi2NCl, he_data::TRigidity, + he_data::TItsClusterSize, he_data::THasTof, he_data::TDetectorMap); +} // namespace o2::aod +namespace +{ +const int nBetheParams = 6; +const int nParticles = 2; +static const std::vector particleNames{"triton", "helion"}; +static const std::vector particlePdgCodes{ + o2::constants::physics::kTriton, o2::constants::physics::kHelium3}; +static const std::vector particleMasses{ + o2::constants::physics::MassTriton, o2::constants::physics::MassHelium3}; +static const std::vector particleCharge{1, 2}; +static const std::vector particleChargeFactor{2.3, 2.55}; +static const std::vector betheBlochParNames{ + "p0", "p1", "p2", "p3", "p4", "resolution"}; +constexpr float BetheBlochDefault[nParticles][nBetheParams]{ + {0.248753, 3.58634, 0.0167065, 2.29194, 0.774344, + 0.07}, // triton + {0.0274556, 18.3054, 3.99987e-05, 3.17219, 11.1775, + 0.07}}; // Helion +} // namespace +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using TracksFull = + soa::Join; + +class Particle +{ + public: + TString name; + int pdgCode; + float mass; + int charge; + float resolution; + float chargeFactor; + std::vector betheParams; + static constexpr int NNumBetheParams = 5; + + Particle(const std::string name_, int pdgCode_, float mass_, int charge_, + LabeledArray bethe, float chargeFactor_) + { + name = TString(name_); + pdgCode = pdgCode_; + mass = mass_; + charge = charge_; + chargeFactor = chargeFactor_; + + resolution = + bethe.get(name, "resolution"); // Access the "resolution" parameter + + betheParams.clear(); + for (int i = 0; i < NNumBetheParams; ++i) { + betheParams.push_back(bethe.get(name, i)); + } + } +}; + +struct TrHeAnalysis { + Produces h3Data; + Produces heData; + HistogramRegistry histos{ + "Histos", + {}, + OutputObjHandlingPolicy::AnalysisObject}; + std::vector particles; + Configurable enableTr{"enableTr", true, "Flag to enable triton analysis."}; + Configurable enableHe{"enableHe", true, "Flag to enable helium-3 analysis."}; + Configurable cfgRigidityCorrection{"cfgRigidityCorrection", true, "Enable Rigidity correction"}; + ConfigurableAxis binsDeDx{"binsDeDx", {600, 0.f, 3000.f}, ""}; + ConfigurableAxis binsBeta{"binsBeta", {120, 0.0, 1.2}, ""}; + ConfigurableAxis binsDca{"binsDca", {400, -1.f, 1.f}, ""}; + ConfigurableAxis binsSigmaTpc{"binsSigmaTpc", {1000, -100, 100}, ""}; + ConfigurableAxis binsSigmaTof{"binsSigmaTof", {1000, -100, 100}, ""}; + ConfigurableAxis binsMassTr{"binsMassTr", {250, -2.5, 2.5f}, ""}; + ConfigurableAxis binsMassHe{"binsMassHe", {300, -3., 3.f}, ""}; + // Set the event selection cuts + struct : ConfigurableGroup { + Configurable useSel8{"useSel8", true, "Use Sel8 for run3 Event Selection"}; + Configurable tvxTrigger{"tvxTrigger", false, "Use TVX for Event Selection (default w/ Sel8)"}; + Configurable removeTfBorder{"removeTfBorder", false, "Remove TimeFrame border (default w/ Sel8)"}; + Configurable removeItsRofBorder{"removeItsRofBorder", false, "Remove ITS Read-Out Frame border (default w/ Sel8)"}; + } evselOptions; + + Configurable cfgTPCPidMethod{"cfgTPCPidMethod", false, "Using own or built in bethe parametrization"}; // false for built in + Configurable cfgMassMethod{"cfgMassMethod", 0, "0: Using built in 1: mass calculated with beta 2: mass calculated with the event time"}; + Configurable cfgEnableItsClusterSizeCut{"cfgEnableItsClusterSizeCut", false, "Enable ITS cluster size cut"}; + Configurable cfgEnableTofMassCut{"cfgEnableTofMassCut", false, "Enable TOF mass cut"}; + Configurable cfgTofMassCutPt{"cfgTofMassCutPt", 1.6f, "Pt value for which the TOF-cut starts to be used"}; + // Set the multiplity event limits + Configurable cfgLowMultCut{"cfgLowMultCut", 0.0f, "Accepted multiplicity percentage lower limit"}; + Configurable cfgHighMultCut{"cfgHighMultCut", 100.0f, "Accepted multiplicity percentage higher limit"}; + + // Set the z-vertex event cut limits + Configurable cfgHighCutVertex{"cfgHighCutVertex", 10.0f, "Accepted z-vertex upper limit"}; + Configurable cfgLowCutVertex{"cfgLowCutVertex", -10.0f, "Accepted z-vertex lower limit"}; + + // Set the quality cuts for tracks + Configurable rejectFakeTracks{"rejectFakeTracks", false, "Flag to reject ITS-TPC fake tracks (for MC)"}; + Configurable cfgCutItsClusters{"cfgCutItsClusters", -1.f, "Minimum number of ITS clusters"}; + Configurable cfgCutTpcXRows{"cfgCutTpcXRows", -1.f, "Minimum number of crossed TPC rows"}; + Configurable cfgCutTpcClusters{"cfgCutTpcClusters", 40.f, "Minimum number of found TPC clusters"}; + Configurable nItsLayer{"nItsLayer", 0, "ITS Layer (0-6)"}; + Configurable cfgCutTpcCrRowToFindableCl{"cfgCutTpcCrRowToFindableCl", 0.8f, "Minimum ratio of crossed rows to findable cluster in TPC"}; + Configurable cfgCutMaxChi2TpcH3{"cfgCutMaxChi2TpcH3", 4.f, "Maximum chi2 per cluster for TPC"}; + Configurable cfgCutMaxChi2ItsH3{"cfgCutMaxChi2ItsH3", 36.f, "Maximum chi2 per cluster for ITS"}; + Configurable cfgCutMaxChi2TpcHe{"cfgCutMaxChi2TpcHe", 4.f, "Maximum chi2 per cluster for TPC"}; + Configurable cfgCutMaxChi2ItsHe{"cfgCutMaxChi2ItsHe", 36.f, "Maximum chi2 per cluster for ITS"}; + Configurable cfgCutTpcRefit{"cfgCutTpcRefit", 1, "TPC refit "}; + Configurable cfgCutItsRefit{"cfgCutItsRefit", 1, "ITS refit"}; + Configurable cfgCutMaxItsClusterSizeHe{"cfgCutMaxItsClusterSizeHe", 4.f, "Maximum ITS Cluster Size for He "}; + Configurable cfgCutMinItsClusterSizeHe{"cfgCutMinItsClusterSizeHe", 1.f, "Minimum ITS Cluster Size for He"}; + Configurable cfgCutMaxItsClusterSizeH3{"cfgCutMaxItsClusterSizeH3", 4.f, "Maximum ITS Cluster Size for Tr"}; + Configurable cfgCutMinItsClusterSizeH3{"cfgCutMinItsClusterSizeH3", 1.f, "Minimum ITS Cluster Size for Tr"}; + Configurable cfgCutMinTofMassH3{"cfgCutMinTofMassH3", 5.f, "Minimum Tof mass H3"}; + Configurable cfgCutMaxTofMassH3{"cfgCutMaxTofMassH3", 11.f, "Maximum TOF mass H3"}; + Configurable cfgMaxRigidity{"cfgMaxRigidity", 10.f, "Maximum rigidity value"}; + Configurable cfgMaxPt{"cfgMaxPt", 10.f, "Maximum pT value"}; + + // Set the kinematic and PID cuts for tracks + struct : ConfigurableGroup { + Configurable pCut{"pCut", 0.6f, "Value of the p selection for spectra (default 0.3)"}; + Configurable etaCut{"etaCut", 0.8f, "Value of the eta selection for spectra (default 0.8)"}; + Configurable yLowCut{"yLowCut", -1.0f, "Value of the low rapidity selection for spectra (default -1.0)"}; + Configurable yHighCut{"yHighCut", 1.0f, "Value of the high rapidity selection for spectra (default 1.0)"}; + } kinemOptions; + + struct : ConfigurableGroup { + Configurable nsigmaTPCTr{"nsigmaTPCTr", 5.f, "Value of the Nsigma TPC cut for tritons"}; + Configurable nsigmaTPCHe{"nsigmaTPCHe", 5.f, "Value of the Nsigma TPC cut for helium-3"}; + } nsigmaTPCvar; + Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {BetheBlochDefault[0], nParticles, nBetheParams, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for light nuclei"}; + + void init(o2::framework::InitContext&) + { + const AxisSpec dedxAxis{binsDeDx, "d#it{E}/d#it{x} A.U."}; + const AxisSpec betaAxis{binsBeta, "TOF #beta"}; + const AxisSpec dcaxyAxis{binsDca, "DCAxy (cm)"}; + const AxisSpec dcazAxis{binsDca, "DCAz (cm)"}; + const AxisSpec massTrAxis{binsMassTr, ""}; + const AxisSpec massHeAxis{binsMassHe, ""}; + const AxisSpec sigmaTPCAxis{binsSigmaTpc, ""}; + const AxisSpec sigmaTOFAxis{binsSigmaTof, ""}; + + histos.add("histogram/pT", + "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", + HistType::kTH1F, {{500, 0., 10.}}); + histos.add("histogram/p", "Track momentum; p (GeV/#it{c}); counts", + HistType::kTH1F, {{500, 0., 10.}}); + histos.add("histogram/TPCsignVsTPCmomentum", + "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC " + "<-dE/dx> (a.u.)", + HistType::kTH2F, {{400, -8.f, 8.f}, {dedxAxis}}); + histos.add( + "histogram/TOFbetaVsP", + "TOF #beta vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TOF #beta", + HistType::kTH2F, {{250, -5.f, 5.f}, {betaAxis}}); + histos.add("histogram/H3/H3-TPCsignVsTPCmomentum", + "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC " + "<-dE/dx> (a.u.)", + HistType::kTH2F, {{400, -8.f, 8.f}, {dedxAxis}}); + histos.add( + "histogram/H3/H3-TOFbetaVsP", + "TOF #beta vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TOF #beta", + HistType::kTH2F, {{250, -5.f, 5.f}, {betaAxis}}); + histos.add("histogram/He/He-TPCsignVsTPCmomentum", + "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC " + "<-dE/dx> (a.u.)", + HistType::kTH2F, {{400, -8.f, 8.f}, {dedxAxis}}); + histos.add( + "histogram/He/He-TOFbetaVsP", + "TOF #beta vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TOF #beta", + HistType::kTH2F, {{250, -5.f, 5.f}, {betaAxis}}); + histos.add("event/eventSelection", "eventSelection", HistType::kTH1D, + {{7, -0.5, 6.5}}); + auto h = histos.get(HIST("event/eventSelection")); + h->GetXaxis()->SetBinLabel(1, "Total"); + h->GetXaxis()->SetBinLabel(2, "TVX trigger cut"); + h->GetXaxis()->SetBinLabel(3, "TF border cut"); + h->GetXaxis()->SetBinLabel(4, "ITS ROF cut"); + h->GetXaxis()->SetBinLabel(5, "TVX + TF + ITS ROF"); + h->GetXaxis()->SetBinLabel(6, "Sel8 cut"); + h->GetXaxis()->SetBinLabel(7, "Z-vert Cut"); + histos.add("histogram/cuts", "cuts", HistType::kTH1D, + {{13, -0.5, 12.5}}); + auto hCuts = histos.get(HIST("histogram/cuts")); + hCuts->GetXaxis()->SetBinLabel(1, "total"); + hCuts->GetXaxis()->SetBinLabel(2, "p cut"); + hCuts->GetXaxis()->SetBinLabel(3, "eta cut"); + hCuts->GetXaxis()->SetBinLabel(4, "TPC cluster"); + hCuts->GetXaxis()->SetBinLabel(5, "ITS clsuter"); + hCuts->GetXaxis()->SetBinLabel(6, "TPC crossed rows"); + hCuts->GetXaxis()->SetBinLabel(7, "max chi2 ITS"); + hCuts->GetXaxis()->SetBinLabel(8, "max chi2 TPC"); + hCuts->GetXaxis()->SetBinLabel(9, "crossed rows over findable cluster"); + hCuts->GetXaxis()->SetBinLabel(10, "TPC refit"); + hCuts->GetXaxis()->SetBinLabel(11, "ITS refit"); + hCuts->GetXaxis()->SetBinLabel(12, "ITS cluster size"); + hCuts->GetXaxis()->SetBinLabel(13, "TOF mass cut"); + for (int i = 0; i < nParticles; i++) { + particles.push_back(Particle(particleNames.at(i), particlePdgCodes.at(i), + particleMasses.at(i), particleCharge.at(i), + cfgBetheBlochParams, particleChargeFactor.at(i))); + } + } + void process(soa::Join::iterator const& event, + TracksFull const& tracks) + { + bool trRapCut = kFALSE; + bool heRapCut = kFALSE; + histos.fill(HIST("event/eventSelection"), 0); + if ((event.selection_bit(aod::evsel::kNoITSROFrameBorder)) && + (event.selection_bit(aod::evsel::kNoTimeFrameBorder)) && + (event.selection_bit(aod::evsel::kIsTriggerTVX))) { + histos.fill(HIST("event/eventSelection"), 4); + } + if (evselOptions.useSel8 && !event.sel8()) + return; + histos.fill(HIST("event/eventSelection"), 5); + if (event.posZ() < cfgLowCutVertex || event.posZ() > cfgHighCutVertex) + return; + histos.fill(HIST("event/eventSelection"), 6); + if (cfgTPCPidMethod) { + for (const auto& track : tracks) { + trRapCut = + track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Triton)) > + kinemOptions.yLowCut && + track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Triton)) < + kinemOptions.yHighCut; + heRapCut = + track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)) > + kinemOptions.yLowCut && + track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)) < + kinemOptions.yHighCut; + histos.fill(HIST("histogram/cuts"), 0); + if (std::abs(track.p()) < kinemOptions.pCut) { + histos.fill(HIST("histogram/cuts"), 1); + continue; + } + if (std::abs(track.eta()) > kinemOptions.etaCut) { + histos.fill(HIST("histogram/cuts"), 2); + continue; + } + if (track.pt() > cfgMaxPt || getRigidity(track) > cfgMaxRigidity) { + continue; + } + if (track.tpcNClsFound() < cfgCutTpcClusters) { + histos.fill(HIST("histogram/cuts"), 3); + continue; + } + if (track.itsNCls() < cfgCutItsClusters) { + histos.fill(HIST("histogram/cuts"), 4); + continue; + } + if (track.tpcNClsCrossedRows() < cfgCutTpcXRows) { + histos.fill(HIST("histogram/cuts"), 5); + continue; + } + if (track.tpcCrossedRowsOverFindableCls() <= cfgCutTpcCrRowToFindableCl) { + histos.fill(HIST("histogram/cuts"), 8); + continue; + } + if (cfgCutTpcRefit) { + if (!track.passedTPCRefit()) { + histos.fill(HIST("histogram/cuts"), 9); + continue; + } + } + if (cfgCutItsRefit) { + if (!track.passedITSRefit()) { + histos.fill(HIST("histogram/cuts"), 10); + continue; + } + } + histos.fill(HIST("histogram/pT"), track.pt()); + histos.fill(HIST("histogram/p"), track.p()); + histos.fill(HIST("histogram/TPCsignVsTPCmomentum"), + getRigidity(track) * track.sign(), + track.tpcSignal()); + histos.fill(HIST("histogram/TOFbetaVsP"), + getRigidity(track) * track.sign(), + track.beta()); + if (enableTr && trRapCut) { + if (std::abs(getTPCnSigma(track, particles.at(0))) < + nsigmaTPCvar.nsigmaTPCTr) { + if (track.itsChi2NCl() > cfgCutMaxChi2ItsH3) { + histos.fill(HIST("histogram/cuts"), 6); + continue; + } + if (track.tpcChi2NCl() > cfgCutMaxChi2TpcH3) { + histos.fill(HIST("histogram/cuts"), 7); + continue; + } + if (cfgEnableItsClusterSizeCut) { + if (getMeanItsClsSize(track) / std::cosh(track.eta()) <= cfgCutMinItsClusterSizeHe || + getMeanItsClsSize(track) / std::cosh(track.eta()) >= cfgCutMaxItsClusterSizeHe) { + histos.fill(HIST("histogram/cuts"), 12); + continue; + } + } + if (cfgEnableTofMassCut && track.pt() > cfgTofMassCutPt) { + if (getMass(track) < cfgCutMinTofMassH3 || getMass(track) > cfgCutMaxTofMassH3) { + histos.fill(HIST("histogram/cuts"), 13); + continue; + } + } + histos.fill(HIST("histogram/H3/H3-TPCsignVsTPCmomentum"), + getRigidity(track) * track.sign(), + track.tpcSignal()); + histos.fill(HIST("histogram/H3/H3-TOFbetaVsP"), + getRigidity(track) * track.sign(), + track.beta()); + float tPt = track.pt(); + float tEta = track.eta(); + float tPhi = track.phi(); + int8_t tCharge = track.sign(); + float tH3DeDx = track.tpcSignal(); + float tnSigmaTpc = getTPCnSigma(track, particles.at(0)); + float tTofSignalH3 = getMass(track); + float tDcaXY = track.dcaXY(); + float tDcaZ = track.dcaZ(); + float tSigmaYX = track.sigmaY(); + float tSigmaXYZ = track.sigmaSnp(); + float tSigmaZ = track.sigmaZ(); + int tnTpcCluster = track.tpcNClsFound(); + int tnItsCluster = track.itsNCls(); + float tTpcChi2NCl = track.tpcChi2NCl(); + float tItsChi2NCl = track.itsChi2NCl(); + float tRigidity = getRigidity(track); + float tItsClusterSize = + getMeanItsClsSize(track) / std::cosh(track.eta()); + bool tHasTof = track.hasTOF(); + int8_t tDetectorMap = track.detectorMap(); + h3Data(tPt, tEta, tPhi, tCharge, tH3DeDx, tnSigmaTpc, tTofSignalH3, + tDcaXY, tDcaZ, tSigmaYX, tSigmaXYZ, tSigmaZ, tnTpcCluster, + tnItsCluster, tTpcChi2NCl, tItsChi2NCl, tRigidity, + tItsClusterSize, tHasTof, tDetectorMap); + } + } + if (enableHe && heRapCut) { + if (std::abs(getTPCnSigma(track, particles.at(1))) < + nsigmaTPCvar.nsigmaTPCHe) { + if (track.itsChi2NCl() > cfgCutMaxChi2ItsHe) { + histos.fill(HIST("histogram/cuts"), 6); + continue; + } + if (track.tpcChi2NCl() > cfgCutMaxChi2TpcHe) { + histos.fill(HIST("histogram/cuts"), 7); + continue; + } + if (cfgEnableItsClusterSizeCut) { + if (getMeanItsClsSize(track) / std::cosh(track.eta()) <= cfgCutMinItsClusterSizeHe || + getMeanItsClsSize(track) / std::cosh(track.eta()) >= cfgCutMaxItsClusterSizeHe) { + histos.fill(HIST("histogram/cuts"), 12); + continue; + } + } + histos.fill(HIST("histogram/He/He-TPCsignVsTPCmomentum"), + getRigidity(track) * track.sign(), + track.tpcSignal()); + histos.fill(HIST("histogram/He/He-TOFbetaVsP"), + getRigidity(track) * track.sign(), + track.beta()); + float tPt = track.pt(); + float tEta = track.eta(); + float tPhi = track.phi(); + int8_t tCharge = 2.f * track.sign(); + float tHeDeDx = track.tpcSignal(); + float tnSigmaTpc = getTPCnSigma(track, particles.at(1)); + float tTofSignalHe = getMass(track); + float tDcaXY = track.dcaXY(); + float tDcaZ = track.dcaZ(); + float tSigmaYX = track.sigmaY(); + float tSigmaXYZ = track.sigmaSnp(); + float tSigmaZ = track.sigmaZ(); + int tnTpcCluster = track.tpcNClsFound(); + int tnItsCluster = track.itsNCls(); + float tTpcChi2NCl = track.tpcChi2NCl(); + float tItsChi2NCl = track.itsChi2NCl(); + float tRigidity = getRigidity(track); + float tItsClusterSize = + getMeanItsClsSize(track) / std::cosh(track.eta()); + bool tHasTof = track.hasTOF(); + int8_t tDetectorMap = track.detectorMap(); + heData(tPt, tEta, tPhi, tCharge, tHeDeDx, tnSigmaTpc, tTofSignalHe, + tDcaXY, tDcaZ, tSigmaYX, tSigmaXYZ, tSigmaZ, tnTpcCluster, + tnItsCluster, tTpcChi2NCl, tItsChi2NCl, tRigidity, + tItsClusterSize, tHasTof, tDetectorMap); + } + } + } + } + if (!cfgTPCPidMethod) { + for (const auto& track : tracks) { + trRapCut = + track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Triton)) > + kinemOptions.yLowCut && + track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Triton)) < + kinemOptions.yHighCut; + heRapCut = + track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)) > + kinemOptions.yLowCut && + track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)) < + kinemOptions.yHighCut; + histos.fill(HIST("histogram/cuts"), 0); + if (std::abs(track.p()) < kinemOptions.pCut) { + histos.fill(HIST("histogram/cuts"), 1); + continue; + } + if (std::abs(track.eta()) > kinemOptions.etaCut) { + histos.fill(HIST("histogram/cuts"), 2); + continue; + } + if (track.pt() > cfgMaxPt || getRigidity(track) > cfgMaxRigidity) { + continue; + } + if (track.tpcNClsFound() < cfgCutTpcClusters) { + histos.fill(HIST("histogram/cuts"), 3); + continue; + } + if (track.itsNCls() < cfgCutItsClusters) { + histos.fill(HIST("histogram/cuts"), 4); + continue; + } + if (track.tpcNClsCrossedRows() < cfgCutTpcXRows) { + histos.fill(HIST("histogram/cuts"), 5); + continue; + } + if (track.tpcCrossedRowsOverFindableCls() <= cfgCutTpcCrRowToFindableCl) { + histos.fill(HIST("histogram/cuts"), 8); + continue; + } + if (cfgCutTpcRefit) { + if (!track.passedTPCRefit()) { + histos.fill(HIST("histogram/cuts"), 9); + continue; + } + } + if (cfgCutItsRefit) { + if (!track.passedITSRefit()) { + histos.fill(HIST("histogram/cuts"), 10); + continue; + } + } + histos.fill(HIST("histogram/pT"), track.pt()); + histos.fill(HIST("histogram/p"), track.p()); + histos.fill(HIST("histogram/TPCsignVsTPCmomentum"), + getRigidity(track) * (1.f * track.sign()), + track.tpcSignal()); + histos.fill(HIST("histogram/TOFbetaVsP"), + track.p() * (1.f * track.sign()), track.beta()); + if (enableTr && trRapCut) { + if (std::abs(track.tpcNSigmaTr()) < nsigmaTPCvar.nsigmaTPCTr) { + if (track.itsChi2NCl() > cfgCutMaxChi2ItsH3) { + histos.fill(HIST("histogram/cuts"), 6); + continue; + } + if (track.tpcChi2NCl() > cfgCutMaxChi2TpcH3) { + histos.fill(HIST("histogram/cuts"), 7); + continue; + } + if (cfgEnableItsClusterSizeCut) { + if (getMeanItsClsSize(track) / std::cosh(track.eta()) <= cfgCutMinItsClusterSizeH3 || + getMeanItsClsSize(track) / std::cosh(track.eta()) >= cfgCutMaxItsClusterSizeH3) { + histos.fill(HIST("histogram/cuts"), 12); + continue; + } + } + if (cfgEnableTofMassCut && track.pt() > cfgTofMassCutPt) { + if (getMass(track) < cfgCutMinTofMassH3 || getMass(track) > cfgCutMaxTofMassH3) { + histos.fill(HIST("histogram/cuts"), 13); + continue; + } + } + histos.fill(HIST("histogram/H3/H3-TPCsignVsTPCmomentum"), + getRigidity(track) * (1.f * track.sign()), + track.tpcSignal()); + histos.fill(HIST("histogram/H3/H3-TOFbetaVsP"), + track.p() * (1.f * track.sign()), + track.beta()); + float tPt = track.pt(); + float tEta = track.eta(); + float tPhi = track.phi(); + int8_t tCharge = track.sign(); + float tH3DeDx = track.tpcSignal(); + float tnSigmaTpc = track.tpcNSigmaTr(); + float tTofSignalH3 = getMass(track); + float tDcaXY = track.dcaXY(); + float tDcaZ = track.dcaZ(); + float tSigmaYX = track.sigmaY(); + float tSigmaXYZ = track.sigmaSnp(); + float tSigmaZ = track.sigmaZ(); + int tnTpcCluster = track.tpcNClsFound(); + int tnItsCluster = track.itsNCls(); + float tTpcChi2NCl = track.tpcChi2NCl(); + float tItsChi2NCl = track.itsChi2NCl(); + float tRigidity = getRigidity(track); + float tItsClusterSize = + getMeanItsClsSize(track) / std::cosh(track.eta()); + bool tHasTof = track.hasTOF(); + int8_t tDetectorMap = track.detectorMap(); + h3Data(tPt, tEta, tPhi, tCharge, tH3DeDx, tnSigmaTpc, tTofSignalH3, + tDcaXY, tDcaZ, tSigmaYX, tSigmaXYZ, tSigmaZ, tnTpcCluster, + tnItsCluster, tTpcChi2NCl, tItsChi2NCl, tRigidity, + tItsClusterSize, tHasTof, tDetectorMap); + } + } + if (enableHe && heRapCut) { + if (std::abs(track.tpcNSigmaHe()) < nsigmaTPCvar.nsigmaTPCHe) { + if (track.itsChi2NCl() > cfgCutMaxChi2ItsHe) { + histos.fill(HIST("histogram/cuts"), 6); + continue; + } + if (track.tpcChi2NCl() > cfgCutMaxChi2TpcHe) { + histos.fill(HIST("histogram/cuts"), 7); + continue; + } + if (cfgEnableItsClusterSizeCut) { + if (getMeanItsClsSize(track) / std::cosh(track.eta()) <= cfgCutMinItsClusterSizeHe || + getMeanItsClsSize(track) / std::cosh(track.eta()) >= cfgCutMaxItsClusterSizeHe) { + histos.fill(HIST("histogram/cuts"), 12); + continue; + } + } + histos.fill(HIST("histogram/He/He-TPCsignVsTPCmomentum"), + getRigidity(track) * track.sign(), + track.tpcSignal()); + histos.fill(HIST("histogram/He/He-TOFbetaVsP"), + getRigidity(track) * track.sign(), + track.beta()); + float tPt = track.pt(); + float tEta = track.eta(); + float tPhi = track.phi(); + int8_t tCharge = 2.f * track.sign(); + float tHeDeDx = track.tpcSignal(); + float tnSigmaTpc = track.tpcNSigmaHe(); + float tTofSignalHe = getMass(track); + float tDcaXY = track.dcaXY(); + float tDcaZ = track.dcaZ(); + float tSigmaYX = track.sigmaY(); + float tSigmaXYZ = track.sigmaSnp(); + float tSigmaZ = track.sigmaZ(); + int tnTpcCluster = track.tpcNClsFound(); + int tnItsCluster = track.itsNCls(); + float tTpcChi2NCl = track.tpcChi2NCl(); + float tItsChi2NCl = track.itsChi2NCl(); + float tRigidity = getRigidity(track); + float tItsClusterSize = + getMeanItsClsSize(track) / std::cosh(track.eta()); + bool tHasTof = track.hasTOF(); + int8_t tDetectorMap = track.detectorMap(); + heData(tPt, tEta, tPhi, tCharge, tHeDeDx, tnSigmaTpc, tTofSignalHe, + tDcaXY, tDcaZ, tSigmaYX, tSigmaXYZ, tSigmaZ, tnTpcCluster, + tnItsCluster, tTpcChi2NCl, tItsChi2NCl, tRigidity, + tItsClusterSize, tHasTof, tDetectorMap); + } + } + } + } + } + + template + float getTPCnSigma(T const& track, Particle const& particle) + { + const float rigidity = getRigidity(track); + if (!track.hasTPC()) + return -999; + + float expBethe{betheBlochAleph(particle, rigidity)}; + float expSigma{expBethe * particle.resolution}; + float sigmaTPC = + static_cast((track.tpcSignal() - expBethe) / expSigma); + return sigmaTPC; + } + + template + float betheBlochAleph(Particle const& particle, T const& rigidity) + { + double bg = particle.charge * rigidity / particle.mass; + double beta = bg / std::sqrt(1. + bg * bg); + double aa = std::pow(beta, particle.betheParams[3]); + double bb = std::pow(1. / bg, particle.betheParams[4]); + if ((particle.betheParams[2] + bb) <= 0) + return 0; + bb = std::log(particle.betheParams[2] + bb); + return std::pow(particle.charge, particle.chargeFactor) * 50 * (particle.betheParams[1] - aa - bb) * particle.betheParams[0] / aa; + } + + template + float getMeanItsClsSize(T const& track) + { + constexpr int NNumLayers = 8; + constexpr int NBitsPerLayer = 4; + constexpr int NBitMask = (1 << NBitsPerLayer) - 1; + + int sum = 0, n = 0; + for (int i = 0; i < NNumLayers; i++) { + int clsSize = (track.itsClusterSizes() >> (NBitsPerLayer * i)) & NBitMask; + sum += clsSize; + if (clsSize) { + n++; + } + } + return n > 0 ? static_cast(sum) / n : 0.f; + } + template + float getRigidity(T const& track) + { + if (!cfgRigidityCorrection) + return track.tpcInnerParam(); + bool hePID = track.pidForTracking() == o2::track::PID::Helium3 || track.pidForTracking() == o2::track::PID::Alpha; + return hePID ? track.tpcInnerParam() / 2 : track.tpcInnerParam(); + } + template + float getMass(const T& track) + { + if (cfgMassMethod == 0) { + float m = track.mass(); + return m * m; + } + if (cfgMassMethod == 1) { + const float beta = track.beta(); + const float rigidity = getRigidity(track); + float gamma = 1.f / std::sqrt(1.f - beta * beta); + float mass = rigidity / std::sqrt(gamma * gamma - 1.f); + return mass * mass; + } + if (cfgMassMethod == 2) { + const float rigidity = getRigidity(track); + float tofStartTime = track.evTimeForTrack(); + float tofTime = track.tofSignal(); + constexpr float CInCmPs = 2.99792458e-2f; + float length = track.length(); + float time = tofTime - tofStartTime; + if (time > 0.f && length > 0.f) { + float beta = length / (CInCmPs * time); + float gamma = 1.f / std::sqrt(1.f - beta * beta); + float mass = rigidity / std::sqrt(gamma * gamma - 1.f); + return mass * mass; + } + return -1.f; + } + return -1.f; + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGLF/TableProducer/QC/flowQC.cxx b/PWGLF/TableProducer/QC/flowQC.cxx index 9dab0a906f0..9a120e1afe8 100644 --- a/PWGLF/TableProducer/QC/flowQC.cxx +++ b/PWGLF/TableProducer/QC/flowQC.cxx @@ -19,34 +19,32 @@ // o2-analysis-multiplicity-table, o2-analysis-ft0-corrected-table, o2-analysis-track-propagation, // o2-analysis-trackselection, o2-analysis-qvector-table, o2-analysis-lf-flow-qc -#include - -#include "Math/Vector4D.h" - -#include "CCDB/BasicCCDBManager.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "Common/Core/EventPlaneHelper.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/EventSelection.h" -#include "Common/Core/EventPlaneHelper.h" -#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Qvectors.h" +#include "CCDB/BasicCCDBManager.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" #include "DataFormatsTPC/BetheBlochAleph.h" #include "DetectorsBase/GeometryManager.h" #include "DetectorsBase/Propagator.h" - +#include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" +#include "Math/Vector4D.h" #include "TRandom3.h" +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -67,9 +65,10 @@ enum qVecDetectors { kFT0A, kTPCl, kTPCr, + kTPC, kNqVecDetectors }; -static const std::vector qVecDetectorNames{"FT0C", "FT0A", "TPCl", "TPCr"}; +static const std::vector qVecDetectorNames{"FT0C", "FT0A", "TPCl", "TPCr", "TPC"}; enum methods { kEP = 0, @@ -110,9 +109,11 @@ struct flowQC { int mRunNumber = 0; float mBz = 0.f; + Configurable cfgHarmonic{"cfgHarmonic", 2.f, "Harmonics for flow analysis"}; + // Flow analysis using CollWithEPandQvec = soa::Join::iterator; + aod::EvSels, aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, aod::FT0Mults, aod::FV0Mults, aod::TPCMults, aod::EPCalibrationTables, aod::QvectorFT0CVecs, aod::QvectorFT0AVecs, aod::QvectorFT0MVecs, aod::QvectorFV0AVecs, aod::QvectorTPCallVecs, aod::QvectorTPCposVecs, aod::QvectorTPCnegVecs>::iterator; HistogramRegistry general{"general", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry flow_ep{"flow_ep", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; @@ -170,15 +171,15 @@ struct flowQC { const AxisSpec centAxis{cfgCentralityBins, fmt::format("{} percentile", (std::string)centDetectorNames[cfgCentralityEstimator])}; - const AxisSpec QxAxis{cfgQvecBins, "Q_{2,x}"}; - const AxisSpec QyAxis{cfgQvecBins, "Q_{2,y}"}; + const AxisSpec QxAxis{cfgQvecBins, Form("Q_{%.0f,x}", cfgHarmonic.value)}; + const AxisSpec QyAxis{cfgQvecBins, Form("Q_{%.0f,y}", cfgHarmonic.value)}; - const AxisSpec NormQxAxis{cfgQvecBins, "#frac{Q_{2,x}}{||#vec{Q_{2}}||}"}; - const AxisSpec NormQyAxis{cfgQvecBins, "#frac{Q_{2,y}}{||#vec{Q_{2}}||}"}; + const AxisSpec NormQxAxis{cfgQvecBins, Form("#frac{Q_{%.0f,x}}{||#vec{Q_{%.0f}}||}", cfgHarmonic.value, cfgHarmonic.value)}; + const AxisSpec NormQyAxis{cfgQvecBins, Form("#frac{Q_{%.0f,y}}{||#vec{Q_{%.0f}}||}", cfgHarmonic.value, cfgHarmonic.value)}; - const AxisSpec psiAxis{cfgPhiBins, "#psi_{2}"}; - const AxisSpec psiCompAxis{cfgPhiBins, "#psi_{2}^{EP} - #psi_{2}^{Qvec}"}; - const AxisSpec cosPsiCompAxis{cfgCosPhiBins, "cos[2(#psi_{2}^{EP} - #psi_{2}^{Qvec})]"}; + const AxisSpec psiAxis{cfgPhiBins, Form("#psi_{%.0f}", cfgHarmonic.value)}; + const AxisSpec psiCompAxis{cfgPhiBins, Form("#psi_{%.0f}^{EP} - #psi_{%.0f}^{Qvec}", cfgHarmonic.value, cfgHarmonic.value)}; + const AxisSpec cosPsiCompAxis{cfgCosPhiBins, Form("cos[2(#psi_{%.0f}^{EP} - #psi_{%.0f}^{Qvec})]", cfgHarmonic.value, cfgHarmonic.value)}; // z vertex histogram general.add("hRecVtxZData", "collision z position", HistType::kTH1F, {{200, -20., +20., "z position (cm)"}}); @@ -202,12 +203,12 @@ struct flowQC { hDeltaPsi[iMethod][iQvecDet][jQvecDet] = registry->add(Form("hDeltaPsi_%s_%s_%s", qVecDetectorNames[iQvecDet].c_str(), qVecDetectorNames[jQvecDet].c_str(), suffixes[iMethod].c_str()), "", HistType::kTH2F, {centAxis, {cfgDeltaPhiBins, Form("#psi_{%s} - #psi_{%s}", qVecDetectorNames[iQvecDet].c_str(), qVecDetectorNames[jQvecDet].c_str())}}); // Scalar-product histograms - auto spLabel = Form("#vec{Q}_{2}^{%s} #upoint #vec{Q}_{2}^{%s}", qVecDetectorNames[iQvecDet].c_str(), qVecDetectorNames[jQvecDet].c_str()); + auto spLabel = Form("#vec{Q}_{%.0f}^{%s} #upoint #vec{Q}_{%.0f}^{%s}", cfgHarmonic.value, qVecDetectorNames[iQvecDet].c_str(), cfgHarmonic.value, qVecDetectorNames[jQvecDet].c_str()); hScalarProduct[iMethod][iQvecDet][jQvecDet] = registry->add(Form("hScalarProduct_%s_%s_%s", qVecDetectorNames[iQvecDet].c_str(), qVecDetectorNames[jQvecDet].c_str(), suffixes[iMethod].c_str()), "", HistType::kTH2F, {centAxis, {cfgQvecBins, spLabel}}); // Normalised scalar-product histograms - auto normSpLabel = Form("#frac{#vec{Q}_{2}^{%s} #upoint #vec{Q}_{2}^{%s}}{||#vec{Q}_{2}^{%s}|| ||#vec{Q}_{2}^{%s}||}", qVecDetectorNames[iQvecDet].c_str(), qVecDetectorNames[jQvecDet].c_str(), qVecDetectorNames[iQvecDet].c_str(), qVecDetectorNames[jQvecDet].c_str()); + auto normSpLabel = Form("#frac{#vec{Q}_{%.0f}^{%s} #upoint #vec{Q}_{%.0f}^{%s}}{||#vec{Q}_{%.0f}^{%s}|| ||#vec{Q}_{%.0f}^{%s}||}", cfgHarmonic.value, qVecDetectorNames[iQvecDet].c_str(), cfgHarmonic.value, qVecDetectorNames[jQvecDet].c_str(), cfgHarmonic.value, qVecDetectorNames[iQvecDet].c_str(), cfgHarmonic.value, qVecDetectorNames[jQvecDet].c_str()); hNormalisedScalarProduct[iMethod][iQvecDet][jQvecDet] = registry->add(Form("hNormalisedScalarProduct_%s_%s_%s", qVecDetectorNames[iQvecDet].c_str(), qVecDetectorNames[jQvecDet].c_str(), suffixes[iMethod].c_str()), "", HistType::kTH2F, {centAxis, {cfgQvecBins, normSpLabel}}); } @@ -258,51 +259,61 @@ struct flowQC { float centrality = getCentrality(collision); // EP method + float QmodFT0A_EP = collision.qFT0A(); float psiFT0A_EP = collision.psiFT0A(); - float QxFT0A_EP = std::cos(2 * psiFT0A_EP); - float QyFT0A_EP = std::sin(2 * psiFT0A_EP); - float QmodFT0A_EP = std::hypot(QxFT0A_EP, QyFT0A_EP); + float QxFT0A_EP = QmodFT0A_EP * std::cos(cfgHarmonic.value * psiFT0A_EP); + float QyFT0A_EP = QmodFT0A_EP * std::sin(cfgHarmonic.value * psiFT0A_EP); + float QmodFT0C_EP = collision.qFT0C(); float psiFT0C_EP = collision.psiFT0C(); - float QxFT0C_EP = std::cos(2 * psiFT0C_EP); - float QyFT0C_EP = std::sin(2 * psiFT0C_EP); - float QmodFT0C_EP = std::hypot(QxFT0C_EP, QyFT0C_EP); + float QxFT0C_EP = QmodFT0C_EP * std::cos(cfgHarmonic.value * psiFT0C_EP); + float QyFT0C_EP = QmodFT0C_EP * std::sin(cfgHarmonic.value * psiFT0C_EP); + float QmodTPCl_EP = collision.qTPCL(); float psiTPCl_EP = collision.psiTPCL(); - float QxTPCl_EP = std::cos(2 * psiTPCl_EP); - float QyTPCl_EP = std::sin(2 * psiTPCl_EP); - float QmodTPCl_EP = std::hypot(QxTPCl_EP, QyTPCl_EP); + float QxTPCl_EP = QmodTPCl_EP * std::cos(cfgHarmonic.value * psiTPCl_EP); + float QyTPCl_EP = QmodTPCl_EP * std::sin(cfgHarmonic.value * psiTPCl_EP); + float QmodTPCr_EP = collision.qTPCR(); float psiTPCr_EP = collision.psiTPCR(); - float QxTPCr_EP = std::cos(2 * psiTPCr_EP); - float QyTPCr_EP = std::sin(2 * psiTPCr_EP); - float QmodTPCr_EP = std::hypot(QxTPCr_EP, QyTPCr_EP); + float QxTPCr_EP = QmodTPCr_EP * std::cos(cfgHarmonic.value * psiTPCr_EP); + float QyTPCr_EP = QmodTPCr_EP * std::sin(cfgHarmonic.value * psiTPCr_EP); + + float QmodTPC_EP = collision.qTPC(); + float psiTPC_EP = collision.psiTPC(); + float QxTPC_EP = QmodTPC_EP * std::cos(cfgHarmonic.value * psiTPC_EP); + float QyTPC_EP = QmodTPC_EP * std::sin(cfgHarmonic.value * psiTPC_EP); // Qvec method - float QxFT0A_Qvec = collision.qvecFT0ARe(); - float QyFT0A_Qvec = collision.qvecFT0AIm(); + float QxFT0A_Qvec = collision.qvecFT0AReVec()[cfgHarmonic.value - 2]; + float QyFT0A_Qvec = collision.qvecFT0AImVec()[cfgHarmonic.value - 2]; float QmodFT0A_Qvec = std::hypot(QxFT0A_Qvec, QyFT0A_Qvec); float psiFT0A_Qvec = computeEventPlane(QyFT0A_Qvec, QxFT0A_Qvec); - float QxFT0C_Qvec = collision.qvecFT0CRe(); - float QyFT0C_Qvec = collision.qvecFT0CIm(); + float QxFT0C_Qvec = collision.qvecFT0CReVec()[cfgHarmonic.value - 2]; + float QyFT0C_Qvec = collision.qvecFT0CImVec()[cfgHarmonic.value - 2]; float QmodFT0C_Qvec = std::hypot(QxFT0C_Qvec, QyFT0C_Qvec); - float psiFT0C_Qvec = computeEventPlane(QyFT0C_Qvec, QxFT0A_Qvec); + float psiFT0C_Qvec = computeEventPlane(QyFT0C_Qvec, QxFT0C_Qvec); - float QxTPCl_Qvec = collision.qvecBNegRe(); - float QyTPCl_Qvec = collision.qvecBNegIm(); + float QxTPCl_Qvec = collision.qvecTPCnegReVec()[cfgHarmonic.value - 2]; + float QyTPCl_Qvec = collision.qvecTPCnegImVec()[cfgHarmonic.value - 2]; float QmodTPCl_Qvec = std::hypot(QxTPCl_Qvec, QyTPCl_Qvec); float psiTPCl_Qvec = computeEventPlane(QyTPCl_Qvec, QxTPCl_Qvec); - float QxTPCr_Qvec = collision.qvecBPosRe(); - float QyTPCr_Qvec = collision.qvecBPosIm(); + float QxTPCr_Qvec = collision.qvecTPCposReVec()[cfgHarmonic.value - 2]; + float QyTPCr_Qvec = collision.qvecTPCposImVec()[cfgHarmonic.value - 2]; float QmodTPCr_Qvec = std::hypot(QxTPCr_Qvec, QyTPCr_Qvec); float psiTPCr_Qvec = computeEventPlane(QyTPCr_Qvec, QxTPCr_Qvec); - std::array vec_Qx[2] = {{QxFT0C_EP, QxFT0A_EP, QxTPCl_EP, QxTPCr_EP}, {QxFT0C_Qvec, QxFT0A_Qvec, QxTPCl_Qvec, QxTPCr_Qvec}}; - std::array vec_Qy[2] = {{QyFT0C_EP, QyFT0A_EP, QyTPCl_EP, QyTPCr_EP}, {QyFT0C_Qvec, QyFT0A_Qvec, QyTPCl_Qvec, QyTPCr_Qvec}}; - std::array vec_Qmod[2] = {{QmodFT0C_EP, QmodFT0A_EP, QmodTPCl_EP, QmodTPCr_EP}, {QmodFT0C_Qvec, QmodFT0A_Qvec, QmodTPCl_Qvec, QmodTPCr_Qvec}}; - std::array vec_Qpsi[2] = {{psiFT0C_EP, psiFT0A_EP, psiTPCl_EP, psiTPCr_EP}, {psiFT0C_Qvec, psiFT0A_Qvec, psiTPCl_Qvec, psiTPCr_Qvec}}; + float QxTPC_Qvec = collision.qvecTPCallReVec()[cfgHarmonic.value - 2]; + float QyTPC_Qvec = collision.qvecTPCallImVec()[cfgHarmonic.value - 2]; + float QmodTPC_Qvec = std::hypot(QxTPC_Qvec, QyTPC_Qvec); + float psiTPC_Qvec = computeEventPlane(QyTPC_Qvec, QxTPC_Qvec); + + std::array vec_Qx[2] = {{QxFT0C_EP, QxFT0A_EP, QxTPCl_EP, QxTPCr_EP, QxTPC_EP}, {QxFT0C_Qvec, QxFT0A_Qvec, QxTPCl_Qvec, QxTPCr_Qvec, QxTPC_Qvec}}; + std::array vec_Qy[2] = {{QyFT0C_EP, QyFT0A_EP, QyTPCl_EP, QyTPCr_EP, QyTPC_EP}, {QyFT0C_Qvec, QyFT0A_Qvec, QyTPCl_Qvec, QyTPCr_Qvec, QyTPC_Qvec}}; + std::array vec_Qmod[2] = {{QmodFT0C_EP, QmodFT0A_EP, QmodTPCl_EP, QmodTPCr_EP, QmodTPC_EP}, {QmodFT0C_Qvec, QmodFT0A_Qvec, QmodTPCl_Qvec, QmodTPCr_Qvec, QmodTPC_Qvec}}; + std::array vec_Qpsi[2] = {{psiFT0C_EP, psiFT0A_EP, psiTPCl_EP, psiTPCr_EP, psiTPC_EP}, {psiFT0C_Qvec, psiFT0A_Qvec, psiTPCl_Qvec, psiTPCr_Qvec, psiTPC_Qvec}}; for (int iMethod = 0; iMethod < methods::kNmethods; iMethod++) { for (int iQvecDet = 0; iQvecDet < qVecDetectors::kNqVecDetectors; iQvecDet++) { @@ -327,7 +338,7 @@ struct flowQC { } for (int iQvecDet = 0; iQvecDet < qVecDetectors::kNqVecDetectors; iQvecDet++) { hPsiComp[iQvecDet]->Fill(centrality, vec_Qpsi[methods::kEP][iQvecDet] - vec_Qpsi[methods::kQvec][iQvecDet]); - hCosPsiComp[iQvecDet]->Fill(centrality, std::cos(2 * (vec_Qpsi[methods::kEP][iQvecDet] - vec_Qpsi[methods::kQvec][iQvecDet]))); + hCosPsiComp[iQvecDet]->Fill(centrality, std::cos(cfgHarmonic.value * (vec_Qpsi[methods::kEP][iQvecDet] - vec_Qpsi[methods::kQvec][iQvecDet]))); } } }; diff --git a/PWGLF/TableProducer/Resonances/CMakeLists.txt b/PWGLF/TableProducer/Resonances/CMakeLists.txt index 236ac38e2d9..a58387288a8 100644 --- a/PWGLF/TableProducer/Resonances/CMakeLists.txt +++ b/PWGLF/TableProducer/Resonances/CMakeLists.txt @@ -40,7 +40,17 @@ o2physics_add_dpl_workflow(resonance-module-initializer PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(reso2mergedf - SOURCES LFResonanceMergeDF.cxx +o2physics_add_dpl_workflow(resonance-merge-df + SOURCES resonanceMergeDF.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(heptaquarktable + SOURCES HeptaQuarktable.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(cksspinalignment + SOURCES cksspinalignment.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGLF/TableProducer/Resonances/HeptaQuarktable.cxx b/PWGLF/TableProducer/Resonances/HeptaQuarktable.cxx new file mode 100644 index 00000000000..ccb0c61465f --- /dev/null +++ b/PWGLF/TableProducer/Resonances/HeptaQuarktable.cxx @@ -0,0 +1,455 @@ +// 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. + +/// \file heptaquarktable.cxx +/// \brief Selection of events with triplets and pairs for femtoscopic studies +/// +/// \author Junlee Kim, (junlee.kim@cern.ch) + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "CommonConstants/MathConstants.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" + +#include "PWGLF/DataModel/ReducedHeptaQuarkTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct heptaquarktable { + + // Produce derived tables + Produces redHQEvents; + Produces hqTrack; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + + Configurable cfgUseGlobalTrack{"cfgUseGlobalTrack", true, "use Global track"}; + Configurable cfgCutCharge{"cfgCutCharge", 0.0, "cut on Charge"}; + Configurable cfgCutPt{"cfgCutPt", 0.2, "PT cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; + Configurable cfgNsigmaTPCKa{"cfgNsigmaTPCKa", 3.0, "Value of the TPC Nsigma cut for kaon"}; + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; + + Configurable cfgMinPhiMass{"cfgMinPhiMass", 1.01, "Minimum phi mass"}; + Configurable cfgMaxPhiMass{"cfgMaxPhiMass", 1.03, "Maximum phi mass"}; + Configurable cfgDeepAngleFlag{"cfgDeepAngleFlag", true, "Deep Angle cut"}; + Configurable cfgDeepAngle{"cfgDeepAngle", 0.04, "Deep Angle cut value"}; + + Configurable cfgv0radiusMin{"cfgv0radiusMin", 1.2, "minimum decay radius"}; + Configurable cfgDCAPosToPVMin{"cfgDCAPosToPVMin", 0.05, "minimum DCA to PV for positive track"}; + Configurable cfgDCANegToPVMin{"cfgDCANegToPVMin", 0.2, "minimum DCA to PV for negative track"}; + Configurable cfgv0CosPA{"cfgv0CosPA", 0.995, "minimum v0 cosine"}; + Configurable cfgDCAV0Dau{"cfgDCAV0Dau", 1.0, "maximum DCA between daughters"}; + + Configurable cfgV0PtMin{"cfgV0PtMin", 0, "minimum pT for lambda"}; + Configurable cfgV0EtaMin{"cfgV0EtaMin", -0.5, "maximum rapidity"}; + Configurable cfgV0EtaMax{"cfgV0EtaMax", 0.5, "maximum rapidity"}; + Configurable cfgV0LifeTime{"cfgV0LifeTime", 30., "maximum lambda lifetime"}; + + Configurable cfgDaughTPCnclsMin{"cfgDaughTPCnclsMin", 70, "minimum fired crossed rows"}; + Configurable cfgDaughPIDCutsTPCPr{"cfgDaughPIDCutsTPCPr", 3, "proton nsigma for TPC"}; + Configurable cfgDaughPIDCutsTPCPi{"cfgDaughPIDCutsTPCPi", 3, "pion nsigma for TPC"}; + Configurable cfgDaughEtaMin{"cfgDaughEtaMin", -0.8, "minimum daughter eta"}; + Configurable cfgDaughEtaMax{"cfgDaughEtaMax", 0.8, "maximum daughter eta"}; + Configurable cfgDaughPrPt{"cfgDaughPrPt", 0.5, "minimum daughter proton pt"}; + Configurable cfgDaughPiPt{"cfgDaughPiPt", 0.5, "minimum daughter pion pt"}; + + Configurable cfgMinLambdaMass{"cfgMinLambdaMass", 1.105, "Minimum lambda mass"}; + Configurable cfgMaxLambdaMass{"cfgMaxLambdaMass", 1.125, "Maximum lambda mass"}; + + ConfigurableAxis massAxis{"massAxis", {200, 3.0, 3.4}, "Invariant mass axis"}; + ConfigurableAxis ptAxis{"ptAxis", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "Transverse momentum bins"}; + ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0, 20, 50, 100}, "Centrality interval"}; + ConfigurableAxis vertexAxis{"vertexAxis", {10, -10, 10}, "vertex axis for mixing"}; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPt); + Filter DCAcutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + + using EventCandidates = soa::Filtered>; + using TrackCandidates = soa::Filtered>; + + HistogramRegistry histos{ + "histos", + {}, + OutputObjHandlingPolicy::AnalysisObject}; + + SliceCache cache; + Partition posTracks = aod::track::signed1Pt > cfgCutCharge; + Partition negTracks = aod::track::signed1Pt < cfgCutCharge; + + double massLambda = o2::constants::physics::MassLambda; + double massPr = o2::constants::physics::MassProton; + double massPi = o2::constants::physics::MassPionCharged; + double massKa = o2::constants::physics::MassKPlus; + + float centrality; + + void init(o2::framework::InitContext&) + { + histos.add("hEventstat", "", {HistType::kTH1F, {{3, 0, 3}}}); + } + + template + bool selectionTrack(const T& candidate) + { + if (cfgUseGlobalTrack && !(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster)) { + return false; + } + return true; + } + + template + bool selectionPID(const T& candidate, int pid) + { + if (pid == 0) { + if (std::abs(candidate.tpcNSigmaPi()) > cfgDaughPIDCutsTPCPi) { + return false; + } + } else if (pid == 1) { + if (std::abs(candidate.tpcNSigmaKa()) > cfgNsigmaTPCKa) { + return false; + } + } else if (pid == 2) { + if (std::abs(candidate.tpcNSigmaPr()) > cfgDaughPIDCutsTPCPr) { + return false; + } + } + return true; + } + + template + bool selectionPair(const T1& candidate1, const T2& candidate2) + { + double pt1, pt2, pz1, pz2, p1, p2, angle; + pt1 = candidate1.pt(); + pt2 = candidate2.pt(); + pz1 = candidate1.pz(); + pz2 = candidate2.pz(); + p1 = candidate1.p(); + p2 = candidate2.p(); + angle = TMath::ACos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); + if (cfgDeepAngleFlag && angle < cfgDeepAngle) { + return false; + } + return true; + } + + template + bool selectionV0(TCollision const& collision, V0 const& candidate) + { + if (candidate.v0radius() < cfgv0radiusMin) + return false; + if (std::abs(candidate.dcapostopv()) < cfgDCAPosToPVMin) + return false; + if (std::abs(candidate.dcanegtopv()) < cfgDCANegToPVMin) + return false; + if (candidate.v0cosPA() < cfgv0CosPA) + return false; + if (std::abs(candidate.dcaV0daughters()) > cfgDCAV0Dau) + return false; + if (candidate.pt() < cfgV0PtMin) + return false; + if (candidate.yLambda() < cfgV0EtaMin) + return false; + if (candidate.yLambda() > cfgV0EtaMax) + return false; + if (candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massLambda > cfgV0LifeTime) + return false; + + return true; + } + + template + bool selectionV0Daughter(T const& track, int pid) // pid 0: proton, pid 1: pion + { + if (track.tpcNClsFound() < cfgDaughTPCnclsMin) + return false; + if (pid == 0 && std::abs(track.tpcNSigmaPr()) > cfgDaughPIDCutsTPCPr) + return false; + if (pid == 1 && std::abs(track.tpcNSigmaPi()) > cfgDaughPIDCutsTPCPi) + return false; + if (track.eta() > cfgDaughEtaMax) + return false; + if (track.eta() < cfgDaughEtaMin) + return false; + if (pid == 0 && track.pt() < cfgDaughPrPt) + return false; + if (pid == 1 && track.pt() < cfgDaughPiPt) + return false; + + return true; + } + + ROOT::Math::PxPyPzMVector DauVec1, DauVec2, HQMesonMother, HQVectorDummy, HQd1dummy, HQd2dummy; + + void processHQReducedTable(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::V0Datas const& V0s, aod::BCsWithTimestamps const&) + { + o2::aod::ITSResponse itsResponse; + bool keepEventDoubleHQ = false; + int numberPhi = 0; + int numberLambda = 0; + auto currentRunNumber = collision.bc_as().runNumber(); + auto bc = collision.bc_as(); + centrality = collision.centFT0M(); + + std::vector HQId = {}; + + std::vector HQd1Index = {}; + std::vector HQd2Index = {}; + + std::vector HQd1Charge = {}; + std::vector HQd2Charge = {}; + + std::vector HQd1TPC = {}; + std::vector HQd2TPC = {}; + + std::vector HQd1TOFHit = {}; + std::vector HQd2TOFHit = {}; + + std::vector HQd1TOF = {}; + std::vector HQd2TOF = {}; + + std::vector hqresonance, hqresonanced1, hqresonanced2; + + histos.fill(HIST("hEventstat"), 0.5); + if (!(collision.sel8() && collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && collision.selection_bit(aod::evsel::kNoITSROFrameBorder) && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) + return; + histos.fill(HIST("hEventstat"), 1.5); + + auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + for (auto track1 : posThisColl) { + if (!selectionTrack(track1)) + continue; + + if (!selectionPID(track1, 1)) + continue; + + if (!(itsResponse.nSigmaITS(track1) > -3.0 && itsResponse.nSigmaITS(track1) < 3.0)) + continue; + + /* + qaRegistry.fill(HIST("hNsigmaPtkaonTPC"), track1.tpcNSigmaKa(), track1.pt()); + if (track1.hasTOF()) { + qaRegistry.fill(HIST("hNsigmaPtkaonTOF"), track1.tofNSigmaKa(), track1.pt()); + } + */ + auto track1ID = track1.globalIndex(); + for (auto track2 : negThisColl) { + if (!selectionTrack(track2)) + continue; + + if (!selectionPID(track2, 1)) + continue; + + if (!(itsResponse.nSigmaITS(track2) > -3.0 && itsResponse.nSigmaITS(track2) < 3.0)) + continue; + + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) + continue; + + if (!selectionPair(track1, track2)) + continue; + + DauVec1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + DauVec2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + HQMesonMother = DauVec1 + DauVec2; + if (!(HQMesonMother.M() > cfgMinPhiMass && HQMesonMother.M() < cfgMaxPhiMass)) + continue; + + numberPhi++; + ROOT::Math::PtEtaPhiMVector temp1(track1.pt(), track1.eta(), track1.phi(), massKa); + ROOT::Math::PtEtaPhiMVector temp2(track2.pt(), track2.eta(), track2.phi(), massKa); + ROOT::Math::PtEtaPhiMVector temp3(HQMesonMother.pt(), HQMesonMother.eta(), HQMesonMother.phi(), HQMesonMother.M()); + + hqresonanced1.push_back(temp1); + hqresonanced2.push_back(temp2); + hqresonance.push_back(temp3); + + HQId.push_back(333); + + HQd1Index.push_back(track1.globalIndex()); + HQd2Index.push_back(track2.globalIndex()); + + HQd1Charge.push_back(track1.sign()); + HQd2Charge.push_back(track2.sign()); + + HQd1TPC.push_back(track1.tpcNSigmaKa()); + HQd2TPC.push_back(track2.tpcNSigmaKa()); + + auto d1TOFHit = -1; + auto d2TOFHit = -1; + auto d1TOF = -999.0; + auto d2TOF = -999.0; + + if (track1.hasTOF()) { + d1TOFHit = 1; + d1TOF = track1.tofNSigmaKa(); + } + if (track2.hasTOF()) { + d2TOFHit = 1; + d2TOF = track2.tofNSigmaKa(); + } + + HQd1TOFHit.push_back(d1TOFHit); + HQd2TOFHit.push_back(d2TOFHit); + + HQd1TOF.push_back(d1TOF); + HQd2TOF.push_back(d2TOF); + } + } + for (auto& v0 : V0s) { + auto postrack_v0 = v0.template posTrack_as(); + auto negtrack_v0 = v0.template negTrack_as(); + + int LambdaTag = 0; + int aLambdaTag = 0; + + if (selectionV0Daughter(postrack_v0, 0) && selectionV0Daughter(negtrack_v0, 1)) + LambdaTag = 1; + + if (selectionV0Daughter(negtrack_v0, 0) && selectionV0Daughter(postrack_v0, 1)) + aLambdaTag = 1; + + if (LambdaTag == aLambdaTag) + continue; + + if (!selectionV0(collision, v0)) + continue; + + if (LambdaTag) { + if (v0.mLambda() < cfgMinLambdaMass || v0.mLambda() > cfgMaxLambdaMass) { + continue; + } + DauVec1 = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPr); + DauVec2 = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPi); + + HQId.push_back(3122); + } else if (aLambdaTag) { + if (v0.mAntiLambda() < cfgMinLambdaMass || v0.mAntiLambda() > cfgMaxLambdaMass) { + continue; + } + DauVec1 = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPi); + DauVec2 = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPr); + HQId.push_back(-3122); + } + numberLambda++; + + HQMesonMother = DauVec1 + DauVec2; + + ROOT::Math::PtEtaPhiMVector temp1(DauVec1.Pt(), DauVec1.Eta(), DauVec1.Phi(), DauVec1.M()); + ROOT::Math::PtEtaPhiMVector temp2(DauVec2.Pt(), DauVec2.Eta(), DauVec2.Phi(), DauVec2.M()); + ROOT::Math::PtEtaPhiMVector temp3(HQMesonMother.Pt(), HQMesonMother.Eta(), HQMesonMother.Phi(), HQMesonMother.M()); + + hqresonanced1.push_back(temp1); + hqresonanced2.push_back(temp2); + hqresonance.push_back(temp3); + + HQd1Index.push_back(postrack_v0.globalIndex()); + HQd2Index.push_back(negtrack_v0.globalIndex()); + + HQd1Charge.push_back(postrack_v0.sign()); + HQd2Charge.push_back(negtrack_v0.sign()); + + if (LambdaTag) { + HQd1TPC.push_back(postrack_v0.tpcNSigmaPr()); + HQd2TPC.push_back(negtrack_v0.tpcNSigmaPi()); + } else if (aLambdaTag) { + HQd1TPC.push_back(postrack_v0.tpcNSigmaPi()); + HQd2TPC.push_back(negtrack_v0.tpcNSigmaPr()); + } + + auto d1TOFHit = -1; + auto d2TOFHit = -1; + auto d1TOF = -999.0; + auto d2TOF = -999.0; + + if (postrack_v0.hasTOF()) { + d1TOFHit = 1; + d1TOF = postrack_v0.tofNSigmaPr(); + } + if (negtrack_v0.hasTOF()) { + d2TOFHit = 1; + d2TOF = negtrack_v0.tofNSigmaPr(); + } ////// TOF with PV assumption to be corrected + HQd1TOFHit.push_back(d1TOFHit); + HQd2TOFHit.push_back(d2TOFHit); + + HQd1TOF.push_back(d1TOF); + HQd2TOF.push_back(d2TOF); + } // select collision + if (numberPhi < 2 || numberLambda < 1) + return; + + keepEventDoubleHQ = true; + + if (keepEventDoubleHQ && numberPhi > 1 && numberLambda > 0 && (hqresonance.size() == hqresonanced1.size()) && (hqresonance.size() == hqresonanced2.size())) { + histos.fill(HIST("hEventstat"), 2.5); + /////////// Fill collision table/////////////// + redHQEvents(bc.globalBC(), currentRunNumber, bc.timestamp(), collision.posZ(), collision.numContrib(), centrality, numberPhi, numberLambda); + auto indexEvent = redHQEvents.lastIndex(); + //// Fill track table for HQ////////////////// + for (auto if1 = hqresonance.begin(); if1 != hqresonance.end(); ++if1) { + auto i5 = std::distance(hqresonance.begin(), if1); + HQVectorDummy = hqresonance.at(i5); + HQd1dummy = hqresonanced1.at(i5); + HQd2dummy = hqresonanced2.at(i5); + hqTrack(indexEvent, HQId.at(i5), HQVectorDummy.Px(), HQVectorDummy.Py(), HQVectorDummy.Pz(), + HQd1dummy.Px(), HQd1dummy.Py(), HQd1dummy.Pz(), HQd2dummy.Px(), HQd2dummy.Py(), HQd2dummy.Pz(), + HQVectorDummy.M(), + HQd1Index.at(i5), HQd2Index.at(i5), + HQd1Charge.at(i5), HQd2Charge.at(i5), HQd1TPC.at(i5), HQd2TPC.at(i5), + HQd1TOFHit.at(i5), HQd2TOFHit.at(i5), HQd1TOF.at(i5), HQd2TOF.at(i5)); + } + } + } // process + PROCESS_SWITCH(heptaquarktable, processHQReducedTable, "Process table creation for double hq", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfg) +{ + return WorkflowSpec{adaptAnalysisTask(cfg)}; +} diff --git a/PWGLF/TableProducer/Resonances/LFResonanceMergeDF.cxx b/PWGLF/TableProducer/Resonances/LFResonanceMergeDF.cxx deleted file mode 100644 index 3d27c68d40e..00000000000 --- a/PWGLF/TableProducer/Resonances/LFResonanceMergeDF.cxx +++ /dev/null @@ -1,318 +0,0 @@ -// 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. - -/// \file LFResonanceInitializer.cxx -/// \brief Initializes variables for the resonance candidate producers -/// -/// -/// In typical dataframes (DF), we usually observe a range of 200 to 300 collisions. -/// This limited number of collisions often results in most events having very few currentwindowneighbors() for event mixing. -/// However, for resonances analysis, a minimum of 10 currentwindowneighbors() is required. -/// To address this limitation, this script is designed to aggregate information from multiple dataframes into a single dataframe, -/// thereby increasing the number of available current window neighbors for analysis. Here, nDF refers to the number of events or collisions. -/// For instance, if the total number of collisions across all dataframes is, say, 10,836, setting nDF to 10,836 will result in the creation of a single table. -/// Conversely, if nDF is set to 2,709, it will generate four tables, each containing approximately 2,709 collisions. -/// If nDF is set to 1, it will generate tables equal to the number of parent tables. -/// -/// /// -/// \author Bong-Hwi Lim -/// Nasir Mehdi Malik -#include - -#include "Common/DataModel/PIDResponse.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Qvectors.h" -#include "Common/Core/EventPlaneHelper.h" -#include "Framework/ASoAHelpers.h" -#include "DetectorsBase/Propagator.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/LFResonanceTables.h" -#include "PWGLF/Utils/collisionCuts.h" -#include "ReconstructionDataFormats/Track.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::soa; - -/// Initializer for the resonance candidate producers - -struct reso2dfmerged { - // SliceCache cache; - Configurable nDF{"nDF", 1, "no of combination of collision"}; - Configurable cpidCut{"cpidCut", 0, "pid cut"}; - Configurable crejtpc{"crejtpc", 0, "reject electron pion"}; - Configurable crejtof{"crejtof", 0, "reject electron pion tof"}; - Configurable isPrimary{"isPrimary", 0, "is Primary only"}; - Configurable isGlobal{"isGlobal", 0, "Global tracks only"}; - Configurable cDCAXY{"cDCAXY", 1., "value of dcaxy"}; - Configurable cDCAZ{"cDCAZ", 1., "value of dcaz"}; - Configurable nsigmaPr{"nsigmaPr", 6., "nsigma value for proton"}; - Configurable nsigmaKa{"nsigmaKa", 6., "nsigma value for kaon"}; - Configurable nsigmatofPr{"nsigmatofPr", 6., "nsigma value for tof prot"}; - Configurable nsigmatofKa{"nsigmatofKa", 6., "nsigma value for tof kaon"}; - - HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - using resoCols = aod::ResoCollisions; - using resoTracks = aod::ResoTracks; - - void init(InitContext const&) - { - - const AxisSpec axisCent(110, 0, 110, "FT0 (%)"); - histos.add("Event/h1d_ft0_mult_percentile", "FT0 (%)", kTH1F, {axisCent}); - } - Produces resoCollisionsdf; - Produces reso2trksdf; - int df = 0; - - std::vector> vecOfTuples; - std::vector>> - vecOfVecOfTuples; - void processTrackDataDF(resoCols::iterator const& collision, resoTracks const& tracks) - { - - int nCollisions = nDF; - vecOfTuples.push_back(std::make_tuple(collision.globalIndex(), collision.posX(), collision.posY(), collision.posZ(), collision.cent(), collision.spherocity(), collision.evtPl())); - std::vector> - innerVector; - for (auto& track : tracks) { - if (cpidCut) { - if (!track.hasTOF()) { - if (std::abs(track.tpcNSigmaPr()) > nsigmaPr && std::abs(track.tpcNSigmaKa()) > nsigmaKa) - continue; - - if (crejtpc && ((std::abs(track.tpcNSigmaPr()) > std::abs(track.tpcNSigmaEl()) && std::abs(track.tpcNSigmaKa()) > std::abs(track.tpcNSigmaEl())) || (std::abs(track.tpcNSigmaPr()) > std::abs(track.tpcNSigmaPi()) && std::abs(track.tpcNSigmaKa()) > std::abs(track.tpcNSigmaPi())))) - continue; - - } else { - if (std::abs(track.tofNSigmaPr()) > nsigmatofPr && std::abs(track.tofNSigmaKa()) > nsigmatofKa) - continue; - - if (crejtof && ((std::abs(track.tofNSigmaPr()) > std::abs(track.tofNSigmaEl()) && std::abs(track.tofNSigmaKa()) > std::abs(track.tofNSigmaEl())) || (std::abs(track.tofNSigmaPr()) > std::abs(track.tofNSigmaPi()) && std::abs(track.tofNSigmaKa()) > std::abs(track.tofNSigmaPi())))) - continue; - } - - if (std::abs(track.dcaXY()) > cDCAXY) - continue; - if (std::abs(track.dcaZ()) > cDCAZ) - continue; - } - - innerVector.push_back(std::make_tuple( - track.globalIndex(), - track.pt(), - track.px(), - track.py(), - track.pz(), - track.eta(), - track.phi(), - track.sign(), - (uint8_t)track.tpcNClsCrossedRows(), - (uint8_t)track.tpcNClsFound(), - (uint8_t)track.itsNCls(), - track.dcaXY(), - track.dcaZ(), - track.x(), - track.alpha(), - track.hasITS(), - track.hasTPC(), - track.hasTOF(), - track.tpcNSigmaPi(), - track.tpcNSigmaKa(), - track.tpcNSigmaPr(), - track.tpcNSigmaEl(), - track.tofNSigmaPi(), - track.tofNSigmaKa(), - track.tofNSigmaPr(), - track.tofNSigmaEl(), - track.tpcSignal(), - track.passedITSRefit(), - track.passedTPCRefit(), - track.isGlobalTrackWoDCA(), - track.isGlobalTrack(), - track.isPrimaryTrack(), - track.isPVContributor(), - track.tpcCrossedRowsOverFindableCls(), - track.itsChi2NCl(), - track.tpcChi2NCl())); - } - - vecOfVecOfTuples.push_back(innerVector); - innerVector.clear(); - df++; - if (df < nCollisions) - return; - df = 0; - - for (size_t i = 0; i < vecOfTuples.size(); ++i) { - const auto& tuple = vecOfTuples[i]; - const auto& innerVector = vecOfVecOfTuples[i]; - - histos.fill(HIST("Event/h1d_ft0_mult_percentile"), std::get<3>(tuple)); - resoCollisionsdf(std::get<0>(tuple), 0, std::get<1>(tuple), std::get<2>(tuple), std::get<3>(tuple), std::get<4>(tuple), std::get<5>(tuple), std::get<6>(tuple), 0., 0., 0., 0., 0, collision.trackOccupancyInTimeRange()); - // LOGF(info, "collisions: Index = %d ) %f - %f - %f %f %d -- %d", std::get<0>(tuple).globalIndex(),std::get<1>(tuple),std::get<2>(tuple), std::get<3>(tuple), std::get<4>(tuple), std::get<5>(tuple).size(),resoCollisionsdf.lastIndex()); - - for (const auto& tuple : innerVector) { - reso2trksdf(resoCollisionsdf.lastIndex(), - std::get<0>(tuple), - std::get<1>(tuple), - std::get<2>(tuple), - std::get<3>(tuple), - std::get<4>(tuple), - std::get<5>(tuple), - std::get<6>(tuple), - std::get<7>(tuple), - std::get<8>(tuple), - std::get<9>(tuple), - std::get<10>(tuple), - std::get<11>(tuple), - std::get<12>(tuple), - std::get<13>(tuple), - std::get<14>(tuple), - std::get<15>(tuple), - std::get<16>(tuple), - std::get<17>(tuple), - std::get<18>(tuple), - std::get<19>(tuple), - std::get<20>(tuple), - std::get<21>(tuple), - std::get<22>(tuple), - std::get<23>(tuple), - std::get<24>(tuple), - std::get<25>(tuple), - std::get<26>(tuple), - std::get<27>(tuple), - std::get<28>(tuple), - std::get<29>(tuple), - std::get<30>(tuple), - std::get<31>(tuple), - std::get<32>(tuple), - std::get<33>(tuple), - std::get<34>(tuple), - std::get<35>(tuple)); - } - } - - vecOfTuples.clear(); - vecOfVecOfTuples.clear(); // - } - - PROCESS_SWITCH(reso2dfmerged, processTrackDataDF, "Process for data merged DF", true); - - void processLambdaStarCandidate(resoCols::iterator const& collision, resoTracks const& - tracks) - { - - if (doprocessTrackDataDF) - LOG(fatal) << "Disable processTrackDataDF first!"; - - histos.fill(HIST("Event/h1d_ft0_mult_percentile"), collision.cent()); - - resoCollisionsdf(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.cent(), collision.spherocity(), collision.evtPl(), 0., 0., 0., 0., 0, collision.trackOccupancyInTimeRange()); - - for (auto& track : tracks) { - if (isPrimary && !track.isPrimaryTrack()) - continue; - if (isGlobal && !track.isGlobalTrack()) - continue; - if (!track.hasTOF()) { - if (std::abs(track.tpcNSigmaPr()) > nsigmaPr && std::abs(track.tpcNSigmaKa()) > nsigmaKa) - continue; - - if (crejtpc && ((std::abs(track.tpcNSigmaPr()) > std::abs(track.tpcNSigmaEl()) && std::abs(track.tpcNSigmaKa()) > std::abs(track.tpcNSigmaEl())) || (std::abs(track.tpcNSigmaPr()) > std::abs(track.tpcNSigmaPi()) && std::abs(track.tpcNSigmaKa()) > std::abs(track.tpcNSigmaPi())))) - continue; - - } else { - if (std::abs(track.tofNSigmaPr()) > nsigmatofPr && std::abs(track.tofNSigmaKa()) > nsigmatofKa) - continue; - - if (crejtof && ((std::abs(track.tofNSigmaPr()) > std::abs(track.tofNSigmaEl()) && std::abs(track.tofNSigmaKa()) > std::abs(track.tofNSigmaEl())) || (std::abs(track.tofNSigmaPr()) > std::abs(track.tofNSigmaPi()) && std::abs(track.tofNSigmaKa()) > std::abs(track.tofNSigmaPi())))) - continue; - } - - if (std::abs(track.dcaXY()) > cDCAXY) - continue; - if (std::abs(track.dcaZ()) > cDCAZ) - continue; - - reso2trksdf(resoCollisionsdf.lastIndex(), - track.globalIndex(), - track.pt(), - track.px(), - track.py(), - track.pz(), - track.eta(), - track.phi(), - track.sign(), - (uint8_t)track.tpcNClsCrossedRows(), - (uint8_t)track.tpcNClsFound(), - (uint8_t)track.itsNCls(), - track.dcaXY(), - track.dcaZ(), - track.x(), - track.alpha(), - track.hasITS(), - track.hasTPC(), - track.hasTOF(), - track.tpcNSigmaPi(), - track.tpcNSigmaKa(), - track.tpcNSigmaPr(), - track.tpcNSigmaEl(), - track.tofNSigmaPi(), - track.tofNSigmaKa(), - track.tofNSigmaPr(), - track.tofNSigmaEl(), - track.tpcSignal(), - track.passedITSRefit(), - track.passedTPCRefit(), - track.isGlobalTrackWoDCA(), - track.isGlobalTrack(), - track.isPrimaryTrack(), - track.isPVContributor(), - track.tpcCrossedRowsOverFindableCls(), - track.itsChi2NCl(), - track.tpcChi2NCl()); - } - } - PROCESS_SWITCH(reso2dfmerged, processLambdaStarCandidate, "Process for lambda star candidate", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/PWGLF/TableProducer/Resonances/cksspinalignment.cxx b/PWGLF/TableProducer/Resonances/cksspinalignment.cxx new file mode 100644 index 00000000000..91bb6662dbc --- /dev/null +++ b/PWGLF/TableProducer/Resonances/cksspinalignment.cxx @@ -0,0 +1,386 @@ +// 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. + +/// \file cksspinalignment.cxx +/// \brief Table producer for Charged KStar spin alignment +/// +/// \author prottay.das@cern.ch + +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/LFCKSSpinalignmentTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGMM/Mult/DataModel/Index.h" // for Particles2Tracks table + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector2D.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" + +#include + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; +using namespace o2::aod::rctsel; + +struct cksspinalignment { + + Produces kshortpionEvent; + Produces kshortpionPair; + + Service ccdb; + + struct : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } rctCut; + + Configurable cfgCutOccupancy{"cfgCutOccupancy", 2000, "Occupancy cut"}; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutCentralityMax{"cfgCutCentralityMax", 80.0f, "Accepted maximum Centrality"}; + Configurable cfgCutCentralityMin{"cfgCutCentralityMin", 0.0f, "Accepted minimum Centrality"}; + + // Configs for track + Configurable cfgCutPt{"cfgCutPt", 0.2, "Pt cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + + // Configs for pion + struct : ConfigurableGroup { + Configurable itsPIDSelection{"itsPIDSelection", true, "PID ITS"}; + Configurable lowITSPIDNsigma{"lowITSPIDNsigma", -3.0, "lower cut on PID nsigma for ITS"}; + Configurable highITSPIDNsigma{"highITSPIDNsigma", 3.0, "higher cut on PID nsigma for ITS"}; + Configurable itsclusterPiMeson{"itsclusterPiMeson", 5, "Minimum number of ITS cluster for pi meson track"}; + Configurable tpcCrossedRowsPiMeson{"tpcCrossedRowsPiMeson", 80, "Minimum number of TPC Crossed Rows for pi meson track"}; + Configurable cutDCAxyPiMeson{"cutDCAxyPiMeson", 0.1, "Maximum DCAxy for pi meson track"}; + Configurable cutDCAzPiMeson{"cutDCAzPiMeson", 0.1, "Maximum DCAz for pi meson track"}; + Configurable cutEtaPiMeson{"cutEtaPiMeson", 0.8, "Maximum eta for pi meson track"}; + Configurable cutPTPiMeson{"cutPTPiMeson", 0.8, "Maximum pt for pi meson track"}; + Configurable usePID{"usePID", true, "Flag for using PID selection for pi meson track"}; + Configurable nsigmaCutTPCPiMeson{"nsigmaCutTPCPiMeson", 3.0, "Maximum nsigma cut TPC for pi meson track"}; + Configurable nsigmaCutTOFPiMeson{"nsigmaCutTOFPiMeson", 3.0, "Maximum nsigma cut TOF for pi meson track"}; + Configurable cutTOFBetaPiMeson{"cutTOFBetaPiMeson", 3.0, "Maximum beta cut for pi meson track"}; + } grpPion; + + // Configs for V0 + Configurable confV0PtMin{"confV0PtMin", 0.f, "Minimum transverse momentum of V0"}; + Configurable confV0PtMax{"confV0PtMax", 1000.f, "Maximum transverse momentum of V0"}; + Configurable confV0Rap{"confV0Rap", 0.8f, "Rapidity range of V0"}; + Configurable confV0DCADaughMax{"confV0DCADaughMax", 1.0f, "Maximum DCA between the V0 daughters"}; + Configurable confV0CPAMin{"confV0CPAMin", 0.9998f, "Minimum CPA of V0"}; + Configurable confV0TranRadV0Min{"confV0TranRadV0Min", 1.5f, "Minimum transverse radius"}; + Configurable confV0TranRadV0Max{"confV0TranRadV0Max", 100.f, "Maximum transverse radius"}; + Configurable cMaxV0DCA{"cMaxV0DCA", 1.2, "Maximum V0 DCA to PV"}; + Configurable cMinV0DCAPi{"cMinV0DCAPi", 0.05, "Minimum V0 daughters DCA to PV for Pi"}; + Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 50, "Maximum V0 life time"}; + Configurable qtArmenterosMin{"qtArmenterosMin", 0.2, "Minimum armenteros cut for K0s"}; + // config for V0 daughters + Configurable confDaughEta{"confDaughEta", 0.8f, "V0 Daugh sel: max eta"}; + Configurable cfgDaughPiPt{"cfgDaughPiPt", 0.2, "minimum daughter pion pt"}; + Configurable confDaughTPCnclsMin{"confDaughTPCnclsMin", 50.f, "V0 Daugh sel: Min. nCls TPC"}; + Configurable confDaughTPCncrwsMin{"confDaughTPCncrwsMin", 70.f, "V0 Daugh sel: Min. nCrws TPC"}; + Configurable confDaughPIDCuts{"confDaughPIDCuts", 3, "PID selections for Kshortpion daughters"}; + + Configurable iMNbins{"iMNbins", 50, "Number of bins in invariant mass"}; + Configurable lbinIM{"lbinIM", 1.09, "lower bin value in IM histograms"}; + Configurable hbinIM{"hbinIM", 1.14, "higher bin value in IM histograms"}; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + RCTFlagsChecker rctChecker; + void init(o2::framework::InitContext&) + { + rctChecker.init(rctCut.cfgEvtRCTFlagCheckerLabel, rctCut.cfgEvtRCTFlagCheckerZDCCheck, rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + AxisSpec thnAxisInvMass{iMNbins, lbinIM, hbinIM, "#it{M} (GeV/#it{c}^{2})"}; + histos.add("hEvtSelInfo", "hEvtSelInfo", kTH1F, {{5, 0, 5.0}}); + histos.add("hTrkSelInfo", "hTrkSelInfo", kTH1F, {{5, 0, 5.0}}); + histos.add("hKShortMass", "hKShortMass", kTH1F, {thnAxisInvMass}); + histos.add("hV0Info", "hV0Info", kTH1F, {{5, 0, 5.0}}); + } + + template + bool selectionTrack(const T& candidate) + { + if (candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() >= grpPion.itsclusterPiMeson && candidate.tpcNClsCrossedRows() > grpPion.tpcCrossedRowsPiMeson && std::abs(candidate.dcaXY()) <= grpPion.cutDCAxyPiMeson && std::abs(candidate.dcaZ()) <= grpPion.cutDCAzPiMeson && std::abs(candidate.eta()) <= grpPion.cutEtaPiMeson && candidate.pt() >= grpPion.cutPTPiMeson) { + return true; + } + return false; + } + + template + bool selectionPID(const T& candidate) + { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < grpPion.nsigmaCutTPCPiMeson) { + return true; + } + if (candidate.hasTOF() && candidate.beta() > grpPion.cutTOFBetaPiMeson && std::abs(candidate.tpcNSigmaPi()) < grpPion.nsigmaCutTPCPiMeson && std::abs(candidate.tofNSigmaPi()) < grpPion.nsigmaCutTOFPiMeson) { + return true; + } + return false; + } + + template + bool selectionV0(Collision const& collision, V0 const& candidate) + { + if (std::abs(candidate.dcav0topv()) > cMaxV0DCA) { + return false; + } + const float pT = candidate.pt(); + const float tranRad = candidate.v0radius(); + const float dcaDaughv0 = std::abs(candidate.dcaV0daughters()); + const float cpav0 = candidate.v0cosPA(); + float ctauKShort = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * (o2::constants::physics::MassK0); + + if (pT < confV0PtMin) { + return false; + } + if (pT > confV0PtMax) { + return false; + } + if (dcaDaughv0 > confV0DCADaughMax) { + return false; + } + if (cpav0 < confV0CPAMin) { + return false; + } + if (tranRad < confV0TranRadV0Min) { + return false; + } + if (tranRad > confV0TranRadV0Max) { + return false; + } + if (std::abs(ctauKShort) > cMaxV0LifeTime) { + return false; + } + if ((candidate.qtarm() / std::abs(candidate.alpha())) < qtArmenterosMin) { + return false; + } + if (std::abs(candidate.yK0Short()) > confV0Rap) { // use full rapidity 0.8 for K0s + return false; + } + return true; + } + + template + bool isSelectedV0Daughter(V0 const& candidate) + { + auto postrack = candidate.template posTrack_as(); + auto negtrack = candidate.template negTrack_as(); + + const auto ncrfc = 0.8; + + if (postrack.sign() < 0 || negtrack.sign() > 0) { + return false; + } + if (postrack.tpcNClsCrossedRows() < confDaughTPCncrwsMin || negtrack.tpcNClsCrossedRows() < confDaughTPCncrwsMin) { + return false; + } + if (postrack.tpcNClsFound() < confDaughTPCnclsMin || negtrack.tpcNClsFound() < confDaughTPCnclsMin) { + return false; + } + if (postrack.tpcCrossedRowsOverFindableCls() < ncrfc || negtrack.tpcCrossedRowsOverFindableCls() < ncrfc) { + return false; + } + if (std::abs(postrack.tpcNSigmaPi()) > confDaughPIDCuts || std::abs(negtrack.tpcNSigmaPi()) > confDaughPIDCuts) { + return false; + } + if (candidate.positivept() < cfgDaughPiPt || candidate.negativept() < cfgDaughPiPt) { + return false; + } + if (std::abs(candidate.positiveeta()) > confDaughEta || std::abs(candidate.negativeeta()) > confDaughEta) { + return false; + } + if (std::abs(candidate.dcapostopv()) < cMinV0DCAPi || std::abs(candidate.dcanegtopv()) < cMinV0DCAPi) { + return false; + } + + return true; + } + + std::tuple getK0sTags(const auto& v0, const auto& collision) + { + // auto postrack = v0.template posTrack_as(); + // auto negtrack = v0.template negTrack_as(); + + int kshortTag = 0; + + if (isSelectedV0Daughter(v0) && v0.mK0Short() > lbinIM && v0.mK0Short() < hbinIM) { + kshortTag = 1; + } + + if (!kshortTag) { + return {0, false}; // No valid tags + } + + if (!selectionV0(collision, v0)) { + return {0, false}; // Fails selection + } + + return {kshortTag, true}; // Valid candidate + } + + ROOT::Math::PxPyPzMVector kshort, pion, pionbach, antiPion; + ROOT::Math::PxPyPzMVector kshortDummy, pionDummy; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter centralityFilter = (nabs(aod::cent::centFT0C) < cfgCutCentralityMax && nabs(aod::cent::centFT0C) > cfgCutCentralityMin); + Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && (aod::track::pt) > cfgCutPt); + + using EventCandidates = soa::Filtered>; + using AllTrackCandidates = soa::Filtered>; + using ResoV0s = aod::V0Datas; + void processData(EventCandidates::iterator const& collision, AllTrackCandidates const& tracks, ResoV0s const& V0s) + { + o2::aod::ITSResponse itsResponse; + std::vector kshortMother, pionBachelor; + std::vector v0Cospa = {}; + std::vector v0Radius = {}; + std::vector dcaPositive = {}; + std::vector dcaNegative = {}; + std::vector positiveIndex = {}; + std::vector negativeIndex = {}; + std::vector dcaBetweenDaughter = {}; + std::vector v0Lifetime = {}; + // std::vector armenteros = {}; + std::vector pionBachelorIndex = {}; + std::vector pionBachelorSign = {}; + std::vector pionBachelorTPC = {}; + std::vector pionBachelorTOF = {}; + std::vector pionBachelorTOFHit = {}; + + int numbV0 = 0; + auto centrality = collision.centFT0C(); + // auto vz = collision.posZ(); + int occupancy = collision.trackOccupancyInTimeRange(); + auto psiFT0C = collision.psiFT0C(); + auto psiFT0A = collision.psiFT0A(); + auto psiTPC = collision.psiTPC(); + // auto psiTPCR = collision.psiTPCR(); + // auto psiTPCL = collision.psiTPCL(); + histos.fill(HIST("hEvtSelInfo"), 0.5); + if ((rctCut.requireRCTFlagChecker && rctChecker(collision)) && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && collision.selection_bit(aod::evsel::kNoITSROFrameBorder) && collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) && collision.sel8() && collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll) && occupancy < cfgCutOccupancy) { + histos.fill(HIST("hEvtSelInfo"), 1.5); + if (collision.triggereventep()) { + histos.fill(HIST("hEvtSelInfo"), 2.5); + + for (const auto& track1 : tracks) { + histos.fill(HIST("hTrkSelInfo"), 0.5); + if (!selectionTrack(track1)) { + continue; + } + histos.fill(HIST("hTrkSelInfo"), 1.5); + + if (grpPion.itsPIDSelection && !(itsResponse.nSigmaITS(track1) > grpPion.lowITSPIDNsigma && itsResponse.nSigmaITS(track1) < grpPion.highITSPIDNsigma)) { + continue; + } + histos.fill(HIST("hTrkSelInfo"), 2.5); + + if (grpPion.usePID && !selectionPID(track1)) { + continue; + } + histos.fill(HIST("hTrkSelInfo"), 3.5); + + auto track1ID = track1.globalIndex(); + auto track1sign = track1.sign(); + auto track1nsigTPC = track1.tpcNSigmaPi(); + auto track1nsigTOF = -999.9; + auto track1TOFHit = -1; + if (track1.hasTOF()) { + track1TOFHit = 1; + track1nsigTOF = track1.tofNSigmaPi(); + histos.fill(HIST("hTrkSelInfo"), 4.5); + } + pionbach = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), o2::constants::physics::MassPionCharged); + for (const auto& v0 : V0s) { + histos.fill(HIST("hV0Info"), 0.5); + auto [kshortTag, isValid] = getK0sTags(v0, collision); + if (kshortTag && isValid) { + histos.fill(HIST("hV0Info"), 1.5); + auto postrack1 = v0.template posTrack_as(); + auto negtrack1 = v0.template negTrack_as(); + positiveIndex.push_back(postrack1.globalIndex()); + negativeIndex.push_back(negtrack1.globalIndex()); + v0Cospa.push_back(v0.v0cosPA()); + v0Radius.push_back(v0.v0radius()); + dcaPositive.push_back(std::abs(v0.dcapostopv())); + dcaNegative.push_back(std::abs(v0.dcanegtopv())); + dcaBetweenDaughter.push_back(std::abs(v0.dcaV0daughters())); + v0Lifetime.push_back(v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * (o2::constants::physics::MassK0)); + // armenteros.push_back((v0.qtarm() / std::abs(v0.alpha()))); + + pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassPionCharged); + antiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassPionCharged); + kshort = pion + antiPion; + // chargedkstar = kshort + pionbach; + kshortMother.push_back(kshort); + // chargedkstarMother.push_back(chargedkstar); + pionBachelor.push_back(pionbach); + pionBachelorIndex.push_back(track1ID); + pionBachelorSign.push_back(track1sign); + pionBachelorTPC.push_back(track1nsigTPC); + pionBachelorTOF.push_back(track1nsigTOF); + pionBachelorTOFHit.push_back(track1TOFHit); + histos.fill(HIST("hKShortMass"), kshort.M()); + } + numbV0 = numbV0 + 1; + } + } + if (numbV0 > 1 && v0Cospa.size() > 1) { + histos.fill(HIST("hEvtSelInfo"), 3.5); + kshortpionEvent(centrality, collision.index(), psiFT0C, psiFT0A, psiTPC); + auto indexEvent = kshortpionEvent.lastIndex(); + //// Fill track table for Charged KStar////////////////// + for (auto icks = kshortMother.begin(); icks != kshortMother.end(); ++icks) { + auto iter = std::distance(kshortMother.begin(), icks); + kshortDummy = kshortMother.at(iter); + // chargedkstarDummy = chargedkstarMother.at(iter); + pionDummy = pionBachelor.at(iter); + + kshortpionPair(indexEvent, v0Cospa.at(iter), v0Radius.at(iter), dcaPositive.at(iter), dcaNegative.at(iter), dcaBetweenDaughter.at(iter), v0Lifetime.at(iter), kshortDummy.Px(), kshortDummy.Py(), kshortDummy.Pz(), kshortDummy.M(), pionDummy.Px(), pionDummy.Py(), pionDummy.Pz(), pionBachelorSign.at(iter), pionBachelorTPC.at(iter), pionBachelorTOFHit.at(iter), pionBachelorTOF.at(iter), pionBachelorIndex.at(iter), positiveIndex.at(iter), negativeIndex.at(iter)); + } + } + } + } + } + PROCESS_SWITCH(cksspinalignment, processData, "Process data", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Resonances/doublephitable.cxx b/PWGLF/TableProducer/Resonances/doublephitable.cxx index ae4e75a26a5..d02ab3d3734 100644 --- a/PWGLF/TableProducer/Resonances/doublephitable.cxx +++ b/PWGLF/TableProducer/Resonances/doublephitable.cxx @@ -45,6 +45,7 @@ #include "DataFormatsTPC/BetheBlochAleph.h" #include "CCDB/BasicCCDBManager.h" #include "CCDB/CcdbApi.h" +#include "Common/DataModel/PIDResponseITS.h" using namespace o2; using namespace o2::framework; @@ -143,6 +144,7 @@ struct doublephitable { ROOT::Math::PxPyPzMVector KaonPlus, KaonMinus, PhiMesonMother, PhiVectorDummy, Phid1dummy, Phid2dummy; void processPhiReducedTable(EventCandidates::iterator const& collision, TrackCandidates const&, aod::BCsWithTimestamps const&) { + o2::aod::ITSResponse itsResponse; bool keepEventDoublePhi = false; int numberPhi = 0; auto currentRunNumber = collision.bc_as().runNumber(); @@ -179,6 +181,9 @@ struct doublephitable { if (!selectionPID(track1)) { continue; } + if (!(itsResponse.nSigmaITS(track1) > -3.0 && itsResponse.nSigmaITS(track1) < 3.0)) { + continue; + } Npostrack = Npostrack + 1; qaRegistry.fill(HIST("hNsigmaPtkaonTPC"), track1.tpcNSigmaKa(), track1.pt()); if (track1.hasTOF()) { @@ -201,6 +206,9 @@ struct doublephitable { if (track2ID == track1ID) { continue; } + if (!(itsResponse.nSigmaITS(track2) > -3.0 && itsResponse.nSigmaITS(track2) < 3.0)) { + continue; + } if (!selectionPair(track1, track2)) { continue; } diff --git a/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx b/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx index 93a41452ece..ce0cdcf3af5 100644 --- a/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx +++ b/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx @@ -46,6 +46,7 @@ #include "DataFormatsTPC/BetheBlochAleph.h" #include "CCDB/BasicCCDBManager.h" #include "CCDB/CcdbApi.h" +#include "Common/DataModel/PIDResponseITS.h" using namespace o2; using namespace o2::framework; @@ -248,6 +249,15 @@ struct f1protonreducedtable { return true; } + template + bool selectionGlobalTrack(const T& candidate) + { + if (!(candidate.isGlobalTrack() && candidate.isPVContributor())) { + return false; + } + return true; + } + template double updatePID(T const& track, double bgScaling, std::vector BB) { @@ -493,6 +503,7 @@ struct f1protonreducedtable { void processF1ProtonReducedTable(EventCandidates::iterator const& collision, aod::BCsWithTimestamps const&, PrimaryTrackCandidates const& tracks, ResoV0s const& V0s) { + o2::aod::ITSResponse itsResponse; bool keepEventF1Proton = false; int numberF1 = 0; // keep track of indices @@ -586,8 +597,12 @@ struct f1protonreducedtable { if (zorroSelected) { hProcessedEvents->Fill(1.5); for (auto& track : tracks) { - if (!isSelectedTrack(track)) + if (!isSelectedTrack(track)) { continue; + } + if (!selectionGlobalTrack(track)) { + continue; + } qaRegistry.fill(HIST("hDCAxy"), track.dcaXY()); qaRegistry.fill(HIST("hDCAz"), track.dcaZ()); qaRegistry.fill(HIST("hEta"), track.eta()); @@ -616,7 +631,7 @@ struct f1protonreducedtable { nTPCSigmaN[0] = updatePID(track, bgScalingPion, BBAntipion); } - if ((track.sign() > 0 && SelectionPID(track, strategyPIDPion, 0, nTPCSigmaP[0])) || (track.sign() < 0 && SelectionPID(track, strategyPIDPion, 0, nTPCSigmaN[0]))) { + if ((track.sign() > 0 && SelectionPID(track, strategyPIDPion, 0, nTPCSigmaP[0]) && (itsResponse.nSigmaITS(track) > -3.0 && itsResponse.nSigmaITS(track) < 3.0)) || (track.sign() < 0 && SelectionPID(track, strategyPIDPion, 0, nTPCSigmaN[0]) && (itsResponse.nSigmaITS(track) > -3.0 && itsResponse.nSigmaITS(track) < 3.0))) { ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), massPi); pions.push_back(temp); PionIndex.push_back(track.globalIndex()); @@ -637,7 +652,7 @@ struct f1protonreducedtable { PionTOFHit.push_back(PionTOF); } - if ((track.pt() > cMinKaonPt && track.sign() > 0 && SelectionPID(track, strategyPIDKaon, 1, nTPCSigmaP[1])) || (track.pt() > cMinKaonPt && track.sign() < 0 && SelectionPID(track, strategyPIDKaon, 1, nTPCSigmaN[1]))) { + if ((track.pt() > cMinKaonPt && track.sign() > 0 && SelectionPID(track, strategyPIDKaon, 1, nTPCSigmaP[1]) && (itsResponse.nSigmaITS(track) > -3.0 && itsResponse.nSigmaITS(track) < 3.0)) || (track.pt() > cMinKaonPt && track.sign() < 0 && SelectionPID(track, strategyPIDKaon, 1, nTPCSigmaN[1]) && (itsResponse.nSigmaITS(track) > -3.0 && itsResponse.nSigmaITS(track) < 3.0))) { ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), massKa); kaons.push_back(temp); KaonIndex.push_back(track.globalIndex()); @@ -660,7 +675,7 @@ struct f1protonreducedtable { KaonTOFHit.push_back(KaonTOF); } - if ((track.pt() < cMaxProtonPt && track.sign() > 0 && SelectionPID(track, strategyPIDProton, 2, nTPCSigmaP[2])) || (track.pt() < cMaxProtonPt && track.sign() < 0 && SelectionPID(track, strategyPIDProton, 2, nTPCSigmaN[2]))) { + if ((track.pt() < cMaxProtonPt && track.sign() > 0 && SelectionPID(track, strategyPIDProton, 2, nTPCSigmaP[2]) && (itsResponse.nSigmaITS(track) > -3.0 && itsResponse.nSigmaITS(track) < 3.0)) || (track.pt() < cMaxProtonPt && track.sign() < 0 && SelectionPID(track, strategyPIDProton, 2, nTPCSigmaN[2]) && (itsResponse.nSigmaITS(track) > -3.0 && itsResponse.nSigmaITS(track) < 3.0))) { ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), massPr); protons.push_back(temp); ProtonIndex.push_back(track.globalIndex()); diff --git a/PWGLF/TableProducer/Resonances/resonanceInitializer.cxx b/PWGLF/TableProducer/Resonances/resonanceInitializer.cxx index 53708c43eae..c318d1d57d9 100644 --- a/PWGLF/TableProducer/Resonances/resonanceInitializer.cxx +++ b/PWGLF/TableProducer/Resonances/resonanceInitializer.cxx @@ -47,6 +47,7 @@ using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::constants::physics; using namespace o2::constants::math; +using namespace o2::aod::rctsel; /// Initializer for the resonance candidate producers struct ResonanceInitializer { @@ -58,10 +59,18 @@ struct ResonanceInitializer { Service pdg; Produces resoCollisions; + Produces resoCollisionColls; Produces resoMCCollisions; + Produces resoSpheroCollisions; + Produces resoEvtPlCollisions; Produces reso2trks; + Produces resoTrackTracks; + Produces reso2microtrks; + Produces resoMicroTrackTracks; Produces reso2v0s; + Produces resoV0V0s; Produces reso2cascades; + Produces resoCascadeCascades; Produces reso2mctracks; Produces reso2mcparents; Produces reso2mcv0s; @@ -75,6 +84,10 @@ struct ResonanceInitializer { Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable cfgFatalWhenNull{"cfgFatalWhenNull", true, "Fatal when null on ccdb access"}; + Configurable cfgFillMicroTracks{"cfgFillMicroTracks", false, "Fill micro tracks"}; + Configurable cfgBypassTrackFill{"cfgBypassTrackFill", false, "Bypass track fill"}; + Configurable cfgBypassCollIndexFill{"cfgBypassCollIndexFill", false, "Bypass collision index fill"}; + Configurable cfgBypassTrackIndexFill{"cfgBypassTrackIndexFill", false, "Bypass track index fill"}; // Configurables Configurable dBzInput{"dBzInput", -999, "bz field, -999 is automatic"}; @@ -91,17 +104,28 @@ struct ResonanceInitializer { /// Event cuts o2::analysis::CollisonCuts colCuts; - Configurable cfgEvtZvtx{"cfgEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; - Configurable cfgEvtOccupancyInTimeRange{"cfgEvtOccupancyInTimeRange", -1, "Evt sel: maximum track occupancy"}; - Configurable cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"}; - Configurable cfgEvtTriggerSel{"cfgEvtTriggerSel", 8, "Evt sel: trigger"}; - Configurable cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"}; - Configurable cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; - Configurable cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; - Configurable cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; - Configurable cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", false, "Evt sel: apply Z-vertex time difference"}; - Configurable cfgEvtPileupRejection{"cfgEvtPileupRejection", false, "Evt sel: apply pileup rejection"}; - Configurable cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + + struct : ConfigurableGroup { + Configurable cfgEvtZvtx{"cfgEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable cfgEvtOccupancyInTimeRangeMax{"cfgEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; + Configurable cfgEvtOccupancyInTimeRangeMin{"cfgEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; + Configurable cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"}; + Configurable cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"}; + Configurable cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; + Configurable cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; + Configurable cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; + Configurable cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", false, "Evt sel: apply Z-vertex time difference"}; + Configurable cfgEvtPileupRejection{"cfgEvtPileupRejection", false, "Evt sel: apply pileup rejection"}; + Configurable cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + Configurable cfgEvtCollInTimeRangeStandard{"cfgEvtCollInTimeRangeStandard", false, "Evt sel: apply NoCollInTimeRangeStandard"}; + Configurable cfgEvtRun2AliEventCuts{"cfgEvtRun2AliEventCuts", true, "Evt sel: apply Run2 AliEventCuts"}; + Configurable cfgEvtRun2INELgtZERO{"cfgEvtRun2INELgtZERO", false, "Evt sel: apply Run2 INELgtZERO"}; + Configurable cfgEvtUseRCTFlagChecker{"cfgEvtUseRCTFlagChecker", false, "Evt sel: use RCT flag checker"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", false, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } EventCuts; + RCTFlagsChecker rctChecker; Configurable cfgMultName{"cfgMultName", "FT0M", "The name of multiplicity estimator"}; @@ -141,6 +165,44 @@ struct ResonanceInitializer { Configurable cMinCascRadius{"cMinCascRadius", 0.0, "Minimum Cascade radius from PV"}; Configurable cCascMassResol{"cCascMassResol", 999, "Cascade mass resolution"}; + // Derived dataset selections + struct : ConfigurableGroup { + Configurable cfgFillPionTracks{"cfgFillPionTracks", false, "Fill pion tracks"}; + Configurable cfgFillKaonTracks{"cfgFillKaonTracks", false, "Fill kaon tracks"}; + Configurable cfgFillProtonTracks{"cfgFillProtonTracks", false, "Fill proton tracks"}; + Configurable cfgFillPionMicroTracks{"cfgFillPionMicroTracks", false, "Fill pion micro tracks"}; + Configurable cfgFillKaonMicroTracks{"cfgFillKaonMicroTracks", false, "Fill kaon micro tracks"}; + Configurable cfgFillProtonMicroTracks{"cfgFillProtonMicroTracks", false, "Fill proton micro tracks"}; + Configurable cfgFillK0s{"cfgFillK0s", false, "Fill K0s"}; + Configurable cfgFillLambda0{"cfgFillLambda0", false, "Fill Lambda0"}; + Configurable cfgFillXi0{"cfgFillXi0", false, "Fill Xi0"}; + Configurable cfgFillOmega0{"cfgFillOmega0", false, "Fill Omega0"}; + } FilterForDerivedTables; + + // Secondary cuts + // Secondary Selection for K0s + struct : ConfigurableGroup { + Configurable cfgSecondaryRequire{"cfgSecondaryRequire", true, "Secondary cuts on/off"}; + Configurable cfgSecondaryArmenterosCut{"cfgSecondaryArmenterosCut", true, "cut on Armenteros-Podolanski graph"}; + Configurable cfgSecondaryCrossMassHypothesisCut{"cfgSecondaryCrossMassHypothesisCut", false, "Apply cut based on the lambda mass hypothesis"}; + + Configurable cfgByPassDauPIDSelection{"cfgByPassDauPIDSelection", true, "Bypass Daughters PID selection"}; + Configurable cfgSecondaryDauDCAMax{"cfgSecondaryDauDCAMax", 0.2, "Maximum DCA Secondary daughters to PV"}; + Configurable cfgSecondaryDauPosDCAtoPVMin{"cfgSecondaryDauPosDCAtoPVMin", 0.0, "Minimum DCA Secondary positive daughters to PV"}; + Configurable cfgSecondaryDauNegDCAtoPVMin{"cfgSecondaryDauNegDCAtoPVMin", 0.0, "Minimum DCA Secondary negative daughters to PV"}; + + Configurable cfgSecondaryPtMin{"cfgSecondaryPtMin", 0.f, "Minimum transverse momentum of Secondary"}; + Configurable cfgSecondaryRapidityMax{"cfgSecondaryRapidityMax", 0.5, "Maximum rapidity of Secondary"}; + Configurable cfgSecondaryRadiusMin{"cfgSecondaryRadiusMin", 0.0, "Minimum transverse radius of Secondary"}; + Configurable cfgSecondaryRadiusMax{"cfgSecondaryRadiusMax", 999.9, "Maximum transverse radius of Secondary"}; + Configurable cfgSecondaryCosPAMin{"cfgSecondaryCosPAMin", 0.998, "Mininum cosine pointing angle of Secondary"}; + Configurable cfgSecondaryDCAtoPVMax{"cfgSecondaryDCAtoPVMax", 0.4, "Maximum DCA Secondary to PV"}; + Configurable cfgSecondaryProperLifetimeMax{"cfgSecondaryProperLifetimeMax", 20., "Maximum Secondary Lifetime"}; + Configurable cfgSecondaryparamArmenterosCut{"cfgSecondaryparamArmenterosCut", 0.2, "parameter for Armenteros Cut"}; + Configurable cfgSecondaryMassWindow{"cfgSecondaryMassWindow", 0.03, "Secondary inv mass selection window"}; + Configurable cfgSecondaryCrossMassCutWindow{"cfgSecondaryCrossMassCutWindow", 0.05, "Secondary inv mass selection window with (anti)lambda hypothesis"}; + } SecondaryCuts; + HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; // Pre-filters for efficient process @@ -180,7 +242,7 @@ struct ResonanceInitializer { || (nabs(aod::mcparticle::pdgCode) == 123314) // Xi(1820)0 || (nabs(aod::mcparticle::pdgCode) == 123324); // Xi(1820)-0 - using ResoEvents = soa::Join; + using ResoEvents = soa::Join; using ResoRun2Events = soa::Join; using ResoEventsMC = soa::Join; using ResoRun2EventsMC = soa::Join; @@ -192,6 +254,145 @@ struct ResonanceInitializer { using ResoCascadesMC = soa::Join; using BCsWithRun2Info = soa::Join; + template + bool filterMicroTrack(T const& track) + { + // if no selection is requested, return true + if (!FilterForDerivedTables.cfgFillPionMicroTracks && !FilterForDerivedTables.cfgFillKaonMicroTracks && !FilterForDerivedTables.cfgFillProtonMicroTracks) + return true; + if (FilterForDerivedTables.cfgFillPionMicroTracks) { + if (std::abs(track.tpcNSigmaPi()) < pidnSigmaPreSelectionCut) + return true; + } + if (FilterForDerivedTables.cfgFillKaonMicroTracks) { + if (std::abs(track.tpcNSigmaKa()) < pidnSigmaPreSelectionCut) + return true; + } + if (FilterForDerivedTables.cfgFillProtonMicroTracks) { + if (std::abs(track.tpcNSigmaPr()) < pidnSigmaPreSelectionCut) + return true; + } + return false; + } + + template + bool filterTrack(T const& track) + { + // if no selection is requested, return true + if (!FilterForDerivedTables.cfgFillPionTracks && !FilterForDerivedTables.cfgFillKaonTracks && !FilterForDerivedTables.cfgFillProtonTracks) + return true; + if (FilterForDerivedTables.cfgFillPionTracks) { + if (std::abs(track.tpcNSigmaPi()) < pidnSigmaPreSelectionCut) + return true; + } + if (FilterForDerivedTables.cfgFillKaonTracks) { + if (std::abs(track.tpcNSigmaKa()) < pidnSigmaPreSelectionCut) + return true; + } + if (FilterForDerivedTables.cfgFillProtonTracks) { + if (std::abs(track.tpcNSigmaPr()) < pidnSigmaPreSelectionCut) + return true; + } + return false; + } + + template + bool filterV0(CollisionType const& collision, V0Type const& v0) + { + // if no selection is requested, return true + if (!FilterForDerivedTables.cfgFillK0s && !FilterForDerivedTables.cfgFillLambda0) + return true; + if (FilterForDerivedTables.cfgFillK0s) { + if (!SecondaryCuts.cfgSecondaryRequire) + return true; + if (v0.dcaV0daughters() > SecondaryCuts.cfgSecondaryDauDCAMax) + return false; + if (std::abs(v0.dcapostopv()) < SecondaryCuts.cfgSecondaryDauPosDCAtoPVMin) + return false; + if (std::abs(v0.dcanegtopv()) < SecondaryCuts.cfgSecondaryDauNegDCAtoPVMin) + return false; + if (v0.pt() < SecondaryCuts.cfgSecondaryPtMin) + return false; + if (std::fabs(v0.yK0Short()) > SecondaryCuts.cfgSecondaryRapidityMax) + return false; + if (v0.v0radius() < SecondaryCuts.cfgSecondaryRadiusMin || v0.v0radius() > SecondaryCuts.cfgSecondaryRadiusMax) + return false; + if (v0.dcav0topv() > SecondaryCuts.cfgSecondaryDCAtoPVMax) + return false; + if (v0.v0cosPA() < SecondaryCuts.cfgSecondaryCosPAMin) + return false; + if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassK0Short > SecondaryCuts.cfgSecondaryProperLifetimeMax) + return false; + if (v0.qtarm() < SecondaryCuts.cfgSecondaryparamArmenterosCut * std::abs(v0.alpha())) + return false; + if (std::fabs(v0.mK0Short() - MassK0Short) > SecondaryCuts.cfgSecondaryMassWindow) + return false; + if (SecondaryCuts.cfgSecondaryCrossMassHypothesisCut && + ((std::fabs(v0.mLambda() - MassLambda0) < SecondaryCuts.cfgSecondaryCrossMassCutWindow) || (std::fabs(v0.mAntiLambda() - MassLambda0Bar) < SecondaryCuts.cfgSecondaryCrossMassCutWindow))) + return false; + return true; + } + if (FilterForDerivedTables.cfgFillLambda0) { + if (!SecondaryCuts.cfgSecondaryRequire) + return true; + if (v0.dcaV0daughters() > SecondaryCuts.cfgSecondaryDauDCAMax) + return false; + if (std::abs(v0.dcapostopv()) < SecondaryCuts.cfgSecondaryDauPosDCAtoPVMin) + return false; + if (std::abs(v0.dcanegtopv()) < SecondaryCuts.cfgSecondaryDauNegDCAtoPVMin) + return false; + if (v0.pt() < SecondaryCuts.cfgSecondaryPtMin) + return false; + if (std::fabs(v0.yLambda()) > SecondaryCuts.cfgSecondaryRapidityMax) + return false; + if (v0.v0radius() < SecondaryCuts.cfgSecondaryRadiusMin || v0.v0radius() > SecondaryCuts.cfgSecondaryRadiusMax) + return false; + if (v0.dcav0topv() > SecondaryCuts.cfgSecondaryDCAtoPVMax) + return false; + if (v0.v0cosPA() < SecondaryCuts.cfgSecondaryCosPAMin) + return false; + if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassLambda0 > SecondaryCuts.cfgSecondaryProperLifetimeMax) + return false; + if (v0.qtarm() < SecondaryCuts.cfgSecondaryparamArmenterosCut * std::abs(v0.alpha())) + return false; + if (std::fabs(v0.mLambda() - MassLambda0) < SecondaryCuts.cfgSecondaryMassWindow) + return false; + if (SecondaryCuts.cfgSecondaryCrossMassHypothesisCut && (std::fabs(v0.mK0Short() - MassK0Short) < SecondaryCuts.cfgSecondaryCrossMassCutWindow)) + return false; + return true; + } + return false; + } + + template + bool filterCasc(T const& /*casc*/) + { + // if no selection is requested, return true + if (!FilterForDerivedTables.cfgFillXi0 && !FilterForDerivedTables.cfgFillOmega0) + return true; + if (FilterForDerivedTables.cfgFillXi0) { + // TODO: Implement, but cascades are very rare, do we need this? + return true; + } + if (FilterForDerivedTables.cfgFillOmega0) { + // TODO: Implement, but cascades are very rare, do we need this? + return true; + } + return false; + } + template + bool isMicroTrackSelected(CollisionType const&, TrackType const& track) + { + // Micro track selection + // DCAxy cut + if (std::fabs(track.dcaXY()) > cMaxDCArToPVcut) + return false; + // DCAz cut + if (std::fabs(track.dcaZ()) > cMaxDCAzToPVcut || std::fabs(track.dcaZ()) < cMinDCAzToPVcut) + return false; + return true; + } + template bool isTrackSelected(CollisionType const&, TrackType const& track) { @@ -365,9 +566,6 @@ struct ResonanceInitializer { case 2: returnValue = ResoEvents.centFT0A(); break; - case 99: - returnValue = ResoEvents.centFV0A(); - break; default: returnValue = ResoEvents.centFT0M(); break; @@ -446,52 +644,85 @@ struct ResonanceInitializer { returnValue = helperEP.GetResolution(helperEP.GetEventPlane(ResoEvents.qvecRe()[a * 4 + 3], ResoEvents.qvecIm()[a * 4 + 3], 2), helperEP.GetEventPlane(ResoEvents.qvecRe()[b * 4 + 3], ResoEvents.qvecIm()[b * 4 + 3], 2), 2); return returnValue; } - + // Filter for micro tracks + template + void fillMicroTracks(CollisionType const& collision, TrackType const& tracks) + { + // Loop over tracks + for (auto const& track : tracks) { + if (!isMicroTrackSelected(collision, track)) + continue; + if (!filterMicroTrack(track)) + continue; + o2::aod::resomicrodaughter::ResoMicroTrackSelFlag trackSelFlag(track.dcaXY(), track.dcaZ()); + if (std::abs(track.dcaXY()) < (0.004 + (0.013 / track.pt()))) { + trackSelFlag.setDCAxy0(); + } + if (std::abs(track.dcaZ()) < (0.004 + (0.013 / track.pt()))) { // TODO: check this + trackSelFlag.setDCAz0(); + } + uint8_t trackFlags = (track.passedITSRefit() << 0) | + (track.passedTPCRefit() << 1) | + (track.isGlobalTrackWoDCA() << 2) | + (track.isGlobalTrack() << 3) | + (track.isPrimaryTrack() << 4) | + (track.isPVContributor() << 5) | + (track.hasTOF() << 6) | + ((track.sign() > 0) << 7); // sign +1: 1, -1: 0 + reso2microtrks(resoCollisions.lastIndex(), + track.px(), + track.py(), + track.pz(), + static_cast(o2::aod::resomicrodaughter::PidNSigma(std::abs(track.tpcNSigmaPi()), std::abs(track.tofNSigmaPi()), track.hasTOF())), + static_cast(o2::aod::resomicrodaughter::PidNSigma(std::abs(track.tpcNSigmaKa()), std::abs(track.tofNSigmaKa()), track.hasTOF())), + static_cast(o2::aod::resomicrodaughter::PidNSigma(std::abs(track.tpcNSigmaPr()), std::abs(track.tofNSigmaPr()), track.hasTOF())), + static_cast(trackSelFlag), + trackFlags); + if (!cfgBypassTrackIndexFill) { + resoMicroTrackTracks(track.globalIndex()); + } + } + } // Filter for all tracks template void fillTracks(CollisionType const& collision, TrackType const& tracks) { + if (cfgBypassTrackFill) + return; // Loop over tracks for (auto const& track : tracks) { if (!isTrackSelected(collision, track)) continue; + if (!filterTrack(track)) + continue; + uint8_t trackFlags = (track.passedITSRefit() << 0) | + (track.passedTPCRefit() << 1) | + (track.isGlobalTrackWoDCA() << 2) | + (track.isGlobalTrack() << 3) | + (track.isPrimaryTrack() << 4) | + (track.isPVContributor() << 5) | + (track.hasTOF() << 6) | + ((track.sign() > 0) << 7); // sign +1: 1, -1: 0 reso2trks(resoCollisions.lastIndex(), - track.globalIndex(), track.pt(), track.px(), track.py(), track.pz(), - track.eta(), - track.phi(), - track.sign(), - (uint8_t)track.tpcNClsCrossedRows(), - (uint8_t)track.tpcNClsFound(), - (uint8_t)track.itsNCls(), - track.dcaXY(), - track.dcaZ(), - track.x(), - track.alpha(), - track.hasITS(), - track.hasTPC(), - track.hasTOF(), - track.tpcNSigmaPi(), - track.tpcNSigmaKa(), - track.tpcNSigmaPr(), - track.tpcNSigmaEl(), - track.tofNSigmaPi(), - track.tofNSigmaKa(), - track.tofNSigmaPr(), - track.tofNSigmaEl(), - track.tpcSignal(), - track.passedITSRefit(), - track.passedTPCRefit(), - track.isGlobalTrackWoDCA(), - track.isGlobalTrack(), - track.isPrimaryTrack(), - track.isPVContributor(), - track.tpcCrossedRowsOverFindableCls(), - track.itsChi2NCl(), - track.tpcChi2NCl()); + static_cast(track.tpcNClsCrossedRows()), + static_cast(track.tpcNClsFound()), + static_cast(std::round(track.dcaXY() * 10000)), + static_cast(std::round(track.dcaZ() * 10000)), + static_cast(std::round(track.tpcNSigmaPi() * 10)), + static_cast(std::round(track.tpcNSigmaKa() * 10)), + static_cast(std::round(track.tpcNSigmaPr() * 10)), + static_cast(std::round(track.tofNSigmaPi() * 10)), + static_cast(std::round(track.tofNSigmaKa() * 10)), + static_cast(std::round(track.tofNSigmaPr() * 10)), + static_cast(std::round(track.tpcSignal() * 10)), + trackFlags); + if (!cfgBypassTrackIndexFill) { + resoTrackTracks(track.globalIndex()); + } if constexpr (isMC) { fillMCTrack(track); } @@ -508,27 +739,26 @@ struct ResonanceInitializer { continue; childIDs[0] = v0.posTrackId(); childIDs[1] = v0.negTrackId(); + if (!filterV0(collision, v0)) + continue; reso2v0s(resoCollisions.lastIndex(), - v0.globalIndex(), v0.pt(), v0.px(), v0.py(), v0.pz(), - v0.eta(), - v0.phi(), childIDs, - v0.template posTrack_as().tpcNSigmaPi(), - v0.template posTrack_as().tpcNSigmaKa(), - v0.template posTrack_as().tpcNSigmaPr(), - v0.template negTrack_as().tpcNSigmaPi(), - v0.template negTrack_as().tpcNSigmaKa(), - v0.template negTrack_as().tpcNSigmaPr(), - v0.template negTrack_as().tofNSigmaPi(), - v0.template negTrack_as().tofNSigmaKa(), - v0.template negTrack_as().tofNSigmaPr(), - v0.template posTrack_as().tofNSigmaPi(), - v0.template posTrack_as().tofNSigmaKa(), - v0.template posTrack_as().tofNSigmaPr(), + (int8_t)(v0.template posTrack_as().tpcNSigmaPi() * 10), + (int8_t)(v0.template posTrack_as().tpcNSigmaKa() * 10), + (int8_t)(v0.template posTrack_as().tpcNSigmaPr() * 10), + (int8_t)(v0.template negTrack_as().tpcNSigmaPi() * 10), + (int8_t)(v0.template negTrack_as().tpcNSigmaKa() * 10), + (int8_t)(v0.template negTrack_as().tpcNSigmaPr() * 10), + (int8_t)(v0.template negTrack_as().tofNSigmaPi() * 10), + (int8_t)(v0.template negTrack_as().tofNSigmaKa() * 10), + (int8_t)(v0.template negTrack_as().tofNSigmaPr() * 10), + (int8_t)(v0.template posTrack_as().tofNSigmaPi() * 10), + (int8_t)(v0.template posTrack_as().tofNSigmaKa() * 10), + (int8_t)(v0.template posTrack_as().tofNSigmaPr() * 10), v0.v0cosPA(), v0.dcaV0daughters(), v0.dcapostopv(), @@ -538,6 +768,9 @@ struct ResonanceInitializer { v0.mAntiLambda(), v0.mK0Short(), v0.v0radius(), v0.x(), v0.y(), v0.z()); + if (!cfgBypassTrackIndexFill) { + resoV0V0s(v0.globalIndex()); + } if constexpr (isMC) { fillMCV0(v0); } @@ -555,33 +788,32 @@ struct ResonanceInitializer { childIDs[0] = casc.posTrackId(); childIDs[1] = casc.negTrackId(); childIDs[2] = casc.bachelorId(); + if (!filterCasc(casc)) + continue; reso2cascades(resoCollisions.lastIndex(), - casc.globalIndex(), casc.pt(), casc.px(), casc.py(), casc.pz(), - casc.eta(), - casc.phi(), childIDs, - casc.template posTrack_as().tpcNSigmaPi(), - casc.template posTrack_as().tpcNSigmaKa(), - casc.template posTrack_as().tpcNSigmaPr(), - casc.template negTrack_as().tpcNSigmaPi(), - casc.template negTrack_as().tpcNSigmaKa(), - casc.template negTrack_as().tpcNSigmaPr(), - casc.template bachelor_as().tpcNSigmaPi(), - casc.template bachelor_as().tpcNSigmaKa(), - casc.template bachelor_as().tpcNSigmaPr(), - casc.template posTrack_as().tofNSigmaPi(), - casc.template posTrack_as().tofNSigmaKa(), - casc.template posTrack_as().tofNSigmaPr(), - casc.template negTrack_as().tofNSigmaPi(), - casc.template negTrack_as().tofNSigmaKa(), - casc.template negTrack_as().tofNSigmaPr(), - casc.template bachelor_as().tofNSigmaPi(), - casc.template bachelor_as().tofNSigmaKa(), - casc.template bachelor_as().tofNSigmaPr(), + (int8_t)(casc.template posTrack_as().tpcNSigmaPi() * 10), + (int8_t)(casc.template posTrack_as().tpcNSigmaKa() * 10), + (int8_t)(casc.template posTrack_as().tpcNSigmaPr() * 10), + (int8_t)(casc.template negTrack_as().tpcNSigmaPi() * 10), + (int8_t)(casc.template negTrack_as().tpcNSigmaKa() * 10), + (int8_t)(casc.template negTrack_as().tpcNSigmaPr() * 10), + (int8_t)(casc.template bachelor_as().tpcNSigmaPi() * 10), + (int8_t)(casc.template bachelor_as().tpcNSigmaKa() * 10), + (int8_t)(casc.template bachelor_as().tpcNSigmaPr() * 10), + (int8_t)(casc.template posTrack_as().tofNSigmaPi() * 10), + (int8_t)(casc.template posTrack_as().tofNSigmaKa() * 10), + (int8_t)(casc.template posTrack_as().tofNSigmaPr() * 10), + (int8_t)(casc.template negTrack_as().tofNSigmaPi() * 10), + (int8_t)(casc.template negTrack_as().tofNSigmaKa() * 10), + (int8_t)(casc.template negTrack_as().tofNSigmaPr() * 10), + (int8_t)(casc.template bachelor_as().tofNSigmaPi() * 10), + (int8_t)(casc.template bachelor_as().tofNSigmaKa() * 10), + (int8_t)(casc.template bachelor_as().tofNSigmaPr() * 10), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()), casc.dcaV0daughters(), @@ -596,6 +828,9 @@ struct ResonanceInitializer { casc.mLambda(), casc.mXi(), casc.v0radius(), casc.cascradius(), casc.x(), casc.y(), casc.z()); + if (!cfgBypassTrackIndexFill) { + resoCascadeCascades(casc.globalIndex()); + } if constexpr (isMC) { fillMCCascade(casc); } @@ -868,8 +1103,6 @@ struct ResonanceInitializer { mcPart.px(), mcPart.py(), mcPart.pz(), - mcPart.eta(), - mcPart.phi(), mcPart.y(), mcPart.e(), mcPart.statusCode()); @@ -961,17 +1194,24 @@ struct ResonanceInitializer { // Case selector based on the process. if (doprocessTrackDataRun2 || doprocessTrackV0DataRun2 || doprocessTrackV0CascDataRun2 || doprocessTrackMCRun2 || doprocessTrackV0MCRun2 || doprocessTrackV0CascMCRun2) { - colCuts.setCuts(cfgEvtZvtx, cfgEvtTriggerCheck, cfgEvtTriggerSel, cfgEvtOfflineCheck, false); + colCuts.setCuts(EventCuts.cfgEvtZvtx, EventCuts.cfgEvtTriggerCheck, EventCuts.cfgEvtOfflineCheck, false); } else if (doprocessTrackData || doprocessTrackV0Data || doprocessTrackV0CascData || doprocessTrackMC || doprocessTrackV0MC || doprocessTrackV0CascMC || doprocessTrackEPData) { - colCuts.setCuts(cfgEvtZvtx, cfgEvtTriggerCheck, cfgEvtTriggerSel, cfgEvtOfflineCheck, true, false, cfgEvtOccupancyInTimeRange); + colCuts.setCuts(EventCuts.cfgEvtZvtx, EventCuts.cfgEvtTriggerCheck, EventCuts.cfgEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, EventCuts.cfgEvtOccupancyInTimeRangeMax, EventCuts.cfgEvtOccupancyInTimeRangeMin); } colCuts.init(&qaRegistry); - colCuts.setTriggerTVX(cfgEvtTriggerTVXSel); - colCuts.setApplyTFBorderCut(cfgEvtTFBorderCut); - colCuts.setApplyITSTPCvertex(cfgEvtUseITSTPCvertex); - colCuts.setApplyZvertexTimedifference(cfgEvtZvertexTimedifference); - colCuts.setApplyPileupRejection(cfgEvtPileupRejection); - colCuts.setApplyNoITSROBorderCut(cfgEvtNoITSROBorderCut); + colCuts.setTriggerTVX(EventCuts.cfgEvtTriggerTVXSel); + colCuts.setApplyTFBorderCut(EventCuts.cfgEvtTFBorderCut); + colCuts.setApplyITSTPCvertex(EventCuts.cfgEvtUseITSTPCvertex); + colCuts.setApplyZvertexTimedifference(EventCuts.cfgEvtZvertexTimedifference); + colCuts.setApplyPileupRejection(EventCuts.cfgEvtPileupRejection); + colCuts.setApplyNoITSROBorderCut(EventCuts.cfgEvtNoITSROBorderCut); + colCuts.setApplyCollInTimeRangeStandard(EventCuts.cfgEvtCollInTimeRangeStandard); + colCuts.setApplyRun2AliEventCuts(EventCuts.cfgEvtRun2AliEventCuts); + colCuts.setApplyRun2INELgtZERO(EventCuts.cfgEvtRun2INELgtZERO); + colCuts.printCuts(); + + rctChecker.init(EventCuts.cfgEvtRCTFlagCheckerLabel, EventCuts.cfgEvtRCTFlagCheckerZDCCheck, EventCuts.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + if (!cfgBypassCCDB) { ccdb->setURL(ccdbURL.value); ccdb->setCaching(true); @@ -1043,7 +1283,7 @@ struct ResonanceInitializer { LOGF(info, "Bz set to %f for run: ", dBz, mRunNumber); } - void processDummy(ResoRun2Events const& /*collisions*/) + void processDummy(aod::Collisions const& /*collisions*/) { } PROCESS_SWITCH(ResonanceInitializer, processDummy, "Process for dummy", true); @@ -1057,11 +1297,21 @@ struct ResonanceInitializer { // Default event selection if (!colCuts.isSelected(collision)) return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQA(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } } PROCESS_SWITCH(ResonanceInitializer, processTrackData, "Process for data", false); @@ -1069,15 +1319,25 @@ struct ResonanceInitializer { soa::Filtered const& tracks, BCsWithRun2Info const&) { - auto bc = collision.bc_as(); + // auto bc = collision.bc_as(); // Default event selection if (!colCuts.isSelected(collision)) return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQARun2(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } } PROCESS_SWITCH(ResonanceInitializer, processTrackDataRun2, "Process for data", false); @@ -1090,11 +1350,20 @@ struct ResonanceInitializer { // Default event selection if (!colCuts.isSelected(collision)) return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQA(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId), dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); - + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId)); fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } } PROCESS_SWITCH(ResonanceInitializer, processTrackEPData, "Process for data and ep ana", false); @@ -1108,11 +1377,21 @@ struct ResonanceInitializer { // Default event selection if (!colCuts.isSelected(collision)) return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQA(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } fillV0s(collision, V0s, tracks); } PROCESS_SWITCH(ResonanceInitializer, processTrackV0Data, "Process for data", false); @@ -1122,15 +1401,23 @@ struct ResonanceInitializer { ResoV0s const& V0s, BCsWithRun2Info const&) { - auto bc = collision.bc_as(); + // auto bc = collision.bc_as(); // Default event selection if (!colCuts.isSelected(collision)) return; colCuts.fillQARun2(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } fillV0s(collision, V0s, tracks); } PROCESS_SWITCH(ResonanceInitializer, processTrackV0DataRun2, "Process for data", false); @@ -1146,11 +1433,20 @@ struct ResonanceInitializer { // Default event selection if (!colCuts.isSelected(collision)) return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQA(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); - + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } fillV0s(collision, V0s, tracks); fillCascades(collision, Cascades, tracks); } @@ -1162,15 +1458,23 @@ struct ResonanceInitializer { ResoCascades const& Cascades, BCsWithRun2Info const&) { - auto bc = collision.bc_as(); + // auto bc = collision.bc_as(); // Default event selection if (!colCuts.isSelected(collision)) return; colCuts.fillQARun2(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } fillV0s(collision, V0s, tracks); fillCascades(collision, Cascades, tracks); } @@ -1183,16 +1487,25 @@ struct ResonanceInitializer { { auto bc = collision.bc_as(); /// adding timestamp to access magnetic field later initCCDB(bc); + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQA(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); - + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); auto mccollision = collision.mcCollision_as(); float impactpar = mccollision.impactParameter(); fillMCCollision(collision, mcParticles, impactpar); // Loop over tracks fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } // Loop over all MC particles auto mcParts = selectedMCParticles->sliceBy(perMcCollision, collision.mcCollision().globalIndex()); @@ -1206,13 +1519,23 @@ struct ResonanceInitializer { { auto bc = collision.bc_as(); /// adding timestamp to access magnetic field later initCCDB(bc); + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQA(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId), dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId)); fillMCCollision(collision, mcParticles); // Loop over tracks fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } // Loop over all MC particles auto mcParts = selectedMCParticles->sliceBy(perMcCollision, collision.mcCollision().globalIndex()); fillMCParticles(mcParts, mcParticles); @@ -1224,15 +1547,22 @@ struct ResonanceInitializer { aod::McCollisions const&, soa::Filtered const& tracks, aod::McParticles const& mcParticles, BCsWithRun2Info const&) { - auto bc = collision.bc_as(); + // auto bc = collision.bc_as(); colCuts.fillQARun2(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillMCCollision(collision, mcParticles); // Loop over tracks fillTracks(collision, tracks); - + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } // Loop over all MC particles auto mcParts = selectedMCParticles->sliceBy(perMcCollisionRun2, collision.mcCollision().globalIndex()); fillMCParticles(mcParts, mcParticles); @@ -1246,13 +1576,23 @@ struct ResonanceInitializer { { auto bc = collision.bc_as(); /// adding timestamp to access magnetic field later initCCDB(bc); + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQA(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillMCCollision(collision, mcParticles); // Loop over tracks fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } fillV0s(collision, V0s, tracks); // Loop over all MC particles @@ -1266,14 +1606,22 @@ struct ResonanceInitializer { ResoV0sMC const& V0s, aod::McParticles const& mcParticles, BCsWithRun2Info const&) { - auto bc = collision.bc_as(); + // auto bc = collision.bc_as(); colCuts.fillQARun2(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillMCCollision(collision, mcParticles); // Loop over tracks fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } fillV0s(collision, V0s, tracks); // Loop over all MC particles @@ -1290,13 +1638,23 @@ struct ResonanceInitializer { { auto bc = collision.bc_as(); /// adding timestamp to access magnetic field later initCCDB(bc); + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQA(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillMCCollision(collision, mcParticles); // Loop over tracks fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } fillV0s(collision, V0s, tracks); fillCascades(collision, Cascades, tracks); @@ -1312,14 +1670,22 @@ struct ResonanceInitializer { ResoCascadesMC const& Cascades, aod::McParticles const& mcParticles, BCsWithRun2Info const&) { - auto bc = collision.bc_as(); + // auto bc = collision.bc_as(); colCuts.fillQARun2(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } + resoSpheroCollisions(computeSpherocity(tracks, trackSphMin, trackSphDef)); + resoEvtPlCollisions(0, 0, 0, 0); fillMCCollision(collision, mcParticles); // Loop over tracks fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } fillV0s(collision, V0s, tracks); fillCascades(collision, Cascades, tracks); diff --git a/PWGLF/TableProducer/Resonances/resonanceMergeDF.cxx b/PWGLF/TableProducer/Resonances/resonanceMergeDF.cxx new file mode 100644 index 00000000000..99ba4ec391d --- /dev/null +++ b/PWGLF/TableProducer/Resonances/resonanceMergeDF.cxx @@ -0,0 +1,584 @@ +// 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. +/// +/// \file resonanceMergeDF.cxx +/// \brief Merges multiple dataframes into a single dataframe +/// +/// +/// In typical dataframes (DF), we usually observe a range of 200 to 300 collisions. +/// This limited number of collisions often results in most events having very few currentwindowneighbors() for event mixing. +/// However, for resonances analysis, a minimum of 10 currentwindowneighbors() is required. +/// To address this limitation, this script is designed to aggregate information from multiple dataframes into a single dataframe, +/// thereby increasing the number of available current window neighbors for analysis. Here, nDF refers to the number of events or collisions. +/// For instance, if the total number of collisions across all dataframes is, say, 10,836, setting nDF to 10,836 will result in the creation of a single table. +/// Conversely, if nDF is set to 2,709, it will generate four tables, each containing approximately 2,709 collisions. +/// If nDF is set to 1, it will generate tables equal to the number of parent tables. +/// +/// /// +/// \author Bong-Hwi Lim +/// Nasir Mehdi Malik +/// Min-jae Kim +#include + +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Qvectors.h" +#include "Common/Core/EventPlaneHelper.h" +#include "Framework/ASoAHelpers.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFResonanceTables.h" +#include "PWGLF/Utils/collisionCuts.h" +#include "ReconstructionDataFormats/Track.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/BasicCCDBManager.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +/// Initializer for the resonance candidate producers + +struct ResonanceMergeDF { + // SliceCache cache; + Configurable nDF{"nDF", 1, "no of combination of collision"}; + Configurable cpidCut{"cpidCut", 0, "pid cut"}; + Configurable crejtpc{"crejtpc", 0, "reject electron pion"}; + Configurable crejtof{"crejtof", 0, "reject electron pion tof"}; + Configurable isPrimary{"isPrimary", 0, "is Primary only"}; + Configurable isGlobal{"isGlobal", 0, "Global tracks only"}; + Configurable cDCAXY{"cDCAXY", 1., "value of dcaxy"}; + Configurable cDCAZ{"cDCAZ", 1., "value of dcaz"}; + Configurable nsigmaPr{"nsigmaPr", 6., "nsigma value for proton"}; + Configurable nsigmaKa{"nsigmaKa", 6., "nsigma value for kaon"}; + Configurable nsigmatofPr{"nsigmatofPr", 6., "nsigma value for tof prot"}; + Configurable nsigmatofKa{"nsigmatofKa", 6., "nsigma value for tof kaon"}; + + // Xi1530 candidate cuts + Configurable trackSelection{"trackSelection", 0, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoDCA"}; + Configurable requireTOF{"requireTOF", false, "Require TOF"}; + Configurable applyTOFveto{"applyTOFveto", 999, "Apply TOF veto with value, 999 for passing all"}; + Configurable nsigmaPi{"nsigmaPi", 5., "nsigma value for pion"}; + Configurable minCent{"minCent", 0., "Minimum centrality"}; + Configurable maxCent{"maxCent", 100., "Maximum centrality"}; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(InitContext const&) + { + + const AxisSpec axisCent(110, 0, 110, "FT0 (%)"); + histos.add("Event/h1d_ft0_mult_percentile", "FT0 (%)", kTH1F, {axisCent}); + histos.add("Event/h1d_ft0_mult_percentile_CASC", "FT0 (%)", kTH1F, {axisCent}); + } + Produces resoCollisionsdf; + Produces reso2trksdf; + Produces reso2cascadesdf; + int df = 0; + + std::vector> vecOfTuples; + std::vector>> + vecOfVecOfTuples; + std::vector>> + vecOfVecOfTuplesCasc; + void processTrackDataDF(aod::ResoCollisions::iterator const& collision, aod::ResoTracks const& tracks) + { + + int nCollisions = nDF; + vecOfTuples.push_back(std::make_tuple(collision.posX(), collision.posY(), collision.posZ(), collision.cent(), 0, 0, 0)); + std::vector> + innerVector; + for (const auto& track : tracks) { + if (cpidCut) { + if (!track.hasTOF()) { + if (std::abs(track.tpcNSigmaPr()) > nsigmaPr && std::abs(track.tpcNSigmaKa()) > nsigmaKa) + continue; + + if (crejtpc && (std::abs(track.tpcNSigmaPr()) > std::abs(track.tpcNSigmaPi()) && std::abs(track.tpcNSigmaKa()) > std::abs(track.tpcNSigmaPi()))) + continue; + + } else { + if (std::abs(track.tofNSigmaPr()) > nsigmatofPr && std::abs(track.tofNSigmaKa()) > nsigmatofKa) + continue; + + if (crejtof && (std::abs(track.tofNSigmaPr()) > std::abs(track.tofNSigmaPi()) && std::abs(track.tofNSigmaKa()) > std::abs(track.tofNSigmaPi()))) + continue; + } + + if (std::abs(track.dcaXY()) > cDCAXY) + continue; + if (std::abs(track.dcaZ()) > cDCAZ) + continue; + } + + innerVector.push_back(std::make_tuple( + // track.trackId(), + track.pt(), + track.px(), + track.py(), + track.pz(), + (uint8_t)track.tpcNClsCrossedRows(), + (uint8_t)track.tpcNClsFound(), + static_cast(track.dcaXY() * 10000), + static_cast(track.dcaZ() * 10000), + (int8_t)(track.tpcNSigmaPi() * 10), + (int8_t)(track.tpcNSigmaKa() * 10), + (int8_t)(track.tpcNSigmaPr() * 10), + (int8_t)(track.tofNSigmaPi() * 10), + (int8_t)(track.tofNSigmaKa() * 10), + (int8_t)(track.tofNSigmaPr() * 10), + (int8_t)(track.tpcSignal() * 10), + track.trackFlags())); + } + + vecOfVecOfTuples.push_back(innerVector); + innerVector.clear(); + df++; + LOGF(info, "collisions: df = %i", df); + if (df < nCollisions) + return; + df = 0; + + for (size_t i = 0; i < vecOfTuples.size(); ++i) { + const auto& tuple = vecOfTuples[i]; + const auto& innerVector = vecOfVecOfTuples[i]; + + histos.fill(HIST("Event/h1d_ft0_mult_percentile"), std::get<3>(tuple)); + resoCollisionsdf(0, std::get<0>(tuple), std::get<1>(tuple), std::get<2>(tuple), std::get<3>(tuple), std::get<4>(tuple), std::get<5>(tuple), 0., 0., 0., 0., 0, std::get<6>(tuple)); + // LOGF(info, "collisions: Index = %d ) %f - %f - %f %f %d -- %d", std::get<0>(tuple).globalIndex(),std::get<1>(tuple),std::get<2>(tuple), std::get<3>(tuple), std::get<4>(tuple), std::get<5>(tuple).size(),resoCollisionsdf.lastIndex()); + + for (const auto& tuple : innerVector) { + reso2trksdf(resoCollisionsdf.lastIndex(), + std::get<0>(tuple), + std::get<1>(tuple), + std::get<2>(tuple), + std::get<3>(tuple), + std::get<4>(tuple), + std::get<5>(tuple), + std::get<6>(tuple), + std::get<7>(tuple), + std::get<8>(tuple), + std::get<9>(tuple), + std::get<10>(tuple), + std::get<11>(tuple), + std::get<12>(tuple), + std::get<13>(tuple), + std::get<14>(tuple), + std::get<15>(tuple)); + } + } + + vecOfTuples.clear(); + vecOfVecOfTuples.clear(); + } + + PROCESS_SWITCH(ResonanceMergeDF, processTrackDataDF, "Process for data merged DF", true); + + void processTrackDataDFCasc(aod::ResoCollisions::iterator const& collision, aod::ResoTracks const& tracks, aod::ResoCascades const& trackCascs) + { + + int nCollisions = nDF; + vecOfTuples.push_back(std::make_tuple(collision.posX(), collision.posY(), collision.posZ(), collision.cent(), 0, 0, 0)); + std::vector> + innerVector; + std::vector> + innerVectorCasc; + for (const auto& track : tracks) { + if (cpidCut) { + if (!track.hasTOF()) { + if (std::abs(track.tpcNSigmaPr()) > nsigmaPr && std::abs(track.tpcNSigmaKa()) > nsigmaKa) + continue; + + if (crejtpc && (std::abs(track.tpcNSigmaPr()) > std::abs(track.tpcNSigmaPi()) && std::abs(track.tpcNSigmaKa()) > std::abs(track.tpcNSigmaPi()))) + continue; + + } else { + if (std::abs(track.tofNSigmaPr()) > nsigmatofPr && std::abs(track.tofNSigmaKa()) > nsigmatofKa) + continue; + + if (crejtof && (std::abs(track.tofNSigmaPr()) > std::abs(track.tofNSigmaPi()) && std::abs(track.tofNSigmaKa()) > std::abs(track.tofNSigmaPi()))) + continue; + } + + if (std::abs(track.dcaXY()) > cDCAXY) + continue; + if (std::abs(track.dcaZ()) > cDCAZ) + continue; + } + + innerVector.push_back(std::make_tuple( + // track.trackId(), + track.pt(), + track.px(), + track.py(), + track.pz(), + (uint8_t)track.tpcNClsCrossedRows(), + (uint8_t)track.tpcNClsFound(), + static_cast(track.dcaXY() * 10000), + static_cast(track.dcaZ() * 10000), + (int8_t)(track.tpcNSigmaPi() * 10), + (int8_t)(track.tpcNSigmaKa() * 10), + (int8_t)(track.tpcNSigmaPr() * 10), + (int8_t)(track.tofNSigmaPi() * 10), + (int8_t)(track.tofNSigmaKa() * 10), + (int8_t)(track.tofNSigmaPr() * 10), + (int8_t)(track.tpcSignal() * 10), + track.trackFlags())); + } + + for (const auto& trackCasc : trackCascs) { + innerVectorCasc.push_back(std::make_tuple( + trackCasc.pt(), + trackCasc.px(), + trackCasc.py(), + trackCasc.pz(), + const_cast(trackCasc.cascadeIndices()), + (int8_t)(trackCasc.daughterTPCNSigmaPosPi() * 10), + (int8_t)(trackCasc.daughterTPCNSigmaPosKa() * 10), + (int8_t)(trackCasc.daughterTPCNSigmaPosPr() * 10), + (int8_t)(trackCasc.daughterTPCNSigmaNegPi() * 10), + (int8_t)(trackCasc.daughterTPCNSigmaNegKa() * 10), + (int8_t)(trackCasc.daughterTPCNSigmaNegPr() * 10), + (int8_t)(trackCasc.daughterTPCNSigmaBachPi() * 10), + (int8_t)(trackCasc.daughterTPCNSigmaBachKa() * 10), + (int8_t)(trackCasc.daughterTPCNSigmaBachPr() * 10), + (int8_t)(trackCasc.daughterTOFNSigmaPosPi() * 10), + (int8_t)(trackCasc.daughterTOFNSigmaPosKa() * 10), + (int8_t)(trackCasc.daughterTOFNSigmaPosPr() * 10), + (int8_t)(trackCasc.daughterTOFNSigmaNegPi() * 10), + (int8_t)(trackCasc.daughterTOFNSigmaNegKa() * 10), + (int8_t)(trackCasc.daughterTOFNSigmaNegPr() * 10), + (int8_t)(trackCasc.daughterTOFNSigmaBachPi() * 10), + (int8_t)(trackCasc.daughterTOFNSigmaBachKa() * 10), + (int8_t)(trackCasc.daughterTOFNSigmaBachPr() * 10), + trackCasc.v0CosPA(), + trackCasc.cascCosPA(), + trackCasc.daughDCA(), + trackCasc.cascDaughDCA(), + trackCasc.dcapostopv(), + trackCasc.dcanegtopv(), + trackCasc.dcabachtopv(), + trackCasc.dcav0topv(), + trackCasc.dcaXYCascToPV(), + trackCasc.dcaZCascToPV(), + trackCasc.sign(), + trackCasc.mLambda(), + trackCasc.mXi(), + trackCasc.transRadius(), trackCasc.cascTransRadius(), trackCasc.decayVtxX(), trackCasc.decayVtxY(), trackCasc.decayVtxZ())); + } + + vecOfVecOfTuples.push_back(innerVector); + vecOfVecOfTuplesCasc.push_back(innerVectorCasc); + innerVector.clear(); + innerVectorCasc.clear(); + + df++; + LOGF(info, "collisions: df = %i", df); + if (df < nCollisions) + return; + df = 0; + + for (size_t i = 0; i < vecOfTuples.size(); ++i) { + const auto& tuple = vecOfTuples[i]; + const auto& innerVector = vecOfVecOfTuples[i]; + const auto& innerVectorCasc = vecOfVecOfTuplesCasc[i]; + + histos.fill(HIST("Event/h1d_ft0_mult_percentile"), std::get<3>(tuple)); + resoCollisionsdf(0, std::get<0>(tuple), std::get<1>(tuple), std::get<2>(tuple), std::get<3>(tuple), std::get<4>(tuple), std::get<5>(tuple), 0., 0., 0., 0., 0, std::get<6>(tuple)); + // LOGF(info, "collisions: Index = %d ) %f - %f - %f %f %d -- %d", std::get<0>(tuple).globalIndex(),std::get<1>(tuple),std::get<2>(tuple), std::get<3>(tuple), std::get<4>(tuple), std::get<5>(tuple).size(),resoCollisionsdf.lastIndex()); + + for (const auto& tuple : innerVector) { + reso2trksdf(resoCollisionsdf.lastIndex(), + std::get<0>(tuple), + std::get<1>(tuple), + std::get<2>(tuple), + std::get<3>(tuple), + std::get<4>(tuple), + std::get<5>(tuple), + std::get<6>(tuple), + std::get<7>(tuple), + std::get<8>(tuple), + std::get<9>(tuple), + std::get<10>(tuple), + std::get<11>(tuple), + std::get<12>(tuple), + std::get<13>(tuple), + std::get<14>(tuple), + std::get<15>(tuple)); + } + + for (const auto& tuple : innerVectorCasc) { + reso2cascadesdf(resoCollisionsdf.lastIndex(), + std::get<0>(tuple), + std::get<1>(tuple), + std::get<2>(tuple), + std::get<3>(tuple), + std::get<4>(tuple), + std::get<5>(tuple), + std::get<6>(tuple), + std::get<7>(tuple), + std::get<8>(tuple), + std::get<9>(tuple), + std::get<10>(tuple), + std::get<11>(tuple), + std::get<12>(tuple), + std::get<13>(tuple), + std::get<14>(tuple), + std::get<15>(tuple), + std::get<16>(tuple), + std::get<17>(tuple), + std::get<18>(tuple), + std::get<19>(tuple), + std::get<20>(tuple), + std::get<21>(tuple), + std::get<22>(tuple), + std::get<23>(tuple), + std::get<24>(tuple), + std::get<25>(tuple), + std::get<26>(tuple), + std::get<27>(tuple), + std::get<28>(tuple), + std::get<29>(tuple), + std::get<30>(tuple), + std::get<31>(tuple), + std::get<32>(tuple), + std::get<33>(tuple), + std::get<34>(tuple), + std::get<35>(tuple), + std::get<36>(tuple), + std::get<37>(tuple), + std::get<38>(tuple), + std::get<39>(tuple), + std::get<40>(tuple)); + } + } + + vecOfTuples.clear(); + vecOfVecOfTuples.clear(); + vecOfVecOfTuplesCasc.clear(); // + } + + PROCESS_SWITCH(ResonanceMergeDF, processTrackDataDFCasc, "Process for data merged DF for cascade", false); + + void processLambdaStarCandidate(aod::ResoCollisions::iterator const& collision, aod::ResoTracks const& tracks) + { + + if (doprocessTrackDataDF) + LOG(fatal) << "Disable processTrackDataDF first!"; + + histos.fill(HIST("Event/h1d_ft0_mult_percentile"), collision.cent()); + + resoCollisionsdf(0, collision.posX(), collision.posY(), collision.posZ(), collision.cent(), 0, 0, 0., 0., 0., 0., 0, 0); + + for (const auto& track : tracks) { + if (isPrimary && !track.isPrimaryTrack()) + continue; + if (isGlobal && !track.isGlobalTrack()) + continue; + if (!track.hasTOF()) { + if (std::abs(track.tpcNSigmaPr()) > nsigmaPr && std::abs(track.tpcNSigmaKa()) > nsigmaKa) + continue; + + if (crejtpc && (std::abs(track.tpcNSigmaPr()) > std::abs(track.tpcNSigmaPi()) && std::abs(track.tpcNSigmaKa()) > std::abs(track.tpcNSigmaPi()))) + continue; + + } else { + if (std::abs(track.tofNSigmaPr()) > nsigmatofPr && std::abs(track.tofNSigmaKa()) > nsigmatofKa) + continue; + + if (crejtof && (std::abs(track.tofNSigmaPr()) > std::abs(track.tofNSigmaPi()) && std::abs(track.tofNSigmaKa()) > std::abs(track.tofNSigmaPi()))) + continue; + } + if (std::abs(track.dcaXY()) > cDCAXY) + continue; + if (std::abs(track.dcaZ()) > cDCAZ) + continue; + reso2trksdf(resoCollisionsdf.lastIndex(), + // track.trackId(), + track.pt(), + track.px(), + track.py(), + track.pz(), + (uint8_t)track.tpcNClsCrossedRows(), + (uint8_t)track.tpcNClsFound(), + static_cast(track.dcaXY() * 10000), + static_cast(track.dcaZ() * 10000), + (int8_t)(track.tpcNSigmaPi() * 10), + (int8_t)(track.tpcNSigmaKa() * 10), + (int8_t)(track.tpcNSigmaPr() * 10), + (int8_t)(track.tofNSigmaPi() * 10), + (int8_t)(track.tofNSigmaKa() * 10), + (int8_t)(track.tofNSigmaPr() * 10), + (int8_t)(track.tpcSignal() * 10), + track.trackFlags()); + } + } + PROCESS_SWITCH(ResonanceMergeDF, processLambdaStarCandidate, "Process for lambda star candidate", false); + + void processXi1530Candidate(aod::ResoCollisions::iterator const& collision, aod::ResoTracks const& tracks, aod::ResoCascades const& resocasctracks) + { + if (doprocessTrackDataDF) + LOG(fatal) << "Disable processTrackDataDF first!"; + if (doprocessLambdaStarCandidate) + LOG(fatal) << "Disable processLambdaStarCandidate first!"; + + if (collision.cent() < minCent || collision.cent() > maxCent) + return; + + resoCollisionsdf(0, collision.posX(), collision.posY(), collision.posZ(), collision.cent(), 0, 0, 0., 0., 0., 0., 0, 0); + histos.fill(HIST("Event/h1d_ft0_mult_percentile"), collision.cent()); + + for (const auto& track : tracks) { + if (trackSelection == 1) { + if (!track.isGlobalTrack()) + continue; + } else if (trackSelection == 2) { + if (!track.isGlobalTrackWoDCA()) + continue; + } + if (!track.hasTOF()) { + if (requireTOF) { + continue; + } + // TPC selection + if (std::abs(track.tpcNSigmaPi()) > nsigmaPi) + continue; + } else { + if (applyTOFveto > 998 && std::abs(track.tofNSigmaPi()) > applyTOFveto) + continue; + // TPC selection + if (std::abs(track.tpcNSigmaPi()) > nsigmaPi) + continue; + } + + if (std::abs(track.dcaXY()) > cDCAXY) + continue; + if (std::abs(track.dcaZ()) > cDCAZ) + continue; + + reso2trksdf(resoCollisionsdf.lastIndex(), + // track.trackId(), + track.pt(), + track.px(), + track.py(), + track.pz(), + (uint8_t)track.tpcNClsCrossedRows(), + (uint8_t)track.tpcNClsFound(), + static_cast(track.dcaXY() * 10000), + static_cast(track.dcaZ() * 10000), + (int8_t)(track.tpcNSigmaPi() * 10), + (int8_t)(track.tpcNSigmaKa() * 10), + (int8_t)(track.tpcNSigmaPr() * 10), + (int8_t)(track.tofNSigmaPi() * 10), + (int8_t)(track.tofNSigmaKa() * 10), + (int8_t)(track.tofNSigmaPr() * 10), + (int8_t)(track.tpcSignal() * 10), + track.trackFlags()); + } + // Cascade candidate + for (const auto& track : resocasctracks) { + // TODO: add cascade cuts + reso2cascadesdf(resoCollisionsdf.lastIndex(), + // casc.globalIndex(), + track.pt(), + track.px(), + track.py(), + track.pz(), + const_cast(track.cascadeIndices()), + (int8_t)(track.daughterTPCNSigmaPosPi() * 10), + (int8_t)(track.daughterTPCNSigmaPosKa() * 10), + (int8_t)(track.daughterTPCNSigmaPosPr() * 10), + (int8_t)(track.daughterTPCNSigmaNegPi() * 10), + (int8_t)(track.daughterTPCNSigmaNegKa() * 10), + (int8_t)(track.daughterTPCNSigmaNegPr() * 10), + (int8_t)(track.daughterTPCNSigmaBachPi() * 10), + (int8_t)(track.daughterTPCNSigmaBachKa() * 10), + (int8_t)(track.daughterTPCNSigmaBachPr() * 10), + (int8_t)(track.daughterTOFNSigmaPosPi() * 10), + (int8_t)(track.daughterTOFNSigmaPosKa() * 10), + (int8_t)(track.daughterTOFNSigmaPosPr() * 10), + (int8_t)(track.daughterTOFNSigmaNegPi() * 10), + (int8_t)(track.daughterTOFNSigmaNegKa() * 10), + (int8_t)(track.daughterTOFNSigmaNegPr() * 10), + (int8_t)(track.daughterTOFNSigmaBachPi() * 10), + (int8_t)(track.daughterTOFNSigmaBachKa() * 10), + (int8_t)(track.daughterTOFNSigmaBachPr() * 10), + track.v0CosPA(), + track.cascCosPA(), + track.daughDCA(), + track.cascDaughDCA(), + track.dcapostopv(), + track.dcanegtopv(), + track.dcabachtopv(), + track.dcav0topv(), + track.dcaXYCascToPV(), + track.dcaZCascToPV(), + track.sign(), + track.mLambda(), + track.mXi(), + track.transRadius(), track.cascTransRadius(), track.decayVtxX(), track.decayVtxY(), track.decayVtxZ()); + } + } + PROCESS_SWITCH(ResonanceMergeDF, processXi1530Candidate, "Process for Xi(1530) candidate", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Resonances/resonanceModuleInitializer.cxx b/PWGLF/TableProducer/Resonances/resonanceModuleInitializer.cxx index 86fa463ba3b..54d2533b05a 100644 --- a/PWGLF/TableProducer/Resonances/resonanceModuleInitializer.cxx +++ b/PWGLF/TableProducer/Resonances/resonanceModuleInitializer.cxx @@ -48,6 +48,7 @@ using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::constants::physics; using namespace o2::constants::math; +using namespace o2::aod::rctsel; /** * @brief Initializer for the event pool for resonance study @@ -66,6 +67,7 @@ struct ResonanceModuleInitializer { EventPlaneHelper helperEP; ///< Helper for event plane calculations Produces resoCollisions; ///< Output table for resonance collisions + Produces resoCollisionColls; ///< Output table for collision references Produces resoMCCollisions; ///< Output table for MC resonance collisions Produces resoSpheroCollisions; ///< Output table for spherocity Produces resoEvtPlCollisions; ///< Output table for event plane @@ -78,6 +80,7 @@ struct ResonanceModuleInitializer { Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable cfgFatalWhenNull{"cfgFatalWhenNull", true, "Fatal when null on ccdb access"}; + Configurable cfgBypassCollIndexFill{"cfgBypassCollIndexFill", false, "Bypass collision index fill"}; // Configurables Configurable dBzInput{"dBzInput", -999, "bz field, -999 is automatic"}; @@ -95,14 +98,21 @@ struct ResonanceModuleInitializer { Configurable cfgEvtZvtx{"cfgEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; Configurable cfgEvtOccupancyInTimeRange{"cfgEvtOccupancyInTimeRange", -1, "Evt sel: maximum track occupancy"}; Configurable cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"}; - Configurable cfgEvtTriggerSel{"cfgEvtTriggerSel", 8, "Evt sel: trigger"}; Configurable cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"}; Configurable cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; Configurable cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; Configurable cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; + Configurable cfgEvtCollInTimeRangeNarrow{"cfgEvtCollInTimeRangeNarrow", false, "Evt sel: apply NoCollInTimeRangeNarrow"}; Configurable cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", false, "Evt sel: apply Z-vertex time difference"}; Configurable cfgEvtPileupRejection{"cfgEvtPileupRejection", false, "Evt sel: apply pileup rejection"}; Configurable cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + Configurable cfgEvtRun2AliEventCuts{"cfgEvtRun2AliEventCuts", true, "Evt sel: apply Run2 AliEventCuts"}; + Configurable cfgEvtRun2INELgtZERO{"cfgEvtRun2INELgtZERO", false, "Evt sel: apply Run2 INELgtZERO"}; + Configurable cfgEvtUseRCTFlagChecker{"cfgEvtUseRCTFlagChecker", false, "Evt sel: use RCT flag checker"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", false, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + RCTFlagsChecker rctChecker; // Spherocity configuration Configurable cfgTrackSphMin{"cfgTrackSphMin", 10, "Number of tracks for Spherocity Calculation"}; @@ -137,8 +147,6 @@ struct ResonanceModuleInitializer { multEstimator = 1; } else if (cfgMultName.value == "FT0A") { multEstimator = 2; - } else if (cfgMultName.value == "FV0A") { - multEstimator = 99; } LOGF(info, "Mult estimator: %d, %s", multEstimator, cfgMultName.value.c_str()); @@ -152,17 +160,22 @@ struct ResonanceModuleInitializer { // Initialize event selection cuts based on the process type if (doprocessRun2) { - colCuts.setCuts(cfgEvtZvtx, cfgEvtTriggerCheck, cfgEvtTriggerSel, cfgEvtOfflineCheck, false); + colCuts.setCuts(cfgEvtZvtx, cfgEvtTriggerCheck, cfgEvtOfflineCheck, false); } else if (doprocessRun3) { - colCuts.setCuts(cfgEvtZvtx, cfgEvtTriggerCheck, cfgEvtTriggerSel, cfgEvtOfflineCheck, true, false, cfgEvtOccupancyInTimeRange); + colCuts.setCuts(cfgEvtZvtx, cfgEvtTriggerCheck, cfgEvtOfflineCheck, true, false, cfgEvtOccupancyInTimeRange); } colCuts.init(&qaRegistry); colCuts.setTriggerTVX(cfgEvtTriggerTVXSel); colCuts.setApplyTFBorderCut(cfgEvtTFBorderCut); colCuts.setApplyITSTPCvertex(cfgEvtUseITSTPCvertex); + colCuts.setApplyCollInTimeRangeNarrow(cfgEvtCollInTimeRangeNarrow); colCuts.setApplyZvertexTimedifference(cfgEvtZvertexTimedifference); colCuts.setApplyPileupRejection(cfgEvtPileupRejection); colCuts.setApplyNoITSROBorderCut(cfgEvtNoITSROBorderCut); + colCuts.setApplyRun2AliEventCuts(cfgEvtRun2AliEventCuts); + colCuts.setApplyRun2INELgtZERO(cfgEvtRun2INELgtZERO); + + rctChecker.init(cfgEvtRCTFlagCheckerLabel, cfgEvtRCTFlagCheckerZDCCheck, cfgEvtRCTFlagCheckerLimitAcceptAsBad); // Configure CCDB access if not bypassed if (!cfgBypassCCDB) { @@ -273,7 +286,7 @@ struct ResonanceModuleInitializer { break; case 1: if constexpr (isMC) { - LOG(fatal) << "CentFV0A is not available for MC"; + LOG(fatal) << "CentFT0C is not available for MC"; return returnValue; } else { returnValue = ResoEvents.centFT0C(); @@ -287,14 +300,6 @@ struct ResonanceModuleInitializer { returnValue = ResoEvents.centFT0A(); break; } - case 99: - if constexpr (isMC) { - LOG(fatal) << "CentFV0A is not available for MC"; - return returnValue; - } else { - returnValue = ResoEvents.centFV0A(); - break; - } default: returnValue = ResoEvents.centFT0M(); break; @@ -534,10 +539,15 @@ struct ResonanceModuleInitializer { // Default event selection if (!colCuts.isSelected(collision)) return; + if (cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; colCuts.fillQA(collision); centrality = centEst(collision); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centrality, -999, 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centrality, dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } } PROCESS_SWITCH(ResonanceModuleInitializer, processRun3, "Default process for RUN3", false); @@ -550,14 +560,17 @@ struct ResonanceModuleInitializer { void processRun2(soa::Filtered::iterator const& collision, aod::BCsWithRun2Info const&) { - auto bc = collision.bc_as(); + // auto bc = collision.bc_as(); // Default event selection if (!colCuts.isSelected(collision)) return; colCuts.fillQARun2(collision); centrality = collision.centRun2V0M(); - resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centrality, -999, 0., 0., 0., 0., dBz, bc.timestamp(), -999); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centrality, dBz); + if (!cfgBypassCollIndexFill) { + resoCollisionColls(collision.globalIndex()); + } } PROCESS_SWITCH(ResonanceModuleInitializer, processRun2, "process for RUN2", false); @@ -571,6 +584,8 @@ struct ResonanceModuleInitializer { void processRun3MC(soa::Filtered::iterator const& collision, aod::McParticles const& mcParticles, GenMCCollisions const&) { + if (cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; fillMCCollision(collision, mcParticles); } PROCESS_SWITCH(ResonanceModuleInitializer, processRun3MC, "process MC for RUN3", false); @@ -594,10 +609,10 @@ struct ResonanceModuleInitializer { * @param collision Collision data * @param tracks Track data */ - void processSpherocity(soa::Filtered::iterator const& collision, aod::ResoTrackCandidates const& tracks) + void processSpherocity(soa::Filtered::iterator const& /*collision*/, aod::ResoTrackCandidates const& tracks) { float spherocity = computeSpherocity(tracks, cfgTrackSphMin, cfgTrackSphDef); - resoSpheroCollisions(collision.globalIndex(), spherocity); + resoSpheroCollisions(spherocity); } PROCESS_SWITCH(ResonanceModuleInitializer, processSpherocity, "process Spherocity", false); @@ -609,7 +624,7 @@ struct ResonanceModuleInitializer { */ void processEventPlane(soa::Filtered>::iterator const& collision) { - resoEvtPlCollisions(collision.globalIndex(), getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId)); + resoEvtPlCollisions(getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId)); } PROCESS_SWITCH(ResonanceModuleInitializer, processEventPlane, "process Event Plane", false); }; @@ -622,21 +637,30 @@ struct ResonanceModuleInitializer { */ struct ResonanceDaughterInitializer { SliceCache cache; - Produces reso2trks; ///< Output table for resonance tracks - Produces reso2mctracks; ///< Output table for MC resonance tracks - Produces reso2v0s; ///< Output table for resonance V0s - Produces reso2mcv0s; ///< Output table for MC resonance V0s - Produces reso2cascades; ///< Output table for resonance cascades - Produces reso2mccascades; ///< Output table for MC resonance cascades + Produces reso2trks; ///< Output table for resonance tracks + Produces resoTrackTracks; ///< Output table for resonance track tracks + Produces reso2microtrks; ///< Output table for resonance microtracks + Produces resoMicroTrackTracks; ///< Output table for resonance microtrack tracks + Produces reso2mctracks; ///< Output table for MC resonance tracks + Produces reso2v0s; ///< Output table for resonance V0s + Produces resoV0V0s; ///< Output table for resonance V0-V0s + Produces reso2mcv0s; ///< Output table for MC resonance V0s + Produces reso2cascades; ///< Output table for resonance cascades + Produces resoCascadeCascades; ///< Output table for resonance cascade-cascades + Produces reso2mccascades; ///< Output table for MC resonance cascades // Configurables Configurable cfgFillQA{"cfgFillQA", false, "Fill QA histograms"}; + Configurable cfgFillMicroTracks{"cfgFillMicroTracks", false, "Fill micro tracks"}; + Configurable cfgBypassTrackFill{"cfgBypassTrackFill", true, "Bypass track fill"}; + Configurable cfgBypassTrackIndexFill{"cfgBypassTrackIndexFill", false, "Bypass track index fill"}; // Configurables for tracks Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 2.0, "Track DCAr cut to PV Maximum"}; Configurable cMinDCArToPVcut{"cMinDCArToPVcut", 0.0, "Track DCAr cut to PV Minimum"}; Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; Configurable cMinDCAzToPVcut{"cMinDCAzToPVcut", 0.0, "Track DCAz cut to PV Minimum"}; + Configurable pidnSigmaPreSelectionCut{"pidnSigmaPreSelectionCut", 5.0f, "TPC and TOF PID cut (loose, improve performance)"}; Configurable trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; // Configurables for V0s @@ -649,6 +673,16 @@ struct ResonanceDaughterInitializer { Configurable cMaxCascRadius{"cMaxCascRadius", 200.0, "Maximum Cascade radius from PV"}; Configurable cMinCascCosPA{"cMinCascCosPA", 0.97, "Minimum Cascade CosPA to PV"}; + // Derived dataset selections + struct : ConfigurableGroup { + Configurable cfgFillPionTracks{"cfgFillPionTracks", false, "Fill pion tracks"}; + Configurable cfgFillKaonTracks{"cfgFillKaonTracks", false, "Fill kaon tracks"}; + Configurable cfgFillProtonTracks{"cfgFillProtonTracks", false, "Fill proton tracks"}; + Configurable cfgFillPionMicroTracks{"cfgFillPionMicroTracks", false, "Fill pion micro tracks"}; + Configurable cfgFillKaonMicroTracks{"cfgFillKaonMicroTracks", false, "Fill kaon micro tracks"}; + Configurable cfgFillProtonMicroTracks{"cfgFillProtonMicroTracks", false, "Fill proton micro tracks"}; + } FilterForDerivedTables; + // Filters Filter dcaXYFilter = nabs(aod::track::dcaXY) < cMaxDCArToPVcut && nabs(aod::track::dcaXY) > cMinDCArToPVcut; Filter dcaZFilter = nabs(aod::track::dcaZ) < cMaxDCAzToPVcut && nabs(aod::track::dcaZ) > cMinDCAzToPVcut; @@ -725,6 +759,93 @@ struct ResonanceDaughterInitializer { LOGF(fatal, "ResonanceDaughterInitializer not initialized, enable at least one process"); } } + template + bool filterMicroTrack(T const& track) + { + // if no selection is requested, return true + if (!FilterForDerivedTables.cfgFillPionMicroTracks && !FilterForDerivedTables.cfgFillKaonMicroTracks && !FilterForDerivedTables.cfgFillProtonMicroTracks) + return true; + if (FilterForDerivedTables.cfgFillPionMicroTracks) { + if (std::abs(track.tpcNSigmaPi()) < pidnSigmaPreSelectionCut) + return true; + } + if (FilterForDerivedTables.cfgFillKaonMicroTracks) { + if (std::abs(track.tpcNSigmaKa()) < pidnSigmaPreSelectionCut) + return true; + } + if (FilterForDerivedTables.cfgFillProtonMicroTracks) { + if (std::abs(track.tpcNSigmaPr()) < pidnSigmaPreSelectionCut) + return true; + } + return false; + } + + template + bool filterTrack(T const& track) + { + // if no selection is requested, return true + if (!FilterForDerivedTables.cfgFillPionTracks && !FilterForDerivedTables.cfgFillKaonTracks && !FilterForDerivedTables.cfgFillProtonTracks) + return true; + if (FilterForDerivedTables.cfgFillPionTracks) { + if (std::abs(track.tpcNSigmaPi()) < pidnSigmaPreSelectionCut) + return true; + } + if (FilterForDerivedTables.cfgFillKaonTracks) { + if (std::abs(track.tpcNSigmaKa()) < pidnSigmaPreSelectionCut) + return true; + } + if (FilterForDerivedTables.cfgFillProtonTracks) { + if (std::abs(track.tpcNSigmaPr()) < pidnSigmaPreSelectionCut) + return true; + } + return false; + } + + /** + * @brief Fills track data + * + * @tparam isMC Boolean indicating if it's MC + * @tparam TrackType Type of track + * @tparam CollisionType Type of collision + * @param collision Collision data + * @param tracks Track data + */ + template + void fillMicroTracks(CollisionType const& collision, TrackType const& tracks) + { + // Loop over tracks + for (auto const& track : tracks) { + if (!filterMicroTrack(track)) + continue; + o2::aod::resomicrodaughter::ResoMicroTrackSelFlag trackSelFlag(track.dcaXY(), track.dcaZ()); + if (std::abs(track.dcaXY()) < (0.004 + (0.013 / track.pt()))) { + trackSelFlag.setDCAxy0(); + } + if (std::abs(track.dcaZ()) < (0.004 + (0.013 / track.pt()))) { // TODO: check this + trackSelFlag.setDCAz0(); + } + uint8_t trackFlags = (track.passedITSRefit() << 0) | + (track.passedTPCRefit() << 1) | + (track.isGlobalTrackWoDCA() << 2) | + (track.isGlobalTrack() << 3) | + (track.isPrimaryTrack() << 4) | + (track.isPVContributor() << 5) | + (track.hasTOF() << 6) | + ((track.sign() > 0) << 7); // sign +1: 1, -1: 0 + reso2microtrks(collision.globalIndex(), + track.px(), + track.py(), + track.pz(), + static_cast(o2::aod::resomicrodaughter::PidNSigma(std::abs(track.tpcNSigmaPi()), std::abs(track.tofNSigmaPi()), track.hasTOF())), + static_cast(o2::aod::resomicrodaughter::PidNSigma(std::abs(track.tpcNSigmaKa()), std::abs(track.tofNSigmaKa()), track.hasTOF())), + static_cast(o2::aod::resomicrodaughter::PidNSigma(std::abs(track.tpcNSigmaPr()), std::abs(track.tofNSigmaPr()), track.hasTOF())), + static_cast(trackSelFlag), + trackFlags); + if (!cfgBypassTrackIndexFill) { + resoMicroTrackTracks(track.globalIndex()); + } + } + } /** * @brief Fills track data @@ -738,51 +859,47 @@ struct ResonanceDaughterInitializer { template void fillTracks(CollisionType const& collision, TrackType const& tracks) { + if (cfgBypassTrackFill) { + return; + } // Loop over tracks for (auto const& track : tracks) { + if (!filterTrack(track)) + continue; if (cfgFillQA) { qaRegistry.fill(HIST("QA/hGoodTrackIndices"), 0); qaRegistry.fill(HIST("QA/hTrackPt"), track.pt()); qaRegistry.fill(HIST("QA/hTrackEta"), track.eta()); qaRegistry.fill(HIST("QA/hTrackPhi"), track.phi()); } + uint8_t trackFlags = (track.passedITSRefit() << 0) | + (track.passedTPCRefit() << 1) | + (track.isGlobalTrackWoDCA() << 2) | + (track.isGlobalTrack() << 3) | + (track.isPrimaryTrack() << 4) | + (track.isPVContributor() << 5) | + (track.hasTOF() << 6) | + ((track.sign() > 0) << 7); // sign +1: 1, -1: 0 reso2trks(collision.globalIndex(), - track.globalIndex(), track.pt(), track.px(), track.py(), track.pz(), - track.eta(), - track.phi(), - track.sign(), (uint8_t)track.tpcNClsCrossedRows(), (uint8_t)track.tpcNClsFound(), - (uint8_t)track.itsNCls(), - track.dcaXY(), - track.dcaZ(), - track.x(), - track.alpha(), - track.hasITS(), - track.hasTPC(), - track.hasTOF(), - track.tpcNSigmaPi(), - track.tpcNSigmaKa(), - track.tpcNSigmaPr(), - track.tpcNSigmaEl(), - track.tofNSigmaPi(), - track.tofNSigmaKa(), - track.tofNSigmaPr(), - track.tofNSigmaEl(), - track.tpcSignal(), - track.passedITSRefit(), - track.passedTPCRefit(), - track.isGlobalTrackWoDCA(), - track.isGlobalTrack(), - track.isPrimaryTrack(), - track.isPVContributor(), - track.tpcCrossedRowsOverFindableCls(), - track.itsChi2NCl(), - track.tpcChi2NCl()); + static_cast(track.dcaXY() * 10000), + static_cast(track.dcaZ() * 10000), + (int8_t)(track.tpcNSigmaPi() * 10), + (int8_t)(track.tpcNSigmaKa() * 10), + (int8_t)(track.tpcNSigmaPr() * 10), + (int8_t)(track.tofNSigmaPi() * 10), + (int8_t)(track.tofNSigmaKa() * 10), + (int8_t)(track.tofNSigmaPr() * 10), + (int8_t)(track.tpcSignal() * 10), + trackFlags); + if (!cfgBypassTrackIndexFill) { + resoTrackTracks(track.globalIndex()); + } if constexpr (isMC) { fillMCTrack(track); } @@ -893,26 +1010,23 @@ struct ResonanceDaughterInitializer { childIDs[0] = v0.posTrackId(); childIDs[1] = v0.negTrackId(); reso2v0s(collision.globalIndex(), - v0.globalIndex(), v0.pt(), v0.px(), v0.py(), v0.pz(), - v0.eta(), - v0.phi(), childIDs, - v0.template posTrack_as().tpcNSigmaPi(), - v0.template posTrack_as().tpcNSigmaKa(), - v0.template posTrack_as().tpcNSigmaPr(), - v0.template negTrack_as().tpcNSigmaPi(), - v0.template negTrack_as().tpcNSigmaKa(), - v0.template negTrack_as().tpcNSigmaPr(), - v0.template negTrack_as().tofNSigmaPi(), - v0.template negTrack_as().tofNSigmaKa(), - v0.template negTrack_as().tofNSigmaPr(), - v0.template posTrack_as().tofNSigmaPi(), - v0.template posTrack_as().tofNSigmaKa(), - v0.template posTrack_as().tofNSigmaPr(), + (int8_t)(v0.template posTrack_as().tpcNSigmaPi() * 10), + (int8_t)(v0.template posTrack_as().tpcNSigmaKa() * 10), + (int8_t)(v0.template posTrack_as().tpcNSigmaPr() * 10), + (int8_t)(v0.template negTrack_as().tpcNSigmaPi() * 10), + (int8_t)(v0.template negTrack_as().tpcNSigmaKa() * 10), + (int8_t)(v0.template negTrack_as().tpcNSigmaPr() * 10), + (int8_t)(v0.template negTrack_as().tofNSigmaPi() * 10), + (int8_t)(v0.template negTrack_as().tofNSigmaKa() * 10), + (int8_t)(v0.template negTrack_as().tofNSigmaPr() * 10), + (int8_t)(v0.template posTrack_as().tofNSigmaPi() * 10), + (int8_t)(v0.template posTrack_as().tofNSigmaKa() * 10), + (int8_t)(v0.template posTrack_as().tofNSigmaPr() * 10), v0.v0cosPA(), v0.dcaV0daughters(), v0.dcapostopv(), @@ -922,6 +1036,9 @@ struct ResonanceDaughterInitializer { v0.mAntiLambda(), v0.mK0Short(), v0.v0radius(), v0.x(), v0.y(), v0.z()); + if (!cfgBypassTrackIndexFill) { + resoV0V0s(v0.globalIndex()); + } if constexpr (isMC) { fillMCV0(v0); } @@ -1048,32 +1165,29 @@ struct ResonanceDaughterInitializer { childIDs[1] = casc.negTrackId(); childIDs[2] = casc.bachelorId(); reso2cascades(collision.globalIndex(), - casc.globalIndex(), casc.pt(), casc.px(), casc.py(), casc.pz(), - casc.eta(), - casc.phi(), childIDs, - casc.template posTrack_as().tpcNSigmaPi(), - casc.template posTrack_as().tpcNSigmaKa(), - casc.template posTrack_as().tpcNSigmaPr(), - casc.template negTrack_as().tpcNSigmaPi(), - casc.template negTrack_as().tpcNSigmaKa(), - casc.template negTrack_as().tpcNSigmaPr(), - casc.template bachelor_as().tpcNSigmaPi(), - casc.template bachelor_as().tpcNSigmaKa(), - casc.template bachelor_as().tpcNSigmaPr(), - casc.template posTrack_as().tofNSigmaPi(), - casc.template posTrack_as().tofNSigmaKa(), - casc.template posTrack_as().tofNSigmaPr(), - casc.template negTrack_as().tofNSigmaPi(), - casc.template negTrack_as().tofNSigmaKa(), - casc.template negTrack_as().tofNSigmaPr(), - casc.template bachelor_as().tofNSigmaPi(), - casc.template bachelor_as().tofNSigmaKa(), - casc.template bachelor_as().tofNSigmaPr(), + (int8_t)(casc.template posTrack_as().tpcNSigmaPi() * 10), + (int8_t)(casc.template posTrack_as().tpcNSigmaKa() * 10), + (int8_t)(casc.template posTrack_as().tpcNSigmaPr() * 10), + (int8_t)(casc.template negTrack_as().tpcNSigmaPi() * 10), + (int8_t)(casc.template negTrack_as().tpcNSigmaKa() * 10), + (int8_t)(casc.template negTrack_as().tpcNSigmaPr() * 10), + (int8_t)(casc.template bachelor_as().tpcNSigmaPi() * 10), + (int8_t)(casc.template bachelor_as().tpcNSigmaKa() * 10), + (int8_t)(casc.template bachelor_as().tpcNSigmaPr() * 10), + (int8_t)(casc.template posTrack_as().tofNSigmaPi() * 10), + (int8_t)(casc.template posTrack_as().tofNSigmaKa() * 10), + (int8_t)(casc.template posTrack_as().tofNSigmaPr() * 10), + (int8_t)(casc.template negTrack_as().tofNSigmaPi() * 10), + (int8_t)(casc.template negTrack_as().tofNSigmaKa() * 10), + (int8_t)(casc.template negTrack_as().tofNSigmaPr() * 10), + (int8_t)(casc.template bachelor_as().tofNSigmaPi() * 10), + (int8_t)(casc.template bachelor_as().tofNSigmaKa() * 10), + (int8_t)(casc.template bachelor_as().tofNSigmaPr() * 10), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()), casc.dcaV0daughters(), @@ -1088,6 +1202,9 @@ struct ResonanceDaughterInitializer { casc.mLambda(), casc.mXi(), casc.v0radius(), casc.cascradius(), casc.x(), casc.y(), casc.z()); + if (!cfgBypassTrackIndexFill) { + resoCascadeCascades(casc.globalIndex()); + } if constexpr (isMC) { fillMCCascade(casc); } @@ -1209,6 +1326,9 @@ struct ResonanceDaughterInitializer { soa::Filtered const& tracks) { fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } } PROCESS_SWITCH(ResonanceDaughterInitializer, processData, "Process tracks for data", false); @@ -1224,6 +1344,9 @@ struct ResonanceDaughterInitializer { aod::McParticles const&) { fillTracks(collision, tracks); + if (cfgFillMicroTracks) { + fillMicroTracks(collision, tracks); + } } PROCESS_SWITCH(ResonanceDaughterInitializer, processMC, "Process tracks for MC", false); diff --git a/PWGLF/TableProducer/Strangeness/CMakeLists.txt b/PWGLF/TableProducer/Strangeness/CMakeLists.txt index 1bb6ae5b8d9..9e4a3fa04f8 100644 --- a/PWGLF/TableProducer/Strangeness/CMakeLists.txt +++ b/PWGLF/TableProducer/Strangeness/CMakeLists.txt @@ -61,7 +61,6 @@ o2physics_add_dpl_workflow(double-casc-tree-creator PUBLIC_LINK_LIBRARIES O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(lambdakzerobuilder SOURCES lambdakzerobuilder.cxx PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore O2Physics::MLCore @@ -92,8 +91,13 @@ o2physics_add_dpl_workflow(lambdakzerospawner PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(sigmaminus-task + SOURCES sigmaminustask.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(strange-tree-creator - SOURCES LFStrangeTreeCreator.cxx + SOURCES strangeTreeCreator.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -107,6 +111,11 @@ o2physics_add_dpl_workflow(strangederivedbuilder PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(strangenessbuilder + SOURCES strangenessbuilder.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2Physics::TPCDriftManager O2Physics::MLCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(v0-selector SOURCES v0selector.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -117,6 +126,11 @@ o2physics_add_dpl_workflow(v0qaanalysis PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(lambdalambdatable + SOURCES LambdaLambdatable.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing + COMPONENT_NAME Analysis) + # ML selection o2physics_add_dpl_workflow(lambdakzeromlselectiontreecreator SOURCES lambdakzeroMLSelectionTreeCreator.cxx @@ -133,7 +147,32 @@ o2physics_add_dpl_workflow(lambdakzeromlselection PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(cascademlselection + SOURCES cascademlselection.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(sigma0builder SOURCES sigma0builder.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore - COMPONENT_NAME Analysis) \ No newline at end of file + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::AnalysisCCDB + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(lambdajetpolarizationbuilder + SOURCES lambdaJetpolarizationbuilder.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(stracents + SOURCES stracents.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(lambdaspincorrelation + SOURCES lambdaspincorrelation.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(propagationservice + SOURCES propagationService.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2Physics::TPCDriftManager + COMPONENT_NAME Analysis) diff --git a/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt b/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt index 010e2fc2813..842137dafe1 100644 --- a/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt +++ b/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt @@ -19,6 +19,11 @@ o2physics_add_dpl_workflow(stradautracksextraconverter2 PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(stradautracksextraconverter3 + SOURCES stradautracksextraconverter3.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(strarawcentsconverter SOURCES strarawcentsconverter.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -36,17 +41,22 @@ o2physics_add_dpl_workflow(straevselsconverter o2physics_add_dpl_workflow(straevselsconverter2 SOURCES straevselsconverter2.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::ITStracking + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::ReconstructionDataFormats COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(straevselsconverter3 SOURCES straevselsconverter3.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::ITStracking + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::ReconstructionDataFormats COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(straevselsconverter4 SOURCES straevselsconverter4.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::ITStracking + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(straevselsconverter5 + SOURCES straevselsconverter5.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(straevselsconverter2rawcents @@ -87,4 +97,24 @@ o2physics_add_dpl_workflow(stramccollisionconverter o2physics_add_dpl_workflow(strastampsconverter SOURCES strastampsconverter.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) \ No newline at end of file + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(stracentconverter + SOURCES stracentconverter.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(stramccollmultconverter + SOURCES stramccollmultconverter.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(stramccollisionconverter2 + SOURCES stramccollisionconverter2.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(zdcneutronsconverter + SOURCES zdcneutronsconverter.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGLF/TableProducer/Strangeness/Converters/stracentconverter.cxx b/PWGLF/TableProducer/Strangeness/Converters/stracentconverter.cxx new file mode 100644 index 00000000000..74a786101e9 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/stracentconverter.cxx @@ -0,0 +1,41 @@ +// 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. +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +using namespace o2; +using namespace o2::framework; + +// Converts Stra Cents from 000 to 001 +struct stracentconverter { + Produces straCents_001; + + void process(aod::StraCents_000 const& straCents_000) + { + for (auto& values : straCents_000) { + straCents_001(values.centFT0M(), + values.centFT0A(), + values.centFT0C(), + values.centFV0A(), + -999., /*dummy FT0Cvariant1 value*/ + -999., /*dummy MFT value*/ + -999. /*dummy NGlobal value*/); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/stradautracksextraconverter2.cxx b/PWGLF/TableProducer/Strangeness/Converters/stradautracksextraconverter2.cxx index 34e005d956d..22c9fc7eea4 100644 --- a/PWGLF/TableProducer/Strangeness/Converters/stradautracksextraconverter2.cxx +++ b/PWGLF/TableProducer/Strangeness/Converters/stradautracksextraconverter2.cxx @@ -24,12 +24,15 @@ struct stradautracksextraconverter2 { void process(aod::DauTrackExtras_001 const& dauTrackExtras_001) { for (auto& values : dauTrackExtras_001) { + const int maxFindable = 130; // synthetic findable to ensure range is ok + int findableMinusFound = maxFindable - values.tpcClusters(); + int findableMinusCrossedRows = maxFindable - values.tpcCrossedRows(); dauTrackExtras_002(values.itsChi2PerNcl(), values.detectorMap(), values.itsClusterSizes(), - static_cast(0), // findable (unknown in old format) - -values.tpcClusters(), // findable minus found: we know found - -values.tpcCrossedRows()); // findable minus crossed rows: we know crossed rows + static_cast(maxFindable), // findable (unknown in old format) + static_cast(findableMinusFound), // findable minus found: we know found + static_cast(findableMinusCrossedRows)); // findable minus crossed rows: we know crossed rows } } }; diff --git a/PWGLF/TableProducer/Strangeness/Converters/stradautracksextraconverter3.cxx b/PWGLF/TableProducer/Strangeness/Converters/stradautracksextraconverter3.cxx new file mode 100644 index 00000000000..a4144c1ee9a --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/stradautracksextraconverter3.cxx @@ -0,0 +1,43 @@ +// 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. +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" + +using namespace o2; +using namespace o2::framework; + +// Converts daughter TracksExtra from 2 to 3 +struct stradautracksextraconverter3 { + Produces dauTrackExtras_003; + + void process(aod::DauTrackExtras_002 const& dauTrackExtras_002) + { + for (auto& values : dauTrackExtras_002) { + dauTrackExtras_003(values.itsChi2PerNcl(), + -1 /* dummy tpcChi2PerNcl value */, + values.detectorMap(), + values.itsClusterSizes(), + values.tpcNClsFindable(), + values.tpcNClsFindableMinusFound(), + values.tpcNClsFindableMinusCrossedRows(), + -1 /* dummy tpcNClsShared value */); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2.cxx b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2.cxx index 401b04bbc83..fd3ccad4ee4 100644 --- a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2.cxx +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2.cxx @@ -8,12 +8,13 @@ // 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 "ITStracking/Vertexer.h" #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Vertex.h" + using namespace o2; using namespace o2::framework; @@ -52,7 +53,7 @@ struct straevselsconverter2 { values.totalFDDAmplitudeC(), values.energyCommonZNA(), values.energyCommonZNC(), - o2::its::Vertex::FlagsMask /*dummy flag value*/); + o2::dataformats::Vertex::FlagsMask /*dummy flag value*/); } } }; diff --git a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter3.cxx b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter3.cxx index ecbd738f5fa..ac209c26fe7 100644 --- a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter3.cxx +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter3.cxx @@ -8,12 +8,13 @@ // 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 "ITStracking/Vertexer.h" #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Vertex.h" + using namespace o2; using namespace o2::framework; @@ -53,7 +54,7 @@ struct straevselsconverter3 { values.totalFDDAmplitudeC(), values.energyCommonZNA(), values.energyCommonZNC(), - o2::its::Vertex::FlagsMask /*dummy flag value*/); + o2::dataformats::Vertex::FlagsMask /*dummy flag value*/); } } }; diff --git a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter4.cxx b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter4.cxx index ad988fd93aa..2dc55f365c9 100644 --- a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter4.cxx +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter4.cxx @@ -8,12 +8,12 @@ // 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 "ITStracking/Vertexer.h" #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + using namespace o2; using namespace o2::framework; diff --git a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter5.cxx b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter5.cxx new file mode 100644 index 00000000000..0ba066f99b3 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter5.cxx @@ -0,0 +1,125 @@ +// 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. +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/AggregatedRunInfo.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod::evsel; + +static const int32_t nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; + +// Converts Stra Event selections from 004 to 005 +struct straevselsconverter5 { + Produces straEvSels_005; + + Service ccdb; + + int lastRun = -1; + int64_t lastTF = -1; + uint32_t lastRCT = 0; + uint64_t sorTimestamp = 0; // default SOR timestamp + uint64_t eorTimestamp = 1; // default EOR timestamp + int64_t bcSOR = -1; // global bc of the start of run + int64_t nBCsPerTF = -1; // duration of TF in bcs, should be 128*3564 or 3 + std::map* mapRCT = nullptr; + + uint32_t getRctRaw(int run, uint64_t timestamp, uint64_t globalBC) + { + if (run != lastRun) { + lastRun = run; + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run); + // first bc of the first orbit + bcSOR = runInfo.orbitSOR * nBCsPerOrbit; + // duration of TF in bcs + nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit; + // SOR and EOR timestamps + sorTimestamp = runInfo.sor; + eorTimestamp = runInfo.eor; + // timestamp of the middle of the run used to access run-wise CCDB entries + int64_t ts = runInfo.sor / 2 + runInfo.eor / 2; + // QC info + std::map metadata; + metadata["run"] = Form("%d", run); + ccdb->setFatalWhenNull(0); + mapRCT = ccdb->getSpecific>("Users/j/jian/RCT", ts, metadata); + ccdb->setFatalWhenNull(1); + if (mapRCT == nullptr) { + LOGP(info, "rct object missing... inserting dummy rct flags"); + mapRCT = new std::map; + mapRCT->insert(std::pair(sorTimestamp, 0)); + } + } + + // store rct flags + uint32_t rct = lastRCT; + int64_t thisTF = (globalBC - bcSOR) / nBCsPerTF; + if (mapRCT != nullptr && thisTF != lastTF) { // skip for unanchored runs; do it once per TF + auto itrct = mapRCT->upper_bound(timestamp); + if (itrct != mapRCT->begin()) + itrct--; + rct = itrct->second; + LOGP(debug, "sor={} eor={} ts={} rct={}", sorTimestamp, eorTimestamp, timestamp, rct); + lastRCT = rct; + lastTF = thisTF; + } + return rct; + } + + void process(soa::Join const& straEvSels_004) + { + for (auto& values : straEvSels_004) { + straEvSels_005(values.sel8(), + values.selection_raw(), + values.multFT0A(), + values.multFT0C(), + values.multFT0A(), + 0 /*dummy FDDA value*/, + 0 /*dummy FDDC value*/, + values.multNTracksPVeta1(), + values.multPVTotalContributors(), + values.multNTracksGlobal(), + values.multNTracksITSTPC(), + values.multAllTracksTPCOnly(), + values.multAllTracksITSTPC(), + values.multZNA(), + values.multZNC(), + values.multZEM1(), + values.multZEM2(), + values.multZPA(), + values.multZPC(), + values.trackOccupancyInTimeRange(), + 0 /*dummy occupancy value*/, + values.gapSide(), + values.totalFT0AmplitudeA(), + values.totalFT0AmplitudeC(), + values.totalFV0AmplitudeA(), + values.totalFDDAmplitudeA(), + values.totalFDDAmplitudeC(), + values.energyCommonZNA(), + values.energyCommonZNC(), + values.flags(), + 0 /*dummy Alias value*/, + getRctRaw(values.runNumber(), values.timestamp(), values.globalBC()) /* Rct value*/); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/stramccollisionconverter2.cxx b/PWGLF/TableProducer/Strangeness/Converters/stramccollisionconverter2.cxx new file mode 100644 index 00000000000..c821c6fb5fe --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/stramccollisionconverter2.cxx @@ -0,0 +1,44 @@ +// 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. +// +// +/// \file stramccollisionconverter2.cxx +/// \brief Converter task to convert StraMCCollisions_001 --> StraMCCollisions_002 +/// +/// \author Romain Schotter , Austrian Academy of Sciences & SMI +// + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +using namespace o2; +using namespace o2::framework; + +// Converts V0 version 001 to 002 +struct stramccollisionconverter2 { + Produces straMCCollisions_002; + + void process(aod::StraMCCollisions_001 const& straMCcoll) + { + for (auto& mccollision : straMCcoll) { + straMCCollisions_002(mccollision.posX(), mccollision.posY(), mccollision.posZ(), + mccollision.impactParameter(), mccollision.eventPlaneAngle(), 0); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/stramccollmultconverter.cxx b/PWGLF/TableProducer/Strangeness/Converters/stramccollmultconverter.cxx new file mode 100644 index 00000000000..411e3c15da5 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/stramccollmultconverter.cxx @@ -0,0 +1,40 @@ +// 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. +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +using namespace o2; +using namespace o2::framework; + +// Converts V0 version 001 to 002 +struct stramccollmultconverter { + Produces straMCCollMults_001; + + void process(aod::StraMCCollMults_000 const& straMCcolls) + { + for (auto& straMCcoll : straMCcolls) { + straMCCollMults_001(straMCcoll.multMCFT0A(), + straMCcoll.multMCFT0C(), + straMCcoll.multMCNParticlesEta05(), + straMCcoll.multMCNParticlesEta08(), + straMCcoll.multMCNParticlesEta10(), + -1 /* dummy value for totalMultMCParticles */); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/zdcneutronsconverter.cxx b/PWGLF/TableProducer/Strangeness/Converters/zdcneutronsconverter.cxx new file mode 100644 index 00000000000..ad081a43052 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/zdcneutronsconverter.cxx @@ -0,0 +1,34 @@ +// 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. +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessMLTables.h" + +using namespace o2; +using namespace o2::framework; + +// +struct zdcneutronsconverter { + Produces zdcNeutrons; // Primary neutrons within ZDC acceptance + Produces zdcNeutronsMCCollRefs; // references collisions from ZDCNeutrons + + void process(aod::StraEvSels const&) + { + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/LambdaLambdatable.cxx b/PWGLF/TableProducer/Strangeness/LambdaLambdatable.cxx new file mode 100644 index 00000000000..778f39ed442 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/LambdaLambdatable.cxx @@ -0,0 +1,299 @@ +// 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 Junlee Kim, (junlee.kim@cern.ch) + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" + +#include "CommonConstants/MathConstants.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" + +#include "PWGLF/DataModel/ReducedLambdaLambdaTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct lambdalambdatable { + + // Produce derived tables + Produces redLLEvents; + Produces llTrack; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + + Configurable cfgUseGlobalTrack{"cfgUseGlobalTrack", true, "use Global track"}; + Configurable cfgCutPt{"cfgCutPt", 0.2, "PT cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + Configurable cfgCutDCAxy{"cfgCutDCAxy", 0.2f, "DCAxy range for tracks"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 0.2f, "DCAz range for tracks"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 50, "Number of TPC cluster"}; + + Configurable cfgv0radiusMin{"cfgv0radiusMin", 1.2, "minimum decay radius"}; + Configurable cfgDCAPosToPVMin{"cfgDCAPosToPVMin", 0.05, "minimum DCA to PV for positive track"}; + Configurable cfgDCANegToPVMin{"cfgDCANegToPVMin", 0.2, "minimum DCA to PV for negative track"}; + Configurable cfgv0CosPA{"cfgv0CosPA", 0.995, "minimum v0 cosine"}; + Configurable cfgDCAV0Dau{"cfgDCAV0Dau", 1.0, "maximum DCA between daughters"}; + + Configurable cfgV0PtMin{"cfgV0PtMin", 0, "minimum pT for lambda"}; + Configurable cfgV0EtaMin{"cfgV0EtaMin", -0.5, "maximum rapidity"}; + Configurable cfgV0EtaMax{"cfgV0EtaMax", 0.5, "maximum rapidity"}; + Configurable cfgV0LifeTime{"cfgV0LifeTime", 30., "maximum lambda lifetime"}; + + Configurable cfgDaughTPCnclsMin{"cfgDaughTPCnclsMin", 50, "minimum fired crossed rows"}; + Configurable cfgDaughPIDCutsTPCPr{"cfgDaughPIDCutsTPCPr", 5, "proton nsigma for TPC"}; + Configurable cfgDaughPIDCutsTPCPi{"cfgDaughPIDCutsTPCPi", 5, "pion nsigma for TPC"}; + Configurable cfgDaughEtaMin{"cfgDaughEtaMin", -0.8, "minimum daughter eta"}; + Configurable cfgDaughEtaMax{"cfgDaughEtaMax", 0.8, "maximum daughter eta"}; + Configurable cfgDaughPrPt{"cfgDaughPrPt", 0.5, "minimum daughter proton pt"}; + Configurable cfgDaughPiPt{"cfgDaughPiPt", 0.2, "minimum daughter pion pt"}; + + Configurable cfgMinLambdaMass{"cfgMinLambdaMass", 1.105, "Minimum lambda mass"}; + Configurable cfgMaxLambdaMass{"cfgMaxLambdaMass", 1.125, "Maximum lambda mass"}; + + ConfigurableAxis massAxis{"massAxis", {200, 2.1, 2.3}, "Invariant mass axis"}; + ConfigurableAxis ptAxis{"ptAxis", {VARIABLE_WIDTH, 0.0, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "Transverse momentum bins"}; + ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0, 20, 50, 100}, "Centrality interval"}; + ConfigurableAxis vertexAxis{"vertexAxis", {10, -10, 10}, "vertex axis for mixing"}; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPt); + Filter DCAcutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + + using EventCandidates = soa::Filtered>; + using TrackCandidates = soa::Filtered>; + + HistogramRegistry histos{ + "histos", + {}, + OutputObjHandlingPolicy::AnalysisObject}; + + SliceCache cache; + + double massLambda = o2::constants::physics::MassLambda; + double massPr = o2::constants::physics::MassProton; + double massPi = o2::constants::physics::MassPionCharged; + + float centrality; + + void init(o2::framework::InitContext&) + { + histos.add("hEventstat", "", {HistType::kTH1F, {{3, 0, 3}}}); + } + + template + bool selectionTrack(const T& candidate) + { + if (cfgUseGlobalTrack && !(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.tpcNClsFound() > cfgTPCcluster)) { + return false; + } + return true; + } + + template + bool selectionPID(const T& candidate, int pid) + { + if (pid == 0) { + if (std::abs(candidate.tpcNSigmaPi()) > cfgDaughPIDCutsTPCPi) { + return false; + } + } else if (pid == 2) { + if (std::abs(candidate.tpcNSigmaPr()) > cfgDaughPIDCutsTPCPr) { + return false; + } + } + return true; + } + + template + bool selectionV0(TCollision const& collision, V0 const& candidate) + { + if (candidate.v0radius() < cfgv0radiusMin) + return false; + if (std::abs(candidate.dcapostopv()) < cfgDCAPosToPVMin) + return false; + if (std::abs(candidate.dcanegtopv()) < cfgDCANegToPVMin) + return false; + if (candidate.v0cosPA() < cfgv0CosPA) + return false; + if (std::abs(candidate.dcaV0daughters()) > cfgDCAV0Dau) + return false; + if (candidate.pt() < cfgV0PtMin) + return false; + if (candidate.yLambda() < cfgV0EtaMin) + return false; + if (candidate.yLambda() > cfgV0EtaMax) + return false; + if (candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massLambda > cfgV0LifeTime) + return false; + + return true; + } + + template + bool selectionV0Daughter(T const& track, int pid) // pid 0: proton, pid 1: pion + { + if (track.tpcNClsFound() < cfgDaughTPCnclsMin) + return false; + if (pid == 0 && std::abs(track.tpcNSigmaPr()) > cfgDaughPIDCutsTPCPr) + return false; + if (pid == 1 && std::abs(track.tpcNSigmaPi()) > cfgDaughPIDCutsTPCPi) + return false; + if (track.eta() > cfgDaughEtaMax) + return false; + if (track.eta() < cfgDaughEtaMin) + return false; + if (pid == 0 && track.pt() < cfgDaughPrPt) + return false; + if (pid == 1 && track.pt() < cfgDaughPiPt) + return false; + + return true; + } + + ROOT::Math::PxPyPzMVector DauVec1, DauVec2, LLMesonMother, LLVectorDummy, LLd1dummy, LLd2dummy; + + void processLLReducedTable(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::V0Datas const& V0s, aod::BCsWithTimestamps const&) + { + bool keepEventLL = false; + int numberLambda = 0; + auto currentRunNumber = collision.bc_as().runNumber(); + auto bc = collision.bc_as(); + centrality = collision.centFT0M(); + + std::vector LLdId = {}; + + std::vector LLdd1Index = {}; + std::vector LLdd2Index = {}; + + std::vector LLdd1TPC = {}; + std::vector LLdd2TPC = {}; + + std::vector LLdx = {}; + std::vector LLdy = {}; + std::vector LLdz = {}; + + std::vector llresonance; + + histos.fill(HIST("hEventstat"), 0.5); + if (!(collision.sel8() && collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && collision.selection_bit(aod::evsel::kNoITSROFrameBorder) && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) + return; + histos.fill(HIST("hEventstat"), 1.5); + + for (auto& v0 : V0s) { + auto postrack_v0 = v0.template posTrack_as(); + auto negtrack_v0 = v0.template negTrack_as(); + + int LambdaTag = 0; + int aLambdaTag = 0; + + if (selectionV0Daughter(postrack_v0, 0) && selectionV0Daughter(negtrack_v0, 1)) + LambdaTag = 1; + + if (selectionV0Daughter(negtrack_v0, 0) && selectionV0Daughter(postrack_v0, 1)) + aLambdaTag = 1; + + if (LambdaTag == aLambdaTag) + continue; + + if (!selectionV0(collision, v0)) + continue; + + if (LambdaTag) { + if (v0.mLambda() < cfgMinLambdaMass || v0.mLambda() > cfgMaxLambdaMass) { + continue; + } + DauVec1 = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPr); + DauVec2 = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPi); + LLdId.push_back(3122); + } else if (aLambdaTag) { + if (v0.mAntiLambda() < cfgMinLambdaMass || v0.mAntiLambda() > cfgMaxLambdaMass) { + continue; + } + DauVec1 = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPi); + DauVec2 = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPr); + LLdId.push_back(-3122); + } + numberLambda++; + + LLdx.push_back(v0.x()); + LLdy.push_back(v0.y()); + LLdz.push_back(v0.z()); + + LLMesonMother = DauVec1 + DauVec2; + + ROOT::Math::PtEtaPhiMVector temp3(LLMesonMother.Pt(), LLMesonMother.Eta(), LLMesonMother.Phi(), LLMesonMother.M()); + llresonance.push_back(temp3); + + if (LambdaTag) { + LLdd1TPC.push_back(postrack_v0.tpcNSigmaPr()); + LLdd2TPC.push_back(negtrack_v0.tpcNSigmaPi()); + } else if (aLambdaTag) { + LLdd1TPC.push_back(postrack_v0.tpcNSigmaPi()); + LLdd2TPC.push_back(negtrack_v0.tpcNSigmaPr()); + } + + LLdd1Index.push_back(postrack_v0.globalIndex()); + LLdd2Index.push_back(negtrack_v0.globalIndex()); + } // select collision + + if (numberLambda < 2) + return; + + keepEventLL = true; + + if (keepEventLL) { + histos.fill(HIST("hEventstat"), 2.5); + /////////// Fill collision table/////////////// + redLLEvents(bc.globalBC(), currentRunNumber, bc.timestamp(), collision.posZ(), collision.numContrib(), centrality, numberLambda); + auto indexEvent = redLLEvents.lastIndex(); + //// Fill track table for LL////////////////// + for (auto if1 = llresonance.begin(); if1 != llresonance.end(); ++if1) { + auto i5 = std::distance(llresonance.begin(), if1); + LLVectorDummy = llresonance.at(i5); + llTrack(indexEvent, LLdId.at(i5), LLVectorDummy.Px(), LLVectorDummy.Py(), LLVectorDummy.Pz(), LLdx.at(i5), LLdy.at(i5), LLdz.at(i5), LLVectorDummy.M(), LLdd1TPC.at(i5), LLdd2TPC.at(i5), LLdd1Index.at(i5), LLdd2Index.at(i5)); + } + } + } // process + PROCESS_SWITCH(lambdalambdatable, processLLReducedTable, "Process table creation for double ll", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfg) +{ + return WorkflowSpec{adaptAnalysisTask(cfg)}; +} diff --git a/PWGLF/TableProducer/Strangeness/cascadebuilder.cxx b/PWGLF/TableProducer/Strangeness/cascadebuilder.cxx index 3ebe4f4b47e..b4a19e6660b 100644 --- a/PWGLF/TableProducer/Strangeness/cascadebuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/cascadebuilder.cxx @@ -862,8 +862,8 @@ struct cascadeBuilder { // from Carolina Reetz (thank you!) o2::track::TrackParCov getTrackParCovFromKFP(const KFParticle& kfParticle, const o2::track::PID pid, const int sign) { - o2::gpu::gpustd::array xyz, pxpypz; - o2::gpu::gpustd::array cv; + std::array xyz, pxpypz; + std::array cv; // get parameters from kfParticle xyz[0] = kfParticle.GetX(); @@ -909,7 +909,7 @@ struct cascadeBuilder { // Calculate DCAxy of the cascade (with bending) o2::track::TrackPar wrongV0 = fitter.createParentTrackPar(); wrongV0.setAbsCharge(0); // charge zero - gpu::gpustd::array dcaInfo; + std::array dcaInfo; dcaInfo[0] = 999; dcaInfo[1] = 999; @@ -989,7 +989,7 @@ struct cascadeBuilder { // bachelor DCA track to PV // Calculate DCA with respect to the collision associated to the V0, not individual tracks - gpu::gpustd::array dcaInfo; + std::array dcaInfo; auto bachTrackPar = getTrackPar(bachTrack); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, bachTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo); @@ -1273,7 +1273,7 @@ struct cascadeBuilder { // bachelor DCA track to PV // Calculate DCA with respect to the collision associated to the V0, not individual tracks - gpu::gpustd::array dcaInfo; + std::array dcaInfo; auto bachTrackPar = getTrackPar(bachTrack); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, bachTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo); @@ -1514,14 +1514,14 @@ struct cascadeBuilder { cascadecandidate.yOmega = KFOmega.GetRapidity(); // KF Cascade covariance matrix - o2::gpu::gpustd::array covCascKF; + std::array covCascKF; for (int i = 0; i < 21; i++) { // get covariance matrix elements (lower triangle) covCascKF[i] = KFXi.GetCovariance(i); cascadecandidate.kfCascadeCov[i] = covCascKF[i]; } // KF V0 covariance matrix - o2::gpu::gpustd::array covV0KF; + std::array covV0KF; for (int i = 0; i < 21; i++) { // get covariance matrix elements (lower triangle) covV0KF[i] = KFV0.GetCovariance(i); cascadecandidate.kfV0Cov[i] = covV0KF[i]; @@ -1618,19 +1618,19 @@ struct cascadeBuilder { } } - template - void buildStrangenessTables(TCascTable const& cascades) + template + void buildStrangenessTables(auto const& cascades) { statisticsRegistry.eventCounter++; for (auto& cascade : cascades) { // de-reference from V0 pool, either specific for cascades or general // use templatizing to avoid code duplication - if constexpr (requires { cascade.template v0(); }) { + if constexpr (requires { cascade.v0(); }) { auto v0index = cascade.template v0_as(); processCascadeCandidate(v0index, cascade); } - if constexpr (requires { cascade.template findableV0(); }) { + if constexpr (requires { cascade.findableV0(); }) { auto v0index = cascade.template findableV0_as(); processCascadeCandidate(v0index, cascade); } @@ -1640,17 +1640,17 @@ struct cascadeBuilder { resetHistos(); } - template - void buildKFStrangenessTables(TCascTable const& cascades) + template + void buildKFStrangenessTables(auto const& cascades) { statisticsRegistry.eventCounter++; for (auto& cascade : cascades) { bool validCascadeCandidateKF = false; - if constexpr (requires { cascade.template v0(); }) { + if constexpr (requires { cascade.v0(); }) { auto v0 = cascade.template v0_as(); validCascadeCandidateKF = buildCascadeCandidateWithKF(cascade, v0); } - if constexpr (requires { cascade.template findableV0(); }) { + if constexpr (requires { cascade.findableV0(); }) { auto v0 = cascade.template findableV0_as(); validCascadeCandidateKF = buildCascadeCandidateWithKF(cascade, v0); } @@ -1839,7 +1839,7 @@ struct cascadeBuilder { auto cascadeTrack = trackedCascade.template track_as(); auto cascadeTrackPar = getTrackParCov(cascadeTrack); auto const& collision = cascade.collision(); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; lCascadeTrack.setPID(o2::track::PID::XiMinus); // FIXME: not OK for omegas o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, cascadeTrackPar, 2.f, matCorrCascade, &dcaInfo); @@ -1979,7 +1979,7 @@ struct cascadeBuilder { } PROCESS_SWITCH(cascadeBuilder, processFindableRun3, "Produce Run 3 findable cascade tables", false); - void processRun3withKFParticle(aod::Collisions const& collisions, soa::Filtered const& cascades, FullTracksExtIU const&, aod::BCsWithTimestamps const&, aod::V0s const&) + void processRun3withKFParticle(aod::Collisions const& collisions, soa::Filtered const& cascades, FullTracksExtIU const&, aod::BCsWithTimestamps const&, aod::V0sLinked const&) { for (const auto& collision : collisions) { // Fire up CCDB @@ -2388,14 +2388,6 @@ struct cascadePreselector { //*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<* }; -/// Extends the cascdata table with expression columns -struct cascadeInitializer { - Spawns cascdataext; - Spawns kfcascdataext; - Spawns tracascdataext; - void init(InitContext const&) {} -}; - struct cascadeLinkBuilder { Produces cascdataLink; @@ -2482,7 +2474,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) return WorkflowSpec{ adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc)}; diff --git a/PWGLF/TableProducer/Strangeness/cascadefinder.cxx b/PWGLF/TableProducer/Strangeness/cascadefinder.cxx index a56b02666a1..3901d3f14c3 100644 --- a/PWGLF/TableProducer/Strangeness/cascadefinder.cxx +++ b/PWGLF/TableProducer/Strangeness/cascadefinder.cxx @@ -244,7 +244,7 @@ struct cascadefinder { auto lCascadeTrack = fitterCasc.createParentTrackPar(); lCascadeTrack.setAbsCharge(-1); // to be sure lCascadeTrack.setPID(o2::track::PID::XiMinus); // FIXME: not OK for omegas - gpu::gpustd::array dcaInfo; + std::array dcaInfo; dcaInfo[0] = 999; dcaInfo[1] = 999; @@ -334,7 +334,7 @@ struct cascadefinder { auto lCascadeTrack = fitterCasc.createParentTrackPar(); lCascadeTrack.setAbsCharge(+1); // to be sure lCascadeTrack.setPID(o2::track::PID::XiMinus); // FIXME: not OK for omegas - gpu::gpustd::array dcaInfo; + std::array dcaInfo; dcaInfo[0] = 999; dcaInfo[1] = 999; @@ -430,17 +430,10 @@ struct cascadefinderQA { } }; -/// Extends the cascdata table with expression columns -struct cascadeinitializer { - Spawns cascdataext; - void init(InitContext const&) {} -}; - WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ adaptAnalysisTask(cfgc, TaskName{"lf-cascadeprefilter"}), adaptAnalysisTask(cfgc, TaskName{"lf-cascadefinder"}), - adaptAnalysisTask(cfgc, TaskName{"lf-cascadefinderQA"}), - adaptAnalysisTask(cfgc, TaskName{"lf-cascadeinitializer"})}; + adaptAnalysisTask(cfgc, TaskName{"lf-cascadefinderQA"})}; } diff --git a/PWGLF/TableProducer/Strangeness/cascadeflow.cxx b/PWGLF/TableProducer/Strangeness/cascadeflow.cxx index 6f6b8b307a3..0b930932754 100644 --- a/PWGLF/TableProducer/Strangeness/cascadeflow.cxx +++ b/PWGLF/TableProducer/Strangeness/cascadeflow.cxx @@ -9,8 +9,11 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// +/// \file cascadeflow.cxx +/// /// \brief Task to create derived data for cascade flow analyses -/// \authors: Chiara De Martin (chiara.de.martin@cern.ch), Maximiliano Puccio (maximiliano.puccio@cern.ch) +/// \author Chiara De Martin (chiara.de.martin@cern.ch) +/// \author Maximiliano Puccio (maximiliano.puccio@cern.ch) #include #include @@ -30,6 +33,7 @@ #include "PWGLF/DataModel/LFStrangenessTables.h" #include "PWGLF/DataModel/LFStrangenessPIDTables.h" #include "Tools/ML/MlResponse.h" +#include "CCDB/BasicCCDBManager.h" using namespace o2; using namespace o2::framework; @@ -40,31 +44,52 @@ using std::array; using DauTracks = soa::Join; using CollEventPlane = soa::Join::iterator; using CollEventPlaneCentralFW = soa::Join::iterator; +using CollEventAndSpecPlane = soa::Join::iterator; +using CollEventAndSpecPlaneCentralFW = soa::Join::iterator; using MCCollisionsStra = soa::Join; +using V0Candidates = soa::Join; using CascCandidates = soa::Join; using CascMCCandidates = soa::Join; +const int nParticles = 2; // Xi, Omega +const int nCharges = 2; // Lambda, AntiLambda +const int nParameters = 4; + namespace cascadev2 { enum species { Xi = 0, Omega = 1 }; -constexpr double massSigmaParameters[4][2]{ +constexpr double massSigmaParameters[nParameters][nParticles]{ {4.9736e-3, 0.006815}, {-2.39594, -2.257}, {1.8064e-3, 0.00138}, {1.03468e-1, 0.1898}}; static const std::vector massSigmaParameterNames{"p0", "p1", "p2", "p3"}; static const std::vector speciesNames{"Xi", "Omega"}; - -std::shared_ptr hMassBeforeSelVsPt[2]; -std::shared_ptr hMassAfterSelVsPt[2]; -std::shared_ptr hSignalScoreBeforeSel[2]; -std::shared_ptr hBkgScoreBeforeSel[2]; -std::shared_ptr hSignalScoreAfterSel[2]; -std::shared_ptr hBkgScoreAfterSel[2]; -std::shared_ptr hSparseV2C[2]; +const double AlphaXi[2] = {-0.390, 0.371}; // decay parameter of XiMinus and XiPlus +const double AlphaOmega[2] = {0.0154, -0.018}; // decay parameter of OmegaMinus and OmegaPlus +const double AlphaLambda[2] = {0.747, -0.757}; // decay parameter of Lambda and AntiLambda + +std::shared_ptr hMassBeforeSelVsPt[nParticles]; +std::shared_ptr hMassAfterSelVsPt[nParticles]; +std::shared_ptr hSignalScoreBeforeSel[nParticles]; +std::shared_ptr hBkgScoreBeforeSel[nParticles]; +std::shared_ptr hSignalScoreAfterSel[nParticles]; +std::shared_ptr hBkgScoreAfterSel[nParticles]; +std::shared_ptr hSparseV2C[nParticles]; } // namespace cascadev2 +namespace lambdav2 +{ +enum species { Lambda = 0, + AntiLambda = 1 }; +static const std::vector speciesNames{"Lambda", "AntiLambda"}; +const double AlphaLambda[2] = {0.747, -0.757}; // decay parameter of Lambda and AntiLambda + +std::shared_ptr hMassBeforeSelVsPt[nCharges]; +std::shared_ptr hMassAfterSelVsPt[nCharges]; +} // namespace lambdav2 + namespace cascade_flow_cuts_ml { // direction of the cut @@ -124,12 +149,49 @@ static const std::vector labelsCutScore = {"Background score", "Sig struct cascadeFlow { + // Output filling criteria + struct : ConfigurableGroup { + Configurable isFillTree{"isFillTree", 1, ""}; + Configurable isFillTHNXi{"isFillTHNXi", 1, ""}; + Configurable isFillTHNXi_PzVsPsi{"isFillTHNXi_PzVsPsi", 1, ""}; + Configurable isFillTHNOmega{"isFillTHNOmega", 1, ""}; + Configurable isFillTHNOmega_PzVsPsi{"isFillTHNOmega_PzVsPsi", 1, ""}; + Configurable isFillTHNLambda{"isFillTHNLambda", 1, ""}; + Configurable isFillTHNLambda_PzVsPsi{"isFillTHNLambda_PzVsPsi", 1, ""}; + Configurable isFillTHN_V2{"isFillTHN_V2", 1, ""}; + Configurable isFillTHN_Pz{"isFillTHN_Pz", 1, ""}; + Configurable isFillTHN_PzFromLambda{"isFillTHN_PzFromLambda", 1, ""}; + Configurable isFillTHN_Acc{"isFillTHN_Acc", 1, ""}; + Configurable isFillTHN_AccFromLambdaVsCasc{"isFillTHN_AccFromLambdaVsCasc", 1, ""}; + Configurable isFillTHN_AccFromLambdaVsLambda{"isFillTHN_AccFromLambdaVsLambda", 1, ""}; + } fillingConfigs; + // axes ConfigurableAxis axisQVs{"axisQVs", {500, -10.f, 10.f}, "axisQVs"}; ConfigurableAxis axisQVsNorm{"axisQVsNorm", {200, -1.f, 1.f}, "axisQVsNorm"}; + // THN axes + ConfigurableAxis thnConfigAxisFT0C{"thnConfigAxisFT0C", {8, 0, 80}, "FT0C centrality (%)"}; + ConfigurableAxis thnConfigAxisEta{"thnConfigAxisEta", {8, -0.8, 0.8}, "pseudorapidity"}; + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {VARIABLE_WIDTH, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2, 2.25, 2.5, 2.75, 3, 3.5, 4, 5, 6, 8, 10}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis thnConfigAxisPtLambda{"thnConfigAxisPtLambda", {VARIABLE_WIDTH, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2, 2.25, 2.5, 2.75, 3, 3.5, 4, 5, 6, 8, 10, 20}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis thnConfigAxisCharge{"thnConfigAxisCharge", {2, 0, 2}, ""}; + ConfigurableAxis thnConfigAxisPsiDiff{"thnConfigAxisPsiDiff", {100, 0, o2::constants::math::TwoPI}, ""}; + ConfigurableAxis thnConfigAxisMassXi{"thnConfigAxisMassXi", {45, 1.300, 1.345}, ""}; + ConfigurableAxis thnConfigAxisMassOmega{"thnConfigAxisMassOmega", {45, 1.655, 1.690}, ""}; + ConfigurableAxis thnConfigAxisMassLambda{"thnConfigAxisMassLambda", {60, 1.1, 1.13}, ""}; + ConfigurableAxis thnConfigAxisBDTScore{"thnConfigAxisBDTScore", {15, 0.4, 1}, ""}; + ConfigurableAxis thnConfigAxisV2{"thnConfigAxiV2", {100, -1., 1.}, ""}; + ConfigurableAxis thnConfigAxisPzs2Xi{"thnConfigAxiPzs2Xi", {200, -2.8, 2.8}, ""}; + ConfigurableAxis thnConfigAxisPzs2Omega{"thnConfigAxiPzs2Omega", {200, -70, 70}, ""}; + ConfigurableAxis thnConfigAxisPzs2Lambda{"thnConfigAxiPzs2Lambda", {200, -2, 2}, ""}; + ConfigurableAxis thnConfigAxisCos2Theta{"thnConfigAxiCos2Theta", {100, 0, 1}, ""}; + ConfigurableAxis thnConfigAxisCos2ThetaL{"thnConfigAxiCos2ThetaL", {100, 0, 1}, ""}; + ConfigurableAxis thnConfigAxisCosThetaXiAlpha{"thnConfigAxisCosThetaXiAlpha", {200, -2.8, 2.8}, ""}; + ConfigurableAxis thnConfigAxisCosThetaOmegaAlpha{"thnConfigAxisCosThetaOmegaAlpha", {200, -70, 70}, ""}; + ConfigurableAxis thnConfigAxisCosThetaProtonAlpha{"thnConfigAxisCosThetaProtonAlpha", {200, -2, 2}, ""}; + // Event selection criteria - Configurable isStoreTrueCascOnly{"isStoreTrueCascOnly", 1, ""}; Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; Configurable sel8{"sel8", 1, "Apply sel8 event selection"}; Configurable isNoSameBunchPileupCut{"isNoSameBunchPileupCut", 1, "Same found-by-T0 bunch crossing rejection"}; @@ -146,8 +208,37 @@ struct cascadeFlow { Configurable isNoCollInRofStandard{"isNoCollInRofStandard", 0, "To remove collisions in the same ITS ROF and with a multiplicity above a certain threshold"}; Configurable isNoTVXinTRD{"isNoTVXinTRD", 0, "To remove collisions with trigger in TRD"}; - Configurable MinPt{"MinPt", 0.6, "Min pt of cascade"}; - Configurable MaxPt{"MaxPt", 10, "Max pt of cascade"}; + struct : ConfigurableGroup { + Configurable MinPt{"MinPt", 0.6, "Min pt of cascade"}; + Configurable MaxPt{"MaxPt", 10, "Max pt of cascade"}; + Configurable MinPtLambda{"MinPtLambda", 0.4, "Min pt of daughter lambda"}; + Configurable MaxPtLambda{"MaxPtLambda", 10, "Max pt of daughter lambda"}; + Configurable etaCasc{"etaCasc", 0.8, "etaCasc"}; + Configurable etaLambdaMax{"etaLambdaMax", 0.8, "etaLambdaMax"}; + Configurable MinLambdaMass{"MinLambdaMass", 1.1, ""}; + Configurable MaxLambdaMass{"MaxLambdaMass", 1.13, ""}; + Configurable MinXiMass{"MinXiMass", 1.300, ""}; + Configurable MaxXiMass{"MaxXiMass", 1.345, ""}; + Configurable MinOmegaMass{"MinOmegaMass", 1.655, ""}; + Configurable MaxOmegaMass{"MaxOmegaMass", 1.690, ""}; + } CandidateConfigs; + + struct : ConfigurableGroup { + Configurable MinPtV0{"MinPtV0", 0.2, "Min pt of v0"}; + Configurable MaxPtV0{"MaxPtV0", 10, "Max pt of v0"}; + Configurable MinMassLambda{"MinMassLambda", 1.105, ""}; + Configurable MaxMassLambda{"MaxMassLambda", 1.125, ""}; + Configurable etaV0{"etaV0", 0.8, "etaV0"}; + Configurable v0cospa{"v0cospa", 0.97, "min V0 CosPA"}; + Configurable dcav0dau{"dcav0dau", 1.0, "max DCA V0 Daughters (cm)"}; + Configurable dcanegtopv{"dcanegtopv", .05, "min DCA Neg To PV (cm)"}; + Configurable dcapostopv{"dcapostopv", .05, "min DCA Pos To PV (cm)"}; + Configurable v0radius{"v0radius", 1.2, "minimum V0 radius (cm)"}; + Configurable v0radiusMax{"v0radiusMax", 1E5, "maximum V0 radius (cm)"}; + Configurable rapidityLambda{"rapidityLambda", 0.5, "rapidityLambda"}; + Configurable etaLambda{"etaLambda", 0.8, "etaLambda"}; + } V0Configs; + Configurable sideBandStart{"sideBandStart", 5, "Start of the sideband region in number of sigmas"}; Configurable sideBandEnd{"sideBandEnd", 7, "End of the sideband region in number of sigmas"}; Configurable downsample{"downsample", 1., "Downsample training output tree"}; @@ -155,6 +246,8 @@ struct cascadeFlow { Configurable nsigmatpcPr{"nsigmatpcPr", 5, "nsigmatpcPr"}; Configurable nsigmatpcPi{"nsigmatpcPi", 5, "nsigmatpcPi"}; Configurable mintpccrrows{"mintpccrrows", 70, "mintpccrrows"}; + + Configurable isStoreTrueCascOnly{"isStoreTrueCascOnly", 1, ""}; Configurable etaCascMCGen{"etaCascMCGen", 0.8, "etaCascMCGen"}; Configurable yCascMCGen{"yCascMCGen", 0.5, "yCascMCGen"}; @@ -165,6 +258,13 @@ struct cascadeFlow { Configurable> onnxFileNamesOmega{"onnxFileNamesOmega", std::vector{"model_onnx.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; Configurable loadModelsFromCCDB{"loadModelsFromCCDB", true, "Flag to enable or disable the loading of models from CCDB"}; + Configurable acceptancePathsCCDBXi{"acceptancePathsCCDBXi", "Users/c/chdemart/AcceptanceXi", "Paths of Xi acceptance on CCDB"}; + Configurable acceptancePathsCCDBOmega{"acceptancePathsCCDBOmega", "Users/c/chdemart/AcceptanceOmega", "Paths of Omega acceptance on CCDB"}; + Configurable acceptancePathsCCDBLambda{"acceptancePathsCCDBLambda", "Users/c/chdemart/AcceptanceLambda", "Paths of Lambda acceptance on CCDB"}; + Configurable acceptancePathsCCDBPrimaryLambda{"acceptancePathsCCDBPrimaryLambda", "Users/c/chdemart/AcceptanceLambda", "Paths of PrimaryLambda acceptance on CCDB"}; + Configurable acceptanceHistoNameCasc{"acceptanceHistoNameCasc", "histoCos2ThetaNoFit2D", "Histo name of acceptance on CCDB"}; + Configurable acceptanceHistoNameLambda{"acceptanceHistoNameLambda", "histoCos2ThetaLambdaFromCNoFit2D", "Histo name of acceptance on CCDB"}; + Configurable acceptanceHistoNamePrimaryLambda{"acceptanceHistoNamePrimaryLambda", "histoCos2ThetaLambdaFromCNoFit2D", "Histo name of acceptance on CCDB"}; // ML inference Configurable isApplyML{"isApplyML", 1, "Flag to apply ML selections"}; @@ -173,7 +273,11 @@ struct cascadeFlow { Configurable> cutsMl{"cutsMl", {cascade_flow_cuts_ml::cuts[0], cascade_flow_cuts_ml::nBinsPt, cascade_flow_cuts_ml::nCutScores, cascade_flow_cuts_ml::labelsPt, cascade_flow_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; Configurable nClassesMl{"nClassesMl", static_cast(cascade_flow_cuts_ml::nCutScores), "Number of classes in ML model"}; + // acceptance crrection + Configurable applyAcceptanceCorrection{"applyAcceptanceCorrection", false, "apply acceptance correction"}; + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; // Add objects needed for ML inference o2::analysis::MlResponse mlResponseXi; @@ -197,7 +301,7 @@ struct cascadeFlow { histos.fill(HIST("hNEvents"), 1.5); // Z vertex selection - if (TMath::Abs(collision.posZ()) > cutzvertex) { + if (std::abs(collision.posZ()) > cutzvertex) { return false; } if (isFillHisto) @@ -289,17 +393,81 @@ struct cascadeFlow { return true; } + template + bool isLambdaAccepted(TDaughter negExtra, TDaughter posExtra, int& counter) // loose cuts on topological selections of v0s + { + // TPC cuts as those implemented for the training of the signal + if (doNTPCSigmaCut) { + if (std::abs(posExtra.tpcNSigmaPr()) > nsigmatpcPr || std::abs(negExtra.tpcNSigmaPi()) > nsigmatpcPi) + return false; + } + counter++; + + if (posExtra.tpcCrossedRows() < mintpccrrows || negExtra.tpcCrossedRows() < mintpccrrows) + return false; + + counter++; + return true; + } + template + bool isAntiLambdaAccepted(TDaughter negExtra, TDaughter posExtra, int& counter) // loose cuts on topological selections of v0s + { + // TPC cuts as those implemented for the training of the signal + if (doNTPCSigmaCut) { + if (std::abs(negExtra.tpcNSigmaPr()) > nsigmatpcPr || std::abs(posExtra.tpcNSigmaPi()) > nsigmatpcPi) + return false; + } + counter++; + + if (posExtra.tpcCrossedRows() < mintpccrrows || negExtra.tpcCrossedRows() < mintpccrrows) + return false; + + counter++; + return true; + } + + template + bool isV0TopoAccepted(TV0 v0) + { + // topological selections + if (v0.v0radius() < V0Configs.v0radius) + return false; + if (v0.v0radius() > V0Configs.v0radiusMax) + return false; + if (std::abs(v0.dcapostopv()) < V0Configs.dcapostopv) + return false; + if (std::abs(v0.dcanegtopv()) < V0Configs.dcanegtopv) + return false; + if (v0.v0cosPA() < V0Configs.v0cospa) + return false; + if (v0.dcaV0daughters() > V0Configs.dcav0dau) + return false; + // rapidity selection + if (std::abs(v0.yLambda()) > V0Configs.rapidityLambda) + return false; + if (std::abs(v0.eta()) > V0Configs.etaLambda) + return false; + + return true; + } + double GetPhiInRange(double phi) { while (phi < 0) { - phi += TMath::Pi(); + phi += o2::constants::math::PI; } - while (phi > TMath::Pi()) { - phi -= TMath::Pi(); + while (phi > o2::constants::math::PI) { + phi -= o2::constants::math::PI; } return phi; } + // objects to use for acceptance correction + TH2F* hAcceptanceXi; + TH2F* hAcceptanceOmega; + TH2F* hAcceptanceLambda; + TH2F* hAcceptancePrimaryLambda; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; HistogramRegistry histosMCGen{"histosMCGen", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; HistogramRegistry resolution{"resolution", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; @@ -309,13 +477,13 @@ struct cascadeFlow { Produces analysisSample; Configurable> parSigmaMass{ "parSigmaMass", - {cascadev2::massSigmaParameters[0], 4, 2, + {cascadev2::massSigmaParameters[0], nParameters, nParticles, cascadev2::massSigmaParameterNames, cascadev2::speciesNames}, "Mass resolution parameters: [0]*exp([1]*x)+[2]*exp([3]*x)"}; float getNsigmaMass(const cascadev2::species s, const float pt, const float nsigma = 6) { - const auto sigma = parSigmaMass->get(0u, s) * exp(parSigmaMass->get(1, s) * pt) + parSigmaMass->get(2, s) * exp(parSigmaMass->get(3, s) * pt); + const auto sigma = parSigmaMass->get(0u, s) * std::exp(parSigmaMass->get(1, s) * pt) + parSigmaMass->get(2, s) * std::exp(parSigmaMass->get(3, s) * pt); return nsigma * sigma; } @@ -345,21 +513,21 @@ struct cascadeFlow { } template - void fillAnalysedTable(collision_t coll, cascade_t casc, float v2CSP, float v2CEP, float PsiT0C, float BDTresponseXi, float BDTresponseOmega, int pdgCode) + void fillAnalysedTable(collision_t coll, bool hasEventPlane, bool hasSpectatorPlane, cascade_t casc, float v2CSP, float v2CEP, float v1SP_ZDCA, float v1SP_ZDCC, float PsiT0C, float BDTresponseXi, float BDTresponseOmega, int pdgCode) { - double masses[2]{o2::constants::physics::MassXiMinus, o2::constants::physics::MassOmegaMinus}; - ROOT::Math::PxPyPzMVector cascadeVector[2], lambdaVector, protonVector; - float cosThetaStarLambda[2], cosThetaStarProton; + double masses[nParticles]{o2::constants::physics::MassXiMinus, o2::constants::physics::MassOmegaMinus}; + ROOT::Math::PxPyPzMVector cascadeVector[nParticles], lambdaVector, protonVector; + float cosThetaStarLambda[nParticles], cosThetaStarProton; lambdaVector.SetCoordinates(casc.pxlambda(), casc.pylambda(), casc.pzlambda(), o2::constants::physics::MassLambda); ROOT::Math::Boost lambdaBoost{lambdaVector.BoostToCM()}; - if (casc.sign() < 0) { + if (casc.sign() > 0) { protonVector.SetCoordinates(casc.pxneg(), casc.pyneg(), casc.pzneg(), o2::constants::physics::MassProton); } else { protonVector.SetCoordinates(casc.pxpos(), casc.pypos(), casc.pzpos(), o2::constants::physics::MassProton); } auto boostedProton{lambdaBoost(protonVector)}; cosThetaStarProton = boostedProton.Pz() / boostedProton.P(); - for (int i{0}; i < 2; ++i) { + for (int i{0}; i < nParticles; ++i) { cascadeVector[i].SetCoordinates(casc.px(), casc.py(), casc.pz(), masses[i]); ROOT::Math::Boost cascadeBoost{cascadeVector[i].BoostToCM()}; auto boostedLambda{cascadeBoost(lambdaVector)}; @@ -370,10 +538,12 @@ struct cascadeFlow { bool isNoCollInTimeRangeStd = 0; if (coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) isNoCollInTimeRangeStd = 1; + // IN-ROF pile-up rejection bool isNoCollInRofStd = 0; if (coll.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) isNoCollInRofStd = 1; + // TVX in TRD // bool isTVXinTRD = 0; // if (coll.alias_bit(kTVXinTRD)) isTVXinTRD = 1; @@ -381,14 +551,19 @@ struct cascadeFlow { analysisSample(coll.centFT0C(), isNoCollInTimeRangeStd, isNoCollInRofStd, + hasEventPlane, + hasSpectatorPlane, casc.sign(), casc.pt(), casc.eta(), casc.phi(), + casc.mLambda(), casc.mXi(), casc.mOmega(), v2CSP, v2CEP, + v1SP_ZDCA, + v1SP_ZDCC, PsiT0C, BDTresponseXi, BDTresponseOmega, @@ -397,15 +572,58 @@ struct cascadeFlow { cosThetaStarProton, pdgCode); } + void initAcceptanceFromCCDB() + { + LOG(info) << "Loading acceptance from CCDB "; + TList* listAcceptanceXi = ccdb->get(acceptancePathsCCDBXi); + if (!listAcceptanceXi) + LOG(fatal) << "Problem getting TList object with acceptance for Xi!"; + TList* listAcceptanceOmega = ccdb->get(acceptancePathsCCDBOmega); + if (!listAcceptanceOmega) + LOG(fatal) << "Problem getting TList object with acceptance for Omega!"; + TList* listAcceptanceLambda = ccdb->get(acceptancePathsCCDBLambda); + if (!listAcceptanceLambda) + LOG(fatal) << "Problem getting TList object with acceptance for Lambda!"; + TList* listAcceptancePrimaryLambda = ccdb->get(acceptancePathsCCDBPrimaryLambda); + if (!listAcceptancePrimaryLambda) + LOG(fatal) << "Problem getting TList object with acceptance for Primary Lambda!"; + + hAcceptanceXi = static_cast(listAcceptanceXi->FindObject(Form("%s", acceptanceHistoNameCasc->data()))); + if (!hAcceptanceXi) { + LOG(fatal) << "The histogram for Xi is not there!"; + } + hAcceptanceXi->SetName("hAcceptanceXi"); + hAcceptanceOmega = static_cast(listAcceptanceOmega->FindObject(Form("%s", acceptanceHistoNameCasc->data()))); + if (!hAcceptanceOmega) { + LOG(fatal) << "The histogram for omega is not there!"; + } + hAcceptanceOmega->SetName("hAcceptanceOmega"); + hAcceptanceLambda = static_cast(listAcceptanceLambda->FindObject(Form("%s", acceptanceHistoNameLambda->data()))); + if (!hAcceptanceLambda) { + LOG(fatal) << "The histogram for Lambda is not there!"; + } + hAcceptanceLambda->SetName("hAcceptanceLambda"); + hAcceptancePrimaryLambda = static_cast(listAcceptancePrimaryLambda->FindObject(Form("%s", acceptanceHistoNamePrimaryLambda->data()))); + if (!hAcceptancePrimaryLambda) { + LOG(fatal) << "The histogram for Primary Lambda is not there!"; + } + hAcceptancePrimaryLambda->SetName("hAcceptancePrimaryLambda"); + LOG(info) << "Acceptance now loaded"; + } void init(InitContext const&) { float minMass[2]{1.28, 1.6}; float maxMass[2]{1.36, 1.73}; + float minMassLambda[2]{1.09, 1.09}; + float maxMassLambda[2]{1.14, 1.14}; const AxisSpec massCascAxis[2]{{static_cast((maxMass[0] - minMass[0]) / 0.001f), minMass[0], maxMass[0], "#Xi candidate mass (GeV/c^{2})"}, {static_cast((maxMass[1] - minMass[1]) / 0.001f), minMass[1], maxMass[1], "#Omega candidate mass (GeV/c^{2})"}}; - const AxisSpec ptAxis{static_cast((MaxPt - MinPt) / 0.2), MinPt, MaxPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec massLambdaAxis[2]{{static_cast((maxMassLambda[0] - minMassLambda[0]) / 0.001f), minMassLambda[0], maxMassLambda[0], "#Lambda candidate mass (GeV/c^{2})"}, + {static_cast((maxMassLambda[1] - minMassLambda[1]) / 0.001f), minMassLambda[1], maxMassLambda[1], "#bar{#Lambda} candidate mass (GeV/c^{2})"}}; + const AxisSpec ptAxisCasc{static_cast((CandidateConfigs.MaxPt - CandidateConfigs.MinPt) / 0.2), CandidateConfigs.MinPt, CandidateConfigs.MaxPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec ptAxisLambda{static_cast((V0Configs.MaxPtV0 - V0Configs.MinPtV0) / 0.2), V0Configs.MinPtV0, V0Configs.MaxPtV0, "#it{p}_{T} (GeV/#it{c})"}; const AxisSpec v2Axis{200, -1., 1., "#it{v}_{2}"}; const AxisSpec CentAxis{18, 0., 90., "FT0C centrality percentile"}; TString hNEventsLabels[10] = {"All", "sel8", "z vrtx", "kNoSameBunchPileup", "kIsGoodZvtxFT0vsPV", "trackOccupancyInTimeRange", "kNoCollInTimeRange", "kNoCollInROF", "kTVXinTRD", "kIsGoodEventEP"}; @@ -418,6 +636,7 @@ struct cascadeFlow { resolution.add("QVectorsNormT0CTPCA", "QVectorsNormT0CTPCA", HistType::kTH2F, {axisQVsNorm, CentAxis}); resolution.add("QVectorsNormT0CTPCC", "QVectorsNormT0CTPCC", HistType::kTH2F, {axisQVsNorm, CentAxis}); resolution.add("QVectorsNormTPCAC", "QVectorsNormTPCCB", HistType::kTH2F, {axisQVsNorm, CentAxis}); + resolution.add("QVectorsSpecPlane", "QVectorsSpecPlane", HistType::kTH2F, {axisQVsNorm, CentAxis}); histos.add("hNEvents", "hNEvents", {HistType::kTH1F, {{10, 0.f, 10.f}}}); for (Int_t n = 1; n <= histos.get(HIST("hNEvents"))->GetNbinsX(); n++) { @@ -425,8 +644,9 @@ struct cascadeFlow { } histos.add("hEventVertexZ", "hEventVertexZ", kTH1F, {{120, -12., 12.}}); histos.add("hEventCentrality", "hEventCentrality", kTH1F, {{101, 0, 101}}); - histos.add("hPsiT0C", "hPsiT0C", HistType::kTH1D, {{100, -TMath::Pi(), TMath::Pi()}}); - histos.add("hPsiT0CvsCentFT0C", "hPsiT0CvsCentFT0C", HistType::kTH2D, {CentAxis, {100, -TMath::Pi(), TMath::Pi()}}); + histos.add("hPsiT0C", "hPsiT0C", HistType::kTH1D, {{100, -o2::constants::math::PI, o2::constants::math::PI}}); + histos.add("hPsiT0CvsCentFT0C", "hPsiT0CvsCentFT0C", HistType::kTH2D, {CentAxis, {100, -o2::constants::math::PI, o2::constants::math::PI}}); + histos.add("hPsiZDCA_vs_ZDCC", "hPsiZDCA_vs_ZDCC", HistType::kTH2D, {{100, -o2::constants::math::PI, o2::constants::math::PI}, {100, -o2::constants::math::PI, o2::constants::math::PI}}); histos.add("hEventNchCorrelation", "hEventNchCorrelation", kTH2F, {{5000, 0, 5000}, {5000, 0, 2500}}); histos.add("hEventPVcontributorsVsCentrality", "hEventPVcontributorsVsCentrality", kTH2F, {{100, 0, 100}, {5000, 0, 5000}}); histos.add("hEventGlobalTracksVsCentrality", "hEventGlobalTracksVsCentrality", kTH2F, {{100, 0, 100}, {2500, 0, 2500}}); @@ -439,18 +659,116 @@ struct cascadeFlow { histos.add("hMultNTracksITSTPCVsCentrality", "hMultNTracksITSTPCVsCentrality", kTH2F, {{100, 0, 100}, {1000, 0, 5000}}); histos.add("hCandidate", "hCandidate", HistType::kTH1F, {{22, -0.5, 21.5}}); + histos.add("hLambdaCandidate", "hLambdaCandidate", HistType::kTH1F, {{5, -0.5, 4.5}}); histos.add("hCascadeSignal", "hCascadeSignal", HistType::kTH1F, {{6, -0.5, 5.5}}); histos.add("hCascade", "hCascade", HistType::kTH1F, {{6, -0.5, 5.5}}); + histos.add("hCascadeDauSel", "hCascadeDauSel", HistType::kTH1F, {{2, -0.5, 1.5}}); + histos.add("hLambdaDauSel", "hLambdaDauSel", HistType::kTH1F, {{3, -0.5, 2.5}}); + histos.add("hALambdaDauSel", "hALambdaDauSel", HistType::kTH1F, {{3, -0.5, 2.5}}); histos.add("hXiPtvsCent", "hXiPtvsCent", HistType::kTH2F, {{100, 0, 100}, {400, 0, 20}}); histos.add("hXiPtvsCentEta08", "hXiPtvsCentEta08", HistType::kTH2F, {{100, 0, 100}, {400, 0, 20}}); histos.add("hXiPtvsCentY05", "hXiPtvsCentY05", HistType::kTH2F, {{100, 0, 100}, {400, 0, 20}}); histos.add("hOmegaPtvsCent", "hOmegaPtvsCent", HistType::kTH2F, {{100, 0, 100}, {400, 0, 20}}); histos.add("hOmegaPtvsCentEta08", "hOmegaPtvsCentEta08", HistType::kTH2F, {{100, 0, 100}, {400, 0, 20}}); histos.add("hOmegaPtvsCentY05", "hOmegaPtvsCentY05", HistType::kTH2F, {{100, 0, 100}, {400, 0, 20}}); - histos.add("hCascadePhi", "hCascadePhi", HistType::kTH1F, {{100, 0, 2 * TMath::Pi()}}); - histos.add("hcascminuspsiT0C", "hcascminuspsiT0C", HistType::kTH1F, {{100, 0, TMath::Pi()}}); + histos.add("hCascadePhi", "hCascadePhi", HistType::kTH1F, {{100, 0, o2::constants::math::TwoPI}}); + histos.add("hcascminuspsiT0C", "hcascminuspsiT0C", HistType::kTH1F, {{100, 0, o2::constants::math::PI}}); + histos.add("hLambdaPhi", "hLambdaPhi", HistType::kTH1F, {{100, 0, o2::constants::math::TwoPI}}); + histos.add("hlambdaminuspsiT0C", "hlambdaminuspsiT0C", HistType::kTH1F, {{100, 0, o2::constants::math::PI}}); histos.add("hv2CEPvsFT0C", "hv2CEPvsFT0C", HistType::kTH2F, {CentAxis, {100, -1, 1}}); histos.add("hv2CEPvsv2CSP", "hv2CEPvsV2CSP", HistType::kTH2F, {{100, -1, 1}, {100, -1, 1}}); + histos.add("hv1EPvsv1SP", "hV1EPvsV1SP", HistType::kTH2F, {{100, -1, 1}, {100, -1, 1}}); + histos.add("hv1SP_ZDCA_vs_ZDCC", "hv1SP_ZDCA_vs_ZDCC", HistType::kTH2F, {{100, -1, 1}, {100, -1, 1}}); + + const AxisSpec thnAxisFT0C{thnConfigAxisFT0C, "FT0C (%)"}; + const AxisSpec thnAxisEta{thnConfigAxisEta, "#eta"}; + const AxisSpec thnAxisPt{thnConfigAxisPt, "p_{T}"}; + const AxisSpec thnAxisPtLambda{thnConfigAxisPtLambda, "p_{T, #Lambda}"}; + const AxisSpec thnAxisCharge{thnConfigAxisCharge, "Charge"}; + const AxisSpec thnAxisPsiDiff{thnConfigAxisPsiDiff, "2(phi-Psi)"}; + const AxisSpec thnAxisMassXi{thnConfigAxisMassXi, "inv. mass (#Lambda #pi) (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisMassOmega{thnConfigAxisMassOmega, "inv. mass (#Lambda K) (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisMassLambda{thnConfigAxisMassLambda, "inv. mass (p #pi) (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisBDTScore{thnConfigAxisBDTScore, "BDT score"}; + const AxisSpec thnAxisV2{thnConfigAxisV2, "v_{2}"}; + const AxisSpec thnAxisPzs2Xi{thnConfigAxisPzs2Xi, "Pzs2Xi"}; + const AxisSpec thnAxisPzs2Omega{thnConfigAxisPzs2Omega, "Pzs2Omega"}; + const AxisSpec thnAxisPzs2Lambda{thnConfigAxisPzs2Lambda, "Pzs2Lambda"}; + const AxisSpec thnAxisCos2Theta{thnConfigAxisCos2Theta, "Cos2Theta"}; + const AxisSpec thnAxisCos2ThetaL{thnConfigAxisCos2ThetaL, "Cos2ThetaL"}; + const AxisSpec thnAxisCosThetaXiAlpha{thnConfigAxisCosThetaXiAlpha, "CosThetaXiWithAlpha"}; + const AxisSpec thnAxisCosThetaOmegaAlpha{thnConfigAxisCosThetaOmegaAlpha, "CosThetaOmegaWithAlpha"}; + const AxisSpec thnAxisCosThetaProtonAlpha{thnConfigAxisCosThetaProtonAlpha, "CosThetaProtonWithAlpha"}; + + histos.add("massXi_ProtonAcc", "massXi", HistType::kTH1F, {thnAxisMassXi}); + histos.add("massOmega_ProtonAcc", "massOmega", HistType::kTH1F, {thnAxisMassOmega}); + + if (fillingConfigs.isFillTHNXi) { + if (fillingConfigs.isFillTHN_V2) + histos.add("hXiV2", "THn for v2 of Xi", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassXi, thnAxisBDTScore, thnAxisV2}); + if (fillingConfigs.isFillTHN_Pz) + histos.add("hXiPzs2", "THn for Pzs2 of Xi", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassXi, thnAxisBDTScore, thnAxisPzs2Xi}); + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.add("hXiPzs2FromLambda", "THn for Pzs2 of Xi", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassXi, thnAxisBDTScore, thnAxisPzs2Lambda}); + if (fillingConfigs.isFillTHN_Acc) + histos.add("hXiCos2Theta", "THn for Cos2Theta of Xi", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPt, thnAxisMassXi, thnAxisBDTScore, thnAxisCos2Theta}); + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.add("hXiCos2ThetaFromLambda", "THn for Cos2Theta of Lambda vs Xi mass and pt", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPt, thnAxisMassXi, thnAxisBDTScore, thnAxisCos2Theta}); + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.add("hXiCos2ThetaFromLambdaL", "THn for Cos2Theta of Lambda vs Lambda mass and pt", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPtLambda, thnAxisMassLambda, thnAxisBDTScore, thnAxisCos2ThetaL}); + } + if (fillingConfigs.isFillTHNXi_PzVsPsi) { + if (fillingConfigs.isFillTHN_Pz) + histos.add("hXiPzVsPsi", "THn for cosTheta of Xi", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassXi, thnAxisBDTScore, thnAxisCosThetaXiAlpha, thnAxisPsiDiff}); + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.add("hXiPzVsPsiFromLambda", "THn for cosTheta of Xi", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassXi, thnAxisBDTScore, thnAxisCosThetaProtonAlpha, thnAxisPsiDiff}); + if (fillingConfigs.isFillTHN_Acc) + histos.add("hXiCos2ThetaVsPsi", "THn for cos2Theta of Xi", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPt, thnAxisMassXi, thnAxisBDTScore, thnAxisCos2Theta, thnAxisPsiDiff}); + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.add("hXiCos2ThetaVsPsiFromLambda", "THn for cos2Theta of Lambda vs Xi mass and pt", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPt, thnAxisMassXi, thnAxisBDTScore, thnAxisCos2Theta, thnAxisPsiDiff}); + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.add("hXiCos2ThetaVsPsiFromLambdaL", "THn for cos2Theta of Lambda vs Lambda mass and pt", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPtLambda, thnAxisMassLambda, thnAxisBDTScore, thnAxisCos2ThetaL, thnAxisPsiDiff}); + } + if (fillingConfigs.isFillTHNOmega) { + if (fillingConfigs.isFillTHN_V2) + histos.add("hOmegaV2", "THn for v2 of Omega", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassOmega, thnAxisBDTScore, thnAxisV2}); + if (fillingConfigs.isFillTHN_Pz) + histos.add("hOmegaPzs2", "THn for Pzs2 of Omega", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassOmega, thnAxisBDTScore, thnAxisPzs2Omega}); + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.add("hOmegaPzs2FromLambda", "THn for Pzs2 of Omega", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassOmega, thnAxisBDTScore, thnAxisPzs2Lambda}); + if (fillingConfigs.isFillTHN_Acc) + histos.add("hOmegaCos2Theta", "THn for Cos2Theta of Omega", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPt, thnAxisMassOmega, thnAxisBDTScore, thnAxisCos2Theta}); + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.add("hOmegaCos2ThetaFromLambda", "THn for Cos2Theta of Lambda vs Omega mass and pt", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPt, thnAxisMassOmega, thnAxisBDTScore, thnAxisCos2Theta}); + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.add("hOmegaCos2ThetaFromLambdaL", "THn for Cos2Theta of Lambda vs Lambda mass and pt", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPtLambda, thnAxisMassLambda, thnAxisBDTScore, thnAxisCos2ThetaL}); + } + if (fillingConfigs.isFillTHNOmega_PzVsPsi) { + if (fillingConfigs.isFillTHN_Pz) + histos.add("hOmegaPzVsPsi", "THn for cosTheta of Omega", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassOmega, thnAxisBDTScore, thnAxisCosThetaOmegaAlpha, thnAxisPsiDiff}); + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.add("hOmegaPzVsPsiFromLambda", "THn for cosTheta of Omega", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPt, thnAxisMassOmega, thnAxisBDTScore, thnAxisCosThetaProtonAlpha, thnAxisPsiDiff}); + if (fillingConfigs.isFillTHN_Acc) + histos.add("hOmegaCos2ThetaVsPsi", "THn for cos2Theta of Omega", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPt, thnAxisMassOmega, thnAxisBDTScore, thnAxisCos2Theta, thnAxisPsiDiff}); + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.add("hOmegaCos2ThetaVsPsiFromLambda", "THn for cos2Theta of Lambda vs Omega mass and pt", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPt, thnAxisMassOmega, thnAxisBDTScore, thnAxisCos2Theta, thnAxisPsiDiff}); + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.add("hOmegaCos2ThetaVsPsiFromLambdaL", "THn for cos2Theta of Lambda vs Lambda mass and pt", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPtLambda, thnAxisMassLambda, thnAxisBDTScore, thnAxisCos2ThetaL, thnAxisPsiDiff}); + } + if (fillingConfigs.isFillTHNLambda) { + if (fillingConfigs.isFillTHN_V2) + histos.add("hLambdaV2", "THn for v2 of Lambda", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPtLambda, thnAxisMassLambda, thnAxisV2}); + if (fillingConfigs.isFillTHN_Pz) + histos.add("hLambdaPzs2", "THn for Pzs2 of Lambda", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPtLambda, thnAxisMassLambda, thnAxisPzs2Lambda}); + if (fillingConfigs.isFillTHN_Acc) + histos.add("hLambdaCos2Theta", "THn for Cos2Theta of Lambda", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPtLambda, thnAxisMassLambda, thnAxisCos2Theta}); + } + if (fillingConfigs.isFillTHNLambda_PzVsPsi) { + if (fillingConfigs.isFillTHN_Pz) + histos.add("hLambdaPzVsPsi", "THn for cosTheta of Lambda", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisPtLambda, thnAxisMassLambda, thnAxisCosThetaProtonAlpha, thnAxisPsiDiff}); + if (fillingConfigs.isFillTHN_Acc) + histos.add("hLambdaCos2ThetaVsPsi", "THn for cos2Theta of Lambda", HistType::kTHnF, {thnAxisFT0C, thnAxisCharge, thnAxisEta, thnAxisPtLambda, thnAxisMassLambda, thnAxisCos2Theta, thnAxisPsiDiff}); + } histosMCGen.add("h2DGenXiEta08", "h2DGenXiEta08", HistType::kTH2F, {{100, 0, 100}, {400, 0, 20}}); histosMCGen.add("h2DGenOmegaEta08", "h2DGenOmegaEta08", HistType::kTH2F, {{100, 0, 100}, {400, 0, 20}}); @@ -468,15 +786,20 @@ struct cascadeFlow { histosMCGen.get(HIST("hNCascGen"))->GetXaxis()->SetBinLabel(n, hNCascLabelsMC[n - 1]); } - for (int iS{0}; iS < 2; ++iS) { - cascadev2::hMassBeforeSelVsPt[iS] = histos.add(Form("hMassBeforeSelVsPt%s", cascadev2::speciesNames[iS].data()), "hMassBeforeSelVsPt", HistType::kTH2F, {massCascAxis[iS], ptAxis}); - cascadev2::hMassAfterSelVsPt[iS] = histos.add(Form("hMassAfterSelVsPt%s", cascadev2::speciesNames[iS].data()), "hMassAfterSelVsPt", HistType::kTH2F, {massCascAxis[iS], ptAxis}); + for (int iS{0}; iS < nParticles; ++iS) { + cascadev2::hMassBeforeSelVsPt[iS] = histos.add(Form("hMassBeforeSelVsPt%s", cascadev2::speciesNames[iS].data()), "hMassBeforeSelVsPt", HistType::kTH2F, {massCascAxis[iS], ptAxisCasc}); + cascadev2::hMassAfterSelVsPt[iS] = histos.add(Form("hMassAfterSelVsPt%s", cascadev2::speciesNames[iS].data()), "hMassAfterSelVsPt", HistType::kTH2F, {massCascAxis[iS], ptAxisCasc}); cascadev2::hSignalScoreBeforeSel[iS] = histos.add(Form("hSignalScoreBeforeSel%s", cascadev2::speciesNames[iS].data()), "Signal score before selection;BDT first score;entries", HistType::kTH1F, {{100, 0., 1.}}); cascadev2::hBkgScoreBeforeSel[iS] = histos.add(Form("hBkgScoreBeforeSel%s", cascadev2::speciesNames[iS].data()), "Bkg score before selection;BDT first score;entries", HistType::kTH1F, {{100, 0., 1.}}); cascadev2::hSignalScoreAfterSel[iS] = histos.add(Form("hSignalScoreAfterSel%s", cascadev2::speciesNames[iS].data()), "Signal score after selection;BDT first score;entries", HistType::kTH1F, {{100, 0., 1.}}); cascadev2::hBkgScoreAfterSel[iS] = histos.add(Form("hBkgScoreAfterSel%s", cascadev2::speciesNames[iS].data()), "Bkg score after selection;BDT first score;entries", HistType::kTH1F, {{100, 0., 1.}}); - cascadev2::hSparseV2C[iS] = histos.add(Form("hSparseV2C%s", cascadev2::speciesNames[iS].data()), "hSparseV2C", HistType::kTHnSparseF, {massCascAxis[iS], ptAxis, v2Axis, CentAxis}); + cascadev2::hSparseV2C[iS] = histos.add(Form("hSparseV2C%s", cascadev2::speciesNames[iS].data()), "hSparseV2C", HistType::kTHnF, {massCascAxis[iS], ptAxisCasc, v2Axis, CentAxis}); } + for (int iS{0}; iS < nCharges; ++iS) { + lambdav2::hMassBeforeSelVsPt[iS] = histos.add(Form("hMassBeforeSelVsPt%s", lambdav2::speciesNames[iS].data()), "hMassBeforeSelVsPt", HistType::kTH2F, {massLambdaAxis[iS], ptAxisLambda}); + lambdav2::hMassAfterSelVsPt[iS] = histos.add(Form("hMassAfterSelVsPt%s", lambdav2::speciesNames[iS].data()), "hMassAfterSelVsPt", HistType::kTH2F, {massLambdaAxis[iS], ptAxisLambda}); + } + if (isApplyML) { // Configure and initialise the ML class mlResponseXi.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); @@ -493,6 +816,13 @@ struct cascadeFlow { mlResponseXi.init(); mlResponseOmega.init(); } + if (applyAcceptanceCorrection) { + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + initAcceptanceFromCCDB(); + } } void processTrainingBackground(soa::Join::iterator const& coll, soa::Join const& Cascades, DauTracks const&) @@ -507,7 +837,7 @@ struct cascadeFlow { histos.fill(HIST("hEventCentrality"), coll.centFT0C()); histos.fill(HIST("hEventVertexZ"), coll.posZ()); - for (auto& casc : Cascades) { + for (auto const& casc : Cascades) { if (gRandom->Uniform() > downsample) { continue; } @@ -557,14 +887,14 @@ struct cascadeFlow { histos.fill(HIST("hEventCentrality"), coll.centFT0C()); histos.fill(HIST("hEventVertexZ"), coll.posZ()); - for (auto& casc : Cascades) { + for (auto const& casc : Cascades) { if (!casc.has_cascMCCore()) continue; auto cascMC = casc.cascMCCore_as>(); int pdgCode{cascMC.pdgCode()}; - if (!(std::abs(pdgCode) == 3312 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 211) // Xi - && !(std::abs(pdgCode) == 3334 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 321)) // Omega + if (!(std::abs(pdgCode) == PDG_t::kXiMinus && std::abs(cascMC.pdgCodeV0()) == PDG_t::kLambda0 && std::abs(cascMC.pdgCodeBachelor()) == PDG_t::kPiPlus) // Xi + && !(std::abs(pdgCode) == PDG_t::kOmegaMinus && std::abs(cascMC.pdgCodeV0()) == PDG_t::kLambda0 && std::abs(cascMC.pdgCodeBachelor()) == kKPlus)) // Omega continue; auto negExtra = casc.negTrackExtra_as(); @@ -572,15 +902,17 @@ struct cascadeFlow { auto bachExtra = casc.bachTrackExtra_as(); int counter = 0; - IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); + bool isCascCandidate = 0; + isCascCandidate = IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); histos.fill(HIST("hCascadeSignal"), counter); // PDG cascades - fillTrainingTable(coll, casc, pdgCode); + if (isCascCandidate) + fillTrainingTable(coll, casc, pdgCode); // I only store cascades that passed PID and track quality selections } } - void processAnalyseData(CollEventPlane const& coll, CascCandidates const& Cascades, DauTracks const&) + void processAnalyseData(CollEventAndSpecPlane const& coll, CascCandidates const& Cascades, DauTracks const&) { if (!AcceptEvent(coll, 1)) { @@ -591,6 +923,17 @@ struct cascadeFlow { if (isGoodEventEP && !coll.triggereventep()) { return; } + + // event has event plane + bool hasEventPlane = 0; + if (coll.triggereventep()) + hasEventPlane = 1; + + // event has spectator plane + bool hasSpectatorPlane = 0; + if (coll.triggereventsp()) + hasSpectatorPlane = 1; + histos.fill(HIST("hNEvents"), 9.5); histos.fill(HIST("hEventNchCorrelationAfterEP"), coll.multNTracksPVeta1(), coll.multNTracksGlobal()); histos.fill(HIST("hEventPVcontributorsVsCentralityAfterEP"), coll.centFT0C(), coll.multNTracksPVeta1()); @@ -602,9 +945,12 @@ struct cascadeFlow { ROOT::Math::XYZVector eventplaneVecT0C{coll.qvecFT0CRe(), coll.qvecFT0CIm(), 0}; ROOT::Math::XYZVector eventplaneVecTPCA{coll.qvecBPosRe(), coll.qvecBPosIm(), 0}; ROOT::Math::XYZVector eventplaneVecTPCC{coll.qvecBNegRe(), coll.qvecBNegIm(), 0}; + ROOT::Math::XYZVector spectatorplaneVecZDCA{std::cos(coll.psiZDCA()), std::sin(coll.psiZDCA()), 0}; // eta positive = projectile + ROOT::Math::XYZVector spectatorplaneVecZDCC{std::cos(coll.psiZDCC()), std::sin(coll.psiZDCC()), 0}; // eta negative = target const float PsiT0C = std::atan2(coll.qvecFT0CIm(), coll.qvecFT0CRe()) * 0.5f; histos.fill(HIST("hPsiT0C"), PsiT0C); + histos.fill(HIST("hPsiZDCA_vs_ZDCC"), coll.psiZDCC(), coll.psiZDCA()); histos.fill(HIST("hPsiT0CvsCentFT0C"), coll.centFT0C(), PsiT0C); resolution.fill(HIST("QVectorsT0CTPCA"), eventplaneVecT0C.Dot(eventplaneVecTPCA), coll.centFT0C()); @@ -613,9 +959,10 @@ struct cascadeFlow { resolution.fill(HIST("QVectorsNormT0CTPCA"), eventplaneVecT0C.Dot(eventplaneVecTPCA) / (coll.qTPCR() * coll.sumAmplFT0C()), coll.centFT0C()); resolution.fill(HIST("QVectorsNormT0CTPCC"), eventplaneVecT0C.Dot(eventplaneVecTPCC) / (coll.qTPCL() * coll.sumAmplFT0C()), coll.centFT0C()); resolution.fill(HIST("QVectorsNormTPCAC"), eventplaneVecTPCA.Dot(eventplaneVecTPCC) / (coll.qTPCR() * coll.qTPCL()), coll.centFT0C()); + resolution.fill(HIST("QVectorsSpecPlane"), spectatorplaneVecZDCC.Dot(spectatorplaneVecZDCA), coll.centFT0C()); - std::vector bdtScore[2]; - for (auto& casc : Cascades) { + std::vector bdtScore[nParticles]; + for (auto const& casc : Cascades) { /// Add some minimal cuts for single track variables (min number of TPC clusters) auto negExtra = casc.negTrackExtra_as(); @@ -623,8 +970,12 @@ struct cascadeFlow { auto bachExtra = casc.bachTrackExtra_as(); int counter = 0; - IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); + bool isCascCandidate = 0; + isCascCandidate = IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); histos.fill(HIST("hCascade"), counter); + histos.fill(HIST("hCascadeDauSel"), (int)isCascCandidate); + if (!isCascCandidate) + continue; // ML selections bool isSelectedCasc[2]{false, false}; @@ -644,8 +995,8 @@ struct cascadeFlow { float massCasc[2]{casc.mXi(), casc.mOmega()}; - // inv mass loose cut - if (casc.pt() < MinPt || casc.pt() > MaxPt) { + // pt cut + if (casc.pt() < CandidateConfigs.MinPt || casc.pt() > CandidateConfigs.MaxPt) { continue; } @@ -657,7 +1008,7 @@ struct cascadeFlow { isSelectedCasc[0] = mlResponseXi.isSelectedMl(inputFeaturesCasc, casc.pt(), bdtScore[0]); isSelectedCasc[1] = mlResponseOmega.isSelectedMl(inputFeaturesCasc, casc.pt(), bdtScore[1]); - for (int iS{0}; iS < 2; ++iS) { + for (int iS{0}; iS < nParticles; ++iS) { // Fill BDT score histograms before selection cascadev2::hSignalScoreBeforeSel[iS]->Fill(bdtScore[0][1]); cascadev2::hBkgScoreBeforeSel[iS]->Fill(bdtScore[1][0]); @@ -677,12 +1028,79 @@ struct cascadeFlow { ROOT::Math::XYZVector cascQvec{std::cos(2 * casc.phi()), std::sin(2 * casc.phi()), 0}; auto v2CSP = cascQvec.Dot(eventplaneVecT0C); // not normalised by amplitude auto cascminuspsiT0C = GetPhiInRange(casc.phi() - PsiT0C); - auto v2CEP = TMath::Cos(2.0 * cascminuspsiT0C); + auto v2CEP = std::cos(2.0 * cascminuspsiT0C); + ROOT::Math::XYZVector cascUvec{std::cos(casc.phi()), std::sin(casc.phi()), 0}; + auto v1SP_ZDCA = cascUvec.Dot(spectatorplaneVecZDCA); + auto v1SP_ZDCC = cascUvec.Dot(spectatorplaneVecZDCC); + auto v1EP_ZDCA = std::cos(casc.phi() - coll.psiZDCA()); + auto v1EP_ZDCC = std::cos(casc.phi() - coll.psiZDCC()); + float v1SP = 0.5 * (v1SP_ZDCA - v1SP_ZDCC); + float v1EP = 0.5 * (v1EP_ZDCA - v1EP_ZDCC); // same as v1SP + + // polarization variables + double masses[2]{o2::constants::physics::MassXiMinus, o2::constants::physics::MassOmegaMinus}; + ROOT::Math::PxPyPzMVector cascadeVector[2], lambdaVector, protonVector; + float cosThetaStarLambda[2], cosThetaStarProton; + lambdaVector.SetCoordinates(casc.pxlambda(), casc.pylambda(), casc.pzlambda(), o2::constants::physics::MassLambda); + ROOT::Math::Boost lambdaBoost{lambdaVector.BoostToCM()}; + if (casc.sign() > 0) { + protonVector.SetCoordinates(casc.pxneg(), casc.pyneg(), casc.pzneg(), o2::constants::physics::MassProton); + } else { + protonVector.SetCoordinates(casc.pxpos(), casc.pypos(), casc.pzpos(), o2::constants::physics::MassProton); + } + auto boostedProton{lambdaBoost(protonVector)}; + cosThetaStarProton = boostedProton.Pz() / boostedProton.P(); + for (int i{0}; i < nParticles; ++i) { + cascadeVector[i].SetCoordinates(casc.px(), casc.py(), casc.pz(), masses[i]); + ROOT::Math::Boost cascadeBoost{cascadeVector[i].BoostToCM()}; + auto boostedLambda{cascadeBoost(lambdaVector)}; + cosThetaStarLambda[i] = boostedLambda.Pz() / boostedLambda.P(); + } + + double ptLambda = std::sqrt(std::pow(casc.pxlambda(), 2) + std::pow(casc.pylambda(), 2)); + auto etaLambda = RecoDecay::eta(std::array{casc.pxlambda(), casc.pylambda(), casc.pzlambda()}); + + // acceptance values if requested + double meanCos2ThetaLambdaFromXi = 1; + double meanCos2ThetaLambdaFromOmega = 1; + double meanCos2ThetaProtonFromLambda = 1; + if (applyAcceptanceCorrection) { + if (ptLambda < CandidateConfigs.MinPtLambda || ptLambda > CandidateConfigs.MaxPtLambda) { + continue; + } + if (std::abs(casc.eta()) > CandidateConfigs.etaCasc) + continue; + if (std::abs(etaLambda) > CandidateConfigs.etaLambdaMax) + continue; + int bin2DXi = hAcceptanceXi->FindBin(casc.pt(), casc.eta()); + int bin2DOmega = hAcceptanceOmega->FindBin(casc.pt(), casc.eta()); + int bin2DLambda = hAcceptanceLambda->FindBin(ptLambda, etaLambda); + meanCos2ThetaLambdaFromXi = hAcceptanceXi->GetBinContent(bin2DXi); + meanCos2ThetaLambdaFromOmega = hAcceptanceOmega->GetBinContent(bin2DOmega); + meanCos2ThetaProtonFromLambda = hAcceptanceLambda->GetBinContent(bin2DLambda); + } + + int chargeIndex = 0; + if (casc.sign() > 0) + chargeIndex = 1; + double pzs2Xi = cosThetaStarLambda[0] * std::sin(2 * (casc.phi() - PsiT0C)) / cascadev2::AlphaXi[chargeIndex] / meanCos2ThetaLambdaFromXi; + double pzs2Omega = cosThetaStarLambda[1] * std::sin(2 * (casc.phi() - PsiT0C)) / cascadev2::AlphaOmega[chargeIndex] / meanCos2ThetaLambdaFromOmega; + double cos2ThetaXi = cosThetaStarLambda[0] * cosThetaStarLambda[0]; + double cos2ThetaOmega = cosThetaStarLambda[1] * cosThetaStarLambda[1]; + double pzs2LambdaFromCasc = cosThetaStarProton * std::sin(2 * (casc.phi() - PsiT0C)) / cascadev2::AlphaLambda[chargeIndex] / meanCos2ThetaProtonFromLambda; + double cos2ThetaLambda = cosThetaStarProton * cosThetaStarProton; + + double cosThetaXiWithAlpha = cosThetaStarLambda[0] / cascadev2::AlphaXi[chargeIndex]; + double cosThetaOmegaWithAlpha = cosThetaStarLambda[1] / cascadev2::AlphaOmega[chargeIndex]; + double cosThetaProtonWithAlpha = cosThetaStarProton / cascadev2::AlphaLambda[chargeIndex]; histos.fill(HIST("hv2CEPvsFT0C"), coll.centFT0C(), v2CEP); histos.fill(HIST("hv2CEPvsv2CSP"), v2CSP, v2CEP); + histos.fill(HIST("hv1EPvsv1SP"), v1SP, v1EP); + histos.fill(HIST("hv1SP_ZDCA_vs_ZDCC"), v1SP_ZDCC, v1SP_ZDCA); histos.fill(HIST("hCascadePhi"), casc.phi()); histos.fill(HIST("hcascminuspsiT0C"), cascminuspsiT0C); + double values[4]{casc.mXi(), casc.pt(), v2CSP, coll.centFT0C()}; if (isSelectedCasc[0]) { cascadev2::hSparseV2C[0]->Fill(values); @@ -692,17 +1110,366 @@ struct cascadeFlow { cascadev2::hSparseV2C[0]->Fill(values); } - float BDTresponse[2]{0.f, 0.f}; + float BDTresponse[nParticles]{0.f, 0.f}; if (isApplyML) { BDTresponse[0] = bdtScore[0][1]; BDTresponse[1] = bdtScore[1][1]; } - if (isSelectedCasc[0] || isSelectedCasc[1]) - fillAnalysedTable(coll, casc, v2CSP, v2CEP, PsiT0C, BDTresponse[0], BDTresponse[1], 0); + + if (std::abs(casc.eta()) < CandidateConfigs.etaCasc) { + if (fillingConfigs.isFillTHNXi) { + if (fillingConfigs.isFillTHN_V2) + histos.get(HIST("hXiV2"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], v2CEP); + if (fillingConfigs.isFillTHN_Pz) + histos.get(HIST("hXiPzs2"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], pzs2Xi); + if (casc.mLambda() > CandidateConfigs.MinLambdaMass && casc.mLambda() < CandidateConfigs.MaxLambdaMass) { + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.get(HIST("hXiPzs2FromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], pzs2LambdaFromCasc); + } + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hXiCos2Theta"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mXi(), BDTresponse[0], cos2ThetaXi); + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.get(HIST("hXiCos2ThetaFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mXi(), BDTresponse[0], cos2ThetaLambda); + if (casc.mXi() > CandidateConfigs.MinXiMass && casc.mXi() < CandidateConfigs.MaxXiMass) { + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.get(HIST("hXiCos2ThetaFromLambdaL"))->Fill(coll.centFT0C(), chargeIndex, etaLambda, ptLambda, casc.mLambda(), BDTresponse[0], cos2ThetaLambda); + histos.get(HIST("massXi_ProtonAcc"))->Fill(casc.mXi()); + } + } + if (fillingConfigs.isFillTHNXi_PzVsPsi) { + if (fillingConfigs.isFillTHN_Pz) + histos.get(HIST("hXiPzVsPsi"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], cosThetaXiWithAlpha, 2 * cascminuspsiT0C); + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.get(HIST("hXiPzVsPsiFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], cosThetaProtonWithAlpha, 2 * cascminuspsiT0C); + if (casc.mLambda() > CandidateConfigs.MinLambdaMass && casc.mLambda() < CandidateConfigs.MaxLambdaMass) { + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hXiCos2ThetaVsPsi"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mXi(), BDTresponse[0], cos2ThetaXi, 2 * cascminuspsiT0C); + } + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.get(HIST("hXiCos2ThetaVsPsiFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mXi(), BDTresponse[0], cos2ThetaLambda, 2 * cascminuspsiT0C); + if (casc.mXi() > CandidateConfigs.MinXiMass && casc.mXi() < CandidateConfigs.MaxXiMass) { + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.get(HIST("hXiCos2ThetaVsPsiFromLambdaL"))->Fill(coll.centFT0C(), chargeIndex, etaLambda, ptLambda, casc.mLambda(), BDTresponse[0], cos2ThetaLambda, 2 * cascminuspsiT0C); + histos.get(HIST("massXi_ProtonAcc"))->Fill(casc.mXi()); + } + } + if (fillingConfigs.isFillTHNOmega) { + if (fillingConfigs.isFillTHN_V2) + histos.get(HIST("hOmegaV2"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], v2CEP); + if (fillingConfigs.isFillTHN_Pz) + histos.get(HIST("hOmegaPzs2"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], pzs2Omega); + if (casc.mLambda() > CandidateConfigs.MinLambdaMass && casc.mLambda() < CandidateConfigs.MaxLambdaMass) { + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.get(HIST("hOmegaPzs2FromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], pzs2LambdaFromCasc); + } + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hOmegaCos2Theta"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mOmega(), BDTresponse[1], cos2ThetaOmega); + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.get(HIST("hOmegaCos2ThetaFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mOmega(), BDTresponse[1], cos2ThetaLambda); + if (casc.mOmega() > CandidateConfigs.MinOmegaMass && casc.mOmega() < CandidateConfigs.MaxOmegaMass) { + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.get(HIST("hOmegaCos2ThetaFromLambdaL"))->Fill(coll.centFT0C(), chargeIndex, etaLambda, ptLambda, casc.mLambda(), BDTresponse[1], cos2ThetaLambda); + histos.get(HIST("massOmega_ProtonAcc"))->Fill(casc.mOmega()); + } + } + if (fillingConfigs.isFillTHNOmega_PzVsPsi) { + if (fillingConfigs.isFillTHN_Pz) + histos.get(HIST("hOmegaPzVsPsi"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], cosThetaOmegaWithAlpha, 2 * cascminuspsiT0C); + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.get(HIST("hOmegaPzVsPsiFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], cosThetaProtonWithAlpha, 2 * cascminuspsiT0C); + if (casc.mLambda() > CandidateConfigs.MinLambdaMass && casc.mLambda() < CandidateConfigs.MaxLambdaMass) { + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hOmegaCos2ThetaVsPsi"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mOmega(), BDTresponse[1], cos2ThetaOmega, 2 * cascminuspsiT0C); + } + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.get(HIST("hOmegaCos2ThetaVsPsiFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mOmega(), BDTresponse[1], cos2ThetaLambda, 2 * cascminuspsiT0C); + if (casc.mOmega() > CandidateConfigs.MinOmegaMass && casc.mOmega() < CandidateConfigs.MaxOmegaMass) { + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.get(HIST("hOmegaCos2ThetaVsPsiFromLambdaL"))->Fill(coll.centFT0C(), chargeIndex, etaLambda, ptLambda, casc.mLambda(), BDTresponse[1], cos2ThetaLambda, 2 * cascminuspsiT0C); + histos.get(HIST("massOmega_ProtonAcc"))->Fill(casc.mOmega()); + } + } + } + + if (isSelectedCasc[0] || isSelectedCasc[1]) { + if (fillingConfigs.isFillTree) + fillAnalysedTable(coll, hasEventPlane, hasSpectatorPlane, casc, v2CSP, v2CEP, v1SP_ZDCA, v1SP_ZDCC, PsiT0C, BDTresponse[0], BDTresponse[1], 0); + } + } + } + + void processAnalyseDataEP2CentralFW(CollEventPlaneCentralFW const& coll, CascCandidates const& Cascades, DauTracks const&) + { + + if (!AcceptEvent(coll, 1)) { + return; + } + + // select only events used for the calibration of the event plane + if (isGoodEventEP) { + if (std::abs(coll.qvecFT0CRe()) > 990 || std::abs(coll.qvecFT0CIm()) > 990 || std::abs(coll.qvecBNegRe()) > 990 || std::abs(coll.qvecBNegIm()) > 990 || std::abs(coll.qvecBPosRe()) > 990 || std::abs(coll.qvecBPosIm()) > 990) { + return; + } + } + + // event has FT0C event plane + bool hasEventPlane = 0; + if (std::abs(coll.qvecFT0CRe()) < 990 && std::abs(coll.qvecFT0CIm()) < 990) + hasEventPlane = 1; + + histos.fill(HIST("hNEvents"), 9.5); + histos.fill(HIST("hEventNchCorrelationAfterEP"), coll.multNTracksPVeta1(), coll.multNTracksGlobal()); + histos.fill(HIST("hEventPVcontributorsVsCentralityAfterEP"), coll.centFT0C(), coll.multNTracksPVeta1()); + histos.fill(HIST("hEventGlobalTracksVsCentralityAfterEP"), coll.centFT0C(), coll.multNTracksGlobal()); + + histos.fill(HIST("hEventCentrality"), coll.centFT0C()); + histos.fill(HIST("hEventVertexZ"), coll.posZ()); + + ROOT::Math::XYZVector eventplaneVecT0C{coll.qvecFT0CRe(), coll.qvecFT0CIm(), 0}; + ROOT::Math::XYZVector eventplaneVecTPCA{coll.qvecBPosRe(), coll.qvecBPosIm(), 0}; + ROOT::Math::XYZVector eventplaneVecTPCC{coll.qvecBNegRe(), coll.qvecBNegIm(), 0}; + + const float PsiT0C = std::atan2(coll.qvecFT0CIm(), coll.qvecFT0CRe()) * 0.5f; + histos.fill(HIST("hPsiT0C"), PsiT0C); + histos.fill(HIST("hPsiT0CvsCentFT0C"), coll.centFT0C(), PsiT0C); + + resolution.fill(HIST("QVectorsT0CTPCA"), eventplaneVecT0C.Dot(eventplaneVecTPCA), coll.centFT0C()); + resolution.fill(HIST("QVectorsT0CTPCC"), eventplaneVecT0C.Dot(eventplaneVecTPCC), coll.centFT0C()); + resolution.fill(HIST("QVectorsTPCAC"), eventplaneVecTPCA.Dot(eventplaneVecTPCC), coll.centFT0C()); + resolution.fill(HIST("QVectorsNormT0CTPCA"), eventplaneVecT0C.Dot(eventplaneVecTPCA) / (coll.qTPCR() * coll.sumAmplFT0C()), coll.centFT0C()); + resolution.fill(HIST("QVectorsNormT0CTPCC"), eventplaneVecT0C.Dot(eventplaneVecTPCC) / (coll.qTPCL() * coll.sumAmplFT0C()), coll.centFT0C()); + resolution.fill(HIST("QVectorsNormTPCAC"), eventplaneVecTPCA.Dot(eventplaneVecTPCC) / (coll.qTPCR() * coll.qTPCL()), coll.centFT0C()); + + std::vector bdtScore[nParticles]; + for (auto const& casc : Cascades) { + + /// Add some minimal cuts for single track variables (min number of TPC clusters) + auto negExtra = casc.negTrackExtra_as(); + auto posExtra = casc.posTrackExtra_as(); + auto bachExtra = casc.bachTrackExtra_as(); + + int counter = 0; + bool isCascCandidate = 0; + isCascCandidate = IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); + histos.fill(HIST("hCascade"), counter); + histos.fill(HIST("hCascadeDauSel"), (int)isCascCandidate); + if (!isCascCandidate) + continue; + + // ML selections + bool isSelectedCasc[nParticles]{false, false}; + + std::vector inputFeaturesCasc{casc.cascradius(), + casc.v0radius(), + casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()), + casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ()), + casc.dcapostopv(), + casc.dcanegtopv(), + casc.dcabachtopv(), + casc.dcacascdaughters(), + casc.dcaV0daughters(), + casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ()), + casc.bachBaryonCosPA(), + casc.bachBaryonDCAxyToPV()}; + + float massCasc[nParticles]{casc.mXi(), casc.mOmega()}; + + // pt cut + if (casc.pt() < CandidateConfigs.MinPt || casc.pt() > CandidateConfigs.MaxPt) { + continue; + } + + cascadev2::hMassBeforeSelVsPt[0]->Fill(massCasc[0], casc.pt()); + cascadev2::hMassBeforeSelVsPt[1]->Fill(massCasc[1], casc.pt()); + + if (isApplyML) { + // Retrieve model output and selection outcome + isSelectedCasc[0] = mlResponseXi.isSelectedMl(inputFeaturesCasc, casc.pt(), bdtScore[0]); + isSelectedCasc[1] = mlResponseOmega.isSelectedMl(inputFeaturesCasc, casc.pt(), bdtScore[1]); + + for (int iS{0}; iS < nParticles; ++iS) { + // Fill BDT score histograms before selection + cascadev2::hSignalScoreBeforeSel[iS]->Fill(bdtScore[0][1]); + cascadev2::hBkgScoreBeforeSel[iS]->Fill(bdtScore[1][0]); + + // Fill histograms for selected candidates + if (isSelectedCasc[iS]) { + cascadev2::hSignalScoreAfterSel[iS]->Fill(bdtScore[0][1]); + cascadev2::hBkgScoreAfterSel[iS]->Fill(bdtScore[1][0]); + cascadev2::hMassAfterSelVsPt[iS]->Fill(massCasc[iS], casc.pt()); + } + } + } else { + isSelectedCasc[0] = true; + isSelectedCasc[1] = true; + } + + ROOT::Math::XYZVector cascQvec{std::cos(2 * casc.phi()), std::sin(2 * casc.phi()), 0}; + auto v2CSP = cascQvec.Dot(eventplaneVecT0C); // not normalised by amplitude + auto cascminuspsiT0C = GetPhiInRange(casc.phi() - PsiT0C); + auto v2CEP = std::cos(2.0 * cascminuspsiT0C); + ROOT::Math::XYZVector cascUvec{std::cos(casc.phi()), std::sin(casc.phi()), 0}; + + // polarization variables + double masses[nParticles]{o2::constants::physics::MassXiMinus, o2::constants::physics::MassOmegaMinus}; + ROOT::Math::PxPyPzMVector cascadeVector[nParticles], lambdaVector, protonVector; + float cosThetaStarLambda[nParticles], cosThetaStarProton; + lambdaVector.SetCoordinates(casc.pxlambda(), casc.pylambda(), casc.pzlambda(), o2::constants::physics::MassLambda); + ROOT::Math::Boost lambdaBoost{lambdaVector.BoostToCM()}; + if (casc.sign() > 0) { + protonVector.SetCoordinates(casc.pxneg(), casc.pyneg(), casc.pzneg(), o2::constants::physics::MassProton); + } else { + protonVector.SetCoordinates(casc.pxpos(), casc.pypos(), casc.pzpos(), o2::constants::physics::MassProton); + } + auto boostedProton{lambdaBoost(protonVector)}; + cosThetaStarProton = boostedProton.Pz() / boostedProton.P(); + for (int i{0}; i < nParticles; ++i) { + cascadeVector[i].SetCoordinates(casc.px(), casc.py(), casc.pz(), masses[i]); + ROOT::Math::Boost cascadeBoost{cascadeVector[i].BoostToCM()}; + auto boostedLambda{cascadeBoost(lambdaVector)}; + cosThetaStarLambda[i] = boostedLambda.Pz() / boostedLambda.P(); + } + + double ptLambda = std::sqrt(std::pow(casc.pxlambda(), 2) + std::pow(casc.pylambda(), 2)); + auto etaLambda = RecoDecay::eta(std::array{casc.pxlambda(), casc.pylambda(), casc.pzlambda()}); + + // acceptance values if requested + double meanCos2ThetaLambdaFromXi = 1; + double meanCos2ThetaLambdaFromOmega = 1; + double meanCos2ThetaProtonFromLambda = 1; + if (applyAcceptanceCorrection) { + if (ptLambda < CandidateConfigs.MinPtLambda || ptLambda > CandidateConfigs.MaxPtLambda) { + continue; + } + if (std::abs(casc.eta()) > CandidateConfigs.etaCasc) + continue; + if (std::abs(etaLambda) > CandidateConfigs.etaLambdaMax) + continue; + int bin2DXi = hAcceptanceXi->FindBin(casc.pt(), casc.eta()); + int bin2DOmega = hAcceptanceOmega->FindBin(casc.pt(), casc.eta()); + int bin2DLambda = hAcceptanceLambda->FindBin(ptLambda, etaLambda); + meanCos2ThetaLambdaFromXi = hAcceptanceXi->GetBinContent(bin2DXi); + meanCos2ThetaLambdaFromOmega = hAcceptanceOmega->GetBinContent(bin2DOmega); + meanCos2ThetaProtonFromLambda = hAcceptanceLambda->GetBinContent(bin2DLambda); + } + + int chargeIndex = 0; + if (casc.sign() > 0) + chargeIndex = 1; + double pzs2Xi = cosThetaStarLambda[0] * std::sin(2 * (casc.phi() - PsiT0C)) / cascadev2::AlphaXi[chargeIndex] / meanCos2ThetaLambdaFromXi; + double pzs2Omega = cosThetaStarLambda[1] * std::sin(2 * (casc.phi() - PsiT0C)) / cascadev2::AlphaOmega[chargeIndex] / meanCos2ThetaLambdaFromOmega; + double cos2ThetaXi = cosThetaStarLambda[0] * cosThetaStarLambda[0]; + double cos2ThetaOmega = cosThetaStarLambda[1] * cosThetaStarLambda[1]; + double pzs2LambdaFromCasc = cosThetaStarProton * std::sin(2 * (casc.phi() - PsiT0C)) / cascadev2::AlphaLambda[chargeIndex] / meanCos2ThetaProtonFromLambda; + double cos2ThetaLambda = cosThetaStarProton * cosThetaStarProton; + + double cosThetaXiWithAlpha = cosThetaStarLambda[0] / cascadev2::AlphaXi[chargeIndex]; + double cosThetaOmegaWithAlpha = cosThetaStarLambda[1] / cascadev2::AlphaOmega[chargeIndex]; + double cosThetaProtonWithAlpha = cosThetaStarProton / cascadev2::AlphaLambda[chargeIndex]; + + histos.fill(HIST("hv2CEPvsFT0C"), coll.centFT0C(), v2CEP); + histos.fill(HIST("hv2CEPvsv2CSP"), v2CSP, v2CEP); + histos.fill(HIST("hCascadePhi"), casc.phi()); + histos.fill(HIST("hcascminuspsiT0C"), cascminuspsiT0C); + + double values[4]{casc.mXi(), casc.pt(), v2CSP, coll.centFT0C()}; + if (isSelectedCasc[0]) { + cascadev2::hSparseV2C[0]->Fill(values); + } + if (isSelectedCasc[1]) { + values[0] = casc.mOmega(); + cascadev2::hSparseV2C[0]->Fill(values); + } + + float BDTresponse[nParticles]{0.f, 0.f}; + if (isApplyML) { + BDTresponse[0] = bdtScore[0][1]; + BDTresponse[1] = bdtScore[1][1]; + } + + if (std::abs(casc.eta()) < CandidateConfigs.etaCasc) { + if (fillingConfigs.isFillTHNXi) { + if (fillingConfigs.isFillTHN_V2) + histos.get(HIST("hXiV2"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], v2CEP); + if (fillingConfigs.isFillTHN_Pz) + histos.get(HIST("hXiPzs2"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], pzs2Xi); + if (casc.mLambda() > CandidateConfigs.MinLambdaMass && casc.mLambda() < CandidateConfigs.MaxLambdaMass) { + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.get(HIST("hXiPzs2FromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], pzs2LambdaFromCasc); + } + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hXiCos2Theta"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mXi(), BDTresponse[0], cos2ThetaXi); + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.get(HIST("hXiCos2ThetaFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mXi(), BDTresponse[0], cos2ThetaLambda); + if (casc.mXi() > CandidateConfigs.MinXiMass && casc.mXi() < CandidateConfigs.MaxXiMass) { + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.get(HIST("hXiCos2ThetaFromLambdaL"))->Fill(coll.centFT0C(), chargeIndex, etaLambda, ptLambda, casc.mLambda(), BDTresponse[0], cos2ThetaLambda); + histos.get(HIST("massXi_ProtonAcc"))->Fill(casc.mXi()); + } + } + if (fillingConfigs.isFillTHNXi_PzVsPsi) { + if (fillingConfigs.isFillTHN_Pz) + histos.get(HIST("hXiPzVsPsi"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], cosThetaXiWithAlpha, 2 * cascminuspsiT0C); + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.get(HIST("hXiPzVsPsiFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mXi(), BDTresponse[0], cosThetaProtonWithAlpha, 2 * cascminuspsiT0C); + if (casc.mLambda() > CandidateConfigs.MinLambdaMass && casc.mLambda() < CandidateConfigs.MaxLambdaMass) { + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hXiCos2ThetaVsPsi"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mXi(), BDTresponse[0], cos2ThetaXi, 2 * cascminuspsiT0C); + } + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.get(HIST("hXiCos2ThetaVsPsiFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mXi(), BDTresponse[0], cos2ThetaLambda, 2 * cascminuspsiT0C); + if (casc.mXi() > CandidateConfigs.MinXiMass && casc.mXi() < CandidateConfigs.MaxXiMass) { + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.get(HIST("hXiCos2ThetaVsPsiFromLambdaL"))->Fill(coll.centFT0C(), chargeIndex, etaLambda, ptLambda, casc.mLambda(), BDTresponse[0], cos2ThetaLambda, 2 * cascminuspsiT0C); + histos.get(HIST("massXi_ProtonAcc"))->Fill(casc.mXi()); + } + } + if (fillingConfigs.isFillTHNOmega) { + if (fillingConfigs.isFillTHN_V2) + histos.get(HIST("hOmegaV2"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], v2CEP); + if (fillingConfigs.isFillTHN_Pz) + histos.get(HIST("hOmegaPzs2"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], pzs2Omega); + if (casc.mLambda() > CandidateConfigs.MinLambdaMass && casc.mLambda() < CandidateConfigs.MaxLambdaMass) { + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.get(HIST("hOmegaPzs2FromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], pzs2LambdaFromCasc); + } + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hOmegaCos2Theta"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mOmega(), BDTresponse[1], cos2ThetaOmega); + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.get(HIST("hOmegaCos2ThetaFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mOmega(), BDTresponse[1], cos2ThetaLambda); + if (casc.mOmega() > CandidateConfigs.MinOmegaMass && casc.mOmega() < CandidateConfigs.MaxOmegaMass) { + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.get(HIST("hOmegaCos2ThetaFromLambdaL"))->Fill(coll.centFT0C(), chargeIndex, etaLambda, ptLambda, casc.mLambda(), BDTresponse[1], cos2ThetaLambda); + histos.get(HIST("massOmega_ProtonAcc"))->Fill(casc.mOmega()); + } + } + if (fillingConfigs.isFillTHNOmega_PzVsPsi) { + if (fillingConfigs.isFillTHN_Pz) + histos.get(HIST("hOmegaPzVsPsi"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], cosThetaOmegaWithAlpha, 2 * cascminuspsiT0C); + if (fillingConfigs.isFillTHN_PzFromLambda) + histos.get(HIST("hOmegaPzVsPsiFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.pt(), casc.mOmega(), BDTresponse[1], cosThetaProtonWithAlpha, 2 * cascminuspsiT0C); + if (casc.mLambda() > CandidateConfigs.MinLambdaMass && casc.mLambda() < CandidateConfigs.MaxLambdaMass) { + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hOmegaCos2ThetaVsPsi"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mOmega(), BDTresponse[1], cos2ThetaOmega, 2 * cascminuspsiT0C); + } + if (fillingConfigs.isFillTHN_AccFromLambdaVsCasc) + histos.get(HIST("hOmegaCos2ThetaVsPsiFromLambda"))->Fill(coll.centFT0C(), chargeIndex, casc.eta(), casc.pt(), casc.mOmega(), BDTresponse[1], cos2ThetaLambda, 2 * cascminuspsiT0C); + if (casc.mOmega() > CandidateConfigs.MinOmegaMass && casc.mOmega() < CandidateConfigs.MaxOmegaMass) { + if (fillingConfigs.isFillTHN_AccFromLambdaVsLambda) + histos.get(HIST("hOmegaCos2ThetaVsPsiFromLambdaL"))->Fill(coll.centFT0C(), chargeIndex, etaLambda, ptLambda, casc.mLambda(), BDTresponse[1], cos2ThetaLambda, 2 * cascminuspsiT0C); + histos.get(HIST("massOmega_ProtonAcc"))->Fill(casc.mOmega()); + } + } + } + + if (isSelectedCasc[0] || isSelectedCasc[1]) { + if (fillingConfigs.isFillTree) + fillAnalysedTable(coll, hasEventPlane, 0, casc, v2CSP, v2CEP, 0, 0, PsiT0C, BDTresponse[0], BDTresponse[1], 0); + } } } - void processAnalyseDataEPCentralFW(CollEventPlaneCentralFW const& coll, CascCandidates const& Cascades, DauTracks const&) + void processAnalyseLambdaEP2CentralFW(CollEventPlaneCentralFW const& coll, V0Candidates const& V0s, DauTracks const&) { if (!AcceptEvent(coll, 1)) { @@ -711,7 +1478,7 @@ struct cascadeFlow { // select only events used for the calibration of the event plane if (isGoodEventEP) { - if (abs(coll.qvecFT0CRe()) > 990 || abs(coll.qvecFT0CIm()) > 990 || abs(coll.qvecBNegRe()) > 990 || abs(coll.qvecBNegIm()) > 990 || abs(coll.qvecBPosRe()) > 990 || abs(coll.qvecBPosIm()) > 990) { + if (std::abs(coll.qvecFT0CRe()) > 990 || std::abs(coll.qvecFT0CIm()) > 990 || std::abs(coll.qvecBNegRe()) > 990 || std::abs(coll.qvecBNegIm()) > 990 || std::abs(coll.qvecBPosRe()) > 990 || std::abs(coll.qvecBPosIm()) > 990) { return; } } @@ -727,9 +1494,187 @@ struct cascadeFlow { ROOT::Math::XYZVector eventplaneVecT0C{coll.qvecFT0CRe(), coll.qvecFT0CIm(), 0}; ROOT::Math::XYZVector eventplaneVecTPCA{coll.qvecBPosRe(), coll.qvecBPosIm(), 0}; ROOT::Math::XYZVector eventplaneVecTPCC{coll.qvecBNegRe(), coll.qvecBNegIm(), 0}; - float NormQvT0C = sqrt(eventplaneVecT0C.Dot(eventplaneVecT0C)); - float NormQvTPCA = sqrt(eventplaneVecTPCA.Dot(eventplaneVecTPCA)); - float NormQvTPCC = sqrt(eventplaneVecTPCC.Dot(eventplaneVecTPCC)); + + const float psiT0C = std::atan2(coll.qvecFT0CIm(), coll.qvecFT0CRe()) * 0.5f; + histos.fill(HIST("hPsiT0C"), psiT0C); + histos.fill(HIST("hPsiT0CvsCentFT0C"), coll.centFT0C(), psiT0C); + + resolution.fill(HIST("QVectorsT0CTPCA"), eventplaneVecT0C.Dot(eventplaneVecTPCA), coll.centFT0C()); + resolution.fill(HIST("QVectorsT0CTPCC"), eventplaneVecT0C.Dot(eventplaneVecTPCC), coll.centFT0C()); + resolution.fill(HIST("QVectorsTPCAC"), eventplaneVecTPCA.Dot(eventplaneVecTPCC), coll.centFT0C()); + resolution.fill(HIST("QVectorsNormT0CTPCA"), eventplaneVecT0C.Dot(eventplaneVecTPCA) / (coll.qTPCR() * coll.sumAmplFT0C()), coll.centFT0C()); + resolution.fill(HIST("QVectorsNormT0CTPCC"), eventplaneVecT0C.Dot(eventplaneVecTPCC) / (coll.qTPCL() * coll.sumAmplFT0C()), coll.centFT0C()); + resolution.fill(HIST("QVectorsNormTPCAC"), eventplaneVecTPCA.Dot(eventplaneVecTPCC) / (coll.qTPCR() * coll.qTPCL()), coll.centFT0C()); + + std::vector bdtScore[nParticles]; + for (auto const& v0 : V0s) { + + /// Add some minimal cuts for single track variables (min number of TPC clusters) + auto negExtra = v0.negTrackExtra_as(); + auto posExtra = v0.posTrackExtra_as(); + + int counterLambda = 0; + int counterALambda = 0; + bool isLambdaCandidate = 0; + bool isALambdaCandidate = 0; + if (isLambdaAccepted(negExtra, posExtra, counterLambda)) + isLambdaCandidate = 1; + if (isAntiLambdaAccepted(negExtra, posExtra, counterALambda)) + isALambdaCandidate = 1; + histos.fill(HIST("hLambdaDauSel"), counterLambda); + histos.fill(HIST("hALambdaDauSel"), counterALambda); + + // pt cut + if (v0.pt() < V0Configs.MinPtV0 || v0.pt() > V0Configs.MaxPtV0) { + continue; + } + + float massV0[nCharges]{v0.mLambda(), v0.mAntiLambda()}; + lambdav2::hMassBeforeSelVsPt[0]->Fill(massV0[0], v0.pt()); + lambdav2::hMassBeforeSelVsPt[1]->Fill(massV0[1], v0.pt()); + + bool isSelectedV0[2]{false, false}; + if (isV0TopoAccepted(v0) && isLambdaCandidate) + isSelectedV0[0] = true; + if (isV0TopoAccepted(v0) && isALambdaCandidate) + isSelectedV0[1] = true; + + int chargeIndex = -1; + if (isSelectedV0[0] && !isSelectedV0[1]) { // Lambdas + histos.fill(HIST("hLambdaCandidate"), 0); + chargeIndex = 0; + } + if (isSelectedV0[1] && !isSelectedV0[0]) { // AntiLambdas + histos.fill(HIST("hLambdaCandidate"), 1); + chargeIndex = 1; + } + if (isSelectedV0[0] && isSelectedV0[1]) { + histos.fill(HIST("hLambdaCandidate"), 2); + if (v0.mLambda() > V0Configs.MinMassLambda && v0.mLambda() < V0Configs.MaxMassLambda && v0.mAntiLambda() > V0Configs.MinMassLambda && v0.mAntiLambda() < V0Configs.MaxMassLambda) { + histos.fill(HIST("hLambdaCandidate"), 3); + continue; // in case of ambiguity between Lambda and AntiLambda, I skip the particle; checked to be zero in range 1.105 - 1.125 + } + if (v0.mLambda() > V0Configs.MinMassLambda && v0.mLambda() < V0Configs.MaxMassLambda) + chargeIndex = 0; + else if (v0.mAntiLambda() > V0Configs.MinMassLambda && v0.mAntiLambda() < V0Configs.MaxMassLambda) + chargeIndex = 1; + else { + chargeIndex = 2; // these are bkg candidates + histos.fill(HIST("hLambdaCandidate"), 4); + } + } + if (!isSelectedV0[0] && !isSelectedV0[1]) + continue; + + ROOT::Math::XYZVector lambdaQvec{std::cos(2 * v0.phi()), std::sin(2 * v0.phi()), 0}; + auto v2CSP = lambdaQvec.Dot(eventplaneVecT0C); // not normalised by amplitude + auto lambdaminuspsiT0C = GetPhiInRange(v0.phi() - psiT0C); + auto v2CEP = std::cos(2.0 * lambdaminuspsiT0C); + ROOT::Math::XYZVector lambdaUvec{std::cos(v0.phi()), std::sin(v0.phi()), 0}; + + // polarization variables + double massLambda = o2::constants::physics::MassLambda; + float cosThetaStarProton[nCharges]; + ROOT::Math::PxPyPzMVector lambdaVector, protonVector[nCharges]; + lambdaVector.SetCoordinates(v0.px(), v0.py(), v0.pz(), massLambda); + ROOT::Math::Boost lambdaBoost{lambdaVector.BoostToCM()}; + for (int i{0}; i < nCharges; ++i) { + if (i == 0) + protonVector[i].SetCoordinates(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassProton); + else + protonVector[i].SetCoordinates(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassProton); + auto boostedProton{lambdaBoost(protonVector[i])}; + cosThetaStarProton[i] = boostedProton.Pz() / boostedProton.P(); + } + + // acceptance values if requested + double meanCos2ThetaProtonFromLambda = 1; + if (applyAcceptanceCorrection) { + int bin2DLambda = hAcceptanceLambda->FindBin(v0.pt(), v0.eta()); + meanCos2ThetaProtonFromLambda = hAcceptancePrimaryLambda->GetBinContent(bin2DLambda); + } + + double pzs2Lambda = 0; + double cos2ThetaLambda = 0; + double cosThetaLambda = 0; + if (chargeIndex == 0) { + pzs2Lambda = cosThetaStarProton[0] * std::sin(2 * (v0.phi() - psiT0C)) / lambdav2::AlphaLambda[0] / meanCos2ThetaProtonFromLambda; + cos2ThetaLambda = cosThetaStarProton[0] * cosThetaStarProton[0]; + cosThetaLambda = cosThetaStarProton[0] / cascadev2::AlphaLambda[0] / meanCos2ThetaProtonFromLambda; + } else if (chargeIndex == 1) { + pzs2Lambda = cosThetaStarProton[1] * std::sin(2 * (v0.phi() - psiT0C)) / lambdav2::AlphaLambda[1] / meanCos2ThetaProtonFromLambda; + cos2ThetaLambda = cosThetaStarProton[1] * cosThetaStarProton[1]; + cosThetaLambda = cosThetaStarProton[1] / cascadev2::AlphaLambda[1] / meanCos2ThetaProtonFromLambda; + } else { // I treat these bkg candidates as Lambdas for the purpose of calculating Pz + pzs2Lambda = cosThetaStarProton[0] * std::sin(2 * (v0.phi() - psiT0C)) / lambdav2::AlphaLambda[0] / meanCos2ThetaProtonFromLambda; + cos2ThetaLambda = cosThetaStarProton[0] * cosThetaStarProton[0]; + cosThetaLambda = cosThetaStarProton[0] / cascadev2::AlphaLambda[0] / meanCos2ThetaProtonFromLambda; + } + + histos.fill(HIST("hv2CEPvsFT0C"), coll.centFT0C(), v2CEP); + histos.fill(HIST("hv2CEPvsv2CSP"), v2CSP, v2CEP); + histos.fill(HIST("hLambdaPhi"), v0.phi()); + histos.fill(HIST("hlambdaminuspsiT0C"), lambdaminuspsiT0C); + + if (fillingConfigs.isFillTHNLambda) { + if (fillingConfigs.isFillTHN_V2) + histos.get(HIST("hLambdaV2"))->Fill(coll.centFT0C(), chargeIndex, v0.pt(), v0.mLambda(), v2CEP); + if (fillingConfigs.isFillTHN_Pz) { + histos.get(HIST("hLambdaPzs2"))->Fill(coll.centFT0C(), chargeIndex, v0.pt(), v0.mLambda(), pzs2Lambda); + } + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hLambdaCos2Theta"))->Fill(coll.centFT0C(), chargeIndex, v0.eta(), v0.pt(), v0.mLambda(), cos2ThetaLambda); + } + if (fillingConfigs.isFillTHNLambda_PzVsPsi) { + if (fillingConfigs.isFillTHN_Pz) + histos.get(HIST("hLambdaPzVsPsi"))->Fill(coll.centFT0C(), chargeIndex, v0.pt(), v0.mLambda(), cosThetaLambda, 2 * lambdaminuspsiT0C); + if (fillingConfigs.isFillTHN_Acc) + histos.get(HIST("hLambdaCos2ThetaVsPsi"))->Fill(coll.centFT0C(), chargeIndex, v0.eta(), v0.pt(), v0.mLambda(), cos2ThetaLambda, 2 * lambdaminuspsiT0C); + } + } + } + + void processAnalyseDataEPCentralFW(CollEventAndSpecPlaneCentralFW const& coll, CascCandidates const& Cascades, DauTracks const&) + { + + if (!AcceptEvent(coll, 1)) { + return; + } + + // select only events used for the calibration of the event plane + if (isGoodEventEP) { + if (std::abs(coll.qvecFT0CRe()) > 990 || std::abs(coll.qvecFT0CIm()) > 990 || std::abs(coll.qvecBNegRe()) > 990 || std::abs(coll.qvecBNegIm()) > 990 || std::abs(coll.qvecBPosRe()) > 990 || std::abs(coll.qvecBPosIm()) > 990) { + return; + } + } + + // event has FT0C event plane + bool hasEventPlane = 0; + if (std::abs(coll.qvecFT0CRe()) < 990 && std::abs(coll.qvecFT0CIm()) < 990) + hasEventPlane = 1; + + // event has spectator plane + bool hasSpectatorPlane = 0; + if (coll.triggereventsp()) + hasSpectatorPlane = 1; + + histos.fill(HIST("hNEvents"), 9.5); + histos.fill(HIST("hEventNchCorrelationAfterEP"), coll.multNTracksPVeta1(), coll.multNTracksGlobal()); + histos.fill(HIST("hEventPVcontributorsVsCentralityAfterEP"), coll.centFT0C(), coll.multNTracksPVeta1()); + histos.fill(HIST("hEventGlobalTracksVsCentralityAfterEP"), coll.centFT0C(), coll.multNTracksGlobal()); + + histos.fill(HIST("hEventCentrality"), coll.centFT0C()); + histos.fill(HIST("hEventVertexZ"), coll.posZ()); + + ROOT::Math::XYZVector eventplaneVecT0C{coll.qvecFT0CRe(), coll.qvecFT0CIm(), 0}; + ROOT::Math::XYZVector eventplaneVecTPCA{coll.qvecBPosRe(), coll.qvecBPosIm(), 0}; + ROOT::Math::XYZVector eventplaneVecTPCC{coll.qvecBNegRe(), coll.qvecBNegIm(), 0}; + ROOT::Math::XYZVector spectatorplaneVecZDCA{std::cos(coll.psiZDCA()), std::sin(coll.psiZDCA()), 0}; // eta positive = projectile + ROOT::Math::XYZVector spectatorplaneVecZDCC{std::cos(coll.psiZDCC()), std::sin(coll.psiZDCC()), 0}; // eta negative = target + + float NormQvT0C = std::sqrt(eventplaneVecT0C.Dot(eventplaneVecT0C)); + float NormQvTPCA = std::sqrt(eventplaneVecTPCA.Dot(eventplaneVecTPCA)); + float NormQvTPCC = std::sqrt(eventplaneVecTPCC.Dot(eventplaneVecTPCC)); const float PsiT0C = std::atan2(coll.qvecFT0CIm(), coll.qvecFT0CRe()) * 0.5f; histos.fill(HIST("hPsiT0C"), PsiT0C); @@ -741,9 +1686,10 @@ struct cascadeFlow { resolution.fill(HIST("QVectorsNormT0CTPCA"), eventplaneVecT0C.Dot(eventplaneVecTPCA) / (NormQvT0C * NormQvTPCA), coll.centFT0C()); resolution.fill(HIST("QVectorsNormT0CTPCC"), eventplaneVecT0C.Dot(eventplaneVecTPCC) / (NormQvT0C * NormQvTPCC), coll.centFT0C()); resolution.fill(HIST("QVectorsNormTPCAC"), eventplaneVecTPCA.Dot(eventplaneVecTPCC) / (NormQvTPCA * NormQvTPCC), coll.centFT0C()); + resolution.fill(HIST("QVectorsSpecPlane"), spectatorplaneVecZDCC.Dot(spectatorplaneVecZDCA), coll.centFT0C()); - std::vector bdtScore[2]; - for (auto& casc : Cascades) { + std::vector bdtScore[nParticles]; + for (auto const& casc : Cascades) { /// Add some minimal cuts for single track variables (min number of TPC clusters) auto negExtra = casc.negTrackExtra_as(); @@ -751,11 +1697,15 @@ struct cascadeFlow { auto bachExtra = casc.bachTrackExtra_as(); int counter = 0; - IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); + bool isCascCandidate = 0; + isCascCandidate = IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); histos.fill(HIST("hCascade"), counter); + histos.fill(HIST("hCascadeDauSel"), (int)isCascCandidate); + if (!isCascCandidate) + continue; // ML selections - bool isSelectedCasc[2]{false, false}; + bool isSelectedCasc[nParticles]{false, false}; std::vector inputFeaturesCasc{casc.cascradius(), casc.v0radius(), @@ -770,10 +1720,10 @@ struct cascadeFlow { casc.bachBaryonCosPA(), casc.bachBaryonDCAxyToPV()}; - float massCasc[2]{casc.mXi(), casc.mOmega()}; + float massCasc[nParticles]{casc.mXi(), casc.mOmega()}; // inv mass loose cut - if (casc.pt() < MinPt || casc.pt() > MaxPt) { + if (casc.pt() < CandidateConfigs.MinPt || casc.pt() > CandidateConfigs.MaxPt) { continue; } @@ -785,7 +1735,7 @@ struct cascadeFlow { isSelectedCasc[0] = mlResponseXi.isSelectedMl(inputFeaturesCasc, casc.pt(), bdtScore[0]); isSelectedCasc[1] = mlResponseOmega.isSelectedMl(inputFeaturesCasc, casc.pt(), bdtScore[1]); - for (int iS{0}; iS < 2; ++iS) { + for (int iS{0}; iS < nParticles; ++iS) { // Fill BDT score histograms before selection cascadev2::hSignalScoreBeforeSel[iS]->Fill(bdtScore[0][1]); cascadev2::hBkgScoreBeforeSel[iS]->Fill(bdtScore[1][0]); @@ -805,10 +1755,19 @@ struct cascadeFlow { ROOT::Math::XYZVector cascQvec{std::cos(2 * casc.phi()), std::sin(2 * casc.phi()), 0}; auto v2CSP = cascQvec.Dot(eventplaneVecT0C); auto cascminuspsiT0C = GetPhiInRange(casc.phi() - PsiT0C); - auto v2CEP = TMath::Cos(2.0 * cascminuspsiT0C); + auto v2CEP = std::cos(2.0 * cascminuspsiT0C); + ROOT::Math::XYZVector cascUvec{std::cos(casc.phi()), std::sin(casc.phi()), 0}; + auto v1SP_ZDCA = cascUvec.Dot(spectatorplaneVecZDCA); + auto v1SP_ZDCC = cascUvec.Dot(spectatorplaneVecZDCC); + auto v1EP_ZDCA = std::cos(casc.phi() - coll.psiZDCA()); + auto v1EP_ZDCC = std::cos(casc.phi() - coll.psiZDCC()); + float v1SP = 0.5 * (v1SP_ZDCA - v1SP_ZDCC); + float v1EP = 0.5 * (v1EP_ZDCA - v1EP_ZDCC); // same as v1SP histos.fill(HIST("hv2CEPvsFT0C"), coll.centFT0C(), v2CEP); histos.fill(HIST("hv2CEPvsv2CSP"), v2CSP, v2CEP); + histos.fill(HIST("hv1EPvsv1SP"), v1SP, v1EP); + histos.fill(HIST("hv1SP_ZDCA_vs_ZDCC"), v1SP_ZDCC, v1SP_ZDCA); histos.fill(HIST("hCascadePhi"), casc.phi()); histos.fill(HIST("hcascminuspsiT0C"), cascminuspsiT0C); double values[4]{casc.mXi(), casc.pt(), v2CSP, coll.centFT0C()}; @@ -820,13 +1779,14 @@ struct cascadeFlow { cascadev2::hSparseV2C[0]->Fill(values); } - float BDTresponse[2]{0.f, 0.f}; + float BDTresponse[nParticles]{0.f, 0.f}; if (isApplyML) { BDTresponse[0] = bdtScore[0][1]; BDTresponse[1] = bdtScore[1][1]; } if (isSelectedCasc[0] || isSelectedCasc[1]) - fillAnalysedTable(coll, casc, v2CSP, v2CEP, PsiT0C, BDTresponse[0], BDTresponse[1], 0); + if (fillingConfigs.isFillTree) + fillAnalysedTable(coll, hasEventPlane, hasSpectatorPlane, casc, v2CSP, v2CEP, v1SP_ZDCA, v1SP_ZDCC, PsiT0C, BDTresponse[0], BDTresponse[1], 0); } } @@ -837,6 +1797,9 @@ struct cascadeFlow { return; } + bool hasEventPlane = 0; // no info at the moment + bool hasSpectatorPlane = 0; // no info at the moment + histos.fill(HIST("hNEvents"), 9.5); histos.fill(HIST("hEventNchCorrelationAfterEP"), coll.multNTracksPVeta1(), coll.multNTracksGlobal()); histos.fill(HIST("hEventPVcontributorsVsCentralityAfterEP"), coll.centFT0C(), coll.multNTracksPVeta1()); @@ -845,8 +1808,8 @@ struct cascadeFlow { histos.fill(HIST("hEventVertexZ"), coll.posZ()); histos.fill(HIST("hMultNTracksITSTPCVsCentrality"), coll.centFT0C(), coll.multNTracksITSTPC()); - std::vector bdtScore[2]; - for (auto& casc : Cascades) { + std::vector bdtScore[nParticles]; + for (auto const& casc : Cascades) { if (!casc.has_cascMCCore()) continue; @@ -854,8 +1817,8 @@ struct cascadeFlow { auto cascMC = casc.cascMCCore_as>(); int pdgCode{cascMC.pdgCode()}; - if (!(std::abs(pdgCode) == 3312 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 211) // Xi - && !(std::abs(pdgCode) == 3334 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 321)) // Omega + if (!(std::abs(pdgCode) == PDG_t::kXiMinus && std::abs(cascMC.pdgCodeV0()) == PDG_t::kLambda0 && std::abs(cascMC.pdgCodeBachelor()) == PDG_t::kPiPlus) // Xi + && !(std::abs(pdgCode) == PDG_t::kOmegaMinus && std::abs(cascMC.pdgCodeV0()) == PDG_t::kLambda0 && std::abs(cascMC.pdgCodeBachelor()) == PDG_t::kKPlus)) // Omega { pdgCode = 0; } @@ -864,13 +1827,13 @@ struct cascadeFlow { float XiY = RecoDecay::y(std::array{casc.px(), casc.py(), casc.pz()}, constants::physics::MassXiMinus); float OmegaY = RecoDecay::y(std::array{casc.px(), casc.py(), casc.pz()}, constants::physics::MassOmegaMinus); // true reco cascades before applying any selection - if (std::abs(pdgCode) == 3312 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 211) { + if (std::abs(pdgCode) == PDG_t::kXiMinus && std::abs(cascMC.pdgCodeV0()) == PDG_t::kLambda0 && std::abs(cascMC.pdgCodeBachelor()) == PDG_t::kPiPlus) { histos.fill(HIST("hXiPtvsCent"), coll.centFT0C(), casc.pt()); if (std::abs(casc.eta()) < 0.8) histos.fill(HIST("hXiPtvsCentEta08"), coll.centFT0C(), casc.pt()); if (std::abs(XiY) < 0.5) histos.fill(HIST("hXiPtvsCentY05"), coll.centFT0C(), casc.pt()); - } else if (std::abs(pdgCode) == 3334 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 321) { + } else if (std::abs(pdgCode) == PDG_t::kOmegaMinus && std::abs(cascMC.pdgCodeV0()) == PDG_t::kLambda0 && std::abs(cascMC.pdgCodeBachelor()) == PDG_t::kKPlus) { histos.fill(HIST("hOmegaPtvsCent"), coll.centFT0C(), casc.pt()); if (std::abs(casc.eta()) < 0.8) histos.fill(HIST("hOmegaPtvsCentEta08"), coll.centFT0C(), casc.pt()); @@ -884,11 +1847,15 @@ struct cascadeFlow { auto bachExtra = casc.bachTrackExtra_as(); int counter = 0; - IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); + bool isCascCandidate = 0; + isCascCandidate = IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); histos.fill(HIST("hCascade"), counter); + histos.fill(HIST("hCascadeDauSel"), (int)isCascCandidate); + if (!isCascCandidate) + continue; // ML selections - bool isSelectedCasc[2]{false, false}; + bool isSelectedCasc[nParticles]{false, false}; std::vector inputFeaturesCasc{casc.cascradius(), casc.v0radius(), @@ -903,9 +1870,9 @@ struct cascadeFlow { casc.bachBaryonCosPA(), casc.bachBaryonDCAxyToPV()}; - float massCasc[2]{casc.mXi(), casc.mOmega()}; + float massCasc[nParticles]{casc.mXi(), casc.mOmega()}; - if (casc.pt() < MinPt || casc.pt() > MaxPt) { + if (casc.pt() < CandidateConfigs.MinPt || casc.pt() > CandidateConfigs.MaxPt) { continue; } @@ -917,7 +1884,7 @@ struct cascadeFlow { isSelectedCasc[0] = mlResponseXi.isSelectedMl(inputFeaturesCasc, casc.pt(), bdtScore[0]); isSelectedCasc[1] = mlResponseOmega.isSelectedMl(inputFeaturesCasc, casc.pt(), bdtScore[1]); - for (int iS{0}; iS < 2; ++iS) { + for (int iS{0}; iS < nParticles; ++iS) { // Fill BDT score histograms before selection cascadev2::hSignalScoreBeforeSel[iS]->Fill(bdtScore[0][1]); cascadev2::hBkgScoreBeforeSel[iS]->Fill(bdtScore[1][0]); @@ -936,10 +1903,12 @@ struct cascadeFlow { histos.fill(HIST("hCascadePhi"), casc.phi()); - float BDTresponse[2]{0.f, 0.f}; + float BDTresponse[nParticles]{0.f, 0.f}; const float PsiT0C = 0; // not defined in MC for now auto v2CSP = 0; // not defined in MC for now auto v2CEP = 0; // not defined in MC for now + auto v1SP_ZDCA = 0; // not defined in MC for now + auto v1SP_ZDCC = 0; // not defined in MC for now if (isApplyML) { BDTresponse[0] = bdtScore[0][1]; @@ -950,7 +1919,7 @@ struct cascadeFlow { continue; } if (isSelectedCasc[0] || isSelectedCasc[1]) - fillAnalysedTable(coll, casc, v2CSP, v2CEP, PsiT0C, BDTresponse[0], BDTresponse[1], pdgCode); + fillAnalysedTable(coll, hasEventPlane, hasSpectatorPlane, casc, v2CSP, v2CEP, v1SP_ZDCA, v1SP_ZDCC, PsiT0C, BDTresponse[0], BDTresponse[1], pdgCode); } } @@ -960,7 +1929,7 @@ struct cascadeFlow { histosMCGen.fill(HIST("hZvertexGen"), mcCollision.posZ()); histosMCGen.fill(HIST("hNEventsMC"), 0.5); // Generated with accepted z vertex - if (TMath::Abs(mcCollision.posZ()) > cutzvertex) { + if (std::abs(mcCollision.posZ()) > cutzvertex) { return; } histosMCGen.fill(HIST("hNEventsMC"), 1.5); @@ -993,21 +1962,21 @@ struct cascadeFlow { histosMCGen.fill(HIST("hNEventsMC"), 5.5); for (auto const& cascmc : cascMC) { - if (TMath::Abs(cascmc.pdgCode()) == 3312) + if (std::abs(cascmc.pdgCode()) == PDG_t::kXiMinus) histosMCGen.fill(HIST("hNCascGen"), 0.5); - else if (TMath::Abs(cascmc.pdgCode()) == 3334) + else if (std::abs(cascmc.pdgCode()) == PDG_t::kOmegaMinus) histosMCGen.fill(HIST("hNCascGen"), 1.5); if (!cascmc.has_straMCCollision()) continue; - if (TMath::Abs(cascmc.pdgCode()) == 3312) + if (std::abs(cascmc.pdgCode()) == PDG_t::kXiMinus) histosMCGen.fill(HIST("hNCascGen"), 2.5); - else if (TMath::Abs(cascmc.pdgCode()) == 3334) + else if (std::abs(cascmc.pdgCode()) == PDG_t::kOmegaMinus) histosMCGen.fill(HIST("hNCascGen"), 3.5); if (!cascmc.isPhysicalPrimary()) continue; - if (TMath::Abs(cascmc.pdgCode()) == 3312) + if (std::abs(cascmc.pdgCode()) == PDG_t::kXiMinus) histosMCGen.fill(HIST("hNCascGen"), 4.5); - else if (TMath::Abs(cascmc.pdgCode()) == 3334) + else if (std::abs(cascmc.pdgCode()) == PDG_t::kOmegaMinus) histosMCGen.fill(HIST("hNCascGen"), 5.5); float ptmc = RecoDecay::sqrtSumOfSquares(cascmc.pxMC(), cascmc.pyMC()); @@ -1021,27 +1990,26 @@ struct cascadeFlow { theta1 = theta; // 0 < theta1/2 < pi/4 --> 0 < tan (theta1/2) < 1 --> positive eta // if pz is negative (i.e. negative rapidity): -pi/2 < theta < 0 --> we need 0 < theta1/2 < pi/2 for the ln to be defined else - theta1 = TMath::Pi() + theta; // pi/2 < theta1 < pi --> pi/4 < theta1/2 < pi/2 --> 1 < tan (theta1/2) --> negative eta + theta1 = o2::constants::math::PI + theta; // pi/2 < theta1 < pi --> pi/4 < theta1/2 < pi/2 --> 1 < tan (theta1/2) --> negative eta - float cascMCeta = -log(std::tan(theta1 / 2)); + float cascMCeta = -std::log(std::tan(theta1 / 2)); float cascMCy = 0; - - if (TMath::Abs(cascmc.pdgCode()) == 3312) { + if (std::abs(cascmc.pdgCode()) == PDG_t::kXiMinus) { cascMCy = RecoDecay::y(std::array{cascmc.pxMC(), cascmc.pyMC(), cascmc.pzMC()}, constants::physics::MassXiMinus); - if (TMath::Abs(cascMCeta) < etaCascMCGen) { + if (std::abs(cascMCeta) < etaCascMCGen) { histosMCGen.fill(HIST("h2DGenXiEta08"), centrality, ptmc); histosMCGen.fill(HIST("hNCascGen"), 6.5); } - if (TMath::Abs(cascMCy) < yCascMCGen) + if (std::abs(cascMCy) < yCascMCGen) histosMCGen.fill(HIST("h2DGenXiY05"), centrality, ptmc); histosMCGen.fill(HIST("hGenXiY"), cascMCy); - } else if (TMath::Abs(cascmc.pdgCode() == 3334)) { + } else if (std::abs(cascmc.pdgCode()) == PDG_t::kOmegaMinus) { cascMCy = RecoDecay::y(std::array{cascmc.pxMC(), cascmc.pyMC(), cascmc.pzMC()}, constants::physics::MassOmegaMinus); - if (TMath::Abs(cascMCeta) < etaCascMCGen) { + if (std::abs(cascMCeta) < etaCascMCGen) { histosMCGen.fill(HIST("h2DGenOmegaEta08"), centrality, ptmc); histosMCGen.fill(HIST("hNCascGen"), 7.5); } - if (TMath::Abs(cascMCy) < yCascMCGen) + if (std::abs(cascMCy) < yCascMCGen) histosMCGen.fill(HIST("h2DGenOmegaY05"), centrality, ptmc); histosMCGen.fill(HIST("hGenOmegaY"), cascMCy); } @@ -1051,7 +2019,9 @@ struct cascadeFlow { PROCESS_SWITCH(cascadeFlow, processTrainingBackground, "Process to create the training dataset for the background", true); PROCESS_SWITCH(cascadeFlow, processTrainingSignal, "Process to create the training dataset for the signal", false); PROCESS_SWITCH(cascadeFlow, processAnalyseData, "Process to apply ML model to the data", false); + PROCESS_SWITCH(cascadeFlow, processAnalyseDataEP2CentralFW, "Process to apply ML model to the data - second order event plane calibration from central framework", false); PROCESS_SWITCH(cascadeFlow, processAnalyseDataEPCentralFW, "Process to apply ML model to the data - event plane calibration from central framework", false); + PROCESS_SWITCH(cascadeFlow, processAnalyseLambdaEP2CentralFW, "Process to measure flow and polarization of Lambda - event plane calibration from central framework", false); PROCESS_SWITCH(cascadeFlow, processAnalyseMC, "Process to apply ML model to the MC", false); PROCESS_SWITCH(cascadeFlow, processMCGen, "Process to store MC generated particles", false); }; diff --git a/PWGLF/TableProducer/Strangeness/cascademlselection.cxx b/PWGLF/TableProducer/Strangeness/cascademlselection.cxx new file mode 100644 index 00000000000..6da4bc669e4 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/cascademlselection.cxx @@ -0,0 +1,298 @@ +// 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. +// +// *+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* +// Lambdakzero ML selection task +// *+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* +// +// Comments, questions, complaints, suggestions? +// Please write to: +// gianni.shigeru.setoue.liveraro@cern.ch +// romain.schotter@cern.ch +// david.dobrigkeit.chinellato@cern.ch +// + +#include +#include +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/ASoA.h" +#include "ReconstructionDataFormats/Track.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessMLTables.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" +#include "CCDB/BasicCCDBManager.h" +#include +#include +#include +#include +#include +#include +#include "Tools/ML/MlResponse.h" +#include "Tools/ML/model.h" + +using namespace o2; +using namespace o2::analysis; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::ml; +using std::array; +using std::cout; +using std::endl; + +// For original data loops +using CascOriginalDatas = soa::Join; + +// For derived data analysis +using CascDerivedDatas = soa::Join; + +struct cascademlselection { + o2::ml::OnnxModel mlModelXiMinus; + o2::ml::OnnxModel mlModelXiPlus; + o2::ml::OnnxModel mlModelOmegaMinus; + o2::ml::OnnxModel mlModelOmegaPlus; + + std::map metadata; + + Produces xiMLSelections; // optionally aggregate information from ML output for posterior analysis (derived data) + Produces omegaMLSelections; // optionally aggregate information from ML output for posterior analysis (derived data) + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // CCDB configuration + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber; + + // CCDB options + struct : ConfigurableGroup { + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + } ccdbConfigurations; + + // Machine learning evaluation for pre-selection and corresponding information generation + struct : ConfigurableGroup { + // ML classifiers: master flags to populate ML Selection tables + Configurable calculateXiMinusScores{"mlConfigurations.calculateXiMinusScores", true, "calculate XiMinus ML scores"}; + Configurable calculateXiPlusScores{"mlConfigurations.calculateXiPlusScores", true, "calculate XiPlus ML scores"}; + Configurable calculateOmegaMinusScores{"mlConfigurations.calculateOmegaMinusScores", true, "calculate OmegaMinus ML scores"}; + Configurable calculateOmegaPlusScores{"mlConfigurations.calculateOmegaPlusScores", true, "calculate OmegaPlus ML scores"}; + + // ML input for ML calculation + Configurable modelPathCCDB{"mlConfigurations.modelPathCCDB", "", "ML Model path in CCDB"}; + Configurable timestampCCDB{"mlConfigurations.timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB. Exceptions: > 0 for the specific timestamp, 0 gets the run dependent timestamp"}; + Configurable loadModelsFromCCDB{"mlConfigurations.loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + Configurable enableOptimizations{"mlConfigurations.enableOptimizations", false, "Enables the ONNX extended model-optimization: sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED)"}; + + // Local paths for test purposes + Configurable localModelPathXiMinus{"mlConfigurations.localModelPathXiMinus", "XiMinus_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; + Configurable localModelPathXiPlus{"mlConfigurations.localModelPathXiPlus", "XiPlus_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; + Configurable localModelPathOmegaMinus{"mlConfigurations.localModelPathOmegaMinus", "OmegaMinus_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; + Configurable localModelPathOmegaPlus{"mlConfigurations.localModelPathOmegaPlus", "OmegaPlus_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; + + // Thresholds for choosing to populate V0Cores tables with pre-selections + Configurable thresholdXiMinus{"mlConfigurations.thresholdXiMinus", -1.0f, "Threshold to keep XiMinus candidates"}; + Configurable thresholdXiPlus{"mlConfigurations.thresholdXiPlus", -1.0f, "Threshold to keep XiPlus candidates"}; + Configurable thresholdOmegaMinus{"mlConfigurations.thresholdOmegaMinus", -1.0f, "Threshold to keep OmegaMinus candidates"}; + Configurable thresholdOmegaPlus{"mlConfigurations.thresholdOmegaPlus", -1.0f, "Threshold to keep OmegaPlus candidates"}; + } mlConfigurations; + + // Axis + // base properties + ConfigurableAxis vertexZ{"vertexZ", {30, -15.0f, 15.0f}, ""}; + + int nCandidates = 0; + + template + void initCCDB(TCollision const& collision) + { + int64_t timeStampML = 0; + if constexpr (requires { collision.timestamp(); }) { // we are in derived data + if (mRunNumber == collision.runNumber()) { + return; + } + mRunNumber = collision.runNumber(); + timeStampML = collision.timestamp(); + } + if constexpr (requires { collision.template bc_as(); }) { // we are in original data + auto bc = collision.template bc_as(); + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + timeStampML = bc.timestamp(); + } + + // machine learning initialization if requested + if (mlConfigurations.calculateXiMinusScores || + mlConfigurations.calculateXiPlusScores || + mlConfigurations.calculateOmegaMinusScores || + mlConfigurations.calculateOmegaPlusScores) { + if (mlConfigurations.timestampCCDB.value != -1) + timeStampML = mlConfigurations.timestampCCDB.value; + LoadMachines(timeStampML); + } + } + + // function to load models for ML-based classifiers + void LoadMachines(int64_t timeStampML) + { + if (mlConfigurations.loadModelsFromCCDB) { + ccdbApi.init(ccdbConfigurations.ccdburl); + LOG(info) << "Fetching cascade models for timestamp: " << timeStampML; + + if (mlConfigurations.calculateXiMinusScores) { + bool retrieveSuccess = ccdbApi.retrieveBlob(mlConfigurations.modelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathXiMinus.value); + if (retrieveSuccess) { + mlModelXiMinus.initModel(mlConfigurations.localModelPathXiMinus.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the XiMinus model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + + if (mlConfigurations.calculateXiPlusScores) { + bool retrieveSuccess = ccdbApi.retrieveBlob(mlConfigurations.modelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathXiPlus.value); + if (retrieveSuccess) { + mlModelXiPlus.initModel(mlConfigurations.localModelPathXiPlus.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the XiPlus model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + + if (mlConfigurations.calculateOmegaMinusScores) { + bool retrieveSuccess = ccdbApi.retrieveBlob(mlConfigurations.modelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathOmegaMinus.value); + if (retrieveSuccess) { + mlModelOmegaMinus.initModel(mlConfigurations.localModelPathOmegaMinus.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the OmegaMinus model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + + if (mlConfigurations.calculateOmegaPlusScores) { + bool retrieveSuccess = ccdbApi.retrieveBlob(mlConfigurations.modelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathOmegaPlus.value); + if (retrieveSuccess) { + mlModelOmegaPlus.initModel(mlConfigurations.localModelPathOmegaPlus.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the OmegaPlus model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + } else { + if (mlConfigurations.calculateXiMinusScores) + mlModelXiMinus.initModel(mlConfigurations.localModelPathXiMinus.value, mlConfigurations.enableOptimizations.value); + if (mlConfigurations.calculateXiPlusScores) + mlModelXiPlus.initModel(mlConfigurations.localModelPathXiPlus.value, mlConfigurations.enableOptimizations.value); + if (mlConfigurations.calculateOmegaMinusScores) + mlModelOmegaMinus.initModel(mlConfigurations.localModelPathOmegaMinus.value, mlConfigurations.enableOptimizations.value); + if (mlConfigurations.calculateOmegaPlusScores) + mlModelOmegaPlus.initModel(mlConfigurations.localModelPathOmegaPlus.value, mlConfigurations.enableOptimizations.value); + } + LOG(info) << "Cascade ML Models loaded."; + } + + void init(InitContext const&) + { + // Histograms + histos.add("hEventVertexZ", "hEventVertexZ", kTH1F, {vertexZ}); + + ccdb->setURL(ccdbConfigurations.ccdburl); + } + + // Process candidate and store properties in object + template + void processCandidate(TCascObject const& cand) + { + // Select features + // FIXME THIS NEEDS ADJUSTING + std::vector inputFeatures{0.0f, 0.0f, + 0.0f, 0.0f}; + + // calculate scores + if (cand.sign() < 0) { + if (mlConfigurations.calculateXiMinusScores) { + float* xiMinusProbability = mlModelXiMinus.evalModel(inputFeatures); + xiMLSelections(xiMinusProbability[1]); + } else { + xiMLSelections(-1); + } + if (mlConfigurations.calculateOmegaMinusScores) { + float* omegaMinusProbability = mlModelOmegaMinus.evalModel(inputFeatures); + omegaMLSelections(omegaMinusProbability[1]); + } else { + omegaMLSelections(-1); + } + } + if (cand.sign() > 0) { + if (mlConfigurations.calculateXiPlusScores) { + float* xiPlusProbability = mlModelXiPlus.evalModel(inputFeatures); + xiMLSelections(xiPlusProbability[1]); + } else { + xiMLSelections(-1); + } + if (mlConfigurations.calculateOmegaPlusScores) { + float* omegaPlusProbability = mlModelOmegaPlus.evalModel(inputFeatures); + omegaMLSelections(omegaPlusProbability[1]); + } else { + omegaMLSelections(-1); + } + } + } + + void processDerivedData(soa::Join::iterator const& collision, CascDerivedDatas const& cascades) + { + initCCDB(collision); + + histos.fill(HIST("hEventVertexZ"), collision.posZ()); + for (auto& casc : cascades) { + nCandidates++; + if (nCandidates % 50000 == 0) { + LOG(info) << "Candidates processed: " << nCandidates; + } + processCandidate(casc); + } + } + void processStandardData(aod::Collision const& collision, CascOriginalDatas const& cascades) + { + initCCDB(collision); + + histos.fill(HIST("hEventVertexZ"), collision.posZ()); + for (auto& casc : cascades) { + nCandidates++; + if (nCandidates % 50000 == 0) { + LOG(info) << "Candidates processed: " << nCandidates; + } + processCandidate(casc); + } + } + + PROCESS_SWITCH(cascademlselection, processStandardData, "Process standard data", false); + PROCESS_SWITCH(cascademlselection, processDerivedData, "Process derived data", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/cascadespawner.cxx b/PWGLF/TableProducer/Strangeness/cascadespawner.cxx index dc004b91e78..ab3f4cb7c3d 100644 --- a/PWGLF/TableProducer/Strangeness/cascadespawner.cxx +++ b/PWGLF/TableProducer/Strangeness/cascadespawner.cxx @@ -35,7 +35,7 @@ using namespace o2::framework::expressions; /// Extends the cascdata table with expression columns struct cascadespawner { - Spawns cascdataext; + // Spawns cascdataext; void init(InitContext const&) {} }; diff --git a/PWGLF/TableProducer/Strangeness/cascqaanalysis.cxx b/PWGLF/TableProducer/Strangeness/cascqaanalysis.cxx index 0e14c0f491f..6a3310d316f 100644 --- a/PWGLF/TableProducer/Strangeness/cascqaanalysis.cxx +++ b/PWGLF/TableProducer/Strangeness/cascqaanalysis.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -8,16 +8,14 @@ // 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. -/// -/// \brief QA task for Cascade analysis using derived data -/// -/// \author Chiara De Martin (chiara.de.martin@cern.ch) -/// \author Francesca Ercolessi (francesca.ercolessi@cern.ch) -/// \modified by Roman Nepeivoda (roman.nepeivoda@cern.ch) -/// \since June 1, 2023 +// +/// \file cascqaanalysis.cxx +/// \brief Analysis of cascades in pp collisions +/// \author Roman Nepeivoda (roman.nepeivoda@cern.ch) #include #include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -42,7 +40,7 @@ using TrkPidInfo = soa::Join; using LabeledCascades = soa::Join; -struct cascqaanalysis { +struct Cascqaanalysis { // Tables to produce Produces mycascades; @@ -50,6 +48,25 @@ struct cascqaanalysis { HistogramRegistry registry{"registry"}; + // Axes + ConfigurableAxis ptAxis{"ptAxis", {200, 0.0f, 10.0f}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis rapidityAxis{"rapidityAxis", {200, -2.0f, 2.0f}, "y"}; + ConfigurableAxis centFT0MAxis{"centFT0MAxis", + {VARIABLE_WIDTH, 0., 0.01, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 105.5}, + "FT0M (%)"}; + ConfigurableAxis centFV0AAxis{"centFV0AAxis", + {VARIABLE_WIDTH, 0., 0.01, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 105.5}, + "FV0A (%)"}; + ConfigurableAxis eventTypeAxis{"eventTypeAxis", {3, -0.5f, 2.5f}, "Event Type"}; + + ConfigurableAxis nAssocCollAxis{"nAssocCollAxis", {5, -0.5f, 4.5f}, "N_{assoc.}"}; + ConfigurableAxis nChargedFT0MGenAxis{"nChargedFT0MGenAxis", {300, 0, 300}, "N_{FT0M, gen.}"}; + ConfigurableAxis nChargedFV0AGenAxis{"nChargedFV0AGenAxis", {300, 0, 300}, "N_{FV0A, gen.}"}; + ConfigurableAxis multNTracksAxis{"multNTracksAxis", {500, 0, 500}, "N_{tracks}"}; + ConfigurableAxis signalFT0MAxis{"signalFT0MAxis", {10000, 0, 40000}, "FT0M amplitude"}; + ConfigurableAxis signalFV0AAxis{"signalFV0AAxis", {10000, 0, 40000}, "FV0A amplitude"}; + ConfigurableAxis nCandidates{"nCandidates", {30, -0.5, 29.5}, "N_{cand.}"}; + // Event selection criteria Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; Configurable isVertexITSTPC{"isVertexITSTPC", 0, "Select collisions with at least one ITS-TPC track"}; @@ -100,74 +117,57 @@ struct cascqaanalysis { void init(InitContext const&) { - AxisSpec ptAxis = {200, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec rapidityAxis = {200, -2.0f, 2.0f, "y"}; - ConfigurableAxis centFT0MAxis{"FT0M", - {VARIABLE_WIDTH, 0., 0.01, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 105.5}, - "FT0M (%)"}; - ConfigurableAxis centFV0AAxis{"FV0A", - {VARIABLE_WIDTH, 0., 0.01, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 105.5}, - "FV0A (%)"}; - AxisSpec eventTypeAxis = {3, -0.5f, 2.5f, "Event Type"}; - AxisSpec nAssocCollAxis = {5, -0.5f, 4.5f, "N_{assoc.}"}; - AxisSpec nChargedFT0MGenAxis = {500, 0, 500, "N_{FT0M, gen.}"}; - AxisSpec nChargedFV0AGenAxis = {500, 0, 500, "N_{FV0A, gen.}"}; - AxisSpec multNTracksAxis = {500, 0, 500, "N_{tracks}"}; - AxisSpec signalFT0MAxis = {10000, 0, 40000, "FT0M amplitude"}; - AxisSpec signalFV0AAxis = {10000, 0, 40000, "FV0A amplitude"}; - AxisSpec nCandidates = {30, -0.5, 29.5, "N_{cand.}"}; - TString hCandidateCounterLabels[4] = {"All candidates", "passed topo cuts", "has associated MC particle", "associated with Xi(Omega)"}; TString hNEventsMCLabels[6] = {"All", "z vrtx", "INEL", "INEL>0", "INEL>1", "Associated with rec. collision"}; TString hNEventsLabels[13] = {"All", "kIsTriggerTVX", "kNoTimeFrameBorder", "kNoITSROFrameBorder", "kIsVertexITSTPC", "kNoSameBunchPileup", "kIsGoodZvtxFT0vsPV", "isVertexTOFmatched", "kNoCollInTimeRangeNarrow", "z vrtx", "INEL", "INEL>0", "INEL>1"}; - registry.add("hNEvents", "hNEvents", {HistType::kTH1F, {{13, 0.f, 13.f}}}); + registry.add("hNEvents", "hNEvents", {HistType::kTH1D, {{13, 0.f, 13.f}}}); - for (Int_t n = 1; n <= registry.get(HIST("hNEvents"))->GetNbinsX(); n++) { + for (int n = 1; n <= registry.get(HIST("hNEvents"))->GetNbinsX(); n++) { registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(n, hNEventsLabels[n - 1]); } - registry.add("hZCollision", "hZCollision", {HistType::kTH1F, {{200, -20.f, 20.f}}}); + registry.add("hZCollision", "hZCollision", {HistType::kTH1D, {{200, -20.f, 20.f}}}); - registry.add("hCandidateCounter", "hCandidateCounter", {HistType::kTH1F, {{4, 0.0f, 4.0f}}}); - for (Int_t n = 1; n <= registry.get(HIST("hCandidateCounter"))->GetNbinsX(); n++) { + registry.add("hCandidateCounter", "hCandidateCounter", {HistType::kTH1D, {{4, 0.0f, 4.0f}}}); + for (int n = 1; n <= registry.get(HIST("hCandidateCounter"))->GetNbinsX(); n++) { registry.get(HIST("hCandidateCounter"))->GetXaxis()->SetBinLabel(n, hCandidateCounterLabels[n - 1]); } if (isMC) { // Rec. lvl registry.add("fakeEvents", "fakeEvents", {HistType::kTH1F, {{1, -0.5f, 0.5f}}}); - registry.add("hNchFT0MPVContr", "hNchFT0MPVContr", {HistType::kTH3F, {nChargedFT0MGenAxis, multNTracksAxis, eventTypeAxis}}); - registry.add("hNchFV0APVContr", "hNchFV0APVContr", {HistType::kTH3F, {nChargedFV0AGenAxis, multNTracksAxis, eventTypeAxis}}); // Gen. lvl - registry.add("hNEventsMC", "hNEventsMC", {HistType::kTH1F, {{6, 0.0f, 6.0f}}}); - for (Int_t n = 1; n <= registry.get(HIST("hNEventsMC"))->GetNbinsX(); n++) { + registry.add("hNEventsMC", "hNEventsMC", {HistType::kTH1D, {{6, 0.0f, 6.0f}}}); + for (int n = 1; n <= registry.get(HIST("hNEventsMC"))->GetNbinsX(); n++) { registry.get(HIST("hNEventsMC"))->GetXaxis()->SetBinLabel(n, hNEventsMCLabels[n - 1]); } - registry.add("hZCollisionGen", "hZCollisionGen", {HistType::kTH1F, {{200, -20.f, 20.f}}}); - registry.add("hNchFT0MNAssocMCCollisions", "hNchFT0MNAssocMCCollisions", {HistType::kTH3F, {nChargedFT0MGenAxis, nAssocCollAxis, eventTypeAxis}}); - registry.add("hNchFT0MNAssocMCCollisionsSameType", "hNchFT0MNAssocMCCollisionsSameType", {HistType::kTH3F, {nChargedFT0MGenAxis, nAssocCollAxis, eventTypeAxis}}); + registry.add("hZCollisionGen", "hZCollisionGen", {HistType::kTH1D, {{200, -20.f, 20.f}}}); + registry.add("hNchFT0MNAssocMCCollisions", "hNchFT0MNAssocMCCollisions", {HistType::kTH3D, {nChargedFT0MGenAxis, nAssocCollAxis, eventTypeAxis}}); + registry.add("hNchFT0MNAssocMCCollisionsSameType", "hNchFT0MNAssocMCCollisionsSameType", {HistType::kTH3D, {nChargedFT0MGenAxis, nAssocCollAxis, eventTypeAxis}}); registry.add("hNContributorsCorrelation", "hNContributorsCorrelation", {HistType::kTH2F, {{250, -0.5f, 249.5f, "Secondary Contributor"}, {250, -0.5f, 249.5f, "Main Contributor"}}}); - registry.add("hNchFT0MGenEvType", "hNchFT0MGenEvType", {HistType::kTH2F, {nChargedFT0MGenAxis, eventTypeAxis}}); - registry.add("hNchFV0AGenEvType", "hNchFV0AGenEvType", {HistType::kTH2F, {nChargedFV0AGenAxis, eventTypeAxis}}); - registry.add("hCentFT0M_genMC", "hCentFT0M_genMC", {HistType::kTH2F, {centFT0MAxis, eventTypeAxis}}); + registry.add("hNchFT0MGenEvType", "hNchFT0MGenEvType", {HistType::kTH2D, {nChargedFT0MGenAxis, eventTypeAxis}}); + registry.add("hNchFV0AGenEvType", "hNchFV0AGenEvType", {HistType::kTH2D, {nChargedFV0AGenAxis, eventTypeAxis}}); + registry.add("hCentFT0M_genMC", "hCentFT0M_genMC", {HistType::kTH2D, {centFT0MAxis, eventTypeAxis}}); } - registry.add("hCentFT0M_rec", "hCentFT0M_rec", {HistType::kTH2F, {centFT0MAxis, eventTypeAxis}}); + registry.add("hCentFT0M_rec", "hCentFT0M_rec", {HistType::kTH2D, {centFT0MAxis, eventTypeAxis}}); if (candidateQA) { - registry.add("hNcandidates", "hNcandidates", {HistType::kTH3F, {nCandidates, centFT0MAxis, {2, -0.5f, 1.5f}}}); + registry.add("hNcandidates", "hNcandidates", {HistType::kTH3D, {nCandidates, centFT0MAxis, {2, -0.5f, 1.5f}}}); } if (multQA) { if (isMC) { // Rec. lvl - registry.add("hNchFT0Mglobal", "hNchFT0Mglobal", {HistType::kTH3F, {nChargedFT0MGenAxis, multNTracksAxis, eventTypeAxis}}); + registry.add("hNchFT0Mglobal", "hNchFT0Mglobal", {HistType::kTH3D, {nChargedFT0MGenAxis, multNTracksAxis, eventTypeAxis}}); + registry.add("hNchFT0MPVContr", "hNchFT0MPVContr", {HistType::kTH3D, {nChargedFT0MGenAxis, multNTracksAxis, eventTypeAxis}}); + registry.add("hNchFV0APVContr", "hNchFV0APVContr", {HistType::kTH3D, {nChargedFV0AGenAxis, multNTracksAxis, eventTypeAxis}}); } - registry.add("hFT0MpvContr", "hFT0MpvContr", {HistType::kTH3F, {centFT0MAxis, multNTracksAxis, eventTypeAxis}}); - registry.add("hFV0ApvContr", "hFV0ApvContr", {HistType::kTH3F, {centFV0AAxis, multNTracksAxis, eventTypeAxis}}); - registry.add("hFT0Mglobal", "hFT0Mglobal", {HistType::kTH3F, {centFT0MAxis, multNTracksAxis, eventTypeAxis}}); - registry.add("hFV0AFT0M", "hFV0AFT0M", {HistType::kTH3F, {centFV0AAxis, centFT0MAxis, eventTypeAxis}}); - registry.add("hFT0MFV0Asignal", "hFT0MFV0Asignal", {HistType::kTH2F, {signalFT0MAxis, signalFV0AAxis}}); - registry.add("hFT0MsignalPVContr", "hFT0MsignalPVContr", {HistType::kTH3F, {signalFT0MAxis, multNTracksAxis, eventTypeAxis}}); + registry.add("hFT0MpvContr", "hFT0MpvContr", {HistType::kTH3D, {centFT0MAxis, multNTracksAxis, eventTypeAxis}}); + registry.add("hFV0ApvContr", "hFV0ApvContr", {HistType::kTH3D, {centFV0AAxis, multNTracksAxis, eventTypeAxis}}); + registry.add("hFT0Mglobal", "hFT0Mglobal", {HistType::kTH3D, {centFT0MAxis, multNTracksAxis, eventTypeAxis}}); + registry.add("hFV0AFT0M", "hFV0AFT0M", {HistType::kTH3D, {centFV0AAxis, centFT0MAxis, eventTypeAxis}}); + registry.add("hFT0MFV0Asignal", "hFT0MFV0Asignal", {HistType::kTH2D, {signalFT0MAxis, signalFV0AAxis}}); + registry.add("hFT0MsignalPVContr", "hFT0MsignalPVContr", {HistType::kTH3D, {signalFT0MAxis, multNTracksAxis, eventTypeAxis}}); } } @@ -182,7 +182,7 @@ struct cascqaanalysis { Partition globalTracksIUEta05 = (nabs(aod::track::eta) < 0.5f) && (requireGlobalTrackInFilter()); template - bool AcceptCascCandidate(TCascade const& cascCand, float const& pvx, float const& pvy, float const& pvz) + bool acceptCascCandidate(TCascade const& cascCand, float const& pvx, float const& pvy, float const& pvz) { // Access daughter tracks auto posdau = cascCand.template posTrack_as(); @@ -194,9 +194,9 @@ struct cascqaanalysis { cascCand.v0radius() > v0radius && cascCand.casccosPA(pvx, pvy, pvz) > casccospa && cascCand.v0cosPA(pvx, pvy, pvz) > v0cospa && - TMath::Abs(posdau.eta()) < etadau && - TMath::Abs(negdau.eta()) < etadau && - TMath::Abs(bachelor.eta()) < etadau) { + std::fabs(posdau.eta()) < etadau && + std::fabs(negdau.eta()) < etadau && + std::fabs(bachelor.eta()) < etadau) { return true; } else { return false; @@ -204,11 +204,11 @@ struct cascqaanalysis { } template - uint16_t GetGenNchInFT0Mregion(TMcParticles particles) + uint16_t getGenNchInFT0Mregion(TMcParticles particles) { // Particle counting in FITFT0: -3.3<η<-2.1; 3.5<η<4.9 uint16_t nchFT0 = 0; - for (auto& mcParticle : particles) { + for (const auto& mcParticle : particles) { if (!mcParticle.isPhysicalPrimary()) { continue; } @@ -228,11 +228,11 @@ struct cascqaanalysis { } template - uint16_t GetGenNchInFV0Aregion(TMcParticles particles) + uint16_t getGenNchInFV0Aregion(TMcParticles particles) { // Particle counting in FV0A: 2.2<η<5.1 uint16_t nchFV0A = 0; - for (auto& mcParticle : particles) { + for (const auto& mcParticle : particles) { if (!mcParticle.isPhysicalPrimary()) { continue; } @@ -252,7 +252,7 @@ struct cascqaanalysis { } template - int GetEventTypeFlag(TCollision const& collision) + int getEventTypeFlag(TCollision const& collision) { // 0 - INEL, 1 - INEL>0, 2 - INEL>1 int evFlag = 0; @@ -269,7 +269,7 @@ struct cascqaanalysis { } template - bool AcceptEvent(TCollision const& collision, bool isFillEventSelectionQA) + bool acceptEvent(TCollision const& collision, bool isFillEventSelectionQA) { if (isFillEventSelectionQA) { registry.fill(HIST("hNEvents"), 0.5); @@ -339,7 +339,7 @@ struct cascqaanalysis { } // Z vertex selection - if (TMath::Abs(collision.posZ()) > cutzvertex) { + if (std::fabs(collision.posZ()) > cutzvertex) { return false; } if (isFillEventSelectionQA) { @@ -357,11 +357,11 @@ struct cascqaanalysis { aod::V0Datas const&, DauTracks const&) { - if (!AcceptEvent(collision, 1)) { + if (!acceptEvent(collision, 1)) { return; } - int evType = GetEventTypeFlag(collision); + int evType = getEventTypeFlag(collision); auto tracksGroupedPVcontr = pvContribTracksIUEta1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); int nTracksPVcontr = tracksGroupedPVcontr.size(); @@ -387,7 +387,7 @@ struct cascqaanalysis { for (const auto& casc : Cascades) { // loop over Cascades registry.fill(HIST("hCandidateCounter"), 0.5); // all candidates nCandAll++; - if (AcceptCascCandidate(casc, collision.posX(), collision.posY(), collision.posZ())) { + if (acceptCascCandidate(casc, collision.posX(), collision.posY(), collision.posZ())) { registry.fill(HIST("hCandidateCounter"), 1.5); // passed topo cuts nCandSel++; // Fill table @@ -422,8 +422,8 @@ struct cascqaanalysis { // c x tau float cascpos = std::hypot(casc.x() - collision.posX(), casc.y() - collision.posY(), casc.z() - collision.posZ()); float cascptotmom = std::hypot(casc.px(), casc.py(), casc.pz()); - float ctauXi = pdgDB->Mass(3312) * cascpos / (cascptotmom + 1e-13); - float ctauOmega = pdgDB->Mass(3334) * cascpos / (cascptotmom + 1e-13); + float ctauXi = o2::constants::physics::MassXiMinus * cascpos / (cascptotmom + 1e-13); + float ctauOmega = o2::constants::physics::MassOmegaMinus * cascpos / (cascptotmom + 1e-13); mycascades(collision.posZ(), collision.centFT0M(), collision.centFV0A(), @@ -438,7 +438,7 @@ struct cascqaanalysis { posdau.tpcNClsFound(), negdau.tpcNClsFound(), bachelor.tpcNClsFound(), posdau.tpcNClsCrossedRows(), negdau.tpcNClsCrossedRows(), bachelor.tpcNClsCrossedRows(), posdau.hasTOF(), negdau.hasTOF(), bachelor.hasTOF(), - posdau.pt(), negdau.pt(), bachelor.pt(), -1, -1, casc.bachBaryonCosPA(), casc.bachBaryonDCAxyToPV(), evFlag); + posdau.pt(), negdau.pt(), bachelor.pt(), -1, -1, casc.bachBaryonCosPA(), casc.bachBaryonDCAxyToPV(), evFlag, 1e3, 1e3); } } } @@ -460,7 +460,7 @@ struct cascqaanalysis { soa::Join const&, // aod::McCentFV0As to be added aod::McParticles const& mcParticles) { - if (!AcceptEvent(collision, 1)) { + if (!acceptEvent(collision, 1)) { return; } @@ -479,8 +479,8 @@ struct cascqaanalysis { // N charged in FT0M region in corresponding gen. MC collision auto mcPartSlice = mcParticles.sliceBy(perMcCollision, collision.mcCollision_as>().globalIndex()); // mcCollision.centFV0A() to be added - uint16_t nchFT0 = GetGenNchInFT0Mregion(mcPartSlice); - uint16_t nchFV0 = GetGenNchInFV0Aregion(mcPartSlice); + uint16_t nchFT0 = getGenNchInFT0Mregion(mcPartSlice); + uint16_t nchFV0 = getGenNchInFV0Aregion(mcPartSlice); int evType = 0; registry.fill(HIST("hNEvents"), 10.5); // INEL @@ -516,19 +516,23 @@ struct cascqaanalysis { for (const auto& casc : Cascades) { // loop over Cascades registry.fill(HIST("hCandidateCounter"), 0.5); // all candidates nCandAll++; - if (AcceptCascCandidate(casc, collision.posX(), collision.posY(), collision.posZ())) { + if (acceptCascCandidate(casc, collision.posX(), collision.posY(), collision.posZ())) { registry.fill(HIST("hCandidateCounter"), 1.5); // passed topo cuts nCandSel++; // Check mc association - float lPDG = -1; + float lPDG = 1e3; + float genPt = 1e3; + float genY = 1e3; float isPrimary = -1; if (casc.has_mcParticle()) { registry.fill(HIST("hCandidateCounter"), 2.5); // has associated MC particle auto cascmc = casc.mcParticle(); - if (TMath::Abs(cascmc.pdgCode()) == 3312 || TMath::Abs(cascmc.pdgCode()) == 3334) { + if (std::abs(cascmc.pdgCode()) == PDG_t::kXiMinus || std::abs(cascmc.pdgCode()) == PDG_t::kOmegaMinus) { registry.fill(HIST("hCandidateCounter"), 3.5); // associated with Xi or Omega lPDG = cascmc.pdgCode(); isPrimary = cascmc.isPhysicalPrimary() ? 1 : 0; + genPt = cascmc.pt(); + genY = cascmc.y(); } } if (fRand->Rndm() < lEventScale) { @@ -564,8 +568,8 @@ struct cascqaanalysis { // c x tau float cascpos = std::hypot(casc.x() - collision.posX(), casc.y() - collision.posY(), casc.z() - collision.posZ()); float cascptotmom = std::hypot(casc.px(), casc.py(), casc.pz()); - float ctauXi = pdgDB->Mass(3312) * cascpos / (cascptotmom + 1e-13); - float ctauOmega = pdgDB->Mass(3334) * cascpos / (cascptotmom + 1e-13); + float ctauXi = o2::constants::physics::MassXiMinus * cascpos / (cascptotmom + 1e-13); + float ctauOmega = o2::constants::physics::MassOmegaMinus * cascpos / (cascptotmom + 1e-13); mycascades(collision.posZ(), mcCollision.centFT0M(), 0, // mcCollision.centFV0A() to be added @@ -580,7 +584,7 @@ struct cascqaanalysis { posdau.tpcNClsFound(), negdau.tpcNClsFound(), bachelor.tpcNClsFound(), posdau.tpcNClsCrossedRows(), negdau.tpcNClsCrossedRows(), bachelor.tpcNClsCrossedRows(), posdau.hasTOF(), negdau.hasTOF(), bachelor.hasTOF(), - posdau.pt(), negdau.pt(), bachelor.pt(), lPDG, isPrimary, casc.bachBaryonCosPA(), casc.bachBaryonDCAxyToPV(), evFlag); + posdau.pt(), negdau.pt(), bachelor.pt(), lPDG, isPrimary, casc.bachBaryonCosPA(), casc.bachBaryonDCAxyToPV(), evFlag, genPt, genY); } } } @@ -600,7 +604,7 @@ struct cascqaanalysis { registry.fill(HIST("hNEventsMC"), 0.5); // Generated with accepted z vertex - if (TMath::Abs(mcCollision.posZ()) > cutzvertex) { + if (std::fabs(mcCollision.posZ()) > cutzvertex) { return; } registry.fill(HIST("hZCollisionGen"), mcCollision.posZ()); @@ -626,18 +630,18 @@ struct cascqaanalysis { registry.fill(HIST("hCentFT0M_genMC"), mcCollision.centFT0M(), evType); - uint16_t nchFT0 = GetGenNchInFT0Mregion(mcParticles); - uint16_t nchFV0 = GetGenNchInFV0Aregion(mcParticles); + uint16_t nchFT0 = getGenNchInFT0Mregion(mcParticles); + uint16_t nchFV0 = getGenNchInFV0Aregion(mcParticles); registry.fill(HIST("hNchFT0MGenEvType"), nchFT0, evType); registry.fill(HIST("hNchFV0AGenEvType"), nchFV0, evType); - std::vector SelectedEvents(collisions.size()); - std::vector NumberOfContributors; + std::vector selectedEvents(collisions.size()); + std::vector numberOfContributors; int nevts = 0; int nAssocColl = 0; for (const auto& collision : collisions) { CollisionIndexAndType collWithType = {0, 0x0}; - if (!AcceptEvent(collision, 0)) { + if (!acceptEvent(collision, 0)) { continue; } collWithType.index = collision.mcCollision_as>().globalIndex(); // mcCollision.centFV0A() to be added @@ -650,30 +654,30 @@ struct cascqaanalysis { collWithType.typeFlag |= o2::aod::myMCcascades::EvFlags::EvINELgt1; } - SelectedEvents[nevts++] = collWithType; + selectedEvents[nevts++] = collWithType; if (collision.mcCollision_as>().globalIndex() == mcCollision.globalIndex()) { // mcCollision.centFV0A() to be added nAssocColl++; - NumberOfContributors.push_back(collision.numContrib()); + numberOfContributors.push_back(collision.numContrib()); } } - SelectedEvents.resize(nevts); + selectedEvents.resize(nevts); registry.fill(HIST("hNchFT0MNAssocMCCollisions"), nchFT0, nAssocColl, evType); - if (NumberOfContributors.size() == 2) { - std::sort(NumberOfContributors.begin(), NumberOfContributors.end()); - registry.fill(HIST("hNContributorsCorrelation"), NumberOfContributors[0], NumberOfContributors[1]); + if (numberOfContributors.size() == 2) { + std::sort(numberOfContributors.begin(), numberOfContributors.end()); + registry.fill(HIST("hNContributorsCorrelation"), numberOfContributors[0], numberOfContributors[1]); } auto isAssocToINEL = [&mcCollision](CollisionIndexAndType i) { return (i.index == mcCollision.globalIndex()) && ((i.typeFlag & o2::aod::myMCcascades::EvFlags::EvINEL) == o2::aod::myMCcascades::EvFlags::EvINEL); }; auto isAssocToINELgt0 = [&mcCollision](CollisionIndexAndType i) { return (i.index == mcCollision.globalIndex()) && ((i.typeFlag & o2::aod::myMCcascades::EvFlags::EvINELgt0) == o2::aod::myMCcascades::EvFlags::EvINELgt0); }; auto isAssocToINELgt1 = [&mcCollision](CollisionIndexAndType i) { return (i.index == mcCollision.globalIndex()) && ((i.typeFlag & o2::aod::myMCcascades::EvFlags::EvINELgt1) == o2::aod::myMCcascades::EvFlags::EvINELgt1); }; // number of reconstructed INEL events that have the same global index as mcCollision - const auto evtReconstructedAndINEL = std::count_if(SelectedEvents.begin(), SelectedEvents.end(), isAssocToINEL); + const auto evtReconstructedAndINEL = std::count_if(selectedEvents.begin(), selectedEvents.end(), isAssocToINEL); // number of reconstructed INEL > 0 events that have the same global index as mcCollision - const auto evtReconstructedAndINELgt0 = std::count_if(SelectedEvents.begin(), SelectedEvents.end(), isAssocToINELgt0); + const auto evtReconstructedAndINELgt0 = std::count_if(selectedEvents.begin(), selectedEvents.end(), isAssocToINELgt0); // number of reconstructed INEL > 1 events that have the same global index as mcCollision - const auto evtReconstructedAndINELgt1 = std::count_if(SelectedEvents.begin(), SelectedEvents.end(), isAssocToINELgt1); + const auto evtReconstructedAndINELgt1 = std::count_if(selectedEvents.begin(), selectedEvents.end(), isAssocToINELgt1); switch (evType) { case 0: { @@ -707,9 +711,9 @@ struct cascqaanalysis { for (const auto& mcParticle : mcParticles) { float sign = 0; - if (mcParticle.pdgCode() == -3312 || mcParticle.pdgCode() == -3334) { + if (mcParticle.pdgCode() == PDG_t::kXiPlusBar || mcParticle.pdgCode() == PDG_t::kOmegaPlusBar) { sign = 1; - } else if (mcParticle.pdgCode() == 3312 || mcParticle.pdgCode() == 3334) { + } else if (mcParticle.pdgCode() == PDG_t::kXiMinus || mcParticle.pdgCode() == PDG_t::kOmegaMinus) { sign = -1; } else { continue; @@ -724,12 +728,12 @@ struct cascqaanalysis { } } - PROCESS_SWITCH(cascqaanalysis, processData, "Process Run 3 data", true); - PROCESS_SWITCH(cascqaanalysis, processMCrec, "Process Run 3 mc, reconstructed", false); - PROCESS_SWITCH(cascqaanalysis, processMCgen, "Process Run 3 mc, genereated", false); + PROCESS_SWITCH(Cascqaanalysis, processData, "Process Run 3 data", true); + PROCESS_SWITCH(Cascqaanalysis, processMCrec, "Process Run 3 mc, reconstructed", false); + PROCESS_SWITCH(Cascqaanalysis, processMCgen, "Process Run 3 mc, genereated", false); }; -struct myCascades { +struct MyCascades { HistogramRegistry registry{"registry"}; @@ -738,7 +742,7 @@ struct myCascades { void init(InitContext const&) { - TString PGDlabels[3] = {"Unknown", "3312", "3334"}; + TString pdglabels[3] = {"Unknown", "3312", "3334"}; registry.add("hPt", "hPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}); registry.add("hMassXi", "hMassXi", {HistType::kTH1F, {{1000, 1.0f, 2.0f}}}); registry.add("hMassOmega", "hMassOmega", {HistType::kTH1F, {{1000, 1.0f, 2.0f}}}); @@ -769,8 +773,8 @@ struct myCascades { registry.add("hBachITSHits", "hBachITSHits", {HistType::kTH1F, {{8, -0.5f, 7.5f}}}); registry.add("hIsPrimary", "hIsPrimary", {HistType::kTH1F, {{3, -1.5f, 1.5f}}}); registry.add("hPDGcode", "hPDGcode", {HistType::kTH1F, {{3, -1.5f, 1.5f}}}); - for (Int_t n = 1; n <= registry.get(HIST("hPDGcode"))->GetNbinsX(); n++) { - registry.get(HIST("hPDGcode"))->GetXaxis()->SetBinLabel(n, PGDlabels[n - 1]); + for (int n = 1; n <= registry.get(HIST("hPDGcode"))->GetNbinsX(); n++) { + registry.get(HIST("hPDGcode"))->GetXaxis()->SetBinLabel(n, pdglabels[n - 1]); } registry.add("hBachBaryonCosPA", "hBachBaryonCosPA", {HistType::kTH1F, {{100, 0.0f, 1.0f}}}); registry.add("hBachBaryonDCAxyToPV", "hBachBaryonDCAxyToPV", {HistType::kTH1F, {{300, -3.0f, 3.0f}}}); @@ -779,7 +783,7 @@ struct myCascades { void process(aod::MyCascades const& mycascades) { - for (auto& candidate : mycascades) { + for (const auto& candidate : mycascades) { registry.fill(HIST("hMassXi"), candidate.massxi()); registry.fill(HIST("hMassOmega"), candidate.massomega()); @@ -813,8 +817,8 @@ struct myCascades { registry.fill(HIST("hBachBaryonCosPA"), candidate.bachBaryonCosPA()); registry.fill(HIST("hBachBaryonDCAxyToPV"), candidate.bachBaryonDCAxyToPV()); - if (TMath::Abs(candidate.mcPdgCode()) == 3312 || TMath::Abs(candidate.mcPdgCode()) == 3334) { - registry.fill(HIST("hPDGcode"), TMath::Abs(candidate.mcPdgCode()) == 3312 ? 0 : 1); // 0 if Xi, 1 if Omega + if (std::abs(candidate.mcPdgCode()) == PDG_t::kXiMinus || std::abs(candidate.mcPdgCode()) == PDG_t::kOmegaMinus) { + registry.fill(HIST("hPDGcode"), std::abs(candidate.mcPdgCode()) == PDG_t::kXiMinus ? 0 : 1); // 0 if Xi, 1 if Omega } else { registry.fill(HIST("hPDGcode"), -1); // -1 if unknown } @@ -826,6 +830,6 @@ struct myCascades { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"lf-cascqaanalysis"}), - adaptAnalysisTask(cfgc, TaskName{"lf-mycascades"})}; + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Strangeness/hStrangeCorrelationFilter.cxx b/PWGLF/TableProducer/Strangeness/hStrangeCorrelationFilter.cxx index dc7fe18a66a..61f9e2f5086 100644 --- a/PWGLF/TableProducer/Strangeness/hStrangeCorrelationFilter.cxx +++ b/PWGLF/TableProducer/Strangeness/hStrangeCorrelationFilter.cxx @@ -12,6 +12,7 @@ /// \brief This task pre-filters tracks, V0s and cascades to do h-strangeness /// correlations with an analysis task. /// +/// \file hStrangeCorrelationFilter.cxx /// \author Kai Cui (kaicui@mails.ccnu.edu.cn) /// \author Lucia Anna Tarasovicova (lucia.anna.husova@cern.ch) /// \author David Dobrigkeit Chinellato (david.dobrigkeit.chinellato@cern.ch) @@ -29,46 +30,59 @@ #include "Common/DataModel/Centrality.h" #include "CCDB/BasicCCDBManager.h" #include "TF1.h" +#include +#include #include "EventFiltering/Zorro.h" #include "EventFiltering/ZorroSummary.h" using namespace o2; +using namespace o2::constants::math; using namespace o2::framework; using namespace o2::framework::expressions; -#define bitset(var, nbit) ((var) |= (1 << (nbit))) -#define bitcheck(var, nbit) ((var) & (1 << (nbit))) +#define BIT_SET(var, nbit) ((var) |= (1 << (nbit))) +#define BIT_CHECK(var, nbit) ((var) & (1 << (nbit))) + +struct HStrangeCorrelationFilter { + const float ctauxiPDG = 4.91; // from PDG + const float ctauomegaPDG = 2.461; // from PDG -struct hstrangecorrelationfilter { Service ccdb; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + // master analysis switches + Configurable doPPAnalysis{"doPPAnalysis", true, "if in pp, set to true"}; // Operational Configurable fillTableOnlyWithCompatible{"fillTableOnlyWithCompatible", true, "pre-apply dE/dx, broad mass window in table filling"}; Configurable strangedEdxNSigmaLoose{"strangedEdxNSigmaLoose", 5, "Nsigmas for strange decay daughters"}; Configurable strangedEdxNSigma{"strangedEdxNSigma", 4, "Nsigmas for strange decay daughters"}; Configurable strangedEdxNSigmaTight{"strangedEdxNSigmaTight", 3, "Nsigmas for strange decay daughters"}; + // used for event selections in Pb-Pb + Configurable cfgCutOccupancyHigh{"cfgCutOccupancyHigh", 3000, "High cut on TPC occupancy"}; + Configurable cfgCutOccupancyLow{"cfgCutOccupancyLow", 0, "Low cut on TPC occupancy"}; + // event filtering Configurable zorroMask{"zorroMask", "", "zorro trigger class to select on (empty: none)"}; // Trigger particle selections in phase space - Configurable triggerEtaMin{"triggerEtaCutMin", -0.8, "triggeretamin"}; - Configurable triggerEtaMax{"triggerEtaCutMax", 0.8, "triggeretamax"}; + Configurable triggerEtaMin{"triggerEtaMin", -0.8, "triggeretamin"}; + Configurable triggerEtaMax{"triggerEtaMax", 0.8, "triggeretamax"}; Configurable triggerPtCutMin{"triggerPtCutMin", 3, "triggerptmin"}; Configurable triggerPtCutMax{"triggerPtCutMax", 20, "triggerptmax"}; // Track quality Configurable minTPCNCrossedRows{"minTPCNCrossedRows", 70, "Minimum TPC crossed rows"}; Configurable triggerRequireITS{"triggerRequireITS", true, "require ITS signal in trigger tracks"}; + Configurable assocRequireITS{"assocRequireITS", true, "require ITS signal in assoc tracks"}; Configurable triggerMaxTPCSharedClusters{"triggerMaxTPCSharedClusters", 200, "maximum number of shared TPC clusters (inclusive)"}; Configurable triggerRequireL0{"triggerRequireL0", false, "require ITS L0 cluster for trigger"}; // Associated particle selections in phase space - Configurable assocEtaMin{"assocEtaCutMin", -0.8, "triggeretamin"}; - Configurable assocEtaMax{"assocEtaCutMax", 0.8, "triggeretamax"}; + Configurable assocEtaMin{"assocEtaMin", -0.8, "triggeretamin"}; + Configurable assocEtaMax{"assocEtaMax", 0.8, "triggeretamax"}; Configurable assocPtCutMin{"assocPtCutMin", 0.2, "assocptmin"}; Configurable assocPtCutMax{"assocPtCutMax", 10, "assocptmax"}; @@ -78,12 +92,23 @@ struct hstrangecorrelationfilter { Configurable rejectSigma{"rejectSigma", 1, "n sigma for rejecting pion candidates"}; // V0 selections - Configurable v0Cospa{"v0cospa", 0.97, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0) - Configurable dcaV0dau{"dcav0dau", 1.0, "DCA V0 Daughters"}; - Configurable dcaNegtopv{"dcanegtopv", 0.06, "DCA Neg To PV"}; - Configurable dcaPostopv{"dcapostopv", 0.06, "DCA Pos To PV"}; - Configurable v0RadiusMin{"v0radiusmin", 0.5, "v0radius"}; - Configurable v0RadiusMax{"v0radiusmax", 200, "v0radius"}; + Configurable v0Cospa{"v0Cospa", 0.97, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0) + Configurable dcaV0dau{"dcaV0dau", 1.0, "DCA V0 Daughters"}; + Configurable dcaNegtopv{"dcaNegtopv", 0.06, "DCA Neg To PV"}; + Configurable dcaPostopv{"dcaPostopv", 0.06, "DCA Pos To PV"}; + Configurable v0RadiusMin{"v0RadiusMin", 0.5, "v0radius"}; + Configurable v0RadiusMax{"v0RadiusMax", 200, "v0radius"}; + // more V0 selections in PbPb + Configurable lifetimecutK0S{"lifetimecutK0S", 20, "lifetimecutK0S"}; + Configurable lifetimecutLambda{"lifetimecutLambda", 30, "lifetimecutLambda"}; + Configurable dcanegtopvK0S{"dcanegtopvK0S", 0.1, "DCA Neg To PV"}; + Configurable dcapostopvK0S{"dcapostopvK0S", 0.1, "DCA Pos To PV"}; + Configurable dcanegtopvLambda{"dcanegtopvLambda", 0.05, "DCA Neg To PV"}; + Configurable dcapostopvLambda{"dcapostopvLambda", 0.2, "DCA Pos To PV"}; + Configurable dcanegtopvAntiLambda{"dcanegtopvAntiLambda", 0.2, "DCA Neg To PV"}; + Configurable dcapostopvAntiLambda{"dcapostopvAntiLambda", 0.05, "DCA Pos To PV"}; + // original equation: lArmPt*2>TMath::Abs(lArmAlpha) only for K0S + Configurable armPodCut{"armPodCut", 5.0f, "pT * (cut) > |alpha|, AP cut. Negative: no cut"}; // specific selections Configurable lambdaCospa{"lambdaCospa", 0.995, "CosPA for lambda"}; // allows for tighter selection for Lambda @@ -94,25 +119,49 @@ struct hstrangecorrelationfilter { Configurable dcaXYpTdep{"dcaXYpTdep", 0.013, "[1] in |DCAxy| < [0]+[1]/pT"}; // cascade selections - Configurable cascadesetting_cospa{"cascadesetting_cospa", 0.95, "cascadesetting_cospa"}; - Configurable cascadesetting_dcacascdau{"cascadesetting_dcacascdau", 1.0, "cascadesetting_dcacascdau"}; - Configurable cascadesetting_dcabachtopv{"cascadesetting_dcabachtopv", 0.1, "cascadesetting_dcabachtopv"}; - Configurable cascadesetting_cascradius{"cascadesetting_cascradius", 0.5, "cascadesetting_cascradius"}; - Configurable cascadesetting_v0masswindow{"cascadesetting_v0masswindow", 0.01, "cascadesetting_v0masswindow"}; - Configurable cascadesetting_mindcav0topv{"cascadesetting_mindcav0topv", 0.01, "cascadesetting_mindcav0topv"}; - + Configurable cascadeSettingCospa{"cascadeSettingCospa", 0.95, "cascadeSettingCospa"}; + Configurable cascadeSettingDcacascdau{"cascadeSettingDcacascdau", 1.0, "cascadeSettingDcacascdau"}; + Configurable cascadeSettingDcabachtopv{"cascadeSettingDcabachtopv", 0.1, "cascadeSettingDcabachtopv"}; + Configurable cascadeSettingCascradius{"cascadeSettingCascradius", 0.5, "cascadeSettingCascradius"}; + Configurable cascadeSettingV0masswindow{"cascadeSettingV0masswindow", 0.01, "cascadeSettingV0masswindow"}; + Configurable cascadeSettingMindcav0topv{"cascadeSettingMindcav0topv", 0.01, "cascadeSettingMindcav0topv"}; + struct : ConfigurableGroup { + // cascade selections in PbPb + Configurable cascCospa{"cascCospa", 0.95, "cascCospa"}; + Configurable cascDcacascdau{"cascDcacascdau", 1.0, "cascDcacascdau"}; + Configurable cascDcabachtopv{"cascDcabachtopv", 0.1, "cascDcabachtopv"}; + Configurable cascRadius{"cascRadius", 0.5, "cascRadius"}; + Configurable cascV0masswindow{"cascV0masswindow", 0.01, "cascV0masswindow"}; + Configurable cascMindcav0topv{"cascMindcav0topv", 0.01, "cascMindcav0topv"}; + Configurable bachBaryonCosPA{"bachBaryonCosPA", 0.9999, "Bachelor baryon CosPA"}; + Configurable bachBaryonDCAxyToPV{"bachBaryonDCAxyToPV", 0.08, "DCA bachelor baryon to PV"}; + Configurable dcaBaryonToPV{"dcaBaryonToPV", 0.05, "DCA of baryon doughter track To PV"}; + Configurable dcaMesonToPV{"dcaMesonToPV", 0.1, "DCA of meson doughter track To PV"}; + Configurable dcaBachToPV{"dcaBachToPV", 0.07, "DCA Bach To PV"}; + Configurable cascdcaV0dau{"cascdcaV0dau", 0.5, "DCA V0 Daughters"}; + Configurable dcaCacsDauPar0{"dcaCacsDauPar0", 0.8, " par for pt dep DCA cascade daughter cut, p_T < 1 GeV/c"}; + Configurable dcaCacsDauPar1{"dcaCacsDauPar1", 0.5, " par for pt dep DCA cascade daughter cut, 1< p_T < 4 GeV/c"}; + Configurable dcaCacsDauPar2{"dcaCacsDauPar2", 0.2, " par for pt dep DCA cascade daughter cut, p_T > 4 GeV/c"}; + Configurable cascdcaV0ToPV{"cascdcaV0ToPV", 0.06, "DCA V0 To PV"}; + Configurable cascv0cospa{"cascv0cospa", 0.98, "V0 CosPA"}; + Configurable cascv0RadiusMin{"cascv0RadiusMin", 2.5, "v0radius"}; + Configurable proplifetime{"proplifetime", 3, "ctau/"}; + Configurable lambdaMassWin{"lambdaMassWin", 0.005, "V0 Mass window limit"}; + Configurable rejcomp{"rejcomp", 0.008, "Competing Cascade rejection"}; + Configurable rapCut{"rapCut", 0.8, "Rapidity acceptance"}; + } MorePbPbsystCuts; // invariant mass parametrizations - Configurable> massParsK0Mean{"massParsK0Mean", {0.495, 0.000250, 0.0, 0.0}, "pars in [0]+[1]*x+[2]*TMath::Exp(-[3]*x)"}; - Configurable> massParsK0Width{"massParsK0Width", {0.00354, 0.000609, 0.0, 0.0}, "pars in [0]+[1]*x+[2]*TMath::Exp(-[3]*x)"}; + Configurable> massParsK0Mean{"massParsK0Mean", {0.495, 0.000250, 0.0, 0.0}, "pars in [0]+[1]*x+[2]*std::exp(-[3]*x)"}; + Configurable> massParsK0Width{"massParsK0Width", {0.00354, 0.000609, 0.0, 0.0}, "pars in [0]+[1]*x+[2]*std::exp(-[3]*x)"}; - Configurable> massParsLambdaMean{"massParsLambdaMean", {1.114, 0.000314, 0.140, 11.9}, "pars in [0]+[1]*x+[2]*TMath::Exp(-[3]*x)"}; - Configurable> massParsLambdaWidth{"massParsLambdaWidth", {0.00127, 0.000172, 0.00261, 2.02}, "pars in [0]+[1]*x+[2]*TMath::Exp(-[3]*x)"}; + Configurable> massParsLambdaMean{"massParsLambdaMean", {1.114, 0.000314, 0.140, 11.9}, "pars in [0]+[1]*x+[2]*std::exp(-[3]*x)"}; + Configurable> massParsLambdaWidth{"massParsLambdaWidth", {0.00127, 0.000172, 0.00261, 2.02}, "pars in [0]+[1]*x+[2]*std::exp(-[3]*x)"}; - Configurable> massParsCascadeMean{"massParsCascadeMean", {1.32, 0.000278, 0.0, 0.0}, "pars in [0]+[1]*x+[2]*TMath::Exp(-[3]*x)"}; - Configurable> massParsCascadeWidth{"massParsCascadeWidth", {0.00189, 0.000227, 0.00370, 1.635}, "pars in [0]+[1]*x+[2]*TMath::Exp(-[3]*x)"}; + Configurable> massParsCascadeMean{"massParsCascadeMean", {1.32, 0.000278, 0.0, 0.0}, "pars in [0]+[1]*x+[2]*std::exp(-[3]*x)"}; + Configurable> massParsCascadeWidth{"massParsCascadeWidth", {0.00189, 0.000227, 0.00370, 1.635}, "pars in [0]+[1]*x+[2]*std::exp(-[3]*x)"}; - Configurable> massParsOmegaMean{"massParsOmegaMean", {1.67, 0.000298, 0.0, 0.0}, "pars in [0]+[1]*x+[2]*TMath::Exp(-[3]*x)"}; - Configurable> massParsOmegaWidth{"massParsOmegaWidth", {0.00189, 0.000325, 0.00606, 1.77}, "pars in [0]+[1]*x+[2]*TMath::Exp(-[3]*x)"}; + Configurable> massParsOmegaMean{"massParsOmegaMean", {1.67, 0.000298, 0.0, 0.0}, "pars in [0]+[1]*x+[2]*std::exp(-[3]*x)"}; + Configurable> massParsOmegaWidth{"massParsOmegaWidth", {0.00189, 0.000325, 0.00606, 1.77}, "pars in [0]+[1]*x+[2]*std::exp(-[3]*x)"}; // must include windows for background and peak Configurable maxMassNSigma{"maxMassNSigma", 12.0f, "max mass region to be considered for further analysis"}; @@ -132,30 +181,36 @@ struct hstrangecorrelationfilter { Filter preFilterV0 = nabs(aod::v0data::dcapostopv) > dcaPostopv&& nabs(aod::v0data::dcanegtopv) > dcaNegtopv&& aod::v0data::dcaV0daughters < dcaV0dau; Filter preFilterCascade = - nabs(aod::cascdata::dcapostopv) > dcaPostopv&& nabs(aod::cascdata::dcanegtopv) > dcaNegtopv&& nabs(aod::cascdata::dcabachtopv) > cascadesetting_dcabachtopv&& aod::cascdata::dcaV0daughters < dcaV0dau&& aod::cascdata::dcacascdaughters < cascadesetting_dcacascdau; + nabs(aod::cascdata::dcapostopv) > dcaPostopv&& nabs(aod::cascdata::dcanegtopv) > dcaNegtopv&& nabs(aod::cascdata::dcabachtopv) > cascadeSettingDcabachtopv&& aod::cascdata::dcaV0daughters < dcaV0dau&& aod::cascdata::dcacascdaughters < cascadeSettingDcacascdau; - using V0LinkedTagged = soa::Join; - using CascadesLinkedTagged = soa::Join; + // using V0LinkedTagged = soa::Join; + // using CascadesLinkedTagged = soa::Join; + using FullTracks = soa::Join; + using FullTracksMC = soa::Join; using DauTracks = soa::Join; using DauTracksMC = soa::Join; // using IDTracks= soa::Join; // prepared for Bayesian PID - using IDTracks = soa::Join; + using IDTracks = soa::Join; + using IDTracksMC = soa::Join; using V0DatasWithoutTrackX = soa::Join; + using V0DatasWithoutTrackXMC = soa::Join; + using CascDatasMC = soa::Join; Produces triggerTrack; - Produces assocPion; + Produces triggerTrackExtra; Produces assocV0; Produces assocCascades; Produces assocHadrons; + Produces assocPID; - TF1* fK0Mean = new TF1("fK0Mean", "[0]+[1]*x+[2]*TMath::Exp(-[3]*x)"); - TF1* fK0Width = new TF1("fK0Width", "[0]+[1]*x+[2]*TMath::Exp(-[3]*x)"); - TF1* fLambdaMean = new TF1("fLambdaMean", "[0]+[1]*x+[2]*TMath::Exp(-[3]*x)"); - TF1* fLambdaWidth = new TF1("fLambdaWidth", "[0]+[1]*x+[2]*TMath::Exp(-[3]*x)"); - TF1* fXiMean = new TF1("fXiMean", "[0]+[1]*x+[2]*TMath::Exp(-[3]*x)"); - TF1* fXiWidth = new TF1("fXiWidth", "[0]+[1]*x+[2]*TMath::Exp(-[3]*x)"); - TF1* fOmegaMean = new TF1("fomegaMean", "[0]+[1]*x+[2]*TMath::Exp(-[3]*x)"); - TF1* fOmegaWidth = new TF1("fomegaWidth", "[0]+[1]*x+[2]*TMath::Exp(-[3]*x)"); + TF1* fK0Mean = new TF1("fK0Mean", "[0]+[1]*x+[2]*std::exp(-[3]*x)"); + TF1* fK0Width = new TF1("fK0Width", "[0]+[1]*x+[2]*std::exp(-[3]*x)"); + TF1* fLambdaMean = new TF1("fLambdaMean", "[0]+[1]*x+[2]*std::exp(-[3]*x)"); + TF1* fLambdaWidth = new TF1("fLambdaWidth", "[0]+[1]*x+[2]*std::exp(-[3]*x)"); + TF1* fXiMean = new TF1("fXiMean", "[0]+[1]*x+[2]*std::exp(-[3]*x)"); + TF1* fXiWidth = new TF1("fXiWidth", "[0]+[1]*x+[2]*std::exp(-[3]*x)"); + TF1* fOmegaMean = new TF1("fomegaMean", "[0]+[1]*x+[2]*std::exp(-[3]*x)"); + TF1* fOmegaWidth = new TF1("fomegaWidth", "[0]+[1]*x+[2]*std::exp(-[3]*x)"); Zorro zorro; OutputObj zorroSummary{"zorroSummary"}; @@ -175,13 +230,17 @@ struct hstrangecorrelationfilter { fOmegaMean->SetParameters(massParsOmegaMean->at(0), massParsOmegaMean->at(1), massParsOmegaMean->at(2), massParsOmegaMean->at(3)); fOmegaWidth->SetParameters(massParsOmegaWidth->at(0), massParsOmegaWidth->at(1), massParsOmegaWidth->at(2), massParsOmegaWidth->at(3)); - histos.add("h3dMassK0Short", "h3dMassK0Short", kTH3F, {axisPtQA, axisK0ShortMass, axisMult}); - histos.add("h3dMassLambda", "h3dMassLambda", kTH3F, {axisPtQA, axisLambdaMass, axisMult}); - histos.add("h3dMassAntiLambda", "h3dMassAntiLambda", kTH3F, {axisPtQA, axisLambdaMass, axisMult}); - histos.add("h3dMassXiMinus", "h3dMassXiMinus", kTH3F, {axisPtQA, axisXiMass, axisMult}); - histos.add("h3dMassXiPlus", "h3dMassXiPlus", kTH3F, {axisPtQA, axisXiMass, axisMult}); - histos.add("h3dMassOmegaMinus", "h3dMassOmegaMinus", kTH3F, {axisPtQA, axisOmegaMass, axisMult}); - histos.add("h3dMassOmegaPlus", "h3dMassOmegaPlus", kTH3F, {axisPtQA, axisOmegaMass, axisMult}); + if (doprocessV0s || doprocessV0sMC) { + histos.add("h3dMassK0Short", "h3dMassK0Short", kTH3F, {axisPtQA, axisK0ShortMass, axisMult}); + histos.add("h3dMassLambda", "h3dMassLambda", kTH3F, {axisPtQA, axisLambdaMass, axisMult}); + histos.add("h3dMassAntiLambda", "h3dMassAntiLambda", kTH3F, {axisPtQA, axisLambdaMass, axisMult}); + } + if (doprocessCascades || doprocessCascadesMC) { + histos.add("h3dMassXiMinus", "h3dMassXiMinus", kTH3F, {axisPtQA, axisXiMass, axisMult}); + histos.add("h3dMassXiPlus", "h3dMassXiPlus", kTH3F, {axisPtQA, axisXiMass, axisMult}); + histos.add("h3dMassOmegaMinus", "h3dMassOmegaMinus", kTH3F, {axisPtQA, axisOmegaMass, axisMult}); + histos.add("h3dMassOmegaPlus", "h3dMassOmegaPlus", kTH3F, {axisPtQA, axisOmegaMass, axisMult}); + } } void initCCDB(aod::BCsWithTimestamps::iterator const& bc) @@ -196,6 +255,28 @@ struct hstrangecorrelationfilter { mRunNumber = bc.runNumber(); } + // more event selections in Pb-Pb + template + bool isCollisionSelectedPbPb(TCollision collision) + { + if (!collision.selection_bit(aod::evsel::kIsTriggerTVX)) /* FT0 vertex (acceptable FT0C-FT0A time difference) collisions */ + return false; + if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) // cut time intervals with dead ITS staves + return false; + if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + return false; + auto occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh) /* Below min occupancy and Above max occupancy*/ + return false; + if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) // reject collisions close to Time Frame borders + return false; + if (!collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) // reject events affected by the ITS ROF border + return false; + if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) // rejects collisions which are associated with the same "found-by-T0" bunch crossing + return false; + return true; + } + // reco-level trigger quality checks (N.B.: DCA is filtered, not selected) template bool isValidTrigger(TTrack track) @@ -216,21 +297,137 @@ struct hstrangecorrelationfilter { if (track.tpcNClsShared() > triggerMaxTPCSharedClusters) { return false; // skip, has shared clusters } - if (!(bitcheck(track.itsClusterMap(), 0)) && triggerRequireL0) { + if (!(BIT_CHECK(track.itsClusterMap(), 0)) && triggerRequireL0) { return false; // skip, doesn't have cluster in ITS L0 } return true; } + template + bool isValidAssocTrack(TTrack assoc) + { + if (assoc.eta() > assocEtaMax || assoc.eta() < assocEtaMin) { + return false; + } + if (assoc.pt() > assocPtCutMax || assoc.pt() < assocPtCutMin) { + return false; + } + if (assoc.tpcNClsCrossedRows() < minTPCNCrossedRows) { + return false; // crossed rows + } + if (!assoc.hasITS() && assocRequireITS) { + return false; // skip, doesn't have ITS signal (skips lots of TPC-only!) + } + + // do this only if information is available + float nSigmaTPCTOF[8] = {-10, -10, -10, -10, -10, -10, -10, -10}; + if constexpr (requires { assoc.tofSignal(); }) { + if (assoc.tofSignal() > 0) { + if (std::sqrt(assoc.tofNSigmaPi() * assoc.tofNSigmaPi() + assoc.tpcNSigmaPi() * assoc.tpcNSigmaPi()) > assocPionNSigmaTPCFOF) + return false; + if (assoc.tofNSigmaPr() < rejectSigma) + return false; + if (assoc.tpcNSigmaPr() < rejectSigma) + return false; + if (assoc.tofNSigmaKa() < rejectSigma) + return false; + if (assoc.tpcNSigmaKa() < rejectSigma) + return false; + nSigmaTPCTOF[4] = assoc.tofNSigmaPi(); + nSigmaTPCTOF[5] = assoc.tofNSigmaKa(); + nSigmaTPCTOF[6] = assoc.tofNSigmaPr(); + nSigmaTPCTOF[7] = assoc.tofNSigmaEl(); + } else { + if (assoc.tpcNSigmaPi() > assocPionNSigmaTPCFOF) + return false; + if (assoc.tpcNSigmaPr() < rejectSigma) + return false; + if (assoc.tpcNSigmaKa() < rejectSigma) + return false; + } + nSigmaTPCTOF[0] = assoc.tpcNSigmaPi(); + nSigmaTPCTOF[1] = assoc.tpcNSigmaKa(); + nSigmaTPCTOF[2] = assoc.tpcNSigmaPr(); + nSigmaTPCTOF[3] = assoc.tpcNSigmaEl(); + } + + bool physicalPrimary = false; + float origPt = -1; + if constexpr (requires { assoc.mcParticle(); }) { + if (assoc.has_mcParticle()) { + auto mcParticle = assoc.mcParticle(); + physicalPrimary = mcParticle.isPhysicalPrimary(); + origPt = mcParticle.pt(); + } + } + + assocHadrons( + assoc.collisionId(), + physicalPrimary, + assoc.globalIndex(), + origPt); + assocPID( + nSigmaTPCTOF[0], + nSigmaTPCTOF[1], + nSigmaTPCTOF[2], + nSigmaTPCTOF[3], + nSigmaTPCTOF[4], + nSigmaTPCTOF[5], + nSigmaTPCTOF[6], + nSigmaTPCTOF[7]); + return true; + } + + // cascadeselection in PbPb + template + bool CascadeSelectedPbPb(TCascade casc, float pvx, float pvy, float pvz) + { + // bachBaryonCosPA + if (casc.bachBaryonCosPA() < MorePbPbsystCuts.bachBaryonCosPA) + return false; + // bachBaryonDCAxyToPV + if (std::abs(casc.bachBaryonDCAxyToPV()) > MorePbPbsystCuts.bachBaryonDCAxyToPV) + return false; + // casccosPA + if (casc.casccosPA(pvx, pvy, pvz) < MorePbPbsystCuts.cascCospa) + return false; + // dcacascdaughters + float ptDepCut = MorePbPbsystCuts.dcaCacsDauPar0; + if (casc.pt() > 1 && casc.pt() < 4) + ptDepCut = MorePbPbsystCuts.dcaCacsDauPar1; + else if (casc.pt() > 4) + ptDepCut = MorePbPbsystCuts.dcaCacsDauPar2; + if (casc.dcacascdaughters() > ptDepCut) + return false; + // dcaV0daughters + if (casc.dcaV0daughters() > dcaV0dau) + return false; + // dcav0topv + if (std::abs(casc.dcav0topv(pvx, pvy, pvz)) < MorePbPbsystCuts.cascdcaV0ToPV) + return false; + // cascradius + if (casc.cascradius() < MorePbPbsystCuts.cascRadius) + return false; + // v0radius + if (casc.v0radius() < MorePbPbsystCuts.cascv0RadiusMin) + return false; + // v0cosPA + if (casc.v0cosPA(casc.x(), casc.y(), casc.z()) < MorePbPbsystCuts.cascv0cospa) + return false; + // lambdaMassWin + if (std::abs(casc.mLambda() - o2::constants::physics::MassLambda0) > MorePbPbsystCuts.lambdaMassWin) + return false; + return true; + } // for real data processing - void processTriggers(soa::Join::iterator const& collision, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) + void processTriggers(soa::Join::iterator const& collision, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) { // Perform basic event selection if (!collision.sel8()) { return; } // No need to correlate stuff that's in far collisions - if (TMath::Abs(collision.posZ()) > 10.0) { + if (std::abs(collision.posZ()) > 10.0) { return; } if (zorroMask.value != "") { @@ -252,18 +449,19 @@ struct hstrangecorrelationfilter { false, // if you decide to check real data for primaries, you'll have a hard time track.globalIndex(), 0); + triggerTrackExtra(1); } } // for MC processing - void processTriggersMC(soa::Join::iterator const& collision, soa::Filtered const& tracks, aod::McParticles const&, aod::BCsWithTimestamps const&) + void processTriggersMC(soa::Join::iterator const& collision, soa::Filtered const& tracks, aod::McParticles const&, aod::BCsWithTimestamps const&) { // Perform basic event selection if (!collision.sel8()) { return; } // No need to correlate stuff that's in far collisions - if (TMath::Abs(collision.posZ()) > 10.0) { + if (std::abs(collision.posZ()) > 10.0) { return; } if (zorroMask.value != "") { @@ -292,6 +490,7 @@ struct hstrangecorrelationfilter { physicalPrimary, track.globalIndex(), origPt); + triggerTrackExtra(1); } } @@ -302,7 +501,7 @@ struct hstrangecorrelationfilter { return; } // No need to correlate stuff that's in far collisions - if (TMath::Abs(collision.posZ()) > 10.0) { + if (std::abs(collision.posZ()) > 10.0) { return; } if (zorroMask.value != "") { @@ -317,66 +516,72 @@ struct hstrangecorrelationfilter { /// _________________________________________________ /// Step 1: Populate table with trigger tracks for (auto const& track : tracks) { - if (track.eta() > assocEtaMax || track.eta() < assocEtaMin) { + if (!isValidAssocTrack(track)) continue; + } + } + + void processAssocPionsMC(soa::Join::iterator const& collision, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) + { + // Perform basic event selection + if (!collision.sel8()) { + return; + } + // No need to correlate stuff that's in far collisions + if (std::abs(collision.posZ()) > 10.0) { + return; + } + if (zorroMask.value != "") { + auto bc = collision.bc_as(); + initCCDB(bc); + bool zorroSelected = zorro.isSelected(collision.bc_as().globalBC()); /// Just let Zorro do the accounting + if (!zorroSelected) { + return; } - // if (track.sign()= 1 ) {continue;} - if (track.pt() > assocPtCutMax || track.pt() < assocPtCutMin) { + } + + /// _________________________________________________ + /// Step 1: Populate table with trigger tracks + for (auto const& track : tracks) { + if (!isValidAssocTrack(track)) continue; + } + } + + void processAssocHadrons(soa::Join::iterator const& collision, soa::Filtered const& tracks, aod::BCsWithTimestamps const&) + { + // Perform basic event selection + if (!collision.sel8()) { + return; + } + // No need to correlate stuff that's in far collisions + if (std::abs(collision.posZ()) > 10.0) { + return; + } + if (zorroMask.value != "") { + auto bc = collision.bc_as(); + initCCDB(bc); + bool zorroSelected = zorro.isSelected(collision.bc_as().globalBC()); /// Just let Zorro do the accounting + if (!zorroSelected) { + return; } - if (track.tpcNClsCrossedRows() < minTPCNCrossedRows) { - continue; // crossed rows - } - if (!track.hasITS() && triggerRequireITS) { - continue; // skip, doesn't have ITS signal (skips lots of TPC-only!) - } - // prepared for Bayesian PID - // if (!track.bayesPi() > pionMinBayesProb) { - // continue; - // } - // if (track.bayesPi() < track.bayesPr() || track.bayesPi() < track.bayesKa()){ - // continue; - // } - // if (track.tpcNSigmaPi() < assocPionNSigmaTPCFOF){ - // continue; - // } - // if (track.tofSignal() > 0 && track.tofNSigmaPi() < assocPionNSigmaTPCFOF){ - // continue; - // } - if (track.tofSignal() > 0) { - if (std::sqrt(track.tofNSigmaPi() * track.tofNSigmaPi() + track.tpcNSigmaPi() * track.tpcNSigmaPi()) > assocPionNSigmaTPCFOF) - continue; - if (track.tofNSigmaPr() < rejectSigma) - continue; - if (track.tpcNSigmaPr() < rejectSigma) - continue; - if (track.tofNSigmaKa() < rejectSigma) - continue; - if (track.tpcNSigmaKa() < rejectSigma) - continue; - } else { - if (track.tpcNSigmaPi() > assocPionNSigmaTPCFOF) - continue; - if (track.tpcNSigmaPr() < rejectSigma) - continue; - if (track.tpcNSigmaKa() < rejectSigma) - continue; - } + } - assocHadrons( - track.collisionId(), - track.globalIndex()); + /// _________________________________________________ + /// Step 1: Populate table with trigger tracks + for (auto const& track : tracks) { + if (!isValidAssocTrack(track)) + continue; } } - - void processAssocHadrons(soa::Join::iterator const& collision, soa::Filtered> const& tracks, aod::BCsWithTimestamps const&) + void processAssocHadronsMC(soa::Join::iterator const& collision, soa::Filtered const& tracks, aod::McParticles const&, aod::BCsWithTimestamps const&) { // Perform basic event selection if (!collision.sel8()) { return; } // No need to correlate stuff that's in far collisions - if (TMath::Abs(collision.posZ()) > 10.0) { + if (std::abs(collision.posZ()) > 10.0) { return; } if (zorroMask.value != "") { @@ -391,34 +596,160 @@ struct hstrangecorrelationfilter { /// _________________________________________________ /// Step 1: Populate table with trigger tracks for (auto const& track : tracks) { - if (track.eta() > assocEtaMax || track.eta() < assocEtaMin) { + if (!isValidAssocTrack(track)) continue; + } + } + + void processV0s(soa::Join::iterator const& collision, DauTracks const&, soa::Filtered const& V0s, aod::BCsWithTimestamps const&) + { + double cent = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + // Perform basic event selection + if (!collision.sel8()) { + return; + } + // No need to correlate stuff that's in far collisions + if (std::abs(collision.posZ()) > 10.0) { + return; + } + if (zorroMask.value != "") { + auto bc = collision.bc_as(); + initCCDB(bc); + bool zorroSelected = zorro.isSelected(collision.bc_as().globalBC()); /// Just let Zorro do the accounting + if (!zorroSelected) { + return; } - // if (track.sign()= 1 ) {continue;} - if (track.pt() > assocPtCutMax || track.pt() < assocPtCutMin) { + } + if (!doPPAnalysis && !isCollisionSelectedPbPb(collision)) + return; + + /// _________________________________________________ + /// Populate table with associated V0s + for (auto const& v0 : V0s) { + if (v0.v0radius() < v0RadiusMin || v0.v0radius() > v0RadiusMax || v0.eta() > assocEtaMax || v0.eta() < assocEtaMin || v0.v0cosPA() < v0Cospa) { continue; } - if (track.tpcNClsCrossedRows() < minTPCNCrossedRows) { - continue; // crossed rows + if (v0.pt() > assocPtCutMax || v0.pt() < assocPtCutMin) { + continue; } - if (!track.hasITS() && triggerRequireITS) { - continue; // skip, doesn't have ITS signal (skips lots of TPC-only!) + // check dE/dx compatibility + int compatibleK0Short = 0; + int compatibleLambda = 0; + int compatibleAntiLambda = 0; + + auto posdau = v0.posTrack_as(); + auto negdau = v0.negTrack_as(); + + if (negdau.tpcNClsCrossedRows() < minTPCNCrossedRows) + continue; + if (posdau.tpcNClsCrossedRows() < minTPCNCrossedRows) + continue; + + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutK0S && + std::abs(v0.dcapostopv()) > dcapostopvK0S && std::abs(v0.dcanegtopv()) > dcanegtopvK0S && + v0.qtarm() * armPodCut > std::abs(v0.alpha()))) { + BIT_SET(compatibleK0Short, 0); + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigma) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutK0S && + std::abs(v0.dcapostopv()) > dcapostopvK0S && std::abs(v0.dcanegtopv()) > dcanegtopvK0S && + v0.qtarm() * armPodCut > std::abs(v0.alpha()))) { + BIT_SET(compatibleK0Short, 1); + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaTight) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutK0S && + std::abs(v0.dcapostopv()) > dcapostopvK0S && std::abs(v0.dcanegtopv()) > dcanegtopvK0S && + v0.qtarm() * armPodCut > std::abs(v0.alpha()))) { + BIT_SET(compatibleK0Short, 2); + } + } + if (std::abs(posdau.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvLambda && std::abs(v0.dcanegtopv()) > dcanegtopvLambda)) { + BIT_SET(compatibleLambda, 0); + } + } + } + if (std::abs(posdau.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigma) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvLambda && std::abs(v0.dcanegtopv()) > dcanegtopvLambda)) { + BIT_SET(compatibleLambda, 1); + } + } + } + if (std::abs(posdau.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaTight) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvLambda && std::abs(v0.dcanegtopv()) > dcanegtopvLambda)) { + BIT_SET(compatibleLambda, 2); + } + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(negdau.tpcNSigmaPr()) < strangedEdxNSigmaLoose) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvAntiLambda && std::abs(v0.dcanegtopv()) > dcanegtopvAntiLambda)) { + BIT_SET(compatibleAntiLambda, 0); + } + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(negdau.tpcNSigmaPr()) < strangedEdxNSigma) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvAntiLambda && std::abs(v0.dcanegtopv()) > dcanegtopvAntiLambda)) { + BIT_SET(compatibleAntiLambda, 1); + } + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(negdau.tpcNSigmaPr()) < strangedEdxNSigmaTight) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvAntiLambda && std::abs(v0.dcanegtopv()) > dcanegtopvAntiLambda)) { + BIT_SET(compatibleAntiLambda, 2); + } + } } - assocHadrons( - track.collisionId(), - track.globalIndex()); + // simplified handling: calculate NSigma in mass here + float massNSigmaK0Short = (v0.mK0Short() - fK0Mean->Eval(v0.pt())) / (fK0Width->Eval(v0.pt()) + 1e-6); + float massNSigmaLambda = (v0.mLambda() - fLambdaMean->Eval(v0.pt())) / (fLambdaWidth->Eval(v0.pt()) + 1e-6); + float massNSigmaAntiLambda = (v0.mAntiLambda() - fLambdaMean->Eval(v0.pt())) / (fLambdaWidth->Eval(v0.pt()) + 1e-6); + + if (compatibleK0Short) + histos.fill(HIST("h3dMassK0Short"), v0.pt(), v0.mK0Short(), cent); + if (compatibleLambda) + histos.fill(HIST("h3dMassLambda"), v0.pt(), v0.mLambda(), cent); + if (compatibleAntiLambda) + histos.fill(HIST("h3dMassAntiLambda"), v0.pt(), v0.mAntiLambda(), cent); + + if (!fillTableOnlyWithCompatible || + ( // start major condition check + (compatibleK0Short > 0 && std::abs(massNSigmaK0Short) < maxMassNSigma) || + (compatibleLambda > 0 && std::abs(massNSigmaLambda) < maxMassNSigma) || + (compatibleAntiLambda > 0 && std::abs(massNSigmaAntiLambda) < maxMassNSigma)) // end major condition check + ) { + assocV0(v0.collisionId(), v0.globalIndex(), + compatibleK0Short, compatibleLambda, compatibleAntiLambda, + false, false, false, false, + massNSigmaK0Short, massNSigmaLambda, massNSigmaAntiLambda); + } } } - void processV0s(soa::Join::iterator const& collision, DauTracks const&, soa::Filtered const& V0s, V0LinkedTagged const&, aod::BCsWithTimestamps const&) + void processV0sMC(soa::Join::iterator const& collision, DauTracksMC const&, soa::Filtered const& V0s, aod::McParticles const&, aod::BCsWithTimestamps const&) { + double cent = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); // Perform basic event selection if (!collision.sel8()) { return; } // No need to correlate stuff that's in far collisions - if (TMath::Abs(collision.posZ()) > 10.0) { + if (std::abs(collision.posZ()) > 10.0) { return; } if (zorroMask.value != "") { @@ -429,65 +760,121 @@ struct hstrangecorrelationfilter { return; } } - + if (!doPPAnalysis && !isCollisionSelectedPbPb(collision)) + return; /// _________________________________________________ /// Populate table with associated V0s for (auto const& v0 : V0s) { if (v0.v0radius() < v0RadiusMin || v0.v0radius() > v0RadiusMax || v0.eta() > assocEtaMax || v0.eta() < assocEtaMin || v0.v0cosPA() < v0Cospa) { continue; } + if (v0.pt() > assocPtCutMax || v0.pt() < assocPtCutMin) { + continue; + } // check dE/dx compatibility int compatibleK0Short = 0; int compatibleLambda = 0; int compatibleAntiLambda = 0; - auto posdau = v0.posTrack_as(); - auto negdau = v0.negTrack_as(); - auto origV0entry = v0.v0_as(); // retrieve tags + auto posdau = v0.posTrack_as(); + auto negdau = v0.negTrack_as(); if (negdau.tpcNClsCrossedRows() < minTPCNCrossedRows) continue; if (posdau.tpcNClsCrossedRows() < minTPCNCrossedRows) continue; - if (TMath::Abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose && TMath::Abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose) - bitset(compatibleK0Short, 0); - if (TMath::Abs(posdau.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(negdau.tpcNSigmaPi()) < strangedEdxNSigma) - bitset(compatibleK0Short, 1); - if (TMath::Abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaTight && TMath::Abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaTight) - bitset(compatibleK0Short, 2); - - if (TMath::Abs(posdau.tpcNSigmaPr()) < strangedEdxNSigmaLoose && TMath::Abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose) - if (v0.v0cosPA() > lambdaCospa) - bitset(compatibleLambda, 0); - if (TMath::Abs(posdau.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(negdau.tpcNSigmaPi()) < strangedEdxNSigma) - if (v0.v0cosPA() > lambdaCospa) - bitset(compatibleLambda, 1); - if (TMath::Abs(posdau.tpcNSigmaPr()) < strangedEdxNSigmaTight && TMath::Abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaTight) - if (v0.v0cosPA() > lambdaCospa) - bitset(compatibleLambda, 2); - - if (TMath::Abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose && TMath::Abs(negdau.tpcNSigmaPr()) < strangedEdxNSigmaLoose) - if (v0.v0cosPA() > lambdaCospa) - bitset(compatibleAntiLambda, 0); - if (TMath::Abs(posdau.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(negdau.tpcNSigmaPr()) < strangedEdxNSigma) - if (v0.v0cosPA() > lambdaCospa) - bitset(compatibleAntiLambda, 1); - if (TMath::Abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaTight && TMath::Abs(negdau.tpcNSigmaPr()) < strangedEdxNSigmaTight) - if (v0.v0cosPA() > lambdaCospa) - bitset(compatibleAntiLambda, 2); + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutK0S && + std::abs(v0.dcapostopv()) > dcapostopvK0S && std::abs(v0.dcanegtopv()) > dcanegtopvK0S && + v0.qtarm() * armPodCut > std::abs(v0.alpha()))) { + BIT_SET(compatibleK0Short, 0); + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigma) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutK0S && + std::abs(v0.dcapostopv()) > dcapostopvK0S && std::abs(v0.dcanegtopv()) > dcanegtopvK0S && + v0.qtarm() * armPodCut > std::abs(v0.alpha()))) { + BIT_SET(compatibleK0Short, 1); + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaTight) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutK0S && + std::abs(v0.dcapostopv()) > dcapostopvK0S && std::abs(v0.dcanegtopv()) > dcanegtopvK0S && + v0.qtarm() * armPodCut > std::abs(v0.alpha()))) { + BIT_SET(compatibleK0Short, 2); + } + } + if (std::abs(posdau.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvLambda && std::abs(v0.dcanegtopv()) > dcanegtopvLambda)) { + BIT_SET(compatibleLambda, 0); + } + } + } + if (std::abs(posdau.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigma) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvLambda && std::abs(v0.dcanegtopv()) > dcanegtopvLambda)) { + BIT_SET(compatibleLambda, 1); + } + } + } + if (std::abs(posdau.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(negdau.tpcNSigmaPi()) < strangedEdxNSigmaTight) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvLambda && std::abs(v0.dcanegtopv()) > dcanegtopvLambda)) { + BIT_SET(compatibleLambda, 2); + } + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(negdau.tpcNSigmaPr()) < strangedEdxNSigmaLoose) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvAntiLambda && std::abs(v0.dcanegtopv()) > dcanegtopvAntiLambda)) { + BIT_SET(compatibleAntiLambda, 0); + } + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(negdau.tpcNSigmaPr()) < strangedEdxNSigma) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvAntiLambda && std::abs(v0.dcanegtopv()) > dcanegtopvAntiLambda)) { + BIT_SET(compatibleAntiLambda, 1); + } + } + } + if (std::abs(posdau.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(negdau.tpcNSigmaPr()) < strangedEdxNSigmaTight) { + if (v0.v0cosPA() > lambdaCospa) { + if (doPPAnalysis || (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutLambda && + std::abs(v0.dcapostopv()) > dcapostopvAntiLambda && std::abs(v0.dcanegtopv()) > dcanegtopvAntiLambda)) { + BIT_SET(compatibleAntiLambda, 2); + } + } + } // simplified handling: calculate NSigma in mass here float massNSigmaK0Short = (v0.mK0Short() - fK0Mean->Eval(v0.pt())) / (fK0Width->Eval(v0.pt()) + 1e-6); float massNSigmaLambda = (v0.mLambda() - fLambdaMean->Eval(v0.pt())) / (fLambdaWidth->Eval(v0.pt()) + 1e-6); float massNSigmaAntiLambda = (v0.mAntiLambda() - fLambdaMean->Eval(v0.pt())) / (fLambdaWidth->Eval(v0.pt()) + 1e-6); - - if (compatibleK0Short && (!doTrueSelectionInMass || (origV0entry.isTrueK0Short() && origV0entry.isPhysicalPrimary()))) - histos.fill(HIST("h3dMassK0Short"), v0.pt(), v0.mK0Short(), collision.centFT0M()); - if (compatibleLambda && (!doTrueSelectionInMass || (origV0entry.isTrueLambda() && origV0entry.isPhysicalPrimary()))) - histos.fill(HIST("h3dMassLambda"), v0.pt(), v0.mLambda(), collision.centFT0M()); - if (compatibleAntiLambda && (!doTrueSelectionInMass || (origV0entry.isTrueAntiLambda() && origV0entry.isPhysicalPrimary()))) - histos.fill(HIST("h3dMassAntiLambda"), v0.pt(), v0.mAntiLambda(), collision.centFT0M()); + bool v0PhysicalPrimary = false; + bool trueK0Short = false; + bool trueLambda = false; + bool trueAntiLambda = false; + v0PhysicalPrimary = v0.isPhysicalPrimary(); + if (v0.pdgCode() == 310) + trueK0Short = true; + if (v0.pdgCode() == 3122) + trueLambda = true; + if (v0.pdgCode() == -3122) + trueAntiLambda = true; + if (compatibleK0Short && (!doTrueSelectionInMass || (trueK0Short && v0PhysicalPrimary))) + histos.fill(HIST("h3dMassK0Short"), v0.pt(), v0.mK0Short(), cent); + if (compatibleLambda && (!doTrueSelectionInMass || (trueLambda && v0PhysicalPrimary))) + histos.fill(HIST("h3dMassLambda"), v0.pt(), v0.mLambda(), cent); + if (compatibleAntiLambda && (!doTrueSelectionInMass || (trueAntiLambda && v0PhysicalPrimary))) + histos.fill(HIST("h3dMassAntiLambda"), v0.pt(), v0.mAntiLambda(), cent); if (!fillTableOnlyWithCompatible || ( // start major condition check @@ -497,19 +884,21 @@ struct hstrangecorrelationfilter { ) { assocV0(v0.collisionId(), v0.globalIndex(), compatibleK0Short, compatibleLambda, compatibleAntiLambda, - origV0entry.isTrueK0Short(), origV0entry.isTrueLambda(), origV0entry.isTrueAntiLambda(), origV0entry.isPhysicalPrimary(), + trueK0Short, trueLambda, trueAntiLambda, v0PhysicalPrimary, massNSigmaK0Short, massNSigmaLambda, massNSigmaAntiLambda); } } } - void processCascades(soa::Join::iterator const& collision, DauTracks const&, soa::Filtered const& /*V0s*/, soa::Filtered const& Cascades, aod::V0sLinked const&, CascadesLinkedTagged const&, aod::BCsWithTimestamps const&) + + void processCascades(soa::Join::iterator const& collision, DauTracks const&, soa::Filtered const& /*V0s*/, soa::Filtered const& Cascades, aod::BCsWithTimestamps const&) { + double cent = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); // Perform basic event selection if (!collision.sel8()) { return; } // No need to correlate stuff that's in far collisions - if (TMath::Abs(collision.posZ()) > 10.0) { + if (std::abs(collision.posZ()) > 10.0) { return; } if (zorroMask.value != "") { @@ -520,13 +909,20 @@ struct hstrangecorrelationfilter { return; } } + if (!doPPAnalysis && !isCollisionSelectedPbPb(collision)) + return; /// _________________________________________________ /// Step 3: Populate table with associated Cascades for (auto const& casc : Cascades) { + if (casc.eta() > assocEtaMax || casc.eta() < assocEtaMin) { + continue; + } + if (casc.pt() > assocPtCutMax || casc.pt() < assocPtCutMin) { + continue; + } auto bachTrackCast = casc.bachelor_as(); auto posTrackCast = casc.posTrack_as(); auto negTrackCast = casc.negTrack_as(); - auto origCascadeEntry = casc.cascade_as(); // minimum TPC crossed rows if (bachTrackCast.tpcNClsCrossedRows() < minTPCNCrossedRows) @@ -535,52 +931,117 @@ struct hstrangecorrelationfilter { continue; if (negTrackCast.tpcNClsCrossedRows() < minTPCNCrossedRows) continue; - + if (!doPPAnalysis && !CascadeSelectedPbPb(casc, collision.posX(), collision.posY(), collision.posZ())) + continue; // check dE/dx compatibility int compatibleXiMinus = 0; int compatibleXiPlus = 0; int compatibleOmegaMinus = 0; int compatibleOmegaPlus = 0; + float cascpos = std::hypot(casc.x() - collision.posX(), casc.y() - collision.posY(), casc.z() - collision.posZ()); + float cascptotmom = std::hypot(casc.px(), casc.py(), casc.pz()); + float ctauXi = o2::constants::physics::MassXiMinus * cascpos / ((cascptotmom + 1e-13) * ctauxiPDG); + float ctauOmega = o2::constants::physics::MassOmegaMinus * cascpos / ((cascptotmom + 1e-13) * ctauomegaPDG); + + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiMinus, 0); + } + } + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiMinus, 1); + } + } + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiMinus, 2); + } + } - if (TMath::Abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && TMath::Abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && TMath::Abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && casc.sign() < 0) - bitset(compatibleXiMinus, 0); - if (TMath::Abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && casc.sign() < 0) - bitset(compatibleXiMinus, 1); - if (TMath::Abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && TMath::Abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && TMath::Abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && casc.sign() < 0) - bitset(compatibleXiMinus, 2); - - if (TMath::Abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && TMath::Abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && TMath::Abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && casc.sign() > 0) - bitset(compatibleXiPlus, 0); - if (TMath::Abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && casc.sign() > 0) - bitset(compatibleXiPlus, 1); - if (TMath::Abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && TMath::Abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && TMath::Abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && casc.sign() > 0) - bitset(compatibleXiPlus, 2); - - if (TMath::Abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && TMath::Abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && TMath::Abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaLoose && casc.sign() < 0) - bitset(compatibleOmegaMinus, 0); - if (TMath::Abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigma && casc.sign() < 0) - bitset(compatibleOmegaMinus, 1); - if (TMath::Abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && TMath::Abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && TMath::Abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaTight && casc.sign() < 0) - bitset(compatibleOmegaMinus, 2); - - if (TMath::Abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && TMath::Abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && TMath::Abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaLoose && casc.sign() > 0) - bitset(compatibleOmegaPlus, 0); - if (TMath::Abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigma && casc.sign() > 0) - bitset(compatibleOmegaPlus, 1); - if (TMath::Abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && TMath::Abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && TMath::Abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaTight && casc.sign() > 0) - bitset(compatibleOmegaPlus, 2); + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiPlus, 0); + } + } + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiPlus, 1); + } + } + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiPlus, 2); + } + } + + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaLoose && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaMinus, 0); + } + } + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigma && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaMinus, 1); + } + } + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaTight && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaMinus, 2); + } + } + + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaLoose && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaMesonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaBaryonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaPlus, 0); + } + } + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigma && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaMesonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaBaryonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaPlus, 1); + } + } + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaTight && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaMesonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaBaryonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaPlus, 2); + } + } float massNSigmaXi = (casc.mXi() - fXiMean->Eval(casc.pt())) / (fXiWidth->Eval(casc.pt()) + 1e-6); float massNSigmaOmega = (casc.mOmega() - fOmegaMean->Eval(casc.pt())) / (fOmegaWidth->Eval(casc.pt()) + 1e-6); - if (compatibleXiMinus && (!doTrueSelectionInMass || (origCascadeEntry.isTrueXiMinus() && origCascadeEntry.isPhysicalPrimary()))) - histos.fill(HIST("h3dMassXiMinus"), casc.pt(), casc.mXi(), collision.centFT0M()); - if (compatibleXiPlus && (!doTrueSelectionInMass || (origCascadeEntry.isTrueXiPlus() && origCascadeEntry.isPhysicalPrimary()))) - histos.fill(HIST("h3dMassXiPlus"), casc.pt(), casc.mXi(), collision.centFT0M()); - if (compatibleOmegaMinus && (!doTrueSelectionInMass || (origCascadeEntry.isTrueOmegaMinus() && origCascadeEntry.isPhysicalPrimary()))) - histos.fill(HIST("h3dMassOmegaMinus"), casc.pt(), casc.mOmega(), collision.centFT0M()); - if (compatibleOmegaPlus && (!doTrueSelectionInMass || (origCascadeEntry.isTrueOmegaPlus() && origCascadeEntry.isPhysicalPrimary()))) - histos.fill(HIST("h3dMassOmegaPlus"), casc.pt(), casc.mOmega(), collision.centFT0M()); + if (compatibleXiMinus) + histos.fill(HIST("h3dMassXiMinus"), casc.pt(), casc.mXi(), cent); + if (compatibleXiPlus) + histos.fill(HIST("h3dMassXiPlus"), casc.pt(), casc.mXi(), cent); + if (compatibleOmegaMinus) + histos.fill(HIST("h3dMassOmegaMinus"), casc.pt(), casc.mOmega(), cent); + if (compatibleOmegaPlus) + histos.fill(HIST("h3dMassOmegaPlus"), casc.pt(), casc.mOmega(), cent); if (!fillTableOnlyWithCompatible || ( // start major condition check @@ -589,24 +1050,207 @@ struct hstrangecorrelationfilter { ) { assocCascades(casc.collisionId(), casc.globalIndex(), compatibleXiMinus, compatibleXiPlus, compatibleOmegaMinus, compatibleOmegaPlus, - origCascadeEntry.isTrueXiMinus(), origCascadeEntry.isTrueXiPlus(), - origCascadeEntry.isTrueOmegaMinus(), origCascadeEntry.isTrueOmegaPlus(), - origCascadeEntry.isPhysicalPrimary(), + false, false, false, false, false, massNSigmaXi, massNSigmaOmega); } } } - PROCESS_SWITCH(hstrangecorrelationfilter, processTriggers, "Produce trigger tables", true); - PROCESS_SWITCH(hstrangecorrelationfilter, processTriggersMC, "Produce trigger tables for MC", false); - PROCESS_SWITCH(hstrangecorrelationfilter, processV0s, "Produce associated V0 tables", true); - PROCESS_SWITCH(hstrangecorrelationfilter, processAssocPions, "Produce associated Pion tables", true); - PROCESS_SWITCH(hstrangecorrelationfilter, processCascades, "Produce associated cascade tables", true); - PROCESS_SWITCH(hstrangecorrelationfilter, processAssocHadrons, "Produce associated Hadron tables", true); + void processCascadesMC(soa::Join::iterator const& collision, DauTracks const&, soa::Filtered const& /*V0s*/, soa::Filtered const& Cascades, aod::McParticles const&, aod::BCsWithTimestamps const&) + { + double cent = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + // Perform basic event selection + if (!collision.sel8()) { + return; + } + // No need to correlate stuff that's in far collisions + if (std::abs(collision.posZ()) > 10.0) { + return; + } + if (zorroMask.value != "") { + auto bc = collision.bc_as(); + initCCDB(bc); + bool zorroSelected = zorro.isSelected(collision.bc_as().globalBC()); /// Just let Zorro do the accounting + if (!zorroSelected) { + return; + } + } + if (!doPPAnalysis && !isCollisionSelectedPbPb(collision)) + return; + /// _________________________________________________ + /// Step 3: Populate table with associated Cascades + for (auto const& casc : Cascades) { + if (casc.eta() > assocEtaMax || casc.eta() < assocEtaMin) { + continue; + } + if (casc.pt() > assocPtCutMax || casc.pt() < assocPtCutMin) { + continue; + } + auto bachTrackCast = casc.bachelor_as(); + auto posTrackCast = casc.posTrack_as(); + auto negTrackCast = casc.negTrack_as(); + + // minimum TPC crossed rows + if (bachTrackCast.tpcNClsCrossedRows() < minTPCNCrossedRows) + continue; + if (posTrackCast.tpcNClsCrossedRows() < minTPCNCrossedRows) + continue; + if (negTrackCast.tpcNClsCrossedRows() < minTPCNCrossedRows) + continue; + if (!doPPAnalysis && !CascadeSelectedPbPb(casc, collision.posX(), collision.posY(), collision.posZ())) + continue; + + // check dE/dx compatibility + int compatibleXiMinus = 0; + int compatibleXiPlus = 0; + int compatibleOmegaMinus = 0; + int compatibleOmegaPlus = 0; + float cascpos = std::hypot(casc.x() - collision.posX(), casc.y() - collision.posY(), casc.z() - collision.posZ()); + float cascptotmom = std::hypot(casc.px(), casc.py(), casc.pz()); + float ctauXi = o2::constants::physics::MassXiMinus * cascpos / ((cascptotmom + 1e-13) * ctauxiPDG); + float ctauOmega = o2::constants::physics::MassOmegaMinus * cascpos / ((cascptotmom + 1e-13) * ctauomegaPDG); + + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiMinus, 0); + } + } + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiMinus, 1); + } + } + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiMinus, 2); + } + } + + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiPlus, 0); + } + } + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiPlus, 1); + } + } + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > MorePbPbsystCuts.rejcomp && + ctauXi < MorePbPbsystCuts.proplifetime && std::abs(casc.yXi()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleXiPlus, 2); + } + } + + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaLoose && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaMinus, 0); + } + } + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigma && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaMinus, 1); + } + } + if (std::abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaTight && casc.sign() < 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaMesonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaMinus, 2); + } + } + + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaLoose && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaLoose && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaLoose && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaMesonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaBaryonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaPlus, 0); + } + } + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigma && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaMesonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaBaryonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaPlus, 1); + } + } + if (std::abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigmaTight && std::abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigmaTight && std::abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigmaTight && casc.sign() > 0) { + if (doPPAnalysis || (std::abs(casc.dcabachtopv()) > MorePbPbsystCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > MorePbPbsystCuts.dcaMesonToPV && + std::abs(casc.dcanegtopv()) > MorePbPbsystCuts.dcaBaryonToPV && std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > MorePbPbsystCuts.rejcomp && + ctauOmega < MorePbPbsystCuts.proplifetime && std::abs(casc.yOmega()) < MorePbPbsystCuts.rapCut)) { + BIT_SET(compatibleOmegaPlus, 2); + } + } + + float massNSigmaXi = (casc.mXi() - fXiMean->Eval(casc.pt())) / (fXiWidth->Eval(casc.pt()) + 1e-6); + float massNSigmaOmega = (casc.mOmega() - fOmegaMean->Eval(casc.pt())) / (fOmegaWidth->Eval(casc.pt()) + 1e-6); + bool cascPhysicalPrimary = false; + bool trueXiMinus = false; + bool trueXiPlus = false; + bool trueOmegaMinus = false; + bool trueOmegaPlus = false; + cascPhysicalPrimary = casc.isPhysicalPrimary(); + if (casc.pdgCode() == 3312) + trueXiMinus = true; + if (casc.pdgCode() == -3312) + trueXiPlus = true; + if (casc.pdgCode() == 3334) + trueOmegaMinus = true; + if (casc.pdgCode() == -3334) + trueOmegaPlus = true; + if (compatibleXiMinus && (!doTrueSelectionInMass || (trueXiMinus && cascPhysicalPrimary))) + histos.fill(HIST("h3dMassXiMinus"), casc.pt(), casc.mXi(), cent); + if (compatibleXiPlus && (!doTrueSelectionInMass || (trueXiPlus && cascPhysicalPrimary))) + histos.fill(HIST("h3dMassXiPlus"), casc.pt(), casc.mXi(), cent); + if (compatibleOmegaMinus && (!doTrueSelectionInMass || (trueOmegaMinus && cascPhysicalPrimary))) + histos.fill(HIST("h3dMassOmegaMinus"), casc.pt(), casc.mOmega(), cent); + if (compatibleOmegaPlus && (!doTrueSelectionInMass || (trueOmegaPlus && cascPhysicalPrimary))) + histos.fill(HIST("h3dMassOmegaPlus"), casc.pt(), casc.mOmega(), cent); + + if (!fillTableOnlyWithCompatible || + ( // start major condition check + ((compatibleXiMinus > 0 || compatibleXiPlus > 0) && std::abs(massNSigmaXi) < maxMassNSigma) || + ((compatibleOmegaMinus > 0 || compatibleOmegaPlus > 0) && std::abs(massNSigmaOmega) < maxMassNSigma)) // end major condition check + ) { + assocCascades(casc.collisionId(), casc.globalIndex(), + compatibleXiMinus, compatibleXiPlus, compatibleOmegaMinus, compatibleOmegaPlus, + trueXiMinus, trueXiPlus, + trueOmegaMinus, trueOmegaPlus, + cascPhysicalPrimary, + massNSigmaXi, massNSigmaOmega); + } + } + } + PROCESS_SWITCH(HStrangeCorrelationFilter, processTriggers, "Produce trigger tables", true); + PROCESS_SWITCH(HStrangeCorrelationFilter, processTriggersMC, "Produce trigger tables for MC", false); + PROCESS_SWITCH(HStrangeCorrelationFilter, processV0s, "Produce associated V0 tables", true); + PROCESS_SWITCH(HStrangeCorrelationFilter, processV0sMC, "Produce associated V0 tables for MC", false); + PROCESS_SWITCH(HStrangeCorrelationFilter, processAssocPions, "Produce associated Pion tables", false); + PROCESS_SWITCH(HStrangeCorrelationFilter, processAssocPionsMC, "Produce associated Pion tables for MC", false); + PROCESS_SWITCH(HStrangeCorrelationFilter, processCascades, "Produce associated cascade tables", true); + PROCESS_SWITCH(HStrangeCorrelationFilter, processCascadesMC, "Produce associated cascade tables for MC", false); + PROCESS_SWITCH(HStrangeCorrelationFilter, processAssocHadrons, "Produce associated Hadron tables", true); + PROCESS_SWITCH(HStrangeCorrelationFilter, processAssocHadronsMC, "Produce associated Hadron tables for MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Strangeness/lambdaJetpolarizationbuilder.cxx b/PWGLF/TableProducer/Strangeness/lambdaJetpolarizationbuilder.cxx new file mode 100644 index 00000000000..cc21c8def05 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/lambdaJetpolarizationbuilder.cxx @@ -0,0 +1,688 @@ +// 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 +#include +#include "PWGLF/DataModel/lambdaJetpolarization.h" + +using std::cout; +using std::endl; +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct myAnalysis { + Produces myTable; + Produces myTableanti; + Produces myTableJet; + Produces outputCollisions; + Produces outputCollisionsV0; + Produces myTableLeadingJet; + + 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 cfgVtxCut{"cfgVtxCut", 10.0, "V_z cut selection"}; + Configurable cfgjetPtMin{"cfgjetPtMin", 0.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 minTpcNcrossedRowsOverFindable{"minTpcNcrossedRowsOverFindable", 0.8, "crossed rows/findable"}; + Configurable etaMin{"etaMin", -0.8f, "eta min track"}; + Configurable etaMax{"etaMax", +0.8f, "eta max track"}; + Configurable minimumV0Radius{"minimumV0Radius", 0.2f, "Minimum 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 Lambda"}; + Configurable v0rejK0s{"v0rejK0s", 0.075, "V0 rej K0s"}; + Configurable CtauLambda{"ctauLambda", 30, "C tau Lambda (cm)"}; + Configurable ifpasslambda{"passedLambdaSelection", 1, "passedLambdaSelection"}; + Configurable ifpassantilambda{"passedAntiLambdaSelection", 1, "passedAntiLambdaSelection"}; + Configurable ifinitpasslambda{"ifinitpasslambda", 0, "ifinitpasslambda"}; + // 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"}; + Configurable doArmenterosCut{"doArmenterosCut", 1, "do Armenteros Cut"}; + Configurable paramArmenterosCut{"paramArmenterosCut", 0.2, "parameter Armenteros Cut"}; + Configurable doDrawPicture{"doDrawPicture", 0, "do Draw Picture"}; + // CONFIG DONE + ///////////////////////////////////////// //INIT//////////////////////////////////////////////////////////////////// + // int eventSelection = -1; + int trackSelection = -1; + std::vector eventSelectionBits; + 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("EventIndexselection", "EventIndexselection", {HistType::kTH1F, {{1000000, 0.5f, 1000000.5f}}}); + } + JEhistos.add("hKaonplusCounts", "hKaonplusCounts", {HistType::kTH1F, {{1, -0.5, 0.5f}}}); + JEhistos.add("hKaonminusCounts", "hKaonminusCounts", {HistType::kTH1F, {{1, -0.5, 0.5f}}}); + + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(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 ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < minTpcNcrossedRowsOverFindable) + return false; + if (track.tpcChi2NCl() > maxChi2TPC) + return false; + if (track.itsChi2NCl() > maxChi2ITS) + return false; + if (track.eta() < etaMin || track.eta() > etaMax) + return false; + if (requireTOF && (!track.hasTOF())) + return false; + return true; + } + + // init Selection + template + bool passedInitLambdaSelection(const Lambda& v0, const TrackPos& ptrack, const TrackNeg& ntrack) + { + if (v0.v0radius() < minimumV0Radius || v0.v0cosPA() < v0cospa || + TMath::Abs(ptrack.eta()) > etaMax || + TMath::Abs(ntrack.eta()) > etaMax) { + return false; + } + if (v0.dcaV0daughters() > dcav0dau) { + return false; + } + + if (TMath::Abs(v0.dcanegtopv()) < dcanegtopv) { + return false; + } + + if (TMath::Abs(v0.dcapostopv()) < dcapostopv) { + return false; + } + return true; + } + + // Lambda Selections + template + bool passedLambdaSelection(const Lambda& v0, const TrackPos& ptrack, const TrackNeg& ntrack) + { + + if (ptrack.tpcNSigmaKa() > nsigmaTPCmin && ptrack.tpcNSigmaKa() < nsigmaTPCmax) { + JEhistos.fill(HIST("hKaonplusCounts"), 1); + } + + if (ntrack.tpcNSigmaKa() > nsigmaTPCmin && ntrack.tpcNSigmaKa() < nsigmaTPCmax) { + JEhistos.fill(HIST("hKaonminusCounts"), 1); + } + + // 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 nEventsJet = 0; + void processJetTracks(aod::JetCollision const& collision, soa::Filtered> const& chargedjets, soa::Join const& tracks, TrackCandidates const&) + { + + registry.fill(HIST("hNEventsJet"), 0.5); + if (fabs(collision.posZ()) > cfgVtxCut) { + + return; + } + registry.fill(HIST("hNEventsJet"), 1.5); + + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + registry.fill(HIST("hNEventsJet"), 2.5); + outputCollisions(collision.posZ()); + + for (auto const& track : tracks) { + + auto originalTrack = track.track_as>(); + if (doDrawPicture) { + 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; + } + if (doDrawPicture) { + JEhistos.fill(HIST("ptHistogram"), track.pt()); + JEhistos.fill(HIST("etaHistogram"), track.eta()); + JEhistos.fill(HIST("phiHistogram"), track.phi()); + } + } + int nJets = 0; + int lastindex = 0; + int collisionId = 0; + float maxJetpx = 0; + float maxJetpy = 0; + float maxJetpz = 0; + float maxJetpT = 0; + float maxJetPt = -999; + nEventsJet++; + for (const 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(outputCollisions.lastIndex(), chargedjet.collisionId(), chargedjet.px(), chargedjet.py(), chargedjet.pz(), chargedjet.pt()); + + nJets++; + if (chargedjet.pt() > maxJetPt) { + maxJetpx = chargedjet.px(); + maxJetpy = chargedjet.py(); + maxJetpz = chargedjet.pz(); + maxJetpT = chargedjet.pt(); + collisionId = chargedjet.collisionId(); + lastindex = outputCollisions.lastIndex(); + maxJetPt = maxJetpT; + } + } + if (maxJetpT > 0) { + myTableLeadingJet(lastindex, collisionId, maxJetpx, maxJetpy, maxJetpz, maxJetpT); + } + 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; + outputCollisionsV0(collision.posX()); + 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 && ifpasslambda) { + if (doDrawPicture) { + 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()); + } + } else if (passedInitLambdaSelection(v0, pos, neg) && ifinitpasslambda) { + if (doDrawPicture) { + 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 && ifpasslambda) { + + V0LambdaNumbers = V0LambdaNumbers + 1; + JEhistos.fill(HIST("hMassVsPtLambda"), v0.pt(), v0.mLambda()); + JEhistos.fill(HIST("hMassLambda"), v0.mLambda()); + + if (doDrawPicture) { + 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(outputCollisionsV0.lastIndex(), v0.collisionId(), v0.px(), v0.py(), v0.pz(), v0.pt(), v0.mLambda(), pos.px(), pos.py(), pos.pz()); + } else if (passedInitLambdaSelection(v0, pos, neg) && ifinitpasslambda) { + V0LambdaNumbers = V0LambdaNumbers + 1; + JEhistos.fill(HIST("hMassVsPtLambda"), v0.pt(), v0.mLambda()); + JEhistos.fill(HIST("hMassLambda"), v0.mLambda()); + if (doDrawPicture) { + 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(outputCollisionsV0.lastIndex(), v0.collisionId(), v0.px(), v0.py(), v0.pz(), v0.pt(), v0.mLambda(), pos.px(), pos.py(), pos.pz()); + } + if (passedAntiLambdaSelection(v0, pos, neg) && ifpassantilambda) { + JEhistos.fill(HIST("hMassVsPtAntiLambda"), v0.pt(), v0.mAntiLambda()); + JEhistos.fill(HIST("hMassAntiLambda"), v0.mAntiLambda()); + + if (doDrawPicture) { + 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()); + } + myTableanti(outputCollisionsV0.lastIndex(), v0.collisionId(), v0.px(), v0.py(), v0.pz(), v0.pt(), v0.mAntiLambda(), neg.px(), neg.py(), neg.pz()); + } else if (passedInitLambdaSelection(v0, pos, neg) && ifinitpasslambda) { + JEhistos.fill(HIST("hMassVsPtAntiLambda"), v0.pt(), v0.mAntiLambda()); + JEhistos.fill(HIST("hMassAntiLambda"), v0.mAntiLambda()); + + if (doDrawPicture) { + 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()); + } + myTableanti(outputCollisionsV0.lastIndex(), v0.collisionId(), v0.px(), v0.py(), v0.pz(), v0.pt(), v0.mAntiLambda(), neg.px(), neg.py(), neg.pz()); + } + } + JEhistos.fill(HIST("V0Counts"), V0NumbersPerEvent); + } + PROCESS_SWITCH(myAnalysis, processV0, "processV0", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGLF/TableProducer/Strangeness/lambdakzerobuilder.cxx b/PWGLF/TableProducer/Strangeness/lambdakzerobuilder.cxx index 7097705f7a1..7b898bfa98e 100644 --- a/PWGLF/TableProducer/Strangeness/lambdakzerobuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/lambdakzerobuilder.cxx @@ -838,7 +838,7 @@ struct lambdakzeroBuilder { statisticsRegistry.v0statsUnassociated[kV0TPCrefit]++; // Calculate DCA with respect to the collision associated to the V0, not individual tracks - gpu::gpustd::array dcaInfo; + std::array dcaInfo; auto posTrackPar = getTrackPar(posTrack); o2::base::Propagator::Instance()->propagateToDCABxByBz({primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, posTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo); @@ -1217,7 +1217,7 @@ struct lambdakzeroBuilder { if (createV0PosAtDCAs) v0dauPositions(v0candidate.posPosition[0], v0candidate.posPosition[1], v0candidate.posPosition[2], v0candidate.negPosition[0], v0candidate.negPosition[1], v0candidate.negPosition[2]); - if (createV0PosAtDCAs) { + if (createV0PosAtIUs) { std::array posPositionIU; std::array negPositionIU; lPositiveTrackIU.getXYZGlo(posPositionIU); @@ -1380,6 +1380,9 @@ struct lambdakzeroPreselector { Configurable forceITSOnlyMesons{"forceITSOnlyMesons", false, "force meson-like daughters to be ITS-only to pass Lambda/AntiLambda selections (yes/no)"}; Configurable minITSCluITSOnly{"minITSCluITSOnly", 0, "minimum number of ITS clusters to ask for if daughter track does not have TPC"}; + // qa coll assoc directly from AO2D (MC mode exclusive) + Configurable qaCollisionAssociation{"qaCollisionAssociation", false, "QA collision association"}; + // for bit-packed maps std::vector selectionMask; enum v0bit { bitInteresting = 0, @@ -1419,6 +1422,30 @@ struct lambdakzeroPreselector { h->GetXaxis()->SetBinLabel(4, "dEdx OK"); h->GetXaxis()->SetBinLabel(5, "Used in Casc"); h->GetXaxis()->SetBinLabel(6, "Used in Tra-Casc"); + + if (qaCollisionAssociation) { + auto hCollAssocQA = histos.add("hCollAssocQA", "hCollAssocQA", kTH2D, {{6, -0.5f, 5.5f}, {2, -0.5f, 1.5f}}); + hCollAssocQA->GetXaxis()->SetBinLabel(1, "K0"); + hCollAssocQA->GetXaxis()->SetBinLabel(2, "Lambda"); + hCollAssocQA->GetXaxis()->SetBinLabel(3, "AntiLambda"); + hCollAssocQA->GetXaxis()->SetBinLabel(4, "Gamma"); + hCollAssocQA->GetYaxis()->SetBinLabel(1, "Wrong collision"); + hCollAssocQA->GetYaxis()->SetBinLabel(2, "Correct collision"); + + auto h2dPtVsCollAssocK0Short = histos.add("h2dPtVsCollAssocK0Short", "h2dPtVsCollAssocK0Short", kTH2D, {{100, 0.0f, 10.0f}, {2, -0.5f, 1.5f}}); + auto h2dPtVsCollAssocLambda = histos.add("h2dPtVsCollAssocLambda", "h2dPtVsCollAssocLambda", kTH2D, {{100, 0.0f, 10.0f}, {2, -0.5f, 1.5f}}); + auto h2dPtVsCollAssocAntiLambda = histos.add("h2dPtVsCollAssocAntiLambda", "h2dPtVsCollAssocAntiLambda", kTH2D, {{100, 0.0f, 10.0f}, {2, -0.5f, 1.5f}}); + auto h2dPtVsCollAssocGamma = histos.add("h2dPtVsCollAssocGamma", "h2dPtVsCollAssocGamma", kTH2D, {{100, 0.0f, 10.0f}, {2, -0.5f, 1.5f}}); + + h2dPtVsCollAssocK0Short->GetYaxis()->SetBinLabel(1, "Wrong collision"); + h2dPtVsCollAssocK0Short->GetYaxis()->SetBinLabel(2, "Correct collision"); + h2dPtVsCollAssocLambda->GetYaxis()->SetBinLabel(1, "Wrong collision"); + h2dPtVsCollAssocLambda->GetYaxis()->SetBinLabel(2, "Correct collision"); + h2dPtVsCollAssocAntiLambda->GetYaxis()->SetBinLabel(1, "Wrong collision"); + h2dPtVsCollAssocAntiLambda->GetYaxis()->SetBinLabel(2, "Correct collision"); + h2dPtVsCollAssocGamma->GetYaxis()->SetBinLabel(1, "Wrong collision"); + h2dPtVsCollAssocGamma->GetYaxis()->SetBinLabel(2, "Correct collision"); + } } //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* @@ -1467,9 +1494,11 @@ struct lambdakzeroPreselector { //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* /// function to check PDG association template - void checkPDG(TV0Object const& lV0Candidate, uint32_t& maskElement) + void checkPDG(TV0Object const& lV0Candidate, uint32_t& maskElement, int mcCollisionId) { int lPDG = -1; + int correctMcCollisionIndex = -1; + float mcpt = -1.0; bool physicalPrimary = false; auto lNegTrack = lV0Candidate.template negTrack_as(); auto lPosTrack = lV0Candidate.template posTrack_as(); @@ -1484,7 +1513,9 @@ struct lambdakzeroPreselector { for (auto& lPosMother : lMCPosTrack.template mothers_as()) { if (lNegMother.globalIndex() == lPosMother.globalIndex() && (!dIfMCselectPhysicalPrimary || lNegMother.isPhysicalPrimary())) { lPDG = lNegMother.pdgCode(); + correctMcCollisionIndex = lNegMother.mcCollisionId(); physicalPrimary = lNegMother.isPhysicalPrimary(); + mcpt = lNegMother.pt(); // additionally check PDG of the mother particle if requested if (dIfMCselectV0MotherPDG != 0) { @@ -1502,14 +1533,40 @@ struct lambdakzeroPreselector { } } } // end association check - if (lPDG == 310) + + bool collisionAssociationOK = false; + if (correctMcCollisionIndex > -1 && correctMcCollisionIndex == mcCollisionId) { + collisionAssociationOK = true; + } + + if (lPDG == 310) { bitset(maskElement, bitTrueK0Short); - if (lPDG == 3122) + if (qaCollisionAssociation) { + histos.fill(HIST("hCollAssocQA"), 0.0f, collisionAssociationOK); + histos.fill(HIST("h2dPtVsCollAssocK0Short"), mcpt, collisionAssociationOK); + } + } + if (lPDG == 3122) { bitset(maskElement, bitTrueLambda); - if (lPDG == -3122) + if (qaCollisionAssociation) { + histos.fill(HIST("hCollAssocQA"), 1.0f, collisionAssociationOK); + histos.fill(HIST("h2dPtVsCollAssocLambda"), mcpt, collisionAssociationOK); + } + } + if (lPDG == -3122) { bitset(maskElement, bitTrueAntiLambda); - if (lPDG == 22) + if (qaCollisionAssociation) { + histos.fill(HIST("hCollAssocQA"), 2.0f, collisionAssociationOK); + histos.fill(HIST("h2dPtVsCollAssocAntiLambda"), mcpt, collisionAssociationOK); + } + } + if (lPDG == 22) { bitset(maskElement, bitTrueGamma); + if (qaCollisionAssociation) { + histos.fill(HIST("hCollAssocQA"), 3.0f, collisionAssociationOK); + histos.fill(HIST("h2dPtVsCollAssocGamma"), mcpt, collisionAssociationOK); + } + } if (lPDG == 1010010030) bitset(maskElement, bitTrueHypertriton); if (lPDG == -1010010030) @@ -1622,11 +1679,12 @@ struct lambdakzeroPreselector { checkAndFinalize(); } //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - void processBuildMCAssociated(aod::Collisions const& /*collisions*/, aod::V0s const& v0table, LabeledTracksExtra const&, aod::McParticles const& /*particlesMC*/) + void processBuildMCAssociated(soa::Join const& /*collisions*/, aod::V0s const& v0table, LabeledTracksExtra const&, aod::McParticles const& /*particlesMC*/) { initializeMasks(v0table.size()); for (auto const& v0 : v0table) { - checkPDG(v0, selectionMask[v0.globalIndex()]); + auto collision = v0.collision_as>(); + checkPDG(v0, selectionMask[v0.globalIndex()], collision.mcCollisionId()); checkTrackQuality(v0, selectionMask[v0.globalIndex()], true); } if (!doprocessSkipV0sNotUsedInCascades && !doprocessSkipV0sNotUsedInTrackedCascades) @@ -1644,11 +1702,12 @@ struct lambdakzeroPreselector { checkAndFinalize(); } //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - void processBuildValiddEdxMCAssociated(aod::Collisions const& /*collisions*/, aod::V0s const& v0table, TracksExtraWithPIDandLabels const&, aod::McParticles const&) + void processBuildValiddEdxMCAssociated(soa::Join const& /*collisions*/, aod::V0s const& v0table, TracksExtraWithPIDandLabels const&, aod::McParticles const&) { initializeMasks(v0table.size()); for (auto const& v0 : v0table) { - checkPDG(v0, selectionMask[v0.globalIndex()]); + auto collision = v0.collision_as>(); + checkPDG(v0, selectionMask[v0.globalIndex()], collision.mcCollisionId()); checkdEdx(v0, selectionMask[v0.globalIndex()]); checkTrackQuality(v0, selectionMask[v0.globalIndex()]); } @@ -1749,18 +1808,10 @@ struct lambdakzeroV0DataLinkBuilder { PROCESS_SWITCH(lambdakzeroV0DataLinkBuilder, processFindable, "process findable V0s", false); }; -// Extends the v0data table with expression columns -struct lambdakzeroInitializer { - Spawns v0cores; - Spawns v0fccores; - void init(InitContext const&) {} -}; - WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Strangeness/lambdakzerofinder.cxx b/PWGLF/TableProducer/Strangeness/lambdakzerofinder.cxx index 60d331ea61d..e75c72c77f4 100644 --- a/PWGLF/TableProducer/Strangeness/lambdakzerofinder.cxx +++ b/PWGLF/TableProducer/Strangeness/lambdakzerofinder.cxx @@ -429,17 +429,10 @@ struct lambdakzerofinderQa { PROCESS_SWITCH(lambdakzerofinderQa, processRun2, "Process Run 2 data", false); }; -/// Extends the v0data table with expression columns -struct lambdakzeroinitializer { - Spawns v0cores; - void init(InitContext const&) {} -}; - WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ adaptAnalysisTask(cfgc, TaskName{"lf-lambdakzeroprefilter"}), adaptAnalysisTask(cfgc, TaskName{"lf-lambdakzerofinder"}), - adaptAnalysisTask(cfgc, TaskName{"lf-lambdakzerofinderQA"}), - adaptAnalysisTask(cfgc, TaskName{"lf-lambdakzeroinitializer"})}; + adaptAnalysisTask(cfgc, TaskName{"lf-lambdakzerofinderQA"})}; } diff --git a/PWGLF/TableProducer/Strangeness/lambdakzerospawner.cxx b/PWGLF/TableProducer/Strangeness/lambdakzerospawner.cxx index 7ec0b4cc010..19c174aef7f 100644 --- a/PWGLF/TableProducer/Strangeness/lambdakzerospawner.cxx +++ b/PWGLF/TableProducer/Strangeness/lambdakzerospawner.cxx @@ -35,7 +35,7 @@ using namespace o2::framework::expressions; // Extends the v0data table with expression columns struct lambdakzerospawner { - Spawns v0cores; + // Spawns v0cores; void init(InitContext const&) {} }; diff --git a/PWGLF/TableProducer/Strangeness/lambdaspincorrelation.cxx b/PWGLF/TableProducer/Strangeness/lambdaspincorrelation.cxx new file mode 100644 index 00000000000..3878bf4e29a --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/lambdaspincorrelation.cxx @@ -0,0 +1,448 @@ +// 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. + +/// \file taskLambdaSpinCorr.cxx +/// \brief Analysis task for Lambda spin spin correlation +/// +/// \author prottay.das@cern.ch +/// \author sourav.kundu@cern.ch + +#include "PWGLF/DataModel/LFSpincorrelationTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGMM/Mult/DataModel/Index.h" // for Particles2Tracks table + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector2D.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" + +#include + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; +using namespace o2::aod::rctsel; + +struct lambdaspincorrelation { + + Produces lambdaEvent; + Produces lambdaPair; + Produces lambdaEventmc; + Produces lambdaPairmc; + + Service ccdb; + + struct : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } rctCut; + // mixing + // Produce derived tables + Configurable cfgCutOccupancy{"cfgCutOccupancy", 2000, "Occupancy cut"}; + ConfigurableAxis axisVertex{"axisVertex", {5, -10, 10}, "vertex axis for bin"}; + ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {8, 0, 80}, "multiplicity percentile for bin"}; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutCentralityMax{"cfgCutCentralityMax", 80.0f, "Accepted maximum Centrality"}; + Configurable cfgCutCentralityMin{"cfgCutCentralityMin", 0.0f, "Accepted minimum Centrality"}; + + // Configs for track + Configurable cfgCutPt{"cfgCutPt", 0.2, "Pt cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + + // Configs for V0 + Configurable confV0PtMin{"confV0PtMin", 0.f, "Minimum transverse momentum of V0"}; + Configurable confV0PtMax{"confV0PtMax", 1000.f, "Maximum transverse momentum of V0"}; + Configurable confV0Rap{"confV0Rap", 0.8f, "Rapidity range of V0"}; + Configurable confV0DCADaughMax{"confV0DCADaughMax", 1.0f, "Maximum DCA between the V0 daughters"}; + Configurable confV0CPAMin{"confV0CPAMin", 0.9998f, "Minimum CPA of V0"}; + Configurable confV0TranRadV0Min{"confV0TranRadV0Min", 1.5f, "Minimum transverse radius"}; + Configurable confV0TranRadV0Max{"confV0TranRadV0Max", 100.f, "Maximum transverse radius"}; + Configurable cMaxV0DCA{"cMaxV0DCA", 1.2, "Maximum V0 DCA to PV"}; + Configurable cMinV0DCAPr{"cMinV0DCAPr", 0.05, "Minimum V0 daughters DCA to PV for Pr"}; + Configurable cMinV0DCAPi{"cMinV0DCAPi", 0.05, "Minimum V0 daughters DCA to PV for Pi"}; + Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 50, "Maximum V0 life time"}; + + // config for V0 daughters + Configurable confDaughEta{"confDaughEta", 0.8f, "V0 Daugh sel: max eta"}; + Configurable cfgDaughPrPt{"cfgDaughPrPt", 0.2, "minimum daughter proton pt"}; + Configurable cfgDaughPiPt{"cfgDaughPiPt", 0.2, "minimum daughter pion pt"}; + Configurable confDaughTPCnclsMin{"confDaughTPCnclsMin", 50.f, "V0 Daugh sel: Min. nCls TPC"}; + Configurable confDaughPIDCuts{"confDaughPIDCuts", 3, "PID selections for Lambda daughters"}; + + Configurable iMNbins{"iMNbins", 50, "Number of bins in invariant mass"}; + Configurable lbinIM{"lbinIM", 1.09, "lower bin value in IM histograms"}; + Configurable hbinIM{"hbinIM", 1.14, "higher bin value in IM histograms"}; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + RCTFlagsChecker rctChecker; + void init(o2::framework::InitContext&) + { + rctChecker.init(rctCut.cfgEvtRCTFlagCheckerLabel, rctCut.cfgEvtRCTFlagCheckerZDCCheck, rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + AxisSpec thnAxisInvMass{iMNbins, lbinIM, hbinIM, "#it{M} (GeV/#it{c}^{2})"}; + histos.add("hEvtSelInfo", "hEvtSelInfo", kTH1F, {{5, 0, 5.0}}); + histos.add("hLambdaMass", "hLambdaMass", kTH1F, {thnAxisInvMass}); + histos.add("hV0Info", "hV0Info", kTH1F, {{5, 0, 5.0}}); + } + + template + bool selectionV0(Collision const& collision, V0 const& candidate) + { + if (std::abs(candidate.dcav0topv()) > cMaxV0DCA) { + return false; + } + const float pT = candidate.pt(); + const float tranRad = candidate.v0radius(); + const float dcaDaughv0 = std::abs(candidate.dcaV0daughters()); + const float cpav0 = candidate.v0cosPA(); + float ctauLambda = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * (o2::constants::physics::MassLambda); + + if (pT < confV0PtMin) { + return false; + } + if (pT > confV0PtMax) { + return false; + } + if (dcaDaughv0 > confV0DCADaughMax) { + return false; + } + if (cpav0 < confV0CPAMin) { + return false; + } + if (tranRad < confV0TranRadV0Min) { + return false; + } + if (tranRad > confV0TranRadV0Max) { + return false; + } + if (std::abs(ctauLambda) > cMaxV0LifeTime) { + return false; + } + if (std::abs(candidate.yLambda()) > confV0Rap) { + return false; + } + return true; + } + + template + bool isSelectedV0Daughter(V0 const& candidate, T const& track, int pid) + { + const auto tpcNClsF = track.tpcNClsFound(); + const auto ncr = 70; + const auto ncrfc = 0.8; + + if (track.tpcNClsCrossedRows() < ncr) { + return false; + } + if (tpcNClsF < confDaughTPCnclsMin) { + return false; + } + if (track.tpcCrossedRowsOverFindableCls() < ncrfc) { + return false; + } + + if (pid == 0 && std::abs(track.tpcNSigmaPr()) > confDaughPIDCuts) { + return false; + } + if (pid == 1 && std::abs(track.tpcNSigmaPi()) > confDaughPIDCuts) { + return false; + } + if (pid == 0 && (candidate.positivept() < cfgDaughPrPt || candidate.negativept() < cfgDaughPiPt)) { + return false; + } + if (pid == 1 && (candidate.positivept() < cfgDaughPiPt || candidate.negativept() < cfgDaughPrPt)) { + return false; + } + if (std::abs(candidate.positiveeta()) > confDaughEta || std::abs(candidate.negativeeta()) > confDaughEta) { + return false; + } + + if (pid == 0 && (std::abs(candidate.dcapostopv()) < cMinV0DCAPr || std::abs(candidate.dcanegtopv()) < cMinV0DCAPi)) { + return false; + } + if (pid == 1 && (std::abs(candidate.dcapostopv()) < cMinV0DCAPi || std::abs(candidate.dcanegtopv()) < cMinV0DCAPr)) { + return false; + } + + return true; + } + + std::tuple getLambdaTags(const auto& v0, const auto& collision) + { + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + + int lambdaTag = 0; + int aLambdaTag = 0; + + const auto signpos = postrack.sign(); + const auto signneg = negtrack.sign(); + + if (signpos < 0 || signneg > 0) { + return {0, 0, false}; // Invalid candidate + } + + if (isSelectedV0Daughter(v0, postrack, 0) && isSelectedV0Daughter(v0, negtrack, 1) && v0.mLambda() > lbinIM && v0.mLambda() < hbinIM) { + lambdaTag = 1; + } + if (isSelectedV0Daughter(v0, negtrack, 0) && isSelectedV0Daughter(v0, postrack, 1) && v0.mAntiLambda() > lbinIM && v0.mAntiLambda() < hbinIM) { + aLambdaTag = 1; + } + + if (!lambdaTag && !aLambdaTag) { + return {0, 0, false}; // No valid tags + } + + if (!selectionV0(collision, v0)) { + return {0, 0, false}; // Fails selection + } + + return {lambdaTag, aLambdaTag, true}; // Valid candidate + } + + ROOT::Math::PxPyPzMVector lambda, antiLambda, proton, pion, antiProton, antiPion; + ROOT::Math::PxPyPzMVector lambdaDummy, pionDummy, protonDummy; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter centralityFilter = (nabs(aod::cent::centFT0C) < cfgCutCentralityMax && nabs(aod::cent::centFT0C) > cfgCutCentralityMin); + + using EventCandidates = soa::Filtered>; + using AllTrackCandidates = soa::Join; + using ResoV0s = aod::V0Datas; + + void processData(EventCandidates::iterator const& collision, AllTrackCandidates const&, ResoV0s const& V0s) + { + std::vector lambdaMother, protonDaughter, pionDaughter; + std::vector v0Status = {}; + std::vector doubleStatus = {}; + std::vector v0Cospa = {}; + std::vector v0Radius = {}; + std::vector dcaPositive = {}; + std::vector dcaNegative = {}; + std::vector positiveIndex = {}; + std::vector negativeIndex = {}; + std::vector dcaBetweenDaughter = {}; + int numbV0 = 0; + // LOGF(info, "event collisions: (%d)", collision.index()); + auto centrality = collision.centFT0C(); + auto vz = collision.posZ(); + int occupancy = collision.trackOccupancyInTimeRange(); + histos.fill(HIST("hEvtSelInfo"), 0.5); + if ((rctCut.requireRCTFlagChecker && rctChecker(collision)) && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && collision.selection_bit(aod::evsel::kNoITSROFrameBorder) && collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) && collision.sel8() && collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll) && occupancy < cfgCutOccupancy) { + histos.fill(HIST("hEvtSelInfo"), 1.5); + for (const auto& v0 : V0s) { + // LOGF(info, "v0 index 0 : (%d)", v0.index()); + auto [lambdaTag, aLambdaTag, isValid] = getLambdaTags(v0, collision); + if (isValid) { + // LOGF(info, "v0 index 1 : (%d)", v0.index()); + if (lambdaTag) { + histos.fill(HIST("hV0Info"), 0.5); + } + if (aLambdaTag) { + histos.fill(HIST("hV0Info"), 1.5); + } + if (lambdaTag && aLambdaTag) { + doubleStatus.push_back(true); + if (std::abs(v0.mLambda() - 1.1154) < std::abs(v0.mAntiLambda() - 1.1154)) { + lambdaTag = true; + aLambdaTag = false; + } else { + lambdaTag = false; + aLambdaTag = true; + } + } else { + doubleStatus.push_back(false); + } + if (lambdaTag) { + histos.fill(HIST("hV0Info"), 2.5); + } + if (aLambdaTag) { + histos.fill(HIST("hV0Info"), 3.5); + } + // LOGF(info, "v0 index2: (%d)", v0.index()); + auto postrack1 = v0.template posTrack_as(); + auto negtrack1 = v0.template negTrack_as(); + positiveIndex.push_back(postrack1.globalIndex()); + negativeIndex.push_back(negtrack1.globalIndex()); + v0Cospa.push_back(v0.v0cosPA()); + v0Radius.push_back(v0.v0radius()); + dcaPositive.push_back(std::abs(v0.dcapostopv())); + dcaNegative.push_back(std::abs(v0.dcanegtopv())); + dcaBetweenDaughter.push_back(std::abs(v0.dcaV0daughters())); + if (lambdaTag) { + v0Status.push_back(0); + proton = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassProton); + antiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassPionCharged); + lambda = proton + antiPion; + lambdaMother.push_back(lambda); + protonDaughter.push_back(proton); + pionDaughter.push_back(antiPion); + histos.fill(HIST("hLambdaMass"), lambda.M()); + } else if (aLambdaTag) { + v0Status.push_back(1); + antiProton = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassProton); + pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda = antiProton + pion; + lambdaMother.push_back(antiLambda); + protonDaughter.push_back(antiProton); + pionDaughter.push_back(pion); + histos.fill(HIST("hLambdaMass"), lambda.M()); + } + numbV0 = numbV0 + 1; + } + } + if (numbV0 > 1 && v0Cospa.size() > 1) { + histos.fill(HIST("hEvtSelInfo"), 2.5); + lambdaEvent(centrality, vz); + auto indexEvent = lambdaEvent.lastIndex(); + //// Fill track table for V0////////////////// + for (auto if1 = lambdaMother.begin(); if1 != lambdaMother.end(); ++if1) { + auto i5 = std::distance(lambdaMother.begin(), if1); + lambdaDummy = lambdaMother.at(i5); + protonDummy = protonDaughter.at(i5); + pionDummy = pionDaughter.at(i5); + lambdaPair(indexEvent, v0Status.at(i5), doubleStatus.at(i5), v0Cospa.at(i5), v0Radius.at(i5), dcaPositive.at(i5), dcaNegative.at(i5), dcaBetweenDaughter.at(i5), lambdaDummy.Pt(), lambdaDummy.Eta(), lambdaDummy.Phi(), lambdaDummy.M(), protonDummy.Pt(), protonDummy.Eta(), protonDummy.Phi(), positiveIndex.at(i5), negativeIndex.at(i5)); + } + } + } + } + PROCESS_SWITCH(lambdaspincorrelation, processData, "Process data", false); + + void processMc(EventCandidates::iterator const& collision, AllTrackCandidates const&, ResoV0s const& V0s) + { + std::vector lambdaMother, protonDaughter, pionDaughter; + std::vector v0Status = {}; + std::vector doubleStatus = {}; + std::vector v0Cospa = {}; + std::vector v0Radius = {}; + std::vector dcaPositive = {}; + std::vector dcaNegative = {}; + std::vector positiveIndex = {}; + std::vector negativeIndex = {}; + std::vector dcaBetweenDaughter = {}; + int numbV0 = 0; + // LOGF(info, "event collisions: (%d)", collision.index()); + auto centrality = collision.centFT0C(); + auto vz = collision.posZ(); + int occupancy = collision.trackOccupancyInTimeRange(); + histos.fill(HIST("hEvtSelInfo"), 0.5); + if ((rctCut.requireRCTFlagChecker && rctChecker(collision)) && collision.selection_bit(aod::evsel::kNoSameBunchPileup) && collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) && collision.sel8() && collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll) && occupancy < cfgCutOccupancy) { + histos.fill(HIST("hEvtSelInfo"), 1.5); + for (const auto& v0 : V0s) { + // LOGF(info, "v0 index 0 : (%d)", v0.index()); + auto [lambdaTag, aLambdaTag, isValid] = getLambdaTags(v0, collision); + if (isValid) { + // LOGF(info, "v0 index 1 : (%d)", v0.index()); + if (lambdaTag) { + histos.fill(HIST("hV0Info"), 0.5); + } + if (aLambdaTag) { + histos.fill(HIST("hV0Info"), 1.5); + } + if (lambdaTag && aLambdaTag) { + doubleStatus.push_back(true); + if (std::abs(v0.mLambda() - 1.1154) < std::abs(v0.mAntiLambda() - 1.1154)) { + lambdaTag = true; + aLambdaTag = false; + } else { + lambdaTag = false; + aLambdaTag = true; + } + } else { + doubleStatus.push_back(false); + } + if (lambdaTag) { + histos.fill(HIST("hV0Info"), 2.5); + } + if (aLambdaTag) { + histos.fill(HIST("hV0Info"), 3.5); + } + // LOGF(info, "v0 index2: (%d)", v0.index()); + auto postrack1 = v0.template posTrack_as(); + auto negtrack1 = v0.template negTrack_as(); + positiveIndex.push_back(postrack1.globalIndex()); + negativeIndex.push_back(negtrack1.globalIndex()); + v0Cospa.push_back(v0.v0cosPA()); + v0Radius.push_back(v0.v0radius()); + dcaPositive.push_back(std::abs(v0.dcapostopv())); + dcaNegative.push_back(std::abs(v0.dcanegtopv())); + dcaBetweenDaughter.push_back(std::abs(v0.dcaV0daughters())); + if (lambdaTag) { + v0Status.push_back(0); + proton = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassProton); + antiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassPionCharged); + lambda = proton + antiPion; + lambdaMother.push_back(lambda); + protonDaughter.push_back(proton); + pionDaughter.push_back(antiPion); + histos.fill(HIST("hLambdaMass"), lambda.M()); + } else if (aLambdaTag) { + v0Status.push_back(1); + antiProton = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassProton); + pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda = antiProton + pion; + lambdaMother.push_back(antiLambda); + protonDaughter.push_back(antiProton); + pionDaughter.push_back(pion); + histos.fill(HIST("hLambdaMass"), lambda.M()); + } + numbV0 = numbV0 + 1; + } + } + if (numbV0 > 1 && v0Cospa.size() > 1) { + histos.fill(HIST("hEvtSelInfo"), 2.5); + lambdaEventmc(centrality, vz); + auto indexEvent = lambdaEventmc.lastIndex(); + //// Fill track table for V0////////////////// + for (auto if1 = lambdaMother.begin(); if1 != lambdaMother.end(); ++if1) { + auto i5 = std::distance(lambdaMother.begin(), if1); + lambdaDummy = lambdaMother.at(i5); + protonDummy = protonDaughter.at(i5); + pionDummy = pionDaughter.at(i5); + lambdaPairmc(indexEvent, v0Status.at(i5), doubleStatus.at(i5), v0Cospa.at(i5), v0Radius.at(i5), dcaPositive.at(i5), dcaNegative.at(i5), dcaBetweenDaughter.at(i5), lambdaDummy.Pt(), lambdaDummy.Eta(), lambdaDummy.Phi(), lambdaDummy.M(), protonDummy.Pt(), protonDummy.Eta(), protonDummy.Phi(), positiveIndex.at(i5), negativeIndex.at(i5)); + } + } + } + } + PROCESS_SWITCH(lambdaspincorrelation, processMc, "Process montecarlo", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/propagationService.cxx b/PWGLF/TableProducer/Strangeness/propagationService.cxx new file mode 100644 index 00000000000..191b920d9ef --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/propagationService.cxx @@ -0,0 +1,156 @@ +// 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. + +/// \file propagationService.cxx +/// \brief +/// \author ALICE + +//=============================================================== +// +// Merged track propagation + strangeness building task +// +// Provides a common task to deal with track propagation and +// strangeness building in a single DPL device that is particularly +// adequate for pipelining. +// +// Currently meant for testing and performance check +// +//=============================================================== + +#include "PWGLF/Utils/strangenessBuilderModule.h" + +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Tools/StandardCCDBLoader.h" +#include "Common/Tools/TrackPropagationModule.h" +#include "Common/Tools/TrackTuner.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "CommonConstants/GeomConstants.h" +#include "CommonUtils/NameConf.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/DCA.h" + +#include + +using namespace o2; +using namespace o2::framework; +// using namespace o2::framework::expressions; + +// use parameters + cov mat non-propagated, aux info + (extension propagated) +using FullTracksExt = soa::Join; +using FullTracksExtIU = soa::Join; +using FullTracksExtWithPID = soa::Join; +using FullTracksExtIUWithPID = soa::Join; +using FullTracksExtLabeled = soa::Join; +using FullTracksExtLabeledIU = soa::Join; +using FullTracksExtLabeledWithPID = soa::Join; +using FullTracksExtLabeledIUWithPID = soa::Join; +using TracksWithExtra = soa::Join; + +// For dE/dx association in pre-selection +using TracksExtraWithPID = soa::Join; + +struct propagationService { + // CCDB boilerplate declarations + o2::framework::Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Service ccdb; + + // propagation stuff + o2::common::StandardCCDBLoaderConfigurables standardCCDBLoaderConfigurables; + o2::common::StandardCCDBLoader ccdbLoader; + + // boilerplate: strangeness builder stuff + o2::pwglf::strangenessbuilder::products products; + o2::pwglf::strangenessbuilder::coreConfigurables baseOpts; + o2::pwglf::strangenessbuilder::v0Configurables v0BuilderOpts; + o2::pwglf::strangenessbuilder::cascadeConfigurables cascadeBuilderOpts; + o2::pwglf::strangenessbuilder::preSelectOpts preSelectOpts; + o2::pwglf::strangenessbuilder::BuilderModule strangenessBuilderModule; + + // the track tuner object -> needs to be here as it inherits from ConfigurableGroup (+ has its own copy of ccdbApi) + TrackTuner trackTunerObj; + + // track propagation + o2::common::TrackPropagationProducts trackPropagationProducts; + o2::common::TrackPropagationConfigurables trackPropagationConfigurables; + o2::common::TrackPropagationModule trackPropagation; + + // registry + HistogramRegistry histos{"histos"}; + + void init(o2::framework::InitContext& initContext) + { + // CCDB boilerplate init + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setURL(ccdburl.value); + + // task-specific + trackPropagation.init(trackPropagationConfigurables, trackTunerObj, histos, initContext); + strangenessBuilderModule.init(baseOpts, v0BuilderOpts, cascadeBuilderOpts, preSelectOpts, histos, initContext); + } + + void processRealData(soa::Join const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtIU const& tracks, aod::BCsWithTimestamps const& bcs) + { + ccdbLoader.initCCDBfromBCs(standardCCDBLoaderConfigurables, ccdb, bcs); + trackPropagation.fillTrackTables(trackPropagationConfigurables, trackTunerObj, ccdbLoader, collisions, tracks, trackPropagationProducts, histos); + strangenessBuilderModule.dataProcess(ccdb, histos, collisions, static_cast(nullptr), v0s, cascades, trackedCascades, tracks, bcs, static_cast(nullptr), products); + } + + void processMonteCarlo(soa::Join const& collisions, aod::McCollisions const& mccollisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtLabeledIU const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const& mcParticles) + { + ccdbLoader.initCCDBfromBCs(standardCCDBLoaderConfigurables, ccdb, bcs); + trackPropagation.fillTrackTables(trackPropagationConfigurables, trackTunerObj, ccdbLoader, collisions, tracks, trackPropagationProducts, histos); + strangenessBuilderModule.dataProcess(ccdb, histos, collisions, mccollisions, v0s, cascades, trackedCascades, tracks, bcs, mcParticles, products); + } + + // FIXME: the part below is only viable if TPC PID + // switches to using TracksIU (circular dependency) + // + // void processRealDataWithPID(soa::Join const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtIUWithPID const& tracks, aod::BCsWithTimestamps const& bcs) + // { + // ccdbLoader.initCCDBfromBCs(standardCCDBLoaderConfigurables, ccdb, bcs); + // trackPropagation.fillTrackTables(trackPropagationConfigurables, ccdbLoader, collisions, tracks, trackPropagationProducts, histos); + // strangenessBuilderModule.dataProcess(ccdb, histos, collisions, static_cast(nullptr), v0s, cascades, trackedCascades, tracks, bcs, static_cast(nullptr), products); + // } + + // void processMonteCarloWithPID(soa::Join const& collisions, aod::McCollisions const& mccollisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtLabeledIUWithPID const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const& mcParticles) + // { + // ccdbLoader.initCCDBfromBCs(standardCCDBLoaderConfigurables, ccdb, bcs); + // trackPropagation.fillTrackTables(trackPropagationConfigurables, ccdbLoader, collisions, tracks, trackPropagationProducts, histos); + // strangenessBuilderModule.dataProcess(ccdb, histos, collisions, mccollisions, v0s, cascades, trackedCascades, tracks, bcs, mcParticles, products); + // } + + PROCESS_SWITCH(propagationService, processRealData, "process real data", true); + PROCESS_SWITCH(propagationService, processMonteCarlo, "process monte carlo", false); + // PROCESS_SWITCH(propagationService, processRealDataWithPID, "process real data", false); + // PROCESS_SWITCH(propagationService, processMonteCarloWithPID, "process monte carlo", false); +}; + +//**************************************************************************************** +/** + * Workflow definition. + */ +//**************************************************************************************** +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/PWGLF/TableProducer/Strangeness/sigma0builder.cxx b/PWGLF/TableProducer/Strangeness/sigma0builder.cxx index 46470a69f79..32ed292dddd 100644 --- a/PWGLF/TableProducer/Strangeness/sigma0builder.cxx +++ b/PWGLF/TableProducer/Strangeness/sigma0builder.cxx @@ -33,15 +33,16 @@ #include "ReconstructionDataFormats/Track.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/LFStrangenessPIDTables.h" -#include "PWGLF/DataModel/LFStrangenessMLTables.h" -#include "PWGLF/DataModel/LFSigmaTables.h" #include "Common/Core/TrackSelection.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/CCDB/ctpRateFetcher.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessMLTables.h" +#include "PWGLF/DataModel/LFSigmaTables.h" #include "CCDB/BasicCCDBManager.h" #include #include @@ -55,12 +56,14 @@ using namespace o2::framework; using namespace o2::framework::expressions; using std::array; using dauTracks = soa::Join; -using V0DerivedMCDatas = soa::Join; -using V0MLDerivedDatas = soa::Join; -using V0StandardDerivedDatas = soa::Join; +using V0DerivedMCDatas = soa::Join; +using V0StandardDerivedDatas = soa::Join; struct sigma0builder { - SliceCache cache; + Service ccdb; + ctpRateFetcher rateFetcher; + + // SliceCache cache; Produces sigma0cores; // save sigma0 candidates for analysis Produces sigmaPhotonExtras; // save sigma0 candidates for analysis @@ -68,20 +71,74 @@ struct sigma0builder { Produces sigma0mccores; // For manual sliceBy - Preslice perCollisionMCDerived = o2::aod::v0data::straCollisionId; - Preslice perCollisionSTDDerived = o2::aod::v0data::straCollisionId; - Preslice perCollisionMLDerived = o2::aod::v0data::straCollisionId; + // PresliceUnsorted perCollisionMCDerived = o2::aod::v0data::straCollisionId; + // PresliceUnsorted perCollisionSTDDerived = o2::aod::v0data::straCollisionId; + PresliceUnsorted> perMcCollision = aod::v0data::straMCCollisionId; + + // pack track quality but separte also afterburner + // dynamic range: 0-31 + enum selection : int { hasTPC = 0, + hasITSTracker, + hasITSAfterburner, + hasTRD, + hasTOF }; // Histogram registry HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable fillQAhistos{"fillQAhistos", false, "if true, fill QA histograms"}; + Configurable fillBkgQAhistos{"fillBkgQAhistos", false, "if true, fill MC QA histograms for Bkg study"}; + Configurable doPi0QA{"doPi0QA", true, "Flag to fill QA histos for pi0 rejection study."}; + Configurable doAssocStudy{"doAssocStudy", false, "Do v0 to collision association study."}; + + // Event level + Configurable doPPAnalysis{"doPPAnalysis", true, "if in pp, set to true"}; + Configurable fGetIR{"fGetIR", false, "Flag to retrieve the IR info."}; + Configurable fIRCrashOnNull{"fIRCrashOnNull", false, "Flag to avoid CTP RateFetcher crash."}; + Configurable irSource{"irSource", "T0VTX", "Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"}; + + struct : ConfigurableGroup { + Configurable requireSel8{"requireSel8", true, "require sel8 event selection"}; + Configurable requireTriggerTVX{"requireTriggerTVX", true, "require FT0 vertex (acceptable FT0C-FT0A time difference) at trigger level"}; + Configurable rejectITSROFBorder{"rejectITSROFBorder", true, "reject events at ITS ROF border"}; + Configurable rejectTFBorder{"rejectTFBorder", true, "reject events at TF border"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", true, "require events with at least one ITS-TPC track"}; + Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", true, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference"}; + Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", false, "require events with at least one of vertex contributors matched to TOF"}; + Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", false, "require events with at least one of vertex contributors matched to TRD"}; + Configurable rejectSameBunchPileup{"rejectSameBunchPileup", false, "reject collisions in case of pileup with another collision in the same foundBC"}; + Configurable requireNoCollInTimeRangeStd{"requireNoCollInTimeRangeStd", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds"}; + Configurable requireNoCollInTimeRangeStrict{"requireNoCollInTimeRangeStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 10 microseconds"}; + Configurable requireNoCollInTimeRangeNarrow{"requireNoCollInTimeRangeNarrow", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds"}; + Configurable requireNoCollInTimeRangeVzDep{"requireNoCollInTimeRangeVzDep", false, "reject collisions corrupted by the cannibalism, with other collisions with pvZ of drifting TPC tracks from past/future collisions within 2.5 cm the current pvZ"}; + Configurable requireNoCollInROFStd{"requireNoCollInROFStd", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF with mult. above a certain threshold"}; + Configurable requireNoCollInROFStrict{"requireNoCollInROFStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF"}; + Configurable requireINEL0{"requireINEL0", false, "require INEL>0 event selection"}; + Configurable requireINEL1{"requireINEL1", false, "require INEL>1 event selection"}; + Configurable maxZVtxPosition{"maxZVtxPosition", 10., "max Z vtx position"}; + Configurable useEvtSelInDenomEff{"useEvtSelInDenomEff", false, "Consider event selections in the recoed <-> gen collision association for the denominator (or numerator) of the acc. x eff. (or signal loss)?"}; + Configurable applyZVtxSelOnMCPV{"applyZVtxSelOnMCPV", false, "Apply Z-vtx cut on the PV of the generated collision?"}; + Configurable useFT0CbasedOccupancy{"useFT0CbasedOccupancy", false, "Use sum of FT0-C amplitudes for estimating occupancy? (if not, use track-based definition)"}; + // fast check on occupancy + Configurable minOccupancy{"minOccupancy", -1, "minimum occupancy from neighbouring collisions"}; + Configurable maxOccupancy{"maxOccupancy", -1, "maximum occupancy from neighbouring collisions"}; + + // fast check on interaction rate + Configurable minIR{"minIR", -1, "minimum IR collisions"}; + Configurable maxIR{"maxIR", -1, "maximum IR collisions"}; + + } eventSelections; + // For ML Selection + Configurable useMLScores{"useMLScores", false, "use ML scores to select candidates"}; Configurable Gamma_MLThreshold{"Gamma_MLThreshold", 0.1, "Decision Threshold value to select gammas"}; Configurable Lambda_MLThreshold{"Lambda_MLThreshold", 0.1, "Decision Threshold value to select lambdas"}; Configurable AntiLambda_MLThreshold{"AntiLambda_MLThreshold", 0.1, "Decision Threshold value to select antilambdas"}; // For standard approach: //// Lambda criteria: + Configurable V0Rapidity{"V0Rapidity", 0.8, "v0 rapidity"}; + Configurable LambdaDauPseudoRap{"LambdaDauPseudoRap", 1.5, "Max pseudorapidity of daughter tracks"}; Configurable LambdaMinDCANegToPv{"LambdaMinDCANegToPv", 0.0, "min DCA Neg To PV (cm)"}; Configurable LambdaMinDCAPosToPv{"LambdaMinDCAPosToPv", 0.0, "min DCA Pos To PV (cm)"}; @@ -103,7 +160,6 @@ struct sigma0builder { Configurable SigmaMaxRap{"SigmaMaxRap", 0.8, "Max sigma0 rapidity"}; //// Extras: - Configurable doPi0QA{"doPi0QA", true, "Flag to fill QA histos for pi0 rejection study."}; Configurable Pi0PhotonMinDCADauToPv{"Pi0PhotonMinDCADauToPv", 0.0, "Min DCA daughter To PV (cm)"}; Configurable Pi0PhotonMaxDCAV0Dau{"Pi0PhotonMaxDCAV0Dau", 3.5, "Max DCA V0 Daughters (cm)"}; Configurable Pi0PhotonMinTPCCrossedRows{"Pi0PhotonMinTPCCrossedRows", 0, "Min daughter TPC Crossed Rows"}; @@ -120,12 +176,13 @@ struct sigma0builder { // base properties ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for analysis"}; ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Centrality"}; - ConfigurableAxis axisDeltaPt{"axisDeltaPt", {100, -1.0, +1.0}, "#Delta(p_{T})"}; // Invariant Mass - ConfigurableAxis axisSigmaMass{"axisSigmaMass", {1000, 1.10f, 1.30f}, "M_{#Sigma^{0}} (GeV/c^{2})"}; + ConfigurableAxis axisSigmaMass{"axisSigmaMass", {500, 1.10f, 1.30f}, "M_{#Sigma^{0}} (GeV/c^{2})"}; ConfigurableAxis axisLambdaMass{"axisLambdaMass", {200, 1.05f, 1.151f}, "M_{#Lambda} (GeV/c^{2})"}; - ConfigurableAxis axisPhotonMass{"axisPhotonMass", {600, -0.1f, 0.5f}, "M_{#Gamma}"}; + ConfigurableAxis axisPhotonMass{"axisPhotonMass", {200, -0.1f, 0.5f}, "M_{#Gamma}"}; + ConfigurableAxis axisPi0Mass{"axisPi0Mass", {200, 0.08f, 0.18f}, "M_{#Pi^{0}}"}; + ConfigurableAxis axisK0SMass{"axisK0SMass", {200, 0.4f, 0.6f}, "M_{K^{0}}"}; // AP plot axes ConfigurableAxis axisAPAlpha{"axisAPAlpha", {220, -1.1f, 1.1f}, "V0 AP alpha"}; @@ -136,110 +193,555 @@ struct sigma0builder { // topological variable QA axes ConfigurableAxis axisDCAtoPV{"axisDCAtoPV", {500, 0.0f, 50.0f}, "DCA (cm)"}; + ConfigurableAxis axisXY{"axisXY", {120, -120.0f, 120.0f}, "XY axis"}; ConfigurableAxis axisDCAdau{"axisDCAdau", {50, 0.0f, 5.0f}, "DCA (cm)"}; ConfigurableAxis axisRadius{"axisRadius", {240, 0.0f, 120.0f}, "V0 radius (cm)"}; + ConfigurableAxis axisPA{"axisPA", {100, 0.0f, 1}, "Pointing angle"}; ConfigurableAxis axisRapidity{"axisRapidity", {100, -2.0f, 2.0f}, "Rapidity"}; - ConfigurableAxis axisCandSel{"axisCandSel", {13, 0.5f, +13.5f}, "Candidate Selection"}; + ConfigurableAxis axisCandSel{"axisCandSel", {7, 0.5f, +7.5f}, "Candidate Selection"}; + ConfigurableAxis axisNch{"axisNch", {300, 0.0f, 3000.0f}, "N_{ch}"}; + ConfigurableAxis axisIRBinning{"axisIRBinning", {150, 0, 1500}, "Binning for the interaction rate (kHz)"}; int nSigmaCandidates = 0; void init(InitContext const&) { - // Event counter - histos.add("hEventCentrality", "hEventCentrality", kTH1F, {axisCentrality}); - histos.add("hCandidateBuilderSelection", "hCandidateBuilderSelection", kTH1F, {axisCandSel}); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(1, "No Sel"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(2, "Photon Mass Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(3, "Photon DauEta Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(4, "Photon DCAToPV Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(5, "Photon DCADau Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(6, "Photon Radius Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(7, "Lambda Mass Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(8, "Lambda DauEta Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(9, "Lambda DCAToPV Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(10, "Lambda Radius Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(11, "Lambda DCADau Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(12, "Sigma Mass Window"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(13, "Sigma Y Window"); - - // For QA: - histos.add("Selection/hPhotonMass", "hPhotonMass", kTH1F, {axisPhotonMass}); - histos.add("Selection/hPhotonNegEta", "hPhotonNegEta", kTH1F, {axisRapidity}); - histos.add("Selection/hPhotonPosEta", "hPhotonPosEta", kTH1F, {axisRapidity}); - histos.add("Selection/hPhotonDCANegToPV", "hPhotonDCANegToPV", kTH1F, {axisDCAtoPV}); - histos.add("Selection/hPhotonDCAPosToPV", "hPhotonDCAPosToPV", kTH1F, {axisDCAtoPV}); - histos.add("Selection/hPhotonDCADau", "hPhotonDCADau", kTH1F, {axisDCAdau}); - histos.add("Selection/hPhotonRadius", "hPhotonRadius", kTH1F, {axisRadius}); - histos.add("Selection/hLambdaMass", "hLambdaMass", kTH1F, {axisLambdaMass}); - histos.add("Selection/hAntiLambdaMass", "hAntiLambdaMass", kTH1F, {axisLambdaMass}); - histos.add("Selection/hLambdaNegEta", "hLambdaNegEta", kTH1F, {axisRapidity}); - histos.add("Selection/hLambdaPosEta", "hLambdaPosEta", kTH1F, {axisRapidity}); - histos.add("Selection/hLambdaDCANegToPV", "hLambdaDCANegToPV", kTH1F, {axisDCAtoPV}); - histos.add("Selection/hLambdaDCAPosToPV", "hLambdaDCAPosToPV", kTH1F, {axisDCAtoPV}); - histos.add("Selection/hLambdaDCADau", "hLambdaDCADau", kTH1F, {axisDCAdau}); - histos.add("Selection/hLambdaRadius", "hLambdaRadius", kTH1F, {axisRadius}); - histos.add("Selection/hSigmaMass", "hSigmaMass", kTH1F, {axisSigmaMass}); - histos.add("Selection/hSigmaMassWindow", "hSigmaMassWindow", kTH1F, {{1000, -0.09f, 0.11f}}); - histos.add("Selection/hSigmaY", "hSigmaY", kTH1F, {axisRapidity}); - - histos.add("GeneralQA/h2dMassGammaVsK0S", "h2dMassGammaVsK0S", kTH2D, {axisPhotonMass, {200, 0.4f, 0.6f}}); - histos.add("GeneralQA/h2dMassLambdaVsK0S", "h2dMassLambdaVsK0S", kTH2D, {axisLambdaMass, {200, 0.4f, 0.6f}}); - histos.add("GeneralQA/h2dMassGammaVsLambda", "h2dMassGammaVsLambda", kTH2D, {axisPhotonMass, axisLambdaMass}); - histos.add("GeneralQA/h3dMassSigma0VsDaupTs", "h3dMassSigma0VsDaupTs", kTH3F, {axisPt, axisPt, axisSigmaMass}); - histos.add("GeneralQA/h2dMassGammaVsK0SAfterMassSel", "h2dMassGammaVsK0SAfterMassSel", kTH2D, {axisPhotonMass, {200, 0.4f, 0.6f}}); - histos.add("GeneralQA/h2dMassLambdaVsK0SAfterMassSel", "h2dMassLambdaVsK0SAfterMassSel", kTH2D, {axisLambdaMass, {200, 0.4f, 0.6f}}); - histos.add("GeneralQA/h2dMassGammaVsLambdaAfterMassSel", "h2dMassGammaVsLambdaAfterMassSel", kTH2D, {axisPhotonMass, axisLambdaMass}); - histos.add("GeneralQA/h2dPtVsMassPi0BeforeSel_Candidates", "h2dPtVsMassPi0BeforeSel_Candidates", kTH2D, {axisPt, {500, 0.08f, 0.18f}}); - histos.add("GeneralQA/h2dPtVsMassPi0AfterSel_Candidates", "h2dPtVsMassPi0AfterSel_Candidates", kTH2D, {axisPt, {500, 0.08f, 0.18f}}); + // setting CCDB service + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setFatalWhenNull(false); + + // Event Counters + histos.add("hEventSelection", "hEventSelection", kTH1D, {{21, -0.5f, +20.5f}}); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(3, "kIsTriggerTVX"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(5, "kNoTimeFrameBorder"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(6, "posZ cut"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(7, "kIsVertexITSTPC"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(8, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(9, "kIsVertexTOFmatched"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(10, "kIsVertexTRDmatched"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(11, "kNoSameBunchPileup"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(12, "kNoCollInTimeRangeStd"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(13, "kNoCollInTimeRangeStrict"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(14, "kNoCollInTimeRangeNarrow"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(15, "kNoCollInRofStd"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(16, "kNoCollInRofStrict"); + if (doPPAnalysis) { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(17, "INEL>0"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "INEL>1"); + } else { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(17, "Below min occup."); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "Above max occup."); + } + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(19, "Below min IR"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(20, "Above max IR"); + + histos.add("hEventCentrality", "hEventCentrality", kTH1D, {axisCentrality}); + + histos.add("PhotonSel/hSelectionStatistics", "hSelectionStatistics", kTH1D, {axisCandSel}); + histos.get(HIST("PhotonSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(1, "No Sel"); + histos.get(HIST("PhotonSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(2, "Photon Mass Cut"); + histos.get(HIST("PhotonSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(3, "Photon Eta/Y Cut"); + histos.get(HIST("PhotonSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(4, "Photon DCAToPV Cut"); + histos.get(HIST("PhotonSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(5, "Photon DCADau Cut"); + histos.get(HIST("PhotonSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(6, "Photon Radius Cut"); + + histos.add("PhotonSel/hPhotonMass", "hPhotonMass", kTH1F, {axisPhotonMass}); + histos.add("PhotonSel/hPhotonNegEta", "hPhotonNegEta", kTH1F, {axisRapidity}); + histos.add("PhotonSel/hPhotonPosEta", "hPhotonPosEta", kTH1F, {axisRapidity}); + histos.add("PhotonSel/hPhotonY", "hPhotonY", kTH1F, {axisRapidity}); + histos.add("PhotonSel/hPhotonDCANegToPV", "hPhotonDCANegToPV", kTH1F, {axisDCAtoPV}); + histos.add("PhotonSel/hPhotonDCAPosToPV", "hPhotonDCAPosToPV", kTH1F, {axisDCAtoPV}); + histos.add("PhotonSel/hPhotonDCADau", "hPhotonDCADau", kTH1F, {axisDCAdau}); + histos.add("PhotonSel/hPhotonRadius", "hPhotonRadius", kTH1F, {axisRadius}); + histos.add("PhotonSel/h3dPhotonMass", "h3dPhotonMass", kTH3D, {axisCentrality, axisPt, axisPhotonMass}); + + histos.add("LambdaSel/hSelectionStatistics", "hSelectionStatistics", kTH1D, {axisCandSel}); + histos.get(HIST("LambdaSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(1, "No Sel"); + histos.get(HIST("LambdaSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(2, "Lambda Mass Cut"); + histos.get(HIST("LambdaSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(3, "Lambda Eta/Y Cut"); + histos.get(HIST("LambdaSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(4, "Lambda DCAToPV Cut"); + histos.get(HIST("LambdaSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(5, "Lambda Radius Cut"); + histos.get(HIST("LambdaSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(6, "Lambda DCADau Cut"); + + histos.add("LambdaSel/hLambdaMass", "hLambdaMass", kTH1F, {axisLambdaMass}); + histos.add("LambdaSel/hAntiLambdaMass", "hAntiLambdaMass", kTH1F, {axisLambdaMass}); + histos.add("LambdaSel/hLambdaNegEta", "hLambdaNegEta", kTH1F, {axisRapidity}); + histos.add("LambdaSel/hLambdaPosEta", "hLambdaPosEta", kTH1F, {axisRapidity}); + histos.add("LambdaSel/hLambdaY", "hLambdaY", kTH1F, {axisRapidity}); + histos.add("LambdaSel/hLambdaDCANegToPV", "hLambdaDCANegToPV", kTH1F, {axisDCAtoPV}); + histos.add("LambdaSel/hLambdaDCAPosToPV", "hLambdaDCAPosToPV", kTH1F, {axisDCAtoPV}); + histos.add("LambdaSel/hLambdaDCADau", "hLambdaDCADau", kTH1F, {axisDCAdau}); + histos.add("LambdaSel/hLambdaRadius", "hLambdaRadius", kTH1F, {axisRadius}); + histos.add("LambdaSel/h3dLambdaMass", "h3dLambdaMass", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("LambdaSel/h3dALambdaMass", "h3dALambdaMass", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); + + histos.add("SigmaSel/hSelectionStatistics", "hSelectionStatistics", kTH1D, {axisCandSel}); + histos.get(HIST("SigmaSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(1, "No Sel"); + histos.get(HIST("SigmaSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(2, "Sigma Mass Window"); + histos.get(HIST("SigmaSel/hSelectionStatistics"))->GetXaxis()->SetBinLabel(3, "Sigma Y Window"); + + // For selection: + histos.add("SigmaSel/h3dMassSigma0BeforeSel", "h3dMassSigma0BeforeSel", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); + histos.add("SigmaSel/hSigmaMass", "hSigmaMass", kTH1F, {axisSigmaMass}); + histos.add("SigmaSel/hSigmaMassWindow", "hSigmaMassWindow", kTH1F, {{200, -0.09f, 0.11f}}); + histos.add("SigmaSel/hSigmaY", "hSigmaY", kTH1F, {axisRapidity}); + histos.add("SigmaSel/hSigmaMassSelected", "hSigmaMassSelected", kTH1F, {axisSigmaMass}); + histos.add("SigmaSel/h3dMassSigma0AfterSel", "h3dMassSigma0AfterSel", kTH3D, {axisCentrality, axisPt, axisSigmaMass}); + + if (fillQAhistos) { + histos.add("GeneralQA/h2dMassGammaVsK0S", "h2dMassGammaVsK0S", kTH2D, {axisPhotonMass, axisK0SMass}); + histos.add("GeneralQA/h2dMassLambdaVsK0S", "h2dMassLambdaVsK0S", kTH2D, {axisLambdaMass, axisK0SMass}); + histos.add("GeneralQA/h2dMassGammaVsLambda", "h2dMassGammaVsLambda", kTH2D, {axisPhotonMass, axisLambdaMass}); + histos.add("GeneralQA/h2dMassLambdaVsGamma", "h2dMassLambdaVsGamma", kTH2D, {axisLambdaMass, axisPhotonMass}); + histos.add("GeneralQA/h3dMassSigma0VsDaupTs", "h3dMassSigma0VsDaupTs", kTH3F, {axisPt, axisPt, axisSigmaMass}); + histos.add("GeneralQA/h2dMassGammaVsK0SAfterMassSel", "h2dMassGammaVsK0SAfterMassSel", kTH2D, {axisPhotonMass, axisK0SMass}); + histos.add("GeneralQA/h2dMassLambdaVsK0SAfterMassSel", "h2dMassLambdaVsK0SAfterMassSel", kTH2D, {axisLambdaMass, axisK0SMass}); + histos.add("GeneralQA/h2dMassGammaVsLambdaAfterMassSel", "h2dMassGammaVsLambdaAfterMassSel", kTH2D, {axisPhotonMass, axisLambdaMass}); + histos.add("GeneralQA/h2dV0XY", "h2dV0XY", kTH2F, {axisXY, axisXY}); + } + + if (fGetIR) { + histos.add("GeneralQA/hRunNumberNegativeIR", "", kTH1D, {{1, 0., 1.}}); + histos.add("GeneralQA/hInteractionRate", "hInteractionRate", kTH1F, {axisIRBinning}); + histos.add("GeneralQA/hCentralityVsInteractionRate", "hCentralityVsInteractionRate", kTH2F, {axisCentrality, axisIRBinning}); + } + + if (doAssocStudy && doprocessMonteCarlo) { + histos.add("V0AssoQA/h2dIRVsPt_TrueGamma", "h2dIRVsPt_TrueGamma", kTH2F, {axisIRBinning, axisPt}); + histos.add("V0AssoQA/h3dPAVsIRVsPt_TrueGamma", "h3dPAVsIRVsPt_TrueGamma", kTH3F, {axisPA, axisIRBinning, axisPt}); + histos.add("V0AssoQA/h2dIRVsPt_TrueGamma_BadCollAssig", "h2dIRVsPt_TrueGamma_BadCollAssig", kTH2F, {axisIRBinning, axisPt}); + histos.add("V0AssoQA/h3dPAVsIRVsPt_TrueGamma_BadCollAssig", "h3dPAVsIRVsPt_TrueGamma_BadCollAssig", kTH3F, {axisPA, axisIRBinning, axisPt}); + + histos.add("V0AssoQA/h2dIRVsPt_TrueLambda", "h2dIRVsPt_TrueLambda", kTH2F, {axisIRBinning, axisPt}); + histos.add("V0AssoQA/h3dPAVsIRVsPt_TrueLambda", "h3dPAVsIRVsPt_TrueLambda", kTH3F, {axisPA, axisIRBinning, axisPt}); + histos.add("V0AssoQA/h2dIRVsPt_TrueLambda_BadCollAssig", "h2dIRVsPt_TrueLambda_BadCollAssig", kTH2F, {axisIRBinning, axisPt}); + histos.add("V0AssoQA/h3dPAVsIRVsPt_TrueLambda_BadCollAssig", "h3dPAVsIRVsPt_TrueLambda_BadCollAssig", kTH3F, {axisPA, axisIRBinning, axisPt}); + } // MC - histos.add("MC/h2dPtVsCentrality_GammaBeforeSel", "h2dPtVsCentrality_GammaBeforeSel", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_LambdaBeforeSel", "h2dPtVsCentrality_LambdaBeforeSel", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_AntiLambdaBeforeSel", "h2dPtVsCentrality_AntiLambdaBeforeSel", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_GammaSigma0", "h2dPtVsCentrality_GammaSigma0", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_LambdaSigma0", "h2dPtVsCentrality_LambdaSigma0", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_Sigma0BeforeSel", "h2dPtVsCentrality_Sigma0BeforeSel", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_Sigma0AfterSel", "h2dPtVsCentrality_Sigma0AfterSel", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_AntiSigma0BeforeSel", "h2dPtVsCentrality_AntiSigma0BeforeSel", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_GammaAntiSigma0", "h2dPtVsCentrality_GammaAntiSigma0", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_LambdaAntiSigma0", "h2dPtVsCentrality_LambdaAntiSigma0", kTH2D, {axisCentrality, axisPt}); - histos.add("MC/h2dPtVsCentrality_AntiSigma0AfterSel", "h2dPtVsCentrality_AntiSigma0AfterSel", kTH2D, {axisCentrality, axisPt}); - - // Sigma vs Daughters pT - histos.add("MC/h2dSigmaPtVsLambdaPt", "h2dSigmaPtVsLambdaPt", kTH2D, {axisPt, axisPt}); - histos.add("MC/h2dSigmaPtVsGammaPt", "h2dSigmaPtVsGammaPt", kTH2D, {axisPt, axisPt}); - - // pT Resolution: - histos.add("MC/h2dLambdaPtResolution", "h2dLambdaPtResolution", kTH2D, {axisPt, axisDeltaPt}); - histos.add("MC/h2dGammaPtResolution", "h2dGammaPtResolution", kTH2D, {axisPt, axisDeltaPt}); + if (doprocessMonteCarlo) { + histos.add("MC/h2dPtVsCentralityBeforeSel_MCAssocGamma", "h2dPtVsCentralityBeforeSel_MCAssocGamma", kTH2D, {axisCentrality, axisPt}); + histos.add("MC/h2dPtVsCentralityBeforeSel_MCAssocLambda", "h2dPtVsCentralityBeforeSel_MCAssocLambda", kTH2D, {axisCentrality, axisPt}); + histos.add("MC/h2dPtVsCentralityBeforeSel_MCAssocALambda", "h2dPtVsCentralityBeforeSel_MCAssocALambda", kTH2D, {axisCentrality, axisPt}); + histos.add("MC/h2dPtVsCentralityBeforeSel_MCAssocSigma0", "h2dPtVsCentralityBeforeSel_MCAssocSigma0", kTH2D, {axisCentrality, axisPt}); + histos.add("MC/h2dPtVsCentralityBeforeSel_MCAssocASigma0", "h2dPtVsCentralityBeforeSel_MCAssocASigma0", kTH2D, {axisCentrality, axisPt}); + histos.add("MC/h2dSigma0PtVsLambdaPtBeforeSel_MCAssoc", "h2dSigma0PtVsLambdaPtBeforeSel_MCAssoc", kTH2D, {axisPt, axisPt}); + histos.add("MC/h2dSigma0PtVsGammaPtBeforeSel_MCAssoc", "h2dSigma0PtVsGammaPtBeforeSel_MCAssoc", kTH2D, {axisPt, axisPt}); + histos.add("MC/h2dPtVsCentralityAfterSel_MCAssocSigma0", "h2dPtVsCentralityAfterSel_MCAssocSigma0", kTH2D, {axisCentrality, axisPt}); + histos.add("MC/h2dPtVsCentralityAfterSel_MCAssocASigma0", "h2dPtVsCentralityAfterSel_MCAssocASigma0", kTH2D, {axisCentrality, axisPt}); + histos.add("MC/h2dGammaXYConversion", "h2dGammaXYConversion", kTH2F, {axisXY, axisXY}); + } // For background decomposition - histos.add("MC/h2dPtVsMassSigma_All", "h2dPtVsMassSigma_All", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_SignalOnly", "h2dPtVsMassSigma_SignalOnly", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_TrueDaughters", "h2dPtVsMassSigma_TrueDaughters", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_TrueGammaFakeLambda", "h2dPtVsMassSigma_TrueGammaFakeLambda", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_FakeGammaTrueLambda", "h2dPtVsMassSigma_FakeGammaTrueLambda", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_FakeDaughters", "h2dPtVsMassSigma_FakeDaughters", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dTrueDaughtersMatrix", "h2dTrueDaughtersMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); - histos.add("MC/h2dTrueGammaFakeLambdaMatrix", "h2dTrueGammaFakeLambdaMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); - histos.add("MC/h2dFakeGammaTrueLambdaMatrix", "h2dFakeGammaTrueLambdaMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); - histos.add("MC/h2dFakeDaughtersMatrix", "h2dFakeDaughtersMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); + if (fillBkgQAhistos && doprocessMonteCarlo) { + histos.add("BkgStudy/h2dPtVsMassSigma_All", "h2dPtVsMassSigma_All", kTH2D, {axisPt, axisSigmaMass}); + histos.add("BkgStudy/h2dPtVsMassSigma_TrueDaughters", "h2dPtVsMassSigma_TrueDaughters", kTH2D, {axisPt, axisSigmaMass}); + histos.add("BkgStudy/h2dPtVsMassSigma_TrueGammaFakeLambda", "h2dPtVsMassSigma_TrueGammaFakeLambda", kTH2D, {axisPt, axisSigmaMass}); + histos.add("BkgStudy/h2dPtVsMassSigma_FakeGammaTrueLambda", "h2dPtVsMassSigma_FakeGammaTrueLambda", kTH2D, {axisPt, axisSigmaMass}); + histos.add("BkgStudy/h2dPtVsMassSigma_FakeDaughters", "h2dPtVsMassSigma_FakeDaughters", kTH2D, {axisPt, axisSigmaMass}); + histos.add("BkgStudy/h2dTrueDaughtersMatrix", "h2dTrueDaughtersMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); + histos.add("BkgStudy/h2dTrueGammaFakeLambdaMatrix", "h2dTrueGammaFakeLambdaMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); + histos.add("BkgStudy/h2dFakeGammaTrueLambdaMatrix", "h2dFakeGammaTrueLambdaMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); + histos.add("BkgStudy/h2dFakeDaughtersMatrix", "h2dFakeDaughtersMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); + } // For Pi0 QA - histos.add("MC/h2dPtVsMassPi0BeforeSel_SignalOnly", "h2dPtVsMassPi0BeforeSel_SignalOnly", kTH2D, {axisPt, {500, 0.08f, 0.18f}}); - histos.add("MC/h2dPtVsMassPi0AfterSel_SignalOnly", "h2dPtVsMassPi0AfterSel_SignalOnly", kTH2D, {axisPt, {500, 0.08f, 0.18f}}); + if (doPi0QA) { + histos.add("Pi0QA/h3dMassPi0BeforeSel_MCAssoc", "h3dMassPi0BeforeSel_MCAssoc", kTH3D, {axisCentrality, axisPt, axisPi0Mass}); + histos.add("Pi0QA/h3dMassPi0AfterSel_MCAssoc", "h3dMassPi0AfterSel_MCAssoc", kTH3D, {axisCentrality, axisPt, axisPi0Mass}); + histos.add("Pi0QA/h3dMassPi0BeforeSel_Candidates", "h3dMassPi0BeforeSel_Candidates", kTH3D, {axisCentrality, axisPt, axisPi0Mass}); + histos.add("Pi0QA/h3dMassPi0AfterSel_Candidates", "h3dMassPi0AfterSel_Candidates", kTH3D, {axisCentrality, axisPt, axisPi0Mass}); + } - histos.add("h3dMassSigmasBeforeSel", "h3dMassSigmasBeforeSel", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); - histos.add("h3dMassSigmasAfterSel", "h3dMassSigmasAfterSel", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); + if (doprocessGeneratedRun3) { + + histos.add("Gen/hGenEvents", "hGenEvents", kTH2F, {{axisNch}, {2, -0.5f, +1.5f}}); + histos.get(HIST("Gen/hGenEvents"))->GetYaxis()->SetBinLabel(1, "All gen. events"); + histos.get(HIST("Gen/hGenEvents"))->GetYaxis()->SetBinLabel(2, "Gen. with at least 1 rec. events"); + + histos.add("Gen/hGenEventCentrality", "hGenEventCentrality", kTH1F, {{101, 0.0f, 101.0f}}); + histos.add("Gen/hCentralityVsNcoll_beforeEvSel", "hCentralityVsNcoll_beforeEvSel", kTH2F, {axisCentrality, {50, -0.5f, 49.5f}}); + histos.add("Gen/hCentralityVsNcoll_afterEvSel", "hCentralityVsNcoll_afterEvSel", kTH2F, {axisCentrality, {50, -0.5f, 49.5f}}); + histos.add("Gen/hCentralityVsMultMC", "hCentralityVsMultMC", kTH2F, {{101, 0.0f, 101.0f}, axisNch}); + histos.add("Gen/h2dGenGamma", "h2dGenGamma", kTH2D, {axisCentrality, axisPt}); + histos.add("Gen/h2dGenLambda", "h2dGenLambda", kTH2D, {axisCentrality, axisPt}); + histos.add("Gen/h2dGenAntiLambda", "h2dGenAntiLambda", kTH2D, {axisCentrality, axisPt}); + histos.add("Gen/h2dGenGammaVsMultMC_RecoedEvt", "h2dGenGammaVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("Gen/h2dGenLambdaVsMultMC_RecoedEvt", "h2dGenLambdaVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("Gen/h2dGenAntiLambdaVsMultMC_RecoedEvt", "h2dGenAntiLambdaVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("Gen/h2dGenGammaVsMultMC", "h2dGenGammaVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("Gen/h2dGenLambdaVsMultMC", "h2dGenLambdaVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("Gen/h2dGenAntiLambdaVsMultMC", "h2dGenAntiLambdaVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("Gen/hEventPVzMC", "hEventPVzMC", kTH1F, {{100, -20.0f, +20.0f}}); + histos.add("Gen/hCentralityVsPVzMC", "hCentralityVsPVzMC", kTH2F, {{101, 0.0f, 101.0f}, {100, -20.0f, +20.0f}}); + + auto hPrimaryV0s = histos.add("Gen/hPrimaryV0s", "hPrimaryV0s", kTH1D, {{2, -0.5f, 1.5f}}); + hPrimaryV0s->GetXaxis()->SetBinLabel(1, "All V0s"); + hPrimaryV0s->GetXaxis()->SetBinLabel(2, "Primary V0s"); + } } - template - void runPi0QA(TV0Object const& gamma1, TV0Object const& gamma2) + + template + bool IsEventAccepted(TCollision const& collision, bool fillHists) + // check whether the collision passes our collision selections { + if (fillHists) + histos.fill(HIST("hEventSelection"), 0. /* all collisions */); + if (eventSelections.requireSel8 && !collision.sel8()) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 1 /* sel8 collisions */); + if (eventSelections.requireTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 2 /* FT0 vertex (acceptable FT0C-FT0A time difference) collisions */); + if (eventSelections.rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 3 /* Not at ITS ROF border */); + if (eventSelections.rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 4 /* Not at TF border */); + if (std::abs(collision.posZ()) > eventSelections.maxZVtxPosition) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 5 /* vertex-Z selected */); + if (eventSelections.requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 6 /* Contains at least one ITS-TPC track */); + if (eventSelections.requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 7 /* PV position consistency check */); + if (eventSelections.requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 8 /* PV with at least one contributor matched with TOF */); + if (eventSelections.requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 9 /* PV with at least one contributor matched with TRD */); + if (eventSelections.rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 10 /* Not at same bunch pile-up */); + if (eventSelections.requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 11 /* No other collision within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds*/); + if (eventSelections.requireNoCollInTimeRangeStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 12 /* No other collision within +/- 10 microseconds */); + if (eventSelections.requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 13 /* No other collision within +/- 2 microseconds */); + if (eventSelections.requireNoCollInROFStd && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 14 /* No other collision within the same ITS ROF with mult. above a certain threshold */); + if (eventSelections.requireNoCollInROFStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 15 /* No other collision within the same ITS ROF */); + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && collision.multNTracksPVeta1() < 1) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 16 /* INEL > 0 */); + if (eventSelections.requireINEL1 && collision.multNTracksPVeta1() < 2) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 17 /* INEL > 1 */); + } else { // we are in Pb-Pb + float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + if (eventSelections.minOccupancy >= 0 && collisionOccupancy < eventSelections.minOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 16 /* Below min occupancy */); + if (eventSelections.maxOccupancy >= 0 && collisionOccupancy > eventSelections.maxOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 17 /* Above max occupancy */); + } + // Fetch interaction rate only if required (in order to limit ccdb calls) + double interactionRate = (eventSelections.minIR >= 0 || eventSelections.maxIR >= 0) ? rateFetcher.fetch(ccdb.service, collision.timestamp(), collision.runNumber(), irSource, fIRCrashOnNull) * 1.e-3 : -1; + if (eventSelections.minIR >= 0 && interactionRate < eventSelections.minIR) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 18 /* Below min IR */); + + if (eventSelections.maxIR >= 0 && interactionRate > eventSelections.maxIR) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 19 /* Above max IR */); + + float centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + histos.fill(HIST("hEventCentrality"), centrality); + return true; + } + + void runBkgAnalysis(bool fIsSigma, bool fIsAntiSigma, int PhotonPDGCode, int PhotonPDGCodeMother, int LambdaPDGCode, int LambdaPDGCodeMother, float sigmapT, float sigmaMass) + { + histos.fill(HIST("BkgStudy/h2dPtVsMassSigma_All"), sigmapT, sigmaMass); + + // Real Gamma x Real Lambda - but not from the same sigma0/antisigma0! + if ((PhotonPDGCode == 22) && ((LambdaPDGCode == 3122) || (LambdaPDGCode == -3122)) && (!fIsSigma && !fIsAntiSigma)) { + histos.fill(HIST("BkgStudy/h2dPtVsMassSigma_TrueDaughters"), sigmapT, sigmaMass); + histos.fill(HIST("BkgStudy/h2dTrueDaughtersMatrix"), LambdaPDGCodeMother, PhotonPDGCodeMother); + } + + // Real Gamma x fake Lambda + if ((PhotonPDGCode == 22) && (LambdaPDGCode != 3122) && (LambdaPDGCode != -3122)) { + histos.fill(HIST("BkgStudy/h2dPtVsMassSigma_TrueGammaFakeLambda"), sigmapT, sigmaMass); + histos.fill(HIST("BkgStudy/h2dTrueGammaFakeLambdaMatrix"), LambdaPDGCodeMother, PhotonPDGCodeMother); + } + + // Fake Gamma x Real Lambda + if ((PhotonPDGCode != 22) && ((LambdaPDGCode == 3122) || (LambdaPDGCode == -3122))) { + histos.fill(HIST("BkgStudy/h2dPtVsMassSigma_FakeGammaTrueLambda"), sigmapT, sigmaMass); + histos.fill(HIST("BkgStudy/h2dFakeGammaTrueLambdaMatrix"), LambdaPDGCodeMother, PhotonPDGCodeMother); + } + + // Fake Gamma x Fake Lambda + if ((PhotonPDGCode != 22) && (LambdaPDGCode != 3122) && (LambdaPDGCode != -3122)) { + histos.fill(HIST("BkgStudy/h2dPtVsMassSigma_FakeDaughters"), sigmapT, sigmaMass); + histos.fill(HIST("BkgStudy/h2dFakeDaughtersMatrix"), LambdaPDGCodeMother, PhotonPDGCodeMother); + } + } + + template + void analyzeV0CollAssoc(TCollision const& collision, TV0Object const& fullv0s, std::vector selV0Indices, float IR, bool isPhotonAnalysis) + { + auto v0MCCollision = collision.template straMCCollision_as>(); + + for (size_t i = 0; i < selV0Indices.size(); ++i) { + auto v0 = fullv0s.rawIteratorAt(selV0Indices[i]); + auto v0MC = v0.template v0MCCore_as>(); + + float V0MCpT = RecoDecay::pt(array{v0MC.pxMC(), v0MC.pyMC()}); + float V0PA = TMath::ACos(v0.v0cosPA()); + bool fIsV0CorrectlyAssigned = (v0MC.straMCCollisionId() == v0MCCollision.globalIndex()); + bool isPrimary = v0MC.isPhysicalPrimary(); + + if ((v0MC.pdgCode() == 22) && isPhotonAnalysis && isPrimary) { // True Gamma + histos.fill(HIST("V0AssoQA/h2dIRVsPt_TrueGamma"), IR, V0MCpT); + histos.fill(HIST("V0AssoQA/h3dPAVsIRVsPt_TrueGamma"), V0PA, IR, V0MCpT); + + if (!fIsV0CorrectlyAssigned) { + histos.fill(HIST("V0AssoQA/h2dIRVsPt_TrueGamma_BadCollAssig"), IR, V0MCpT); + histos.fill(HIST("V0AssoQA/h3dPAVsIRVsPt_TrueGamma_BadCollAssig"), V0PA, IR, V0MCpT); + } + } + if ((v0MC.pdgCode() == 3122) && !isPhotonAnalysis && isPrimary) { // True Lambda + histos.fill(HIST("V0AssoQA/h2dIRVsPt_TrueLambda"), IR, V0MCpT); + histos.fill(HIST("V0AssoQA/h3dPAVsIRVsPt_TrueLambda"), V0PA, IR, V0MCpT); + + if (!fIsV0CorrectlyAssigned) { + histos.fill(HIST("V0AssoQA/h2dIRVsPt_TrueLambda_BadCollAssig"), IR, V0MCpT); + histos.fill(HIST("V0AssoQA/h3dPAVsIRVsPt_TrueLambda_BadCollAssig"), V0PA, IR, V0MCpT); + } + } + } + } + + // ______________________________________________________ + // Simulated processing + // Return the list of indices to the recoed collision associated to a given MC collision. + template + std::vector getListOfRecoCollIndices(TMCollisions const& mcCollisions, TCollisions const& collisions) + { + std::vector listBestCollisionIdx(mcCollisions.size()); + for (auto const& mcCollision : mcCollisions) { + auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex()); + int biggestNContribs = -1; + int bestCollisionIndex = -1; + for (auto const& collision : groupedCollisions) { + // consider event selections in the recoed <-> gen collision association, for the denominator (or numerator) of the efficiency (or signal loss)? + if (eventSelections.useEvtSelInDenomEff) { + if (!IsEventAccepted(collision, false)) { + continue; + } + } + // Find the collision with the biggest nbr of PV contributors + // Follows what was done here: https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/mcCollsExtra.cxx#L93 + if (biggestNContribs < collision.multPVTotalContributors()) { + biggestNContribs = collision.multPVTotalContributors(); + bestCollisionIndex = collision.globalIndex(); + } + } + listBestCollisionIdx[mcCollision.globalIndex()] = bestCollisionIndex; + } + return listBestCollisionIdx; + } + + // ______________________________________________________ + // Simulated processing + // Fill generated event information (for event loss/splitting estimation) + template + void fillGeneratedEventProperties(TMCCollisions const& mcCollisions, TCollisions const& collisions) + { + std::vector listBestCollisionIdx(mcCollisions.size()); + for (auto const& mcCollision : mcCollisions) { + // Apply selections on MC collisions + if (eventSelections.applyZVtxSelOnMCPV && std::abs(mcCollision.posZ()) > eventSelections.maxZVtxPosition) { + continue; + } + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && mcCollision.multMCNParticlesEta10() < 1) { + continue; + } + + if (eventSelections.requireINEL1 && mcCollision.multMCNParticlesEta10() < 2) { + continue; + } + } + + histos.fill(HIST("Gen/hGenEvents"), mcCollision.multMCNParticlesEta05(), 0 /* all gen. events*/); + + auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex()); + // Check if there is at least one of the reconstructed collisions associated to this MC collision + // If so, we consider it + bool atLeastOne = false; + int biggestNContribs = -1; + float centrality = 100.5f; + int nCollisions = 0; + for (auto const& collision : groupedCollisions) { + + if (!IsEventAccepted(collision, false)) { + continue; + } + + if (biggestNContribs < collision.multPVTotalContributors()) { + biggestNContribs = collision.multPVTotalContributors(); + centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + } + + nCollisions++; + atLeastOne = true; + } + + histos.fill(HIST("Gen/hCentralityVsNcoll_beforeEvSel"), centrality, groupedCollisions.size()); + histos.fill(HIST("Gen/hCentralityVsNcoll_afterEvSel"), centrality, nCollisions); + histos.fill(HIST("Gen/hCentralityVsMultMC"), centrality, mcCollision.multMCNParticlesEta05()); + histos.fill(HIST("Gen/hCentralityVsPVzMC"), centrality, mcCollision.posZ()); + histos.fill(HIST("Gen/hEventPVzMC"), mcCollision.posZ()); + + if (atLeastOne) { + histos.fill(HIST("Gen/hGenEvents"), mcCollision.multMCNParticlesEta05(), 1 /* at least 1 rec. event*/); + histos.fill(HIST("Gen/hGenEventCentrality"), centrality); + } + } + return; + } + + // ______________________________________________________ + // Simulated processing (subscribes to MC information too) + template + void analyzeGeneratedV0s(TMCCollisions const& mcCollisions, TV0MCs const& V0MCCores, TCollisions const& collisions) + { + fillGeneratedEventProperties(mcCollisions, collisions); + std::vector listBestCollisionIdx = getListOfRecoCollIndices(mcCollisions, collisions); + for (auto const& v0MC : V0MCCores) { + if (!v0MC.has_straMCCollision()) + continue; + + histos.fill(HIST("Gen/hPrimaryV0s"), 0); + if (!v0MC.isPhysicalPrimary()) + continue; + + histos.fill(HIST("Gen/hPrimaryV0s"), 1); + + // TODO: get generated sigma0s + + float ptmc = v0MC.ptMC(); + float ymc = 1e3; + if (v0MC.pdgCode() == 22) + ymc = RecoDecay::y(std::array{v0MC.pxMC(), v0MC.pyMC(), v0MC.pzMC()}, o2::constants::physics::MassGamma); + + else if (std::abs(v0MC.pdgCode()) == 3122) + ymc = v0MC.rapidityMC(1); + + if (std::abs(ymc) > V0Rapidity) + continue; + + auto mcCollision = v0MC.template straMCCollision_as>(); + if (eventSelections.applyZVtxSelOnMCPV && std::abs(mcCollision.posZ()) > eventSelections.maxZVtxPosition) { + continue; + } + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && mcCollision.multMCNParticlesEta10() < 1) { + continue; + } + + if (eventSelections.requireINEL1 && mcCollision.multMCNParticlesEta10() < 2) { + continue; + } + } + + float centrality = 100.5f; + if (listBestCollisionIdx[mcCollision.globalIndex()] > -1) { + auto collision = collisions.iteratorAt(listBestCollisionIdx[mcCollision.globalIndex()]); + centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + + if (v0MC.pdgCode() == 22) { + histos.fill(HIST("Gen/h2dGenGammaVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == 3122) { + histos.fill(HIST("Gen/h2dGenLambdaVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == -3122) { + histos.fill(HIST("Gen/h2dGenAntiLambdaVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + } + if (v0MC.pdgCode() == 22) { + histos.fill(HIST("Gen/h2dGenGamma"), centrality, ptmc); + histos.fill(HIST("Gen/h2dGenGammaVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == 3122) { + histos.fill(HIST("Gen/h2dGenLambda"), centrality, ptmc); + histos.fill(HIST("Gen/h2dGenLambdaVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == -3122) { + histos.fill(HIST("Gen/h2dGenAntiLambda"), centrality, ptmc); + histos.fill(HIST("Gen/h2dGenAntiLambdaVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + } + } + template + void runPi0QA(TV0Object const& gamma1, TV0Object const& gamma2, TCollision collision) + { // Check if both V0s are made of the same tracks if (gamma1.posTrackExtraId() == gamma2.posTrackExtraId() || - gamma1.negTrackExtraId() == gamma2.negTrackExtraId() || - gamma1.posTrackExtraId() == gamma2.negTrackExtraId() || - gamma1.negTrackExtraId() == gamma2.posTrackExtraId()) { + gamma1.negTrackExtraId() == gamma2.negTrackExtraId()) { return; } @@ -250,23 +752,29 @@ struct sigma0builder { float pi0Mass = RecoDecay::m(arrpi0, std::array{o2::constants::physics::MassPhoton, o2::constants::physics::MassPhoton}); float pi0Pt = RecoDecay::pt(std::array{gamma1.px() + gamma2.px(), gamma1.py() + gamma2.py()}); float pi0Y = RecoDecay::y(std::array{gamma1.px() + gamma2.px(), gamma1.py() + gamma2.py(), gamma1.pz() + gamma2.pz()}, o2::constants::physics::MassPi0); + float centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); // MC-specific variables bool fIsPi0 = false, fIsMC = false; // Check if MC data and populate fIsMC, fIsPi0 - if constexpr (requires { gamma1.pdgCode(); gamma2.pdgCode(); }) { - fIsMC = true; - if (gamma1.pdgCode() == 22 && gamma2.pdgCode() == 22 && - gamma1.pdgCodeMother() == 111 && gamma2.pdgCodeMother() == 111 && - gamma1.motherMCPartId() == gamma2.motherMCPartId()) { - fIsPi0 = true; - histos.fill(HIST("MC/h2dPtVsMassPi0BeforeSel_SignalOnly"), pi0Pt, pi0Mass); + if constexpr (requires { gamma1.motherMCPartId(); gamma2.motherMCPartId(); }) { + if (gamma1.has_v0MCCore() && gamma2.has_v0MCCore()) { + fIsMC = true; + auto gamma1MC = gamma1.template v0MCCore_as>(); + auto gamma2MC = gamma2.template v0MCCore_as>(); + + if (gamma1MC.pdgCode() == 22 && gamma2MC.pdgCode() == 22 && + gamma1MC.pdgCodeMother() == 111 && gamma2MC.pdgCodeMother() == 111 && + gamma1.motherMCPartId() == gamma2.motherMCPartId()) { + fIsPi0 = true; + histos.fill(HIST("Pi0QA/h3dMassPi0BeforeSel_MCAssoc"), centrality, pi0Pt, pi0Mass); + } } - } else { - histos.fill(HIST("GeneralQA/h2dPtVsMassPi0BeforeSel_Candidates"), pi0Pt, pi0Mass); } + histos.fill(HIST("Pi0QA/h3dMassPi0BeforeSel_Candidates"), centrality, pi0Pt, pi0Mass); + // Photon-specific selections auto posTrackGamma1 = gamma1.template posTrackExtra_as(); auto negTrackGamma1 = gamma1.template negTrackExtra_as(); @@ -274,8 +782,8 @@ struct sigma0builder { auto negTrackGamma2 = gamma2.template negTrackExtra_as(); // Gamma1 Selection - bool passedTPCGamma1 = (posTrackGamma1.tpcNSigmaEl() == -999.f || TMath::Abs(posTrackGamma1.tpcNSigmaEl()) < Pi0PhotonMaxTPCNSigmas) && - (negTrackGamma1.tpcNSigmaEl() == -999.f || TMath::Abs(negTrackGamma1.tpcNSigmaEl()) < Pi0PhotonMaxTPCNSigmas); + bool passedTPCGamma1 = (TMath::Abs(posTrackGamma1.tpcNSigmaEl()) < Pi0PhotonMaxTPCNSigmas) || + (TMath::Abs(negTrackGamma1.tpcNSigmaEl()) < Pi0PhotonMaxTPCNSigmas); if (TMath::Abs(gamma1.mGamma()) > Pi0PhotonMaxMass || gamma1.qtarm() >= Pi0PhotonMaxQt || @@ -295,8 +803,8 @@ struct sigma0builder { } // Gamma2 Selection - bool passedTPCGamma2 = (posTrackGamma2.tpcNSigmaEl() == -999.f || TMath::Abs(posTrackGamma2.tpcNSigmaEl()) < Pi0PhotonMaxTPCNSigmas) && - (negTrackGamma2.tpcNSigmaEl() == -999.f || TMath::Abs(negTrackGamma2.tpcNSigmaEl()) < Pi0PhotonMaxTPCNSigmas); + bool passedTPCGamma2 = (TMath::Abs(posTrackGamma2.tpcNSigmaEl()) < Pi0PhotonMaxTPCNSigmas) || + (TMath::Abs(negTrackGamma2.tpcNSigmaEl()) < Pi0PhotonMaxTPCNSigmas); if (TMath::Abs(gamma2.mGamma()) > Pi0PhotonMaxMass || gamma2.qtarm() >= Pi0PhotonMaxQt || @@ -321,148 +829,159 @@ struct sigma0builder { } // Fill histograms - if (fIsMC) { - if (fIsPi0) - histos.fill(HIST("MC/h2dPtVsMassPi0AfterSel_SignalOnly"), pi0Pt, pi0Mass); - } else { - histos.fill(HIST("GeneralQA/h2dPtVsMassPi0AfterSel_Candidates"), pi0Pt, pi0Mass); - } + histos.fill(HIST("Pi0QA/h3dMassPi0AfterSel_Candidates"), centrality, pi0Pt, pi0Mass); + if (fIsMC && fIsPi0) + histos.fill(HIST("Pi0QA/h3dMassPi0AfterSel_MCAssoc"), centrality, pi0Pt, pi0Mass); } - // Process sigma candidate and store properties in object - template - bool processSigmaCandidate(TV0Object const& lambda, TV0Object const& gamma) + // Process photon candidate + template + bool processPhotonCandidate(TV0Object const& gamma, TCollision collision) { - if ((lambda.v0Type() == 0) || (gamma.v0Type() == 0)) - return false; - - // Checking if both V0s are made of the very same tracks - if ((gamma.posTrackExtraId() == lambda.posTrackExtraId()) || (gamma.negTrackExtraId() == lambda.negTrackExtraId()) || (gamma.posTrackExtraId() == lambda.negTrackExtraId()) || (gamma.negTrackExtraId() == lambda.posTrackExtraId()) || (gamma.posTrackExtraId() == lambda.negTrackExtraId())) + if (gamma.v0Type() == 0) return false; - if constexpr ( - requires { gamma.gammaBDTScore(); } && - requires { lambda.lambdaBDTScore(); } && - requires { lambda.antiLambdaBDTScore(); }) { - - LOGF(info, "X-check: ML Selection is on!"); + if (useMLScores) { // Gamma selection: if (gamma.gammaBDTScore() <= Gamma_MLThreshold) return false; - // Lambda and AntiLambda selection - if ((lambda.lambdaBDTScore() <= Lambda_MLThreshold) && (lambda.antiLambdaBDTScore() <= AntiLambda_MLThreshold)) - return false; - } else { // Standard selection // Gamma basic selection criteria: - histos.fill(HIST("hCandidateBuilderSelection"), 1.); - histos.fill(HIST("Selection/hPhotonMass"), gamma.mGamma()); + histos.fill(HIST("PhotonSel/hSelectionStatistics"), 1.); + histos.fill(HIST("PhotonSel/hPhotonMass"), gamma.mGamma()); if ((gamma.mGamma() < 0) || (gamma.mGamma() > PhotonMaxMass)) return false; - histos.fill(HIST("Selection/hPhotonNegEta"), gamma.negativeeta()); - histos.fill(HIST("Selection/hPhotonPosEta"), gamma.positiveeta()); - histos.fill(HIST("hCandidateBuilderSelection"), 2.); - if ((TMath::Abs(gamma.negativeeta()) > PhotonMaxDauPseudoRap) || (TMath::Abs(gamma.positiveeta()) > PhotonMaxDauPseudoRap)) + float PhotonY = RecoDecay::y(std::array{gamma.px(), gamma.py(), gamma.pz()}, o2::constants::physics::MassGamma); + histos.fill(HIST("PhotonSel/hPhotonNegEta"), gamma.negativeeta()); + histos.fill(HIST("PhotonSel/hPhotonPosEta"), gamma.positiveeta()); + histos.fill(HIST("PhotonSel/hPhotonY"), PhotonY); + histos.fill(HIST("PhotonSel/hSelectionStatistics"), 2.); + if ((TMath::Abs(PhotonY) > V0Rapidity) || (TMath::Abs(gamma.negativeeta()) > PhotonMaxDauPseudoRap) || (TMath::Abs(gamma.positiveeta()) > PhotonMaxDauPseudoRap)) return false; - histos.fill(HIST("Selection/hPhotonDCANegToPV"), TMath::Abs(gamma.dcanegtopv())); - histos.fill(HIST("Selection/hPhotonDCAPosToPV"), TMath::Abs(gamma.dcapostopv())); - histos.fill(HIST("hCandidateBuilderSelection"), 3.); + histos.fill(HIST("PhotonSel/hPhotonDCANegToPV"), TMath::Abs(gamma.dcanegtopv())); + histos.fill(HIST("PhotonSel/hPhotonDCAPosToPV"), TMath::Abs(gamma.dcapostopv())); + histos.fill(HIST("PhotonSel/hSelectionStatistics"), 3.); if ((TMath::Abs(gamma.dcapostopv()) < PhotonMinDCAToPv) || (TMath::Abs(gamma.dcanegtopv()) < PhotonMinDCAToPv)) return false; - histos.fill(HIST("Selection/hPhotonDCADau"), TMath::Abs(gamma.dcaV0daughters())); - histos.fill(HIST("hCandidateBuilderSelection"), 4.); + histos.fill(HIST("PhotonSel/hPhotonDCADau"), TMath::Abs(gamma.dcaV0daughters())); + histos.fill(HIST("PhotonSel/hSelectionStatistics"), 4.); if (TMath::Abs(gamma.dcaV0daughters()) > PhotonMaxDCAV0Dau) return false; - histos.fill(HIST("Selection/hPhotonRadius"), gamma.v0radius()); - histos.fill(HIST("hCandidateBuilderSelection"), 5.); + histos.fill(HIST("PhotonSel/hPhotonRadius"), gamma.v0radius()); + histos.fill(HIST("PhotonSel/hSelectionStatistics"), 5.); if ((gamma.v0radius() < PhotonMinRadius) || (gamma.v0radius() > PhotonMaxRadius)) return false; + histos.fill(HIST("PhotonSel/hSelectionStatistics"), 6.); + } + float centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + histos.fill(HIST("PhotonSel/h3dPhotonMass"), centrality, gamma.pt(), gamma.mGamma()); + return true; + } + + // Process photon candidate + template + bool processLambdaCandidate(TV0Object const& lambda, TCollision collision) + { + if (lambda.v0Type() != 1) + return false; + + if (useMLScores) { + if ((lambda.lambdaBDTScore() <= Lambda_MLThreshold) && (lambda.antiLambdaBDTScore() <= AntiLambda_MLThreshold)) + return false; - histos.fill(HIST("hCandidateBuilderSelection"), 6.); - histos.fill(HIST("Selection/hLambdaMass"), lambda.mLambda()); - histos.fill(HIST("Selection/hAntiLambdaMass"), lambda.mAntiLambda()); + } else { // Lambda basic selection criteria: - if ((TMath::Abs(lambda.mLambda() - 1.115683) > LambdaWindow) && (TMath::Abs(lambda.mAntiLambda() - 1.115683) > LambdaWindow)) + histos.fill(HIST("LambdaSel/hSelectionStatistics"), 1.); + histos.fill(HIST("LambdaSel/hLambdaMass"), lambda.mLambda()); + histos.fill(HIST("LambdaSel/hAntiLambdaMass"), lambda.mAntiLambda()); + if ((TMath::Abs(lambda.mLambda() - o2::constants::physics::MassLambda0) > LambdaWindow) && (TMath::Abs(lambda.mAntiLambda() - o2::constants::physics::MassLambda0) > LambdaWindow)) return false; - histos.fill(HIST("Selection/hLambdaNegEta"), lambda.negativeeta()); - histos.fill(HIST("Selection/hLambdaPosEta"), lambda.positiveeta()); - histos.fill(HIST("hCandidateBuilderSelection"), 7.); - if ((TMath::Abs(lambda.negativeeta()) > LambdaDauPseudoRap) || (TMath::Abs(lambda.positiveeta()) > LambdaDauPseudoRap)) + histos.fill(HIST("LambdaSel/hLambdaNegEta"), lambda.negativeeta()); + histos.fill(HIST("LambdaSel/hLambdaPosEta"), lambda.positiveeta()); + histos.fill(HIST("LambdaSel/hLambdaY"), lambda.yLambda()); + histos.fill(HIST("LambdaSel/hSelectionStatistics"), 2.); + if ((TMath::Abs(lambda.yLambda()) > V0Rapidity) || (TMath::Abs(lambda.negativeeta()) > LambdaDauPseudoRap) || (TMath::Abs(lambda.positiveeta()) > LambdaDauPseudoRap)) return false; - histos.fill(HIST("Selection/hLambdaDCANegToPV"), lambda.dcanegtopv()); - histos.fill(HIST("Selection/hLambdaDCAPosToPV"), lambda.dcapostopv()); - histos.fill(HIST("hCandidateBuilderSelection"), 8.); + histos.fill(HIST("LambdaSel/hLambdaDCANegToPV"), lambda.dcanegtopv()); + histos.fill(HIST("LambdaSel/hLambdaDCAPosToPV"), lambda.dcapostopv()); + histos.fill(HIST("LambdaSel/hSelectionStatistics"), 3.); if ((TMath::Abs(lambda.dcapostopv()) < LambdaMinDCAPosToPv) || (TMath::Abs(lambda.dcanegtopv()) < LambdaMinDCANegToPv)) return false; - histos.fill(HIST("Selection/hLambdaRadius"), lambda.v0radius()); - histos.fill(HIST("hCandidateBuilderSelection"), 9.); + histos.fill(HIST("LambdaSel/hLambdaRadius"), lambda.v0radius()); + histos.fill(HIST("LambdaSel/hSelectionStatistics"), 4.); if ((lambda.v0radius() < LambdaMinv0radius) || (lambda.v0radius() > LambdaMaxv0radius)) return false; - histos.fill(HIST("Selection/hLambdaDCADau"), lambda.dcaV0daughters()); - histos.fill(HIST("hCandidateBuilderSelection"), 10.); + histos.fill(HIST("LambdaSel/hLambdaDCADau"), lambda.dcaV0daughters()); + histos.fill(HIST("LambdaSel/hSelectionStatistics"), 5.); if (TMath::Abs(lambda.dcaV0daughters()) > LambdaMaxDCAV0Dau) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 11.); + histos.fill(HIST("LambdaSel/hSelectionStatistics"), 6.); + } + + float centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + histos.fill(HIST("LambdaSel/h3dLambdaMass"), centrality, lambda.pt(), lambda.mLambda()); + histos.fill(HIST("LambdaSel/h3dALambdaMass"), centrality, lambda.pt(), lambda.mAntiLambda()); + + return true; + } + /////////// + // Process sigma candidate and store properties in object + template + bool buildSigma0(TV0Object const& lambda, TV0Object const& gamma, TCollision collision) + { + // Checking if both V0s are made of the very same tracks + if (gamma.posTrackExtraId() == lambda.posTrackExtraId() || + gamma.negTrackExtraId() == lambda.negTrackExtraId()) { + return false; } + // Sigma0 candidate properties std::array pVecPhotons{gamma.px(), gamma.py(), gamma.pz()}; std::array pVecLambda{lambda.px(), lambda.py(), lambda.pz()}; auto arrMom = std::array{pVecPhotons, pVecLambda}; - float sigmamass = RecoDecay::m(arrMom, std::array{o2::constants::physics::MassPhoton, o2::constants::physics::MassLambda0}); - float sigmarap = RecoDecay::y(std::array{gamma.px() + lambda.px(), gamma.py() + lambda.py(), gamma.pz() + lambda.pz()}, o2::constants::physics::MassSigma0); + float sigmaMass = RecoDecay::m(arrMom, std::array{o2::constants::physics::MassPhoton, o2::constants::physics::MassLambda0}); + float sigmaY = RecoDecay::y(std::array{gamma.px() + lambda.px(), gamma.py() + lambda.py(), gamma.pz() + lambda.pz()}, o2::constants::physics::MassSigma0); float SigmapT = RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()}); + float centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); - histos.fill(HIST("Selection/hSigmaMass"), sigmamass); - histos.fill(HIST("Selection/hSigmaMassWindow"), sigmamass - 1.192642); - histos.fill(HIST("GeneralQA/h2dMassGammaVsK0S"), gamma.mGamma(), gamma.mK0Short()); - histos.fill(HIST("GeneralQA/h2dMassLambdaVsK0S"), lambda.mLambda(), lambda.mK0Short()); - histos.fill(HIST("GeneralQA/h2dMassGammaVsLambda"), gamma.mGamma(), lambda.mLambda()); - histos.fill(HIST("GeneralQA/h3dMassSigma0VsDaupTs"), gamma.pt(), lambda.pt(), sigmamass); - - if constexpr (requires { gamma.pdgCode(); } && requires { lambda.pdgCode(); }) { + // Before any selection + histos.fill(HIST("SigmaSel/h3dMassSigma0BeforeSel"), centrality, SigmapT, sigmaMass); - histos.fill(HIST("MC/h2dPtVsMassSigma_All"), SigmapT, sigmamass); + histos.fill(HIST("SigmaSel/hSelectionStatistics"), 1.); + histos.fill(HIST("SigmaSel/hSigmaMass"), sigmaMass); + histos.fill(HIST("SigmaSel/hSigmaMassWindow"), sigmaMass - 1.192642); - // Real Gamma x Real Lambda - but not from the same sigma0/antisigma0! - if ((gamma.pdgCode() == 22) && ((lambda.pdgCode() == 3122) || (lambda.pdgCode() == -3122)) && (gamma.motherMCPartId() != lambda.motherMCPartId())) { - histos.fill(HIST("MC/h2dPtVsMassSigma_TrueDaughters"), SigmapT, sigmamass); - histos.fill(HIST("MC/h2dTrueDaughtersMatrix"), lambda.pdgCodeMother(), gamma.pdgCodeMother()); - } - - // Real Gamma x fake Lambda - if ((gamma.pdgCode() == 22) && (lambda.pdgCode() != 3122) && (lambda.pdgCode() != -3122)) { - histos.fill(HIST("MC/h2dPtVsMassSigma_TrueGammaFakeLambda"), SigmapT, sigmamass); - histos.fill(HIST("MC/h2dTrueGammaFakeLambdaMatrix"), lambda.pdgCodeMother(), gamma.pdgCodeMother()); - } - - // Fake Gamma x Real Lambda - if ((gamma.pdgCode() != 22) && ((lambda.pdgCode() == 3122) || (lambda.pdgCode() == -3122))) { - histos.fill(HIST("MC/h2dPtVsMassSigma_FakeGammaTrueLambda"), SigmapT, sigmamass); - histos.fill(HIST("MC/h2dFakeGammaTrueLambdaMatrix"), lambda.pdgCodeMother(), gamma.pdgCodeMother()); - } - - // Fake Gamma x Fake Lambda - if ((gamma.pdgCode() != 22) && (lambda.pdgCode() != 3122) && (lambda.pdgCode() != -3122)) { - histos.fill(HIST("MC/h2dPtVsMassSigma_FakeDaughters"), SigmapT, sigmamass); - histos.fill(HIST("MC/h2dFakeDaughtersMatrix"), lambda.pdgCodeMother(), gamma.pdgCodeMother()); - } + if (fillQAhistos) { + histos.fill(HIST("GeneralQA/h2dMassGammaVsK0S"), gamma.mGamma(), gamma.mK0Short()); + histos.fill(HIST("GeneralQA/h2dMassLambdaVsK0S"), lambda.mLambda(), lambda.mK0Short()); + histos.fill(HIST("GeneralQA/h2dMassGammaVsLambda"), gamma.mGamma(), gamma.mLambda()); + histos.fill(HIST("GeneralQA/h2dMassLambdaVsGamma"), lambda.mLambda(), lambda.mGamma()); + histos.fill(HIST("GeneralQA/h3dMassSigma0VsDaupTs"), gamma.pt(), lambda.pt(), sigmaMass); } - if (TMath::Abs(sigmamass - 1.192642) > Sigma0Window) + if (TMath::Abs(sigmaMass - 1.192642) > Sigma0Window) return false; - histos.fill(HIST("GeneralQA/h2dMassGammaVsK0SAfterMassSel"), gamma.mGamma(), gamma.mK0Short()); - histos.fill(HIST("GeneralQA/h2dMassLambdaVsK0SAfterMassSel"), lambda.mLambda(), lambda.mK0Short()); - histos.fill(HIST("GeneralQA/h2dMassGammaVsLambdaAfterMassSel"), gamma.mGamma(), lambda.mLambda()); - histos.fill(HIST("Selection/hSigmaY"), sigmarap); - histos.fill(HIST("hCandidateBuilderSelection"), 12.); + histos.fill(HIST("SigmaSel/hSigmaY"), sigmaY); + histos.fill(HIST("SigmaSel/hSelectionStatistics"), 2.); - if (TMath::Abs(sigmarap) > SigmaMaxRap) + if (TMath::Abs(sigmaY) > SigmaMaxRap) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 13.); + histos.fill(HIST("SigmaSel/hSigmaMassSelected"), sigmaMass); + histos.fill(HIST("SigmaSel/hSelectionStatistics"), 3.); + + if (fillQAhistos) { + histos.fill(HIST("GeneralQA/h2dMassGammaVsK0SAfterMassSel"), gamma.mGamma(), gamma.mK0Short()); + histos.fill(HIST("GeneralQA/h2dMassLambdaVsK0SAfterMassSel"), lambda.mLambda(), lambda.mK0Short()); + histos.fill(HIST("GeneralQA/h2dMassGammaVsLambdaAfterMassSel"), gamma.mGamma(), lambda.mLambda()); + histos.fill(HIST("GeneralQA/h2dV0XY"), gamma.x(), gamma.y()); + } + + histos.fill(HIST("SigmaSel/h3dMassSigma0AfterSel"), centrality, SigmapT, sigmaMass); + return true; } @@ -470,20 +989,9 @@ struct sigma0builder { template void fillTables(TV0Object const& lambda, TV0Object const& gamma, TCollision const& coll) { - - float GammaBDTScore = -1; - float LambdaBDTScore = -1; - float AntiLambdaBDTScore = -1; - - if constexpr ( - requires { gamma.gammaBDTScore(); } && - requires { lambda.lambdaBDTScore(); } && - requires { lambda.antiLambdaBDTScore(); }) { - - GammaBDTScore = gamma.gammaBDTScore(); - LambdaBDTScore = lambda.lambdaBDTScore(); - AntiLambdaBDTScore = lambda.antiLambdaBDTScore(); - } + float GammaBDTScore = gamma.gammaBDTScore(); + float LambdaBDTScore = lambda.lambdaBDTScore(); + float AntiLambdaBDTScore = lambda.antiLambdaBDTScore(); // Daughters related /// Photon @@ -503,8 +1011,10 @@ struct sigma0builder { float fPhotonEta = gamma.eta(); float fPhotonY = RecoDecay::y(std::array{gamma.px(), gamma.py(), gamma.pz()}, o2::constants::physics::MassGamma); float fPhotonPhi = RecoDecay::phi(gamma.px(), gamma.py()); - float fPhotonPosTPCNSigma = posTrackGamma.tpcNSigmaEl(); - float fPhotonNegTPCNSigma = negTrackGamma.tpcNSigmaEl(); + float fPhotonPosTPCNSigmaEl = posTrackGamma.tpcNSigmaEl(); + float fPhotonNegTPCNSigmaEl = negTrackGamma.tpcNSigmaEl(); + float fPhotonPosTPCNSigmaPi = posTrackGamma.tpcNSigmaPi(); + float fPhotonNegTPCNSigmaPi = negTrackGamma.tpcNSigmaPi(); uint8_t fPhotonPosTPCCrossedRows = posTrackGamma.tpcCrossedRows(); uint8_t fPhotonNegTPCCrossedRows = negTrackGamma.tpcCrossedRows(); float fPhotonPosPt = gamma.positivept(); @@ -516,10 +1026,22 @@ struct sigma0builder { float fPhotonPsiPair = gamma.psipair(); int fPhotonPosITSCls = posTrackGamma.itsNCls(); int fPhotonNegITSCls = negTrackGamma.itsNCls(); - uint32_t fPhotonPosITSClSize = posTrackGamma.itsClusterSizes(); - uint32_t fPhotonNegITSClSize = negTrackGamma.itsClusterSizes(); + float fPhotonPosITSChi2PerNcl = posTrackGamma.itsChi2PerNcl(); + float fPhotonNegITSChi2PerNcl = negTrackGamma.itsChi2PerNcl(); uint8_t fPhotonV0Type = gamma.v0Type(); + uint8_t fPhotonPosTrackCode = ((uint8_t(posTrackGamma.hasTPC()) << hasTPC) | + (uint8_t(posTrackGamma.hasITSTracker()) << hasITSTracker) | + (uint8_t(posTrackGamma.hasITSAfterburner()) << hasITSAfterburner) | + (uint8_t(posTrackGamma.hasTRD()) << hasTRD) | + (uint8_t(posTrackGamma.hasTOF()) << hasTOF)); + + uint8_t fPhotonNegTrackCode = ((uint8_t(negTrackGamma.hasTPC()) << hasTPC) | + (uint8_t(negTrackGamma.hasITSTracker()) << hasITSTracker) | + (uint8_t(negTrackGamma.hasITSAfterburner()) << hasITSAfterburner) | + (uint8_t(negTrackGamma.hasTRD()) << hasTRD) | + (uint8_t(negTrackGamma.hasTOF()) << hasTOF)); + // Lambda auto posTrackLambda = lambda.template posTrackExtra_as(); auto negTrackLambda = lambda.template negTrackExtra_as(); @@ -529,6 +1051,7 @@ struct sigma0builder { float fAntiLambdaMass = lambda.mAntiLambda(); float fLambdaQt = lambda.qtarm(); float fLambdaAlpha = lambda.alpha(); + float fLambdaLifeTime = lambda.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0; float fLambdaRadius = lambda.v0radius(); float fLambdaCosPA = lambda.v0cosPA(); float fLambdaDCADau = lambda.dcaV0daughters(); @@ -559,10 +1082,22 @@ struct sigma0builder { float fLambdaNegPiY = RecoDecay::y(std::array{lambda.pxneg(), lambda.pyneg(), lambda.pzneg()}, o2::constants::physics::MassPionCharged); int fLambdaPosITSCls = posTrackLambda.itsNCls(); int fLambdaNegITSCls = negTrackLambda.itsNCls(); - uint32_t fLambdaPosITSClSize = posTrackLambda.itsClusterSizes(); - uint32_t fLambdaNegITSClSize = negTrackLambda.itsClusterSizes(); + float fLambdaPosITSChi2PerNcl = posTrackLambda.itsChi2PerNcl(); + float fLambdaNegITSChi2PerNcl = negTrackLambda.itsChi2PerNcl(); uint8_t fLambdaV0Type = lambda.v0Type(); + uint8_t fLambdaPosTrackCode = ((uint8_t(posTrackLambda.hasTPC()) << hasTPC) | + (uint8_t(posTrackLambda.hasITSTracker()) << hasITSTracker) | + (uint8_t(posTrackLambda.hasITSAfterburner()) << hasITSAfterburner) | + (uint8_t(posTrackLambda.hasTRD()) << hasTRD) | + (uint8_t(posTrackLambda.hasTOF()) << hasTOF)); + + uint8_t fLambdaNegTrackCode = ((uint8_t(negTrackLambda.hasTPC()) << hasTPC) | + (uint8_t(negTrackLambda.hasITSTracker()) << hasITSTracker) | + (uint8_t(negTrackLambda.hasITSAfterburner()) << hasITSAfterburner) | + (uint8_t(negTrackLambda.hasTRD()) << hasTRD) | + (uint8_t(negTrackLambda.hasTOF()) << hasTOF)); + // Sigma0 candidate properties std::array pVecPhotons{gamma.px(), gamma.py(), gamma.pz()}; std::array pVecLambda{lambda.px(), lambda.py(), lambda.pz()}; @@ -575,80 +1110,146 @@ struct sigma0builder { float fSigmaMass = RecoDecay::m(arrMom, std::array{o2::constants::physics::MassPhoton, o2::constants::physics::MassLambda0}); float fSigmaRap = RecoDecay::y(std::array{gamma.px() + lambda.px(), gamma.py() + lambda.py(), gamma.pz() + lambda.pz()}, o2::constants::physics::MassSigma0); float fSigmaOPAngle = v1.Angle(v2); - float fSigmaCentrality = coll.centFT0C(); + float fSigmaCentrality = doPPAnalysis ? coll.centFT0M() : coll.centFT0C(); + uint64_t fSigmaTimeStamp = coll.timestamp(); + int fSigmaRunNumber = coll.runNumber(); // Filling TTree for ML analysis - sigma0cores(fSigmapT, fSigmaMass, fSigmaRap, fSigmaOPAngle, fSigmaCentrality); + sigma0cores(fSigmapT, fSigmaMass, fSigmaRap, fSigmaOPAngle, fSigmaCentrality, fSigmaRunNumber, fSigmaTimeStamp); sigmaPhotonExtras(fPhotonPt, fPhotonMass, fPhotonQt, fPhotonAlpha, fPhotonRadius, fPhotonCosPA, fPhotonDCADau, fPhotonDCANegPV, fPhotonDCAPosPV, fPhotonZconv, - fPhotonEta, fPhotonY, fPhotonPhi, fPhotonPosTPCNSigma, fPhotonNegTPCNSigma, fPhotonPosTPCCrossedRows, + fPhotonEta, fPhotonY, fPhotonPhi, fPhotonPosTPCNSigmaEl, fPhotonNegTPCNSigmaEl, fPhotonPosTPCNSigmaPi, fPhotonNegTPCNSigmaPi, fPhotonPosTPCCrossedRows, fPhotonNegTPCCrossedRows, fPhotonPosPt, fPhotonNegPt, fPhotonPosEta, fPhotonNegEta, fPhotonPosY, fPhotonNegY, fPhotonPsiPair, - fPhotonPosITSCls, fPhotonNegITSCls, fPhotonPosITSClSize, fPhotonNegITSClSize, + fPhotonPosITSCls, fPhotonNegITSCls, fPhotonPosITSChi2PerNcl, fPhotonNegITSChi2PerNcl, fPhotonPosTrackCode, fPhotonNegTrackCode, fPhotonV0Type, GammaBDTScore); - sigmaLambdaExtras(fLambdaPt, fLambdaMass, fAntiLambdaMass, fLambdaQt, fLambdaAlpha, + sigmaLambdaExtras(fLambdaPt, fLambdaMass, fAntiLambdaMass, fLambdaQt, fLambdaAlpha, fLambdaLifeTime, fLambdaRadius, fLambdaCosPA, fLambdaDCADau, fLambdaDCANegPV, fLambdaDCAPosPV, fLambdaEta, fLambdaY, fLambdaPhi, fLambdaPosPrTPCNSigma, fLambdaPosPiTPCNSigma, fLambdaNegPrTPCNSigma, fLambdaNegPiTPCNSigma, fLambdaPrTOFNSigma, fLambdaPiTOFNSigma, fALambdaPrTOFNSigma, fALambdaPiTOFNSigma, fLambdaPosTPCCrossedRows, fLambdaNegTPCCrossedRows, fLambdaPosPt, fLambdaNegPt, fLambdaPosEta, fLambdaNegEta, fLambdaPosPrY, fLambdaPosPiY, fLambdaNegPrY, fLambdaNegPiY, - fLambdaPosITSCls, fLambdaNegITSCls, fLambdaPosITSClSize, fLambdaNegITSClSize, + fLambdaPosITSCls, fLambdaNegITSCls, fLambdaPosITSChi2PerNcl, fLambdaNegITSChi2PerNcl, fLambdaPosTrackCode, fLambdaNegTrackCode, fLambdaV0Type, LambdaBDTScore, AntiLambdaBDTScore); } - void processMonteCarlo(soa::Join const& collisions, V0DerivedMCDatas const& V0s, dauTracks const&) + void processMonteCarlo(soa::Join const& collisions, V0DerivedMCDatas const& fullV0s, dauTracks const&, aod::MotherMCParts const&, soa::Join const&, soa::Join const&) { + // Initialize auxiliary vectors + std::vector bestGammasArray; + std::vector bestLambdasArray; + + // brute force grouped index construction + std::vector> v0grouped(collisions.size()); + + for (const auto& v0 : fullV0s) { + v0grouped[v0.straCollisionId()].push_back(v0.globalIndex()); + } + for (const auto& coll : collisions) { - // Do analysis with collision-grouped V0s, retain full collision information - const uint64_t collIdx = coll.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionMCDerived, collIdx); + // Clear vectors + bestGammasArray.clear(); + bestLambdasArray.clear(); - // V0 table sliced - for (auto& gamma : V0Table_thisCollision) { // selecting photons from Sigma0 - float centrality = coll.centFT0C(); + if (!IsEventAccepted(coll, true)) + continue; - // Auxiliary histograms: - if (gamma.pdgCode() == 22) { - float GammaY = TMath::Abs(RecoDecay::y(std::array{gamma.px(), gamma.py(), gamma.pz()}, o2::constants::physics::MassGamma)); + float centrality = doPPAnalysis ? coll.centFT0M() : coll.centFT0C(); - if (GammaY < 0.5) { // rapidity selection - histos.fill(HIST("MC/h2dPtVsCentrality_GammaBeforeSel"), centrality, gamma.pt()); // isgamma - histos.fill(HIST("MC/h2dGammaPtResolution"), gamma.pt(), gamma.pt() - RecoDecay::pt(array{gamma.pxMC(), gamma.pyMC()})); // pT resolution + bool fhasMCColl = false; + if (coll.has_straMCCollision()) + fhasMCColl = true; - if (gamma.pdgCodeMother() == 3212) { - histos.fill(HIST("MC/h2dPtVsCentrality_GammaSigma0"), centrality, gamma.pt()); // isgamma from sigma - } - if (gamma.pdgCodeMother() == -3212) { - histos.fill(HIST("MC/h2dPtVsCentrality_GammaAntiSigma0"), centrality, gamma.pt()); // isgamma from sigma - } + //_______________________________________________ + // Retrieving IR info + float interactionRate = -1; + if (fGetIR) { + interactionRate = rateFetcher.fetch(ccdb.service, coll.timestamp(), coll.runNumber(), irSource, fIRCrashOnNull) * 1.e-3; + if (interactionRate < 0) + histos.get(HIST("GeneralQA/hRunNumberNegativeIR"))->Fill(Form("%d", coll.runNumber()), 1); + + histos.fill(HIST("GeneralQA/hInteractionRate"), interactionRate); + histos.fill(HIST("GeneralQA/hCentralityVsInteractionRate"), centrality, interactionRate); + } + + //_______________________________________________ + // V0s loop + for (size_t i = 0; i < v0grouped[coll.globalIndex()].size(); i++) { + auto v0 = fullV0s.rawIteratorAt(v0grouped[coll.globalIndex()][i]); + + if (!v0.has_v0MCCore()) + continue; + + auto v0MC = v0.v0MCCore_as>(); + + if (v0MC.pdgCode() == 22) { + histos.fill(HIST("MC/h2dGammaXYConversion"), v0.x(), v0.y()); + float GammaY = TMath::Abs(RecoDecay::y(std::array{v0.px(), v0.py(), v0.pz()}, o2::constants::physics::MassGamma)); + if (GammaY < 0.5) { // rapidity selection + histos.fill(HIST("MC/h2dPtVsCentralityBeforeSel_MCAssocGamma"), centrality, v0.pt()); // isgamma } } - if (gamma.pdgCode() == 3122) { // Is Lambda - float LambdaY = TMath::Abs(RecoDecay::y(std::array{gamma.px(), gamma.py(), gamma.pz()}, o2::constants::physics::MassLambda)); - if (LambdaY < 0.5) { // rapidity selection - histos.fill(HIST("MC/h2dPtVsCentrality_LambdaBeforeSel"), centrality, gamma.pt()); - histos.fill(HIST("MC/h2dLambdaPtResolution"), gamma.pt(), gamma.pt() - RecoDecay::pt(array{gamma.pxMC(), gamma.pyMC()})); // pT resolution - if (gamma.pdgCodeMother() == 3212) { - histos.fill(HIST("MC/h2dPtVsCentrality_LambdaSigma0"), centrality, gamma.pt()); - } - } + + float lambdaY = TMath::Abs(RecoDecay::y(std::array{v0.px(), v0.py(), v0.pz()}, o2::constants::physics::MassLambda)); + if (lambdaY < 0.5) { + if (v0MC.pdgCode() == 3122) // Is Lambda + histos.fill(HIST("MC/h2dPtVsCentralityBeforeSel_MCAssocLambda"), centrality, v0.pt()); + if (v0MC.pdgCode() == -3122) // Is AntiLambda + histos.fill(HIST("MC/h2dPtVsCentralityBeforeSel_MCAssocALambda"), centrality, v0.pt()); } - if (gamma.pdgCode() == -3122) { // Is AntiLambda - float AntiLambdaY = TMath::Abs(RecoDecay::y(std::array{gamma.px(), gamma.py(), gamma.pz()}, o2::constants::physics::MassLambda)); - if (AntiLambdaY < 0.5) { // rapidity selection - histos.fill(HIST("MC/h2dPtVsCentrality_AntiLambdaBeforeSel"), centrality, gamma.pt()); - if (gamma.pdgCodeMother() == -3212) { - histos.fill(HIST("MC/h2dPtVsCentrality_LambdaAntiSigma0"), centrality, gamma.pt()); // isantilambda from antisigma - } + + if (processPhotonCandidate(v0, coll)) // selecting photons + bestGammasArray.push_back(v0.globalIndex()); // Save indices of best gamma candidates + + if (processLambdaCandidate(v0, coll)) // selecting lambdas + bestLambdasArray.push_back(v0.globalIndex()); // Save indices of best lambda candidates + } + + //_______________________________________________ + // Pi0 optional loop + if (doPi0QA) { + for (size_t i = 0; i < bestGammasArray.size(); ++i) { + auto gamma1 = fullV0s.rawIteratorAt(bestGammasArray[i]); + for (size_t j = i + 1; j < bestGammasArray.size(); ++j) { + auto gamma2 = fullV0s.rawIteratorAt(bestGammasArray[j]); + runPi0QA(gamma1, gamma2, coll); } } + } + + //_______________________________________________ + // Wrongly collision association study + if (doAssocStudy && fhasMCColl) { + analyzeV0CollAssoc(coll, fullV0s, bestGammasArray, interactionRate, true); // Gamma + analyzeV0CollAssoc(coll, fullV0s, bestLambdasArray, interactionRate, false); // Lambda + } + + //_______________________________________________ + // Sigma0 loop + for (size_t i = 0; i < bestGammasArray.size(); ++i) { + auto gamma = fullV0s.rawIteratorAt(bestGammasArray[i]); + + if (!gamma.has_v0MCCore()) + continue; + + auto gammaMC = gamma.v0MCCore_as>(); + + bool fIsPhotonCorrectlyAssign = false; + if (fhasMCColl) { + auto gammaMCCollision = coll.template straMCCollision_as>(); + fIsPhotonCorrectlyAssign = (gammaMC.straMCCollisionId() == gammaMCCollision.globalIndex()); + } + + for (size_t j = 0; j < bestLambdasArray.size(); ++j) { + auto lambda = fullV0s.rawIteratorAt(bestLambdasArray[j]); + + if (!lambda.has_v0MCCore()) + continue; - for (auto& lambda : V0Table_thisCollision) { // selecting lambdas from Sigma0 - if (doPi0QA) // Pi0 QA study - runPi0QA(gamma, lambda); + auto lambdaMC = lambda.v0MCCore_as>(); // Sigma0 candidate properties std::array pVecPhotons{gamma.px(), gamma.py(), gamma.pz()}; @@ -658,115 +1259,162 @@ struct sigma0builder { float SigmapT = RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()}); float SigmaY = TMath::Abs(RecoDecay::y(std::array{gamma.px() + lambda.px(), gamma.py() + lambda.py(), gamma.pz() + lambda.pz()}, o2::constants::physics::MassSigma0)); - if ((gamma.pdgCode() == 22) && (gamma.pdgCodeMother() == 3212) && (lambda.pdgCode() == 3122) && (lambda.pdgCodeMother() == 3212) && (gamma.motherMCPartId() == lambda.motherMCPartId()) && (SigmaY < 0.5)) { - histos.fill(HIST("MC/h2dPtVsCentrality_Sigma0BeforeSel"), centrality, RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()})); - histos.fill(HIST("MC/h2dSigmaPtVsLambdaPt"), SigmapT, lambda.pt()); - histos.fill(HIST("MC/h2dSigmaPtVsGammaPt"), SigmapT, gamma.pt()); - } - if ((gamma.pdgCode() == 22) && (gamma.pdgCodeMother() == -3212) && (lambda.pdgCode() == -3122) && (lambda.pdgCodeMother() == -3212) && (gamma.motherMCPartId() == lambda.motherMCPartId()) && (SigmaY < 0.5)) - histos.fill(HIST("MC/h2dPtVsCentrality_AntiSigma0BeforeSel"), centrality, SigmapT); - - if (!processSigmaCandidate(lambda, gamma)) // basic selection - continue; - + // MC properties bool fIsSigma = false; bool fIsAntiSigma = false; - bool fIsPhotonPrimary = gamma.isPhysicalPrimary(); - int PhotonCandPDGCode = gamma.pdgCode(); - int PhotonCandPDGCodeMother = gamma.pdgCodeMother(); - bool fIsLambdaPrimary = lambda.isPhysicalPrimary(); - int LambdaCandPDGCode = lambda.pdgCode(); - int LambdaCandPDGCodeMother = lambda.pdgCodeMother(); - - if ((gamma.pdgCode() == 22) && (gamma.pdgCodeMother() == 3212) && (lambda.pdgCode() == 3122) && (lambda.pdgCodeMother() == 3212) && (gamma.motherMCPartId() == lambda.motherMCPartId())) { - fIsSigma = true; - histos.fill(HIST("MC/h2dPtVsCentrality_Sigma0AfterSel"), centrality, RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()})); + bool fIsPhotonPrimary = gammaMC.isPhysicalPrimary(); + bool fIsLambdaPrimary = lambdaMC.isPhysicalPrimary(); + bool fIsLambdaCorrectlyAssign = false; + + int PhotonCandPDGCode = gammaMC.pdgCode(); + int PhotonCandPDGCodeMother = gammaMC.pdgCodeMother(); + int LambdaCandPDGCode = lambdaMC.pdgCode(); + int LambdaCandPDGCodeMother = lambdaMC.pdgCodeMother(); + + float SigmaMCpT = RecoDecay::pt(array{gammaMC.pxMC() + lambdaMC.pxMC(), gammaMC.pyMC() + lambdaMC.pyMC()}); + float PhotonMCpT = RecoDecay::pt(array{gammaMC.pxMC(), gammaMC.pyMC()}); + float LambdaMCpT = RecoDecay::pt(array{lambdaMC.pxMC(), lambdaMC.pyMC()}); + + if (fhasMCColl) { + auto lambdaMCCollision = coll.template straMCCollision_as>(); + fIsLambdaCorrectlyAssign = (lambdaMC.straMCCollisionId() == lambdaMCCollision.globalIndex()); } - if ((gamma.pdgCode() == 22) && (gamma.pdgCodeMother() == -3212) && (lambda.pdgCode() == -3122) && (lambda.pdgCodeMother() == -3212) && (gamma.motherMCPartId() == lambda.motherMCPartId())) { + + if ((PhotonCandPDGCode == 22) && (PhotonCandPDGCodeMother == 3212) && (LambdaCandPDGCode == 3122) && (LambdaCandPDGCodeMother == 3212) && (gamma.motherMCPartId() == lambda.motherMCPartId())) + fIsSigma = true; + if ((PhotonCandPDGCode == 22) && (PhotonCandPDGCodeMother == -3212) && (LambdaCandPDGCode == -3122) && (LambdaCandPDGCodeMother == -3212) && (gamma.motherMCPartId() == lambda.motherMCPartId())) fIsAntiSigma = true; - histos.fill(HIST("MC/h2dPtVsCentrality_AntiSigma0AfterSel"), centrality, RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()})); - // TH3D Mass histogram + + if (SigmaY < 0.5) { + if (fIsSigma) { + histos.fill(HIST("MC/h2dPtVsCentralityBeforeSel_MCAssocSigma0"), centrality, SigmaMCpT); + histos.fill(HIST("MC/h2dSigma0PtVsLambdaPtBeforeSel_MCAssoc"), SigmaMCpT, LambdaMCpT); + histos.fill(HIST("MC/h2dSigma0PtVsGammaPtBeforeSel_MCAssoc"), SigmaMCpT, PhotonMCpT); + } + if (fIsAntiSigma) + histos.fill(HIST("MC/h2dPtVsCentralityBeforeSel_MCAssocASigma0"), centrality, SigmaMCpT); } - sigma0mccores(fIsSigma, fIsAntiSigma, - PhotonCandPDGCode, PhotonCandPDGCodeMother, fIsPhotonPrimary, - LambdaCandPDGCode, LambdaCandPDGCodeMother, fIsLambdaPrimary); - - // QA histograms - // Signal only (sigma0+antisigma0) - if (fIsSigma || fIsAntiSigma) - histos.fill(HIST("MC/h2dPtVsMassSigma_SignalOnly"), SigmapT, SigmaMass); + + // Build sigma0 candidate, please + if (!buildSigma0(lambda, gamma, coll)) + continue; + + if (SigmaY < 0.5) { + if (fIsSigma) + histos.fill(HIST("MC/h2dPtVsCentralityAfterSel_MCAssocSigma0"), centrality, SigmaMCpT); + if (fIsAntiSigma) + histos.fill(HIST("MC/h2dPtVsCentralityAfterSel_MCAssocASigma0"), centrality, SigmaMCpT); + } + + if (fillBkgQAhistos) + runBkgAnalysis(fIsSigma, fIsAntiSigma, PhotonCandPDGCode, PhotonCandPDGCodeMother, LambdaCandPDGCode, LambdaCandPDGCodeMother, SigmapT, SigmaMass); + + // Fill Tables please + sigma0mccores(fIsSigma, fIsAntiSigma, SigmaMCpT, + PhotonCandPDGCode, PhotonCandPDGCodeMother, fIsPhotonPrimary, PhotonMCpT, fIsPhotonCorrectlyAssign, + LambdaCandPDGCode, LambdaCandPDGCodeMother, fIsLambdaPrimary, LambdaMCpT, fIsLambdaCorrectlyAssign); + + // Filling tables with accepted candidates + fillTables(lambda, gamma, coll); + + nSigmaCandidates++; + if (nSigmaCandidates % 10000 == 0) + LOG(info) << "Sigma0 Candidates built: " << nSigmaCandidates; } } } } - void processSTDSelection(soa::Join const& collisions, V0StandardDerivedDatas const& V0s, dauTracks const&) + void processRealData(soa::Join const& collisions, V0StandardDerivedDatas const& fullV0s, dauTracks const&) { + // Initialize auxiliary vectors + std::vector bestGammasArray; + std::vector bestLambdasArray; + + // brute force grouped index construction + std::vector> v0grouped(collisions.size()); + + for (const auto& v0 : fullV0s) { + v0grouped[v0.straCollisionId()].push_back(v0.globalIndex()); + } + for (const auto& coll : collisions) { - // Do analysis with collision-grouped V0s, retain full collision information - const uint64_t collIdx = coll.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionSTDDerived, collIdx); + // Clear vectors + bestGammasArray.clear(); + bestLambdasArray.clear(); - histos.fill(HIST("hEventCentrality"), coll.centFT0C()); + if (!IsEventAccepted(coll, true)) + continue; - // V0 table sliced - for (auto& gamma : V0Table_thisCollision) { // selecting photons from Sigma0 - for (auto& lambda : V0Table_thisCollision) { // selecting lambdas from Sigma0 - if (doPi0QA) // Pi0 QA study - runPi0QA(gamma, lambda); + float centrality = doPPAnalysis ? coll.centFT0M() : coll.centFT0C(); - // Sigma0 candidate properties - std::array pVecPhotons{gamma.px(), gamma.py(), gamma.pz()}; - std::array pVecLambda{lambda.px(), lambda.py(), lambda.pz()}; - auto arrMom = std::array{pVecPhotons, pVecLambda}; - float SigmaMass = RecoDecay::m(arrMom, std::array{o2::constants::physics::MassPhoton, o2::constants::physics::MassLambda0}); - float SigmapT = RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()}); - // float SigmaY = TMath::Abs(RecoDecay::y(std::array{gamma.px() + lambda.px(), gamma.py() + lambda.py(), gamma.pz() + lambda.pz()}, o2::constants::physics::MassSigma0)); - histos.fill(HIST("h3dMassSigmasBeforeSel"), coll.centFT0C(), SigmapT, SigmaMass); + //_______________________________________________ + // Retrieving IR info + float interactionRate = -1; + if (fGetIR) { + interactionRate = rateFetcher.fetch(ccdb.service, coll.timestamp(), coll.runNumber(), irSource, fIRCrashOnNull) * 1.e-3; + if (interactionRate < 0) + histos.get(HIST("GeneralQA/hRunNumberNegativeIR"))->Fill(Form("%d", coll.runNumber()), 1); - if (!processSigmaCandidate(lambda, gamma)) // applying selection for reconstruction - continue; + histos.fill(HIST("GeneralQA/hInteractionRate"), interactionRate); + histos.fill(HIST("GeneralQA/hCentralityVsInteractionRate"), centrality, interactionRate); + } - histos.fill(HIST("h3dMassSigmasAfterSel"), coll.centFT0C(), SigmapT, SigmaMass); + //_______________________________________________ + // V0s loop + for (size_t i = 0; i < v0grouped[coll.globalIndex()].size(); i++) { + auto v0 = fullV0s.rawIteratorAt(v0grouped[coll.globalIndex()][i]); + if (processPhotonCandidate(v0, coll)) // selecting photons + bestGammasArray.push_back(v0.globalIndex()); // Save indices of best gamma candidates - fillTables(lambda, gamma, coll); // filling tables with accepted candidates + if (processLambdaCandidate(v0, coll)) // selecting lambdas + bestLambdasArray.push_back(v0.globalIndex()); // Save indices of best lambda candidates + } - nSigmaCandidates++; - if (nSigmaCandidates % 5000 == 0) { - LOG(info) << "Sigma0 Candidates built: " << nSigmaCandidates; + //_______________________________________________ + // Pi0 optional loop + if (doPi0QA) { + for (size_t i = 0; i < bestGammasArray.size(); ++i) { + auto gamma1 = fullV0s.rawIteratorAt(bestGammasArray[i]); + for (size_t j = i + 1; j < bestGammasArray.size(); ++j) { + auto gamma2 = fullV0s.rawIteratorAt(bestGammasArray[j]); + runPi0QA(gamma1, gamma2, coll); } } } - } - } - void processMLSelection(soa::Join const& collisions, V0MLDerivedDatas const& V0s, dauTracks const&) - { - for (const auto& coll : collisions) { - // Do analysis with collision-grouped V0s, retain full collision information - const uint64_t collIdx = coll.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionMLDerived, collIdx); + //_______________________________________________ + // Sigma0 nested loop + for (size_t i = 0; i < bestGammasArray.size(); ++i) { + auto gamma = fullV0s.rawIteratorAt(bestGammasArray[i]); - histos.fill(HIST("hEventCentrality"), coll.centFT0C()); + for (size_t j = 0; j < bestLambdasArray.size(); ++j) { + auto lambda = fullV0s.rawIteratorAt(bestLambdasArray[j]); - // V0 table sliced - for (auto& gamma : V0Table_thisCollision) { // selecting photons from Sigma0 - for (auto& lambda : V0Table_thisCollision) { // selecting lambdas from Sigma0 - if (!processSigmaCandidate(lambda, gamma)) + // Building sigma0 candidate + if (!buildSigma0(lambda, gamma, coll)) continue; + // Filling tables with accepted candidates + fillTables(lambda, gamma, coll); + nSigmaCandidates++; - if (nSigmaCandidates % 5000 == 0) { + if (nSigmaCandidates % 10000 == 0) LOG(info) << "Sigma0 Candidates built: " << nSigmaCandidates; - } - fillTables(lambda, gamma, coll); // filling tables with accepted candidates } } } } - PROCESS_SWITCH(sigma0builder, processMonteCarlo, "Fill sigma0 MC table", false); - PROCESS_SWITCH(sigma0builder, processSTDSelection, "Select gammas and lambdas with standard cuts", true); - PROCESS_SWITCH(sigma0builder, processMLSelection, "Select gammas and lambdas with ML", false); + + // Simulated processing in Run 3 (subscribes to MC information too) + void processGeneratedRun3(soa::Join const& mcCollisions, soa::Join const& V0MCCores, soa::Join const& collisions) + { + analyzeGeneratedV0s(mcCollisions, V0MCCores, collisions); + } + + PROCESS_SWITCH(sigma0builder, processMonteCarlo, "process as if MC data", false); + PROCESS_SWITCH(sigma0builder, processRealData, "process as if real data", true); + PROCESS_SWITCH(sigma0builder, processGeneratedRun3, "process generated MC collisions", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/TableProducer/Strangeness/sigmaminustask.cxx b/PWGLF/TableProducer/Strangeness/sigmaminustask.cxx new file mode 100644 index 00000000000..fbf5929effc --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/sigmaminustask.cxx @@ -0,0 +1,252 @@ +// 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. + +/// \file sigmaminustask.cxx +/// \brief Example of a simple task for the analysis of the Sigma-minus +/// \author Francesco Mazzaschi + +#include "PWGLF/DataModel/LFKinkDecayTables.h" + +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/PID.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using TracksFull = soa::Join; +using CollisionsFull = soa::Join; +using CollisionsFullMC = soa::Join; + +struct sigmaminustask { + + // Output Tables + Produces outputDataTable; + Produces outputDataTableMC; + + // Histograms are defined with HistogramRegistry + HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rSigmaMinus{"sigmaminus", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Configurable for event selection + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable cutNSigmaPi{"cutNSigmaPi", 4, "NSigmaTPCPion"}; + Configurable cutEtaMotherMC{"cutEtaMotherMC", 1.0f, "Eta cut for mother Sigma in MC"}; + + Configurable fillOutputTree{"fillOutputTree", true, "If true, fill the output tree with Kink candidates"}; + + Preslice mPerCol = aod::track::collisionId; + + void init(InitContext const&) + { + // Axes + const AxisSpec ptAxis{100, -10, 10, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec nSigmaPiAxis{100, -5, 5, "n#sigma_{#pi}"}; + const AxisSpec sigmaMassAxis{100, 1.1, 1.4, "m (GeV/#it{c}^{2})"}; + const AxisSpec xiMassAxis{100, 1.2, 1.6, "m_{#Xi} (GeV/#it{c}^{2})"}; + const AxisSpec pdgAxis{10001, -5000, 5000, "PDG code"}; + const AxisSpec vertexZAxis{100, -15., 15., "vrtx_{Z} [cm]"}; + + const AxisSpec ptResolutionAxis{100, -0.5, 0.5, "#it{p}_{T}^{rec} - #it{p}_{T}^{gen} (GeV/#it{c})"}; + const AxisSpec massResolutionAxis{100, -0.1, 0.1, "m_{rec} - m_{gen} (GeV/#it{c}^{2})"}; + + // Event selection + rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + // Sigma-minus reconstruction + rSigmaMinus.add("h2MassSigmaMinusPt", "h2MassSigmaMinusPt", {HistType::kTH2F, {ptAxis, sigmaMassAxis}}); + rSigmaMinus.add("h2SigmaMassVsXiMass", "h2SigmaMassVsXiMass", {HistType::kTH2F, {xiMassAxis, sigmaMassAxis}}); + rSigmaMinus.add("h2NSigmaPiPt", "h2NSigmaPiPt", {HistType::kTH2F, {ptAxis, nSigmaPiAxis}}); + + if (doprocessMC) { + // Add MC histograms if needed + rSigmaMinus.add("h2MassPtMCRec", "h2MassPtMCRec", {HistType::kTH2F, {ptAxis, sigmaMassAxis}}); + rSigmaMinus.add("h2MassPtMCGen", "h2MassPtMCGen", {HistType::kTH2F, {ptAxis, sigmaMassAxis}}); + + rSigmaMinus.add("h2MassResolution_minus", "h2MassResolution_minus", {HistType::kTH2F, {sigmaMassAxis, massResolutionAxis}}); + rSigmaMinus.add("h2PtResolution_minus", "h2PtResolution_minus", {HistType::kTH2F, {ptAxis, ptResolutionAxis}}); + rSigmaMinus.add("h2MassResolution_plus", "h2MassResolution_plus", {HistType::kTH2F, {sigmaMassAxis, massResolutionAxis}}); + rSigmaMinus.add("h2PtResolution_plus", "h2PtResolution_plus", {HistType::kTH2F, {ptAxis, ptResolutionAxis}}); + } + } + + void processData(CollisionsFull::iterator const& collision, aod::KinkCands const& KinkCands, TracksFull const&) + { + if (std::abs(collision.posZ()) > cutzvertex || !collision.sel8()) { + return; + } + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + + for (const auto& kinkCand : KinkCands) { + auto dauTrack = kinkCand.trackDaug_as(); + + if (std::abs(dauTrack.tpcNSigmaPi()) > cutNSigmaPi) { + continue; + } + + rSigmaMinus.fill(HIST("h2MassSigmaMinusPt"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.mSigmaMinus()); + rSigmaMinus.fill(HIST("h2SigmaMassVsXiMass"), kinkCand.mXiMinus(), kinkCand.mSigmaMinus()); + rSigmaMinus.fill(HIST("h2NSigmaPiPt"), kinkCand.mothSign() * kinkCand.ptMoth(), dauTrack.tpcNSigmaPi()); + + if (fillOutputTree) { + outputDataTable(kinkCand.xDecVtx(), kinkCand.yDecVtx(), kinkCand.zDecVtx(), + kinkCand.pxMoth(), kinkCand.pyMoth(), kinkCand.pzMoth(), + kinkCand.pxDaug(), kinkCand.pyDaug(), kinkCand.pzDaug(), + kinkCand.dcaMothPv(), kinkCand.dcaDaugPv(), kinkCand.dcaKinkTopo(), + kinkCand.mothSign(), + dauTrack.tpcNSigmaPi(), dauTrack.tpcNSigmaPr(), dauTrack.tpcNSigmaKa(), + dauTrack.tofNSigmaPi(), dauTrack.tofNSigmaPr(), dauTrack.tofNSigmaKa()); + } + } + } + PROCESS_SWITCH(sigmaminustask, processData, "Data processing", true); + + void processMC(CollisionsFullMC const& collisions, aod::KinkCands const& KinkCands, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const& particlesMC, aod::McCollisions const&, TracksFull const&) + { + for (const auto& collision : collisions) { + if (std::abs(collision.posZ()) > cutzvertex || !collision.sel8()) { + continue; + } + + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + auto kinkCandPerColl = KinkCands.sliceBy(mPerCol, collision.globalIndex()); + + for (const auto& kinkCand : kinkCandPerColl) { + + auto dauTrack = kinkCand.trackDaug_as(); + auto mothTrack = kinkCand.trackMoth_as(); + if (dauTrack.sign() != mothTrack.sign()) { + LOG(info) << "Skipping kink candidate with opposite sign daughter and mother: " << kinkCand.globalIndex(); + continue; // Skip if the daughter has the opposite sign as the mother + } + if (std::abs(dauTrack.tpcNSigmaPi()) > cutNSigmaPi) { + continue; + } + + rSigmaMinus.fill(HIST("h2MassSigmaMinusPt"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.mSigmaMinus()); + rSigmaMinus.fill(HIST("h2SigmaMassVsXiMass"), kinkCand.mXiMinus(), kinkCand.mSigmaMinus()); + rSigmaMinus.fill(HIST("h2NSigmaPiPt"), kinkCand.mothSign() * kinkCand.ptMoth(), dauTrack.tpcNSigmaPi()); + + // do MC association + auto mcLabSigma = trackLabelsMC.rawIteratorAt(mothTrack.globalIndex()); + auto mcLabPiDau = trackLabelsMC.rawIteratorAt(dauTrack.globalIndex()); + if (mcLabSigma.has_mcParticle() && mcLabPiDau.has_mcParticle()) { + auto mcTrackSigma = mcLabSigma.mcParticle_as(); + auto mcTrackPiDau = mcLabPiDau.mcParticle_as(); + if (!mcTrackPiDau.has_mothers()) { + continue; + } + for (auto& piMother : mcTrackPiDau.mothers_as()) { + if (piMother.globalIndex() != mcTrackSigma.globalIndex()) { + continue; + } + if (std::abs(mcTrackSigma.pdgCode()) != 3112) { + continue; + } + if (std::abs(mcTrackPiDau.pdgCode()) != 211 && std::abs(mcTrackPiDau.pdgCode()) != 2212) { + continue; + } + + float MotherMassMC = std::sqrt(piMother.e() * piMother.e() - piMother.p() * piMother.p()); + float MotherpTMC = piMother.pt(); + float deltaXMother = mcTrackPiDau.vx() - piMother.vx(); + float deltaYMother = mcTrackPiDau.vy() - piMother.vy(); + float decayRadiusMC = std::sqrt(deltaXMother * deltaXMother + deltaYMother * deltaYMother); + + // Check coherence of MCcollision Id for daughter MCparticle and reconstructed collision + bool mcCollisionIdCheck = false; + if (collision.has_mcCollision()) { + mcCollisionIdCheck = collision.mcCollision().globalIndex() == mcTrackPiDau.mcCollisionId(); + } + + rSigmaMinus.fill(HIST("h2MassPtMCRec"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.mSigmaMinus()); + if (mcTrackSigma.pdgCode() > 0) { + rSigmaMinus.fill(HIST("h2MassResolution_plus"), kinkCand.mSigmaMinus(), kinkCand.mSigmaMinus() - MotherMassMC); + rSigmaMinus.fill(HIST("h2PtResolution_plus"), kinkCand.ptMoth(), kinkCand.ptMoth() - MotherpTMC); + } else { + rSigmaMinus.fill(HIST("h2MassResolution_minus"), kinkCand.mSigmaMinus(), kinkCand.mSigmaMinus() - MotherMassMC); + rSigmaMinus.fill(HIST("h2PtResolution_minus"), kinkCand.ptMoth(), kinkCand.ptMoth() - MotherpTMC); + } + + // fill the output table with Mc information + if (fillOutputTree) { + outputDataTableMC(kinkCand.xDecVtx(), kinkCand.yDecVtx(), kinkCand.zDecVtx(), + kinkCand.pxMoth(), kinkCand.pyMoth(), kinkCand.pzMoth(), + kinkCand.pxDaug(), kinkCand.pyDaug(), kinkCand.pzDaug(), + kinkCand.dcaMothPv(), kinkCand.dcaDaugPv(), kinkCand.dcaKinkTopo(), + kinkCand.mothSign(), + dauTrack.tpcNSigmaPi(), dauTrack.tpcNSigmaPr(), dauTrack.tpcNSigmaKa(), + dauTrack.tofNSigmaPi(), dauTrack.tofNSigmaPr(), dauTrack.tofNSigmaKa(), + mcTrackSigma.pdgCode(), mcTrackPiDau.pdgCode(), + MotherpTMC, MotherMassMC, decayRadiusMC, mcCollisionIdCheck); + } + } + } // MC association and selection + } // kink cand loop + } // collision loop + + // Loop over all generated particles to fill MC histograms + for (const auto& mcPart : particlesMC) { + if (std::abs(mcPart.pdgCode()) != 3112 || std::abs(mcPart.y()) > cutEtaMotherMC) { // only sigma mothers and rapidity cut + continue; + } + if (!mcPart.has_daughters()) { + continue; // Skip if no daughters + } + bool hasSigmaDaughter = false; + int daug_pdg = 0; + std::array secVtx; + std::array momDaug; + for (const auto& daughter : mcPart.daughters_as()) { + if (std::abs(daughter.pdgCode()) == 211 || std::abs(daughter.pdgCode()) == 2212) { // Pi or proton daughter + hasSigmaDaughter = true; + secVtx = {daughter.vx(), daughter.vy(), daughter.vz()}; + momDaug = {daughter.px(), daughter.py(), daughter.pz()}; + daug_pdg = daughter.pdgCode(); + break; // Found a daughter, exit loop + } + } + if (!hasSigmaDaughter) { + continue; // Skip if no pi/proton daughter found + } + float mcMass = std::sqrt(mcPart.e() * mcPart.e() - mcPart.p() * mcPart.p()); + float mcDecayRadius = std::sqrt((secVtx[0] - mcPart.vx()) * (secVtx[0] - mcPart.vx()) + (secVtx[1] - mcPart.vy()) * (secVtx[1] - mcPart.vy())); + int sigmaSign = mcPart.pdgCode() > 0 ? 1 : -1; // Determine the sign of the Sigma + rSigmaMinus.fill(HIST("h2MassPtMCGen"), sigmaSign * mcPart.pt(), mcMass); + + // Fill output table with non reconstructed MC candidates + if (fillOutputTree) { + outputDataTableMC(-999, -999, -999, + -999, -999, -999, + -999, -999, -999, + -999, -999, -999, + sigmaSign, + -999, -999, -999, + -999, -999, -999, + mcPart.pdgCode(), daug_pdg, + mcPart.pt(), mcMass, mcDecayRadius, false); + } + } + } + + PROCESS_SWITCH(sigmaminustask, processMC, "MC processing", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/stracents.cxx b/PWGLF/TableProducer/Strangeness/stracents.cxx new file mode 100644 index 00000000000..ce5597563da --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/stracents.cxx @@ -0,0 +1,587 @@ +// 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. +// +/// \file straCents.cxx +/// \brief Task to re-produce the strangeness centrality tables, repeating what has been done the centralityTable.cxx and multiplicityTable.cxx tasks +/// +/// \author ALICE +// + +#include +#include +#include +#include + +#include +#include +#include +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/RunningWorkflowInfo.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/HistogramRegistry.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "MetadataHelper.h" +#include "TableHelper.h" +#include "TList.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +o2::common::core::MetadataHelper metadataInfo; // Metadata helper + +struct straCents { + Produces strangeCents; + Produces strangeCentsRun2; + + Service ccdb; + + Configurable doVertexZeq{"doVertexZeq", 1, "if 1: do vertex Z eq mult table"}; + struct : ConfigurableGroup { + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "The CCDB endpoint url address"}; + Configurable ccdbPath_Centrality{"ccdbPath_Centrality", "Centrality/Estimators", "The CCDB path for centrality/multiplicity information"}; + Configurable ccdbPath_Multiplicity{"ccdbPath_Multiplicity", "Centrality/Calibration", "The CCDB path for centrality/multiplicity information"}; + Configurable genName{"genName", "", "Genearator name: HIJING, PYTHIA8, ... Default: \"\""}; + Configurable doNotCrashOnNull{"doNotCrashOnNull", false, {"Option to not crash on null and instead fill required tables with dummy info"}}; + Configurable reconstructionPass{"reconstructionPass", "", {"Apass to use when fetching the calibration tables. Empty (default) does not check for any pass. Use `metadata` to fetch it from the AO2D metadata. Otherwise it will override the metadata."}}; + } ccdbConfig; + + Configurable embedINELgtZEROselection{"embedINELgtZEROselection", false, {"Option to do percentile 100.5 if not INELgtZERO"}}; + Configurable produceHistograms{"produceHistograms", false, {"Option to produce debug histograms"}}; + ConfigurableAxis binsPercentile{"binsPercentile", {VARIABLE_WIDTH, 0, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.011, 0.012, 0.013, 0.014, 0.015, 0.016, 0.017, 0.018, 0.019, 0.02, 0.021, 0.022, 0.023, 0.024, 0.025, 0.026, 0.027, 0.028, 0.029, 0.03, 0.031, 0.032, 0.033, 0.034, 0.035, 0.036, 0.037, 0.038, 0.039, 0.04, 0.041, 0.042, 0.043, 0.044, 0.045, 0.046, 0.047, 0.048, 0.049, 0.05, 0.051, 0.052, 0.053, 0.054, 0.055, 0.056, 0.057, 0.058, 0.059, 0.06, 0.061, 0.062, 0.063, 0.064, 0.065, 0.066, 0.067, 0.068, 0.069, 0.07, 0.071, 0.072, 0.073, 0.074, 0.075, 0.076, 0.077, 0.078, 0.079, 0.08, 0.081, 0.082, 0.083, 0.084, 0.085, 0.086, 0.087, 0.088, 0.089, 0.09, 0.091, 0.092, 0.093, 0.094, 0.095, 0.096, 0.097, 0.098, 0.099, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0, 71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0, 80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0, 90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0}, "Binning of the percentile axis"}; + + struct TagRun2V0MCalibration { + bool mCalibrationStored = false; + TFormula* mMCScale = nullptr; + float mMCScalePars[6] = {0.0}; + TH1* mhVtxAmpCorrV0A = nullptr; + TH1* mhVtxAmpCorrV0C = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2V0MInfo; + struct TagRun2V0ACalibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorrV0A = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2V0AInfo; + struct TagRun2SPDTrackletsCalibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorr = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2SPDTksInfo; + struct TagRun2SPDClustersCalibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorrCL0 = nullptr; + TH1* mhVtxAmpCorrCL1 = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2SPDClsInfo; + struct TagRun2CL0Calibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorr = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2CL0Info; + struct TagRun2CL1Calibration { + bool mCalibrationStored = false; + TH1* mhVtxAmpCorr = nullptr; + TH1* mhMultSelCalib = nullptr; + } Run2CL1Info; + struct CalibrationInfo { + std::string name = ""; + bool mCalibrationStored = false; + TH1* mhMultSelCalib = nullptr; + float mMCScalePars[6] = {0.0}; + TFormula* mMCScale = nullptr; + explicit CalibrationInfo(std::string name) + : name(name), + mCalibrationStored(false), + mhMultSelCalib(nullptr), + mMCScalePars{0.0}, + mMCScale(nullptr) + { + } + bool isSane(bool fatalize = false) + { + if (!mhMultSelCalib) { + return true; + } + for (int i = 1; i < mhMultSelCalib->GetNbinsX() + 1; i++) { + if (mhMultSelCalib->GetXaxis()->GetBinLowEdge(i) > mhMultSelCalib->GetXaxis()->GetBinUpEdge(i)) { + if (fatalize) { + LOG(fatal) << "Centrality calibration table " << name << " has bins with low edge > up edge"; + } + LOG(warning) << "Centrality calibration table " << name << " has bins with low edge > up edge"; + return false; + } + } + return true; + } + }; + CalibrationInfo fv0aInfo = CalibrationInfo("FV0"); + CalibrationInfo ft0mInfo = CalibrationInfo("FT0"); + CalibrationInfo ft0aInfo = CalibrationInfo("FT0A"); + CalibrationInfo ft0cInfo = CalibrationInfo("FT0C"); + CalibrationInfo ft0cVariant1Info = CalibrationInfo("FT0Cvar1"); + CalibrationInfo fddmInfo = CalibrationInfo("FDD"); + CalibrationInfo ntpvInfo = CalibrationInfo("NTracksPV"); + CalibrationInfo nGlobalInfo = CalibrationInfo("NGlobal"); + CalibrationInfo mftInfo = CalibrationInfo("MFT"); + + int mRunNumber; + bool lCalibLoaded; + TProfile* hVtxZFV0A; + TProfile* hVtxZFT0A; + TProfile* hVtxZFT0C; + TProfile* hVtxZFDDA; + + TProfile* hVtxZFDDC; + TProfile* hVtxZNTracks; + + // Debug output + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + OutputObj listCalib{"calib-list", OutputObjHandlingPolicy::QAObject}; + + void init(InitContext&) + { + LOG(info) << "Initializing centrality table producer"; + + if (metadataInfo.isFullyDefined() && !doprocessRun2 && !doprocessRun3) { // Check if the metadata is initialized (only if not forced from the workflow configuration) + if (metadataInfo.isRun3()) { + doprocessRun3.value = true; + } else { + doprocessRun2.value = false; + } + } + + if (doprocessRun2 == false && doprocessRun3 == false) { + LOGF(fatal, "Neither processRun2 nor processRun3 nor processRun3Complete enabled. Please choose one."); + } + if (doprocessRun2 == true && doprocessRun3 == true) { + LOGF(fatal, "Cannot enable processRun2 and processRun3 at the same time. Please choose one."); + } + + mRunNumber = 0; + lCalibLoaded = false; + + hVtxZFV0A = nullptr; + hVtxZFT0A = nullptr; + hVtxZFT0C = nullptr; + hVtxZFDDA = nullptr; + hVtxZFDDC = nullptr; + hVtxZNTracks = nullptr; + + ccdb->setURL(ccdbConfig.ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); // don't fatal, please - exception is caught explicitly (as it should) + + if (produceHistograms) { + histos.add("FT0M/Mult", "FT0M mult.", HistType::kTH1D, {{1000, 0, 5000, "FT0M mult."}}); + histos.add("FT0M/percentile", "FT0M percentile.", HistType::kTH1D, {{binsPercentile, "FT0M percentile"}}); + histos.add("FT0M/percentilevsPV", "percentile vs PV mult.", HistType::kTH2D, {{binsPercentile, "FT0M percentile"}, {100, 0, 100, "PV mult."}}); + histos.add("FT0M/MultvsPV", "FT0M mult. vs PV mult.", HistType::kTH2D, {{1000, 0, 5000, "FT0M mult."}, {100, 0, 100, "PV mult."}}); + + histos.add("FT0A/Mult", "FT0A mult", HistType::kTH1D, {{1000, 0, 1000, "FT0A multiplicity"}}); + histos.add("FT0A/percentile", "FT0A percentile.", HistType::kTH1D, {{binsPercentile, "FT0A percentile"}}); + histos.add("FT0A/percentilevsPV", "percentile vs PV mult.", HistType::kTH2D, {{binsPercentile, "FT0A percentile"}, {100, 0, 100, "PV mult."}}); + histos.add("FT0A/MultvsPV", "FT0A mult. vs PV mult.", HistType::kTH2D, {{1000, 0, 5000, "FT0A mult."}, {100, 0, 100, "PV mult."}}); + + histos.add("FT0C/Mult", "FT0C mult", HistType::kTH1D, {{1000, 0, 5000, "FT0C multiplicity"}}); + histos.add("FT0C/percentile", "FT0C percentile.", HistType::kTH1D, {{binsPercentile, "FT0C percentile"}}); + histos.add("FT0C/percentilevsPV", "percentile vs PV mult.", HistType::kTH2D, {{binsPercentile, "FT0C percentile"}, {100, 0, 100, "PV mult."}}); + histos.add("FT0C/MultvsPV", "FT0C mult. vs PV mult.", HistType::kTH2D, {{1000, 0, 5000, "FT0C mult."}, {100, 0, 100, "PV mult."}}); + + histos.addClone("FT0M/", "sel8FT0M/"); + histos.addClone("FT0C/", "sel8FT0C/"); + histos.addClone("FT0A/", "sel8FT0A/"); + + histos.print(); + } + listCalib.setObject(new TList); + } + + template + void initCCDB(TCollision collision) + { + if (mRunNumber == collision.runNumber()) { + return; + } + + mRunNumber = collision.runNumber(); + LOGF(info, "timestamp=%llu, run number=%d", collision.timestamp(), collision.runNumber()); + + TList* lCalibObjects_Centrality = nullptr; + TList* lCalibObjects_Multiplicity = nullptr; + if (ccdbConfig.reconstructionPass.value == "") { + lCalibObjects_Centrality = ccdb->getForRun(ccdbConfig.ccdbPath_Centrality, mRunNumber); + lCalibObjects_Multiplicity = ccdb->getForRun(ccdbConfig.ccdbPath_Multiplicity, mRunNumber); + } else if (ccdbConfig.reconstructionPass.value == "metadata") { + std::map metadata; + metadata["RecoPassName"] = metadataInfo.get("RecoPassName"); + LOGF(info, "Loading CCDB for reconstruction pass (from metadata): %s", metadataInfo.get("RecoPassName")); + lCalibObjects_Centrality = ccdb->getSpecificForRun(ccdbConfig.ccdbPath_Centrality, mRunNumber, metadata); + lCalibObjects_Multiplicity = ccdb->getSpecificForRun(ccdbConfig.ccdbPath_Multiplicity, mRunNumber, metadata); + } else { + std::map metadata; + metadata["RecoPassName"] = ccdbConfig.reconstructionPass.value; + LOGF(info, "Loading CCDB for reconstruction pass (from provided argument): %s", ccdbConfig.reconstructionPass.value); + lCalibObjects_Centrality = ccdb->getSpecificForRun(ccdbConfig.ccdbPath_Centrality, mRunNumber, metadata); + lCalibObjects_Multiplicity = ccdb->getSpecificForRun(ccdbConfig.ccdbPath_Multiplicity, mRunNumber, metadata); + } + + fv0aInfo.mCalibrationStored = false; + ft0mInfo.mCalibrationStored = false; + ft0aInfo.mCalibrationStored = false; + ft0cInfo.mCalibrationStored = false; + ft0cVariant1Info.mCalibrationStored = false; + fddmInfo.mCalibrationStored = false; + ntpvInfo.mCalibrationStored = false; + nGlobalInfo.mCalibrationStored = false; + mftInfo.mCalibrationStored = false; + + Run2V0MInfo.mCalibrationStored = false; + Run2V0AInfo.mCalibrationStored = false; + Run2SPDTksInfo.mCalibrationStored = false; + Run2SPDClsInfo.mCalibrationStored = false; + Run2CL0Info.mCalibrationStored = false; + Run2CL1Info.mCalibrationStored = false; + + if (lCalibObjects_Centrality) { + if (produceHistograms) { + listCalib->Add(lCalibObjects_Centrality->Clone(Form("Centrality_%i", collision.runNumber()))); + } + + LOGF(info, "Getting new histograms with %d run number for %d run number", mRunNumber, collision.runNumber()); + + if constexpr (requires { collision.sel7(); }) { // check if we are in Run 2 + auto getccdb = [lCalibObjects_Centrality](const char* ccdbhname) { + TH1* h = reinterpret_cast(lCalibObjects_Centrality->FindObject(ccdbhname)); + return h; + }; + auto getformulaccdb = [lCalibObjects_Centrality](const char* ccdbhname) { + TFormula* f = reinterpret_cast(lCalibObjects_Centrality->FindObject(ccdbhname)); + return f; + }; + + // V0M + Run2V0MInfo.mhVtxAmpCorrV0A = getccdb("hVtx_fAmplitude_V0A_Normalized"); + Run2V0MInfo.mhVtxAmpCorrV0C = getccdb("hVtx_fAmplitude_V0C_Normalized"); + Run2V0MInfo.mhMultSelCalib = getccdb("hMultSelCalib_V0M"); + Run2V0MInfo.mMCScale = getformulaccdb(TString::Format("%s-V0M", ccdbConfig.genName->c_str()).Data()); + if ((Run2V0MInfo.mhVtxAmpCorrV0A != nullptr) && (Run2V0MInfo.mhVtxAmpCorrV0C != nullptr) && (Run2V0MInfo.mhMultSelCalib != nullptr)) { + if (ccdbConfig.genName->length() != 0) { + if (Run2V0MInfo.mMCScale != nullptr) { + for (int ixpar = 0; ixpar < 6; ++ixpar) { + Run2V0MInfo.mMCScalePars[ixpar] = Run2V0MInfo.mMCScale->GetParameter(ixpar); + } + } else { + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "MC Scale information from V0M for run %d not available", collision.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(warning, "MC Scale information from V0M for run %d not available", collision.runNumber()); + } + } + } + Run2V0MInfo.mCalibrationStored = true; + } else { + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from V0M for run %d corrupted", collision.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(warning, "Calibration information from V0M for run %d corrupted, will fill V0M tables with dummy values", collision.runNumber()); + } + } + + // V0A + Run2V0AInfo.mhVtxAmpCorrV0A = getccdb("hVtx_fAmplitude_V0A_Normalized"); + Run2V0AInfo.mhMultSelCalib = getccdb("hMultSelCalib_V0A"); + if ((Run2V0AInfo.mhVtxAmpCorrV0A != nullptr) && (Run2V0AInfo.mhMultSelCalib != nullptr)) { + Run2V0AInfo.mCalibrationStored = true; + } else { + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from V0A for run %d corrupted", collision.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(warning, "Calibration information from V0A for run %d corrupted, will fill V0A tables with dummy values", collision.runNumber()); + } + } + + // SPD tracklets + Run2SPDTksInfo.mhVtxAmpCorr = getccdb("hVtx_fnTracklets_Normalized"); + Run2SPDTksInfo.mhMultSelCalib = getccdb("hMultSelCalib_SPDTracklets"); + if ((Run2SPDTksInfo.mhVtxAmpCorr != nullptr) && (Run2SPDTksInfo.mhMultSelCalib != nullptr)) { + Run2SPDTksInfo.mCalibrationStored = true; + } else { + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from SPD tracklets for run %d corrupted", collision.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(warning, "Calibration information from SPD tracklets for run %d corrupted, will fill SPD tracklets tables with dummy values", collision.runNumber()); + } + } + + // SPD clusters + Run2SPDClsInfo.mhVtxAmpCorrCL0 = getccdb("hVtx_fnSPDClusters0_Normalized"); + Run2SPDClsInfo.mhVtxAmpCorrCL1 = getccdb("hVtx_fnSPDClusters1_Normalized"); + Run2SPDClsInfo.mhMultSelCalib = getccdb("hMultSelCalib_SPDClusters"); + if ((Run2SPDClsInfo.mhVtxAmpCorrCL0 != nullptr) && (Run2SPDClsInfo.mhVtxAmpCorrCL1 != nullptr) && (Run2SPDClsInfo.mhMultSelCalib != nullptr)) { + Run2SPDClsInfo.mCalibrationStored = true; + } else { + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Calibration information from SPD clusters for run %d corrupted", collision.runNumber()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(warning, "Calibration information from SPD clusters for run %d corrupted, will fill SPD clusters tables with dummy values", collision.runNumber()); + } + } + } else { + // we are in Run 3 + auto getccdb = [lCalibObjects_Centrality, collision](struct CalibrationInfo& estimator, const Configurable generatorName, const Configurable notCrashOnNull) { // TODO: to consider the name inside the estimator structure + estimator.mhMultSelCalib = reinterpret_cast(lCalibObjects_Centrality->FindObject(TString::Format("hCalibZeq%s", estimator.name.c_str()).Data())); + estimator.mMCScale = reinterpret_cast(lCalibObjects_Centrality->FindObject(TString::Format("%s-%s", generatorName->c_str(), estimator.name.c_str()).Data())); + if (estimator.mhMultSelCalib != nullptr) { + if (generatorName->length() != 0) { + LOGF(info, "Retrieving MC calibration for %d, generator name: %s", collision.runNumber(), generatorName->c_str()); + if (estimator.mMCScale != nullptr) { + for (int ixpar = 0; ixpar < 6; ++ixpar) { + estimator.mMCScalePars[ixpar] = estimator.mMCScale->GetParameter(ixpar); + LOGF(info, "Parameter index %i value %.5f", ixpar, estimator.mMCScalePars[ixpar]); + } + } else { + LOGF(warning, "MC Scale information from %s for run %d not available", estimator.name.c_str(), collision.runNumber()); + } + } + estimator.mCalibrationStored = true; + estimator.isSane(); + } else { + if (!notCrashOnNull.value) { // default behaviour: crash + LOGF(error, "Calibration information from %s for run %d not available", estimator.name.c_str(), collision.runNumber()); + } else { + LOGF(warning, "Calibration information from %s for run %d not available", estimator.name.c_str(), collision.runNumber()); + } + } + }; + getccdb(fv0aInfo, ccdbConfig.genName, ccdbConfig.doNotCrashOnNull); + getccdb(ft0mInfo, ccdbConfig.genName, ccdbConfig.doNotCrashOnNull); + getccdb(ft0aInfo, ccdbConfig.genName, ccdbConfig.doNotCrashOnNull); + getccdb(ft0cInfo, ccdbConfig.genName, ccdbConfig.doNotCrashOnNull); + getccdb(ft0cVariant1Info, ccdbConfig.genName, ccdbConfig.doNotCrashOnNull); + getccdb(fddmInfo, ccdbConfig.genName, ccdbConfig.doNotCrashOnNull); + getccdb(ntpvInfo, ccdbConfig.genName, ccdbConfig.doNotCrashOnNull); + getccdb(nGlobalInfo, ccdbConfig.genName, ccdbConfig.doNotCrashOnNull); + getccdb(mftInfo, ccdbConfig.genName, ccdbConfig.doNotCrashOnNull); + + if (lCalibObjects_Multiplicity) { + if (produceHistograms) { + listCalib->Add(lCalibObjects_Multiplicity->Clone(Form("Multiplicity_%i", collision.runNumber()))); + } + + hVtxZFV0A = static_cast(lCalibObjects_Multiplicity->FindObject("hVtxZFV0A")); + hVtxZFT0A = static_cast(lCalibObjects_Multiplicity->FindObject("hVtxZFT0A")); + hVtxZFT0C = static_cast(lCalibObjects_Multiplicity->FindObject("hVtxZFT0C")); + hVtxZFDDA = static_cast(lCalibObjects_Multiplicity->FindObject("hVtxZFDDA")); + hVtxZFDDC = static_cast(lCalibObjects_Multiplicity->FindObject("hVtxZFDDC")); + hVtxZNTracks = static_cast(lCalibObjects_Multiplicity->FindObject("hVtxZNTracksPV")); + lCalibLoaded = true; + // Capture error + if (!hVtxZFV0A || !hVtxZFT0A || !hVtxZFT0C || !hVtxZFDDA || !hVtxZFDDC || !hVtxZNTracks) { + LOGF(error, "Problem loading CCDB objects! Please check"); + lCalibLoaded = false; + } + } else { + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Multiplicity calibration is not available in CCDB for run=%d at timestamp=%llu", collision.runNumber(), collision.timestamp()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(warning, "Multiplicity calibration is not available in CCDB for run=%d at timestamp=%llu, will fill tables with dummy values", collision.runNumber(), collision.timestamp()); + } + lCalibLoaded = false; + } + } // end we are in Run 3 + } else { + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash + LOGF(fatal, "Centrality calibration is not available in CCDB for run=%d at timestamp=%llu", collision.runNumber(), collision.timestamp()); + } else { // only if asked: continue filling with non-valid values (105) + LOGF(warning, "Centrality calibration is not available in CCDB for run=%d at timestamp=%llu, will fill tables with dummy values", collision.runNumber(), collision.timestamp()); + } + lCalibLoaded = false; + } + } + + void processRun2(soa::Join const& collisions) + { + for (auto const& collision : collisions) { + if (doVertexZeq > 0) { + initCCDB(collision); + } + + float centRun2V0M = 105.0f; + float centRun2V0A = 105.0f; + float centRun2SPDTrks = 105.0f; + float centRun2SPDClss = 105.0f; + + auto scaleMC = [](float x, float pars[6]) { + return std::pow(((pars[0] + pars[1] * std::pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); + }; + + // Run 2 V0M + if (Run2V0MInfo.mCalibrationStored) { + float v0m; + if (Run2V0MInfo.mMCScale != nullptr) { + v0m = scaleMC(collision.multFV0A() + collision.multFV0C(), Run2V0MInfo.mMCScalePars); + LOGF(debug, "Unscaled v0m: %f, scaled v0m: %f", collision.multFV0A() + collision.multFV0C(), v0m); + } else { + v0m = collision.multFV0A() * Run2V0MInfo.mhVtxAmpCorrV0A->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0A->FindFixBin(collision.posZ())) + + collision.multFV0C() * Run2V0MInfo.mhVtxAmpCorrV0C->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0C->FindFixBin(collision.posZ())); + } + centRun2V0M = Run2V0MInfo.mhMultSelCalib->GetBinContent(Run2V0MInfo.mhMultSelCalib->FindFixBin(v0m)); + } + LOGF(debug, "centRun2V0M=%.0f", centRun2V0M); + + // Run 2 V0A + if (Run2V0AInfo.mCalibrationStored) { + float v0a = collision.multFV0A() * Run2V0AInfo.mhVtxAmpCorrV0A->GetBinContent(Run2V0AInfo.mhVtxAmpCorrV0A->FindFixBin(collision.posZ())); + centRun2V0A = Run2V0AInfo.mhMultSelCalib->GetBinContent(Run2V0AInfo.mhMultSelCalib->FindFixBin(v0a)); + } + LOGF(debug, "centRun2V0A=%.0f", centRun2V0A); + + // Run 2 SPD tracklets + if (Run2SPDTksInfo.mCalibrationStored) { + float spdm = collision.multTracklets() * Run2SPDTksInfo.mhVtxAmpCorr->GetBinContent(Run2SPDTksInfo.mhVtxAmpCorr->FindFixBin(collision.posZ())); + centRun2SPDTrks = Run2SPDTksInfo.mhMultSelCalib->GetBinContent(Run2SPDTksInfo.mhMultSelCalib->FindFixBin(spdm)); + } + LOGF(debug, "centSPDTracklets=%.0f", centRun2SPDTrks); + + // Run 2 SPD Cls + if (Run2SPDClsInfo.mCalibrationStored) { + // spdClustersL0 and spdClustersL1 not available in strangeness data model + float spdm = collision.spdClustersL0() * Run2SPDClsInfo.mhVtxAmpCorrCL0->GetBinContent(Run2SPDClsInfo.mhVtxAmpCorrCL0->FindFixBin(collision.posZ())) + + collision.spdClustersL1() * Run2SPDClsInfo.mhVtxAmpCorrCL1->GetBinContent(Run2SPDClsInfo.mhVtxAmpCorrCL1->FindFixBin(collision.posZ())); + centRun2SPDClss = Run2SPDClsInfo.mhMultSelCalib->GetBinContent(Run2SPDClsInfo.mhMultSelCalib->FindFixBin(spdm)); + } + LOGF(debug, "centSPDClusters=%.0f", centRun2SPDClss); + + strangeCentsRun2(centRun2V0M, centRun2V0A, + centRun2SPDTrks, centRun2SPDClss); + } + } + + void processRun3(soa::Join const& collisions) + { + for (auto const& collision : collisions) { + if (doVertexZeq > 0) { + initCCDB(collision); + } + + float multZeqFV0A = 0.f; + float multZeqFT0A = 0.f; + float multZeqFT0C = 0.f; + // float multZeqFDDA = 0.f; + // float multZeqFDDC = 0.f; + + if (std::fabs(collision.posZ()) < 15.0f && hVtxZFV0A) { + multZeqFV0A = hVtxZFV0A->Interpolate(0.0) * collision.multFV0A() / hVtxZFV0A->Interpolate(collision.posZ()); + } + if (std::fabs(collision.posZ()) < 15.0f && hVtxZFT0A) { + multZeqFT0A = hVtxZFT0A->Interpolate(0.0) * collision.multFT0A() / hVtxZFT0A->Interpolate(collision.posZ()); + } + if (std::fabs(collision.posZ()) < 15.0f && hVtxZFT0C) { + multZeqFT0C = hVtxZFT0C->Interpolate(0.0) * collision.multFT0C() / hVtxZFT0C->Interpolate(collision.posZ()); + } + // if (std::fabs(collision.posZ()) < 15.0f && hVtxZFDDA) { + // multZeqFDDA = hVtxZFDDA->Interpolate(0.0) * collision.multFDDA() / hVtxZFDDA->Interpolate(collision.posZ()); + // } + // if (std::fabs(collision.posZ()) < 15.0f && hVtxZFDDC) { + // multZeqFDDC = hVtxZFDDC->Interpolate(0.0) * collision.multFDDC() / hVtxZFDDC->Interpolate(collision.posZ()); + // } + + /** + * @brief Get centrality value based on the given calibration information and multiplicity. + * Modified version of populateTable (https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/centralityTable.cxx#L648) + * + * @param estimator The calibration information. + * @param multiplicity The multiplicity value. + */ + + auto getCentrality = [&](struct CalibrationInfo& estimator, float multiplicity) { + const bool assignOutOfRange = embedINELgtZEROselection && !(collision.multNTracksPVeta1() > 0); + auto scaleMC = [](float x, float pars[6]) { + return std::pow(((pars[0] + pars[1] * std::pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); + }; + + float percentile = 105.0f; + float scaledMultiplicity = multiplicity; + if (estimator.mCalibrationStored) { + if (estimator.mMCScale != nullptr) { + scaledMultiplicity = scaleMC(multiplicity, estimator.mMCScalePars); + LOGF(debug, "Unscaled %s multiplicity: %f, scaled %s multiplicity: %f", estimator.name.c_str(), multiplicity, estimator.name.c_str(), scaledMultiplicity); + } + percentile = estimator.mhMultSelCalib->GetBinContent(estimator.mhMultSelCalib->FindFixBin(scaledMultiplicity)); + if (assignOutOfRange) + percentile = 100.5f; + } + LOGF(debug, "%s centrality/multiplicity percentile = %.0f for a zvtx eq %s value %.0f", estimator.name.c_str(), percentile, estimator.name.c_str(), scaledMultiplicity); + return percentile; + }; + + float centFT0M = getCentrality(ft0mInfo, multZeqFT0A + multZeqFT0C); + float centFT0A = getCentrality(ft0aInfo, multZeqFT0A); + float centFT0C = getCentrality(ft0cInfo, multZeqFT0C); + float centFV0A = getCentrality(fv0aInfo, multZeqFV0A); + float centFT0CVariant1 = getCentrality(ft0cVariant1Info, multZeqFT0C); + float centMFT = 100.5f; // missing mftNtracks in strangeness data model + float centNGlobal = getCentrality(nGlobalInfo, collision.multNTracksGlobal()); + + strangeCents(centFT0M, centFT0A, + centFT0C, centFV0A, centFT0CVariant1, + centMFT, centNGlobal); + + if (produceHistograms.value) { + histos.fill(HIST("FT0M/Mult"), multZeqFT0A + multZeqFT0C); + histos.fill(HIST("FT0M/percentile"), centFT0M); + histos.fill(HIST("FT0M/percentilevsPV"), centFT0M, collision.multNTracksPVeta1()); + histos.fill(HIST("FT0M/MultvsPV"), multZeqFT0A + multZeqFT0C, collision.multNTracksPVeta1()); + + histos.fill(HIST("FT0A/Mult"), multZeqFT0A); + histos.fill(HIST("FT0A/percentile"), centFT0A); + histos.fill(HIST("FT0A/percentilevsPV"), centFT0A, collision.multNTracksPVeta1()); + histos.fill(HIST("FT0A/MultvsPV"), multZeqFT0A, collision.multNTracksPVeta1()); + + histos.fill(HIST("FT0C/Mult"), multZeqFT0C); + histos.fill(HIST("FT0C/percentile"), centFT0C); + histos.fill(HIST("FT0C/percentilevsPV"), centFT0C, collision.multNTracksPVeta1()); + histos.fill(HIST("FT0C/MultvsPV"), multZeqFT0C, collision.multNTracksPVeta1()); + if (collision.sel8()) { + histos.fill(HIST("sel8FT0M/Mult"), multZeqFT0A + multZeqFT0C); + histos.fill(HIST("sel8FT0M/percentile"), centFT0M); + histos.fill(HIST("sel8FT0M/percentilevsPV"), centFT0M, collision.multNTracksPVeta1()); + histos.fill(HIST("sel8FT0M/MultvsPV"), multZeqFT0A + multZeqFT0C, collision.multNTracksPVeta1()); + + histos.fill(HIST("sel8FT0A/Mult"), multZeqFT0A); + histos.fill(HIST("sel8FT0A/percentile"), centFT0A); + histos.fill(HIST("sel8FT0A/percentilevsPV"), centFT0A, collision.multNTracksPVeta1()); + histos.fill(HIST("sel8FT0A/MultvsPV"), multZeqFT0A, collision.multNTracksPVeta1()); + + histos.fill(HIST("sel8FT0C/Mult"), multZeqFT0C); + histos.fill(HIST("sel8FT0C/percentile"), centFT0C); + histos.fill(HIST("sel8FT0C/percentilevsPV"), centFT0C, collision.multNTracksPVeta1()); + histos.fill(HIST("sel8FT0C/MultvsPV"), multZeqFT0C, collision.multNTracksPVeta1()); + } + } + } + } + + // Process switches + PROCESS_SWITCH(straCents, processRun2, "Provide Run2 calibrated centrality/multiplicity percentiles tables", false); + PROCESS_SWITCH(straCents, processRun3, "Provide Run3 calibrated centrality/multiplicity percentiles tables", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + metadataInfo.initMetadata(cfgc); + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/LFStrangeTreeCreator.cxx b/PWGLF/TableProducer/Strangeness/strangeTreeCreator.cxx similarity index 76% rename from PWGLF/TableProducer/Strangeness/LFStrangeTreeCreator.cxx rename to PWGLF/TableProducer/Strangeness/strangeTreeCreator.cxx index fd5f225ea99..455da9e0719 100644 --- a/PWGLF/TableProducer/Strangeness/LFStrangeTreeCreator.cxx +++ b/PWGLF/TableProducer/Strangeness/strangeTreeCreator.cxx @@ -9,35 +9,37 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include -#include -#include +/// \file strangeTreeCreator.cxx +/// \brief table producer for strangeness studies +/// \author Mario Ciacco -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFSlimStrangeTables.h" #include "PWGLF/DataModel/LFStrangenessTables.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" #include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" -#include "DCAFitter/DCAFitterN.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGLF/DataModel/LFSlimStrangeTables.h" +#include "CCDB/BasicCCDBManager.h" +#include "DCAFitter/DCAFitterN.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" -#include "TDatabasePDG.h" +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -49,7 +51,7 @@ namespace { void momTotXYZ(std::array& momA, std::array const& momB, std::array const& momC) { - for (int i = 0; i < 3; ++i) { + for (unsigned int i{0}; i < momA.size(); ++i) { momA[i] = momB[i] + momC[i]; } } @@ -99,10 +101,27 @@ float etaFromMom(std::array const& momA, std::array const& m (1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) - (1.f * momA[2] + 1.f * momB[2]))); } -float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) +float calculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) { return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz)); } +float kineFactor(std::array const& momA, std::array const& momB, std::array const& momC, float const& massB, float const& massC, bool const& reso) +{ + float invMass = invMass2Body(momA, momC, momB, massC, massB); + float ptC = std::hypot(momC[0], momC[1]); + float ptB = std::hypot(momB[0], momB[1]); + float p2C = momC[0] * momC[0] + momC[1] * momC[1] + momC[2] * momC[2]; + float p2B = momB[0] * momB[0] + momB[1] * momB[1] + momB[2] * momB[2]; + float eC = RecoDecay::sqrtSumOfSquares(momC[0], momC[1], momC[2], massC); + float eB = RecoDecay::sqrtSumOfSquares(momB[0], momB[1], momB[2], massB); + float pCpB = momC[0] * momB[0] + momC[1] * momB[1] + momC[2] * momB[2]; + float kineC = (eB * p2C / eC / ptC) - pCpB / ptC; + float kineB = (eC * p2B / eB / ptB) - pCpB / ptB; + if (reso) { + return std::hypot(kineC, kineB) / invMass; + } + return (kineC + kineB) / invMass; +} } // namespace struct CandidateV0 { @@ -145,7 +164,7 @@ struct CandidateV0 { int64_t globalIndexNeg = -999; }; -struct LFStrangeTreeCreator { +struct StrangeTreeCreator { Produces lambdaTableML; Produces v0TableAP; Produces mcLambdaTableML; @@ -156,16 +175,19 @@ struct LFStrangeTreeCreator { o2::vertexing::DCAFitterN<2> fitter; int mRunNumber; - float d_bz; - // o2::base::MatLayerCylSet* lut = nullptr; - Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"}; + float mBz; + o2::base::MatLayerCylSet* lut = nullptr; + Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrLUT), "Type of material correction"}; ConfigurableAxis centAxis{"centAxis", {106, 0, 106}, "binning for the centrality"}; ConfigurableAxis zVtxAxis{"zVtxBins", {100, -20.f, 20.f}, "Binning for the vertex z in cm"}; + ConfigurableAxis etaAxis{"etaAxis", {8, -0.8f, 0.8f}, "binning for pseudorapidity"}; + ConfigurableAxis massKineAxis{"kineAxis", {3000, -3.f, 3.f}, "binning for the kinematic-transofrmed mass shift distributions"}; // binning of (anti)lambda mass QA histograms ConfigurableAxis massLambdaAxis{"massLambdaAxis", {400, o2::constants::physics::MassLambda0 - 0.03f, o2::constants::physics::MassLambda0 + 0.03f}, "binning for the lambda invariant-mass"}; ConfigurableAxis massXiAxis{"massXiAxis", {400, o2::constants::physics::MassXiMinus - 0.05f, o2::constants::physics::MassXiMinus + 0.05f}, "binning for the Xi invariant-mass"}; + ConfigurableAxis massK0sAxis{"massK0sAxis", {400, o2::constants::physics::MassK0 - 0.1f, o2::constants::physics::MassK0 + 0.1f}, "binning for the K0s invariant-mass"}; Configurable zVtxMax{"zVtxMax", 10.0f, "maximum z position of the primary vertex"}; Configurable etaMax{"etaMax", 0.8f, "maximum eta"}; @@ -184,21 +206,24 @@ struct LFStrangeTreeCreator { Configurable v0trackNsharedClusTpc{"v0trackNsharedClusTpc", 5, "Maximum number of shared TPC clusters for V0 daughter"}; Configurable vetoMassK0Short{"vetoMassK0Short", 0.01f, "veto for V0 compatible with K0s mass"}; Configurable v0radiusMax{"v0radiusMax", 100.f, "maximum V0 radius eccepted"}; - - Configurable v0setting_dcav0dau{"v0setting_dcav0dau", 0.5f, "DCA V0 Daughters"}; - Configurable v0setting_dcav0pv{"v0setting_dcav0pv", 1.f, "DCA V0 to Pv"}; - Configurable v0setting_dcadaughtopv{"v0setting_dcadaughtopv", 0.1f, "DCA Pos To PV"}; - Configurable v0setting_cospa{"v0setting_cospa", 0.99f, "V0 CosPA"}; - Configurable v0setting_radius{"v0setting_radius", 5.f, "v0radius"}; - Configurable v0setting_lifetime{"v0setting_lifetime", 40.f, "v0 lifetime cut"}; - Configurable v0setting_nsigmatpc{"v0setting_nsigmatpc", 4.f, "nsigmatpc"}; - Configurable cascsetting_dcabachpv{"cascsetting_dcabachpv", 0.1f, "cascdcabachpv"}; - Configurable cascsetting_cospa{"cascsetting_cospa", 0.99f, "casc cospa cut"}; - Configurable cascsetting_dcav0bach{"cascsetting_dcav0bach", 1.0f, "dcav0bach"}; - Configurable cascsetting_vetoOm{"cascsetting_vetoOm", 0.01f, "vetoOm"}; - Configurable cascsetting_mXi{"cascsetting_mXi", 0.02f, "mXi"}; + Configurable v0alphaMax{"v0alphaMax", 10.f, "maximum Armenteros alpha (longitdinal momentum asymmetry)"}; + Configurable v0qtMin{"v0qtMin", 0.f, "minimum Armenteros qt (transverse momentum)"}; + + Configurable v0settingDcav0dau{"v0setting_dcav0dau", 0.5f, "DCA V0 Daughters"}; + Configurable v0settingDcav0pv{"v0setting_dcav0pv", 1.f, "DCA V0 to Pv"}; + Configurable v0settingDcadaughtopv{"v0setting_dcadaughtopv", 0.1f, "DCA Pos To PV"}; + Configurable v0settingCospa{"v0setting_cospa", 0.99f, "V0 CosPA"}; + Configurable v0settingRadius{"v0setting_radius", 5.f, "v0radius"}; + Configurable v0settingLifetime{"v0setting_lifetime", 40.f, "v0 lifetime cut"}; + Configurable v0settingNsigmatpc{"v0setting_nsigmatpc", 4.f, "nsigmatpc"}; + Configurable cascsettingDcabachpv{"cascsetting_dcabachpv", 0.1f, "cascdcabachpv"}; + Configurable cascsettingCospa{"cascsetting_cospa", 0.99f, "casc cospa cut"}; + Configurable cascsettingDcav0bach{"cascsetting_dcav0bach", 1.0f, "dcav0bach"}; + Configurable cascsettingVetoOm{"cascsetting_vetoOm", 0.01f, "vetoOm"}; + Configurable cascsettingMXi{"cascsetting_mXi", 0.02f, "mXi"}; Configurable lambdaMassCut{"lambdaMassCut", 0.02f, "maximum deviation from PDG mass (for QA histograms)"}; Configurable k0short{"k0short", false, "process for k0short (true) or lambda (false)"}; + Configurable tpcFindableClsOverCR{"tpcFindableClsOverCR", 0.8, "fraction of findable clusters over crossed rows in TPC"}; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -218,7 +243,7 @@ struct LFStrangeTreeCreator { if (track.itsNCls() < v0trackNclusItsCut || track.tpcNClsFound() < v0trackNclusTpcCut || track.tpcNClsCrossedRows() < v0trackNclusTpcCut || - track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || + track.tpcNClsCrossedRows() < tpcFindableClsOverCR * track.tpcNClsFindable() || track.tpcNClsShared() > v0trackNsharedClusTpc) { return false; } @@ -243,25 +268,28 @@ struct LFStrangeTreeCreator { o2::base::Propagator::initFieldFromGRP(grpmag); // Fetch magnetic field from ccdb for current collision - d_bz = o2::base::Propagator::Instance()->getNominalBz(); - LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << d_bz << " kG"; + mBz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << mBz << " kG"; mRunNumber = bc.runNumber(); - fitter.setBz(d_bz); + fitter.setBz(mBz); - // o2::base::Propagator::Instance()->setMatLUT(lut); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); + o2::base::Propagator::Instance()->setMatLUT(lut); + + int mat{static_cast(cfgMaterialCorrection)}; + fitter.setMatCorrType(static_cast(mat)); } void init(o2::framework::InitContext&) { mRunNumber = 0; - d_bz = 0; + mBz = 0; ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); - // lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); fitter.setPropagateToPCA(true); fitter.setMaxR(200.); @@ -272,8 +300,6 @@ struct LFStrangeTreeCreator { fitter.setMaxChi2(1e9); fitter.setUseAbsDCA(true); fitter.setWeightedFinalPCA(false); - int mat{static_cast(cfgMaterialCorrection)}; - fitter.setMatCorrType(static_cast(mat)); // event QA histos.add("QA/zVtx", ";#it{z}_{vtx} (cm);Entries", HistType::kTH1F, {zVtxAxis}); @@ -281,6 +307,11 @@ struct LFStrangeTreeCreator { // v0 QA histos.add("QA/massLambda", ";Centrality (%);#it{p}_{T} (GeV/#it{c});#it{M}(p + #pi^{-}) (GeV/#it{c}^{2});Entries", HistType::kTH3F, {centAxis, momAxis, massLambdaAxis}); histos.add("QA/massXi", ";Centrality (%);#it{p}_{T} (GeV/#it{c});#it{M}(#Lambda + #pi^{-}) (GeV/#it{c}^{2});Entries", HistType::kTH3F, {centAxis, momAxis, massXiAxis}); + histos.add("QA/massK0s", ";#it{p}_{T} (GeV/#it{c});#it{M}(#pi^{+} + #pi^{-}) (GeV/#it{c}^{2});Entries", HistType::kTH2F, {momAxis, massK0sAxis}); + + // histograms for momentum shift/resolution extraction + histos.add("massKineBias", ";#eta;#it{p}_{T} (GeV/#it{c});#delta#it{M}/#Sigma_{i}#partial#it{M}/#partial#it{p}^{i}_{T}", HistType::kTH3F, {etaAxis, momAxis, massKineAxis}); + histos.add("massKineReso", ";#eta;#it{p}_{T} (GeV/#it{c});#delta#it{M}/#Sigma_{i}(#partial#it{M}/#partial#it{p}^{i}_{T})^{2}", HistType::kTH3F, {etaAxis, momAxis, massKineAxis}); } template @@ -288,7 +319,7 @@ struct LFStrangeTreeCreator { { candidateV0s.clear(); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; for (const auto& v0 : V0s) { auto posTrack = v0.posTrack_as(); @@ -334,12 +365,21 @@ struct LFStrangeTreeCreator { } auto alpha = alphaAP(momV0, momPos, momNeg); + if (std::abs(alpha) > v0alphaMax) { + continue; + } + bool matter = alpha > 0; auto massPos = matter ? o2::constants::physics::MassProton : o2::constants::physics::MassPionCharged; auto massNeg = matter ? o2::constants::physics::MassPionCharged : o2::constants::physics::MassProton; auto mLambda = invMass2Body(momV0, momPos, momNeg, massPos, massNeg); auto mK0Short = invMass2Body(momV0, momPos, momNeg, o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged); + auto qt = qtAP(momV0, momPos); + if (std::abs(qt) < v0qtMin) { + continue; + } + // pid selections auto nSigmaTPCPos = matter ? posTrack.tpcNSigmaPr() : posTrack.tpcNSigmaPi(); auto nSigmaTPCNeg = matter ? negTrack.tpcNSigmaPi() : negTrack.tpcNSigmaPr(); @@ -349,7 +389,7 @@ struct LFStrangeTreeCreator { nSigmaTPCNeg = negTrack.tpcNSigmaPi(); } - if (std::abs(nSigmaTPCPos) > v0setting_nsigmatpc || std::abs(nSigmaTPCNeg) > v0setting_nsigmatpc) { + if (std::abs(nSigmaTPCPos) > v0settingNsigmatpc || std::abs(nSigmaTPCNeg) > v0settingNsigmatpc) { continue; } @@ -359,7 +399,7 @@ struct LFStrangeTreeCreator { } float dcaV0dau = std::sqrt(fitter.getChi2AtPCACandidate()); - if (dcaV0dau > v0setting_dcav0dau) { + if (dcaV0dau > v0settingDcav0dau) { continue; } @@ -367,22 +407,22 @@ struct LFStrangeTreeCreator { const auto& vtx = fitter.getPCACandidate(); float radiusV0 = std::hypot(vtx[0], vtx[1]); - if (radiusV0 < v0setting_radius || radiusV0 > v0radiusMax) { + if (radiusV0 < v0settingRadius || radiusV0 > v0radiusMax) { continue; } - float dcaV0Pv = CalculateDCAStraightToPV( + float dcaV0Pv = calculateDCAStraightToPV( vtx[0], vtx[1], vtx[2], momPos[0] + momNeg[0], momPos[1] + momNeg[1], momPos[2] + momNeg[2], collision.posX(), collision.posY(), collision.posZ()); - if (std::abs(dcaV0Pv) > v0setting_dcav0pv) { + if (std::abs(dcaV0Pv) > v0settingDcav0pv) { continue; } double cosPA = RecoDecay::cpa(primVtx, vtx, momV0); - if (cosPA < v0setting_cospa) { + if (cosPA < v0settingCospa) { continue; } @@ -395,38 +435,49 @@ struct LFStrangeTreeCreator { } else { particlemass = o2::constants::physics::MassLambda; } - float ML2P = particlemass * lengthTraveled / ptotal; - if (ML2P > v0setting_lifetime) { + float mL2P = particlemass * lengthTraveled / ptotal; + if (mL2P > v0settingLifetime) { continue; } o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, posTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); auto posDcaToPv = std::hypot(dcaInfo[0], dcaInfo[1]); - if (posDcaToPv < v0setting_dcadaughtopv && std::abs(dcaInfo[0]) < v0setting_dcadaughtopv) { + if (posDcaToPv < v0settingDcadaughtopv && std::abs(dcaInfo[0]) < v0settingDcadaughtopv) { continue; } o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, negTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); auto negDcaToPv = std::hypot(dcaInfo[0], dcaInfo[1]); - if (negDcaToPv < v0setting_dcadaughtopv && std::abs(dcaInfo[0]) < v0setting_dcadaughtopv) { + if (negDcaToPv < v0settingDcadaughtopv && std::abs(dcaInfo[0]) < v0settingDcadaughtopv) { continue; } if (std::abs(mLambda - o2::constants::physics::MassLambda0) > lambdaMassCut) { // for QA histograms continue; } + + float ptPos = std::hypot(momPos[0], momPos[1]); + float pPos = std::hypot(momPos[0], momPos[1], momPos[2]); + float etaPos = 0.5 * std::log((pPos + momPos[2]) / (pPos - momPos[2])); + float deltaMass = mK0Short - o2::constants::physics::MassK0; + float massKineBias = deltaMass / kineFactor(momV0, momPos, momNeg, o2::constants::physics::MassPiMinus, o2::constants::physics::MassPiMinus, false); + float massKineReso = deltaMass / kineFactor(momV0, momPos, momNeg, o2::constants::physics::MassPiMinus, o2::constants::physics::MassPiMinus, true); + histos.fill(HIST("QA/massLambda"), centrality, ptV0, mLambda); + histos.fill(HIST("QA/massK0s"), ptV0, mK0Short); + histos.fill(HIST("massKineBias"), etaPos, ptPos, massKineBias); + histos.fill(HIST("massKineReso"), etaPos, ptPos, massKineReso); CandidateV0 candV0; candV0.pt = matter > 0. ? ptV0 : -ptV0; candV0.eta = etaV0; - candV0.ct = ML2P; + candV0.ct = mL2P; candV0.len = lengthTraveled; candV0.mass = mLambda; candV0.radius = radiusV0; candV0.cpa = cosPA; candV0.alphaAP = alpha; - candV0.qtAP = qtAP(momV0, momPos); + candV0.qtAP = qt; candV0.trackv0 = fitter.createParentTrackParCov(); candV0.mompos = std::array{momPos[0], momPos[1], momPos[2]}; candV0.momneg = std::array{momNeg[0], momNeg[1], momNeg[2]}; @@ -442,7 +493,7 @@ struct LFStrangeTreeCreator { candidateV0s.push_back(candV0); } - for (auto& casc : cascades) { + for (const auto& casc : cascades) { auto v0 = casc.template v0_as(); auto itv0 = find_if(candidateV0s.begin(), candidateV0s.end(), [&](CandidateV0 v0cand) { return v0cand.globalIndex == v0.globalIndex(); }); if (itv0 == candidateV0s.end()) { @@ -452,7 +503,7 @@ struct LFStrangeTreeCreator { auto bachTrackPar = getTrackPar(bachTrack); o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, bachTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo); - if (TMath::Abs(dcaInfo[0]) < cascsetting_dcabachpv) + if (std::abs(dcaInfo[0]) < cascsettingDcabachpv) continue; auto bachelorTrack = getTrackParCov(bachTrack); @@ -476,23 +527,23 @@ struct LFStrangeTreeCreator { bachelorTrack.getPxPyPzGlo(momBach); momTotXYZ(momCasc, momV0, momBach); - auto dcacascv0bach = TMath::Sqrt(fitter.getChi2AtPCACandidate()); - if (dcacascv0bach > cascsetting_dcav0bach) + auto dcacascv0bach = std::sqrt(fitter.getChi2AtPCACandidate()); + if (dcacascv0bach > cascsettingDcav0bach) continue; std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; const auto& vtx = fitter.getPCACandidate(); double cosPA = RecoDecay::cpa(primVtx, vtx, momCasc); - if (cosPA < cascsetting_cospa) + if (cosPA < cascsettingCospa) continue; float mXi = invMass2Body(momCasc, momV0, momBach, o2::constants::physics::MassLambda0, o2::constants::physics::MassPionCharged); float mOm = invMass2Body(momCasc, momV0, momBach, o2::constants::physics::MassLambda0, o2::constants::physics::MassKaonCharged); - if (std::abs(mOm - o2::constants::physics::MassOmegaMinus) < cascsetting_vetoOm) + if (std::abs(mOm - o2::constants::physics::MassOmegaMinus) < cascsettingVetoOm) continue; - if (std::abs(mXi - o2::constants::physics::MassXiMinus) > cascsetting_mXi) + if (std::abs(mXi - o2::constants::physics::MassXiMinus) > cascsettingMXi) continue; histos.fill(HIST("QA/massXi"), centrality, std::hypot(momCasc[0], momCasc[1]), mXi); @@ -505,7 +556,7 @@ struct LFStrangeTreeCreator { { fillRecoEvent(collision, tracks, V0s, V0s_all, cascades, centrality); - for (auto& candidateV0 : candidateV0s) { + for (auto& candidateV0 : candidateV0s) { // o2-linter disable=const-red-in-for-loops (non const) candidateV0.isreco = true; auto mcLabPos = mcLabels.rawIteratorAt(candidateV0.globalIndexPos); auto mcLabNeg = mcLabels.rawIteratorAt(candidateV0.globalIndexNeg); @@ -519,23 +570,23 @@ struct LFStrangeTreeCreator { auto pdgCodeMotherDauNeg = -999; auto pdgMatchMotherSecondMother = -999; if (mcTrackPos.has_mothers() && mcTrackNeg.has_mothers()) { - for (auto& negMother : mcTrackNeg.template mothers_as()) { - for (auto& posMother : mcTrackPos.template mothers_as()) { + for (const auto& negMother : mcTrackNeg.template mothers_as()) { + for (const auto& posMother : mcTrackPos.template mothers_as()) { if (posMother.globalIndex() != negMother.globalIndex()) { pdgCodeMotherDauPos = posMother.pdgCode(); pdgCodeMotherDauNeg = negMother.pdgCode(); - if (negMother.pdgCode() == -211) { + if (negMother.pdgCode() == PDG_t::kPiMinus) { if (negMother.has_mothers()) { - for (auto& negSecondMother : negMother.template mothers_as()) { + for (const auto& negSecondMother : negMother.template mothers_as()) { if (negSecondMother.globalIndex() == posMother.globalIndex()) { pdgMatchMotherSecondMother = negSecondMother.pdgCode(); } } } } - if (posMother.pdgCode() == 211) { + if (posMother.pdgCode() == PDG_t::kPiPlus) { if (posMother.has_mothers()) { - for (auto& posSecondMother : posMother.template mothers_as()) { + for (const auto& posSecondMother : posMother.template mothers_as()) { if (posSecondMother.globalIndex() == negMother.globalIndex()) { pdgMatchMotherSecondMother = posSecondMother.pdgCode(); } @@ -550,13 +601,13 @@ struct LFStrangeTreeCreator { bool mother; bool daughter; if (k0short) { - // mother is k0short (310) and daughters are pions (211/-211) - mother = posMother.pdgCode() == 310; - daughter = (mcTrackPos.pdgCode() == 211 && mcTrackNeg.pdgCode() == -211); + // mother is k0short and daughters are pions + mother = posMother.pdgCode() == PDG_t::kK0Short; + daughter = (mcTrackPos.pdgCode() == PDG_t::kPiPlus && mcTrackNeg.pdgCode() == PDG_t::kPiMinus); } else { - // mother is lambda (3122) and daughters are proton (2212) and pion(211) - mother = posMother.pdgCode() == 3122; - daughter = ((mcTrackPos.pdgCode() == 2212 && mcTrackNeg.pdgCode() == -211) || (mcTrackPos.pdgCode() == 211 && mcTrackNeg.pdgCode() == -2212)); + // mother is lambda and daughters are proton and pion + mother = posMother.pdgCode() == PDG_t::kLambda0; + daughter = ((mcTrackPos.pdgCode() == PDG_t::kProton && mcTrackNeg.pdgCode() == PDG_t::kPiMinus) || (mcTrackPos.pdgCode() == PDG_t::kPiPlus && mcTrackNeg.pdgCode() == PDG_t::kProtonBar)); } // check conditions if (!mother || !daughter) { @@ -570,9 +621,9 @@ struct LFStrangeTreeCreator { if (posMother.isPhysicalPrimary()) { pdgCodeMother = 0; } else if (posMother.has_mothers()) { - for (auto& mcMother : posMother.mothers_as()) { + for (const auto& mcMother : posMother.mothers_as()) { // feed-down: xi and omega decaying to lambda, ignore for k0 - if (!k0short && (std::abs(mcMother.pdgCode()) == 3322 || std::abs(mcMother.pdgCode()) == 3312 || std::abs(mcMother.pdgCode()) == 3334)) { + if (!k0short && (std::abs(mcMother.pdgCode()) == o2::constants::physics::Pdg::kXi0 || std::abs(mcMother.pdgCode()) == PDG_t::kXiMinus || std::abs(mcMother.pdgCode()) == PDG_t::kOmegaMinus)) { pdgCodeMother = mcMother.pdgCode(); break; } @@ -595,13 +646,13 @@ struct LFStrangeTreeCreator { } if ((!mcTrackPos.has_mothers()) && mcTrackNeg.has_mothers()) { pdgCodeMotherDauPos = -999; - for (auto& negMother : mcTrackNeg.template mothers_as()) { + for (const auto& negMother : mcTrackNeg.template mothers_as()) { pdgCodeMotherDauNeg = negMother.pdgCode(); } } if ((!mcTrackNeg.has_mothers()) && mcTrackPos.has_mothers()) { pdgCodeMotherDauNeg = -999; - for (auto& posMother : mcTrackPos.template mothers_as()) { + for (const auto& posMother : mcTrackPos.template mothers_as()) { pdgCodeMotherDauPos = posMother.pdgCode(); } } @@ -629,8 +680,8 @@ struct LFStrangeTreeCreator { void fillMcGen(aod::McParticles const& mcParticles, aod::McTrackLabels const& /*mcLab*/, uint64_t const& collisionId) { - auto mcParticles_thisCollision = mcParticles.sliceBy(perCollisionMcParts, collisionId); - for (auto& mcPart : mcParticles_thisCollision) { + auto mcParticlesThisCollision = mcParticles.sliceBy(perCollisionMcParts, collisionId); + for (const auto& mcPart : mcParticlesThisCollision) { auto genEta = mcPart.eta(); if (std::abs(genEta) > etaMax) { continue; @@ -641,23 +692,23 @@ struct LFStrangeTreeCreator { std::array momPosMC = std::array{static_cast(-999.), static_cast(-999.), static_cast(-999.)}; std::array momNegMC = std::array{static_cast(-999.), static_cast(-999.), static_cast(-999.)}; - // look for lambda (3122) or k0short (310) - int pdg_test = 3122; + // look for lambda or k0short + int pdg_test = PDG_t::kLambda0; if (k0short) - pdg_test = 310; + pdg_test = PDG_t::kK0Short; if (std::abs(pdgCode) == pdg_test) { if (!mcPart.isPhysicalPrimary() && !mcPart.has_mothers()) continue; - // check if its the right decay containing proton (2122) for lambda and charged pion (211) for k0short + // check if its the right decay containing proton for lambda and charged pion for k0short int pdg_particle; if (k0short) { - pdg_particle = 211; + pdg_particle = PDG_t::kPiPlus; } else { - pdg_particle = 2212; + pdg_particle = PDG_t::kProton; } bool foundParticle = false; - for (auto& mcDaught : mcPart.daughters_as()) { + for (const auto& mcDaught : mcPart.daughters_as()) { if (std::abs(mcDaught.pdgCode()) == pdg_particle) { foundParticle = true; secVtx = std::array{mcDaught.vx(), mcDaught.vy(), mcDaught.vz()}; @@ -665,7 +716,7 @@ struct LFStrangeTreeCreator { } } // momentum of daughters - for (auto& mcDaught : mcPart.daughters_as()) { + for (const auto& mcDaught : mcPart.daughters_as()) { if (mcDaught.pdgCode() < 0) { momNegMC[0] = mcDaught.px(); momNegMC[1] = mcDaught.py(); @@ -683,9 +734,9 @@ struct LFStrangeTreeCreator { if (mcPart.isPhysicalPrimary()) { pdgCodeMother = 0; } else if (mcPart.has_mothers()) { - for (auto& mcMother : mcPart.mothers_as()) { + for (const auto& mcMother : mcPart.mothers_as()) { // feed-down: xi and omega decaying to lambda, ignore for k0 - if (!k0short && (std::abs(mcMother.pdgCode()) == 3322 || std::abs(mcMother.pdgCode()) == 3312 || std::abs(mcMother.pdgCode()) == 3334)) { + if (!k0short && (std::abs(mcMother.pdgCode()) == o2::constants::physics::Pdg::kXi0 || std::abs(mcMother.pdgCode()) == PDG_t::kXiMinus || std::abs(mcMother.pdgCode()) == PDG_t::kOmegaMinus)) { pdgCodeMother = mcMother.pdgCode(); break; } @@ -740,16 +791,16 @@ struct LFStrangeTreeCreator { histos.fill(HIST("QA/zVtx"), collision.posZ()); const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - auto CascTable_thisCollision = cascades.sliceBy(perCollisionCasc, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); - CascTable_thisCollision.bindExternalIndices(&tracks); - CascTable_thisCollision.bindExternalIndices(&V0s); + auto V0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + auto CascTableThisCollision = cascades.sliceBy(perCollisionCasc, collIdx); + V0TableThisCollision.bindExternalIndices(&tracks); + CascTableThisCollision.bindExternalIndices(&tracks); + CascTableThisCollision.bindExternalIndices(&V0s); auto centrality = collision.centFT0C(); - fillRecoEvent(collision, tracks, V0Table_thisCollision, V0s, CascTable_thisCollision, centrality); + fillRecoEvent(collision, tracks, V0TableThisCollision, V0s, CascTableThisCollision, centrality); - for (auto& candidateV0 : candidateV0s) { + for (const auto& candidateV0 : candidateV0s) { lambdaTableML( candidateV0.pt, candidateV0.eta, @@ -785,11 +836,11 @@ struct LFStrangeTreeCreator { } } } - PROCESS_SWITCH(LFStrangeTreeCreator, processRun3, "process (Run 3)", false); + PROCESS_SWITCH(StrangeTreeCreator, processRun3, "process (Run 3)", false); void processMcRun3(soa::Join const& collisions, aod::McCollisions const& /*mcCollisions*/, TracksFullIU const& tracks, aod::V0s const& V0s, aod::Cascades const& cascades, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, aod::BCsWithTimestamps const&) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { auto bc = collision.bc_as(); initCCDB(bc); @@ -807,16 +858,16 @@ struct LFStrangeTreeCreator { histos.fill(HIST("QA/zVtx"), collision.posZ()); const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - auto CascTable_thisCollision = cascades.sliceBy(perCollisionCasc, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); - CascTable_thisCollision.bindExternalIndices(&tracks); - CascTable_thisCollision.bindExternalIndices(&V0s); + auto V0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + auto CascTableThisCollision = cascades.sliceBy(perCollisionCasc, collIdx); + V0TableThisCollision.bindExternalIndices(&tracks); + CascTableThisCollision.bindExternalIndices(&tracks); + CascTableThisCollision.bindExternalIndices(&V0s); - fillMcEvent(collision, tracks, V0Table_thisCollision, V0s, CascTable_thisCollision, centrality, mcParticles, mcLab); + fillMcEvent(collision, tracks, V0TableThisCollision, V0s, CascTableThisCollision, centrality, mcParticles, mcLab); fillMcGen(mcParticles, mcLab, collision.mcCollisionId()); - for (auto& candidateV0 : candidateV0s) { + for (const auto& candidateV0 : candidateV0s) { mcLambdaTableML( candidateV0.pt, candidateV0.eta, @@ -872,11 +923,11 @@ struct LFStrangeTreeCreator { } } } - PROCESS_SWITCH(LFStrangeTreeCreator, processMcRun3, "process MC (Run 3)", false); + PROCESS_SWITCH(StrangeTreeCreator, processMcRun3, "process MC (Run 3)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx index 1dbbaa907c5..8140448576a 100644 --- a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx @@ -48,6 +48,7 @@ #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Qvectors.h" #include "Framework/StaticFor.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "Common/DataModel/McCollisionExtra.h" #include "PWGLF/DataModel/EPCalibrationTables.h" @@ -56,12 +57,14 @@ using namespace o2::framework; using namespace o2::framework::expressions; using std::array; -using TracksWithExtra = soa::Join; +using TracksWithExtra = soa::Join; using TracksCompleteIUMC = soa::Join; using FullTracksExtIUTOF = soa::Join; using FullCollisions = soa::Join; using UDCollisionsFull = soa::Join; +using BCsWithTimestampsAndRun2Infos = soa::Join; + // simple bit checkers #define bitset(var, nbit) ((var) |= (1 << (nbit))) #define bitcheck(var, nbit) ((var) & (1 << (nbit))) @@ -75,8 +78,10 @@ struct strangederivedbuilder { Produces strangeCollLabels; // characterises collisions Produces strangeMCColl; // characterises collisions / MC Produces strangeMCMults; // characterises collisions / MC mults - Produces strangeCents; // characterises collisions / centrality - Produces strangeEvSels; // characterises collisions / centrality / sel8 selection + Produces strangeCents; // characterises collisions / centrality in Run 3 + Produces strangeCentsRun2; // characterises collisions / centrality in Run 2 + Produces strangeEvSels; // characterises collisions / centrality / sel8 selection in Run 3 + Produces strangeEvSelsRun2; // characterises collisions / centrality / sel8 selection in Run 2 Produces strangeStamps; // provides timestamps, run numbers Produces v0collref; // references collisions from V0s Produces casccollref; // references collisions from cascades @@ -106,6 +111,11 @@ struct strangederivedbuilder { Produces cascmothers; // casc mother references Produces motherMCParts; // mc particles for mothers + //__________________________________________________ + // UPC specific information + Produces zdcNeutrons; // Primary neutrons within ZDC acceptance + Produces zdcNeutronsMCCollRefs; // references collisions from ZDCNeutrons + //__________________________________________________ // Q-vectors Produces StraFT0AQVs; // FT0A Q-vector @@ -127,11 +137,6 @@ struct strangederivedbuilder { Produces geOmegaMinus; Produces geOmegaPlus; - //__________________________________________________ - // Found tags for findable exercise - Produces v0FoundTags; - Produces cascFoundTags; - //__________________________________________________ // Debug Produces straOrigin; @@ -175,10 +180,14 @@ struct strangederivedbuilder { Configurable fillRawFT0A{"fillRawFT0A", false, "Fill raw FT0A information for debug"}; Configurable fillRawFT0C{"fillRawFT0C", true, "Fill raw FT0C information for debug"}; Configurable fillRawFV0A{"fillRawFV0A", false, "Fill raw FV0A information for debug"}; + Configurable fillRawFV0C{"fillRawFV0C", false, "Fill raw FV0C information for debug (only Run 2)"}; Configurable fillRawFDDA{"fillRawFDDA", false, "Fill raw FDDA information for debug"}; Configurable fillRawFDDC{"fillRawFDDC", false, "Fill raw FDDC information for debug"}; Configurable fillRawZDC{"fillRawZDC", false, "Fill raw ZDC information for debug"}; Configurable fillRawNTracksEta1{"fillRawNTracksEta1", true, "Fill raw NTracks |eta|<1 information for debug"}; + Configurable fillRawTrackletsRun2{"fillRawTrackletsRun2", true, "Fill raw tracklets information for debug (only Run 2)"}; + Configurable fillRawSPDclsL0Run2{"fillRawSPDclsL0Run2", true, "Fill raw SPD clusters at layer 0 information for debug (only Run 2)"}; + Configurable fillRawSPDclsL1Run2{"fillRawSPDclsL1Run2", true, "Fill raw SPD clusters at layer 1 information for debug (only Run 2)"}; Configurable fillRawNTracksForCorrelation{"fillRawNTracksForCorrelation", true, "Fill raw NTracks for correlation cuts"}; Configurable fillTOFInformation{"fillTOFInformation", true, "Fill Daughter Track TOF information"}; } fillTruncationOptions; @@ -202,6 +211,8 @@ struct strangederivedbuilder { Preslice mcParticlePerMcCollision = o2::aod::mcparticle::mcCollisionId; Preslice udCollisionsPerCollision = o2::aod::udcollision::collisionId; + Service pdg; + std::vector genK0Short; std::vector genLambda; std::vector genAntiLambda; @@ -222,17 +233,20 @@ struct strangederivedbuilder { void init(InitContext&) { LOGF(info, "Initializing now: cross-checking correctness..."); - if (doprocessCollisions + - doprocessCollisionsWithUD + - doprocessCollisionsWithMC + - doprocessCollisionsWithUDWithMC > + if (doprocessCollisionsRun3 + + doprocessCollisionsRun3WithUD + + doprocessCollisionsRun3WithMC + + doprocessCollisionsRun3WithUDWithMC + + doprocessCollisionsRun2 + + doprocessCollisionsRun2WithMC > 1) { LOGF(fatal, "You have enabled more than one process function associated to collisions. Please check your configuration! Aborting now."); } if (doprocessTrackExtrasV0sOnly + doprocessTrackExtras + doprocessTrackExtrasNoPID + - doprocessTrackExtrasMC > + doprocessTrackExtrasMC + + doprocessTrackExtrasMCNoPID > 1) { LOGF(fatal, "You have enabled more than one process function associated to TracksExtra. Please check your configuration! Aborting now."); } @@ -245,17 +259,23 @@ struct strangederivedbuilder { } // collision processing printout - if (doprocessCollisions) { - LOGF(info, "Collision processing type.........: no UD, no MC"); + if (doprocessCollisionsRun3) { + LOGF(info, "Collision processing type.........: Run 3, no UD, no MC"); + } + if (doprocessCollisionsRun3WithUD) { + LOGF(info, "Collision processing type.........: Run 3, with UD, no MC"); + } + if (doprocessCollisionsRun3WithMC) { + LOGF(info, "Collision processing type.........: Run 3, with MC, no UD"); } - if (doprocessCollisionsWithUD) { - LOGF(info, "Collision processing type.........: with UD, no MC"); + if (doprocessCollisionsRun3WithUDWithMC) { + LOGF(info, "Collision processing type.........: Run 3, with MC, with UD"); } - if (doprocessCollisionsWithMC) { - LOGF(info, "Collision processing type.........: with MC, no UD"); + if (doprocessCollisionsRun2) { + LOGF(info, "Collision processing type.........: Run 2, no UD, no MC"); } - if (doprocessCollisionsWithUDWithMC) { - LOGF(info, "Collision processing type.........: with MC, with UD"); + if (doprocessCollisionsRun2WithMC) { + LOGF(info, "Collision processing type.........: Run 2, with MC, no UD"); } LOGF(info, "====] event characterization processing [========================="); @@ -313,6 +333,9 @@ struct strangederivedbuilder { if (doprocessTrackExtrasMC) { LOGF(info, "TracksExtra processing type.......: V0s + cascades, Monte Carlo"); } + if (doprocessTrackExtrasMCNoPID) { + LOGF(info, "TracksExtra processing type.......: V0s + cascades, Monte Carlo"); + } LOGF(info, "====] cascade interlink processing [=============================="); if (doprocessCascadeInterlinkTracked) { LOGF(info, "Process cascade/tracked interlink.: yes"); @@ -345,17 +368,6 @@ struct strangederivedbuilder { } else { LOGF(info, "Process strange mothers...........: no"); } - LOGF(info, "====] findable exercise extras [=================================="); - if (doprocessV0FoundTags) { - LOGF(info, "Process found V0 tags.............: yes"); - } else { - LOGF(info, "Process found V0 tags.............: no"); - } - if (doprocessCascFoundTags) { - LOGF(info, "Process found cascade tags........: yes"); - } else { - LOGF(info, "Process found cascade tags........: no"); - } LOGF(info, "=================================================================="); // setup map for fast checking if enabled @@ -375,16 +387,6 @@ struct strangederivedbuilder { histos.add("h2dNVerticesVsCentrality", "h2dNVerticesVsCentrality", kTH2D, {axisCentrality, axisNVertices}); - if (doprocessV0FoundTags || doprocessCascFoundTags) { - auto h = histos.add("hFoundTagsCounters", "hFoundTagsCounters", kTH1D, {{6, -0.5f, 5.5f}}); - h->GetXaxis()->SetBinLabel(1, "Found V0s"); - h->GetXaxis()->SetBinLabel(2, "Findable V0s"); - h->GetXaxis()->SetBinLabel(3, "Findable & found V0s"); - h->GetXaxis()->SetBinLabel(4, "Found Cascades"); - h->GetXaxis()->SetBinLabel(5, "Findable Cascades"); - h->GetXaxis()->SetBinLabel(6, "Findable & found Cascades"); - } - // for QA and test purposes auto hRawCentrality = histos.add("hRawCentrality", "hRawCentrality", kTH1F, {axisRawCentrality}); @@ -417,8 +419,8 @@ struct strangederivedbuilder { } // master function to process a collision - template - void populateCollisionTables(coll const& collisions, udcoll const& udCollisions, v0d const& V0s, cad const& Cascades, kfcad const& KFCascades, tracad const& TraCascades) + template + void populateCollisionTables(coll const& collisions, udcoll const& udCollisions, v0d const& V0s, cad const& Cascades, kfcad const& KFCascades, tracad const& TraCascades, bcType const& /*bcs*/) { // create collision indices beforehand std::vector V0CollIndices(V0s.size(), -1); // index -1: no collision @@ -430,12 +432,6 @@ struct strangederivedbuilder { for (const auto& collision : collisions) { const uint64_t collIdx = collision.globalIndex(); - float centrality = collision.centFT0C(); - if (qaCentrality) { - auto hRawCentrality = histos.get(HIST("hRawCentrality")); - centrality = hRawCentrality->GetBinContent(hRawCentrality->FindBin(collision.multFT0C())); - } - auto V0Table_thisColl = V0s.sliceBy(V0perCollision, collIdx); auto CascTable_thisColl = Cascades.sliceBy(CascperCollision, collIdx); auto KFCascTable_thisColl = KFCascades.sliceBy(KFCascperCollision, collIdx); @@ -445,7 +441,7 @@ struct strangederivedbuilder { KFCascTable_thisColl.size() > 0 || TraCascTable_thisColl.size() > 0; - auto bc = collision.template bc_as(); + auto bc = collision.template bc_as(); int gapSide = -1; float totalFT0AmplitudeA = -999; @@ -486,41 +482,78 @@ struct strangederivedbuilder { // +-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ // fill collision tables if (strange || fillEmptyCollisions) { + strangeStamps(bc.runNumber(), bc.timestamp(), bc.globalBC()); strangeColl(collision.posX(), collision.posY(), collision.posZ()); if constexpr (requires { collision.mcCollisionId(); }) { // check if MC information is available and if so fill labels strangeCollLabels(collision.mcCollisionId()); } - strangeCents(collision.centFT0M(), collision.centFT0A(), - centrality, collision.centFV0A()); - strangeEvSels(collision.sel8(), collision.selection_raw(), - collision.multFT0A() * static_cast(fillTruncationOptions.fillRawFT0A), - collision.multFT0C() * static_cast(fillTruncationOptions.fillRawFT0C), - collision.multFV0A() * static_cast(fillTruncationOptions.fillRawFV0A), - collision.multFDDA() * static_cast(fillTruncationOptions.fillRawFDDA), - collision.multFDDC() * static_cast(fillTruncationOptions.fillRawFDDC), - collision.multNTracksPVeta1() * static_cast(fillTruncationOptions.fillRawNTracksEta1), - collision.multPVTotalContributors() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), - collision.multNTracksGlobal() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), - collision.multNTracksITSTPC() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), - collision.multAllTracksTPCOnly() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), - collision.multAllTracksITSTPC() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), - collision.multZNA() * static_cast(fillTruncationOptions.fillRawZDC), - collision.multZNC() * static_cast(fillTruncationOptions.fillRawZDC), - collision.multZEM1() * static_cast(fillTruncationOptions.fillRawZDC), - collision.multZEM2() * static_cast(fillTruncationOptions.fillRawZDC), - collision.multZPA() * static_cast(fillTruncationOptions.fillRawZDC), - collision.multZPC() * static_cast(fillTruncationOptions.fillRawZDC), - collision.trackOccupancyInTimeRange(), - collision.ft0cOccupancyInTimeRange(), - // UPC info - gapSide, - totalFT0AmplitudeA, totalFT0AmplitudeC, totalFV0AmplitudeA, - totalFDDAmplitudeA, totalFDDAmplitudeC, - energyCommonZNA, energyCommonZNC, - // Collision flags - collision.flags(), - collision.alias_raw()); - strangeStamps(bc.runNumber(), bc.timestamp(), bc.globalBC()); + + if constexpr (requires { collision.centFT0C(); }) { // check if we are in Run 3 + float centrality = collision.centFT0C(); + if (qaCentrality) { + auto hRawCentrality = histos.get(HIST("hRawCentrality")); + centrality = hRawCentrality->GetBinContent(hRawCentrality->FindBin(collision.multFT0C())); + } + + strangeCents(collision.centFT0M(), collision.centFT0A(), + centrality, collision.centFV0A(), collision.centFT0CVariant1(), + collision.centMFT(), collision.centNGlobal()); + strangeEvSels(collision.sel8(), collision.selection_raw(), + collision.multFT0A() * static_cast(fillTruncationOptions.fillRawFT0A), + collision.multFT0C() * static_cast(fillTruncationOptions.fillRawFT0C), + collision.multFV0A() * static_cast(fillTruncationOptions.fillRawFV0A), + collision.multFDDA() * static_cast(fillTruncationOptions.fillRawFDDA), + collision.multFDDC() * static_cast(fillTruncationOptions.fillRawFDDC), + collision.multNTracksPVeta1() * static_cast(fillTruncationOptions.fillRawNTracksEta1), + collision.multPVTotalContributors() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), + collision.multNTracksGlobal() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), + collision.multNTracksITSTPC() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), + collision.multAllTracksTPCOnly() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), + collision.multAllTracksITSTPC() * static_cast(fillTruncationOptions.fillRawNTracksForCorrelation), + collision.multZNA() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZNC() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZEM1() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZEM2() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZPA() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZPC() * static_cast(fillTruncationOptions.fillRawZDC), + collision.trackOccupancyInTimeRange(), + collision.ft0cOccupancyInTimeRange(), + // UPC info + gapSide, + totalFT0AmplitudeA, totalFT0AmplitudeC, totalFV0AmplitudeA, + totalFDDAmplitudeA, totalFDDAmplitudeC, + energyCommonZNA, energyCommonZNC, + // Collision flags + collision.flags(), + collision.alias_raw(), + collision.rct_raw()); + } else { // We are in Run 2 + strangeCentsRun2(collision.centRun2V0M(), collision.centRun2V0A(), + collision.centRun2SPDTracklets(), collision.centRun2SPDClusters()); + strangeEvSelsRun2(collision.sel8(), collision.sel7(), collision.selection_raw(), + collision.multFT0A() * static_cast(fillTruncationOptions.fillRawFT0A), + collision.multFT0C() * static_cast(fillTruncationOptions.fillRawFT0C), + collision.multFV0A() * static_cast(fillTruncationOptions.fillRawFV0A), + collision.multFV0C() * static_cast(fillTruncationOptions.fillRawFV0C), + collision.multFDDA() * static_cast(fillTruncationOptions.fillRawFDDA), + collision.multFDDC() * static_cast(fillTruncationOptions.fillRawFDDC), + bc.spdClustersL0() * static_cast(fillTruncationOptions.fillRawSPDclsL0Run2), + bc.spdClustersL1() * static_cast(fillTruncationOptions.fillRawSPDclsL1Run2), + collision.multNTracksPVeta1() * static_cast(fillTruncationOptions.fillRawNTracksEta1), + collision.multTracklets() * static_cast(fillTruncationOptions.fillRawTrackletsRun2), + -1, /* dummy number of PV contribs total while waiting for the multiplicity task to produce it */ + -1, /* dummy global track multiplicities while waiting for the multiplicity task to produce it */ + -1, /* dummy track multiplicities, PV contribs, no eta cut while waiting for the multiplicity task to produce it */ + -1, /* dummy TPConly track multiplicities, all, no eta cut while waiting for the multiplicity task to produce it */ + -1, /* dummy ITSTPC track multiplicities, all, no eta cut waiting for the multiplicity task to produce it */ + collision.multZNA() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZNC() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZEM1() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZEM2() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZPA() * static_cast(fillTruncationOptions.fillRawZDC), + collision.multZPC() * static_cast(fillTruncationOptions.fillRawZDC), + collision.alias_raw()); + } } for (const auto& v0 : V0Table_thisColl) V0CollIndices[v0.globalIndex()] = strangeColl.lastIndex(); @@ -549,41 +582,76 @@ struct strangederivedbuilder { } // master function to process a collision - template - void populateMCCollisionTable(mccoll const& mcCollisions) + template + void populateMCCollisionTable(mccoll const& mcCollisions, mcparts const& mcParticlesEntireTable) { // ______________________________________________ // fill all MC collisions, correlate via index later on for (const auto& mccollision : mcCollisions) { + const uint64_t mcCollIndex = mccollision.globalIndex(); + auto mcParticles = mcParticlesEntireTable.sliceBy(mcParticlePerMcCollision, mcCollIndex); + + // count total MC multiplicity in generated collision + // reproduces what is done here: + // https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/multiplicityTable.cxx#L654 + int totalMult = 0; + for (const auto& mcPart : mcParticles) { + if (!mcPart.isPhysicalPrimary()) { + continue; + } + + auto charge = 0.; + auto* p = pdg->GetParticle(mcPart.pdgCode()); + if (p != nullptr) { + charge = p->Charge(); + } + if (std::abs(charge) < 1e-3) { + continue; // reject neutral particles in counters + } + totalMult++; + } + strangeMCColl(mccollision.posX(), mccollision.posY(), mccollision.posZ(), - mccollision.impactParameter(), mccollision.eventPlaneAngle()); + mccollision.impactParameter(), mccollision.eventPlaneAngle(), mccollision.generatorsID()); strangeMCMults(mccollision.multMCFT0A(), mccollision.multMCFT0C(), mccollision.multMCNParticlesEta05(), mccollision.multMCNParticlesEta08(), - mccollision.multMCNParticlesEta10()); + mccollision.multMCNParticlesEta10(), + totalMult); } } - void processCollisions(soa::Join const& collisions, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, aod::BCsWithTimestamps const& /*bcs*/) + void processCollisionsRun3(soa::Join const& collisions, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, aod::BCsWithTimestamps const& bcs) + { + populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades, bcs); + } + + void processCollisionsRun3WithUD(soa::Join const& collisions, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, aod::BCsWithTimestamps const& bcs, UDCollisionsFull const& udCollisions) + { + populateCollisionTables(collisions, udCollisions, V0s, Cascades, KFCascades, TraCascades, bcs); + } + + void processCollisionsRun3WithMC(soa::Join const& collisions, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, aod::BCsWithTimestamps const& bcs, soa::Join const& mcCollisions, aod::McParticles const& mcParticles) { - populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades); + populateMCCollisionTable(mcCollisions, mcParticles); + populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades, bcs); } - void processCollisionsWithUD(soa::Join const& collisions, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, aod::BCsWithTimestamps const& /*bcs*/, UDCollisionsFull const& udCollisions) + void processCollisionsRun3WithUDWithMC(soa::Join const& collisions, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, aod::BCsWithTimestamps const& bcs, UDCollisionsFull const& udCollisions, soa::Join const& mcCollisions, aod::McParticles const& mcParticles) { - populateCollisionTables(collisions, udCollisions, V0s, Cascades, KFCascades, TraCascades); + populateMCCollisionTable(mcCollisions, mcParticles); + populateCollisionTables(collisions, udCollisions, V0s, Cascades, KFCascades, TraCascades, bcs); } - void processCollisionsWithMC(soa::Join const& collisions, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, aod::BCsWithTimestamps const& /*bcs*/, soa::Join const& mcCollisions, aod::McParticles const&) + void processCollisionsRun2(soa::Join const& collisions, aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, BCsWithTimestampsAndRun2Infos const& bcs) { - populateMCCollisionTable(mcCollisions); - populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades); + populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades, bcs); } - void processCollisionsWithUDWithMC(soa::Join const& collisions, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, aod::BCsWithTimestamps const& /*bcs*/, UDCollisionsFull const& udCollisions, soa::Join const& mcCollisions, aod::McParticles const&) + void processCollisionsRun2WithMC(soa::Join const& collisions, soa::Join const& V0s, soa::Join const& /*V0MCCores*/, soa::Join const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, BCsWithTimestampsAndRun2Infos const& bcs, soa::Join const& mcCollisions, aod::McParticles const& mcParticles) { - populateMCCollisionTable(mcCollisions); - populateCollisionTables(collisions, udCollisions, V0s, Cascades, KFCascades, TraCascades); + populateMCCollisionTable(mcCollisions, mcParticles); + populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades, bcs); } void processTrackExtrasV0sOnly(aod::V0Datas const& V0s, TracksWithExtra const& tracksExtra) @@ -620,11 +688,13 @@ struct strangederivedbuilder { for (auto const& tr : tracksExtra) { if (trackMap[tr.globalIndex()] >= 0) { dauTrackExtras(tr.itsChi2NCl(), + tr.tpcChi2NCl(), tr.detectorMap(), tr.itsClusterSizes(), tr.tpcNClsFindable(), tr.tpcNClsFindableMinusFound(), - tr.tpcNClsFindableMinusCrossedRows()); + tr.tpcNClsFindableMinusCrossedRows(), + tr.tpcNClsShared()); } } // done! @@ -714,11 +784,13 @@ struct strangederivedbuilder { for (auto const& tr : tracksExtra) { if (trackMap[tr.globalIndex()] >= 0) { dauTrackExtras(tr.itsChi2NCl(), + tr.tpcChi2NCl(), tr.detectorMap(), tr.itsClusterSizes(), tr.tpcNClsFindable(), tr.tpcNClsFindableMinusFound(), - tr.tpcNClsFindableMinusCrossedRows()); + tr.tpcNClsFindableMinusCrossedRows(), + tr.tpcNClsShared()); // _________________________________________ // if the table has MC info @@ -752,18 +824,23 @@ struct strangederivedbuilder { // done! } - void processTrackExtras(aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& tracksExtra, aod::V0s const&) + void processTrackExtras(aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& tracksExtra, aod::V0s const&) { fillTrackExtras(V0s, Cascades, KFCascades, TraCascades, tracksExtra); } // no TPC services - void processTrackExtrasNoPID(aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& tracksExtra, aod::V0s const&) + void processTrackExtrasNoPID(aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& tracksExtra, aod::V0s const&) { fillTrackExtras(V0s, Cascades, KFCascades, TraCascades, tracksExtra); } - void processTrackExtrasMC(aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& tracksExtra, aod::V0s const&) + void processTrackExtrasMC(aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& tracksExtra, aod::V0s const&) + { + fillTrackExtras(V0s, Cascades, KFCascades, TraCascades, tracksExtra); + } + + void processTrackExtrasMCNoPID(aod::V0Datas const& V0s, aod::CascDatas const& Cascades, aod::KFCascDatas const& KFCascades, aod::TraCascDatas const& TraCascades, soa::Join const& tracksExtra, aod::V0s const&) { fillTrackExtras(V0s, Cascades, KFCascades, TraCascades, tracksExtra); } @@ -774,12 +851,14 @@ struct strangederivedbuilder { //__________________________________________________ // mark mcParticles for referencing - for (auto const& v0 : V0s) + for (auto const& v0 : V0s) { if (v0.has_mcMotherParticle()) motherReference[v0.mcMotherParticleId()] = 0; - for (auto const& ca : Cascades) + } + for (auto const& ca : Cascades) { if (ca.has_mcMotherParticle()) motherReference[ca.mcMotherParticleId()] = 0; + } //__________________________________________________ // Figure out the numbering of the new mcMother table // assume filling per order @@ -791,10 +870,20 @@ struct strangederivedbuilder { } //__________________________________________________ // populate track references - for (auto const& v0 : V0s) - v0mothers(motherReference[v0.mcMotherParticleId()]); // joinable with V0Datas - for (auto const& ca : Cascades) - cascmothers(motherReference[ca.mcMotherParticleId()]); // joinable with CascDatas + for (auto const& v0 : V0s) { + if (v0.mcMotherParticleId() > -1) { + v0mothers(motherReference[v0.mcMotherParticleId()]); // joinable with V0Datas + } else { + v0mothers(-1); // joinable with V0Datas + } + } + for (auto const& ca : Cascades) { + if (ca.mcMotherParticleId() > -1) { + cascmothers(motherReference[ca.mcMotherParticleId()]); // joinable with CascDatas + } else { + cascmothers(-1); // joinable with CascDatas + } + } //__________________________________________________ // populate motherMCParticles for (auto const& tr : mcParticles) { @@ -960,7 +1049,7 @@ struct strangederivedbuilder { void processZDCSP(soa::Join::iterator const& collision) { StraZDCSP(collision.triggereventsp(), - collision.psiZDCA(), collision.psiZDCC()); + collision.psiZDCA(), collision.psiZDCC(), collision.qxZDCA(), collision.qxZDCC(), collision.qyZDCA(), collision.qyZDCC()); } void processFT0MQVectors(soa::Join::iterator const& collision) { @@ -979,86 +1068,63 @@ struct strangederivedbuilder { StraTPCQVs(collision.qTPCL() * std::cos(2 * collision.psiTPCL()), collision.qTPCL() * std::sin(2 * collision.psiTPCL()), collision.qTPCL(), collision.qTPCR() * std::cos(2 * collision.psiTPCR()), collision.qTPCR() * std::sin(2 * collision.psiTPCR()), collision.qTPCR()); } - uint64_t combineProngIndices(uint32_t low, uint32_t high) + using uint128_t = __uint128_t; + uint128_t combineProngIndices128(uint32_t pos, uint32_t neg, uint32_t bach) { - return ((static_cast(high)) << 32) | (static_cast(low)); + return ((static_cast(pos)) << 64) | ((static_cast(neg)) << 32) | (static_cast(bach)); } - void processV0FoundTags(aod::V0s const& foundV0s, aod::V0Datas const& findableV0s, aod::FindableV0s const& /* added to avoid troubles */) + void processDataframeIDs(aod::Origins const& origins) { - histos.fill(HIST("hFoundTagsCounters"), 0.0f, foundV0s.size()); - histos.fill(HIST("hFoundTagsCounters"), 1.0f, findableV0s.size()); - - for (auto const& findableV0 : findableV0s) { - bool hasBeenFound = false; - for (auto const& foundV0 : foundV0s) { - if (foundV0.posTrackId() == findableV0.posTrackId() && foundV0.negTrackId() == findableV0.negTrackId()) { - hasBeenFound = true; - } - } - v0FoundTags(hasBeenFound); - } + auto origin = origins.begin(); + straOrigin(origin.dataframeID()); } - using uint128_t = __uint128_t; - uint128_t combineProngIndices128(uint32_t pos, uint32_t neg, uint32_t bach) + void processSimulatedZDCNeutrons(soa::Join const& mcCollisions, aod::McParticles const& mcParticlesEntireTable) { - return ((static_cast(pos)) << 64) | ((static_cast(neg)) << 32) | (static_cast(bach)); - } + for (const auto& mccollision : mcCollisions) { + const uint64_t mcCollIndex = mccollision.globalIndex(); + auto mcParticles = mcParticlesEntireTable.sliceBy(mcParticlePerMcCollision, mcCollIndex); - void processCascFoundTags(aod::Cascades const& foundCascades, aod::CascDatas const& findableCascades, aod::V0s const&, aod::FindableCascades const& /* added to avoid troubles */) - { - histos.fill(HIST("hFoundTagsCounters"), 3.0f, foundCascades.size()); - histos.fill(HIST("hFoundTagsCounters"), 4.0f, findableCascades.size()); - - // pack the found V0s in a long long - std::vector foundCascadesPacked; - foundCascadesPacked.reserve(foundCascades.size()); - for (auto const& foundCascade : foundCascades) { - auto v0 = foundCascade.v0(); - foundCascadesPacked[foundCascade.globalIndex()] = combineProngIndices128(v0.posTrackId(), v0.negTrackId(), foundCascade.bachelorId()); - } - - bool hasBeenFound = false; - for (auto const& findableCascade : findableCascades) { - uint128_t indexPack = combineProngIndices128(findableCascade.posTrackId(), findableCascade.negTrackId(), findableCascade.bachelorId()); - for (uint32_t ic = 0; ic < foundCascades.size(); ic++) { - if (indexPack == foundCascadesPacked[ic]) { - hasBeenFound = true; - histos.fill(HIST("hFoundTagsCounters"), 5.0f); - break; + for (const auto& mcPart : mcParticles) { + if (std::abs(mcPart.pdgCode()) == kNeutron) { // check if it is a neutron or anti-neutron + if (std::abs(mcPart.eta()) > 8.7) { // check if it is within ZDC acceptance + zdcNeutrons(mcPart.pdgCode(), mcPart.statusCode(), mcPart.flags(), + mcPart.vx(), mcPart.vy(), mcPart.vz(), mcPart.vt(), + mcPart.px(), mcPart.py(), mcPart.pz(), mcPart.e()); + + zdcNeutronsMCCollRefs(mcPart.mcCollisionId()); + } } } - cascFoundTags(hasBeenFound); } } - void processDataframeIDs(aod::Origins const& origins) - { - auto origin = origins.begin(); - straOrigin(origin.dataframeID()); - } - // debug processing PROCESS_SWITCH(strangederivedbuilder, processDataframeIDs, "Produce data frame ID tags", false); - // collision processing - PROCESS_SWITCH(strangederivedbuilder, processCollisions, "Produce collisions", true); - PROCESS_SWITCH(strangederivedbuilder, processCollisionsWithUD, "Produce collisions with UD info", true); - PROCESS_SWITCH(strangederivedbuilder, processCollisionsWithMC, "Produce collisions with MC info", true); - PROCESS_SWITCH(strangederivedbuilder, processCollisionsWithUDWithMC, "Produce collisions with UD + MC info", true); + // Run 3: collision processing + PROCESS_SWITCH(strangederivedbuilder, processCollisionsRun3, "Produce collisions (Run 3)", true); + PROCESS_SWITCH(strangederivedbuilder, processCollisionsRun3WithUD, "Produce collisions (Run 3) with UD info", true); + PROCESS_SWITCH(strangederivedbuilder, processCollisionsRun3WithMC, "Produce collisions (Run 3) with MC info", true); + PROCESS_SWITCH(strangederivedbuilder, processCollisionsRun3WithUDWithMC, "Produce collisions (Run 3) with UD + MC info", true); + // Run 2: collision processing + PROCESS_SWITCH(strangederivedbuilder, processCollisionsRun2, "Produce collisions (Run2)", false); + PROCESS_SWITCH(strangederivedbuilder, processCollisionsRun2WithMC, "Produce collisions (Run 2) with MC info", false); // detailed information processing PROCESS_SWITCH(strangederivedbuilder, processTrackExtrasV0sOnly, "Produce track extra information (V0s only)", true); PROCESS_SWITCH(strangederivedbuilder, processTrackExtras, "Produce track extra information (V0s + casc)", true); PROCESS_SWITCH(strangederivedbuilder, processTrackExtrasNoPID, "Produce track extra information (V0s + casc), no PID", false); PROCESS_SWITCH(strangederivedbuilder, processTrackExtrasMC, "Produce track extra information (V0s + casc)", false); + PROCESS_SWITCH(strangederivedbuilder, processTrackExtrasMCNoPID, "Produce track extra information (V0s + casc), no PID", false); PROCESS_SWITCH(strangederivedbuilder, processStrangeMothers, "Produce tables with mother info for V0s + casc", true); PROCESS_SWITCH(strangederivedbuilder, processCascadeInterlinkTracked, "Produce tables interconnecting cascades", false); PROCESS_SWITCH(strangederivedbuilder, processCascadeInterlinkKF, "Produce tables interconnecting cascades", false); PROCESS_SWITCH(strangederivedbuilder, processPureSimulation, "Produce pure simulated information", true); PROCESS_SWITCH(strangederivedbuilder, processReconstructedSimulation, "Produce reco-ed simulated information", true); PROCESS_SWITCH(strangederivedbuilder, processBinnedGenerated, "Produce binned generated information", false); + PROCESS_SWITCH(strangederivedbuilder, processSimulatedZDCNeutrons, "Produce generated neutrons (within ZDC acceptance) table for UPC analysis", false); // event plane information PROCESS_SWITCH(strangederivedbuilder, processFT0AQVectors, "Produce FT0A Q-vectors table", false); @@ -1069,10 +1135,6 @@ struct strangederivedbuilder { PROCESS_SWITCH(strangederivedbuilder, processTPCQVectors, "Produce TPC Q-vectors table", false); PROCESS_SWITCH(strangederivedbuilder, processTPCQVectorsLF, "Produce TPC Q-vectors table using LF temporary calibration", false); PROCESS_SWITCH(strangederivedbuilder, processZDCSP, "Produce ZDC SP table", false); - - // dedicated findable functionality - PROCESS_SWITCH(strangederivedbuilder, processV0FoundTags, "Produce FoundV0Tags for findable exercise", false); - PROCESS_SWITCH(strangederivedbuilder, processCascFoundTags, "Produce FoundCascTags for findable exercise", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx b/PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx new file mode 100644 index 00000000000..d7012626b4f --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx @@ -0,0 +1,2956 @@ +// 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. +// +// ======================== +/// \file strangenessbuilder.cxx +/// \brief Strangeness builder task +/// \author David Dobrigkeit Chinellato (david.dobrigkeit.chinellato@cern.ch) +// ======================== +// +// This task produces all tables that may be necessary for +// strangeness analyses. A single device is provided to +// ensure better computing resource (memory) management. +// +// process functions: +// +// -- processRealData[Run2] .........: use this OR processMonteCarlo but NOT both +// -- processMonteCarlo[Run2] .......: use this OR processRealData but NOT both +// +// Most important configurables: +// -- enabledTables ......: key control bools to decide which tables to generate +// task will adapt algorithm to spare / spend CPU accordingly +// -- mc_findableMode ....: 0: only found (default), 1: add findable to found, 2: all findable +// When using findables, refer to FoundTag bools for checking if found +// -- v0builderopts ......: V0-specific building options (topological, deduplication, etc) +// -- cascadebuilderopts .: cascade-specific building options (topological, etc) + +#include "TableHelper.h" + +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/Utils/strangenessBuilderHelper.h" + +#include "Common/Core/TPCVDriftManager.h" +#include "Common/DataModel/PIDResponse.h" +#include "Tools/ML/MlResponse.h" +#include "Tools/ML/model.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/DataSpecUtils.h" +#include "Framework/runDataProcessing.h" + +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::ml; + +static constexpr int nParameters = 1; +static const std::vector tableNames{ + "V0Indices", //.0 (standard analysis: V0Cores) + "V0CoresBase", //.1 (standard analyses: main table) + "V0Covs", //.2 (joinable with V0Cores) + "CascIndices", //.3 (standard analyses: CascData) + "KFCascIndices", //.4 (standard analyses: KFCascData) + "TraCascIndices", //.5 (standard analyses: TraCascData) + "StoredCascCores", //.6 (standard analyses: CascData, main table) + "StoredKFCascCores", //.7 (standard analyses: KFCascData, main table) + "StoredTraCascCores", //.8 (standard analyses: TraCascData, main table) + "CascCovs", //.9 (joinable with CascData) + "KFCascCovs", //.10 (joinable with KFCascData) + "TraCascCovs", //.11 (joinable with TraCascData) + "V0TrackXs", //.12 (joinable with V0Data) + "CascTrackXs", //.13 (joinable with CascData) + "CascBBs", //.14 (standard, bachelor-baryon vars) + "V0DauCovs", //.15 (requested: tracking studies) + "V0DauCovIUs", //.16 (requested: tracking studies) + "V0TraPosAtDCAs", //.17 (requested: tracking studies) + "V0TraPosAtIUs", //.18 (requested: tracking studies) + "V0Ivanovs", //.19 (requested: tracking studies) + "McV0Labels", //.20 (MC/standard analysis) + "V0MCCores", //.21 (MC, all generated desired V0s) + "V0CoreMCLabels", //.22 (MC, refs V0Cores to V0MCCores) + "V0MCCollRefs", //.23 (MC, refs V0MCCores to McCollisions) + "McCascLabels", //.24 (MC/standard analysis) + "McKFCascLabels", //.25 (MC, refs KFCascCores to CascMCCores) + "McTraCascLabels", //.26 (MC, refs TraCascCores to CascMCCores) + "McCascBBTags", //.27 (MC, joinable with CascCores, tags reco-ed) + "CascMCCores", //.28 (MC, all generated desired cascades) + "CascCoreMCLabels", //.29 (MC, refs CascCores to CascMCCores) + "CascMCCollRefs", // 30 (MC, refs CascMCCores to McCollisions) + "CascToTraRefs", //.31 (interlink CascCores -> TraCascCores) + "CascToKFRefs", //.32 (interlink CascCores -> KFCascCores) + "TraToCascRefs", //.33 (interlink TraCascCores -> CascCores) + "KFToCascRefs", //.34 (interlink KFCascCores -> CascCores) + "V0FoundTags", //.35 (tags found vs findable V0s in findable mode) + "CascFoundTags" //.36 (tags found vs findable Cascades in findable mode) +}; + +static constexpr int nTablesConst = 37; + +static const std::vector parameterNames{"enable"}; +static const int defaultParameters[nTablesConst][nParameters]{ + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, // index 9 + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, // index 19 + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, // index 29 + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}}; + +// use parameters + cov mat non-propagated, aux info + (extension propagated) +using FullTracksExt = soa::Join; +using FullTracksExtIU = soa::Join; +using FullTracksExtWithPID = soa::Join; +using FullTracksExtIUWithPID = soa::Join; +using FullTracksExtLabeled = soa::Join; +using FullTracksExtLabeledIU = soa::Join; +using FullTracksExtLabeledWithPID = soa::Join; +using FullTracksExtLabeledIUWithPID = soa::Join; +using TracksWithExtra = soa::Join; + +// For dE/dx association in pre-selection +using TracksExtraWithPID = soa::Join; + +// simple checkers, but ensure 8 bit integers +#define BITSET(var, nbit) ((var) |= (static_cast(1) << static_cast(nbit))) + +struct StrangenessBuilder { + // helper object + o2::pwglf::strangenessBuilderHelper straHelper; + + // ML model + o2::ml::OnnxModel deduplication_bdt; + + // table index : match order above + enum tableIndex { kV0Indices = 0, + kV0CoresBase, + kV0Covs, + kCascIndices, + kKFCascIndices, + kTraCascIndices, + kStoredCascCores, + kStoredKFCascCores, + kStoredTraCascCores, + kCascCovs, + kKFCascCovs, + kTraCascCovs, + kV0TrackXs, + kCascTrackXs, + kCascBBs, + kV0DauCovs, + kV0DauCovIUs, + kV0TraPosAtDCAs, + kV0TraPosAtIUs, + kV0Ivanovs, + kMcV0Labels, + kV0MCCores, + kV0CoreMCLabels, + kV0MCCollRefs, + kMcCascLabels, + kMcKFCascLabels, + kMcTraCascLabels, + kMcCascBBTags, + kCascMCCores, + kCascCoreMCLabels, + kCascMCCollRefs, + kCascToTraRefs, + kCascToKFRefs, + kTraToCascRefs, + kKFToCascRefs, + kV0FoundTags, + kCascFoundTags, + nTables }; + + enum V0PreSelection : uint8_t { selGamma = 0, + selK0Short, + selLambda, + selAntiLambda }; + + enum CascPreSelection : uint8_t { selXiMinus = 0, + selXiPlus, + selOmegaMinus, + selOmegaPlus }; + + struct : ProducesGroup { + //__________________________________________________ + // V0 tables + Produces v0indices; // standard part of V0Datas + Produces v0cores; // standard part of V0Datas + Produces v0covs; // for decay chain reco + + //__________________________________________________ + // cascade tables + Produces cascidx; // standard part of CascDatas + Produces kfcascidx; // standard part of KFCascDatas + Produces tracascidx; // standard part of TraCascDatas + Produces cascdata; // standard part of CascDatas + Produces kfcascdata; // standard part of KFCascDatas + Produces tracascdata; // standard part of TraCascDatas + Produces casccovs; // for decay chain reco + Produces kfcasccovs; // for decay chain reco + Produces tracasccovs; // for decay chain reco + + //__________________________________________________ + // interlink tables + Produces v0dataLink; // de-refs V0s -> V0Data + Produces cascdataLink; // de-refs Cascades -> CascData + Produces kfcascdataLink; // de-refs Cascades -> KFCascData + Produces tracascdataLink; // de-refs Cascades -> TraCascData + + //__________________________________________________ + // secondary auxiliary tables + Produces v0trackXs; // for decay chain reco + Produces cascTrackXs; // for decay chain reco + + //__________________________________________________ + // further auxiliary / optional if desired + Produces cascbb; + Produces v0daucovs; // covariances of daughter tracks + Produces v0daucovIUs; // covariances of daughter tracks + Produces v0dauPositions; // auxiliary debug information + Produces v0dauPositionsIU; // auxiliary debug information + Produces v0ivanovs; // information for Marian's tests + + //__________________________________________________ + // MC information: V0 + Produces v0labels; // MC labels for V0s + Produces v0mccores; // mc info storage + Produces v0CoreMCLabels; // interlink V0Cores -> V0MCCores + Produces v0mccollref; // references collisions from V0MCCores + + // MC information: Cascades + Produces casclabels; // MC labels for cascades + Produces kfcasclabels; // MC labels for KF cascades + Produces tracasclabels; // MC labels for tracked cascades + Produces bbtags; // bb tags (inv structure tagging in mc) + Produces cascmccores; // mc info storage + Produces cascCoreMClabels; // interlink CascCores -> CascMCCores + Produces cascmccollrefs; // references MC collisions from MC cascades + + //__________________________________________________ + // cascade interlinks + // FIXME: commented out until strangederivedbuilder adjusted accordingly + // Produces cascToTraRefs; // cascades -> tracked + // Produces cascToKFRefs; // cascades -> KF + // Produces traToCascRefs; // tracked -> cascades + // Produces kfToCascRefs; // KF -> cascades + + //__________________________________________________ + // Findable tags + Produces v0FoundTag; + Produces cascFoundTag; + } products; + + Configurable> enabledTables{"enabledTables", + {defaultParameters[0], nTables, nParameters, tableNames, parameterNames}, + "Produce this table: -1 for autodetect; otherwise, 0/1 is false/true"}; + std::vector mEnabledTables; // Vector of enabled tables + + // CCDB options + struct : ConfigurableGroup { + std::string prefix = "ccdb"; + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + } ccdbConfigurations; + + // ML options + std::map metadata; + + struct : ConfigurableGroup { + std::string prefix = "DeduplicationOpts"; + + Configurable deduplicationAlgorithm{"deduplicationAlgorithm", 1, + "0: disabled;" + "1: best pointing angle wins;" + "2: best DCA daughters wins;" + "3: best pointing and best DCA wins;" + "4: best BDT score wins;" + "5: selects on PA (not a winner takes it all approach!);" + "6: selects on BDT score (not a winner takes it all approach!)"}; + + // BDT settings + Configurable BDTLocalPath{"BDTLocalPath", "Deduplication_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; + Configurable BDTPathCCDB{"BDTPathCCDB", "Users/g/gsetouel/MLModels2", "Path on CCDB"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB. Exceptions: > 0 for the specific timestamp, 0 gets the run dependent timestamp"}; + Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; + Configurable enableOptimizations{"enableOptimizations", false, "Enables the ONNX extended model-optimization: sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED)"}; + + // Selection based duplicates removal + Configurable PAthreshold{"PAthreshold", 0.02, "PA cut to remove duplicates."}; + Configurable BDTthreshold{"BDTthreshold", 0.7, "BDT score cut to remove duplicates."}; + + } DeduplicationOpts; + + // V0 buffer for V0s used in cascades: master switch + // exchanges CPU (generate V0s again) with memory (save pre-generated V0s) + Configurable useV0BufferForCascades{"useV0BufferForCascades", false, "store array of V0s for cascades or not. False (default): save RAM, use more CPU; true: save CPU, use more RAM"}; + + Configurable mc_findableMode{"mc_findableMode", 0, "0: disabled; 1: add findable-but-not-found to existing V0s from AO2D; 2: reset V0s and generate only findable-but-not-found"}; + + // Autoconfigure process functions + Configurable autoConfigureProcess{"autoConfigureProcess", false, "if true, will configure process function switches based on metadata"}; + + // V0 building options + struct : ConfigurableGroup { + std::string prefix = "v0BuilderOpts"; + Configurable generatePhotonCandidates{"generatePhotonCandidates", false, "generate gamma conversion candidates (V0s using TPC-only tracks)"}; + Configurable moveTPCOnlyTracks{"moveTPCOnlyTracks", true, "if dealing with TPC-only tracks, move them according to TPC drift / time info"}; + + // baseline conditionals of V0 building + Configurable minCrossedRows{"minCrossedRows", 50, "minimum TPC crossed rows for daughter tracks"}; + Configurable dcanegtopv{"dcanegtopv", .1, "DCA Neg To PV"}; + Configurable dcapostopv{"dcapostopv", .1, "DCA Pos To PV"}; + Configurable v0cospa{"v0cospa", 0.95, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0) + Configurable dcav0dau{"dcav0dau", 1.0, "DCA V0 Daughters"}; + Configurable v0radius{"v0radius", 0.9, "v0radius"}; + Configurable maxDaughterEta{"maxDaughterEta", 5.0, "Maximum daughter eta (in abs value)"}; + + // MC builder options + Configurable mc_populateV0MCCoresSymmetric{"mc_populateV0MCCoresSymmetric", false, "populate V0MCCores table for derived data analysis, keep V0MCCores joinable with V0Cores"}; + Configurable mc_populateV0MCCoresAsymmetric{"mc_populateV0MCCoresAsymmetric", true, "populate V0MCCores table for derived data analysis, create V0Cores -> V0MCCores interlink. Saves only labeled V0s."}; + Configurable mc_treatPiToMuDecays{"mc_treatPiToMuDecays", true, "if true, will correctly capture pi -> mu and V0 label will still point to originating V0 decay in those cases. Nota bene: prong info will still be for the muon!"}; + Configurable mc_rapidityWindow{"mc_rapidityWindow", 0.5, "rapidity window to save non-recoed candidates"}; + Configurable mc_keepOnlyPhysicalPrimary{"mc_keepOnlyPhysicalPrimary", false, "Keep only physical primary generated V0s if not recoed"}; + Configurable mc_addGeneratedK0Short{"mc_addGeneratedK0Short", true, "add V0MCCore entry for generated, not-recoed K0Short"}; + Configurable mc_addGeneratedLambda{"mc_addGeneratedLambda", true, "add V0MCCore entry for generated, not-recoed Lambda"}; + Configurable mc_addGeneratedAntiLambda{"mc_addGeneratedAntiLambda", true, "add V0MCCore entry for generated, not-recoed AntiLambda"}; + Configurable mc_addGeneratedGamma{"mc_addGeneratedGamma", false, "add V0MCCore entry for generated, not-recoed Gamma"}; + Configurable mc_addGeneratedGammaMakeCollinear{"mc_addGeneratedGammaMakeCollinear", true, "when adding findable gammas, mark them as collinear"}; + Configurable mc_findableDetachedV0{"mc_findableDetachedV0", false, "if true, generate findable V0s that have collisionId -1. Caution advised."}; + } v0BuilderOpts; + + // cascade building options + struct : ConfigurableGroup { + std::string prefix = "cascadeBuilderOpts"; + Configurable useCascadeMomentumAtPrimVtx{"useCascadeMomentumAtPrimVtx", false, "use cascade momentum at PV"}; + + // conditionals + Configurable minCrossedRows{"minCrossedRows", 50, "minimum TPC crossed rows for daughter tracks"}; + Configurable dcabachtopv{"dcabachtopv", .05, "DCA Bach To PV"}; + Configurable cascradius{"cascradius", 0.9, "cascradius"}; + Configurable casccospa{"casccospa", 0.95, "casccospa"}; + Configurable dcacascdau{"dcacascdau", 1.0, "DCA cascade Daughters"}; + Configurable lambdaMassWindow{"lambdaMassWindow", .010, "Distance from Lambda mass (does not apply to KF path)"}; + Configurable maxDaughterEta{"maxDaughterEta", 5.0, "Maximum daughter eta (in abs value)"}; + + // KF building specific + Configurable kfTuneForOmega{"kfTuneForOmega", false, "if enabled, take main cascade properties from Omega fit instead of Xi fit (= default)"}; + Configurable kfConstructMethod{"kfConstructMethod", 2, "KF Construct Method"}; + Configurable kfUseV0MassConstraint{"kfUseV0MassConstraint", true, "KF: use Lambda mass constraint"}; + Configurable kfUseCascadeMassConstraint{"kfUseCascadeMassConstraint", false, "KF: use Cascade mass constraint - WARNING: not adequate for inv mass analysis of Xi"}; + Configurable kfDoDCAFitterPreMinimV0{"kfDoDCAFitterPreMinimV0", true, "KF: do DCAFitter pre-optimization before KF fit to include material corrections for V0"}; + Configurable kfDoDCAFitterPreMinimCasc{"kfDoDCAFitterPreMinimCasc", true, "KF: do DCAFitter pre-optimization before KF fit to include material corrections for Xi"}; + + // MC builder options + Configurable mc_populateCascMCCoresSymmetric{"mc_populateCascMCCoresSymmetric", false, "populate CascMCCores table for derived data analysis, keep CascMCCores joinable with CascCores"}; + Configurable mc_populateCascMCCoresAsymmetric{"mc_populateCascMCCoresAsymmetric", true, "populate CascMCCores table for derived data analysis, create CascCores -> CascMCCores interlink. Saves only labeled Cascades."}; + Configurable mc_addGeneratedXiMinus{"mc_addGeneratedXiMinus", true, "add CascMCCore entry for generated, not-recoed XiMinus"}; + Configurable mc_addGeneratedXiPlus{"mc_addGeneratedXiPlus", true, "add CascMCCore entry for generated, not-recoed XiPlus"}; + Configurable mc_addGeneratedOmegaMinus{"mc_addGeneratedOmegaMinus", true, "add CascMCCore entry for generated, not-recoed OmegaMinus"}; + Configurable mc_addGeneratedOmegaPlus{"mc_addGeneratedOmegaPlus", true, "add CascMCCore entry for generated, not-recoed OmegaPlus"}; + Configurable mc_treatPiToMuDecays{"mc_treatPiToMuDecays", true, "if true, will correctly capture pi -> mu and V0 label will still point to originating V0 decay in those cases. Nota bene: prong info will still be for the muon!"}; + Configurable mc_rapidityWindow{"mc_rapidityWindow", 0.5, "rapidity window to save non-recoed candidates"}; + Configurable mc_keepOnlyPhysicalPrimary{"mc_keepOnlyPhysicalPrimary", false, "Keep only physical primary generated cascades if not recoed"}; + Configurable mc_findableDetachedCascade{"mc_findableDetachedCascade", false, "if true, generate findable cascades that have collisionId -1. Caution advised."}; + } cascadeBuilderOpts; + + static constexpr float defaultK0MassWindowParameters[1][4] = {{2.81882e-03, 1.14057e-03, 1.72138e-03, 5.00262e-01}}; + static constexpr float defaultLambdaWindowParameters[1][4] = {{1.17518e-03, 1.24099e-04, 5.47937e-03, 3.08009e-01}}; + static constexpr float defaultXiMassWindowParameters[1][4] = {{1.43210e-03, 2.03561e-04, 2.43187e-03, 7.99668e-01}}; + static constexpr float defaultOmMassWindowParameters[1][4] = {{1.43210e-03, 2.03561e-04, 2.43187e-03, 7.99668e-01}}; + + static constexpr float defaultLifetimeCuts[1][4] = {{20, 60, 40, 20}}; + + // preselection options + struct : ConfigurableGroup { + std::string prefix = "preSelectOpts"; + Configurable preselectOnlyDesiredV0s{"preselectOnlyDesiredV0s", false, "preselect only V0s with compatible TPC PID and mass info"}; + Configurable preselectOnlyDesiredCascades{"preselectOnlyDesiredCascades", false, "preselect only Cascades with compatible TPC PID and mass info"}; + + // lifetime preselection options + // apply lifetime cuts to V0 and cascade candidates + // unit of measurement: centimeters + // lifetime of K0Short ~2.6844 cm, no feeddown and plenty to cut + // lifetime of Lambda ~7.9 cm but keep in mind feeddown from cascades + // lifetime of Xi ~4.91 cm + // lifetime of Omega ~2.461 cm + Configurable> lifetimeCut{"lifetimeCut", {defaultLifetimeCuts[0], 4, {"lifetimeCutK0S", "lifetimeCutLambda", "lifetimeCutXi", "lifetimeCutOmega"}}, "Lifetime cut for V0s and cascades (cm)"}; + + // mass preselection options + Configurable massCutPhoton{"massCutPhoton", 0.3, "Photon max mass"}; + Configurable> massCutK0{"massCutK0", {defaultK0MassWindowParameters[0], 4, {"constant", "linear", "expoConstant", "expoRelax"}}, "mass parameters for K0"}; + Configurable> massCutLambda{"massCutLambda", {defaultLambdaWindowParameters[0], 4, {"constant", "linear", "expoConstant", "expoRelax"}}, "mass parameters for Lambda"}; + Configurable> massCutXi{"massCutXi", {defaultXiMassWindowParameters[0], 4, {"constant", "linear", "expoConstant", "expoRelax"}}, "mass parameters for Xi"}; + Configurable> massCutOm{"massCutOm", {defaultOmMassWindowParameters[0], 4, {"constant", "linear", "expoConstant", "expoRelax"}}, "mass parameters for Omega"}; + Configurable massWindownumberOfSigmas{"massWindownumberOfSigmas", 20, "number of sigmas around mass peaks to keep"}; + Configurable massWindowSafetyMargin{"massWindowSafetyMargin", 0.001, "Extra mass window safety margin (in GeV/c2)"}; + + // TPC PID preselection options + Configurable maxTPCpidNsigma{"maxTPCpidNsigma", 5.0, "Maximum TPC PID N sigma (in abs value)"}; + } preSelectOpts; + + float getMassSigmaK0Short(float pt) + { + return preSelectOpts.massCutK0->get("constant") + pt * preSelectOpts.massCutK0->get("linear") + preSelectOpts.massCutK0->get("expoConstant") * TMath::Exp(-pt / preSelectOpts.massCutK0->get("expoRelax")); + } + float getMassSigmaLambda(float pt) + { + return preSelectOpts.massCutLambda->get("constant") + pt * preSelectOpts.massCutLambda->get("linear") + preSelectOpts.massCutLambda->get("expoConstant") * TMath::Exp(-pt / preSelectOpts.massCutLambda->get("expoRelax")); + } + float getMassSigmaXi(float pt) + { + return preSelectOpts.massCutXi->get("constant") + pt * preSelectOpts.massCutXi->get("linear") + preSelectOpts.massCutXi->get("expoConstant") * TMath::Exp(-pt / preSelectOpts.massCutXi->get("expoRelax")); + } + float getMassSigmaOmega(float pt) + { + return preSelectOpts.massCutOm->get("constant") + pt * preSelectOpts.massCutOm->get("linear") + preSelectOpts.massCutOm->get("expoConstant") * TMath::Exp(-pt / preSelectOpts.massCutOm->get("expoRelax")); + } + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + + int mRunNumber; + o2::base::MatLayerCylSet* lut = nullptr; + + // for handling TPC-only tracks (photons) + o2::aod::common::TPCVDriftManager mVDriftMgr; + + // for establishing CascData/KFData/TraCascData interlinks + struct { + std::vector cascCoreToCascades; + std::vector kfCascCoreToCascades; + std::vector traCascCoreToCascades; + std::vector cascadeToCascCores; + std::vector cascadeToKFCascCores; + std::vector cascadeToTraCascCores; + } interlinks; + + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + // struct to add abstraction layer between V0s, Cascades and build indices + // desirable for adding extra (findable, etc) V0s, Cascades to built list + struct trackEntry { + int globalId = -1; + int originId = -1; + int mcCollisionId = -1; + int pdgCode = -1; + }; + struct v0Entry { + int globalId = -1; + int collisionId = -1; + int posTrackId = -1; + int negTrackId = -1; + int v0Type = 0; + int pdgCode = 0; // undefined if not MC - useful for faster finding + int particleId = -1; // de-reference the V0 particle if necessary + bool isCollinearV0 = false; + bool found = false; + }; + struct cascadeEntry { + int globalId = -1; + int collisionId = -1; + int v0Id = -1; + int posTrackId = -1; + int negTrackId = -1; + int bachTrackId = -1; + bool found = false; + }; + + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + // Helper struct to contain V0MCCore information prior to filling + struct mcV0info { + int label = -1; + int motherLabel = -1; + int pdgCode = 0; + int pdgCodeMother = 0; + int pdgCodePositive = 0; + int pdgCodeNegative = 0; + int mcCollision = -1; + bool isPhysicalPrimary = false; + int processPositive = -1; + int processNegative = -1; + std::array xyz; + std::array posP; + std::array negP; + std::array momentum; + }; + mcV0info thisInfo; + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + // Helper struct to contain CascMCCore information prior to filling + struct mcCascinfo { + int label; + int motherLabel; + int mcCollision; + int pdgCode; + int pdgCodeMother; + int pdgCodeV0; + int pdgCodePositive; + int pdgCodeNegative; + int pdgCodeBachelor; + bool isPhysicalPrimary; + int processPositive = -1; + int processNegative = -1; + int processBachelor = -1; + std::array xyz; + std::array lxyz; + std::array posP; + std::array negP; + std::array bachP; + std::array momentum; + int mcParticlePositive; + int mcParticleNegative; + int mcParticleBachelor; + }; + mcCascinfo thisCascInfo; + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + // Helper structure to save v0 duplicates auxiliary info + struct V0DuplicateExtra { + bool isBestPA; + bool isBestDCADau; + bool isBestMLScore; + bool isBuildOk; + float PA; + float V0DCAToPVz; + float V0zVtx; + float MLScore; + }; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + std::vector v0List; + std::vector cascadeList; + std::vector sorted_v0; + std::vector sorted_cascade; + + // for tagging V0s used in cascades + std::vector v0sFromCascades; // Vector of v0 candidates used in cascades + std::vector ao2dV0toV0List; // index to relate v0s -> v0List + std::vector v0Map; // index to relate v0List -> v0sFromCascades + + void init(InitContext& context) + { + // setup bookkeeping histogram + auto h = histos.add("hTableBuildingStatistics", "hTableBuildingStatistics", kTH1D, {{nTablesConst, -0.5f, static_cast(nTablesConst)}}); + auto h2 = histos.add("hInputStatistics", "hInputStatistics", kTH1D, {{nTablesConst, -0.5f, static_cast(nTablesConst)}}); + h2->SetTitle("Input table sizes"); + + if (v0BuilderOpts.generatePhotonCandidates.value == true) { + auto hDeduplicationStatistics = histos.add("hDeduplicationStatistics", "hDeduplicationStatistics", kTH1D, {{2, -0.5f, 1.5f}}); + hDeduplicationStatistics->GetXaxis()->SetBinLabel(1, "AO2D V0s"); + hDeduplicationStatistics->GetXaxis()->SetBinLabel(2, "Deduplicated V0s"); + } + + if (preSelectOpts.preselectOnlyDesiredV0s.value == true) { + auto hPreselectionV0s = histos.add("hPreselectionV0s", "hPreselectionV0s", kTH1D, {{16, -0.5f, 15.5f}}); + hPreselectionV0s->GetXaxis()->SetBinLabel(1, "Not preselected"); + hPreselectionV0s->GetXaxis()->SetBinLabel(2, "#gamma"); + hPreselectionV0s->GetXaxis()->SetBinLabel(3, "K^{0}_{S}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(4, "#gamma, K^{0}_{S}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(5, "#Lambda"); + hPreselectionV0s->GetXaxis()->SetBinLabel(6, "#gamma, #Lambda"); + hPreselectionV0s->GetXaxis()->SetBinLabel(7, "K^{0}_{S}, #Lambda"); + hPreselectionV0s->GetXaxis()->SetBinLabel(8, "#gamma, K^{0}_{S}, #Lambda"); + hPreselectionV0s->GetXaxis()->SetBinLabel(9, "#bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(10, "#gamma, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(11, "K^{0}_{S}, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(12, "#gamma, K^{0}_{S}, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(13, "#Lambda, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(14, "#gamma, #Lambda, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(15, "K^{0}_{S}, #Lambda, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(16, "#gamma, K^{0}_{S}, #Lambda, #bar{#Lambda}"); + } + + if (preSelectOpts.preselectOnlyDesiredCascades.value == true) { + auto hPreselectionCascades = histos.add("hPreselectionCascades", "hPreselectionCascades", kTH1D, {{16, -0.5f, 15.5f}}); + hPreselectionCascades->GetXaxis()->SetBinLabel(1, "Not preselected"); + hPreselectionCascades->GetXaxis()->SetBinLabel(2, "#Xi^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(3, "#Xi^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(4, "#Xi^{-}, #Xi^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(5, "#Omega^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(6, "#Xi^{-}, #Omega^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(7, "#Xi^{+}, #Omega^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(8, "#Xi^{-}, #Xi^{+}, #Omega^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(9, "#Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(10, "#Xi^{-}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(11, "#Xi^{+}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(12, "#Xi^{-}, #Xi^{+}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(13, "#Omega^{-}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(14, "#Xi^{-}, #Omega^{-}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(15, "#Xi^{+}, #Omega^{-}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(16, "#Xi^{-}, #Xi^{+}, #Omega^{-}, #Omega^{+}"); + } + + if (mc_findableMode.value > 0) { + // save statistics of findable candidate processing + auto hFindable = histos.add("hFindableStatistics", "hFindableStatistics", kTH1D, {{6, -0.5f, 5.5f}}); + hFindable->SetTitle(Form("Findable mode: %i", static_cast(mc_findableMode.value))); + hFindable->GetXaxis()->SetBinLabel(1, "AO2D V0s"); + hFindable->GetXaxis()->SetBinLabel(2, "V0s to be built"); + hFindable->GetXaxis()->SetBinLabel(3, "V0s with collId -1"); + hFindable->GetXaxis()->SetBinLabel(4, "AO2D Cascades"); + hFindable->GetXaxis()->SetBinLabel(5, "Cascades to be built"); + hFindable->GetXaxis()->SetBinLabel(6, "Cascades with collId -1"); + } + + if (DeduplicationOpts.deduplicationAlgorithm.value > 0) { + histos.add("DeduplicationQA/hMLScore", "hMLScore", kTH1F, {{200, 0.0f, 1.0f}}); + histos.add("DeduplicationQA/hPA", "hPA", kTH1F, {{200, 0.0f, 0.4f}}); + histos.add("DeduplicationQA/hBestPA", "hBestPA", kTH1F, {{200, 0.0f, 0.4f}}); + histos.add("DeduplicationQA/hBestDCADau", "hBestDCADau", kTH1F, {{200, -10.0f, 10.0f}}); + histos.add("DeduplicationQA/hBestMLScore", "hBestMLScore", kTH1F, {{200, 0.0f, 1.0f}}); + } + + auto hPrimaryV0s = histos.add("hPrimaryV0s", "hPrimaryV0s", kTH1D, {{2, -0.5f, 1.5f}}); + hPrimaryV0s->GetXaxis()->SetBinLabel(1, "All V0s"); + hPrimaryV0s->GetXaxis()->SetBinLabel(2, "Primary V0s"); + + mRunNumber = 0; + + mEnabledTables.resize(nTables, 0); + + LOGF(info, "Configuring tables to generate"); + auto& workflows = context.services().get(); + + TString listOfRequestors[nTables]; + for (int i = 0; i < nTables; i++) { + // adjust bookkeeping histogram + h->GetXaxis()->SetBinLabel(i + 1, tableNames[i].c_str()); + h2->GetXaxis()->SetBinLabel(i + 1, tableNames[i].c_str()); + h->SetBinContent(i + 1, -1); // mark all as disabled to start + + int f = enabledTables->get(tableNames[i].c_str(), "enable"); + if (f == 1) { + mEnabledTables[i] = 1; + listOfRequestors[i] = "manual enabling"; + } + if (f == -1) { + // autodetect this table in other devices + for (DeviceSpec const& device : workflows.devices) { + // Step 1: check if this device subscribed to the V0data table + for (auto const& input : device.inputs) { + if (device.name.compare("strangenessbuilder-initializer") == 0) + continue; // don't listen to the initializer + if (DataSpecUtils::partialMatch(input.matcher, o2::header::DataOrigin("AOD"))) { + auto&& [origin, description, version] = DataSpecUtils::asConcreteDataMatcher(input.matcher); + std::string tableNameWithVersion = tableNames[i]; + if (version > 0) { + tableNameWithVersion += Form("_%03d", version); + } + if (input.matcher.binding == tableNameWithVersion) { + LOGF(info, "Device %s has subscribed to %s (version %i)", device.name, tableNames[i], version); + listOfRequestors[i].Append(Form("%s ", device.name.c_str())); + mEnabledTables[i] = 1; + } + } + } + } + } + } + + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + LOGF(info, " Strangeness builder: basic configuration listing"); + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + + if (doprocessRealData) { + LOGF(info, " ===> process function enabled: processRealData"); + } + if (doprocessRealDataRun2) { + LOGF(info, " ===> process function enabled: processRealDataRun2"); + } + if (doprocessMonteCarlo) { + LOGF(info, " ===> process function enabled: processMonteCarlo"); + } + if (doprocessMonteCarloRun2) { + LOGF(info, " ===> process function enabled: processMonteCarloRun2"); + } + if (mc_findableMode.value == 1) { + LOGF(info, " ===> findable mode 1 is enabled: complement reco-ed with non-found findable"); + } + if (mc_findableMode.value == 2) { + LOGF(info, " ===> findable mode 2 is enabled: re-generate all findable from scratch"); + } + + // list enabled tables + + for (int i = 0; i < nTables; i++) { + // printout to be improved in the future + if (mEnabledTables[i]) { + LOGF(info, " -~> Table enabled: %s, requested by %s", tableNames[i], listOfRequestors[i].Data()); + h->SetBinContent(i + 1, 0); // mark enabled + } + } + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + // print base cuts + LOGF(info, "-~> V0 | min crossed rows ..............: %i", v0BuilderOpts.minCrossedRows.value); + LOGF(info, "-~> V0 | DCA pos track to PV ...........: %f", v0BuilderOpts.dcapostopv.value); + LOGF(info, "-~> V0 | DCA neg track to PV ...........: %f", v0BuilderOpts.dcanegtopv.value); + LOGF(info, "-~> V0 | V0 cosine of PA ...............: %f", v0BuilderOpts.v0cospa.value); + LOGF(info, "-~> V0 | DCA between V0 daughters ......: %f", v0BuilderOpts.dcav0dau.value); + LOGF(info, "-~> V0 | V0 2D decay radius ............: %f", v0BuilderOpts.v0radius.value); + LOGF(info, "-~> V0 | Maximum daughter eta ..........: %f", v0BuilderOpts.maxDaughterEta.value); + + LOGF(info, "-~> Cascade | min crossed rows .........: %i", cascadeBuilderOpts.minCrossedRows.value); + LOGF(info, "-~> Cascade | DCA bach track to PV .....: %f", cascadeBuilderOpts.dcabachtopv.value); + LOGF(info, "-~> Cascade | Cascade cosine of PA .....: %f", cascadeBuilderOpts.casccospa.value); + LOGF(info, "-~> Cascade | Cascade daughter DCA .....: %f", cascadeBuilderOpts.dcacascdau.value); + LOGF(info, "-~> Cascade | Cascade radius ...........: %f", cascadeBuilderOpts.cascradius.value); + LOGF(info, "-~> Cascade | Lambda mass window .......: %f", cascadeBuilderOpts.lambdaMassWindow.value); + LOGF(info, "-~> Cascade | Maximum daughter eta .....: %f", cascadeBuilderOpts.maxDaughterEta.value); + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + + ccdb->setURL(ccdbConfigurations.ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + // set V0 parameters in the helper + straHelper.v0selections.minCrossedRows = v0BuilderOpts.minCrossedRows; + straHelper.v0selections.dcanegtopv = v0BuilderOpts.dcanegtopv; + straHelper.v0selections.dcapostopv = v0BuilderOpts.dcapostopv; + straHelper.v0selections.v0cospa = v0BuilderOpts.v0cospa; + straHelper.v0selections.dcav0dau = v0BuilderOpts.dcav0dau; + straHelper.v0selections.v0radius = v0BuilderOpts.v0radius; + straHelper.v0selections.maxDaughterEta = v0BuilderOpts.maxDaughterEta; + + // set cascade parameters in the helper + straHelper.cascadeselections.minCrossedRows = cascadeBuilderOpts.minCrossedRows; + straHelper.cascadeselections.dcabachtopv = cascadeBuilderOpts.dcabachtopv; + straHelper.cascadeselections.cascradius = cascadeBuilderOpts.cascradius; + straHelper.cascadeselections.casccospa = cascadeBuilderOpts.casccospa; + straHelper.cascadeselections.dcacascdau = cascadeBuilderOpts.dcacascdau; + straHelper.cascadeselections.lambdaMassWindow = cascadeBuilderOpts.lambdaMassWindow; + straHelper.cascadeselections.maxDaughterEta = cascadeBuilderOpts.maxDaughterEta; + + // Loading BDT model + if (DeduplicationOpts.deduplicationAlgorithm.value == 4 || DeduplicationOpts.deduplicationAlgorithm.value == 6) { + if (DeduplicationOpts.loadModelsFromCCDB) { + + // Retrieve the model from CCDB + ccdbApi.init(ccdbConfigurations.ccdburl); + + /// Fetching model for specific timestamp + LOG(info) << "Fetching model for timestamp: " << DeduplicationOpts.timestampCCDB.value; + + bool retrieveSuccess = ccdbApi.retrieveBlob(DeduplicationOpts.BDTPathCCDB.value, ".", metadata, DeduplicationOpts.timestampCCDB.value, false, DeduplicationOpts.BDTLocalPath.value); + if (retrieveSuccess) { + deduplication_bdt.initModel(DeduplicationOpts.BDTLocalPath.value, DeduplicationOpts.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the Gamma model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } else { + deduplication_bdt.initModel(DeduplicationOpts.BDTLocalPath.value, DeduplicationOpts.enableOptimizations.value); + } + } + } + + // for sorting + template + std::vector sort_indices(const std::vector& v, bool doSorting = false) + { + std::vector idx(v.size()); + std::iota(idx.begin(), idx.end(), 0); + if (doSorting) { + // do sorting only if requested (not always necessary) + std::stable_sort(idx.begin(), idx.end(), + [&v](std::size_t i1, std::size_t i2) { return v[i1].collisionId < v[i2].collisionId; }); + } + return idx; + } + + // Simple function to rank vectors based on values + std::vector rankSort(const std::vector& v_temp, bool descending = false) + { + std::vector> v_sort(v_temp.size()); + + // Pair each value with its original index + for (size_t i = 0U; i < v_temp.size(); ++i) { + v_sort[i] = std::make_pair(v_temp[i], i); + } + + // Sort by value - ascending: lowest gets rank 1, descending: highest gets rank 1 + + if (descending) { + std::sort(v_sort.begin(), v_sort.end(), [](const auto& a, const auto& b) { + return a.first > b.first; + }); + } else { + std::sort(v_sort.begin(), v_sort.end(), [](const auto& a, const auto& b) { + return a.first < b.first; + }); + } + + std::pair rank_tracker = std::make_pair(std::numeric_limits::quiet_NaN(), 0); + std::vector result(v_temp.size()); + + for (size_t i = 0U; i < v_sort.size(); ++i) { + // Only update rank if value is different from previous + if (v_sort[i].first != rank_tracker.first) { + rank_tracker = std::make_pair(v_sort[i].first, i + 1); // +1 for 1-based rank + } + result[v_sort[i].second] = rank_tracker.second; // assign rank to original index + } + + return result; + } + + //_______________________________________________________________________ + // Process duplicated photons + template + std::vector processDuplicates(TCollisions const& collisions, TTracks const& tracks, std::vector V0Grouped, size_t iV0) + { + auto pTrack = tracks.rawIteratorAt(V0Grouped[iV0].posTrackId); + auto nTrack = tracks.rawIteratorAt(V0Grouped[iV0].negTrackId); + + bool isPosTPCOnly = (pTrack.hasTPC() && !pTrack.hasITS() && !pTrack.hasTRD() && !pTrack.hasTOF()); + bool isNegTPCOnly = (nTrack.hasTPC() && !nTrack.hasITS() && !nTrack.hasTRD() && !nTrack.hasTOF()); + + // don't try to de-duplicate if no track is TPC only + if (!isPosTPCOnly && !isNegTPCOnly) { + return {}; + } + + // fitness criteria defined here + float bestPointingAngle = 10; // a nonsense angle, anything's better + size_t bestPointingAngleIndex = -1; + + float bestDCADaughters = 1e+3; // an excessively large DCA + size_t bestDCADaughtersIndex = -1; + + float bestMLScore = -1; // a nonsense ML score + size_t bestMLScoreIndex = -1; + + // Defining context variables + int NDuplicates = 0; + float AvgPA = 0.0f; + + // Containers for ranking + std::vector paVec(V0Grouped[iV0].collisionIds.size(), 999.f); + std::vector v0zVec(V0Grouped[iV0].collisionIds.size(), 999.f); + + // Auxiliary vector to store V0 duplicate info + std::vector V0DuplicateExtras; + + // Loop over duplicates + for (size_t ic = 0; ic < V0Grouped[iV0].collisionIds.size(); ic++) { + + // Helper structure to save duplicates info - initializing with dummy values + V0DuplicateExtra v0DuplicateInfo; + v0DuplicateInfo.isBestPA = false; + v0DuplicateInfo.isBestDCADau = false; + v0DuplicateInfo.isBestMLScore = false; + v0DuplicateInfo.isBuildOk = false; + v0DuplicateInfo.PA = 10; + v0DuplicateInfo.V0DCAToPVz = 999.f; + v0DuplicateInfo.V0zVtx = 999.f; + v0DuplicateInfo.MLScore = -1; + + // We include V0DuplicateExtra info in the vector at this point to avoid indexing issues later + V0DuplicateExtras.push_back(v0DuplicateInfo); + + // get track parametrizations, collisions + auto posTrackPar = getTrackParCov(pTrack); + auto negTrackPar = getTrackParCov(nTrack); + auto const& collision = collisions.rawIteratorAt(V0Grouped[iV0].collisionIds[ic]); + + // handle TPC-only tracks properly (photon conversions) + if (v0BuilderOpts.moveTPCOnlyTracks) { + if (isPosTPCOnly) { + // Nota bene: positive is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + if (!mVDriftMgr.moveTPCTrack(collision, pTrack, posTrackPar)) { + continue; + } + } + if (isNegTPCOnly) { + // Nota bene: negative is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + if (!mVDriftMgr.moveTPCTrack(collision, nTrack, negTrackPar)) { + continue; + } + } + } // end TPC drift treatment + + // process candidate with helper, generate properties for consulting + // : do not apply selections: do as much as possible to preserve + // candidate at this level and do not select with topo selections + if (straHelper.buildV0Candidate(V0Grouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false, true)) { + + // candidate built, check pointing angle + if (straHelper.v0.pointingAngle < bestPointingAngle) { + bestPointingAngle = straHelper.v0.pointingAngle; + bestPointingAngleIndex = ic; + } + if (straHelper.v0.daughterDCA < bestDCADaughters) { + bestDCADaughters = straHelper.v0.daughterDCA; + bestDCADaughtersIndex = ic; + } + + // Calculating features for ML Analysis + if (DeduplicationOpts.deduplicationAlgorithm.value == 4 || DeduplicationOpts.deduplicationAlgorithm.value == 6) { + AvgPA += straHelper.v0.pointingAngle; + paVec[ic] = straHelper.v0.pointingAngle; + v0zVec[ic] = std::abs(straHelper.v0.position[2]); + NDuplicates++; + } + + // Updating values in the struct + V0DuplicateExtras[ic].isBuildOk = true; + V0DuplicateExtras[ic].PA = straHelper.v0.pointingAngle; + V0DuplicateExtras[ic].V0DCAToPVz = std::abs(straHelper.v0.v0DCAToPVz); + V0DuplicateExtras[ic].V0zVtx = std::abs(straHelper.v0.position[2]); + } // end build V0 + } // end candidate loop + + // Additional loop to perform ML Analysis if requested + if (DeduplicationOpts.deduplicationAlgorithm.value == 4 || DeduplicationOpts.deduplicationAlgorithm.value == 6) { + + // Preparing features + if (NDuplicates > 0) + AvgPA /= NDuplicates; + + // Get vector of ranks + std::vector paRanks = rankSort(paVec, false); + std::vector v0zRanks = rankSort(v0zVec, false); + + // Fill the ML score for all candidates + for (size_t ic = 0; ic < V0Grouped[iV0].collisionIds.size(); ic++) { + + // Skip if v0 was not built + if (!V0DuplicateExtras[ic].isBuildOk) + continue; + + // Input vector for BDT + std::vector inputFeatures{V0DuplicateExtras[ic].V0DCAToPVz, // 1. V0DCAToPVz + V0DuplicateExtras[ic].PA, // 2. Pointing Angle + V0DuplicateExtras[ic].V0zVtx, // 3. V0 Vtx z-position + static_cast(paRanks[ic]), // 4. Pointing Angle Rank + static_cast(NDuplicates), // 5. N. of Duplicates + AvgPA, // 6. Avg Pointing Angle + static_cast(v0zRanks[ic])}; // 7. V0 Vtx z Rank + + float* BDTProbability = deduplication_bdt.evalModel(inputFeatures); + + if (BDTProbability[1] > bestMLScore) { + bestMLScore = BDTProbability[1]; + bestMLScoreIndex = ic; + } + + // QA histo + histos.fill(HIST("DeduplicationQA/hMLScore"), BDTProbability[1]); + histos.fill(HIST("DeduplicationQA/hPA"), V0DuplicateExtras[ic].PA); + + // Updating BDT score info in the struct + V0DuplicateExtras[ic].MLScore = BDTProbability[1]; + } + } + + histos.fill(HIST("DeduplicationQA/hBestPA"), bestPointingAngle); + histos.fill(HIST("DeduplicationQA/hBestDCADau"), bestDCADaughters); + histos.fill(HIST("DeduplicationQA/hBestMLScore"), bestMLScore); + + // Final step: Defining the winners: + if (bestPointingAngleIndex != static_cast(-1)) + V0DuplicateExtras[bestPointingAngleIndex].isBestPA = true; + if (bestDCADaughtersIndex != static_cast(-1)) + V0DuplicateExtras[bestDCADaughtersIndex].isBestDCADau = true; + if (bestMLScoreIndex != static_cast(-1)) + V0DuplicateExtras[bestMLScoreIndex].isBestMLScore = true; + + // return vector with duplicates info + return V0DuplicateExtras; + } + + template + bool initCCDB(aod::BCsWithTimestamps const& bcs, TCollisions const& collisions) + { + auto bc = collisions.size() ? collisions.begin().template bc_as() : bcs.begin(); + if (!bcs.size()) { + LOGF(warn, "No BC found, skipping this DF."); + return false; // signal to skip this DF + } + + if (mRunNumber == bc.runNumber()) { + return true; + } + + auto timestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = 0x0; + o2::parameters::GRPMagField* grpmag = 0x0; + if (doprocessRealDataRun2) { + grpo = ccdb->getForTimeStamp(ccdbConfigurations.grpPath, timestamp); + if (!grpo) { + LOG(fatal) << "Got nullptr from CCDB for path " << ccdbConfigurations.grpPath << " of object GRPObject for timestamp " << timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpo); + } else { + grpmag = ccdb->getForTimeStamp(ccdbConfigurations.grpmagPath, timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << ccdbConfigurations.grpmagPath << " of object GRPMagField for timestamp " << timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + } + // Fetch magnetic field from ccdb for current collision + auto magneticField = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << magneticField << " kG"; + + // Set magnetic field value once known + straHelper.fitter.setBz(magneticField); + + // acquire LUT for this timestamp + LOG(info) << "Loading material look-up table for timestamp: " << timestamp; + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(ccdbConfigurations.lutPath, timestamp)); + o2::base::Propagator::Instance()->setMatLUT(lut); + straHelper.lut = lut; + + LOG(info) << "Fully configured for run: " << bc.runNumber(); + // mmark this run as configured + mRunNumber = bc.runNumber(); + + if (v0BuilderOpts.generatePhotonCandidates.value && v0BuilderOpts.moveTPCOnlyTracks.value) { + // initialize only if needed, avoid unnecessary CCDB calls + mVDriftMgr.init(&ccdb->instance()); + mVDriftMgr.update(timestamp); + } + + return true; + } + + //__________________________________________________ + void resetInterlinks() + { + interlinks.cascCoreToCascades.clear(); + interlinks.kfCascCoreToCascades.clear(); + interlinks.traCascCoreToCascades.clear(); + interlinks.cascadeToCascCores.clear(); + interlinks.cascadeToKFCascCores.clear(); + interlinks.cascadeToTraCascCores.clear(); + } + + //__________________________________________________ + void populateCascadeInterlinks() + { + // if (mEnabledTables[kCascToKFRefs]) { + // for (const auto& cascCore : interlinks.cascCoreToCascades) { + // cascToKFRefs(interlinks.cascadeToKFCascCores[cascCore]); + // histos.fill(HIST("hTableBuildingStatistics"), kCascToKFRefs); + // } + // } + // if (mEnabledTables[kCascToTraRefs]) { + // for (const auto& cascCore : interlinks.cascCoreToCascades) { + // cascToTraRefs(interlinks.cascadeToTraCascCores[cascCore]); + // histos.fill(HIST("hTableBuildingStatistics"), kCascToTraRefs); + // } + // } + // if (mEnabledTables[kKFToCascRefs]) { + // for (const auto& kfCascCore : interlinks.kfCascCoreToCascades) { + // kfToCascRefs(interlinks.cascadeToCascCores[kfCascCore]); + // histos.fill(HIST("hTableBuildingStatistics"), kKFToCascRefs); + // } + // } + // if (mEnabledTables[kTraToCascRefs]) { + // for (const auto& traCascCore : interlinks.traCascCoreToCascades) { + // traToCascRefs(interlinks.cascadeToCascCores[traCascCore]); + // histos.fill(HIST("hTableBuildingStatistics"), kTraToCascRefs); + // } + // } + } + + //__________________________________________________ + template + void prepareBuildingLists(TCollisions const& collisions, TMCCollisions const& mcCollisions, TV0s const& v0s, TCascades const& cascades, TTracks const& tracks, TMCParticles const& mcParticles) + { + // this function prepares the v0List and cascadeList depending on + // how the task has been set up. Standard operation simply uses + // the existing V0s and Cascades from AO2D, while findable MC + // operation either complements with all findable-but-not-found + // or resets and fills with all findable. + // + // Whenever using findable candidates, they will be appropriately + // marked for posterior analysis using 'tag' variables. + // + // findable mode legend: + // 0: simple passthrough of V0s, Cascades in AO2Ds + // (in data, this is the only mode possible!) + // 1: add extra findable that haven't been found + // 2: generate only findable (no background) + + // redo lists from scratch + v0List.clear(); + cascadeList.clear(); + sorted_v0.clear(); + sorted_cascade.clear(); + ao2dV0toV0List.clear(); + + trackEntry currentTrackEntry; + v0Entry currentV0Entry; + cascadeEntry currentCascadeEntry; + + std::vector bestCollisionArray; // stores McCollision -> Collision map + std::vector bestCollisionNContribsArray; // stores Ncontribs for biggest coll assoc to mccoll + + int collisionLessV0s = 0; + int collisionLessCascades = 0; + + if (mc_findableMode.value > 0) { + if constexpr (soa::is_table) { + // if mcCollisions exist, assemble mcColl -> bestRecoColl map here + bestCollisionArray.clear(); + bestCollisionNContribsArray.clear(); + bestCollisionArray.resize(mcCollisions.size(), -1); // marks not reconstructed + bestCollisionNContribsArray.resize(mcCollisions.size(), -1); // marks not reconstructed + + // single loop over double loop at a small cost in memory for extra array + for (const auto& collision : collisions) { + if (collision.has_mcCollision()) { + if (collision.numContrib() > bestCollisionNContribsArray[collision.mcCollisionId()]) { + bestCollisionArray[collision.mcCollisionId()] = collision.globalIndex(); + bestCollisionNContribsArray[collision.mcCollisionId()] = collision.numContrib(); + } + } + } // end collision loop + } // end is_table + } // end findable mode check + + if (mc_findableMode.value < 2) { + // keep all unless de-duplication active + ao2dV0toV0List.resize(v0s.size(), -1); // -1 means keep, -2 means do not keep + + if (DeduplicationOpts.deduplicationAlgorithm.value > 0 && v0BuilderOpts.generatePhotonCandidates) { + // handle duplicates explicitly: group V0s according to (p,n) indices + // will provide a list of collisionIds (in V0group), allowing for + // easy de-duplication when passing to the v0List + std::vector v0tableGrouped = o2::pwglf::groupDuplicates(v0s); + histos.fill(HIST("hDeduplicationStatistics"), 0.0, v0s.size()); + histos.fill(HIST("hDeduplicationStatistics"), 1.0, v0tableGrouped.size()); + + // process grouped duplicates, remove 'bad' ones + for (size_t iV0 = 0; iV0 < v0tableGrouped.size(); iV0++) { + + // skip single copy V0s + if (v0tableGrouped[iV0].collisionIds.size() == 1) { + continue; + } + + // process duplicates + std::vector deduplicationOutput = processDuplicates(collisions, tracks, v0tableGrouped, iV0); + + // skip if empty + if (deduplicationOutput.empty()) { + continue; + } + + // mark de-duplicated candidates + for (size_t ic = 0; ic < v0tableGrouped[iV0].collisionIds.size(); ic++) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -2; + // algorithm 1: best pointing angle + if (DeduplicationOpts.deduplicationAlgorithm.value == 1 && deduplicationOutput[ic].isBestPA) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -1; // keep best only + } + // algorithm 2: best DCA between daughters + if (DeduplicationOpts.deduplicationAlgorithm.value == 2 && deduplicationOutput[ic].isBestDCADau) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -1; // keep best only + } + // algorithm 3: best PA AND DCA between daughters + if (DeduplicationOpts.deduplicationAlgorithm.value == 3 && deduplicationOutput[ic].isBestDCADau && deduplicationOutput[ic].isBestPA) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -1; // keep best only + } + // algorithm 4: best ML Score + if (DeduplicationOpts.deduplicationAlgorithm.value == 4 && deduplicationOutput[ic].isBestMLScore) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -1; // keep best only + } + // Selection-based duplicate removal + if (DeduplicationOpts.deduplicationAlgorithm.value == 5 && deduplicationOutput[ic].PA <= DeduplicationOpts.PAthreshold) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -1; // keep best only + } + if (DeduplicationOpts.deduplicationAlgorithm.value == 6 && deduplicationOutput[ic].MLScore >= DeduplicationOpts.BDTthreshold) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -1; // keep best only + } + } + } // end V0 loop + } // end de-duplication process + + for (const auto& v0 : v0s) { + if (ao2dV0toV0List[v0.globalIndex()] == -1) { // keep only de-duplicated + ao2dV0toV0List[v0.globalIndex()] = v0List.size(); // maps V0s to the corresponding v0List entry + currentV0Entry.globalId = v0.globalIndex(); + currentV0Entry.collisionId = v0.collisionId(); + currentV0Entry.posTrackId = v0.posTrackId(); + currentV0Entry.negTrackId = v0.negTrackId(); + currentV0Entry.v0Type = v0.v0Type(); + currentV0Entry.pdgCode = 0; + currentV0Entry.particleId = -1; + currentV0Entry.isCollinearV0 = v0.isCollinearV0(); + currentV0Entry.found = true; + v0List.push_back(currentV0Entry); + } + } + } + // any mode other than 0 will require mcParticles + if constexpr (soa::is_table) { + if (mc_findableMode.value > 0) { + // for search if existing or not + int v0ListReconstructedSize = v0List.size(); + + // find extra candidates, step 1: find subset of tracks that interest + std::vector positiveTrackArray; + std::vector negativeTrackArray; + // vector elements: track index, origin index [, mc collision id, pdg code] + int dummy = -1; // unnecessary in this path + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; // skip this, it's trouble + } + auto particle = track.template mcParticle_as(); + int originParticleIndex = getOriginatingParticle(particle, dummy, v0BuilderOpts.mc_treatPiToMuDecays); + if (originParticleIndex < 0) { + continue; // skip this, it's trouble (2) + } + auto originParticle = mcParticles.rawIteratorAt(originParticleIndex); + + bool trackIsInteresting = false; + if ( + (originParticle.pdgCode() == 310 && v0BuilderOpts.mc_addGeneratedK0Short.value > 0) || + (originParticle.pdgCode() == 3122 && v0BuilderOpts.mc_addGeneratedLambda.value > 0) || + (originParticle.pdgCode() == -3122 && v0BuilderOpts.mc_addGeneratedAntiLambda.value > 0) || + (originParticle.pdgCode() == 22 && v0BuilderOpts.mc_addGeneratedGamma.value > 0)) { + trackIsInteresting = true; + } + if (!trackIsInteresting) { + continue; // skip this, it's uninteresting + } + + currentTrackEntry.globalId = static_cast(track.globalIndex()); + currentTrackEntry.originId = originParticleIndex; + currentTrackEntry.mcCollisionId = originParticle.mcCollisionId(); + currentTrackEntry.pdgCode = originParticle.pdgCode(); + + // now separate according to particle species + if (track.sign() < 0) { + negativeTrackArray.push_back(currentTrackEntry); + } else { + positiveTrackArray.push_back(currentTrackEntry); + } + } + + // Nested loop only with valuable tracks + for (const auto& positiveTrackIndex : positiveTrackArray) { + for (const auto& negativeTrackIndex : negativeTrackArray) { + if (positiveTrackIndex.originId != negativeTrackIndex.originId) { + continue; // not the same originating particle + } + // findable mode 1: add non-reconstructed as v0Type 8 + if (mc_findableMode.value == 1) { + bool detected = false; + for (int ii = 0; ii < v0ListReconstructedSize; ii++) { + // check if this particular combination already exists in v0List + if (v0List[ii].posTrackId == positiveTrackIndex.globalId && + v0List[ii].negTrackId == negativeTrackIndex.globalId) { + detected = true; + // override pdg code with something useful for cascade findable math + v0List[ii].pdgCode = positiveTrackIndex.pdgCode; + break; + } + } + if (detected == false) { + // collision index: from best-version-of-this-mcCollision + // nota bene: this could be negative, caution advised + currentV0Entry.globalId = -1; + currentV0Entry.collisionId = bestCollisionArray[positiveTrackIndex.mcCollisionId]; + currentV0Entry.posTrackId = positiveTrackIndex.globalId; + currentV0Entry.negTrackId = negativeTrackIndex.globalId; + currentV0Entry.v0Type = 1; + currentV0Entry.pdgCode = positiveTrackIndex.pdgCode; + currentV0Entry.particleId = positiveTrackIndex.originId; + currentV0Entry.isCollinearV0 = false; + if (v0BuilderOpts.mc_addGeneratedGammaMakeCollinear.value && currentV0Entry.pdgCode == 22) { + currentV0Entry.isCollinearV0 = true; + } + currentV0Entry.found = false; + if (bestCollisionArray[positiveTrackIndex.mcCollisionId] < 0) { + collisionLessV0s++; + } + if (v0BuilderOpts.mc_findableDetachedV0.value || currentV0Entry.collisionId >= 0) { + v0List.push_back(currentV0Entry); + } + } + } + // findable mode 2 + if (mc_findableMode.value == 2) { + currentV0Entry.globalId = -1; + currentV0Entry.collisionId = bestCollisionArray[positiveTrackIndex.mcCollisionId]; + currentV0Entry.posTrackId = positiveTrackIndex.globalId; + currentV0Entry.negTrackId = negativeTrackIndex.globalId; + currentV0Entry.v0Type = 1; + currentV0Entry.pdgCode = positiveTrackIndex.pdgCode; + currentV0Entry.particleId = positiveTrackIndex.originId; + currentV0Entry.isCollinearV0 = false; + if (v0BuilderOpts.mc_addGeneratedGammaMakeCollinear.value && currentV0Entry.pdgCode == 22) { + currentV0Entry.isCollinearV0 = true; + } + currentV0Entry.found = false; + for (const auto& v0 : v0s) { + if (v0.posTrackId() == positiveTrackIndex.globalId && + v0.negTrackId() == negativeTrackIndex.globalId) { + // this will override type, but not collision index + // N.B.: collision index checks still desirable! + currentV0Entry.globalId = v0.globalIndex(); + currentV0Entry.v0Type = v0.v0Type(); + currentV0Entry.isCollinearV0 = v0.isCollinearV0(); + currentV0Entry.found = true; + break; + } + } + if (v0BuilderOpts.mc_findableDetachedV0.value || currentV0Entry.collisionId >= 0) { + v0List.push_back(currentV0Entry); + } + } + } + } // end positive / negative track loops + + // fill findable statistics table + histos.fill(HIST("hFindableStatistics"), 0.0, v0s.size()); + histos.fill(HIST("hFindableStatistics"), 1.0, v0List.size()); + histos.fill(HIST("hFindableStatistics"), 2.0, collisionLessV0s); + + } // end findableMode > 0 check + } // end soa::is_table + + // determine properly collision-id-sorted index array for later use + // N.B.: necessary also before cascade part + sorted_v0.clear(); + sorted_v0 = sort_indices(v0List, (mc_findableMode.value > 0)); + + // Cascade part if cores are requested, skip otherwise + if (mEnabledTables[kStoredCascCores] || mEnabledTables[kStoredKFCascCores]) { + if (mc_findableMode.value < 2) { + // simple passthrough: copy existing cascades to build list + for (const auto& cascade : cascades) { + auto const& v0 = cascade.v0(); + currentCascadeEntry.globalId = cascade.globalIndex(); + currentCascadeEntry.collisionId = cascade.collisionId(); + currentCascadeEntry.v0Id = ao2dV0toV0List[v0.globalIndex()]; + currentCascadeEntry.posTrackId = v0.posTrackId(); + currentCascadeEntry.negTrackId = v0.negTrackId(); + currentCascadeEntry.bachTrackId = cascade.bachelorId(); + currentCascadeEntry.found = true; + cascadeList.push_back(currentCascadeEntry); + } + } + + // any mode other than 0 will require mcParticles + if constexpr (soa::is_table) { + if (mc_findableMode.value > 0) { + // for search if existing or not + size_t cascadeListReconstructedSize = cascadeList.size(); + + // determine which tracks are of interest + std::vector bachelorTrackArray; + // vector elements: track index, origin index, mc collision id, pdg code] + int dummy = -1; // unnecessary in this path + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; // skip this, it's trouble + } + auto particle = track.template mcParticle_as(); + int originParticleIndex = getOriginatingParticle(particle, dummy, cascadeBuilderOpts.mc_treatPiToMuDecays); + if (originParticleIndex < 0) { + continue; // skip this, it's trouble (2) + } + auto originParticle = mcParticles.rawIteratorAt(originParticleIndex); + + bool trackIsInteresting = false; + if ( + (originParticle.pdgCode() == 3312 && cascadeBuilderOpts.mc_addGeneratedXiMinus.value > 0) || + (originParticle.pdgCode() == -3312 && cascadeBuilderOpts.mc_addGeneratedXiPlus.value > 0) || + (originParticle.pdgCode() == 3334 && cascadeBuilderOpts.mc_addGeneratedOmegaMinus.value > 0) || + (originParticle.pdgCode() == -3334 && cascadeBuilderOpts.mc_addGeneratedOmegaPlus.value > 0)) { + trackIsInteresting = true; + } + if (!trackIsInteresting) { + continue; // skip this, it's uninteresting + } + + currentTrackEntry.globalId = static_cast(track.globalIndex()); + currentTrackEntry.originId = originParticleIndex; + currentTrackEntry.mcCollisionId = originParticle.mcCollisionId(); + currentTrackEntry.pdgCode = originParticle.pdgCode(); + + // populate list of bachelor tracks to pair + bachelorTrackArray.push_back(currentTrackEntry); + } + + // determine which V0s are of interest to pair and do pairing + for (size_t v0i = 0; v0i < v0List.size(); v0i++) { + auto v0 = v0List[sorted_v0[v0i]]; + + if (std::abs(v0.pdgCode) != 3122) { + continue; // this V0 isn't a lambda, can't come from a cascade: skip + } + if (v0.particleId < 0) { + continue; // no de-referencing possible (e.g. background, ...) + } + auto v0Particle = mcParticles.rawIteratorAt(v0.particleId); + + int v0OriginParticleIndex = -1; + if (v0Particle.has_mothers()) { + auto const& motherList = v0Particle.template mothers_as(); + if (motherList.size() == 1) { + for (const auto& mother : motherList) { + v0OriginParticleIndex = mother.globalIndex(); + } + } + } + if (v0OriginParticleIndex < 0) { + continue; + } + auto v0OriginParticle = mcParticles.rawIteratorAt(v0OriginParticleIndex); + + if (std::abs(v0OriginParticle.pdgCode()) != 3312 && std::abs(v0OriginParticle.pdgCode()) != 3334) { + continue; // this V0 does not come from any particle of interest, don't try + } + for (const auto& bachelorTrackIndex : bachelorTrackArray) { + if (bachelorTrackIndex.originId != v0OriginParticle.globalIndex()) { + continue; + } + // if we are here: v0 origin is 3312 or 3334, bachelor origin matches V0 origin + // findable mode 1: add non-reconstructed as cascadeType 1 + if (mc_findableMode.value == 1) { + bool detected = false; + for (size_t ii = 0; ii < cascadeListReconstructedSize; ii++) { + // check if this particular combination already exists in cascadeList + // caution: use track indices (immutable) but not V0 indices (re-indexing) + if (cascadeList[ii].posTrackId == v0.posTrackId && + cascadeList[ii].negTrackId == v0.negTrackId && + cascadeList[ii].bachTrackId == bachelorTrackIndex.globalId) { + detected = true; + break; + } + } + if (detected == false) { + // collision index: from best-version-of-this-mcCollision + // nota bene: this could be negative, caution advised + currentCascadeEntry.globalId = -1; + currentCascadeEntry.collisionId = bestCollisionArray[bachelorTrackIndex.mcCollisionId]; + currentCascadeEntry.v0Id = v0i; // correct information here + currentCascadeEntry.posTrackId = v0.posTrackId; + currentCascadeEntry.negTrackId = v0.negTrackId; + currentCascadeEntry.bachTrackId = bachelorTrackIndex.globalId; + currentCascadeEntry.found = false; + cascadeList.push_back(currentCascadeEntry); + if (bestCollisionArray[bachelorTrackIndex.mcCollisionId] < 0) { + collisionLessCascades++; + } + if (cascadeBuilderOpts.mc_findableDetachedCascade.value || currentCascadeEntry.collisionId >= 0) { + cascadeList.push_back(currentCascadeEntry); + } + } + } + + // findable mode 2: determine type based on cascade table, + // with type 1 being reserved to findable-but-not-found + if (mc_findableMode.value == 2) { + currentCascadeEntry.globalId = -1; + currentCascadeEntry.collisionId = bestCollisionArray[bachelorTrackIndex.mcCollisionId]; + currentCascadeEntry.v0Id = v0i; // fill this in one go later + currentCascadeEntry.posTrackId = v0.posTrackId; + currentCascadeEntry.negTrackId = v0.negTrackId; + currentCascadeEntry.bachTrackId = bachelorTrackIndex.globalId; + currentCascadeEntry.found = false; + if (bestCollisionArray[bachelorTrackIndex.mcCollisionId] < 0) { + collisionLessCascades++; + } + for (const auto& cascade : cascades) { + auto const& v0fromAOD = cascade.v0(); + if (v0fromAOD.posTrackId() == v0.posTrackId && + v0fromAOD.negTrackId() == v0.negTrackId && + cascade.bachelorId() == bachelorTrackIndex.globalId) { + // this will override type, but not collision index + // N.B.: collision index checks still desirable! + currentCascadeEntry.found = true; + currentCascadeEntry.globalId = cascade.globalIndex(); + break; + } + } + if (cascadeBuilderOpts.mc_findableDetachedCascade.value || currentCascadeEntry.collisionId >= 0) { + cascadeList.push_back(currentCascadeEntry); + } + } + } // end bachelorTrackArray loop + } // end v0List loop + + // at this stage, cascadeList is alright, but the v0 indices are still not + // correct. We'll have to loop over all V0s and find the appropriate matches + // ---> but only in mode 1, and only for AO2D-native V0s + if (mc_findableMode.value == 1) { + for (size_t casci = 0; casci < cascadeListReconstructedSize; casci++) { + // loop over v0List to find corresponding v0 index, but do it in sorted way + for (size_t v0i = 0; v0i < v0List.size(); v0i++) { + auto v0 = v0List[sorted_v0[v0i]]; + if (cascadeList[casci].posTrackId == v0.posTrackId && + cascadeList[casci].negTrackId == v0.negTrackId) { + cascadeList[casci].v0Id = v0i; // fix, point to correct V0 index + break; + } + } + } + } + // we should now be done! collect statistics + histos.fill(HIST("hFindableStatistics"), 3.0, cascades.size()); + histos.fill(HIST("hFindableStatistics"), 4.0, cascadeList.size()); + histos.fill(HIST("hFindableStatistics"), 5.0, collisionLessCascades); + + } // end findable mode check + } // end soa::is_table + + // we need to allow for sorted use of cascadeList + sorted_cascade.clear(); + sorted_cascade = sort_indices(cascadeList, (mc_findableMode.value > 0)); + } + + LOGF(info, "AO2D input: %i V0s, %i cascades. Building list sizes: %i V0s, %i cascades", v0s.size(), cascades.size(), v0List.size(), cascadeList.size()); + } + + //__________________________________________________ + template + void markV0sUsedInCascades(TV0s const& v0s, TCascades const& cascades, TTrackedCascades const& trackedCascades) + { + int v0sUsedInCascades = 0; + v0sFromCascades.clear(); + v0Map.clear(); + v0Map.resize(v0List.size(), -2); // marks not used + if (useV0BufferForCascades.value == false) { + return; // don't attempt to mark needlessly + } + if (mEnabledTables[kStoredCascCores]) { + for (const auto& cascade : cascadeList) { + if (cascade.v0Id < 0) + continue; + if (v0Map[cascade.v0Id] == -2) { + v0sUsedInCascades++; + } + v0Map[cascade.v0Id] = -1; // marks used (but isn't the index of a properly built V0, which would be >= 0) + } + } + int trackedCascadeCount = 0; + if constexpr (soa::is_table) { + // tracked only created outside of findable mode + if (mEnabledTables[kStoredTraCascCores] && mc_findableMode.value == 0) { + trackedCascadeCount = trackedCascades.size(); + for (const auto& trackedCascade : trackedCascades) { + auto const& cascade = trackedCascade.cascade(); + LOGF(info, "trouble: cascade.v0Id() = %i but v0Map size %i", ao2dV0toV0List[cascade.v0Id()], v0Map.size()); + if (v0Map[ao2dV0toV0List[cascade.v0Id()]] == -2) { + v0sUsedInCascades++; + } + v0Map[ao2dV0toV0List[cascade.v0Id()]] = -1; // marks used (but isn't the index of a built V0, which would be >= 0) + } + } + } + LOGF(debug, "V0 total %i, Cascade total %i, Tracked cascade total %i, V0s flagged used in cascades: %i", v0s.size(), cascades.size(), trackedCascadeCount, v0sUsedInCascades); + } + + //__________________________________________________ + template + void buildV0s(TCollisions const& collisions, TV0s const& v0s, TTracks const& tracks, TMCParticles const& mcParticles) + { + // prepare MC containers (not necessarily used) + std::vector mcV0infos; // V0MCCore information + std::vector mcParticleIsReco; + + if constexpr (soa::is_table) { + // do this if provided with a mcParticle table as well + mcParticleIsReco.resize(mcParticles.size(), false); + } + + int nV0s = 0; + // Loops over all V0s in the time frame + histos.fill(HIST("hInputStatistics"), kV0CoresBase, v0s.size()); + for (size_t iv0 = 0; iv0 < v0List.size(); iv0++) { + const auto& v0 = v0List[sorted_v0[iv0]]; + + if (!mEnabledTables[kV0CoresBase] && v0Map[iv0] == -2) { + // this v0 hasn't been used by cascades and we're not generating V0s, so skip it + products.v0dataLink(-1, -1); + continue; + } + + // Get tracks and generate candidate + // if collisionId positive: get vertex, negative: origin + // could be replaced by mean vertex (but without much benefit...) + float pvX = 0.0f, pvY = 0.0f, pvZ = 0.0f; + if (v0.collisionId >= 0) { + auto const& collision = collisions.rawIteratorAt(v0.collisionId); + pvX = collision.posX(); + pvY = collision.posY(); + pvZ = collision.posZ(); + } + auto const& posTrack = tracks.rawIteratorAt(v0.posTrackId); + auto const& negTrack = tracks.rawIteratorAt(v0.negTrackId); + + auto posTrackPar = getTrackParCov(posTrack); + auto negTrackPar = getTrackParCov(negTrack); + + // handle TPC-only tracks properly (photon conversions) + if (v0BuilderOpts.moveTPCOnlyTracks) { + bool isPosTPCOnly = (posTrack.hasTPC() && !posTrack.hasITS() && !posTrack.hasTRD() && !posTrack.hasTOF()); + if (isPosTPCOnly) { + // Nota bene: positive is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + + auto const& collision = collisions.rawIteratorAt(v0.collisionId); + if (!mVDriftMgr.moveTPCTrack(collision, posTrack, posTrackPar)) { + products.v0dataLink(-1, -1); + continue; + } + } + + bool isNegTPCOnly = (negTrack.hasTPC() && !negTrack.hasITS() && !negTrack.hasTRD() && !negTrack.hasTOF()); + if (isNegTPCOnly) { + // Nota bene: negative is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + + auto const& collision = collisions.rawIteratorAt(v0.collisionId); + if (!mVDriftMgr.moveTPCTrack(collision, negTrack, negTrackPar)) { + products.v0dataLink(-1, -1); + continue; + } + } + } + + if (!straHelper.buildV0Candidate(v0.collisionId, pvX, pvY, pvZ, posTrack, negTrack, posTrackPar, negTrackPar, v0.isCollinearV0, mEnabledTables[kV0Covs], v0BuilderOpts.generatePhotonCandidates)) { + products.v0dataLink(-1, -1); + continue; + } + if constexpr (requires { posTrack.tpcNSigmaEl(); }) { + if (preSelectOpts.preselectOnlyDesiredV0s) { + float lPt = RecoDecay::sqrtSumOfSquares( + straHelper.v0.positiveMomentum[0] + straHelper.v0.negativeMomentum[0], + straHelper.v0.positiveMomentum[1] + straHelper.v0.negativeMomentum[1]); + + float lPtot = RecoDecay::sqrtSumOfSquares( + straHelper.v0.positiveMomentum[0] + straHelper.v0.negativeMomentum[0], + straHelper.v0.positiveMomentum[1] + straHelper.v0.negativeMomentum[1], + straHelper.v0.positiveMomentum[2] + straHelper.v0.negativeMomentum[2]); + + float lLengthTraveled = RecoDecay::sqrtSumOfSquares( + straHelper.v0.position[0] - pvX, + straHelper.v0.position[1] - pvY, + straHelper.v0.position[2] - pvZ); + + uint8_t maskV0Preselection = 0; + + if ( // photon PID, mass, lifetime selection + std::abs(posTrack.tpcNSigmaEl()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaEl()) < preSelectOpts.maxTPCpidNsigma && + std::abs(straHelper.v0.massGamma) < preSelectOpts.massCutPhoton) { + BITSET(maskV0Preselection, selGamma); + } + + if ( // K0Short PID, mass, lifetime selection + std::abs(posTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassKaonNeutral * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutK0S") && + std::abs(straHelper.v0.massK0Short - o2::constants::physics::MassKaonNeutral) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaK0Short(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskV0Preselection, selK0Short); + } + + if ( // Lambda PID, mass, lifetime selection + std::abs(posTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + std::abs(straHelper.v0.massLambda - o2::constants::physics::MassLambda) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaLambda(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskV0Preselection, selLambda); + } + + if ( // antiLambda PID, mass, lifetime selection + std::abs(posTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + std::abs(straHelper.v0.massAntiLambda - o2::constants::physics::MassLambda) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaLambda(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskV0Preselection, selAntiLambda); + } + + histos.fill(HIST("hPreselectionV0s"), maskV0Preselection); + + if (maskV0Preselection == 0) { + products.v0dataLink(-1, -1); + continue; + } + } + } + if (v0Map[iv0] == -1 && useV0BufferForCascades) { + v0Map[iv0] = v0sFromCascades.size(); // provide actual valid index in buffer + v0sFromCascades.push_back(straHelper.v0); + } + // fill requested cursors only if type is not 0 + if (v0.v0Type == 1 || (v0.v0Type > 1 && v0BuilderOpts.generatePhotonCandidates)) { + nV0s++; + if (mEnabledTables[kV0Indices]) { + // for referencing (especially - but not only - when using derived data) + products.v0indices(v0.posTrackId, v0.negTrackId, + v0.collisionId, iv0); + histos.fill(HIST("hTableBuildingStatistics"), kV0Indices); + } + if (mEnabledTables[kV0TrackXs]) { + // further decay chains may need this + products.v0trackXs(straHelper.v0.positiveTrackX, straHelper.v0.negativeTrackX); + histos.fill(HIST("hTableBuildingStatistics"), kV0TrackXs); + } + if (mEnabledTables[kV0CoresBase]) { + // standard analysis + products.v0cores(straHelper.v0.position[0], straHelper.v0.position[1], straHelper.v0.position[2], + straHelper.v0.positiveMomentum[0], straHelper.v0.positiveMomentum[1], straHelper.v0.positiveMomentum[2], + straHelper.v0.negativeMomentum[0], straHelper.v0.negativeMomentum[1], straHelper.v0.negativeMomentum[2], + straHelper.v0.daughterDCA, + straHelper.v0.positiveDCAxy, + straHelper.v0.negativeDCAxy, + TMath::Cos(straHelper.v0.pointingAngle), + straHelper.v0.dcaToPV, + v0.v0Type); + products.v0dataLink(products.v0cores.lastIndex(), -1); + histos.fill(HIST("hTableBuildingStatistics"), kV0CoresBase); + } + if (mEnabledTables[kV0TraPosAtDCAs]) { + // for tracking studies + products.v0dauPositions(straHelper.v0.positivePosition[0], straHelper.v0.positivePosition[1], straHelper.v0.positivePosition[2], + straHelper.v0.negativePosition[0], straHelper.v0.negativePosition[1], straHelper.v0.negativePosition[2]); + histos.fill(HIST("hTableBuildingStatistics"), kV0TraPosAtDCAs); + } + if (mEnabledTables[kV0TraPosAtIUs]) { + // for tracking studies + std::array positivePositionIU; + std::array negativePositionIU; + o2::track::TrackPar positiveTrackParam = getTrackPar(posTrack); + o2::track::TrackPar negativeTrackParam = getTrackPar(negTrack); + positiveTrackParam.getXYZGlo(positivePositionIU); + negativeTrackParam.getXYZGlo(negativePositionIU); + products.v0dauPositionsIU(positivePositionIU[0], positivePositionIU[1], positivePositionIU[2], + negativePositionIU[0], negativePositionIU[1], negativePositionIU[2]); + histos.fill(HIST("hTableBuildingStatistics"), kV0TraPosAtIUs); + } + if (mEnabledTables[kV0Covs]) { + products.v0covs(straHelper.v0.positionCovariance, straHelper.v0.momentumCovariance); + histos.fill(HIST("hTableBuildingStatistics"), kV0Covs); + } + + //_________________________________________________________ + // MC handling part + if constexpr (soa::is_table) { + // only worry about this if someone else worried about this + if ((mEnabledTables[kV0MCCores] || mEnabledTables[kMcV0Labels] || mEnabledTables[kV0MCCollRefs])) { + thisInfo.label = -1; + thisInfo.motherLabel = -1; + thisInfo.pdgCode = 0; + thisInfo.pdgCodeMother = 0; + thisInfo.pdgCodePositive = 0; + thisInfo.pdgCodeNegative = 0; + thisInfo.mcCollision = -1; + thisInfo.xyz[0] = thisInfo.xyz[1] = thisInfo.xyz[2] = 0.0f; + thisInfo.posP[0] = thisInfo.posP[1] = thisInfo.posP[2] = 0.0f; + thisInfo.negP[0] = thisInfo.negP[1] = thisInfo.negP[2] = 0.0f; + thisInfo.momentum[0] = thisInfo.momentum[1] = thisInfo.momentum[2] = 0.0f; + + // Association check + // There might be smarter ways of doing this in the future + if (negTrack.has_mcParticle() && posTrack.has_mcParticle()) { + auto lMCNegTrack = negTrack.template mcParticle_as(); + auto lMCPosTrack = posTrack.template mcParticle_as(); + + thisInfo.pdgCodePositive = lMCPosTrack.pdgCode(); + thisInfo.pdgCodeNegative = lMCNegTrack.pdgCode(); + thisInfo.processPositive = lMCPosTrack.getProcess(); + thisInfo.processNegative = lMCNegTrack.getProcess(); + thisInfo.posP[0] = lMCPosTrack.px(); + thisInfo.posP[1] = lMCPosTrack.py(); + thisInfo.posP[2] = lMCPosTrack.pz(); + thisInfo.negP[0] = lMCNegTrack.px(); + thisInfo.negP[1] = lMCNegTrack.py(); + thisInfo.negP[2] = lMCNegTrack.pz(); + + // check for pi -> mu + antineutrino decay + // if present, de-reference original V0 correctly and provide label to original object + // NOTA BENE: the prong info will still correspond to a muon, treat carefully! + int negOriginating = -1, posOriginating = -1, particleForDecayPositionIdx = -1; + negOriginating = getOriginatingParticle(lMCNegTrack, particleForDecayPositionIdx, v0BuilderOpts.mc_treatPiToMuDecays); + posOriginating = getOriginatingParticle(lMCPosTrack, particleForDecayPositionIdx, v0BuilderOpts.mc_treatPiToMuDecays); + + if (negOriginating > -1 && negOriginating == posOriginating) { + auto originatingV0 = mcParticles.rawIteratorAt(negOriginating); + auto particleForDecayPosition = mcParticles.rawIteratorAt(particleForDecayPositionIdx); + + thisInfo.label = originatingV0.globalIndex(); + thisInfo.xyz[0] = particleForDecayPosition.vx(); + thisInfo.xyz[1] = particleForDecayPosition.vy(); + thisInfo.xyz[2] = particleForDecayPosition.vz(); + + if (originatingV0.has_mcCollision()) { + thisInfo.mcCollision = originatingV0.mcCollisionId(); // save this reference, please + } + + // acquire information + thisInfo.pdgCode = originatingV0.pdgCode(); + thisInfo.isPhysicalPrimary = originatingV0.isPhysicalPrimary(); + thisInfo.momentum[0] = originatingV0.px(); + thisInfo.momentum[1] = originatingV0.py(); + thisInfo.momentum[2] = originatingV0.pz(); + + if (originatingV0.has_mothers()) { + for (const auto& lV0Mother : originatingV0.template mothers_as()) { + thisInfo.pdgCodeMother = lV0Mother.pdgCode(); + thisInfo.motherLabel = lV0Mother.globalIndex(); + } + } + } + + } // end association check + // Construct label table (note: this will be joinable with V0Datas!) + if (mEnabledTables[kMcV0Labels]) { + products.v0labels(thisInfo.label, thisInfo.motherLabel); + histos.fill(HIST("hTableBuildingStatistics"), kMcV0Labels); + } + + // Construct found tag + if (mEnabledTables[kV0FoundTags]) { + products.v0FoundTag(v0.found); + histos.fill(HIST("hTableBuildingStatistics"), kV0FoundTags); + } + + // Mark mcParticle as recoed (no searching necessary afterwards) + if (thisInfo.label > -1) { + mcParticleIsReco[thisInfo.label] = true; + } + + // ---] Symmetric populate [--- + // in this approach, V0Cores will be joinable with V0MCCores. + // this is the most pedagogical approach, but it is also more limited + // and it might use more disk space unnecessarily. + if (v0BuilderOpts.mc_populateV0MCCoresSymmetric) { + if (mEnabledTables[kV0MCCores]) { + products.v0mccores( + thisInfo.label, thisInfo.pdgCode, + thisInfo.pdgCodeMother, thisInfo.pdgCodePositive, thisInfo.pdgCodeNegative, + thisInfo.isPhysicalPrimary, thisInfo.xyz[0], thisInfo.xyz[1], thisInfo.xyz[2], + thisInfo.posP[0], thisInfo.posP[1], thisInfo.posP[2], + thisInfo.negP[0], thisInfo.negP[1], thisInfo.negP[2], + thisInfo.momentum[0], thisInfo.momentum[1], thisInfo.momentum[2]); + histos.fill(HIST("hTableBuildingStatistics"), kV0MCCores); + histos.fill(HIST("hPrimaryV0s"), 0); + if (thisInfo.isPhysicalPrimary) + histos.fill(HIST("hPrimaryV0s"), 1); + } + if (mEnabledTables[kV0MCCollRefs]) { + products.v0mccollref(thisInfo.mcCollision); + histos.fill(HIST("hTableBuildingStatistics"), kV0MCCollRefs); + } + + // n.b. placing the interlink index here allows for the writing of + // code that is agnostic with respect to the joinability of + // V0Cores and V0MCCores (always dereference -> safe) + if (mEnabledTables[kV0CoreMCLabels]) { + products.v0CoreMCLabels(iv0); // interlink index + histos.fill(HIST("hTableBuildingStatistics"), kV0CoreMCLabels); + } + } + // ---] Asymmetric populate [--- + // in this approach, V0Cores will NOT be joinable with V0MCCores. + // an additional reference to V0MCCore that IS joinable with V0Cores + // will be provided to the user. + if (v0BuilderOpts.mc_populateV0MCCoresAsymmetric) { + int thisV0MCCoreIndex = -1; + // step 1: check if this element is already provided in the table + // using the packedIndices variable calculated above + for (uint32_t ii = 0; ii < mcV0infos.size(); ii++) { + if (thisInfo.label == mcV0infos[ii].label && mcV0infos[ii].label > -1) { + thisV0MCCoreIndex = ii; + break; // this exists already in list + } + } + if (thisV0MCCoreIndex < 0 && thisInfo.label > -1) { + // this V0MCCore does not exist yet. Create it and reference it + thisV0MCCoreIndex = mcV0infos.size(); + mcV0infos.push_back(thisInfo); + } + if (mEnabledTables[kV0CoreMCLabels]) { + products.v0CoreMCLabels(thisV0MCCoreIndex); // interlink index + histos.fill(HIST("hTableBuildingStatistics"), kV0CoreMCLabels); + } + } + } // enabled tables check + } // constexpr requires check + } else { + products.v0dataLink(-1, -1); + } + } + + // finish populating V0MCCores if in asymmetric mode + if constexpr (soa::is_table) { + if (v0BuilderOpts.mc_populateV0MCCoresAsymmetric && (mEnabledTables[kV0MCCores] || mEnabledTables[kV0MCCollRefs])) { + // first step: add any un-recoed v0mmcores that were requested + for (const auto& mcParticle : mcParticles) { + thisInfo.label = -1; + thisInfo.motherLabel = -1; + thisInfo.pdgCode = 0; + thisInfo.pdgCodeMother = -1; + thisInfo.pdgCodePositive = -1; + thisInfo.pdgCodeNegative = -1; + thisInfo.mcCollision = -1; + thisInfo.xyz[0] = thisInfo.xyz[1] = thisInfo.xyz[2] = 0.0f; + thisInfo.posP[0] = thisInfo.posP[1] = thisInfo.posP[2] = 0.0f; + thisInfo.negP[0] = thisInfo.negP[1] = thisInfo.negP[2] = 0.0f; + thisInfo.momentum[0] = thisInfo.momentum[1] = thisInfo.momentum[2] = 0.0f; + + if (mcParticleIsReco[mcParticle.globalIndex()] == true) + continue; // skip if already created in list + + if (std::fabs(mcParticle.y()) > v0BuilderOpts.mc_rapidityWindow) + continue; // skip outside midrapidity + + if (v0BuilderOpts.mc_keepOnlyPhysicalPrimary && !mcParticle.isPhysicalPrimary()) + continue; // skip secondary MC V0s + + if ( + (v0BuilderOpts.mc_addGeneratedK0Short && mcParticle.pdgCode() == 310) || + (v0BuilderOpts.mc_addGeneratedLambda && mcParticle.pdgCode() == 3122) || + (v0BuilderOpts.mc_addGeneratedAntiLambda && mcParticle.pdgCode() == -3122) || + (v0BuilderOpts.mc_addGeneratedGamma && mcParticle.pdgCode() == 22)) { + thisInfo.pdgCode = mcParticle.pdgCode(); + thisInfo.isPhysicalPrimary = mcParticle.isPhysicalPrimary(); + thisInfo.label = mcParticle.globalIndex(); + + if (mcParticle.has_mcCollision()) { + thisInfo.mcCollision = mcParticle.mcCollisionId(); // save this reference, please + } + + // + thisInfo.momentum[0] = mcParticle.px(); + thisInfo.momentum[1] = mcParticle.py(); + thisInfo.momentum[2] = mcParticle.pz(); + + if (mcParticle.has_mothers()) { + auto const& mother = mcParticle.template mothers_first_as(); + thisInfo.pdgCodeMother = mother.pdgCode(); + thisInfo.motherLabel = mother.globalIndex(); + } + if (mcParticle.has_daughters()) { + auto const& daughters = mcParticle.template daughters_as(); + + for (const auto& dau : daughters) { + if (dau.getProcess() != 4) + continue; + + if (dau.pdgCode() > 0) { + thisInfo.pdgCodePositive = dau.pdgCode(); + thisInfo.processPositive = dau.getProcess(); + thisInfo.posP[0] = dau.px(); + thisInfo.posP[1] = dau.py(); + thisInfo.posP[2] = dau.pz(); + thisInfo.xyz[0] = dau.vx(); + thisInfo.xyz[1] = dau.vy(); + thisInfo.xyz[2] = dau.vz(); + } + if (dau.pdgCode() < 0) { + thisInfo.pdgCodeNegative = dau.pdgCode(); + thisInfo.processNegative = dau.getProcess(); + thisInfo.negP[0] = dau.px(); + thisInfo.negP[1] = dau.py(); + thisInfo.negP[2] = dau.pz(); + } + } + } + + // if I got here, it means this MC particle was not recoed and is of interest. Add it please + mcV0infos.push_back(thisInfo); + } + } + + for (const auto& info : mcV0infos) { + if (mEnabledTables[kV0MCCores]) { + products.v0mccores( + info.label, info.pdgCode, + info.pdgCodeMother, info.pdgCodePositive, info.pdgCodeNegative, + info.isPhysicalPrimary, info.xyz[0], info.xyz[1], info.xyz[2], + info.posP[0], info.posP[1], info.posP[2], + info.negP[0], info.negP[1], info.negP[2], + info.momentum[0], info.momentum[1], info.momentum[2]); + histos.fill(HIST("hTableBuildingStatistics"), kV0MCCores); + histos.fill(HIST("hPrimaryV0s"), 0); + if (info.isPhysicalPrimary) + histos.fill(HIST("hPrimaryV0s"), 1); + } + if (mEnabledTables[kV0MCCollRefs]) { + products.v0mccollref(info.mcCollision); + histos.fill(HIST("hTableBuildingStatistics"), kV0MCCollRefs); + } + } + } // end V0MCCores filling in case of MC + } // end constexpr requires mcParticles + + LOGF(debug, "V0s in DF: %i, V0s built: %i, V0s built and buffered for cascades: %i.", v0s.size(), nV0s, v0sFromCascades.size()); + } + + //__________________________________________________ + template + void extractMonteCarloProperties(TTrack const& posTrack, TTrack const& negTrack, TTrack const& bachTrack, TMCParticles const& mcParticles) + { + // encapsulates acquisition of MC properties from MC + thisCascInfo.pdgCode = -1, thisCascInfo.pdgCodeMother = -1; + thisCascInfo.pdgCodePositive = -1, thisCascInfo.pdgCodeNegative = -1; + thisCascInfo.pdgCodeBachelor = -1, thisCascInfo.pdgCodeV0 = -1; + thisCascInfo.isPhysicalPrimary = false; + thisCascInfo.xyz[0] = -999.0f, thisCascInfo.xyz[1] = -999.0f, thisCascInfo.xyz[2] = -999.0f; + thisCascInfo.lxyz[0] = -999.0f, thisCascInfo.lxyz[1] = -999.0f, thisCascInfo.lxyz[2] = -999.0f; + thisCascInfo.posP[0] = -999.0f, thisCascInfo.posP[1] = -999.0f, thisCascInfo.posP[2] = -999.0f; + thisCascInfo.negP[0] = -999.0f, thisCascInfo.negP[1] = -999.0f, thisCascInfo.negP[2] = -999.0f; + thisCascInfo.bachP[0] = -999.0f, thisCascInfo.bachP[1] = -999.0f, thisCascInfo.bachP[2] = -999.0f; + thisCascInfo.momentum[0] = -999.0f, thisCascInfo.momentum[1] = -999.0f, thisCascInfo.momentum[2] = -999.0f; + thisCascInfo.label = -1, thisCascInfo.motherLabel = -1; + thisCascInfo.mcParticlePositive = -1; + thisCascInfo.mcParticleNegative = -1; + thisCascInfo.mcParticleBachelor = -1; + + // Association check + // There might be smarter ways of doing this in the future + if (negTrack.has_mcParticle() && posTrack.has_mcParticle() && bachTrack.has_mcParticle()) { + auto lMCBachTrack = bachTrack.template mcParticle_as(); + auto lMCNegTrack = negTrack.template mcParticle_as(); + auto lMCPosTrack = posTrack.template mcParticle_as(); + + thisCascInfo.mcParticlePositive = lMCPosTrack.globalIndex(); + thisCascInfo.mcParticleNegative = lMCNegTrack.globalIndex(); + thisCascInfo.mcParticleBachelor = lMCBachTrack.globalIndex(); + thisCascInfo.pdgCodePositive = lMCPosTrack.pdgCode(); + thisCascInfo.pdgCodeNegative = lMCNegTrack.pdgCode(); + thisCascInfo.pdgCodeBachelor = lMCBachTrack.pdgCode(); + thisCascInfo.posP[0] = lMCPosTrack.px(); + thisCascInfo.posP[1] = lMCPosTrack.py(); + thisCascInfo.posP[2] = lMCPosTrack.pz(); + thisCascInfo.negP[0] = lMCNegTrack.px(); + thisCascInfo.negP[1] = lMCNegTrack.py(); + thisCascInfo.negP[2] = lMCNegTrack.pz(); + thisCascInfo.bachP[0] = lMCBachTrack.px(); + thisCascInfo.bachP[1] = lMCBachTrack.py(); + thisCascInfo.bachP[2] = lMCBachTrack.pz(); + thisCascInfo.processPositive = lMCPosTrack.getProcess(); + thisCascInfo.processNegative = lMCNegTrack.getProcess(); + thisCascInfo.processBachelor = lMCBachTrack.getProcess(); + + // Step 0: treat pi -> mu + antineutrino + // if present, de-reference original V0 correctly and provide label to original object + // NOTA BENE: the prong info will still correspond to a muon, treat carefully! + int negOriginating = -1, posOriginating = -1, bachOriginating = -1; + int particleForLambdaDecayPositionIdx = -1, particleForCascadeDecayPositionIdx = -1; + negOriginating = getOriginatingParticle(lMCNegTrack, particleForLambdaDecayPositionIdx, cascadeBuilderOpts.mc_treatPiToMuDecays); + posOriginating = getOriginatingParticle(lMCPosTrack, particleForLambdaDecayPositionIdx, cascadeBuilderOpts.mc_treatPiToMuDecays); + bachOriginating = getOriginatingParticle(lMCBachTrack, particleForCascadeDecayPositionIdx, cascadeBuilderOpts.mc_treatPiToMuDecays); + + if (negOriginating > -1 && negOriginating == posOriginating) { + auto originatingV0 = mcParticles.rawIteratorAt(negOriginating); + auto particleForLambdaDecayPosition = mcParticles.rawIteratorAt(particleForLambdaDecayPositionIdx); + + thisCascInfo.label = originatingV0.globalIndex(); + thisCascInfo.lxyz[0] = particleForLambdaDecayPosition.vx(); + thisCascInfo.lxyz[1] = particleForLambdaDecayPosition.vy(); + thisCascInfo.lxyz[2] = particleForLambdaDecayPosition.vz(); + thisCascInfo.pdgCodeV0 = originatingV0.pdgCode(); + + if (originatingV0.has_mothers()) { + for (const auto& lV0Mother : originatingV0.template mothers_as()) { + if (lV0Mother.globalIndex() == bachOriginating) { // found mother particle + thisCascInfo.label = lV0Mother.globalIndex(); + + if (lV0Mother.has_mcCollision()) { + thisCascInfo.mcCollision = lV0Mother.mcCollisionId(); // save this reference, please + } + + thisCascInfo.pdgCode = lV0Mother.pdgCode(); + thisCascInfo.isPhysicalPrimary = lV0Mother.isPhysicalPrimary(); + thisCascInfo.xyz[0] = originatingV0.vx(); + thisCascInfo.xyz[1] = originatingV0.vy(); + thisCascInfo.xyz[2] = originatingV0.vz(); + thisCascInfo.momentum[0] = lV0Mother.px(); + thisCascInfo.momentum[1] = lV0Mother.py(); + thisCascInfo.momentum[2] = lV0Mother.pz(); + if (lV0Mother.has_mothers()) { + for (const auto& lV0GrandMother : lV0Mother.template mothers_as()) { + thisCascInfo.pdgCodeMother = lV0GrandMother.pdgCode(); + thisCascInfo.motherLabel = lV0GrandMother.globalIndex(); + } + } + } + } // end v0 mother loop + } // end has_mothers check for V0 + } // end conditional of pos/neg originating being the same + } // end association check + } + + //__________________________________________________ + template + void buildCascades(TCollisions const& collisions, TCascades const& cascades, TTracks const& tracks, TMCParticles const& mcParticles) + { + // prepare MC containers (not necessarily used) + std::vector mcCascinfos; // V0MCCore information + std::vector mcParticleIsReco; + + if constexpr (soa::is_table) { + // do this if provided with a mcParticle table as well + mcParticleIsReco.resize(mcParticles.size(), false); + } + + if (!mEnabledTables[kStoredCascCores]) { + return; // don't do if no request for cascades in place + } + int nCascades = 0; + // Loops over all cascades in the time frame + histos.fill(HIST("hInputStatistics"), kStoredCascCores, cascades.size()); + for (size_t icascade = 0; icascade < cascades.size(); icascade++) { + // Get tracks and generate candidate + auto const& cascade = cascades[sorted_cascade[icascade]]; + // if collisionId positive: get vertex, negative: origin + // could be replaced by mean vertex (but without much benefit...) + float pvX = 0.0f, pvY = 0.0f, pvZ = 0.0f; + if (cascade.collisionId >= 0) { + auto const& collision = collisions.rawIteratorAt(cascade.collisionId); + pvX = collision.posX(); + pvY = collision.posY(); + pvZ = collision.posZ(); + } + auto const& posTrack = tracks.rawIteratorAt(cascade.posTrackId); + auto const& negTrack = tracks.rawIteratorAt(cascade.negTrackId); + auto const& bachTrack = tracks.rawIteratorAt(cascade.bachTrackId); + if (useV0BufferForCascades) { + // this processing path uses a buffer of V0s so that no + // additional minimization step is redone. It consumes less + // CPU at the cost of more memory. Since memory is a more + // limited commodity, this isn't the default option. + + // check if cached - if not, skip + if (cascade.v0Id < 0 || v0Map[cascade.v0Id] < 0) { + // this V0 hasn't been stored / cached + products.cascdataLink(-1); + interlinks.cascadeToCascCores.push_back(-1); + continue; // didn't work out, skip + } + + if (!straHelper.buildCascadeCandidate(cascade.collisionId, pvX, pvY, pvZ, + v0sFromCascades[v0Map[cascade.v0Id]], + posTrack, + negTrack, + bachTrack, + mEnabledTables[kCascBBs], + cascadeBuilderOpts.useCascadeMomentumAtPrimVtx, + mEnabledTables[kCascCovs])) { + products.cascdataLink(-1); + interlinks.cascadeToCascCores.push_back(-1); + continue; // didn't work out, skip + } + } else { + // this processing path generates the entire cascade + // from tracks, without any need to have V0s generated. + if (!straHelper.buildCascadeCandidate(cascade.collisionId, pvX, pvY, pvZ, + posTrack, + negTrack, + bachTrack, + mEnabledTables[kCascBBs], + cascadeBuilderOpts.useCascadeMomentumAtPrimVtx, + mEnabledTables[kCascCovs])) { + products.cascdataLink(-1); + interlinks.cascadeToCascCores.push_back(-1); + continue; // didn't work out, skip + } + } + nCascades++; + + if constexpr (requires { posTrack.tpcNSigmaEl(); }) { + if (preSelectOpts.preselectOnlyDesiredCascades) { + float lPt = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.bachelorMomentum[0] + straHelper.cascade.positiveMomentum[0] + straHelper.cascade.negativeMomentum[0], + straHelper.cascade.bachelorMomentum[1] + straHelper.cascade.positiveMomentum[1] + straHelper.cascade.negativeMomentum[1]); + + float lPtot = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.bachelorMomentum[0] + straHelper.cascade.positiveMomentum[0] + straHelper.cascade.negativeMomentum[0], + straHelper.cascade.bachelorMomentum[1] + straHelper.cascade.positiveMomentum[1] + straHelper.cascade.negativeMomentum[1], + straHelper.cascade.bachelorMomentum[2] + straHelper.cascade.positiveMomentum[2] + straHelper.cascade.negativeMomentum[2]); + + float lV0Ptot = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.positiveMomentum[0] + straHelper.cascade.negativeMomentum[0], + straHelper.cascade.positiveMomentum[1] + straHelper.cascade.negativeMomentum[1], + straHelper.cascade.positiveMomentum[2] + straHelper.cascade.negativeMomentum[2]); + + float lLengthTraveled = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.cascadePosition[0] - pvX, + straHelper.cascade.cascadePosition[1] - pvY, + straHelper.cascade.cascadePosition[2] - pvZ); + + float lV0LengthTraveled = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.v0Position[0] - straHelper.cascade.cascadePosition[0], + straHelper.cascade.v0Position[1] - straHelper.cascade.cascadePosition[1], + straHelper.cascade.v0Position[2] - straHelper.cascade.cascadePosition[2]); + + uint8_t maskCascadePreselection = 0; + + if ( // XiMinus PID and mass selection + straHelper.cascade.charge < 0 && + std::abs(posTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(bachTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lV0LengthTraveled / (lV0Ptot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + o2::constants::physics::MassXiMinus * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutXi") && + std::abs(straHelper.cascade.massXi - o2::constants::physics::MassXiMinus) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaXi(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskCascadePreselection, selXiMinus); + } + + if ( // XiPlus PID and mass selection + straHelper.cascade.charge > 0 && + std::abs(posTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(bachTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lV0LengthTraveled / (lV0Ptot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + o2::constants::physics::MassXiMinus * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutXi") && + std::abs(straHelper.cascade.massXi - o2::constants::physics::MassXiMinus) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaXi(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskCascadePreselection, selXiPlus); + } + + if ( // OmegaMinus PID and mass selection + straHelper.cascade.charge < 0 && + std::abs(posTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(bachTrack.tpcNSigmaKa()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lV0LengthTraveled / (lV0Ptot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + o2::constants::physics::MassOmegaMinus * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutOmega") && + std::abs(straHelper.cascade.massOmega - o2::constants::physics::MassOmegaMinus) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaOmega(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskCascadePreselection, selOmegaMinus); + } + + if ( // OmegaPlus PID and mass selection + straHelper.cascade.charge > 0 && + std::abs(posTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(bachTrack.tpcNSigmaKa()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lV0LengthTraveled / (lV0Ptot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + o2::constants::physics::MassOmegaMinus * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutOmega") && + std::abs(straHelper.cascade.massOmega - o2::constants::physics::MassOmegaMinus) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaOmega(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskCascadePreselection, selOmegaPlus); + } + + histos.fill(HIST("hPreselectionCascades"), maskCascadePreselection); + + if (maskCascadePreselection == 0) { + products.cascdataLink(-1); + interlinks.cascadeToCascCores.push_back(-1); + continue; + } + } + } + + // generate analysis tables as required + if (mEnabledTables[kCascIndices]) { + products.cascidx(cascade.globalId, + straHelper.cascade.positiveTrack, straHelper.cascade.negativeTrack, + straHelper.cascade.bachelorTrack, straHelper.cascade.collisionId); + histos.fill(HIST("hTableBuildingStatistics"), kCascIndices); + } + if (mEnabledTables[kStoredCascCores]) { + products.cascdata(straHelper.cascade.charge, straHelper.cascade.massXi, straHelper.cascade.massOmega, + straHelper.cascade.cascadePosition[0], straHelper.cascade.cascadePosition[1], straHelper.cascade.cascadePosition[2], + straHelper.cascade.v0Position[0], straHelper.cascade.v0Position[1], straHelper.cascade.v0Position[2], + straHelper.cascade.positiveMomentum[0], straHelper.cascade.positiveMomentum[1], straHelper.cascade.positiveMomentum[2], + straHelper.cascade.negativeMomentum[0], straHelper.cascade.negativeMomentum[1], straHelper.cascade.negativeMomentum[2], + straHelper.cascade.bachelorMomentum[0], straHelper.cascade.bachelorMomentum[1], straHelper.cascade.bachelorMomentum[2], + straHelper.cascade.cascadeMomentum[0], straHelper.cascade.cascadeMomentum[1], straHelper.cascade.cascadeMomentum[2], + straHelper.cascade.v0DaughterDCA, straHelper.cascade.cascadeDaughterDCA, + straHelper.cascade.positiveDCAxy, straHelper.cascade.negativeDCAxy, + straHelper.cascade.bachelorDCAxy, straHelper.cascade.cascadeDCAxy, straHelper.cascade.cascadeDCAz); + histos.fill(HIST("hTableBuildingStatistics"), kStoredCascCores); + + // interlink always produced if cascades generated + products.cascdataLink(products.cascdata.lastIndex()); + interlinks.cascCoreToCascades.push_back(cascade.globalId); + interlinks.cascadeToCascCores.push_back(products.cascdata.lastIndex()); + } + + if (mEnabledTables[kCascTrackXs]) { + products.cascTrackXs(straHelper.cascade.positiveTrackX, straHelper.cascade.negativeTrackX, straHelper.cascade.bachelorTrackX); + histos.fill(HIST("hTableBuildingStatistics"), kCascTrackXs); + } + if (mEnabledTables[kCascBBs]) { + products.cascbb(straHelper.cascade.bachBaryonCosPA, straHelper.cascade.bachBaryonDCAxyToPV); + histos.fill(HIST("hTableBuildingStatistics"), kCascBBs); + } + if (mEnabledTables[kCascCovs]) { + products.casccovs(straHelper.cascade.covariance); + histos.fill(HIST("hTableBuildingStatistics"), kCascCovs); + } + + //_________________________________________________________ + // MC handling part + if constexpr (soa::is_table) { + // only worry about this if someone else worried about this + if ((mEnabledTables[kCascMCCores] || mEnabledTables[kMcCascLabels] || mEnabledTables[kCascMCCollRefs])) { + extractMonteCarloProperties(posTrack, negTrack, bachTrack, mcParticles); + + // Construct label table (note: this will be joinable with CascDatas) + if (mEnabledTables[kMcCascLabels]) { + products.casclabels( + thisCascInfo.label, thisCascInfo.motherLabel); + histos.fill(HIST("hTableBuildingStatistics"), kMcCascLabels); + } + + // Construct found tag + if (mEnabledTables[kCascFoundTags]) { + products.cascFoundTag(cascade.found); + histos.fill(HIST("hTableBuildingStatistics"), kCascFoundTags); + } + + // Mark mcParticle as recoed (no searching necessary afterwards) + if (thisCascInfo.label > -1) { + mcParticleIsReco[thisCascInfo.label] = true; + } + + if (cascadeBuilderOpts.mc_populateCascMCCoresSymmetric) { + if (mEnabledTables[kCascMCCores]) { + products.cascmccores( + thisCascInfo.pdgCode, thisCascInfo.pdgCodeMother, thisCascInfo.pdgCodeV0, thisCascInfo.isPhysicalPrimary, + thisCascInfo.pdgCodePositive, thisCascInfo.pdgCodeNegative, thisCascInfo.pdgCodeBachelor, + thisCascInfo.xyz[0], thisCascInfo.xyz[1], thisCascInfo.xyz[2], + thisCascInfo.lxyz[0], thisCascInfo.lxyz[1], thisCascInfo.lxyz[2], + thisCascInfo.posP[0], thisCascInfo.posP[1], thisCascInfo.posP[2], + thisCascInfo.negP[0], thisCascInfo.negP[1], thisCascInfo.negP[2], + thisCascInfo.bachP[0], thisCascInfo.bachP[1], thisCascInfo.bachP[2], + thisCascInfo.momentum[0], thisCascInfo.momentum[1], thisCascInfo.momentum[2]); + histos.fill(HIST("hTableBuildingStatistics"), kCascMCCores); + } + if (mEnabledTables[kCascMCCollRefs]) { + products.cascmccollrefs(thisCascInfo.mcCollision); + histos.fill(HIST("hTableBuildingStatistics"), kCascMCCollRefs); + } + } + + if (cascadeBuilderOpts.mc_populateCascMCCoresAsymmetric) { + int thisCascMCCoreIndex = -1; + // step 1: check if this element is already provided in the table + // using the packedIndices variable calculated above + for (uint32_t ii = 0; ii < mcCascinfos.size(); ii++) { + if (thisCascInfo.label == mcCascinfos[ii].label && mcCascinfos[ii].label > -1) { + thisCascMCCoreIndex = ii; + break; // this exists already in list + } + } + if (thisCascMCCoreIndex < 0) { + // this CascMCCore does not exist yet. Create it and reference it + thisCascMCCoreIndex = mcCascinfos.size(); + mcCascinfos.push_back(thisCascInfo); + } + if (mEnabledTables[kCascCoreMCLabels]) { + products.cascCoreMClabels(thisCascMCCoreIndex); // interlink: reconstructed -> MC index + histos.fill(HIST("hTableBuildingStatistics"), kCascCoreMCLabels); + } + } + + } // enabled tables check + + // if BB tags requested, generate them now + if (mEnabledTables[kMcCascBBTags]) { + bool bbTag = false; + if (bachTrack.has_mcParticle()) { + auto bachelorParticle = bachTrack.template mcParticle_as(); + if (bachelorParticle.pdgCode() == 211) { // pi+, look for antiproton in negative prong + if (negTrack.has_mcParticle()) { + auto baryonParticle = negTrack.template mcParticle_as(); + if (baryonParticle.has_mothers() && bachelorParticle.has_mothers() && baryonParticle.pdgCode() == -2212) { + for (const auto& baryonMother : baryonParticle.template mothers_as()) { + for (const auto& pionMother : bachelorParticle.template mothers_as()) { + if (baryonMother.globalIndex() == pionMother.globalIndex() && baryonMother.pdgCode() == -3122) { + bbTag = true; + } + } + } + } + } + } // end if-pion + if (bachelorParticle.pdgCode() == -211) { // pi-, look for proton in positive prong + if (posTrack.has_mcParticle()) { + auto baryonParticle = posTrack.template mcParticle_as(); + if (baryonParticle.has_mothers() && bachelorParticle.has_mothers() && baryonParticle.pdgCode() == 2212) { + for (const auto& baryonMother : baryonParticle.template mothers_as()) { + for (const auto& pionMother : bachelorParticle.template mothers_as()) { + if (baryonMother.globalIndex() == pionMother.globalIndex() && baryonMother.pdgCode() == 3122) { + bbTag = true; + } + } + } + } + } + } // end if-pion + } // end bachelor has mcparticle + // Construct label table (note: this will be joinable with CascDatas) + products.bbtags(bbTag); + histos.fill(HIST("hTableBuildingStatistics"), kMcCascBBTags); + } // end BB tag table enabled check + + } // constexpr requires mcParticles check + } // cascades loop + + //_________________________________________________________ + // MC handling part + if constexpr (soa::is_table) { + if ((mEnabledTables[kCascMCCores] || mEnabledTables[kMcCascLabels] || mEnabledTables[kCascMCCollRefs])) { + // now populate V0MCCores if in asymmetric mode + if (cascadeBuilderOpts.mc_populateCascMCCoresAsymmetric) { + // first step: add any un-recoed v0mmcores that were requested + for (const auto& mcParticle : mcParticles) { + thisCascInfo.pdgCode = -1, thisCascInfo.pdgCodeMother = -1; + thisCascInfo.pdgCodePositive = -1, thisCascInfo.pdgCodeNegative = -1; + thisCascInfo.pdgCodeBachelor = -1, thisCascInfo.pdgCodeV0 = -1; + thisCascInfo.isPhysicalPrimary = false; + thisCascInfo.xyz[0] = 0.0f, thisCascInfo.xyz[1] = 0.0f, thisCascInfo.xyz[2] = 0.0f; + thisCascInfo.lxyz[0] = 0.0f, thisCascInfo.lxyz[1] = 0.0f, thisCascInfo.lxyz[2] = 0.0f; + thisCascInfo.posP[0] = 0.0f, thisCascInfo.posP[1] = 0.0f, thisCascInfo.posP[2] = 0.0f; + thisCascInfo.negP[0] = 0.0f, thisCascInfo.negP[1] = 0.0f, thisCascInfo.negP[2] = 0.0f; + thisCascInfo.bachP[0] = 0.0f, thisCascInfo.bachP[1] = 0.0f, thisCascInfo.bachP[2] = 0.0f; + thisCascInfo.momentum[0] = 0.0f, thisCascInfo.momentum[1] = 0.0f, thisCascInfo.momentum[2] = 0.0f; + thisCascInfo.label = -1, thisCascInfo.motherLabel = -1; + thisCascInfo.mcParticlePositive = -1; + thisCascInfo.mcParticleNegative = -1; + thisCascInfo.mcParticleBachelor = -1; + + if (mcParticleIsReco[mcParticle.globalIndex()] == true) + continue; // skip if already created in list + + if (std::fabs(mcParticle.y()) > cascadeBuilderOpts.mc_rapidityWindow) + continue; // skip outside midrapidity + + if (cascadeBuilderOpts.mc_keepOnlyPhysicalPrimary && !mcParticle.isPhysicalPrimary()) + continue; // skip secondary MC cascades + + if ( + (cascadeBuilderOpts.mc_addGeneratedXiMinus && mcParticle.pdgCode() == 3312) || + (cascadeBuilderOpts.mc_addGeneratedXiPlus && mcParticle.pdgCode() == -3312) || + (cascadeBuilderOpts.mc_addGeneratedOmegaMinus && mcParticle.pdgCode() == 3334) || + (cascadeBuilderOpts.mc_addGeneratedOmegaPlus && mcParticle.pdgCode() == -3334)) { + thisCascInfo.pdgCode = mcParticle.pdgCode(); + thisCascInfo.isPhysicalPrimary = mcParticle.isPhysicalPrimary(); + + if (mcParticle.has_mcCollision()) { + thisCascInfo.mcCollision = mcParticle.mcCollisionId(); // save this reference, please + } + thisCascInfo.momentum[0] = mcParticle.px(); + thisCascInfo.momentum[1] = mcParticle.py(); + thisCascInfo.momentum[2] = mcParticle.pz(); + thisCascInfo.label = mcParticle.globalIndex(); + + if (mcParticle.has_daughters()) { + auto const& daughters = mcParticle.template daughters_as(); + for (const auto& dau : daughters) { + if (dau.getProcess() != 4) // check whether the daughter comes from a decay + continue; + + if (std::abs(dau.pdgCode()) == 211 || std::abs(dau.pdgCode()) == 321) { + thisCascInfo.pdgCodeBachelor = dau.pdgCode(); + thisCascInfo.bachP[0] = dau.px(); + thisCascInfo.bachP[1] = dau.py(); + thisCascInfo.bachP[2] = dau.pz(); + thisCascInfo.xyz[0] = dau.vx(); + thisCascInfo.xyz[1] = dau.vy(); + thisCascInfo.xyz[2] = dau.vz(); + thisCascInfo.mcParticleBachelor = dau.globalIndex(); + } + if (std::abs(dau.pdgCode()) == 2212) { + thisCascInfo.pdgCodeV0 = dau.pdgCode(); + + for (const auto& v0Dau : dau.template daughters_as()) { + if (v0Dau.getProcess() != 4) + continue; + + if (v0Dau.pdgCode() > 0) { + thisCascInfo.pdgCodePositive = v0Dau.pdgCode(); + thisCascInfo.processPositive = v0Dau.getProcess(); + thisCascInfo.posP[0] = v0Dau.px(); + thisCascInfo.posP[1] = v0Dau.py(); + thisCascInfo.posP[2] = v0Dau.pz(); + thisCascInfo.lxyz[0] = v0Dau.vx(); + thisCascInfo.lxyz[1] = v0Dau.vy(); + thisCascInfo.lxyz[2] = v0Dau.vz(); + thisCascInfo.mcParticlePositive = v0Dau.globalIndex(); + } + if (v0Dau.pdgCode() < 0) { + thisCascInfo.pdgCodeNegative = v0Dau.pdgCode(); + thisCascInfo.processNegative = v0Dau.getProcess(); + thisCascInfo.negP[0] = v0Dau.px(); + thisCascInfo.negP[1] = v0Dau.py(); + thisCascInfo.negP[2] = v0Dau.pz(); + thisCascInfo.mcParticleNegative = v0Dau.globalIndex(); + } + } + } + } + } + + // if I got here, it means this MC particle was not recoed and is of interest. Add it please + mcCascinfos.push_back(thisCascInfo); + } + } + + for (const auto& thisInfoToFill : mcCascinfos) { + if (mEnabledTables[kCascMCCores]) { + products.cascmccores( // a lot of the info below will be compressed in case of not-recoed MC (good!) + thisInfoToFill.pdgCode, thisInfoToFill.pdgCodeMother, thisInfoToFill.pdgCodeV0, thisInfoToFill.isPhysicalPrimary, + thisInfoToFill.pdgCodePositive, thisInfoToFill.pdgCodeNegative, thisInfoToFill.pdgCodeBachelor, + thisInfoToFill.xyz[0], thisInfoToFill.xyz[1], thisInfoToFill.xyz[2], + thisInfoToFill.lxyz[0], thisInfoToFill.lxyz[1], thisInfoToFill.lxyz[2], + thisInfoToFill.posP[0], thisInfoToFill.posP[1], thisInfoToFill.posP[2], + thisInfoToFill.negP[0], thisInfoToFill.negP[1], thisInfoToFill.negP[2], + thisInfoToFill.bachP[0], thisInfoToFill.bachP[1], thisInfoToFill.bachP[2], + thisInfoToFill.momentum[0], thisInfoToFill.momentum[1], thisInfoToFill.momentum[2]); + histos.fill(HIST("hTableBuildingStatistics"), kCascMCCores); + } + if (mEnabledTables[kCascMCCollRefs]) { + products.cascmccollrefs(thisInfoToFill.mcCollision); + histos.fill(HIST("hTableBuildingStatistics"), kCascMCCollRefs); + } + } + } + } // enabled tables check + } // constexpr requires mcParticles check + + LOGF(debug, "Cascades in DF: %i, cascades built: %i", cascades.size(), nCascades); + } + + //__________________________________________________ + template + void buildKFCascades(TCollisions const& collisions, TCascades const& cascades, TTracks const& tracks, TMCParticles const& mcParticles) + { + if (!mEnabledTables[kStoredKFCascCores]) { + return; // don't do if no request for cascades in place + } + int nCascades = 0; + // Loops over all cascades in the time frame + histos.fill(HIST("hInputStatistics"), kStoredKFCascCores, cascades.size()); + for (size_t icascade = 0; icascade < cascades.size(); icascade++) { + // Get tracks and generate candidate + auto const& cascade = cascades[sorted_cascade[icascade]]; + // if collisionId positive: get vertex, negative: origin + // could be replaced by mean vertex (but without much benefit...) + float pvX = 0.0f, pvY = 0.0f, pvZ = 0.0f; + if (cascade.collisionId >= 0) { + auto const& collision = collisions.rawIteratorAt(cascade.collisionId); + pvX = collision.posX(); + pvY = collision.posY(); + pvZ = collision.posZ(); + } + auto const& posTrack = tracks.rawIteratorAt(cascade.posTrackId); + auto const& negTrack = tracks.rawIteratorAt(cascade.negTrackId); + auto const& bachTrack = tracks.rawIteratorAt(cascade.bachTrackId); + if (!straHelper.buildCascadeCandidateWithKF(cascade.collisionId, pvX, pvY, pvZ, + posTrack, + negTrack, + bachTrack, + mEnabledTables[kCascBBs], + cascadeBuilderOpts.kfConstructMethod, + cascadeBuilderOpts.kfTuneForOmega, + cascadeBuilderOpts.kfUseV0MassConstraint, + cascadeBuilderOpts.kfUseCascadeMassConstraint, + cascadeBuilderOpts.kfDoDCAFitterPreMinimV0, + cascadeBuilderOpts.kfDoDCAFitterPreMinimCasc)) { + products.kfcascdataLink(-1); + interlinks.cascadeToKFCascCores.push_back(-1); + continue; // didn't work out, skip + } + nCascades++; + + // generate analysis tables as required + if (mEnabledTables[kKFCascIndices]) { + products.kfcascidx(cascade.globalId, + straHelper.cascade.positiveTrack, straHelper.cascade.negativeTrack, + straHelper.cascade.bachelorTrack, straHelper.cascade.collisionId); + histos.fill(HIST("hTableBuildingStatistics"), kKFCascIndices); + } + if (mEnabledTables[kStoredKFCascCores]) { + products.kfcascdata(straHelper.cascade.charge, straHelper.cascade.massXi, straHelper.cascade.massOmega, + straHelper.cascade.cascadePosition[0], straHelper.cascade.cascadePosition[1], straHelper.cascade.cascadePosition[2], + straHelper.cascade.v0Position[0], straHelper.cascade.v0Position[1], straHelper.cascade.v0Position[2], + straHelper.cascade.positivePosition[0], straHelper.cascade.positivePosition[1], straHelper.cascade.positivePosition[2], + straHelper.cascade.negativePosition[0], straHelper.cascade.negativePosition[1], straHelper.cascade.negativePosition[2], + straHelper.cascade.positiveMomentum[0], straHelper.cascade.positiveMomentum[1], straHelper.cascade.positiveMomentum[2], + straHelper.cascade.negativeMomentum[0], straHelper.cascade.negativeMomentum[1], straHelper.cascade.negativeMomentum[2], + straHelper.cascade.bachelorMomentum[0], straHelper.cascade.bachelorMomentum[1], straHelper.cascade.bachelorMomentum[2], + straHelper.cascade.v0Momentum[0], straHelper.cascade.v0Momentum[1], straHelper.cascade.v0Momentum[2], + straHelper.cascade.cascadeMomentum[0], straHelper.cascade.cascadeMomentum[1], straHelper.cascade.cascadeMomentum[2], + straHelper.cascade.v0DaughterDCA, straHelper.cascade.cascadeDaughterDCA, + straHelper.cascade.positiveDCAxy, straHelper.cascade.negativeDCAxy, + straHelper.cascade.bachelorDCAxy, straHelper.cascade.cascadeDCAxy, straHelper.cascade.cascadeDCAz, + straHelper.cascade.kfMLambda, straHelper.cascade.kfV0Chi2, straHelper.cascade.kfCascadeChi2); + histos.fill(HIST("hTableBuildingStatistics"), kStoredKFCascCores); + + // interlink always produced if cascades generated + products.kfcascdataLink(products.kfcascdata.lastIndex()); + interlinks.kfCascCoreToCascades.push_back(cascade.globalId); + interlinks.cascadeToKFCascCores.push_back(products.kfcascdata.lastIndex()); + } + if (mEnabledTables[kKFCascCovs]) { + products.kfcasccovs(straHelper.cascade.covariance, straHelper.cascade.kfTrackCovarianceV0, straHelper.cascade.kfTrackCovariancePos, straHelper.cascade.kfTrackCovarianceNeg); + histos.fill(HIST("hTableBuildingStatistics"), kKFCascCovs); + } + + //_________________________________________________________ + // MC handling part (labels only) + if constexpr (soa::is_table) { + // only worry about this if someone else worried about this + if ((mEnabledTables[kMcKFCascLabels])) { + extractMonteCarloProperties(posTrack, negTrack, bachTrack, mcParticles); + + // Construct label table (note: this will be joinable with KFCascDatas) + products.kfcasclabels(thisCascInfo.label); + histos.fill(HIST("hTableBuildingStatistics"), kMcKFCascLabels); + } // enabled tables check + } // constexpr requires mcParticles check + } // end loop over cascades + + LOGF(debug, "KF Cascades in DF: %i, KF cascades built: %i", cascades.size(), nCascades); + } + + //__________________________________________________ + template + void buildTrackedCascades(TCollisions const& collisions, TStrangeTracks const& cascadeTracks, TMCParticles const& mcParticles) + { + if (!mEnabledTables[kStoredTraCascCores] || mc_findableMode.value != 0) { + return; // don't do if no request for cascades in place or findable mode used + } + int nCascades = 0; + // Loops over all V0s in the time frame + histos.fill(HIST("hInputStatistics"), kStoredTraCascCores, cascadeTracks.size()); + for (const auto& cascadeTrack : cascadeTracks) { + // Get tracks and generate candidate + if (!cascadeTrack.has_track()) + continue; // safety (should be fine but depends on future stratrack dev) + + auto const& strangeTrack = cascadeTrack.template track_as(); + + // if collisionId positive: get vertex, negative: origin + // could be replaced by mean vertex (but without much benefit...) + float pvX = 0.0f, pvY = 0.0f, pvZ = 0.0f; + if (strangeTrack.has_collision()) { + auto const& collision = collisions.rawIteratorAt(strangeTrack.collisionId()); + pvX = collision.posX(); + pvY = collision.posY(); + pvZ = collision.posZ(); + } + auto const& cascade = cascadeTrack.cascade(); + auto const& v0 = cascade.v0(); + auto const& posTrack = v0.template posTrack_as(); + auto const& negTrack = v0.template negTrack_as(); + auto const& bachTrack = cascade.template bachelor_as(); + if (!straHelper.buildCascadeCandidate(strangeTrack.collisionId(), pvX, pvY, pvZ, + posTrack, + negTrack, + bachTrack, + mEnabledTables[kCascBBs], + cascadeBuilderOpts.useCascadeMomentumAtPrimVtx, + mEnabledTables[kCascCovs])) { + products.tracascdataLink(-1); + interlinks.cascadeToTraCascCores.push_back(-1); + continue; // didn't work out, skip + } + + // recalculate DCAxy, DCAz with strange track + auto strangeTrackParCov = getTrackParCov(strangeTrack); + std::array dcaInfo; + strangeTrackParCov.setPID(o2::track::PID::XiMinus); // FIXME: not OK for omegas + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, strangeTrackParCov, 2.f, straHelper.fitter.getMatCorrType(), &dcaInfo); + straHelper.cascade.cascadeDCAxy = dcaInfo[0]; + straHelper.cascade.cascadeDCAz = dcaInfo[1]; + + // get momentum from strange track (should not be very different) + strangeTrackParCov.getPxPyPzGlo(straHelper.cascade.cascadeMomentum); + + // accounting + nCascades++; + + // generate analysis tables as required + if (mEnabledTables[kTraCascIndices]) { + products.tracascidx(cascade.globalIndex(), + straHelper.cascade.positiveTrack, straHelper.cascade.negativeTrack, + straHelper.cascade.bachelorTrack, cascadeTrack.trackId(), straHelper.cascade.collisionId); + histos.fill(HIST("hTableBuildingStatistics"), kTraCascIndices); + } + if (mEnabledTables[kStoredTraCascCores]) { + products.tracascdata(straHelper.cascade.charge, cascadeTrack.xiMass(), cascadeTrack.omegaMass(), + cascadeTrack.decayX(), cascadeTrack.decayY(), cascadeTrack.decayZ(), + straHelper.cascade.v0Position[0], straHelper.cascade.v0Position[1], straHelper.cascade.v0Position[2], + straHelper.cascade.positiveMomentum[0], straHelper.cascade.positiveMomentum[1], straHelper.cascade.positiveMomentum[2], + straHelper.cascade.negativeMomentum[0], straHelper.cascade.negativeMomentum[1], straHelper.cascade.negativeMomentum[2], + straHelper.cascade.bachelorMomentum[0], straHelper.cascade.bachelorMomentum[1], straHelper.cascade.bachelorMomentum[2], + straHelper.cascade.cascadeMomentum[0], straHelper.cascade.cascadeMomentum[1], straHelper.cascade.cascadeMomentum[2], + straHelper.cascade.v0DaughterDCA, straHelper.cascade.cascadeDaughterDCA, + straHelper.cascade.positiveDCAxy, straHelper.cascade.negativeDCAxy, + straHelper.cascade.bachelorDCAxy, straHelper.cascade.cascadeDCAxy, straHelper.cascade.cascadeDCAz, + cascadeTrack.matchingChi2(), cascadeTrack.topologyChi2(), cascadeTrack.itsClsSize()); + histos.fill(HIST("hTableBuildingStatistics"), kStoredTraCascCores); + + // interlink always produced if base core table generated + products.tracascdataLink(products.tracascdata.lastIndex()); + interlinks.traCascCoreToCascades.push_back(cascade.globalIndex()); + interlinks.cascadeToTraCascCores.push_back(products.tracascdata.lastIndex()); + } + if (mEnabledTables[kCascCovs]) { + std::array traCovMat = {0.}; + strangeTrackParCov.getCovXYZPxPyPzGlo(traCovMat); + float traCovMatArray[21]; + for (int ii = 0; ii < 21; ii++) { + traCovMatArray[ii] = traCovMat[ii]; + } + products.tracasccovs(traCovMatArray); + histos.fill(HIST("hTableBuildingStatistics"), kCascCovs); + } + + //_________________________________________________________ + // MC handling part (labels only) + if constexpr (soa::is_table) { + // only worry about this if someone else worried about this + if ((mEnabledTables[kMcTraCascLabels])) { + extractMonteCarloProperties(posTrack, negTrack, bachTrack, mcParticles); + + // Construct label table (note: this will be joinable with KFCascDatas) + products.tracasclabels(thisCascInfo.label); + histos.fill(HIST("hTableBuildingStatistics"), kMcTraCascLabels); + } // enabled tables check + } // constexpr requires mcParticles check + } // end loop over cascades + LOGF(debug, "Tracked cascades in DF: %i, tracked cascades built: %i", cascadeTracks.size(), nCascades); + } + + //__________________________________________________ + // MC kink handling + template + int getOriginatingParticle(mcpart const& part, int& indexForPositionOfDecay, bool treatPiToMuDecays) + { + int returnValue = -1; + if (part.has_mothers()) { + auto const& motherList = part.template mothers_as(); + if (motherList.size() == 1) { + for (const auto& mother : motherList) { + if (std::abs(part.pdgCode()) == 13 && treatPiToMuDecays) { + // muon decay, de-ref mother twice + if (mother.has_mothers()) { + auto grandMotherList = mother.template mothers_as(); + if (grandMotherList.size() == 1) { + for (const auto& grandMother : grandMotherList) { + returnValue = grandMother.globalIndex(); + indexForPositionOfDecay = mother.globalIndex(); // for V0 decay position: grab muon + } + } + } + } else { + returnValue = mother.globalIndex(); + indexForPositionOfDecay = part.globalIndex(); + } + } + } + } + return returnValue; + } + + //__________________________________________________ + template + void dataProcess(TCollisions const& collisions, TMCCollisions const& mccollisions, TV0s const& v0s, TCascades const& cascades, TTrackedCascades const& trackedCascades, TTracks const& tracks, TBCs const& bcs, TMCParticles const& mcParticles) + { + if (!initCCDB(bcs, collisions)) + return; + + // reset vectors for cascade interlinks + resetInterlinks(); + + // prepare v0List, cascadeList + prepareBuildingLists(collisions, mccollisions, v0s, cascades, tracks, mcParticles); + + // mark V0s that will be buffered for the cascade building + markV0sUsedInCascades(v0List, cascadeList, trackedCascades); + + // build V0s + buildV0s(collisions, v0List, tracks, mcParticles); + + // build cascades + buildCascades(collisions, cascadeList, tracks, mcParticles); + buildKFCascades(collisions, cascadeList, tracks, mcParticles); + + // build tracked cascades only if subscription is Run 3 like (doesn't exist in Run 2) + if constexpr (soa::is_table) { + buildTrackedCascades(collisions, trackedCascades, mcParticles); + } + + populateCascadeInterlinks(); + } + + void processRealData(soa::Join const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtIU const& tracks, aod::BCsWithTimestamps const& bcs) + { + dataProcess(collisions, static_cast(nullptr), v0s, cascades, trackedCascades, tracks, bcs, static_cast(nullptr)); + } + + void processRealDataRun2(soa::Join const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, FullTracksExt const& tracks, aod::BCsWithTimestamps const& bcs) + { + dataProcess(collisions, static_cast(nullptr), v0s, cascades, static_cast(nullptr), tracks, bcs, static_cast(nullptr)); + } + + void processMonteCarlo(soa::Join const& collisions, aod::McCollisions const& mccollisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtLabeledIU const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const& mcParticles) + { + dataProcess(collisions, mccollisions, v0s, cascades, trackedCascades, tracks, bcs, mcParticles); + } + + void processMonteCarloRun2(soa::Join const& collisions, aod::McCollisions const& mccollisions, aod::V0s const& v0s, aod::Cascades const& cascades, FullTracksExtLabeled const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const& mcParticles) + { + dataProcess(collisions, mccollisions, v0s, cascades, static_cast(nullptr), tracks, bcs, mcParticles); + } + + void processRealDataWithPID(soa::Join const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtIUWithPID const& tracks, aod::BCsWithTimestamps const& bcs) + { + dataProcess(collisions, static_cast(nullptr), v0s, cascades, trackedCascades, tracks, bcs, static_cast(nullptr)); + } + + void processRealDataRun2WithPID(soa::Join const& collisions, aod::V0s const& v0s, aod::Cascades const& cascades, FullTracksExtWithPID const& tracks, aod::BCsWithTimestamps const& bcs) + { + dataProcess(collisions, static_cast(nullptr), v0s, cascades, static_cast(nullptr), tracks, bcs, static_cast(nullptr)); + } + + void processMonteCarloWithPID(soa::Join const& collisions, aod::McCollisions const& mccollisions, aod::V0s const& v0s, aod::Cascades const& cascades, aod::TrackedCascades const& trackedCascades, FullTracksExtLabeledIUWithPID const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const& mcParticles) + { + dataProcess(collisions, mccollisions, v0s, cascades, trackedCascades, tracks, bcs, mcParticles); + } + + void processMonteCarloRun2WithPID(soa::Join const& collisions, aod::McCollisions const& mccollisions, aod::V0s const& v0s, aod::Cascades const& cascades, FullTracksExtLabeledWithPID const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const& mcParticles) + { + dataProcess(collisions, mccollisions, v0s, cascades, static_cast(nullptr), tracks, bcs, mcParticles); + } + + PROCESS_SWITCH(StrangenessBuilder, processRealData, "process real data", true); + PROCESS_SWITCH(StrangenessBuilder, processRealDataRun2, "process real data (Run 2)", false); + PROCESS_SWITCH(StrangenessBuilder, processMonteCarlo, "process monte carlo", false); + PROCESS_SWITCH(StrangenessBuilder, processMonteCarloRun2, "process monte carlo (Run 2)", false); + PROCESS_SWITCH(StrangenessBuilder, processRealDataWithPID, "process real data", false); + PROCESS_SWITCH(StrangenessBuilder, processRealDataRun2WithPID, "process real data (Run 2)", false); + PROCESS_SWITCH(StrangenessBuilder, processMonteCarloWithPID, "process monte carlo", false); + PROCESS_SWITCH(StrangenessBuilder, processMonteCarloRun2WithPID, "process monte carlo (Run 2)", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + auto strangenessBuilderTask = adaptAnalysisTask(cfgc); + bool isRun3 = true, hasRunInfo = false; + bool isMC = false, hasDataTypeInfo = false; + if (cfgc.options().hasOption("aod-metadata-Run") == true) { + hasRunInfo = true; + if (cfgc.options().get("aod-metadata-Run") == "2") { + isRun3 = false; + } + } + if (cfgc.options().hasOption("aod-metadata-DataType") == true) { + hasDataTypeInfo = true; + if (cfgc.options().get("aod-metadata-DataType") == "MC") { + isMC = true; + } + } + + int idxSwitches[8]; // 8 switches (real / real r2 / MC / MC r2 + PID) + bool autoConfigureProcessConfig = true; + bool withPID = false; + + for (size_t ipar = 0; ipar < strangenessBuilderTask.options.size(); ipar++) { + auto option = strangenessBuilderTask.options[ipar]; + if (option.name == "processRealData") { + idxSwitches[0] = ipar; + } + if (option.name == "processRealDataRun2") { + idxSwitches[1] = ipar; + } + if (option.name == "processMonteCarlo") { + idxSwitches[2] = ipar; + } + if (option.name == "processMonteCarloRun2") { + idxSwitches[3] = ipar; + } + if (option.name == "processRealDataWithPID") { + idxSwitches[4] = ipar; + } + if (option.name == "processRealDataRun2WithPID") { + idxSwitches[5] = ipar; + } + if (option.name == "processMonteCarloWithPID") { + idxSwitches[6] = ipar; + } + if (option.name == "processMonteCarloRun2WithPID") { + idxSwitches[7] = ipar; + } + if (option.name == "autoConfigureProcess") { + autoConfigureProcessConfig = option.defaultValue.get(); // check if autoconfig requested + } + // use withPID in case preselection is requested + if (option.name == "preSelectOpts.preselectOnlyDesiredV0s" || option.name == "preSelectOpts.preselectOnlyDesiredCascades") { + withPID = withPID || option.defaultValue.get(); + } + } + if ((!hasRunInfo || !hasDataTypeInfo) && autoConfigureProcessConfig) { + throw std::runtime_error("Autoconfigure requested but no metadata information found! Please check if --aod-file was used in the last workflow added in the execution and if the AO2D in question has metadata saved in it."); + } + + // positions of switches are known. Next: flip if asked for + if (autoConfigureProcessConfig) { + int relevantProcess = static_cast(!isRun3) + 2 * static_cast(isMC) + 4 * static_cast(withPID); + LOGF(info, "Automatic configuration of process switches requested! Autodetected settings: isRun3? %i, isMC? %i, withPID? %i (switch #%i)", hasRunInfo, hasDataTypeInfo, isRun3, isMC, withPID, relevantProcess); + for (size_t idx = 0; idx < 8; idx++) { + auto option = strangenessBuilderTask.options[idxSwitches[idx]]; + option.defaultValue = false; // switch all off + } + strangenessBuilderTask.options[idxSwitches[relevantProcess]].defaultValue = true; + } + + return WorkflowSpec{ + strangenessBuilderTask}; +} diff --git a/PWGLF/TableProducer/Strangeness/v0qaanalysis.cxx b/PWGLF/TableProducer/Strangeness/v0qaanalysis.cxx index 1d0c3e50187..bafe557c237 100644 --- a/PWGLF/TableProducer/Strangeness/v0qaanalysis.cxx +++ b/PWGLF/TableProducer/Strangeness/v0qaanalysis.cxx @@ -13,6 +13,9 @@ /// /// \author Francesca Ercolessi (francesca.ercolessi@cern.ch) +#include +#include + #include "Framework/AnalysisTask.h" #include "Common/DataModel/TrackSelectionTables.h" #include "PWGLF/DataModel/LFStrangenessTables.h" @@ -40,7 +43,7 @@ void customize(std::vector& workflowOptions) using DauTracks = soa::Join; using DauTracksMC = soa::Join; -using V0Collisions = soa::Join; +using V0Collisions = soa::Join; struct LfV0qaanalysis { @@ -66,7 +69,7 @@ struct LfV0qaanalysis { } LOG(info) << "Number of process functions enabled: " << nProc; - registry.add("hNEvents", "hNEvents", {HistType::kTH1I, {{10, 0.f, 10.f}}}); + registry.add("hNEvents", "hNEvents", {HistType::kTH1D, {{10, 0.f, 10.f}}}); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "all"); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "sel8"); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "TVX"); @@ -74,11 +77,11 @@ struct LfV0qaanalysis { registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(5, "TFBorder"); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(6, "ITSROFBorder"); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(7, "isTOFVertexMatched"); - registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(8, "isGoodZvtxFT0vsPV"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(8, "isNoSameBunchPileup"); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(9, "Applied selection"); registry.add("hCentFT0M", "hCentFT0M", {HistType::kTH1F, {{1000, 0.f, 100.f}}}); - registry.add("hCentFV0A", "hCentFV0A", {HistType::kTH1F, {{1000, 0.f, 100.f}}}); + registry.add("hCentNGlobals", "hCentNGlobals", {HistType::kTH1F, {{1000, 0.f, 100.f}}}); if (isMC) { registry.add("hCentFT0M_RecoColl_MC", "hCentFT0M_RecoColl_MC", {HistType::kTH1F, {{1000, 0.f, 100.f}}}); registry.add("hCentFT0M_RecoColl_MC_INELgt0", "hCentFT0M_RecoColl_MC_INELgt0", {HistType::kTH1F, {{1000, 0.f, 100.f}}}); @@ -86,14 +89,14 @@ struct LfV0qaanalysis { registry.add("hCentFT0M_GenRecoColl_MC_INELgt0", "hCentFT0M_GenRecoColl_MC_INELgt0", {HistType::kTH1F, {{1000, 0.f, 100.f}}}); registry.add("hCentFT0M_GenColl_MC", "hCentFT0M_GenColl_MC", {HistType::kTH1F, {{1000, 0.f, 100.f}}}); registry.add("hCentFT0M_GenColl_MC_INELgt0", "hCentFT0M_GenColl_MC_INELgt0", {HistType::kTH1F, {{1000, 0.f, 100.f}}}); - registry.add("hNEventsMCGen", "hNEventsMCGen", {HistType::kTH1I, {{4, 0.f, 4.f}}}); + registry.add("hNEventsMCGen", "hNEventsMCGen", {HistType::kTH1D, {{4, 0.f, 4.f}}}); registry.get(HIST("hNEventsMCGen"))->GetXaxis()->SetBinLabel(1, "all"); registry.get(HIST("hNEventsMCGen"))->GetXaxis()->SetBinLabel(2, "zvertex_true"); registry.get(HIST("hNEventsMCGen"))->GetXaxis()->SetBinLabel(3, "INELgt0_true"); - registry.add("hNEventsMCGenReco", "hNEventsMCGenReco", {HistType::kTH1I, {{2, 0.f, 2.f}}}); + registry.add("hNEventsMCGenReco", "hNEventsMCGenReco", {HistType::kTH1D, {{2, 0.f, 2.f}}}); registry.get(HIST("hNEventsMCGenReco"))->GetXaxis()->SetBinLabel(1, "INEL"); registry.get(HIST("hNEventsMCGenReco"))->GetXaxis()->SetBinLabel(2, "INELgt0"); - registry.add("hNEventsMCReco", "hNEventsMCReco", {HistType::kTH1I, {{4, 0.f, 4.f}}}); + registry.add("hNEventsMCReco", "hNEventsMCReco", {HistType::kTH1D, {{4, 0.f, 4.f}}}); registry.get(HIST("hNEventsMCReco"))->GetXaxis()->SetBinLabel(1, "all"); registry.get(HIST("hNEventsMCReco"))->GetXaxis()->SetBinLabel(2, "pass ev sel"); registry.get(HIST("hNEventsMCReco"))->GetXaxis()->SetBinLabel(3, "INELgt0"); @@ -107,6 +110,8 @@ struct LfV0qaanalysis { registry.add("Generated_MCGenRecoColl_INEL_K0Short", "Generated_MCGenRecoColl_INEL_K0Short", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCGenRecoColl_INEL_Lambda", "Generated_MCGenRecoColl_INEL_Lambda", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCGenRecoColl_INEL_AntiLambda", "Generated_MCGenRecoColl_INEL_AntiLambda", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); + registry.add("Generated_MCGenRecoColl_INEL_XiMinus", "Generated_MCGenRecoColl_INEL_XiMinus", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); + registry.add("Generated_MCGenRecoColl_INEL_XiPlus", "Generated_MCGenRecoColl_INEL_XiPlus", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCRecoColl_INEL_K0Short", "Generated_MCRecoColl_INEL_K0Short", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCRecoColl_INEL_Lambda", "Generated_MCRecoColl_INEL_Lambda", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCRecoColl_INEL_AntiLambda", "Generated_MCRecoColl_INEL_AntiLambda", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); @@ -119,6 +124,8 @@ struct LfV0qaanalysis { registry.add("Generated_MCGenRecoColl_INELgt0_K0Short", "Generated_MCGenRecoColl_INELgt0_K0Short", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCGenRecoColl_INELgt0_Lambda", "Generated_MCGenRecoColl_INELgt0_Lambda", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCGenRecoColl_INELgt0_AntiLambda", "Generated_MCGenRecoColl_INELgt0_AntiLambda", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); + registry.add("Generated_MCGenRecoColl_INELgt0_XiMinus", "Generated_MCGenRecoColl_INELgt0_XiMinus", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); + registry.add("Generated_MCGenRecoColl_INELgt0_XiPlus", "Generated_MCGenRecoColl_INELgt0_XiPlus", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCRecoColl_INELgt0_K0Short", "Generated_MCRecoColl_INELgt0_K0Short", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCRecoColl_INELgt0_Lambda", "Generated_MCRecoColl_INELgt0_Lambda", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); registry.add("Generated_MCRecoColl_INELgt0_AntiLambda", "Generated_MCRecoColl_INELgt0_AntiLambda", {HistType::kTH2F, {{250, 0.f, 25.f}, {1000, 0.f, 100.f}}}); @@ -134,13 +141,16 @@ struct LfV0qaanalysis { // Event selection criteria Configurable cutzvertex{"cutzvertex", 15.0f, "Accepted z-vertex range (cm)"}; + Configurable MCcutzvertex{"MCcutzvertex", 100.0f, "Accepted true MC z-vertex range (cm)"}; Configurable sel8{"sel8", 0, "Apply sel8 event selection"}; Configurable isMC{"isMC", 0, "Is MC"}; Configurable isTriggerTVX{"isTriggerTVX", 1, "Is Trigger TVX"}; Configurable isNoTimeFrameBorder{"isNoTimeFrameBorder", 1, "Is No Time Frame Border"}; Configurable isNoITSROFrameBorder{"isNoITSROFrameBorder", 1, "Is No ITS Readout Frame Border"}; Configurable isVertexTOFmatched{"isVertexTOFmatched", 0, "Is Vertex TOF matched"}; - Configurable isGoodZvtxFT0vsPV{"isGoodZvtxFT0vsPV", 0, "isGoodZvtxFT0vsPV"}; + Configurable isNoSameBunchPileup{"isNoSameBunchPileup", 0, "isNoSameBunchPileup"}; + Configurable v0TypeSelection{"v0TypeSelection", 1, "select on a certain V0 type (leave negative if no selection desired)"}; + Configurable NotITSAfterburner{"NotITSAfterburner", 0, "NotITSAfterburner"}; // V0 selection criteria Configurable v0cospa{"v0cospa", 0.97, "V0 CosPA"}; @@ -163,7 +173,7 @@ struct LfV0qaanalysis { return false; } registry.fill(HIST("hNEvents"), 2.5); - if (TMath::Abs(collision.posZ()) > cutzvertex) { + if (std::abs(collision.posZ()) > cutzvertex) { return false; } registry.fill(HIST("hNEvents"), 3.5); @@ -171,7 +181,7 @@ struct LfV0qaanalysis { return false; } registry.fill(HIST("hNEvents"), 4.5); - if (!isMC && isNoITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + if (isNoITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { return false; } registry.fill(HIST("hNEvents"), 5.5); @@ -179,7 +189,7 @@ struct LfV0qaanalysis { return false; } registry.fill(HIST("hNEvents"), 6.5); - if (isGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + if (isNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { return false; } registry.fill(HIST("hNEvents"), 7.5); @@ -201,25 +211,21 @@ struct LfV0qaanalysis { } registry.fill(HIST("hNEvents"), 8.5); registry.fill(HIST("hCentFT0M"), collision.centFT0M()); - registry.fill(HIST("hCentFV0A"), collision.centFV0A()); + registry.fill(HIST("hCentNGlobals"), collision.centNGlobal()); for (auto& v0 : V0s) { // loop over V0s + if (v0.v0Type() != v0TypeSelection) { + continue; + } // c tau 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; float ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; // ITS clusters - int posITSNhits = 0, negITSNhits = 0; - for (unsigned int i = 0; i < 7; i++) { - if (v0.posTrack_as().itsClusterMap() & (1 << i)) { - posITSNhits++; - } - if (v0.negTrack_as().itsClusterMap() & (1 << i)) { - negITSNhits++; - } - } + const int posITSNhits = v0.posTrack_as().itsNCls(); + const int negITSNhits = v0.negTrack_as().itsNCls(); // Event flags int evFlag = 0; @@ -228,27 +234,40 @@ struct LfV0qaanalysis { } int lPDG = 0; + float ptMotherMC = 0.; + float pdgMotherMC = 0.; + float yMC = 0.; bool isPhysicalPrimary = isMC; + bool isDauK0Short = false, isDauLambda = false, isDauAntiLambda = false; + + if (NotITSAfterburner && (v0.negTrack_as().isITSAfterburner() || v0.posTrack_as().isITSAfterburner())) { + continue; + } if (v0.v0radius() > v0radius && v0.v0cosPA() > v0cospa && - TMath::Abs(v0.posTrack_as().eta()) < etadau && - TMath::Abs(v0.negTrack_as().eta()) < etadau) { + std::abs(v0.posTrack_as().eta()) < etadau && + std::abs(v0.negTrack_as().eta()) < etadau) { // Fill table - myv0s(v0.globalIndex(), v0.pt(), v0.yLambda(), v0.yK0Short(), + myv0s(v0.pt(), ptMotherMC, yMC, v0.yLambda(), v0.yK0Short(), v0.mLambda(), v0.mAntiLambda(), v0.mK0Short(), v0.v0radius(), v0.v0cosPA(), v0.dcapostopv(), v0.dcanegtopv(), v0.dcaV0daughters(), v0.posTrack_as().eta(), v0.negTrack_as().eta(), - v0.posTrack_as().phi(), v0.negTrack_as().phi(), posITSNhits, negITSNhits, ctauLambda, ctauAntiLambda, ctauK0s, v0.negTrack_as().tpcNSigmaPr(), v0.posTrack_as().tpcNSigmaPr(), v0.negTrack_as().tpcNSigmaPi(), v0.posTrack_as().tpcNSigmaPi(), v0.negTrack_as().tofNSigmaPr(), v0.posTrack_as().tofNSigmaPr(), v0.negTrack_as().tofNSigmaPi(), v0.posTrack_as().tofNSigmaPi(), - v0.posTrack_as().hasTOF(), v0.negTrack_as().hasTOF(), lPDG, isPhysicalPrimary, - collision.centFT0M(), collision.centFV0A(), evFlag, v0.alpha(), v0.qtarm()); + v0.posTrack_as().hasTOF(), v0.negTrack_as().hasTOF(), lPDG, pdgMotherMC, isDauK0Short, isDauLambda, isDauAntiLambda, isPhysicalPrimary, + collision.centFT0M(), collision.centNGlobal(), evFlag, v0.alpha(), v0.qtarm(), + v0.posTrack_as().tpcNClsCrossedRows(), + v0.posTrack_as().tpcNClsShared(), v0.posTrack_as().itsChi2NCl(), + v0.posTrack_as().tpcChi2NCl(), + v0.negTrack_as().tpcNClsCrossedRows(), + v0.negTrack_as().tpcNClsShared(), v0.negTrack_as().itsChi2NCl(), + v0.negTrack_as().tpcChi2NCl()); } } } @@ -298,6 +317,14 @@ struct LfV0qaanalysis { continue; } + if (v0.v0Type() != v0TypeSelection) { + continue; + } + + if (NotITSAfterburner && (v0.negTrack_as().isITSAfterburner() || v0.posTrack_as().isITSAfterburner())) { + continue; + } + // Highest numerator of efficiency if (v0mcparticle.isPhysicalPrimary()) { if (v0mcparticle.pdgCode() == 310) { @@ -321,46 +348,70 @@ struct LfV0qaanalysis { } int lPDG = 0; + bool isDauK0Short = false, isDauLambda = false, isDauAntiLambda = false; bool isprimary = false; - if (TMath::Abs(v0mcparticle.pdgCode()) == 310 || TMath::Abs(v0mcparticle.pdgCode()) == 3122) { + if (std::abs(v0mcparticle.pdgCode()) == 310 || std::abs(v0mcparticle.pdgCode()) == 3122) { lPDG = v0mcparticle.pdgCode(); isprimary = v0mcparticle.isPhysicalPrimary(); } - - int posITSNhits = 0, negITSNhits = 0; - for (unsigned int i = 0; i < 7; i++) { - if (v0.posTrack_as().itsClusterMap() & (1 << i)) { - posITSNhits++; + for (auto& mcparticleDaughter0 : v0mcparticle.daughters_as()) { + for (auto& mcparticleDaughter1 : v0mcparticle.daughters_as()) { + if (mcparticleDaughter0.pdgCode() == 211 && mcparticleDaughter1.pdgCode() == -211) { + isDauK0Short = true; + } + if (mcparticleDaughter0.pdgCode() == -211 && mcparticleDaughter1.pdgCode() == 2212) { + isDauLambda = true; + } + if (mcparticleDaughter0.pdgCode() == 211 && mcparticleDaughter1.pdgCode() == -2212) { + isDauAntiLambda = true; + } } - if (v0.negTrack_as().itsClusterMap() & (1 << i)) { - negITSNhits++; + } + + float ptMotherMC = 0.; + float pdgMother = 0.; + + if (std::abs(v0mcparticle.pdgCode()) == 3122 && v0mcparticle.has_mothers()) { + for (auto& mcparticleMother0 : v0mcparticle.mothers_as()) { + if (std::abs(mcparticleMother0.pdgCode()) == 3312 || std::abs(mcparticleMother0.pdgCode()) == 3322) { + ptMotherMC = mcparticleMother0.pt(); + pdgMother = mcparticleMother0.pdgCode(); + } } } + const int posITSNhits = v0.posTrack_as().itsNCls(); + const int negITSNhits = v0.negTrack_as().itsNCls(); + 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; float ctauK0s = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; if (v0.v0radius() > v0radius && v0.v0cosPA() > v0cospa && - TMath::Abs(v0.posTrack_as().eta()) < etadau && - TMath::Abs(v0.negTrack_as().eta()) < etadau // && + std::abs(v0.posTrack_as().eta()) < etadau && + std::abs(v0.negTrack_as().eta()) < etadau // && ) { // Fill table - myv0s(v0.globalIndex(), v0.pt(), v0.yLambda(), v0.yK0Short(), + myv0s(v0.pt(), ptMotherMC, v0mcparticle.y(), v0.yLambda(), v0.yK0Short(), v0.mLambda(), v0.mAntiLambda(), v0.mK0Short(), v0.v0radius(), v0.v0cosPA(), v0.dcapostopv(), v0.dcanegtopv(), v0.dcaV0daughters(), v0.posTrack_as().eta(), v0.negTrack_as().eta(), - v0.posTrack_as().phi(), v0.negTrack_as().phi(), posITSNhits, negITSNhits, ctauLambda, ctauAntiLambda, ctauK0s, v0.negTrack_as().tpcNSigmaPr(), v0.posTrack_as().tpcNSigmaPr(), v0.negTrack_as().tpcNSigmaPi(), v0.posTrack_as().tpcNSigmaPi(), v0.negTrack_as().tofNSigmaPr(), v0.posTrack_as().tofNSigmaPr(), v0.negTrack_as().tofNSigmaPi(), v0.posTrack_as().tofNSigmaPi(), - v0.posTrack_as().hasTOF(), v0.negTrack_as().hasTOF(), lPDG, isprimary, - mcCollision.centFT0M(), cent, evFlag, v0.alpha(), v0.qtarm()); + v0.posTrack_as().hasTOF(), v0.negTrack_as().hasTOF(), lPDG, pdgMother, isDauK0Short, isDauLambda, isDauAntiLambda, isprimary, + mcCollision.centFT0M(), cent, evFlag, v0.alpha(), v0.qtarm(), + v0.posTrack_as().tpcNClsCrossedRows(), + v0.posTrack_as().tpcNClsShared(), v0.posTrack_as().itsChi2NCl(), + v0.posTrack_as().tpcChi2NCl(), + v0.negTrack_as().tpcNClsCrossedRows(), + v0.negTrack_as().tpcNClsShared(), v0.negTrack_as().itsChi2NCl(), + v0.negTrack_as().tpcChi2NCl()); } } @@ -409,7 +460,7 @@ struct LfV0qaanalysis { registry.fill(HIST("hNEventsMCGen"), 0.5); - if (TMath::Abs(mcCollision.posZ()) > cutzvertex) { + if (std::abs(mcCollision.posZ()) > MCcutzvertex) { return; } registry.fill(HIST("hNEventsMCGen"), 1.5); @@ -565,6 +616,18 @@ struct LfV0qaanalysis { registry.fill(HIST("Generated_MCGenRecoColl_INELgt0_AntiLambda"), mcParticle.pt(), mcCollision.centFT0M()); // AntiLambda } } + if (mcParticle.pdgCode() == 3312) { + registry.fill(HIST("Generated_MCGenRecoColl_INEL_XiMinus"), mcParticle.pt(), mcCollision.centFT0M()); // XiMinus + if (recoCollIndex_INELgt0 > 0) { + registry.fill(HIST("Generated_MCGenRecoColl_INELgt0_XiMinus"), mcParticle.pt(), mcCollision.centFT0M()); // XiMinus + } + } + if (mcParticle.pdgCode() == -3312) { + registry.fill(HIST("Generated_MCGenRecoColl_INEL_XiPlus"), mcParticle.pt(), mcCollision.centFT0M()); // XiPlus + if (recoCollIndex_INELgt0 > 0) { + registry.fill(HIST("Generated_MCGenRecoColl_INELgt0_XiPlus"), mcParticle.pt(), mcCollision.centFT0M()); // XiPlus + } + } } } PROCESS_SWITCH(LfV0qaanalysis, processMCGen, "Process MC", false); diff --git a/PWGLF/TableProducer/Strangeness/v0selector.cxx b/PWGLF/TableProducer/Strangeness/v0selector.cxx index 454fce2c6da..7d06871d78c 100644 --- a/PWGLF/TableProducer/Strangeness/v0selector.cxx +++ b/PWGLF/TableProducer/Strangeness/v0selector.cxx @@ -15,6 +15,7 @@ #include #include +#include #include #include "Framework/runDataProcessing.h" @@ -36,27 +37,44 @@ struct V0SelectorTask { Produces v0FlagTable; Configurable> K0SPtBins{"K0SPtBins", {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0}, "K0S pt Vals"}; - Configurable> K0SRVals{"K0SRVals", {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, "K0S min R values"}; - Configurable> K0SCtauVals{"K0SCtauVals", {20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0}, "K0S max ctau values"}; - Configurable> K0SCosPAVals{"K0SCosPAVals", {0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997}, "K0S min cosPA values"}; - Configurable> K0SDCAVals{"K0SDCAVals", {0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.15, 0.15, 0.10, 0.10}, "K0S min DCA +- values"}; - Configurable> K0SDCAdVals{"K0SDCAdVals", {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, "K0S max DCAd values"}; + Configurable> K0SRminVals{"K0SRminVals", {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, "K0S min R values"}; + Configurable> K0SRmaxVals{"K0SRmaxVals", {40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0}, "K0S max R values"}; + Configurable> K0SCtauminVals{"K0SCtauminVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "K0S min ctau values"}; + Configurable> K0SCtaumaxVals{"K0SCtaumaxVals", {20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0}, "K0S max ctau values"}; + Configurable> K0SCosPAminVals{"K0SCosPAminVals", {0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997}, "K0S min cosPA values"}; + Configurable> K0SCosPAmaxVals{"K0SCosPAmaxVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "K0S max cosPA values"}; + Configurable> K0SDCAminVals{"K0SDCAminVals", {0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.15, 0.15, 0.10, 0.10}, "K0S min DCA +- values"}; + Configurable> K0SDCAmaxVals{"K0SDCAmaxVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "K0S max DCA +- values"}; + Configurable> K0SDCAdminVals{"K0SDCAdminVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "K0S min DCAd values"}; + Configurable> K0SDCAdmaxVals{"K0SDCAdmaxVals", {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, "K0S max DCAd values"}; Configurable> LambdaPtBins{"LambdaPtBins", {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0}, "Lambda pt Vals"}; - Configurable> LambdaRVals{"LambdaRVals", {1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 20.0, 20.0}, "Lambda min R values"}; - Configurable> LambdaCtauVals{"LambdaCtauVals", {22.5, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0}, "Lambda max ctau values"}; - Configurable> LambdaCosPAVals{"LambdaCosPAVals", {0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997}, "Lambda min cosPA values"}; - Configurable> LambdaDCApVals{"LambdaDCApVals", {0.20, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10}, "Lambda min DCA+ values"}; - Configurable> LambdaDCAnVals{"LambdaDCAnVals", {0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.15, 0.15}, "Lambda min DCA- values"}; - Configurable> LambdaDCAdVals{"LambdaDCAdVals", {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, "Lambda max DCAd values"}; + Configurable> LambdaRminVals{"LambdaRminVals", {1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 20.0, 20.0}, "Lambda min R values"}; + Configurable> LambdaRmaxVals{"LambdaRmaxVals", {40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0}, "Lambda max R values"}; + Configurable> LambdaCtauminVals{"LambdaCtauminVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "Lambda min ctau values"}; + Configurable> LambdaCtaumaxVals{"LambdaCtaumaxVals", {22.5, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0}, "Lambda max ctau values"}; + Configurable> LambdaCosPAminVals{"LambdaCosPAminVals", {0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997}, "Lambda min cosPA values"}; + Configurable> LambdaCosPAmaxVals{"LambdaCosPAmaxVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "Lambda max cosPA values"}; + Configurable> LambdaDCApminVals{"LambdaDCApminVals", {0.20, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10}, "Lambda min DCA+ values"}; + Configurable> LambdaDCApmaxVals{"LambdaDCApmaxVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "Lambda max DCA+ values"}; + Configurable> LambdaDCAnminVals{"LambdaDCAnminVals", {0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.15, 0.15}, "Lambda min DCA- values"}; + Configurable> LambdaDCAnmaxVals{"LambdaDCAnmaxVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "Lambda max DCA- values"}; + Configurable> LambdaDCAdminVals{"LambdaDCAdminVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "Lambda max DCAd values"}; + Configurable> LambdaDCAdmaxVals{"LambdaDCAdmaxVals", {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, "Lambda max DCAd values"}; Configurable> AntiLambdaPtBins{"AntiLambdaPtBins", {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0}, "AntiLambda pt Vals"}; - Configurable> AntiLambdaRVals{"AntiLambdaRVals", {10.0, 10.0, 10.0, 10.0, 20.0, 20.0, 20.0, 20.0}, "AntiLambda min R values"}; - Configurable> AntiLambdaCtauVals{"AntiLambdaCtauVals", {22.5, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0}, "AntiLambda max ctau values"}; - Configurable> AntiLambdaCosPAVals{"AntiLambdaCosPAVals", {0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997}, "AntiLambda min cosPA values"}; - Configurable> AntiLambdaDCApVals{"AntiLambdaDCApVals", {0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20}, "AntiLambda min DCA+ values"}; - Configurable> AntiLambdaDCAnVals{"AntiLambdaDCAnVals", {0.20, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10}, "AntiLambda min DCA- values"}; - Configurable> AntiLambdaDCAdVals{"AntiLambdaDCAdVals", {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, "AntiLambda max DCAd values"}; + Configurable> AntiLambdaRminVals{"AntiLambdaRminVals", {10.0, 10.0, 10.0, 10.0, 20.0, 20.0, 20.0, 20.0}, "AntiLambda min R values"}; + Configurable> AntiLambdaRmaxVals{"AntiLambdaRmaxVals", {40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0}, "AntiLambda max R values"}; + Configurable> AntiLambdaCtauminVals{"AntiLambdaCtauminVals", {-1e-3, -1e-3, -1e-3, -1e-3, -1e-3, -1e-3, -1e-3, -1e-3}, "AntiLambda min ctau values"}; + Configurable> AntiLambdaCtaumaxVals{"AntiLambdaCtaumaxVals", {22.5, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0}, "AntiLambda max ctau values"}; + Configurable> AntiLambdaCosPAminVals{"AntiLambdaCosPAminVals", {0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997}, "AntiLambda min cosPA values"}; + Configurable> AntiLambdaCosPAmaxVals{"AntiLambdaCosPAmaxVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "AntiLambda max cosPA values"}; + Configurable> AntiLambdaDCApminVals{"AntiLambdaDCApminVals", {0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20}, "AntiLambda min DCA+ values"}; + Configurable> AntiLambdaDCApmaxVals{"AntiLambdaDCApmaxVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "AntiLambda max DCA+ values"}; + Configurable> AntiLambdaDCAnminVals{"AntiLambdaDCAnminVals", {0.20, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10}, "AntiLambda min DCA- values"}; + Configurable> AntiLambdaDCAnmaxVals{"AntiLambdaDCAnmaxVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "AntiLambda max DCA- values"}; + Configurable> AntiLambdaDCAdminVals{"AntiLambdaDCAdminVals", {-1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3, -1e3}, "AntiLambda min DCAd values"}; + Configurable> AntiLambdaDCAdmaxVals{"AntiLambdaDCAdmaxVals", {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, "AntiLambda max DCAd values"}; Configurable massCuts{"massCuts", true, "Apply mass cuts"}; Configurable competingMassCuts{"competingMassCuts", true, "Apply competing mass cuts"}; @@ -68,7 +86,7 @@ struct V0SelectorTask { Configurable> AntiLambdaMassHighVals{"AntiLambdaMassHighVals", {1.125, 1.125, 1.125, 1.125, 1.125, 1.125, 1.125, 1.125}, "AntiLambda mass cut upper values (MeV)"}; Configurable randomSelection{"randomSelection", true, "Randomly select V0s"}; - Configurable> K0SFraction{"randomSelectionFraction", {2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0}, "Fraction of K0S to randomly select"}; + Configurable> K0SFraction{"K0SFraction", {2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0}, "Fraction of K0S to randomly select"}; Configurable> LambdaFraction{"LambdaFraction", {2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0}, "Fraction of Lambda to randomly select"}; Configurable> AntiLambdaFraction{"AntiLambdaFraction", {2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0}, "Fraction of AntiLambda to randomly select"}; @@ -76,178 +94,198 @@ struct V0SelectorTask { { } - template - bool K0SCuts(T const& collision, U const& v0) + int getPtBin(float pt, std::vector ptBins) { - if (v0.pt() < K0SPtBins->at(0) || v0.pt() > K0SPtBins->at(K0SPtBins->size() - 1)) { - return false; - } - int ptBin = std::distance(K0SPtBins->begin(), std::upper_bound(K0SPtBins->begin(), K0SPtBins->end(), v0.pt())) - 1; - if (v0.v0radius() < K0SRVals->at(ptBin)) { - return false; - } - if (v0.v0cosPA() < K0SCosPAVals->at(ptBin)) { - return false; - } - if (v0.dcaV0daughters() > K0SDCAdVals->at(ptBin)) { - return false; + if (pt < ptBins.at(0)) + return -1; + if (pt > ptBins.at(ptBins.size() - 1)) + return -2; + + for (unsigned int i = 0; i < ptBins.size() - 1; i++) { + if (pt >= ptBins.at(i) && pt < ptBins.at(i + 1)) { + return i; + } } - if (TMath::Abs(v0.dcapostopv()) < K0SDCAVals->at(ptBin)) { - return false; + return -3; + } + bool cuts(std::vector values, std::vector mincuts, std::vector maxcuts) + { + for (unsigned int i = 0; i < values.size(); i++) { + float val = values.at(i); + float min = mincuts.at(i); + float max = maxcuts.at(i); + + if (val < min && min > -1e2) + return false; + if (val > max && max > -1e2) + return false; } - if (TMath::Abs(v0.dcanegtopv()) < K0SDCAVals->at(ptBin)) { + return true; + } + template + bool K0SCuts(T const& collision, U const& v0) + { + int ptBin = getPtBin(v0.pt(), K0SPtBins); + if (ptBin < 0) return false; + + // This is the only time we need to check min and max simultaneously + // K0S and Lambda(bar) do not share pt binning, so check the ptBin for Lambda(bar) separately + if (competingMassCuts) { + int ptBinCMC = getPtBin(v0.pt(), LambdaPtBins); + if (ptBinCMC >= 0) { // TODO: Should we still do CMC when v0 is out of pT range for Lambda(bar)? + if (v0.mLambda() > LambdaMassLowVals->at(ptBinCMC) && v0.mLambda() < LambdaMassHighVals->at(ptBinCMC)) { + return false; + } + } + ptBinCMC = getPtBin(v0.pt(), AntiLambdaPtBins); + if (ptBinCMC >= 0) { + if (v0.mAntiLambda() > AntiLambdaMassLowVals->at(ptBinCMC) && v0.mAntiLambda() < AntiLambdaMassHighVals->at(ptBinCMC)) { + return false; + } + } } + + float rmin = K0SRminVals->at(ptBin); + float rmax = K0SRmaxVals->at(ptBin); + float ctaumin = K0SCtauminVals->at(ptBin); + float ctaumax = K0SCtaumaxVals->at(ptBin); + float cospamin = K0SCosPAminVals->at(ptBin); + float cospamax = K0SCosPAmaxVals->at(ptBin); + float dcapmin = K0SDCAminVals->at(ptBin); + float dcapmax = K0SDCAmaxVals->at(ptBin); + float dcanmin = K0SDCAminVals->at(ptBin); + float dcanmax = K0SDCAmaxVals->at(ptBin); + float dcadmin = K0SDCAdminVals->at(ptBin); + float dcadmax = K0SDCAdmaxVals->at(ptBin); + float ctau = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; - if (ctau < K0SCtauVals->at(ptBin)) { - return false; - } - // Apply mass cuts only if requested - if (!massCuts) { - return true; - } - if (v0.mK0Short() < K0SMassLowVals->at(ptBin) || v0.mK0Short() > K0SMassHighVals->at(ptBin)) { - return false; - } - if (!competingMassCuts) { - return true; - } - if (v0.mLambda() > LambdaMassLowVals->at(ptBin) && v0.mLambda() < LambdaMassHighVals->at(ptBin)) { - return false; - } - if (v0.mAntiLambda() > AntiLambdaMassLowVals->at(ptBin) && v0.mAntiLambda() < AntiLambdaMassHighVals->at(ptBin)) { - return false; + std::vector vals = {v0.v0radius(), ctau, v0.v0cosPA(), v0.dcaV0daughters(), TMath::Abs(v0.dcapostopv()), TMath::Abs(v0.dcanegtopv())}; + std::vector mincuts = {rmin, ctaumin, cospamin, dcadmin, dcapmin, dcanmin}; + std::vector maxcuts = {rmax, ctaumax, cospamax, dcadmax, dcapmax, dcanmax}; + + if (massCuts) { + vals.push_back(v0.mK0Short()); + mincuts.push_back(K0SMassLowVals->at(ptBin)); + maxcuts.push_back(K0SMassHighVals->at(ptBin)); } - return true; + + return cuts(vals, mincuts, maxcuts); } template bool LambdaCuts(T const& collision, U const& v0) { - if (v0.pt() < LambdaPtBins->at(0) || v0.pt() > LambdaPtBins->at(LambdaPtBins->size() - 1)) { - return false; - } - int ptBin = std::distance(LambdaPtBins->begin(), std::upper_bound(LambdaPtBins->begin(), LambdaPtBins->end(), v0.pt())) - 1; - if (v0.v0radius() < LambdaRVals->at(ptBin)) { - return false; - } - if (v0.v0cosPA() < LambdaCosPAVals->at(ptBin)) { - return false; - } - if (v0.dcaV0daughters() > LambdaDCAdVals->at(ptBin)) { - return false; - } - if (TMath::Abs(v0.dcapostopv()) < LambdaDCApVals->at(ptBin)) { - return false; - } - if (TMath::Abs(v0.dcanegtopv()) < LambdaDCAnVals->at(ptBin)) { + int ptBin = getPtBin(v0.pt(), LambdaPtBins); + if (ptBin < 0) return false; + + if (competingMassCuts) { + int ptBinCMC = getPtBin(v0.pt(), K0SPtBins); + if (ptBinCMC >= 0) { + if (v0.mK0Short() > K0SMassLowVals->at(ptBinCMC) && v0.mK0Short() < K0SMassHighVals->at(ptBinCMC)) + return false; + } } + + float rmin = LambdaRminVals->at(ptBin); + float rmax = LambdaRmaxVals->at(ptBin); + float ctaumin = LambdaCtauminVals->at(ptBin); + float ctaumax = LambdaCtaumaxVals->at(ptBin); + float cospamin = LambdaCosPAminVals->at(ptBin); + float cospamax = LambdaCosPAmaxVals->at(ptBin); + float dcapmin = LambdaDCApminVals->at(ptBin); + float dcapmax = LambdaDCApmaxVals->at(ptBin); + float dcanmin = LambdaDCAnminVals->at(ptBin); + float dcanmax = LambdaDCAnmaxVals->at(ptBin); + float dcadmin = LambdaDCAdminVals->at(ptBin); + float dcadmax = LambdaDCAdmaxVals->at(ptBin); + float ctau = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - if (ctau < LambdaCtauVals->at(ptBin)) { - return false; - } - // Apply mass cuts only if requested - if (!massCuts) { - return true; - } - if (v0.mLambda() < LambdaMassLowVals->at(ptBin) || v0.mLambda() > LambdaMassHighVals->at(ptBin)) { - return false; - } - if (!competingMassCuts) { - return true; - } - if (v0.mK0Short() > K0SMassLowVals->at(ptBin) && v0.mK0Short() < K0SMassHighVals->at(ptBin)) { - return false; + std::vector vals = {v0.v0radius(), ctau, v0.v0cosPA(), v0.dcaV0daughters(), TMath::Abs(v0.dcapostopv()), TMath::Abs(v0.dcanegtopv())}; + std::vector mincuts = {rmin, ctaumin, cospamin, dcadmin, dcapmin, dcanmin}; + std::vector maxcuts = {rmax, ctaumax, cospamax, dcadmax, dcapmax, dcanmax}; + + if (massCuts) { + vals.push_back(v0.mLambda()); + mincuts.push_back(LambdaMassLowVals->at(ptBin)); + maxcuts.push_back(LambdaMassHighVals->at(ptBin)); } - return true; + return cuts(vals, mincuts, maxcuts); } template bool AntiLambdaCuts(T const& collision, U const& v0) { - if (v0.pt() < AntiLambdaPtBins->at(0) || v0.pt() > AntiLambdaPtBins->at(AntiLambdaPtBins->size() - 1)) { - return false; - } - int ptBin = std::distance(AntiLambdaPtBins->begin(), std::upper_bound(AntiLambdaPtBins->begin(), AntiLambdaPtBins->end(), v0.pt())) - 1; - if (v0.v0radius() < AntiLambdaRVals->at(ptBin)) { - return false; - } - if (v0.v0cosPA() < AntiLambdaCosPAVals->at(ptBin)) { - return false; - } - if (v0.dcaV0daughters() > AntiLambdaDCAdVals->at(ptBin)) { - return false; - } - if (TMath::Abs(v0.dcapostopv()) < AntiLambdaDCApVals->at(ptBin)) { - return false; - } - if (TMath::Abs(v0.dcanegtopv()) < AntiLambdaDCAnVals->at(ptBin)) { + int ptBin = getPtBin(v0.pt(), AntiLambdaPtBins); + if (ptBin < 0) return false; + + if (competingMassCuts) { + int ptBinCMC = getPtBin(v0.pt(), K0SPtBins); + if (ptBinCMC >= 0) { + if (v0.mK0Short() > K0SMassLowVals->at(ptBinCMC) && v0.mK0Short() < K0SMassHighVals->at(ptBinCMC)) + return false; + } } + + float rmin = AntiLambdaRminVals->at(ptBin); + float rmax = AntiLambdaRmaxVals->at(ptBin); + float ctaumin = AntiLambdaCtauminVals->at(ptBin); + float ctaumax = AntiLambdaCtaumaxVals->at(ptBin); + float cospamin = AntiLambdaCosPAminVals->at(ptBin); + float cospamax = AntiLambdaCosPAmaxVals->at(ptBin); + float dcapmin = AntiLambdaDCApminVals->at(ptBin); + float dcapmax = AntiLambdaDCApmaxVals->at(ptBin); + float dcanmin = AntiLambdaDCAnminVals->at(ptBin); + float dcanmax = AntiLambdaDCAnmaxVals->at(ptBin); + float dcadmin = AntiLambdaDCAdminVals->at(ptBin); + float dcadmax = AntiLambdaDCAdmaxVals->at(ptBin); + float ctau = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; - if (ctau < AntiLambdaCtauVals->at(ptBin)) { - return false; - } - // Apply mass cuts only if requested - if (!massCuts) { - return true; - } - if (v0.mAntiLambda() < AntiLambdaMassLowVals->at(ptBin) || v0.mAntiLambda() > AntiLambdaMassHighVals->at(ptBin)) { - return false; - } - if (!competingMassCuts) { - return true; - } - if (v0.mK0Short() > K0SMassLowVals->at(ptBin) && v0.mK0Short() < K0SMassHighVals->at(ptBin)) { - return false; + std::vector vals = {v0.v0radius(), ctau, v0.v0cosPA(), v0.dcaV0daughters(), TMath::Abs(v0.dcapostopv()), TMath::Abs(v0.dcanegtopv())}; + std::vector mincuts = {rmin, ctaumin, cospamin, dcadmin, dcapmin, dcanmin}; + std::vector maxcuts = {rmax, ctaumax, cospamax, dcadmax, dcapmax, dcanmax}; + + if (competingMassCuts) { + vals.push_back(v0.mAntiLambda()); + mincuts.push_back(AntiLambdaMassLowVals->at(ptBin)); + maxcuts.push_back(AntiLambdaMassHighVals->at(ptBin)); } - return true; + return cuts(vals, mincuts, maxcuts); } template bool RandomlyReject(T const& v0, uint8_t flag) { - if (!(flag & aod::v0flags::FK0S || flag & aod::v0flags::FLAMBDA || flag & aod::v0flags::FANTILAMBDA)) { - return true; - } - // In case of multiple candidate types, only check the lowest threshold value float threshold = 2.; if (flag & aod::v0flags::FK0S) { - int ptBin = std::distance(K0SPtBins->begin(), std::upper_bound(K0SPtBins->begin(), K0SPtBins->end(), v0.pt())) - 1; - if (threshold > K0SFraction->at(ptBin)) { - threshold = K0SFraction->at(ptBin); - } + int ptBin = getPtBin(v0.pt(), K0SPtBins); + threshold = std::min(threshold, K0SFraction->at(ptBin)); } if (flag & aod::v0flags::FLAMBDA) { - int ptBin = std::distance(LambdaPtBins->begin(), std::upper_bound(LambdaPtBins->begin(), LambdaPtBins->end(), v0.pt())) - 1; - if (threshold > LambdaFraction->at(ptBin)) { - threshold = LambdaFraction->at(ptBin); - } + int ptBin = getPtBin(v0.pt(), LambdaPtBins); + threshold = std::min(threshold, LambdaFraction->at(ptBin)); } if (flag & aod::v0flags::FANTILAMBDA) { - int ptBin = std::distance(AntiLambdaPtBins->begin(), std::upper_bound(AntiLambdaPtBins->begin(), AntiLambdaPtBins->end(), v0.pt())) - 1; - if (threshold > AntiLambdaFraction->at(ptBin)) { - threshold = AntiLambdaFraction->at(ptBin); - } + int ptBin = getPtBin(v0.pt(), AntiLambdaPtBins); + threshold = std::min(threshold, AntiLambdaFraction->at(ptBin)); } + // If gRandom > threshold, reject the candidate return (gRandom->Uniform() > threshold); } void processV0(aod::Collision const& collision, aod::V0Datas const& v0s) { for (const auto& v0 : v0s) { - bool candidateK0S = K0SCuts(collision, v0); - bool candidateLambda = LambdaCuts(collision, v0); - bool candidateAntiLambda = AntiLambdaCuts(collision, v0); uint8_t flag = 0; - flag += candidateK0S * aod::v0flags::FK0S; - flag += candidateLambda * aod::v0flags::FLAMBDA; - flag += candidateAntiLambda * aod::v0flags::FANTILAMBDA; + flag += K0SCuts(collision, v0) * aod::v0flags::FK0S; + flag += LambdaCuts(collision, v0) * aod::v0flags::FLAMBDA; + flag += AntiLambdaCuts(collision, v0) * aod::v0flags::FANTILAMBDA; - if (candidateK0S + candidateLambda + candidateAntiLambda == 0) { + if (flag == 0) flag += aod::v0flags::FREJECTED; - } else if (randomSelection) { + else flag += RandomlyReject(v0, flag) * aod::v0flags::FREJECTED; - } + v0FlagTable(flag); } } diff --git a/PWGLF/Tasks/GlobalEventProperties/CMakeLists.txt b/PWGLF/Tasks/GlobalEventProperties/CMakeLists.txt index 17bb6e42f65..258a43a91d0 100644 --- a/PWGLF/Tasks/GlobalEventProperties/CMakeLists.txt +++ b/PWGLF/Tasks/GlobalEventProperties/CMakeLists.txt @@ -9,3 +9,22 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. +o2physics_add_dpl_workflow(ucc-zdc + SOURCES uccZdc.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + + o2physics_add_dpl_workflow(heavyion-multiplicity + SOURCES heavyionMultiplicity.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(dndeta-mft-pp + SOURCES dndeta-mft-pp.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flattenicty-pikp + SOURCES flattenictyPikp.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB + COMPONENT_NAME Analysis) diff --git a/PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.cxx b/PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.cxx new file mode 100644 index 00000000000..c90a3d89474 --- /dev/null +++ b/PWGLF/Tasks/GlobalEventProperties/dndeta-mft-pp.cxx @@ -0,0 +1,1092 @@ +// Copyright 2020-2025 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. + +// \file dndeta-mft.cxx +// \author Sarah Herrmann +// +// \brief This code loops over MFT tracks and collisions and fills histograms +// useful to compute dNdeta + +#include "PWGMM/Mult/DataModel/bestCollisionTable.h" + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/MathConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RuntimeError.h" +#include "Framework/runDataProcessing.h" +#include "MathUtils/Utils.h" +#include "ReconstructionDataFormats/GlobalTrackID.h" + +#include "TFile.h" + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::track; + +AxisSpec PtAxis = {1001, -0.005, 10.005}; +AxisSpec DeltaZAxis = {61, -6.1, 6.1}; +AxisSpec ZAxis = {301, -30.1, 30.1}; +AxisSpec PhiAxis = {629, 0, o2::constants::math::TwoPI, "Rad", "phi axis"}; +// AxisSpec EtaAxis = {18, -4.6, -1.}; +AxisSpec DCAxyAxis = {100, -1, 10}; +AxisSpec CentAxis = {{0, 10, 20, 30, 40, 50, 60, 70, 80, 100}}; + +static constexpr TrackSelectionFlags::flagtype trackSelectionITS = + TrackSelectionFlags::kITSNCls | TrackSelectionFlags::kITSChi2NDF | + TrackSelectionFlags::kITSHits; + +static constexpr TrackSelectionFlags::flagtype trackSelectionTPC = + TrackSelectionFlags::kTPCNCls | + TrackSelectionFlags::kTPCCrossedRowsOverNCls | + TrackSelectionFlags::kTPCChi2NDF; + +static constexpr TrackSelectionFlags::flagtype trackSelectionDCA = + TrackSelectionFlags::kDCAz | TrackSelectionFlags::kDCAxy; + +using MFTTracksLabeled = soa::Join; + +struct PseudorapidityDensityMFT { + SliceCache cache; + Preslice perCol = o2::aod::fwdtrack::collisionId; + Preslice perMcCol = aod::mcparticle::mcCollisionId; + Preslice perColCentral = aod::track::collisionId; + + Service pdg; + + Configurable estimatorEta{"estimatorEta", 1.0, + "eta range for INEL>0 sample definition"}; + + Configurable useEvSel{"useEvSel", true, "use event selection"}; + Configurable disableITSROFCut{"disableITSROFCut", false, "Disable ITS ROF cut for event selection"}; + ConfigurableAxis multBinning{"multBinning", {701, -0.5, 700.5}, ""}; + ConfigurableAxis EtaAxis = {"etaBinning", {36, -4.6, -1.}, ""}; + + Configurable useZDiffCut{"useZDiffCut", true, "use Z difference cut"}; + Configurable maxZDiff{ + "maxZDiff", 1.0f, + "max allowed Z difference for reconstructed collisions (cm)"}; + + Configurable usePhiCut{"usePhiCut", true, "use azimuthal angle cut"}; + Configurable cfgPhiCut{"cfgPhiCut", 0.1f, + "Cut on azimuthal angle of MFT tracks"}; + Configurable cfgPhiCut1{"cfgPhiCut1", 0.0f, + "low Cut on azimuthal angle of MFT tracks"}; + Configurable cfgPhiCut2{"cfgPhiCut2", 6.3f, + "high Cut on azimuthal angle of MFT tracks"}; + Configurable cfgVzCut1{"cfgVzCut1", -30.0f, + "Cut1 on vertex position of MFT tracks"}; + Configurable cfgVzCut2{"cfgVzCut2", 30.0f, + "Cut2 on vertex position of MFT tracks"}; + Configurable cfgnCluster{"cfgnCluster", 5.0f, + "Cut on no of clusters per MFT track"}; + Configurable cfgnEta1{"cfgnEta1", -4.5f, + "Cut on eta1"}; + Configurable cfgnEta2{"cfgnEta2", -1.0f, + "Cut on eta1"}; + Configurable cfgChi2NDFMax{"cfgChi2NDFMax", 2000.0f, "Max allowed chi2/NDF for MFT tracks"}; + + HistogramRegistry registry{ + "registry", + { + {"TracksEtaZvtx", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}, // + {"Tracks/EtaZvtx_gt0", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}, // + {"TracksPhiEta", + "; #varphi; #eta; tracks", + {HistType::kTH2F, {PhiAxis, EtaAxis}}}, // + {"TracksPhiZvtx", + "; #varphi; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {PhiAxis, ZAxis}}}, // + {"TracksPtEta", + " ; p_{T} (GeV/c); #eta", + {HistType::kTH2F, {PtAxis, EtaAxis}}}, // + {"EventSelection", + ";status;events", + {HistType::kTH1F, {{15, 0.5, 15.5}}}}, + {"EventCounts", + ";status;events", + {HistType::kTH1F, {{2, 0.5, 2.5}}}}, + {"Tracks/Control/TrackCount", ";status;Track counts", {HistType::kTH1F, {{15, 0.5, 15.5}}}}, // added + }}; + + void init(InitContext&) + { + if (static_cast(doprocessMult) + + static_cast(doprocessMultReassoc) + + static_cast(doprocessCountingCentrality) > + 1) { + LOGP(fatal, + "Exactly one process function between processMult, " + "processMultReassoc and processCountingCentrality should be " + "enabled!"); + } + AxisSpec MultAxis = {multBinning, "N_{trk}"}; + auto hstat = registry.get(HIST("EventSelection")); + auto* x = hstat->GetXaxis(); + x->SetBinLabel(1, "All"); + x->SetBinLabel(2, "Vz"); + x->SetBinLabel(3, "Vz+ITSRof"); + x->SetBinLabel(4, "Vz+Selected"); + x->SetBinLabel(5, "Sel8+Vz+INEL>0"); + x->SetBinLabel(6, "Sel INEL,INEL_fwd>0"); + x->SetBinLabel(7, "Rejected"); + x->SetBinLabel(8, "Good BCs"); + x->SetBinLabel(9, "BCs with collisions"); + x->SetBinLabel(10, "BCs with pile-up/splitting"); + x->SetBinLabel(11, "percollisionSample>0"); + x->SetBinLabel(12, "midtracks+percollisionSample>0"); + registry.add({"EventsNtrkZvtx", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"EventsNtrkZvtx_gt0", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"Tracks/2Danalysis/EventsNtrkZvtx_all", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"Tracks/2Danalysis/EventsNtrkZvtx_sel8", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"Tracks/2Danalysis/EventsNtrkZvtx_sel8_inelgt0", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"Tracks/2Danalysis/EventsNtrkZvtx_sel8_inelfwdgt0", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"Tracks/Control/DCAXY", + " ; DCA_{XY} (cm)", + {HistType::kTH1F, {DCAxyAxis}}}); + if (doprocessGen) { + registry.add({"EventsNtrkZvtxGen", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"EventsNtrkZvtxGen_t", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"EventsNtrkZvtxGen_gt0", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"EventsNtrkZvtxGen_gt0t", + "; N_{trk}; #it{z}_{vtx} (cm); events", + {HistType::kTH2F, {MultAxis, ZAxis}}}); + registry.add({"TracksEtaZvtxGen", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); + registry.add({"TracksEtaZvtxGen_t", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); + registry.add({"TracksEtaZvtxGen_gt0", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); + registry.add({"TracksEtaZvtxGen_gt0t", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); + registry.add({"TracksPhiEtaGen", + "; #varphi; #eta; tracks", + {HistType::kTH2F, {PhiAxis, EtaAxis}}}); + registry.add({"TracksPhiEtaGen_gt0", + "; #varphi; #eta; tracks", + {HistType::kTH2F, {PhiAxis, EtaAxis}}}); + registry.add({"TracksPhiEtaGen_gt0t", + "; #varphi; #eta; tracks", + {HistType::kTH2F, {PhiAxis, EtaAxis}}}); + registry.add({"TracksPhiZvtxGen", + "; #varphi; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {PhiAxis, ZAxis}}}); // + registry.add({"TracksToPartPtEta", + " ; p_{T} (GeV/c); #eta", + {HistType::kTH2F, {PtAxis, EtaAxis}}}); // + registry.add({"TracksPtEtaGen", + " ; p_{T} (GeV/c); #eta", + {HistType::kTH2F, {PtAxis, EtaAxis}}}); + registry.add({"TracksPtEtaGen_t", + " ; p_{T} (GeV/c); #eta", + {HistType::kTH2F, {PtAxis, EtaAxis}}}); + registry.add({"EventEfficiency", + "; status; events", + {HistType::kTH1F, {{5, 0.5, 5.5}}}}); + registry.add({"NotFoundEventZvtx", + " ; #it{z}_{vtx} (cm)", + {HistType::kTH1F, {ZAxis}}}); + registry.add({"EventsZposDiff", + " ; Z_{rec} - Z_{gen} (cm)", + {HistType::kTH1F, {DeltaZAxis}}}); + registry.add({"EventsSplitMult", " ; N_{gen}", {HistType::kTH1F, {MultAxis}}}); + auto heff = registry.get(HIST("EventEfficiency")); + x = heff->GetXaxis(); + x->SetBinLabel(1, "Generated"); + x->SetBinLabel(2, "Generated INEL>0"); + x->SetBinLabel(3, "Reconstructed"); + x->SetBinLabel(4, "Selected"); + x->SetBinLabel(5, "Selected INEL>0"); + } + + if (doprocessMultReassoc) { + registry.add({"Tracks/Control/DeltaZ", + " ; #it{z_{orig}}-#it{z_{reass}}", + {HistType::kTH1F, {ZAxis}}}); + + registry.add({"Tracks/Control/TrackAmbDegree", + " ; N_{coll}^{comp}", + {HistType::kTH1F, {{51, -0.5, 50.5}}}}); + registry.add({"Tracks/Control/TrackIsAmb", + " ; isAmbiguous", + {HistType::kTH1I, {{2, -0.5, 1.5}}}}); + + auto htrk = registry.get(HIST("Tracks/Control/TrackCount")); + auto* x = htrk->GetXaxis(); + x->SetBinLabel(0, "All"); + x->SetBinLabel(1, "Reass"); + x->SetBinLabel(2, "Not Reass"); + x->SetBinLabel(3, "Amb"); + x->SetBinLabel(4, "Amb+Not-reass"); + x->SetBinLabel(5, "Non-Amb"); + x->SetBinLabel(6, "Not-Reass+Non-Amb"); + x->SetBinLabel(7, "Amb+Non-Amb"); + x->SetBinLabel(8, "colid<0"); + x->SetBinLabel(9, "wo orphan"); + + registry.add({"Tracks/Control/ReassignedTracksEtaZvtx", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); + registry.add({"Tracks/Control/ReassignedTracksPhiEta", + "; #varphi; #eta; tracks", + {HistType::kTH2F, {PhiAxis, EtaAxis}}}); + registry.add({"Tracks/Control/ReassignedVertexCorr", + "; #it{z}_{vtx}^{orig} (cm); #it{z}_{vtx}^{re} (cm)", + {HistType::kTH2F, {ZAxis, ZAxis}}}); + + registry.add({"Tracks/Control/notReassignedTracksEtaZvtx", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); + registry.add({"Tracks/Control/notReassignedTracksPhiEta", + "; #varphi; #eta; tracks", + {HistType::kTH2F, {PhiAxis, EtaAxis}}}); + registry.add({"Tracks/Control/notReassignedVertexCorr", + "; #it{z}_{vtx}^{orig} (cm); #it{z}_{vtx}^{re} (cm)", + {HistType::kTH2F, {ZAxis, ZAxis}}}); + registry.add({"Tracks/Control/Chi2NDF", + " ; #chi^{2}/ndf", + {HistType::kTH1F, {{5000, 0.0, 5000.0}}}}); + registry.add({"Tracks/Control/amb/AmbTracksEtaZvtx", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + + registry.add({"Tracks/Control/woOrp/nTrk", + " ; N_{Trk}^{all}", + {HistType::kTH1F, {{701, -0.5, 700.5}}}}); // + registry.add({"Tracks/Control/amb/nTrkAmb", + " ; N_{Trk}^{amb}", + {HistType::kTH1F, {{701, -0.5, 700.5}}}}); // + registry.add({"Tracks/Control/nonamb/nTrkNonAmb", + " ; N_{Trk}^{nonamb}", + {HistType::kTH1F, {{701, -0.5, 700.5}}}}); // + + registry.add({"Tracks/Control/amb/AmbTracksPhiEta", + "; #varphi; #eta; tracks", + {HistType::kTH2F, {PhiAxis, EtaAxis}}}); // + registry.add({"Tracks/Control/amb/AmbVertexCorr", + "; #it{z}_{vtx}^{orig} (cm); #it{z}_{vtx}^{re} (cm)", + {HistType::kTH2F, {ZAxis, ZAxis}}}); // + registry.add({"Tracks/Control/amb/EtaZvtxAmb_gt0", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + + registry.add({"Tracks/Control/nonamb/nonAmbTracksEtaZvtx", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + + registry.add({"Tracks/Control/nonamb/nonAmbTracksPhiEta", + "; #varphi; #eta; tracks", + {HistType::kTH2F, {PhiAxis, EtaAxis}}}); // + registry.add({"Tracks/Control/nonamb/nonAmbVertexCorr", + "; #it{z}_{vtx}^{orig} (cm); #it{z}_{vtx}^{re} (cm)", + {HistType::kTH2F, {ZAxis, ZAxis}}}); // + registry.add({"Tracks/Control/nonamb/EtaZvtxNonAmb_gt0", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + + registry.add({"Tracks/Control/woOrp/woOrpTracksEtaZvtx", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + registry.add({"Tracks/Control/woOrp/woOrpEtaZvtx_gt0", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + registry.add({"Tracks/2Danalysis/EtaZvtx", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + registry.add({"Tracks/2Danalysis/EtaZvtx_sel8", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + registry.add({"Tracks/2Danalysis/EtaZvtx_sel8_inelgt0", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + registry.add({"Tracks/2Danalysis/EtaZvtx_sel8_inelfwdgt0", + "; #eta; #it{z}_{vtx} (cm); tracks", + {HistType::kTH2F, {EtaAxis, ZAxis}}}); // + registry.add({"Tracks/Control/woOrp/woOrpTracksPhiEta", + "; #varphi; #eta; tracks", + {HistType::kTH2F, {PhiAxis, EtaAxis}}}); // + registry.add({"Tracks/Control/woOrp/woOrpVertexCorr", + "; #it{z}_{vtx}^{orig} (cm); #it{z}_{vtx}^{re} (cm)", + {HistType::kTH2F, {ZAxis, ZAxis}}}); // + registry.add({"collisionID", " ; Collision ID", + // {HistType::kTH1F,{{100000, 0.5, 100000.0}}}}); // + {HistType::kTH1F, {{100000, -50000.0, 50000.0}}}}); // + registry.add({"collisionIDamb", " ; Collision ID amb", + // {HistType::kTH1F,{{100000, 0.5, 100000.0}}}}); // + {HistType::kTH1F, {{100000, -50000.0, 50000.0}}}}); // + registry.add({"NonambEventCounts", " ; EventCounts Nonamb", {HistType::kTH1F, {{1, 0.5, 1.5}}}}); // + registry.add({"hNumCollisionsNonAmb_InelMFT", " ; Number of Collisions with Non-Ambiguous Tracks;Count;Frequency", {HistType::kTH1F, {{1, 0.5, 1.5}}}}); // + registry.add({"hNumCollisionsAmb_InelMFT", " ; Number of Collisions with Non-Ambiguous Tracks;Count;Frequency", {HistType::kTH1F, {{1, 0.5, 1.5}}}}); // + registry.add({"hNumCollisions_InelMFT", " ; Number of selected events with Inel>0 and MFT>0;Count;Frequency", {HistType::kTH1F, {{1, 0.5, 1.5}}}}); // + registry.add({"hNumCollisions_Inel", " ; Number of selected events with Inel>0;Count;Frequency", {HistType::kTH1F, {{1, 0.5, 1.5}}}}); // + registry.add({"ambEventCounts", " ; EventCounts Nonamb", {HistType::kTH1F, {{1, 0.5, 1.5}}}}); // + } + + if (doprocessCountingCentrality) { + registry.add({"Events/Centrality/Selection", + ";status;centrality;events", + {HistType::kTH2F, {{3, 0.5, 3.5}, CentAxis}}}); + auto hstat = registry.get(HIST("Events/Centrality/Selection")); + auto* x = hstat->GetXaxis(); + x->SetBinLabel(1, "All"); + x->SetBinLabel(2, "Selected"); + x->SetBinLabel(3, "Rejected"); + + registry.add({"Events/Centrality/NtrkZvtx", + "; N_{trk}; Z_{vtx} (cm); centrality", + {HistType::kTH3F, {MultAxis, ZAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/EtaZvtx", + "; #eta; Z_{vtx} (cm); centrality", + {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/PhiEta", + "; #varphi; #eta; centrality", + {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/Control/PtEta", + " ; p_{T} (GeV/c); #eta; centrality", + {HistType::kTH3F, {PtAxis, EtaAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/Control/DCAXYPt", + " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality", + {HistType::kTH3F, {PtAxis, DCAxyAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/Control/ReassignedDCAXYPt", + " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality", + {HistType::kTH3F, {PtAxis, DCAxyAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/Control/ExtraDCAXYPt", + " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality", + {HistType::kTH3F, {PtAxis, DCAxyAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/Control/ExtraTracksEtaZvtx", + "; #eta; Z_{vtx} (cm); centrality", + {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/Control/ExtraTracksPhiEta", + "; #varphi; #eta; centrality", + {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/Control/ReassignedTracksEtaZvtx", + "; #eta; Z_{vtx} (cm); centrality", + {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/Control/ReassignedTracksPhiEta", + "; #varphi; #eta; centrality", + {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/Control/ReassignedVertexCorr", + "; Z_{vtx}^{orig} (cm); Z_{vtx}^{re} (cm); centrality", + {HistType::kTH3F, {ZAxis, ZAxis, CentAxis}}}); + } + + if (doprocessGenCent) { + registry.add({"Events/Centrality/EventEfficiency", + ";status;centrality;events", + {HistType::kTH2F, {{2, 0.5, 2.5}, CentAxis}}}); + auto heff = registry.get(HIST("Events/Centrality/EventEfficiency")); + auto* x = heff->GetXaxis(); + x->SetBinLabel(1, "Generated"); + x->SetBinLabel(2, "Selected"); + + registry.add("Events/Centrality/CentPercentileMCGen", + "CentPercentileMCGen", kTH1D, {CentAxis}, false); + registry.add({"Events/Centrality/NtrkZvtxGen", + "; N_{trk}; Z_{vtx} (cm); centrality", + {HistType::kTH3F, {MultAxis, ZAxis, CentAxis}}}); + registry.add({"Events/Centrality/NtrkZvtxGen_t", + "; N_{trk}; Z_{vtx} (cm); centrality", + {HistType::kTH3F, {MultAxis, ZAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/EtaZvtxGen_t", + "; #eta; Z_{vtx} (cm); centrality", + {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/EtaZvtxGen", + "; #eta; Z_{vtx} (cm); centrality", + {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); + registry.add({"Tracks/Centrality/PhiEtaGen", + "; #varphi; #eta; centrality", + {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); + } + } + + using FullBCs = soa::Join; + void processTagging(FullBCs const& bcs, + soa::Join const& collisions) + { + + std::vector::iterator> cols; + for (const auto& bc : bcs) { + if (!useEvSel || + (useEvSel && ((bc.selection_bit(aod::evsel::kIsBBT0A) && + bc.selection_bit(aod::evsel::kIsBBT0C)) != 0))) { + registry.fill(HIST("EventSelection"), 8); // added 5->12 + cols.clear(); + for (const auto& collision : collisions) { + if (collision.has_foundBC()) { + if (collision.foundBCId() == bc.globalIndex()) { + cols.emplace_back(collision); + } + } else if (collision.bcId() == bc.globalIndex()) { + cols.emplace_back(collision); + } + } + LOGP(debug, "BC {} has {} collisions", bc.globalBC(), cols.size()); + if (!cols.empty()) { + registry.fill(HIST("EventSelection"), 9); // added 6->13 + if (cols.size() > 1) { + registry.fill(HIST("EventSelection"), 10); // added 7->14 + } + } + } + } + } + + PROCESS_SWITCH(PseudorapidityDensityMFT, processTagging, + "Collect event sample stats", true); + + Partition sample = + (aod::fwdtrack::eta < -2.8f) && (aod::fwdtrack::eta > -3.2f); + + Partition sampleCentral = (nabs(aod::track::eta) < 1.f); + + expressions::Filter atrackFilter = + (aod::fwdtrack::bestCollisionId >= 0) && (aod::fwdtrack::eta < -2.0f) && + (aod::fwdtrack::eta > -3.9f) && (nabs(aod::fwdtrack::bestDCAXY) <= 2.f); + + using CollwEv = soa::Join; + + expressions::Filter trackSelectionCentral = + ((aod::track::trackCutFlag & trackSelectionITS) == trackSelectionITS) && + ifnode((aod::track::v001::detectorMap & (uint8_t)o2::aod::track::TPC) == + (uint8_t)o2::aod::track::TPC, + (aod::track::trackCutFlag & trackSelectionTPC) == + trackSelectionTPC, + true) && + ((aod::track::trackCutFlag & trackSelectionDCA) == trackSelectionDCA) && + (nabs(aod::track::eta) < estimatorEta); + + using FiCentralTracks = soa::Filtered< + soa::Join>; // central tracks for INEL>0 + + void processMult(CollwEv::iterator const& collision, + aod::MFTTracks const& tracks, + FiCentralTracks const& midtracks, aod::Tracks const&) + { + + registry.fill(HIST("EventSelection"), 1.); + if (!useEvSel || (useEvSel && collision.sel8())) { + registry.fill(HIST("EventSelection"), 2.); + auto z = collision.posZ(); + auto perCollisionSample = sampleCentral->sliceByCached( + o2::aod::track::collisionId, collision.globalIndex(), cache); + auto Ntrk = perCollisionSample.size(); + + registry.fill(HIST("EventsNtrkZvtx"), Ntrk, z); + + if (midtracks.size() > 0) // INEL>0 + { + registry.fill(HIST("EventSelection"), 3.); + registry.fill(HIST("EventsNtrkZvtx_gt0"), Ntrk, z); + } + + if (tracks.size() > 0) { + for (const auto& track : tracks) { + + float phi = track.phi(); + o2::math_utils::bringTo02Pi(phi); + + if (usePhiCut) { + if ((phi < cfgPhiCut) || + ((phi > o2::constants::math::PI - cfgPhiCut) && (phi < o2::constants::math::PI + cfgPhiCut)) || + (phi > o2::constants::math::TwoPI - cfgPhiCut) || + ((phi > ((o2::constants::math::PIHalf - 0.1) * o2::constants::math::PI) - cfgPhiCut) && + (phi < ((o2::constants::math::PIHalf - 0.1) * o2::constants::math::PI) + cfgPhiCut))) + continue; + } + + registry.fill(HIST("TracksEtaZvtx"), track.eta(), z); + if (midtracks.size() > 0) // INEL>0 + { + registry.fill(HIST("Tracks/EtaZvtx_gt0"), track.eta(), z); + } + registry.fill(HIST("TracksPhiEta"), phi, track.eta()); + registry.fill(HIST("TracksPtEta"), track.pt(), track.eta()); + if ((track.eta() < -2.0f) && (track.eta() > -3.9f)) { + registry.fill(HIST("TracksPhiZvtx"), phi, z); + } + } + } + + } else { + registry.fill(HIST("EventSelection"), 4.); + } + } + + PROCESS_SWITCH(PseudorapidityDensityMFT, processMult, + "Process reco or data info", true); + void processMultReassoc(CollwEv::iterator const& collision, + o2::aod::MFTTracks const&, + soa::SmallGroups const& retracks, + FiCentralTracks const& midtracks, aod::Tracks const&) + { + registry.fill(HIST("EventSelection"), 1.); + auto perCollisionSample = sampleCentral->sliceByCached( + o2::aod::track::collisionId, collision.globalIndex(), cache); + auto Ntrk = perCollisionSample.size(); + auto z = collision.posZ(); + registry.fill(HIST("EventsNtrkZvtx"), Ntrk, z); + if ((z >= cfgVzCut1) && (z <= cfgVzCut2)) { + registry.fill(HIST("Tracks/2Danalysis/EventsNtrkZvtx_all"), Ntrk, z); + registry.fill(HIST("EventSelection"), 2.); + for (const auto& retrack : retracks) { + auto track = retrack.mfttrack(); + float ndf = std::max(2.0f * track.nClusters() - 5.0f, 1.0f); + float chi2ndf = track.chi2() / ndf; + float phi = track.phi(); + o2::math_utils::bringTo02Pi(phi); + if (usePhiCut) { + if ((phi <= 0.02) || ((phi >= 3.10) && (phi <= 3.23)) || (phi >= 6.21)) + continue; + } + if ((cfgnEta1 < track.eta()) && (track.eta() < cfgnEta2) && track.nClusters() >= cfgnCluster && retrack.ambDegree() > 0 && chi2ndf < cfgChi2NDFMax && (phi > cfgPhiCut1 && phi < cfgPhiCut2)) { + registry.fill(HIST("Tracks/2Danalysis/EtaZvtx"), track.eta(), z); + } + } + if (!disableITSROFCut && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return; + } + registry.fill(HIST("EventSelection"), 3.); + if (!useEvSel || (useEvSel && collision.selection_bit(aod::evsel::kIsTriggerTVX) && collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && collision.selection_bit(aod::evsel::kNoSameBunchPileup))) { + registry.fill(HIST("EventSelection"), 4.); + registry.fill(HIST("Tracks/2Danalysis/EventsNtrkZvtx_sel8"), Ntrk, z); + std::unordered_set uniqueEvents; + std::unordered_set uniqueEventsAmb; + std::unordered_set uniqueCollisions; + std::unordered_set uniqueCollisionsAmb; + std::unordered_set eventsInelMFT; + std::unordered_set eventsInel; + if (midtracks.size() > 0) { + registry.fill(HIST("EventSelection"), 5.); + registry.fill(HIST("EventsNtrkZvtx_gt0"), Ntrk, z); + registry.fill(HIST("Tracks/2Danalysis/EventsNtrkZvtx_sel8_inelgt0"), Ntrk, z); + eventsInel.insert(collision.globalIndex()); + } + if (perCollisionSample.size() > 0) { + registry.fill(HIST("EventSelection"), 11.); + } + if (midtracks.size() > 0 && perCollisionSample.size() > 0) { + registry.fill(HIST("EventSelection"), 12.); + } + int64_t i = 0.0, j = 0.0, k = 0.0; + for (const auto& retrack : retracks) { + auto track = retrack.mfttrack(); + float ndf = std::max(2.0f * track.nClusters() - 5.0f, 1.0f); + float chi2ndf = track.chi2() / ndf; + float phi = track.phi(); + o2::math_utils::bringTo02Pi(phi); + if (usePhiCut) { + if ((phi <= 0.02) || ((phi >= 3.10) && (phi <= 3.23)) || (phi >= 6.21)) + continue; + } + if ((cfgnEta1 < track.eta()) && (track.eta() < cfgnEta2) && track.nClusters() >= cfgnCluster && retrack.ambDegree() > 0 && chi2ndf < cfgChi2NDFMax && (phi > cfgPhiCut1 && phi < cfgPhiCut2)) { + registry.fill(HIST("Tracks/Control/Chi2NDF"), chi2ndf); + registry.fill(HIST("Tracks/2Danalysis/EtaZvtx_sel8"), track.eta(), z); + if (midtracks.size() > 0 && retrack.ambDegree() > 0) { + registry.fill(HIST("Tracks/2Danalysis/EtaZvtx_sel8_inelgt0"), track.eta(), z); + } + } + } + if (retracks.size() > 0) { + registry.fill(HIST("EventSelection"), 6.); + if (midtracks.size() > 0) { + registry.fill(HIST("Tracks/2Danalysis/EventsNtrkZvtx_sel8_inelfwdgt0"), Ntrk, z); + } + for (const auto& retrack : retracks) { + auto track = retrack.mfttrack(); + float ndf = std::max(2.0f * track.nClusters() - 5.0f, 1.0f); + float chi2ndf = track.chi2() / ndf; + float phi = track.phi(); + o2::math_utils::bringTo02Pi(phi); + if ((cfgnEta1 < track.eta()) && (track.eta() < cfgnEta2) && track.nClusters() >= cfgnCluster && chi2ndf < cfgChi2NDFMax && (phi > cfgPhiCut1 && phi < cfgPhiCut2)) { + if (usePhiCut) { + if ((phi <= 0.02) || ((phi >= 3.10) && (phi <= 3.23)) || (phi >= 6.21)) + continue; + } + registry.fill(HIST("TracksEtaZvtx"), track.eta(), z); + if (midtracks.size() > 0 && retrack.ambDegree() > 0) { + registry.fill(HIST("Tracks/EtaZvtx_gt0"), track.eta(), z); + registry.fill(HIST("Tracks/2Danalysis/EtaZvtx_sel8_inelfwdgt0"), track.eta(), z); + eventsInelMFT.insert(retrack.bestCollisionId()); + } + if (retrack.ambDegree() != 0) { + registry.fill(HIST("Tracks/Control/woOrp/woOrpEtaZvtx_gt0"), track.eta(), z); + ++k; + } + float phi = track.phi(); + o2::math_utils::bringTo02Pi(phi); + registry.fill(HIST("Tracks/Control/TrackCount"), 0); + registry.fill(HIST("TracksPhiEta"), phi, track.eta()); + registry.fill(HIST("TracksPtEta"), track.pt(), track.eta()); + if ((track.eta() < -2.0f) && (track.eta() > -3.9f)) { + registry.fill(HIST("TracksPhiZvtx"), phi, z); + } + if (track.collisionId() > -1 && retrack.ambDegree() == 1) { + registry.fill(HIST("Tracks/Control/TrackCount"), 8); + registry.fill(HIST("collisionID"), track.collisionId()); + } + if (track.collisionId() > -1 && retrack.ambDegree() > 1) { + registry.fill(HIST("collisionIDamb"), track.collisionId()); + } + if (track.collisionId() != retrack.bestCollisionId()) { + registry.fill(HIST("Tracks/Control/ReassignedTracksEtaZvtx"), + track.eta(), z); + registry.fill(HIST("Tracks/Control/ReassignedTracksPhiEta"), phi, + track.eta()); + registry.fill(HIST("Tracks/Control/ReassignedVertexCorr"), + track.collision_as().posZ(), z); + + registry.fill(HIST("Tracks/Control/DeltaZ"), + track.collision_as().posZ() - + collision.posZ()); + registry.fill(HIST("Tracks/Control/TrackCount"), 1); + } + if (track.collisionId() == retrack.bestCollisionId()) { + registry.fill(HIST("Tracks/Control/notReassignedTracksEtaZvtx"), + track.eta(), z); + registry.fill(HIST("Tracks/Control/notReassignedTracksPhiEta"), phi, + track.eta()); + registry.fill(HIST("Tracks/Control/notReassignedVertexCorr"), + track.collision_as().posZ(), z); + registry.fill(HIST("Tracks/Control/TrackCount"), 2); + } + + registry.fill(HIST("Tracks/Control/TrackAmbDegree"), + retrack.ambDegree()); + registry.fill(HIST("Tracks/Control/DCAXY"), retrack.bestDCAXY()); + int isAmbiguous = 0; + + if (retrack.ambDegree() > 1 && retrack.ambDegree() != 0) { + isAmbiguous = 1; + ++i; + + registry.fill(HIST("Tracks/Control/amb/EtaZvtxAmb_gt0"), track.eta(), z); + + registry.fill(HIST("Tracks/Control/amb/AmbTracksEtaZvtx"), + track.eta(), z); + registry.fill(HIST("Tracks/Control/amb/AmbTracksPhiEta"), phi, + track.eta()); + registry.fill(HIST("Tracks/Control/amb/AmbVertexCorr"), + track.collision_as().posZ(), z); + registry.fill(HIST("Tracks/Control/TrackCount"), 3); + if (track.collisionId() == retrack.bestCollisionId()) { + registry.fill(HIST("Tracks/Control/TrackCount"), 5); + } + uniqueEventsAmb.insert(retrack.bestCollisionId()); + } + if (midtracks.size() > 0 && retrack.ambDegree() > 1 && retrack.ambDegree() != 0) { + uniqueCollisionsAmb.insert(collision.globalIndex()); + } + + registry.fill(HIST("Tracks/Control/TrackIsAmb"), isAmbiguous); + if (retrack.ambDegree() == 1 && retrack.ambDegree() != 0) { + ++j; + registry.fill(HIST("Tracks/Control/nonamb/EtaZvtxNonAmb_gt0"), track.eta(), z); + registry.fill(HIST("Tracks/Control/nonamb/nonAmbTracksEtaZvtx"), + track.eta(), z); + registry.fill(HIST("Tracks/Control/nonamb/nonAmbTracksPhiEta"), phi, + track.eta()); + registry.fill(HIST("Tracks/Control/nonamb/nonAmbVertexCorr"), + track.collision_as().posZ(), z); + registry.fill(HIST("Tracks/Control/TrackCount"), 4); + if (track.collisionId() == retrack.bestCollisionId()) { + registry.fill(HIST("Tracks/Control/TrackCount"), 6); + } + uniqueEvents.insert(retrack.bestCollisionId()); + } + if (midtracks.size() > 0 && retrack.ambDegree() == 1 && retrack.ambDegree() != 0) { + uniqueCollisions.insert(collision.globalIndex()); + } + if ((retrack.ambDegree() > 1) || (retrack.ambDegree() <= 1)) + registry.fill(HIST("Tracks/Control/TrackCount"), 7); + if (retrack.ambDegree() != 0) { + registry.fill(HIST("Tracks/Control/woOrp/woOrpTracksEtaZvtx"), + track.eta(), z); + registry.fill(HIST("Tracks/Control/woOrp/woOrpTracksPhiEta"), phi, + track.eta()); + registry.fill(HIST("Tracks/Control/woOrp/woOrpVertexCorr"), + track.collision_as().posZ(), z); + registry.fill(HIST("Tracks/Control/TrackCount"), 9); // without orphan + } + } + } + registry.fill(HIST("ambEventCounts"), 1, uniqueEventsAmb.size()); + registry.fill(HIST("NonambEventCounts"), 1, uniqueEvents.size()); + registry.fill(HIST("hNumCollisionsNonAmb_InelMFT"), 1, uniqueCollisions.size()); + registry.fill(HIST("hNumCollisionsAmb_InelMFT"), 1, uniqueCollisionsAmb.size()); + registry.fill(HIST("hNumCollisions_InelMFT"), 1, eventsInelMFT.size()); + } + registry.fill(HIST("Tracks/Control/amb/nTrkAmb"), i); + registry.fill(HIST("Tracks/Control/nonamb/nTrkNonAmb"), j); + registry.fill(HIST("Tracks/Control/woOrp/nTrk"), k); + registry.fill(HIST("hNumCollisions_Inel"), 1, eventsInel.size()); + } + } else { + registry.fill(HIST("EventSelection"), 7); + } + } + PROCESS_SWITCH(PseudorapidityDensityMFT, processMultReassoc, + "Process reco or data info", false); + + using ExColsCent = soa::Join; + + void processCountingCentrality(ExColsCent::iterator const& collision, + aod::MFTTracks const& tracks) + { + auto c = collision.centFT0C(); + registry.fill(HIST("Events/Centrality/Selection"), 1., c); + + if (!useEvSel || collision.sel8()) { + auto z = collision.posZ(); + registry.fill(HIST("Events/Centrality/Selection"), 2., c); + auto perCollisionSample = sample->sliceByCached( + o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); + auto Ntrk = perCollisionSample.size(); + + registry.fill(HIST("Events/Centrality/NtrkZvtx"), Ntrk, z, c); + + for (const auto& track : tracks) { + + float phi = track.phi(); + o2::math_utils::bringTo02Pi(phi); + + if (usePhiCut) { + if ((phi < cfgPhiCut) || + ((phi > o2::constants::math::PI - cfgPhiCut) && (phi < o2::constants::math::PI + cfgPhiCut)) || + (phi > o2::constants::math::TwoPI - cfgPhiCut) || + ((phi > ((o2::constants::math::PIHalf - 0.1) * o2::constants::math::PI) - cfgPhiCut) && + (phi < ((o2::constants::math::PIHalf - 0.1) * o2::constants::math::PI) + cfgPhiCut))) + continue; + } + + registry.fill(HIST("Tracks/Centrality/EtaZvtx"), track.eta(), z, c); + registry.fill(HIST("Tracks/Centrality/PhiEta"), phi, track.eta(), c); + } + + } else { + registry.fill(HIST("Events/Centrality/Selection"), 3., + c); // rejected events + } + } + + PROCESS_SWITCH(PseudorapidityDensityMFT, processCountingCentrality, + "Count tracks in centrality bins", false); + + using Particles = soa::Filtered; + expressions::Filter primaries = + (aod::mcparticle::flags & + (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary) == + (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary; + Partition mcSample = nabs(aod::mcparticle::eta) < 1.1f; + Partition mcSampleCentral = + nabs(aod::mcparticle::eta) < estimatorEta; + + void processGen( + aod::McCollisions::iterator const& mcCollision, + o2::soa::SmallGroups> const& collisions, + Particles const& particles, aod::MFTTracks const& /*tracks*/, + FiCentralTracks const& midtracks) + { + registry.fill(HIST("EventEfficiency"), 1.); + + auto perCollisionMCSample = mcSample->sliceByCached( + aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + auto nCharged = 0; + for (const auto& particle : perCollisionMCSample) { + auto charge = 0.; + auto p = pdg->GetParticle(particle.pdgCode()); + if (p != nullptr) { + charge = p->Charge(); + } + if (std::abs(charge) < 3.) { + continue; + } + nCharged++; + } + registry.fill(HIST("EventsNtrkZvtxGen_t"), nCharged, mcCollision.posZ()); + + //--------for INEL>0 + auto perCollisionMCSampleCentral = mcSampleCentral->sliceByCached( + aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + auto nChargedCentral = 0; + for (const auto& particle : perCollisionMCSample) { + auto charge = 0.; + auto p = pdg->GetParticle(particle.pdgCode()); + if (p != nullptr) { + charge = p->Charge(); + } + if (std::abs(charge) < 3.) { + continue; + } + nChargedCentral++; + } + if ((mcCollision.posZ() >= cfgVzCut1) && (mcCollision.posZ() <= cfgVzCut2)) { + if (nChargedCentral > 0) { + registry.fill(HIST("EventEfficiency"), 2.); + registry.fill(HIST("EventsNtrkZvtxGen_gt0t"), nCharged, + mcCollision.posZ()); + } + } + //----------- + bool atLeastOne = false; + bool atLeastOne_gt0 = false; + int moreThanOne = 0; + + LOGP(debug, "MC col {} has {} reco cols", mcCollision.globalIndex(), + collisions.size()); + for (const auto& collision : collisions) { + registry.fill(HIST("EventEfficiency"), 3.); + if (!disableITSROFCut && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return; + } + if (!useEvSel || (useEvSel && collision.selection_bit(aod::evsel::kIsTriggerTVX) && collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && collision.selection_bit(aod::evsel::kNoSameBunchPileup))) { + atLeastOne = true; + auto perCollisionSample = sample->sliceByCached( + o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); + + registry.fill(HIST("EventEfficiency"), 4.); + + auto perCollisionSampleCentral = + midtracks.sliceBy(perColCentral, collision.globalIndex()); + if ((collision.posZ() >= cfgVzCut1) && (collision.posZ() <= cfgVzCut2) && (mcCollision.posZ() >= cfgVzCut1) && (mcCollision.posZ() <= cfgVzCut2)) { + if (perCollisionSampleCentral.size() > 0) { + registry.fill(HIST("EventEfficiency"), 5.); + atLeastOne_gt0 = true; + registry.fill(HIST("EventsNtrkZvtxGen_gt0"), + perCollisionSample.size(), collision.posZ()); + } + + registry.fill(HIST("EventsZposDiff"), + collision.posZ() - mcCollision.posZ()); + if (useZDiffCut) { + if (std::abs(collision.posZ() - mcCollision.posZ()) > maxZDiff) { + continue; + } + } + registry.fill(HIST("EventsNtrkZvtxGen"), perCollisionSample.size(), + collision.posZ()); + ++moreThanOne; + } + } + } + if (collisions.size() == 0) { + registry.fill(HIST("NotFoundEventZvtx"), mcCollision.posZ()); + } + if (moreThanOne > 1) { + registry.fill(HIST("EventsSplitMult"), nCharged); + } + if ((mcCollision.posZ() >= cfgVzCut1) && (mcCollision.posZ() <= cfgVzCut2)) { + for (const auto& particle : particles) { + auto p = pdg->GetParticle(particle.pdgCode()); + auto charge = 0; + if (p != nullptr) { + charge = static_cast(p->Charge()); + } + if (std::abs(charge) < 3.) { + continue; + } + float phi = particle.phi(); + o2::math_utils::bringTo02Pi(phi); + if (usePhiCut) { + if ((phi <= 0.02) || ((phi >= 3.10) && (phi <= 3.23)) || (phi >= 6.21)) + continue; + } + if (cfgnEta1 < particle.eta() && particle.eta() < cfgnEta2 && (phi > cfgPhiCut1 && phi < cfgPhiCut2)) { + registry.fill(HIST("TracksEtaZvtxGen_t"), particle.eta(), + mcCollision.posZ()); + if (perCollisionMCSampleCentral.size() > 0) { + registry.fill(HIST("TracksEtaZvtxGen_gt0t"), particle.eta(), + mcCollision.posZ()); + registry.fill(HIST("TracksPhiEtaGen_gt0t"), particle.phi(), particle.eta()); + } + if (atLeastOne) { + registry.fill(HIST("TracksEtaZvtxGen"), particle.eta(), + mcCollision.posZ()); + registry.fill(HIST("TracksPtEtaGen"), particle.pt(), particle.eta()); + if (atLeastOne_gt0) { + registry.fill(HIST("TracksEtaZvtxGen_gt0"), particle.eta(), + mcCollision.posZ()); + registry.fill(HIST("TracksPhiEtaGen_gt0"), particle.phi(), particle.eta()); + } + } + + registry.fill(HIST("TracksPhiEtaGen"), particle.phi(), particle.eta()); + registry.fill(HIST("TracksPhiZvtxGen"), particle.phi(), + mcCollision.posZ()); + registry.fill(HIST("TracksPtEtaGen_t"), particle.pt(), particle.eta()); + } + } + } + } + + PROCESS_SWITCH(PseudorapidityDensityMFT, processGen, + "Process generator-level info", false); + + using ExColsGenCent = + soa::SmallGroups>; + + void processGenCent(aod::McCollisions::iterator const& mcCollision, + ExColsGenCent const& collisions, + Particles const& particles, + MFTTracksLabeled const& /*tracks*/) + { + + LOGP(debug, "MC col {} has {} reco cols", mcCollision.globalIndex(), + collisions.size()); + + float c_gen = -1; + bool atLeastOne = false; + for (const auto& collision : collisions) { + float c_rec = -1; + if constexpr (ExColsGenCent::template contains()) { + c_rec = collision.centFT0C(); + } + if (!useEvSel || (useEvSel && collision.sel8())) { + if constexpr (ExColsGenCent::template contains()) { + if (!atLeastOne) { + c_gen = c_rec; + } + } + atLeastOne = true; + + registry.fill(HIST("Events/Centrality/EventEfficiency"), 2., c_gen); + registry.fill(HIST("Events/Centrality/CentPercentileMCGen"), c_gen); + + auto perCollisionSample = sample->sliceByCached( + o2::aod::fwdtrack::collisionId, collision.globalIndex(), cache); + registry.fill(HIST("Events/Centrality/NtrkZvtxGen"), + perCollisionSample.size(), collision.posZ(), c_gen); + } + } + + registry.fill(HIST("Events/Centrality/EventEfficiency"), 1., c_gen); + + auto perCollisionMCSample = mcSample->sliceByCached( + aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + auto nCharged = 0; + + for (const auto& particle : perCollisionMCSample) { + auto p = pdg->GetParticle(particle.pdgCode()); + auto charge = 0; + if (p != nullptr) { + charge = static_cast(p->Charge()); + } + if (std::abs(charge) < 3.) { + continue; + } + nCharged++; + } + + if constexpr (ExColsGenCent::template contains()) { + registry.fill(HIST("Events/Centrality/NtrkZvtxGen_t"), nCharged, + mcCollision.posZ(), c_gen); + } + + for (const auto& particle : particles) { + auto p = pdg->GetParticle(particle.pdgCode()); + auto charge = 0; + if (p != nullptr) { + charge = static_cast(p->Charge()); + } + if (std::abs(charge) < 3.) { + continue; + } + + if constexpr (ExColsGenCent::template contains()) { + registry.fill(HIST("Tracks/Centrality/EtaZvtxGen_t"), particle.eta(), + mcCollision.posZ(), c_gen); + } + + if (atLeastOne) { + if constexpr (ExColsGenCent::template contains()) { + registry.fill(HIST("Tracks/Centrality/EtaZvtxGen"), particle.eta(), + mcCollision.posZ(), c_gen); + float phi = particle.phi(); + o2::math_utils::bringTo02Pi(phi); + registry.fill(HIST("Tracks/Centrality/PhiEtaGen"), phi, + particle.eta(), c_gen); + } + } + } + } + + PROCESS_SWITCH(PseudorapidityDensityMFT, processGenCent, + "Process generator-level info in centrality bins", false); + + void processGenPt( + soa::Join::iterator const& collision, + MFTTracksLabeled const& tracks, aod::McParticles const&) + { + if (!useEvSel || (useEvSel && collision.sel8())) { + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + auto particle = track.mcParticle(); + if (!particle.isPhysicalPrimary()) { + continue; + } + registry.fill(HIST("TracksToPartPtEta"), particle.pt(), particle.eta()); + } + } + } + + PROCESS_SWITCH(PseudorapidityDensityMFT, processGenPt, + "Process particle-level info of pt", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/GlobalEventProperties/flattenictyPikp.cxx b/PWGLF/Tasks/GlobalEventProperties/flattenictyPikp.cxx new file mode 100644 index 00000000000..101898b826d --- /dev/null +++ b/PWGLF/Tasks/GlobalEventProperties/flattenictyPikp.cxx @@ -0,0 +1,2055 @@ +// Copyright 2020-2022 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. + +/// \file flattenictyPikp.cxx +/// \author Gyula Bencedi, gyula.bencedi@cern.ch +/// \brief Task to produce pion, kaon, proton high-pT +/// distributions as a function of charged-particle flattenicity +/// \since 26 June 2025 + +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/mcCentrality.h" +#include "PWGLF/Utils/inelGt.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/McCollisionExtra.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/MathConstants.h" +#include "DataFormatsFIT/Triggers.h" +#include "DetectorsCommonDataFormats/AlignParam.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/StaticFor.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/PID.h" +#include "ReconstructionDataFormats/Track.h" +#include +#include +#include + +#include "TEfficiency.h" +#include "THashList.h" +#include "TPDGCode.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::constants::math; + +auto static constexpr kMinCharge = 3.f; +// FV0 specific constants +static constexpr int kMaxRingsFV0 = 5; +static constexpr int kNCellsFV0 = 48; +static constexpr int kInnerFV0 = 32; +static constexpr float kFV0IndexPhi[5] = {0., 8., 16., 24., 32.}; +static constexpr float kEtaMaxFV0 = 5.1; +static constexpr float kEtaMinFV0 = 2.2; +static constexpr float kDEtaFV0 = (kEtaMaxFV0 - kEtaMinFV0) / kMaxRingsFV0; +// PID names +static constexpr int kProcessIdWeak = 4; +static constexpr int Ncharges = 2; +static constexpr o2::track::PID::ID Npart = 5; +static constexpr o2::track::PID::ID NpartChrg = Npart * Ncharges; +static constexpr int PDGs[] = {11, 13, 211, 321, 2212}; +static constexpr int PidSgn[NpartChrg] = {11, 13, 211, 321, 2212, -11, -13, -211, -321, -2212}; +static constexpr const char* Pid[Npart] = {"el", "mu", "pi", "ka", "pr"}; +static constexpr const char* PidChrg[NpartChrg] = {"e^{-}", "#mu^{-}", "#pi^{+}", "K^{+}", "p", "e^{+}", "#mu^{+}", "#pi^{-}", "K^{-}", "#bar{p}"}; +static constexpr std::string_view kSpecies[NpartChrg] = {"Elminus", "Muplus", "PiPlus", "KaPlus", "Pr", "ElPlus", "MuMinus", "PiMinus", "KaMinus", "PrBar"}; +static constexpr std::string_view kSpeciesAll[Npart] = {"El", "Mu", "Pi", "Ka", "Pr"}; +// histogram naming +static constexpr std::string_view kCharge[] = {"all/", "pos/", "neg/"}; +static constexpr std::string_view kPrefix = "Tracks/"; +static constexpr std::string_view kPrefixCleanTof = "Tracks/CleanTof/"; +static constexpr std::string_view kPrefixCleanV0 = "Tracks/CleanV0/"; +static constexpr std::string_view kStatus[] = {"preSel/", "postSel/"}; +static constexpr std::string_view kStatCalib[] = {"preCalib/", "postCalib/"}; +static constexpr std::string_view kPtGenPrimSgn = "/hPtGenPrimSgn"; +static constexpr std::string_view kPtGenPrimSgnF = "Tracks/{}/hPtGenPrimSgn"; +static constexpr std::string_view kPtGenPrimSgnINEL = "/hPtGenPrimSgnINEL"; +static constexpr std::string_view kPtGenPrimSgnINELF = "Tracks/{}/hPtGenPrimSgnINEL"; +static constexpr std::string_view kPtRecCollPrimSgn = "/hPtRecCollPrimSgn"; +static constexpr std::string_view kPtRecCollPrimSgnF = "Tracks/{}/hPtRecCollPrimSgn"; +static constexpr std::string_view kPtRecCollPrimSgnINEL = "/hPtRecCollPrimSgnINEL"; +static constexpr std::string_view kPtRecCollPrimSgnINELF = "Tracks/{}/hPtRecCollPrimSgnINEL"; +static constexpr std::string_view kPtGenRecCollPrimSgn = "/hPtGenRecCollPrimSgn"; +static constexpr std::string_view kPtGenRecCollPrimSgnF = "Tracks/{}/hPtGenRecCollPrimSgn"; +static constexpr std::string_view kPtGenRecCollPrimSgnINEL = "/hPtGenRecCollPrimSgnINEL"; +static constexpr std::string_view kPtGenRecCollPrimSgnINELF = "Tracks/{}/hPtGenRecCollPrimSgnINEL"; +static constexpr std::string_view kPtMCclosurePrim = "/hPtMCclosurePrim"; +static constexpr std::string_view kPtMCclosurePrimF = "Tracks/{}/hPtMCclosurePrim"; + +enum V0sSel { + kNaN = -1, + kGa = 0, + kKz = 1, + kLam = 2, + kaLam = 3 +}; + +enum TrkSelNoFilt { + trkSelEta, + trkSelPt, + trkSelDCA, + trkNRowsTPC, + trkSelNCls, + trkSelTPCBndr, + nTrkSel +}; + +enum EvtSel { + evtSelAll, + evtSelSel8, + evtSelNoITSROFrameBorder, + evtSelkNoTimeFrameBorder, + evtSelkNoSameBunchPileup, + evtSelkIsGoodZvtxFT0vsPV, + evtSelkIsVertexITSTPC, + evtSelkIsVertexTOFmatched, + evtSelVtxZ, + evtSelINELgt0, + nEvtSel +}; + +enum FillType { + kBefore, + kAfter +}; + +enum ChargeType { + kAll, + kPos, + kNeg +}; + +struct MultE { + static constexpr int kNoMult = 0; + static constexpr int kMultFT0M = 1; + static constexpr int kMultTPC = 2; +}; + +std::array rhoLatticeFV0{0}; +std::array fv0AmplitudeWoCalib{0}; + +std::array, NpartChrg> hPtEffRecPrim{}; +std::array, NpartChrg> hPtEffRecWeak{}; +std::array, NpartChrg> hPtEffRecMat{}; +std::array, NpartChrg> hPtEffRec{}; +std::array, NpartChrg> hPtEffGen{}; +std::array, NpartChrg> hPtGenRecEvt{}; +std::array, NpartChrg> hPtGenPrimRecEvt{}; +std::array, NpartChrg> hPtEffGenPrim{}; +std::array, NpartChrg> hPtEffGenWeak{}; +std::array, NpartChrg> hPtEffGenMat{}; +std::array, NpartChrg> hPtVsDCAxyPrim{}; +std::array, NpartChrg> hPtVsDCAxyWeak{}; +std::array, NpartChrg> hPtVsDCAxyMat{}; +std::array, NpartChrg> hDCAxyBadCollPrim{}; +std::array, NpartChrg> hDCAxyBadCollWeak{}; +std::array, NpartChrg> hDCAxyBadCollMat{}; +std::array, NpartChrg> hPtNsigmaTPC{}; +std::array, NpartChrg> hThPtNsigmaTPC{}; +std::array, NpartChrg> hPtNsigmaTOF{}; +std::array, NpartChrg> hPtNsigmaTPCTOF{}; + +struct FlattenictyPikp { + + HistogramRegistry flatchrg{"flatchrg", {}, OutputObjHandlingPolicy::AnalysisObject, true, false}; + OutputObj listEfficiency{"Efficiency"}; + Service pdg; + + std::vector fv0AmplCorr{}; + TProfile2D* zVtxMap = nullptr; + int runNumber{-1}; + + Configurable multEst{"multEst", 1, "0: without multiplicity; 1: MultFT0M; 2: MultTPC"}; + Configurable applyCalibGain{"applyCalibGain", false, "equalize detector amplitudes"}; + Configurable applyCalibVtx{"applyCalibVtx", false, "equalize Amp vs vtx"}; + Configurable applyCalibDeDx{"applyCalibDeDx", false, "calibration of dedx signal"}; + Configurable cfgFillTrackQaHist{"cfgFillTrackQaHist", false, "fill track QA histograms"}; + Configurable cfgFilldEdxCalibHist{"cfgFilldEdxCalibHist", false, "fill dEdx calibration histograms"}; + Configurable cfgFilldEdxQaHist{"cfgFilldEdxQaHist", false, "fill dEdx QA histograms"}; + Configurable cfgFillNsigmaQAHist{"cfgFillNsigmaQAHist", false, "fill nsigma QA histograms"}; + Configurable cfgFillV0Hist{"cfgFillV0Hist", false, "fill V0 histograms"}; + Configurable cfgFillChrgType{"cfgFillChrgType", false, "fill histograms per charge types"}; + Configurable> paramsFuncMIPpos{"paramsFuncMIPpos", std::vector{-1.f}, "parameters of pol2"}; + Configurable> paramsFuncMIPneg{"paramsFuncMIPneg", std::vector{-1.f}, "parameters of pol2"}; + Configurable> paramsFuncMIPall{"paramsFuncMIPall", std::vector{-1.f}, "parameters of pol2"}; + Configurable cfgGainEqCcdbPath{"cfgGainEqCcdbPath", "Users/g/gbencedi/flattenicity/GainEq", "CCDB path for gain equalization constants"}; + Configurable cfgVtxEqCcdbPath{"cfgVtxEqCcdbPath", "Users/g/gbencedi/flattenicity/ZvtxEq", "CCDB path for z-vertex equalization constants"}; + Configurable cfgUseCcdbForRun{"cfgUseCcdbForRun", true, "Get ccdb object based on run number instead of timestamp"}; + Configurable cfgStoreThnSparse{"cfgStoreThnSparse", false, "Store histograms as THnSparse"}; + + struct : ConfigurableGroup { + Configurable cfgCustomTVX{"cfgCustomTVX", false, "Ask for custom TVX instead of sel8"}; + Configurable cfgRemoveNoTimeFrameBorder{"cfgRemoveNoTimeFrameBorder", true, "Bunch crossing is far from Time Frame borders"}; + Configurable cfgRemoveITSROFrameBorder{"cfgRemoveITSROFrameBorder", true, "Bunch crossing is far from ITS RO Frame border"}; + Configurable cfgCutVtxZ{"cfgCutVtxZ", 10.0f, "Accepted z-vertex range"}; + Configurable cfgINELCut{"cfgINELCut", true, "INEL event selection"}; + Configurable cfgRemoveNoSameBunchPileup{"cfgRemoveNoSameBunchPileup", false, "Reject collisions in case of pileup with another collision in the same foundBC"}; + Configurable cfgRequireIsGoodZvtxFT0vsPV{"cfgRequireIsGoodZvtxFT0vsPV", false, "Small difference between z-vertex from PV and from FT0"}; + Configurable cfgRequireIsVertexITSTPC{"cfgRequireIsVertexITSTPC", false, "At least one ITS-TPC track (reject vertices built from ITS-only tracks)"}; + Configurable cfgRequirekIsVertexTOFmatched{"cfgRequirekIsVertexTOFmatched", false, "Require kIsVertexTOFmatched: at least one of vertex contributors is matched to TOF"}; + } evtSelOpt; + + struct : ConfigurableGroup { + Configurable useFlatData{"useFlatData", true, "use flattenicity from rec collisions"}; + } flatSelOpt; + + struct : ConfigurableGroup { + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 20.0}, "pT binning"}; + ConfigurableAxis axisFlatPerc{"axisFlatPerc", {102, -0.01, 1.01}, "Flattenicity percentiles binning"}; + ConfigurableAxis axisMultPerc{"axisMultPerc", {20, 0, 100}, "Multiplicity percentiles binning"}; + ConfigurableAxis axisVertexZ{"axisVertexZ", {80, -20., 20.}, "Vertex z binning"}; + ConfigurableAxis axisMult{"axisMult", {301, -0.5, 300.5}, "Multiplicity binning"}; + ConfigurableAxis axisDCAxy{"axisDCAxy", {200, -5, 5}, "DCAxy binning"}; + ConfigurableAxis axisDCAz{"axisDCAz", {200, -5, 5}, "DCAz binning"}; + ConfigurableAxis axisPhi = {"axisPhi", {60, 0, constants::math::TwoPI}, "#varphi binning"}; + ConfigurableAxis axisPhiMod = {"axisPhiMod", {100, 0, constants::math::PI / 9}, "fmod(#varphi,#pi/9)"}; + ConfigurableAxis axisEta = {"axisEta", {8, -0.8, 0.8}, "#eta binning"}; + ConfigurableAxis axisDedx{"axisDedx", {100, 0, 100}, "dE/dx binning"}; + ConfigurableAxis axisNsigmaTPC{"axisNsigmaTPC", {200, -10, 10}, "nsigmaTPC binning"}; + ConfigurableAxis axisNsigmaTOF{"axisNsigmaTOF", {200, -10, 10}, "nsigmaTOF binning"}; + ConfigurableAxis axisAmplFV0{"axsAmplFV0", {4096, 0, 4096}, "FV0 amplitude (ADC) binning"}; + ConfigurableAxis axisAmplFV0Sum{"axisAmplFV0Sum", {4096, 0, 4096 * 49}, "FV0 amplitude sum (ADC) binning"}; + ConfigurableAxis axisChannelFV0{"axisChannelFV0", {49, 0., 49.}, "FV0 channel ID binning"}; + } binOpt; + + struct : ConfigurableGroup { + Configurable cfgTrkEtaMax{"cfgTrkEtaMax", 0.8f, "Eta range for tracks"}; + Configurable cfgRapMax{"cfgRapMax", 0.5f, "Maximum range of rapidity for tracks"}; + Configurable cfgTrkPtMin{"cfgTrkPtMin", 0.15f, "Minimum pT of tracks"}; + Configurable cfgNclTPCMin{"cfgNclTPCMin", 100.0f, "Minimum of number of TPC clusters"}; + Configurable cfgPhiCutPtMin{"cfgPhiCutPtMin", 2.0f, "Minimum pT for phi cut"}; + Configurable cfgTOFBetaPion{"cfgTOFBetaPion", 1.0f, "Minimum beta for TOF pions"}; + Configurable cfgUseExtraTrkCut{"cfgUseExtraTrkCut", true, "Use extra track cut"}; + Configurable cfgGeoTrkCutMin{"cfgGeoTrkCutMin", "0.06/x+pi/18.0-0.06", "ROOT TF1 formula for minimum phi cut in TPC"}; + Configurable cfgGeoTrkCutMax{"cfgGeoTrkCutMax", "0.1/x+pi/18.0+0.06", "ROOT TF1 formula for maximum phi cut in TPC"}; + Configurable cfgMomMIPMax{"cfgMomMIPMax", 0.6f, "Maximum momentum of MIP pions"}; + Configurable cfgMomMIPMin{"cfgMomMIPMin", 0.4f, "Minimum momentum of MIP pions"}; + Configurable cfgDeDxMIPMax{"cfgDeDxMIPMax", 60.0f, "Maximum range of MIP dedx"}; + Configurable cfgDeDxMIPMin{"cfgDeDxMIPMin", 40.0f, "Maximum range of MIP dedx"}; + Configurable cfgNsigmaMax{"cfgNsigmaMax", 100.0f, "Maximum range of nsgima for tracks"}; + Configurable cfgMomSelPiTOF{"cfgMomSelPiTOF", 0.7f, "Momentum cut for TOF pions"}; + Configurable cfgNsigSelKaTOF{"cfgNsigSelKaTOF", 3.0f, "Nsigma cut for TOF kaons"}; + Configurable cfgBetaPlateuMax{"cfgBetaPlateuMax", 0.1f, "Beta max for Plateau electrons"}; + } trkSelOpt; + + struct : ConfigurableGroup { + Configurable cfgDCAv0daughter{"cfgDCAv0daughter", 0.3, "DCA of V0 daughter tracks"}; + Configurable cfgV0etamax{"cfgV0etamax", 0.9f, "max eta of V0s"}; + Configurable cfgV0DaughterTpcMomMax{"cfgV0DaughterTpcMomMax", 0.6f, "Maximum momentum of V0 daughter tracks in TPC"}; + Configurable cfgTPCnClsmin{"cfgTPCnClsmin", 50.0f, "cfgTPCnClsmin"}; + Configurable cfgDCAposToPV{"cfgDCAposToPV", 0.05f, "cfgDCAposToPV"}; + Configurable cfgv0cospa{"cfgv0cospa", 0.998, "V0 CosPA"}; + Configurable cfgv0Rmin{"cfgv0Rmin", 0.0, "cfgv0Rmin"}; + Configurable cfgv0Rmax{"cfgv0Rmax", 90.0, "cfgv0Rmax"}; + Configurable cfgdmassG{"cfgdmassG", 0.1, "max mass for photon"}; + Configurable cfgdmassK{"cfgdmassK", 0.1, "max mass for K0s"}; + Configurable cfgdmassL{"cfgdmassL", 0.1, "max mass for Lambda"}; + Configurable cfgdmassAL{"cfgdmassAL", 0.1, "max mass for anti Lambda"}; + Configurable cfgNsigmaElTPC{"cfgNsigmaElTPC", 5.0, "max nsigma of TPC for electorn"}; + Configurable cfgNsigmaPiTPC{"cfgNsigmaPiTPC", 5.0, "max nsigma of TPC for pion"}; + Configurable cfgNsigmaPrTPC{"cfgNsigmaPrTPC", 5.0, "max nsigma of TPC for proton"}; + Configurable cfgNsigmaElTOF{"cfgNsigmaElTOF", 3.0, "max nsigma of TOF for electorn"}; + Configurable cfgNsigmaPiTOF{"cfgNsigmaPiTOF", 3.0, "max nsigma of TOF for pion"}; + Configurable cfgNsigmaPrTOF{"cfgNsigmaPrTOF", 3.0, "max nsigma of TOF for proton"}; + } v0SelOpt; + + Service ccdb; + struct : ConfigurableGroup { + Configurable cfgMagField{"cfgMagField", 99999, "Configurable magnetic field;default CCDB will be queried"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + } ccdbConf; + + TrackSelection mTrackSelector; + Configurable isCustomTracks{"isCustomTracks", false, "Use custom track cuts"}; + Configurable requirePt{"requirePt", 0.15f, "Set minimum pT of tracks"}; + Configurable requireEta{"requireEta", 0.8f, "Set eta range of tracks"}; + Configurable setITSreq{"setITSreq", 1, "0 = Run3ITSibAny, 1 = Run3ITSallAny, 2 = Run3ITSall7Layers, 3 = Run3ITSibTwo"}; + Configurable requireITS{"requireITS", true, "Additional cut on the ITS requirement"}; + Configurable requireTPC{"requireTPC", true, "Additional cut on the TPC requirement"}; + Configurable requireGoldenChi2{"requireGoldenChi2", true, "Additional cut on the GoldenChi2"}; + Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 70.f, "Additional cut on the minimum number of crossed rows in the TPC"}; + Configurable minNCrossedRowsOverFindableClustersTPC{"minNCrossedRowsOverFindableClustersTPC", 0.8f, "Additional cut on the minimum value of the ratio between crossed rows and findable clusters in the TPC"}; + Configurable maxChi2PerClusterTPC{"maxChi2PerClusterTPC", 4.f, "Additional cut on the maximum value of the chi2 per cluster in the TPC"}; + Configurable maxChi2PerClusterITS{"maxChi2PerClusterITS", 36.f, "Additional cut on the maximum value of the chi2 per cluster in the ITS"}; + Configurable minITSnClusters{"minITSnClusters", 5, "minimum number of found ITS clusters"}; + Configurable maxDcaXYFactor{"maxDcaXYFactor", 1.f, "Multiplicative factor on the maximum value of the DCA xy"}; + Configurable maxDcaZ{"maxDcaZ", 2.f, "Additional cut on the maximum value of the DCA z"}; + Configurable minTPCNClsFound{"minTPCNClsFound", 70.0f, "Additional cut on the minimum value of the number of found clusters in the TPC"}; + + TF1* fPhiCutLow = nullptr; + TF1* fPhiCutHigh = nullptr; + + std::vector> fDeDxVsEta; + std::vector> vecParams; + + void init(InitContext&) + { + auto vecParamsMIPpos = (std::vector)paramsFuncMIPpos; + auto vecParamsMIPneg = (std::vector)paramsFuncMIPneg; + auto vecParamsMIPall = (std::vector)paramsFuncMIPall; + + auto addVec = [&](std::vector>& targetVec, const std::string& name) { + targetVec.emplace_back(vecParamsMIPpos); + targetVec.emplace_back(vecParamsMIPneg); + targetVec.emplace_back(vecParamsMIPall); + if (!vecParams.size()) { + LOG(info) << "size of " << name << "is zero."; + } + }; + addVec(vecParams, "vecParams"); + for (const auto& params : vecParams) { + fDeDxVsEta.emplace_back(setFuncPars(params)); + } + + ccdb->setURL(ccdbConf.ccdbUrl.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + ccdb->setFatalWhenNull(false); + + if (isCustomTracks.value) { + mTrackSelector = getGlobalTrackSelectionRun3ITSMatch(setITSreq.value); + mTrackSelector.SetPtRange(requirePt.value, 1e10f); + mTrackSelector.SetEtaRange(-requireEta.value, requireEta.value); + mTrackSelector.SetRequireITSRefit(requireITS.value); + mTrackSelector.SetRequireTPCRefit(requireTPC.value); + mTrackSelector.SetRequireGoldenChi2(requireGoldenChi2.value); + mTrackSelector.SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC.value); + mTrackSelector.SetMaxChi2PerClusterITS(maxChi2PerClusterITS.value); + mTrackSelector.SetMinNClustersITS(minITSnClusters.value); + mTrackSelector.SetMinNCrossedRowsTPC(minNCrossedRowsTPC.value); + mTrackSelector.SetMinNClustersTPC(minTPCNClsFound.value); + mTrackSelector.SetMinNCrossedRowsOverFindableClustersTPC(minNCrossedRowsOverFindableClustersTPC.value); + // // mTrackSelector.SetMaxDcaXYPtDep([](float pt) { return 0.0105f + 0.0350f / pow(pt, 1.1f); }); + mTrackSelector.SetMaxDcaXYPtDep([](float /*pt*/) { return 10000.f; }); + mTrackSelector.SetMaxDcaZ(maxDcaZ.value); + mTrackSelector.print(); + } + + const AxisSpec chargeAxis{2, -2.f, 2.f, "Charge"}; + const AxisSpec dEdxAxis{binOpt.axisDedx, "TPC dEdx (a.u.)"}; + const AxisSpec vtxzAxis{binOpt.axisVertexZ, "Z_{vtx} (cm)"}; + const AxisSpec flatAxis{binOpt.axisFlatPerc, "Flat FV0"}; + const AxisSpec etaAxis{binOpt.axisEta, "#eta"}; + const AxisSpec phiAxis{binOpt.axisPhi, "#varphi"}; + const AxisSpec phiAxisMod{binOpt.axisPhiMod, "fmod(#varphi,#pi/9)"}; + const AxisSpec pAxis{binOpt.axisPt, "#it{p} (GeV/#it{c})"}; + const AxisSpec ptAxis{binOpt.axisPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec dcaXYAxis{binOpt.axisDCAxy, "DCA_{xy} (cm)"}; + const AxisSpec dcaZAxis{binOpt.axisDCAz, "DCA_{z} (cm)"}; + const AxisSpec shCluserAxis{200, 0, 1, "Fraction of shared TPC clusters"}; + const AxisSpec clTpcAxis{160, 0, 160, "Number of clusters in TPC"}; + const AxisSpec nSigmaTPCAxis{binOpt.axisNsigmaTPC, "n#sigma_{TPC}"}; + const AxisSpec nSigmaTOFAxis{binOpt.axisNsigmaTOF, "n#sigma_{TOF}"}; + const AxisSpec amplitudeFV0{binOpt.axisAmplFV0, "FV0 amplitude (ADC)"}; + const AxisSpec amplitudeFV0Sum{binOpt.axisAmplFV0Sum, "FV0 amplitude sm (ADC)"}; + const AxisSpec channelFV0Axis{binOpt.axisChannelFV0, "FV0 channel ID"}; + + AxisSpec multAxis{binOpt.axisMultPerc, "multiplicity estimator"}; + + switch (multEst) { + case MultE::kNoMult: + break; + case MultE::kMultFT0M: + multAxis.name = "multFT0M"; + break; + case MultE::kMultTPC: + multAxis.name = "multTPC"; + break; + default: + LOG(fatal) << "No valid option for mult estimator " << multEst; + } + + // Event counter + flatchrg.add("Events/hEvtSel", "Number of events; Cut; #Events Passed Cut", {HistType::kTH1F, {{nEvtSel, 0, nEvtSel}}}); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelAll + 1, "Events read"); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelSel8 + 1, "Evt. sel8"); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelNoITSROFrameBorder + 1, "NoITSROFrameBorder"); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelkNoTimeFrameBorder + 1, "NoTimeFrameBorder"); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelkNoSameBunchPileup + 1, "NoSameBunchPileup"); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelkIsGoodZvtxFT0vsPV + 1, "IsGoodZvtxFT0vsPV"); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelkIsVertexITSTPC + 1, "IsVertexITSTPC"); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelkIsVertexTOFmatched + 1, "IsVertexTOFmatched"); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelVtxZ + 1, "Vtx-z pos"); + flatchrg.get(HIST("Events/hEvtSel"))->GetXaxis()->SetBinLabel(evtSelINELgt0 + 1, "INEL>0"); + // Track counter + flatchrg.add("Tracks/hTrkSel", "Number of tracks; Cut; #Tracks Passed Cut", {HistType::kTH1F, {{nTrkSel, 0, nTrkSel}}}); + flatchrg.get(HIST("Tracks/hTrkSel"))->GetXaxis()->SetBinLabel(trkSelEta + 1, "Eta"); + flatchrg.get(HIST("Tracks/hTrkSel"))->GetXaxis()->SetBinLabel(trkSelPt + 1, "Pt"); + flatchrg.get(HIST("Tracks/hTrkSel"))->GetXaxis()->SetBinLabel(trkSelDCA + 1, "DCA"); + flatchrg.get(HIST("Tracks/hTrkSel"))->GetXaxis()->SetBinLabel(trkNRowsTPC + 1, "trkNRowsTPC"); + flatchrg.get(HIST("Tracks/hTrkSel"))->GetXaxis()->SetBinLabel(trkSelNCls + 1, "NClsTPC"); + flatchrg.get(HIST("Tracks/hTrkSel"))->GetXaxis()->SetBinLabel(trkSelTPCBndr + 1, "TPC Boundary"); + + if (trkSelOpt.cfgUseExtraTrkCut) { + fPhiCutLow = new TF1("fPhiCutLow", trkSelOpt.cfgGeoTrkCutMin.value.c_str(), 0, 100); + fPhiCutHigh = new TF1("fPhiCutHigh", trkSelOpt.cfgGeoTrkCutMax.value.c_str(), 0, 100); + } + + if (doprocessFlat) { + flatchrg.add("Events/hVtxZ", "Measured vertex z position", HistType::kTH1F, {vtxzAxis}); + flatchrg.add("Events/hFlatVsMultEst", "hFlatVsMultEst", HistType::kTH2F, {flatAxis, multAxis}); + flatchrg.add("Tracks/postSel/hPVsPtEta", "; #it{p} (GeV/#it{c}); #it{p}_{T} (GeV/#it{c}); #eta;", {HistType::kTH3F, {pAxis, ptAxis, etaAxis}}); + if (cfgFillTrackQaHist || cfgFilldEdxQaHist || cfgFillNsigmaQAHist) { + if (cfgFillTrackQaHist) { + flatchrg.add("Tracks/postSel/hPtPhi", "; #it{p}_{T} (GeV/#it{c}); fmod(#varphi,#pi/9)", {HistType::kTH2F, {ptAxis, phiAxisMod}}); + flatchrg.add("Tracks/postSel/hPtVsWOcutDCA", "hPtVsWOcutDCA", HistType::kTH2F, {ptAxis, dcaXYAxis}); + flatchrg.add("Tracks/postSel/hPt", "", HistType::kTH1F, {ptAxis}); + flatchrg.add("Tracks/postSel/hPhi", "", HistType::kTH1F, {phiAxis}); + flatchrg.add("Tracks/postSel/hEta", "", HistType::kTH1F, {etaAxis}); + flatchrg.add("Tracks/postSel/hDCAXYvsPt", "", HistType::kTH2F, {ptAxis, dcaXYAxis}); + flatchrg.add("Tracks/postSel/hDCAZvsPt", "", HistType::kTH2F, {ptAxis, dcaZAxis}); + // tpc + if (cfgStoreThnSparse) { + flatchrg.add("Tracks/postSel/hPtPhiTPCCluster", "; #it{p}_{T} (GeV/#it{c}); fmod(#varphi,#pi/9); N_{cluster}", {HistType::kTHnSparseF, {ptAxis, phiAxisMod, clTpcAxis}}); + } else { + flatchrg.add("Tracks/postSel/hPtPhiTPCCluster", "; #it{p}_{T} (GeV/#it{c}); fmod(#varphi,#pi/9); N_{cluster}", {HistType::kTH2F, {ptAxis, phiAxisMod}}); + } + flatchrg.add("Tracks/postSel/hShTpcClvsPt", "", {HistType::kTH2F, {ptAxis, shCluserAxis}}); + flatchrg.add("Tracks/postSel/hCrossTPCvsPt", "", {HistType::kTH2F, {ptAxis, clTpcAxis}}); + flatchrg.add("Tracks/postSel/hTPCCluster", "N_{cluster}", HistType::kTH1F, {clTpcAxis}); + flatchrg.add("Tracks/postSel/tpcNClsShared", " ; # shared TPC clusters TPC", HistType::kTH1F, {{165, -0.5, 164.5}}); + flatchrg.add("Tracks/postSel/tpcCrossedRows", " ; # crossed TPC rows", HistType::kTH1F, {{165, -0.5, 164.5}}); + flatchrg.add("Tracks/postSel/tpcCrossedRowsOverFindableCls", " ; crossed rows / findable TPC clusters", HistType::kTH1F, {{60, 0.7, 1.3}}); + // its + flatchrg.add("Tracks/postSel/itsNCls", " ; # ITS clusters", HistType::kTH1F, {{8, -0.5, 7.5}}); + flatchrg.add("Tracks/postSel/hChi2ITSTrkSegment", "chi2ITS", HistType::kTH1F, {{100, -0.5, 99.5}}); + // tof + flatchrg.add("Tracks/postSel/hTOFPvsBeta", "Beta from TOF; #it{p} (GeV/#it{c}); #beta", {HistType::kTH2F, {pAxis, {120, 0.0, 1.2}}}); + if (cfgStoreThnSparse) { + flatchrg.add("Tracks/postSel/hTOFpi", "Primary Pions from TOF; #eta; #it{p} (GeV/#it{c}); dEdx", {HistType::kTHnSparseF, {etaAxis, pAxis, dEdxAxis}}); + } else { + flatchrg.add("Tracks/postSel/hTOFpi", "Primary Pions from TOF; #eta; #it{p} (GeV/#it{c}); dEdx", {HistType::kTH3F, {etaAxis, pAxis, dEdxAxis}}); + } + } + if (cfgFilldEdxQaHist) { + if (cfgStoreThnSparse) { + flatchrg.add("Tracks/postCalib/all/hMIP", "; mult; flat; #eta; #LT dE/dx #GT_{MIP, primary tracks};", {HistType::kTHnSparseF, {multAxis, flatAxis, etaAxis, dEdxAxis}}); + flatchrg.add("Tracks/postCalib/all/hPlateau", "; mult; flat; #eta; #LT dE/dx #GT_{Plateau, primary tracks};", {HistType::kTHnSparseF, {multAxis, flatAxis, etaAxis, dEdxAxis}}); + } else { + flatchrg.add("Tracks/postCalib/all/hMIP", "; #eta; #LT dE/dx #GT_{MIP, primary tracks};", {HistType::kTH2F, {etaAxis, dEdxAxis}}); + flatchrg.add("Tracks/postCalib/all/hPlateau", "; #eta; #LT dE/dx #GT_{Plateau, primary tracks};", {HistType::kTH2F, {etaAxis, dEdxAxis}}); + } + flatchrg.add("Tracks/postCalib/all/hMIPVsPhi", "; #varphi; #LT dE/dx #GT_{MIP, primary tracks};", {HistType::kTH2F, {phiAxis, dEdxAxis}}); + flatchrg.add("Tracks/postCalib/all/pMIPVsPhi", "; #varphi; #LT dE/dx #GT_{MIP, primary tracks};", {HistType::kTProfile, {phiAxis}}); + flatchrg.add("Tracks/postCalib/all/hMIPVsPhiVsEta", "; #varphi; #LT dE/dx #GT_{MIP, primary tracks}; #eta;", {HistType::kTH3F, {phiAxis, dEdxAxis, etaAxis}}); + flatchrg.add("Tracks/postCalib/all/hPlateauVsPhi", "; #varphi; #LT dE/dx #GT_{Plateau, primary tracks};", {HistType::kTH2F, {phiAxis, dEdxAxis}}); + flatchrg.add("Tracks/postCalib/all/pPlateauVsPhi", "; #varphi; #LT dE/dx #GT_{Plateau, primary tracks};", {HistType::kTProfile, {phiAxis}}); + flatchrg.add("Tracks/postCalib/all/hPlateauVsPhiVsEta", "; #varphi; #LT dE/dx #GT_{Plateau, primary tracks}; #eta;", {HistType::kTH3F, {phiAxis, dEdxAxis, etaAxis}}); + flatchrg.addClone("Tracks/postCalib/all/", "Tracks/preCalib/all/"); + if (cfgFillChrgType) { + flatchrg.addClone("Tracks/postCalib/all/", "Tracks/postCalib/pos/"); + flatchrg.addClone("Tracks/postCalib/all/", "Tracks/postCalib/neg/"); + flatchrg.addClone("Tracks/preCalib/all/", "Tracks/preCalib/pos/"); + flatchrg.addClone("Tracks/preCalib/all/", "Tracks/preCalib/neg/"); + } + } + if (cfgFillNsigmaQAHist) { + for (int i = 0; i < NpartChrg; i++) { + const std::string strID = Form("/%s/%s", (i < Npart) ? "pos" : "neg", Pid[i % Npart]); + if (cfgStoreThnSparse) { + hThPtNsigmaTPC[i] = flatchrg.add("Tracks/hThPtNsigmaTPC" + strID, " ; p_{T} (GeV/c)", HistType::kTHnSparseF, {ptAxis, nSigmaTPCAxis, multAxis, flatAxis}); + } else { + hPtNsigmaTPC[i] = flatchrg.add("Tracks/hPtNsigmaTPC" + strID, " ; p_{T} (GeV/c)", HistType::kTH2F, {ptAxis, nSigmaTPCAxis}); + } + hPtNsigmaTOF[i] = flatchrg.add("Tracks/hPtNsigmaTOF" + strID, " ; p_{T} (GeV/c)", HistType::kTH2F, {ptAxis, nSigmaTOFAxis}); + hPtNsigmaTPCTOF[i] = flatchrg.add("Tracks/hPtNsigmaTPCTOF" + strID, PidChrg[i], HistType::kTH2F, {nSigmaTPCAxis, nSigmaTOFAxis}); + } + } + } + flatchrg.addClone("Tracks/postSel/", "Tracks/preSel/"); + // FV0 QA + flatchrg.add("FV0/hFV0AmplWCalib", "", {HistType::kTH2F, {channelFV0Axis, amplitudeFV0}}); + flatchrg.add("FV0/hFV0AmplvsVtxzWoCalib", "", {HistType::kTH2F, {vtxzAxis, amplitudeFV0Sum}}); + flatchrg.add("FV0/hFV0AmplvsVtxzCalib", "", {HistType::kTH2F, {vtxzAxis, amplitudeFV0Sum}}); + flatchrg.add("FV0/hFV0amp", "", {HistType::kTH2F, {channelFV0Axis, amplitudeFV0}}); + flatchrg.add("FV0/pFV0amp", "", HistType::kTProfile, {channelFV0Axis}); + flatchrg.add("FV0/hFV0ampCorr", "", {HistType::kTH2F, {channelFV0Axis, amplitudeFV0}}); + // V0's QA + flatchrg.add("Tracks/V0qa/hV0Pt", "pT", HistType::kTH1F, {{100, 0.0f, 10}}); + flatchrg.add("Tracks/V0qa/hV0ArmPod", ";#alpha; #it{q}_T", HistType::kTH2F, {{200, -1.0f, +1.0f}, {250, 0.0f, 0.25f}}); + // dEdx PID + flatchrg.add({"Tracks/all/hdEdx", "; #eta; mult; flat; #it{p} (GeV/#it{c}); dEdx", {HistType::kTHnSparseF, {etaAxis, multAxis, flatAxis, pAxis, dEdxAxis}}}); + // Clean samples + if (cfgFillV0Hist) { + if (cfgStoreThnSparse) { + flatchrg.add({"Tracks/CleanTof/all/hPiTof", "; #eta; mult; flat; #it{p} (GeV/#it{c}); dEdx", {HistType::kTHnSparseF, {etaAxis, multAxis, flatAxis, pAxis, dEdxAxis}}}); + flatchrg.add({"Tracks/CleanV0/pos/hEV0", "; #eta; mult; flat; #it{p} (GeV/#it{c}); dEdx", {HistType::kTHnSparseF, {etaAxis, multAxis, flatAxis, pAxis, dEdxAxis}}}); + flatchrg.add({"Tracks/CleanV0/pos/hPiV0", "; #eta; mult; flat; #it{p} (GeV/#it{c}); dEdx", {HistType::kTHnSparseF, {etaAxis, multAxis, flatAxis, pAxis, dEdxAxis}}}); + flatchrg.add({"Tracks/CleanV0/pos/hPV0", "; #eta; mult; flat; #it{p} (GeV/#it{c}); dEdx", {HistType::kTHnSparseF, {etaAxis, multAxis, flatAxis, pAxis, dEdxAxis}}}); + } else { + flatchrg.add({"Tracks/CleanTof/all/hPiTof", "; #eta; mult; flat; #it{p} (GeV/#it{c}); dEdx", {HistType::kTH3F, {etaAxis, pAxis, dEdxAxis}}}); + flatchrg.add({"Tracks/CleanV0/pos/hEV0", "; #eta; mult; flat; #it{p} (GeV/#it{c}); dEdx", {HistType::kTH3F, {etaAxis, pAxis, dEdxAxis}}}); + flatchrg.add({"Tracks/CleanV0/pos/hPiV0", "; #eta; mult; flat; #it{p} (GeV/#it{c}); dEdx", {HistType::kTH3F, {etaAxis, pAxis, dEdxAxis}}}); + flatchrg.add({"Tracks/CleanV0/pos/hPV0", "; #eta; mult; flat; #it{p} (GeV/#it{c}); dEdx", {HistType::kTH3F, {etaAxis, pAxis, dEdxAxis}}}); + } + flatchrg.addClone("Tracks/CleanV0/pos/", "Tracks/CleanV0/neg/"); + if (cfgFillChrgType) { + flatchrg.addClone("Tracks/CleanTof/all/", "Tracks/CleanTof/pos/"); + flatchrg.addClone("Tracks/CleanTof/all/", "Tracks/CleanTof/neg/"); + } + } + if (cfgFillChrgType) { + flatchrg.addClone("Tracks/all/", "Tracks/pos/"); + flatchrg.addClone("Tracks/all/", "Tracks/neg/"); + } + } + + if (doprocessMC) { + auto h = flatchrg.add("hEvtGenRec", "Generated and Reconstructed MC Collisions", kTH1F, {{3, 0.5, 3.5}}); + h->GetXaxis()->SetBinLabel(1, "Gen coll"); + h->GetXaxis()->SetBinLabel(2, "Rec coll"); + h->GetXaxis()->SetBinLabel(3, "INEL>0"); + + flatchrg.add("hEvtMcGenColls", "Number of events; Cut; #Events Passed Cut", {HistType::kTH1F, {{5, 0.5, 5.5}}}); + flatchrg.get(HIST("hEvtMcGenColls"))->GetXaxis()->SetBinLabel(1, "Gen. coll"); + flatchrg.get(HIST("hEvtMcGenColls"))->GetXaxis()->SetBinLabel(2, "At least 1 reco"); + flatchrg.get(HIST("hEvtMcGenColls"))->GetXaxis()->SetBinLabel(3, "Reco. coll."); + flatchrg.get(HIST("hEvtMcGenColls"))->GetXaxis()->SetBinLabel(4, "Reco. good coll."); + + for (int i = 0; i < NpartChrg; i++) { + const std::string strID = Form("/%s/%s", (i < Npart) ? "pos" : "neg", Pid[i % Npart]); + hPtGenRecEvt[i] = flatchrg.add("Tracks/hPtGenRecEvt" + strID, " ; p_{T} (GeV/c)", HistType::kTH1F, {ptAxis}); + hPtGenPrimRecEvt[i] = flatchrg.add("Tracks/hPtGenPrimRecEvt" + strID, " ; p_{T} (GeV/c)", HistType::kTH1F, {ptAxis}); + hPtEffGenPrim[i] = flatchrg.add("Tracks/hPtEffGenPrim" + strID, " ; p_{T} (GeV/c)", HistType::kTH3F, {multAxis, flatAxis, ptAxis}); + hPtEffGenWeak[i] = flatchrg.add("Tracks/hPtEffGenWeak" + strID, " ; p_{T} (GeV/c)", HistType::kTH3F, {multAxis, flatAxis, ptAxis}); + hPtEffGenMat[i] = flatchrg.add("Tracks/hPtEffGenMat" + strID, " ; p_{T} (GeV/c)", HistType::kTH3F, {multAxis, flatAxis, ptAxis}); + hPtEffRecPrim[i] = flatchrg.add("Tracks/hPtEffRecPrim" + strID, " ; p_{T} (GeV/c)", HistType::kTH3F, {multAxis, flatAxis, ptAxis}); + hPtEffRecWeak[i] = flatchrg.add("Tracks/hPtEffRecWeak" + strID, " ; p_{T} (GeV/c)", HistType::kTH3F, {multAxis, flatAxis, ptAxis}); + hPtEffRecMat[i] = flatchrg.add("Tracks/hPtEffRecMat" + strID, " ; p_{T} (GeV/c)", HistType::kTH3F, {multAxis, flatAxis, ptAxis}); + hDCAxyBadCollPrim[i] = flatchrg.add("Tracks/hDCAxyBadCollPrim" + strID, " ; p_{T} (GeV/c)", HistType::kTH2F, {ptAxis, dcaXYAxis}); + hDCAxyBadCollWeak[i] = flatchrg.add("Tracks/hDCAxyBadCollWeak" + strID, " ; p_{T} (GeV/c)", HistType::kTH2F, {ptAxis, dcaXYAxis}); + hDCAxyBadCollMat[i] = flatchrg.add("Tracks/hDCAxyBadCollMat" + strID, " ; p_{T} (GeV/c)", HistType::kTH2F, {ptAxis, dcaXYAxis}); + hPtVsDCAxyPrim[i] = flatchrg.add("Tracks/hPtVsDCAxyPrim" + strID, " ; p_{T} (GeV/c)", HistType::kTH2F, {ptAxis, dcaXYAxis}); + hPtVsDCAxyWeak[i] = flatchrg.add("Tracks/hPtVsDCAxyWeak" + strID, " ; p_{T} (GeV/c)", HistType::kTH2F, {ptAxis, dcaXYAxis}); + hPtVsDCAxyMat[i] = flatchrg.add("Tracks/hPtVsDCAxyMat" + strID, " ; p_{T} (GeV/c)", HistType::kTH2F, {ptAxis, dcaXYAxis}); + } + + flatchrg.add({"hPtOut", " ; p_{T} (GeV/c)", {HistType::kTH1F, {ptAxis}}}); + flatchrg.add({"hPtOutPrim", " ; p_{T} (GeV/c)", {HistType::kTH1F, {ptAxis}}}); + flatchrg.add({"hPtOutNoEtaCut", " ; p_{T} (GeV/c)", {HistType::kTH1F, {ptAxis}}}); + flatchrg.add({"PtOutFakes", " ; p_{T} (GeV/c)", {HistType::kTH1F, {ptAxis}}}); + flatchrg.add("hPtVsDCAxyPrimAll", "hPtVsDCAxyPrimAll", HistType::kTH2F, {ptAxis, dcaXYAxis}); + flatchrg.add("hPtVsDCAxyWeakAll", "hPtVsDCAxyWeakAll", HistType::kTH2F, {ptAxis, dcaXYAxis}); + flatchrg.add("hPtVsDCAxyMatAll", "hPtVsDCAxyMatAll", HistType::kTH2F, {ptAxis, dcaXYAxis}); + flatchrg.add("hPtVsDCAxyAll", "hPtVsDCAxyAll", HistType::kTH2F, {ptAxis, dcaXYAxis}); + flatchrg.add({"ResponseGen", " ; N_{part}; F_{FV0};", {HistType::kTHnSparseF, {multAxis, flatAxis}}}); + flatchrg.add("h1flatencityFV0MCGen", "", HistType::kTH1F, {{102, -0.01, 1.01, "1-flatencityFV0"}}); + + // Hash list for efficiency + listEfficiency.setObject(new THashList); + static_for<0, 1>([&](auto pidSgn) { + bookMcHist(); + bookMcHist(); + bookMcHist(); + initEfficiency(); + initEfficiency(); + initEfficiency(); + }); + } + + if (doprocessMCclosure) { + for (int i = 0; i < Npart; i++) { + flatchrg.add({fmt::format(kPtMCclosurePrimF.data(), kSpeciesAll[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH3F, {multAxis, flatAxis, ptAxis}}}); + } + } + + if (doprocessSgnLoss) { + flatchrg.add("hFlatMCGenRecColl", "hFlatMCGenRecColl", {HistType::kTH1F, {flatAxis}}); + flatchrg.add("hFlatMCGen", "hFlatMCGen", {HistType::kTH1F, {flatAxis}}); + // Event counter + flatchrg.add("hEvtMcGen", "hEvtMcGen", {HistType::kTH1F, {{4, 0.f, 4.f}}}); + flatchrg.get(HIST("hEvtMcGen"))->GetXaxis()->SetBinLabel(1, "all"); + flatchrg.get(HIST("hEvtMcGen"))->GetXaxis()->SetBinLabel(2, "z-vtx"); + flatchrg.get(HIST("hEvtMcGen"))->GetXaxis()->SetBinLabel(3, "INELgt0"); + flatchrg.add("hEvtMCRec", "hEvtMCRec", {HistType::kTH1F, {{4, 0.f, 4.f}}}); + flatchrg.get(HIST("hEvtMCRec"))->GetXaxis()->SetBinLabel(1, "all"); + flatchrg.get(HIST("hEvtMCRec"))->GetXaxis()->SetBinLabel(2, "evt sel"); + flatchrg.get(HIST("hEvtMCRec"))->GetXaxis()->SetBinLabel(3, "INELgt0"); + flatchrg.add("hEvtMcGenRecColl", "hEvtMcGenRecColl", {HistType::kTH1F, {{2, 0.f, 2.f}}}); + flatchrg.get(HIST("hEvtMcGenRecColl"))->GetXaxis()->SetBinLabel(1, "INEL"); + flatchrg.get(HIST("hEvtMcGenRecColl"))->GetXaxis()->SetBinLabel(2, "INELgt0"); + + flatchrg.add("hFlatGenINELgt0", "hFlatGenINELgt0", {HistType::kTH1F, {flatAxis}}); + + for (int i = 0; i < NpartChrg; ++i) { + flatchrg.add({fmt::format(kPtGenPrimSgnF.data(), kSpecies[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH3F, {multAxis, flatAxis, ptAxis}}}); + flatchrg.add({fmt::format(kPtGenPrimSgnINELF.data(), kSpecies[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH3F, {multAxis, flatAxis, ptAxis}}}); + flatchrg.add({fmt::format(kPtRecCollPrimSgnF.data(), kSpecies[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH3F, {multAxis, flatAxis, ptAxis}}}); + flatchrg.add({fmt::format(kPtRecCollPrimSgnINELF.data(), kSpecies[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH3F, {multAxis, flatAxis, ptAxis}}}); + flatchrg.add({fmt::format(kPtGenRecCollPrimSgnF.data(), kSpecies[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH3F, {multAxis, flatAxis, ptAxis}}}); + flatchrg.add({fmt::format(kPtGenRecCollPrimSgnINELF.data(), kSpecies[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH3F, {multAxis, flatAxis, ptAxis}}}); + } + } + + LOG(info) << "Size of the histograms:"; + flatchrg.print(); + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + fv0AmplCorr.clear(); + fv0AmplCorr = {}; + std::string fullPathCalibGain; + std::string fullPathCalibVtx; + auto timestamp = bc.timestamp(); + auto runnumber = bc.runNumber(); + + if (applyCalibGain) { + fullPathCalibGain = cfgGainEqCcdbPath; + fullPathCalibGain += "/FV0"; + auto objfv0Gain = getForTsOrRun>(fullPathCalibGain, timestamp, runnumber); + if (!objfv0Gain) { + for (auto i{0u}; i < kNCellsFV0; i++) { + fv0AmplCorr.push_back(1.); + LOGF(warning, "Setting FV0 calibration object values to 1"); + } + } else { + fv0AmplCorr = *(objfv0Gain); + } + } + + if (applyCalibVtx) { + fullPathCalibVtx = cfgVtxEqCcdbPath; + fullPathCalibVtx += "/FV0"; + zVtxMap = getForTsOrRun(fullPathCalibVtx, timestamp, runnumber); + } + } + + using MyCollisions = soa::Join; + using Colls = soa::Join; + using CollsGen = soa::Join; + using MCColls = soa::Join; + using CollsGenSgn = soa::SmallGroups>; + using MyPIDTracks = soa::Join; + using MyLabeledTracks = soa::Join; + using MyFiltLabeledTracks = soa::Filtered; + using MyLabeledPIDTracks = soa::Join; + + template + std::unique_ptr setFuncPars(T const& vecPars) + { + std::unique_ptr fCalibFunc(new TF1("fCalibFunc", "pol2", -1., 1.)); + if (vecPars.size() >= 1) { + for (typename T::size_type i = 0; i < vecPars.size(); i++) { + fCalibFunc->SetParameter(i, vecPars[i]); + } + } + return fCalibFunc; + } + + template + bool isPID(const P& mcParticle) + { + static_assert(pidSgn == 0 || pidSgn == 1); + static_assert(id > 0 || id < Npart); + constexpr int kIdx = id + pidSgn * Npart; + return mcParticle.pdgCode() == PidSgn[kIdx]; + } + + template + bool selTPCtrack(T const& track) + { + return (track.hasTPC() && + track.passedTPCCrossedRowsOverNCls() && + track.passedTPCChi2NDF() && + track.passedTPCNCls() && + track.passedTPCCrossedRows() && + track.passedTPCRefit()); + } + + template + bool selTOFPi(T const& track) + { + if (track.p() < trkSelOpt.cfgMomSelPiTOF) { + if (track.hasTOF()) { + if (std::abs(track.tpcNSigmaPi()) < v0SelOpt.cfgNsigmaPiTPC && std::abs(track.tofNSigmaPi()) < v0SelOpt.cfgNsigmaPiTOF) { + return true; + } + } + } + return false; + } + + template + void fillNsigma(T const& tracks, const C& collision) + { + const float mult = getMult(collision); + const float flat = fillFlat(collision); + for (const auto& track : tracks) { + checkNsigma(track, mult, flat); + } + } + + template + void filldEdx(T const& tracks, V const& v0s, const C& collision, aod::BCsWithTimestamps const& /*bcs*/) + { + auto bc = collision.template bc_as(); + auto magField = (ccdbConf.cfgMagField == 0) ? getMagneticField(bc.timestamp()) : ccdbConf.cfgMagField; + + if (applyCalibGain || applyCalibVtx) { + int currentRun = bc.runNumber(); + if (runNumber != currentRun) { + initCCDB(bc); + runNumber = currentRun; + } + } + + const float mult = getMult(collision); + const float flat = fillFlat(collision); + flatchrg.fill(HIST("Events/hFlatVsMultEst"), flat, mult); + + for (const auto& track : tracks) { + float dEdx = track.tpcSignal(); + if (cfgFillTrackQaHist) { + fillTrackQA(track); + } + if (!isGoodTrack(track, magField)) { + continue; + } + if (cfgFillTrackQaHist) { + fillTrackQA(track); + } + if (cfgFilldEdxCalibHist && cfgFilldEdxQaHist) { + if (cfgFillChrgType) { + if (track.sign() * track.tpcInnerParam() > 0) { + filldEdxQA(track, collision, dEdx); + } else { + filldEdxQA(track, collision, dEdx); + } + } else { + filldEdxQA(track, collision, dEdx); + } + } + if (applyCalibDeDx) { + if (cfgFillChrgType) { + dEdx *= (50.0 / getCalibration(fDeDxVsEta, track)); + if (cfgFilldEdxQaHist) { + if (track.sign() * track.tpcInnerParam() > 0) { + filldEdxQA(track, collision, dEdx); + } else { + filldEdxQA(track, collision, dEdx); + } + } + } else { + dEdx *= (50.0 / getCalibration(fDeDxVsEta, track)); + if (cfgFilldEdxQaHist) { + filldEdxQA(track, collision, dEdx); + } + } + } + + // PID TPC dEdx + if (cfgFillChrgType) { + if (track.sign() * track.tpcInnerParam() > 0) { + flatchrg.fill(HIST(kPrefix) + HIST(kCharge[kPos]) + HIST("hdEdx"), track.eta(), mult, flat, track.tpcInnerParam(), dEdx); + } else { + flatchrg.fill(HIST(kPrefix) + HIST(kCharge[kNeg]) + HIST("hdEdx"), track.eta(), mult, flat, track.tpcInnerParam(), dEdx); + } + } else { + flatchrg.fill(HIST(kPrefix) + HIST(kCharge[kAll]) + HIST("hdEdx"), track.eta(), mult, flat, track.tpcInnerParam(), dEdx); + } + + // TOF pions + if (cfgFillV0Hist) { + if (track.hasTOF() && track.beta() > 1.) { + if (selTOFPi(track)) { + if (cfgFillChrgType) { + if (track.sign() * track.tpcInnerParam() > 0) { + if (cfgStoreThnSparse) { + flatchrg.fill(HIST(kPrefixCleanTof) + HIST(kCharge[kPos]) + HIST("hPiTof"), track.eta(), mult, flat, track.tpcInnerParam(), dEdx); + } else { + flatchrg.fill(HIST(kPrefixCleanTof) + HIST(kCharge[kPos]) + HIST("hPiTof"), track.eta(), track.tpcInnerParam(), dEdx); + } + } else { + if (cfgStoreThnSparse) { + flatchrg.fill(HIST(kPrefixCleanTof) + HIST(kCharge[kNeg]) + HIST("hPiTof"), track.eta(), mult, flat, track.tpcInnerParam(), dEdx); + } else { + flatchrg.fill(HIST(kPrefixCleanTof) + HIST(kCharge[kNeg]) + HIST("hPiTof"), track.eta(), track.tpcInnerParam(), dEdx); + } + } + } else { + if (cfgStoreThnSparse) { + flatchrg.fill(HIST(kPrefixCleanTof) + HIST(kCharge[kAll]) + HIST("hPiTof"), track.eta(), mult, flat, track.tpcInnerParam(), dEdx); + } else { + flatchrg.fill(HIST(kPrefixCleanTof) + HIST(kCharge[kAll]) + HIST("hPiTof"), track.eta(), track.tpcInnerParam(), dEdx); + } + } + } + } + } + } + + // V0s + if (cfgFillV0Hist) { + for (const auto& v0 : v0s) { + if (!isGoodV0Track(v0, tracks)) { + continue; + } + + const auto& posTrack = v0.template posTrack_as(); + const auto& negTrack = v0.template negTrack_as(); + float dEdxPos = posTrack.tpcSignal(); + float dEdxNeg = negTrack.tpcSignal(); + + if (applyCalibDeDx) { + dEdxPos *= (50.0 / getCalibration(fDeDxVsEta, posTrack)); + dEdxNeg *= (50.0 / getCalibration(fDeDxVsEta, negTrack)); + } + + if (selectTypeV0s(v0, posTrack, negTrack) == kGa) { // Gamma selection + if (cfgStoreThnSparse) { + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kPos]) + HIST("hEV0"), posTrack.eta(), mult, flat, posTrack.sign() * posTrack.tpcInnerParam(), dEdxPos); + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kNeg]) + HIST("hEV0"), negTrack.eta(), mult, flat, negTrack.sign() * negTrack.tpcInnerParam(), dEdxNeg); + } else { + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kPos]) + HIST("hEV0"), posTrack.eta(), posTrack.sign() * posTrack.tpcInnerParam(), dEdxPos); + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kNeg]) + HIST("hEV0"), negTrack.eta(), negTrack.sign() * negTrack.tpcInnerParam(), dEdxNeg); + } + } + if (selectTypeV0s(v0, posTrack, negTrack) == kKz) { // K0S -> pi + pi + if (cfgStoreThnSparse) { + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kPos]) + HIST("hPiV0"), posTrack.eta(), mult, flat, posTrack.sign() * posTrack.tpcInnerParam(), dEdxPos); + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kNeg]) + HIST("hPiV0"), negTrack.eta(), mult, flat, negTrack.sign() * negTrack.tpcInnerParam(), dEdxNeg); + } else { + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kPos]) + HIST("hPiV0"), posTrack.eta(), posTrack.sign() * posTrack.tpcInnerParam(), dEdxPos); + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kNeg]) + HIST("hPiV0"), negTrack.eta(), negTrack.sign() * negTrack.tpcInnerParam(), dEdxNeg); + } + } + if (selectTypeV0s(v0, posTrack, negTrack) == kLam) { // L -> p + pi- + if (cfgStoreThnSparse) { + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kPos]) + HIST("hPV0"), posTrack.eta(), mult, flat, posTrack.sign() * posTrack.tpcInnerParam(), dEdxPos); + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kNeg]) + HIST("hPV0"), negTrack.eta(), mult, flat, negTrack.sign() * negTrack.tpcInnerParam(), dEdxNeg); + } else { + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kPos]) + HIST("hPV0"), posTrack.eta(), posTrack.sign() * posTrack.tpcInnerParam(), dEdxPos); + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kNeg]) + HIST("hPV0"), negTrack.eta(), negTrack.sign() * negTrack.tpcInnerParam(), dEdxNeg); + } + } + if (selectTypeV0s(v0, posTrack, negTrack) == kaLam) { // L -> p + pi- + if (cfgStoreThnSparse) { + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kPos]) + HIST("hPiV0"), posTrack.eta(), mult, flat, posTrack.sign() * posTrack.tpcInnerParam(), dEdxPos); + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kNeg]) + HIST("hPiV0"), negTrack.eta(), mult, flat, negTrack.sign() * negTrack.tpcInnerParam(), dEdxNeg); + } else { + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kPos]) + HIST("hPiV0"), posTrack.eta(), posTrack.sign() * posTrack.tpcInnerParam(), dEdxPos); + flatchrg.fill(HIST(kPrefixCleanV0) + HIST(kCharge[kNeg]) + HIST("hPiV0"), negTrack.eta(), negTrack.sign() * negTrack.tpcInnerParam(), dEdxNeg); + } + } + } + } + } + + template + float getCalibration(std::vector> const& fCalib, V const& track) + { + float valCalib = -1.; + if constexpr (isChrg) { + if (track.sign() * track.tpcInnerParam() > 0) { + valCalib = fCalib.at(0)->Eval(track.eta()); + } else { + valCalib = fCalib.at(1)->Eval(track.eta()); + } + } else { + valCalib = fCalib.at(2)->Eval(track.eta()); + } + return valCalib; + } + + bool isChrgParticle(int code) + { + auto p = pdg->GetParticle(code); + auto charge = 0.; + if (p != nullptr) { + charge = p->Charge(); + } + return std::abs(charge) >= kMinCharge; + } + + template + bool phiCut(T const& track, float mag, TF1* fphiCutLow, TF1* fphiCutHigh) + { + if (track.pt() < trkSelOpt.cfgPhiCutPtMin) + return true; + // cut to remove tracks at TPC boundaries + double phimodn = track.phi(); + if (mag < 0) // for negative polarity field + phimodn = o2::constants::math::TwoPI - phimodn; + if (track.sign() < 0) // for negative charge + phimodn = o2::constants::math::TwoPI - phimodn; + if (phimodn < 0) + LOGF(warning, "phi < 0: %g", phimodn); + + phimodn += o2::constants::math::PI / 18.0; // to center gap in the middle + phimodn = std::fmod(phimodn, o2::constants::math::PI / 9.0); + + if (cfgFillTrackQaHist) { + flatchrg.fill(HIST("Tracks/preSel/hPtPhi"), track.pt(), phimodn); + if (track.hasTPC() && track.hasITS()) { + if (cfgStoreThnSparse) { + flatchrg.fill(HIST("Tracks/preSel/hPtPhiTPCCluster"), track.pt(), phimodn, track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()); + } else { + flatchrg.fill(HIST("Tracks/preSel/hPtPhiTPCCluster"), track.pt(), phimodn); + } + } + } + if (phimodn < fphiCutHigh->Eval(track.pt()) && phimodn > fphiCutLow->Eval(track.pt())) { + return false; + } + if (cfgFillTrackQaHist) { + flatchrg.fill(HIST("Tracks/postSel/hPtPhi"), track.pt(), phimodn); + if (track.hasTPC() && track.hasITS()) { + if (cfgStoreThnSparse) { + flatchrg.fill(HIST("Tracks/postSel/hPtPhiTPCCluster"), track.pt(), phimodn, track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()); + } else { + flatchrg.fill(HIST("Tracks/postSel/hPtPhiTPCCluster"), track.pt(), phimodn); + } + } + } + return true; + } + + template + bool isGoodTrack(T const& track, int const magfield) + { + if (std::abs(track.eta()) > trkSelOpt.cfgTrkEtaMax) { + return false; + } + flatchrg.fill(HIST("Tracks/hTrkSel"), trkSelEta); + if (track.pt() < trkSelOpt.cfgTrkPtMin) { + return false; + } + flatchrg.fill(HIST("Tracks/hTrkSel"), trkSelPt); + if (!isDCAxyCut(track)) { + return false; + } + flatchrg.fill(HIST("Tracks/hTrkSel"), trkSelDCA); + if (track.tpcNClsCrossedRows() < minNCrossedRowsTPC) { + return false; + } + flatchrg.fill(HIST("Tracks/hTrkSel"), trkNRowsTPC); + auto nClusterTPC = track.tpcNClsFindable() - track.tpcNClsFindableMinusFound(); + if (nClusterTPC < trkSelOpt.cfgNclTPCMin) { + return false; + } + flatchrg.fill(HIST("Tracks/hTrkSel"), trkSelNCls); + if (trkSelOpt.cfgUseExtraTrkCut && !phiCut(track, magfield, fPhiCutLow, fPhiCutHigh)) { + return false; + } + flatchrg.fill(HIST("Tracks/hTrkSel"), trkSelTPCBndr); + return true; + } + + template + int selectTypeV0s(T1 const& v0, T2 const& postrk, T2 const& negtrk) + { + // Gamma selection + if (v0.mGamma() < v0SelOpt.cfgdmassG) { + if (postrk.tpcInnerParam() < v0SelOpt.cfgV0DaughterTpcMomMax && postrk.hasTPC() && std::abs(postrk.tpcNSigmaEl()) < v0SelOpt.cfgNsigmaElTPC) { + if (postrk.hasTOF() && std::abs(postrk.tofNSigmaEl()) < v0SelOpt.cfgNsigmaElTOF) { + return kGa; + } + } + if (negtrk.tpcInnerParam() < v0SelOpt.cfgV0DaughterTpcMomMax && negtrk.hasTPC() && std::abs(negtrk.tpcNSigmaEl()) < v0SelOpt.cfgNsigmaElTPC) { + if (negtrk.hasTOF() && std::abs(negtrk.tofNSigmaEl()) < v0SelOpt.cfgNsigmaElTOF) { + return kGa; + } + } + } + // K0S selection, K0S -> pi + pi + if (std::abs(v0.mK0Short() - o2::constants::physics::MassK0Short) < v0SelOpt.cfgdmassK) { + if (postrk.tpcInnerParam() < v0SelOpt.cfgV0DaughterTpcMomMax && postrk.hasTPC() && std::abs(postrk.tpcNSigmaPi()) < v0SelOpt.cfgNsigmaPiTPC) { + if (postrk.hasTOF() && std::abs(postrk.tofNSigmaPi()) < v0SelOpt.cfgNsigmaElTOF) { + return kKz; + } + } + if (negtrk.tpcInnerParam() < v0SelOpt.cfgV0DaughterTpcMomMax && negtrk.hasTPC() && std::abs(negtrk.tpcNSigmaPi()) < v0SelOpt.cfgNsigmaPiTPC) { + if (negtrk.hasTOF() && std::abs(negtrk.tofNSigmaPi()) < v0SelOpt.cfgNsigmaPiTOF) { + return kKz; + } + } + } + // Lambda selection, L -> p + pi- + if (std::abs(v0.mLambda() - o2::constants::physics::MassLambda0) < v0SelOpt.cfgdmassL) { + if (postrk.tpcInnerParam() < v0SelOpt.cfgV0DaughterTpcMomMax && postrk.hasTPC() && std::abs(postrk.tpcNSigmaPr()) < v0SelOpt.cfgNsigmaPrTPC && negtrk.hasTPC() && std::abs(negtrk.tpcNSigmaPi()) < v0SelOpt.cfgNsigmaPiTPC) { + if (postrk.hasTOF() && std::abs(postrk.tofNSigmaPr()) < v0SelOpt.cfgNsigmaPrTOF && negtrk.hasTOF() && std::abs(negtrk.tofNSigmaPi()) < v0SelOpt.cfgNsigmaPiTOF) { + return kLam; + } + } + } + // antiLambda -> pbar + pi+ + if (std::abs(v0.mAntiLambda() - o2::constants::physics::MassLambda0) < v0SelOpt.cfgdmassL) { + if (postrk.tpcInnerParam() < v0SelOpt.cfgV0DaughterTpcMomMax && postrk.hasTPC() && std::abs(postrk.tpcNSigmaPi()) < v0SelOpt.cfgNsigmaPiTPC && negtrk.hasTPC() && std::abs(negtrk.tpcNSigmaPr()) < v0SelOpt.cfgNsigmaPrTPC) { + if (postrk.hasTOF() && std::abs(postrk.tofNSigmaPi()) < v0SelOpt.cfgNsigmaPiTOF && negtrk.hasTOF() && std::abs(negtrk.tofNSigmaPr()) < v0SelOpt.cfgNsigmaPrTOF) { + return kaLam; + } + } + } + return kNaN; + } + + template + bool isGoodV0Track(T1 const& v0, T2 const& /*track*/) + { + const auto& posTrack = v0.template posTrack_as(); + const auto& negTrack = v0.template negTrack_as(); + + if (std::abs(posTrack.eta()) > v0SelOpt.cfgV0etamax || std::abs(negTrack.eta()) > v0SelOpt.cfgV0etamax) { + return false; + } + if (posTrack.tpcNClsFound() < v0SelOpt.cfgTPCnClsmin || negTrack.tpcNClsFound() < v0SelOpt.cfgTPCnClsmin) { + return false; + } + if (posTrack.sign() * negTrack.sign() > 0) { // reject same sign pair + return false; + } + if (v0.dcaV0daughters() > v0SelOpt.cfgDCAv0daughter) { + return false; + } + if (v0.v0cosPA() < v0SelOpt.cfgv0cospa) { + return false; + } + if (v0.v0radius() < v0SelOpt.cfgv0Rmin || v0.v0radius() > v0SelOpt.cfgv0Rmax) { + return false; + } + if (std::abs(v0.dcapostopv()) < v0SelOpt.cfgDCAposToPV || std::abs(v0.dcanegtopv()) < v0SelOpt.cfgDCAposToPV) { + return false; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Tracks/V0qa/hV0Pt"), v0.pt()); + flatchrg.fill(HIST("Tracks/V0qa/hV0ArmPod"), v0.alpha(), v0.qtarm()); + } + return true; + } + + template + void checkNsigma(const T& track, const float mult, const float flat) + { + if (std::abs(track.rapidity(o2::track::PID::getMass(pid))) > trkSelOpt.cfgRapMax) { + return; + } + + float valTPCnsigma = -999, valTOFnsigma = -999; + switch (pid) { + case o2::track::PID::Pion: + valTPCnsigma = track.tpcNSigmaPi(); + valTOFnsigma = track.tofNSigmaPi(); + break; + case o2::track::PID::Kaon: + valTPCnsigma = track.tpcNSigmaKa(); + valTOFnsigma = track.tofNSigmaKa(); + break; + case o2::track::PID::Proton: + valTPCnsigma = track.tpcNSigmaPr(); + valTOFnsigma = track.tofNSigmaPr(); + break; + case o2::track::PID::Electron: + valTPCnsigma = track.tpcNSigmaEl(); + valTOFnsigma = track.tofNSigmaEl(); + break; + case o2::track::PID::Muon: + valTPCnsigma = track.tpcNSigmaMu(); + valTOFnsigma = track.tofNSigmaMu(); + break; + default: + valTPCnsigma = -999, valTOFnsigma = -999; + break; + } + + if (track.sign() > 0) { + if (cfgStoreThnSparse) { + hThPtNsigmaTPC[pid]->Fill(track.pt(), valTPCnsigma, mult, flat); + } else { + hPtNsigmaTPC[pid]->Fill(track.pt(), valTPCnsigma); + } + } else { + if (cfgStoreThnSparse) { + hThPtNsigmaTPC[pid + Npart]->Fill(track.pt(), valTPCnsigma, mult, flat); + } else { + hPtNsigmaTPC[pid + Npart]->Fill(track.pt(), valTPCnsigma); + } + } + if (!track.hasTOF()) { + return; + } + if (track.sign() > 0) { + hPtNsigmaTOF[pid]->Fill(track.pt(), valTOFnsigma); + hPtNsigmaTPCTOF[pid]->Fill(valTPCnsigma, valTOFnsigma); + } else { + hPtNsigmaTOF[pid + Npart]->Fill(track.pt(), valTOFnsigma); + hPtNsigmaTPCTOF[pid + Npart]->Fill(valTPCnsigma, valTOFnsigma); + } + } + + template + inline void fillTrackQA(T const& track) + { + if constexpr (fillHist) { + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hPt"), track.pt()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hPhi"), track.phi()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hEta"), track.eta()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hDCAXYvsPt"), track.pt(), track.dcaXY()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hDCAZvsPt"), track.pt(), track.dcaZ()); + + if (track.hasTPC() && track.hasITS()) { + int nFindable = track.tpcNClsFindable(); + int nMinusFound = track.tpcNClsFindableMinusFound(); + int nCluster = nFindable - nMinusFound; + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hTPCCluster"), nCluster); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hShTpcClvsPt"), track.pt(), track.tpcFractionSharedCls()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hCrossTPCvsPt"), track.pt(), track.tpcNClsFound()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("tpcNClsShared"), track.tpcNClsShared()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("tpcCrossedRows"), track.tpcNClsCrossedRows()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("tpcCrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hChi2ITSTrkSegment"), track.itsChi2NCl()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("itsNCls"), track.itsNCls()); + } + + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hTOFPvsBeta"), track.tpcInnerParam(), track.beta()); + if (track.beta() > trkSelOpt.cfgTOFBetaPion && track.beta() < trkSelOpt.cfgTOFBetaPion + 0.05) { // TOF pions + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hTOFpi"), track.eta(), track.tpcInnerParam(), track.tpcSignal()); + } + + if (std::abs(track.eta()) < trkSelOpt.cfgTrkEtaMax) { + if (isDCAxyWoCut(track)) { + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hPtVsWOcutDCA"), track.pt(), track.dcaXY()); + } + } + } + flatchrg.fill(HIST(kPrefix) + HIST(kStatus[ft]) + HIST("hPVsPtEta"), track.tpcInnerParam(), track.pt(), track.eta()); + } + + template + inline void filldEdxQA(T const& track, C const& collision, const float dEdx) + { + const float mult = getMult(collision); + const float flat = fillFlat(collision); + // float dEdx = track.tpcSignal(); + if constexpr (fillHist) { + if (track.tpcInnerParam() >= trkSelOpt.cfgMomMIPMin && track.tpcInnerParam() <= trkSelOpt.cfgMomMIPMax) { + if (dEdx > trkSelOpt.cfgDeDxMIPMin && dEdx < trkSelOpt.cfgDeDxMIPMax) { // MIP pions + if (cfgStoreThnSparse) { + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("hMIP"), mult, flat, track.eta(), dEdx); + } else { + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("hMIP"), track.eta(), dEdx); + } + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("hMIPVsPhi"), track.phi(), dEdx); + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("hMIPVsPhiVsEta"), track.phi(), dEdx, track.eta()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("pMIPVsPhi"), track.phi(), dEdx); + } + if (dEdx > trkSelOpt.cfgDeDxMIPMax + 10. && dEdx < trkSelOpt.cfgDeDxMIPMax + 30.) { // Plateau electrons + if (std::abs(track.beta() - 1) < trkSelOpt.cfgBetaPlateuMax) { + if (cfgStoreThnSparse) { + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("hPlateau"), mult, flat, track.eta(), dEdx); + } else { + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("hPlateau"), track.eta(), dEdx); + } + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("hPlateauVsPhi"), track.phi(), dEdx); + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("hPlateauVsPhiVsEta"), track.phi(), dEdx, track.eta()); + flatchrg.fill(HIST(kPrefix) + HIST(kStatCalib[ft]) + HIST(kCharge[chrg]) + HIST("pPlateauVsPhi"), track.phi(), dEdx); + } + } + } + } + } + + template + bool isGoodEvent(C const& collision) + { + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelAll); + } + if (evtSelOpt.cfgCustomTVX) { + if (!collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + } else { + if (!collision.sel8()) { + return false; + } + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelSel8); + } + if (evtSelOpt.cfgRemoveITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return false; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelNoITSROFrameBorder); + } + if (evtSelOpt.cfgRemoveNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelkNoTimeFrameBorder); + } + if (evtSelOpt.cfgRemoveNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return false; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelkNoSameBunchPileup); + } + if (evtSelOpt.cfgRequireIsGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelkIsGoodZvtxFT0vsPV); + } + if (evtSelOpt.cfgRequireIsVertexITSTPC && !collision.selection_bit(aod::evsel::kIsVertexITSTPC)) { + return false; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelkIsVertexITSTPC); + } + if (evtSelOpt.cfgRequirekIsVertexTOFmatched && !collision.selection_bit(aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelkIsVertexTOFmatched); + } + if (std::abs(collision.posZ()) > evtSelOpt.cfgCutVtxZ) { + return false; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelVtxZ); + flatchrg.fill(HIST("Events/hVtxZ"), collision.posZ()); + } + if (evtSelOpt.cfgINELCut && !collision.isInelGt0()) { + return false; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("Events/hEvtSel"), evtSelINELgt0); + } + return true; + } + + int getFV0IndexPhi(int i_ch) + { + int iRing = -1; + + if (i_ch >= kFV0IndexPhi[0] && i_ch < kFV0IndexPhi[1]) { + if (i_ch < kFV0IndexPhi[0] + 4) { + iRing = i_ch; + } else { + if (i_ch == kFV0IndexPhi[1] - 1) { + iRing = i_ch - 3; // 4; + } else if (i_ch == kFV0IndexPhi[1] - 2) { + iRing = i_ch - 1; // 5; + } else if (i_ch == kFV0IndexPhi[1] - 3) { + iRing = i_ch + 1; // 6; + } else if (i_ch == kFV0IndexPhi[1] - 4) { + iRing = i_ch + 3; // 7; + } + } + } else if (i_ch >= kFV0IndexPhi[1] && i_ch < kFV0IndexPhi[2]) { + if (i_ch < kFV0IndexPhi[2] - 4) { + iRing = i_ch; + } else { + if (i_ch == kFV0IndexPhi[2] - 1) { + iRing = i_ch - 3; // 12; + } else if (i_ch == kFV0IndexPhi[2] - 2) { + iRing = i_ch - 1; // 13; + } else if (i_ch == kFV0IndexPhi[2] - 3) { + iRing = i_ch + 1; // 14; + } else if (i_ch == kFV0IndexPhi[2] - 4) { + iRing = i_ch + 3; // 15; + } + } + } else if (i_ch >= kFV0IndexPhi[2] && i_ch < kFV0IndexPhi[3]) { + if (i_ch < kFV0IndexPhi[3] - 4) { + iRing = i_ch; + } else { + if (i_ch == kFV0IndexPhi[3] - 1) { + iRing = i_ch - 3; // 20; + } else if (i_ch == kFV0IndexPhi[3] - 2) { + iRing = i_ch - 1; // 21; + } else if (i_ch == kFV0IndexPhi[3] - 3) { + iRing = i_ch + 1; // 22; + } else if (i_ch == kFV0IndexPhi[3] - 4) { + iRing = i_ch + 3; // 23; + } + } + } else if (i_ch >= kFV0IndexPhi[3] && i_ch < kFV0IndexPhi[4]) { + if (i_ch < kFV0IndexPhi[3] + 4) { + iRing = i_ch; + } else { + if (i_ch == kFV0IndexPhi[4] - 5) { + iRing = i_ch - 3; // 28; + } else if (i_ch == kFV0IndexPhi[4] - 6) { + iRing = i_ch - 1; // 29; + } else if (i_ch == kFV0IndexPhi[4] - 7) { + iRing = i_ch + 1; // 30; + } else if (i_ch == kFV0IndexPhi[4] - 8) { + iRing = i_ch + 3; // 31; + } + } + } else if (i_ch == kFV0IndexPhi[4]) { + iRing = kFV0IndexPhi[4]; + } else if (i_ch == kFV0IndexPhi[4] + 8) { + iRing = i_ch - 7; // 33; + } else if (i_ch == kFV0IndexPhi[4] - 3) { + iRing = i_ch + 1; // 34; + } else if (i_ch == kFV0IndexPhi[4] + 5) { + iRing = i_ch - 6; // 35; + } else if (i_ch == kFV0IndexPhi[4] - 2) { + iRing = i_ch + 2; // 36; + } else if (i_ch == kFV0IndexPhi[4] + 6) { + iRing = i_ch - 5; // 37; + } else if (i_ch == kFV0IndexPhi[4] - 1) { + iRing = i_ch + 3; // 38; + } else if (i_ch == kFV0IndexPhi[4] + 7) { + iRing = i_ch - 4; // 39; + } else if (i_ch == kFV0IndexPhi[4] + 11) { + iRing = i_ch + 7; // 40; + } else if (i_ch == kFV0IndexPhi[4] + 3) { + iRing = i_ch + 2; // 41; + } else if (i_ch == kFV0IndexPhi[4] + 10) { + iRing = i_ch - 4; // 42; + } else if (i_ch == kFV0IndexPhi[4] + 1) { + iRing = i_ch + 5; // 43; + } else if (i_ch == kFV0IndexPhi[4] + 9) { + iRing = i_ch - 1; // 44; + } else if (i_ch == kFV0IndexPhi[4] + 1) { + iRing = i_ch + 8; // 45; + } else if (i_ch == kFV0IndexPhi[4] + 8) { + iRing = i_ch + 2; // 46; + } else if (i_ch == kFV0IndexPhi[4]) { + iRing = i_ch + 11; // 47; + } + return iRing; + } + + int getMagneticField(uint64_t timestamp) + { + o2::parameters::GRPMagField* grpmag = nullptr; + grpmag = ccdb->getForTimeStamp(ccdbConf.grpmagPath, timestamp); + if (!grpmag) { + return 0; + } + return grpmag->getNominalL3Field(); + } + + template + float getMult(C const& collision) + { + float val = -999.0; + switch (multEst) { + case MultE::kNoMult: + return val; + break; + case MultE::kMultFT0M: + return collision.centFT0M(); + break; + case MultE::kMultTPC: + if constexpr (!isMC) { + return collision.multTPC(); + } else { + LOG(fatal) << "No valid multiplicity estimator: " << multEst; + return val; + } + break; + default: + return collision.centFT0M(); + break; + } + } + + float getMultMC(MCColls::iterator const& collision) + { + return getMult(collision); + } + + template + float calcFlatenicity(std::array const& signals) + { + static_assert(S != 0); + + int entries = signals.size(); + float flat{-1}; + float mRho{0}; + for (int iCell = 0; iCell < entries; ++iCell) { + if (signals[iCell] > 0.) { + mRho += 1.0 * signals[iCell]; + } + } + // average activity per cell + mRho /= (1.0 * entries); + if (mRho <= 0) { + return -1; + } + // get sigma + float sRhoTmp{0}; + float sRho{0}; + for (int iCell = 0; iCell < entries; ++iCell) { + if (signals[iCell] > 0.) { + sRhoTmp += std::pow(1.0 * signals[iCell] - mRho, 2); + } + } + sRhoTmp /= (1.0 * entries * entries); + sRho = std::sqrt(sRhoTmp); + if (mRho > 0.) { + flat = sRho / mRho; + } else { + flat = -1; + } + return flat; + } + + template + float fillFlat(C const& collision) + { + rhoLatticeFV0.fill(0); + fv0AmplitudeWoCalib.fill(0); + bool isOkFV0OrA = false; + if (collision.has_foundFV0()) { + auto fv0 = collision.foundFV0(); + std::bitset<8> fV0Triggers = fv0.triggerMask(); + isOkFV0OrA = fV0Triggers[o2::fit::Triggers::bitA]; + if (isOkFV0OrA) { + for (std::size_t ich = 0; ich < fv0.channel().size(); ich++) { + float amplCh = fv0.amplitude()[ich]; + int chv0 = fv0.channel()[ich]; + int chv0phi = getFV0IndexPhi(chv0); + if constexpr (fillHist) { + flatchrg.fill(HIST("FV0/hFV0amp"), chv0, amplCh); + flatchrg.fill(HIST("FV0/pFV0amp"), chv0, amplCh); + if (applyCalibGain) { + flatchrg.fill(HIST("FV0/hFV0ampCorr"), chv0, amplCh / fv0AmplCorr[chv0]); + } + } + if (amplCh > 0.) { + if (applyCalibGain) { // equalize gain channel-by-channel + amplCh /= fv0AmplCorr[chv0]; + } + if (chv0phi > 0) { + fv0AmplitudeWoCalib[chv0phi] = amplCh; + if constexpr (fillHist) { + flatchrg.fill(HIST("FV0/hFV0AmplWCalib"), ich, fv0AmplitudeWoCalib[ich]); + } + if (chv0 < kInnerFV0) { + rhoLatticeFV0[chv0phi] += amplCh; + } else { // two channels per bin + rhoLatticeFV0[chv0phi] += amplCh / 2.; + } + if constexpr (fillHist) { + flatchrg.fill(HIST("FV0/hFV0AmplvsVtxzWoCalib"), collision.posZ(), rhoLatticeFV0[chv0phi]); + } + if (applyCalibVtx) { + rhoLatticeFV0[chv0phi] *= zVtxMap->GetBinContent(zVtxMap->GetXaxis()->FindBin(chv0phi), zVtxMap->GetYaxis()->FindBin(collision.posZ())); + if constexpr (fillHist) { + flatchrg.fill(HIST("FV0/hFV0AmplvsVtxzCalib"), collision.posZ(), rhoLatticeFV0[chv0phi]); + } + } + } + } + } + float flattenicityFV0 = calcFlatenicity(rhoLatticeFV0); + return 1. - flattenicityFV0; + } else { + return 9999; + } + } else { + return 9999; + } + } + + template + bool isDCAxyCut(T const& track) const + { + if (isCustomTracks.value) { + for (int i = 0; i < static_cast(TrackSelection::TrackCuts::kNCuts); i++) { + if (i == static_cast(TrackSelection::TrackCuts::kDCAxy)) { + continue; + } + if (!mTrackSelector.IsSelected(track, static_cast(i))) { + return false; + } + } + return (std::abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / std::pow(track.pt(), 1.1f)))); + } + return track.isGlobalTrack(); + } + + template + bool isDCAxyWoCut(T const& track) const + { + if (isCustomTracks.value) { + for (int i = 0; i < static_cast(TrackSelection::TrackCuts::kNCuts); i++) { + if (i == static_cast(TrackSelection::TrackCuts::kDCAxy)) { + continue; + } + if (i == static_cast(TrackSelection::TrackCuts::kDCAz)) { + continue; + } + if (!mTrackSelector.IsSelected(track, static_cast(i))) { + return false; + } + } + return true; + } + return track.isGlobalTrackWoDCA(); + } + + Preslice perCol = aod::track::collisionId; + Preslice perColV0s = aod::v0::collisionId; + + template + void processData(C const& collisions, + MyPIDTracks const& tracks, + aod::V0Datas const& v0s, + aod::BCsWithTimestamps const& bcs) + { + for (const auto& collision : collisions) { + if (!isGoodEvent(collision)) { + continue; + } + auto tracksPerCollision = tracks.sliceBy(perCol, collision.globalIndex()); + auto v0sPerCollision = v0s.sliceBy(perColV0s, collision.globalIndex()); + v0sPerCollision.bindExternalIndices(&tracks); + filldEdx(tracksPerCollision, v0sPerCollision, collision, bcs); + if (cfgFillNsigmaQAHist) { + fillNsigma(tracksPerCollision, collision); + fillNsigma(tracksPerCollision, collision); + fillNsigma(tracksPerCollision, collision); + } + } + } + + void processFlat( + Colls const& collisions, + MyPIDTracks const& tracks, + aod::V0Datas const& v0s, + aod::BCsWithTimestamps const& bcs, + aod::FT0s const&, aod::FV0As const&) + { + processData(collisions, tracks, v0s, bcs); + } + PROCESS_SWITCH(FlattenictyPikp, processFlat, "process Flat data inclusive", true); + + template + float fillFlatMC(McPart const& mcparts) + { + int nFV0sectors = 0; + float minPhi = 0; + float maxPhi = 0; + float dPhi = 0; + + double etaMinFV0bins[kMaxRingsFV0] = {0.0}; + double etaMaxFV0bins[kMaxRingsFV0] = {0.0}; + for (int i = 0; i < kMaxRingsFV0; ++i) { + etaMaxFV0bins[i] = kEtaMaxFV0 - i * kDEtaFV0; + if (i < kMaxRingsFV0 - 1) { + etaMinFV0bins[i] = kEtaMaxFV0 - (i + 1) * kDEtaFV0; + } else { + etaMinFV0bins[i] = kEtaMinFV0; + } + } + + rhoLatticeFV0.fill(0); + std::vector vNch; + float nCharged{0}; + for (const auto& mcPart : mcparts) { + if (!isChrgParticle(mcPart.pdgCode())) { + continue; + } + auto etaMc = mcPart.eta(); + auto phiMc = mcPart.phi(); + + int isegment = 0; + for (int ieta = 0; ieta < kMaxRingsFV0; ieta++) { + + nFV0sectors = kNCellsFV0 / 6.; + if (ieta == kMaxRingsFV0 - 1) { + nFV0sectors = kNCellsFV0 / 3.; + } + + for (int iphi = 0; iphi < nFV0sectors; iphi++) { + + minPhi = iphi * TwoPI / nFV0sectors; + maxPhi = (iphi + 1) * TwoPI / nFV0sectors; + dPhi = std::abs(maxPhi - minPhi); + + if (etaMc >= etaMinFV0bins[ieta] && etaMc < etaMaxFV0bins[ieta] && phiMc >= minPhi && phiMc < maxPhi) { + rhoLatticeFV0[isegment] += 1. / std::abs(kDEtaFV0 * dPhi); + } + isegment++; + } + } + nCharged++; + } + + vNch.push_back(nCharged); + auto flatFV0 = calcFlatenicity(rhoLatticeFV0); + + if constexpr (fillHist) { + flatchrg.fill(HIST("ResponseGen"), vNch[0], 1. - flatFV0); + flatchrg.fill(HIST("h1flatencityFV0MCGen"), 1. - flatFV0); + } + vNch.clear(); + return 1. - flatFV0; + } + + template + void bookMcHist() + { + AxisSpec ptAxis{binOpt.axisPt, "#it{p}_{T} (GeV/#it{c})"}; + constexpr int kHistIdx = id + pidSgn * Npart; + auto kIdx = static_cast(id); + const std::string strID = Form("/%s/%s", (pidSgn == 0 && id < Npart) ? "pos" : "neg", Pid[kIdx]); + hPtEffRec[kHistIdx] = flatchrg.add("Tracks/hPtEffRec" + strID, " ; p_{T} (GeV/c)", HistType::kTH1F, {ptAxis}); + hPtEffGen[kHistIdx] = flatchrg.add("Tracks/hPtEffGen" + strID, " ; p_{T} (GeV/c)", HistType::kTH1F, {ptAxis}); + } + + template + void initEfficiency() + { + static_assert(pidSgn == 0 || pidSgn == 1); + static_assert(id > 0 || id < Npart); + constexpr int kIdx = id + pidSgn * Npart; + const TString partName = PidChrg[kIdx]; + THashList* lhash = new THashList(); + lhash->SetName(partName); + listEfficiency->Add(lhash); + + auto bookEff = [&](const TString eName, auto h) { + const TAxis* axis = h->GetXaxis(); + TString eTitle = h->GetTitle(); + eTitle.ReplaceAll("Numerator", "").Strip(TString::kBoth); + eTitle = Form("%s;%s;Efficiency", eTitle.Data(), axis->GetTitle()); + lhash->Add(new TEfficiency(eName, eTitle, axis->GetNbins(), axis->GetXbins()->GetArray())); + }; + + const int kHistIdx = id + pidSgn * Npart; + bookEff("hEffvsPt", hPtEffRec[kHistIdx]); + } + + template + void fillEfficiency() + { + static_assert(pidSgn == 0 || pidSgn == 1); + constexpr int kHistIdx = id + pidSgn * Npart; + const char* partName = PidChrg[kHistIdx]; + THashList* lhash = static_cast(listEfficiency->FindObject(partName)); + if (!lhash) { + LOG(warning) << "No efficiency object found for particle " << partName; + return; + } + + auto fillEff = [&](const TString eName, auto num, auto den) { + TEfficiency* eff = static_cast(lhash->FindObject(eName)); + if (!eff) { + LOG(warning) << "Cannot find TEfficiency " << eName; + return; + } + eff->SetTotalHistogram(*den, "f"); + eff->SetPassedHistogram(*num, "f"); + }; + fillEff("hEffvsPt", hPtEffRec[kHistIdx], hPtEffGen[kHistIdx]); + } + + template + void fillMCRecTrack(MyLabeledPIDTracks::iterator const& track, const float mult, const float flat) + { + static_assert(pidSgn == 0 || pidSgn == 1); + constexpr int kHistIdx = id + pidSgn * Npart; + const aod::McParticles::iterator& mcParticle = track.mcParticle(); + const CollsGen::iterator& collision = track.collision_as(); + + if (!isPID(mcParticle)) { + return; + } + flatchrg.fill(HIST("hPtOutNoEtaCut"), track.pt()); + if (std::abs(track.eta()) > trkSelOpt.cfgTrkEtaMax) { + return; + } + if (std::abs(mcParticle.y()) > trkSelOpt.cfgRapMax) { + return; + } + + if ((collision.has_mcCollision() && (mcParticle.mcCollisionId() != collision.mcCollisionId())) || !collision.has_mcCollision()) { + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == kProcessIdWeak) { + hDCAxyBadCollWeak[kHistIdx]->Fill(track.pt(), track.dcaXY()); + } else { + hDCAxyBadCollMat[kHistIdx]->Fill(track.pt(), track.dcaXY()); + } + } else { + hDCAxyBadCollPrim[kHistIdx]->Fill(track.pt(), track.dcaXY()); + } + } + + if (!isDCAxyCut(track)) { + return; + } + flatchrg.fill(HIST("hPtVsDCAxyAll"), track.pt(), track.dcaXY()); + + if (selTPCtrack(track)) { + hPtEffRec[kHistIdx]->Fill(mcParticle.pt()); + } + + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == kProcessIdWeak) { + hPtEffRecWeak[kHistIdx]->Fill(mult, flat, track.pt()); + hPtVsDCAxyWeak[kHistIdx]->Fill(track.pt(), track.dcaXY()); + flatchrg.fill(HIST("hPtVsDCAxyWeakAll"), track.pt(), track.dcaXY()); + } else { + hPtEffRecMat[kHistIdx]->Fill(mult, flat, track.pt()); + hPtVsDCAxyMat[kHistIdx]->Fill(track.pt(), track.dcaXY()); + flatchrg.fill(HIST("hPtVsDCAxyMatAll"), track.pt(), track.dcaXY()); + } + } else { + hPtEffRecPrim[kHistIdx]->Fill(mult, flat, track.pt()); + hPtVsDCAxyPrim[kHistIdx]->Fill(track.pt(), track.dcaXY()); + flatchrg.fill(HIST("hPtVsDCAxyPrimAll"), track.pt(), track.dcaXY()); + } + } + + template + void fillMCGen(aod::McParticles::iterator const& mcParticle, const float mult, const float flat) + { + static_assert(pidSgn == 0 || pidSgn == 1); + constexpr int kHistIdx = id + pidSgn * Npart; + + if (!isPID(mcParticle)) { + return; + } + + if constexpr (recoEvt) { + hPtGenRecEvt[kHistIdx]->Fill(mcParticle.pt()); + if (mcParticle.isPhysicalPrimary()) { + hPtGenPrimRecEvt[kHistIdx]->Fill(mcParticle.pt()); + } + return; + } + + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == kProcessIdWeak) { + hPtEffGenWeak[kHistIdx]->Fill(mult, flat, mcParticle.pt()); + } else { + hPtEffGenMat[kHistIdx]->Fill(mult, flat, mcParticle.pt()); + } + } else { + hPtEffGenPrim[kHistIdx]->Fill(mult, flat, mcParticle.pt()); + hPtEffGen[kHistIdx]->Fill(mcParticle.pt()); + } + } + + void processSgnLoss(MCColls::iterator const& mcCollision, + CollsGenSgn const& collisions, + aod::FV0As const& /*fv0s*/, + aod::McParticles const& particles) + { + float flat; + float mult; + if (flatSelOpt.useFlatData) { + float flatRec = 999.0; + float multRec = 999.0; + for (const auto& collision : collisions) { + multRec = getMult(collision); + flatRec = fillFlat(collision); + } + flat = flatRec; + mult = multRec; + flatchrg.fill(HIST("hFlatMCGenRecColl"), flatRec); + } else { + float flatGen = fillFlatMC(particles); + flat = flatGen; + flatchrg.fill(HIST("hFlatMCGen"), flatGen); + float multGen = getMultMC(mcCollision); + mult = multGen; + } + + // Evt loss den + flatchrg.fill(HIST("hEvtMcGen"), 0.5); + if (std::abs(mcCollision.posZ()) > evtSelOpt.cfgCutVtxZ) { + return; + } + flatchrg.fill(HIST("hEvtMcGen"), 1.5); + + bool isINELgt0mc = false; + if (pwglf::isINELgtNmc(particles, 0, pdg)) { + isINELgt0mc = true; + flatchrg.fill(HIST("hEvtMcGen"), 2.5); + flatchrg.fill(HIST("hFlatGenINELgt0"), flat); + } + + // Sgn loss den + for (const auto& particle : particles) { + if (!particle.isPhysicalPrimary()) { + continue; + } + if (std::abs(particle.y()) > trkSelOpt.cfgRapMax) { + continue; + } + static_for<0, 5>([&](auto i) { + constexpr int kIdx = i.value; + if (particle.pdgCode() == PidSgn[kIdx]) { + flatchrg.fill(HIST(kPrefix) + HIST(kSpecies[kIdx]) + HIST(kPtGenPrimSgn), mult, flat, particle.pt()); + if (isINELgt0mc) { + flatchrg.fill(HIST(kPrefix) + HIST(kSpecies[kIdx]) + HIST(kPtGenPrimSgnINEL), mult, flat, particle.pt()); + } + } + }); + } + + int nRecCollINEL = 0; + int nRecCollINELgt0 = 0; + for (const auto& collision : collisions) { + // Evt split num + flatchrg.fill(HIST("hEvtMCRec"), 0.5); + if (!isGoodEvent(collision)) { + continue; + } + flatchrg.fill(HIST("hEvtMCRec"), 1.5); + + nRecCollINEL++; + + if (collision.isInelGt0() && isINELgt0mc) { + flatchrg.fill(HIST("hEvtMCRec"), 2.5); + nRecCollINELgt0++; + } + // Sgn split num + for (const auto& particle : particles) { + if (!particle.isPhysicalPrimary()) { + continue; + } + if (std::abs(particle.y()) > trkSelOpt.cfgRapMax) { + continue; + } + static_for<0, 5>([&](auto i) { + constexpr int kIdx = i.value; + if (particle.pdgCode() == PidSgn[kIdx]) { + flatchrg.fill(HIST(kPrefix) + HIST(kSpecies[kIdx]) + HIST(kPtRecCollPrimSgn), mult, flat, particle.pt()); + if (nRecCollINELgt0) { + flatchrg.fill(HIST(kPrefix) + HIST(kSpecies[kIdx]) + HIST(kPtRecCollPrimSgnINEL), mult, flat, particle.pt()); + } + } + }); + } + } + + if (nRecCollINEL < 1) { + return; + } + // Evt loss num + flatchrg.fill(HIST("hEvtMcGenRecColl"), 0.5); + if (nRecCollINELgt0 > 0) { + flatchrg.fill(HIST("hEvtMcGenRecColl"), 1.5); + } + + // Sgn loss num + for (const auto& particle : particles) { + if (!particle.isPhysicalPrimary()) { + continue; + } + if (std::abs(particle.y()) > trkSelOpt.cfgRapMax) { + continue; + } + static_for<0, 5>([&](auto i) { + constexpr int kIdx = i.value; + if (particle.pdgCode() == PidSgn[kIdx]) { + flatchrg.fill(HIST(kPrefix) + HIST(kSpecies[kIdx]) + HIST(kPtGenRecCollPrimSgn), mult, flat, particle.pt()); + if (nRecCollINELgt0) { + flatchrg.fill(HIST(kPrefix) + HIST(kSpecies[kIdx]) + HIST(kPtGenRecCollPrimSgnINEL), mult, flat, particle.pt()); + } + } + }); + } + } + PROCESS_SWITCH(FlattenictyPikp, processSgnLoss, "process to calcuate signal/event lossses", false); + + // using Particles = soa::Filtered; + // expressions::Filter primaries = (aod::mcparticle::flags & (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary) == (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary; + + void processMCclosure(Colls::iterator const& collision, + MyPIDTracks const& tracks, + MyLabeledTracks const& mcTrackLabels, + aod::McParticles const& particles, + // Particles const& particles, + aod::FV0As const& /*fv0s*/, + aod::BCsWithTimestamps const& /*bcs*/) + { + const float multRec = getMult(collision); + const float flatRec = fillFlat(collision); + for (const auto& track : tracks) { + if (!track.has_collision()) { + continue; + } + const auto& coll = track.collision_as(); + auto bc = coll.template bc_as(); + auto magField = (ccdbConf.cfgMagField == 0) ? getMagneticField(bc.timestamp()) : ccdbConf.cfgMagField; + + if (!isGoodEvent(coll)) { + continue; + } + if (!isGoodTrack(track, magField)) { + continue; + } + if (!isDCAxyCut(track)) { + continue; + } + const auto& mcLabel = mcTrackLabels.iteratorAt(track.globalIndex()); + const auto& mcParticle = particles.iteratorAt(mcLabel.mcParticleId()); + + static_for<0, 4>([&](auto i) { + constexpr int kIdx = i.value; + if ((std::abs(o2::aod::pidutils::tpcNSigma(track)) < trkSelOpt.cfgNsigmaMax) && std::abs(track.rapidity(o2::track::PID::getMass(kIdx))) <= trkSelOpt.cfgRapMax) { + if (std::fabs(mcParticle.pdgCode()) == PDGs[kIdx]) { + flatchrg.fill(HIST(kPrefix) + HIST(kSpeciesAll[kIdx]) + HIST(kPtMCclosurePrim), multRec, flatRec, track.pt()); + } + } + }); + } + } + PROCESS_SWITCH(FlattenictyPikp, processMCclosure, "process MC closure test", false); + + Preslice perCollTrk = aod::track::collisionId; + PresliceUnsorted perCollMcLabel = aod::mccollisionlabel::mcCollisionId; + Preslice perCollMcPart = aod::mcparticle::mcCollisionId; + + void processMC(MCColls const& mcCollisions, + CollsGen const& collisions, + MyLabeledPIDTracks const& tracks, + aod::McParticles const& mcparticles) + { + flatchrg.fill(HIST("hEvtGenRec"), 1.f, mcCollisions.size()); + flatchrg.fill(HIST("hEvtGenRec"), 2.f, collisions.size()); + + for (const auto& mcCollision : mcCollisions) { + if (mcCollision.isInelGt0()) { + flatchrg.fill(HIST("hEvtGenRec"), 3.f); + } + flatchrg.fill(HIST("hEvtMcGenColls"), 1); + const auto groupedColls = collisions.sliceBy(perCollMcLabel, mcCollision.globalIndex()); + const auto groupedParts = mcparticles.sliceBy(perCollMcPart, mcCollision.globalIndex()); + const float flatMC = fillFlatMC(groupedParts); + const float multMC = getMultMC(mcCollision); + if (groupedColls.size() < 1) { // if MC events have no rec collisions + continue; + } + flatchrg.fill(HIST("hEvtMcGenColls"), 2); + for (const auto& collision : groupedColls) { + flatchrg.fill(HIST("hEvtMcGenColls"), 3); + if (!isGoodEvent(collision)) { + continue; + } + flatchrg.fill(HIST("hEvtMcGenColls"), 4); + const auto groupedTrks = tracks.sliceBy(perCollTrk, collision.globalIndex()); + for (const auto& track : groupedTrks) { + if (!isDCAxyWoCut(track)) { + continue; + } + if (!track.has_mcParticle()) { + flatchrg.fill(HIST("PtOutFakes"), track.pt()); + continue; + } + const auto& mcParticle = track.mcParticle(); + if (std::abs(mcParticle.y()) > trkSelOpt.cfgRapMax) { + continue; + } + if (!track.has_collision()) { + continue; + } + static_for<0, 1>([&](auto pidSgn) { + fillMCRecTrack(track, multMC, flatMC); + fillMCRecTrack(track, multMC, flatMC); + fillMCRecTrack(track, multMC, flatMC); + }); + } + + if (std::abs(mcCollision.posZ()) > evtSelOpt.cfgCutVtxZ) { + continue; + } + + if (evtSelOpt.cfgINELCut.value) { + if (!o2::pwglf::isINELgt0mc(groupedParts, pdg)) { + continue; + } + } + + for (const auto& particle : groupedParts) { + if (std::abs(particle.y()) > trkSelOpt.cfgRapMax) { + continue; + } + static_for<0, 1>([&](auto pidSgn) { + fillMCGen(particle, multMC, flatMC); + fillMCGen(particle, multMC, flatMC); + fillMCGen(particle, multMC, flatMC); + }); + } + } // reco collisions + + if (evtSelOpt.cfgINELCut.value) { + if (!o2::pwglf::isINELgt0mc(groupedParts, pdg)) { + continue; + } + } + + for (const auto& mcParticle : groupedParts) { + if (std::abs(mcParticle.y()) > trkSelOpt.cfgRapMax) { + continue; + } + static_for<0, 1>([&](auto pidSgn) { + fillMCGen(mcParticle, multMC, flatMC); + fillMCGen(mcParticle, multMC, flatMC); + fillMCGen(mcParticle, multMC, flatMC); + }); + } + + static_for<0, 1>([&](auto pidSgn) { + fillEfficiency(); + fillEfficiency(); + fillEfficiency(); + }); + + } // gen collisions + } + PROCESS_SWITCH(FlattenictyPikp, processMC, "process MC", false); + + template + ObjType* getForTsOrRun(std::string const& fullPath, int64_t timestamp, int runNumber) + { + if (cfgUseCcdbForRun) { + return ccdb->getForRun(fullPath, runNumber); + } else { + return ccdb->getForTimeStamp(fullPath, timestamp); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/GlobalEventProperties/heavyionMultiplicity.cxx b/PWGLF/Tasks/GlobalEventProperties/heavyionMultiplicity.cxx new file mode 100644 index 00000000000..b91db8d09e0 --- /dev/null +++ b/PWGLF/Tasks/GlobalEventProperties/heavyionMultiplicity.cxx @@ -0,0 +1,853 @@ +// 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. +/// +/// \file heavyionMultiplicity.cxx +/// +/// \brief task for analysis of charged-particle multiplicity at midrapidity +/// \author Abhi Modak (abhi.modak@cern.ch) +/// \since September 15, 2023 + +#include +#include +#include +#include + +#include "PWGMM/Mult/DataModel/bestCollisionTable.h" +#include "CCDB/BasicCCDBManager.h" +#include "Common/Core/trackUtilities.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "CommonConstants/MathConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/GlobalTrackID.h" +#include "ReconstructionDataFormats/Track.h" +#include "PWGMM/Mult/DataModel/Index.h" +#include "Common/DataModel/PIDResponse.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::track; +using namespace o2::aod::evsel; + +using CollisionDataTable = soa::Join; +using ColDataTablepp = soa::Join; +using TrackDataTable = soa::Join; +using FilTrackDataTable = soa::Filtered; +using CollisionMCTrueTable = aod::McCollisions; +using TrackMCTrueTable = aod::McParticles; +using CollisionMCRecTable = soa::SmallGroups>; +using ColMCRecTablepp = soa::SmallGroups>; +using TrackMCRecTable = soa::Join; +using FilTrackMCRecTable = soa::Filtered; +using V0TrackCandidates = soa::Join; + +enum { + kTrackTypebegin = 0, + kGlobalplusITS = 1, + kGlobalonly, + kITSonly, + kTrackTypeend +}; + +enum { + kGenpTbegin = 0, + kNoGenpTVar = 1, + kGenpTup, + kGenpTdown, + kGenpTend +}; + +enum { + kSpeciesbegin = 0, + kSpPion = 1, + kSpKaon, + kSpProton, + kSpOther, + kSpStrangeDecay, + kBkg, + kSpNotPrimary, + kSpAll, + kSpeciesend +}; + +static constexpr TrackSelectionFlags::flagtype TrackSelectionIts = + TrackSelectionFlags::kITSNCls | TrackSelectionFlags::kITSChi2NDF | + TrackSelectionFlags::kITSHits; +static constexpr TrackSelectionFlags::flagtype TrackSelectionTpc = + TrackSelectionFlags::kTPCNCls | + TrackSelectionFlags::kTPCCrossedRowsOverNCls | + TrackSelectionFlags::kTPCChi2NDF; +static constexpr TrackSelectionFlags::flagtype TrackSelectionDca = + TrackSelectionFlags::kDCAz | TrackSelectionFlags::kDCAxy; +static constexpr TrackSelectionFlags::flagtype TrackSelectionDcaxyOnly = + TrackSelectionFlags::kDCAxy; + +AxisSpec axisEvent{10, 0.5, 10.5, "#Event", "EventAxis"}; +AxisSpec axisVtxZ{40, -20, 20, "Vertex Z", "VzAxis"}; +AxisSpec axisEta{40, -2, 2, "#eta", "EtaAxis"}; +AxisSpec axisPhi{{0, o2::constants::math::PIQuarter, o2::constants::math::PIHalf, o2::constants::math::PIQuarter * 3., o2::constants::math::PI, o2::constants::math::PIQuarter * 5., o2::constants::math::PIHalf * 3., o2::constants::math::PIQuarter * 7., o2::constants::math::TwoPI}, "#phi", "PhiAxis"}; +AxisSpec axisPhi2{629, 0, o2::constants::math::TwoPI, "#phi"}; +AxisSpec axisCent{100, 0, 100, "#Cent"}; +AxisSpec axisTrackType = {kTrackTypeend - 1, +kTrackTypebegin + 0.5, +kTrackTypeend - 0.5, "", "TrackTypeAxis"}; +AxisSpec axisGenPtVary = {kGenpTend - 1, +kGenpTbegin + 0.5, +kGenpTend - 0.5, "", "GenpTVaryAxis"}; +AxisSpec axisSpecies = {kSpeciesend - 1, +kSpeciesbegin + 0.5, +kSpeciesend - 0.5, "", "SpeciesAxis"}; +AxisSpec axisMassK0s = {200, 0.4, 0.6, "K0sMass", "K0sMass"}; +AxisSpec axisMassLambda = {200, 1.07, 1.17, "Lambda/AntiLamda Mass", "Lambda/AntiLamda Mass"}; +AxisSpec axisTracks{9, 0.5, 9.5, "#tracks", "TrackAxis"}; +auto static constexpr kMinCharge = 3.f; +auto static constexpr kMinpTcut = 0.1f; +auto static constexpr kEtaInelgt0 = 1.0f; +auto static constexpr kNItslayers = 7; + +struct HeavyionMultiplicity { + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Service pdg; + Preslice perCollision = aod::track::collisionId; + + Configurable etaRange{"etaRange", 1.0f, "Eta range to consider"}; + Configurable vtxRange{"vtxRange", 10.0f, "Vertex Z range to consider"}; + Configurable dcaZ{"dcaZ", 0.2f, "Custom DCA Z cut (ignored if negative)"}; + Configurable v0radiusCut{"v0radiusCut", 1.2f, "RadiusCut"}; + Configurable dcapostopvCut{"dcapostopvCut", 0.05f, "dcapostopvCut"}; + Configurable dcanegtopvCut{"dcanegtopvCut", 0.05f, "dcanegtopvCut"}; + Configurable v0cospaCut{"v0cospaCut", 0.995f, "v0cospaCut"}; + Configurable dcav0daughtercut{"dcav0daughtercut", 1.0f, "dcav0daughtercut"}; + Configurable minTPCnClsCut{"minTPCnClsCut", 50.0f, "minTPCnClsCut"}; + Configurable nSigmaTpcCut{"nSigmaTpcCut", 5.0f, "nSigmaTpcCut"}; + Configurable v0etaCut{"v0etaCut", 0.9f, "v0etaCut"}; + Configurable extraphicut1{"extraphicut1", 3.07666f, "Extra Phi cut 1"}; + Configurable extraphicut2{"extraphicut2", 3.12661f, "Extra Phi cut 2"}; + Configurable extraphicut3{"extraphicut3", 0.03f, "Extra Phi cut 3"}; + Configurable extraphicut4{"extraphicut4", 6.253f, "Extra Phi cut 4"}; + ConfigurableAxis multHistBin{"multHistBin", {501, -0.5, 500.5}, ""}; + ConfigurableAxis pvHistBin{"pvHistBin", {501, -0.5, 500.5}, ""}; + ConfigurableAxis fv0aMultHistBin{"fv0aMultHistBin", {501, -0.5, 500.5}, ""}; + ConfigurableAxis ft0aMultHistBin{"ft0aMultHistBin", {501, -0.5, 500.5}, ""}; + ConfigurableAxis ft0cMultHistBin{"ft0cMultHistBin", {501, -0.5, 500.5}, ""}; + ConfigurableAxis ptHistBin{"ptHistBin", {200, 0., 20.}, ""}; + ConfigurableAxis centralityBinning{"centralityBinning", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, ""}; + ConfigurableAxis occupancyBin{"occupancyBin", {VARIABLE_WIDTH, 0, 500, 1000, 2000, 5000, 10000}, ""}; + ConfigurableAxis centBinGen{"centBinGen", {VARIABLE_WIDTH, 0, 500, 1000, 2000, 5000, 10000}, ""}; + + Configurable isApplySameBunchPileup{"isApplySameBunchPileup", true, "Enable SameBunchPileup cut"}; + Configurable isApplyGoodZvtxFT0vsPV{"isApplyGoodZvtxFT0vsPV", true, "Enable GoodZvtxFT0vsPV cut"}; + Configurable isApplyExtraCorrCut{"isApplyExtraCorrCut", false, "Enable extra NPVtracks vs FTOC correlation cut"}; + Configurable isApplyExtraPhiCut{"isApplyExtraPhiCut", false, "Enable extra phi cut"}; + Configurable npvTracksCut{"npvTracksCut", 1.0f, "Apply extra NPVtracks cut"}; + Configurable ft0cCut{"ft0cCut", 1.0f, "Apply extra FT0C cut"}; + Configurable isApplyNoCollInTimeRangeStandard{"isApplyNoCollInTimeRangeStandard", true, "Enable NoCollInTimeRangeStandard cut"}; + Configurable isApplyNoCollInRofStandard{"isApplyNoCollInRofStandard", false, "Enable NoCollInRofStandard cut"}; + Configurable isApplyNoHighMultCollInPrevRof{"isApplyNoHighMultCollInPrevRof", false, "Enable NoHighMultCollInPrevRof cut"}; + Configurable isApplyFT0CbasedOccupancy{"isApplyFT0CbasedOccupancy", false, "Enable FT0CbasedOccupancy cut"}; + Configurable isApplyCentFT0C{"isApplyCentFT0C", true, "Centrality based on FT0C"}; + Configurable isApplyCentFT0CVariant1{"isApplyCentFT0CVariant1", false, "Centrality based on FT0C variant1"}; + Configurable isApplyCentFT0M{"isApplyCentFT0M", false, "Centrality based on FT0A + FT0C"}; + Configurable isApplyCentNGlobal{"isApplyCentNGlobal", false, "Centrality based on global tracks"}; + Configurable isApplyCentMFT{"isApplyCentMFT", false, "Centrality based on MFT tracks"}; + + void init(InitContext const&) + { + AxisSpec axisMult = {multHistBin, "Mult", "MultAxis"}; + AxisSpec axisPV = {pvHistBin, "PV", "PVAxis"}; + AxisSpec axisFv0aMult = {fv0aMultHistBin, "fv0a", "FV0AMultAxis"}; + AxisSpec axisFt0aMult = {ft0aMultHistBin, "ft0a", "FT0AMultAxis"}; + AxisSpec axisFt0cMult = {ft0cMultHistBin, "ft0c", "FT0CMultAxis"}; + AxisSpec centAxis = {centralityBinning, "Centrality", "CentralityAxis"}; + AxisSpec axisPt = {ptHistBin, "pT", "pTAxis"}; + AxisSpec axisOccupancy = {occupancyBin, "occupancy", "OccupancyAxis"}; + AxisSpec axisCentBinGen = {centBinGen, "GenCentrality", "CentGenAxis"}; + + histos.add("EventHist", "EventHist", kTH1D, {axisEvent}, false); + histos.add("VtxZHist", "VtxZHist", kTH1D, {axisVtxZ}, false); + + auto hstat = histos.get(HIST("EventHist")); + auto* x = hstat->GetXaxis(); + x->SetBinLabel(1, "All events"); + x->SetBinLabel(2, "sel8"); + x->SetBinLabel(3, "kNoSameBunchPileup"); // reject collisions in case of pileup with another collision in the same foundBC + x->SetBinLabel(4, "kIsGoodZvtxFT0vsPV"); // small difference between z-vertex from PV and from FT0 + x->SetBinLabel(5, "ApplyExtraCorrCut"); + x->SetBinLabel(6, "ApplyNoCollInTimeRangeStandard"); + x->SetBinLabel(7, "ApplyNoCollInRofStandard"); + x->SetBinLabel(8, "ApplyNoHighMultCollInPrevRof"); + + if (doprocessData) { + histos.add("CentPercentileHist", "CentPercentileHist", kTH1D, {axisCent}, false); + histos.add("hdatazvtxcent", "hdatazvtxcent", kTH3D, {axisVtxZ, centAxis, axisOccupancy}, false); + histos.add("PhiVsEtaHist", "PhiVsEtaHist", kTH2D, {axisPhi2, axisEta}, false); + histos.add("hdatadndeta", "hdatadndeta", kTHnSparseD, {axisVtxZ, centAxis, axisOccupancy, axisEta, axisPhi, axisTrackType}, false); + } + + if (doprocessMonteCarlo || doprocessMCpTefficiency || doprocessMCcheckFakeTracks) { + histos.add("CentPercentileMCRecHist", "CentPercentileMCRecHist", kTH1D, {axisCent}, false); + histos.add("hmczvtxcent", "hmczvtxcent", kTH3D, {axisVtxZ, centAxis, axisOccupancy}, false); + } + + if (doprocessMonteCarlo) { + histos.add("MCrecPhiVsEtaHist", "MCrecPhiVsEtaHist", kTH2D, {axisPhi2, axisEta}, false); + histos.add("hmcrecdndeta", "hmcrecdndeta", kTHnSparseD, {axisVtxZ, centAxis, axisOccupancy, axisEta, axisPhi, axisSpecies, axisTrackType}, false); + histos.add("hmcgendndeta", "hmcgendndeta", kTHnSparseD, {axisVtxZ, centAxis, axisEta, axisPhi, axisSpecies, axisGenPtVary}, false); + } + + if (doprocessMCpTefficiency) { + histos.add("hmcrecdndpt", "hmcrecdndpt", kTHnSparseD, {centAxis, axisOccupancy, axisTrackType, axisPt}, false); + histos.add("hmcgendndpt", "hmcgendndpt", kTHnSparseD, {centAxis, axisPt, axisGenPtVary}, false); + } + + if (doprocessMCcheckFakeTracks) { + histos.add("hTracksCount", "hTracksCount", kTHnSparseD, {centAxis, axisTracks}, false); + auto htrack = histos.get(HIST("hTracksCount")); + auto* x2 = htrack->GetAxis(1); + x2->SetBinLabel(1, "All tracks"); + x2->SetBinLabel(2, "Non-fake tracks"); + for (int i = 0; i < kNItslayers; i++) { + x2->SetBinLabel(i + 3, Form("layer %d", i)); + } + } + + if (doprocessCorrelation) { + histos.add("GlobalMult_vs_FT0A", "GlobalMult_vs_FT0A", kTH2F, {axisMult, axisFt0aMult}, true); + histos.add("GlobalMult_vs_FT0C", "GlobalMult_vs_FT0C", kTH2F, {axisMult, axisFt0cMult}, true); + histos.add("NPVtracks_vs_FT0C", "NPVtracks_vs_FT0C", kTH2F, {axisPV, axisFt0cMult}, true); + histos.add("GlobalMult_vs_FV0A", "GlobalMult_vs_FV0A", kTH2F, {axisMult, axisFv0aMult}, true); + histos.add("NPVtracks_vs_GlobalMult", "NPVtracks_vs_GlobalMult", kTH2F, {axisPV, axisMult}, true); + } + + if (doprocessStrangeYield) { + histos.add("hzvtxcent", "hzvtxcent", kTH2D, {axisVtxZ, centAxis}, false); + histos.add("K0sCentEtaMass", "K0sCentEtaMass", kTH3D, {centAxis, axisEta, axisMassK0s}, false); + histos.add("LambdaCentEtaMass", "LambdaCentEtaMass", kTH3D, {centAxis, axisEta, axisMassLambda}, false); + histos.add("AntiLambdaCentEtaMass", "AntiLambdaCentEtaMass", kTH3D, {centAxis, axisEta, axisMassLambda}, false); + } + + if (doprocessppData) { + histos.add("MultPercentileHist", "MultPercentileHist", kTH1D, {axisCent}, false); + histos.add("hdatazvtxmultpp", "hdatazvtxmultpp", kTH2D, {axisVtxZ, centAxis}, false); + histos.add("PhiVsEtaHistpp", "PhiVsEtaHistpp", kTH2D, {axisPhi2, axisEta}, false); + histos.add("hdatadndetapp", "hdatadndetapp", kTHnSparseD, {axisVtxZ, centAxis, axisEta, axisPhi, axisTrackType}, false); + } + + if (doprocessppMonteCarlo) { + histos.add("MultPercentileMCRecHist", "MultPercentileMCRecHist", kTH1D, {axisCent}, false); + histos.add("hmczvtxmultpp", "hmczvtxmultpp", kTH2D, {axisVtxZ, centAxis}, false); + histos.add("MCrecPhiVsEtaHistpp", "MCrecPhiVsEtaHistpp", kTH2D, {axisPhi2, axisEta}, false); + histos.add("hmcrecdndetapp", "hmcrecdndetapp", kTHnSparseD, {axisVtxZ, centAxis, axisEta, axisPhi, axisSpecies, axisTrackType}, false); + histos.add("hmcgendndetapp", "hmcgendndetapp", kTHnSparseD, {axisVtxZ, centAxis, axisEta, axisPhi, axisSpecies, axisGenPtVary}, false); + } + + if (doprocessGen) { + histos.add("MultBarrelEta10_vs_FT0A", "MultBarrelEta10_vs_FT0A", kTH2F, {axisMult, axisFt0aMult}, true); + histos.add("MultBarrelEta10_vs_FT0C", "MultBarrelEta10_vs_FT0C", kTH2F, {axisMult, axisFt0cMult}, true); + histos.add("MultBarrelEta10", "MultBarrelEta10", kTH1F, {axisMult}, true); + histos.add("MultFT0A", "MultFT0A", kTH1F, {axisFt0aMult}, true); + histos.add("MultFT0C", "MultFT0C", kTH1F, {axisFt0cMult}, true); + histos.add("dndeta10_vs_FT0C", "dndeta10_vs_FT0C", kTH2F, {axisEta, axisCentBinGen}, true); + histos.add("dndeta10_vs_FT0A", "dndeta10_vs_FT0A", kTH2F, {axisEta, axisCentBinGen}, true); + histos.add("mult10_vs_FT0C", "mult10_vs_FT0C", kTH2F, {axisMult, axisCentBinGen}, true); + histos.add("mult10_vs_FT0A", "mult10_vs_FT0A", kTH2F, {axisMult, axisCentBinGen}, true); + } + } + + template + bool isEventSelected(CheckCol const& col) + { + histos.fill(HIST("EventHist"), 1); + + if (!col.sel8()) { + return false; + } + histos.fill(HIST("EventHist"), 2); + + if (isApplySameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + histos.fill(HIST("EventHist"), 3); + + if (isApplyGoodZvtxFT0vsPV && !col.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + histos.fill(HIST("EventHist"), 4); + + if (isApplyExtraCorrCut && col.multNTracksPV() > npvTracksCut && col.multFT0C() < (10 * col.multNTracksPV() - ft0cCut)) { + return false; + } + histos.fill(HIST("EventHist"), 5); + + if (isApplyNoCollInTimeRangeStandard && !col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + histos.fill(HIST("EventHist"), 6); + + if (isApplyNoCollInRofStandard && !col.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + histos.fill(HIST("EventHist"), 7); + + if (isApplyNoHighMultCollInPrevRof && !col.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return false; + } + histos.fill(HIST("EventHist"), 8); + return true; + } + + template + float selColCent(CheckColCent const& col) + { + auto cent = -1; + if (isApplyCentFT0C) { + cent = col.centFT0C(); + } + if (isApplyCentFT0CVariant1) { + cent = col.centFT0CVariant1(); + } + if (isApplyCentFT0M) { + cent = col.centFT0M(); + } + if (isApplyCentNGlobal) { + cent = col.centNGlobal(); + } + if (isApplyCentMFT) { + cent = col.centMFT(); + } + return cent; + } + + template + float selColOccu(CheckColOccu const& col) + { + auto occu = isApplyFT0CbasedOccupancy ? col.ft0cOccupancyInTimeRange() : col.trackOccupancyInTimeRange(); + return occu; + } + + template + bool isTrackSelected(CheckTrack const& track) + { + if (std::abs(track.eta()) >= etaRange) { + return false; + } + if (isApplyExtraPhiCut && ((track.phi() > extraphicut1 && track.phi() < extraphicut2) || track.phi() <= extraphicut3 || track.phi() >= extraphicut4)) { + return false; + } + return true; + } + + template + bool isGenTrackSelected(CheckGenTrack const& track) + { + if (!track.isPhysicalPrimary()) { + return false; + } + if (!track.producedByGenerator()) { + return false; + } + auto pdgTrack = pdg->GetParticle(track.pdgCode()); + if (pdgTrack == nullptr) { + return false; + } + if (std::abs(pdgTrack->Charge()) < kMinCharge) { + return false; + } + if (std::abs(track.eta()) >= etaRange) { + return false; + } + if (isApplyExtraPhiCut && ((track.phi() > extraphicut1 && track.phi() < extraphicut2) || track.phi() <= extraphicut3 || track.phi() >= extraphicut4)) { + return false; + } + return true; + } + + expressions::Filter trackSelectionProperMixed = ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) && + ncheckbit(aod::track::trackCutFlag, TrackSelectionIts) && + ifnode(ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC), + ncheckbit(aod::track::trackCutFlag, TrackSelectionTpc), true) && + ifnode(dcaZ.node() > 0.f, nabs(aod::track::dcaZ) <= dcaZ && ncheckbit(aod::track::trackCutFlag, TrackSelectionDcaxyOnly), + ncheckbit(aod::track::trackCutFlag, TrackSelectionDca)); + + void processData(CollisionDataTable::iterator const& cols, FilTrackDataTable const& tracks) + { + if (!isEventSelected(cols)) { + return; + } + histos.fill(HIST("VtxZHist"), cols.posZ()); + histos.fill(HIST("CentPercentileHist"), selColCent(cols)); + histos.fill(HIST("hdatazvtxcent"), cols.posZ(), selColCent(cols), selColOccu(cols)); + + for (const auto& track : tracks) { + if (!isTrackSelected(track)) { + continue; + } + histos.fill(HIST("PhiVsEtaHist"), track.phi(), track.eta()); + histos.fill(HIST("hdatadndeta"), cols.posZ(), selColCent(cols), selColOccu(cols), track.eta(), track.phi(), kGlobalplusITS); + if (track.hasTPC()) { + histos.fill(HIST("hdatadndeta"), cols.posZ(), selColCent(cols), selColOccu(cols), track.eta(), track.phi(), kGlobalonly); + } else { + histos.fill(HIST("hdatadndeta"), cols.posZ(), selColCent(cols), selColOccu(cols), track.eta(), track.phi(), kITSonly); + } + } + } + PROCESS_SWITCH(HeavyionMultiplicity, processData, "process data CentFT0C", false); + + void processCorrelation(CollisionDataTable::iterator const& cols, FilTrackDataTable const& tracks) + { + if (!isEventSelected(cols)) { + return; + } + if (std::abs(cols.posZ()) >= vtxRange) { + return; + } + histos.fill(HIST("VtxZHist"), cols.posZ()); + + auto nchTracks = 0; + for (const auto& track : tracks) { + if (std::abs(track.eta()) >= etaRange) { + continue; + } + nchTracks++; + } + histos.fill(HIST("GlobalMult_vs_FT0A"), nchTracks, cols.multFT0A()); + histos.fill(HIST("GlobalMult_vs_FT0C"), nchTracks, cols.multFT0C()); + histos.fill(HIST("NPVtracks_vs_FT0C"), cols.multNTracksPV(), cols.multFT0C()); + histos.fill(HIST("GlobalMult_vs_FV0A"), nchTracks, cols.multFV0A()); + histos.fill(HIST("NPVtracks_vs_GlobalMult"), cols.multNTracksPV(), nchTracks); + } + PROCESS_SWITCH(HeavyionMultiplicity, processCorrelation, "do correlation study in data", false); + + void processMonteCarlo(CollisionMCTrueTable::iterator const&, CollisionMCRecTable const& RecCols, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + { + for (const auto& RecCol : RecCols) { + if (!isEventSelected(RecCol)) { + continue; + } + histos.fill(HIST("VtxZHist"), RecCol.posZ()); + histos.fill(HIST("CentPercentileMCRecHist"), selColCent(RecCol)); + histos.fill(HIST("hmczvtxcent"), RecCol.posZ(), selColCent(RecCol), selColOccu(RecCol)); + + auto recTracksPart = RecTracks.sliceBy(perCollision, RecCol.globalIndex()); + std::vector mclabels; + for (const auto& Rectrack : recTracksPart) { + if (!isTrackSelected(Rectrack)) { + continue; + } + histos.fill(HIST("MCrecPhiVsEtaHist"), Rectrack.phi(), Rectrack.eta()); + histos.fill(HIST("hmcrecdndeta"), RecCol.posZ(), selColCent(RecCol), selColOccu(RecCol), Rectrack.eta(), Rectrack.phi(), static_cast(kSpAll), kGlobalplusITS); + if (Rectrack.hasTPC()) { + histos.fill(HIST("hmcrecdndeta"), RecCol.posZ(), selColCent(RecCol), selColOccu(RecCol), Rectrack.eta(), Rectrack.phi(), static_cast(kSpAll), kGlobalonly); + } else { + histos.fill(HIST("hmcrecdndeta"), RecCol.posZ(), selColCent(RecCol), selColOccu(RecCol), Rectrack.eta(), Rectrack.phi(), static_cast(kSpAll), kITSonly); + } + + if (Rectrack.has_mcParticle()) { + int pid = kBkg; + auto mcpart = Rectrack.template mcParticle_as(); + if (mcpart.isPhysicalPrimary()) { + switch (std::abs(mcpart.pdgCode())) { + case PDG_t::kPiPlus: + pid = kSpPion; + break; + case PDG_t::kKPlus: + pid = kSpKaon; + break; + case PDG_t::kProton: + pid = kSpProton; + break; + default: + pid = kSpOther; + break; + } + } else { + pid = kSpNotPrimary; + } + if (mcpart.has_mothers()) { + auto mcpartMother = mcpart.template mothers_as().front(); + if (mcpartMother.pdgCode() == PDG_t::kK0Short || std::abs(mcpartMother.pdgCode()) == PDG_t::kLambda0) { + pid = kSpStrangeDecay; + } + } + if (find(mclabels.begin(), mclabels.end(), Rectrack.mcParticleId()) != mclabels.end()) { + pid = kBkg; + } + mclabels.push_back(Rectrack.mcParticleId()); + histos.fill(HIST("hmcrecdndeta"), RecCol.posZ(), selColCent(RecCol), selColOccu(RecCol), Rectrack.eta(), Rectrack.phi(), static_cast(pid), kGlobalplusITS); + } else { + histos.fill(HIST("hmcrecdndeta"), RecCol.posZ(), selColCent(RecCol), selColOccu(RecCol), Rectrack.eta(), Rectrack.phi(), static_cast(kBkg), kGlobalplusITS); + } + } // track (mcrec) loop + + for (const auto& particle : GenParticles) { + if (!isGenTrackSelected(particle)) { + continue; + } + histos.fill(HIST("hmcgendndeta"), RecCol.posZ(), selColCent(RecCol), particle.eta(), particle.phi(), static_cast(kSpAll), kNoGenpTVar); + if (particle.pt() < kMinpTcut) { + histos.fill(HIST("hmcgendndeta"), RecCol.posZ(), selColCent(RecCol), particle.eta(), particle.phi(), static_cast(kSpAll), kGenpTup, -10.0 * particle.pt() + 2); + histos.fill(HIST("hmcgendndeta"), RecCol.posZ(), selColCent(RecCol), particle.eta(), particle.phi(), static_cast(kSpAll), kGenpTdown, 5.0 * particle.pt() + 0.5); + } else { + histos.fill(HIST("hmcgendndeta"), RecCol.posZ(), selColCent(RecCol), particle.eta(), particle.phi(), static_cast(kSpAll), kGenpTup); + histos.fill(HIST("hmcgendndeta"), RecCol.posZ(), selColCent(RecCol), particle.eta(), particle.phi(), static_cast(kSpAll), kGenpTdown); + } + + int pid = 0; + switch (std::abs(particle.pdgCode())) { + case PDG_t::kPiPlus: + pid = kSpPion; + break; + case PDG_t::kKPlus: + pid = kSpKaon; + break; + case PDG_t::kProton: + pid = kSpProton; + break; + default: + pid = kSpOther; + break; + } + histos.fill(HIST("hmcgendndeta"), RecCol.posZ(), selColCent(RecCol), particle.eta(), particle.phi(), static_cast(pid), kNoGenpTVar); + } // track (mcgen) loop + } // collision loop + } + PROCESS_SWITCH(HeavyionMultiplicity, processMonteCarlo, "process MC CentFT0C", false); + + void processMCpTefficiency(CollisionMCTrueTable::iterator const&, CollisionMCRecTable const& RecCols, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + { + for (const auto& RecCol : RecCols) { + if (!isEventSelected(RecCol)) { + continue; + } + if (std::abs(RecCol.posZ()) >= vtxRange) { + continue; + } + histos.fill(HIST("VtxZHist"), RecCol.posZ()); + histos.fill(HIST("CentPercentileMCRecHist"), selColCent(RecCol)); + histos.fill(HIST("hmczvtxcent"), RecCol.posZ(), selColCent(RecCol), selColOccu(RecCol)); + + auto recTracksPart = RecTracks.sliceBy(perCollision, RecCol.globalIndex()); + for (const auto& Rectrack : recTracksPart) { + if (std::abs(Rectrack.eta()) >= etaRange) { + continue; + } + if (Rectrack.has_mcParticle()) { + auto mcpart = Rectrack.mcParticle(); + if (mcpart.isPhysicalPrimary()) { + histos.fill(HIST("hmcrecdndpt"), selColCent(RecCol), selColOccu(RecCol), kGlobalplusITS, mcpart.pt()); + if (Rectrack.hasTPC()) { + histos.fill(HIST("hmcrecdndpt"), selColCent(RecCol), selColOccu(RecCol), kGlobalonly, mcpart.pt()); + } else { + histos.fill(HIST("hmcrecdndpt"), selColCent(RecCol), selColOccu(RecCol), kITSonly, mcpart.pt()); + } + } + } + } + + for (const auto& particle : GenParticles) { + if (!isGenTrackSelected(particle)) { + continue; + } + histos.fill(HIST("hmcgendndpt"), selColCent(RecCol), particle.pt(), kNoGenpTVar); + if (particle.pt() < kMinpTcut) { + histos.fill(HIST("hmcgendndpt"), selColCent(RecCol), particle.pt(), kGenpTup, -10.0 * particle.pt() + 2); + histos.fill(HIST("hmcgendndpt"), selColCent(RecCol), particle.pt(), kGenpTdown, 5.0 * particle.pt() + 0.5); + } else { + histos.fill(HIST("hmcgendndpt"), selColCent(RecCol), particle.pt(), kGenpTup); + histos.fill(HIST("hmcgendndpt"), selColCent(RecCol), particle.pt(), kGenpTdown); + } + } + } + } + PROCESS_SWITCH(HeavyionMultiplicity, processMCpTefficiency, "process MC pTefficiency", false); + + void processMCcheckFakeTracks(CollisionMCTrueTable::iterator const&, CollisionMCRecTable const& RecCols, FilTrackMCRecTable const& RecTracks) + { + for (const auto& RecCol : RecCols) { + if (!isEventSelected(RecCol)) { + continue; + } + if (std::abs(RecCol.posZ()) >= vtxRange) { + continue; + } + histos.fill(HIST("VtxZHist"), RecCol.posZ()); + histos.fill(HIST("CentPercentileMCRecHist"), selColCent(RecCol)); + histos.fill(HIST("hmczvtxcent"), RecCol.posZ(), selColCent(RecCol), selColOccu(RecCol)); + + auto recTracksPart = RecTracks.sliceBy(perCollision, RecCol.globalIndex()); + for (const auto& Rectrack : recTracksPart) { + if (std::abs(Rectrack.eta()) >= etaRange) { + continue; + } + if (!Rectrack.hasTPC()) { + continue; + } + histos.fill(HIST("hTracksCount"), selColCent(RecCol), 1); + bool isFakeItsTracks = false; + for (int i = 0; i < kNItslayers; i++) { + if (Rectrack.mcMask() & 1 << i) { + isFakeItsTracks = true; + histos.fill(HIST("hTracksCount"), selColCent(RecCol), i + 3); + break; + } + } + if (isFakeItsTracks) { + continue; + } + histos.fill(HIST("hTracksCount"), selColCent(RecCol), 2); + } + } + } + PROCESS_SWITCH(HeavyionMultiplicity, processMCcheckFakeTracks, "Check Fake tracks", false); + + void processStrangeYield(CollisionDataTable::iterator const& cols, V0TrackCandidates const&, aod::V0Datas const& v0data) + { + if (!isEventSelected(cols)) { + return; + } + if (std::abs(cols.posZ()) >= vtxRange) { + return; + } + histos.fill(HIST("hzvtxcent"), cols.posZ(), selColCent(cols)); + for (const auto& v0track : v0data) { + auto v0pTrack = v0track.template posTrack_as(); + auto v0nTrack = v0track.template negTrack_as(); + if (std::abs(v0pTrack.eta()) > v0etaCut || std::abs(v0nTrack.eta()) > v0etaCut) { + continue; + } + if (v0pTrack.tpcNClsFound() < minTPCnClsCut) { + continue; + } + if (v0nTrack.tpcNClsFound() < minTPCnClsCut) { + continue; + } + if (std::abs(v0pTrack.tpcNSigmaPi()) > nSigmaTpcCut) { + continue; + } + if (std::abs(v0nTrack.tpcNSigmaPi()) > nSigmaTpcCut) { + continue; + } + if (std::abs(v0pTrack.tpcNSigmaPr()) > nSigmaTpcCut) { + continue; + } + if (std::abs(v0nTrack.tpcNSigmaPr()) > nSigmaTpcCut) { + continue; + } + if (std::abs(v0track.dcapostopv()) < dcapostopvCut || std::abs(v0track.dcanegtopv()) < dcanegtopvCut || v0track.v0radius() < v0radiusCut || v0track.v0cosPA() < v0cospaCut || std::abs(v0track.dcaV0daughters()) > dcav0daughtercut) { + continue; + } + histos.fill(HIST("K0sCentEtaMass"), selColCent(cols), v0track.eta(), v0track.mK0Short()); + histos.fill(HIST("LambdaCentEtaMass"), selColCent(cols), v0track.eta(), v0track.mLambda()); + histos.fill(HIST("AntiLambdaCentEtaMass"), selColCent(cols), v0track.eta(), v0track.mAntiLambda()); + } + } + PROCESS_SWITCH(HeavyionMultiplicity, processStrangeYield, "Strange particle yield", false); + + void processppData(ColDataTablepp::iterator const& cols, FilTrackDataTable const& tracks) + { + if (!isEventSelected(cols)) { + return; + } + + // INEL>0 sample + auto nTrks = 0; + for (const auto& track : tracks) { + if (!isTrackSelected(track)) { + continue; + } + if (track.eta() < kEtaInelgt0) { + nTrks++; + } + } // track loop + + if (nTrks > 0) { + histos.fill(HIST("EventHist"), 9); + histos.fill(HIST("VtxZHist"), cols.posZ()); + histos.fill(HIST("MultPercentileHist"), cols.centFT0M()); + histos.fill(HIST("hdatazvtxmultpp"), cols.posZ(), cols.centFT0M()); + + for (const auto& track : tracks) { + if (!isTrackSelected(track)) { + continue; + } + histos.fill(HIST("PhiVsEtaHistpp"), track.phi(), track.eta()); + histos.fill(HIST("hdatadndetapp"), cols.posZ(), cols.centFT0M(), track.eta(), track.phi(), kGlobalplusITS); + if (track.hasTPC()) { + histos.fill(HIST("hdatadndetapp"), cols.posZ(), cols.centFT0M(), track.eta(), track.phi(), kGlobalonly); + } else { + histos.fill(HIST("hdatadndetapp"), cols.posZ(), cols.centFT0M(), track.eta(), track.phi(), kITSonly); + } + } // track loop + } // nTrks>0 + } + PROCESS_SWITCH(HeavyionMultiplicity, processppData, "process pp data", false); + + void processppMonteCarlo(CollisionMCTrueTable::iterator const&, ColMCRecTablepp const& RecCols, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + { + for (const auto& RecCol : RecCols) { + if (!isEventSelected(RecCol)) { + continue; + } + auto recTracksPart = RecTracks.sliceBy(perCollision, RecCol.globalIndex()); + std::vector mclabels; + + // INEL>0 sample + auto nTrks = 0; + for (const auto& Rectrack : recTracksPart) { + if (!isTrackSelected(Rectrack)) { + continue; + } + if (Rectrack.eta() < kEtaInelgt0) { + nTrks++; + } + } + + if (nTrks > 0) { + histos.fill(HIST("EventHist"), 9); + histos.fill(HIST("VtxZHist"), RecCol.posZ()); + histos.fill(HIST("MultPercentileMCRecHist"), RecCol.centFT0M()); + histos.fill(HIST("hmczvtxmultpp"), RecCol.posZ(), RecCol.centFT0M()); + + for (const auto& Rectrack : recTracksPart) { + if (!isTrackSelected(Rectrack)) { + continue; + } + histos.fill(HIST("MCrecPhiVsEtaHistpp"), Rectrack.phi(), Rectrack.eta()); + histos.fill(HIST("hmcrecdndetapp"), RecCol.posZ(), RecCol.centFT0M(), Rectrack.eta(), Rectrack.phi(), static_cast(kSpAll), kGlobalplusITS); + if (Rectrack.hasTPC()) { + histos.fill(HIST("hmcrecdndetapp"), RecCol.posZ(), RecCol.centFT0M(), Rectrack.eta(), Rectrack.phi(), static_cast(kSpAll), kGlobalonly); + } else { + histos.fill(HIST("hmcrecdndetapp"), RecCol.posZ(), RecCol.centFT0M(), Rectrack.eta(), Rectrack.phi(), static_cast(kSpAll), kITSonly); + } + + if (Rectrack.has_mcParticle()) { + int pid = kBkg; + auto mcpart = Rectrack.template mcParticle_as(); + if (mcpart.isPhysicalPrimary()) { + switch (std::abs(mcpart.pdgCode())) { + case PDG_t::kPiPlus: + pid = kSpPion; + break; + case PDG_t::kKPlus: + pid = kSpKaon; + break; + case PDG_t::kProton: + pid = kSpProton; + break; + default: + pid = kSpOther; + break; + } + } else { + pid = kSpNotPrimary; + } + if (mcpart.has_mothers()) { + auto mcpartMother = mcpart.template mothers_as().front(); + if (mcpartMother.pdgCode() == PDG_t::kK0Short || std::abs(mcpartMother.pdgCode()) == PDG_t::kLambda0) { + pid = kSpStrangeDecay; + } + } + if (find(mclabels.begin(), mclabels.end(), Rectrack.mcParticleId()) != mclabels.end()) { + pid = kBkg; + } + mclabels.push_back(Rectrack.mcParticleId()); + histos.fill(HIST("hmcrecdndetapp"), RecCol.posZ(), RecCol.centFT0M(), Rectrack.eta(), Rectrack.phi(), static_cast(pid), kGlobalplusITS); + } else { + histos.fill(HIST("hmcrecdndetapp"), RecCol.posZ(), RecCol.centFT0M(), Rectrack.eta(), Rectrack.phi(), static_cast(kBkg), kGlobalplusITS); + } + } // track (mcrec) loop + + for (const auto& particle : GenParticles) { + if (!isGenTrackSelected(particle)) { + continue; + } + histos.fill(HIST("hmcgendndetapp"), RecCol.posZ(), RecCol.centFT0M(), particle.eta(), particle.phi(), static_cast(kSpAll), kNoGenpTVar); + if (particle.pt() < kMinpTcut) { + histos.fill(HIST("hmcgendndetapp"), RecCol.posZ(), RecCol.centFT0M(), particle.eta(), particle.phi(), static_cast(kSpAll), kGenpTup, -10.0 * particle.pt() + 2); + histos.fill(HIST("hmcgendndetapp"), RecCol.posZ(), RecCol.centFT0M(), particle.eta(), particle.phi(), static_cast(kSpAll), kGenpTdown, 5.0 * particle.pt() + 0.5); + } else { + histos.fill(HIST("hmcgendndetapp"), RecCol.posZ(), RecCol.centFT0M(), particle.eta(), particle.phi(), static_cast(kSpAll), kGenpTup); + histos.fill(HIST("hmcgendndetapp"), RecCol.posZ(), RecCol.centFT0M(), particle.eta(), particle.phi(), static_cast(kSpAll), kGenpTdown); + } + + int pid = 0; + switch (std::abs(particle.pdgCode())) { + case PDG_t::kPiPlus: + pid = kSpPion; + break; + case PDG_t::kKPlus: + pid = kSpKaon; + break; + case PDG_t::kProton: + pid = kSpProton; + break; + default: + pid = kSpOther; + break; + } + histos.fill(HIST("hmcgendndetapp"), RecCol.posZ(), RecCol.centFT0M(), particle.eta(), particle.phi(), static_cast(pid), kNoGenpTVar); + } // track (mcgen) loop + } // nTrks>0 + } // collision loop + } + PROCESS_SWITCH(HeavyionMultiplicity, processppMonteCarlo, "process pp MC", false); + + void processGen(aod::McCollisions::iterator const&, aod::McParticles const& GenParticles) + { + + int multFT0A = 0; + int multFT0C = 0; + int multBarrelEta10 = 0; + + for (const auto& particle : GenParticles) { + if (!isGenTrackSelected(particle)) { + continue; + } + if (std::abs(particle.eta()) < 1.0) { + multBarrelEta10++; + } + if (-3.3 < particle.eta() && particle.eta() < -2.1) { + multFT0C++; + } + if (3.5 < particle.eta() && particle.eta() < 4.9) { + multFT0A++; + } + } + + histos.fill(HIST("MultBarrelEta10_vs_FT0A"), multBarrelEta10, multFT0A); + histos.fill(HIST("MultBarrelEta10_vs_FT0C"), multBarrelEta10, multFT0C); + histos.fill(HIST("MultBarrelEta10"), multBarrelEta10); + histos.fill(HIST("MultFT0A"), multFT0A); + histos.fill(HIST("MultFT0C"), multFT0C); + histos.fill(HIST("mult10_vs_FT0A"), multBarrelEta10, multFT0A); + histos.fill(HIST("mult10_vs_FT0C"), multBarrelEta10, multFT0C); + + for (const auto& particle : GenParticles) { + if (!isGenTrackSelected(particle)) { + continue; + } + histos.fill(HIST("dndeta10_vs_FT0A"), particle.eta(), multFT0A); + histos.fill(HIST("dndeta10_vs_FT0C"), particle.eta(), multFT0C); + } + } + PROCESS_SWITCH(HeavyionMultiplicity, processGen, "process pure MC gen", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx b/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx new file mode 100644 index 00000000000..cc56b8fe550 --- /dev/null +++ b/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx @@ -0,0 +1,1801 @@ +// 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. + +/// \file uccZdc.cxx +/// +/// \brief task for analysis of UCC with the ZDC +/// \author Omar Vazquez (omar.vazquez.rueda@cern.ch) +/// \since January 29, 2025 + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/ZDCConstants.h" +#include "Framework/ASoAHelpers.h" // required for Filter op. +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/GlobalTrackID.h" +#include "ReconstructionDataFormats/Track.h" +#include + +#include "TPDGCode.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::evsel; +using namespace o2::constants::physics; +using namespace o2::constants::math; + +namespace o2::aod +{ +using ColEvSels = soa::Join; +using BCsRun3 = soa::Join; +using TracksSel = soa::Join; +using SimCollisions = soa::Join; +using SimTracks = soa::Join; +} // namespace o2::aod + +static constexpr int kSizeBootStrapEnsemble{8}; + +std::array, kSizeBootStrapEnsemble> hNch{}; +std::array, kSizeBootStrapEnsemble> hPoisson{}; +std::array, kSizeBootStrapEnsemble> pNchVsOneParCorrVsZN{}; +std::array, kSizeBootStrapEnsemble> pNchVsTwoParCorrVsZN{}; +std::array, kSizeBootStrapEnsemble> pNchVsThreeParCorrVsZN{}; + +std::array, kSizeBootStrapEnsemble> pOneParCorrVsT0M{}; +std::array, kSizeBootStrapEnsemble> pTwoParCorrVsT0M{}; +std::array, kSizeBootStrapEnsemble> pThreeParCorrVsT0M{}; + +std::array, kSizeBootStrapEnsemble> pOneParCorrVsV0A{}; +std::array, kSizeBootStrapEnsemble> pTwoParCorrVsV0A{}; +std::array, kSizeBootStrapEnsemble> pThreeParCorrVsV0A{}; + +std::array, kSizeBootStrapEnsemble> pOneParCorrVsNch{}; +std::array, kSizeBootStrapEnsemble> pTwoParCorrVsNch{}; +std::array, kSizeBootStrapEnsemble> pThreeParCorrVsNch{}; + +std::array, kSizeBootStrapEnsemble> hPoissonMC{}; +std::array, kSizeBootStrapEnsemble> hNchGen{}; + +// std::array, kSizeBootStrapEnsemble> pOneParCorrVsT0MGen{}; +// std::array, kSizeBootStrapEnsemble> pTwoParCorrVsT0MGen{}; +// std::array, kSizeBootStrapEnsemble> pThreeParCorrVsT0MGen{}; +// +// std::array, kSizeBootStrapEnsemble> pOneParCorrVsV0AGen{}; +// std::array, kSizeBootStrapEnsemble> pTwoParCorrVsV0AGen{}; +// std::array, kSizeBootStrapEnsemble> pThreeParCorrVsV0AGen{}; + +std::array, kSizeBootStrapEnsemble> pOneParCorrVsNchGen{}; +std::array, kSizeBootStrapEnsemble> pTwoParCorrVsNchGen{}; +std::array, kSizeBootStrapEnsemble> pThreeParCorrVsNchGen{}; + +struct UccZdc { + + static constexpr float kCollEnergy{2.68}; + static constexpr float kZero{0.}; + static constexpr float kOne{1.}; + static constexpr float kMinCharge{3.f}; + + // Configurables Event Selection + Configurable isNoCollInTimeRangeStrict{"isNoCollInTimeRangeStrict", true, "use isNoCollInTimeRangeStrict?"}; + Configurable isNoCollInTimeRangeStandard{"isNoCollInTimeRangeStandard", false, "use isNoCollInTimeRangeStandard?"}; + Configurable isNoCollInRofStrict{"isNoCollInRofStrict", true, "use isNoCollInRofStrict?"}; + Configurable isNoCollInRofStandard{"isNoCollInRofStandard", false, "use isNoCollInRofStandard?"}; + Configurable isNoHighMultCollInPrevRof{"isNoHighMultCollInPrevRof", true, "use isNoHighMultCollInPrevRof?"}; + Configurable isNoCollInTimeRangeNarrow{"isNoCollInTimeRangeNarrow", false, "use isNoCollInTimeRangeNarrow?"}; + Configurable isOccupancyCut{"isOccupancyCut", true, "Occupancy cut?"}; + Configurable isApplyFT0CbasedOccupancy{"isApplyFT0CbasedOccupancy", false, "T0C Occu cut"}; + Configurable isTDCcut{"isTDCcut", false, "Use TDC cut"}; + Configurable isZEMcut{"isZEMcut", true, "Use ZEM cut"}; + Configurable useMidRapNchSel{"useMidRapNchSel", true, "Use mid-rapidit Nch selection"}; + Configurable applyEff{"applyEff", true, "Apply track-by-track efficiency correction"}; + Configurable applyFD{"applyFD", false, "Apply track-by-track feed down correction"}; + Configurable correctNch{"correctNch", true, "Correct also Nch"}; + Configurable skipRecoColGTOne{"skipRecoColGTOne", true, "Remove collisions if reconstructed more than once"}; + Configurable detector4Calibration{"detector4Calibration", "T0M", "Detector for nSigma-Nch rejection"}; + + // Event selection + Configurable posZcut{"posZcut", +10.0, "z-vertex position cut"}; + Configurable minT0CcentCut{"minT0CcentCut", 0.0, "Min T0C Cent. cut"}; + Configurable maxT0CcentCut{"maxT0CcentCut", 90.0, "Max T0C Cent. cut"}; + Configurable nSigmaNchCut{"nSigmaNchCut", 1., "nSigma Nch selection"}; + Configurable zemCut{"zemCut", 1000., "ZEM cut"}; + Configurable tdcCut{"tdcCut", 1., "TDC cut"}; + Configurable minOccCut{"minOccCut", 0., "min Occu cut"}; + Configurable maxOccCut{"maxOccCut", 500., "max Occu cut"}; + Configurable minNchSel{"minNchSel", 5., "min Nch Selection"}; + Configurable evtFracMCcl{"evtFracMCcl", 0.5, "fraction of events for MC closure"}; + + // Track-kinematics selection + Configurable minPt{"minPt", 0.1, "minimum pt of the tracks"}; + Configurable maxPt{"maxPt", 3., "maximum pt of the tracks"}; + Configurable maxPtSpectra{"maxPtSpectra", 50., "maximum pt of the tracks"}; + Configurable minEta{"minEta", -0.8, "minimum eta"}; + Configurable maxEta{"maxEta", +0.8, "maximum eta"}; + + // Configurables, binning + Configurable minNch{"minNch", 0, "Min Nch (|eta|<0.8)"}; + Configurable minZN{"minZN", -0.5, "Min ZN signal"}; + Configurable minTdc{"minTdc", -15.0, "minimum TDC"}; + + Configurable maxNch{"maxNch", 3000, "Max Nch (|eta|<0.8)"}; + Configurable maxITSTrack{"maxITSTrack", 6000., "Min ITS tracks"}; + Configurable maxAmpV0A{"maxAmpV0A", 2000, "Max FV0 amp"}; + Configurable maxAmpFT0{"maxAmpFT0", 2500, "Max FT0 amp"}; + Configurable maxAmpFT0A{"maxAmpFT0A", 200, "Max FT0 amp"}; + Configurable maxAmpFT0C{"maxAmpFT0C", 60, "Max FT0 amp"}; + Configurable maxZN{"maxZN", 150, "Max ZN signal"}; + Configurable maxZP{"maxZP", 60, "Max ZP signal"}; + Configurable maxZEM{"maxZEM", 2200, "Max ZEM signal"}; + Configurable maxTdc{"maxTdc", 15.0, "maximum TDC"}; + + Configurable nBinsNch{"nBinsNch", 2501, "N bins Nch (|eta|<0.8)"}; + Configurable nBinsITSTrack{"nBinsITSTrack", 2000, "N bins ITS tracks"}; + Configurable nBinsAmpV0A{"nBinsAmpV0A", 100, "N bins V0A amp"}; + Configurable nBinsAmpFT0{"nBinsAmpFT0", 100, "N bins FT0 amp"}; + Configurable nBinsAmpFT0A{"nBinsAmpFT0A", 100, "N bins FT0A amp"}; + Configurable nBinsAmpFT0C{"nBinsAmpFT0C", 100, "N bins FT0C amp"}; + Configurable nBinsZN{"nBinsZN", 400, "N bins ZN"}; + Configurable nBinsZP{"nBinsZP", 160, "N bins ZP"}; + Configurable nBinsTDC{"nBinsTDC", 150, "nbinsTDC"}; + + ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 0.0, 0.1, 0.12}, "pT binning"}; + ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.}, "T0C binning"}; + + // CCDB paths + Configurable paTHEff{"paTHEff", "Users/o/omvazque/MCcorrection/perTimeStamp/TrackingEff", "base path to the ccdb object"}; + Configurable paTHFD{"paTHFD", "Users/o/omvazque/MCcorrection/perTimeStamp/FeedDown", "base path to the ccdb object"}; + Configurable paTHmeanNch{"paTHmeanNch", "Users/o/omvazque/FitMeanNch_9May2025", "base path to the ccdb object"}; + Configurable paTHsigmaNch{"paTHsigmaNch", "Users/o/omvazque/FitSigmaNch_9May2025", "base path to the ccdb object"}; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + + enum EvCutLabel { + All = 1, + SelEigth, + NoSameBunchPileup, + IsGoodZvtxFT0vsPV, + NoCollInTimeRangeStrict, + NoCollInTimeRangeStandard, + NoCollInRofStrict, + NoCollInRofStandard, + NoHighMultCollInPrevRof, + NoCollInTimeRangeNarrow, + OccuCut, + Centrality, + VtxZ, + Zdc, + TZero, + Tdc, + Zem + }; + + Filter trackFilter = ((aod::track::eta > minEta) && (aod::track::eta < maxEta)); + + // Apply Filters + using TheFilteredTracks = soa::Filtered; + using TheFilteredSimTracks = soa::Filtered; + + // Histograms: Data + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + Service ccdb; + + struct Config { + TH2F* hEfficiency = nullptr; + TH2F* hFeedDown = nullptr; + bool correctionsLoaded = false; + } cfg; + + struct NchConfig { + TH1F* hMeanNch = nullptr; + TH1F* hSigmaNch = nullptr; + bool calibrationsLoaded = false; + } cfgNch; + + void init(InitContext const&) + { + const char* tiT0A{"T0A (#times 1/100, 3.5 < #eta < 4.9)"}; + const char* tiT0C{"T0C (#times 1/100, -3.3 < #eta < -2.1)"}; + const char* tiT0M{"T0A+T0C (#times 1/100, -3.3 < #eta < -2.1 and 3.5 < #eta < 4.9)"}; + const char* tiNch{"#it{N}_{ch} (|#eta| < 0.8)"}; + const char* tiV0A{"V0A (#times 1/100, 2.2 < #eta < 5)"}; + const char* tiZNs{"ZNA + ZNC"}; + const char* tiZPs{"ZPA + ZPC"}; + const char* tiPt{"#it{p}_{T} (GeV/#it{c})"}; + const char* tiOneParCorr{"#LT[#it{p}_{T}^{(1)}]#GT (GeV/#it{c})"}; + const char* tiTwoParCorr{"Two-Particle #it{p}_{T} correlation"}; + const char* tiThreeParCorr{"Three-Particle #it{p}_{T} correlation"}; + + // define axes you want to use + const AxisSpec axisZpos{48, -12., 12., "Vtx_{z} (cm)"}; + const AxisSpec axisEvent{18, 0.5, 18.5, ""}; + const AxisSpec axisEta{40, -1., +1., "#eta"}; + const AxisSpec axisPt{binsPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisDeltaPt{100, -1.0, +1.0, "#Delta(p_{T})"}; + const AxisSpec axisCent{binsCent, "T0C centrality"}; + const AxisSpec axisAmpCh{250, 0., 2500., "Amplitude of non-zero channels"}; + const AxisSpec axisEneCh{300, 0., 300., "Energy of non-zero channels"}; + + registry.add("NchUncorrected", Form(";%s;Entries;", tiNch), kTH1F, {{nBinsNch, minNch, maxNch}}); + registry.add("hEventCounter", ";;Events", kTH1F, {axisEvent}); + registry.add("ExcludedEvtVsFT0M", Form(";%s;Entries;", tiT0M), kTH1F, {{nBinsAmpFT0, 0., maxAmpFT0}}); + registry.add("ExcludedEvtVsFV0A", Form(";%s;Entries;", tiT0M), kTH1F, {{nBinsAmpV0A, 0., maxAmpV0A}}); + registry.add("ExcludedEvtVsNch", Form(";%s;Entries;", tiNch), kTH1F, {{nBinsNch, minNch, maxNch}}); + registry.add("Nch", Form(";%s;Entries;", tiNch), kTH1F, {{nBinsNch, minNch, maxNch}}); + registry.add("NchVsOneParCorr", Form(";%s;%s;", tiNch, tiOneParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + + auto hstat = registry.get(HIST("hEventCounter")); + auto* x = hstat->GetXaxis(); + x->SetBinLabel(1, "All"); + x->SetBinLabel(2, "SelEigth"); + x->SetBinLabel(3, "NoSameBunchPileup"); + x->SetBinLabel(4, "GoodZvtxFT0vsPV"); + x->SetBinLabel(5, "NoCollInTimeRangeStrict"); + x->SetBinLabel(6, "NoCollInTimeRangeStandard"); + x->SetBinLabel(7, "NoCollInRofStrict"); + x->SetBinLabel(8, "NoCollInRofStandard"); + x->SetBinLabel(9, "NoHighMultCollInPrevRof"); + x->SetBinLabel(10, "NoCollInTimeRangeNarrow"); + x->SetBinLabel(11, "Occupancy Cut"); + x->SetBinLabel(12, "Cent. Sel."); + x->SetBinLabel(13, "VtxZ cut"); + x->SetBinLabel(14, "has ZDC?"); + x->SetBinLabel(15, "has T0?"); + x->SetBinLabel(16, "Within TDC cut?"); + x->SetBinLabel(17, "Within ZEM cut?"); + + if (doprocessZdcCollAss) { + registry.add("NchVsT0Mamp", Form(";%s;%s;", tiNch, tiT0M), kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsAmpFT0, 0., maxAmpFT0}}}); + registry.add("NchVsV0Aamp", Form(";%s;%s;", tiNch, tiV0A), kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsAmpV0A, 0., maxAmpV0A}}}); + registry.add("NchVsZN", Form(";%s;%s;", tiNch, tiZNs), kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + registry.add("NchVsZP", Form(";%s;%s;", tiNch, tiZPs), kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsZP, minZN, maxZP}}}); + registry.add("NchVsZNVsPt", Form(";%s;%s;%s", tiNch, tiZNs, tiPt), kTH3F, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}, {axisPt}}}); + registry.add("NchVsOneParCorrVsZN", Form(";%s;%s;%s", tiNch, tiZNs, tiOneParCorr), kTProfile2D, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + registry.add("NchVsTwoParCorrVsZN", Form(";%s;%s;%s", tiNch, tiZNs, tiTwoParCorr), kTProfile2D, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + registry.add("NchVsThreeParCorrVsZN", Form(";%s;%s;%s", tiNch, tiZNs, tiThreeParCorr), kTProfile2D, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + registry.add("OneParCorrVsT0M", Form(";%s;%s;", tiT0M, tiOneParCorr), kTProfile, {{nBinsAmpFT0, 0., maxAmpFT0}}); + registry.add("TwoParCorrVsT0M", Form(";%s;%s;", tiT0M, tiTwoParCorr), kTProfile, {{nBinsAmpFT0, 0., maxAmpFT0}}); + registry.add("ThreeParCorrVsT0M", Form(";%s;%s;", tiT0M, tiThreeParCorr), kTProfile, {{nBinsAmpFT0, 0., maxAmpFT0}}); + registry.add("OneParCorrVsV0A", Form(";%s;%s;", tiV0A, tiOneParCorr), kTProfile, {{nBinsAmpV0A, 0., maxAmpV0A}}); + registry.add("TwoParCorrVsV0A", Form(";%s;%s;", tiV0A, tiTwoParCorr), kTProfile, {{nBinsAmpV0A, 0., maxAmpV0A}}); + registry.add("ThreeParCorrVsV0A", Form(";%s;%s;", tiV0A, tiThreeParCorr), kTProfile, {{nBinsAmpV0A, 0., maxAmpV0A}}); + + for (int i = 0; i < kSizeBootStrapEnsemble; i++) { + hNch[i] = registry.add(Form("Nch_Replica%d", i), Form(";%s;Entries", tiNch), kTH1F, {{nBinsNch, minNch, maxNch}}); + hPoisson[i] = registry.add(Form("Poisson_Replica%d", i), ";#it{k};Entries", kTH1F, {{11, -0.5, 10.5}}); + pNchVsOneParCorrVsZN[i] = registry.add(Form("NchVsOneParCorrVsZN_Replica%d", i), Form(";%s;%s;%s", tiNch, tiZNs, tiOneParCorr), kTProfile2D, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + pNchVsTwoParCorrVsZN[i] = registry.add(Form("NchVsTwoParCorrVsZN_Replica%d", i), Form(";%s;%s;%s", tiNch, tiZNs, tiTwoParCorr), kTProfile2D, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + pNchVsThreeParCorrVsZN[i] = registry.add(Form("NchVsThreeParCorrVsZN_Replica%d", i), Form(";%s;%s;%s", tiNch, tiZNs, tiThreeParCorr), kTProfile2D, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + + pOneParCorrVsT0M[i] = registry.add(Form("OneParCorrVsT0M_Replica%d", i), Form(";%s;%s;", tiT0M, tiOneParCorr), kTProfile, {{nBinsAmpFT0, 0., maxAmpFT0}}); + pTwoParCorrVsT0M[i] = registry.add(Form("TwoParCorrVsT0M_Replica%d", i), Form(";%s;%s;", tiT0M, tiTwoParCorr), kTProfile, {{nBinsAmpFT0, 0., maxAmpFT0}}); + pThreeParCorrVsT0M[i] = registry.add(Form("ThreeParCorrVsT0M_Replica%d", i), Form(";%s;%s;", tiT0M, tiThreeParCorr), kTProfile, {{nBinsAmpFT0, 0., maxAmpFT0}}); + + pOneParCorrVsV0A[i] = registry.add(Form("OneParCorrVsV0A_Replica%d", i), Form(";%s;%s;", tiV0A, tiOneParCorr), kTProfile, {{nBinsAmpV0A, 0., maxAmpV0A}}); + pTwoParCorrVsV0A[i] = registry.add(Form("TwoParCorrVsV0A_Replica%d", i), Form(";%s;%s;", tiV0A, tiTwoParCorr), kTProfile, {{nBinsAmpV0A, 0., maxAmpV0A}}); + pThreeParCorrVsV0A[i] = registry.add(Form("ThreeParCorrVsV0A_Replica%d", i), Form(";%s;%s;", tiV0A, tiThreeParCorr), kTProfile, {{nBinsAmpV0A, 0., maxAmpV0A}}); + } + } + + if (doprocessMCclosure) { + registry.add("zPos", ";;Entries;", kTH1F, {axisZpos}); + registry.add("T0Ccent", ";;Entries", kTH1F, {axisCent}); + registry.add("EtaVsPhi", ";#eta;#varphi", kTH2F, {{{axisEta}, {100, -0.1 * PI, +2.1 * PI}}}); + registry.add("ZposVsEta", "", kTProfile, {axisZpos}); + registry.add("sigma1Pt", ";;#sigma(p_{T})/p_{T};", kTProfile, {axisPt}); + registry.add("dcaXYvspT", ";DCA_{xy} (cm);;", kTH2F, {{{50, -1., 1.}, {axisPt}}}); + registry.add("RandomNumber", "", kTH1F, {{50, 0., 1.}}); + registry.add("EvtsDivided", ";Event type;Entries;", kTH1F, {{2, -0.5, 1.5}}); + auto hEvtsDiv = registry.get(HIST("EvtsDivided")); + auto* xEvtsDiv = hEvtsDiv->GetXaxis(); + xEvtsDiv->SetBinLabel(1, "MC closure"); + xEvtsDiv->SetBinLabel(2, "Corrections"); + // MC closure + registry.add("NchGen", Form("MC Closure;%s;Entries", tiNch), kTH1F, {{nBinsNch, minNch, maxNch}}); + registry.add("NchvsOneParCorrGen", Form("MC Closure;%s;%s", tiNch, tiOneParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + registry.add("NchvsTwoParCorrGen", Form("MC Closure;%s;%s", tiNch, tiTwoParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + registry.add("NchvsThreeParCorrGen", Form("MC Closure;%s;%s", tiNch, tiThreeParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + registry.add("NchVsTwoParCorr", Form("MC Closure;%s;%s", tiNch, tiTwoParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + registry.add("NchVsThreeParCorr", Form("MC Closure;%s;%s", tiNch, tiThreeParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + // Corrections + registry.add("zPosMC", "Filled at MC closure + Corrections;;Entries;", kTH1F, {axisZpos}); + registry.add("hEventCounterMC", "Event counter", kTH1F, {axisEvent}); + registry.add("nRecColvsCent", "", kTH2F, {{6, -0.5, 5.5}, {{axisCent}}}); + registry.add("Pt_all_ch", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("Pt_ch", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("Pt_pi", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("Pt_ka", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("Pt_pr", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("Pt_sigpos", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("Pt_signeg", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("Pt_re", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("PtMC_ch", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("PtMC_pi", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("PtMC_ka", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("PtMC_pr", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("PtMC_sigpos", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("PtMC_signeg", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("PtMC_re", Form("Corrections;%s;%s", tiNch, tiPt), kTH2F, {{nBinsNch, minNch, maxNch}, {axisPt}}); + registry.add("McNchVsFT0M", Form("Corrections;%s;%s", tiT0M, tiNch), kTH2F, {{{nBinsAmpFT0, 0., maxAmpFT0}, {nBinsNch, minNch, maxNch}}}); + + auto hECMC = registry.get(HIST("hEventCounterMC")); + auto* x = hECMC->GetXaxis(); + x->SetBinLabel(1, "All"); + x->SetBinLabel(13, "VtxZ cut"); + + for (int i = 0; i < kSizeBootStrapEnsemble; i++) { + + hPoissonMC[i] = registry.add(Form("PoissonMC_Replica%d", i), ";#it{k};Entries", kTH1F, {{11, -0.5, 10.5}}); + hNchGen[i] = registry.add(Form("NchGen_Replica%d", i), Form(";%s;Entries", tiNch), kTH1F, {{nBinsNch, minNch, maxNch}}); + + pOneParCorrVsNchGen[i] = registry.add(Form("OneParCorrVsNchGen_Replica%d", i), Form(";%s;%s;", tiNch, tiOneParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + pTwoParCorrVsNchGen[i] = registry.add(Form("TwoParCorrVsNchGen_Replica%d", i), Form(";%s;%s;", tiNch, tiTwoParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + pThreeParCorrVsNchGen[i] = registry.add(Form("ThreeParCorrVsNchGen_Replica%d", i), Form(";%s;%s;", tiNch, tiThreeParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + + // pOneParCorrVsT0MGen[i] = registry.add(Form("OneParCorrVsT0MGen_Replica%d",i),Form(";%s;%s;",tiT0M,tiOneParCorr), kTProfile,{{nBinsAmpFT0,0.,maxAmpFT0}}); + // pTwoParCorrVsT0MGen[i] = registry.add(Form("TwoParCorrVsT0MGen_Replica%d",i),Form(";%s;%s;",tiT0M,tiTwoParCorr), kTProfile,{{nBinsAmpFT0,0.,maxAmpFT0}}); + // pThreeParCorrVsT0MGen[i] = registry.add(Form("ThreeParCorrVsT0MGen_Replica%d",i),Form(";%s;%s;",tiT0M,tiThreeParCorr), kTProfile,{{nBinsAmpFT0,0.,maxAmpFT0}}); + + // pOneParCorrVsV0AGen[i] = registry.add(Form("OneParCorrVsV0AGen_Replica%d",i),Form(";%s;%s;",tiT0M,tiOneParCorr), kTProfile,{{nBinsAmpFT0,0.,maxAmpFT0}}); + // pTwoParCorrVsV0AGen[i] = registry.add(Form("TwoParCorrVsV0AGen_Replica%d",i),Form(";%s;%s;",tiT0M,tiTwoParCorr), kTProfile,{{nBinsAmpFT0,0.,maxAmpFT0}}); + // pThreeParCorrVsV0AGen[i] = registry.add(Form("ThreeParCorrVsV0AGen_Replica%d",i),Form(";%s;%s;",tiT0M,tiThreeParCorr), kTProfile,{{nBinsAmpFT0,0.,maxAmpFT0}}); + + hNch[i] = registry.add(Form("Nch_Replica%d", i), Form(";%s;Entries", tiNch), kTH1F, {{nBinsNch, minNch, maxNch}}); + hPoisson[i] = registry.add(Form("Poisson_Replica%d", i), ";#it{k};Entries", kTH1F, {{11, -0.5, 10.5}}); + + pOneParCorrVsNch[i] = registry.add(Form("OneParCorrVsNch_Replica%d", i), Form(";%s;%s;", tiNch, tiOneParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + pTwoParCorrVsNch[i] = registry.add(Form("TwoParCorrVsNch_Replica%d", i), Form(";%s;%s;", tiNch, tiTwoParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + pThreeParCorrVsNch[i] = registry.add(Form("ThreeParCorrVsNch_Replica%d", i), Form(";%s;%s;", tiNch, tiTwoParCorr), kTProfile, {{nBinsNch, minNch, maxNch}}); + + // pOneParCorrVsT0M[i] = registry.add(Form("OneParCorrVsT0M_Replica%d",i),Form(";%s;%s;",tiT0M,tiOneParCorr),kTProfile,{{nBinsAmpFT0,0.,maxAmpFT0}}); + // pTwoParCorrVsT0M[i] = registry.add(Form("TwoParCorrVsT0M_Replica%d",i),Form(";%s;%s;",tiT0M,tiTwoParCorr),kTProfile,{{nBinsAmpFT0,0.,maxAmpFT0}}); + // pThreeParCorrVsT0M[i] = registry.add(Form("ThreeParCorrVsT0M_Replica%d",i),Form(";%s;%s;",tiT0M,tiThreeParCorr),kTProfile,{{nBinsAmpFT0,0.,maxAmpFT0}}); + // + // pOneParCorrVsV0A[i] = registry.add(Form("OneParCorrVsV0A_Replica%d",i),Form(";%s;%s;",tiV0A,tiOneParCorr),kTProfile,{{nBinsAmpV0A,0.,maxAmpV0A}}); + // pTwoParCorrVsV0A[i] = registry.add(Form("TwoParCorrVsV0A_Replica%d",i),Form(";%s;%s;",tiV0A,tiTwoParCorr),kTProfile,{{nBinsAmpV0A,0.,maxAmpV0A}}); + // pThreeParCorrVsV0A[i] = registry.add(Form("ThreeParCorrVsV0A_Replica%d",i),Form(";%s;%s;",tiV0A,tiThreeParCorr),kTProfile,{{nBinsAmpV0A,0.,maxAmpV0A}}); + } + } + + if (doprocessQA) { + registry.add("zPos", ";;Entries;", kTH1F, {axisZpos}); + registry.add("T0Ccent", ";;Entries", kTH1F, {axisCent}); + registry.add("EtaVsPhi", ";#eta;#varphi", kTH2F, {{{axisEta}, {100, -0.1 * PI, +2.1 * PI}}}); + registry.add("ZposVsEta", "", kTProfile, {axisZpos}); + registry.add("sigma1Pt", ";;#sigma(p_{T})/p_{T};", kTProfile, {axisPt}); + registry.add("dcaXYvspT", ";DCA_{xy} (cm);;", kTH2F, {{{50, -1., 1.}, {axisPt}}}); + registry.add("Debunch", ";t_{ZDC}-t_{ZDA};t_{ZDC}+t_{ZDA}", kTH2F, {{{nBinsTDC, minTdc, maxTdc}, {nBinsTDC, minTdc, maxTdc}}}); + registry.add("NchVsFT0M", Form(";%s;%s;", tiT0M, tiNch), kTH2F, {{{nBinsAmpFT0, 0., maxAmpFT0}, {nBinsNch, minNch, maxNch}}}); + registry.add("NchVsFT0A", Form(";%s;%s;", tiT0A, tiNch), kTH2F, {{{nBinsAmpFT0A, 0., maxAmpFT0A}, {nBinsNch, minNch, maxNch}}}); + registry.add("NchVsFT0C", Form(";%s;%s;", tiT0C, tiNch), kTH2F, {{{nBinsAmpFT0C, 0., maxAmpFT0C}, {nBinsNch, minNch, maxNch}}}); + registry.add("NchVsFV0A", Form(";%s;%s;", tiV0A, tiNch), kTH2F, {{{nBinsAmpV0A, 0., maxAmpV0A}, {nBinsNch, minNch, maxNch}}}); + registry.add("NchVsNPV", ";#it{N}_{PV} (|#eta|<1);ITS+TPC tracks (|#eta|<0.8);", kTH2F, {{{nBinsITSTrack, 0, maxITSTrack}, {nBinsNch, minNch, maxNch}}}); + registry.add("NchVsITStracks", ";ITS trks (|#eta|<0.8);TITS+TPC tracks (|#eta|<0.8);", kTH2F, {{{nBinsITSTrack, 0, maxITSTrack}, {nBinsNch, minNch, maxNch}}}); + registry.add("ZNVsFT0A", Form(";%s;%s;", tiT0A, tiZNs), kTH2F, {{{nBinsAmpFT0A, 0., maxAmpFT0A}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZNVsFT0C", Form(";%s;%s;", tiT0C, tiZNs), kTH2F, {{{nBinsAmpFT0C, 0., maxAmpFT0C}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZNVsFT0M", Form(";%s;%s;", tiT0M, tiZNs), kTH2F, {{{nBinsAmpFT0, 0., maxAmpFT0}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZNAamp", ";ZNA;Entries;", kTH1F, {{nBinsZN, minZN, maxZN}}); + registry.add("ZPAamp", ";ZPA;Entries;", kTH1F, {{nBinsZP, minZN, maxZP}}); + registry.add("ZNCamp", ";ZNC;Entries;", kTH1F, {{nBinsZN, minZN, maxZN}}); + registry.add("ZPCamp", ";ZPC;Entries;", kTH1F, {{nBinsZP, minZN, maxZP}}); + registry.add("ZNAVsZNC", ";ZNC;ZNA", kTH2F, {{{nBinsZN, minZN, maxZN}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZPAVsZPC", ";ZPC;ZPA;", kTH2F, {{{nBinsZP, minZN, maxZP}, {nBinsZP, minZN, maxZP}}}); + registry.add("ZNAVsZPA", ";ZPA;ZNA;", kTH2F, {{{nBinsZP, minZN, maxZP}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZNCVsZPC", ";ZPC;ZNC;", kTH2F, {{{nBinsZP, minZN, maxZP}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZNVsZEM", ";ZEM;ZNA+ZNC;", kTH2F, {{{nBinsZN, minZN, maxZEM}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZNCVsNch", Form(";%s;ZNC;", tiNch), kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZNAVsNch", Form(";%s;ZNA;", tiNch), kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZNVsNch", Form(";%s;%s;", tiNch, tiZNs), kTH2F, {{{nBinsNch, minNch, maxNch}, {nBinsZN, minZN, maxZN}}}); + registry.add("ZNDifVsNch", Form(";%s;ZNA-ZNC;", tiNch), kTH2F, {{{nBinsNch, minNch, maxNch}, {100, -50., 50.}}}); + } + + LOG(info) << "\tccdbNoLaterThan=" << ccdbNoLaterThan.value; + LOG(info) << "\tapplyEff=" << applyEff.value; + LOG(info) << "\tapplyFD=" << applyFD.value; + LOG(info) << "\tcorrectNch=" << correctNch.value; + LOG(info) << "\tpaTHEff=" << paTHEff.value; + LOG(info) << "\tpaTHFD=" << paTHFD.value; + LOG(info) << "\tuseMidRapNchSel=" << useMidRapNchSel.value; + LOG(info) << "\tdetector4Calibration=" << detector4Calibration.value; + LOG(info) << "\tnSigmaNchCut=" << nSigmaNchCut.value; + LOG(info) << "\tpaTHmeanNch=" << paTHmeanNch.value; + LOG(info) << "\tpaTHsigmaNch=" << paTHsigmaNch.value; + LOG(info) << "\tminPt=" << minPt.value; + LOG(info) << "\tmaxPt=" << maxPt.value; + LOG(info) << "\tmaxPtSpectra=" << maxPtSpectra.value; + + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + } + + template + bool isEventSelected(CheckCol const& col) + { + registry.fill(HIST("hEventCounter"), EvCutLabel::All); + if (!col.sel8()) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::SelEigth); + + if (!col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::NoSameBunchPileup); + + if (!col.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::IsGoodZvtxFT0vsPV); + + if (isNoCollInTimeRangeStrict) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::NoCollInTimeRangeStrict); + } + + if (isNoCollInTimeRangeStandard) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::NoCollInTimeRangeStandard); + } + + if (isNoCollInRofStrict) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::NoCollInRofStrict); + } + + if (isNoCollInRofStandard) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::NoCollInRofStandard); + } + + if (isNoHighMultCollInPrevRof) { + if (!col.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::NoHighMultCollInPrevRof); + } + + // To be used in combination with FT0C-based occupancy + if (isNoCollInTimeRangeNarrow) { + if (!col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::NoCollInTimeRangeNarrow); + } + + if (isOccupancyCut) { + auto occuValue{isApplyFT0CbasedOccupancy ? col.ft0cOccupancyInTimeRange() : col.trackOccupancyInTimeRange()}; + if (occuValue < minOccCut || occuValue > maxOccCut) { + return false; + } + } + registry.fill(HIST("hEventCounter"), EvCutLabel::OccuCut); + + if (col.centFT0C() < minT0CcentCut || col.centFT0C() > maxT0CcentCut) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::Centrality); + + // Z-vertex position cut + if (std::fabs(col.posZ()) > posZcut) { + return false; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::VtxZ); + + return true; + } + void processQA(o2::aod::ColEvSels::iterator const& collision, o2::aod::BCsRun3 const& /**/, aod::Zdcs const& /**/, aod::FV0As const& /**/, aod::FT0s const& /**/, TheFilteredTracks const& tracks) + { + // LOG(info) << " Collisions size: " << collisions.size() << " Table's size: " << collisions.tableSize() << "\n"; + const auto& foundBC = collision.foundBC_as(); + // LOG(info) << "Run number: " << foundBC.runNumber() << "\n"; + if (!isEventSelected(collision)) { + return; + } + + // has ZDC? + if (!foundBC.has_zdc()) { + return; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::Zdc); + auto zdc = foundBC.zdc(); + + double aT0A{-999.}; + double aT0C{-999.}; + if (foundBC.has_ft0()) { + for (const auto& amplitude : foundBC.ft0().amplitudeA()) { + aT0A += amplitude; + } + for (const auto& amplitude : foundBC.ft0().amplitudeC()) { + aT0C += amplitude; + } + } else { + return; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::TZero); + + double aV0A{-999.}; + if (foundBC.has_fv0a()) { + for (const auto& amplitude : foundBC.fv0a().amplitude()) { + aV0A += amplitude; + } + } + + const double normT0M{(aT0A + aT0C) / 100.}; + const double normV0A{aV0A / 100.}; + const double normT0A{aT0A / 100.}; + const double normT0C{aT0C / 100.}; + float znA{zdc.amplitudeZNA()}; + float znC{zdc.amplitudeZNC()}; + float zpA{zdc.amplitudeZPA()}; + float zpC{zdc.amplitudeZPC()}; + float aZEM1{zdc.amplitudeZEM1()}; + float aZEM2{zdc.amplitudeZEM2()}; + float tZNA{zdc.timeZNA()}; + float tZNC{zdc.timeZNC()}; + float tZPA{zdc.timeZPA()}; + float tZPC{zdc.timeZPC()}; + float tZDCdif{tZNC + tZPC - tZNA - tZPA}; + float tZDCsum{tZNC + tZPC + tZNA + tZPA}; + znA /= kCollEnergy; + znC /= kCollEnergy; + zpA /= kCollEnergy; + zpC /= kCollEnergy; + float sumZNs{znA + znC}; + float sumZEMs{aZEM1 + aZEM2}; + // TDC cut + if (isTDCcut) { + if (std::sqrt(std::pow(tZDCdif, 2.) + std::pow(tZDCsum, 2.)) > tdcCut) { + return; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::Tdc); + } + + // ZEM cut + if (isZEMcut) { + if (sumZEMs < zemCut) { + return; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::Zem); + } + + int itsTracks = 0, glbTracks = 0; + for (const auto& track : tracks) { + if (track.hasITS() && ((track.eta() > minEta) && (track.eta() < maxEta))) { + itsTracks++; + } + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + glbTracks++; + } + + bool skipEvent{false}; + if (useMidRapNchSel) { + loadNchCalibrations(foundBC.timestamp()); + if (!(cfgNch.hMeanNch && cfgNch.hSigmaNch)) + return; + + TString s1 = TString(detector4Calibration.value); + double xEval{1.}; + if (s1 == "T0M") { + xEval = normT0M; + } + if (s1 == "V0A") { + xEval = normV0A; + } + + const int bin4Calibration{cfgNch.hMeanNch->FindBin(xEval)}; + const double meanNch{cfgNch.hMeanNch->GetBinContent(bin4Calibration)}; + const double sigmaNch{cfgNch.hSigmaNch->GetBinContent(bin4Calibration)}; + const double nSigmaSelection{nSigmaNchCut * sigmaNch}; + const double diffMeanNch{meanNch - glbTracks}; + + if (std::abs(diffMeanNch) > nSigmaSelection) { + registry.fill(HIST("ExcludedEvtVsFT0M"), normT0M); + registry.fill(HIST("ExcludedEvtVsFV0A"), normV0A); + registry.fill(HIST("ExcludedEvtVsNch"), glbTracks); + skipEvent = true; + } + } + + if (useMidRapNchSel && skipEvent) { + return; + } + + double meanpt{0.}; + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPtSpectra)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + + registry.fill(HIST("ZposVsEta"), collision.posZ(), track.eta()); + registry.fill(HIST("EtaVsPhi"), track.eta(), track.phi()); + registry.fill(HIST("sigma1Pt"), track.pt(), track.sigma1Pt()); + registry.fill(HIST("dcaXYvspT"), track.dcaXY(), track.pt()); + meanpt += track.pt(); + } + + registry.fill(HIST("zPos"), collision.posZ()); + registry.fill(HIST("T0Ccent"), collision.centFT0C()); + registry.fill(HIST("ZNAamp"), znA); + registry.fill(HIST("ZNCamp"), znC); + registry.fill(HIST("ZPAamp"), zpA); + registry.fill(HIST("ZPCamp"), zpC); + registry.fill(HIST("ZNAVsZNC"), znC, znA); + registry.fill(HIST("ZNAVsZPA"), zpA, znA); + registry.fill(HIST("ZNCVsZPC"), zpC, znC); + registry.fill(HIST("ZPAVsZPC"), zpC, zpA); + registry.fill(HIST("ZNVsZEM"), sumZEMs, sumZNs); + registry.fill(HIST("Debunch"), tZDCdif, tZDCsum); + registry.fill(HIST("ZNVsFT0A"), normT0A, sumZNs); + registry.fill(HIST("ZNVsFT0C"), normT0C, sumZNs); + registry.fill(HIST("ZNVsFT0M"), normT0M, sumZNs); + registry.fill(HIST("NchVsFV0A"), normV0A, glbTracks); + registry.fill(HIST("NchVsFT0A"), normT0A, glbTracks); + registry.fill(HIST("NchVsFT0C"), normT0C, glbTracks); + registry.fill(HIST("NchVsFT0M"), normT0M, glbTracks); + registry.fill(HIST("NchUncorrected"), glbTracks); + registry.fill(HIST("Nch"), glbTracks); + registry.fill(HIST("NchVsNPV"), collision.multNTracksPVeta1(), glbTracks); + registry.fill(HIST("NchVsITStracks"), itsTracks, glbTracks); + registry.fill(HIST("ZNAVsNch"), glbTracks, znA); + registry.fill(HIST("ZNCVsNch"), glbTracks, znC); + registry.fill(HIST("ZNVsNch"), glbTracks, sumZNs); + registry.fill(HIST("ZNDifVsNch"), glbTracks, znA - znC); + if (glbTracks >= minNchSel) + registry.fill(HIST("NchVsOneParCorr"), glbTracks, meanpt / glbTracks); + } + PROCESS_SWITCH(UccZdc, processQA, "Process QA", true); + void processZdcCollAss(o2::aod::ColEvSels::iterator const& collision, o2::aod::BCsRun3 const& /*bcs*/, aod::Zdcs const& /*zdcs*/, aod::FV0As const& /*fv0as*/, aod::FT0s const& /*ft0s*/, TheFilteredTracks const& tracks) + { + if (!isEventSelected(collision)) { + return; + } + + const auto& foundBC = collision.foundBC_as(); + // LOGF(info, "Getting object %s for run number %i from timestamp=%llu", paTH.value.data(), foundBC.runNumber(), foundBC.timestamp()); + + // has ZDC? + if (!foundBC.has_zdc()) { + return; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::Zdc); + + double aT0A{-999.}; + double aT0C{-999.}; + if (foundBC.has_ft0()) { + for (const auto& amplitude : foundBC.ft0().amplitudeA()) { + aT0A += amplitude; + } + for (const auto& amplitude : foundBC.ft0().amplitudeC()) { + aT0C += amplitude; + } + } else { + return; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::TZero); + + double aV0A{-999.}; + if (foundBC.has_fv0a()) { + for (const auto& amplitude : foundBC.fv0a().amplitude()) { + aV0A += amplitude; + } + } + + const double normT0M{(aT0A + aT0C) / 100.}; + const double normV0A{aV0A / 100.}; + float znA{foundBC.zdc().amplitudeZNA()}; + float znC{foundBC.zdc().amplitudeZNC()}; + float zpA{foundBC.zdc().amplitudeZPA()}; + float zpC{foundBC.zdc().amplitudeZPC()}; + float aZEM1{foundBC.zdc().amplitudeZEM1()}; + float aZEM2{foundBC.zdc().amplitudeZEM2()}; + float tZNA{foundBC.zdc().timeZNA()}; + float tZNC{foundBC.zdc().timeZNC()}; + float tZPA{foundBC.zdc().timeZPA()}; + float tZPC{foundBC.zdc().timeZPC()}; + float tZDCdif{tZNC + tZPC - tZNA - tZPA}; + float tZDCsum{tZNC + tZPC + tZNA + tZPA}; + znA /= kCollEnergy; + znC /= kCollEnergy; + zpA /= kCollEnergy; + zpC /= kCollEnergy; + const double sumZNs{znA + znC}; + const double sumZPs{zpA + zpC}; + const double sumZEMs{aZEM1 + aZEM2}; + + // TDC cut + if (isTDCcut) { + if (std::sqrt(std::pow(tZDCdif, 2.) + std::pow(tZDCsum, 2.)) > tdcCut) { + return; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::Tdc); + } + + // ZEM cut + if (isZEMcut) { + if (sumZEMs < zemCut) { + return; + } + registry.fill(HIST("hEventCounter"), EvCutLabel::Zem); + } + + // Nch-based selection + int glbTracks{0}; + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + glbTracks++; + } + + if (glbTracks < minNchSel) { + return; + } + + bool skipEvent{false}; + if (useMidRapNchSel) { + loadNchCalibrations(foundBC.timestamp()); + if (!(cfgNch.hMeanNch && cfgNch.hSigmaNch)) + return; + + TString s1 = TString(detector4Calibration.value); + double xEval{1.}; + if (s1 == "T0M") { + xEval = normT0M; + } + if (s1 == "V0A") { + xEval = normV0A; + } + + const int bin4Calibration{cfgNch.hMeanNch->FindBin(xEval)}; + const double meanNch{cfgNch.hMeanNch->GetBinContent(bin4Calibration)}; + const double sigmaNch{cfgNch.hSigmaNch->GetBinContent(bin4Calibration)}; + const double nSigmaSelection{nSigmaNchCut * sigmaNch}; + const double diffMeanNch{meanNch - glbTracks}; + + if (std::abs(diffMeanNch) > nSigmaSelection) { + registry.fill(HIST("ExcludedEvtVsFT0M"), normT0M); + registry.fill(HIST("ExcludedEvtVsFV0A"), normV0A); + registry.fill(HIST("ExcludedEvtVsNch"), glbTracks); + skipEvent = true; + } + } + + // Skip event based on number of Nch sigmas + if (useMidRapNchSel && skipEvent) { + return; + } + + double nchMult{static_cast(glbTracks)}; + std::vector pTs; + std::vector vecFD; + std::vector vecEff; + + // apply corrections + if (applyEff || applyFD) { + nchMult = 0.; + loadCorrections(foundBC.timestamp()); + if (!(cfg.hEfficiency && cfg.hFeedDown)) + return; + + const int foundNchBin{cfg.hEfficiency->GetXaxis()->FindBin(glbTracks)}; + + // Calculates the Corrected Nch + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + + const float pt{track.pt()}; + const int foundPtBin{cfg.hEfficiency->GetYaxis()->FindBin(pt)}; + const double effValue{cfg.hEfficiency->GetBinContent(foundNchBin, foundPtBin)}; + double fdValue{1.}; + + if (applyFD) + fdValue = cfg.hFeedDown->GetBinContent(foundNchBin, foundPtBin); + + if ((effValue > 0.) && (fdValue > 0.)) { + nchMult += (std::pow(effValue, -1.) * fdValue); + } + } + + if (applyEff && !correctNch) + nchMult = static_cast(glbTracks); + + // Fill vectors for [pT] measurement + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPtSpectra)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + + const float pt{track.pt()}; + const int foundPtBin{cfg.hEfficiency->GetYaxis()->FindBin(pt)}; + const double effValue{cfg.hEfficiency->GetBinContent(foundNchBin, foundPtBin)}; + double fdValue{1.}; + + if (applyFD) + fdValue = cfg.hFeedDown->GetBinContent(foundNchBin, foundPtBin); + + if ((effValue > 0.) && (fdValue > 0.)) { + pTs.emplace_back(pt); + vecEff.emplace_back(effValue); + vecFD.emplace_back(fdValue); + // To calculate event-averaged + registry.fill(HIST("NchVsZNVsPt"), nchMult, sumZNs, pt * (fdValue / effValue)); + } + } + } else { + // Fill vectors for [pT] measurement + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPtSpectra)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + + pTs.emplace_back(track.pt()); + vecEff.emplace_back(1.); + vecFD.emplace_back(1.); + // To calculate event-averaged + registry.fill(HIST("NchVsZNVsPt"), nchMult, sumZNs, track.pt()); + } + } + + double p1, p2, p3, p4, w1, w2, w3, w4; + p1 = p2 = p3 = p4 = w1 = w2 = w3 = w4 = 0.0; + getPTpowers(pTs, vecEff, vecFD, p1, w1, p2, w2, p3, w3, p4, w4); + + // EbE one-particle pT correlation + double oneParCorr{p1 / w1}; + + // EbE two-particle pT correlation + double denTwoParCorr{std::pow(w1, 2.) - w2}; + double numTwoParCorr{std::pow(p1, 2.) - p2}; + double twoParCorr{numTwoParCorr / denTwoParCorr}; + + // EbE three-particle pT correlation + double denThreeParCorr{std::pow(w1, 3.) - 3. * w2 * w1 + 2. * w3}; + double numThreeParCorr{std::pow(p1, 3.) - 3. * p2 * p1 + 2. * p3}; + double threeParCorr{numThreeParCorr / denThreeParCorr}; + + // EbE four-particle pT correlation + // double denFourParCorr{std::pow(w1, 4.) - 6. * w2 * std::pow(w1, 2.) + 3. * std::pow(w2, 2.) + 8 * w3 * w1 - 6. * w4}; + // double numFourParCorr{std::pow(p1, 4.) - 6. * p2 * std::pow(p1, 2.) + 3. * std::pow(p2, 2.) + 8 * p3 * p1 - 6. * p4}; + // double fourParCorr{numFourParCorr / denFourParCorr}; + + // One-dimensional distributions + registry.fill(HIST("Nch"), nchMult); + registry.fill(HIST("NchUncorrected"), glbTracks); + + registry.fill(HIST("NchVsV0Aamp"), nchMult, normV0A); + registry.fill(HIST("NchVsT0Mamp"), nchMult, normT0M); + registry.fill(HIST("NchVsZN"), nchMult, sumZNs); + registry.fill(HIST("NchVsZP"), nchMult, sumZPs); + + registry.fill(HIST("NchVsOneParCorr"), nchMult, oneParCorr, w1); + + registry.fill(HIST("NchVsOneParCorrVsZN"), nchMult, sumZNs, oneParCorr, w1); + registry.fill(HIST("NchVsTwoParCorrVsZN"), nchMult, sumZNs, twoParCorr, denTwoParCorr); + registry.fill(HIST("NchVsThreeParCorrVsZN"), nchMult, sumZNs, threeParCorr, denThreeParCorr); + + registry.fill(HIST("OneParCorrVsT0M"), normT0M, oneParCorr, w1); + registry.fill(HIST("TwoParCorrVsT0M"), normT0M, twoParCorr, denTwoParCorr); + registry.fill(HIST("ThreeParCorrVsT0M"), normT0M, threeParCorr, denThreeParCorr); + + registry.fill(HIST("OneParCorrVsV0A"), normV0A, oneParCorr, w1); + registry.fill(HIST("TwoParCorrVsV0A"), normV0A, twoParCorr, denTwoParCorr); + registry.fill(HIST("ThreeParCorrVsV0A"), normV0A, threeParCorr, denThreeParCorr); + + const uint64_t timeStamp{foundBC.timestamp()}; + eventSampling(tracks, normV0A, normT0M, sumZNs, timeStamp); + } + PROCESS_SWITCH(UccZdc, processZdcCollAss, "Process ZDC W/Coll Ass.", true); + + Preslice perCollision = aod::track::collisionId; + Service pdg; + void processMCclosure(aod::McCollisions::iterator const& mccollision, soa::SmallGroups const& collisions, o2::aod::BCsRun3 const& /*bcs*/, aod::FT0s const& /*ft0s*/, aod::FV0As const& /*fv0as*/, aod::McParticles const& mcParticles, TheFilteredSimTracks const& simTracks) + { + for (const auto& collision : collisions) { + // Event selection + if (!isEventSelected(collision)) { + continue; + } + // MC collision? + if (!collision.has_mcCollision()) { + continue; + } + + registry.fill(HIST("hEventCounterMC"), EvCutLabel::All); + // Vtx_z selection MC + if (std::fabs(mccollision.posZ()) > posZcut) { + continue; + } + + const auto& foundBC = collision.foundBC_as(); + + uint64_t timeStamp{foundBC.timestamp()}; + TRandom3 rndGen(timeStamp); + const double rndNum{rndGen.Uniform(0.0, 1.0)}; + registry.fill(HIST("RandomNumber"), rndNum); + + double aT0A = 0., aT0C = 0.; + if (foundBC.has_ft0()) { + for (const auto& amplitude : foundBC.ft0().amplitudeA()) { + aT0A += amplitude; + } + for (const auto& amplitude : foundBC.ft0().amplitudeC()) { + aT0C += amplitude; + } + } else { + return; + } + + // double aV0A{-999.}; + // if (foundBC.has_fv0a()) { + // for (const auto& amplitude : foundBC.fv0a().amplitude()) { aV0A += amplitude; } + // } + + const double normT0M{(aT0A + aT0C) / 100.}; + // const double normV0A{aV0A/100.}; + + double nchRaw{0.}; + double nchMult{0.}; + double nchMC{0.}; + + registry.fill(HIST("zPos"), collision.posZ()); + registry.fill(HIST("zPosMC"), mccollision.posZ()); + registry.fill(HIST("hEventCounterMC"), EvCutLabel::VtxZ); + + if (skipRecoColGTOne && (collisions.size() > kOne)) { + continue; + } + + registry.fill(HIST("nRecColvsCent"), collisions.size(), collision.centFT0C()); + + const auto& cent{collision.centFT0C()}; + registry.fill(HIST("T0Ccent"), cent); + + const auto& groupedTracks{simTracks.sliceBy(perCollision, collision.globalIndex())}; + + // Half of the statistics for MC closure + if (rndNum >= kZero && rndNum < evtFracMCcl) { + + registry.fill(HIST("EvtsDivided"), 0); + + // Run-by-run efficiency + loadCorrections(foundBC.timestamp()); + if (!(cfg.hEfficiency && cfg.hFeedDown)) { + continue; + } + + std::vector pTs; + std::vector vecFD; + std::vector vecEff; + + // Calculates the event's Nch to evaluate the efficiency + for (const auto& track : groupedTracks) { + // Track Selection + if (track.eta() < minEta || track.eta() > maxEta) { + continue; + } + if (track.pt() < minPt || track.pt() > maxPt) { + continue; + } + if (!track.isGlobalTrack()) { + continue; + } + nchRaw++; + } + + // Reject event if nchRaw less than a lower cutoff + if (nchRaw < minNchSel) { + return; + } + + // Calculates the event weight, W_k + const int foundNchBin{cfg.hEfficiency->GetXaxis()->FindBin(nchRaw)}; + + for (const auto& track : groupedTracks) { + // Track Selection + if (track.eta() < minEta || track.eta() > maxEta) { + continue; + } + if (track.pt() < minPt || track.pt() > maxPt) { + continue; + } + if (!track.isGlobalTrack()) { + continue; + } + if (!track.has_mcParticle()) { + continue; + } + const auto& particle{track.mcParticle()}; + + auto charge{0.}; + // Get the MC particle + auto* pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (pdgParticle != nullptr) { + charge = pdgParticle->Charge(); + } else { + continue; + } + + // Is it a charged particle? + if (std::abs(charge) < kMinCharge) { + continue; + } + // Is it a primary particle? + // if (!particle.isPhysicalPrimary()) { continue; } + + const double pt{static_cast(track.pt())}; + const int foundPtBin{cfg.hEfficiency->GetYaxis()->FindBin(pt)}; + const double effValue{cfg.hEfficiency->GetBinContent(foundNchBin, foundPtBin)}; + double fdValue{1.}; + + if (applyFD) + fdValue = cfg.hFeedDown->GetBinContent(foundNchBin, foundPtBin); + if ((effValue > 0.) && (fdValue > 0.)) { + pTs.emplace_back(pt); + vecEff.emplace_back(effValue); + vecFD.emplace_back(fdValue); + nchMult += (std::pow(effValue, -1.0) * fdValue); + } + } + + double p1, p2, p3, p4, w1, w2, w3, w4; + p1 = p2 = p3 = p4 = w1 = w2 = w3 = w4 = 0.0; + getPTpowers(pTs, vecEff, vecFD, p1, w1, p2, w2, p3, w3, p4, w4); + + const double denTwoParCorr{std::pow(w1, 2.) - w2}; + const double numTwoParCorr{std::pow(p1, 2.) - p2}; + const double denThreeParCorr{std::pow(w1, 3.) - 3. * w2 * w1 + 2. * w3}; + const double numThreeParCorr{std::pow(p1, 3.) - 3. * p2 * p1 + 2. * p3}; + // const double denFourParCorr{std::pow(w1, 4.) - 6. * w2 * std::pow(w1, 2.) + 3. * std::pow(w2, 2.) + 8 * w3 * w1 - 6. * w4}; + // const double numFourParCorr{std::pow(p1, 4.) - 6. * p2 * std::pow(p1, 2.) + 3. * std::pow(p2, 2.) + 8 * p3 * p1 - 6. * p4}; + + const double oneParCorr{p1 / w1}; + const double twoParCorr{numTwoParCorr / denTwoParCorr}; + const double threeParCorr{numThreeParCorr / denThreeParCorr}; + + registry.fill(HIST("Nch"), nchMult); + registry.fill(HIST("NchUncorrected"), nchRaw); + registry.fill(HIST("NchVsOneParCorr"), nchMult, oneParCorr, w1); + registry.fill(HIST("NchVsTwoParCorr"), nchMult, twoParCorr, denTwoParCorr); + registry.fill(HIST("NchVsThreeParCorr"), nchMult, threeParCorr, denThreeParCorr); + + //--------------------------- Generated MC --------------------------- + std::vector pTsMC; + std::vector vecFullEff; + std::vector vecFDEqualOne; + + // Calculates the event weight, W_k + for (const auto& particle : mcParticles) { + if (particle.eta() < minEta || particle.eta() > maxEta) { + continue; + } + if (particle.pt() < minPt || particle.pt() > maxPt) { + continue; + } + + auto charge{0.}; + // Get the MC particle + auto* pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (pdgParticle != nullptr) { + charge = pdgParticle->Charge(); + } else { + continue; + } + + // Is it a charged particle? + if (std::abs(charge) < kMinCharge) { + continue; + } + // Is it a primary particle? + if (!particle.isPhysicalPrimary()) { + continue; + } + + float pt{particle.pt()}; + pTsMC.emplace_back(pt); + vecFullEff.emplace_back(1.); + vecFDEqualOne.emplace_back(1.); + nchMC++; + } + + if (nchMC < minNchSel) { + continue; + } + // printf("nchMult = %f | nchMC = %f | nchMult/nchMc = %f\n",nchMult,nchMC,nchMult/nchMC); + + double p1MC, p2MC, p3MC, p4MC, w1MC, w2MC, w3MC, w4MC; + p1MC = p2MC = p3MC = p4MC = w1MC = w2MC = w3MC = w4MC = 0.0; + getPTpowers(pTsMC, vecFullEff, vecFDEqualOne, p1MC, w1MC, p2MC, w2MC, p3MC, w3MC, p4MC, w4MC); + + const double denTwoParCorrMC{std::pow(w1MC, 2.) - w2MC}; + const double numTwoParCorrMC{std::pow(p1MC, 2.) - p2MC}; + const double denThreeParCorrMC{std::pow(w1MC, 3.) - 3. * w2MC * w1MC + 2. * w3MC}; + const double numThreeParCorrMC{std::pow(p1MC, 3.) - 3. * p2MC * p1MC + 2. * p3MC}; + // const double denFourParCorrMC{std::pow(w1MC, 4.) - 6. * w2MC * std::pow(w1MC, 2.) + 3. * std::pow(w2MC, 2.) + 8 * w3MC * w1MC - 6. * w4MC}; + // const double numFourParCorrMC{std::pow(p1MC, 4.) - 6. * p2MC * std::pow(p1MC, 2.) + 3. * std::pow(p2MC, 2.) + 8 * p3MC * p1MC - 6. * p4MC}; + + const double oneParCorrMC{p1MC / w1MC}; + const double twoParCorrMC{numTwoParCorrMC / denTwoParCorrMC}; + const double threeParCorrMC{numThreeParCorrMC / denThreeParCorrMC}; + // const double fourParCorrMC{numFourParCorrMC / denFourParCorrMC}; + + registry.fill(HIST("NchGen"), nchMC); + registry.fill(HIST("NchvsOneParCorrGen"), nchMC, oneParCorrMC, w1MC); + registry.fill(HIST("NchvsTwoParCorrGen"), nchMC, twoParCorrMC, denTwoParCorrMC); + registry.fill(HIST("NchvsThreeParCorrGen"), nchMC, threeParCorrMC, denThreeParCorrMC); + + //------------------ Poisson sampling + eventSamplingMC(mcParticles, timeStamp); + eventSamplingMCRec(groupedTracks, timeStamp); + } else { // Correction with the remaining half of the sample + registry.fill(HIST("EvtsDivided"), 1); + //----- MC reconstructed -----// + // const auto& groupedTracks{simTracks.sliceBy(perCollision, collision.globalIndex())}; + for (const auto& track : groupedTracks) { + // Track Selection + if (track.eta() < minEta || track.eta() > maxEta) { + continue; + } + if (track.pt() < minPt || track.pt() > maxPt) { + continue; + } + if (!track.isGlobalTrack()) { + continue; + } + registry.fill(HIST("ZposVsEta"), collision.posZ(), track.eta()); + registry.fill(HIST("EtaVsPhi"), track.eta(), track.phi()); + registry.fill(HIST("dcaXYvspT"), track.dcaXY(), track.pt()); + nchRaw++; + } + + for (const auto& track : groupedTracks) { + // Track Selection + if (track.eta() < minEta || track.eta() > maxEta) { + continue; + } + if (track.pt() < minPt || track.pt() > maxPt) { + continue; + } + if (!track.isGlobalTrack()) { + continue; + } + // Has MC particle? + if (!track.has_mcParticle()) { + continue; + } + // Get the MC particle + const auto& particle{track.mcParticle()}; + auto charge{0.}; + auto* pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (pdgParticle != nullptr) { + charge = pdgParticle->Charge(); + } else { + continue; + } + + // Is it a charged particle? + if (std::abs(charge) < kMinCharge) { + continue; + } + // All charged particles + registry.fill(HIST("Pt_all_ch"), nchRaw, track.pt()); + // Is it a primary particle? + if (!particle.isPhysicalPrimary()) { + continue; + } + + registry.fill(HIST("Pt_ch"), nchRaw, track.pt()); + if (particle.pdgCode() == PDG_t::kPiPlus || particle.pdgCode() == PDG_t::kPiMinus) { + registry.fill(HIST("Pt_pi"), nchRaw, track.pt()); + } else if (particle.pdgCode() == PDG_t::kKPlus || particle.pdgCode() == PDG_t::kKMinus) { + registry.fill(HIST("Pt_ka"), nchRaw, track.pt()); + } else if (particle.pdgCode() == PDG_t::kProton || particle.pdgCode() == PDG_t::kProtonBar) { + registry.fill(HIST("Pt_pr"), nchRaw, track.pt()); + } else if (particle.pdgCode() == PDG_t::kSigmaPlus || particle.pdgCode() == PDG_t::kSigmaBarMinus) { + registry.fill(HIST("Pt_sigpos"), nchRaw, track.pt()); + } else if (particle.pdgCode() == PDG_t::kSigmaMinus || particle.pdgCode() == PDG_t::kSigmaBarPlus) { + registry.fill(HIST("Pt_signeg"), nchRaw, track.pt()); + } else { + registry.fill(HIST("Pt_re"), nchRaw, track.pt()); + } + } + + // Generated MC + for (const auto& particle : mcParticles) { + if (particle.eta() < minEta || particle.eta() > maxEta) { + continue; + } + if (particle.pt() < minPt || particle.pt() > maxPt) { + continue; + } + + auto charge{0.}; + // Get the MC particle + auto* pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (pdgParticle != nullptr) { + charge = pdgParticle->Charge(); + } else { + continue; + } + + // Is it a charged particle? + if (std::abs(charge) < kMinCharge) { + continue; + } + // Is it a primary particle? + if (!particle.isPhysicalPrimary()) { + continue; + } + + registry.fill(HIST("PtMC_ch"), nchRaw, particle.pt()); + if (particle.pdgCode() == PDG_t::kPiPlus || particle.pdgCode() == PDG_t::kPiMinus) { // pion + registry.fill(HIST("PtMC_pi"), nchRaw, particle.pt()); + } else if (particle.pdgCode() == PDG_t::kKPlus || particle.pdgCode() == PDG_t::kKMinus) { // kaon + registry.fill(HIST("PtMC_ka"), nchRaw, particle.pt()); + } else if (particle.pdgCode() == PDG_t::kProton || particle.pdgCode() == PDG_t::kProtonBar) { // proton + registry.fill(HIST("PtMC_pr"), nchRaw, particle.pt()); + } else if (particle.pdgCode() == PDG_t::kSigmaPlus || particle.pdgCode() == PDG_t::kSigmaBarMinus) { // positive sigma + registry.fill(HIST("PtMC_sigpos"), nchRaw, particle.pt()); + } else if (particle.pdgCode() == PDG_t::kSigmaMinus || particle.pdgCode() == PDG_t::kSigmaBarPlus) { // negative sigma + registry.fill(HIST("PtMC_signeg"), nchRaw, particle.pt()); + } else { // rest + registry.fill(HIST("PtMC_re"), nchRaw, particle.pt()); + } + } + } // Half of statistics for corrections + registry.fill(HIST("McNchVsFT0M"), normT0M, nchRaw); + } // Collisions + } + PROCESS_SWITCH(UccZdc, processMCclosure, "Process MC closure", false); + + template + void getPTpowers(const T& pTs, const T& vecEff, const T& vecFD, U& pOne, U& wOne, U& pTwo, U& wTwo, U& pThree, U& wThree, U& pFour, U& wFour) + { + pOne = wOne = pTwo = wTwo = pThree = wThree = pFour = wFour = 0.; + for (std::size_t i = 0; i < pTs.size(); ++i) { + const double pTi{pTs.at(i)}; + const double eFFi{vecEff.at(i)}; + const double fDi{vecFD.at(i)}; + const double wEighti{std::pow(eFFi, -1.) * fDi}; + pOne += wEighti * pTi; + wOne += wEighti; + pTwo += std::pow(wEighti * pTi, 2.); + wTwo += std::pow(wEighti, 2.); + pThree += std::pow(wEighti * pTi, 3.); + wThree += std::pow(wEighti, 3.); + pFour += std::pow(wEighti * pTi, 4.); + wFour += std::pow(wEighti, 4.); + } + } + + template + void eventSamplingMC(const T& mcParticles, const V& timeStamp) + { + TRandom3 rndGen(timeStamp); + std::vector vPoisson; + for (int replica = 0; replica < kSizeBootStrapEnsemble; ++replica) + vPoisson.emplace_back(rndGen.Poisson(1.)); + + for (int replica = 0; replica < kSizeBootStrapEnsemble; ++replica) { + + hPoissonMC[replica]->Fill(vPoisson.at(replica)); + + for (uint64_t evtRep = 0; evtRep < vPoisson.at(replica); ++evtRep) { + + double nchMult{0.}; + std::vector pTs; + std::vector vecFD; + std::vector vecEff; + + // Calculates the event weight, W_k + for (const auto& particle : mcParticles) { + if (particle.eta() < minEta || particle.eta() > maxEta) { + continue; + } + if (particle.pt() < minPt || particle.pt() > maxPt) { + continue; + } + + auto charge{0.}; + // Get the MC particle + auto* pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (pdgParticle != nullptr) { + charge = pdgParticle->Charge(); + } else { + continue; + } + + // Is it a charged particle? + if (std::abs(charge) < kMinCharge) { + continue; + } + // Is it a primary particle? + if (!particle.isPhysicalPrimary()) { + continue; + } + + float pt{particle.pt()}; + pTs.emplace_back(pt); + vecEff.emplace_back(1.); + vecFD.emplace_back(1.); + nchMult++; + } + + if (nchMult < minNchSel) { + continue; + } + // printf("nchMult = %f | nchMC = %f | nchMult/nchMc = %f\n",nchMult,nchMC,nchMult/nchMC); + + double p1, p2, p3, p4, w1, w2, w3, w4; + p1 = p2 = p3 = p4 = w1 = w2 = w3 = w4 = 0.0; + getPTpowers(pTs, vecEff, vecFD, p1, w1, p2, w2, p3, w3, p4, w4); + + // EbE one-particle pT correlation + const double oneParCorr{p1 / w1}; + + // EbE two-particle pT correlation + const double denTwoParCorr{std::pow(w1, 2.) - w2}; + const double numTwoParCorr{std::pow(p1, 2.) - p2}; + const double twoParCorr{numTwoParCorr / denTwoParCorr}; + + // EbE three-particle pT correlation + const double denThreeParCorr{std::pow(w1, 3.) - 3. * w2 * w1 + 2. * w3}; + const double numThreeParCorr{std::pow(p1, 3.) - 3. * p2 * p1 + 2. * p3}; + const double threeParCorr{numThreeParCorr / denThreeParCorr}; + + hNchGen[replica]->Fill(nchMult); + + pOneParCorrVsNchGen[replica]->Fill(nchMult, oneParCorr, w1); + pTwoParCorrVsNchGen[replica]->Fill(nchMult, twoParCorr, denTwoParCorr); + pThreeParCorrVsNchGen[replica]->Fill(nchMult, threeParCorr, denThreeParCorr); + + // pOneParCorrVsV0AGen[replica]->Fill(normV0A, oneParCorr, w1); + // pTwoParCorrVsV0AGen[replica]->Fill(normV0A, twoParCorr, denTwoParCorr); + // pThreeParCorrVsV0AGen[replica]->Fill(normV0A, threeParCorr, denThreeParCorr); + + // pOneParCorrVsT0MGen[replica]->Fill(normT0M, oneParCorr, w1); + // pTwoParCorrVsT0MGen[replica]->Fill(normT0M, twoParCorr, denTwoParCorr); + // pThreeParCorrVsT0MGen[replica]->Fill(normT0M, threeParCorr, denThreeParCorr); + } // event per replica + } // replica's loop + } + + template + void eventSamplingMCRec(const T& tracks, const V& timeStamp) + { + TRandom3 rndGen(timeStamp); + std::vector vPoisson; + for (int replica = 0; replica < kSizeBootStrapEnsemble; ++replica) + vPoisson.emplace_back(rndGen.Poisson(1.)); + + for (int replica = 0; replica < kSizeBootStrapEnsemble; ++replica) { + + hPoisson[replica]->Fill(vPoisson.at(replica)); + + for (uint64_t evtRep = 0; evtRep < vPoisson.at(replica); ++evtRep) { + + double nchMult{0.}; + int glbTracks{0}; + std::vector pTs; + std::vector vecFD; + std::vector vecEff; + + // Calculates the uncorrected Nch multiplicity + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + glbTracks++; + } + + if (glbTracks < minNchSel) { + continue; + } + + // Calculates the Nch multiplicity if corrections are loaded + if (cfg.correctionsLoaded) { + const int foundNchBin{cfg.hEfficiency->GetXaxis()->FindBin(glbTracks)}; + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + + float pt{track.pt()}; + double fdValue{1.}; + int foundPtBin{cfg.hEfficiency->GetYaxis()->FindBin(pt)}; + double effValue{cfg.hEfficiency->GetBinContent(foundNchBin, foundPtBin)}; + + if (applyFD) + fdValue = cfg.hFeedDown->GetBinContent(foundNchBin, foundPtBin); + if ((effValue > 0.) && (fdValue > 0.)) { + nchMult += (std::pow(effValue, -1.) * fdValue); + } + } + } + + if (!applyEff) + nchMult = static_cast(glbTracks); + if (applyEff && !correctNch) + nchMult = static_cast(glbTracks); + + // Fill vectors for [pT] measurement + if (cfg.correctionsLoaded) { + const int foundNchBin{cfg.hEfficiency->GetXaxis()->FindBin(glbTracks)}; + // Fill vectors for [pT] measurement + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPtSpectra)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + + float pt{track.pt()}; + double fdValue{1.}; + int foundPtBin{cfg.hEfficiency->GetYaxis()->FindBin(pt)}; + double effValue{cfg.hEfficiency->GetBinContent(foundNchBin, foundPtBin)}; + + if (applyFD) + fdValue = cfg.hFeedDown->GetBinContent(foundNchBin, foundPtBin); + + if ((effValue > 0.) && (fdValue > 0.)) { + pTs.emplace_back(pt); + vecEff.emplace_back(effValue); + vecFD.emplace_back(fdValue); + } + } + } else { + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPtSpectra)) { + continue; + } + + pTs.emplace_back(track.pt()); + vecEff.emplace_back(1.); + vecFD.emplace_back(1.); + } + } + + double p1, p2, p3, p4, w1, w2, w3, w4; + p1 = p2 = p3 = p4 = w1 = w2 = w3 = w4 = 0.0; + getPTpowers(pTs, vecEff, vecFD, p1, w1, p2, w2, p3, w3, p4, w4); + + // EbE one-particle pT correlation + const double oneParCorr{p1 / w1}; + + // EbE two-particle pT correlation + const double denTwoParCorr{std::pow(w1, 2.) - w2}; + const double numTwoParCorr{std::pow(p1, 2.) - p2}; + const double twoParCorr{numTwoParCorr / denTwoParCorr}; + + // EbE three-particle pT correlation + const double denThreeParCorr{std::pow(w1, 3.) - 3. * w2 * w1 + 2. * w3}; + const double numThreeParCorr{std::pow(p1, 3.) - 3. * p2 * p1 + 2. * p3}; + const double threeParCorr{numThreeParCorr / denThreeParCorr}; + + hNch[replica]->Fill(nchMult); + + pOneParCorrVsNch[replica]->Fill(nchMult, oneParCorr, w1); + pTwoParCorrVsNch[replica]->Fill(nchMult, twoParCorr, denTwoParCorr); + pThreeParCorrVsNch[replica]->Fill(nchMult, threeParCorr, denThreeParCorr); + + // pOneParCorrVsV0A[replica]->Fill(normV0A, oneParCorr, w1); + // pTwoParCorrVsV0A[replica]->Fill(normV0A, twoParCorr, denTwoParCorr); + // pThreeParCorrVsV0A[replica]->Fill(normV0A, threeParCorr, denThreeParCorr); + // + // pOneParCorrVsT0M[replica]->Fill(normT0M, oneParCorr, w1); + // pTwoParCorrVsT0M[replica]->Fill(normT0M, twoParCorr, denTwoParCorr); + // pThreeParCorrVsT0M[replica]->Fill(normT0M, threeParCorr, denThreeParCorr); + } // event per replica + } // replica's loop + } + + template + void eventSampling(const T& tracks, const U& normV0A, const U& normT0M, const U& sumZNs, const V& timeStamp) + { + TRandom3 rndGen(timeStamp); + std::vector vPoisson; + for (int replica = 0; replica < kSizeBootStrapEnsemble; ++replica) + vPoisson.emplace_back(rndGen.Poisson(1.)); + + for (int replica = 0; replica < kSizeBootStrapEnsemble; ++replica) { + + hPoisson[replica]->Fill(vPoisson.at(replica)); + + for (uint64_t evtRep = 0; evtRep < vPoisson.at(replica); ++evtRep) { + + double nchMult{0.}; + int glbTracks{0}; + std::vector pTs; + std::vector vecFD; + std::vector vecEff; + + // Calculates the uncorrected Nch multiplicity + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + glbTracks++; + } + + if (glbTracks < minNchSel) { + continue; + } + + // Calculates the Nch multiplicity if corrections are loaded + if (cfg.correctionsLoaded) { + const int foundNchBin{cfg.hEfficiency->GetXaxis()->FindBin(glbTracks)}; + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPt)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + + float pt{track.pt()}; + double fdValue{1.}; + int foundPtBin{cfg.hEfficiency->GetYaxis()->FindBin(pt)}; + double effValue{cfg.hEfficiency->GetBinContent(foundNchBin, foundPtBin)}; + + if (applyFD) + fdValue = cfg.hFeedDown->GetBinContent(foundNchBin, foundPtBin); + if ((effValue > 0.) && (fdValue > 0.)) { + nchMult += (std::pow(effValue, -1.) * fdValue); + } + } + } + + if (!applyEff) + nchMult = static_cast(glbTracks); + if (applyEff && !correctNch) + nchMult = static_cast(glbTracks); + + // Fill vectors for [pT] measurement + if (cfg.correctionsLoaded) { + const int foundNchBin{cfg.hEfficiency->GetXaxis()->FindBin(glbTracks)}; + // Fill vectors for [pT] measurement + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPtSpectra)) { + continue; + } + if ((track.eta() < minEta) || (track.eta() > maxEta)) { + continue; + } + + float pt{track.pt()}; + double fdValue{1.}; + int foundPtBin{cfg.hEfficiency->GetYaxis()->FindBin(pt)}; + double effValue{cfg.hEfficiency->GetBinContent(foundNchBin, foundPtBin)}; + + if (applyFD) + fdValue = cfg.hFeedDown->GetBinContent(foundNchBin, foundPtBin); + + if ((effValue > 0.) && (fdValue > 0.)) { + pTs.emplace_back(pt); + vecEff.emplace_back(effValue); + vecFD.emplace_back(fdValue); + // To calculate event-averaged + registry.fill(HIST("NchVsZNVsPt"), nchMult, sumZNs, pt * (fdValue / effValue)); + } + } + } else { + for (const auto& track : tracks) { + // Track Selection + if (!track.isGlobalTrack()) { + continue; + } + if ((track.pt() < minPt) || (track.pt() > maxPtSpectra)) { + continue; + } + + pTs.emplace_back(track.pt()); + vecEff.emplace_back(1.); + vecFD.emplace_back(1.); + + // To calculate event-averaged + registry.fill(HIST("NchVsZNVsPt"), nchMult, sumZNs, track.pt()); + } + } + + double p1, p2, p3, p4, w1, w2, w3, w4; + p1 = p2 = p3 = p4 = w1 = w2 = w3 = w4 = 0.0; + getPTpowers(pTs, vecEff, vecFD, p1, w1, p2, w2, p3, w3, p4, w4); + + // EbE one-particle pT correlation + const double oneParCorr{p1 / w1}; + + // EbE two-particle pT correlation + const double denTwoParCorr{std::pow(w1, 2.) - w2}; + const double numTwoParCorr{std::pow(p1, 2.) - p2}; + const double twoParCorr{numTwoParCorr / denTwoParCorr}; + + // EbE three-particle pT correlation + const double denThreeParCorr{std::pow(w1, 3.) - 3. * w2 * w1 + 2. * w3}; + const double numThreeParCorr{std::pow(p1, 3.) - 3. * p2 * p1 + 2. * p3}; + const double threeParCorr{numThreeParCorr / denThreeParCorr}; + + hNch[replica]->Fill(nchMult); + pNchVsOneParCorrVsZN[replica]->Fill(nchMult, sumZNs, oneParCorr, w1); + pNchVsTwoParCorrVsZN[replica]->Fill(nchMult, sumZNs, twoParCorr, denTwoParCorr); + pNchVsThreeParCorrVsZN[replica]->Fill(nchMult, sumZNs, threeParCorr, denThreeParCorr); + + pOneParCorrVsV0A[replica]->Fill(normV0A, oneParCorr, w1); + pTwoParCorrVsV0A[replica]->Fill(normV0A, twoParCorr, denTwoParCorr); + pThreeParCorrVsV0A[replica]->Fill(normV0A, threeParCorr, denThreeParCorr); + + pOneParCorrVsT0M[replica]->Fill(normT0M, oneParCorr, w1); + pTwoParCorrVsT0M[replica]->Fill(normT0M, twoParCorr, denTwoParCorr); + pThreeParCorrVsT0M[replica]->Fill(normT0M, threeParCorr, denThreeParCorr); + } // event per replica + } // replica's loop + } + + void loadCorrections(uint64_t timeStamp) + { + // if (cfg.correctionsLoaded) return; + + if (paTHEff.value.empty() == false) { + cfg.hEfficiency = ccdb->getForTimeStamp(paTHEff, timeStamp); + if (cfg.hEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram from %s", paTHEff.value.c_str()); + } + } + + if (paTHFD.value.empty() == false) { + cfg.hFeedDown = ccdb->getForTimeStamp(paTHFD, timeStamp); + if (cfg.hFeedDown == nullptr) { + LOGF(fatal, "Could not load feed down histogram from %s", paTHFD.value.c_str()); + } + } + cfg.correctionsLoaded = true; + } + + void loadNchCalibrations(uint64_t timeStamp) + { + if (paTHmeanNch.value.empty() == false) { + cfgNch.hMeanNch = ccdb->getForTimeStamp(paTHmeanNch, timeStamp); + if (cfgNch.hMeanNch == nullptr) { + LOGF(fatal, "Could not load hMeanNch histogram from %s", paTHmeanNch.value.c_str()); + } + } + + if (paTHsigmaNch.value.empty() == false) { + cfgNch.hSigmaNch = ccdb->getForTimeStamp(paTHsigmaNch, timeStamp); + if (cfgNch.hSigmaNch == nullptr) { + LOGF(fatal, "Could not load hSigmaNch histogram from %s", paTHsigmaNch.value.c_str()); + } + } + cfgNch.calibrationsLoaded = true; + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Nuspex/AngularCorrelationsInJets.cxx b/PWGLF/Tasks/Nuspex/AngularCorrelationsInJets.cxx deleted file mode 100644 index 3fa2f9a4c76..00000000000 --- a/PWGLF/Tasks/Nuspex/AngularCorrelationsInJets.cxx +++ /dev/null @@ -1,1365 +0,0 @@ -// 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: Lars Jörgensen - -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "CCDB/BasicCCDBManager.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/Core/PID/PIDTOF.h" -#include "Common/TableProducer/PID/pidTOFBase.h" -#include "Common/DataModel/McCollisionExtra.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" - -#include "fastjet/PseudoJet.hh" -#include "fastjet/AreaDefinition.hh" -#include "fastjet/ClusterSequenceArea.hh" -#include "fastjet/GhostedAreaSpec.hh" -#include "PWGJE/Core/JetBkgSubUtils.h" -#include "TVector2.h" -#include "TVector3.h" -#include "TPDGCode.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct AxisSpecs { - AxisSpec ptAxisPos = {1000, 0, 100, "#it{p}_{T} [GeV/#it{c}]"}; - AxisSpec ptAxisFull = {2000, -100, 100, "#it{p}_{T} [GeV/#it{c}]"}; - AxisSpec nsigmapTAxis = {500, 0, 50, "#it{p}_{T} [GeV/#it{c}]"}; - AxisSpec nsigmaAxis = {300, -15, 15, "n#sigma"}; - AxisSpec dcazAxis = {1000, -1, 1, "DCA_{z} [cm]"}; - AxisSpec dcaxyAxis = {1000, -0.5, 0.5, "DCA_{xy} [cm]"}; - AxisSpec angDistPhiAxis = {1000, -2, 5, "#Delta#varphi"}; - AxisSpec angDistEtaAxis = {1000, -2, 2, "#Delta#eta"}; -}; - -struct AngularCorrelationsInJets { - // Preliminary Cuts - Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 70, "min number of crossed rows TPC"}; - Configurable minReqClusterITS{"minReqClusterITS", 2, "min number of clusters required in ITS"}; - Configurable minReqClusterTPC{"minReqClusterTPC", 70, "min number of clusters required in TPC"}; - Configurable minRatioCrossedRowsTPC{"minRatioCrossedRowsTPC", 0.7, "min ratio of crossed rows over findable clusters TPC"}; - Configurable maxChi2ITS{"maxChi2ITS", 36.0, "max chi2 per cluster ITS"}; - Configurable maxChi2TPC{"maxChi2TPC", 4.0, "max chi2 per cluster TPC"}; - Configurable maxDCAxy{"maxDCAxy", 0.5, "max DCA to vertex xy"}; - Configurable maxDCAz{"maxDCAz", 1.0, "max DCA to vertex z"}; - Configurable maxEta{"maxEta", 0.8, "max pseudorapidity"}; // consider jet cone? - - // Jet Cuts - Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; - Configurable minJetPt{"minJetPt", 5.0, "minimum total pT to accept jet"}; - Configurable minJetParticlePt{"minJetParticlePt", 0.0, "minimum pT to accept jet particle"}; - - // Proton Cuts - Configurable protonDCAxyYield{"protonDCAxyYield", 0.05, "[proton] DCAxy cut for yield"}; - Configurable protonDCAzYield{"protonDCAzYield", 1.0, "[proton] DCAz cut for yield"}; - Configurable protonDCAxyCF{"protonDCAxyCF", 0.05, "[proton] DCAxy cut for CF"}; - Configurable protonDCAzCF{"protonDCAzCF", 1.0, "[proton] DCAz cut for CF"}; - Configurable protonTPCTOFpT{"protonTPCTOFpT", 0.7, "[proton] pT for switch in TPC/TPC+TOF nsigma"}; - Configurable protonTPCnsigmaLowPtYield{"protonTPCnsigmaLowPtYield", 4.0, "[proton] max TPC nsigma with low pT for yield"}; - Configurable protonTPCnsigmaHighPtYield{"protonTPCnsigmaHighPtYield", 4.0, "[proton] max TPC nsigma with high pT for yield"}; - Configurable protonTOFnsigmaHighPtYield{"protonTOFnsigmaHighPtYield", 4.0, "[proton] max TOF nsigma with high pT yield"}; - Configurable protonNsigma{"protonNsigma", 2.0, "[proton] max combined nsigma for CF (sqrt(nsigTPC^2 + nsigTOF^2))"}; - - // Antiproton Cuts - Configurable antiprotonDCAxyYield{"antiprotonDCAxyYield", 0.05, "[antiproton] DCAxy cut for yield"}; - Configurable antiprotonDCAzYield{"antiprotonDCAzYield", 1.0, "[antiproton] DCAz cut for yield"}; - Configurable antiprotonDCAxyCF{"antiprotonDCAxyCF", 0.05, "[antiproton] DCAxy cut for CF"}; - Configurable antiprotonDCAzCF{"antiprotonDCAzCF", 1.0, "[antiproton] DCAz cut for CF"}; - Configurable antiprotonTPCTOFpT{"antiprotonTPCTOFpT", 0.7, "[antiproton] pT for switch in TPC/TPC+TOF nsigma"}; - Configurable antiprotonTPCnsigmaLowPtYield{"antiprotonTPCnsigmaLowPtYield", 4.0, "[antiproton] max TPC nsigma with low pT for yield"}; - Configurable antiprotonTPCnsigmaHighPtYield{"antiprotonTPCnsigmaHighPtYield", 4.0, "[antiproton] max TPC nsigma with high pT for yield"}; - Configurable antiprotonTOFnsigmaHighPtYield{"antiprotonTOFnsigmaHighPtYield", 4.0, "[antiproton] min TOF nsigma with high pT for yield"}; - Configurable antiprotonNsigma{"antiprotonNsigma", 2.0, "[antiproton] max combined nsigma for CF (sqrt(nsigTPC^2 + nsigTOF^2))"}; - - // Nuclei Cuts - Configurable nucleiDCAxyYield{"nucleiDCAxyYield", 0.05, "[nuclei] DCAxy cut for yield"}; - Configurable nucleiDCAzYield{"nucleiDCAzYield", 1.0, "[nuclei] DCAz cut for yield"}; - Configurable nucleiDCAxyCF{"nucleiDCAxyCF", 0.05, "[nuclei] DCAxy cut for CF"}; - Configurable nucleiDCAzCF{"nucleiDCAzCF", 1.0, "[nuclei] DCAz cut for CF"}; - Configurable nucleiTPCTOFpT{"nucleiTPCTOFpT", 0.7, "[nuclei] pT for switch in TPC/TPC+TOF nsigma"}; - Configurable nucleiTPCnsigmaLowPtYield{"nucleiTPCnsigmaLowPtYield", 4.0, "[nuclei] max TPC nsigma with low pT for yield"}; - Configurable nucleiTPCnsigmaHighPtYield{"nucleiTPCnsigmaHighPtYield", 4.0, "[nuclei] max TPC nsigma with high pT for yield"}; - Configurable nucleiTOFnsigmaHighPtYield{"nucleiTOFnsigmaHighPtYield", 4.0, "[nuclei] min TOF nsigma with high pT for yield"}; - Configurable nucleiNsigma{"nucleiNsigma", 2.0, "[nuclei] max combined nsigma for CF (sqrt(nsigTPC^2 + nsigTOF^2))"}; - - // Antinuclei Cuts - Configurable antinucleiDCAxyYield{"antinucleiDCAxyYield", 0.05, "[antinuclei] DCAxy cut for yield"}; - Configurable antinucleiDCAzYield{"antinucleiDCAzYield", 1.0, "[antinuclei] DCAz cut for yield"}; - Configurable antinucleiDCAxyCF{"antinucleiDCAxyCF", 0.05, "[antinuclei] DCAxy cut for CF"}; - Configurable antinucleiDCAzCF{"antinucleiDCAzCF", 1.0, "[antinuclei] DCAz cut for CF"}; - Configurable antinucleiTPCTOFpT{"antinucleiTPCTOFpT", 0.7, "[antinuclei] pT for switch in TPC/TPC+TOF nsigma"}; - Configurable antinucleiTPCnsigmaLowPtYield{"antinucleiTPCnsigmaLowPtYield", 4.0, "[antinuclei] max TPC nsigma with low pT for yield"}; - Configurable antinucleiTPCnsigmaHighPtYield{"antinucleiTPCnsigmaHighPtYield", 4.0, "[antinuclei] max TPC nsigma with high pT for yield"}; - Configurable antinucleiTOFnsigmaHighPtYield{"antinucleiTOFnsigmaHighPtYield", 4.0, "[antinuclei] min TOF nsigma with high pT for yield"}; - Configurable antinucleiNsigma{"antinucleiNsigma", 2.0, "[nuclei] max combined nsigma for CF (sqrt(nsigTPC^2 + nsigTOF^2))"}; - - Configurable nsigmaRejection{"nsigmaRejection", 3.0, "particles with TPC nsigma < nsigmaRejection other than the species in question will be rejected"}; - - Configurable deuteronAnalysis{"deuteronAnalysis", true, "true [false]: analyse (anti)deuterons [(anti)helium-3]"}; - Configurable useTOFmass{"useTOFmass", true, "use TOF mass instead of pion mass if available"}; - - Configurable trackBufferSize{"trackBufferSize", 200, "Number of mixed-event tracks being stored"}; - - // QC Configurables - Configurable zVtx{"zVtx", 10.0, "max zVertex"}; - Configurable Rmax{"Rmax", 0.4, "Maximum radius for jet and UE regions"}; - - Service ccdb; - int mRunNumber; - - using FullTracksRun2 = soa::Join; - using FullTracksRun3 = soa::Join; - using McTracksRun2 = soa::Join; - using McTracksRun3 = soa::Join; - using BCsWithRun2Info = soa::Join; - using McCollisions = soa::Join; - - Filter prelimTrackCuts = (aod::track::itsChi2NCl < maxChi2ITS && - aod::track::tpcChi2NCl < maxChi2TPC && - nabs(aod::track::dcaXY) < maxDCAxy && - nabs(aod::track::dcaZ) < maxDCAz && - nabs(aod::track::eta) < maxEta); // add more preliminary cuts to filter if possible - - Preslice perCollisionFullTracksRun2 = o2::aod::track::collisionId; - Preslice perCollisionFullTracksRun3 = o2::aod::track::collisionId; - Preslice perCollisionMcTracksRun2 = o2::aod::track::collisionId; - Preslice perCollisionMcTracksRun3 = o2::aod::track::collisionId; - - AxisSpecs axisSpecs; - - HistogramRegistry registryData{"dataOutput", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; - HistogramRegistry registryMC{"MCOutput", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; - HistogramRegistry registryQA{"dataQA", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; - - JetBkgSubUtils bkgSub; - - void init(o2::framework::InitContext&) - { - mRunNumber = 0; - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - // Counters - registryData.add("hNumberOfEvents", "Number of events", HistType::kTH1I, {{1, 0, 1}}); - registryData.add("hNumberOfJets", "Total number of jets", HistType::kTH1I, {{1, 0, 1}}); - registryData.add("hEventProtocol", "Event protocol", HistType::kTH1I, {{20, 0, 20}}); - registryData.add("hTrackProtocol", "Track protocol", HistType::kTH1I, {{20, 0, 20}}); - registryData.add("hNumPartInJet", "Number of particles in a jet", HistType::kTH1I, {{200, 0, 200}}); - registryData.add("hNumJetsInEvent", "Number of jets selected", HistType::kTH1I, {{10, 0, 10}}); - - // (Pseudo)Rapidity - registryData.add("hJetRapidity", "Jet rapidity;#it{y}", HistType::kTH1F, {{200, -1, 1}}); - - // pT - registryData.add("hPtJetParticle", "p_{T} of particles in jets", HistType::kTH1D, {axisSpecs.ptAxisPos}); - registryData.add("hPtTotalSubJetArea", "Subtracted full jet p_{T} (area)", HistType::kTH1D, {axisSpecs.ptAxisPos}); - registryData.add("hPtTotalSubJetPerp", "Subtracted full jet p_{T} (perpendicular)", HistType::kTH1D, {axisSpecs.ptAxisPos}); - registryData.add("hPtJetProton", "p_{T} of protons", HistType::kTH1D, {axisSpecs.ptAxisPos}); - registryData.add("hPtJetAntiproton", "p_{T} of antiprotons", HistType::kTH1D, {axisSpecs.ptAxisPos}); - registryData.add("hPtJetNuclei", "p_{T} of nuclei", HistType::kTH1D, {axisSpecs.ptAxisPos}); - registryData.add("hPtJetAntinuclei", "p_{T} of antinuclei", HistType::kTH1D, {axisSpecs.ptAxisPos}); - registryData.add("hPtTotalJet", "p_{T} of entire jet;#it{p}_{T} [GeV/#it{c}]", HistType::kTH1F, {{1000, 0, 500}}); - registryQA.add("hPtJetProtonVsTotalJet", "Proton p_{T} vs. jet p_{T}", HistType::kTH2D, {axisSpecs.ptAxisPos, {1000, 0, 500, "jet p_{T} [GeV/#it{c}]"}}); - registryQA.add("hPtJetAntiprotonVsTotalJet", "Antiproton p_{T} vs. jet p_{T}", HistType::kTH2D, {axisSpecs.ptAxisPos, {1000, 0, 500, "jet p_{T} [GeV/#it{c}]"}}); - registryQA.add("hPtJetNucleiVsTotalJet", "Nuclei p_{T} vs. jet p_{T}", HistType::kTH2D, {axisSpecs.ptAxisPos, {1000, 0, 500, "jet p_{T} [GeV/#it{c}]"}}); - registryQA.add("hPtJetAntinucleiVsTotalJet", "Antinuclei p_{T} vs. jet p_{T}", HistType::kTH2D, {axisSpecs.ptAxisPos, {1000, 0, 500, "jet p_{T} [GeV/#it{c}]"}}); - - // nSigma - registryData.add("hTPCsignal", "TPC signal", HistType::kTH2F, {{1000, -100, 100, "#it{p} [GeV/#it{c}]"}, {1000, 0, 5000, "d#it{E}/d#it{X} (a.u.)"}}); - registryData.add("hTOFsignal", "TOF signal", HistType::kTH2F, {{1000, -100, 100, "#it{p} [GeV/#it{c}]"}, {550, 0, 1.1, "#beta (TOF)"}}); - registryData.add("hTPCnsigmaProton", "TPC n#sigma for proton", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTOFnsigmaProton", "TOF n#sigma for proton", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTPCnsigmaAntiproton", "TPC n#sigma for antiproton", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTOFnsigmaAntiproton", "TOF n#sigma for antiproton", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTPCnsigmaNuclei", "TPC n#sigma for nuclei", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTOFnsigmaNuclei", "TOF n#sigma for nuclei", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTPCnsigmaAntinuclei", "TPC n#sigma for antinuclei", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTOFnsigmaAntinuclei", "TOF n#sigma for antinuclei", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTPCnsigmaProtonCF", "TPC n#sigma for proton CF", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTOFnsigmaProtonCF", "TOF n#sigma for proton CF", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTPCnsigmaAntiprotonCF", "TPC n#sigma for antiproton CF", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTOFnsigmaAntiprotonCF", "TOF n#sigma for antiproton CF", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTPCnsigmaNucleiCF", "TPC n#sigma for nuclei CF", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTOFnsigmaNucleiCF", "TOF n#sigma for nuclei CF", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTPCnsigmaAntinucleiCF", "TPC n#sigma for antinuclei CF", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - registryData.add("hTOFnsigmaAntinucleiCF", "TOF n#sigma for antinuclei CF", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); - - // DCA - registryData.add("hDCAxyFullJet", "DCA_{xy} of full jet", HistType::kTH2F, {axisSpecs.ptAxisFull, axisSpecs.dcaxyAxis}); - registryData.add("hDCAzFullJet", "DCA_{z} of full jet", HistType::kTH2F, {axisSpecs.ptAxisFull, axisSpecs.dcazAxis}); - registryData.add("hDCAzJetProton", "DCA_{z} of high purity protons", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); - registryData.add("hDCAzJetAntiproton", "DCA_{z} of high purity antiprotons", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); - registryData.add("hDCAzJetNuclei", "DCA_{z} of high purity nuclei", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); - registryData.add("hDCAzJetAntinuclei", "DCA_{z} of high purity antinuclei", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); - - // Angular Distributions - registryQA.add("hPhiFullEvent", "#varphi in full event", HistType::kTH1F, {{1000, 0, 6.3}}); - registryQA.add("hPhiPtFullEvent", "#varphi vs. p_{T} in full event", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, 0, 6.3}}); - registryQA.add("hPhiJet", "#varphi in jet", HistType::kTH1F, {{1000, 0, 6.3}}); - registryQA.add("hPhiPtJet", "#varphi vs. p_{T} in jet", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, 0, 6.3}}); - registryQA.add("hEtaFullEvent", "#eta in full event", HistType::kTH1F, {{1000, -1, 1}}); - registryQA.add("hEtaPtFullEvent", "#eta vs. p_{T} in full event", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, -1, 1}}); - registryQA.add("hEtaJet", "#eta in jet", HistType::kTH1F, {{1000, -1, 1}}); - registryQA.add("hEtaPtJet", "#eta vs. p_{T} in jet", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, -1, 1}}); - - registryData.add("hDeltaPhiSEFull", "#Delta#varphi of particles in single event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiSEJet", "#Delta#varphi of jet particles in single event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiSEProton", "#Delta#varphi of protons in single event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiSEAntiproton", "#Delta#varphi of antiprotons in single event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiSENuclei", "#Delta#varphi of nuclei in single event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiSEAntinuclei", "#Delta#varphi of antinuclei in single event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiMEFull", "#Delta#varphi of particles in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiMEJet", "#Delta#varphi of jet particles in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiMEProton", "#Delta#varphi of protons in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiMEAntiproton", "#Delta#varphi of antiprotons in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiMENuclei", "#Delta#varphi of nuclei in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiMEAntinuclei", "#Delta#varphi of antinuclei in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); - registryData.add("hDeltaPhiEtaSEFull", "#Delta#varphi vs #Delta#eta of full particles in single event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaSEJet", "#Delta#varphi vs #Delta#eta of jet particles in single event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaSEProton", "#Delta#varphi vs #Delta#eta of protons in single event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaSEAntiproton", "#Delta#varphi vs #Delta#eta of antiprotons in single event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaSENuclei", "#Delta#varphi vs #Delta#eta of nuclei in single event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaSEAntinuclei", "#Delta#varphi vs #Delta#eta of antinuclei in single event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaMEFull", "#Delta#varphi vs #Delta#eta of particles in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaMEJet", "#Delta#varphi vs #Delta#eta of jet particles in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaMEProton", "#Delta#varphi vs #Delta#eta of protons in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaMEAntiproton", "#Delta#varphi vs #Delta#eta of antiprotons in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaMENuclei", "#Delta#varphi vs #Delta#eta of nuclei in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - registryData.add("hDeltaPhiEtaMEAntinuclei", "#Delta#varphi vs #Delta#eta of antinuclei in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); - - // QA - registryQA.add("hPtDiff", "p_{T} difference PseudoJet/original track;#it{p}_{T} [GeV/#it{c}]", HistType::kTH1D, {{100, -5, 5}}); - registryQA.add("hJetConeRadius", "Jet Radius;#it{R}", HistType::kTH1F, {{100, 0, 1}}); - registryQA.add("hMaxRadiusVsPt", "Max Cone Radius vs p_{T}", HistType::kTH2F, {{axisSpecs.ptAxisPos}, {100, 0, 1}}); - registryQA.add("hRhoEstimatePerp", "Background #rho (perp)", HistType::kTH2F, {{axisSpecs.ptAxisPos}, {200, 0, 20}}); - registryQA.add("hRhoMEstimatePerp", "Background #rho_{m} (perp)", HistType::kTH2F, {{axisSpecs.ptAxisPos}, {200, 0, 20}}); - registryQA.add("hRhoEstimateArea", "Background #rho (area)", HistType::kTH2F, {{axisSpecs.ptAxisPos}, {200, 0, 20}}); - registryQA.add("hRhoMEstimateArea", "Background #rho_{m} (area)", HistType::kTH2F, {{axisSpecs.ptAxisPos}, {200, 0, 20}}); - registryQA.add("hJetBkgDeltaPt", "#Delta p_{T} Clustered Cone - Pure Jet", HistType::kTH1F, {{200, 0, 10}}); - - registryQA.add("hTOFmass", "TOF mass vs p_{T}", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, 0, 5, "#it{m} [GeV/#it{c}^{2}]"}}); - registryQA.get(HIST("hTOFmass"))->Sumw2(); - registryQA.add("hPtFullEvent", "p_{T} after basic cuts", HistType::kTH1F, {axisSpecs.ptAxisPos}); - registryQA.add("hCrossedRowsTPC", "Crossed rows TPC", HistType::kTH2I, {axisSpecs.ptAxisPos, {135, 65, 200}}); - registryQA.add("hClusterITS", "ITS clusters", HistType::kTH2I, {axisSpecs.ptAxisPos, {10, 0, 10}}); - registryQA.add("hClusterTPC", "TPC clusters", HistType::kTH2I, {axisSpecs.ptAxisPos, {135, 65, 200}}); - registryQA.add("hRatioCrossedRowsTPC", "Ratio crossed rows/findable TPC", HistType::kTH2F, {axisSpecs.ptAxisPos, {100, 0.5, 1.5}}); - registryQA.add("hChi2ITS", "ITS #chi^{2}", HistType::kTH2F, {axisSpecs.ptAxisPos, {400, 0, 40}}); - registryQA.add("hChi2TPC", "TPC #chi^{2}", HistType::kTH2F, {axisSpecs.ptAxisPos, {50, 0, 5}}); - registryQA.add("hDCAxyFullEvent", "DCA_{xy} of full event", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcaxyAxis}); - registryQA.add("hDCAzFullEvent", "DCA_{z} of full event", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); - registryQA.add("hJetPtVsNumPart", "Total jet p_{T} vs number of constituents", HistType::kTH2F, {axisSpecs.ptAxisPos, {100, 0, 100}}); - - // QA Histograms for Comparison with nuclei_in_jets.cxx - registryQA.add("hMultiplicityJetPlusUE", "hMultiplicityJetPlusUE", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); - registryQA.add("hMultiplicityJet", "hMultiplicityJet", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); - registryQA.add("hMultiplicityUE", "hMultiplicityUE", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); - registryQA.add("hPtJetPlusUE", "hPtJetPlusUE", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQA.add("hPtJet", "hPtJet", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQA.add("hPtUE", "hPtUE", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQA.add("hDeltaEtadeltaPhiJet", "hDeltaEtadeltaPhiJet", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, 0.5 * TMath::Pi(), "#Delta#phi"}}); - registryQA.add("hDeltaEtadeltaPhiUE", "hDeltaEtadeltaPhiUE", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, 0.5 * TMath::Pi(), "#Delta#phi"}}); - registryQA.add("hDeltaJetPt", "hDeltaJetPt", HistType::kTH1F, {{200, -2, 2, "#Delta#it{p}_{T} (GeV/#it{c})"}}); - - registryQA.add("hNParticlesClusteredInJet", "hNParticlesClusteredInJet", HistType::kTH1F, {{50, 0, 50, "#it{N}_{ch}"}}); - registryQA.add("hPtParticlesClusteredInJet", "hPtParticlesClusteredInJet", HistType::kTH1F, {{200, 0, 10, "#it{p}_{T} (GeV/#it{c})"}}); - - // MC - registryMC.add("hPtJetProtonMC", "Truth jet proton p_{T}", HistType::kTH1F, {axisSpecs.ptAxisPos}); - registryMC.add("hPtJetAntiprotonMC", "Truth jet antiproton p_{T}", HistType::kTH1F, {axisSpecs.ptAxisPos}); - registryMC.add("hPtJetNucleiMC", "Truth jet nuclei p_{T}", HistType::kTH1F, {axisSpecs.ptAxisPos}); - registryMC.add("hPtJetAntinucleiMC", "Truth jet antinuclei p_{T}", HistType::kTH1F, {axisSpecs.ptAxisPos}); - registryMC.add("hNumberOfTruthParticles", "Truth yields (anti)p, (anti)d, (anti)He-3", HistType::kTH1I, {{6, 0, 6}}); - } - - std::vector> fBufferProton; - std::vector> fBufferAntiproton; - std::vector> fBufferNuclei; - std::vector> fBufferAntinuclei; - std::vector> fBufferJet; - std::vector> fBufferFull; - - template - void initCCDB(Bc const& bc) - { - if (mRunNumber == bc.runNumber()) { - return; - } - mRunNumber = bc.runNumber(); - } - - template - bool selectTrack(T const& track) // preliminary track selections - { - if (track.tpcNClsCrossedRows() < minRatioCrossedRowsTPC * track.tpcNClsFindable() || - track.tpcNClsCrossedRows() < minNCrossedRowsTPC || - track.tpcNClsFound() < minReqClusterTPC || - track.itsNCls() < minReqClusterITS) { - return false; - } - if (doprocessRun2 || doprocessMCRun2) { - if (!(track.trackType() & o2::aod::track::Run2Track) || - !(track.flags() & o2::aod::track::TPCrefit) || - !(track.flags() & o2::aod::track::ITSrefit)) { - return false; - } - } - return true; - } - - template - bool singleSpeciesTPCNSigma(T const& track, int species) // make cut configurable - { // reject any track that has nsigma < 3 for more than 1 species - if (track.tpcNSigmaStoreEl() < nsigmaRejection || track.tpcNSigmaStoreMu() < nsigmaRejection || track.tpcNSigmaStorePi() < nsigmaRejection || track.tpcNSigmaStoreKa() < nsigmaRejection || track.tpcNSigmaStoreTr() < nsigmaRejection || track.tpcNSigmaStoreAl() < nsigmaRejection) - return false; - switch (species) { // guard against nsigmaRejection being lower than nsigma cuts that are applied before this function - case 1: // proton - return (track.tpcNSigmaPr() < protonNsigma && track.tpcNSigmaDe() > nsigmaRejection && track.tpcNSigmaHe() > nsigmaRejection); - break; - case 2: // antiproton - return (track.tpcNSigmaPr() < antiprotonNsigma && track.tpcNSigmaDe() > nsigmaRejection && track.tpcNSigmaHe() > nsigmaRejection); - break; - case 3: // deuteron - return (track.tpcNSigmaDe() < nucleiNsigma && track.tpcNSigmaPr() > nsigmaRejection && track.tpcNSigmaHe() > nsigmaRejection); - break; - case 4: // antideuteron - return (track.tpcNSigmaDe() < antinucleiNsigma && track.tpcNSigmaPr() > nsigmaRejection && track.tpcNSigmaHe() > nsigmaRejection); - break; - case 5: // helium-3 - return (track.tpcNSigmaHe() < nucleiNsigma && track.tpcNSigmaDe() > nsigmaRejection && track.tpcNSigmaPr() > nsigmaRejection); - break; - case 6: // antihelium-3 - return (track.tpcNSigmaHe() < antinucleiNsigma && track.tpcNSigmaDe() > nsigmaRejection && track.tpcNSigmaPr() > nsigmaRejection); - break; - default: - return false; - } - } - - template - bool isProton(const T& track, bool tightCuts) - { - if (track.sign() < 0) - return false; - - if (tightCuts) { // for correlation function - // DCA - if (TMath::Abs(track.dcaXY()) > protonDCAxyCF) - return false; - if (TMath::Abs(track.dcaZ()) > protonDCAzCF) - return false; - - registryData.fill(HIST("hTPCnsigmaProtonCF"), track.pt(), track.tpcNSigmaPr()); - if (track.hasTOF()) - registryData.fill(HIST("hTOFnsigmaProtonCF"), track.pt(), track.tofNSigmaPr()); - - // nsigma - double tofNsigma = track.hasTOF() ? track.tofNSigmaPr() : 999; - if ((track.pt() < protonTPCTOFpT && (TMath::Abs(track.tpcNSigmaPr()) > protonNsigma)) || (track.pt() > protonTPCTOFpT && (TMath::Sqrt(track.tpcNSigmaPr() * track.tpcNSigmaPr() + tofNsigma * tofNsigma) > protonNsigma))) - if (TMath::Sqrt(track.tpcNSigmaPr() * track.tpcNSigmaPr() + tofNsigma * tofNsigma) > protonNsigma) - return false; - if (!singleSpeciesTPCNSigma(track, 1)) - return false; - } else { // for yields - // DCA - if (TMath::Abs(track.dcaXY()) > protonDCAxyYield) - return false; - if (TMath::Abs(track.dcaZ()) > protonDCAzYield) - return false; - - registryData.fill(HIST("hTPCnsigmaProton"), track.pt(), track.tpcNSigmaPr()); - - // TPC - if (track.pt() < protonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > protonTPCnsigmaLowPtYield) - return false; - if (track.pt() > protonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > protonTPCnsigmaHighPtYield) - return false; - - // TOF - if (track.hasTOF()) { - registryData.fill(HIST("hTOFnsigmaProton"), track.pt(), track.tofNSigmaPr()); - if (track.pt() > protonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) > protonTOFnsigmaHighPtYield) - return false; - } - } - - return true; - } - - template - bool isAntiproton(const T& track, bool tightCuts) - { - if (track.sign() > 0) - return false; - - if (tightCuts) { // for correlation function - // DCA - if (TMath::Abs(track.dcaXY()) > antiprotonDCAxyCF) - return false; - if (TMath::Abs(track.dcaZ()) > antiprotonDCAzCF) - return false; - - registryData.fill(HIST("hTPCnsigmaAntiprotonCF"), track.pt(), track.tpcNSigmaPr()); - if (track.hasTOF()) - registryData.fill(HIST("hTOFnsigmaAntiprotonCF"), track.pt(), track.tofNSigmaPr()); - - // nsigma - double tofNsigma = track.hasTOF() ? track.tofNSigmaPr() : 999; - if ((track.pt() < antiprotonTPCTOFpT && (TMath::Abs(track.tpcNSigmaPr()) > antiprotonNsigma)) || (track.pt() > antiprotonTPCTOFpT && (TMath::Sqrt(track.tpcNSigmaPr() * track.tpcNSigmaPr() + tofNsigma * tofNsigma) > antiprotonNsigma))) - return false; - if (!singleSpeciesTPCNSigma(track, 2)) - return false; - } else { // for yields - // DCA - if (TMath::Abs(track.dcaXY()) > antiprotonDCAxyYield) - return false; - if (TMath::Abs(track.dcaZ()) > antiprotonDCAzYield) - return false; - - registryData.fill(HIST("hTPCnsigmaAntiproton"), track.pt(), track.tpcNSigmaPr()); - - // TPC - if (track.pt() < antiprotonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > antiprotonTPCnsigmaLowPtYield) - return false; - if (track.pt() > antiprotonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > antiprotonTPCnsigmaHighPtYield) - return false; - - // TOF - if (track.hasTOF()) { - registryData.fill(HIST("hTOFnsigmaAntiproton"), track.pt(), track.tofNSigmaPr()); - if (track.pt() > antiprotonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) > antiprotonTOFnsigmaHighPtYield) - return false; - } - } - - return true; - } - - template - bool isNucleus(const T& track, bool tightCuts) - { - if (track.sign() < 0) - return false; - if (deuteronAnalysis) { - if (tightCuts) { // for correlation function - // DCA - if (TMath::Abs(track.dcaXY()) > nucleiDCAxyCF) - return false; - if (TMath::Abs(track.dcaZ()) > nucleiDCAzCF) - return false; - - registryData.fill(HIST("hTPCnsigmaNucleiCF"), track.pt(), track.tpcNSigmaDe()); - if (track.hasTOF()) - registryData.fill(HIST("hTOFnsigmaNucleiCF"), track.pt(), track.tofNSigmaDe()); - - // nsigma - double tofNsigma = track.hasTOF() ? track.tofNSigmaDe() : 999; - if ((track.pt() < nucleiTPCTOFpT && (TMath::Abs(track.tpcNSigmaDe()) > nucleiNsigma)) || (track.pt() > nucleiTPCTOFpT && (TMath::Sqrt(track.tpcNSigmaDe() * track.tpcNSigmaDe() + tofNsigma * tofNsigma) > nucleiNsigma))) - return false; - if (!singleSpeciesTPCNSigma(track, 3)) - return false; - } else { // for yields - // DCA - if (TMath::Abs(track.dcaXY()) > nucleiDCAxyYield) - return false; - if (TMath::Abs(track.dcaZ()) > nucleiDCAzYield) - return false; - - registryData.fill(HIST("hTPCnsigmaNuclei"), track.pt(), track.tpcNSigmaDe()); - - // TPC - if (track.pt() < nucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > nucleiTPCnsigmaLowPtYield) - return false; - if (track.pt() > nucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > nucleiTPCnsigmaHighPtYield) - return false; - - // TOF - if (track.hasTOF()) { - registryData.fill(HIST("hTOFnsigmaNuclei"), track.pt(), track.tofNSigmaDe()); - if (track.pt() > nucleiTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) > nucleiTOFnsigmaHighPtYield) - return false; - } - } - } else { - if (tightCuts) { // for correlation function - including for helium just in case, but realistically, angular correlations won't be a thing here - // DCA - if (TMath::Abs(track.dcaXY()) > nucleiDCAxyCF) - return false; - if (TMath::Abs(track.dcaZ()) > nucleiDCAzCF) - return false; - - registryData.fill(HIST("hTPCnsigmaNucleiCF"), track.pt(), track.tpcNSigmaHe()); - if (track.hasTOF()) - registryData.fill(HIST("hTOFnsigmaNucleiCF"), track.pt(), track.tofNSigmaHe()); - - // nsigma - double tofNsigma = track.hasTOF() ? track.tofNSigmaHe() : 999; - if ((track.pt() < nucleiTPCTOFpT && (TMath::Abs(track.tpcNSigmaHe()) > nucleiNsigma)) || (track.pt() > nucleiTPCTOFpT && (TMath::Sqrt(track.tpcNSigmaHe() * track.tpcNSigmaHe() + tofNsigma * tofNsigma) > nucleiNsigma))) - return false; - if (!singleSpeciesTPCNSigma(track, 5)) - return false; - } else { // for yields - // DCA - if (TMath::Abs(track.dcaXY()) > nucleiDCAxyYield) - return false; - if (TMath::Abs(track.dcaZ()) > nucleiDCAzYield) - return false; - - registryData.fill(HIST("hTPCnsigmaNuclei"), track.pt(), track.tpcNSigmaHe()); - - // TPC - if (track.pt() < nucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > nucleiTPCnsigmaLowPtYield) - return false; - if (track.pt() > nucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > nucleiTPCnsigmaHighPtYield) - return false; - - // TOF - if (track.hasTOF()) { - registryData.fill(HIST("hTOFnsigmaNuclei"), track.pt(), track.tofNSigmaHe()); - if (track.pt() > nucleiTPCTOFpT && TMath::Abs(track.tofNSigmaHe()) > nucleiTOFnsigmaHighPtYield) - return false; - } - } - } - - return true; - } - - template - bool isAntinucleus(const T& track, bool tightCuts) - { - if (track.sign() > 0) - return false; - - if (deuteronAnalysis) { - if (tightCuts) { // for correlation function - // DCA - if (TMath::Abs(track.dcaXY()) > antinucleiDCAxyCF) - return false; - if (TMath::Abs(track.dcaZ()) > antinucleiDCAzCF) - return false; - - registryData.fill(HIST("hTPCnsigmaAntinucleiCF"), track.pt(), track.tpcNSigmaDe()); - if (track.hasTOF()) - registryData.fill(HIST("hTOFnsigmaAntinucleiCF"), track.pt(), track.tofNSigmaDe()); - - // nsigma - double tofNsigma = track.hasTOF() ? track.tofNSigmaDe() : 999; - if ((track.pt() < antinucleiTPCTOFpT && (TMath::Abs(track.tpcNSigmaDe()) > antinucleiNsigma)) || (track.pt() > antinucleiTPCTOFpT && (TMath::Sqrt(track.tpcNSigmaDe() * track.tpcNSigmaDe() + tofNsigma * tofNsigma) > antinucleiNsigma))) - return false; - if (!singleSpeciesTPCNSigma(track, 4)) - return false; - } else { // for yields - // DCA - if (TMath::Abs(track.dcaXY()) > antinucleiDCAxyYield) - return false; - if (TMath::Abs(track.dcaZ()) > antinucleiDCAzYield) - return false; - - registryData.fill(HIST("hTPCnsigmaAntinuclei"), track.pt(), track.tpcNSigmaDe()); - - // TPC - if (track.pt() < antinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > antinucleiTPCnsigmaLowPtYield) - return false; - if (track.pt() > antinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > antinucleiTPCnsigmaHighPtYield) - return false; - - // TOF - if (track.hasTOF()) { - registryData.fill(HIST("hTOFnsigmaAntinuclei"), track.pt(), track.tofNSigmaDe()); - if (track.pt() > antinucleiTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) > antinucleiTOFnsigmaHighPtYield) - return false; - } - } - } else { - if (tightCuts) { // for correlation function - including for antihelium just in case, but realistically, angular correlations won't be a thing here - // DCA - if (TMath::Abs(track.dcaXY()) > antinucleiDCAxyCF) - return false; - if (TMath::Abs(track.dcaZ()) > antinucleiDCAzCF) - return false; - - registryData.fill(HIST("hTPCnsigmaAntinucleiCF"), track.pt(), track.tpcNSigmaHe()); - if (track.hasTOF()) - registryData.fill(HIST("hTOFnsigmaAntinucleiCF"), track.pt(), track.tofNSigmaHe()); - - // nsigma - double tofNsigma = track.hasTOF() ? track.tofNSigmaHe() : 999; - if ((track.pt() < antinucleiTPCTOFpT && (TMath::Abs(track.tpcNSigmaHe()) > antinucleiNsigma)) || (track.pt() > antinucleiTPCTOFpT && (TMath::Sqrt(track.tpcNSigmaHe() * track.tpcNSigmaHe() + tofNsigma * tofNsigma) > antinucleiNsigma))) - return false; - if (!singleSpeciesTPCNSigma(track, 6)) - return false; - } else { // for yields - // DCA - if (TMath::Abs(track.dcaXY()) > antinucleiDCAxyYield) - return false; - if (TMath::Abs(track.dcaZ()) > antinucleiDCAzYield) - return false; - - registryData.fill(HIST("hTPCnsigmaAntinuclei"), track.pt(), track.tpcNSigmaHe()); - - // TPC - if (track.pt() < antinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > antinucleiTPCnsigmaLowPtYield) - return false; - if (track.pt() > antinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > antinucleiTPCnsigmaHighPtYield) - return false; - - // TOF - if (track.hasTOF()) { - registryData.fill(HIST("hTOFnsigmaAntinuclei"), track.pt(), track.tofNSigmaHe()); - if (track.pt() > antinucleiTPCTOFpT && TMath::Abs(track.tofNSigmaHe()) > antinucleiTOFnsigmaHighPtYield) - return false; - } - } - } - - return true; - } - - void setTrackBuffer(const auto& tempBuffer, auto& buffer) // refresh track buffer - { - for (const auto& pair : tempBuffer) { - if (static_cast(buffer.size()) == trackBufferSize) { - buffer.insert(buffer.begin(), pair); - buffer.resize(trackBufferSize); - } else if (static_cast(buffer.size()) < trackBufferSize) { - buffer.emplace_back(pair); - } - } - } - - void fillMixedEventDeltas(const auto& track, const auto& buffer, int particleType, const TVector3 jetAxis) // correlate tracks from current event with tracks from buffer, i.e. other events - { - if (buffer.size() == 0) - return; - if (std::isnan(track.phi()) || std::isnan(jetAxis.Phi())) - return; - for (int i = 0; i < static_cast(buffer.size()); i++) { // loop over tracks in buffer - if (std::isnan(buffer.at(i).first)) - continue; - if (buffer.at(i).first > 2 * TMath::Pi() || buffer.at(i).first < -2 * TMath::Pi()) { - registryData.fill(HIST("hTrackProtocol"), 16); - continue; - } - - double phiToAxis = TVector2::Phi_0_2pi(track.phi() - jetAxis.Phi()); - double etaToAxis = track.eta() - jetAxis.Eta(); - double DeltaPhi = TVector2::Phi_0_2pi(phiToAxis - buffer.at(i).first); - if (DeltaPhi > (1.5 * TMath::Pi())) { // ensure range of [-pi/2, 3/2 pi] - DeltaPhi = DeltaPhi - 2 * TMath::Pi(); - } - double DeltaEta = etaToAxis - buffer.at(i).second; - - switch (particleType) { - case -1: - registryData.fill(HIST("hDeltaPhiMEFull"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaMEFull"), DeltaPhi, DeltaEta); - break; - case 0: - registryData.fill(HIST("hDeltaPhiMEJet"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaMEJet"), DeltaPhi, DeltaEta); - break; - case 1: - registryData.fill(HIST("hDeltaPhiMEProton"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaMEProton"), DeltaPhi, DeltaEta); - break; - case 2: - registryData.fill(HIST("hDeltaPhiMEAntiproton"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaMEAntiproton"), DeltaPhi, DeltaEta); - break; - case 3: - registryData.fill(HIST("hDeltaPhiMENuclei"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaMENuclei"), DeltaPhi, DeltaEta); - break; - case 4: - registryData.fill(HIST("hDeltaPhiMEAntinuclei"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaMEAntinuclei"), DeltaPhi, DeltaEta); - break; - } - } // for (int i = 0; i < static_cast(buffer.size()); i++) - } - - void doCorrelations(const auto& particleVector, const auto& buffer, auto& tempBuffer, int particleType, const TVector3 jetAxis) - { - if (std::isnan(jetAxis.Phi())) - return; - for (int i = 0; i < static_cast(particleVector.size()); i++) { - if (std::isnan(particleVector.at(i).phi())) - continue; - double phiToAxis = TVector2::Phi_0_2pi(particleVector.at(i).phi() - jetAxis.Phi()); - double etaToAxis = particleVector.at(i).eta() - jetAxis.Eta(); - if (TMath::Abs(particleVector.at(i).phi()) > 2 * TMath::Pi()) { - registryData.fill(HIST("hTrackProtocol"), 14); - continue; - } - for (int j = i + 1; j < static_cast(particleVector.size()); j++) { - if ((j == static_cast(particleVector.size())) || std::isnan(particleVector.at(j).phi())) - continue; - if (TMath::Abs(particleVector.at(j).phi()) > 2 * TMath::Pi()) { - registryData.fill(HIST("hTrackProtocol"), 15); - continue; - } - - double DeltaPhi = TVector2::Phi_0_2pi(particleVector.at(i).phi() - particleVector.at(j).phi()); - double DeltaEta = particleVector.at(i).eta() - particleVector[j].eta(); - if (DeltaPhi > (1.5 * TMath::Pi())) { - DeltaPhi = DeltaPhi - 2 * TMath::Pi(); - } - switch (particleType) { - case -1: - registryData.fill(HIST("hDeltaPhiSEFull"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaSEFull"), DeltaPhi, DeltaEta); - break; - case 0: - registryData.fill(HIST("hDeltaPhiSEJet"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaSEJet"), DeltaPhi, DeltaEta); - break; - case 1: - registryData.fill(HIST("hDeltaPhiSEProton"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaSEProton"), DeltaPhi, DeltaEta); - break; - case 2: - registryData.fill(HIST("hDeltaPhiSEAntiproton"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaSEAntiproton"), DeltaPhi, DeltaEta); - break; - case 3: - registryData.fill(HIST("hDeltaPhiSENuclei"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaSENuclei"), DeltaPhi, DeltaEta); - break; - case 4: - registryData.fill(HIST("hDeltaPhiSEAntinuclei"), DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaSEAntinuclei"), DeltaPhi, DeltaEta); - break; - } - } - fillMixedEventDeltas(particleVector.at(i), buffer, particleType, jetAxis); - tempBuffer.emplace_back(std::make_pair(phiToAxis, etaToAxis)); - } - } - - double getDeltaPhi(double a1, double a2) - { - if (std::isnan(a1) || std::isnan(a2) || a1 == -999 || a2 == -999) - return -999; - double deltaPhi(0); - double phi1 = TVector2::Phi_0_2pi(a1); - double phi2 = TVector2::Phi_0_2pi(a2); - double diff = TMath::Abs(phi1 - phi2); - - if (diff <= TMath::Pi()) - deltaPhi = diff; - if (diff > TMath::Pi()) - deltaPhi = TMath::TwoPi() - diff; - - return deltaPhi; - } - - void getPerpendicularAxis(TVector3 p, TVector3& u, double sign) - { - // Initialization - double ux(0), uy(0), uz(0); - - // Components of Vector p - double px = p.X(); - double py = p.Y(); - double pz = p.Z(); - - // Protection 1 - if (px == 0 && py != 0) { - - uy = -(pz * pz) / py; - ux = sign * sqrt(py * py - (pz * pz * pz * pz) / (py * py)); - uz = pz; - u.SetXYZ(ux, uy, uz); - return; - } - - // Protection 2 - if (py == 0 && px != 0) { - - ux = -(pz * pz) / px; - uy = sign * sqrt(px * px - (pz * pz * pz * pz) / (px * px)); - uz = pz; - u.SetXYZ(ux, uy, uz); - return; - } - - // Equation Parameters - double a = px * px + py * py; - double b = 2.0 * px * pz * pz; - double c = pz * pz * pz * pz - py * py * py * py - px * px * py * py; - double delta = b * b - 4.0 * a * c; - - // Protection agains delta<0 - if (delta < 0) { - return; - } - - // Solutions - ux = (-b + sign * sqrt(delta)) / (2.0 * a); - uy = (-pz * pz - px * ux) / py; - uz = pz; - u.SetXYZ(ux, uy, uz); - return; - } - - int analyseJet(int jetCounter, fastjet::PseudoJet jet, const auto& particles, auto& jetProtons, auto& jetAntiprotons, auto& jetNuclei, auto& jetAntinuclei, auto& jetAll, double rho, double rhoM, double rhoPerp, double rhoMPerp) - { - if (!jet.has_constituents()) - return jetCounter; - fastjet::PseudoJet subtractedJetPerp(0., 0., 0., 0.); - subtractedJetPerp = bkgSub.doRhoAreaSub(jet, rhoPerp, rhoMPerp); - fastjet::PseudoJet subtractedJetArea(0., 0., 0., 0.); - subtractedJetArea = bkgSub.doRhoAreaSub(jet, rho, rhoM); - - if (subtractedJetPerp.pt() < minJetPt) // cut on jet w/o bkg - return jetCounter; - registryData.fill(HIST("hPtTotalSubJetPerp"), subtractedJetPerp.pt()); - registryData.fill(HIST("hPtTotalSubJetArea"), subtractedJetArea.pt()); - registryQA.fill(HIST("hRhoEstimateArea"), jet.pt(), rho); // switch to subtracted jet pt - registryQA.fill(HIST("hRhoMEstimateArea"), jet.pt(), rhoM); - registryQA.fill(HIST("hRhoEstimatePerp"), jet.pt(), rhoPerp); - registryQA.fill(HIST("hRhoMEstimatePerp"), jet.pt(), rhoMPerp); - double jetBkgDeltaPt = jet.pt() - subtractedJetPerp.pt(); - registryQA.fill(HIST("hJetBkgDeltaPt"), jetBkgDeltaPt); - - registryData.fill(HIST("hEventProtocol"), 4); - std::vector constituents = jet.constituents(); - - registryData.fill(HIST("hEventProtocol"), 5); - registryData.fill(HIST("hNumberOfJets"), 0); - registryData.fill(HIST("hPtTotalJet"), jet.pt()); - registryData.fill(HIST("hJetRapidity"), jet.rap()); - registryData.fill(HIST("hNumPartInJet"), jet.constituents().size()); - registryQA.fill(HIST("hJetPtVsNumPart"), jet.pt(), jet.constituents().size()); - - double maxRadius = 0; - for (const auto& constituent : constituents) { - registryData.fill(HIST("hPtJetParticle"), constituent.pt()); - registryQA.fill(HIST("hPhiJet"), constituent.phi()); - registryQA.fill(HIST("hPhiPtJet"), constituent.pt(), constituent.phi()); - registryQA.fill(HIST("hEtaJet"), constituent.eta()); - registryQA.fill(HIST("hEtaPtJet"), constituent.pt(), constituent.eta()); - - if (std::isnan(constituent.phi()) || std::isnan(jet.phi())) // geometric jet cone - continue; - double DeltaPhi = TVector2::Phi_0_2pi(constituent.phi() - jet.phi()); - if (DeltaPhi > TMath::Pi()) - DeltaPhi = DeltaPhi - 2 * TMath::Pi(); - double DeltaEta = constituent.eta() - jet.eta(); - double Delta = TMath::Sqrt(DeltaPhi * DeltaPhi + DeltaEta * DeltaEta); - registryQA.fill(HIST("hJetConeRadius"), Delta); - if (Delta > maxRadius) - maxRadius = Delta; - } - registryQA.fill(HIST("hMaxRadiusVsPt"), jet.pt(), maxRadius); - - // QA for comparison with nuclei_in_jets - TVector3 pJet(0., 0., 0.); - pJet.SetXYZ(jet.px(), jet.py(), jet.pz()); - TVector3 UEAxis1(0.0, 0.0, 0.0); - TVector3 UEAxis2(0.0, 0.0, 0.0); - getPerpendicularAxis(pJet, UEAxis1, +1.0); - getPerpendicularAxis(pJet, UEAxis2, -1.0); - - double NchJetPlusUE(0); - double NchJet(0); - double NchUE(0); - double ptJetPlusUE(0); - double ptJet(0); - double ptUE(0); - - for (const auto& [index, track] : particles) { - TVector3 particleDir(track.px(), track.py(), track.pz()); - double deltaEtaJet = particleDir.Eta() - pJet.Eta(); - double deltaPhiJet = getDeltaPhi(particleDir.Phi(), pJet.Phi()); - double deltaRJet = sqrt(deltaEtaJet * deltaEtaJet + deltaPhiJet * deltaPhiJet); - double deltaEtaUE1 = particleDir.Eta() - UEAxis1.Eta(); - double deltaPhiUE1 = getDeltaPhi(particleDir.Phi(), UEAxis1.Phi()); - double deltaRUE1 = sqrt(deltaEtaUE1 * deltaEtaUE1 + deltaPhiUE1 * deltaPhiUE1); - double deltaEtaUE2 = particleDir.Eta() - UEAxis2.Eta(); - double deltaPhiUE2 = getDeltaPhi(particleDir.Phi(), UEAxis2.Phi()); - double deltaRUE2 = sqrt(deltaEtaUE2 * deltaEtaUE2 + deltaPhiUE2 * deltaPhiUE2); - - if (deltaRJet < Rmax) { - if (deltaPhiJet != -999) - registryQA.fill(HIST("hDeltaEtadeltaPhiJet"), deltaEtaJet, deltaPhiJet); - NchJetPlusUE++; - ptJetPlusUE = ptJetPlusUE + track.pt(); - } - if (deltaRUE1 < Rmax) { - if (deltaPhiUE1 != -999) - registryQA.fill(HIST("hDeltaEtadeltaPhiUE"), deltaEtaUE1, deltaPhiUE1); - NchUE++; - ptUE = ptUE + track.pt(); - } - if (deltaRUE2 < Rmax) { - if (deltaPhiUE2 != -999) - registryQA.fill(HIST("hDeltaEtadeltaPhiUE"), deltaEtaUE2, deltaPhiUE2); - NchUE++; - ptUE = ptUE + track.pt(); - } - } // for (const auto& [index, track] : particles) - - NchJet = NchJetPlusUE - 0.5 * NchUE; - ptJet = ptJetPlusUE - 0.5 * ptUE; - registryQA.fill(HIST("hMultiplicityJetPlusUE"), NchJetPlusUE); - registryQA.fill(HIST("hMultiplicityJet"), NchJet); - registryQA.fill(HIST("hMultiplicityUE"), 0.5 * NchUE); - registryQA.fill(HIST("hPtJetPlusUE"), ptJetPlusUE); - registryQA.fill(HIST("hPtJet"), ptJet); - registryQA.fill(HIST("hPtUE"), 0.5 * ptUE); - registryQA.fill(HIST("hDeltaJetPt"), jet.pt() - ptJetPlusUE); - - int nPartClusteredJet = static_cast(constituents.size()); - - // Fill QA Histograms - if (ptJetPlusUE < minJetPt) { // swap for sub pt? - - registryQA.fill(HIST("hNParticlesClusteredInJet"), nPartClusteredJet); - - for (const auto& track : constituents) { - registryQA.fill(HIST("hPtParticlesClusteredInJet"), track.pt()); - } - } - - std::vector> fTempBufferProton; - std::vector> fTempBufferAntiproton; - std::vector> fTempBufferNuclei; - std::vector> fTempBufferAntinuclei; - std::vector> fTempBufferJet; - fTempBufferProton.clear(); - fTempBufferAntiproton.clear(); - fTempBufferNuclei.clear(); - fTempBufferAntinuclei.clear(); - fTempBufferJet.clear(); - - for (int i = 0; i < static_cast(constituents.size()); i++) { // analyse jet constituents - this is where the magic happens - registryData.fill(HIST("hTrackProtocol"), 3); - fastjet::PseudoJet pseudoParticle = constituents.at(i); - int id = pseudoParticle.user_index(); - const auto& jetParticle = particles.at(id); - jetAll.emplace_back(jetParticle); - - registryData.fill(HIST("hDCAxyFullJet"), jetParticle.pt() * jetParticle.sign(), jetParticle.dcaXY()); - registryData.fill(HIST("hDCAzFullJet"), jetParticle.pt() * jetParticle.sign(), jetParticle.dcaZ()); - registryData.fill(HIST("hTPCsignal"), jetParticle.pt() * jetParticle.sign(), jetParticle.tpcSignal()); - if (jetParticle.hasTOF()) { - registryData.fill(HIST("hTOFsignal"), jetParticle.pt() * jetParticle.sign(), jetParticle.beta()); - } - double ptDiff = pseudoParticle.pt() - jetParticle.pt(); - registryQA.fill(HIST("hPtDiff"), ptDiff); - - if (jetParticle.pt() < minJetParticlePt) - continue; - if (isProton(jetParticle, false)) { // collect protons in jet - registryData.fill(HIST("hPtJetProton"), jetParticle.pt()); - registryQA.fill(HIST("hPtJetProtonVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); - registryData.fill(HIST("hTrackProtocol"), 4); // # protons - if (isProton(jetParticle, true)) { - registryData.fill(HIST("hTrackProtocol"), 5); // # high purity protons - jetProtons.emplace_back(jetParticle); - registryData.fill(HIST("hDCAzJetProton"), jetParticle.pt(), jetParticle.dcaZ()); - } - } else if (isAntiproton(jetParticle, false)) { // collect antiprotons in jet - registryData.fill(HIST("hPtJetAntiproton"), jetParticle.pt()); - registryQA.fill(HIST("hPtJetAntiprotonVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); - registryData.fill(HIST("hTrackProtocol"), 6); // # antiprotons - if (isAntiproton(jetParticle, true)) { - registryData.fill(HIST("hTrackProtocol"), 7); // # high purity antiprotons - jetAntiprotons.emplace_back(jetParticle); - registryData.fill(HIST("hDCAzJetAntiproton"), jetParticle.pt(), jetParticle.dcaZ()); - } - } else if (isNucleus(jetParticle, false)) { // collect nuclei in jet - registryData.fill(HIST("hPtJetNuclei"), jetParticle.pt()); - registryQA.fill(HIST("hPtJetNucleiVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); - registryData.fill(HIST("hTrackProtocol"), 8); // # nuclei - if (isNucleus(jetParticle, true)) { - registryData.fill(HIST("hTrackProtocol"), 9); // # high purity nuclei - jetNuclei.emplace_back(jetParticle); - registryData.fill(HIST("hDCAzJetNuclei"), jetParticle.pt(), jetParticle.dcaZ()); - } - } else if (isAntinucleus(jetParticle, false)) { - registryData.fill(HIST("hPtJetAntinuclei"), jetParticle.pt()); - registryQA.fill(HIST("hPtJetAntinucleiVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); - registryData.fill(HIST("hTrackProtocol"), 10); // # antinuclei - if (isAntinucleus(jetParticle, true)) { - registryData.fill(HIST("hTrackProtocol"), 11); // # high purity antinuclei - jetAntinuclei.emplace_back(jetParticle); - registryData.fill(HIST("hDCAzJetAntinuclei"), jetParticle.pt(), jetParticle.dcaZ()); - } - } - } // for (int i=0; i(constituents.size()); i++) - - if (jetAll.size() > 1) { // general correlation function - doCorrelations(jetAll, fBufferJet, fTempBufferJet, 0, pJet); - setTrackBuffer(fTempBufferJet, fBufferJet); - } - jetCounter++; - - if ((jetProtons.size() < 2) && (jetAntiprotons.size() < 2) && (jetNuclei.size() < 2) && (jetAntinuclei.size() < 2)) - return jetCounter; - registryData.fill(HIST("hEventProtocol"), 6); - - if (jetProtons.size() > 1) { - doCorrelations(jetProtons, fBufferProton, fTempBufferProton, 1, pJet); - setTrackBuffer(fTempBufferProton, fBufferProton); - } - if (jetAntiprotons.size() > 1) { - doCorrelations(jetAntiprotons, fBufferAntiproton, fTempBufferAntiproton, 2, pJet); - setTrackBuffer(fTempBufferAntiproton, fBufferAntiproton); - } - if (jetNuclei.size() > 1) { - doCorrelations(jetNuclei, fBufferNuclei, fTempBufferNuclei, 3, pJet); - setTrackBuffer(fTempBufferNuclei, fBufferNuclei); - } - if (jetAntinuclei.size() > 1) { - doCorrelations(jetAntinuclei, fBufferAntinuclei, fTempBufferAntinuclei, 4, pJet); - setTrackBuffer(fTempBufferAntinuclei, fBufferAntinuclei); - } - return jetCounter; - } - - template - void fillHistograms(U const& tracks) - { - std::vector jetProtons; - std::vector jetAntiprotons; - std::vector jetNuclei; - std::vector jetAntinuclei; - std::vector jetAll; - std::vector> fTempBufferFull; - fTempBufferFull.clear(); - std::vector jetInput; // input for jet finder - std::map particles; // all selected particles in event - std::vector particlesForCF; // particles for full event angular correlations - jetInput.clear(); - particles.clear(); - int index = 0; - int jetCounter = 0; - std::vector jets; - jets.clear(); - - for (const auto& track : tracks) { - if (!selectTrack(track)) - continue; - - double mass; - if (useTOFmass) { - if (track.hasTOF()) { - mass = track.mass(); // check reliability, maybe use only pion mass - registryQA.fill(HIST("hTOFmass"), track.pt(), track.mass()); - registryData.fill(HIST("hTrackProtocol"), 1); - } else { - mass = 0.139; // pion mass as default, ~80% are pions - registryData.fill(HIST("hTrackProtocol"), 2); - } - } else { - mass = 0.139; - } - - if (track.tpcNClsFindable() != 0) { - registryQA.fill(HIST("hRatioCrossedRowsTPC"), track.pt(), track.tpcNClsCrossedRows() / track.tpcNClsFindable()); - } - registryQA.fill(HIST("hPtFullEvent"), track.pt()); - registryQA.fill(HIST("hCrossedRowsTPC"), track.pt(), track.tpcNClsCrossedRows()); - registryQA.fill(HIST("hClusterITS"), track.pt(), track.itsNCls()); - registryQA.fill(HIST("hClusterTPC"), track.pt(), track.tpcNClsFound()); - registryQA.fill(HIST("hChi2ITS"), track.pt(), track.itsChi2NCl()); - registryQA.fill(HIST("hChi2TPC"), track.pt(), track.tpcChi2NCl()); - registryQA.fill(HIST("hDCAxyFullEvent"), track.pt(), track.dcaXY()); - registryQA.fill(HIST("hDCAzFullEvent"), track.pt(), track.dcaZ()); - registryQA.fill(HIST("hPhiFullEvent"), track.phi()); - registryQA.fill(HIST("hPhiPtFullEvent"), track.pt(), track.phi()); - registryQA.fill(HIST("hEtaFullEvent"), track.eta()); - registryQA.fill(HIST("hEtaPtFullEvent"), track.pt(), track.eta()); - - fastjet::PseudoJet inputPseudoJet(track.px(), track.py(), track.pz(), track.energy(mass)); - inputPseudoJet.set_user_index(index); - particles[index] = track; - particlesForCF.emplace_back(track); - jetInput.emplace_back(inputPseudoJet); - - index++; - } // for (const auto& track : tracks) - - if (jetInput.size() < 2) - return; - registryData.fill(HIST("hEventProtocol"), 2); - - // Reconstruct Jets - double ghost_maxrap = 1.0; - double ghost_area = 0.005; - int ghost_repeat = 1; - fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, jetR); - fastjet::JetDefinition jetDefBkg(fastjet::kt_algorithm, 0.5); - fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(ghost_maxrap, ghost_repeat, ghost_area)); - fastjet::AreaDefinition areaDefBkg(fastjet::active_area_explicit_ghosts, fastjet::GhostedAreaSpec(ghost_maxrap)); - fastjet::ClusterSequenceArea clusterSeq(jetInput, jetDef, areaDef); - jets = sorted_by_pt(clusterSeq.inclusive_jets()); - - if (jets.size() == 0) - return; - - registryData.fill(HIST("hEventProtocol"), 3); - - bool doSparse = true; - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(jetInput, doSparse); - auto [rhoPerp, rhoMPerp] = bkgSub.estimateRhoPerpCone(jetInput, jets); - - for (const auto& jet : jets) { - jetCounter = analyseJet(jetCounter, jet, particles, jetProtons, jetAntiprotons, jetNuclei, jetAntinuclei, jetAll, rho, rhoM, rhoPerp, rhoMPerp); - } - registryData.fill(HIST("hNumJetsInEvent"), jetCounter); - - TVector3 hardestJetAxis(jets.at(0).px(), jets.at(0).py(), jets.at(0).pz()); // for full event, use hardest jet as orientation - doCorrelations(particlesForCF, fBufferFull, fTempBufferFull, -1, hardestJetAxis); - setTrackBuffer(fTempBufferFull, fBufferFull); - } - - template - void fillHistogramsMC(U const& tracks) - { - std::vector jetProtons; - std::vector jetAntiprotons; - std::vector jetNuclei; - std::vector jetAntinuclei; - std::vector jetAll; - std::vector> fTempBufferFull; - fTempBufferFull.clear(); - std::vector jetInput; // input for jet finder - std::map particles; // all selected particles in event - std::vector particlesForCF; // particles for full event angular correlations - jetInput.clear(); - particles.clear(); - int index = 0; - int jetCounter = 0; - std::vector jets; - jets.clear(); - - for (const auto& track : tracks) { - if (!selectTrack(track)) - continue; - - double mass; - if (useTOFmass) { - if (track.hasTOF()) { - mass = track.mass(); // check reliability, maybe use only pion mass - registryQA.fill(HIST("hTOFmass"), track.pt(), track.mass()); - registryData.fill(HIST("hTrackProtocol"), 1); - } else { - mass = 0.139; // pion mass as default, ~80% are pions - registryData.fill(HIST("hTrackProtocol"), 2); - } - } else { - mass = 0.139; - } - - if (track.tpcNClsFindable() != 0) { - registryQA.fill(HIST("hRatioCrossedRowsTPC"), track.pt(), track.tpcNClsCrossedRows() / track.tpcNClsFindable()); - } - registryQA.fill(HIST("hPtFullEvent"), track.pt()); - registryQA.fill(HIST("hCrossedRowsTPC"), track.pt(), track.tpcNClsCrossedRows()); - registryQA.fill(HIST("hClusterITS"), track.pt(), track.itsNCls()); - registryQA.fill(HIST("hClusterTPC"), track.pt(), track.tpcNClsFound()); - registryQA.fill(HIST("hChi2ITS"), track.pt(), track.itsChi2NCl()); - registryQA.fill(HIST("hChi2TPC"), track.pt(), track.tpcChi2NCl()); - registryQA.fill(HIST("hDCAxyFullEvent"), track.pt(), track.dcaXY()); - registryQA.fill(HIST("hDCAzFullEvent"), track.pt(), track.dcaZ()); - registryQA.fill(HIST("hPhiFullEvent"), track.phi()); - registryQA.fill(HIST("hPhiPtFullEvent"), track.pt(), track.phi()); - registryQA.fill(HIST("hEtaFullEvent"), track.eta()); - registryQA.fill(HIST("hEtaPtFullEvent"), track.pt(), track.eta()); - - fastjet::PseudoJet inputPseudoJet(track.px(), track.py(), track.pz(), track.energy(mass)); - inputPseudoJet.set_user_index(index); - particles[index] = track; - particlesForCF.emplace_back(track); - jetInput.emplace_back(inputPseudoJet); - - index++; - } // for (const auto& track : tracks) - - if (jetInput.size() < 2) - return; - registryData.fill(HIST("hEventProtocol"), 2); - - // Reconstruct Jets - double ghost_maxrap = 1.0; - double ghost_area = 0.005; - int ghost_repeat = 1; - fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, jetR); - fastjet::JetDefinition jetDefBkg(fastjet::kt_algorithm, 0.5); - fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(ghost_maxrap, ghost_repeat, ghost_area)); - fastjet::AreaDefinition areaDefBkg(fastjet::active_area_explicit_ghosts, fastjet::GhostedAreaSpec(ghost_maxrap)); - fastjet::ClusterSequenceArea clusterSeq(jetInput, jetDef, areaDef); - jets = sorted_by_pt(clusterSeq.inclusive_jets()); - - if (jets.size() == 0) - return; - - registryData.fill(HIST("hEventProtocol"), 3); - - bool doSparse = true; - auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(jetInput, doSparse); - auto [rhoPerp, rhoMPerp] = bkgSub.estimateRhoPerpCone(jetInput, jets); - - for (auto& jet : jets) { - jetCounter = analyseJet(jetCounter, jet, particles, jetProtons, jetAntiprotons, jetNuclei, jetAntinuclei, jetAll, rho, rhoM, rhoPerp, rhoMPerp); - - // MC Truth Particles - fastjet::PseudoJet subtractedJetPerp(0., 0., 0., 0.); - subtractedJetPerp = bkgSub.doRhoAreaSub(jet, rhoPerp, rhoMPerp); - if (subtractedJetPerp.pt() < minJetPt) // cut on jet w/o bkg - continue; - for (const auto& constituent : jet.constituents()) { - const auto& jetParticle = particles.at(constituent.user_index()); - if (!jetParticle.has_mcParticle()) - continue; - switch (jetParticle.mcParticle().pdgCode()) { - case 2212: - registryMC.fill(HIST("hNumberOfTruthParticles"), 0); - registryMC.fill(HIST("hPtJetProtonMC"), jetParticle.pt()); - break; - case -2212: - registryMC.fill(HIST("hNumberOfTruthParticles"), 1); - registryMC.fill(HIST("hPtJetAntiprotonMC"), jetParticle.pt()); - break; - case 1000010020: - registryMC.fill(HIST("hNumberOfTruthParticles"), 2); - registryMC.fill(HIST("hPtJetNucleiMC"), jetParticle.pt()); - break; - case -1000010020: - registryMC.fill(HIST("hNumberOfTruthParticles"), 3); - registryMC.fill(HIST("hPtJetAntinucleiMC"), jetParticle.pt()); - break; - case 1000020030: - registryMC.fill(HIST("hNumberOfTruthParticles"), 4); - registryMC.fill(HIST("hPtJetNucleiMC"), jetParticle.pt()); - break; - case -1000020030: - registryMC.fill(HIST("hNumberOfTruthParticles"), 5); - registryMC.fill(HIST("hPtJetAntinucleiMC"), jetParticle.pt()); - break; - default: - continue; - } - } // for (const auto& constituent : jet.constituents()) - } // for (const auto& jet : jets) - registryData.fill(HIST("hNumJetsInEvent"), jetCounter); - - TVector3 hardestJetAxis(jets.at(0).px(), jets.at(0).py(), jets.at(0).pz()); // for full event, use hardest jet as orientation - doCorrelations(particlesForCF, fBufferFull, fTempBufferFull, -1, hardestJetAxis); - setTrackBuffer(fTempBufferFull, fBufferFull); - } - - void processRun2(soa::Join const& collisions, - soa::Filtered const& tracks, - BCsWithRun2Info const&) - { - for (const auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - registryData.fill(HIST("hEventProtocol"), 0); - if (!collision.alias_bit(kINT7)) - continue; - registryData.fill(HIST("hNumberOfEvents"), 0); - registryData.fill(HIST("hEventProtocol"), 1); - - auto slicedTracks = tracks.sliceBy(perCollisionFullTracksRun2, collision.globalIndex()); - - fillHistograms(slicedTracks); - } - } - PROCESS_SWITCH(AngularCorrelationsInJets, processRun2, "process Run 2 data", true); - - void processRun3(soa::Join const& collisions, - soa::Filtered const& tracks) - { - for (const auto& collision : collisions) { - registryData.fill(HIST("hEventProtocol"), 0); - if (!collision.sel8()) - continue; - registryData.fill(HIST("hNumberOfEvents"), 0); - registryData.fill(HIST("hEventProtocol"), 1); - if (TMath::Abs(collision.posZ()) > zVtx) - continue; - - auto slicedTracks = tracks.sliceBy(perCollisionFullTracksRun3, collision.globalIndex()); - - fillHistograms(slicedTracks); - } - } - PROCESS_SWITCH(AngularCorrelationsInJets, processRun3, "process Run 3 data", false); - - void processMCRun2(McCollisions const& collisions, soa::Filtered const& tracks, BCsWithRun2Info const&, aod::McParticles&, aod::McCollisions const&) - { - for (const auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - registryData.fill(HIST("hEventProtocol"), 0); - if (!collision.alias_bit(kINT7)) - continue; - registryData.fill(HIST("hNumberOfEvents"), 0); - registryData.fill(HIST("hEventProtocol"), 1); - - auto slicedTracks = tracks.sliceBy(perCollisionMcTracksRun2, collision.globalIndex()); - - fillHistogramsMC(slicedTracks); - } - } - PROCESS_SWITCH(AngularCorrelationsInJets, processMCRun2, "process Run 2 MC", false); - - void processMCRun3(McCollisions const& collisions, soa::Filtered const& tracks, aod::McParticles&, aod::McCollisions const&) - { - for (const auto& collision : collisions) { - registryData.fill(HIST("hEventProtocol"), 0); - if (!collision.sel8()) - continue; - registryData.fill(HIST("hNumberOfEvents"), 0); - registryData.fill(HIST("hEventProtocol"), 1); - if (TMath::Abs(collision.posZ()) > zVtx) - continue; - - auto slicedTracks = tracks.sliceBy(perCollisionMcTracksRun3, collision.globalIndex()); - - fillHistogramsMC(slicedTracks); - } - } - PROCESS_SWITCH(AngularCorrelationsInJets, processMCRun3, "process Run 3 MC", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGLF/Tasks/Nuspex/CMakeLists.txt b/PWGLF/Tasks/Nuspex/CMakeLists.txt index 9f730fc29a1..8e86feab651 100644 --- a/PWGLF/Tasks/Nuspex/CMakeLists.txt +++ b/PWGLF/Tasks/Nuspex/CMakeLists.txt @@ -11,7 +11,7 @@ o2physics_add_dpl_workflow(nuclei-batask SOURCES LFNucleiBATask.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(hypertritonanalysis @@ -24,21 +24,6 @@ o2physics_add_dpl_workflow(nuclei-hist PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(hypertriton3bodyanalysis - SOURCES hypertriton3bodyanalysis.cxx - PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(hypertriton3bodymcqa - SOURCES hypertriton3bodyMCQA.cxx - PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore O2::TOFBase - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(nuclei-in-jets - SOURCES nuclei_in_jets.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(helium-flow SOURCES helium_flow.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -54,11 +39,6 @@ o2physics_add_dpl_workflow(hyhefour-analysis PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(antid-lambda-ebye - SOURCES antidLambdaEbye.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(mc-spectra-efficiency SOURCES mcspectraefficiency.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -89,6 +69,11 @@ o2physics_add_dpl_workflow(spectra-tpc-tiny PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(nuclei-tpcspectra + SOURCES nucleitpcpbpb.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(spectra-tpc-tiny-pikapr SOURCES spectraTPCtinyPiKaPr.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -139,11 +124,6 @@ o2physics_add_dpl_workflow(nuclei-toward-transv PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(ebye-mult - SOURCES ebyeMult.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(nuclei-from-hypertriton-map SOURCES nucleiFromHypertritonMap.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -151,7 +131,28 @@ o2physics_add_dpl_workflow(nuclei-from-hypertriton-map if(FastJet_FOUND) o2physics_add_dpl_workflow(angular-correlations-in-jets - SOURCES AngularCorrelationsInJets.cxx + SOURCES angularCorrelationsInJets.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGJECore FastJet::FastJet FastJet::Contrib COMPONENT_NAME Analysis) -endif() \ No newline at end of file + +o2physics_add_dpl_workflow(antinuclei-in-jets + SOURCES antinucleiInJets.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGJECore FastJet::FastJet FastJet::Contrib + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(kink-pika + SOURCES spectraKinkPiKa.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(he3-lambda-derived-analysis + SOURCES he3LambdaDerivedAnalysis.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(dedx-pid-analysis + SOURCES dedxPidAnalysis.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +endif() diff --git a/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx index 32c73b8e806..8e5f159d331 100644 --- a/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx +++ b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx @@ -16,36 +16,51 @@ /// /// \author Giovanni Malfattore and Rutuparna Rath /// + #include "PWGLF/DataModel/LFNucleiTables.h" -#include -#include -#include "ReconstructionDataFormats/Track.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "PWGLF/DataModel/mcCentrality.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/PIDResponseITS.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/trackUtilities.h" -#include "Common/CCDB/EventSelectionParams.h" -#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "CCDB/BasicCCDBManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/PID.h" +#include "ReconstructionDataFormats/Track.h" + +#include +// #include + +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; struct LFNucleiBATask { + Service ccdb; + + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry spectraGen{"spectraGen", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; HistogramRegistry debugHistos{"debugHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry evtimeHistos{"evtimeHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry evLossHistos{"evLossHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; // Enable particle for analysis Configurable enablePr{"enablePr", true, "Flag to enable proton analysis."}; @@ -55,39 +70,52 @@ struct LFNucleiBATask { Configurable enableAl{"enableAl", true, "Flag to enable alpha analysis."}; Configurable enableTrackingEff{"enableTrackingEff", 0, "Flag to enable tracking efficiency hitos."}; + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + // Set the triggered events skimming scheme + struct : ConfigurableGroup { + Configurable applySkimming{"applySkimming", false, "Skimmed dataset processing"}; + Configurable cfgSkimming{"cfgSkimming", "fHe", "Configurable for skimming"}; + } skimmingOptions; // Set the event selection cuts struct : ConfigurableGroup { Configurable useSel8{"useSel8", true, "Use Sel8 for run3 Event Selection"}; - Configurable TVXtrigger{"TVXtrigger", false, "Use TVX for Event Selection (default w/ Sel8)"}; + Configurable useTVXtrigger{"useTVXtrigger", false, "Use TVX for Event Selection (default w/ Sel8)"}; Configurable removeTFBorder{"removeTFBorder", false, "Remove TimeFrame border (default w/ Sel8)"}; Configurable removeITSROFBorder{"removeITSROFBorder", false, "Remove ITS Read-Out Frame border (default w/ Sel8)"}; } evselOptions; // Set the multiplity event limits - Configurable cfgLowMultCut{"cfgLowMultCut", 0.0f, "Accepted multiplicity percentage lower limit"}; - Configurable cfgHighMultCut{"cfgHighMultCut", 100.0f, "Accepted multiplicity percentage higher limit"}; + Configurable cfgMultCutLow{"cfgMultCutLow", 0.0f, "Accepted multiplicity percentage lower limit"}; + Configurable cfgMultCutHigh{"cfgMultCutHigh", 100.0f, "Accepted multiplicity percentage higher limit"}; // Set the z-vertex event cut limits - Configurable cfgHighCutVertex{"cfgHighCutVertex", 10.0f, "Accepted z-vertex upper limit"}; - Configurable cfgLowCutVertex{"cfgLowCutVertex", -10.0f, "Accepted z-vertex lower limit"}; + Configurable cfgVzCutLow{"cfgVzCutLow", -10.0f, "Accepted z-vertex lower limit"}; + Configurable cfgVzCutHigh{"cfgVzCutHigh", 10.0f, "Accepted z-vertex upper limit"}; // Set the quality cuts for tracks - Configurable rejectFakeTracks{"rejectFakeTracks", false, "Flag to reject ITS-TPC fake tracks (for MC)"}; - Configurable cfgCutITSClusters{"cfgCutITSClusters", -1.f, "Minimum number of ITS clusters"}; - Configurable cfgCutTPCXRows{"cfgCutTPCXRows", -1.f, "Minimum number of crossed TPC rows"}; - Configurable cfgCutTPCClusters{"cfgCutTPCClusters", -1.f, "Minimum number of found TPC clusters"}; - Configurable nITSLayer{"nITSLayer", 0, "ITS Layer (0-6)"}; + struct : ConfigurableGroup { + Configurable rejectFakeTracks{"rejectFakeTracks", false, "Flag to reject ITS-TPC fake tracks (for MC)"}; + Configurable cfgCutITSClusters{"cfgCutITSClusters", -1.f, "Minimum number of ITS clusters"}; + Configurable cfgCutTPCXRows{"cfgCutTPCXRows", -1.f, "Minimum number of crossed TPC rows"}; + Configurable cfgCutTPCClusters{"cfgCutTPCClusters", -1.f, "Minimum number of found TPC clusters"}; + Configurable cfgCutTPCCROFnd{"cfgCutTPCCROFnd", 0.8, "Minimum ratio of crossed TPC clusters over findable"}; + Configurable> tpcChi2NclCuts{"tpcChi2NclCuts", {0.5, 4}, "Range of accepted of Chi2/TPC clusters"}; + Configurable> itsChi2NclCuts{"itsChi2NclCuts", {0.f, 36}, "Range of accepted of Chi2/ITS clusters"}; + Configurable nITSLayer{"nITSLayer", 0, "ITS Layer (0-6)"}; + } trkqcOptions; // Set the kinematic and PID cuts for tracks struct : ConfigurableGroup { - Configurable pCut{"pCut", 0.3f, "Value of the p selection for spectra (default 0.3)"}; - Configurable etaCut{"etaCut", 0.8f, "Value of the eta selection for spectra (default 0.8)"}; - Configurable yLowCut{"yLowCut", -1.0f, "Value of the low rapidity selection for spectra (default -1.0)"}; - Configurable yHighCut{"yHighCut", 1.0f, "Value of the high rapidity selection for spectra (default 1.0)"}; + Configurable cfgMomentumCut{"cfgMomentumCut", 0.3f, "Value of the p selection for spectra (default 0.3)"}; + Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "Value of the eta selection for spectra (default 0.8)"}; + Configurable cfgRapidityCutLow{"cfgRapidityCutLow", -1.0f, "Value of the low rapidity selection for spectra (default -1.0)"}; + Configurable cfgRapidityCutHigh{"cfgRapidityCutHigh", 1.0f, "Value of the high rapidity selection for spectra (default 1.0)"}; } kinemOptions; Configurable isPVContributorCut{"isPVContributorCut", false, "Flag to enable isPVContributor cut."}; + Configurable initITSPID{"initITSPID", false, "Flag to init the ITS PID response"}; struct : ConfigurableGroup { Configurable nsigmaTPCPr{"nsigmaTPCPr", 3.f, "Value of the Nsigma TPC cut for protons"}; @@ -98,14 +126,15 @@ struct LFNucleiBATask { } nsigmaTPCvar; struct : ConfigurableGroup { - Configurable useITSTrCut{"useITSTrCut", false, "Select Helium if NOT compatible with triton hypothesis (via SigmaITS)"}; - Configurable nsigmaITSTr{"nsigmaITSTr", 3.f, "Value of the Nsigma ITS cut for tritons ( > nSigmaITSTr)"}; - // Configurable useITSHeCut{"useITSHeCut", false, "Select Helium if compatible with helium hypothesis (via SigmaITS)"}; - // Configurable nsigmaITSHe{"nsigmaITSHe", 3.f, "Value of the Nsigma ITS cut for helium-3 ( < nSigmaITSHe)"}; + Configurable useITSDeCut{"useITSDeCut", false, "Select Deuteron if compatible with deuteron hypothesis (via SigmaITS)"}; + Configurable useITSHeCut{"useITSHeCut", false, "Select Helium if compatible with helium hypothesis (via SigmaITS)"}; + Configurable nsigmaITSDe{"nsigmaITSDe", -1.f, "Value of the Nsigma ITS cut for deuteron ( > nSigmaITSHe)"}; + Configurable nsigmaITSHe{"nsigmaITSHe", -1.f, "Value of the Nsigma ITS cut for helium-3 ( > nSigmaITSHe)"}; + Configurable showAverageClusterSize{"showAverageClusterSize", false, "Show average cluster size"}; } nsigmaITSvar; // Set additional cuts (used for debug) - Configurable betaCut{"betaCut", 0.4f, "Value of the beta selection for TOF cut (default 0.4)"}; + Configurable cfgBetaCut{"cfgBetaCut", 0.4f, "Value of the beta selection for TOF cut (default 0.4)"}; // Set the axis used in this task ConfigurableAxis binsPercentile{"binsPercentile", {100, 0, 100}, "Centrality FT0M"}; @@ -123,16 +152,20 @@ struct LFNucleiBATask { ConfigurableAxis binsMassDe{"binsMassDe", {180, -1.8, 1.8f}, ""}; ConfigurableAxis binsMassTr{"binsMassTr", {250, -2.5, 2.5f}, ""}; ConfigurableAxis binsMassHe{"binsMassHe", {300, -3., 3.f}, ""}; + ConfigurableAxis avClsBins{"avClsBins", {200, 0, 20}, "Binning in average cluster size"}; // Enable custom cuts/debug functions - Configurable enableFiltering{"enableFiltering", false, "Flag to enable filtering for p,d,t,He only -- disable if launch on skimmed dataset!"}; - Configurable enableEvTimeSplitting{"enableEvTimeSplitting", false, "Flag to enable histograms splitting depending on the Event Time used"}; + struct : ConfigurableGroup { + Configurable enableFiltering{"enableFiltering", false, "Flag to enable filtering for p,d,t,He only -- disable if launch on skimmed dataset!"}; + Configurable enableIsGlobalTrack{"enableIsGlobalTrack", true, "Flag to enable IsGlobalTrackWoDCA"}; + Configurable enableEvTimeSplitting{"enableEvTimeSplitting", false, "Flag to enable histograms splitting depending on the Event Time used"}; + } filterOptions; - Configurable enableDCACustomCut{"enableDCACustomCut", false, "Flag to enable DCA custom cuts - unflag to use standard isGlobalCut DCA cut"}; + Configurable enableCustomDCACut{"enableCustomDCACut", false, "Flag to enable DCA custom cuts - unflag to use standard isGlobalCut DCA cut"}; struct : ConfigurableGroup { - Configurable DCACustomConfig{"DCACustomConfig", 0, "Select to use: pT independent DCAxy and DCAz CustomCut (0), pT dependent DCAxy and DCAz cut (1), pt dependent DCAxy, DCAz CustomCut (2) DCAxy CustomCut, pT dependent DCAz (3) or a circular DCAxy,z cut (4) for tracks. Need 'enableDCACustomCut' to be enabled."}; - Configurable DCAxyCustomCut{"DCAxyCustomCut", 0.05f, "Value of the DCAxy selection for spectra (default 0.05 cm)"}; - Configurable DCAzCustomCut{"DCAzCustomCut", 0.5f, "Value of the DCAz selection for spectra (default 0.5 cm)"}; + Configurable cfgCustomDCA{"cfgCustomDCA", 0, "Select to use: pT independent DCAxy and DCAz CustomCut (0), pT dependent DCAxy and DCAz cut (1), pt dependent DCAxy, DCAz CustomCut (2) DCAxy CustomCut, pT dependent DCAz (3) or a circular DCAxy,z cut (4) for tracks. Need 'enableCustomDCACut' to be enabled."}; + Configurable cfgCustomDCAxy{"cfgCustomDCAxy", 0.05f, "Value of the DCAxy selection for spectra (default 0.05 cm)"}; + Configurable cfgCustomDCAz{"cfgCustomDCAz", 0.5f, "Value of the DCAz selection for spectra (default 0.5 cm)"}; } dcaConfOptions; Configurable> parDCAxycuts{"parDCAxycuts", {0.004f, 0.013f, 1, 1}, "Parameters for Pt dependent DCAxy cut (if enabled): |DCAxy| < [3] * ([O] + [1]/Pt^[2])."}; @@ -142,22 +175,26 @@ struct LFNucleiBATask { struct : ConfigurableGroup { Configurable makeDCABeforeCutPlots{"makeDCABeforeCutPlots", false, "Flag to enable plots of DCA before cuts"}; Configurable makeDCAAfterCutPlots{"makeDCAAfterCutPlots", false, "Flag to enable plots of DCA after cuts"}; + Configurable makeFakeTracksPlots{"makeFakeTracksPlots", false, "Flag to enable plots of misidentified particles"}; + Configurable makeWrongEventPlots{"makeWrongEventPlots", false, "Flag to enable plots of particles from wrong event"}; Configurable doTOFplots{"doTOFplots", true, "Flag to export plots of tracks with 1 hit on TOF."}; Configurable enableExpSignalTPC{"enableExpSignalTPC", true, "Flag to export dEdX - dEdX(exp) plots."}; Configurable enableExpSignalTOF{"enableExpSignalTOF", false, "Flag to export T - T(exp) plots."}; Configurable enableBetaCut{"enableBetaCut", false, "Flag to enable TOF histograms with beta cut for debug"}; + Configurable enablePIDplot{"enablePIDplot", false, "Flag to enable PID histograms for debug"}; + Configurable enableEffPlots{"enableEffPlots", false, "Flag to enable histograms for efficiency debug."}; + Configurable enableNoTOFPlots{"enableNoTOFPlots", false, "Flag to enable histograms for TOF debug."}; + } outFlagOptions; - Configurable enablePIDplot{"enablePIDplot", false, "Flag to enable PID histograms for debug"}; Configurable enableDebug{"enableDebug", false, "Flag to enable histograms for debug"}; - Configurable enablePtSpectra{"enablePtSpectra", false, "Flag to enable histograms for efficiency debug."}; Configurable usenITSLayer{"usenITSLayer", false, "Flag to enable ITS layer hit"}; Configurable useHasTRDConfig{"useHasTRDConfig", 0, "No selections on TRD (0); With TRD (1); Without TRD (2)"}; Configurable massTOFConfig{"massTOFConfig", 0, "Estimate massTOF using beta with (0) TPC momentum (1) TOF expected momentum (2) p momentum."}; Configurable helium3Pt{"helium3Pt", 0, "Select use default pT (0) or use instead 2*pT (1) for helium-3"}; - Configurable DeuteronPt{"DeuteronPt", 0, "Select (0) to apply deuteron pT shift or (1) to use default pT."}; - Configurable antiDeuteronPt{"antiDeuteronPt", 0, "Select (0) to apply antideuteron pT shift or (1) to use default pT."}; + Configurable unableDPtShift{"unableDPtShift", 0, "Select (0) to apply deuteron pT shift or (1) to use default pT."}; + Configurable unableAntiDPtShift{"unableAntiDPtShift", 0, "Select (0) to apply antideuteron pT shift or (1) to use default pT."}; // Additional function used for pT-shift calibration TF1* fShiftPtHe = 0; @@ -165,36 +202,66 @@ struct LFNucleiBATask { TF1* fShiftAntiD = 0; TF1* fShiftD = 0; - Configurable enablePtShiftAntiD{"enablePtShiftAntiD", true, "Flag to enable Pt shift (for antiDeuteron only)"}; Configurable enablePtShiftD{"enablePtShiftD", true, "Flag to enable Pt shift (for Deuteron only)"}; - Configurable> parShiftPtAntiD{"parShiftPtAntiD", {-0.0955412, 0.798164, -0.536111, 0.0887876, -1.11022e-13}, "Parameters for Pt shift (if enabled)."}; + Configurable enablePtShiftAntiD{"enablePtShiftAntiD", true, "Flag to enable Pt shift (for antiDeuteron only)"}; Configurable> parShiftPtD{"parShiftPtD", {-0.0955412, 0.798164, -0.536111, 0.0887876, -1.11022e-13}, "Parameters for Pt shift (if enabled)."}; + Configurable> parShiftPtAntiD{"parShiftPtAntiD", {-0.0955412, 0.798164, -0.536111, 0.0887876, -1.11022e-13}, "Parameters for Pt shift (if enabled)."}; - Configurable enablePtShift{"enablePtShift", false, "Flag to enable Pt shift (for He only)"}; + Configurable enablePtShiftHe{"enablePtShiftHe", false, "Flag to enable Pt shift (for He only)"}; Configurable> parShiftPtHe{"parShiftPtHe", {0.0f, 0.1f, 0.1f, 0.1f, 0.1f}, "Parameters for helium3-Pt shift (if enabled)."}; - Configurable> parShiftPtantiHe{"parShiftPtantiHe", {0.0f, 0.1f, 0.1f, 0.1f, 0.1f}, "Parameters for anti-helium3-Pt shift (if enabled)."}; + Configurable> parShiftPtAntiHe{"parShiftPtAntiHe", {0.0f, 0.1f, 0.1f, 0.1f, 0.1f}, "Parameters for anti-helium3-Pt shift (if enabled)."}; Configurable enableCentrality{"enableCentrality", true, "Flag to enable centrality 3D histos)"}; // PDG codes and masses used in this analysis - static constexpr int PDGPion = 211; - static constexpr int PDGKaon = 321; - static constexpr int PDGProton = 2212; - static constexpr int PDGDeuteron = 1000010020; - static constexpr int PDGTriton = 1000010030; - static constexpr int PDGHelium = 1000020030; - static constexpr int PDGAlpha = 1000020040; - static constexpr float MassProtonVal = 0.938272088f; - static constexpr float MassDeuteronVal = 1.87561f; - static constexpr float MassTritonVal = 2.80892f; - static constexpr float MassHeliumVal = 2.80839f; - static constexpr float MassAlphaVal = 3.72738f; - - void init(o2::framework::InitContext&) + static constexpr int PDGPion = PDG_t::kPiPlus; + static constexpr int PDGKaon = PDG_t::kKPlus; + static constexpr int PDGProton = PDG_t::kProton; + static constexpr int PDGDeuteron = o2::constants::physics::Pdg::kDeuteron; + static constexpr int PDGTriton = o2::constants::physics::Pdg::kTriton; + static constexpr int PDGHelium = o2::constants::physics::Pdg::kHelium3; + static constexpr int PDGAlpha = o2::constants::physics::Pdg::kAlpha; + static constexpr float MassProtonVal = o2::constants::physics::MassProton; + static constexpr float MassDeuteronVal = o2::constants::physics::MassDeuteron; + static constexpr float MassTritonVal = o2::constants::physics::MassTriton; + static constexpr float MassHeliumVal = o2::constants::physics::MassHelium3; + static constexpr float MassAlphaVal = o2::constants::physics::MassAlpha; + + template + float averageClusterSizeTrk(const TrackType& track) + { + return o2::aod::ITSResponse::averageClusterSize(track.itsClusterSizes()); + } + + float averageClusterSizePerCoslInv(uint32_t itsClusterSizes, float eta) { return o2::aod::ITSResponse::averageClusterSize(itsClusterSizes) * std::cosh(eta); } + + template + float averageClusterSizePerCoslInv(const TrackType& track) { + return averageClusterSizePerCoslInv(track.itsClusterSizes(), track.eta()); + } + + void initCCDB(o2::aod::BCsWithTimestamps::iterator const& bc) + { + if (skimmingOptions.applySkimming) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), skimmingOptions.cfgSkimming.value); + zorro.populateHistRegistry(histos, bc.runNumber()); + } + } + + void init(o2::framework::InitContext& context) + { + if (initITSPID) { + o2::aod::ITSResponse::setParameters(context); + } + if (skimmingOptions.applySkimming) { + zorroSummary.setObject(zorro.getZorroSummary()); + } + const AxisSpec pAxis{binsPt, "#it{p} (GeV/#it{c})"}; const AxisSpec ptAxis{binsPt, "#it{p}_{T} (GeV/#it{c})"}; const AxisSpec ptHeAxis{binsPtHe, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec pZAxis{binsPt, "#it{p}/z (GeV/#it{c})"}; const AxisSpec ptZHeAxis{binsPtZHe, "#it{p}_{T}/z (GeV/#it{c})"}; const AxisSpec dedxAxis{binsdEdx, "d#it{E}/d#it{x} A.U."}; const AxisSpec betaAxis{binsBeta, "TOF #beta"}; @@ -207,10 +274,25 @@ struct LFNucleiBATask { const AxisSpec sigmaITSAxis{binsSigmaITS, ""}; const AxisSpec sigmaTPCAxis{binsSigmaTPC, ""}; const AxisSpec sigmaTOFAxis{binsSigmaTOF, ""}; + const AxisSpec avClsAxis{avClsBins, ""}; + const AxisSpec avClsEffAxis{avClsBins, " / cosh(#eta)"}; if (doprocessData == true && doprocessMCReco == true) { LOG(fatal) << "Can't enable processData and processMCReco in the same time, pick one!"; } + if (doprocessEvSgLossMC) { + evLossHistos.add("evLoss/hEvent", "Event loss histograms; ; counts", HistType::kTH1F, {{3, 0., 3.}}); + evLossHistos.get(HIST("evLoss/hEvent"))->GetXaxis()->SetBinLabel(1, "All Gen."); + evLossHistos.get(HIST("evLoss/hEvent"))->GetXaxis()->SetBinLabel(2, "TVX (reco.)"); + evLossHistos.get(HIST("evLoss/hEvent"))->GetXaxis()->SetBinLabel(3, "Sel8 (reco.)"); + + evLossHistos.add("evLoss/pt/hDeuteronTriggeredTVX", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{100, 0., 5.}}); + evLossHistos.add("evLoss/pt/hDeuteronTriggeredSel8", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{100, 0., 5.}}); + evLossHistos.add("evLoss/pt/hDeuteronGen", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{100, 0., 5.}}); + evLossHistos.add("evLoss/pt/hAntiDeuteronTriggeredTVX", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{100, 0., 5.}}); + evLossHistos.add("evLoss/pt/hAntiDeuteronTriggeredSel8", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{100, 0., 5.}}); + evLossHistos.add("evLoss/pt/hAntiDeuteronGen", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{100, 0., 5.}}); + } spectraGen.add("LfEv/pT_nocut", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{ptHeAxis}}); spectraGen.add("LfEv/pT_TVXtrigger", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{ptHeAxis}}); spectraGen.add("LfEv/pT_TFrameBorder", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{ptHeAxis}}); @@ -248,19 +330,30 @@ struct LFNucleiBATask { } } - histos.add("event/eventSelection", "eventSelection", HistType::kTH1D, {{7, -0.5, 6.5}}); + histos.add("event/eventSkimming", "eventSkimming", HistType::kTH1D, {{2, 0.0, 2.0}}); + auto hSkim = histos.get(HIST("event/eventSkimming")); + hSkim->GetXaxis()->SetBinLabel(1, "Total"); + hSkim->GetXaxis()->SetBinLabel(2, "Skimmed events"); + + histos.add("event/eventSelection", "eventSelection", HistType::kTH1D, {{8, -0.5, 7.5}}); auto h = histos.get(HIST("event/eventSelection")); - h->GetXaxis()->SetBinLabel(1, "Total"); + if (skimmingOptions.applySkimming) + h->GetXaxis()->SetBinLabel(1, "Skimmed events"); + else + h->GetXaxis()->SetBinLabel(1, "Total"); h->GetXaxis()->SetBinLabel(2, "TVX trigger cut"); h->GetXaxis()->SetBinLabel(3, "TF border cut"); h->GetXaxis()->SetBinLabel(4, "ITS ROF cut"); h->GetXaxis()->SetBinLabel(5, "TVX + TF + ITS ROF"); h->GetXaxis()->SetBinLabel(6, "Sel8 cut"); h->GetXaxis()->SetBinLabel(7, "Z-vert Cut"); + h->GetXaxis()->SetBinLabel(8, "Multiplicity cut"); histos.add("event/h1VtxZ", "V_{z};V_{z} (in cm); counts", HistType::kTH1F, {{1500, -15, 15}}); - histos.add("tracks/h1pT", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{500, 0., 10.}}); - histos.add("tracks/h1p", "Track momentum; p (GeV/#it{c}); counts", HistType::kTH1F, {{500, 0., 10.}}); + if (outFlagOptions.enablePIDplot) { + histos.add("tracks/h1pT", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{500, 0., 10.}}); + histos.add("tracks/h1p", "Track momentum; p (GeV/#it{c}); counts", HistType::kTH1F, {{500, 0., 10.}}); + } histos.add("qa/h1ITSncr", "number of crossed rows in ITS; ITSncr; counts", HistType::kTH1F, {{12, 0, 12}}); histos.add("qa/h1TPCncr", "number of crossed rows in TPC; TPCncr; counts", HistType::kTH1F, {{150, 60, 170}}); @@ -269,7 +362,7 @@ struct LFNucleiBATask { histos.add("qa/h1chi2ITS", "#chi^{2}_{ITS}/n_{ITS}; #chi^{2}_{ITS}/n_{ITS};counts", HistType::kTH1F, {{51, -0.5, 50.5}}); histos.add("qa/h1chi2TPC", "#chi^{2}_{TPC}/n_{TPC}; #chi^{2}_{TPC}/n_{TPC}; counts", HistType::kTH1F, {{11, -0.5, 10.5}}); - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.add("tracks/eff/h2pVsTPCmomentum", "#it{p}_{TPC} vs #it{p}; #it{p}_{TPC}; #it{p}", HistType::kTH2F, {{200, 0.f, 8.f}, {200, 0.f, 8.f}}); if (outFlagOptions.doTOFplots) histos.add("tracks/eff/h2TPCmomentumVsTOFExpMomentum", "#it{p}_{TOF} vs #it{p}_{TPC}; #it{p}_{TOF}; #it{p}_{TPC}", HistType::kTH2F, {{200, 0.f, 8.f}, {200, 0.f, 8.f}}); @@ -319,12 +412,13 @@ struct LFNucleiBATask { if (enableDebug) { debugHistos.add("debug/event/h1CentV0M", "V0M; Multiplicity; counts", HistType::kTH1F, {{27000, 0, 27000}}); // trackQA - debugHistos.add("debug/tracks/h1Eta", "pseudoRapidity; #eta; counts", HistType::kTH1F, {{200, -1.0, 1.0}}); + debugHistos.add("debug/tracks/h1Eta", "pseudoRapidity; #eta; counts", HistType::kTH1F, {{200, -2.0, 2.0}}); debugHistos.add("debug/tracks/h1VarPhi", "#phi; #phi; counts", HistType::kTH1F, {{63, 0.0, 6.3}}); - debugHistos.add("debug/tracks/h2EtaVsPhi", "#eta vs #phi; #eta; #phi", HistType::kTH2F, {{200, -1.0, 1.0}, {63, 0.0, 6.3}}); + debugHistos.add("debug/tracks/h2EtaVsPhi", "#eta vs #phi; #eta; #phi", HistType::kTH2F, {{200, -2.0, 2.0}, {63, 0.0, 6.3}}); + debugHistos.add("debug/tracks/h2PionYvsPt", "#it{y} vs #it{p}_{T} (#pi)", HistType::kTH2F, {{200, -2.0, 2.0}, {ptAxis}}); } - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { if (enableDebug) { debugHistos.add("tracks/eff/hPtP", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); debugHistos.add("tracks/eff/hPtantiP", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); @@ -379,16 +473,12 @@ struct LFNucleiBATask { histos.add("tracks/dca/before/hDCAzVsPt", "DCAz vs Pt", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); if (enablePr) { - // histos.add("tracks/proton/dca/before/hDCAxyVsDCAzVsPtProton", "DCAxy vs DCAz vs Pt/z (p)", HistType::kTH3F, {{140, -0.7f, 0.7f}, {160, -0.8f, 0.8f}, {binsPtHe}}); - // histos.add("tracks/proton/dca/before/hDCAxyVsDCAzVsPtantiProton", "DCAxy vs DCAz vs Pt/z (#bar{p})", HistType::kTH3F, {{140, -0.7f, 0.7f}, {160, -0.8f, 0.8f}, {binsPtHe}}); histos.add("tracks/proton/dca/before/hDCAxyVsPtProton", "DCAxy vs Pt (p)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/hDCAxyVsPtantiProton", "DCAxy vs Pt (#bar{p})", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/hDCAzVsPtProton", "DCAz vs Pt (p)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/hDCAzVsPtantiProton", "DCAz vs Pt (#bar{p})", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); } if (enableDe) { - // histos.add("tracks/deuteron/dca/before/hDCAxyVsDCAzVsPtDeuteron", "DCAxy vs DCAz vs Pt/z (d)", HistType::kTH3F, {{140, -0.7f, 0.7f}, {160, -0.8f, 0.8f}, {binsPtHe}}); - // histos.add("tracks/deuteron/dca/before/hDCAxyVsDCAzVsPtantiDeuteron", "DCAxy vs DCAz vs Pt/z (#bar{d})", HistType::kTH3F, {{140, -0.7f, 0.7f}, {160, -0.8f, 0.8f}, {binsPtHe}}); if (enableCentrality) { histos.add("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronVsMult", "DCAxy vs Pt (d)", HistType::kTH3F, {{ptAxis}, {dcaxyAxis}, {binsPercentile}}); histos.add("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronVsMult", "DCAxy vs Pt (#bar{d})", HistType::kTH3F, {{ptAxis}, {dcaxyAxis}, {binsPercentile}}); @@ -399,14 +489,14 @@ struct LFNucleiBATask { histos.add("tracks/deuteron/dca/before/hDCAzVsPtDeuteron", "DCAz vs Pt (d)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteron", "DCAz vs Pt (#bar{d})", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronNoTOF", "DCAxy vs Pt (d)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronNoTOF", "DCAxy vs Pt (#bar{d})", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/hDCAzVsPtDeuteronNoTOF", "DCAz vs Pt (d)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronNoTOF", "DCAz vs Pt (#bar{d})", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + if (outFlagOptions.enableNoTOFPlots) { + histos.add("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronNoTOF", "DCAxy vs Pt (d)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronNoTOF", "DCAxy vs Pt (#bar{d})", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/hDCAzVsPtDeuteronNoTOF", "DCAz vs Pt (d)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronNoTOF", "DCAz vs Pt (#bar{d})", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + } } if (enableTr) { - // histos.add("tracks/triton/dca/before/hDCAxyVsDCAzVsPtTriton", "DCAxy vs DCAz vs Pt/z (t)", HistType::kTH3F, {{140, -0.7f, 0.7f}, {160, -0.8f, 0.8f}, {binsPtHe}}); - // histos.add("tracks/triton/dca/before/hDCAxyVsDCAzVsPtantiTriton", "DCAxy vs DCAz vs Pt/z (#bar{t})", HistType::kTH3F, {{140, -0.7f, 0.7f}, {160, -0.8f, 0.8f}, {binsPtHe}}); histos.add("tracks/triton/dca/before/hDCAxyVsPtTriton", "DCAxy vs Pt (t)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/hDCAxyVsPtantiTriton", "DCAxy vs Pt (#bar{t})", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/hDCAzVsPtTriton", "DCAz vs Pt (t)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); @@ -420,10 +510,12 @@ struct LFNucleiBATask { histos.add("tracks/helium/dca/before/hDCAzVsPtHelium", "DCAz vs Pt (He)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/hDCAzVsPtantiHelium", "DCAz vs Pt (#bar{He})", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/hDCAxyVsPtHeliumNoTOF", "DCAxy vs Pt (He)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/hDCAxyVsPtantiHeliumNoTOF", "DCAxy vs Pt (#bar{He})", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/hDCAzVsPtHeliumNoTOF", "DCAz vs Pt (He)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/hDCAzVsPtantiHeliumNoTOF", "DCAz vs Pt (#bar{He})", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + if (outFlagOptions.enableNoTOFPlots) { + histos.add("tracks/helium/dca/before/hDCAxyVsPtHeliumNoTOF", "DCAxy vs Pt (He)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/hDCAxyVsPtantiHeliumNoTOF", "DCAxy vs Pt (#bar{He})", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/hDCAzVsPtHeliumNoTOF", "DCAz vs Pt (He)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/hDCAzVsPtantiHeliumNoTOF", "DCAz vs Pt (#bar{He})", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + } if (outFlagOptions.doTOFplots) { histos.add("tracks/helium/dca/before/TOF/hDCAxyVsDCAzVsPtHelium", "DCAxy vs DCAz vs Pt/z (He) (w/TOF); DCAxy; DCAz", HistType::kTH3F, {{140, -0.7f, 0.7f}, {160, -0.8f, 0.8f}, {binsPtZHe}}); @@ -435,8 +527,6 @@ struct LFNucleiBATask { } } if (enableAl) { - // histos.add("tracks/alpha/dca/before/hDCAxyVsDCAzVsPtAlpha", "DCAxy vs DCAz vs Pt/z (#alpha)", HistType::kTH3F, {{140, -0.7f, 0.7f}, {160, -0.8f, 0.8f}, {binsPtZHe}}); - // histos.add("tracks/alpha/dca/before/hDCAxyVsDCAzVsPtantiAlpha", "DCAxy vs DCAz vs Pt/z (#bar{#alpha})", HistType::kTH3F, {{140, -0.7f, 0.7f}, {160, -0.8f, 0.8f}, {binsPtZHe}}); histos.add("tracks/alpha/dca/before/hDCAxyVsPtAlpha", "DCAxy vs Pt (#alpha)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/before/hDCAxyVsPtantiAlpha", "DCAxy vs Pt (#bar{#alpha})", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/before/hDCAzVsPtAlpha", "DCAz vs Pt (#alpha)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); @@ -516,20 +606,20 @@ struct LFNucleiBATask { histos.add("tracks/triton/h1antiTritonSpectra", "#it{p}_{T} (#bar{t})", HistType::kTH1F, {ptAxis}); } if (enableHe) { - histos.add("tracks/helium/h1HeliumSpectra", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h1antiHeliumSpectra", "#it{p}_{T}/z (#bar{He})", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1HeliumSpectra", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1antiHeliumSpectra", "#it{p}_{T}/z (#bar{He})", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h2HeliumYvsPt", "#it{y} vs #it{p}_{T}/z (He)", HistType::kTH2F, {{96, -1.2, 1.2}, {ptZHeAxis}}); + // histos.add("tracks/helium/h2HeliumYvsPt", "#it{y} vs #it{p}_{T}/z (He)", HistType::kTH2F, {{96, -1.2, 1.2}, {ptZHeAxis}}); histos.add("tracks/helium/h2HeliumYvsPt_Z2", "#it{y} vs #it{p}_{T} (He)", HistType::kTH2F, {{96, -1.2, 1.2}, {ptHeAxis}}); - histos.add("tracks/helium/h2HeliumEtavsPt", "#it{#eta} vs #it{p}_{T}/z (He)", HistType::kTH2F, {{96, -1.2, 1.2}, {ptZHeAxis}}); + // histos.add("tracks/helium/h2HeliumEtavsPt", "#it{#eta} vs #it{p}_{T}/z (He)", HistType::kTH2F, {{96, -1.2, 1.2}, {ptZHeAxis}}); histos.add("tracks/helium/h2HeliumEtavsPt_Z2", "#it{#eta} vs #it{p}_{T} (He)", HistType::kTH2F, {{96, -1.2, 1.2}, {ptHeAxis}}); histos.add("tracks/helium/h1HeliumSpectra_Z2", "#it{p}_{T} (He)", HistType::kTH1F, {ptHeAxis}); histos.add("tracks/helium/h1antiHeliumSpectra_Z2", "#it{p}_{T} (#bar{He})", HistType::kTH1F, {ptHeAxis}); - histos.add("tracks/helium/h2antiHeliumYvsPt", "#it{y} vs #it{p}_{T}/z (#bar{He})", HistType::kTH2F, {{96, -1.2, 1.2}, {ptZHeAxis}}); + // histos.add("tracks/helium/h2antiHeliumYvsPt", "#it{y} vs #it{p}_{T}/z (#bar{He})", HistType::kTH2F, {{96, -1.2, 1.2}, {ptZHeAxis}}); histos.add("tracks/helium/h2antiHeliumYvsPt_Z2", "#it{y} vs #it{p}_{T} (#bar{He})", HistType::kTH2F, {{96, -1.2, 1.2}, {ptHeAxis}}); - histos.add("tracks/helium/h2antiHeliumEtavsPt", "#it{#eta} vs #it{p}_{T}/z (#bar{He})", HistType::kTH2F, {{96, -1.2, 1.2}, {ptZHeAxis}}); + // histos.add("tracks/helium/h2antiHeliumEtavsPt", "#it{#eta} vs #it{p}_{T}/z (#bar{He})", HistType::kTH2F, {{96, -1.2, 1.2}, {ptZHeAxis}}); histos.add("tracks/helium/h2antiHeliumEtavsPt_Z2", "#it{#eta} vs #it{p}_{T} (#bar{He})", HistType::kTH2F, {{96, -1.2, 1.2}, {ptHeAxis}}); } if (enableAl) { @@ -729,11 +819,11 @@ struct LFNucleiBATask { histos.add("tracks/triton/h1antiTritonSpectraTrueTransport", "#it{p}_{T} (#bar{t})", HistType::kTH1F, {ptAxis}); } if (enableHe) { - histos.add("tracks/helium/h1HeliumSpectraTrue", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h1HeliumSpectraTrueWPID", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h1HeliumSpectraTruePrim", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h1HeliumSpectraTrueSec", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h1HeliumSpectraTrueTransport", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1HeliumSpectraTrue", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1HeliumSpectraTrueWPID", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1HeliumSpectraTruePrim", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1HeliumSpectraTrueSec", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1HeliumSpectraTrueTransport", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); histos.add("tracks/helium/h1HeliumSpectraTrue_Z2", "#it{p}_{T} (He)", HistType::kTH1F, {ptHeAxis}); histos.add("tracks/helium/h1HeliumSpectraTrueWPID_Z2", "#it{p}_{T} (He)", HistType::kTH1F, {ptHeAxis}); @@ -741,11 +831,11 @@ struct LFNucleiBATask { histos.add("tracks/helium/h1HeliumSpectraTrueSec_Z2", "#it{p}_{T} (He)", HistType::kTH1F, {ptHeAxis}); histos.add("tracks/helium/h1HeliumSpectraTrueTransport_Z2", "#it{p}_{T} (He)", HistType::kTH1F, {ptHeAxis}); - histos.add("tracks/helium/h1antiHeliumSpectraTrue", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h1antiHeliumSpectraTrueWPID", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h1antiHeliumSpectraTruePrim", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h1antiHeliumSpectraTrueSec", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); - histos.add("tracks/helium/h1antiHeliumSpectraTrueTransport", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1antiHeliumSpectraTrue", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1antiHeliumSpectraTrueWPID", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1antiHeliumSpectraTruePrim", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1antiHeliumSpectraTrueSec", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); + // histos.add("tracks/helium/h1antiHeliumSpectraTrueTransport", "#it{p}_{T}/z (He)", HistType::kTH1F, {ptZHeAxis}); histos.add("tracks/helium/h1antiHeliumSpectraTrue_Z2", "#it{p}_{T} (He)", HistType::kTH1F, {ptHeAxis}); histos.add("tracks/helium/h1antiHeliumSpectraTrueWPID_Z2", "#it{p}_{T} (He)", HistType::kTH1F, {ptHeAxis}); @@ -757,12 +847,12 @@ struct LFNucleiBATask { histos.add("tracks/helium/TOF/h1HeliumSpectraTruePrim_Z2", "#it{p}_{T} (He)", HistType::kTH1F, {ptHeAxis}); histos.add("tracks/helium/TOF/h1antiHeliumSpectraTruePrim_Z2", "#it{p}_{T} (He)", HistType::kTH1F, {ptHeAxis}); } - if (enablePtSpectra) { - histos.add("tracks/eff/helium/hPtHeTrue", "Track #it{p}_{T} (He); #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); - histos.add("tracks/eff/helium/hPtantiHeTrue", "Track #it{p}_{T} (#bar{He}); #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); + if (outFlagOptions.enableEffPlots) { + histos.add("tracks/eff/helium/hPtHeTrue_Z2", "Track #it{p}_{T} (He); #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); + histos.add("tracks/eff/helium/hPtantiHeTrue_Z2", "Track #it{p}_{T} (#bar{He}); #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); if (outFlagOptions.doTOFplots) { - histos.add("tracks/eff/helium/hPtHeTOFTrue", "Track #it{p}_{T} (He); #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); - histos.add("tracks/eff/helium/hPtantiHeTOFTrue", "Track #it{p}_{T} (#bar{He}); #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); + histos.add("tracks/eff/helium/hPtHeTOFTrue_Z2", "Track #it{p}_{T} (He); #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); + histos.add("tracks/eff/helium/hPtantiHeTOFTrue_Z2", "Track #it{p}_{T} (#bar{He}); #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{400, 0., 8.}}); } } } @@ -784,12 +874,14 @@ struct LFNucleiBATask { histos.add("tracks/proton/dca/before/hDCAxyVsPtProtonTruePrim", "DCAxy vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/hDCAxyVsPtProtonTrueSec", "DCAxy vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/proton/dca/before/hDCAxyVsPtProtonTrueMaterial", "DCAxy vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/hDCAxyVsPtProtonTrueTransport", "DCAxy vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/hDCAxyVsPtantiProtonTrue", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/hDCAxyVsPtantiProtonTruePrim", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/hDCAxyVsPtantiProtonTrueSec", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/proton/dca/before/hDCAxyVsPtantiProtonTrueMaterial", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/hDCAxyVsPtantiProtonTrueTransport", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); if (outFlagOptions.doTOFplots) { @@ -797,24 +889,28 @@ struct LFNucleiBATask { histos.add("tracks/proton/dca/before/TOF/hDCAxyVsPtProtonTruePrim", "DCAxy vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAxyVsPtProtonTrueSec", "DCAxy vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/proton/dca/before/TOF/hDCAxyVsPtProtonTrueMaterial", "DCAxy vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAxyVsPtProtonTrueTransport", "DCAxy vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAxyVsPtantiProtonTrue", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAxyVsPtantiProtonTruePrim", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAxyVsPtantiProtonTrueSec", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/proton/dca/before/TOF/hDCAxyVsPtantiProtonTrueMaterial", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAxyVsPtantiProtonTrueTransport", "DCAxy vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtProtonTrue", "DCAz vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtProtonTruePrim", "DCAz vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtProtonTrueSec", "DCAz vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtProtonTrueMaterial", "DCAz vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtProtonTrueTransport", "DCAz vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtantiProtonTrue", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtantiProtonTruePrim", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtantiProtonTrueSec", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtantiProtonTrueMaterial", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/TOF/hDCAzVsPtantiProtonTrueTransport", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); } } @@ -839,111 +935,89 @@ struct LFNucleiBATask { histos.add("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronTruePrim", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronTrueSec", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronTrueMaterial", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronTrueTransport", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronTrue", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronTruePrim", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronTrueSec", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronTrueMaterial", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronTrueTransport", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); // Fake & wrong histos - histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrue", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTruePrim", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrueSec", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrueTransport", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrue", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTruePrim", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrueSec", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrueTransport", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - - // histos.add("tracks/deuteron/dca/before/wrong/hDCAxyVsPtDeuteronTrue", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + if (outFlagOptions.makeFakeTracksPlots) { + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrue", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAxyVsPtDeuteronTruePrim", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAxyVsPtDeuteronTrueSec", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAxyVsPtDeuteronTrueTransport", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTruePrim", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrueSec", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrueTransport", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrueMaterial", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAxyVsPtantiDeuteronTrue", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrue", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAxyVsPtantiDeuteronTruePrim", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAxyVsPtantiDeuteronTrueSec", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAxyVsPtantiDeuteronTrueTransport", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTruePrim", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrueSec", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrueTransport", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrueMaterial", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + } if (outFlagOptions.doTOFplots) { histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtDeuteronTrue", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtDeuteronTruePrim", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtDeuteronTrueSec", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtDeuteronTrueMaterial", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtDeuteronTrueTransport", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtantiDeuteronTrue", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtantiDeuteronTruePrim", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtantiDeuteronTrueSec", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtantiDeuteronTrueMaterial", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAxyVsPtantiDeuteronTrueTransport", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtDeuteronTrue", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtDeuteronTruePrim", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtDeuteronTrueSec", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtDeuteronTrueMaterial", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtDeuteronTrueTransport", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtantiDeuteronTrue", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtantiDeuteronTruePrim", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtantiDeuteronTrueSec", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtantiDeuteronTrueMaterial", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/TOF/hDCAzVsPtantiDeuteronTrueTransport", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrue", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTruePrim", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrueSec", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrueTransport", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrue", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTruePrim", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrueSec", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrueTransport", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtDeuteronTrue", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + if (outFlagOptions.makeFakeTracksPlots) { + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrue", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtDeuteronTruePrim", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtDeuteronTrueSec", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtDeuteronTrueTransport", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTruePrim", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrueSec", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrueTransport", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrueMaterial", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtantiDeuteronTrue", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrue", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtantiDeuteronTruePrim", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtantiDeuteronTrueSec", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtantiDeuteronTrueTransport", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTruePrim", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrueSec", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrueTransport", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrueMaterial", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAxyVsPtDeuteronTrue", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtDeuteronTrue", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAxyVsPtDeuteronTruePrim", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAxyVsPtDeuteronTrueSec", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAxyVsPtDeuteronTrueTransport", "DCAxy vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtDeuteronTruePrim", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtDeuteronTrueSec", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtDeuteronTrueTransport", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAxyVsPtantiDeuteronTrue", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtantiDeuteronTrue", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAxyVsPtantiDeuteronTruePrim", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAxyVsPtantiDeuteronTrueSec", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAxyVsPtantiDeuteronTrueTransport", "DCAxy vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAzVsPtDeuteronTrue", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAzVsPtDeuteronTruePrim", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAzVsPtDeuteronTrueSec", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAzVsPtDeuteronTrueTransport", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAzVsPtantiDeuteronTrue", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAzVsPtantiDeuteronTruePrim", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAzVsPtantiDeuteronTrueSec", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/TOF/hDCAzVsPtantiDeuteronTrueTransport", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtantiDeuteronTruePrim", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtantiDeuteronTrueSec", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtantiDeuteronTrueTransport", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + } } } @@ -969,37 +1043,43 @@ struct LFNucleiBATask { histos.add("tracks/triton/dca/before/hDCAxyVsPtTritonTruePrim", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/hDCAxyVsPtTritonTrueSec", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/triton/dca/before/hDCAxyVsPtTritonTrueMaterial", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/hDCAxyVsPtTritonTrueTransport", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/hDCAxyVsPtantiTritonTrue", "DCAxy vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/hDCAxyVsPtantiTritonTruePrim", "DCAxy vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/hDCAxyVsPtantiTritonTrueSec", "DCAxy vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); - histos.add("tracks/triton/dca/before/hDCAxyVsPtantiTritonTrueTransport", "DCAxy vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/triton/dca/before/hDCAxyVsPtTritonTrueMaterial", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/triton/dca/before/hDCAxyVsPtTritonTrueTransport", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); if (outFlagOptions.doTOFplots) { histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtTritonTrue", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtTritonTruePrim", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtTritonTrueSec", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtTritonTrueMaterial", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtTritonTrueTransport", "DCAxy vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtantiTritonTrue", "DCAxy vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtantiTritonTruePrim", "DCAxy vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtantiTritonTrueSec", "DCAxy vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtantiTritonTrueMaterial", "DCAxy vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAxyVsPtantiTritonTrueTransport", "DCAxy vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtTritonTrue", "DCAz vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtTritonTruePrim", "DCAz vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtTritonTrueSec", "DCAz vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtTritonTrueMaterial", "DCAz vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtTritonTrueTransport", "DCAz vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtantiTritonTrue", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtantiTritonTruePrim", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtantiTritonTrueSec", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtantiTritonTrueMaterial", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/TOF/hDCAzVsPtantiTritonTrueTransport", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); } } @@ -1051,24 +1131,28 @@ struct LFNucleiBATask { histos.add("tracks/helium/dca/before/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/hDCAxyVsPtHeliumTrueMaterial", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/hDCAxyVsPtantiHeliumTrueMaterial", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/hDCAzVsPtHeliumTrueMaterial", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/hDCAzVsPtantiHeliumTrueMaterial", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); if (outFlagOptions.doTOFplots) { @@ -1076,123 +1160,137 @@ struct LFNucleiBATask { histos.add("tracks/helium/dca/before/TOF/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/TOF/hDCAxyVsPtHeliumTrueMaterial", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/TOF/hDCAxyVsPtantiHeliumTrueMaterial", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtHeliumTrueMaterial", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtantiHeliumTrueMaterial", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); histos.add("tracks/helium/dca/before/TOF/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); } // Fake & wrong histos - histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrue", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + if (outFlagOptions.makeFakeTracksPlots) { + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrue", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrueMaterial", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrueMaterial", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + } - histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtHeliumTrue", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + if (outFlagOptions.makeWrongEventPlots) { + histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtHeliumTrue", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + } if (outFlagOptions.doTOFplots) { - histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTrue", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + if (outFlagOptions.makeFakeTracksPlots) { + histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTrue", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/fake/TOF/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + } - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtHeliumTrue", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + if (outFlagOptions.makeWrongEventPlots) { + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtHeliumTrue", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtHeliumTruePrim", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtHeliumTrueSec", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtHeliumTrueTransport", "DCAxy vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtantiHeliumTrue", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtantiHeliumTruePrim", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtantiHeliumTrueSec", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtantiHeliumTrueTransport", "DCAxy vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcaxyAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtHeliumTrue", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtHeliumTruePrim", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtHeliumTrueSec", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtHeliumTrueTransport", "DCAz vs Pt (He); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtantiHeliumTrue", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); - histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtantiHeliumTruePrim", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtantiHeliumTrueSec", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + histos.add("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtantiHeliumTrueTransport", "DCAz vs Pt (#bar{He}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptZHeAxis}, {dcazAxis}}); + } } } @@ -1254,12 +1352,14 @@ struct LFNucleiBATask { histos.add("tracks/alpha/dca/before/hDCAxyVsPtAlphaTruePrim", "DCAxy vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/before/hDCAxyVsPtAlphaTrueSec", "DCAxy vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/alpha/dca/before/hDCAxyVsPtAlphaTrueMaterial", "DCAxy vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/before/hDCAxyVsPtAlphaTrueTransport", "DCAxy vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/before/hDCAxyVsPtantiAlphaTrue", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/before/hDCAxyVsPtantiAlphaTruePrim", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/before/hDCAxyVsPtantiAlphaTrueSec", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/alpha/dca/before/hDCAxyVsPtantiAlphaTrueMaterial", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/before/hDCAxyVsPtantiAlphaTrueTransport", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); } @@ -1268,12 +1368,14 @@ struct LFNucleiBATask { histos.add("tracks/alpha/dca/after/hDCAxyVsPtAlphaTruePrim", "DCAxy vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/after/hDCAxyVsPtAlphaTrueSec", "DCAxy vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/alpha/dca/after/hDCAxyVsPtAlphaTrueMaterial", "DCAxy vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/after/hDCAxyVsPtAlphaTrueTransport", "DCAxy vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/after/hDCAxyVsPtantiAlphaTrue", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/after/hDCAxyVsPtantiAlphaTruePrim", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/after/hDCAxyVsPtantiAlphaTrueSec", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); + histos.add("tracks/alpha/dca/after/hDCAxyVsPtantiAlphaTrueMaterial", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); histos.add("tracks/alpha/dca/after/hDCAxyVsPtantiAlphaTrueTransport", "DCAxy vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAxy (cm)", HistType::kTH2F, {{ptAxis}, {dcaxyAxis}}); } } @@ -1284,12 +1386,14 @@ struct LFNucleiBATask { histos.add("tracks/proton/dca/before/hDCAzVsPtProtonTruePrim", "DCAz vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/hDCAzVsPtProtonTrueSec", "DCAz vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/proton/dca/before/hDCAzVsPtProtonTrueMaterial", "DCAz vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/hDCAzVsPtProtonTrueTransport", "DCAz vs Pt (p); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/hDCAzVsPtantiProtonTrue", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/hDCAzVsPtantiProtonTruePrim", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/hDCAzVsPtantiProtonTrueSec", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/proton/dca/before/hDCAzVsPtantiProtonTrueMaterial", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/proton/dca/before/hDCAzVsPtantiProtonTrueTransport", "DCAz vs Pt (#bar{p}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); } if (outFlagOptions.makeDCAAfterCutPlots) { @@ -1312,37 +1416,29 @@ struct LFNucleiBATask { histos.add("tracks/deuteron/dca/before/hDCAzVsPtDeuteronTruePrim", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/hDCAzVsPtDeuteronTrueSec", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/hDCAzVsPtDeuteronTrueMaterial", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/hDCAzVsPtDeuteronTrueTransport", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronTrue", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronTruePrim", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronTrueSec", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronTrueMaterial", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronTrueTransport", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtDeuteronTrue", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtDeuteronTruePrim", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtDeuteronTrueSec", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtDeuteronTrueTransport", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtantiDeuteronTrue", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - - histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtantiDeuteronTruePrim", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtantiDeuteronTrueSec", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtantiDeuteronTrueTransport", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - - // histos.add("tracks/deuteron/dca/before/wrong/hDCAzVsPtDeuteronTrue", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + if (outFlagOptions.makeFakeTracksPlots) { + histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtDeuteronTrue", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAzVsPtDeuteronTruePrim", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAzVsPtDeuteronTrueSec", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAzVsPtDeuteronTrueTransport", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtDeuteronTruePrim", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtDeuteronTrueSec", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtDeuteronTrueTransport", "DCAz vs Pt (d); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAzVsPtantiDeuteronTrue", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtantiDeuteronTrue", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAzVsPtantiDeuteronTruePrim", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAzVsPtantiDeuteronTrueSec", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); - // histos.add("tracks/deuteron/dca/before/wrong/hDCAzVsPtantiDeuteronTrueTransport", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtantiDeuteronTruePrim", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtantiDeuteronTrueSec", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/deuteron/dca/before/fake/hDCAzVsPtantiDeuteronTrueTransport", "DCAz vs Pt (#bar{d}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + } } if (outFlagOptions.makeDCAAfterCutPlots) { @@ -1367,12 +1463,14 @@ struct LFNucleiBATask { histos.add("tracks/triton/dca/before/hDCAzVsPtTritonTruePrim", "DCAz vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/hDCAzVsPtTritonTrueSec", "DCAz vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/triton/dca/before/hDCAzVsPtTritonTrueMaterial", "DCAz vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/hDCAzVsPtTritonTrueTransport", "DCAz vs Pt (t); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/hDCAzVsPtantiTritonTrue", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/hDCAzVsPtantiTritonTruePrim", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/hDCAzVsPtantiTritonTrueSec", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/triton/dca/before/hDCAzVsPtantiTritonTrueMaterial", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/triton/dca/before/hDCAzVsPtantiTritonTrueTransport", "DCAz vs Pt (#bar{t}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); } @@ -1397,12 +1495,14 @@ struct LFNucleiBATask { histos.add("tracks/alpha/dca/before/hDCAzVsPtAlphaTruePrim", "DCAz vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/alpha/dca/before/hDCAzVsPtAlphaTrueSec", "DCAz vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/alpha/dca/before/hDCAzVsPtAlphaTrueMaterial", "DCAz vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/alpha/dca/before/hDCAzVsPtAlphaTrueTransport", "DCAz vs Pt (#alpha); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/alpha/dca/before/hDCAzVsPtantiAlphaTrue", "DCAz vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/alpha/dca/before/hDCAzVsPtantiAlphaTruePrim", "DCAz vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/alpha/dca/before/hDCAzVsPtantiAlphaTrueSec", "DCAz vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); + histos.add("tracks/alpha/dca/before/hDCAzVsPtantiAlphaTrueMaterial", "DCAz vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); histos.add("tracks/alpha/dca/before/hDCAzVsPtantiAlphaTrueTransport", "DCAz vs Pt (#bar{#alpha}); #it{p}_{T} (GeV/#it{c}); DCAz (cm)", HistType::kTH2F, {{ptAxis}, {dcazAxis}}); } @@ -1423,35 +1523,47 @@ struct LFNucleiBATask { } // Bethe-Bloch TPC distribution and Beta vs pT TOF distribution - histos.add("tracks/h2TPCsignVsTPCmomentum", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, -8.f, 8.f}, {dedxAxis}}); + if (nsigmaITSvar.showAverageClusterSize && outFlagOptions.enablePIDplot) { + histos.add("tracks/avgClusterSizePerCoslInvVsITSlayers", "", HistType::kTH3F, {{pZAxis}, {avClsEffAxis}, {8, -0.5, 7.5}}); + histos.add("tracks/averageClusterSize", "", HistType::kTH2F, {{pZAxis}, {avClsAxis}}); + histos.add("tracks/averageClusterSizePerCoslInv", "", HistType::kTH2F, {{pZAxis}, {avClsEffAxis}}); + } if (enableDebug) { debugHistos.add("debug/h2TPCsignVsTPCmomentum_AllTracks", "TPC <-dE/dX> vs #it{p}/Z (w/o rejection); Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, -8.f, 8.f}, {dedxAxis}}); debugHistos.add("debug/h2TPCsignVsTPCmomentum_FakeHits", "TPC <-dE/dX> vs #it{p}/Z (Fake hits); Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, -8.f, 8.f}, {dedxAxis}}); } - if (enablePIDplot) { + if (outFlagOptions.enablePIDplot) { + histos.add("tracks/h2TPCsignVsTPCmomentum", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, -8.f, 8.f}, {dedxAxis}}); if (enablePr) { - histos.add("tracks/proton/h2TPCsignVsTPCmomentumProton", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); - histos.add("tracks/proton/h2TPCsignVsTPCmomentumantiProton", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/proton/h2TPCsignVsTPCmomentumProton", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/proton/h2TPCsignVsTPCmomentumantiProton", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); } if (enableDe) { - histos.add("tracks/deuteron/h2TPCsignVsTPCmomentumDeuteron", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); - histos.add("tracks/deuteron/h2TPCsignVsTPCmomentumantiDeuteron", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/deuteron/h2TPCsignVsTPCmomentumDeuteron", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/deuteron/h2TPCsignVsTPCmomentumantiDeuteron", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); } if (enableTr) { - histos.add("tracks/triton/h2TPCsignVsTPCmomentumTriton", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); - histos.add("tracks/triton/h2TPCsignVsTPCmomentumantiTriton", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/triton/h2TPCsignVsTPCmomentumTriton", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/triton/h2TPCsignVsTPCmomentumantiTriton", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); } if (enableHe) { - histos.add("tracks/helium/h2TPCsignVsTPCmomentumHelium", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); - histos.add("tracks/helium/h2TPCsignVsTPCmomentumantiHelium", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/helium/h2TPCsignVsTPCmomentumHelium", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/helium/h2TPCsignVsTPCmomentumantiHelium", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); } if (enableAl) { - histos.add("tracks/alpha/h2TPCsignVsTPCmomentumAlpha", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); - histos.add("tracks/alpha/h2TPCsignVsTPCmomentumantiAlpha", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{400, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/alpha/h2TPCsignVsTPCmomentumAlpha", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); + histos.add("tracks/alpha/h2TPCsignVsTPCmomentumantiAlpha", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{200, 0.f, 8.f}, {dedxAxis}}); } } - if (outFlagOptions.doTOFplots) { + if (enableHe) { + if (nsigmaITSvar.showAverageClusterSize) { + histos.add("tracks/helium/averageClusterSize", "", HistType::kTH2F, {{pZAxis}, {avClsAxis}}); + histos.add("tracks/helium/averageClusterSizePerCoslInv", "", HistType::kTH2F, {{pZAxis}, {avClsEffAxis}}); + } + } + + if (outFlagOptions.doTOFplots && outFlagOptions.enablePIDplot) { histos.add("tracks/h2TPCsignVsBetaGamma", "TPC <-dE/dX> vs #beta#gamma/Z; Signed #beta#gamma; TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{250, -5.f, 5.f}, {dedxAxis}}); histos.add("tracks/h2TOFbetaVsP", "TOF #beta vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TOF #beta", HistType::kTH2F, {{250, -5.f, 5.f}, {betaAxis}}); if (outFlagOptions.enableBetaCut) @@ -1485,6 +1597,11 @@ struct LFNucleiBATask { histos.add("tracks/proton/h2antiProtonVspTNSigmaTPC", "NSigmaTPC(#bar{p}) vs pT; #it{p}_{T} (GeV/#it{c}); NSigmaTPC", HistType::kTH2F, {{ptAxis}, {sigmaTPCAxis}}); } if (enableDe) { + histos.add("tracks/deuteron/h2DeuteronVspNSigmaITSDe", "NSigmaITS(d) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(d)", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + histos.add("tracks/deuteron/h2antiDeuteronVspNSigmaITSDe", "NSigmaITS(#bar{d}) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(#bar{d})", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + histos.add("tracks/deuteron/h2DeuteronVspNSigmaITSDe_wTPCpid", "NSigmaITS(d) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(d)", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + histos.add("tracks/deuteron/h2antiDeuteronVspNSigmaITSDe_wTPCpid", "NSigmaITS(#bar{d}) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(#bar{d})", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + if (enableCentrality) { histos.add("tracks/deuteron/h3DeuteronVspTNSigmaTPCVsMult", "NSigmaTPC(d) vs pT; #it{p}_{T} (GeV/#it{c}) vs mult; NSigmaTPC", HistType::kTH3F, {{ptAxis}, {sigmaTPCAxis}, {binsPercentile}}); histos.add("tracks/deuteron/h3antiDeuteronVspTNSigmaTPCVsMult", "NSigmaTPC(#bar{d}) vs pT; #it{p}_{T} (GeV/#it{c}) vs mult; NSigmaTPC", HistType::kTH3F, {{ptAxis}, {sigmaTPCAxis}, {binsPercentile}}); @@ -1496,15 +1613,21 @@ struct LFNucleiBATask { } } if (enableTr) { - // histos.add("tracks/triton/h2TritonVspTNSigmaITS", "NSigmaITS(t) vs pT; #it{p}_{T} (GeV/#it{c}); NSigmaITS", HistType::kTH2F, {{ptAxis}, {sigmaITSAxis}}); - // histos.add("tracks/triton/h2antiTritonVspTNSigmaITS", "NSigmaITS(#bar{t}) vs pT; #it{p}_{T} (GeV/#it{c}); NSigmaITS", HistType::kTH2F, {{ptAxis}, {sigmaITSAxis}}); - histos.add("tracks/triton/h2TritonVspTNSigmaTPC", "NSigmaTPC(t) vs pT; #it{p}_{T} (GeV/#it{c}); NSigmaTPC", HistType::kTH2F, {{ptAxis}, {sigmaTPCAxis}}); histos.add("tracks/triton/h2antiTritonVspTNSigmaTPC", "NSigmaTPC(#bar{t}) vs pT; #it{p}_{T} (GeV/#it{c}); NSigmaTPC", HistType::kTH2F, {{ptAxis}, {sigmaTPCAxis}}); } if (enableHe) { - histos.add("tracks/helium/h2HeliumVspTNSigmaITS", "NSigmaITS(He) vs pT/z; #it{p}_{T}/z (GeV/#it{c}); NSigmaITS", HistType::kTH2F, {{ptZHeAxis}, {sigmaITSAxis}}); - histos.add("tracks/helium/h2antiHeliumVspTNSigmaITS", "NSigmaITS(#bar{He}) vs pT/z; #it{p}_{T}/z (GeV/#it{c}); NSigmaITS", HistType::kTH2F, {{ptZHeAxis}, {sigmaITSAxis}}); + histos.add("tracks/helium/h2HeliumVspTNSigmaITSHe", "NSigmaITS(He) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(He)", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + histos.add("tracks/helium/h2antiHeliumVspTNSigmaITSHe", "NSigmaITS(#bar{He}) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(#bar{He})", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + + histos.add("tracks/helium/h2HeliumVspTNSigmaITSTr", "NSigmaITS(t) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(t)", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + histos.add("tracks/helium/h2antiHeliumVspTNSigmaITSTr", "NSigmaITS(#bar{t}) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(#bar{t})", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + + histos.add("tracks/helium/h2HeliumVspTNSigmaITSHe_wTPCpid", "NSigmaITS(He) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(He)", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + histos.add("tracks/helium/h2antiHeliumVspTNSigmaITSHe_wTPCpid", "NSigmaITS(#bar{He}) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(#bar{He})", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + + histos.add("tracks/helium/h2HeliumVspTNSigmaITSTr_wTPCpid", "NSigmaITS(t) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(t)", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); + histos.add("tracks/helium/h2antiHeliumVspTNSigmaITSTr_wTPCpid", "NSigmaITS(#bar{t}) vs p/z; #it{p}/z (GeV/#it{c}); NSigmaITS(#bar{t})", HistType::kTH2F, {{pZAxis}, {sigmaITSAxis}}); histos.add("tracks/helium/h2HeliumVspTNSigmaTPC", "NSigmaTPC(He) vs pT/z; #it{p}_{T}/z (GeV/#it{c}); NSigmaTPC", HistType::kTH2F, {{ptZHeAxis}, {sigmaTPCAxis}}); histos.add("tracks/helium/h2antiHeliumVspTNSigmaTPC", "NSigmaTPC(#bar{He}) vs pT/z; #it{p}_{T}/z (GeV/#it{c}); NSigmaTPC", HistType::kTH2F, {{ptZHeAxis}, {sigmaTPCAxis}}); @@ -1573,7 +1696,8 @@ struct LFNucleiBATask { histos.add("tracks/helium/h2antiHeliumVspTNSigmaTOF", "NSigmaTOF(#bar{He}) vs #it{p}_{T}/z; #it{p}_{T}/z (GeV/#it{c}); NSigmaTOF", HistType::kTH2F, {{ptZHeAxis}, {sigmaTOFAxis}}); } // TOF mass histograms - histos.add("tracks/h2TOFmassVsPt", "h2TOFmassVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{180, 0.4, 4.}, {250, 0., 5.}}); + if (outFlagOptions.enablePIDplot) + histos.add("tracks/h2TOFmassVsPt", "h2TOFmassVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{180, 0.4, 4.}, {250, 0., 5.}}); if (enablePr) { histos.add("tracks/proton/h2TOFmassProtonVsPt", "h2TOFmassProtonVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{180, 0.4, 4.}, {250, 0., 5.}}); histos.add("tracks/proton/h2TOFmassantiProtonVsPt", "h2TOFmassantiProtonVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{180, 0.4, 4.}, {250, 0., 5.}}); @@ -1647,7 +1771,7 @@ struct LFNucleiBATask { } } // TOF EvTime Splitting plots - if (enableEvTimeSplitting) { + if (filterOptions.enableEvTimeSplitting) { // Bethe-Bloch TPC distribution - TOF EvTime Splitted evtimeHistos.add("tracks/evtime/fill/h2TPCsignVsTPCmomentum", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{500, -5.f, 5.f}, {dedxAxis}}); evtimeHistos.add("tracks/evtime/tof/h2TPCsignVsTPCmomentum", "TPC <-dE/dX> vs #it{p}/Z; Signed #it{p} (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{500, -5.f, 5.f}, {dedxAxis}}); @@ -1844,8 +1968,8 @@ struct LFNucleiBATask { } } } - - if (!doprocessMCGen) { + // To be optimised + if (!doprocessMCGen && !doprocessMCReco && !doprocessMCRecoLfPid && !doprocessMCRecoFiltered && !doprocessMCRecoFilteredLight) { LOG(info) << "Histograms of LFNucleiBATask:"; histos.print(); return; @@ -1971,6 +2095,19 @@ struct LFNucleiBATask { const TracksType& tracks, const ParticleType& /*particles*/) { + histos.fill(HIST("event/eventSkimming"), 0.5); + // Apply skimming + if constexpr (!IsFilteredData) { + const auto& bc = event.template bc_as(); + initCCDB(bc); + if (skimmingOptions.applySkimming) { + if (!zorro.isSelected(bc.globalBC())) { + return; + } + } + histos.fill(HIST("event/eventSkimming"), 1.5); + } + // Event histos fill histos.fill(HIST("event/eventSelection"), 0); if (enableDebug) @@ -1978,7 +2115,7 @@ struct LFNucleiBATask { if constexpr (!IsFilteredData) { if (!event.selection_bit(aod::evsel::kIsTriggerTVX)) { - if (evselOptions.TVXtrigger) + if (evselOptions.useTVXtrigger) return; } else { histos.fill(HIST("event/eventSelection"), 1); @@ -2016,24 +2153,24 @@ struct LFNucleiBATask { if (enableDebug) debugHistos.fill(HIST("qa/h1VtxZ_sel8"), event.posZ()); - if (enableCentrality) { - if (event.centFT0M() < cfgLowMultCut || event.centFT0M() > cfgHighMultCut) { - return; - } - if (enableDebug) - debugHistos.fill(HIST("event/h1VtxZ_Centrality"), event.posZ()); - } - - if (event.posZ() < cfgLowCutVertex || event.posZ() > cfgHighCutVertex) + if (event.posZ() < cfgVzCutLow || event.posZ() > cfgVzCutHigh) return; histos.fill(HIST("event/eventSelection"), 6); } else { - if (event.posZ() < cfgLowCutVertex || event.posZ() > cfgHighCutVertex) + if (event.posZ() < cfgVzCutLow || event.posZ() > cfgVzCutHigh) return; if (evselOptions.removeTFBorder && !event.selection_bit(aod::evsel::kNoTimeFrameBorder)) return; } + if (event.centFT0M() <= cfgMultCutLow || event.centFT0M() > cfgMultCutHigh) { + return; + } + histos.fill(HIST("event/eventSelection"), 7); + + if (enableCentrality && enableDebug) { + debugHistos.fill(HIST("event/h1VtxZ_Centrality"), event.posZ()); + } float gamma = 0., massTOF = 0., massTOFhe = 0., massTOFantihe = 0., heTPCmomentum = 0.f, antiheTPCmomentum = 0.f, heP = 0.f, antiheP = 0.f, hePt = 0.f, antihePt = 0.f, antiDPt = 0.f, DPt = 0.f; bool isTritonTPCpid = false; @@ -2054,40 +2191,69 @@ struct LFNucleiBATask { } auto tracksWithITS = soa::Attach(tracks); + if (tracksWithITS.size() != tracks.size()) { + LOG(fatal) << "Problem with track size"; + } - for (auto& track : tracksWithITS) { - histos.fill(HIST("tracks/h1pT"), track.pt()); - histos.fill(HIST("tracks/h1p"), track.p()); + tracks.copyIndexBindings(tracksWithITS); + for (auto& track : tracksWithITS) { if constexpr (!IsFilteredData) { - if (!track.isGlobalTrackWoDCA()) { + if (!track.isGlobalTrackWoDCA() && filterOptions.enableIsGlobalTrack) { continue; } } std::bitset<8> itsClusterMap = track.itsClusterMap(); - if (track.itsNCls() < cfgCutITSClusters) + + if constexpr (!IsFilteredData) { + if (nsigmaITSvar.showAverageClusterSize && outFlagOptions.enablePIDplot) + histos.fill(HIST("tracks/avgClusterSizePerCoslInvVsITSlayers"), track.p(), averageClusterSizePerCoslInv(track), track.itsNCls()); + } + + if (track.itsNCls() < trkqcOptions.cfgCutITSClusters) + continue; + if (track.tpcNClsCrossedRows() < trkqcOptions.cfgCutTPCXRows) + continue; + if (track.tpcNClsFound() < trkqcOptions.cfgCutTPCClusters) continue; - if (track.tpcNClsCrossedRows() < cfgCutTPCXRows) + if (track.tpcCrossedRowsOverFindableCls() < trkqcOptions.cfgCutTPCCROFnd) + continue; + auto tpcChi2NclRange = (std::vector)trkqcOptions.tpcChi2NclCuts; + if ((track.tpcChi2NCl() < tpcChi2NclRange[0]) || (track.tpcChi2NCl() > tpcChi2NclRange[1])) + continue; + auto itsChi2NclRange = (std::vector)trkqcOptions.itsChi2NclCuts; + if ((track.itsChi2NCl() < itsChi2NclRange[0]) || (track.itsChi2NCl() > itsChi2NclRange[1])) + continue; + + // p cut + if (std::abs(track.tpcInnerParam()) < kinemOptions.cfgMomentumCut) continue; - if (track.tpcNClsFound() < cfgCutTPCClusters) + // eta cut + if (std::abs(track.eta()) > kinemOptions.cfgEtaCut) continue; + if (outFlagOptions.enablePIDplot) { + histos.fill(HIST("tracks/h1pT"), track.pt()); + histos.fill(HIST("tracks/h1p"), track.p()); + } + isTritonTPCpid = std::abs(track.tpcNSigmaTr()) < nsigmaTPCvar.nsigmaTPCTr; float shiftPtPos = 0.f; float shiftPtNeg = 0.f; - if (enablePtShift && !fShiftPtHe) { + if (enablePtShiftHe && !fShiftPtHe) { fShiftPtHe = new TF1("fShiftPtHe", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x", 0.f, 8.f); auto par = (std::vector)parShiftPtHe; fShiftPtHe->SetParameters(par[0], par[1], par[2], par[3], par[4]); } - if (enablePtShift && !fShiftPtantiHe) { + if (enablePtShiftHe && !fShiftPtantiHe) { fShiftPtantiHe = new TF1("fShiftPtantiHe", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x", 0.f, 8.f); - auto par = (std::vector)parShiftPtantiHe; + auto par = (std::vector)parShiftPtAntiHe; fShiftPtantiHe->SetParameters(par[0], par[1], par[2], par[3], par[4]); } @@ -2097,7 +2263,7 @@ struct LFNucleiBATask { fShiftAntiD->SetParameters(par[0], par[1], par[2], par[3], par[4]); } - switch (antiDeuteronPt) { + switch (unableAntiDPtShift) { case 0: if (enablePtShiftAntiD && fShiftAntiD) { auto shiftAntiD = fShiftAntiD->Eval(track.pt()); @@ -2115,7 +2281,7 @@ struct LFNucleiBATask { fShiftD->SetParameters(par[0], par[1], par[2], par[3], par[4]); } - switch (DeuteronPt) { + switch (unableDPtShift) { case 0: if (enablePtShiftD && fShiftD) { auto shiftD = fShiftD->Eval(track.pt()); @@ -2130,12 +2296,12 @@ struct LFNucleiBATask { switch (helium3Pt) { case 0: hePt = track.pt(); - if (enablePtShift && fShiftPtHe) { + if (enablePtShiftHe && fShiftPtHe) { shiftPtPos = fShiftPtHe->Eval(2 * track.pt()); hePt = track.pt() - shiftPtPos / 2.f; } antihePt = track.pt(); - if (enablePtShift && fShiftPtantiHe) { + if (enablePtShiftHe && fShiftPtantiHe) { shiftPtNeg = fShiftPtantiHe->Eval(2 * track.pt()); antihePt = track.pt() - shiftPtNeg / 2.f; } @@ -2146,10 +2312,17 @@ struct LFNucleiBATask { break; } - float nITSTr, nITSHe; - nITSTr = track.itsNSigmaTr(); - nITSHe = track.itsNSigmaHe(); + // float nITSDe_Table = 99.f; + float nITSDe = 99.f; + float nITSTr = 99.f; + float nITSHe = 99.f; + // o2::aod::ITSResponse itsResponse; + if (!IsFilteredData) { + nITSDe = track.itsNSigmaDe(); + nITSTr = track.itsNSigmaTr(); + nITSHe = track.itsNSigmaHe(); + } heP = track.p(); antiheP = track.p(); heTPCmomentum = track.tpcInnerParam(); @@ -2208,20 +2381,20 @@ struct LFNucleiBATask { bool passDCAxyzCut = false; - switch (dcaConfOptions.DCACustomConfig) { + switch (dcaConfOptions.cfgCustomDCA) { case 0: - passDCAxyCut = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); - passDCAzCut = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); - - passDCAxyCutDe = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); - passDCAzCutDe = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); - passDCAxyCutAntiDe = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); - passDCAzCutAntiDe = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); - - passDCAxyCutHe = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); - passDCAzCutHe = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); - passDCAxyCutAntiHe = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); - passDCAzCutAntiHe = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); + passDCAxyCut = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); + passDCAzCut = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); + + passDCAxyCutDe = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); + passDCAzCutDe = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); + passDCAxyCutAntiDe = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); + passDCAzCutAntiDe = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); + + passDCAxyCutHe = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); + passDCAzCutHe = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); + passDCAxyCutAntiHe = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); + passDCAzCutAntiHe = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); break; case 1: passDCAxyCut = (std::abs(track.dcaXY()) <= parDCAxy[3] * (parDCAxy[0] + parDCAxy[1] / std::pow(track.pt(), parDCAxy[2]))); @@ -2239,45 +2412,45 @@ struct LFNucleiBATask { break; case 2: passDCAxyCut = (std::abs(track.dcaXY()) <= parDCAxy[3] * (parDCAxy[0] + parDCAxy[1] / std::pow(track.pt(), parDCAxy[2]))); - passDCAzCut = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); + passDCAzCut = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); passDCAxyCutDe = (std::abs(track.dcaXY()) <= parDCAxy[3] * (parDCAxy[0] + parDCAxy[1] / std::pow(DPt, parDCAxy[2]))); - passDCAzCutDe = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); + passDCAzCutDe = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); passDCAxyCutAntiDe = (std::abs(track.dcaXY()) <= parDCAxy[3] * (parDCAxy[0] + parDCAxy[1] / std::pow(antiDPt, parDCAxy[2]))); - passDCAzCutAntiDe = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); + passDCAzCutAntiDe = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); passDCAxyCutHe = (std::abs(track.dcaXY()) <= parDCAxy[3] * (parDCAxy[0] + parDCAxy[1] / std::pow(hePt, parDCAxy[2]))); - passDCAzCutHe = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); + passDCAzCutHe = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); passDCAxyCutAntiHe = (std::abs(track.dcaXY()) <= parDCAxy[3] * (parDCAxy[0] + parDCAxy[1] / std::pow(antihePt, parDCAxy[2]))); - passDCAzCutAntiHe = (std::abs(track.dcaZ()) <= dcaConfOptions.DCAzCustomCut); + passDCAzCutAntiHe = (std::abs(track.dcaZ()) <= dcaConfOptions.cfgCustomDCAz); break; case 3: - passDCAxyCut = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); + passDCAxyCut = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); passDCAzCut = (std::abs(track.dcaZ()) <= parDCAz[3] * (parDCAz[0] + parDCAz[1] / std::pow(track.pt(), parDCAz[2]))); - passDCAxyCutDe = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); + passDCAxyCutDe = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); passDCAzCutDe = (std::abs(track.dcaZ()) <= parDCAz[3] * (parDCAz[0] + parDCAz[1] / std::pow(DPt, parDCAz[2]))); - passDCAxyCutAntiDe = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); + passDCAxyCutAntiDe = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); passDCAzCutAntiDe = (std::abs(track.dcaZ()) <= parDCAz[3] * (parDCAz[0] + parDCAz[1] / std::pow(antiDPt, parDCAz[2]))); - passDCAxyCutHe = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); + passDCAxyCutHe = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); passDCAzCutHe = (std::abs(track.dcaZ()) <= parDCAz[3] * (parDCAz[0] + parDCAz[1] / std::pow(hePt, parDCAz[2]))); - passDCAxyCutAntiHe = (std::abs(track.dcaXY()) <= dcaConfOptions.DCAxyCustomCut); + passDCAxyCutAntiHe = (std::abs(track.dcaXY()) <= dcaConfOptions.cfgCustomDCAxy); passDCAzCutAntiHe = (std::abs(track.dcaZ()) <= parDCAz[3] * (parDCAz[0] + parDCAz[1] / std::pow(antihePt, parDCAz[2]))); break; case 4: - passDCAxyCut = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; - passDCAzCut = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; - - passDCAxyCutDe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; - passDCAzCutDe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; - passDCAxyCutAntiDe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; - passDCAzCutAntiDe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; - - passDCAxyCutHe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; - passDCAzCutHe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; - passDCAxyCutAntiHe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; - passDCAzCutAntiHe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.DCAxyCustomCut, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.DCAzCustomCut, 2) <= 1; + passDCAxyCut = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; + passDCAzCut = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; + + passDCAxyCutDe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; + passDCAzCutDe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; + passDCAxyCutAntiDe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; + passDCAzCutAntiDe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; + + passDCAxyCutHe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; + passDCAzCutHe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; + passDCAxyCutAntiHe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; + passDCAzCutAntiHe = std::pow(track.dcaXY(), 2) / std::pow(dcaConfOptions.cfgCustomDCAxy, 2) + std::pow(track.dcaZ(), 2) / std::pow(dcaConfOptions.cfgCustomDCAz, 2) <= 1; break; case 5: passDCAxyCut = std::pow(track.dcaXY(), 2) / std::pow(parDCAxy[3] * (parDCAxy[0] + parDCAxy[1] / std::pow(track.pt(), parDCAxy[2])), 2) + std::pow(track.dcaZ(), 2) / std::pow(parDCAz[3] * (parDCAz[0] + parDCAz[1] / std::pow(track.pt(), parDCAz[2])), 2) <= 1; @@ -2295,30 +2468,30 @@ struct LFNucleiBATask { break; } - // p cut - if (std::abs(track.tpcInnerParam()) < kinemOptions.pCut) - continue; - // Rapidity cuts - prRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Proton)) > kinemOptions.yLowCut && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Proton)) < kinemOptions.yHighCut; - deRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Deuteron)) > kinemOptions.yLowCut && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Deuteron)) < kinemOptions.yHighCut; - trRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Triton)) > kinemOptions.yLowCut && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Triton)) < kinemOptions.yHighCut; - heRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)) > kinemOptions.yLowCut && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)) < kinemOptions.yHighCut; - alRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Alpha)) > kinemOptions.yLowCut && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Alpha)) < kinemOptions.yHighCut; + prRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Proton)) > kinemOptions.cfgRapidityCutLow && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Proton)) < kinemOptions.cfgRapidityCutHigh; + deRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Deuteron)) > kinemOptions.cfgRapidityCutLow && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Deuteron)) < kinemOptions.cfgRapidityCutHigh; + trRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Triton)) > kinemOptions.cfgRapidityCutLow && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Triton)) < kinemOptions.cfgRapidityCutHigh; + heRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)) > kinemOptions.cfgRapidityCutLow && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)) < kinemOptions.cfgRapidityCutHigh; + alRapCut = track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Alpha)) > kinemOptions.cfgRapidityCutLow && track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Alpha)) < kinemOptions.cfgRapidityCutHigh; isDeuteron = enableDe && deRapCut; isHelium = enableHe && heRapCut; isDe = isDeuteron && track.sign() > 0; isAntiDe = isDeuteron && track.sign() < 0; - if (!nsigmaITSvar.useITSTrCut) { - isHe = isHelium && track.sign() > 0; - isAntiHe = isHelium && track.sign() < 0; - } else { - isHe = isHelium && track.sign() > 0 && std::abs(nITSTr) > nsigmaITSvar.nsigmaITSTr; - isAntiHe = isHelium && track.sign() < 0 && std::abs(nITSTr) > nsigmaITSvar.nsigmaITSTr; + // nSigmaITSHe cut + if (nsigmaITSvar.useITSDeCut && (nITSDe <= nsigmaITSvar.nsigmaITSDe)) { + continue; } + if (nsigmaITSvar.useITSHeCut && (nITSHe <= nsigmaITSvar.nsigmaITSHe)) { + continue; + } + + isHe = isHelium && track.sign() > 0; + isAntiHe = isHelium && track.sign() < 0; + isDeWoDCAxy = isDe && passDCAzCutDe; isAntiDeWoDCAxy = isAntiDe && passDCAzCutAntiDe; isHeWoDCAxy = isHe && passDCAzCutHe; @@ -2404,19 +2577,19 @@ struct LFNucleiBATask { if (isDeWoDCAzWTPCpid) { histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtDeuteron"), DPt, track.dcaZ()); - if (!track.hasTOF()) + if (!track.hasTOF() && (outFlagOptions.enableNoTOFPlots)) histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtDeuteronNoTOF"), DPt, track.dcaZ()); } if (isAntiDeWoDCAzWTPCpid) { histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteron"), antiDPt, track.dcaZ()); - if (!track.hasTOF()) + if (!track.hasTOF() && (outFlagOptions.enableNoTOFPlots)) histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronNoTOF"), antiDPt, track.dcaZ()); } if (isHeWoDCAzWTPCpid) { histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtHelium"), hePt, track.dcaZ()); - if (!track.hasTOF()) + if (!track.hasTOF() && (outFlagOptions.enableNoTOFPlots)) histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtHeliumNoTOF"), hePt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAzVsPtHelium"), hePt, track.dcaZ()); @@ -2425,7 +2598,7 @@ struct LFNucleiBATask { if (isAntiHeWoDCAzWTPCpid) { histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtantiHelium"), antihePt, track.dcaZ()); - if (!track.hasTOF()) + if (!track.hasTOF() && (outFlagOptions.enableNoTOFPlots)) histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtantiHeliumNoTOF"), hePt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAzVsPtantiHelium"), antihePt, track.dcaZ()); @@ -2471,14 +2644,16 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/proton/dca/before/hDCAzVsPtProtonTrueTransport"), track.pt(), track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/proton/dca/before/hDCAzVsPtProtonTrueSec"), track.pt(), track.dcaZ()); - } + else + histos.fill(HIST("tracks/proton/dca/before/hDCAzVsPtProtonTrueMaterial"), track.pt(), track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAzVsPtProtonTrueTransport"), track.pt(), track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAzVsPtProtonTrueSec"), track.pt(), track.dcaZ()); - } + else + histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAzVsPtProtonTrueMaterial"), track.pt(), track.dcaZ()); } } } @@ -2497,14 +2672,16 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/proton/dca/before/hDCAzVsPtantiProtonTrueTransport"), track.pt(), track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/proton/dca/before/hDCAzVsPtantiProtonTrueSec"), track.pt(), track.dcaZ()); - } + else + histos.fill(HIST("tracks/proton/dca/before/hDCAzVsPtantiProtonTrueMaterial"), track.pt(), track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAzVsPtantiProtonTrueTransport"), hePt, track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAzVsPtantiProtonTrueSec"), hePt, track.dcaZ()); - } + else + histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAzVsPtantiProtonTrueMaterial"), hePt, track.dcaZ()); } } } @@ -2523,14 +2700,16 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtDeuteronTrueTransport"), DPt, track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtDeuteronTrueSec"), DPt, track.dcaZ()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtDeuteronTrueMaterial"), DPt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAzVsPtDeuteronTrueTransport"), DPt, track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAzVsPtDeuteronTrueSec"), DPt, track.dcaZ()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAzVsPtDeuteronTrueMaterial"), DPt, track.dcaZ()); } } } @@ -2549,14 +2728,16 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronTrueTransport"), antiDPt, track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronTrueSec"), antiDPt, track.dcaZ()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/hDCAzVsPtantiDeuteronTrueMaterial"), antiDPt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAzVsPtantiDeuteronTrueTransport"), antiDPt, track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAzVsPtantiDeuteronTrueSec"), antiDPt, track.dcaZ()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAzVsPtantiDeuteronTrueMaterial"), antiDPt, track.dcaZ()); } } } @@ -2569,9 +2750,10 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/triton/dca/before/hDCAzVsPtTritonTrueTransport"), track.pt(), track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/triton/dca/before/hDCAzVsPtTritonTrueSec"), track.pt(), track.dcaZ()); - } + else + histos.fill(HIST("tracks/triton/dca/before/hDCAzVsPtTritonTrueMaterial"), track.pt(), track.dcaZ()); } } break; @@ -2583,9 +2765,10 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/triton/dca/before/hDCAzVsPtantiTritonTrueTransport"), track.pt(), track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/triton/dca/before/hDCAzVsPtantiTritonTrueSec"), track.pt(), track.dcaZ()); - } + else + histos.fill(HIST("tracks/triton/dca/before/hDCAzVsPtantiTritonTrueMaterial"), track.pt(), track.dcaZ()); } } break; @@ -2603,20 +2786,22 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtHeliumTrueTransport"), hePt, track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtHeliumTrueSec"), hePt, track.dcaZ()); - } + else + histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtHeliumTrueMaterial"), hePt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAzVsPtHeliumTrueTransport"), hePt, track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAzVsPtHeliumTrueSec"), hePt, track.dcaZ()); - } + else + histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAzVsPtHeliumTrueMaterial"), hePt, track.dcaZ()); } } } if constexpr (!IsFilteredData) { if ((event.has_mcCollision() && (track.mcParticle().mcCollisionId() != event.mcCollisionId())) || !event.has_mcCollision()) { - if (isHeWoDCAz) { + if (isHeWoDCAz && outFlagOptions.makeWrongEventPlots) { histos.fill(HIST("tracks/helium/dca/before/wrong/hDCAzVsPtHeliumTrue"), hePt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtHeliumTrue"), hePt, track.dcaZ()); @@ -2657,20 +2842,22 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtantiHeliumTrueTransport"), antihePt, track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtantiHeliumTrueSec"), antihePt, track.dcaZ()); - } + else + histos.fill(HIST("tracks/helium/dca/before/hDCAzVsPtantiHeliumTrueMaterial"), antihePt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAzVsPtantiHeliumTrueTransport"), antihePt, track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAzVsPtantiHeliumTrueSec"), antihePt, track.dcaZ()); - } + else + histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAzVsPtantiHeliumTrueMaterial"), antihePt, track.dcaZ()); } } } if constexpr (!IsFilteredData) { if ((event.has_mcCollision() && (track.mcParticle().mcCollisionId() != event.mcCollisionId())) || !event.has_mcCollision()) { - if (isAntiHeWoDCAz) { + if (isAntiHeWoDCAz && outFlagOptions.makeWrongEventPlots) { histos.fill(HIST("tracks/helium/dca/before/wrong/hDCAzVsPtantiHeliumTrue"), antihePt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/wrong/TOF/hDCAzVsPtantiHeliumTrue"), antihePt, track.dcaZ()); @@ -2706,9 +2893,10 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/alpha/dca/before/hDCAzVsPtAlphaTrueTransport"), track.pt(), track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/alpha/dca/before/hDCAzVsPtAlphaTrueSec"), track.pt(), track.dcaZ()); - } + else + histos.fill(HIST("tracks/alpha/dca/before/hDCAzVsPtAlphaTrueMaterial"), track.pt(), track.dcaZ()); } } break; @@ -2720,9 +2908,10 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/alpha/dca/before/hDCAzVsPtantiAlphaTrueTransport"), track.pt(), track.dcaZ()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/alpha/dca/before/hDCAzVsPtantiAlphaTrueSec"), track.pt(), track.dcaZ()); - } + else + histos.fill(HIST("tracks/alpha/dca/before/hDCAzVsPtantiAlphaTrueMaterial"), track.pt(), track.dcaZ()); } } break; @@ -2734,7 +2923,7 @@ struct LFNucleiBATask { // break; default: - if (isDeWoDCAzWTPCpid) { + if (isDeWoDCAzWTPCpid && outFlagOptions.makeFakeTracksPlots) { histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAzVsPtDeuteronTrue"), DPt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtDeuteronTrue"), DPt, track.dcaZ()); @@ -2757,7 +2946,7 @@ struct LFNucleiBATask { } } } - } else if (isAntiDeWoDCAzWTPCpid) { + } else if (isAntiDeWoDCAzWTPCpid && outFlagOptions.makeFakeTracksPlots) { histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAzVsPtantiDeuteronTrue"), antiDPt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/deuteron/dca/before/fake/TOF/hDCAzVsPtantiDeuteronTrue"), antiDPt, track.dcaZ()); @@ -2789,7 +2978,7 @@ struct LFNucleiBATask { // break; default: - if (isHeWoDCAzWTPCpid) { + if (isHeWoDCAzWTPCpid && outFlagOptions.makeFakeTracksPlots) { histos.fill(HIST("tracks/helium/dca/before/fake/hDCAzVsPtHeliumTrue"), hePt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/fake/TOF/hDCAzVsPtHeliumTrue"), hePt, track.dcaZ()); @@ -2813,7 +3002,7 @@ struct LFNucleiBATask { } } } - if (isAntiHeWoDCAzWTPCpid) { + if (isAntiHeWoDCAzWTPCpid && outFlagOptions.makeFakeTracksPlots) { histos.fill(HIST("tracks/helium/dca/before/fake/hDCAzVsPtantiHeliumTrue"), antihePt, track.dcaZ()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/fake/TOF/hDCAzVsPtantiHeliumTrue"), antihePt, track.dcaZ()); @@ -2878,29 +3067,29 @@ struct LFNucleiBATask { } if (isDeWoDCAxyWTPCpid) { - if (usenITSLayer && !itsClusterMap.test(nITSLayer)) + if (usenITSLayer && !itsClusterMap.test(trkqcOptions.nITSLayer)) continue; if (enableCentrality) histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronVsMult"), DPt, track.dcaXY(), event.centFT0M()); else histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtDeuteron"), DPt, track.dcaXY()); - if (!track.hasTOF()) + if (!track.hasTOF() && (outFlagOptions.enableNoTOFPlots)) histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronNoTOF"), DPt, track.dcaXY()); } if (isAntiDeWoDCAxyWTPCpid) { - if (usenITSLayer && !itsClusterMap.test(nITSLayer)) + if (usenITSLayer && !itsClusterMap.test(trkqcOptions.nITSLayer)) continue; if (enableCentrality) histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronVsMult"), antiDPt, track.dcaXY(), event.centFT0M()); else histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteron"), antiDPt, track.dcaXY()); - if (!track.hasTOF()) + if (!track.hasTOF() && (outFlagOptions.enableNoTOFPlots)) histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronNoTOF"), antiDPt, track.dcaXY()); } if (isHeWoDCAxyWTPCpid) { histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtHelium"), hePt, track.dcaXY()); - if (!track.hasTOF()) + if (!track.hasTOF() && (outFlagOptions.enableNoTOFPlots)) histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtHeliumNoTOF"), hePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAxyVsPtHelium"), hePt, track.dcaXY()); @@ -2908,7 +3097,7 @@ struct LFNucleiBATask { } if (isAntiHeWoDCAxyWTPCpid) { histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtantiHelium"), antihePt, track.dcaXY()); - if (!track.hasTOF()) + if (!track.hasTOF() && (outFlagOptions.enableNoTOFPlots)) histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtantiHeliumNoTOF"), antihePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAxyVsPtantiHelium"), antihePt, track.dcaXY()); @@ -2968,14 +3157,16 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/proton/dca/before/hDCAxyVsPtProtonTrueTransport"), track.pt(), track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/proton/dca/before/hDCAxyVsPtProtonTrueSec"), track.pt(), track.dcaXY()); - } + else + histos.fill(HIST("tracks/proton/dca/before/hDCAxyVsPtProtonTrueMaterial"), track.pt(), track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAxyVsPtProtonTrueTransport"), track.pt(), track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAxyVsPtProtonTrueSec"), track.pt(), track.dcaXY()); - } + else + histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAxyVsPtProtonTrueMaterial"), track.pt(), track.dcaXY()); } } } @@ -2994,14 +3185,16 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/proton/dca/before/hDCAxyVsPtantiProtonTrueTransport"), track.pt(), track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/proton/dca/before/hDCAxyVsPtantiProtonTrueSec"), track.pt(), track.dcaXY()); - } + else + histos.fill(HIST("tracks/proton/dca/before/hDCAxyVsPtantiProtonTrueMaterial"), track.pt(), track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAxyVsPtantiProtonTrueTransport"), track.pt(), track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAxyVsPtantiProtonTrueSec"), track.pt(), track.dcaXY()); - } + else + histos.fill(HIST("tracks/proton/dca/before/TOF/hDCAxyVsPtantiProtonTrueMaterial"), track.pt(), track.dcaXY()); } } } @@ -3040,16 +3233,16 @@ struct LFNucleiBATask { if (!isPhysPrim && !isProdByGen) { if (outFlagOptions.makeDCABeforeCutPlots) { histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronTrueTransport"), DPt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronTrueSec"), DPt, track.dcaXY()); - } else { - // LOG(info) << " PID: "<< pdgCode << " Prod. by Gen: "<< isProdByGen << " Process: " << track.mcParticle().getProcess() << " HasMothers: " << track.mcParticle().has_mothers() << " and MomIs: "<< mother.pdgCode(); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtDeuteronTrueMaterial"), DPt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAxyVsPtDeuteronTrueTransport"), DPt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAxyVsPtDeuteronTrueSec"), DPt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAxyVsPtDeuteronTrueMaterial"), DPt, track.dcaXY()); } } } @@ -3089,14 +3282,16 @@ struct LFNucleiBATask { if (!isPhysPrim && !isProdByGen) { if (outFlagOptions.makeDCABeforeCutPlots) { histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronTrueTransport"), antiDPt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronTrueSec"), antiDPt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/hDCAxyVsPtantiDeuteronTrueMaterial"), antiDPt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAxyVsPtantiDeuteronTrueTransport"), antiDPt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAxyVsPtantiDeuteronTrueSec"), antiDPt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/TOF/hDCAxyVsPtantiDeuteronTrueMaterial"), antiDPt, track.dcaXY()); } } } @@ -3124,6 +3319,11 @@ struct LFNucleiBATask { if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/triton/dca/before/TOF/hDCAxyVsPtTritonTrueSec"), track.pt(), track.dcaXY()); } + } else { + histos.fill(HIST("tracks/triton/dca/before/hDCAxyVsPtTritonTrueMaterial"), track.pt(), track.dcaXY()); + if (track.hasTOF() && outFlagOptions.doTOFplots) { + histos.fill(HIST("tracks/triton/dca/before/TOF/hDCAxyVsPtTritonTrueMaterial"), track.pt(), track.dcaXY()); + } } } } @@ -3154,6 +3354,11 @@ struct LFNucleiBATask { if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/triton/dca/before/TOF/hDCAxyVsPtantiTritonTrueSec"), track.pt(), track.dcaXY()); } + } else { + histos.fill(HIST("tracks/triton/dca/before/hDCAxyVsPtantiTritonTrueMaterial"), track.pt(), track.dcaXY()); + if (track.hasTOF() && outFlagOptions.doTOFplots) { + histos.fill(HIST("tracks/triton/dca/before/TOF/hDCAxyVsPtantiTritonTrueMaterial"), track.pt(), track.dcaXY()); + } } } } @@ -3187,20 +3392,22 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen && outFlagOptions.makeDCABeforeCutPlots) { histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtHeliumTrueTransport"), hePt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtHeliumTrueSec"), hePt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtHeliumTrueMaterial"), hePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAxyVsPtHeliumTrueTransport"), hePt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAxyVsPtHeliumTrueSec"), hePt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAxyVsPtHeliumTrueMaterial"), hePt, track.dcaXY()); } } } if constexpr (!IsFilteredData) { if ((event.has_mcCollision() && (track.mcParticle().mcCollisionId() != event.mcCollisionId())) || !event.has_mcCollision()) { - if (isHeWoDCAxy && outFlagOptions.makeDCABeforeCutPlots) { + if (isHeWoDCAxy && outFlagOptions.makeDCABeforeCutPlots && outFlagOptions.makeWrongEventPlots) { histos.fill(HIST("tracks/helium/dca/before/wrong/hDCAxyVsPtHeliumTrue"), hePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtHeliumTrue"), hePt, track.dcaXY()); @@ -3256,21 +3463,23 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen && outFlagOptions.makeDCABeforeCutPlots) { histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtantiHeliumTrueTransport"), antihePt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtantiHeliumTrueSec"), antihePt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/helium/dca/before/hDCAxyVsPtantiHeliumTrueMaterial"), antihePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAxyVsPtantiHeliumTrueTransport"), antihePt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAxyVsPtantiHeliumTrueSec"), antihePt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/helium/dca/before/TOF/hDCAxyVsPtantiHeliumTrueMaterial"), antihePt, track.dcaXY()); } } } if constexpr (!IsFilteredData) { if ((event.has_mcCollision() && (track.mcParticle().mcCollisionId() != event.mcCollisionId())) || !event.has_mcCollision()) { - if (isAntiHeWoDCAxy && outFlagOptions.makeDCABeforeCutPlots) { + if (isAntiHeWoDCAxy && outFlagOptions.makeDCABeforeCutPlots && outFlagOptions.makeWrongEventPlots) { histos.fill(HIST("tracks/helium/dca/before/wrong/hDCAxyVsPtantiHeliumTrue"), antihePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/wrong/TOF/hDCAxyVsPtantiHeliumTrue"), antihePt, track.dcaXY()); @@ -3305,9 +3514,10 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/alpha/dca/before/hDCAxyVsPtAlphaTrueTransport"), track.pt(), track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/alpha/dca/before/hDCAxyVsPtAlphaTrueSec"), track.pt(), track.dcaXY()); - } + else + histos.fill(HIST("tracks/alpha/dca/before/hDCAxyVsPtAlphaTrueMaterial"), track.pt(), track.dcaXY()); } } break; @@ -3319,9 +3529,10 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/alpha/dca/before/hDCAxyVsPtantiAlphaTrueTransport"), track.pt(), track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/alpha/dca/before/hDCAxyVsPtantiAlphaTrueSec"), track.pt(), track.dcaXY()); - } + else + histos.fill(HIST("tracks/alpha/dca/before/hDCAxyVsPtantiAlphaTrueMaterial"), track.pt(), track.dcaXY()); } } break; @@ -3333,7 +3544,7 @@ struct LFNucleiBATask { // break; default: - if (isDeWoDCAxyWTPCpid) { + if (isDeWoDCAxyWTPCpid && outFlagOptions.makeFakeTracksPlots) { if (outFlagOptions.makeDCABeforeCutPlots) { histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrue"), DPt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { @@ -3353,16 +3564,19 @@ struct LFNucleiBATask { histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrueTransport"), DPt, track.dcaXY()); if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrueSec"), DPt, track.dcaXY()); + else + histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAxyVsPtDeuteronTrueMaterial"), DPt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrueTransport"), DPt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrueSec"), DPt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtDeuteronTrueMaterial"), DPt, track.dcaXY()); } } } } - if (isAntiDeWoDCAxyWTPCpid) { + if (isAntiDeWoDCAxyWTPCpid && outFlagOptions.makeFakeTracksPlots) { if (outFlagOptions.makeDCABeforeCutPlots) { histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrue"), antiDPt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { @@ -3380,14 +3594,16 @@ struct LFNucleiBATask { if (!isPhysPrim && !isProdByGen) { if (outFlagOptions.makeDCABeforeCutPlots) { histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrueTransport"), antiDPt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrueSec"), antiDPt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/fake/hDCAxyVsPtantiDeuteronTrueMaterial"), antiDPt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrueTransport"), antiDPt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrueSec"), antiDPt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/deuteron/dca/before/fake/TOF/hDCAxyVsPtantiDeuteronTrueMaterial"), antiDPt, track.dcaXY()); } } } @@ -3400,7 +3616,7 @@ struct LFNucleiBATask { // break; default: - if (isHeWoDCAxyWTPCpid) { + if (isHeWoDCAxyWTPCpid && outFlagOptions.makeFakeTracksPlots) { if (outFlagOptions.makeDCABeforeCutPlots) { histos.fill(HIST("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrue"), hePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { @@ -3414,19 +3630,21 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrueTransport"), hePt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrueSec"), hePt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/helium/dca/before/fake/hDCAxyVsPtHeliumTrueMaterial"), hePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTrueTransport"), hePt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTrueSec"), hePt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtHeliumTrueMaterial"), hePt, track.dcaXY()); } } } } - if (isAntiHeWoDCAxyWTPCpid) { + if (isAntiHeWoDCAxyWTPCpid && outFlagOptions.makeFakeTracksPlots) { if (outFlagOptions.makeDCABeforeCutPlots) { histos.fill(HIST("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrue"), antihePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { @@ -3440,14 +3658,16 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { histos.fill(HIST("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrueTransport"), antihePt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrueSec"), antihePt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/helium/dca/before/fake/hDCAxyVsPtantiHeliumTrueMaterial"), antihePt, track.dcaXY()); if (track.hasTOF() && outFlagOptions.doTOFplots) { histos.fill(HIST("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTrueTransport"), antihePt, track.dcaXY()); - if (isWeakDecay) { + if (isWeakDecay) histos.fill(HIST("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTrueSec"), antihePt, track.dcaXY()); - } + else + histos.fill(HIST("tracks/helium/dca/before/fake/TOF/hDCAxyVsPtantiHeliumTrueMaterial"), antihePt, track.dcaXY()); } } } @@ -3458,12 +3678,14 @@ struct LFNucleiBATask { // DCA Cut if constexpr (!IsFilteredData) { - if (!enableDCACustomCut) { - if (!track.isGlobalTrack()) - continue; - } else { - if (!track.isGlobalTrackWoDCA()) - continue; + if (filterOptions.enableIsGlobalTrack) { + if (!enableCustomDCACut) { + if (!track.isGlobalTrack()) + continue; + } else { + if (!track.isGlobalTrackWoDCA()) + continue; + } } } @@ -3527,13 +3749,13 @@ struct LFNucleiBATask { } } if (isDeWTPCpid) { - if (usenITSLayer && !itsClusterMap.test(nITSLayer)) + if (usenITSLayer && !itsClusterMap.test(trkqcOptions.nITSLayer)) continue; histos.fill(HIST("tracks/deuteron/dca/after/hDCAxyVsPtDeuteron"), DPt, track.dcaXY()); histos.fill(HIST("tracks/deuteron/dca/after/hDCAzVsPtDeuteron"), DPt, track.dcaZ()); } if (isAntiDeWTPCpid) { - if (usenITSLayer && !itsClusterMap.test(nITSLayer)) + if (usenITSLayer && !itsClusterMap.test(trkqcOptions.nITSLayer)) continue; histos.fill(HIST("tracks/deuteron/dca/after/hDCAxyVsPtantiDeuteron"), antiDPt, track.dcaXY()); histos.fill(HIST("tracks/deuteron/dca/after/hDCAzVsPtantiDeuteron"), antiDPt, track.dcaZ()); @@ -3575,6 +3797,7 @@ struct LFNucleiBATask { debugHistos.fill(HIST("debug/tracks/h1Eta"), track.eta()); debugHistos.fill(HIST("debug/tracks/h1VarPhi"), track.phi()); debugHistos.fill(HIST("debug/tracks/h2EtaVsPhi"), track.eta(), track.phi()); + debugHistos.fill(HIST("debug/tracks/h2PionYvsPt"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Pion)), track.pt()); if (track.sign() > 0) { debugHistos.fill(HIST("debug/qa/h2TPCncrVsPtPos"), track.tpcInnerParam(), track.tpcNClsCrossedRows()); @@ -3608,15 +3831,23 @@ struct LFNucleiBATask { debugHistos.fill(HIST("debug/tracks/kaon/h2KaonVspTNSigmaTPC"), track.pt(), track.tpcNSigmaKa()); } - if (enablePtSpectra) + if (outFlagOptions.enableEffPlots) histos.fill(HIST("tracks/eff/h2pVsTPCmomentum"), track.tpcInnerParam(), track.p()); - if (enableFiltering) { + if (filterOptions.enableFiltering) { if (track.tpcNSigmaKa() < 5) continue; } - histos.fill(HIST("tracks/h2TPCsignVsTPCmomentum"), track.tpcInnerParam() / (1.f * track.sign()), track.tpcSignal()); + if (outFlagOptions.enablePIDplot) + histos.fill(HIST("tracks/h2TPCsignVsTPCmomentum"), track.tpcInnerParam() / (1.f * track.sign()), track.tpcSignal()); + + if constexpr (!IsFilteredData) { + if (nsigmaITSvar.showAverageClusterSize && outFlagOptions.enablePIDplot) { + histos.fill(HIST("tracks/averageClusterSize"), track.p(), averageClusterSizeTrk(track)); + histos.fill(HIST("tracks/averageClusterSizePerCoslInv"), track.p(), averageClusterSizePerCoslInv(track)); + } + } if (track.sign() > 0) { if (enablePr && prRapCut) { @@ -3701,7 +3932,7 @@ struct LFNucleiBATask { histos.fill(HIST("tracks/proton/h2ProtonTOFExpSignalDiffVsPt"), track.pt(), track.tofExpSignalDiffPr()); } - if (enableEvTimeSplitting && track.hasTOF()) { + if (filterOptions.enableEvTimeSplitting && track.hasTOF()) { if (track.isEvTimeTOF() && track.isEvTimeT0AC()) { if (enablePr) evtimeHistos.fill(HIST("tracks/evtime/ft0tof/proton/h2ProtonVspTNSigmaTOF"), track.pt(), track.tofNSigmaPr()); @@ -3717,7 +3948,7 @@ struct LFNucleiBATask { evtimeHistos.fill(HIST("tracks/evtime/ft0tof/proton/h3ProtonNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); if (enableDe) evtimeHistos.fill(HIST("tracks/evtime/ft0tof/deuteron/h3DeuteronNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaDe(), track.tofNSigmaDe(), DPt); - if (enableDebug && (track.beta() > betaCut)) { + if (enableDebug && (track.beta() > cfgBetaCut)) { if (enablePr) debugHistos.fill(HIST("debug/evtime/ft0tof/proton/h2ProtonVspTNSigmaTPC_BetaCut"), track.pt(), track.tpcNSigmaPr()); if (enableDe) @@ -3749,7 +3980,7 @@ struct LFNucleiBATask { evtimeHistos.fill(HIST("tracks/evtime/ft0/proton/h3ProtonNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); if (enableDe) evtimeHistos.fill(HIST("tracks/evtime/ft0/deuteron/h3DeuteronNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaDe(), track.tofNSigmaDe(), DPt); - if (enableDebug && (track.beta() > betaCut)) { + if (enableDebug && (track.beta() > cfgBetaCut)) { if (enablePr) debugHistos.fill(HIST("debug/evtime/ft0/proton/h2ProtonVspTNSigmaTPC_BetaCut"), track.pt(), track.tpcNSigmaPr()); if (enableDe) @@ -3781,7 +4012,7 @@ struct LFNucleiBATask { evtimeHistos.fill(HIST("tracks/evtime/tof/proton/h3ProtonNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); if (enableDe) evtimeHistos.fill(HIST("tracks/evtime/tof/deuteron/h3DeuteronNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaDe(), track.tofNSigmaDe(), DPt); - if (enableDebug && (track.beta() > betaCut)) { + if (enableDebug && (track.beta() > cfgBetaCut)) { if (enablePr) debugHistos.fill(HIST("debug/evtime/tof/proton/h2ProtonVspTNSigmaTPC_BetaCut"), track.pt(), track.tpcNSigmaPr()); if (enableDe) @@ -3815,7 +4046,7 @@ struct LFNucleiBATask { evtimeHistos.fill(HIST("tracks/evtime/fill/proton/h3ProtonNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); if (enableDe) evtimeHistos.fill(HIST("tracks/evtime/fill/deuteron/h3DeuteronNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaDe(), track.tofNSigmaDe(), DPt); - if (enableDebug && (track.beta() > betaCut)) { + if (enableDebug && (track.beta() > cfgBetaCut)) { if (enablePr) debugHistos.fill(HIST("debug/evtime/fill/proton/h2ProtonVspTNSigmaTPC_BetaCut"), track.pt(), track.tpcNSigmaPr()); if (enableDe) @@ -3855,7 +4086,7 @@ struct LFNucleiBATask { if (outFlagOptions.enableExpSignalTOF) histos.fill(HIST("tracks/proton/h2antiProtonTOFExpSignalDiffVsPt"), track.pt(), track.tofExpSignalDiffPr()); } - if (enableEvTimeSplitting && track.hasTOF()) { + if (filterOptions.enableEvTimeSplitting && track.hasTOF()) { if (track.isEvTimeTOF() && track.isEvTimeT0AC()) { if (enablePr) evtimeHistos.fill(HIST("tracks/evtime/ft0tof/proton/h2antiProtonVspTNSigmaTOF"), track.pt(), track.tofNSigmaPr()); @@ -3871,7 +4102,7 @@ struct LFNucleiBATask { evtimeHistos.fill(HIST("tracks/evtime/ft0tof/proton/h3antiProtonNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); if (enableDe) evtimeHistos.fill(HIST("tracks/evtime/ft0tof/deuteron/h3antiDeuteronNSigmaTPCvsNSigmaTOFvsPt"), track.tpcNSigmaDe(), track.tofNSigmaDe(), antiDPt); - if (enableDebug && (track.beta() > betaCut)) { + if (enableDebug && (track.beta() > cfgBetaCut)) { if (enablePr) debugHistos.fill(HIST("debug/evtime/ft0tof/proton/h2antiProtonVspTNSigmaTPC_BetaCut"), track.pt(), track.tpcNSigmaPr()); if (enableDe) @@ -3987,6 +4218,8 @@ struct LFNucleiBATask { if (outFlagOptions.enableExpSignalTPC) histos.fill(HIST("tracks/deuteron/h2DeuteronTPCExpSignalDiffVsPt"), DPt, track.tpcExpSignalDiffDe()); + histos.fill(HIST("tracks/deuteron/h2DeuteronVspNSigmaITSDe"), track.p(), nITSDe); + switch (useHasTRDConfig) { case 0: if (enableCentrality) @@ -4010,6 +4243,8 @@ struct LFNucleiBATask { if (outFlagOptions.enableExpSignalTPC) histos.fill(HIST("tracks/deuteron/h2antiDeuteronTPCExpSignalDiffVsPt"), antiDPt, track.tpcExpSignalDiffDe()); + histos.fill(HIST("tracks/deuteron/h2antiDeuteronVspNSigmaITSDe"), track.p(), nITSDe); + switch (useHasTRDConfig) { case 0: if (enableCentrality) @@ -4033,15 +4268,33 @@ struct LFNucleiBATask { if (isHeWoTPCpid) { if (outFlagOptions.enableExpSignalTPC) histos.fill(HIST("tracks/helium/h2HeliumTPCExpSignalDiffVsPt"), hePt, track.tpcExpSignalDiffHe()); - histos.fill(HIST("tracks/helium/h2HeliumVspTNSigmaITS"), hePt, nITSHe); + histos.fill(HIST("tracks/helium/h2HeliumVspTNSigmaITSTr"), track.p(), nITSTr); + histos.fill(HIST("tracks/helium/h2HeliumVspTNSigmaITSHe"), track.p(), nITSHe); histos.fill(HIST("tracks/helium/h2HeliumVspTNSigmaTPC"), hePt, track.tpcNSigmaHe()); } if (isAntiHeWoTPCpid) { if (outFlagOptions.enableExpSignalTPC) histos.fill(HIST("tracks/helium/h2antiHeliumTPCExpSignalDiffVsPt"), antihePt, track.tpcExpSignalDiffHe()); - histos.fill(HIST("tracks/helium/h2antiHeliumVspTNSigmaITS"), antihePt, nITSHe); + histos.fill(HIST("tracks/helium/h2antiHeliumVspTNSigmaITSTr"), track.p(), nITSTr); + histos.fill(HIST("tracks/helium/h2antiHeliumVspTNSigmaITSHe"), track.p(), nITSHe); histos.fill(HIST("tracks/helium/h2antiHeliumVspTNSigmaTPC"), antihePt, track.tpcNSigmaHe()); } + if (isHeWTPCpid) { + histos.fill(HIST("tracks/helium/h2HeliumVspTNSigmaITSTr_wTPCpid"), track.p(), nITSTr); + histos.fill(HIST("tracks/helium/h2HeliumVspTNSigmaITSHe_wTPCpid"), track.p(), nITSHe); + } + if (isAntiHeWTPCpid) { + histos.fill(HIST("tracks/helium/h2antiHeliumVspTNSigmaITSTr_wTPCpid"), track.p(), nITSTr); + histos.fill(HIST("tracks/helium/h2antiHeliumVspTNSigmaITSHe_wTPCpid"), track.p(), nITSHe); + } + if constexpr (!IsFilteredData) { + if (isHeWTPCpid || isAntiHeWTPCpid) { + if (nsigmaITSvar.showAverageClusterSize) { + histos.fill(HIST("tracks/helium/averageClusterSize"), track.p(), averageClusterSizeTrk(track)); + histos.fill(HIST("tracks/helium/averageClusterSizePerCoslInv"), track.p(), averageClusterSizePerCoslInv(track)); + } + } + } // TOF if (outFlagOptions.doTOFplots) { @@ -4101,7 +4354,7 @@ struct LFNucleiBATask { if (passDCAxyzCut) { // PID - if (enablePtSpectra && enableDebug) { + if (outFlagOptions.enableEffPlots && enableDebug) { if (track.sign() > 0) { debugHistos.fill(HIST("tracks/eff/hPtP"), track.pt()); debugHistos.fill(HIST("tracks/eff/hPtPrebinned"), track.pt()); @@ -4114,7 +4367,7 @@ struct LFNucleiBATask { if (enablePr) { if (std::abs(track.tpcNSigmaPr()) < nsigmaTPCvar.nsigmaTPCPr && prRapCut) { if (track.sign() > 0) { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/proton/hPtPr"), track.pt()); histos.fill(HIST("tracks/eff/proton/hPtPrrebinned"), track.pt()); histos.fill(HIST("tracks/eff/proton/h2pVsTPCmomentumPr"), track.tpcInnerParam(), track.p()); @@ -4123,10 +4376,10 @@ struct LFNucleiBATask { histos.fill(HIST("tracks/proton/h2ProtonYvsPt"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Proton)), track.pt()); histos.fill(HIST("tracks/proton/h2ProtonEtavsPt"), track.eta(), track.pt()); - if (enablePIDplot) + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/proton/h2TPCsignVsTPCmomentumProton"), track.tpcInnerParam(), track.tpcSignal()); } else { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/proton/hPtantiPr"), track.pt()); histos.fill(HIST("tracks/eff/proton/hPtantiPrrebinned"), track.pt()); histos.fill(HIST("tracks/eff/proton/h2pVsTPCmomentumantiPr"), track.tpcInnerParam(), track.p()); @@ -4135,7 +4388,7 @@ struct LFNucleiBATask { histos.fill(HIST("tracks/proton/h2antiProtonYvsPt"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Proton)), track.pt()); histos.fill(HIST("tracks/proton/h2antiProtonEtavsPt"), track.eta(), track.pt()); - if (enablePIDplot) + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/proton/h2TPCsignVsTPCmomentumantiProton"), track.tpcInnerParam(), track.tpcSignal()); } } @@ -4143,20 +4396,20 @@ struct LFNucleiBATask { if (enableTr) { if ((isTritonTPCpid) && trRapCut) { if (track.sign() > 0) { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/triton/hPtTr"), track.pt()); histos.fill(HIST("tracks/eff/triton/h2pVsTPCmomentumTr"), track.tpcInnerParam(), track.p()); } histos.fill(HIST("tracks/triton/h1TritonSpectra"), track.pt()); - if (enablePIDplot) + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/triton/h2TPCsignVsTPCmomentumTriton"), track.tpcInnerParam(), track.tpcSignal()); } else { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/triton/hPtantiTr"), track.pt()); histos.fill(HIST("tracks/eff/triton/h2pVsTPCmomentumantiTr"), track.tpcInnerParam(), track.p()); } histos.fill(HIST("tracks/triton/h1antiTritonSpectra"), track.pt()); - if (enablePIDplot) + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/triton/h2TPCsignVsTPCmomentumantiTriton"), track.tpcInnerParam(), track.tpcSignal()); } } @@ -4165,18 +4418,18 @@ struct LFNucleiBATask { if ((std::abs(track.tpcNSigmaAl()) < nsigmaTPCvar.nsigmaTPCAl) && alRapCut) { if (track.sign() > 0) { histos.fill(HIST("tracks/alpha/h1AlphaSpectra"), track.pt()); - if (enablePIDplot) + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/alpha/h2TPCsignVsTPCmomentumAlpha"), track.tpcInnerParam(), track.tpcSignal()); } else { histos.fill(HIST("tracks/alpha/h1antiAlphaSpectra"), track.pt()); - if (enablePIDplot) + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/alpha/h2TPCsignVsTPCmomentumantiAlpha"), track.tpcInnerParam(), track.tpcSignal()); } } } if (outFlagOptions.doTOFplots && track.hasTOF()) { - if (enablePtSpectra && enableDebug) { + if (outFlagOptions.enableEffPlots && enableDebug) { if (track.sign() > 0) { debugHistos.fill(HIST("tracks/eff/hPtPTOF"), track.pt()); debugHistos.fill(HIST("tracks/eff/hPtPTOFrebinned"), track.pt()); @@ -4186,38 +4439,40 @@ struct LFNucleiBATask { } } - if (outFlagOptions.enableBetaCut && (track.beta() > betaCut)) + if (outFlagOptions.enableBetaCut && (track.beta() > cfgBetaCut) && outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/h2TOFbetaVsP_BetaCut"), track.p() / (1.f * track.sign()), track.beta()); - switch (useHasTRDConfig) { - case 0: - histos.fill(HIST("tracks/h2TOFbetaVsP"), track.p() / (1.f * track.sign()), track.beta()); - break; - case 1: - if (track.hasTRD()) { - histos.fill(HIST("tracks/h2TOFbetaVsP"), track.p() / (1.f * track.sign()), track.beta()); - } - break; - case 2: - if (!track.hasTRD()) { + if (outFlagOptions.enablePIDplot) { + switch (useHasTRDConfig) { + case 0: histos.fill(HIST("tracks/h2TOFbetaVsP"), track.p() / (1.f * track.sign()), track.beta()); - } - break; + break; + case 1: + if (track.hasTRD()) { + histos.fill(HIST("tracks/h2TOFbetaVsP"), track.p() / (1.f * track.sign()), track.beta()); + } + break; + case 2: + if (!track.hasTRD()) { + histos.fill(HIST("tracks/h2TOFbetaVsP"), track.p() / (1.f * track.sign()), track.beta()); + } + break; + } } - if (enablePtSpectra) + if (outFlagOptions.enableEffPlots) histos.fill(HIST("tracks/eff/h2TPCmomentumVsTOFExpMomentum"), track.tofExpMom(), track.tpcInnerParam()); if (enablePr && prRapCut) { if (std::abs(track.tpcNSigmaPr()) < nsigmaTPCvar.nsigmaTPCPr && track.sign() > 0) { histos.fill(HIST("tracks/proton/h2ProtonTOFbetaVsP"), track.p(), track.beta()); - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/proton/h2pVsTOFExpMomentumPr"), track.tofExpMom(), track.p()); histos.fill(HIST("tracks/eff/proton/h2TPCmomentumVsTOFExpMomentumPr"), track.tofExpMom(), track.tpcInnerParam()); } } if (std::abs(track.tpcNSigmaPr()) < nsigmaTPCvar.nsigmaTPCPr && track.sign() < 0) { histos.fill(HIST("tracks/proton/h2antiProtonTOFbetaVsP"), track.p(), track.beta()); - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/proton/h2pVsTOFExpMomentumantiPr"), track.tofExpMom(), track.p()); histos.fill(HIST("tracks/eff/proton/h2TPCmomentumVsTOFExpMomentumantiPr"), track.tofExpMom(), track.tpcInnerParam()); } @@ -4226,20 +4481,20 @@ struct LFNucleiBATask { if (enableTr && trRapCut) { if (isTritonTPCpid && track.sign() > 0) { histos.fill(HIST("tracks/triton/h2TritonTOFbetaVsP"), track.p(), track.beta()); - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/triton/h2pVsTOFExpMomentumTr"), track.tofExpMom(), track.p()); histos.fill(HIST("tracks/eff/triton/h2TPCmomentumVsTOFExpMomentumTr"), track.tofExpMom(), track.tpcInnerParam()); } } if (isTritonTPCpid && track.sign() < 0) { histos.fill(HIST("tracks/triton/h2antiTritonTOFbetaVsP"), track.p(), track.beta()); - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/triton/h2pVsTOFExpMomentumantiTr"), track.tofExpMom(), track.p()); histos.fill(HIST("tracks/eff/triton/h2TPCmomentumVsTOFExpMomentumantiTr"), track.tofExpMom(), track.tpcInnerParam()); } } } - if (enableEvTimeSplitting) { + if (filterOptions.enableEvTimeSplitting) { if (track.isEvTimeTOF() && track.isEvTimeT0AC()) { evtimeHistos.fill(HIST("tracks/evtime/ft0tof/h2TOFbetaVsP"), track.p() / (1.f * track.sign()), track.beta()); evtimeHistos.fill(HIST("tracks/evtime/ft0tof/h2TPCsignVsTPCmomentum"), track.tpcInnerParam() / (1.f * track.sign()), track.tpcSignal()); @@ -4258,65 +4513,71 @@ struct LFNucleiBATask { } if (isDeWTPCpid) { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/deuteron/hPtDe"), DPt); histos.fill(HIST("tracks/eff/deuteron/h2pVsTPCmomentumDe"), track.tpcInnerParam(), track.p()); } histos.fill(HIST("tracks/deuteron/h1DeuteronSpectra"), DPt); histos.fill(HIST("tracks/deuteron/h2DeuteronYvsPt"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Deuteron)), DPt); - if (enablePIDplot) + histos.fill(HIST("tracks/deuteron/h2DeuteronEtavsPt"), track.eta(), DPt); + histos.fill(HIST("tracks/deuteron/h2DeuteronVspNSigmaITSDe_wTPCpid"), track.p(), nITSDe); + + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/deuteron/h2TPCsignVsTPCmomentumDeuteron"), track.tpcInnerParam(), track.tpcSignal()); } if (isAntiDeWTPCpid) { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/deuteron/hPtantiDe"), antiDPt); histos.fill(HIST("tracks/eff/deuteron/h2pVsTPCmomentumantiDe"), track.tpcInnerParam(), track.p()); } histos.fill(HIST("tracks/deuteron/h1antiDeuteronSpectra"), antiDPt); histos.fill(HIST("tracks/deuteron/h2antiDeuteronYvsPt"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Deuteron)), antiDPt); - if (enablePIDplot) + histos.fill(HIST("tracks/deuteron/h2antiDeuteronEtavsPt"), track.eta(), antiDPt); + histos.fill(HIST("tracks/deuteron/h2antiDeuteronVspNSigmaITSDe_wTPCpid"), track.p(), nITSDe); + + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/deuteron/h2TPCsignVsTPCmomentumantiDeuteron"), track.tpcInnerParam(), track.tpcSignal()); } if (isHeWTPCpid) { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/helium/hPtHe"), 2 * hePt); histos.fill(HIST("tracks/eff/helium/h2pVsTPCmomentumHe"), heTPCmomentum, heP); } - histos.fill(HIST("tracks/helium/h1HeliumSpectra"), hePt); + // histos.fill(HIST("tracks/helium/h1HeliumSpectra"), hePt); histos.fill(HIST("tracks/helium/h1HeliumSpectra_Z2"), 2 * hePt); - histos.fill(HIST("tracks/helium/h2HeliumYvsPt"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)), hePt); + // histos.fill(HIST("tracks/helium/h2HeliumYvsPt"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)), hePt); histos.fill(HIST("tracks/helium/h2HeliumYvsPt_Z2"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)), 2 * hePt); - histos.fill(HIST("tracks/helium/h2HeliumEtavsPt"), track.eta(), hePt); + // histos.fill(HIST("tracks/helium/h2HeliumEtavsPt"), track.eta(), hePt); histos.fill(HIST("tracks/helium/h2HeliumEtavsPt_Z2"), track.eta(), 2 * hePt); - if (enablePIDplot) + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/helium/h2TPCsignVsTPCmomentumHelium"), heTPCmomentum, track.tpcSignal()); } if (isAntiHeWTPCpid) { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/helium/hPtantiHe"), 2 * antihePt); histos.fill(HIST("tracks/eff/helium/h2pVsTPCmomentumantiHe"), antiheTPCmomentum, antiheP); } - histos.fill(HIST("tracks/helium/h1antiHeliumSpectra"), antihePt); + // histos.fill(HIST("tracks/helium/h1antiHeliumSpectra"), antihePt); histos.fill(HIST("tracks/helium/h1antiHeliumSpectra_Z2"), 2 * antihePt); - histos.fill(HIST("tracks/helium/h2antiHeliumYvsPt"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)), antihePt); + // histos.fill(HIST("tracks/helium/h2antiHeliumYvsPt"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)), antihePt); histos.fill(HIST("tracks/helium/h2antiHeliumYvsPt_Z2"), track.rapidity(o2::track::PID::getMass2Z(o2::track::PID::Helium3)), 2 * antihePt); - histos.fill(HIST("tracks/helium/h2antiHeliumEtavsPt"), track.eta(), antihePt); + // histos.fill(HIST("tracks/helium/h2antiHeliumEtavsPt"), track.eta(), antihePt); histos.fill(HIST("tracks/helium/h2antiHeliumEtavsPt_Z2"), track.eta(), 2 * antihePt); - if (enablePIDplot) + if (outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/helium/h2TPCsignVsTPCmomentumantiHelium"), antiheTPCmomentum, track.tpcSignal()); } if (outFlagOptions.doTOFplots && track.hasTOF()) { if (isDeWTPCpid) { histos.fill(HIST("tracks/deuteron/h2DeuteronTOFbetaVsP"), track.p(), track.beta()); - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/deuteron/h2pVsTOFExpMomentumDe"), track.tofExpMom(), track.p()); histos.fill(HIST("tracks/eff/deuteron/h2TPCmomentumVsTOFExpMomentumDe"), track.tofExpMom(), track.tpcInnerParam()); } } if (isAntiDeWTPCpid) { histos.fill(HIST("tracks/deuteron/h2antiDeuteronTOFbetaVsP"), track.p(), track.beta()); - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/deuteron/h2pVsTOFExpMomentumantiDe"), track.tofExpMom(), track.p()); histos.fill(HIST("tracks/eff/deuteron/h2TPCmomentumVsTOFExpMomentumantiDe"), track.tofExpMom(), track.tpcInnerParam()); } @@ -4324,7 +4585,7 @@ struct LFNucleiBATask { if (isHeWTPCpid) { histos.fill(HIST("tracks/helium/h2HeliumTOFbetaVsP"), heP, track.beta()); - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/helium/h2pVsTOFExpMomentumHe"), track.tofExpMom(), heP); histos.fill(HIST("tracks/eff/helium/h2TPCmomentumVsTOFExpMomentumHe"), track.tofExpMom(), heTPCmomentum); } @@ -4332,7 +4593,7 @@ struct LFNucleiBATask { if (isAntiHeWTPCpid) { histos.fill(HIST("tracks/helium/h2antiHeliumTOFbetaVsP"), antiheP, track.beta()); - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/helium/h2pVsTOFExpMomentumantiHe"), track.tofExpMom(), antiheP); histos.fill(HIST("tracks/eff/helium/h2TPCmomentumVsTOFExpMomentumantiHe"), track.tofExpMom(), antiheTPCmomentum); } @@ -4356,7 +4617,7 @@ struct LFNucleiBATask { massTOFantihe = antiheP * std::sqrt(1.f / (track.beta() * track.beta()) - 1.f); break; } - if (passDCAxyzCut) + if (passDCAxyzCut && outFlagOptions.doTOFplots && outFlagOptions.enablePIDplot) histos.fill(HIST("tracks/h2TPCsignVsBetaGamma"), (track.beta() * gamma) / (1.f * track.sign()), track.tpcSignal()); } else { massTOF = -99.f; @@ -4365,8 +4626,9 @@ struct LFNucleiBATask { } if (passDCAxyzCut) { - histos.fill(HIST("tracks/h2TOFmassVsPt"), massTOF, track.pt()); - if (enableEvTimeSplitting) { + if (outFlagOptions.enablePIDplot) + histos.fill(HIST("tracks/h2TOFmassVsPt"), massTOF, track.pt()); + if (filterOptions.enableEvTimeSplitting) { if (track.isEvTimeTOF() && track.isEvTimeT0AC()) { evtimeHistos.fill(HIST("tracks/evtime/ft0tof/h2TOFmassVsPt"), massTOF, track.pt()); } else if (track.isEvTimeT0AC()) { @@ -4381,19 +4643,19 @@ struct LFNucleiBATask { if (enablePr) { if ((std::abs(track.tpcNSigmaPr()) < nsigmaTPCvar.nsigmaTPCPr) && prRapCut) { if (track.sign() > 0) { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/proton/hPtPrTOF"), track.pt()); histos.fill(HIST("tracks/eff/proton/hPtPrTOFrebinned"), track.pt()); } histos.fill(HIST("tracks/proton/h2TOFmassProtonVsPt"), massTOF, track.pt()); histos.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt"), massTOF * massTOF - MassProtonVal * MassProtonVal, track.pt()); - if (outFlagOptions.enableBetaCut && (track.beta() > betaCut)) { + if (outFlagOptions.enableBetaCut && (track.beta() > cfgBetaCut)) { histos.fill(HIST("tracks/proton/h2TOFmassProtonVsPt_BetaCut"), massTOF, track.pt()); histos.fill(HIST("tracks/proton/h2TOFmass2ProtonVsPt_BetaCut"), massTOF * massTOF - MassProtonVal * MassProtonVal, track.pt()); } if (outFlagOptions.enableExpSignalTOF) histos.fill(HIST("tracks/proton/h2ProtonTOFExpSignalDiffVsPtCut"), track.pt(), track.tofExpSignalDiffPr()); - if (enableEvTimeSplitting) { + if (filterOptions.enableEvTimeSplitting) { if (track.isEvTimeTOF() && track.isEvTimeT0AC()) { evtimeHistos.fill(HIST("tracks/evtime/ft0tof/proton/h2TOFmass2ProtonVsPt"), massTOF * massTOF - MassProtonVal * MassProtonVal, track.pt()); } else if (track.isEvTimeT0AC()) { @@ -4405,19 +4667,19 @@ struct LFNucleiBATask { } } } else { - if (enablePtSpectra) { + if (outFlagOptions.enableEffPlots) { histos.fill(HIST("tracks/eff/proton/hPtantiPrTOF"), track.pt()); histos.fill(HIST("tracks/eff/proton/hPtantiPrTOFrebinned"), track.pt()); } histos.fill(HIST("tracks/proton/h2TOFmassantiProtonVsPt"), massTOF, track.pt()); histos.fill(HIST("tracks/proton/h2TOFmass2antiProtonVsPt"), massTOF * massTOF - MassProtonVal * MassProtonVal, track.pt()); - if (outFlagOptions.enableBetaCut && (track.beta() > betaCut)) { + if (outFlagOptions.enableBetaCut && (track.beta() > cfgBetaCut)) { histos.fill(HIST("tracks/proton/h2TOFmassantiProtonVsPt_BetaCut"), massTOF, track.pt()); histos.fill(HIST("tracks/proton/h2TOFmass2antiProtonVsPt_BetaCut"), massTOF * massTOF - MassProtonVal * MassProtonVal, track.pt()); } if (outFlagOptions.enableExpSignalTOF) histos.fill(HIST("tracks/proton/h2antiProtonTOFExpSignalDiffVsPtCut"), track.pt(), track.tofExpSignalDiffPr()); - if (enableEvTimeSplitting) { + if (filterOptions.enableEvTimeSplitting) { if (track.isEvTimeTOF() && track.isEvTimeT0AC()) { evtimeHistos.fill(HIST("tracks/evtime/ft0tof/proton/h2TOFmass2antiProtonVsPt"), massTOF * massTOF - MassProtonVal * MassProtonVal, track.pt()); } else if (track.isEvTimeT0AC()) { @@ -4435,20 +4697,20 @@ struct LFNucleiBATask { if (enableTr) { if ((isTritonTPCpid) && trRapCut) { if (track.sign() > 0) { - if (enablePtSpectra) + if (outFlagOptions.enableEffPlots) histos.fill(HIST("tracks/eff/triton/hPtTrTOF"), track.pt()); histos.fill(HIST("tracks/triton/h2TOFmassTritonVsPt"), massTOF, track.pt()); histos.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt"), massTOF * massTOF - MassTritonVal * MassTritonVal, track.pt()); - if (outFlagOptions.enableBetaCut && (track.beta() > betaCut)) { + if (outFlagOptions.enableBetaCut && (track.beta() > cfgBetaCut)) { histos.fill(HIST("tracks/triton/h2TOFmassTritonVsPt_BetaCut"), massTOF, track.pt()); histos.fill(HIST("tracks/triton/h2TOFmass2TritonVsPt_BetaCut"), massTOF * massTOF - MassTritonVal * MassTritonVal, track.pt()); } } else { - if (enablePtSpectra) + if (outFlagOptions.enableEffPlots) histos.fill(HIST("tracks/eff/triton/hPtantiTrTOF"), track.pt()); histos.fill(HIST("tracks/triton/h2TOFmassantiTritonVsPt"), massTOF, track.pt()); histos.fill(HIST("tracks/triton/h2TOFmass2antiTritonVsPt"), massTOF * massTOF - MassTritonVal * MassTritonVal, track.pt()); - if (outFlagOptions.enableBetaCut && (track.beta() > betaCut)) { + if (outFlagOptions.enableBetaCut && (track.beta() > cfgBetaCut)) { histos.fill(HIST("tracks/triton/h2TOFmassantiTritonVsPt_BetaCut"), massTOF, track.pt()); histos.fill(HIST("tracks/triton/h2TOFmass2antiTritonVsPt_BetaCut"), massTOF * massTOF - MassTritonVal * MassTritonVal, track.pt()); } @@ -4458,20 +4720,20 @@ struct LFNucleiBATask { } if (isDeWTPCpid) { - if (enablePtSpectra) + if (outFlagOptions.enableEffPlots) histos.fill(HIST("tracks/eff/deuteron/hPtDeTOF"), DPt); histos.fill(HIST("tracks/deuteron/h2TOFmassDeuteronVsPt"), massTOF, DPt); if (enableCentrality) histos.fill(HIST("tracks/deuteron/h3TOFmass2DeuteronVsPtVsMult"), massTOF * massTOF - MassDeuteronVal * MassDeuteronVal, DPt, event.centFT0M()); else histos.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt"), massTOF * massTOF - MassDeuteronVal * MassDeuteronVal, DPt); - if (outFlagOptions.enableBetaCut && (track.beta() > betaCut)) { + if (outFlagOptions.enableBetaCut && (track.beta() > cfgBetaCut)) { histos.fill(HIST("tracks/deuteron/h2TOFmassDeuteronVsPt_BetaCut"), massTOF, DPt); histos.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt_BetaCut"), massTOF * massTOF - MassDeuteronVal * MassDeuteronVal, DPt); } if (outFlagOptions.enableExpSignalTOF) histos.fill(HIST("tracks/deuteron/h2DeuteronTOFExpSignalDiffVsPtCut"), DPt, track.tofExpSignalDiffDe()); - if (enableEvTimeSplitting) { + if (filterOptions.enableEvTimeSplitting) { if (track.isEvTimeTOF() && track.isEvTimeT0AC()) { evtimeHistos.fill(HIST("tracks/evtime/ft0tof/deuteron/h2TOFmass2DeuteronVsPt"), massTOF * massTOF - MassDeuteronVal * MassDeuteronVal, DPt); } else if (track.isEvTimeT0AC()) { @@ -4484,20 +4746,20 @@ struct LFNucleiBATask { } } if (isAntiDeWTPCpid) { - if (enablePtSpectra) + if (outFlagOptions.enableEffPlots) histos.fill(HIST("tracks/eff/deuteron/hPtantiDeTOF"), antiDPt); histos.fill(HIST("tracks/deuteron/h2TOFmassantiDeuteronVsPt"), massTOF, antiDPt); if (enableCentrality) histos.fill(HIST("tracks/deuteron/h3TOFmass2antiDeuteronVsPtVsMult"), massTOF * massTOF - MassDeuteronVal * MassDeuteronVal, antiDPt, event.centFT0M()); else histos.fill(HIST("tracks/deuteron/h2TOFmass2antiDeuteronVsPt"), massTOF * massTOF - MassDeuteronVal * MassDeuteronVal, antiDPt); - if (outFlagOptions.enableBetaCut && (track.beta() > betaCut)) { + if (outFlagOptions.enableBetaCut && (track.beta() > cfgBetaCut)) { histos.fill(HIST("tracks/deuteron/h2TOFmassantiDeuteronVsPt_BetaCut"), massTOF, antiDPt); histos.fill(HIST("tracks/deuteron/h2TOFmass2antiDeuteronVsPt_BetaCut"), massTOF * massTOF - MassDeuteronVal * MassDeuteronVal, antiDPt); } if (outFlagOptions.enableExpSignalTOF) histos.fill(HIST("tracks/deuteron/h2antiDeuteronTOFExpSignalDiffVsPtCut"), antiDPt, track.tofExpSignalDiffDe()); - if (enableEvTimeSplitting) { + if (filterOptions.enableEvTimeSplitting) { if (track.isEvTimeTOF() && track.isEvTimeT0AC()) { evtimeHistos.fill(HIST("tracks/evtime/ft0tof/deuteron/h2TOFmass2antiDeuteronVsPt"), massTOF * massTOF - MassDeuteronVal * MassDeuteronVal, antiDPt); } else if (track.isEvTimeT0AC()) { @@ -4511,12 +4773,12 @@ struct LFNucleiBATask { } if (isHeWTPCpid) { - if (enablePtSpectra) + if (outFlagOptions.enableEffPlots) histos.fill(HIST("tracks/eff/helium/hPtHeTOF"), 2 * hePt); histos.fill(HIST("tracks/helium/h2TOFmassHeliumVsPt"), 2.f * massTOFhe, hePt); histos.fill(HIST("tracks/helium/h2TOFmassDeltaHeliumVsPt"), 2.f * massTOFhe - MassHeliumVal, hePt); histos.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt"), 2.f * massTOFhe * 2.f * massTOFhe - MassHeliumVal * MassHeliumVal, hePt); - if (outFlagOptions.enableBetaCut && (track.beta() > betaCut)) { + if (outFlagOptions.enableBetaCut && (track.beta() > cfgBetaCut)) { histos.fill(HIST("tracks/helium/h2TOFmassHeliumVsPt_BetaCut"), 2.f * massTOFhe, hePt); histos.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt_BetaCut"), 2.f * massTOFhe * 2.f * massTOFhe - MassHeliumVal * MassHeliumVal, hePt); } @@ -4524,12 +4786,12 @@ struct LFNucleiBATask { histos.fill(HIST("tracks/helium/h2HeliumTOFExpSignalDiffVsPtCut"), hePt, track.tofExpSignalDiffHe()); } if (isAntiHeWTPCpid) { - if (enablePtSpectra) + if (outFlagOptions.enableEffPlots) histos.fill(HIST("tracks/eff/helium/hPtantiHeTOF"), 2 * antihePt); histos.fill(HIST("tracks/helium/h2TOFmassantiHeliumVsPt"), 2.f * massTOFantihe, antihePt); histos.fill(HIST("tracks/helium/h2TOFmassDeltaantiHeliumVsPt"), 2.f * massTOFantihe - MassHeliumVal, antihePt); histos.fill(HIST("tracks/helium/h2TOFmass2antiHeliumVsPt"), 2.f * massTOFantihe * 2.f * massTOFantihe - MassHeliumVal * MassHeliumVal, antihePt); - if (outFlagOptions.enableBetaCut && (track.beta() > betaCut)) { + if (outFlagOptions.enableBetaCut && (track.beta() > cfgBetaCut)) { histos.fill(HIST("tracks/helium/h2TOFmassantiHeliumVsPt_BetaCut"), 2.f * massTOFantihe, antihePt); histos.fill(HIST("tracks/helium/h2TOFmass2antiHeliumVsPt_BetaCut"), 2.f * massTOFantihe * 2.f * massTOFantihe - MassHeliumVal * MassHeliumVal, antihePt); } @@ -5256,7 +5518,7 @@ struct LFNucleiBATask { break; case PDGHelium: if (isHelium && passDCAzCutHe && passDCAxyCutHe) { - histos.fill(HIST("tracks/helium/h1HeliumSpectraTrue"), hePt); + // histos.fill(HIST("tracks/helium/h1HeliumSpectraTrue"), hePt); histos.fill(HIST("tracks/helium/h1HeliumSpectraTrue_Z2"), 2 * hePt); if (outFlagOptions.makeDCAAfterCutPlots) { @@ -5269,17 +5531,17 @@ struct LFNucleiBATask { } } if (std::abs(track.tpcNSigmaHe()) < nsigmaTPCvar.nsigmaTPCHe) { - histos.fill(HIST("tracks/helium/h1HeliumSpectraTrueWPID"), hePt); + // histos.fill(HIST("tracks/helium/h1HeliumSpectraTrueWPID"), hePt); histos.fill(HIST("tracks/helium/h1HeliumSpectraTrueWPID_Z2"), 2 * hePt); - if (enablePtSpectra) { - histos.fill(HIST("tracks/eff/helium/hPtHeTrue"), 2 * hePt); + if (outFlagOptions.enableEffPlots) { + histos.fill(HIST("tracks/eff/helium/hPtHeTrue_Z2"), 2 * hePt); if (track.hasTOF() && outFlagOptions.doTOFplots) { - histos.fill(HIST("tracks/eff/helium/hPtHeTOFTrue"), 2 * hePt); + histos.fill(HIST("tracks/eff/helium/hPtHeTOFTrue_Z2"), 2 * hePt); } } } if (isPhysPrim) { - histos.fill(HIST("tracks/helium/h1HeliumSpectraTruePrim"), hePt); + // histos.fill(HIST("tracks/helium/h1HeliumSpectraTruePrim"), hePt); histos.fill(HIST("tracks/helium/h1HeliumSpectraTruePrim_Z2"), 2 * hePt); if (std::abs(track.tpcNSigmaHe()) < nsigmaTPCvar.nsigmaTPCHe) { @@ -5299,7 +5561,7 @@ struct LFNucleiBATask { } if (!isPhysPrim && !isProdByGen) { - histos.fill(HIST("tracks/helium/h1HeliumSpectraTrueTransport"), hePt); + // histos.fill(HIST("tracks/helium/h1HeliumSpectraTrueTransport"), hePt); histos.fill(HIST("tracks/helium/h1HeliumSpectraTrueTransport_Z2"), 2 * hePt); if (outFlagOptions.makeDCAAfterCutPlots) { @@ -5311,7 +5573,7 @@ struct LFNucleiBATask { } } if (isWeakDecay) { - histos.fill(HIST("tracks/helium/h1HeliumSpectraTrueSec"), hePt); + // histos.fill(HIST("tracks/helium/h1HeliumSpectraTrueSec"), hePt); histos.fill(HIST("tracks/helium/h1HeliumSpectraTrueSec_Z2"), 2 * hePt); if (outFlagOptions.makeDCAAfterCutPlots) { @@ -5328,7 +5590,7 @@ struct LFNucleiBATask { break; case -PDGHelium: if (isHelium && passDCAzCutAntiHe && passDCAxyCutAntiHe) { - histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrue"), antihePt); + // histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrue"), antihePt); histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrue_Z2"), 2 * antihePt); if (outFlagOptions.makeDCAAfterCutPlots) { @@ -5340,17 +5602,17 @@ struct LFNucleiBATask { } } if (std::abs(track.tpcNSigmaHe()) < nsigmaTPCvar.nsigmaTPCHe) { - histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrueWPID"), antihePt); + // histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrueWPID"), antihePt); histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrueWPID_Z2"), 2 * antihePt); - if (enablePtSpectra) { - histos.fill(HIST("tracks/eff/helium/hPtantiHeTrue"), 2 * antihePt); + if (outFlagOptions.enableEffPlots) { + histos.fill(HIST("tracks/eff/helium/hPtantiHeTrue_Z2"), 2 * antihePt); if (track.hasTOF() && outFlagOptions.doTOFplots) { - histos.fill(HIST("tracks/eff/helium/hPtantiHeTOFTrue"), 2 * antihePt); + histos.fill(HIST("tracks/eff/helium/hPtantiHeTOFTrue_Z2"), 2 * antihePt); } } } if (isPhysPrim) { - histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTruePrim"), antihePt); + // histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTruePrim"), antihePt); histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTruePrim_Z2"), 2 * antihePt); if (std::abs(track.tpcNSigmaHe()) < nsigmaTPCvar.nsigmaTPCHe) { @@ -5369,7 +5631,7 @@ struct LFNucleiBATask { } } if (!isPhysPrim && !isProdByGen) { - histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrueTransport"), antihePt); + // histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrueTransport"), antihePt); histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrueTransport_Z2"), 2 * antihePt); if (outFlagOptions.makeDCAAfterCutPlots) { @@ -5382,7 +5644,7 @@ struct LFNucleiBATask { } if (isWeakDecay) { - histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrueSec"), antihePt); + // histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrueSec"), antihePt); histos.fill(HIST("tracks/helium/h1antiHeliumSpectraTrueSec_Z2"), 2 * antihePt); if (outFlagOptions.makeDCAAfterCutPlots) { @@ -5468,7 +5730,7 @@ struct LFNucleiBATask { using EventCandidates = soa::Join; using EventCandidatesMC = soa::Join; - using TrackCandidates0 = soa::Join(event, tracks, true /*dummy*/); } @@ -5505,7 +5768,8 @@ struct LFNucleiBATask { // Process function that runs on the original AO2D void processDataLfPid(EventCandidates::iterator const& event, - TrackCandidatesLfPid const& tracks) + TrackCandidatesLfPid const& tracks, + o2::aod::BCsWithTimestamps const&) { fillHistograms(event, tracks, true /*dummy*/); } @@ -5513,7 +5777,8 @@ struct LFNucleiBATask { // Process function that runs on the filtered data void processDataFiltered(o2::aod::LfNuclEvents::iterator const& event, - o2::aod::LfCandNucleusFull const& tracks) + o2::aod::LfCandNucleusFull const& tracks, + o2::aod::BCsWithTimestamps const&) { // Runs on data filtered on the fly with LF Tree creator nuclei task // Takes as input full AO2Ds @@ -5522,7 +5787,8 @@ struct LFNucleiBATask { PROCESS_SWITCH(LFNucleiBATask, processDataFiltered, "process data on the filtered data", false); void processDataLight(o2::aod::LfNuclEvents::iterator const& event, - o2::aod::LfCandNucleusDummy const& tracks) + o2::aod::LfCandNucleusDummy const& tracks, + o2::aod::BCsWithTimestamps const&) { // Runs on derived tables produced with LF Tree creator nuclei task // Takes as input derived trees @@ -5536,8 +5802,10 @@ struct LFNucleiBATask { // Process function that runs on the original AO2D (for the MC) void processMCReco(EventCandidatesMC::iterator const& event, + soa::Join const&, soa::Join const& tracks, - aod::McParticles const& mcParticles) + aod::McParticles const& mcParticles, + o2::aod::BCsWithTimestamps const&) { fillHistograms(event, tracks, mcParticles); } // CLOSING PROCESS MC RECO @@ -5545,8 +5813,10 @@ struct LFNucleiBATask { // Process function that runs on the original AO2D (for the MC) with the LfPIDcalibration void processMCRecoLfPid(EventCandidatesMC::iterator const& event, + soa::Join const&, soa::Join const& tracks, - aod::McParticles const& mcParticles) + aod::McParticles const& mcParticles, + o2::aod::BCsWithTimestamps const&) { fillHistograms(event, tracks, mcParticles); } // CLOSING PROCESS MC RECO @@ -5567,7 +5837,7 @@ struct LFNucleiBATask { const auto& particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, collision.mcCollision().globalIndex(), cache); for (const auto& mcParticle : particlesInCollision) { - if (mcParticle.y() > kinemOptions.yHighCut || mcParticle.y() < kinemOptions.yLowCut) { + if (mcParticle.y() > kinemOptions.cfgRapidityCutHigh || mcParticle.y() < kinemOptions.cfgRapidityCutLow) { continue; } spectraGen.fill(HIST("LfEv/pT_nocut"), mcParticle.pt()); @@ -5580,7 +5850,7 @@ struct LFNucleiBATask { } if (collision.selection_bit(aod::evsel::kIsTriggerTVX)) { for (const auto& mcParticle : particlesInCollision) { - if (mcParticle.y() > kinemOptions.yHighCut || mcParticle.y() < kinemOptions.yLowCut) { + if (mcParticle.y() > kinemOptions.cfgRapidityCutHigh || mcParticle.y() < kinemOptions.cfgRapidityCutLow) { continue; } @@ -5595,7 +5865,7 @@ struct LFNucleiBATask { } if (collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { for (const auto& mcParticle : particlesInCollision) { - if (mcParticle.y() > kinemOptions.yHighCut || mcParticle.y() < kinemOptions.yLowCut) { + if (mcParticle.y() > kinemOptions.cfgRapidityCutHigh || mcParticle.y() < kinemOptions.cfgRapidityCutLow) { continue; } @@ -5610,7 +5880,7 @@ struct LFNucleiBATask { } if (collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { for (const auto& mcParticle : particlesInCollision) { - if (mcParticle.y() > kinemOptions.yHighCut || mcParticle.y() < kinemOptions.yLowCut) { + if (mcParticle.y() > kinemOptions.cfgRapidityCutHigh || mcParticle.y() < kinemOptions.cfgRapidityCutLow) { continue; } @@ -5625,7 +5895,7 @@ struct LFNucleiBATask { } if ((collision.selection_bit(aod::evsel::kIsTriggerTVX)) && (collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { for (const auto& mcParticle : particlesInCollision) { - if (mcParticle.y() > kinemOptions.yHighCut || mcParticle.y() < kinemOptions.yLowCut) { + if (mcParticle.y() > kinemOptions.cfgRapidityCutHigh || mcParticle.y() < kinemOptions.cfgRapidityCutLow) { continue; } @@ -5646,7 +5916,7 @@ struct LFNucleiBATask { } if (collision.sel8()) { for (const auto& mcParticle : particlesInCollision) { - if (mcParticle.y() > kinemOptions.yHighCut || mcParticle.y() < kinemOptions.yLowCut) { + if (mcParticle.y() > kinemOptions.cfgRapidityCutHigh || mcParticle.y() < kinemOptions.cfgRapidityCutLow) { continue; } @@ -5667,14 +5937,16 @@ struct LFNucleiBATask { // Process function that runs on the filtered AO2D (for the MC) void processMCRecoFiltered(o2::aod::LfNuclEvents::iterator const& event, - soa::Join const& tracks) + soa::Join const& tracks, + o2::aod::BCsWithTimestamps const&) { fillHistograms(event, tracks, true /*dummy*/); } // CLOSING PROCESS MC RECO ON FILTERED DATA PROCESS_SWITCH(LFNucleiBATask, processMCRecoFiltered, "process mc reco on the filtered data", false); void processMCRecoFilteredLight(o2::aod::LfNuclEvents::iterator const& event, - soa::Join const& tracks) + soa::Join const& tracks, + o2::aod::BCsWithTimestamps const&) { fillHistograms(event, tracks, true /*dummy*/); } // CLOSING PROCESS MC RECO ON FILTERED DATA @@ -5685,12 +5957,14 @@ struct LFNucleiBATask { //////////// // LOOP OVER GENERATED MC PARTICLES - void processMCGen(aod::McCollision const& mcCollision, - aod::McParticles& mcParticles) + void processMCGen(soa::Join::iterator const& mcCollision, + aod::McParticles const& mcParticles) { spectraGen.fill(HIST("histGenVetxZ"), mcCollision.posZ()); + if (mcCollision.centFT0M() < cfgMultCutLow || mcCollision.centFT0M() > cfgMultCutHigh) + return; for (auto& mcParticleGen : mcParticles) { - if (mcParticleGen.y() > kinemOptions.yHighCut || mcParticleGen.y() < kinemOptions.yLowCut) { + if (mcParticleGen.y() > kinemOptions.cfgRapidityCutHigh || mcParticleGen.y() < kinemOptions.cfgRapidityCutLow) { continue; } @@ -5920,6 +6194,63 @@ struct LFNucleiBATask { } } // Close processMCGen PROCESS_SWITCH(LFNucleiBATask, processMCGen, "process MC Generated", true); + void processEvSgLossMC(soa::Join::iterator const& mcCollision, + aod::McParticles const& mcParticles, + const soa::SmallGroups& recoColls) + { + if (std::abs(mcCollision.posZ()) < cfgVzCutHigh) { + evLossHistos.fill(HIST("evLoss/hEvent"), 0.5); + } + + bool isSel8Event = false; + bool isTvxEvent = false; + + // Check if there is an event reconstructed for a generated event + for (const auto& recoColl : recoColls) { + if (std::abs(recoColl.posZ()) > cfgVzCutHigh) + continue; + if (recoColl.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + isTvxEvent = true; + } + if (recoColl.sel8()) { + isSel8Event = true; + } + } + + if (isTvxEvent) { + evLossHistos.fill(HIST("evLoss/hEvent"), 1.5); + } + if (isSel8Event) { + evLossHistos.fill(HIST("evLoss/hEvent"), 2.5); + } + + // Loop over all the Generated level particles + for (const auto& mcPart : mcParticles) { + if (!mcPart.isPhysicalPrimary()) + continue; + if (std::abs(mcPart.y()) >= 0.5) + continue; + if (mcPart.pdgCode() == PDGDeuteron) { + evLossHistos.fill(HIST("evLoss/pt/hDeuteronGen"), mcPart.pt()); + if (isTvxEvent) { + evLossHistos.fill(HIST("evLoss/pt/hDeuteronTriggeredTVX"), mcPart.pt()); + } + if (isSel8Event) { + evLossHistos.fill(HIST("evLoss/pt/hDeuteronTriggeredSel8"), mcPart.pt()); + } + } + if (mcPart.pdgCode() == -PDGDeuteron) { + evLossHistos.fill(HIST("evLoss/pt/hAntiDeuteronGen"), mcPart.pt()); + if (isTvxEvent) { + evLossHistos.fill(HIST("evLoss/pt/hAntiDeuteronTriggeredTVX"), mcPart.pt()); + } + if (isSel8Event) { + evLossHistos.fill(HIST("evLoss/pt/hAntiDeuteronTriggeredSel8"), mcPart.pt()); + } + } + } // MC particles + } + PROCESS_SWITCH(LFNucleiBATask, processEvSgLossMC, "process MC Sig Event", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Nuspex/NucleiEfficiencyTask.cxx b/PWGLF/Tasks/Nuspex/NucleiEfficiencyTask.cxx index cf29855fc2f..4ca2bd51c6f 100644 --- a/PWGLF/Tasks/Nuspex/NucleiEfficiencyTask.cxx +++ b/PWGLF/Tasks/Nuspex/NucleiEfficiencyTask.cxx @@ -16,64 +16,81 @@ #include #include #include +#include +#include +#include #include "ReconstructionDataFormats/Track.h" +#include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" +#include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/McCollisionExtra.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Centrality.h" -#include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" #include "PWGDQ/DataModel/ReducedInfoTables.h" #include "TPDGCode.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/Core/TrackSelection.h" +#include "Framework/StaticFor.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "PWGLF/DataModel/spectraTOF.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "PWGLF/Utils/inelGt.h" +#include "PWGLF/DataModel/mcCentrality.h" +#include "Common/Core/RecoDecay.h" using namespace o2; +using namespace o2::track; using namespace o2::framework; using namespace o2::framework::expressions; struct NucleiEfficiencyTask { - HistogramRegistry MC_truth_reg{"MC_particles_gen", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry MC_truth_reg_cent{"MC_particles_gen_cent", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry MC_gen_reg{"MC_particles_gen", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry MC_recon_reg{"MC_particles_reco", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry MC_recon_reg_cent{"MC_particles_reco_cent", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - OutputObj histPDG_mctruth{TH1F("PDG_gen", "PDG;PDG code", 20, 0.0, 20.0)}; - OutputObj histPDG{TH1F("PDG_reco", "PDG;PDG code", 20, 0.0, 20.0)}; + OutputObj histPDG_gen{TH1F("PDG_gen", "PDG;PDG code", 18, 0.0, 18)}; + OutputObj histPDG_gen_reco{TH1F("PDG_gen_reco", "PDG;PDG code", 18, 0.0, 18)}; + OutputObj histPDG_reco{TH1F("PDG_reco", "PDG;PDG code", 18, 0.0, 18)}; void init(o2::framework::InitContext&) { std::vector ptBinning = {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, 1.6, 1.8, 2.0, 2.2, 2.4, 2.8, 3.2, 3.6, 4., 5., 6., 8., 10., 12., 14.}; - std::vector centBinning = {0., 10., 20., 30., 40., 50., 60., 70., 80., 100.}; std::vector etaBinning = {-1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}; std::vector PDGBinning = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0}; AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec pAxis = {ptBinning, "#it{p} (GeV/#it{c})"}; - AxisSpec centralityAxis = {100, 0.0, 100.0, "VT0C (%)"}; - AxisSpec centralityAxis_extended = {105, 0.0, 105.0, "VT0C (%)"}; + AxisSpec centralityAxis = {100, 0.0, 105.0, "VT0C (%)"}; AxisSpec etaAxis = {etaBinning, "#eta"}; - AxisSpec centAxis = {centBinning, "Centrality (%)"}; - AxisSpec ImPaAxis = {centBinning, "Impact parameter"}; + AxisSpec ImPaAxis = {100, 0.0, 105.0, "Impact parameter"}; AxisSpec PDGBINNING = {PDGBinning, "PDG code"}; - // Generated - MC_truth_reg.add("histGenVtxMC", "MC generated vertex z position", HistType::kTH1F, {{400, -40., +40., "z position (cm)"}}); - MC_truth_reg.add("histCentrality", "Impact parameter", HistType::kTH1F, {centralityAxis_extended}); - MC_truth_reg.add("hist_gen_p", "generated p distribution", HistType::kTH2F, {pAxis, PDGBINNING}); - MC_truth_reg.add("hist_gen_pT", "generated p_{T} distribution", HistType::kTH2F, {ptAxis, PDGBINNING}); - MC_truth_reg.add("histPhi", "#phi", HistType::kTH2F, {{100, 0., 2. * TMath::Pi()}, PDGBINNING}); - MC_truth_reg.add("histEta", "#eta", HistType::kTH2F, {{102, -2.01, 2.01}, PDGBINNING}); - MC_truth_reg.add("histRapid", "#gamma", HistType::kTH2F, {{1000, -5.0, 5.0}, PDGBINNING}); - // Centrality - MC_truth_reg_cent.add("hist_gen_p_cent", "generated p distribution vs impact param", HistType::kTH3F, {pAxis, PDGBINNING, ImPaAxis}); - MC_truth_reg_cent.add("hist_gen_pT_cent", "generated p_{T} distribution vs impact param", HistType::kTH3F, {ptAxis, PDGBINNING, ImPaAxis}); - - // Reconstructed + // *********************** Generated ********************** + MC_gen_reg.add("histGenVtxMC", "MC generated vertex z position", HistType::kTH1F, {{400, -40., +40., "z position (cm)"}}); + MC_gen_reg.add("histCentrality", "Impact parameter", HistType::kTH1F, {centralityAxis}); + MC_gen_reg.add("hist_gen_p", "generated p distribution", HistType::kTH2F, {pAxis, PDGBINNING}); + MC_gen_reg.add("hist_gen_pT", "generated p_{T} distribution", HistType::kTH2F, {ptAxis, PDGBINNING}); + MC_gen_reg.add("histPhi", "#phi", HistType::kTH2F, {{100, 0., 2. * TMath::Pi()}, PDGBINNING}); + MC_gen_reg.add("histEta", "#eta", HistType::kTH2F, {{102, -2.01, 2.01}, PDGBINNING}); + MC_gen_reg.add("histRapid", "#gamma", HistType::kTH2F, {{1000, -5.0, 5.0}, PDGBINNING}); + + // *********************** Generated reco ********************** + + MC_gen_reg.add("histGenVtxMC_reco", "MC generated (reco) vertex z position", HistType::kTH1F, {{400, -40., +40., "z position (cm)"}}); + MC_gen_reg.add("histCentrality_reco", "Centrality", HistType::kTH1F, {centralityAxis}); + MC_gen_reg.add("histEta_reco", "generated (reco) #eta", HistType::kTH2F, {{102, -2.01, 2.01}, PDGBINNING}); + MC_gen_reg.add("hist_gen_reco_p", "generated (reco) p distribution", HistType::kTH2F, {pAxis, PDGBINNING}); + MC_gen_reg.add("hist_gen_reco_pT", "generated (reco) p_{T} distribution", HistType::kTH2F, {ptAxis, PDGBINNING}); + + // ********************** Reconstructed ********************* MC_recon_reg.add("histRecVtxMC", "MC reconstructed vertex z position", HistType::kTH1F, {{400, -40., +40., "z position (cm)"}}); - MC_recon_reg.add("histCentrality", "Centrality", HistType::kTH1F, {centralityAxis_extended}); + MC_recon_reg.add("histCentrality", "Centrality", HistType::kTH1F, {centralityAxis}); MC_recon_reg.add("histPhi", "#phi", HistType::kTH2F, {{100, 0., 2. * TMath::Pi()}, PDGBINNING}); MC_recon_reg.add("histEta", "#eta", HistType::kTH2F, {{102, -2.01, 2.01}, PDGBINNING}); MC_recon_reg.add("hist_rec_ITS_vs_p", "ITS reconstructed p distribution", HistType::kTH2F, {pAxis, PDGBINNING}); @@ -82,334 +99,474 @@ struct NucleiEfficiencyTask { MC_recon_reg.add("hist_rec_ITS_vs_pT", "ITS reconstructed p_{T} distribution", HistType::kTH2F, {ptAxis, PDGBINNING}); MC_recon_reg.add("hist_rec_ITS_TPC_vs_pT", "ITS_TPC reconstructed p_{T} distribution", HistType::kTH2F, {ptAxis, PDGBINNING}); MC_recon_reg.add("hist_rec_ITS_TPC_TOF_vs_pT", "ITS_TPC_TOF reconstructed p_{T} distribution", HistType::kTH2F, {ptAxis, PDGBINNING}); - // Centrality - MC_recon_reg_cent.add("hist_rec_ITS_vs_p_cent", "ITS reconstructed p distribution vs centrality", HistType::kTH3F, {pAxis, PDGBINNING, centAxis}); - MC_recon_reg_cent.add("hist_rec_ITS_TPC_vs_p_cent", "ITS_TPC reconstructed p distribution vs centrality", HistType::kTH3F, {pAxis, PDGBINNING, centAxis}); - MC_recon_reg_cent.add("hist_rec_ITS_TPC_TOF_vs_p_cent", "ITS_TPC_TOF reconstructed p distribution vs centrality", HistType::kTH3F, {pAxis, PDGBINNING, centAxis}); - MC_recon_reg_cent.add("hist_rec_ITS_vs_pT_cent", "ITS reconstructed p_{T} distribution vs centrality", HistType::kTH3F, {ptAxis, PDGBINNING, centAxis}); - MC_recon_reg_cent.add("hist_rec_ITS_TPC_vs_pT_cent", "ITS_TPC reconstructed p_{T} distribution vs centrality", HistType::kTH3F, {ptAxis, PDGBINNING, centAxis}); - MC_recon_reg_cent.add("hist_rec_ITS_TPC_TOF_vs_pT_cent", "ITS_TPC_TOF reconstructed p_{T} distribution vs centrality", HistType::kTH3F, {ptAxis, PDGBINNING, centAxis}); } + // ************************ Configurables *********************** Configurable event_selection_MC_sel8{"event_selection_MC_sel8", true, "Enable sel8 event selection in MC processing"}; - Configurable calc_cent{"calc_cent", false, "Enable centrality processing"}; - Configurable y_cut_MC_gen{"y_cut_MC_gen", true, "Enable rapidity cut for generated MC"}; - Configurable eta_cut_MC_gen{"eta_cut_MC_gen", true, "Enable eta cut for generated MC"}; - Configurable use_pT_cut{"use_pT_cut", true, "0: p is used | 1: pT is used"}; - Configurable yMin_gen{"yMin_gen", -0.5, "Maximum rapidity (generated)"}; - Configurable yMax_gen{"yMax_gen", 0.5, "Minimum rapidity (generated)"}; + Configurable applyPvZCutGenColl{"applyPvZCutGenColl", true, "applyPvZCutGenColl"}; + Configurable yMin{"yMin", -0.5, "Minimum rapidity"}; + Configurable yMax{"yMax", 0.5, "Maximum rapidity"}; + Configurable p_min{"p_min", 0.1f, "min track.pt()"}; + Configurable p_max{"p_max", 1e+10f, "max track.pt()"}; Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; - Configurable cfgCutEta{"cfgCutEta", 0.9f, "Eta range for tracks"}; - Configurable yMin_reco{"yMin_reco", -0.5, "Maximum rapidity (reconstructed)"}; - Configurable yMax_reco{"yMax_reco", 0.5, "Minimum rapidity (reconstructed)"}; - Configurable pmin_reco{"pmin_reco", 0.1f, "min p (reconstructed)"}; - Configurable pmax_reco{"pmax_reco", 1e+10f, "max p (reconstructed)"}; - Configurable pTmin_reco{"pTmin_reco", 0.1f, "min pT (reconstructed)"}; - Configurable pTmax_reco{"pTmax_reco", 1e+10f, "max pT (reconstructed)"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"}; + Configurable minCentrality{"minCentrality", 0.0, "min Centrality used"}; + Configurable maxCentrality{"maxCentrality", 80.0, "max Centrality used"}; + Configurable enable_Centrality_cut{"enable_Centrality_cut", true, "enable Centrality cut"}; + + // Track filter + Configurable requireITS{"requireITS", true, "Additional cut on the ITS requirement"}; + Configurable requireTPC{"requireTPC", true, "Additional cut on the TPC requirement"}; + Configurable passedITSRefit{"passedITSRefit", true, "Additional cut on the ITS refit requirement"}; + Configurable passedTPCRefit{"passedTPCRefit", true, "Additional cut on the TPC refit requirement"}; Configurable minReqClusterITS{"minReqClusterITS", 1.0, "min number of clusters required in ITS"}; Configurable minReqClusterITSib{"minReqClusterITSib", 1.0, "min number of clusters required in ITS inner barrel"}; Configurable minTPCnClsFound{"minTPCnClsFound", 0.0f, "min number of crossed rows TPC"}; Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 70.0f, "min number of crossed rows TPC"}; Configurable minRatioCrossedRowsTPC{"minRatioCrossedRowsTPC", 0.8f, "min ratio of crossed rows over findable clusters TPC"}; - Configurable maxRatioCrossedRowsTPC{"maxRatioCrossedRowsTPC", 1.5f, "max ratio of crossed rows over findable clusters TPC"}; - Configurable maxChi2ITS{"maxChi2ITS", 36.0f, "max chi2 per cluster ITS"}; - Configurable maxChi2TPC{"maxChi2TPC", 4.0f, "max chi2 per cluster TPC"}; - Configurable maxDCA_XY{"maxDCA_XY", 0.5f, "max DCA to vertex xy"}; + Configurable maxRatioCrossedRowsTPC{"maxRatioCrossedRowsTPC", 2.0f, "max ratio of crossed rows over findable clusters TPC"}; + Configurable maxChi2PerClusterTPC{"maxChi2PerClusterTPC", 4.f, "Cut on the maximum value of the chi2 per cluster in the TPC"}; + Configurable minChi2PerClusterTPC{"minChi2PerClusterTPC", 0.5f, "Cut on the minimum value of the chi2 per cluster in the TPC"}; + Configurable maxChi2PerClusterITS{"maxChi2PerClusterITS", 36.f, "Cut on the maximum value of the chi2 per cluster in the ITS"}; + Configurable maxDcaXYFactor{"maxDcaXYFactor", 0.5f, "DCA xy factor"}; Configurable maxDCA_Z{"maxDCA_Z", 2.0f, "max DCA to vertex z"}; + Configurable lastRequiredTrdCluster{"lastRequiredTrdCluster", -1, "Last cluster to required in TRD for track selection. -1 does not require any TRD cluster"}; + Configurable requireGoldenChi2{"requireGoldenChi2", false, "Enable the requirement of GoldenChi2"}; - //**************************************************************************************************** + Configurable calc_cent{"calc_cent", false, "Enable centrality processing"}; - template - void process_MC_gen(const McCollisionType& mcCollision, const McParticlesType& mcParticles) - { - MC_truth_reg.fill(HIST("histGenVtxMC"), mcCollision.posZ()); - MC_truth_reg.fill(HIST("histCentrality"), mcCollision.impactParameter()); + Configurable eta_cut_MC_gen{"eta_cut_MC_gen", true, "Enable eta cut for generated MC"}; + Configurable use_pT_cut{"use_pT_cut", true, "0: p is used | 1: pT is used"}; - for (const auto& MCparticle : mcParticles) { - if (!MCparticle.isPhysicalPrimary()) - continue; - if ((MCparticle.y() > yMax_gen || MCparticle.y() < yMin_gen) && y_cut_MC_gen) - continue; - if ((TMath::Abs(MCparticle.eta()) > cfgCutEta) && eta_cut_MC_gen) - continue; + Configurable removeITSROFrameBorder{"removeITSROFrameBorder", false, "Remove TF border"}; + Configurable removeNoSameBunchPileup{"removeNoSameBunchPileup", false, "Remove TF border"}; + Configurable requireIsGoodZvtxFT0vsPV{"requireIsGoodZvtxFT0vsPV", false, "Remove TF border"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "Remove TF border"}; + Configurable removeNoTimeFrameBorder{"removeNoTimeFrameBorder", false, "Remove TF border"}; - int pdgbin = 0; - switch (MCparticle.pdgCode()) { - case +211: - histPDG_mctruth->AddBinContent(1); - pdgbin = 0; - break; - case -211: - histPDG_mctruth->AddBinContent(2); - pdgbin = 1; - break; - case +321: - histPDG_mctruth->AddBinContent(3); - pdgbin = 2; - break; - case -321: - histPDG_mctruth->AddBinContent(4); - pdgbin = 3; - break; - case +2212: - histPDG_mctruth->AddBinContent(5); - pdgbin = 4; - break; - case -2212: - histPDG_mctruth->AddBinContent(6); - pdgbin = 5; - break; - case +1000010020: - histPDG_mctruth->AddBinContent(7); - pdgbin = 6; - break; - case -1000010020: - histPDG_mctruth->AddBinContent(8); - pdgbin = 7; - break; - case +1000010030: - histPDG_mctruth->AddBinContent(9); - pdgbin = 8; - break; - case -1000010030: - histPDG_mctruth->AddBinContent(10); - pdgbin = 9; - break; - case +1000020030: - histPDG_mctruth->AddBinContent(11); - pdgbin = 10; - break; - case -1000020030: - histPDG_mctruth->AddBinContent(12); - pdgbin = 11; - break; - case +1000020040: - histPDG_mctruth->AddBinContent(13); - pdgbin = 12; - break; - case -1000020040: - histPDG_mctruth->AddBinContent(14); - pdgbin = 13; - break; - default: - continue; - } + //*********************************************************************************** - MC_truth_reg.fill(HIST("histPhi"), MCparticle.phi(), pdgbin); - MC_truth_reg.fill(HIST("histEta"), MCparticle.eta(), pdgbin); - MC_truth_reg.fill(HIST("histRapid"), MCparticle.y(), pdgbin); - MC_truth_reg.fill(HIST("hist_gen_p"), MCparticle.p(), pdgbin); - MC_truth_reg.fill(HIST("hist_gen_pT"), MCparticle.pt(), pdgbin); + template + bool isInAcceptance(const particleType& particle) + { + if (particle.pt() < p_min || particle.pt() > p_max) + return false; + if (particle.eta() < -cfgCutEta || particle.eta() > cfgCutEta) + return false; + // if (particle.phi() < phiMin || particle.phi() > phiMax) return false; + if (particle.y() < yMin || particle.y() > yMax) + return false; + if (!particle.isPhysicalPrimary()) + return false; + + return true; + } - if (calc_cent) { - MC_truth_reg_cent.fill(HIST("hist_gen_p_cent"), MCparticle.p(), pdgbin, mcCollision.impactParameter()); - MC_truth_reg_cent.fill(HIST("hist_gen_pT_cent"), MCparticle.pt(), pdgbin, mcCollision.impactParameter()); - } - } + //*********************************************************************************** + + template + bool isEventSelected(CollisionType const& collision) + { + if (removeITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) + return false; + if (removeNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) + return false; + if (requireIsGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) + return false; + if (requireIsVertexITSTPC && !collision.selection_bit(aod::evsel::kIsVertexITSTPC)) + return false; + if (removeNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) + return false; + + return true; } - //**************************************************************************************************** + //*********************************************************************************** - template - void process_MC_reco(const CollisionType& collision, const TracksType& tracks, const mcParticlesType& /*mcParticles*/) + template + bool isCollisionSelected(const CollType& collision) { if (event_selection_MC_sel8 && !collision.sel8()) - return; - MC_recon_reg.fill(HIST("histRecVtxMC"), collision.posZ()); - MC_recon_reg.fill(HIST("histCentrality"), collision.centFT0C()); + return false; + if (collision.posZ() < -cfgCutVertex || collision.posZ() > cfgCutVertex) + return false; + if (removeITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) + return false; + if (removeNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) + return false; + if (requireIsGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) + return false; + if (requireIsVertexITSTPC && !collision.selection_bit(aod::evsel::kIsVertexITSTPC)) + return false; + if (removeNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) + return false; + + return true; + } - for (auto& track : tracks) { - const auto particle = track.mcParticle(); - if (!particle.isPhysicalPrimary()) - continue; + //*********************************************************************************** - int pdgbin = 0; - switch (particle.pdgCode()) { - case +211: - histPDG->AddBinContent(1); - pdgbin = 0; - break; - case -211: - histPDG->AddBinContent(2); - pdgbin = 1; - break; - case +321: - histPDG->AddBinContent(3); - pdgbin = 2; - break; - case -321: - histPDG->AddBinContent(4); - pdgbin = 3; - break; - case +2212: - histPDG->AddBinContent(5); - pdgbin = 4; - break; - case -2212: - histPDG->AddBinContent(6); - pdgbin = 5; - break; - case +1000010020: - histPDG->AddBinContent(7); - pdgbin = 6; - break; - case -1000010020: - histPDG->AddBinContent(8); - pdgbin = 7; - break; - case +1000010030: - histPDG->AddBinContent(9); - pdgbin = 8; - break; - case -1000010030: - histPDG->AddBinContent(10); - pdgbin = 9; - break; - case +1000020030: - histPDG->AddBinContent(11); - pdgbin = 10; - break; - case -1000020030: - histPDG->AddBinContent(12); - pdgbin = 11; - break; - case +1000020040: - histPDG->AddBinContent(13); - pdgbin = 12; - break; - case -1000020040: - histPDG->AddBinContent(14); - pdgbin = 13; - break; - default: - continue; - } + template + bool isTrackSelected(trackType& track) + { + if (!track.has_mcParticle()) + return false; + + const auto mcParticle = track.mcParticle(); + if (!isInAcceptance(mcParticle)) + return false; // pt eta phi y + if (!track.has_collision()) + return false; + + float TPCnumberClsFound = track.tpcNClsFound(); + float TPC_nCls_Crossed_Rows = track.tpcNClsCrossedRows(); + float RatioCrossedRowsOverFindableTPC = track.tpcCrossedRowsOverFindableCls(); + float Chi2perClusterTPC = track.tpcChi2NCl(); + float Chi2perClusterITS = track.itsChi2NCl(); + + bool insideDCAxy = (std::abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / pow(track.pt(), 1.1f)))); + + if (!(insideDCAxy) || TMath::Abs(track.dcaZ()) > maxDCA_Z || TPCnumberClsFound < minTPCnClsFound || TPC_nCls_Crossed_Rows < minNCrossedRowsTPC || RatioCrossedRowsOverFindableTPC < minRatioCrossedRowsTPC || RatioCrossedRowsOverFindableTPC > maxRatioCrossedRowsTPC || Chi2perClusterTPC > maxChi2PerClusterTPC || Chi2perClusterTPC < minChi2PerClusterTPC || Chi2perClusterITS > maxChi2PerClusterITS || !(track.passedTPCRefit()) || !(track.passedITSRefit()) || (track.itsNClsInnerBarrel()) < minReqClusterITSib || (track.itsNCls()) < minReqClusterITS) + return false; + if ((requireITS && !(track.hasITS())) || (requireTPC && !(track.hasTPC()))) + return false; + if (requireGoldenChi2 && !(track.passedGoldenChi2())) + return false; + + return true; + } - TLorentzVector lorentzVector_pion{}; - TLorentzVector lorentzVector_kaon{}; - TLorentzVector lorentzVector_proton{}; - TLorentzVector lorentzVector_deuteron{}; - TLorentzVector lorentzVector_triton{}; - TLorentzVector lorentzVector_He3{}; - TLorentzVector lorentzVector_He4{}; - - lorentzVector_pion.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassPiPlus); - lorentzVector_kaon.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassKPlus); - lorentzVector_proton.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassProton); - lorentzVector_deuteron.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassDeuteron); - lorentzVector_triton.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassTriton); - lorentzVector_He3.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassHelium3); - lorentzVector_He4.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassAlpha); - - if (lorentzVector_pion.Rapidity() < yMin_reco || lorentzVector_pion.Rapidity() > yMax_reco || - lorentzVector_kaon.Rapidity() < yMin_reco || lorentzVector_kaon.Rapidity() > yMax_reco || - lorentzVector_proton.Rapidity() < yMin_reco || lorentzVector_proton.Rapidity() > yMax_reco || - lorentzVector_deuteron.Rapidity() < yMin_reco || lorentzVector_deuteron.Rapidity() > yMax_reco || - lorentzVector_triton.Rapidity() < yMin_reco || lorentzVector_triton.Rapidity() > yMax_reco || - lorentzVector_He3.Rapidity() < yMin_reco || lorentzVector_He3.Rapidity() > yMax_reco || - lorentzVector_He4.Rapidity() < yMin_reco || lorentzVector_He4.Rapidity() > yMax_reco) - continue; + //*********************************************************************************** + using CollisionCandidates = o2::soa::Join; + using CollisionCandidatesMC = o2::soa::Join; + using TrackCandidates = o2::soa::Join; + using TrackCandidatesMC = o2::soa::Join; + + SliceCache cache; + Preslice perCollision = o2::aod::track::collisionId; + Preslice perCollisionMc = o2::aod::mcparticle::mcCollisionId; + PresliceUnsorted collPerCollMc = o2::aod::mccollisionlabel::mcCollisionId; + + void processMC(o2::aod::McCollisions const& mcCollisions, + // o2::soa::SmallGroups const& collisions, + CollisionCandidatesMC const& collisions, + TrackCandidatesMC const& tracks, + o2::aod::McParticles const& mcParticles) + { + /// loop over generated collisions + for (const auto& mcCollision : mcCollisions) { - float TPCnumberClsFound = track.tpcNClsFound(); - float TPC_nCls_Crossed_Rows = track.tpcNClsCrossedRows(); - float RatioCrossedRowsOverFindableTPC = track.tpcCrossedRowsOverFindableCls(); - float Chi2perClusterTPC = track.tpcChi2NCl(); - float Chi2perClusterITS = track.itsChi2NCl(); + const auto groupedCollisions = collisions.sliceBy(collPerCollMc, mcCollision.globalIndex()); + const auto groupedMcParticles = mcParticles.sliceBy(perCollisionMc, mcCollision.globalIndex()); - if (TPCnumberClsFound < minTPCnClsFound || TPC_nCls_Crossed_Rows < minNCrossedRowsTPC || RatioCrossedRowsOverFindableTPC < minRatioCrossedRowsTPC || RatioCrossedRowsOverFindableTPC > maxRatioCrossedRowsTPC || Chi2perClusterTPC > maxChi2TPC || Chi2perClusterITS > maxChi2ITS || !(track.passedTPCRefit()) || !(track.passedITSRefit()) || (track.itsNClsInnerBarrel()) < minReqClusterITSib || (track.itsNCls()) < minReqClusterITS || TMath::Abs(track.dcaXY()) > maxDCA_XY || TMath::Abs(track.dcaZ()) > maxDCA_Z) + if (groupedCollisions.size() < 1) continue; + float centrality = -1.; - if (use_pT_cut) { - if (track.pt() < pTmin_reco || track.pt() > pTmax_reco) + /// loop over reconstructed collisions + for (const auto& collision : groupedCollisions) { + if (!isCollisionSelected(collision)) continue; - } else { - if (track.p() < pmin_reco || track.p() > pmax_reco) + + centrality = collision.centFT0C(); + if (centrality < minCentrality || centrality > maxCentrality) continue; - } - MC_recon_reg.fill(HIST("histPhi"), track.phi(), pdgbin); - MC_recon_reg.fill(HIST("histEta"), track.eta(), pdgbin); - - if ((particle.pdgCode() == 1000020030) || (particle.pdgCode() == -1000020030) || (particle.pdgCode() == 1000020040) || (particle.pdgCode() == -1000020040)) { - if (track.hasITS()) { - MC_recon_reg.fill(HIST("hist_rec_ITS_vs_p"), track.p() * 2, pdgbin); - MC_recon_reg.fill(HIST("hist_rec_ITS_vs_pT"), track.pt() * 2, pdgbin); - if (track.hasTPC()) { - MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_vs_p"), track.p() * 2, pdgbin); - MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_vs_pT"), track.pt() * 2, pdgbin); - if (track.hasTOF()) { - MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_TOF_vs_p"), track.p() * 2, pdgbin); - MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_TOF_vs_pT"), track.pt() * 2, pdgbin); - } + MC_recon_reg.fill(HIST("histCentrality"), centrality); + MC_recon_reg.fill(HIST("histRecVtxMC"), collision.posZ()); + + const auto groupedTracks = tracks.sliceBy(perCollision, collision.globalIndex()); + + // Track loop + for (const auto& track : groupedTracks) { + if (!isTrackSelected(track)) + continue; + + const auto& particle = track.mcParticle(); + // TLorentzVector lorentzVector_particle_MC{}; + + int pdgbin = -10; + switch (particle.pdgCode()) { + case +211: + histPDG_reco->AddBinContent(1); + pdgbin = 0; + break; + case -211: + histPDG_reco->AddBinContent(2); + pdgbin = 1; + break; + case +321: + histPDG_reco->AddBinContent(3); + pdgbin = 2; + break; + case -321: + histPDG_reco->AddBinContent(4); + pdgbin = 3; + break; + case +2212: + histPDG_reco->AddBinContent(5); + pdgbin = 4; + break; + case -2212: + histPDG_reco->AddBinContent(6); + pdgbin = 5; + break; + case +1000010020: + histPDG_reco->AddBinContent(7); + pdgbin = 6; + break; + case -1000010020: + histPDG_reco->AddBinContent(8); + pdgbin = 7; + break; + case +1000010030: + histPDG_reco->AddBinContent(9); + pdgbin = 8; + break; + case -1000010030: + histPDG_reco->AddBinContent(10); + pdgbin = 9; + break; + case +1000020030: + histPDG_reco->AddBinContent(11); + pdgbin = 10; + break; + case -1000020030: + histPDG_reco->AddBinContent(12); + pdgbin = 11; + break; + case +1000020040: + histPDG_reco->AddBinContent(13); + pdgbin = 12; + break; + case -1000020040: + histPDG_reco->AddBinContent(14); + pdgbin = 13; + break; + default: + pdgbin = -10; + continue; + break; } - } - } else { - if (track.hasITS()) { - MC_recon_reg.fill(HIST("hist_rec_ITS_vs_p"), track.p(), pdgbin); - MC_recon_reg.fill(HIST("hist_rec_ITS_vs_pT"), track.pt(), pdgbin); - if (track.hasTPC()) { - MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_vs_p"), track.p(), pdgbin); - MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_vs_pT"), track.pt(), pdgbin); - if (track.hasTOF()) { - MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_TOF_vs_p"), track.p(), pdgbin); - MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_TOF_vs_pT"), track.pt(), pdgbin); + + MC_recon_reg.fill(HIST("histPhi"), track.phi(), pdgbin); + MC_recon_reg.fill(HIST("histEta"), track.eta(), pdgbin); + + if ((particle.pdgCode() == 1000020030) || (particle.pdgCode() == -1000020030) || (particle.pdgCode() == 1000020040) || (particle.pdgCode() == -1000020040)) { + if (track.hasITS()) { + MC_recon_reg.fill(HIST("hist_rec_ITS_vs_p"), track.p() * 2, pdgbin); + MC_recon_reg.fill(HIST("hist_rec_ITS_vs_pT"), track.pt() * 2, pdgbin); + if (track.hasTPC()) { + MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_vs_p"), track.p() * 2, pdgbin); + MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_vs_pT"), track.pt() * 2, pdgbin); + if (track.hasTOF()) { + MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_TOF_vs_p"), track.p() * 2, pdgbin); + MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_TOF_vs_pT"), track.pt() * 2, pdgbin); + } + } } - } - } - } - if (calc_cent) { - if ((particle.pdgCode() == 1000020030) || (particle.pdgCode() == -1000020030) || (particle.pdgCode() == 1000020040) || (particle.pdgCode() == -1000020040)) { - if (track.hasITS()) { - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_vs_p_cent"), track.p() * 2, pdgbin, collision.centFT0C()); - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_vs_pT_cent"), track.pt() * 2, pdgbin, collision.centFT0C()); - if (track.hasTPC()) { - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_TPC_vs_p_cent"), track.p() * 2, pdgbin, collision.centFT0C()); - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_TPC_vs_pT_cent"), track.pt() * 2, pdgbin, collision.centFT0C()); - if (track.hasTOF()) { - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_TPC_TOF_vs_p_cent"), track.p() * 2, pdgbin, collision.centFT0C()); - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_TPC_TOF_vs_pT_cent"), track.pt() * 2, pdgbin, collision.centFT0C()); + } else { + if (track.hasITS()) { + MC_recon_reg.fill(HIST("hist_rec_ITS_vs_p"), track.p(), pdgbin); + MC_recon_reg.fill(HIST("hist_rec_ITS_vs_pT"), track.pt(), pdgbin); + if (track.hasTPC()) { + MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_vs_p"), track.p(), pdgbin); + MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_vs_pT"), track.pt(), pdgbin); + if (track.hasTOF()) { + MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_TOF_vs_p"), track.p(), pdgbin); + MC_recon_reg.fill(HIST("hist_rec_ITS_TPC_TOF_vs_pT"), track.pt(), pdgbin); + } } } } + } + + // Skipping collisions without the generated collisions + // Actually this should never happen, since we group per MC collision + if (!collision.has_mcCollision()) { + continue; } else { - if (track.hasITS()) { - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_vs_p_cent"), track.p(), pdgbin, collision.centFT0C()); - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_vs_pT_cent"), track.pt(), pdgbin, collision.centFT0C()); - if (track.hasTPC()) { - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_TPC_vs_p_cent"), track.p(), pdgbin, collision.centFT0C()); - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_TPC_vs_pT_cent"), track.pt(), pdgbin, collision.centFT0C()); - if (track.hasTOF()) { - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_TPC_TOF_vs_p_cent"), track.p(), pdgbin, collision.centFT0C()); - MC_recon_reg_cent.fill(HIST("hist_rec_ITS_TPC_TOF_vs_pT_cent"), track.pt(), pdgbin, collision.centFT0C()); - } - } + // skip generated collisions outside the allowed vtx-z range + // putting this condition here avoids the particle loop a few lines below + if (applyPvZCutGenColl) { + const float genPvZ = mcCollision.posZ(); + if (genPvZ < -cfgCutVertex || genPvZ > cfgCutVertex) + continue; } } - } - } - } - //**************************************************************************************************** + MC_gen_reg.fill(HIST("histGenVtxMC_reco"), mcCollision.posZ()); + MC_gen_reg.fill(HIST("histCentrality_reco"), centrality); + + /// only to fill denominator of ITS-TPC matched primary tracks only in MC events with at least 1 reco. vtx + for (const auto& particle : groupedMcParticles) { // Particle loop + + /// require generated particle in acceptance + if (!isInAcceptance(particle)) + continue; + + int pdgbin = -10; + switch (particle.pdgCode()) { + case +211: + histPDG_gen_reco->AddBinContent(1); + pdgbin = 0; + break; + case -211: + histPDG_gen_reco->AddBinContent(2); + pdgbin = 1; + break; + case +321: + histPDG_gen_reco->AddBinContent(3); + pdgbin = 2; + break; + case -321: + histPDG_gen_reco->AddBinContent(4); + pdgbin = 3; + break; + case +2212: + histPDG_gen_reco->AddBinContent(5); + pdgbin = 4; + break; + case -2212: + histPDG_gen_reco->AddBinContent(6); + pdgbin = 5; + break; + case +1000010020: + histPDG_gen_reco->AddBinContent(7); + pdgbin = 6; + break; + case -1000010020: + histPDG_gen_reco->AddBinContent(8); + pdgbin = 7; + break; + case +1000010030: + histPDG_gen_reco->AddBinContent(9); + pdgbin = 8; + break; + case -1000010030: + histPDG_gen_reco->AddBinContent(10); + pdgbin = 9; + break; + case +1000020030: + histPDG_gen_reco->AddBinContent(11); + pdgbin = 10; + break; + case -1000020030: + histPDG_gen_reco->AddBinContent(12); + pdgbin = 11; + break; + case +1000020040: + histPDG_gen_reco->AddBinContent(13); + pdgbin = 12; + break; + case -1000020040: + histPDG_gen_reco->AddBinContent(14); + pdgbin = 13; + break; + default: + pdgbin = -10; + continue; + break; + } + MC_gen_reg.fill(HIST("histEta_reco"), particle.eta(), pdgbin); + MC_gen_reg.fill(HIST("hist_gen_reco_p"), particle.p(), pdgbin); + MC_gen_reg.fill(HIST("hist_gen_reco_pT"), particle.pt(), pdgbin); + } + } /// end loop over reconstructed collisions - void processMCgen(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles) - { - process_MC_gen(mcCollision, mcParticles); - } - PROCESS_SWITCH(NucleiEfficiencyTask, processMCgen, "process generated MC", true); + // skip generated collisions outside the allowed vtx-z range + // putting this condition here avoids the particle loop a few lines below + if (applyPvZCutGenColl) { + const float genPvZ = mcCollision.posZ(); + if (genPvZ < -cfgCutVertex || genPvZ > cfgCutVertex) { + continue; + } + } - Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVertex); - Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta && requireGlobalTrackWoDCAInFilter()); + // Loop on particles to fill the denominator + for (const auto& mcParticle : groupedMcParticles) { + if (!isInAcceptance(mcParticle)) + continue; - void processMCreco(soa::Join::iterator const& collision, - soa::Filtered> const& tracks, - aod::McParticles const& mcParticles) - { - process_MC_reco(collision, tracks, mcParticles); + MC_gen_reg.fill(HIST("histGenVtxMC"), mcCollision.posZ()); + // MC_gen_reg.fill(HIST("histCentrality"), mcParticle.impactParameter()); + + int pdgbin = -10; + switch (mcParticle.pdgCode()) { + case +211: + histPDG_gen->AddBinContent(1); + pdgbin = 0; + break; + case -211: + histPDG_gen->AddBinContent(2); + pdgbin = 1; + break; + case +321: + histPDG_gen->AddBinContent(3); + pdgbin = 2; + break; + case -321: + histPDG_gen->AddBinContent(4); + pdgbin = 3; + break; + case +2212: + histPDG_gen->AddBinContent(5); + pdgbin = 4; + break; + case -2212: + histPDG_gen->AddBinContent(6); + pdgbin = 5; + break; + case +1000010020: + histPDG_gen->AddBinContent(7); + pdgbin = 6; + break; + case -1000010020: + histPDG_gen->AddBinContent(8); + pdgbin = 7; + break; + case +1000010030: + histPDG_gen->AddBinContent(9); + pdgbin = 8; + break; + case -1000010030: + histPDG_gen->AddBinContent(10); + pdgbin = 9; + break; + case +1000020030: + histPDG_gen->AddBinContent(11); + pdgbin = 10; + break; + case -1000020030: + histPDG_gen->AddBinContent(12); + pdgbin = 11; + break; + case +1000020040: + histPDG_gen->AddBinContent(13); + pdgbin = 12; + break; + case -1000020040: + histPDG_gen->AddBinContent(14); + pdgbin = 13; + break; + default: + pdgbin = -10; + continue; + break; + } + + MC_gen_reg.fill(HIST("histPhi"), mcParticle.phi(), pdgbin); + MC_gen_reg.fill(HIST("histEta"), mcParticle.eta(), pdgbin); + MC_gen_reg.fill(HIST("histRapid"), mcParticle.y(), pdgbin); + MC_gen_reg.fill(HIST("hist_gen_p"), mcParticle.p(), pdgbin); + MC_gen_reg.fill(HIST("hist_gen_pT"), mcParticle.pt(), pdgbin); + } + } /// end loop over generated collisions } - PROCESS_SWITCH(NucleiEfficiencyTask, processMCreco, "process reconstructed MC", false); + PROCESS_SWITCH(NucleiEfficiencyTask, processMC, "process generated MC", true); }; -//**************************************************************************************************** +//*********************************************************************************** WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGLF/Tasks/Nuspex/NucleiHistTask.cxx b/PWGLF/Tasks/Nuspex/NucleiHistTask.cxx index cf97c14939d..e3152c05cfb 100644 --- a/PWGLF/Tasks/Nuspex/NucleiHistTask.cxx +++ b/PWGLF/Tasks/Nuspex/NucleiHistTask.cxx @@ -99,16 +99,16 @@ struct NucleiHistTask { histTrackcuts_data_particle->GetXaxis()->SetBinLabel(1, "Events read"); histTrackcuts_data_particle->GetXaxis()->SetBinLabel(2, "Ev. sel. passed"); histTrackcuts_data_particle->GetXaxis()->SetBinLabel(3, "Rap. cut passed"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(4, "DCA cut passed"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(5, "TPCnCls cut passed"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(6, "TPCCrossedRowsOverFindable cut passed"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(7, "Chi2 cut passed"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(8, "Passed TPC refit cut"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(9, "Passed ITS refit cut"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(10, "ITSnCls cut passed"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(11, "track.pt() cut passed"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(12, "hasITS & hasTPC cut passed"); - histTrackcuts_data_particle->GetXaxis()->SetBinLabel(13, "GoldenChi2 cut passed"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(4, "TPCnCls cut passed"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(5, "TPCCrossedRowsOverFindable cut passed"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(6, "Chi2 cut passed"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(7, "Passed TPC refit cut"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(8, "Passed ITS refit cut"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(9, "ITSnCls cut passed"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(10, "track.pt() cut passed"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(11, "hasITS & hasTPC cut passed"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(12, "GoldenChi2 cut passed"); + histTrackcuts_data_particle->GetXaxis()->SetBinLabel(13, "DCA cut passed"); // +++++++++++++++++++ reconstructed MC ++++++++++++++++++++++ histTrackcuts_MC->GetXaxis()->SetBinLabel(1, "Events read"); @@ -141,9 +141,9 @@ struct NucleiHistTask { spectra_reg.add("histRecVtxZData", "collision z position", HistType::kTH1F, {{200, -20., +20., "z position (cm)"}}); spectra_reg.add("histTpcSignalData", "Specific energy loss", HistType::kTH2F, {{600, -6., 6., "#it{p*} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); spectra_reg.add("histTofSignalData", "TOF signal", HistType::kTH2F, {{600, -6., 6., "#it{p*} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - spectra_reg.add("histDcaVsPtData_particle", "dcaXY vs Pt (particle)", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + spectra_reg.add("histDcaVsPtData_particle", "dcaXY vs Pt (particle)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); spectra_reg.add("histDcaZVsPtData_particle", "dcaZ vs Pt (particle)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); - spectra_reg.add("histDcaVsPtData_antiparticle", "dcaXY vs Pt (antiparticle)", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + spectra_reg.add("histDcaVsPtData_antiparticle", "dcaXY vs Pt (antiparticle)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); spectra_reg.add("histDcaZVsPtData_antiparticle", "dcaZ vs Pt (antiparticle)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); spectra_reg.add("histTOFm2", "TOF m^2 vs P", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); spectra_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); @@ -159,8 +159,10 @@ struct NucleiHistTask { // histograms for pi⁺ pion_reg.add("histTpcSignalData", "Specific energy loss (#pi^{+})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); pion_reg.add("histTofSignalData", "TOF signal (#pi^{+})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - pion_reg.add("histDcaVsPtData", "dcaXY vs Pt (#pi^{+})", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + pion_reg.add("histDcaVsPtData", "dcaXY vs Pt (#pi^{+})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); pion_reg.add("histDcaZVsPtData", "dcaZ vs Pt (#pi^{+})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + pion_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (#pi^{+}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + pion_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (#pi^{+}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); pion_reg.add("histTOFm2", "TOF m^2 vs Pt (#pi^{+})", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); pion_reg.add("histTpcNsigmaData", "n-sigma TPC (#pi^{+})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); pion_reg.add("histTofNsigmaData", "n-sigma TOF (#pi^{+})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); @@ -179,8 +181,10 @@ struct NucleiHistTask { // histograms for pi⁻ apion_reg.add("histTpcSignalData", "Specific energy loss (#pi^{-})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); apion_reg.add("histTofSignalData", "TOF signal (#pi^{-})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - apion_reg.add("histDcaVsPtData", "dcaXY vs Pt (#pi^{-})", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + apion_reg.add("histDcaVsPtData", "dcaXY vs Pt (#pi^{-})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); apion_reg.add("histDcaZVsPtData", "dcaZ vs Pt (#pi^{-})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + apion_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (#pi^{-}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + apion_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (#pi^{-}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); apion_reg.add("histTOFm2", "TOF m^2 vs Pt (#pi^{-})", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); apion_reg.add("histTpcNsigmaData", "n-sigma TPC (#pi^{-})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); apion_reg.add("histTofNsigmaData", "n-sigma TOF (#pi^{-})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); @@ -199,8 +203,10 @@ struct NucleiHistTask { // histograms for Proton proton_reg.add("histTpcSignalData", "Specific energy loss (p)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); proton_reg.add("histTofSignalData", "TOF signal (p)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - proton_reg.add("histDcaVsPtData", "dcaXY vs Pt (p)", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + proton_reg.add("histDcaVsPtData", "dcaXY vs Pt (p)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); proton_reg.add("histDcaZVsPtData", "dcaZ vs Pt (p)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + proton_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (p) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + proton_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (p) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); proton_reg.add("histTOFm2", "TOF m^2 vs Pt (p)", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); proton_reg.add("histTpcNsigmaData", "n-sigma TPC (p)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{p}"}}); proton_reg.add("histTofNsigmaData", "n-sigma TOF (p)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{p}"}}); @@ -219,8 +225,10 @@ struct NucleiHistTask { // histograms for antiProton aproton_reg.add("histTpcSignalData", "Specific energy loss (#bar{p})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); aproton_reg.add("histTofSignalData", "TOF signal (#bar{p})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - aproton_reg.add("histDcaVsPtData", "dcaXY vs Pt (#bar{p})", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + aproton_reg.add("histDcaVsPtData", "dcaXY vs Pt (#bar{p})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); aproton_reg.add("histDcaZVsPtData", "dcaZ vs Pt (#bar{p})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + aproton_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (#bar{p}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + aproton_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (#bar{p}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); aproton_reg.add("histTOFm2", "TOF m^2 vs Pt (#bar{p})", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); aproton_reg.add("histTpcNsigmaData", "n-sigma TPC (#bar{p})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#bar{p}}"}}); aproton_reg.add("histTofNsigmaData", "n-sigma TOF (#bar{p})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#bar{p}}"}}); @@ -239,8 +247,10 @@ struct NucleiHistTask { // histograms for Deuterons deuteron_reg.add("histTpcSignalData", "Specific energy loss (d)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); deuteron_reg.add("histTofSignalData", "TOF signal (d)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - deuteron_reg.add("histDcaVsPtData", "dcaXY vs Pt (d)", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + deuteron_reg.add("histDcaVsPtData", "dcaXY vs Pt (d)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); deuteron_reg.add("histDcaZVsPtData", "dcaZ vs Pt (d)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + deuteron_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (d) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + deuteron_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (d) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); deuteron_reg.add("histTOFm2", "TOF m^2 vs Pt (d)", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); deuteron_reg.add("histTpcNsigmaData", "n-sigma TPC (d)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{d}"}}); deuteron_reg.add("histTofNsigmaData", "n-sigma TOF (d)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{d}"}}); @@ -259,8 +269,10 @@ struct NucleiHistTask { // histograms for antiDeuterons adeuteron_reg.add("histTpcSignalData", "Specific energy loss (#bar{d})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); adeuteron_reg.add("histTofSignalData", "TOF signal (#bar{d})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - adeuteron_reg.add("histDcaVsPtData", "dcaXY vs Pt (#bar{d})", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + adeuteron_reg.add("histDcaVsPtData", "dcaXY vs Pt (#bar{d})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); adeuteron_reg.add("histDcaZVsPtData", "dcaZ vs Pt (#bar{d})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + adeuteron_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (#bar{d}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + adeuteron_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (#bar{d}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); adeuteron_reg.add("histTOFm2", "TOF m^2 vs Pt (#bar{d})", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); adeuteron_reg.add("histTpcNsigmaData", "n-sigma TPC (#bar{d})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#bar{d}}"}}); adeuteron_reg.add("histTofNsigmaData", "n-sigma TOF (#bar{d})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#bar{d}}"}}); @@ -279,8 +291,10 @@ struct NucleiHistTask { // histograms for Triton triton_reg.add("histTpcSignalData", "Specific energy loss (t)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); triton_reg.add("histTofSignalData", "TOF signal (t)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - triton_reg.add("histDcaVsPtData", "dcaXY vs Pt (t)", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + triton_reg.add("histDcaVsPtData", "dcaXY vs Pt (t)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); triton_reg.add("histDcaZVsPtData", "dcaZ vs Pt (t)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + triton_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (t) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + triton_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (t) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); triton_reg.add("histTOFm2", "TOF m^2 vs Pt (t)", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); triton_reg.add("histTpcNsigmaData", "n-sigma TPC (t)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{t}"}}); triton_reg.add("histTofNsigmaData", "n-sigma TOF (t)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{t}"}}); @@ -299,8 +313,10 @@ struct NucleiHistTask { // histograms for antiTriton atriton_reg.add("histTpcSignalData", "Specific energy loss (#bar{t})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); atriton_reg.add("histTofSignalData", "TOF signal (#bar{t})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - atriton_reg.add("histDcaVsPtData", "dcaXY vs Pt (#bar{t})", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + atriton_reg.add("histDcaVsPtData", "dcaXY vs Pt (#bar{t})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); atriton_reg.add("histDcaZVsPtData", "dcaZ vs Pt (#bar{t})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + atriton_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (#bar{t}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + atriton_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (#bar{t}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); atriton_reg.add("histTOFm2", "TOF m^2 vs Pt (#bar{t})", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); atriton_reg.add("histTpcNsigmaData", "n-sigma TPC (#bar{t})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#bar{t}}"}}); atriton_reg.add("histTofNsigmaData", "n-sigma TOF (#bar{t})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{#bar{t}}"}}); @@ -319,8 +335,10 @@ struct NucleiHistTask { // histograms for Helium-3 Helium3_reg.add("histTpcSignalData", "Specific energy loss (^{3}He)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); Helium3_reg.add("histTofSignalData", "TOF signal (^{3}He)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - Helium3_reg.add("histDcaVsPtData", "dcaXY vs Pt (^{3}He)", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + Helium3_reg.add("histDcaVsPtData", "dcaXY vs Pt (^{3}He)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); Helium3_reg.add("histDcaZVsPtData", "dcaZ vs Pt (^{3}He)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + Helium3_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (^{3}He) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + Helium3_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (^{3}He) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); Helium3_reg.add("histTOFm2", "TOF m^2 vs Pt (^{3}He)", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); Helium3_reg.add("histTpcNsigmaData", "n-sigma TPC (^{3}He)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); Helium3_reg.add("histTofNsigmaData", "n-sigma TOF (^{3}He)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); @@ -339,8 +357,10 @@ struct NucleiHistTask { // histograms for antiHelium-3 aHelium3_reg.add("histTpcSignalData", "Specific energy loss (^{3}#bar{He})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); aHelium3_reg.add("histTofSignalData", "TOF signal (^{3}#bar{He})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - aHelium3_reg.add("histDcaVsPtData", "dcaXY vs Pt (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + aHelium3_reg.add("histDcaVsPtData", "dcaXY vs Pt (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); aHelium3_reg.add("histDcaZVsPtData", "dcaZ vs Pt (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + aHelium3_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (^{3}#bar{He}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + aHelium3_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (^{3}#bar{He}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); aHelium3_reg.add("histTOFm2", "TOF m^2 vs Pt (^{3}#bar{He})", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); aHelium3_reg.add("histTpcNsigmaData", "n-sigma TPC (^{3}#bar{He})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); aHelium3_reg.add("histTofNsigmaData", "n-sigma TOF (^{3}#bar{He})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); @@ -359,8 +379,10 @@ struct NucleiHistTask { // histograms for Helium-4 (alpha) Helium4_reg.add("histTpcSignalData", "Specific energy loss (^{4}He)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); Helium4_reg.add("histTofSignalData", "TOF signal (^{4}He)", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - Helium4_reg.add("histDcaVsPtData", "dcaXY vs Pt (^{4}He)", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + Helium4_reg.add("histDcaVsPtData", "dcaXY vs Pt (^{4}He)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); Helium4_reg.add("histDcaZVsPtData", "dcaZ vs Pt (^{4}He)", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + Helium4_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (^{4}He) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + Helium4_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (^{4}He) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); Helium4_reg.add("histTOFm2", "TOF m^2 vs Pt (^{4}He)", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); Helium4_reg.add("histTpcNsigmaData", "n-sigma TPC (^{4}He)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{^{4}He}"}}); Helium4_reg.add("histTofNsigmaData", "n-sigma TOF (^{4}He)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{^{4}He}"}}); @@ -379,8 +401,10 @@ struct NucleiHistTask { // histograms for antiHelium-4 (alpha) aHelium4_reg.add("histTpcSignalData", "Specific energy loss (^{4}#bar{He})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); aHelium4_reg.add("histTofSignalData", "TOF signal (^{4}#bar{He})", HistType::kTH2F, {{600, 0., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - aHelium4_reg.add("histDcaVsPtData", "dcaXY vs Pt (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + aHelium4_reg.add("histDcaVsPtData", "dcaXY vs Pt (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); aHelium4_reg.add("histDcaZVsPtData", "dcaZ vs Pt (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + aHelium4_reg.add("histDcaVsPtData_after_cut", "dcaXY vs Pt (^{4}#bar{He}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + aHelium4_reg.add("histDcaZVsPtData_after_cut", "dcaZ vs Pt (^{4}#bar{He}) after cut", HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); aHelium4_reg.add("histTOFm2", "TOF m^2 vs Pt (^{4}#bar{He})", HistType::kTH2F, {pAxis, {400, 0.0, 10.0, "m^2"}}); aHelium4_reg.add("histTpcNsigmaData", "n-sigma TPC (^{4}#bar{He})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{antiHe-4}"}}); aHelium4_reg.add("histTofNsigmaData", "n-sigma TOF (^{4}#bar{He})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{antiHe-4}"}}); @@ -409,7 +433,7 @@ struct NucleiHistTask { MC_recon_reg.add("histCentrality", "Centrality", HistType::kTH1F, {centralityAxis}); MC_recon_reg.add("histEta", "#eta", HistType::kTH2F, {{102, -2.01, 2.01}, PDGBINNING}); MC_recon_reg.add("histPt", "p_{t}", HistType::kTH2F, {ptAxis, PDGBINNING}); - MC_recon_reg.add("histDCA", "DCA xy", HistType::kTH3F, {ptAxis, {250, -0.5, 0.5, "dca"}, PDGBINNING}); + MC_recon_reg.add("histDCA", "DCA xy", HistType::kTH3F, {ptAxis, {1000, -2.0, 2.0, "dca"}, PDGBINNING}); MC_recon_reg.add("histDCAz", "DCA z", HistType::kTH3F, {ptAxis, {1000, -2.0, 2.0, "dca"}, PDGBINNING}); MC_recon_reg.add("histTpcSignalData", "Specific energy loss", HistType::kTH3F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}, PDGBINNING}); MC_recon_reg.add("histTofSignalData", "TOF signal", HistType::kTH3F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}, PDGBINNING}); @@ -447,11 +471,12 @@ struct NucleiHistTask { MC_recon_reg.add("histTofNsigmaDataAl", "TOF nSigma (^{4}He)", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{^{4}He}"}}); MC_recon_reg.add("histTofNsigmaDataaAl", "TOF nSigma (^{4}#bar{He})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{^{4}He}"}}); - MC_DCA.add("histDCA_prim", "DCA xy", HistType::kTH3F, {ptAxis, {250, -0.5, 0.5, "dca"}, PDGBINNING}); + MC_DCA.add("histEta", "#eta", HistType::kTH2F, {{204, -2.01, 2.01}, PDGBINNING}); + MC_DCA.add("histDCA_prim", "DCA xy", HistType::kTH3F, {ptAxis, {1000, -2.0, 2.0, "dca"}, PDGBINNING}); MC_DCA.add("histDCAz_prim", "DCA z", HistType::kTH3F, {ptAxis, {1000, -2.0, 2.0, "dca"}, PDGBINNING}); - MC_DCA.add("histDCA_weak", "DCA xy", HistType::kTH3F, {ptAxis, {250, -0.5, 0.5, "dca"}, PDGBINNING}); + MC_DCA.add("histDCA_weak", "DCA xy", HistType::kTH3F, {ptAxis, {1000, -2.0, 2.0, "dca"}, PDGBINNING}); MC_DCA.add("histDCAz_weak", "DCA z", HistType::kTH3F, {ptAxis, {1000, -2.0, 2.0, "dca"}, PDGBINNING}); - MC_DCA.add("histDCA_mat", "DCA xy", HistType::kTH3F, {ptAxis, {250, -0.5, 0.5, "dca"}, PDGBINNING}); + MC_DCA.add("histDCA_mat", "DCA xy", HistType::kTH3F, {ptAxis, {1000, -2.0, 2.0, "dca"}, PDGBINNING}); MC_DCA.add("histDCAz_mat", "DCA z", HistType::kTH3F, {ptAxis, {1000, -2.0, 2.0, "dca"}, PDGBINNING}); } @@ -497,6 +522,7 @@ struct NucleiHistTask { Configurable requireGoldenChi2{"requireGoldenChi2", false, "Enable the requirement of GoldenChi2"}; Configurable event_selection_sel8{"event_selection_sel8", true, "Enable sel8 event selection"}; Configurable event_selection_MC_sel8{"event_selection_MC_sel8", true, "Enable sel8 event selection in MC processing"}; + Configurable require_PhysicalPrimary_MC_reco{"require_PhysicalPrimary_MC_reco", true, "Enable PhysicalPrimary selection in reconstructed MC processing"}; Configurable require_PhysicalPrimary_MC_gen{"require_PhysicalPrimary_MC_gen", true, "Enable PhysicalPrimary selection in generated MC processing"}; Configurable removeITSROFrameBorder{"removeITSROFrameBorder", false, "Remove TF border"}; Configurable removeNoSameBunchPileup{"removeNoSameBunchPileup", false, "Remove TF border"}; @@ -504,6 +530,30 @@ struct NucleiHistTask { Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "Remove TF border"}; Configurable removeNoTimeFrameBorder{"removeNoTimeFrameBorder", false, "Remove TF border"}; + TF1* Particle_Tpc_nSigma_shift = 0; + Configurable enable_pT_shift_tpc_nSigma{"enable_pT_shift_tpc_nSigma", false, "Enable Data TPC nSigma recentering by TF1"}; + Configurable> parShiftPt{"parShiftPt", {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, "Parameters for pT shift."}; + + TF1* Pion_Tpc_nSigma_shift = 0; + TF1* Proton_Tpc_nSigma_shift = 0; + TF1* Deuteron_Tpc_nSigma_shift = 0; + TF1* Triton_Tpc_nSigma_shift = 0; + TF1* He3_Tpc_nSigma_shift = 0; + TF1* He4_Tpc_nSigma_shift = 0; + + Configurable enable_pT_shift_pion_tpc_nSigma{"enable_pT_shift_pion_tpc_nSigma", false, "Enable MC Pi plus TPC nSigma recentering by TF1"}; + Configurable enable_pT_shift_proton_tpc_nSigma{"enable_pT_shift_proton_tpc_nSigma", false, "Enable MC Proton TPC nSigma recentering by TF1"}; + Configurable enable_pT_shift_deuteron_tpc_nSigma{"enable_pT_shift_deuteron_tpc_nSigma", false, "Enable MC Deuteron TPC nSigma recentering by TF1"}; + Configurable enable_pT_shift_triton_tpc_nSigma{"enable_pT_shift_triton_tpc_nSigma", false, "Enable MC Triton TPC nSigma recentering by TF1"}; + Configurable enable_pT_shift_He3_tpc_nSigma{"enable_pT_shift_He3_tpc_nSigma", false, "Enable MC Helium-3 TPC nSigma recentering by TF1"}; + Configurable enable_pT_shift_He4_tpc_nSigma{"enable_pT_shift_He4_tpc_nSigma", false, "Enable MC Helium-4 TPC nSigma recentering by TF1"}; + Configurable> parShiftPtPion{"parShiftPtPion", {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, "MC Parameters for Pi plus pT shift."}; + Configurable> parShiftPtProton{"parShiftPtProton", {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, "MC Parameters for Proton pT shift."}; + Configurable> parShiftPtDeuteron{"parShiftPtDeuteron", {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, "MC Parameters for Deuteron pT shift."}; + Configurable> parShiftPtTriton{"parShiftPtTriton", {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, "MC Parameters for Triton pT shift."}; + Configurable> parShiftPtHe3{"parShiftPtHe3", {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, "MC Parameters for Helium-3 pT shift."}; + Configurable> parShiftPtHe4{"parShiftPtHe4", {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, "MC Parameters for Alpha pT shift."}; + //*********************************************************************************** template @@ -612,6 +662,12 @@ struct NucleiHistTask { if (!isEventSelected(event)) return; + + if (enable_pT_shift_tpc_nSigma) { + Particle_Tpc_nSigma_shift = new TF1("Particle_Tpc_nSigma_shift", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x + [5] * x * x", 0.f, 14.f); + auto par = (std::vector)parShiftPt; + Particle_Tpc_nSigma_shift->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5]); + } for (auto track : tracks) { float TPCnSigma_particle = -100; @@ -675,6 +731,11 @@ struct NucleiHistTask { break; } + if (enable_pT_shift_tpc_nSigma) { + float nSigma_shift = Particle_Tpc_nSigma_shift->Eval(momentum); + TPCnSigma_particle -= nSigma_shift; + } + histTrackcuts_data_particle->AddBinContent(1); if (event_selection_sel8 && !event.sel8()) continue; @@ -689,37 +750,49 @@ struct NucleiHistTask { if (lorentzVector_particle.Rapidity() < yMin || lorentzVector_particle.Rapidity() > yMax) continue; histTrackcuts_data_particle->AddBinContent(3); - - bool insideDCAxy = (std::abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / pow(momentum, 1.1f)))); - - if (!(insideDCAxy) || TMath::Abs(track.dcaZ()) > maxDCA_Z) + if (TPCnumberClsFound < minTPCnClsFound || TPC_nCls_Crossed_Rows < minNCrossedRowsTPC) continue; histTrackcuts_data_particle->AddBinContent(4); - if (TPCnumberClsFound < minTPCnClsFound || TPC_nCls_Crossed_Rows < minNCrossedRowsTPC) + if (RatioCrossedRowsOverFindableTPC < minRatioCrossedRowsTPC || RatioCrossedRowsOverFindableTPC > maxRatioCrossedRowsTPC) continue; histTrackcuts_data_particle->AddBinContent(5); - if (RatioCrossedRowsOverFindableTPC < minRatioCrossedRowsTPC || RatioCrossedRowsOverFindableTPC > maxRatioCrossedRowsTPC) + if (Chi2perClusterTPC > maxChi2PerClusterTPC || Chi2perClusterTPC < minChi2PerClusterTPC || Chi2perClusterITS > maxChi2PerClusterITS) continue; histTrackcuts_data_particle->AddBinContent(6); - if (Chi2perClusterTPC > maxChi2PerClusterTPC || Chi2perClusterTPC < minChi2PerClusterTPC || Chi2perClusterITS > maxChi2PerClusterITS) + if (!(track.passedTPCRefit())) continue; histTrackcuts_data_particle->AddBinContent(7); - if (!(track.passedTPCRefit())) + if (!(track.passedITSRefit())) continue; histTrackcuts_data_particle->AddBinContent(8); - if (!(track.passedITSRefit())) + if ((track.itsNClsInnerBarrel()) < minReqClusterITSib || (track.itsNCls()) < minReqClusterITS) continue; histTrackcuts_data_particle->AddBinContent(9); - if ((track.itsNClsInnerBarrel()) < minReqClusterITSib || (track.itsNCls()) < minReqClusterITS) + if (momentum < p_min || momentum > p_max) continue; histTrackcuts_data_particle->AddBinContent(10); - if (momentum < p_min || momentum > p_max) + if ((requireITS && !(track.hasITS())) || (requireTPC && !(track.hasTPC()))) continue; histTrackcuts_data_particle->AddBinContent(11); - if ((requireITS && !(track.hasITS())) || (requireTPC && !(track.hasTPC()))) + if (requireGoldenChi2 && !(track.passedGoldenChi2())) continue; + histTrackcuts_data_particle->AddBinContent(12); - if (requireGoldenChi2 && !(track.passedGoldenChi2())) + + if (TPCnSigma_particle > nsigmacutLow && TPCnSigma_particle < nsigmacutHigh) { + if (track.sign() > 0) { + particle_reg.fill(HIST("histDcaVsPtData"), momentum, track.dcaXY()); + particle_reg.fill(HIST("histDcaZVsPtData"), momentum, track.dcaZ()); + } + if (track.sign() < 0) { + aparticle_reg.fill(HIST("histDcaVsPtData"), momentum, track.dcaXY()); + aparticle_reg.fill(HIST("histDcaZVsPtData"), momentum, track.dcaZ()); + } + } + + bool insideDCAxy = (std::abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / pow(momentum, 1.1f)))); + + if (!(insideDCAxy) || TMath::Abs(track.dcaZ()) > maxDCA_Z) continue; histTrackcuts_data_particle->AddBinContent(13); @@ -735,8 +808,8 @@ struct NucleiHistTask { if (TPCnSigma_particle > nsigmacutLow && TPCnSigma_particle < nsigmacutHigh) { if (track.sign() > 0) { - particle_reg.fill(HIST("histDcaVsPtData"), momentum, track.dcaXY()); - particle_reg.fill(HIST("histDcaZVsPtData"), momentum, track.dcaZ()); + particle_reg.fill(HIST("histDcaVsPtData_after_cut"), momentum, track.dcaXY()); + particle_reg.fill(HIST("histDcaZVsPtData_after_cut"), momentum, track.dcaZ()); particle_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); particle_reg.fill(HIST("histNClusterTPC"), momentum, track.tpcNClsFound()); particle_reg.fill(HIST("histNClusterITS"), momentum, track.itsNCls()); @@ -765,8 +838,8 @@ struct NucleiHistTask { } if (track.sign() < 0) { - aparticle_reg.fill(HIST("histDcaVsPtData"), momentum, track.dcaXY()); - aparticle_reg.fill(HIST("histDcaZVsPtData"), momentum, track.dcaZ()); + aparticle_reg.fill(HIST("histDcaVsPtData_after_cut"), momentum, track.dcaXY()); + aparticle_reg.fill(HIST("histDcaZVsPtData_after_cut"), momentum, track.dcaZ()); aparticle_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); aparticle_reg.fill(HIST("histNClusterTPC"), momentum, track.tpcNClsFound()); aparticle_reg.fill(HIST("histNClusterITS"), momentum, track.itsNCls()); @@ -804,6 +877,13 @@ struct NucleiHistTask { { if (!isEventSelected(event)) return; + + if (enable_pT_shift_tpc_nSigma) { + Particle_Tpc_nSigma_shift = new TF1("Particle_Tpc_nSigma_shift", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x + [5] * x * x", 0.f, 14.f); + auto par = (std::vector)parShiftPt; + Particle_Tpc_nSigma_shift->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5]); + } + if (event_selection_sel8 && event.sel8()) spectra_reg.fill(HIST("histCentrality"), event.centFT0C()); if (!event_selection_sel8) @@ -874,6 +954,11 @@ struct NucleiHistTask { break; } + if (enable_pT_shift_tpc_nSigma) { + float nSigma_shift = Particle_Tpc_nSigma_shift->Eval(momentum); + TPCnSigma_particle -= nSigma_shift; + } + spectra_reg.fill(HIST("histEtaWithOverFlow"), track.eta()); spectra_reg.fill(HIST("histEta_cent"), event.centFT0C(), track.eta()); @@ -1128,152 +1213,123 @@ struct NucleiHistTask { if (!isEventSelected(collisions)) return; + if (enable_pT_shift_pion_tpc_nSigma) { + Pion_Tpc_nSigma_shift = new TF1("Pion_Tpc_nSigma_shift", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x + [5] * x * x", 0.f, 14.f); + auto par = (std::vector)parShiftPtPion; + Pion_Tpc_nSigma_shift->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5]); + } + if (enable_pT_shift_proton_tpc_nSigma) { + Proton_Tpc_nSigma_shift = new TF1("Proton_Tpc_nSigma_shift", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x + [5] * x * x", 0.f, 14.f); + auto par = (std::vector)parShiftPtProton; + Proton_Tpc_nSigma_shift->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5]); + } + if (enable_pT_shift_deuteron_tpc_nSigma) { + Deuteron_Tpc_nSigma_shift = new TF1("Deuteron_Tpc_nSigma_shift", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x + [5] * x * x", 0.f, 14.f); + auto par = (std::vector)parShiftPtDeuteron; + Deuteron_Tpc_nSigma_shift->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5]); + } + if (enable_pT_shift_triton_tpc_nSigma) { + Triton_Tpc_nSigma_shift = new TF1("Triton_Tpc_nSigma_shift", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x + [5] * x * x", 0.f, 14.f); + auto par = (std::vector)parShiftPtTriton; + Triton_Tpc_nSigma_shift->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5]); + } + if (enable_pT_shift_He3_tpc_nSigma) { + He3_Tpc_nSigma_shift = new TF1("He3_Tpc_nSigma_shift", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x + [5] * x * x", 0.f, 14.f); + auto par = (std::vector)parShiftPtHe3; + He3_Tpc_nSigma_shift->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5]); + } + if (enable_pT_shift_He4_tpc_nSigma) { + He4_Tpc_nSigma_shift = new TF1("He4_Tpc_nSigma_shift", "[0] * TMath::Exp([1] + [2] * x) + [3] + [4] * x + [5] * x * x", 0.f, 14.f); + auto par = (std::vector)parShiftPtHe4; + He4_Tpc_nSigma_shift->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5]); + } + for (auto& track : tracks) { histTrackcuts_MC->AddBinContent(1); const auto particle = track.mcParticle(); int pdgbin = 0; - switch (particle.pdgCode()) { - case +211: - pdgbin = 0; - break; - case -211: - pdgbin = 1; - break; - case +321: - pdgbin = 2; - break; - case -321: - pdgbin = 3; - break; - case +2212: - pdgbin = 4; - break; - case -2212: - pdgbin = 5; - break; - case +1000010020: - pdgbin = 6; - break; - case -1000010020: - pdgbin = 7; - break; - case +1000010030: - pdgbin = 8; - break; - case -1000010030: - pdgbin = 9; - break; - case +1000020030: - pdgbin = 10; - break; - case -1000020030: - pdgbin = 11; - break; - case +1000020040: - pdgbin = 12; - break; - case -1000020040: - pdgbin = 13; - break; - default: - pdgbin = -1; - break; - } - - if (particle.isPhysicalPrimary()) { - if ((particle.pdgCode() == 1000020030) || (particle.pdgCode() == -1000020030) || (particle.pdgCode() == 1000020040) || (particle.pdgCode() == -1000020040)) { - MC_DCA.fill(HIST("histDCA_prim"), track.pt() * 2.0, track.dcaXY(), pdgbin); - MC_DCA.fill(HIST("histDCAz_prim"), track.pt() * 2.0, track.dcaZ(), pdgbin); - } else { - MC_DCA.fill(HIST("histDCA_prim"), track.pt(), track.dcaXY(), pdgbin); - MC_DCA.fill(HIST("histDCAz_prim"), track.pt(), track.dcaZ(), pdgbin); - } - } else if (particle.has_mothers()) { - if ((particle.pdgCode() == 1000020030) || (particle.pdgCode() == -1000020030) || (particle.pdgCode() == 1000020040) || (particle.pdgCode() == -1000020040)) { - MC_DCA.fill(HIST("histDCA_weak"), track.pt() * 2.0, track.dcaXY(), pdgbin); - MC_DCA.fill(HIST("histDCAz_weak"), track.pt() * 2.0, track.dcaZ(), pdgbin); - } else { - MC_DCA.fill(HIST("histDCA_weak"), track.pt(), track.dcaXY(), pdgbin); - MC_DCA.fill(HIST("histDCAz_weak"), track.pt(), track.dcaZ(), pdgbin); - } - } else { - if ((particle.pdgCode() == 1000020030) || (particle.pdgCode() == -1000020030) || (particle.pdgCode() == 1000020040) || (particle.pdgCode() == -1000020040)) { - MC_DCA.fill(HIST("histDCA_mat"), track.pt() * 2.0, track.dcaXY(), pdgbin); - MC_DCA.fill(HIST("histDCAz_mat"), track.pt() * 2.0, track.dcaZ(), pdgbin); - } else { - MC_DCA.fill(HIST("histDCA_mat"), track.pt(), track.dcaXY(), pdgbin); - MC_DCA.fill(HIST("histDCAz_mat"), track.pt(), track.dcaZ(), pdgbin); - } - } - - if (!particle.isPhysicalPrimary()) - continue; - histTrackcuts_MC->AddBinContent(2); TLorentzVector lorentzVector_particle_MC{}; - switch (particle.pdgCode()) { case +211: + pdgbin = 0; histPDG_reco->AddBinContent(1); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassPiPlus); break; case -211: + pdgbin = 1; histPDG_reco->AddBinContent(2); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassPiPlus); break; case +321: + pdgbin = 2; histPDG_reco->AddBinContent(3); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassKPlus); break; case -321: + pdgbin = 3; histPDG_reco->AddBinContent(4); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassKPlus); break; case +2212: + pdgbin = 4; histPDG_reco->AddBinContent(5); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassProton); break; case -2212: + pdgbin = 5; histPDG_reco->AddBinContent(6); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassProton); break; case +1000010020: + pdgbin = 6; histPDG_reco->AddBinContent(7); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassDeuteron); break; case -1000010020: + pdgbin = 7; histPDG_reco->AddBinContent(8); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassDeuteron); break; case +1000010030: + pdgbin = 8; histPDG_reco->AddBinContent(9); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassTriton); break; case -1000010030: + pdgbin = 9; histPDG_reco->AddBinContent(10); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassTriton); break; case +1000020030: + pdgbin = 10; histPDG_reco->AddBinContent(11); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassHelium3); break; case -1000020030: + pdgbin = 11; histPDG_reco->AddBinContent(12); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassHelium3); break; case +1000020040: + pdgbin = 12; histPDG_reco->AddBinContent(13); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassAlpha); break; case -1000020040: + pdgbin = 13; histPDG_reco->AddBinContent(14); lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassAlpha); break; default: - continue; + pdgbin = -1; break; } + if (require_PhysicalPrimary_MC_reco && !particle.isPhysicalPrimary()) + continue; + histTrackcuts_MC->AddBinContent(2); + if (lorentzVector_particle_MC.Rapidity() < yMin || lorentzVector_particle_MC.Rapidity() > yMax) continue; histTrackcuts_MC->AddBinContent(3); @@ -1352,6 +1408,31 @@ struct NucleiHistTask { float nSigmaHe3 = track.tpcNSigmaHe(); float nSigmaHe4 = track.tpcNSigmaAl(); + if (enable_pT_shift_pion_tpc_nSigma) { + float nSigmaPion_shift = Pion_Tpc_nSigma_shift->Eval(track.pt()); + nSigmaPion -= nSigmaPion_shift; + } + if (enable_pT_shift_proton_tpc_nSigma) { + float nSigmaProton_shift = Proton_Tpc_nSigma_shift->Eval(track.pt()); + nSigmaProton -= nSigmaProton_shift; + } + if (enable_pT_shift_deuteron_tpc_nSigma) { + float nSigmaDeuteron_shift = Deuteron_Tpc_nSigma_shift->Eval(track.pt()); + nSigmaDeuteron -= nSigmaDeuteron_shift; + } + if (enable_pT_shift_triton_tpc_nSigma) { + float nSigmaTriton_shift = Triton_Tpc_nSigma_shift->Eval(track.pt()); + nSigmaTriton -= nSigmaTriton_shift; + } + if (enable_pT_shift_He3_tpc_nSigma) { + float nSigmaHe3_shift = He3_Tpc_nSigma_shift->Eval(track.pt() * 2.0); + nSigmaHe3 -= nSigmaHe3_shift; + } + if (enable_pT_shift_He4_tpc_nSigma) { + float nSigmaHe4_shift = He4_Tpc_nSigma_shift->Eval(track.pt() * 2.0); + nSigmaHe4 -= nSigmaHe4_shift; + } + if (track.sign() > 0) { MC_recon_reg.fill(HIST("histTpcNsigmaDataPi"), track.pt(), nSigmaPion); MC_recon_reg.fill(HIST("histTpcNsigmaDataPr"), track.pt(), nSigmaProton); @@ -1408,6 +1489,141 @@ struct NucleiHistTask { } } PROCESS_SWITCH(NucleiHistTask, processMCreco, "process reconstructed MC", false); + + void processMCdca(soa::Join::iterator const& collisions, soa::Filtered> const& tracks, + aod::McParticles& /*mcParticles*/, aod::McCollisions const& /*mcCollisions*/) + { + + if (event_selection_MC_sel8 && !collisions.sel8()) + return; + if (!isEventSelected(collisions)) + return; + + for (auto& track : tracks) { + histTrackcuts_MC->AddBinContent(1); + const auto particle = track.mcParticle(); + + int pdgbin = 0; + TLorentzVector lorentzVector_particle_MC{}; + switch (particle.pdgCode()) { + case +211: + pdgbin = 0; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassPiPlus); + break; + case -211: + pdgbin = 1; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassPiPlus); + break; + case +321: + pdgbin = 2; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassKPlus); + break; + case -321: + pdgbin = 3; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassKPlus); + break; + case +2212: + pdgbin = 4; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassProton); + break; + case -2212: + pdgbin = 5; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassProton); + break; + case +1000010020: + pdgbin = 6; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassDeuteron); + break; + case -1000010020: + pdgbin = 7; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassDeuteron); + break; + case +1000010030: + pdgbin = 8; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassTriton); + break; + case -1000010030: + pdgbin = 9; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassTriton); + break; + case +1000020030: + pdgbin = 10; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassHelium3); + break; + case -1000020030: + pdgbin = 11; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassHelium3); + break; + case +1000020040: + pdgbin = 12; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassAlpha); + break; + case -1000020040: + pdgbin = 13; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassAlpha); + break; + default: + pdgbin = -1; + break; + } + + if (lorentzVector_particle_MC.Rapidity() < yMin || lorentzVector_particle_MC.Rapidity() > yMax) + continue; + float TPCnumberClsFound = track.tpcNClsFound(); + float TPC_nCls_Crossed_Rows = track.tpcNClsCrossedRows(); + float RatioCrossedRowsOverFindableTPC = track.tpcCrossedRowsOverFindableCls(); + float Chi2perClusterTPC = track.tpcChi2NCl(); + float Chi2perClusterITS = track.itsChi2NCl(); + + if (TPCnumberClsFound < minTPCnClsFound || TPC_nCls_Crossed_Rows < minNCrossedRowsTPC) + continue; + if (RatioCrossedRowsOverFindableTPC < minRatioCrossedRowsTPC || RatioCrossedRowsOverFindableTPC > maxRatioCrossedRowsTPC) + continue; + if (Chi2perClusterTPC > maxChi2PerClusterTPC || Chi2perClusterTPC < minChi2PerClusterTPC || Chi2perClusterITS > maxChi2PerClusterITS) + continue; + if (!(track.passedTPCRefit())) + continue; + if (!(track.passedITSRefit())) + continue; + if ((track.itsNClsInnerBarrel()) < minReqClusterITSib || (track.itsNCls()) < minReqClusterITS) + continue; + if (track.pt() < p_min || track.pt() > p_max) + continue; + if ((requireITS && !(track.hasITS())) || (requireTPC && !(track.hasTPC()))) + continue; + if (requireGoldenChi2 && !(track.passedGoldenChi2())) + continue; + + MC_DCA.fill(HIST("histEta"), track.eta(), pdgbin); + + if (particle.isPhysicalPrimary()) { + if ((particle.pdgCode() == 1000020030) || (particle.pdgCode() == -1000020030) || (particle.pdgCode() == 1000020040) || (particle.pdgCode() == -1000020040)) { + MC_DCA.fill(HIST("histDCA_prim"), track.pt() * 2.0, track.dcaXY(), pdgbin); + MC_DCA.fill(HIST("histDCAz_prim"), track.pt() * 2.0, track.dcaZ(), pdgbin); + } else { + MC_DCA.fill(HIST("histDCA_prim"), track.pt(), track.dcaXY(), pdgbin); + MC_DCA.fill(HIST("histDCAz_prim"), track.pt(), track.dcaZ(), pdgbin); + } + } else if (particle.getProcess() == 4) { + if ((particle.pdgCode() == 1000020030) || (particle.pdgCode() == -1000020030) || (particle.pdgCode() == 1000020040) || (particle.pdgCode() == -1000020040)) { + MC_DCA.fill(HIST("histDCA_weak"), track.pt() * 2.0, track.dcaXY(), pdgbin); + MC_DCA.fill(HIST("histDCAz_weak"), track.pt() * 2.0, track.dcaZ(), pdgbin); + } else { + MC_DCA.fill(HIST("histDCA_weak"), track.pt(), track.dcaXY(), pdgbin); + MC_DCA.fill(HIST("histDCAz_weak"), track.pt(), track.dcaZ(), pdgbin); + } + } else if (particle.getProcess() == 23) { + if ((particle.pdgCode() == 1000020030) || (particle.pdgCode() == -1000020030) || (particle.pdgCode() == 1000020040) || (particle.pdgCode() == -1000020040)) { + MC_DCA.fill(HIST("histDCA_mat"), track.pt() * 2.0, track.dcaXY(), pdgbin); + MC_DCA.fill(HIST("histDCAz_mat"), track.pt() * 2.0, track.dcaZ(), pdgbin); + } else { + MC_DCA.fill(HIST("histDCA_mat"), track.pt(), track.dcaXY(), pdgbin); + MC_DCA.fill(HIST("histDCAz_mat"), track.pt(), track.dcaZ(), pdgbin); + } + } + } + } + PROCESS_SWITCH(NucleiHistTask, processMCdca, "process MC DCA", false); }; //*********************************************************************************** diff --git a/PWGLF/Tasks/Nuspex/QAHistTask.cxx b/PWGLF/Tasks/Nuspex/QAHistTask.cxx index 40318c18ca9..2afc40a7261 100644 --- a/PWGLF/Tasks/Nuspex/QAHistTask.cxx +++ b/PWGLF/Tasks/Nuspex/QAHistTask.cxx @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include "ReconstructionDataFormats/Track.h" @@ -44,33 +46,33 @@ struct QAHistTask { // Data HistogramRegistry QA_reg{"data_all_species", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry QA_species{"data_species", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry QA_species_pos{"data_positive", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry QA_species_neg{"data_negative", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry particle_reg{"data_positive", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry aparticle_reg{"data_negative", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry MC_recon_reg{"MC_particles_reco", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - OutputObj histPDG{TH1D("PDG", "PDG;PDG code", 20, 0.0, 20.0)}; + OutputObj histPDG_reco{TH1I("PDG reconstructed", "PDG;PDG code", 18, 0.0, 18)}; void init(o2::framework::InitContext&) { - if ((process_pion == true && (process_kaon == true || process_proton == true || process_deuteron == true || process_triton == true || process_He3 == true || process_He4 == true)) || (process_kaon == true && (process_proton == true || process_deuteron == true || process_triton == true || process_He3 == true || process_He4 == true)) || (process_proton == true && (process_deuteron == true || process_triton == true || process_He3 == true || process_He4 == true)) || (process_deuteron == true && (process_triton == true || process_He3 == true || process_He4 == true)) || (process_triton == true && (process_He3 == true || process_He4 == true)) || (process_He3 == true && process_He4 == true)) { + if ((do_pion == true && (do_kaon == true || do_proton == true || do_deuteron == true || do_triton == true || do_He3 == true || do_He4 == true)) || (do_kaon == true && (do_proton == true || do_deuteron == true || do_triton == true || do_He3 == true || do_He4 == true)) || (do_proton == true && (do_deuteron == true || do_triton == true || do_He3 == true || do_He4 == true)) || (do_deuteron == true && (do_triton == true || do_He3 == true || do_He4 == true)) || (do_triton == true && (do_He3 == true || do_He4 == true)) || (do_He3 == true && do_He4 == true)) { LOG(fatal) << "++++++++ Can't enable more than one species at a time, use subwagons for that purpose. ++++++++"; } std::string species; - if (process_pion) + if (do_pion) species = "pi"; - if (process_kaon) + if (do_kaon) species = "ka"; - if (process_proton) + if (do_proton) species = "p"; - if (process_deuteron) + if (do_deuteron) species = "d"; - if (process_triton) + if (do_triton) species = "t"; - if (process_He3) + if (do_He3) species = "He3"; - if (process_He4) + if (do_He4) species = "He4"; std::vector ptBinning = {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, 1.6, 1.8, 2.0, 2.2, 2.4, 2.8, 3.2, 3.6, 4., 5., 6., 8., 10., 12., 14.}; @@ -129,60 +131,60 @@ struct QAHistTask { QA_species.add("histpTCorralation", "TPC-glo pT vs glo pT", HistType::kTH2F, {{100, -5.0, 5.0, "#it{p}^{global} (GeV/#it{c})"}, {80, -4.0, 4.0, "#it{p}^{TPC} - #it{p}^{global} (GeV/#it{c})"}}); // QA choosen species (positive) - QA_species_pos.add("histTpcSignalData", Form("Specific energy loss (%s)", species.c_str()), HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - QA_species_pos.add("histTofSignalData", Form("TOF signal (%s)", species.c_str()), HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - QA_species_pos.add("histDcaVsPtData", Form("dcaXY vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); - QA_species_pos.add("histDcaZVsPtData", Form("dcaZ vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); - QA_species_pos.add("histTOFm2", Form("TOF m^2 vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {400, 0.0, 10.0, "m^2"}}); - QA_species_pos.add("histNClusterTPC", Form("Number of Clusters in TPC vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {80, 0.0, 160.0, "nCluster"}}); - QA_species_pos.add("histNClusterITS", Form("Number of Clusters in ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "ITS nCls"}}); - QA_species_pos.add("histNClusterITSib", Form("Number of Clusters in ib of ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "ITS ib nCls"}}); - QA_species_pos.add("histTPCnClsFindable", Form("Findable TPC clusters (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {200, 0.0, 200.0, "nCluster"}}); - QA_species_pos.add("histTPCnClsFindableMinusFound", Form("TPC Clusters: Findable - Found (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {60, 0.0, 60.0, "nCluster"}}); - QA_species_pos.add("histTPCnClsFindableMinusCrossedRows", Form("TPC Clusters: Findable - crossed rows (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {60, 0.0, 60.0, "nCluster"}}); - QA_species_pos.add("histTPCnClsShared", Form("Number of shared TPC clusters (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {70, 0.0, 70.0, "nCluster"}}); - QA_species_pos.add("histTPCCrossedRowsOverFindableCls", Form("Ratio crossed rows over findable clusters (%s)", species.c_str()), HistType::kTH1F, {{100, 0., 2.0, "Crossed Rows / Findable Cls"}}); - QA_species_pos.add("histTPCFoundOverFindable", Form("Ratio of found over findable clusters (%s)", species.c_str()), HistType::kTH1F, {{100, 0., 2.0, "Found Cls / Findable Cls"}}); - QA_species_pos.add("histTPCFractionSharedCls", Form("Fraction of shared TPC clusters (%s)", species.c_str()), HistType::kTH1F, {{100, -2.0, 2.0, "Shared Cls"}}); - QA_species_pos.add("histChi2TPC", Form("chi^2 TPC vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {100, 0.0, 5.0, "chi^2"}}); - QA_species_pos.add("histChi2ITS", Form("chi^2 ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {125, 0.0, 50.0, "chi^2"}}); - QA_species_pos.add("histChi2ITSvsITSnCls", "chi^2 ITS vs ITS nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS nCls"}}); - QA_species_pos.add("histChi2ITSvsITSibnCls", "chi^2 ITS vs ITS ib nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS ib nCls"}}); - QA_species_pos.add("histChi2ITSvsITSnClsAll", "chi^2 ITS vs ITS nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS nCls"}}); - QA_species_pos.add("histChi2TOF", Form("chi^2 TOF vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {75, 0.0, 15.0, "chi^2"}}); - QA_species_pos.add("histEtaWithOverFlow", Form("Pseudorapidity 0 - 105%% centrality (%s)", species.c_str()), HistType::kTH1F, {etaAxis}); - QA_species_pos.add("histEta", Form("Pseudorapidity with centrality cut (%s)", species.c_str()), HistType::kTH1F, {etaAxis}); - QA_species_pos.add("histEta_cent", Form("Pseudorapidity vs Centrality (%s)", species.c_str()), HistType::kTH2F, {centralityAxis_extended, etaAxis}); - QA_species_pos.add("histTrackLength", Form("Track length (%s)", species.c_str()), HistType::kTH1F, {{350, 0., 700., "length (cm)"}}); - QA_species_pos.add("histpTCorralation", "TPC-glo pT vs glo pT", HistType::kTH2F, {{100, -5.0, 5.0, "#it{p}^{global} (GeV/#it{c})"}, {80, -4.0, 4.0, "#it{p}^{TPC} - #it{p}^{global} (GeV/#it{c})"}}); + particle_reg.add("histTpcSignalData", Form("Specific energy loss (%s)", species.c_str()), HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); + particle_reg.add("histTofSignalData", Form("TOF signal (%s)", species.c_str()), HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); + particle_reg.add("histDcaVsPtData", Form("dcaXY vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + particle_reg.add("histDcaZVsPtData", Form("dcaZ vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + particle_reg.add("histTOFm2", Form("TOF m^2 vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {400, 0.0, 10.0, "m^2"}}); + particle_reg.add("histNClusterTPC", Form("Number of Clusters in TPC vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {80, 0.0, 160.0, "nCluster"}}); + particle_reg.add("histNClusterITS", Form("Number of Clusters in ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "ITS nCls"}}); + particle_reg.add("histNClusterITSib", Form("Number of Clusters in ib of ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "ITS ib nCls"}}); + particle_reg.add("histTPCnClsFindable", Form("Findable TPC clusters (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {200, 0.0, 200.0, "nCluster"}}); + particle_reg.add("histTPCnClsFindableMinusFound", Form("TPC Clusters: Findable - Found (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {60, 0.0, 60.0, "nCluster"}}); + particle_reg.add("histTPCnClsFindableMinusCrossedRows", Form("TPC Clusters: Findable - crossed rows (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {60, 0.0, 60.0, "nCluster"}}); + particle_reg.add("histTPCnClsShared", Form("Number of shared TPC clusters (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {70, 0.0, 70.0, "nCluster"}}); + particle_reg.add("histTPCCrossedRowsOverFindableCls", Form("Ratio crossed rows over findable clusters (%s)", species.c_str()), HistType::kTH1F, {{100, 0., 2.0, "Crossed Rows / Findable Cls"}}); + particle_reg.add("histTPCFoundOverFindable", Form("Ratio of found over findable clusters (%s)", species.c_str()), HistType::kTH1F, {{100, 0., 2.0, "Found Cls / Findable Cls"}}); + particle_reg.add("histTPCFractionSharedCls", Form("Fraction of shared TPC clusters (%s)", species.c_str()), HistType::kTH1F, {{100, -2.0, 2.0, "Shared Cls"}}); + particle_reg.add("histChi2TPC", Form("chi^2 TPC vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {100, 0.0, 5.0, "chi^2"}}); + particle_reg.add("histChi2ITS", Form("chi^2 ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {125, 0.0, 50.0, "chi^2"}}); + particle_reg.add("histChi2ITSvsITSnCls", "chi^2 ITS vs ITS nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS nCls"}}); + particle_reg.add("histChi2ITSvsITSibnCls", "chi^2 ITS vs ITS ib nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS ib nCls"}}); + particle_reg.add("histChi2ITSvsITSnClsAll", "chi^2 ITS vs ITS nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS nCls"}}); + particle_reg.add("histChi2TOF", Form("chi^2 TOF vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {75, 0.0, 15.0, "chi^2"}}); + particle_reg.add("histEtaWithOverFlow", Form("Pseudorapidity 0 - 105%% centrality (%s)", species.c_str()), HistType::kTH1F, {etaAxis}); + particle_reg.add("histEta", Form("Pseudorapidity with centrality cut (%s)", species.c_str()), HistType::kTH1F, {etaAxis}); + particle_reg.add("histEta_cent", Form("Pseudorapidity vs Centrality (%s)", species.c_str()), HistType::kTH2F, {centralityAxis_extended, etaAxis}); + particle_reg.add("histTrackLength", Form("Track length (%s)", species.c_str()), HistType::kTH1F, {{350, 0., 700., "length (cm)"}}); + particle_reg.add("histpTCorralation", "TPC-glo pT vs glo pT", HistType::kTH2F, {{100, -5.0, 5.0, "#it{p}^{global} (GeV/#it{c})"}, {80, -4.0, 4.0, "#it{p}^{TPC} - #it{p}^{global} (GeV/#it{c})"}}); // QA choosen species (negative) - QA_species_neg.add("histTpcSignalData", Form("Specific energy loss (anti-%s)", species.c_str()), HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - QA_species_neg.add("histTofSignalData", Form("TOF signal (%s)", species.c_str()), HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); - QA_species_neg.add("histDcaVsPtData", Form("dcaXY vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); - QA_species_neg.add("histDcaZVsPtData", Form("dcaZ vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); - QA_species_neg.add("histTOFm2", Form("TOF m^2 vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {400, 0.0, 10.0, "m^2"}}); - QA_species_neg.add("histNClusterTPC", Form("Number of Clusters in TPC vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {80, 0.0, 160.0, "nCluster"}}); - QA_species_neg.add("histNClusterITS", Form("Number of Clusters in ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "ITS nCls"}}); - QA_species_neg.add("histNClusterITSib", Form("Number of Clusters in ib of ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "ITS ib nCls"}}); - QA_species_neg.add("histTPCnClsFindable", Form("Findable TPC clusters (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {200, 0.0, 200.0, "nCluster"}}); - QA_species_neg.add("histTPCnClsFindableMinusFound", Form("TPC Clusters: Findable - Found (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {60, 0.0, 60.0, "nCluster"}}); - QA_species_neg.add("histTPCnClsFindableMinusCrossedRows", Form("TPC Clusters: Findable - crossed rows (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {60, 0.0, 60.0, "nCluster"}}); - QA_species_neg.add("histTPCnClsShared", Form("Number of shared TPC clusters (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {70, 0.0, 70.0, "nCluster"}}); - QA_species_neg.add("histTPCCrossedRowsOverFindableCls", Form("Ratio crossed rows over findable clusters (%s)", species.c_str()), HistType::kTH1F, {{100, 0., 2.0, "Crossed Rows / Findable Cls"}}); - QA_species_neg.add("histTPCFoundOverFindable", Form("Ratio of found over findable clusters (%s)", species.c_str()), HistType::kTH1F, {{100, 0., 2.0, "Found Cls / Findable Cls"}}); - QA_species_neg.add("histTPCFractionSharedCls", Form("Fraction of shared TPC clusters (%s)", species.c_str()), HistType::kTH1F, {{100, -2.0, 2.0, "Shared Cls"}}); - QA_species_neg.add("histChi2TPC", Form("chi^2 TPC vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {100, 0.0, 5.0, "chi^2"}}); - QA_species_neg.add("histChi2ITS", Form("chi^2 ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {125, 0.0, 50.0, "chi^2"}}); - QA_species_neg.add("histChi2ITSvsITSnCls", "chi^2 ITS vs ITS nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS nCls"}}); - QA_species_neg.add("histChi2ITSvsITSibnCls", "chi^2 ITS vs ITS ib nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS ib nCls"}}); - QA_species_neg.add("histChi2ITSvsITSnClsAll", "chi^2 ITS vs ITS nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS nCls"}}); - QA_species_neg.add("histChi2TOF", Form("chi^2 TOF vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {75, 0.0, 15.0, "chi^2"}}); - QA_species_neg.add("histEtaWithOverFlow", Form("Pseudorapidity 0 - 105%% centrality (%s)", species.c_str()), HistType::kTH1F, {etaAxis}); - QA_species_neg.add("histEta", Form("Pseudorapidity with centrality cut (%s)", species.c_str()), HistType::kTH1F, {etaAxis}); - QA_species_neg.add("histEta_cent", Form("Pseudorapidity vs Centrality (%s)", species.c_str()), HistType::kTH2F, {centralityAxis_extended, etaAxis}); - QA_species_neg.add("histTrackLength", Form("Track length (%s)", species.c_str()), HistType::kTH1F, {{350, 0., 700., "length (cm)"}}); - QA_species_neg.add("histpTCorralation", "TPC-glo pT vs glo pT", HistType::kTH2F, {{100, -5.0, 5.0, "#it{p}^{global} (GeV/#it{c})"}, {80, -4.0, 4.0, "#it{p}^{TPC} - #it{p}^{global} (GeV/#it{c})"}}); + aparticle_reg.add("histTpcSignalData", Form("Specific energy loss (anti-%s)", species.c_str()), HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); + aparticle_reg.add("histTofSignalData", Form("TOF signal (%s)", species.c_str()), HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); + aparticle_reg.add("histDcaVsPtData", Form("dcaXY vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {250, -0.5, 0.5, "dca"}}); + aparticle_reg.add("histDcaZVsPtData", Form("dcaZ vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {1000, -2.0, 2.0, "dca"}}); + aparticle_reg.add("histTOFm2", Form("TOF m^2 vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {400, 0.0, 10.0, "m^2"}}); + aparticle_reg.add("histNClusterTPC", Form("Number of Clusters in TPC vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {80, 0.0, 160.0, "nCluster"}}); + aparticle_reg.add("histNClusterITS", Form("Number of Clusters in ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "ITS nCls"}}); + aparticle_reg.add("histNClusterITSib", Form("Number of Clusters in ib of ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "ITS ib nCls"}}); + aparticle_reg.add("histTPCnClsFindable", Form("Findable TPC clusters (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {200, 0.0, 200.0, "nCluster"}}); + aparticle_reg.add("histTPCnClsFindableMinusFound", Form("TPC Clusters: Findable - Found (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {60, 0.0, 60.0, "nCluster"}}); + aparticle_reg.add("histTPCnClsFindableMinusCrossedRows", Form("TPC Clusters: Findable - crossed rows (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {60, 0.0, 60.0, "nCluster"}}); + aparticle_reg.add("histTPCnClsShared", Form("Number of shared TPC clusters (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {70, 0.0, 70.0, "nCluster"}}); + aparticle_reg.add("histTPCCrossedRowsOverFindableCls", Form("Ratio crossed rows over findable clusters (%s)", species.c_str()), HistType::kTH1F, {{100, 0., 2.0, "Crossed Rows / Findable Cls"}}); + aparticle_reg.add("histTPCFoundOverFindable", Form("Ratio of found over findable clusters (%s)", species.c_str()), HistType::kTH1F, {{100, 0., 2.0, "Found Cls / Findable Cls"}}); + aparticle_reg.add("histTPCFractionSharedCls", Form("Fraction of shared TPC clusters (%s)", species.c_str()), HistType::kTH1F, {{100, -2.0, 2.0, "Shared Cls"}}); + aparticle_reg.add("histChi2TPC", Form("chi^2 TPC vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {100, 0.0, 5.0, "chi^2"}}); + aparticle_reg.add("histChi2ITS", Form("chi^2 ITS vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {125, 0.0, 50.0, "chi^2"}}); + aparticle_reg.add("histChi2ITSvsITSnCls", "chi^2 ITS vs ITS nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS nCls"}}); + aparticle_reg.add("histChi2ITSvsITSibnCls", "chi^2 ITS vs ITS ib nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS ib nCls"}}); + aparticle_reg.add("histChi2ITSvsITSnClsAll", "chi^2 ITS vs ITS nCls", HistType::kTH2F, {{125, 0.0, 50.0, "chi^2"}, {10, 0.0, 10.0, "ITS nCls"}}); + aparticle_reg.add("histChi2TOF", Form("chi^2 TOF vs Pt (%s)", species.c_str()), HistType::kTH2F, {ptAxis, {75, 0.0, 15.0, "chi^2"}}); + aparticle_reg.add("histEtaWithOverFlow", Form("Pseudorapidity 0 - 105%% centrality (%s)", species.c_str()), HistType::kTH1F, {etaAxis}); + aparticle_reg.add("histEta", Form("Pseudorapidity with centrality cut (%s)", species.c_str()), HistType::kTH1F, {etaAxis}); + aparticle_reg.add("histEta_cent", Form("Pseudorapidity vs Centrality (%s)", species.c_str()), HistType::kTH2F, {centralityAxis_extended, etaAxis}); + aparticle_reg.add("histTrackLength", Form("Track length (%s)", species.c_str()), HistType::kTH1F, {{350, 0., 700., "length (cm)"}}); + aparticle_reg.add("histpTCorralation", "TPC-glo pT vs glo pT", HistType::kTH2F, {{100, -5.0, 5.0, "#it{p}^{global} (GeV/#it{c})"}, {80, -4.0, 4.0, "#it{p}^{TPC} - #it{p}^{global} (GeV/#it{c})"}}); // +++++++++++++++++++++ MC ++++++++++++++++++++++++++ @@ -223,13 +225,13 @@ struct QAHistTask { } // Configurables - Configurable process_pion{"process_pion", false, "0: disabled, 1: enabled"}; - Configurable process_kaon{"process_kaon", false, "0: disabled, 1: enabled"}; - Configurable process_proton{"process_proton", false, "0: disabled, 1: enabled"}; - Configurable process_deuteron{"process_deuteron", false, "0: disabled, 1: enabled"}; - Configurable process_triton{"process_triton", false, "0: disabled, 1: enabled"}; - Configurable process_He3{"process_He3", false, "0: disabled, 1: enabled"}; - Configurable process_He4{"process_He4", false, "0: disabled, 1: enabled"}; + Configurable do_pion{"do_pion", false, "0: disabled, 1: enabled"}; + Configurable do_kaon{"do_kaon", false, "0: disabled, 1: enabled"}; + Configurable do_proton{"do_proton", false, "0: disabled, 1: enabled"}; + Configurable do_deuteron{"do_deuteron", false, "0: disabled, 1: enabled"}; + Configurable do_triton{"do_triton", false, "0: disabled, 1: enabled"}; + Configurable do_He3{"do_He3", false, "0: disabled, 1: enabled"}; + Configurable do_He4{"do_He4", false, "0: disabled, 1: enabled"}; Configurable event_selection_sel8{"event_selection_sel8", true, "0: disabled, 1: enabled"}; Configurable event_selection_MC_sel8{"event_selection_MC_sel8", true, "Enable sel8 event selection in MC processing"}; @@ -266,9 +268,34 @@ struct QAHistTask { Configurable maxChi2TOF{"maxChi2TOF", 100.0f, "max chi2 for the TOF track segment"}; Configurable minTPCFoundOverFindable{"minTPCFoundOverFindable", 0.0f, "min ratio of found over findable clusters TPC"}; Configurable maxTPCFoundOverFindable{"maxTPCFoundOverFindable", 2.0f, "max ratio of found over findable clusters TPC"}; + Configurable removeITSROFrameBorder{"removeITSROFrameBorder", false, "Remove TF border"}; + Configurable removeNoSameBunchPileup{"removeNoSameBunchPileup", false, "Remove TF border"}; + Configurable requireIsGoodZvtxFT0vsPV{"requireIsGoodZvtxFT0vsPV", false, "Remove TF border"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "Remove TF border"}; + Configurable removeNoTimeFrameBorder{"removeNoTimeFrameBorder", false, "Remove TF border"}; + + //*********************************************************************************** + + template + bool isEventSelected(CollisionType const& collision) + { + if (removeITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) + return false; + if (removeNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) + return false; + if (requireIsGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) + return false; + if (requireIsVertexITSTPC && !collision.selection_bit(aod::evsel::kIsVertexITSTPC)) + return false; + if (removeNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) + return false; + return true; + } + + //*********************************************************************************** template - void fillDataHistograms(const CollisionType& event, const TracksType& tracks) + void fillDataHistograms(const CollisionType& event, const TracksType& tracks, const int Partilce_type) { if (event_selection_sel8 && event.sel8()) { @@ -279,28 +306,63 @@ struct QAHistTask { QA_reg.fill(HIST("histRecVtxZData"), event.posZ()); } - for (auto track : tracks) { + if (!isEventSelected(event)) + return; + + for (auto track : tracks) { // start loop over all tracks + + if (event_selection_sel8 && !event.sel8()) + continue; QA_reg.fill(HIST("histDcaVsPID"), track.dcaXY(), track.pidForTracking()); QA_reg.fill(HIST("histDcaZVsPID"), track.dcaZ(), track.pidForTracking()); QA_reg.fill(HIST("histpTCorralation"), track.sign() * track.pt(), track.tpcInnerParam() - track.pt()); - float nSigmaSpecies = 999.0; - - if (process_pion) - nSigmaSpecies = track.tpcNSigmaPi(); - if (process_kaon) - nSigmaSpecies = track.tpcNSigmaKa(); - if (process_proton) - nSigmaSpecies = track.tpcNSigmaPr(); - if (process_deuteron) - nSigmaSpecies = track.tpcNSigmaDe(); - if (process_triton) - nSigmaSpecies = track.tpcNSigmaTr(); - if (process_He3) - nSigmaSpecies = track.tpcNSigmaHe(); - if (process_He4) - nSigmaSpecies = track.tpcNSigmaAl(); + float TPCnSigma_particle = -100; + + float momentum; + TLorentzVector lorentzVector{}; + + switch (Partilce_type) { + case 0: // pi plus/minus + lorentzVector.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassPiPlus); + TPCnSigma_particle = track.tpcNSigmaPi(); + momentum = track.pt(); + break; + case 1: // (anti)kaon + lorentzVector.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassKPlus); + TPCnSigma_particle = track.tpcNSigmaKa(); + momentum = track.pt(); + break; + case 2: // (anti)proton + lorentzVector.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassProton); + TPCnSigma_particle = track.tpcNSigmaPr(); + momentum = track.pt(); + break; + case 3: // (anti)deuteron + lorentzVector.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassDeuteron); + TPCnSigma_particle = track.tpcNSigmaDe(); + momentum = track.pt(); + break; + case 4: // (anti)triton + lorentzVector.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassTriton); + TPCnSigma_particle = track.tpcNSigmaTr(); + momentum = track.pt(); + break; + case 5: // (anti)Helium-3 + lorentzVector.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassHelium3); + TPCnSigma_particle = track.tpcNSigmaHe(); + momentum = track.pt() * 2.0; + break; + case 6: // (anti)Helium-4 + lorentzVector.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassAlpha); + TPCnSigma_particle = track.tpcNSigmaAl(); + momentum = track.pt() * 2.0; + break; + default: + continue; + break; + } if (event_selection_sel8 && !event.sel8()) { continue; @@ -315,17 +377,16 @@ struct QAHistTask { float Chi2perClusterITS = track.itsChi2NCl(); if (track.sign() > 0) { - QA_reg.fill(HIST("histDcaVsPtData_particle"), track.pt(), track.dcaXY()); - QA_reg.fill(HIST("histDcaZVsPtData_particle"), track.pt(), track.dcaZ()); + QA_reg.fill(HIST("histDcaVsPtData_particle"), momentum, track.dcaXY()); + QA_reg.fill(HIST("histDcaZVsPtData_particle"), momentum, track.dcaZ()); } if (track.sign() < 0) { - QA_reg.fill(HIST("histDcaVsPtData_antiparticle"), track.pt(), track.dcaXY()); - QA_reg.fill(HIST("histDcaZVsPtData_antiparticle"), track.pt(), track.dcaZ()); + QA_reg.fill(HIST("histDcaVsPtData_antiparticle"), momentum, track.dcaXY()); + QA_reg.fill(HIST("histDcaZVsPtData_antiparticle"), momentum, track.dcaZ()); } if (custom_Track_selection && (TMath::Abs(track.dcaXY()) > maxDCA_XY || TMath::Abs(track.dcaZ()) > maxDCA_Z || TPCnumberClsFound < minTPCnClsFound || TPC_nCls_Crossed_Rows < minNCrossedRowsTPC || RatioCrossedRowsOverFindableTPC < minRatioCrossedRowsTPC || RatioCrossedRowsOverFindableTPC > maxRatioCrossedRowsTPC || Chi2perClusterTPC > maxChi2TPC || Chi2perClusterITS > maxChi2ITS || !(track.passedTPCRefit()) || !(track.passedITSRefit()) || (track.itsNClsInnerBarrel()) < minReqClusterITSib || (track.itsNCls()) < minReqClusterITS || track.length() < minTrackLength || track.length() > maxTrackLength || track.tpcNClsFindable() < minTPCNClsFindable || track.tpcNClsShared() > maxTPCNClsShared || track.tpcFoundOverFindableCls() < minTPCFoundOverFindable || track.tpcFoundOverFindableCls() > maxTPCFoundOverFindable)) { - if (track.hasTOF() && track.tofChi2() > maxChi2TOF) continue; continue; @@ -335,44 +396,28 @@ struct QAHistTask { continue; } - TLorentzVector lorentzVector_proton{}; - TLorentzVector lorentzVector_deuteron{}; - TLorentzVector lorentzVector_triton{}; - TLorentzVector lorentzVector_He3{}; - TLorentzVector lorentzVector_He4{}; - - lorentzVector_proton.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassProton); - lorentzVector_deuteron.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassDeuteron); - lorentzVector_triton.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassTriton); - lorentzVector_He3.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassHelium3); - lorentzVector_He4.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassAlpha); - - if (lorentzVector_proton.Rapidity() < yMin || lorentzVector_proton.Rapidity() > yMax || - lorentzVector_deuteron.Rapidity() < yMin || lorentzVector_deuteron.Rapidity() > yMax || - lorentzVector_triton.Rapidity() < yMin || lorentzVector_triton.Rapidity() > yMax || - lorentzVector_He3.Rapidity() < yMin || lorentzVector_He3.Rapidity() > yMax || - lorentzVector_He4.Rapidity() < yMin || lorentzVector_He4.Rapidity() > yMax) { + if (lorentzVector.Rapidity() < yMin || lorentzVector.Rapidity() > yMax) { continue; } - if (track.pt() < pTmin || track.pt() > pTmax) + if (momentum < pTmin || momentum > pTmax) continue; - QA_reg.fill(HIST("histTpcSignalData"), track.pt() * track.sign(), track.tpcSignal()); - QA_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsCrossedRows()); - QA_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); - QA_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); - QA_reg.fill(HIST("histChi2TPC"), track.pt(), track.tpcChi2NCl()); - QA_reg.fill(HIST("histChi2ITS"), track.pt(), track.itsChi2NCl()); + QA_reg.fill(HIST("histTpcSignalData"), momentum * track.sign(), track.tpcSignal()); + QA_reg.fill(HIST("histNClusterTPC"), momentum, track.tpcNClsCrossedRows()); + QA_reg.fill(HIST("histNClusterITS"), momentum, track.itsNCls()); + QA_reg.fill(HIST("histNClusterITSib"), momentum, track.itsNClsInnerBarrel()); + QA_reg.fill(HIST("histChi2TPC"), momentum, track.tpcChi2NCl()); + QA_reg.fill(HIST("histChi2ITS"), momentum, track.itsChi2NCl()); QA_reg.fill(HIST("histChi2ITSvsITSnCls"), track.itsChi2NCl(), track.itsNCls()); QA_reg.fill(HIST("histChi2ITSvsITSibnCls"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); QA_reg.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNCls()); QA_reg.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); - QA_reg.fill(HIST("histTPCnClsFindable"), track.pt(), track.tpcNClsFindable()); - QA_reg.fill(HIST("histTPCnClsFindableMinusFound"), track.pt(), track.tpcNClsFindableMinusFound()); - QA_reg.fill(HIST("histTPCnClsFindableMinusCrossedRows"), track.pt(), track.tpcNClsFindableMinusCrossedRows()); - QA_reg.fill(HIST("histTPCnClsShared"), track.pt(), track.tpcNClsShared()); - QA_reg.fill(HIST("histChi2TOF"), track.pt(), track.tofChi2()); + QA_reg.fill(HIST("histTPCnClsFindable"), momentum, track.tpcNClsFindable()); + QA_reg.fill(HIST("histTPCnClsFindableMinusFound"), momentum, track.tpcNClsFindableMinusFound()); + QA_reg.fill(HIST("histTPCnClsFindableMinusCrossedRows"), momentum, track.tpcNClsFindableMinusCrossedRows()); + QA_reg.fill(HIST("histTPCnClsShared"), momentum, track.tpcNClsShared()); + QA_reg.fill(HIST("histChi2TOF"), momentum, track.tofChi2()); QA_reg.fill(HIST("histTrackLength"), track.length()); QA_reg.fill(HIST("histTPCCrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); QA_reg.fill(HIST("histTPCFoundOverFindable"), track.tpcFoundOverFindableCls()); @@ -395,37 +440,37 @@ struct QAHistTask { Float_t TOFmass2 = ((track.mass()) * (track.mass())); - QA_reg.fill(HIST("histTOFm2"), track.pt(), TOFmass2); - QA_reg.fill(HIST("histTofSignalData"), track.pt() * track.sign(), track.beta()); + QA_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + QA_reg.fill(HIST("histTofSignalData"), momentum * track.sign(), track.beta()); } - if (TMath::Abs(nSigmaSpecies) < nsigmacut) { + if (TMath::Abs(TPCnSigma_particle) < nsigmacut) { - QA_species.fill(HIST("histpTCorralation"), track.sign() * track.pt(), track.tpcInnerParam() - track.pt()); + QA_species.fill(HIST("histpTCorralation"), track.sign() * momentum, track.tpcInnerParam() - momentum); if (track.sign() > 0) { - QA_species_pos.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); - QA_species_pos.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - QA_species_pos.fill(HIST("histTpcSignalData"), track.pt(), track.tpcSignal()); - QA_species_pos.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsCrossedRows()); - QA_species_pos.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); - QA_species_pos.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); - QA_species_pos.fill(HIST("histChi2TPC"), track.pt(), track.tpcChi2NCl()); - QA_species_pos.fill(HIST("histChi2ITS"), track.pt(), track.itsChi2NCl()); - QA_species_pos.fill(HIST("histChi2ITSvsITSnCls"), track.itsChi2NCl(), track.itsNCls()); - QA_species_pos.fill(HIST("histChi2ITSvsITSibnCls"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); - QA_species_pos.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNCls()); - QA_species_pos.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); - QA_species_pos.fill(HIST("histTPCnClsFindable"), track.pt(), track.tpcNClsFindable()); - QA_species_pos.fill(HIST("histTPCnClsFindableMinusFound"), track.pt(), track.tpcNClsFindableMinusFound()); - QA_species_pos.fill(HIST("histTPCnClsFindableMinusCrossedRows"), track.pt(), track.tpcNClsFindableMinusCrossedRows()); - QA_species_pos.fill(HIST("histTPCnClsShared"), track.pt(), track.tpcNClsShared()); - QA_species_pos.fill(HIST("histChi2TOF"), track.pt(), track.tofChi2()); - QA_species_pos.fill(HIST("histTrackLength"), track.length()); - QA_species_pos.fill(HIST("histTPCCrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); - QA_species_pos.fill(HIST("histTPCFoundOverFindable"), track.tpcFoundOverFindableCls()); - QA_species_pos.fill(HIST("histTPCFractionSharedCls"), track.tpcFractionSharedCls()); - QA_species_pos.fill(HIST("histpTCorralation"), track.sign() * track.pt(), track.tpcInnerParam() - track.pt()); + particle_reg.fill(HIST("histDcaVsPtData"), momentum, track.dcaXY()); + particle_reg.fill(HIST("histDcaZVsPtData"), momentum, track.dcaZ()); + particle_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); + particle_reg.fill(HIST("histNClusterTPC"), momentum, track.tpcNClsCrossedRows()); + particle_reg.fill(HIST("histNClusterITS"), momentum, track.itsNCls()); + particle_reg.fill(HIST("histNClusterITSib"), momentum, track.itsNClsInnerBarrel()); + particle_reg.fill(HIST("histChi2TPC"), momentum, track.tpcChi2NCl()); + particle_reg.fill(HIST("histChi2ITS"), momentum, track.itsChi2NCl()); + particle_reg.fill(HIST("histChi2ITSvsITSnCls"), track.itsChi2NCl(), track.itsNCls()); + particle_reg.fill(HIST("histChi2ITSvsITSibnCls"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); + particle_reg.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNCls()); + particle_reg.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); + particle_reg.fill(HIST("histTPCnClsFindable"), momentum, track.tpcNClsFindable()); + particle_reg.fill(HIST("histTPCnClsFindableMinusFound"), momentum, track.tpcNClsFindableMinusFound()); + particle_reg.fill(HIST("histTPCnClsFindableMinusCrossedRows"), momentum, track.tpcNClsFindableMinusCrossedRows()); + particle_reg.fill(HIST("histTPCnClsShared"), momentum, track.tpcNClsShared()); + particle_reg.fill(HIST("histChi2TOF"), momentum, track.tofChi2()); + particle_reg.fill(HIST("histTrackLength"), track.length()); + particle_reg.fill(HIST("histTPCCrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); + particle_reg.fill(HIST("histTPCFoundOverFindable"), track.tpcFoundOverFindableCls()); + particle_reg.fill(HIST("histTPCFractionSharedCls"), track.tpcFractionSharedCls()); + particle_reg.fill(HIST("histpTCorralation"), track.sign() * momentum, track.tpcInnerParam() - momentum); if (track.hasTOF()) { @@ -444,33 +489,33 @@ struct QAHistTask { Float_t TOFmass2 = ((track.mass()) * (track.mass())); - QA_species_pos.fill(HIST("histTOFm2"), track.pt(), TOFmass2); - QA_species_pos.fill(HIST("histTofSignalData"), track.pt() * track.sign(), track.beta()); + particle_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + particle_reg.fill(HIST("histTofSignalData"), momentum * track.sign(), track.beta()); } } if (track.sign() < 0) { - QA_species_neg.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); - QA_species_neg.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - QA_species_neg.fill(HIST("histTpcSignalData"), track.pt(), track.tpcSignal()); - QA_species_neg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsCrossedRows()); - QA_species_neg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); - QA_species_neg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); - QA_species_neg.fill(HIST("histChi2TPC"), track.pt(), track.tpcChi2NCl()); - QA_species_neg.fill(HIST("histChi2ITS"), track.pt(), track.itsChi2NCl()); - QA_species_neg.fill(HIST("histChi2ITSvsITSnCls"), track.itsChi2NCl(), track.itsNCls()); - QA_species_neg.fill(HIST("histChi2ITSvsITSibnCls"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); - QA_species_neg.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNCls()); - QA_species_neg.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); - QA_species_neg.fill(HIST("histTPCnClsFindable"), track.pt(), track.tpcNClsFindable()); - QA_species_neg.fill(HIST("histTPCnClsFindableMinusFound"), track.pt(), track.tpcNClsFindableMinusFound()); - QA_species_neg.fill(HIST("histTPCnClsFindableMinusCrossedRows"), track.pt(), track.tpcNClsFindableMinusCrossedRows()); - QA_species_neg.fill(HIST("histTPCnClsShared"), track.pt(), track.tpcNClsShared()); - QA_species_neg.fill(HIST("histChi2TOF"), track.pt(), track.tofChi2()); - QA_species_neg.fill(HIST("histTrackLength"), track.length()); - QA_species_neg.fill(HIST("histTPCCrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); - QA_species_neg.fill(HIST("histTPCFoundOverFindable"), track.tpcFoundOverFindableCls()); - QA_species_neg.fill(HIST("histTPCFractionSharedCls"), track.tpcFractionSharedCls()); - QA_species_neg.fill(HIST("histpTCorralation"), track.sign() * track.pt(), track.tpcInnerParam() - track.pt()); + aparticle_reg.fill(HIST("histDcaVsPtData"), momentum, track.dcaXY()); + aparticle_reg.fill(HIST("histDcaZVsPtData"), momentum, track.dcaZ()); + aparticle_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); + aparticle_reg.fill(HIST("histNClusterTPC"), momentum, track.tpcNClsCrossedRows()); + aparticle_reg.fill(HIST("histNClusterITS"), momentum, track.itsNCls()); + aparticle_reg.fill(HIST("histNClusterITSib"), momentum, track.itsNClsInnerBarrel()); + aparticle_reg.fill(HIST("histChi2TPC"), momentum, track.tpcChi2NCl()); + aparticle_reg.fill(HIST("histChi2ITS"), momentum, track.itsChi2NCl()); + aparticle_reg.fill(HIST("histChi2ITSvsITSnCls"), track.itsChi2NCl(), track.itsNCls()); + aparticle_reg.fill(HIST("histChi2ITSvsITSibnCls"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); + aparticle_reg.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNCls()); + aparticle_reg.fill(HIST("histChi2ITSvsITSnClsAll"), track.itsChi2NCl(), track.itsNClsInnerBarrel()); + aparticle_reg.fill(HIST("histTPCnClsFindable"), momentum, track.tpcNClsFindable()); + aparticle_reg.fill(HIST("histTPCnClsFindableMinusFound"), momentum, track.tpcNClsFindableMinusFound()); + aparticle_reg.fill(HIST("histTPCnClsFindableMinusCrossedRows"), momentum, track.tpcNClsFindableMinusCrossedRows()); + aparticle_reg.fill(HIST("histTPCnClsShared"), momentum, track.tpcNClsShared()); + aparticle_reg.fill(HIST("histChi2TOF"), momentum, track.tofChi2()); + aparticle_reg.fill(HIST("histTrackLength"), track.length()); + aparticle_reg.fill(HIST("histTPCCrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); + aparticle_reg.fill(HIST("histTPCFoundOverFindable"), track.tpcFoundOverFindableCls()); + aparticle_reg.fill(HIST("histTPCFractionSharedCls"), track.tpcFractionSharedCls()); + aparticle_reg.fill(HIST("histpTCorralation"), track.sign() * momentum, track.tpcInnerParam() - momentum); if (track.hasTOF()) { @@ -489,8 +534,8 @@ struct QAHistTask { Float_t TOFmass2 = ((track.mass()) * (track.mass())); - QA_species_neg.fill(HIST("histTOFm2"), track.pt(), TOFmass2); - QA_species_neg.fill(HIST("histTofSignalData"), track.pt() * track.sign(), track.beta()); + aparticle_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + aparticle_reg.fill(HIST("histTofSignalData"), momentum * track.sign(), track.beta()); } } } @@ -511,6 +556,9 @@ struct QAHistTask { QA_reg.fill(HIST("histCentrality"), event.centFT0C()); } + if (!isEventSelected(event)) + return; + for (auto track : tracks) { if (event_selection_sel8 && !event.sel8()) { @@ -530,33 +578,61 @@ struct QAHistTask { Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVertex); Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta && requireGlobalTrackWoDCAInFilter()); - using EventCandidatesData = soa::Filtered>; + using EventCandidates = soa::Filtered>; - using EventCandidatesDataCent = soa::Filtered>; + using EventCandidatesCent = soa::Filtered>; - using TrackCandidatesData = soa::Filtered>; + using TrackCandidates = soa::Filtered>; - void processData(EventCandidatesData::iterator const& event, TrackCandidatesData const& tracks) + void processData(EventCandidates::iterator const& event, TrackCandidates const& tracks) { - fillDataHistograms(event, tracks); + if (do_pion) + fillDataHistograms(event, tracks, 0); // pion + if (do_kaon) + fillDataHistograms(event, tracks, 1); // kaon + if (do_proton) + fillDataHistograms(event, tracks, 2); // proton + if (do_deuteron) + fillDataHistograms(event, tracks, 3); // deuteron + if (do_triton) + fillDataHistograms(event, tracks, 4); // triton + if (do_He3) + fillDataHistograms(event, tracks, 5); // He3 + if (do_He4) + fillDataHistograms(event, tracks, 6); // He4 } PROCESS_SWITCH(QAHistTask, processData, "process data", true); - void processDataCent(EventCandidatesDataCent::iterator const& event, TrackCandidatesData const& tracks) + void processDataCent(EventCandidatesCent::iterator const& event, TrackCandidates const& tracks) { - fillDataHistograms(event, tracks); + if (do_pion) + fillDataHistograms(event, tracks, 0); // pion + if (do_kaon) + fillDataHistograms(event, tracks, 1); // kaon + if (do_proton) + fillDataHistograms(event, tracks, 2); // proton + if (do_deuteron) + fillDataHistograms(event, tracks, 3); // deuteron + if (do_triton) + fillDataHistograms(event, tracks, 4); // triton + if (do_He3) + fillDataHistograms(event, tracks, 5); // He3 + if (do_He4) + fillDataHistograms(event, tracks, 6); // He4 fillDataCentHistorgrams(event, tracks); } PROCESS_SWITCH(QAHistTask, processDataCent, "process data containing centralities", false); - void processMC(soa::Join::iterator const& collisions, soa::Filtered> const& tracks, - aod::McParticles& /*mcParticles*/, aod::McCollisions const& /*mcCollisions*/) + void processMCreco(soa::Join::iterator const& collisions, soa::Filtered> const& tracks, + aod::McParticles& /*mcParticles*/, aod::McCollisions const& /*mcCollisions*/) { if (event_selection_MC_sel8 && !collisions.sel8()) return; MC_recon_reg.fill(HIST("histRecVtxMC"), collisions.posZ()); MC_recon_reg.fill(HIST("histCentrality"), collisions.centFT0C()); + if (!isEventSelected(collisions)) + return; for (auto& track : tracks) { const auto particle = track.mcParticle(); @@ -582,66 +658,83 @@ struct QAHistTask { } } - int pdgbin = 0; + int pdgbin = -10; + TLorentzVector lorentzVector_particle_MC{}; switch (particle.pdgCode()) { case +211: - histPDG->AddBinContent(1); + histPDG_reco->AddBinContent(1); pdgbin = 0; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassPiPlus); break; case -211: - histPDG->AddBinContent(2); + histPDG_reco->AddBinContent(2); pdgbin = 1; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassPiPlus); break; case +321: - histPDG->AddBinContent(3); + histPDG_reco->AddBinContent(3); pdgbin = 2; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassKPlus); break; case -321: - histPDG->AddBinContent(4); + histPDG_reco->AddBinContent(4); pdgbin = 3; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassKPlus); break; case +2212: - histPDG->AddBinContent(5); + histPDG_reco->AddBinContent(5); pdgbin = 4; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassProton); break; case -2212: - histPDG->AddBinContent(6); + histPDG_reco->AddBinContent(6); pdgbin = 5; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassProton); break; case +1000010020: - histPDG->AddBinContent(7); + histPDG_reco->AddBinContent(7); pdgbin = 6; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassDeuteron); break; case -1000010020: - histPDG->AddBinContent(8); + histPDG_reco->AddBinContent(8); pdgbin = 7; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassDeuteron); break; case +1000010030: - histPDG->AddBinContent(9); + histPDG_reco->AddBinContent(9); pdgbin = 8; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassTriton); break; case -1000010030: - histPDG->AddBinContent(10); + histPDG_reco->AddBinContent(10); pdgbin = 9; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), constants::physics::MassTriton); break; case +1000020030: - histPDG->AddBinContent(11); + histPDG_reco->AddBinContent(11); pdgbin = 10; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassHelium3); break; case -1000020030: - histPDG->AddBinContent(12); + histPDG_reco->AddBinContent(12); pdgbin = 11; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassHelium3); break; case +1000020040: - histPDG->AddBinContent(13); + histPDG_reco->AddBinContent(13); pdgbin = 12; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassAlpha); break; case -1000020040: - histPDG->AddBinContent(14); + histPDG_reco->AddBinContent(14); pdgbin = 13; + lorentzVector_particle_MC.SetPtEtaPhiM(track.pt() * 2.0, track.eta(), track.phi(), constants::physics::MassAlpha); break; default: + pdgbin = -10; continue; + break; } MC_recon_reg.fill(HIST("histPhi"), track.phi(), pdgbin); @@ -697,7 +790,7 @@ struct QAHistTask { } } } - PROCESS_SWITCH(QAHistTask, processMC, "process MC", false); + PROCESS_SWITCH(QAHistTask, processMCreco, "process MC", false); }; //**************************************************************************************************** diff --git a/PWGLF/Tasks/Nuspex/angularCorrelationsInJets.cxx b/PWGLF/Tasks/Nuspex/angularCorrelationsInJets.cxx new file mode 100644 index 00000000000..20e1604e206 --- /dev/null +++ b/PWGLF/Tasks/Nuspex/angularCorrelationsInJets.cxx @@ -0,0 +1,1556 @@ +// 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. +/// +/// \file angularCorrelationsInJets.cxx +/// +/// \author Lars Jörgensen (lars.christian.joergensen@cern.ch) +/// \brief task for analysis of angular correlations in jets using Fastjet + +#include +#include +#include +#include +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "ReconstructionDataFormats/Track.h" +#include "CCDB/BasicCCDBManager.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/PID/PIDTOF.h" +#include "Common/TableProducer/PID/pidTOFBase.h" +#include "Common/Core/RecoDecay.h" + +#include "fastjet/PseudoJet.hh" +#include "fastjet/AreaDefinition.hh" +#include "fastjet/ClusterSequenceArea.hh" +#include "fastjet/GhostedAreaSpec.hh" +#include "PWGJE/Core/JetBkgSubUtils.h" +#include "TVector3.h" +#include "TPDGCode.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct AxisSpecs { + AxisSpec ptAxisPos = {1000, 0, 100, "#it{p}_{T} [GeV/#it{c}]"}; + AxisSpec ptAxisFull = {2000, -100, 100, "#it{p}_{T} [GeV/#it{c}]"}; + AxisSpec nsigmapTAxis = {500, 0, 50, "#it{p}_{T} [GeV/#it{c}]"}; + AxisSpec nsigmaAxis = {300, -15, 15, "n#sigma"}; + AxisSpec dcazAxis = {1000, -1, 1, "DCA_{z} [cm]"}; + AxisSpec dcaxyAxis = {1000, -0.5, 0.5, "DCA_{xy} [cm]"}; + AxisSpec angDistPhiAxis = {1000, -2, 5, "#Delta#varphi"}; + AxisSpec angDistEtaAxis = {1000, -2, 2, "#Delta#eta"}; +}; + +struct AngularCorrelationsInJets { + // Switches + Configurable useRejectionCut{"useRejectionCut", true, "use nsigmaRejection for correlations"}; + Configurable outputQC{"outputQC", true, "add QC output"}; + Configurable doppCorrelations{"doppCorrelations", true, "measure correlations for p-p"}; + Configurable doapapCorrelations{"doapapCorrelations", false, "measure correlations for pbar-pbar"}; + Configurable dopapCorrelations{"dopapCorrelations", false, "measure correlations for p-pbar"}; + Configurable dopipiCorrelations{"dopipiCorrelations", false, "measure correlations for pi+-p+, pi--pi-"}; + Configurable doJetCorrelations{"doJetCorrelations", false, "measure correlations for all particles inside jets"}; + Configurable doFullCorrelations{"doFullCorrelations", false, "measure correlations for all particles in an event"}; + Configurable doUECorrelations{"doUECorrelations", false, "measure correlations for p-p, pbar-pbar in cone perp. to jet"}; + Configurable measureKaons{"measureKaons", false, "measure correlations for K-K"}; + Configurable useBkgEstimateForUE{"useBkgEstimateForUE", false, "use bkg density for anti-kt-style clustering in UE"}; + Configurable rejectEvents{"rejectEvents", false, "reject some events"}; + Configurable rejectionPercentage{"rejectionPercentage", 3, "percentage of events to reject"}; + + // Track Cuts + Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 80, "min number of crossed rows TPC"}; + Configurable minReqClusterITS{"minReqClusterITS", 5, "min number of clusters required in ITS"}; + Configurable minRatioCrossedRowsTPC{"minRatioCrossedRowsTPC", 0.8, "min ratio of crossed rows over findable clusters TPC"}; + Configurable maxChi2ITS{"maxChi2ITS", 36.0, "max chi2 per cluster ITS"}; + Configurable maxChi2TPC{"maxChi2TPC", 4.0, "max chi2 per cluster TPC"}; + Configurable maxDCAxy{"maxDCAxy", 0.05, "max DCA to vertex xy"}; + Configurable maxDCAz{"maxDCAz", 0.05, "max DCA to vertex z"}; + Configurable maxEta{"maxEta", 0.8, "max pseudorapidity"}; + Configurable deltaEtaEdge{"deltaEtaEdge", 0.05, "min eta distance of jet from acceptance edge"}; + Configurable minTrackPt{"minTrackPt", 0.3, "minimum track pT"}; + Configurable requirePVContributor{"requirePVContributor", false, "require track to be PV contributor"}; + + // Jet Cuts + Configurable jetR{"jetR", 0.3, "jet resolution parameter"}; + Configurable minJetPt{"minJetPt", 10.0, "minimum total pT to accept jet"}; + + // Proton Cuts + Configurable protonDCAxy{"protonDCAxy", 0.05, "[proton] DCAxy cut"}; + Configurable protonDCAz{"protonDCAz", 0.02, "[proton] DCAz cut"}; + Configurable protonTPCTOFpT{"protonTPCTOFpT", 0.7, "[proton] pT for switch in TPC/TPC+TOF nsigma"}; + Configurable protonTPCnsigma{"protonTPCnsigma", 4.0, "[proton] max TPC nsigma for pt > 0/1.5/3.0 GeV"}; + Configurable protonTOFnsigma{"protonTOFnsigma", 3.0, "[proton] max TOF nsigma for pt > 0/1.5/3.0 GeV"}; + + // Antiproton Cuts + Configurable antiprotonDCAxy{"antiprotonDCAxy", 0.05, "[antiproton] DCAxy cut"}; + Configurable antiprotonDCAz{"antiprotonDCAz", 0.02, "[antiproton] DCAz cut"}; + Configurable antiprotonTPCTOFpT{"antiprotonTPCTOFpT", 0.7, "[antiproton] pT for switch in TPC/TPC+TOF nsigma"}; + Configurable antiprotonTPCnsigma{"antiprotonTPCnsigma", 4.0, "[antiproton] max TPC nsigma for pt > 0/1.5/3.0 GeV"}; + Configurable antiprotonTOFnsigma{"antiprotonTOFnsigma", 3.0, "[antiproton] max TOF nsigma for pt > 0/1.5/3.0 GeV"}; + + // Pion & Kaon PID + Configurable pionDCAxy{"pionDCAxy", 0.05, "[pion] DCAxy cut"}; + Configurable pionDCAz{"pionDCAz", 0.05, "[pion] DCAz cut"}; + Configurable pionTPCTOFpT{"pionTPCTOFpT", 0.7, "[pion] pT for switch in TPC/TPC+TOF nsigma"}; + Configurable pionTPCnsigmaLowPt{"pionTPCnsigmaLowPt", 3.0, "[pion] max TPC nsigma with low pT"}; + Configurable pionTPCnsigmaHighPt{"pionTPCnsigmaHighPt", 3.0, "[pion] max TPC nsigma with high pT"}; + Configurable pionTOFnsigma{"pionTOFnsigma", 3.0, "[pion] max TOF nsigma"}; + Configurable kaonDCAxy{"kaonDCAxy", 0.05, "[kaon] DCAxy cut"}; + Configurable kaonDCAz{"kaonDCAz", 0.05, "[kaon] DCAz cut"}; + Configurable kaonTPCTOFpT{"kaonTPCTOFpT", 0.7, "[kaon] pT for switch in TPC/TPC+TOF nsigma"}; + Configurable kaonTPCnsigmaLowPt{"kaonTPCnsigmaLowPt", 3.0, "[kaon] max TPC nsigma with low pT"}; + Configurable kaonTPCnsigmaHighPt{"kaonTPCnsigmaHighPt", 3.0, "[kaon] max TPC nsigma with high pT"}; + Configurable kaonTOFnsigma{"kaonTOFnsigma", 3.0, "[kaon] max TOF nsigma"}; + + Configurable nsigmaRejection{"nsigmaRejection", 1.0, "reject tracks with nsigma < nsigmaRejection for >1 species"}; + Configurable trackBufferSize{"trackBufferSize", 200, "Number of mixed-event tracks being stored"}; + + // QC Configurables + Configurable zVtx{"zVtx", 10.0, "max zVertex"}; + + Service ccdb; + int mRunNumber; + + using FullTracksRun2 = soa::Join; + using FullTracksRun3 = soa::Join; + using McTracksRun2 = soa::Join; + using McTracksRun3 = soa::Join; + using BCsWithRun2Info = soa::Join; + using McCollisions = soa::Join; + + Filter prelimTrackCuts = (aod::track::itsChi2NCl < maxChi2ITS && // some of the track cuts already as filter + aod::track::tpcChi2NCl < maxChi2TPC && + nabs(aod::track::dcaXY) < maxDCAxy && + nabs(aod::track::dcaZ) < maxDCAz && + nabs(aod::track::eta) < maxEta); + + Preslice perCollisionFullTracksRun2 = o2::aod::track::collisionId; + Preslice perCollisionFullTracksRun3 = o2::aod::track::collisionId; + Preslice perCollisionMcTracksRun2 = o2::aod::track::collisionId; + Preslice perCollisionMcTracksRun3 = o2::aod::track::collisionId; + + AxisSpecs axisSpecs; // struct for axis specs because at one point there were too many variables for the compiler + + HistogramRegistry registryData{"data", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry registryMC{"MC", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry registryQC{"QC", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + + JetBkgSubUtils bkgSub; + std::vector eventSelection; + + void init(o2::framework::InitContext&) + { + mRunNumber = 0; // this block is a remnant from the run2 code adapted here + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + // Counters + registryData.add("numberOfEvents", "Number of events", HistType::kTH1I, {{1, 0, 1}}); + registryData.add("numberRejectedEvents", "Number of events rejected", HistType::kTH1I, {{2, 0, 2, "counter"}}); + registryData.add("numberOfJets", "Total number of jets", HistType::kTH1I, {{1, 0, 1}}); + registryData.add("eventProtocol", "Event protocol", HistType::kTH1I, {{20, 0, 20}}); + registryData.add("trackProtocol", "Track protocol", HistType::kTH1I, {{20, 0, 20}}); + registryData.add("numPartInJet", "Number of particles in a jet", HistType::kTH1I, {{200, 0, 200}}); + registryData.add("numJetsInEvent", "Number of jets selected", HistType::kTH1I, {{10, 0, 10}}); + registryData.add("jetRapidity", "Jet rapidity;#it{y}", HistType::kTH1F, {{200, -1, 1}}); + + if (doFullCorrelations) { + registryData.add("deltaPhiSEFull", "#Delta#varphi of particles in same event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiMEFull", "#Delta#varphi of particles in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiEtaSEFull", "#Delta#varphi vs #Delta#eta of full particles in same event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiEtaMEFull", "#Delta#varphi vs #Delta#eta of particles in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + } + + if (doJetCorrelations) { + registryData.add("deltaPhiSEJet", "#Delta#varphi of jet particles in same event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiMEJet", "#Delta#varphi of jet particles in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiEtaSEJet", "#Delta#varphi vs #Delta#eta of jet particles in same event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiEtaMEJet", "#Delta#varphi vs #Delta#eta of jet particles in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + } + + if (doppCorrelations) { + registryData.add("deltaPhiSEProton", "#Delta#varphi of protons in same event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiMEProton", "#Delta#varphi of protons in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiEtaSEProton", "#Delta#varphi vs #Delta#eta of protons in same event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiEtaMEProton", "#Delta#varphi vs #Delta#eta of protons in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + } + + if (doapapCorrelations) { + registryData.add("deltaPhiSEAntiproton", "#Delta#varphi of antiprotons in same event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiMEAntiproton", "#Delta#varphi of antiprotons in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiEtaSEAntiproton", "#Delta#varphi vs #Delta#eta of antiprotons in same event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiEtaMEAntiproton", "#Delta#varphi vs #Delta#eta of antiprotons in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + } + + if (dopipiCorrelations) { + registryData.add("dcaZJetPion", "DCA_{z} of high purity pions", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); + registryQC.add("ptJetPionVsTotalJet", "Pion p_{T} vs. jet p_{T}", HistType::kTH2D, {axisSpecs.ptAxisPos, {1000, 0, 500, "jet p_{T} [GeV/#it{c}]"}}); + registryData.add("tpcNSigmaPion", "TPC n#sigma for pion", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); + registryData.add("tofNSigmaPion", "TOF n#sigma for pion", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); + registryData.add("deltaPhiSEPion", "#Delta#varphi of pions in same event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiMEPion", "#Delta#varphi of pions in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiEtaSEPion", "#Delta#varphi vs #Delta#eta of pions in same event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiEtaMEPion", "#Delta#varphi vs #Delta#eta of pions in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + } + + if (dopapCorrelations) { + registryData.add("deltaPhiSEProtonAntiproton", "#Delta#varphi of proton-antiproton in same event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiMEProtonAntiproton", "#Delta#varphi of proton-antiproton in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiEtaSEProtonAntiproton", "#Delta#varphi vs #Delta#eta of proton-antiproton in same event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiEtaMEProtonAntiproton", "#Delta#varphi vs #Delta#eta of proton-antiproton in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + } + + if (doUECorrelations) { + registryData.add("deltaPhiSEProtonUE", "#Delta#varphi of UE protons in same event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiMEProtonUE", "#Delta#varphi of UE protons in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiEtaSEProtonUE", "#Delta#varphi vs #Delta#eta of UE protons in same event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiEtaMEProtonUE", "#Delta#varphi vs #Delta#eta of UE protons in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiSEAntiprotonUE", "#Delta#varphi of UE antiprotons in same event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiMEAntiprotonUE", "#Delta#varphi of UE antiprotons in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiEtaSEAntiprotonUE", "#Delta#varphi vs #Delta#eta of UE antiprotons in same event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiEtaMEAntiprotonUE", "#Delta#varphi vs #Delta#eta of UE antiprotons in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiSEPionUE", "#Delta#varphi of UE pions in same event", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiMEPionUE", "#Delta#varphi of UE pions in mixed events", HistType::kTH1D, {axisSpecs.angDistPhiAxis}); + registryData.add("deltaPhiEtaSEPionUE", "#Delta#varphi vs #Delta#eta of UE pions in same event", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + registryData.add("deltaPhiEtaMEPionUE", "#Delta#varphi vs #Delta#eta of UE pions in mixed events", HistType::kTH2D, {axisSpecs.angDistPhiAxis, axisSpecs.angDistEtaAxis}); + } + + if (doprocessMCRun2 || doprocessMCRun3 || doppCorrelations || doapapCorrelations || dopapCorrelations) { + registryData.add("ptJetProton", "p_{T} of protons", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryData.add("dcaZJetProton", "DCA_{z} of high purity protons", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); + registryQC.add("ptJetProtonVsTotalJet", "Proton p_{T} vs. jet p_{T}", HistType::kTH2D, {axisSpecs.ptAxisPos, {1000, 0, 500, "jet p_{T} [GeV/#it{c}]"}}); + registryData.add("ptJetAntiproton", "p_{T} of antiprotons", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryData.add("dcaZJetAntiproton", "DCA_{z} of high purity antiprotons", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); + registryQC.add("ptJetAntiprotonVsTotalJet", "Antiproton p_{T} vs. jet p_{T}", HistType::kTH2D, {axisSpecs.ptAxisPos, {1000, 0, 500, "jet p_{T} [GeV/#it{c}]"}}); + registryData.add("tpcNSigmaProton", "TPC n#sigma for proton", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); + registryData.add("tofNSigmaProton", "TOF n#sigma for proton", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); + registryData.add("tpcNSigmaAntiproton", "TPC n#sigma for antiproton", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); + registryData.add("tofNSigmaAntiproton", "TOF n#sigma for antiproton", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); + } + + if (measureKaons) { + registryData.add("dcaZJetKaon", "DCA_{z} of high purity kaons", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); + registryQC.add("ptJetKaonVsTotalJet", "Kaon p_{T} vs. jet p_{T}", HistType::kTH2D, {axisSpecs.ptAxisPos, {1000, 0, 500, "jet p_{T} [GeV/#it{c}]"}}); + registryData.add("tpcNSigmaKaon", "TPC n#sigma for kaon", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); + registryData.add("tofNSigmaKaon", "TOF n#sigma for kaon", HistType::kTH2F, {axisSpecs.nsigmapTAxis, axisSpecs.nsigmaAxis}); + } + + // pT + registryData.add("ptJetParticle", "p_{T} of particles in jets", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryData.add("ptTotalSubJetPerp", "Subtracted full jet p_{T} (perpendicular)", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryData.add("ptTotalJet", "p_{T} of entire jet;#it{p}_{T} [GeV/#it{c}]", HistType::kTH1F, {{1000, 0, 500}}); + + // nSigma + registryData.add("tpcSignal", "TPC signal", HistType::kTH2F, {{800, -10, 10, "#it{p} [GeV/#it{c}]"}, {1000, 0, 500, "d#it{E}/d#it{X} (a.u.)"}}); + registryData.add("tofSignal", "TOF signal", HistType::kTH2F, {{800, -20, 20, "#it{p} [GeV/#it{c}]"}, {800, 0.75, 1.05, "#beta (TOF)"}}); + + // Angular Distributions + registryQC.add("phiFullEvent", "#varphi in full event", HistType::kTH1F, {{1000, 0, 6.3}}); + registryQC.add("phiPtFullEvent", "#varphi vs. p_{T} in full event", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, 0, 6.3}}); + registryQC.add("phiJet", "#varphi in jet", HistType::kTH1F, {{1000, 0, 6.3}}); + registryQC.add("phiPtJet", "#varphi vs. p_{T} in jet", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, 0, 6.3}}); + registryQC.add("etaFullEvent", "#eta in full event", HistType::kTH1F, {{1000, -1, 1}}); + registryQC.add("etaPtFullEvent", "#eta vs. p_{T} in full event", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, -1, 1}}); + registryQC.add("etaJet", "#eta in jet", HistType::kTH1F, {{1000, -1, 1}}); + registryQC.add("etaPtJet", "#eta vs. p_{T} in jet", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, -1, 1}}); + + // QA + registryQC.add("rhoEstimatePerp", "Background #rho (perp)", HistType::kTH2F, {{axisSpecs.ptAxisPos}, {200, 0, 20}}); + registryQC.add("rhoMEstimatePerp", "Background #rho_{m} (perp)", HistType::kTH2F, {{axisSpecs.ptAxisPos}, {200, 0, 20}}); + registryQC.add("jetPtVsNumPart", "Total jet p_{T} vs number of constituents", HistType::kTH2F, {axisSpecs.ptAxisPos, {100, 0, 100}}); + + if (doprocessMCRun2 || doprocessMCRun3) { + registryMC.add("ptJetProtonMC", "Truth jet proton p_{T}", HistType::kTH1F, {axisSpecs.ptAxisPos}); + registryMC.add("ptJetAntiprotonMC", "Truth jet antiproton p_{T}", HistType::kTH1F, {axisSpecs.ptAxisPos}); + registryMC.add("numberOfTruthParticles", "Truth yields (anti)p, (anti)d, (anti)He-3", HistType::kTH1I, {{6, 0, 6}}); + } + + if (outputQC) { + registryQC.add("ptDiff", "p_{T} difference PseudoJet/original track;#it{p}_{T} [GeV/#it{c}]", HistType::kTH1D, {{2000, -0.0001, 0.0001}}); + registryQC.add("jetConeRadius", "Jet Radius;#it{R}", HistType::kTH1F, {{100, 0, 1}}); + registryQC.add("maxRadiusVsPt", "Max Cone Radius vs p_{T}", HistType::kTH2F, {{axisSpecs.ptAxisPos}, {100, 0, 1}}); + registryQC.add("jetBkgDeltaPt", "#Delta p_{T} Clustered Cone - Pure Jet", HistType::kTH1F, {{200, 0, 10}}); + + registryQC.add("ptFullEvent", "p_{T} after basic cuts", HistType::kTH1F, {axisSpecs.ptAxisPos}); + registryQC.add("crossedRowsTPC", "Crossed rows TPC", HistType::kTH2I, {axisSpecs.ptAxisPos, {135, 65, 200}}); + registryQC.add("clusterITS", "ITS clusters", HistType::kTH2I, {axisSpecs.ptAxisPos, {10, 0, 10}}); + registryQC.add("clusterTPC", "TPC clusters", HistType::kTH2I, {axisSpecs.ptAxisPos, {135, 65, 200}}); + registryQC.add("ratioCrossedRowsTPC", "Ratio crossed rows/findable TPC", HistType::kTH2F, {axisSpecs.ptAxisPos, {100, 0.5, 1.5}}); + registryQC.add("chi2ITS", "ITS #chi^{2}", HistType::kTH2F, {axisSpecs.ptAxisPos, {400, 0, 40}}); + registryQC.add("chi2TPC", "TPC #chi^{2}", HistType::kTH2F, {axisSpecs.ptAxisPos, {50, 0, 5}}); + registryQC.add("dcaXYFullEvent", "DCA_{xy} of full event", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcaxyAxis}); + registryQC.add("dcaZFullEvent", "DCA_{z} of full event", HistType::kTH2F, {axisSpecs.ptAxisPos, axisSpecs.dcazAxis}); + + registryQC.add("multiplicityJetPlusUE", "multiplicityJetPlusUE", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); + registryQC.add("multiplicityJet", "multiplicityJet", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); + registryQC.add("multiplicityUE", "multiplicityUE", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); + registryQC.add("ptJetPlusUE", "ptJetPlusUE", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); + registryQC.add("ptJet", "ptJet", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); + registryQC.add("ptUE", "ptUE", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); + registryQC.add("deltaEtadeltaPhiJet", "deltaEtadeltaPhiJet", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, constants::math::PIHalf, "#Delta#phi"}}); + registryQC.add("deltaEtadeltaPhiUE", "deltaEtadeltaPhiUE", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, constants::math::PIHalf, "#Delta#phi"}}); + registryQC.add("deltaJetPt", "deltaJetPt", HistType::kTH1F, {{200, -2, 2, "#Delta#it{p}_{T} (GeV/#it{c})"}}); + registryQC.add("nParticlesClusteredInJet", "nParticlesClusteredInJet", HistType::kTH1F, {{50, 0, 50, "#it{N}_{ch}"}}); + registryQC.add("ptParticlesClusteredInJet", "ptParticlesClusteredInJet", HistType::kTH1F, {{200, 0, 10, "#it{p}_{T} (GeV/#it{c})"}}); + + registryQC.add("whichUECone", "whichUECone", HistType::kTH1D, {{2, 0, 2, "UE cone"}}); + } + } + + // create track buffers outside processes so the tracks can be stored independently of events for mixed-event distributions + std::vector> fBufferProton; + std::vector> fBufferAntiproton; + std::vector> fBufferPiPlus; + std::vector> fBufferPiMinus; + std::vector> fBufferJet; + std::vector> fBufferFull; + std::vector> fBufferProtonsUE; + std::vector> fBufferAntiprotonsUE; + std::vector> fBufferPiPlusUE; + std::vector> fBufferPiMinusUE; + + template + void initCCDB(Bc const& bc) // remnant from run2 code + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + } + + bool shouldRejectEvent() + { + static std::random_device rd; + static std::mt19937 gen(rd()); + static std::uniform_int_distribution<> dis(0, 99); + int randomNumber = dis(gen); + if (randomNumber > rejectionPercentage) { + return false; // accept event + } + return true; // reject event + } + + template + bool hasITSHit(const T& track, int layer) + { + int bit = layer - 1; + return (track.itsClusterMap() & (1 << bit)); + } + + template + bool selectTrackForJetReco(const T& track) + { + if (track.dcaZ() > maxDCAz) + return false; + double maxEtaForJetReco = 0.8; + if (track.eta() > maxEtaForJetReco) + return false; + double minTrackPtForJetReco = 0.1; + if (track.pt() < minTrackPtForJetReco) + return false; + if (!track.hasITS()) + return false; + if (!track.hasTPC()) + return false; + int minCrossedRowsForJetReco = 70; + if (track.tpcNClsCrossedRows() < minCrossedRowsForJetReco) + return false; + if ((!hasITSHit(track, 1)) && (!hasITSHit(track, 2)) && (!hasITSHit(track, 3))) + return false; + double minRatioCrRowsFindableJetReco = 0.8; + if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < minRatioCrRowsFindableJetReco) + return false; + if (std::fabs(track.dcaXY()) > (0.0105 + 0.035 / std::pow(track.pt(), 1.1))) + return false; + if (doprocessRun2 || doprocessMCRun2) { + if (!(track.trackType() & o2::aod::track::Run2Track) || + !(track.flags() & o2::aod::track::TPCrefit) || + !(track.flags() & o2::aod::track::ITSrefit)) { + return false; + } + } + return true; + } + + template + bool selectTrack(const T& track) + { + if (requirePVContributor && !(track.isPVContributor())) + return false; + if (!track.hasITS()) + return false; + if (track.itsNCls() < minReqClusterITS) + return false; + if (!track.hasTPC()) + return false; + if (track.tpcNClsCrossedRows() < minNCrossedRowsTPC) + return false; + if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < minRatioCrossedRowsTPC) + return false; + if (track.tpcChi2NCl() > maxChi2TPC) + return false; + if (track.itsChi2NCl() > maxChi2ITS) + return false; + if (std::fabs(track.eta()) > maxEta) + return false; + if (track.pt() < minTrackPt) + return false; + + return true; + } + + // reject any track that has TPC nsigma < 3 for more than 1 species to avoid ambiguity (not really suitable for the low statistics in jets, thus optional) + template + bool singleSpeciesTPCNSigma(T const& track) + { + if (useRejectionCut && (track.tpcNSigmaStoreEl() < nsigmaRejection || track.tpcNSigmaStoreMu() < nsigmaRejection || track.tpcNSigmaPi() < nsigmaRejection || track.tpcNSigmaKa() < nsigmaRejection || track.tpcNSigmaStoreTr() < nsigmaRejection || track.tpcNSigmaStoreAl() < nsigmaRejection || track.tpcNSigmaDe() < nsigmaRejection || track.tpcNSigmaHe() < nsigmaRejection)) + return false; + return true; + } + + template + bool isProton(const T& track) + { + if (track.sign() < 0) + return false; + + double pt = track.pt(); + + // DCA + double maxDCApt = 1.2; + if (pt < maxDCApt) { + if (std::abs(track.dcaXY()) > protonDCAxy) + return false; + if (std::abs(track.dcaZ()) > protonDCAz) + return false; + } + + // nsigma + double midPt = 1.5; + double highPt = 3.0; + + // set max nsigma depending on pt range + double maxTPCnsigma = protonTPCnsigma; + double maxTOFnsigma = protonTOFnsigma; + if (pt > midPt) { + maxTPCnsigma = protonTPCnsigma - 1; + maxTOFnsigma = protonTOFnsigma - 1; + } + if (pt > highPt) { + maxTPCnsigma = protonTPCnsigma - 2; + maxTOFnsigma = protonTOFnsigma - 2; + } + + // only TPC below 0.7 GeV + registryData.fill(HIST("tpcNSigmaProton"), track.pt(), track.tpcNSigmaPr()); + if (pt < protonTPCTOFpT && (std::abs(track.tpcNSigmaPr()) > maxTPCnsigma)) + return false; + + double tofNSigma = 999; + if (track.hasTOF()) { + registryData.fill(HIST("tofNSigmaProton"), track.pt(), track.tofNSigmaPr()); + tofNSigma = track.tofNSigmaPr(); + } + + // require TOF as well above 0.7 GeV + if (pt > protonTPCTOFpT && ((std::abs(tofNSigma) > maxTOFnsigma) || std::abs(track.tpcNSigmaPr()) > maxTPCnsigma)) + return false; + + if (useRejectionCut && !singleSpeciesTPCNSigma(track)) // useRejectionCut false by default + return false; + + return true; + } + + template + bool isAntiproton(const T& track) + { + if (track.sign() > 0) + return false; + + double pt = track.pt(); + + // DCA + double maxDCApt = 1.2; + if (pt < maxDCApt) { + if (std::abs(track.dcaXY()) > antiprotonDCAxy) + return false; + if (std::abs(track.dcaZ()) > antiprotonDCAz) + return false; + } + + // nsigma + double midPt = 1.5; + double highPt = 3.0; + + // set max nsigma depending on pt range + double maxTPCnsigma = antiprotonTPCnsigma; + double maxTOFnsigma = antiprotonTOFnsigma; + if (pt > midPt) { + maxTPCnsigma = antiprotonTPCnsigma - 1; + maxTOFnsigma = antiprotonTOFnsigma - 1; + } + if (pt > highPt) { + maxTPCnsigma = antiprotonTPCnsigma - 2; + maxTOFnsigma = antiprotonTOFnsigma - 2; + } + + // only TPC below 0.7 GeV + registryData.fill(HIST("tpcNSigmaAntiproton"), track.pt(), track.tpcNSigmaPr()); + if (pt < antiprotonTPCTOFpT && (std::abs(track.tpcNSigmaPr()) > maxTPCnsigma)) + return false; + + double tofNSigma = 999; + if (track.hasTOF()) { + registryData.fill(HIST("tofNSigmaAntiproton"), track.pt(), track.tofNSigmaPr()); + tofNSigma = track.tofNSigmaPr(); + } + + // require TOF as well above 0.7 GeV + if (pt > antiprotonTPCTOFpT && ((std::abs(tofNSigma) > maxTOFnsigma) || std::abs(track.tpcNSigmaPr()) > maxTPCnsigma)) + return false; + + if (useRejectionCut && !singleSpeciesTPCNSigma(track)) + return false; + + return true; + } + + template + bool isPion(const T& track) + { + // looser cuts because it's pions and also because the results aren't used in ToMCCA + // DCA + if (std::abs(track.dcaXY()) > pionDCAxy) + return false; + if (std::abs(track.dcaZ()) > pionDCAz) + return false; + + registryData.fill(HIST("tpcNSigmaPion"), track.pt(), track.tpcNSigmaPi()); + + // TPC + if (track.pt() < pionTPCTOFpT && std::abs(track.tpcNSigmaPi()) > pionTPCnsigmaLowPt) + return false; + if (track.pt() > pionTPCTOFpT && std::abs(track.tpcNSigmaPi()) > pionTPCnsigmaHighPt) + return false; + + // TOF + if (track.hasTOF()) { + registryData.fill(HIST("tofNSigmaPion"), track.pt(), track.tofNSigmaPi()); + if (track.pt() > pionTPCTOFpT && std::abs(track.tofNSigmaPi()) > pionTOFnsigma) + return false; + } + + return true; + } + + template + bool isKaon(const T& track) + { + // looser cuts because this was just for the particle-jet pt correlations + // DCA + if (std::abs(track.dcaXY()) > kaonDCAxy) + return false; + if (std::abs(track.dcaZ()) > kaonDCAz) + return false; + + registryData.fill(HIST("tpcNSigmaKaon"), track.pt(), track.tpcNSigmaKa()); + + // TPC + if (track.pt() < kaonTPCTOFpT && std::abs(track.tpcNSigmaKa()) > kaonTPCnsigmaLowPt) + return false; + if (track.pt() > kaonTPCTOFpT && std::abs(track.tpcNSigmaKa()) > kaonTPCnsigmaHighPt) + return false; + + // TOF + if (track.hasTOF()) { + registryData.fill(HIST("tofNSigmaKaon"), track.pt(), track.tofNSigmaKa()); + if (track.pt() > kaonTPCTOFpT && std::abs(track.tofNSigmaKa()) > kaonTOFnsigma) + return false; + } + + return true; + } + + void setTrackBuffer(const auto& tempBuffer, auto& buffer) // refresh track buffer + { + for (const auto& pair : tempBuffer) { // loop over angles we collected during same-event correlations + if (static_cast(buffer.size()) == trackBufferSize) { + buffer.insert(buffer.begin(), pair); // insert angles at the beginning + buffer.resize(trackBufferSize); // trim at the end, down to buffer size + } else if (static_cast(buffer.size()) < trackBufferSize) { // buffer not full yet + buffer.emplace_back(pair); + } + } + } + + void fillMixedEventDeltas(const auto& track, const auto& buffer, int particleType, const TVector3 jetAxis) // correlate tracks from current event with tracks from buffer, i.e. other events + { + if (buffer.size() == 0) + return; + if (std::isnan(track.phi()) || std::isnan(jetAxis.Phi())) + return; + for (int i = 0; i < static_cast(buffer.size()); i++) { // loop over tracks in buffer + if (std::isnan(buffer.at(i).first)) + continue; + if (buffer.at(i).first > constants::math::TwoPI || buffer.at(i).first < -constants::math::TwoPI) { + registryData.fill(HIST("trackProtocol"), 13); // # buffer tracks failed with phi > 2 pi + continue; + } + + // deltaPhi = (difference track 1 to jet axis 1) - (difference track 2 to jet axis 2) + // overlay jet axes from different events to pretend tracks are from same jet + double phiToAxis = RecoDecay::constrainAngle(track.phi() - jetAxis.Phi(), 0); + double etaToAxis = track.eta() - jetAxis.Eta(); + double deltaPhi = RecoDecay::constrainAngle(phiToAxis - buffer.at(i).first, -constants::math::PIHalf); + double deltaEta = etaToAxis - buffer.at(i).second; + + switch (particleType) { + case -1: + registryData.fill(HIST("deltaPhiMEFull"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaMEFull"), deltaPhi, deltaEta); + break; + case 0: + registryData.fill(HIST("deltaPhiMEJet"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaMEJet"), deltaPhi, deltaEta); + break; + case 1: + registryData.fill(HIST("deltaPhiMEProton"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaMEProton"), deltaPhi, deltaEta); + break; + case 2: + registryData.fill(HIST("deltaPhiMEAntiproton"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaMEAntiproton"), deltaPhi, deltaEta); + break; + case 3: + registryData.fill(HIST("deltaPhiMEPion"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaMEPion"), deltaPhi, deltaEta); + break; + case 4: + registryData.fill(HIST("deltaPhiMEProtonAntiproton"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaMEProtonAntiproton"), deltaPhi, deltaEta); + break; + case 5: + registryData.fill(HIST("deltaPhiMEProtonUE"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaMEProtonUE"), deltaPhi, deltaEta); + break; + case 6: + registryData.fill(HIST("deltaPhiMEAntiprotonUE"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaMEAntiprotonUE"), deltaPhi, deltaEta); + break; + case 7: + registryData.fill(HIST("deltaPhiMEPionUE"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaMEPionUE"), deltaPhi, deltaEta); + break; + } + } // for (int i = 0; i < static_cast(buffer.size()); i++) + } + + void doCorrelations(const auto& particleVector, const auto& buffer, auto& tempBuffer, int particleType, const TVector3 jetAxis) + { + if (std::isnan(jetAxis.Phi())) + return; + for (int i = 0; i < static_cast(particleVector.size()); i++) { // loop over SE tracks + if (std::isnan(particleVector.at(i).phi())) + continue; + double phiToAxis = RecoDecay::constrainAngle(particleVector.at(i).phi() - jetAxis.Phi(), 0); // for use in ME function + double etaToAxis = particleVector.at(i).eta() - jetAxis.Eta(); + if (std::abs(particleVector.at(i).phi()) > constants::math::TwoPI) { + registryData.fill(HIST("trackProtocol"), 11); // # tracks failed with phi > 2 pi + continue; + } + for (int j = i + 1; j < static_cast(particleVector.size()); j++) { // loop over remaining SE tracks + if ((j == static_cast(particleVector.size())) || std::isnan(particleVector.at(j).phi())) + continue; + if (std::abs(particleVector.at(j).phi()) > constants::math::TwoPI) { + registryData.fill(HIST("trackProtocol"), 12); // # tracks failed with phi > 2 pi + continue; + } + + double deltaPhi = RecoDecay::constrainAngle(particleVector.at(i).phi() - particleVector.at(j).phi(), -constants::math::PIHalf); // dPhi in [-pi/2, 3pi/2] + double deltaEta = particleVector.at(i).eta() - particleVector.at(j).eta(); + switch (particleType) { + case -1: + registryData.fill(HIST("deltaPhiSEFull"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaSEFull"), deltaPhi, deltaEta); + break; + case 0: + registryData.fill(HIST("deltaPhiSEJet"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaSEJet"), deltaPhi, deltaEta); + break; + case 1: + registryData.fill(HIST("deltaPhiSEProton"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaSEProton"), deltaPhi, deltaEta); + break; + case 2: + registryData.fill(HIST("deltaPhiSEAntiproton"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaSEAntiproton"), deltaPhi, deltaEta); + break; + case 3: + registryData.fill(HIST("deltaPhiSEPion"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaSEPion"), deltaPhi, deltaEta); + break; + case 5: + registryData.fill(HIST("deltaPhiSEProtonUE"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaSEProtonUE"), deltaPhi, deltaEta); + break; + case 6: + registryData.fill(HIST("deltaPhiSEAntiprotonUE"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaSEAntiprotonUE"), deltaPhi, deltaEta); + break; + case 7: + registryData.fill(HIST("deltaPhiSEPionUE"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaSEPionUE"), deltaPhi, deltaEta); + break; + } + } // for (int j = i + 1; j < static_cast(particleVector.size()); j++) + fillMixedEventDeltas(particleVector.at(i), buffer, particleType, jetAxis); // do ME distribution of current track vs all tracks in buffer + tempBuffer.emplace_back(std::make_pair(phiToAxis, etaToAxis)); // use pair to maintain phi-eta correlation + } // for (int i = 0; i < static_cast(particleVector.size()); i++) + } + + void doCorrelationsAnti(const auto& particleVector, const auto& particleVectorAnti, const auto& bufferAnti, auto& tempBuffer, const TVector3 jetAxis) // correlations between proton/antiproton - same story as doCorrelations but different track vectors are correlated + { + if (std::isnan(jetAxis.Phi())) + return; + for (int i = 0; i < static_cast(particleVector.size()); i++) { + if (std::isnan(particleVector.at(i).phi())) + continue; + double phiToAxis = RecoDecay::constrainAngle(particleVector.at(i).phi() - jetAxis.Phi(), 0); + double etaToAxis = particleVector.at(i).eta() - jetAxis.Eta(); + if (std::abs(particleVector.at(i).phi()) > constants::math::TwoPI) { + registryData.fill(HIST("trackProtocol"), 14); // # tracks failed with phi > 2 pi + continue; + } + for (int j = 0; j < static_cast(particleVectorAnti.size()); j++) { + if (std::isnan(particleVectorAnti.at(j).phi())) + continue; + if (std::abs(particleVectorAnti.at(j).phi()) > constants::math::TwoPI) { + registryData.fill(HIST("trackProtocol"), 15); // # tracks failed with phi > 2 pi + continue; + } + + double deltaPhi = RecoDecay::constrainAngle(particleVector.at(i).phi() - particleVectorAnti.at(j).phi(), -constants::math::PIHalf); + double deltaEta = particleVector.at(i).eta() - particleVectorAnti.at(j).eta(); + registryData.fill(HIST("deltaPhiSEProtonAntiproton"), deltaPhi); + registryData.fill(HIST("deltaPhiEtaSEProtonAntiproton"), deltaPhi, deltaEta); + break; + } + fillMixedEventDeltas(particleVector.at(i), bufferAnti, 4, jetAxis); + tempBuffer.emplace_back(std::make_pair(phiToAxis, etaToAxis)); + } + } + + void getPerpendicularAxis(TVector3 p, TVector3& u, double sign) + { + // Initialization + double ux(0), uy(0), uz(0); + + // Components of Vector p + double px = p.X(); + double py = p.Y(); + double pz = p.Z(); + + // Protection 1 + if (px == 0 && py != 0) { + uy = -(pz * pz) / py; + ux = sign * std::abs(py * py - (pz * pz * pz * pz) / (py * py)); + uz = pz; + u.SetXYZ(ux, uy, uz); + return; + } + + // Protection 2 + if (py == 0 && px != 0) { + ux = -(pz * pz) / px; + uy = sign * std::abs(px * px - (pz * pz * pz * pz) / (px * px)); + uz = pz; + u.SetXYZ(ux, uy, uz); + return; + } + + // Equation Parameters + double a = px * px + py * py; + double b = 2.0 * px * pz * pz; + double c = pz * pz * pz * pz - py * py * py * py - px * px * py * py; + double delta = b * b - 4.0 * a * c; + + // Protection agains delta<0 + if (delta < 0) { + return; + } + + // Solutions + ux = (-b + sign * std::abs(delta)) / (2.0 * a); + uy = (-pz * pz - px * ux) / py; + uz = pz; + u.SetXYZ(ux, uy, uz); + return; + } + + int analyseJet(int jetCounter, fastjet::PseudoJet jet, const auto& particles, auto& jetProtons, auto& jetAntiprotons, auto& jetPiPlus, auto& jetPiMinus, auto& jetAll, double rhoPerp, double rhoMPerp) + { + if (!jet.has_constituents()) + return jetCounter; + fastjet::PseudoJet subtractedJetPerp(0., 0., 0., 0.); + subtractedJetPerp = bkgSub.doRhoAreaSub(jet, rhoPerp, rhoMPerp); + + if (subtractedJetPerp.pt() < minJetPt) // cut on jet without bkg + return jetCounter; + if ((std::fabs(jet.eta()) + jetR) > (maxEta - deltaEtaEdge)) // keep jet away from acceptance edge + return jetCounter; + registryData.fill(HIST("ptTotalSubJetPerp"), subtractedJetPerp.pt()); + registryQC.fill(HIST("rhoEstimatePerp"), jet.pt(), rhoPerp); + registryQC.fill(HIST("rhoMEstimatePerp"), jet.pt(), rhoMPerp); + double jetBkgDeltaPt = jet.pt() - subtractedJetPerp.pt(); + + registryData.fill(HIST("eventProtocol"), 4); + std::vector constituents = jet.constituents(); + + if (constituents.size() <= 1) + return jetCounter; + + jetCounter++; + + registryData.fill(HIST("eventProtocol"), 5); + registryData.fill(HIST("numberOfJets"), 0); + registryData.fill(HIST("ptTotalJet"), jet.pt()); + registryData.fill(HIST("jetRapidity"), jet.rap()); + registryData.fill(HIST("numPartInJet"), jet.constituents().size()); + + TVector3 pJet(0., 0., 0.); + pJet.SetXYZ(jet.px(), jet.py(), jet.pz()); // create jet axis + + if (outputQC) { // for comparison with antinucleiInJets + registryQC.fill(HIST("jetBkgDeltaPt"), jetBkgDeltaPt); + registryQC.fill(HIST("jetPtVsNumPart"), jet.pt(), jet.constituents().size()); + + double maxRadius = 0; // get max distance of a jet track to jet axis + for (const auto& constituent : constituents) { + registryData.fill(HIST("ptJetParticle"), constituent.pt()); + registryQC.fill(HIST("phiJet"), constituent.phi()); + registryQC.fill(HIST("phiPtJet"), constituent.pt(), constituent.phi()); + registryQC.fill(HIST("etaJet"), constituent.eta()); + registryQC.fill(HIST("etaPtJet"), constituent.pt(), constituent.eta()); + + if (std::isnan(constituent.phi()) || std::isnan(jet.phi())) // geometric jet cone + continue; + double deltaPhi = RecoDecay::constrainAngle(constituent.phi() - jet.phi(), -constants::math::PIHalf); + double deltaEta = constituent.eta() - jet.eta(); + double delta = std::abs(deltaPhi * deltaPhi + deltaEta * deltaEta); + registryQC.fill(HIST("jetConeRadius"), delta); + if (delta > maxRadius) + maxRadius = delta; + } + registryQC.fill(HIST("maxRadiusVsPt"), jet.pt(), maxRadius); + + TVector3 ueAxis1(0.0, 0.0, 0.0); + TVector3 ueAxis2(0.0, 0.0, 0.0); + getPerpendicularAxis(pJet, ueAxis1, +1.0); + getPerpendicularAxis(pJet, ueAxis2, -1.0); + + double nchJetPlusUE(0); + double nchJet(0); + double nchUE(0); + double ptJetPlusUE(0); + double ptJet(0); + double ptUE(0); + + for (const auto& [index, track] : particles) { + TVector3 particleDir(track.px(), track.py(), track.pz()); + double deltaEtaJet = particleDir.Eta() - pJet.Eta(); + double deltaPhiJet = RecoDecay::constrainAngle(particleDir.Phi() - pJet.Phi(), -constants::math::PI); + double deltaRJet = std::abs(deltaEtaJet * deltaEtaJet + deltaPhiJet * deltaPhiJet); + double deltaEtaUE1 = particleDir.Eta() - ueAxis1.Eta(); + double deltaPhiUE1 = RecoDecay::constrainAngle(particleDir.Phi() - ueAxis1.Phi(), -constants::math::PI); + double deltaRUE1 = std::abs(deltaEtaUE1 * deltaEtaUE1 + deltaPhiUE1 * deltaPhiUE1); + double deltaEtaUE2 = particleDir.Eta() - ueAxis2.Eta(); + double deltaPhiUE2 = RecoDecay::constrainAngle(particleDir.Phi() - ueAxis2.Phi(), -constants::math::PI); + double deltaRUE2 = std::abs(deltaEtaUE2 * deltaEtaUE2 + deltaPhiUE2 * deltaPhiUE2); + double failedPhi = -999; + if (deltaRJet < jetR) { + if (deltaPhiJet != failedPhi) + registryQC.fill(HIST("deltaEtadeltaPhiJet"), deltaEtaJet, deltaPhiJet); + nchJetPlusUE++; + ptJetPlusUE = ptJetPlusUE + track.pt(); + } + if (deltaRUE1 < jetR) { + if (deltaPhiUE1 != failedPhi) + registryQC.fill(HIST("deltaEtadeltaPhiUE"), deltaEtaUE1, deltaPhiUE1); + nchUE++; + ptUE = ptUE + track.pt(); + } + if (deltaRUE2 < jetR) { + if (deltaPhiUE2 != failedPhi) + registryQC.fill(HIST("deltaEtadeltaPhiUE"), deltaEtaUE2, deltaPhiUE2); + nchUE++; + ptUE = ptUE + track.pt(); + } + } // for (const auto& [index, track] : particles) + + nchJet = nchJetPlusUE - 0.5 * nchUE; + ptJet = ptJetPlusUE - 0.5 * ptUE; + registryQC.fill(HIST("multiplicityJetPlusUE"), nchJetPlusUE); + registryQC.fill(HIST("multiplicityJet"), nchJet); + registryQC.fill(HIST("multiplicityUE"), 0.5 * nchUE); + registryQC.fill(HIST("ptJetPlusUE"), ptJetPlusUE); + registryQC.fill(HIST("ptJet"), ptJet); + registryQC.fill(HIST("ptUE"), 0.5 * ptUE); + registryQC.fill(HIST("deltaJetPt"), jet.pt() - ptJetPlusUE); + + int nPartClusteredJet = static_cast(constituents.size()); + + // Fill QA Histograms + if (ptJetPlusUE < minJetPt) { // swap for sub pt? + + registryQC.fill(HIST("nParticlesClusteredInJet"), nPartClusteredJet); + + for (const auto& track : constituents) { + registryQC.fill(HIST("ptParticlesClusteredInJet"), track.pt()); + } + } + } + + std::vector> fTempBufferProton; + std::vector> fTempBufferAntiproton; + std::vector> fTempBufferPiPlus; + std::vector> fTempBufferPiMinus; + std::vector> fTempBufferJet; + fTempBufferProton.clear(); + fTempBufferPiPlus.clear(); + fTempBufferPiMinus.clear(); + fTempBufferAntiproton.clear(); + fTempBufferJet.clear(); + + for (const auto& pseudoParticle : constituents) { // analyse jet constituents + registryData.fill(HIST("trackProtocol"), 2); + int id = pseudoParticle.user_index(); + const auto& jetParticle = particles.at(id); // get track for corresponding PseudoJet index + if (!selectTrack(jetParticle)) + continue; + jetAll.emplace_back(jetParticle); + + registryData.fill(HIST("tpcSignal"), jetParticle.pt() * jetParticle.sign(), jetParticle.tpcSignal()); + if (jetParticle.hasTOF()) { + registryData.fill(HIST("tofSignal"), jetParticle.pt() * jetParticle.sign(), jetParticle.beta()); + } + if (outputQC) { + double ptDiff = pseudoParticle.pt() - jetParticle.pt(); // track recovery from PseudoJet index working properly if this is close to 0 + registryQC.fill(HIST("ptDiff"), ptDiff); + } + + // gather proton/antiproton/pion/kaon in respective vectors + if ((doppCorrelations || dopapCorrelations) && isProton(jetParticle)) { + registryData.fill(HIST("trackProtocol"), 3); // # high purity protons + registryData.fill(HIST("ptJetProton"), jetParticle.pt()); + registryData.fill(HIST("dcaZJetProton"), jetParticle.pt(), jetParticle.dcaZ()); + registryQC.fill(HIST("ptJetProtonVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); + jetProtons.emplace_back(jetParticle); + } else if ((doapapCorrelations || dopapCorrelations) && isAntiproton(jetParticle)) { + registryData.fill(HIST("trackProtocol"), 4); // # high purity antiprotons + registryData.fill(HIST("ptJetAntiproton"), jetParticle.pt()); + registryData.fill(HIST("dcaZJetAntiproton"), jetParticle.pt(), jetParticle.dcaZ()); + registryQC.fill(HIST("ptJetAntiprotonVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); + jetAntiprotons.emplace_back(jetParticle); + } else if (dopipiCorrelations && isPion(jetParticle)) { + registryQC.fill(HIST("ptJetPionVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); + registryData.fill(HIST("trackProtocol"), 5); + registryData.fill(HIST("dcaZJetPion"), jetParticle.pt(), jetParticle.dcaZ()); + if (jetParticle.sign() > 0) { + jetPiPlus.emplace_back(jetParticle); + } else if (jetParticle.sign() < 0) { + jetPiMinus.emplace_back(jetParticle); + } + } + if (measureKaons && isKaon(jetParticle)) { + registryQC.fill(HIST("ptJetKaonVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); + registryData.fill(HIST("trackProtocol"), 6); + registryData.fill(HIST("dcaZJetKaon"), jetParticle.pt(), jetParticle.dcaZ()); + } + } // for (const auto& pseudoParticle : constituents) + + if (doJetCorrelations && jetAll.size() > 1) { // correlation of all jet particles + doCorrelations(jetAll, fBufferJet, fTempBufferJet, 0, pJet); + setTrackBuffer(fTempBufferJet, fBufferJet); + } + + if (dopapCorrelations && (jetProtons.size() > 0) && (jetAntiprotons.size() > 0)) { + doCorrelationsAnti(jetProtons, jetAntiprotons, fBufferAntiproton, fTempBufferProton, pJet); + doCorrelationsAnti(jetAntiprotons, jetProtons, fBufferProton, fTempBufferAntiproton, pJet); // don't worry about dividing result by 2, the factor will drop out in correlation function + } + int minNumPartForCorrelations = 2; + // need at least 2 tracks in any one list + if ((static_cast(jetProtons.size()) < minNumPartForCorrelations) && (static_cast(jetAntiprotons.size()) < minNumPartForCorrelations) && (static_cast(jetPiPlus.size()) < minNumPartForCorrelations) && (static_cast(jetPiMinus.size()) < minNumPartForCorrelations)) + return jetCounter; + registryData.fill(HIST("eventProtocol"), 6); + + if (doppCorrelations && jetProtons.size() > 1) { + doCorrelations(jetProtons, fBufferProton, fTempBufferProton, 1, pJet); + setTrackBuffer(fTempBufferProton, fBufferProton); + } + if (doapapCorrelations && jetAntiprotons.size() > 1) { + doCorrelations(jetAntiprotons, fBufferAntiproton, fTempBufferAntiproton, 2, pJet); + setTrackBuffer(fTempBufferAntiproton, fBufferAntiproton); + } + if (dopipiCorrelations && jetPiPlus.size() > 1) { + doCorrelations(jetPiPlus, fBufferPiPlus, fTempBufferPiPlus, 3, pJet); + setTrackBuffer(fTempBufferPiPlus, fBufferPiPlus); + } + if (dopipiCorrelations && jetPiMinus.size() > 1) { + doCorrelations(jetPiMinus, fBufferPiMinus, fTempBufferPiMinus, 3, pJet); + setTrackBuffer(fTempBufferPiMinus, fBufferPiMinus); + } + return jetCounter; + } + + template + void fillHistograms(U const& tracks) + { + std::vector jetProtons; + std::vector jetAntiprotons; + std::vector jetPiPlus; + std::vector jetPiMinus; + std::vector jetAll; + std::vector protonsUE; + std::vector antiprotonsUE; + std::vector piPlusUE; + std::vector piMinusUE; + jetProtons.clear(); + jetAntiprotons.clear(); + jetPiPlus.clear(); + jetPiMinus.clear(); + jetAll.clear(); + protonsUE.clear(); + antiprotonsUE.clear(); + piPlusUE.clear(); + piMinusUE.clear(); + std::vector> fTempBufferFull; + fTempBufferFull.clear(); + std::vector jetInput; // input for jet finder + std::map particles; // all selected particles in event + std::vector particlesForCF; // particles for full event angular correlations + jetInput.clear(); + particles.clear(); + int index = 0; // index attached to input PseudoJets + int jetCounter = 0; // how many actual jets in the event + + for (const auto& track : tracks) { + registryData.fill(HIST("trackProtocol"), 0); // # all tracks + if (!selectTrackForJetReco(track)) + continue; + + registryData.fill(HIST("trackProtocol"), 1); // # tracks selected for jet reconstruction + + if (outputQC && (track.tpcNClsFindable() != 0)) { + registryQC.fill(HIST("ratioCrossedRowsTPC"), track.pt(), track.tpcNClsCrossedRows() / track.tpcNClsFindable()); + } + + if (outputQC) { + registryQC.fill(HIST("ptFullEvent"), track.pt()); + registryQC.fill(HIST("crossedRowsTPC"), track.pt(), track.tpcNClsCrossedRows()); + registryQC.fill(HIST("clusterITS"), track.pt(), track.itsNCls()); + registryQC.fill(HIST("clusterTPC"), track.pt(), track.tpcNClsFound()); + registryQC.fill(HIST("chi2ITS"), track.pt(), track.itsChi2NCl()); + registryQC.fill(HIST("chi2TPC"), track.pt(), track.tpcChi2NCl()); + registryQC.fill(HIST("dcaXYFullEvent"), track.pt(), track.dcaXY()); + registryQC.fill(HIST("dcaZFullEvent"), track.pt(), track.dcaZ()); + registryQC.fill(HIST("phiFullEvent"), track.phi()); + registryQC.fill(HIST("phiPtFullEvent"), track.pt(), track.phi()); + registryQC.fill(HIST("etaFullEvent"), track.eta()); + registryQC.fill(HIST("etaPtFullEvent"), track.pt(), track.eta()); + } + fastjet::PseudoJet inputPseudoJet(track.px(), track.py(), track.pz(), track.energy(o2::constants::physics::MassPionCharged)); + inputPseudoJet.set_user_index(index); + particles[index] = track; + particlesForCF.emplace_back(track); + jetInput.emplace_back(inputPseudoJet); + + index++; + } // for (const auto& track : tracks) + + int minNumPartForJetReco = 2; + if (static_cast(jetInput.size()) < minNumPartForJetReco) + return; + registryData.fill(HIST("eventProtocol"), 2); + + // Reconstruct Jets + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, jetR); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); + fastjet::ClusterSequenceArea clusterSeq(jetInput, jetDef, areaDef); + std::vector jets = sorted_by_pt(clusterSeq.inclusive_jets()); + + if (jets.size() == 0) + return; + + registryData.fill(HIST("eventProtocol"), 3); + + auto [rhoPerp, rhoMPerp] = bkgSub.estimateRhoPerpCone(jetInput, jets); + + for (const auto& jet : jets) { + // this is where the magic happens + jetCounter = analyseJet(jetCounter, jet, particles, jetProtons, jetAntiprotons, jetPiPlus, jetPiMinus, jetAll, rhoPerp, rhoMPerp); + } + registryData.fill(HIST("numJetsInEvent"), jetCounter); + + TVector3 hardestJetAxis(jets.at(0).px(), jets.at(0).py(), jets.at(0).pz()); // for full event and UE, use hardest jet as orientation + doCorrelations(particlesForCF, fBufferFull, fTempBufferFull, -1, hardestJetAxis); + setTrackBuffer(fTempBufferFull, fBufferFull); + + if (!doUECorrelations) + return; + + // UE correlations + TVector3 ueAxis1(0.0, 0.0, 0.0); + TVector3 ueAxis2(0.0, 0.0, 0.0); + getPerpendicularAxis(hardestJetAxis, ueAxis1, +1.0); + getPerpendicularAxis(hardestJetAxis, ueAxis2, -1.0); + + // untested so far, and the method may need to be rethought, this is the best I could think of + // useBkgEstimateForUE == true tries to somewhat imitate a seeded anti-kt algorithm centred around the perp cone axis + // useBkgEstimateForUE == false simply collects all tracks geometrically, with a hard cut at R + for (const auto& track : tracks) { // try for first cone + double uePt = rhoPerp * constants::math::PI * jetR * jetR; // pt = rho_bkg * area + double trackPt = track.pt(); + if (isProton(track)) { + double geometricDelta = (std::pow(track.phi() - ueAxis1.Phi(), 2) + std::pow(track.eta() - ueAxis1.Eta(), 2)) / (jetR * jetR); + double dij = useBkgEstimateForUE ? std::min(1 / (trackPt * trackPt), 1 / (uePt * uePt)) * geometricDelta : geometricDelta; + double diB = useBkgEstimateForUE ? 1 / (uePt * uePt) : 1; + if (dij < diB) { + protonsUE.emplace_back(track); + if (outputQC) + registryQC.fill(HIST("whichUECone"), 1); // see if track ends up in cone 1 or 2 + } + } else if (isAntiproton(track)) { + double geometricDelta = (std::pow(track.phi() - ueAxis1.Phi(), 2) + std::pow(track.eta() - ueAxis1.Eta(), 2)) / (jetR * jetR); + double dij = useBkgEstimateForUE ? std::min(1 / (trackPt * trackPt), 1 / (uePt * uePt)) * geometricDelta : geometricDelta; + double diB = useBkgEstimateForUE ? 1 / (uePt * uePt) : 1; + if (dij < diB) { + antiprotonsUE.emplace_back(track); + if (outputQC) + registryQC.fill(HIST("whichUECone"), 1); + } + } else if (isPion(track)) { + double geometricDelta = (std::pow(track.phi() - ueAxis1.Phi(), 2) + std::pow(track.eta() - ueAxis1.Eta(), 2)) / (jetR * jetR); + double dij = useBkgEstimateForUE ? std::min(1 / (trackPt * trackPt), 1 / (uePt * uePt)) * geometricDelta : geometricDelta; + double diB = useBkgEstimateForUE ? 1 / (uePt * uePt) : 1; + if (dij < diB) { + track.sign() > 0 ? piPlusUE.emplace_back(track) : piMinusUE.emplace_back(track); + if (outputQC) + registryQC.fill(HIST("whichUECone"), 1); + } + } + } // for (const auto& track : tracks) + + std::vector> fTempBufferProtonUE; + std::vector> fTempBufferAntiprotonUE; + std::vector> fTempBufferPiPlusUE; + std::vector> fTempBufferPiMinusUE; + + doCorrelations(protonsUE, fBufferProtonsUE, fTempBufferProtonUE, 5, ueAxis1); + setTrackBuffer(fTempBufferProtonUE, fBufferProtonsUE); + + doCorrelations(antiprotonsUE, fBufferAntiprotonsUE, fTempBufferAntiprotonUE, 6, ueAxis1); + setTrackBuffer(fTempBufferProtonUE, fBufferAntiprotonsUE); + + doCorrelations(piPlusUE, fBufferPiPlusUE, fTempBufferPiPlusUE, 7, ueAxis1); + setTrackBuffer(fTempBufferProtonUE, fBufferPiPlusUE); + + doCorrelations(piMinusUE, fBufferPiMinusUE, fTempBufferPiMinusUE, 7, ueAxis1); + setTrackBuffer(fTempBufferProtonUE, fBufferPiMinusUE); + + fTempBufferProtonUE.clear(); + fTempBufferAntiprotonUE.clear(); + fTempBufferPiPlusUE.clear(); + fTempBufferPiMinusUE.clear(); + fBufferProtonsUE.clear(); + fBufferAntiprotonsUE.clear(); + fBufferPiPlusUE.clear(); + fBufferPiMinusUE.clear(); + + for (const auto& track : tracks) { // try for second cone + double uePt = rhoPerp * constants::math::PI * jetR * jetR; // pt = rho_bkg * area + double trackPt = track.pt(); + if (isProton(track)) { + double geometricDelta = (std::pow(track.phi() - ueAxis2.Phi(), 2) + std::pow(track.eta() - ueAxis2.Eta(), 2)) / (jetR * jetR); + double dij = useBkgEstimateForUE ? std::min(1 / (trackPt * trackPt), 1 / (uePt * uePt)) * geometricDelta : geometricDelta; + double diB = useBkgEstimateForUE ? 1 / (uePt * uePt) : 1; + if (dij < diB) { + protonsUE.emplace_back(track); + if (outputQC) + registryQC.fill(HIST("whichUECone"), 2); // see if track ends up in cone 1 or 2 + } + } else if (isAntiproton(track)) { + double geometricDelta = (std::pow(track.phi() - ueAxis2.Phi(), 2) + std::pow(track.eta() - ueAxis2.Eta(), 2)) / (jetR * jetR); + double dij = useBkgEstimateForUE ? std::min(1 / (trackPt * trackPt), 1 / (uePt * uePt)) * geometricDelta : geometricDelta; + double diB = useBkgEstimateForUE ? 1 / (uePt * uePt) : 1; + if (dij < diB) { + antiprotonsUE.emplace_back(track); + if (outputQC) + registryQC.fill(HIST("whichUECone"), 2); + } + } else if (isPion(track)) { + double geometricDelta = (std::pow(track.phi() - ueAxis2.Phi(), 2) + std::pow(track.eta() - ueAxis2.Eta(), 2)) / (jetR * jetR); + double dij = useBkgEstimateForUE ? std::min(1 / (trackPt * trackPt), 1 / (uePt * uePt)) * geometricDelta : geometricDelta; + double diB = useBkgEstimateForUE ? 1 / (uePt * uePt) : 1; + if (dij < diB) { + track.sign() > 0 ? piPlusUE.emplace_back(track) : piMinusUE.emplace_back(track); + if (outputQC) + registryQC.fill(HIST("whichUECone"), 2); + } + } + } // for (const auto& track : tracks) + + doCorrelations(protonsUE, fBufferProtonsUE, fTempBufferProtonUE, 5, ueAxis2); + setTrackBuffer(fTempBufferProtonUE, fBufferProtonsUE); + + doCorrelations(antiprotonsUE, fBufferAntiprotonsUE, fTempBufferAntiprotonUE, 6, ueAxis2); + setTrackBuffer(fTempBufferProtonUE, fBufferAntiprotonsUE); + + doCorrelations(piPlusUE, fBufferPiPlusUE, fTempBufferPiPlusUE, 7, ueAxis2); + setTrackBuffer(fTempBufferProtonUE, fBufferPiPlusUE); + + doCorrelations(piMinusUE, fBufferPiMinusUE, fTempBufferPiMinusUE, 7, ueAxis2); + setTrackBuffer(fTempBufferProtonUE, fBufferPiMinusUE); + } + + // this may need to be reworked, it hasn't really been tested yet + // so far it does almost the same as fillHistograms without correlations but including MCgen tracks + template + void fillHistogramsMC(U const& tracks) + { + std::vector jetInput; // input for jet finder + std::map particles; // all selected particles in event + jetInput.clear(); + particles.clear(); + int index = 0; + + for (const auto& track : tracks) { + if (outputQC && (track.tpcNClsFindable() != 0)) { + registryQC.fill(HIST("ratioCrossedRowsTPC"), track.pt(), track.tpcNClsCrossedRows() / track.tpcNClsFindable()); + } + registryQC.fill(HIST("ptFullEvent"), track.pt()); + registryQC.fill(HIST("crossedRowsTPC"), track.pt(), track.tpcNClsCrossedRows()); + registryQC.fill(HIST("clusterITS"), track.pt(), track.itsNCls()); + registryQC.fill(HIST("clusterTPC"), track.pt(), track.tpcNClsFound()); + registryQC.fill(HIST("chi2ITS"), track.pt(), track.itsChi2NCl()); + registryQC.fill(HIST("chi2TPC"), track.pt(), track.tpcChi2NCl()); + registryQC.fill(HIST("dcaXYFullEvent"), track.pt(), track.dcaXY()); + registryQC.fill(HIST("dcaZFullEvent"), track.pt(), track.dcaZ()); + registryQC.fill(HIST("phiFullEvent"), track.phi()); + registryQC.fill(HIST("phiPtFullEvent"), track.pt(), track.phi()); + registryQC.fill(HIST("etaFullEvent"), track.eta()); + registryQC.fill(HIST("etaPtFullEvent"), track.pt(), track.eta()); + + fastjet::PseudoJet inputPseudoJet(track.px(), track.py(), track.pz(), track.energy(o2::constants::physics::MassPionCharged)); + inputPseudoJet.set_user_index(index); + particles[index] = track; + jetInput.emplace_back(inputPseudoJet); + + index++; + } // for (const auto& track : tracks) + + int minNumPartForJetReco = 2; + if (static_cast(jetInput.size()) < minNumPartForJetReco) + return; + registryData.fill(HIST("eventProtocol"), 2); + + // Reconstruct Jets + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, jetR); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); + fastjet::ClusterSequenceArea clusterSeq(jetInput, jetDef, areaDef); + std::vector jets = sorted_by_pt(clusterSeq.inclusive_jets()); + + if (jets.size() == 0) + return; + + registryData.fill(HIST("eventProtocol"), 3); + + auto [rhoPerp, rhoMPerp] = bkgSub.estimateRhoPerpCone(jetInput, jets); + + for (auto& jet : jets) { // o2-linter: disable=const-ref-in-for-loop (jets are modified) + if (!jet.has_constituents()) + continue; + fastjet::PseudoJet subtractedJetPerp(0., 0., 0., 0.); + subtractedJetPerp = bkgSub.doRhoAreaSub(jet, rhoPerp, rhoMPerp); + + if (subtractedJetPerp.pt() < minJetPt) // cut on jet w/o bkg + continue; + registryData.fill(HIST("ptTotalSubJetPerp"), subtractedJetPerp.pt()); + registryQC.fill(HIST("rhoEstimatePerp"), jet.pt(), rhoPerp); + registryQC.fill(HIST("rhoMEstimatePerp"), jet.pt(), rhoMPerp); + double jetBkgDeltaPt = jet.pt() - subtractedJetPerp.pt(); + registryQC.fill(HIST("jetBkgDeltaPt"), jetBkgDeltaPt); + + registryData.fill(HIST("eventProtocol"), 4); + std::vector constituents = jet.constituents(); + + registryData.fill(HIST("eventProtocol"), 5); + registryData.fill(HIST("numberOfJets"), 0); + registryData.fill(HIST("ptTotalJet"), jet.pt()); + registryData.fill(HIST("jetRapidity"), jet.rap()); + registryData.fill(HIST("numPartInJet"), jet.constituents().size()); + registryQC.fill(HIST("jetPtVsNumPart"), jet.pt(), jet.constituents().size()); + + double maxRadius = 0; + for (const auto& constituent : constituents) { + registryData.fill(HIST("ptJetParticle"), constituent.pt()); + registryQC.fill(HIST("phiJet"), constituent.phi()); + registryQC.fill(HIST("phiPtJet"), constituent.pt(), constituent.phi()); + registryQC.fill(HIST("etaJet"), constituent.eta()); + registryQC.fill(HIST("etaPtJet"), constituent.pt(), constituent.eta()); + + if (std::isnan(constituent.phi()) || std::isnan(jet.phi())) // geometric jet cone + continue; + double deltaPhi = RecoDecay::constrainAngle(constituent.phi() - jet.phi(), -constants::math::PIHalf); + double deltaEta = constituent.eta() - jet.eta(); + double delta = std::abs(deltaPhi * deltaPhi + deltaEta * deltaEta); + registryQC.fill(HIST("jetConeRadius"), delta); + if (delta > maxRadius) + maxRadius = delta; + } + registryQC.fill(HIST("maxRadiusVsPt"), jet.pt(), maxRadius); + + TVector3 pJet(0., 0., 0.); + pJet.SetXYZ(jet.px(), jet.py(), jet.pz()); + TVector3 ueAxis1(0.0, 0.0, 0.0); + TVector3 ueAxis2(0.0, 0.0, 0.0); + getPerpendicularAxis(pJet, ueAxis1, +1.0); + getPerpendicularAxis(pJet, ueAxis2, -1.0); + + double nchJetPlusUE(0); + double nchJet(0); + double nchUE(0); + + for (const auto& [index, track] : particles) { + TVector3 particleDir(track.px(), track.py(), track.pz()); + double deltaEtaJet = particleDir.Eta() - pJet.Eta(); + double deltaPhiJet = RecoDecay::constrainAngle(particleDir.Phi() - pJet.Phi(), -constants::math::PI); + double deltaRJet = std::abs(deltaEtaJet * deltaEtaJet + deltaPhiJet * deltaPhiJet); + double deltaEtaUE1 = particleDir.Eta() - ueAxis1.Eta(); + double deltaPhiUE1 = RecoDecay::constrainAngle(particleDir.Phi() - ueAxis1.Phi(), -constants::math::PI); + double deltaRUE1 = std::abs(deltaEtaUE1 * deltaEtaUE1 + deltaPhiUE1 * deltaPhiUE1); + double deltaEtaUE2 = particleDir.Eta() - ueAxis2.Eta(); + double deltaPhiUE2 = RecoDecay::constrainAngle(particleDir.Phi() - ueAxis2.Phi(), -constants::math::PI); + double deltaRUE2 = std::abs(deltaEtaUE2 * deltaEtaUE2 + deltaPhiUE2 * deltaPhiUE2); + + double failedPhi = -999; + if (deltaRJet < jetR) { + if (deltaPhiJet != failedPhi) + registryQC.fill(HIST("deltaEtadeltaPhiJet"), deltaEtaJet, deltaPhiJet); + nchJetPlusUE++; + } + if (deltaRUE1 < jetR) { + if (deltaPhiUE1 != failedPhi) + registryQC.fill(HIST("deltaEtadeltaPhiUE"), deltaEtaUE1, deltaPhiUE1); + nchUE++; + } + if (deltaRUE2 < jetR) { + if (deltaPhiUE2 != failedPhi) + registryQC.fill(HIST("deltaEtadeltaPhiUE"), deltaEtaUE2, deltaPhiUE2); + nchUE++; + } + } // for (const auto& [index, track] : particles) + + nchJet = nchJetPlusUE - 0.5 * nchUE; + registryQC.fill(HIST("multiplicityJetPlusUE"), nchJetPlusUE); + registryQC.fill(HIST("multiplicityJet"), nchJet); + registryQC.fill(HIST("multiplicityUE"), 0.5 * nchUE); + + for (const auto& pseudoParticle : constituents) { // analyse jet constituents - this is where the magic happens + registryData.fill(HIST("trackProtocol"), 3); + int id = pseudoParticle.user_index(); + const auto& jetParticle = particles.at(id); + if (!selectTrack(jetParticle)) + continue; + + registryData.fill(HIST("tpcSignal"), jetParticle.pt() * jetParticle.sign(), jetParticle.tpcSignal()); + if (jetParticle.hasTOF()) { + registryData.fill(HIST("tofSignal"), jetParticle.pt() * jetParticle.sign(), jetParticle.beta()); + } + if (outputQC) { + double ptDiff = pseudoParticle.pt() - jetParticle.pt(); + registryQC.fill(HIST("ptDiff"), ptDiff); + } + + // if (jetParticle.pt() < minJetParticlePt) + // continue; + if (!jetParticle.has_mcParticle()) + continue; + switch (jetParticle.mcParticle().pdgCode()) { + case kProton: + registryMC.fill(HIST("numberOfTruthParticles"), 0); + registryMC.fill(HIST("ptJetProtonMC"), jetParticle.pt()); + break; + case kProtonBar: + registryMC.fill(HIST("numberOfTruthParticles"), 1); + registryMC.fill(HIST("ptJetAntiprotonMC"), jetParticle.pt()); + break; + default: + continue; + } + + if (!selectTrackForJetReco(jetParticle)) + continue; + switch (jetParticle.mcParticle().pdgCode()) { + case kProton: + registryData.fill(HIST("ptJetProton"), jetParticle.pt()); + registryQC.fill(HIST("ptJetProtonVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); + registryData.fill(HIST("trackProtocol"), 4); // # protons + break; + case kProtonBar: + registryData.fill(HIST("ptJetAntiproton"), jetParticle.pt()); + registryQC.fill(HIST("ptJetAntiprotonVsTotalJet"), jetParticle.pt(), subtractedJetPerp.pt()); + registryData.fill(HIST("trackProtocol"), 6); // # antiprotons + break; + default: + continue; + } + } // for (const auto& pseudoParticle : constituents) + } // for (auto& jet : jets) + } + + void processRun2(soa::Join const& collisions, + soa::Filtered const& tracks, + BCsWithRun2Info const&) + { + for (const auto& collision : collisions) { + if (rejectEvents) { + // event counter: before event rejection + registryData.fill(HIST("numberRejectedEvents"), 0); + + if (shouldRejectEvent()) + continue; + + // event counter: after event rejection + registryData.fill(HIST("numberRejectedEvents"), 1); + } + auto bc = collision.bc_as(); + initCCDB(bc); + + registryData.fill(HIST("eventProtocol"), 0); + if (!collision.alias_bit(kINT7)) + continue; + registryData.fill(HIST("numberOfEvents"), 0); + registryData.fill(HIST("eventProtocol"), 1); + + auto slicedTracks = tracks.sliceBy(perCollisionFullTracksRun2, collision.globalIndex()); + + fillHistograms(slicedTracks); + } + } + PROCESS_SWITCH(AngularCorrelationsInJets, processRun2, "process Run 2 data w/o jet tables", false); + + void processRun3(soa::Join const& collisions, + soa::Filtered const& tracks) + { + for (const auto& collision : collisions) { + if (rejectEvents) { + // event counter: before event rejection + registryData.fill(HIST("numberRejectedEvents"), 0); + + if (shouldRejectEvent()) + continue; + + // event counter: after event rejection + registryData.fill(HIST("numberRejectedEvents"), 1); + } + registryData.fill(HIST("eventProtocol"), 0); + if (!collision.sel8()) + continue; + registryData.fill(HIST("numberOfEvents"), 0); + registryData.fill(HIST("eventProtocol"), 1); + if (std::abs(collision.posZ()) > zVtx) + continue; + + auto slicedTracks = tracks.sliceBy(perCollisionFullTracksRun3, collision.globalIndex()); + + fillHistograms(slicedTracks); + } + } + PROCESS_SWITCH(AngularCorrelationsInJets, processRun3, "process Run 3 data w/o jet tables", false); + + void processMCRun2(McCollisions const& collisions, soa::Filtered const& tracks, BCsWithRun2Info const&, aod::McParticles const&, aod::McCollisions const&) + { + for (const auto& collision : collisions) { + if (rejectEvents) { + // event counter: before event rejection + registryData.fill(HIST("numberRejectedEvents"), 0); + + if (shouldRejectEvent()) + continue; + + // event counter: after event rejection + registryData.fill(HIST("numberRejectedEvents"), 1); + } + auto bc = collision.bc_as(); + initCCDB(bc); + + registryData.fill(HIST("eventProtocol"), 0); + if (!collision.alias_bit(kINT7)) + continue; + registryData.fill(HIST("numberOfEvents"), 0); + registryData.fill(HIST("eventProtocol"), 1); + + auto slicedTracks = tracks.sliceBy(perCollisionMcTracksRun2, collision.globalIndex()); + + fillHistogramsMC(slicedTracks); + } + } + PROCESS_SWITCH(AngularCorrelationsInJets, processMCRun2, "process Run 2 MC w/o jet tables, not currently usable", false); + + void processMCRun3(McCollisions const& collisions, soa::Filtered const& tracks, aod::McParticles const&, aod::McCollisions const&) + { + for (const auto& collision : collisions) { + if (rejectEvents) { + // event counter: before event rejection + registryData.fill(HIST("numberRejectedEvents"), 0); + + if (shouldRejectEvent()) + continue; + + // event counter: after event rejection + registryData.fill(HIST("numberRejectedEvents"), 1); + } + registryData.fill(HIST("eventProtocol"), 0); + if (!collision.sel8()) + continue; + registryData.fill(HIST("numberOfEvents"), 0); + registryData.fill(HIST("eventProtocol"), 1); + if (std::abs(collision.posZ()) > zVtx) + continue; + + auto slicedTracks = tracks.sliceBy(perCollisionMcTracksRun3, collision.globalIndex()); + + fillHistogramsMC(slicedTracks); + } + } + PROCESS_SWITCH(AngularCorrelationsInJets, processMCRun3, "process Run 3 MC w/o jet tables, not currently usable", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Nuspex/antidLambdaEbye.cxx b/PWGLF/Tasks/Nuspex/antidLambdaEbye.cxx deleted file mode 100644 index f31fff08713..00000000000 --- a/PWGLF/Tasks/Nuspex/antidLambdaEbye.cxx +++ /dev/null @@ -1,1241 +0,0 @@ -// 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. - -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "DataFormatsTPC/BetheBlochAleph.h" -#include "Common/Core/PID/PIDTOF.h" -#include "Common/TableProducer/PID/pidTOFBase.h" - -#include "Common/Core/PID/TPCPIDResponse.h" -#include "Common/DataModel/PIDResponse.h" -#include "DCAFitter/DCAFitterN.h" - -#include "TDatabasePDG.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -using TracksFull = soa::Join; -using TracksFullIU = soa::Join; -using BCsWithRun2Info = soa::Join; - -namespace -{ -constexpr int kNpart = 2; -constexpr double betheBlochDefault[kNpart][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}, {-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}}; -constexpr double estimatorsCorrelationCoef[2]{-0.669108, 1.04489}; -constexpr double estimatorsSigmaPars[4]{0.933321, 0.0416976, -0.000936344, 8.92179e-06}; -constexpr double deltaEstimatorNsigma[2]{5.5, 5.}; -constexpr double partMass[kNpart]{o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}; -constexpr double partPdg[kNpart]{2212, o2::constants::physics::kDeuteron}; -static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; -static const std::vector particleNamesBB{"p", "d"}; -std::array, kNpart> tempTracks; -std::shared_ptr tempAntiLambda; -std::shared_ptr tempLambda; -std::shared_ptr nAntid; -std::shared_ptr nAntip; -std::shared_ptr nAntiL; -std::shared_ptr nL; -std::shared_ptr nSqAntid; -std::shared_ptr nSqAntip; -std::shared_ptr nSqAntiL; -std::shared_ptr nSqL; -std::shared_ptr nAntipAntid; -std::shared_ptr nLantiL; -std::shared_ptr nLantid; -std::shared_ptr nAntiLantid; -std::shared_ptr nGenAntid; -std::shared_ptr nGenAntip; -std::shared_ptr nGenAntiL; -std::shared_ptr nGenL; -std::shared_ptr nGenSqAntid; -std::shared_ptr nGenSqAntip; -std::shared_ptr nGenSqAntiL; -std::shared_ptr nGenSqL; -std::shared_ptr nGenAntipAntid; -std::shared_ptr nGenLantiL; -std::shared_ptr nGenLantid; -std::shared_ptr nGenAntiLantid; -std::array, kNpart> recTracks; -std::array, kNpart> recAntiTracks; -std::array, kNpart> genTracks; -std::array, kNpart> genAntiTracks; -std::array, kNpart> tpcNsigma; -std::array, kNpart> tpcNsigmaGlo; -std::array, kNpart> tofMass; -std::array, kNpart> tofSignal; -std::array, kNpart> tofSignal_glo; -void momTotXYZ(std::array& momA, std::array const& momB, std::array const& momC) -{ - for (int i = 0; i < 3; ++i) { - momA[i] = momB[i] + momC[i]; - } -} -float invMass2Body(std::array const& momA, std::array const& momB, std::array const& momC, float const& massB, float const& massC) -{ - float p2B = momB[0] * momB[0] + momB[1] * momB[1] + momB[2] * momB[2]; - float p2C = momC[0] * momC[0] + momC[1] * momC[1] + momC[2] * momC[2]; - float eB = std::sqrt(p2B + massB * massB); - float eC = std::sqrt(p2C + massC * massC); - float eA = eB + eC; - float massA = std::sqrt(eA * eA - momA[0] * momA[0] - momA[1] * momA[1] - momA[2] * momA[2]); - return massA; -} -float alphaAP(std::array const& momA, std::array const& momB, std::array const& momC) -{ - float momTot = std::sqrt(std::pow(momA[0], 2.) + std::pow(momA[1], 2.) + std::pow(momA[2], 2.)); - float lQlPos = (momB[0] * momA[0] + momB[1] * momA[1] + momB[2] * momA[2]) / momTot; - float lQlNeg = (momC[0] * momA[0] + momC[1] * momA[1] + momC[2] * momA[2]) / momTot; - return (lQlPos - lQlNeg) / (lQlPos + lQlNeg); -} -float etaFromMom(std::array const& momA, std::array const& momB) -{ - if (std::sqrt((1.f * momA[0] + 1.f * momB[0]) * (1.f * momA[0] + 1.f * momB[0]) + - (1.f * momA[1] + 1.f * momB[1]) * (1.f * momA[1] + 1.f * momB[1]) + - (1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) - - (1.f * momA[2] + 1.f * momB[2]) < - static_cast(1e-7)) { - if ((1.f * momA[2] + 1.f * momB[2]) < 0.f) - return -100.f; - return 100.f; - } - return 0.5f * std::log((std::sqrt((1.f * momA[0] + 1.f * momB[0]) * (1.f * momA[0] + 1.f * momB[0]) + - (1.f * momA[1] + 1.f * momB[1]) * (1.f * momA[1] + 1.f * momB[1]) + - (1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) + - (1.f * momA[2] + 1.f * momB[2])) / - (std::sqrt((1.f * momA[0] + 1.f * momB[0]) * (1.f * momA[0] + 1.f * momB[0]) + - (1.f * momA[1] + 1.f * momB[1]) * (1.f * momA[1] + 1.f * momB[1]) + - (1.f * momA[2] + 1.f * momB[2]) * (1.f * momA[2] + 1.f * momB[2])) - - (1.f * momA[2] + 1.f * momB[2]))); -} -float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) -{ - return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz)); -} -} // namespace - -struct CandidateV0 { - float pt; - float eta; - float mass; - float cpa; - float dcav0daugh; - float dcav0pv; - int64_t globalIndexPos = -999; - int64_t globalIndexNeg = -999; -}; - -struct CandidateTrack { - float pt; - float eta; - int64_t globalIndex = -999; -}; - -struct antidLambdaEbye { - std::mt19937 gen32; - std::vector candidateV0s; - std::array, 2> candidateTracks; - Service ccdb; - o2::vertexing::DCAFitterN<2> fitter; - - int nSubsamples; - int mRunNumber; - float d_bz; - // o2::base::MatLayerCylSet* lut = nullptr; - - ConfigurableAxis centAxis{"centAxis", {106, 0, 106}, "binning for the centrality"}; - ConfigurableAxis subsampleAxis{"subsampleAxis", {30, 0, 30}, "binning of the subsample axis"}; - ConfigurableAxis deltaEtaAxis{"deltaEtaAxis", {4, 0, 0.8}, "binning of the delta eta axis"}; - ConfigurableAxis ptAntidAxis{"ptAntidAxis", {VARIABLE_WIDTH, 0.7f, 0.8f, 0.9f, 1.0f, 1.2f, 1.4f, 1.6f, 1.8f}, "binning of the antideuteron pT axis (GeV/c)"}; - ConfigurableAxis ptAntipAxis{"ptAntipAxis", {VARIABLE_WIDTH, 0.4f, 0.6f, 0.7f, 0.8f, 0.9f}, "binning of the antiproton pT axis (GeV/c)"}; - ConfigurableAxis ptLambdaAxis{"ptLambdaAxis", {VARIABLE_WIDTH, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f}, "binning of the (anti)lambda pT axis (GeV/c)"}; - - ConfigurableAxis zVtxAxis{"zVtxBins", {100, -20.f, 20.f}, "Binning for the vertex z in cm"}; - ConfigurableAxis multAxis{"multAxis", {100, 0, 10000}, "Binning for the multiplicity axis"}; - ConfigurableAxis multFt0Axis{"multFt0Axis", {100, 0, 100000}, "Binning for the ft0 multiplicity axis"}; - ConfigurableAxis nGenRecAxis{"nGenRecAxis", {20, 0, 20}, "binning for the number of reconstructed or generated candidates per event"}; - - // binning of (anti)lambda QA histograms - ConfigurableAxis massLambdaAxis{"massLambdaAxis", {400, o2::constants::physics::MassLambda0 - 0.03f, o2::constants::physics::MassLambda0 + 0.03f}, "binning for the lambda invariant-mass"}; - ConfigurableAxis cosPaAxis{"cosPaAxis", {1e3, 0.95f, 1.00f}, "binning for the cosPa axis"}; - ConfigurableAxis radiusAxis{"radiusAxis", {1e3, 0.f, 100.f}, "binning for the radius axis"}; - ConfigurableAxis dcaV0daughAxis{"dcaV0daughAxis", {2e2, 0.f, 2.f}, "binning for the dca of V0 daughters"}; - ConfigurableAxis dcaDaughPvAxis{"dcaDaughPvAxis", {1e3, -10.f, 10.f}, "binning for the dca of positive daughter to PV"}; - - // binning of deuteron QA histograms - ConfigurableAxis tpcNsigmaAxis{"tpcNsigmaAxis", {100, -5.f, 5.f}, "tpc nsigma axis"}; - ConfigurableAxis tofMassAxis{"tofMassAxis", {1000, 0., 3.f}, "tof mass axis"}; - ConfigurableAxis momAxis{"momAxis", {60., 0.f, 3.f}, "momentum axis binning"}; - ConfigurableAxis momAxisFine{"momAxisFine", {5.e2, 0.f, 5.f}, "momentum axis binning"}; - ConfigurableAxis momResAxis{"momResAxis", {1.e2, -1.f, 1.f}, "momentum resolution binning"}; - ConfigurableAxis tpcAxis{"tpcAxis", {4.e2, 0.f, 4.e3f}, "tpc signal axis binning"}; - ConfigurableAxis tofAxis{"tofAxis", {1.e3, 0.f, 1.f}, "tof signal axis binning"}; - ConfigurableAxis tpcClsAxis{"tpcClsAxis", {160, 0.f, 160.f}, "tpc n clusters binning"}; - - struct : ConfigurableGroup { - Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"}; - Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 2, 6, particleNamesBB, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for deuteron"}; - Configurable zVtxMax{"zVtxMax", 10.0f, "maximum z position of the primary vertex"}; - Configurable etaMax{"etaMax", 0.8f, "maximum eta"}; - Configurable etaMaxV0dau{"etaMaxV0dau", 0.8f, "maximum eta V0 daughters"}; - - Configurable fillOnlySignal{"fillOnlySignal", false, "fill histograms only for true signal candidates (MC)"}; - - Configurable kINT7Intervals{"kINT7Intervals", false, "toggle kINT7 trigger selection in the 10-30% and 50-90% centrality intervals (2018 Pb-Pb)"}; - Configurable kUseTPCPileUpCut{"kUseTPCPileUpCut", false, "toggle strong correlation cuts (Run 2)"}; - Configurable kUseEstimatorsCorrelationCut{"kUseEstimatorsCorrelationCut", false, "toggle cut on the correlation between centrality estimators (2018 Pb-Pb)"}; - - Configurable antidPtMin{"antidPtMin", 0.8f, "minimum antideuteron pT (GeV/c)"}; - Configurable antidPtTof{"antidPtTof", 1.0f, "antideuteron pT to switch to TOF pid (GeV/c) "}; - Configurable antidPtMax{"antidPtMax", 1.8f, "maximum antideuteron pT (GeV/c)"}; - - Configurable antipPtMin{"antipPtMin", 0.4f, "minimum antiproton pT (GeV/c)"}; - Configurable antipPtTof{"antipPtTof", 0.6f, "antiproton pT to switch to TOF pid (GeV/c) "}; - Configurable antipPtMax{"antipPtMax", 0.9f, "maximum antiproton pT (GeV/c)"}; - - Configurable lambdaPtMin{"lambdaPtMin", 0.5f, "minimum (anti)lambda pT (GeV/c)"}; - Configurable lambdaPtMax{"lambdaPtMax", 3.0f, "maximum (anti)lambda pT (GeV/c)"}; - - Configurable trackNcrossedRows{"trackNcrossedRows", 70, "Minimum number of crossed TPC rows"}; - Configurable trackNclusItsCut{"trackNclusITScut", 5, "Minimum number of ITS clusters"}; - Configurable trackNclusTpcCut{"trackNclusTPCcut", 70, "Minimum number of TPC clusters"}; - Configurable trackDcaCut{"trackDcaCut", 0.1f, "DCA antid to PV"}; - - Configurable v0trackNcrossedRows{"v0trackNcrossedRows", 70, "Minimum number of crossed TPC rows for V0 daughter"}; - Configurable v0trackNclusItsCut{"v0trackNclusITScut", 1, "Minimum number of ITS clusters for V0 daughter"}; - Configurable v0trackNclusTpcCut{"v0trackNclusTPCcut", 70, "Minimum number of TPC clusters for V0 daughter"}; - Configurable v0trackNsharedClusTpc{"v0trackNsharedClusTpc", 10, "Maximum number of shared TPC clusters for V0 daughter"}; - Configurable v0requireITSrefit{"v0requireITSrefit", false, "require ITS refit for V0 daughter"}; - Configurable vetoMassK0Short{"vetoMassK0Short", -999.f, "veto for V0 compatible with K0s mass"}; - Configurable v0radiusMax{"v0radiusMax", 100.f, "maximum V0 radius eccepted"}; - - Configurable antidNsigmaTpcCutLow{"antidNsigmaTpcCutLow", 4.f, "TPC PID cut low"}; - Configurable antidNsigmaTpcCutUp{"antidNsigmaTpcCutUp", 4.f, "TPC PID cut up"}; - Configurable antidNsigmaTofCut{"antidNsigmaTofCut", 4.f, "TOF PID cut"}; - Configurable antidTpcInnerParamMax{"tpcInnerParamMax", 0.6f, "(temporary) tpc inner param cut"}; - Configurable antidTofMassMax{"tofMassMax", 0.3f, "(temporary) tof mass cut"}; - - Configurable antipNsigmaTpcCutLow{"antipNsigmaTpcCutLow", 4.f, "TPC PID cut low"}; - Configurable antipNsigmaTpcCutUp{"antipNsigmaTpcCutUp", 4.f, "TPC PID cut up"}; - Configurable antipNsigmaTofCut{"antipNsigmaTofCut", 4.f, "TOF PID cut"}; - Configurable antipTpcInnerParamMax{"antipTpcInnerParamMax", 0.6f, "(temporary) tpc inner param cut"}; - Configurable antipTofMassMax{"antipTofMassMax", 0.3f, "(temporary) tof mass cut"}; - Configurable tofMassMaxQA{"tofMassMaxQA", 0.6f, "(temporary) tof mass cut (for QA histograms)"}; - - Configurable v0setting_dcav0dau{"v0setting_dcav0dau", 1, "DCA V0 Daughters"}; - Configurable v0setting_dcav0pv{"v0setting_dcav0pv", 1, "DCA V0 to Pv"}; - Configurable v0setting_dcadaughtopv{"v0setting_dcadaughtopv", 0.1f, "DCA Pos To PV"}; - Configurable v0setting_cospa{"v0setting_cospa", 0.98, "V0 CosPA"}; - Configurable v0setting_radius{"v0setting_radius", 0.5f, "v0radius"}; - Configurable v0setting_lifetime{"v0setting_lifetime", 40.f, "v0 lifetime cut"}; - Configurable v0setting_nsigmatpc{"v0setting_nsigmatpc", 4.f, "nsigmatpc"}; - Configurable lambdaMassCut{"lambdaMassCut", 0.005f, "maximum deviation from PDG mass"}; - Configurable lambdaMassCutQA{"lambdaMassCutQA", 0.02f, "maximum deviation from PDG mass (for QA histograms)"}; - - Configurable antidItsClsSizeCut{"antidItsClsSizeCut", 2.f, "cluster size cut for antideuterons"}; - Configurable antidPtItsClsSizeCut{"antidPtItsClsSizeCut", 1.f, "pt for cluster size cut for antideuterons"}; - } config; - - std::array ptMin; - std::array ptTof; - std::array ptMax; - std::array nSigmaTpcCutLow; - std::array nSigmaTpcCutUp; - std::array nSigmaTofCut; - std::array tpcInnerParamMax; - std::array tofMassMax; - - HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry tempHistos{"tempHistos", {}, OutputObjHandlingPolicy::TransientObject}; - - Preslice perCollisionTracksFull = o2::aod::track::collisionId; - Preslice perCollisionTracksFullIU = o2::aod::track::collisionId; - Preslice perCollisionV0 = o2::aod::v0::collisionId; - Preslice perCollisionMcParts = o2::aod::mcparticle::mcCollisionId; - - template - bool selectV0Daughter(T const& track) - { - if (std::abs(track.eta()) > config.etaMaxV0dau) { - return false; - } - if (track.itsNCls() < config.v0trackNclusItsCut || - track.tpcNClsFound() < config.v0trackNclusTpcCut || - track.tpcNClsCrossedRows() < config.v0trackNclusTpcCut || - track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || - track.tpcNClsShared() > config.v0trackNsharedClusTpc) { - return false; - } - if (doprocessRun2 || doprocessMcRun2) { - if (!(track.trackType() & o2::aod::track::Run2Track) || - !(track.flags() & o2::aod::track::TPCrefit)) { - return false; - } - if (config.v0requireITSrefit && !(track.flags() & o2::aod::track::ITSrefit)) { - return false; - } - } - return true; - } - - template - bool selectTrack(T const& track) - { - if (std::abs(track.eta()) > config.etaMax) { - return false; - } - if (!(track.itsClusterMap() & 0x01) && !(track.itsClusterMap() & 0x02)) { - return false; - } - if (track.itsNCls() < config.trackNclusItsCut || - track.tpcNClsFound() < config.trackNclusTpcCut || - track.tpcNClsCrossedRows() < config.trackNcrossedRows || - track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || - track.tpcChi2NCl() > 4.f || - track.itsChi2NCl() > 36.f) { - return false; - } - if (doprocessRun2 || doprocessMcRun2) { - if (!(track.trackType() & o2::aod::track::Run2Track) || - !(track.flags() & o2::aod::track::TPCrefit) || - !(track.flags() & o2::aod::track::ITSrefit)) { - return false; - } - } - return true; - } - - template - float getITSClSize(T const& track) - { - float sum{0.f}; - for (int iL{0}; iL < 6; ++iL) { - sum += (track.itsClusterSizes() >> (iL * 4)) & 0xf; - } - return sum / track.itsNCls(); - } - - void fillHistoN(std::shared_ptr hFull, std::shared_ptr const& hTmp, int const subsample, int const centrality) - { - for (int iEta{1}; iEta < hTmp->GetNbinsX() + 1; ++iEta) { - for (int iPt{1}; iPt < hTmp->GetNbinsY() + 1; ++iPt) { - auto eta = hTmp->GetXaxis()->GetBinCenter(iEta); - auto pt = hTmp->GetYaxis()->GetBinCenter(iPt); - auto num = hTmp->Integral(1, iEta, iPt, iPt); - - hFull->Fill(subsample, centrality, eta, pt, num); - } - } - } - - void fillHistoN(std::shared_ptr hFull, std::shared_ptr const& hTmpA, std::shared_ptr const& hTmpB, int const subsample, int const centrality) - { - for (int iEta{1}; iEta < hTmpA->GetNbinsX() + 1; ++iEta) { - auto eta = hTmpA->GetXaxis()->GetBinCenter(iEta); - for (int iPtA{1}; iPtA < hTmpA->GetNbinsY() + 1; ++iPtA) { - for (int iPtB{1}; iPtB < hTmpB->GetNbinsY() + 1; ++iPtB) { - auto ptA = hTmpA->GetYaxis()->GetBinCenter(iPtA); - auto ptB = hTmpB->GetYaxis()->GetBinCenter(iPtB); - auto numA = hTmpA->Integral(1, iEta, iPtA, iPtA); - auto numB = hTmpB->Integral(1, iEta, iPtB, iPtB); - - hFull->Fill(subsample, centrality, eta, ptA, ptB, numA * numB); - } - } - } - } - - template - void initCCDB(Bc const& bc) - { - if (mRunNumber == bc.runNumber()) { - return; - } - - auto timestamp = bc.timestamp(); - o2::parameters::GRPObject* grpo = 0x0; - o2::parameters::GRPMagField* grpmag = 0x0; - if (doprocessRun2 || doprocessMcRun2) { - auto grpPath{"GLO/GRP/GRP"}; - grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); - if (!grpo) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpPath << " of object GRPObject for timestamp " << timestamp; - } - o2::base::Propagator::initFieldFromGRP(grpo); - } else { - auto grpmagPath{"GLO/Config/GRPMagField"}; - grpmag = ccdb->getForTimeStamp("GLO/Config/GRPMagField", timestamp); - if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField for timestamp " << timestamp; - } - o2::base::Propagator::initFieldFromGRP(grpmag); - } - // Fetch magnetic field from ccdb for current collision - d_bz = o2::base::Propagator::Instance()->getNominalBz(); - LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << d_bz << " kG"; - mRunNumber = bc.runNumber(); - fitter.setBz(d_bz); - - // o2::base::Propagator::Instance()->setMatLUT(lut); - } - - void init(o2::framework::InitContext&) - { - - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - // lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); - - fitter.setPropagateToPCA(true); - fitter.setMaxR(200.); - fitter.setMinParamChange(1e-3); - fitter.setMinRelChi2Change(0.9); - fitter.setMaxDZIni(4); - fitter.setMaxDXYIni(1); - fitter.setMaxChi2(1e9); - fitter.setUseAbsDCA(true); - fitter.setWeightedFinalPCA(false); - int mat{static_cast(config.cfgMaterialCorrection)}; - fitter.setMatCorrType(static_cast(mat)); - - uint32_t randomSeed = static_cast(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - gen32.seed(randomSeed); - - histos.add("QA/zVtx", ";#it{z}_{vtx} (cm);Entries", HistType::kTH1F, {zVtxAxis}); - - auto hNev = histos.add("nEv", ";Subsample;Centrality (%);", HistType::kTHnSparseD, {subsampleAxis, centAxis}); - nSubsamples = hNev->GetAxis(0)->GetNbins(); - - histos.add("QA/nRecPerEvAntid", ";Centrality (%);#it{N}_{#bar{d}};#it{N}_{ev}", HistType::kTH2D, {centAxis, nGenRecAxis}); - histos.add("QA/nRecPerEvAntip", ";Centrality (%);#it{N}_{#bar{p}};#it{N}_{ev}", HistType::kTH2D, {centAxis, nGenRecAxis}); - histos.add("QA/nRecPerEvAntiL", ";Centrality (%);#it{N}_{#bar{#Lambda}};#it{N}_{ev}", HistType::kTH2D, {centAxis, nGenRecAxis}); - histos.add("QA/nRecPerEvL", ";Centrality (%);#it{N}_{#Lambda};#it{N}_{ev}", HistType::kTH2D, {centAxis, nGenRecAxis}); - histos.add("QA/nTrklCorrelation", ";Tracklets |#eta| > 0.6; Tracklets |#eta| < 0.6", HistType::kTH2D, {{201, -0.5, 200.5}, {201, -0.5, 200.5}}); - histos.add("QA/TrklEta", ";Tracklets #eta; Entries", HistType::kTH1D, {{100, -3., 3.}}); - - nAntid = histos.add("nAntid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntidAxis}); - nAntip = histos.add("nAntip", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{p}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntipAxis}); - nAntiL = histos.add("nAntiL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis}); - nL = histos.add("nL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#Lambda) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis}); - - nSqAntid = histos.add("nSqAntid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{d}) (GeV/#it{c});#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntidAxis, ptAntidAxis}); - nSqAntip = histos.add("nSqAntip", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{p}) (GeV/#it{c});#it{p}_{T}(#bar{p}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntipAxis, ptAntipAxis}); - nSqAntiL = histos.add("nSqAntiL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptLambdaAxis}); - nSqL = histos.add("nSqL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#Lambda) (GeV/#it{c});#it{p}_{T}(#Lambda) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptLambdaAxis}); - - nAntipAntid = histos.add("nAntipAntid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{p}) (GeV/#it{c});#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntipAxis, ptAntidAxis}); - nLantiL = histos.add("nLantiL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#Lambda) (GeV/#it{c});#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptLambdaAxis}); - nLantid = histos.add("nLantid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#Lambda) (GeV/#it{c});#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptAntidAxis}); - nAntiLantid = histos.add("nAntiLantid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptAntidAxis}); - - // mc generated - nGenAntid = histos.add("nGenAntid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntidAxis}); - nGenAntip = histos.add("nGenAntip", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{p}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntipAxis}); - nGenAntiL = histos.add("nGenAntiL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis}); - nGenL = histos.add("nGenL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#Lambda) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis}); - - nGenSqAntid = histos.add("nGenSqAntid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{d}) (GeV/#it{c});#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntidAxis, ptAntidAxis}); - nGenSqAntip = histos.add("nGenSqAntip", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{p}) (GeV/#it{c});#it{p}_{T}(#bar{p}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntipAxis, ptAntipAxis}); - nGenSqAntiL = histos.add("nGenSqAntiL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptLambdaAxis}); - nGenSqL = histos.add("nGenSqL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#Lambda) (GeV/#it{c});#it{p}_{T}(#Lambda) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptLambdaAxis}); - - nGenAntipAntid = histos.add("nGenAntipAntid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{p}) (GeV/#it{c});#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptAntipAxis, ptAntidAxis}); - nGenLantiL = histos.add("nGenLantiL", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#Lambda) (GeV/#it{c});#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptLambdaAxis}); - nGenLantid = histos.add("nGenLantid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#Lambda) (GeV/#it{c});#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptAntidAxis}); - nGenAntiLantid = histos.add("nGenAntiLantid", ";Subsample;Centrality (%);#Delta#eta;#it{p}_{T}(#bar{#Lambda}) (GeV/#it{c});#it{p}_{T}(#bar{d}) (GeV/#it{c});", HistType::kTHnSparseD, {subsampleAxis, centAxis, deltaEtaAxis, ptLambdaAxis, ptAntidAxis}); - - // event QA - if (doprocessRun3) { - histos.add("QA/PvMultVsCent", ";Centrality T0C (%);#it{N}_{PV contributors};", HistType::kTH2F, {centAxis, multAxis}); - histos.add("QA/MultVsCent", ";Centrality T0C (%);Multiplicity T0C;", HistType::kTH2F, {centAxis, multFt0Axis}); - } else if (doprocessRun2) { - histos.add("QA/V0MvsCL0", ";Centrality CL0 (%);Centrality V0M (%)", HistType::kTH2F, {centAxis, centAxis}); - histos.add("QA/trackletsVsV0M", ";Centrality CL0 (%);Centrality V0M (%)", HistType::kTH2F, {centAxis, multAxis}); - } - - // v0 QA - histos.add("QA/massLambda", ";Centrality (%);#it{p}_{T} (GeV/#it{c});#it{M}(p + #pi^{-}) (GeV/#it{c}^{2});Entries", HistType::kTH3F, {centAxis, momAxis, massLambdaAxis}); - histos.add("QA/cosPa", ";cosPa;Entries", HistType::kTH1F, {cosPaAxis}); - histos.add("QA/cosPaSig", ";cosPa;Entries", HistType::kTH1F, {cosPaAxis}); - histos.add("QA/cosPaBkg", ";cosPa;Entries", HistType::kTH1F, {cosPaAxis}); - histos.add("QA/dcaV0daughSig", ";dcaV0daugh;Entries", HistType::kTH1F, {dcaV0daughAxis}); - histos.add("QA/dcaV0daughBkg", ";dcaV0daugh;Entries", HistType::kTH1F, {dcaV0daughAxis}); - histos.add("QA/dcaV0PvSig", ";dcaV0Pv;Entries", HistType::kTH1F, {dcaV0daughAxis}); - histos.add("QA/dcaV0PvBkg", ";dcaV0Pv;Entries", HistType::kTH1F, {dcaV0daughAxis}); - histos.add("QA/cosPaDcaV0daughSig", ";cosPa;dcaV0daugh", HistType::kTH2F, {cosPaAxis, dcaV0daughAxis}); - histos.add("QA/cosPaDcaV0daughBkg", ";cosPa;dcaV0daugh", HistType::kTH2F, {cosPaAxis, dcaV0daughAxis}); - histos.add("QA/massLambdaEvRej", ";Centrality (%);#it{p}_{T} (GeV/#it{c});#it{M}(p + #pi^{-}) (GeV/#it{c}^{2});Entries", HistType::kTH3F, {centAxis, momAxis, massLambdaAxis}); - histos.add("QA/massLambdaEvRejSig", ";Centrality (%);#it{p}_{T} (GeV/#it{c});#it{M}(p + #pi^{-}) (GeV/#it{c}^{2});Entries", HistType::kTH3F, {centAxis, momAxis, massLambdaAxis}); - histos.add("QA/massLambdaEvRejBkg", ";Centrality (%);#it{p}_{T} (GeV/#it{c});#it{M}(p + #pi^{-}) (GeV/#it{c}^{2});Entries", HistType::kTH3F, {centAxis, momAxis, massLambdaAxis}); - histos.add("QA/radius", ";radius;Entries", HistType::kTH1F, {radiusAxis}); - histos.add("QA/dcaV0daugh", ";dcaV0daugh;Entries", HistType::kTH1F, {dcaV0daughAxis}); - histos.add("QA/dcaV0Pv", ";dcaV0Pv;Entries", HistType::kTH1F, {dcaV0daughAxis}); - histos.add("QA/dcaPosPv", ";dcaPosPv;Entries", HistType::kTH1F, {dcaDaughPvAxis}); - histos.add("QA/dcaNegPv", ";dcaNegPv;Entries", HistType::kTH1F, {dcaDaughPvAxis}); - histos.add("QA/cosPaBeforeCut", ";cosPa;Entries", HistType::kTH1F, {cosPaAxis}); - histos.add("QA/radiusBeforeCut", ";radius;Entries", HistType::kTH1F, {radiusAxis}); - histos.add("QA/dcaV0daughBeforeCut", ";dcaV0daugh;Entries", HistType::kTH1F, {dcaV0daughAxis}); - histos.add("QA/dcaV0PvBeforeCut", ";dcaV0Pv;Entries", HistType::kTH1F, {dcaV0daughAxis}); - - // d QA - histos.add("QA/dcaPv", ";#it{p}_{T} (GeV/#it{c});dcaPv;Entries", HistType::kTH2F, {momAxis, dcaDaughPvAxis}); - histos.add("QA/nClsTPC", ";tpcCls;Entries", HistType::kTH1F, {tpcClsAxis}); - histos.add("QA/nCrossedRowsTPC", ";nCrossedRowsTPC;Entries", HistType::kTH1F, {tpcClsAxis}); - histos.add("QA/dcaPvBefore", ";#it{p}_{T} (GeV/#it{c});dcaPv;Entries", HistType::kTH2F, {momAxis, dcaDaughPvAxis}); - histos.add("QA/nClsTPCBeforeCut", ";tpcCls;Entries", HistType::kTH1F, {tpcClsAxis}); - histos.add("QA/nCrossedRowsTPCBeforeCut", ";nCrossedRowsTPC;Entries", HistType::kTH1F, {tpcClsAxis}); - - // antid and antip QA - histos.add("QA/tpcSignal", ";#it{p}_{TPC} (GeV/#it{c});d#it{E}/d#it{x}_{TPC} (a.u.)", HistType::kTH2F, {momAxisFine, tpcAxis}); - histos.add("QA/tpcSignal_glo", ";#it{p}_{glo} (GeV/#it{c});d#it{E}/d#it{x}_{TPC} (a.u.);", HistType::kTH2F, {momAxisFine, tpcAxis}); - - tpcNsigma[0] = histos.add("QA/tpcNsigma_p", ";#it{p}_{TPC} (GeV/#it{c});n#sigma_{TPC} (a.u.)", HistType::kTH2F, {momAxis, tpcNsigmaAxis}); - tpcNsigmaGlo[0] = histos.add("QA/tpcNsigmaGlo_p", ";Centrality (%);#it{p}_{T} (GeV/#it{c});n#sigma_{TPC} (a.u.)", HistType::kTH3F, {centAxis, momAxis, tpcNsigmaAxis}); - tofMass[0] = histos.add("QA/tofMass_p", ";Centrality (%);#it{p}_{T} (GeV/#it{c});Mass (GeV/#it{c}^{2});Entries", HistType::kTH3F, {centAxis, momAxis, tofMassAxis}); - tofSignal[0] = histos.add("QA/tofSignal_p", ";#it{p}_{TPC} (GeV/#it{c});#beta_{TOF}", HistType::kTH2F, {momAxisFine, tofAxis}); - tofSignal_glo[0] = histos.add("QA/tofSignal_glo_p", ";#it{p}_{T} (GeV/#it{c});#beta_{TOF}", HistType::kTH2F, {momAxisFine, tofAxis}); - - tpcNsigma[1] = histos.add("QA/tpcNsigma_d", ";#it{p}_{TPC} (GeV/#it{c});n#sigma_{TPC} (a.u.)", HistType::kTH2F, {momAxis, tpcNsigmaAxis}); - tpcNsigmaGlo[1] = histos.add("QA/tpcNsigmaGlo_d", ";Centrality (%);#it{p}_{T} (GeV/#it{c});n#sigma_{TPC} (a.u.)", HistType::kTH3F, {centAxis, momAxis, tpcNsigmaAxis}); - tofMass[1] = histos.add("QA/tofMass_d", ";Centrality (%);#it{p}_{T} (GeV/#it{c});Mass (GeV/#it{c}^{2});Entries", HistType::kTH3F, {centAxis, momAxis, tofMassAxis}); - tofSignal[1] = histos.add("QA/tofSignal_d", ";#it{p}_{TPC} (GeV/#it{c});#beta_{TOF}", HistType::kTH2F, {momAxisFine, tofAxis}); - tofSignal_glo[1] = histos.add("QA/tofSignal_glo_d", ";#it{p}_{T} (GeV/#it{c});#beta_{TOF}", HistType::kTH2F, {momAxisFine, tofAxis}); - - // mc histograms - if (doprocessMcRun3 || doprocessMcRun2) { - histos.add("recL", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptLambdaAxis, deltaEtaAxis}); - histos.add("recAntiL", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptLambdaAxis, deltaEtaAxis}); - recTracks[0] = histos.add("recP", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptAntipAxis, deltaEtaAxis}); - recTracks[1] = histos.add("recD", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptAntidAxis, deltaEtaAxis}); - recAntiTracks[0] = histos.add("recAntip", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptAntipAxis, deltaEtaAxis}); - recAntiTracks[1] = histos.add("recAntid", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptAntidAxis, deltaEtaAxis}); - histos.add("genL", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptLambdaAxis, deltaEtaAxis}); - histos.add("genAntiL", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptLambdaAxis, deltaEtaAxis}); - genTracks[0] = histos.add("genP", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptAntipAxis, deltaEtaAxis}); - genTracks[1] = histos.add("genD", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptAntidAxis, deltaEtaAxis}); - genAntiTracks[0] = histos.add("genAntip", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptAntipAxis, deltaEtaAxis}); - genAntiTracks[1] = histos.add("genAntid", ";Centrality (%); #it{p}_{T} (GeV/#it{c});#Delta#eta", HistType::kTH3D, {centAxis, ptAntidAxis, deltaEtaAxis}); - } - - // temporary histograms - tempTracks[0] = tempHistos.add("tempAntip", ";#Delta#eta;#it{p}_{T} (GeV/#it{c})", HistType::kTH2D, {deltaEtaAxis, ptAntipAxis}); - tempTracks[1] = tempHistos.add("tempAntid", ";#Delta#eta;#it{p}_{T} (GeV/#it{c})", HistType::kTH2D, {deltaEtaAxis, ptAntidAxis}); - tempLambda = tempHistos.add("tempLambda", ";#Delta#eta;#it{p}_{T} (GeV/#it{c})", HistType::kTH2D, {deltaEtaAxis, ptLambdaAxis}); - tempAntiLambda = tempHistos.add("tempAntiLambda", ";#Delta#eta;#it{p}_{T} (GeV/#it{c})", HistType::kTH2D, {deltaEtaAxis, ptLambdaAxis}); - - ptMin = std::array{config.antipPtMin, config.antidPtMin}; - ptMax = std::array{config.antipPtMax, config.antidPtMax}; - ptTof = std::array{config.antipPtTof, config.antidPtTof}; - - nSigmaTpcCutLow = std::array{config.antipNsigmaTpcCutLow, config.antidNsigmaTpcCutLow}; - nSigmaTpcCutUp = std::array{config.antipNsigmaTpcCutUp, config.antidNsigmaTpcCutUp}; - nSigmaTofCut = std::array{config.antipNsigmaTofCut, config.antidNsigmaTofCut}; - tpcInnerParamMax = std::array{config.antipTpcInnerParamMax, config.antidTpcInnerParamMax}; - tofMassMax = std::array{config.antipTofMassMax, config.antidTofMassMax}; - } - - template - int fillRecoEvent(C const& collision, T const& tracksAll, aod::V0s const& V0s, float const& centrality) - { - auto tracks = (doprocessRun3 || doprocessMcRun3) ? tracksAll.sliceBy(perCollisionTracksFullIU, collision.globalIndex()) : tracksAll.sliceBy(perCollisionTracksFull, collision.globalIndex()); - candidateTracks[0].clear(); - candidateTracks[1].clear(); - candidateV0s.clear(); - - tempTracks[0]->Reset(); - tempTracks[1]->Reset(); - tempLambda->Reset(); - tempAntiLambda->Reset(); - auto rnd = static_cast(gen32()) / static_cast(gen32.max()); - auto subsample = static_cast(rnd * nSubsamples); - - gpu::gpustd::array dcaInfo; - int nTracklets[2]{0, 0}; - for (const auto& track : tracks) { - - histos.fill(HIST("QA/nClsTPCBeforeCut"), track.tpcNClsFound()); - histos.fill(HIST("QA/nCrossedRowsTPCBeforeCut"), track.tpcNClsCrossedRows()); - - if (track.trackType() == 255 && std::abs(track.eta()) < 1.2) { // tracklet - nTracklets[std::abs(track.eta()) < 0.6]++; - histos.fill(HIST("QA/TrklEta"), track.eta()); - } - - if (!selectTrack(track)) { - continue; - } - - if (track.sign() > 0.) { - continue; - } - - auto trackParCov = getTrackParCov(track); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCov, 2.f, fitter.getMatCorrType(), &dcaInfo); - auto dca = std::hypot(dcaInfo[0], dcaInfo[1]); - auto trackPt = trackParCov.getPt(); - auto trackEta = trackParCov.getEta(); - histos.fill(HIST("QA/dcaPvBefore"), trackPt, dca); - if (dca > config.trackDcaCut) { - continue; - } - histos.fill(HIST("QA/dcaPv"), trackPt, dca); - - histos.fill(HIST("QA/nClsTPC"), track.tpcNClsFound()); - histos.fill(HIST("QA/nCrossedRowsTPC"), track.tpcNClsCrossedRows()); - histos.fill(HIST("QA/tpcSignal"), track.tpcInnerParam(), track.tpcSignal()); - histos.fill(HIST("QA/tpcSignal_glo"), track.p(), track.tpcSignal()); - - for (int iP{0}; iP < kNpart; ++iP) { - if (trackPt < ptMin[iP] || trackPt > ptMax[iP]) { - continue; - } - - if (doprocessRun3 || doprocessMcRun3) { - float cosL = 1 / std::sqrt(1.f + track.tgl() * track.tgl()); - if (iP && getITSClSize(track) * cosL < config.antidItsClsSizeCut && trackPt < config.antidPtItsClsSizeCut) { - continue; - } - } - - double expBethe{tpc::BetheBlochAleph(static_cast(track.tpcInnerParam() / partMass[iP]), config.cfgBetheBlochParams->get(iP, "p0"), config.cfgBetheBlochParams->get(iP, "p1"), config.cfgBetheBlochParams->get(iP, "p2"), config.cfgBetheBlochParams->get(iP, "p3"), config.cfgBetheBlochParams->get(iP, "p4"))}; - double expSigma{expBethe * config.cfgBetheBlochParams->get(iP, "resolution")}; - auto nSigmaTPC = static_cast((track.tpcSignal() - expBethe) / expSigma); - - float beta{track.hasTOF() ? track.length() / (track.tofSignal() - track.tofEvTime()) * o2::pid::tof::kCSPEDDInv : -999.f}; - beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); - float mass{track.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f)}; - bool hasTof = track.hasTOF() && track.tofChi2() < 3; - - if (trackPt <= ptTof[iP] || (trackPt > ptTof[iP] && hasTof && std::abs(mass - partMass[iP]) < config.tofMassMaxQA)) { // for QA histograms - tpcNsigmaGlo[iP]->Fill(centrality, trackPt, nSigmaTPC); - if (nSigmaTPC > nSigmaTpcCutLow[iP] && nSigmaTPC < nSigmaTpcCutUp[iP]) { - tofMass[iP]->Fill(centrality, trackPt, mass); - } - } - - if (nSigmaTPC < nSigmaTpcCutLow[iP] || nSigmaTPC > nSigmaTpcCutUp[iP]) { - continue; - } - - tpcNsigma[iP]->Fill(track.tpcInnerParam(), nSigmaTPC); - if (trackPt > ptTof[iP] && hasTof) { - tofSignal_glo[iP]->Fill(track.p(), beta); - tofSignal[iP]->Fill(track.tpcInnerParam(), beta); - } - - // temporary cut to reject fake matches (run 3) - if (track.tpcInnerParam() < tpcInnerParamMax[iP]) { - continue; - } - if (trackPt > ptTof[iP] && !hasTof) { - continue; - } - - if (trackPt <= ptTof[iP] || (trackPt > ptTof[iP] && hasTof && std::abs(mass - partMass[iP]) < tofMassMax[iP])) { - tempTracks[iP]->Fill(std::abs(trackEta), trackPt); - CandidateTrack candTrack; - candTrack.pt = trackPt; - candTrack.eta = trackEta; - candTrack.globalIndex = track.globalIndex(); - candidateTracks[iP].push_back(candTrack); - } - } - } - histos.fill(HIST("QA/nTrklCorrelation"), nTracklets[0], nTracklets[1]); - - std::vector trkId; - for (const auto& v0 : V0s) { - auto posTrack = v0.posTrack_as(); - auto negTrack = v0.negTrack_as(); - - bool posSelect = selectV0Daughter(posTrack); - bool negSelect = selectV0Daughter(negTrack); - if (!posSelect || !negSelect) - continue; - - if (doprocessRun2 || doprocessMcRun2) { - bool checkPosPileUp = posTrack.hasTOF() || (posTrack.flags() & o2::aod::track::ITSrefit); - bool checkNegPileUp = negTrack.hasTOF() || (negTrack.flags() & o2::aod::track::ITSrefit); - if (!checkPosPileUp && !checkNegPileUp) { - continue; - } - } - - auto posTrackCov = getTrackParCov(posTrack); - auto negTrackCov = getTrackParCov(negTrack); - - int nCand = 0; - try { - nCand = fitter.process(posTrackCov, negTrackCov); - } catch (...) { - LOG(error) << "Exception caught in DCA fitter process call!"; - continue; - } - if (nCand == 0) { - continue; - } - - auto& posPropTrack = fitter.getTrack(0); - auto& negPropTrack = fitter.getTrack(1); - - std::array momPos; - std::array momNeg; - std::array momV0; - posPropTrack.getPxPyPzGlo(momPos); - negPropTrack.getPxPyPzGlo(momNeg); - momTotXYZ(momV0, momPos, momNeg); - - auto ptV0 = std::hypot(momV0[0], momV0[1]); - if (ptV0 < config.lambdaPtMin || ptV0 > config.lambdaPtMax) { - continue; - } - - auto etaV0 = etaFromMom(momPos, momNeg); - if (std::abs(etaV0) > config.etaMax) { - continue; - } - - auto alpha = alphaAP(momV0, momPos, momNeg); - bool matter = alpha > 0; - auto massPos = matter ? o2::constants::physics::MassProton : o2::constants::physics::MassPionCharged; - auto massNeg = matter ? o2::constants::physics::MassPionCharged : o2::constants::physics::MassProton; - auto mLambda = invMass2Body(momV0, momPos, momNeg, massPos, massNeg); - auto mK0Short = invMass2Body(momV0, momPos, momNeg, o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged); - - // pid selections - double expBethePos{tpc::BetheBlochAleph(static_cast(posTrack.tpcInnerParam() / massPos), config.cfgBetheBlochParams->get("p0"), config.cfgBetheBlochParams->get("p1"), config.cfgBetheBlochParams->get("p2"), config.cfgBetheBlochParams->get("p3"), config.cfgBetheBlochParams->get("p4"))}; - double expSigmaPos{expBethePos * config.cfgBetheBlochParams->get("resolution")}; - auto nSigmaTPCPos = static_cast((posTrack.tpcSignal() - expBethePos) / expSigmaPos); - double expBetheNeg{tpc::BetheBlochAleph(static_cast(negTrack.tpcInnerParam() / massNeg), config.cfgBetheBlochParams->get("p0"), config.cfgBetheBlochParams->get("p1"), config.cfgBetheBlochParams->get("p2"), config.cfgBetheBlochParams->get("p3"), config.cfgBetheBlochParams->get("p4"))}; - double expSigmaNeg{expBetheNeg * config.cfgBetheBlochParams->get("resolution")}; - auto nSigmaTPCNeg = static_cast((negTrack.tpcSignal() - expBetheNeg) / expSigmaNeg); - - if (std::abs(nSigmaTPCPos) > config.v0setting_nsigmatpc || std::abs(nSigmaTPCNeg) > config.v0setting_nsigmatpc) { - continue; - } - - // veto on K0s mass - if (std::abs(mK0Short - o2::constants::physics::MassK0Short) < config.vetoMassK0Short) { - continue; - } - - float dcaV0dau = std::sqrt(fitter.getChi2AtPCACandidate()); - histos.fill(HIST("QA/dcaV0daughBeforeCut"), dcaV0dau); - if (dcaV0dau > config.v0setting_dcav0dau) { - continue; - } - - std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; - const auto& vtx = fitter.getPCACandidate(); - - float radiusV0 = std::hypot(vtx[0], vtx[1]); - histos.fill(HIST("QA/radiusBeforeCut"), radiusV0); - if (radiusV0 < config.v0setting_radius || radiusV0 > config.v0radiusMax) { - continue; - } - - float dcaV0Pv = CalculateDCAStraightToPV( - vtx[0], vtx[1], vtx[2], - momPos[0] + momNeg[0], - momPos[1] + momNeg[1], - momPos[2] + momNeg[2], - collision.posX(), collision.posY(), collision.posZ()); - histos.fill(HIST("QA/dcaV0PvBeforeCut"), dcaV0Pv); - if (std::abs(dcaV0Pv) > config.v0setting_dcav0pv) { - continue; - } - - double cosPA = RecoDecay::cpa(primVtx, vtx, momV0); - histos.fill(HIST("QA/cosPaBeforeCut"), cosPA); - if (cosPA < config.v0setting_cospa) { - continue; - } - - auto ptotal = RecoDecay::sqrtSumOfSquares(momV0[0], momV0[1], momV0[2]); - auto lengthTraveled = RecoDecay::sqrtSumOfSquares(vtx[0] - primVtx[0], vtx[1] - primVtx[1], vtx[2] - primVtx[2]); - float ML2P_Lambda = o2::constants::physics::MassLambda * lengthTraveled / ptotal; - if (ML2P_Lambda > config.v0setting_lifetime) { - continue; - } - - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, posTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); - auto posDcaToPv = std::hypot(dcaInfo[0], dcaInfo[1]); - if (posDcaToPv < config.v0setting_dcadaughtopv && std::abs(dcaInfo[0]) < config.v0setting_dcadaughtopv) { - continue; - } - - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, negTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); - auto negDcaToPv = std::hypot(dcaInfo[0], dcaInfo[1]); - if (negDcaToPv < config.v0setting_dcadaughtopv && std::abs(dcaInfo[0]) < config.v0setting_dcadaughtopv) { - continue; - } - - if (std::abs(mLambda - o2::constants::physics::MassLambda0) > config.lambdaMassCutQA) { // for QA histograms - continue; - } - histos.fill(HIST("QA/massLambda"), centrality, ptV0, mLambda); - - if (std::abs(mLambda - o2::constants::physics::MassLambda0) > config.lambdaMassCut) { - continue; - } - histos.fill(HIST("QA/cosPa"), cosPA); - histos.fill(HIST("QA/radius"), radiusV0); - histos.fill(HIST("QA/dcaV0daugh"), dcaV0dau); - histos.fill(HIST("QA/dcaPosPv"), posDcaToPv); - histos.fill(HIST("QA/dcaNegPv"), negDcaToPv); - histos.fill(HIST("QA/dcaV0Pv"), dcaV0Pv); - - if (matter) { - tempHistos.fill(HIST("tempLambda"), std::abs(etaV0), ptV0); - } else { - tempHistos.fill(HIST("tempAntiLambda"), std::abs(etaV0), ptV0); - } - - trkId.emplace_back(posTrack.globalIndex()); - trkId.emplace_back(negTrack.globalIndex()); - - CandidateV0 candV0; - candV0.pt = ptV0; - candV0.eta = etaV0; - candV0.mass = mLambda; - candV0.cpa = cosPA; - candV0.dcav0daugh = dcaV0dau; - candV0.dcav0pv = dcaV0Pv; - candV0.globalIndexPos = posTrack.globalIndex(); - candV0.globalIndexNeg = negTrack.globalIndex(); - candidateV0s.push_back(candV0); - } - - // reject events having multiple v0s from same tracks (TODO: also across collisions?) - std::sort(trkId.begin(), trkId.end()); - if ((std::adjacent_find(trkId.begin(), trkId.end()) != trkId.end()) && config.fillOnlySignal) { - candidateV0s.clear(); - - CandidateV0 candV0; - candV0.pt = -999.f; - candV0.eta = -999.f; - candV0.globalIndexPos = -999; - candV0.globalIndexNeg = -999; - candidateV0s.push_back(candV0); - return -1; - } - for (auto& candidateV0 : candidateV0s) { - histos.fill(HIST("QA/massLambdaEvRej"), centrality, candidateV0.pt, candidateV0.mass); - } - - histos.fill(HIST("nEv"), subsample, centrality); - - if ((doprocessMcRun3 || doprocessMcRun2) && config.fillOnlySignal) - return subsample; - - fillHistoN(nAntip, tempTracks[0], subsample, centrality); - fillHistoN(nAntid, tempTracks[1], subsample, centrality); - fillHistoN(nAntiL, tempAntiLambda, subsample, centrality); - fillHistoN(nL, tempLambda, subsample, centrality); - - fillHistoN(nSqAntip, tempTracks[0], tempTracks[0], subsample, centrality); - fillHistoN(nSqAntid, tempTracks[1], tempTracks[1], subsample, centrality); - fillHistoN(nSqAntiL, tempAntiLambda, tempAntiLambda, subsample, centrality); - fillHistoN(nSqL, tempLambda, tempLambda, subsample, centrality); - - fillHistoN(nAntipAntid, tempTracks[0], tempTracks[1], subsample, centrality); - fillHistoN(nLantid, tempLambda, tempTracks[1], subsample, centrality); - fillHistoN(nLantiL, tempLambda, tempAntiLambda, subsample, centrality); - fillHistoN(nAntiLantid, tempAntiLambda, tempTracks[1], subsample, centrality); - - histos.fill(HIST("QA/nRecPerEvAntip"), centrality, tempTracks[0]->GetEntries()); - histos.fill(HIST("QA/nRecPerEvAntid"), centrality, tempTracks[1]->GetEntries()); - histos.fill(HIST("QA/nRecPerEvAntiL"), centrality, tempAntiLambda->GetEntries()); - histos.fill(HIST("QA/nRecPerEvL"), centrality, tempLambda->GetEntries()); - - return 0; - } - - template - void fillMcEvent(C const& collision, T const& tracks, aod::V0s const& V0s, float const& centrality, aod::McParticles const&, aod::McTrackLabels const& mcLabels) - { - int subsample = fillRecoEvent(collision, tracks, V0s, centrality); - if (candidateV0s.size() == 1 && candidateV0s[0].pt < -998.f && candidateV0s[0].eta < -998.f && candidateV0s[0].globalIndexPos == -999 && candidateV0s[0].globalIndexPos == -999) { - return; - } - - if (config.fillOnlySignal) { - tempTracks[0]->Reset(); - tempTracks[1]->Reset(); - tempLambda->Reset(); - tempAntiLambda->Reset(); - } - - for (int iP{0}; iP < kNpart; ++iP) { - for (auto& candidateTrack : candidateTracks[iP]) { - auto mcLab = mcLabels.rawIteratorAt(candidateTrack.globalIndex); - if (mcLab.has_mcParticle()) { - auto mcTrack = mcLab.template mcParticle_as(); - if (std::abs(mcTrack.pdgCode()) != partPdg[iP]) - continue; - if (((mcTrack.flags() & 0x8) && doprocessMcRun2) || (mcTrack.flags() & 0x2) || (mcTrack.flags() & 0x1)) - continue; - if (!mcTrack.isPhysicalPrimary()) - continue; - if (mcTrack.pdgCode() > 0) { - recTracks[iP]->Fill(centrality, candidateTrack.pt, std::abs(candidateTrack.eta)); - } else { - recAntiTracks[iP]->Fill(centrality, candidateTrack.pt, std::abs(candidateTrack.eta)); - if (config.fillOnlySignal) - tempTracks[iP]->Fill(std::abs(candidateTrack.eta), candidateTrack.pt); - } - } - } - } - for (auto& candidateV0 : candidateV0s) { - auto mcLabPos = mcLabels.rawIteratorAt(candidateV0.globalIndexPos); - auto mcLabNeg = mcLabels.rawIteratorAt(candidateV0.globalIndexNeg); - - if (mcLabPos.has_mcParticle() && mcLabNeg.has_mcParticle()) { - auto mcTrackPos = mcLabPos.template mcParticle_as(); - auto mcTrackNeg = mcLabNeg.template mcParticle_as(); - if (mcTrackPos.has_mothers() && mcTrackNeg.has_mothers()) { - for (auto& negMother : mcTrackNeg.template mothers_as()) { - for (auto& posMother : mcTrackPos.template mothers_as()) { - if (posMother.globalIndex() != negMother.globalIndex()) - continue; - if (!((mcTrackPos.pdgCode() == 2212 && mcTrackNeg.pdgCode() == -211) || (mcTrackPos.pdgCode() == 211 && mcTrackNeg.pdgCode() == -2212))) - continue; - if (std::abs(posMother.pdgCode()) != 3122) { - histos.fill(HIST("QA/cosPaBkg"), candidateV0.cpa); - histos.fill(HIST("QA/dcaV0daughBkg"), candidateV0.dcav0daugh); - histos.fill(HIST("QA/dcaV0PvBkg"), candidateV0.dcav0pv); - histos.fill(HIST("QA/cosPaDcaV0daughBkg"), candidateV0.cpa, candidateV0.dcav0daugh); - histos.fill(HIST("QA/massLambdaEvRejBkg"), centrality, candidateV0.pt, candidateV0.mass); - continue; - } - if (!posMother.isPhysicalPrimary() && !posMother.has_mothers()) - continue; - if (((posMother.flags() & 0x8) && doprocessMcRun2) || (posMother.flags() & 0x2) || (posMother.flags() & 0x1)) - continue; - histos.fill(HIST("QA/cosPaSig"), candidateV0.cpa); - histos.fill(HIST("QA/dcaV0daughSig"), candidateV0.dcav0daugh); - histos.fill(HIST("QA/dcaV0PvSig"), candidateV0.dcav0pv); - histos.fill(HIST("QA/cosPaDcaV0daughSig"), candidateV0.cpa, candidateV0.dcav0daugh); - histos.fill(HIST("QA/massLambdaEvRejSig"), centrality, candidateV0.pt, candidateV0.mass); - if (posMother.pdgCode() > 0) { - histos.fill(HIST("recL"), centrality, candidateV0.pt, std::abs(candidateV0.eta)); - if (config.fillOnlySignal) - tempLambda->Fill(std::abs(candidateV0.eta), candidateV0.pt); - } else { - histos.fill(HIST("recAntiL"), centrality, candidateV0.pt, std::abs(candidateV0.eta)); - if (config.fillOnlySignal) - tempAntiLambda->Fill(std::abs(candidateV0.eta), candidateV0.pt); - } - } - } - } - } - } - - if (config.fillOnlySignal) { - fillHistoN(nAntip, tempTracks[0], subsample, centrality); - fillHistoN(nAntid, tempTracks[1], subsample, centrality); - fillHistoN(nAntiL, tempAntiLambda, subsample, centrality); - fillHistoN(nL, tempLambda, subsample, centrality); - - fillHistoN(nSqAntip, tempTracks[0], tempTracks[0], subsample, centrality); - fillHistoN(nSqAntid, tempTracks[1], tempTracks[1], subsample, centrality); - fillHistoN(nSqAntiL, tempAntiLambda, tempAntiLambda, subsample, centrality); - fillHistoN(nSqL, tempLambda, tempLambda, subsample, centrality); - - fillHistoN(nAntipAntid, tempTracks[0], tempTracks[1], subsample, centrality); - fillHistoN(nLantid, tempLambda, tempTracks[1], subsample, centrality); - fillHistoN(nLantiL, tempLambda, tempAntiLambda, subsample, centrality); - fillHistoN(nAntiLantid, tempAntiLambda, tempTracks[1], subsample, centrality); - - histos.fill(HIST("QA/nRecPerEvAntip"), centrality, tempTracks[0]->GetEntries()); - histos.fill(HIST("QA/nRecPerEvAntid"), centrality, tempTracks[1]->GetEntries()); - histos.fill(HIST("QA/nRecPerEvAntiL"), centrality, tempAntiLambda->GetEntries()); - histos.fill(HIST("QA/nRecPerEvL"), centrality, tempLambda->GetEntries()); - } - } - - void fillMcGen(aod::McParticles const& mcParticles, aod::McTrackLabels const& /*mcLab*/, std::vector> const& goodCollisions) - { - for (uint64_t iC{0}; iC < goodCollisions.size(); ++iC) { - if (goodCollisions[iC].first == false) { - continue; - } - - tempTracks[0]->Reset(); - tempTracks[1]->Reset(); - tempLambda->Reset(); - tempAntiLambda->Reset(); - - auto centrality = goodCollisions[iC].second; - auto rnd = static_cast(gen32()) / static_cast(gen32.max()); - auto subsample = static_cast(rnd * nSubsamples); - auto mcParticles_thisCollision = mcParticles.sliceBy(perCollisionMcParts, iC); - for (auto& mcPart : mcParticles_thisCollision) { - auto genEta = mcPart.eta(); - if (std::abs(genEta) > config.etaMax) { - continue; - } - if (((mcPart.flags() & 0x8) && doprocessMcRun2) || (mcPart.flags() & 0x2) || (mcPart.flags() & 0x1)) - continue; - auto pdgCode = mcPart.pdgCode(); - if (std::abs(pdgCode) == 3122) { - if (!mcPart.isPhysicalPrimary() && !mcPart.has_mothers()) - continue; - bool foundPr = false; - for (auto& mcDaught : mcPart.daughters_as()) { - if (std::abs(mcDaught.pdgCode()) == 2212) { - foundPr = true; - break; - } - } - if (!foundPr) { - continue; - } - auto genPt = std::hypot(mcPart.px(), mcPart.py()); - - if (pdgCode > 0) { - histos.fill(HIST("genL"), centrality, genPt, std::abs(genEta)); - tempHistos.fill(HIST("tempLambda"), std::abs(genEta), genPt); - } else { - histos.fill(HIST("genAntiL"), centrality, genPt, std::abs(genEta)); - tempHistos.fill(HIST("tempAntiLambda"), std::abs(genEta), genPt); - } - } else if (std::abs(pdgCode) == partPdg[0] || std::abs(pdgCode) == partPdg[1]) { - int iP = 1; - if (std::abs(pdgCode) == partPdg[0]) { - iP = 0; - } - if (!mcPart.isPhysicalPrimary() && !mcPart.has_mothers()) - continue; - auto genPt = std::hypot(mcPart.px(), mcPart.py()); - if (pdgCode > 0) { - genTracks[iP]->Fill(centrality, genPt, std::abs(genEta)); - } else { - genAntiTracks[iP]->Fill(centrality, genPt, std::abs(genEta)); - tempTracks[iP]->Fill(std::abs(genEta), genPt); - } - } - } - - fillHistoN(nGenAntip, tempTracks[0], subsample, centrality); - fillHistoN(nGenAntid, tempTracks[1], subsample, centrality); - fillHistoN(nGenAntiL, tempAntiLambda, subsample, centrality); - fillHistoN(nGenL, tempLambda, subsample, centrality); - - fillHistoN(nGenSqAntip, tempTracks[0], tempTracks[0], subsample, centrality); - fillHistoN(nGenSqAntid, tempTracks[1], tempTracks[1], subsample, centrality); - fillHistoN(nGenSqAntiL, tempAntiLambda, tempAntiLambda, subsample, centrality); - fillHistoN(nGenSqL, tempLambda, tempLambda, subsample, centrality); - - fillHistoN(nGenAntipAntid, tempTracks[0], tempTracks[1], subsample, centrality); - fillHistoN(nGenLantid, tempLambda, tempTracks[1], subsample, centrality); - fillHistoN(nGenLantiL, tempLambda, tempAntiLambda, subsample, centrality); - fillHistoN(nGenAntiLantid, tempAntiLambda, tempTracks[1], subsample, centrality); - } - } - - void processRun3(soa::Join const& collisions, TracksFullIU const& tracks, aod::V0s const& V0s, aod::BCsWithTimestamps const&) - { - for (const auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - if (!collision.sel8()) - continue; - - if (std::abs(collision.posZ()) > config.zVtxMax) - continue; - - if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) - continue; - - if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) - continue; - - if (!collision.selection_bit(aod::evsel::kNoSameBunchPileup)) - continue; - - if (!collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) - continue; - - histos.fill(HIST("QA/zVtx"), collision.posZ()); - - const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); - - auto multiplicity = collision.multFT0C(); - auto centrality = collision.centFT0C(); - fillRecoEvent(collision, tracks, V0Table_thisCollision, centrality); - - histos.fill(HIST("QA/PvMultVsCent"), centrality, collision.numContrib()); - histos.fill(HIST("QA/MultVsCent"), centrality, multiplicity); - } - } - PROCESS_SWITCH(antidLambdaEbye, processRun3, "process (Run 3)", false); - - void processRun2(soa::Join const& collisions, TracksFull const& tracks, aod::V0s const& V0s, BCsWithRun2Info const&) - { - for (const auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - if (std::abs(collision.posZ()) > config.zVtxMax) - continue; - - if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) - continue; - - if (config.kUseTPCPileUpCut && !(bc.eventCuts() & BIT(aod::Run2EventCuts::kTPCPileUp))) - continue; - - auto centrality = collision.centRun2V0M(); - if (!(collision.sel7() && collision.alias_bit(kINT7)) && (!config.kINT7Intervals || (config.kINT7Intervals && ((centrality >= 10 && centrality < 30) || centrality > 50)))) - continue; - - auto centralityCl0 = collision.centRun2CL0(); - if (config.kUseEstimatorsCorrelationCut) { - const auto& x = centralityCl0; - const double center = estimatorsCorrelationCoef[0] + estimatorsCorrelationCoef[1] * x; - const double sigma = estimatorsSigmaPars[0] + estimatorsSigmaPars[1] * x + estimatorsSigmaPars[2] * std::pow(x, 2) + estimatorsSigmaPars[3] * std::pow(x, 3); - if (centrality < center - deltaEstimatorNsigma[0] * sigma || centrality > center + deltaEstimatorNsigma[1] * sigma) { - continue; - } - } - - histos.fill(HIST("QA/zVtx"), collision.posZ()); - - const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); - - auto multTracklets = collision.multTracklets(); - fillRecoEvent(collision, tracks, V0Table_thisCollision, centrality); - - histos.fill(HIST("QA/V0MvsCL0"), centralityCl0, centrality); - histos.fill(HIST("QA/trackletsVsV0M"), centrality, multTracklets); - } - } - PROCESS_SWITCH(antidLambdaEbye, processRun2, "process (Run 2)", false); - - void processMcRun3(soa::Join const& collisions, aod::McCollisions const& mcCollisions, TracksFullIU const& tracks, aod::V0s const& V0s, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, aod::BCsWithTimestamps const&) - { - std::vector> goodCollisions(mcCollisions.size(), std::make_pair(false, -999.)); - for (auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - if (!collision.sel8()) - continue; - - if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) - continue; - - if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) - continue; - - if (!collision.selection_bit(aod::evsel::kNoSameBunchPileup)) - continue; - - if (!collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) - continue; - - if (std::abs(collision.posZ()) > config.zVtxMax) - continue; - - auto centrality = collision.centFT0C(); - goodCollisions[collision.mcCollisionId()].first = true; - goodCollisions[collision.mcCollisionId()].second = centrality; - - histos.fill(HIST("QA/zVtx"), collision.posZ()); - - const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); - - fillMcEvent(collision, tracks, V0Table_thisCollision, centrality, mcParticles, mcLab); - if (candidateV0s.size() == 1 && candidateV0s[0].pt < -998.f && candidateV0s[0].eta < -998.f && candidateV0s[0].globalIndexPos == -999 && candidateV0s[0].globalIndexPos == -999) { - goodCollisions[collision.mcCollisionId()].first = false; - } - } - - fillMcGen(mcParticles, mcLab, goodCollisions); - } - PROCESS_SWITCH(antidLambdaEbye, processMcRun3, "process MC (Run 3)", false); - - void processMcRun2(soa::Join const& collisions, aod::McCollisions const& mcCollisions, TracksFull const& tracks, aod::V0s const& V0s, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, BCsWithRun2Info const&) - { - std::vector> goodCollisions(mcCollisions.size(), std::make_pair(false, -999.)); - for (auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - if (std::abs(collision.posZ()) > config.zVtxMax) - continue; - - if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) - continue; - - auto centrality = collision.centRun2V0M(); - goodCollisions[collision.mcCollisionId()].first = true; - goodCollisions[collision.mcCollisionId()].second = centrality; - - histos.fill(HIST("QA/zVtx"), collision.posZ()); - - const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); - - fillMcEvent(collision, tracks, V0Table_thisCollision, centrality, mcParticles, mcLab); - if (candidateV0s.size() == 1 && candidateV0s[0].pt < -998.f && candidateV0s[0].eta < -998.f && candidateV0s[0].globalIndexPos == -999 && candidateV0s[0].globalIndexPos == -999) { - goodCollisions[collision.mcCollisionId()].first = false; - } - } - - fillMcGen(mcParticles, mcLab, goodCollisions); - } - PROCESS_SWITCH(antidLambdaEbye, processMcRun2, "process MC (Run 2)", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGLF/Tasks/Nuspex/antinucleiInJets.cxx b/PWGLF/Tasks/Nuspex/antinucleiInJets.cxx new file mode 100644 index 00000000000..b4509b40f28 --- /dev/null +++ b/PWGLF/Tasks/Nuspex/antinucleiInJets.cxx @@ -0,0 +1,1734 @@ +// 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. +/// +/// \file antinucleiInJets.cxx +/// +/// \brief task for analysis of antinuclei in jets using Fastjet +/// \author Alberto Caliva (alberto.caliva@cern.ch), Chiara Pinto (chiara.pinto@cern.ch) +/// \since February 13, 2025 + +#include "PWGJE/Core/JetBkgSubUtils.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/DataTypes.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/Logger.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/PID.h" +#include "ReconstructionDataFormats/Track.h" + +#include "TGrid.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace std; +using namespace o2; +using namespace o2::soa; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +using namespace o2::constants::math; +using std::array; + +using SelectedCollisions = soa::Join; +using SimCollisions = soa::Join; +using GenCollisions = aod::McCollisions; + +using FullNucleiTracks = soa::Join; + +using MCTracks = soa::Join; + +struct AntinucleiInJets { + + // histogram registries + HistogramRegistry registryData{"registryData", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry registryMC{"registryMC", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry registryQC{"registryQC", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry registryMult{"registryMult", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // global parameters + Configurable minJetPt{"minJetPt", 10.0, "Minimum pt of the jet"}; + Configurable ptLeadingMin{"ptLeadingMin", 5.0, "pt Leading Min"}; + Configurable rJet{"rJet", 0.3, "Jet resolution parameter R"}; + Configurable zVtx{"zVtx", 10.0, "Maximum zVertex"}; + Configurable deltaEtaEdge{"deltaEtaEdge", 0.05, "eta gap from the edge"}; + + // track parameters + Configurable requirePvContributor{"requirePvContributor", false, "require that the track is a PV contributor"}; + Configurable applyItsPid{"applyItsPid", true, "apply ITS PID"}; + Configurable rejectEvents{"rejectEvents", false, "reject some events"}; + Configurable rejectionPercentage{"rejectionPercentage", 3, "percentage of events to reject"}; + Configurable minItsNclusters{"minItsNclusters", 5, "minimum number of ITS clusters"}; + Configurable minTpcNcrossedRows{"minTpcNcrossedRows", 80, "minimum number of TPC crossed pad rows"}; + Configurable maxChiSquareTpc{"maxChiSquareTpc", 4.0, "maximum TPC chi^2/Ncls"}; + Configurable maxChiSquareIts{"maxChiSquareIts", 36.0, "maximum ITS chi^2/Ncls"}; + Configurable minPt{"minPt", 0.3, "minimum pt of the tracks"}; + Configurable minEta{"minEta", -0.8, "minimum eta"}; + Configurable maxEta{"maxEta", +0.8, "maximum eta"}; + Configurable maxDcaxy{"maxDcaxy", 0.05, "Maximum DCAxy"}; + Configurable maxDcaz{"maxDcaz", 0.05, "Maximum DCAz"}; + Configurable minNsigmaTpc{"minNsigmaTpc", -3.0, "Minimum nsigma TPC"}; + Configurable maxNsigmaTpc{"maxNsigmaTpc", +3.0, "Maximum nsigma TPC"}; + Configurable minNsigmaTof{"minNsigmaTof", -3.0, "Minimum nsigma TOF"}; + Configurable maxNsigmaTof{"maxNsigmaTof", +3.5, "Maximum nsigma TOF"}; + Configurable ptMaxItsPidProt{"ptMaxItsPidProt", 1.0, "maximum pt for ITS PID for protons"}; + Configurable ptMaxItsPidDeut{"ptMaxItsPidDeut", 1.0, "maximum pt for ITS PID for deuterons"}; + Configurable ptMaxItsPidHel{"ptMaxItsPidHel", 1.0, "maximum pt for ITS PID for helium"}; + Configurable nSigmaItsMin{"nSigmaItsMin", -2.0, "nSigmaITS min"}; + Configurable nSigmaItsMax{"nSigmaItsMax", +2.0, "nSigmaITS max"}; + + // reweighting + Configurable urlToCcdb{"urlToCcdb", "http://alice-ccdb.cern.ch", "url of the personal ccdb"}; + Configurable pathToFile{"pathToFile", "", "path to file with reweighting"}; + Configurable histoNameWeightAntipJet{"histoNameWeightAntipJet", "", "reweighting histogram: antip in jet"}; + Configurable histoNameWeightAntipUe{"histoNameWeightAntipUe", "", "reweighting histogram: antip in ue"}; + TH2F* twoDweightsAntipJet; + TH2F* twoDweightsAntipUe; + + // jet pt unfolding + Configurable applyPtUnfolding{"applyPtUnfolding", true, "apply jet pt unfolding"}; + Configurable urlToCcdbPtUnfolding{"urlToCcdbPtUnfolding", "http://alice-ccdb.cern.ch", "url of the personal ccdb"}; + Configurable pathToFilePtUnfolding{"pathToFilePtUnfolding", "Users/c/chpinto/My/Object/ResponseMatrix", "path to file with pt unfolding"}; + Configurable histoNamePtUnfolding{"histoNamePtUnfolding", "detectorResponseMatrix", "pt unfolding histogram"}; + TH2F* responseMatrix; + + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + + JetBkgSubUtils backgroundSub; + + void init(InitContext const&) + { + ccdb->setURL(urlToCcdb.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + ccdb->setFatalWhenNull(false); + + getReweightingHistograms(ccdb, TString(pathToFile), TString(histoNameWeightAntipJet), TString(histoNameWeightAntipUe)); + + if (applyPtUnfolding) { + getPtUnfoldingHistogram(ccdb, TString(pathToFilePtUnfolding), TString(histoNamePtUnfolding)); + } else { + responseMatrix = nullptr; + } + + // binning + double min = 0.0; + double max = 6.0; + int nbins = 120; + + // QC histograms + if (doprocessQC) { + registryQC.add("deltaEta_deltaPhi_jet", "deltaEta_deltaPhi_jet", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, PIHalf, "#Delta#phi"}}); + registryQC.add("deltaEta_deltaPhi_ue", "deltaEta_deltaPhi_ue", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, PIHalf, "#Delta#phi"}}); + registryQC.add("eta_phi_jet", "eta_phi_jet", HistType::kTH2F, {{200, -0.5, 0.5, "#eta_{jet}"}, {200, 0, TwoPI, "#phi_{jet}"}}); + registryQC.add("eta_phi_ue", "eta_phi_ue", HistType::kTH2F, {{200, -0.5, 0.5, "#eta_{UE}"}, {200, 0, TwoPI, "#phi_{UE}"}}); + registryQC.add("NchJetCone", "NchJetCone", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); + registryQC.add("NchJet", "NchJet", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); + registryQC.add("NchUE", "NchUE", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); + registryQC.add("sumPtJetCone", "sumPtJetCone", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); + registryQC.add("sumPtJet", "sumPtJet", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); + registryQC.add("sumPtUE", "sumPtUE", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); + registryQC.add("nJetsFound", "nJetsFound", HistType::kTH1F, {{50, 0, 50, "#it{n}_{Jet}"}}); + registryQC.add("nJetsInAcceptance", "nJetsInAcceptance", HistType::kTH1F, {{50, 0, 50, "#it{n}_{Jet}"}}); + registryQC.add("nJetsSelectedHighPt", "nJetsSelectedHighPt", HistType::kTH1F, {{50, 0, 50, "#it{n}_{Jet}"}}); + registryQC.add("jetPtDifference", "jetPtDifference", HistType::kTH1F, {{200, -1, 1, "#Deltap_{T}^{jet}"}}); + } + + if (doprocessMultEvents) { + registryMult.add("multiplicityEvtsPtLeading", "multiplicityEvtsPtLeading", HistType::kTH1F, {{1000, 0, 1000, "#it{N}_{ch}"}}); + registryMult.add("multiplicityEvtsWithJet", "multiplicityEvtsWithJet", HistType::kTH1F, {{1000, 0, 1000, "#it{N}_{ch}"}}); + } + + // data histograms + if (doprocessData) { + + // event counter data + registryData.add("number_of_events_data", "number of events in data", HistType::kTH1F, {{10, 0, 10, "counter"}}); + registryData.add("number_of_rejected_events", "check on number of events rejected", HistType::kTH1F, {{10, 0, 10, "counter"}}); + + // Jet Area + registryData.add("jetEffectiveArea", "jetEffectiveArea", HistType::kTH1F, {{2000, 0, 2, "Area/#piR^{2}"}}); + registryData.add("ptDistributionJet", "ptDistributionJet", HistType::kTH1F, {{2000, 0, 200, "#it{p}_{T} (GeV/#it{c})"}}); + + // antiprotons + registryData.add("antiproton_jet_tpc", "antiproton_jet_tpc", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + registryData.add("antiproton_jet_tof", "antiproton_jet_tof", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); + registryData.add("antiproton_ue_tpc", "antiproton_ue_tpc", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + registryData.add("antiproton_ue_tof", "antiproton_ue_tof", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); + registryData.add("antiproton_dca_jet", "antiproton_dca_jet", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); + registryData.add("antiproton_dca_ue", "antiproton_dca_ue", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); + + // antideuterons + registryData.add("antideuteron_jet_tpc", "antideuteron_jet_tpc", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + registryData.add("antideuteron_jet_tof", "antideuteron_jet_tof", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); + registryData.add("antideuteron_ue_tpc", "antideuteron_ue_tpc", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + registryData.add("antideuteron_ue_tof", "antideuteron_ue_tof", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); + + // deuterons + registryData.add("deuteron_jet_tof", "deuteron_jet_tof", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); + registryData.add("deuteron_ue_tof", "deuteron_ue_tof", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); + + // antihelium-3 + registryData.add("antihelium3_jet_tpc", "antihelium3_jet_tpc", HistType::kTH2F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + registryData.add("antihelium3_ue_tpc", "antihelium3_ue_tpc", HistType::kTH2F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + + // helium-3 + registryData.add("helium3_jet_tpc", "helium3_jet_tpc", HistType::kTH2F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + registryData.add("helium3_ue_tpc", "helium3_ue_tpc", HistType::kTH2F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + } + + // monte carlo histograms + if (doprocessEfficiency) { + + // event counter MC + registryMC.add("number_of_events_mc", "number of events in mc", HistType::kTH1F, {{10, 0, 10, "counter"}}); + + // generated spectra (antiprotons) + registryMC.add("antiproton_gen_jet_unweighted", "antiproton_gen_jet_unweighted", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_gen_ue_unweighted", "antiproton_gen_ue_unweighted", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_gen_jet_weighted2d", "antiproton_gen_jet_weighted2d", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_gen_ue_weighted2d", "antiproton_gen_ue_weighted2d", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_gen_jet_weightedFinal", "antiproton_gen_jet_weightedFinal", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_gen_ue_weightedFinal", "antiproton_gen_ue_weightedFinal", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_gen_jet_antikt", "antiproton_gen_jet_antikt", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_gen_ue_antikt", "antiproton_gen_ue_antikt", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + + // generated spectra (antinuclei) + registryMC.add("deuteron_incl_gen", "deuteron_incl_gen", HistType::kTH1F, {{nbins, 2 * min, 2 * max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antideuteron_incl_gen", "antideuteron_incl_gen", HistType::kTH1F, {{nbins, 2 * min, 2 * max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("helium3_incl_gen", "helium3_incl_gen", HistType::kTH1F, {{nbins, 3 * min, 3 * max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antihelium3_incl_gen", "antihelium3_incl_gen", HistType::kTH1F, {{nbins, 3 * min, 3 * max, "#it{p}_{T} (GeV/#it{c})"}}); + + // reconstructed TPC (antiprotons) + registryMC.add("antiproton_recTpc_jet_unweighted", "antiproton_recTpc_jet_unweighted", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTpc_ue_unweighted", "antiproton_recTpc_ue_unweighted", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTpc_jet_weighted2d", "antiproton_recTpc_jet_weighted2d", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTpc_ue_weighted2d", "antiproton_recTpc_ue_weighted2d", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTpc_jet_weightedFinal", "antiproton_recTpc_jet_weightedFinal", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTpc_ue_weightedFinal", "antiproton_recTpc_ue_weightedFinal", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTpc_jet_antikt", "antiproton_recTpc_jet_antikt", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTpc_ue_antikt", "antiproton_recTpc_ue_antikt", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + + // reconstructed TPC (antinuclei) + registryMC.add("antideuteron_incl_rec_tpc", "antideuteron_incl_rec_tpc", HistType::kTH1F, {{nbins, 2 * min, 2 * max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("deuteron_incl_rec_tpc", "deuteron_incl_rec_tpc", HistType::kTH1F, {{nbins, 2 * min, 2 * max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antihelium3_incl_rec_tpc", "antihelium3_incl_rec_tpc", HistType::kTH1F, {{nbins, 3 * min, 3 * max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("helium3_incl_rec_tpc", "helium3_incl_rec_tpc", HistType::kTH1F, {{nbins, 3 * min, 3 * max, "#it{p}_{T} (GeV/#it{c})"}}); + + // reconstructed TOF (antiprotons) + registryMC.add("antiproton_recTof_jet_unweighted", "antiproton_recTof_jet_unweighted", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTof_ue_unweighted", "antiproton_recTof_ue_unweighted", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTof_jet_weighted2d", "antiproton_recTof_jet_weighted2d", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTof_ue_weighted2d", "antiproton_recTof_ue_weighted2d", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTof_jet_weightedFinal", "antiproton_recTof_jet_weightedFinal", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTof_ue_weightedFinal", "antiproton_recTof_ue_weightedFinal", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTof_jet_antikt", "antiproton_recTof_jet_antikt", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_recTof_ue_antikt", "antiproton_recTof_ue_antikt", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + + // reconstructed TOF (antinuclei) + registryMC.add("antideuteron_incl_rec_tof", "antideuteron_incl_rec_tof", HistType::kTH1F, {{nbins, 2 * min, 2 * max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("deuteron_incl_rec_tof", "deuteron_incl_rec_tof", HistType::kTH1F, {{nbins, 2 * min, 2 * max, "#it{p}_{T} (GeV/#it{c})"}}); + + // fraction of primary antiprotons from MC (all unweighted for now) + registryMC.add("antiproton_prim_jet", "antiproton_prim_jet", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_incl_jet", "antiproton_incl_jet", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_prim_ue", "antiproton_prim_ue", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_incl_ue", "antiproton_incl_ue", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + + // DCA Templates + registryMC.add("antiproton_prim_dca_jet", "antiproton_prim_dca_jet", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); + registryMC.add("antiproton_prim_dca_ue", "antiproton_prim_dca_ue", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); + registryMC.add("antiproton_all_dca_jet", "antiproton_all_dca_jet", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); + registryMC.add("antiproton_all_dca_ue", "antiproton_all_dca_ue", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); + + // antiproton reweighting + registryMC.add("antiproton_eta_pt_pythia", "antiproton_eta_pt_pythia", HistType::kTH2F, {{200, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {20, -1.0, 1.0, "#it{#eta}"}}); + registryMC.add("antiproton_eta_pt_jet", "antiproton_eta_pt_jet", HistType::kTH2F, {{200, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {20, -1.0, 1.0, "#it{#eta}"}}); + registryMC.add("antiproton_eta_pt_ue", "antiproton_eta_pt_ue", HistType::kTH2F, {{200, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {20, -1.0, 1.0, "#it{#eta}"}}); + registryMC.add("antiproton_forReweighting_jet_weighted2d", "antiproton_forReweighting_jet_weighted2d", HistType::kTH1F, {{5000, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_forReweighting_ue_weighted2d", "antiproton_forReweighting_ue_weighted2d", HistType::kTH1F, {{5000, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_forReweighting_jet_weightedFinal", "antiproton_forReweighting_jet_weightedFinal", HistType::kTH1F, {{5000, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_forReweighting_ue_weightedFinal", "antiproton_forReweighting_ue_weightedFinal", HistType::kTH1F, {{5000, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); + } + + if (doprocessJetsMCrec) { + // detector response matrix + registryMC.add("detectorResponseMatrix", "detectorResponseMatrix", HistType::kTH2F, {{1000, 0.0, 100.0, "#it{p}_{T}^{rec} (GeV/#it{c})"}, {2000, -20.0, 20.0, "#it{p}_{T}^{gen} - #it{p}_{T}^{rec} (GeV/#it{c})"}}); + registryMC.add("generatedVsReconstructedPt", "generatedVsReconstructedPt", HistType::kTH2F, {{1000, 0.0, 100.0, "#it{p}_{T}^{rec} (GeV/#it{c})"}, {1000, 0.0, 100.0, "#it{p}_{T}^{gen} (GeV/#it{c})"}}); + } + + // systematic uncertainties + if (doprocessSystematicsData) { + registryData.add("number_of_rejected_events_syst", "check on number of events rejected", HistType::kTH1F, {{10, 0, 10, "counter"}}); + registryData.add("antiproton_tpc_syst", "antiproton_tpc_syst", HistType::kTHnSparseF, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}, {10, 0, 10, "systematic uncertainty"}}); + registryData.add("antiproton_tof_syst", "antiproton_tof_syst", HistType::kTHnSparseF, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}, {10, 0, 10, "systematic uncertainty"}}); + registryData.add("antideuteron_tpc_syst", "antideuteron_tpc_syst", HistType::kTHnSparseF, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}, {10, 0, 10, "systematic uncertainty"}}); + registryData.add("antideuteron_tof_syst", "antideuteron_tof_syst", HistType::kTHnSparseF, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}, {10, 0, 10, "systematic uncertainty"}}); + } + + if (doprocessSystematicsEfficiency) { + registryMC.add("antiproton_incl_gen_syst", "antiproton_incl_gen_syst", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antideuteron_incl_gen_syst", "antideuteron_incl_gen_syst", HistType::kTH1F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_incl_prim_syst", "antiproton_incl_prim_syst", HistType::kTHnSparseF, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {10, 0, 10, "systematic uncertainty"}}); + registryMC.add("antiproton_incl_rec_tpc_syst", "antiproton_incl_rec_tpc_syst", HistType::kTHnSparseF, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {10, 0, 10, "systematic uncertainty"}}); + registryMC.add("antiproton_incl_rec_tof_syst", "antiproton_incl_rec_tof_syst", HistType::kTHnSparseF, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {10, 0, 10, "systematic uncertainty"}}); + registryMC.add("antideuteron_incl_rec_tpc_syst", "antideuteron_incl_rec_tpc_syst", HistType::kTHnSparseF, {{nbins, 2 * min, 2 * max, "#it{p}_{T} (GeV/#it{c})"}, {10, 0, 10, "systematic uncertainty"}}); + registryMC.add("antideuteron_incl_rec_tof_syst", "antideuteron_incl_rec_tof_syst", HistType::kTHnSparseF, {{nbins, 2 * min, 2 * max, "#it{p}_{T} (GeV/#it{c})"}, {10, 0, 10, "systematic uncertainty"}}); + } + } + + void getPerpendicularAxis(const TVector3& p, TVector3& u, double sign) + { + double px = p.X(); + double py = p.Y(); + double pz = p.Z(); + + double px2 = px * px; + double py2 = py * py; + double pz2 = pz * pz; + double pz4 = pz2 * pz2; + + // px and py are both zero + if (px == 0 && py == 0) { + u.SetXYZ(0, 0, 0); + return; + } + + // protection 1 + if (px == 0 && py != 0) { + double ux = sign * std::sqrt(py2 - pz4 / py2); + double uy = -pz2 / py; + u.SetXYZ(ux, uy, pz); + return; + } + + // protection 2 + if (py == 0 && px != 0) { + double ux = -pz2 / px; + double uy = sign * std::sqrt(px2 - pz4 / px2); + u.SetXYZ(ux, uy, pz); + return; + } + + // General case + double a = px2 + py2; + double b = 2.0 * px * pz2; + double c = pz4 - py2 * py2 - px2 * py2; + + double delta = b * b - 4.0 * a * c; + + if (delta < 0 || a == 0) { + LOGP(warn, "Invalid input in getPerpendicularAxis: delta = {}, a = {}", delta, a); + u.SetXYZ(0, 0, 0); + return; + } + + double ux = (-b + sign * std::sqrt(delta)) / (2.0 * a); + double uy = (-pz2 - px * ux) / py; + u.SetXYZ(ux, uy, pz); + } + + double getDeltaPhi(double a1, double a2) + { + double deltaPhi(0); + double phi1 = TVector2::Phi_0_2pi(a1); + double phi2 = TVector2::Phi_0_2pi(a2); + double diff = std::fabs(phi1 - phi2); + + if (diff <= PI) + deltaPhi = diff; + if (diff > PI) + deltaPhi = TwoPI - diff; + + return deltaPhi; + } + + // ITS hit + template + bool hasITSHit(const TrackIts& track, int layer) + { + int ibit = layer - 1; + return (track.itsClusterMap() & (1 << ibit)); + } + + // single-track selection for particles inside jets + template + bool passedTrackSelectionForJetReconstruction(const JetTrack& track) + { + + const int minTpcCr = 70; + const double maxChi2Tpc = 4.0; + const double maxChi2Its = 36.0; + const double maxPseudorapidity = 0.8; + const double minPtTrack = 0.1; + const double dcaxyMaxTrackPar0 = 0.0105; + const double dcaxyMaxTrackPar1 = 0.035; + const double dcaxyMaxTrackPar2 = 1.1; + const double dcazMaxTrack = 2.0; + + if (!track.hasITS()) + return false; + if ((!hasITSHit(track, 1)) && (!hasITSHit(track, 2)) && (!hasITSHit(track, 3))) + return false; + if (!track.hasTPC()) + return false; + if (track.tpcNClsCrossedRows() < minTpcCr) + return false; + if (track.tpcChi2NCl() > maxChi2Tpc) + return false; + if (track.itsChi2NCl() > maxChi2Its) + return false; + if (track.eta() < -maxPseudorapidity || track.eta() > maxPseudorapidity) + return false; + if (track.pt() < minPtTrack) + return false; + if (std::fabs(track.dcaXY()) > (dcaxyMaxTrackPar0 + dcaxyMaxTrackPar1 / std::pow(track.pt(), dcaxyMaxTrackPar2))) + return false; + if (std::fabs(track.dcaZ()) > dcazMaxTrack) + return false; + return true; + } + + // single-track selection + template + bool passedTrackSelection(const AntinucleusTrack& track) + { + if (requirePvContributor && !(track.isPVContributor())) + return false; + if (!track.hasITS()) + return false; + if (track.itsNCls() < minItsNclusters) + return false; + if (!track.hasTPC()) + return false; + if (track.tpcNClsCrossedRows() < minTpcNcrossedRows) + return false; + if (track.tpcChi2NCl() > maxChiSquareTpc) + return false; + if (track.itsChi2NCl() > maxChiSquareIts) + return false; + if (track.eta() < minEta || track.eta() > maxEta) + return false; + if (track.pt() < minPt) + return false; + + return true; + } + + template + bool isHighPurityAntiproton(const AntiprotonTrack& track) + { + // variables + double nsigmaTPCPr = track.tpcNSigmaPr(); + double nsigmaTOFPr = track.tofNSigmaPr(); + double pt = track.pt(); + double ptThreshold = 0.5; + double nsigmaMaxPr = 2.0; + + if (pt < ptThreshold && std::fabs(nsigmaTPCPr) < nsigmaMaxPr) + return true; + if (pt >= ptThreshold && std::fabs(nsigmaTPCPr) < nsigmaMaxPr && track.hasTOF() && std::fabs(nsigmaTOFPr) < nsigmaMaxPr) + return true; + return false; + } + + double getCorrectedPt(double ptRec, TH2* responseMatrix) + { + if (!responseMatrix) { + LOGP(error, "Response matrix is null. Returning uncorrected pt."); + return ptRec; + } + + int binX = responseMatrix->GetXaxis()->FindBin(ptRec); + if (binX < 1 || binX > responseMatrix->GetNbinsX()) { + LOGP(error, "Bin index out of range: binX = {}", binX); + return ptRec; // Return uncorrected pt if bin index is invalid + } + std::unique_ptr proj(responseMatrix->ProjectionY("proj", binX, binX)); + + // add a protection in case the projection is empty + if (proj->GetEntries() == 0) { + return ptRec; + } + + double deltaPt = proj->GetRandom(); + double ptGen = ptRec + deltaPt; + + return ptGen; + } + + void getPtUnfoldingHistogram(o2::framework::Service const& ccdbObj, TString filepath, TString histoNamePtUnfolding) + { + TList* l = ccdbObj->get(filepath.Data()); + if (!l) { + LOGP(error, "Could not open the file {}", Form("%s", filepath.Data())); + return; + } + TObject* obj = l->FindObject(Form("%s", histoNamePtUnfolding.Data())); + if (!obj || !obj->InheritsFrom(TH2F::Class())) { + LOGP(error, "Could not find a valid TH2F histogram {}", Form("%s", histoNamePtUnfolding.Data())); + return; + } + responseMatrix = static_cast(obj); + LOGP(info, "Opened histogram {}", Form("%s", histoNamePtUnfolding.Data())); + } + + void getReweightingHistograms(o2::framework::Service const& ccdbObj, TString filepath, TString histname_antip_jet, TString histname_antip_ue) + { + TList* l = ccdbObj->get(filepath.Data()); + if (!l) { + LOGP(error, "Could not open the file {}", Form("%s", filepath.Data())); + return; + } + twoDweightsAntipJet = static_cast(l->FindObject(Form("%s_antiproton", histname_antip_jet.Data()))); + if (!twoDweightsAntipJet) { + LOGP(error, "Could not open histogram {}", Form("%s_antiproton", histname_antip_jet.Data())); + return; + } + twoDweightsAntipUe = static_cast(l->FindObject(Form("%s_antiproton", histname_antip_ue.Data()))); + if (!twoDweightsAntipUe) { + LOGP(error, "Could not open histogram {}", Form("%s_antiproton", histname_antip_ue.Data())); + return; + } + LOGP(info, "Opened histogram {}", Form("%s_antiproton", histname_antip_jet.Data())); + LOGP(info, "Opened histogram {}", Form("%s_antiproton", histname_antip_ue.Data())); + } + + bool shouldRejectEvent() + { + static std::random_device rd; + static std::mt19937 gen(rd()); + static std::uniform_int_distribution<> dis(0, 99); + int randomNumber = dis(gen); + if (randomNumber > rejectionPercentage) { + return false; // accept event + } + return true; // reject event + } + + // Process Data + void processData(SelectedCollisions::iterator const& collision, FullNucleiTracks const& tracks) + { + if (rejectEvents) { + // event counter: before event rejection + registryData.fill(HIST("number_of_rejected_events"), 0.5); + + if (shouldRejectEvent()) + return; + + // event counter: after event rejection + registryData.fill(HIST("number_of_rejected_events"), 1.5); + } + + // event counter: before event selection + registryData.fill(HIST("number_of_events_data"), 0.5); + + // event selection + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + return; + + // event counter: after event selection + registryData.fill(HIST("number_of_events_data"), 1.5); + + // loop over reconstructed tracks + int id(-1); + std::vector fjParticles; + for (auto const& track : tracks) { + id++; + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + + // 4-momentum representation of a particle + fastjet::PseudoJet fourMomentum(track.px(), track.py(), track.pz(), track.energy(MassPionCharged)); + fourMomentum.set_user_index(id); + fjParticles.emplace_back(fourMomentum); + } + + // reject empty events + if (fjParticles.size() < 1) + return; + registryData.fill(HIST("number_of_events_data"), 2.5); + + // cluster particles using the anti-kt algorithm + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); // active_area_explicit_ghosts + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // loop over reconstructed jets + bool isAtLeastOneJetSelected = false; + for (const auto& jet : jets) { + + // jet must be fully contained in the acceptance + if ((std::fabs(jet.eta()) + rJet) > (maxEta - deltaEtaEdge)) + continue; + + // jet pt must be larger than threshold + auto jetForSub = jet; + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jetForSub, rhoPerp, rhoMPerp); + // if (getCorrectedPt(jetMinusBkg.pt(), responseMatrix) < minJetPt) + registryData.fill(HIST("ptDistributionJet"), jet.pt()); + + if (jetMinusBkg.pt() < minJetPt) + continue; + isAtLeastOneJetSelected = true; + + // perpendicular cone + double coneRadius = std::sqrt(jet.area() / PI); + TVector3 jetAxis(jet.px(), jet.py(), jet.pz()); // before or after subtraction of perpendicular cone? + TVector3 ueAxis1(0, 0, 0); + TVector3 ueAxis2(0, 0, 0); + getPerpendicularAxis(jetAxis, ueAxis1, +1); + getPerpendicularAxis(jetAxis, ueAxis2, -1); + + // Jet Area + registryData.fill(HIST("jetEffectiveArea"), jet.area() / (PI * rJet * rJet)); + + // get jet constituents + std::vector jetConstituents = jet.constituents(); + o2::aod::ITSResponse itsResponse; + + // loop over jet constituents + for (const auto& particle : jetConstituents) { + + // get corresponding track and apply track selection criteria + auto const& track = tracks.iteratorAt(particle.user_index()); + if (!passedTrackSelection(track)) + continue; + + // variables + double nsigmaTPCPr = track.tpcNSigmaPr(); + double nsigmaTOFPr = track.tofNSigmaPr(); + double nsigmaTPCDe = track.tpcNSigmaDe(); + double nsigmaTOFDe = track.tofNSigmaDe(); + double nsigmaTPCHe = track.tpcNSigmaHe(); + double pt = track.pt(); + double dcaxy = track.dcaXY(); + double dcaz = track.dcaZ(); + + // fill DCA distribution for antiprotons + if (track.sign() < 0 && isHighPurityAntiproton(track) && std::fabs(dcaz) < maxDcaz) { + registryData.fill(HIST("antiproton_dca_jet"), pt, dcaxy); + } + + // DCA selections + if (std::fabs(dcaxy) > maxDcaxy || std::fabs(dcaz) > maxDcaz) + continue; + + // Particle identification using the ITS cluster size + bool passedItsPidProt(true), passedItsPidDeut(true), passedItsPidHel(true); + double nSigmaITSprot = static_cast(itsResponse.nSigmaITS(track)); + double nSigmaITSdeut = static_cast(itsResponse.nSigmaITS(track)); + double nSigmaITShel3 = static_cast(itsResponse.nSigmaITS(track)); + + if (applyItsPid && pt < ptMaxItsPidProt && (nSigmaITSprot < nSigmaItsMin || nSigmaITSprot > nSigmaItsMax)) { + passedItsPidProt = false; + } + if (applyItsPid && pt < ptMaxItsPidDeut && (nSigmaITSdeut < nSigmaItsMin || nSigmaITSdeut > nSigmaItsMax)) { + passedItsPidDeut = false; + } + if (applyItsPid && (2.0 * pt) < ptMaxItsPidHel && (nSigmaITShel3 < nSigmaItsMin || nSigmaITShel3 > nSigmaItsMax)) { + passedItsPidHel = false; + } + + // antimatter + if (track.sign() < 0) { + if (passedItsPidProt) { + registryData.fill(HIST("antiproton_jet_tpc"), pt, nsigmaTPCPr); + if (nsigmaTPCPr > minNsigmaTpc && nsigmaTPCPr < maxNsigmaTpc && track.hasTOF()) + registryData.fill(HIST("antiproton_jet_tof"), pt, nsigmaTOFPr); + } + if (passedItsPidDeut) { + registryData.fill(HIST("antideuteron_jet_tpc"), pt, nsigmaTPCDe); + if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc && track.hasTOF()) + registryData.fill(HIST("antideuteron_jet_tof"), pt, nsigmaTOFDe); + } + if (passedItsPidHel) { + registryData.fill(HIST("antihelium3_jet_tpc"), 2.0 * pt, nsigmaTPCHe); + } + } + + // matter + if (track.sign() > 0) { + if (passedItsPidDeut && nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc && track.hasTOF()) + registryData.fill(HIST("deuteron_jet_tof"), pt, nsigmaTOFDe); + if (passedItsPidHel) { + registryData.fill(HIST("helium3_jet_tpc"), 2.0 * pt, nsigmaTPCHe); + } + } + } + + // underlying event + for (auto const& track : tracks) { + + // get corresponding track and apply track selection criteria + if (!passedTrackSelection(track)) + continue; + + double deltaEtaUe1 = track.eta() - ueAxis1.Eta(); + double deltaPhiUe1 = getDeltaPhi(track.phi(), ueAxis1.Phi()); + double deltaRUe1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1); + double deltaEtaUe2 = track.eta() - ueAxis2.Eta(); + double deltaPhiUe2 = getDeltaPhi(track.phi(), ueAxis2.Phi()); + double deltaRUe2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2); + if (deltaRUe1 > coneRadius && deltaRUe2 > coneRadius) + continue; + + // variables + double nsigmaTPCPr = track.tpcNSigmaPr(); + double nsigmaTOFPr = track.tofNSigmaPr(); + double nsigmaTPCDe = track.tpcNSigmaDe(); + double nsigmaTOFDe = track.tofNSigmaDe(); + double nsigmaTPCHe = track.tpcNSigmaHe(); + double pt = track.pt(); + double dcaxy = track.dcaXY(); + double dcaz = track.dcaZ(); + + // fill DCA distribution for antiprotons + if (track.sign() < 0 && isHighPurityAntiproton(track) && std::fabs(dcaz) < maxDcaz) { + registryData.fill(HIST("antiproton_dca_ue"), pt, dcaxy); + } + + // DCA selections + if (std::fabs(dcaxy) > maxDcaxy || std::fabs(dcaz) > maxDcaz) + continue; + + // Particle identification using the ITS cluster size + bool passedItsPidProt(true), passedItsPidDeut(true), passedItsPidHel(true); + double nSigmaITSprot = static_cast(itsResponse.nSigmaITS(track)); + double nSigmaITSdeut = static_cast(itsResponse.nSigmaITS(track)); + double nSigmaITShel3 = static_cast(itsResponse.nSigmaITS(track)); + + if (applyItsPid && pt < ptMaxItsPidProt && (nSigmaITSprot < nSigmaItsMin || nSigmaITSprot > nSigmaItsMax)) { + passedItsPidProt = false; + } + if (applyItsPid && pt < ptMaxItsPidDeut && (nSigmaITSdeut < nSigmaItsMin || nSigmaITSdeut > nSigmaItsMax)) { + passedItsPidDeut = false; + } + if (applyItsPid && (2.0 * pt) < ptMaxItsPidHel && (nSigmaITShel3 < nSigmaItsMin || nSigmaITShel3 > nSigmaItsMax)) { + passedItsPidHel = false; + } + + // antimatter + if (track.sign() < 0) { + if (passedItsPidProt) { + registryData.fill(HIST("antiproton_ue_tpc"), pt, nsigmaTPCPr); + if (nsigmaTPCPr > minNsigmaTpc && nsigmaTPCPr < maxNsigmaTpc && track.hasTOF()) + registryData.fill(HIST("antiproton_ue_tof"), pt, nsigmaTOFPr); + } + if (passedItsPidDeut) { + registryData.fill(HIST("antideuteron_ue_tpc"), pt, nsigmaTPCDe); + if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc && track.hasTOF()) + registryData.fill(HIST("antideuteron_ue_tof"), pt, nsigmaTOFDe); + } + if (passedItsPidHel) { + registryData.fill(HIST("antihelium3_ue_tpc"), 2.0 * pt, nsigmaTPCHe); + } + } + + // matter + if (track.sign() > 0) { + if (passedItsPidDeut && nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc && track.hasTOF()) + registryData.fill(HIST("deuteron_ue_tof"), pt, nsigmaTOFDe); + // helium3 + if (passedItsPidHel) { + registryData.fill(HIST("helium3_ue_tpc"), 2.0 * pt, nsigmaTPCHe); + } + } + } + } + if (isAtLeastOneJetSelected) { + registryData.fill(HIST("number_of_events_data"), 3.5); + } + } + PROCESS_SWITCH(AntinucleiInJets, processData, "Process Data", true); + + void processMultEvents(SelectedCollisions::iterator const& collision, FullNucleiTracks const& tracks) + { + // event selection + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + return; + + // Leading Track + double ptMax(0.0); + + // loop over reconstructed tracks + int id(-1); + std::vector fjParticles; + for (auto const& track : tracks) { + id++; + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + if (track.pt() > ptMax) { + ptMax = track.pt(); + } + + // 4-momentum representation of a particle + fastjet::PseudoJet fourMomentum(track.px(), track.py(), track.pz(), track.energy(MassPionCharged)); + fourMomentum.set_user_index(id); + fjParticles.emplace_back(fourMomentum); + } + // reject empty events + if (fjParticles.empty()) { + return; + } + + if (ptMax > ptLeadingMin) { + registryMult.fill(HIST("multiplicityEvtsPtLeading"), fjParticles.size()); + } + + // cluster particles using the anti-kt algorithm + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // loop over reconstructed jets + bool isAtLeastOneJetSelected = false; + for (const auto& jet : jets) { + + // jet must be fully contained in the acceptance + if ((std::fabs(jet.eta()) + rJet) > (maxEta - deltaEtaEdge)) + continue; + + // jet pt must be larger than threshold + auto jetForSub = jet; + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jetForSub, rhoPerp, rhoMPerp); + if (jetMinusBkg.pt() < minJetPt) + continue; + isAtLeastOneJetSelected = true; + } + if (isAtLeastOneJetSelected) { + registryMult.fill(HIST("multiplicityEvtsWithJet"), fjParticles.size()); + } + } + PROCESS_SWITCH(AntinucleiInJets, processMultEvents, "Process Mult Events", true); + + // Process QC + void processQC(SelectedCollisions::iterator const& collision, FullNucleiTracks const& tracks) + { + // event selection + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + return; + + // loop over reconstructed tracks + std::vector fjParticles; + for (auto const& track : tracks) { + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + + // 4-momentum representation of a particle + fastjet::PseudoJet fourMomentum(track.px(), track.py(), track.pz(), track.energy(MassPionCharged)); + fjParticles.emplace_back(fourMomentum); + } + + // reject empty events + if (fjParticles.size() < 1) + return; + + // cluster particles using the anti-kt algorithm + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); // active_area_explicit_ghosts + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // loop over reconstructed jets + int njetsInAcc(0); + int njetsHighPt(0); + for (const auto& jet : jets) { + + // jet must be fully contained in the acceptance + if ((std::fabs(jet.eta()) + rJet) > (maxEta - deltaEtaEdge)) + continue; + njetsInAcc++; + registryQC.fill(HIST("sumPtJetCone"), jet.pt()); + double ptJetBeforeSub = jet.pt(); + + // jet pt must be larger than threshold + auto jetForSub = jet; + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jetForSub, rhoPerp, rhoMPerp); + double ptJetAfterSub = jetForSub.pt(); + registryQC.fill(HIST("jetPtDifference"), ptJetAfterSub - ptJetBeforeSub); + + if (getCorrectedPt(jetMinusBkg.pt(), responseMatrix) < minJetPt) + continue; + njetsHighPt++; + registryQC.fill(HIST("sumPtJet"), jet.pt()); + + // jet properties and perpendicular cone + std::vector jetConstituents = jet.constituents(); + TVector3 jetAxis(jet.px(), jet.py(), jet.pz()); + double coneRadius = std::sqrt(jet.area() / PI); + TVector3 ueAxis1(0, 0, 0); + TVector3 ueAxis2(0, 0, 0); + getPerpendicularAxis(jetAxis, ueAxis1, +1); + getPerpendicularAxis(jetAxis, ueAxis2, -1); + + registryQC.fill(HIST("NchJetCone"), static_cast(jetConstituents.size())); + + // loop over jet constituents + for (const auto& particle : jetConstituents) { + + double deltaEta = particle.eta() - jetAxis.Eta(); + double deltaPhi = getDeltaPhi(particle.phi(), jetAxis.Phi()); + registryQC.fill(HIST("deltaEta_deltaPhi_jet"), deltaEta, deltaPhi); + registryQC.fill(HIST("eta_phi_jet"), particle.eta(), particle.phi()); + } + + // loop over particles in perpendicular cones + double nParticlesPerp(0); + double ptPerp(0); + for (auto const& track : tracks) { + + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + + double deltaEtaUe1 = track.eta() - ueAxis1.Eta(); + double deltaPhiUe1 = getDeltaPhi(track.phi(), ueAxis1.Phi()); + double deltaRUe1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1); + double deltaEtaUe2 = track.eta() - ueAxis2.Eta(); + double deltaPhiUe2 = getDeltaPhi(track.phi(), ueAxis2.Phi()); + double deltaRUe2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2); + if (deltaRUe1 > coneRadius && deltaRUe2 > coneRadius) + continue; + + ptPerp = ptPerp + track.pt(); + nParticlesPerp++; + registryQC.fill(HIST("deltaEta_deltaPhi_ue"), deltaEtaUe1, deltaPhiUe1); + registryQC.fill(HIST("deltaEta_deltaPhi_ue"), deltaEtaUe2, deltaPhiUe2); + registryQC.fill(HIST("eta_phi_ue"), track.eta(), track.phi()); + } + registryQC.fill(HIST("NchUE"), 0.5 * nParticlesPerp); + registryQC.fill(HIST("NchJet"), static_cast(jetConstituents.size()) - 0.5 * nParticlesPerp); + registryQC.fill(HIST("sumPtUE"), 0.5 * ptPerp); + } + registryQC.fill(HIST("nJetsFound"), static_cast(jets.size())); + registryQC.fill(HIST("nJetsInAcceptance"), njetsInAcc); + registryQC.fill(HIST("nJetsSelectedHighPt"), njetsHighPt); + } + PROCESS_SWITCH(AntinucleiInJets, processQC, "Process QC", false); + + void processEfficiency(SimCollisions const& collisions, MCTracks const& mcTracks, aod::McParticles const& mcParticles) + { + // Loop over all simulated collision events + for (const auto& collision : collisions) { + + // Count all generated events before applying any event selection criteria + registryMC.fill(HIST("number_of_events_mc"), 0.5); + + // Apply event selection: require sel8 and vertex position within the allowed z range + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + continue; + + // Count events that pass the selection criteria + registryMC.fill(HIST("number_of_events_mc"), 1.5); + + // Loop over all generated Monte Carlo particles for the selected event + for (const auto& particle : mcParticles) { + + // primary particles + if (!particle.isPhysicalPrimary()) + continue; + + // Fill (eta, pT) distribution of generated antiprotons + if (particle.pdgCode() == kProtonBar) { + registryMC.fill(HIST("antiproton_eta_pt_pythia"), particle.pt(), particle.eta()); + } + + // Select particles within the specified pseudorapidity interval + if (particle.eta() < minEta || particle.eta() > maxEta) + continue; + + // Initialize weights for antiproton reweighting in Jet and UE cones + double wAntipJet2d(1.0), wAntipUe2d(1.0); + int ix = twoDweightsAntipJet->GetXaxis()->FindBin(particle.pt()); + int iy = twoDweightsAntipJet->GetYaxis()->FindBin(particle.eta()); + + // Retrieve 2D weights from histograms based on particle's (pT, eta) + wAntipJet2d = twoDweightsAntipJet->GetBinContent(ix, iy); + wAntipUe2d = twoDweightsAntipUe->GetBinContent(ix, iy); + + // Sanity checks: if (pT, eta) is out of histogram bounds, set default weight to 1.0 + if (ix == 0 || ix > twoDweightsAntipJet->GetNbinsX()) { + wAntipJet2d = 1.0; + wAntipUe2d = 1.0; + } + if (iy == 0 || iy > twoDweightsAntipJet->GetNbinsY()) { + wAntipJet2d = 1.0; + wAntipUe2d = 1.0; + } + + // Placeholder for 1D weight factors (e.g., for further corrections, still to be implemented) + double wAntipJetFinal(1.0), wAntipUeFinal(1.0); + + // Process different particle species based on PDG code + switch (particle.pdgCode()) { + case kProtonBar: + // Fill histograms with unweighted and weighted (2D and final) pT spectra for antiprotons + registryMC.fill(HIST("antiproton_gen_jet_unweighted"), particle.pt()); + registryMC.fill(HIST("antiproton_gen_ue_unweighted"), particle.pt()); + registryMC.fill(HIST("antiproton_gen_jet_weighted2d"), particle.pt(), wAntipJet2d); + registryMC.fill(HIST("antiproton_gen_ue_weighted2d"), particle.pt(), wAntipUe2d); + registryMC.fill(HIST("antiproton_gen_jet_weightedFinal"), particle.pt(), wAntipJetFinal); + registryMC.fill(HIST("antiproton_gen_ue_weightedFinal"), particle.pt(), wAntipUeFinal); + + // Fill additional histograms used for deriving or validating reweighting corrections + registryMC.fill(HIST("antiproton_forReweighting_jet_weighted2d"), particle.pt(), wAntipJet2d); + registryMC.fill(HIST("antiproton_forReweighting_ue_weighted2d"), particle.pt(), wAntipUe2d); + registryMC.fill(HIST("antiproton_forReweighting_jet_weightedFinal"), particle.pt(), wAntipJetFinal); + registryMC.fill(HIST("antiproton_forReweighting_ue_weightedFinal"), particle.pt(), wAntipUeFinal); + break; + + // Generated spectra for other light nuclei + case o2::constants::physics::Pdg::kDeuteron: + registryMC.fill(HIST("deuteron_incl_gen"), particle.pt()); + break; + case -o2::constants::physics::Pdg::kDeuteron: + registryMC.fill(HIST("antideuteron_incl_gen"), particle.pt()); + break; + case o2::constants::physics::Pdg::kHelium3: + registryMC.fill(HIST("helium3_incl_gen"), particle.pt()); + break; + case -o2::constants::physics::Pdg::kHelium3: + registryMC.fill(HIST("antihelium3_incl_gen"), particle.pt()); + break; + } + } + + // ITS PID response utility + o2::aod::ITSResponse itsResponse; + + // Loop over all reconstructed MC tracks + for (auto const& track : mcTracks) { + + // Apply standard track selection criteria + if (!passedTrackSelection(track)) + continue; + + // Cut on transverse and longitudinal distance of closest approach + if (std::fabs(track.dcaXY()) > maxDcaxy) + continue; + if (std::fabs(track.dcaZ()) > maxDcaz) + continue; + + // Skip tracks that are not associated with a true MC particle + if (!track.has_mcParticle()) + continue; + const auto particle = track.mcParticle(); + + // select only physical primary particles + if (!particle.isPhysicalPrimary()) + continue; + + // Retrieve PID responses from TPC and TOF detectors for proton, deuteron, helium-3 + double nsigmaTPCPr = track.tpcNSigmaPr(); + double nsigmaTOFPr = track.tofNSigmaPr(); + double nsigmaTPCDe = track.tpcNSigmaDe(); + double nsigmaTOFDe = track.tofNSigmaDe(); + double nsigmaTPCHe = track.tpcNSigmaHe(); + double pt = track.pt(); + + // particle identification using the ITS cluster size + bool passedItsPidProt(true), passedItsPidDeut(true), passedItsPidHel(true); + double nSigmaITSprot = static_cast(itsResponse.nSigmaITS(track)); + double nSigmaITSdeut = static_cast(itsResponse.nSigmaITS(track)); + double nSigmaITShel3 = static_cast(itsResponse.nSigmaITS(track)); + + if (applyItsPid && pt < ptMaxItsPidProt && (nSigmaITSprot < nSigmaItsMin || nSigmaITSprot > nSigmaItsMax)) { + passedItsPidProt = false; + } + if (applyItsPid && pt < ptMaxItsPidDeut && (nSigmaITSdeut < nSigmaItsMin || nSigmaITSdeut > nSigmaItsMax)) { + passedItsPidDeut = false; + } + if (applyItsPid && (2.0 * pt) < ptMaxItsPidHel && (nSigmaITShel3 < nSigmaItsMin || nSigmaITShel3 > nSigmaItsMax)) { + passedItsPidHel = false; + } + + // Get correction weights as a function of (pt, eta) from external histograms + double wAntipJet2d(1.0), wAntipUe2d(1.0); + int ix = twoDweightsAntipJet->GetXaxis()->FindBin(particle.pt()); + int iy = twoDweightsAntipJet->GetYaxis()->FindBin(particle.eta()); + wAntipJet2d = twoDweightsAntipJet->GetBinContent(ix, iy); + wAntipUe2d = twoDweightsAntipUe->GetBinContent(ix, iy); + + // Edge protection: reset weights to 1 if out of histogram range + if (ix == 0 || ix > twoDweightsAntipJet->GetNbinsX()) { + wAntipJet2d = 1.0; + wAntipUe2d = 1.0; + } + if (iy == 0 || iy > twoDweightsAntipJet->GetNbinsY()) { + wAntipJet2d = 1.0; + wAntipUe2d = 1.0; + } + + // 1d weights (to be implemented) + double wAntipJetFinal(1.0), wAntipUeFinal(1.0); + + // antiprotons + if (particle.pdgCode() == kProtonBar) { + if (passedItsPidProt && nsigmaTPCPr > minNsigmaTpc && nsigmaTPCPr < maxNsigmaTpc) { + registryMC.fill(HIST("antiproton_recTpc_jet_unweighted"), track.pt()); + registryMC.fill(HIST("antiproton_recTpc_ue_unweighted"), track.pt()); + registryMC.fill(HIST("antiproton_recTpc_jet_weighted2d"), track.pt(), wAntipJet2d); + registryMC.fill(HIST("antiproton_recTpc_ue_weighted2d"), track.pt(), wAntipUe2d); + registryMC.fill(HIST("antiproton_recTpc_jet_weightedFinal"), track.pt(), wAntipJetFinal); + registryMC.fill(HIST("antiproton_recTpc_ue_weightedFinal"), track.pt(), wAntipUeFinal); + + if (track.hasTOF() && nsigmaTOFPr > minNsigmaTof && nsigmaTOFPr < maxNsigmaTof) { + registryMC.fill(HIST("antiproton_recTof_jet_unweighted"), track.pt()); + registryMC.fill(HIST("antiproton_recTof_ue_unweighted"), track.pt()); + registryMC.fill(HIST("antiproton_recTof_jet_weighted2d"), track.pt(), wAntipJet2d); + registryMC.fill(HIST("antiproton_recTof_ue_weighted2d"), track.pt(), wAntipUe2d); + registryMC.fill(HIST("antiproton_recTof_jet_weightedFinal"), track.pt(), wAntipJetFinal); + registryMC.fill(HIST("antiproton_recTof_ue_weightedFinal"), track.pt(), wAntipUeFinal); + } + } + } + + // antideuterons + if (particle.pdgCode() == -o2::constants::physics::Pdg::kDeuteron && passedItsPidDeut) { + if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc) { + registryMC.fill(HIST("antideuteron_incl_rec_tpc"), track.pt()); + if (track.hasTOF() && nsigmaTOFDe > minNsigmaTof && nsigmaTOFDe < maxNsigmaTof) + registryMC.fill(HIST("antideuteron_incl_rec_tof"), track.pt()); + } + } + + // deuterons + if (particle.pdgCode() == o2::constants::physics::Pdg::kDeuteron && passedItsPidDeut) { + if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc) { + registryMC.fill(HIST("deuteron_incl_rec_tpc"), track.pt()); + if (track.hasTOF() && nsigmaTOFDe > minNsigmaTof && nsigmaTOFDe < maxNsigmaTof) + registryMC.fill(HIST("deuteron_incl_rec_tof"), track.pt()); + } + } + + // antihelium3 + if (particle.pdgCode() == -o2::constants::physics::Pdg::kHelium3 && passedItsPidHel) { + if (nsigmaTPCHe > minNsigmaTpc && nsigmaTPCHe < maxNsigmaTpc) { + registryMC.fill(HIST("antihelium3_incl_rec_tpc"), 2.0 * track.pt()); + } + } + + // helium3 + if (particle.pdgCode() == o2::constants::physics::Pdg::kHelium3 && passedItsPidHel) { + if (nsigmaTPCHe > minNsigmaTpc && nsigmaTPCHe < maxNsigmaTpc) { + registryMC.fill(HIST("helium3_incl_rec_tpc"), 2.0 * track.pt()); + } + } + } + } + } + PROCESS_SWITCH(AntinucleiInJets, processEfficiency, "process efficiency", false); + + void processJetsMCgen(GenCollisions const& collisions, aod::McParticles const& mcParticles) + { + // Loop over all simulated collision events + for (const auto& collision : collisions) { + + // Apply event selection: require vertex position within the allowed z range + if (std::fabs(collision.posZ()) > zVtx) + continue; + + // Loop over all MC particles and select physical primaries within acceptance + std::vector fjParticles; + for (const auto& particle : mcParticles) { + if (!particle.isPhysicalPrimary()) + continue; + double minPtParticle = 0.1; + if (particle.eta() < minEta || particle.eta() > maxEta || particle.pt() < minPtParticle) + continue; + + // Build 4-momentum assuming charged pion mass + double energy = std::sqrt(particle.p() * particle.p() + MassPionCharged * MassPionCharged); + fastjet::PseudoJet fourMomentum(particle.px(), particle.py(), particle.pz(), energy); + fourMomentum.set_user_index(particle.pdgCode()); + fjParticles.emplace_back(fourMomentum); + } + + // Skip events with no particles + if (fjParticles.size() < 1) + continue; + + // Cluster MC particles into jets using anti-kt algorithm + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + + // Estimate background energy density (rho) in perpendicular cone + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // Loop over clustered jets + for (const auto& jet : jets) { + + // Jet must be fully contained in acceptance + if ((std::fabs(jet.eta()) + rJet) > (maxEta - deltaEtaEdge)) + continue; + + // Subtract background energy from jet + auto jetForSub = jet; + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jetForSub, rhoPerp, rhoMPerp); + + // Apply jet pT threshold + if (jetMinusBkg.pt() < minJetPt) + continue; + + // Analyze jet constituents and search for antiprotons + std::vector jetConstituents = jet.constituents(); + for (const auto& particle : jetConstituents) { + if (particle.user_index() != kProtonBar) + continue; + registryMC.fill(HIST("antiproton_eta_pt_jet"), particle.pt(), particle.eta()); + registryMC.fill(HIST("antiproton_gen_jet_antikt"), particle.pt()); + } + + // Set up two perpendicular cone axes for underlying event estimation + TVector3 jetAxis(jet.px(), jet.py(), jet.pz()); + double coneRadius = std::sqrt(jet.area() / PI); + TVector3 ueAxis1(0, 0, 0), ueAxis2(0, 0, 0); + getPerpendicularAxis(jetAxis, ueAxis1, +1); + getPerpendicularAxis(jetAxis, ueAxis2, -1); + + // Loop over MC particles to analyze underlying event region + for (const auto& particle : mcParticles) { + if (!particle.isPhysicalPrimary()) + continue; + double minPtParticle = 0.1; + if (particle.eta() < minEta || particle.eta() > maxEta || particle.pt() < minPtParticle) + continue; + + // Compute distance of particle from both perpendicular cone axes + double deltaEtaUe1 = particle.eta() - ueAxis1.Eta(); + double deltaPhiUe1 = getDeltaPhi(particle.phi(), ueAxis1.Phi()); + double deltaRUe1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1); + double deltaEtaUe2 = particle.eta() - ueAxis2.Eta(); + double deltaPhiUe2 = getDeltaPhi(particle.phi(), ueAxis2.Phi()); + double deltaRUe2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2); + + // Select particles inside one of the perpendicular cones + if (deltaRUe1 > coneRadius && deltaRUe2 > coneRadius) + continue; + + // Select antiprotons based on PDG + if (particle.pdgCode() != kProtonBar) + continue; + + registryMC.fill(HIST("antiproton_eta_pt_ue"), particle.pt(), particle.eta()); + registryMC.fill(HIST("antiproton_gen_ue_antikt"), particle.pt()); + } + } + } + } + PROCESS_SWITCH(AntinucleiInJets, processJetsMCgen, "process jets mc gen", false); + + void processJetsMCrec(SimCollisions const& collisions, MCTracks const& mcTracks, McParticles const&) + { + // Initialize ITS PID response tool + o2::aod::ITSResponse itsResponse; + + // Loop over all simulated collision events + for (const auto& collision : collisions) { + + // Apply event selection: require sel8 and vertex position within the allowed z range + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + continue; + + // Prepare particle list for jet clustering + int id(-1); + std::vector fjParticles; + for (auto const& track : mcTracks) { + id++; + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + + // Build 4-momentum assuming charged pion mass + fastjet::PseudoJet fourMomentum(track.px(), track.py(), track.pz(), track.energy(MassPionCharged)); + fourMomentum.set_user_index(id); + fjParticles.emplace_back(fourMomentum); + } + + // Skip events with no particles + if (fjParticles.size() < 1) + continue; + + // Perform jet clustering using anti-kT algorithm with active area correction + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + + // Estimate background energy density (rho) in perpendicular cone + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // Loop over reconstructed jets + for (const auto& jet : jets) { + + // Retrieve constituents of the current jet + std::vector jetConstituents = jet.constituents(); + + // Estimate generator-level jet pT by summing pT of matched MC particles + double jetPtGen(0); + for (const auto& particle : jetConstituents) { + auto const& track = mcTracks.iteratorAt(particle.user_index()); + if (!track.has_mcParticle()) + continue; + const auto mcparticle = track.mcParticle(); + jetPtGen += mcparticle.pt(); + } + + // Jet must be fully contained in acceptance + if ((std::fabs(jet.eta()) + rJet) > (maxEta - deltaEtaEdge)) + continue; + + // Fill detector response matrix + registryMC.fill(HIST("detectorResponseMatrix"), jet.pt(), jetPtGen - jet.pt()); + registryMC.fill(HIST("generatedVsReconstructedPt"), jet.pt(), jetPtGen); + + // Subtract estimated background contribution from jet 4-momentum + auto jetForSub = jet; + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jetForSub, rhoPerp, rhoMPerp); + + // Apply jet pT threshold + // if (getCorrectedPt(jetMinusBkg.pt(), responseMatrix) < minJetPt) + if (jetMinusBkg.pt() < minJetPt) + continue; + + // Set up two perpendicular cone axes for underlying event estimation + double coneRadius = std::sqrt(jet.area() / PI); + TVector3 jetAxis(jet.px(), jet.py(), jet.pz()); + TVector3 ueAxis1(0, 0, 0), ueAxis2(0, 0, 0); + getPerpendicularAxis(jetAxis, ueAxis1, +1); + getPerpendicularAxis(jetAxis, ueAxis2, -1); + + // Analyze antiproton candidates among jet constituents + for (const auto& particle : jetConstituents) { + auto const& track = mcTracks.iteratorAt(particle.user_index()); + if (!track.has_mcParticle()) + continue; + const auto mcparticle = track.mcParticle(); + + // Fill DCA templates + if (mcparticle.pdgCode() == kProtonBar && passedTrackSelection(track) && std::fabs(track.dcaZ()) < maxDcaz) { + if (mcparticle.isPhysicalPrimary()) { + registryMC.fill(HIST("antiproton_prim_dca_jet"), track.pt(), track.dcaXY()); + } else { + registryMC.fill(HIST("antiproton_all_dca_jet"), track.pt(), track.dcaXY()); + } + } + + // Apply standard track quality and PID selection + if (!passedTrackSelection(track) || std::fabs(track.dcaXY()) > maxDcaxy || std::fabs(track.dcaZ()) > maxDcaz) + continue; + if (track.sign() > 0 || mcparticle.pdgCode() != kProtonBar) + continue; + + // PID variables + double nsigmaTPCPr = track.tpcNSigmaPr(); + double nsigmaTOFPr = track.tofNSigmaPr(); + + // particle identification using the ITS cluster size + double pt = track.pt(); + bool passedItsPidProt(true); + double nSigmaITSprot = static_cast(itsResponse.nSigmaITS(track)); + if (applyItsPid && pt < ptMaxItsPidProt && (nSigmaITSprot < nSigmaItsMin || nSigmaITSprot > nSigmaItsMax)) { + passedItsPidProt = false; + } + + // Inclusive antiproton spectrum + registryMC.fill(HIST("antiproton_incl_jet"), track.pt()); + + // Select physical primary antiprotons + if (!mcparticle.isPhysicalPrimary()) + continue; + registryMC.fill(HIST("antiproton_prim_jet"), track.pt()); + + // Fill histograms (TPC and TOF) only for selected candidates + if (passedItsPidProt && nsigmaTPCPr > minNsigmaTpc && nsigmaTPCPr < maxNsigmaTpc) { + registryMC.fill(HIST("antiproton_recTpc_jet_antikt"), track.pt()); + if (track.hasTOF() && nsigmaTOFPr > minNsigmaTof && nsigmaTOFPr < maxNsigmaTof) { + registryMC.fill(HIST("antiproton_recTof_jet_antikt"), track.pt()); + } + } + } + + // Analyze antiprotons in the Underlying Event (UE) using perpendicular cones + for (auto const& track : mcTracks) { + + if (!track.has_mcParticle()) + continue; + const auto mcparticle = track.mcParticle(); + if (track.sign() > 0 || mcparticle.pdgCode() != kProtonBar) + continue; + + // Fill DCA templates + if (mcparticle.pdgCode() == kProtonBar && passedTrackSelection(track) && std::fabs(track.dcaZ()) < maxDcaz) { + if (mcparticle.isPhysicalPrimary()) { + registryMC.fill(HIST("antiproton_prim_dca_ue"), track.pt(), track.dcaXY()); + } else { + registryMC.fill(HIST("antiproton_all_dca_ue"), track.pt(), track.dcaXY()); + } + } + + // Track Selection + if (!passedTrackSelection(track) || std::fabs(track.dcaXY()) > maxDcaxy || std::fabs(track.dcaZ()) > maxDcaz) + continue; + + // Compute distance from UE cones + double deltaEtaUe1 = track.eta() - ueAxis1.Eta(); + double deltaPhiUe1 = getDeltaPhi(track.phi(), ueAxis1.Phi()); + double deltaRUe1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1); + double deltaEtaUe2 = track.eta() - ueAxis2.Eta(); + double deltaPhiUe2 = getDeltaPhi(track.phi(), ueAxis2.Phi()); + double deltaRUe2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2); + + // Require particle to be within at least one UE cone + if (deltaRUe1 > coneRadius && deltaRUe2 > coneRadius) + continue; + + // PID variables + double nsigmaTPCPr = track.tpcNSigmaPr(); + double nsigmaTOFPr = track.tofNSigmaPr(); + + // particle identification using the ITS cluster size + double pt = track.pt(); + bool passedItsPidProt(true); + double nSigmaITSprot = static_cast(itsResponse.nSigmaITS(track)); + if (applyItsPid && pt < ptMaxItsPidProt && (nSigmaITSprot < nSigmaItsMin || nSigmaITSprot > nSigmaItsMax)) { + passedItsPidProt = false; + } + + registryMC.fill(HIST("antiproton_incl_ue"), track.pt()); + if (!mcparticle.isPhysicalPrimary()) + continue; + registryMC.fill(HIST("antiproton_prim_ue"), track.pt()); + + // Fill histograms in UE + if (passedItsPidProt && nsigmaTPCPr > minNsigmaTpc && nsigmaTPCPr < maxNsigmaTpc) { + registryMC.fill(HIST("antiproton_recTpc_ue_antikt"), track.pt()); + if (track.hasTOF() && nsigmaTOFPr > minNsigmaTof && nsigmaTOFPr < maxNsigmaTof) { + registryMC.fill(HIST("antiproton_recTof_ue_antikt"), track.pt()); + } + } + } + } + } + } + PROCESS_SWITCH(AntinucleiInJets, processJetsMCrec, "process jets MC rec", false); + + // Process Systematics + void processSystematicsData(SelectedCollisions::iterator const& collision, FullNucleiTracks const& tracks) + { + if (rejectEvents) { + // event counter: before event rejection + registryData.fill(HIST("number_of_rejected_events_syst"), 0.5); + + if (shouldRejectEvent()) + return; + + // event counter: after event rejection + registryData.fill(HIST("number_of_rejected_events_syst"), 1.5); + } + + const int nSystematics = 10; + int itsNclustersSyst[nSystematics] = {5, 6, 5, 4, 5, 3, 5, 6, 3, 4}; + float tpcNcrossedRowsSyst[nSystematics] = {100, 85, 80, 110, 95, 90, 105, 95, 100, 105}; + float dcaxySyst[nSystematics] = {0.05, 0.07, 0.10, 0.03, 0.06, 0.15, 0.08, 0.04, 0.09, 0.10}; + float dcazSyst[nSystematics] = {0.1, 0.15, 0.3, 0.075, 0.12, 0.18, 0.2, 0.1, 0.15, 0.2}; + + // event selection + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + return; + + // loop over reconstructed tracks + int id(-1); + std::vector fjParticles; + for (auto const& track : tracks) { + id++; + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + + // 4-momentum representation of a particle + fastjet::PseudoJet fourMomentum(track.px(), track.py(), track.pz(), track.energy(MassPionCharged)); + fourMomentum.set_user_index(id); + fjParticles.emplace_back(fourMomentum); + } + + // reject empty events + if (fjParticles.size() < 1) + return; + + // cluster particles using the anti-kt algorithm + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); // active_area_explicit_ghosts + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // loop over reconstructed jets + for (const auto& jet : jets) { + + // jet must be fully contained in the acceptance + if ((std::fabs(jet.eta()) + rJet) > (maxEta - deltaEtaEdge)) + continue; + + // jet pt must be larger than threshold + auto jetForSub = jet; + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jetForSub, rhoPerp, rhoMPerp); + if (getCorrectedPt(jetMinusBkg.pt(), responseMatrix) < minJetPt) + continue; + + // get jet constituents + std::vector jetConstituents = jet.constituents(); + o2::aod::ITSResponse itsResponse; + + // loop over jet constituents + for (const auto& particle : jetConstituents) { + for (int i = 0; i < nSystematics; i++) { + // get corresponding track and apply track selection criteria + auto const& track = tracks.iteratorAt(particle.user_index()); + + // variables + double nsigmaTPCPr = track.tpcNSigmaPr(); + double nsigmaTOFPr = track.tofNSigmaPr(); + double nsigmaTPCDe = track.tpcNSigmaDe(); + double nsigmaTOFDe = track.tofNSigmaDe(); + double pt = track.pt(); + double dcaxy = track.dcaXY(); + double dcaz = track.dcaZ(); + + if (requirePvContributor && !(track.isPVContributor())) + continue; + if (!track.hasITS()) + continue; + if (track.itsNCls() < itsNclustersSyst[i]) + continue; + if (!track.hasTPC()) + continue; + if (track.tpcNClsCrossedRows() < tpcNcrossedRowsSyst[i]) + continue; + if (track.tpcChi2NCl() > maxChiSquareTpc) + continue; + if (track.itsChi2NCl() > maxChiSquareIts) + continue; + if (track.eta() < minEta || track.eta() > maxEta) + continue; + if (track.pt() < minPt) + continue; + if (std::fabs(dcaxy) > dcaxySyst[i]) + continue; + if (std::fabs(dcaz) > dcazSyst[i]) + continue; + + bool passedItsPidProt(false), passedItsPidDeut(false); + if (itsResponse.nSigmaITS(track) > nSigmaItsMin && itsResponse.nSigmaITS(track) < nSigmaItsMax) { + passedItsPidProt = true; + } + if (itsResponse.nSigmaITS(track) > nSigmaItsMin && itsResponse.nSigmaITS(track) < nSigmaItsMax) { + passedItsPidDeut = true; + } + if (!applyItsPid) { + passedItsPidProt = true; + passedItsPidDeut = true; + } + if (pt > ptMaxItsPidProt) + passedItsPidProt = true; + if (pt > ptMaxItsPidDeut) + passedItsPidDeut = true; + + // antimatter + if (track.sign() < 0) { + if (passedItsPidProt) { + registryData.fill(HIST("antiproton_tpc_syst"), pt, nsigmaTPCPr, i); + if (nsigmaTPCPr > minNsigmaTpc && nsigmaTPCPr < maxNsigmaTpc && track.hasTOF()) + registryData.fill(HIST("antiproton_tof_syst"), pt, nsigmaTOFPr, i); + } + if (passedItsPidDeut) { + registryData.fill(HIST("antideuteron_tpc_syst"), pt, nsigmaTPCDe, i); + if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc && track.hasTOF()) + registryData.fill(HIST("antideuteron_tof_syst"), pt, nsigmaTOFDe, i); + } + } + } + } + } + } + PROCESS_SWITCH(AntinucleiInJets, processSystematicsData, "Process Systematics", false); + + void processSystematicsEfficiency(SimCollisions const& collisions, MCTracks const& mcTracks, aod::McParticles const& mcParticles) + { + const int nSystematics = 10; + int itsNclustersSyst[nSystematics] = {5, 6, 5, 4, 5, 3, 5, 6, 3, 4}; + float tpcNcrossedRowsSyst[nSystematics] = {100, 85, 80, 110, 95, 90, 105, 95, 100, 105}; + float dcaxySyst[nSystematics] = {0.05, 0.07, 0.10, 0.03, 0.06, 0.15, 0.08, 0.04, 0.09, 0.10}; + float dcazSyst[nSystematics] = {0.1, 0.15, 0.3, 0.075, 0.12, 0.18, 0.2, 0.1, 0.15, 0.2}; + + for (const auto& collision : collisions) { + + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + continue; + + // generated + for (const auto& particle : mcParticles) { + + if (!particle.isPhysicalPrimary()) + continue; + + if (particle.eta() < minEta || particle.eta() > maxEta) + continue; + + switch (particle.pdgCode()) { + case kProtonBar: + registryMC.fill(HIST("antiproton_incl_gen_syst"), particle.pt()); + break; + case -o2::constants::physics::Pdg::kDeuteron: + registryMC.fill(HIST("antideuteron_incl_gen_syst"), particle.pt()); + break; + } + } + + // ITS pid using cluster size + o2::aod::ITSResponse itsResponse; + + // Reconstructed Tracks + for (auto const& track : mcTracks) { + + // Get MC Particle + if (!track.has_mcParticle()) + continue; + const auto particle = track.mcParticle(); + + // Variables + double nsigmaTPCPr = track.tpcNSigmaPr(); + double nsigmaTOFPr = track.tofNSigmaPr(); + double nsigmaTPCDe = track.tpcNSigmaDe(); + double nsigmaTOFDe = track.tofNSigmaDe(); + double dcaxy = track.dcaXY(); + double dcaz = track.dcaZ(); + + for (int i = 0; i < nSystematics; i++) { + + // Track Selection + if (requirePvContributor && !(track.isPVContributor())) + continue; + if (!track.hasITS()) + continue; + if (track.itsNCls() < itsNclustersSyst[i]) + continue; + if (!track.hasTPC()) + continue; + if (track.tpcNClsCrossedRows() < tpcNcrossedRowsSyst[i]) + continue; + if (track.tpcChi2NCl() > maxChiSquareTpc) + continue; + if (track.itsChi2NCl() > maxChiSquareIts) + continue; + if (track.eta() < minEta || track.eta() > maxEta) + continue; + if (track.pt() < minPt) + continue; + if (std::fabs(dcaxy) > dcaxySyst[i]) + continue; + if (std::fabs(dcaz) > dcazSyst[i]) + continue; + + // particle identification using the ITS cluster size + bool passedItsPidProt(false), passedItsPidDeut(false); + if (itsResponse.nSigmaITS(track) > nSigmaItsMin && itsResponse.nSigmaITS(track) < nSigmaItsMax) { + passedItsPidProt = true; + } + if (itsResponse.nSigmaITS(track) > nSigmaItsMin && itsResponse.nSigmaITS(track) < nSigmaItsMax) { + passedItsPidDeut = true; + } + if (!applyItsPid) { + passedItsPidProt = true; + passedItsPidDeut = true; + } + if (track.pt() > ptMaxItsPidProt) + passedItsPidProt = true; + if (track.pt() > ptMaxItsPidDeut) + passedItsPidDeut = true; + if (!particle.isPhysicalPrimary()) + continue; + + if (particle.pdgCode() == kProtonBar) + registryMC.fill(HIST("antiproton_incl_prim_syst"), track.pt(), i); + + // antiprotons + if (particle.pdgCode() == kProtonBar && passedItsPidProt) { + if (nsigmaTPCPr > minNsigmaTpc && nsigmaTPCPr < maxNsigmaTpc) { + registryMC.fill(HIST("antiproton_incl_rec_tpc_syst"), track.pt(), i); + if (track.hasTOF() && nsigmaTOFPr > minNsigmaTof && nsigmaTOFPr < maxNsigmaTof) + registryMC.fill(HIST("antiproton_incl_rec_tof_syst"), track.pt(), i); + } + } + + // antideuterons + if (particle.pdgCode() == -o2::constants::physics::Pdg::kDeuteron && passedItsPidDeut) { + if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc) { + registryMC.fill(HIST("antideuteron_incl_rec_tpc_syst"), track.pt(), i); + if (track.hasTOF() && nsigmaTOFDe > minNsigmaTof && nsigmaTOFDe < maxNsigmaTof) + registryMC.fill(HIST("antideuteron_incl_rec_tof_syst"), track.pt(), i); + } + } + } + } + } + } + PROCESS_SWITCH(AntinucleiInJets, processSystematicsEfficiency, "process efficiency for systematics", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Nuspex/dedxPidAnalysis.cxx b/PWGLF/Tasks/Nuspex/dedxPidAnalysis.cxx new file mode 100644 index 00000000000..d688f0c8e72 --- /dev/null +++ b/PWGLF/Tasks/Nuspex/dedxPidAnalysis.cxx @@ -0,0 +1,852 @@ +// 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 Paola Vargas Torres (paola.vargas.torres@cern.ch) +/// \since January 8, 2025 +/// \file dedxPidAnalysis.cxx +/// \brief Analysis to do PID + +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "TF1.h" + +using namespace o2; +using namespace o2::framework; +using namespace constants::physics; + +using PIDTracks = soa::Join< + aod::Tracks, aod::TracksExtra, aod::TrackSelectionExtension, aod::TracksDCA, aod::TrackSelection, + aod::pidTOFFullPi, aod::pidTOFFullPr, aod::pidTOFFullEl, aod::pidTOFbeta>; + +using SelectedCollisions = soa::Join; + +struct DedxPidAnalysis { + + // dE/dx for all charged particles + HistogramRegistry registryDeDx{ + "registryDeDx", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + // Constant values + static constexpr int kEtaIntervals = 8; + static constexpr int kParticlesType = 4; + float tpcCut = 0.6; + float pionMin = 0.35; + float pionMax = 0.45; + float elTofCut = 0.1; + float pionTofCut = 1.0; + float invMassCut = 0.01; + float invMassCutGamma = 0.0015; + float magField = 1; + float pTcut = 2.0; + + // Configurable Parameters + // Tracks cuts + Configurable minTPCnClsFound{"minTPCnClsFound", 70.0f, + "min number of found TPC clusters"}; + Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 70.0f, "min number of found TPC crossed rows"}; + Configurable maxChi2TPC{"maxChi2TPC", 4.0f, + "max chi2 per cluster TPC"}; + Configurable maxChi2ITS{"maxChi2ITS", 36.0f, + "max chi2 per cluster ITS"}; + Configurable maxZDistanceToIP{"maxZDistanceToIP", 10.0f, + "max z distance to IP"}; + Configurable etaMin{"etaMin", -0.8f, "etaMin"}; + Configurable etaMax{"etaMax", +0.8f, "etaMax"}; + Configurable minNCrossedRowsOverFindableClustersTPC{"minNCrossedRowsOverFindableClustersTPC", 0.8f, "Additional cut on the minimum value of the ratio between crossed rows and findable clusters in the TPC"}; + Configurable maxDCAz{"maxDCAz", 2.f, "maxDCAz"}; + // v0 cuts + Configurable v0cospaMin{"v0cospaMin", 0.998f, "Minimum V0 CosPA"}; + Configurable minimumV0Radius{"minimumV0Radius", 0.5f, + "Minimum V0 Radius"}; + Configurable maximumV0Radius{"maximumV0Radius", 100.0f, + "Maximum V0 Radius"}; + Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 0.5f, + "Maximum DCA Daughters"}; + Configurable nsigmaTOFmax{"nsigmaTOFmax", 3.0f, "Maximum nsigma TOF"}; + Configurable minMassK0s{"minMassK0s", 0.4f, "Minimum Mass K0s"}; + Configurable maxMassK0s{"maxMassK0s", 0.6f, "Maximum Mass K0s"}; + Configurable minMassLambda{"minMassLambda", 1.1f, + "Minimum Mass Lambda"}; + Configurable maxMassLambda{"maxMassLambda", 1.2f, + "Maximum Mass Lambda"}; + Configurable minMassGamma{"minMassGamma", 0.000922f, + "Minimum Mass Gamma"}; + Configurable maxMassGamma{"maxMassGamma", 0.002022f, + "Maximum Mass Gamma"}; + Configurable nclCut{"nclCut", 135.0f, + "ncl Cut"}; + Configurable calibrationMode{"calibrationMode", false, "calibration mode"}; + Configurable additionalCuts{"additionalCuts", true, "additional cuts"}; + // Histograms names + static constexpr std::string_view kDedxvsMomentumPos[kParticlesType] = {"dEdx_vs_Momentum_all_Pos", "dEdx_vs_Momentum_Pi_v0_Pos", "dEdx_vs_Momentum_Pr_v0_Pos", "dEdx_vs_Momentum_El_v0_Pos"}; + static constexpr std::string_view kDedxvsMomentumNeg[kParticlesType] = {"dEdx_vs_Momentum_all_Neg", "dEdx_vs_Momentum_Pi_v0_Neg", "dEdx_vs_Momentum_Pr_v0_Neg", "dEdx_vs_Momentum_El_v0_Neg"}; + static constexpr std::string_view kNclDedxMomentumNegBefore[kEtaIntervals] = {"Ncl_vs_dEdx_vs_Momentum_Neg_1_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_2_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_3_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_4_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_5_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_6_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_7_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_8_Before"}; + static constexpr std::string_view kNclDedxMomentumPosBefore[kEtaIntervals] = {"Ncl_vs_dEdx_vs_Momentum_Pos_1_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_2_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_3_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_4_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_5_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_6_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_7_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_8_Before"}; + static constexpr std::string_view kNclDedxMomentumNegAfter[kEtaIntervals] = {"Ncl_vs_dEdx_vs_Momentum_Neg_1_After", "Ncl_vs_dEdx_vs_Momentum_Neg_2_After", "Ncl_vs_dEdx_vs_Momentum_Neg_3_After", "Ncl_vs_dEdx_vs_Momentum_Neg_4_After", "Ncl_vs_dEdx_vs_Momentum_Neg_5_After", "Ncl_vs_dEdx_vs_Momentum_Neg_6_After", "Ncl_vs_dEdx_vs_Momentum_Neg_7_After", "Ncl_vs_dEdx_vs_Momentum_Neg_8_After"}; + static constexpr std::string_view kNclDedxMomentumPosAfter[kEtaIntervals] = {"Ncl_vs_dEdx_vs_Momentum_Pos_1_After", "Ncl_vs_dEdx_vs_Momentum_Pos_2_After", "Ncl_vs_dEdx_vs_Momentum_Pos_3_After", "Ncl_vs_dEdx_vs_Momentum_Pos_4_After", "Ncl_vs_dEdx_vs_Momentum_Pos_5_After", "Ncl_vs_dEdx_vs_Momentum_Pos_6_After", "Ncl_vs_dEdx_vs_Momentum_Pos_7_After", "Ncl_vs_dEdx_vs_Momentum_Pos_8_After"}; + static constexpr double EtaCut[kEtaIntervals + 1] = {-0.8, -0.6, -0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8}; + Configurable> calibrationFactorNeg{"calibrationFactorNeg", {50.4011, 50.4764, 50.186, 49.2955, 48.8222, 49.4273, 49.9292, 50.0556}, "negative calibration factors"}; + Configurable> calibrationFactorPos{"calibrationFactorPos", {50.5157, 50.6359, 50.3198, 49.3345, 48.9197, 49.4931, 50.0188, 50.1406}, "positive calibration factors"}; + ConfigurableAxis binP{"binP", {VARIABLE_WIDTH, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 20.0}, ""}; + + // phi cut fits + TF1* fphiCutHigh = nullptr; + TF1* fphiCutLow = nullptr; + + TrackSelection myTrackSelection() + { + TrackSelection selectedTracks; + selectedTracks.SetPtRange(0.1f, 1e10f); + selectedTracks.SetEtaRange(etaMin, etaMax); + selectedTracks.SetRequireITSRefit(true); + selectedTracks.SetRequireTPCRefit(true); + selectedTracks.SetMinNCrossedRowsTPC(minNCrossedRowsTPC); + selectedTracks.SetMinNCrossedRowsOverFindableClustersTPC(minNCrossedRowsOverFindableClustersTPC); + selectedTracks.SetMaxChi2PerClusterTPC(maxChi2TPC); + selectedTracks.SetRequireHitsInITSLayers(1, {0, 1}); + selectedTracks.SetMaxChi2PerClusterITS(maxChi2ITS); + selectedTracks.SetMaxDcaXYPtDep([](float pt) { return 0.0105f + 0.0350f / std::pow(pt, 1.1f); }); + selectedTracks.SetMaxDcaZ(maxDCAz); + selectedTracks.SetRequireGoldenChi2(true); + + return selectedTracks; + } + + TrackSelection mySelectionPrim; + + void init(InitContext const&) + { + AxisSpec dedxAxis{100, 0.0, 100.0, "dE/dx (a. u.)"}; + AxisSpec ptAxis = {binP, "pT (GeV/c)"}; + AxisSpec etaAxis{8, -0.8, 0.8, "#eta"}; + AxisSpec pAxis = {binP, "#it{p}/Z (GeV/c)"}; + fphiCutLow = new TF1("StandardPhiCutLow", "0.119297/x/x+pi/18.0-0.000379693", 0, 50); + fphiCutHigh = new TF1("StandardPhiCutHigh", "0.16685/x+pi/18.0+0.00981942", 0, 50); + if (calibrationMode) { + // MIP for pions + registryDeDx.add( + "hdEdx_vs_eta_Neg_Pi", "dE/dx", HistType::kTH2F, + {{etaAxis}, {dedxAxis}}); + registryDeDx.add( + "hdEdx_vs_eta_Pos_Pi", "dE/dx", HistType::kTH2F, + {{etaAxis}, {dedxAxis}}); + // MIP for electrons + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Neg_El", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Pos_El", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + // Pions from TOF + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Neg_TOF", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Pos_TOF", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + } else { + // MIP for pions + registryDeDx.add( + "hdEdx_vs_eta_Neg_calibrated_Pi", "dE/dx", HistType::kTH2F, + {{etaAxis}, {dedxAxis}}); + + registryDeDx.add( + "hdEdx_vs_eta_Pos_calibrated_Pi", "dE/dx", HistType::kTH2F, + {{etaAxis}, {dedxAxis}}); + + // MIP for electrons + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Neg_calibrated_El", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Pos_calibrated_El", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + // Pions from TOF + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Neg_calibrated_TOF", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Pos_calibrated_TOF", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + // pt vs p + registryDeDx.add( + "hp_vs_pt_all_Neg", "p_vs_pT", HistType::kTH2F, + {{ptAxis}, {pAxis}}); + registryDeDx.add( + "hp_vs_pt_all_Pos", "p_vs_pT", HistType::kTH2F, + {{ptAxis}, {pAxis}}); + + // De/Dx for ch and v0 particles + for (int i = 0; i < kParticlesType; ++i) { + registryDeDx.add(kDedxvsMomentumPos[i].data(), "dE/dx", HistType::kTH3F, + {{pAxis}, {dedxAxis}, {etaAxis}}); + registryDeDx.add(kDedxvsMomentumNeg[i].data(), "dE/dx", HistType::kTH3F, + {{pAxis}, {dedxAxis}, {etaAxis}}); + } + } + + registryDeDx.add( + "hdEdx_vs_phi", "dE/dx", HistType::kTH2F, + {{100, 0.0, 6.4, "#phi"}, {dedxAxis}}); + + // phi cut + registryDeDx.add( + "hpt_vs_phi_Ncl_After", "phi cut", HistType::kTH3F, + {{ptAxis}, {100, 0.0, 0.4, "#varphi^{'}"}, {100, 0, 160, "N_{cl}"}}); + + registryDeDx.add( + "hpt_vs_phi_Ncl_Before", "phi cut", HistType::kTH3F, + {{ptAxis}, {100, 0.0, 0.4, "#varphi^{'}"}, {100, 0, 160, "N_{cl}"}}); + + // Ncl vs de/dx + + for (int i = 0; i < kEtaIntervals; ++i) { + registryDeDx.add(kNclDedxMomentumPosBefore[i].data(), "Ncl vs dE/dx vs Momentum Positive before", HistType::kTH3F, + {{100, 0, 160, "N_{cl}"}, {dedxAxis}, {pAxis}}); + registryDeDx.add(kNclDedxMomentumNegBefore[i].data(), "Ncl vs dE/dx vs Momentum Negative before", HistType::kTH3F, + {{100, 0, 160, "N_{cl}"}, {dedxAxis}, {pAxis}}); + + registryDeDx.add(kNclDedxMomentumPosAfter[i].data(), "Ncl vs dE/dx vs Momentum Positive after", HistType::kTH3F, + {{100, 0, 160, "N_{cl}"}, {dedxAxis}, {pAxis}}); + registryDeDx.add(kNclDedxMomentumNegAfter[i].data(), "Ncl vs dE/dx vs Momentum Negative after", HistType::kTH3F, + {{100, 0, 160, "N_{cl}"}, {dedxAxis}, {pAxis}}); + } + + // beta plot + registryDeDx.add( + "hbeta_vs_p_Neg", "beta", HistType::kTH2F, + {{pAxis}, {100, 0.0, 1.1, "#beta"}}); + + registryDeDx.add( + "hbeta_vs_p_Pos", "beta", HistType::kTH2F, + {{pAxis}, {100, 0.0, 1.1, "#beta"}}); + + // Event Counter + registryDeDx.add("histRecVtxZData", "collision z position", HistType::kTH1F, {{100, -20.0, +20.0, "z_{vtx} (cm)"}}); + + mySelectionPrim = myTrackSelection(); + } + + // Single-Track Selection + template + bool passedSingleTrackSelection(const T1& track, const C& /*collision*/) + { + // Single-Track Selections + 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; + + return true; + } + + // General V0 Selections + template + bool passedV0Selection(const T1& v0, const C& /*collision*/) + { + if (v0.v0cosPA() < v0cospaMin) + return false; + if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) + return false; + + return true; + } + + // K0s Selections + template + bool passedK0Selection(const T1& v0, const T2& ntrack, const T2& ptrack, + const C& collision) + { + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack, collision)) + return false; + if (!passedSingleTrackSelection(ntrack, collision)) + return false; + + if (ptrack.tpcInnerParam() > tpcCut) { + if (!ptrack.hasTOF()) + return false; + if (std::abs(ptrack.tofNSigmaPi()) > nsigmaTOFmax) + return false; + } + + if (ntrack.tpcInnerParam() > tpcCut) { + if (!ntrack.hasTOF()) + return false; + if (std::abs(ntrack.tofNSigmaPi()) > nsigmaTOFmax) + return false; + } + + // Invariant-Mass Selection + if (v0.mK0Short() < minMassK0s || v0.mK0Short() > maxMassK0s) + return false; + + return true; + } + + // Lambda Selections + template + bool passedLambdaSelection(const T1& v0, const T2& ntrack, const T2& ptrack, + const C& collision) + { + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack, collision)) + return false; + if (!passedSingleTrackSelection(ntrack, collision)) + return false; + + if (ptrack.tpcInnerParam() > tpcCut) { + if (!ptrack.hasTOF()) + return false; + if (std::abs(ptrack.tofNSigmaPr()) > nsigmaTOFmax) + return false; + } + + if (ntrack.tpcInnerParam() > tpcCut) { + if (!ntrack.hasTOF()) + return false; + if (std::abs(ntrack.tofNSigmaPi()) > nsigmaTOFmax) + return false; + } + + // Invariant-Mass Selection + if (v0.mLambda() < minMassLambda || v0.mLambda() > maxMassLambda) + return false; + + return true; + } + + // AntiLambda Selections + template + bool passedAntiLambdaSelection(const T1& v0, const T2& ntrack, + const T2& ptrack, const C& collision) + { + + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack, collision)) + return false; + if (!passedSingleTrackSelection(ntrack, collision)) + return false; + + if (ptrack.tpcInnerParam() > tpcCut) { + if (!ptrack.hasTOF()) + return false; + if (std::abs(ptrack.tofNSigmaPi()) > nsigmaTOFmax) + return false; + } + + if (ntrack.tpcInnerParam() > tpcCut) { + if (!ntrack.hasTOF()) + return false; + if (std::abs(ntrack.tofNSigmaPr()) > nsigmaTOFmax) + return false; + } + + // Invariant-Mass Selection + if (v0.mAntiLambda() < minMassLambda || v0.mAntiLambda() > maxMassLambda) + return false; + + return true; + } + + // Gamma Selections + template + bool passedGammaSelection(const T1& v0, const T2& ntrack, const T2& ptrack, + const C& collision) + { + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack, collision)) + return false; + if (!passedSingleTrackSelection(ntrack, collision)) + return false; + + if (ptrack.tpcInnerParam() > tpcCut) { + if (!ptrack.hasTOF()) + return false; + if (std::abs(ptrack.tofNSigmaEl()) > nsigmaTOFmax) + return false; + } + + if (ntrack.tpcInnerParam() > tpcCut) { + if (!ntrack.hasTOF()) + return false; + if (std::abs(ntrack.tofNSigmaEl()) > nsigmaTOFmax) + return false; + } + + // Invariant-Mass Selection + if (v0.mGamma() < minMassGamma || v0.mGamma() > maxMassGamma) + return false; + + return true; + } + + // Phi cut + template + bool passedPhiCut(const T& trk, float magField, const TF1& fphiCutLow, const TF1& fphiCutHigh) + { + float pt = trk.pt(); + float phi = trk.phi(); + int charge = trk.sign(); + float eta = trk.eta(); + auto nTPCCl = trk.tpcNClsFindable() - trk.tpcNClsFindableMinusFound(); + float sigP = trk.sign() * trk.tpcInnerParam(); + + if (pt < pTcut) + return true; + + if (magField < 0) // for negatve polarity field + phi = o2::constants::math::TwoPI - phi; + if (charge < 0) // for negatve charge + phi = o2::constants::math::TwoPI - phi; + + // to center gap in the middle + phi += o2::constants::math::PI / 18.0f; + phi = std::fmod(phi, o2::constants::math::PI / 9.0f); + + registryDeDx.fill(HIST("hpt_vs_phi_Ncl_Before"), pt, phi, nTPCCl); + + // cut phi + if (phi < fphiCutHigh.Eval(pt) && phi > fphiCutLow.Eval(pt)) + return false; // reject track + + if (eta > EtaCut[0] && eta < EtaCut[1]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[0]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[0]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[1] && eta < EtaCut[2]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[1]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[1]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[2] && eta < EtaCut[3]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[2]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[2]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[3] && eta < EtaCut[4]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[3]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[3]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[4] && eta < EtaCut[5]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[4]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[4]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[5] && eta < EtaCut[6]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[5]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[5]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[6] && eta < EtaCut[7]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[6]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[6]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[7] && eta < EtaCut[8]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[7]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[7]), nTPCCl, trk.tpcSignal(), sigP); + } + } + + // cut Ncl + if (nTPCCl < nclCut) + return false; + + registryDeDx.fill(HIST("hpt_vs_phi_Ncl_After"), pt, phi, nTPCCl); + + if (eta > EtaCut[0] && eta < EtaCut[1]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[0]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[0]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[1] && eta < EtaCut[2]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[1]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[1]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[2] && eta < EtaCut[3]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[2]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[2]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[3] && eta < EtaCut[4]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[3]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[3]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[4] && eta < EtaCut[5]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[4]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[4]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[5] && eta < EtaCut[6]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[5]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[5]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[6] && eta < EtaCut[7]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[6]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[6]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[7] && eta < EtaCut[8]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[7]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[7]), nTPCCl, trk.tpcSignal(), sigP); + } + } + + return true; + } + + // Phi cut Secondaries + template + bool passedPhiCutSecondaries(const T& trk, float magField, const TF1& fphiCutLow, const TF1& fphiCutHigh) + { + float pt = trk.pt(); + float phi = trk.phi(); + int charge = trk.sign(); + auto nTPCCl = trk.tpcNClsFindable() - trk.tpcNClsFindableMinusFound(); + + if (pt < pTcut) + return true; + + if (magField < 0) // for negatve polarity field + phi = o2::constants::math::TwoPI - phi; + if (charge < 0) // for negatve charge + phi = o2::constants::math::TwoPI - phi; + + // to center gap in the middle + phi += o2::constants::math::PI / 18.0f; + phi = std::fmod(phi, o2::constants::math::PI / 9.0f); + + // cut phi + if (phi < fphiCutHigh.Eval(pt) && phi > fphiCutLow.Eval(pt)) + return false; // reject track + + // cut Ncl + if (nTPCCl < nclCut) + return false; + + return true; + } + + // Process Data + void process(SelectedCollisions::iterator const& collision, + aod::V0Datas const& fullV0s, PIDTracks const& tracks) + { + // Event Selection + if (!collision.sel8()) + return; + + if (additionalCuts) { + if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + return; + + if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) + return; + + if (std::abs(collision.posZ()) >= maxZDistanceToIP) + return; + + if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) + return; + } + + // Event Counter + registryDeDx.fill(HIST("histRecVtxZData"), collision.posZ()); + + // Kaons + for (const auto& trk : tracks) { + + // track Selection + if (!passedSingleTrackSelection(trk, collision)) + continue; + + if (!mySelectionPrim.IsSelected(trk)) + continue; + + // phi and Ncl cut + if (!passedPhiCut(trk, magField, *fphiCutLow, *fphiCutHigh)) + continue; + + float signedP = trk.sign() * trk.tpcInnerParam(); + + // MIP calibration for pions + if (trk.tpcInnerParam() >= pionMin && trk.tpcInnerParam() <= pionMax) { + if (calibrationMode) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_Neg_Pi"), trk.eta(), trk.tpcSignal()); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_Pos_Pi"), trk.eta(), trk.tpcSignal()); + } + + } else { + for (int i = 0; i < kEtaIntervals; ++i) { + if (trk.eta() > EtaCut[i] && trk.eta() < EtaCut[i + 1]) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_Neg_calibrated_Pi"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorNeg->at(i)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_Pos_calibrated_Pi"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorPos->at(i)); + } + } + } + } + } + // Beta from TOF + if (signedP < 0) { + registryDeDx.fill(HIST("hbeta_vs_p_Neg"), std::abs(signedP), trk.beta()); + } else { + registryDeDx.fill(HIST("hbeta_vs_p_Pos"), signedP, trk.beta()); + } + // Electrons from TOF + if (std::abs(trk.beta() - 1) < elTofCut) { // beta cut + if (calibrationMode) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Neg_El"), trk.eta(), trk.tpcSignal(), std::abs(signedP)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Pos_El"), trk.eta(), trk.tpcSignal(), signedP); + } + } else { + for (int i = 0; i < kEtaIntervals; ++i) { + if (trk.eta() > EtaCut[i] && trk.eta() < EtaCut[i + 1]) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Neg_calibrated_El"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorNeg->at(i), std::abs(signedP)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Pos_calibrated_El"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorPos->at(i), signedP); + } + } + } + } + } + // pions from TOF + if (trk.beta() > pionTofCut && trk.beta() < pionTofCut + 0.05) { // beta cut + if (calibrationMode) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Neg_TOF"), trk.eta(), trk.tpcSignal(), std::abs(signedP)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Pos_TOF"), trk.eta(), trk.tpcSignal(), signedP); + } + } else { + for (int i = 0; i < kEtaIntervals; ++i) { + if (trk.eta() > EtaCut[i] && trk.eta() < EtaCut[i + 1]) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Neg_calibrated_TOF"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorNeg->at(i), std::abs(signedP)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Pos_calibrated_TOF"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorPos->at(i), signedP); + } + } + } + } + } + + registryDeDx.fill(HIST("hdEdx_vs_phi"), trk.phi(), trk.tpcSignal()); + + if (!calibrationMode) { + for (int i = 0; i < kEtaIntervals; ++i) { + if (trk.eta() > EtaCut[i] && trk.eta() < EtaCut[i + 1]) { + if (signedP > 0) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[0]), signedP, trk.tpcSignal() * 50 / calibrationFactorPos->at(i), trk.eta()); + registryDeDx.fill(HIST("hp_vs_pt_all_Pos"), trk.pt(), signedP); + } else { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[0]), std::abs(signedP), trk.tpcSignal() * 50 / calibrationFactorNeg->at(i), trk.eta()); + registryDeDx.fill(HIST("hp_vs_pt_all_Neg"), trk.pt(), std::abs(signedP)); + } + } + } + } + } + + // Loop over Reconstructed V0s + if (!calibrationMode) { + for (const auto& v0 : fullV0s) { + + // Standard V0 Selections + if (!passedV0Selection(v0, collision)) { + continue; + } + + if (v0.dcaV0daughters() > dcaV0DaughtersMax) { + continue; + } + + // Positive and Negative Tracks + const auto& posTrack = v0.posTrack_as(); + const auto& negTrack = v0.negTrack_as(); + + if (!posTrack.passedTPCRefit()) + continue; + if (!negTrack.passedTPCRefit()) + continue; + // phi and Ncl cut + if (!passedPhiCutSecondaries(posTrack, magField, *fphiCutLow, *fphiCutHigh)) + continue; + + if (!passedPhiCutSecondaries(negTrack, magField, *fphiCutLow, *fphiCutHigh)) + continue; + + float signedPpos = posTrack.sign() * posTrack.tpcInnerParam(); + float signedPneg = negTrack.sign() * negTrack.tpcInnerParam(); + + float pxPos = posTrack.px(); + float pyPos = posTrack.py(); + float pzPos = posTrack.pz(); + + float pxNeg = negTrack.px(); + float pyNeg = negTrack.py(); + float pzNeg = negTrack.pz(); + + const float gammaMass = 2 * MassElectron; // GeV/c^2 + + // K0s Selection + if (passedK0Selection(v0, negTrack, posTrack, collision)) { + float ePosPi = posTrack.energy(MassPionCharged); + float eNegPi = negTrack.energy(MassPionCharged); + + float invMass = std::sqrt((eNegPi + ePosPi) * (eNegPi + ePosPi) - ((pxNeg + pxPos) * (pxNeg + pxPos) + (pyNeg + pyPos) * (pyNeg + pyPos) + (pzNeg + pzPos) * (pzNeg + pzPos))); + + if (std::abs(invMass - MassK0Short) > invMassCut) { + continue; + } + + for (int i = 0; i < kEtaIntervals; ++i) { + if (negTrack.eta() > EtaCut[i] && negTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[1]), std::abs(signedPneg), negTrack.tpcSignal() * 50 / calibrationFactorNeg->at(i), negTrack.eta()); + } + if (posTrack.eta() > EtaCut[i] && posTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[1]), signedPpos, posTrack.tpcSignal() * 50 / calibrationFactorPos->at(i), posTrack.eta()); + } + } + } + + // Lambda Selection + if (passedLambdaSelection(v0, negTrack, posTrack, collision)) { + + float ePosPr = posTrack.energy(MassProton); + float eNegPi = negTrack.energy(MassPionCharged); + + float invMass = std::sqrt((eNegPi + ePosPr) * (eNegPi + ePosPr) - ((pxNeg + pxPos) * (pxNeg + pxPos) + (pyNeg + pyPos) * (pyNeg + pyPos) + (pzNeg + pzPos) * (pzNeg + pzPos))); + + if (std::abs(invMass - MassLambda) > invMassCut) { + continue; + } + + for (int i = 0; i < kEtaIntervals; ++i) { + if (negTrack.eta() > EtaCut[i] && negTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[1]), std::abs(signedPneg), negTrack.tpcSignal() * 50 / calibrationFactorNeg->at(i), negTrack.eta()); + } + if (posTrack.eta() > EtaCut[i] && posTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[2]), signedPpos, posTrack.tpcSignal() * 50 / calibrationFactorPos->at(i), posTrack.eta()); + } + } + } + + // AntiLambda Selection + if (passedAntiLambdaSelection(v0, negTrack, posTrack, collision)) { + + float ePosPi = posTrack.energy(MassPionCharged); + float eNegPr = negTrack.energy(MassProton); + + float invMass = std::sqrt((eNegPr + ePosPi) * (eNegPr + ePosPi) - ((pxNeg + pxPos) * (pxNeg + pxPos) + (pyNeg + pyPos) * (pyNeg + pyPos) + (pzNeg + pzPos) * (pzNeg + pzPos))); + + if (std::abs(invMass - MassLambda) > invMassCut) { + continue; + } + + for (int i = 0; i < kEtaIntervals; ++i) { + if (negTrack.eta() > EtaCut[i] && negTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[2]), std::abs(signedPneg), negTrack.tpcSignal() * 50 / calibrationFactorNeg->at(i), negTrack.eta()); + } + if (posTrack.eta() > EtaCut[i] && posTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[1]), signedPpos, posTrack.tpcSignal() * 50 / calibrationFactorPos->at(i), posTrack.eta()); + } + } + } + + // Gamma Selection + if (passedGammaSelection(v0, negTrack, posTrack, collision)) { + + float ePosEl = posTrack.energy(MassElectron); + float eNegEl = negTrack.energy(MassElectron); + + float invMass = std::sqrt((eNegEl + ePosEl) * (eNegEl + ePosEl) - ((pxNeg + pxPos) * (pxNeg + pxPos) + (pyNeg + pyPos) * (pyNeg + pyPos) + (pzNeg + pzPos) * (pzNeg + pzPos))); + + if (std::abs(invMass - gammaMass) > invMassCutGamma) { + continue; + } + + for (int i = 0; i < kEtaIntervals; ++i) { + if (negTrack.eta() > EtaCut[i] && negTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[3]), std::abs(signedPneg), negTrack.tpcSignal() * 50 / calibrationFactorNeg->at(i), negTrack.eta()); + } + if (posTrack.eta() > EtaCut[i] && posTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[3]), signedPpos, posTrack.tpcSignal() * 50 / calibrationFactorPos->at(i), posTrack.eta()); + } + } + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Nuspex/ebyeMult.cxx b/PWGLF/Tasks/Nuspex/ebyeMult.cxx deleted file mode 100644 index 7fc0ca8e941..00000000000 --- a/PWGLF/Tasks/Nuspex/ebyeMult.cxx +++ /dev/null @@ -1,584 +0,0 @@ -// 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. - -/// \file ebyeMult.cxx -/// \brief task to carry out multiplicity measurements for lf ebye analyses -/// \author Mario Ciacco - -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/Centrality.h" -// #include "Common/DataModel/Multiplicity.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" - -#include "TFormula.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -using TracksFull = soa::Join; -using BCsWithRun2Info = soa::Join; - -namespace -{ -constexpr float dcaSels[3]{10., 10., 10.}; -static const std::vector dcaSelsNames{"dcaxy", "dcaz", "dca"}; -static const std::vector particleName{"tracks"}; -} // namespace - -struct CandidateTrack { - float pt = -999.f; - float eta = -999.f; - float dcapv = 0; - float dcaxypv = 0; - float dcazpv = 0; - float genpt = -999.f; - float geneta = -999.f; - int pdgcode = -999; - bool isreco = 0; - int64_t mcIndex = -999; - int64_t globalIndex = -999; -}; - -struct CandidateEvent { - int nTrkRec = -1; - int nTklRec = -1; -}; - -struct TagRun2V0MCalibration { - bool mCalibrationStored = false; - TH1* mhVtxAmpCorrV0A = nullptr; - TH1* mhVtxAmpCorrV0C = nullptr; - TH1* mhMultSelCalib = nullptr; - float mMCScalePars[6] = {0.0}; - TFormula* mMCScale = nullptr; -} Run2V0MInfo; - -enum PartTypes { - kPi = 0, - kKa = 1, - kPr = 2, - kEl = 3, - kMu = 4, - kSig = 5, - kXi = 6, - kOm = 7, - kOther = 8 -}; - -struct EbyeMult { - std::vector candidateTracks; - Service ccdb; - CandidateEvent candidateEvent; - - int mRunNumber; - float dBz; - uint8_t nTrackletsColl; - - ConfigurableAxis centAxis{"centAxis", {106, 0, 106}, "binning for the centrality"}; - ConfigurableAxis zVtxAxis{"zVtxAxis", {100, -20.f, 20.f}, "Binning for the vertex z in cm"}; - ConfigurableAxis multAxis{"multAxis", {100, 0.f, 100.f}, "Binning for the multiplicity axis"}; - ConfigurableAxis multFt0Axis{"multFt0Axis", {100, 0.f, 100.f}, "Binning for the ft0 multiplicity axis"}; - Configurable genName{"genName", "", "Genearator name: HIJING, PYTHIA8, ... Default: \"\""}; - - Configurable zVtxMax{"zVtxMax", 10.0f, "maximum z position of the primary vertex"}; - Configurable etaMax{"etaMax", 0.8f, "maximum eta"}; - - Configurable ptMin{"ptMin", 0.05f, "minimum pT (GeV/c)"}; - Configurable ptMax{"ptMax", 10.f, "maximum pT (GeV/c)"}; - - Configurable trackNcrossedRows{"trackNcrossedRows", 70, "Minimum number of crossed TPC rows"}; - Configurable trackNclusITScut{"trackNclusITScut", 2, "Minimum number of ITS clusters"}; - Configurable trackNclusTPCcut{"trackNclusTPCcut", 60, "Minimum number of TPC clusters"}; - Configurable trackChi2Cut{"trackChi2Cut", 4.f, "Maximum chi2/ncls in TPC"}; - Configurable> cfgDcaSels{"cfgDcaSels", {dcaSels, 1, 3, particleName, dcaSelsNames}, "DCA selections"}; - - HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - Preslice perCollisionTracksFull = o2::aod::track::collisionId; - Preslice perCollisionMcParts = o2::aod::mcparticle::mcCollisionId; - - // TODO: add function to extract the particle type based on the pdg code - int getPartType(int const pdgCode) - { - switch (std::abs(pdgCode)) { - case 211: - return PartTypes::kPi; - case 321: - return PartTypes::kKa; - case 2212: - return PartTypes::kPr; - case 11: - return PartTypes::kEl; - case 13: - return PartTypes::kMu; - case 3222: - return PartTypes::kSig; - case 3112: - return PartTypes::kSig; - case 3312: - return PartTypes::kXi; - case 3334: - return PartTypes::kOm; - default: - return PartTypes::kOther; - } - } - - template - bool selectTrack(T const& track) - { - if (std::abs(track.eta()) > etaMax) { - return false; - } - if (!(track.itsClusterMap() & 0x01) && !(track.itsClusterMap() & 0x02)) { - return false; - } - if (track.itsNCls() < trackNclusITScut || - track.tpcNClsFound() < trackNclusTPCcut || - track.tpcNClsCrossedRows() < trackNcrossedRows || - track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || - track.tpcChi2NCl() > trackChi2Cut || - track.itsChi2NCl() > 36.f) { - return false; - } - if (doprocessRun2 || doprocessMcRun2) { - if (!(track.trackType() & o2::aod::track::Run2Track) || - !(track.flags() & o2::aod::track::TPCrefit) || - !(track.flags() & o2::aod::track::ITSrefit)) { - return false; - } - } - return true; - } - - template - void initCCDB(Bc const& bc) - { - if (mRunNumber == bc.runNumber()) { - return; - } - - auto timestamp = bc.timestamp(); - o2::parameters::GRPObject* grpo = 0x0; - o2::parameters::GRPMagField* grpmag = 0x0; - if (doprocessRun2 || doprocessMcRun2) { - auto grpPath{"GLO/GRP/GRP"}; - grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); - if (!grpo) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpPath << " of object GRPObject for timestamp " << timestamp; - } - o2::base::Propagator::initFieldFromGRP(grpo); - TList* callst = ccdb->getForTimeStamp("Centrality/Estimators", bc.timestamp()); - auto getccdb = [callst](const char* ccdbhname) { - TH1* h = reinterpret_cast(callst->FindObject(ccdbhname)); - return h; - }; - auto getformulaccdb = [callst](const char* ccdbhname) { - TFormula* f = reinterpret_cast(callst->FindObject(ccdbhname)); - return f; - }; - Run2V0MInfo.mhVtxAmpCorrV0A = getccdb("hVtx_fAmplitude_V0A_Normalized"); - Run2V0MInfo.mhVtxAmpCorrV0C = getccdb("hVtx_fAmplitude_V0C_Normalized"); - Run2V0MInfo.mhMultSelCalib = getccdb("hMultSelCalib_V0M"); - Run2V0MInfo.mMCScale = getformulaccdb(TString::Format("%s-V0M", genName->c_str()).Data()); - if ((Run2V0MInfo.mhVtxAmpCorrV0A != nullptr) && (Run2V0MInfo.mhVtxAmpCorrV0C != nullptr) && (Run2V0MInfo.mhMultSelCalib != nullptr)) { - if (genName->length() != 0) { - if (Run2V0MInfo.mMCScale != nullptr) { - for (int ixpar = 0; ixpar < 6; ++ixpar) { - Run2V0MInfo.mMCScalePars[ixpar] = Run2V0MInfo.mMCScale->GetParameter(ixpar); - } - } else { - LOGF(fatal, "MC Scale information from V0M for run %d not available", bc.runNumber()); - } - } - Run2V0MInfo.mCalibrationStored = true; - } else { - LOGF(fatal, "Calibration information from V0M for run %d corrupted", bc.runNumber()); - } - } else { - auto grpmagPath{"GLO/Config/GRPMagField"}; - grpmag = ccdb->getForTimeStamp("GLO/Config/GRPMagField", timestamp); - if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField for timestamp " << timestamp; - } - o2::base::Propagator::initFieldFromGRP(grpmag); - } - // Fetch magnetic field from ccdb for current collision - dBz = o2::base::Propagator::Instance()->getNominalBz(); - LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << dBz << " kG"; - mRunNumber = bc.runNumber(); - } - - float getV0M(int64_t const id, float const zvtx, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs) - { - auto fv0a = fv0as.rawIteratorAt(id); - auto fv0c = fv0cs.rawIteratorAt(id); - float multFV0A = 0; - float multFV0C = 0; - for (float const& amplitude : fv0a.amplitude()) { - multFV0A += amplitude; - } - - for (float const& amplitude : fv0c.amplitude()) { - multFV0C += amplitude; - } - - float v0m = -1; - auto scaleMC = [](float x, float pars[6]) { - return std::pow(((pars[0] + pars[1] * std::pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]); - }; - - if (Run2V0MInfo.mMCScale != nullptr) { - float multFV0M = multFV0A + multFV0C; - v0m = scaleMC(multFV0M, Run2V0MInfo.mMCScalePars); - LOGF(debug, "Unscaled v0m: %f, scaled v0m: %f", multFV0M, v0m); - } else { - v0m = multFV0A * Run2V0MInfo.mhVtxAmpCorrV0A->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0A->FindFixBin(zvtx)) + - multFV0C * Run2V0MInfo.mhVtxAmpCorrV0C->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0C->FindFixBin(zvtx)); - } - return v0m; - } - - void init(o2::framework::InitContext&) - { - - mRunNumber = 0; - dBz = 0; - - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - // event QA - histos.add("QA/zVtx", ";#it{z}_{vtx} (cm);Entries", HistType::kTH1F, {zVtxAxis}); - histos.add("QA/V0MvsCL0", ";Centrality CL0 (%);Centrality V0M (%)", HistType::kTH2F, {centAxis, centAxis}); - histos.add("QA/trackletsVsV0M", ";Centrality CL0 (%);Centrality V0M (%)", HistType::kTH2F, {centAxis, multAxis}); - histos.add("QA/nTrklCorrelation", ";Tracklets |#eta| > 0.7; Tracklets |#eta| < 0.6", HistType::kTH2D, {{201, -0.5, 200.5}, {201, -0.5, 200.5}}); - histos.add("QA/nV0MCorrelation", ";V0M Multiplicity (%); Tracklets |#eta| < 0.6", HistType::kTH2D, {multAxis, {201, -0.5, 200.5}}); - histos.add("QA/TrklEta", ";Tracklets #eta; Entries", HistType::kTH1D, {{100, -3., 3.}}); - - // rec tracks - histos.add("RecTracks", ";Tracklets |#eta| > 0.7;#it{p}_{T} (GeV/#it{c});DCA_{#it{xy}} (cm)", HistType::kTH3D, {{201, -0.5, 200.5}, {100, -5., 5.}, {200, -1., 1.}}); - histos.add("RecTracksV0M", ";V0M Multiplicity (%);#it{p}_{T} (GeV/#it{c});DCA_{#it{xy}} (cm)", HistType::kTH3D, {multAxis, {100, -5., 5.}, {200, -1., 1.}}); - - // rec tracks and tracklets distribution - histos.add("TracksDistr", ";Tracklets |#eta| > 0.7;#it{N}_{trk}", HistType::kTH2D, {{201, -0.5, 200.5}, {201, -0.5, 200.5}}); - histos.add("TrackletsDistr", ";Tracklets |#eta| > 0.7;#it{N}_{tkl}", HistType::kTH2D, {{201, -0.5, 200.5}, {201, -0.5, 200.5}}); - - histos.add("TracksDistrV0M", ";V0M Multiplicity (%);#it{N}_{trk}", HistType::kTH2D, {multAxis, {201, -0.5, 200.5}}); - histos.add("TrackletsDistrV0M", ";V0M Multiplicity (%);#it{N}_{tkl}", HistType::kTH2D, {multAxis, {201, -0.5, 200.5}}); - - if (doprocessMcRun2) { - // rec & gen particles (per species) - histos.add("RecPart", ";Tracklets |#eta| > 0.7;#it{p}_{T} (GeV/#it{c});Species", HistType::kTH3D, {{201, -0.5, 200.5}, {100, -5., 5.}, {10, 0, 10}}); - histos.add("GenPart", ";Tracklets |#eta| > 0.7;#it{p}_{T} (GeV/#it{c});Species", HistType::kTH3D, {{201, -0.5, 200.5}, {100, -5., 5.}, {10, 0, 10}}); - - histos.add("RecPartV0M", ";V0M Multiplicity (%);#it{p}_{T} (GeV/#it{c});Species", HistType::kTH3D, {multAxis, {100, -5., 5.}, {10, 0, 10}}); - histos.add("GenPartV0M", ";V0M Multiplicity (%);#it{p}_{T} (GeV/#it{c});Species", HistType::kTH3D, {multAxis, {100, -5., 5.}, {10, 0, 10}}); - - // dca_xy templates - histos.add("PrimTracks", ";Tracklets |#eta| > 0.7;#it{p}_{T} (GeV/#it{c});DCA_{#it{xy}} (cm)", HistType::kTH3D, {{201, -0.5, 200.5}, {100, -5., 5.}, {200, -1., 1.}}); - histos.add("SecWDTracks", ";Tracklets |#eta| > 0.7;#it{p}_{T} (GeV/#it{c});DCA_{#it{xy}} (cm)", HistType::kTH3D, {{201, -0.5, 200.5}, {100, -5., 5.}, {200, -1., 1.}}); - histos.add("SecTracks", ";Tracklets |#eta| > 0.7;#it{p}_{T} (GeV/#it{c});DCA_{#it{xy}} (cm)", HistType::kTH3D, {{201, -0.5, 200.5}, {100, -5., 5.}, {200, -1., 1.}}); - - histos.add("PrimTracksV0M", ";V0M Multiplicity (%);#it{p}_{T} (GeV/#it{c});DCA_{#it{xy}} (cm)", HistType::kTH3D, {multAxis, {100, -5., 5.}, {200, -1., 1.}}); - histos.add("SecWDTracksV0M", ";V0M Multiplicity (%);#it{p}_{T} (GeV/#it{c});DCA_{#it{xy}} (cm)", HistType::kTH3D, {multAxis, {100, -5., 5.}, {200, -1., 1.}}); - histos.add("SecTracksV0M", ";V0M Multiplicity (%);#it{p}_{T} (GeV/#it{c});DCA_{#it{xy}} (cm)", HistType::kTH3D, {multAxis, {100, -5., 5.}, {200, -1., 1.}}); - - // response - histos.add("GenRecTracks", ";Tracklets |#eta| > 0.7;#it{N}_{trk};#it{N}_{gen}", HistType::kTH3D, {{201, -0.5, 200.5}, {201, -0.5, 200.5}, {201, -0.5, 200.5}}); - histos.add("GenRecTracklets", ";Tracklets |#eta| > 0.7;#it{N}_{tkl};#it{N}_{gen}", HistType::kTH3D, {{201, -0.5, 200.5}, {201, -0.5, 200.5}, {201, -0.5, 200.5}}); - - histos.add("GenRecTracksV0M", ";V0M Multiplicity (%);#it{N}_{trk};#it{N}_{gen}", HistType::kTH3D, {multAxis, {201, -0.5, 200.5}, {201, -0.5, 200.5}}); - histos.add("GenRecTrackletsV0M", ";V0M Multiplicity (%);#it{N}_{tkl};#it{N}_{gen}", HistType::kTH3D, {multAxis, {201, -0.5, 200.5}, {201, -0.5, 200.5}}); - } - - // histograms for the evaluation of trigger efficiency - histos.add("GenINELgtZERO", ";#it{N}_{gen}", HistType::kTH1D, {multAxis}); - histos.add("RecINELgtZERO", ";#it{N}_{gen}", HistType::kTH1D, {multAxis}); - } - - template - void fillRecoEvent(C const& collision, T const& tracksAll, float const& centrality) - { - auto tracks = tracksAll.sliceBy(perCollisionTracksFull, collision.globalIndex()); - candidateTracks.clear(); - - gpu::gpustd::array dcaInfo; - int nTracklets[2]{0, 0}; - int nTracks{0}; - for (const auto& track : tracks) { - - if (track.trackType() == 255 && std::abs(track.eta()) < 1.2) { // tracklet - if (std::abs(track.eta()) < 0.6) - nTracklets[0]++; - else if (std::abs(track.eta()) > 0.7) - nTracklets[1]++; - } - - if (!selectTrack(track)) { - continue; - } - - auto trackParCov = getTrackParCov(track); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParCov, 2.f, o2::base::Propagator::MatCorrType::USEMatCorrNONE, &dcaInfo); - auto dca = std::hypot(dcaInfo[0], dcaInfo[1]); - auto trackPt = trackParCov.getPt(); - auto trackEta = trackParCov.getEta(); - if (dca > cfgDcaSels->get("dca")) { // dca - continue; - } - if (std::abs(dcaInfo[1]) > cfgDcaSels->get("dcaz")) { // dcaz - continue; - } - - CandidateTrack candTrack; - candTrack.pt = track.sign() > 0. ? trackPt : -trackPt; - if (trackPt < ptMin || trackPt > ptMax) - continue; - candTrack.eta = trackEta; - candTrack.dcapv = dca; - candTrack.dcaxypv = dcaInfo[0]; - candTrack.dcazpv = dcaInfo[1]; - candTrack.globalIndex = track.globalIndex(); - candidateTracks.push_back(candTrack); - - if (std::abs(dcaInfo[0]) < cfgDcaSels->get("dcaxy")) { // dcaxy TODO: add pt dependent dcaxy cut - ++nTracks; - } - } - - histos.fill(HIST("QA/nTrklCorrelation"), nTracklets[1], nTracklets[0]); - histos.fill(HIST("QA/nV0MCorrelation"), centrality, nTracklets[0]); - nTrackletsColl = nTracklets[1]; - - candidateEvent.nTklRec = nTracklets[0]; - histos.fill(HIST("TracksDistr"), nTracklets[1], nTracks); - histos.fill(HIST("TrackletsDistr"), nTracklets[1], nTracklets[0]); - histos.fill(HIST("TracksDistrV0M"), centrality, nTracks); - histos.fill(HIST("TrackletsDistrV0M"), centrality, nTracklets[0]); - } - - template - void fillMcEvent(C const& collision, T const& tracks, float const& centrality, aod::McParticles const&, aod::McTrackLabels const& mcLabels) - { - fillRecoEvent(collision, tracks, centrality); - - int nTracks{0}; - for (int iT{0}; iT < static_cast(candidateTracks.size()); ++iT) { - candidateTracks[iT].isreco = true; - - auto mcLab = mcLabels.rawIteratorAt(candidateTracks[iT].globalIndex); - if (mcLab.has_mcParticle()) { - auto mcTrack = mcLab.template mcParticle_as(); - if (((mcTrack.flags() & 0x8) && (doprocessMcRun2)) || (mcTrack.flags() & 0x2) || (mcTrack.flags() & 0x1)) - continue; - if (!mcTrack.isPhysicalPrimary()) { - if (mcTrack.has_mothers()) { // sec WD - histos.fill(HIST("SecWDTracks"), nTrackletsColl, candidateTracks[iT].pt, candidateTracks[iT].dcaxypv); - histos.fill(HIST("SecWDTracksV0M"), centrality, candidateTracks[iT].pt, candidateTracks[iT].dcaxypv); - } else { // from material - histos.fill(HIST("SecTracks"), nTrackletsColl, candidateTracks[iT].pt, candidateTracks[iT].dcaxypv); - histos.fill(HIST("SecTracksV0M"), centrality, candidateTracks[iT].pt, candidateTracks[iT].dcaxypv); - } - } - if (std::abs(candidateTracks[iT].dcaxypv) > cfgDcaSels->get("dcaxy")) { // TODO: add pt dependent cut - ++nTracks; - } - - if (mcTrack.isPhysicalPrimary()) { // primary - histos.fill(HIST("PrimTracks"), nTrackletsColl, candidateTracks[iT].pt, candidateTracks[iT].dcaxypv); - histos.fill(HIST("PrimTracksV0M"), centrality, candidateTracks[iT].pt, candidateTracks[iT].dcaxypv); - } - - if (std::abs(candidateTracks[iT].dcaxypv) > cfgDcaSels->get("dcaxy")) - continue; - int partType = getPartType(mcTrack.pdgCode()); - if (mcTrack.isPhysicalPrimary()) { // primary - histos.fill(HIST("RecPart"), nTrackletsColl, candidateTracks[iT].pt, partType); - histos.fill(HIST("RecPartV0M"), centrality, candidateTracks[iT].pt, partType); - } - auto genPt = std::hypot(mcTrack.px(), mcTrack.py()); - candidateTracks[iT].pdgcode = mcTrack.pdgCode(); - candidateTracks[iT].genpt = genPt; - candidateTracks[iT].geneta = mcTrack.eta(); - candidateTracks[iT].mcIndex = mcTrack.globalIndex(); - } - } - candidateEvent.nTrkRec = nTracks; - } - - void fillMcGen(aod::McParticles const& mcParticles, aod::McTrackLabels const& /*mcLab*/, uint64_t const& collisionId, float const& centrality) - { - int nParticles = 0; - auto mcParticlesThisCollision = mcParticles.sliceBy(perCollisionMcParts, collisionId); - for (auto const& mcPart : mcParticlesThisCollision) { - auto genEta = mcPart.eta(); - if (std::abs(genEta) > etaMax) { - continue; - } - if (((mcPart.flags() & 0x8) && (doprocessMcRun2)) || (mcPart.flags() & 0x2) || (mcPart.flags() & 0x1)) - continue; - if (!mcPart.isPhysicalPrimary() /* && !mcPart.has_mothers() */) - continue; - auto genPt = std::hypot(mcPart.px(), mcPart.py()); - if (genPt < ptMin || genPt > ptMax) - continue; - CandidateTrack candTrack; - candTrack.genpt = genPt; - candTrack.geneta = mcPart.eta(); - candTrack.pdgcode = mcPart.pdgCode(); - - int partType = getPartType(mcPart.pdgCode()); - if (partType < PartTypes::kOther) { - ++nParticles; - } - histos.fill(HIST("GenPart"), nTrackletsColl, mcPart.pdgCode() > 0 ? genPt : -genPt, partType); - histos.fill(HIST("GenPartV0M"), centrality, mcPart.pdgCode() > 0 ? genPt : -genPt, partType); - - auto it = find_if(candidateTracks.begin(), candidateTracks.end(), [&](CandidateTrack trk) { return trk.mcIndex == mcPart.globalIndex(); }); - if (it != candidateTracks.end()) { - continue; - } else { - candidateTracks.emplace_back(candTrack); - } - } - histos.fill(HIST("RecINELgtZERO"), nParticles); - histos.fill(HIST("GenRecTracks"), nTrackletsColl, candidateEvent.nTrkRec, nParticles); - histos.fill(HIST("GenRecTracklets"), nTrackletsColl, candidateEvent.nTklRec, nParticles); - histos.fill(HIST("GenRecTracksV0M"), centrality, candidateEvent.nTrkRec, nParticles); - histos.fill(HIST("GenRecTrackletsV0M"), centrality, candidateEvent.nTklRec, nParticles); - } - - template - int genMultINELgtZERO(C const& collision, P const& particles) - { - if (std::abs(collision.posZ()) > zVtxMax) - return -1; - - int nParticles = 0; - int partInAcc = 0; - auto particlesThisCollision = particles.sliceBy(perCollisionMcParts, collision.globalIndex()); - for (auto const& particle : particlesThisCollision) { - if (((particle.flags() & 0x8) && (doprocessMcRun2)) || (particle.flags() & 0x2) || (particle.flags() & 0x1)) - continue; - if (!particle.isPhysicalPrimary() /* && !particle.has_mothers() */) - continue; - auto pt = std::hypot(particle.px(), particle.py()); - if (pt < ptMin || pt > ptMax) - continue; - - int partType = getPartType(particle.pdgCode()); - if (partType < PartTypes::kOther) { - if (std::abs(particle.eta()) < etaMax) - ++nParticles; - if (std::abs(particle.eta()) < 1.f) { - ++partInAcc; - } - } - } - if (partInAcc >= 0) - return nParticles; - return -1; - } - - void processRun2(soa::Join const& collisions, TracksFull const& tracks, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, BCsWithRun2Info const&) - { - - for (const auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - if (std::abs(collision.posZ()) > zVtxMax) - continue; - - if (!collision.alias_bit(kINT7)) - continue; - - if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) - continue; - - if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kINELgtZERO))) - continue; - - float v0m = getV0M(bc.globalIndex(), collision.posZ(), fv0as, fv0cs); - float cV0M = Run2V0MInfo.mhMultSelCalib->GetBinContent(Run2V0MInfo.mhMultSelCalib->FindFixBin(v0m)); - - histos.fill(HIST("QA/zVtx"), collision.posZ()); - - fillRecoEvent(collision, tracks, cV0M); - - for (auto const& t : candidateTracks) { - histos.fill(HIST("RecTracks"), nTrackletsColl, t.pt, t.dcaxypv); - histos.fill(HIST("RecTracksV0M"), cV0M, t.pt, t.dcaxypv); - } - } - } - PROCESS_SWITCH(EbyeMult, processRun2, "process (Run 2)", false); - - void processMcRun2(soa::Join const& collisions, aod::McCollisions const& mcCollisions, TracksFull const& tracks, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, BCsWithRun2Info const&) - { - - for (const auto& collision : collisions) { // TODO: fill numerator for trigger efficiency - auto bc = collision.bc_as(); - initCCDB(bc); - - if (std::abs(collision.posZ()) > zVtxMax) - continue; - - if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) - continue; - - if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kINELgtZERO))) - continue; - - float v0m = getV0M(bc.globalIndex(), collision.posZ(), fv0as, fv0cs); - float cV0M = Run2V0MInfo.mhMultSelCalib->GetBinContent(Run2V0MInfo.mhMultSelCalib->FindFixBin(v0m)); - - histos.fill(HIST("QA/zVtx"), collision.posZ()); - - fillMcEvent(collision, tracks, cV0M, mcParticles, mcLab); - fillMcGen(mcParticles, mcLab, collision.mcCollisionId(), cV0M); - } - - // search generated INEL > 0 (one charged particle in |eta| < 1) - for (const auto& mcCollision : mcCollisions) { - int mult = genMultINELgtZERO(mcCollision, mcParticles); - if (mult >= 0) { - histos.fill(HIST("GenINELgtZERO"), mult); - } - } - } - PROCESS_SWITCH(EbyeMult, processMcRun2, "process mc (Run 2)", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGLF/Tasks/Nuspex/hadronnucleicorrelation.cxx b/PWGLF/Tasks/Nuspex/hadronnucleicorrelation.cxx index 334c952a105..fec8025339a 100644 --- a/PWGLF/Tasks/Nuspex/hadronnucleicorrelation.cxx +++ b/PWGLF/Tasks/Nuspex/hadronnucleicorrelation.cxx @@ -13,32 +13,38 @@ /// \author Francesca Ercolessi /// \since 21 April 2024 -#include -#include -#include -#include -#include -#include -#include -#include -#include "TGrid.h" +#include "PWGCF/Femto3D/Core/femto3dPairTask.h" +#include "PWGCF/Femto3D/DataModel/singletrackselector.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Multiplicity.h" #include "CCDB/BasicCCDBManager.h" #include "CCDB/CcdbApi.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" - #include "Framework/ASoA.h" -#include "MathUtils/Utils.h" -#include "Framework/DataTypes.h" -#include "Common/DataModel/Multiplicity.h" #include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/DataTypes.h" #include "Framework/Expressions.h" - +#include "Framework/HistogramRegistry.h" #include "Framework/StaticFor.h" -#include "PWGCF/Femto3D/DataModel/singletrackselector.h" -#include "PWGCF/Femto3D/Core/femto3dPairTask.h" +#include "Framework/runDataProcessing.h" +#include "MathUtils/Utils.h" + +#include "TGrid.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::soa; @@ -52,9 +58,14 @@ struct hadronnucleicorrelation { static constexpr int pdgProton = 2212; static constexpr int pdgDeuteron = 1000010020; + Configurable mode{"mode", 0, "0: antid-antip, 1: d-p, 2: antid-p, 3: d-antip, 4: antip-p, 5: antip-antip, 6: p-p"}; + Configurable doQA{"doQA", true, "save QA histograms"}; Configurable doMCQA{"doMCQA", false, "save MC QA histograms"}; Configurable isMC{"isMC", false, "is MC"}; + Configurable isMCGen{"isMCGen", false, "is isMCGen"}; + Configurable isPrim{"isPrim", true, "is isPrim"}; + Configurable domatterGen{"domatterGen", true, "domatterGen"}; Configurable mcCorrelation{"mcCorrelation", false, "true: build the correlation function only for SE"}; Configurable docorrection{"docorrection", false, "do efficiency correction"}; @@ -86,26 +97,35 @@ struct hadronnucleicorrelation { Configurable rejectionEl{"rejectionEl", true, "use TPC El rejection"}; Configurable max_tpcSharedCls{"max_tpcSharedCls", 0.4, "maximum fraction of TPC shared clasters"}; Configurable min_itsNCls{"min_itsNCls", 0, "minimum allowed number of ITS clasters"}; + Configurable maxmixcollsGen{"maxmixcollsGen", 100, "maxmixcollsGen"}; + Configurable radiusTPC{"radiusTPC", 1.2, "TPC radius to calculate phi_star for"}; + Configurable deta{"deta", 0.01, "minimum allowed defference in eta between two tracks in a pair"}; + Configurable dphi{"dphi", 0.01, "minimum allowed defference in phi_star between two tracks in a pair"}; // Mixing parameters Configurable _vertexNbinsToMix{"vertexNbinsToMix", 10, "Number of vertexZ bins for the mixing"}; Configurable _multNsubBins{"multSubBins", 10, "number of sub-bins to perform the mixing within"}; // pT/A bins - Configurable> pTBins{"pTBins", {0.4f, 0.6f, 0.8f}, "p_{T} bins"}; + Configurable> pTBins{"pTBins", {0.6f, 1.0f, 1.2f, 2.f}, "p_{T} bins"}; ConfigurableAxis AxisNSigma{"AxisNSigma", {35, -7.f, 7.f}, "n#sigma"}; + ConfigurableAxis DeltaPhiAxis = {"DeltaPhiAxis", {46, -1 * o2::constants::math::PIHalf, 3 * o2::constants::math::PIHalf}, "#Delta#phi (rad)"}; using FilteredCollisions = soa::Filtered; - using FilteredTracks = soa::Filtered>; - using FilteredTracksMC = soa::Filtered>; + using SimCollisions = aod::McCollisions; + using SimParticles = aod::McParticles; + using FilteredTracks = soa::Filtered>; // new tables (v3) + using FilteredTracksMC = soa::Filtered>; // new tables (v3) HistogramRegistry registry{"registry"}; HistogramRegistry QA{"QA"}; typedef std::shared_ptr trkType; typedef std::shared_ptr trkTypeMC; + typedef std::shared_ptr partTypeMC; typedef std::shared_ptr colType; + typedef std::shared_ptr MCcolType; // key: int64_t - value: vector of trkType objects std::map> selectedtracks_p; @@ -113,6 +133,12 @@ struct hadronnucleicorrelation { std::map> selectedtracks_antid; std::map> selectedtracks_antip; + // key: int64_t - value: vector of trkType objects + std::map> selectedparticlesMC_d; + std::map> selectedparticlesMC_p; + std::map> selectedparticlesMC_antid; + std::map> selectedparticlesMC_antip; + // key: int64_t - value: vector of trkType objects std::map> selectedtracksMC_d; std::map> selectedtracksMC_p; @@ -125,14 +151,24 @@ struct hadronnucleicorrelation { // key: pair of an integer and a float - value: vector of colType objects // for each key I have a vector of collisions - std::map, std::vector> mixbins_antidantip; + std::map, std::vector> mixbins_antid; + std::map, std::vector> mixbins_d; + std::map, std::vector> mixbins_antip; + std::map, std::vector> mixbins_p; std::map, std::vector> mixbinsPID_antidantip; + std::map> mixbinsMC_antidantip; + std::map> mixbinsMC_dp; + + std::unique_ptr> Pair = std::make_unique>(); + std::unique_ptr> PairMC = std::make_unique>(); - std::vector> hEtaPhi_AntiDeAntiPr_SE; - std::vector> hEtaPhi_AntiDeAntiPr_ME; - std::vector> hCorrEtaPhi_AntiDeAntiPr_SE; - std::vector> hCorrEtaPhi_AntiDeAntiPr_ME; + // Data histograms + std::vector> hEtaPhi_SE; + std::vector> hEtaPhi_ME; + std::vector> hCorrEtaPhi_SE; + std::vector> hCorrEtaPhi_ME; + // MC histograms std::vector> hEtaPhiRec_AntiDeAntiPr_SE; std::vector> hEtaPhiGen_AntiDeAntiPr_SE; std::vector> hEtaPhiRec_AntiDeAntiPr_ME; @@ -141,6 +177,8 @@ struct hadronnucleicorrelation { std::vector> hPIDEtaPhiGen_AntiDeAntiPr_SE; std::vector> hPIDEtaPhiRec_AntiDeAntiPr_ME; std::vector> hPIDEtaPhiGen_AntiDeAntiPr_ME; + std::vector> hEtaPhiGen_AntiPrAntiPr_SE; + std::vector> hEtaPhiGen_AntiPrAntiPr_ME; int nBinspT; TH2F* hEffpTEta_proton; @@ -170,19 +208,20 @@ struct hadronnucleicorrelation { AxisSpec ptBinnedAxis = {pTBins, "#it{p}_{T} of #bar{p} (GeV/c)"}; AxisSpec etaAxis = {100, -1., 1., "#eta"}; - AxisSpec phiAxis = {157, 0., 2 * TMath::Pi(), "#phi (rad)"}; + AxisSpec phiAxis = {157, 0., o2::constants::math::TwoPI, "#phi (rad)"}; AxisSpec pTAxis = {200, -10.f, 10.f, "p_{T} GeV/c"}; AxisSpec pTAxis_small = {100, -5.f, 5.f, "p_{T} GeV/c"}; AxisSpec DeltaEtaAxis = {100, -1.5, 1.5, "#Delta#eta"}; - AxisSpec DeltaPhiAxis = {60, -TMath::Pi() / 2, 1.5 * TMath::Pi(), "#Delta#phi (rad)"}; - registry.add("hNEvents", "hNEvents", {HistType::kTH1D, {{5, 0.f, 5.f}}}); + registry.add("hNEvents", "hNEvents", {HistType::kTH1D, {{7, 0.f, 7.f}}}); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "Selected"); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "events with #bar{d}-#bar{p}"); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "events with d-p"); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(4, "events with #bar{d}"); registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(5, "events with d"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(6, "events with #bar{p}"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(7, "events with p"); nBinspT = pTBins.value.size() - 1; @@ -190,16 +229,10 @@ struct hadronnucleicorrelation { for (int i = 0; i < nBinspT; i++) { auto htempSERec_AntiDeAntiPr = registry.add(Form("hEtaPhiRec_AntiDeAntiPr_SE_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("Rec #Delta#eta#Delta#phi (%.1f(Form("hEtaPhiGen_AntiDeAntiPr_SE_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), - Form("Gen #Delta#eta#Delta#phi (%.1f(Form("hEtaPhiRec_AntiDeAntiPr_ME_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("Rec #Delta#eta#Delta#phi (%.1f(Form("hEtaPhiGen_AntiDeAntiPr_ME_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), - Form("Gen #Delta#eta#Delta#phi (%.1f(Form("hPIDEtaPhiRec_AntiDeAntiPr_SE_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("Rec #Delta#eta#Delta#phi (%.1f(Form("hEtaPhiGen_AntiDeAntiPr_SE_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), + Form("Gen #Delta#eta#Delta#phi (%.1f(Form("hEtaPhiGen_AntiDeAntiPr_ME_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), + Form("Gen #Delta#eta#Delta#phi (%.1f(Form("hEtaPhiGen_AntiPrAntiPr_SE_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), + Form("Gen #Delta#eta#Delta#phi (%.1f(Form("hEtaPhiGen_AntiPrAntiPr_ME_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), + Form("Gen #Delta#eta#Delta#phi (%.1f(Form("hEtaPhi_AntiDeAntiPr_SE_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("Raw #Delta#eta#Delta#phi (%.1f(Form("hEtaPhi_AntiDeAntiPr_ME_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("Raw #Delta#eta#Delta#phi (%.1f(Form("hCorrEtaPhi_AntiDeAntiPr_SE_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("#Delta#eta#Delta#phi (%.1f(Form("hCorrEtaPhi_AntiDeAntiPr_ME_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("#Delta#eta#Delta#phi (%.1f(Form("hEtaPhi_%s_SE_pt%02.0f%02.0f", name.Data(), pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("Raw #Delta#eta#Delta#phi (%.1f(Form("hEtaPhi_%s_ME_pt%02.0f%02.0f", name.Data(), pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("Raw #Delta#eta#Delta#phi (%.1f(Form("hCorrEtaPhi_%s_SE_pt%02.0f%02.0f", name.Data(), pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("#Delta#eta#Delta#phi (%.1f(Form("hCorrEtaPhi_%s_ME_pt%02.0f%02.0f", name.Data(), pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), Form("#Delta#eta#Delta#phi (%.1f(HIST("Generated/hNEventsMC"))->GetXaxis()->SetBinLabel(1, "All"); + + registry.add("Generated/hQAProtons", "hQAProtons", {HistType::kTH1D, {{5, 0.f, 5.f}}}); + registry.get(HIST("Generated/hQAProtons"))->GetXaxis()->SetBinLabel(1, "All"); + registry.get(HIST("Generated/hQAProtons"))->GetXaxis()->SetBinLabel(2, "PhysicalPrimary"); + registry.get(HIST("Generated/hQAProtons"))->GetXaxis()->SetBinLabel(3, "|#eta|<0.8"); + registry.get(HIST("Generated/hQAProtons"))->GetXaxis()->SetBinLabel(4, "no daughters"); + registry.get(HIST("Generated/hQAProtons"))->GetXaxis()->SetBinLabel(5, "d daughter"); + + registry.add("Generated/hQADeuterons", "hQADeuterons", {HistType::kTH1D, {{3, 0.f, 3.f}}}); + registry.get(HIST("Generated/hQADeuterons"))->GetXaxis()->SetBinLabel(1, "All"); + registry.get(HIST("Generated/hQADeuterons"))->GetXaxis()->SetBinLabel(2, "PhysicalPrimary"); + registry.get(HIST("Generated/hQADeuterons"))->GetXaxis()->SetBinLabel(3, "|#eta|<0.8"); + + registry.add("Generated/hDeuteronsVsPt", "hDeuteronsVsPt; p_{T} (GeV/c);", {HistType::kTH1D, {{100, 0.f, 10.f}}}); + registry.add("Generated/hAntiDeuteronsVsPt", "hAntiDeuteronsVsPt; p_{T} (GeV/c);", {HistType::kTH1D, {{100, 0.f, 10.f}}}); + } } // Filters @@ -342,8 +457,8 @@ struct hadronnucleicorrelation { o2::aod::singletrackselector::unPack(o2::aod::singletrackselector::storedTpcChi2NCl) <= max_chi2_TPC && o2::aod::singletrackselector::unPack(o2::aod::singletrackselector::storedTpcCrossedRowsOverFindableCls) >= min_TPC_nCrossedRowsOverFindableCls && o2::aod::singletrackselector::unPack(o2::aod::singletrackselector::storedItsChi2NCl) <= max_chi2_ITS && - nabs(o2::aod::singletrackselector::unPack(o2::aod::singletrackselector::storedDcaXY_v2)) <= max_dcaxy && // For now no filtering on the DCAxy or DCAz (casting not supported) - nabs(o2::aod::singletrackselector::unPack(o2::aod::singletrackselector::storedDcaXY_v2)) <= max_dcaz && // For now no filtering on the DCAxy or DCAz (casting not supported) + nabs(o2::aod::singletrackselector::unPack(o2::aod::singletrackselector::storedDcaXY)) <= max_dcaxy && + nabs(o2::aod::singletrackselector::unPack(o2::aod::singletrackselector::storedDcaXY)) <= max_dcaz && nabs(o2::aod::singletrackselector::eta) <= etacut; template @@ -457,86 +572,196 @@ struct hadronnucleicorrelation { { bool passcut = true; // pt-dependent selection - if (TMath::Abs(track.dcaXY()) > (par0 + par1 / track.pt())) + if (std::abs(track.dcaXY()) > (par0 + par1 / track.pt())) passcut = false; - if (TMath::Abs(track.dcaZ()) > (par0 + par1 / track.pt())) + if (std::abs(track.dcaZ()) > (par0 + par1 / track.pt())) passcut = false; return passcut; } - template - void mixTracks(Type const& tracks1, Type const& tracks2, bool isMCPID) + template + void mixTracks(Type const& tracks1, Type const& tracks2, bool isIdentical) { // last value: 0 -- SE; 1 -- ME - for (auto it1 : tracks1) { - for (auto it2 : tracks2) { + for (auto const& it1 : tracks1) { + for (auto const& it2 : tracks2) { + + Pair->SetPair(it1, it2); + Pair->SetIdentical(isIdentical); + + // if Identical (pp and antip-antip) + if (isIdentical && Pair->IsClosePair(deta, dphi, radiusTPC)) { + QA.fill(HIST("QA/hdetadphistar"), Pair->GetPhiStarDiff(radiusTPC), Pair->GetEtaDiff()); + continue; + } + + // Calculate Delta-eta Delta-phi (reco) + float deltaEta = it2->eta() - it1->eta(); + float deltaPhi = it2->phi() - it1->phi(); + deltaPhi = RecoDecay::constrainAngle(deltaPhi, -1 * o2::constants::math::PIHalf); + + for (int k = 0; k < nBinspT; k++) { + + if (it1->pt() >= pTBins.value.at(k) && it1->pt() < pTBins.value.at(k + 1)) { + + float corr1 = 1, corr2 = 1; + + if (docorrection) { // Apply corrections + switch (mode) { + case 0: + corr1 = hEffpTEta_antideuteron->Interpolate(it1->pt(), it1->eta()); + corr2 = hEffpTEta_antiproton->Interpolate(it2->pt(), it2->eta()); + break; + case 1: + corr1 = hEffpTEta_deuteron->Interpolate(it1->pt(), it1->eta()); + corr2 = hEffpTEta_proton->Interpolate(it2->pt(), it2->eta()); + break; + case 2: + corr1 = hEffpTEta_antideuteron->Interpolate(it1->pt(), it1->eta()); + corr2 = hEffpTEta_proton->Interpolate(it2->pt(), it2->eta()); + break; + case 3: + corr1 = hEffpTEta_deuteron->Interpolate(it1->pt(), it1->eta()); + corr2 = hEffpTEta_antiproton->Interpolate(it2->pt(), it2->eta()); + break; + case 4: + corr1 = hEffpTEta_antiproton->Interpolate(it1->pt(), it1->eta()); + corr2 = hEffpTEta_proton->Interpolate(it2->pt(), it2->eta()); + break; + case 5: + corr1 = hEffpTEta_antiproton->Interpolate(it1->pt(), it1->eta()); + corr2 = hEffpTEta_antiproton->Interpolate(it2->pt(), it2->eta()); + break; + case 6: + corr1 = hEffpTEta_proton->Interpolate(it1->pt(), it1->eta()); + corr2 = hEffpTEta_proton->Interpolate(it2->pt(), it2->eta()); + break; + } + } + + if (ME) { + hEtaPhi_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); + hCorrEtaPhi_ME[k]->Fill(deltaEta, deltaPhi, it2->pt(), 1. / (corr1 * corr2)); + } else { + hEtaPhi_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); + hCorrEtaPhi_SE[k]->Fill(deltaEta, deltaPhi, it2->pt(), 1. / (corr1 * corr2)); + } // SE + } // pT condition + } // nBinspT loop + + Pair->ResetPair(); + + } // tracks 2 + } // tracks 1 + } + + template + void mixTracksMC(Type const& tracks1, Type const& tracks2, bool isIdentical, bool isMCPID) + { // last value: 0 -- SE; 1 -- ME + for (auto const& it1 : tracks1) { + for (auto const& it2 : tracks2) { + + PairMC->SetPair(it1, it2); + PairMC->SetIdentical(isIdentical); + + // if Identical (pp and antip-antip) + if (isIdentical && PairMC->IsClosePair(deta, dphi, radiusTPC)) { + QA.fill(HIST("QA/hdetadphistar"), PairMC->GetPhiStarDiff(radiusTPC), PairMC->GetEtaDiff()); + continue; + } // Calculate Delta-eta Delta-phi (reco) float deltaEta = it2->eta() - it1->eta(); float deltaPhi = it2->phi() - it1->phi(); - deltaPhi = getDeltaPhi(deltaPhi); + deltaPhi = RecoDecay::constrainAngle(deltaPhi, -1 * o2::constants::math::PIHalf); // Calculate Delta-eta Delta-phi (gen) float deltaEtaGen = -999.; float deltaPhiGen = -999.; - if constexpr (doMC) { - deltaEtaGen = it2->eta_MC() - it1->eta_MC(); - deltaPhiGen = it2->phi_MC() - it1->phi_MC(); - deltaPhiGen = getDeltaPhi(deltaPhiGen); - } - - float antipcorr = 1, antidcorr = 1; + deltaEtaGen = it2->eta_MC() - it1->eta_MC(); + deltaPhiGen = it2->phi_MC() - it1->phi_MC(); + deltaPhiGen = RecoDecay::constrainAngle(deltaPhiGen, -1 * o2::constants::math::PIHalf); for (int k = 0; k < nBinspT; k++) { if (it1->pt() >= pTBins.value.at(k) && it1->pt() < pTBins.value.at(k + 1)) { - if (docorrection) { // Apply corrections - antipcorr = hEffpTEta_antiproton->Interpolate(it2->pt(), it2->eta()); - antidcorr = hEffpTEta_antideuteron->Interpolate(it1->pt(), it1->eta()); - } - if (ME) { - if constexpr (!doMC) { // Data - hEtaPhi_AntiDeAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hCorrEtaPhi_AntiDeAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt(), 1. / (antipcorr * antidcorr)); - } else { // MC - if (isMCPID) { - hPIDEtaPhiRec_AntiDeAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hPIDEtaPhiGen_AntiDeAntiPr_ME[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); - } else { - hEtaPhiRec_AntiDeAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hEtaPhiGen_AntiDeAntiPr_ME[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); - } + if (isMCPID) { + hPIDEtaPhiRec_AntiDeAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); + hPIDEtaPhiGen_AntiDeAntiPr_ME[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); + } else { + hEtaPhiRec_AntiDeAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); + hEtaPhiGen_AntiDeAntiPr_ME[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); } } else { - if constexpr (!doMC) { // Data - hEtaPhi_AntiDeAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hCorrEtaPhi_AntiDeAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt(), 1. / (antipcorr * antidcorr)); - } else { // MC - if (isMCPID) { - hPIDEtaPhiRec_AntiDeAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hPIDEtaPhiGen_AntiDeAntiPr_SE[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); - } else { - hEtaPhiRec_AntiDeAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hEtaPhiGen_AntiDeAntiPr_SE[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); - } + if (isMCPID) { + hPIDEtaPhiRec_AntiDeAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); + hPIDEtaPhiGen_AntiDeAntiPr_SE[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); + } else { + hEtaPhiRec_AntiDeAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); + hEtaPhiGen_AntiDeAntiPr_SE[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); } } // SE } // pT condition } // nBinspT loop + + Pair->ResetPair(); + } // tracks 2 } // tracks 1 } - float getDeltaPhi(float deltaPhi) + template + void mixMCParticles(Type const& particles1, Type const& particles2) { - if (deltaPhi < -TMath::Pi() / 2) { - return deltaPhi += 2 * TMath::Pi(); - } else if (deltaPhi >= 3 * TMath::Pi() / 2) { - return deltaPhi -= 2 * TMath::Pi(); + for (auto const& it1 : particles1) { + for (auto const& it2 : particles2) { + // Calculate Delta-eta Delta-phi (gen) + float deltaEtaGen = it2->eta() - it1->eta(); + float deltaPhiGen = RecoDecay::constrainAngle(it2->phi() - it1->phi(), -1 * o2::constants::math::PIHalf); + + // Loop over pT bins + for (int k = 0; k < nBinspT; k++) { + if (it1->pt() >= pTBins.value.at(k) && it1->pt() < pTBins.value.at(k + 1)) { + // Use correct histogram based on ME flag + if constexpr (ME) { + hEtaPhiGen_AntiDeAntiPr_ME[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); + } else { + hEtaPhiGen_AntiDeAntiPr_SE[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); + } + } + } + } + } + } + + template + void mixMCParticlesIdentical(Type const& particles1, Type const& particles2) + { + for (auto const& it1 : particles1) { + for (auto const& it2 : particles2) { + // Calculate Delta-eta Delta-phi (gen) + float deltaEtaGen = it2->eta() - it1->eta(); + float deltaPhiGen = RecoDecay::constrainAngle(it2->phi() - it1->phi(), -1 * o2::constants::math::PIHalf); + + if (!ME && std::abs(deltaPhiGen) < 0.001 && std::abs(deltaEtaGen) < 0.001) { + continue; + } + + // Loop over pT bins + for (int k = 0; k < nBinspT; k++) { + if (it1->pt() >= pTBins.value.at(k) && it1->pt() < pTBins.value.at(k + 1)) { + // Use correct histogram based on ME flag + if constexpr (ME) { + hEtaPhiGen_AntiPrAntiPr_ME[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); + } else { + hEtaPhiGen_AntiPrAntiPr_SE[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); + } + } + } + } } - return deltaPhi; } void GetCorrection(o2::framework::Service const& ccdbObj, TString filepath, TString histname) @@ -582,11 +807,22 @@ struct hadronnucleicorrelation { continue; if (track.itsNCls() < min_itsNCls) continue; + + if (IsProton(track, +1)) + registry.fill(HIST("hPrDCAxy"), track.dcaXY(), track.pt()); + if (IsProton(track, -1)) + registry.fill(HIST("hAntiPrDCAxy"), track.dcaXY(), track.pt()); + if (IsDeuteron(track, +1)) + registry.fill(HIST("hDeDCAxy"), track.dcaXY(), track.pt()); + if (IsDeuteron(track, -1)) + registry.fill(HIST("hAntiDeDCAxy"), track.dcaXY(), track.pt()); + if (!applyDCAcut(track)) continue; if (doQA) { QA.fill(HIST("QA/hTPCnClusters"), track.tpcNClsFound()); + QA.fill(HIST("QA/hTPCSharedClusters"), track.tpcFractionSharedCls()); QA.fill(HIST("QA/hTPCchi2"), track.tpcChi2NCl()); QA.fill(HIST("QA/hTPCcrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); QA.fill(HIST("QA/hITSchi2"), track.itsChi2NCl()); @@ -686,14 +922,121 @@ struct hadronnucleicorrelation { if (selectedtracks_antid.find(collision.globalIndex()) != selectedtracks_antid.end()) { registry.fill(HIST("hNEvents"), 3.5); + mixbins_antid[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); + } + if (selectedtracks_d.find(collision.globalIndex()) != selectedtracks_d.end()) { + registry.fill(HIST("hNEvents"), 4.5); + mixbins_d[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); + } + if (selectedtracks_antip.find(collision.globalIndex()) != selectedtracks_antip.end()) { + registry.fill(HIST("hNEvents"), 5.5); + mixbins_antip[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); + } + if (selectedtracks_p.find(collision.globalIndex()) != selectedtracks_p.end()) { + registry.fill(HIST("hNEvents"), 6.5); + mixbins_p[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); + } + + Pair->SetMagField1(collision.magField()); + Pair->SetMagField2(collision.magField()); + } + + if (mode == 0 && !mixbins_antid.empty()) { + + for (auto i = mixbins_antid.begin(); i != mixbins_antid.end(); i++) { // iterating over all vertex&mult bins + + std::vector value = i->second; + int EvPerBin = value.size(); // number of collisions in each vertex&mult bin + + for (int indx1 = 0; indx1 < EvPerBin; indx1++) { // loop over all the events in each vertex&mult bin + + auto col1 = value[indx1]; + + if (selectedtracks_antip.find(col1->index()) != selectedtracks_antip.end()) { + mixTracks<0>(selectedtracks_antid[col1->index()], selectedtracks_antip[col1->index()], 0); // mixing SE + } + + for (int indx2 = 0; indx2 < EvPerBin; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin + + auto col2 = value[indx2]; + + if (col1 == col2) { + continue; + } + + if (selectedtracks_antip.find(col2->index()) != selectedtracks_antip.end()) { + mixTracks<1>(selectedtracks_antid[col1->index()], selectedtracks_antip[col2->index()], 0); // mixing ME + } + } + } + } + } + + if (mode == 1 && !mixbins_d.empty()) { + + for (auto i = mixbins_d.begin(); i != mixbins_d.end(); i++) { // iterating over all vertex&mult bins + + std::vector value = i->second; + int EvPerBin = value.size(); // number of collisions in each vertex&mult bin + + for (int indx1 = 0; indx1 < EvPerBin; indx1++) { // loop over all the events in each vertex&mult bin + + auto col1 = value[indx1]; + + if (selectedtracks_p.find(col1->index()) != selectedtracks_p.end()) { + mixTracks<0>(selectedtracks_d[col1->index()], selectedtracks_p[col1->index()], 0); // mixing SE + } + + for (int indx2 = 0; indx2 < EvPerBin; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin + + auto col2 = value[indx2]; + + if (col1 == col2) { + continue; + } + + if (selectedtracks_p.find(col2->index()) != selectedtracks_p.end()) { + mixTracks<1>(selectedtracks_d[col1->index()], selectedtracks_p[col2->index()], 0); // mixing ME + } + } + } + } + } + + if (mode == 2 && !mixbins_antid.empty()) { + + for (auto i = mixbins_antid.begin(); i != mixbins_antid.end(); i++) { // iterating over all vertex&mult bins + + std::vector value = i->second; + int EvPerBin = value.size(); // number of collisions in each vertex&mult bin + + for (int indx1 = 0; indx1 < EvPerBin; indx1++) { // loop over all the events in each vertex&mult bin - mixbins_antidantip[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); + auto col1 = value[indx1]; + + if (selectedtracks_p.find(col1->index()) != selectedtracks_p.end()) { + mixTracks<0>(selectedtracks_antid[col1->index()], selectedtracks_p[col1->index()], 0); // mixing SE + } + + for (int indx2 = 0; indx2 < EvPerBin; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin + + auto col2 = value[indx2]; + + if (col1 == col2) { + continue; + } + + if (selectedtracks_p.find(col2->index()) != selectedtracks_p.end()) { + mixTracks<1>(selectedtracks_antid[col1->index()], selectedtracks_p[col2->index()], 0); // mixing ME + } + } + } } } - if (!mixbins_antidantip.empty()) { + if (mode == 3 && !mixbins_d.empty()) { - for (auto i = mixbins_antidantip.begin(); i != mixbins_antidantip.end(); i++) { // iterating over all vertex&mult bins + for (auto i = mixbins_d.begin(); i != mixbins_d.end(); i++) { // iterating over all vertex&mult bins std::vector value = i->second; int EvPerBin = value.size(); // number of collisions in each vertex&mult bin @@ -703,7 +1046,7 @@ struct hadronnucleicorrelation { auto col1 = value[indx1]; if (selectedtracks_antip.find(col1->index()) != selectedtracks_antip.end()) { - mixTracks<0, 0>(selectedtracks_antid[col1->index()], selectedtracks_antip[col1->index()], 0); // mixing SE + mixTracks<0>(selectedtracks_d[col1->index()], selectedtracks_antip[col1->index()], 0); // mixing SE } for (int indx2 = 0; indx2 < EvPerBin; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin @@ -715,7 +1058,100 @@ struct hadronnucleicorrelation { } if (selectedtracks_antip.find(col2->index()) != selectedtracks_antip.end()) { - mixTracks<1, 0>(selectedtracks_antid[col1->index()], selectedtracks_antip[col2->index()], 0); // mixing ME + mixTracks<1>(selectedtracks_d[col1->index()], selectedtracks_antip[col2->index()], 0); // mixing ME + } + } + } + } + } + + if (mode == 4 && !mixbins_antip.empty()) { + + for (auto i = mixbins_antip.begin(); i != mixbins_antip.end(); i++) { // iterating over all vertex&mult bins + + std::vector value = i->second; + int EvPerBin = value.size(); // number of collisions in each vertex&mult bin + + for (int indx1 = 0; indx1 < EvPerBin; indx1++) { // loop over all the events in each vertex&mult bin + + auto col1 = value[indx1]; + + if (selectedtracks_p.find(col1->index()) != selectedtracks_p.end()) { + mixTracks<0>(selectedtracks_antip[col1->index()], selectedtracks_p[col1->index()], 0); // mixing SE + } + + for (int indx2 = 0; indx2 < EvPerBin; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin + + auto col2 = value[indx2]; + + if (col1 == col2) { + continue; + } + + if (selectedtracks_p.find(col2->index()) != selectedtracks_p.end()) { + mixTracks<1>(selectedtracks_antip[col1->index()], selectedtracks_p[col2->index()], 0); // mixing ME + } + } + } + } + } + + if (mode == 5 && !mixbins_antip.empty()) { + + for (auto i = mixbins_antip.begin(); i != mixbins_antip.end(); i++) { // iterating over all vertex&mult bins + + std::vector value = i->second; + int EvPerBin = value.size(); // number of collisions in each vertex&mult bin + + for (int indx1 = 0; indx1 < EvPerBin; indx1++) { // loop over all the events in each vertex&mult bin + + auto col1 = value[indx1]; + + if (selectedtracks_antip.find(col1->index()) != selectedtracks_antip.end()) { + mixTracks<0>(selectedtracks_antip[col1->index()], selectedtracks_antip[col1->index()], 1); // mixing SE + } + + for (int indx2 = 0; indx2 < EvPerBin; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin + + auto col2 = value[indx2]; + + if (col1 == col2) { + continue; + } + + if (selectedtracks_antip.find(col2->index()) != selectedtracks_antip.end()) { + mixTracks<1>(selectedtracks_antip[col1->index()], selectedtracks_antip[col2->index()], 1); // mixing ME + } + } + } + } + } + + if (mode == 6 && !mixbins_p.empty()) { + + for (auto i = mixbins_p.begin(); i != mixbins_p.end(); i++) { // iterating over all vertex&mult bins + + std::vector value = i->second; + int EvPerBin = value.size(); // number of collisions in each vertex&mult bin + + for (int indx1 = 0; indx1 < EvPerBin; indx1++) { // loop over all the events in each vertex&mult bin + + auto col1 = value[indx1]; + + if (selectedtracks_p.find(col1->index()) != selectedtracks_p.end()) { + mixTracks<0>(selectedtracks_p[col1->index()], selectedtracks_p[col1->index()], 1); // mixing SE + } + + for (int indx2 = 0; indx2 < EvPerBin; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin + + auto col2 = value[indx2]; + + if (col1 == col2) { + continue; + } + + if (selectedtracks_p.find(col2->index()) != selectedtracks_p.end()) { + mixTracks<1>(selectedtracks_p[col1->index()], selectedtracks_p[col2->index()], 1); // mixing ME } } } @@ -739,10 +1175,25 @@ struct hadronnucleicorrelation { (i->second).clear(); selectedtracks_d.clear(); - for (auto& pair : mixbins_antidantip) { + for (auto& pair : mixbins_antid) { + pair.second.clear(); // Clear the vector associated with the key + } + mixbins_antid.clear(); // Then clear the map itself + + for (auto& pair : mixbins_d) { + pair.second.clear(); // Clear the vector associated with the key + } + mixbins_d.clear(); // Then clear the map itself + + for (auto& pair : mixbins_antip) { + pair.second.clear(); // Clear the vector associated with the key + } + mixbins_antip.clear(); // Then clear the map itself + + for (auto& pair : mixbins_p) { pair.second.clear(); // Clear the vector associated with the key } - mixbins_antidantip.clear(); // Then clear the map itself + mixbins_p.clear(); // Then clear the map itself } PROCESS_SWITCH(hadronnucleicorrelation, processData, "processData", true); @@ -756,6 +1207,44 @@ struct hadronnucleicorrelation { continue; if (track.itsNCls() < min_itsNCls) continue; + + if (IsProton(track, +1) && track.pdgCode() == pdgProton) { + registry.fill(HIST("hPrDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 0) + registry.fill(HIST("hPrimPrDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 1) + registry.fill(HIST("hSecWeakPrDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 2) + registry.fill(HIST("hSecMatPrDCAxy"), track.dcaXY(), track.pt()); + } + if (IsProton(track, -1) && track.pdgCode() == -pdgProton) { + registry.fill(HIST("hAntiPrDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 0) + registry.fill(HIST("hPrimAntiPrDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 1) + registry.fill(HIST("hSecWeakAntiPrDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 2) + registry.fill(HIST("hSecMatAntiPrDCAxy"), track.dcaXY(), track.pt()); + } + if (IsDeuteron(track, +1) && track.pdgCode() == pdgDeuteron) { + registry.fill(HIST("hDeDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 0) + registry.fill(HIST("hPrimDeDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 1) + registry.fill(HIST("hSecWeakDeDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 2) + registry.fill(HIST("hSecMatDeDCAxy"), track.dcaXY(), track.pt()); + } + if (IsDeuteron(track, -1) && track.pdgCode() == -pdgDeuteron) { + registry.fill(HIST("hAntiDeDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 0) + registry.fill(HIST("hPrimAntiDeDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 1) + registry.fill(HIST("hSecWeakAntiDeDCAxy"), track.dcaXY(), track.pt()); + if (track.origin() == 2) + registry.fill(HIST("hSecMatAntiDeDCAxy"), track.dcaXY(), track.pt()); + } + if (!applyDCAcut(track)) continue; @@ -765,6 +1254,7 @@ struct hadronnucleicorrelation { if (doQA) { QA.fill(HIST("QA/hTPCnClusters"), track.tpcNClsFound()); + QA.fill(HIST("QA/hTPCSharedClusters"), track.tpcFractionSharedCls()); QA.fill(HIST("QA/hTPCchi2"), track.tpcChi2NCl()); QA.fill(HIST("QA/hTPCcrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); QA.fill(HIST("QA/hITSchi2"), track.itsChi2NCl()); @@ -1115,17 +1605,20 @@ struct hadronnucleicorrelation { int centBinToMix = std::floor(collision.multPerc() / (100.0 / _multNsubBins)); if (selectedtracksMC_antid.find(collision.globalIndex()) != selectedtracksMC_antid.end()) { - mixbins_antidantip[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); + mixbins_antid[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); } if (selectedtracksPIDMC_antid.find(collision.globalIndex()) != selectedtracksPIDMC_antid.end()) { mixbinsPID_antidantip[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); } + + PairMC->SetMagField1(collision.magField()); + PairMC->SetMagField2(collision.magField()); } // coll - if (!mixbins_antidantip.empty()) { + if (!mixbins_antid.empty()) { - for (auto i = mixbins_antidantip.begin(); i != mixbins_antidantip.end(); i++) { // iterating over all vertex&mult bins + for (auto i = mixbins_antid.begin(); i != mixbins_antid.end(); i++) { // iterating over all vertex&mult bins std::vector value = i->second; int EvPerBin = value.size(); // number of collisions in each vertex&mult bin @@ -1135,7 +1628,7 @@ struct hadronnucleicorrelation { auto col1 = value[indx1]; if (selectedtracksMC_antip.find(col1->index()) != selectedtracksMC_antip.end()) { - mixTracks<0, 1>(selectedtracksMC_antid[col1->index()], selectedtracksMC_antip[col1->index()], 0); // mixing SE + mixTracksMC<0>(selectedtracksMC_antid[col1->index()], selectedtracksMC_antip[col1->index()], 0, 0); // mixing SE } for (int indx2 = indx1 + 1; indx2 < EvPerBin; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin @@ -1147,7 +1640,7 @@ struct hadronnucleicorrelation { } if (selectedtracksMC_antip.find(col2->index()) != selectedtracksMC_antip.end()) { - mixTracks<1, 1>(selectedtracksMC_antid[col1->index()], selectedtracksMC_antip[col2->index()], 0); // mixing ME + mixTracksMC<1>(selectedtracksMC_antid[col1->index()], selectedtracksMC_antip[col2->index()], 0, 0); // mixing ME } } } @@ -1166,7 +1659,7 @@ struct hadronnucleicorrelation { auto col1 = value[indx1]; if (selectedtracksPIDMC_antip.find(col1->index()) != selectedtracksPIDMC_antip.end()) { - mixTracks<0, 1>(selectedtracksPIDMC_antid[col1->index()], selectedtracksPIDMC_antip[col1->index()], 1); // mixing SE + mixTracksMC<0>(selectedtracksPIDMC_antid[col1->index()], selectedtracksPIDMC_antip[col1->index()], 0, 1); // mixing SE } for (int indx2 = indx1 + 1; indx2 < EvPerBin; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin @@ -1178,7 +1671,7 @@ struct hadronnucleicorrelation { } if (selectedtracksPIDMC_antip.find(col2->index()) != selectedtracksPIDMC_antip.end()) { - mixTracks<1, 1>(selectedtracksPIDMC_antid[col1->index()], selectedtracksPIDMC_antip[col2->index()], 1); // mixing ME + mixTracksMC<1>(selectedtracksPIDMC_antid[col1->index()], selectedtracksPIDMC_antip[col2->index()], 0, 1); // mixing ME } } } @@ -1223,12 +1716,209 @@ struct hadronnucleicorrelation { } mixbinsPID_antidantip.clear(); // clear the map - for (auto& pair : mixbins_antidantip) { + for (auto& pair : mixbins_antid) { pair.second.clear(); // clear the vector associated with the key } - mixbins_antidantip.clear(); // clear the map + mixbins_antid.clear(); // clear the map } PROCESS_SWITCH(hadronnucleicorrelation, processMC, "processMC", false); + + void processGen(SimCollisions const& mcCollisions, + SimParticles const& mcParticles) + { + for (auto particle : mcParticles) { + + if (particle.pdgCode() == pdgProton) { + registry.fill(HIST("Generated/hQAProtons"), 0.5); + } + if (particle.pdgCode() == pdgDeuteron) { + registry.fill(HIST("Generated/hQADeuterons"), 0.5); + } + + if (isPrim && !particle.isPhysicalPrimary()) { + continue; + } + if (particle.pdgCode() == pdgProton) { + registry.fill(HIST("Generated/hQAProtons"), 1.5); + } + if (particle.pdgCode() == pdgDeuteron) { + registry.fill(HIST("Generated/hQADeuterons"), 1.5); + } + + if (particle.pdgCode() == pdgDeuteron && std::abs(particle.y()) < 0.5) { + registry.fill(HIST("Generated/hDeuteronsVsPt"), particle.pt()); + } + if (particle.pdgCode() == -pdgDeuteron && std::abs(particle.y()) < 0.5) { + registry.fill(HIST("Generated/hAntiDeuteronsVsPt"), particle.pt()); + } + + if (std::abs(particle.eta()) > etacut) { + continue; + } + if (particle.pdgCode() == pdgProton) { + registry.fill(HIST("Generated/hQAProtons"), 2.5); + } + if (particle.pdgCode() == pdgDeuteron) { + registry.fill(HIST("Generated/hQADeuterons"), 2.5); + } + + if (particle.pdgCode() == pdgDeuteron) { + selectedparticlesMC_d[particle.mcCollisionId()].push_back(std::make_shared(particle)); + } + if (particle.pdgCode() == -pdgDeuteron) { + selectedparticlesMC_antid[particle.mcCollisionId()].push_back(std::make_shared(particle)); + } + if (particle.pdgCode() == pdgProton) { + if (!particle.has_daughters()) { + selectedparticlesMC_p[particle.mcCollisionId()].push_back(std::make_shared(particle)); + registry.fill(HIST("Generated/hQAProtons"), 3.5); + } else { + bool isd = false; + for (auto& dau : particle.daughters_as()) { + if (dau.pdgCode() == pdgDeuteron) { + isd = true; + } + } + if (isd) { + registry.fill(HIST("Generated/hQAProtons"), 4.5); + } + } + } + if (particle.pdgCode() == -pdgProton) { + if (!particle.has_daughters()) { + selectedparticlesMC_antip[particle.mcCollisionId()].push_back(std::make_shared(particle)); + } + } + } + + for (auto collision1 : mcCollisions) { // loop on collisions + + registry.fill(HIST("Generated/hNEventsMC"), 0.5); + + // anti-d - anti-p correlation + if (selectedparticlesMC_antid.find(collision1.globalIndex()) != selectedparticlesMC_antid.end()) { + if (selectedparticlesMC_antip.find(collision1.globalIndex()) != selectedparticlesMC_antip.end()) { + mixMCParticles<0>(selectedparticlesMC_antid[collision1.globalIndex()], selectedparticlesMC_antip[collision1.globalIndex()]); // mixing SE + } + + int stop1 = 0; + + for (auto collision2 : mcCollisions) { // nested loop on collisions + + if (collision1.globalIndex() == collision2.globalIndex()) { + continue; + } + + if (stop1 > maxmixcollsGen) { + break; + } + + if (selectedparticlesMC_antip.find(collision2.globalIndex()) != selectedparticlesMC_antip.end()) { + mixMCParticles<1>(selectedparticlesMC_antid[collision1.globalIndex()], selectedparticlesMC_antip[collision2.globalIndex()]); // mixing ME + } + + stop1++; + } + } + + // d - p correlation + if (domatterGen) { + if (selectedparticlesMC_d.find(collision1.globalIndex()) != selectedparticlesMC_d.end()) { + if (selectedparticlesMC_p.find(collision1.globalIndex()) != selectedparticlesMC_p.end()) { + mixMCParticles<0>(selectedparticlesMC_d[collision1.globalIndex()], selectedparticlesMC_p[collision1.globalIndex()]); // mixing SE + } + + int stop2 = 0; + + for (auto collision2 : mcCollisions) { // nested loop on collisions + + if (collision1.globalIndex() == collision2.globalIndex()) { + continue; + } + + if (stop2 > maxmixcollsGen) { + break; + } + + if (selectedparticlesMC_p.find(collision2.globalIndex()) != selectedparticlesMC_p.end()) { + mixMCParticles<1>(selectedparticlesMC_d[collision1.globalIndex()], selectedparticlesMC_p[collision2.globalIndex()]); // mixing ME + } + + stop2++; + } + } + } + + // anti-p - anti-p correlation + if (selectedparticlesMC_antip.find(collision1.globalIndex()) != selectedparticlesMC_antip.end()) { + + mixMCParticlesIdentical<0>(selectedparticlesMC_antip[collision1.globalIndex()], selectedparticlesMC_antip[collision1.globalIndex()]); // mixing SE + + int stop3 = 0; + + for (auto collision2 : mcCollisions) { // nested loop on collisions + + if (collision1.globalIndex() == collision2.globalIndex()) { + continue; + } + + if (stop3 > maxmixcollsGen) { + break; + } + + if (selectedparticlesMC_antip.find(collision2.globalIndex()) != selectedparticlesMC_antip.end()) { + mixMCParticlesIdentical<1>(selectedparticlesMC_antip[collision1.globalIndex()], selectedparticlesMC_antip[collision2.globalIndex()]); // mixing ME + } + + stop3++; + } + } + // p - p correlation + if (domatterGen) { + if (selectedparticlesMC_p.find(collision1.globalIndex()) != selectedparticlesMC_p.end()) { + + mixMCParticlesIdentical<0>(selectedparticlesMC_p[collision1.globalIndex()], selectedparticlesMC_p[collision1.globalIndex()]); // mixing SE + + int stop4 = 0; + + for (auto collision2 : mcCollisions) { // nested loop on collisions + + if (collision1.globalIndex() == collision2.globalIndex()) { + continue; + } + + if (stop4 > maxmixcollsGen) { + break; + } + + if (selectedparticlesMC_p.find(collision2.globalIndex()) != selectedparticlesMC_p.end()) { + mixMCParticlesIdentical<1>(selectedparticlesMC_p[collision1.globalIndex()], selectedparticlesMC_p[collision2.globalIndex()]); // mixing ME + } + + stop4++; + } + } + } + } + + // clearing up + for (auto i = selectedparticlesMC_antid.begin(); i != selectedparticlesMC_antid.end(); i++) + (i->second).clear(); + selectedparticlesMC_antid.clear(); + + for (auto i = selectedparticlesMC_d.begin(); i != selectedparticlesMC_d.end(); i++) + (i->second).clear(); + selectedparticlesMC_d.clear(); + + for (auto i = selectedparticlesMC_antip.begin(); i != selectedparticlesMC_antip.end(); i++) + (i->second).clear(); + selectedparticlesMC_antip.clear(); + + for (auto i = selectedparticlesMC_p.begin(); i != selectedparticlesMC_p.end(); i++) + (i->second).clear(); + selectedparticlesMC_p.clear(); + } + PROCESS_SWITCH(hadronnucleicorrelation, processGen, "processGen", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Nuspex/he3LambdaDerivedAnalysis.cxx b/PWGLF/Tasks/Nuspex/he3LambdaDerivedAnalysis.cxx new file mode 100644 index 00000000000..7929f4eaa9c --- /dev/null +++ b/PWGLF/Tasks/Nuspex/he3LambdaDerivedAnalysis.cxx @@ -0,0 +1,140 @@ +// 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. + +#include "PWGLF/DataModel/LFSlimHeLambda.h" + +#include +#include +#include +#include + +#include + +#include + +namespace +{ +std::shared_ptr hInvariantMassUS[2]; +std::shared_ptr hInvariantMassLS[2]; +std::shared_ptr hRotationInvariantMassUS[2]; +std::shared_ptr hRotationInvariantMassLS[2]; +std::shared_ptr hRotationInvariantMassAntiLSeta[2]; +std::shared_ptr hInvariantMassLambda[2]; +std::shared_ptr hCosPALambda; +std::shared_ptr hNsigmaHe3; +std::shared_ptr hNsigmaProton; +}; // namespace + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +struct he3LambdaDerivedAnalysis { + HistogramRegistry mRegistry{"He3LambdaDerivedAnalysis"}; + + Configurable cfgNrotations{"cfgNrotations", 7, "Number of rotations for He3 candidates"}; + Configurable cfgMirrorEta{"cfgMirrorEta", true, "Mirror eta for He3 candidates"}; + Configurable cfgMinCosPA{"cfgMinCosPA", 0.99, "Minimum cosPA for Lambda candidates"}; + Configurable cfgMaxNSigmaTPCHe3{"cfgMaxNSigmaTPCHe3", 2.0, "Maximum nSigmaTPC for He3 candidates"}; + Configurable cfgMinLambdaPt{"cfgMinLambdaPt", 0.4, "Minimum pT for Lambda candidates"}; + Configurable cfgMaxLambdaDeltaM{"cfgMaxLambdaDeltaM", 10.0e-3, "Maximum deltaM for Lambda candidates"}; + + void init(InitContext const&) + { + constexpr double ConstituentsMass = o2::constants::physics::MassProton + o2::constants::physics::MassNeutron * 2 + o2::constants::physics::MassSigmaPlus; + for (int i = 0; i < 2; ++i) { + hInvariantMassUS[i] = mRegistry.add(Form("hInvariantMassUS%i", i), "Invariant Mass", {HistType::kTH2D, {{45, 1., 10}, {100, ConstituentsMass - 0.05, ConstituentsMass + 0.05}}}); + hInvariantMassLS[i] = mRegistry.add(Form("hInvariantMassLS%i", i), "Invariant Mass", {HistType::kTH2D, {{45, 1., 10}, {100, ConstituentsMass - 0.05, ConstituentsMass + 0.05}}}); + hRotationInvariantMassUS[i] = mRegistry.add(Form("hRotationInvariantMassUS%i", i), "Rotation Invariant Mass", {HistType::kTH2D, {{45, 1., 10}, {100, ConstituentsMass - 0.05, ConstituentsMass + 0.05}}}); + hRotationInvariantMassLS[i] = mRegistry.add(Form("hRotationInvariantMassLS%i", i), "Rotation Invariant Mass", {HistType::kTH2D, {{45, 1., 10}, {100, ConstituentsMass - 0.05, ConstituentsMass + 0.05}}}); + hInvariantMassLambda[i] = mRegistry.add(Form("hInvariantMassLambda%i", i), "Invariant Mass Lambda", {HistType::kTH2D, {{50, 0., 10.}, {30, o2::constants::physics::MassLambda0 - 0.015, o2::constants::physics::MassLambda0 + 0.015}}}); + hRotationInvariantMassAntiLSeta[i] = mRegistry.add(Form("hRotationInvariantMassAntiLSeta%i", i), "Rotation Invariant Mass Anti-Lambda", {HistType::kTH2D, {{45, 1., 10}, {100, ConstituentsMass - 0.05, ConstituentsMass + 0.05}}}); + } + hCosPALambda = mRegistry.add("hCosPALambda", "Cosine of Pointing Angle for Lambda", {HistType::kTH2D, {{50, 0., 10.}, {500, 0.9, 1.}}}); + hNsigmaHe3 = mRegistry.add("hNsigmaHe3", "nSigma TPC for He3", {HistType::kTH2D, {{100, -10., 10.}, {200, -5, 5.}}}); + hNsigmaProton = mRegistry.add("hNsigmaProton", "nSigma TPC for Proton", {HistType::kTH2D, {{100, -10., 10.}, {200, -5, 5.}}}); + } + + void processSameEvent(o2::aod::LFEvents::iterator const& collision, o2::aod::LFHe3_000 const& he3s, o2::aod::LFLambda_000 const& lambdas) + { + std::vector he3Candidates; + he3Candidates.reserve(he3s.size()); + std::vector lambdaCandidates; + lambdaCandidates.reserve(lambdas.size()); + for (const auto& he3 : he3s) { + if (he3.lfEventId() != collision.globalIndex()) { + std::cout << "He3 candidate does not match event index, skipping." << std::endl; + return; + } + he3Candidate candidate; + candidate.momentum = ROOT::Math::LorentzVector>(he3.pt(), he3.eta(), he3.phi(), o2::constants::physics::MassHelium3); + candidate.nSigmaTPC = he3.nSigmaTPC(); + candidate.dcaXY = he3.dcaXY(); + candidate.dcaZ = he3.dcaZ(); + candidate.tpcNClsFound = he3.tpcNCls(); + candidate.itsNCls = he3.itsClusterSizes(); + candidate.itsClusterSizes = he3.itsClusterSizes(); + candidate.sign = he3.sign(); + hNsigmaHe3->Fill(he3.pt() * he3.sign(), he3.nSigmaTPC()); + if (std::abs(he3.nSigmaTPC()) > cfgMaxNSigmaTPCHe3) { + continue; // Skip candidates with nSigmaTPC outside range + } + he3Candidates.push_back(candidate); + } + for (const auto& lambda : lambdas) { + if (lambda.lfEventId() != collision.globalIndex()) { + std::cout << "Lambda candidate does not match event index, skipping." << std::endl; + return; + } + lambdaCandidate candidate; + candidate.momentum.SetCoordinates(lambda.pt(), lambda.eta(), lambda.phi(), o2::constants::physics::MassLambda0); + candidate.mass = lambda.mass(); + candidate.cosPA = lambda.cosPA(); + candidate.dcaV0Daughters = lambda.dcaDaughters(); + hCosPALambda->Fill(lambda.pt(), candidate.cosPA); + // hNsigmaProton->Fill(lambda.pt() * lambda.sign(), lambda.protonNSigmaTPC()); + hInvariantMassLambda[0]->Fill(lambda.pt(), lambda.mass()); + if (candidate.cosPA < cfgMinCosPA || lambda.pt() < cfgMinLambdaPt || + std::abs(lambda.mass() - o2::constants::physics::MassLambda0) > cfgMaxLambdaDeltaM) { + continue; // Skip candidates with low cosPA + } + hInvariantMassLambda[1]->Fill(lambda.pt(), lambda.mass()); + lambdaCandidates.push_back(candidate); + } + + for (const auto& he3 : he3Candidates) { + for (const auto& lambda : lambdaCandidates) { + auto pairMomentum = lambda.momentum + he3.momentum; // Calculate invariant mass + (he3.sign * lambda.sign > 0 ? hInvariantMassLS : hInvariantMassUS)[he3.sign > 0]->Fill(pairMomentum.Pt(), pairMomentum.M()); + } + for (int iEta{0}; iEta <= cfgMirrorEta; ++iEta) { + for (int iR{0}; iR <= cfgNrotations; ++iR) { + auto he3Momentum = ROOT::Math::LorentzVector>(he3.momentum.Pt(), (1. - iEta * 2.) * he3.momentum.Eta(), he3.momentum.Phi() + TMath::Pi() * (0.75 + 0.5 * iR / cfgNrotations), he3.momentum.M()); + for (const auto& lambda : lambdaCandidates) { + auto pairMomentum = lambda.momentum + he3Momentum; // Calculate invariant mass + (he3.sign * lambda.sign > 0 ? hRotationInvariantMassLS : hRotationInvariantMassUS)[he3.sign > 0]->Fill(pairMomentum.Pt(), pairMomentum.M()); + if (he3.sign < 0 && lambda.sign < 0) { + hRotationInvariantMassAntiLSeta[iEta]->Fill(pairMomentum.Pt(), pairMomentum.M()); + } + } + } + } + } + } + PROCESS_SWITCH(he3LambdaDerivedAnalysis, processSameEvent, "Process same event", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Nuspex/hypertriton3bodyMCQA.cxx b/PWGLF/Tasks/Nuspex/hypertriton3bodyMCQA.cxx deleted file mode 100644 index 7d54bd86d48..00000000000 --- a/PWGLF/Tasks/Nuspex/hypertriton3bodyMCQA.cxx +++ /dev/null @@ -1,905 +0,0 @@ -// 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. -// ======================== -// -// This code perform a check for all mcparticles and tracks -// which has corresponding mcparticles to find out the properties -// of hypertriton 3-body decay -// -// author: yuanzhe.wang@cern.ch - -#include -#include -#include -#include -#include -#include -#include - -#include "CommonDataFormat/InteractionRecord.h" -#include "CommonDataFormat/IRFrame.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/pidTOFGeneric.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/TableProducer/PID/pidTOFBase.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "CommonConstants/PhysicsConstants.h" -#include "CCDB/BasicCCDBManager.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using std::array; -using ColwithEvTimes = o2::soa::Join; -using FullTracksExtIU = soa::Join; -using MCLabeledTracksIU = soa::Join; - -template -bool is3bodyDecayedH3L(TMCParticle const& particle) -{ - if (std::abs(particle.pdgCode()) != 1010010030) { - return false; - } - bool haveProton = false, havePion = false, haveDeuteron = false; - bool haveAntiProton = false, haveAntiPion = false, haveAntiDeuteron = false; - for (auto& mcDaughter : particle.template daughters_as()) { - if (mcDaughter.pdgCode() == 2212) - haveProton = true; - if (mcDaughter.pdgCode() == -2212) - haveAntiProton = true; - if (mcDaughter.pdgCode() == 211) - havePion = true; - if (mcDaughter.pdgCode() == -211) - haveAntiPion = true; - if (mcDaughter.pdgCode() == 1000010020) - haveDeuteron = true; - if (mcDaughter.pdgCode() == -1000010020) - haveAntiDeuteron = true; - } - if (haveProton && haveAntiPion && haveDeuteron && particle.pdgCode() > 0) { - return true; - } else if (haveAntiProton && havePion && haveAntiDeuteron && particle.pdgCode() < 0) { - return true; - } - return false; -} - -template -bool isPairedH3LDaughters(TMCParticle const& mctrack0, TMCParticle const& mctrack1, TMCParticle const& mctrack2) -{ - for (auto& particleMother : mctrack0.template mothers_as()) { - if (!(particleMother.pdgCode() == 1010010030 && mctrack0.pdgCode() == 2212 && mctrack1.pdgCode() == -211 && mctrack2.pdgCode() == 1000010020) && - !(particleMother.pdgCode() == -1010010030 && mctrack0.pdgCode() == -2212 && mctrack1.pdgCode() == 211 && mctrack2.pdgCode() == -1000010020)) { - continue; - } - bool flag1 = false, flag2 = false; - for (auto& mcDaughter : particleMother.template daughters_as()) { - if (mcDaughter.globalIndex() == mctrack1.globalIndex()) - flag1 = true; - if (mcDaughter.globalIndex() == mctrack2.globalIndex()) - flag2 = true; - } - if (!flag1 || !flag2) - continue; - // move the requirement in mass region into the loop to draw a histogram - // double hypertritonMCMass = RecoDecay::m(array{array{mctrack0.px(), mctrack0.py(), mctrack0.pz()}, array{mctrack1.px(), mctrack1.py(), mctrack1.pz()}, array{mctrack2.px(), mctrack2.py(), mctrack2.pz()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); - // if (hypertritonMCMass > 2.990 && hypertritonMCMass < 2.993) - return true; - } - return false; -} - -// check the properties of daughters candidates and true daughters -struct hypertriton3bodyTrackMcinfo { - - Service ccdb; - Preslice perCollisionTracks = aod::track::collisionId; - - // Basic checks - HistogramRegistry registry{ - "registry", - { - {"hEventCounter", "hEventCounter", {HistType::kTH1F, {{3, 0.0f, 3.0f}}}}, - {"hParticleCounter", "hParticleCounter", {HistType::kTH1F, {{7, 0.0f, 7.0f}}}}, - - {"hTPCNCls", "hTPCNCls", {HistType::kTH1F, {{160, 0.0f, 160.0f}}}}, - {"hTPCNClsCrossedRows", "hTPCNClsCrossedRows", {HistType::kTH1F, {{160, 0.0f, 160.0f}}}}, - {"hTrackEta", "hTrackEta", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hTrackITSNcls", "hTrackITSNcls", {HistType::kTH1F, {{10, 0.0f, 10.0f}}}}, - {"hTrackMcRapidity", "hTrackMcRapidity", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hTrackNsigmaProton", "hTrackNsigmaProton", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hTrackNsigmaPion", "hTrackNsigmaPion", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hTrackNsigmaDeuteron", "hTrackNsigmaDeuteron", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - - {"hHypertritonEta", "hHypertritomEta", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hHypertritonMcRapidity", "hHypertritonMcRapidity", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hHypertritonMcPt", "hHypertritonMcPt", {HistType::kTH1F, {{300, 0.0f, 15.0f}}}}, - - {"hProtonCounter", "hProtonCounter", {HistType::kTH1F, {{2, 0.0f, 2.0f}}}}, - {"hProtonPt", "hProtonPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hProtonP", "hProtonP", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hProtonMcPt", "hProtonMcPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hProtonMcP", "hProtonMcP", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hProtonEta", "hProtonEta", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hProtonMcRapidity", "hProtonMcRapidity", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hProtonNsigmaProton", "hProtonNsigmaProton", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hProtonTPCNCls", "hProtonTPCNCls", {HistType::kTH1F, {{120, 0.0f, 120.0f}}}}, - {"hProtonTPCBB", "hProtonTPCBB", {HistType::kTH2F, {{320, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hProtonTPCBBAfterTPCNclsCut", "hProtonTPCBBAfterTPCNclsCut", {HistType::kTH2F, {{320, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hDauProtonPt", "hDauProtonPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDauProtonMcPt", "hDauProtonMcPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDauProtonNsigmaProton", "hDauProtonNsigmaProton", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hDauProtonTPCVsPt", "hDauProtonTPCVsPt", {HistType::kTH2F, {{50, 0.0f, 5.0f, "#it{p}_{T} (GeV/c)"}, {120, -6.0f, 6.0f, "TPC n#sigma"}}}}, - - {"hPionCounter", "hPionCounter", {HistType::kTH1F, {{2, 0.0f, 2.0f}}}}, - {"hPionPt", "hPionPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hPionP", "hPionP", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hPionMcPt", "hPionMcPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hPionMcP", "hPionMcP", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hPionEta", "hPionEta", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hPionMcRapidity", "hPionMcRapidity", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hPionNsigmaPion", "hPionNsigmaPion", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hPionTPCNCls", "hPionTPCNCls", {HistType::kTH1F, {{160, 0.0f, 160.0f}}}}, - {"hPionTPCBB", "hPionTPCBB", {HistType::kTH2F, {{320, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hPionTPCBBAfterTPCNclsCut", "hPionTPCBBAfterTPCNclsCut", {HistType::kTH2F, {{320, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hDauPionPt", "hDauPionPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDauPionMcPt", "hDauPionMcPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDauPionNsigmaPion", "hDauPionNsigmaPion", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hDauPionTPCVsPt", "hDauPionTPCVsPt", {HistType::kTH2F, {{20, 0.0f, 2.0f, "#it{p}_{T} (GeV/c)"}, {120, -6.0f, 6.0f, "TPC n#sigma"}}}}, - {"hDauPionDcaXY", "hDauPionDcaXY", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}}, - - {"hDeuteronCounter", "hDeuteronCounter", {HistType::kTH1F, {{2, 0.0f, 2.0f}}}}, - {"hDeuteronPt", "hDeuteronPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDeuteronP", "hDeuteronP", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDeuteronMcPt", "hDeuteronMcPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDeuteronMcP", "hDeuteronMcP", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDeuteronEta", "hDeuteronEta", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hDeuteronMcRapidity", "hDeuteronMcRapidity", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, - {"hDeuteronNsigmaDeuteron", "hDeuteronNsigmaDeuteron", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hDeuteronTPCNCls", "hDeuteronTPCNCls", {HistType::kTH1F, {{120, 0.0f, 120.0f}}}}, - {"hDeuteronTPCBB", "hDeuteronTPCBB", {HistType::kTH2F, {{320, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hDeuteronTPCBBAfterTPCNclsCut", "hDeuteronTPCBBAfterTPCNclsCut", {HistType::kTH2F, {{320, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hDauDeuteronPt", "hDauDeuteronPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDauDeuteronMcPt", "hDauDeuteronMcPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDauDeuteronTPCVsPt", "hDauDeuteronTPCVsPt", {HistType::kTH2F, {{80, 0.0f, 8.0f, "#it{p}_{T} (GeV/c)"}, {120, -6.0f, 6.0f, "TPC n#sigma"}}}}, - {"hDauDeuteronTOFNSigmaVsP", "hDauDeuteronTOFNSigmaVsP", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronTOFNSigmaVsPHasTOF", "hDauDeuteronTOFNSigmaVsPHasTOF", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronMatchCounter", "hDauDeuteronMatchCounter", {HistType::kTH1F, {{4, 0.0f, 4.0f}}}}, - - {"hTPCBB", "hTPCBB", {HistType::kTH2F, {{120, -8.0f, 8.0f, "p/z(GeV/c)"}, {100, 0.0f, 1000.0f, "TPCSignal"}}}}, - - {"hPairedH3LDaughers", "hPairedH3LDaughers", {HistType::kTH1F, {{3, 0.0f, 3.0f}}}}, - {"hPairedH3LDaughersInvMass", "hPairedH3LDaughersInvMass", {HistType::kTH1F, {{300, 2.9f, 3.2f}}}}, - {"hDuplicatedH3LDaughers", "hDuplicatedH3LDaughers", {HistType::kTH1F, {{3, 0.0f, 3.0f}}}}, - - // Diff checks always requir hasTOF - {"hDiffTrackTOFSignal", "hDiffTrackTOFSignal", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, - {"hDiffEvTimeForTrack", "hDiffEvTimeForTrack", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, - {"hDiffTrackTOFNSigmaDe", "hDiffTrackTOFNSigmaDe", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, - {"hDauDeuteronNewTOFNSigmaVsP", "hDauDeuteronNewTOFNSigmaVsP", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hWrongDeuteronTOFNSigmaVsP", "hWrongDeuteronTOFNSigmaVsP", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hWrongDeuteronNewTOFNSigmaVsP", "hWrongDeuteronNewTOFNSigmaVsP", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDiffColTime", "hDiffColTime", {HistType::kTH1F, {{200, -100.0f, 100.0f}}}}, - {"hDauDeuteronDiffTOFNsigmaDeHasTOF", "hDauDeuteronDiffTOFNsigmaDeHasTOF", {HistType::kTH1F, {{200, -100.0f, 100.0f}}}}, - - // _v2 for using relinked collision - {"hDauDeuteronTOFNSigmaVsP_CorrectCol", "hDauDeuteronTOFNSigmaVsP_CorrectCol", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronNewTOFNSigmaVsP_CorrectCol", "hDauDeuteronNewTOFNSigmaVsP_CorrectCol", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronTOFNSigmaVsP_v2", "hDauDeuteronTOFNSigmaVsP_v2", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronNewTOFNSigmaVsP_v2_AO2D", "hDauDeuteronNewTOFNSigmaVsP_v2 AO2D", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronNewTOFNSigmaVsP_v2_EvSel", "hDauDeuteronNewTOFNSigmaVsP_v2 EvSel", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronTOFNSigmaVsColTimeRes_v2", "hDauDeuteronTOFNSigmaVsColTimeRes_v2", {HistType::kTH2F, {{100, 0.0f, 400.0f, "CollisionTimeRes(ns)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronTOFNSigmaVsColTimeRes_v2_AO2D", "hDauDeuteronTOFNSigmaVsColTimeRes_v2 AO2D", {HistType::kTH2F, {{100, 0.0f, 400.0f, "CollisionTimeRes(ns)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronTOFNSigmaVsColTimeRes_v2_EvSel", "hDauDeuteronTOFNSigmaVsColTimeRes_v2 EvSel", {HistType::kTH2F, {{100, 0.0f, 400.0f, "CollisionTimeRes(ns)"}, {600, -300.0f, 300.0f, "TOF n#sigma"}}}}, - {"hDauDeuteronTOFPIDCounter", "hDauDeuteronTOFPIDCounter", {HistType::kTH1F, {{5, 0.0f, 5.0f}}}}, - {"hDauDeuteronTOFPIDCounter_CloseBC", "hDauDeuteronTOFPIDCounter CloseBC", {HistType::kTH1F, {{5, 0.0f, 5.0f}}}}, - }, - }; - - void init(InitContext&) - { - registry.get(HIST("hParticleCounter"))->GetXaxis()->SetBinLabel(1, "Readin"); - registry.get(HIST("hParticleCounter"))->GetXaxis()->SetBinLabel(2, "Has_mcparticle"); - registry.get(HIST("hParticleCounter"))->GetXaxis()->SetBinLabel(3, "Rapidity Cut"); - registry.get(HIST("hParticleCounter"))->GetXaxis()->SetBinLabel(4, "McisHypertriton"); - registry.get(HIST("hParticleCounter"))->GetXaxis()->SetBinLabel(5, "McisProton"); - registry.get(HIST("hParticleCounter"))->GetXaxis()->SetBinLabel(6, "McisPion"); - registry.get(HIST("hParticleCounter"))->GetXaxis()->SetBinLabel(7, "McisDeuteron"); - - TString TrackCounterbinLabel[2] = {"hasMom", "FromHypertriton"}; - for (int i{0}; i < 2; i++) { - registry.get(HIST("hProtonCounter"))->GetXaxis()->SetBinLabel(i + 1, TrackCounterbinLabel[i]); - registry.get(HIST("hPionCounter"))->GetXaxis()->SetBinLabel(i + 1, TrackCounterbinLabel[i]); - registry.get(HIST("hDeuteronCounter"))->GetXaxis()->SetBinLabel(i + 1, TrackCounterbinLabel[i]); - } - registry.get(HIST("hDuplicatedH3LDaughers"))->GetXaxis()->SetBinLabel(1, "proton"); - registry.get(HIST("hDuplicatedH3LDaughers"))->GetXaxis()->SetBinLabel(2, "pion"); - registry.get(HIST("hDuplicatedH3LDaughers"))->GetXaxis()->SetBinLabel(3, "deuteron"); - - registry.get(HIST("hDauDeuteronMatchCounter"))->GetXaxis()->SetBinLabel(1, "Total"); - registry.get(HIST("hDauDeuteronMatchCounter"))->GetXaxis()->SetBinLabel(2, "correct collision"); - registry.get(HIST("hDauDeuteronMatchCounter"))->GetXaxis()->SetBinLabel(3, "hasTOF"); - registry.get(HIST("hDauDeuteronMatchCounter"))->GetXaxis()->SetBinLabel(4, "hasTOF & correct collsion"); - - registry.get(HIST("hDauDeuteronTOFPIDCounter"))->GetXaxis()->SetBinLabel(1, "Origin |n#sigma| >= 6"); - registry.get(HIST("hDauDeuteronTOFPIDCounter"))->GetXaxis()->SetBinLabel(2, "BothBC work"); - registry.get(HIST("hDauDeuteronTOFPIDCounter"))->GetXaxis()->SetBinLabel(3, "Only BCAO2D work"); - registry.get(HIST("hDauDeuteronTOFPIDCounter"))->GetXaxis()->SetBinLabel(4, "Only BCEvSel work"); - registry.get(HIST("hDauDeuteronTOFPIDCounter"))->GetXaxis()->SetBinLabel(5, "BothBC not work"); - registry.get(HIST("hDauDeuteronTOFPIDCounter_CloseBC"))->GetXaxis()->SetBinLabel(1, "Origin |n#sigma| < 6"); - registry.get(HIST("hDauDeuteronTOFPIDCounter_CloseBC"))->GetXaxis()->SetBinLabel(2, "BothBC work"); - registry.get(HIST("hDauDeuteronTOFPIDCounter_CloseBC"))->GetXaxis()->SetBinLabel(3, "Only BCAO2D work"); - registry.get(HIST("hDauDeuteronTOFPIDCounter_CloseBC"))->GetXaxis()->SetBinLabel(4, "Only BCEvSel work"); - registry.get(HIST("hDauDeuteronTOFPIDCounter_CloseBC"))->GetXaxis()->SetBinLabel(5, "BothBC not work"); - } - - Configurable dcapiontopv{"dcapiontopv", .05, "DCA Pion To PV"}; - Configurable minProtonPt{"minProtonPt", 0.3, "minProtonPt"}; - Configurable maxProtonPt{"maxProtonPt", 5, "maxProtonPt"}; - Configurable minPionPt{"minPionPt", 0.1, "minPionPt"}; - Configurable maxPionPt{"maxPionPt", 1.2, "maxPionPt"}; - Configurable minDeuteronPt{"minDeuteronPt", 0.6, "minDeuteronPt"}; - Configurable maxDeuteronPt{"maxDeuteronPt", 10, "maxDeuteronPt"}; - Configurable event_sel8_selection{"event_sel8_selection", false, "event selection count post sel8 cut"}; - Configurable event_posZ_selection{"event_posZ_selection", false, "event selection count post poZ cut"}; - - // CCDB TOF PID paras - Configurable timestamp{"ccdb-timestamp", -1, "timestamp of the object"}; - Configurable paramFileName{"paramFileName", "", "Path to the parametrization object. If empty the parametrization is not taken from file"}; - Configurable parametrizationPath{"parametrizationPath", "TOF/Calib/Params", "Path of the TOF parametrization on the CCDB or in the file, if the paramFileName is not empty"}; - Configurable passName{"passName", "", "Name of the pass inside of the CCDB parameter collection. If empty, the automatically deceted from metadata (to be implemented!!!)"}; - Configurable timeShiftCCDBPath{"timeShiftCCDBPath", "", "Path of the TOF time shift vs eta. If empty none is taken"}; - Configurable loadResponseFromCCDB{"loadResponseFromCCDB", false, "Flag to load the response from the CCDB"}; - Configurable fatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"}; - - o2::aod::pidtofgeneric::TofPidNewCollision bachelorTOFPID; - o2::pid::tof::TOFResoParamsV2 mRespParamsV2; - - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) - { - // Initial TOF PID Paras, copied from PIDTOF.h - timestamp.value = bc.timestamp(); - ccdb->setTimestamp(timestamp.value); - // Not later than now objects - ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - // TODO: implement the automatic pass name detection from metadata - if (passName.value == "") { - passName.value = "unanchored"; // temporary default - LOG(warning) << "Passed autodetect mode for pass, not implemented yet, waiting for metadata. Taking '" << passName.value << "'"; - } - LOG(info) << "Using parameter collection, starting from pass '" << passName.value << "'"; - - const std::string fname = paramFileName.value; - if (!fname.empty()) { // Loading the parametrization from file - LOG(info) << "Loading exp. sigma parametrization from file " << fname << ", using param: " << parametrizationPath.value; - if (1) { - o2::tof::ParameterCollection paramCollection; - paramCollection.loadParamFromFile(fname, parametrizationPath.value); - LOG(info) << "+++ Loaded parameter collection from file +++"; - if (!paramCollection.retrieveParameters(mRespParamsV2, passName.value)) { - if (fatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } - } else { - mRespParamsV2.setShiftParameters(paramCollection.getPars(passName.value)); - mRespParamsV2.printShiftParameters(); - } - } else { - mRespParamsV2.loadParamFromFile(fname.data(), parametrizationPath.value); - } - } else if (loadResponseFromCCDB) { // Loading it from CCDB - LOG(info) << "Loading exp. sigma parametrization from CCDB, using path: " << parametrizationPath.value << " for timestamp " << timestamp.value; - o2::tof::ParameterCollection* paramCollection = ccdb->getForTimeStamp(parametrizationPath.value, timestamp.value); - paramCollection->print(); - if (!paramCollection->retrieveParameters(mRespParamsV2, passName.value)) { // Attempt at loading the parameters with the pass defined - if (fatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); - } - } else { // Pass is available, load non standard parameters - mRespParamsV2.setShiftParameters(paramCollection->getPars(passName.value)); - mRespParamsV2.printShiftParameters(); - } - } - mRespParamsV2.print(); - if (timeShiftCCDBPath.value != "") { - if (timeShiftCCDBPath.value.find(".root") != std::string::npos) { - mRespParamsV2.setTimeShiftParameters(timeShiftCCDBPath.value, "gmean_Pos", true); - mRespParamsV2.setTimeShiftParameters(timeShiftCCDBPath.value, "gmean_Neg", false); - } else { - mRespParamsV2.setTimeShiftParameters(ccdb->getForTimeStamp(Form("%s/pos", timeShiftCCDBPath.value.c_str()), timestamp.value), true); - mRespParamsV2.setTimeShiftParameters(ccdb->getForTimeStamp(Form("%s/neg", timeShiftCCDBPath.value.c_str()), timestamp.value), false); - } - } - - bachelorTOFPID.SetParams(mRespParamsV2); - } - - struct Indexdaughters { // check duplicated paired daughters - int64_t index0; - int64_t index1; - int64_t index2; - bool operator==(const Indexdaughters& t) const - { - return (this->index0 == t.index0 && this->index1 == t.index1 && this->index2 == t.index2); - } - }; - - void process(ColwithEvTimes const& collisions, MCLabeledTracksIU const& tracks, aod::McParticles const& /*particlesMC*/, aod::McCollisions const& /*mcCollisions*/, aod::BCsWithTimestamps const&) - { - for (auto collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - registry.fill(HIST("hEventCounter"), 0.5); - if (event_sel8_selection && !collision.sel8()) { - return; - } - registry.fill(HIST("hEventCounter"), 1.5); - if (event_posZ_selection && abs(collision.posZ()) > 10.f) { // 10cm - return; - } - registry.fill(HIST("hEventCounter"), 2.5); - - std::vector protons, pions, deuterons; // index for daughter tracks - std::unordered_set set_proton, set_pion, set_deuteron; // check duplicated daughters - int itrack = -1; - - auto coltracks = tracks.sliceBy(perCollisionTracks, collision.globalIndex()); - - for (auto& track : coltracks) { - - ++itrack; - registry.fill(HIST("hParticleCounter"), 0.5); - registry.fill(HIST("hTrackITSNcls"), track.itsNCls()); - registry.fill(HIST("hTPCNCls"), track.tpcNClsFound()); - registry.fill(HIST("hTPCNClsCrossedRows"), track.tpcNClsCrossedRows()); - registry.fill(HIST("hTrackNsigmaDeuteron"), track.tpcNSigmaDe()); - registry.fill(HIST("hTrackNsigmaProton"), track.tpcNSigmaPr()); - registry.fill(HIST("hTrackNsigmaPion"), track.tpcNSigmaPi()); - - if (!track.has_mcParticle()) { - continue; - } - auto mcparticle = track.mcParticle_as(); - registry.fill(HIST("hTPCBB"), track.p() * track.sign(), track.tpcSignal()); - - registry.fill(HIST("hParticleCounter"), 1.5); - - // if (TMath::Abs(mcparticle.y()) > 0.9) {continue;} - registry.fill(HIST("hParticleCounter"), 2.5); - registry.fill(HIST("hTrackEta"), track.eta()); - registry.fill(HIST("hTrackMcRapidity"), mcparticle.y()); - - // Hypertriton detected directly - if (mcparticle.pdgCode() == 1010010030 || mcparticle.pdgCode() == -1010010030) { - registry.fill(HIST("hParticleCounter"), 3.5); - registry.fill(HIST("hHypertritonMcPt"), mcparticle.pt()); - registry.fill(HIST("hHypertritonEta"), track.eta()); - registry.fill(HIST("hHypertritonMcRapidity"), mcparticle.y()); - } - - // Proton - if (mcparticle.pdgCode() == 2212 || mcparticle.pdgCode() == -2212) { - registry.fill(HIST("hParticleCounter"), 4.5); - if (track.tpcNClsFound() > 70) { - registry.fill(HIST("hProtonTPCBBAfterTPCNclsCut"), track.p() * track.sign(), track.tpcSignal()); - } - - if (mcparticle.has_mothers()) { - registry.fill(HIST("hProtonCounter"), 0.5); - for (auto& particleMother : mcparticle.mothers_as()) { - bool flag_H3L = is3bodyDecayedH3L(particleMother); - if (!flag_H3L) { - continue; - } - protons.push_back(itrack); - auto p = set_proton.insert(mcparticle.globalIndex()); - if (p.second == false) - registry.fill(HIST("hDuplicatedH3LDaughers"), 0); - registry.fill(HIST("hProtonCounter"), 1.5); - registry.fill(HIST("hDauProtonPt"), track.pt()); - registry.fill(HIST("hDauProtonMcPt"), mcparticle.pt()); - registry.fill(HIST("hDauProtonNsigmaProton"), track.tpcNSigmaPr()); - registry.fill(HIST("hDauProtonTPCVsPt"), track.pt(), track.tpcNSigmaPr()); - } - } - - registry.fill(HIST("hProtonMcPt"), mcparticle.pt()); - registry.fill(HIST("hProtonMcP"), mcparticle.p()); - registry.fill(HIST("hProtonPt"), track.pt()); - registry.fill(HIST("hProtonP"), track.p()); - - registry.fill(HIST("hProtonNsigmaProton"), track.tpcNSigmaPr()); - registry.fill(HIST("hProtonTPCNCls"), track.tpcNClsFound()); - registry.fill(HIST("hProtonEta"), track.eta()); - registry.fill(HIST("hProtonMcRapidity"), mcparticle.y()); - registry.fill(HIST("hProtonTPCBB"), track.p() * track.sign(), track.tpcSignal()); - } - - // Pion - if (mcparticle.pdgCode() == 211 || mcparticle.pdgCode() == -211) { - registry.fill(HIST("hParticleCounter"), 5.5); - if (track.tpcNClsFound() > 70) { - registry.fill(HIST("hPionTPCBBAfterTPCNclsCut"), track.p() * track.sign(), track.tpcSignal()); - } - - if (mcparticle.has_mothers()) { - registry.fill(HIST("hPionCounter"), 0.5); - for (auto& particleMother : mcparticle.mothers_as()) { - bool flag_H3L = is3bodyDecayedH3L(particleMother); - if (!flag_H3L) { - continue; - } - pions.push_back(itrack); - auto p = set_pion.insert(mcparticle.globalIndex()); - if (p.second == false) { - registry.fill(HIST("hDuplicatedH3LDaughers"), 1); - } - registry.fill(HIST("hPionCounter"), 1.5); - registry.fill(HIST("hDauPionPt"), track.pt()); - registry.fill(HIST("hDauPionMcPt"), mcparticle.pt()); - registry.fill(HIST("hDauPionTPCVsPt"), track.pt(), track.tpcNSigmaPi()); - registry.fill(HIST("hDauPionDcaXY"), track.dcaXY()); - } - } - - registry.fill(HIST("hPionMcPt"), mcparticle.pt()); - registry.fill(HIST("hPionMcP"), mcparticle.p()); - registry.fill(HIST("hPionPt"), track.pt()); - registry.fill(HIST("hPionP"), track.p()); - - registry.fill(HIST("hPionNsigmaPion"), track.tpcNSigmaPi()); - registry.fill(HIST("hPionTPCNCls"), track.tpcNClsFound()); - registry.fill(HIST("hPionEta"), track.eta()); - registry.fill(HIST("hPionMcRapidity"), mcparticle.y()); - registry.fill(HIST("hPionTPCBB"), track.p() * track.sign(), track.tpcSignal()); - } - - float tofNsigmaDe = -999; - static constexpr float kCSPEED = TMath::C() * 1.0e2f * 1.0e-12f; // c in cm/ps - - if (track.hasTOF() && track.has_collision()) { - auto responseDe = o2::pid::tof::ExpTimes(); - // float bachExpTime = track.length() * sqrt((o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron) + (track.tofExpMom() * track.tofExpMom())) / (kCSPEED * track.tofExpMom()); // L*E/(p*c) = L/v - - float mMassHyp = o2::track::pid_constants::sMasses2Z[track.pidForTracking()]; - float bachExpTime = track.length() * sqrt((mMassHyp * mMassHyp) + (track.tofExpMom() * track.tofExpMom())) / (kCSPEED * track.tofExpMom()); // L*E/(p*c) = L/v - float tofsignal = track.trackTime() * 1000 + bachExpTime; // in ps - - float expSigma = responseDe.GetExpectedSigma(mRespParamsV2, track, tofsignal, track.tofEvTimeErr()); - // tofNsigmaDe = (track.tofSignal() - track.tofEvTime() - responseDe.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - tofNsigmaDe = (tofsignal - track.tofEvTime() - responseDe.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - // tofNsigmaDe = (tofsignal - track.evTimeForTrack() - responseDe.GetCorrectedExpectedSignal(mRespParamsV2, track)) / expSigma; - - if (collision.bcId() == collision.foundBCId()) { - registry.fill(HIST("hDiffColTime"), track.tofEvTime() - collision.collisionTime()); - } - - // Assume deuterons linked to the correct collision, result of new TOF PID should be same as the default one - registry.fill(HIST("hDiffTrackTOFSignal"), track.tofSignal() - tofsignal); - registry.fill(HIST("hDiffEvTimeForTrack"), track.tofEvTime() - track.evTimeForTrack()); - registry.fill(HIST("hDiffTrackTOFNSigmaDe"), track.tofNSigmaDe() - bachelorTOFPID.GetTOFNSigma(o2::track::PID::Deuteron, track, collision, collision)); - // registry.fill(HIST("hDiffTrackTOFNSigmaDe"), track.tofExpSigmaDe() - bachelorTOFPID.GetTOFNSigma(o2::track::PID::Deuteron, track, collision, collision)); - } - - // Deuteron - if (mcparticle.pdgCode() == 1000010020 || mcparticle.pdgCode() == -1000010020) { - registry.fill(HIST("hParticleCounter"), 6.5); - if (track.tpcNClsFound() > 70) { - registry.fill(HIST("hDeuteronTPCBBAfterTPCNclsCut"), track.p() * track.sign(), track.tpcSignal()); - } - - if (mcparticle.has_mothers()) { - registry.fill(HIST("hDeuteronCounter"), 0.5); - for (auto& particleMother : mcparticle.mothers_as()) { - bool flag_H3L = is3bodyDecayedH3L(particleMother); - if (!flag_H3L) { - continue; - } - deuterons.push_back(itrack); - auto p = set_deuteron.insert(mcparticle.globalIndex()); - if (p.second == false) - registry.fill(HIST("hDuplicatedH3LDaughers"), 2); - registry.fill(HIST("hDeuteronCounter"), 1.5); - registry.fill(HIST("hDauDeuteronPt"), track.pt()); - registry.fill(HIST("hDauDeuteronMcPt"), mcparticle.pt()); - registry.fill(HIST("hDauDeuteronTPCVsPt"), track.pt(), track.tpcNSigmaDe()); - registry.fill(HIST("hDauDeuteronTOFNSigmaVsP"), track.sign() * track.p(), track.tofNSigmaDe()); - - registry.fill(HIST("hDauDeuteronNewTOFNSigmaVsP"), track.sign() * track.p(), tofNsigmaDe); - if (track.hasTOF()) { - registry.fill(HIST("hDauDeuteronTOFNSigmaVsPHasTOF"), track.sign() * track.p(), track.tofNSigmaDe()); - registry.fill(HIST("hDauDeuteronDiffTOFNsigmaDeHasTOF"), track.tofNSigmaDe() - tofNsigmaDe); - } - registry.fill(HIST("hDauDeuteronMatchCounter"), 0.5); - if (mcparticle.mcCollisionId() == collision.mcCollisionId()) { - registry.fill(HIST("hDauDeuteronMatchCounter"), 1.5); - } - if (track.hasTOF()) { - registry.fill(HIST("hDauDeuteronMatchCounter"), 2.5); - if (mcparticle.mcCollisionId() == collision.mcCollisionId()) { - registry.fill(HIST("hDauDeuteronMatchCounter"), 3.5); - } - } - } - } - - registry.fill(HIST("hDeuteronMcPt"), mcparticle.pt()); - registry.fill(HIST("hDeuteronMcP"), mcparticle.p()); - registry.fill(HIST("hDeuteronPt"), track.pt()); - registry.fill(HIST("hDeuteronP"), track.p()); - - registry.fill(HIST("hDeuteronNsigmaDeuteron"), track.tpcNSigmaDe()); - registry.fill(HIST("hDeuteronTPCNCls"), track.tpcNClsFound()); - registry.fill(HIST("hDeuteronEta"), track.eta()); - registry.fill(HIST("hDeuteronMcRapidity"), mcparticle.y()); - registry.fill(HIST("hDeuteronTPCBB"), track.p() * track.sign(), track.tpcSignal()); - } else { - if (track.hasTOF()) { - registry.fill(HIST("hWrongDeuteronTOFNSigmaVsP"), track.sign() * track.p(), track.tofNSigmaDe()); - registry.fill(HIST("hWrongDeuteronNewTOFNSigmaVsP"), track.sign() * track.p(), tofNsigmaDe); - } - } - } - - std::vector set_pair; - for (size_t iproton = 0; iproton < protons.size(); iproton++) { - auto track0 = tracks.iteratorAt(protons[iproton]); - auto mctrack0 = track0.mcParticle_as(); - for (size_t ipion = 0; ipion < pions.size(); ipion++) { - auto track1 = tracks.iteratorAt(pions[ipion]); - auto mctrack1 = track1.mcParticle_as(); - for (size_t ideuteron = 0; ideuteron < deuterons.size(); ideuteron++) { - auto track2 = tracks.iteratorAt(deuterons[ideuteron]); - auto mctrack2 = track2.mcParticle_as(); - if (isPairedH3LDaughters(mctrack0, mctrack1, mctrack2)) { - registry.fill(HIST("hPairedH3LDaughers"), 0); - // MC mass cut, to check if the daughters are from materials - double hypertritonMCMass = RecoDecay::m(array{array{mctrack0.px(), mctrack0.py(), mctrack0.pz()}, array{mctrack1.px(), mctrack1.py(), mctrack1.pz()}, array{mctrack2.px(), mctrack2.py(), mctrack2.pz()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); - registry.fill(HIST("hPairedH3LDaughersInvMass"), hypertritonMCMass); - if (hypertritonMCMass < 2.990 || hypertritonMCMass > 2.993) - continue; - registry.fill(HIST("hPairedH3LDaughers"), 1); - // duplicated daughters check - Indexdaughters temp = {mctrack0.globalIndex(), mctrack1.globalIndex(), mctrack2.globalIndex()}; - auto p = std::find(set_pair.begin(), set_pair.end(), temp); - if (p == set_pair.end()) { - set_pair.push_back(temp); - registry.fill(HIST("hPairedH3LDaughers"), 2); - } - } - } - } - } - } - - // Check for recalculated TOF PID for secondary deuterons - - std::vector SelectedEvents(collisions.size()); - int nevts = 0; - for (const auto& collision : collisions) { - SelectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); - } - - for (auto& track : tracks) { - if (!track.has_mcParticle()) { - continue; - } - auto mcparticle = track.mcParticle_as(); - if (mcparticle.pdgCode() == 1000010020 || mcparticle.pdgCode() == -1000010020) { - if (!mcparticle.has_mothers()) { - continue; - } - const auto evtReconstructed = std::find(SelectedEvents.begin(), SelectedEvents.end(), mcparticle.mcCollision_as().globalIndex()); - if (evtReconstructed == SelectedEvents.end() || !track.has_collision()) { - continue; - } - if (!track.has_collision()) { - continue; - } - auto collision = collisions.iteratorAt(evtReconstructed - SelectedEvents.begin()); - auto originalcollision = track.collision_as(); - - for (auto& particleMother : mcparticle.mothers_as()) { - bool flag_H3L = is3bodyDecayedH3L(particleMother); - if (!flag_H3L) { - continue; - } - - // auto bc = collision.bc_as(); - // initCCDB(bc); - float tofNsigmaDeAO2D = -999; - float tofNsigmaDeEvSel = -999; - - if (track.hasTOF()) { - /*auto responseDe = o2::pid::tof::ExpTimes(); - //float bachExpTime = track.length() * sqrt((o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron) + (track.tofExpMom() * track.tofExpMom())) / (kCSPEED * track.tofExpMom()); // L*E/(p*c) = L/v - float mMassHyp = o2::track::pid_constants::sMasses2Z[track.pidForTracking()]; - float bachExpTime = track.length() * sqrt((mMassHyp * mMassHyp) + (track.tofExpMom() * track.tofExpMom())) / (kCSPEED * track.tofExpMom()); // L*E/(p*c) = L/v - */ - - tofNsigmaDeAO2D = bachelorTOFPID.GetTOFNSigma(o2::track::PID::Deuteron, track, originalcollision, collision); - tofNsigmaDeEvSel = bachelorTOFPID.GetTOFNSigma(o2::track::PID::Deuteron, track, originalcollision, collision, false); - - if (collision.globalIndex() == originalcollision.globalIndex()) { - registry.fill(HIST("hDauDeuteronTOFNSigmaVsP_CorrectCol"), track.sign() * track.p(), track.tofNSigmaDe()); - registry.fill(HIST("hDauDeuteronNewTOFNSigmaVsP_CorrectCol"), track.sign() * track.p(), tofNsigmaDeAO2D); - continue; - } - - /*if (originalcollision.collisionTimeRes() > 40){ - continue; - }*/ - registry.fill(HIST("hDauDeuteronTOFNSigmaVsP_v2"), track.sign() * track.p(), track.tofNSigmaDe()); - registry.fill(HIST("hDauDeuteronNewTOFNSigmaVsP_v2_AO2D"), track.sign() * track.p(), tofNsigmaDeAO2D); - registry.fill(HIST("hDauDeuteronNewTOFNSigmaVsP_v2_EvSel"), track.sign() * track.p(), tofNsigmaDeEvSel); - registry.fill(HIST("hDauDeuteronTOFNSigmaVsColTimeRes_v2"), collision.collisionTimeRes(), track.tofNSigmaDe()); - registry.fill(HIST("hDauDeuteronTOFNSigmaVsColTimeRes_v2_AO2D"), originalcollision.collisionTimeRes(), tofNsigmaDeAO2D); - registry.fill(HIST("hDauDeuteronTOFNSigmaVsColTimeRes_v2_EvSel"), originalcollision.collisionTimeRes(), tofNsigmaDeEvSel); - - if (std::abs(track.tofNSigmaDe()) >= 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter"), 0.5); - if (std::abs(tofNsigmaDeAO2D) < 6 && std::abs(tofNsigmaDeEvSel) < 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter"), 1.5); - } else if (std::abs(tofNsigmaDeAO2D) < 6 && std::abs(tofNsigmaDeEvSel) >= 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter"), 2.5); - } else if (std::abs(tofNsigmaDeAO2D) >= 6 && std::abs(tofNsigmaDeEvSel) < 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter"), 3.5); - } else if (std::abs(tofNsigmaDeAO2D) >= 6 && std::abs(tofNsigmaDeEvSel) >= 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter"), 4.5); - } - } else if (std::abs(track.tofNSigmaDe()) < 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter_CloseBC"), 0.5); - if (std::abs(tofNsigmaDeAO2D) < 6 && std::abs(tofNsigmaDeEvSel) < 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter_CloseBC"), 1.5); - } else if (std::abs(tofNsigmaDeAO2D) < 6 && std::abs(tofNsigmaDeEvSel) >= 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter_CloseBC"), 2.5); - } else if (std::abs(tofNsigmaDeAO2D) >= 6 && std::abs(tofNsigmaDeEvSel) < 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter_CloseBC"), 3.5); - } else if (std::abs(tofNsigmaDeAO2D) >= 6 && std::abs(tofNsigmaDeEvSel) >= 6) { - registry.fill(HIST("hDauDeuteronTOFPIDCounter_CloseBC"), 4.5); - } - } - } - } - } - } - } -}; - -// check the performance of mcparticle -struct hypertriton3bodyMcParticleCheck { - // Basic checks - HistogramRegistry registry{ - "registry", - { - {"hMcCollCounter", "hMcCollCounter", {HistType::kTH1F, {{2, 0.0f, 2.0f}}}}, - - {"h3dMCDecayedHypertriton", "h3dMCDecayedHypertriton", {HistType::kTH3F, {{20, -1.0f, 1.0f, "Rapidity"}, {200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}, {50, 0.0f, 50.0f, "ct(cm)"}}}}, - - {"hMcHypertritonCounter", "hMcHypertritonCounter", {HistType::kTH1F, {{9, 0.0f, 9.0f}}}}, - {"hMcHypertritonPt", "hMcHypertritonPt", {HistType::kTH1F, {{300, 0.0f, 15.0f}}}}, - {"hMcProtonPt", "hMcProtonPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hMcPionPt", "hMcPionPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hMcDeuteronPt", "hMcDeuteronPt", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - - {"hMcRecoInvMass", "hMcRecoInvMass", {HistType::kTH1F, {{100, 2.95, 3.05f}}}}, - - {"hDiffDaughterR", "hDiffDaughterR", {HistType::kTH1F, {{10000, -100, 100}}}}, // difference between minR of pion&proton and R of deuteron(bachelor) - {"hTrackX", "hTrackX", {HistType::kTH1F, {{10000, -100, 100}}}}, - {"hTrackY", "hTrackY", {HistType::kTH1F, {{10000, -100, 100}}}}, - {"hTrackZ", "hTrackZ", {HistType::kTH1F, {{10000, -100, 100}}}}, - }, - }; - - o2::pid::tof::TOFResoParamsV2 mRespParamsV2; - - void init(InitContext&) - { - registry.get(HIST("hMcCollCounter"))->GetXaxis()->SetBinLabel(1, "Total Counter"); - registry.get(HIST("hMcCollCounter"))->GetXaxis()->SetBinLabel(2, "Recoonstructed"); - - registry.get(HIST("hMcHypertritonCounter"))->GetXaxis()->SetBinLabel(1, "Hypertriton All"); - registry.get(HIST("hMcHypertritonCounter"))->GetXaxis()->SetBinLabel(2, "Matter All"); - registry.get(HIST("hMcHypertritonCounter"))->GetXaxis()->SetBinLabel(3, "AntiMatter All"); - registry.get(HIST("hMcHypertritonCounter"))->GetXaxis()->SetBinLabel(4, "confirm to 3-body decay"); - registry.get(HIST("hMcHypertritonCounter"))->GetXaxis()->SetBinLabel(5, "Matter"); - registry.get(HIST("hMcHypertritonCounter"))->GetXaxis()->SetBinLabel(6, "AntiMatter"); - registry.get(HIST("hMcHypertritonCounter"))->GetXaxis()->SetBinLabel(7, "Rapidity"); - registry.get(HIST("hMcHypertritonCounter"))->GetXaxis()->SetBinLabel(8, "Lifetime"); - registry.get(HIST("hMcHypertritonCounter"))->GetXaxis()->SetBinLabel(9, "PtCut"); - } - - Configurable rapidityMCcut{"rapidityMCcut", 1, "rapidity cut MC count"}; - Configurable event_sel8_selection{"event_sel8_selection", false, "event selection count post sel8 cut"}; - Configurable event_posZ_selection{"event_posZ_selection", false, "event selection count post poZ cut"}; - - Preslice permcCollision = o2::aod::mcparticle::mcCollisionId; - - std::vector mcPartIndices; - template - void SetTrackIDForMC(aod::McParticles const& particlesMC, TTrackTable const& tracks) - { - mcPartIndices.clear(); - mcPartIndices.resize(particlesMC.size()); - std::fill(mcPartIndices.begin(), mcPartIndices.end(), -1); - for (auto& track : tracks) { - if (track.has_mcParticle()) { - auto mcparticle = track.template mcParticle_as(); - if (mcPartIndices[mcparticle.globalIndex()] == -1) { - mcPartIndices[mcparticle.globalIndex()] = track.globalIndex(); - } else { - auto candTrack = tracks.rawIteratorAt(mcPartIndices[mcparticle.globalIndex()]); - // Use the track which has innest information (also best quality? - if (track.x() < candTrack.x()) { - mcPartIndices[mcparticle.globalIndex()] = track.globalIndex(); - } - } - - // Checks for TrackR - registry.fill(HIST("hTrackX"), track.x()); - registry.fill(HIST("hTrackY"), track.y()); - registry.fill(HIST("hTrackZ"), track.z()); - } - } - } - - void process(aod::McCollisions const& mcCollisions, aod::McParticles const& particlesMC, const soa::SmallGroups>& collisions, MCLabeledTracksIU const& tracks) - { - SetTrackIDForMC(particlesMC, tracks); - std::vector SelectedEvents(collisions.size()); - int nevts = 0; - for (const auto& collision : collisions) { - if (event_sel8_selection && !collision.sel8()) { - continue; - } - if (event_posZ_selection && abs(collision.posZ()) > 10.f) { // 10cm - continue; - } - SelectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); - } - SelectedEvents.resize(nevts); - - for (auto mcCollision : mcCollisions) { - registry.fill(HIST("hMcCollCounter"), 0.5); - const auto evtReconstructedAndSelected = std::find(SelectedEvents.begin(), SelectedEvents.end(), mcCollision.globalIndex()) != SelectedEvents.end(); - if (evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection - registry.fill(HIST("hMcCollCounter"), 1.5); - // return; - } - - const auto& dparticlesMC = particlesMC.sliceBy(permcCollision, mcCollision.globalIndex()); - - for (auto& mcparticle : dparticlesMC) { - - if (mcparticle.pdgCode() == 2212 || mcparticle.pdgCode() == -2212) { - registry.fill(HIST("hMcProtonPt"), mcparticle.pt()); - } - if (mcparticle.pdgCode() == 211 || mcparticle.pdgCode() == -211) { - registry.fill(HIST("hMcPionPt"), mcparticle.pt()); - } - if (mcparticle.pdgCode() == 1000010020 || mcparticle.pdgCode() == -1000010020) { - registry.fill(HIST("hMcDeuteronPt"), mcparticle.pt()); - } - if (mcparticle.pdgCode() == 1010010030) { - registry.fill(HIST("hMcHypertritonCounter"), 1.5); - } else if (mcparticle.pdgCode() == -1010010030) { - registry.fill(HIST("hMcHypertritonCounter"), 2.5); - } - if (mcparticle.pdgCode() == 1010010030 || mcparticle.pdgCode() == -1010010030) { - registry.fill(HIST("hMcHypertritonCounter"), 0.5); - registry.fill(HIST("hMcHypertritonPt"), mcparticle.pt()); - - double dauDeuteronPos[3] = {-999, -999, -999}; - double dauProtonMom[3] = {-999, -999, -999}; - double dauPionMom[3] = {-999, -999, -999}; - double dauDeuteronMom[3] = {-999, -999, -999}; - double MClifetime = 999; - double dauProtonTrackR = 9999, dauPionTrackR = 99999, dauDeuteronTrackR = 999999; - bool flag_H3L = is3bodyDecayedH3L(mcparticle); - if (!flag_H3L) { - continue; - } - for (auto& mcparticleDaughter : mcparticle.daughters_as()) { - if (std::abs(mcparticleDaughter.pdgCode()) == 2212) { - dauProtonMom[0] = mcparticleDaughter.px(); - dauProtonMom[1] = mcparticleDaughter.py(); - dauProtonMom[2] = mcparticleDaughter.pz(); - if (mcPartIndices[mcparticleDaughter.globalIndex()] != -1) { - auto trackProton = tracks.rawIteratorAt(mcPartIndices[mcparticleDaughter.globalIndex()]); - dauProtonTrackR = trackProton.x(); - } - } - if (std::abs(mcparticleDaughter.pdgCode()) == 211) { - dauPionMom[0] = mcparticleDaughter.px(); - dauPionMom[1] = mcparticleDaughter.py(); - dauPionMom[2] = mcparticleDaughter.pz(); - if (mcPartIndices[mcparticleDaughter.globalIndex()] != -1) { - auto trackPion = tracks.rawIteratorAt(mcPartIndices[mcparticleDaughter.globalIndex()]); - dauPionTrackR = trackPion.x(); - } - } - if (std::abs(mcparticleDaughter.pdgCode()) == 1000010020) { - dauDeuteronPos[0] = mcparticleDaughter.vx(); - dauDeuteronPos[1] = mcparticleDaughter.vy(); - dauDeuteronPos[2] = mcparticleDaughter.vz(); - dauDeuteronMom[0] = mcparticleDaughter.px(); - dauDeuteronMom[1] = mcparticleDaughter.py(); - dauDeuteronMom[2] = mcparticleDaughter.pz(); - if (mcPartIndices[mcparticleDaughter.globalIndex()] != -1) { - auto trackDeuteron = tracks.rawIteratorAt(mcPartIndices[mcparticleDaughter.globalIndex()]); - dauDeuteronTrackR = trackDeuteron.x(); - } - } - } - if (mcparticle.pdgCode() == 1010010030) { - registry.fill(HIST("hMcHypertritonCounter"), 3.5); - registry.fill(HIST("hMcHypertritonCounter"), 4.5); - } - if (mcparticle.pdgCode() == -1010010030) { - registry.fill(HIST("hMcHypertritonCounter"), 3.5); - registry.fill(HIST("hMcHypertritonCounter"), 5.5); - } - double hypertritonMCMass = RecoDecay::m(array{array{dauProtonMom[0], dauProtonMom[1], dauProtonMom[2]}, array{dauPionMom[0], dauPionMom[1], dauPionMom[2]}, array{dauDeuteronMom[0], dauDeuteronMom[1], dauDeuteronMom[2]}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); - registry.fill(HIST("hMcRecoInvMass"), hypertritonMCMass); - - if (hypertritonMCMass > 2.990 && hypertritonMCMass < 2.993) { - MClifetime = RecoDecay::sqrtSumOfSquares(dauDeuteronPos[0] - mcparticle.vx(), dauDeuteronPos[1] - mcparticle.vy(), dauDeuteronPos[2] - mcparticle.vz()) * o2::constants::physics::MassHyperTriton / mcparticle.p(); - registry.fill(HIST("h3dMCDecayedHypertriton"), mcparticle.y(), mcparticle.pt(), MClifetime); - - double diffTrackR = dauDeuteronTrackR - std::min(dauPionTrackR, dauProtonTrackR); - registry.fill(HIST("hDiffDaughterR"), diffTrackR); - - // int daughterPionCount = 0; - // for (auto& mcparticleDaughter : mcparticle.daughters_as()) { - // if (std::abs(mcparticleDaughter.pdgCode()) == 211) { - // daughterPionCount++; - // } - // } - - // Counter for hypertriton N_gen - if (TMath::Abs(mcparticle.y()) < 1) { - registry.fill(HIST("hMcHypertritonCounter"), 6.5); - if (MClifetime < 40) { - registry.fill(HIST("hMcHypertritonCounter"), 7.5); - if (mcparticle.pt() > 1 && mcparticle.pt() < 10) { - registry.fill(HIST("hMcHypertritonCounter"), 8.5); - } - } - } - } - } - } - } - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - }; -} diff --git a/PWGLF/Tasks/Nuspex/hypertriton3bodyanalysis.cxx b/PWGLF/Tasks/Nuspex/hypertriton3bodyanalysis.cxx deleted file mode 100644 index 6d07b9e1de4..00000000000 --- a/PWGLF/Tasks/Nuspex/hypertriton3bodyanalysis.cxx +++ /dev/null @@ -1,803 +0,0 @@ -// 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. -// -// StoredVtx3BodyDatas analysis task -// ======================== -// -// This code loops over a StoredVtx3BodyDatas table and produces some -// standard analysis output. It requires either -// the hypertriton3bodybuilder or hypertriton3bodyfinder (not recommended) tasks -// to have been executed in the workflow (before). -// -// author: yuanzhe.wang@cern.ch -// - -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/Vtx3BodyTables.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "CommonConstants/PhysicsConstants.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using std::array; - -using FullTracksExtIU = soa::Join; -// using FullTracksExtIU = soa::Join; // For TOF PID check -using MCLabeledTracksIU = soa::Join; - -struct hypertriton3bodyQa { - // Basic checks - HistogramRegistry registry{ - "registry", - { - {"hVtxRadius", "hVtxRadius", {HistType::kTH1F, {{1000, 0.0f, 100.0f, "cm"}}}}, - {"hVtxCosPA", "hVtxCosPA", {HistType::kTH1F, {{1000, 0.9f, 1.0f}}}}, - {"hPtProton", "hPtProton", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hPtPionMinus", "hPtPionMinus", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hPtDeuteron", "hPtDeuteron", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hPtAntiProton", "hPtAntiProton", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hPtPionPlus", "hPtPionPlus", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hPtAntiDeuteron", "hPtAntiDeuteron", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hDCAXYProtonToPV", "hDCAXYProtonToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCAXYPionToPV", "hDCAXYPionToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCAXYDeuteronToPV", "hDCAXYDeuteronToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCAProtonToPV", "hDCAProtonToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCAPionToPV", "hDCAPionToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCADeuteronToPV", "hDCADeuteronToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hProtonTPCNcls", "hProtonTPCNcls", {HistType::kTH1F, {{300, 0, 300, "TPC cluster"}}}}, - {"hPionTPCNcls", "hPionTPCNcls", {HistType::kTH1F, {{300, 0, 300, "TPC cluster"}}}}, - {"hDeuteronTPCNcls", "hDeuteronTPCNcls", {HistType::kTH1F, {{300, 0, 300, "TPC cluster"}}}}, - {"hDCAVtxDau", "hDCAVtxDau", {HistType::kTH1F, {{1000, 0.0f, 10.0f, "cm^{2}"}}}}, - {"hVtxPt", "hVtxPt", {HistType::kTH1F, {{200, 0.0f, 10.0f, "p_{T}"}}}}, - {"hTOFPIDDeuteron", "hTOFPIDDeuteron", {HistType::kTH1F, {{2000, -100.0f, 100.0f}}}}, - {"hDeuTOFNsigma", "Deuteron TOF Nsigma distribution", {HistType::kTH2F, {{1200, -6, 6, "#it{p} (GeV/#it{c})"}, {2000, -100, 100, "TOF n#sigma"}}}}, - {"hDeuTOFNsigmaWithTPC", "Deuteron TOF Nsigma distribution", {HistType::kTH2F, {{1200, -6, 6, "#it{p} (GeV/#it{c})"}, {1000, -100, 100, "TOF n#sigma"}}}}, - }, - }; - - void init(InitContext const&) - { - AxisSpec massAxis = {120, 2.9f, 3.2f, "Inv. Mass (GeV/c^{2})"}; - registry.add("hMassHypertriton", "hMassHypertriton", {HistType::kTH1F, {massAxis}}); - registry.add("hMassAntiHypertriton", "hMassAntiHypertriton", {HistType::kTH1F, {massAxis}}); - // Check for selection criteria - registry.add("hDiffRVtxProton", "hDiffRVtxProton", HistType::kTH1F, {{100, -10, 10}}); // difference between the radius of decay vertex and minR of proton - registry.add("hDiffRVtxPion", "hDiffRVtxPion", HistType::kTH1F, {{100, -10, 10}}); // difference between the radius of decay vertex and minR of pion - registry.add("hDiffRVtxDeuteron", "hDiffRVtxDeuteron", HistType::kTH1F, {{100, -10, 10}}); // difference between the radius of decay vertex and minR of deuteron - registry.add("hDiffDaughterR", "hDiffDaughterR", HistType::kTH1F, {{10000, -100, 100}}); // difference between minR of pion&proton and R of deuteron(bachelor) - } - - void process(aod::Collision const& collision, aod::Vtx3BodyDatas const& vtx3bodydatas, FullTracksExtIU const& /*tracks*/) - { - for (auto& vtx : vtx3bodydatas) { - auto track0 = vtx.track0_as(); - auto track1 = vtx.track1_as(); - auto track2 = vtx.track2_as(); - - registry.fill(HIST("hVtxRadius"), vtx.vtxradius()); - registry.fill(HIST("hVtxCosPA"), vtx.vtxcosPA(collision.posX(), collision.posY(), collision.posZ())); - registry.fill(HIST("hDCAVtxDau"), vtx.dcaVtxdaughters()); - registry.fill(HIST("hVtxPt"), vtx.pt()); - registry.fill(HIST("hMassHypertriton"), vtx.mHypertriton()); - registry.fill(HIST("hMassAntiHypertriton"), vtx.mAntiHypertriton()); - if (std::abs(track2.tpcNSigmaDe()) < 5) { - registry.fill(HIST("hDeuTOFNsigmaWithTPC"), track2.tpcInnerParam() * track2.sign(), vtx.tofNSigmaBachDe()); - } - if (track2.sign() > 0) { - registry.fill(HIST("hPtProton"), track0.pt()); - registry.fill(HIST("hPtPionMinus"), track1.pt()); - registry.fill(HIST("hPtDeuteron"), track2.pt()); - registry.fill(HIST("hDCAXYProtonToPV"), vtx.dcaXYtrack0topv()); - registry.fill(HIST("hDCAXYPionToPV"), vtx.dcaXYtrack1topv()); - registry.fill(HIST("hDCAProtonToPV"), vtx.dcatrack0topv()); - registry.fill(HIST("hDCAPionToPV"), vtx.dcatrack1topv()); - registry.fill(HIST("hProtonTPCNcls"), track0.tpcNClsCrossedRows()); - registry.fill(HIST("hPionTPCNcls"), track1.tpcNClsCrossedRows()); - registry.fill(HIST("hDiffRVtxProton"), track0.x() - vtx.vtxradius()); - registry.fill(HIST("hDiffRVtxPion"), track1.x() - vtx.vtxradius()); - } else { - registry.fill(HIST("hPtPionPlus"), track0.pt()); - registry.fill(HIST("hPtAntiProton"), track1.pt()); - registry.fill(HIST("hPtAntiDeuteron"), track2.pt()); - registry.fill(HIST("hDCAXYProtonToPV"), vtx.dcaXYtrack1topv()); - registry.fill(HIST("hDCAXYPionToPV"), vtx.dcaXYtrack0topv()); - registry.fill(HIST("hDCAProtonToPV"), vtx.dcatrack1topv()); - registry.fill(HIST("hDCAPionToPV"), vtx.dcatrack0topv()); - registry.fill(HIST("hProtonTPCNcls"), track1.tpcNClsCrossedRows()); - registry.fill(HIST("hPionTPCNcls"), track0.tpcNClsCrossedRows()); - registry.fill(HIST("hDiffRVtxProton"), track1.x() - vtx.vtxradius()); - registry.fill(HIST("hDiffRVtxPion"), track0.x() - vtx.vtxradius()); - } - registry.fill(HIST("hDCAXYDeuteronToPV"), vtx.dcaXYtrack2topv()); - registry.fill(HIST("hDCADeuteronToPV"), vtx.dcatrack2topv()); - registry.fill(HIST("hDeuteronTPCNcls"), track2.tpcNClsCrossedRows()); - registry.fill(HIST("hTOFPIDDeuteron"), vtx.tofNSigmaBachDe()); - registry.fill(HIST("hDeuTOFNsigma"), track2.tpcInnerParam() * track2.sign(), vtx.tofNSigmaBachDe()); - registry.fill(HIST("hDiffRVtxDeuteron"), track2.x() - vtx.vtxradius()); - float diffTrackR = track2.x() - std::min(track0.x(), track1.x()); - registry.fill(HIST("hDiffDaughterR"), diffTrackR); - } - } -}; - -struct hypertriton3bodyAnalysis { - - Preslice perCollisionVtx3BodyDatas = o2::aod::vtx3body::collisionId; - - // Selection criteria - Configurable vtxcospa{"vtxcospa", 0.99, "Vtx CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0) - Configurable dcavtxdau{"dcavtxdau", 1.0, "DCA Vtx Daughters"}; // loose cut - Configurable dcapiontopv{"dcapiontopv", .05, "DCA Pion To PV"}; - Configurable etacut{"etacut", 0.9, "etacut"}; - Configurable rapiditycut{"rapiditycut", 1, "rapiditycut"}; - Configurable TofPidNsigmaMin{"TofPidNsigmaMin", -5, "TofPidNsigmaMin"}; - Configurable TofPidNsigmaMax{"TofPidNsigmaMax", 5, "TofPidNsigmaMax"}; - Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; - Configurable event_sel8_selection{"event_sel8_selection", true, "event selection count post sel8 cut"}; - Configurable mc_event_selection{"mc_event_selection", true, "mc event selection count post kIsTriggerTVX and kNoTimeFrameBorder"}; - Configurable event_posZ_selection{"event_posZ_selection", true, "event selection count post poZ cut"}; - Configurable lifetimecut{"lifetimecut", 40., "lifetimecut"}; // ct - Configurable minProtonPt{"minProtonPt", 0.3, "minProtonPt"}; - Configurable maxProtonPt{"maxProtonPt", 5, "maxProtonPt"}; - Configurable minPionPt{"minPionPt", 0.1, "minPionPt"}; - Configurable maxPionPt{"maxPionPt", 1.2, "maxPionPt"}; - Configurable minDeuteronPt{"minDeuteronPt", 0.6, "minDeuteronPt"}; - Configurable maxDeuteronPt{"maxDeuteronPt", 10, "maxDeuteronPt"}; - Configurable minDeuteronPUseTOF{"minDeuteronPUseTOF", 1, "minDeuteronPt Enable TOF PID"}; - Configurable h3LMassLowerlimit{"h3LMassLowerlimit", 2.96, "Hypertriton mass lower limit"}; - Configurable h3LMassUpperlimit{"h3LMassUpperlimit", 3.04, "Hypertriton mass upper limit"}; - Configurable mintpcNClsproton{"mintpcNClsproton", 90, "min tpc Nclusters for proton"}; - Configurable mintpcNClspion{"mintpcNClspion", 70, "min tpc Nclusters for pion"}; - Configurable mintpcNClsdeuteron{"mintpcNClsdeuteron", 100, "min tpc Nclusters for deuteron"}; - - Configurable mcsigma{"mcsigma", 0.0015, "sigma of mc invariant mass fit"}; // obtained from MC - Configurable bachelorPdgCode{"bachelorPdgCode", 1000010020, "pdgCode of bachelor daughter"}; - Configurable motherPdgCode{"motherPdgCode", 1010010030, "pdgCode of mother track"}; - - // 3sigma region for Dalitz plot - float lowersignallimit = o2::constants::physics::MassHyperTriton - 3 * mcsigma; - float uppersignallimit = o2::constants::physics::MassHyperTriton + 3 * mcsigma; - - HistogramRegistry registry{ - "registry", - { - {"hEventCounter", "hEventCounter", {HistType::kTH1F, {{4, 0.0f, 4.0f}}}}, - {"hCandidatesCounter", "hCandidatesCounter", {HistType::kTH1F, {{12, 0.0f, 12.0f}}}}, - {"hMassHypertriton", "hMassHypertriton", {HistType::kTH1F, {{80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"}}}}, - {"hMassAntiHypertriton", "hMassAntiHypertriton", {HistType::kTH1F, {{80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"}}}}, - {"hMassHypertritonTotal", "hMassHypertritonTotal", {HistType::kTH1F, {{300, 2.9f, 3.2f, "Inv. Mass (GeV/c^{2})"}}}}, - {"hPtProton", "hPtProton", {HistType::kTH1F, {{200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}}}, - {"hPtPionMinus", "hPtPionMinus", {HistType::kTH1F, {{200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}}}, - {"hPtDeuteron", "hPtDeuteron", {HistType::kTH1F, {{200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}}}, - {"hPtAntiProton", "hPtAntiProton", {HistType::kTH1F, {{200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}}}, - {"hPtPionPlus", "hPtPionPlus", {HistType::kTH1F, {{200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}}}, - {"hPtAntiDeuteron", "hPtAntiDeuteron", {HistType::kTH1F, {{200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}}}, - {"hDCAXYProtonToPV", "hDCAXYProtonToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCAXYPionToPV", "hDCAXYPionToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCAXYDeuteronToPV", "hDCAXYDeuteronToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCAProtonToPV", "hDCAProtonToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCAPionToPV", "hDCAPionToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hDCADeuteronToPV", "hDCADeuteronToPV", {HistType::kTH1F, {{1000, -10.0f, 10.0f, "cm"}}}}, - {"hProtonTPCNcls", "hProtonTPCNcls", {HistType::kTH1F, {{180, 0, 180, "TPC cluster"}}}}, - {"hPionTPCNcls", "hPionTPCNcls", {HistType::kTH1F, {{180, 0, 180, "TPC cluster"}}}}, - {"hDeuteronTPCNcls", "hDeuteronTPCNcls", {HistType::kTH1F, {{180, 0, 180, "TPC cluster"}}}}, - {"hVtxCosPA", "hVtxCosPA", {HistType::kTH1F, {{1000, 0.9f, 1.0f}}}}, - {"hDCAVtxDau", "hDCAVtxDau", {HistType::kTH1F, {{1000, 0.0f, 10.0f, "cm^{2}"}}}}, - {"hTOFPIDDeuteron", "hTOFPIDDeuteron", {HistType::kTH1F, {{2000, -100.0f, 100.0f}}}}, - {"hTPCPIDProton", "hTPCPIDProton", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hTPCPIDPion", "hTPCPIDPion", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hTPCPIDDeuteron", "hTPCPIDDeuteron", {HistType::kTH1F, {{120, -6.0f, 6.0f}}}}, - {"hProtonTPCBB", "hProtonTPCBB", {HistType::kTH2F, {{160, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hPionTPCBB", "hPionTPCBB", {HistType::kTH2F, {{160, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hDeuteronTPCBB", "hDeuteronTPCBB", {HistType::kTH2F, {{160, -8.0f, 8.0f, "p/z(GeV/c)"}, {200, 0.0f, 1000.0f, "TPCSignal"}}}}, - {"hProtonTPCVsPt", "hProtonTPCVsPt", {HistType::kTH2F, {{50, 0.0f, 5.0f, "#it{p}_{T} (GeV/c)"}, {120, -6.0f, 6.0f, "TPC n#sigma"}}}}, - {"hPionTPCVsPt", "hPionTPCVsPt", {HistType::kTH2F, {{20, 0.0f, 2.0f, "#it{p}_{T} (GeV/c)"}, {120, -6.0f, 6.0f, "TPC n#sigma"}}}}, - {"hDeuteronTPCVsPt", "hDeuteronTPCVsPt", {HistType::kTH2F, {{80, 0.0f, 8.0f, "#it{p}_{T} (GeV/c)"}, {120, -6.0f, 6.0f, "TPC n#sigma"}}}}, - {"hDeuteronTOFVsPBeforeTOFCut", "hDeuteronTOFVsPBeforeTOFCut", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"hDeuteronTOFVsPAfterTOFCut", "hDeuteronTOFVsPAfterTOFCut", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - - {"hDalitz", "hDalitz", {HistType::kTH2F, {{120, 7.85, 8.45, "M^{2}(dp) (GeV^{2}/c^{4})"}, {60, 1.1, 1.4, "M^{2}(p#pi) (GeV^{2}/c^{4})"}}}}, - {"h3dMassHypertriton", "h3dMassHypertriton", {HistType::kTH3F, {{20, 0.0f, 100.0f, "Cent (%)"}, {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}, {80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"}}}}, - {"h3dMassAntiHypertriton", "h3dMassAntiHypertriton", {HistType::kTH3F, {{20, 0.0f, 100.0f, "Cent (%)"}, {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}, {80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"}}}}, - {"h3dTotalHypertriton", "h3dTotalHypertriton", {HistType::kTH3F, {{50, 0, 50, "ct(cm)"}, {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}, {80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"}}}}, - - {"hDeuteronTOFVsPBeforeTOFCutSig", "hDeuteronTOFVsPBeforeTOFCutSig", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"hDeuteronTOFVsPAfterTOFCutSig", "hDeuteronTOFVsPAfterTOFCutSig", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"h3dTotalTrueHypertriton", "h3dTotalTrueHypertriton", {HistType::kTH3F, {{50, 0, 50, "ct(cm)"}, {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}, {80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"}}}}, - // For TOF PID check - /*{"hDeuteronDefaultTOFVsPBeforeTOFCut", "hDeuteronDefaultTOFVsPBeforeTOFCut", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"hDeuteronDefaultTOFVsPAtferTOFCut", "hDeuteronDefaultTOFVsPAtferTOFCut", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"hDeuteronDefaultTOFVsPBeforeTOFCutSig", "hDeuteronDefaultTOFVsPBeforeTOFCutSig", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"hDeuteronDefaultTOFVsPAfterTOFCutSig", "hDeuteronDefaultTOFVsPAfterTOFCutSig", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}},*/ - }, - }; - - //------------------------------------------------------------------ - // Fill stats histograms - enum vtxstep { kCandAll = 0, - kCandDauEta, - kCandDauPt, - kCandTPCNcls, - kCandTPCPID, - kCandTOFPID, - kCandDcaToPV, - kCandRapidity, - kCandct, - kCandCosPA, - kCandDcaDau, - kCandInvMass, - kNCandSteps }; - - struct { - std::array candstats; - std::array truecandstats; - } statisticsRegistry; - - void resetHistos() - { - for (Int_t ii = 0; ii < kNCandSteps; ii++) { - statisticsRegistry.candstats[ii] = 0; - statisticsRegistry.truecandstats[ii] = 0; - } - } - void FillCandCounter(int kn, bool istrue = false) - { - statisticsRegistry.candstats[kn]++; - if (istrue) { - statisticsRegistry.truecandstats[kn]++; - } - } - void fillHistos() - { - for (Int_t ii = 0; ii < kNCandSteps; ii++) { - registry.fill(HIST("hCandidatesCounter"), ii, statisticsRegistry.candstats[ii]); - if (doprocessMC == true) { - registry.fill(HIST("hTrueHypertritonCounter"), ii, statisticsRegistry.truecandstats[ii]); - } - } - } - - ConfigurableAxis dcaBinning{"dca-binning", {200, 0.0f, 1.0f}, ""}; - ConfigurableAxis ptBinning{"pt-binning", {200, 0.0f, 10.0f}, ""}; - - void init(InitContext const&) - { - registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(1, "total"); - registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(2, "sel8"); - registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(3, "vertexZ"); - registry.get(HIST("hEventCounter"))->GetXaxis()->SetBinLabel(4, "has Candidate"); - - if (doprocessMC == true) { - registry.add("hTrueHypertritonCounter", "hTrueHypertritonCounter", HistType::kTH1F, {{12, 0.0f, 12.0f}}); - auto hGeneratedHypertritonCounter = registry.add("hGeneratedHypertritonCounter", "hGeneratedHypertritonCounter", HistType::kTH1F, {{2, 0.0f, 2.0f}}); - hGeneratedHypertritonCounter->GetXaxis()->SetBinLabel(1, "Total"); - hGeneratedHypertritonCounter->GetXaxis()->SetBinLabel(2, "3-body decay"); - registry.add("hPtGeneratedHypertriton", "hPtGeneratedHypertriton", HistType::kTH1F, {{200, 0.0f, 10.0f}}); - registry.add("hctGeneratedHypertriton", "hctGeneratedHypertriton", HistType::kTH1F, {{50, 0, 50, "ct(cm)"}}); - registry.add("hEtaGeneratedHypertriton", "hEtaGeneratedHypertriton", HistType::kTH1F, {{40, -2.0f, 2.0f}}); - registry.add("hRapidityGeneratedHypertriton", "hRapidityGeneratedHypertriton", HistType::kTH1F, {{40, -2.0f, 2.0f}}); - registry.add("hPtGeneratedAntiHypertriton", "hPtGeneratedAntiHypertriton", HistType::kTH1F, {{200, 0.0f, 10.0f}}); - registry.add("hctGeneratedAntiHypertriton", "hctGeneratedAntiHypertriton", HistType::kTH1F, {{50, 0, 50, "ct(cm)"}}); - registry.add("hEtaGeneratedAntiHypertriton", "hEtaGeneratedAntiHypertriton", HistType::kTH1F, {{40, -2.0f, 2.0f}}); - registry.add("hRapidityGeneratedAntiHypertriton", "hRapidityGeneratedAntiHypertriton", HistType::kTH1F, {{40, -2.0f, 2.0f}}); - } - - TString CandCounterbinLabel[kNCandSteps] = {"Total", "TrackEta", "DauPt", "TPCNcls", "TPCPID", "d TOFPID", "PionDcatoPV", "MomRapidity", "Lifetime", "VtxCosPA", "VtxDcaDau", "InvMass"}; - for (int i{0}; i < kNCandSteps; i++) { - registry.get(HIST("hCandidatesCounter"))->GetXaxis()->SetBinLabel(i + 1, CandCounterbinLabel[i]); - if (doprocessMC == true) { - registry.get(HIST("hTrueHypertritonCounter"))->GetXaxis()->SetBinLabel(i + 1, CandCounterbinLabel[i]); - } - } - } - - //------------------------------------------------------------------ - // Selections for candidates - template - bool SelectCand(TCollisionTable const& collision, TCandTable const& candData, TTrackTable const& trackProton, TTrackTable const& trackPion, TTrackTable const& trackDeuteron, bool isMatter, bool isTrueCand = false, double MClifetime = -1, double lPt = -1) - { - FillCandCounter(kCandAll, isTrueCand); - - // Selection on daughters - if (std::abs(trackProton.eta()) > etacut || std::abs(trackPion.eta()) > etacut || std::abs(trackDeuteron.eta()) > etacut) { - return false; - } - FillCandCounter(kCandDauEta, isTrueCand); - - if (trackProton.pt() < minProtonPt || trackProton.pt() > maxProtonPt || trackPion.pt() < minPionPt || trackPion.pt() > maxPionPt || trackDeuteron.pt() < minDeuteronPt || trackDeuteron.pt() > maxDeuteronPt) { - return false; - } - FillCandCounter(kCandDauPt, isTrueCand); - - if (trackProton.tpcNClsFound() < mintpcNClsproton || trackPion.tpcNClsFound() < mintpcNClspion || trackDeuteron.tpcNClsFound() < mintpcNClsdeuteron) { - return false; - } - FillCandCounter(kCandTPCNcls, isTrueCand); - - if (std::abs(trackProton.tpcNSigmaPr()) > TpcPidNsigmaCut || std::abs(trackPion.tpcNSigmaPi()) > TpcPidNsigmaCut || std::abs(trackDeuteron.tpcNSigmaDe()) > TpcPidNsigmaCut) { - return false; - } - FillCandCounter(kCandTPCPID, isTrueCand); - - // registry.fill(HIST("hDeuteronDefaultTOFVsPBeforeTOFCut"), trackDeuteron.sign() * trackDeuteron.p(), trackDeuteron.tofNSigmaDe()); - registry.fill(HIST("hDeuteronTOFVsPBeforeTOFCut"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - if (isTrueCand) { - // registry.fill(HIST("hDeuteronDefaultTOFVsPBeforeTOFCutSig"), trackDeuteron.sign() * trackDeuteron.p(), trackDeuteron.tofNSigmaDe()); - registry.fill(HIST("hDeuteronTOFVsPBeforeTOFCutSig"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - } - if ((candData.tofNSigmaBachDe() < TofPidNsigmaMin || candData.tofNSigmaBachDe() > TofPidNsigmaMax) && trackDeuteron.p() > minDeuteronPUseTOF) { - return false; - } - FillCandCounter(kCandTOFPID, isTrueCand); - // registry.fill(HIST("hDeuteronDefaultTOFVsPAtferTOFCut"), trackDeuteron.sign() * trackDeuteron.p(), trackDeuteron.tofNSigmaDe()); - registry.fill(HIST("hDeuteronTOFVsPAfterTOFCut"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - if (isTrueCand) { - // registry.fill(HIST("hDeuteronDefaultTOFVsPAfterTOFCutSig"), trackDeuteron.sign() * trackDeuteron.p(), trackDeuteron.tofNSigmaDe()); - registry.fill(HIST("hDeuteronTOFVsPAfterTOFCutSig"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - } - - double dcapion = isMatter ? candData.dcatrack1topv() : candData.dcatrack0topv(); - if (std::abs(dcapion) < dcapiontopv) { - return false; - } - FillCandCounter(kCandDcaToPV, isTrueCand); - - // Selection on candidate hypertriton - if (std::abs(candData.yHypertriton()) > rapiditycut) { - return false; - } - FillCandCounter(kCandRapidity, isTrueCand); - - double ct = candData.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassHyperTriton; - if (ct > lifetimecut) { - return false; - } - FillCandCounter(kCandct, isTrueCand); - - double cospa = candData.vtxcosPA(collision.posX(), collision.posY(), collision.posZ()); - if (cospa < vtxcospa) { - return false; - } - FillCandCounter(kCandCosPA, isTrueCand); - - if (candData.dcaVtxdaughters() > dcavtxdau) { - return false; - } - FillCandCounter(kCandDcaDau, isTrueCand); - - if ((isMatter && candData.mHypertriton() > h3LMassLowerlimit && candData.mHypertriton() < h3LMassUpperlimit)) { - // Hypertriton - registry.fill(HIST("hPtProton"), trackProton.pt()); - registry.fill(HIST("hPtPionMinus"), trackPion.pt()); - registry.fill(HIST("hPtDeuteron"), trackDeuteron.pt()); - registry.fill(HIST("hDCAXYProtonToPV"), candData.dcaXYtrack0topv()); - registry.fill(HIST("hDCAXYPionToPV"), candData.dcaXYtrack1topv()); - registry.fill(HIST("hDCAProtonToPV"), candData.dcatrack0topv()); - registry.fill(HIST("hDCAPionToPV"), candData.dcatrack1topv()); - - registry.fill(HIST("hMassHypertriton"), candData.mHypertriton()); - registry.fill(HIST("hMassHypertritonTotal"), candData.mHypertriton()); - registry.fill(HIST("h3dMassHypertriton"), 0., candData.pt(), candData.mHypertriton()); // collision.centV0M() instead of 0. once available - registry.fill(HIST("h3dTotalHypertriton"), ct, candData.pt(), candData.mHypertriton()); - if (candData.mHypertriton() > lowersignallimit && candData.mHypertriton() < uppersignallimit) { - registry.fill(HIST("hDalitz"), RecoDecay::m2(array{array{candData.pxtrack0(), candData.pytrack0(), candData.pztrack0()}, array{candData.pxtrack2(), candData.pytrack2(), candData.pztrack2()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}), RecoDecay::m2(array{array{candData.pxtrack0(), candData.pytrack0(), candData.pztrack0()}, array{candData.pxtrack1(), candData.pytrack1(), candData.pztrack1()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged})); - } - if (isTrueCand) { - registry.fill(HIST("h3dTotalTrueHypertriton"), MClifetime, lPt, candData.mHypertriton()); - } - } else if ((!isMatter && candData.mAntiHypertriton() > h3LMassLowerlimit && candData.mAntiHypertriton() < h3LMassUpperlimit)) { - // AntiHypertriton - registry.fill(HIST("hPtAntiProton"), trackProton.pt()); - registry.fill(HIST("hPtPionPlus"), trackPion.pt()); - registry.fill(HIST("hPtAntiDeuteron"), trackDeuteron.pt()); - registry.fill(HIST("hDCAXYProtonToPV"), candData.dcaXYtrack1topv()); - registry.fill(HIST("hDCAXYPionToPV"), candData.dcaXYtrack0topv()); - registry.fill(HIST("hDCAProtonToPV"), candData.dcatrack1topv()); - registry.fill(HIST("hDCAPionToPV"), candData.dcatrack0topv()); - - registry.fill(HIST("hMassAntiHypertriton"), candData.mAntiHypertriton()); - registry.fill(HIST("hMassHypertritonTotal"), candData.mAntiHypertriton()); - registry.fill(HIST("h3dMassAntiHypertriton"), 0., candData.pt(), candData.mAntiHypertriton()); // collision.centV0M() instead of 0. once available - registry.fill(HIST("h3dTotalHypertriton"), ct, candData.pt(), candData.mAntiHypertriton()); - if (candData.mAntiHypertriton() > lowersignallimit && candData.mAntiHypertriton() < uppersignallimit) { - registry.fill(HIST("hDalitz"), RecoDecay::m2(array{array{candData.pxtrack1(), candData.pytrack1(), candData.pztrack1()}, array{candData.pxtrack2(), candData.pytrack2(), candData.pztrack2()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron}), RecoDecay::m2(array{array{candData.pxtrack1(), candData.pytrack1(), candData.pztrack1()}, array{candData.pxtrack0(), candData.pytrack0(), candData.pztrack0()}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged})); - } - if (isTrueCand) { - registry.fill(HIST("h3dTotalTrueHypertriton"), MClifetime, lPt, candData.mHypertriton()); - } - } else { - return false; - } - - FillCandCounter(kCandInvMass, isTrueCand); - - registry.fill(HIST("hDCAXYDeuteronToPV"), candData.dcaXYtrack2topv()); - registry.fill(HIST("hDCADeuteronToPV"), candData.dcatrack2topv()); - registry.fill(HIST("hVtxCosPA"), candData.vtxcosPA(collision.posX(), collision.posY(), collision.posZ())); - registry.fill(HIST("hDCAVtxDau"), candData.dcaVtxdaughters()); - registry.fill(HIST("hProtonTPCNcls"), trackProton.tpcNClsCrossedRows()); - registry.fill(HIST("hPionTPCNcls"), trackPion.tpcNClsCrossedRows()); - registry.fill(HIST("hDeuteronTPCNcls"), trackDeuteron.tpcNClsCrossedRows()); - registry.fill(HIST("hTPCPIDProton"), trackProton.tpcNSigmaPr()); - registry.fill(HIST("hTPCPIDPion"), trackPion.tpcNSigmaPi()); - registry.fill(HIST("hTPCPIDDeuteron"), trackDeuteron.tpcNSigmaDe()); - registry.fill(HIST("hProtonTPCBB"), trackProton.sign() * trackProton.p(), trackProton.tpcSignal()); - registry.fill(HIST("hPionTPCBB"), trackPion.sign() * trackPion.p(), trackPion.tpcSignal()); - registry.fill(HIST("hDeuteronTPCBB"), trackDeuteron.sign() * trackDeuteron.p(), trackDeuteron.tpcSignal()); - registry.fill(HIST("hProtonTPCVsPt"), trackProton.pt(), trackProton.tpcNSigmaPr()); - registry.fill(HIST("hPionTPCVsPt"), trackProton.pt(), trackPion.tpcNSigmaPi()); - registry.fill(HIST("hDeuteronTPCVsPt"), trackDeuteron.pt(), trackDeuteron.tpcNSigmaDe()); - registry.fill(HIST("hTOFPIDDeuteron"), candData.tofNSigmaBachDe()); - - return true; - } - - //------------------------------------------------------------------ - // Analysis process for a single candidate - template - void CandidateAnalysis(TCollisionTable const& collision, TCandTable const& candData, bool& if_hasvtx, bool isTrueCand = false, double MClifetime = -1, double lPt = -1) - { - - auto track0 = candData.template track0_as(); - auto track1 = candData.template track1_as(); - auto track2 = candData.template track2_as(); - - bool isMatter = track2.sign() > 0; - - auto& trackProton = isMatter ? track0 : track1; - auto& trackPion = isMatter ? track1 : track0; - auto& trackDeuteron = track2; - - if (SelectCand(collision, candData, trackProton, trackPion, trackDeuteron, isMatter, isTrueCand, MClifetime, lPt)) { - if_hasvtx = true; - } - } - - //------------------------------------------------------------------ - // collect information for generated hypertriton (should be called after event selection) - void GetGeneratedH3LInfo(aod::McParticles const& particlesMC) - { - for (auto& mcparticle : particlesMC) { - if (std::abs(mcparticle.pdgCode()) != motherPdgCode) { - continue; - } - registry.fill(HIST("hGeneratedHypertritonCounter"), 0.5); - - bool haveProton = false, havePionPlus = false, haveDeuteron = false; - bool haveAntiProton = false, havePionMinus = false, haveAntiDeuteron = false; - double MClifetime = -1; - for (auto& mcparticleDaughter : mcparticle.template daughters_as()) { - if (mcparticleDaughter.pdgCode() == 2212) - haveProton = true; - if (mcparticleDaughter.pdgCode() == -2212) - haveAntiProton = true; - if (mcparticleDaughter.pdgCode() == 211) - havePionPlus = true; - if (mcparticleDaughter.pdgCode() == -211) - havePionMinus = true; - if (mcparticleDaughter.pdgCode() == bachelorPdgCode) { - haveDeuteron = true; - MClifetime = RecoDecay::sqrtSumOfSquares(mcparticleDaughter.vx() - mcparticle.vx(), mcparticleDaughter.vy() - mcparticle.vy(), mcparticleDaughter.vz() - mcparticle.vz()) * o2::constants::physics::MassHyperTriton / mcparticle.p(); - } - if (mcparticleDaughter.pdgCode() == -bachelorPdgCode) { - haveAntiDeuteron = true; - MClifetime = RecoDecay::sqrtSumOfSquares(mcparticleDaughter.vx() - mcparticle.vx(), mcparticleDaughter.vy() - mcparticle.vy(), mcparticleDaughter.vz() - mcparticle.vz()) * o2::constants::physics::MassHyperTriton / mcparticle.p(); - } - } - if (haveProton && havePionMinus && haveDeuteron && mcparticle.pdgCode() == motherPdgCode) { - registry.fill(HIST("hGeneratedHypertritonCounter"), 1.5); - registry.fill(HIST("hPtGeneratedHypertriton"), mcparticle.pt()); - registry.fill(HIST("hctGeneratedHypertriton"), MClifetime); - registry.fill(HIST("hEtaGeneratedHypertriton"), mcparticle.eta()); - registry.fill(HIST("hRapidityGeneratedHypertriton"), mcparticle.y()); - } else if (haveAntiProton && havePionPlus && haveAntiDeuteron && mcparticle.pdgCode() == -motherPdgCode) { - registry.fill(HIST("hGeneratedHypertritonCounter"), 1.5); - registry.fill(HIST("hPtGeneratedAntiHypertriton"), mcparticle.pt()); - registry.fill(HIST("hctGeneratedAntiHypertriton"), MClifetime); - registry.fill(HIST("hEtaGeneratedAntiHypertriton"), mcparticle.eta()); - registry.fill(HIST("hRapidityGeneratedAntiHypertriton"), mcparticle.y()); - } - } - } - - //------------------------------------------------------------------ - // process real data analysis - void processData(soa::Join::iterator const& collision, aod::Vtx3BodyDatas const& vtx3bodydatas, FullTracksExtIU const& /*tracks*/) - { - registry.fill(HIST("hEventCounter"), 0.5); - if (event_sel8_selection && !collision.sel8()) { - return; - } - registry.fill(HIST("hEventCounter"), 1.5); - if (event_posZ_selection && abs(collision.posZ()) > 10.f) { // 10cm - return; - } - registry.fill(HIST("hEventCounter"), 2.5); - - bool if_hasvtx = false; - - for (auto& vtx : vtx3bodydatas) { - CandidateAnalysis(collision, vtx, if_hasvtx); - } - - if (if_hasvtx) - registry.fill(HIST("hEventCounter"), 3.5); - fillHistos(); - resetHistos(); - } - PROCESS_SWITCH(hypertriton3bodyAnalysis, processData, "Real data analysis", true); - - //------------------------------------------------------------------ - // process mc analysis - void processMC(soa::Join const& collisions, aod::Vtx3BodyDatas const& vtx3bodydatas, aod::McParticles const& particlesMC, MCLabeledTracksIU const& /*tracks*/) - { - GetGeneratedH3LInfo(particlesMC); - - for (const auto& collision : collisions) { - registry.fill(HIST("hEventCounter"), 0.5); - if (mc_event_selection && (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { - continue; - } - registry.fill(HIST("hEventCounter"), 1.5); - if (event_posZ_selection && abs(collision.posZ()) > 10.f) { // 10cm - continue; - } - registry.fill(HIST("hEventCounter"), 2.5); - - bool if_hasvtx = false; - auto vtxsthiscol = vtx3bodydatas.sliceBy(perCollisionVtx3BodyDatas, collision.globalIndex()); - - for (auto& vtx : vtxsthiscol) { - // int lLabel = -1; - int lPDG = -1; - float lPt = -1; - double MClifetime = -1; - bool isTrueCand = false; - auto track0 = vtx.track0_as(); - auto track1 = vtx.track1_as(); - auto track2 = vtx.track2_as(); - if (track0.has_mcParticle() && track1.has_mcParticle() && track2.has_mcParticle()) { - auto lMCTrack0 = track0.mcParticle_as(); - auto lMCTrack1 = track1.mcParticle_as(); - auto lMCTrack2 = track2.mcParticle_as(); - if (lMCTrack0.has_mothers() && lMCTrack1.has_mothers() && lMCTrack2.has_mothers()) { - for (auto& lMother0 : lMCTrack0.mothers_as()) { - for (auto& lMother1 : lMCTrack1.mothers_as()) { - for (auto& lMother2 : lMCTrack2.mothers_as()) { - if (lMother0.globalIndex() == lMother1.globalIndex() && lMother0.globalIndex() == lMother2.globalIndex()) { - // lLabel = lMother1.globalIndex(); - lPt = lMother1.pt(); - lPDG = lMother1.pdgCode(); - if ((lPDG == motherPdgCode && lMCTrack0.pdgCode() == 2212 && lMCTrack1.pdgCode() == -211 && lMCTrack2.pdgCode() == bachelorPdgCode) || - (lPDG == -motherPdgCode && lMCTrack0.pdgCode() == 211 && lMCTrack1.pdgCode() == -2212 && lMCTrack2.pdgCode() == -bachelorPdgCode)) { - isTrueCand = true; - MClifetime = RecoDecay::sqrtSumOfSquares(lMCTrack2.vx() - lMother2.vx(), lMCTrack2.vy() - lMother2.vy(), lMCTrack2.vz() - lMother2.vz()) * o2::constants::physics::MassHyperTriton / lMother2.p(); - } - } - } - } - } - } - } - - CandidateAnalysis(collision, vtx, if_hasvtx, isTrueCand, MClifetime, lPt); - } - - if (if_hasvtx) - registry.fill(HIST("hEventCounter"), 3.5); - fillHistos(); - resetHistos(); - } - } - PROCESS_SWITCH(hypertriton3bodyAnalysis, processMC, "MC analysis", false); -}; - -// check vtx3body with mclabels -struct hypertriton3bodyLabelCheck { - - Configurable mc_event_selection{"mc_event_selection", true, "mc event selection count post kIsTriggerTVX and kNoTimeFrameBorder"}; - Configurable event_posZ_selection{"event_posZ_selection", false, "event selection count post poZ cut"}; - Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; - Configurable motherPdgCode{"motherPdgCode", 1010010030, "pdgCode of mother track"}; - - HistogramRegistry registry{"registry", {}}; - - void init(InitContext const&) - { - if (doprocessData == false) { - auto hLabeledVtxCounter = registry.add("hLabeledVtxCounter", "hLabeledVtxCounter", HistType::kTH1F, {{3, 0.0f, 3.0f}}); - hLabeledVtxCounter->GetXaxis()->SetBinLabel(1, "Readin"); - hLabeledVtxCounter->GetXaxis()->SetBinLabel(2, "TrueMCH3L"); - hLabeledVtxCounter->GetXaxis()->SetBinLabel(3, "Nonrepetitive"); - registry.add("hMassTrueH3L", "hMassTrueH3L", HistType::kTH1F, {{80, 2.96f, 3.04f}}); - registry.add("hMassTrueH3LMatter", "hMassTrueH3LMatter", HistType::kTH1F, {{80, 2.96f, 3.04f}}); - registry.add("hMassTrueH3LAntiMatter", "hMassTrueH3LAntiMatter", HistType::kTH1F, {{80, 2.96f, 3.04f}}); - auto hPIDCounter = registry.add("hPIDCounter", "hPIDCounter", HistType::kTH1F, {{6, 0.0f, 6.0f}}); - hPIDCounter->GetXaxis()->SetBinLabel(1, "H3L Proton PID > 5"); - hPIDCounter->GetXaxis()->SetBinLabel(2, "H3L Pion PID > 5"); - hPIDCounter->GetXaxis()->SetBinLabel(3, "H3L Deuteron PID > 5"); - hPIDCounter->GetXaxis()->SetBinLabel(4, "#bar{H3L} Proton PID > 5"); - hPIDCounter->GetXaxis()->SetBinLabel(5, "#bar{H3L} Pion PID > 5"); - hPIDCounter->GetXaxis()->SetBinLabel(6, "#bar{H3L} Deuteron PID > 5"); - auto hHypertritonCounter = registry.add("hHypertritonCounter", "hHypertritonCounter", HistType::kTH1F, {{4, 0.0f, 4.0f}}); - hHypertritonCounter->GetXaxis()->SetBinLabel(1, "H3L"); - hHypertritonCounter->GetXaxis()->SetBinLabel(2, "H3L daughters pass PID"); - hHypertritonCounter->GetXaxis()->SetBinLabel(3, "#bar{H3L}"); - hHypertritonCounter->GetXaxis()->SetBinLabel(4, "#bar{H3L} daughters pass PID"); - auto hDecay3BodyCounter = registry.add("hDecay3BodyCounter", "hDecay3BodyCounter", HistType::kTH1F, {{5, 0.0f, 5.0f}}); - hDecay3BodyCounter->GetXaxis()->SetBinLabel(1, "Total"); - hDecay3BodyCounter->GetXaxis()->SetBinLabel(2, "True H3L"); - hDecay3BodyCounter->GetXaxis()->SetBinLabel(3, "Unduplicated H3L"); - hDecay3BodyCounter->GetXaxis()->SetBinLabel(4, "Correct collision"); - hDecay3BodyCounter->GetXaxis()->SetBinLabel(5, "Same ColID for daughters"); - registry.add("hDiffRVtxProton", "hDiffRVtxProton", HistType::kTH1F, {{100, -10, 10}}); // difference between the radius of decay vertex and minR of proton - registry.add("hDiffRVtxPion", "hDiffRVtxPion", HistType::kTH1F, {{100, -10, 10}}); // difference between the radius of decay vertex and minR of pion - registry.add("hDiffRVtxDeuteron", "hDiffRVtxDeuteron", HistType::kTH1F, {{100, -10, 10}}); // difference between the radius of decay vertex and minR of deuteron - } - } - - struct Indexdaughters { // check duplicated paired daughters - int64_t index0; - int64_t index1; - int64_t index2; - bool operator==(const Indexdaughters& t) const - { - return (this->index0 == t.index0 && this->index1 == t.index1 && this->index2 == t.index2); - } - }; - - void processData(soa::Join::iterator const&) - { - // dummy function - } - PROCESS_SWITCH(hypertriton3bodyLabelCheck, processData, "Donot check MC label tables", true); - - void processCheckLabel(soa::Join::iterator const& collision, aod::Decay3Bodys const& decay3bodys, soa::Join const& vtx3bodydatas, MCLabeledTracksIU const& /*tracks*/, aod::McParticles const& /*particlesMC*/, aod::McCollisions const& /*mcCollisions*/) - { - // check the decay3body table - std::vector set_pair; - for (auto& d3body : decay3bodys) { - registry.fill(HIST("hDecay3BodyCounter"), 0.5); - auto lTrack0 = d3body.track0_as(); - auto lTrack1 = d3body.track1_as(); - auto lTrack2 = d3body.track2_as(); - if (!lTrack0.has_mcParticle() || !lTrack1.has_mcParticle() || !lTrack2.has_mcParticle()) { - continue; - } - auto lMCTrack0 = lTrack0.mcParticle_as(); - auto lMCTrack1 = lTrack1.mcParticle_as(); - auto lMCTrack2 = lTrack2.mcParticle_as(); - if (!lMCTrack0.has_mothers() || !lMCTrack1.has_mothers() || !lMCTrack2.has_mothers()) { - continue; - } - - for (auto& lMother0 : lMCTrack0.mothers_as()) { - for (auto& lMother1 : lMCTrack1.mothers_as()) { - for (auto& lMother2 : lMCTrack2.mothers_as()) { - if (lMother0.globalIndex() == lMother1.globalIndex() && lMother0.globalIndex() == lMother2.globalIndex()) { - registry.fill(HIST("hDecay3BodyCounter"), 1.5); - // duplicated daughters check - Indexdaughters temp = {lMCTrack0.globalIndex(), lMCTrack1.globalIndex(), lMCTrack2.globalIndex()}; - auto p = std::find(set_pair.begin(), set_pair.end(), temp); - if (p == set_pair.end()) { - set_pair.push_back(temp); - registry.fill(HIST("hDecay3BodyCounter"), 2.5); - if (lMother0.mcCollisionId() == collision.mcCollisionId()) { - registry.fill(HIST("hDecay3BodyCounter"), 3.5); - if (lTrack0.collisionId() == lTrack1.collisionId() && lTrack0.collisionId() == lTrack2.collisionId()) { - registry.fill(HIST("hDecay3BodyCounter"), 4.5); - } - } - } - } - } - } - } - } - - if (mc_event_selection && (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { - return; - } - - if (event_posZ_selection && abs(collision.posZ()) > 10.f) { // 10cm - return; - } - - std::vector set_mothertrack; - for (auto& vtx : vtx3bodydatas) { - registry.fill(HIST("hLabeledVtxCounter"), 0.5); - if (vtx.mcParticleId() != -1) { - auto mcparticle = vtx.mcParticle_as(); - auto lTrack0 = vtx.track0_as(); - auto lTrack1 = vtx.track1_as(); - auto lTrack2 = vtx.track2_as(); - if (std::abs(mcparticle.pdgCode()) != motherPdgCode) { - continue; - } - registry.fill(HIST("hLabeledVtxCounter"), 1.5); - registry.fill(HIST("hDiffRVtxDeuteron"), lTrack2.x() - vtx.vtxradius()); - if (mcparticle.pdgCode() > 0) { - registry.fill(HIST("hHypertritonCounter"), 0.5); - registry.fill(HIST("hMassTrueH3L"), vtx.mHypertriton()); - registry.fill(HIST("hMassTrueH3LMatter"), vtx.mHypertriton()); - registry.fill(HIST("hDiffRVtxProton"), lTrack0.x() - vtx.vtxradius()); - registry.fill(HIST("hDiffRVtxPion"), lTrack1.x() - vtx.vtxradius()); - auto p = std::find(set_mothertrack.begin(), set_mothertrack.end(), mcparticle.globalIndex()); - if (p == set_mothertrack.end()) { - set_mothertrack.push_back(mcparticle.globalIndex()); - registry.fill(HIST("hLabeledVtxCounter"), 2.5); - } - if (TMath::Abs(lTrack0.tpcNSigmaPr()) > TpcPidNsigmaCut) { - registry.fill(HIST("hPIDCounter"), 0.5); - } - if (TMath::Abs(lTrack1.tpcNSigmaPi()) > TpcPidNsigmaCut) { - registry.fill(HIST("hPIDCounter"), 1.5); - } - if (TMath::Abs(lTrack2.tpcNSigmaDe()) > TpcPidNsigmaCut) { - registry.fill(HIST("hPIDCounter"), 2.5); - } - if (TMath::Abs(lTrack0.tpcNSigmaPr()) < TpcPidNsigmaCut && TMath::Abs(lTrack1.tpcNSigmaPi()) < TpcPidNsigmaCut && TMath::Abs(lTrack2.tpcNSigmaDe()) < TpcPidNsigmaCut) { - registry.fill(HIST("hHypertritonCounter"), 1.5); - } - } else { - registry.fill(HIST("hHypertritonCounter"), 2.5); - registry.fill(HIST("hMassTrueH3L"), vtx.mAntiHypertriton()); - registry.fill(HIST("hMassTrueH3LAntiMatter"), vtx.mAntiHypertriton()); - registry.fill(HIST("hDiffRVtxProton"), lTrack1.x() - vtx.vtxradius()); - registry.fill(HIST("hDiffRVtxPion"), lTrack0.x() - vtx.vtxradius()); - auto p = std::find(set_mothertrack.begin(), set_mothertrack.end(), mcparticle.globalIndex()); - if (p == set_mothertrack.end()) { - set_mothertrack.push_back(mcparticle.globalIndex()); - registry.fill(HIST("hLabeledVtxCounter"), 2.5); - } - if (TMath::Abs(lTrack0.tpcNSigmaPi()) > TpcPidNsigmaCut) { - registry.fill(HIST("hPIDCounter"), 4.5); - } - if (TMath::Abs(lTrack1.tpcNSigmaPr()) > TpcPidNsigmaCut) { - registry.fill(HIST("hPIDCounter"), 3.5); - } - if (TMath::Abs(lTrack2.tpcNSigmaDe()) > TpcPidNsigmaCut) { - registry.fill(HIST("hPIDCounter"), 5.5); - } - if (TMath::Abs(lTrack0.tpcNSigmaPi()) < TpcPidNsigmaCut && TMath::Abs(lTrack1.tpcNSigmaPr()) < TpcPidNsigmaCut && TMath::Abs(lTrack2.tpcNSigmaDe()) < TpcPidNsigmaCut) { - registry.fill(HIST("hHypertritonCounter"), 3.5); - } - } - } - } - } - PROCESS_SWITCH(hypertriton3bodyLabelCheck, processCheckLabel, "Check MC label tables", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - }; -} diff --git a/PWGLF/Tasks/Nuspex/hypertritonAnalysis.cxx b/PWGLF/Tasks/Nuspex/hypertritonAnalysis.cxx index 8a296edc5b5..42470a606b0 100644 --- a/PWGLF/Tasks/Nuspex/hypertritonAnalysis.cxx +++ b/PWGLF/Tasks/Nuspex/hypertritonAnalysis.cxx @@ -218,7 +218,7 @@ struct hypertritonAnalysis { auto bc = collision.bc_as(); initCCDB(bc); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; evselstats[kEvSelAll]++; if (event_sel8_selection && !collision.sel8()) { @@ -324,7 +324,7 @@ struct hypertritonAnalysis { auto bc = collision.bc_as(); initCCDB(bc); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; evselstats[kEvSelAll]++; if (event_sel8_selection && !collision.sel8()) { diff --git a/PWGLF/Tasks/Nuspex/nucleiFromHypertritonMap.cxx b/PWGLF/Tasks/Nuspex/nucleiFromHypertritonMap.cxx index ace8de3fa99..2d959f9488d 100644 --- a/PWGLF/Tasks/Nuspex/nucleiFromHypertritonMap.cxx +++ b/PWGLF/Tasks/Nuspex/nucleiFromHypertritonMap.cxx @@ -79,50 +79,86 @@ struct nucleiFromHypertritonMap { void init(InitContext const&) { - registryMC.add("hypertritonPtgen", "hypertritonPtGen", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); + registryMC.add("hypertritonPtGen", "hypertritonPtGen", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); if (saveHelium) { registryMC.add("he3SecPtRec_from_hypertriton", "he3SecPtRec_from_hypertriton", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); - registryMC.add("hyperHe4Ptgen", "hyperHe4PtGen", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); + registryMC.add("hyperHe4PtGen", "hyperHe4PtGen", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); registryMC.add("he3SecPtRec_from_hyperHe4", "he3SecPtRec_from_hyperHe4", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); + registryMC.add("he3PtRec", "he3PtRec", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); + registryMC.add("he3PtGen", "he3PtGen", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); } else { registryMC.add("deutSecPtRec_from_hypertriton", "deutSecPtRec_from_hypertriton", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); + registryMC.add("deutPtRec", "deutPtRec", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); + registryMC.add("deutPtGen", "deutPtGen", HistType::kTH1F, {{nbin_pt, min_pt, max_pt, "p_{T} (GeV/c)"}}); } } - void processMC(aod::McParticles const& /*mcParticles*/, const MCTracks& tracks) + void processMC(const aod::McParticles& mcParticles, const MCTracks& tracks) { + int selectedPDG = 0; + if (saveHelium) { + selectedPDG = AntihePDG; + } else { + selectedPDG = AntideuteronPDG; + } + + for (const auto& mcparticle : mcParticles) { + if (((mcparticle.pdgCode() == AntiHypertritonPDG || mcparticle.pdgCode() == AntiHyperHelium4PDG) && mcparticle.has_daughters()) || mcparticle.pdgCode() == selectedPDG) { + if (mcparticle.pdgCode() == AntiHypertritonPDG) { + for (auto& daughter : mcparticle.daughters_as()) { + if (daughter.pdgCode() == selectedPDG) { + registryMC.fill(HIST("hypertritonPtGen"), mcparticle.pt()); + } + } + } + if (mcparticle.pdgCode() == AntiHyperHelium4PDG) { + for (auto& daughter : mcparticle.daughters_as()) { + if (daughter.pdgCode() == selectedPDG) { + registryMC.fill(HIST("hyperHe4PtGen"), mcparticle.pt()); + } + } + } + if (mcparticle.pdgCode() == AntihePDG && mcparticle.isPhysicalPrimary()) { + registryMC.fill(HIST("he3PtGen"), mcparticle.pt()); + } + if (mcparticle.pdgCode() == AntideuteronPDG && mcparticle.isPhysicalPrimary()) { + registryMC.fill(HIST("deutPtGen"), mcparticle.pt()); + } + } + } + for (const auto& track : tracks) { if (!track.has_mcParticle()) { continue; } auto mcparticle = track.mcParticle(); - if (saveHelium) { - if (mcparticle.pdgCode() != AntihePDG || mcparticle.isPhysicalPrimary()) { - continue; - } - } else { - if (mcparticle.pdgCode() != AntideuteronPDG || mcparticle.isPhysicalPrimary()) { - continue; - } + if (mcparticle.pdgCode() != selectedPDG) { + continue; + } + + if (track.itsNCls() < min_ITS_nClusters || + track.tpcNClsFound() < min_TPC_nClusters || + track.tpcNClsCrossedRows() < min_TPC_nCrossedRows || + track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || + track.tpcChi2NCl() > 4.f || + track.tpcChi2NCl() < min_chi2_TPC || + track.eta() < min_eta || track.eta() > max_eta || + track.dcaXY() > max_dcaxy || track.dcaXY() < -max_dcaxy || + track.dcaZ() > max_dcaz || track.dcaZ() < -max_dcaz || + track.itsChi2NCl() > 36.f) { + continue; + } + if (mcparticle.pdgCode() == AntideuteronPDG && mcparticle.isPhysicalPrimary()) { + registryMC.fill(HIST("deutPtRec"), track.pt()); + } + if (mcparticle.pdgCode() == AntihePDG && mcparticle.isPhysicalPrimary()) { + registryMC.fill(HIST("he3PtRec"), 2 * track.pt()); } for (auto& motherparticle : mcparticle.mothers_as()) { if (motherparticle.pdgCode() == AntiHypertritonPDG || motherparticle.pdgCode() == AntiHyperHelium4PDG) { - if (track.itsNCls() < min_ITS_nClusters || - track.tpcNClsFound() < min_TPC_nClusters || - track.tpcNClsCrossedRows() < min_TPC_nCrossedRows || - track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || - track.tpcChi2NCl() > 4.f || - track.tpcChi2NCl() < min_chi2_TPC || - track.eta() < min_eta || track.eta() > max_eta || - track.dcaXY() > max_dcaxy || track.dcaXY() < -max_dcaxy || - track.dcaZ() > max_dcaz || track.dcaZ() < -max_dcaz || - track.itsChi2NCl() > 36.f) { - continue; - } if (motherparticle.pdgCode() == AntiHypertritonPDG) { - registryMC.fill(HIST("hypertritonPtgen"), motherparticle.pt()); - if (saveHelium) { + if (mcparticle.pdgCode() == AntihePDG) { registryMC.fill(HIST("he3SecPtRec_from_hypertriton"), 2 * track.pt()); } else { registryMC.fill(HIST("deutSecPtRec_from_hypertriton"), track.pt()); @@ -130,7 +166,6 @@ struct nucleiFromHypertritonMap { } if (motherparticle.pdgCode() == AntiHyperHelium4PDG) { registryMC.fill(HIST("he3SecPtRec_from_hyperHe4"), 2 * track.pt()); - registryMC.fill(HIST("hyperHe4Ptgen"), motherparticle.pt()); } } } diff --git a/PWGLF/Tasks/Nuspex/nuclei_in_jets.cxx b/PWGLF/Tasks/Nuspex/nuclei_in_jets.cxx deleted file mode 100644 index ab26df26ea1..00000000000 --- a/PWGLF/Tasks/Nuspex/nuclei_in_jets.cxx +++ /dev/null @@ -1,1343 +0,0 @@ -// 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 Alberto Caliva (alberto.caliva@cern.ch) -/// \since November 22, 2023 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "TGrid.h" -#include - -#include "CCDB/BasicCCDBManager.h" -#include "CCDB/CcdbApi.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/RunningWorkflowInfo.h" -#include "Framework/DataTypes.h" -#include "ReconstructionDataFormats/Track.h" -#include "ReconstructionDataFormats/PID.h" -#include "ReconstructionDataFormats/DCA.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" - -using namespace std; -using namespace o2; -using namespace o2::soa; -using namespace o2::aod; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::constants::physics; -using std::array; - -using SelectedCollisions = soa::Join; -using SimCollisions = soa::Join; - -using FullNucleiTracks = soa::Join; - -using MCTracks = soa::Join; - -struct nuclei_in_jets { - - // QC Histograms - HistogramRegistry registryQC{ - "registryQC", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - - // Analysis Histograms: Data - HistogramRegistry registryData{ - "registryData", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - - // Analysis Histograms: MC - HistogramRegistry registryMC{ - "registryMC", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - - // Global Parameters - Configurable min_jet_pt{"min_jet_pt", 10.0, "Minimum pt of the jet"}; - Configurable Rjet{"Rjet", 0.3, "Jet resolution parameter R"}; - Configurable zVtx{"zVtx", 10.0, "Maximum zVertex"}; - Configurable min_nPartInJet{"min_nPartInJet", 2, "Minimum number of particles inside jet"}; - Configurable n_jets_per_event_max{"n_jets_per_event_max", 1000, "Maximum number of jets per event"}; - Configurable requireNoOverlap{"requireNoOverlap", false, "require no overlap between jets and UE cones"}; - - // Track Parameters - Configurable par0{"par0", 0.004, "par 0"}; - Configurable par1{"par1", 0.013, "par 1"}; - Configurable min_ITS_nClusters{"min_ITS_nClusters", 5, "minimum number of ITS clusters"}; - Configurable min_TPC_nClusters{"min_TPC_nClusters", 80, "minimum number of TPC clusters"}; - Configurable min_TPC_nCrossedRows{"min_TPC_nCrossedRows", 80, "minimum number of TPC crossed pad rows"}; - Configurable max_chi2_TPC{"max_chi2_TPC", 4.0, "maximum TPC chi^2/Ncls"}; - Configurable max_chi2_ITS{"max_chi2_ITS", 36.0, "maximum ITS chi^2/Ncls"}; - Configurable min_pt{"min_pt", 0.3, "minimum pt of the tracks"}; - Configurable min_eta{"min_eta", -0.8, "minimum eta"}; - Configurable max_eta{"max_eta", +0.8, "maximum eta"}; - Configurable max_dcaxy{"max_dcaxy", 0.05, "Maximum DCAxy"}; - Configurable max_dcaz{"max_dcaz", 0.05, "Maximum DCAz"}; - Configurable min_nsigmaTPC{"min_nsigmaTPC", -3.0, "Minimum nsigma TPC"}; - Configurable max_nsigmaTPC{"max_nsigmaTPC", +3.0, "Maximum nsigma TPC"}; - Configurable min_nsigmaTOF{"min_nsigmaTOF", -3.0, "Minimum nsigma TOF"}; - Configurable max_nsigmaTOF{"max_nsigmaTOF", +3.5, "Maximum nsigma TOF"}; - Configurable max_pt_for_nsigmaTPC{"max_pt_for_nsigmaTPC", 2.0, "Maximum pt for TPC analysis"}; - Configurable min_pt_for_nsigmaTOF{"min_pt_for_nsigmaTOF", 0.5, "Minimum pt for TOF analysis"}; - Configurable require_PV_contributor{"require_PV_contributor", true, "require that the track is a PV contributor"}; - Configurable setDCAselectionPtDep{"setDCAselectionPtDep", true, "require pt dependent selection"}; - Configurable applyReweighting{"applyReweighting", true, "apply reweighting"}; - - Configurable url_to_ccdb{"url_to_ccdb", "http://alice-ccdb.cern.ch", "url of the personal ccdb"}; - Configurable path_to_file{"path_to_file", "", "path to file with reweighting"}; - Configurable histo_name_weight_antip_jet{"histo_name_weight_antip_jet", "", "reweighting histogram: antip in jet"}; - Configurable histo_name_weight_antip_ue{"histo_name_weight_antip_ue", "", "reweighting histogram: antip in ue"}; - - TH2F* twod_weights_antip_jet; - TH2F* twod_weights_antip_ue; - - Service ccdb; - o2::ccdb::CcdbApi ccdbApi; - - void init(InitContext const&) - { - ccdb->setURL(url_to_ccdb.value); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - ccdb->setFatalWhenNull(false); - - if (applyReweighting) { - GetReweightingHistograms(ccdb, TString(path_to_file), TString(histo_name_weight_antip_jet), TString(histo_name_weight_antip_ue)); - } else { - twod_weights_antip_jet = nullptr; - twod_weights_antip_ue = nullptr; - } - - // QC Histograms - registryQC.add("deltaEtadeltaPhi_jet", "deltaEtadeltaPhi_jet", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, 0.5 * TMath::Pi(), "#Delta#phi"}}); - registryQC.add("deltaEtadeltaPhi_ue", "deltaEtadeltaPhi_ue", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, 0.5 * TMath::Pi(), "#Delta#phi"}}); - registryQC.add("NchJetPlusUE", "NchJetPlusUE", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); - registryQC.add("NchJet", "NchJet", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); - registryQC.add("NchUE", "NchUE", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); - registryQC.add("sumPtJetPlusUE", "sumPtJetPlusUE", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQC.add("sumPtJet", "sumPtJet", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQC.add("sumPtUE", "sumPtUE", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQC.add("nJets_found", "nJets_found", HistType::kTH1F, {{10, 0, 10, "#it{n}_{Jet}"}}); - registryQC.add("nJets_selected", "nJets_selected", HistType::kTH1F, {{10, 0, 10, "#it{n}_{Jet}"}}); - registryQC.add("event_selection_jets", "event_selection_jets", HistType::kTH1F, {{10, 0, 10, "counter"}}); - registryQC.add("dcaxy_vs_pt", "dcaxy_vs_pt", HistType::kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); - registryQC.add("dcaz_vs_pt", "dcaz_vs_pt", HistType::kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); - registryQC.add("jet_ue_overlaps", "jet_ue_overlaps", HistType::kTH2F, {{20, 0.0, 20.0, "#it{n}_{jet}"}, {200, 0.0, 200.0, "#it{n}_{overlaps}"}}); - - // Event Counters - registryData.add("number_of_events_data", "number of events in data", HistType::kTH1F, {{10, 0, 10, "counter"}}); - registryMC.add("number_of_events_mc", "number of events in mc", HistType::kTH1F, {{10, 0, 10, "counter"}}); - - // Binning - double min = 0.0; - double max = 6.0; - int nbins = 120; - - // Antiprotons - registryData.add("antiproton_jet_tpc", "antiproton_jet_tpc", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antiproton_jet_tof", "antiproton_jet_tof", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); - registryData.add("antiproton_ue_tpc", "antiproton_ue_tpc", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antiproton_ue_tof", "antiproton_ue_tof", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); - registryData.add("antiproton_dca_jet", "antiproton_dca_jet", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -0.5, 0.5, "DCA_{xy} (cm)"}}); - registryData.add("antiproton_dca_ue", "antiproton_dca_ue", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -0.5, 0.5, "DCA_{xy} (cm)"}}); - - // Antideuterons - registryData.add("antideuteron_jet_tpc", "antideuteron_jet_tpc", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antideuteron_jet_tof", "antideuteron_jet_tof", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); - registryData.add("antideuteron_ue_tpc", "antideuteron_ue_tpc", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antideuteron_ue_tof", "antideuteron_ue_tof", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); - - // Deuterons - registryData.add("deuteron_jet_tof", "deuteron_jet_tof", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); - registryData.add("deuteron_ue_tof", "deuteron_ue_tof", HistType::kTH2F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); - - // Antihelium-3 - registryData.add("antihelium3_jet_tpc", "antihelium3_jet_tpc", HistType::kTH2F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antihelium3_ue_tpc", "antihelium3_ue_tpc", HistType::kTH2F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - - // Helium-3 - registryData.add("helium3_jet_tpc", "helium3_jet_tpc", HistType::kTH2F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("helium3_ue_tpc", "helium3_ue_tpc", HistType::kTH2F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - - // Generated - registryMC.add("antiproton_jet_gen", "antiproton_jet_gen", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_jet_gen", "antideuteron_jet_gen", HistType::kTH1F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antihelium3_jet_gen", "antihelium3_jet_gen", HistType::kTH1F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_ue_gen", "antiproton_ue_gen", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_ue_gen", "antideuteron_ue_gen", HistType::kTH1F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antihelium3_ue_gen", "antihelium3_ue_gen", HistType::kTH1F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}}); - - // Reconstructed TPC - registryMC.add("antiproton_jet_rec_tpc", "antiproton_jet_rec_tpc", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_jet_rec_tpc", "antideuteron_jet_rec_tpc", HistType::kTH1F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antihelium3_jet_rec_tpc", "antihelium3_jet_rec_tpc", HistType::kTH1F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_ue_rec_tpc", "antiproton_ue_rec_tpc", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_ue_rec_tpc", "antideuteron_ue_rec_tpc", HistType::kTH1F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antihelium3_ue_rec_tpc", "antihelium3_ue_rec_tpc", HistType::kTH1F, {{nbins, min * 3, max * 3, "#it{p}_{T} (GeV/#it{c})"}}); - - // Reconstructed TOF - registryMC.add("antiproton_jet_rec_tof", "antiproton_jet_rec_tof", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_jet_rec_tof", "antideuteron_jet_rec_tof", HistType::kTH1F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_ue_rec_tof", "antiproton_ue_rec_tof", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_ue_rec_tof", "antideuteron_ue_rec_tof", HistType::kTH1F, {{nbins, min * 2, max * 2, "#it{p}_{T} (GeV/#it{c})"}}); - - // DCA Templates - registryMC.add("antiproton_dca_prim", "antiproton_dca_prim", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -0.5, 0.5, "DCA_{xy} (cm)"}}); - registryMC.add("antiproton_dca_sec", "antiproton_dca_sec", HistType::kTH2F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}, {200, -0.5, 0.5, "DCA_{xy} (cm)"}}); - - // Fraction of Primary Antiprotons from MC - registryMC.add("antiproton_prim", "antiproton_prim", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_all", "antiproton_all", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_prim_jet", "antiproton_prim_jet", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_all_jet", "antiproton_all_jet", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_prim_ue", "antiproton_prim_ue", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_all_ue", "antiproton_all_ue", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); - - // Antiproton Reweighting - registryMC.add("antiproton_eta_pt_pythia", "antiproton_eta_pt_pythia", HistType::kTH2F, {{200, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {20, -1.0, 1.0, "#it{#eta}"}}); - registryMC.add("antiproton_eta_pt_jet", "antiproton_eta_pt_jet", HistType::kTH2F, {{200, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {20, -1.0, 1.0, "#it{#eta}"}}); - registryMC.add("antiproton_eta_pt_ue", "antiproton_eta_pt_ue", HistType::kTH2F, {{200, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {20, -1.0, 1.0, "#it{#eta}"}}); - } - - // Single-Track Selection for Particles inside Jets - template - bool passedTrackSelectionForJetReconstruction(const T1& track) - { - if (!track.hasITS()) - return false; - if (track.itsNCls() < 3) - return false; - if (!track.hasTPC()) - return false; - if (track.tpcNClsCrossedRows() < 70) - return false; - if (track.tpcChi2NCl() > 4) - return false; - if (track.itsChi2NCl() > 36) - return false; - if (track.eta() < -0.8 || track.eta() > 0.8) - return false; - if (track.pt() < 0.15) - return false; - - // pt-dependent selection - if (setDCAselectionPtDep) { - if (TMath::Abs(track.dcaXY()) > (par0 + par1 / track.pt())) - return false; - if (TMath::Abs(track.dcaZ()) > (par0 + par1 / track.pt())) - return false; - } - - // standard selection - if (!setDCAselectionPtDep) { - if (TMath::Abs(track.dcaXY()) > max_dcaxy) - return false; - if (TMath::Abs(track.dcaZ()) > max_dcaz) - return false; - } - - return true; - } - - // Single-Track Selection - template - bool passedTrackSelection(const T2& track) - { - if (!track.hasITS()) - return false; - if (track.itsNCls() < min_ITS_nClusters) - return false; - if (!track.hasTPC()) - return false; - if (track.tpcNClsFound() < min_TPC_nClusters) - return false; - if (track.tpcNClsCrossedRows() < min_TPC_nCrossedRows) - return false; - if (track.tpcChi2NCl() > max_chi2_TPC) - return false; - if (track.itsChi2NCl() > max_chi2_ITS) - return false; - if (track.eta() < min_eta || track.eta() > max_eta) - return false; - if (track.pt() < min_pt) - return false; - - return true; - } - - template - bool isHighPurityAntiproton(const T3& track) - { - // Variables - double nsigmaTPCPr = track.tpcNSigmaPr(); - double nsigmaTOFPr = track.tofNSigmaPr(); - double pt = track.pt(); - - if (pt < 0.5 && TMath::Abs(nsigmaTPCPr) < 2.0) - return true; - if (pt >= 0.5 && TMath::Abs(nsigmaTPCPr) < 2.0 && track.hasTOF() && TMath::Abs(nsigmaTOFPr) < 2.0) - return true; - return false; - } - - // Minimum - double Minimum(double x1, double x2) - { - double x_min(x1); - if (x1 < x2) - x_min = x1; - if (x1 >= x2) - x_min = x2; - - return x_min; - } - - // Deltaphi - double GetDeltaPhi(double a1, double a2) - { - double delta_phi(0); - double phi1 = TVector2::Phi_0_2pi(a1); - double phi2 = TVector2::Phi_0_2pi(a2); - double diff = TMath::Abs(phi1 - phi2); - - if (diff <= TMath::Pi()) - delta_phi = diff; - if (diff > TMath::Pi()) - delta_phi = TMath::TwoPi() - diff; - - return delta_phi; - } - - void get_perpendicular_axis(TVector3 p, TVector3& u, double sign) - { - // Initialization - double ux(0), uy(0), uz(0); - - // Components of Vector p - double px = p.X(); - double py = p.Y(); - double pz = p.Z(); - - // Protection 1 - if (px == 0 && py != 0) { - - uy = -(pz * pz) / py; - ux = sign * sqrt(py * py - (pz * pz * pz * pz) / (py * py)); - uz = pz; - u.SetXYZ(ux, uy, uz); - return; - } - - // Protection 2 - if (py == 0 && px != 0) { - - ux = -(pz * pz) / px; - uy = sign * sqrt(px * px - (pz * pz * pz * pz) / (px * px)); - uz = pz; - u.SetXYZ(ux, uy, uz); - return; - } - - // Equation Parameters - double a = px * px + py * py; - double b = 2.0 * px * pz * pz; - double c = pz * pz * pz * pz - py * py * py * py - px * px * py * py; - double delta = b * b - 4.0 * a * c; - - // Protection against delta<0 - if (delta < 0) { - return; - } - - // Solutions - ux = (-b + sign * sqrt(delta)) / (2.0 * a); - uy = (-pz * pz - px * ux) / py; - uz = pz; - u.SetXYZ(ux, uy, uz); - return; - } - - double calculate_dij(TVector3 t1, TVector3 t2, double R) - { - double distance_jet(0); - double x1 = 1.0 / (t1.Pt() * t1.Pt()); - double x2 = 1.0 / (t2.Pt() * t2.Pt()); - double deltaEta = t1.Eta() - t2.Eta(); - double deltaPhi = GetDeltaPhi(t1.Phi(), t2.Phi()); - double min = Minimum(x1, x2); - double Delta2 = deltaEta * deltaEta + deltaPhi * deltaPhi; - distance_jet = min * Delta2 / (R * R); - return distance_jet; - } - - bool overlap(TVector3 v1, TVector3 v2, double R) - { - double dx = v1.Eta() - v2.Eta(); - double dy = GetDeltaPhi(v1.Phi(), v2.Phi()); - double d = sqrt(dx * dx + dy * dy); - if (d < 2.0 * R) - return true; - return false; - } - - void GetReweightingHistograms(o2::framework::Service const& ccdbObj, TString filepath, TString histname_antip_jet, TString histname_antip_ue) - { - TList* l = ccdbObj->get(filepath.Data()); - if (!l) { - LOGP(error, "Could not open the file {}", Form("%s", filepath.Data())); - return; - } - twod_weights_antip_jet = static_cast(l->FindObject(Form("%s_antiproton", histname_antip_jet.Data()))); - if (!twod_weights_antip_jet) { - LOGP(error, "Could not open histogram {}", Form("%s_antiproton", histname_antip_jet.Data())); - return; - } - twod_weights_antip_ue = static_cast(l->FindObject(Form("%s_antiproton", histname_antip_ue.Data()))); - if (!twod_weights_antip_ue) { - LOGP(error, "Could not open histogram {}", Form("%s_antiproton", histname_antip_ue.Data())); - return; - } - LOGP(info, "Opened histogram {}", Form("%s_antiproton", histname_antip_jet.Data())); - LOGP(info, "Opened histogram {}", Form("%s_antiproton", histname_antip_ue.Data())); - } - - // Process Data - void processData(SelectedCollisions::iterator const& collision, FullNucleiTracks const& tracks) - { - // Event Counter: before event selection - registryData.fill(HIST("number_of_events_data"), 0.5); - registryQC.fill(HIST("event_selection_jets"), 0.5); // all events before jet selection - - // Event Selection - if (!collision.sel8()) - return; - - // Event Counter: after event selection sel8 - registryData.fill(HIST("number_of_events_data"), 1.5); - - // Cut on z-vertex - if (TMath::Abs(collision.posZ()) > zVtx) - return; - - // Event Counter: after z-vertex cut - registryData.fill(HIST("number_of_events_data"), 2.5); - - // List of Tracks - std::vector trk; - - for (auto track : tracks) { - - if (!passedTrackSelectionForJetReconstruction(track)) - continue; - registryQC.fill(HIST("dcaxy_vs_pt"), track.pt(), track.dcaXY()); - registryQC.fill(HIST("dcaz_vs_pt"), track.pt(), track.dcaZ()); - - TVector3 momentum(track.px(), track.py(), track.pz()); - trk.push_back(momentum); - } - - // Anti-kt Jet Finder - int n_particles_removed(0); - std::vector jet; - std::vector ue1; - std::vector ue2; - - do { - double dij_min(1e+06), diB_min(1e+06); - int i_min(0), j_min(0), iB_min(0); - for (int i = 0; i < static_cast(trk.size()); i++) { - if (trk[i].Mag() == 0) - continue; - double diB = 1.0 / (trk[i].Pt() * trk[i].Pt()); - if (diB < diB_min) { - diB_min = diB; - iB_min = i; - } - for (int j = (i + 1); j < static_cast(trk.size()); j++) { - if (trk[j].Mag() == 0) - continue; - double dij = calculate_dij(trk[i], trk[j], Rjet); - if (dij < dij_min) { - dij_min = dij; - i_min = i; - j_min = j; - } - } - } - if (dij_min < diB_min) { - trk[i_min] = trk[i_min] + trk[j_min]; - trk[j_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - if (dij_min > diB_min) { - jet.push_back(trk[iB_min]); - trk[iB_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - } while (n_particles_removed < static_cast(trk.size())); - - registryQC.fill(HIST("nJets_found"), static_cast(jet.size())); - - // Jet Selection - std::vector isSelected; - for (int i = 0; i < static_cast(jet.size()); i++) { - isSelected.push_back(0); - } - - int n_jets_selected(0); - for (int i = 0; i < static_cast(jet.size()); i++) { - - if ((TMath::Abs(jet[i].Eta()) + Rjet) > max_eta) - continue; - - // Perpendicular cones - TVector3 ue_axis1(0, 0, 0); - TVector3 ue_axis2(0, 0, 0); - get_perpendicular_axis(jet[i], ue_axis1, +1); - get_perpendicular_axis(jet[i], ue_axis2, -1); - ue1.push_back(ue_axis1); - ue2.push_back(ue_axis2); - - double nPartJetPlusUE(0); - double nPartJet(0); - double nPartUE(0); - double ptJetPlusUE(0); - double ptJet(0); - double ptUE(0); - - for (auto track : tracks) { - - if (!passedTrackSelectionForJetReconstruction(track)) - continue; - TVector3 sel_track(track.px(), track.py(), track.pz()); - - double deltaEta_jet = sel_track.Eta() - jet[i].Eta(); - double deltaPhi_jet = GetDeltaPhi(sel_track.Phi(), jet[i].Phi()); - double deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = sel_track.Eta() - ue_axis1.Eta(); - double deltaPhi_ue1 = GetDeltaPhi(sel_track.Phi(), ue_axis1.Phi()); - double deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = sel_track.Eta() - ue_axis2.Eta(); - double deltaPhi_ue2 = GetDeltaPhi(sel_track.Phi(), ue_axis2.Phi()); - double deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - if (deltaR_jet < Rjet) { - registryQC.fill(HIST("deltaEtadeltaPhi_jet"), deltaEta_jet, deltaPhi_jet); - nPartJetPlusUE++; - ptJetPlusUE = ptJetPlusUE + sel_track.Pt(); - } - if (deltaR_ue1 < Rjet) { - registryQC.fill(HIST("deltaEtadeltaPhi_ue"), deltaEta_ue1, deltaPhi_ue1); - nPartUE++; - ptUE = ptUE + sel_track.Pt(); - } - if (deltaR_ue2 < Rjet) { - registryQC.fill(HIST("deltaEtadeltaPhi_ue"), deltaEta_ue2, deltaPhi_ue2); - nPartUE++; - ptUE = ptUE + sel_track.Pt(); - } - } - nPartJet = nPartJetPlusUE - 0.5 * nPartUE; - ptJet = ptJetPlusUE - 0.5 * ptUE; - registryQC.fill(HIST("NchJetPlusUE"), nPartJetPlusUE); - registryQC.fill(HIST("NchJet"), nPartJet); - registryQC.fill(HIST("NchUE"), nPartUE); - registryQC.fill(HIST("sumPtJetPlusUE"), ptJetPlusUE); - registryQC.fill(HIST("sumPtJet"), ptJet); - registryQC.fill(HIST("sumPtUE"), ptUE); - - if (ptJet < min_jet_pt) - continue; - if (nPartJetPlusUE < min_nPartInJet) - continue; - n_jets_selected++; - isSelected[i] = 1; - } - registryQC.fill(HIST("nJets_selected"), n_jets_selected); - - if (n_jets_selected == 0) - return; - registryData.fill(HIST("number_of_events_data"), 3.5); - registryQC.fill(HIST("event_selection_jets"), 1.5); // events with pTjet>10 GeV/c selected - //************************************************************************************************************************************ - - // Leading Track - double pt_max(0); - - // Loop over Reconstructed Tracks - for (auto const& track : tracks) { - - if (!passedTrackSelectionForJetReconstruction(track)) - continue; - - if (track.pt() > pt_max) { - pt_max = track.pt(); - } - } - // Event Counter: Skip Events with pt 5 GeV/c selected - - // Overlaps - int nOverlaps(0); - for (int i = 0; i < static_cast(jet.size()); i++) { - if (isSelected[i] == 0) - continue; - - for (int j = 0; j < static_cast(jet.size()); j++) { - if (isSelected[j] == 0 || i == j) - continue; - if (overlap(jet[i], ue1[j], Rjet) || overlap(jet[i], ue2[j], Rjet)) - nOverlaps++; - } - } - registryQC.fill(HIST("jet_ue_overlaps"), n_jets_selected, nOverlaps); - - if (n_jets_selected > n_jets_per_event_max) - return; - registryData.fill(HIST("number_of_events_data"), 4.5); - - if (requireNoOverlap && nOverlaps > 0) - return; - registryData.fill(HIST("number_of_events_data"), 5.5); - - //************************************************************************************************************************************ - - for (int i = 0; i < static_cast(jet.size()); i++) { - - if (isSelected[i] == 0) - continue; - - for (auto track : tracks) { - if (!passedTrackSelection(track)) - continue; - if (require_PV_contributor && !(track.isPVContributor())) - continue; - - // Variables - double nsigmaTPCPr = track.tpcNSigmaPr(); - double nsigmaTOFPr = track.tofNSigmaPr(); - double nsigmaTPCDe = track.tpcNSigmaDe(); - double nsigmaTOFDe = track.tofNSigmaDe(); - double nsigmaTPCHe = track.tpcNSigmaHe(); - double pt = track.pt(); - double dcaxy = track.dcaXY(); - double dcaz = track.dcaZ(); - - TVector3 particle_dir(track.px(), track.py(), track.pz()); - double deltaEta_jet = particle_dir.Eta() - jet[i].Eta(); - double deltaPhi_jet = GetDeltaPhi(particle_dir.Phi(), jet[i].Phi()); - double deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = particle_dir.Eta() - ue1[i].Eta(); - double deltaPhi_ue1 = GetDeltaPhi(particle_dir.Phi(), ue1[i].Phi()); - double deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = particle_dir.Eta() - ue2[i].Eta(); - double deltaPhi_ue2 = GetDeltaPhi(particle_dir.Phi(), ue2[i].Phi()); - double deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - // DCAxy Distributions of Antiprotons - if (track.sign() < 0) { // only antiprotons - if (isHighPurityAntiproton(track) && TMath::Abs(dcaz) < max_dcaz) { - if (deltaR_jet < Rjet) { - registryData.fill(HIST("antiproton_dca_jet"), pt, dcaxy); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryData.fill(HIST("antiproton_dca_ue"), pt, dcaxy); - } - } - } - // DCA Cuts - if (TMath::Abs(dcaxy) > max_dcaxy) - continue; - if (TMath::Abs(dcaz) > max_dcaz) - continue; - - // Jet - if (deltaR_jet < Rjet) { - - if (track.sign() < 0) { // only antimatter - // Antiproton - if (pt < max_pt_for_nsigmaTPC) - registryData.fill(HIST("antiproton_jet_tpc"), pt, nsigmaTPCPr); - if (pt >= min_pt_for_nsigmaTOF && nsigmaTPCPr > min_nsigmaTPC && nsigmaTPCPr < max_nsigmaTPC && track.hasTOF()) - registryData.fill(HIST("antiproton_jet_tof"), pt, nsigmaTOFPr); - - // Antideuteron - if (pt < max_pt_for_nsigmaTPC) - registryData.fill(HIST("antideuteron_jet_tpc"), pt, nsigmaTPCDe); - if (pt >= min_pt_for_nsigmaTOF && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC && track.hasTOF()) - registryData.fill(HIST("antideuteron_jet_tof"), pt, nsigmaTOFDe); - - // Antihelium3 - registryData.fill(HIST("antihelium3_jet_tpc"), 2.0 * pt, nsigmaTPCHe); - } - - if (track.sign() > 0) { // only matter - // Deuteron - if (pt >= min_pt_for_nsigmaTOF && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC && track.hasTOF()) - registryData.fill(HIST("deuteron_jet_tof"), pt, nsigmaTOFDe); - - // Helium3 - registryData.fill(HIST("helium3_jet_tpc"), 2.0 * pt, nsigmaTPCHe); - } - } - - // UE - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - - if (track.sign() < 0) { // only antimatter - // Antiproton - if (pt < max_pt_for_nsigmaTPC) - registryData.fill(HIST("antiproton_ue_tpc"), pt, nsigmaTPCPr); - if (pt >= min_pt_for_nsigmaTOF && nsigmaTPCPr > min_nsigmaTPC && nsigmaTPCPr < max_nsigmaTPC && track.hasTOF()) - registryData.fill(HIST("antiproton_ue_tof"), pt, nsigmaTOFPr); - - // Antideuteron - if (pt < max_pt_for_nsigmaTPC) - registryData.fill(HIST("antideuteron_ue_tpc"), pt, nsigmaTPCDe); - if (pt >= min_pt_for_nsigmaTOF && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC && track.hasTOF()) - registryData.fill(HIST("antideuteron_ue_tof"), pt, nsigmaTOFDe); - - // Antihelium3 - registryData.fill(HIST("antihelium3_ue_tpc"), 2.0 * pt, nsigmaTPCHe); - } - - if (track.sign() > 0) { // only matter - // Deuteron - if (pt >= min_pt_for_nsigmaTOF && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC && track.hasTOF()) - registryData.fill(HIST("deuteron_ue_tof"), pt, nsigmaTOFDe); - - // Helium3 - registryData.fill(HIST("helium3_ue_tpc"), 2.0 * pt, nsigmaTPCHe); - } - } - } - } - } - PROCESS_SWITCH(nuclei_in_jets, processData, "Process Data", true); - - Preslice perMCCollision = o2::aod::mcparticle::mcCollisionId; - Preslice perCollision = o2::aod::track::collisionId; - - void processEfficiency(o2::aod::McCollisions const& mcCollisions, SimCollisions const& collisions, MCTracks const& mcTracks, aod::McParticles const& mcParticles) - { - // Generated Events - for (const auto& mccollision : mcCollisions) { - - registryMC.fill(HIST("number_of_events_mc"), 0.5); - auto mcParticles_per_coll = mcParticles.sliceBy(perMCCollision, mccollision.globalIndex()); - - for (auto& particle : mcParticles_per_coll) { - - if (!particle.isPhysicalPrimary()) - continue; - if ((particle.pdgCode() != -2212) && (particle.pdgCode() != -1000010020) && (particle.pdgCode() != -1000020030)) - continue; - if (particle.eta() < min_eta || particle.eta() > max_eta) - continue; - - double w_antip_jet(1.0); - double w_antip_ue(1.0); - if (applyReweighting) { - int ix = twod_weights_antip_jet->GetXaxis()->FindBin(particle.pt()); - int iy = twod_weights_antip_jet->GetYaxis()->FindBin(particle.eta()); - w_antip_jet = twod_weights_antip_jet->GetBinContent(ix, iy); - w_antip_ue = twod_weights_antip_ue->GetBinContent(ix, iy); - - // protections - if (ix == 0 || ix > twod_weights_antip_jet->GetNbinsX()) { - w_antip_jet = 1.0; - w_antip_ue = 1.0; - } - if (iy == 0 || iy > twod_weights_antip_jet->GetNbinsY()) { - w_antip_jet = 1.0; - w_antip_ue = 1.0; - } - } - - if (particle.pdgCode() == -2212) { - registryMC.fill(HIST("antiproton_jet_gen"), particle.pt(), w_antip_jet); - registryMC.fill(HIST("antiproton_ue_gen"), particle.pt(), w_antip_ue); - } - if (particle.pdgCode() == -1000010020) { - registryMC.fill(HIST("antideuteron_jet_gen"), particle.pt()); - registryMC.fill(HIST("antideuteron_ue_gen"), particle.pt()); - } - if (particle.pdgCode() == -1000020030) { - registryMC.fill(HIST("antihelium3_jet_gen"), particle.pt()); - registryMC.fill(HIST("antihelium3_ue_gen"), particle.pt()); - } - } - } - - // Reconstructed Events - for (const auto& collision : collisions) { - - registryMC.fill(HIST("number_of_events_mc"), 1.5); - - // Event Selection - if (!collision.sel8()) - continue; - - if (TMath::Abs(collision.posZ()) > 10) - continue; - - // Event Counter (after event sel) - registryMC.fill(HIST("number_of_events_mc"), 2.5); - - auto tracks_per_coll = mcTracks.sliceBy(perCollision, collision.globalIndex()); - - // Reconstructed Tracks - for (auto track : tracks_per_coll) { - - // Get MC Particle - if (!track.has_mcParticle()) - continue; - - const auto particle = track.mcParticle(); - if ((particle.pdgCode() != -2212) && (particle.pdgCode() != -1000010020) && (particle.pdgCode() != -1000020030)) - continue; - - // Track Selection - if (!passedTrackSelection(track)) - continue; - if (require_PV_contributor && !(track.isPVContributor())) - continue; - - // Variables - float nsigmaTPCPr = track.tpcNSigmaPr(); - float nsigmaTOFPr = track.tofNSigmaPr(); - float nsigmaTPCDe = track.tpcNSigmaDe(); - float nsigmaTOFDe = track.tofNSigmaDe(); - float nsigmaTPCHe = track.tpcNSigmaHe(); - float pt = track.pt(); - - // DCA Templates - if (particle.pdgCode() == -2212 && particle.isPhysicalPrimary() && TMath::Abs(track.dcaZ()) < max_dcaz) - registryMC.fill(HIST("antiproton_dca_prim"), pt, track.dcaXY()); - - if (particle.pdgCode() == -2212 && (!particle.isPhysicalPrimary()) && TMath::Abs(track.dcaZ()) < max_dcaz) - registryMC.fill(HIST("antiproton_dca_sec"), pt, track.dcaXY()); - - // DCA Cuts - if (TMath::Abs(track.dcaXY()) > max_dcaxy) - continue; - if (TMath::Abs(track.dcaZ()) > max_dcaz) - continue; - - // Fraction of Primary Antiprotons - if (particle.pdgCode() == -2212) { - registryMC.fill(HIST("antiproton_all"), pt); - if (particle.isPhysicalPrimary()) { - registryMC.fill(HIST("antiproton_prim"), pt); - } - } - - if (!particle.isPhysicalPrimary()) - continue; - - double w_antip_jet(1.0); - double w_antip_ue(1.0); - if (applyReweighting) { - int ix = twod_weights_antip_jet->GetXaxis()->FindBin(particle.pt()); - int iy = twod_weights_antip_jet->GetYaxis()->FindBin(particle.eta()); - w_antip_jet = twod_weights_antip_jet->GetBinContent(ix, iy); - w_antip_ue = twod_weights_antip_ue->GetBinContent(ix, iy); - - // protection - if (ix == 0 || ix > twod_weights_antip_jet->GetNbinsX()) { - w_antip_jet = 1.0; - w_antip_ue = 1.0; - } - if (iy == 0 || iy > twod_weights_antip_jet->GetNbinsY()) { - w_antip_jet = 1.0; - w_antip_ue = 1.0; - } - } - - // Antiproton - if (particle.pdgCode() == -2212) { - if (pt < max_pt_for_nsigmaTPC && nsigmaTPCPr > min_nsigmaTPC && nsigmaTPCPr < max_nsigmaTPC) { - registryMC.fill(HIST("antiproton_jet_rec_tpc"), pt, w_antip_jet); - registryMC.fill(HIST("antiproton_ue_rec_tpc"), pt, w_antip_ue); - } - if (pt >= min_pt_for_nsigmaTOF && nsigmaTPCPr > min_nsigmaTPC && nsigmaTPCPr < max_nsigmaTPC && track.hasTOF() && nsigmaTOFPr > min_nsigmaTOF && nsigmaTOFPr < max_nsigmaTOF) { - registryMC.fill(HIST("antiproton_jet_rec_tof"), pt, w_antip_jet); - registryMC.fill(HIST("antiproton_ue_rec_tof"), pt, w_antip_ue); - } - } - - // Antideuteron - if (particle.pdgCode() == -1000010020) { - if (pt < max_pt_for_nsigmaTPC && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC) { - registryMC.fill(HIST("antideuteron_jet_rec_tpc"), pt); - registryMC.fill(HIST("antideuteron_ue_rec_tpc"), pt); - } - if (pt >= min_pt_for_nsigmaTOF && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC && track.hasTOF() && nsigmaTOFDe > min_nsigmaTOF && nsigmaTOFDe < max_nsigmaTOF) { - registryMC.fill(HIST("antideuteron_jet_rec_tof"), pt); - registryMC.fill(HIST("antideuteron_ue_rec_tof"), pt); - } - } - - // Antihelium-3 - if (particle.pdgCode() == -1000020030) { - if (nsigmaTPCHe > min_nsigmaTPC && nsigmaTPCHe < max_nsigmaTPC) { - registryMC.fill(HIST("antihelium3_jet_rec_tpc"), 2.0 * pt); - registryMC.fill(HIST("antihelium3_ue_rec_tpc"), 2.0 * pt); - } - } - } - } - } - PROCESS_SWITCH(nuclei_in_jets, processEfficiency, "process efficiency", false); - - void processSecondaryAntiprotons(SimCollisions const& collisions, MCTracks const& mcTracks, aod::McCollisions const&, const aod::McParticles&) - { - for (const auto& collision : collisions) { - - registryMC.fill(HIST("number_of_events_mc"), 3.5); - - // Event Selection - if (!collision.sel8()) - continue; - registryMC.fill(HIST("number_of_events_mc"), 4.5); - - if (TMath::Abs(collision.posZ()) > zVtx) - continue; - registryMC.fill(HIST("number_of_events_mc"), 5.5); - - auto tracks_per_coll = mcTracks.sliceBy(perCollision, collision.globalIndex()); - - // List of Tracks - std::vector trk; - - for (auto track : tracks_per_coll) { - - if (!passedTrackSelectionForJetReconstruction(track)) - continue; - - TVector3 momentum(track.px(), track.py(), track.pz()); - trk.push_back(momentum); - } - - // Anti-kt Jet Finder - int n_particles_removed(0); - std::vector jet; - std::vector ue1; - std::vector ue2; - - do { - double dij_min(1e+06), diB_min(1e+06); - int i_min(0), j_min(0), iB_min(0); - for (int i = 0; i < static_cast(trk.size()); i++) { - if (trk[i].Mag() == 0) - continue; - double diB = 1.0 / (trk[i].Pt() * trk[i].Pt()); - if (diB < diB_min) { - diB_min = diB; - iB_min = i; - } - for (int j = (i + 1); j < static_cast(trk.size()); j++) { - if (trk[j].Mag() == 0) - continue; - double dij = calculate_dij(trk[i], trk[j], Rjet); - if (dij < dij_min) { - dij_min = dij; - i_min = i; - j_min = j; - } - } - } - if (dij_min < diB_min) { - trk[i_min] = trk[i_min] + trk[j_min]; - trk[j_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - if (dij_min > diB_min) { - jet.push_back(trk[iB_min]); - trk[iB_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - } while (n_particles_removed < static_cast(trk.size())); - - // Jet Selection - std::vector isSelected; - for (int i = 0; i < static_cast(jet.size()); i++) { - isSelected.push_back(0); - } - - int n_jets_selected(0); - for (int i = 0; i < static_cast(jet.size()); i++) { - - if ((TMath::Abs(jet[i].Eta()) + Rjet) > max_eta) - continue; - - // Perpendicular cones - TVector3 ue_axis1(0, 0, 0); - TVector3 ue_axis2(0, 0, 0); - get_perpendicular_axis(jet[i], ue_axis1, +1); - get_perpendicular_axis(jet[i], ue_axis2, -1); - ue1.push_back(ue_axis1); - ue2.push_back(ue_axis2); - - double nPartJetPlusUE(0); - double ptJetPlusUE(0); - double ptJet(0); - double ptUE(0); - - for (auto track : tracks_per_coll) { - - if (!passedTrackSelectionForJetReconstruction(track)) - continue; - TVector3 sel_track(track.px(), track.py(), track.pz()); - - double deltaEta_jet = sel_track.Eta() - jet[i].Eta(); - double deltaPhi_jet = GetDeltaPhi(sel_track.Phi(), jet[i].Phi()); - double deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = sel_track.Eta() - ue_axis1.Eta(); - double deltaPhi_ue1 = GetDeltaPhi(sel_track.Phi(), ue_axis1.Phi()); - double deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = sel_track.Eta() - ue_axis2.Eta(); - double deltaPhi_ue2 = GetDeltaPhi(sel_track.Phi(), ue_axis2.Phi()); - double deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - if (deltaR_jet < Rjet) { - nPartJetPlusUE++; - ptJetPlusUE = ptJetPlusUE + sel_track.Pt(); - } - if (deltaR_ue1 < Rjet) { - ptUE = ptUE + sel_track.Pt(); - } - if (deltaR_ue2 < Rjet) { - ptUE = ptUE + sel_track.Pt(); - } - } - ptJet = ptJetPlusUE - 0.5 * ptUE; - - if (ptJet < min_jet_pt) - continue; - if (nPartJetPlusUE < min_nPartInJet) - continue; - n_jets_selected++; - isSelected[i] = 1; - } - if (n_jets_selected == 0) - continue; - registryMC.fill(HIST("number_of_events_mc"), 6.5); - - for (int i = 0; i < static_cast(jet.size()); i++) { - - if (isSelected[i] == 0) - continue; - - for (auto track : tracks_per_coll) { - if (!passedTrackSelection(track)) - continue; - if (require_PV_contributor && !(track.isPVContributor())) - continue; - if (track.sign() > 0) - continue; - if (TMath::Abs(track.dcaXY()) > max_dcaxy) - continue; - if (TMath::Abs(track.dcaZ()) > max_dcaz) - continue; - if (!track.has_mcParticle()) - continue; - const auto particle = track.mcParticle(); - if (particle.pdgCode() != -2212) - continue; - - TVector3 particle_dir(track.px(), track.py(), track.pz()); - float deltaEta_jet = particle_dir.Eta() - jet[i].Eta(); - float deltaPhi_jet = GetDeltaPhi(particle_dir.Phi(), jet[i].Phi()); - float deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - float deltaEta_ue1 = particle_dir.Eta() - ue1[i].Eta(); - float deltaPhi_ue1 = GetDeltaPhi(particle_dir.Phi(), ue1[i].Phi()); - float deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - float deltaEta_ue2 = particle_dir.Eta() - ue2[i].Eta(); - float deltaPhi_ue2 = GetDeltaPhi(particle_dir.Phi(), ue2[i].Phi()); - float deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("antiproton_all_jet"), track.pt()); - if (particle.isPhysicalPrimary()) { - registryMC.fill(HIST("antiproton_prim_jet"), track.pt()); - } - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("antiproton_all_ue"), track.pt()); - if (particle.isPhysicalPrimary()) { - registryMC.fill(HIST("antiproton_prim_ue"), track.pt()); - } - } - } - } - } - } - PROCESS_SWITCH(nuclei_in_jets, processSecondaryAntiprotons, "process secondary antiprotons", false); - - void processAntiprotonReweighting(o2::aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) - { - for (const auto& mccollision : mcCollisions) { - - registryMC.fill(HIST("number_of_events_mc"), 7.5); - - // Selection on z_{vertex} - if (TMath::Abs(mccollision.posZ()) > 10) - continue; - registryMC.fill(HIST("number_of_events_mc"), 8.5); - - // MC Particles per Collision - auto mcParticles_per_coll = mcParticles.sliceBy(perMCCollision, mccollision.globalIndex()); - - // List of Tracks - std::vector trk; - - for (auto& particle : mcParticles_per_coll) { - if (particle.isPhysicalPrimary() && particle.pdgCode() == -2212) { - registryMC.fill(HIST("antiproton_eta_pt_pythia"), particle.pt(), particle.eta()); - } - - // Select Primary Particles - double dx = particle.vx() - mccollision.posX(); - double dy = particle.vy() - mccollision.posY(); - double dz = particle.vz() - mccollision.posZ(); - double dcaxy = sqrt(dx * dx + dy * dy); - double dcaz = TMath::Abs(dz); - - if (setDCAselectionPtDep) { - if (dcaxy > (par0 + par1 / particle.pt())) - continue; - if (dcaz > (par0 + par1 / particle.pt())) - continue; - } - if (!setDCAselectionPtDep) { - if (dcaxy > max_dcaxy) - continue; - if (dcaz > max_dcaz) - continue; - } - - if (TMath::Abs(particle.eta()) > 0.8) - continue; - if (particle.pt() < 0.15) - continue; - - // PDG Selection - int pdg = TMath::Abs(particle.pdgCode()); - if ((pdg != 11) && (pdg != 211) && (pdg != 321) && (pdg != 2212)) - continue; - - TVector3 momentum(particle.px(), particle.py(), particle.pz()); - trk.push_back(momentum); - } - - // Anti-kt Jet Finder - int n_particles_removed(0); - std::vector jet; - std::vector ue1; - std::vector ue2; - - do { - double dij_min(1e+06), diB_min(1e+06); - int i_min(0), j_min(0), iB_min(0); - for (int i = 0; i < static_cast(trk.size()); i++) { - if (trk[i].Mag() == 0) - continue; - double diB = 1.0 / (trk[i].Pt() * trk[i].Pt()); - if (diB < diB_min) { - diB_min = diB; - iB_min = i; - } - for (int j = (i + 1); j < static_cast(trk.size()); j++) { - if (trk[j].Mag() == 0) - continue; - double dij = calculate_dij(trk[i], trk[j], Rjet); - if (dij < dij_min) { - dij_min = dij; - i_min = i; - j_min = j; - } - } - } - if (dij_min < diB_min) { - trk[i_min] = trk[i_min] + trk[j_min]; - trk[j_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - if (dij_min > diB_min) { - jet.push_back(trk[iB_min]); - trk[iB_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - } while (n_particles_removed < static_cast(trk.size())); - - // Jet Selection - std::vector isSelected; - for (int i = 0; i < static_cast(jet.size()); i++) { - isSelected.push_back(0); - } - - int n_jets_selected(0); - for (int i = 0; i < static_cast(jet.size()); i++) { - - if ((TMath::Abs(jet[i].Eta()) + Rjet) > max_eta) - continue; - - // Perpendicular cones - TVector3 ue_axis1(0, 0, 0); - TVector3 ue_axis2(0, 0, 0); - get_perpendicular_axis(jet[i], ue_axis1, +1); - get_perpendicular_axis(jet[i], ue_axis2, -1); - ue1.push_back(ue_axis1); - ue2.push_back(ue_axis2); - - double nPartJetPlusUE(0); - double ptJetPlusUE(0); - double ptJet(0); - double ptUE(0); - - for (auto& particle : mcParticles_per_coll) { - - // Select Primary Particles - double dx = particle.vx() - mccollision.posX(); - double dy = particle.vy() - mccollision.posY(); - double dz = particle.vz() - mccollision.posZ(); - double dcaxy = sqrt(dx * dx + dy * dy); - double dcaz = TMath::Abs(dz); - - if (setDCAselectionPtDep) { - if (dcaxy > (par0 + par1 / particle.pt())) - continue; - if (dcaz > (par0 + par1 / particle.pt())) - continue; - } - if (!setDCAselectionPtDep) { - if (dcaxy > max_dcaxy) - continue; - if (dcaz > max_dcaz) - continue; - } - - if (TMath::Abs(particle.eta()) > 0.8) - continue; - if (particle.pt() < 0.15) - continue; - - // PDG Selection - int pdg = TMath::Abs(particle.pdgCode()); - if ((pdg != 11) && (pdg != 211) && (pdg != 321) && (pdg != 2212)) - continue; - - TVector3 sel_track(particle.px(), particle.py(), particle.pz()); - - double deltaEta_jet = sel_track.Eta() - jet[i].Eta(); - double deltaPhi_jet = GetDeltaPhi(sel_track.Phi(), jet[i].Phi()); - double deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = sel_track.Eta() - ue_axis1.Eta(); - double deltaPhi_ue1 = GetDeltaPhi(sel_track.Phi(), ue_axis1.Phi()); - double deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = sel_track.Eta() - ue_axis2.Eta(); - double deltaPhi_ue2 = GetDeltaPhi(sel_track.Phi(), ue_axis2.Phi()); - double deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - if (deltaR_jet < Rjet) { - nPartJetPlusUE++; - ptJetPlusUE = ptJetPlusUE + sel_track.Pt(); - } - if (deltaR_ue1 < Rjet) { - ptUE = ptUE + sel_track.Pt(); - } - if (deltaR_ue2 < Rjet) { - ptUE = ptUE + sel_track.Pt(); - } - } - ptJet = ptJetPlusUE - 0.5 * ptUE; - - if (ptJet < min_jet_pt) - continue; - if (nPartJetPlusUE < min_nPartInJet) - continue; - n_jets_selected++; - isSelected[i] = 1; - } - if (n_jets_selected == 0) - continue; - - for (int i = 0; i < static_cast(jet.size()); i++) { - - if (isSelected[i] == 0) - continue; - - // Generated Particles - for (auto& particle : mcParticles_per_coll) { - - if (!particle.isPhysicalPrimary()) - continue; - if (particle.pdgCode() != -2212) - continue; - - TVector3 particle_dir(particle.px(), particle.py(), particle.pz()); - double deltaEta_jet = particle_dir.Eta() - jet[i].Eta(); - double deltaPhi_jet = GetDeltaPhi(particle_dir.Phi(), jet[i].Phi()); - double deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = particle_dir.Eta() - ue1[i].Eta(); - double deltaPhi_ue1 = GetDeltaPhi(particle_dir.Phi(), ue1[i].Phi()); - double deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = particle_dir.Eta() - ue2[i].Eta(); - double deltaPhi_ue2 = GetDeltaPhi(particle_dir.Phi(), ue2[i].Phi()); - double deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("antiproton_eta_pt_jet"), particle.pt(), particle.eta()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("antiproton_eta_pt_ue"), particle.pt(), particle.eta()); - } - } - } - } - } - PROCESS_SWITCH(nuclei_in_jets, processAntiprotonReweighting, "Process antiproton reweighting", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/PWGLF/Tasks/Nuspex/nucleitpcpbpb.cxx b/PWGLF/Tasks/Nuspex/nucleitpcpbpb.cxx new file mode 100644 index 00000000000..d69d0b97b93 --- /dev/null +++ b/PWGLF/Tasks/Nuspex/nucleitpcpbpb.cxx @@ -0,0 +1,788 @@ +// 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. + +/// \file nucleitpcpbpb.cxx +/// \brief nuclei analysis +/// \note under work +/// +/// \author Jaideep Tanwar , Panjab University + +#include "Common/Core/PID/PIDTOF.h" +#include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include + +#include +#include +#include +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using CollisionsFull = soa::Join; +using TracksFull = soa::Join; +using CollisionsFullMC = soa::Join; +//--------------------------------------------------------------------------------------------------------------------------------- +namespace +{ +static const int nParticles = 6; +static const std::vector particleNames{"pion", "proton", "deuteron", "triton", "helion", "alpha"}; +static const std::vector particlePdgCodes{211, 2212, o2::constants::physics::kDeuteron, o2::constants::physics::kTriton, o2::constants::physics::kHelium3, o2::constants::physics::kAlpha}; +static const std::vector particleMasses{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron, o2::constants::physics::MassTriton, o2::constants::physics::MassHelium3, o2::constants::physics::MassAlpha}; +static const std::vector particleCharge{1, 1, 1, 1, 2, 2}; +const int nBetheParams = 6; +static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; +constexpr double kBetheBlochDefault[nParticles][nBetheParams]{ + {13.611469, 3.598765, -0.021138, 2.039562, 0.651040, 0.09}, // pion + {5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09}, // proton + {5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09}, // deuteron + {5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09}, // triton + {-126.557359, -0.858569, 1.111643, 1.210323, 2.656374, 0.09}, // helion + {-126.557359, -0.858569, 1.111643, 1.210323, 2.656374, 0.09}}; // alpha +const int nTrkSettings = 19; +static const std::vector trackPIDsettingsNames{"useBBparams", "minITSnCls", "minITSnClscos", "minTPCnCls", "maxTPCchi2", "minTPCchi2", "maxITSchi2", "minRigidity", "maxRigidity", "maxTPCnSigma", "TOFrequiredabove", "minTOFmass", "maxTOFmass", "maxDcaXY", "maxDcaZ", "minITSclsSize", "maxITSclsSize", "minTPCnClsCrossedRows", "minReqClusterITSib"}; +constexpr double kTrackPIDSettings[nParticles][nTrkSettings]{ + {0, 0, 4, 60, 4.0, 0.5, 100, 0.15, 1.2, 2.5, -1, 0, 100, 2., 2., 0., 1000, 70, 1}, + {1, 0, 4, 70, 4.0, 0.5, 100, 0.20, 4.0, 3.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1}, + {1, 0, 4, 70, 4.0, 0.5, 100, 0.50, 5.0, 3.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1}, + {1, 0, 4, 70, 4.0, 0.5, 100, 0.50, 5.0, 3.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1}, + {1, 0, 4, 75, 4.0, 0.5, 100, 0.50, 5.0, 5.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1}, + {1, 0, 4, 70, 4.0, 0.5, 100, 0.50, 5.0, 5.0, -1, 0, 100, 2., 2., 0., 1000, 70, 1}}; +struct PrimParticles { + TString name; + int pdgCode, charge; + double mass, resolution; + std::vector betheParams; + bool active; + PrimParticles(std::string name_, int pdgCode_, double mass_, int charge_, LabeledArray bethe) : name(name_), pdgCode(pdgCode_), charge(charge_), mass(mass_), active(false) + { + resolution = bethe.get(name, "resolution"); + betheParams.clear(); + constexpr unsigned int kNSpecies = 5; + for (unsigned int i = 0; i < kNSpecies; i++) + betheParams.push_back(bethe.get(name, i)); + } +}; // struct PrimParticles +//---------------------------------------------------------------------------------------------------------------- +std::vector> hDeDx; +std::vector> hNsigmaPt; +std::vector> hmass; +} // namespace +//---------------------------------------------------------------------------------------------------------------- +struct NucleitpcPbPb { + Preslice perCollision = aod::track_association::collisionId; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry histomc{"histomc", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + Configurable cfgDebug{"cfgDebug", 1, "debug level"}; + // event Selections cuts + Configurable removeITSROFrameBorder{"removeITSROFrameBorder", false, "Remove TF border"}; + Configurable removeNoSameBunchPileup{"removeNoSameBunchPileup", false, "Remove TF border"}; + Configurable requireIsGoodZvtxFT0vsPV{"requireIsGoodZvtxFT0vsPV", false, "Remove TF border"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "Remove TF border"}; + Configurable removeNoTimeFrameBorder{"removeNoTimeFrameBorder", false, "Remove TF border"}; + Configurable cfgRigidityCorrection{"cfgRigidityCorrection", false, "apply rigidity correction"}; + // Track Selection Cuts + Configurable cfgCutEta{"cfgCutEta", 0.9f, "Eta range for tracks"}; + Configurable cfgetaRequire{"cfgetaRequire", true, "eta cut require"}; + Configurable cfgetaRequireMC{"cfgetaRequireMC", true, "eta cut require for generated particles"}; + Configurable cfgrapidityRequireMC{"cfgrapidityRequireMC", true, "rapidity cut require for generated particles"}; + Configurable cfgUsePVcontributors{"cfgUsePVcontributors", true, "use tracks that are PV contibutors"}; + Configurable cfgITSrequire{"cfgITSrequire", true, "Additional cut on ITS require"}; + Configurable cfgTPCrequire{"cfgTPCrequire", true, "Additional cut on TPC require"}; + Configurable cfgPassedITSRefit{"cfgPassedITSRefit", true, "Require ITS refit"}; + Configurable cfgPassedTPCRefit{"cfgPassedTPCRefit", true, "Require TPC refit"}; + Configurable cfgRapidityRequire{"cfgRapidityRequire", true, "Require Rapidity cut"}; + Configurable cfgTPCNClsfoundRequire{"cfgTPCNClsfoundRequire", true, "Require TPCNClsfound Cut"}; + Configurable cfgTPCNClsCrossedRowsRequire{"cfgTPCNClsCrossedRowsRequire", true, "Require TPCNClsCrossedRows Cut"}; + Configurable cfgmaxTPCchi2Require{"cfgmaxTPCchi2Require", true, "Require maxTPCchi2 Cut"}; + Configurable cfgminTPCchi2Require{"cfgminTPCchi2Require", true, "Require minTPCchi2 Cut"}; + Configurable cfgminITSnClsRequire{"cfgminITSnClsRequire", false, "Require minITSnCls Cut"}; + Configurable cfgmccorrectionhe4Require{"cfgmccorrectionhe4Require", true, "MC correction for pp he4 particle"}; + Configurable cfgminITSnClscosRequire{"cfgminITSnClscosRequire", true, "Require minITSnCls / cosh(eta) Cut"}; + Configurable cfgminReqClusterITSibRequire{"cfgminReqClusterITSibRequire", true, " Require min number of clusters required in ITS inner barrel"}; + Configurable cfgmaxITSchi2Require{"cfgmaxITSchi2Require", true, "Require maxITSchi2 Cut"}; + Configurable cfgmaxTPCnSigmaRequire{"cfgmaxTPCnSigmaRequire", true, "Require maxTPCnSigma Cut"}; + Configurable cfgmaxITSnSigmaRequire{"cfgmaxITSnSigmaRequire", true, "Require maxITSnSigma Cut for helium"}; + Configurable cfgminGetMeanItsClsSizeRequire{"cfgminGetMeanItsClsSizeRequire", true, "Require minGetMeanItsClsSize Cut"}; + Configurable cfgmaxGetMeanItsClsSizeRequire{"cfgmaxGetMeanItsClsSizeRequire", true, "Require maxGetMeanItsClsSize Cut"}; + Configurable cfgRigidityCutRequire{"cfgRigidityCutRequire", true, "Require Rigidity Cut"}; + Configurable cfgmassRequire{"cfgmassRequire", true, "Require mass Cuts"}; + Configurable cfgDCAwithptRequire{"cfgDCAwithptRequire", true, "Require DCA cuts with pt dependance"}; + Configurable cfgDCAnopt{"cfgDCAnopt", true, "Require DCA cuts without pt dependance"}; + Configurable cfgTwicemass{"cfgTwicemass", true, "multiply mass by its charge"}; + Configurable cfgRequirebetaplot{"cfgRequirebetaplot", true, "Require beta plot"}; + Configurable cfgRequireMCposZ{"cfgRequireMCposZ", true, "Require beta plot"}; + + Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {kBetheBlochDefault[0], nParticles, nBetheParams, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for light nuclei"}; + Configurable> cfgTrackPIDsettings{"cfgTrackPIDsettings", {kTrackPIDSettings[0], nParticles, nTrkSettings, particleNames, trackPIDsettingsNames}, "track selection and PID criteria"}; + Configurable cfgFillDeDxWithCut{"cfgFillDeDxWithCut", true, "Fill with cut beth bloch"}; + Configurable cfgFillnsigma{"cfgFillnsigma", false, "Fill n-sigma histograms"}; + Configurable cfgFillmass{"cfgFillmass", false, "Fill mass histograms"}; + Configurable centcut{"centcut", 80.0f, "centrality cut"}; + Configurable cfgCutRapidity{"cfgCutRapidity", 0.5f, "Rapidity range"}; + Configurable cfgZvertex{"cfgZvertex", 10, "Min Z Vertex"}; + Configurable cfgZvertexRequire{"cfgZvertexRequire", true, "Pos Z cut require"}; + Configurable cfgZvertexRequireMC{"cfgZvertexRequireMC", true, "Pos Z cut require for generated particles"}; + Configurable cfgsel8Require{"cfgsel8Require", true, "sel8 cut require"}; + Configurable cfgITSnsigma{"cfgITSnsigma", 5, "Max ITS nsigma value"}; + Configurable cfgtpcNClsFound{"cfgtpcNClsFound", 100.0f, "min. no. of tpcNClsFound"}; + Configurable cfgitsNCls{"cfgitsNCls", 2.0f, "min. no. of itsNCls"}; + o2::track::TrackParametrizationWithError mTrackParCov; + // Binning configuration + ConfigurableAxis axisMagField{"axisMagField", {10, -10., 10.}, "magnetic field"}; + ConfigurableAxis axisNev{"axisNev", {3, 0., 3.}, "Number of events"}; + ConfigurableAxis axisRigidity{"axisRigidity", {4000, -10., 10.}, "#it{p}^{TPC}/#it{z}"}; + ConfigurableAxis axisdEdx{"axisdEdx", {4000, 0, 4000}, "d#it{E}/d#it{x}"}; + ConfigurableAxis axisCent{"axisCent", {100, 0, 100}, "centrality"}; + ConfigurableAxis axisVtxZ{"axisVtxZ", {120, -20, 20}, "z"}; + ConfigurableAxis axisImpt{"axisImpt", {100, 0, 20}, "impact parameter"}; + ConfigurableAxis ptAxis{"ptAxis", {200, 0, 10}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axiseta{"axiseta", {100, -1, 1}, "eta"}; + ConfigurableAxis axisrapidity{"axisrapidity", {100, -2, 2}, "rapidity"}; + ConfigurableAxis axismass{"axismass", {100, -10, 10}, "mass^{2}"}; + ConfigurableAxis nsigmaAxis{"nsigmaAxis", {160, -20, 20}, "n#sigma_{#pi^{+}}"}; + // CCDB + Service ccdb; + Configurable bField{"bField", -999, "bz field, -999 is automatic"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable pidPath{"pidPath", "", "Path to the PID response object"}; + + std::vector primaryParticles; + std::vector primVtx, cents; + bool collHasCandidate, collPassedEvSel, collPassedEvSelMc; + int mRunNumber, occupancy; + float dBz, momn; + TRandom3 rand; + float he3 = 4; + float he4 = 5; + //---------------------------------------------------------------------------------------------------------------- + void init(InitContext const&) + { + mRunNumber = 0; + dBz = 0; + rand.SetSeed(0); + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + for (int i = 0; i < nParticles; i++) { // create primaryParticles + primaryParticles.push_back(PrimParticles(particleNames.at(i), particlePdgCodes.at(i), particleMasses.at(i), particleCharge.at(i), cfgBetheBlochParams)); + } + // create histograms + if (doprocessData) { + histos.add("histMagField", "histMagField", kTH1F, {axisMagField}); + histos.add("histNev", "histNev", kTH1F, {axisNev}); + histos.add("histVtxZ", "histVtxZ", kTH1F, {axisVtxZ}); + histos.add("histCentFT0C", "histCentFT0C", kTH1F, {axisCent}); + histos.add("histCentFT0M", "histCentFT0M", kTH1F, {axisCent}); + histos.add("histCentFTOC_cut", "histCentFTOC_cut", kTH1F, {axisCent}); + } + histos.add("histeta", "histeta", kTH1F, {axiseta}); + histos.add("Tofsignal", "Tofsignal", kTH2F, {axisRigidity, {4000, 0.2, 1.2, "#beta"}}); + histos.add("histDcaZVsPtData_particle", "dcaZ vs Pt (particle)", HistType::kTH2F, {{1000, 0, 20}, {1000, -2.5, 2.5, "dca"}}); + histos.add("histDcaXYVsPtData_particle", "dcaXY vs Pt (particle)", HistType::kTH2F, {{1000, 0, 20}, {1000, -2.0, 2.0, "dca"}}); + histos.add("histDcaZVsPtData_antiparticle", "dcaZ vs Pt (antiparticle)", HistType::kTH2F, {{1000, 0, 20}, {1000, -2.5, 2.5, "dca"}}); + histos.add("histDcaXYVsPtData_antiparticle", "dcaXY vs Pt (antiparticle)", HistType::kTH2F, {{1000, 0, 20}, {1000, -2.0, 2.0, "dca"}}); + hDeDx.resize(2 * nParticles + 2); + hNsigmaPt.resize(2 * nParticles + 2); + hmass.resize(2 * nParticles + 2); + for (int i = 0; i < nParticles + 1; i++) { + TString histName = i < nParticles ? primaryParticles[i].name : "all"; + if (cfgFillDeDxWithCut) { + hDeDx[2 * i] = histos.add(Form("dedx/histdEdx_%s_Cuts", histName.Data()), ";p_{TPC}/z (GeV/#it{c}); d#it{E}/d#it{x}", HistType::kTH2F, {axisRigidity, axisdEdx}); + } + } + for (int i = 0; i < nParticles; i++) { + TString histName = primaryParticles[i].name; + if (cfgFillnsigma) { + hNsigmaPt[2 * i] = histos.add(Form("histnsigmaTPC_%s", histName.Data()), ";p_T{TPC} (GeV/#it{c}); TPCnsigma", HistType::kTH2F, {ptAxis, nsigmaAxis}); + hNsigmaPt[2 * i + 1] = histos.add(Form("histnsigmaTPC_anti_%s", histName.Data()), ";p_T{TPC} (GeV/#it{c}); TPCnsigma", HistType::kTH2F, {ptAxis, nsigmaAxis}); + } + if (cfgFillmass) { + hmass[2 * i] = histos.add(Form("histmass_pt/histmass_%s", histName.Data()), ";p_T{TPC} (GeV/#it{c}); mass^{2}", HistType::kTH2F, {ptAxis, axismass}); + hmass[2 * i + 1] = histos.add(Form("histmass_ptanti/histmass_%s", histName.Data()), ";p_T{TPC} (GeV/#it{c}); mass^{2}", HistType::kTH2F, {ptAxis, axismass}); + } + } + + if (doprocessMC) { + histomc.add("histVtxZgen", "histVtxZgen", kTH1F, {axisVtxZ}); + histomc.add("ImptParameter", "ImptParameter", kTH1F, {axisImpt}); + histomc.add("histEtagen", "histEtagen", kTH1F, {axiseta}); + histomc.add("histPtgenHe3", "histPtgenHe3", kTH1F, {ptAxis}); + histomc.add("histPtgenAntiHe3", "histPtgenAntiHe3", kTH1F, {ptAxis}); + histomc.add("histPtgenHe4", "histPtgenHe4", kTH1F, {ptAxis}); + histomc.add("histPtgenAntiHe4", "histPtgenAntiHe4", kTH1F, {ptAxis}); + // Reconstrcuted eta + histomc.add("histNevReco", "histNevReco", kTH1F, {axisNev}); + histomc.add("histVtxZReco", "histVtxZReco", kTH1F, {axisVtxZ}); + histomc.add("histCentFT0CReco", "histCentFT0CReco", kTH1F, {axisCent}); + histomc.add("histCentFT0MReco", "histCentFT0MReco", kTH1F, {axisCent}); + histomc.add("histPtRecoHe3", "histPtgenHe3", kTH1F, {ptAxis}); + histomc.add("histPtRecoAntiHe3", "histPtgenAntiHe3", kTH1F, {ptAxis}); + histomc.add("histPtRecoHe4", "histPtgenHe4", kTH1F, {ptAxis}); + histomc.add("histPtRecoAntiHe4", "histPtgenAntiHe4", kTH1F, {ptAxis}); + histomc.add("histDeltaPtVsPtGen", " delta pt vs pt rec", HistType::kTH2F, {{1000, 0, 10}, {1000, -0.5, 0.5, "p_{T}(reco) - p_{T}(gen);p_{T}(reco)"}}); + histomc.add("histPIDtrack", " delta pt vs pt rec", HistType::kTH2F, {{1000, 0, 10, "p_{T}(reco)"}, {9, -0.5, 8.5, "p_{T}(reco) - p_{T}(gen)"}}); + histomc.add("histDeltaPtVsPtGenHe4", " delta pt vs pt rec", HistType::kTH2F, {{1000, 0, 10}, {1000, -0.5, 0.5, "p_{T}(reco) - p_{T}(gen);p_{T}(reco)"}}); + } + } + //---------------------------------------------------------------------------------------------------------------- + void findprimaryParticles(aod::TrackAssoc const& tracksByColl, TracksFull const& tracks) + { + for (const auto& trackId : tracksByColl) { + const auto& track = tracks.rawIteratorAt(trackId.trackId()); + if (!track.isPVContributor() && cfgUsePVcontributors) + continue; + if (!track.hasITS() && cfgITSrequire) + continue; + if (!track.hasTPC() && cfgTPCrequire) + continue; + if (!track.passedITSRefit() && cfgPassedITSRefit) + continue; + if (!track.passedTPCRefit() && cfgPassedTPCRefit) + continue; + if (std::abs(track.eta()) > cfgCutEta && cfgetaRequire) + continue; + for (size_t i = 0; i < primaryParticles.size(); i++) { + if (std::abs(getRapidity(track, i)) > cfgCutRapidity && cfgRapidityRequire) + continue; + if (track.tpcNClsFound() < cfgTrackPIDsettings->get(i, "minTPCnCls") && cfgTPCNClsfoundRequire) + continue; + if (((track.tpcNClsCrossedRows() < cfgTrackPIDsettings->get(i, "minTPCnClsCrossedRows")) || track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable()) && cfgTPCNClsCrossedRowsRequire) // o2-linter: disable=magic-number (To be checked) + continue; + if (track.tpcChi2NCl() > cfgTrackPIDsettings->get(i, "maxTPCchi2") && cfgmaxTPCchi2Require) + continue; + if (track.tpcChi2NCl() < cfgTrackPIDsettings->get(i, "minTPCchi2") && cfgminTPCchi2Require) + continue; + if (track.itsNCls() < cfgTrackPIDsettings->get(i, "minITSnCls") && cfgminITSnClsRequire) + continue; + double cosheta = std::cosh(track.eta()); + if ((track.itsNCls() / cosheta) < cfgTrackPIDsettings->get(i, "minITSnClscos") && cfgminITSnClscosRequire) + continue; + if ((track.itsNClsInnerBarrel() < cfgTrackPIDsettings->get(i, "minReqClusterITSib")) && cfgminReqClusterITSibRequire) + continue; + if (track.itsChi2NCl() > cfgTrackPIDsettings->get(i, "maxITSchi2") && cfgmaxITSchi2Require) + continue; + if (getMeanItsClsSize(track) < cfgTrackPIDsettings->get(i, "minITSclsSize") && cfgminGetMeanItsClsSizeRequire) + continue; + if (getMeanItsClsSize(track) > cfgTrackPIDsettings->get(i, "maxITSclsSize") && cfgmaxGetMeanItsClsSizeRequire) + continue; + if ((getRigidity(track) < cfgTrackPIDsettings->get(i, "minRigidity") || getRigidity(track) > cfgTrackPIDsettings->get(i, "maxRigidity")) && cfgRigidityCutRequire) + continue; + float ptMomn; + setTrackParCov(track, mTrackParCov); + mTrackParCov.setPID(track.pidForTracking()); + ptMomn = (i == he3 || i == he4) ? 2 * mTrackParCov.getPt() : mTrackParCov.getPt(); + bool insideDCAxy = (std::abs(track.dcaXY()) <= (cfgTrackPIDsettings->get(i, "maxDcaXY") * (0.0105f + 0.0350f / std::pow(ptMomn, 1.1f)))); // o2-linter: disable=magic-number (To be checked) + if ((!(insideDCAxy) || std::abs(track.dcaZ()) > dcazSigma(ptMomn, cfgTrackPIDsettings->get(i, "maxDcaZ"))) && cfgDCAwithptRequire) + continue; + if (track.sign() > 0) { + histos.fill(HIST("histDcaZVsPtData_particle"), ptMomn, track.dcaZ()); + histos.fill(HIST("histDcaXYVsPtData_particle"), ptMomn, track.dcaXY()); + } + if (track.sign() < 0) { + histos.fill(HIST("histDcaZVsPtData_antiparticle"), ptMomn, track.dcaZ()); + histos.fill(HIST("histDcaXYVsPtData_antiparticle"), ptMomn, track.dcaXY()); + } + float tpcNsigma = getTPCnSigma(track, primaryParticles.at(i)); + if ((std::abs(tpcNsigma) > cfgTrackPIDsettings->get(i, "maxTPCnSigma")) && cfgmaxTPCnSigmaRequire) + continue; + float itsSigma = getITSnSigma(track, primaryParticles.at(i)); + if ((std::abs(itsSigma) > cfgITSnsigma) && cfgmaxITSnSigmaRequire) + continue; + fillnsigma(track, i); + filldedx(track, i); + // TOF selection + if (!track.hasTOF() && cfgTrackPIDsettings->get(i, "TOFrequiredabove") < 1) + continue; + float beta{o2::pid::tof::Beta::GetBeta(track)}; + float charge{1.f + static_cast(i == he3 || i == he4)}; + float tofMasses = getRigidity(track) * charge * std::sqrt(1.f / (beta * beta) - 1.f); + if ((getRigidity(track) > cfgTrackPIDsettings->get(i, "TOFrequiredabove") && (tofMasses < cfgTrackPIDsettings->get(i, "minTOFmass") || tofMasses > cfgTrackPIDsettings->get(i, "maxTOFmass"))) && cfgmassRequire) + continue; + fillhmass(track, i); + if (cfgRequirebetaplot) { + histos.fill(HIST("Tofsignal"), getRigidity(track) * track.sign(), o2::pid::tof::Beta::GetBeta(track)); + } + filldedx(track, nParticles); + } + histos.fill(HIST("histeta"), track.eta()); + } // track loop + } + //---------------------------------------------------------------------------------------------------------------- + void processData(CollisionsFull const& collisions, TracksFull const& tracks, aod::BCsWithTimestamps const&, aod::TrackAssoc const& tracksColl) + { + for (const auto& collision : collisions) { + auto bc = collision.bc_as(); + initCCDB(bc); + initCollision(collision); + if (!collPassedEvSel) + continue; + if (collision.centFT0C() > centcut) + continue; + if (removeITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) + continue; + if (removeNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) + continue; + if (requireIsGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) + continue; + if (requireIsVertexITSTPC && !collision.selection_bit(aod::evsel::kIsVertexITSTPC)) + continue; + if (removeNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) + continue; + histos.fill(HIST("histCentFTOC_cut"), collision.centFT0C()); + const uint64_t collIdx = collision.globalIndex(); + auto tracksByColl = tracksColl.sliceBy(perCollision, collIdx); + findprimaryParticles(tracksByColl, tracks); + if (!collHasCandidate) + continue; + } + } + PROCESS_SWITCH(NucleitpcPbPb, processData, "data analysis", false); + //---------------------------------------------------------------------------------------------------------------- + // MC particles + //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + struct McCollInfo { + bool passedEvSel = false; + }; + std::vector mcCollInfos; + void processMC(CollisionsFullMC const& collisions, aod::McCollisions const& mcCollisions, TracksFull const& tracks, aod::BCsWithTimestamps const& bcs, aod::McParticles const& particlesMC, aod::McTrackLabels const& trackLabelsMC, aod::McCollisionLabels const& collLabels, aod::TrackAssoc const& tracksColl, CollisionsFull const& colls) + { + (void)colls; + (void)collLabels; + (void)bcs; + mcCollInfos.clear(); + mcCollInfos.resize(mcCollisions.size()); + // ----------------------------- Generated particles loop ----------------------------- + for (auto const& mcColl : mcCollisions) { + if (std::abs(mcColl.posZ()) > cfgZvertex && cfgZvertexRequireMC) + continue; + histomc.fill(HIST("histVtxZgen"), mcColl.posZ()); + histomc.fill(HIST("ImptParameter"), mcColl.impactParameter()); + for (auto const& mcParticle : particlesMC) { + if (mcParticle.mcCollisionId() != mcColl.globalIndex()) + continue; + if (!mcParticle.isPhysicalPrimary()) + continue; + int pdgCode = mcParticle.pdgCode(); + if (std::abs(mcParticle.y()) > cfgCutRapidity && cfgrapidityRequireMC) + continue; + if (std::abs(mcParticle.eta()) > cfgCutEta && cfgetaRequireMC) + continue; + histomc.fill(HIST("histEtagen"), mcParticle.eta()); + float ptScaled = mcParticle.pt(); + if (pdgCode == particlePdgCodes.at(4)) { + histomc.fill(HIST("histPtgenHe3"), ptScaled); + } else if (pdgCode == -particlePdgCodes.at(4)) { + histomc.fill(HIST("histPtgenAntiHe3"), ptScaled); + } else if (pdgCode == particlePdgCodes.at(5)) { + histomc.fill(HIST("histPtgenHe4"), ptScaled); + } else if (pdgCode == -particlePdgCodes.at(5)) { + histomc.fill(HIST("histPtgenAntiHe4"), ptScaled); + } + } // mc track loop generated + } // mc collision loop generated + // ----------------------------- Reconstructed track loop ----------------------------- + for (auto const& collision : collisions) { + auto mcCollIdx = collision.mcCollisionId(); + if (mcCollIdx < 0 || mcCollIdx >= mcCollisions.size()) + continue; + auto bc = collision.bc_as(); + initCCDB(bc); + collHasCandidate = false; + histomc.fill(HIST("histNevReco"), 0.5); + if (std::abs(collision.posZ()) > cfgZvertex && cfgZvertexRequire) + continue; + collPassedEvSel = collision.sel8(); + occupancy = collision.trackOccupancyInTimeRange(); + if (!collPassedEvSel && cfgsel8Require) + continue; + histomc.fill(HIST("histNevReco"), 1.5); + histomc.fill(HIST("histVtxZReco"), collision.posZ()); + histomc.fill(HIST("histCentFT0CReco"), collision.centFT0C()); + histomc.fill(HIST("histCentFT0MReco"), collision.centFT0M()); + if (collision.centFT0C() > centcut) + continue; + if (removeITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) + continue; + if (removeNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) + continue; + if (requireIsGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) + continue; + if (requireIsVertexITSTPC && !collision.selection_bit(aod::evsel::kIsVertexITSTPC)) + continue; + if (removeNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) + continue; + // Loop through TrackAssoc and check if this track belongs to the current collision + for (const auto& assoc : tracksColl) { + if (assoc.collisionId() != collision.globalIndex()) + continue; + const auto& track = tracks.rawIteratorAt(assoc.trackId()); + auto labelRow = trackLabelsMC.iteratorAt(track.globalIndex()); + int label = labelRow.mcParticleId(); + if (label < 0 || label >= particlesMC.size()) + continue; + auto const& matchedMCParticle = particlesMC.iteratorAt(label); + int pdg = matchedMCParticle.pdgCode(); + if (!track.isPVContributor() && cfgUsePVcontributors) + continue; + if (!track.hasITS() && cfgITSrequire) + continue; + if (!track.hasTPC() && cfgTPCrequire) + continue; + if (!track.passedITSRefit() && cfgPassedITSRefit) + continue; + if (!track.passedTPCRefit() && cfgPassedTPCRefit) + continue; + if (std::abs(track.eta()) > cfgCutEta && cfgetaRequire) + continue; + if (!matchedMCParticle.isPhysicalPrimary()) + continue; + for (size_t i = 0; i < primaryParticles.size(); i++) { + if (std::abs(pdg) != std::abs(particlePdgCodes.at(i))) + continue; + if (std::abs(getRapidity(track, i)) > cfgCutRapidity && cfgRapidityRequire) + continue; + if (track.tpcNClsFound() < cfgTrackPIDsettings->get(i, "minTPCnCls") && cfgTPCNClsfoundRequire) + continue; + if (((track.tpcNClsCrossedRows() < cfgTrackPIDsettings->get(i, "minTPCnClsCrossedRows")) || track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable()) && cfgTPCNClsCrossedRowsRequire) // o2-linter: disable=magic-number (To be checked) + continue; + if (track.tpcChi2NCl() > cfgTrackPIDsettings->get(i, "maxTPCchi2") && cfgmaxTPCchi2Require) + continue; + if (track.tpcChi2NCl() < cfgTrackPIDsettings->get(i, "minTPCchi2") && cfgminTPCchi2Require) + continue; + if (track.itsNCls() < cfgTrackPIDsettings->get(i, "minITSnCls") && cfgminITSnClsRequire) + continue; + double cosheta = std::cosh(track.eta()); + if ((track.itsNCls() / cosheta) < cfgTrackPIDsettings->get(i, "minITSnClscos") && cfgminITSnClscosRequire) + continue; + if ((track.itsNClsInnerBarrel() < cfgTrackPIDsettings->get(i, "minReqClusterITSib")) && cfgminReqClusterITSibRequire) + continue; + if (track.itsChi2NCl() > cfgTrackPIDsettings->get(i, "maxITSchi2") && cfgmaxITSchi2Require) + continue; + if (getMeanItsClsSize(track) < cfgTrackPIDsettings->get(i, "minITSclsSize") && cfgminGetMeanItsClsSizeRequire) + continue; + if (getMeanItsClsSize(track) > cfgTrackPIDsettings->get(i, "maxITSclsSize") && cfgmaxGetMeanItsClsSizeRequire) + continue; + if ((getRigidity(track) < cfgTrackPIDsettings->get(i, "minRigidity") || getRigidity(track) > cfgTrackPIDsettings->get(i, "maxRigidity")) && cfgRigidityCutRequire) + continue; + float ptMomn; + setTrackParCov(track, mTrackParCov); + mTrackParCov.setPID(track.pidForTracking()); + ptMomn = (i == he3 || i == he4) ? 2 * mTrackParCov.getPt() : mTrackParCov.getPt(); + bool insideDCAxy = (std::abs(track.dcaXY()) <= (cfgTrackPIDsettings->get(i, "maxDcaXY") * (0.0105f + 0.0350f / std::pow(ptMomn, 1.1f)))); // o2-linter: disable=magic-number (To be checked) + if ((!(insideDCAxy) || std::abs(track.dcaZ()) > dcazSigma(ptMomn, cfgTrackPIDsettings->get(i, "maxDcaZ"))) && cfgDCAwithptRequire) + continue; + if (track.sign() > 0) { + histos.fill(HIST("histDcaZVsPtData_particle"), ptMomn, track.dcaZ()); + histos.fill(HIST("histDcaXYVsPtData_particle"), ptMomn, track.dcaXY()); + } + if (track.sign() < 0) { + histos.fill(HIST("histDcaZVsPtData_antiparticle"), ptMomn, track.dcaZ()); + histos.fill(HIST("histDcaXYVsPtData_antiparticle"), ptMomn, track.dcaXY()); + } + float tpcNsigma = getTPCnSigma(track, primaryParticles.at(i)); + if ((std::abs(tpcNsigma) > cfgTrackPIDsettings->get(i, "maxTPCnSigma")) && cfgmaxTPCnSigmaRequire) + continue; + float itsSigma = getITSnSigma(track, primaryParticles.at(i)); + if ((std::abs(itsSigma) > cfgITSnsigma) && cfgmaxITSnSigmaRequire) + continue; + fillnsigma(track, i); + filldedx(track, i); + if (!track.hasTOF() && cfgTrackPIDsettings->get(i, "TOFrequiredabove") < 1) + continue; + float beta{o2::pid::tof::Beta::GetBeta(track)}; + float charge{1.f + static_cast(i == he3 || i == he4)}; + float tofMasses = getRigidity(track) * charge * std::sqrt(1.f / (beta * beta) - 1.f); + if ((getRigidity(track) > cfgTrackPIDsettings->get(i, "TOFrequiredabove") && (tofMasses < cfgTrackPIDsettings->get(i, "minTOFmass") || tofMasses > cfgTrackPIDsettings->get(i, "maxTOFmass"))) && cfgmassRequire) + continue; + fillhmass(track, i); + if (cfgRequirebetaplot) { + histos.fill(HIST("Tofsignal"), getRigidity(track) * track.sign(), o2::pid::tof::Beta::GetBeta(track)); + } + filldedx(track, nParticles); + /*----------------------------------------------------------------------------------------------------------------*/ + float ptReco; + mTrackParCov.setPID(track.pidForTracking()); + ptReco = (std::abs(pdg) == particlePdgCodes.at(4) || std::abs(pdg) == particlePdgCodes.at(5)) ? 2 * mTrackParCov.getPt() : mTrackParCov.getPt(); + if (pdg == -particlePdgCodes.at(5) && cfgmccorrectionhe4Require) { + ptReco = ptReco + 0.00765 + 0.503791 * std::exp(-1.10517 * ptReco); + } + + if (pdg == -particlePdgCodes.at(4) && cfgmccorrectionhe4Require) { + int pidGuess = track.pidForTracking(); + int antitriton = 6; + if (pidGuess == antitriton) { + ptReco = ptReco - 0.464215 + 0.195771 * ptReco - 0.0183111 * ptReco * ptReco; + // LOG(info) << "we have he3" << pidGuess; + } + } + float ptGen = matchedMCParticle.pt(); + float deltaPt = ptReco - ptGen; + + if (pdg == -particlePdgCodes.at(4)) { + histomc.fill(HIST("histDeltaPtVsPtGen"), ptReco, deltaPt); + histomc.fill(HIST("histPIDtrack"), ptReco, track.pidForTracking()); + } + if (pdg == -particlePdgCodes.at(5)) { + histomc.fill(HIST("histDeltaPtVsPtGenHe4"), ptReco, deltaPt); + } + if (pdg == particlePdgCodes.at(4)) { + histomc.fill(HIST("histPtRecoHe3"), ptReco); + } else if (pdg == -particlePdgCodes.at(4)) { + histomc.fill(HIST("histPtRecoAntiHe3"), ptReco); + } else if (pdg == particlePdgCodes.at(5)) { + histomc.fill(HIST("histPtRecoHe4"), ptReco); + } else if (pdg == -particlePdgCodes.at(5)) { + histomc.fill(HIST("histPtRecoAntiHe4"), ptReco); + } + } + histos.fill(HIST("histeta"), track.eta()); + /*----------------------------------------------------------------------------------------------------------------*/ + } // Track loop + } // Collision loop + } + PROCESS_SWITCH(NucleitpcPbPb, processMC, "MC reco+gen analysis", false); + //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + constexpr float kInvalidBField = -990.f; + auto run3grpTimestamp = bc.timestamp(); + dBz = 0; + o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grpTimestamp); + o2::parameters::GRPMagField* grpmag = 0x0; + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + if (bField < kInvalidBField) { + // Fetch magnetic field from ccdb for current collision + dBz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grpTimestamp << " with magnetic field of " << dBz << " kZG"; + } else { + dBz = bField; + } + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grpTimestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grpTimestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + if (bField < kInvalidBField) { + // Fetch magnetic field from ccdb for current collision + dBz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grpTimestamp << " with magnetic field of " << dBz << " kZG"; + } else { + dBz = bField; + } + } + mRunNumber = bc.runNumber(); + } + //---------------------------------------------------------------------------------------------------------------- + template + void initCollision(const T& collision) + { + collHasCandidate = false; + histos.fill(HIST("histMagField"), dBz); + histos.fill(HIST("histNev"), 0.5); + collPassedEvSel = collision.sel8() && std::abs(collision.posZ()) < cfgZvertex; + occupancy = collision.trackOccupancyInTimeRange(); + if (collPassedEvSel) { + histos.fill(HIST("histNev"), 1.5); + histos.fill(HIST("histVtxZ"), collision.posZ()); + histos.fill(HIST("histCentFT0C"), collision.centFT0C()); + histos.fill(HIST("histCentFT0M"), collision.centFT0M()); + } + primVtx.assign({collision.posX(), collision.posY(), collision.posZ()}); + cents.assign({collision.centFT0A(), collision.centFT0C(), collision.centFT0M()}); + } + //---------------------------------------------------------------------------------------------------------------- + template + void filldedx(T const& track, int species) + { + const float rigidity = getRigidity(track); + if (track.tpcNClsFound() < cfgtpcNClsFound || track.itsNCls() < cfgitsNCls) + return; + if (cfgFillDeDxWithCut) { + hDeDx[2 * species]->Fill(track.sign() * rigidity, track.tpcSignal()); + } + } + //---------------------------------------------------------------------------------------------------------------- + template + void fillnsigma(T const& track, int species) + { + if (track.tpcNClsFound() < cfgtpcNClsFound || track.itsNCls() < cfgitsNCls) + return; + if (cfgFillnsigma) { + int i = species; + const float tpcNsigma = getTPCnSigma(track, primaryParticles.at(i)); + float ptMomn; + setTrackParCov(track, mTrackParCov); + mTrackParCov.setPID(track.pidForTracking()); + ptMomn = (i == he3 || i == he4) ? 2 * mTrackParCov.getPt() : mTrackParCov.getPt(); + if (track.sign() > 0) { + hNsigmaPt[2 * species]->Fill(ptMomn, tpcNsigma); + } + if (track.sign() < 0) { + hNsigmaPt[2 * species + 1]->Fill(ptMomn, tpcNsigma); + } + } + } + //---------------------------------------------------------------------------------------------------------------- + template + void fillhmass(T const& track, int species) + { + if (track.tpcNClsFound() < cfgtpcNClsFound || track.itsNCls() < cfgitsNCls) + return; + if (!track.hasTOF() || !cfgFillmass) + return; + float beta{o2::pid::tof::Beta::GetBeta(track)}; + if (beta <= 0.f || beta >= 1.f) + return; + float charge = (species == he3 || species == he4) ? 2.f : 1.f; + float p = getRigidity(track); // assuming this is the momentum from inner TPC + float massTOF = p * charge * std::sqrt(1.f / (beta * beta) - 1.f); + // get PDG mass + float pdgMass = particleMasses[species]; + float massDiff = massTOF - pdgMass; + float ptMomn; + setTrackParCov(track, mTrackParCov); + mTrackParCov.setPID(track.pidForTracking()); + ptMomn = (species == he3 || species == he4) ? 2 * mTrackParCov.getPt() : mTrackParCov.getPt(); + if (track.sign() > 0) { + hmass[2 * species]->Fill(ptMomn, massDiff); + } else if (track.sign() < 0) { + hmass[2 * species + 1]->Fill(ptMomn, massDiff); + } + } + //---------------------------------------------------------------------------------------------------------------- + template + float getTPCnSigma(T const& track, PrimParticles& particle) + { + const float rigidity = getRigidity(track); + if (!track.hasTPC()) + return -999; + if (particle.name == "pion" && cfgTrackPIDsettings->get("pion", "useBBparams") < 1) + return cfgTrackPIDsettings->get("pion", "useBBparams") == 0 ? track.tpcNSigmaPi() : 0; + if (particle.name == "proton" && cfgTrackPIDsettings->get("proton", "useBBparams") < 1) + return cfgTrackPIDsettings->get("proton", "useBBparams") == 0 ? track.tpcNSigmaPr() : 0; + if (particle.name == "deuteron" && cfgTrackPIDsettings->get("deuteron", "useBBparams") < 1) + return cfgTrackPIDsettings->get("deuteron", "useBBparams") == 0 ? track.tpcNSigmaDe() : 0; + if (particle.name == "triton" && cfgTrackPIDsettings->get("triton", "useBBparams") < 1) + return cfgTrackPIDsettings->get("triton", "useBBparams") == 0 ? track.tpcNSigmaTr() : 0; + if (particle.name == "helion" && cfgTrackPIDsettings->get("helion", "useBBparams") < 1) + return cfgTrackPIDsettings->get("helion", "useBBparams") == 0 ? track.tpcNSigmaHe() : 0; + if (particle.name == "alpha" && cfgTrackPIDsettings->get("alpha", "useBBparams") < 1) + return cfgTrackPIDsettings->get("alpha", "useBBparams") == 0 ? track.tpcNSigmaAl() : 0; + + double expBethe{tpc::BetheBlochAleph(static_cast(particle.charge * rigidity / particle.mass), particle.betheParams[0], particle.betheParams[1], particle.betheParams[2], particle.betheParams[3], particle.betheParams[4])}; + double expSigma{expBethe * particle.resolution}; + float sigmaTPC = static_cast((track.tpcSignal() - expBethe) / expSigma); + return sigmaTPC; + } + //---------------------------------------------------------------------------------------------------------------- + template + float getITSnSigma(T const& track, PrimParticles& particle) + { + if (!track.hasITS()) + return -999; + o2::aod::ITSResponse itsResponse; + if (particle.name == "pion") + return itsResponse.nSigmaITS(track); + if (particle.name == "proton") + return itsResponse.nSigmaITS(track); + if (particle.name == "deuteron") + return itsResponse.nSigmaITS(track); + if (particle.name == "triton") + return itsResponse.nSigmaITS(track); + if (particle.name == "helion") + return itsResponse.nSigmaITS(track); + if (particle.name == "alpha") + return itsResponse.nSigmaITS(track); + return -999; // fallback if no match + } + //---------------------------------------------------------------------------------------------------------------- + template + float getMeanItsClsSize(T const& track) + { + int sum = 0, n = 0; + constexpr int kNITSLayers = 8; + for (int i = 0; i < kNITSLayers; i++) { + sum += (track.itsClusterSizes() >> (4 * i) & 15); + if (track.itsClusterSizes() >> (4 * i) & 15) + n++; + } + return n > 0 ? static_cast(sum) / n : 0.f; + } + //---------------------------------------------------------------------------------------------------------------- + template + float getRigidity(T const& track) + { + if (!cfgRigidityCorrection) + return track.tpcInnerParam(); + bool hePID = track.pidForTracking() == o2::track::PID::Helium3 || track.pidForTracking() == o2::track::PID::Alpha; + return hePID ? track.tpcInnerParam() / 2 : track.tpcInnerParam(); + } + //---------------------------------------------------------------------------------------------------------------- + float dcazSigma(double pt, float dcasigma) + { + float invPt = 1.f / pt; + return (5.00000e-04 + 8.73690e-03 * invPt + 9.62329e-04 * invPt * invPt) * dcasigma; // o2-linter: disable=magic-number (To be checked) + } + //---------------------------------------------------------------------------------------------------------------- + template + float getRapidity(T const& track, int species) + { + using PtEtaPhiMVector = ROOT::Math::LorentzVector>; + double momn; + int speciesHe3 = 4; + int speciesHe4 = 5; + if (species == speciesHe3 || species == speciesHe4) { + momn = 2 * track.pt(); + } else { + momn = track.pt(); + } + PtEtaPhiMVector lorentzVectorParticle(momn, track.eta(), track.phi(), particleMasses[species]); + return lorentzVectorParticle.Rapidity(); + } +}; // end of the task here +//---------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------- +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Nuspex/spectraKinkPiKa.cxx b/PWGLF/Tasks/Nuspex/spectraKinkPiKa.cxx new file mode 100644 index 00000000000..1b3c900fc35 --- /dev/null +++ b/PWGLF/Tasks/Nuspex/spectraKinkPiKa.cxx @@ -0,0 +1,693 @@ +// 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. + +/// \file spectraKinkPiKa.cxx +/// \brief Example of a simple task for the analysis of the muon from Kaon pion using kink topology +/// \author sandeep dudi sandeep.dudi@cern.ch + +#include "PWGLF/DataModel/LFKinkDecayTables.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "PWGLF/Utils/svPoolCreator.h" + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DCAFitter/DCAFitterN.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +////////////// +#include "Common/DataModel/PIDResponse.h" + +#include "Framework/O2DatabasePDGPlugin.h" +#include "ReconstructionDataFormats/PID.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TPDGCode.h" +#include "TVector3.h" +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +using VBracket = o2::math_utils::Bracket; + +using TracksFull = soa::Join; +using CollisionsFull = soa::Join; +using CollisionsFullMC = soa::Join; +namespace +{ +constexpr std::array LayerRadii{2.33959f, 3.14076f, 3.91924f, 19.6213f, 24.5597f, 34.388f, 39.3329f}; +constexpr double betheBlochDefault[1][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}}; +static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; +static const std::vector particleNames{"Daughter"}; + +} // namespace + +struct kinkCandidate { + int mothTrackID; + int daugTrackID; + int collisionID; + + int mothSign; + std::array momMoth = {-999, -999, -999}; + std::array momDaug = {-999, -999, -999}; + std::array primVtx = {-999, -999, -999}; + std::array decVtx = {-999, -999, -999}; + + float dcaKinkTopo = -999; + float dcaXYdaug = -999; + float dcaXYmoth = -999; + float kinkAngle = -999; +}; +struct kinkBuilder { + // kink analysis + Produces outputDataTable; + Service ccdb; + // Selection criteria + Configurable maxDCAMothToPV{"maxDCAMothToPV", 0.1, "Max DCA of the mother to the PV"}; + Configurable minDCADaugToPV{"minDCADaugToPV", 0., "Min DCA of the daughter to the PV"}; + Configurable minPtMoth{"minPtMoth", 0.5, "Minimum pT of the hypercandidate"}; + Configurable maxZDiff{"maxZDiff", 20., "Max z difference between the kink daughter and the mother"}; + Configurable maxPhiDiff{"maxPhiDiff", 100, "Max phi difference between the kink daughter and the mother"}; + Configurable timeMarginNS{"timeMarginNS", 600, "Additional time res tolerance in ns"}; + Configurable etaMax{"etaMax", 1., "eta daughter"}; + Configurable nTPCClusMinDaug{"nTPCClusMinDaug", 30, "mother NTPC clusters cut"}; + Configurable itsChi2cut{"itsChi2cut", 30, "mother itsChi2 cut"}; + Configurable askTOFforDaug{"askTOFforDaug", false, "If true, ask for TOF signal"}; + Configurable kaontopologhy{"kaontopologhy", true, "If true, selected mother have both ITS+TPC "}; + + o2::vertexing::DCAFitterN<2> fitter; + o2::base::MatLayerCylSet* lut = nullptr; + + // constants + float radToDeg = o2::constants::math::Rad2Deg; + svPoolCreator svCreator; + + // bethe bloch parameters + Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 1, 6, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for charged daughter"}; + Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"}; + Configurable customVertexerTimeMargin{"customVertexerTimeMargin", 800, "Time margin for custom vertexer (ns)"}; + Configurable skipAmbiTracks{"skipAmbiTracks", false, "Skip ambiguous tracks"}; + Configurable unlikeSignBkg{"unlikeSignBkg", false, "Use unlike sign background"}; + + // CCDB options + Configurable ccdbPath{"ccdbPath", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + + // std vector of candidates + std::vector kinkCandidates; + int mRunNumber; + float mBz; + std::array mBBparamsDaug; + + // mother and daughter tracks' properties (absolute charge and mass) + int charge = 1; + void init(InitContext const&) + { + // dummy values, 1 for mother, 0 for daughter + svCreator.setPDGs(1, 0); + + mRunNumber = 0; + mBz = 0; + + ccdb->setURL(ccdbPath); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + fitter.setPropagateToPCA(true); + fitter.setMaxR(200.); + fitter.setMinParamChange(1e-3); + fitter.setMinRelChi2Change(0.9); + fitter.setMaxDZIni(1e9); + fitter.setMaxChi2(1e9); + fitter.setUseAbsDCA(true); + + svCreator.setTimeMargin(customVertexerTimeMargin); + if (skipAmbiTracks) { + svCreator.setSkipAmbiTracks(); + } + for (int i = 0; i < 5; i++) { + mBBparamsDaug[i] = cfgBetheBlochParams->get("Daughter", Form("p%i", i)); + } + mBBparamsDaug[5] = cfgBetheBlochParams->get("Daughter", "resolution"); + } + + template + bool selectMothTrack(const T& candidate) + { + // ITS-standalone (no TPC, no TOF) + if (!kaontopologhy) { + if (candidate.has_collision() && candidate.hasITS() && !candidate.hasTPC() && !candidate.hasTOF() && + candidate.itsNCls() < 6 && + candidate.itsNClsInnerBarrel() == 3 && + candidate.itsChi2NCl() < 36 && + candidate.pt() > minPtMoth) { + return true; + } + return false; + } + // Kaon topology: ITS+TPC, no TOF + if (kaontopologhy) { + if (candidate.has_collision() && candidate.hasITS() && candidate.hasTPC() && !candidate.hasTOF() && + candidate.pt() > minPtMoth && + candidate.tpcNClsCrossedRows() >= nTPCClusMinDaug && + candidate.itsChi2NCl() <= itsChi2cut) { + return true; + } + return false; + } + + return false; // fallback + } + + template + bool selectDaugTrack(const T& candidate) + { + if (!kaontopologhy && (!candidate.hasTPC() || !candidate.hasITS())) { + return false; + } + + if (kaontopologhy && (!candidate.hasTPC() || candidate.hasITS())) { + return false; + } + + if (askTOFforDaug && !candidate.hasTOF()) { + return false; + } + return true; + } + + template + void fillCandidateData(const Tcolls& collisions, const Ttracks& tracks, aod::AmbiguousTracks const& ambiguousTracks, aod::BCs const& bcs) + { + svCreator.clearPools(); + svCreator.fillBC2Coll(collisions, bcs); + + for (const auto& track : tracks) { + if (std::abs(track.eta()) > etaMax) + continue; + + bool isDaug = selectDaugTrack(track); + bool isMoth = selectMothTrack(track); + + if (!isDaug && !isMoth) + continue; + + int pdgHypo = isMoth ? 1 : 0; + svCreator.appendTrackCand(track, collisions, pdgHypo, ambiguousTracks, bcs); + } + auto& kinkPool = svCreator.getSVCandPool(collisions, !unlikeSignBkg); + + for (const auto& svCand : kinkPool) { + kinkCandidate kinkCand; + + auto trackMoth = tracks.rawIteratorAt(svCand.tr0Idx); + auto trackDaug = tracks.rawIteratorAt(svCand.tr1Idx); + + auto const& collision = trackMoth.template collision_as(); + auto const& bc = collision.template bc_as(); + initCCDB(bc); + + o2::dataformats::VertexBase primaryVertex; + primaryVertex.setPos({collision.posX(), collision.posY(), collision.posZ()}); + primaryVertex.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + kinkCand.primVtx = {primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}; + + o2::track::TrackParCov trackParCovMoth = getTrackParCov(trackMoth); + o2::track::TrackParCov trackParCovMothPV{trackParCovMoth}; + o2::base::Propagator::Instance()->PropagateToXBxByBz(trackParCovMoth, LayerRadii[trackMoth.itsNCls() - 1]); + std::array dcaInfoMoth; + o2::base::Propagator::Instance()->propagateToDCABxByBz({primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, trackParCovMothPV, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfoMoth); + + o2::track::TrackParCov trackParCovDaug = getTrackParCov(trackDaug); + + // check if the kink daughter is close to the mother + if (std::abs(trackParCovMoth.getZ() - trackParCovDaug.getZ()) > maxZDiff) { + continue; + } + if ((std::abs(trackParCovMoth.getPhi() - trackParCovDaug.getPhi()) * radToDeg) > maxPhiDiff) { + continue; + } + + // propagate to PV + std::array dcaInfoDaug; + o2::base::Propagator::Instance()->propagateToDCABxByBz({primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, trackParCovDaug, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfoDaug); + if (std::abs(dcaInfoDaug[0]) < minDCADaugToPV) { + continue; + } + + int nCand = 0; + try { + nCand = fitter.process(trackParCovMoth, trackParCovDaug); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + continue; + } + if (nCand == 0) { + continue; + } + + if (!fitter.propagateTracksToVertex()) { + continue; + } + + auto propMothTrack = fitter.getTrack(0); + auto propDaugTrack = fitter.getTrack(1); + kinkCand.decVtx = fitter.getPCACandidatePos(); + + for (int i = 0; i < 3; i++) { + kinkCand.decVtx[i] -= kinkCand.primVtx[i]; + } + propMothTrack.getPxPyPzGlo(kinkCand.momMoth); + propDaugTrack.getPxPyPzGlo(kinkCand.momDaug); + for (int i = 0; i < 3; i++) { + kinkCand.momMoth[i] *= charge; + kinkCand.momDaug[i] *= charge; + } + float pMoth = propMothTrack.getP() * charge; + float pDaug = propDaugTrack.getP() * charge; + float spKink = kinkCand.momMoth[0] * kinkCand.momDaug[0] + kinkCand.momMoth[1] * kinkCand.momDaug[1] + kinkCand.momMoth[2] * kinkCand.momDaug[2]; + kinkCand.kinkAngle = std::acos(spKink / (pMoth * pDaug)); + + kinkCand.collisionID = collision.globalIndex(); + kinkCand.mothTrackID = trackMoth.globalIndex(); + kinkCand.daugTrackID = trackDaug.globalIndex(); + + kinkCand.dcaXYmoth = dcaInfoMoth[0]; + kinkCand.mothSign = trackMoth.sign(); + kinkCand.dcaXYdaug = dcaInfoDaug[0]; + kinkCand.dcaKinkTopo = std::sqrt(fitter.getChi2AtPCACandidate()); + kinkCandidates.push_back(kinkCand); + } + } + + void initCCDB(aod::BCs::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + LOG(info) << "Initializing CCDB for run " << mRunNumber; + o2::parameters::GRPMagField* grpmag = ccdb->getForRun(grpmagPath, mRunNumber); + o2::base::Propagator::initFieldFromGRP(grpmag); + mBz = grpmag->getNominalL3Field(); + fitter.setBz(mBz); + + if (!lut) { + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); + int mat{static_cast(cfgMaterialCorrection)}; + fitter.setMatCorrType(static_cast(mat)); + } + o2::base::Propagator::Instance()->setMatLUT(lut); + LOG(info) << "Task initialized for run " << mRunNumber << " with magnetic field " << mBz << " kZG"; + } + + void process(aod::Collisions const& collisions, TracksFull const& tracks, aod::AmbiguousTracks const& ambiTracks, aod::BCs const& bcs) + { + kinkCandidates.clear(); + fillCandidateData(collisions, tracks, ambiTracks, bcs); + // sort kinkCandidates by collisionID to allow joining with collision table + std::sort(kinkCandidates.begin(), kinkCandidates.end(), [](const kinkCandidate& a, const kinkCandidate& b) { return a.collisionID < b.collisionID; }); + + for (const auto& kinkCand : kinkCandidates) { + outputDataTable(kinkCand.collisionID, kinkCand.mothTrackID, kinkCand.daugTrackID, + kinkCand.decVtx[0], kinkCand.decVtx[1], kinkCand.decVtx[2], + kinkCand.mothSign, kinkCand.momMoth[0], kinkCand.momMoth[1], kinkCand.momMoth[2], + kinkCand.momDaug[0], kinkCand.momDaug[1], kinkCand.momDaug[2], + kinkCand.dcaXYmoth, kinkCand.dcaXYdaug, kinkCand.dcaKinkTopo); + } + } + PROCESS_SWITCH(kinkBuilder, process, "Produce kink tables", false); +}; + +struct spectraKinkPiKa { + Service pdg; + // Histograms are defined with HistogramRegistry + HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rpiKkink{"rpiKkink", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Configurable for event selection + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable cutNSigmaPi{"cutNSigmaPi", 4, "NSigmaTPCPion"}; + Configurable cutNSigmaKa{"cutNSigmaKa", 4, "NSigmaTPCKaon"}; + Configurable cutNSigmaMu{"cutNSigmaMu", 4, "cutNSigmaMu"}; + Configurable rapCut{"rapCut", 0.8, "rapCut"}; + Configurable kinkanglecut{"kinkanglecut", 2.0, "kinkanglecut"}; + Configurable minradius{"minradius", 130.0, "minradiuscut"}; + Configurable maxradius{"maxradius", 200.0, "maxradiuscut"}; + Configurable dcaXYcut{"dcaXYcut", 0.2, "dcaXYcut"}; + Configurable dcaZcut{"dcaZcut", 0.2, "dcaZcut"}; + Configurable tpcChi2Cut{"tpcChi2Cut", 4.0, "tpcChi2Cut"}; + + Configurable pid{"pidMother", 321, ""}; + Configurable dpid{"pidDaughter", 13, ""}; + Configurable d0pid{"dopid", 0, ""}; + + Preslice mPerCol = aod::track::collisionId; + Preslice mtPerCol = aod::track::collisionId; + + void init(InitContext const&) + { + // Axes + const AxisSpec ptAxis{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec qtAxis{2000, 0, 2, "#it{q}_{T} (GeV/#it{c})"}; + const AxisSpec kinkAxis{200, 0, 4, "#theta"}; + const AxisSpec etaAxis{200, -5.0, 5.0, "#eta"}; + const AxisSpec vertexAxis{1200, -300., 300., "vrtx [cm]"}; + const AxisSpec radiusAxis{600, 0., 300., "vrtx [cm]"}; + const AxisSpec massAxis{600, 0.1, 0.7, "Inv mass (GeV/#it{c}^{2})"}; + + // Event selection + rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexAxis}}); + + rpiKkink.add("h2_dau_pt_vs_eta_rec", "pt_vs_eta_dau", {HistType::kTH2F, {ptAxis, etaAxis}}); + rpiKkink.add("h2_moth_pt_vs_eta_rec", "pt_vs_eta_moth", {HistType::kTH2F, {ptAxis, etaAxis}}); + rpiKkink.add("h2_pt_moth_vs_dau_rec", "pt_moth_vs_dau", {HistType::kTH2F, {ptAxis, ptAxis}}); + + rpiKkink.add("h2_qt", "qt", {HistType::kTH1F, {qtAxis}}); + rpiKkink.add("h2_qt_vs_pt", "qt_pt", {HistType::kTH2F, {qtAxis, ptAxis}}); + + rpiKkink.add("h2_kink_angle", "kink angle", {HistType::kTH1F, {kinkAxis}}); + + // pion + rpiKkink.add("h2_dau_pt_vs_eta_rec_pion", "pt_vs_eta_dau", {HistType::kTH2F, {ptAxis, etaAxis}}); + rpiKkink.add("h2_moth_pt_vs_eta_rec_pion", "pt_vs_eta_moth", {HistType::kTH2F, {ptAxis, etaAxis}}); + rpiKkink.add("h2_pt_moth_vs_dau_rec_pion", "pt_moth_vs_dau", {HistType::kTH2F, {ptAxis, ptAxis}}); + + // inv mass + rpiKkink.add("h2_invmass_kaon", "Inv mass vs Pt", {HistType::kTH3F, {massAxis, ptAxis, ptAxis}}); + rpiKkink.add("h2_invmass_pion", "Inv mass vs Pt", {HistType::kTH3F, {massAxis, ptAxis, ptAxis}}); + + rpiKkink.add("h2_qt_pion", "qt", {HistType::kTH1F, {qtAxis}}); + rpiKkink.add("h2_qt_vs_ptpion", "qt_pt", {HistType::kTH2F, {qtAxis, ptAxis}}); + rpiKkink.add("h2_kink_angle_pion", "kink angle", {HistType::kTH1F, {kinkAxis}}); + + // track qa + + rpiKkink.add("h2_kinkradius_vs_vz", "kink radius_vz", {HistType::kTH2F, {vertexAxis, radiusAxis}}); + rpiKkink.add("h2_kink_vx_vs_vy", "kink vx vs vz ", {HistType::kTH2F, {vertexAxis, vertexAxis}}); + + if (doprocessMC) { + rpiKkink.add("h2_dau_pt_vs_eta_gen", "pt_vs_eta_dau", {HistType::kTH2F, {ptAxis, etaAxis}}); + rpiKkink.add("h2_moth_pt_vs_eta_gen", "pt_vs_eta_moth", {HistType::kTH2F, {ptAxis, etaAxis}}); + rpiKkink.add("h2_pt_moth_vs_dau_gen", "pt_moth_vs_dau", {HistType::kTH2F, {ptAxis, ptAxis}}); + + rpiKkink.add("h2_qt_gen", "qt", {HistType::kTH1F, {qtAxis}}); + rpiKkink.add("h2_qt_rec", "qt", {HistType::kTH1F, {qtAxis}}); + rpiKkink.add("h2_kink_angle_gen", "kink angle", {HistType::kTH1F, {kinkAxis}}); + } + } + + double computeMotherMass(ROOT::Math::PxPyPzMVector p_moth, ROOT::Math::PxPyPzMVector p_daug) + { + // Infer neutrino momentum from conservation + ROOT::Math::XYZVector p_nu_vec = p_moth.Vect() - p_daug.Vect(); + + // Neutrino energy (massless): E_nu = |p_nu| + double E_nu = p_nu_vec.R(); + + // Total energy of the system + double E_total = p_daug.E() + E_nu; + + // Total momentum = p_nu + p_daug + ROOT::Math::XYZVector p_total_vec = p_nu_vec + p_daug.Vect(); + double p_total_sq = p_total_vec.Mag2(); + + // Invariant mass from E² - |p|² + double m2 = E_total * E_total - p_total_sq; + return (m2 > 0) ? std::sqrt(m2) : -1.0; + } + + void processData(CollisionsFull::iterator const& collision, aod::KinkCands const& KinkCands, TracksFull const&) + { + ROOT::Math::PxPyPzMVector v0; + ROOT::Math::PxPyPzMVector v1; + + if (std::abs(collision.posZ()) > cutzvertex || !collision.sel8() || !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return; + } + if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return; + } + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + for (const auto& kinkCand : KinkCands) { + auto dauTrack = kinkCand.trackDaug_as(); + auto mothTrack = kinkCand.trackMoth_as(); + if (mothTrack.collisionId() != collision.globalIndex()) { + continue; // not from this event + } + if (!mothTrack.has_collision() || !dauTrack.has_collision()) { + continue; + } + if (mothTrack.collisionId() != dauTrack.collisionId()) { + continue; // skip mismatched collision tracks + } + bool kaon = false; + bool pion = false; + /* + if (mothTrack.dcaXY() > dcaXYcut) + continue; + if (mothTrack.dcaZ() > dcaZcut) + continue; + */ + if (mothTrack.tpcChi2NCl() > tpcChi2Cut) + continue; + if (std::abs(mothTrack.tpcNSigmaKa()) < cutNSigmaKa) { + kaon = true; + } + if (std::abs(mothTrack.tpcNSigmaPi()) < cutNSigmaPi) { + pion = true; + } + if (!kaon && !pion) { + continue; + } + if (cutNSigmaMu != -1 && std::abs(dauTrack.tpcNSigmaMu()) > cutNSigmaMu) { + continue; + } + double radiusxy = std::sqrt(kinkCand.xDecVtx() * kinkCand.xDecVtx() + kinkCand.yDecVtx() * kinkCand.yDecVtx()); + if (radiusxy < minradius || radiusxy > maxradius) + continue; + rpiKkink.fill(HIST("h2_kinkradius_vs_vz"), kinkCand.zDecVtx(), radiusxy); + rpiKkink.fill(HIST("h2_kink_vx_vs_vy"), kinkCand.xDecVtx(), kinkCand.yDecVtx()); + + v0.SetCoordinates(mothTrack.px(), mothTrack.py(), mothTrack.pz(), o2::constants::physics::MassPionCharged); + v1.SetCoordinates(dauTrack.px(), dauTrack.py(), dauTrack.pz(), o2::constants::physics::MassMuon); + + float pMoth = v0.P(); + float pDaug = v1.P(); + float spKink = mothTrack.px() * dauTrack.px() + mothTrack.py() * dauTrack.py() + mothTrack.pz() * dauTrack.pz(); + float kinkangle = std::acos(spKink / (pMoth * pDaug)); + float radToDeg = o2::constants::math::Rad2Deg; + if (kinkangle * radToDeg < kinkanglecut) + continue; + + if (kaon) { + rpiKkink.fill(HIST("h2_moth_pt_vs_eta_rec"), v0.Pt(), v0.Eta()); + rpiKkink.fill(HIST("h2_dau_pt_vs_eta_rec"), v1.Pt(), v1.Eta()); + rpiKkink.fill(HIST("h2_pt_moth_vs_dau_rec"), v0.Pt(), v1.Pt()); + rpiKkink.fill(HIST("h2_kink_angle"), kinkangle); + } + if (pion) { + rpiKkink.fill(HIST("h2_moth_pt_vs_eta_rec_pion"), v0.Pt(), v0.Eta()); + rpiKkink.fill(HIST("h2_dau_pt_vs_eta_rec_pion"), v1.Pt(), v1.Eta()); + rpiKkink.fill(HIST("h2_pt_moth_vs_dau_rec_pion"), v0.Pt(), v1.Pt()); + rpiKkink.fill(HIST("h2_kink_angle_pion"), kinkangle); + } + TVector3 pdlab(v1.Px(), v1.Py(), v1.Pz()); + // Compute transverse component + TVector3 motherDir(v0.Px(), v0.Py(), v0.Pz()); + double ptd = pdlab.Perp(motherDir); // or p_d_lab.Mag() * sin(theta) + + if (kaon) { + v0.SetCoordinates(mothTrack.px(), mothTrack.py(), mothTrack.pz(), o2::constants::physics::MassKaonCharged); + double mass = computeMotherMass(v0, v1); + rpiKkink.fill(HIST("h2_qt"), ptd); + rpiKkink.fill(HIST("h2_qt_vs_pt"), ptd, v1.Pt()); + rpiKkink.fill(HIST("h2_invmass_kaon"), mass, v0.Pt(), ptd); + } + if (pion) { + v0.SetCoordinates(mothTrack.px(), mothTrack.py(), mothTrack.pz(), o2::constants::physics::MassPionCharged); + double mass = computeMotherMass(v0, v1); + rpiKkink.fill(HIST("h2_qt_pion"), ptd); + rpiKkink.fill(HIST("h2_qt_vs_ptpion"), ptd, v1.Pt()); + rpiKkink.fill(HIST("h2_invmass_pion"), mass, v0.Pt(), ptd); + } + } + } + PROCESS_SWITCH(spectraKinkPiKa, processData, "Data processing", true); + + void processMC(CollisionsFullMC const& collisions, aod::KinkCands const& KinkCands, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const& particlesMC, TracksFull const&) + { + for (const auto& collision : collisions) { + ROOT::Math::PxPyPzMVector v0; + ROOT::Math::PxPyPzMVector v1; + if (std::abs(collision.posZ()) > cutzvertex || !collision.sel8() || !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + continue; + } + if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + continue; + } + + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + auto kinkCandPerColl = KinkCands.sliceBy(mPerCol, collision.globalIndex()); + for (const auto& kinkCand : kinkCandPerColl) { + auto dauTrack = kinkCand.trackDaug_as(); + auto mothTrack = kinkCand.trackMoth_as(); + if (dauTrack.sign() != mothTrack.sign()) { + LOG(info) << "Skipping kink candidate with opposite sign daughter and mother: " << kinkCand.globalIndex(); + continue; // Skip if the daughter has the opposite sign as the mother + } + bool kaon = false; + bool pion = false; + if (std::abs(mothTrack.tpcNSigmaKa()) < cutNSigmaKa) { + kaon = true; + } + if (std::abs(mothTrack.tpcNSigmaPi()) < cutNSigmaPi) { + pion = true; + } + if (!kaon && !pion) + continue; + double radiusxy = std::sqrt(kinkCand.xDecVtx() * kinkCand.xDecVtx() + kinkCand.yDecVtx() * kinkCand.yDecVtx()); + if (radiusxy < minradius || radiusxy > maxradius) + continue; + rpiKkink.fill(HIST("h2_kinkradius_vs_vz"), kinkCand.zDecVtx(), radiusxy); + rpiKkink.fill(HIST("h2_kink_vx_vs_vy"), kinkCand.xDecVtx(), kinkCand.yDecVtx()); + v0.SetCoordinates(mothTrack.px(), mothTrack.py(), mothTrack.pz(), o2::constants::physics::MassPionCharged); + v1.SetCoordinates(dauTrack.px(), dauTrack.py(), dauTrack.pz(), o2::constants::physics::MassMuon); + + float pMoth = v0.P(); + float pDaug = v1.P(); + float spKink = mothTrack.px() * dauTrack.px() + mothTrack.py() * dauTrack.py() + mothTrack.pz() * dauTrack.pz(); + float kinkangle = std::acos(spKink / (pMoth * pDaug)); + float radToDeg = o2::constants::math::Rad2Deg; + if (kinkangle * radToDeg < kinkanglecut) + continue; + + rpiKkink.fill(HIST("h2_moth_pt_vs_eta_rec"), v0.Pt(), v0.Eta()); + rpiKkink.fill(HIST("h2_dau_pt_vs_eta_rec"), v1.Pt(), v1.Eta()); + rpiKkink.fill(HIST("h2_pt_moth_vs_dau_rec"), v0.Pt(), v1.Pt()); + rpiKkink.fill(HIST("h2_kink_angle"), kinkangle); + + TVector3 pdlab(v1.Px(), v1.Py(), v1.Pz()); + // Compute transverse component + TVector3 motherDir(v0.Px(), v0.Py(), v0.Pz()); + double ptd = pdlab.Perp(motherDir); // or p_d_lab.Mag() * sin(theta) + + rpiKkink.fill(HIST("h2_qt"), ptd); + + // do MC association + auto mcLabMoth = trackLabelsMC.rawIteratorAt(mothTrack.globalIndex()); + auto mcLabDau = trackLabelsMC.rawIteratorAt(dauTrack.globalIndex()); + + if (mcLabMoth.has_mcParticle() && mcLabDau.has_mcParticle()) { + + auto mcTrackMoth = mcLabMoth.mcParticle_as(); + auto mcTrackDau = mcLabDau.mcParticle_as(); + if (!mcTrackDau.has_mothers()) { + continue; + } + for (const auto& piMother : mcTrackDau.mothers_as()) { + if (piMother.globalIndex() != mcTrackMoth.globalIndex()) { + continue; + } + if (std::abs(mcTrackMoth.pdgCode()) != pid || std::abs(mcTrackDau.pdgCode()) != dpid) { + continue; + } + rpiKkink.fill(HIST("h2_qt_rec"), ptd); + } + } + } + } + for (const auto& mcPart : particlesMC) { + ROOT::Math::PxPyPzMVector v0; + ROOT::Math::PxPyPzMVector v1; + if (!d0pid && (std::abs(mcPart.pdgCode()) != pid || std::abs(mcPart.eta()) > rapCut)) { + continue; + } + bool isDmeson = std::abs(mcPart.pdgCode()) == kD0 || std::abs(mcPart.pdgCode()) == kDPlus || std::abs(mcPart.pdgCode()) == kDStar; + if (d0pid && (!isDmeson || std::abs(mcPart.eta()) > rapCut)) { + continue; + } + if (!mcPart.has_daughters()) { + continue; // Skip if no daughters + } + bool hasKaonpionDaughter = false; + for (const auto& daughter : mcPart.daughters_as()) { + if (std::abs(daughter.pdgCode()) == dpid) { // muon PDG code + hasKaonpionDaughter = true; + v1.SetCoordinates(daughter.px(), daughter.py(), daughter.pz(), o2::constants::physics::MassMuon); + break; // Found a muon daughter, exit loop + } + } + if (!hasKaonpionDaughter) { + continue; // Skip if no muon daughter found + } + if (!d0pid && pid == kKPlus) { + v0.SetCoordinates(mcPart.px(), mcPart.py(), mcPart.pz(), o2::constants::physics::MassKaonCharged); + } + + if (!d0pid && pid == kPiPlus) { + v0.SetCoordinates(mcPart.px(), mcPart.py(), mcPart.pz(), o2::constants::physics::MassPionCharged); + } + if (d0pid) { + v0.SetCoordinates(mcPart.px(), mcPart.py(), mcPart.pz(), o2::constants::physics::MassD0); + } + float pMoth = v0.P(); + float pDaug = v1.P(); + float spKink = v0.Px() * v1.Px() + v0.Py() * v1.Py() + v0.Pz() * v1.Pz(); + float kinkangle = std::acos(spKink / (pMoth * pDaug)); + float radToDeg = o2::constants::math::Rad2Deg; + if (kinkangle * radToDeg < kinkanglecut) + continue; + rpiKkink.fill(HIST("h2_moth_pt_vs_eta_gen"), v0.Pt(), v0.Eta()); + rpiKkink.fill(HIST("h2_dau_pt_vs_eta_gen"), v1.Pt(), v1.Eta()); + rpiKkink.fill(HIST("h2_pt_moth_vs_dau_gen"), v0.Pt(), v1.Pt()); + rpiKkink.fill(HIST("h2_kink_angle_gen"), kinkangle); + TVector3 pdlab(v1.Px(), v1.Py(), v1.Pz()); + // Compute transverse component + TVector3 motherDir(v0.Px(), v0.Py(), v0.Pz()); + double ptd = pdlab.Perp(motherDir); // or p_d_lab.Mag() * sin(theta) + rpiKkink.fill(HIST("h2_qt_gen"), ptd); + } + } + PROCESS_SWITCH(spectraKinkPiKa, processMC, "MC processing", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + auto builderTask = adaptAnalysisTask(cfgc); + auto spectraTask = adaptAnalysisTask(cfgc); + + return {builderTask, spectraTask}; // Just return both tasks +} diff --git a/PWGLF/Tasks/Nuspex/spectraTOF.cxx b/PWGLF/Tasks/Nuspex/spectraTOF.cxx index 0bd719aed88..f80b2870959 100644 --- a/PWGLF/Tasks/Nuspex/spectraTOF.cxx +++ b/PWGLF/Tasks/Nuspex/spectraTOF.cxx @@ -18,6 +18,7 @@ /// // O2 includes + #include #include #include "ReconstructionDataFormats/Track.h" @@ -69,9 +70,10 @@ std::array, NpCharge> hDecayLengthMCCharm; // Decay Length std::array, NpCharge> hDecayLengthMCBeauty; // Decay Length in the MC for particles from charm std::array, NpCharge> hDecayLengthMCNotHF; // Decay Length in the MC for particles from not a HF +std::array, NpCharge> hPtNumTOFMatchWithPIDSignalPrm; // Pt distribution of particles with a hit in the TOF and a compatible signal + // Spectra task -// o2-linter: disable=name/workflow-file -struct tofSpectra { // o2-linter: disable=name/struct +struct tofSpectra { struct : ConfigurableGroup { Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgINELCut{"cfgINELCut", 0, "INEL event selection: 0 no sel, 1 INEL>0, 2 INEL>1"}; @@ -86,7 +88,7 @@ struct tofSpectra { // o2-linter: disable=name/struct struct : ConfigurableGroup { Configurable cfgCutEtaMax{"cfgCutEtaMax", 0.8f, "Max eta range for tracks"}; - Configurable cfgCutNsigma{"cfgCutNsigma", 10.0f, "nsigma cut range for tracks"}; + Configurable cfgCutNsigma{"cfgCutNsigma", 100.0f, "nsigma cut range for tracks"}; Configurable cfgCutEtaMin{"cfgCutEtaMin", -0.8f, "Min eta range for tracks"}; Configurable cfgCutY{"cfgCutY", 0.5f, "Y range for tracks"}; Configurable lastRequiredTrdCluster{"lastRequiredTrdCluster", 5, "Last cluster to require in TRD for track selection. -1 does not require any TRD cluster"}; @@ -96,6 +98,7 @@ struct tofSpectra { // o2-linter: disable=name/struct } trkselOptions; Configurable enableDcaGoodEvents{"enableDcaGoodEvents", true, "Enables the MC plots with the correct match between data and MC"}; + Configurable enablePureDCAHistogram{"enablePureDCAHistogram", false, "Enables the pure DCA histograms"}; Configurable enableTrackCutHistograms{"enableTrackCutHistograms", true, "Enables track cut histograms, before and after the cut"}; Configurable enableDeltaHistograms{"enableDeltaHistograms", true, "Enables the delta TPC and TOF histograms"}; Configurable enableTPCTOFHistograms{"enableTPCTOFHistograms", true, "Enables TPC TOF histograms"}; @@ -134,12 +137,15 @@ struct tofSpectra { // o2-linter: disable=name/struct Configurable maxChi2PerClusterITS{"maxChi2PerClusterITS", 36.f, "Additional cut on the maximum value of the chi2 per cluster in the ITS"}; Configurable maxDcaXYFactor{"maxDcaXYFactor", 1.f, "Additional cut on the maximum value of the DCA xy (multiplicative factor)"}; Configurable maxDcaZ{"maxDcaZ", 2.f, "Additional cut on the maximum value of the DCA z"}; - Configurable minTPCNClsFound{"minTPCNClsFound", 0.f, "Additional cut on the minimum value of the number of found clusters in the TPC"}; + Configurable minTPCNClsFound{"minTPCNClsFound", 100.f, "Additional cut on the minimum value of the number of found clusters in the TPC"}; Configurable makeTHnSparseChoice{"makeTHnSparseChoice", false, "choose if produce thnsparse"}; // RD Configurable enableTPCTOFvsEtaHistograms{"enableTPCTOFvsEtaHistograms", false, "choose if produce TPC tof vs Eta"}; - Configurable includeCentralityMC{"includeCentralityMC", true, "choose if include Centrality to MC"}; + Configurable includeCentralityMC{"includeCentralityMC", false, "choose if include Centrality to MC"}; + Configurable isImpactParam{"isImpactParam", false, "choose if include impactparam to MC"}; + Configurable usePDGcode{"usePDGcode", false, "choose if include PDG code for MC closure test"}; Configurable enableTPCTOFVsMult{"enableTPCTOFVsMult", false, "Produce TPC-TOF plots vs multiplicity"}; Configurable includeCentralityToTracks{"includeCentralityToTracks", false, "choose if include Centrality to tracks"}; + Configurable min_ITS_nClusters{"min_ITS_nClusters", 5, "minimum number of found ITS clusters"}; // Histograms HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -215,6 +221,7 @@ struct tofSpectra { // o2-linter: disable=name/struct LOG(info) << "\tmaxChi2PerClusterTPC=" << maxChi2PerClusterTPC.value; LOG(info) << "\tminChi2PerClusterTPC=" << minChi2PerClusterTPC.value; LOG(info) << "\tminNCrossedRowsTPC=" << minNCrossedRowsTPC.value; + LOG(info) << "\tmin_ITS_nClusters=" << min_ITS_nClusters.value; LOG(info) << "\tminTPCNClsFound=" << minTPCNClsFound.value; LOG(info) << "\tmaxChi2PerClusterITS=" << maxChi2PerClusterITS.value; LOG(info) << "\tmaxDcaZ=" << maxDcaZ.value; @@ -224,6 +231,7 @@ struct tofSpectra { // o2-linter: disable=name/struct LOG(info) << "Customizing track cuts:"; customTrackCuts.SetRequireITSRefit(requireITS.value); customTrackCuts.SetRequireTPCRefit(requireTPC.value); + customTrackCuts.SetMinNClustersITS(min_ITS_nClusters.value); customTrackCuts.SetRequireGoldenChi2(requireGoldenChi2.value); customTrackCuts.SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC.value); customTrackCuts.SetMaxChi2PerClusterITS(maxChi2PerClusterITS.value); @@ -435,9 +443,25 @@ struct tofSpectra { // o2-linter: disable=name/struct histos.add("Data/cent/pos/pt/its_tof", "pos ITS-TOF", kTH3D, {ptAxis, multAxis, occupancyAxis}); histos.add("Data/cent/neg/pt/its_tof", "neg ITS-TOF", kTH3D, {ptAxis, multAxis, occupancyAxis}); } + const AxisSpec nsigmaTPCAxisOccupancy{binsOptions.binsnsigmaTPC, "nsigmaTPC"}; + if (doprocessMCclosure) { + histos.add("nsigmatpc/mc_closure/pos/pi", "mc_closure dependent pion", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + histos.add("nsigmatpc/mc_closure/neg/pi", "mc_closure dependent pion", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + histos.add("nsigmatof/mc_closure/pos/pi", "mc_closure dependent pion", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + histos.add("nsigmatof/mc_closure/neg/pi", "mc_closure dependent pion", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + + histos.add("nsigmatpc/mc_closure/pos/ka", "mc_closure dependent kaon", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + histos.add("nsigmatpc/mc_closure/neg/ka", "mc_closure dependent kaon", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + histos.add("nsigmatof/mc_closure/pos/ka", "mc_closure dependent kaon", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + histos.add("nsigmatof/mc_closure/neg/ka", "mc_closure dependent kaon", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + + histos.add("nsigmatpc/mc_closure/pos/pr", "mc_closure dependent proton", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + histos.add("nsigmatpc/mc_closure/neg/pr", "mc_closure dependent proton", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + histos.add("nsigmatof/mc_closure/pos/pr", "mc_closure dependent proton", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + histos.add("nsigmatof/mc_closure/neg/pr", "mc_closure dependent proton", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + } if (doprocessOccupancy) { - const AxisSpec nsigmaTPCAxisOccupancy{binsOptions.binsnsigmaTPC, "nsigmaTPC"}; histos.add("nsigmatpc/test_occupancy/Mult_vs_Occupancy", "occuppancy vs Multiplicity", kTHnSparseD, {multAxis, occupancyAxis}); histos.add("nsigmatpc/test_occupancy/pos/pi", "occuppancy dependent pion", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); histos.add("nsigmatpc/test_occupancy/neg/pi", "occuppancy dependent pion", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); @@ -459,6 +483,69 @@ struct tofSpectra { // o2-linter: disable=name/struct histos.add("MC/fake/neg", "Fake negative tracks", kTH1D, {ptAxis}); histos.add("MC/no_collision/pos", "No collision pos track", kTH1D, {ptAxis}); histos.add("MC/no_collision/neg", "No collision neg track", kTH1D, {ptAxis}); + if (isImpactParam) { + histos.add("MC/withPID/pi/pos/prm/pt/num", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/num", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/num", "recons. MC K^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/num", "recons. MC K^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/num", "recons. MC p", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/num", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pi/pos/prm/pt/num_str", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/num_str", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/num_str", "recons. MC K^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/num_str", "recons. MC K^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/num_str", "recons. MC p", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/num_str", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pi/pos/prm/pt/num_mat", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/num_mat", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/num_mat", "recons. MC K^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/num_mat", "recons. MC K^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/num_mat", "recons. MC p", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/num_mat", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pi/pos/prm/pt/numtof", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/numtof", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/numtof", "recons. MC K^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/numtof", "recons. MC K^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/numtof", "recons. MC p", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/numtof", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pi/pos/prm/pt/numtof_matched", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/numtof_matched", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/numtof_matched", "recons. MC K^{+}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/numtof_matched", "recons. MC K^{-}", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/numtof_matched", "recons. MC p", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/numtof_matched", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, impParamAxis}); + } else { + histos.add("MC/withPID/pi/pos/prm/pt/num", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/num", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/num", "recons. MC K^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/num", "recons. MC K^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/num", "recons. MC p", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/num", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pi/pos/prm/pt/num_str", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/num_str", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/num_str", "recons. MC K^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/num_str", "recons. MC K^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/num_str", "recons. MC p", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/num_str", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pi/pos/prm/pt/num_mat", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/num_mat", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/num_mat", "recons. MC K^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/num_mat", "recons. MC K^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/num_mat", "recons. MC p", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/num_mat", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pi/pos/prm/pt/numtof", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/numtof", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/numtof", "recons. MC K^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/numtof", "recons. MC K^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/numtof", "recons. MC p", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/numtof", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pi/pos/prm/pt/numtof_matched", "recons. MC #pi^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pi/neg/prm/pt/numtof_matched", "recons. MC #pi^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/pos/prm/pt/numtof_matched", "recons. MC K^{+}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/ka/neg/prm/pt/numtof_matched", "recons. MC K^{-}", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/pos/prm/pt/numtof_matched", "recons. MC p", kTHnSparseD, {ptAxis, multAxis}); + histos.add("MC/withPID/pr/neg/prm/pt/numtof_matched", "recons. MC #bar{p}", kTHnSparseD, {ptAxis, multAxis}); + } if (doprocessMCgen) { histos.add("MC/test/pi/pos/prm/pt/den", "generated MC #pi^{+}", kTHnSparseD, {ptAxis, impParamAxis}); histos.add("MC/test/pi/neg/prm/pt/den", "generated MC #pi^{-}", kTHnSparseD, {ptAxis, impParamAxis}); @@ -610,16 +697,27 @@ struct tofSpectra { // o2-linter: disable=name/struct } if (doprocessMC) { + const std::string cpName = Form("/%s/%s", (i < Np) ? "pos" : "neg", pN[i % Np]); if (includeCentralityMC) { //*************************************RD********************************************** - histos.add(hpt_num_prm[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); - histos.add(hpt_num_str[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); - histos.add(hpt_num_mat[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); + if (isImpactParam) { + histos.add(hpt_num_prm[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, impParamAxis, dcaXyAxis, occupancyAxis}); + histos.add(hpt_num_str[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, impParamAxis, dcaXyAxis}); + histos.add(hpt_num_mat[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, impParamAxis, dcaXyAxis}); + + histos.add(hpt_numtof_prm[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, impParamAxis, dcaXyAxis, occupancyAxis}); + histos.add(hpt_numtof_str[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, impParamAxis, dcaXyAxis}); + histos.add(hpt_numtof_mat[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, impParamAxis, dcaXyAxis}); + } else { + histos.add(hpt_num_prm[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis, occupancyAxis}); + histos.add(hpt_num_str[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); + histos.add(hpt_num_mat[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); - histos.add(hpt_numtof_prm[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); - histos.add(hpt_numtof_str[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); - histos.add(hpt_numtof_mat[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); + histos.add(hpt_numtof_prm[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis, occupancyAxis}); + histos.add(hpt_numtof_str[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); + histos.add(hpt_numtof_mat[i].data(), pTCharge[i], kTHnSparseD, {ptAxis, multAxis, dcaXyAxis}); + } histos.add(hpt_numtofgoodmatch_prm[i].data(), pTCharge[i], kTH3D, {ptAxis, multAxis, etaAxis}); @@ -641,6 +739,7 @@ struct tofSpectra { // o2-linter: disable=name/struct histos.add(hpt_numtof_mat[i].data(), pTCharge[i], kTH2D, {ptAxis, multAxis}); histos.add(hpt_numtofgoodmatch_prm[i].data(), pTCharge[i], kTH2D, {ptAxis, multAxis}); + hPtNumTOFMatchWithPIDSignalPrm[i] = histos.add("MC" + cpName + "/prm/pt/numtofwithpid", pTCharge[i], kTH2D, {ptAxis, multAxis}); histos.add(hpt_den_prm[i].data(), pTCharge[i], kTH2D, {ptAxis, multAxis}); histos.add(hpt_den_str[i].data(), pTCharge[i], kTH2D, {ptAxis, multAxis}); @@ -652,7 +751,6 @@ struct tofSpectra { // o2-linter: disable=name/struct } histos.add(hpt_den_prm_mcgoodev[i].data(), pTCharge[i], kTH2D, {ptAxis, multAxis}); histos.add(hpt_den_prm_mcbadev[i].data(), pTCharge[i], kTH2D, {ptAxis, multAxis}); - const std::string cpName = Form("/%s/%s", (i < Np) ? "pos" : "neg", pN[i % Np]); if (enableDCAxyzHistograms) { hDcaXYZPrm[i] = histos.add("dcaprm" + cpName, pTCharge[i], kTH3D, {ptAxis, dcaXyAxis, dcaZAxis}); hDcaXYZStr[i] = histos.add("dcastr" + cpName, pTCharge[i], kTH3D, {ptAxis, dcaXyAxis, dcaZAxis}); @@ -745,6 +843,7 @@ struct tofSpectra { // o2-linter: disable=name/struct } const auto& nsigmaTOF = o2::aod::pidutils::tofNSigma(track); const auto& nsigmaTPC = o2::aod::pidutils::tpcNSigma(track); + // const auto id = track.sign() > 0 ? id : id + Np; const float multiplicity = getMultiplicity(collision); if (multiplicityEstimator == MultCodes::kNoMultiplicity) { @@ -920,7 +1019,6 @@ struct tofSpectra { // o2-linter: disable=name/struct } } } - if constexpr (fillFullInfo) { if (enableDeltaHistograms) { const auto& deltaTOF = o2::aod::pidutils::tofExpSignalDiff(track); @@ -939,7 +1037,6 @@ struct tofSpectra { // o2-linter: disable=name/struct } } } - // Filling DCA info with the TPC+TOF PID bool isDCAPureSample = (std::sqrt(nsigmaTOF * nsigmaTOF + nsigmaTPC * nsigmaTPC) < 2.f); if (track.pt() <= 0.4) { @@ -1109,7 +1206,7 @@ struct tofSpectra { // o2-linter: disable=name/struct return false; } } - return (std::abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / pow(track.pt(), 1.1f)))); // o2-linter: disable=std-prefix + return (std::abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / std::pow(track.pt(), 1.1f)))); } return track.isGlobalTrack(); } @@ -1340,6 +1437,136 @@ struct tofSpectra { // o2-linter: disable=name/struct aod::CentFV0As, aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs>; using TrackCandidates = soa::Join; + void processMCclosure(CollisionCandidates::iterator const& collisions, + soa::Join const& tracks, + aod::McTrackLabels const& mcTrackLabels, aod::McParticles const& mcParticles) + { + const float multiplicity = getMultiplicity(collisions); + // int trackwoCut = 0; int trackwCut = 0; + + for (const auto& track : tracks) { + if (!track.has_collision()) { + continue; + } + const auto& collision = track.collision_as(); + if (!isEventSelected(collision)) { + continue; + } + if (!isTrackSelected(track, collision)) { + continue; + } + // trackwoCut++; + if (std::abs(track.dcaXY()) > 0.05) { // Skipping tracks that don't pass the standard cuts + return; + } + + // trackwCut++; + const auto& mcLabel = mcTrackLabels.iteratorAt(track.globalIndex()); + const auto& mcParticle = mcParticles.iteratorAt(mcLabel.mcParticleId()); + int pdgCode = mcParticle.pdgCode(); + const auto& nsigmaTPCPi = o2::aod::pidutils::tpcNSigma<2>(track); + const auto& nsigmaTPCKa = o2::aod::pidutils::tpcNSigma<3>(track); + const auto& nsigmaTPCPr = o2::aod::pidutils::tpcNSigma<4>(track); + + bool isTPCPion = std::abs(nsigmaTPCPi) < trkselOptions.cfgCutNsigma; + bool isTPCKaon = std::abs(nsigmaTPCKa) < trkselOptions.cfgCutNsigma; + bool isTPCProton = std::abs(nsigmaTPCPr) < trkselOptions.cfgCutNsigma; + + const auto& nsigmaTOFPi = o2::aod::pidutils::tofNSigma<2>(track); + const auto& nsigmaTOFKa = o2::aod::pidutils::tofNSigma<3>(track); + const auto& nsigmaTOFPr = o2::aod::pidutils::tofNSigma<4>(track); + + bool isTOFPion = track.hasTOF() && std::abs(nsigmaTOFPi) < trkselOptions.cfgCutNsigma; + bool isTOFKaon = track.hasTOF() && std::abs(nsigmaTOFKa) < trkselOptions.cfgCutNsigma; + bool isTOFProton = track.hasTOF() && std::abs(nsigmaTOFPr) < trkselOptions.cfgCutNsigma; + // Precompute rapidity values to avoid redundant calculations + double rapidityPi = std::abs(track.rapidity(PID::getMass(2))); + double rapidityKa = std::abs(track.rapidity(PID::getMass(3))); + double rapidityPr = std::abs(track.rapidity(PID::getMass(4))); + if (track.eta() < trkselOptions.cfgCutEtaMin || track.eta() > trkselOptions.cfgCutEtaMax) { + return; + } + if (mcParticle.isPhysicalPrimary()) { + if (isTPCPion && rapidityPi <= trkselOptions.cfgCutY) { + if (usePDGcode) { + if (pdgCode == 211) { + histos.fill(HIST("nsigmatpc/mc_closure/pos/pi"), track.pt(), nsigmaTPCPi, multiplicity); + } else if (pdgCode == -211) { + histos.fill(HIST("nsigmatpc/mc_closure/neg/pi"), track.pt(), nsigmaTPCPi, multiplicity); + } + } else { + histos.fill(HIST("nsigmatpc/mc_closure/pos/pi"), track.pt(), nsigmaTPCPi, multiplicity); + histos.fill(HIST("nsigmatpc/mc_closure/neg/pi"), track.pt(), nsigmaTPCPi, multiplicity); + } + } + if (isTPCKaon && rapidityKa <= trkselOptions.cfgCutY) { + if (usePDGcode) { + if (pdgCode == 321) { + histos.fill(HIST("nsigmatpc/mc_closure/pos/ka"), track.pt(), nsigmaTPCKa, multiplicity); + } else if (pdgCode == -321) { + histos.fill(HIST("nsigmatpc/mc_closure/neg/ka"), track.pt(), nsigmaTPCKa, multiplicity); + } + } else { + histos.fill(HIST("nsigmatpc/mc_closure/pos/ka"), track.pt(), nsigmaTPCKa, multiplicity); + histos.fill(HIST("nsigmatpc/mc_closure/neg/ka"), track.pt(), nsigmaTPCKa, multiplicity); + } + } + if (isTPCProton && rapidityPr <= trkselOptions.cfgCutY) { + if (usePDGcode) { + if (pdgCode == 2212) { + histos.fill(HIST("nsigmatpc/mc_closure/pos/pr"), track.pt(), nsigmaTPCPr, multiplicity); + } else if (pdgCode == -2212) { + histos.fill(HIST("nsigmatpc/mc_closure/neg/pr"), track.pt(), nsigmaTPCPr, multiplicity); + } + } else { + histos.fill(HIST("nsigmatpc/mc_closure/pos/pr"), track.pt(), nsigmaTPCPr, multiplicity); + histos.fill(HIST("nsigmatpc/mc_closure/neg/pr"), track.pt(), nsigmaTPCPr, multiplicity); + } + } + + // TOF Selection and Histogram Filling + if (isTOFPion && rapidityPi <= trkselOptions.cfgCutY) { + if (usePDGcode) { + if (pdgCode == 211) { + histos.fill(HIST("nsigmatof/mc_closure/pos/pi"), track.pt(), nsigmaTOFPi, multiplicity); + } else if (pdgCode == -211) { + histos.fill(HIST("nsigmatof/mc_closure/neg/pi"), track.pt(), nsigmaTOFPi, multiplicity); + } + } else { + histos.fill(HIST("nsigmatof/mc_closure/pos/pi"), track.pt(), nsigmaTOFPi, multiplicity); + histos.fill(HIST("nsigmatof/mc_closure/neg/pi"), track.pt(), nsigmaTOFPi, multiplicity); + } + } + if (isTOFKaon && rapidityKa <= trkselOptions.cfgCutY) { + if (usePDGcode) { + if (pdgCode == 321) { + histos.fill(HIST("nsigmatof/mc_closure/pos/ka"), track.pt(), nsigmaTOFKa, multiplicity); + } else if (pdgCode == -321) { + histos.fill(HIST("nsigmatof/mc_closure/neg/ka"), track.pt(), nsigmaTOFKa, multiplicity); + } + } else { + histos.fill(HIST("nsigmatof/mc_closure/pos/ka"), track.pt(), nsigmaTOFKa, multiplicity); + histos.fill(HIST("nsigmatof/mc_closure/neg/ka"), track.pt(), nsigmaTOFKa, multiplicity); + } + } + if (isTOFProton && rapidityPr <= trkselOptions.cfgCutY) { + if (usePDGcode) { + if (pdgCode == 2212) { + histos.fill(HIST("nsigmatof/mc_closure/pos/pr"), track.pt(), nsigmaTOFPr, multiplicity); + } else if (pdgCode == -2212) { + histos.fill(HIST("nsigmatof/mc_closure/neg/pr"), track.pt(), nsigmaTOFPr, multiplicity); + } + } else { + histos.fill(HIST("nsigmatof/mc_closure/pos/pr"), track.pt(), nsigmaTOFPr, multiplicity); + histos.fill(HIST("nsigmatof/mc_closure/neg/pr"), track.pt(), nsigmaTOFPr, multiplicity); + } + } + } + } + } + PROCESS_SWITCH(tofSpectra, processMCclosure, "MC closure test", false); void processOccupancy(CollisionCandidates::iterator const& collision, soa::Join const& tracks) { // Event selection criteria - if (!collision.sel8() || std::abs(collision.posZ()) > 10 || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || + /*if (!collision.sel8() || std::abs(collision.posZ()) > 10 || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return; + }*/ + if (!isEventSelected(collision)) { return; } histos.fill(HIST("test_occupancy/event/vertexz"), collision.posZ()); @@ -1364,28 +1594,29 @@ struct tofSpectra { // o2-linter: disable=name/struct for (const auto& track : tracks) { // Track selection criteria - if (track.tpcNClsCrossedRows() < 70 || track.tpcChi2NCl() > 4 || track.tpcChi2NCl() < 0.5 || - track.itsChi2NCl() > 36 || std::abs(track.dcaXY()) > 0.05 || std::abs(track.dcaZ()) > 2.0 || - std::abs(track.eta()) > 0.8 || track.tpcCrossedRowsOverFindableCls() < 0.8 || track.tpcNClsFound() < 100 || - !(o2::aod::track::ITSrefit) || !(o2::aod::track::TPCrefit)) { + /* if (track.tpcNClsCrossedRows() < minNCrossedRowsTPC || track.tpcChi2NCl() > maxChi2PerClusterTPC || track.tpcChi2NCl() > maxChi2PerClusterTPC || + track.itsChi2NCl() > maxChi2PerClusterITS || std::abs(track.dcaXY()) > maxDcaXYFactor.value * (0.0105f + 0.0350f / pow(track.pt(), 1.1f)) || std::abs(track.dcaZ()) > maxDcaZ.value || track.eta() < trkselOptions.cfgCutEtaMin || track.eta() > trkselOptions.cfgCutEtaMax || track.tpcCrossedRowsOverFindableCls() < minNCrossedRowsOverFindableClustersTPC || track.tpcNClsFound() < minTPCNClsFound || + !(o2::aod::track::ITSrefit) || !(o2::aod::track::TPCrefit)) { + continue; + }*/ + if (!isTrackSelected(track, collision)) { continue; } const auto& nsigmaTPCPi = o2::aod::pidutils::tpcNSigma<2>(track); - ; const auto& nsigmaTPCKa = o2::aod::pidutils::tpcNSigma<3>(track); const auto& nsigmaTPCPr = o2::aod::pidutils::tpcNSigma<4>(track); - bool isTPCPion = std::abs(nsigmaTPCPi) < trkselOptions.cfgCutNsigma; - bool isTPCKaon = std::abs(nsigmaTPCKa) < trkselOptions.cfgCutNsigma; - bool isTPCProton = std::abs(nsigmaTPCPr) < trkselOptions.cfgCutNsigma; + const bool isTPCPion = std::abs(nsigmaTPCPi) < trkselOptions.cfgCutNsigma; + const bool isTPCKaon = std::abs(nsigmaTPCKa) < trkselOptions.cfgCutNsigma; + const bool isTPCProton = std::abs(nsigmaTPCPr) < trkselOptions.cfgCutNsigma; const auto& nsigmaTOFPi = o2::aod::pidutils::tofNSigma<2>(track); const auto& nsigmaTOFKa = o2::aod::pidutils::tofNSigma<3>(track); const auto& nsigmaTOFPr = o2::aod::pidutils::tofNSigma<4>(track); - bool isTOFPion = track.hasTOF() && std::abs(nsigmaTOFPi) < trkselOptions.cfgCutNsigma; - bool isTOFKaon = track.hasTOF() && std::abs(nsigmaTOFKa) < trkselOptions.cfgCutNsigma; - bool isTOFProton = track.hasTOF() && std::abs(nsigmaTOFPr) < trkselOptions.cfgCutNsigma; + const bool isTOFPion = track.hasTOF() && std::abs(nsigmaTOFPi) < trkselOptions.cfgCutNsigma; + const bool isTOFKaon = track.hasTOF() && std::abs(nsigmaTOFKa) < trkselOptions.cfgCutNsigma; + const bool isTOFProton = track.hasTOF() && std::abs(nsigmaTOFPr) < trkselOptions.cfgCutNsigma; // Apply rapidity cut for identified particles if (isTPCPion && std::abs(track.rapidity(PID::getMass(2))) < trkselOptions.cfgCutY) { @@ -1438,7 +1669,7 @@ struct tofSpectra { // o2-linter: disable=name/struct histos.fill(HIST("test_occupancy/tpcCount"), tpcCount); histos.fill(HIST("test_occupancy/tofCount"), tofCount); } // process function - PROCESS_SWITCH(tofSpectra, processOccupancy, "check for occupancy plots", false); + PROCESS_SWITCH(tofSpectra, processOccupancy, "check for occupancy plots", true); void processStandard(CollisionCandidates::iterator const& collision, TrackCandidates const& tracks) @@ -1477,26 +1708,26 @@ struct tofSpectra { // o2-linter: disable=name/struct } // end of the process function PROCESS_SWITCH(tofSpectra, processDerived, "Derived data processor", false); -#define makeProcessFunction(processorName, inputPid, particleId, isFull, tofTable, tpcTable) /* o2-linter: disable=name/macro */ \ - void process##processorName##inputPid(CollisionCandidates::iterator const& collision, \ - soa::Join const& tracks) \ - { \ - if (!isEventSelected(collision)) { \ - return; \ - } \ - for (const auto& track : tracks) { \ - if (!isTrackSelected(track, collision)) { \ - continue; \ - } \ - fillParticleHistos(track, collision); \ - } \ - } \ +#define makeProcessFunction(processorName, inputPid, particleId, isFull, tofTable, tpcTable) \ + void process##processorName##inputPid(CollisionCandidates::iterator const& collision, \ + soa::Join const& tracks) \ + { \ + if (!isEventSelected(collision)) { \ + return; \ + } \ + for (const auto& track : tracks) { \ + if (!isTrackSelected(track, collision)) { \ + continue; \ + } \ + fillParticleHistos(track, collision); \ + } \ + } \ PROCESS_SWITCH(tofSpectra, process##processorName##inputPid, Form("Process for the %s hypothesis from %s tables", #particleId, #processorName), false); // Full tables -#define makeProcessFunctionFull(inputPid, particleId) makeProcessFunction(Full, inputPid, particleId, true, TOFFull, TPCFull) // o2-linter: disable=name/macro +#define makeProcessFunctionFull(inputPid, particleId) makeProcessFunction(Full, inputPid, particleId, true, TOFFull, TPCFull) makeProcessFunctionFull(El, Electron); makeProcessFunctionFull(Mu, Muon); @@ -1510,7 +1741,7 @@ struct tofSpectra { // o2-linter: disable=name/struct #undef makeProcessFunctionFull // Full LF tables -#define makeProcessFunctionFull(inputPid, particleId) makeProcessFunction(LfFull, inputPid, particleId, true, TOFFull, TPCLfFull) // o2-linter: disable=name/macro +#define makeProcessFunctionFull(inputPid, particleId) makeProcessFunction(LfFull, inputPid, particleId, true, TOFFull, TPCLfFull) makeProcessFunctionFull(El, Electron); makeProcessFunctionFull(Mu, Muon); @@ -1648,7 +1879,7 @@ struct tofSpectra { // o2-linter: disable=name/struct using RecoMCCollisions = soa::Join; // RD template - void fillTrackHistograms_MC(TrackType const& track, // o2-linter: disable=name/function-variable + void fillTrackHistograms_MC(TrackType const& track, ParticleType::iterator const& mcParticle, RecoMCCollisions::iterator const& collision, ParticleType const& mcParticles) @@ -1656,18 +1887,20 @@ struct tofSpectra { // o2-linter: disable=name/struct if (!isParticleEnabled()) { // Check if the particle is enabled return; } - + if (!collision.has_mcCollision()) { + return; // Skips processing if no corresponding MC collision is found (rare case!) + } const auto& mcCollision = collision.mcCollision_as(); - float multiplicity = getMultiplicityMC(mcCollision); + const float multiplicity = getMultiplicity(collision); + const int occupancy = collision.trackOccupancyInTimeRange(); //************************************RD************************************************** - if (includeCentralityMC) { - multiplicity = mcCollision.impactParameter(); - } + const float impParam = mcCollision.impactParameter(); //************************************RD************************************************** if (mcParticle.pdgCode() != PDGs[i]) { return; } + if (track.eta() < trkselOptions.cfgCutEtaMin || track.eta() > trkselOptions.cfgCutEtaMax) { return; } @@ -1675,118 +1908,138 @@ struct tofSpectra { // o2-linter: disable=name/struct if (std::abs(mcParticle.y()) > trkselOptions.cfgCutY) { return; } + if (enablePureDCAHistogram) { + const auto& nsigmaTPCKa = o2::aod::pidutils::tpcNSigma<3>(track); + const auto& nsigmaTOFKa = o2::aod::pidutils::tofNSigma<3>(track); - if (enableDCAvsmotherHistograms) { - hDcaXYMC[i]->Fill(track.pt(), track.dcaXY()); - hDcaZMC[i]->Fill(track.pt(), track.dcaZ()); - } - if (!mcParticle.isPhysicalPrimary()) { // Secondaries (weak decays and material) - if (mcParticle.getProcess() == 4) { - if (enableDCAxyzHistograms) { - hDcaXYZStr[i]->Fill(track.pt(), track.dcaXY(), track.dcaZ()); - } else { - histos.fill(HIST(hdcaxystr[i]), track.pt(), track.dcaXY()); - histos.fill(HIST(hdcazstr[i]), track.pt(), track.dcaZ()); - } - - if (mcParticle.has_mothers()) { - for (const auto& mother : mcParticle.template mothers_as()) { - auto daughter0 = mother.template daughters_as().begin(); - double vertexDau[3] = {daughter0.vx(), daughter0.vy(), daughter0.vz()}; - double vertexMoth[3] = {mother.vx(), mother.vy(), mother.vz()}; - auto decayLength = RecoDecay::distance(vertexMoth, vertexDau); - hDecayLengthStr[i]->Fill(track.pt(), decayLength); - } - } - } else { - if (enableDCAxyzHistograms) { - hDcaXYZMat[i]->Fill(track.pt(), track.dcaXY(), track.dcaZ()); - } else { - histos.fill(HIST(hdcaxymat[i]), track.pt(), track.dcaXY()); - histos.fill(HIST(hdcazmat[i]), track.pt(), track.dcaZ()); - } + // Filling DCA info with the TPC+TOF PID + bool isDCAPureSample = (std::sqrt(nsigmaTOFKa * nsigmaTOFKa + nsigmaTPCKa * nsigmaTPCKa) < 2.f); + if (track.pt() <= 0.4) { + isDCAPureSample = (nsigmaTPCKa < 1.f); } - } else { // Primaries - if (enableDCAxyzHistograms) { - hDcaXYZPrm[i]->Fill(track.pt(), track.dcaXY(), track.dcaZ()); - if (enableDcaGoodEvents.value && collision.has_mcCollision()) { - histos.fill(HIST(hdcaxyprmgoodevs[i]), track.pt(), track.dcaXY(), track.dcaZ()); + + if (isDCAPureSample) { + if (enableDCAvsmotherHistograms) { + hDcaXYMC[i]->Fill(track.pt(), track.dcaXY()); + hDcaZMC[i]->Fill(track.pt(), track.dcaZ()); } - } else { - // DCAxy for all primaries - histos.fill(HIST(hdcaxyprm[i]), track.pt(), track.dcaXY()); - histos.fill(HIST(hdcazprm[i]), track.pt(), track.dcaZ()); - } - if (enableDcaGoodEvents.value && collision.has_mcCollision()) { - histos.fill(HIST(hdcaxyprmgoodevs[i]), track.pt(), track.dcaXY()); - histos.fill(HIST(hdcazprmgoodevs[i]), track.pt(), track.dcaZ()); - } - - if (enableDCAvsmotherHistograms) { - bool IsD0Mother = false; // o2-linter: disable=name/function-variable - bool IsCharmMother = false; // o2-linter: disable=name/function-variable - bool IsBeautyMother = false; // o2-linter: disable=name/function-variable - bool IsNotHFMother = false; // o2-linter: disable=name/function-variable - if (mcParticle.has_mothers()) { - const int charmOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, false); - for (const auto& mother : mcParticle.template mothers_as()) { - const int motherPdgCode = std::abs(mother.pdgCode()); - if (motherPdgCode == 421) { - IsD0Mother = true; + + if (!mcParticle.isPhysicalPrimary()) { // Secondaries (weak decays and material) + if (mcParticle.getProcess() == 4) { // Particles from decay + if (enableDCAxyzHistograms) { + hDcaXYZStr[i]->Fill(track.pt(), track.dcaXY(), track.dcaZ()); + } else { + histos.fill(HIST(hdcaxystr[i]), track.pt(), track.dcaXY()); + histos.fill(HIST(hdcazstr[i]), track.pt(), track.dcaZ()); } - if (charmOrigin == RecoDecay::OriginType::NonPrompt) { - IsBeautyMother = true; - LOG(info) << "Charm Origin for Beauty: " << charmOrigin; + + if (mcParticle.has_mothers()) { + for (const auto& mother : mcParticle.template mothers_as()) { + auto daughter0 = mother.template daughters_as().begin(); + double vertexDau[3] = {daughter0.vx(), daughter0.vy(), daughter0.vz()}; + double vertexMoth[3] = {mother.vx(), mother.vy(), mother.vz()}; + auto decayLength = RecoDecay::distance(vertexMoth, vertexDau); + hDecayLengthStr[i]->Fill(track.pt(), decayLength); + } } - if (charmOrigin == RecoDecay::OriginType::Prompt) { - IsCharmMother = true; - LOG(info) << "Charm Origin for Charm: " << charmOrigin; + } else { // Particles from the material + if (enableDCAxyzHistograms) { + hDcaXYZMat[i]->Fill(track.pt(), track.dcaXY(), track.dcaZ()); + } else { + histos.fill(HIST(hdcaxymat[i]), track.pt(), track.dcaXY()); + histos.fill(HIST(hdcazmat[i]), track.pt(), track.dcaZ()); } - if (charmOrigin == RecoDecay::OriginType::None) { - IsNotHFMother = true; - LOG(info) << "Charm Origin for NotHF: " << charmOrigin; + } + } else { // Primaries + if (enableDCAxyzHistograms) { + hDcaXYZPrm[i]->Fill(track.pt(), track.dcaXY(), track.dcaZ()); + if (enableDcaGoodEvents.value && collision.has_mcCollision()) { + histos.fill(HIST(hdcaxyprmgoodevs[i]), track.pt(), track.dcaXY(), track.dcaZ()); } + } else { + // DCAxy for all primaries + histos.fill(HIST(hdcaxyprm[i]), track.pt(), track.dcaXY()); + histos.fill(HIST(hdcazprm[i]), track.pt(), track.dcaZ()); + } + if (enableDcaGoodEvents.value && collision.has_mcCollision()) { + histos.fill(HIST(hdcaxyprmgoodevs[i]), track.pt(), track.dcaXY()); + histos.fill(HIST(hdcazprmgoodevs[i]), track.pt(), track.dcaZ()); } - } - if (IsD0Mother) { - hDcaXYMCD0[i]->Fill(track.pt(), track.dcaXY()); - hDcaZMCD0[i]->Fill(track.pt(), track.dcaZ()); - } - if (IsCharmMother) { - hDcaXYMCCharm[i]->Fill(track.pt(), track.dcaXY()); - hdcaZMCCharm[i]->Fill(track.pt(), track.dcaZ()); - } - if (IsBeautyMother) { - hDcaXYMCBeauty[i]->Fill(track.pt(), track.dcaXY()); - hDcaZMCBeauty[i]->Fill(track.pt(), track.dcaZ()); - } - if (IsNotHFMother) { - hDcaXYMCNotHF[i]->Fill(track.pt(), track.dcaXY()); - hDcaZMCNotHF[i]->Fill(track.pt(), track.dcaZ()); - } - - if (mcParticle.has_mothers()) { - for (const auto& mother : mcParticle.template mothers_as()) { - auto daughter0 = mother.template daughters_as().begin(); - double vertexDau[3] = {daughter0.vx(), daughter0.vy(), daughter0.vz()}; - double vertexMoth[3] = {mother.vx(), mother.vy(), mother.vz()}; - auto decayLength = RecoDecay::distance(vertexMoth, vertexDau); + if (enableDCAvsmotherHistograms) { + bool IsD0Mother = false; + bool IsCharmMother = false; + bool IsBeautyMother = false; + bool IsNotHFMother = false; + if (mcParticle.has_mothers()) { + const int charmOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, false); + for (const auto& mother : mcParticle.template mothers_as()) { + const int motherPdgCode = std::abs(mother.pdgCode()); + if (motherPdgCode == 421) { + IsD0Mother = true; + } + if (charmOrigin == RecoDecay::OriginType::NonPrompt) { + IsBeautyMother = true; + } + if (charmOrigin == RecoDecay::OriginType::Prompt) { + IsCharmMother = true; + } + if (charmOrigin == RecoDecay::OriginType::None) { + IsNotHFMother = true; + } + } + } if (IsD0Mother) { - hDecayLengthMCD0[i]->Fill(track.pt(), decayLength); + hDcaXYMCD0[i]->Fill(track.pt(), track.dcaXY()); + hDcaZMCD0[i]->Fill(track.pt(), track.dcaZ()); } if (IsCharmMother) { - hDecayLengthMCCharm[i]->Fill(track.pt(), decayLength); + hDcaXYMCCharm[i]->Fill(track.pt(), track.dcaXY()); + hdcaZMCCharm[i]->Fill(track.pt(), track.dcaZ()); } if (IsBeautyMother) { - hDecayLengthMCBeauty[i]->Fill(track.pt(), decayLength); + hDcaXYMCBeauty[i]->Fill(track.pt(), track.dcaXY()); + hDcaZMCBeauty[i]->Fill(track.pt(), track.dcaZ()); } if (IsNotHFMother) { - hDecayLengthMCNotHF[i]->Fill(track.pt(), decayLength); + hDcaXYMCNotHF[i]->Fill(track.pt(), track.dcaXY()); + hDcaZMCNotHF[i]->Fill(track.pt(), track.dcaZ()); + } + + if (mcParticle.has_mothers()) { + for (const auto& mother : mcParticle.template mothers_as()) { + auto daughter0 = mother.template daughters_as().begin(); + double vertexDau[3] = {daughter0.vx(), daughter0.vy(), daughter0.vz()}; + double vertexMoth[3] = {mother.vx(), mother.vy(), mother.vz()}; + auto decayLength = RecoDecay::distance(vertexMoth, vertexDau); + + if (IsD0Mother) { + hDecayLengthMCD0[i]->Fill(track.pt(), decayLength); + } + if (IsCharmMother) { + hDecayLengthMCCharm[i]->Fill(track.pt(), decayLength); + } + if (IsBeautyMother) { + hDecayLengthMCBeauty[i]->Fill(track.pt(), decayLength); + } + if (IsNotHFMother) { + hDecayLengthMCNotHF[i]->Fill(track.pt(), decayLength); + } + } } } } } + } else { + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST(hdcaxystr[i]), track.pt(), track.dcaXY()); + } else { + histos.fill(HIST(hdcaxymat[i]), track.pt(), track.dcaXY()); + } + } else { + histos.fill(HIST(hdcaxyprm[i]), track.pt(), track.dcaXY()); + } } if ((collision.has_mcCollision() && (mcParticle.mcCollisionId() != collision.mcCollisionId())) || !collision.has_mcCollision()) { @@ -1804,11 +2057,29 @@ struct tofSpectra { // o2-linter: disable=name/struct if (!passesDCAxyCut(track)) { // Skipping tracks that don't pass the standard cuts return; } + const int pdgCode = mcParticle.pdgCode(); + const auto& nsigmaTPCPi = o2::aod::pidutils::tpcNSigma<2>(track); + const auto& nsigmaTPCKa = o2::aod::pidutils::tpcNSigma<3>(track); + const auto& nsigmaTPCPr = o2::aod::pidutils::tpcNSigma<4>(track); - if (!mcParticle.isPhysicalPrimary()) { - if (mcParticle.getProcess() == 4) { + const bool isPionTPC = std::abs(nsigmaTPCPi) < trkselOptions.cfgCutNsigma; + const bool isKaonTPC = std::abs(nsigmaTPCKa) < trkselOptions.cfgCutNsigma; + const bool isProtonTPC = std::abs(nsigmaTPCPr) < trkselOptions.cfgCutNsigma; + + const auto& nsigmaTOFPi = o2::aod::pidutils::tofNSigma<2>(track); + const auto& nsigmaTOFKa = o2::aod::pidutils::tofNSigma<3>(track); + const auto& nsigmaTOFPr = o2::aod::pidutils::tofNSigma<4>(track); + + const bool isPionTOF = std::abs(nsigmaTOFPi) < trkselOptions.cfgCutNsigma; + const bool isKaonTOF = std::abs(nsigmaTOFKa) < trkselOptions.cfgCutNsigma; + const bool isProtonTOF = std::abs(nsigmaTOFPr) < trkselOptions.cfgCutNsigma; + + if (!mcParticle.isPhysicalPrimary()) { // Is not physical primary + if (mcParticle.getProcess() == 4) { // Is from decay if (includeCentralityMC) { - histos.fill(HIST(hpt_num_str[i]), track.pt(), multiplicity, track.dcaXY()); + if (includeCentralityMC) { + histos.fill(HIST(hpt_num_str[i]), track.pt(), multiplicity, track.dcaXY()); + } } else { histos.fill(HIST(hpt_num_str[i]), track.pt(), multiplicity); } @@ -1832,12 +2103,139 @@ struct tofSpectra { // o2-linter: disable=name/struct } } } - } else { + } else { // Is physical primary if (includeCentralityMC) { - histos.fill(HIST(hpt_num_prm[i]), track.pt(), multiplicity, track.dcaXY()); + if (isImpactParam) { + histos.fill(HIST(hpt_num_prm[i]), track.pt(), impParam, track.dcaXY(), occupancy); + } else { + histos.fill(HIST(hpt_num_prm[i]), track.pt(), multiplicity, track.dcaXY(), occupancy); + } } else { histos.fill(HIST(hpt_num_prm[i]), track.pt(), multiplicity); } + if (isPionTPC || isKaonTPC || isProtonTPC) { + if (pdgCode == 2212) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/num"), track.pt(), impParam); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/num_str"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/num_mat"), track.pt(), impParam); + } + } + } else { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/num"), track.pt(), multiplicity); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/num_str"), track.pt(), multiplicity); + } else { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/num_mat"), track.pt(), multiplicity); + } + } + } + } else if (pdgCode == -2212) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/num"), track.pt(), impParam); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/num_str"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/num_mat"), track.pt(), impParam); + } + } + } else { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/num"), track.pt(), multiplicity); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/num_str"), track.pt(), multiplicity); + } else { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/num_mat"), track.pt(), multiplicity); + } + } + } + } else if (pdgCode == 211) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/num"), track.pt(), impParam); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/num_str"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/num_mat"), track.pt(), impParam); + } + } + } else { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/num"), track.pt(), multiplicity); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/num_str"), track.pt(), multiplicity); + } else { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/num_mat"), track.pt(), multiplicity); + } + } + } + } else if (pdgCode == -211) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/num"), track.pt(), impParam); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/num_str"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/num_mat"), track.pt(), impParam); + } + } + } else { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/num"), track.pt(), multiplicity); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/num_str"), track.pt(), multiplicity); + } else { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/num_mat"), track.pt(), multiplicity); + } + } + } + } else if (pdgCode == 321) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/num"), track.pt(), impParam); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/num_str"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/num_mat"), track.pt(), impParam); + } + } + } else { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/num"), track.pt(), multiplicity); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/num_str"), track.pt(), multiplicity); + } else { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/num_mat"), track.pt(), multiplicity); + } + } + } + } else if (pdgCode == -321) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/num"), track.pt(), impParam); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/num_str"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/num_mat"), track.pt(), impParam); + } + } + } else { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/num"), track.pt(), multiplicity); + if (!mcParticle.isPhysicalPrimary()) { + if (mcParticle.getProcess() == 4) { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/num_str"), track.pt(), multiplicity); + } else { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/num_mat"), track.pt(), multiplicity); + } + } + } + } + } if (track.hasTRD() && trkselOptions.lastRequiredTrdCluster > 0) { int lastLayer = 0; for (int l = 7; l >= 0; l--) { @@ -1851,8 +2249,99 @@ struct tofSpectra { // o2-linter: disable=name/struct } } if (track.hasTOF()) { + if (isPionTOF || isKaonTOF || isProtonTOF) { + // Proton (positive) + if (pdgCode == 2212) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/numtof"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/numtof"), track.pt(), multiplicity); + } + // Matched proton condition + if (!(track.mcMask() & (1 << 11))) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/numtof_matched"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pr/pos/prm/pt/numtof_matched"), track.pt(), multiplicity); + } + } + } else if (pdgCode == -2212) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/numtof"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/numtof"), track.pt(), multiplicity); + } + if (!(track.mcMask() & (1 << 11))) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/numtof_matched"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pr/neg/prm/pt/numtof_matched"), track.pt(), multiplicity); + } + } + } else if (pdgCode == 211) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/numtof"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/numtof"), track.pt(), multiplicity); + } + // Matched pion condition + if (!(track.mcMask() & (1 << 11))) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/numtof_matched"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pi/pos/prm/pt/numtof_matched"), track.pt(), multiplicity); + } + } + } else if (pdgCode == -211) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/numtof"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/numtof"), track.pt(), multiplicity); + } + // Matched pion condition + if (!(track.mcMask() & (1 << 11))) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/numtof_matched"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/pi/neg/prm/pt/numtof_matched"), track.pt(), multiplicity); + } + } + } else if (pdgCode == 321) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/numtof"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/numtof"), track.pt(), multiplicity); + } + // Matched kaon condition + if (!(track.mcMask() & (1 << 11))) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/numtof_matched"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/ka/pos/prm/pt/numtof_matched"), track.pt(), multiplicity); + } + } + } else if (pdgCode == -321) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/numtof"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/numtof"), track.pt(), multiplicity); + } + // Matched kaon condition + if (!(track.mcMask() & (1 << 11))) { + if (isImpactParam) { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/numtof_matched"), track.pt(), impParam); + } else { + histos.fill(HIST("MC/withPID/ka/neg/prm/pt/numtof_matched"), track.pt(), multiplicity); + } + } + } + } if (includeCentralityMC) { - histos.fill(HIST(hpt_numtof_prm[i]), track.pt(), multiplicity, track.dcaXY()); + if (isImpactParam) { + histos.fill(HIST(hpt_numtof_prm[i]), track.pt(), impParam, track.dcaXY(), occupancy); + } else { + histos.fill(HIST(hpt_numtof_prm[i]), track.pt(), multiplicity, track.dcaXY(), occupancy); + } } else { histos.fill(HIST(hpt_numtof_prm[i]), track.pt(), multiplicity); } @@ -1863,6 +2352,28 @@ struct tofSpectra { // o2-linter: disable=name/struct histos.fill(HIST(hpt_numtofgoodmatch_prm[i]), track.pt(), multiplicity); } } + // Check if the signal is compatible with the PID hypothesis + float nsigma = 0.f; + switch (i) { + case 2: + case Np + 2: + nsigma = track.tofNSigmaPi(); + break; + case 3: + case Np + 3: + nsigma = track.tofNSigmaKa(); + break; + case 4: + case Np + 4: + nsigma = track.tofNSigmaPr(); + break; + default: + break; + } + if (std::abs(nsigma) <= trkselOptions.cfgCutNsigma) { + if (hPtNumTOFMatchWithPIDSignalPrm[i]) + hPtNumTOFMatchWithPIDSignalPrm[i]->Fill(track.pt(), multiplicity); + } } // Filling mismatched info for primary tracks @@ -1882,7 +2393,7 @@ struct tofSpectra { // o2-linter: disable=name/struct } template - void fillParticleHistograms_MC(const float multiplicity, ParticleType const& mcParticle) // o2-linter: disable=name/function-variable + void fillParticleHistograms_MC(const float multiplicity, ParticleType const& mcParticle) { if (!isParticleEnabled()) { // Check if the particle is enabled return; @@ -1899,12 +2410,16 @@ struct tofSpectra { // o2-linter: disable=name/struct histos.fill(HIST(hpt_den_mat[i]), mcParticle.pt(), multiplicity); } } else { - histos.fill(HIST(hpt_den_prm[i]), mcParticle.pt(), multiplicity); + if (includeCentralityMC) { + histos.fill(HIST(hpt_den_prm[i]), mcParticle.pt(), multiplicity); + } else { + histos.fill(HIST(hpt_den_prm[i]), mcParticle.pt(), multiplicity); + } } } template - void fillParticleHistograms_MCRecoEvs(ParticleType const& mcParticle, RecoMCCollisions::iterator const& collision) // o2-linter: disable=name/function-variable + void fillParticleHistograms_MCRecoEvs(ParticleType const& mcParticle, RecoMCCollisions::iterator const& collision) { if (!isParticleEnabled()) { // Check if the particle is enabled return; @@ -1962,7 +2477,7 @@ struct tofSpectra { // o2-linter: disable=name/struct } template - void fillParticleHistograms_MCGenEvs(ParticleType const& mcParticle, GenMCCollisions::iterator const& mcCollision) // o2-linter: disable=name/function-variable + void fillParticleHistograms_MCGenEvs(ParticleType const& mcParticle, GenMCCollisions::iterator const& mcCollision) { if (!isParticleEnabled()) { // Check if the particle is enabled @@ -1989,6 +2504,7 @@ struct tofSpectra { // o2-linter: disable=name/struct SliceCache cache; void processMC(soa::Join const& tracks, aod::McParticles const& mcParticles, @@ -2036,7 +2552,6 @@ struct tofSpectra { // o2-linter: disable=name/struct const auto& mcCollision = collision.mcCollision_as(); const auto& particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); const float multiplicity = getMultiplicity(collision); - for (const auto& mcParticle : particlesInCollision) { if (std::abs(mcParticle.y()) > trkselOptions.cfgCutY) { @@ -2121,12 +2636,12 @@ struct tofSpectra { // o2-linter: disable=name/struct fillParticleHistograms_MCGenEvs(mcParticle, mcCollision); }); } - // if (mcCollision.isInelGt0()) { - // histos.fill(HIST("MC/GenRecoCollisions"), 3.f); - // } - // if (mcCollision.isInelGt1()) { - // histos.fill(HIST("MC/GenRecoCollisions"), 4.f); - // } + if (mcCollision.isInelGt0()) { + histos.fill(HIST("MC/GenRecoCollisions"), 3.f); + } + if (mcCollision.isInelGt1()) { + histos.fill(HIST("MC/GenRecoCollisions"), 4.f); + } if (hasParticleInFT0C && hasParticleInFT0A) { histos.fill(HIST("MC/GenRecoCollisions"), 5.f); } @@ -2165,7 +2680,7 @@ struct tofSpectra { // o2-linter: disable=name/struct } } PROCESS_SWITCH(tofSpectra, processMCgen, "process generated MC", false); - void processMCgen_RecoEvs(soa::Join const& tracks, aod::McTrackLabels const& mcTrackLabels, @@ -2214,21 +2729,20 @@ struct tofSpectra { // o2-linter: disable=name/struct } const auto& nsigmaTPCPi = o2::aod::pidutils::tpcNSigma<2>(track); - ; const auto& nsigmaTPCKa = o2::aod::pidutils::tpcNSigma<3>(track); const auto& nsigmaTPCPr = o2::aod::pidutils::tpcNSigma<4>(track); - bool isPionTPC = std::abs(nsigmaTPCPi) < trkselOptions.cfgCutNsigma; - bool isKaonTPC = std::abs(nsigmaTPCKa) < trkselOptions.cfgCutNsigma; - bool isProtonTPC = std::abs(nsigmaTPCPr) < trkselOptions.cfgCutNsigma; + const bool isPionTPC = std::abs(nsigmaTPCPi) < trkselOptions.cfgCutNsigma; + const bool isKaonTPC = std::abs(nsigmaTPCKa) < trkselOptions.cfgCutNsigma; + const bool isProtonTPC = std::abs(nsigmaTPCPr) < trkselOptions.cfgCutNsigma; const auto& nsigmaTOFPi = o2::aod::pidutils::tofNSigma<2>(track); const auto& nsigmaTOFKa = o2::aod::pidutils::tofNSigma<3>(track); const auto& nsigmaTOFPr = o2::aod::pidutils::tofNSigma<4>(track); - bool isPionTOF = track.hasTOF() && std::abs(nsigmaTOFPi) < trkselOptions.cfgCutNsigma; - bool isKaonTOF = track.hasTOF() && std::abs(nsigmaTOFKa) < trkselOptions.cfgCutNsigma; - bool isProtonTOF = track.hasTOF() && std::abs(nsigmaTOFPr) < trkselOptions.cfgCutNsigma; + const bool isPionTOF = track.hasTOF() && std::abs(nsigmaTOFPi) < trkselOptions.cfgCutNsigma; + const bool isKaonTOF = track.hasTOF() && std::abs(nsigmaTOFKa) < trkselOptions.cfgCutNsigma; + const bool isProtonTOF = track.hasTOF() && std::abs(nsigmaTOFPr) < trkselOptions.cfgCutNsigma; if (isPionTPC || isKaonTPC || isProtonTPC) { if (pdgCode == 2212) { diff --git a/PWGLF/Tasks/QC/CMakeLists.txt b/PWGLF/Tasks/QC/CMakeLists.txt index 5fba2292100..126ec29b3e5 100644 --- a/PWGLF/Tasks/QC/CMakeLists.txt +++ b/PWGLF/Tasks/QC/CMakeLists.txt @@ -111,8 +111,8 @@ o2physics_add_dpl_workflow(mcinelgt0 COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(tracked-cascade-properties - SOURCES tracked_cascade_properties.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + SOURCES trackedCascadeProperties.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(mc-particle-predictions @@ -124,3 +124,18 @@ o2physics_add_dpl_workflow(strange-derived-qa SOURCES strangederivedqa.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(str-derived-genqa + SOURCES strderivedGenQA.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(its-tpc-matching-vzeros + SOURCES lfITSTPCMatchingSecondaryTracksQA.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(v0assoqa + SOURCES v0assoqa.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter KFParticle::KFParticle O2Physics::TPCDriftManager + COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGLF/Tasks/QC/efficiencyQA.cxx b/PWGLF/Tasks/QC/efficiencyQA.cxx index 62bfc4e1622..4a0257bb6e5 100644 --- a/PWGLF/Tasks/QC/efficiencyQA.cxx +++ b/PWGLF/Tasks/QC/efficiencyQA.cxx @@ -449,7 +449,7 @@ struct efficiencyQA { histos.fill(HIST("tagCuts"), 5., tagTrack.sign() * tagTrack.pt()); // if survived all selections, propagate decay daughters to PV - gpu::gpustd::array dcaInfo; + std::array dcaInfo; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, tagTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); float tagDcaXYZ = dcaInfo[0]; @@ -534,7 +534,7 @@ struct efficiencyQA { continue; } - gpu::gpustd::array dcaInfo; + std::array dcaInfo; auto tpcTrackCov = getTrackParCov(tpcTrack); if (propToTPCinnerWall) { o2::base::Propagator::Instance()->PropagateToXBxByBz(probeTrackCov, 70.f, 1.f, 2.f, fitter.getMatCorrType()); @@ -660,7 +660,7 @@ struct efficiencyQA { if (hasITS && !hasTPC) { auto tagTrack = tracks.rawIteratorAt(probeTrack.globalIndexTag); auto tagTrackCov = getTrackParCov(tagTrack); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; o2::base::Propagator::Instance()->propagateToDCABxByBz({probeTrack.vtx0, probeTrack.vtx1, probeTrack.vtx2}, tagTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); std::array momTag; tagTrackCov.getPxPyPzGlo(momTag); @@ -697,7 +697,7 @@ struct efficiencyQA { histos.fill(HIST("timeTpcItsNoNorm"), tdiff); auto trackCov = getTrackParCov(tpcTrack); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; if (propToTPCinnerWall) { o2::base::Propagator::Instance()->PropagateToXBxByBz(trackCov, 70.f, 1.f, 2.f, fitter.getMatCorrType()); } else { @@ -848,7 +848,7 @@ struct efficiencyQA { const o2::math_utils::Point3D collVtx{collision.posX(), collision.posY(), collision.posZ()}; auto trackParCov = getTrackParCov(track); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; o2::base::Propagator::Instance()->propagateToDCA(collVtx, trackParCov, d_bz, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfo); auto trackPt = track.sign() * trackParCov.getPt(); diff --git a/PWGLF/Tasks/QC/lfITSTPCMatchingSecondaryTracksQA.cxx b/PWGLF/Tasks/QC/lfITSTPCMatchingSecondaryTracksQA.cxx new file mode 100644 index 00000000000..14aebdb354a --- /dev/null +++ b/PWGLF/Tasks/QC/lfITSTPCMatchingSecondaryTracksQA.cxx @@ -0,0 +1,343 @@ +// 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. +/// +/// \file lfITSTPCMatchingSecondaryTracksQA.cxx +/// +/// \brief task for QA of ITS-TPC matching efficiency of secondary tracks from V0s +/// \author Alberto Caliva (alberto.caliva@cern.ch), Francesca Ercolessi (francesca.ercolessi@cern.ch), Nicolò Jacazio (nicolo.jacazio@cern.ch) +/// \since Feb 11, 2025 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "ReconstructionDataFormats/Track.h" + +using namespace std; +using namespace o2; +using namespace o2::soa; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +using namespace o2::constants::math; +using std::array; + +using SelCollisions = soa::Join; +using SimCollisions = soa::Join; +using StrHadronDaughterTracks = soa::Join; +using MCTracks = soa::Join; + +struct LfITSTPCMatchingSecondaryTracksQA { + + HistogramRegistry registryData{"registryData", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry registryMC{"registryMC", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Global Parameters + Configurable zVtx{"zVtx", 10.0, "Maximum zVertex"}; + + // Track Parameters + Configurable minITSnCls{"minITSnCls", 1.0f, "min number of ITS 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 nsigmaTPCmin{"nsigmaTPCmin", -3.0f, "Minimum nsigma TPC"}; + Configurable nsigmaTPCmax{"nsigmaTPCmax", +3.0f, "Maximum nsigma TPC"}; + Configurable nsigmaTOFmin{"nsigmaTOFmin", -3.0f, "Minimum nsigma TOF"}; + Configurable nsigmaTOFmax{"nsigmaTOFmax", +3.0f, "Maximum nsigma TOF"}; + Configurable dcaxyMax{"dcaxyMax", 0.1f, "dcaxy max"}; + Configurable dcazMax{"dcazMax", 0.1f, "dcaz max"}; + Configurable dcaMin{"dcaMin", 0.1f, "dca min"}; + Configurable requireTOF{"requireTOF", false, "require TOF hit"}; + Configurable requireItsHits{"requireItsHits", false, "require ITS hits"}; + Configurable> requiredHit{"requiredHit", {0, 0, 0, 0, 0, 0, 0}, "required ITS Hits (1=required, 0=not required)"}; + + // V0 Parameters + Configurable minimumV0Radius{"minimumV0Radius", 0.0f, "Minimum V0 Radius"}; + Configurable maximumV0Radius{"maximumV0Radius", 100.0f, "Maximum V0 Radius"}; + Configurable dcanegtoPVmin{"dcanegtoPVmin", 0.1f, "Minimum DCA Neg To PV"}; + Configurable dcapostoPVmin{"dcapostoPVmin", 0.1f, "Minimum DCA Pos To PV"}; + Configurable v0cospaMin{"v0cospaMin", 0.99f, "Minimum V0 CosPA"}; + Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 0.5f, "Maximum DCA Daughters"}; + Configurable mK0Min{"mK0Min", 0.48f, "K0 mass lower cut"}; + Configurable mK0Max{"mK0Max", 0.52f, "K0 mass upper cut"}; + + void init(InitContext const&) + { + // Event Counters + if (doprocessData) { + registryData.add("number_of_events_data", "number of events in data", HistType::kTH1D, {{20, 0, 20, "Event Cuts"}}); + registryData.add("dcaxyDatavspt", "dcaxyDatavspt", HistType::kTH2D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {400, -2, 2, "DCA_{xy} (cm)"}}); + registryData.add("dcazDatavspt", "dcazDatavspt", HistType::kTH2D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {400, -2, 2, "DCA_{z} (cm)"}}); + registryData.add("primPionTPC", "primPionTPC", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryData.add("primPionTPC_ITS", "primPionTPC_ITS", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryData.add("secPionTPC", "secPionTPC", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryData.add("secPionTPC_ITS", "secPionTPC_ITS", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryData.add("secPionV0TPC", "secPionV0TPC", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryData.add("secPionV0TPC_ITS", "secPionV0TPC_ITS", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + } + + if (doprocessMC) { + registryMC.add("number_of_events_mc", "number of events in mc", HistType::kTH1D, {{20, 0, 20, "Event Cuts"}}); + registryMC.add("dcaxyMCvspt", "dcaxyMCvspt", HistType::kTH2D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {400, -2, 2, "DCA_{xy} (cm)"}}); + registryMC.add("dcazMCvspt", "dcazMCvspt", HistType::kTH2D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {400, -2, 2, "DCA_{z} (cm)"}}); + registryMC.add("primPionTPC_MC", "primPionTPC_MC", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryMC.add("primPionTPC_ITS_MC", "primPionTPC_ITS_MC", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryMC.add("secPionTPC_MC", "secPionTPC_MC", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryMC.add("secPionTPC_ITS_MC", "secPionTPC_ITS_MC", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryMC.add("secPionV0TPC_MC", "secPionV0TPC_MC", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + registryMC.add("secPionV0TPC_ITS_MC", "secPionV0TPC_ITS_MC", HistType::kTH3D, {{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}, {100, 0, TwoPI, "#phi"}}); + } + } + + bool hasHitOnITSlayer(uint8_t itsClsmap, int layer) + { + unsigned char testBit = 1 << layer; + return (itsClsmap & testBit); + } + + template + bool passedTrackSelectionTpcPrimary(const TpcPrimTrack& track) + { + if (!track.hasTPC()) + return false; + if (track.tpcNClsCrossedRows() < minNCrossedRowsTPC) + return false; + if (track.tpcChi2NCl() > maxChi2TPC) + return false; + if (track.eta() < etaMin || track.eta() > etaMax) + return false; + if (std::fabs(track.dcaXY()) > dcaxyMax) + return false; + if (std::fabs(track.dcaZ()) > dcazMax) + return false; + return true; + } + + template + bool passedTrackSelectionTpcSecondary(const TpcSecTrack& track) + { + if (!track.hasTPC()) + return false; + if (track.tpcNClsCrossedRows() < minNCrossedRowsTPC) + return false; + if (track.tpcChi2NCl() > maxChi2TPC) + return false; + if (track.eta() < etaMin || track.eta() > etaMax) + return false; + if (std::sqrt(track.dcaXY() * track.dcaXY() + track.dcaZ() * track.dcaZ()) < dcaMin) + return false; + return true; + } + + template + bool passedTrackSelectionV0daughTPC(const v0Track& track) + { + if (!track.hasTPC()) + return false; + if (track.tpcNClsCrossedRows() < minNCrossedRowsTPC) + return false; + if (track.tpcChi2NCl() > maxChi2TPC) + return false; + if (track.eta() < etaMin || track.eta() > etaMax) + return false; + return true; + } + + // K0s Selections + template + bool passedK0ShortSelection(const K0short& v0) + { + if (v0.v0cosPA() < v0cospaMin) + return false; + if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) + return false; + if (v0.dcaV0daughters() > dcaV0DaughtersMax) + return false; + if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) + return false; + if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) + return false; + if (v0.mK0Short() < mK0Min || v0.mK0Short() > mK0Max) + return false; + + return true; + } + + template + bool passedPionSelection(const pionTrack& track) + { + // TPC Selection + if (track.tpcNSigmaPi() < nsigmaTPCmin || track.tpcNSigmaPi() > nsigmaTPCmax) + return false; + + // TOF Selection + if (requireTOF) { + if (track.tofNSigmaPi() < nsigmaTOFmin || track.tofNSigmaPi() > nsigmaTOFmax) + return false; + } + return true; + } + + template + bool passedTrackSelectionIts(const ItsTrack& track) + { + /* + if (!track.hasITS()) + return false; + if (track.itsNCls() < minITSnCls) + return false; + if (track.itsChi2NCl() > maxChi2ITS) + return false; + */ + + if (track.itsNCls() < minITSnCls) + return false; + + auto requiredItsHit = static_cast>(requiredHit); + if (requireItsHits) { + for (int i = 0; i < 7; i++) { + if (requiredItsHit[i] > 0 && !hasHitOnITSlayer(track.itsClusterMap(), i)) { + return false; + } + } + } + return true; + } + + void processData(SelCollisions::iterator const& collision, aod::V0Datas const& fullV0s, StrHadronDaughterTracks const& tracks) + { + registryData.fill(HIST("number_of_events_data"), 0.5); + + // Event Selection + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + return; + registryData.fill(HIST("number_of_events_data"), 1.5); + + for (const auto& track : tracks) { + + // DCA distributions + if (passedTrackSelectionV0daughTPC(track) && passedPionSelection(track)) { + registryData.fill(HIST("dcaxyDatavspt"), track.pt(), track.dcaXY()); + registryData.fill(HIST("dcazDatavspt"), track.pt(), track.dcaZ()); + } + + // Primary Tracks + if (passedTrackSelectionTpcPrimary(track) && passedPionSelection(track)) + registryData.fill(HIST("primPionTPC"), track.pt(), track.eta(), TVector2::Phi_0_2pi(track.phi())); + if (passedTrackSelectionTpcPrimary(track) && passedPionSelection(track) && passedTrackSelectionIts(track)) + registryData.fill(HIST("primPionTPC_ITS"), track.pt(), track.eta(), TVector2::Phi_0_2pi(track.phi())); + + // Secondary Tracks + if (passedTrackSelectionTpcSecondary(track) && passedPionSelection(track)) + registryData.fill(HIST("secPionTPC"), track.pt(), track.eta(), TVector2::Phi_0_2pi(track.phi())); + if (passedTrackSelectionTpcSecondary(track) && passedPionSelection(track) && passedTrackSelectionIts(track)) + registryData.fill(HIST("secPionTPC_ITS"), track.pt(), track.eta(), TVector2::Phi_0_2pi(track.phi())); + } + + for (const auto& v0 : fullV0s) { + + const auto& posTrack = v0.posTrack_as(); + const auto& negTrack = v0.negTrack_as(); + if (!passedK0ShortSelection(v0)) + continue; + + if (passedTrackSelectionV0daughTPC(posTrack) && passedPionSelection(posTrack)) + registryData.fill(HIST("secPionV0TPC"), posTrack.pt(), posTrack.eta(), TVector2::Phi_0_2pi(posTrack.phi())); + if (passedTrackSelectionV0daughTPC(negTrack) && passedPionSelection(negTrack)) + registryData.fill(HIST("secPionV0TPC"), negTrack.pt(), negTrack.eta(), TVector2::Phi_0_2pi(negTrack.phi())); + if (passedTrackSelectionV0daughTPC(posTrack) && passedPionSelection(posTrack) && passedTrackSelectionIts(posTrack)) + registryData.fill(HIST("secPionV0TPC_ITS"), posTrack.pt(), posTrack.eta(), TVector2::Phi_0_2pi(posTrack.phi())); + if (passedTrackSelectionV0daughTPC(negTrack) && passedPionSelection(negTrack) && passedTrackSelectionIts(negTrack)) + registryData.fill(HIST("secPionV0TPC_ITS"), negTrack.pt(), negTrack.eta(), TVector2::Phi_0_2pi(negTrack.phi())); + } + } + PROCESS_SWITCH(LfITSTPCMatchingSecondaryTracksQA, processData, "Process data", true); + + Preslice perCollisionV0 = o2::aod::v0data::collisionId; + Preslice perCollisionTrk = o2::aod::track::collisionId; + + void processMC(SimCollisions const& collisions, MCTracks const& mcTracks, aod::V0Datas const& fullV0s, const aod::McParticles&) + { + for (const auto& collision : collisions) { + registryMC.fill(HIST("number_of_events_mc"), 0.5); + + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + continue; + registryMC.fill(HIST("number_of_events_mc"), 1.5); + + auto v0sPerColl = fullV0s.sliceBy(perCollisionV0, collision.globalIndex()); + auto tracksPerColl = mcTracks.sliceBy(perCollisionTrk, collision.globalIndex()); + + for (const auto& track : tracksPerColl) { + + // DCA distributions + if (passedTrackSelectionV0daughTPC(track) && passedPionSelection(track)) { + registryMC.fill(HIST("dcaxyMCvspt"), track.pt(), track.dcaXY()); + registryMC.fill(HIST("dcazMCvspt"), track.pt(), track.dcaZ()); + } + + // Primary Tracks + if (passedTrackSelectionTpcPrimary(track) && passedPionSelection(track)) + registryMC.fill(HIST("primPionTPC_MC"), track.pt(), track.eta(), TVector2::Phi_0_2pi(track.phi())); + if (passedTrackSelectionTpcPrimary(track) && passedPionSelection(track) && passedTrackSelectionIts(track)) + registryMC.fill(HIST("primPionTPC_ITS_MC"), track.pt(), track.eta(), TVector2::Phi_0_2pi(track.phi())); + + // Secondary Tracks + if (passedTrackSelectionTpcSecondary(track) && passedPionSelection(track)) + registryMC.fill(HIST("secPionTPC_MC"), track.pt(), track.eta(), TVector2::Phi_0_2pi(track.phi())); + if (passedTrackSelectionTpcSecondary(track) && passedPionSelection(track) && passedTrackSelectionIts(track)) + registryMC.fill(HIST("secPionTPC_ITS_MC"), track.pt(), track.eta(), TVector2::Phi_0_2pi(track.phi())); + } + + for (const auto& v0 : v0sPerColl) { + + const auto& posTrack = v0.posTrack_as(); + const auto& negTrack = v0.negTrack_as(); + if (!passedK0ShortSelection(v0)) + continue; + + if (passedTrackSelectionV0daughTPC(posTrack) && passedPionSelection(posTrack)) + registryMC.fill(HIST("secPionV0TPC_MC"), posTrack.pt(), posTrack.eta(), TVector2::Phi_0_2pi(posTrack.phi())); + if (passedTrackSelectionV0daughTPC(negTrack) && passedPionSelection(negTrack)) + registryMC.fill(HIST("secPionV0TPC_MC"), negTrack.pt(), negTrack.eta(), TVector2::Phi_0_2pi(negTrack.phi())); + if (passedTrackSelectionV0daughTPC(posTrack) && passedPionSelection(posTrack) && passedTrackSelectionIts(posTrack)) + registryMC.fill(HIST("secPionV0TPC_ITS_MC"), posTrack.pt(), posTrack.eta(), TVector2::Phi_0_2pi(posTrack.phi())); + if (passedTrackSelectionV0daughTPC(negTrack) && passedPionSelection(negTrack) && passedTrackSelectionIts(negTrack)) + registryMC.fill(HIST("secPionV0TPC_ITS_MC"), negTrack.pt(), negTrack.eta(), TVector2::Phi_0_2pi(negTrack.phi())); + } + } + } + PROCESS_SWITCH(LfITSTPCMatchingSecondaryTracksQA, processMC, "Process MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/QC/mcParticlePrediction.cxx b/PWGLF/Tasks/QC/mcParticlePrediction.cxx index 8a4a1ec3ac9..0c1fca899f3 100644 --- a/PWGLF/Tasks/QC/mcParticlePrediction.cxx +++ b/PWGLF/Tasks/QC/mcParticlePrediction.cxx @@ -63,7 +63,8 @@ struct Estimators { static constexpr estID V0A = 16; // (Run2) static constexpr estID V0C = 17; // (Run2) static constexpr estID V0AC = 18; // (Run2 V0M) - static constexpr estID nEstimators = 19; + static constexpr estID ImpactParameter = 19; // (Run2 V0M) + static constexpr estID nEstimators = 20; static constexpr const char* estimatorNames[nEstimators] = {"FT0A", "FT0C", @@ -83,7 +84,8 @@ struct Estimators { "ETA08", "V0A", "V0C", - "V0AC"}; + "V0AC", + "ImpactParameter"}; static std::vector arrayNames() { static std::vector names; @@ -115,13 +117,15 @@ static const int defaultEstimators[Estimators::nEstimators][nParameters]{{0}, / {0}, // ETA08 {0}, // V0A (Run2) {0}, // V0C (Run2) - {0}}; // V0AC (Run2 V0M) + {0}, // V0AC (Run2 V0M) + {0}}; // ImpactParamter // Histograms std::array, Estimators::nEstimators> hestimators; std::array, Estimators::nEstimators> hestimatorsVsITS; std::array, Estimators::nEstimators> hestimatorsVsETA05; std::array, Estimators::nEstimators> hestimatorsVsETA08; +std::array, Estimators::nEstimators> hestimatorsVsImpactParameter; std::array, Estimators::nEstimators> hestimatorsRecoEvGenVsReco; std::array, Estimators::nEstimators> hestimatorsRecoEvGenVsReco_BCMC; std::array, Estimators::nEstimators> hestimatorsRecoEvGenVsRecoITS; @@ -146,6 +150,7 @@ struct mcParticlePrediction { ConfigurableAxis binsVxy{"binsVxy", {100, -10, 10}, "Binning of the production vertex (x and y) axis"}; ConfigurableAxis binsVz{"binsVz", {100, -10, 10}, "Binning of the production vertex (z) axis"}; ConfigurableAxis binsPt{"binsPt", {100, 0, 10}, "Binning of the Pt axis"}; + ConfigurableAxis binsImpactParameter{"binsImpactParameter", {400, 0.0, 20.0}, "Binning of the impact parameter axis"}; ConfigurableAxis binsMultiplicity{"binsMultiplicity", {300, -0.5, 299.5}, "Binning of the Multiplicity axis"}; ConfigurableAxis binsMultiplicityReco{"binsMultiplicityReco", {1000, -0.5, -0.5 + 10000}, "Binning of the Multiplicity axis"}; Configurable> enabledSpecies{"enabledSpecies", @@ -169,6 +174,7 @@ struct mcParticlePrediction { Configurable enableVsITSHistograms{"enableVsITSHistograms", true, "Enables the correlation between ITS and other estimators"}; Configurable enableVsEta05Histograms{"enableVsEta05Histograms", true, "Enables the correlation between ETA05 and other estimators"}; Configurable enableVsEta08Histograms{"enableVsEta08Histograms", true, "Enables the correlation between ETA08 and other estimators"}; + Configurable enableVsImpactParameterHistograms{"enableVsImpactParameterHistograms", true, "Enables the correlation between impact parameter and other estimators"}; Service pdgDB; o2::pwglf::ParticleCounter mCounter; @@ -182,6 +188,7 @@ struct mcParticlePrediction { const AxisSpec axisVy{binsVxy, "Vy"}; const AxisSpec axisVz{binsVz, "Vz"}; const AxisSpec axisPt{binsPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisImpactParameter{binsImpactParameter, "Impact parameter (fm)"}; const AxisSpec axisMultiplicity{binsMultiplicity, "Multiplicity (undefined)"}; const AxisSpec axisMultiplicityReco{binsMultiplicityReco, "Multiplicity Reco. (undefined)"}; const AxisSpec axisMultiplicityRecoITS{100, 0, 100, "Multiplicity Reco. ITSIB"}; @@ -258,30 +265,38 @@ struct mcParticlePrediction { if (!enabledEstimatorsArray[i]) { continue; } + AxisSpec axisThisEstimator = axisMultiplicity; + if (i == Estimators::ImpactParameter) { + axisThisEstimator = axisImpactParameter; + } const char* name = Estimators::estimatorNames[i]; - hestimators[i] = histos.add(Form("multiplicity/%s", name), name, kTH1D, {axisMultiplicity}); + hestimators[i] = histos.add(Form("multiplicity/%s", name), name, kTH1D, {axisThisEstimator}); hestimators[i]->GetXaxis()->SetTitle(Form("Multiplicity %s", name)); - auto make2DH = [&](const std::string& h, const char* ytitle) { + auto make2DH = [&](const std::string& h, const char* ytitle, bool isImpactParameterX = false, bool isImpactParameterY = false) { auto hist = histos.add(Form("%s%s", h.c_str(), name), name, kTH2D, - {axisMultiplicity, axisMultiplicity}); + {isImpactParameterX ? axisImpactParameter : axisMultiplicity, + isImpactParameterY ? axisImpactParameter : axisMultiplicity}); hist->GetXaxis()->SetTitle(Form("Multiplicity %s", name)); - hist->GetXaxis()->SetTitle(Form("Multiplicity %s", ytitle)); + hist->GetYaxis()->SetTitle(Form("Multiplicity %s", ytitle)); return hist; }; if (enableVsITSHistograms) { - hestimatorsVsITS[i] = make2DH("multiplicity/vsITS/", Estimators::estimatorNames[Estimators::ITSIB]); + hestimatorsVsITS[i] = make2DH("multiplicity/vsITS/", Estimators::estimatorNames[Estimators::ITSIB], (i == Estimators::ImpactParameter)); } if (enableVsEta05Histograms) { - hestimatorsVsETA05[i] = make2DH("multiplicity/vsETA05/", Estimators::estimatorNames[Estimators::ETA05]); + hestimatorsVsETA05[i] = make2DH("multiplicity/vsETA05/", Estimators::estimatorNames[Estimators::ETA05], (i == Estimators::ImpactParameter)); } if (enableVsEta08Histograms) { - hestimatorsVsETA08[i] = make2DH("multiplicity/vsETA08/", Estimators::estimatorNames[Estimators::ETA08]); + hestimatorsVsETA08[i] = make2DH("multiplicity/vsETA08/", Estimators::estimatorNames[Estimators::ETA08], (i == Estimators::ImpactParameter)); + } + if (enableVsImpactParameterHistograms) { + hestimatorsVsImpactParameter[i] = make2DH("multiplicity/vsImpactParameter/", Estimators::estimatorNames[Estimators::ImpactParameter], (i == Estimators::ImpactParameter), true); } - hvertexPosZ[i] = histos.add(Form("multiplicity/posZ/%s", name), name, kTH2D, {{200, -20, 20, "pos Z"}, axisMultiplicity}); + hvertexPosZ[i] = histos.add(Form("multiplicity/posZ/%s", name), name, kTH2D, {{200, -20, 20, "pos Z"}, axisThisEstimator}); hvertexPosZ[i]->GetYaxis()->SetTitle(Form("Multiplicity %s", name)); if (!doprocessReco) { // Reco events @@ -331,11 +346,15 @@ struct mcParticlePrediction { if (!enabledEstimatorsArray[j]) { continue; } + AxisSpec axisThisEstimator = axisMultiplicity; + if (j == Estimators::ImpactParameter) { + axisThisEstimator = axisImpactParameter; + } const char* name = Estimators::estimatorNames[j]; - hpt[j][i] = histosPt.add(Form("prediction/pt/%s/%s", name, PIDExtended::getName(i)), PIDExtended::getName(i), kTH2D, {axisPt, axisMultiplicity}); + hpt[j][i] = histosPt.add(Form("prediction/pt/%s/%s", name, PIDExtended::getName(i)), PIDExtended::getName(i), kTH2D, {axisPt, axisThisEstimator}); hpt[j][i]->GetYaxis()->SetTitle(Form("Multiplicity %s", name)); - hyield[j][i] = histosYield.add(Form("prediction/yield/%s/%s", name, PIDExtended::getName(i)), PIDExtended::getName(i), kTH1D, {axisMultiplicity}); + hyield[j][i] = histosYield.add(Form("prediction/yield/%s/%s", name, PIDExtended::getName(i)), PIDExtended::getName(i), kTH1D, {axisThisEstimator}); hyield[j][i]->GetYaxis()->SetTitle(Form("Multiplicity %s", name)); } } @@ -345,7 +364,7 @@ struct mcParticlePrediction { histosYield.print(); } - std::array genMult(const auto& mcParticles) + std::array genMult(const auto& mcCollision, const auto& mcParticles) { std::array nMult; if (enabledEstimatorsArray[Estimators::FT0A] || enabledEstimatorsArray[Estimators::FT0AC]) { @@ -402,6 +421,9 @@ struct mcParticlePrediction { nMult[Estimators::V0AC] = 0; } } + if (enabledEstimatorsArray[Estimators::ImpactParameter]) { + nMult[Estimators::ImpactParameter] = mcCollision.impactParameter(); + } return nMult; } @@ -419,7 +441,7 @@ struct mcParticlePrediction { } histos.fill(HIST("collisions/generated"), 2); - const std::array& nMult = genMult(mcParticles); + const std::array& nMult = genMult(mcCollision, mcParticles); for (int i = 0; i < Estimators::nEstimators; i++) { if (!enabledEstimatorsArray[i]) { @@ -436,6 +458,9 @@ struct mcParticlePrediction { if (enableVsEta08Histograms) { hestimatorsVsETA08[i]->Fill(nMult[i], nMult[Estimators::ETA08]); } + if (enableVsImpactParameterHistograms) { + hestimatorsVsImpactParameter[i]->Fill(nMult[i], nMult[Estimators::ImpactParameter]); + } hvertexPosZ[i]->Fill(mcCollision.posZ(), nMult[i]); } @@ -611,7 +636,7 @@ struct mcParticlePrediction { histos.fill(HIST("particles/FromCollVsFromCollBad"), particlesFromColl, particlesFromCollWrongBC); histos.fill(HIST("particles/FromCollBadOverFromCollVsVsFromMCColl"), 1.f * particlesFromCollWrongBC / particlesFromColl, particlesInCollision.size()); - const std::array& nMult = genMult(mcParticles); + const std::array& nMult = genMult(mcCollision, particlesInCollision); float nMultReco[Estimators::nEstimators]; nMultReco[Estimators::FT0A] = collision.multFT0A(); diff --git a/PWGLF/Tasks/QC/strderivedGenQA.cxx b/PWGLF/Tasks/QC/strderivedGenQA.cxx new file mode 100644 index 00000000000..201dcd99ac2 --- /dev/null +++ b/PWGLF/Tasks/QC/strderivedGenQA.cxx @@ -0,0 +1,1211 @@ +// 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. +// +// This code does basic QA of strangeness derived data +// *+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* +// Strange Derived Generation QA +// *+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* +// +// Comments, questions, complaints, suggestions? +// Please write to: +// gianni.shigeru.setoue.liveraro@cern.ch +// + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "ReconstructionDataFormats/Track.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/trackUtilities.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessMLTables.h" +#include "CCDB/BasicCCDBManager.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace std; +using std::array; +using dauTracks = soa::Join; +using StrCollisionsDatas = soa::Join; +using V0DerivedDatas = soa::Join; +using V0DerivedMCDatas = soa::Join; +using CascDerivedMCDatas = soa::Join; +using CascDerivedDatas = soa::Join; + +struct strderivedGenQA { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // pack track quality but separte also afterburner + // dynamic range: 0-31 + enum selection : int { hasTPC = 0, + hasITSTracker, + hasITSAfterburner, + hasTRD, + hasTOF }; + + Configurable doPPAnalysis{"doPPAnalysis", true, "if in pp, set to true"}; + + struct : ConfigurableGroup { + Configurable requireSel8{"requireSel8", true, "require sel8 event selection"}; + Configurable requireTriggerTVX{"requireTriggerTVX", true, "require FT0 vertex (acceptable FT0C-FT0A time difference) at trigger level"}; + Configurable rejectITSROFBorder{"rejectITSROFBorder", true, "reject events at ITS ROF border"}; + Configurable rejectTFBorder{"rejectTFBorder", true, "reject events at TF border"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "require events with at least one ITS-TPC track"}; + Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", true, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference"}; + Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", false, "require events with at least one of vertex contributors matched to TOF"}; + Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", false, "require events with at least one of vertex contributors matched to TRD"}; + Configurable rejectSameBunchPileup{"rejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC"}; + Configurable requireNoCollInTimeRangeStd{"requireNoCollInTimeRangeStd", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds"}; + Configurable requireNoCollInTimeRangeStrict{"requireNoCollInTimeRangeStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 10 microseconds"}; + Configurable requireNoCollInTimeRangeNarrow{"requireNoCollInTimeRangeNarrow", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds"}; + Configurable requireNoCollInROFStd{"requireNoCollInROFStd", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF with mult. above a certain threshold"}; + Configurable requireNoCollInROFStrict{"requireNoCollInROFStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF"}; + Configurable requireINEL0{"requireINEL0", true, "require INEL>0 event selection"}; + Configurable requireINEL1{"requireINEL1", false, "require INEL>1 event selection"}; + + Configurable maxZVtxPosition{"maxZVtxPosition", 10., "max Z vtx position"}; + + Configurable useFT0CbasedOccupancy{"useFT0CbasedOccupancy", false, "Use sum of FT0-C amplitudes for estimating occupancy? (if not, use track-based definition)"}; + // fast check on occupancy + Configurable minOccupancy{"minOccupancy", -1, "minimum occupancy from neighbouring collisions"}; + Configurable maxOccupancy{"maxOccupancy", -1, "maximum occupancy from neighbouring collisions"}; + } eventSelections; + + struct : ConfigurableGroup { + Configurable v0TypeSelection{"v0TypeSelection", 1, "select on a certain V0 type (leave negative if no selection desired)"}; + + // Selection criteria: acceptance + Configurable rapidityCut{"rapidityCut", 0.5, "rapidity"}; + Configurable daughterEtaCut{"daughterEtaCut", 0.8, "max eta for daughters"}; + + // Standard 5 topological criteria + Configurable v0cospa{"v0cospa", 0.97, "min V0 CosPA"}; + Configurable dcav0dau{"dcav0dau", 1.0, "max DCA V0 Daughters (cm)"}; + Configurable dcanegtopv{"dcanegtopv", .05, "min DCA Neg To PV (cm)"}; + Configurable dcapostopv{"dcapostopv", .05, "min DCA Pos To PV (cm)"}; + Configurable v0radius{"v0radius", 1.2, "minimum V0 radius (cm)"}; + Configurable v0radiusMax{"v0radiusMax", 1E5, "maximum V0 radius (cm)"}; + + // Additional selection on the AP plot (exclusive for K0Short) + // original equation: lArmPt*5>TMath::Abs(lArmAlpha) + Configurable armPodCut{"armPodCut", 5.0f, "pT * (cut) > |alpha|, AP cut. Negative: no cut"}; + + // Track quality + Configurable minTPCrows{"minTPCrows", 70, "minimum TPC crossed rows"}; + Configurable minITSclusters{"minITSclusters", -1, "minimum ITS clusters"}; + Configurable skipTPConly{"skipTPConly", false, "skip V0s comprised of at least one TPC only prong"}; + Configurable requirePosITSonly{"requirePosITSonly", false, "require that positive track is ITSonly (overrides TPC quality)"}; + Configurable requireNegITSonly{"requireNegITSonly", false, "require that negative track is ITSonly (overrides TPC quality)"}; + Configurable rejectPosITSafterburner{"rejectPosITSafterburner", false, "reject positive track formed out of afterburner ITS tracks"}; + Configurable rejectNegITSafterburner{"rejectNegITSafterburner", false, "reject negative track formed out of afterburner ITS tracks"}; + + // PID (TPC/TOF) + Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; + Configurable TofPidNsigmaCutLaPr{"TofPidNsigmaCutLaPr", 1e+6, "TofPidNsigmaCutLaPr"}; + Configurable TofPidNsigmaCutLaPi{"TofPidNsigmaCutLaPi", 1e+6, "TofPidNsigmaCutLaPi"}; + Configurable TofPidNsigmaCutK0Pi{"TofPidNsigmaCutK0Pi", 1e+6, "TofPidNsigmaCutK0Pi"}; + + // PID (TOF) + Configurable maxDeltaTimeProton{"maxDeltaTimeProton", 1e+9, "check maximum allowed time"}; + Configurable maxDeltaTimePion{"maxDeltaTimePion", 1e+9, "check maximum allowed time"}; + } v0Selections; + + // Axis declarations + ConfigurableAxis axisPosZ{"axisPosZ", {100, -50.0f, 50.0f}, "Z Position"}; + ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Centrality"}; + + // Boolean axes + ConfigurableAxis axisBool{"axisBool", {2, 0.0f, 2.0f}, "axisBool"}; + ConfigurableAxis axisFt0cOccupancyInTimeRange{"axisFt0cOccupancyInTimeRange", {50, 0, 80000}, "FT0C occupancy"}; + ConfigurableAxis axisTrackOccupancyInTimeRange{"axisTrackOccupancyInTimeRange", {50, 0, 5000}, "Track occupancy"}; + ConfigurableAxis axisMultFT0C{"axisMultFT0C", {1000, 0, 100000}, "FT0C amplitude"}; + ConfigurableAxis axisMultNTracksPVeta1{"axisMultNTracksPVeta1", {200, 0, 6000}, "Mult NTracks PV eta 1"}; + ConfigurableAxis axisMultPVTotalContributors{"axisMultPVTotalContributors", {200, 0, 6000}, "Number of PV Contributors"}; + ConfigurableAxis axisMultAllTracksTPCOnly{"axisMultAllTracksTPCOnly", {200, 0, 6000}, "Mult All Tracks TPC Only"}; + ConfigurableAxis axisMultAllTracksITSTPC{"axisMultAllTracksITSTPC", {200, 0, 6000}, "Mult All Tracks ITS TPC"}; + ConfigurableAxis axisNch{"axisNch", {500, 0.0f, +5000.0f}, "Number of charged particles"}; + ConfigurableAxis axisNumV0sPerColl{"axisNumV0sPerColl", {50000, -0.5f, 49999.5f}, "Num V0s Per Coll"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "Pt Axis"}; + ConfigurableAxis axisPt2{"axisPt2", {VARIABLE_WIDTH, -50.0f, -40.0f, -35.0f, -30.0f, -25.0f, -23.0f, -21.0f, -19.0f, -17.0f, -15.0f, -14.0f, -13.0f, -12.0f, -11.0f, -10.0f, -9.0f, -8.0f, -7.5f, -7.0f, -6.5f, -6.0f, -5.6f, -5.2f, -4.8f, -4.4f, -4.0f, -3.8f, -3.6f, -3.4f, -3.2f, -3.0f, -2.8f, -2.6f, -2.4f, -2.2f, -2.0f, -1.9f, -1.8f, -1.7f, -1.6f, -1.5f, -1.4f, -1.3f, -1.2f, -1.1f, -1.0f, -0.9f, -0.8f, -0.7f, -0.6f, -0.5f, -0.4f, -0.3f, -0.2f, -0.1f, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "Pt Axis"}; + ConfigurableAxis axisAlpha{"axisAlpha", {220, -1.1f, 1.1f}, "Alpha"}; + ConfigurableAxis axisQtarm{"axisQtarm", {220, 0.0f, 0.5f}, "Qtarm"}; + ConfigurableAxis axisCosPA{"axisCosPA", {240, 0.0f, 1.2f}, "CosPA"}; + ConfigurableAxis axisDCAdau{"axisDCAdau", {50, 0.0f, 5.0f}, "DCA V0 Daughters"}; + ConfigurableAxis axisEta{"axisEta", {100, -3.0f, 3.0f}, "Eta"}; + ConfigurableAxis axisPhi{"axisPhi", {100, 0.0f, TMath::TwoPi()}, "Phi"}; + ConfigurableAxis axisMassGamma{"axisMassGamma", {400, 0.0f, 0.5f}, "Mass Gamma"}; + ConfigurableAxis axisMassLambda{"axisMassLambda", {400, 1.0f, 1.2f}, "Mass Lambda"}; + ConfigurableAxis axisMassK0Short{"axisMassK0Short", {400, 0.4f, 0.6f}, "Mass K0Short"}; + ConfigurableAxis axisV0Type{"axisV0Type", {5, 0.0f, 5.0f}, "V0 Type"}; + ConfigurableAxis axisStraCollisionId{"axisStraCollisionId", {4000, 0.0f, 40000.0f}, "Stra Collision Id"}; + ConfigurableAxis axisGlobalIndex{"axisGlobalIndex", {4000, 0.0f, 40000.0f}, "Global Index"}; + ConfigurableAxis axisNCls{"axisNCls", {8, -0.5, 7.5}, "NCls"}; + ConfigurableAxis axisTPCrows{"axisTPCrows", {160, 0.0f, 160.0f}, "N TPC rows"}; + ConfigurableAxis axisChi2PerNcl{"axisChi2PerNcl", {100, 0, 40}, "Chi2 Per Ncl"}; + ConfigurableAxis axisTPCNSigma{"axisTPCNSigma", {100, -50.0f, 50.0f}, "TPC N Sigma"}; + ConfigurableAxis axisTPCSignal{"axisTPCSignal", {400, -100.0, 300.0}, "TPC Signal"}; + ConfigurableAxis axisTOFNSigma{"axisTOFNSigma", {100, -50.0f, 50.0f}, "TOF N Sigma"}; + ConfigurableAxis axisTOFDeltaT{"axisTOFDeltaT", {200, -1000.0f, +1000.0f}, "TOF Delta T"}; + ConfigurableAxis axisPtResolution{"axisPtResolution", {100, -1.0f, 1.0f}, "Pt Resolution"}; + ConfigurableAxis axisPDGCode{"axisPDGCode", {10001, -5000.5f, +5000.5f}, "PDG Code"}; + ConfigurableAxis axisV0Radius{"axisV0Radius", {400, 0.0f, 200.0f}, "V0 Radius"}; + ConfigurableAxis axisCascRadius{"axisCascRadius", {500, 0.0f, 50.0f}, "Casc Radius"}; + ConfigurableAxis axisDCAToPV{"axisDCAToPV", {500, -50.0f, 50.0f}, "DCA Dau to PV"}; + ConfigurableAxis axisDCAXYCascToPV{"axisDCAXYCascToPV", {1000, 0.0f, 10.0f}, "DCA XY Casc to PV"}; + ConfigurableAxis axisDCAZCascToPV{"axisDCAZCascToPV", {500, -10.0f, 10.0f}, "DCA Z Casc to PV"}; + ConfigurableAxis axisDCAV0ToPV{"axisDCAV0ToPV", {1000, -10.0f, 10.0f}, "DCA V0 to PV"}; + ConfigurableAxis axisDCAV0Dau{"axisDCAV0Dau", {1000, 0.0f, 10.0f}, "DCA V0 Daughters"}; + ConfigurableAxis axisDCACascDau{"axisDCACascDau", {1000, 0.0f, 10.0f}, "DCA Casc Daughters"}; + ConfigurableAxis axisOmegaMass{"axisOmegaMass", {400, 1.6f, 1.8f}, "Omega Mass"}; + ConfigurableAxis axisXiMass{"axisXiMass", {400, 1.2f, 1.4f}, "Xi Mass"}; + ConfigurableAxis axisTrackProperties{"axisTrackProperties", {32, -0.5, 31.5f}, "Track Properties"}; + + PresliceUnsorted> perMcCollision = aod::v0data::straMCCollisionId; + + void init(InitContext const&) + { + // Histogram declarations (can be improved!) + histos.add("Event/hPosZ", "hPosZ", kTH1F, {axisPosZ}); + + // Event Counters + histos.add("Event/hEventProperties", "hEventProperties", kTH1F, {{20, -0.5f, +18.5f}}); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(1, "All collisions"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(3, "kIsTriggerTVX"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(5, "kNoTimeFrameBorder"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(6, "kIsVertexITSTPC"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(7, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(8, "kIsVertexTOFmatched"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(9, "kIsVertexTRDmatched"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(10, "kNoSameBunchPileup"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(11, "kNoCollInTimeRangeStd"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(12, "kNoCollInTimeRangeStrict"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(13, "kNoCollInTimeRangeNarrow"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(14, "kNoCollInRofStd"); + histos.get(HIST("Event/hEventProperties"))->GetXaxis()->SetBinLabel(15, "kNoCollInRofStrict"); + + histos.add("Event/hft0cOccupancyInTimeRange", "hft0cOccupancyInTimeRange", kTH1F, {axisFt0cOccupancyInTimeRange}); + histos.add("Event/htrackOccupancyInTimeRange", "htrackOccupancyInTimeRange", kTH1F, {axisTrackOccupancyInTimeRange}); + histos.add("Event/h2dMultFT0C", "h2dMultFT0C", kTH2F, {axisCentrality, axisMultFT0C}); + histos.add("Event/h2dMultNTracksPVeta1", "h2dMultNTracksPVeta1", kTH2F, {axisCentrality, axisMultNTracksPVeta1}); + histos.add("Event/h2dMultPVTotalContributors", "h2dMultPVTotalContributors", kTH2F, {axisCentrality, axisMultPVTotalContributors}); + histos.add("Event/h2dMultAllTracksTPCOnly", "h2dMultAllTracksTPCOnly", kTH2F, {axisCentrality, axisMultAllTracksTPCOnly}); + histos.add("Event/h2dMultAllTracksITSTPC", "h2dMultAllTracksITSTPC", kTH2F, {axisCentrality, axisMultAllTracksITSTPC}); + histos.add("Event/h2dNumV0sPerColl", "h2dNumV0sPerColl", kTH2F, {axisCentrality, axisNumV0sPerColl}); + + histos.add("V0/hpT", "hpT", kTH1F, {axisPt}); + histos.add("V0/h2dArmenterosP", "h2dArmenterosP", kTH2F, {axisAlpha, axisQtarm}); + histos.add("V0/hRadius", "hRadius", kTH1F, {axisV0Radius}); + histos.add("V0/hZ", "hZ", kTH1F, {axisPosZ}); + histos.add("V0/hCosPA", "hCosPA", kTH1F, {axisCosPA}); + histos.add("V0/hdcaDau", "hdcaDau", kTH1F, {axisDCAdau}); + histos.add("V0/hdcaNegtopv", "hdcaNegtopv", kTH1F, {axisDCAToPV}); + histos.add("V0/hdcaPostopv", "hdcaPostopv", kTH1F, {axisDCAToPV}); + histos.add("V0/h2dEtaPhi", "h2dEtaPhi", kTH2F, {axisEta, axisPhi}); + histos.add("V0/hYGamma", "hYGamma", kTH1F, {axisEta}); + histos.add("V0/hYLambda", "hYLambda", kTH1F, {axisEta}); + histos.add("V0/hYK0Short", "hYK0Short", kTH1F, {axisEta}); + histos.add("V0/hMassGamma", "hMassGamma", kTH1F, {axisMassGamma}); + histos.add("V0/hMassLambda", "hMassLambda", kTH1F, {axisMassLambda}); + histos.add("V0/hMassK0Short", "hMassK0Short", kTH1F, {axisMassK0Short}); + histos.add("V0/hV0Type", "hV0Type", kTH1F, {axisV0Type}); + histos.add("V0/h2dV0Indices", "h2dV0Indices", kTH2F, {axisStraCollisionId, axisGlobalIndex}); + + histos.add("V0/Track/h2dITSNCls", "h2dITSNCls", kTH2F, {axisPt2, axisNCls}); + histos.add("V0/Track/h2dITSChi2PerNcl", "h2dITSChi2PerNcl", kTH2F, {axisPt2, axisChi2PerNcl}); + histos.add("V0/Track/h2dTPCCrossedRows", "h2dTPCCrossedRows", kTH2F, {axisPt2, axisTPCrows}); + + histos.add("V0/Track/h2dPosTrackProperties", "h2dPosTrackProperties", kTH2F, {axisTrackProperties, axisPt}); + histos.add("V0/Track/h3dTrackPropertiesVspT", "h3dTrackPropertiesVspT", kTH3F, {axisTrackProperties, axisTrackProperties, axisPt}); + histos.add("V0/Track/h2dNegTrackProperties", "h2dNegTrackProperties", kTH2F, {axisTrackProperties, axisPt}); + + // Add histogram to the list + histos.add("V0/Track/hTrackCode", "hTrackCode", kTH1F, {axisTrackProperties}); + + // Set bin labels for all combinations + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(1, "None"); // Code 0 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(2, "TPC"); // Code 1 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(3, "ITSTracker"); // Code 2 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(4, "ITSTracker + TPC"); // Code 3 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(5, "ITSAfterburner"); // Code 4 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(6, "ITSAfterburner + TPC"); // Code 5 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(7, "ITSAfterburner + ITSTracker"); // Code 6 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(8, "ITSAfterburner + ITSTracker + TPC"); // Code 7 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(9, "TRD"); // Code 8 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(10, "TRD + TPC"); // Code 9 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(11, "TRD + ITSTracker"); // Code 10 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(12, "TRD + ITSTracker + TPC"); // Code 11 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(13, "TRD + ITSAfterburner"); // Code 12 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(14, "TRD + ITSAfterburner + TPC"); // Code 13 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(15, "TRD + ITSAfterburner + ITSTracker"); // Code 14 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(16, "TRD + ITSAfterburner + ITSTracker + TPC"); // Code 15 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(17, "TOF"); // Code 16 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(18, "TOF + TPC"); // Code 17 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(19, "TOF + ITSTracker"); // Code 18 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(20, "TOF + ITSTracker + TPC"); // Code 19 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(21, "TOF + ITSAfterburner"); // Code 20 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(22, "TOF + ITSAfterburner + TPC"); // Code 21 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(23, "TOF + ITSAfterburner + ITSTracker"); // Code 22 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(24, "TOF + ITSAfterburner + ITSTracker + TPC"); // Code 23 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(25, "TOF + TRD"); // Code 24 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(26, "TOF + TRD + TPC"); // Code 25 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(27, "TOF + TRD + ITSTracker"); // Code 26 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(28, "TOF + TRD + ITSTracker + TPC"); // Code 27 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(29, "TOF + TRD + ITSAfterburner"); // Code 28 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(30, "TOF + TRD + ITSAfterburner + TPC"); // Code 29 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(31, "TOF + TRD + ITSAfterburner + ITSTracker"); // Code 30 + histos.get(HIST("V0/Track/hTrackCode"))->GetXaxis()->SetBinLabel(32, "All"); // Code 31 + + histos.add("V0/PID/h2dTPCNSigmaEl", "h2dTPCNSigmaEl", kTH2F, {axisPt2, axisTPCNSigma}); + histos.add("V0/PID/h2dTPCNSigmaPr", "h2dTPCNSigmaPr", kTH2F, {axisPt2, axisTPCNSigma}); + histos.add("V0/PID/h2dTPCNSigmaPi", "h2dTPCNSigmaPi", kTH2F, {axisPt2, axisTPCNSigma}); + histos.add("V0/PID/h2dTPCSignal", "h2dTPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + + histos.add("V0/PID/h2dTOFNSigmaLaPr", "h2dTOFNSigmaLaPr", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("V0/PID/h2dTOFNSigmaLaPi", "h2dTOFNSigmaLaPi", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("V0/PID/h2dposTOFDeltaTLaPr", "h2dposTOFDeltaTLaPr", kTH2F, {axisPt, axisTOFDeltaT}); + histos.add("V0/PID/h2dnegTOFDeltaTLaPi", "h2dnegTOFDeltaTLaPi", kTH2F, {axisPt, axisTOFDeltaT}); + histos.add("V0/PID/h2dnegTOFDeltaTLaPr", "h2dnegTOFDeltaTLaPr", kTH2F, {axisPt, axisTOFDeltaT}); + histos.add("V0/PID/h2dposTOFDeltaTLaPi", "h2dposTOFDeltaTLaPi", kTH2F, {axisPt, axisTOFDeltaT}); + histos.add("V0/PID/h2dTOFNSigmaALaPr", "h2dTOFNSigmaALaPr", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("V0/PID/h2dTOFNSigmaALaPi", "h2dTOFNSigmaALaPi", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("V0/PID/h2dTOFNSigmaK0PiPlus", "h2dTOFNSigmaK0PiPlus", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("V0/PID/h2dTOFNSigmaK0PiMinus", "h2dTOFNSigmaK0PiMinus", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("V0/PID/h3dTPCVsTOFNSigmaLaPr", "h3dTPCVsTOFNSigmaLaPr", kTH3F, {axisTPCNSigma, axisTOFNSigma, axisPt}); + histos.add("V0/PID/h3dTPCVsTOFNSigmaLaPi", "h3dTPCVsTOFNSigmaLaPi", kTH3F, {axisTPCNSigma, axisTOFNSigma, axisPt}); + + histos.add("MCV0/hv0MCCore", "hv0MCCore", kTH1F, {axisBool}); + histos.add("MCV0/h2dPDGV0VsMother", "h2dPDGV0VsMother", kTHnSparseD, {axisPDGCode, axisPDGCode}); + histos.add("MCV0/h2dPDGV0VsPositive", "h2dPDGV0VsPositive", kTHnSparseD, {axisPDGCode, axisPDGCode}); + histos.add("MCV0/h2dPDGV0VsNegative", "h2dPDGV0VsNegative", kTHnSparseD, {axisPDGCode, axisPDGCode}); + histos.add("MCV0/h2dPDGV0VsIsPhysicalPrimary", "h2dPDGV0VsIsPhysicalPrimary", kTH2F, {axisPDGCode, axisBool}); + histos.add("MCV0/h2dArmenterosP", "h2dArmenterosP", kTH2F, {axisAlpha, axisQtarm}); + histos.add("MCV0/Gamma/h2dpTResolution", "h2dpTResolution", kTH2F, {axisPt, axisPtResolution}); + histos.add("MCV0/Gamma/h2dMass", "h2dMass", kTH2F, {axisPt, axisMassGamma}); + histos.add("MCV0/Gamma/h2dTPCNSigmaEl", "h2dTPCNSigmaEl", kTH2F, {axisPt2, axisTPCNSigma}); + histos.add("MCV0/Gamma/h2dTPCSignal", "h2dTPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + histos.add("MCV0/Gamma/hRadius", "hRadius", kTH1F, {axisV0Radius}); + histos.add("MCV0/Gamma/hCosPA", "hCosPA", kTH1F, {axisCosPA}); + histos.add("MCV0/Gamma/hdcaDau", "hdcaDau", kTH1F, {axisDCAdau}); + histos.add("MCV0/Gamma/hdcaNegtopv", "hdcaNegtopv", kTH1F, {axisDCAToPV}); + histos.add("MCV0/Gamma/hdcaPostopv", "hdcaPostopv", kTH1F, {axisDCAToPV}); + histos.add("MCV0/Gamma/hZ", "hZ", kTH1F, {{240, -120.0f, 120.0f}}); + + histos.add("MCV0/Lambda/h2dpTResolution", "h2dpTResolution", kTH2F, {axisPt, axisPtResolution}); + histos.add("MCV0/Lambda/h2dMass", "h2dMass", kTH2F, {axisPt, axisMassLambda}); + histos.add("MCV0/Lambda/h2dTPCNSigmaPr", "h2dTPCNSigmaPr", kTH2F, {axisPt, axisTPCNSigma}); + histos.add("MCV0/Lambda/h2dTPCNSigmaPi", "h2dTPCNSigmaPi", kTH2F, {axisPt, axisTPCNSigma}); + histos.add("MCV0/Lambda/h2dTPCSignal", "h2dTPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + histos.add("MCV0/Lambda/hRadius", "hRadius", kTH1F, {axisV0Radius}); + histos.add("MCV0/Lambda/hCosPA", "hCosPA", kTH1F, {axisCosPA}); + histos.add("MCV0/Lambda/hdcaDau", "hdcaDau", kTH1F, {axisDCAdau}); + histos.add("MCV0/Lambda/hdcaNegtopv", "hdcaNegtopv", kTH1F, {axisDCAToPV}); + histos.add("MCV0/Lambda/hdcaPostopv", "hdcaPostopv", kTH1F, {axisDCAToPV}); + + histos.add("MCV0/AntiLambda/h2dpTResolution", "h2dpTResolution", kTH2F, {axisPt, axisPtResolution}); + histos.add("MCV0/AntiLambda/h2dMass", "h2dMass", kTH2F, {axisPt, axisMassLambda}); + histos.add("MCV0/AntiLambda/h2dTPCNSigmaPr", "h2dTPCNSigmaPr", kTH2F, {axisPt, axisTPCNSigma}); + histos.add("MCV0/AntiLambda/h2dTPCNSigmaPi", "h2dTPCNSigmaPi", kTH2F, {axisPt, axisTPCNSigma}); + histos.add("MCV0/AntiLambda/h2dTPCSignal", "h2dTPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + histos.add("MCV0/AntiLambda/hRadius", "hRadius", kTH1F, {axisV0Radius}); + histos.add("MCV0/AntiLambda/hCosPA", "hCosPA", kTH1F, {axisCosPA}); + histos.add("MCV0/AntiLambda/hdcaDau", "hdcaDau", kTH1F, {axisDCAdau}); + histos.add("MCV0/AntiLambda/hdcaNegtopv", "hdcaNegtopv", kTH1F, {axisDCAToPV}); + histos.add("MCV0/AntiLambda/hdcaPostopv", "hdcaPostopv", kTH1F, {axisDCAToPV}); + + histos.add("MCV0/K0Short/h2dpTResolution", "h2dpTResolution", kTH2F, {axisPt, axisPtResolution}); + histos.add("MCV0/K0Short/h2dMass", "h2dMass", kTH2F, {axisPt, axisMassK0Short}); + histos.add("MCV0/K0Short/h2dTPCNSigmaPi", "h2dTPCNSigmaPi", kTH2F, {axisPt2, axisTPCNSigma}); + histos.add("MCV0/K0Short/h2dTPCSignal", "h2dTPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + histos.add("MCV0/K0Short/hRadius", "hRadius", kTH1F, {axisV0Radius}); + histos.add("MCV0/K0Short/hCosPA", "hCosPA", kTH1F, {axisCosPA}); + histos.add("MCV0/K0Short/hdcaDau", "hdcaDau", kTH1F, {axisDCAdau}); + histos.add("MCV0/K0Short/hdcaNegtopv", "hdcaNegtopv", kTH1F, {axisDCAToPV}); + histos.add("MCV0/K0Short/hdcaPostopv", "hdcaPostopv", kTH1F, {axisDCAToPV}); + + histos.add("Casc/Sign", "Sign", kTH1F, {{3, -1.5f, 1.5f}}); + histos.add("Casc/hpT", "hpT", kTH1F, {axisPt}); + histos.add("Casc/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); + histos.add("Casc/hCascRadius", "hCascRadius", kTH1F, {axisCascRadius}); + histos.add("Casc/hV0CosPA", "hV0CosPA", kTH1F, {axisCosPA}); + histos.add("Casc/hCascCosPA", "hCascCosPA", kTH1F, {axisCosPA}); + histos.add("Casc/hDCAPosToPV", "hDCAPosToPV", kTH1F, {axisDCAToPV}); + histos.add("Casc/hDCANegToPV", "hDCANegToPV", kTH1F, {axisDCAToPV}); + histos.add("Casc/hDCABachToPV", "hDCABachToPV", kTH1F, {axisDCAToPV}); + histos.add("Casc/hDCAXYCascToPV", "hDCAXYCascToPV", kTH1F, {axisDCAXYCascToPV}); + histos.add("Casc/hDCAZCascToPV", "hDCAZCascToPV", kTH1F, {axisDCAZCascToPV}); + histos.add("Casc/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("Casc/hDCAV0Dau", "hDCAV0Dau", kTH1F, {axisDCAV0Dau}); + histos.add("Casc/hDCACascDau", "hDCACascDau", kTH1F, {axisDCACascDau}); + histos.add("Casc/hLambdaMass", "hLambdaMass", kTH1F, {axisMassLambda}); + + histos.add("Casc/Track/h3dTrackProperties", "h3dTrackProperties", kTH3F, {axisTrackProperties, axisTrackProperties, axisTrackProperties}); + histos.add("Casc/Track/h2dPosTrackProperties", "h2dPosTrackProperties", kTH2F, {axisTrackProperties, axisPt}); + histos.add("Casc/Track/h2dNegTrackProperties", "h2dNegTrackProperties", kTH2F, {axisTrackProperties, axisPt}); + histos.add("Casc/Track/h2dBachTrackProperties", "h2dBachTrackProperties", kTH2F, {axisTrackProperties, axisPt}); + histos.add("Casc/Track/h2dV0ITSChi2PerNcl", "h2dV0ITSChi2PerNcl", kTH2F, {axisPt2, axisChi2PerNcl}); + histos.add("Casc/Track/h2dV0TPCCrossedRows", "h2dV0TPCCrossedRows", kTH2F, {axisPt2, axisTPCrows}); + histos.add("Casc/Track/h2dV0ITSNCls", "h2dV0ITSNCls", kTH2F, {axisPt2, axisNCls}); + + histos.add("Casc/PID/h2dV0TPCNSigmaPr", "h2dV0TPCNSigmaPr", kTH2F, {axisPt2, axisTPCNSigma}); + histos.add("Casc/PID/h2dV0TPCNSigmaPi", "h2dV0TPCNSigmaPi", kTH2F, {axisPt2, axisTPCNSigma}); + histos.add("Casc/PID/h2dV0TPCSignal", "h2dV0TPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + histos.add("Casc/PID/h2dTOFNSigmaXiLaPi", "h2dTOFNSigmaXiLaPi", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("Casc/PID/h2dTOFNSigmaXiLaPr", "h2dTOFNSigmaXiLaPr", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("Casc/PID/h2dTOFNSigmaXiPi", "h2dTOFNSigmaXiPi", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("Casc/PID/h2dTOFNSigmaOmLaPi", "h2dTOFNSigmaOmLaPi", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("Casc/PID/h2dTOFNSigmaOmLaPr", "h2dTOFNSigmaOmLaPr", kTH2F, {axisPt, axisTOFNSigma}); + histos.add("Casc/PID/h2dTOFNSigmaOmKa", "h2dTOFNSigmaOmKa", kTH2F, {axisPt, axisTOFNSigma}); + + histos.add("Casc/hMassXiMinus", "hMassXiMinus", kTH1F, {axisXiMass}); + histos.add("Casc/hMassOmegaMinus", "hMassOmegaMinus", kTH1F, {axisOmegaMass}); + histos.add("Casc/hMassXiPlus", "hMassXiPlus", kTH1F, {axisXiMass}); + histos.add("Casc/hMassOmegaPlus", "hMassOmegaPlus", kTH1F, {axisOmegaMass}); + histos.add("Casc/Track/h2dBachITSNCls", "h2dBachITSNCls", kTH2F, {axisPt2, axisNCls}); + histos.add("Casc/Track/h2dBachITSChi2PerNcl", "h2dBachITSChi2PerNcl", kTH2F, {axisPt2, axisChi2PerNcl}); + histos.add("Casc/Track/h2dBachTPCCrossedRows", "h2dBachTPCCrossedRows", kTH2F, {axisPt2, axisTPCrows}); + histos.add("Casc/PID/h2dBachTPCSignal", "h2dBachTPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + + histos.add("MCCasc/hcascMCCore", "hcascMCCore", kTH1F, {axisBool}); + histos.add("MCCasc/h2dPDGV0VsMother", "h2dPDGV0VsMother", kTHnSparseD, {axisPDGCode, axisPDGCode}); + histos.add("MCCasc/h2dPDGV0VsPositive", "h2dPDGV0VsPositive", kTHnSparseD, {axisPDGCode, axisPDGCode}); + histos.add("MCCasc/h2dPDGV0VsNegative", "h2dPDGV0VsNegative", kTHnSparseD, {axisPDGCode, axisPDGCode}); + histos.add("MCCasc/h2dPDGV0VsBach", "h2dPDGV0VsBach", kTHnSparseD, {axisPDGCode, axisPDGCode}); + histos.add("MCCasc/h2dPDGV0VsIsPhysicalPrimary", "h2dPDGV0VsIsPhysicalPrimary", kTH2F, {axisPDGCode, axisBool}); + + histos.add("MCCasc/XiMinus/h2dpTResolution", "h2dpTResolution", kTH2F, {axisPt, axisPtResolution}); + histos.add("MCCasc/XiMinus/h2dMass", "h2dMass", kTH2F, {axisPt, axisXiMass}); + histos.add("MCCasc/XiMinus/h2dV0TPCSignal", "h2dV0TPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + histos.add("MCCasc/XiMinus/h2dBachTPCSignal", "h2dBachTPCSignal", kTH2F, {axisPt, axisTPCSignal}); + histos.add("MCCasc/XiMinus/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); + histos.add("MCCasc/XiMinus/hCascRadius", "hCascRadius", kTH1F, {axisCascRadius}); + histos.add("MCCasc/XiMinus/hV0CosPA", "hV0CosPA", kTH1F, {axisCosPA}); + histos.add("MCCasc/XiMinus/hCascCosPA", "hCascCosPA", kTH1F, {axisCosPA}); + histos.add("MCCasc/XiMinus/hDCAPosToPV", "hDCAPosToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/XiMinus/hDCANegToPV", "hDCANegToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/XiMinus/hDCABachToPV", "hDCABachToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/XiMinus/hDCAXYCascToPV", "hDCAXYCascToPV", kTH1F, {axisDCAXYCascToPV}); + histos.add("MCCasc/XiMinus/hDCAZCascToPV", "hDCAZCascToPV", kTH1F, {axisDCAZCascToPV}); + histos.add("MCCasc/XiMinus/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("MCCasc/XiMinus/hDCAV0Dau", "hDCAV0Dau", kTH1F, {axisDCAV0Dau}); + histos.add("MCCasc/XiMinus/hDCACascDau", "hDCACascDau", kTH1F, {axisDCACascDau}); + histos.add("MCCasc/XiMinus/hLambdaMass", "hLambdaMass", kTH1F, {axisMassLambda}); + + histos.add("MCCasc/XiPlus/h2dpTResolution", "h2dpTResolution", kTH2F, {axisPt, axisPtResolution}); + histos.add("MCCasc/XiPlus/h2dMass", "h2dMass", kTH2F, {axisPt, axisXiMass}); + histos.add("MCCasc/XiPlus/h2dV0TPCSignal", "h2dV0TPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + histos.add("MCCasc/XiPlus/h2dBachTPCSignal", "h2dBachTPCSignal", kTH2F, {axisPt, axisTPCSignal}); + histos.add("MCCasc/XiPlus/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); + histos.add("MCCasc/XiPlus/hCascRadius", "hCascRadius", kTH1F, {axisCascRadius}); + histos.add("MCCasc/XiPlus/hV0CosPA", "hV0CosPA", kTH1F, {axisCosPA}); + histos.add("MCCasc/XiPlus/hCascCosPA", "hCascCosPA", kTH1F, {axisCosPA}); + histos.add("MCCasc/XiPlus/hDCAPosToPV", "hDCAPosToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/XiPlus/hDCANegToPV", "hDCANegToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/XiPlus/hDCABachToPV", "hDCABachToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/XiPlus/hDCAXYCascToPV", "hDCAXYCascToPV", kTH1F, {axisDCAXYCascToPV}); + histos.add("MCCasc/XiPlus/hDCAZCascToPV", "hDCAZCascToPV", kTH1F, {axisDCAZCascToPV}); + histos.add("MCCasc/XiPlus/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("MCCasc/XiPlus/hDCAV0Dau", "hDCAV0Dau", kTH1F, {axisDCAV0Dau}); + histos.add("MCCasc/XiPlus/hDCACascDau", "hDCACascDau", kTH1F, {axisDCACascDau}); + histos.add("MCCasc/XiPlus/hLambdaMass", "hLambdaMass", kTH1F, {axisMassLambda}); + + histos.add("MCCasc/OmegaMinus/h2dpTResolution", "h2dpTResolution", kTH2F, {axisPt, axisPtResolution}); + histos.add("MCCasc/OmegaMinus/h2dMass", "h2dMass", kTH2F, {axisPt, axisOmegaMass}); + histos.add("MCCasc/OmegaMinus/h2dV0TPCSignal", "h2dV0TPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + histos.add("MCCasc/OmegaMinus/h2dBachTPCSignal", "h2dBachTPCSignal", kTH2F, {axisPt, axisTPCSignal}); + histos.add("MCCasc/OmegaMinus/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); + histos.add("MCCasc/OmegaMinus/hCascRadius", "hCascRadius", kTH1F, {axisCascRadius}); + histos.add("MCCasc/OmegaMinus/hV0CosPA", "hV0CosPA", kTH1F, {axisCosPA}); + histos.add("MCCasc/OmegaMinus/hCascCosPA", "hCascCosPA", kTH1F, {axisCosPA}); + histos.add("MCCasc/OmegaMinus/hDCAPosToPV", "hDCAPosToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/OmegaMinus/hDCANegToPV", "hDCANegToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/OmegaMinus/hDCABachToPV", "hDCABachToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/OmegaMinus/hDCAXYCascToPV", "hDCAXYCascToPV", kTH1F, {axisDCAXYCascToPV}); + histos.add("MCCasc/OmegaMinus/hDCAZCascToPV", "hDCAZCascToPV", kTH1F, {axisDCAZCascToPV}); + histos.add("MCCasc/OmegaMinus/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("MCCasc/OmegaMinus/hDCAV0Dau", "hDCAV0Dau", kTH1F, {axisDCAV0Dau}); + histos.add("MCCasc/OmegaMinus/hDCACascDau", "hDCACascDau", kTH1F, {axisDCACascDau}); + histos.add("MCCasc/OmegaMinus/hLambdaMass", "hLambdaMass", kTH1F, {axisMassLambda}); + + histos.add("MCCasc/OmegaPlus/h2dpTResolution", "h2dpTResolution", kTH2F, {axisPt, axisPtResolution}); + histos.add("MCCasc/OmegaPlus/h2dMass", "h2dMass", kTH2F, {axisPt, axisOmegaMass}); + histos.add("MCCasc/OmegaPlus/h2dV0TPCSignal", "h2dV0TPCSignal", kTH2F, {axisPt2, axisTPCSignal}); + histos.add("MCCasc/OmegaPlus/h2dBachTPCSignal", "h2dBachTPCSignal", kTH2F, {axisPt, axisTPCSignal}); + histos.add("MCCasc/OmegaPlus/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); + histos.add("MCCasc/OmegaPlus/hCascRadius", "hCascRadius", kTH1F, {axisCascRadius}); + histos.add("MCCasc/OmegaPlus/hV0CosPA", "hV0CosPA", kTH1F, {axisCosPA}); + histos.add("MCCasc/OmegaPlus/hCascCosPA", "hCascCosPA", kTH1F, {axisCosPA}); + histos.add("MCCasc/OmegaPlus/hDCAPosToPV", "hDCAPosToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/OmegaPlus/hDCANegToPV", "hDCANegToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/OmegaPlus/hDCABachToPV", "hDCABachToPV", kTH1F, {axisDCAToPV}); + histos.add("MCCasc/OmegaPlus/hDCAXYCascToPV", "hDCAXYCascToPV", kTH1F, {axisDCAXYCascToPV}); + histos.add("MCCasc/OmegaPlus/hDCAZCascToPV", "hDCAZCascToPV", kTH1F, {axisDCAZCascToPV}); + histos.add("MCCasc/OmegaPlus/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("MCCasc/OmegaPlus/hDCAV0Dau", "hDCAV0Dau", kTH1F, {axisDCAV0Dau}); + histos.add("MCCasc/OmegaPlus/hDCACascDau", "hDCACascDau", kTH1F, {axisDCACascDau}); + histos.add("MCCasc/OmegaPlus/hLambdaMass", "hLambdaMass", kTH1F, {axisMassLambda}); + + // MC Generated level + histos.add("GenMC/hGenEvents", "hGenEvents", kTH2F, {{axisNch}, {2, -0.5f, +1.5f}}); + histos.get(HIST("GenMC/hGenEvents"))->GetYaxis()->SetBinLabel(1, "All gen. events"); + histos.get(HIST("GenMC/hGenEvents"))->GetYaxis()->SetBinLabel(2, "Gen. with at least 1 rec. events"); + histos.add("GenMC/hGenEventCentrality", "hGenEventCentrality", kTH1F, {{101, 0.0f, 101.0f}}); + histos.add("GenMC/hCentralityVsNcoll_beforeEvSel", "hCentralityVsNcoll_beforeEvSel", kTH2F, {axisCentrality, {50, -0.5f, 49.5f}}); + histos.add("GenMC/hCentralityVsNcoll_afterEvSel", "hCentralityVsNcoll_afterEvSel", kTH2F, {axisCentrality, {50, -0.5f, 49.5f}}); + histos.add("GenMC/hCentralityVsMultMC", "hCentralityVsMultMC", kTH2F, {{101, 0.0f, 101.0f}, axisNch}); + histos.add("GenMC/h2dGenGamma", "h2dGenGamma", kTH2D, {axisCentrality, axisPt}); + histos.add("GenMC/h2dGenK0Short", "h2dGenK0Short", kTH2D, {axisCentrality, axisPt}); + histos.add("GenMC/h2dGenLambda", "h2dGenLambda", kTH2D, {axisCentrality, axisPt}); + histos.add("GenMC/h2dGenAntiLambda", "h2dGenAntiLambda", kTH2D, {axisCentrality, axisPt}); + histos.add("GenMC/h2dGenXiMinus", "h2dGenXiMinus", kTH2D, {axisCentrality, axisPt}); + histos.add("GenMC/h2dGenXiPlus", "h2dGenXiPlus", kTH2D, {axisCentrality, axisPt}); + histos.add("GenMC/h2dGenOmegaMinus", "h2dGenOmegaMinus", kTH2D, {axisCentrality, axisPt}); + histos.add("GenMC/h2dGenOmegaPlus", "h2dGenOmegaPlus", kTH2D, {axisCentrality, axisPt}); + histos.add("GenMC/h2dGenK0ShortVsMultMC_RecoedEvt", "h2dGenK0ShortVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenLambdaVsMultMC_RecoedEvt", "h2dGenLambdaVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenAntiLambdaVsMultMC_RecoedEvt", "h2dGenAntiLambdaVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenXiMinusVsMultMC_RecoedEvt", "h2dGenXiMinusVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenXiPlusVsMultMC_RecoedEvt", "h2dGenXiPlusVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenOmegaMinusVsMultMC_RecoedEvt", "h2dGenOmegaMinusVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenOmegaPlusVsMultMC_RecoedEvt", "h2dGenOmegaPlusVsMultMC_RecoedEvt", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenGammaVsMultMC", "h2dGenGammaVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenK0ShortVsMultMC", "h2dGenK0ShortVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenLambdaVsMultMC", "h2dGenLambdaVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenAntiLambdaVsMultMC", "h2dGenAntiLambdaVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenXiMinusVsMultMC", "h2dGenXiMinusVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenXiPlusVsMultMC", "h2dGenXiPlusVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenOmegaMinusVsMultMC", "h2dGenOmegaMinusVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("GenMC/h2dGenOmegaPlusVsMultMC", "h2dGenOmegaPlusVsMultMC", kTH2D, {axisNch, axisPt}); + } + + template + bool IsEventAccepted(TCollision collision) + // check whether the collision passes our collision selections + { + if (eventSelections.requireSel8 && !collision.sel8()) { + return false; + } + if (eventSelections.requireTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + if (eventSelections.rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + if (eventSelections.rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (std::abs(collision.posZ()) > eventSelections.maxZVtxPosition) { + return false; + } + if (eventSelections.requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + if (eventSelections.requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if (eventSelections.requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if (eventSelections.requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + return false; + } + if (eventSelections.rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + if (eventSelections.requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + if (eventSelections.requireNoCollInTimeRangeStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + return false; + } + if (eventSelections.requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; + } + if (eventSelections.requireNoCollInROFStd && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + if (eventSelections.requireNoCollInROFStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; + } + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && collision.multNTracksPVeta1() < 1) { + return false; + } + if (eventSelections.requireINEL1 && collision.multNTracksPVeta1() < 2) { + return false; + } + } else { // we are in Pb-Pb + float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + if (eventSelections.minOccupancy >= 0 && collisionOccupancy < eventSelections.minOccupancy) { + return false; + } + if (eventSelections.maxOccupancy >= 0 && collisionOccupancy > eventSelections.maxOccupancy) { + return false; + } + } + + return true; + } + + // ______________________________________________________ + // Simulated processing + // Return the list of indices to the recoed collision associated to a given MC collision. + std::vector getListOfRecoCollIndices(soa::Join const& mcCollisions, soa::Join const& collisions) + { + std::vector listBestCollisionIdx(mcCollisions.size()); + for (auto const& mcCollision : mcCollisions) { + auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex()); + // Find the collision with the biggest nbr of PV contributors + // Follows what was done here: https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/mcCollsExtra.cxx#L93 + int biggestNContribs = -1; + int bestCollisionIndex = -1; + for (auto const& collision : groupedCollisions) { + if (biggestNContribs < collision.multPVTotalContributors()) { + biggestNContribs = collision.multPVTotalContributors(); + bestCollisionIndex = collision.globalIndex(); + } + } + listBestCollisionIdx[mcCollision.globalIndex()] = bestCollisionIndex; + } + return listBestCollisionIdx; + } + + // ______________________________________________________ + // Simulated processing + // Fill generated event information (for event loss/splitting estimation) + void fillGeneratedEventProperties(soa::Join const& mcCollisions, soa::Join const& collisions) + { + std::vector listBestCollisionIdx(mcCollisions.size()); + for (auto const& mcCollision : mcCollisions) { + histos.fill(HIST("GenMC/hGenEvents"), mcCollision.multMCNParticlesEta05(), 0 /* all gen. events*/); + + auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex()); + // Check if there is at least one of the reconstructed collisions associated to this MC collision + // If so, we consider it + bool atLeastOne = false; + int biggestNContribs = -1; + float centrality = 100.5f; + int nCollisions = 0; + for (auto const& collision : groupedCollisions) { + + if (!IsEventAccepted(collision)) { + continue; + } + + if (biggestNContribs < collision.multPVTotalContributors()) { + biggestNContribs = collision.multPVTotalContributors(); + centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + } + nCollisions++; + + atLeastOne = true; + } + + histos.fill(HIST("GenMC/hCentralityVsNcoll_beforeEvSel"), centrality, groupedCollisions.size()); + histos.fill(HIST("GenMC/hCentralityVsNcoll_afterEvSel"), centrality, nCollisions); + histos.fill(HIST("GenMC/hCentralityVsMultMC"), centrality, mcCollision.multMCNParticlesEta05()); + + if (atLeastOne) { + histos.fill(HIST("GenMC/hGenEvents"), mcCollision.multMCNParticlesEta05(), 1 /* at least 1 rec. event*/); + histos.fill(HIST("GenMC/hGenEventCentrality"), centrality); + } + } + return; + } + + void processDerivedV0s(StrCollisionsDatas::iterator const& coll, V0DerivedDatas const& V0s, dauTracks const&) + { + // Event Level + float centrality = coll.centFT0C(); + histos.fill(HIST("Event/hPosZ"), coll.posZ()); + histos.fill(HIST("Event/hEventProperties"), 0. /* all collisions */); + + if (coll.sel8()) + histos.fill(HIST("Event/hEventProperties"), 1.); + if (coll.selection_bit(aod::evsel::kIsTriggerTVX)) + histos.fill(HIST("Event/hEventProperties"), 2.); + if (coll.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) + histos.fill(HIST("Event/hEventProperties"), 3.); + if (coll.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) + histos.fill(HIST("Event/hEventProperties"), 4.); + if (coll.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) + histos.fill(HIST("Event/hEventProperties"), 5.); + if (coll.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) + histos.fill(HIST("Event/hEventProperties"), 6.); + if (coll.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) + histos.fill(HIST("Event/hEventProperties"), 7.); + if (coll.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) + histos.fill(HIST("Event/hEventProperties"), 8.); + if (coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + histos.fill(HIST("Event/hEventProperties"), 9.); + if (coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) + histos.fill(HIST("Event/hEventProperties"), 10.); + if (coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) + histos.fill(HIST("Event/hEventProperties"), 11.); + if (coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) + histos.fill(HIST("Event/hEventProperties"), 12.); + if (coll.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) + histos.fill(HIST("Event/hEventProperties"), 13.); + if (coll.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) + histos.fill(HIST("Event/hEventProperties"), 14.); + + histos.fill(HIST("Event/hft0cOccupancyInTimeRange"), coll.ft0cOccupancyInTimeRange()); + histos.fill(HIST("Event/htrackOccupancyInTimeRange"), coll.trackOccupancyInTimeRange()); + histos.fill(HIST("Event/h2dMultFT0C"), centrality, coll.multFT0C()); + histos.fill(HIST("Event/h2dMultNTracksPVeta1"), centrality, coll.multNTracksPVeta1()); + histos.fill(HIST("Event/h2dMultPVTotalContributors"), centrality, coll.multPVTotalContributors()); + histos.fill(HIST("Event/h2dMultAllTracksTPCOnly"), centrality, coll.multAllTracksTPCOnly()); + histos.fill(HIST("Event/h2dMultAllTracksITSTPC"), centrality, coll.multAllTracksITSTPC()); + histos.fill(HIST("Event/h2dNumV0sPerColl"), centrality, V0s.size()); + + for (auto const& v0 : V0s) { + + // V0-Level + float V0Y_Gamma = RecoDecay::y(std::array{v0.px(), v0.py(), v0.pz()}, o2::constants::physics::MassGamma); + float V0Y_Lambda = RecoDecay::y(std::array{v0.px(), v0.py(), v0.pz()}, o2::constants::physics::MassLambda); + float V0Y_K0Short = RecoDecay::y(std::array{v0.px(), v0.py(), v0.pz()}, o2::constants::physics::MassK0Short); + + float pT = v0.pt(); + histos.fill(HIST("V0/hpT"), pT); + histos.fill(HIST("V0/h2dArmenterosP"), v0.alpha(), v0.qtarm()); + histos.fill(HIST("V0/hRadius"), v0.v0radius()); + histos.fill(HIST("V0/hZ"), v0.z()); + histos.fill(HIST("V0/hCosPA"), v0.v0cosPA()); + histos.fill(HIST("V0/hdcaDau"), v0.dcaV0daughters()); + histos.fill(HIST("V0/hdcaNegtopv"), v0.dcanegtopv()); + histos.fill(HIST("V0/hdcaPostopv"), v0.dcapostopv()); + histos.fill(HIST("V0/h2dEtaPhi"), v0.eta(), RecoDecay::phi(v0.px(), v0.py())); + histos.fill(HIST("V0/hYGamma"), V0Y_Gamma); + histos.fill(HIST("V0/hYLambda"), V0Y_Lambda); + histos.fill(HIST("V0/hYK0Short"), V0Y_K0Short); + histos.fill(HIST("V0/hMassGamma"), v0.mGamma()); + histos.fill(HIST("V0/hMassLambda"), v0.mLambda()); + histos.fill(HIST("V0/hMassK0Short"), v0.mK0Short()); + histos.fill(HIST("V0/hV0Type"), v0.v0Type()); + histos.fill(HIST("V0/h2dV0Indices"), v0.straCollisionId(), coll.globalIndex()); // cross-check index correctness + + // Track-level + auto posTrack = v0.template posTrackExtra_as(); + auto negTrack = v0.template negTrackExtra_as(); + + uint8_t positiveTrackCode = ((uint8_t(posTrack.hasTPC()) << hasTPC) | + (uint8_t(posTrack.hasITSTracker()) << hasITSTracker) | + (uint8_t(posTrack.hasITSAfterburner()) << hasITSAfterburner) | + (uint8_t(posTrack.hasTRD()) << hasTRD) | + (uint8_t(posTrack.hasTOF()) << hasTOF)); + + uint8_t negativeTrackCode = ((uint8_t(negTrack.hasTPC()) << hasTPC) | + (uint8_t(negTrack.hasITSTracker()) << hasITSTracker) | + (uint8_t(negTrack.hasITSAfterburner()) << hasITSAfterburner) | + (uint8_t(negTrack.hasTRD()) << hasTRD) | + (uint8_t(negTrack.hasTOF()) << hasTOF)); + + histos.fill(HIST("V0/Track/h2dITSNCls"), v0.positivept(), posTrack.itsNCls()); + histos.fill(HIST("V0/Track/h2dITSNCls"), -1 * v0.negativept(), negTrack.itsNCls()); + histos.fill(HIST("V0/Track/h2dITSChi2PerNcl"), v0.positivept(), posTrack.itsChi2PerNcl()); + histos.fill(HIST("V0/Track/h2dITSChi2PerNcl"), -1 * v0.negativept(), negTrack.itsChi2PerNcl()); + histos.fill(HIST("V0/Track/h2dTPCCrossedRows"), v0.positivept(), posTrack.tpcCrossedRows()); + histos.fill(HIST("V0/Track/h2dTPCCrossedRows"), -1 * v0.negativept(), negTrack.tpcCrossedRows()); + histos.fill(HIST("V0/Track/hTrackCode"), positiveTrackCode); // pos track info + histos.fill(HIST("V0/Track/hTrackCode"), negativeTrackCode); // neg track info + histos.fill(HIST("V0/Track/h3dTrackPropertiesVspT"), positiveTrackCode, negativeTrackCode, pT); // tracking complete info + histos.fill(HIST("V0/Track/h2dPosTrackProperties"), positiveTrackCode, v0.positivept()); // pos track info + histos.fill(HIST("V0/Track/h2dNegTrackProperties"), negativeTrackCode, v0.negativept()); // neg track info + + // PID (TPC) + histos.fill(HIST("V0/PID/h2dTPCNSigmaEl"), v0.positivept(), posTrack.tpcNSigmaEl()); + histos.fill(HIST("V0/PID/h2dTPCNSigmaEl"), -1 * v0.negativept(), negTrack.tpcNSigmaEl()); + histos.fill(HIST("V0/PID/h2dTPCNSigmaPr"), v0.positivept(), posTrack.tpcNSigmaPr()); + histos.fill(HIST("V0/PID/h2dTPCNSigmaPr"), -1 * v0.negativept(), negTrack.tpcNSigmaPr()); + histos.fill(HIST("V0/PID/h2dTPCNSigmaPi"), v0.positivept(), posTrack.tpcNSigmaPi()); + histos.fill(HIST("V0/PID/h2dTPCNSigmaPi"), -1 * v0.negativept(), negTrack.tpcNSigmaPi()); + histos.fill(HIST("V0/PID/h2dTPCSignal"), v0.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("V0/PID/h2dTPCSignal"), -1 * v0.negativept(), negTrack.tpcSignal()); + + // PID (TOF) + histos.fill(HIST("V0/PID/h2dTOFNSigmaLaPr"), pT, v0.tofNSigmaLaPr()); + histos.fill(HIST("V0/PID/h2dTOFNSigmaLaPi"), pT, v0.tofNSigmaLaPi()); + histos.fill(HIST("V0/PID/h2dposTOFDeltaTLaPr"), pT, v0.posTOFDeltaTLaPr()); + histos.fill(HIST("V0/PID/h2dnegTOFDeltaTLaPi"), pT, v0.negTOFDeltaTLaPi()); + histos.fill(HIST("V0/PID/h2dnegTOFDeltaTLaPr"), pT, v0.negTOFDeltaTLaPr()); + histos.fill(HIST("V0/PID/h2dposTOFDeltaTLaPi"), pT, v0.posTOFDeltaTLaPi()); + histos.fill(HIST("V0/PID/h2dTOFNSigmaALaPr"), pT, v0.tofNSigmaALaPr()); + histos.fill(HIST("V0/PID/h2dTOFNSigmaALaPi"), pT, v0.tofNSigmaALaPi()); + + histos.fill(HIST("V0/PID/h2dTOFNSigmaK0PiPlus"), pT, v0.tofNSigmaK0PiPlus()); + histos.fill(HIST("V0/PID/h2dTOFNSigmaK0PiMinus"), pT, v0.tofNSigmaK0PiMinus()); + + // PID TPC + TOF + histos.fill(HIST("V0/PID/h3dTPCVsTOFNSigmaLaPr"), posTrack.tpcNSigmaPr(), v0.tofNSigmaLaPr(), v0.positivept()); + histos.fill(HIST("V0/PID/h3dTPCVsTOFNSigmaLaPi"), negTrack.tpcNSigmaPi(), v0.tofNSigmaLaPi(), v0.negativept()); + } + } + + void processMCDerivedV0s(V0DerivedMCDatas const& V0s, dauTracks const&, aod::MotherMCParts const&, soa::Join const&) + { + for (auto const& v0 : V0s) { + histos.fill(HIST("MCV0/hv0MCCore"), v0.has_v0MCCore()); + if (!v0.has_v0MCCore()) + continue; + + auto v0MC = v0.v0MCCore_as>(); + + // General + histos.fill(HIST("MCV0/h2dPDGV0VsMother"), v0MC.pdgCode(), v0MC.pdgCodeMother()); + histos.fill(HIST("MCV0/h2dPDGV0VsPositive"), v0MC.pdgCode(), v0MC.pdgCodePositive()); + histos.fill(HIST("MCV0/h2dPDGV0VsNegative"), v0MC.pdgCode(), v0MC.pdgCodeNegative()); + histos.fill(HIST("MCV0/h2dPDGV0VsIsPhysicalPrimary"), v0MC.pdgCode(), v0MC.isPhysicalPrimary()); + + // Track-level + auto posTrack = v0.template posTrackExtra_as(); + auto negTrack = v0.template negTrackExtra_as(); + + // Specific analysis by species: + if (v0MC.pdgCode() == 22) { // IsGamma + histos.fill(HIST("MCV0/h2dArmenterosP"), v0.alpha(), v0.qtarm()); + histos.fill(HIST("MCV0/Gamma/h2dpTResolution"), v0.pt(), v0.pt() - v0MC.ptMC()); + histos.fill(HIST("MCV0/Gamma/h2dMass"), v0.pt(), v0.mGamma()); + histos.fill(HIST("MCV0/Gamma/h2dTPCNSigmaEl"), v0.positivept(), posTrack.tpcNSigmaEl()); + histos.fill(HIST("MCV0/Gamma/h2dTPCNSigmaEl"), -1 * v0.negativept(), negTrack.tpcNSigmaEl()); + histos.fill(HIST("MCV0/Gamma/h2dTPCSignal"), v0.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("MCV0/Gamma/h2dTPCSignal"), -1 * v0.negativept(), negTrack.tpcSignal()); + histos.fill(HIST("MCV0/Gamma/hRadius"), v0.v0radius()); + histos.fill(HIST("MCV0/Gamma/hCosPA"), v0.v0cosPA()); + histos.fill(HIST("MCV0/Gamma/hdcaDau"), v0.dcaV0daughters()); + histos.fill(HIST("MCV0/Gamma/hdcaNegtopv"), v0.dcanegtopv()); + histos.fill(HIST("MCV0/Gamma/hdcaPostopv"), v0.dcapostopv()); + histos.fill(HIST("MCV0/Gamma/hZ"), v0.z()); + } + if (v0MC.pdgCode() == 3122) { // IsLambda + histos.fill(HIST("MCV0/h2dArmenterosP"), v0.alpha(), v0.qtarm()); + histos.fill(HIST("MCV0/Lambda/h2dpTResolution"), v0.pt(), v0.pt() - v0MC.ptMC()); + histos.fill(HIST("MCV0/Lambda/h2dMass"), v0.pt(), v0.mLambda()); + histos.fill(HIST("MCV0/Lambda/h2dTPCNSigmaPr"), v0.positivept(), posTrack.tpcNSigmaPr()); + histos.fill(HIST("MCV0/Lambda/h2dTPCNSigmaPi"), v0.negativept(), negTrack.tpcNSigmaPi()); + histos.fill(HIST("MCV0/Lambda/h2dTPCSignal"), v0.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("MCV0/Lambda/h2dTPCSignal"), -1 * v0.negativept(), negTrack.tpcSignal()); + histos.fill(HIST("MCV0/Lambda/hRadius"), v0.v0radius()); + histos.fill(HIST("MCV0/Lambda/hCosPA"), v0.v0cosPA()); + histos.fill(HIST("MCV0/Lambda/hdcaDau"), v0.dcaV0daughters()); + histos.fill(HIST("MCV0/Lambda/hdcaNegtopv"), v0.dcanegtopv()); + histos.fill(HIST("MCV0/Lambda/hdcaPostopv"), v0.dcapostopv()); + } + if (v0MC.pdgCode() == -3122) { // IsAntiLambda + histos.fill(HIST("MCV0/h2dArmenterosP"), v0.alpha(), v0.qtarm()); + histos.fill(HIST("MCV0/AntiLambda/h2dpTResolution"), v0.pt(), v0.pt() - v0MC.ptMC()); + histos.fill(HIST("MCV0/AntiLambda/h2dMass"), v0.pt(), v0.mAntiLambda()); + histos.fill(HIST("MCV0/AntiLambda/h2dTPCNSigmaPr"), v0.negativept(), negTrack.tpcNSigmaPr()); + histos.fill(HIST("MCV0/AntiLambda/h2dTPCNSigmaPi"), v0.positivept(), posTrack.tpcNSigmaPi()); + histos.fill(HIST("MCV0/AntiLambda/h2dTPCSignal"), v0.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("MCV0/AntiLambda/h2dTPCSignal"), -1 * v0.negativept(), negTrack.tpcSignal()); + histos.fill(HIST("MCV0/AntiLambda/hRadius"), v0.v0radius()); + histos.fill(HIST("MCV0/AntiLambda/hCosPA"), v0.v0cosPA()); + histos.fill(HIST("MCV0/AntiLambda/hdcaDau"), v0.dcaV0daughters()); + histos.fill(HIST("MCV0/AntiLambda/hdcaNegtopv"), v0.dcanegtopv()); + histos.fill(HIST("MCV0/AntiLambda/hdcaPostopv"), v0.dcapostopv()); + } + if (v0MC.pdgCode() == 310) { // IsK0Short + histos.fill(HIST("MCV0/h2dArmenterosP"), v0.alpha(), v0.qtarm()); + histos.fill(HIST("MCV0/K0Short/h2dpTResolution"), v0.pt(), v0.pt() - v0MC.ptMC()); + histos.fill(HIST("MCV0/K0Short/h2dMass"), v0.pt(), v0.mK0Short()); + histos.fill(HIST("MCV0/K0Short/h2dTPCNSigmaPi"), v0.positivept(), posTrack.tpcNSigmaPi()); + histos.fill(HIST("MCV0/K0Short/h2dTPCNSigmaPi"), -1 * v0.negativept(), negTrack.tpcNSigmaPi()); + histos.fill(HIST("MCV0/K0Short/h2dTPCSignal"), v0.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("MCV0/K0Short/h2dTPCSignal"), -1 * v0.negativept(), negTrack.tpcSignal()); + histos.fill(HIST("MCV0/K0Short/hRadius"), v0.v0radius()); + histos.fill(HIST("MCV0/K0Short/hCosPA"), v0.v0cosPA()); + histos.fill(HIST("MCV0/K0Short/hdcaDau"), v0.dcaV0daughters()); + histos.fill(HIST("MCV0/K0Short/hdcaNegtopv"), v0.dcanegtopv()); + histos.fill(HIST("MCV0/K0Short/hdcaPostopv"), v0.dcapostopv()); + } + } + } + + void processDerivedCascades(StrCollisionsDatas::iterator const& coll, CascDerivedDatas const& Cascades, dauTracks const&) + { + for (auto& casc : Cascades) { + // Cascade level + float pT = casc.pt(); + histos.fill(HIST("Casc/Sign"), casc.sign()); + histos.fill(HIST("Casc/hpT"), pT); + histos.fill(HIST("Casc/hV0Radius"), casc.v0radius()); + histos.fill(HIST("Casc/hCascRadius"), casc.cascradius()); + histos.fill(HIST("Casc/hV0CosPA"), casc.v0cosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("Casc/hCascCosPA"), casc.casccosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("Casc/hDCAPosToPV"), casc.dcapostopv()); + histos.fill(HIST("Casc/hDCANegToPV"), casc.dcanegtopv()); + histos.fill(HIST("Casc/hDCABachToPV"), casc.dcabachtopv()); + histos.fill(HIST("Casc/hDCAXYCascToPV"), casc.dcaXYCascToPV()); + histos.fill(HIST("Casc/hDCAZCascToPV"), casc.dcaZCascToPV()); + histos.fill(HIST("Casc/hDCAV0ToPV"), casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())); + histos.fill(HIST("Casc/hDCAV0Dau"), casc.dcaV0daughters()); + histos.fill(HIST("Casc/hDCACascDau"), casc.dcacascdaughters()); + histos.fill(HIST("Casc/hLambdaMass"), casc.mLambda()); + + // Track level + auto negTrack = casc.template negTrackExtra_as(); + auto posTrack = casc.template posTrackExtra_as(); + auto bachTrack = casc.template bachTrackExtra_as(); + + uint8_t positiveTrackCode = ((uint8_t(posTrack.hasTPC()) << hasTPC) | + (uint8_t(posTrack.hasITSTracker()) << hasITSTracker) | + (uint8_t(posTrack.hasITSAfterburner()) << hasITSAfterburner) | + (uint8_t(posTrack.hasTRD()) << hasTRD) | + (uint8_t(posTrack.hasTOF()) << hasTOF)); + + uint8_t negativeTrackCode = ((uint8_t(negTrack.hasTPC()) << hasTPC) | + (uint8_t(negTrack.hasITSTracker()) << hasITSTracker) | + (uint8_t(negTrack.hasITSAfterburner()) << hasITSAfterburner) | + (uint8_t(negTrack.hasTRD()) << hasTRD) | + (uint8_t(negTrack.hasTOF()) << hasTOF)); + + uint8_t bachTrackCode = ((uint8_t(bachTrack.hasTPC()) << hasTPC) | + (uint8_t(bachTrack.hasITSTracker()) << hasITSTracker) | + (uint8_t(bachTrack.hasITSAfterburner()) << hasITSAfterburner) | + (uint8_t(bachTrack.hasTRD()) << hasTRD) | + (uint8_t(bachTrack.hasTOF()) << hasTOF)); + + histos.fill(HIST("Casc/Track/h3dTrackProperties"), positiveTrackCode, negativeTrackCode, bachTrackCode); // complete tracking info + histos.fill(HIST("Casc/Track/h2dPosTrackProperties"), positiveTrackCode, casc.positivept()); // positive track info + histos.fill(HIST("Casc/Track/h2dNegTrackProperties"), negativeTrackCode, casc.negativept()); // negative track info + histos.fill(HIST("Casc/Track/h2dBachTrackProperties"), bachTrackCode, casc.bachelorpt()); // bach track info + histos.fill(HIST("Casc/Track/h2dV0ITSChi2PerNcl"), casc.positivept(), posTrack.itsChi2PerNcl()); + histos.fill(HIST("Casc/Track/h2dV0ITSChi2PerNcl"), -1 * casc.negativept(), negTrack.itsChi2PerNcl()); + histos.fill(HIST("Casc/Track/h2dV0TPCCrossedRows"), casc.positivept(), posTrack.tpcCrossedRows()); + histos.fill(HIST("Casc/Track/h2dV0TPCCrossedRows"), -1 * casc.negativept(), negTrack.tpcCrossedRows()); + histos.fill(HIST("Casc/Track/h2dV0ITSNCls"), casc.positivept(), posTrack.itsNCls()); + histos.fill(HIST("Casc/Track/h2dV0ITSNCls"), -1 * casc.negativept(), negTrack.itsNCls()); + + // PID (TPC) + histos.fill(HIST("Casc/PID/h2dV0TPCNSigmaPr"), casc.positivept(), posTrack.tpcNSigmaPr()); + histos.fill(HIST("Casc/PID/h2dV0TPCNSigmaPr"), -1 * casc.negativept(), negTrack.tpcNSigmaPr()); + histos.fill(HIST("Casc/PID/h2dV0TPCNSigmaPi"), casc.positivept(), posTrack.tpcNSigmaPi()); + histos.fill(HIST("Casc/PID/h2dV0TPCNSigmaPi"), -1 * casc.negativept(), negTrack.tpcNSigmaPi()); + histos.fill(HIST("Casc/PID/h2dV0TPCSignal"), casc.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("Casc/PID/h2dV0TPCSignal"), -1 * casc.negativept(), negTrack.tpcSignal()); + + // PID (TOF) + histos.fill(HIST("Casc/PID/h2dTOFNSigmaXiLaPi"), pT, casc.tofNSigmaXiLaPi()); //! meson track NSigma from pion <- lambda <- xi expectation + histos.fill(HIST("Casc/PID/h2dTOFNSigmaXiLaPr"), pT, casc.tofNSigmaXiLaPr()); //! baryon track NSigma from proton <- lambda <- xi expectation + histos.fill(HIST("Casc/PID/h2dTOFNSigmaXiPi"), pT, casc.tofNSigmaXiPi()); //! bachelor track NSigma from pion <- xi expectation + histos.fill(HIST("Casc/PID/h2dTOFNSigmaOmLaPi"), pT, casc.tofNSigmaOmLaPi()); //! meson track NSigma from pion <- lambda <- om expectation + histos.fill(HIST("Casc/PID/h2dTOFNSigmaOmLaPr"), pT, casc.tofNSigmaOmLaPr()); //! baryon track NSigma from proton <- lambda <- om expectation + histos.fill(HIST("Casc/PID/h2dTOFNSigmaOmKa"), pT, casc.tofNSigmaOmKa()); //! bachelor track NSigma from kaon <- om expectation + + // By particle species + if (casc.sign() < 0) { + histos.fill(HIST("Casc/hMassXiMinus"), casc.mXi()); + histos.fill(HIST("Casc/hMassOmegaMinus"), casc.mOmega()); + histos.fill(HIST("Casc/Track/h2dBachITSNCls"), -1 * casc.bachelorpt(), bachTrack.itsNCls()); + histos.fill(HIST("Casc/Track/h2dBachITSChi2PerNcl"), -1 * casc.bachelorpt(), bachTrack.itsChi2PerNcl()); + histos.fill(HIST("Casc/Track/h2dBachTPCCrossedRows"), -1 * casc.bachelorpt(), bachTrack.tpcCrossedRows()); + histos.fill(HIST("Casc/PID/h2dBachTPCSignal"), -1 * casc.bachelorpt(), bachTrack.tpcSignal()); + } else { + histos.fill(HIST("Casc/hMassXiPlus"), casc.mXi()); + histos.fill(HIST("Casc/hMassOmegaPlus"), casc.mOmega()); + histos.fill(HIST("Casc/Track/h2dBachITSNCls"), casc.bachelorpt(), bachTrack.itsNCls()); + histos.fill(HIST("Casc/Track/h2dBachITSChi2PerNcl"), casc.bachelorpt(), bachTrack.itsChi2PerNcl()); + histos.fill(HIST("Casc/Track/h2dBachTPCCrossedRows"), casc.bachelorpt(), bachTrack.tpcCrossedRows()); + histos.fill(HIST("Casc/PID/h2dBachTPCSignal"), casc.bachelorpt(), bachTrack.tpcSignal()); + } + } + } + + void processMCDerivedCascades(StrCollisionsDatas::iterator const& coll, CascDerivedMCDatas const& Cascades, dauTracks const&, soa::Join const&) + { + for (auto& casc : Cascades) { + + float pT = casc.pt(); + histos.fill(HIST("MCCasc/hcascMCCore"), casc.has_cascMCCore()); + if (!casc.has_cascMCCore()) + continue; + auto cascMC = casc.cascMCCore_as>(); + + // General + histos.fill(HIST("MCCasc/h2dPDGV0VsMother"), cascMC.pdgCode(), cascMC.pdgCodeMother()); + histos.fill(HIST("MCCasc/h2dPDGV0VsPositive"), cascMC.pdgCode(), cascMC.pdgCodePositive()); + histos.fill(HIST("MCCasc/h2dPDGV0VsNegative"), cascMC.pdgCode(), cascMC.pdgCodeNegative()); + histos.fill(HIST("MCCasc/h2dPDGV0VsBach"), cascMC.pdgCode(), cascMC.pdgCodeBachelor()); + histos.fill(HIST("MCCasc/h2dPDGV0VsIsPhysicalPrimary"), cascMC.pdgCode(), cascMC.isPhysicalPrimary()); + + // Track level + auto negTrack = casc.template negTrackExtra_as(); + auto posTrack = casc.template posTrackExtra_as(); + auto bachTrack = casc.template bachTrackExtra_as(); + + // Specific analysis by species: + if (cascMC.pdgCode() == 3312) { // XiMinus + histos.fill(HIST("MCCasc/XiMinus/h2dpTResolution"), pT, pT - cascMC.ptMC()); + histos.fill(HIST("MCCasc/XiMinus/h2dMass"), pT, casc.mXi()); + histos.fill(HIST("MCCasc/XiMinus/h2dV0TPCSignal"), casc.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("MCCasc/XiMinus/h2dV0TPCSignal"), -1 * casc.negativept(), negTrack.tpcSignal()); + histos.fill(HIST("MCCasc/XiMinus/h2dBachTPCSignal"), casc.bachelorpt(), bachTrack.tpcSignal()); + histos.fill(HIST("MCCasc/XiMinus/hV0Radius"), casc.v0radius()); + histos.fill(HIST("MCCasc/XiMinus/hCascRadius"), casc.cascradius()); + histos.fill(HIST("MCCasc/XiMinus/hV0CosPA"), casc.v0cosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("MCCasc/XiMinus/hCascCosPA"), casc.casccosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("MCCasc/XiMinus/hDCAPosToPV"), casc.dcapostopv()); + histos.fill(HIST("MCCasc/XiMinus/hDCANegToPV"), casc.dcanegtopv()); + histos.fill(HIST("MCCasc/XiMinus/hDCABachToPV"), casc.dcabachtopv()); + histos.fill(HIST("MCCasc/XiMinus/hDCAXYCascToPV"), casc.dcaXYCascToPV()); + histos.fill(HIST("MCCasc/XiMinus/hDCAZCascToPV"), casc.dcaZCascToPV()); + histos.fill(HIST("MCCasc/XiMinus/hDCAV0ToPV"), casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())); + histos.fill(HIST("MCCasc/XiMinus/hDCAV0Dau"), casc.dcaV0daughters()); + histos.fill(HIST("MCCasc/XiMinus/hDCACascDau"), casc.dcacascdaughters()); + histos.fill(HIST("MCCasc/XiMinus/hLambdaMass"), casc.mLambda()); + } + if (cascMC.pdgCode() == -3312) { // XiPlus + histos.fill(HIST("MCCasc/XiPlus/h2dpTResolution"), pT, pT - cascMC.ptMC()); + histos.fill(HIST("MCCasc/XiPlus/h2dMass"), pT, casc.mXi()); + histos.fill(HIST("MCCasc/XiPlus/h2dV0TPCSignal"), casc.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("MCCasc/XiPlus/h2dV0TPCSignal"), -1 * casc.negativept(), negTrack.tpcSignal()); + histos.fill(HIST("MCCasc/XiPlus/h2dBachTPCSignal"), casc.bachelorpt(), bachTrack.tpcSignal()); + histos.fill(HIST("MCCasc/XiPlus/hV0Radius"), casc.v0radius()); + histos.fill(HIST("MCCasc/XiPlus/hCascRadius"), casc.cascradius()); + histos.fill(HIST("MCCasc/XiPlus/hV0CosPA"), casc.v0cosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("MCCasc/XiPlus/hCascCosPA"), casc.casccosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("MCCasc/XiPlus/hDCAPosToPV"), casc.dcapostopv()); + histos.fill(HIST("MCCasc/XiPlus/hDCANegToPV"), casc.dcanegtopv()); + histos.fill(HIST("MCCasc/XiPlus/hDCABachToPV"), casc.dcabachtopv()); + histos.fill(HIST("MCCasc/XiPlus/hDCAXYCascToPV"), casc.dcaXYCascToPV()); + histos.fill(HIST("MCCasc/XiPlus/hDCAZCascToPV"), casc.dcaZCascToPV()); + histos.fill(HIST("MCCasc/XiPlus/hDCAV0ToPV"), casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())); + histos.fill(HIST("MCCasc/XiPlus/hDCAV0Dau"), casc.dcaV0daughters()); + histos.fill(HIST("MCCasc/XiPlus/hDCACascDau"), casc.dcacascdaughters()); + histos.fill(HIST("MCCasc/XiPlus/hLambdaMass"), casc.mLambda()); + } + if (cascMC.pdgCode() == 3334) { // OmegaMinus + histos.fill(HIST("MCCasc/OmegaMinus/h2dpTResolution"), pT, pT - cascMC.ptMC()); + histos.fill(HIST("MCCasc/OmegaMinus/h2dMass"), pT, casc.mOmega()); + histos.fill(HIST("MCCasc/OmegaMinus/h2dV0TPCSignal"), casc.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("MCCasc/OmegaMinus/h2dV0TPCSignal"), -1 * casc.negativept(), negTrack.tpcSignal()); + histos.fill(HIST("MCCasc/OmegaMinus/h2dBachTPCSignal"), casc.bachelorpt(), bachTrack.tpcSignal()); + histos.fill(HIST("MCCasc/OmegaMinus/hV0Radius"), casc.v0radius()); + histos.fill(HIST("MCCasc/OmegaMinus/hCascRadius"), casc.cascradius()); + histos.fill(HIST("MCCasc/OmegaMinus/hV0CosPA"), casc.v0cosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("MCCasc/OmegaMinus/hCascCosPA"), casc.casccosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("MCCasc/OmegaMinus/hDCAPosToPV"), casc.dcapostopv()); + histos.fill(HIST("MCCasc/OmegaMinus/hDCANegToPV"), casc.dcanegtopv()); + histos.fill(HIST("MCCasc/OmegaMinus/hDCABachToPV"), casc.dcabachtopv()); + histos.fill(HIST("MCCasc/OmegaMinus/hDCAXYCascToPV"), casc.dcaXYCascToPV()); + histos.fill(HIST("MCCasc/OmegaMinus/hDCAZCascToPV"), casc.dcaZCascToPV()); + histos.fill(HIST("MCCasc/OmegaMinus/hDCAV0ToPV"), casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())); + histos.fill(HIST("MCCasc/OmegaMinus/hDCAV0Dau"), casc.dcaV0daughters()); + histos.fill(HIST("MCCasc/OmegaMinus/hDCACascDau"), casc.dcacascdaughters()); + histos.fill(HIST("MCCasc/OmegaMinus/hLambdaMass"), casc.mLambda()); + } + if (cascMC.pdgCode() == -3334) { // OmegaPlus + histos.fill(HIST("MCCasc/OmegaPlus/h2dpTResolution"), pT, pT - cascMC.ptMC()); + histos.fill(HIST("MCCasc/OmegaPlus/h2dMass"), pT, casc.mOmega()); + histos.fill(HIST("MCCasc/OmegaPlus/h2dV0TPCSignal"), casc.positivept(), posTrack.tpcSignal()); + histos.fill(HIST("MCCasc/OmegaPlus/h2dV0TPCSignal"), -1 * casc.negativept(), negTrack.tpcSignal()); + histos.fill(HIST("MCCasc/OmegaPlus/h2dBachTPCSignal"), casc.bachelorpt(), bachTrack.tpcSignal()); + histos.fill(HIST("MCCasc/OmegaPlus/hV0Radius"), casc.v0radius()); + histos.fill(HIST("MCCasc/OmegaPlus/hCascRadius"), casc.cascradius()); + histos.fill(HIST("MCCasc/OmegaPlus/hV0CosPA"), casc.v0cosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("MCCasc/OmegaPlus/hCascCosPA"), casc.casccosPA(casc.x(), casc.y(), casc.z())); + histos.fill(HIST("MCCasc/OmegaPlus/hDCAPosToPV"), casc.dcapostopv()); + histos.fill(HIST("MCCasc/OmegaPlus/hDCANegToPV"), casc.dcanegtopv()); + histos.fill(HIST("MCCasc/OmegaPlus/hDCABachToPV"), casc.dcabachtopv()); + histos.fill(HIST("MCCasc/OmegaPlus/hDCAXYCascToPV"), casc.dcaXYCascToPV()); + histos.fill(HIST("MCCasc/OmegaPlus/hDCAZCascToPV"), casc.dcaZCascToPV()); + histos.fill(HIST("MCCasc/OmegaPlus/hDCAV0ToPV"), casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())); + histos.fill(HIST("MCCasc/OmegaPlus/hDCAV0Dau"), casc.dcaV0daughters()); + histos.fill(HIST("MCCasc/OmegaPlus/hDCACascDau"), casc.dcacascdaughters()); + histos.fill(HIST("MCCasc/OmegaPlus/hLambdaMass"), casc.mLambda()); + } + } + } + + // ______________________________________________________ + // Simulated processing (subscribes to MC information too) + void processGenerated(soa::Join const& mcCollisions, soa::Join const& V0MCCores, soa::Join const& CascMCCores, soa::Join const& collisions) + { + fillGeneratedEventProperties(mcCollisions, collisions); + std::vector listBestCollisionIdx = getListOfRecoCollIndices(mcCollisions, collisions); + for (auto const& v0MC : V0MCCores) { + if (!v0MC.has_straMCCollision()) + continue; + + if (!v0MC.isPhysicalPrimary()) + continue; + + float ptmc = v0MC.ptMC(); + float ymc = 1e3; + if (v0MC.pdgCode() == 310) + ymc = v0MC.rapidityMC(0); + else if (TMath::Abs(v0MC.pdgCode()) == 3122) + ymc = v0MC.rapidityMC(1); + + if (TMath::Abs(ymc) > v0Selections.rapidityCut) + continue; + + auto mcCollision = v0MC.straMCCollision_as>(); + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && mcCollision.multMCNParticlesEta10() < 1) { + continue; + } + + if (eventSelections.requireINEL1 && mcCollision.multMCNParticlesEta10() < 2) { + continue; + } + } + + float centrality = 100.5f; + if (listBestCollisionIdx[mcCollision.globalIndex()] > -1) { + auto collision = collisions.iteratorAt(listBestCollisionIdx[mcCollision.globalIndex()]); + centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + + if (eventSelections.minOccupancy >= 0 && collisionOccupancy < eventSelections.minOccupancy) { + continue; + } + if (eventSelections.maxOccupancy >= 0 && collisionOccupancy > eventSelections.maxOccupancy) { + continue; + } + + if (v0MC.pdgCode() == 310) { + histos.fill(HIST("GenMC/h2dGenK0ShortVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == 3122) { + histos.fill(HIST("GenMC/h2dGenLambdaVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == -3122) { + histos.fill(HIST("GenMC/h2dGenAntiLambdaVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + } + if (v0MC.pdgCode() == 22) { + histos.fill(HIST("GenMC/h2dGenGamma"), centrality, ptmc); + histos.fill(HIST("GenMC/h2dGenGammaVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == 310) { + histos.fill(HIST("GenMC/h2dGenK0Short"), centrality, ptmc); + histos.fill(HIST("GenMC/h2dGenK0ShortVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == 3122) { + histos.fill(HIST("GenMC/h2dGenLambda"), centrality, ptmc); + histos.fill(HIST("GenMC/h2dGenLambdaVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == -3122) { + histos.fill(HIST("GenMC/h2dGenAntiLambda"), centrality, ptmc); + histos.fill(HIST("GenMC/h2dGenAntiLambdaVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + } + + for (auto const& cascMC : CascMCCores) { + if (!cascMC.has_straMCCollision()) + continue; + + if (!cascMC.isPhysicalPrimary()) + continue; + + float ptmc = cascMC.ptMC(); + float ymc = 1e3; + if (TMath::Abs(cascMC.pdgCode()) == 3312) + ymc = cascMC.rapidityMC(0); + else if (TMath::Abs(cascMC.pdgCode()) == 3334) + ymc = cascMC.rapidityMC(2); + + if (TMath::Abs(ymc) > v0Selections.rapidityCut) + continue; + + auto mcCollision = cascMC.straMCCollision_as>(); + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && mcCollision.multMCNParticlesEta10() < 1) { + continue; + } + + if (eventSelections.requireINEL1 && mcCollision.multMCNParticlesEta10() < 2) { + continue; + } + } + + float centrality = 100.5f; + if (listBestCollisionIdx[mcCollision.globalIndex()] > -1) { + auto collision = collisions.iteratorAt(listBestCollisionIdx[mcCollision.globalIndex()]); + centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + + if (eventSelections.minOccupancy >= 0 && collisionOccupancy < eventSelections.minOccupancy) { + continue; + } + if (eventSelections.maxOccupancy >= 0 && collisionOccupancy > eventSelections.maxOccupancy) { + continue; + } + + if (cascMC.pdgCode() == 3312) { + histos.fill(HIST("GenMC/h2dGenXiMinusVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (cascMC.pdgCode() == -3312) { + histos.fill(HIST("GenMC/h2dGenXiPlusVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (cascMC.pdgCode() == 3334) { + histos.fill(HIST("GenMC/h2dGenOmegaMinusVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (cascMC.pdgCode() == -3334) { + histos.fill(HIST("GenMC/h2dGenOmegaPlusVsMultMC_RecoedEvt"), mcCollision.multMCNParticlesEta05(), ptmc); + } + } + + if (cascMC.pdgCode() == 3312) { + histos.fill(HIST("GenMC/h2dGenXiMinus"), centrality, ptmc); + histos.fill(HIST("GenMC/h2dGenXiMinusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (cascMC.pdgCode() == -3312) { + histos.fill(HIST("GenMC/h2dGenXiPlus"), centrality, ptmc); + histos.fill(HIST("GenMC/h2dGenXiPlusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (cascMC.pdgCode() == 3334) { + histos.fill(HIST("GenMC/h2dGenOmegaMinus"), centrality, ptmc); + histos.fill(HIST("GenMC/h2dGenOmegaMinusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (cascMC.pdgCode() == -3334) { + histos.fill(HIST("GenMC/h2dGenOmegaPlus"), centrality, ptmc); + histos.fill(HIST("GenMC/h2dGenOmegaPlusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + } + } + + PROCESS_SWITCH(strderivedGenQA, processDerivedV0s, "Process derived data", true); + PROCESS_SWITCH(strderivedGenQA, processMCDerivedV0s, "Process derived data", false); + PROCESS_SWITCH(strderivedGenQA, processDerivedCascades, "Process derived data", true); + PROCESS_SWITCH(strderivedGenQA, processMCDerivedCascades, "Process derived data", false); + PROCESS_SWITCH(strderivedGenQA, processGenerated, "process MC generated", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/QC/trackedCascadeProperties.cxx b/PWGLF/Tasks/QC/trackedCascadeProperties.cxx new file mode 100644 index 00000000000..489e37e2608 --- /dev/null +++ b/PWGLF/Tasks/QC/trackedCascadeProperties.cxx @@ -0,0 +1,313 @@ +// 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. +// +/// \file trackedCascadeProperties.cxx +/// +/// \brief task to study the average cluster size of tracked cascades +/// +/// \author Alberto Caliva (alberto.caliva@cern.ch), Francesca Ercolessi (francesca.ercolessi@cern.ch) +/// \since May 31, 2024 + +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +using namespace o2::constants::math; +using std::array; + +// Define type aliases for joined tables +using SelectedCollisions = soa::Join; +using FullTracks = soa::Join; + +struct TrackedCascadeProperties { + + // Instantiate the CCDB manager service and API interface + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + + // Instantiate the main Zorro processing object and define an output to store summary information + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + + // Histogram registry for quality control + HistogramRegistry registryQC{"registryQC", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Histogram registry for data + HistogramRegistry registryData{"registryData", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Global Parameters + Configurable zVtx{"zVtx", 10.0f, "z vertex cut"}; + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "Skimmed dataset processing"}; + Configurable triggerList{"triggerList", "fTrackedOmega, fTrackedXi, fOmegaLargeRadius, fDoubleOmega, fOmegaHighMult, fSingleXiYN, fQuadrupleXi, fDoubleXi, fhadronOmega, fOmegaXi, fTripleXi, fOmega", "Trigger list"}; + + // Analysis Selections + Configurable minItsClustersCasc{"minItsClustersCasc", 4, "min ITS Clusters"}; + Configurable massMinXi{"massMinXi", 1.315f, "mMin Xi"}; + Configurable massMaxXi{"massMaxXi", 1.328f, "mMax Xi"}; + Configurable massMinOmega{"massMinOmega", 1.665f, "mMin Omega"}; + Configurable massMaxOmega{"massMaxOmega", 1.680f, "mMax Omega"}; + + // Initialize CCDB access and histogram registry for Zorro processing + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (cfgSkimmedProcessing) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), triggerList); + zorro.populateHistRegistry(registryData, bc.runNumber()); + } + } + + void init(InitContext const&) + { + if (cfgSkimmedProcessing) { + zorroSummary.setObject(zorro.getZorroSummary()); + } + + // Quality Control Histograms + registryQC.add("matchingChi2", "matching Chi2", HistType::kTH1F, {{200, 0, 1000, "#chi^{2}_{matching}"}}); + registryQC.add("topologyChi2", "topology Chi2", HistType::kTH1F, {{500, 0, 0.5, "#chi^{2}_{topology}"}}); + registryQC.add("nITScls_vs_p_xi", "nITS Xi", HistType::kTH2F, {{100, 0, 10, "#it{p} (GeV/#it{c})"}, {8, 0, 8, "n_{ITS}^{cls}"}}); + registryQC.add("nITScls_vs_p_omega", "nITS Omega", HistType::kTH2F, {{100, 0, 10, "#it{p} (GeV/#it{c})"}, {8, 0, 8, "n_{ITS}^{cls}"}}); + registryQC.add("decayXY", "decayXY", HistType::kTH2F, {{500, -50, 50, "x"}, {500, -50, 50, "y"}}); + + // Event Counter + registryData.add("number_of_events_data", "number of events in data", HistType::kTH1F, {{5, 0, 5, "Event Cuts"}}); + + // Average cluster size vs momentum + registryData.add("xi_pos_avgclustersize_cosL_vs_p", "xi_pos_avgclustersize_cosL_vs_p", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("xi_neg_avgclustersize_cosL_vs_p", "xi_neg_avgclustersize_cosL_vs_p", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("omega_pos_avgclustersize_cosL_vs_p", "omega_pos_avgclustersize_cosL_vs_p", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("omega_neg_avgclustersize_cosL_vs_p", "omega_neg_avgclustersize_cosL_vs_p", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + + // Average cluster size vs betagamma + registryData.add("xi_pos_avgclustersize_cosL_vs_betagamma", "xi_pos_avgclustersize_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("xi_neg_avgclustersize_cosL_vs_betagamma", "xi_neg_avgclustersize_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("omega_pos_avgclustersize_cosL_vs_betagamma", "omega_pos_avgclustersize_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("omega_neg_avgclustersize_cosL_vs_betagamma", "omega_neg_avgclustersize_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + + // Cluster size using truncated mean vs momentum + registryData.add("xi_pos_avgclustersize_trunc_cosL_vs_p", "xi_pos_avgclustersize_trunc_cosL_vs_p", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("xi_neg_avgclustersize_trunc_cosL_vs_p", "xi_neg_avgclustersize_trunc_cosL_vs_p", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("omega_pos_avgclustersize_trunc_cosL_vs_p", "omega_pos_avgclustersize_trunc_cosL_vs_p", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("omega_neg_avgclustersize_trunc_cosL_vs_p", "omega_neg_avgclustersize_trunc_cosL_vs_p", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + + // Cluster size using truncated mean vs betagamma + registryData.add("xi_pos_avgclustersize_trunc_cosL_vs_betagamma", "xi_pos_avgclustersize_trunc_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("xi_neg_avgclustersize_trunc_cosL_vs_betagamma", "xi_neg_avgclustersize_trunc_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("omega_pos_avgclustersize_trunc_cosL_vs_betagamma", "omega_pos_avgclustersize_trunc_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + registryData.add("omega_neg_avgclustersize_trunc_cosL_vs_betagamma", "omega_neg_avgclustersize_trunc_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); + + // mass histograms + registryData.add("xi_mass_pos", "xi_mass_pos", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {200, 1.28, 1.36, "m_{p#pi#pi} (GeV/#it{c}^{2})"}}); + registryData.add("xi_mass_neg", "xi_mass_neg", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {200, 1.28, 1.36, "m_{p#pi#pi} (GeV/#it{c}^{2})"}}); + registryData.add("omega_mass_pos", "omega_mass_pos", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {200, 1.63, 1.71, "m_{p#piK} (GeV/#it{c}^{2})"}}); + registryData.add("omega_mass_neg", "omega_mass_neg", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {200, 1.63, 1.71, "m_{p#piK} (GeV/#it{c}^{2})"}}); + } + + double trackInclination(double eta) + { + double lambda(0); + double theta = 2.0 * std::atan(std::exp(-eta)); + if (theta <= PIHalf) + lambda = PIHalf - theta; + if (theta > PIHalf) + lambda = theta - PIHalf; + return lambda; + } + + int findBin(const std::vector& edges, double value) + { + auto it = std::upper_bound(edges.begin(), edges.end(), value); + int index = static_cast(it - edges.begin()) - 1; + if (index < 0 || index >= static_cast(edges.size()) - 1) { + return -1; // value is out of bounds + } + return index; + } + + void processData(SelectedCollisions::iterator const& collision, aod::AssignedTrackedCascades const& trackedCascades, + aod::Cascades const&, FullTracks const&, aod::BCsWithTimestamps const&) + { + // Number of events before any selection + registryData.fill(HIST("number_of_events_data"), 0.5); + + // Retrieve the bunch crossing information with timestamps from the collision + auto bc = collision.template bc_as(); + initCCDB(bc); + + // If skimmed processing is enabled, apply Zorro trigger selection + if (cfgSkimmedProcessing && !zorro.isSelected(collision.template bc_as().globalBC())) { + return; + } + + // Number of events after skimming selection + registryData.fill(HIST("number_of_events_data"), 1.5); + if (!collision.sel8()) + return; + + // Number of events after sel8 + registryData.fill(HIST("number_of_events_data"), 2.5); + if (std::abs(collision.posZ()) > zVtx) + return; + + // Number of events after zVtx cut + registryData.fill(HIST("number_of_events_data"), 3.5); + + // radii of ITS layers + std::vector edgesItsLayers = {0.0, 2.2, 2.8, 3.6, 20.0, 22.0, 37.0, 39.0, 100.0}; + + // Loop over tracked cascades + for (const auto& trackedCascade : trackedCascades) { + + // Get tracked cascade + const auto track = trackedCascade.track_as(); + const auto trackITS = trackedCascade.itsTrack_as(); + const auto& casc = trackedCascade.cascade(); + const auto& btrack = casc.bachelor_as(); + double dx = trackedCascade.decayX(); + double dy = trackedCascade.decayY(); + double r = std::sqrt(dx * dx + dy * dy); + int nItsLayersCrossed = findBin(edgesItsLayers, r); + + // Fill QC histograms + registryQC.fill(HIST("matchingChi2"), trackedCascade.matchingChi2()); + registryQC.fill(HIST("topologyChi2"), trackedCascade.topologyChi2()); + registryQC.fill(HIST("decayXY"), dx, dy); + + // Compute average cluster size and truncated mean + double sumClusterSize = 0.0; + double sumClusterSizeTrunc = 0.0; + double maxClusterSize = 0.0; + double averageClusterSize = 0.0; + double averageClusterSizeTrunc = 0.0; + int nCls = 0; + + for (int i = 0; i < nItsLayersCrossed; i++) { + double clusterSize = static_cast(trackITS.itsClsSizeInLayer(i)); + if (clusterSize > 0) { + sumClusterSize += clusterSize; + sumClusterSizeTrunc += clusterSize; + nCls++; + if (clusterSize > maxClusterSize) { + maxClusterSize = clusterSize; + } + } + } + if (nCls > 0) { + averageClusterSize = sumClusterSize / static_cast(nCls); + } + if (nCls > 1) { + averageClusterSizeTrunc = (sumClusterSizeTrunc - maxClusterSize) / static_cast(nCls - 1); + } + + // Apply selection on number of ITS clusters + if (nCls < minItsClustersCasc) + continue; + + // Xi Mass + if (btrack.sign() > 0) { + registryData.fill(HIST("xi_mass_pos"), track.p(), trackedCascade.xiMass()); + } + if (btrack.sign() < 0) { + registryData.fill(HIST("xi_mass_neg"), track.p(), trackedCascade.xiMass()); + } + + // Variables + double lambda = trackInclination(track.eta()); + double clsSizeCosL = averageClusterSize * std::cos(lambda); + double clsSizeCosLtrunc = averageClusterSizeTrunc * std::cos(lambda); + double bgXi = track.p() / MassXiPlusBar; + double bgOmega = track.p() / MassOmegaPlusBar; + + // Xi + if (trackedCascade.xiMass() > massMinXi && trackedCascade.xiMass() < massMaxXi) { + registryQC.fill(HIST("nITScls_vs_p_xi"), track.p(), trackITS.itsNCls()); + if (btrack.sign() > 0) { + registryData.fill(HIST("xi_pos_avgclustersize_cosL_vs_p"), track.p(), clsSizeCosL); + registryData.fill(HIST("xi_pos_avgclustersize_cosL_vs_betagamma"), bgXi, clsSizeCosL); + registryData.fill(HIST("xi_pos_avgclustersize_trunc_cosL_vs_p"), track.p(), clsSizeCosLtrunc); + registryData.fill(HIST("xi_pos_avgclustersize_trunc_cosL_vs_betagamma"), bgXi, clsSizeCosLtrunc); + } + if (btrack.sign() < 0) { + registryData.fill(HIST("xi_neg_avgclustersize_cosL_vs_p"), track.p(), clsSizeCosL); + registryData.fill(HIST("xi_neg_avgclustersize_cosL_vs_betagamma"), bgXi, clsSizeCosL); + registryData.fill(HIST("xi_neg_avgclustersize_trunc_cosL_vs_p"), track.p(), clsSizeCosLtrunc); + registryData.fill(HIST("xi_neg_avgclustersize_trunc_cosL_vs_betagamma"), bgXi, clsSizeCosLtrunc); + } + continue; + } + + // Omega Mass + if (btrack.sign() > 0) { + registryData.fill(HIST("omega_mass_pos"), track.p(), trackedCascade.omegaMass()); + } + if (btrack.sign() < 0) { + registryData.fill(HIST("omega_mass_neg"), track.p(), trackedCascade.omegaMass()); + } + + // Omega + if (trackedCascade.omegaMass() > massMinOmega && trackedCascade.omegaMass() < massMaxOmega) { + registryQC.fill(HIST("nITScls_vs_p_omega"), track.p(), trackITS.itsNCls()); + if (btrack.sign() > 0) { + registryData.fill(HIST("omega_pos_avgclustersize_cosL_vs_p"), track.p(), clsSizeCosL); + registryData.fill(HIST("omega_pos_avgclustersize_cosL_vs_betagamma"), bgOmega, clsSizeCosL); + registryData.fill(HIST("omega_pos_avgclustersize_trunc_cosL_vs_p"), track.p(), clsSizeCosLtrunc); + registryData.fill(HIST("omega_pos_avgclustersize_trunc_cosL_vs_betagamma"), bgOmega, clsSizeCosLtrunc); + } + if (btrack.sign() < 0) { + registryData.fill(HIST("omega_neg_avgclustersize_cosL_vs_p"), track.p(), clsSizeCosL); + registryData.fill(HIST("omega_neg_avgclustersize_cosL_vs_betagamma"), bgOmega, clsSizeCosL); + registryData.fill(HIST("omega_neg_avgclustersize_trunc_cosL_vs_p"), track.p(), clsSizeCosLtrunc); + registryData.fill(HIST("omega_neg_avgclustersize_trunc_cosL_vs_betagamma"), bgOmega, clsSizeCosLtrunc); + } + } + } + } + PROCESS_SWITCH(TrackedCascadeProperties, processData, "Process data", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/QC/tracked_cascade_properties.cxx b/PWGLF/Tasks/QC/tracked_cascade_properties.cxx deleted file mode 100644 index e2f93dbe481..00000000000 --- a/PWGLF/Tasks/QC/tracked_cascade_properties.cxx +++ /dev/null @@ -1,241 +0,0 @@ -// 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 Alberto Caliva (alberto.caliva@cern.ch), Francesca Ercolessi (francesca.ercolessi@cern.ch) -/// \since May 31, 2024 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Framework/ASoA.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "ReconstructionDataFormats/Track.h" -#include "ReconstructionDataFormats/DCA.h" -#define mXi 1.32171 -#define mOmega 1.67245 - -using namespace std; -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::constants::physics; -using std::array; - -using SelectedCollisions = soa::Join; - -using FullTracks = soa::Join; - -struct tracked_cascade_properties { - - // QC Histograms - HistogramRegistry registryQC{ - "registryQC", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - - // Analysis Histograms: Data - HistogramRegistry registryData{ - "registryData", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - - // Global Parameters - Configurable zVtx{"zVtx", 10.0f, "z vertex cut"}; - - // Cascade Parameters - Configurable minimumCascRadius{"minimumCascRadius", 5.0f, "Minimum Cascade Radius"}; - Configurable maximumCascRadius{"maximumCascRadius", 18.0f, "Maximum Cascade Radius"}; - - // Mass Cuts - Configurable mMin_xi{"mMin_xi", 1.315f, "mMin Xi"}; - Configurable mMax_xi{"mMax_xi", 1.328f, "mMax Xi"}; - Configurable mMin_omega{"mMin_omega", 1.665f, "mMin Omega"}; - Configurable mMax_omega{"mMax_omega", 1.680f, "mMax Omega"}; - - void init(InitContext const&) - { - registryQC.add("matchingChi2", "matching Chi2", HistType::kTH1F, {{200, 0, 1000, "#chi^{2}_{matching}"}}); - registryQC.add("topologyChi2", "topology Chi2", HistType::kTH1F, {{500, 0, 0.5, "#chi^{2}_{topology}"}}); - registryQC.add("nITScls_vs_p_xi", "nITS Xi", HistType::kTH2F, {{100, 0, 10, "#it{p} (GeV/#it{c})"}, {8, 0, 8, "n_{ITS}^{cls}"}}); - registryQC.add("nITScls_vs_p_omega", "nITS Omega", HistType::kTH2F, {{100, 0, 10, "#it{p} (GeV/#it{c})"}, {8, 0, 8, "n_{ITS}^{cls}"}}); - registryQC.add("decayXY", "decayXY", HistType::kTH2F, {{500, -50, 50, "x"}, {500, -50, 50, "y"}}); - registryQC.add("deltaClsSize", "deltaClsSize", HistType::kTH1F, {{40, -20, 20, "#DeltaClsSize"}}); - registryQC.add("deltaP", "deltaP", HistType::kTH1F, {{1000, -1, 1, "#Deltap"}}); - registryQC.add("deltaEta", "deltaEta", HistType::kTH1F, {{200, -0.5, 0.5, "#Delta#eta"}}); - registryQC.add("deltaNclsITS", "deltaNclsITS", HistType::kTH1F, {{20, -10, 10, "#DeltaN"}}); - registryQC.add("deltaNclsITS_track", "deltaNclsITS_track", HistType::kTH1F, {{20, -10, 10, "#DeltaN"}}); - registryQC.add("deltaNclsITS_itstrack", "deltaNclsITS_itstrack", HistType::kTH1F, {{20, -10, 10, "#DeltaN"}}); - - registryData.add("number_of_events_data", "number of events in data", HistType::kTH1F, {{5, 0, 5, "Event Cuts"}}); - registryData.add("xi_pos_avgclustersize", "xi_pos_avgclustersize", HistType::kTH3F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT"}, {16, -0.8, 0.8, "#eta"}}); - registryData.add("xi_neg_avgclustersize", "xi_neg_avgclustersize", HistType::kTH3F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT"}, {16, -0.8, 0.8, "#eta"}}); - registryData.add("omega_pos_avgclustersize", "omega_pos_avgclustersize", HistType::kTH3F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT"}, {16, -0.8, 0.8, "#eta"}}); - registryData.add("omega_neg_avgclustersize", "omega_neg_avgclustersize", HistType::kTH3F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT"}, {16, -0.8, 0.8, "#eta"}}); - - registryData.add("xi_pos_avgclustersize_cosL", "xi_pos_avgclustersize_cosL", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); - registryData.add("xi_neg_avgclustersize_cosL", "xi_neg_avgclustersize_cosL", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); - registryData.add("omega_pos_avgclustersize_cosL", "omega_pos_avgclustersize_cosL", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); - registryData.add("omega_neg_avgclustersize_cosL", "omega_neg_avgclustersize_cosL", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); - - registryData.add("xi_pos_avgclustersize_cosL_vs_betagamma", "xi_pos_avgclustersize_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); - registryData.add("xi_neg_avgclustersize_cosL_vs_betagamma", "xi_neg_avgclustersize_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); - registryData.add("omega_pos_avgclustersize_cosL_vs_betagamma", "omega_pos_avgclustersize_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); - registryData.add("omega_neg_avgclustersize_cosL_vs_betagamma", "omega_neg_avgclustersize_cosL_vs_betagamma", HistType::kTH2F, {{200, 0.0, 10.0, "#beta#gamma"}, {100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}}); - - registryData.add("xi_mass_pos", "xi_mass_pos", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {200, 1.28, 1.36, "m_{p#pi#pi} (GeV/#it{c}^{2})"}}); - registryData.add("xi_mass_neg", "xi_mass_neg", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {200, 1.28, 1.36, "m_{p#pi#pi} (GeV/#it{c}^{2})"}}); - registryData.add("omega_mass_pos", "omega_mass_pos", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {200, 1.63, 1.71, "m_{p#piK} (GeV/#it{c}^{2})"}}); - registryData.add("omega_mass_neg", "omega_mass_neg", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {200, 1.63, 1.71, "m_{p#piK} (GeV/#it{c}^{2})"}}); - } - - double track_inclination(double eta) - { - double lambda(0); - double theta = 2.0 * atan(exp(-eta)); - if (theta <= TMath::Pi() / 2.0) - lambda = 0.5 * TMath::Pi() - theta; - if (theta > TMath::Pi() / 2.0) - lambda = theta - 0.5 * TMath::Pi(); - return lambda; - } - - void processData(SelectedCollisions::iterator const& collision, aod::AssignedTrackedCascades const& trackedCascades, - aod::Cascades const&, FullTracks const&) - { - registryData.fill(HIST("number_of_events_data"), 0.5); - if (!collision.sel8()) - return; - - registryData.fill(HIST("number_of_events_data"), 1.5); - if (abs(collision.posZ()) > zVtx) - return; - - registryData.fill(HIST("number_of_events_data"), 2.5); - - for (const auto& trackedCascade : trackedCascades) { - - const auto track = trackedCascade.track_as(); - const auto trackITS = trackedCascade.itsTrack_as(); - - // Comparison between track and ITStrack - registryQC.fill(HIST("deltaP"), track.p() - trackITS.p()); - registryQC.fill(HIST("deltaEta"), track.eta() - trackITS.eta()); - registryQC.fill(HIST("deltaNclsITS"), track.itsNCls() - trackITS.itsNCls()); - for (int i = 0; i < 7; i++) { - registryQC.fill(HIST("deltaClsSize"), track.itsClsSizeInLayer(i) - trackITS.itsClsSizeInLayer(i)); - } - - const auto& casc = trackedCascade.cascade(); - const auto& btrack = casc.bachelor_as(); - double dx = trackedCascade.decayX(); - double dy = trackedCascade.decayY(); - double r = sqrt(dx * dx + dy * dy); - if (r < minimumCascRadius || r > maximumCascRadius) - continue; - - registryQC.fill(HIST("matchingChi2"), trackedCascade.matchingChi2()); - registryQC.fill(HIST("topologyChi2"), trackedCascade.topologyChi2()); - registryQC.fill(HIST("decayXY"), dx, dy); - - // Calculate (Average) Cluster Size - double averageClusterSize(0); - int nCls(0); - for (int i = 0; i < 7; i++) { - int clusterSize = trackITS.itsClsSizeInLayer(i); - averageClusterSize += static_cast(clusterSize); - if (clusterSize > 0) - nCls++; - } - averageClusterSize = averageClusterSize / static_cast(nCls); - - registryQC.fill(HIST("deltaNclsITS_track"), nCls - track.itsNCls()); - registryQC.fill(HIST("deltaNclsITS_itstrack"), nCls - trackITS.itsNCls()); - - // Xi Mass - if (btrack.sign() > 0) { - registryData.fill(HIST("xi_mass_pos"), track.p(), trackedCascade.xiMass()); - } - if (btrack.sign() < 0) { - registryData.fill(HIST("xi_mass_neg"), track.p(), trackedCascade.xiMass()); - } - - // Track Inclination - double lambda = track_inclination(track.eta()); - - // Xi - if (trackedCascade.xiMass() > mMin_xi && trackedCascade.xiMass() < mMax_xi) { - registryQC.fill(HIST("nITScls_vs_p_xi"), track.p(), trackITS.itsNCls()); - if (btrack.sign() > 0) { - registryData.fill(HIST("xi_pos_avgclustersize"), track.p(), averageClusterSize, track.eta()); - registryData.fill(HIST("xi_pos_avgclustersize_cosL"), track.p(), averageClusterSize * cos(lambda)); - registryData.fill(HIST("xi_pos_avgclustersize_cosL_vs_betagamma"), track.p() / mXi, averageClusterSize * cos(lambda)); - } - if (btrack.sign() < 0) { - registryData.fill(HIST("xi_neg_avgclustersize"), track.p(), averageClusterSize, track.eta()); - registryData.fill(HIST("xi_neg_avgclustersize_cosL"), track.p(), averageClusterSize * cos(lambda)); - registryData.fill(HIST("xi_neg_avgclustersize_cosL_vs_betagamma"), track.p() / mXi, averageClusterSize * cos(lambda)); - } - continue; - } - - // Omega Mass - if (btrack.sign() > 0) { - registryData.fill(HIST("omega_mass_pos"), track.p(), trackedCascade.omegaMass()); - } - if (btrack.sign() < 0) { - registryData.fill(HIST("omega_mass_neg"), track.p(), trackedCascade.omegaMass()); - } - - // Omega - if (trackedCascade.omegaMass() > mMin_omega && trackedCascade.omegaMass() < mMax_omega) { - registryQC.fill(HIST("nITScls_vs_p_omega"), track.p(), trackITS.itsNCls()); - if (btrack.sign() > 0) { - registryData.fill(HIST("omega_pos_avgclustersize"), track.p(), averageClusterSize, track.eta()); - registryData.fill(HIST("omega_pos_avgclustersize_cosL"), track.p(), averageClusterSize * cos(lambda)); - registryData.fill(HIST("omega_pos_avgclustersize_cosL_vs_betagamma"), track.p() / mOmega, averageClusterSize * cos(lambda)); - } - if (btrack.sign() < 0) { - registryData.fill(HIST("omega_neg_avgclustersize"), track.p(), averageClusterSize, track.eta()); - registryData.fill(HIST("omega_neg_avgclustersize_cosL"), track.p(), averageClusterSize * cos(lambda)); - registryData.fill(HIST("omega_neg_avgclustersize_cosL_vs_betagamma"), track.p() / mOmega, averageClusterSize * cos(lambda)); - } - } - } - } - PROCESS_SWITCH(tracked_cascade_properties, processData, "Process data", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/PWGLF/Tasks/QC/v0assoqa.cxx b/PWGLF/Tasks/QC/v0assoqa.cxx new file mode 100644 index 00000000000..fcfd8d59b01 --- /dev/null +++ b/PWGLF/Tasks/QC/v0assoqa.cxx @@ -0,0 +1,481 @@ +// 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. +// +// Strangeness-to-collision association tests +// +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "ReconstructionDataFormats/Track.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/McCollisionExtra.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsBase/GeometryManager.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/BasicCCDBManager.h" +#include "PWGLF/Utils/strangenessBuilderHelper.h" +#include "Common/Core/TPCVDriftManager.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "Framework/ASoAHelpers.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; + +// using MyTracks = soa::Join; +using TracksCompleteIU = soa::Join; +using TracksCompleteIUMC = soa::Join; +using V0DataLabeled = soa::Join; +using CascMC = soa::Join; +using TraCascMC = soa::Join; +using RecoedMCCollisions = soa::Join; +using CollisionsWithEvSels = soa::Join; + +// For MC association in pre-selection +using LabeledTracksExtra = soa::Join; + +struct v0assoqa { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // helper object + o2::pwglf::strangenessBuilderHelper straHelper; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + + int mRunNumber; + o2::base::MatLayerCylSet* lut = nullptr; + + // for handling TPC-only tracks (photons) + o2::aod::common::TPCVDriftManager mVDriftMgr; + + // CCDB options + struct : ConfigurableGroup { + std::string prefix = "ccdb"; + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + } ccdbConfigurations; + + // V0 building options + struct : ConfigurableGroup { + std::string prefix = "v0BuilderOpts"; + Configurable moveTPCOnlyTracks{"moveTPCOnlyTracks", true, "if dealing with TPC-only tracks, move them according to TPC drift / time info"}; + + // baseline conditionals of V0 building + Configurable minCrossedRows{"minCrossedRows", -1, "minimum TPC crossed rows for daughter tracks"}; + Configurable dcanegtopv{"dcanegtopv", .0, "DCA Neg To PV"}; + Configurable dcapostopv{"dcapostopv", .0, "DCA Pos To PV"}; + Configurable v0cospa{"v0cospa", -2, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0) + Configurable dcav0dau{"dcav0dau", 10000.0, "DCA V0 Daughters"}; + Configurable v0radius{"v0radius", 0.0, "v0radius"}; + Configurable maxDaughterEta{"maxDaughterEta", 5.0, "Maximum daughter eta (in abs value)"}; + } v0BuilderOpts; + + // cascade building options + struct : ConfigurableGroup { + std::string prefix = "cascadeBuilderOpts"; + // conditionals + Configurable minCrossedRows{"minCrossedRows", 50, "minimum TPC crossed rows for daughter tracks"}; + Configurable dcabachtopv{"dcabachtopv", .05, "DCA Bach To PV"}; + Configurable cascradius{"cascradius", 0.9, "cascradius"}; + Configurable casccospa{"casccospa", 0.95, "casccospa"}; + Configurable dcacascdau{"dcacascdau", 1.0, "DCA cascade Daughters"}; + Configurable lambdaMassWindow{"lambdaMassWindow", .010, "Distance from Lambda mass (does not apply to KF path)"}; + Configurable maxDaughterEta{"maxDaughterEta", 5.0, "Maximum daughter eta (in abs value)"}; + } cascadeBuilderOpts; + + //_______________________________________________________________________ + template + int findMotherFromLabels(int const& p1, int const& p2, const int expected_pdg1, const int expected_pdg2, const int expected_mother_pdg, TMCParticles const& mcparticles) + { + // encompasses a simple check for labels existing + if (p1 < 0 || p2 < 0) { + return -1; + } + auto mcParticle1 = mcparticles.rawIteratorAt(p1); + auto mcParticle2 = mcparticles.rawIteratorAt(p2); + return (findMother(mcParticle1, mcParticle2, expected_pdg1, expected_pdg2, expected_mother_pdg, mcparticles)); + } + + //_______________________________________________________________________ + template + int findMother(TMCParticle1 const& p1, TMCParticle2 const& p2, const int expected_pdg1, const int expected_pdg2, const int expected_mother_pdg, TMCParticles const& mcparticles) + { + if (p1.globalIndex() == p2.globalIndex()) + return -1; + if (p1.pdgCode() != expected_pdg1 || p2.pdgCode() != expected_pdg2) + return -1; + if (!p1.has_mothers() || !p2.has_mothers()) + return -1; + + int motherid1 = p1.mothersIds()[0]; + auto mother1 = mcparticles.iteratorAt(motherid1); + int mother1_pdg = mother1.pdgCode(); + int motherid2 = p2.mothersIds()[0]; + auto mother2 = mcparticles.iteratorAt(motherid2); + int mother2_pdg = mother2.pdgCode(); + + if (motherid1 != motherid2 || mother1_pdg != mother2_pdg || mother1_pdg != expected_mother_pdg) + return -1; + + return motherid1; + } + + void init(InitContext const&) + { + histos.add("hDuplicateCount", "hDuplicateCount", kTH1F, {{50, -0.5f, 49.5f}}); + histos.add("hDuplicateCountType7", "hDuplicateCountType7", kTH1F, {{50, -0.5f, 49.5f}}); + histos.add("hDuplicateCountType7allTPConly", "hDuplicateCountType7allTPConly", kTH1F, {{50, -0.5f, 49.5f}}); + + histos.add("hPhotonPt", "hPhotonPt", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hPhotonPt_Duplicates", "hPhotonPt_Duplicates", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hPhotonPt_withRecoedMcCollision", "hPhotonPt_withRecoedMcCollision", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hPhotonPt_withCorrectCollisionCopy", "hPhotonPt_withCorrectCollisionCopy", kTH1F, {{200, 0.0f, 20.0f}}); + + histos.add("hPA_All", "hPA_All", kTH1F, {{100, 0.0f, 1.0f}}); + histos.add("hPA_Correct", "hPA_Correct", kTH1F, {{100, 0.0f, 1.0f}}); + + // 2D for vs pT + histos.add("hPAvsPt_All", "hPAvsPt_All", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 1.0f}}); + histos.add("hPAvsPt_Correct", "hPAvsPt_Correct", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 1.0f}}); + histos.add("hDCADaughtersvsPt_All", "hDCADaughtersvsPt_All", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 5.0f}}); + histos.add("hDCADaughtersvsPt_Correct", "hDCADaughtersvsPt_Correct", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 5.0f}}); + histos.add("hDCADaughters3DvsPt_All", "hDCADaughters3DvsPt_All", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 5.0f}}); + histos.add("hDCADaughters3DvsPt_Correct", "hDCADaughters3DvsPt_Correct", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 5.0f}}); + histos.add("hDCADaughtersXYvsPt_All", "hDCADaughtersXYvsPt_All", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 5.0f}}); + histos.add("hDCADaughtersXYvsPt_Correct", "hDCADaughtersXYvsPt_Correct", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 5.0f}}); + histos.add("hDCADaughtersZvsPt_All", "hDCADaughtersZvsPt_All", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 5.0f}}); + histos.add("hDCADaughtersZvsPt_Correct", "hDCADaughtersZvsPt_Correct", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 5.0f}}); + + // winner-takes-all criteria spectra + histos.add("hCorrect_BestPA", "hCorrect_BestPA", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hCorrect_BestDCADau", "hCorrect_DCADau", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hCorrect_BestDCADau3D", "hCorrect_DCADau3D", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hCorrect_BestDCADauXY", "hCorrect_DCADauXY", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hCorrect_BestDCADauZ", "hCorrect_DCADauZ", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hCorrect_BestPAandDCADau3D", "hCorrect_BestPAandDCADau3D", kTH1F, {{200, 0.0f, 20.0f}}); + + ccdb->setURL(ccdbConfigurations.ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + // set V0 parameters in the helper + straHelper.v0selections.minCrossedRows = v0BuilderOpts.minCrossedRows; + straHelper.v0selections.dcanegtopv = v0BuilderOpts.dcanegtopv; + straHelper.v0selections.dcapostopv = v0BuilderOpts.dcapostopv; + straHelper.v0selections.v0cospa = v0BuilderOpts.v0cospa; + straHelper.v0selections.dcav0dau = v0BuilderOpts.dcav0dau; + straHelper.v0selections.v0radius = v0BuilderOpts.v0radius; + straHelper.v0selections.maxDaughterEta = v0BuilderOpts.maxDaughterEta; + + // set cascade parameters in the helper + straHelper.cascadeselections.minCrossedRows = cascadeBuilderOpts.minCrossedRows; + straHelper.cascadeselections.dcabachtopv = cascadeBuilderOpts.dcabachtopv; + straHelper.cascadeselections.cascradius = cascadeBuilderOpts.cascradius; + straHelper.cascadeselections.casccospa = cascadeBuilderOpts.casccospa; + straHelper.cascadeselections.dcacascdau = cascadeBuilderOpts.dcacascdau; + straHelper.cascadeselections.lambdaMassWindow = cascadeBuilderOpts.lambdaMassWindow; + straHelper.cascadeselections.maxDaughterEta = cascadeBuilderOpts.maxDaughterEta; + } + + template + bool initCCDB(aod::BCsWithTimestamps const& bcs, TCollisions const& collisions) + { + auto bc = collisions.size() ? collisions.begin().template bc_as() : bcs.begin(); + if (!bcs.size()) { + LOGF(warn, "No BC found, skipping this DF."); + return false; // signal to skip this DF + } + + if (mRunNumber == bc.runNumber()) { + return true; + } + + auto timestamp = bc.timestamp(); + o2::parameters::GRPMagField* grpmag = 0x0; + + grpmag = ccdb->getForTimeStamp(ccdbConfigurations.grpmagPath, timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << ccdbConfigurations.grpmagPath << " of object GRPMagField for timestamp " << timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + + // Fetch magnetic field from ccdb for current collision + auto magneticField = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << magneticField << " kG"; + + // Set magnetic field value once known + straHelper.fitter.setBz(magneticField); + + // acquire LUT for this timestamp + LOG(info) << "Loading material look-up table for timestamp: " << timestamp; + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp(ccdbConfigurations.lutPath, timestamp)); + o2::base::Propagator::Instance()->setMatLUT(lut); + straHelper.lut = lut; + + LOG(info) << "Fully configured for run: " << bc.runNumber(); + // mmark this run as configured + mRunNumber = bc.runNumber(); + + // initialize only if needed, avoid unnecessary CCDB calls + mVDriftMgr.init(&ccdb->instance()); + mVDriftMgr.update(timestamp); + + return true; + } + + void process(soa::Join const& collisions, aod::McCollisions const& mcCollisions, aod::V0s const& V0s, LabeledTracksExtra const& tracks, aod::McParticles const& mcParticles, aod::BCsWithTimestamps const& bcs) + { + if (!initCCDB(bcs, collisions)) + return; + + std::vector v0tableGrouped = o2::pwglf::groupDuplicates(V0s); + + // determine map of McCollisions -> Collisions + std::vector> mcCollToColl(mcCollisions.size()); + for (auto const& collision : collisions) { + if (collision.mcCollisionId() > -1) { + // useful to determine if collision has been reconstructed afterwards + mcCollToColl[collision.mcCollisionId()].push_back(collision.globalIndex()); + } + } + + // simple inspection of grouped duplicates + for (size_t iV0 = 0; iV0 < v0tableGrouped.size(); iV0++) { + // base QA histograms + histos.fill(HIST("hDuplicateCount"), v0tableGrouped[iV0].collisionIds.size()); + if (v0tableGrouped[iV0].v0Type == 7) { + histos.fill(HIST("hDuplicateCountType7"), v0tableGrouped[iV0].collisionIds.size()); + } + + // Monte Carlo exclusive: process + auto pTrack = tracks.rawIteratorAt(v0tableGrouped[iV0].posTrackId); + auto nTrack = tracks.rawIteratorAt(v0tableGrouped[iV0].negTrackId); + bool pTrackTPCOnly = (pTrack.hasTPC() && !pTrack.hasITS() && !pTrack.hasTRD() && !pTrack.hasTOF()); + bool nTrackTPCOnly = (nTrack.hasTPC() && !nTrack.hasITS() && !nTrack.hasTRD() && !nTrack.hasTOF()); + + if (v0tableGrouped[iV0].v0Type == 7 && pTrackTPCOnly && nTrackTPCOnly) { + histos.fill(HIST("hDuplicateCountType7allTPConly"), v0tableGrouped[iV0].collisionIds.size()); + } + + int pTrackLabel = pTrack.mcParticleId(); + int nTrackLabel = nTrack.mcParticleId(); + int v0Label = findMotherFromLabels(pTrackLabel, nTrackLabel, -11, 11, 22, mcParticles); + int correctMcCollision = -1; + if (v0Label > -1) { + // this mc particle exists and is a gamma + auto mcV0 = mcParticles.rawIteratorAt(v0Label); + correctMcCollision = mcV0.mcCollisionId(); + + histos.fill(HIST("hPhotonPt"), mcV0.pt()); + + if (mcCollToColl[mcV0.mcCollisionId()].size() > 0) { + histos.fill(HIST("hPhotonPt_withRecoedMcCollision"), mcV0.pt()); + } + + bool hasCorrectCollisionCopy = false; + for (size_t ic = 0; ic < v0tableGrouped[iV0].collisionIds.size(); ic++) { + for (size_t imcc = 0; imcc < mcCollToColl[mcV0.mcCollisionId()].size(); imcc++) { + if (v0tableGrouped[iV0].collisionIds[ic] == mcCollToColl[mcV0.mcCollisionId()][imcc]) { + hasCorrectCollisionCopy = true; + } + } + } + + if (hasCorrectCollisionCopy) { + histos.fill(HIST("hPhotonPt_withCorrectCollisionCopy"), mcV0.pt()); + } + + std::vector v0duplicates; // Vector of v0 candidate duplicates + std::vector v0duplicatesCorrectlyAssociated; + + // de-duplication strategy tests start here + // store best-of index for cross-checking strict de-duplication techniques + + float bestPointingAngle = .99; + float bestDCADaughters = 1e+6; + float bestDCADaughters3D = 1e+6; + float bestDCADaughtersXY = 1e+6; + float bestDCADaughtersZ = 1e+6; + + bool bestPointingAngleCorrect = false; + bool bestDCADaughtersCorrect = false; + bool bestDCADaughters3DCorrect = false; + bool bestDCADaughtersXYCorrect = false; + bool bestDCADaughtersZCorrect = false; + + // START OF MAIN DUPLICATE LOOP IS HERE + for (size_t ic = 0; ic < v0tableGrouped[iV0].collisionIds.size(); ic++) { + // simple duplicate accounting + histos.fill(HIST("hPhotonPt_Duplicates"), mcV0.pt()); + + // check if candidate is correctly associated + bool correctlyAssociated = false; + for (size_t imcc = 0; imcc < mcCollToColl[correctMcCollision].size(); imcc++) { + if (v0tableGrouped[iV0].collisionIds[ic] == mcCollToColl[correctMcCollision][imcc]) { + correctlyAssociated = true; + } + } + // store check for correct association + v0duplicatesCorrectlyAssociated.push_back(correctlyAssociated); + + // actually treat tracks + auto posTrackPar = getTrackParCov(pTrack); + auto negTrackPar = getTrackParCov(nTrack); + + auto const& collision = collisions.rawIteratorAt(v0tableGrouped[iV0].collisionIds[ic]); + + // handle TPC-only tracks properly (photon conversions) + if (v0BuilderOpts.moveTPCOnlyTracks) { + bool isPosTPCOnly = (pTrack.hasTPC() && !pTrack.hasITS() && !pTrack.hasTRD() && !pTrack.hasTOF()); + if (isPosTPCOnly) { + // Nota bene: positive is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + + if (!mVDriftMgr.moveTPCTrack>(collision, pTrack, posTrackPar)) { + return; + } + } + + bool isNegTPCOnly = (nTrack.hasTPC() && !nTrack.hasITS() && !nTrack.hasTRD() && !nTrack.hasTOF()); + if (isNegTPCOnly) { + // Nota bene: negative is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + + if (!mVDriftMgr.moveTPCTrack>(collision, nTrack, negTrackPar)) { + return; + } + } + } // end TPC drift treatment + + // process candidate with helper + bool buildOK = straHelper.buildV0Candidate(v0tableGrouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false); + + v0duplicates.push_back(straHelper.v0); + + float daughterDCA3D = std::hypot( + straHelper.v0.positivePosition[0] - straHelper.v0.negativePosition[0], + straHelper.v0.positivePosition[1] - straHelper.v0.negativePosition[1], + straHelper.v0.positivePosition[2] - straHelper.v0.negativePosition[2]); + float daughterDCAXY = std::hypot( + straHelper.v0.positivePosition[0] - straHelper.v0.negativePosition[0], + straHelper.v0.positivePosition[1] - straHelper.v0.negativePosition[1]); + float daughterDCAZ = std::abs( + straHelper.v0.positivePosition[2] - straHelper.v0.negativePosition[2]); + + if (!buildOK) { + daughterDCA3D = daughterDCAXY = daughterDCAZ = 1e+6; + } + + histos.fill(HIST("hPA_All"), straHelper.v0.pointingAngle); + histos.fill(HIST("hPAvsPt_All"), mcV0.pt(), straHelper.v0.pointingAngle); + histos.fill(HIST("hDCADaughtersvsPt_All"), mcV0.pt(), straHelper.v0.daughterDCA); + histos.fill(HIST("hDCADaughters3DvsPt_All"), mcV0.pt(), daughterDCA3D); + histos.fill(HIST("hDCADaughtersXYvsPt_All"), mcV0.pt(), daughterDCAXY); + histos.fill(HIST("hDCADaughtersZvsPt_All"), mcV0.pt(), daughterDCAZ); + + if (correctlyAssociated) { + histos.fill(HIST("hPA_Correct"), straHelper.v0.pointingAngle); + histos.fill(HIST("hPAvsPt_Correct"), mcV0.pt(), straHelper.v0.pointingAngle); + histos.fill(HIST("hDCADaughtersvsPt_Correct"), mcV0.pt(), straHelper.v0.daughterDCA); + histos.fill(HIST("hDCADaughters3DvsPt_Correct"), mcV0.pt(), daughterDCA3D); + histos.fill(HIST("hDCADaughtersXYvsPt_Correct"), mcV0.pt(), daughterDCAXY); + histos.fill(HIST("hDCADaughtersZvsPt_Correct"), mcV0.pt(), daughterDCAZ); + } + + // check criteria + if (straHelper.v0.pointingAngle < bestPointingAngle) { + bestPointingAngle = straHelper.v0.pointingAngle; + bestPointingAngleCorrect = correctlyAssociated; + } + if (straHelper.v0.daughterDCA < bestDCADaughters) { + bestDCADaughters = straHelper.v0.daughterDCA; + bestDCADaughtersCorrect = correctlyAssociated; + } + if (daughterDCA3D < bestDCADaughters3D) { + bestDCADaughters3D = daughterDCA3D; + bestDCADaughters3DCorrect = correctlyAssociated; + } + if (daughterDCAXY < bestDCADaughtersXY) { + bestDCADaughtersXY = daughterDCAXY; + bestDCADaughtersXYCorrect = correctlyAssociated; + } + if (daughterDCAZ < bestDCADaughtersZ) { + bestDCADaughtersZ = daughterDCAZ; + bestDCADaughtersZCorrect = correctlyAssociated; + } + } // end duplicate loop + + if (hasCorrectCollisionCopy) { + // check individual criteria for winner-is-correct + if (bestPointingAngleCorrect) { + histos.fill(HIST("hCorrect_BestPA"), mcV0.pt()); + } + if (bestDCADaughtersCorrect) { + histos.fill(HIST("hCorrect_BestDCADau"), mcV0.pt()); + } + if (bestDCADaughters3DCorrect) { + histos.fill(HIST("hCorrect_BestDCADau3D"), mcV0.pt()); + } + if (bestDCADaughtersXYCorrect) { + histos.fill(HIST("hCorrect_BestDCADauXY"), mcV0.pt()); + } + if (bestDCADaughtersZCorrect) { + histos.fill(HIST("hCorrect_BestDCADauZ"), mcV0.pt()); + } + if (bestPointingAngleCorrect && bestDCADaughtersZCorrect) { + histos.fill(HIST("hCorrect_BestPAandDCADau3D"), mcV0.pt()); + } + } + + // printout for inspection + // TString cosPAString = ""; + // for (size_t iCollisionId = 0; iCollisionId < v0tableGrouped[iV0].collisionIds.size(); iCollisionId++) { + // cosPAString.Append(Form("%.5f ", v0duplicates[iCollisionId].pointingAngle)); + // } + // LOGF(info, "#%i (p,n) = (%i,%i), type %i, point. angles: %s", iV0, v0tableGrouped[iV0].posTrackId, v0tableGrouped[iV0].negTrackId, v0tableGrouped[iV0].v0Type, cosPAString.Data()); + } // end this-is-a-mc-gamma check + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Resonances/CMakeLists.txt b/PWGLF/Tasks/Resonances/CMakeLists.txt index 3982955c885..a1fea7646a2 100644 --- a/PWGLF/Tasks/Resonances/CMakeLists.txt +++ b/PWGLF/Tasks/Resonances/CMakeLists.txt @@ -25,7 +25,7 @@ o2physics_add_dpl_workflow(k892analysis COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(k892analysispbpb - SOURCES k892analysis_PbPb.cxx + SOURCES k892analysispbpb.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -39,16 +39,36 @@ o2physics_add_dpl_workflow(k892pmanalysis PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(lambda1405analysis + SOURCES lambda1405analysis.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(lambda1520analysis SOURCES lambda1520analysis.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(lambda1520analysisinpp + SOURCES lambda1520analysisinpp.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(lambda1520analysisinoo + SOURCES lambda1520analysisinOO.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(k1analysis SOURCES k1analysis.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(k1analysismicro + SOURCES k1AnalysisMicro.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(phianalysisrun3 SOURCES phianalysisrun3.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -134,6 +154,11 @@ o2physics_add_dpl_workflow(kstarpbpb PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(lstarpbpbv2 + SOURCES lstarpbpbv2.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(xi1530analysis SOURCES xi1530Analysis.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -151,7 +176,7 @@ o2physics_add_dpl_workflow(kaonkaonanalysis o2physics_add_dpl_workflow(highmasslambda SOURCES highmasslambda.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(lambdav2 @@ -165,7 +190,7 @@ o2physics_add_dpl_workflow(highmasslambdasvx COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(chk892flow - SOURCES chk892flow.cxx + SOURCES chk892Flow.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -187,4 +212,29 @@ o2physics_add_dpl_workflow(kshortlambda o2physics_add_dpl_workflow(rho770analysis SOURCES rho770analysis.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(kstarpbpbv1 + SOURCES kstarFlowv1.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(heptaquark + SOURCES heptaquark.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(double-resonance-scan + SOURCES doubleResonanceScan.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(kstar-in-oo + SOURCES kstarInOO.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + + o2physics_add_dpl_workflow(phioo + SOURCES phiOO.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx b/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx index 9daeae66180..536d7a2d030 100644 --- a/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx +++ b/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx @@ -8,29 +8,18 @@ // 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. -/// -/// \brief this is a code for the CKS resonance -/// \author prottay das -/// \since 13/01/2024 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "TF1.h" +/// \file chargedkstaranalysis.cxx +/// \brief Reconstruction of track-track decay resonance candidates +/// +/// +/// \author Protay +/// \author Navneet -#include -#include -#include +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/Utils/collisionCuts.h" -#include "CCDB/BasicCCDBManager.h" -#include "CCDB/CcdbApi.h" +#include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" @@ -38,1280 +27,913 @@ #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" #include "CommonConstants/PhysicsConstants.h" +#include "DCAFitter/DCAFitterN.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/StaticFor.h" #include "Framework/StepTHn.h" #include "Framework/runDataProcessing.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" #include "ReconstructionDataFormats/Track.h" -// For charged kstarpp analysis -#include "PWGLF/DataModel/LFResonanceTables.h" +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TRandom3.h" +#include "TVector2.h" +// #include // FIXME +#include +#include +#include +#include +#include +#include +#include +#include +#include // FIXME + +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -using std::array; +using namespace o2::constants::physics; struct chargedkstaranalysis { + SliceCache cache; + Preslice perCollision = aod::track::collisionId; - // Connect to ccdb - Service ccdb; - Configurable nolaterthan{ - "ccdb-no-later-than", - std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count(), - "latest acceptable timestamp of creation for the object"}; - Configurable url{"ccdb-url", "http://ccdb-test.cern.ch:8080", - "url of the ccdb repository"}; + using EventCandidates = soa::Join; + // using EventCandidates = soa::Join; + // using TrackCandidates = soa::Join; + // using TrackCandidates = soa::Join; + using TrackCandidates = soa::Join; + using V0Candidates = aod::V0Datas; - SliceCache cache; + using MCEventCandidates = soa::Join; + using MCTrackCandidates = soa::Join; + using MCV0Candidates = soa::Join; - // For charged Kstarpp analysis use Resonance Initalizer and THnSparse - ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0., 1., 5., 10., 30., 50., 70., 100., 110.}, "Binning of the centrality axis"}; - ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; - ConfigurableAxis Etabins{"Etabins", {VARIABLE_WIDTH, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}, "Eta Binning"}; - Configurable cDCABinsQA{"cDCABinsQA", 150, "DCA binning"}; - ConfigurableAxis binsPtQA{"binsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0}, "Binning of the pT axis"}; - - HistogramRegistry histos1{"histos1", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - - // Histograms are defined with HistogramRegistry - HistogramRegistry rEventSelection{"eventSelection", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - HistogramRegistry histos{ - "histos", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - - HistogramRegistry rGenParticles{"genParticles", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rRecParticles{"recParticles", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - - // Pre-selection cuts - Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minimum pt cut"}; - /// PID Selections - Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; // Combined + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - // DCAr to PV - Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; - // DCAz to PV - Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; - // Track selections - Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz - Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) - Configurable cfgPVContributor{"cfgPVContributor", true, "PV contributor track selection"}; // PV Contributor - // V0 selections - Configurable cV0MinCosPA{"cV0MinCosPA", 0.97, "V0 minimum pointing angle cosine"}; - Configurable cV0MaxDaughDCA{"cV0MaxDaughDCA", 1.0, "V0 daughter DCA Maximum"}; - // Competing V0 rejection - Configurable cV0MassWindow{"cV0MassWindow", 0.0043, "Mass window for competing Lambda0 rejection"}; - Configurable cInvMassStart{"cInvMassStart", 0.6, "Invariant mass start"}; - Configurable cInvMassEnd{"cInvMassEnd", 1.5, "Invariant mass end"}; - Configurable cInvMassBins{"cInvMassBins", 900, "Invariant mass binning"}; - - // Event mixing Configurable nEvtMixing{"nEvtMixing", 5, "Number of events to mix"}; - ConfigurableAxis CfgVtxBins{"CfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; - ConfigurableAxis CfgMultBins{"CfgMultBins", {VARIABLE_WIDTH, 0., 1., 5., 10., 30., 50., 70., 100., 110.}, "Mixing bins - multiplicity"}; - Configurable cTpcNsigmaPionBinsQA{"cTpcNsigmaPionBinsQA", 140, "tpcNSigmaPi binning"}; - - // Configurable for histograms - Configurable nBins{"nBins", 100, "N bins in all histos"}; - - // Confugrable for QA histograms - Configurable QAbefore{"QAbefore", false, "QAbefore"}; - Configurable QAafter{"QAafter", false, "QAafter"}; - Configurable QAv0{"QAv0", false, "QAv0"}; - - // Configurable for event selection - Configurable cutzvertex{"cutzvertex", 10.0f, - "Accepted z-vertex range (cm)"}; - - // Configurable parameters for V0 selection - Configurable ConfV0PtMin{"ConfV0PtMin", 0.f, - "Minimum transverse momentum of V0"}; - Configurable ConfV0DCADaughMax{"ConfV0DCADaughMax", 1.0f, - "Maximum DCA between the V0 daughters"}; - Configurable ConfV0CPAMin{"ConfV0CPAMin", 0.985f, "Minimum CPA of V0"}; - Configurable ConfV0TranRadV0Min{"ConfV0TranRadV0Min", 0.5f, - "Minimum transverse radius"}; - Configurable ConfV0TranRadV0Max{"ConfV0TranRadV0Max", 200.f, - "Maximum transverse radius"}; - Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 15, - "Maximum V0 life time"}; - Configurable cMaxV0DCA{"cMaxV0DCA", 0.3, "DCA V0 to PV"}; - Configurable cSigmaMassKs0{"cSigmaMassKs0", 4, - "n Sigma cut on KS0 mass"}; - Configurable cWidthKs0{"cWidthKs0", 0.005, "Width of KS0"}; - - Configurable ConfDaughEta{"ConfDaughEta", 0.8f, - "V0 Daugh sel: max eta"}; - Configurable ConfDaughTPCnclsMin{"ConfDaughTPCnclsMin", 70.f, - "V0 Daugh sel: Min. nCls TPC"}; - Configurable ConfDaughDCAMin{ - "ConfDaughDCAMin", 0.06f, "V0 Daugh sel: Max. DCA Daugh to PV (cm)"}; - Configurable ConfDaughPIDCuts{"ConfDaughPIDCuts", 4, - "PID selections for KS0 daughters"}; - - // Configurables for track selections - Configurable cfgCutPT{"cfgCutPT", 0.2f, "PT cut on daughter track"}; - Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta cut on daughter track"}; - Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, - "DCAxy range for tracks"}; - Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; - Configurable nsigmaCutTPC{"nsigmacutTPC", 3.0, - "Value of the TPC Nsigma cut"}; - Configurable nsigmaCutTOF{"nsigmacutTOF", 3.0, - "Value of the TOF Nsigma cut"}; - Configurable nsigmaCutCombined{"nsigmaCutCombined", 3.0, - "Value of the Combined Nsigma cut"}; - Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 5, - "Number of mixed events per event"}; - Configurable cfgMultFT0{"cfgMultFT0", false, "cfgMultFT0"}; - Configurable cfgCentFT0C{"cfgCentFT0C", true, "cfgCentFT0C"}; - Configurable iscustomDCAcut{"iscustomDCAcut", false, "iscustomDCAcut"}; - Configurable ismanualDCAcut{"ismanualDCAcut", true, "ismanualDCAcut"}; - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; - Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; - Configurable isMC{"isMC", true, "Run MC"}; - Configurable avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"}; - Configurable isNoTOF{"isNoTOF", false, "isNoTOF"}; - Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; - Configurable TVXEvsel{"TVXEvsel", false, "Triggger selection"}; - Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; - - // Event selection cuts - Alex - TF1* fMultPVCutLow = nullptr; - TF1* fMultPVCutHigh = nullptr; - TF1* fMultCutLow = nullptr; - TF1* fMultCutHigh = nullptr; - TF1* fMultMultPVCut = nullptr; - - void init(InitContext const&) - { - AxisSpec dcaxyAxisQA = {cDCABinsQA, 0.0, 3.0, "DCA_{#it{xy}} (cm)"}; - AxisSpec dcazAxisQA = {cDCABinsQA, 0.0, 3.0, "DCA_{#it{xy}} (cm)"}; - AxisSpec ptAxisQA = {binsPtQA, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec tpcNSigmaPiAxisQA = {cTpcNsigmaPionBinsQA, -7.0, 7.0, "N#sigma_{TPC}"}; - - AxisSpec centAxis = {binsCent, "V0M (%)"}; - AxisSpec ptAxis = {binsPt, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec invMassAxis = {cInvMassBins, cInvMassStart, cInvMassEnd, "Invariant Mass (GeV/#it{c}^2)"}; - AxisSpec etaAxis = {Etabins, "#eta"}; - AxisSpec goodTrackCountAxis = {3, 0., 3., "Passed track = 1, Passed V0 = 2, Passed track and V0 = 3"}; - // register histograms - histos1.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{nBins, -15., 15.}}); - histos1.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); - // Multiplicity and accepted events QA - histos1.add("QAbefore/collMult", "Collision multiplicity", HistType::kTH1F, {centAxis}); - // QA before - histos1.add("QAbefore/pi_Eta", "Primary pion track eta", kTH1F, {etaAxis}); - histos1.add("QAbefore/k0s_Eta", "K0short track eta", kTH1F, {etaAxis}); - histos1.add("QAbefore/chargedkstarpmRapidity", "Reconstructed K*^{#pm} rapidity", kTH1F, {etaAxis}); - - histos1.add("QAbefore/DCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {dcaxyAxisQA}); - histos1.add("QAbefore/DCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH1F, {dcazAxisQA}); - histos1.add("QAbefore/pT_pi", "pT distribution of pion track candidates", kTH1F, {ptAxisQA}); - histos1.add("QAbefore/tpcNsigmaPionQA", "NsigmaTPC distribution of primary pion candidates", kTH2F, {ptAxisQA, tpcNSigmaPiAxisQA}); - - // QA after - histos1.add("QAAfter/DCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {dcaxyAxisQA}); - histos1.add("QAAfter/DCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH1F, {dcazAxisQA}); - histos1.add("QAAfter/pT_pi", "pT distribution of pion track candidates", kTH1F, {ptAxisQA}); - histos1.add("QAAfter/tpcNsigmaPionQA", "NsigmaTPC distribution of primary pion candidates", kTH2F, {ptAxisQA, tpcNSigmaPiAxisQA}); - histos1.add("QAAfter/pi_Eta", "Primary pion track eta", kTH1F, {etaAxis}); - - // Good tracks and V0 counts QA - histos1.add("QAafter/hGoodTracksV0s", "Number of good track and V0 passed", kTH1F, {goodTrackCountAxis}); - histos1.add("chargedkstarinvmassUlikeSign", "Invariant mass of charged K*(892)", kTH1F, {invMassAxis}); - histos1.add("chargedkstarinvmassMixedEvent", "Invariant mass of charged K*(892)", kTH1F, {invMassAxis}); - - // Mass vs Pt vs Multiplicity 3-dimensional histogram - // histos1.add("chargekstarMassPtMult", "Charged K*(892) mass vs pT vs V0 multiplicity distribution", kTH3F, {invMassAxis, ptAxis, centAxis}); - - histos1.add("chargekstarMassPtMultPtUnlikeSign", - "Invariant mass of CKS meson Unlike Sign", kTHnSparseF, - {invMassAxis, ptAxis, centAxis}, true); - histos1.add("chargekstarMassPtMultPtMixedEvent", - "Invariant mass of CKS meson MixedEvent Sign", kTHnSparseF, - {invMassAxis, ptAxis, centAxis}, true); - - // Axes - AxisSpec K0ShortMassAxis = {200, 0.45f, 0.55f, - "#it{M}_{inv} [GeV/#it{c}^{2}]"}; - AxisSpec vertexZAxis = {nBins, -10., 10., "vrtx_{Z} [cm]"}; - AxisSpec multAxis = {100, 0.0f, 100.0f, "Multiplicity"}; - - // Histograms - // Event selection - rEventSelection.add("hVertexZRec", "hVertexZRec", - {HistType::kTH1F, {vertexZAxis}}); - rEventSelection.add("hmult", "Centrality distribution", kTH1F, - {{200, 0.0f, 200.0f}}); - - // for primary tracks - if (QAbefore && QAafter) { - histos.add("hNsigmaPionTPC_before", "NsigmaPion TPC distribution before", - kTH1F, {{200, -10.0f, 10.0f}}); - histos.add("hNsigmaPionTOF_before", "NsigmaPion TOF distribution before", - kTH1F, {{200, -10.0f, 10.0f}}); - - histos.add("hEta_after", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); - histos.add("hDcaxy_after", "Dcaxy distribution", kTH1F, - {{200, -10.0f, 10.0f}}); - histos.add("hDcaz_after", "Dcaz distribution", kTH1F, - {{200, -10.0f, 10.0f}}); - histos.add("hNsigmaPionTPC_after", "NsigmaPion TPC distribution", kTH1F, - {{200, -10.0f, 10.0f}}); - histos.add("hNsigmaPionTOF_after", "NsigmaPion TOF distribution", kTH1F, - {{200, -10.0f, 10.0f}}); - } + ConfigurableAxis cfgvtxbins{"cfgvtxbins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgmultbins{"cfgmultbins", {VARIABLE_WIDTH, 0., 1., 5., 10., 30., 50., 70., 100., 110.}, "Mixing bins - multiplicity"}; - if (QAv0) { - // K0s reconstruction - histos.add( - "hMassvsptvsmult", "hMassvsptvsmult", - {HistType::kTHnSparseF, {{K0ShortMassAxis}, {ptAxis}, {multAxis}}}, - true); - // K0s topological/PID cuts - histos.add("hDCAV0Daughters", "hDCAV0Daughters", - {HistType::kTH1F, {{50, 0.0f, 5.0f}}}); - histos.add("hLT", "hLT", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); - histos.add("hV0CosPA", "hV0CosPA", - {HistType::kTH1F, {{100, 0.95f, 1.f}}}); - } + Service ccdb; + Service pdg; + o2::ccdb::CcdbApi ccdbApi; - // histos.add("counter", "counter", {HistType::kTH1F, {{10, 0.0f, 10.0f}}}); - - // CKStar histograms - histos.add("h3CKSInvMassUnlikeSign", - "Invariant mass of CKS meson Unlike Sign", kTHnSparseF, - {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {90, 0.6, 1.5}}, true); - histos.add("h3CKSInvMassMixed", "Invariant mass of CKS meson Mixed", - kTHnSparseF, - {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {90, 0.6, 1.5}}, true); - - if (isMC) { - rGenParticles.add("hMC", "Gen MC Event statistics", kTH1F, {{10, 0.0f, 10.0f}}); - rGenParticles.add("hCentGen", "Gen MC Event centrality", kTH1F, {{100, 0.0f, 100.0f}}); - rRecParticles.add("hCentRec", "Rec MC Event centrality", kTH1F, {{100, 0.0f, 100.0f}}); - rRecParticles.add("hMCRec", "Rec MC Event statistics", kTH1F, {{10, 0.0f, 10.0f}}); - rGenParticles.add("hPtK0ShortGen", "hPtK0ShortGen", {HistType::kTH1F, {{ptAxis}}}); - // rGenParticles.add("hCKSGen", "hCKSGen", {HistType::kTH1F, {{ptAxis}}}); - // rRecParticles.add("hCKSRec", "hCKSRec", {HistType::kTH1F, {{ptAxis}}}); - - rGenParticles.add("hCKSGen", - "Invariant mass of CKS meson Gen", kTHnSparseF, - {{200, 0.0, 20.0}, {100, 0.0f, 100.0f}}, true); - rRecParticles.add("hCKSRec", - "Invariant mass of CKS meson Rec", kTHnSparseF, - {{200, 0.0, 20.0}, {100, 0.0f, 100.0f}}, true); - } + Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; - // Event selection cut additional - Alex - if (additionalEvsel) { - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); - fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x)", 0, 100); - fMultCutLow->SetParameters(1893.94, -53.86, 0.502913, -0.0015122, 109.625, -1.19253); - fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x)", 0, 100); - fMultCutHigh->SetParameters(1893.94, -53.86, 0.502913, -0.0015122, 109.625, -1.19253); - fMultMultPVCut = new TF1("fMultMultPVCut", "[0]+[1]*x+[2]*x*x", 0, 5000); - fMultMultPVCut->SetParameters(-0.1, 0.785, -4.7e-05); - } - } + // DCAr to PV + Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 2.0, "Track DCAr cut to PV Maximum"}; + // DCAz to PV + Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; + Configurable cMinDCAzToPVcut{"cMinDCAzToPVcut", 0.0, "Track DCAz cut to PV Minimum"}; + + Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"}; + + Configurable trackSelection{"trackSelection", 0, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQ ualityTracks, 5 -> kInAcceptanceTracks"}; + // + // Filter trackFilter = (trackSelection.node() == 0) || // from tpcSkimsTableCreator + // ((trackSelection.node() == 1) && requireGlobalTrackInFilter()) || + // ((trackSelection.node() == 2) && requireGlobalTrackWoPtEtaInFilter()) || + // ((trackSelection.node() == 3) && requireGlobalTrackWoDCAInFilter()) || + // ((trackSelection.node() == 4) && requireQualityTracksInFilter()) || + // ((trackSelection.node() == 5) && requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks)); + // Filter trackEtaFilter = nabs(aod::track::eta) < cfgCutEta; // Eta cut + // + // Configurables + ConfigurableAxis cfgBinsPt{"cfgBinsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; + ConfigurableAxis cfgBinsPtQA{"cfgBinsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0}, "Binning of the pT axis"}; + ConfigurableAxis cfgBinsCent{"cfgBinsCent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; + ConfigurableAxis cfgBinsVtxZ{"cfgBinsVtxZ", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "Binning of the z-vertex axis"}; + Configurable cNbinsDiv{"cNbinsDiv", 1, "Integer to divide the number of bins"}; + + /// Event cuts + o2::analysis::CollisonCuts colCuts; + Configurable confEvtZvtx{"confEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable confEvtOccupancyInTimeRangeMax{"confEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; + Configurable confEvtOccupancyInTimeRangeMin{"confEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; + Configurable confEvtTriggerCheck{"confEvtTriggerCheck", false, "Evt sel: check for trigger"}; + Configurable confEvtOfflineCheck{"confEvtOfflineCheck", true, "Evt sel: check for offline selection"}; + Configurable confEvtTriggerTVXSel{"confEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; + Configurable confEvtTFBorderCut{"confEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; + Configurable confEvtUseITSTPCvertex{"confEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; + Configurable confEvtZvertexTimedifference{"confEvtZvertexTimedifference", true, "Evt sel: apply Z-vertex time difference"}; + Configurable confEvtPileupRejection{"confEvtPileupRejection", true, "Evt sel: apply pileup rejection"}; + Configurable confEvtNoITSROBorderCut{"confEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + Configurable confincludeCentralityMC{"confincludeCentralityMC", false, "Include centrality in MC"}; + Configurable confEvtCollInTimeRangeStandard{"confEvtCollInTimeRangeStandard", true, "Evt sel: apply NoCollInTimeRangeStandard"}; + + /// Track selections + Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"}; + Configurable cMaxEtacut{"cMaxEtacut", 0.8, "Track maximum eta cut"}; + + Configurable cfgCentEst{"cfgCentEst", 1, "Centrality estimator, 1: FT0C, 2: FT0M"}; - double massPi = TDatabasePDG::Instance() - ->GetParticle(kPiPlus) - ->Mass(); - double massK0s = TDatabasePDG::Instance() - ->GetParticle(kK0Short) - ->Mass(); - double massKa = o2::constants::physics::MassKPlus; - ROOT::Math::PtEtaPhiMVector CKSVector; - - template - bool eventSelected(TCollision collision, const float& centrality) - { - if (collision.alias_bit(kTVXinTRD)) { - // TRD triggered - // return 0; - } - auto multNTracksPV = collision.multNTracksPV(); - if (multNTracksPV < fMultPVCutLow->Eval(centrality)) - return 0; - if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) - return 0; - // if (multTrk < fMultCutLow->Eval(centrality)) - // return 0; - // if (multTrk > fMultCutHigh->Eval(centrality)) - // return 0; - // if (multTrk > fMultMultPVCut->Eval(multNTracksPV)) - // return 0; - - return 1; - } + // DCAr to PV + Configurable cMaxbDCArToPVcut{"cMaxbDCArToPVcut", 0.1, "Track DCAr cut to PV Maximum"}; + // DCAz to PV + Configurable cMaxbDCAzToPVcut{"cMaxbDCAzToPVcut", 0.1, "Track DCAz cut to PV Maximum"}; - template - bool selectionTrack(const T& candidate) - { - if (iscustomDCAcut && - (!candidate.isGlobalTrack() || !candidate.isPVContributor() || - candidate.itsNCls() < cfgITScluster)) { - return false; - } - /* - if (ismanualDCAcut && - (!candidate.isGlobalTrackWoDCA() || !candidate.isPVContributor() || - std::abs(candidate.dcaXY()) > cfgCutDCAxy || - std::abs(candidate.dcaZ()) > cfgCutDCAz || - candidate.itsNCls() < cfgITScluster || candidate.tpcNClsFound() < 70)) { - return false; - } - */ - if (ismanualDCAcut && !(candidate.isGlobalTrackWoDCA() && candidate.isPVContributor() && std::abs(candidate.dcaXY()) < cfgCutDCAxy && std::abs(candidate.dcaZ()) < cfgCutDCAz && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster)) { - return false; - } + /// PID Selections, pion + Configurable cTPConly{"cTPConly", true, "Use only TPC for PID"}; // bool + Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC + Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF + Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; // Combined + Configurable cTOFVeto{"cTOFVeto", true, "TOF Veto, if false, TOF is nessessary for PID selection"}; // TOF Veto - return true; - } + // Track selections + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor - template - bool selectionPID(const T& candidate) + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; + Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; + Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; + Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; + Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; + Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; + Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; + Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; + Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + + // Secondary Selection + Configurable cfgReturnFlag{"cfgReturnFlag", false, "Return Flag for debugging"}; + Configurable cSecondaryRequire{"cSecondaryRequire", true, "Secondary cuts on/off"}; + + Configurable cfgByPassDauPIDSelection{"cfgByPassDauPIDSelection", true, "Bypass Daughters PID selection"}; + Configurable cSecondaryDauDCAMax{"cSecondaryDauDCAMax", 1., "Maximum DCA Secondary daughters to PV"}; + Configurable cSecondaryDauPosDCAtoPVMin{"cSecondaryDauPosDCAtoPVMin", 0.0, "Minimum DCA Secondary positive daughters to PV"}; + Configurable cSecondaryDauNegDCAtoPVMin{"cSecondaryDauNegDCAtoPVMin", 0.0, "Minimum DCA Secondary negative daughters to PV"}; + + Configurable cSecondaryPtMin{"cSecondaryPtMin", 0.f, "Minimum transverse momentum of Secondary"}; + Configurable cSecondaryRapidityMax{"cSecondaryRapidityMax", 0.5, "Maximum rapidity of Secondary"}; + Configurable cSecondaryRadiusMin{"cSecondaryRadiusMin", 1.2, "Minimum transverse radius of Secondary"}; + Configurable cSecondaryCosPAMin{"cSecondaryCosPAMin", 0.995, "Mininum cosine pointing angle of Secondary"}; + Configurable cSecondaryDCAtoPVMax{"cSecondaryDCAtoPVMax", 0.3, "Maximum DCA Secondary to PV"}; + Configurable cSecondaryProperLifetimeMax{"cSecondaryProperLifetimeMax", 20, "Maximum Secondary Lifetime"}; + Configurable cSecondaryMassWindow{"cSecondaryMassWindow", 0.075, "Secondary inv mass selciton window"}; + + // K* selection + Configurable cKstarMaxRap{"cKstarMaxRap", 0.5, "Kstar maximum rapidity"}; + Configurable cKstarMinRap{"cKstarMinRap", -0.5, "Kstar minimum rapidity"}; + + // For rotational background + Configurable fillRotation{"fillRotation", true, "fill rotation"}; + Configurable confMinRot{"confMinRot", 5.0 * o2::constants::math::PI / 6.0, "Minimum of rotation"}; + Configurable confMaxRot{"confMaxRot", 7.0 * o2::constants::math::PI / 6.0, "Maximum of rotation"}; + Configurable nBkgRotations{"nBkgRotations", 9, "Number of rotated copies (background) per each original candidate"}; + + float centrality; + + // PDG code + int kPDGK0s = 310; + int kKstarPlus = static_cast(o2::constants::physics::Pdg::kKPlusStar892); + int kPiPlus = 211; + int kPDGK0 = 311; + + void init(o2::framework::InitContext&) { - - if (candidate.hasTOF() && - (candidate.tofNSigmaPi() * candidate.tofNSigmaPi() + - candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi()) < - (nsigmaCutCombined * nsigmaCutCombined)) { - return true; - } - - if (!candidate.hasTOF() && - std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { - return true; - } - - /* - if (!candidate.hasTOF() && - std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { - return true; - } - else if (candidate.hasTOF() && - std::abs(candidate.tofNSigmaPi()) < nsigmaCutTOF) { - return true; - } - */ - - /* - if (candidate.hasTOF() && - (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + - candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < - (nsigmaCutCombined * nsigmaCutCombined)) { - return true; - } - if (!candidate.hasTOF() && - std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { - return true; - } - */ - - /* - if (!isNoTOF && candidate.hasTOF() && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < (nsigmaCutCombined * nsigmaCutCombined)) { - return true; - } - if (!isNoTOF && !candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { - return true; - } - if (isNoTOF && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { - return true; - } - */ - - return false; + centrality = -999; + + colCuts.setCuts(confEvtZvtx, confEvtTriggerCheck, confEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, confEvtOccupancyInTimeRangeMax, confEvtOccupancyInTimeRangeMin); + colCuts.init(&histos); + colCuts.setTriggerTVX(confEvtTriggerTVXSel); + colCuts.setApplyTFBorderCut(confEvtTFBorderCut); + colCuts.setApplyITSTPCvertex(confEvtUseITSTPCvertex); + colCuts.setApplyZvertexTimedifference(confEvtZvertexTimedifference); + colCuts.setApplyPileupRejection(confEvtPileupRejection); + colCuts.setApplyNoITSROBorderCut(confEvtNoITSROBorderCut); + colCuts.setApplyCollInTimeRangeStandard(confEvtCollInTimeRangeStandard); + + AxisSpec centAxis = {cfgBinsCent, "T0M (%)"}; + AxisSpec vtxzAxis = {cfgBinsVtxZ, "Z Vertex (cm)"}; + AxisSpec ptAxis = {cfgBinsPt, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec ptAxisQA = {cfgBinsPtQA, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec radiusAxis = {50, 0, 5, "Radius (cm)"}; + AxisSpec cpaAxis = {50, 0.95, 1.0, "CPA"}; + AxisSpec tauAxis = {250, 0, 25, "Lifetime (cm)"}; + AxisSpec dcaAxis = {200, 0, 2, "DCA (cm)"}; + AxisSpec dcaxyAxis = {200, 0, 2, "DCA_{#it{xy}} (cm)"}; + AxisSpec dcazAxis = {200, 0, 2, "DCA_{#it{z}} (cm)"}; + AxisSpec yAxis = {100, -1, 1, "Rapidity"}; + AxisSpec invMassAxisK0s = {400 / cNbinsDiv, 0.3, 0.7, "Invariant Mass (GeV/#it{c}^2)"}; // K0s ~497.611 + AxisSpec invMassAxisReso = {900 / cNbinsDiv, 0.5f, 1.4f, "Invariant Mass (GeV/#it{c}^2)"}; // chK(892) ~892 + AxisSpec invMassAxisScan = {150, 0, 1.5, "Invariant Mass (GeV/#it{c}^2)"}; // For selection + AxisSpec pidQAAxis = {130, -6.5, 6.5}; + AxisSpec dataTypeAxis = {9, 0, 9, "Histogram types"}; + AxisSpec mcTypeAxis = {4, 0, 4, "Histogram types"}; + + // THnSparse + AxisSpec mcLabelAxis = {5, -0.5, 4.5, "MC Label"}; + + histos.add("QA/K0sCutCheck", "Check K0s cut", HistType::kTH1D, {AxisSpec{12, -0.5, 11.5, "Check"}}); + + histos.add("QA/before/CentDist", "Centrality distribution", {HistType::kTH1D, {centAxis}}); + histos.add("QA/before/CentDist1", "Centrality distribution", o2::framework::kTH1F, {{110, 0, 110}}); + histos.add("QA/before/VtxZ", "Centrality distribution", {HistType::kTH1D, {vtxzAxis}}); + histos.add("QA/before/hEvent", "Number of Events", HistType::kTH1F, {{1, 0.5, 1.5}}); + + histos.add("QA/trkbpionTPCPIDME", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + + // Bachelor pion + histos.add("QA/before/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/before/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QA/before/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/before/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + histos.add("QA/after/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/after/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QA/after/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/after/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + // Secondary pion 1 + histos.add("QA/before/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QA/before/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/before/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/before/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); + + histos.add("QA/after/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QA/after/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/after/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/after/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); + + // Secondary pion 2 + histos.add("QA/before/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QA/before/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/before/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/before/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); + + histos.add("QA/after/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QA/after/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/after/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/after/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); + + // K0s + histos.add("QA/before/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/before/hDauPosDCAtoPVSecondary", "Pos DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/before/hDauNegDCAtoPVSecondary", "Neg DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/before/hpT_Secondary", "pT distribution of secondary resonance", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/before/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); + histos.add("QA/before/hRadiusSecondary", "Radius distribution of secondary resonance", HistType::kTH1D, {radiusAxis}); + histos.add("QA/before/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); + histos.add("QA/before/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/before/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); + histos.add("QA/before/hPtAsymSecondary", "pT asymmetry distribution of secondary resonance", HistType::kTH1D, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); + histos.add("QA/before/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); + + histos.add("QA/after/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/after/hDauPosDCAtoPVSecondary", "Pos DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/after/hDauNegDCAtoPVSecondary", "Neg DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/after/hpT_Secondary", "pT distribution of secondary resonance", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/after/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); + histos.add("QA/after/hRadiusSecondary", "Radius distribution of secondary resonance", HistType::kTH1D, {radiusAxis}); + histos.add("QA/after/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); + histos.add("QA/after/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/after/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); + histos.add("QA/after/hPtAsymSecondary", "pT asymmetry distribution of secondary resonance", HistType::kTH1D, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); + histos.add("QA/after/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); + + // Kstar + // Invariant mass nSparse + histos.add("QA/before/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); + histos.add("hInvmass_Kstar", "Invariant mass of unlike-sign chK(892)", HistType::kTHnSparseD, {centAxis, ptAxis, invMassAxisReso}); + histos.add("hInvmass_KstarME", "Invariant mass of unlike-sign chK(892)ME", HistType::kTHnSparseD, {centAxis, ptAxis, invMassAxisReso}); + histos.add("hInvmass_KstarRotated", "Invariant mass of unlike-sign chK(892)Rota", HistType::kTHnSparseD, {centAxis, ptAxis, invMassAxisReso}); + + // Mass QA (quick check) + histos.add("QA/before/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); + histos.add("QA/before/kstarinvmass_Mix", "Invariant mass of unlike-sign chK(892) from mixed event", HistType::kTH1D, {invMassAxisReso}); + + histos.add("QA/after/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); + histos.add("QA/after/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); + histos.add("QA/after/kstarinvmass_Mix", "Invariant mass of unlike-sign chK(892) from mixed event", HistType::kTH1D, {invMassAxisReso}); + + if (fillRotation) { + histos.add("hRotation", "hRotation", kTH1F, {{360, 0.0, o2::constants::math::TwoPI}}); + } + // MC + if (doprocessMC) { + + histos.add("QAMC/hEvent", "Number of Events", HistType::kTH1F, {{1, 0.5, 1.5}}); + // Bachelor pion + histos.add("QAMC/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QAMC/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QAMC/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + // Secondary pion 1 + histos.add("QAMC/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QAMC/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QAMC/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + // Secondary pion 2 + histos.add("QAMC/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QAMC/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QAMC/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); + + // Secondary Resonance (K0s cand) + histos.add("QAMC/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QAMC/hDauPosDCAtoPVSecondary", "Pos DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QAMC/hDauNegDCAtoPVSecondary", "Neg DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + + histos.add("QAMC/hpT_Secondary", "pT distribution of secondary resonance", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); + histos.add("QAMC/hRadiusSecondary", "Radius distribution of secondary resonance", HistType::kTH1D, {radiusAxis}); + histos.add("QAMC/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); + histos.add("QAMC/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QAMC/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); + histos.add("QAMC/hPtAsymSecondary", "pT asymmetry distribution of secondary resonance", HistType::kTH1D, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); + histos.add("QAMC/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); + + // K892 + histos.add("QAMC/KstarOA", "Opening angle of chK(892)", HistType::kTH1D, {AxisSpec{100, 0, 3.14, "Opening angle"}}); + histos.add("QAMC/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); + + histos.add("QAMC/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); + histos.add("QAMC/kstarinvmass_noKstar", "Invariant mass of unlike-sign no chK(892)", HistType::kTH1D, {invMassAxisReso}); + + histos.add("hInvmass_Kstar_MC", "Invariant mass of unlike chK(892)", HistType::kTHnSparseD, {centAxis, ptAxis, invMassAxisReso}); + + ccdb->setURL(cfgURL); + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + } + + // Print output histograms statistics + LOG(info) << "Size of the histograms in chK(892) Analysis Task"; + histos.print(); } - template - bool SelectionV0(Collision const& collision, V0 const& candidate, - float multiplicity) + // Track selection + template + bool trackCut(TrackType const& track) { - if (fabs(candidate.dcav0topv()) > cMaxV0DCA) { + // basic track cuts + if (std::abs(track.pt()) < cMinPtcut) return false; - } - - if (TMath::Abs(candidate.yK0Short()) > 0.5) { + if (std::abs(track.eta()) > cMaxEtacut) return false; - } - - const float qtarm = candidate.qtarm(); - const float alph = candidate.alpha(); - float arm = qtarm / alph; - const float pT = candidate.pt(); - const float tranRad = candidate.v0radius(); - const float dcaDaughv0 = candidate.dcaV0daughters(); - const float cpav0 = candidate.v0cosPA(); - float CtauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), - collision.posZ()) * - TDatabasePDG::Instance() - ->GetParticle(kK0Short) - ->Mass(); // FIXME: Get from the common header - float lowmasscutks0 = 0.497 - cWidthKs0 * cSigmaMassKs0; - float highmasscutks0 = 0.497 + cWidthKs0 * cSigmaMassKs0; - // float decayLength = candidate.distovertotmom(collision.posX(), - // collision.posY(), collision.posZ()) * - // RecoDecay::sqrtSumOfSquares(candidate.px(), candidate.py(), - // candidate.pz()); - - if (pT < ConfV0PtMin) { + if (track.itsNCls() < cfgITScluster) return false; - } - if (dcaDaughv0 > ConfV0DCADaughMax) { + if (track.tpcNClsFound() < cfgTPCcluster) return false; - } - if (cpav0 < ConfV0CPAMin) { + if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) return false; - } - if (tranRad < ConfV0TranRadV0Min) { + if (track.itsChi2NCl() >= cfgITSChi2NCl) return false; - } - if (tranRad > ConfV0TranRadV0Max) { + if (track.tpcChi2NCl() >= cfgTPCChi2NCl) return false; - } - if (fabs(CtauK0s) > cMaxV0LifeTime || - candidate.mK0Short() < lowmasscutks0 || - candidate.mK0Short() > highmasscutks0) { + if (cfgHasITS && !track.hasITS()) return false; - } - if (arm < 0.2) { + if (cfgHasTPC && !track.hasTPC()) return false; - } - - if (QAv0) { - histos.fill(HIST("hLT"), CtauK0s); - histos.fill(HIST("hMassvsptvsmult"), candidate.mK0Short(), candidate.pt(), - multiplicity); - histos.fill(HIST("hDCAV0Daughters"), candidate.dcaV0daughters()); - histos.fill(HIST("hV0CosPA"), candidate.v0cosPA()); - } - return true; - } - - template - bool isSelectedV0Daughter(T const& track, float charge, - double nsigmaV0Daughter) - { - const auto eta = track.eta(); - const auto tpcNClsF = track.tpcNClsFound(); - const auto dcaXY = track.dcaXY(); - const auto sign = track.sign(); - - if (!track.hasTPC()) + if (cfgHasTOF && !track.hasTOF()) return false; - if (track.tpcNClsCrossedRows() < 70) + if (cfgUseITSRefit && !track.passedITSRefit()) return false; - if (track.tpcCrossedRowsOverFindableCls() < 0.8) + if (cfgUseTPCRefit && !track.passedTPCRefit()) return false; - - if (charge < 0 && sign > 0) { + if (cfgPVContributor && !track.isPVContributor()) return false; - } - if (charge > 0 && sign < 0) { + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) return false; - } - if (std::abs(eta) > ConfDaughEta) { + if (cfgGlobalTrack && !track.isGlobalTrack()) return false; - } - if (tpcNClsF < ConfDaughTPCnclsMin) { + if (cfgPrimaryTrack && !track.isPrimaryTrack()) return false; - } - if (std::abs(dcaXY) < ConfDaughDCAMin) { + if (std::abs(track.dcaXY()) > cMaxbDCArToPVcut) return false; - } - if (std::abs(nsigmaV0Daughter) > ConfDaughPIDCuts) { + if (std::abs(track.dcaZ()) > cMaxbDCAzToPVcut) return false; - } - return true; } - double massK0 = o2::constants::physics::MassK0Short; - double massPicharged = o2::constants::physics::MassPionCharged; - double massLambda0 = o2::constants::physics::MassLambda; - double massAntiLambda0 = o2::constants::physics::MassLambda0Bar; - // Fill histograms (main function) - template - void fillHistograms(const CollisionType& collision, const TracksType& dTracks, const V0sType& dV0s) - { - // auto multiplicity = collision.cent(); - auto multiplicity = collision.cent(); - histos1.fill(HIST("QAbefore/collMult"), multiplicity); - TLorentzVector lDecayDaughter, lDecayV0, lResonance; - - for (auto track : dTracks) { // loop over all dTracks1 - // if (!trackCut(track1)) - // continue; // track selection and PID selection - // trying to see the information without applying any cut yet //Let's I am trying to reconstruct the charged kstar it is V0s + pion - histos1.fill(HIST("hEta"), track.eta()); - - auto trackId = track.index(); - auto trackptPi = track.pt(); - auto tracketaPi = track.eta(); - - histos1.fill(HIST("QAbefore/pi_Eta"), tracketaPi); - - if (!IsMix) { - // DCA QA (before cuts) - histos1.fill(HIST("QAbefore/DCAxy_pi"), track.dcaXY()); - histos1.fill(HIST("QAbefore/DCAz_pi"), track.dcaZ()); - // Pseudo-rapidity QA (before cuts) - histos1.fill(HIST("QAbefore/pi_Eta"), tracketaPi); - // pT QA (before cuts) - histos1.fill(HIST("QAbefore/pT_pi"), trackptPi); - // TPC PID (before cuts) - histos1.fill(HIST("QAbefore/tpcNsigmaPionQA"), trackptPi, track.tpcNSigmaPi()); - } - - // apply the track cut - if (!trackCutpp(track) || !selectionPIDpp(track)) - continue; - - histos1.fill(HIST("QAafter/hGoodTracksV0s"), 0.5); - - if (!IsMix) { - // DCA QA (before cuts) - histos1.fill(HIST("QAAfter/DCAxy_pi"), track.dcaXY()); - histos1.fill(HIST("QAAfter/DCAz_pi"), track.dcaZ()); - // Pseudo-rapidity QA (before cuts) - histos1.fill(HIST("QAAfter/pi_Eta"), tracketaPi); - // pT QA (before cuts) - histos1.fill(HIST("QAAfter/pT_pi"), trackptPi); - // TPC PID (before cuts) - histos1.fill(HIST("QAAfter/tpcNsigmaPionQA"), trackptPi, track.tpcNSigmaPi()); - } - - for (auto& v0 : dV0s) { - - // Full index policy is needed to consider all possible combinations - if (v0.indices()[0] == trackId || v0.indices()[1] == trackId) - continue; // To avoid combining secondary and primary pions - //// Initialize variables - // trk: Pion, v0: K0s - // apply the track cut - if (!V0Cut(v0)) - continue; - histos1.fill(HIST("QAafter/hGoodTracksV0s"), 1.5); - - lDecayDaughter.SetXYZM(track.px(), track.py(), track.pz(), massPi); - lDecayV0.SetXYZM(v0.px(), v0.py(), v0.pz(), massK0); - lResonance = lDecayDaughter + lDecayV0; - // Counting how many resonances passed - histos1.fill(HIST("QAafter/hGoodTracksV0s"), 2.5); - - // Checking whether the mid-rapidity condition is met - if (abs(lResonance.Rapidity()) > 0.5) - continue; - if constexpr (!IsMix) { - histos1.fill(HIST("chargedkstarinvmassUlikeSign"), lResonance.M()); - // Reconstructed K*(892)pm 3d mass, pt, multiplicity histogram - histos1.fill(HIST("chargekstarMassPtMultPtUnlikeSign"), lResonance.M(), lResonance.Pt(), multiplicity); - - } else { - histos1.fill(HIST("chargedkstarinvmassMixedEvent"), lResonance.M()); - // Reconstructed K*(892)pm 3d mass, pt, multiplicity histogram - histos1.fill(HIST("chargekstarMassPtMultPtMixedEvent"), lResonance.M(), lResonance.Pt(), multiplicity); - } - } - } - } - - template - bool selectionPIDpp(const T& candidate) - { - bool tpcPIDPassed{false}, tofPIDPassed{false}; - if (std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { - tpcPIDPassed = true; - } - if (candidate.hasTOF()) { - if (std::abs(candidate.tofNSigmaPi()) < nsigmaCutTOF) { - tofPIDPassed = true; - } - if ((nsigmaCutCombinedPion > 0) && (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + candidate.tofNSigmaPi() * candidate.tofNSigmaPi() < nsigmaCutCombinedPion * nsigmaCutCombinedPion)) { - tofPIDPassed = true; - } - } else { - tofPIDPassed = true; - } - if (tpcPIDPassed && tofPIDPassed) { - return true; - } - return false; - } - template - bool trackCutpp(const TrackType track) + bool isTrackSelected(TrackType const& track) { - // basic track cuts - if (std::abs(track.pt()) < cMinPtcut) - return false; - if (std::abs(track.eta()) > ConfDaughEta) - return false; - if (std::abs(track.dcaXY()) > cMaxDCArToPVcut) - return false; - if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) - return false; - if (cfgPrimaryTrack && !track.isPrimaryTrack()) + // Track selection + // These are the track selection for the resotracks this cut is to compare the no. of tracks after reso-initializer + // MC case can be handled here + // DCAxy cut + if (std::fabs(track.dcaXY()) > cMaxDCArToPVcut) return false; - if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) - return false; - if (cfgPVContributor && !track.isPVContributor()) + // DCAz cut + if (std::fabs(track.dcaZ()) > cMaxDCAzToPVcut || std::fabs(track.dcaZ()) < cMinDCAzToPVcut) return false; - return true; } - template - bool V0Cut(const V0Type v0) - { - // V0 track cuts - if (std::abs(v0.eta()) > ConfDaughEta) - return false; - if (v0.v0CosPA() < cV0MinCosPA) - return false; - if (v0.daughDCA() > cV0MaxDaughDCA) - return false; - - // apply the competing V0 rejection cut (excluding Lambda0 candidates, massLambdaPDG = 1115.683 MeV/c2) - - if (std::abs(v0.mLambda() - massLambda0) < cV0MassWindow) - return false; - if (std::abs(v0.mAntiLambda() - massAntiLambda0) < cV0MassWindow) - return false; - return true; - } - - // Defining filters for events (event selection) - // Processed events will be already fulfilling the event selection - // requirements - // Filter eventFilter = (o2::aod::evsel::sel8 == true); - Filter posZFilter = (nabs(o2::aod::collision::posZ) < cutzvertex); - Filter posZFilterMC = (nabs(o2::aod::mccollision::posZ) < cutzvertex); - - Filter acceptanceFilter = - (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPT); - Filter DCAcutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && - (nabs(aod::track::dcaZ) < cfgCutDCAz); - - using EventCandidatesMC = soa::Join; - // using EventCandidates = soa::Filtered< - // soa::Join>; - using EventCandidates = soa::Filtered>; - - using TrackCandidates = soa::Filtered>; - using TrackCandidatesMC = soa::Filtered< - soa::Join>; - - using V0TrackCandidatesMC = soa::Join; - using V0TrackCandidate = aod::V0Datas; - - ConfigurableAxis axisVertex{ - "axisVertex", - {20, -10, 10}, - "vertex axis for bin"}; - ConfigurableAxis axisMultiplicityClass{ - "axisMultiplicityClass", - {2, 0, 100}, - "multiplicity percentile for bin"}; - ConfigurableAxis axisMultiplicity{ - "axisMultiplicity", - {2000, 0, 10000}, - "TPC multiplicity for bin"}; - - using BinningTypeTPCMultiplicity = - ColumnBinningPolicy; - // using BinningTypeVertexContributor = - // ColumnBinningPolicy; - using BinningTypeCentralityM = - ColumnBinningPolicy; - using BinningTypeVertexContributor = - ColumnBinningPolicy; - - BinningTypeVertexContributor binningOnPositions{ - {axisVertex, axisMultiplicityClass}, - true}; - - Pair - pair{binningOnPositions, cfgNoMixedEvents, -1, &cache}; - - /* - SameKindPair - pair{binningOnPositions, cfgNoMixedEvents, -1, &cache}; - */ - - void processSE(EventCandidates::iterator const& collision, - TrackCandidates const& tracks, aod::V0Datas const& V0s, - aod::BCs const&) - - /* - void processSE(EventCandidates::iterator const& collision, - TrackCandidates const& tracks, aod::BCs const&) - */ + // PID selection tools + template + bool selectionPIDPion(TrackType const& candidate) { + bool tpcPIDPassed{false}, tofPIDPassed{false}; - if (!collision.sel8()) { - return; - } - - std::vector pions, kaons, kshorts; - std::vector pions2, kaons2; - std::vector PionIndex = {}; - std::vector PionSign = {}; - std::vector PioncollIndex = {}; - std::vector PionIndex2 = {}; - std::vector PionSign2 = {}; - std::vector PioncollIndex2 = {}; - - std::vector KaonIndex = {}; - std::vector KaonSign = {}; - std::vector KaoncollIndex = {}; - std::vector KaonIndex2 = {}; - std::vector KaonSign2 = {}; - std::vector KaoncollIndex2 = {}; - - std::vector V0collIndex = {}; - std::vector KshortPosDaughIndex = {}; - std::vector KshortNegDaughIndex = {}; - /* - float multiplicity = 0.0f; - if (cfgMultFT0) - multiplicity = collision.multZeqFT0A() + collision.multZeqFT0C(); - if (cfgMultFT0 == 0 && cfgCentFT0C == 1) - multiplicity = collision.centFT0C(); - if (cfgMultFT0 == 0 && cfgCentFT0C == 0) - multiplicity = collision.centFT0M(); - */ - float centrality = 0.0f; - centrality = collision.centFT0C(); - - if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - return; - } - - if (TVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { - return; - } - - if (additionalEvsel && !eventSelected(collision, centrality)) { - return; - } - - // Fill the event counter - rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); - rEventSelection.fill(HIST("hmult"), centrality); - - for (auto track1 : tracks) { - /* - if (QAbefore) { - histos.fill(HIST("hNsigmaPionTPC_before"), track1.tpcNSigmaPi()); - histos.fill(HIST("hNsigmaPionTOF_before"), track1.tofNSigmaPi()); - } - */ - if (!selectionPID(track1)) - continue; // for primary particle PID - - if (!selectionTrack(track1)) { - continue; - } - - if (QAafter) { - histos.fill(HIST("hEta_after"), track1.eta()); - histos.fill(HIST("hDcaxy_after"), track1.dcaXY()); - histos.fill(HIST("hDcaz_after"), track1.dcaZ()); - // histos.fill(HIST("hNsigmaPionTPC_after"), track1.tpcNSigmaPi()); - // histos.fill(HIST("hNsigmaPionTOF_after"), track1.tofNSigmaPi()); - } - - ROOT::Math::PtEtaPhiMVector temp1(track1.pt(), track1.eta(), track1.phi(), - massPi); - pions.push_back(temp1); - PionIndex.push_back(track1.globalIndex()); - // PionIndex.push_back(track1.index()); - PioncollIndex.push_back(track1.collisionId()); - PionSign.push_back(track1.sign()); - } - /* - for (auto track2 : tracks) { - - if (!selectionPID(track2)) - continue; // for primary particle PID + if (cTPConly) { - if (!selectionTrack(track2)) { - continue; + if (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { + tpcPIDPassed = true; + } else { + return false; } + tofPIDPassed = true; - ROOT::Math::PtEtaPhiMVector temp2(track2.pt(), track2.eta(), track2.phi(), - massKa); - kaons.push_back(temp2); - //PionIndex.push_back(track1.globalIndex()); - KaonIndex.push_back(track2.index()); - KaoncollIndex.push_back(track2.collisionId()); - KaonSign.push_back(track2.sign()); - } // track loop ends - */ - - for (auto& v0 : V0s) { - - auto postrack = v0.template posTrack_as(); - auto negtrack = v0.template negTrack_as(); - double nTPCSigmaPos[1]{postrack.tpcNSigmaPi()}; - double nTPCSigmaNeg[1]{negtrack.tpcNSigmaPi()}; + } else { - if (!isSelectedV0Daughter(postrack, 1, nTPCSigmaPos[0])) { - continue; - } - if (!isSelectedV0Daughter(negtrack, -1, nTPCSigmaNeg[0])) { - continue; + if (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { + tpcPIDPassed = true; + } else { + return false; } - - if (!SelectionV0(collision, v0, centrality)) { - continue; + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaPi()) < cMaxTOFnSigmaPion) { + tofPIDPassed = true; + } + if ((nsigmaCutCombinedPion > 0) && (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + candidate.tofNSigmaPi() * candidate.tofNSigmaPi() < nsigmaCutCombinedPion * nsigmaCutCombinedPion)) { + tofPIDPassed = true; + } + } else { + if (!cTOFVeto) { + return false; + } + tofPIDPassed = true; } - - ROOT::Math::PtEtaPhiMVector temp2(v0.pt(), v0.eta(), v0.phi(), massK0s); - kshorts.push_back(temp2); - V0collIndex.push_back(v0.collisionId()); - // KshortPosDaughIndex.push_back(postrack.index()); - // KshortNegDaughIndex.push_back(negtrack.index()); - KshortPosDaughIndex.push_back(postrack.globalIndex()); - KshortNegDaughIndex.push_back(negtrack.globalIndex()); } - if (pions.size() != 0 && kshorts.size() != 0) { - // if (pions.size() != 0 && kaons.size() != 0) { - // if (pions.size() != 0 && pions2.size() != 0) { - for (auto ipion = pions.begin(); ipion != pions.end(); ++ipion) { - auto i1 = std::distance(pions.begin(), ipion); - if (PionSign.at(i1) == 0) - continue; - for (auto ikshort = kshorts.begin(); ikshort != kshorts.end(); - ++ikshort) { - // for (auto ikaon = kaons.begin(); ikaon != kaons.end(); - // ++ikaon) { - // for (auto ikshort = pions2.begin(); ikshort != pions2.end(); - // ++ikshort) { - auto i3 = std::distance(kshorts.begin(), ikshort); - // auto i3 = std::distance(kaons.begin(), ikaon); - if (PionIndex.at(i1) == KshortPosDaughIndex.at(i3)) - continue; - if (PionIndex.at(i1) == KshortNegDaughIndex.at(i3)) - continue; - // if (KaonIndex.at(i3) <= PionIndex.at(i1)) - // continue; - if (PioncollIndex.at(i1) != V0collIndex.at(i3)) - continue; - - // if (PionSign.at(i1) * KaonSign.at(i3) >= 0) - // continue; - - CKSVector = pions.at(i1) + kshorts.at(i3); - // CKSVector = pions.at(i1) + kaons.at(i3); - if (TMath::Abs(CKSVector.Rapidity()) < 0.5) { - histos.fill(HIST("h3CKSInvMassUnlikeSign"), centrality, - CKSVector.Pt(), CKSVector.M()); - } - } - } + if (tpcPIDPassed && tofPIDPassed) { + return true; } + return false; } - PROCESS_SWITCH(chargedkstaranalysis, processSE, "Process Same event", false); - - void processME(EventCandidates const& /*collisions*/, - TrackCandidates const& /*tracks*/, V0TrackCandidate const& /*V0s*/) - - /* - void processME(EventCandidates const& collisions, - TrackCandidates const& tracks)*/ + template + bool selectionK0s(CollisionType const& collision, K0sType const& candidate) { - - // histos.fill(HIST("counter"), 1.5); - /* - auto tracksTuple = std::make_tuple(tracks); - //////// currently mixing the event with similar TPC multiplicity //////// - BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicity}, true}; - SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, t - racksTuple, &cache}; - */ - - for (auto& [c1, tracks1, c2, tracks2] : pair) { - - if (!c1.sel8()) { - continue; - } - if (!c2.sel8()) { - continue; - } - - // histos.fill(HIST("counter"), 2.5); - - auto centrality = c1.centFT0C(); - auto centrality2 = c2.centFT0C(); - - if (timFrameEvsel && (!c1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !c2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - continue; - } - - if (TVXEvsel && (!c1.selection_bit(aod::evsel::kIsTriggerTVX) || !c2.selection_bit(aod::evsel::kIsTriggerTVX))) { - continue; - } - - if (additionalEvsel && !eventSelected(c1, centrality)) { - continue; - } - if (additionalEvsel && !eventSelected(c2, centrality2)) { - continue; - } - - for (auto& [t1, t2] : o2::soa::combinations( - o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - - // histos.fill(HIST("counter"), 3.5); - if (!selectionTrack(t1)) - continue; - // histos.fill(HIST("counter"), 4.5); - if (!selectionPID(t1)) - continue; - // histos.fill(HIST("counter"), 5.5); - if (t1.sign() == 0) - continue; - // histos.fill(HIST("counter"), 6.5); - - /*if (!selectionTrack(t2)) - continue; - if (!selectionPID(t2)) - continue; - */ - - if (!SelectionV0(c2, t2, centrality2)) - continue; - - // histos.fill(HIST("counter"), 7.5); - - auto postrack = t2.template posTrack_as(); - auto negtrack = t2.template negTrack_as(); - double nTPCSigmaPos[1]{postrack.tpcNSigmaPi()}; - double nTPCSigmaNeg[1]{negtrack.tpcNSigmaPi()}; - - if (!isSelectedV0Daughter(postrack, 1, nTPCSigmaPos[0])) { - continue; + auto dauDCA = candidate.dcaV0daughters(); + auto dauPosDCAtoPV = candidate.dcapostopv(); + auto dauNegDCAtoPV = candidate.dcanegtopv(); + auto pT = candidate.pt(); + auto rapidity = candidate.yK0Short(); + auto v0Radius = candidate.v0radius(); + auto DCAtoPV = candidate.dcav0topv(); + auto cosPA = candidate.v0cosPA(); + auto PropTauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massK0s; + auto mK0s = candidate.mK0Short(); + + if (cfgReturnFlag) { + bool returnFlag = true; + + if (cSecondaryRequire) { + histos.fill(HIST("QA/K0sCutCheck"), 0); + if (dauDCA > cSecondaryDauDCAMax) { + histos.fill(HIST("QA/K0sCutCheck"), 1); + returnFlag = false; } - // histos.fill(HIST("counter"), 8.5); - if (!isSelectedV0Daughter(negtrack, -1, nTPCSigmaNeg[0])) { - continue; + if (dauPosDCAtoPV < cSecondaryDauPosDCAtoPVMin) { + histos.fill(HIST("QA/K0sCutCheck"), 2); + returnFlag = false; } - // histos.fill(HIST("counter"), 9.5); - - // if (t1.sign() * t2.sign() >= 0) - // continue; - - TLorentzVector pi; - pi.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massPi); - TLorentzVector KSh; - KSh.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massK0s); - - TLorentzVector CKSmix = pi + KSh; - - if (TMath::Abs(CKSmix.Rapidity()) < 0.5) { - histos.fill(HIST("h3CKSInvMassMixed"), centrality, CKSmix.Pt(), - CKSmix.M()); + if (dauNegDCAtoPV < cSecondaryDauNegDCAtoPVMin) { + histos.fill(HIST("QA/K0sCutCheck"), 3); + returnFlag = false; + } + if (pT < cSecondaryPtMin) { + histos.fill(HIST("QA/K0sCutCheck"), 4); + returnFlag = false; + } + if (rapidity > cSecondaryRapidityMax) { + histos.fill(HIST("QA/K0sCutCheck"), 5); + returnFlag = false; + } + if (v0Radius < cSecondaryRadiusMin) { + histos.fill(HIST("QA/K0sCutCheck"), 6); + returnFlag = false; + } + if (DCAtoPV > cSecondaryDCAtoPVMax) { + histos.fill(HIST("QA/K0sCutCheck"), 7); + returnFlag = false; + } + if (cosPA < cSecondaryCosPAMin) { + histos.fill(HIST("QA/K0sCutCheck"), 8); + returnFlag = false; + } + if (PropTauK0s > cSecondaryProperLifetimeMax) { + histos.fill(HIST("QA/K0sCutCheck"), 9); + returnFlag = false; + } + if (std::fabs(mK0s - massK0s) > cSecondaryMassWindow) { + histos.fill(HIST("QA/K0sCutCheck"), 10); + returnFlag = false; } - } - } - } - PROCESS_SWITCH(chargedkstaranalysis, processME, "Process Mixed event", false); + return returnFlag; - void processGenMC(aod::McCollision const& mcCollision, aod::McParticles& mcParticles, const soa::SmallGroups& collisions) - { + } else { + if (std::fabs(mK0s - massK0s) > cSecondaryMassWindow) { + histos.fill(HIST("QA/K0sCutCheck"), 10); + returnFlag = false; + } - if (std::abs(mcCollision.posZ()) < cutzvertex) - rGenParticles.fill(HIST("hMC"), 0.5); - std::vector SelectedEvents(collisions.size()); - int nevts = 0; - auto cent = 0; - for (const auto& collision : collisions) { - // if (!collision.sel8() || std::abs(collision.mcCollision().posZ()) > cutzvertex) { - if (std::abs(collision.mcCollision().posZ()) > cutzvertex) { - continue; - } - rGenParticles.fill(HIST("hMC"), 1.5); - /*if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - continue; - }*/ - if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { - continue; + return returnFlag; } - if (TVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { - continue; - } - rGenParticles.fill(HIST("hMC"), 2.5); - - cent = collision.centFT0C(); - rGenParticles.fill(HIST("hCentGen"), cent); - SelectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); - } - SelectedEvents.resize(nevts); - const auto evtReconstructedAndSelected = std::find(SelectedEvents.begin(), SelectedEvents.end(), mcCollision.globalIndex()) != SelectedEvents.end(); - if (!evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection - return; - } + } else { + if (cSecondaryRequire) { - rGenParticles.fill(HIST("hMC"), 3.5); - for (auto& mcParticle : mcParticles) { - if (std::abs(mcParticle.y()) >= 0.5) { - continue; - } - rGenParticles.fill(HIST("hMC"), 4.5); - if (std::abs(mcParticle.pdgCode()) != 323) { - continue; - } - rGenParticles.fill(HIST("hMC"), 5.5); - auto kDaughters = mcParticle.daughters_as(); - if (kDaughters.size() != 2) { - continue; - } + histos.fill(HIST("QA/K0sCutCheck"), 0); + if (dauDCA > cSecondaryDauDCAMax) { + histos.fill(HIST("QA/K0sCutCheck"), 1); + return false; + } + if (dauPosDCAtoPV < cSecondaryDauPosDCAtoPVMin) { + histos.fill(HIST("QA/K0sCutCheck"), 2); + return false; + } + if (dauNegDCAtoPV < cSecondaryDauNegDCAtoPVMin) { + histos.fill(HIST("QA/K0sCutCheck"), 3); + return false; + } + if (pT < cSecondaryPtMin) { + histos.fill(HIST("QA/K0sCutCheck"), 4); + return false; + } + if (rapidity > cSecondaryRapidityMax) { + histos.fill(HIST("QA/K0sCutCheck"), 5); + return false; + } + if (v0Radius < cSecondaryRadiusMin) { + histos.fill(HIST("QA/K0sCutCheck"), 6); + return false; + } + if (DCAtoPV > cSecondaryDCAtoPVMax) { + histos.fill(HIST("QA/K0sCutCheck"), 7); + return false; + } + if (cosPA < cSecondaryCosPAMin) { + histos.fill(HIST("QA/K0sCutCheck"), 8); + return false; + } + if (PropTauK0s > cSecondaryProperLifetimeMax) { + histos.fill(HIST("QA/K0sCutCheck"), 9); + return false; + } + if (std::fabs(mK0s - massK0s) > cSecondaryMassWindow) { + histos.fill(HIST("QA/K0sCutCheck"), 10); + return false; + } + return true; - rGenParticles.fill(HIST("hMC"), 6.5); - auto daughts = false; - auto daughtp = false; - // int count = 0; - for (auto kCurrentDaughter : kDaughters) { - // LOG(info) << "Daughters PDG:\t" << count<<" "<(); - for (auto kCurrentDaughter2 : kDaughter2) { - if (kCurrentDaughter2.pdgCode() == 310) - daughts = true; - } - } else if (std::abs(kCurrentDaughter.pdgCode()) == 211) { - if (kCurrentDaughter.isPhysicalPrimary() == 1) - daughtp = true; + } else { + if (std::fabs(mK0s - massK0s) > cSecondaryMassWindow) { + histos.fill(HIST("QA/K0sCutCheck"), 10); + return false; } - // count += 1; - } - rGenParticles.fill(HIST("hMC"), 7.5); - if (daughtp && daughts) { - rGenParticles.fill(HIST("hCKSGen"), mcParticle.pt(), cent); + return true; } } - } - - void processRecMC(EventCandidatesMC::iterator const& collision, - TrackCandidatesMC const& tracks, V0TrackCandidatesMC const& V0s, - aod::McParticles const& /*mcParticles*/, aod::McCollisions const& /*mcCollisions*/) + } // selectionK0s + template + bool isTrueKstar(const TrackTemplate& bTrack, const V0Template& K0scand) { + if (std::abs(bTrack.PDGCode()) != kPiPlus) // Are you pion? + return false; + if (std::abs(K0scand.PDGCode()) != kPDGK0s) // Are you K0s? + return false; - if (!collision.has_mcCollision()) { - return; - } - // if (std::abs(collision.mcCollision().posZ()) > cutzvertex || !collision.sel8()) { - if (std::abs(collision.mcCollision().posZ()) > cutzvertex) { - return; - } - - rRecParticles.fill(HIST("hMCRec"), 0.5); + auto motherbTrack = bTrack.template mothers_as(); + auto motherkV0 = K0scand.template mothers_as(); - // if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { - return; - } - if (TVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { - return; - } + // Check bTrack first + if (std::abs(motherbTrack.pdgCode()) != kKstarPlus) // Are you charged Kstar's daughter? + return false; // Apply first since it's more restrictive - auto cent = 0; - cent = collision.centFT0C(); + if (std::abs(motherkV0.pdgCode()) != kPDGK0) // Is it K0s? + return false; + // Check if K0s's mother is K0 (311) + auto motherK0 = motherkV0.template mothers_as(); + if (std::abs(motherK0.pdgCode()) != kPDGK0) + return false; - rRecParticles.fill(HIST("hMCRec"), 1.5); - rRecParticles.fill(HIST("hCentRec"), cent); + // Check if K0's mother is Kstar (323) + auto motherKstar = motherK0.template mothers_as(); + if (std::abs(motherKstar.pdgCode()) != kKstarPlus) + return false; - float centrality = 0.0f; - auto oldindex = -999; + // Check if bTrack and K0 have the same mother (global index) + if (motherbTrack.globalIndex() != motherK0.globalIndex()) + return false; - for (auto track1 : tracks) { + return true; + } - if (!selectionPID(track1)) - continue; // for primary particle PID + int count = 0; + double massPi = o2::constants::physics::MassPionCharged; + double massK0s = o2::constants::physics::MassK0Short; - if (!track1.has_mcParticle()) { + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksTypeK0s& dTracks2) + { + histos.fill(HIST("QA/before/CentDist"), collision.centFT0M()); + histos.fill(HIST("QA/before/CentDist1"), collision.centFT0M()); + ROOT::Math::PxPyPzMVector lDecayDaughter1, lDecayDaughter2, lResoSecondary, lDecayDaughter_bach, lResoKstar, chargekstarrot; + std::vector trackIndicies = {}; + std::vector k0sIndicies = {}; + + for (const auto& bTrack : dTracks1) { + auto trkbpt = bTrack.pt(); + auto istrkbhasTOF = bTrack.hasTOF(); + auto trkbNSigmaPiTPC = bTrack.tpcNSigmaPi(); + auto trkbNSigmaPiTOF = (istrkbhasTOF) ? bTrack.tofNSigmaPi() : -999.; + + if (!isTrackSelected(bTrack)) continue; - } + if constexpr (!IsMix) { + // Bachelor pion QA plots + histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); + } else { - if (!selectionTrack(track1)) { - continue; + histos.fill(HIST("QA/trkbpionTPCPIDME"), trkbpt, trkbNSigmaPiTPC); } - auto mctrack1 = track1.mcParticle(); - - if (!mctrack1.isPhysicalPrimary()) { + if (!trackCut(bTrack)) + continue; + if (!selectionPIDPion(bTrack)) continue; - } - - for (auto& v0 : V0s) { - if (!v0.has_mcParticle()) { - continue; + if constexpr (!IsMix) { + // Bachelor pion QA plots after applying cuts + histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); } - - auto postrack = v0.template posTrack_as(); - auto negtrack = v0.template negTrack_as(); - - if (!postrack.has_mcParticle()) - continue; // Checking that the daughter tracks come from particles and are not fake - if (!negtrack.has_mcParticle()) // Checking that the daughter tracks come from particles and are not fake - continue; - - // auto posParticle = postrack.mcParticle(); - // auto negParticle = negtrack.mcParticle(); - - double nTPCSigmaPos[1]{postrack.tpcNSigmaPi()}; - double nTPCSigmaNeg[1]{negtrack.tpcNSigmaPi()}; - - if (!isSelectedV0Daughter(postrack, 1, nTPCSigmaPos[0])) { - continue; + histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); + } + trackIndicies.push_back(bTrack.index()); + } + + for (const auto& K0scand : dTracks2) { + auto posDauTrack = K0scand.template posTrack_as(); + auto negDauTrack = K0scand.template negTrack_as(); + + /// Daughters + // Positve pion + auto trkppt = posDauTrack.pt(); + auto istrkphasTOF = posDauTrack.hasTOF(); + auto trkpNSigmaPiTPC = posDauTrack.tpcNSigmaPi(); + auto trkpNSigmaPiTOF = (istrkphasTOF) ? posDauTrack.tofNSigmaPi() : -999.; + // Negative pion + auto trknpt = negDauTrack.pt(); + auto istrknhasTOF = negDauTrack.hasTOF(); + auto trknNSigmaPiTPC = negDauTrack.tpcNSigmaPi(); + auto trknNSigmaPiTOF = (istrknhasTOF) ? negDauTrack.tofNSigmaPi() : -999.; + + /// K0s + auto trkkDauDCA = K0scand.dcaV0daughters(); + auto trkkDauDCAPostoPV = K0scand.dcapostopv(); + auto trkkDauDCANegtoPV = K0scand.dcanegtopv(); + auto trkkpt = K0scand.pt(); + auto trkky = K0scand.yK0Short(); + auto trkkRadius = K0scand.v0radius(); + auto trkkDCAtoPV = K0scand.dcav0topv(); + auto trkkCPA = K0scand.v0cosPA(); + auto trkkMass = K0scand.mK0Short(); + + if constexpr (!IsMix) { + // Seconddary QA plots + histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); } - - if (!isSelectedV0Daughter(negtrack, -1, nTPCSigmaNeg[0])) { - continue; + histos.fill(HIST("QA/before/trkppionpT"), trkppt); + histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); } + histos.fill(HIST("QA/before/trknpionpT"), trknpt); + histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); - if (!SelectionV0(collision, v0, centrality)) { - continue; - } + histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); + histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - auto mctrackv0 = v0.mcParticle(); - - int track1PDG = std::abs(mctrack1.pdgCode()); - // int track2PDG = std::abs(mctrack2.pdgCode()); - int trackv0PDG = std::abs(mctrackv0.pdgCode()); + histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); + histos.fill(HIST("QA/before/hy_Secondary"), trkky); + histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); + histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); + } - if (postrack.globalIndex() == track1.globalIndex()) - continue; - if (negtrack.globalIndex() == track1.globalIndex()) - continue; + // if (!trackCut(posDauTrack) || !trackCut(negDauTrack)) // Too tight cut for K0s daugthers + // continue; + if (!cfgByPassDauPIDSelection && !selectionPIDPion(posDauTrack)) // Perhaps it's already applied in trackCut (need to check QA plots) + continue; + if (!cfgByPassDauPIDSelection && !selectionPIDPion(negDauTrack)) + continue; + if (!selectionK0s(collision, K0scand)) + continue; - rRecParticles.fill(HIST("hMCRec"), 2.5); + if constexpr (!IsMix) { + // Seconddary QA plots after applying cuts - if (track1PDG != 211) { - continue; + histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); } - // if (track2PDG != 321) { - // continue; - // } - if (trackv0PDG != 310) { - continue; + histos.fill(HIST("QA/after/trkppionpT"), trkppt); + histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); } + histos.fill(HIST("QA/after/trknpionpT"), trknpt); + histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); - rRecParticles.fill(HIST("hMCRec"), 3.5); - - for (auto& mothertrack1 : mctrack1.mothers_as()) { - // for (auto& mothertrack2 : mctrack2.mothers_as()) { - for (auto& mothertrack2 : mctrackv0.mothers_as()) { - - rRecParticles.fill(HIST("hMCRec"), 4.5); - // LOG(info) << "Initial Mothers PDG:\t" <()) { - - // LOG(info) << "final Mothers PDG:\t" < cKstarMaxRap || lResoKstar.Rapidity() < cKstarMinRap) + continue; - if (mothertrack3.globalIndex() != mothertrack1.globalIndex()) { - continue; - } + if constexpr (!IsMix) { - rRecParticles.fill(HIST("hMCRec"), 6.5); - // rRecParticles.fill(HIST("hMCRec"), 7.5); + histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); + histos.fill(HIST("hInvmass_Kstar"), collision.centFT0M(), lResoKstar.Pt(), lResoKstar.M()); - // LOG(info) << "Mothers PDG:\t" < 1) { + auto anglestart = confMinRot; + auto angleend = confMaxRot; + auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); + rotangle = anglestart + nrotbkg * anglestep; } - - oldindex = mothertrack1.globalIndex(); - - if (std::abs(mothertrack1.y()) >= 0.5) { + histos.fill(HIST("hRotation"), rotangle); + auto rotpionPx = lDecayDaughter_bach.Px() * std::cos(rotangle) - lDecayDaughter_bach.Py() * std::sin(rotangle); + auto rotpionPy = lDecayDaughter_bach.Px() * std::sin(rotangle) + lDecayDaughter_bach.Py() * std::cos(rotangle); + ROOT::Math::PtEtaPhiMVector pionrot; + pionrot = ROOT::Math::PxPyPzMVector(rotpionPx, rotpionPy, lDecayDaughter_bach.Pz(), massPi); + chargekstarrot = pionrot + lResoSecondary; + if (chargekstarrot.Rapidity() > cKstarMaxRap || chargekstarrot.Rapidity() < cKstarMinRap) continue; - } - - rRecParticles.fill(HIST("hMCRec"), 7.5); - - rRecParticles.fill(HIST("hCKSRec"), mothertrack1.pt(), cent); + histos.fill(HIST("hInvmass_KstarRotated"), collision.centFT0M(), chargekstarrot.Pt(), chargekstarrot.M()); } } } - } - } // track loop ends - } + } // K0scand + } // bTrack + + count++; - PROCESS_SWITCH(chargedkstaranalysis, processGenMC, "Process Gen event", false); - PROCESS_SWITCH(chargedkstaranalysis, processRecMC, "Process Rec event", false); + } // fillHistograms - void processSEnew(aod::ResoCollision& collision, aod::ResoTracks const& resotracks, aod::ResoV0s const& resov0s) + // process data + void processDataSE(EventCandidates::iterator const& collision, + TrackCandidates const& tracks, + V0Candidates const& v0s, + aod::BCsWithTimestamps const&) { - // Fill the event counter - histos1.fill(HIST("hVertexZ"), collision.posZ()); - fillHistograms(collision, resotracks, resov0s); // Fill histograms, no MC, no mixing + if (!colCuts.isSelected(collision)) // Default event selection + return; + colCuts.fillQA(collision); + fillHistograms(collision, tracks, v0s); } - PROCESS_SWITCH(chargedkstaranalysis, processSEnew, "Process Same event new", true); + PROCESS_SWITCH(chargedkstaranalysis, processDataSE, "Process Event for data without Partitioning", true); - using BinningTypeVtxZT0M = ColumnBinningPolicy; - void processMEnew(aod::ResoCollisions& collisions, aod::ResoTracks const& resotracks, aod::ResoV0s const& resov0s) + using BinningTypeVtxZT0M = ColumnBinningPolicy; + + // using BinningTypeVtxZT0M = ColumnBinningPolicy>; + BinningTypeVtxZT0M colBinning{{cfgvtxbins, cfgmultbins}, true}; + void processDataME(EventCandidates const& collisions, TrackCandidates const& tracks, V0Candidates const& v0s) { - auto tracksV0sTuple = std::make_tuple(resotracks, resov0s); - auto V0sTuple = std::make_tuple(resov0s); - BinningTypeVtxZT0M colBinning{{CfgVtxBins, CfgMultBins}, true}; - Pair pairs{colBinning, nEvtMixing, -1, collisions, tracksV0sTuple, &cache}; // -1 is the number of the bin to skip - for (auto& [c1, restrk1, c2, resov0s2] : pairs) { + auto tracksV0sTuple = std::make_tuple(tracks, v0s); + + Pair pair{colBinning, nEvtMixing, -1, collisions, tracksV0sTuple, &cache}; + // restrk1 is a TrackCandidates table of tracks belonging to collision c1 (aod::Collision::iterator) + // resov0s2 is a V0Candidates table of V0s belonging to collision c2 (aod::Collision::iterator) + for (const auto& [c1, restrk1, c2, resov0s2] : pair) { + if (!colCuts.isSelected(c1) || !colCuts.isSelected(c2)) { + // Default event selection + continue; + } + colCuts.fillQA(c1); fillHistograms(c1, restrk1, resov0s2); } + // fillHistograms(collision, tracks, v0s); // second order } - PROCESS_SWITCH(chargedkstaranalysis, processMEnew, "Process Mixed events new", true); -}; + PROCESS_SWITCH(chargedkstaranalysis, processDataME, "Process Event for data without Partitioning", true); + + // process MC reconstructed level + void processMC(MCEventCandidates::iterator const& collision, + MCTrackCandidates const& tracks, + MCV0Candidates const& v0s) + { + // histos.fill(HIST("QAMC/hEvent"), 1.0); + + fillHistograms(collision, tracks, v0s); + } + PROCESS_SWITCH(chargedkstaranalysis, processMC, "Process Event for MC", false); +}; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; diff --git a/PWGLF/Tasks/Resonances/chk892Flow.cxx b/PWGLF/Tasks/Resonances/chk892Flow.cxx new file mode 100644 index 00000000000..2c616d81406 --- /dev/null +++ b/PWGLF/Tasks/Resonances/chk892Flow.cxx @@ -0,0 +1,1117 @@ +// 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. +/// +/// \file chk892Flow.cxx +/// \brief Reconstruction of track-track decay resonance candidates +/// \author Su-Jeong Ji , Bong-Hwi Lim +/// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "TRandom3.h" +#include "TF1.h" +#include "TVector2.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "Math/GenVector/Boost.h" +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/StaticFor.h" +#include "DCAFitter/DCAFitterN.h" + +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Qvectors.h" + +#include "Common/Core/trackUtilities.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/RecoDecay.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "CommonConstants/MathConstants.h" + +#include "ReconstructionDataFormats/Track.h" + +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" + +#include "CCDB/CcdbApi.h" +#include "CCDB/BasicCCDBManager.h" + +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/Utils/collisionCuts.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::constants::physics; +using namespace o2::aod::rctsel; + +struct Chk892Flow { + enum BinType : unsigned int { + kKstarP = 0, + kKstarN, + kKstarP_Mix, + kKstarN_Mix, + kKstarP_Rot, + kKstarN_Rot, + kTYEnd + }; + + SliceCache cache; + Preslice perCollision = aod::track::collisionId; + + using EventCandidates = soa::Join; + using TrackCandidates = soa::Join; + using V0Candidates = aod::V0Datas; + + using MCEventCandidates = soa::Join; + using MCTrackCandidates = soa::Join; + using MCV0Candidates = soa::Join; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + + struct : ConfigurableGroup { + Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + } CCDBConfig; + // Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; + + // Configurables + struct : ConfigurableGroup { + ConfigurableAxis cfgBinsPt{"cfgBinsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; + ConfigurableAxis cfgBinsPtQA{"cfgBinsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0}, "Binning of the pT axis"}; + ConfigurableAxis cfgBinsCent{"cfgBinsCent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; + ConfigurableAxis cfgBinsVtxZ{"cfgBinsVtxZ", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "Binning of the z-vertex axis"}; + ConfigurableAxis cfgBinsOccu{"cfgBinsOccu", {VARIABLE_WIDTH, 0, 500, 1000, 2500, 9999}, "Binning of the occupancy axis"}; + Configurable cNbinsDiv{"cNbinsDiv", 1, "Integer to divide the number of bins"}; + Configurable cNbinsDivQA{"cNbinsDivQA", 1, "Integer to divide the number of bins for QA"}; + ConfigurableAxis cfgAxisV2{"cfgAxisV2", {200, -1, 1}, "Binning of the v2 axis (+-1 for EP method)"}; + ConfigurableAxis cfgAxisPhi{"cfgAxisPhi", {8, 0, constants::math::PI}, "Binning of the #phi axis"}; + } AxisConfig; + + struct : ConfigurableGroup { + Configurable cfgFillQAPlots{"cfgFillQAPlots", true, "Fill QA plots"}; + Configurable cfgQvecSel{"cfgQvecSel", true, "Reject events when no QVector"}; + Configurable cfgCentEst{"cfgCentEst", 1, "Centrality estimator, 1: FT0C, 2: FT0M"}; + Configurable cfgFillAdditionalAxis{"cfgFillAdditionalAxis", false, "Fill additional axis"}; + Configurable cfgUseScalProduct{"cfgUseScalProduct", false, "Use scalar product method"}; + } AnalysisConfig; + + // Event cuts + o2::analysis::CollisonCuts colCuts; + struct : ConfigurableGroup { + Configurable cfgEvtZvtx{"cfgEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + // Configurable cfgEvtOccupancyInTimeRangeMax{"cfgEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; + // Configurable cfgEvtOccupancyInTimeRangeMin{"cfgEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; + Configurable cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"}; + Configurable cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"}; + Configurable cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; + Configurable cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; + Configurable cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; + Configurable cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", true, "Evt sel: apply Z-vertex time difference"}; + Configurable cfgEvtPileupRejection{"cfgEvtPileupRejection", true, "Evt sel: apply pileup rejection"}; + Configurable cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + Configurable cfgEvtCollInTimeRangeStandard{"cfgEvtCollInTimeRangeStandard", true, "Evt sel: apply NoCollInTimeRangeStandard"}; + Configurable cfgEventCentralityMin{"cfgEventCentralityMin", 0.0f, "Event sel: minimum centrality"}; + Configurable cfgEventCentralityMax{"cfgEventCentralityMax", 80.0f, "Event sel: maximum centrality"}; + Configurable cfgEvtUseRCTFlagChecker{"cfgEvtUseRCTFlagChecker", false, "Evt sel: use RCT flag checker"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", false, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } EventCuts; + RCTFlagsChecker rctChecker; + + /// PID Selections, pion + struct : ConfigurableGroup { + Configurable cfgTPConly{"cfgTPConly", false, "Use only TPC for PID"}; // bool + Configurable cfgMaxTPCnSigmaPion{"cfgMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC + Configurable cfgMaxTOFnSigmaPion{"cfgMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF + Configurable cfgNsigmaCutCombinedPion{"cfgNsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; // Combined + Configurable cfgTOFVeto{"cfgTOFVeto", true, "TOF Veto, if false, TOF is nessessary for PID selection"}; // TOF Veto + } PIDCuts; + + // Track selections + struct : ConfigurableGroup { + Configurable cfgMinPtcut{"cfgMinPtcut", 0.6, "Track minium pt cut"}; + Configurable cfgMaxEtacut{"cfgMaxEtacut", 0.8, "Track maximum eta cut"}; + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor + Configurable cfgpTdepDCAxyCut{"cfgpTdepDCAxyCut", false, "pT-dependent DCAxy cut"}; + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; + Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; + Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; + Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; + Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; + Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; + Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; + Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; + Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + // DCA to PV + Configurable cfgMaxbDCArToPVcut{"cfgMaxbDCArToPVcut", 0.1, "Track DCAr cut to PV Maximum"}; + Configurable cfgMaxbDCAzToPVcut{"cfgMaxbDCAzToPVcut", 0.1, "Track DCAz cut to PV Maximum"}; + } TrackCuts; + + // Secondary Selection + struct : ConfigurableGroup { + Configurable cfgReturnFlag{"cfgReturnFlag", false, "Return Flag for debugging"}; + Configurable cfgSecondaryRequire{"cfgSecondaryRequire", true, "Secondary cuts on/off"}; + Configurable cfgSecondaryArmenterosCut{"cfgSecondaryArmenterosCut", true, "cut on Armenteros-Podolanski graph"}; + Configurable cfgSecondaryCrossMassHypothesisCut{"cfgSecondaryCrossMassHypothesisCut", false, "Apply cut based on the lambda mass hypothesis"}; + + Configurable cfgByPassDauPIDSelection{"cfgByPassDauPIDSelection", true, "Bypass Daughters PID selection"}; + Configurable cfgSecondaryDauDCAMax{"cfgSecondaryDauDCAMax", 0.2, "Maximum DCA Secondary daughters to PV"}; + Configurable cfgSecondaryDauPosDCAtoPVMin{"cfgSecondaryDauPosDCAtoPVMin", 0.1, "Minimum DCA Secondary positive daughters to PV"}; + Configurable cfgSecondaryDauNegDCAtoPVMin{"cfgSecondaryDauNegDCAtoPVMin", 0.1, "Minimum DCA Secondary negative daughters to PV"}; + + Configurable cfgSecondaryPtMin{"cfgSecondaryPtMin", 0.f, "Minimum transverse momentum of Secondary"}; + Configurable cfgSecondaryRapidityMax{"cfgSecondaryRapidityMax", 0.8, "Maximum rapidity of Secondary"}; + Configurable cfgSecondaryRadiusMin{"cfgSecondaryRadiusMin", 0.0, "Minimum transverse radius of Secondary"}; + Configurable cfgSecondaryRadiusMax{"cfgSecondaryRadiusMax", 999.9, "Maximum transverse radius of Secondary"}; + Configurable cfgSecondaryCosPAMin{"cfgSecondaryCosPAMin", 0.995, "Mininum cosine pointing angle of Secondary"}; + Configurable cfgSecondaryDCAtoPVMax{"cfgSecondaryDCAtoPVMax", 0.4, "Maximum DCA Secondary to PV"}; + Configurable cfgSecondaryProperLifetimeMax{"cfgSecondaryProperLifetimeMax", 20., "Maximum Secondary Lifetime"}; + Configurable cfgSecondaryparamArmenterosCut{"cfgSecondaryparamArmenterosCut", 0.2, "parameter for Armenteros Cut"}; + Configurable cfgSecondaryMassWindow{"cfgSecondaryMassWindow", 0.03, "Secondary inv mass selection window"}; + Configurable cfgSecondaryCrossMassCutWindow{"cfgSecondaryCrossMassCutWindow", 0.05, "Secondary inv mass selection window with (anti)lambda hypothesis"}; + } SecondaryCuts; + + // K* selection + struct : ConfigurableGroup { + Configurable cfgKstarMaxRap{"cfgKstarMaxRap", 0.5, "Kstar maximum rapidity"}; + Configurable cfgKstarMinRap{"cfgKstarMinRap", -0.5, "Kstar minimum rapidity"}; + } KstarCuts; + + // Confs from flow analysis + struct : ConfigurableGroup { + Configurable cfgnMods{"cfgnMods", 2, "The number of modulations of interest starting from 2"}; + Configurable cfgNQvec{"cfgNQvec", 7, "The number of total Qvectors for looping over the task"}; + + Configurable cfgQvecDetName{"cfgQvecDetName", "FT0C", "The name of detector to be analyzed"}; + Configurable cfgQvecRefAName{"cfgQvecRefAName", "TPCpos", "The name of detector for reference A"}; + Configurable cfgQvecRefBName{"cfgQvecRefBName", "TPCneg", "The name of detector for reference B"}; + } EventPlaneConfig; + + // Bkg estimation + struct : ConfigurableGroup { + Configurable cfgFillRotBkg{"cfgFillRotBkg", true, "Fill rotated background"}; + Configurable cfgMinRot{"cfgMinRot", 5.0 * constants::math::PI / 6.0, "Minimum of rotation"}; + Configurable cfgMaxRot{"cfgMaxRot", 7.0 * constants::math::PI / 6.0, "Maximum of rotation"}; + Configurable cfgRotPion{"cfgRotPion", true, "Rotate pion"}; + Configurable cfgNrotBkg{"cfgNrotBkg", 9, "Number of rotated copies (background) per each original candidate"}; + } BkgEstimationConfig; + + int lDetId; + int lRefAId; + int lRefBId; + + int lQvecDetInd; + int lQvecRefAInd; + int lQvecRefBInd; + + float lCentrality; + + // PDG code + int kPDGK0s = kK0Short; + int kPDGK0 = kK0; + int kKstarPlus = o2::constants::physics::Pdg::kKPlusStar892; + + void init(o2::framework::InitContext&) + { + lCentrality = -999; + + colCuts.setCuts(EventCuts.cfgEvtZvtx, EventCuts.cfgEvtTriggerCheck, EventCuts.cfgEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, /*EventCuts.cfgEvtOccupancyInTimeRangeMax*/ false, /*EventCuts.cfgEvtOccupancyInTimeRangeMin*/ false); + colCuts.init(&histos); + colCuts.setTriggerTVX(EventCuts.cfgEvtTriggerTVXSel); + colCuts.setApplyTFBorderCut(EventCuts.cfgEvtTFBorderCut); + colCuts.setApplyITSTPCvertex(EventCuts.cfgEvtUseITSTPCvertex); + colCuts.setApplyZvertexTimedifference(EventCuts.cfgEvtZvertexTimedifference); + colCuts.setApplyPileupRejection(EventCuts.cfgEvtPileupRejection); + colCuts.setApplyNoITSROBorderCut(EventCuts.cfgEvtNoITSROBorderCut); + colCuts.setApplyCollInTimeRangeStandard(EventCuts.cfgEvtCollInTimeRangeStandard); + colCuts.printCuts(); + + rctChecker.init(EventCuts.cfgEvtRCTFlagCheckerLabel, EventCuts.cfgEvtRCTFlagCheckerZDCCheck, EventCuts.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + + AxisSpec centAxis = {AxisConfig.cfgBinsCent, "T0M (%)"}; + AxisSpec vtxzAxis = {AxisConfig.cfgBinsVtxZ, "Z Vertex (cm)"}; + AxisSpec epAxis = {100, -1.0 * constants::math::PI, constants::math::PI}; + AxisSpec ptAxis = {AxisConfig.cfgBinsPt, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec ptAxisQA = {AxisConfig.cfgBinsPtQA, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec v2Axis = {AxisConfig.cfgAxisV2, "#v_{2}"}; + AxisSpec phiAxis = {AxisConfig.cfgAxisPhi, "2(#phi-#Psi_{2})"}; + AxisSpec occuAxis = {AxisConfig.cfgBinsOccu, "Occupancy"}; + AxisSpec radiusAxis = {50, 0, 5, "Radius (cm)"}; + AxisSpec cpaAxis = {30, 0.97, 1.0, "CPA"}; + AxisSpec tauAxis = {250, 0, 25, "Lifetime (cm)"}; + AxisSpec dcaAxis = {100, 0, 2, "DCA (cm)"}; + AxisSpec dcaxyAxis = {100, 0, 1, "DCA_{#it{xy}} (cm)"}; + AxisSpec dcazAxis = {200, 0, 2, "DCA_{#it{z}} (cm)"}; + AxisSpec yAxis = {50, -1, 1, "Rapidity"}; + AxisSpec invMassAxisK0s = {800 / AxisConfig.cNbinsDiv, 0.46, 0.54, "Invariant Mass (GeV/#it{c}^2)"}; // K0s ~497.611 + AxisSpec invMassAxisReso = {900 / AxisConfig.cNbinsDiv, 0.5f, 1.4f, "Invariant Mass (GeV/#it{c}^2)"}; // chK(892) ~892 + AxisSpec pidQAAxis = {130 / AxisConfig.cNbinsDivQA, -6.5, 6.5}; + + // THnSparse + AxisSpec axisType = {BinType::kTYEnd, 0, BinType::kTYEnd, "Type of bin with charge and mix"}; + AxisSpec mcLabelAxis = {5, -0.5, 4.5, "MC Label"}; + + if (SecondaryCuts.cfgReturnFlag) { + histos.add("QA/K0sCutCheck", "Check K0s cut", HistType::kTH1D, {AxisSpec{13, -0.5, 12.5, "Check"}}); + } + histos.add("QA/before/CentDist", "Centrality distribution", {HistType::kTH1D, {centAxis}}); + histos.add("QA/before/VtxZ", "z-vertex distribution", {HistType::kTH1D, {vtxzAxis}}); + histos.add("QA/before/Occupancy", "Occupancy distribution", {HistType::kTH1D, {occuAxis}}); + + // EventPlane + histos.add("QA/EP/hEPDet", "Event plane distribution of FT0C (Det = A)", {HistType::kTH2D, {centAxis, epAxis}}); + histos.add("QA/EP/hEPB", "Event plane distribution of TPCpos (B)", {HistType::kTH2D, {centAxis, epAxis}}); + histos.add("QA/EP/hEPC", "Event plane distribution of TPCneg (C)", {HistType::kTH2D, {centAxis, epAxis}}); + histos.add("QA/EP/hEPResAB", "cos(n(A-B))", {HistType::kTH2D, {centAxis, epAxis}}); + histos.add("QA/EP/hEPResAC", "cos(n(A-C))", {HistType::kTH2D, {centAxis, epAxis}}); + histos.add("QA/EP/hEPResBC", "cos(n(B-C))", {HistType::kTH2D, {centAxis, epAxis}}); + + if (AnalysisConfig.cfgUseScalProduct) { + histos.add("QA/EP/hEPSPResAB", "cos(n(A-B))", {HistType::kTH2D, {centAxis, epAxis}}); + histos.add("QA/EP/hEPSPResAC", "cos(n(A-C))", {HistType::kTH2D, {centAxis, epAxis}}); + histos.add("QA/EP/hEPSPResBC", "cos(n(B-C))", {HistType::kTH2D, {centAxis, epAxis}}); + } + + if (AnalysisConfig.cfgFillQAPlots) { + // Rotated background + if (BkgEstimationConfig.cfgFillRotBkg) { + histos.add("QA/RotBkg/hRotBkg", "Rotated angle of rotated background", HistType::kTH1F, {{360, 0.0, o2::constants::math::TwoPI}}); + } + + // Bachelor pion + histos.add("QA/before/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/before/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QA/before/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/before/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + histos.add("QA/after/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/after/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QA/after/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/after/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + // Secondary pion 1 + histos.add("QA/before/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QA/before/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/before/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/before/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); + + histos.add("QA/after/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QA/after/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/after/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/after/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); + + // Secondary pion 2 + histos.add("QA/before/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/before/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QA/before/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/before/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/before/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); + + histos.add("QA/after/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); + histos.add("QA/after/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QA/after/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxisQA}); + histos.add("QA/after/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QA/after/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); + + // K0s + histos.add("QA/before/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/before/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); + histos.add("QA/before/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); + histos.add("QA/before/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/before/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); + histos.add("QA/before/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); + + histos.add("QA/after/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/after/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); + histos.add("QA/after/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); + histos.add("QA/after/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QA/after/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); + histos.add("QA/after/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); + + // Mass QA (quick check) + histos.add("QA/before/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); + histos.add("QA/before/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); + histos.add("QA/before/k0sv2vsinvmass", "Invariant mass vs v2 of unlike-sign K0s", HistType::kTH2D, {invMassAxisK0s, v2Axis}); + histos.add("QA/before/kstarv2vsinvmass", "Invariant mass vs v2 of unlike-sign chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); + histos.add("QA/before/kstarinvmass_Mix", "Invariant mass of unlike-sign chK(892) from mixed event", HistType::kTH1D, {invMassAxisReso}); + + histos.add("QA/after/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); + histos.add("QA/after/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); + histos.add("QA/after/k0sv2vsinvmass", "Invariant mass vs v2 of unlike-sign K0s", HistType::kTH2D, {invMassAxisK0s, v2Axis}); + histos.add("QA/after/kstarv2vsinvmass", "Invariant mass vs v2 of unlike-sign chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); + histos.add("QA/after/kstarinvmass_Mix", "Invariant mass of unlike-sign chK(892) from mixed event", HistType::kTH1D, {invMassAxisReso}); + + // MC + if (doprocessMC) { + // Bachelor pion + histos.add("QAMC/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QAMC/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QAMC/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + // Secondary pion 1 + histos.add("QAMC/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QAMC/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QAMC/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + // Secondary pion 2 + histos.add("QAMC/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QAMC/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QAMC/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); + + // Secondary Resonance (K0s candidates) + histos.add("QAMC/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QAMC/hDauPosDCAtoPVSecondary", "Pos DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QAMC/hDauNegDCAtoPVSecondary", "Neg DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + + histos.add("QAMC/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); + histos.add("QAMC/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); + histos.add("QAMC/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QAMC/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); + histos.add("QAMC/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); + + // K892 + histos.add("QAMC/KstarOA", "Opening angle of chK(892)", HistType::kTH1D, {AxisSpec{100, 0, 3.14, "Opening angle"}}); + histos.add("QAMC/KstarPairAsym", "Pair asymmetry of chK(892)", HistType::kTH1D, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); + histos.add("QAMC/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); + + histos.add("QAMC/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); + histos.add("QAMC/k0sv2vsinvmass", "Invariant mass vs v2 of unlike-sign K0s", HistType::kTH2D, {invMassAxisK0s, v2Axis}); + histos.add("QAMC/kstarv2vsinvmass", "Invariant mass vs v2 of unlike-sign chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); + histos.add("QAMC/kstarinvmass_noKstar", "Invariant mass of unlike-sign no chK(892)", HistType::kTH1D, {invMassAxisReso}); + histos.add("QAMC/kstarv2vsinvmass_noKstar", "Invariant mass vs v2 of unlike-sign no chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); + } + } + + // Invariant mass nSparse + if (AnalysisConfig.cfgFillAdditionalAxis) { + histos.add("hInvmass_Kstar", "Invariant mass of unlike-sign chK(892)", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso, v2Axis, phiAxis, occuAxis}); + histos.add("hInvmass_K0s", "Invariant mass of unlike-sign K0s", HistType::kTHnSparseD, {centAxis, ptAxis, invMassAxisK0s, v2Axis, phiAxis, occuAxis}); + if (doprocessMC) { + histos.add("hInvmass_Kstar_MC", "Invariant mass of unlike chK(892)", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso, v2Axis, phiAxis, occuAxis}); + } + } else { + histos.add("hInvmass_Kstar", "Invariant mass of unlike-sign chK(892)", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso, v2Axis, occuAxis}); + histos.add("hInvmass_K0s", "Invariant mass of unlike-sign K0s", HistType::kTHnSparseD, {centAxis, ptAxis, invMassAxisK0s, v2Axis, occuAxis}); + if (doprocessMC) { + histos.add("hInvmass_Kstar_MC", "Invariant mass of unlike chK(892)", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso, v2Axis, occuAxis}); + } + } + + lDetId = getlDetId(EventPlaneConfig.cfgQvecDetName); + lRefAId = getlDetId(EventPlaneConfig.cfgQvecRefAName); + lRefBId = getlDetId(EventPlaneConfig.cfgQvecRefBName); + + if (lDetId == lRefAId || lDetId == lRefBId || lRefAId == lRefBId) { + LOGF(info, "Wrong detector configuration \n The FT0C will be used to get Q-Vector \n The TPCpos and TPCneg will be used as reference systems"); + lDetId = 0; + lRefAId = 4; + lRefBId = 5; + } + if (EventPlaneConfig.cfgNQvec < 2) { + LOG(fatal) << "nMode must be larger than 1, current input (cfgNQvec): " << EventPlaneConfig.cfgNQvec; + } + LOGF(info, "lDetId: %d, lRefAId: %d, lRefBId: %d", lDetId, lRefAId, lRefBId); + + // MC + if (doprocessMC) { + // Bachelor pion + histos.add("QAMC/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QAMC/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QAMC/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + // Secondary pion 1 + histos.add("QAMC/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QAMC/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); + histos.add("QAMC/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + + // Secondary pion 2 + histos.add("QAMC/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); + histos.add("QAMC/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); + histos.add("QAMC/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxis}); + histos.add("QAMC/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); + histos.add("QAMC/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); + + // Secondary Resonance (K0s candidates) + histos.add("QAMC/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QAMC/hDauPosDCAtoPVSecondary", "Pos DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QAMC/hDauNegDCAtoPVSecondary", "Neg DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); + + histos.add("QAMC/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); + histos.add("QAMC/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); + histos.add("QAMC/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); + histos.add("QAMC/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); + histos.add("QAMC/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); + + // K892 + histos.add("QAMC/KstarOA", "Opening angle of chK(892)", HistType::kTH1D, {AxisSpec{100, 0, 3.14, "Opening angle"}}); + histos.add("QAMC/KstarPairAsym", "Pair asymmetry of chK(892)", HistType::kTH1D, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); + histos.add("QAMC/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); + + histos.add("QAMC/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); + histos.add("QAMC/k0sv2vsinvmass", "Invariant mass vs v2 of unlike-sign K0s", HistType::kTH2D, {invMassAxisK0s, v2Axis}); + histos.add("QAMC/kstarv2vsinvmass", "Invariant mass vs v2 of unlike-sign chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); + histos.add("QAMC/kstarinvmass_noKstar", "Invariant mass of unlike-sign no chK(892)", HistType::kTH1D, {invMassAxisReso}); + histos.add("QAMC/kstarv2vsinvmass_noKstar", "Invariant mass vs v2 of unlike-sign no chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); + + if (AnalysisConfig.cfgFillAdditionalAxis) { + histos.add("hInvmass_Kstar_MC", "Invariant mass of unlike chK(892)", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso, v2Axis, phiAxis, occuAxis}); + } else { + histos.add("hInvmass_Kstar_MC", "Invariant mass of unlike chK(892)", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso, v2Axis, occuAxis}); + } + } + + ccdb->setURL(CCDBConfig.cfgURL); + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + + // Print output histograms statistics + LOG(info) << "Size of the histograms in chK(892) Analysis Task"; + histos.print(); + } + + template + float getCentrality(CollisionType const& collision) + { + if (AnalysisConfig.cfgCentEst == 1) { + return collision.centFT0C(); + } else if (AnalysisConfig.cfgCentEst == 2) { + return collision.centFT0M(); + } else { + return -999; + } + } + + template + int getlDetId(DetNameType const& name) + { + LOGF(info, "GetlDetID running"); + if (name.value == "FT0C") { + return 0; + } else if (name.value == "FT0A") { + return 1; + } else if (name.value == "FT0M") { + return 2; + } else if (name.value == "FV0A") { + return 3; + } else if (name.value == "TPCpos") { + return 4; + } else if (name.value == "TPCneg") { + return 5; + } else { + return false; + } + } + + // Track selection + template + bool trackCut(TrackType const& track) + { + // basic track cuts + if (std::abs(track.pt()) < TrackCuts.cfgMinPtcut) + return false; + if (std::abs(track.eta()) > TrackCuts.cfgMaxEtacut) + return false; + if (track.itsNCls() < TrackCuts.cfgITScluster) + return false; + if (track.tpcNClsFound() < TrackCuts.cfgTPCcluster) + return false; + if (track.tpcCrossedRowsOverFindableCls() < TrackCuts.cfgRatioTPCRowsOverFindableCls) + return false; + if (track.itsChi2NCl() >= TrackCuts.cfgITSChi2NCl) + return false; + if (track.tpcChi2NCl() >= TrackCuts.cfgTPCChi2NCl) + return false; + if (TrackCuts.cfgHasITS && !track.hasITS()) + return false; + if (TrackCuts.cfgHasTPC && !track.hasTPC()) + return false; + if (TrackCuts.cfgHasTOF && !track.hasTOF()) + return false; + if (TrackCuts.cfgUseITSRefit && !track.passedITSRefit()) + return false; + if (TrackCuts.cfgUseTPCRefit && !track.passedTPCRefit()) + return false; + if (TrackCuts.cfgPVContributor && !track.isPVContributor()) + return false; + if (TrackCuts.cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (TrackCuts.cfgGlobalTrack && !track.isGlobalTrack()) + return false; + if (TrackCuts.cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (TrackCuts.cfgpTdepDCAxyCut) { + // Tuned on the LHC22f anchored MC LHC23d1d on primary pions. 7 Sigmas of the resolution + if (std::abs(track.dcaXY()) > (0.004 + (0.013 / track.pt()))) + return false; + } else { + if (std::abs(track.dcaXY()) > TrackCuts.cfgMaxbDCArToPVcut) + return false; + } + if (std::abs(track.dcaZ()) > TrackCuts.cfgMaxbDCAzToPVcut) + return false; + return true; + } + + // PID selection tools + template + bool selectionPIDPion(TrackType const& candidate) + { + bool tpcPIDPassed = std::abs(candidate.tpcNSigmaPi()) < PIDCuts.cfgMaxTPCnSigmaPion; + bool tofPIDPassed = false; + + if (PIDCuts.cfgTPConly) { + return tpcPIDPassed; + } + + if (candidate.hasTOF()) { + tofPIDPassed = std::abs(candidate.tofNSigmaPi()) < PIDCuts.cfgMaxTOFnSigmaPion || + (PIDCuts.cfgNsigmaCutCombinedPion > 0 && + candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + + candidate.tofNSigmaPi() * candidate.tofNSigmaPi() < + PIDCuts.cfgNsigmaCutCombinedPion * PIDCuts.cfgNsigmaCutCombinedPion); + } else { + tofPIDPassed = PIDCuts.cfgTOFVeto; + } + + return tpcPIDPassed && tofPIDPassed; + } + + template + bool selectionK0s(CollisionType const& collision, K0sType const& candidate) + { + auto lDauDCA = candidate.dcaV0daughters(); + auto lDauPosDCAtoPV = std::abs(candidate.dcapostopv()); + auto lDauNegDCAtoPV = std::abs(candidate.dcanegtopv()); + auto lPt = candidate.pt(); + auto lRapidity = candidate.yK0Short(); + auto lRadius = candidate.v0radius(); + auto lDCAtoPV = candidate.dcav0topv(); + auto lCPA = candidate.v0cosPA(); + auto lPropTauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassK0Short; + auto lMk0s = candidate.mK0Short(); + auto lMLambda = candidate.mLambda(); + auto lMALambda = candidate.mAntiLambda(); + + auto checkCommonCuts = [&]() { + if (lDauDCA > SecondaryCuts.cfgSecondaryDauDCAMax) + return false; + if (lDauPosDCAtoPV < SecondaryCuts.cfgSecondaryDauPosDCAtoPVMin) + return false; + if (lDauNegDCAtoPV < SecondaryCuts.cfgSecondaryDauNegDCAtoPVMin) + return false; + if (lPt < SecondaryCuts.cfgSecondaryPtMin) + return false; + if (std::fabs(lRapidity) > SecondaryCuts.cfgSecondaryRapidityMax) + return false; + if (lRadius < SecondaryCuts.cfgSecondaryRadiusMin || lRadius > SecondaryCuts.cfgSecondaryRadiusMax) + return false; + if (lDCAtoPV > SecondaryCuts.cfgSecondaryDCAtoPVMax) + return false; + if (lCPA < SecondaryCuts.cfgSecondaryCosPAMin) + return false; + if (lPropTauK0s > SecondaryCuts.cfgSecondaryProperLifetimeMax) + return false; + if (candidate.qtarm() < SecondaryCuts.cfgSecondaryparamArmenterosCut * std::abs(candidate.alpha())) + return false; + if (std::fabs(lMk0s - MassK0Short) > SecondaryCuts.cfgSecondaryMassWindow) + return false; + if (SecondaryCuts.cfgSecondaryCrossMassHypothesisCut && + ((std::fabs(lMLambda - MassLambda0) < SecondaryCuts.cfgSecondaryCrossMassCutWindow) || (std::fabs(lMALambda - MassLambda0Bar) < SecondaryCuts.cfgSecondaryCrossMassCutWindow))) + return false; + return true; + }; + + if (SecondaryCuts.cfgReturnFlag) { // For cut study + bool returnFlag = true; + histos.fill(HIST("QA/K0sCutCheck"), 0); + if (lDauDCA > SecondaryCuts.cfgSecondaryDauDCAMax) { + histos.fill(HIST("QA/K0sCutCheck"), 1); + returnFlag = false; + } + if (lDauPosDCAtoPV < SecondaryCuts.cfgSecondaryDauPosDCAtoPVMin) { + histos.fill(HIST("QA/K0sCutCheck"), 2); + returnFlag = false; + } + if (lDauNegDCAtoPV < SecondaryCuts.cfgSecondaryDauNegDCAtoPVMin) { + histos.fill(HIST("QA/K0sCutCheck"), 3); + returnFlag = false; + } + if (lPt < SecondaryCuts.cfgSecondaryPtMin) { + histos.fill(HIST("QA/K0sCutCheck"), 4); + returnFlag = false; + } + if (std::fabs(lRapidity) > SecondaryCuts.cfgSecondaryRapidityMax) { + histos.fill(HIST("QA/K0sCutCheck"), 5); + returnFlag = false; + } + if (lRadius < SecondaryCuts.cfgSecondaryRadiusMin || lRadius > SecondaryCuts.cfgSecondaryRadiusMax) { + histos.fill(HIST("QA/K0sCutCheck"), 6); + returnFlag = false; + } + if (lDCAtoPV > SecondaryCuts.cfgSecondaryDCAtoPVMax) { + histos.fill(HIST("QA/K0sCutCheck"), 7); + returnFlag = false; + } + if (lCPA < SecondaryCuts.cfgSecondaryCosPAMin) { + histos.fill(HIST("QA/K0sCutCheck"), 8); + returnFlag = false; + } + if (lPropTauK0s > SecondaryCuts.cfgSecondaryProperLifetimeMax) { + histos.fill(HIST("QA/K0sCutCheck"), 9); + returnFlag = false; + } + if (candidate.qtarm() < SecondaryCuts.cfgSecondaryparamArmenterosCut * std::abs(candidate.alpha())) { + histos.fill(HIST("QA/K0sCutCheck"), 10); + returnFlag = false; + } + if (std::fabs(lMk0s - MassK0Short) > SecondaryCuts.cfgSecondaryMassWindow) { + histos.fill(HIST("QA/K0sCutCheck"), 11); + returnFlag = false; + } + if (SecondaryCuts.cfgSecondaryCrossMassHypothesisCut && + ((std::fabs(lMLambda - MassLambda0) < SecondaryCuts.cfgSecondaryCrossMassCutWindow) || (std::fabs(lMALambda - MassLambda0Bar) < SecondaryCuts.cfgSecondaryCrossMassCutWindow))) { + histos.fill(HIST("QA/K0sCutCheck"), 12); + returnFlag = false; + } + return returnFlag; + } else { // normal usage + if (SecondaryCuts.cfgSecondaryRequire) { + return checkCommonCuts(); + } else { + return std::fabs(lMk0s - MassK0Short) <= SecondaryCuts.cfgSecondaryMassWindow; // always apply mass window cut + } + } + } // selectionK0s + + template + bool isTrueKstar(const TrackTemplate& bTrack, const V0Template& k0sCand) + { + if (std::abs(bTrack.PDGCode()) != kPiPlus) // Are you pion? + return false; + if (std::abs(k0sCand.PDGCode()) != kPDGK0s) // Are you K0s? + return false; + + auto motherbTrack = bTrack.template mothers_as(); + auto motherkV0 = k0sCand.template mothers_as(); + + // Check bTrack first + if (std::abs(motherbTrack.pdgCode()) != kKstarPlus) // Are you charged Kstar's daughter? + return false; // Apply first since it's more restrictive + + if (std::abs(motherkV0.pdgCode()) != 310) // Is it K0s? + return false; + // Check if K0s's mother is K0 (311) + auto motherK0 = motherkV0.template mothers_as(); + if (std::abs(motherK0.pdgCode()) != 311) + return false; + + // Check if K0's mother is Kstar (323) + auto motherKstar = motherK0.template mothers_as(); + if (std::abs(motherKstar.pdgCode()) != 323) + return false; + + // Check if bTrack and K0 have the same mother (global index) + if (motherbTrack.globalIndex() != motherK0.globalIndex()) + return false; + + return true; + } + + int count = 0; + + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksTypeK0s& dTracks2, int nmode) + { + histos.fill(HIST("QA/before/CentDist"), lCentrality); + + lQvecDetInd = lDetId * 4 + 3 + (nmode - 2) * EventPlaneConfig.cfgNQvec * 4; + lQvecRefAInd = lRefAId * 4 + 3 + (nmode - 2) * EventPlaneConfig.cfgNQvec * 4; + lQvecRefBInd = lRefBId * 4 + 3 + (nmode - 2) * EventPlaneConfig.cfgNQvec * 4; + + double lEPDet = std::atan2(collision.qvecIm()[lQvecDetInd], collision.qvecRe()[lQvecDetInd]) / static_cast(nmode); + double lEPRefB = std::atan2(collision.qvecIm()[lQvecRefAInd], collision.qvecRe()[lQvecRefAInd]) / static_cast(nmode); + double lEPRefC = std::atan2(collision.qvecIm()[lQvecRefBInd], collision.qvecRe()[lQvecRefBInd]) / static_cast(nmode); + + double lEPResAB = std::cos(static_cast(nmode) * (lEPDet - lEPRefB)); + double lEPResAC = std::cos(static_cast(nmode) * (lEPDet - lEPRefC)); + double lEPResBC = std::cos(static_cast(nmode) * (lEPRefB - lEPRefC)); + + // EP method + histos.fill(HIST("QA/EP/hEPDet"), lCentrality, lEPDet); + histos.fill(HIST("QA/EP/hEPB"), lCentrality, lEPRefB); + histos.fill(HIST("QA/EP/hEPC"), lCentrality, lEPRefC); + histos.fill(HIST("QA/EP/hEPResAB"), lCentrality, lEPResAB); + histos.fill(HIST("QA/EP/hEPResAC"), lCentrality, lEPResAC); + histos.fill(HIST("QA/EP/hEPResBC"), lCentrality, lEPResBC); + // Scalar product method + if (AnalysisConfig.cfgUseScalProduct) { + double lEPSPResAB = (collision.qvecRe()[lQvecDetInd] * collision.qvecRe()[lQvecRefAInd] + collision.qvecIm()[lQvecDetInd] * collision.qvecIm()[lQvecRefAInd]); + double lEPSPResAC = (collision.qvecRe()[lQvecDetInd] * collision.qvecRe()[lQvecRefBInd] + collision.qvecIm()[lQvecDetInd] * collision.qvecIm()[lQvecRefBInd]); + double lEPSPResBC = (collision.qvecRe()[lQvecRefAInd] * collision.qvecRe()[lQvecRefBInd] + collision.qvecIm()[lQvecRefAInd] * collision.qvecIm()[lQvecRefBInd]); + + histos.fill(HIST("QA/EP/hEPSPResAB"), lCentrality, lEPSPResAB); + histos.fill(HIST("QA/EP/hEPSPResAC"), lCentrality, lEPSPResAC); + histos.fill(HIST("QA/EP/hEPSPResBC"), lCentrality, lEPSPResBC); + } + + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResoSecondary, lDecayDaughter_bach, lResoKstar, lDaughterRot, lResonanceRot; + std::vector trackIndicies = {}; + std::vector k0sIndicies = {}; + + for (const auto& bTrack : dTracks1) { + auto trkbpt = bTrack.pt(); + auto istrkbhasTOF = bTrack.hasTOF(); + auto trkbNSigmaPiTPC = bTrack.tpcNSigmaPi(); + auto trkbNSigmaPiTOF = (istrkbhasTOF) ? bTrack.tofNSigmaPi() : -999.; + + if constexpr (!IsMix) { + if (AnalysisConfig.cfgFillQAPlots) { + // Bachelor pion QA plots + histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); + } + } + + if (!trackCut(bTrack)) + continue; + if (!selectionPIDPion(bTrack)) + continue; + + if constexpr (!IsMix) { + if (AnalysisConfig.cfgFillQAPlots) { + // Bachelor pion QA plots after applying cuts + histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); + } + } + trackIndicies.push_back(bTrack.index()); + } + + for (const auto& k0sCand : dTracks2) { + auto posDauTrack = k0sCand.template posTrack_as(); + auto negDauTrack = k0sCand.template negTrack_as(); + + /// Daughters + // Positve pion + auto trkppt = posDauTrack.pt(); + auto istrkphasTOF = posDauTrack.hasTOF(); + auto trkpNSigmaPiTPC = posDauTrack.tpcNSigmaPi(); + auto trkpNSigmaPiTOF = (istrkphasTOF) ? posDauTrack.tofNSigmaPi() : -999.; + // Negative pion + auto trknpt = negDauTrack.pt(); + auto istrknhasTOF = negDauTrack.hasTOF(); + auto trknNSigmaPiTPC = negDauTrack.tpcNSigmaPi(); + auto trknNSigmaPiTOF = (istrknhasTOF) ? negDauTrack.tofNSigmaPi() : -999.; + + /// K0s + auto trkkDauDCA = k0sCand.dcaV0daughters(); + auto trkky = k0sCand.yK0Short(); + auto trkkDCAtoPV = k0sCand.dcav0topv(); + auto trkkCPA = k0sCand.v0cosPA(); + auto trkkPropTau = k0sCand.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassK0Short; + auto trkkMass = k0sCand.mK0Short(); + + // lResoSecondary.SetXYZM(k0sCand.px(), k0sCand.py(), k0sCand.pz(), MassK0Short); + lResoSecondary.SetXYZM(k0sCand.px(), k0sCand.py(), k0sCand.pz(), trkkMass); + auto lPhiMinusPsiK0s = RecoDecay::constrainAngle(lResoSecondary.Phi() - lEPDet, 0.0, 2); // constrain angle to range 0, Pi + // auto v2K0s = std::cos(static_cast(nmode) * lPhiMinusPsiK0s); + + float cosNPhi_K0s = std::cos(static_cast(nmode) * lResoSecondary.Phi()); + float sinNPhi_K0s = std::sin(static_cast(nmode) * lResoSecondary.Phi()); + + auto v2K0s = cosNPhi_K0s * collision.qvecRe()[lQvecDetInd] + sinNPhi_K0s * collision.qvecIm()[lQvecDetInd]; + if constexpr (!IsMix) { + if (AnalysisConfig.cfgFillQAPlots) { + // Seconddary QA plots + histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkppionpT"), trkppt); + histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trknpionpT"), trknpt); + histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); + histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/before/hy_Secondary"), trkky); + histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); + + histos.fill(HIST("QA/before/k0sv2vsinvmass"), lResoSecondary.M(), v2K0s); + } + } + + if (!SecondaryCuts.cfgByPassDauPIDSelection && !selectionPIDPion(posDauTrack)) + continue; + if (!SecondaryCuts.cfgByPassDauPIDSelection && !selectionPIDPion(negDauTrack)) + continue; + if (!selectionK0s(collision, k0sCand)) + continue; + + if constexpr (!IsMix) { + if (AnalysisConfig.cfgFillQAPlots) { + // Seconddary QA plots after applying cuts + histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkppionpT"), trkppt); + histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trknpionpT"), trknpt); + histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/after/hy_Secondary"), trkky); + histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); + + histos.fill(HIST("QA/after/k0sv2vsinvmass"), lResoSecondary.M(), v2K0s); + if (AnalysisConfig.cfgFillAdditionalAxis) { + histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M(), v2K0s, static_cast(nmode) * lPhiMinusPsiK0s, collision.trackOccupancyInTimeRange()); + } else { + histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M(), v2K0s, collision.trackOccupancyInTimeRange()); + } + } + if (AnalysisConfig.cfgFillAdditionalAxis) { + histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M(), v2K0s, static_cast(nmode) * lPhiMinusPsiK0s, collision.trackOccupancyInTimeRange()); + } else { + histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M(), v2K0s, collision.trackOccupancyInTimeRange()); + } + k0sIndicies.push_back(k0sCand.index()); + } + } + + for (const auto& trackIndex : trackIndicies) { + for (const auto& k0sIndex : k0sIndicies) { + auto bTrack = dTracks1.rawIteratorAt(trackIndex); + auto k0sCand = dTracks2.rawIteratorAt(k0sIndex); + auto trkkMass = k0sCand.mK0Short(); + + lDecayDaughter_bach.SetXYZM(bTrack.px(), bTrack.py(), bTrack.pz(), MassPionCharged); + // lResoSecondary.SetXYZM(k0sCand.px(), k0sCand.py(), k0sCand.pz(), MassK0Short); + lResoSecondary.SetXYZM(k0sCand.px(), k0sCand.py(), k0sCand.pz(), trkkMass); + lResoKstar = lResoSecondary + lDecayDaughter_bach; + auto resoPhi = lResoKstar.Phi(); + // EP method + auto lPhiMinusPsiKstar = RecoDecay::constrainAngle(resoPhi - lEPDet, 0.0, 2); // constrain angle to range 0, Pi + auto resoFlowValue = std::cos(static_cast(nmode) * lPhiMinusPsiKstar); + // Scalar product method + if (AnalysisConfig.cfgUseScalProduct) { + float cosNPhi = std::cos(static_cast(nmode) * resoPhi); + float sinNPhi = std::sin(static_cast(nmode) * resoPhi); + resoFlowValue = cosNPhi * collision.qvecRe()[lQvecDetInd] + sinNPhi * collision.qvecIm()[lQvecDetInd]; + } + + // QA plots + if constexpr (!IsMix) { + if (AnalysisConfig.cfgFillQAPlots) { + histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); + histos.fill(HIST("QA/before/kstarv2vsinvmass"), lResoKstar.M(), resoFlowValue); + } + } + + if (lResoKstar.Rapidity() > KstarCuts.cfgKstarMaxRap || lResoKstar.Rapidity() < KstarCuts.cfgKstarMinRap) + continue; + + if constexpr (!IsMix) { + unsigned int typeKstar = bTrack.sign() > 0 ? BinType::kKstarP : BinType::kKstarN; + + if (AnalysisConfig.cfgFillQAPlots) { + histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); + histos.fill(HIST("QA/after/kstarv2vsinvmass"), lResoKstar.M(), resoFlowValue); + } + if (AnalysisConfig.cfgFillAdditionalAxis) { + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M(), resoFlowValue, static_cast(nmode) * lPhiMinusPsiKstar, collision.trackOccupancyInTimeRange()); + } else { + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M(), resoFlowValue, collision.trackOccupancyInTimeRange()); + } + + if (BkgEstimationConfig.cfgFillRotBkg) { + for (int i = 0; i < BkgEstimationConfig.cfgNrotBkg; i++) { + auto lRotAngle = BkgEstimationConfig.cfgMinRot + i * ((BkgEstimationConfig.cfgMaxRot - BkgEstimationConfig.cfgMinRot) / (BkgEstimationConfig.cfgNrotBkg - 1)); + if (AnalysisConfig.cfgFillQAPlots) { + histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); + } + if (BkgEstimationConfig.cfgRotPion) { + lDaughterRot = lDecayDaughter_bach; + lDaughterRot.RotateZ(lRotAngle); + lResonanceRot = lDaughterRot + lResoSecondary; + } else { + lDaughterRot = lResoSecondary; + lDaughterRot.RotateZ(lRotAngle); + lResonanceRot = lDecayDaughter_bach + lDaughterRot; + } + resoPhi = lResonanceRot.Phi(); + auto lPhiMinusPsiKstar = RecoDecay::constrainAngle(resoPhi - lEPDet, 0.0, 2); // constrain angle to range 0, Pi + auto resoFlowValue = std::cos(static_cast(nmode) * lPhiMinusPsiKstar); + if (AnalysisConfig.cfgUseScalProduct) { + float cosNPhi = std::cos(static_cast(nmode) * resoPhi); + float sinNPhi = std::sin(static_cast(nmode) * resoPhi); + resoFlowValue = cosNPhi * collision.qvecRe()[lQvecDetInd] + sinNPhi * collision.qvecIm()[lQvecDetInd]; + } + typeKstar = bTrack.sign() > 0 ? BinType::kKstarP_Rot : BinType::kKstarN_Rot; + if (AnalysisConfig.cfgFillAdditionalAxis) { + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResonanceRot.Pt(), lResonanceRot.M(), resoFlowValue, static_cast(nmode) * lPhiMinusPsiKstar, collision.trackOccupancyInTimeRange()); + } else { + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResonanceRot.Pt(), lResonanceRot.M(), resoFlowValue, collision.trackOccupancyInTimeRange()); + } + } + } + } // IsMix + } // k0sCand + } // bTrack + + count++; + + } // fillHistograms + + // process dummy + void processDummy(aod::Collisions const&) + { + } + PROCESS_SWITCH(Chk892Flow, processDummy, "process Dummy", true); + + // process data + void processData(EventCandidates::iterator const& collision, + TrackCandidates const& tracks, + V0Candidates const& v0s, + aod::BCsWithTimestamps const&) + { + if (!colCuts.isSelected(collision)) // Default event selection + return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) { + return; + } + if (AnalysisConfig.cfgQvecSel && (collision.qvecAmp()[lDetId] < 1e-4 || collision.qvecAmp()[lRefAId] < 1e-4 || collision.qvecAmp()[lRefBId] < 1e-4)) + return; // If we don't have a Q-vector + lCentrality = getCentrality(collision); + if (lCentrality < EventCuts.cfgEventCentralityMin || lCentrality > EventCuts.cfgEventCentralityMax) + return; + colCuts.fillQA(collision); + + fillHistograms(collision, tracks, v0s, EventPlaneConfig.cfgnMods); // second order + } + PROCESS_SWITCH(Chk892Flow, processData, "Process Event for data without Partitioning", false); + + // process MC reconstructed level + void processMC(EventCandidates::iterator const& collision, + MCTrackCandidates const& tracks, + MCV0Candidates const& v0s) + { + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) { + return; + } + fillHistograms(collision, tracks, v0s, EventPlaneConfig.cfgnMods); + } + PROCESS_SWITCH(Chk892Flow, processMC, "Process Event for MC", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Resonances/chk892flow.cxx b/PWGLF/Tasks/Resonances/chk892flow.cxx deleted file mode 100644 index 06405f06d19..00000000000 --- a/PWGLF/Tasks/Resonances/chk892flow.cxx +++ /dev/null @@ -1,1002 +0,0 @@ -// 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. - -/// \file chk892flow.cxx -/// \brief Reconstruction of track-track decay resonance candidates -/// -/// -/// \author Su-Jeong Ji - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // FIXME -#include // FIXME - -#include -#include -#include -#include -#include -#include - -#include "TRandom3.h" -#include "TF1.h" -#include "TVector2.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/StaticFor.h" -#include "DCAFitter/DCAFitterN.h" - -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Qvectors.h" - -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" -#include "Common/Core/RecoDecay.h" - -#include "CommonConstants/PhysicsConstants.h" - -#include "ReconstructionDataFormats/Track.h" - -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" - -#include "CCDB/CcdbApi.h" -#include "CCDB/BasicCCDBManager.h" - -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/Utils/collisionCuts.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::soa; -using namespace o2::constants::physics; - -struct chk892flow { - enum binType : unsigned int { - kKstarP = 0, - kKstarN, - kKstarP_Mix, - kKstarN_Mix, - kKstarP_GenINEL10, - kKstarN_GenINEL10, - kKstarP_GenINELgt10, - kKstarN_GenINELgt10, - kKstarP_GenTrig10, - kKstarN_GenTrig10, - kKstarP_GenEvtSel, - kKstarN_GenEvtSel, - kKstarP_Rec, - kKstarN_Rec, - kTYEnd - }; - - SliceCache cache; - Preslice perCollision = aod::track::collisionId; - - using EventCandidates = soa::Join; - using TrackCandidates = soa::Join; - using V0Candidates = aod::V0Datas; - - using MCEventCandidates = soa::Join; - using MCTrackCandidates = soa::Join; - using MCV0Candidates = soa::Join; - - HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - Service ccdb; - Service pdg; - o2::ccdb::CcdbApi ccdbApi; - - Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; - Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; - - // Configurables - ConfigurableAxis cfgBinsPt{"cfgBinsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; - ConfigurableAxis cfgBinsPtQA{"cfgBinsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0}, "Binning of the pT axis"}; - ConfigurableAxis cfgBinsCent{"cfgBinsCent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; - ConfigurableAxis cfgBinsVtxZ{"cfgBinsVtxZ", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "Binning of the z-vertex axis"}; - Configurable cNbinsDiv{"cNbinsDiv", 1, "Integer to divide the number of bins"}; - - /// Event cuts - o2::analysis::CollisonCuts colCuts; - Configurable ConfEvtZvtx{"ConfEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; - Configurable ConfEvtOccupancyInTimeRangeMax{"ConfEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; - Configurable ConfEvtOccupancyInTimeRangeMin{"ConfEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; - Configurable ConfEvtTriggerCheck{"ConfEvtTriggerCheck", false, "Evt sel: check for trigger"}; - Configurable ConfEvtTriggerSel{"ConfEvtTriggerSel", 8, "Evt sel: trigger"}; - Configurable ConfEvtOfflineCheck{"ConfEvtOfflineCheck", true, "Evt sel: check for offline selection"}; - Configurable ConfEvtTriggerTVXSel{"ConfEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; - Configurable ConfEvtTFBorderCut{"ConfEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; - Configurable ConfEvtUseITSTPCvertex{"ConfEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; - Configurable ConfEvtZvertexTimedifference{"ConfEvtZvertexTimedifference", true, "Evt sel: apply Z-vertex time difference"}; - Configurable ConfEvtPileupRejection{"ConfEvtPileupRejection", true, "Evt sel: apply pileup rejection"}; - Configurable ConfEvtNoITSROBorderCut{"ConfEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; - Configurable ConfincludeCentralityMC{"ConfincludeCentralityMC", false, "Include centrality in MC"}; - Configurable ConfEvtCollInTimeRangeStandard{"ConfEvtCollInTimeRangeStandard", true, "Evt sel: apply NoCollInTimeRangeStandard"}; - - /// Track selections - Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"}; - Configurable cMaxEtacut{"cMaxEtacut", 0.8, "Track maximum eta cut"}; - - // Cuts from polarization analysis - Configurable cfgQvecSel{"cfgQvecSel", true, "Reject events when no QVector"}; - Configurable cfgCentEst{"cfgCentEst", 1, "Centrality estimator, 1: FT0C, 2: FT0M"}; - - // DCAr to PV - Configurable cMaxbDCArToPVcut{"cMaxbDCArToPVcut", 0.1, "Track DCAr cut to PV Maximum"}; - // DCAz to PV - Configurable cMaxbDCAzToPVcut{"cMaxbDCAzToPVcut", 0.1, "Track DCAz cut to PV Maximum"}; - - /// PID Selections, pion - Configurable cTPConly{"cTPConly", false, "Use only TPC for PID"}; // bool - Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC - Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF - Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; // Combined - Configurable cTOFVeto{"cTOFVeto", true, "TOF Veto, if false, TOF is nessessary for PID selection"}; // TOF Veto - - // Track selections - Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz - Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) - Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz - Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor - - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; - Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; - Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; - Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; - Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; - Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; - Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; - Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; - Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; - Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; - - // Secondary Selection - Configurable cfgReturnFlag{"boolReturnFlag", false, "Return Flag for debugging"}; - Configurable cSecondaryRequire{"bool", true, "Secondary cuts on/off"}; - Configurable cSecondaryArmenterosCut{"boolArmenterosCut", true, "cut on Armenteros-Podolanski graph"}; - - Configurable cfgByPassDauPIDSelection{"cfgByPassDauPIDSelection", true, "Bypass Daughters PID selection"}; - Configurable cSecondaryDauDCAMax{"cSecondaryDauDCAMax", 1., "Maximum DCA Secondary daughters to PV"}; - Configurable cSecondaryDauPosDCAtoPVMin{"cSecondaryDauPosDCAtoPVMin", 0.0, "Minimum DCA Secondary positive daughters to PV"}; - Configurable cSecondaryDauNegDCAtoPVMin{"cSecondaryDauNegDCAtoPVMin", 0.0, "Minimum DCA Secondary negative daughters to PV"}; - - Configurable cSecondaryPtMin{"cSecondaryPtMin", 0.f, "Minimum transverse momentum of Secondary"}; - Configurable cSecondaryRapidityMax{"cSecondaryRapidityMax", 0.5, "Maximum rapidity of Secondary"}; - Configurable cSecondaryRadiusMin{"cSecondaryRadiusMin", 1.2, "Minimum transverse radius of Secondary"}; - Configurable cSecondaryCosPAMin{"cSecondaryCosPAMin", 0.995, "Mininum cosine pointing angle of Secondary"}; - Configurable cSecondaryDCAtoPVMax{"cSecondaryDCAtoPVMax", 0.3, "Maximum DCA Secondary to PV"}; - Configurable cSecondaryProperLifetimeMax{"cSecondaryProperLifetimeMax", 20, "Maximum Secondary Lifetime"}; - Configurable cSecondaryparamArmenterosCut{"paramArmenterosCut", 0.2, "parameter for Armenteros Cut"}; - Configurable cSecondaryMassWindow{"cSecondaryMassWindow", 0.03, "Secondary inv mass selciton window"}; - - // K* selection - Configurable cKstarMaxRap{"cKstarMaxRap", 0.5, "Kstar maximum rapidity"}; - Configurable cKstarMinRap{"cKstarMinRap", -0.5, "Kstar minimum rapidity"}; - - // Confs from flow analysis - Configurable cfgnMods{"cfgnMods", 1, "The number of modulations of interest starting from 2"}; - Configurable cfgNQvec{"cfgNQvec", 7, "The number of total Qvectors for looping over the task"}; - - Configurable cfgQvecDetName{"cfgQvecDetName", "FT0C", "The name of detector to be analyzed"}; - Configurable cfgQvecRefAName{"cfgQvecRefAName", "TPCpos", "The name of detector for reference A"}; - Configurable cfgQvecRefBName{"cfgQvecRefBName", "TPCneg", "The name of detector for reference B"}; - - int DetId; - int RefAId; - int RefBId; - - int QvecDetInd; - int QvecRefAInd; - int QvecRefBInd; - - float centrality; - - // PDG code - int kPDGK0s = 310; - int kPDGK0 = 311; - int kKstarPlus = 323; - int kPiPlus = 211; - - void init(o2::framework::InitContext&) - { - centrality = -999; - - colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, ConfEvtOccupancyInTimeRangeMax, ConfEvtOccupancyInTimeRangeMin); - colCuts.init(&histos); - colCuts.setTriggerTVX(ConfEvtTriggerTVXSel); - colCuts.setApplyTFBorderCut(ConfEvtTFBorderCut); - colCuts.setApplyITSTPCvertex(ConfEvtUseITSTPCvertex); - colCuts.setApplyZvertexTimedifference(ConfEvtZvertexTimedifference); - colCuts.setApplyPileupRejection(ConfEvtPileupRejection); - colCuts.setApplyNoITSROBorderCut(ConfEvtNoITSROBorderCut); - colCuts.setApplyCollInTimeRangeStandard(ConfEvtCollInTimeRangeStandard); - - AxisSpec centAxis = {cfgBinsCent, "T0M (%)"}; - AxisSpec vtxzAxis = {cfgBinsVtxZ, "Z Vertex (cm)"}; - AxisSpec epAxis = {100, -1.0 * constants::math::PI, constants::math::PI}; - AxisSpec epresAxis = {100, -1.02, 1.02}; - AxisSpec ptAxis = {cfgBinsPt, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec ptAxisQA = {cfgBinsPtQA, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec v2Axis = {200, -1, 1, "#v_{2}"}; - AxisSpec radiusAxis = {50, 0, 5, "Radius (cm)"}; - AxisSpec cpaAxis = {50, 0.95, 1.0, "CPA"}; - AxisSpec tauAxis = {250, 0, 25, "Lifetime (cm)"}; - AxisSpec dcaAxis = {200, 0, 2, "DCA (cm)"}; - AxisSpec dcaxyAxis = {200, 0, 2, "DCA_{#it{xy}} (cm)"}; - AxisSpec dcazAxis = {200, 0, 2, "DCA_{#it{z}} (cm)"}; - AxisSpec yAxis = {100, -1, 1, "Rapidity"}; - AxisSpec invMassAxisK0s = {400 / cNbinsDiv, 0.3, 0.7, "Invariant Mass (GeV/#it{c}^2)"}; // K0s ~497.611 - AxisSpec invMassAxisReso = {900 / cNbinsDiv, 0.5f, 1.4f, "Invariant Mass (GeV/#it{c}^2)"}; // chK(892) ~892 - AxisSpec invMassAxisScan = {150, 0, 1.5, "Invariant Mass (GeV/#it{c}^2)"}; // For selection - AxisSpec pidQAAxis = {130, -6.5, 6.5}; - AxisSpec dataTypeAxis = {9, 0, 9, "Histogram types"}; - AxisSpec mcTypeAxis = {4, 0, 4, "Histogram types"}; - - // THnSparse - AxisSpec axisType = {binType::kTYEnd, 0, binType::kTYEnd, "Type of bin with charge and mix"}; - AxisSpec mcLabelAxis = {5, -0.5, 4.5, "MC Label"}; - - histos.add("QA/K0sCutCheck", "Check K0s cut", HistType::kTH1D, {AxisSpec{12, -0.5, 11.5, "Check"}}); - - histos.add("QA/before/CentDist", "Centrality distribution", {HistType::kTH1D, {centAxis}}); - histos.add("QA/before/VtxZ", "Centrality distribution", {HistType::kTH1D, {vtxzAxis}}); - histos.add("QA/before/hEvent", "Number of Events", HistType::kTH1F, {{1, 0.5, 1.5}}); - - // EventPlane - histos.add("QA/EP/hEPDet", "Event plane distribution of FT0C (Det = A)", {HistType::kTH2D, {centAxis, epAxis}}); - histos.add("QA/EP/hEPB", "Event plane distribution of TPCpos (B)", {HistType::kTH2D, {centAxis, epAxis}}); - histos.add("QA/EP/hEPC", "Event plane distribution of TPCneg (C)", {HistType::kTH2D, {centAxis, epAxis}}); - histos.add("QA/EP/hEPResAB", "cos(n(A-B))", {HistType::kTH2D, {centAxis, epAxis}}); - histos.add("QA/EP/hEPResAC", "cos(n(A-C))", {HistType::kTH2D, {centAxis, epAxis}}); - histos.add("QA/EP/hEPResBC", "cos(n(B-C))", {HistType::kTH2D, {centAxis, epAxis}}); - - // Bachelor pion - histos.add("QA/before/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); - histos.add("QA/before/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); - histos.add("QA/before/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxisQA}); - histos.add("QA/before/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/before/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/before/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); - - histos.add("QA/after/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); - histos.add("QA/after/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); - histos.add("QA/after/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxisQA}); - histos.add("QA/after/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/after/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/after/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); - - // Secondary pion 1 - histos.add("QA/before/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/before/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/before/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); - histos.add("QA/before/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxisQA}); - histos.add("QA/before/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); - histos.add("QA/before/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); - - histos.add("QA/after/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/after/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/after/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); - histos.add("QA/after/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxisQA}); - histos.add("QA/after/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); - histos.add("QA/after/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); - - // Secondary pion 2 - histos.add("QA/before/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/before/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/before/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); - histos.add("QA/before/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxisQA}); - histos.add("QA/before/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); - histos.add("QA/before/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); - - histos.add("QA/after/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/after/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxisQA, pidQAAxis}); - histos.add("QA/after/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); - histos.add("QA/after/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxisQA}); - histos.add("QA/after/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); - histos.add("QA/after/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); - - // K0s - histos.add("QA/before/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QA/before/hDauPosDCAtoPVSecondary", "Pos DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QA/before/hDauNegDCAtoPVSecondary", "Neg DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QA/before/hpT_Secondary", "pT distribution of secondary resonance", HistType::kTH1D, {ptAxisQA}); - histos.add("QA/before/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); - histos.add("QA/before/hRadiusSecondary", "Radius distribution of secondary resonance", HistType::kTH1D, {radiusAxis}); - histos.add("QA/before/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); - histos.add("QA/before/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QA/before/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); - histos.add("QA/before/hPtAsymSecondary", "pT asymmetry distribution of secondary resonance", HistType::kTH1D, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); - histos.add("QA/before/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); - - histos.add("QA/after/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QA/after/hDauPosDCAtoPVSecondary", "Pos DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QA/after/hDauNegDCAtoPVSecondary", "Neg DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QA/after/hpT_Secondary", "pT distribution of secondary resonance", HistType::kTH1D, {ptAxisQA}); - histos.add("QA/after/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); - histos.add("QA/after/hRadiusSecondary", "Radius distribution of secondary resonance", HistType::kTH1D, {radiusAxis}); - histos.add("QA/after/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); - histos.add("QA/after/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QA/after/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); - histos.add("QA/after/hPtAsymSecondary", "pT asymmetry distribution of secondary resonance", HistType::kTH1D, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); - histos.add("QA/after/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); - - // Kstar - // Invariant mass nSparse - histos.add("QA/before/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); - histos.add("hInvmass_Kstar", "Invariant mass of unlike-sign chK(892)", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso, v2Axis}); - histos.add("hInvmass_Kstar_Mix", "Invariant mass of unlike-sign chK(892) from mixed event", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso, v2Axis}); - - // Mass QA (quick check) - histos.add("QA/before/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); - histos.add("QA/before/k0sv2vsinvmass", "Invariant mass vs v2 of unlike-sign K0s", HistType::kTH2D, {invMassAxisK0s, v2Axis}); - histos.add("QA/before/kstarv2vsinvmass", "Invariant mass vs v2 of unlike-sign chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); - histos.add("QA/before/kstarinvmass_Mix", "Invariant mass of unlike-sign chK(892) from mixed event", HistType::kTH1D, {invMassAxisReso}); - histos.add("QA/before/kstarv2vsinvmass_Mix", "Invariant mass vs v2 of unlike-sign chK(892) from mixed event", HistType::kTH2D, {invMassAxisReso, v2Axis}); - - histos.add("QA/after/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); - histos.add("QA/after/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); - histos.add("QA/after/k0sv2vsinvmass", "Invariant mass vs v2 of unlike-sign K0s", HistType::kTH2D, {invMassAxisK0s, v2Axis}); - histos.add("QA/after/kstarv2vsinvmass", "Invariant mass vs v2 of unlike-sign chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); - histos.add("QA/after/kstarinvmass_Mix", "Invariant mass of unlike-sign chK(892) from mixed event", HistType::kTH1D, {invMassAxisReso}); - histos.add("QA/after/kstarv2vsinvmass_Mix", "Invariant mass vs v2 of unlike-sign chK(892) from mixed event", HistType::kTH2D, {invMassAxisReso, v2Axis}); - - DetId = GetDetId(cfgQvecDetName); - RefAId = GetDetId(cfgQvecRefAName); - RefBId = GetDetId(cfgQvecRefBName); - - if (DetId == RefAId || DetId == RefBId || RefAId == RefBId) { - LOGF(info, "Wrong detector configuration \n The FT0C will be used to get Q-Vector \n The TPCpos and TPCneg will be used as reference systems"); - // LOGF(info) << "Wrong detector configuration \n The FT0C will be used to get Q-Vector \n The TPCpos and TPCneg will be used as reference systems"; - DetId = 0; - RefAId = 4; - RefBId = 5; - } - - // MC - if (doprocessMC) { - - histos.add("QAMC/hEvent", "Number of Events", HistType::kTH1F, {{1, 0.5, 1.5}}); - // Bachelor pion - histos.add("QAMC/trkbpionDCAxy", "DCAxy distribution of bachelor pion candidates", HistType::kTH1D, {dcaxyAxis}); - histos.add("QAMC/trkbpionDCAz", "DCAz distribution of bachelor pion candidates", HistType::kTH1D, {dcazAxis}); - histos.add("QAMC/trkbpionpT", "pT distribution of bachelor pion candidates", HistType::kTH1D, {ptAxis}); - histos.add("QAMC/trkbpionTPCPID", "TPC PID of bachelor pion candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); - histos.add("QAMC/trkbpionTOFPID", "TOF PID of bachelor pion candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); - histos.add("QAMC/trkbpionTPCTOFPID", "TPC-TOF PID map of bachelor pion candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); - - // Secondary pion 1 - histos.add("QAMC/trkppionDCAxy", "DCAxy distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcaxyAxis}); - histos.add("QAMC/trkppionDCAz", "DCAz distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {dcazAxis}); - histos.add("QAMC/trkppionpT", "pT distribution of secondary pion 1 (positive) candidates", HistType::kTH1D, {ptAxis}); - histos.add("QAMC/trkppionTPCPID", "TPC PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); - histos.add("QAMC/trkppionTOFPID", "TOF PID of secondary pion 1 (positive) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); - histos.add("QAMC/trkppionTPCTOFPID", "TPC-TOF PID map of secondary pion 1 (positive) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); - - // Secondary pion 2 - histos.add("QAMC/trknpionTPCPID", "TPC PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); - histos.add("QAMC/trknpionTOFPID", "TOF PID of secondary pion 2 (negative) candidates", HistType::kTH2D, {ptAxis, pidQAAxis}); - histos.add("QAMC/trknpionTPCTOFPID", "TPC-TOF PID map of secondary pion 2 (negative) candidates", HistType::kTH2D, {pidQAAxis, pidQAAxis}); - histos.add("QAMC/trknpionpT", "pT distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {ptAxis}); - histos.add("QAMC/trknpionDCAxy", "DCAxy distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcaxyAxis}); - histos.add("QAMC/trknpionDCAz", "DCAz distribution of secondary pion 2 (negative) candidates", HistType::kTH1D, {dcazAxis}); - - // Secondary Resonance (K0s cand) - histos.add("QAMC/hDauDCASecondary", "DCA of daughters of secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QAMC/hDauPosDCAtoPVSecondary", "Pos DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QAMC/hDauNegDCAtoPVSecondary", "Neg DCA to PV of daughters secondary resonance", HistType::kTH1D, {dcaAxis}); - - histos.add("QAMC/hpT_Secondary", "pT distribution of secondary resonance", HistType::kTH1D, {ptAxis}); - histos.add("QAMC/hy_Secondary", "Rapidity distribution of secondary resonance", HistType::kTH1D, {yAxis}); - histos.add("QAMC/hRadiusSecondary", "Radius distribution of secondary resonance", HistType::kTH1D, {radiusAxis}); - histos.add("QAMC/hCPASecondary", "Cosine pointing angle distribution of secondary resonance", HistType::kTH1D, {cpaAxis}); - histos.add("QAMC/hDCAtoPVSecondary", "DCA to PV distribution of secondary resonance", HistType::kTH1D, {dcaAxis}); - histos.add("QAMC/hPropTauSecondary", "Proper Lifetime distribution of secondary resonance", HistType::kTH1D, {tauAxis}); - histos.add("QAMC/hPtAsymSecondary", "pT asymmetry distribution of secondary resonance", HistType::kTH1D, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); - histos.add("QAMC/hInvmassSecondary", "Invariant mass of unlike-sign secondary resonance", HistType::kTH1D, {invMassAxisK0s}); - - // K892 - histos.add("QAMC/KstarOA", "Opening angle of chK(892)", HistType::kTH1D, {AxisSpec{100, 0, 3.14, "Opening angle"}}); - histos.add("QAMC/KstarPairAsym", "Pair asymmetry of chK(892)", HistType::kTH1D, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); - histos.add("QAMC/KstarRapidity", "Rapidity distribution of chK(892)", HistType::kTH1D, {yAxis}); - - histos.add("QAMC/kstarinvmass", "Invariant mass of unlike-sign chK(892)", HistType::kTH1D, {invMassAxisReso}); - histos.add("QAMC/k0sv2vsinvmass", "Invariant mass vs v2 of unlike-sign K0s", HistType::kTH2D, {invMassAxisK0s, v2Axis}); - histos.add("QAMC/kstarv2vsinvmass", "Invariant mass vs v2 of unlike-sign chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); - histos.add("QAMC/kstarinvmass_noKstar", "Invariant mass of unlike-sign no chK(892)", HistType::kTH1D, {invMassAxisReso}); - histos.add("QAMC/kstarv2vsinvmass_noKstar", "Invariant mass vs v2 of unlike-sign no chK(892)", HistType::kTH2D, {invMassAxisReso, v2Axis}); - - histos.add("hInvmass_Kstar_MC", "Invariant mass of unlike chK(892)", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso, v2Axis}); - - ccdb->setURL(cfgURL); - ccdbApi.init("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - } - - // Print output histograms statistics - LOG(info) << "Size of the histograms in chK(892) Analysis Task"; - histos.print(); - } - - template - float GetCentrality(CollisionType const& collision) - { - if (cfgCentEst == 1) { - return collision.centFT0C(); - } else if (cfgCentEst == 2) { - return collision.centFT0M(); - } else { - return -999; - } - } - - template - int GetDetId(DetNameType const& name) - { - LOGF(info, "GetDetID running"); - if (name.value == "FT0C") { - return 0; - } else if (name.value == "FT0A") { - return 1; - } else if (name.value == "FT0M") { - return 2; - } else if (name.value == "FV0A") { - return 3; - } else if (name.value == "TPCpos") { - return 4; - } else if (name.value == "TPCneg") { - return 5; - } else { - return false; - } - } - - // Track selection - template - bool trackCut(TrackType const& track) - { - // basic track cuts - if (std::abs(track.pt()) < cMinPtcut) - return false; - if (std::abs(track.eta()) > cMaxEtacut) - return false; - if (track.itsNCls() < cfgITScluster) - return false; - if (track.tpcNClsFound() < cfgTPCcluster) - return false; - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) - return false; - if (track.itsChi2NCl() >= cfgITSChi2NCl) - return false; - if (track.tpcChi2NCl() >= cfgTPCChi2NCl) - return false; - if (cfgHasITS && !track.hasITS()) - return false; - if (cfgHasTPC && !track.hasTPC()) - return false; - if (cfgHasTOF && !track.hasTOF()) - return false; - if (cfgUseITSRefit && !track.passedITSRefit()) - return false; - if (cfgUseTPCRefit && !track.passedTPCRefit()) - return false; - if (cfgPVContributor && !track.isPVContributor()) - return false; - if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) - return false; - if (cfgGlobalTrack && !track.isGlobalTrack()) - return false; - if (cfgPrimaryTrack && !track.isPrimaryTrack()) - return false; - if (std::abs(track.dcaXY()) > cMaxbDCArToPVcut) - return false; - if (std::abs(track.dcaZ()) > cMaxbDCAzToPVcut) - return false; - return true; - } - - // PID selection tools - template - bool selectionPIDPion(TrackType const& candidate) - { - bool tpcPIDPassed{false}, tofPIDPassed{false}; - - if (cTPConly) { - - if (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { - tpcPIDPassed = true; - } else { - return false; - } - tofPIDPassed = true; - - } else { - - if (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { - tpcPIDPassed = true; - } else { - return false; - } - if (candidate.hasTOF()) { - if (std::abs(candidate.tofNSigmaPi()) < cMaxTOFnSigmaPion) { - tofPIDPassed = true; - } - if ((nsigmaCutCombinedPion > 0) && (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + candidate.tofNSigmaPi() * candidate.tofNSigmaPi() < nsigmaCutCombinedPion * nsigmaCutCombinedPion)) { - tofPIDPassed = true; - } - } else { - if (!cTOFVeto) { - return false; - } - tofPIDPassed = true; - } - } - - if (tpcPIDPassed && tofPIDPassed) { - return true; - } - return false; - } - - template - bool selectionK0s(CollisionType const& collision, K0sType const& candidate) - { - auto DauDCA = candidate.dcaV0daughters(); - auto DauPosDCAtoPV = candidate.dcapostopv(); - auto DauNegDCAtoPV = candidate.dcanegtopv(); - auto pT = candidate.pt(); - auto Rapidity = candidate.yK0Short(); - auto Radius = candidate.v0radius(); - auto DCAtoPV = candidate.dcav0topv(); - auto CPA = candidate.v0cosPA(); - auto PropTauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassK0Short; - auto mK0s = candidate.mK0Short(); - - if (cfgReturnFlag) { - bool returnFlag = true; - - if (cSecondaryRequire) { - histos.fill(HIST("QA/K0sCutCheck"), 0); - if (DauDCA > cSecondaryDauDCAMax) { - histos.fill(HIST("QA/K0sCutCheck"), 1); - returnFlag = false; - } - if (DauPosDCAtoPV < cSecondaryDauPosDCAtoPVMin) { - histos.fill(HIST("QA/K0sCutCheck"), 2); - returnFlag = false; - } - if (DauNegDCAtoPV < cSecondaryDauNegDCAtoPVMin) { - histos.fill(HIST("QA/K0sCutCheck"), 3); - returnFlag = false; - } - if (pT < cSecondaryPtMin) { - histos.fill(HIST("QA/K0sCutCheck"), 4); - returnFlag = false; - } - if (Rapidity > cSecondaryRapidityMax) { - histos.fill(HIST("QA/K0sCutCheck"), 5); - returnFlag = false; - } - if (Radius < cSecondaryRadiusMin) { - histos.fill(HIST("QA/K0sCutCheck"), 6); - returnFlag = false; - } - if (DCAtoPV > cSecondaryDCAtoPVMax) { - histos.fill(HIST("QA/K0sCutCheck"), 7); - returnFlag = false; - } - if (CPA < cSecondaryCosPAMin) { - histos.fill(HIST("QA/K0sCutCheck"), 8); - returnFlag = false; - } - if (PropTauK0s > cSecondaryProperLifetimeMax) { - histos.fill(HIST("QA/K0sCutCheck"), 9); - returnFlag = false; - } - if (candidate.qtarm() < cSecondaryparamArmenterosCut * TMath::Abs(candidate.alpha())) { - histos.fill(HIST("QA/K0sCutCheck"), 11); - returnFlag = false; - } - if (std::fabs(mK0s - MassK0Short) > cSecondaryMassWindow) { - histos.fill(HIST("QA/K0sCutCheck"), 10); - returnFlag = false; - } - - return returnFlag; - - } else { - if (std::fabs(mK0s - MassK0Short) > cSecondaryMassWindow) { - histos.fill(HIST("QA/K0sCutCheck"), 10); - returnFlag = false; - } - - return returnFlag; - } - - } else { - if (cSecondaryRequire) { - - histos.fill(HIST("QA/K0sCutCheck"), 0); - if (DauDCA > cSecondaryDauDCAMax) { - histos.fill(HIST("QA/K0sCutCheck"), 1); - return false; - } - if (DauPosDCAtoPV < cSecondaryDauPosDCAtoPVMin) { - histos.fill(HIST("QA/K0sCutCheck"), 2); - return false; - } - if (DauNegDCAtoPV < cSecondaryDauNegDCAtoPVMin) { - histos.fill(HIST("QA/K0sCutCheck"), 3); - return false; - } - if (pT < cSecondaryPtMin) { - histos.fill(HIST("QA/K0sCutCheck"), 4); - return false; - } - if (Rapidity > cSecondaryRapidityMax) { - histos.fill(HIST("QA/K0sCutCheck"), 5); - return false; - } - if (Radius < cSecondaryRadiusMin) { - histos.fill(HIST("QA/K0sCutCheck"), 6); - return false; - } - if (DCAtoPV > cSecondaryDCAtoPVMax) { - histos.fill(HIST("QA/K0sCutCheck"), 7); - return false; - } - if (CPA < cSecondaryCosPAMin) { - histos.fill(HIST("QA/K0sCutCheck"), 8); - return false; - } - if (PropTauK0s > cSecondaryProperLifetimeMax) { - histos.fill(HIST("QA/K0sCutCheck"), 9); - return false; - } - if (candidate.qtarm() < cSecondaryparamArmenterosCut * TMath::Abs(candidate.alpha())) { - histos.fill(HIST("QA/K0sCutCheck"), 11); - return false; - } - if (std::fabs(mK0s - MassK0Short) > cSecondaryMassWindow) { - histos.fill(HIST("QA/K0sCutCheck"), 10); - return false; - } - return true; - - } else { - if (std::fabs(mK0s - MassK0Short) > cSecondaryMassWindow) { - histos.fill(HIST("QA/K0sCutCheck"), 10); - return false; - } - return true; - } - } - } // selectionK0s - - double GetPhiInRange(double phi) - { - double result = phi; - while (result < 0) { - result = result + 2. * o2::constants::math::PI / 2; - } - while (result > 2. * o2::constants::math::PI / 2) { - result = result - 2. * o2::constants::math::PI / 2; - } - return result; - } - - template - bool isTrueKstar(const TrackTemplate& bTrack, const V0Template& K0scand) - { - if (std::abs(bTrack.PDGCode()) != kPiPlus) // Are you pion? - return false; - if (std::abs(K0scand.PDGCode()) != kPDGK0s) // Are you K0s? - return false; - - auto motherbTrack = bTrack.template mothers_as(); - auto motherkV0 = K0scand.template mothers_as(); - - // Check bTrack first - if (std::abs(motherbTrack.pdgCode()) != kKstarPlus) // Are you charged Kstar's daughter? - return false; // Apply first since it's more restrictive - - if (std::abs(motherkV0.pdgCode()) != 310) // Is it K0s? - return false; - // Check if K0s's mother is K0 (311) - auto motherK0 = motherkV0.template mothers_as(); - if (std::abs(motherK0.pdgCode()) != 311) - return false; - - // Check if K0's mother is Kstar (323) - auto motherKstar = motherK0.template mothers_as(); - if (std::abs(motherKstar.pdgCode()) != 323) - return false; - - // Check if bTrack and K0 have the same mother (global index) - if (motherbTrack.globalIndex() != motherK0.globalIndex()) - return false; - - return true; - } - - int count = 0; - - template - void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksTypeK0s& dTracks2, int nmode) - { - histos.fill(HIST("QA/before/CentDist"), centrality); - - QvecDetInd = DetId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; - QvecRefAInd = RefAId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; - QvecRefBInd = RefBId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; - - double EPDet = TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) / static_cast(nmode); - double EPRefB = TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) / static_cast(nmode); - double EPRefC = TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]) / static_cast(nmode); - - double EPResAB = TMath::Cos(static_cast(nmode) * (EPDet - EPRefB)); - double EPResAC = TMath::Cos(static_cast(nmode) * (EPDet - EPRefC)); - double EPResBC = TMath::Cos(static_cast(nmode) * (EPRefB - EPRefC)); - - histos.fill(HIST("QA/EP/hEPDet"), centrality, EPDet); - histos.fill(HIST("QA/EP/hEPB"), centrality, EPRefB); - histos.fill(HIST("QA/EP/hEPC"), centrality, EPRefC); - histos.fill(HIST("QA/EP/hEPResAB"), centrality, EPResAB); - histos.fill(HIST("QA/EP/hEPResAC"), centrality, EPResAC); - histos.fill(HIST("QA/EP/hEPResBC"), centrality, EPResBC); - - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResoSecondary, lDecayDaughter_bach, lResoKstar; - std::vector trackIndicies = {}; - std::vector k0sIndicies = {}; - - for (auto& bTrack : dTracks1) { - auto trkbpt = bTrack.pt(); - auto istrkbhasTOF = bTrack.hasTOF(); - auto trkbNSigmaPiTPC = bTrack.tpcNSigmaPi(); - auto trkbNSigmaPiTOF = (istrkbhasTOF) ? bTrack.tofNSigmaPi() : -999.; - - if constexpr (!IsMix) { - // Bachelor pion QA plots - histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); - } - - if (!trackCut(bTrack)) - continue; - if (!selectionPIDPion(bTrack)) - continue; - - if constexpr (!IsMix) { - // Bachelor pion QA plots after applying cuts - histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); - } - trackIndicies.push_back(bTrack.index()); - } - - for (auto& K0scand : dTracks2) { - auto posDauTrack = K0scand.template posTrack_as(); - auto negDauTrack = K0scand.template negTrack_as(); - - /// Daughters - // Positve pion - auto trkppt = posDauTrack.pt(); - auto istrkphasTOF = posDauTrack.hasTOF(); - auto trkpNSigmaPiTPC = posDauTrack.tpcNSigmaPi(); - auto trkpNSigmaPiTOF = (istrkphasTOF) ? posDauTrack.tofNSigmaPi() : -999.; - // Negative pion - auto trknpt = negDauTrack.pt(); - auto istrknhasTOF = negDauTrack.hasTOF(); - auto trknNSigmaPiTPC = negDauTrack.tpcNSigmaPi(); - auto trknNSigmaPiTOF = (istrknhasTOF) ? negDauTrack.tofNSigmaPi() : -999.; - - /// K0s - auto trkkDauDCA = K0scand.dcaV0daughters(); - auto trkkDauDCAPostoPV = K0scand.dcapostopv(); - auto trkkDauDCANegtoPV = K0scand.dcanegtopv(); - auto trkkpt = K0scand.pt(); - auto trkky = K0scand.yK0Short(); - auto trkkRadius = K0scand.v0radius(); - auto trkkDCAtoPV = K0scand.dcav0topv(); - auto trkkCPA = K0scand.v0cosPA(); - auto trkkPropTau = K0scand.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassK0Short; - auto trkkMass = K0scand.mK0Short(); - - if constexpr (!IsMix) { - // Seconddary QA plots - histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkppionpT"), trkppt); - histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trknpionpT"), trknpt); - histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/before/hy_Secondary"), trkky); - histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); - } - - // if (!trackCut(posDauTrack) || !trackCut(negDauTrack)) // Too tight cut for K0s daugthers - // continue; - if (!cfgByPassDauPIDSelection && !selectionPIDPion(posDauTrack)) // Perhaps it's already applied in trackCut (need to check QA plots) - continue; - if (!cfgByPassDauPIDSelection && !selectionPIDPion(negDauTrack)) - continue; - if (!selectionK0s(collision, K0scand)) - continue; - - if constexpr (!IsMix) { - // Seconddary QA plots after applying cuts - - histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkppionpT"), trkppt); - histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trknpionpT"), trknpt); - histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/after/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/after/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/after/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/after/hy_Secondary"), trkky); - histos.fill(HIST("QA/after/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); - } - k0sIndicies.push_back(K0scand.index()); - } - - for (auto& trackIndex : trackIndicies) { - for (auto& k0sIndex : k0sIndicies) { - auto bTrack = dTracks1.rawIteratorAt(trackIndex); - auto K0scand = dTracks2.rawIteratorAt(k0sIndex); - - lDecayDaughter_bach.SetXYZM(bTrack.px(), bTrack.py(), bTrack.pz(), MassPionCharged); - lResoSecondary.SetXYZM(K0scand.px(), K0scand.py(), K0scand.pz(), MassK0Short); - lResoKstar = lResoSecondary + lDecayDaughter_bach; - - auto phiminuspsi_k0s = GetPhiInRange(lResoSecondary.Phi() - EPDet); - auto phiminuspsi_kstar = GetPhiInRange(lResoKstar.Phi() - EPDet); - auto v2_k0s = TMath::Cos(static_cast(nmode) * phiminuspsi_k0s); - auto v2_kstar = TMath::Cos(static_cast(nmode) * phiminuspsi_kstar); - - // QA plots - if constexpr (!IsMix) { - histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); - histos.fill(HIST("QA/before/k0sv2vsinvmass"), lResoSecondary.M(), v2_k0s); - histos.fill(HIST("QA/before/kstarv2vsinvmass"), lResoKstar.M(), v2_kstar); - } - - if (lResoKstar.Rapidity() > cKstarMaxRap || lResoKstar.Rapidity() < cKstarMinRap) - continue; - - if constexpr (!IsMix) { - unsigned int typeKstar = bTrack.sign() > 0 ? binType::kKstarP : binType::kKstarN; - - histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); - histos.fill(HIST("QA/after/k0sv2vsinvmass"), lResoSecondary.M(), v2_k0s); - histos.fill(HIST("QA/after/kstarv2vsinvmass"), lResoKstar.M(), v2_kstar); - histos.fill(HIST("hInvmass_Kstar"), typeKstar, centrality, lResoKstar.Pt(), lResoKstar.M(), v2_kstar); - - } // IsMix - } // K0scand - } // bTrack - - count++; - - } // fillHistograms - - // process data - void processData(EventCandidates::iterator const& collision, - TrackCandidates const& tracks, - V0Candidates const& v0s, - aod::BCsWithTimestamps const&) - { - if (!colCuts.isSelected(collision)) // Default event selection - return; - if (cfgQvecSel && (collision.qvecAmp()[DetId] < 1e-4 || collision.qvecAmp()[RefAId] < 1e-4 || collision.qvecAmp()[RefBId] < 1e-4)) - return; // If we don't have a Q-vector - colCuts.fillQA(collision); - centrality = GetCentrality(collision); - - fillHistograms(collision, tracks, v0s, 2); // second order - } - PROCESS_SWITCH(chk892flow, processData, "Process Event for data without Partitioning", true); - - // process MC reconstructed level - void processMC(EventCandidates::iterator const& collision, - MCTrackCandidates const& tracks, - MCV0Candidates const& v0s) - { - - histos.fill(HIST("QAMC/hEvent"), 1.0); - - fillHistograms(collision, tracks, v0s, 2); - } - PROCESS_SWITCH(chk892flow, processMC, "Process Event for MC", false); -}; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"lf-chk892flow"})}; -} diff --git a/PWGLF/Tasks/Resonances/chk892flow_pp.cxx b/PWGLF/Tasks/Resonances/chk892flow_pp.cxx index 2adc9170064..7e1d65bd7e8 100644 --- a/PWGLF/Tasks/Resonances/chk892flow_pp.cxx +++ b/PWGLF/Tasks/Resonances/chk892flow_pp.cxx @@ -134,7 +134,6 @@ struct chk892_pp { Configurable ConfEvtOccupancyInTimeRangeMax{"ConfEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; Configurable ConfEvtOccupancyInTimeRangeMin{"ConfEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; Configurable ConfEvtTriggerCheck{"ConfEvtTriggerCheck", false, "Evt sel: check for trigger"}; - Configurable ConfEvtTriggerSel{"ConfEvtTriggerSel", 8, "Evt sel: trigger"}; Configurable ConfEvtOfflineCheck{"ConfEvtOfflineCheck", true, "Evt sel: check for offline selection"}; Configurable ConfEvtTriggerTVXSel{"ConfEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; Configurable ConfEvtTFBorderCut{"ConfEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; @@ -222,7 +221,7 @@ struct chk892_pp { { centrality = -999; - colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, ConfEvtOccupancyInTimeRangeMax, ConfEvtOccupancyInTimeRangeMin); + colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, ConfEvtOccupancyInTimeRangeMax, ConfEvtOccupancyInTimeRangeMin); colCuts.init(&histos); colCuts.setTriggerTVX(ConfEvtTriggerTVXSel); colCuts.setApplyTFBorderCut(ConfEvtTFBorderCut); diff --git a/PWGLF/Tasks/Resonances/chk892pp.cxx b/PWGLF/Tasks/Resonances/chk892pp.cxx index e61226dd567..410643d6c6b 100644 --- a/PWGLF/Tasks/Resonances/chk892pp.cxx +++ b/PWGLF/Tasks/Resonances/chk892pp.cxx @@ -63,6 +63,7 @@ #include "Common/Core/RecoDecay.h" #include "CommonConstants/PhysicsConstants.h" +#include "CommonConstants/MathConstants.h" #include "ReconstructionDataFormats/Track.h" @@ -80,23 +81,16 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::constants::physics; +using namespace o2::aod::rctsel; -struct chk892pp { - enum binType : unsigned int { +struct Chk892pp { + enum BinType : unsigned int { kKstarP = 0, kKstarN, kKstarP_Mix, kKstarN_Mix, - kKstarP_GenINEL10, - kKstarN_GenINEL10, - kKstarP_GenINELgt10, - kKstarN_GenINELgt10, - kKstarP_GenTrig10, - kKstarN_GenTrig10, - kKstarP_GenEvtSel, - kKstarN_GenEvtSel, - kKstarP_Rec, - kKstarN_Rec, + kKstarP_Rot, + kKstarN_Rot, kTYEnd }; @@ -118,36 +112,45 @@ struct chk892pp { Service pdg; o2::ccdb::CcdbApi ccdbApi; - Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; - Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; + struct : ConfigurableGroup { + Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + } CCDBConfig; + // Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; // Configurables - ConfigurableAxis cfgBinsPt{"cfgBinsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; - ConfigurableAxis cfgBinsPtQA{"cfgBinsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0}, "Binning of the pT axis"}; - ConfigurableAxis cfgBinsCent{"cfgBinsCent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; - ConfigurableAxis cfgBinsVtxZ{"cfgBinsVtxZ", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "Binning of the z-vertex axis"}; - Configurable cNbinsDiv{"cNbinsDiv", 1, "Integer to divide the number of bins"}; + struct : ConfigurableGroup { + ConfigurableAxis cfgBinsPt{"cfgBinsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; + ConfigurableAxis cfgBinsPtQA{"cfgBinsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0}, "Binning of the pT axis"}; + ConfigurableAxis cfgBinsCent{"cfgBinsCent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; + ConfigurableAxis cfgBinsVtxZ{"cfgBinsVtxZ", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "Binning of the z-vertex axis"}; + Configurable cNbinsDiv{"cNbinsDiv", 1, "Integer to divide the number of bins"}; + Configurable cNbinsDivQA{"cNbinsDivQA", 1, "Integer to divide the number of bins for QA"}; + } AxisConfig; /// Event cuts o2::analysis::CollisonCuts colCuts; - Configurable ConfEvtZvtx{"ConfEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; - Configurable ConfEvtOccupancyInTimeRangeMax{"ConfEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; - Configurable ConfEvtOccupancyInTimeRangeMin{"ConfEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; - Configurable ConfEvtTriggerCheck{"ConfEvtTriggerCheck", false, "Evt sel: check for trigger"}; - Configurable ConfEvtTriggerSel{"ConfEvtTriggerSel", 8, "Evt sel: trigger"}; - Configurable ConfEvtOfflineCheck{"ConfEvtOfflineCheck", true, "Evt sel: check for offline selection"}; - Configurable ConfEvtTriggerTVXSel{"ConfEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; - Configurable ConfEvtTFBorderCut{"ConfEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; - Configurable ConfEvtUseITSTPCvertex{"ConfEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; - Configurable ConfEvtZvertexTimedifference{"ConfEvtZvertexTimedifference", true, "Evt sel: apply Z-vertex time difference"}; - Configurable ConfEvtPileupRejection{"ConfEvtPileupRejection", true, "Evt sel: apply pileup rejection"}; - Configurable ConfEvtNoITSROBorderCut{"ConfEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; - Configurable ConfincludeCentralityMC{"ConfincludeCentralityMC", false, "Include centrality in MC"}; - Configurable ConfEvtCollInTimeRangeStandard{"ConfEvtCollInTimeRangeStandard", true, "Evt sel: apply NoCollInTimeRangeStandard"}; - - /// Track selections - Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"}; - Configurable cMaxEtacut{"cMaxEtacut", 0.8, "Track maximum eta cut"}; + struct : ConfigurableGroup { + Configurable cfgEvtZvtx{"cfgEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable cfgEvtOccupancyInTimeRangeMax{"cfgEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; + Configurable cfgEvtOccupancyInTimeRangeMin{"cfgEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; + Configurable cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"}; + Configurable cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"}; + Configurable cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; + Configurable cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; + Configurable cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; + Configurable cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", true, "Evt sel: apply Z-vertex time difference"}; + Configurable cfgEvtPileupRejection{"cfgEvtPileupRejection", true, "Evt sel: apply pileup rejection"}; + Configurable cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + Configurable cfgincludeCentralityMC{"cfgincludeCentralityMC", false, "Include centrality in MC"}; + Configurable cfgEvtCollInTimeRangeStandard{"cfgEvtCollInTimeRangeStandard", true, "Evt sel: apply NoCollInTimeRangeStandard"}; + Configurable cfgEventCentralityMin{"cfgEventCentralityMin", 0.0f, "Event sel: minimum centrality"}; + Configurable cfgEventCentralityMax{"cfgEventCentralityMax", 80.0f, "Event sel: maximum centrality"}; + Configurable cfgEvtUseRCTFlagChecker{"cfgEvtUseRCTFlagChecker", false, "Evt sel: use RCT flag checker"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", false, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } EventCuts; + RCTFlagsChecker rctChecker; /* // Cuts from polarization analysis @@ -158,86 +161,111 @@ struct chk892pp { */ Configurable cfgCentEst{"cfgCentEst", 1, "Centrality estimator, 1: FT0C, 2: FT0M"}; - // DCAr to PV - Configurable cMaxbDCArToPVcut{"cMaxbDCArToPVcut", 0.1, "Track DCAr cut to PV Maximum"}; - // DCAz to PV - Configurable cMaxbDCAzToPVcut{"cMaxbDCAzToPVcut", 0.1, "Track DCAz cut to PV Maximum"}; - /// PID Selections, pion - Configurable cTPConly{"cTPConly", true, "Use only TPC for PID"}; // bool - Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC - Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF - Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; // Combined - Configurable cTOFVeto{"cTOFVeto", true, "TOF Veto, if false, TOF is nessessary for PID selection"}; // TOF Veto + struct : ConfigurableGroup { + Configurable cfgTPConly{"cfgTPConly", true, "Use only TPC for PID"}; // bool + Configurable cfgMaxTPCnSigmaPion{"cfgMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC + Configurable cfgMaxTOFnSigmaPion{"cfgMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF + Configurable cfgNsigmaCutCombinedPion{"cfgNsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; // Combined + Configurable cfgTOFVeto{"cfgTOFVeto", true, "TOF Veto, if false, TOF is nessessary for PID selection"}; // TOF Veto + } PIDCuts; // Track selections - Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz - Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) - Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz - Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor - - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; - Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; - Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; - Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; - Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; - Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; - Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; - Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; - Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; - Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + struct : ConfigurableGroup { + Configurable cfgMinPtcut{"cfgMinPtcut", 0.15, "Track minium pt cut"}; + Configurable cfgMaxEtacut{"cfgMaxEtacut", 0.8, "Track maximum eta cut"}; + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor + + Configurable cfgpTdepDCAxyCut{"cfgpTdepDCAxyCut", false, "pT-dependent DCAxy cut"}; + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; + Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; + Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; + Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; + Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; + Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; + Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; + Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; + Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + // DCAr to PV + Configurable cfgMaxbDCArToPVcut{"cfgMaxbDCArToPVcut", 0.1, "Track DCAr cut to PV Maximum"}; + // DCAz to PV + Configurable cfgMaxbDCAzToPVcut{"cfgMaxbDCAzToPVcut", 0.1, "Track DCAz cut to PV Maximum"}; + } TrackCuts; // Secondary Selection - Configurable cfgReturnFlag{"boolReturnFlag", false, "Return Flag for debugging"}; - Configurable cSecondaryRequire{"bool", true, "Secondary cuts on/off"}; - Configurable cSecondaryArmenterosCut{"boolArmenterosCut", true, "cut on Armenteros-Podolanski graph"}; - - Configurable cfgByPassDauPIDSelection{"cfgByPassDauPIDSelection", true, "Bypass Daughters PID selection"}; - Configurable cSecondaryDauDCAMax{"cSecondaryDauDCAMax", 1., "Maximum DCA Secondary daughters to PV"}; - Configurable cSecondaryDauPosDCAtoPVMin{"cSecondaryDauPosDCAtoPVMin", 0.0, "Minimum DCA Secondary positive daughters to PV"}; - Configurable cSecondaryDauNegDCAtoPVMin{"cSecondaryDauNegDCAtoPVMin", 0.0, "Minimum DCA Secondary negative daughters to PV"}; - - Configurable cSecondaryPtMin{"cSecondaryPtMin", 0.f, "Minimum transverse momentum of Secondary"}; - Configurable cSecondaryRapidityMax{"cSecondaryRapidityMax", 0.5, "Maximum rapidity of Secondary"}; - Configurable cSecondaryRadiusMin{"cSecondaryRadiusMin", 1.2, "Minimum transverse radius of Secondary"}; - Configurable cSecondaryCosPAMin{"cSecondaryCosPAMin", 0.995, "Mininum cosine pointing angle of Secondary"}; - Configurable cSecondaryDCAtoPVMax{"cSecondaryDCAtoPVMax", 0.3, "Maximum DCA Secondary to PV"}; - Configurable cSecondaryProperLifetimeMax{"cSecondaryProperLifetimeMax", 20, "Maximum Secondary Lifetime"}; - Configurable cSecondaryparamArmenterosCut{"paramArmenterosCut", 0.2, "parameter for Armenteros Cut"}; - Configurable cSecondaryMassWindow{"cSecondaryMassWindow", 0.075, "Secondary inv mass selciton window"}; + struct : ConfigurableGroup { + Configurable cfgReturnFlag{"cfgReturnFlag", false, "Return Flag for debugging"}; + Configurable cfgSecondaryRequire{"cfgSecondaryRequire", true, "Secondary cuts on/off"}; + Configurable cfgSecondaryArmenterosCut{"cfgSecondaryArmenterosCut", true, "cut on Armenteros-Podolanski graph"}; + Configurable cfgSecondaryCrossMassHypothesisCut{"cfgSecondaryCrossMassHypothesisCut", false, "Apply cut based on the lambda mass hypothesis"}; + + Configurable cfgByPassDauPIDSelection{"cfgByPassDauPIDSelection", true, "Bypass Daughters PID selection"}; + Configurable cfgSecondaryDauDCAMax{"cfgSecondaryDauDCAMax", 1., "Maximum DCA Secondary daughters to PV"}; + Configurable cfgSecondaryDauPosDCAtoPVMin{"cfgSecondaryDauPosDCAtoPVMin", 0.0, "Minimum DCA Secondary positive daughters to PV"}; + Configurable cfgSecondaryDauNegDCAtoPVMin{"cfgSecondaryDauNegDCAtoPVMin", 0.0, "Minimum DCA Secondary negative daughters to PV"}; + + Configurable cfgSecondaryPtMin{"cfgSecondaryPtMin", 0.f, "Minimum transverse momentum of Secondary"}; + Configurable cfgSecondaryRapidityMax{"cfgSecondaryRapidityMax", 0.8, "Maximum rapidity of Secondary"}; + Configurable cfgSecondaryRadiusMin{"cfgSecondaryRadiusMin", 1.2, "Minimum transverse radius of Secondary"}; + Configurable cfgSecondaryRadiusMax{"cfgSecondaryRadiusMax", 999.9, "Maximum transverse radius of Secondary"}; + Configurable cfgSecondaryCosPAMin{"cfgSecondaryCosPAMin", 0.995, "Mininum cosine pointing angle of Secondary"}; + Configurable cfgSecondaryDCAtoPVMax{"cfgSecondaryDCAtoPVMax", 0.3, "Maximum DCA Secondary to PV"}; + Configurable cfgSecondaryProperLifetimeMax{"cfgSecondaryProperLifetimeMax", 20, "Maximum Secondary Lifetime"}; + Configurable cfgSecondaryparamArmenterosCut{"cfgSecondaryparamArmenterosCut", 0.2, "parameter for Armenteros Cut"}; + Configurable cfgSecondaryMassWindow{"cfgSecondaryMassWindow", 0.03, "Secondary inv mass selciton window"}; + Configurable cfgSecondaryCrossMassCutWindow{"cfgSecondaryCrossMassCutWindow", 0.05, "Secondary inv mass selection window with (anti)lambda hypothesis"}; + } SecondaryCuts; // K* selection - Configurable cKstarMaxRap{"cKstarMaxRap", 0.5, "Kstar maximum rapidity"}; - Configurable cKstarMinRap{"cKstarMinRap", -0.5, "Kstar minimum rapidity"}; - - float centrality; + struct : ConfigurableGroup { + Configurable cfgKstarMaxRap{"cfgKstarMaxRap", 0.5, "Kstar maximum rapidity"}; + Configurable cfgKstarMinRap{"cfgKstarMinRap", -0.5, "Kstar minimum rapidity"}; + } KstarCuts; + + // Bkg estimation + struct : ConfigurableGroup { + Configurable cfgFillRotBkg{"cfgFillRotBkg", true, "Fill rotated background"}; + Configurable cfgMinRot{"cfgMinRot", 5.0 * constants::math::PI / 6.0, "Minimum of rotation"}; + Configurable cfgMaxRot{"cfgMaxRot", 7.0 * constants::math::PI / 6.0, "Maximum of rotation"}; + Configurable cfgRotPion{"cfgRotPion", true, "Rotate pion"}; + Configurable cfgNrotBkg{"cfgNrotBkg", 4, "Number of rotated copies (background) per each original candidate"}; + } BkgEstimationConfig; + + float lCentrality; // PDG code - int kPDGK0s = 310; - int kPDGK0 = 311; - int kKstarPlus = 323; - int kPiPlus = 211; + int kPDGK0s = kK0Short; + int kPDGK0 = kK0; + int kKstarPlus = o2::constants::physics::Pdg::kKPlusStar892; + // int kPiPlus = 211; void init(o2::framework::InitContext&) { - centrality = -999; + lCentrality = -999; - colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, ConfEvtOccupancyInTimeRangeMax, ConfEvtOccupancyInTimeRangeMin); + colCuts.setCuts(EventCuts.cfgEvtZvtx, EventCuts.cfgEvtTriggerCheck, EventCuts.cfgEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, EventCuts.cfgEvtOccupancyInTimeRangeMax, EventCuts.cfgEvtOccupancyInTimeRangeMin); colCuts.init(&histos); - colCuts.setTriggerTVX(ConfEvtTriggerTVXSel); - colCuts.setApplyTFBorderCut(ConfEvtTFBorderCut); - colCuts.setApplyITSTPCvertex(ConfEvtUseITSTPCvertex); - colCuts.setApplyZvertexTimedifference(ConfEvtZvertexTimedifference); - colCuts.setApplyPileupRejection(ConfEvtPileupRejection); - colCuts.setApplyNoITSROBorderCut(ConfEvtNoITSROBorderCut); - colCuts.setApplyCollInTimeRangeStandard(ConfEvtCollInTimeRangeStandard); - - AxisSpec centAxis = {cfgBinsCent, "T0M (%)"}; - AxisSpec vtxzAxis = {cfgBinsVtxZ, "Z Vertex (cm)"}; + colCuts.setTriggerTVX(EventCuts.cfgEvtTriggerTVXSel); + colCuts.setApplyTFBorderCut(EventCuts.cfgEvtTFBorderCut); + colCuts.setApplyITSTPCvertex(EventCuts.cfgEvtUseITSTPCvertex); + colCuts.setApplyZvertexTimedifference(EventCuts.cfgEvtZvertexTimedifference); + colCuts.setApplyPileupRejection(EventCuts.cfgEvtPileupRejection); + colCuts.setApplyNoITSROBorderCut(EventCuts.cfgEvtNoITSROBorderCut); + colCuts.setApplyCollInTimeRangeStandard(EventCuts.cfgEvtCollInTimeRangeStandard); + colCuts.printCuts(); + + rctChecker.init(EventCuts.cfgEvtRCTFlagCheckerLabel, EventCuts.cfgEvtRCTFlagCheckerZDCCheck, EventCuts.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + + AxisSpec centAxis = {AxisConfig.cfgBinsCent, "T0M (%)"}; + AxisSpec vtxzAxis = {AxisConfig.cfgBinsVtxZ, "Z Vertex (cm)"}; AxisSpec epAxis = {100, -1.0 * constants::math::PI, constants::math::PI}; AxisSpec epresAxis = {100, -1.02, 1.02}; - AxisSpec ptAxis = {cfgBinsPt, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec ptAxisQA = {cfgBinsPtQA, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec ptAxis = {AxisConfig.cfgBinsPt, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec ptAxisQA = {AxisConfig.cfgBinsPtQA, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec radiusAxis = {50, 0, 5, "Radius (cm)"}; AxisSpec cpaAxis = {50, 0.95, 1.0, "CPA"}; AxisSpec tauAxis = {250, 0, 25, "Lifetime (cm)"}; @@ -245,15 +273,14 @@ struct chk892pp { AxisSpec dcaxyAxis = {200, 0, 2, "DCA_{#it{xy}} (cm)"}; AxisSpec dcazAxis = {200, 0, 2, "DCA_{#it{z}} (cm)"}; AxisSpec yAxis = {100, -1, 1, "Rapidity"}; - AxisSpec invMassAxisK0s = {400 / cNbinsDiv, 0.3, 0.7, "Invariant Mass (GeV/#it{c}^2)"}; // K0s ~497.611 - AxisSpec invMassAxisReso = {900 / cNbinsDiv, 0.5f, 1.4f, "Invariant Mass (GeV/#it{c}^2)"}; // chK(892) ~892 - AxisSpec invMassAxisScan = {150, 0, 1.5, "Invariant Mass (GeV/#it{c}^2)"}; // For selection - AxisSpec pidQAAxis = {130, -6.5, 6.5}; + AxisSpec invMassAxisK0s = {800 / AxisConfig.cNbinsDiv, 0.46, 0.54, "Invariant Mass (GeV/#it{c}^2)"}; // K0s ~497.611 + AxisSpec invMassAxisReso = {900 / AxisConfig.cNbinsDiv, 0.5f, 1.4f, "Invariant Mass (GeV/#it{c}^2)"}; // chK(892) ~892 + AxisSpec pidQAAxis = {130 / AxisConfig.cNbinsDivQA, -6.5, 6.5}; AxisSpec dataTypeAxis = {9, 0, 9, "Histogram types"}; AxisSpec mcTypeAxis = {4, 0, 4, "Histogram types"}; // THnSparse - AxisSpec axisType = {binType::kTYEnd, 0, binType::kTYEnd, "Type of bin with charge and mix"}; + AxisSpec axisType = {BinType::kTYEnd, 0, BinType::kTYEnd, "Type of bin with charge and mix"}; AxisSpec mcLabelAxis = {5, -0.5, 4.5, "MC Label"}; histos.add("QA/K0sCutCheck", "Check K0s cut", HistType::kTH1D, {AxisSpec{12, -0.5, 11.5, "Check"}}); @@ -398,7 +425,7 @@ struct chk892pp { histos.add("hInvmass_Kstar_MC", "Invariant mass of unlike chK(892)", HistType::kTHnSparseD, {axisType, centAxis, ptAxis, invMassAxisReso}); - ccdb->setURL(cfgURL); + ccdb->setURL(CCDBConfig.cfgURL); ccdbApi.init("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); @@ -411,7 +438,7 @@ struct chk892pp { } template - float GetCentrality(CollisionType const& collision) + float getCentrality(CollisionType const& collision) { if (cfgCentEst == 1) { return collision.multFT0C(); @@ -423,7 +450,7 @@ struct chk892pp { } template - int GetDetId(DetNameType const& name) + int getlDetId(DetNameType const& name) { LOGF(info, "GetDetID running"); if (name.value == "FT0C") { @@ -448,41 +475,47 @@ struct chk892pp { bool trackCut(TrackType const& track) { // basic track cuts - if (std::abs(track.pt()) < cMinPtcut) - return false; - if (std::abs(track.eta()) > cMaxEtacut) + if (std::abs(track.pt()) < TrackCuts.cfgMinPtcut) return false; - if (track.itsNCls() < cfgITScluster) + if (std::abs(track.eta()) > TrackCuts.cfgMaxEtacut) return false; - if (track.tpcNClsFound() < cfgTPCcluster) + if (track.itsNCls() < TrackCuts.cfgITScluster) return false; - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) + if (track.tpcNClsFound() < TrackCuts.cfgTPCcluster) return false; - if (track.itsChi2NCl() >= cfgITSChi2NCl) + if (track.tpcCrossedRowsOverFindableCls() < TrackCuts.cfgRatioTPCRowsOverFindableCls) return false; - if (track.tpcChi2NCl() >= cfgTPCChi2NCl) + if (track.itsChi2NCl() >= TrackCuts.cfgITSChi2NCl) return false; - if (cfgHasITS && !track.hasITS()) + if (track.tpcChi2NCl() >= TrackCuts.cfgTPCChi2NCl) return false; - if (cfgHasTPC && !track.hasTPC()) + if (TrackCuts.cfgHasITS && !track.hasITS()) return false; - if (cfgHasTOF && !track.hasTOF()) + if (TrackCuts.cfgHasTPC && !track.hasTPC()) return false; - if (cfgUseITSRefit && !track.passedITSRefit()) + if (TrackCuts.cfgHasTOF && !track.hasTOF()) return false; - if (cfgUseTPCRefit && !track.passedTPCRefit()) + if (TrackCuts.cfgUseITSRefit && !track.passedITSRefit()) return false; - if (cfgPVContributor && !track.isPVContributor()) + if (TrackCuts.cfgUseTPCRefit && !track.passedTPCRefit()) return false; - if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + if (TrackCuts.cfgPVContributor && !track.isPVContributor()) return false; - if (cfgGlobalTrack && !track.isGlobalTrack()) + if (TrackCuts.cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) return false; - if (cfgPrimaryTrack && !track.isPrimaryTrack()) + if (TrackCuts.cfgGlobalTrack && !track.isGlobalTrack()) return false; - if (std::abs(track.dcaXY()) > cMaxbDCArToPVcut) + if (TrackCuts.cfgPrimaryTrack && !track.isPrimaryTrack()) return false; - if (std::abs(track.dcaZ()) > cMaxbDCAzToPVcut) + if (TrackCuts.cfgpTdepDCAxyCut) { + // Tuned on the LHC22f anchored MC LHC23d1d on primary pions. 7 Sigmas of the resolution + if (std::abs(track.dcaXY()) > (0.004 + (0.013 / track.pt()))) + return false; + } else { + if (std::abs(track.dcaXY()) > TrackCuts.cfgMaxbDCArToPVcut) + return false; + } + if (std::abs(track.dcaZ()) > TrackCuts.cfgMaxbDCAzToPVcut) return false; return true; } @@ -491,217 +524,158 @@ struct chk892pp { template bool selectionPIDPion(TrackType const& candidate) { - bool tpcPIDPassed{false}, tofPIDPassed{false}; - - if (cTPConly) { + bool tpcPIDPassed = std::abs(candidate.tpcNSigmaPi()) < PIDCuts.cfgMaxTPCnSigmaPion; + bool tofPIDPassed = false; - if (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { - tpcPIDPassed = true; - } else { - return false; - } - tofPIDPassed = true; + if (PIDCuts.cfgTPConly) { + return tpcPIDPassed; + } + if (candidate.hasTOF()) { + tofPIDPassed = std::abs(candidate.tofNSigmaPi()) < PIDCuts.cfgMaxTOFnSigmaPion || + (PIDCuts.cfgNsigmaCutCombinedPion > 0 && + candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + + candidate.tofNSigmaPi() * candidate.tofNSigmaPi() < + PIDCuts.cfgNsigmaCutCombinedPion * PIDCuts.cfgNsigmaCutCombinedPion); } else { - - if (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { - tpcPIDPassed = true; - } else { - return false; - } - if (candidate.hasTOF()) { - if (std::abs(candidate.tofNSigmaPi()) < cMaxTOFnSigmaPion) { - tofPIDPassed = true; - } - if ((nsigmaCutCombinedPion > 0) && (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + candidate.tofNSigmaPi() * candidate.tofNSigmaPi() < nsigmaCutCombinedPion * nsigmaCutCombinedPion)) { - tofPIDPassed = true; - } - } else { - if (!cTOFVeto) { - return false; - } - tofPIDPassed = true; - } + tofPIDPassed = PIDCuts.cfgTOFVeto; } - if (tpcPIDPassed && tofPIDPassed) { - return true; - } - return false; + return tpcPIDPassed && tofPIDPassed; } template bool selectionK0s(CollisionType const& collision, K0sType const& candidate) { - auto DauDCA = candidate.dcaV0daughters(); - auto DauPosDCAtoPV = candidate.dcapostopv(); - auto DauNegDCAtoPV = candidate.dcanegtopv(); - auto pT = candidate.pt(); - auto Rapidity = candidate.yK0Short(); - auto Radius = candidate.v0radius(); - auto DCAtoPV = candidate.dcav0topv(); - auto CPA = candidate.v0cosPA(); - auto PropTauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassK0Short; - auto mK0s = candidate.mK0Short(); - - if (cfgReturnFlag) { - bool returnFlag = true; - - if (cSecondaryRequire) { - histos.fill(HIST("QA/K0sCutCheck"), 0); - if (DauDCA > cSecondaryDauDCAMax) { - histos.fill(HIST("QA/K0sCutCheck"), 1); - returnFlag = false; - } - if (DauPosDCAtoPV < cSecondaryDauPosDCAtoPVMin) { - histos.fill(HIST("QA/K0sCutCheck"), 2); - returnFlag = false; - } - if (DauNegDCAtoPV < cSecondaryDauNegDCAtoPVMin) { - histos.fill(HIST("QA/K0sCutCheck"), 3); - returnFlag = false; - } - if (pT < cSecondaryPtMin) { - histos.fill(HIST("QA/K0sCutCheck"), 4); - returnFlag = false; - } - if (Rapidity > cSecondaryRapidityMax) { - histos.fill(HIST("QA/K0sCutCheck"), 5); - returnFlag = false; - } - if (Radius < cSecondaryRadiusMin) { - histos.fill(HIST("QA/K0sCutCheck"), 6); - returnFlag = false; - } - if (DCAtoPV > cSecondaryDCAtoPVMax) { - histos.fill(HIST("QA/K0sCutCheck"), 7); - returnFlag = false; - } - if (CPA < cSecondaryCosPAMin) { - histos.fill(HIST("QA/K0sCutCheck"), 8); - returnFlag = false; - } - if (PropTauK0s > cSecondaryProperLifetimeMax) { - histos.fill(HIST("QA/K0sCutCheck"), 9); - returnFlag = false; - } - if (candidate.qtarm() < cSecondaryparamArmenterosCut * TMath::Abs(candidate.alpha())) { - histos.fill(HIST("QA/K0sCutCheck"), 11); - returnFlag = false; - } - if (fabs(mK0s - MassK0Short) > cSecondaryMassWindow) { - histos.fill(HIST("QA/K0sCutCheck"), 10); - returnFlag = false; - } - - return returnFlag; - - } else { - if (fabs(mK0s - MassK0Short) > cSecondaryMassWindow) { - histos.fill(HIST("QA/K0sCutCheck"), 10); - returnFlag = false; - } + auto lDauDCA = candidate.dcaV0daughters(); + auto lDauPosDCAtoPV = candidate.dcapostopv(); + auto lDauNegDCAtoPV = candidate.dcanegtopv(); + auto lPt = candidate.pt(); + auto lRapidity = candidate.yK0Short(); + auto lRadius = candidate.v0radius(); + auto lDCAtoPV = candidate.dcav0topv(); + auto lCPA = candidate.v0cosPA(); + auto lPropTauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassK0Short; + auto lMk0s = candidate.mK0Short(); + auto lMLambda = candidate.mLambda(); + auto lMALambda = candidate.mAntiLambda(); + + auto checkCommonCuts = [&]() { + if (lDauDCA > SecondaryCuts.cfgSecondaryDauDCAMax) + return false; + if (lDauPosDCAtoPV < SecondaryCuts.cfgSecondaryDauPosDCAtoPVMin) + return false; + if (lDauNegDCAtoPV < SecondaryCuts.cfgSecondaryDauNegDCAtoPVMin) + return false; + if (lPt < SecondaryCuts.cfgSecondaryPtMin) + return false; + if (std::fabs(lRapidity) > SecondaryCuts.cfgSecondaryRapidityMax) + return false; + if (lRadius < SecondaryCuts.cfgSecondaryRadiusMin || lRadius > SecondaryCuts.cfgSecondaryRadiusMax) + return false; + if (lDCAtoPV > SecondaryCuts.cfgSecondaryDCAtoPVMax) + return false; + if (lCPA < SecondaryCuts.cfgSecondaryCosPAMin) + return false; + if (lPropTauK0s > SecondaryCuts.cfgSecondaryProperLifetimeMax) + return false; + if (candidate.qtarm() < SecondaryCuts.cfgSecondaryparamArmenterosCut * std::abs(candidate.alpha())) + return false; + if (std::fabs(lMk0s - MassK0Short) > SecondaryCuts.cfgSecondaryMassWindow) + return false; + if (SecondaryCuts.cfgSecondaryCrossMassHypothesisCut && + ((std::fabs(lMLambda - MassLambda0) < SecondaryCuts.cfgSecondaryCrossMassCutWindow) || (std::fabs(lMALambda - MassLambda0Bar) < SecondaryCuts.cfgSecondaryCrossMassCutWindow))) + return false; + return true; + }; - return returnFlag; + if (SecondaryCuts.cfgReturnFlag) { // For cut study + bool returnFlag = true; + histos.fill(HIST("QA/K0sCutCheck"), 0); + if (lDauDCA > SecondaryCuts.cfgSecondaryDauDCAMax) { + histos.fill(HIST("QA/K0sCutCheck"), 1); + returnFlag = false; } - - } else { - if (cSecondaryRequire) { - - histos.fill(HIST("QA/K0sCutCheck"), 0); - if (DauDCA > cSecondaryDauDCAMax) { - histos.fill(HIST("QA/K0sCutCheck"), 1); - return false; - } - if (DauPosDCAtoPV < cSecondaryDauPosDCAtoPVMin) { - histos.fill(HIST("QA/K0sCutCheck"), 2); - return false; - } - if (DauNegDCAtoPV < cSecondaryDauNegDCAtoPVMin) { - histos.fill(HIST("QA/K0sCutCheck"), 3); - return false; - } - if (pT < cSecondaryPtMin) { - histos.fill(HIST("QA/K0sCutCheck"), 4); - return false; - } - if (Rapidity > cSecondaryRapidityMax) { - histos.fill(HIST("QA/K0sCutCheck"), 5); - return false; - } - if (Radius < cSecondaryRadiusMin) { - histos.fill(HIST("QA/K0sCutCheck"), 6); - return false; - } - if (DCAtoPV > cSecondaryDCAtoPVMax) { - histos.fill(HIST("QA/K0sCutCheck"), 7); - return false; - } - if (CPA < cSecondaryCosPAMin) { - histos.fill(HIST("QA/K0sCutCheck"), 8); - return false; - } - if (PropTauK0s > cSecondaryProperLifetimeMax) { - histos.fill(HIST("QA/K0sCutCheck"), 9); - return false; - } - if (candidate.qtarm() < cSecondaryparamArmenterosCut * TMath::Abs(candidate.alpha())) { - histos.fill(HIST("QA/K0sCutCheck"), 11); - return false; - } - if (fabs(mK0s - MassK0Short) > cSecondaryMassWindow) { - histos.fill(HIST("QA/K0sCutCheck"), 10); - return false; - } - return true; - + if (lDauPosDCAtoPV < SecondaryCuts.cfgSecondaryDauPosDCAtoPVMin) { + histos.fill(HIST("QA/K0sCutCheck"), 2); + returnFlag = false; + } + if (lDauNegDCAtoPV < SecondaryCuts.cfgSecondaryDauNegDCAtoPVMin) { + histos.fill(HIST("QA/K0sCutCheck"), 3); + returnFlag = false; + } + if (lPt < SecondaryCuts.cfgSecondaryPtMin) { + histos.fill(HIST("QA/K0sCutCheck"), 4); + returnFlag = false; + } + if (std::fabs(lRapidity) > SecondaryCuts.cfgSecondaryRapidityMax) { + histos.fill(HIST("QA/K0sCutCheck"), 5); + returnFlag = false; + } + if (lRadius < SecondaryCuts.cfgSecondaryRadiusMin || lRadius > SecondaryCuts.cfgSecondaryRadiusMax) { + histos.fill(HIST("QA/K0sCutCheck"), 6); + returnFlag = false; + } + if (lDCAtoPV > SecondaryCuts.cfgSecondaryDCAtoPVMax) { + histos.fill(HIST("QA/K0sCutCheck"), 7); + returnFlag = false; + } + if (lCPA < SecondaryCuts.cfgSecondaryCosPAMin) { + histos.fill(HIST("QA/K0sCutCheck"), 8); + returnFlag = false; + } + if (lPropTauK0s > SecondaryCuts.cfgSecondaryProperLifetimeMax) { + histos.fill(HIST("QA/K0sCutCheck"), 9); + returnFlag = false; + } + if (candidate.qtarm() < SecondaryCuts.cfgSecondaryparamArmenterosCut * std::abs(candidate.alpha())) { + histos.fill(HIST("QA/K0sCutCheck"), 10); + returnFlag = false; + } + if (std::fabs(lMk0s - MassK0Short) > SecondaryCuts.cfgSecondaryMassWindow) { + histos.fill(HIST("QA/K0sCutCheck"), 11); + returnFlag = false; + } + if (SecondaryCuts.cfgSecondaryCrossMassHypothesisCut && + ((std::fabs(lMLambda - MassLambda0) < SecondaryCuts.cfgSecondaryCrossMassCutWindow) || (std::fabs(lMALambda - MassLambda0Bar) < SecondaryCuts.cfgSecondaryCrossMassCutWindow))) { + histos.fill(HIST("QA/K0sCutCheck"), 12); + returnFlag = false; + } + return returnFlag; + } else { // normal usage + if (SecondaryCuts.cfgSecondaryRequire) { + return checkCommonCuts(); } else { - if (fabs(mK0s - MassK0Short) > cSecondaryMassWindow) { - histos.fill(HIST("QA/K0sCutCheck"), 10); - return false; - } - return true; + return std::fabs(lMk0s - MassK0Short) <= SecondaryCuts.cfgSecondaryMassWindow; // always apply mass window cut } } } // selectionK0s - double GetPhiInRange(double phi) - { - double result = phi; - while (result < 0) { - result = result + 2. * TMath::Pi() / 2; - } - while (result > 2. * TMath::Pi() / 2) { - result = result - 2. * TMath::Pi() / 2; - } - return result; - } - template bool isTrueKstar(const TrackTemplate& bTrack, const V0Template& K0scand) { - if (abs(bTrack.PDGCode()) != kPiPlus) // Are you pion? + if (std::abs(bTrack.PDGCode()) != kPiPlus) // Are you pion? return false; - if (abs(K0scand.PDGCode()) != kPDGK0s) // Are you K0s? + if (std::abs(K0scand.PDGCode()) != kPDGK0s) // Are you K0s? return false; auto motherbTrack = bTrack.template mothers_as(); auto motherkV0 = K0scand.template mothers_as(); // Check bTrack first - if (abs(motherbTrack.pdgCode()) != kKstarPlus) // Are you charged Kstar's daughter? + if (std::abs(motherbTrack.pdgCode()) != kKstarPlus) // Are you charged Kstar's daughter? return false; // Apply first since it's more restrictive - if (abs(motherkV0.pdgCode()) != 310) // Is it K0s? + if (std::abs(motherkV0.pdgCode()) != 310) // Is it K0s? return false; // Check if K0s's mother is K0 (311) auto motherK0 = motherkV0.template mothers_as(); - if (abs(motherK0.pdgCode()) != 311) + if (std::abs(motherK0.pdgCode()) != 311) return false; // Check if K0's mother is Kstar (323) auto motherKstar = motherK0.template mothers_as(); - if (abs(motherKstar.pdgCode()) != 323) + if (std::abs(motherKstar.pdgCode()) != 323) return false; // Check if bTrack and K0 have the same mother (global index) @@ -716,9 +690,9 @@ struct chk892pp { template void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksTypeK0s& dTracks2) { - histos.fill(HIST("QA/before/CentDist"), centrality); + histos.fill(HIST("QA/before/CentDist"), lCentrality); - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResoSecondary, lDecayDaughter_bach, lResoKstar; + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResoSecondary, lDecayDaughter_bach, lResoKstar, lDaughterRot, lResonanceRot; std::vector trackIndicies = {}; std::vector k0sIndicies = {}; @@ -759,9 +733,9 @@ struct chk892pp { trackIndicies.push_back(bTrack.index()); } - for (auto& K0scand : dTracks2) { - auto posDauTrack = K0scand.template posTrack_as(); - auto negDauTrack = K0scand.template negTrack_as(); + for (auto& k0sCand : dTracks2) { + auto posDauTrack = k0sCand.template posTrack_as(); + auto negDauTrack = k0sCand.template negTrack_as(); /// Daughters // Positve pion @@ -776,16 +750,16 @@ struct chk892pp { auto trknNSigmaPiTOF = (istrknhasTOF) ? negDauTrack.tofNSigmaPi() : -999.; /// K0s - auto trkkDauDCA = K0scand.dcaV0daughters(); - auto trkkDauDCAPostoPV = K0scand.dcapostopv(); - auto trkkDauDCANegtoPV = K0scand.dcanegtopv(); - auto trkkpt = K0scand.pt(); - auto trkky = K0scand.yK0Short(); - auto trkkRadius = K0scand.v0radius(); - auto trkkDCAtoPV = K0scand.dcav0topv(); - auto trkkCPA = K0scand.v0cosPA(); - auto trkkPropTau = K0scand.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassK0Short; - auto trkkMass = K0scand.mK0Short(); + auto trkkDauDCA = k0sCand.dcaV0daughters(); + auto trkky = k0sCand.yK0Short(); + auto trkkDCAtoPV = k0sCand.dcav0topv(); + auto trkkCPA = k0sCand.v0cosPA(); + auto trkkPropTau = k0sCand.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * MassK0Short; + auto trkkMass = k0sCand.mK0Short(); + auto trkkDauDCAPostoPV = k0sCand.dcapostopv(); + auto trkkDauDCANegtoPV = k0sCand.dcanegtopv(); + auto trkkpt = k0sCand.pt(); + auto trkkRadius = k0sCand.v0radius(); if constexpr (!IsMix) { // Seconddary QA plots @@ -820,13 +794,11 @@ struct chk892pp { histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); } - // if (!trackCut(posDauTrack) || !trackCut(negDauTrack)) // Too tight cut for K0s daugthers - // continue; - if (!cfgByPassDauPIDSelection && !selectionPIDPion(posDauTrack)) // Perhaps it's already applied in trackCut (need to check QA plots) + if (!SecondaryCuts.cfgByPassDauPIDSelection && !selectionPIDPion(posDauTrack)) continue; - if (!cfgByPassDauPIDSelection && !selectionPIDPion(negDauTrack)) + if (!SecondaryCuts.cfgByPassDauPIDSelection && !selectionPIDPion(negDauTrack)) continue; - if (!selectionK0s(collision, K0scand)) + if (!selectionK0s(collision, k0sCand)) continue; if constexpr (!IsMix) { @@ -861,17 +833,19 @@ struct chk892pp { histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); + histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M()); } - k0sIndicies.push_back(K0scand.index()); + k0sIndicies.push_back(k0sCand.index()); } for (auto& trackIndex : trackIndicies) { for (auto& k0sIndex : k0sIndicies) { auto bTrack = dTracks1.rawIteratorAt(trackIndex); - auto K0scand = dTracks2.rawIteratorAt(k0sIndex); + auto k0sCand = dTracks2.rawIteratorAt(k0sIndex); + auto trkkMass = k0sCand.mK0Short(); lDecayDaughter_bach.SetXYZM(bTrack.px(), bTrack.py(), bTrack.pz(), MassPionCharged); - lResoSecondary.SetXYZM(K0scand.px(), K0scand.py(), K0scand.pz(), MassK0Short); + lResoSecondary.SetXYZM(k0sCand.px(), k0sCand.py(), k0sCand.pz(), trkkMass); lResoKstar = lResoSecondary + lDecayDaughter_bach; // QA plots @@ -880,16 +854,33 @@ struct chk892pp { histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); } - if (lResoKstar.Rapidity() > cKstarMaxRap || lResoKstar.Rapidity() < cKstarMinRap) + if (lResoKstar.Rapidity() > KstarCuts.cfgKstarMaxRap || lResoKstar.Rapidity() < KstarCuts.cfgKstarMinRap) continue; if constexpr (!IsMix) { - unsigned int typeKstar = bTrack.sign() > 0 ? binType::kKstarP : binType::kKstarN; + unsigned int typeKstar = bTrack.sign() > 0 ? BinType::kKstarP : BinType::kKstarN; histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); - histos.fill(HIST("hInvmass_Kstar"), typeKstar, centrality, lResoKstar.Pt(), lResoKstar.M()); - + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M()); + + if (BkgEstimationConfig.cfgFillRotBkg) { + for (int i = 0; i < BkgEstimationConfig.cfgNrotBkg; i++) { + auto lRotAngle = BkgEstimationConfig.cfgMinRot + i * ((BkgEstimationConfig.cfgMaxRot - BkgEstimationConfig.cfgMinRot) / (BkgEstimationConfig.cfgNrotBkg - 1)); + histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); + if (BkgEstimationConfig.cfgRotPion) { + lDaughterRot = lDecayDaughter_bach; + lDaughterRot.RotateZ(lRotAngle); + lResonanceRot = lDaughterRot + lResoSecondary; + } else { + lDaughterRot = lResoSecondary; + lDaughterRot.RotateZ(lRotAngle); + lResonanceRot = lDecayDaughter_bach + lDaughterRot; + } + typeKstar = bTrack.sign() > 0 ? BinType::kKstarP_Rot : BinType::kKstarN_Rot; + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResonanceRot.Pt(), lResonanceRot.M()); + } + } } // IsMix } // K0scand } // bTrack @@ -906,12 +897,17 @@ struct chk892pp { { if (!colCuts.isSelected(collision)) // Default event selection return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) { + return; + } + lCentrality = getCentrality(collision); + if (lCentrality < EventCuts.cfgEventCentralityMin || lCentrality > EventCuts.cfgEventCentralityMax) + return; colCuts.fillQA(collision); - centrality = GetCentrality(collision); fillHistograms(collision, tracks, v0s); // second order } - PROCESS_SWITCH(chk892pp, processData, "Process Event for data without Partitioning", true); + PROCESS_SWITCH(Chk892pp, processData, "Process Event for data without Partitioning", true); // process MC reconstructed level void processMC(EventCandidates::iterator const& collision, @@ -923,9 +919,9 @@ struct chk892pp { fillHistograms(collision, tracks, v0s); } - PROCESS_SWITCH(chk892pp, processMC, "Process Event for MC", false); + PROCESS_SWITCH(Chk892pp, processMC, "Process Event for MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"lf-chk892pp"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Resonances/doubleResonanceScan.cxx b/PWGLF/Tasks/Resonances/doubleResonanceScan.cxx new file mode 100644 index 00000000000..4b67171c448 --- /dev/null +++ b/PWGLF/Tasks/Resonances/doubleResonanceScan.cxx @@ -0,0 +1,548 @@ +// 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. +/// +/// \file doubleResonanceScan.cxx +/// \brief Resonance Scanner with ResoTracks and ResoMicroTracks +/// \author Bong-Hwi Lim +/// \since 27/03/2025 +/// + +#include +#include + +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/runDataProcessing.h" +#include "PWGLF/DataModel/LFResonanceTables.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "CommonConstants/MathConstants.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +using namespace o2::constants::math; +// Extract STEP +// Handle resomicrotracks +struct DoubleResonanceScan { + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Configurables + struct : ConfigurableGroup { + ConfigurableAxis cfgBinsPt{"cfgBinsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; + ConfigurableAxis cfgBinsPtQA{"cfgBinsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0}, "Binning of the pT axis"}; + ConfigurableAxis cfgBinsCent{"cfgBinsCent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; + ConfigurableAxis cfgBinsVtxZ{"cfgBinsVtxZ", {VARIABLE_WIDTH, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, "Binning of the z-vertex axis"}; + Configurable cNbinsDiv{"cNbinsDiv", 1, "Integer to divide the number of bins"}; + Configurable cNbinsDivQA{"cNbinsDivQA", 1, "Integer to divide the number of bins for QA"}; + Configurable cfgInvMassNBins1{"cfgInvMassNBins1", 400, "Number of bins for the invariant mass pair"}; + Configurable cfgInvMassPairStart1{"cfgInvMassPairStart1", 0.9, "Start of the invariant mass pair"}; + Configurable cfgInvMassPairEnd1{"cfgInvMassPairEnd1", 1.3, "Start of the invariant mass pair"}; + Configurable cfgInvMassNBins2{"cfgInvMassNBins2", 400, "Number of bins for the invariant mass pair"}; + Configurable cfgInvMassPairStart2{"cfgInvMassPairStart2", 0.9, "Start of the invariant mass pair"}; + Configurable cfgInvMassPairEnd2{"cfgInvMassPairEnd2", 1.3, "Start of the invariant mass pair"}; + Configurable cfgInvMassNBinsReso{"cfgInvMassNBinsReso", 800, "Number of bins for the invariant mass final pair"}; + Configurable cfgInvMassPairStartReso{"cfgInvMassPairStartReso", 2.4, "Start of the invariant mass final pair"}; + Configurable cfgInvMassPairEndReso{"cfgInvMassPairEndReso", 4.0, "Start of the invariant mass final pair"}; + } AxisConfig; + + struct : ConfigurableGroup { + Configurable cfgFillQAPlots{"cfgFillQAPlots", true, "Fill QA plots"}; + } AnalysisConfig; + + // Configurable for min pT cut + Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"}; + + // Track selection + // primary track condition + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; + + // DCA Selections + Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.15, "Track DCAr cut to PV Maximum"}; + Configurable cUsePtDependentDCArCut{"cUsePtDependentDCArCut", false, "Use Pt dependent DCAr cut"}; + Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 0.15, "Track DCAz cut to PV Maximum"}; + + // PID selection + Configurable cfgFirstDaughter{"cfgFirstDaughter", 0, "code of the first daughter, 0: pion, 1: kaon, 2: proton"}; + Configurable cfgSecondDaughter{"cfgSecondDaughter", 0, "code of the second daughter, 0: pion, 1: kaon, 2: proton"}; + Configurable cfgThirdDaughter{"cfgThirdDaughter", 0, "code of the third daughter, 0: pion, 1: kaon, 2: proton"}; + Configurable cfgFourthDaughter{"cfgFourthDaughter", 0, "code of the fourth daughter, 0: pion, 1: kaon, 2: proton"}; + // PID selection values + Configurable nSigmaCutTPC{"nSigmaCutTPC", 3.0, "Value of the TPC Nsigma cut"}; + Configurable nSigmaCutTOF{"nSigmaCutTOF", 3.0, "Value of the TOF Nsigma cut, if negative, TOF is not used"}; + + struct : ConfigurableGroup { + Configurable> cfgPairMassesLow{"cfgPairMassesLow", {1.01, 1.01}, "Low mass cut for pair_1 pair_2"}; + Configurable> cfgPairMassesHigh{"cfgPairMassesHigh", {1.03, 1.03}, "High mass cut for pair_1 pair_2"}; + Configurable> cfgPairOACut{"cfgPairOACut", {0.04, 0.04}, "Opening angle cut for pair_1 pair_2"}; + } PairCuts; + + struct : ConfigurableGroup { + Configurable cfgPairOALow{"cfgPairOALow", -999, "Low opening angle cut for pair_1 pair_2"}; + Configurable cfgPairOAHigh{"cfgPairOAHigh", 999, "High opening angle cut for pair_1 pair_2"}; + } ResoCuts; + + /// Event Mixing + Configurable nEvtMixing{"nEvtMixing", 5, "Number of events to mix"}; + ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgMultBins{"cfgMultBins", {VARIABLE_WIDTH, 0.0f, 1.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - z-vertex"}; + + /// Rotation background + struct : ConfigurableGroup { + Configurable cfgFillRotBkg{"cfgFillRotBkg", true, "Fill rotated background"}; + Configurable cfgMinRot{"cfgMinRot", 5.0 * constants::math::PI / 6.0, "Minimum of rotation"}; + Configurable cfgMaxRot{"cfgMaxRot", 7.0 * constants::math::PI / 6.0, "Maximum of rotation"}; + Configurable cfgNrotBkg{"cfgNrotBkg", 9, "Number of rotated copies (background) per each original candidate"}; + } BkgEstimationConfig; + + float mass1{MassPionCharged}, mass2{MassPionCharged}, mass3{MassPionCharged}, mass4{MassPionCharged}; + + float getMassFromCode(int code) + { + switch (code) { + case 0: + return MassPionCharged; + case 1: + return MassKaonCharged; + case 2: + return MassProton; + default: + return 0.f; + } + } + void init(o2::framework::InitContext&) + { + LOG(info) << "Initializing DoubleResonanceScan"; + LOG(info) << "First Daughter: " << cfgFirstDaughter << " Second Daughter: " << cfgSecondDaughter << " Third Daughter: " << cfgThirdDaughter << " Fourth Daughter: " << cfgFourthDaughter; + mass1 = getMassFromCode(cfgFirstDaughter); + mass2 = getMassFromCode(cfgSecondDaughter); + mass3 = getMassFromCode(cfgThirdDaughter); + mass4 = getMassFromCode(cfgFourthDaughter); + LOG(info) << "Masses: " << mass1 << " " << mass2 << " " << mass3 << " " << mass4; + + AxisSpec centAxis = {AxisConfig.cfgBinsCent, "T0M (%)"}; + AxisSpec vtxzAxis = {AxisConfig.cfgBinsVtxZ, "Z Vertex (cm)"}; + AxisSpec ptAxis = {AxisConfig.cfgBinsPt, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec ptAxisQA = {AxisConfig.cfgBinsPtQA, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec dcaAxis = {200 / AxisConfig.cNbinsDivQA, 0, 2, "DCA (cm)"}; + AxisSpec dcaxyAxis = {100 / AxisConfig.cNbinsDivQA, 0, 1, "DCA_{#it{xy}} (cm)"}; + AxisSpec dcazAxis = {100 / AxisConfig.cNbinsDivQA, 0, 1, "DCA_{#it{z}} (cm)"}; + AxisSpec yAxis = {50, -1, 1, "Rapidity"}; + AxisSpec invMassAxisPair1 = {AxisConfig.cfgInvMassNBins1, AxisConfig.cfgInvMassPairStart1, AxisConfig.cfgInvMassPairEnd1, "Invariant Mass (GeV/#it{c}^2)"}; + AxisSpec invMassAxisPair2 = {AxisConfig.cfgInvMassNBins2, AxisConfig.cfgInvMassPairStart2, AxisConfig.cfgInvMassPairEnd2, "Invariant Mass (GeV/#it{c}^2)"}; + AxisSpec invMassAxisReso = {AxisConfig.cfgInvMassNBinsReso, AxisConfig.cfgInvMassPairStartReso, AxisConfig.cfgInvMassPairEndReso, "Invariant Mass (GeV/#it{c}^2)"}; + AxisSpec pidQAAxis = {130 / AxisConfig.cNbinsDivQA, -6.5, 6.5}; + // Event QA + histos.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{300, -15., 15.}}); + histos.add("hMultiplicityPercent", "Multiplicity Percentile", kTH1F, {{120, 0.0f, 120.0f}}); + + if (AnalysisConfig.cfgFillQAPlots) { + // First Daughter + histos.add("hEta_1", "Eta distribution", kTH1F, {yAxis}); + histos.add("hPhi_1", "Phi distribution", kTH1F, {{200 / AxisConfig.cNbinsDivQA, 0, TwoPI}}); + histos.add("hPt_1", "Pt distribution", kTH1F, {ptAxisQA}); + histos.add("hDCAr_1", "DCAr distribution", kTH1F, {dcaxyAxis}); + histos.add("hDCAz_1", "DCAz distribution", kTH1F, {dcazAxis}); + histos.add("hNsigmaTPC_1", "nSigmaTPC distribution", kTH1F, {pidQAAxis}); + histos.add("hNsigmaTOF_1", "nSigmaTOF distribution", kTH1F, {pidQAAxis}); + + // Second Daughter + histos.add("hEta_2", "Eta distribution", kTH1F, {yAxis}); + histos.add("hPhi_2", "Phi distribution", kTH1F, {{200 / AxisConfig.cNbinsDivQA, 0, TwoPI}}); + histos.add("hPt_2", "Pt distribution", kTH1F, {ptAxisQA}); + histos.add("hDCAr_2", "DCAr distribution", kTH1F, {dcaxyAxis}); + histos.add("hDCAz_2", "DCAz distribution", kTH1F, {dcazAxis}); + histos.add("hNsigmaTPC_2", "nSigmaTPC distribution", kTH1F, {pidQAAxis}); + histos.add("hNsigmaTOF_2", "nSigmaTOF distribution", kTH1F, {pidQAAxis}); + + // Third Daughter + histos.add("hEta_3", "Eta distribution", kTH1F, {yAxis}); + histos.add("hPhi_3", "Phi distribution", kTH1F, {{200 / AxisConfig.cNbinsDivQA, 0, TwoPI}}); + histos.add("hPt_3", "Pt distribution", kTH1F, {ptAxisQA}); + histos.add("hDCAr_3", "DCAr distribution", kTH1F, {dcaxyAxis}); + histos.add("hDCAz_3", "DCAz distribution", kTH1F, {dcazAxis}); + histos.add("hNsigmaTPC_3", "nSigmaTPC distribution", kTH1F, {pidQAAxis}); + histos.add("hNsigmaTOF_3", "nSigmaTOF distribution", kTH1F, {pidQAAxis}); + + // Forth Daughter + histos.add("hEta_4", "Eta distribution", kTH1F, {yAxis}); + histos.add("hPhi_4", "Phi distribution", kTH1F, {{200 / AxisConfig.cNbinsDivQA, 0, TwoPI}}); + histos.add("hPt_4", "Pt distribution", kTH1F, {ptAxisQA}); + histos.add("hDCAr_4", "DCAr distribution", kTH1F, {dcaxyAxis}); + histos.add("hDCAz_4", "DCAz distribution", kTH1F, {dcazAxis}); + histos.add("hNsigmaTPC_4", "nSigmaTPC distribution", kTH1F, {pidQAAxis}); + histos.add("hNsigmaTOF_4", "nSigmaTOF distribution", kTH1F, {pidQAAxis}); + + // First Pair + histos.add("hPairInvMass_1", "Invariant mass distribution", kTH1F, {invMassAxisPair1}); + histos.add("hPairPt_1", "Pt distribution", kTH1F, {ptAxis}); + histos.add("hPairOA_1", "Opening angle distribution", kTH1F, {AxisSpec{100, 0, PI, "Opening Angle (rad)"}}); + + // Second Pair + histos.add("hPairInvMass_2", "Invariant mass distribution", kTH1F, {invMassAxisPair2}); + histos.add("hPairPt_2", "Pt distribution", kTH1F, {ptAxis}); + histos.add("hPairOA_2", "Opening angle distribution", kTH1F, {AxisSpec{100, 0, PI, "Opening Angle (rad)"}}); + + // Resonance + histos.add("h2PairInvMass", "Invariant mass distribution", kTH2F, {invMassAxisPair1, invMassAxisPair2}); + histos.add("hResoInvMass", "Invariant mass distribution", kTH1F, {invMassAxisReso}); + histos.add("hResoOA", "Opening angle distribution", kTH1F, {AxisSpec{100, 0, PI, "Opening Angle (rad)"}}); + histos.add("THnResoInvMass", "Invariant mass distribution with other axes", HistType::kTHnSparseD, {centAxis, ptAxis, invMassAxisReso}); + histos.add("THnResoInvMassBkg", "Invariant mass distribution with other axes", HistType::kTHnSparseD, {centAxis, ptAxis, invMassAxisReso}); + } + + LOG(info) << "Size of the histograms in double resonance scan with table combination:"; + histos.print(); + } + + template + bool trackCut(const TrackType track) + { + if constexpr (!IsResoMicrotrack) { + if (std::abs(track.pt()) < cMinPtcut) + return false; + if (cUsePtDependentDCArCut) { + // Tuned on the LHC22f anchored MC LHC23d1d on primary pions. 7 Sigmas of the resolution + if (std::abs(track.dcaXY()) > (0.004 + (0.013 / track.pt()))) + return false; + } else { + if (std::abs(track.dcaXY()) > cMaxDCArToPVcut) + return false; + } + if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) + return false; + if (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + return false; + } else { + if (std::abs(track.pt()) < cMinPtcut) + return false; + if (cUsePtDependentDCArCut) { + if (o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(track.trackSelectionFlags()) > -Epsilon) + return false; + } else { + if (o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(track.trackSelectionFlags()) > cMaxDCArToPVcut - Epsilon) + return false; + } + if (o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(track.trackSelectionFlags()) > cMaxDCAzToPVcut - Epsilon) + return false; + if (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + return false; + } + return true; + } + + template + float getPIDTPC(const T& candidate, int particleType) + { + if constexpr (!IsResoMicrotrack) { + // switch based on particleType + switch (particleType) { + case 0: // pion + return candidate.tpcNSigmaPi(); + case 1: // kaon + return candidate.tpcNSigmaKa(); + case 2: // proton + return candidate.tpcNSigmaPr(); + default: + return -999; + } + } else { + switch (particleType) { + case 0: // pion + return o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(candidate.pidNSigmaPiFlag()); + case 1: // kaon + return o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(candidate.pidNSigmaKaFlag()); + case 2: // proton + return o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(candidate.pidNSigmaPrFlag()); + default: + return -999; + } + } + } + + template + float getPIDTOF(const T& candidate, int particleType) + { + if constexpr (!IsResoMicrotrack) { + // switch based on particleType + switch (particleType) { + case 0: // pion + return candidate.hasTOF() ? candidate.tofNSigmaPi() : -999; + case 1: // kaon + return candidate.hasTOF() ? candidate.tofNSigmaKa() : -999; + case 2: // proton + return candidate.hasTOF() ? candidate.tofNSigmaPr() : -999; + default: + return -999; + } + } else { + switch (particleType) { + case 0: // pion + return candidate.hasTOF() ? o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(candidate.pidNSigmaPiFlag()) : -999; + case 1: // kaon + return candidate.hasTOF() ? o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(candidate.pidNSigmaKaFlag()) : -999; + case 2: // proton + return candidate.hasTOF() ? o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(candidate.pidNSigmaPrFlag()) : -999; + default: + return -999; + } + } + } + + template + bool selectionPID(const T& candidate, int particleType) + { + bool tpcPass = std::abs(getPIDTPC(candidate, particleType)) < nSigmaCutTPC; + bool tofPass = (nSigmaCutTOF > 0) ? std::abs(getPIDTOF(candidate, particleType)) < nSigmaCutTOF : true; + if (tpcPass && tofPass) { + return true; + } + return false; + } + + template + std::vector selectTrackIndicesWithQA(const TracksType& dTracks, int daughterType, int daughterIndex) + { + std::vector selectedIndices; + for (auto const& track : dTracks) { + if (!trackCut(track)) { + continue; + } + if (!selectionPID(track, daughterType)) { + continue; + } + + if (AnalysisConfig.cfgFillQAPlots) { + auto dcaXY = -999; + auto dcaZ = -999; + if constexpr (!IsResoMicrotrack) { + dcaXY = track.dcaXY(); + dcaZ = track.dcaZ(); + } else { + dcaXY = o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(track.trackSelectionFlags()); + dcaZ = o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(track.trackSelectionFlags()); + } + // FIXME: Apply better method + switch (daughterIndex) { + case 0: // First + histos.fill(HIST("hEta_1"), track.eta()); + histos.fill(HIST("hPhi_1"), track.phi()); + histos.fill(HIST("hPt_1"), track.pt()); + histos.fill(HIST("hDCAr_1"), dcaXY); + histos.fill(HIST("hDCAz_1"), dcaZ); + histos.fill(HIST("hNsigmaTPC_1"), getPIDTPC(track, daughterType)); + histos.fill(HIST("hNsigmaTOF_1"), getPIDTOF(track, daughterType)); + break; + case 1: // Second + histos.fill(HIST("hEta_2"), track.eta()); + histos.fill(HIST("hPhi_2"), track.phi()); + histos.fill(HIST("hPt_2"), track.pt()); + histos.fill(HIST("hDCAr_2"), dcaXY); + histos.fill(HIST("hDCAz_2"), dcaZ); + histos.fill(HIST("hNsigmaTPC_2"), getPIDTPC(track, daughterType)); + histos.fill(HIST("hNsigmaTOF_2"), getPIDTOF(track, daughterType)); + break; + case 2: // Third + histos.fill(HIST("hEta_3"), track.eta()); + histos.fill(HIST("hPhi_3"), track.phi()); + histos.fill(HIST("hPt_3"), track.pt()); + histos.fill(HIST("hDCAr_3"), dcaXY); + histos.fill(HIST("hDCAz_3"), dcaZ); + histos.fill(HIST("hNsigmaTPC_3"), getPIDTPC(track, daughterType)); + histos.fill(HIST("hNsigmaTOF_3"), getPIDTOF(track, daughterType)); + break; + case 3: // Forth + histos.fill(HIST("hEta_4"), track.eta()); + histos.fill(HIST("hPhi_4"), track.phi()); + histos.fill(HIST("hPt_4"), track.pt()); + histos.fill(HIST("hDCAr_4"), dcaXY); + histos.fill(HIST("hDCAz_4"), dcaZ); + histos.fill(HIST("hNsigmaTPC_4"), getPIDTPC(track, daughterType)); + histos.fill(HIST("hNsigmaTOF_4"), getPIDTOF(track, daughterType)); + break; + default: + break; + } + } + selectedIndices.push_back(track.index()); + } + return selectedIndices; + } + + bool isPairSelected(const TLorentzVector& lv1, const TLorentzVector& lv2, int pairType = 0) + { + TLorentzVector lvSum = lv1 + lv2; + // Mass window cut + auto pairMass = lvSum.M(); + auto pairMassesLow = PairCuts.cfgPairMassesLow.value; + auto pairMassesHigh = PairCuts.cfgPairMassesHigh.value; + if ((pairMassesLow[pairType] > 0) || (pairMassesHigh[pairType] > 0)) { + if (pairMass < pairMassesLow[pairType] || pairMass > pairMassesHigh[pairType]) { + return false; + } + } + // Opening angle cut + double angle = lv1.Vect().Angle(lv2.Vect()); + auto angleCut = PairCuts.cfgPairOACut.value; + if (angleCut[pairType] > 0) { + if (angle < angleCut[pairType]) { + return false; + } + } + if (AnalysisConfig.cfgFillQAPlots) { + // FIXME: Apply better method + if (pairType > 0) { + histos.fill(HIST("hPairInvMass_2"), pairMass); + histos.fill(HIST("hPairPt_2"), lvSum.Pt()); + histos.fill(HIST("hPairOA_2"), angle); + } else { + histos.fill(HIST("hPairInvMass_1"), pairMass); + histos.fill(HIST("hPairPt_1"), lvSum.Pt()); + histos.fill(HIST("hPairOA_1"), angle); + } + } + return true; + } + + template + std::vector> + getSelectedTrackPairs(const TracksType& dTracks, + const std::vector& indicesA, + const std::vector& indicesB, + float massA, float massB, + int pairType) + { + std::vector> selectedPairs; + TLorentzVector lv1, lv2; + for (const auto& indexA : indicesA) { + for (const auto& indexB : indicesB) { + if (indexA == indexB) { + continue; + } + + auto trackA = dTracks.rawIteratorAt(indexA); + auto trackB = dTracks.rawIteratorAt(indexB); + + lv1.SetXYZM(trackA.px(), trackA.py(), trackA.pz(), massA); + lv2.SetXYZM(trackB.px(), trackB.py(), trackB.pz(), massB); + + if (!isPairSelected(lv1, lv2, pairType)) { + continue; + } + selectedPairs.emplace_back(indexA, indexB); + } + } + return selectedPairs; + } + + bool isResoSelected(const TLorentzVector& par1, const TLorentzVector& pair2) + { + // Opening angle (3D) + double oa = par1.Vect().Angle(pair2.Vect()); + if (oa < ResoCuts.cfgPairOALow || oa > ResoCuts.cfgPairOAHigh) { + return false; + } + // Rapidity cut + TLorentzVector lvTotal = par1 + pair2; + if (lvTotal.Rapidity() < -0.5 || lvTotal.Rapidity() > 0.5) { + return false; + } + histos.fill(HIST("hResoOA"), oa); + return true; + } + + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks) + { + auto multiplicity = collision.cent(); + histos.fill(HIST("hVertexZ"), collision.posZ()); + histos.fill(HIST("hMultiplicityPercent"), multiplicity); + + auto trackIndices1 = selectTrackIndicesWithQA(dTracks, cfgFirstDaughter, 0); + auto trackIndices2 = selectTrackIndicesWithQA(dTracks, cfgSecondDaughter, 1); + auto trackIndices3 = selectTrackIndicesWithQA(dTracks, cfgThirdDaughter, 2); + auto trackIndices4 = selectTrackIndicesWithQA(dTracks, cfgFourthDaughter, 3); + + // First resconstructed pair + auto selectedPairs1 = getSelectedTrackPairs(dTracks, trackIndices1, trackIndices2, mass1, mass2, 0); + auto selectedPairs2 = getSelectedTrackPairs(dTracks, trackIndices3, trackIndices4, mass3, mass4, 1); + + // Resonance loop of selectedPairs1 and selectedPairs2 + for (const auto& pair1 : selectedPairs1) { + const auto& i1 = pair1.first; + const auto& i2 = pair1.second; + for (const auto& pair2 : selectedPairs2) { + const auto& j1 = pair2.first; + const auto& j2 = pair2.second; + // Remove the same track + if (i1 == j1 || i1 == j2 || i2 == j1 || i2 == j2) { + continue; + } + auto t1 = dTracks.rawIteratorAt(i1); + auto t2 = dTracks.rawIteratorAt(i2); + auto t3 = dTracks.rawIteratorAt(j1); + auto t4 = dTracks.rawIteratorAt(j2); + + TLorentzVector lv1, lv2, lv3, lv4, lvPair1, lvPair2, lvTotal, lResonanceRot; + lv1.SetXYZM(t1.px(), t1.py(), t1.pz(), mass1); + lv2.SetXYZM(t2.px(), t2.py(), t2.pz(), mass2); + lv3.SetXYZM(t3.px(), t3.py(), t3.pz(), mass3); + lv4.SetXYZM(t4.px(), t4.py(), t4.pz(), mass4); + lvPair1 = lv1 + lv2; + lvPair2 = lv3 + lv4; + if (!isResoSelected(lvPair1, lvPair2)) + continue; + lvTotal = lv1 + lv2 + lv3 + lv4; + histos.fill(HIST("h2PairInvMass"), lvPair1.M(), lvPair2.M()); + histos.fill(HIST("hResoInvMass"), lvTotal.M()); + histos.fill(HIST("THnResoInvMass"), multiplicity, lvTotal.Pt(), lvTotal.M()); + if (BkgEstimationConfig.cfgFillRotBkg) { + for (int i = 0; i < BkgEstimationConfig.cfgNrotBkg; i++) { + auto lRotAngle = BkgEstimationConfig.cfgMinRot + i * ((BkgEstimationConfig.cfgMaxRot - BkgEstimationConfig.cfgMinRot) / (BkgEstimationConfig.cfgNrotBkg - 1)); + lvPair2.RotateZ(lRotAngle); + lResonanceRot = lvPair1 + lvPair2; + histos.fill(HIST("THnResoInvMassBkg"), multiplicity, lResonanceRot.Pt(), lResonanceRot.M()); + } + } + } + } + } + + void processDummy(aod::ResoCollision const& /*collisions*/) + { + } + PROCESS_SWITCH(DoubleResonanceScan, processDummy, "Process Dummy", true); + + void processResoTracks(aod::ResoCollision const& collision, aod::ResoTracks const& resotracks) + { + fillHistograms(collision, resotracks); + } + PROCESS_SWITCH(DoubleResonanceScan, processResoTracks, "Process ResoTracks", false); + + void processResoMicroTracks(aod::ResoCollision const& collision, aod::ResoMicroTracks const& resomicrotracks) + { + fillHistograms(collision, resomicrotracks); + } + PROCESS_SWITCH(DoubleResonanceScan, processResoMicroTracks, "Process ResoMicroTracks", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Resonances/doublephimeson.cxx b/PWGLF/Tasks/Resonances/doublephimeson.cxx index 95296b748ad..0c8f9c2c780 100644 --- a/PWGLF/Tasks/Resonances/doublephimeson.cxx +++ b/PWGLF/Tasks/Resonances/doublephimeson.cxx @@ -41,29 +41,37 @@ using namespace o2::soa; struct doublephimeson { HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - Configurable fillDeltaMass{"fillDeltaMass", 1, "Fill Delta Mass"}; - Configurable fillRotation{"fillRotation", 1, "Fill rotation"}; Configurable strategyPID1{"strategyPID1", 0, "PID strategy 1"}; Configurable strategyPID2{"strategyPID2", 0, "PID strategy 2"}; - Configurable minPhiMass{"minPhiMass", 1.01, "Minimum phi mass"}; - Configurable maxPhiMass{"maxPhiMass", 1.03, "Maximum phi mass"}; + Configurable daughterDeltaR{"daughterDeltaR", 0.0, "delta R of daughter"}; + Configurable minPhiMass1{"minPhiMass1", 1.01, "Minimum phi mass1"}; + Configurable maxPhiMass1{"maxPhiMass1", 1.03, "Maximum phi mass1"}; + Configurable minPhiMass2{"minPhiMass2", 1.01, "Minimum phi mass2"}; + Configurable maxPhiMass2{"maxPhiMass2", 1.03, "Maximum phi mass2"}; + Configurable minExoticMass{"minExoticMass", 2.0, "Minimum Exotic mass"}; + Configurable maxExoticMass{"maxExoticMass", 3.6, "Maximum Exotic mass"}; Configurable additionalEvsel{"additionalEvsel", false, "Additional event selection"}; - Configurable cutNsigmaTPC{"cutNsigmaTPC", 2.5, "nsigma cut TPC"}; + Configurable isDeep{"isDeep", true, "Store deep angle"}; + Configurable cutMinNsigmaTPC{"cutMinNsigmaTPC", -2.5, "nsigma cut TPC"}; + Configurable cutNsigmaTPC{"cutNsigmaTPC", 3.0, "nsigma cut TPC"}; Configurable cutNsigmaTOF{"cutNsigmaTOF", 3.0, "nsigma cut TOF"}; + Configurable momTOFCut{"momTOFCut", 1.8, "minimum pT cut for madnatory TOF"}; + Configurable maxKaonPt{"maxKaonPt", 100.0, "maximum kaon pt cut"}; // Event Mixing - Configurable nEvtMixing{"nEvtMixing", 10, "Number of events to mix"}; + Configurable nEvtMixing{"nEvtMixing", 1, "Number of events to mix"}; ConfigurableAxis CfgVtxBins{"CfgVtxBins", {10, -10, 10}, "Mixing bins - z-vertex"}; ConfigurableAxis CfgMultBins{"CfgMultBins", {VARIABLE_WIDTH, 0.0, 20.0, 40.0, 60.0, 80.0, 500.0}, "Mixing bins - number of contributor"}; // THnsparse bining ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {1500, 2.0, 3.5}, "#it{M} (GeV/#it{c}^{2})"}; ConfigurableAxis configThnAxisInvMassPhi{"configThnAxisInvMassPhi", {20, 1.01, 1.03}, "#it{M} (GeV/#it{c}^{2})"}; + ConfigurableAxis configThnAxisInvMassDeltaPhi{"configThnAxisInvMassDeltaPhi", {80, 0.0, 0.08}, "#it{M} (GeV/#it{c}^{2})"}; ConfigurableAxis configThnAxisDaugherPt{"configThnAxisDaugherPt", {25, 0.0, 50.}, "#it{p}_{T} (GeV/#it{c})"}; ConfigurableAxis configThnAxisPt{"configThnAxisPt", {40, 0.0, 20.}, "#it{p}_{T} (GeV/#it{c})"}; ConfigurableAxis configThnAxisKstar{"configThnAxisKstar", {200, 0.0, 2.0}, "#it{k}^{*} (GeV/#it{c})"}; ConfigurableAxis configThnAxisDeltaR{"configThnAxisDeltaR", {200, 0.0, 2.0}, "#it{k}^{*} (GeV/#it{c})"}; - ConfigurableAxis configThnAxisCosTheta{"configThnAxisCosTheta", {5, 0.0, 1.0}, "cos #theta{*}"}; - // ConfigurableAxis configThnAxisPhiMult{"configThnAxisPhiMult", {10, 0.5, 10.5}, "#Phi Multiplicity"}; + ConfigurableAxis configThnAxisCosTheta{"configThnAxisCosTheta", {160, 0.0, 3.2}, "cos #theta{*}"}; + ConfigurableAxis configThnAxisNumPhi{"configThnAxisNumPhi", {101, -0.5, 100.5}, "cos #theta{*}"}; // Initialize the ananlysis task void init(o2::framework::InitContext&) @@ -71,21 +79,23 @@ struct doublephimeson { // register histograms histos.add("hnsigmaTPCKaonPlus", "hnsigmaTPCKaonPlus", kTH2F, {{1000, -3.0, 3.0f}, {100, 0.0f, 10.0f}}); histos.add("hnsigmaTPCKaonMinus", "hnsigmaTPCKaonMinus", kTH2F, {{1000, -3.0, 3.0f}, {100, 0.0f, 10.0f}}); - histos.add("hPhid1Mass", "hPhid1Mass", kTH2F, {{40, 1.0, 1.04f}, {100, 0.0f, 10.0f}}); - histos.add("hPhid2Mass", "hPhid2Mass", kTH2F, {{40, 1.0, 1.04f}, {100, 0.0f, 10.0f}}); + histos.add("hnsigmaTPCTOFKaon", "hnsigmaTPCTOFKaon", kTH3F, {{500, -3.0, 3.0f}, {500, -3.0, 3.0f}, {100, 0.0f, 10.0f}}); + histos.add("hPhiMass", "hPhiMass", kTH2F, {{40, 1.0, 1.04f}, {100, 0.0f, 10.0f}}); + histos.add("hPhiMass2", "hPhiMass2", kTH2F, {{40, 1.0, 1.04f}, {40, 1.0f, 1.04f}}); + histos.add("hkPlusDeltaetaDeltaPhi", "hkPlusDeltaetaDeltaPhi", kTH2F, {{400, -2.0, 2.0}, {640, -2.0 * TMath::Pi(), 2.0 * TMath::Pi()}}); + histos.add("hkMinusDeltaetaDeltaPhi", "hkMinusDeltaetaDeltaPhi", kTH2F, {{400, -2.0, 2.0}, {640, -2.0 * TMath::Pi(), 2.0 * TMath::Pi()}}); const AxisSpec thnAxisInvMass{configThnAxisInvMass, "#it{M} (GeV/#it{c}^{2})"}; const AxisSpec thnAxisInvMassPhi{configThnAxisInvMassPhi, "#it{M} (GeV/#it{c}^{2})"}; - const AxisSpec thnAxisDaughterPt{configThnAxisDaugherPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisInvMassDeltaPhi{configThnAxisInvMassDeltaPhi, "#it{M} (GeV/#it{c}^{2})"}; const AxisSpec thnAxisPt{configThnAxisPt, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec thnAxisKstar{configThnAxisKstar, "#it{k}^{*} (GeV/#it{c})"}; const AxisSpec thnAxisDeltaR{configThnAxisDeltaR, "#Delta R)"}; - const AxisSpec thnAxisCosTheta{configThnAxisCosTheta, "cos #theta{*}"}; - // const AxisSpec thnAxisPhiMult{configThnAxisPhiMult, "#Phi Multiplicity)"}; - histos.add("SEMass", "SEMass", HistType::kTHnSparseF, {thnAxisInvMassPhi, thnAxisInvMassPhi, thnAxisDaughterPt, thnAxisDaughterPt}); - histos.add("SEMassUnlike", "SEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisKstar, thnAxisCosTheta, thnAxisDeltaR}); - histos.add("SEMassRot", "SEMassRot", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisKstar, thnAxisCosTheta, thnAxisDeltaR}); - histos.add("MEMassUnlike", "MEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisKstar, thnAxisCosTheta, thnAxisDeltaR}); + const AxisSpec thnAxisCosTheta{configThnAxisCosTheta, "cos #theta"}; + const AxisSpec thnAxisNumPhi{configThnAxisNumPhi, "Number of phi meson"}; + + histos.add("SEMassUnlike", "SEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisDeltaR, thnAxisInvMassDeltaPhi, thnAxisNumPhi}); + // histos.add("SEMassLike", "SEMassLike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisDeltaR, thnAxisInvMassPhi, thnAxisInvMassPhi, thnAxisNumPhi}); + histos.add("MEMassUnlike", "MEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisDeltaR, thnAxisInvMassDeltaPhi}); } // get kstar @@ -111,6 +121,34 @@ struct doublephimeson { return 0.5 * trackRelK.P(); } + float deepangle2(const ROOT::Math::PtEtaPhiMVector candidate1, + const ROOT::Math::PtEtaPhiMVector candidate2) + { + double pt1, pt2, pz1, pz2, p1, p2, angle; + pt1 = candidate1.Pt(); + pt2 = candidate2.Pt(); + pz1 = candidate1.Pz(); + pz2 = candidate2.Pz(); + p1 = candidate1.P(); + p2 = candidate2.P(); + angle = TMath::ACos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); + return angle; + } + + float deepangle(const TLorentzVector candidate1, + const TLorentzVector candidate2) + { + double pt1, pt2, pz1, pz2, p1, p2, angle; + pt1 = candidate1.Pt(); + pt2 = candidate2.Pt(); + pz1 = candidate1.Pz(); + pz2 = candidate2.Pz(); + p1 = candidate1.P(); + p2 = candidate2.P(); + angle = TMath::ACos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); + return angle; + } + // get cosTheta TLorentzVector daughterCMS; ROOT::Math::XYZVector threeVecDauCM, threeVecMother; @@ -131,123 +169,196 @@ struct doublephimeson { bool selectionPID(float nsigmaTPC, float nsigmaTOF, int TOFHit, int PIDStrategy, float ptcand) { + // optimized TPC TOF if (PIDStrategy == 0) { - if (TOFHit != 1) { - if (TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + if (ptcand < 0.4) { + if (nsigmaTPC > -3.0 && nsigmaTPC < 3.0) { return true; } - } - if (TOFHit == 1) { - if (TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + } else if (ptcand >= 0.4 && ptcand < 0.5) { + if (nsigmaTPC > -2.0 && nsigmaTPC < 3.0) { return true; } - } - } - if (PIDStrategy == 1) { - if (ptcand < 0.5) { - if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + } else if (ptcand >= 0.5 && ptcand < 5.0 && TOFHit == 1) { + if (ptcand < 2.0 && TMath::Sqrt(nsigmaTOF * nsigmaTOF + nsigmaTPC * nsigmaTPC) < 2.5) { return true; } - if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + if (ptcand >= 2.0 && TMath::Sqrt(nsigmaTOF * nsigmaTOF + nsigmaTPC * nsigmaTPC) < 2.0) { return true; } - } - if (ptcand >= 0.5) { - if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + } else if (ptcand >= 0.5 && ptcand < 5.0 && TOFHit != 1) { + if (ptcand >= 0.5 && ptcand < 0.6 && nsigmaTPC > -1.5 && nsigmaTPC < 2.0) { return true; } - } - } - if (PIDStrategy == 2) { - if (ptcand < 0.5) { - if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + if (ptcand >= 0.6 && ptcand < 0.7 && nsigmaTPC > -1.0 && nsigmaTPC < 2.0) { return true; } - if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + if (ptcand >= 0.7 && ptcand < 0.8 && nsigmaTPC > -0.4 && nsigmaTPC < 2.0) { return true; } - } - if (ptcand >= 0.5 && ptcand < 1.2) { - if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + if (ptcand >= 0.8 && ptcand < 1.0 && nsigmaTPC > -0.0 && nsigmaTPC < 2.0) { return true; } - if (TOFHit != 1 && nsigmaTPC > -1.5 && nsigmaTPC < cutNsigmaTPC) { + if (ptcand >= 1.0 && ptcand < 1.8 && nsigmaTPC > -2.0 && nsigmaTPC < 2.0) { return true; } - } - if (ptcand >= 1.2) { - if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + if (ptcand >= 1.8 && ptcand < 2.0 && nsigmaTPC > -2.0 && nsigmaTPC < 1.5) { return true; } - if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + if (ptcand >= 2.0 && nsigmaTPC > -2.0 && nsigmaTPC < 1.0) { return true; } + } else if (ptcand >= 5.0 && nsigmaTPC > -2.0 && nsigmaTPC < 2.0) { + return true; } } - if (PIDStrategy == 3) { - if (ptcand < 0.5) { - if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + // optimized TPC TOF combined + if (PIDStrategy == 1) { + if (ptcand < 0.4) { + if (nsigmaTPC > cutMinNsigmaTPC && nsigmaTPC < cutNsigmaTPC) { return true; } - if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + } else if (ptcand >= 0.4 && ptcand < 0.5) { + if (nsigmaTPC > -2.0 && nsigmaTPC < cutNsigmaTPC) { return true; } - } - if (ptcand >= 0.5 && ptcand < 1.2) { - if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + } else if (ptcand >= 0.5 && ptcand < 5.0 && TOFHit == 1) { + if (ptcand < 2.0 && TMath::Sqrt(nsigmaTOF * nsigmaTOF + nsigmaTPC * nsigmaTPC) < 2.5) { return true; } + if (ptcand >= 2.0 && TMath::Sqrt(nsigmaTOF * nsigmaTOF + nsigmaTPC * nsigmaTPC) < 2.0) { + return true; + } + } else if (ptcand >= 5.0 && nsigmaTPC > -2.0 && nsigmaTPC < 2.0) { + return true; } - if (ptcand >= 1.2) { - if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + } + + if (PIDStrategy == 2) { + if (ptcand < 0.5) { + if (nsigmaTPC > cutMinNsigmaTPC && nsigmaTPC < cutNsigmaTPC) { return true; } - if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + } + if (ptcand >= 0.5) { + if (TOFHit != 1 && ptcand < momTOFCut) { + if (ptcand >= 0.5 && ptcand < 0.6 && nsigmaTPC > -1.5 && nsigmaTPC < cutNsigmaTPC) { + return true; + } + if (ptcand >= 0.6 && ptcand < 0.7 && nsigmaTPC > -1.0 && nsigmaTPC < cutNsigmaTPC) { + return true; + } + if (ptcand >= 0.7 && ptcand < 0.8 && nsigmaTPC > -0.4 && nsigmaTPC < cutNsigmaTPC) { + return true; + } + if (ptcand >= 0.8 && ptcand < 1.0 && nsigmaTPC > -0.0 && nsigmaTPC < cutNsigmaTPC) { + return true; + } + if (ptcand >= 1.0 && ptcand < 1.8 && nsigmaTPC > -2.0 && nsigmaTPC < 2.0) { + return true; + } + if (ptcand >= 1.8 && ptcand < 2.0 && nsigmaTPC > -2.0 && nsigmaTPC < 1.5) { + return true; + } + if (ptcand >= 2.0 && nsigmaTPC > -2.0 && nsigmaTPC < 1.0) { + return true; + } + } + if (TOFHit == 1) { + if (TMath::Sqrt((nsigmaTPC * nsigmaTPC + nsigmaTOF * nsigmaTOF) / 2.0) < cutNsigmaTOF) { + return true; + } + } + } + } + if (PIDStrategy == 3) { + if (ptcand < 0.5) { + if (nsigmaTPC > cutMinNsigmaTPC && nsigmaTPC < cutNsigmaTPC) { return true; } } + if (ptcand >= 0.5) { + if (TOFHit != 1) { + if (nsigmaTPC > cutMinNsigmaTPC && nsigmaTPC < cutNsigmaTPC) { + return true; + } + } + if (TOFHit == 1) { + if (TMath::Sqrt((nsigmaTPC * nsigmaTPC + nsigmaTOF * nsigmaTOF) / 2.0) < cutNsigmaTOF) { + return true; + } + } + } } return false; } TLorentzVector exotic, Phid1, Phid2; - TLorentzVector exoticRot, Phid1Rot; - void process(aod::RedPhiEvents::iterator const& collision, aod::PhiTracks const& phitracks) + TLorentzVector Phi1kaonplus, Phi1kaonminus, Phi2kaonplus, Phi2kaonminus; + // TLorentzVector exoticRot, Phid1Rot; + + void processSE(aod::RedPhiEvents::iterator const& collision, aod::PhiTracks const& phitracks) { if (additionalEvsel && (collision.numPos() < 2 || collision.numNeg() < 2)) { return; } + int phimult = 0; for (auto phitrackd1 : phitracks) { - if (phitrackd1.phiMass() < minPhiMass || phitrackd1.phiMass() > maxPhiMass) { + if (phitrackd1.phiMass() < minPhiMass1 || phitrackd1.phiMass() > maxPhiMass1) { continue; } - auto kaonplusd1pt = TMath::Sqrt(phitrackd1.phid1Px() * phitrackd1.phid1Px() + phitrackd1.phid1Py() * phitrackd1.phid1Py()); auto kaonminusd1pt = TMath::Sqrt(phitrackd1.phid2Px() * phitrackd1.phid2Px() + phitrackd1.phid2Py() * phitrackd1.phid2Py()); - + if (kaonplusd1pt > maxKaonPt) { + continue; + } + if (kaonminusd1pt > maxKaonPt) { + continue; + } + if (!selectionPID(phitrackd1.phid1TPC(), phitrackd1.phid1TOF(), phitrackd1.phid1TOFHit(), strategyPID1, kaonplusd1pt)) { + continue; + } + if (!selectionPID(phitrackd1.phid2TPC(), phitrackd1.phid2TOF(), phitrackd1.phid2TOFHit(), strategyPID2, kaonminusd1pt)) { + continue; + } + phimult = phimult + 1; + } + for (auto phitrackd1 : phitracks) { + auto kaonplusd1pt = TMath::Sqrt(phitrackd1.phid1Px() * phitrackd1.phid1Px() + phitrackd1.phid1Py() * phitrackd1.phid1Py()); + auto kaonminusd1pt = TMath::Sqrt(phitrackd1.phid2Px() * phitrackd1.phid2Px() + phitrackd1.phid2Py() * phitrackd1.phid2Py()); + if (kaonplusd1pt > maxKaonPt) { + continue; + } + if (kaonminusd1pt > maxKaonPt) { + continue; + } if (!selectionPID(phitrackd1.phid1TPC(), phitrackd1.phid1TOF(), phitrackd1.phid1TOFHit(), strategyPID1, kaonplusd1pt)) { continue; } if (!selectionPID(phitrackd1.phid2TPC(), phitrackd1.phid2TOF(), phitrackd1.phid2TOFHit(), strategyPID1, kaonminusd1pt)) { continue; } - // LOGF(info, "pass TOF hit: (%d, %d)", phitrackd1.phid1TOFHit(), phitrackd1.phid2TOFHit()); + histos.fill(HIST("hnsigmaTPCTOFKaon"), phitrackd1.phid1TPC(), phitrackd1.phid1TOF(), kaonplusd1pt); histos.fill(HIST("hnsigmaTPCKaonPlus"), phitrackd1.phid1TPC(), kaonplusd1pt); histos.fill(HIST("hnsigmaTPCKaonMinus"), phitrackd1.phid2TPC(), kaonminusd1pt); - Phid1.SetXYZM(phitrackd1.phiPx(), phitrackd1.phiPy(), phitrackd1.phiPz(), phitrackd1.phiMass()); - histos.fill(HIST("hPhid1Mass"), Phid1.M(), Phid1.Pt()); + histos.fill(HIST("hPhiMass"), Phid1.M(), Phid1.Pt()); auto phid1id = phitrackd1.index(); + Phid1.SetXYZM(phitrackd1.phiPx(), phitrackd1.phiPy(), phitrackd1.phiPz(), phitrackd1.phiMass()); + Phi1kaonplus.SetXYZM(phitrackd1.phid1Px(), phitrackd1.phid1Py(), phitrackd1.phid1Pz(), 0.493); + Phi1kaonminus.SetXYZM(phitrackd1.phid2Px(), phitrackd1.phid2Py(), phitrackd1.phid2Pz(), 0.493); for (auto phitrackd2 : phitracks) { auto phid2id = phitrackd2.index(); if (phid2id <= phid1id) { continue; } - if (phitrackd2.phiMass() < minPhiMass || phitrackd2.phiMass() > maxPhiMass) { - continue; - } auto kaonplusd2pt = TMath::Sqrt(phitrackd2.phid1Px() * phitrackd2.phid1Px() + phitrackd2.phid1Py() * phitrackd2.phid1Py()); auto kaonminusd2pt = TMath::Sqrt(phitrackd2.phid2Px() * phitrackd2.phid2Px() + phitrackd2.phid2Py() * phitrackd2.phid2Py()); - + if (kaonplusd2pt > maxKaonPt) { + continue; + } + if (kaonminusd2pt > maxKaonPt) { + continue; + } if (!selectionPID(phitrackd2.phid1TPC(), phitrackd2.phid1TOF(), phitrackd2.phid1TOFHit(), strategyPID2, kaonplusd2pt)) { continue; } @@ -261,41 +372,264 @@ struct doublephimeson { continue; } Phid2.SetXYZM(phitrackd2.phiPx(), phitrackd2.phiPy(), phitrackd2.phiPz(), phitrackd2.phiMass()); + Phi2kaonplus.SetXYZM(phitrackd2.phid1Px(), phitrackd2.phid1Py(), phitrackd2.phid1Pz(), 0.493); + Phi2kaonminus.SetXYZM(phitrackd2.phid2Px(), phitrackd2.phid2Py(), phitrackd2.phid2Pz(), 0.493); + + /* + // Like + Phid1like = Phi1kaonplus + Phi2kaonplus; + Phid2like = Phi1kaonminus + Phi2kaonminus; + exoticlike = Phid1like + Phid2like; + auto deltaRlike = TMath::Sqrt(TMath::Power(Phid1like.Phi() - Phid2like.Phi(), 2.0) + TMath::Power(Phid1like.Eta() - Phid2like.Eta(), 2.0)); + auto costhetalike = (Phid1like.Px() * Phid2like.Px() + Phid1like.Py() * Phid2like.Py() + Phid1like.Pz() * Phid2like.Pz()) / (Phid1like.P() * Phid2like.P()); + auto deltamlike = TMath::Sqrt(TMath::Power(Phid1like.M() - 1.0192, 2.0) + TMath::Power(Phid2like.M() - 1.0192, 2.0)); + if (!isDeep) { + histos.fill(HIST("SEMassLike"), exoticlike.M(), exoticlike.Pt(), deltaRlike, costhetalike, deltamlike, phimult); + } + if (isDeep) { + histos.fill(HIST("SEMassLike"), exoticlike.M(), exoticlike.Pt(), deltaRlike, deepangle(Phid1like, Phid2like), deltamlike, phimult); + } + */ + + // Unlike + histos.fill(HIST("hPhiMass2"), Phid1.M(), Phid2.M()); + if (phitrackd2.phiMass() < minPhiMass2 || phitrackd2.phiMass() > maxPhiMass2) { + continue; + } + if (phitrackd1.phiMass() < minPhiMass1 || phitrackd1.phiMass() > maxPhiMass1) { + continue; + } exotic = Phid1 + Phid2; - auto cosThetaStar = getCosTheta(exotic, Phid1); - auto kstar = getkstar(Phid1, Phid2); + if (exotic.M() < minExoticMass || exotic.M() > maxExoticMass) { + continue; + } + histos.fill(HIST("hkPlusDeltaetaDeltaPhi"), Phi1kaonplus.Eta() - Phi2kaonplus.Eta(), Phi1kaonplus.Phi() - Phi2kaonplus.Phi()); + histos.fill(HIST("hkMinusDeltaetaDeltaPhi"), Phi1kaonminus.Eta() - Phi2kaonminus.Eta(), Phi1kaonminus.Phi() - Phi2kaonminus.Phi()); + // auto cosThetaStar = getCosTheta(exotic, Phid1); + // auto kstar = getkstar(Phid1, Phid2); auto deltaR = TMath::Sqrt(TMath::Power(Phid1.Phi() - Phid2.Phi(), 2.0) + TMath::Power(Phid1.Eta() - Phid2.Eta(), 2.0)); - if (!fillDeltaMass) { - histos.fill(HIST("SEMassUnlike"), exotic.M(), exotic.Pt(), kstar, cosThetaStar, deltaR); - } - if (fillDeltaMass) { - histos.fill(HIST("SEMassUnlike"), exotic.M() - Phid1.M(), exotic.Pt(), kstar, cosThetaStar, deltaR); - } - histos.fill(HIST("SEMass"), Phid1.M(), Phid2.M(), Phid1.Pt(), Phid2.Pt()); - if (fillRotation) { - for (int nrotbkg = 0; nrotbkg < 5; nrotbkg++) { - auto anglestart = 5.0 * TMath::Pi() / 6.0; - auto angleend = 7.0 * TMath::Pi() / 6.0; - auto anglestep = (angleend - anglestart) / (1.0 * (9.0 - 1.0)); - auto rotangle = anglestart + nrotbkg * anglestep; - auto rotd1px = Phid1.Px() * std::cos(rotangle) - Phid1.Py() * std::sin(rotangle); - auto rotd1py = Phid1.Px() * std::sin(rotangle) + Phid1.Py() * std::cos(rotangle); - Phid1Rot.SetXYZM(rotd1px, rotd1py, Phid1.Pz(), Phid1.M()); - exoticRot = Phid1Rot + Phid2; - auto cosThetaStar_rot = getCosTheta(exoticRot, Phid1Rot); - auto kstar_rot = getkstar(Phid1Rot, Phid2); - auto deltaR_rot = TMath::Sqrt(TMath::Power(Phid1Rot.Phi() - Phid2.Phi(), 2.0) + TMath::Power(Phid1Rot.Eta() - Phid2.Eta(), 2.0)); - if (!fillDeltaMass) { - histos.fill(HIST("SEMassRot"), exoticRot.M(), exoticRot.Pt(), kstar_rot, cosThetaStar_rot, deltaR_rot); - } - if (fillDeltaMass) { - histos.fill(HIST("SEMassRot"), exoticRot.M() - Phid1Rot.M(), exoticRot.Pt(), kstar_rot, cosThetaStar_rot, deltaR_rot); + auto deltaRd1 = TMath::Sqrt(TMath::Power(Phi1kaonplus.Phi() - Phi2kaonplus.Phi(), 2.0) + TMath::Power(Phi1kaonplus.Eta() - Phi2kaonplus.Eta(), 2.0)); + auto deltaRd2 = TMath::Sqrt(TMath::Power(Phi1kaonminus.Phi() - Phi2kaonminus.Phi(), 2.0) + TMath::Power(Phi1kaonminus.Eta() - Phi2kaonminus.Eta(), 2.0)); + auto deltam = TMath::Sqrt(TMath::Power(Phid1.M() - 1.0192, 2.0) + TMath::Power(Phid2.M() - 1.0192, 2.0)); + if (deltaRd1 < daughterDeltaR) { + continue; + } + if (deltaRd2 < daughterDeltaR) { + continue; + } + if (!isDeep) { + histos.fill(HIST("SEMassUnlike"), exotic.M(), exotic.Pt(), deltaR, deltam, phimult); + } + if (isDeep) { + histos.fill(HIST("SEMassUnlike"), exotic.M(), exotic.Pt(), deltaR, deltam, phimult); + } + } + } + } + PROCESS_SWITCH(doublephimeson, processSE, "Process Same Event", false); + void processopti(aod::RedPhiEvents::iterator const& collision, aod::PhiTracks const& phitracks) + { + std::vector exoticresonance, phiresonanced1, phiresonanced2, kaonplus1, kaonplus2, kaonminus1, kaonminus2; + std::vector d1trackid = {}; + std::vector d2trackid = {}; + std::vector d3trackid = {}; + std::vector d4trackid = {}; + if (additionalEvsel && (collision.numPos() < 2 || collision.numNeg() < 2)) { + return; + } + int phimult = 0; + + for (auto phitrackd1 : phitracks) { + if (phitrackd1.phiMass() < minPhiMass1 || phitrackd1.phiMass() > maxPhiMass1) { + continue; + } + auto kaonplusd1pt = TMath::Sqrt(phitrackd1.phid1Px() * phitrackd1.phid1Px() + phitrackd1.phid1Py() * phitrackd1.phid1Py()); + auto kaonminusd1pt = TMath::Sqrt(phitrackd1.phid2Px() * phitrackd1.phid2Px() + phitrackd1.phid2Py() * phitrackd1.phid2Py()); + if (kaonplusd1pt > maxKaonPt) { + continue; + } + if (kaonminusd1pt > maxKaonPt) { + continue; + } + if (!selectionPID(phitrackd1.phid1TPC(), phitrackd1.phid1TOF(), phitrackd1.phid1TOFHit(), strategyPID1, kaonplusd1pt)) { + continue; + } + if (!selectionPID(phitrackd1.phid2TPC(), phitrackd1.phid2TOF(), phitrackd1.phid2TOFHit(), strategyPID1, kaonminusd1pt)) { + continue; + } + phimult = phimult + 1; + } + for (auto phitrackd1 : phitracks) { + auto kaonplusd1pt = TMath::Sqrt(phitrackd1.phid1Px() * phitrackd1.phid1Px() + phitrackd1.phid1Py() * phitrackd1.phid1Py()); + auto kaonminusd1pt = TMath::Sqrt(phitrackd1.phid2Px() * phitrackd1.phid2Px() + phitrackd1.phid2Py() * phitrackd1.phid2Py()); + if (kaonplusd1pt > maxKaonPt) { + continue; + } + if (kaonminusd1pt > maxKaonPt) { + continue; + } + if (!selectionPID(phitrackd1.phid1TPC(), phitrackd1.phid1TOF(), phitrackd1.phid1TOFHit(), strategyPID1, kaonplusd1pt)) { + continue; + } + if (!selectionPID(phitrackd1.phid2TPC(), phitrackd1.phid2TOF(), phitrackd1.phid2TOFHit(), strategyPID1, kaonminusd1pt)) { + continue; + } + histos.fill(HIST("hnsigmaTPCTOFKaon"), phitrackd1.phid1TPC(), phitrackd1.phid1TOF(), kaonplusd1pt); + histos.fill(HIST("hnsigmaTPCKaonPlus"), phitrackd1.phid1TPC(), kaonplusd1pt); + histos.fill(HIST("hnsigmaTPCKaonMinus"), phitrackd1.phid2TPC(), kaonminusd1pt); + histos.fill(HIST("hPhiMass"), Phid1.M(), Phid1.Pt()); + auto phid1id = phitrackd1.index(); + Phid1.SetXYZM(phitrackd1.phiPx(), phitrackd1.phiPy(), phitrackd1.phiPz(), phitrackd1.phiMass()); + Phi1kaonplus.SetXYZM(phitrackd1.phid1Px(), phitrackd1.phid1Py(), phitrackd1.phid1Pz(), 0.493); + Phi1kaonminus.SetXYZM(phitrackd1.phid2Px(), phitrackd1.phid2Py(), phitrackd1.phid2Pz(), 0.493); + for (auto phitrackd2 : phitracks) { + auto phid2id = phitrackd2.index(); + if (phid2id <= phid1id) { + continue; + } + auto kaonplusd2pt = TMath::Sqrt(phitrackd2.phid1Px() * phitrackd2.phid1Px() + phitrackd2.phid1Py() * phitrackd2.phid1Py()); + auto kaonminusd2pt = TMath::Sqrt(phitrackd2.phid2Px() * phitrackd2.phid2Px() + phitrackd2.phid2Py() * phitrackd2.phid2Py()); + if (kaonplusd2pt > maxKaonPt) { + continue; + } + if (kaonminusd2pt > maxKaonPt) { + continue; + } + if (!selectionPID(phitrackd2.phid1TPC(), phitrackd2.phid1TOF(), phitrackd2.phid1TOFHit(), strategyPID2, kaonplusd2pt)) { + continue; + } + if (!selectionPID(phitrackd2.phid2TPC(), phitrackd2.phid2TOF(), phitrackd2.phid2TOFHit(), strategyPID2, kaonminusd2pt)) { + continue; + } + if ((phitrackd1.phid1Index() == phitrackd2.phid1Index()) || (phitrackd1.phid2Index() == phitrackd2.phid2Index())) { + continue; + } + Phid2.SetXYZM(phitrackd2.phiPx(), phitrackd2.phiPy(), phitrackd2.phiPz(), phitrackd2.phiMass()); + Phi2kaonplus.SetXYZM(phitrackd2.phid1Px(), phitrackd2.phid1Py(), phitrackd2.phid1Pz(), 0.493); + Phi2kaonminus.SetXYZM(phitrackd2.phid2Px(), phitrackd2.phid2Py(), phitrackd2.phid2Pz(), 0.493); + + // unlike + if (phitrackd1.phiMass() < minPhiMass1 || phitrackd1.phiMass() > maxPhiMass1) { + continue; + } + if (phitrackd2.phiMass() < minPhiMass2 || phitrackd2.phiMass() > maxPhiMass2) { + continue; + } + exotic = Phid1 + Phid2; + if (exotic.M() < minExoticMass || exotic.M() > maxExoticMass) { + continue; + } + + ROOT::Math::PtEtaPhiMVector temp1(exotic.Pt(), exotic.Eta(), exotic.Phi(), exotic.M()); + ROOT::Math::PtEtaPhiMVector temp2(Phid1.Pt(), Phid1.Eta(), Phid1.Phi(), Phid1.M()); + ROOT::Math::PtEtaPhiMVector temp3(Phid2.Pt(), Phid2.Eta(), Phid2.Phi(), Phid2.M()); + exoticresonance.push_back(temp1); + phiresonanced1.push_back(temp2); + phiresonanced2.push_back(temp3); + d1trackid.push_back(phitrackd1.phid1Index()); + d2trackid.push_back(phitrackd2.phid1Index()); + d3trackid.push_back(phitrackd1.phid2Index()); + d4trackid.push_back(phitrackd2.phid2Index()); + + ROOT::Math::PtEtaPhiMVector temp4(Phi1kaonplus.Pt(), Phi1kaonplus.Eta(), Phi1kaonplus.Phi(), 0.493); + ROOT::Math::PtEtaPhiMVector temp5(Phi1kaonminus.Pt(), Phi1kaonminus.Eta(), Phi1kaonminus.Phi(), 0.493); + ROOT::Math::PtEtaPhiMVector temp6(Phi2kaonplus.Pt(), Phi2kaonplus.Eta(), Phi2kaonplus.Phi(), 0.493); + ROOT::Math::PtEtaPhiMVector temp7(Phi2kaonminus.Pt(), Phi2kaonminus.Eta(), Phi2kaonminus.Phi(), 0.493); + kaonplus1.push_back(temp4); + kaonplus2.push_back(temp6); + kaonminus1.push_back(temp5); + kaonminus2.push_back(temp7); + } + } + if (exoticresonance.size() == 0) { + return; + } + // LOGF(info, "Total number of exotic: %d", exoticresonance.size()); + if (exoticresonance.size() == 2) { + for (auto if1 = exoticresonance.begin(); if1 != exoticresonance.end(); ++if1) { + auto i5 = std::distance(exoticresonance.begin(), if1); + + auto exotic1phi1 = phiresonanced1.at(i5); + auto exotic1phi2 = phiresonanced2.at(i5); + auto exotic1 = exoticresonance.at(i5); + + auto exotic1kaonplus1 = kaonplus1.at(i5); + auto exotic1kaonminus1 = kaonminus1.at(i5); + auto exotic1kaonplus2 = kaonplus2.at(i5); + auto exotic1kaonminus2 = kaonminus2.at(i5); + auto deltaRkaonplus1 = TMath::Sqrt(TMath::Power(exotic1kaonplus1.Phi() - exotic1kaonplus2.Phi(), 2.0) + TMath::Power(exotic1kaonplus1.Eta() - exotic1kaonplus2.Eta(), 2.0)); + auto deltaRkaonminus1 = TMath::Sqrt(TMath::Power(exotic1kaonminus1.Phi() - exotic1kaonminus2.Phi(), 2.0) + TMath::Power(exotic1kaonminus1.Eta() - exotic1kaonminus2.Eta(), 2.0)); + + auto deltam1 = TMath::Sqrt(TMath::Power(exotic1phi1.M() - 1.0192, 2.0) + TMath::Power(exotic1phi2.M() - 1.0192, 2.0)); + auto deltaR1 = TMath::Sqrt(TMath::Power(exotic1phi1.Phi() - exotic1phi2.Phi(), 2.0) + TMath::Power(exotic1phi1.Eta() - exotic1phi2.Eta(), 2.0)); + + if (deltaRkaonplus1 < daughterDeltaR) { + continue; + } + if (deltaRkaonminus1 < daughterDeltaR) { + continue; + } + + for (auto if2 = if1 + 1; if2 != exoticresonance.end(); ++if2) { + auto i6 = std::distance(exoticresonance.begin(), if2); + auto exotic2phi1 = phiresonanced1.at(i6); + auto exotic2phi2 = phiresonanced2.at(i6); + auto exotic2 = exoticresonance.at(i6); + + auto exotic2kaonplus1 = kaonplus1.at(i6); + auto exotic2kaonminus1 = kaonminus1.at(i6); + auto exotic2kaonplus2 = kaonplus2.at(i6); + auto exotic2kaonminus2 = kaonminus2.at(i6); + auto deltaRkaonplus2 = TMath::Sqrt(TMath::Power(exotic2kaonplus1.Phi() - exotic2kaonplus2.Phi(), 2.0) + TMath::Power(exotic2kaonplus1.Eta() - exotic2kaonplus2.Eta(), 2.0)); + auto deltaRkaonminus2 = TMath::Sqrt(TMath::Power(exotic2kaonminus1.Phi() - exotic2kaonminus2.Phi(), 2.0) + TMath::Power(exotic2kaonminus1.Eta() - exotic2kaonminus2.Eta(), 2.0)); + + auto deltam2 = TMath::Sqrt(TMath::Power(exotic2phi1.M() - 1.0192, 2.0) + TMath::Power(exotic2phi2.M() - 1.0192, 2.0)); + auto deltaR2 = TMath::Sqrt(TMath::Power(exotic2phi1.Phi() - exotic2phi2.Phi(), 2.0) + TMath::Power(exotic2phi1.Eta() - exotic2phi2.Eta(), 2.0)); + + if ((d1trackid.at(i5) == d1trackid.at(i6) || d1trackid.at(i5) == d2trackid.at(i6)) && + (d2trackid.at(i5) == d1trackid.at(i6) || d2trackid.at(i5) == d2trackid.at(i6)) && + (d3trackid.at(i5) == d3trackid.at(i6) || d3trackid.at(i5) == d4trackid.at(i6)) && + (d4trackid.at(i5) == d3trackid.at(i6) || d4trackid.at(i5) == d4trackid.at(i6))) { + + if (deltam2 < deltam1 && deltaRkaonplus2 > daughterDeltaR && deltaRkaonminus2 > daughterDeltaR) { + histos.fill(HIST("SEMassUnlike"), exotic2.M(), exotic2.Pt(), deltaR2, deltam2, phimult); + // LOGF(info, "Fill exotic Id %d which is pair of Id %d", i6, i5); + } else { + histos.fill(HIST("SEMassUnlike"), exotic1.M(), exotic1.Pt(), deltaR1, deltam1, phimult); } + } else { + histos.fill(HIST("SEMassUnlike"), exotic1.M(), exotic1.Pt(), deltaR1, deltam1, phimult); } } } + } else { + for (auto if1 = exoticresonance.begin(); if1 != exoticresonance.end(); ++if1) { + auto i5 = std::distance(exoticresonance.begin(), if1); + auto exotic1phi1 = phiresonanced1.at(i5); + auto exotic1phi2 = phiresonanced2.at(i5); + auto exotic1 = exoticresonance.at(i5); + + auto exotic1kaonplus1 = kaonplus1.at(i5); + auto exotic1kaonminus1 = kaonminus1.at(i5); + auto exotic1kaonplus2 = kaonplus2.at(i5); + auto exotic1kaonminus2 = kaonminus2.at(i5); + auto deltaRkaonplus1 = TMath::Sqrt(TMath::Power(exotic1kaonplus1.Phi() - exotic1kaonplus2.Phi(), 2.0) + TMath::Power(exotic1kaonplus1.Eta() - exotic1kaonplus2.Eta(), 2.0)); + auto deltaRkaonminus1 = TMath::Sqrt(TMath::Power(exotic1kaonminus1.Phi() - exotic1kaonminus2.Phi(), 2.0) + TMath::Power(exotic1kaonminus1.Eta() - exotic1kaonminus2.Eta(), 2.0)); + auto deltam1 = TMath::Sqrt(TMath::Power(exotic1phi1.M() - 1.0192, 2.0) + TMath::Power(exotic1phi2.M() - 1.0192, 2.0)); + auto deltaR1 = TMath::Sqrt(TMath::Power(exotic1phi1.Phi() - exotic1phi2.Phi(), 2.0) + TMath::Power(exotic1phi1.Eta() - exotic1phi2.Eta(), 2.0)); + + if (deltaRkaonplus1 < daughterDeltaR) { + continue; + } + if (deltaRkaonminus1 < daughterDeltaR) { + continue; + } + + histos.fill(HIST("SEMassUnlike"), exotic1.M(), exotic1.Pt(), deltaR1, deltam1, phimult); + } } } + PROCESS_SWITCH(doublephimeson, processopti, "Process Optimized same event", false); SliceCache cache; using BinningTypeVertexContributor = ColumnBinningPolicy; @@ -309,23 +643,29 @@ struct doublephimeson { if (collision1.index() == collision2.index()) { continue; } - if (additionalEvsel && (collision1.numPos() < 2 || collision1.numNeg() < 2)) { - continue; - } - if (additionalEvsel && (collision2.numPos() < 2 || collision2.numNeg() < 2)) { - continue; - } for (auto& [phitrackd1, phitrackd2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - if (phitrackd1.phiMass() < minPhiMass || phitrackd1.phiMass() > maxPhiMass) { + if (phitrackd1.phiMass() < minPhiMass1 || phitrackd1.phiMass() > maxPhiMass1) { continue; } - if (phitrackd2.phiMass() < minPhiMass || phitrackd2.phiMass() > maxPhiMass) { + if (phitrackd2.phiMass() < minPhiMass2 || phitrackd2.phiMass() > maxPhiMass2) { continue; } auto kaonplusd1pt = TMath::Sqrt(phitrackd1.phid1Px() * phitrackd1.phid1Px() + phitrackd1.phid1Py() * phitrackd1.phid1Py()); auto kaonminusd1pt = TMath::Sqrt(phitrackd1.phid2Px() * phitrackd1.phid2Px() + phitrackd1.phid2Py() * phitrackd1.phid2Py()); auto kaonplusd2pt = TMath::Sqrt(phitrackd2.phid1Px() * phitrackd2.phid1Px() + phitrackd2.phid1Py() * phitrackd2.phid1Py()); auto kaonminusd2pt = TMath::Sqrt(phitrackd2.phid2Px() * phitrackd2.phid2Px() + phitrackd2.phid2Py() * phitrackd2.phid2Py()); + if (kaonplusd1pt > maxKaonPt) { + continue; + } + if (kaonminusd1pt > maxKaonPt) { + continue; + } + if (kaonplusd2pt > maxKaonPt) { + continue; + } + if (kaonminusd2pt > maxKaonPt) { + continue; + } if (!selectionPID(phitrackd1.phid1TPC(), phitrackd1.phid1TOF(), phitrackd1.phid1TOFHit(), strategyPID1, kaonplusd1pt)) { continue; } @@ -341,14 +681,27 @@ struct doublephimeson { } Phid2.SetXYZM(phitrackd2.phiPx(), phitrackd2.phiPy(), phitrackd2.phiPz(), phitrackd2.phiMass()); exotic = Phid1 + Phid2; - auto cosThetaStar = getCosTheta(exotic, Phid1); - auto kstar = getkstar(Phid1, Phid2); + + Phi1kaonplus.SetXYZM(phitrackd1.phid1Px(), phitrackd1.phid1Py(), phitrackd1.phid1Pz(), 0.493); + Phi1kaonminus.SetXYZM(phitrackd1.phid2Px(), phitrackd1.phid2Py(), phitrackd1.phid2Pz(), 0.493); + Phi2kaonplus.SetXYZM(phitrackd2.phid1Px(), phitrackd2.phid1Py(), phitrackd2.phid1Pz(), 0.493); + Phi2kaonminus.SetXYZM(phitrackd2.phid2Px(), phitrackd2.phid2Py(), phitrackd2.phid2Pz(), 0.493); + auto deltaRd1 = TMath::Sqrt(TMath::Power(Phi1kaonplus.Phi() - Phi2kaonplus.Phi(), 2.0) + TMath::Power(Phi1kaonplus.Eta() - Phi2kaonplus.Eta(), 2.0)); + auto deltaRd2 = TMath::Sqrt(TMath::Power(Phi1kaonminus.Phi() - Phi2kaonminus.Phi(), 2.0) + TMath::Power(Phi1kaonminus.Eta() - Phi2kaonminus.Eta(), 2.0)); auto deltaR = TMath::Sqrt(TMath::Power(Phid1.Phi() - Phid2.Phi(), 2.0) + TMath::Power(Phid1.Eta() - Phid2.Eta(), 2.0)); - if (!fillDeltaMass) { - histos.fill(HIST("MEMassUnlike"), exotic.M(), exotic.Pt(), kstar, cosThetaStar, deltaR); + // auto costheta = (Phid1.Px() * Phid2.Px() + Phid1.Py() * Phid2.Py() + Phid1.Pz() * Phid2.Pz()) / (Phid1.P() * Phid2.P()); + auto deltam = TMath::Sqrt(TMath::Power(Phid1.M() - 1.0192, 2.0) + TMath::Power(Phid2.M() - 1.0192, 2.0)); + if (deltaRd1 < daughterDeltaR) { + continue; + } + if (deltaRd2 < daughterDeltaR) { + continue; + } + if (!isDeep) { + histos.fill(HIST("MEMassUnlike"), exotic.M(), exotic.Pt(), deltaR, deltam); } - if (fillDeltaMass) { - histos.fill(HIST("MEMassUnlike"), exotic.M() - Phid1.M(), exotic.Pt(), kstar, cosThetaStar, deltaR); + if (isDeep) { + histos.fill(HIST("MEMassUnlike"), exotic.M(), exotic.Pt(), deltaR, deltam); } } } diff --git a/PWGLF/Tasks/Resonances/f0980analysis.cxx b/PWGLF/Tasks/Resonances/f0980analysis.cxx index 3353fbebbab..0d489209e93 100644 --- a/PWGLF/Tasks/Resonances/f0980analysis.cxx +++ b/PWGLF/Tasks/Resonances/f0980analysis.cxx @@ -8,138 +8,122 @@ // 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. +/// +/// \file f0980analysis.cxx +/// \brief f0(980) analysis in pp 13.6 TeV +/// \author Yunseul Bae (ybae@cern.ch), Junlee Kim (jikim1290@gmail.com) +/// \since 01/07/2024 -/// \author Junlee Kim (jikim1290@gmail.com) - -#include -#include -#include "TVector2.h" +#include "PWGLF/DataModel/LFResonanceTables.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/PIDResponse.h" + +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" #include "DataFormatsParameters/GRPObject.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisHelpers.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" -#include "PWGLF/DataModel/LFResonanceTables.h" -#include "CommonConstants/PhysicsConstants.h" +#include + +#include "Math/LorentzVector.h" +#include "Math/Vector4D.h" +#include "TVector2.h" +#include + +#include using namespace o2; +using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::aod; using namespace o2::soa; -using namespace o2::constants::physics; struct f0980analysis { SliceCache cache; - HistogramRegistry histos{ - "histos", - {}, - OutputObjHandlingPolicy::AnalysisObject}; - - Configurable cfgMinPt{"cfgMinPt", 0.15, - "Minimum transverse momentum for charged track"}; - Configurable cfgMaxEta{"cfgMaxEta", 0.8, - "Maximum pseudorapidiy for charged track"}; - Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.5, - "Maximum transverse DCA"}; - Configurable cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 2.0, - "Maximum longitudinal DCA"}; - Configurable cfgMaxTPC{"cfgMaxTPC", 5.0, "Maximum TPC PID with TOF"}; - Configurable cfgMaxTOF{"cfgMaxTOF", 3.0, "Maximum TOF PID with TPC"}; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Event selections + Configurable cfgMinpT{"cfgMinpT", 0.15, "Minimum transverse momentum for charged track"}; + Configurable cfgMaxEta{"cfgMaxEta", 0.8, "Maximum pseudorapidiy for charged track"}; + Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.5, "Maximum transverse DCA"}; + Configurable cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 2.0, "Maximum longitudinal DCA"}; Configurable cfgMinRap{"cfgMinRap", -0.5, "Minimum rapidity for pair"}; Configurable cfgMaxRap{"cfgMaxRap", 0.5, "Maximum rapidity for pair"}; Configurable cfgFindRT{"cfgFindRT", false, "boolean for RT analysis"}; - // Track selection - Configurable cfgPrimaryTrack{ - "cfgPrimaryTrack", true, - "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz - Configurable cfgGlobalWoDCATrack{ - "cfgGlobalWoDCATrack", true, - "Global track selection without DCA"}; // kQualityTracks (kTrackType | - // kTPCNCls | kTPCCrossedRows | - // kTPCCrossedRowsOverNCls | - // kTPCChi2NDF | kTPCRefit | - // kITSNCls | kITSChi2NDF | - // kITSRefit | kITSHits) | - // kInAcceptanceTracks (kPtRange | - // kEtaRange) - Configurable cfgPVContributor{ - "cfgPVContributor", true, - "PV contributor track selection"}; // PV Contriuibutor - Configurable cfgGlobalTrack{ - "cfgGlobalTrack", false, - "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; - Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; - Configurable cfgRatioTPCRowsOverFindableCls{ - "cfgRatioTPCRowsOverFindableCls", 0.0f, - "TPC Crossed Rows to Findable Clusters"}; - Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; - Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; + // Track selections + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | + // kTPCNCls | kTPCCrossedRows | + // kTPCCrossedRowsOverNCls | + // kTPCChi2NDF | kTPCRefit | + // kITSNCls | kITSChi2NDF | + // kITSRefit | kITSHits) | + // kInAcceptanceTracks (kPtRange | + // kEtaRange) + Configurable cfgPVContributor{"cfgPVContributor", true, "PV contributor track selection"}; Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; - Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; - Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; - // PID - Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF - Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC + // PID + Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; + Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 5.0, "TPC nSigma cut for Pion"}; + Configurable cMaxTPCnSigmaPionWoTOF{"cMaxTPCnSigmaPionWoTOF", 2.0, "TPC nSigma cut without TOF for Pion"}; Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; - Configurable SelectType{"SelectType", 0, "PID selection type"}; + Configurable selectType{"SelectType", 0, "PID selection type"}; - // Axis + // Axis ConfigurableAxis massAxis{"massAxis", {400, 0.2, 2.2}, "Invariant mass axis"}; - ConfigurableAxis ptAxis{"ptAxis", {VARIABLE_WIDTH, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 13.0, 20.0}, "Transverse momentum Binning"}; - ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 65.0, 70.0, 75.0, 80.0, 95.0, 100.0, 105.0, 110.0}, "Centrality Binning"}; + ConfigurableAxis pTAxis{"pTAxis", {VARIABLE_WIDTH, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 13.0, 20.0}, "Transverse momentum Binning"}; + ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 65.0, 70.0, 75.0, 80.0, 95.0, 100.0, 105.0, 110.0}, "Centrality Binning"}; + void init(o2::framework::InitContext&) { std::vector lptBinning = {0, 5.0, 13.0, 20.0, 50.0, 1000.0}; - AxisSpec RTAxis = {3, 0, 3}; - AxisSpec LptAxis = {lptBinning}; // Minimum leading hadron pT selection + AxisSpec rtAxis = {3, 0, 3}; + AxisSpec lptAxis = {lptBinning}; // Minimum leading hadron pT selection - AxisSpec PIDqaAxis = {120, -6, 6}; + AxisSpec pidqaAxis = {60, -6, 6}; AxisSpec pTqaAxis = {200, 0, 20}; - AxisSpec phiqaAxis = {72, 0., 2.0 * constants::math::PI}; - AxisSpec EPAxis = {10, 0, constants::math::PI}; - AxisSpec EPqaAxis = {200, -constants::math::PI, constants::math::PI}; - AxisSpec EPresAxis = {200, -2, 2}; + AxisSpec phiqaAxis = {72, 0, o2::constants::math::TwoPI}; // Azimuthal angle axis + + AxisSpec epAxis = {10, 0, o2::constants::math::PI}; // Event Plane + AxisSpec epqaAxis = {200, -o2::constants::math::PI, o2::constants::math::PI}; + AxisSpec epResAxis = {200, -2, 2}; if (cfgFindRT) { - histos.add("hInvMass_f0980_US", "unlike invariant mass", - {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, RTAxis, LptAxis}}); - histos.add("hInvMass_f0980_LSpp", "++ invariant mass", - {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, RTAxis, LptAxis}}); - histos.add("hInvMass_f0980_LSmm", "-- invariant mass", - {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, RTAxis, LptAxis}}); + histos.add("hInvMass_f0980_US", "unlike invariant mass", {HistType::kTHnSparseF, {massAxis, pTAxis, centAxis, rtAxis, lptAxis}}); + histos.add("hInvMass_f0980_LSpp", "++ invariant mass", {HistType::kTHnSparseF, {massAxis, pTAxis, centAxis, rtAxis, lptAxis}}); + histos.add("hInvMass_f0980_LSmm", "-- invariant mass", {HistType::kTHnSparseF, {massAxis, pTAxis, centAxis, rtAxis, lptAxis}}); + } else { + histos.add("hInvMass_f0980_US_EPA", "unlike invariant mass", {HistType::kTHnSparseF, {massAxis, pTAxis, centAxis, epAxis}}); + histos.add("hInvMass_f0980_LSpp_EPA", "++ invariant mass", {HistType::kTHnSparseF, {massAxis, pTAxis, centAxis, epAxis}}); + histos.add("hInvMass_f0980_LSmm_EPA", "-- invariant mass", {HistType::kTHnSparseF, {massAxis, pTAxis, centAxis, epAxis}}); } - histos.add("hInvMass_f0980_US_EPA", "unlike invariant mass", - {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, EPAxis}}); - histos.add("hInvMass_f0980_LSpp_EPA", "++ invariant mass", - {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, EPAxis}}); - histos.add("hInvMass_f0980_LSmm_EPA", "-- invariant mass", - {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, EPAxis}}); - - histos.add("QA/hEPResAB", "", {HistType::kTH2F, {centAxis, EPresAxis}}); - histos.add("QA/hEPResAC", "", {HistType::kTH2F, {centAxis, EPresAxis}}); - histos.add("QA/hEPResBC", "", {HistType::kTH2F, {centAxis, EPresAxis}}); - histos.add("QA/Nsigma_TPC", "", {HistType::kTH2F, {pTqaAxis, PIDqaAxis}}); - histos.add("QA/Nsigma_TOF", "", {HistType::kTH2F, {pTqaAxis, PIDqaAxis}}); - histos.add("QA/TPC_TOF", "", {HistType::kTH2F, {PIDqaAxis, PIDqaAxis}}); + histos.add("QA/EPhist", "", {HistType::kTH2F, {centAxis, epqaAxis}}); + histos.add("QA/hEPResAB", "", {HistType::kTH2F, {centAxis, epResAxis}}); + histos.add("QA/hEPResBC", "", {HistType::kTH2F, {centAxis, epResAxis}}); + histos.add("QA/hEPResAC", "", {HistType::kTH2F, {centAxis, epResAxis}}); histos.add("QA/LTpt", "", {HistType::kTH3F, {pTqaAxis, centAxis, phiqaAxis}}); - histos.add("QA/EPhist", "", {HistType::kTH2F, {centAxis, EPqaAxis}}); + + histos.add("QA/Nsigma_TPC", "", {HistType::kTH2F, {pTqaAxis, pidqaAxis}}); + histos.add("QA/Nsigma_TOF", "", {HistType::kTH2F, {pTqaAxis, pidqaAxis}}); + histos.add("QA/Nsigma_TPC_TOF", "", {HistType::kTH2F, {pidqaAxis, pidqaAxis}}); if (doprocessMCLight) { - histos.add("MCL/hpT_f0980_GEN", "generated f0 signals", HistType::kTH1F, - {pTqaAxis}); - histos.add("MCL/hpT_f0980_REC", "reconstructed f0 signals", - HistType::kTH3F, {massAxis, pTqaAxis, centAxis}); + histos.add("MCL/hpT_f0980_GEN", "generated f0 signals", HistType::kTH1F, {pTqaAxis}); + histos.add("MCL/hpT_f0980_REC", "reconstructed f0 signals", HistType::kTH3F, {massAxis, pTqaAxis, centAxis}); } histos.print(); @@ -147,23 +131,28 @@ struct f0980analysis { double massPi = MassPionCharged; - int RTIndex(double pairphi, double lhphi) + static constexpr float OneThird = 1.0f / 3.0f; + static constexpr float PIthird = o2::constants::math::PI * OneThird; + static constexpr float TWOPIthird = o2::constants::math::TwoPI * OneThird; + + int rtIndex(double pairphi, double lhphi) { double dphi = std::fabs(TVector2::Phi_mpi_pi(lhphi - pairphi)); - if (dphi < constants::math::PI / 3.0) + + if (dphi < PIthird) return 0; - if (dphi < 2.0 * constants::math::PI / 3.0 && dphi > constants::math::PI / 3.0) + if (dphi < TWOPIthird && dphi > PIthird) return 1; - if (dphi > 2.0 * constants::math::PI / 3.0) + if (dphi > TWOPIthird) return 2; return -1; } template - bool SelTrack(const TrackType track) + bool selTrack(const TrackType track) { - if (std::abs(track.pt()) < cfgMinPt) + if (std::abs(track.pt()) < cfgMinpT) return false; if (std::fabs(track.eta()) > cfgMaxEta) return false; @@ -171,162 +160,145 @@ struct f0980analysis { return false; if (std::abs(track.dcaZ()) > cfgMaxDCAzToPVcut) return false; - if (track.itsNCls() < cfgITScluster) - return false; if (track.tpcNClsFound() < cfgTPCcluster) return false; - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) - return false; - if (track.itsChi2NCl() >= cfgITSChi2NCl) - return false; - if (track.tpcChi2NCl() >= cfgTPCChi2NCl) + if (cfgPrimaryTrack && !track.isPrimaryTrack()) return false; - if (cfgHasITS && !track.hasITS()) + if (cfgGlobalTrack && !track.isGlobalTrack()) return false; - if (cfgHasTPC && !track.hasTPC()) + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) return false; - if (cfgHasTOF && !track.hasTOF()) + if (cfgPVContributor && !track.isPVContributor()) return false; if (cfgUseITSRefit && !track.passedITSRefit()) return false; if (cfgUseTPCRefit && !track.passedTPCRefit()) return false; - if (cfgPVContributor && !track.isPVContributor()) - return false; - if (cfgPrimaryTrack && !track.isPrimaryTrack()) - return false; - if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) - return false; - if (cfgGlobalTrack && !track.isGlobalTrack()) + if (cfgHasTOF && !track.hasTOF()) return false; return true; } template - bool SelPion(const TrackType track) + bool selPion(const TrackType track) { - if (SelectType == 0) { - if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPion || std::fabs(track.tofNSigmaPi()) >= cMaxTOFnSigmaPion) - return false; - } - if (SelectType == 1) { - if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPion) - return false; - } - if (SelectType == 2) { - if (track.tpcNSigmaPi() * track.tpcNSigmaPi() + track.tofNSigmaPi() * track.tofNSigmaPi() >= nsigmaCutCombinedPion * nsigmaCutCombinedPion) - return false; + switch (selectType) { + case 0: + if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPion || std::fabs(track.tofNSigmaPi()) >= cMaxTOFnSigmaPion) + return false; + break; + case 1: + if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPion) + return false; + break; + case 2: + if (track.tpcNSigmaPi() * track.tpcNSigmaPi() + track.tofNSigmaPi() * track.tofNSigmaPi() >= nsigmaCutCombinedPion * nsigmaCutCombinedPion) + return false; + break; + case 3: + if (track.hasTOF()) { + if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPion || std::fabs(track.tofNSigmaPi()) >= cMaxTOFnSigmaPion) + return false; + } else { + if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPionWoTOF) + return false; + } + break; } return true; } template - void fillHistograms(const CollisionType& collision, - const TracksType& dTracks) + void fillHistograms(const CollisionType& collision, const TracksType& dTracks) { - double LHpt = 0.; - double LHphi = 0.; - double relPhi = 0.; + double lhpT = 0.; + double lhphi = 0.; + double relphi = 0.; if (cfgFindRT) { - for (auto& trk : dTracks) { - if (trk.pt() > LHpt) { - LHpt = trk.pt(); - LHphi = trk.phi(); + for (const auto& trk : dTracks) { + if (trk.pt() > lhpT) { + lhpT = trk.pt(); + lhphi = trk.phi(); } } } - histos.fill(HIST("QA/EPhist"), collision.cent(), collision.evtPl()); histos.fill(HIST("QA/hEPResAB"), collision.cent(), collision.evtPlResAB()); - histos.fill(HIST("QA/hEPResAC"), collision.cent(), collision.evtPlResBC()); - histos.fill(HIST("QA/hEPResBC"), collision.cent(), collision.evtPlResAC()); - histos.fill(HIST("QA/LTpt"), LHpt, collision.cent(), LHphi); - - TLorentzVector Pion1, Pion2, Reco; - for (auto& [trk1, trk2] : - combinations(CombinationsStrictlyUpperIndexPolicy(dTracks, dTracks))) { - if (trk1.index() == trk2.index()) { - if (!SelTrack(trk1)) - continue; - histos.fill(HIST("QA/Nsigma_TPC"), trk1.pt(), trk1.tpcNSigmaPi()); - histos.fill(HIST("QA/Nsigma_TOF"), trk1.pt(), trk1.tofNSigmaPi()); - histos.fill(HIST("QA/TPC_TOF"), trk1.tpcNSigmaPi(), trk1.tofNSigmaPi()); - continue; - } + histos.fill(HIST("QA/hEPResBC"), collision.cent(), collision.evtPlResBC()); + histos.fill(HIST("QA/hEPResAC"), collision.cent(), collision.evtPlResAC()); + histos.fill(HIST("QA/LTpt"), lhpT, collision.cent(), lhphi); - if (!SelTrack(trk1) || !SelTrack(trk2)) - continue; - if (!SelPion(trk1) || !SelPion(trk2)) + ROOT::Math::LorentzVector> pion1, pion2, reco; + for (const auto& [trk1, trk2] : combinations(CombinationsStrictlyUpperIndexPolicy(dTracks, dTracks))) { + + if (!selTrack(trk1) || !selTrack(trk2)) continue; + histos.fill(HIST("QA/Nsigma_TPC"), trk1.pt(), trk1.tpcNSigmaPi()); + histos.fill(HIST("QA/Nsigma_TOF"), trk1.pt(), trk1.tofNSigmaPi()); + histos.fill(HIST("QA/Nsigma_TPC_TOF"), trk1.tpcNSigmaPi(), trk1.tofNSigmaPi()); - Pion1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi); - Pion2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi); - Reco = Pion1 + Pion2; + if (!selPion(trk1) || !selPion(trk2)) + continue; - if (Reco.Rapidity() > cfgMaxRap || Reco.Rapidity() < cfgMinRap) + pion1 = ROOT::Math::PxPyPzMVector(trk1.px(), trk1.py(), trk1.pz(), massPi); + pion2 = ROOT::Math::PxPyPzMVector(trk2.px(), trk2.py(), trk2.pz(), massPi); + reco = pion1 + pion2; + if (reco.Rapidity() > cfgMaxRap || reco.Rapidity() < cfgMinRap) continue; - relPhi = TVector2::Phi_0_2pi(Reco.Phi() - collision.evtPl()); - if (relPhi > constants::math::PI) { - relPhi -= constants::math::PI; + relphi = TVector2::Phi_0_2pi(reco.Phi() - collision.evtPl()); + if (relphi > o2::constants::math::PI) { + relphi -= o2::constants::math::PI; } if (trk1.sign() * trk2.sign() < 0) { if (cfgFindRT) { - histos.fill(HIST("hInvMass_f0980_US"), Reco.M(), Reco.Pt(), - collision.cent(), RTIndex(Reco.Phi(), LHphi), LHpt); + histos.fill(HIST("hInvMass_f0980_US"), reco.M(), reco.Pt(), collision.cent(), rtIndex(reco.Phi(), lhphi), lhpT); } - histos.fill(HIST("hInvMass_f0980_US_EPA"), Reco.M(), Reco.Pt(), - collision.cent(), relPhi); + histos.fill(HIST("hInvMass_f0980_US_EPA"), reco.M(), reco.Pt(), collision.cent(), relphi); if constexpr (IsMC) { - if (abs(trk1.pdgCode()) != 211 || abs(trk2.pdgCode()) != 211) + if (std::abs(trk1.pdgCode()) != kPiPlus || std::abs(trk2.pdgCode()) != kPiPlus) continue; if (trk1.motherId() != trk2.motherId()) continue; - if (abs(trk1.motherPDG()) != 9010221) + if (std::abs(trk1.motherPDG()) != 9010221) continue; - histos.fill(HIST("MCL/hpT_f0980_REC"), Reco.M(), Reco.Pt(), - collision.cent()); + histos.fill(HIST("MCL/hpT_f0980_REC"), reco.M(), reco.Pt(), collision.cent()); } } else if (trk1.sign() > 0 && trk2.sign() > 0) { if (cfgFindRT) { - histos.fill(HIST("hInvMass_f0980_LSpp"), Reco.M(), Reco.Pt(), - collision.cent(), RTIndex(Reco.Phi(), LHphi), LHpt); + histos.fill(HIST("hInvMass_f0980_LSpp"), reco.M(), reco.Pt(), collision.cent(), rtIndex(reco.Phi(), lhphi), lhpT); } - histos.fill(HIST("hInvMass_f0980_LSpp_EPA"), Reco.M(), Reco.Pt(), - collision.cent(), relPhi); + histos.fill(HIST("hInvMass_f0980_LSpp_EPA"), reco.M(), reco.Pt(), collision.cent(), relphi); } else if (trk1.sign() < 0 && trk2.sign() < 0) { if (cfgFindRT) { - histos.fill(HIST("hInvMass_f0980_LSmm"), Reco.M(), Reco.Pt(), - collision.cent(), RTIndex(Reco.Phi(), LHphi), LHpt); + histos.fill(HIST("hInvMass_f0980_LSmm"), reco.M(), reco.Pt(), collision.cent(), rtIndex(reco.Phi(), lhphi), lhpT); } - histos.fill(HIST("hInvMass_f0980_LSmm_EPA"), Reco.M(), Reco.Pt(), - collision.cent(), relPhi); + histos.fill(HIST("hInvMass_f0980_LSmm_EPA"), reco.M(), reco.Pt(), collision.cent(), relphi); } } } - void processData(aod::ResoCollision& collision, - aod::ResoTracks const& resotracks) + void processData(o2::soa::Join::iterator const& collision, + o2::aod::ResoTracks const& resotracks) { fillHistograms(collision, resotracks); } PROCESS_SWITCH(f0980analysis, processData, "Process Event for data", true); void processMCLight( - aod::ResoCollision& collision, - soa::Join const& resotracks) + o2::soa::Join::iterator const& collision, + o2::soa::Join const& resotracks) { fillHistograms(collision, resotracks); } PROCESS_SWITCH(f0980analysis, processMCLight, "Process Event for MC", false); - void processMCTrue(aod::ResoMCParents& resoParents) + void processMCTrue(const o2::aod::ResoMCParents& resoParents) { - - for (auto& part : resoParents) { // loop over all pre-filtered MC particles - if (abs(part.pdgCode()) != 9010221) + for (const auto& part : resoParents) { // loop over all pre-filtered MC particles + if (std::abs(part.pdgCode()) != 9010221) continue; if (!part.producedByGenerator()) continue; @@ -334,8 +306,8 @@ struct f0980analysis { continue; } bool pass = false; - if ((abs(part.daughterPDG1()) == 211 && - abs(part.daughterPDG2()) == 211)) { + if ((std::abs(part.daughterPDG1()) == kPiPlus && + std::abs(part.daughterPDG2()) == kPiPlus)) { pass = true; } if (!pass) // If we have both decay products diff --git a/PWGLF/Tasks/Resonances/f0980pbpbanalysis.cxx b/PWGLF/Tasks/Resonances/f0980pbpbanalysis.cxx index febb7eeec96..96abd0ca43a 100644 --- a/PWGLF/Tasks/Resonances/f0980pbpbanalysis.cxx +++ b/PWGLF/Tasks/Resonances/f0980pbpbanalysis.cxx @@ -9,51 +9,56 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file f0980pbpbanalysis.cxx +/// \brief f0980 resonance analysis in PbPb collisions /// \author Junlee Kim (jikim1290@gmail.com) -#include +#include +#include + #include -#include #include +#include +#include +// #include #include -#include "TLorentzVector.h" -#include "TRandom3.h" -#include "TF1.h" -#include "TVector2.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/StaticFor.h" - -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" +// #include "TLorentzVector.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" - +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" #include "CommonConstants/PhysicsConstants.h" - +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/StaticFor.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" +#include -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TRandom3.h" +#include "TVector2.h" +#include -#include "CCDB/CcdbApi.h" -#include "CCDB/BasicCCDBManager.h" +// from phi +#include "Common/DataModel/PIDResponseITS.h" using namespace o2; using namespace o2::framework; @@ -61,7 +66,7 @@ using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::constants::physics; -struct f0980pbpbanalysis { +struct F0980pbpbanalysis { HistogramRegistry histos{ "histos", {}, @@ -71,13 +76,13 @@ struct f0980pbpbanalysis { o2::ccdb::CcdbApi ccdbApi; Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; - Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; Configurable cfgCutVertex{"cfgCutVertex", 10.0, "PV selection"}; Configurable cfgQvecSel{"cfgQvecSel", true, "Reject events when no QVector"}; - Configurable cfgOccupancySel{"cfgOccupancySe", false, "Occupancy selection"}; - Configurable cfgMaxOccupancy{"cfgMaxOccupancy", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; - Configurable cfgMinOccupancy{"cfgMinOccupancy", -100, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; + Configurable cfgOccupancySel{"cfgOccupancySel", false, "Occupancy selection"}; + Configurable cfgOccupancyMax{"cfgOccupancyMax", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; + Configurable cfgOccupancyMin{"cfgOccupancyMin", -100, "minimum occupancy of tracks in neighbouring collisions in a given time range"}; Configurable cfgNCollinTR{"cfgNCollinTR", false, "Additional selection for the number of coll in time range"}; Configurable cfgPVSel{"cfgPVSel", false, "Additional PV selection flag for syst"}; Configurable cfgPV{"cfgPV", 8.0, "Additional PV selection range for syst"}; @@ -92,56 +97,114 @@ struct f0980pbpbanalysis { Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.8, "TPC Crossed Rows to Findable Clusters"}; - Configurable cfgMinRap{"cfgMinRap", -0.5, "Minimum rapidity for pair"}; - Configurable cfgMaxRap{"cfgMaxRap", 0.5, "Maximum rapidity for pair"}; + Configurable cfgRapMin{"cfgRapMin", -0.5, "Minimum rapidity for pair"}; + Configurable cfgRapMax{"cfgRapMax", 0.5, "Maximum rapidity for pair"}; - Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; - Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; - Configurable cfgPVContributor{"cfgPVContributor", true, "PV contributor track selection"}; + Configurable cfgIsPrimaryTrack{"cfgIsPrimaryTrack", true, "Primary track selection"}; + Configurable cfgIsGlobalWoDCATrack{"cfgIsGlobalWoDCATrack", true, "Global track selection without DCA"}; + Configurable cfgIsPVContributor{"cfgIsPVContributor", true, "PV contributor track selection"}; Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 5.0, "TPC nSigma cut for Pion"}; // TPC Configurable cMaxTPCnSigmaPionS{"cMaxTPCnSigmaPionS", 3.0, "TPC nSigma cut for Pion as a standalone"}; Configurable cfgUSETOF{"cfgUSETOF", false, "TPC usage"}; + Configurable cfgSelectPID{"cfgSelectPID", 0, "PID selection type"}; + Configurable cfgSelectPtl{"cfgSelectPtl", 0, "Particle selection type"}; - Configurable cfgnMods{"cfgnMods", 1, "The number of modulations of interest starting from 2"}; + Configurable cfgNMods{"cfgNMods", 1, "The number of modulations of interest starting from 2"}; Configurable cfgNQvec{"cfgNQvec", 7, "The number of total Qvectors for looping over the task"}; Configurable cfgQvecDetName{"cfgQvecDetName", "FT0C", "The name of detector to be analyzed"}; Configurable cfgQvecRefAName{"cfgQvecRefAName", "TPCpos", "The name of detector for reference A"}; Configurable cfgQvecRefBName{"cfgQvecRefBName", "TPCneg", "The name of detector for reference B"}; + Configurable cfgRotBkgSel{"cfgRotBkgSel", true, "flag to construct rotational backgrounds"}; + Configurable cfgRotBkgNum{"cfgRotBkgNum", 10, "the number of rotational backgrounds"}; + + // for phi test + Configurable cfgRatioTPCRowsFinableClsSel{"cfgRatioTPCRowsFinableClsSel", true, "TPC Crossed Rows to Findable Clusters selection flag"}; + Configurable cfgITSClsSel{"cfgITSClsSel", false, "ITS cluster selection flag"}; + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTOFBetaSel{"cfgTOFBetaSel", false, "TOF beta cut selection flag"}; + Configurable cfgTOFBetaCut{"cfgTOFBetaCut", 0.0, "cut TOF beta"}; + Configurable cfgDeepAngleSel{"cfgDeepAngleSel", true, "Deep Angle cut"}; + Configurable cfgDeepAngle{"cfgDeepAngle", 0.04, "Deep Angle cut value"}; + Configurable cfgTrackIndexSelType{"cfgTrackIndexSelType", 1, "Index selection type"}; + Configurable cMaxTiednSigmaPion{"cMaxTiednSigmaPion", 3.0, "Combined nSigma cut for Pion"}; + ConfigurableAxis massAxis{"massAxis", {400, 0.2, 2.2}, "Invariant mass axis"}; ConfigurableAxis ptAxis{"ptAxis", {VARIABLE_WIDTH, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 13.0, 20.0}, "Transverse momentum Binning"}; ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "Centrality interval"}; + // for event mixing + SliceCache cache; + Configurable cfgNMixedEvents{"cfgNMixedEvents", 10, "Number of mixed events per event"}; + ConfigurableAxis mixingAxisVertex{"mixingAxisVertex", {10, -10, 10}, "Vertex axis for mixing bin"}; + ConfigurableAxis mixingAxisMultiplicity{"mixingAxisMultiplicity", {VARIABLE_WIDTH, 0, 10, 20, 50, 100}, "multiplicity percentile for mixing bin"}; + // ConfigurableAxis mixingAxisMultiplicity{"mixingAxisMultiplicity", {2000, 0, 10000}, "TPC multiplicity for bin"}; + TF1* fMultPVCutLow = nullptr; TF1* fMultPVCutHigh = nullptr; - int DetId; - int RefAId; - int RefBId; + int detId; + int refAId; + int refBId; - int QvecDetInd; - int QvecRefAInd; - int QvecRefBInd; + int qVecDetInd; + int qVecRefAInd; + int qVecRefBInd; float centrality; double angle; double relPhi; + double relPhiRot; + double relPhiMix; - double massPi = o2::constants::physics::MassPionCharged; + // double massPi = o2::constants::physics::MassPionCharged; + double massPtl; + + enum CentEstList { + FT0C = 0, + FT0M = 1, + }; + + enum PIDList { + PIDRun3 = 0, + PIDRun2 = 1, + PIDTest = 2, + }; + + enum PtlList { + PtlPion = 0, + PtlKaon = 1, + }; + + enum IndexSelList { + None = 0, + woSame = 1, + leq = 2 + }; + + TRandom* rn = new TRandom(); + // float theta2; Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter acceptanceFilter = (nabs(aod::track::eta) < cfgMaxEta && nabs(aod::track::pt) > cfgMinPt); - Filter DCAcutFilter = (nabs(aod::track::dcaXY) < cfgMaxDCArToPVcut) && (nabs(aod::track::dcaZ) < cfgMaxDCAzToPVcut); + Filter cutDCAFilter = (nabs(aod::track::dcaXY) < cfgMaxDCArToPVcut) && (nabs(aod::track::dcaZ) < cfgMaxDCAzToPVcut); + // from phi + // Filter centralityFilter = nabs(aod::cent::centFT0C) < cfgCentSel; + // Filter PIDcutFilter = nabs(aod::pidtpc::tpcNSigmaKa) < cMaxTPCnSigmaPion; + // Filter PIDcutFilter = nabs(aod::pidTPCFullKa::tpcNSigmaKa) < cMaxTPCnSigmaPion; using EventCandidates = soa::Filtered>; - using TrackCandidates = soa::Filtered>; + using TrackCandidates = soa::Filtered>; + // aod::pidTOFbeta 추가됨 + + using BinningTypeVertexContributor = ColumnBinningPolicy; template - int GetDetId(const T& name) + int getDetId(const T& name) { if (name.value == "FT0C") { return 0; @@ -163,6 +226,7 @@ struct f0980pbpbanalysis { template bool eventSelected(TCollision collision) { + constexpr double QvecAmpMin = 1e-4; if (!collision.sel8()) { return 0; } @@ -185,10 +249,10 @@ struct f0980pbpbanalysis { if (!collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { return 0; } - if (cfgQvecSel && (collision.qvecAmp()[DetId] < 1e-4 || collision.qvecAmp()[RefAId] < 1e-4 || collision.qvecAmp()[RefAId] < 1e-4)) { + if (cfgQvecSel && (collision.qvecAmp()[detId] < QvecAmpMin || collision.qvecAmp()[refAId] < QvecAmpMin || collision.qvecAmp()[refBId] < QvecAmpMin)) { return 0; } - if (cfgOccupancySel && (collision.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision.trackOccupancyInTimeRange() < cfgMinOccupancy)) { + if (cfgOccupancySel && (collision.trackOccupancyInTimeRange() > cfgOccupancyMax || collision.trackOccupancyInTimeRange() < cfgOccupancyMin)) { return 0; } if (cfgNCollinTR && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { @@ -197,7 +261,6 @@ struct f0980pbpbanalysis { if (cfgPVSel && std::abs(collision.posZ()) > cfgPV) { return 0; } - return 1; } // event selection @@ -216,138 +279,341 @@ struct f0980pbpbanalysis { if (std::fabs(track.dcaZ()) > cfgMaxDCAzToPVcut) { return 0; } - if (track.tpcNClsFound() < cfgTPCcluster) { + if (cfgIsPVContributor && !track.isPVContributor()) { return 0; } - if (cfgPVContributor && !track.isPVContributor()) { + if (cfgIsPrimaryTrack && !track.isPrimaryTrack()) { return 0; } - if (cfgPrimaryTrack && !track.isPrimaryTrack()) { + if (cfgIsGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) { return 0; } - if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) { + if (track.tpcNClsFound() < cfgTPCcluster) { return 0; } - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) { + if (cfgRatioTPCRowsFinableClsSel && track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) { + return 0; + } + if (cfgITSClsSel && track.itsNCls() < cfgITScluster) { return 0; } - return 1; } template - bool PIDSelected(const TrackType track) + bool selectionPID(const TrackType track) { - if (cfgUSETOF) { - if (std::fabs(track.tofNSigmaPi()) > cMaxTOFnSigmaPion) { + if (cfgSelectPID == PIDList::PIDRun3) { + if (cfgUSETOF) { + if (std::fabs(track.tofNSigmaPi()) > cMaxTOFnSigmaPion) { + return 0; + } + if (std::fabs(track.tpcNSigmaPi()) > cMaxTPCnSigmaPion) { + return 0; + } + } + if (std::fabs(track.tpcNSigmaPi()) > cMaxTPCnSigmaPionS) { + return 0; + } + } else if (cfgSelectPID == PIDList::PIDRun2) { + if (cfgUSETOF) { + if (track.hasTOF()) { + if (std::fabs(track.tofNSigmaPi()) > cMaxTOFnSigmaPion) { + return 0; + } + if (std::fabs(track.tpcNSigmaPi()) > cMaxTPCnSigmaPion) { + return 0; + } + } else { + if (std::fabs(track.tpcNSigmaPi()) > cMaxTPCnSigmaPionS) { + return 0; + } + } + } else { + if (std::fabs(track.tpcNSigmaPi()) > cMaxTPCnSigmaPionS) { + return 0; + } + } + } else if (cfgSelectPID == PIDList::PIDTest) { + if (cfgUSETOF) { + if (track.hasTOF()) { + if ((getTpcNSigma(track) * getTpcNSigma(track) + getTofNSigma(track) * getTofNSigma(track)) > (cMaxTiednSigmaPion * cMaxTiednSigmaPion)) { + return 0; + } + } else { + if (std::fabs(getTpcNSigma(track)) > cMaxTPCnSigmaPionS) { + return 0; + } + } + } else { + if (std::fabs(getTpcNSigma(track)) > cMaxTPCnSigmaPionS) { + return 0; + } + } + } + return 1; + } + + template + bool indexSelection(const TrackType1 track1, const TrackType2 track2) + { + if (cfgTrackIndexSelType == IndexSelList::woSame) { + if (track2.globalIndex() == track1.globalIndex()) { return 0; } - if (std::fabs(track.tpcNSigmaPi()) > cMaxTPCnSigmaPion) { + } else if (cfgTrackIndexSelType == IndexSelList::leq) { + if (track2.globalIndex() <= track1.globalIndex()) { return 0; } } - if (std::fabs(track.tpcNSigmaPi()) > cMaxTPCnSigmaPionS) { + return 1; + } + + template + bool selectionPair(const TrackType1 track1, const TrackType2 track2) + { + double pt1, pt2, pz1, pz2, p1, p2, angle; + pt1 = track1.pt(); + pt2 = track2.pt(); + pz1 = track1.pz(); + pz2 = track2.pz(); + p1 = track1.p(); + p2 = track2.p(); + angle = std::acos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); + if (cfgDeepAngleSel && angle < cfgDeepAngle) { return 0; } - return 1; } + template + float getTpcNSigma(const TrackType track) + { + if (cfgSelectPtl == PtlList::PtlPion) { + return track.tpcNSigmaPi(); + } else { + return track.tpcNSigmaKa(); + } + } + + template + float getTofNSigma(const TrackType track) + { + if (cfgSelectPtl == PtlList::PtlPion) { + return track.tofNSigmaPi(); + } else { + return track.tofNSigmaKa(); + } + } + template - void FillHistograms(const CollisionType& collision, + void fillHistograms(const CollisionType& collision, const TracksType& dTracks, int nmode) { - QvecDetInd = DetId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; - QvecRefAInd = RefAId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; - QvecRefBInd = RefBId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; + qVecDetInd = detId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; + qVecRefAInd = refAId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; + qVecRefBInd = refBId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; - double eventPlaneDet = TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) / static_cast(nmode); - double eventPlaneRefA = TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) / static_cast(nmode); - double eventPlaneRefB = TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]) / static_cast(nmode); + double eventPlaneDet = std::atan2(collision.qvecIm()[qVecDetInd], collision.qvecRe()[qVecDetInd]) / static_cast(nmode); + double eventPlaneRefA = std::atan2(collision.qvecIm()[qVecRefAInd], collision.qvecRe()[qVecRefAInd]) / static_cast(nmode); + double eventPlaneRefB = std::atan2(collision.qvecIm()[qVecRefBInd], collision.qvecRe()[qVecRefBInd]) / static_cast(nmode); histos.fill(HIST("QA/EPhist"), centrality, eventPlaneDet); - histos.fill(HIST("QA/EPResAB"), centrality, TMath::Cos(static_cast(nmode) * (eventPlaneDet - eventPlaneRefA))); - histos.fill(HIST("QA/EPResAC"), centrality, TMath::Cos(static_cast(nmode) * (eventPlaneDet - eventPlaneRefB))); - histos.fill(HIST("QA/EPResBC"), centrality, TMath::Cos(static_cast(nmode) * (eventPlaneRefA - eventPlaneRefB))); - - TLorentzVector Pion1, Pion2, Reco; - for (auto& [trk1, trk2] : - combinations(CombinationsUpperIndexPolicy(dTracks, dTracks))) { - if (trk1.index() == trk2.index()) { - if (!trackSelected(trk1)) - continue; - histos.fill(HIST("QA/Nsigma_TPC"), trk1.pt(), trk1.tpcNSigmaPi()); - histos.fill(HIST("QA/Nsigma_TOF"), trk1.pt(), trk1.tofNSigmaPi()); - histos.fill(HIST("QA/TPC_TOF"), trk1.tpcNSigmaPi(), trk1.tofNSigmaPi()); + histos.fill(HIST("QA/EPResAB"), centrality, std::cos(static_cast(nmode) * (eventPlaneDet - eventPlaneRefA))); + histos.fill(HIST("QA/EPResAC"), centrality, std::cos(static_cast(nmode) * (eventPlaneDet - eventPlaneRefB))); + histos.fill(HIST("QA/EPResBC"), centrality, std::cos(static_cast(nmode) * (eventPlaneRefA - eventPlaneRefB))); + + ROOT::Math::PxPyPzMVector pion1, pion2, pion2Rot, reco, recoRot; + for (const auto& trk1 : dTracks) { + if (!trackSelected(trk1)) { continue; } - if (!trackSelected(trk1) || !trackSelected(trk2)) + if (!selectionPID(trk1)) { continue; - if (!PIDSelected(trk1) || !PIDSelected(trk2)) - continue; - - if (trk1.index() == trk2.index()) { - histos.fill(HIST("QA/Nsigma_TPC_selected"), trk1.pt(), trk1.tpcNSigmaPi()); - histos.fill(HIST("QA/Nsigma_TOF_selected"), trk1.pt(), trk1.tofNSigmaPi()); - histos.fill(HIST("QA/TPC_TOF_selected"), trk1.tpcNSigmaPi(), trk1.tofNSigmaPi()); } - Pion1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi); - Pion2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi); - Reco = Pion1 + Pion2; + histos.fill(HIST("QA/Nsigma_TPC"), trk1.pt(), getTpcNSigma(trk1)); + histos.fill(HIST("QA/Nsigma_TOF"), trk1.pt(), getTofNSigma(trk1)); + histos.fill(HIST("QA/TPC_TOF"), getTpcNSigma(trk1), getTofNSigma(trk1)); + + for (const auto& trk2 : dTracks) { + if (!trackSelected(trk2)) { + continue; + } - if (Reco.Rapidity() > cfgMaxRap || Reco.Rapidity() < cfgMinRap) + // PID + if (!selectionPID(trk2)) { + continue; + } + + if (trk1.index() == trk2.index()) { + histos.fill(HIST("QA/Nsigma_TPC_selected"), trk1.pt(), getTpcNSigma(trk2)); + histos.fill(HIST("QA/Nsigma_TOF_selected"), trk1.pt(), getTofNSigma(trk2)); + histos.fill(HIST("QA/TPC_TOF_selected"), getTpcNSigma(trk2), getTofNSigma(trk2)); + } + + if (!indexSelection(trk1, trk2)) { + continue; + } + + if (!selectionPair(trk1, trk2)) { + continue; + } + + pion1 = ROOT::Math::PxPyPzMVector(trk1.px(), trk1.py(), trk1.pz(), massPtl); + pion2 = ROOT::Math::PxPyPzMVector(trk2.px(), trk2.py(), trk2.pz(), massPtl); + reco = pion1 + pion2; + + if (reco.Rapidity() > cfgRapMax || reco.Rapidity() < cfgRapMin) { + continue; + } + + relPhi = TVector2::Phi_0_2pi((reco.Phi() - eventPlaneDet) * static_cast(nmode)); + + if (trk1.sign() * trk2.sign() < 0) { + histos.fill(HIST("hInvMass_f0980_US_EPA"), reco.M(), reco.Pt(), centrality, relPhi); + } else if (trk1.sign() > 0 && trk2.sign() > 0) { + histos.fill(HIST("hInvMass_f0980_LSpp_EPA"), reco.M(), reco.Pt(), centrality, relPhi); + } else if (trk1.sign() < 0 && trk2.sign() < 0) { + histos.fill(HIST("hInvMass_f0980_LSmm_EPA"), reco.M(), reco.Pt(), centrality, relPhi); + } + + if (cfgRotBkgSel && trk1.sign() * trk2.sign() < 0) { + for (int nr = 0; nr < cfgRotBkgNum; nr++) { + auto randomPhi = rn->Uniform(o2::constants::math::PI * 5.0 / 6.0, o2::constants::math::PI * 7.0 / 6.0); + randomPhi += pion2.Phi(); + pion2Rot = ROOT::Math::PxPyPzMVector(pion2.Pt() * std::cos(randomPhi), pion2.Pt() * std::sin(randomPhi), trk2.pz(), massPtl); + recoRot = pion1 + pion2Rot; + relPhiRot = TVector2::Phi_0_2pi((recoRot.Phi() - eventPlaneDet) * static_cast(nmode)); + histos.fill(HIST("hInvMass_f0980_USRot_EPA"), recoRot.M(), recoRot.Pt(), centrality, relPhiRot); + } + } + } + } + } + + void processEventMixing(EventCandidates const& collisions, TrackCandidates const& tracks) + { + int nmode = 2; // second order + qVecDetInd = detId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; + + auto trackTuple = std::make_tuple(tracks); + BinningTypeVertexContributor binningOnPositions{{mixingAxisVertex, mixingAxisMultiplicity}, true}; + SameKindPair pair{binningOnPositions, cfgNMixedEvents, -1, collisions, trackTuple, &cache}; + ROOT::Math::PxPyPzMVector ptl1, ptl2, recoPtl; + for (const auto& [c1, t1, c2, t2] : pair) { + if (cfgCentEst == CentEstList::FT0C) { + centrality = c1.centFT0C(); + } else if (cfgCentEst == CentEstList::FT0M) { + centrality = c1.centFT0M(); + } + if (!eventSelected(c1) || !eventSelected(c2)) { continue; + } + if (c1.bcId() == c2.bcId()) { + continue; + } + double eventPlaneDet = std::atan2(c1.qvecIm()[qVecDetInd], c1.qvecRe()[qVecDetInd]) / static_cast(nmode); - relPhi = TVector2::Phi_0_2pi((Reco.Phi() - eventPlaneDet) * static_cast(nmode)); - - if (trk1.sign() * trk2.sign() < 0) { - histos.fill(HIST("hInvMass_f0980_US_EPA"), Reco.M(), Reco.Pt(), centrality, relPhi); - /* - if constexpr (IsMC) { - if (abs(trk1.pdgCode()) != 211 || abs(trk2.pdgCode()) != 211) - continue; - if (trk1.motherId() != trk2.motherId()) - continue; - if (abs(trk1.motherPDG()) != 9010221) - continue; - histos.fill(HIST("MCL/hpT_f0980_REC"), Reco.M(), Reco.Pt(), centrality); - } - */ - } else if (trk1.sign() > 0 && trk2.sign() > 0) { - histos.fill(HIST("hInvMass_f0980_LSpp_EPA"), Reco.M(), Reco.Pt(), centrality, relPhi); - } else if (trk1.sign() < 0 && trk2.sign() < 0) { - histos.fill(HIST("hInvMass_f0980_LSmm_EPA"), Reco.M(), Reco.Pt(), centrality, relPhi); + for (const auto& trk1 : t1) { + if (!trackSelected(trk1)) { + continue; + } + if (!selectionPID(trk1)) { + continue; + } + + for (const auto& trk2 : t2) { + if (!trackSelected(trk2)) { + continue; + } + if (!selectionPID(trk2)) { + continue; + } + if (!indexSelection(trk1, trk2)) { + continue; + } + if (!selectionPair(trk1, trk2)) { + continue; + } + ptl1 = ROOT::Math::PxPyPzMVector(trk1.px(), trk1.py(), trk1.pz(), massPtl); + ptl2 = ROOT::Math::PxPyPzMVector(trk2.px(), trk2.py(), trk2.pz(), massPtl); + recoPtl = ptl1 + ptl2; + if (recoPtl.Rapidity() > cfgRapMax || recoPtl.Rapidity() < cfgRapMin) { + continue; + } + + relPhiMix = TVector2::Phi_0_2pi((recoPtl.Phi() - eventPlaneDet) * static_cast(nmode)); + + if (trk1.sign() * trk2.sign() < 0) { + histos.fill(HIST("hInvMass_f0980_MixedUS_EPA"), recoPtl.M(), recoPtl.Pt(), centrality, relPhiMix); + } // else if (trk1.sign() > 0 && trk2.sign() > 0) { + // histos.fill(HIST("hInvMass_f0980_MixedLSpp_EPA"), recoPtl.M(), recoPtl.Pt(), centrality, relPhiMix); + // } else if (trk1.sign() < 0 && trk2.sign() < 0) { + // histos.fill(HIST("hInvMass_f0980_MixedLSmm_EPA"), recoPtl.M(), recoPtl.Pt(), centrality, relPhiMix); + // } + } } + // for (auto& [trk1, trk2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(t1, t2))) { + // if (!trackSelected(trk1) || !trackSelected(trk2)) { + // continue; + // } + // if (!selectionPID(trk1) || !selectionPID(trk2)) { + // continue; + // } + // if (!indexSelection(trk1, trk2)) { + // continue; + // } + // if (!selectionPair(trk1, trk2)) { + // continue; + // } + // ptl1 = ROOT::Math::PxPyPzMVector(trk1.px(), trk1.py(), trk1.pz(), massPtl); + // ptl2 = ROOT::Math::PxPyPzMVector(trk2.px(), trk2.py(), trk2.pz(), massPtl); + // recoPtl = ptl1 + ptl2; + // if (recoPtl.Rapidity() > cfgRapMax || recoPtl.Rapidity() < cfgRapMin) { + // continue; + // } + + // relPhiMix = TVector2::Phi_0_2pi((recoPtl.Phi() - eventPlaneDet) * static_cast(nmode)); + + // if (trk1.sign() * trk2.sign() < 0) { + // histos.fill(HIST("hInvMass_f0980_MixedUS_EPA"), recoPtl.M(), recoPtl.Pt(), centrality, relPhiMix); + // } else if (trk1.sign() > 0 && trk2.sign() > 0) { + // histos.fill(HIST("hInvMass_f0980_MixedLSpp_EPA"), recoPtl.M(), recoPtl.Pt(), centrality, relPhiMix); + // } else if (trk1.sign() < 0 && trk2.sign() < 0) { + // histos.fill(HIST("hInvMass_f0980_MixedLSmm_EPA"), recoPtl.M(), recoPtl.Pt(), centrality, relPhiMix); + // } + // } } } + PROCESS_SWITCH(F0980pbpbanalysis, processEventMixing, "Process Event mixing", true); void init(o2::framework::InitContext&) { - AxisSpec epAxis = {6, 0.0, 2.0 * constants::math::PI}; - AxisSpec centQaAxis = {110, 0, 110}; - AxisSpec vzQaAxis = {100, -20, 20}; - AxisSpec PIDqaAxis = {100, -10, 10}; - AxisSpec pTqaAxis = {200, 0, 20}; - AxisSpec epQaAxis = {100, -1.0 * constants::math::PI, constants::math::PI}; + AxisSpec epAxis = {6, 0.0, o2::constants::math::TwoPI}; + AxisSpec qaCentAxis = {110, 0, 110}; + AxisSpec qaVzAxis = {100, -20, 20}; + AxisSpec qaPIDAxis = {100, -10, 10}; + AxisSpec qaPtAxis = {200, 0, 20}; + AxisSpec qaEpAxis = {100, -1.0 * o2::constants::math::PI, o2::constants::math::PI}; AxisSpec epresAxis = {102, -1.02, 1.02}; - histos.add("QA/CentDist", "", {HistType::kTH1F, {centQaAxis}}); - histos.add("QA/Vz", "", {HistType::kTH1F, {vzQaAxis}}); + histos.add("QA/CentDist", "", {HistType::kTH1F, {qaCentAxis}}); + histos.add("QA/Vz", "", {HistType::kTH1F, {qaVzAxis}}); - histos.add("QA/Nsigma_TPC", "", {HistType::kTH2F, {pTqaAxis, PIDqaAxis}}); - histos.add("QA/Nsigma_TOF", "", {HistType::kTH2F, {pTqaAxis, PIDqaAxis}}); - histos.add("QA/TPC_TOF", "", {HistType::kTH2F, {PIDqaAxis, PIDqaAxis}}); + histos.add("QA/Nsigma_TPC", "", {HistType::kTH2F, {qaPtAxis, qaPIDAxis}}); + histos.add("QA/Nsigma_TOF", "", {HistType::kTH2F, {qaPtAxis, qaPIDAxis}}); + histos.add("QA/TPC_TOF", "", {HistType::kTH2F, {qaPIDAxis, qaPIDAxis}}); - histos.add("QA/Nsigma_TPC_selected", "", {HistType::kTH2F, {pTqaAxis, PIDqaAxis}}); - histos.add("QA/Nsigma_TOF_selected", "", {HistType::kTH2F, {pTqaAxis, PIDqaAxis}}); - histos.add("QA/TPC_TOF_selected", "", {HistType::kTH2F, {PIDqaAxis, PIDqaAxis}}); + histos.add("QA/Nsigma_TPC_selected", "", {HistType::kTH2F, {qaPtAxis, qaPIDAxis}}); + histos.add("QA/Nsigma_TOF_selected", "", {HistType::kTH2F, {qaPtAxis, qaPIDAxis}}); + histos.add("QA/TPC_TOF_selected", "", {HistType::kTH2F, {qaPIDAxis, qaPIDAxis}}); - histos.add("QA/EPhist", "", {HistType::kTH2F, {centQaAxis, epQaAxis}}); - histos.add("QA/EPResAB", "", {HistType::kTH2F, {centQaAxis, epresAxis}}); - histos.add("QA/EPResAC", "", {HistType::kTH2F, {centQaAxis, epresAxis}}); - histos.add("QA/EPResBC", "", {HistType::kTH2F, {centQaAxis, epresAxis}}); + histos.add("QA/EPhist", "", {HistType::kTH2F, {qaCentAxis, qaEpAxis}}); + histos.add("QA/EPResAB", "", {HistType::kTH2F, {qaCentAxis, epresAxis}}); + histos.add("QA/EPResAC", "", {HistType::kTH2F, {qaCentAxis, epresAxis}}); + histos.add("QA/EPResBC", "", {HistType::kTH2F, {qaCentAxis, epresAxis}}); histos.add("hInvMass_f0980_US_EPA", "unlike invariant mass", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, epAxis}}); @@ -355,21 +621,30 @@ struct f0980pbpbanalysis { {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, epAxis}}); histos.add("hInvMass_f0980_LSmm_EPA", "-- invariant mass", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, epAxis}}); - + histos.add("hInvMass_f0980_USRot_EPA", "unlike invariant mass Rotation", + {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, epAxis}}); + histos.add("hInvMass_f0980_MixedUS_EPA", "unlike invariant mass EventMixing", + {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, epAxis}}); // if (doprocessMCLight) { - // histos.add("MCL/hpT_f0980_GEN", "generated f0 signals", HistType::kTH1F, {pTqaAxis}); - // histos.add("MCL/hpT_f0980_REC", "reconstructed f0 signals", HistType::kTH3F, {massAxis, pTqaAxis, centAxis}); + // histos.add("MCL/hpT_f0980_GEN", "generated f0 signals", HistType::kTH1F, {qaPtAxis}); + // histos.add("MCL/hpT_f0980_REC", "reconstructed f0 signals", HistType::kTH3F, {massAxis, qaPtAxis, centAxis}); // } - DetId = GetDetId(cfgQvecDetName); - RefAId = GetDetId(cfgQvecRefAName); - RefBId = GetDetId(cfgQvecRefBName); + detId = getDetId(cfgQvecDetName); + refAId = getDetId(cfgQvecRefAName); + refBId = getDetId(cfgQvecRefBName); - if (DetId == RefAId || DetId == RefBId || RefAId == RefBId) { + if (detId == refAId || detId == refBId || refAId == refBId) { LOGF(info, "Wrong detector configuration \n The FT0C will be used to get Q-Vector \n The TPCpos and TPCneg will be used as reference systems"); - DetId = 0; - RefAId = 4; - RefBId = 5; + detId = 0; + refAId = 4; + refBId = 5; + } + + if (cfgSelectPtl == PtlList::PtlPion) { + massPtl = o2::constants::physics::MassPionCharged; + } else if (cfgSelectPtl == PtlList::PtlKaon) { + massPtl = o2::constants::physics::MassKaonCharged; } fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); @@ -387,9 +662,9 @@ struct f0980pbpbanalysis { void processData(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCsWithTimestamps const&) { - if (cfgCentEst == 1) { + if (cfgCentEst == CentEstList::FT0C) { centrality = collision.centFT0C(); - } else if (cfgCentEst == 2) { + } else if (cfgCentEst == CentEstList::FT0M) { centrality = collision.centFT0M(); } if (!eventSelected(collision)) { @@ -398,13 +673,13 @@ struct f0980pbpbanalysis { histos.fill(HIST("QA/CentDist"), centrality, 1.0); histos.fill(HIST("QA/Vz"), collision.posZ(), 1.0); - FillHistograms(collision, tracks, 2); // second order + fillHistograms(collision, tracks, 2); // second order }; - PROCESS_SWITCH(f0980pbpbanalysis, processData, "Process Event for data", true); + PROCESS_SWITCH(F0980pbpbanalysis, processData, "Process Event for data", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"lf-f0980pbpbanalysis"})}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx index 20e986625a8..af45b89b8da 100644 --- a/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx +++ b/PWGLF/Tasks/Resonances/f1protoncorrelation.cxx @@ -77,6 +77,13 @@ struct f1protoncorrelation { void init(o2::framework::InitContext&) { colBinningFemto = {{CfgVtxBins, CfgMultBins}, true}; + + const AxisSpec thnAxisInvMass{configThnAxisInvMass, "#it{M} (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisPt{configThnAxisPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisPtProton{configThnAxisPtProton, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisKstar{configThnAxisKstar, "#it{k}^{*} (GeV/#it{c})"}; + const AxisSpec thnAxisNsigma{configThnAxisNsigma, "NsigmaCombined"}; + // register histograms histos.add("hNsigmaProtonTPC", "Nsigma Proton TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {100, 0.0f, 10.0f}}); histos.add("hNsigmaKaonTPC", "Nsigma Kaon TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {100, 0.0f, 10.0f}}); @@ -84,19 +91,14 @@ struct f1protoncorrelation { histos.add("hNsigmaPionKaonTPC", "Nsigma Pion Kaon TPC correlation", kTH2F, {{100, -5.0f, 5.0f}, {100, -5.0f, 5.0f}}); histos.add("h2SameEventPtCorrelation", "Pt correlation of F1 and proton", kTH3F, {{100, 0.0f, 1.0f}, {100, 0.0, 10.0}, {100, 0.0, 10.0}}); - histos.add("h2SameEventInvariantMassUnlike_mass", "Unlike Sign Invariant mass of f1 same event", kTH3F, {{100, 0.0f, 1.0f}, {100, 0.0, 10.0}, {800, 1.0, 1.8}}); - histos.add("h2SameEventInvariantMassLike_mass", "Like Sign Invariant mass of f1 same event", kTH3F, {{100, 0.0f, 1.0f}, {100, 0.0, 10.0}, {800, 1.0, 1.8}}); - histos.add("h2SameEventInvariantMassRot_mass", "Rotational Invariant mass of f1 same event", kTH3F, {{100, 0.0f, 1.0f}, {100, 0.0, 10.0}, {800, 1.0, 1.8}}); + histos.add("h2SameEventInvariantMassUnlike_mass", "Unlike Sign Invariant mass of f1 same event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); + histos.add("h2SameEventInvariantMassLike_mass", "Like Sign Invariant mass of f1 same event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); + histos.add("h2SameEventInvariantMassRot_mass", "Rotational Invariant mass of f1 same event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); - histos.add("h2MixEventInvariantMassUnlike_mass", "Unlike Sign Invariant mass of f1 mix event", kTH3F, {{100, 0.0f, 1.0f}, {100, 0.0, 10.0}, {800, 1.0, 1.8}}); - histos.add("h2MixEventInvariantMassLike_mass", "Like Sign Invariant mass of f1 mix event", kTH3F, {{100, 0.0f, 1.0f}, {100, 0.0, 10.0}, {800, 1.0, 1.8}}); - histos.add("h2MixEventInvariantMassRot_mass", "Rotational Sign Invariant mass of f1 mix event", kTH3F, {{100, 0.0f, 1.0f}, {100, 0.0, 10.0}, {800, 1.0, 1.8}}); + histos.add("h2MixEventInvariantMassUnlike_mass", "Unlike Sign Invariant mass of f1 mix event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); + histos.add("h2MixEventInvariantMassLike_mass", "Like Sign Invariant mass of f1 mix event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); + histos.add("h2MixEventInvariantMassRot_mass", "Rotational Sign Invariant mass of f1 mix event", kTH3F, {thnAxisKstar, thnAxisPt, thnAxisInvMass}); - const AxisSpec thnAxisInvMass{configThnAxisInvMass, "#it{M} (GeV/#it{c}^{2})"}; - const AxisSpec thnAxisPt{configThnAxisPt, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec thnAxisPtProton{configThnAxisPtProton, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec thnAxisKstar{configThnAxisKstar, "#it{k}^{*} (GeV/#it{c})"}; - const AxisSpec thnAxisNsigma{configThnAxisNsigma, "NsigmaCombined"}; if (fillSparse) { histos.add("SEMassUnlike", "SEMassUnlike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma}); histos.add("SEMassLike", "SEMassLike", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisPtProton, thnAxisKstar, thnAxisNsigma}); diff --git a/PWGLF/Tasks/Resonances/heptaquark.cxx b/PWGLF/Tasks/Resonances/heptaquark.cxx new file mode 100644 index 00000000000..407c3199073 --- /dev/null +++ b/PWGLF/Tasks/Resonances/heptaquark.cxx @@ -0,0 +1,358 @@ +// 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. +/// +/// \brief this is a starting point for the Resonances tutorial +/// \author junlee kim + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/StepTHn.h" +#include "Common/Core/trackUtilities.h" +#include "PWGLF/DataModel/ReducedHeptaQuarkTables.h" +#include "CommonConstants/PhysicsConstants.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct heptaquark { + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable cfgRotBkg{"cfgRotBkg", true, "flag to construct rotational backgrounds"}; + Configurable cfgNRotBkg{"cfgNRotBkg", 10, "the number of rotational backgrounds"}; + + Configurable cfgPIDStrategy{"cfgPIDStrategy", 3, "PID strategy 1"}; + Configurable cfgPIDPrPi{"cfgPIDPrPi", 3, "PID selection for proton and pion"}; + + Configurable minPhiMass{"minPhiMass", 1.01, "Minimum phi mass"}; + Configurable maxPhiMass{"maxPhiMass", 1.03, "Maximum phi mass"}; + + Configurable minLambdaMass{"minLambdaMass", 1.1, "Minimum lambda mass"}; + Configurable maxLambdaMass{"maxLambdaMass", 1.13, "Maximum lambda mass"}; + + Configurable cutNsigmaTPC{"cutNsigmaTPC", 2.5, "nsigma cut TPC"}; + Configurable cutNsigmaTOF{"cutNsigmaTOF", 3.0, "nsigma cut TOF"}; + + ConfigurableAxis massAxis{"massAxis", {600, 2.8, 3.4}, "Invariant mass axis"}; + ConfigurableAxis ptAxis{"ptAxis", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "Transverse momentum bins"}; + ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0, 20, 50, 100}, "Centrality interval"}; + ConfigurableAxis massPPAxis{"massPPAxis", {100, 3.0, 8.0}, "Mass square of phi phi"}; + ConfigurableAxis massPLAxis{"massPLAxis", {100, 3.0, 8.0}, "Mass square of phi lambda"}; + + void init(o2::framework::InitContext&) + { + histos.add("hnsigmaTPCPi", "hnsigmaTPCPi", kTH2F, {{1000, -7.0, 7.0f}, {100, 0.0f, 10.0f}}); + + histos.add("hnsigmaTPCKa", "hnsigmaTPCKa", kTH2F, {{1000, -7.0, 7.0f}, {100, 0.0f, 10.0f}}); + histos.add("hnsigmaTOFKa", "hnsigmaTOFKa", kTH2F, {{1000, -7.0, 7.0f}, {100, 0.0f, 10.0f}}); + + histos.add("hnsigmaTPCPr", "hnsigmaTPCPr", kTH2F, {{1000, -7.0, 7.0f}, {100, 0.0f, 10.0f}}); + + histos.add("hPhid1Mass", "hPhid1Mass", kTH2F, {{40, 1.0, 1.04f}, {100, 0.0f, 10.0f}}); + histos.add("hPhid2Mass", "hPhid2Mass", kTH2F, {{40, 1.0, 1.04f}, {100, 0.0f, 10.0f}}); + histos.add("hLambdaMass", "hLambdaMass", kTH2F, {{140, 1.095, 1.135}, {100, 0.0f, 10.0f}}); + + histos.add("h_InvMass_same", "h_InvMass_same", {HistType::kTH3F, {massAxis, ptAxis, centAxis}}); + histos.add("h_InvMass_rotPhi", "h_InvMass_rotPhi", {HistType::kTH3F, {massAxis, ptAxis, centAxis}}); + histos.add("h_InvMass_rotLambda", "h_InvMass_rotLambda", {HistType::kTH3F, {massAxis, ptAxis, centAxis}}); + histos.add("h_InvMass_rotPhiLambda", "h_InvMass_rotPhiLambda", {HistType::kTH3F, {massAxis, ptAxis, centAxis}}); + + histos.add("hDalitz", "hDalitz", {HistType::kTHnSparseF, {massPPAxis, massPLAxis, massAxis, ptAxis, {2, -0.5f, 1.5f}, centAxis}}); + histos.add("hDalitzRot", "hDalitzRot", {HistType::kTHnSparseF, {massPPAxis, massPLAxis, massAxis, ptAxis, {2, -0.5f, 1.5f}, centAxis}}); + } + + double massLambda = o2::constants::physics::MassLambda; + double massPr = o2::constants::physics::MassProton; + double massPi = o2::constants::physics::MassPionCharged; + double massKa = o2::constants::physics::MassKPlus; + + TRandom* rn = new TRandom(); + + bool selectionPIDKaon(float nsigmaTPC, float nsigmaTOF, int TOFHit, int PIDStrategy, float ptcand) + { + if (PIDStrategy == 0) { + if (TOFHit != 1) { + if (TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + return true; + } + } + if (TOFHit == 1) { + if (TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + return true; + } + } + } + if (PIDStrategy == 1) { + if (ptcand < 0.5) { + if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + return true; + } + if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + return true; + } + } + if (ptcand >= 0.5) { + if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + return true; + } + } + } + if (PIDStrategy == 2) { + if (ptcand < 0.5) { + if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + return true; + } + if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + return true; + } + } + if (ptcand >= 0.5 && ptcand < 1.2) { + if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + return true; + } + if (TOFHit != 1 && nsigmaTPC > -1.5 && nsigmaTPC < cutNsigmaTPC) { + return true; + } + } + if (ptcand >= 1.2) { + if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + return true; + } + if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + return true; + } + } + } + if (PIDStrategy == 3) { + if (ptcand < 0.5) { + if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + return true; + } + if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + return true; + } + } + if (ptcand >= 0.5 && ptcand < 1.2) { + if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + return true; + } + } + if (ptcand >= 1.2) { + if (TOFHit == 1 && TMath::Abs(nsigmaTOF) < cutNsigmaTOF) { + return true; + } + if (TOFHit != 1 && TMath::Abs(nsigmaTPC) < cutNsigmaTPC) { + return true; + } + } + } + return false; + } + + template + ROOT::Math::XYZVector getDCAofV0V0(V01 const& v01, V02 const& v02) + { + ROOT::Math::XYZVector v01pos, v02pos, v01mom, v02mom; + v01pos.SetXYZ(v01.x(), v01.y(), v01.z()); + v02pos.SetXYZ(v02.x(), v02.y(), v02.z()); + v01mom.SetXYZ(v01.px(), v01.py(), v01.pz()); + v02mom.SetXYZ(v02.px(), v02.py(), v02.pz()); + + ROOT::Math::XYZVector posdiff = v02pos - v01pos; + ROOT::Math::XYZVector cross = v01mom.Cross(v02mom); + ROOT::Math::XYZVector dcaVec = (posdiff.Dot(cross) / cross.Mag2()) * cross; + return dcaVec; + } + + template + float getCPA(V01 const& v01, V02 const& v02) + { + ROOT::Math::XYZVector v01mom, v02mom; + v01mom.SetXYZ(v01.px() / v01.p(), v01.py() / v01.p(), v01.pz() / v01.p()); + v02mom.SetXYZ(v02.px() / v02.p(), v02.py() / v02.p(), v02.pz() / v02.p()); + return v01mom.Dot(v02mom); + } + + ROOT::Math::PxPyPzMVector DauVec1, DauVec2; + + TLorentzVector exotic, HQ1, HQ2, HQ3; + TLorentzVector exoticRot2, HQ2Rot; + TLorentzVector exoticRot3, HQ3Rot; + TLorentzVector exoticRot23; + TLorentzVector HQ12, HQ13; + TLorentzVector HQ12Rot, HQ13Rot; + + void processSameEvent(aod::RedHQEvents::iterator const& collision, aod::HQTracks const& hqtracks) + { + if (collision.numLambda() < 1 || collision.numPhi() < 2) + return; + + for (auto hqtrackd1 : hqtracks) { + if (hqtrackd1.hqId() != 333) + continue; + + if (hqtrackd1.hqMass() < minPhiMass || hqtrackd1.hqMass() > maxPhiMass) + continue; + + DauVec1 = ROOT::Math::PxPyPzMVector(hqtrackd1.hqd1Px(), hqtrackd1.hqd1Py(), hqtrackd1.hqd1Pz(), massKa); + DauVec2 = ROOT::Math::PxPyPzMVector(hqtrackd1.hqd2Px(), hqtrackd1.hqd2Py(), hqtrackd1.hqd2Pz(), massKa); + + if (!selectionPIDKaon(hqtrackd1.hqd1TPC(), hqtrackd1.hqd1TOF(), hqtrackd1.hqd1TOFHit(), cfgPIDStrategy, DauVec1.Pt())) + continue; + + if (!selectionPIDKaon(hqtrackd1.hqd2TPC(), hqtrackd1.hqd2TOF(), hqtrackd1.hqd2TOFHit(), cfgPIDStrategy, DauVec2.Pt())) + continue; + + HQ1.SetXYZM(hqtrackd1.hqPx(), hqtrackd1.hqPy(), hqtrackd1.hqPz(), hqtrackd1.hqMass()); + + histos.fill(HIST("hnsigmaTPCKa"), hqtrackd1.hqd1TPC(), DauVec1.Pt()); + histos.fill(HIST("hnsigmaTPCKa"), hqtrackd1.hqd2TPC(), DauVec2.Pt()); + if (hqtrackd1.hqd1TOFHit()) + histos.fill(HIST("hnsigmaTOFKa"), hqtrackd1.hqd1TOF(), DauVec1.Pt()); + if (hqtrackd1.hqd2TOFHit()) + histos.fill(HIST("hnsigmaTOFKa"), hqtrackd1.hqd2TOF(), DauVec2.Pt()); + + auto hqd1id = hqtrackd1.index(); + histos.fill(HIST("hPhid1Mass"), HQ1.M(), HQ1.Pt()); + + for (auto hqtrackd2 : hqtracks) { + auto hqd2id = hqtrackd2.index(); + if (hqd2id <= hqd1id) + continue; + + if (hqtrackd2.hqId() != 333) + continue; + + if (hqtrackd2.hqMass() < minPhiMass || hqtrackd2.hqMass() > maxPhiMass) + continue; + + DauVec1 = ROOT::Math::PxPyPzMVector(hqtrackd2.hqd1Px(), hqtrackd2.hqd1Py(), hqtrackd2.hqd1Pz(), massKa); + DauVec2 = ROOT::Math::PxPyPzMVector(hqtrackd2.hqd2Px(), hqtrackd2.hqd2Py(), hqtrackd2.hqd2Pz(), massKa); + + if (!selectionPIDKaon(hqtrackd2.hqd1TPC(), hqtrackd2.hqd1TOF(), hqtrackd2.hqd1TOFHit(), cfgPIDStrategy, DauVec1.Pt())) + continue; + + if (!selectionPIDKaon(hqtrackd2.hqd2TPC(), hqtrackd2.hqd2TOF(), hqtrackd2.hqd2TOFHit(), cfgPIDStrategy, DauVec2.Pt())) + continue; + + if (hqtrackd1.hqd1Index() == hqtrackd2.hqd1Index()) + continue; + + if (hqtrackd1.hqd2Index() == hqtrackd2.hqd2Index()) + continue; + + HQ2.SetXYZM(hqtrackd2.hqPx(), hqtrackd2.hqPy(), hqtrackd2.hqPz(), hqtrackd2.hqMass()); + + histos.fill(HIST("hnsigmaTPCKa"), hqtrackd2.hqd1TPC(), DauVec1.Pt()); + histos.fill(HIST("hnsigmaTPCKa"), hqtrackd2.hqd2TPC(), DauVec2.Pt()); + if (hqtrackd2.hqd1TOFHit()) + histos.fill(HIST("hnsigmaTOFKa"), hqtrackd2.hqd1TOF(), DauVec1.Pt()); + if (hqtrackd2.hqd2TOFHit()) + histos.fill(HIST("hnsigmaTOFKa"), hqtrackd2.hqd2TOF(), DauVec2.Pt()); + histos.fill(HIST("hPhid2Mass"), HQ2.M(), HQ2.Pt()); + + for (auto hqtrackd3 : hqtracks) { + if (std::abs(hqtrackd3.hqId()) != 3122) + continue; + + if (hqtrackd3.hqMass() < minLambdaMass || hqtrackd3.hqMass() > maxLambdaMass) + continue; + + int isLambda = static_cast(hqtrackd3.hqId() < 0); + + if (hqtrackd3.hqId() > 0) { + DauVec1 = ROOT::Math::PxPyPzMVector(hqtrackd3.hqd1Px(), hqtrackd3.hqd1Py(), hqtrackd3.hqd1Pz(), massPr); + DauVec2 = ROOT::Math::PxPyPzMVector(hqtrackd3.hqd2Px(), hqtrackd3.hqd2Py(), hqtrackd3.hqd2Pz(), massPi); + } else if (hqtrackd3.hqId() < 0) { + DauVec1 = ROOT::Math::PxPyPzMVector(hqtrackd3.hqd1Px(), hqtrackd3.hqd1Py(), hqtrackd3.hqd1Pz(), massPi); + DauVec2 = ROOT::Math::PxPyPzMVector(hqtrackd3.hqd2Px(), hqtrackd3.hqd2Py(), hqtrackd3.hqd2Pz(), massPr); + } + + if (std::abs(hqtrackd3.hqd1TPC()) > cfgPIDPrPi || std::abs(hqtrackd3.hqd2TPC()) > cfgPIDPrPi) + continue; + + if (hqtrackd1.hqd1Index() == hqtrackd3.hqd1Index()) + continue; + + if (hqtrackd1.hqd2Index() == hqtrackd3.hqd2Index()) + continue; + + if (hqtrackd2.hqd1Index() == hqtrackd3.hqd1Index()) + continue; + + if (hqtrackd2.hqd2Index() == hqtrackd3.hqd2Index()) + continue; + + HQ3.SetXYZM(hqtrackd3.hqPx(), hqtrackd3.hqPy(), hqtrackd3.hqPz(), hqtrackd3.hqMass()); + histos.fill(HIST("hLambdaMass"), HQ3.M(), HQ3.Pt()); + + if (hqtrackd3.hqId() > 0) { + histos.fill(HIST("hnsigmaTPCPr"), hqtrackd3.hqd1TPC(), DauVec1.Pt()); + histos.fill(HIST("hnsigmaTPCPi"), hqtrackd3.hqd2TPC(), DauVec2.Pt()); + } else if (hqtrackd3.hqId() < 0) { + histos.fill(HIST("hnsigmaTPCPi"), hqtrackd3.hqd1TPC(), DauVec1.Pt()); + histos.fill(HIST("hnsigmaTPCPr"), hqtrackd3.hqd2TPC(), DauVec2.Pt()); + } + + exotic = HQ1 + HQ2 + HQ3; + HQ12 = HQ1 + HQ2; + HQ13 = HQ1 + HQ3; + + histos.fill(HIST("h_InvMass_same"), exotic.M(), exotic.Pt(), collision.centrality()); + histos.fill(HIST("hDalitz"), HQ12.M2(), HQ13.M2(), exotic.M(), exotic.Pt(), isLambda, collision.centrality()); + + if (cfgRotBkg) { + for (int nr = 0; nr < cfgNRotBkg; nr++) { + auto RanPhiForD2 = rn->Uniform(o2::constants::math::PI * 5.0 / 6.0, o2::constants::math::PI * 7.0 / 6.0); + auto RanPhiForD3 = rn->Uniform(o2::constants::math::PI * 5.0 / 6.0, o2::constants::math::PI * 7.0 / 6.0); + + RanPhiForD2 += HQ2.Phi(); + RanPhiForD3 += HQ3.Phi(); + + HQ2Rot.SetXYZM(HQ2.Pt() * std::cos(RanPhiForD2), HQ2.Pt() * std::sin(RanPhiForD2), HQ2.Pz(), HQ2.M()); + HQ3Rot.SetXYZM(HQ3.Pt() * std::cos(RanPhiForD3), HQ3.Pt() * std::sin(RanPhiForD3), HQ3.Pz(), HQ3.M()); + + exoticRot2 = HQ1 + HQ2Rot + HQ3; + exoticRot3 = HQ1 + HQ2 + HQ3Rot; + exoticRot23 = HQ1 + HQ2Rot + HQ3Rot; + + HQ12Rot = HQ1 + HQ2Rot; + HQ13Rot = HQ1 + HQ3Rot; + + histos.fill(HIST("h_InvMass_rotPhi"), exoticRot2.M(), exoticRot2.Pt(), collision.centrality()); + histos.fill(HIST("h_InvMass_rotLambda"), exoticRot3.M(), exoticRot3.Pt(), collision.centrality()); + histos.fill(HIST("h_InvMass_rotPhiLambda"), exoticRot23.M(), exoticRot23.Pt(), collision.centrality()); + histos.fill(HIST("hDalitzRot"), HQ12Rot.M2(), HQ13Rot.M2(), exoticRot23.M(), exoticRot23.Pt(), isLambda, collision.centrality()); + } + } + } + } + } + } + PROCESS_SWITCH(heptaquark, processSameEvent, "Process same event", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Resonances/higherMassResonances.cxx b/PWGLF/Tasks/Resonances/higherMassResonances.cxx index f6de828ef46..3a34c13fad2 100644 --- a/PWGLF/Tasks/Resonances/higherMassResonances.cxx +++ b/PWGLF/Tasks/Resonances/higherMassResonances.cxx @@ -14,47 +14,51 @@ /// \author Sawan // #include +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" // + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" // +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" // +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" // +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" // +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TRandom3.h" #include #include #include #include #include -#include #include #include #include + +#include #include #include #include +#include #include -#include -#include "TF1.h" -#include "TRandom3.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" - -#include "Common/Core/TrackSelection.h" -#include "Common/Core/trackUtilities.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/StepTHn.h" -#include "ReconstructionDataFormats/Track.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/EventSelection.h" // -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" // -#include "Common/DataModel/TrackSelectionTables.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/AnalysisTask.h" // -#include "Framework/runDataProcessing.h" // -#include "PWGLF/DataModel/LFStrangenessTables.h" // using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; +using namespace o2::aod::rctsel; // using namespace o2::constants::physics; using std::array; @@ -65,174 +69,204 @@ struct HigherMassResonances { HistogramRegistry hglue{"hglueball", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry hMChists{"hMChists", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - // PID and QA - Configurable qAv0{"qAv0", false, "qAv0"}; - Configurable qAPID{"qAPID", true, "qAPID"}; - Configurable qAv0Daughters{"qAv0Daughters", false, "QA of v0 daughters"}; - Configurable qAevents{"qAevents", false, "QA of events"}; - Configurable invMass1D{"invMass1D", false, "1D invariant mass histograms"}; - Configurable correlation2Dhist{"correlation2Dhist", true, "Lamda K0 mass correlation"}; - Configurable cDCAv0topv{"cDCAv0topv", false, "DCA V0 to PV"}; - Configurable armcut{"armcut", true, "arm cut"}; - Configurable globalTracks{"globalTracks", false, "Global tracks"}; - Configurable hasTPC{"hasTPC", false, "TPC"}; - - // Configurable for event selection - Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; - Configurable cfgETAcut{"cfgETAcut", 0.8f, "Track ETA cut"}; - Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; - Configurable piluprejection{"piluprejection", false, "Pileup rejection"}; - Configurable goodzvertex{"goodzvertex", false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference."}; - Configurable itstpctracks{"itstpctracks", false, "selects collisions with at least one ITS-TPC track,"}; - Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; - Configurable applyOccupancyCut{"applyOccupancyCut", false, "Apply occupancy cut"}; - Configurable occupancyCut{"occupancyCut", 1000, "Mimimum Occupancy cut"}; - - // Configurable parameters for V0 selection - Configurable confV0DCADaughMax{"confV0DCADaughMax", 1.0f, "DCA b/w V0 daughters"}; - Configurable v0settingDcapostopv{"v0settingDcapostopv", 0.06, "DCA Pos To PV"}; - Configurable v0settingDcanegtopv{"v0settingDcanegtopv", 0.06, "DCA Neg To PV"}; - Configurable cMaxV0DCA{"cMaxV0DCA", 1, "DCA V0 to PV"}; - // Configurable isStandarv0{"isStandarv0", false, "Standard V0"}; - // Configurable ConfDaughDCAMin{"ConfDaughDCAMin", 0.06f, "V0 Daugh sel: Max. DCA Daugh to PV (cm)"}; // same as DCA pos to pv and neg to pv - Configurable confV0PtMin{"confV0PtMin", 0.f, "Minimum transverse momentum of V0"}; - Configurable confV0CPAMin{"confV0CPAMin", 0.97f, "Minimum CPA of V0"}; - Configurable confV0TranRadV0Min{"confV0TranRadV0Min", 0.5f, "Minimum transverse radius"}; - Configurable confV0TranRadV0Max{"confV0TranRadV0Max", 200.f, "Maximum transverse radius"}; - Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 15, "Maximum V0 life time"}; - Configurable cSigmaMassKs0{"cSigmaMassKs0", 4, "n Sigma cut on Ks0 mass (Mass (Ks) - cSigmaMassKs0*cWidthKs0)"}; - Configurable cWidthKs0{"cWidthKs0", 0.005, "Width of KS0"}; - Configurable confDaughEta{"confDaughEta", 0.8f, "V0 Daugh sel: max eta"}; - Configurable confDaughTPCnclsMin{"confDaughTPCnclsMin", 70.f, "V0 Daugh sel: Min. nCls TPC"}; - Configurable confDaughPIDCuts{"confDaughPIDCuts", 5, "PID selections for KS0 daughters"}; - Configurable confarmcut{"confarmcut", 0.2f, "Armenteros cut"}; - Configurable confKsrapidity{"confKsrapidity", 0.5f, "Rapidity cut on K0s"}; - // Configurable lowmasscutks0{"lowmasscutks0", 0.497 - 4 * 0.005, "Low mass cut on K0s"}; - // Configurable highmasscutks0{"highmasscutks0", 0.497 + 4 * 0.005, "High mass cut on K0s"}; - - // Configurable for track selection and multiplicity - Configurable cfgPTcut{"cfgPTcut", 0.2f, "Track PT cut"}; - Configurable cfgNmixedEvents{"cfgNmixedEvents", 5, "Number of mixed events"}; - Configurable cfgMultFOTM{"cfgMultFOTM", true, "Use FOTM multiplicity if pp else use 0 here for PbPb (FT0C)"}; - ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0., 5., 10., 30., 50., 70., 100., 110., 150.}, "Binning of the centrality axis"}; - - // Configurable for MC - Configurable allGenCollisions{"allGenCollisions", true, "To fill all generated collisions for the signal loss calculations"}; - Configurable cTVXEvsel{"cTVXEvsel", true, "Triggger selection"}; - - // output THnSparses - Configurable activateTHnSparseCosThStarHelicity{"activateTHnSparseCosThStarHelicity", false, "Activate the THnSparse with cosThStar w.r.t. helicity axis"}; - Configurable activateTHnSparseCosThStarProduction{"activateTHnSparseCosThStarProduction", false, "Activate the THnSparse with cosThStar w.r.t. production axis"}; - Configurable activateTHnSparseCosThStarBeam{"activateTHnSparseCosThStarBeam", true, "Activate the THnSparse with cosThStar w.r.t. beam axis (Gottified jackson frame)"}; - Configurable activateTHnSparseCosThStarRandom{"activateTHnSparseCosThStarRandom", false, "Activate the THnSparse with cosThStar w.r.t. random axis"}; - Configurable cRrotations{"cRrotations", 3, "Number of random rotations in the rotational background"}; - - // Other cuts on Ks and glueball - Configurable rapidityks{"rapidityks", true, "rapidity cut on K0s"}; - Configurable applyCompetingcut{"applyCompetingcut", false, "Competing cascade rejection cut"}; - Configurable competingcascrejlambda{"competingcascrejlambda", 0.005, "rejecting competing cascade lambda"}; - Configurable competingcascrejlambdaanti{"competingcascrejlambdaanti", 0.005, "rejecting competing cascade anti-lambda"}; // If one of the pions is misidentified as a proton, then instead of Ks we reconstruct lambda, therefore the competing cascade rejection cut is applied in which if the reconstrcted mass of a pion and proton (which we are assuming to be misidentified as proton) is close to lambda or anti-lambda, then the track is rejected. - Configurable tpcCrossedrows{"tpcCrossedrows", 70, "TPC crossed rows"}; - Configurable tpcCrossedrowsOverfcls{"tpcCrossedrowsOverfcls", 0.8, "TPC crossed rows over findable clusters"}; - - // Mass and pT axis as configurables - Configurable cPtMin{"cPtMin", 0.0f, "Minimum pT"}; - Configurable cPtMax{"cPtMax", 30.0f, "Maximum pT"}; - Configurable cPtBins{"cPtBins", 300, "Number of pT bins"}; - Configurable cMassMin{"cMassMin", 0.9f, "Minimum mass of glueball"}; - Configurable cMassMax{"cMassMax", 3.0f, "Maximum mass of glueball"}; - Configurable cMassBins{"cMassBins", 210, "Number of mass bins for glueball"}; - Configurable ksMassMin{"ksMassMin", 0.45f, "Minimum mass of K0s"}; - Configurable ksMassMax{"ksMassMax", 0.55f, "Maximum mass of K0s"}; - Configurable ksMassBins{"ksMassBins", 200, "Number of mass bins for K0s"}; - Configurable rotationalCut{"rotationalCut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; - ConfigurableAxis configThnAxisPOL{"configThnAxisPOL", {20, -1.0, 1.0}, "Costheta axis"}; - ConfigurableAxis axisdEdx{"axisdEdx", {20000, 0.0f, 200.0f}, "dE/dx (a.u.)"}; - ConfigurableAxis axisPtfordEbydx{"axisPtfordEbydx", {2000, 0, 20}, "pT (GeV/c)"}; - ConfigurableAxis axisMultdist{"axisMultdist", {3500, 0, 70000}, "Multiplicity distribution"}; - ConfigurableAxis occupancyBins{"occupancyBins", {VARIABLE_WIDTH, 0.0, 100, 500, 600, 1000, 1100, 1500, 1600, 2000, 2100, 2500, 2600, 3000, 3100, 3500, 3600, 4000, 4100, 4500, 4600, 5000, 5100, 9999}, "Binning: occupancy axis"}; - - // Event selection cuts - Alex (Temporary, need to fix!) - TF1* fMultPVCutLow = nullptr; - TF1* fMultPVCutHigh = nullptr; - TF1* fMultCutLow = nullptr; - TF1* fMultCutHigh = nullptr; - TF1* fMultMultPVCut = nullptr; + struct RCTCut : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + + RCTFlagsChecker rctChecker; + }; + RCTCut rctCut; + + struct : ConfigurableGroup { + // PID and QA + Configurable qAv0{"qAv0", false, "qAv0"}; + Configurable qAPID{"qAPID", true, "qAPID"}; + // Configurable qAv0Daughters{"qAv0Daughters", false, "QA of v0 daughters"}; + Configurable qAevents{"qAevents", false, "QA of events"}; + // Configurable invMass1D{"invMass1D", false, "1D invariant mass histograms"}; + Configurable correlation2Dhist{"correlation2Dhist", true, "Lamda K0 mass correlation"}; + Configurable cDCAv0topv{"cDCAv0topv", false, "DCA V0 to PV"}; + // Configurable armcut{"armcut", false, "arm cut"}; + Configurable globalTracks{"globalTracks", false, "Global tracks"}; + Configurable hasTPC{"hasTPC", false, "TPC"}; + Configurable selectTWOKsOnly{"selectTWOKsOnly", true, "Select only events with two K0s"}; + Configurable applyPairRapidityRec{"applyPairRapidityRec", false, "Apply pair rapidity cut on reconstructed mother (after already applying rapidity cut on generated mother)"}; + Configurable applyPairRapidityGen{"applyPairRapidityGen", false, "Apply pair rapidity cut on generated mother (before applying rapidity cut on reconstructed mother)"}; + + // Configurables for event selection + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable cfgETAcut{"cfgETAcut", 0.8f, "Track ETA cut"}; + Configurable timFrameEvsel{"timFrameEvsel", true, "TPC Time frame boundary cut"}; + // Configurable piluprejection{"piluprejection", false, "Pileup rejection"}; + // Configurable goodzvertex{"goodzvertex", false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference."}; + // Configurable itstpctracks{"itstpctracks", false, "selects collisions with at least one ITS-TPC track,"}; + // Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; + // Configurable applyOccupancyCut{"applyOccupancyCut", false, "Apply occupancy cut"}; + // Configurable occupancyCut{"occupancyCut", 1000, "Mimimum Occupancy cut"}; + + // Configurable parameters for V0 selection + Configurable confV0DCADaughMax{"confV0DCADaughMax", 1.0f, "DCA b/w V0 daughters"}; + Configurable v0settingDcapostopv{"v0settingDcapostopv", 0.06, "DCA Pos To PV"}; + Configurable v0settingDcanegtopv{"v0settingDcanegtopv", 0.06, "DCA Neg To PV"}; + Configurable cMaxV0DCA{"cMaxV0DCA", 1, "DCA V0 to PV"}; + // Configurable isStandarv0{"isStandarv0", false, "Standard V0"}; + // Configurable ConfDaughDCAMin{"ConfDaughDCAMin", 0.06f, "V0 Daugh sel: Max. DCA Daugh to PV (cm)"}; // same as DCA pos to pv and neg to pv + Configurable confV0PtMin{"confV0PtMin", 0.f, "Minimum transverse momentum of V0"}; + Configurable confV0CPAMin{"confV0CPAMin", 0.97f, "Minimum CPA of V0"}; + Configurable confV0TranRadV0Min{"confV0TranRadV0Min", 0.5f, "Minimum transverse radius"}; + Configurable confV0TranRadV0Max{"confV0TranRadV0Max", 200.f, "Maximum transverse radius"}; + Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 15, "Maximum V0 life time"}; + Configurable cSigmaMassKs0{"cSigmaMassKs0", 4, "n Sigma cut on Ks0 mass (Mass (Ks) - cSigmaMassKs0*cWidthKs0)"}; + Configurable cWidthKs0{"cWidthKs0", 0.005, "Width of KS0"}; + Configurable confDaughEta{"confDaughEta", 0.8f, "V0 Daugh sel: max eta"}; + Configurable confDaughTPCnclsMin{"confDaughTPCnclsMin", 70.f, "V0 Daugh sel: Min. nCls TPC"}; + Configurable confDaughPIDCuts{"confDaughPIDCuts", 5, "PID selections for KS0 daughters"}; + // Configurable confarmcut{"confarmcut", 0.2f, "Armenteros cut"}; + Configurable confKsrapidity{"confKsrapidity", 0.5f, "Rapidity cut on K0s"}; + // Configurable lowmasscutks0{"lowmasscutks0", 0.497 - 4 * 0.005, "Low mass cut on K0s"}; + // Configurable highmasscutks0{"highmasscutks0", 0.497 + 4 * 0.005, "High mass cut on K0s"}; + Configurable applyAngSepCut{"applyAngSepCut", false, "Apply angular separation cut"}; + Configurable angSepCut{"angSepCut", 0.01f, "Angular separation cut"}; + + // Configurable for track selection and multiplicity + Configurable cfgPTcut{"cfgPTcut", 0.2f, "Track PT cut"}; + Configurable cfgNmixedEvents{"cfgNmixedEvents", 5, "Number of mixed events"}; + Configurable cfgMultFOTM{"cfgMultFOTM", true, "Use FOTM multiplicity if pp else use 0 here for PbPb (FT0C)"}; + ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0., 5., 10., 30., 50., 70., 100., 110., 150.}, "Binning of the centrality axis"}; + + // Configurable for MC + Configurable isMC{"isMC", false, "Is MC"}; + Configurable allGenCollisions{"allGenCollisions", true, "To fill all generated collisions for the signal loss calculations"}; + Configurable cTVXEvsel{"cTVXEvsel", true, "Triggger selection"}; + Configurable avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"}; + Configurable selectMCparticles{"selectMCparticles", 1, "0: f0(1710), 1: f2(1525), 2: a2(1320), 3: f0(1370), 4: f0(1500)"}; + Configurable applyRapidityMC{"applyRapidityMC", true, "Apply rapidity cut on generated and reconstructed particles"}; + std::vector pdgCodes = {10331, 335, 115, 10221, 9030221}; + + // output THnSparses + Configurable activateTHnSparseCosThStarHelicity{"activateTHnSparseCosThStarHelicity", false, "Activate the THnSparse with cosThStar w.r.t. helicity axis"}; + Configurable activateTHnSparseCosThStarProduction{"activateTHnSparseCosThStarProduction", false, "Activate the THnSparse with cosThStar w.r.t. production axis"}; + Configurable activateTHnSparseCosThStarBeam{"activateTHnSparseCosThStarBeam", true, "Activate the THnSparse with cosThStar w.r.t. beam axis (Gottified jackson frame)"}; + Configurable activateTHnSparseCosThStarRandom{"activateTHnSparseCosThStarRandom", false, "Activate the THnSparse with cosThStar w.r.t. random axis"}; + Configurable cRotations{"cRotations", 3, "Number of random rotations in the rotational background"}; + + // Other cuts on Ks and glueball + // Configurable rapidityks{"rapidityks", true, "rapidity cut on K0s"}; + Configurable applyCompetingcut{"applyCompetingcut", false, "Competing cascade rejection cut"}; + Configurable competingcascrejlambda{"competingcascrejlambda", 0.005, "rejecting competing cascade lambda"}; + // Configurable competingcascrejlambdaanti{"competingcascrejlambdaanti", 0.005, "rejecting competing cascade anti-lambda"}; // If one of the pions is misidentified as a proton, then instead of Ks we reconstruct lambda, therefore the competing cascade rejection cut is applied in which if the reconstrcted mass of a pion and proton (which we are assuming to be misidentified as proton) is close to lambda or anti-lambda, then the track is rejected + Configurable tpcCrossedrows{"tpcCrossedrows", 70, "TPC crossed rows"}; + Configurable tpcCrossedrowsOverfcls{"tpcCrossedrowsOverfcls", 0.8, "TPC crossed rows over findable clusters"}; + + // // Mass and pT axis as configurables + Configurable rotationalCut{"rotationalCut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; + ConfigurableAxis configThnAxisPOL{"configThnAxisPOL", {20, -1.0, 1.0}, "Costheta axis"}; + ConfigurableAxis configThnAxisPhi{"configThnAxisPhi", {70, 0.0f, 7.0f}, "Phi axis"}; // 0 to 2pi + ConfigurableAxis ksMassBins{"ksMassBins", {200, 0.45f, 0.55f}, "K0s invariant mass axis"}; + ConfigurableAxis cGlueMassBins{"cGlueMassBins", {200, 0.9f, 3.0f}, "Glueball invariant mass axis"}; + ConfigurableAxis cPtBins{"cPtBins", {200, 0.0f, 20.0f}, "Glueball pT axis"}; + // ConfigurableAxis axisdEdx{"axisdEdx", {20000, 0.0f, 200.0f}, "dE/dx (a.u.)"}; + // ConfigurableAxis axisPtfordEbydx{"axisPtfordEbydx", {2000, 0, 20}, "pT (GeV/c)"}; + // ConfigurableAxis axisMultdist{"axisMultdist", {3500, 0, 70000}, "Multiplicity distribution"}; + + // fixed variables + float rapidityMotherData = 0.5; + float beamEnergy = 13600.0; + double beamMomentum = std::sqrt(beamEnergy * beamEnergy / 4 - o2::constants::physics::MassProton * o2::constants::physics::MassProton); // GeV + int noOfDaughters = 2; + } config; + // Service PDGdatabase; TRandom* rn = new TRandom(); + // variables declaration + float multiplicity = 0.0f; + float theta2; + ROOT::Math::PxPyPzMVector daughter1, daughter2, daughterRot, daughterRotCM, mother, motherRot, fourVecDauCM, fourVecDauCM1; + ROOT::Math::PxPyPzEVector mother1; + ROOT::Math::XYZVector randomVec, beamVec, normalVec; + ROOT::Math::XYZVectorF v1CM, zaxisHE, yaxisHE, xaxisHE; + // ROOT::Math::XYZVector threeVecDauCM, helicityVec, randomVec, beamVec, normalVec; + ROOT::Math::XYZVector zBeam; // ẑ: beam direction in lab frame + ROOT::Math::PxPyPzEVector beam1{0., 0., -config.beamMomentum, 13600. / 2.}; + ROOT::Math::PxPyPzEVector beam2{0., 0., config.beamMomentum, 13600. / 2.}; + ROOT::Math::XYZVectorF beam1CM, beam2CM; + + // const double massK0s = o2::constants::physics::MassK0Short; + bool isMix = false; + void init(InitContext const&) { + rctCut.rctChecker.init( + rctCut.cfgEvtRCTFlagCheckerLabel, + rctCut.cfgEvtRCTFlagCheckerZDCCheck, + rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + // Axes - AxisSpec k0ShortMassAxis = {ksMassBins, ksMassMin, ksMassMax, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; - AxisSpec glueballMassAxis = {cMassBins, cMassMin, cMassMax, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec k0ShortMassAxis = {config.ksMassBins, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec glueballMassAxis = {config.cGlueMassBins, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; AxisSpec vertexZAxis = {60, -15.f, 15.f, "vrtx_{Z} [cm]"}; // for histogram - AxisSpec ptAxis = {cPtBins, cPtMin, cPtMax, "#it{p}_{T} (GeV/#it{c})"}; - // AxisSpec multiplicityAxis = {110, 0.0f, 150.0f, "Multiplicity Axis"}; - AxisSpec multiplicityAxis = {binsCent, "Multiplicity Axis"}; - AxisSpec thnAxisPOL{configThnAxisPOL, "Configurabel theta axis"}; - AxisSpec occupancyAxis = {occupancyBins, "Occupancy [-40,100]"}; + AxisSpec ptAxis = {config.cPtBins, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec multiplicityAxis = {config.binsCent, "Multiplicity Axis"}; + AxisSpec thnAxisPOL{config.configThnAxisPOL, "Configurabel theta axis"}; + AxisSpec thnAxisPhi = {config.configThnAxisPhi, "Configurabel phi axis"}; // 0 to 2pi // THnSparses - std::array sparses = {activateTHnSparseCosThStarHelicity, activateTHnSparseCosThStarProduction, activateTHnSparseCosThStarBeam, activateTHnSparseCosThStarRandom}; + std::array sparses = {config.activateTHnSparseCosThStarHelicity, config.activateTHnSparseCosThStarProduction, config.activateTHnSparseCosThStarBeam, config.activateTHnSparseCosThStarRandom}; - // std::array sparses = {activateTHnSparseCosThStarHelicity}; + // std::array sparses = {config.activateTHnSparseCosThStarHelicity}; if (std::accumulate(sparses.begin(), sparses.end(), 0) == 0) { LOGP(fatal, "No output THnSparses enabled"); } else { - if (activateTHnSparseCosThStarHelicity) { + if (config.activateTHnSparseCosThStarHelicity) { LOGP(info, "THnSparse with cosThStar w.r.t. helicity axis active."); } - if (activateTHnSparseCosThStarProduction) { + if (config.activateTHnSparseCosThStarProduction) { LOGP(info, "THnSparse with cosThStar w.r.t. production axis active."); } - if (activateTHnSparseCosThStarBeam) { + if (config.activateTHnSparseCosThStarBeam) { LOGP(info, "THnSparse with cosThStar w.r.t. beam axis active. (Gottified jackson frame)"); } - if (activateTHnSparseCosThStarRandom) { + if (config.activateTHnSparseCosThStarRandom) { LOGP(info, "THnSparse with cosThStar w.r.t. random axis active."); } } // Event selection - if (qAevents) { + if (config.qAevents) { rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); rEventSelection.add("hmultiplicity", "multiplicity percentile distribution", {HistType::kTH1F, {{150, 0.0f, 150.0f}}}); - rEventSelection.add("multdist_FT0M", "FT0M Multiplicity distribution", kTH1F, {axisMultdist}); - rEventSelection.add("multdist_FT0A", "FT0A Multiplicity distribution", kTH1F, {axisMultdist}); - rEventSelection.add("multdist_FT0C", "FT0C Multiplicity distribution", kTH1F, {axisMultdist}); - rEventSelection.add("hNcontributor", "Number of primary vertex contributor", kTH1F, {{2000, 0.0f, 10000.0f}}); - } - - if (invMass1D) { - hglue.add("h1glueInvMassDS", "h1glueInvMassDS", kTH1F, {glueballMassAxis}); - hglue.add("h1glueInvMassME", "h1glueInvMassME", kTH1F, {glueballMassAxis}); - hglue.add("h1glueInvMassRot", "h1glueInvMassRot", kTH1F, {glueballMassAxis}); + // rEventSelection.add("multdist_FT0M", "FT0M Multiplicity distribution", kTH1F, {config.axisMultdist}); + // rEventSelection.add("multdist_FT0A", "FT0A Multiplicity distribution", kTH1F, {config.axisMultdist}); + // rEventSelection.add("multdist_FT0C", "FT0C Multiplicity distribution", kTH1F, {config.axisMultdist}); + // rEventSelection.add("hNcontributor", "Number of primary vertex contributor", kTH1F, {{2000, 0.0f, 10000.0f}}); } - hglue.add("h3glueInvMassDS", "h3glueInvMassDS", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL, occupancyAxis}, true); - hglue.add("h3glueInvMassME", "h3glueInvMassME", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL, occupancyAxis}, true); - hglue.add("h3glueInvMassRot", "h3glueInvMassRot", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL, occupancyAxis}, true); + hglue.add("h3glueInvMassDS", "h3glueInvMassDS", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL, thnAxisPhi}, true); + hglue.add("h3glueInvMassME", "h3glueInvMassME", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL, thnAxisPhi}, true); + hglue.add("h3glueInvMassRot", "h3glueInvMassRot", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL, thnAxisPhi}, true); hglue.add("heventscheck", "heventscheck", kTH1I, {{10, 0, 10}}); hglue.add("htrackscheck_v0", "htrackscheck_v0", kTH1I, {{15, 0, 15}}); hglue.add("htrackscheck_v0_daughters", "htrackscheck_v0_daughters", kTH1I, {{15, 0, 15}}); // K0s topological/PID cuts - if (correlation2Dhist) { + if (config.correlation2Dhist) { rKzeroShort.add("mass_lambda_kshort_before", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); - rKzeroShort.add("mass_lambda_kshort_after1", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); - rKzeroShort.add("mass_lambda_kshort_after2", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); - rKzeroShort.add("mass_lambda_kshort_after3", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); - rKzeroShort.add("mass_lambda_kshort_after4", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); - rKzeroShort.add("mass_lambda_kshort_after5", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); - rKzeroShort.add("mass_lambda_kshort_after6", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); - rKzeroShort.add("mass_lambda_kshort_after7", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); - rKzeroShort.add("mass_lambda_kshort_after8", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); - rKzeroShort.add("mass_lambda_kshort_after9", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + // rKzeroShort.add("mass_lambda_kshort_after1", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + // rKzeroShort.add("mass_lambda_kshort_after2", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + // rKzeroShort.add("mass_lambda_kshort_after3", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + // rKzeroShort.add("mass_lambda_kshort_after4", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + // rKzeroShort.add("mass_lambda_kshort_after5", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + // rKzeroShort.add("mass_lambda_kshort_after6", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + // rKzeroShort.add("mass_lambda_kshort_after7", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + // rKzeroShort.add("mass_lambda_kshort_after8", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + // rKzeroShort.add("mass_lambda_kshort_after9", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); rKzeroShort.add("mass_lambda_kshort_after10", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); } - if (qAv0) { + if (config.qAv0) { // Invariant Mass rKzeroShort.add("hMassK0Shortbefore", "hMassK0Shortbefore", kTHnSparseF, {k0ShortMassAxis, ptAxis}); rKzeroShort.add("hMasscorrelationbefore", "hMasscorrelationbefore", kTH2F, {k0ShortMassAxis, k0ShortMassAxis}); @@ -241,75 +275,85 @@ struct HigherMassResonances { rKzeroShort.add("hDCAV0Daughters", "DCA between v0 daughters", {HistType::kTH1F, {{60, -3.0f, 3.0f}}}); rKzeroShort.add("hV0CosPA", "hV0CosPA", {HistType::kTH1F, {{100, 0.96f, 1.1f}}}); rKzeroShort.add("hLT", "hLT", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); - rKzeroShort.add("Mass_lambda", "Mass under lambda hypothesis", kTH1F, {glueballMassAxis}); - rKzeroShort.add("mass_AntiLambda", "Mass under anti-lambda hypothesis", kTH1F, {glueballMassAxis}); - rKzeroShort.add("mass_Gamma", "Mass under Gamma hypothesis", kTH1F, {glueballMassAxis}); + rKzeroShort.add("angularSeparation", "Angular distribution between two K0s vs pT", {HistType::kTH1F, {{200, 0.0f, 4.0f}}}); + // rKzeroShort.add("Mass_lambda", "Mass under lambda hypothesis", kTH1F, {glueballMassAxis}); + // rKzeroShort.add("mass_AntiLambda", "Mass under anti-lambda hypothesis", kTH1F, {glueballMassAxis}); + // rKzeroShort.add("mass_Gamma", "Mass under Gamma hypothesis", kTH1F, {glueballMassAxis}); // rKzeroShort.add("mass_Hypertriton", "Mass under hypertriton hypothesis", kTH1F, {glueballMassAxis}); // rKzeroShort.add("mass_AnitHypertriton", "Mass under anti-hypertriton hypothesis", kTH1F, {glueballMassAxis}); - rKzeroShort.add("rapidity", "Rapidity distribution", kTH1F, {{100, -1.0f, 1.0f}}); - rKzeroShort.add("hv0radius", "hv0radius", kTH1F, {{100, 0.0f, 200.0f}}); - rKzeroShort.add("hDCApostopv", "DCA positive daughter to PV", kTH1F, {{1000, -10.0f, 10.0f}}); - rKzeroShort.add("hDCAnegtopv", "DCA negative daughter to PV", kTH1F, {{1000, -10.0f, 10.0f}}); - rKzeroShort.add("hcDCAv0topv", "DCA V0 to PV", kTH1F, {{60, -3.0f, 3.0f}}); - rKzeroShort.add("halpha", "Armenteros alpha", kTH1F, {{100, -5.0f, 5.0f}}); - rKzeroShort.add("hqtarmbyalpha", "qtarm/alpha", kTH1F, {{100, 0.0f, 1.0f}}); - rKzeroShort.add("hpsipair", "psi pair angle", kTH1F, {{100, -5.0f, 5.0f}}); - rKzeroShort.add("NksProduced", "Number of K0s produced", kTH1I, {{15, 0, 15}}); + // rKzeroShort.add("rapidity", "Rapidity distribution", kTH1F, {{100, -1.0f, 1.0f}}); + // rKzeroShort.add("hv0radius", "hv0radius", kTH1F, {{100, 0.0f, 200.0f}}); + // rKzeroShort.add("hDCApostopv", "DCA positive daughter to PV", kTH1F, {{1000, -10.0f, 10.0f}}); + // rKzeroShort.add("hDCAnegtopv", "DCA negative daughter to PV", kTH1F, {{1000, -10.0f, 10.0f}}); + // rKzeroShort.add("hcDCAv0topv", "DCA V0 to PV", kTH1F, {{60, -3.0f, 3.0f}}); + // rKzeroShort.add("halpha", "Armenteros alpha", kTH1F, {{100, -5.0f, 5.0f}}); + // rKzeroShort.add("hqtarmbyalpha", "qtarm/alpha", kTH1F, {{100, 0.0f, 1.0f}}); + // rKzeroShort.add("hpsipair", "psi pair angle", kTH1F, {{100, -5.0f, 5.0f}}); // // Topological histograms (before the selection) // rKzeroShort.add("hDCAV0Daughters_before", "DCA between v0 daughters before the selection", {HistType::kTH1F, {{60, -3.0f, 3.0f}}}); // rKzeroShort.add("hV0CosPA_before", "hV0CosPA_before", {HistType::kTH1F, {{200, 0.91f, 1.1f}}}); // rKzeroShort.add("hLT_before", "hLT_before", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); } - if (qAPID) { + rKzeroShort.add("NksProduced", "Number of K0s produced", kTH1I, {{15, -0.5, 14.5}}); + + if (config.qAPID) { rKzeroShort.add("hNSigmaPosPionK0s_before", "hNSigmaPosPionK0s_before", {HistType::kTH2F, {{ptAxis}, {100, -5.f, 5.f}}}); - // rKzeroShort.add("hNSigmaPosPionK0s_after", "hNSigmaPosPionK0s_after", {HistType::kTH2F, {{ptAxis}, {100, -5.f, 5.f}}}); + rKzeroShort.add("hNSigmaPosPionK0s_after", "hNSigmaPosPionK0s_after", {HistType::kTH2F, {{ptAxis}, {100, -5.f, 5.f}}}); rKzeroShort.add("hNSigmaNegPionK0s_before", "hNSigmaNegPionK0s_before", {HistType::kTH2F, {{ptAxis}, {100, -5.f, 5.f}}}); - // rKzeroShort.add("hNSigmaNegPionK0s_after", "hNSigmaNegPionK0s_after", {HistType::kTH2F, {{ptAxis}, {100, -5.f, 5.f}}}); - rKzeroShort.add("dE_by_dx_TPC", "dE/dx signal in the TPC as a function of pT", kTH2F, {axisPtfordEbydx, axisdEdx}); - } - if (qAv0Daughters) { - rKzeroShort.add("negative_pt", "Negative daughter pT", kTH1F, {ptAxis}); - rKzeroShort.add("positive_pt", "Positive daughter pT", kTH1F, {ptAxis}); - rKzeroShort.add("negative_eta", "Negative daughter eta", kTH1F, {{100, -1.0f, 1.0f}}); - rKzeroShort.add("positive_eta", "Positive daughter eta", kTH1F, {{100, -1.0f, 1.0f}}); - rKzeroShort.add("negative_phi", "Negative daughter phi", kTH1F, {{70, 0.0f, 7.0f}}); - rKzeroShort.add("positive_phi", "Positive daughter phi", kTH1F, {{70, 0.0f, 7.0f}}); + rKzeroShort.add("hNSigmaNegPionK0s_after", "hNSigmaNegPionK0s_after", {HistType::kTH2F, {{ptAxis}, {100, -5.f, 5.f}}}); + // rKzeroShort.add("dE_by_dx_TPC", "dE/dx signal in the TPC as a function of pT", kTH2F, {config.axisPtfordEbydx, config.axisdEdx}); } + // if (config.qAv0Daughters) { + // rKzeroShort.add("negative_pt", "Negative daughter pT", kTH1F, {ptAxis}); + // rKzeroShort.add("positive_pt", "Positive daughter pT", kTH1F, {ptAxis}); + // rKzeroShort.add("negative_eta", "Negative daughter eta", kTH1F, {{100, -1.0f, 1.0f}}); + // rKzeroShort.add("positive_eta", "Positive daughter eta", kTH1F, {{100, -1.0f, 1.0f}}); + // rKzeroShort.add("negative_phi", "Negative daughter phi", kTH1F, {{70, 0.0f, 7.0f}}); + // rKzeroShort.add("positive_phi", "Positive daughter phi", kTH1F, {{70, 0.0f, 7.0f}}); + // } // For MC - hMChists.add("events_check", "No. of events in the generated MC", kTH1I, {{20, 0, 20}}); - hMChists.add("events_checkrec", "No. of events in the reconstructed MC", kTH1I, {{20, 0, 20}}); - hMChists.add("Genf1710", "Gen f_{0}(1710)", kTH1F, {ptAxis}); - hMChists.add("Recf1710_pt1", "Rec f_{0}(1710) p_{T}", kTH1F, {ptAxis}); - hMChists.add("Recf1710_pt2", "Rec f_{0}(1710) p_{T}", kTH1F, {ptAxis}); - hMChists.add("Recf1710_p", "Rec f_{0}(1710) p", kTH1F, {ptAxis}); - hMChists.add("Recf1710_mass", "Rec f_{0}(1710) mass", kTH1F, {glueballMassAxis}); - hMChists.add("Genf1710_mass", "Gen f_{0}(1710) mass", kTH1F, {glueballMassAxis}); - hMChists.add("MC_mult", "Multiplicity in MC", kTH1F, {multiplicityAxis}); - hMChists.add("MC_mult_after_event_sel", "Multiplicity in MC", kTH1F, {multiplicityAxis}); - - if (additionalEvsel) { - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); - // fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x)", 0, 100); - // fMultCutLow->SetParameters(1893.94, -53.86, 0.502913, -0.0015122, 109.625, -1.19253); - // fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x)", 0, 100); - // fMultCutHigh->SetParameters(1893.94, -53.86, 0.502913, -0.0015122, 109.625, -1.19253); - // fMultMultPVCut = new TF1("fMultMultPVCut", "[0]+[1]*x+[2]*x*x", 0, 5000); - // fMultMultPVCut->SetParameters(-0.1, 0.785, -4.7e-05); + if (config.isMC) { + hMChists.add("events_check", "No. of events in the generated MC", kTH1I, {{20, 0, 20}}); + hMChists.add("events_checkrec", "No. of events in the reconstructed MC", kTH1I, {{25, 0, 25}}); + hMChists.add("Genf1710", "Gen f_{0}(1710)", kTHnSparseF, {multiplicityAxis, ptAxis, thnAxisPOL}); + hMChists.add("Genf17102", "Gen f_{0}(1710)", kTHnSparseF, {multiplicityAxis, ptAxis, thnAxisPOL}); + hMChists.add("Recf1710_pt1", "Rec f_{0}(1710) p_{T}", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL}); + hMChists.add("Recf1710_pt2", "Rec f_{0}(1710) p_{T}", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL}); + // hMChists.add("Recf1710_p", "Rec f_{0}(1710) p", kTH1F, {ptAxis}); + hMChists.add("h1Recsplit", "Rec p_{T}2", kTH1F, {ptAxis}); + // hMChists.add("Recf1710_mass", "Rec f_{0}(1710) mass", kTH1F, {glueballMassAxis}); + hMChists.add("Genf1710_mass", "Gen f_{0}(1710) mass", kTH1F, {glueballMassAxis}); + hMChists.add("Genf1710_mass2", "Gen f_{0}(1710) mass", kTH1F, {glueballMassAxis}); + // hMChists.add("Genf1710_pt2", "Gen f_{0}(1710) p_{T}", kTH1F, {ptAxis}); + hMChists.add("GenPhi", "Gen Phi", kTH1F, {{70, 0.0, 7.0f}}); + hMChists.add("GenPhi2", "Gen Phi", kTH1F, {{70, 0.0, 7.0f}}); + hMChists.add("GenEta", "Gen Eta", kTHnSparseF, {{150, -1.5f, 1.5f}}); + hMChists.add("GenEta2", "Gen Eta", kTHnSparseF, {{150, -1.5f, 1.5f}}); + hMChists.add("GenRapidity", "Gen Rapidity", kTHnSparseF, {{100, -1.0f, 1.0f}}); + hMChists.add("GenRapidity2", "Gen Rapidity", kTHnSparseF, {{100, -1.0f, 1.0f}}); + hMChists.add("RecEta", "Rec Eta", kTH1F, {{150, -1.5f, 1.5f}}); + hMChists.add("RecEta2", "Rec Eta", kTH1F, {{150, -1.5f, 1.5f}}); + hMChists.add("RecPhi", "Rec Phi", kTH1F, {{70, 0.0f, 7.0f}}); + hMChists.add("RecPhi2", "Rec Phi", kTH1F, {{70, 0.0f, 7.0f}}); + hMChists.add("RecRapidity", "Rec Rapidity", kTH1F, {{100, -1.0f, 1.0f}}); + hMChists.add("RecRapidity2", "Rec Rapidity", kTH1F, {{100, -1.0f, 1.0f}}); + hMChists.add("Rec_Multiplicity", "Multiplicity in MC", kTH1F, {multiplicityAxis}); + hMChists.add("MC_mult_after_event_sel", "Multiplicity in MC", kTH1F, {multiplicityAxis}); + // hMChists.add("GenPx", "Gen Px", kTH1F, {{100, -10.0f, 10.0f}}); + // hMChists.add("GenPy", "Gen Py", kTH1F, {{100, -10.0f, 10.0f}}); + // hMChists.add("GenPz", "Gen Pz", kTH1F, {{100, -10.0f, 10.0f}}); } } template - bool eventselection(Collision const& collision, const float& multiplicity) + bool eventselection(Collision const& collision) { hglue.fill(HIST("heventscheck"), 1.5); - if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + if (config.timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { return false; } hglue.fill(HIST("heventscheck"), 2.5); @@ -319,30 +363,20 @@ struct HigherMassResonances { } hglue.fill(HIST("heventscheck"), 3.5); - if (piluprejection && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return false; - } - hglue.fill(HIST("heventscheck"), 4.5); - - if (goodzvertex && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return false; - } - hglue.fill(HIST("heventscheck"), 5.5); + // if (config.piluprejection && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // return false; + // } + // hglue.fill(HIST("heventscheck"), 4.5); - if (itstpctracks && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - return false; - } - hglue.fill(HIST("heventscheck"), 6.5); + // if (config.goodzvertex && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // return false; + // } + // hglue.fill(HIST("heventscheck"), 5.5); - auto multNTracksPV = collision.multNTracksPV(); - if (additionalEvsel && multNTracksPV < fMultPVCutLow->Eval(multiplicity)) { - return false; - } - hglue.fill(HIST("heventscheck"), 7.5); - if (additionalEvsel && multNTracksPV > fMultPVCutHigh->Eval(multiplicity)) { - return false; - } - hglue.fill(HIST("heventscheck"), 8.5); + // if (config.itstpctracks && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + // return false; + // } + // hglue.fill(HIST("heventscheck"), 6.5); return true; } @@ -350,116 +384,118 @@ struct HigherMassResonances { template bool selectionV0(Collision const& collision, V0 const& candidate, float /*multiplicity*/) { - const float qtarm = candidate.qtarm(); - const float alph = candidate.alpha(); - float arm = qtarm / alph; + // const float qtarm = candidate.qtarm(); + // const float alph = candidate.alpha(); + // float arm = qtarm / alph; const float pT = candidate.pt(); const float tranRad = candidate.v0radius(); const float dcaDaughv0 = candidate.dcaV0daughters(); const float cpav0 = candidate.v0cosPA(); float ctauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; - float lowmasscutks0 = 0.497 - cWidthKs0 * cSigmaMassKs0; - float highmasscutks0 = 0.497 + cWidthKs0 * cSigmaMassKs0; + float lowmasscutks0 = o2::constants::physics::MassKPlus - config.cWidthKs0 * config.cSigmaMassKs0; + float highmasscutks0 = o2::constants::physics::MassKPlus + config.cWidthKs0 * config.cSigmaMassKs0; // float decayLength = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * RecoDecay::sqrtSumOfSquares(candidate.px(), candidate.py(), candidate.pz()); - if (qAv0) { + if (config.qAv0) { rKzeroShort.fill(HIST("hMassK0Shortbefore"), candidate.mK0Short(), candidate.pt()); - rKzeroShort.fill(HIST("hMasscorrelationbefore"), candidate.mK0Short(), candidate.mK0Short()); rKzeroShort.fill(HIST("hLT"), ctauK0s); rKzeroShort.fill(HIST("hDCAV0Daughters"), candidate.dcaV0daughters()); rKzeroShort.fill(HIST("hV0CosPA"), candidate.v0cosPA()); - rKzeroShort.fill(HIST("Mass_lambda"), candidate.mLambda()); - rKzeroShort.fill(HIST("mass_AntiLambda"), candidate.mAntiLambda()); - rKzeroShort.fill(HIST("mass_Gamma"), candidate.mGamma()); + // rKzeroShort.fill(HIST("Mass_lambda"), candidate.mLambda()); + // rKzeroShort.fill(HIST("mass_AntiLambda"), candidate.mAntiLambda()); + // rKzeroShort.fill(HIST("mass_Gamma"), candidate.mGamma()); // rKzeroShort.fill(HIST("mass_Hypertriton"), candidate.mHypertriton()); // rKzeroShort.fill(HIST("mass_AnitHypertriton"), candidate.mAntiHypertriton()); - rKzeroShort.fill(HIST("rapidity"), candidate.yK0Short()); - rKzeroShort.fill(HIST("hv0radius"), candidate.v0radius()); - rKzeroShort.fill(HIST("hDCApostopv"), candidate.dcapostopv()); - rKzeroShort.fill(HIST("hDCAnegtopv"), candidate.dcanegtopv()); - rKzeroShort.fill(HIST("hcDCAv0topv"), candidate.dcav0topv()); - rKzeroShort.fill(HIST("halpha"), candidate.alpha()); - rKzeroShort.fill(HIST("hqtarmbyalpha"), arm); - rKzeroShort.fill(HIST("hpsipair"), candidate.psipair()); + // rKzeroShort.fill(HIST("rapidity"), candidate.yK0Short()); + // rKzeroShort.fill(HIST("hv0radius"), candidate.v0radius()); + // rKzeroShort.fill(HIST("hDCApostopv"), candidate.dcapostopv()); + // rKzeroShort.fill(HIST("hDCAnegtopv"), candidate.dcanegtopv()); + // rKzeroShort.fill(HIST("hcDCAv0topv"), candidate.dcav0topv()); + // rKzeroShort.fill(HIST("halpha"), candidate.alpha()); + // rKzeroShort.fill(HIST("hqtarmbyalpha"), arm); + // rKzeroShort.fill(HIST("hpsipair"), candidate.psipair()); } - if (correlation2Dhist) + if (config.correlation2Dhist) rKzeroShort.fill(HIST("mass_lambda_kshort_before"), candidate.mK0Short(), candidate.mLambda()); hglue.fill(HIST("htrackscheck_v0"), 0.5); - if (cDCAv0topv && std::fabs(candidate.dcav0topv()) > cMaxV0DCA) { + if (config.cDCAv0topv && std::fabs(candidate.dcav0topv()) > config.cMaxV0DCA) { return false; } hglue.fill(HIST("htrackscheck_v0"), 1.5); - if (correlation2Dhist) - rKzeroShort.fill(HIST("mass_lambda_kshort_after1"), candidate.mK0Short(), candidate.mLambda()); + // if (config.correlation2Dhist) + // rKzeroShort.fill(HIST("mass_lambda_kshort_after1"), candidate.mK0Short(), candidate.mLambda()); - if (rapidityks && std::abs(candidate.yK0Short()) >= confKsrapidity) { + // if (config.rapidityks && std::abs(candidate.yK0Short()) >= config.confKsrapidity) { + // return false; + // } + if (std::abs(candidate.yK0Short()) >= config.confKsrapidity) { return false; } hglue.fill(HIST("htrackscheck_v0"), 2.5); - if (correlation2Dhist) - rKzeroShort.fill(HIST("mass_lambda_kshort_after2"), candidate.mK0Short(), candidate.mLambda()); + // if (config.correlation2Dhist) + // rKzeroShort.fill(HIST("mass_lambda_kshort_after2"), candidate.mK0Short(), candidate.mLambda()); - if (pT < confV0PtMin) { + if (pT < config.confV0PtMin) { return false; } hglue.fill(HIST("htrackscheck_v0"), 3.5); - if (correlation2Dhist) - rKzeroShort.fill(HIST("mass_lambda_kshort_after3"), candidate.mK0Short(), candidate.mLambda()); + // if (config.correlation2Dhist) + // rKzeroShort.fill(HIST("mass_lambda_kshort_after3"), candidate.mK0Short(), candidate.mLambda()); - if (dcaDaughv0 > confV0DCADaughMax) { + if (dcaDaughv0 > config.confV0DCADaughMax) { return false; } hglue.fill(HIST("htrackscheck_v0"), 4.5); - if (correlation2Dhist) - rKzeroShort.fill(HIST("mass_lambda_kshort_after4"), candidate.mK0Short(), candidate.mLambda()); + // if (config.correlation2Dhist) + // rKzeroShort.fill(HIST("mass_lambda_kshort_after4"), candidate.mK0Short(), candidate.mLambda()); - if (cpav0 < confV0CPAMin) { + if (cpav0 < config.confV0CPAMin) { return false; } hglue.fill(HIST("htrackscheck_v0"), 5.5); - if (correlation2Dhist) - rKzeroShort.fill(HIST("mass_lambda_kshort_after5"), candidate.mK0Short(), candidate.mLambda()); + // if (config.correlation2Dhist) + // rKzeroShort.fill(HIST("mass_lambda_kshort_after5"), candidate.mK0Short(), candidate.mLambda()); - if (tranRad < confV0TranRadV0Min) { + if (tranRad < config.confV0TranRadV0Min) { return false; } hglue.fill(HIST("htrackscheck_v0"), 6.5); - if (correlation2Dhist) - rKzeroShort.fill(HIST("mass_lambda_kshort_after6"), candidate.mK0Short(), candidate.mLambda()); + // if (config.correlation2Dhist) + // rKzeroShort.fill(HIST("mass_lambda_kshort_after6"), candidate.mK0Short(), candidate.mLambda()); - if (tranRad > confV0TranRadV0Max) { + if (tranRad > config.confV0TranRadV0Max) { return false; } hglue.fill(HIST("htrackscheck_v0"), 7.5); - if (correlation2Dhist) - rKzeroShort.fill(HIST("mass_lambda_kshort_after7"), candidate.mK0Short(), candidate.mLambda()); + // if (config.correlation2Dhist) + // rKzeroShort.fill(HIST("mass_lambda_kshort_after7"), candidate.mK0Short(), candidate.mLambda()); - if (std::fabs(ctauK0s) > cMaxV0LifeTime) { + if (std::fabs(ctauK0s) > config.cMaxV0LifeTime) { return false; } hglue.fill(HIST("htrackscheck_v0"), 8.5); - if (correlation2Dhist) - rKzeroShort.fill(HIST("mass_lambda_kshort_after8"), candidate.mK0Short(), candidate.mLambda()); + // if (config.correlation2Dhist) + // rKzeroShort.fill(HIST("mass_lambda_kshort_after8"), candidate.mK0Short(), candidate.mLambda()); - if (armcut && arm < confarmcut) { - return false; - } + // if (config.armcut && arm < config.confarmcut) { + // return false; + // } hglue.fill(HIST("htrackscheck_v0"), 9.5); - if (correlation2Dhist) - rKzeroShort.fill(HIST("mass_lambda_kshort_after9"), candidate.mK0Short(), candidate.mLambda()); + // if (config.correlation2Dhist) + // rKzeroShort.fill(HIST("mass_lambda_kshort_after9"), candidate.mK0Short(), candidate.mLambda()); - // if (applyCompetingcut && (std::abs(candidate.mLambda() - PDGdatabase->Mass(3122)) <= competingcascrejlambda || std::abs(candidate.mAntiLambda() - PDGdatabase->Mass(-3122)) <= competingcascrejlambdaanti)) - if (applyCompetingcut && (std::abs(candidate.mLambda() - o2::constants::physics::MassLambda0) <= competingcascrejlambda || std::abs(candidate.mAntiLambda() - o2::constants::physics::MassLambda0) <= competingcascrejlambdaanti)) { + // if (config.applyCompetingcut && (std::abs(candidate.mLambda() - PDGdatabase->Mass(3122)) <= config.competingcascrejlambda || std::abs(candidate.mAntiLambda() - PDGdatabase->Mass(-3122)) <= config.competingcascrejlambdaanti)) + if (config.applyCompetingcut && (std::abs(candidate.mLambda() - o2::constants::physics::MassLambda0) <= config.competingcascrejlambda || std::abs(candidate.mAntiLambda() - o2::constants::physics::MassLambda0) <= config.competingcascrejlambda)) { return false; } hglue.fill(HIST("htrackscheck_v0"), 10.5); - if (correlation2Dhist) + if (config.correlation2Dhist) rKzeroShort.fill(HIST("mass_lambda_kshort_after10"), candidate.mK0Short(), candidate.mLambda()); - if (qAv0) { + if (config.qAv0) { rKzeroShort.fill(HIST("hMassK0ShortSelected"), candidate.mK0Short(), candidate.pt()); // rKzeroShort.fill(HIST("mass_lambda_kshort_after"), candidate.mK0Short(), candidate.mLambda()); } @@ -473,10 +509,10 @@ struct HigherMassResonances { template bool isSelectedV0Daughter(T const& track, float charge, double nsigmaV0Daughter, V0s const& /*candidate*/) { - if (qAPID) { + if (config.qAPID) { // Filling the PID of the V0 daughters in the region of the K0 peak. (charge == 1) ? rKzeroShort.fill(HIST("hNSigmaPosPionK0s_before"), track.tpcInnerParam(), track.tpcNSigmaPi()) : rKzeroShort.fill(HIST("hNSigmaNegPionK0s_before"), track.tpcInnerParam(), track.tpcNSigmaPi()); - rKzeroShort.fill(HIST("dE_by_dx_TPC"), track.p(), track.tpcSignal()); + // rKzeroShort.fill(HIST("dE_by_dx_TPC"), track.p(), track.tpcSignal()); } const auto eta = track.eta(); const auto tpcNClsF = track.tpcNClsFound(); @@ -484,20 +520,20 @@ struct HigherMassResonances { hglue.fill(HIST("htrackscheck_v0_daughters"), 0.5); - if (hasTPC && !track.hasTPC()) + if (config.hasTPC && !track.hasTPC()) return false; hglue.fill(HIST("htrackscheck_v0_daughters"), 1.5); - if (!globalTracks) { - if (track.tpcNClsCrossedRows() < tpcCrossedrows) + if (!config.globalTracks) { + if (track.tpcNClsCrossedRows() < config.tpcCrossedrows) return false; hglue.fill(HIST("htrackscheck_v0_daughters"), 2.5); - if (track.tpcCrossedRowsOverFindableCls() < tpcCrossedrowsOverfcls) + if (track.tpcCrossedRowsOverFindableCls() < config.tpcCrossedrowsOverfcls) return false; hglue.fill(HIST("htrackscheck_v0_daughters"), 3.5); - if (tpcNClsF < confDaughTPCnclsMin) { + if (tpcNClsF < config.confDaughTPCnclsMin) { return false; } hglue.fill(HIST("htrackscheck_v0_daughters"), 4.5); @@ -517,77 +553,238 @@ struct HigherMassResonances { } hglue.fill(HIST("htrackscheck_v0_daughters"), 6.5); - if (std::abs(eta) > confDaughEta) { + if (std::abs(eta) > config.confDaughEta) { return false; } hglue.fill(HIST("htrackscheck_v0_daughters"), 7.5); - if (std::abs(nsigmaV0Daughter) > confDaughPIDCuts) { + if (std::abs(nsigmaV0Daughter) > config.confDaughPIDCuts) { return false; } hglue.fill(HIST("htrackscheck_v0_daughters"), 8.5); + if (config.qAPID) { + (charge == 1) ? rKzeroShort.fill(HIST("hNSigmaPosPionK0s_after"), track.tpcInnerParam(), track.tpcNSigmaPi()) : rKzeroShort.fill(HIST("hNSigmaNegPionK0s_after"), track.tpcInnerParam(), track.tpcNSigmaPi()); + } + + return true; + } + + // Angular separation cut on KsKs pairs + template + bool applyAngSep(const T1& candidate1, const T2& candidate2) + { + double eta1, eta2, phi1, phi2; + eta1 = candidate1.eta(); + eta2 = candidate2.eta(); + phi1 = candidate1.phi(); + phi2 = candidate2.phi(); + + double angle = std::sqrt(std::pow(eta1 - eta2, 2) + std::pow(phi1 - phi2, 2)); + if (config.qAv0) { + rKzeroShort.fill(HIST("angularSeparation"), angle); + } + if (config.applyAngSepCut && angle > config.angSepCut) { + return false; + } return true; } // Defining filters for events (event selection) // Filter eventFilter = (o2::aod::evsel::sel8 == true); - Filter posZFilter = (nabs(o2::aod::collision::posZ) < cutzvertex); - Filter acceptenceFilter = (nabs(aod::track::eta) < cfgETAcut && nabs(aod::track::pt) > cfgPTcut); + Filter posZFilter = (nabs(o2::aod::collision::posZ) < config.cutzvertex); + Filter acceptenceFilter = (nabs(aod::track::eta) < config.cfgETAcut && nabs(aod::track::pt) > config.cfgPTcut); // Filters on V0s - Filter preFilterV0 = (nabs(aod::v0data::dcapostopv) > v0settingDcapostopv && - nabs(aod::v0data::dcanegtopv) > v0settingDcanegtopv); + Filter preFilterV0 = (nabs(aod::v0data::dcapostopv) > config.v0settingDcapostopv && nabs(aod::v0data::dcanegtopv) > config.v0settingDcanegtopv); // Defining the type of the daughter tracks - using DaughterTracks = soa::Join; using EventCandidates = soa::Filtered>; using TrackCandidates = soa::Filtered>; using V0TrackCandidate = aod::V0Datas; // For Monte Carlo - using EventCandidatesMC = soa::Join; + using EventCandidatesMC = soa::Join; using TrackCandidatesMC = soa::Filtered>; - using V0TrackCandidatesMC = soa::Join; + using V0TrackCandidatesMC = soa::Filtered>; + // zBeam direction in lab frame + + template + void fillInvMass(const T& mother, float multiplicity, const T& daughter1, const T& daughter2, bool isMix) + { - // void processSE(soa::Filtered>::iterator const& collision, - // soa::Filtered const& V0s, - // DaughterTracks const&) + // //polarization calculations + // zBeam = ROOT::Math::XYZVector(0.f, 0.f, 1.f); // ẑ: beam direction in lab frame + + ROOT::Math::Boost boost{mother.BoostToCM()}; // define the boost to the center of mass frame + fourVecDauCM = boost(daughter1); // boost the frame of daughter to the center of mass frame + // threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother + + beam1CM = ROOT::Math::XYZVectorF((boost(beam1).Vect()).Unit()); + beam2CM = ROOT::Math::XYZVectorF((boost(beam2).Vect()).Unit()); + + // define y = zBeam x z: Normal to the production plane + // ẑ: mother direction in lab, boosted into mother's rest frame + + // auto motherLabDirection = ROOT::Math::XYZVector(0, 0, mother.Vect().Z()); // ẑ axis in lab frame + + // // ŷ = zBeam × ẑ + // auto y_axis = zBeam.Cross(motherLabDirection).Unit(); + + // // x̂ = ŷ × ẑ + // auto x_axis = y_axis.Cross(motherLabDirection).Unit(); + + // // Project daughter momentum onto x–y plane + // auto p_proj_x = threeVecDauCM.Dot(x_axis); + // auto p_proj_y = threeVecDauCM.Dot(y_axis); + + // // Calculate φ in [-π, π] + // auto anglePhi = std::atan2(p_proj_y, p_proj_x); // φ in radians + + v1CM = ROOT::Math::XYZVectorF(boost(daughter1).Vect()).Unit(); + // ROOT::Math::XYZVectorF v2_CM{(boost(daughter1).Vect()).Unit()}; + // using positive sign convention for the first track + // ROOT::Math::XYZVectorF v_CM = (t1.sign() > 0 ? v1CM : v2_CM); // here selected decay daughter momentum is intested. here you can choose one decay daughter no need to check both case as it is neutral particle for our case + // Helicity frame + zaxisHE = ROOT::Math::XYZVectorF(mother.Vect()).Unit(); + yaxisHE = ROOT::Math::XYZVectorF(beam1CM.Cross(beam2CM)).Unit(); + xaxisHE = ROOT::Math::XYZVectorF(yaxisHE.Cross(zaxisHE)).Unit(); + + // CosThetaHE = zaxisHE.Dot(v_CM); + + auto anglePhi = std::atan2(yaxisHE.Dot(v1CM), xaxisHE.Dot(v1CM)); + anglePhi = RecoDecay::constrainAngle(anglePhi, 0.0); + // if (anglePhi < 0) { + // anglePhi += o2::constants::math::TwoPI; // ensure phi is in [0, 2pi] + // } + + // if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { + if (config.activateTHnSparseCosThStarHelicity) { + // helicityVec = mother.Vect(); // 3 vector of mother in COM frame + // auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); + auto cosThetaStarHelicity = mother.Vect().Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(mother.Vect().Mag2())); + if (!isMix) { + if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassDS"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity, anglePhi); + } + + for (int i = 0; i < config.cRotations; i++) { + theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / config.rotationalCut, o2::constants::math::PI + o2::constants::math::PI / config.rotationalCut); + + daughterRot = ROOT::Math::PxPyPzMVector(daughter1.Px() * std::cos(theta2) - daughter1.Py() * std::sin(theta2), daughter1.Px() * std::sin(theta2) + daughter1.Py() * std::cos(theta2), daughter1.Pz(), daughter1.M()); + + motherRot = daughterRot + daughter2; + + ROOT::Math::Boost boost2{motherRot.BoostToCM()}; + daughterRotCM = boost2(daughterRot); + + auto cosThetaStarHelicityRot = motherRot.Vect().Dot(daughterRotCM.Vect()) / (std::sqrt(daughterRotCM.Vect().Mag2()) * std::sqrt(motherRot.Vect().Mag2())); + if (motherRot.Rapidity() < config.rapidityMotherData) + hglue.fill(HIST("h3glueInvMassRot"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarHelicityRot, anglePhi); + } + } else { + if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassME"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity, anglePhi); + } + } + } else if (config.activateTHnSparseCosThStarProduction) { + normalVec = ROOT::Math::XYZVector(mother.Py(), -mother.Px(), 0.f); + auto cosThetaStarProduction = normalVec.Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(normalVec.Mag2())); + if (!isMix) { + if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassDS"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction, anglePhi); + } + for (int i = 0; i < config.cRotations; i++) { + theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / config.rotationalCut, o2::constants::math::PI + o2::constants::math::PI / config.rotationalCut); + motherRot = ROOT::Math::PxPyPzMVector(mother.Px() * std::cos(theta2) - mother.Py() * std::sin(theta2), mother.Px() * std::sin(theta2) + mother.Py() * std::cos(theta2), mother.Pz(), mother.M()); + if (std::abs(motherRot.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassRot"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarProduction, anglePhi); + } + } + } else { + if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassME"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction, anglePhi); + } + } + } else if (config.activateTHnSparseCosThStarBeam) { + beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); + auto cosThetaStarBeam = beamVec.Dot(fourVecDauCM.Vect()) / std::sqrt(fourVecDauCM.Vect().Mag2()); + if (!isMix) { + if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassDS"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam, anglePhi); + } + for (int i = 0; i < config.cRotations; i++) { + theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / config.rotationalCut, o2::constants::math::PI + o2::constants::math::PI / config.rotationalCut); + motherRot = ROOT::Math::PxPyPzMVector(mother.Px() * std::cos(theta2) - mother.Py() * std::sin(theta2), mother.Px() * std::sin(theta2) + mother.Py() * std::cos(theta2), mother.Pz(), mother.M()); + if (std::abs(motherRot.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassRot"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarBeam, anglePhi); + } + } + } else { + if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassME"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam, anglePhi); + } + } + } else if (config.activateTHnSparseCosThStarRandom) { + auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); + auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); + + randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); + auto cosThetaStarRandom = randomVec.Dot(fourVecDauCM.Vect()) / std::sqrt(fourVecDauCM.Vect().Mag2()); + if (!isMix) { + if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassDS"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom, anglePhi); + } + for (int i = 0; i < config.cRotations; i++) { + theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / config.rotationalCut, o2::constants::math::PI + o2::constants::math::PI / config.rotationalCut); + motherRot = ROOT::Math::PxPyPzMVector(mother.Px() * std::cos(theta2) - mother.Py() * std::sin(theta2), mother.Px() * std::sin(theta2) + mother.Py() * std::cos(theta2), mother.Pz(), mother.M()); + if (std::abs(motherRot.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassRot"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarRandom, anglePhi); + } + } + } else { + if (std::abs(mother.Rapidity()) < config.rapidityMotherData) { + hglue.fill(HIST("h3glueInvMassME"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom, anglePhi); + } + } + } + // } + } - ROOT::Math::PxPyPzMVector daughter1, daughter2; - ROOT::Math::PxPyPzMVector lv3; - // int counter3 = 0; void processSE(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::V0Datas const& V0s) { hglue.fill(HIST("heventscheck"), 0.5); - // const double massK0s = TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass(); - const double massK0s = o2::constants::physics::MassK0Short; - float multiplicity = 0.0f; - if (cfgMultFOTM) { + multiplicity = 0.0; + if (config.cfgMultFOTM) { multiplicity = collision.centFT0M(); } else { multiplicity = collision.centFT0C(); } - if (!eventselection(collision, multiplicity)) { + if (!eventselection(collision)) { return; } - auto occupancyNumber = collision.trackOccupancyInTimeRange(); - if (applyOccupancyCut && occupancyNumber < occupancyCut) { + if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(collision)) { return; } - if (qAevents) { + // auto occupancyNumber = collision.trackOccupancyInTimeRange(); + // if (applyOccupancyCut && occupancyNumber < occupancyCut) { + // return; + // } + + if (config.qAevents) { rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); rEventSelection.fill(HIST("hmultiplicity"), multiplicity); - rEventSelection.fill(HIST("multdist_FT0M"), collision.multFT0M()); - rEventSelection.fill(HIST("multdist_FT0A"), collision.multFT0A()); - rEventSelection.fill(HIST("multdist_FT0C"), collision.multFT0C()); - rEventSelection.fill(HIST("hNcontributor"), collision.numContrib()); + // rEventSelection.fill(HIST("multdist_FT0M"), collision.multFT0M()); + // rEventSelection.fill(HIST("multdist_FT0A"), collision.multFT0A()); + // rEventSelection.fill(HIST("multdist_FT0C"), collision.multFT0C()); + // rEventSelection.fill(HIST("hNcontributor"), collision.numContrib()); } std::vector v0indexes; + bool allConditionsMet = 0; - for (const auto& [v1, v2] : combinations(CombinationsUpperIndexPolicy(V0s, V0s))) { + for (const auto& [v1, v2] : combinations(CombinationsFullIndexPolicy(V0s, V0s))) { if (v1.size() == 0 || v2.size() == 0) { continue; @@ -617,33 +814,147 @@ struct HigherMassResonances { continue; } - if (qAv0Daughters) { - rKzeroShort.fill(HIST("negative_pt"), negtrack1.pt()); - rKzeroShort.fill(HIST("positive_pt"), postrack1.pt()); - rKzeroShort.fill(HIST("negative_eta"), negtrack1.eta()); - rKzeroShort.fill(HIST("positive_eta"), postrack1.eta()); - rKzeroShort.fill(HIST("negative_phi"), negtrack1.phi()); - rKzeroShort.fill(HIST("positive_phi"), postrack1.phi()); + if (std::find(v0indexes.begin(), v0indexes.end(), v1.globalIndex()) == v0indexes.end()) { + v0indexes.push_back(v1.globalIndex()); } - // if (!isSelectedV0Daughter(negtrack1, -1, nTPCSigmaNeg1, v1)) { - // continue; + // if (!(std::find(v0indexes.begin(), v0indexes.end(), v2.globalIndex()) != v0indexes.end())) { + // v0indexes.push_back(v2.globalIndex()); // } - // if (!isSelectedV0Daughter(negtrack2, -1, nTPCSigmaNeg2, v2)) { - // continue; + + if (v2.globalIndex() <= v1.globalIndex()) { + continue; + } + + // if (config.qAv0Daughters) { + // rKzeroShort.fill(HIST("negative_pt"), negtrack1.pt()); + // rKzeroShort.fill(HIST("positive_pt"), postrack1.pt()); + // rKzeroShort.fill(HIST("negative_eta"), negtrack1.eta()); + // rKzeroShort.fill(HIST("positive_eta"), postrack1.eta()); + // rKzeroShort.fill(HIST("negative_phi"), negtrack1.phi()); + // rKzeroShort.fill(HIST("positive_phi"), postrack1.phi()); // } - if (!(std::find(v0indexes.begin(), v0indexes.end(), v1.globalIndex()) != v0indexes.end())) { - v0indexes.push_back(v1.globalIndex()); + if (postrack1.globalIndex() == postrack2.globalIndex()) { + continue; + } + if (negtrack1.globalIndex() == negtrack2.globalIndex()) { + continue; + } + + if (!applyAngSep(v1, v2)) { + continue; + } + + if (config.qAv0) { + rKzeroShort.fill(HIST("hMasscorrelationbefore"), v1.mK0Short(), v2.mK0Short()); + } + allConditionsMet = 1; + daughter1 = ROOT::Math::PxPyPzMVector(v1.px(), v1.py(), v1.pz(), o2::constants::physics::MassK0Short); // Kshort + daughter2 = ROOT::Math::PxPyPzMVector(v2.px(), v2.py(), v2.pz(), o2::constants::physics::MassK0Short); // Kshort + + mother = daughter1 + daughter2; // invariant mass of Kshort pair + isMix = false; + + if (!config.selectTWOKsOnly) + fillInvMass(mother, multiplicity, daughter1, daughter2, isMix); + } + int sizeofv0indexes = v0indexes.size(); + rKzeroShort.fill(HIST("NksProduced"), sizeofv0indexes); + if (config.selectTWOKsOnly && sizeofv0indexes == config.noOfDaughters && allConditionsMet) { + fillInvMass(mother, multiplicity, daughter1, daughter2, false); + } + v0indexes.clear(); + } + PROCESS_SWITCH(HigherMassResonances, processSE, "same event process", true); + + using EventCandidatesDerivedData = soa::Join; + using V0CandidatesDerivedData = soa::Join; + using DauTracks = soa::Join; + + void processSEderived(EventCandidatesDerivedData::iterator const& collision, TrackCandidates const& /*tracks*/, aod::V0Datas const& V0s) + { + hglue.fill(HIST("heventscheck"), 0.5); + multiplicity = 0.0; + if (config.cfgMultFOTM) { + multiplicity = collision.centFT0M(); + } else { + multiplicity = collision.centFT0C(); + } + if (!eventselection(collision)) { + return; + } + + if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(collision)) { + return; + } + + // auto occupancyNumber = collision.trackOccupancyInTimeRange(); + // if (applyOccupancyCut && occupancyNumber < occupancyCut) { + // return; + // } + + if (config.qAevents) { + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + rEventSelection.fill(HIST("hmultiplicity"), multiplicity); + // rEventSelection.fill(HIST("multdist_FT0M"), collision.multFT0M()); + // rEventSelection.fill(HIST("multdist_FT0A"), collision.multFT0A()); + // rEventSelection.fill(HIST("multdist_FT0C"), collision.multFT0C()); + // rEventSelection.fill(HIST("hNcontributor"), collision.numContrib()); + } + + std::vector v0indexes; + bool allConditionsMet = 0; + + for (const auto& [v1, v2] : combinations(CombinationsFullIndexPolicy(V0s, V0s))) { + + if (v1.size() == 0 || v2.size() == 0) { + continue; } - // std::cout << "global index of v1: " << v1.globalIndex() << " global index of v2: " << v2.globalIndex() << std::endl; - if (!(std::find(v0indexes.begin(), v0indexes.end(), v2.globalIndex()) != v0indexes.end())) { - v0indexes.push_back(v2.globalIndex()); + + if (!selectionV0(collision, v1, multiplicity)) { + continue; + } + if (!selectionV0(collision, v2, multiplicity)) { + continue; } - if (v1.globalIndex() == v2.globalIndex()) { + auto postrack1 = v1.template posTrack_as(); + auto negtrack1 = v1.template negTrack_as(); + auto postrack2 = v2.template posTrack_as(); + auto negtrack2 = v2.template negTrack_as(); + + double nTPCSigmaPos1{postrack1.tpcNSigmaPi()}; + double nTPCSigmaNeg1{negtrack1.tpcNSigmaPi()}; + double nTPCSigmaPos2{postrack2.tpcNSigmaPi()}; + double nTPCSigmaNeg2{negtrack2.tpcNSigmaPi()}; + + if (!(isSelectedV0Daughter(negtrack1, -1, nTPCSigmaNeg1, v1) && isSelectedV0Daughter(postrack1, 1, nTPCSigmaPos1, v1))) { + continue; + } + if (!(isSelectedV0Daughter(postrack2, 1, nTPCSigmaPos2, v2) && isSelectedV0Daughter(negtrack2, -1, nTPCSigmaNeg2, v2))) { continue; } + if (std::find(v0indexes.begin(), v0indexes.end(), v1.globalIndex()) == v0indexes.end()) { + v0indexes.push_back(v1.globalIndex()); + } + // if (!(std::find(v0indexes.begin(), v0indexes.end(), v2.globalIndex()) != v0indexes.end())) { + // v0indexes.push_back(v2.globalIndex()); + // } + + if (v2.globalIndex() <= v1.globalIndex()) { + continue; + } + + // if (config.qAv0Daughters) { + // rKzeroShort.fill(HIST("negative_pt"), negtrack1.pt()); + // rKzeroShort.fill(HIST("positive_pt"), postrack1.pt()); + // rKzeroShort.fill(HIST("negative_eta"), negtrack1.eta()); + // rKzeroShort.fill(HIST("positive_eta"), postrack1.eta()); + // rKzeroShort.fill(HIST("negative_phi"), negtrack1.phi()); + // rKzeroShort.fill(HIST("positive_phi"), postrack1.phi()); + // } + if (postrack1.globalIndex() == postrack2.globalIndex()) { continue; } @@ -651,90 +962,185 @@ struct HigherMassResonances { continue; } - TLorentzVector lv1, lv2, lv3, lv4, lv5; + if (!applyAngSep(v1, v2)) { + continue; + } + + if (config.qAv0) { + rKzeroShort.fill(HIST("hMasscorrelationbefore"), v1.mK0Short(), v2.mK0Short()); + } + allConditionsMet = 1; + daughter1 = ROOT::Math::PxPyPzMVector(v1.px(), v1.py(), v1.pz(), o2::constants::physics::MassK0Short); // Kshort + daughter2 = ROOT::Math::PxPyPzMVector(v2.px(), v2.py(), v2.pz(), o2::constants::physics::MassK0Short); // Kshort - lv1.SetPtEtaPhiM(v1.pt(), v1.eta(), v1.phi(), massK0s); + mother = daughter1 + daughter2; // invariant mass of Kshort pair + isMix = false; + + if (!config.selectTWOKsOnly) + fillInvMass(mother, multiplicity, daughter1, daughter2, isMix); + } + int sizeofv0indexes = v0indexes.size(); + rKzeroShort.fill(HIST("NksProduced"), sizeofv0indexes); + if (config.selectTWOKsOnly && sizeofv0indexes == config.noOfDaughters && allConditionsMet) { + fillInvMass(mother, multiplicity, daughter1, daughter2, false); + } + v0indexes.clear(); + } + PROCESS_SWITCH(HigherMassResonances, processSEderived, "same event process in strangeness derived data", true); - lv2.SetPtEtaPhiM(v2.pt(), v2.eta(), v2.phi(), massK0s); + ConfigurableAxis mevz = {"mevz", {10, -10., 10.}, "mixed event vertex z binning"}; + ConfigurableAxis memult = {"memult", {20, 0, 100}, "mixed event multiplicity binning"}; - lv3 = lv1 + lv2; + // Processing Event Mixing + using BinningType = ColumnBinningPolicy; + BinningType colBinning{{mevz, memult}, true}; + Preslice tracksPerCollisionV0Mixed = o2::aod::v0data::straCollisionId; // for derived data only - daughter1 = ROOT::Math::PxPyPzMVector(v1.px(), v1.py(), v1.pz(), massK0s); // Kplus - daughter2 = ROOT::Math::PxPyPzMVector(v2.px(), v2.py(), v2.pz(), massK0s); // Kminus + void processMEderived(EventCandidatesDerivedData const& collisions, TrackCandidates const& /*tracks*/, V0CandidatesDerivedData const& v0s) + { + // auto tracksTuple = std::make_tuple(v0s); + // BinningTypeVertexContributor binningOnPositions1{{mevz, memult}, true}; + // BinningTypeCentralityM binningOnPositions2{{mevz, memult}, true}; - // polarization calculations + // SameKindPair pair1{binningOnPositions1, config.cfgNmixedEvents, -1, collisions, tracksTuple, &cache}; // for PbPb + // SameKindPair pair2{binningOnPositions2, config.cfgNmixedEvents, -1, collisions, tracksTuple, &cache}; // for pp - ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massK0s); // Kshort + // if (config.cfgMultFOTM) { + for (const auto& [c1, c2] : selfCombinations(colBinning, config.cfgNmixedEvents, -1, collisions, collisions)) // two different centrality c1 and c2 and tracks corresponding to them + { - ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of HigherMassResonances pair - ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother + multiplicity = 0.0; + multiplicity = c1.centFT0M(); - // if (counter3 < 1e3) { - // std::cout << "rapidity is " << lv3.Rapidity() << std::endl; + if (!eventselection(c1) || !eventselection(c2)) { + continue; + } + // auto occupancyNumber = c1.trackOccupancyInTimeRange(); + // auto occupancyNumber2 = c2.trackOccupancyInTimeRange(); + // if (applyOccupancyCut && (occupancyNumber < occupancyCut || occupancyNumber2 < occupancyCut)) { + // return; // } - // counter3++; - if (std::abs(lv3.Rapidity()) < 0.5) { + if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(c1)) { + return; + } + if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(c2)) { + return; + } + auto groupV01 = v0s.sliceBy(tracksPerCollisionV0Mixed, c1.index()); + auto groupV02 = v0s.sliceBy(tracksPerCollisionV0Mixed, c2.index()); + for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(groupV01, groupV02))) { - if (invMass1D) { - hglue.fill(HIST("h1glueInvMassRot"), lv3.M()); + if (t1.size() == 0 || t2.size() == 0) { + continue; } - if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame - auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); - hglue.fill(HIST("h3glueInvMassDS"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity, occupancyNumber); - for (int i = 0; i < cRrotations; i++) { - float theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); - lv4.SetPtEtaPhiM(v1.pt(), v1.eta(), v1.phi() + theta2, massK0s); // for rotated background - lv5 = lv2 + lv4; - hglue.fill(HIST("h3glueInvMassRot"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarHelicity, occupancyNumber); - } - } else if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); - auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); - hglue.fill(HIST("h3glueInvMassDS"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction, occupancyNumber); - for (int i = 0; i < cRrotations; i++) { - float theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); - lv4.SetPtEtaPhiM(v1.pt(), v1.eta(), v1.phi() + theta2, massK0s); // for rotated background - lv5 = lv2 + lv4; - hglue.fill(HIST("h3glueInvMassRot"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarProduction, occupancyNumber); - } - } else if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); - auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - hglue.fill(HIST("h3glueInvMassDS"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam, occupancyNumber); - for (int i = 0; i < cRrotations; i++) { - float theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); - lv4.SetPtEtaPhiM(v1.pt(), v1.eta(), v1.phi() + theta2, massK0s); // for rotated background - lv5 = lv2 + lv4; - hglue.fill(HIST("h3glueInvMassRot"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarBeam, occupancyNumber); - } - } else if (activateTHnSparseCosThStarRandom) { - auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); - auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); - auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - hglue.fill(HIST("h3glueInvMassDS"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom, occupancyNumber); - for (int i = 0; i < cRrotations; i++) { - float theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); - lv4.SetPtEtaPhiM(v1.pt(), v1.eta(), v1.phi() + theta2, massK0s); // for rotated background - lv5 = lv2 + lv4; - hglue.fill(HIST("h3glueInvMassRot"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarRandom, occupancyNumber); - } + if (!selectionV0(c1, t1, multiplicity)) + continue; + if (!selectionV0(c2, t2, multiplicity)) + continue; + + auto postrack1 = t1.template posTrackExtra_as(); + auto negtrack1 = t1.template negTrackExtra_as(); + auto postrack2 = t2.template posTrackExtra_as(); + auto negtrack2 = t2.template negTrackExtra_as(); + + if (postrack1.globalIndex() == postrack2.globalIndex()) { + continue; + } + if (negtrack1.globalIndex() == negtrack2.globalIndex()) { + continue; + } + double nTPCSigmaPos1{postrack1.tpcNSigmaPi()}; + double nTPCSigmaNeg1{negtrack1.tpcNSigmaPi()}; + double nTPCSigmaPos2{postrack2.tpcNSigmaPi()}; + double nTPCSigmaNeg2{negtrack2.tpcNSigmaPi()}; + + if (!isSelectedV0Daughter(postrack1, 1, nTPCSigmaPos1, t1)) { + continue; + } + if (!isSelectedV0Daughter(postrack2, 1, nTPCSigmaPos2, t2)) { + continue; } + if (!isSelectedV0Daughter(negtrack1, -1, nTPCSigmaNeg1, t1)) { + continue; + } + if (!isSelectedV0Daughter(negtrack2, -1, nTPCSigmaNeg2, t2)) { + continue; + } + + daughter1 = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassK0Short); // Kshort + daughter2 = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), o2::constants::physics::MassK0Short); // Kshort + + mother = daughter1 + daughter2; // invariant mass of Kshort pair + isMix = true; + fillInvMass(mother, multiplicity, daughter1, daughter2, isMix); } } - if (qAv0) { - int sizeofv0indexes = v0indexes.size(); - rKzeroShort.fill(HIST("NksProduced"), sizeofv0indexes); - // std::cout << "Size of v0indexes: " << sizeofv0indexes << std::endl; - } + // } + // else { + // for (const auto& [c1, tracks1, c2, tracks2] : pair1) // two different centrality c1 and c2 and tracks corresponding to them + // { + // multiplicity = 0.0f; + // multiplicity = c1.centFT0C(); + + // if (!eventselection(c1) || !eventselection(c2)) { + // continue; + // } + // // auto occupancyNumber = c1.trackOccupancyInTimeRange(); + // // auto occupancyNumber2 = c2.trackOccupancyInTimeRange(); + // // if (applyOccupancyCut && (occupancyNumber < occupancyCut || occupancyNumber2 < occupancyCut)) { + // // return; + // // } + + // for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + // if (t1.size() == 0 || t2.size() == 0) { + // continue; + // } + + // if (!selectionV0(c1, t1, multiplicity)) + // continue; + // if (!selectionV0(c2, t2, multiplicity)) + // continue; + + // auto postrack1 = t1.template posTrack_as(); + // auto negtrack1 = t1.template negTrack_as(); + // auto postrack2 = t2.template posTrack_as(); + // auto negtrack2 = t2.template negTrack_as(); + // if (postrack1.globalIndex() == postrack2.globalIndex()) { + // continue; + // } + // if (negtrack1.globalIndex() == negtrack2.globalIndex()) { + // continue; + // } + // double nTPCSigmaPos1{postrack1.tpcNSigmaPi()}; + // double nTPCSigmaNeg1{negtrack1.tpcNSigmaPi()}; + // double nTPCSigmaPos2{postrack2.tpcNSigmaPi()}; + // double nTPCSigmaNeg2{negtrack2.tpcNSigmaPi()}; + + // if (!isSelectedV0Daughter(postrack1, 1, nTPCSigmaPos1, t1)) { + // continue; + // } + // if (!isSelectedV0Daughter(postrack2, 1, nTPCSigmaPos2, t2)) { + // continue; + // } + // if (!isSelectedV0Daughter(negtrack1, -1, nTPCSigmaNeg1, t1)) { + // continue; + // } + // if (!isSelectedV0Daughter(negtrack2, -1, nTPCSigmaNeg2, t2)) { + // continue; + // } + // daughter1 = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassK0Short); // Kshort + // daughter2 = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), o2::constants::physics::MassK0Short); // Kshort + + // mother = daughter1 + daughter2; // invariant mass of Kshort pair + // isMix = true; + // fillInvMass(mother, multiplicity, daughter1, daughter2, isMix); + // } + // } + // } } - - PROCESS_SWITCH(HigherMassResonances, processSE, "same event process", true); + PROCESS_SWITCH(HigherMassResonances, processMEderived, "mixed event process in derived data", true); array pvec0; array pvec1; @@ -742,35 +1148,36 @@ struct HigherMassResonances { using BinningTypeTPCMultiplicity = ColumnBinningPolicy; using BinningTypeCentralityM = ColumnBinningPolicy; using BinningTypeVertexContributor = ColumnBinningPolicy; - ConfigurableAxis mevz = {"mevz", {10, -10., 10.}, "mixed event vertex z binning"}; - ConfigurableAxis memult = {"memult", {2000, 0, 10000}, "mixed event multiplicity binning"}; void processME(EventCandidates const& collisions, TrackCandidates const& /*tracks*/, V0TrackCandidate const& v0s) { - - // const double massK0s = TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass(); - const double massK0s = o2::constants::physics::MassK0Short; auto tracksTuple = std::make_tuple(v0s); BinningTypeVertexContributor binningOnPositions1{{mevz, memult}, true}; BinningTypeCentralityM binningOnPositions2{{mevz, memult}, true}; - SameKindPair pair1{binningOnPositions1, cfgNmixedEvents, -1, collisions, tracksTuple, &cache}; // for PbPb - SameKindPair pair2{binningOnPositions2, cfgNmixedEvents, -1, collisions, tracksTuple, &cache}; // for pp + SameKindPair pair1{binningOnPositions1, config.cfgNmixedEvents, -1, collisions, tracksTuple, &cache}; // for PbPb + SameKindPair pair2{binningOnPositions2, config.cfgNmixedEvents, -1, collisions, tracksTuple, &cache}; // for pp - if (cfgMultFOTM) { + if (config.cfgMultFOTM) { for (const auto& [c1, tracks1, c2, tracks2] : pair2) // two different centrality c1 and c2 and tracks corresponding to them { - float multiplicity = 0.0f; - + multiplicity = 0.0; multiplicity = c1.centFT0M(); - if (!eventselection(c1, multiplicity) || !eventselection(c2, multiplicity)) { + if (!eventselection(c1) || !eventselection(c2)) { continue; } - auto occupancyNumber = c1.trackOccupancyInTimeRange(); - auto occupancyNumber2 = c2.trackOccupancyInTimeRange(); - if (applyOccupancyCut && (occupancyNumber < occupancyCut || occupancyNumber2 < occupancyCut)) { + // auto occupancyNumber = c1.trackOccupancyInTimeRange(); + // auto occupancyNumber2 = c2.trackOccupancyInTimeRange(); + // if (applyOccupancyCut && (occupancyNumber < occupancyCut || occupancyNumber2 < occupancyCut)) { + // return; + // } + + if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(c1)) { + return; + } + if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(c2)) { return; } @@ -813,63 +1220,28 @@ struct HigherMassResonances { continue; } - TLorentzVector lv1, lv2, lv3; - lv1.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massK0s); - lv2.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massK0s); - lv3 = lv1 + lv2; - - ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massK0s); // Kshort - - ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of HigherMassResonances pair - ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother - - if (std::abs(lv3.Rapidity()) < 0.5) { - - if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame - auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity, occupancyNumber); - } else if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); - auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction, occupancyNumber); - } else if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); - auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam, occupancyNumber); - } else if (activateTHnSparseCosThStarRandom) { - auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); - auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); - auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom, occupancyNumber); - } - } + daughter1 = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassK0Short); // Kshort + daughter2 = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), o2::constants::physics::MassK0Short); // Kshort - // if (std::abs(lv3.Rapidity()) < 0.5) { - // if (invMass1D) { - // hglue.fill(HIST("h1glueInvMassME"), lv3.M()); - // } - // hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M()); - // } + mother = daughter1 + daughter2; // invariant mass of Kshort pair + isMix = true; + fillInvMass(mother, multiplicity, daughter1, daughter2, isMix); } } } else { for (const auto& [c1, tracks1, c2, tracks2] : pair1) // two different centrality c1 and c2 and tracks corresponding to them { - float multiplicity = 0.0f; + multiplicity = 0.0f; multiplicity = c1.centFT0C(); - if (!eventselection(c1, multiplicity) || !eventselection(c2, multiplicity)) { + if (!eventselection(c1) || !eventselection(c2)) { continue; } - auto occupancyNumber = c1.trackOccupancyInTimeRange(); - auto occupancyNumber2 = c2.trackOccupancyInTimeRange(); - if (applyOccupancyCut && (occupancyNumber < occupancyCut || occupancyNumber2 < occupancyCut)) { - return; - } + // auto occupancyNumber = c1.trackOccupancyInTimeRange(); + // auto occupancyNumber2 = c2.trackOccupancyInTimeRange(); + // if (applyOccupancyCut && (occupancyNumber < occupancyCut || occupancyNumber2 < occupancyCut)) { + // return; + // } for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { if (t1.size() == 0 || t2.size() == 0) { @@ -908,52 +1280,12 @@ struct HigherMassResonances { if (!isSelectedV0Daughter(negtrack2, -1, nTPCSigmaNeg2, t2)) { continue; } + daughter1 = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassK0Short); // Kshort + daughter2 = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), o2::constants::physics::MassK0Short); // Kshort - TLorentzVector lv1, lv2, lv3; - lv1.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massK0s); - lv2.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massK0s); - lv3 = lv1 + lv2; - - ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massK0s); // Kshort - - ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of HigherMassResonances pair - ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother - - if (std::abs(lv3.Rapidity()) < 0.5) { - - if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame - auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity, occupancyNumber); - } else if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); - auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction, occupancyNumber); - } else if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); - auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam, occupancyNumber); - } else if (activateTHnSparseCosThStarRandom) { - auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); - auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); - auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom, occupancyNumber); - } - } - - // TLorentzVector lv1, lv2, lv3; - // lv1.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massK0s); - // lv2.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massK0s); - // lv3 = lv1 + lv2; - // if (std::abs(lv3.Rapidity()) < 0.5) { - // if (invMass1D) { - // hglue.fill(HIST("h1glueInvMassME"), lv3.M()); - // } - // hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M()); - // } + mother = daughter1 + daughter2; // invariant mass of Kshort pair + isMix = true; + fillInvMass(mother, multiplicity, daughter1, daughter2, isMix); } } } @@ -961,11 +1293,18 @@ struct HigherMassResonances { PROCESS_SWITCH(HigherMassResonances, processME, "mixed event process", true); int counter = 0; + float multiplicityGen = 0.0; + std::vector passKs; + ROOT::Math::PxPyPzMVector lResonanceGen1; + ROOT::Math::PxPyPzEVector lResonanceGen; + void processGen(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& collisions) { - TLorentzVector genvec; + if (config.isMC == false) { + return; + } hMChists.fill(HIST("events_check"), 0.5); - if (std::abs(mcCollision.posZ()) < cutzvertex) { + if (std::abs(mcCollision.posZ()) < config.cutzvertex) { hMChists.fill(HIST("events_check"), 1.5); } // int Nchinel = 0; @@ -977,114 +1316,147 @@ struct HigherMassResonances { // } // } // } - // if (Nchinel > 0 && std::abs(mcCollision.posZ()) < cutzvertex) + // if (Nchinel > 0 && std::abs(mcCollision.posZ()) < config.cutzvertex) hMChists.fill(HIST("events_check"), 2.5); std::vector selectedEvents(collisions.size()); int nevts = 0; + multiplicityGen = 0.0; for (const auto& collision : collisions) { - if (std::abs(collision.mcCollision().posZ()) > cutzvertex) { + if (std::abs(collision.mcCollision().posZ()) > config.cutzvertex) { continue; } - if (timFrameEvsel && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + if (config.timFrameEvsel && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { continue; } - if (cTVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { + if (config.cTVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { continue; } + multiplicityGen = collision.centFT0M(); + selectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); } selectedEvents.resize(nevts); hMChists.fill(HIST("events_check"), 3.5); - // const auto evtReconstructedAndSelected = std::find(selectedEvents.begin(), selectedEvents.end(), mcCollision.globalIndex()) != selectedEvents.end(); + const auto evtReconstructedAndSelected = std::find(selectedEvents.begin(), selectedEvents.end(), mcCollision.globalIndex()) != selectedEvents.end(); - // if (!allGenCollisions && !evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection - // return; - // } + if (!config.allGenCollisions && !evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection + return; + } hMChists.fill(HIST("events_check"), 4.5); for (const auto& mcParticle : mcParticles) { - if (std::abs(mcParticle.y()) >= 0.5) { + + if (std::abs(mcParticle.pdgCode()) != config.pdgCodes[config.selectMCparticles]) // f2(1525), f0(1710) + { continue; } hMChists.fill(HIST("events_check"), 5.5); - // if (counter < 1e4) { - // std::cout << "PDG code mother " << mcParticle.pdgCode() << std::endl; - // } - // counter++; - if (std::abs(mcParticle.pdgCode()) != 10331) // f2(1525), f0(1710) - { + if (config.applyRapidityMC && std::abs(mcParticle.y()) >= config.rapidityMotherData) { continue; } hMChists.fill(HIST("events_check"), 6.5); + // if (counter < 1e3) + // std::cout << "px " << mcParticle.px() << " py " << mcParticle.py() << " pz " << mcParticle.pz() << " y " << mcParticle.y() << std::endl; + // counter++; + auto kDaughters = mcParticle.daughters_as(); - if (kDaughters.size() != 2) { + if (kDaughters.size() != config.noOfDaughters) { continue; } hMChists.fill(HIST("events_check"), 7.5); - auto passKs = false; for (const auto& kCurrentDaughter : kDaughters) { // int daupdg = std::abs(kCurrentDaughter.pdgCode()); - // if (counter < 1e4) - // std::cout << "Daughter pdg code: " << daupdg << std::endl; - // counter++; if (!kCurrentDaughter.isPhysicalPrimary()) { continue; } hMChists.fill(HIST("events_check"), 8.5); - - if (std::abs(kCurrentDaughter.pdgCode()) == 310) { - passKs = true; + if (std::abs(kCurrentDaughter.pdgCode()) == PDG_t::kK0Short) { + passKs.push_back(true); hMChists.fill(HIST("events_check"), 9.5); + if (passKs.size() == 1) { + daughter1 = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassK0Short); + } else if (static_cast(passKs.size()) == config.noOfDaughters) { + daughter2 = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassK0Short); + } } } - if (passKs) { - genvec.SetPtEtaPhiE(mcParticle.pt(), mcParticle.eta(), mcParticle.phi(), mcParticle.e()); - hMChists.fill(HIST("Genf1710"), mcParticle.pt()); - hMChists.fill(HIST("Genf1710_mass"), genvec.M()); + if (static_cast(passKs.size()) == config.noOfDaughters) { + lResonanceGen = ROOT::Math::PxPyPzEVector(mcParticle.pt(), mcParticle.eta(), mcParticle.phi(), mcParticle.e()); + lResonanceGen1 = daughter1 + daughter2; + + ROOT::Math::Boost boost{lResonanceGen.BoostToCM()}; + ROOT::Math::Boost boost1{lResonanceGen1.BoostToCM()}; + + fourVecDauCM = boost(daughter1); + fourVecDauCM1 = boost1(daughter1); + + auto helicityGen = lResonanceGen.Vect().Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(lResonanceGen.Vect().Mag2())); + auto helicityGen1 = lResonanceGen1.Vect().Dot(fourVecDauCM1.Vect()) / (std::sqrt(fourVecDauCM1.Vect().Mag2()) * std::sqrt(lResonanceGen1.Vect().Mag2())); + + hMChists.fill(HIST("Genf1710"), multiplicityGen, lResonanceGen.pt(), helicityGen); + hMChists.fill(HIST("Genf1710_mass"), lResonanceGen.M()); + hMChists.fill(HIST("GenRapidity"), mcParticle.y()); + hMChists.fill(HIST("GenEta"), mcParticle.eta()); + hMChists.fill(HIST("GenPhi"), mcParticle.phi()); + + if (config.applyPairRapidityGen && std::abs(lResonanceGen1.Rapidity()) >= config.rapidityMotherData) { + continue; + } + + hMChists.fill(HIST("Genf17102"), multiplicityGen, lResonanceGen1.pt(), helicityGen1); + hMChists.fill(HIST("Genf1710_mass2"), lResonanceGen1.M()); + hMChists.fill(HIST("GenRapidity2"), lResonanceGen1.Rapidity()); + hMChists.fill(HIST("GenEta2"), lResonanceGen1.Eta()); + hMChists.fill(HIST("GenPhi2"), lResonanceGen1.Phi()); } + passKs.clear(); // clear the vector for the next iteration } } PROCESS_SWITCH(HigherMassResonances, processGen, "Process Generated", false); - int counter2 = 0; int eventCounter = 0; std::vector gindex1, gindex2; void processRec(EventCandidatesMC::iterator const& collision, TrackCandidatesMC const&, V0TrackCandidatesMC const& V0s, aod::McParticles const&, aod::McCollisions const& /*mcCollisions*/) { + if (config.isMC == false) { + return; + } - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; - - float multiplicity = 0.0f; - multiplicity = collision.centFT0C(); - hMChists.fill(HIST("MC_mult"), multiplicity); + auto multiplicity = collision.centFT0M(); + hMChists.fill(HIST("Rec_Multiplicity"), multiplicity); hMChists.fill(HIST("events_checkrec"), 0.5); if (!collision.has_mcCollision()) { return; } hMChists.fill(HIST("events_checkrec"), 1.5); - // if (std::abs(collision.mcCollision().posZ()) > cutzvertex || !collision.sel8()) { - if (std::abs(collision.mcCollision().posZ()) > cutzvertex) { + // // if (std::abs(collision.mcCollision().posZ()) > config.cutzvertex || !collision.sel8()) { + if (std::abs(collision.mcCollision().posZ()) > config.cutzvertex) { return; } hMChists.fill(HIST("events_checkrec"), 2.5); - if (timFrameEvsel && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { - return; - } - hMChists.fill(HIST("events_checkrec"), 3.5); - if (cTVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { + // if (config.timFrameEvsel && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + // return; + // } + // hMChists.fill(HIST("events_checkrec"), 3.5); + // if (config.cTVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { + // return; + // } + + if (!collision.sel8()) { return; } hMChists.fill(HIST("events_checkrec"), 4.5); hMChists.fill(HIST("MC_mult_after_event_sel"), multiplicity); eventCounter++; + // auto oldindex = -999; for (const auto& v01 : V0s) { @@ -1117,7 +1489,6 @@ struct HigherMassResonances { double nTPCSigmaPos1[1]{postrack1.tpcNSigmaPi()}; double nTPCSigmaNeg1[1]{negtrack1.tpcNSigmaPi()}; - double nTPCSigmaPos2[1]{postrack2.tpcNSigmaPi()}; double nTPCSigmaNeg2[1]{negtrack2.tpcNSigmaPi()}; @@ -1142,7 +1513,7 @@ struct HigherMassResonances { int trackv0PDG1 = std::abs(mctrackv01.pdgCode()); int trackv0PDG2 = std::abs(mctrackv02.pdgCode()); - if (std::abs(trackv0PDG1) != 310 || std::abs(trackv0PDG2) != 310) { + if (std::abs(trackv0PDG1) != PDG_t::kK0Short || std::abs(trackv0PDG2) != PDG_t::kK0Short) { continue; } hMChists.fill(HIST("events_checkrec"), 12.5); @@ -1156,75 +1527,79 @@ struct HigherMassResonances { continue; } } - // if (counter2 < 1e4) - // std::cout << "Mother1 pdg code: " << motpdgs << " p_{T} " << mothertrack1.pt() << "Global index " << mothertrack1.globalIndex() << " event " << eventCounter << std::endl; - // counter2++; - - // int counter_check = 0; for (const auto& mothertrack2 : mctrackv02.mothers_as()) { hMChists.fill(HIST("events_checkrec"), 13.5); - if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) { + if (mothertrack1.pdgCode() != config.pdgCodes[config.selectMCparticles]) { continue; } hMChists.fill(HIST("events_checkrec"), 14.5); - // int motpdgs2 = std::abs(mothertrack2.pdgCode()); + if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) { + continue; + } + hMChists.fill(HIST("events_checkrec"), 15.5); + gindex2.push_back(mothertrack2.globalIndex()); if (gindex2.size() > 1) { if (std::find(gindex2.begin(), gindex2.end(), mothertrack2.globalIndex()) != gindex2.end()) { continue; } } - // if (counter2 < 1e4) - // std::cout << "Mother2 pdg code: " << motpdgs2 << " p_{T} " << mothertrack2.pt() << "Global index " << mothertrack1.globalIndex() << " event " << eventCounter << std::endl; - - if (mothertrack1.pdgCode() != 10331) { - continue; - } - hMChists.fill(HIST("events_checkrec"), 15.5); + hMChists.fill(HIST("events_checkrec"), 16.5); if (mothertrack1.globalIndex() != mothertrack2.globalIndex()) { continue; } - hMChists.fill(HIST("events_checkrec"), 16.5); + hMChists.fill(HIST("events_checkrec"), 17.5); if (!mothertrack1.producedByGenerator()) { continue; } - hMChists.fill(HIST("events_checkrec"), 17.5); + hMChists.fill(HIST("events_checkrec"), 18.5); - if (std::abs(mothertrack1.y()) >= 0.5) { + if (config.applyRapidityMC && std::abs(mothertrack1.y()) >= config.rapidityMotherData) { continue; } - hMChists.fill(HIST("events_checkrec"), 18.5); + hMChists.fill(HIST("events_checkrec"), 19.5); - // counter_check++; - // if (counter_check > 1) { - // std::cout << "Total mothers is " << counter_check << std::endl; + // if (config.avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { + // hMChists.fill(HIST("h1Recsplit"), mothertrack1.pt()); + // continue; // } - // std::cout << "After selection " << " p_{T} " << mothertrack2.pt() << " event " << eventCounter << std::endl; - - pvec0 = std::array{v01.px(), v01.py(), v01.pz()}; - pvec1 = std::array{v02.px(), v02.py(), v02.pz()}; - auto arrMomrec = std::array{pvec0, pvec1}; - auto motherP = mothertrack1.p(); - // auto motherE = mothertrack1.e(); - // auto genMass = std::sqrt(motherE * motherE - motherP * motherP); - auto recMass = RecoDecay::m(arrMomrec, std::array{o2::constants::physics::MassK0Short, o2::constants::physics::MassK0Short}); - // auto recpt = TMath::Sqrt((track1.px() + track2.px()) * (track1.px() + track2.px()) + (track1.py() + track2.py()) * (track1.py() + track2.py())); - //// Resonance reconstruction - lDecayDaughter1.SetXYZM(v01.px(), v01.py(), v01.pz(), o2::constants::physics::MassK0Short); - lDecayDaughter2.SetXYZM(v02.px(), v02.py(), v02.pz(), o2::constants::physics::MassK0Short); - lResonance = lDecayDaughter1 + lDecayDaughter2; - - hMChists.fill(HIST("Recf1710_p"), motherP); - hMChists.fill(HIST("Recf1710_mass"), recMass); - hMChists.fill(HIST("Recf1710_pt1"), mothertrack1.pt()); - // hMChists.fill(HIST("Genf1710_mass"), genMass); - hMChists.fill(HIST("Recf1710_pt2"), lResonance.Pt()); + // hMChists.fill(HIST("events_checkrec"), 20.5); + // oldindex = mothertrack1.globalIndex(); // split tracks is already handled using gindex1 and gindex2 + + daughter1 = ROOT::Math::PxPyPzMVector(v01.px(), v01.py(), v01.pz(), o2::constants::physics::MassK0Short); + daughter2 = ROOT::Math::PxPyPzMVector(v02.px(), v02.py(), v02.pz(), o2::constants::physics::MassK0Short); + mother = daughter1 + daughter2; + mother1 = ROOT::Math::PxPyPzEVector(mothertrack1.px(), mothertrack1.py(), mothertrack1.pz(), mothertrack1.e()); + + ROOT::Math::Boost boost{mother.BoostToCM()}; + ROOT::Math::Boost boost1{mother1.BoostToCM()}; + + fourVecDauCM = boost(daughter1); + fourVecDauCM1 = boost1(daughter1); + + auto helicityRec = mother.Vect().Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(mother.Vect().Mag2())); + + auto helicityRec2 = mother1.Vect().Dot(fourVecDauCM1.Vect()) / (std::sqrt(fourVecDauCM1.Vect().Mag2()) * std::sqrt(mother1.Vect().Mag2())); + + hMChists.fill(HIST("Recf1710_pt1"), multiplicity, mothertrack1.pt(), mother1.M(), helicityRec2); + hMChists.fill(HIST("RecRapidity"), mothertrack1.y()); + hMChists.fill(HIST("RecPhi"), mothertrack1.phi()); + hMChists.fill(HIST("RecEta"), mothertrack1.eta()); + + if (config.applyPairRapidityRec && std::abs(mother.Rapidity()) >= config.rapidityMotherData) { + continue; + } + + hMChists.fill(HIST("Recf1710_pt2"), multiplicity, mother.Pt(), mother.M(), helicityRec); + hMChists.fill(HIST("RecRapidity2"), mother.Rapidity()); + hMChists.fill(HIST("RecPhi2"), mother.Phi()); + hMChists.fill(HIST("RecEta2"), mother.Eta()); } gindex2.clear(); } diff --git a/PWGLF/Tasks/Resonances/highmasslambda.cxx b/PWGLF/Tasks/Resonances/highmasslambda.cxx index 75c41977fd5..c799c1d0ba7 100644 --- a/PWGLF/Tasks/Resonances/highmasslambda.cxx +++ b/PWGLF/Tasks/Resonances/highmasslambda.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include "TRandom3.h" #include "Math/Vector3D.h" @@ -54,67 +55,64 @@ #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Common/DataModel/PIDResponseITS.h" +// #include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/V0.h" +#include "DCAFitter/DCAFitterN.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using std::array; struct highmasslambda { - - int mRunNumber; int multEstimator; - float d_bz; Service ccdb; Service pdg; + o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + o2::vertexing::DCAFitterN<2> df; + int runNumber{0}; + double bz{0.}; - // CCDB options - // Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - // Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - // Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - // Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - // Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + // Configurable ccdbPathLut{"ccdbPathLut", "GLO/Param/MatLUT", "Path for LUT parametrization"}; + // Configurable ccdbPathGrp{"ccdbPathGrp", "GLO/GRP/GRP", "Path of the grp file (Run 2)"}; + Configurable ccdbPathGrpMag{"ccdbPathGrpMag", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object (Run 3)"}; + // Configurable isRun2{"isRun2", false, "enable Run 2 or Run 3 GRP objects for magnetic field"}; + Configurable cnfabsdca{"cnfabsdca", false, "Use Abs DCA for secondary vertex fitting"}; // fill output - Configurable fillQA{"fillQA", false, "fillQA"}; - Configurable useSP{"useSP", false, "useSP"}; - Configurable useSignDCAV0{"useSignDCAV0", true, "useSignDCAV0"}; - Configurable fillDefault{"fillDefault", false, "fill Occupancy"}; Configurable cfgOccupancyCut{"cfgOccupancyCut", 2500, "Occupancy cut"}; - Configurable fillDecayLength{"fillDecayLength", true, "fill decay length"}; - Configurable fillPolarization{"fillPolarization", false, "fill polarization"}; Configurable fillRotation{"fillRotation", false, "fill rotation"}; + Configurable useSP{"useSP", false, "useSP"}; + Configurable useKshortOpti{"useKshortOpti", 1, "useKshortOpti"}; // events Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgCutCentralityMax{"cfgCutCentralityMax", 50.0f, "Accepted maximum Centrality"}; Configurable cfgCutCentralityMin{"cfgCutCentralityMin", 30.0f, "Accepted minimum Centrality"}; + Configurable additionalEvSel{"additionalEvSel", true, "additionalEvSel"}; // proton track cut - Configurable rejectPID{"rejectPID", true, "pion, kaon, electron rejection"}; - Configurable cfgCutTOFBeta{"cfgCutTOFBeta", 0.0, "cut TOF beta"}; - Configurable ispTdifferentialDCA{"ispTdifferentialDCA", true, "is pT differential DCA"}; - Configurable isPVContributor{"isPVContributor", true, "is PV contributor"}; Configurable confMinRot{"confMinRot", 5.0 * TMath::Pi() / 6.0, "Minimum of rotation"}; Configurable confMaxRot{"confMaxRot", 7.0 * TMath::Pi() / 6.0, "Maximum of rotation"}; Configurable confRapidity{"confRapidity", 0.8, "cut on Rapidity"}; - Configurable cfgCutPT{"cfgCutPT", 0.3, "PT cut on daughter track"}; + Configurable cfgCutPT{"cfgCutPT", 0.4, "PT cut on daughter track"}; Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; Configurable cfgCutDCAxymin1{"cfgCutDCAxymin1", 0.005f, "Minimum DCAxy range for tracks pt 0 to 0.5"}; Configurable cfgCutDCAxymin2{"cfgCutDCAxymin2", 0.003f, "Minimum DCAxy range for tracks pt 0.5 to 1"}; Configurable cfgCutDCAxymin3{"cfgCutDCAxymin3", 0.003f, "Minimum DCAxy range for tracks pt 1.0 to 1.5"}; Configurable cfgCutDCAxymin4{"cfgCutDCAxymin4", 0.002f, "Minimum DCAxy range for tracks pt 1.5 to 2.0"}; - Configurable cfgCutDCAxymin5{"cfgCutDCAxymin5", 0.001f, "Minimum DCAxy range for tracks pt 2.0 to 2.5"}; - Configurable cfgCutDCAxymin6{"cfgCutDCAxymin6", 0.0003f, "Minimum DCAxy range for tracks pt 2.5 to 3.0"}; - Configurable cfgCutDCAxymin7{"cfgCutDCAxymin7", 0.0003f, "Minimum DCAxy range for tracks pt 3.0 to 4.0"}; - Configurable cfgCutDCAxymin8{"cfgCutDCAxymin8", 0.0003f, "Minimum DCAxy range for tracks pt 4.0 to 10.0"}; + Configurable cfgCutDCAxymin5{"cfgCutDCAxymin5", 0.001f, "Minimum DCAxy range for tracks pt 2.0 to 1000.5"}; Configurable cfgCutDCAxy{"cfgCutDCAxy", 0.1f, "DCAxy range for tracks"}; Configurable cfgCutDCAz{"cfgCutDCAz", 1.0f, "DCAz range for tracks"}; Configurable cfgITScluster{"cfgITScluster", 5, "Number of ITS cluster"}; Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; - Configurable PIDstrategy{"PIDstrategy", 0, "0: TOF Veto, 1: TOF Veto opti, 2: TOF, 3: TOF loose 1, 4: TOF loose 2, 5: old pt dep"}; + Configurable PIDstrategy{"PIDstrategy", 0, "0: default p dep TPC and TOF (TOF no mandatory), 1: 7 with relax TOF, 2: 7 with relax TPC and TOF, 3: TOF mandatory"}; Configurable nsigmaCutTPC{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"}; Configurable nsigmaCutTOF{"nsigmaCutTOF", 3.0, "TOF PID"}; - Configurable nsigmaCutTPCPre{"nsigmacutTPCPre", 3.0, "Value of the TPC Nsigma cut Pre filter"}; - Configurable minnsigmaCutTPCPre{"minnsigmacutTPCPre", -2.0, "Minimum Value of the TPC Nsigma cut Pre filter"}; - Configurable kaonrejpar{"kaonrejpar", 1.0, "Kaon rej. par"}; + Configurable nsigmaCutITS{"nsigmaCutITS", 3.0, "Value of the ITS Nsigma cut"}; + // Configs for V0 Configurable ConfV0PtMin{"ConfV0PtMin", 0.f, "Minimum transverse momentum of V0"}; Configurable ConfV0DCADaughMax{"ConfV0DCADaughMax", 0.2f, "Maximum DCA between the V0 daughters"}; @@ -127,137 +125,122 @@ struct highmasslambda { Configurable cMinLambdaMass{"cMinLambdaMass", 2.18, "Minimum lambda mass"}; Configurable cMaxLambdaMass{"cMaxLambdaMass", 2.42, "Maximum lambda mass"}; // config for V0 daughters - Configurable ConfDaughEta{"ConfDaughEta", 0.8f, "V0 Daugh sel: max eta"}; - Configurable ConfDaughPt{"ConfDaughPt", 0.1f, "V0 Daugh sel: min pt"}; - Configurable ConfDaughTPCnclsMin{"ConfDaughTPCnclsMin", 50.f, "V0 Daugh sel: Min. nCls TPC"}; Configurable ConfDaughDCAMin{"ConfDaughDCAMin", 0.08f, "V0 Daugh sel: Max. DCA Daugh to PV (cm)"}; Configurable ConfDaughPIDCuts{"ConfDaughPIDCuts", 3, "PID selections for KS0 daughters"}; - // Fill strategy - // Configurable cfgSelectDaughterTopology{"cfgSelectDaughterTopology", 2, "Select daughter for topology"}; + // config SVx + Configurable ConfMaxDecayLength{"ConfMaxDecayLength", 0.1f, "Maximum decay length (cm)"}; + Configurable ConfMinCPA{"ConfMinCPA", 0.9f, "Minimum CPA"}; // Mixed event Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 1, "Number of mixed events per event"}; /// activate rotational background Configurable nBkgRotations{"nBkgRotations", 9, "Number of rotated copies (background) per each original candidate"}; - // THnsparse bining ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {60, 2.15, 2.45}, "#it{M} (GeV/#it{c}^{2})"}; - ConfigurableAxis configThnAxisPt{"configThnAxisPt", {24, 1.0, 25.}, "#it{p}_{T} (GeV/#it{c})"}; - ConfigurableAxis configThnAxisCosThetaStar{"configThnAxisCosThetaStar", {10, -1.0, 1.}, "cos(#vartheta)"}; - ConfigurableAxis configThnAxisCentrality{"configThnAxisCentrality", {1, 30., 50}, "Centrality"}; - ConfigurableAxis configThnAxisPhiminusPsi{"configThnAxisPhiminusPsi", {6, 0.0, TMath::Pi()}, "#phi - #psi"}; + ConfigurableAxis configThnAxisPt{"configThnAxisPt", {5, 1.0, 6.}, "#it{p}_{T} (GeV/#it{c})"}; ConfigurableAxis configThnAxisV2{"configThnAxisV2", {80, -1, 1}, "V2"}; - ConfigurableAxis configThnAxisSA{"configThnAxisSA", {100, -1, 1}, "SA"}; - ConfigurableAxis cnfigThnAxisDecayLength{"cnfigThnAxisDecayLength", {150, 0.0, 0.3}, "SA"}; - ConfigurableAxis cnfigThnAxisDCASum{"cnfigThnAxisDCASum", {150, -0.3, 0.3}, "SA"}; + ConfigurableAxis cnfigThnAxisDCA{"cnfigThnAxisDCA", {100, 0.0, 0.1}, "DCA"}; + ConfigurableAxis cnfigThnAxisDecayLength{"cnfigThnAxisDecayLength", {150, 0.0, 0.3}, "decay length"}; ConfigurableAxis cnfigThnAxisPtProton{"cnfigThnAxisPtProton", {16, 0.0, 8.0}, "pT"}; - ConfigurableAxis configThnAxisSP{"configThnAxisSP", {400, -12, 12}, "SP"}; + ConfigurableAxis cnfigThnAxisCPA{"cnfigThnAxisCPA", {300, 0.8, 1.1}, "CPA"}; + // ConfigurableAxis configThnAxisCosThetaStar{"configThnAxisCosThetaStar", {10, -1.0, 1.}, "cos(#vartheta)"}; + // ConfigurableAxis configThnAxisSA{"configThnAxisSA", {100, -1, 1}, "SA"}; Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter centralityFilter = (nabs(aod::cent::centFT0C) < cfgCutCentralityMax && nabs(aod::cent::centFT0C) > cfgCutCentralityMin); Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPT); Filter dcaCutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); - Filter pidFilter = aod::pidtpc::tpcNSigmaPr > minnsigmaCutTPCPre&& aod::pidtpc::tpcNSigmaPr < nsigmaCutTPCPre; + Filter pidFilter = nabs(aod::pidtpc::tpcNSigmaPr) < nsigmaCutTPC; using EventCandidates = soa::Filtered>; - using TrackCandidates = soa::Filtered>; + + using TrackCandidates = soa::Filtered>; using AllTrackCandidates = soa::Join; using ResoV0s = aod::V0Datas; + using TrackCandidatesSvx = soa::Filtered>; + using AllTrackCandidatesSvx = soa::Join; + using ResoV0sSvx = soa::Join; + SliceCache cache; - // Partition posTracks = aod::track::signed1Pt > cfgCutCharge; - // Partition negTracks = aod::track::signed1Pt < cfgCutCharge; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(o2::framework::InitContext&) { - std::vector occupancyBinning = {0.0, 500.0, 1000.0, 1500.0, 2000.0, 3000.0, 4000.0, 5000.0, 50000.0}; + // std::vector dcaBinning = {0.0, 0.0005, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.012, 0.014, 0.016, 0.02, 0.03, 0.05, 0.1, 0.5, 1.0}; - std::vector dcaBinning = {0.0, 0.0005, 0.001, 0.0012, 0.0014, 0.0016, 0.002, 0.0025, 0.003, 0.004, 0.005, 0.006, 0.008, 0.01, 0.015, 0.02, 0.04, 0.05, 0.06, 0.08, 0.1, 0.3, 1.0}; - std::vector ptProtonBinning = {0.2, 0.3, 0.5, 0.6, 0.8, 1.2, 1.4, 1.6, 2.0, 3.0, 4.0, 6.0}; - std::vector ptLambdaBinning = {2.0, 3.0, 4.0, 5.0, 6.0}; + // std::vector dcaBinning = {0.0, 0.0005, 0.001, 0.0012, 0.0014, 0.0016, 0.002, 0.0025, 0.003, 0.004, 0.005, 0.006, 0.008, 0.01, 0.015, 0.02, 0.04, 0.05, 0.06, 0.08, 0.1, 0.3, 1.0}; + // std::vector ptProtonBinning = {0.2, 0.3, 0.5, 0.6, 0.8, 1.2, 1.4, 1.6, 2.0, 3.0, 4.0, 6.0}; + // std::vector ptLambdaBinning = {2.0, 3.0, 4.0, 5.0, 6.0}; + std::vector occupancyBinning = {-0.5, 500.0, 1000.0, 1500.0, 2000.0, 3000.0, 4000.0, 5000.0, 50000.0}; + std::vector dcaV0toPVBinning = {0.0, 0.1, 0.2, 0.3, 0.5, 3.0, 100.0}; + std::vector cpaV0Binning = {0.995, 0.996, 0.997, 0.998, 0.999, 0.9995, 0.9997, 0.9999, 1.005}; + std::vector ptV0Binning = {0.0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.5, 100.0}; + std::vector dcaBetweenV0 = {0.0, 0.05, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0}; + std::vector dcaBetweenProtonV0 = {-2.0, -1.0, -0.5, -0.4, -0.3, -0.2, -0.18, -0.16, -0.14, -0.12, -0.1, -0.08, -0.06, -0.05, -0.04, -0.03, -0.025, -0.02, -0.01, -0.005, -0.004, -0.003, -0.003, -0.002, -0.001, 0.0, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.01, 0.012, 0.014, 0.016, 0.018, 0.02, 0.025, 0.03, 0.04, 0.05, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.3, 0.4, 0.5, 1.0, 2.0}; + std::vector nsigmaKaon = {-0.1, 0.0, 0.005, 0.01, 0.03, 0.05, 0.1, 0.15, 0.2, 0.5, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 20.0, 100.0, 1000.0}; + AxisSpec resAxis = {1600, -30, 30, "Res"}; + AxisSpec phiAxis = {500, -6.28, 6.28, "phi"}; + AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; + AxisSpec dcaV0toPVAxis = {dcaV0toPVBinning, "dcaV0toPV"}; const AxisSpec thnAxisInvMass{configThnAxisInvMass, "#it{M} (GeV/#it{c}^{2})"}; const AxisSpec thnAxisPt{configThnAxisPt, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec thnAxisCosThetaStar{configThnAxisCosThetaStar, "cos(#vartheta)"}; - const AxisSpec thnAxisPhiminusPsi{configThnAxisPhiminusPsi, "#phi - #psi"}; - const AxisSpec thnAxisCentrality{configThnAxisCentrality, "Centrality (%)"}; const AxisSpec thnAxisV2{configThnAxisV2, "V2"}; - const AxisSpec thnAxisSA{configThnAxisSA, "SA"}; + const AxisSpec thnAxisDCA{cnfigThnAxisDCA, "DCAxy"}; const AxisSpec thnAxisDecayLength{cnfigThnAxisDecayLength, "Decay Length"}; - const AxisSpec thnAxisDCASum{cnfigThnAxisDCASum, "DCA Sum"}; const AxisSpec thnAxisPtProton{cnfigThnAxisPtProton, "Proton Pt"}; - const AxisSpec thnAxisSP{configThnAxisSP, "SP"}; - - AxisSpec phiAxis = {500, -6.28, 6.28, "phi"}; - AxisSpec resAxis = {1000, -10, 10, "Res"}; - AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; - // AxisSpec ptProtonAxis = {16, 0.0, 8, "V0M (%)"}; - AxisSpec dcaAxis = {dcaBinning, "DCAxy"}; - AxisSpec dcatoPVAxis = {50, 0.0, 0.5, "V0M (%)"}; + const AxisSpec thnAxisCPA{cnfigThnAxisCPA, "CPA"}; AxisSpec occupancyAxis = {occupancyBinning, "occupancy"}; - AxisSpec ptProtonAxis = {ptProtonBinning, "pT proton"}; - histos.add("hMomCorr", "hMomCorr", kTH3F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}, {8, 0.0f, 80.0f}}); + // const AxisSpec thnAxisCosThetaStar{configThnAxisCosThetaStar, "cos(#vartheta)"}; + // const AxisSpec thnAxisPhiminusPsi{configThnAxisPhiminusPsi, "#phi - #psi"}; + // const AxisSpec thnAxisCentrality{configThnAxisCentrality, "Centrality (%)"}; + // const AxisSpec thnAxisSA{configThnAxisSA, "SA"}; + + histos.add("hMomCorr", "hMomCorr", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}); histos.add("hInvMassKs0", "hInvMassKs0", kTH1F, {{200, 0.4f, 0.6f}}); + histos.add("hInvMassKs0before", "hInvMassKs0before", kTH1F, {{200, 0.4f, 0.6f}}); + histos.add("hInvMassKs0before2", "hInvMassKs0before2", kTH1F, {{200, 0.4f, 0.6f}}); + histos.add("hInvMassKs0before3", "hInvMassKs0before3", kTH1F, {{200, 0.4f, 0.6f}}); histos.add("hV0Dca", "hV0Dca", kTH1F, {{2000, -1.0f, 1.0f}}); histos.add("hpTvsRapidity", "pT vs Rapidity", kTH2F, {{100, 0.0f, 10.0f}, {300, -1.5f, 1.5f}}); - histos.add("hFTOCvsTPCNoCut", "Mult correlation FT0C vs. TPC without any cut", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); - histos.add("hFTOCvsTPC", "Mult correlation FT0C vs. TPC", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); - histos.add("hFTOCvsTPCSelected", "Mult correlation FT0C vs. TPC after selection", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); histos.add("hCentrality", "Centrality distribution", kTH1F, {{200, 0.0, 200.0}}); histos.add("hVtxZ", "Vertex distribution in Z;Z (cm)", kTH1F, {{400, -20.0, 20.0}}); - histos.add("hOccupancy", "Occupancy", kTH1F, {{5000, 0.0, 50000.0}}); + histos.add("hOccupancy", "Occupancy", kTH1F, {{5000, -0.5, 50000.5}}); histos.add("hRotation", "hRotation", kTH1F, {{360, 0.0, 2.0 * TMath::Pi()}}); histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); - histos.add("hDcaxy", "Dcaxy distribution", kTH1F, {{1000, -0.5f, 0.5f}}); - histos.add("hDcaz", "Dcaz distribution", kTH1F, {{1000, -0.5f, 0.5f}}); - histos.add("hNsigmaProtonTPCDiff", "Difference NsigmaProton NsigmaKaon TPC distribution", kTH3F, {{100, -5.0f, 5.0f}, {100, -5.0f, 5.0f}, {80, 0.0f, 8.0f}}); - - histos.add("hNsigmaProtonElectronTPC", "NsigmaProton-Electron TPC distribution", kTH3F, {{60, -3.0f, 3.0f}, {200, -10.0f, 10.0f}, {60, 0.0f, 6.0f}}); - histos.add("hNsigmaProtonPionTPC", "NsigmaProton-Pion TPC distribution", kTH3F, {{60, -3.0f, 3.0f}, {200, -10.0f, 10.0f}, {60, 0.0f, 6.0f}}); - histos.add("hNsigmaProtonKaonTPC", "NsigmaProton-Kaon TPC distribution", kTH3F, {{60, -3.0f, 3.0f}, {200, -10.0f, 10.0f}, {60, 0.0f, 6.0f}}); - - histos.add("hNsigmaProtonElectronTPC_afterKa", "NsigmaProton-Electron TPC distribution", kTH3F, {{60, -3.0f, 3.0f}, {200, -10.0f, 10.0f}, {60, 0.0f, 6.0f}}); - histos.add("hNsigmaProtonPionTPC_afterKa", "NsigmaProton-Pion TPC distribution", kTH3F, {{60, -3.0f, 3.0f}, {200, -10.0f, 10.0f}, {60, 0.0f, 6.0f}}); - histos.add("hNsigmaProtonKaonTPC_afterKa", "NsigmaProton-Kaon TPC distribution", kTH3F, {{60, -3.0f, 3.0f}, {200, -10.0f, 10.0f}, {60, 0.0f, 6.0f}}); - + histos.add("hDcaxy", "Dcaxy distribution", kTH2F, {{1000, -0.5f, 0.5f}, {100, 0.0f, 10.0f}}); + histos.add("hDcaz", "Dcaz distribution", kTH2F, {{1000, -0.5f, 0.5f}, {100, 0.0f, 10.0f}}); + histos.add("hNsigmaProtonITS", "NsigmaProton ITS distribution", kTH2F, {{100, -5.0f, 5.0f}, {60, 0.0f, 6.0f}}); histos.add("hNsigmaProtonTPC", "NsigmaProton TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {60, 0.0f, 6.0f}}); histos.add("hNsigmaProtonTOF", "NsigmaProton TOF distribution", kTH2F, {{1000, -50.0f, 50.0f}, {60, 0.0f, 6.0f}}); - histos.add("hNsigmaProtonTOFPre", "NsigmaProton TOF distribution Pre sel", kTH2F, {{1000, -50.0f, 50.0f}, {60, 0.0f, 6.0f}}); - histos.add("hMassvsDecaySum", "hMassvsDecaySum", kTH2F, {thnAxisInvMass, thnAxisDCASum}); + histos.add("hNsigmaProtonTPCPre", "NsigmaProton TPC distribution Pre sel", kTH2F, {{1000, -50.0f, 50.0f}, {60, 0.0f, 6.0f}}); histos.add("hPsiFT0C", "PsiFT0C", kTH3F, {centAxis, phiAxis, occupancyAxis}); histos.add("hPsiFT0A", "PsiFT0A", kTH3F, {centAxis, phiAxis, occupancyAxis}); histos.add("hPsiTPC", "PsiTPC", kTH3F, {centAxis, phiAxis, occupancyAxis}); - histos.add("hPsiTPCR", "PsiTPCR", kTH3F, {centAxis, phiAxis, occupancyAxis}); - histos.add("hPsiTPCL", "PsiTPCL", kTH3F, {centAxis, phiAxis, occupancyAxis}); - - if (fillDefault) { - histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcaAxis, ptProtonAxis}); - histos.add("hSparseV2SASameEventRotational_V2", "hSparseV2SASameEventRotational", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcaAxis, ptProtonAxis}); - histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcaAxis, ptProtonAxis}); - } - if (fillDecayLength) { - histos.add("hSparseV2SASameEvent_V2_dcatopv", "hSparseV2SASameEvent_V2_dcatopv", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcatoPVAxis, ptProtonAxis}); - histos.add("hSparseV2SASameEventRotational_V2_dcatopv", "hSparseV2SASameEventRotational_V2_dcatopv", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcatoPVAxis, ptProtonAxis}); - histos.add("hSparseV2SAMixedEvent_V2_dcatopv", "hSparseV2SAMixedEvent_V2_dcatopv", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcatoPVAxis, ptProtonAxis}); - } - if (fillPolarization) { - histos.add("hSparseV2SASameEventplus_SA", "hSparseV2SASameEventplus_SA", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEventplus_SA_A0", "hSparseV2SASameEventplus_SA_A0", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEventplus_SA_azimuth", "hSparseV2SASameEventplus_SA_azimuth", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisCentrality}); - histos.add("hSparseV2SASameEventminus_SA", "hSparseV2SASameEventminus_SA", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEventminus_SA_A0", "hSparseV2SASameEventminus_SA_A0", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEventminus_SA_azimuth", "hSparseV2SASameEventminus_SA_azimuth", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisCentrality}); - - histos.add("hSparseV2SAMixedEventplus_SA", "hSparseV2SAMixedEventplus_SA", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEventplus_SA_A0", "hSparseV2SAMixedEventplus_SA_A0", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEventplus_SA_azimuth", "hSparseV2SAMixedEventplus_SA_azimuth", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEventminus_SA", "hSparseV2SAMixedEventminus_SA", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEventminus_SA_A0", "hSparseV2SAMixedEventminus_SA_A0", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEventminus_SA_azimuth", "hSparseV2SAMixedEventminus_SA_azimuth", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSA, thnAxisCentrality}); - } + // SVX histo + histos.add("hDecayLengthxy", "Decay length xy", kTH1F, {{500, 0.0f, 0.1f}}); + histos.add("hDecayLength", "Decay length", kTH1F, {{500, 0.0f, 0.1f}}); + histos.add("hImpactPar0", "hImpactPar0", kTH1F, {{500, 0.0f, 0.1f}}); + histos.add("hImpactPar1", "hImpactPar1", kTH1F, {{500, 0.0f, 0.1f}}); + histos.add("hCPA", "hCPA", kTH1F, {{220, -1.1f, 1.1f}}); + histos.add("hSparseV2SASameEvent_V2_SVX", "hSparseV2SASameEvent_V2_SVX", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisDecayLength, thnAxisCPA}); + histos.add("hSparseV2SASameEventRotational_V2_SVX", "hSparseV2SASameEventRotational_SVX", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisDecayLength, thnAxisCPA}); + histos.add("hSparseV2SASameEventRotational_V2", "hSparseV2SASameEventRotational", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2}); + if (useKshortOpti == 0) { + histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisDCA, thnAxisPtProton}); + histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisDCA, thnAxisPtProton}); + } + if (useKshortOpti == 1) { + histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, dcaV0toPVBinning, cpaV0Binning, ptV0Binning, dcaBetweenV0, dcaBetweenProtonV0}); + histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, dcaV0toPVBinning, cpaV0Binning, ptV0Binning, dcaBetweenV0, dcaBetweenProtonV0}); + } + if (useKshortOpti == 2) { + histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisDCA, nsigmaKaon}); + histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisDCA, nsigmaKaon}); + } // histogram for resolution histos.add("ResFT0CTPC", "ResFT0CTPC", kTH2F, {centAxis, resAxis}); histos.add("ResFT0CTPCR", "ResFT0CTPCR", kTH2F, {centAxis, resAxis}); @@ -265,141 +248,104 @@ struct highmasslambda { histos.add("ResTPCRTPCL", "ResTPCRTPCL", kTH2F, {centAxis, resAxis}); histos.add("ResFT0CFT0A", "ResFT0CFT0A", kTH2F, {centAxis, resAxis}); histos.add("ResFT0ATPC", "ResFT0ATPC", kTH2F, {centAxis, resAxis}); - } - template - bool selectionTrack(const T& candidate) - { - if (isPVContributor && !(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster && candidate.itsNClsInnerBarrel() >= 1)) { - return false; - } - if (!isPVContributor && !(candidate.isGlobalTrackWoDCA() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster && candidate.itsNClsInnerBarrel() >= 1)) { - return false; - } - if (ispTdifferentialDCA) { - if (candidate.pt() > 0.0 && candidate.pt() < 0.5 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin1) { - return false; - } - if (candidate.pt() >= 0.5 && candidate.pt() < 1.0 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin2) { - return false; - } - if (candidate.pt() >= 1.0 && candidate.pt() < 1.5 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin3) { - return false; - } - if (candidate.pt() >= 1.5 && candidate.pt() < 2.0 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin4) { - return false; - } - if (candidate.pt() >= 2.0 && candidate.pt() < 2.5 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin5) { - return false; - } - if (candidate.pt() >= 2.5 && candidate.pt() < 3.0 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin6) { - return false; - } - if (candidate.pt() >= 3.0 && candidate.pt() < 4.0 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin7) { - return false; - } - if (candidate.pt() >= 4.0 && candidate.pt() < 10.0 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin8) { - return false; - } - } + df.setPropagateToPCA(true); + df.setMaxR(200); + df.setMaxDZIni(4); + df.setMinParamChange(1.e-3); + df.setMinRelChi2Change(0.9); + df.setUseAbsDCA(cnfabsdca); + df.setWeightedFinalPCA(cnfabsdca); + df.setMatCorrType(noMatCorr); - if (!ispTdifferentialDCA) { - if (candidate.pt() > 0.0 && candidate.pt() < 0.5 && TMath::Abs(candidate.dcaXY()) < 0.004) { - return false; - } - if (candidate.pt() >= 0.5 && candidate.pt() < 1.0 && TMath::Abs(candidate.dcaXY()) < 0.003) { - return false; - } - if (candidate.pt() >= 1.0 && candidate.pt() < 2.0 && TMath::Abs(candidate.dcaXY()) < 0.002) { - return false; - } - } - return true; + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + runNumber = 0; + bz = 0; } - template - bool rejectPi(const T& candidate) + bool selectionTrack(const T& candidate) { - if (candidate.tpcInnerParam() > 0.9 && candidate.tpcInnerParam() < 1.0 && candidate.tpcNSigmaPi() < 6.0) { - return false; - } - if (candidate.tpcInnerParam() > 1.0 && candidate.tpcInnerParam() < 1.1 && candidate.tpcNSigmaPi() < 4.0) { - return false; - } - if (candidate.tpcInnerParam() > 1.1 && candidate.tpcInnerParam() < 1.2 && candidate.tpcNSigmaPi() < 3.0) { + if (!(candidate.isGlobalTrackWoDCA() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsCrossedRows() > cfgTPCcluster)) { return false; } - if (candidate.tpcInnerParam() > 1.2 && candidate.tpcInnerParam() < 1.4 && candidate.tpcNSigmaPi() < 1.0) { + if (std::abs(candidate.dcaXY()) > (0.0105 + (0.035 / TMath::Power(candidate.pt(), 1.1)))) { return false; } - if (candidate.tpcInnerParam() > 1.4 && candidate.tpcInnerParam() < 1.5 && candidate.tpcNSigmaPi() < 0.5) { + if (candidate.pt() > 0.0 && candidate.pt() < 0.5 && std::abs(candidate.dcaXY()) < cfgCutDCAxymin1) { return false; } - return true; - } - - template - bool rejectEl(const T& candidate) - { - - if (candidate.tpcInnerParam() > 0.7 && candidate.tpcInnerParam() < 0.8 && candidate.tpcNSigmaEl() < 2.0) { - return false; - } - if (candidate.tpcInnerParam() > 0.8 && candidate.tpcInnerParam() < 0.9 && candidate.tpcNSigmaEl() < 0.0) { + if (candidate.pt() >= 0.5 && candidate.pt() < 1.0 && std::abs(candidate.dcaXY()) < cfgCutDCAxymin2) { return false; } - if (candidate.tpcInnerParam() > 0.9 && candidate.tpcInnerParam() < 1.0 && candidate.tpcNSigmaEl() < -1.0) { + if (candidate.pt() >= 1.0 && candidate.pt() < 1.5 && std::abs(candidate.dcaXY()) < cfgCutDCAxymin3) { return false; } - if (candidate.tpcInnerParam() > 1.0 && candidate.tpcInnerParam() < 1.1 && candidate.tpcNSigmaEl() < -2.0) { + if (candidate.pt() >= 1.5 && candidate.pt() < 2.0 && std::abs(candidate.dcaXY()) < cfgCutDCAxymin4) { return false; } - if (candidate.tpcInnerParam() > 1.1 && candidate.tpcInnerParam() < 1.2 && candidate.tpcNSigmaEl() < -3.0) { + if (candidate.pt() >= 2.0 && candidate.pt() < 10000000.0 && std::abs(candidate.dcaXY()) < cfgCutDCAxymin5) { return false; } - return true; } + // TOF Veto template - bool rejectKa(const T& candidate) + bool selectionPID1(const T& candidate) { - if (candidate.tpcInnerParam() > 0.7 && candidate.tpcInnerParam() < 0.8 && candidate.tpcNSigmaKa() < 7.5) { - return false; - } - if (candidate.tpcInnerParam() > 0.8 && candidate.tpcInnerParam() < 0.9 && candidate.tpcNSigmaKa() < 6.0) { - return false; - } - if (candidate.tpcInnerParam() > 0.9 && candidate.tpcInnerParam() < 1.1 && candidate.tpcNSigmaKa() < 5.0) { - return false; - } - if (candidate.tpcInnerParam() > 1.1 && candidate.tpcInnerParam() < 1.2 && candidate.tpcNSigmaKa() < 3.5) { - return false; - } - if (candidate.tpcInnerParam() > 1.2 && candidate.tpcInnerParam() < 1.4 && candidate.tpcNSigmaKa() < 3.0) { - return false; + if (candidate.hasTOF()) { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + if (candidate.p() >= 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } } - if (candidate.tpcInnerParam() > 1.4 && candidate.tpcInnerParam() < 1.5 && candidate.tpcNSigmaKa() < 2.5) { - return false; + if (!candidate.hasTOF()) { + if (std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } } - return true; + return false; } - // TPC TOF template - bool selectionPID1(const T& candidate) + bool selectionPID7(const T& candidate) { - if (candidate.tpcInnerParam() < 0.85 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { return true; } - if (candidate.tpcInnerParam() >= 0.85) { - if (candidate.hasTOF()) { - if (candidate.beta() > cfgCutTOFBeta && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + if (candidate.pt() >= 0.7) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + if (candidate.pt() < 2.5 && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 2.5 && candidate.pt() < 4 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 4 && candidate.pt() < 5 && candidate.tofNSigmaPr() > -1.5 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 5 && candidate.tofNSigmaPr() > -1.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { return true; } } if (!candidate.hasTOF()) { - if (candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + if (candidate.pt() >= 0.7 && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -1.8 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.8 && candidate.pt() < 0.9 && candidate.tpcNSigmaPr() > -1.7 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.9 && candidate.pt() < 1.0 && candidate.tpcNSigmaPr() > -1.6 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 1.0 && candidate.pt() < 1.8 && candidate.tpcNSigmaPr() > -0.5 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 1.8 && TMath::Abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { return true; } } @@ -407,34 +353,73 @@ struct highmasslambda { return false; } - // TOF Veto + // TPC TOF template - bool selectionPID2(const T& candidate) + bool selectionPID8(const T& candidate) { - if (candidate.tpcInnerParam() < 0.85 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { return true; } - if (candidate.tpcInnerParam() >= 0.85 && candidate.beta() > cfgCutTOFBeta && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { - return true; + if (candidate.pt() >= 0.7) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + if (candidate.pt() < 2.5 && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 2.5 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + } + if (!candidate.hasTOF()) { + if (candidate.pt() >= 0.7 && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -1.8 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.8 && candidate.pt() < 0.9 && candidate.tpcNSigmaPr() > -1.7 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.9 && candidate.pt() < 1.0 && candidate.tpcNSigmaPr() > -1.6 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 1.0 && candidate.pt() < 1.8 && candidate.tpcNSigmaPr() > -0.5 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 1.8 && TMath::Abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + } } return false; } - // TOF veto loose + // TPC TOF template - bool selectionPID3(const T& candidate) + bool selectionPID9(const T& candidate) { - if (candidate.tpcInnerParam() < 0.85 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { return true; } - if (candidate.tpcInnerParam() >= 0.85) { - if (candidate.hasTOF()) { - if (candidate.beta() > cfgCutTOFBeta && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + if (candidate.pt() >= 0.7) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + if (candidate.pt() < 2.5 && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 2.5 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { return true; } } if (!candidate.hasTOF()) { - if (candidate.tpcInnerParam() < 1.5 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + if (candidate.pt() >= 0.7 && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -1.8 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.8 && candidate.pt() < 0.9 && candidate.tpcNSigmaPr() > -1.7 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.9 && candidate.pt() < 1.0 && candidate.tpcNSigmaPr() > -1.6 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 1.0 && candidate.pt() < 1.8 && candidate.tpcNSigmaPr() > -1.5 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 1.8 && TMath::Abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { return true; } } @@ -442,38 +427,55 @@ struct highmasslambda { return false; } - // TOF veto very loose + // TPC TOF template - bool selectionPID4(const T& candidate) + bool selectionPID10(const T& candidate) { - if (candidate.tpcInnerParam() < 0.85 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.7 && candidate.pt() < 1.8 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { return true; } - if (candidate.tpcInnerParam() >= 0.85) { - if (candidate.hasTOF()) { - if (candidate.beta() > cfgCutTOFBeta && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + if (candidate.pt() >= 1.8) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + if (candidate.pt() < 2.5 && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { return true; } - } - if (!candidate.hasTOF()) { - if (candidate.tpcInnerParam() < 1.8 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + if (candidate.pt() >= 2.5 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { return true; } } + if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } } return false; } + template + double combinekaon(const T& candidate) + { + if (candidate.pt() < 0.7) { + return std::abs(candidate.tpcNSigmaKa()); + } else if (candidate.pt() >= 0.7 && candidate.hasTOF()) { + return std::sqrt((candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) / 2.0); + } else if (candidate.pt() >= 0.7 && !candidate.hasTOF()) { + return std::abs(candidate.tpcNSigmaKa()); + } + return -0.1; + } + template bool SelectionV0(Collision const& collision, V0 const& candidate) { - if (TMath::Abs(candidate.dcav0topv()) > cMaxV0DCA) { + if (std::abs(candidate.dcav0topv()) > cMaxV0DCA) { return false; } const float pT = candidate.pt(); const std::vector decVtx = {candidate.x(), candidate.y(), candidate.z()}; const float tranRad = candidate.v0radius(); - const double dcaDaughv0 = TMath::Abs(candidate.dcaV0daughters()); + const double dcaDaughv0 = std::abs(candidate.dcaV0daughters()); const double cpav0 = candidate.v0cosPA(); float CtauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass(); // FIXME: Get from the common header @@ -495,7 +497,7 @@ struct highmasslambda { if (tranRad > ConfV0TranRadV0Max) { return false; } - if (TMath::Abs(CtauK0s) > cMaxV0LifeTime || candidate.mK0Short() < lowmasscutks0 || candidate.mK0Short() > highmasscutks0) { + if (std::abs(CtauK0s) > cMaxV0LifeTime || candidate.mK0Short() < lowmasscutks0 || candidate.mK0Short() > highmasscutks0) { return false; } return true; @@ -505,7 +507,7 @@ struct highmasslambda { { const auto eta = track.eta(); const auto pt = track.pt(); - const auto tpcNClsF = track.tpcNClsFound(); + const auto tpcNClsF = track.tpcNClsCrossedRows(); const auto dcaXY = track.dcaXY(); const auto sign = track.sign(); if (charge < 0 && sign > 0) { @@ -514,19 +516,19 @@ struct highmasslambda { if (charge > 0 && sign < 0) { return false; } - if (TMath::Abs(eta) > ConfDaughEta) { + if (std::abs(eta) > 0.8) { return false; } - if (TMath::Abs(pt) < ConfDaughPt) { + if (std::abs(pt) < 0.15) { return false; } - if (tpcNClsF < ConfDaughTPCnclsMin) { + if (tpcNClsF < 50) { return false; } - if (TMath::Abs(dcaXY) < ConfDaughDCAMin) { + if (std::abs(dcaXY) < ConfDaughDCAMin) { return false; } - if (TMath::Abs(track.tpcNSigmaPi()) > ConfDaughPIDCuts) { + if (std::abs(track.tpcNSigmaPi()) > ConfDaughPIDCuts) { return false; } return true; @@ -551,19 +553,20 @@ struct highmasslambda { using BinningTypeVertexContributor = ColumnBinningPolicy; ROOT::Math::PxPyPzMVector Lambdac, Proton, Kshort, LambdacRot, KshortRot, fourVecDauCM; ROOT::Math::XYZVector threeVecDauCM, threeVecDauCMXY, eventplaneVec, eventplaneVecNorm, beamvector; - double massPi = TDatabasePDG::Instance()->GetParticle(kPiPlus)->Mass(); // FIXME: Get from the common header double massPr = TDatabasePDG::Instance()->GetParticle(kProton)->Mass(); // FIXME: Get from the common header double massK0s = TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass(); // FIXME: Get from the common header double v2, v2Rot; void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, AllTrackCandidates const&, ResoV0s const& V0s, aod::BCs const&) { - if (!collision.sel8() || !collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + if (!collision.sel8() || !collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { return; } - + if (additionalEvSel && (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + return; + } + o2::aod::ITSResponse itsResponse; auto centrality = collision.centFT0C(); - auto multTPC = collision.multNTracksPV(); - histos.fill(HIST("hFTOCvsTPCNoCut"), centrality, multTPC); + // auto multTPC = collision.multNTracksPV(); int occupancy = collision.trackOccupancyInTimeRange(); if (occupancy > cfgOccupancyCut) { return; @@ -579,14 +582,9 @@ struct highmasslambda { auto QTPC = collision.qTPC(); auto QTPCR = collision.qTPCR(); auto QTPCL = collision.qTPCL(); - - histos.fill(HIST("hFTOCvsTPC"), centrality, multTPC); - histos.fill(HIST("hFTOCvsTPCSelected"), centrality, multTPC); histos.fill(HIST("hPsiFT0C"), centrality, psiFT0C, occupancy); histos.fill(HIST("hPsiFT0A"), centrality, psiFT0A, occupancy); histos.fill(HIST("hPsiTPC"), centrality, psiTPC, occupancy); - histos.fill(HIST("hPsiTPCR"), centrality, psiTPCR, occupancy); - histos.fill(HIST("hPsiTPCL"), centrality, psiTPCL, occupancy); histos.fill(HIST("ResFT0CTPC"), centrality, QFT0C * QTPC * TMath::Cos(2.0 * (psiFT0C - psiTPC))); histos.fill(HIST("ResFT0CTPCR"), centrality, QFT0C * QTPCR * TMath::Cos(2.0 * (psiFT0C - psiTPCR))); histos.fill(HIST("ResFT0CTPCL"), centrality, QFT0C * QTPCL * TMath::Cos(2.0 * (psiFT0C - psiTPCL))); @@ -601,56 +599,50 @@ struct highmasslambda { if (!selectionTrack(track1)) { continue; } - // PID check - if (PIDstrategy == 0 && !selectionPID1(track1)) { + histos.fill(HIST("hNsigmaProtonITS"), itsResponse.nSigmaITS(track1), track1.pt()); + if (track1.pt() <= 0.6 && !(itsResponse.nSigmaITS(track1) > -2.0)) { continue; } - if (PIDstrategy == 1 && !selectionPID2(track1)) { + if (track1.pt() > 0.6 && track1.pt() <= 0.8 && !(itsResponse.nSigmaITS(track1) > -1.5)) { continue; } - if (PIDstrategy == 2 && !selectionPID3(track1)) { + histos.fill(HIST("hNsigmaProtonTPCPre"), track1.tpcNSigmaPr(), track1.pt()); + if (PIDstrategy == 0 && !selectionPID7(track1)) { continue; } - if (PIDstrategy == 3 && !selectionPID4(track1)) { + if (PIDstrategy == 1 && !selectionPID8(track1)) { continue; } - - if (track1.hasTOF()) { - histos.fill(HIST("hNsigmaProtonTOFPre"), track1.tofNSigmaPr(), track1.pt()); + if (PIDstrategy == 2 && !selectionPID9(track1)) { + continue; } - if (!track1.hasTOF()) { - if (fillQA) { - histos.fill(HIST("hNsigmaProtonElectronTPC"), track1.tpcNSigmaPr(), track1.tpcNSigmaEl(), track1.tpcInnerParam()); - histos.fill(HIST("hNsigmaProtonPionTPC"), track1.tpcNSigmaPr(), track1.tpcNSigmaPi(), track1.tpcInnerParam()); - histos.fill(HIST("hNsigmaProtonKaonTPC"), track1.tpcNSigmaPr(), track1.tpcNSigmaKa(), track1.tpcInnerParam()); - } - if (rejectPID && !rejectKa(track1)) { - continue; - } - if (fillQA) { - histos.fill(HIST("hNsigmaProtonElectronTPC_afterKa"), track1.tpcNSigmaPr(), track1.tpcNSigmaEl(), track1.tpcInnerParam()); - histos.fill(HIST("hNsigmaProtonPionTPC_afterKa"), track1.tpcNSigmaPr(), track1.tpcNSigmaPi(), track1.tpcInnerParam()); - histos.fill(HIST("hNsigmaProtonKaonTPC_afterKa"), track1.tpcNSigmaPr(), track1.tpcNSigmaKa(), track1.tpcInnerParam()); - } + if (PIDstrategy == 3 && !selectionPID10(track1)) { + continue; + } + if (PIDstrategy == 4 && !selectionPID1(track1)) { + continue; } - histos.fill(HIST("hMomCorr"), track1.p() / track1.sign(), track1.p() - track1.tpcInnerParam(), centrality); histos.fill(HIST("hEta"), track1.eta()); - histos.fill(HIST("hDcaxy"), track1.dcaXY()); - histos.fill(HIST("hDcaz"), track1.dcaZ()); - histos.fill(HIST("hNsigmaProtonTPCDiff"), track1.tpcNSigmaPr(), track1.tpcNSigmaKa(), track1.pt()); + histos.fill(HIST("hDcaxy"), track1.dcaXY(), track1.pt()); + histos.fill(HIST("hDcaz"), track1.dcaZ(), track1.pt()); histos.fill(HIST("hNsigmaProtonTPC"), track1.tpcNSigmaPr(), track1.pt()); if (track1.hasTOF()) { histos.fill(HIST("hNsigmaProtonTOF"), track1.tofNSigmaPr(), track1.pt()); } auto track1ID = track1.globalIndex(); for (auto v0 : V0s) { + if (firstprimarytrack == 0) { + histos.fill(HIST("hInvMassKs0before"), v0.mK0Short()); + } if (!SelectionV0(collision, v0)) { continue; } - auto anglesign = (v0.x() - collision.posX()) * v0.px() + (v0.y() - collision.posY()) * v0.py() + (v0.z() - collision.posZ()) * v0.pz(); - anglesign = anglesign / TMath::Abs(anglesign); if (firstprimarytrack == 0) { - histos.fill(HIST("hV0Dca"), anglesign * v0.dcav0topv()); + histos.fill(HIST("hInvMassKs0before2"), v0.mK0Short()); + } + + if (firstprimarytrack == 0) { + histos.fill(HIST("hV0Dca"), v0.dcav0topv()); } auto postrack = v0.template posTrack_as(); auto negtrack = v0.template negTrack_as(); @@ -660,6 +652,10 @@ struct highmasslambda { if (!isSelectedV0Daughter(negtrack, -1)) { continue; } + if (firstprimarytrack == 0) { + histos.fill(HIST("hInvMassKs0before3"), v0.mK0Short()); + } + if (track1ID == postrack.globalIndex()) { continue; } @@ -674,27 +670,24 @@ struct highmasslambda { Kshort = ROOT::Math::PxPyPzMVector(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); Lambdac = Proton + Kshort; auto phiminuspsi = GetPhiInRange(Lambdac.Phi() - psiFT0C); - + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; if (useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; - } - if (!useSP) { v2 = TMath::Cos(2.0 * phiminuspsi); } - auto dcasum = 0.0; - if (useSignDCAV0) { - dcasum = anglesign * (v0.dcav0topv()) - track1.dcaXY(); - } - if (!useSignDCAV0) { - dcasum = v0.dcav0topv() - track1.dcaXY(); - } - histos.fill(HIST("hMassvsDecaySum"), Lambdac.M(), dcasum); - if (Lambdac.M() > cMinLambdaMass && Lambdac.M() <= cMaxLambdaMass && TMath::Abs(Lambdac.Rapidity()) < confRapidity && Lambdac.Pt() > 2.0 && Lambdac.Pt() <= 6.0) { - if (fillDefault) { - histos.fill(HIST("hSparseV2SASameEvent_V2"), Lambdac.M(), Lambdac.Pt(), v2, TMath::Abs(track1.dcaXY()), Proton.Pt()); + auto dcaV0toPV = std::abs(v0.dcav0topv()); + auto cpaV0 = v0.v0cosPA(); + auto ptV0 = v0.pt(); + auto dcaV0Daughters = std::abs(v0.dcaV0daughters()); + auto dcaProtonV0 = v0.dcav0topv() - track1.dcaXY(); + if (Lambdac.M() > cMinLambdaMass && Lambdac.M() <= cMaxLambdaMass && std::abs(Lambdac.Rapidity()) < confRapidity && Lambdac.Pt() > 1.0 && Lambdac.Pt() <= 6.0) { + if (useKshortOpti == 0) { + histos.fill(HIST("hSparseV2SASameEvent_V2"), Lambdac.M(), Lambdac.Pt(), std::abs(track1.dcaXY()), Proton.Pt()); + } + if (useKshortOpti == 1) { + histos.fill(HIST("hSparseV2SASameEvent_V2"), Lambdac.M(), Lambdac.Pt(), dcaV0toPV, cpaV0, ptV0, dcaV0Daughters, dcaProtonV0); } - if (fillDecayLength) { - histos.fill(HIST("hSparseV2SASameEvent_V2_dcatopv"), Lambdac.M(), Lambdac.Pt(), v2, v0.dcav0topv(), Proton.Pt()); + if (useKshortOpti == 2) { + histos.fill(HIST("hSparseV2SASameEvent_V2"), Lambdac.M(), Lambdac.Pt(), v2, std::abs(track1.dcaXY()), combinekaon(track1)); } } if (fillRotation) { @@ -709,43 +702,15 @@ struct highmasslambda { KshortRot = ROOT::Math::PxPyPzMVector(rotKaonPx, rotKaonPy, Kshort.pz(), massK0s); LambdacRot = Proton + KshortRot; auto phiminuspsiRot = GetPhiInRange(LambdacRot.Phi() - psiFT0C); + v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; if (useSP) { - v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; - } - if (!useSP) { v2Rot = TMath::Cos(2.0 * phiminuspsiRot); } - - if (LambdacRot.M() > cMinLambdaMass && LambdacRot.M() <= cMaxLambdaMass && TMath::Abs(LambdacRot.Rapidity()) < confRapidity && LambdacRot.Pt() > 2.0 && LambdacRot.Pt() <= 6.0) { - if (fillDefault) { - histos.fill(HIST("hSparseV2SASameEventRotational_V2"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, TMath::Abs(track1.dcaXY()), Proton.Pt()); - } - if (fillDecayLength) { - histos.fill(HIST("hSparseV2SASameEventRotational_V2_dcatopv"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, v0.dcav0topv(), Proton.Pt()); - } + if (LambdacRot.M() > cMinLambdaMass && LambdacRot.M() <= cMaxLambdaMass && std::abs(LambdacRot.Rapidity()) < confRapidity && LambdacRot.Pt() > 1.0 && LambdacRot.Pt() <= 6.0) { + histos.fill(HIST("hSparseV2SASameEventRotational_V2"), LambdacRot.M(), LambdacRot.Pt(), v2Rot); } } } - if (fillPolarization) { - ROOT::Math::Boost boost{Lambdac.BoostToCM()}; - fourVecDauCM = boost(Kshort); - threeVecDauCM = fourVecDauCM.Vect(); - threeVecDauCMXY = ROOT::Math::XYZVector(threeVecDauCM.X(), threeVecDauCM.Y(), 0.); - beamvector = ROOT::Math::XYZVector(0, 0, 1); - auto cosThetaStar = beamvector.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(beamvector.Mag2()); - auto SA = cosThetaStar * TMath::Sin(2.0 * phiminuspsi); - - if (track1.sign() > 0) { - histos.fill(HIST("hSparseV2SASameEventplus_SA"), Lambdac.M(), Lambdac.Pt(), cosThetaStar, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEventplus_SA_A0"), Lambdac.M(), Lambdac.Pt(), cosThetaStar * cosThetaStar, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEventplus_SA_azimuth"), Lambdac.M(), Lambdac.Pt(), SA, centrality); - } - if (track1.sign() < 0) { - histos.fill(HIST("hSparseV2SASameEventminus_SA"), Lambdac.M(), Lambdac.Pt(), cosThetaStar, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEventminus_SA_A0"), Lambdac.M(), Lambdac.Pt(), cosThetaStar * cosThetaStar, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEventminus_SA_azimuth"), Lambdac.M(), Lambdac.Pt(), SA, centrality); - } - } } } } @@ -756,16 +721,29 @@ struct highmasslambda { BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicityClass, axisEPAngle}, true}; Pair pairs{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksV0sTuple, &cache}; // -1 is the number of the bin to skip for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { - if (!collision1.sel8() || !collision1.triggereventep() || !collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + if (!collision1.sel8() || !collision1.triggereventep() || !collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return; + } + if (additionalEvSel && (!collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll) || !collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + return; + } + if (!collision2.sel8() || !collision2.triggereventep() || !collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return; + } + if (additionalEvSel && (!collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll) || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + return; + } + if (collision1.bcId() == collision2.bcId()) { continue; } - if (!collision2.sel8() || !collision2.triggereventep() || !collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + if (additionalEvSel && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { continue; } - if (collision1.bcId() == collision2.bcId()) { + if (additionalEvSel && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { continue; } - auto centrality = collision1.centFT0C(); + o2::aod::ITSResponse itsResponse; + auto psiFT0C = collision1.psiFT0C(); auto QFT0C = collision1.qFT0C(); int occupancy1 = collision1.trackOccupancyInTimeRange(); @@ -781,24 +759,27 @@ struct highmasslambda { if (!selectionTrack(track1)) { continue; } + if (track1.pt() <= 0.6 && !(itsResponse.nSigmaITS(track1) > -2.0)) { + continue; + } + if (track1.pt() > 0.6 && track1.pt() <= 0.8 && !(itsResponse.nSigmaITS(track1) > -1.5)) { + continue; + } // PID check - if (PIDstrategy == 0 && !selectionPID1(track1)) { + if (PIDstrategy == 0 && !selectionPID7(track1)) { continue; } - if (PIDstrategy == 1 && !selectionPID2(track1)) { + if (PIDstrategy == 1 && !selectionPID8(track1)) { continue; } - if (PIDstrategy == 2 && !selectionPID3(track1)) { + if (PIDstrategy == 2 && !selectionPID9(track1)) { continue; } - if (PIDstrategy == 3 && !selectionPID4(track1)) { + if (PIDstrategy == 3 && !selectionPID10(track1)) { continue; } - - if (!track1.hasTOF()) { - if (rejectPID && !rejectEl(track1)) { - continue; - } + if (PIDstrategy == 4 && !selectionPID1(track1)) { + continue; } if (!SelectionV0(collision2, v0)) { continue; @@ -814,54 +795,318 @@ struct highmasslambda { Proton = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massPr); Kshort = ROOT::Math::PxPyPzMVector(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); Lambdac = Proton + Kshort; - if (Lambdac.Pt() > 6.0 || Lambdac.Pt() < 2.0) { + // if (Lambdac.Pt() > 6.0 || Lambdac.Pt() < 2.0) { + // continue; + // } + if (std::abs(Lambdac.Rapidity()) > confRapidity) { continue; } - if (TMath::Abs(Lambdac.Rapidity()) > confRapidity) { + auto phiminuspsi = GetPhiInRange(Lambdac.Phi() - psiFT0C); + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; + if (useSP) { + v2 = TMath::Cos(2.0 * phiminuspsi); + } + auto dcaV0toPV = std::abs(v0.dcav0topv()); + auto cpaV0 = v0.v0cosPA(); + auto ptV0 = v0.pt(); + auto dcaV0Daughters = std::abs(v0.dcaV0daughters()); + auto dcaProtonV0 = v0.dcav0topv() - track1.dcaXY(); + if (Lambdac.M() > cMinLambdaMass && Lambdac.M() <= cMaxLambdaMass && std::abs(Lambdac.Rapidity()) < confRapidity && Lambdac.Pt() > 1.0 && Lambdac.Pt() <= 6.0) { + if (useKshortOpti == 0) { + histos.fill(HIST("hSparseV2SAMixedEvent_V2"), Lambdac.M(), Lambdac.Pt(), std::abs(track1.dcaXY()), Proton.Pt()); + } + if (useKshortOpti == 1) { + histos.fill(HIST("hSparseV2SAMixedEvent_V2"), Lambdac.M(), Lambdac.Pt(), dcaV0toPV, cpaV0, ptV0, dcaV0Daughters, dcaProtonV0); + } + if (useKshortOpti == 2) { + histos.fill(HIST("hSparseV2SAMixedEvent_V2"), Lambdac.M(), Lambdac.Pt(), v2, std::abs(track1.dcaXY()), combinekaon(track1)); + } + } + } + } + } + PROCESS_SWITCH(highmasslambda, processMixedEventOpti, "Process Mixed event new", false); + void processSameEventSvx(EventCandidates::iterator const& collision, TrackCandidatesSvx const& tracks, AllTrackCandidatesSvx const&, ResoV0sSvx const& V0s, aod::BCsWithTimestamps const&) + { + if (!collision.sel8() || !collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return; + } + if (additionalEvSel && (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + return; + } + /// Set the magnetic field from ccdb. + auto bc = collision.template bc_as(); + if (runNumber != bc.runNumber()) { + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(ccdbPathGrpMag, bc.timestamp()); + if (grpo == nullptr) { + LOGF(fatal, "Run 3 GRP object (type o2::parameters::GRPMagField) is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp()); + } + o2::base::Propagator::initFieldFromGRP(grpo); + bz = o2::base::Propagator::Instance()->getNominalBz(); + runNumber = bc.runNumber(); + } + df.setBz(bz); + int occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy > cfgOccupancyCut) { + return; + } + o2::aod::ITSResponse itsResponse; + auto centrality = collision.centFT0C(); + // auto multTPC = collision.multNTracksPV(); + auto psiFT0C = collision.psiFT0C(); + auto psiFT0A = collision.psiFT0A(); + auto psiTPC = collision.psiTPC(); + auto psiTPCR = collision.psiTPCR(); + auto psiTPCL = collision.psiTPCL(); + auto QFT0C = collision.qFT0C(); + auto QFT0A = collision.qFT0A(); + auto QTPC = collision.qTPC(); + auto QTPCR = collision.qTPCR(); + auto QTPCL = collision.qTPCL(); + histos.fill(HIST("hPsiFT0C"), centrality, psiFT0C, occupancy); + histos.fill(HIST("hPsiFT0A"), centrality, psiFT0A, occupancy); + histos.fill(HIST("hPsiTPC"), centrality, psiTPC, occupancy); + histos.fill(HIST("ResFT0CTPC"), centrality, QFT0C * QTPC * TMath::Cos(2.0 * (psiFT0C - psiTPC))); + histos.fill(HIST("ResFT0CTPCR"), centrality, QFT0C * QTPCR * TMath::Cos(2.0 * (psiFT0C - psiTPCR))); + histos.fill(HIST("ResFT0CTPCL"), centrality, QFT0C * QTPCL * TMath::Cos(2.0 * (psiFT0C - psiTPCL))); + histos.fill(HIST("ResTPCRTPCL"), centrality, QTPCR * QTPCL * TMath::Cos(2.0 * (psiTPCR - psiTPCL))); + histos.fill(HIST("ResFT0CFT0A"), centrality, QFT0C * QFT0A * TMath::Cos(2.0 * (psiFT0C - psiFT0A))); + histos.fill(HIST("ResFT0ATPC"), centrality, QTPC * QFT0A * TMath::Cos(2.0 * (psiTPC - psiFT0A))); + histos.fill(HIST("hCentrality"), centrality); + histos.fill(HIST("hVtxZ"), collision.posZ()); + histos.fill(HIST("hOccupancy"), occupancy); + auto firstprimarytrack = 0; + for (auto track1 : tracks) { + if (!selectionTrack(track1)) { + continue; + } + histos.fill(HIST("hNsigmaProtonITS"), itsResponse.nSigmaITS(track1), track1.pt()); + if (track1.p() < 1.0 && !(itsResponse.nSigmaITS(track1) > -nsigmaCutITS && itsResponse.nSigmaITS(track1) < nsigmaCutITS)) { + continue; + } + + histos.fill(HIST("hNsigmaProtonTPCPre"), track1.tpcNSigmaPr(), track1.pt()); + // PID check + if (PIDstrategy == 0 && !selectionPID7(track1)) { + continue; + } + if (PIDstrategy == 1 && !selectionPID8(track1)) { + continue; + } + if (PIDstrategy == 2 && !selectionPID9(track1)) { + continue; + } + if (PIDstrategy == 3 && !selectionPID10(track1)) { + continue; + } + histos.fill(HIST("hEta"), track1.eta()); + histos.fill(HIST("hDcaxy"), track1.dcaXY()); + histos.fill(HIST("hDcaz"), track1.dcaZ()); + histos.fill(HIST("hNsigmaProtonTPC"), track1.tpcNSigmaPr(), track1.pt()); + if (track1.hasTOF()) { + histos.fill(HIST("hNsigmaProtonTOF"), track1.tofNSigmaPr(), track1.pt()); + } + auto track1ID = track1.globalIndex(); + auto trackParCovBach = getTrackParCov(track1); + // auto trackParCovBach = getTrackParCov(bach); + + for (auto v0 : V0s) { + if (!SelectionV0(collision, v0)) { + continue; + } + if (firstprimarytrack == 0) { + histos.fill(HIST("hV0Dca"), v0.dcav0topv()); + } + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + if (!isSelectedV0Daughter(postrack, 1)) { continue; } + if (!isSelectedV0Daughter(negtrack, -1)) { + continue; + } + if (track1ID == postrack.globalIndex()) { + continue; + } + if (track1ID == negtrack.globalIndex()) { + continue; + } + if (firstprimarytrack == 0) { + histos.fill(HIST("hInvMassKs0"), v0.mK0Short()); + } + firstprimarytrack = firstprimarytrack + 1; + // LOGF(info, "Before dca fitter"); + std::array pVecV0 = {0., 0., 0.}; + std::array pVecBach = {0., 0., 0.}; + // std::array pVecCand = {0., 0., 0.}; + const std::array vertexV0 = {v0.x(), v0.y(), v0.z()}; + const std::array momentumV0 = {v0.px(), v0.py(), v0.pz()}; + // we build the neutral track to then build the cascade + std::array covV = {0.}; + constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int i = 0; i < 6; i++) { + covV[MomInd[i]] = v0.momentumCovMat()[i]; + covV[i] = v0.positionCovMat()[i]; + } + auto trackV0 = o2::track::TrackParCov(vertexV0, momentumV0, covV, 0, true); + trackV0.setAbsCharge(0); + trackV0.setPID(o2::track::PID::K0); + + int nCand2 = 0; + try { + nCand2 = df.process(trackV0, trackParCovBach); + } catch (...) { + continue; + } + + if (nCand2 == 0) { + continue; + } + df.propagateTracksToVertex(); // propagate the bach and V0 to the Lc vertex + df.getTrack(0).getPxPyPzGlo(pVecV0); // take the momentum at the Lc vertex + df.getTrack(1).getPxPyPzGlo(pVecBach); + // LOGF(info, "after dca fitter"); + + /* + float v0x, v0y, v0z, v0px, v0py, v0pz; + float posTrackX, negTrackX; + o2::track::TrackParCov trackParCovV0DaughPos; + o2::track::TrackParCov trackParCovV0DaughNeg; + trackParCovV0DaughPos = getTrackParCov(postrack); // check that aod::TracksWCov does not need TracksDCA! + trackParCovV0DaughNeg = getTrackParCov(negtrack); // check that aod::TracksWCov does not need TracksDCA! + posTrackX = v0.posX(); + negTrackX = v0.negX(); + v0x = v0.x(); + v0y = v0.y(); + v0z = v0.z(); + const std::array vertexV0 = {v0x, v0y, v0z}; + + v0px = v0.px(); + v0py = v0.py(); + v0pz = v0.pz(); + const std::array momentumV0 = {v0px, v0py, v0pz}; + + std::array covV0Pos = {0.}; + for (int i = 0; i < 6; i++) { + covV0Pos[i] = v0.positionCovMat()[i]; + } + trackParCovV0DaughPos.propagateTo(posTrackX, bz); // propagate the track to the X closest to the V0 vertex + trackParCovV0DaughNeg.propagateTo(negTrackX, bz); // propagate the track to the X closest to the V0 vertex + + // we build the neutral track to then build the cascade + // auto trackV0 = o2::dataformats::V0(vertexV0, momentumV0, {0, 0, 0, 0, 0, 0}, trackParCovV0DaughPos, trackParCovV0DaughNeg); // build the V0 track (indices for v0 daughters set to 0 for now) + auto trackV0 = o2::dataformats::V0(vertexV0, momentumV0, covV0Pos, trackParCovV0DaughPos, trackParCovV0DaughNeg); // build the V0 track (indices for v0 daughters set to 0 for now) + std::array pVecV0 = {0., 0., 0.}; + std::array pVecBach = {0., 0., 0.}; + std::array pVecCand = {0., 0., 0.}; + try { + if (df.process(trackV0, trackParCovBach) == 0) { + continue; + } else { + } + } catch (const std::runtime_error& error) { + continue; + } + df.propagateTracksToVertex(); // propagate the bachelor and V0 to the Lambdac vertex + trackV0.getPxPyPzGlo(pVecV0); // momentum of D0 at the Lambdac vertex + trackParCovBach.getPxPyPzGlo(pVecBach); // momentum of proton at the Lambdac vertex + */ + + const auto& secondaryVertex = df.getPCACandidate(); + auto primaryVertex = getPrimaryVertex(collision); + o2::dataformats::DCA impactParameter0; + o2::dataformats::DCA impactParameter1; + trackV0.propagateToDCA(primaryVertex, bz, &impactParameter0); + trackParCovBach.propagateToDCA(primaryVertex, bz, &impactParameter1); + double phi, theta; + getPointDirection(std::array{collision.posX(), collision.posY(), collision.posZ()}, secondaryVertex, phi, theta); + // auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta)); + // auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); + + Kshort = ROOT::Math::PxPyPzMVector(pVecV0[0], pVecV0[1], pVecV0[2], massK0s); + Proton = ROOT::Math::PxPyPzMVector(pVecBach[0], pVecBach[1], pVecBach[2], massPr); + Lambdac = Proton + Kshort; auto phiminuspsi = GetPhiInRange(Lambdac.Phi() - psiFT0C); + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; if (useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; - } - if (!useSP) { v2 = TMath::Cos(2.0 * phiminuspsi); } - auto anglesign = (v0.x() - collision1.posX()) * v0.px() + (v0.y() - collision1.posY()) * v0.py() + (v0.z() - collision1.posZ()) * v0.pz(); - anglesign = anglesign / TMath::Abs(anglesign); + double protonimpactparameter = impactParameter1.getY(); + double kshortimpactparameter = impactParameter0.getY(); - if (occupancy1 < cfgOccupancyCut && occupancy2 < cfgOccupancyCut && Lambdac.M() > cMinLambdaMass && Lambdac.M() <= cMaxLambdaMass && TMath::Abs(Lambdac.Rapidity()) < confRapidity && Lambdac.Pt() > 2.0 && Lambdac.Pt() <= 6.0) { - if (fillDefault) { - histos.fill(HIST("hSparseV2SAMixedEvent_V2"), Lambdac.M(), Lambdac.Pt(), v2, TMath::Abs(track1.dcaXY()), Proton.Pt()); - } - if (fillDecayLength) { - histos.fill(HIST("hSparseV2SAMixedEvent_V2_dcatopv"), Lambdac.M(), Lambdac.Pt(), v2, v0.dcav0topv(), Proton.Pt()); - } + double decaylengthx = secondaryVertex[0] - collision.posX(); + double decaylengthy = secondaryVertex[1] - collision.posY(); + double decaylengthz = secondaryVertex[2] - collision.posZ(); + double decaylength = TMath::Sqrt(decaylengthx * decaylengthx + decaylengthy * decaylengthy + decaylengthz * decaylengthz); + double decaylengthxy = TMath::Sqrt(decaylengthx * decaylengthx + decaylengthy * decaylengthy); + double anglesign = decaylengthx * Lambdac.Px() + decaylengthy * Lambdac.Py() + decaylengthz * Lambdac.Pz(); + double CPAlambdac = anglesign / (decaylength * Lambdac.P()); + + histos.fill(HIST("hDecayLengthxy"), decaylengthxy); + histos.fill(HIST("hDecayLength"), decaylength); + histos.fill(HIST("hImpactPar0"), protonimpactparameter); + histos.fill(HIST("hImpactPar1"), kshortimpactparameter); + histos.fill(HIST("hCPA"), CPAlambdac); + histos.fill(HIST("hMomCorr"), Proton.P() - track1.p(), v0.p() - Kshort.P()); + if (Lambdac.M() > cMinLambdaMass && Lambdac.M() <= cMaxLambdaMass && std::abs(Lambdac.Rapidity()) < confRapidity && Lambdac.Pt() > 1.0 && Lambdac.Pt() <= 6.0 && decaylength < ConfMaxDecayLength && CPAlambdac > ConfMinCPA) { + histos.fill(HIST("hSparseV2SASameEvent_V2_SVX"), Lambdac.M(), Lambdac.Pt(), v2, decaylength, CPAlambdac); } - if (fillPolarization) { - ROOT::Math::Boost boost{Lambdac.BoostToCM()}; - fourVecDauCM = boost(Kshort); - threeVecDauCM = fourVecDauCM.Vect(); - threeVecDauCMXY = ROOT::Math::XYZVector(threeVecDauCM.X(), threeVecDauCM.Y(), 0.); - beamvector = ROOT::Math::XYZVector(0, 0, 1); - auto cosThetaStar = beamvector.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(beamvector.Mag2()); - auto SA = cosThetaStar * TMath::Sin(2.0 * phiminuspsi); - - if (track1.sign() > 0) { - histos.fill(HIST("hSparseV2SAMixedEventplus_SA"), Lambdac.M(), Lambdac.Pt(), cosThetaStar, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEventplus_SA_A0"), Lambdac.M(), Lambdac.Pt(), cosThetaStar * cosThetaStar, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEventplus_SA_azimuth"), Lambdac.M(), Lambdac.Pt(), SA, centrality); - } - if (track1.sign() < 0) { - histos.fill(HIST("hSparseV2SAMixedEventminus_SA"), Lambdac.M(), Lambdac.Pt(), cosThetaStar, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEventminus_SA_A0"), Lambdac.M(), Lambdac.Pt(), cosThetaStar * cosThetaStar, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEventminus_SA_azimuth"), Lambdac.M(), Lambdac.Pt(), SA, centrality); + if (fillRotation) { + for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { + auto anglestart = confMinRot; + auto angleend = confMaxRot; + auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); + auto rotangle = anglestart + nrotbkg * anglestep; + histos.fill(HIST("hRotation"), rotangle); + float rotKaonPx = Kshort.px() * std::cos(rotangle) - Kshort.py() * std::sin(rotangle); + float rotKaonPy = Kshort.px() * std::sin(rotangle) + Kshort.py() * std::cos(rotangle); + ////////// DCA fitter //////////////// + // LOGF(info, "Before dca fitter"); + std::array pVecV0rot = {0., 0., 0.}; + std::array pVecBachrot = {0., 0., 0.}; + const std::array momentumV0rot = {rotKaonPx, rotKaonPy, v0.pz()}; + auto trackV0rot = o2::track::TrackParCov(vertexV0, momentumV0rot, covV, 0, true); + trackV0rot.setAbsCharge(0); + trackV0rot.setPID(o2::track::PID::K0); + int nCand2rot = 0; + try { + nCand2rot = df.process(trackV0rot, trackParCovBach); + } catch (...) { + continue; + } + if (nCand2rot == 0) { + continue; + } + df.propagateTracksToVertex(); // propagate the bach and V0 to the Lc vertex + df.getTrack(0).getPxPyPzGlo(pVecV0rot); // take the momentum at the Lc vertex + df.getTrack(1).getPxPyPzGlo(pVecBachrot); + const auto& secondaryVertexrot = df.getPCACandidate(); + double phirot, thetarot; + getPointDirection(std::array{collision.posX(), collision.posY(), collision.posZ()}, secondaryVertexrot, phirot, thetarot); + KshortRot = ROOT::Math::PxPyPzMVector(pVecV0rot[0], pVecV0rot[1], pVecV0rot[2], massK0s); + Proton = ROOT::Math::PxPyPzMVector(pVecBachrot[0], pVecBachrot[1], pVecBachrot[2], massPr); + LambdacRot = Proton + KshortRot; + auto phiminuspsiRot = GetPhiInRange(LambdacRot.Phi() - psiFT0C); + v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; + if (useSP) { + v2Rot = TMath::Cos(2.0 * phiminuspsiRot); + } + double decaylengthxrot = secondaryVertexrot[0] - collision.posX(); + double decaylengthyrot = secondaryVertexrot[1] - collision.posY(); + double decaylengthzrot = secondaryVertexrot[2] - collision.posZ(); + double decaylengthrot = TMath::Sqrt(decaylengthxrot * decaylengthxrot + decaylengthyrot * decaylengthyrot + decaylengthzrot * decaylengthzrot); + // double decaylengthxyrot = TMath::Sqrt(decaylengthxrot * decaylengthxrot + decaylengthyrot * decaylengthyrot); + double anglesignrot = decaylengthxrot * LambdacRot.Px() + decaylengthyrot * LambdacRot.Py() + decaylengthzrot * LambdacRot.Pz(); + double CPAlambdacrot = anglesignrot / (decaylengthrot * LambdacRot.P()); + if (LambdacRot.M() > cMinLambdaMass && LambdacRot.M() <= cMaxLambdaMass && std::abs(LambdacRot.Rapidity()) < confRapidity && LambdacRot.Pt() > 1.0 && LambdacRot.Pt() <= 6.0 && decaylengthrot < ConfMaxDecayLength && CPAlambdacrot > ConfMinCPA) { + histos.fill(HIST("hSparseV2SASameEventRotational_V2_SVX"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, decaylength, CPAlambdacrot); + } } } } } } - PROCESS_SWITCH(highmasslambda, processMixedEventOpti, "Process Mixed event new", true); + PROCESS_SWITCH(highmasslambda, processSameEventSvx, "Process Same event SVX", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGLF/Tasks/Resonances/k1AnalysisMicro.cxx b/PWGLF/Tasks/Resonances/k1AnalysisMicro.cxx new file mode 100644 index 00000000000..35d6224da36 --- /dev/null +++ b/PWGLF/Tasks/Resonances/k1AnalysisMicro.cxx @@ -0,0 +1,741 @@ +// 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. +/// +/// \file k1AnalysisMicro.cxx +/// \brief Reconstruction of track-track decay resonance candidates +/// \author Su-Jeong Ji , Bong-Hwi Lim +/// + +#include +#include +#include // FIXME +#include // FIXME + +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/runDataProcessing.h" +#include "PWGLF/DataModel/LFResonanceTables.h" +#include "DataFormatsParameters/GRPObject.h" +#include "CommonConstants/PhysicsConstants.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::constants::physics; +using namespace o2::constants::math; +; + +struct K1AnalysisMicro { + enum BinAnti : unsigned int { + kNormal = 0, + kAnti, + kNAEnd + }; + enum BinType : unsigned int { + kK1P = 0, + kK1N, + kK1P_Mix, + kK1N_Mix, + kK1P_GenINEL10, + kK1N_GenINEL10, + kK1P_GenINELgt10, + kK1N_GenINELgt10, + kK1P_GenTrig10, + kK1N_GenTrig10, + kK1P_GenEvtSel, + kK1N_GenEvtSel, + kK1P_Rec, + kK1N_Rec, + kTYEnd + }; + SliceCache cache; + Preslice perRCol = aod::resodaughter::resoCollisionId; + Preslice perCollision = aod::track::collisionId; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + using ResoMCCols = soa::Join; + + //// Configurables + Configurable cNbinsDiv{"cNbinsDiv", 1, "Integer to divide the number of bins"}; + /// Event Mixing + Configurable nEvtMixing{"nEvtMixing", 5, "Number of events to mix"}; + ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgMultBins{"cfgMultBins", {VARIABLE_WIDTH, 0.0f, 20.0f, 40.0f, 60.0f, 80.0f, 100.0f, 200.0f, 99999.f}, "Mixing bins - multiplicity"}; + /// Pre-selection cuts + Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"}; + + /// DCA Selections + // DCAr to PV + Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.1, "Track DCAr cut to PV Maximum"}; + // DCAz to PV + Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 0.1, "Track DCAz cut to PV Maximum"}; + Configurable cMinDCAzToPVcut{"cMinDCAzToPVcut", 0.0, "Track DCAz cut to PV Minimum"}; + + /// PID Selections + Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC + Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF + Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; // Combined + Configurable cTOFVeto{"cTOFVeto", true, "TOF Veto, if false, TOF is nessessary for PID selection"}; // TOF Veto + Configurable cUseOnlyTOFTrackPi{"cUseOnlyTOFTrackPi", false, "Use only TOF track for PID selection"}; // Use only TOF track for Pion PID selection + // Kaon + Configurable cMaxTPCnSigmaKaon{"cMaxTPCnSigmaKaon", 3.0, "TPC nSigma cut for Kaon"}; // TPC + Configurable cMaxTOFnSigmaKaon{"cMaxTOFnSigmaKaon", 3.0, "TOF nSigma cut for Kaon"}; // TOF + Configurable nsigmaCutCombinedKaon{"nsigmaCutCombinedKaon", -999, "Combined nSigma cut for Kaon"}; // Combined + Configurable cUseOnlyTOFTrackKa{"cUseOnlyTOFTrackKa", false, "Use only TOF track for PID selection"}; // Use only TOF track for Kaon PID selection + // Track selections + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor + Configurable additionalQAplots{"additionalQAplots", true, "Additional QA plots"}; + Configurable additionalEvsel{"additionalEvsel", true, "Additional event selcection"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; + Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; + Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; + Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + + // Secondary selection + Configurable cMinSecondaryPtCut{"cMinSecondaryPtCut", 0.5, "Min pT cut for secondary selection"}; + /* + Configurable cfgModeK892orRho{"cfgModeK892orRho", false, "Secondary scenario for K892 (true) or Rho (false)"}; + Configurable cSecondaryMasswindow{"cSecondaryMasswindow", 0.1, "Secondary inv mass selection window"}; + Configurable cMinAnotherSecondaryMassCut{"cMinAnotherSecondaryMassCut", 0, "Min inv. mass selection of another secondary scenario"}; + Configurable cMaxAnotherSecondaryMassCut{"cMaxAnotherSecondaryMassCut", 999, "MAx inv. mass selection of another secondary scenario"}; + Configurable cMinPiKaMassCut{"cMinPiKaMassCut", 0, "bPion-Kaon pair inv mass selection minimum"}; + Configurable cMaxPiKaMassCut{"cMaxPiKaMassCut", 999, "bPion-Kaon pair inv mass selection maximum"}; + Configurable cMinAngle{"cMinAngle", 0, "Minimum angle between K(892)0 and bachelor pion"}; + Configurable cMaxAngle{"cMaxAngle", 4, "Maximum angle between K(892)0 and bachelor pion"}; + Configurable cMinPairAsym{"cMinPairAsym", -1, "Minimum pair asymmetry"}; + Configurable cMaxPairAsym{"cMaxPairAsym", 1, "Maximum pair asymmetry"}; +*/ + + // K1 selection + Configurable cK1MaxRap{"cK1MaxRap", 0.5, "K1 maximum rapidity"}; + Configurable cK1MinRap{"cK1MinRap", -0.5, "K1 minimum rapidity"}; + + void init(o2::framework::InitContext&) + { + std::vector centBinning = {0., 1., 5., 10., 15., 20., 25., 30., 35., 40., 45., 50., 55., 60., 65., 70., 80., 90., 100., 200.}; + AxisSpec centAxis = {centBinning, "T0M (%)"}; + AxisSpec ptAxis = {150, 0, 15, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec dcaxyAxis = {300, 0, 3, "DCA_{#it{xy}} (cm)"}; + AxisSpec dcazAxis = {500, 0, 5, "DCA_{#it{z}} (cm)"}; + AxisSpec invMassAxisK892 = {1400 / cNbinsDiv, 0.6, 2.0, "Invariant Mass (GeV/#it{c}^2)"}; // K(892)0 + AxisSpec invMassAxisRho = {2000 / cNbinsDiv, 0.0, 2.0, "Invariant Mass (GeV/#it{c}^2)"}; // rho + AxisSpec invMassAxisReso = {1600 / cNbinsDiv, 0.9f, 2.5f, "Invariant Mass (GeV/#it{c}^2)"}; // K1 + AxisSpec invMassAxisScan = {250, 0, 2.5, "Invariant Mass (GeV/#it{c}^2)"}; // For selection + AxisSpec pidQAAxis = {130, -6.5, 6.5}; + AxisSpec dataTypeAxis = {9, 0, 9, "Histogram types"}; + AxisSpec mcTypeAxis = {4, 0, 4, "Histogram types"}; + + // THnSparse + AxisSpec axisAnti = {BinAnti::kNAEnd, 0, BinAnti::kNAEnd, "Type of bin: Normal or Anti"}; + AxisSpec axisType = {BinType::kTYEnd, 0, BinType::kTYEnd, "Type of bin with charge and mix"}; + AxisSpec mcLabelAxis = {5, -0.5, 4.5, "MC Label"}; + + // DCA QA + // Primary pion + histos.add("QA/trkppionDCAxy", "DCAxy disstribution of primary pion candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QA/trkppionDCAz", "DCAz disstribution of primary pion candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QA/trkppionpT", "pT distribution of primary pion candidates", HistType::kTH1F, {ptAxis}); + histos.add("QA/trkppionTPCPID", "TPC PID of primary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QA/trkppionTOFPID", "TOF PID of primary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QA/trkppionTPCTOFPID", "TPC-TOF PID map of primary pion candidates", HistType::kTH2F, {pidQAAxis, pidQAAxis}); + + histos.add("QAcut/trkppionDCAxy", "DCAxy distribution of primary pion candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QAcut/trkppionDCAz", "DCAz distribution of primary pion candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QAcut/trkppionpT", "pT distribution of primary pion candidates", HistType::kTH1F, {ptAxis}); + histos.add("QAcut/trkppionTPCPID", "TPC PID of primary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAcut/trkppionTOFPID", "TOF PID of primary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAcut/trkppionTPCTOFPID", "TPC-TOF PID map of primary pion candidates", HistType::kTH2F, {pidQAAxis, pidQAAxis}); + + // Secondary pion + histos.add("QA/trkspionDCAxy", "DCAxy distribution of secondary pion candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QA/trkspionDCAz", "DCAz distribution of secondary pion candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QA/trkspionpT", "pT distribution of secondary pion candidates", HistType::kTH1F, {ptAxis}); + histos.add("QA/trkspionTPCPID", "TPC PID of secondary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QA/trkspionTOFPID", "TOF PID of secondary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QA/trkspionTPCTOFPID", "TPC-TOF PID map of secondary pion candidates", HistType::kTH2F, {pidQAAxis, pidQAAxis}); + + histos.add("QAcut/trkspionDCAxy", "DCAxy distribution of secondary pion candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QAcut/trkspionDCAz", "DCAz distribution of secondary pion candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QAcut/trkspionpT", "pT distribution of secondary pion candidates", HistType::kTH1F, {ptAxis}); + histos.add("QAcut/trkspionTPCPID", "TPC PID of secondary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAcut/trkspionTOFPID", "TOF PID of secondary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAcut/trkspionTPCTOFPID", "TPC-TOF PID map of secondary pion candidates", HistType::kTH2F, {pidQAAxis, pidQAAxis}); + + // Kaon + histos.add("QA/trkkaonDCAxy", "DCAxy distribution of kaon candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QA/trkkaonDCAz", "DCAz distribution of kaon candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QA/trkkaonpT", "pT distribution of kaon candidates", HistType::kTH1F, {ptAxis}); + histos.add("QA/trkkaonTPCPID", "TPC PID of kaon candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QA/trkkaonTOFPID", "TOF PID of kaon candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QA/trkkaonTPCTOFPID", "TPC-TOF PID map of kaon candidates", HistType::kTH2F, {pidQAAxis, pidQAAxis}); + + histos.add("QAcut/trkkaonDCAxy", "DCAxy distribution of kaon candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QAcut/trkkaonDCAz", "DCAz distribution of kaon candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QAcut/trkkaonpT", "pT distribution of kaon candidates", HistType::kTH1F, {ptAxis}); + histos.add("QAcut/trkkaonTPCPID", "TPC PID of kaon candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAcut/trkkaonTOFPID", "TOF PID of kaon candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAcut/trkkaonTPCTOFPID", "TPC-TOF PID map of kaon candidates", HistType::kTH2F, {pidQAAxis, pidQAAxis}); + + // K1 + histos.add("QA/K1OA", "Opening angle of K1(1270)", HistType::kTH1F, {AxisSpec{100, 0, 3.14, "Opening angle"}}); + histos.add("QA/K1PairAsym", "Pair asymmetry of K1(1270)", HistType::kTH1F, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); + histos.add("QA/hInvmassK892_Rho", "Invariant mass of K(892)0 vs Rho(770)", HistType::kTH2F, {invMassAxisK892, invMassAxisRho}); + histos.add("QA/hInvmassSecon_PiKa", "Invariant mass of secondary resonance vs pion-kaon", HistType::kTH2F, {invMassAxisRho, invMassAxisK892}); + histos.add("QA/hInvmassSecon", "Invariant mass of secondary resonance", HistType::kTH1F, {invMassAxisRho}); + histos.add("QA/hpT_Secondary", "pT distribution of secondary resonance", HistType::kTH1F, {ptAxis}); + + histos.add("QAcut/K1OA", "Opening angle of K1(1270)", HistType::kTH1F, {AxisSpec{100, 0, 3.14, "Opening angle"}}); + histos.add("QAcut/K1PairAsym", "Pair asymmetry of K1(1270)", HistType::kTH1F, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); + histos.add("QAcut/hInvmassK892_Rho", "Invariant mass of K(892)0 vs Rho(770)", HistType::kTH2F, {invMassAxisK892, invMassAxisRho}); + histos.add("QAcut/hInvmassSecon_PiKa", "Invariant mass of secondary resonance vs pion-kaon", HistType::kTH2F, {invMassAxisRho, invMassAxisK892}); + histos.add("QAcut/hInvmassSecon", "Invariant mass of secondary resonance", HistType::kTH1F, {invMassAxisRho}); + histos.add("QAcut/hpT_Secondary", "pT distribution of secondary resonance", HistType::kTH1F, {ptAxis}); + + // Invariant mass + histos.add("hInvmass_K1", "Invariant mass of K1(1270) (US)", HistType::kTHnSparseD, {axisAnti, axisType, centAxis, ptAxis, invMassAxisReso}); + histos.add("hInvmass_K1_LS", "Invariant mass of K1(1270) (LS)", HistType::kTHnSparseD, {axisAnti, axisType, centAxis, ptAxis, invMassAxisReso}); + histos.add("hInvmass_K1_Mix", "Invariant mass of K1(1270) (ME)", HistType::kTHnSparseD, {axisAnti, axisType, centAxis, ptAxis, invMassAxisReso}); + // Mass QA (quick check) + histos.add("k1invmass", "Invariant mass of K1(1270) (US)", HistType::kTH1F, {invMassAxisReso}); + histos.add("k1invmass_LS", "Invariant mass of K1(1270) (LS)", HistType::kTH1F, {invMassAxisReso}); + histos.add("k1invmass_Mix", "Invariant mass of K1(1270) (ME)", HistType::kTH1F, {invMassAxisReso}); + + // MC + if (doprocessMC) { + histos.add("k1invmass_MC", "Invariant mass of K1(1270)", HistType::kTH1F, {invMassAxisReso}); + histos.add("k1invmass_MC_noK1", "Invariant mass of K1(1270)", HistType::kTH1F, {invMassAxisReso}); + + histos.add("QAMC/trkppionDCAxy", "DCAxy distribution of primary pion candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QAMC/trkppionDCAz", "DCAz distribution of primary pion candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QAMC/trkppionpT", "pT distribution of primary pion candidates", HistType::kTH1F, {ptAxis}); + histos.add("QAMC/trkppionTPCPID", "TPC PID of primary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkppionTOFPID", "TOF PID of primary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkppionTPCTOFPID", "TPC-TOF PID map of primary pion candidates", HistType::kTH2F, {pidQAAxis, pidQAAxis}); + + histos.add("QAMC/trkspionDCAxy", "DCAxy distribution of secondary pion candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QAMC/trkspionDCAz", "DCAz distribution of secondary pion candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QAMC/trkspionpT", "pT distribution of secondary pion candidates", HistType::kTH1F, {ptAxis}); + histos.add("QAMC/trkspionTPCPID", "TPC PID of secondary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkspionTOFPID", "TOF PID of secondary pion candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkspionTPCTOFPID", "TPC-TOF PID map of secondary pion candidates", HistType::kTH2F, {pidQAAxis, pidQAAxis}); + + histos.add("QAMC/trkkaonDCAxy", "DCAxy distribution of kaon candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QAMC/trkkaonDCAz", "DCAz distribution of kaon candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QAMC/trkkaonpT", "pT distribution of kaon candidates", HistType::kTH1F, {ptAxis}); + histos.add("QAMC/trkkaonTPCPID", "TPC PID of kaon candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkkaonTOFPID", "TOF PID of kaon candidates", HistType::kTH2F, {ptAxis, pidQAAxis}); + histos.add("QAMC/trkkaonTPCTOFPID", "TPC-TOF PID map of kaon candidates", HistType::kTH2F, {pidQAAxis, pidQAAxis}); + + histos.add("QAMC/K1OA", "Opening angle of K1(1270)", HistType::kTH1F, {AxisSpec{100, 0, 3.14, "Opening angle"}}); + histos.add("QAMC/K1PairAsym", "Pair asymmetry of K1(1270)", HistType::kTH1F, {AxisSpec{100, -1, 1, "Pair asymmetry"}}); + histos.add("QAMC/hInvmassK892_Rho", "Invariant mass of K(892)0 vs Rho(770)", HistType::kTH2F, {invMassAxisK892, invMassAxisRho}); + histos.add("QAMC/hInvmassSecon_PiKa", "Invariant mass of secondary resonance vs pion-kaon", HistType::kTH2F, {invMassAxisRho, invMassAxisK892}); + histos.add("QAMC/hInvmassSecon", "Invariant mass of secondary resonance", HistType::kTH1F, {invMassAxisRho}); + histos.add("QAMC/hpT_Secondary", "pT distribution of secondary resonance", HistType::kTH1F, {ptAxis}); + } // doprocessMC + // Print output histograms statistics + LOG(info) << "Size of the histograms in K1 Analysis Task"; + histos.print(); + } // init + + // PDG code + int kPDGRho770 = 113; + int kK1Plus = 10323; + + template + bool trackCut(const TrackType track) + { + if constexpr (!IsResoMicrotrack) { + // basic track cuts + if (std::abs(track.pt()) < cMinPtcut) + return false; + if (std::abs(track.dcaXY()) > cMaxDCArToPVcut) + return false; + if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) + return false; + if (track.tpcNClsFound() < cfgTPCcluster) + return false; + if (cfgHasTOF && !track.hasTOF()) + return false; + if (cfgUseITSRefit && !track.passedITSRefit()) + return false; + if (cfgUseTPCRefit && !track.passedTPCRefit()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + return false; + if (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgGlobalTrack && !track.isGlobalTrack()) + return false; + } else { + if (std::abs(track.pt()) < cMinPtcut) + return false; + if (o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(track.trackSelectionFlags()) > cMaxDCArToPVcut - Epsilon) + return false; + if (o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(track.trackSelectionFlags()) > cMaxDCAzToPVcut - Epsilon) + return false; + if (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + return false; + } + return true; + } + + // Pion PID selection tools + template + bool selectionPIDpion(const T& candidate) + { + if constexpr (!IsResoMicrotrack) { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + if (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { + tpcPIDPassed = true; + } else { + return false; + } + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaPi()) < cMaxTOFnSigmaPion) { + tofPIDPassed = true; + } + if ((nsigmaCutCombinedPion > 0) && (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + candidate.tofNSigmaPi() * candidate.tofNSigmaPi() < nsigmaCutCombinedPion * nsigmaCutCombinedPion)) { + tofPIDPassed = true; + } + } else { + if (!cTOFVeto) { + return false; + } + tofPIDPassed = true; + } + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + } else { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + tpcPIDPassed = std::abs(o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(candidate.pidNSigmaPiFlag())) < cMaxTPCnSigmaPion + Epsilon; + tofPIDPassed = candidate.hasTOF() ? std::abs(o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(candidate.pidNSigmaPiFlag())) < cMaxTOFnSigmaPion + Epsilon : true; + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + } + return false; + } + + // Kaon PID selection tools + template + bool selectionPIDkaon(const T& candidate) + { + if constexpr (!IsResoMicrotrack) { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + if (std::abs(candidate.tpcNSigmaKa()) < cMaxTPCnSigmaKaon) { + tpcPIDPassed = true; + } else { + return false; + } + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaKa()) < cMaxTOFnSigmaKaon) { + tofPIDPassed = true; + } + if ((nsigmaCutCombinedKaon > 0) && (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa() < nsigmaCutCombinedKaon * nsigmaCutCombinedKaon)) { + tofPIDPassed = true; + } + } else { + if (!cTOFVeto) { + return false; + } + tofPIDPassed = true; + } + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + } else { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + tpcPIDPassed = std::abs(o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(candidate.pidNSigmaKaFlag())) < cMaxTPCnSigmaKaon + Epsilon; + tofPIDPassed = candidate.hasTOF() ? std::abs(o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(candidate.pidNSigmaKaFlag())) < cMaxTOFnSigmaKaon + Epsilon : true; + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + } + return false; + } + + template + bool isTrueK1(const T& trk1, const T& trk2, const T2& bTrack) + { + if (std::abs(trk1.pdgCode()) != kPiPlus || std::abs(trk2.pdgCode()) != kPiPlus) + return false; + if (std::abs(bTrack.pdgCode()) != kKPlus) + return false; + auto mother1 = trk1.motherId(); + auto mother2 = trk2.motherId(); + if (mother1 != mother2) + return false; + if (((std::abs(trk1.motherPDG()) && std::abs(trk2.motherPDG()) != kPDGRho770) && (std::abs(bTrack.motherPDG()) != kK1Plus)) || (std::abs(trk1.motherPDG()) && std::abs(bTrack.motherPDG()) != kK0Star892 && (std::abs(trk2.motherPDG()) != kK1Plus)) || (std::abs(trk2.motherPDG()) && std::abs(bTrack.motherPDG()) != kK0Star892 && (std::abs(trk1.motherPDG()) != kK1Plus))) + return false; + auto siblings = bTrack.siblingIds(); + if (siblings[0] != mother1 && siblings[1] != mother2) + return false; + return true; + } // isTrueK1 + + template + bool isTrueK892(const T& trk1, const T& trk2) + { + if (std::abs(trk1.pdgCode()) != kPiPlus || std::abs(trk2.pdgCode()) != kKPlus) + return false; + auto mother1 = trk1.motherId(); + auto mother2 = trk2.motherId(); + if (mother1 != mother2) + return false; + if (std::abs(trk1.motherPDG()) != kK0Star892) + return false; + return true; + } + + template + bool isTrueRho(const T& trk1, const T& trk2) + { + if (std::abs(trk1.pdgCode()) != kPiPlus || std::abs(trk2.pdgCode()) != kPiPlus) + return false; + auto mother1 = trk1.motherId(); + auto mother2 = trk2.motherId(); + if (mother1 != mother2) + return false; + if (std::abs(trk1.motherPDG()) != kPDGRho770) + return false; + return true; + } + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2) + { + auto multiplicity = collision.cent(); + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonanceSecondary, lDecayDaughter_bach, lResonanceK1; + for (const auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks2, dTracks2))) { + // Full index policy is needed to consider all possible combinations + if (trk1.index() == trk2.index()) + continue; // We need to run (0,1), (1,0) pairs too. But the same id pairs are not needed. + // trk1: pion, trk2: pion, bTrack: kaon + if (!trackCut(trk1) || !trackCut(trk2)) + continue; + + auto trk1pt = trk1.pt(); + auto trk2pt = trk2.pt(); + auto isTrk1hasTOF = trk1.hasTOF(); + auto isTrk2hasTOF = trk2.hasTOF(); + + if constexpr (!IsResoMicrotrack) { + auto trk1NSigmaPiTPC = trk1.tpcNSigmaPi(); + auto trk1NSigmaPiTOF = (isTrk1hasTOF) ? trk1.tofNSigmaPi() : -999.; + auto trk2NSigmaPiTPC = trk2.tpcNSigmaPi(); + auto trk2NSigmaPiTOF = (isTrk2hasTOF) ? trk2.tofNSigmaPi() : -999.; + + if (cUseOnlyTOFTrackPi && !isTrk1hasTOF) + continue; + if (!selectionPIDpion(trk1) || !selectionPIDpion(trk2)) + continue; + + if constexpr (!IsMix) { + + histos.fill(HIST("QA/trkppionTPCPID"), trk1pt, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/trkppionTOFPID"), trk1pt, trk1NSigmaPiTOF); + histos.fill(HIST("QA/trkppionTPCTOFPID"), trk1NSigmaPiTPC, trk1NSigmaPiTOF); + } + histos.fill(HIST("QA/trkppionpT"), trk1pt); + histos.fill(HIST("QA/trkppionDCAxy"), trk1.dcaXY()); + histos.fill(HIST("QA/trkppionDCAz"), trk1.dcaZ()); + + histos.fill(HIST("QA/trkspionTPCPID"), trk2pt, trk2NSigmaPiTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/trkspionTOFPID"), trk2pt, trk2NSigmaPiTOF); + histos.fill(HIST("QA/trkspionTPCTOFPID"), trk2NSigmaPiTPC, trk2NSigmaPiTOF); + } + histos.fill(HIST("QA/trkspionpT"), trk2pt); + histos.fill(HIST("QA/trkspionDCAxy"), trk2.dcaXY()); + histos.fill(HIST("QA/trkspionDCAz"), trk2.dcaZ()); + } + } else { + histos.fill(HIST("QA/trkppionTPCPID"), trk1pt, o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(trk1.pidNSigmaPiFlag())); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/trkppionTOFPID"), trk1pt, o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(trk1.pidNSigmaPiFlag())); + histos.fill(HIST("QA/trkppionTPCTOFPID"), o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(trk1.pidNSigmaPiFlag()), o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(trk1.pidNSigmaPiFlag())); + } + histos.fill(HIST("QA/trkppionpT"), trk1pt); + histos.fill(HIST("QA/trkppionDCAxy"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(trk1.trackSelectionFlags())); + histos.fill(HIST("QA/trkppionDCAz"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(trk1.trackSelectionFlags())); + + histos.fill(HIST("QA/trkspionTPCPID"), trk2pt, o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(trk2.pidNSigmaPiFlag())); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/trkspionTOFPID"), trk2pt, o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(trk2.pidNSigmaPiFlag())); + histos.fill(HIST("QA/trkspionTPCTOFPID"), o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(trk2.pidNSigmaPiFlag()), o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(trk2.pidNSigmaPiFlag())); + } + histos.fill(HIST("QA/trkspionpT"), trk2pt); + histos.fill(HIST("QA/trkspionDCAxy"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(trk2.trackSelectionFlags())); + histos.fill(HIST("QA/trkspionDCAz"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(trk2.trackSelectionFlags())); + } + + // Resonance reconstruction + lDecayDaughter1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), MassPionCharged); + lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), MassPionCharged); + lResonanceSecondary = lDecayDaughter1 + lDecayDaughter2; + + if (lResonanceSecondary.Pt() < cMinSecondaryPtCut) + continue; + + if constexpr (!IsMix) { + histos.fill(HIST("QA/hInvmassSecon"), lResonanceSecondary.M()); + } + if constexpr (IsMC) { + /* + if (isTrueK892(trk1, trk2)) + histos.fill(HIST("QAMC/hpT_Secondary"), lResonanceSecondary.Pt()); + } else { + if (isTrueRho(trk1, trk2)) + histos.fill(HIST("QAMC/hpT_Secondary"), lResonanceSecondary.Pt()); + } + */ + histos.fill(HIST("QAMC/hpT_Secondary"), lResonanceSecondary.Pt()); + } + // Mass Window cut is removed + + for (const auto& bTrack : dTracks1) { + if (bTrack.index() == trk1.index() || bTrack.index() == trk2.index()) + continue; + if (!trackCut(bTrack)) + continue; + if (!selectionPIDkaon(bTrack)) + continue; + + // K1 reconstruction + lDecayDaughter_bach.SetXYZM(bTrack.px(), bTrack.py(), bTrack.pz(), MassKaonCharged); + lResonanceK1 = lResonanceSecondary + lDecayDaughter_bach; + + // Cuts + if (lResonanceK1.Rapidity() > cK1MaxRap || lResonanceK1.Rapidity() < cK1MinRap) + continue; + + auto lK1Angle = lResonanceSecondary.Angle(lDecayDaughter_bach.Vect()); + auto lPairAsym = (lResonanceSecondary.E() - lDecayDaughter_bach.E()) / (lResonanceSecondary.E() + lDecayDaughter_bach.E()); + + TLorentzVector temp13 = lDecayDaughter1 + lDecayDaughter_bach; + TLorentzVector temp23 = lDecayDaughter2 + lDecayDaughter_bach; + + // QA histogram + if constexpr (!IsMix) { + histos.fill(HIST("QA/K1OA"), lK1Angle); + histos.fill(HIST("QA/K1PairAsym"), lPairAsym); + histos.fill(HIST("QA/hInvmassK892_Rho"), temp13.M(), lResonanceSecondary.M()); + histos.fill(HIST("QA/hInvmassSecon_PiKa"), lResonanceSecondary.M(), temp23.M()); + histos.fill(HIST("QA/hpT_Secondary"), lResonanceSecondary.Pt()); + } + // Selection cuts are removed + // QA histograms after the cuts are removed as no cuts are applied + + if constexpr (!IsMix) { + unsigned int typeK1 = bTrack.sign() > 0 ? BinType::kK1P : BinType::kK1N; + unsigned int typeNormal = BinAnti::kNormal; + if (trk1.sign() * trk2.sign() < 0) { + histos.fill(HIST("k1invmass"), lResonanceK1.M()); + histos.fill(HIST("hInvmass_K1"), typeNormal, typeK1, multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); + } else { + histos.fill(HIST("k1invmass_LS"), lResonanceK1.M()); + histos.fill(HIST("hInvmass_K1_LS"), typeNormal, typeK1, multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); + } + + if constexpr (IsMC) { + if (isTrueK1(trk1, trk2, bTrack)) { + typeK1 = bTrack.sign() > 0 ? BinType::kK1P_Rec : BinType::kK1N_Rec; + histos.fill(HIST("hInvmass_K1"), typeNormal, typeK1, multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); + histos.fill(HIST("k1invmass_MC"), lResonanceK1.M()); + histos.fill(HIST("QAMC/K1OA"), lK1Angle); + histos.fill(HIST("QAMC/K1PairAsym"), lPairAsym); + histos.fill(HIST("QAMC/hInvmassK892_Rho"), temp13.M(), lResonanceSecondary.M()); + histos.fill(HIST("QAMC/hInvmassSecon_PiKa"), lResonanceSecondary.M(), temp23.M()); + histos.fill(HIST("QAMC/hInvmassSecon"), lResonanceSecondary.M()); + histos.fill(HIST("QAMC/hpT_Seocondary"), lResonanceSecondary.Pt()); + + if constexpr (!IsResoMicrotrack) { + + auto trk1NSigmaPiTPC = trk1.tpcNSigmaPi(); + auto trk1NSigmaPiTOF = (isTrk1hasTOF) ? trk1.tofNSigmaPi() : -999.; + auto trk2NSigmaPiTPC = trk2.tpcNSigmaPi(); + auto trk2NSigmaPiTOF = (isTrk2hasTOF) ? trk2.tofNSigmaPi() : -999.; + + // PID QA primary pion + histos.fill(HIST("QAMC/trkppionTPCPID"), trk1pt, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QAMC/trkppionTOFPID"), trk1pt, trk1NSigmaPiTOF); + histos.fill(HIST("QAMC/trkppionTPCTOFPID"), trk1NSigmaPiTPC, trk1NSigmaPiTOF); + } + histos.fill(HIST("QAMC/trkppionpT"), trk1pt); + histos.fill(HIST("QAMC/trkppionDCAxy"), trk1.dcaXY()); + histos.fill(HIST("QAMC/trkppionDCAz"), trk1.dcaZ()); + + // PID QA secondary pion + histos.fill(HIST("QAMC/trkspionTPCPID"), trk2pt, trk2NSigmaPiTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QAMC/trkspionTOFPID"), trk2pt, trk2NSigmaPiTOF); + histos.fill(HIST("QAMC/trkspionTPCTOFPID"), trk2NSigmaPiTPC, trk2NSigmaPiTOF); + } + histos.fill(HIST("QAMC/trkspionpT"), trk2pt); + histos.fill(HIST("QAMC/trkspionDCAxy"), trk2.dcaXY()); + histos.fill(HIST("QAMC/trkspionDCAz"), trk2.dcaZ()); + + } else { + + histos.fill(HIST("QAMC/trkppionTPCPID"), trk1pt, o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(trk1.pidNSigmaSelectionFlags())); + if (isTrk1hasTOF) { + histos.fill(HIST("QAMC/trkppionTOFPID"), trk1pt, o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(trk1.pidNSigmaSelectionFlags())); + histos.fill(HIST("QAMC/trkppionTPCTOFPID"), o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(trk1.pidNSigmaSelectionFlags()), o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(trk1.pidNSigmaSelectionFlags())); + } + histos.fill(HIST("QAMC/trkppionpT"), trk1pt); + histos.fill(HIST("QAMC/trkppionDCAxy"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(trk1.trackSelectionFlags())); + histos.fill(HIST("QAMC/trkppionDCAz"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(trk1.trackSelectionFlags())); + + // PID QA secondary pion + histos.fill(HIST("QAMC/trkspionTPCPID"), trk2pt, o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(trk2.pidNSigmaSelectionFlags())); + if (isTrk2hasTOF) { + histos.fill(HIST("QAMC/trkspionTOFPID"), trk2pt, o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(trk2.pidNSigmaSelectionFlags())); + histos.fill(HIST("QAMC/trkspionTPCTOFPID"), o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(trk2.pidNSigmaSelectionFlags()), o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(trk2.pidNSigmaSelectionFlags())); + } + histos.fill(HIST("QAMC/trkspionpT"), trk2pt); + histos.fill(HIST("QAMC/trkspionDCAxy"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(trk2.trackSelectionFlags())); + histos.fill(HIST("QAMC/trkspionDCAz"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(trk2.trackSelectionFlags())); + } + } else { + histos.fill(HIST("k1invmass_MC_noK1"), lResonanceK1.M()); + } + } // IsMC + } else { + unsigned int typeK1 = bTrack.sign() > 0 ? BinType::kK1P_Mix : BinType::kK1N_Mix; + unsigned int typeNormal = BinAnti::kNormal; + histos.fill(HIST("hInvmass_K1_Mix"), typeNormal, typeK1, multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); + histos.fill(HIST("k1invmass_Mix"), lResonanceK1.M()); + } + } // bTrack + } + } // fillHistograms + + void processResoTracks(aod::ResoCollision const& collision, + aod::ResoTracks const& resotracks) + { + fillHistograms(collision, resotracks, resotracks); + } + PROCESS_SWITCH(K1AnalysisMicro, processResoTracks, "Process ResoTracks", false); + + void processResoMicroTracks(aod::ResoCollision const& collision, + aod::ResoMicroTracks const& resomicrotracks) + { + fillHistograms(collision, resomicrotracks, resomicrotracks); + } + PROCESS_SWITCH(K1AnalysisMicro, processResoMicroTracks, "Process ResoMicroTracks", true); + + void processMC(aod::ResoCollision const& collision, + soa::Join const& resotracks) + { + fillHistograms(collision, resotracks, resotracks); + } + PROCESS_SWITCH(K1AnalysisMicro, processMC, "Process Event for MC", false); + + void processMCTrue(ResoMCCols::iterator const& collision, aod::ResoMCParents const& resoParents) + { + auto multiplicity = collision.cent(); + for (const auto& part : resoParents) { + if (std::abs(part.pdgCode()) != kK1Plus) + continue; + if (std::abs(part.y()) > 0.5) { + continue; + } + bool pass1 = false; + bool pass2 = false; + bool pass3 = false; + bool pass4 = false; + if (std::abs(part.daughterPDG1()) == 313 || std::abs(part.daughterPDG2()) == 313) { // At least one decay into K892 + pass2 = true; + } + if (std::abs(part.daughterPDG1()) == kPiPlus || std::abs(part.daughterPDG2()) == kPiPlus) { // At lest one decay into pion + pass1 = true; + } + if (std::abs(part.daughterPDG1()) == kPDGRho770 || std::abs(part.daughterPDG2()) == kPDGRho770) { + pass4 = true; + } + if (std::abs(part.daughterPDG1()) == kKPlus || std::abs(part.daughterPDG2()) == kKPlus) { + pass3 = true; + } + if (!pass1 || !pass2 || !pass3 || !pass4) // If we have both decay products + continue; + auto typeNormal = part.pdgCode() > 0 ? BinAnti::kNormal : BinAnti::kAnti; + if (collision.isVtxIn10()) // INEL>10 + { + auto typeK1 = part.pdgCode() > 0 ? BinType::kK1P_GenINEL10 : BinType::kK1N_GenINEL10; + histos.fill(HIST("hInvmass_K1"), typeNormal, typeK1, multiplicity, part.pt(), 1); + } + if (collision.isVtxIn10() && collision.isInSel8()) // INEL>10, vtx10 + { + auto typeK1 = part.pdgCode() > 0 ? BinType::kK1P_GenINELgt10 : BinType::kK1N_GenINELgt10; + histos.fill(HIST("hInvmass_K1"), typeNormal, typeK1, multiplicity, part.pt(), 1); + } + if (collision.isVtxIn10() && collision.isTriggerTVX()) // vtx10, TriggerTVX + { + auto typeK1 = part.pdgCode() > 0 ? BinType::kK1P_GenTrig10 : BinType::kK1N_GenTrig10; + histos.fill(HIST("hInvmass_K1"), typeNormal, typeK1, multiplicity, part.pt(), 1); + } + if (collision.isInAfterAllCuts()) // after all event selection + { + auto typeK1 = part.pdgCode() > 0 ? BinType::kK1P_GenEvtSel : BinType::kK1N_GenEvtSel; + histos.fill(HIST("hInvmass_K1"), typeNormal, typeK1, multiplicity, part.pt(), 1); + } + } + } + PROCESS_SWITCH(K1AnalysisMicro, processMCTrue, "Process Event for MC", false); + + // Processing Event Mixing + using BinningTypeVtxZT0M = ColumnBinningPolicy; + void processME(o2::aod::ResoCollisions const& collisions, aod::ResoTracks const& resotracks) + { + auto tracksTuple = std::make_tuple(resotracks); + BinningTypeVtxZT0M colBinning{{cfgVtxBins, cfgMultBins}, true}; + SameKindPair pairs{colBinning, nEvtMixing, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + fillHistograms(collision1, tracks1, tracks2); + } + }; + PROCESS_SWITCH(K1AnalysisMicro, processME, "Process EventMixing light without partition", false); + + // Processing Event Mixing -- Micro + // using BinningTypeVtxZT0M = ColumnBinningPolicy; + void processMEMicro(o2::aod::ResoCollisions const& collisions, aod::ResoMicroTracks const& resomicrotracks) + { + auto tracksTuple = std::make_tuple(resomicrotracks); + BinningTypeVtxZT0M colBinning{{cfgVtxBins, cfgMultBins}, true}; + SameKindPair pairs{colBinning, nEvtMixing, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + fillHistograms(collision1, tracks1, tracks2); + } + }; + PROCESS_SWITCH(K1AnalysisMicro, processMEMicro, "Process EventMixing light without partition", true); +}; // struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Resonances/k1analysis.cxx b/PWGLF/Tasks/Resonances/k1analysis.cxx index 7d145eff641..601227b666e 100644 --- a/PWGLF/Tasks/Resonances/k1analysis.cxx +++ b/PWGLF/Tasks/Resonances/k1analysis.cxx @@ -15,6 +15,7 @@ /// /// \author Bong-Hwi Lim +#include #include #include // FIXME #include // FIXME @@ -99,15 +100,9 @@ struct k1analysis { Configurable additionalQAplots{"additionalQAplots", true, "Additional QA plots"}; Configurable tof_at_high_pt{"tof_at_high_pt", false, "Use TOF at high pT"}; Configurable additionalEvsel{"additionalEvsel", true, "Additional event selcection"}; - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; - Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; - Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; - Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; - Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; - Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; // Secondary selection @@ -272,20 +267,8 @@ struct k1analysis { return false; if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) return false; - if (track.itsNCls() < cfgITScluster) - return false; if (track.tpcNClsFound() < cfgTPCcluster) return false; - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) - return false; - if (track.itsChi2NCl() >= cfgITSChi2NCl) - return false; - if (track.tpcChi2NCl() >= cfgTPCChi2NCl) - return false; - if (cfgHasITS && !track.hasITS()) - return false; - if (cfgHasTPC && !track.hasTPC()) - return false; if (cfgHasTOF && !track.hasTOF()) return false; if (cfgUseITSRefit && !track.passedITSRefit()) diff --git a/PWGLF/Tasks/Resonances/k892SpherocityAnalysis.cxx b/PWGLF/Tasks/Resonances/k892SpherocityAnalysis.cxx index 1c3490e0164..7081f79c751 100644 --- a/PWGLF/Tasks/Resonances/k892SpherocityAnalysis.cxx +++ b/PWGLF/Tasks/Resonances/k892SpherocityAnalysis.cxx @@ -437,7 +437,7 @@ struct k892Analysis { } } - using resoCols = aod::ResoCollisions; + using resoCols = soa::Join; using resoTracks = aod::ResoTracks; void processData(resoCols::iterator const& collision, resoTracks const& tracks) diff --git a/PWGLF/Tasks/Resonances/k892analysis.cxx b/PWGLF/Tasks/Resonances/k892analysis.cxx index 2a980b3ffcd..34e4cc662a0 100644 --- a/PWGLF/Tasks/Resonances/k892analysis.cxx +++ b/PWGLF/Tasks/Resonances/k892analysis.cxx @@ -8,7 +8,7 @@ // 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. - +/// /// \file k892analysis.cxx /// \brief Reconstruction of track-track decay resonance candidates /// @@ -35,7 +35,7 @@ using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::constants::physics; -struct k892analysis { +struct K892analysis { SliceCache cache; Preslice perRCol = aod::resodaughter::resoCollisionId; Preslice perCollision = aod::track::collisionId; @@ -48,7 +48,7 @@ struct k892analysis { ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; ConfigurableAxis binsPtQA{"binsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0}, "Binning of the pT axis"}; ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; - ConfigurableAxis occupancy_bins{"occupancy_bins", {VARIABLE_WIDTH, 0.0, 100, 500, 600, 1000, 1100, 1500, 1600, 2000, 2100, 2500, 2600, 3000, 3100, 3500, 3600, 4000, 4100, 4500, 4600, 5000, 5100, 9999}, "Binning of the occupancy axis"}; + ConfigurableAxis occupancyBins{"occupancyBins", {VARIABLE_WIDTH, 0.0, 100, 500, 600, 1000, 1100, 1500, 1600, 2000, 2100, 2500, 2600, 3000, 3100, 3500, 3600, 4000, 4100, 4500, 4600, 5000, 5100, 9999}, "Binning of the occupancy axis"}; // ConfigurableAxis binsCent{"binsCent", {200, 0.0f, 200.0f}, "Binning of the centrality axis"}; Configurable cInvMassStart{"cInvMassStart", 0.6, "Invariant mass start"}; Configurable cInvMassEnd{"cInvMassEnd", 1.5, "Invariant mass end"}; @@ -57,15 +57,15 @@ struct k892analysis { Configurable cPIDQALimit{"cPIDQALimit", 6.5, "PID QA limit"}; Configurable cDCABins{"cDCABins", 150, "DCA binning"}; Configurable invmass1D{"invmass1D", false, "Invariant mass 1D"}; - Configurable study_antiparticle{"study_antiparticle", false, "Study anti-particles separately"}; - Configurable PIDplots{"PIDplots", false, "Make TPC and TOF PID plots"}; - Configurable applyOccupancyCut{"applyOccupancyCut", false, "Apply occupancy cut"}; - Configurable OccupancyCut{"OccupancyCut", 1000, "Mimimum Occupancy cut"}; + Configurable studyAntiparticle{"studyAntiparticle", false, "Study anti-particles separately"}; + Configurable fillPidPlots{"fillPidPlots", false, "Make TPC and TOF PID plots"}; + // Configurable applyOccupancyCut{"applyOccupancyCut", false, "Apply occupancy cut"}; + // Configurable occupancyCut{"occupancyCut", 1000, "Mimimum Occupancy cut"}; /// Event Mixing Configurable nEvtMixing{"nEvtMixing", 5, "Number of events to mix"}; - ConfigurableAxis CfgVtxBins{"CfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; - ConfigurableAxis CfgMultBins{"CfgMultBins", {VARIABLE_WIDTH, 0.0f, 1.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgMultBins{"cfgMultBins", {VARIABLE_WIDTH, 0.0f, 1.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - z-vertex"}; /// Pre-selection cuts Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"}; @@ -95,23 +95,17 @@ struct k892analysis { Configurable additionalQAeventPlots{"additionalQAeventPlots", false, "Additional QA event plots"}; Configurable additionalMEPlots{"additionalMEPlots", false, "Additional Mixed event plots"}; - Configurable tof_at_high_pt{"tof_at_high_pt", false, "Use TOF at high pT"}; + Configurable tofAtHighPt{"tofAtHighPt", false, "Use TOF at high pT"}; Configurable additionalEvsel{"additionalEvsel", true, "Additional event selcection"}; - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; - Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; - Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; - Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; - Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; - Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; // Rotational background - Configurable IsCalcRotBkg{"IsCalcRotBkg", true, "Calculate rotational background"}; - Configurable rotational_cut{"rotational_cut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; - Configurable c_nof_rotations{"c_nof_rotations", 3, "Number of random rotations in the rotational background"}; + Configurable isCalcRotBkg{"isCalcRotBkg", true, "Calculate rotational background"}; + Configurable rotationalCut{"rotationalCut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; + Configurable cNofRotations{"cNofRotations", 3, "Number of random rotations in the rotational background"}; // MC Event selection Configurable cZvertCutMC{"cZvertCutMC", 10.0, "MC Z-vertex cut"}; @@ -143,7 +137,7 @@ struct k892analysis { AxisSpec ptAxisQA = {binsPtQA, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec invMassAxis = {cInvMassBins, cInvMassStart, cInvMassEnd, "Invariant Mass (GeV/#it{c}^2)"}; AxisSpec pidQAAxis = {cPIDBins, -cPIDQALimit, cPIDQALimit}; - AxisSpec occupancy_axis = {occupancy_bins, "Occupancy [-40,100]"}; + // AxisSpec occupancyAxis = {occupancyBins, "Occupancy [-40,100]"}; if (additionalQAeventPlots) { // Test on Mixed event @@ -169,7 +163,7 @@ struct k892analysis { histos.add("k892invmassDS", "Invariant mass of K(892)0 differnt sign", kTH1F, {invMassAxis}); histos.add("k892invmassLS", "Invariant mass of K(892)0 like sign", kTH1F, {invMassAxis}); histos.add("k892invmassME", "Invariant mass of K(892)0 mixed event", kTH1F, {invMassAxis}); - if (study_antiparticle) { + if (studyAntiparticle) { histos.add("k892invmassDSAnti", "Invariant mass of Anti-K(892)0 differnt sign", kTH1F, {invMassAxis}); histos.add("k892invmassLSAnti", "Invariant mass of Anti-K(892)0 like sign", kTH1F, {invMassAxis}); } @@ -214,7 +208,7 @@ struct k892analysis { histos.add("QAafter/trkpT_pi", "pT distribution of pion track candidates", kTH1F, {ptAxis}); histos.add("QAafter/trkpT_ka", "pT distribution of kaon track candidates", kTH1F, {ptAxis}); // PID QA before cuts - if (PIDplots) { + if (fillPidPlots) { histos.add("QAbefore/TOF_TPC_Map_pi_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); histos.add("QAbefore/TOF_Nsigma_pi_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); histos.add("QAbefore/TPC_Nsigma_pi_all", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); @@ -253,17 +247,17 @@ struct k892analysis { } // 3d histogram - histos.add("h3k892invmassDS", "Invariant mass of K(892)0 differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, occupancy_axis}); - histos.add("h3k892invmassLS", "Invariant mass of K(892)0 same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, occupancy_axis}); - histos.add("h3k892invmassME", "Invariant mass of K(892)0 mixed event", kTHnSparseF, {centAxis, ptAxis, invMassAxis, occupancy_axis}); - histos.add("h3k892invmassLSAnti", "Invariant mass of Anti-K(892)0 same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, occupancy_axis}); + histos.add("h3k892invmassDS", "Invariant mass of K(892)0 differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassLS", "Invariant mass of K(892)0 same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassME", "Invariant mass of K(892)0 mixed event", kTHnSparseF, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassLSAnti", "Invariant mass of Anti-K(892)0 same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis}); - if (study_antiparticle) { - histos.add("h3k892invmassDSAnti", "Invariant mass of Anti-K(892)0 differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, occupancy_axis}); + if (studyAntiparticle) { + histos.add("h3k892invmassDSAnti", "Invariant mass of Anti-K(892)0 differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis}); } - if (IsCalcRotBkg) { - histos.add("h3K892InvMassRotation", "Invariant mass of K(892)0 rotation", kTHnSparseF, {centAxis, ptAxis, invMassAxis, occupancy_axis}); + if (isCalcRotBkg) { + histos.add("h3K892InvMassRotation", "Invariant mass of K(892)0 rotation", kTHnSparseF, {centAxis, ptAxis, invMassAxis}); } if (additionalMEPlots) { @@ -277,7 +271,7 @@ struct k892analysis { histos.add("QAMCTrue/trkDCAxy_ka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {dcaxyAxis}); histos.add("QAMCTrue/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH1F, {dcazAxis}); histos.add("QAMCTrue/trkDCAz_ka", "DCAz distribution of kaon track candidates", HistType::kTH1F, {dcazAxis}); - if (PIDplots) { + if (fillPidPlots) { histos.add("QAMCTrue/TOF_Nsigma_pi_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); histos.add("QAMCTrue/TPC_Nsigma_pi_all", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); histos.add("QAMCTrue/TOF_Nsigma_ka_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); @@ -343,20 +337,8 @@ struct k892analysis { return false; if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) return false; - if (track.itsNCls() < cfgITScluster) - return false; if (track.tpcNClsFound() < cfgTPCcluster) return false; - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) - return false; - if (track.itsChi2NCl() >= cfgITSChi2NCl) - return false; - if (track.tpcChi2NCl() >= cfgTPCChi2NCl) - return false; - if (cfgHasITS && !track.hasITS()) - return false; - if (cfgHasTPC && !track.hasTPC()) - return false; if (cfgHasTOF && !track.hasTOF()) return false; if (cfgUseITSRefit && !track.passedITSRefit()) @@ -378,7 +360,7 @@ struct k892analysis { template bool selectionPIDPion(const T& candidate) { - if (tof_at_high_pt) { + if (tofAtHighPt) { if (candidate.hasTOF() && (std::abs(candidate.tofNSigmaPi()) < cMaxTOFnSigmaPion)) { return true; } @@ -412,7 +394,7 @@ struct k892analysis { template bool selectionPIDKaon(const T& candidate) { - if (tof_at_high_pt) { + if (tofAtHighPt) { if (candidate.hasTOF() && (std::abs(candidate.tofNSigmaKa()) < cMaxTOFnSigmaKaon)) { return true; } @@ -452,10 +434,10 @@ struct k892analysis { if (additionalEvsel && !eventSelected(collision, multiplicity)) { return; } - auto occupancy_no = collision.trackOccupancyInTimeRange(); - if (applyOccupancyCut && occupancy_no < OccupancyCut) { - return; - } + // auto occupancyNo = collision.trackOccupancyInTimeRange(); + // if (applyOccupancyCut && occupancyNo < occupancyCut) { + // return; + // } if (additionalQAplots) { histos.fill(HIST("MultCalib/centglopi_before"), multiplicity, dTracks1.size()); // centrality vs global tracks before the multiplicity calibration cuts @@ -481,8 +463,8 @@ struct k892analysis { histos.fill(HIST("MultCalib/GloPVpi_after"), dTracks1.size(), collision.multNTracksPV()); // global tracks vs PV tracks after the multiplicity calibration cuts } - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance, ldaughter_rot, lresonance_rot; - for (auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance, ldaughterRot, lresonanceRot; + for (const auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { // Full index policy is needed to consider all possible combinations if (trk1.index() == trk2.index()) @@ -511,14 +493,14 @@ struct k892analysis { auto trk2NSigmaKaTPC = trk2.tpcNSigmaKa(); auto trk2NSigmaKaTOF = (isTrk2hasTOF) ? trk2.tofNSigmaKa() : -999.; - auto deltaEta = TMath::Abs(trk1.eta() - trk2.eta()); - auto deltaPhi = TMath::Abs(trk1.phi() - trk2.phi()); - deltaPhi = (deltaPhi > TMath::Pi()) ? (2 * TMath::Pi() - deltaPhi) : deltaPhi; + auto deltaEta = std::abs(trk1.eta() - trk2.eta()); + auto deltaPhi = std::abs(trk1.phi() - trk2.phi()); + deltaPhi = (deltaPhi > constants::math::PI) ? (constants::math::TwoPI - deltaPhi) : deltaPhi; if constexpr (!IsMix) { //// QA plots before the selection // --- PID QA Pion - if (PIDplots) { + if (fillPidPlots) { histos.fill(HIST("QAbefore/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); if (isTrk1hasTOF) { histos.fill(HIST("QAbefore/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); @@ -565,7 +547,7 @@ struct k892analysis { if constexpr (!IsMix) { //// QA plots after the selection // --- PID QA Pion - if (PIDplots) { + if (fillPidPlots) { histos.fill(HIST("QAafter/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); if (isTrk1hasTOF) { histos.fill(HIST("QAafter/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); @@ -601,7 +583,7 @@ struct k892analysis { lDecayDaughter2.SetPtEtaPhiM(trk2.pt(), trk2.eta(), trk2.phi(), massKa); lResonance = lDecayDaughter1 + lDecayDaughter2; // Rapidity cut - if (abs(lResonance.Rapidity()) >= 0.5) + if (std::abs(lResonance.Rapidity()) >= 0.5) continue; if (cfgCutsOnMother) { if (lResonance.Pt() >= cMaxPtMotherCut) // excluding candidates in overflow @@ -629,33 +611,33 @@ struct k892analysis { //// Un-like sign pair only if (trk1.sign() * trk2.sign() < 0) { if constexpr (!IsMix) { - if (IsCalcRotBkg) { - for (int i = 0; i < c_nof_rotations; i++) { - float theta2 = rn->Uniform(TMath::Pi() - TMath::Pi() / rotational_cut, TMath::Pi() + TMath::Pi() / rotational_cut); - ldaughter_rot.SetPtEtaPhiM(trk2.pt(), trk2.eta(), trk2.phi() + theta2, massKa); // for rotated background - lresonance_rot = lDecayDaughter1 + ldaughter_rot; - histos.fill(HIST("h3K892InvMassRotation"), multiplicity, lresonance_rot.Pt(), lresonance_rot.M(), occupancy_no); + if (isCalcRotBkg) { + for (int i = 0; i < cNofRotations; i++) { + float theta2 = rn->Uniform(constants::math::PI - constants::math::PI / rotationalCut, constants::math::PI + constants::math::PI / rotationalCut); + ldaughterRot.SetPtEtaPhiM(trk2.pt(), trk2.eta(), trk2.phi() + theta2, massKa); // for rotated background + lresonanceRot = lDecayDaughter1 + ldaughterRot; + histos.fill(HIST("h3K892InvMassRotation"), multiplicity, lresonanceRot.Pt(), lresonanceRot.M()); } } - if (study_antiparticle) { + if (studyAntiparticle) { if (trk1.sign() < 0) { if (invmass1D) histos.fill(HIST("k892invmassDS"), lResonance.M()); - histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); + histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M()); } else if (trk1.sign() > 0) { if (invmass1D) histos.fill(HIST("k892invmassDSAnti"), lResonance.M()); - histos.fill(HIST("h3k892invmassDSAnti"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); + histos.fill(HIST("h3k892invmassDSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); } } else { if (invmass1D) histos.fill(HIST("k892invmassDS"), lResonance.M()); - histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); + histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M()); } } else { if (invmass1D) histos.fill(HIST("k892invmassME"), lResonance.M()); - histos.fill(HIST("h3k892invmassME"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); + histos.fill(HIST("h3k892invmassME"), multiplicity, lResonance.Pt(), lResonance.M()); if (additionalMEPlots) { if (trk1.sign() < 0) { if (invmass1D) @@ -671,11 +653,11 @@ struct k892analysis { // MC if constexpr (IsMC) { - if (abs(trk1.pdgCode()) != 211 || abs(trk2.pdgCode()) != 321) + if (std::abs(trk1.pdgCode()) != 211 || std::abs(trk2.pdgCode()) != 321) continue; if (trk1.motherId() != trk2.motherId()) // Same mother continue; - if (abs(trk1.motherPDG()) != 313) + if (std::abs(trk1.motherPDG()) != 313) continue; // Track selection check. @@ -683,7 +665,7 @@ struct k892analysis { histos.fill(HIST("QAMCTrue/trkDCAxy_ka"), trk2.dcaXY()); histos.fill(HIST("QAMCTrue/trkDCAz_pi"), trk1.dcaZ()); histos.fill(HIST("QAMCTrue/trkDCAz_ka"), trk2.dcaZ()); - if (PIDplots) { + if (fillPidPlots) { histos.fill(HIST("QAMCTrue/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); if (isTrk1hasTOF) { histos.fill(HIST("QAMCTrue/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); @@ -710,18 +692,18 @@ struct k892analysis { if (trk1.sign() < 0) { if (invmass1D) histos.fill(HIST("k892invmassLS"), lResonance.M()); - histos.fill(HIST("h3k892invmassLS"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); + histos.fill(HIST("h3k892invmassLS"), multiplicity, lResonance.Pt(), lResonance.M()); } else if (trk1.sign() > 0) { if (invmass1D) histos.fill(HIST("k892invmassLSAnti"), lResonance.M()); - histos.fill(HIST("h3k892invmassLSAnti"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); + histos.fill(HIST("h3k892invmassLSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); } } } } } - void processDataLight(aod::ResoCollision& collision, + void processDataLight(aod::ResoCollision const& collision, aod::ResoTracks const& resotracks) { // LOG(info) << "new collision, zvtx: " << collision.posZ(); @@ -729,25 +711,25 @@ struct k892analysis { histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); fillHistograms(collision, resotracks, resotracks); } - PROCESS_SWITCH(k892analysis, processDataLight, "Process Event for data", false); + PROCESS_SWITCH(K892analysis, processDataLight, "Process Event for data", false); void processMCLight(ResoMCCols::iterator const& collision, soa::Join const& resotracks) { - if (!collision.isInAfterAllCuts() || (abs(collision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut + if (!collision.isInAfterAllCuts() || (std::abs(collision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut return; fillHistograms(collision, resotracks, resotracks); } - PROCESS_SWITCH(k892analysis, processMCLight, "Process Event for MC (Reconstructed)", false); + PROCESS_SWITCH(K892analysis, processMCLight, "Process Event for MC (Reconstructed)", false); - void processMCTrue(ResoMCCols::iterator const& collision, aod::ResoMCParents& resoParents) + void processMCTrue(ResoMCCols::iterator const& collision, aod::ResoMCParents const& resoParents) { auto multiplicity = collision.cent(); - for (auto& part : resoParents) { // loop over all pre-filtered MC particles - if (abs(part.pdgCode()) != 313 || abs(part.y()) >= 0.5) + for (const auto& part : resoParents) { // loop over all pre-filtered MC particles + if (std::abs(part.pdgCode()) != 313 || std::abs(part.y()) >= 0.5) continue; - bool pass1 = abs(part.daughterPDG1()) == 211 || abs(part.daughterPDG2()) == 211; - bool pass2 = abs(part.daughterPDG1()) == 321 || abs(part.daughterPDG2()) == 321; + bool pass1 = std::abs(part.daughterPDG1()) == 211 || std::abs(part.daughterPDG2()) == 211; + bool pass2 = std::abs(part.daughterPDG1()) == 321 || std::abs(part.daughterPDG2()) == 321; if (!pass1 || !pass2) continue; @@ -782,26 +764,26 @@ struct k892analysis { } } } - PROCESS_SWITCH(k892analysis, processMCTrue, "Process Event for MC (Generated)", false); + PROCESS_SWITCH(K892analysis, processMCTrue, "Process Event for MC (Generated)", false); // Processing Event Mixing using BinningTypeVtxZT0M = ColumnBinningPolicy; - void processMELight(o2::aod::ResoCollisions& collisions, aod::ResoTracks const& resotracks) + void processMELight(o2::aod::ResoCollisions const& collisions, aod::ResoTracks const& resotracks) { auto tracksTuple = std::make_tuple(resotracks); - BinningTypeVtxZT0M colBinning{{CfgVtxBins, CfgMultBins}, true}; + BinningTypeVtxZT0M colBinning{{cfgVtxBins, cfgMultBins}, true}; SameKindPair pairs{colBinning, nEvtMixing, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip - for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { if (additionalQAeventPlots) histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); fillHistograms(collision1, tracks1, tracks2); } }; - PROCESS_SWITCH(k892analysis, processMELight, "Process EventMixing light without partition", false); + PROCESS_SWITCH(K892analysis, processMELight, "Process EventMixing light without partition", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"lf-k892analysis"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Resonances/k892analysis_PbPb.cxx b/PWGLF/Tasks/Resonances/k892analysispbpb.cxx similarity index 52% rename from PWGLF/Tasks/Resonances/k892analysis_PbPb.cxx rename to PWGLF/Tasks/Resonances/k892analysispbpb.cxx index d1866ffb594..303a6cd6fc9 100644 --- a/PWGLF/Tasks/Resonances/k892analysis_PbPb.cxx +++ b/PWGLF/Tasks/Resonances/k892analysispbpb.cxx @@ -9,6 +9,8 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // +/// \file k892analysispbpb.cxx +/// \brief K*0 spectra in Pb-Pb /// \author Marta Urioni #include @@ -19,9 +21,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -51,7 +53,7 @@ using namespace o2::soa; using namespace o2::constants::physics; using std::array; -struct k892analysis_PbPb { +struct K892analysispbpb { SliceCache cache; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -67,6 +69,8 @@ struct k892analysis_PbPb { Configurable cPIDBins{"cPIDBins", 65, "PID binning"}; Configurable cPIDQALimit{"cPIDQALimit", 6.5, "PID QA limit"}; Configurable cDCABins{"cDCABins", 300, "DCA binning"}; + Configurable cPDGbins{"cPDGbins", 5000, "number of PDG bins"}; + Configurable cPDGMax{"cPDGMax", 9500000.0f, "PDG limit"}; // events Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; @@ -76,16 +80,23 @@ struct k892analysis_PbPb { // presel Configurable cfgCutCentrality{"cfgCutCentrality", 80.0f, "Accepted maximum Centrality"}; + Configurable cfgCutMaxOccupancy{"cfgCutMaxOccupancy", 2000.0f, "Accepted maximum Occupancy"}; + Configurable cfgApplyOccupancyCut{"cfgApplyOccupancyCut", false, "Apply maximum Occupancy"}; // Track selections Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; + Configurable cfgIsPhysicalPrimary{"cfgIsPhysicalPrimary", true, "Primary track selection in MC"}; // for MC bkg study + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor + Configurable cfgUseITSTPCrefit{"cfgUseITSTPCrefit", true, "Use ITS and TPC refit"}; + Configurable cfgITSChi2Ncl{"cfgITSChi2Ncl", 999.0, "ITS Chi2/NCl"}; + Configurable cfgTPCChi2Ncl{"cfgTPCChi2Ncl", 999.0, "TPC Chi2/NCl"}; Configurable cfgCutPT{"cfgCutPT", 0.2, "PT cut on daughter track"}; Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; @@ -96,16 +107,23 @@ struct k892analysis_PbPb { Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF Configurable cByPassTOF{"cByPassTOF", false, "By pass TOF PID selection"}; // By pass TOF PID selection + Configurable cTofBetaCut{"cTofBetaCut", false, "selection on TOF beta"}; - Configurable TofandTpcPID{"TOFandTPCPID", false, "apply both TOF and TPC PID"}; + Configurable cTPClowpt{"cTPClowpt", true, "apply TPC at low pt"}; + Configurable cTOFonlyHighpt{"cTOFonlyHighpt", false, "apply TOF only at high pt"}; + Configurable cTOFandTPCHighpt{"cTOFandTPCHighpt", false, "apply TOF and TPC at high pt"}; - Configurable tpclowpt{"tpclowpt", true, "apply TPC at low pt"}; - Configurable tofhighpt{"tofhighpt", false, "apply TOF at high pt"}; + // rotational bkg + Configurable cfgNoRotations{"cfgNoRotations", 3, "Number of rotations per pair for rotbkg"}; + Configurable rotationalCut{"rotationalCut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; + Configurable cfgRotPi{"cfgRotPi", true, "rotate Pion"}; // event mixing Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 5, "Number of mixed events per event"}; - ConfigurableAxis CfgVtxBins{"CfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; - ConfigurableAxis CfgMultBins{"CfgMultBins", {VARIABLE_WIDTH, 0.0f, 1.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f}, "Mixing bins - z-vertex"}; + + ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgMultBins{"cfgMultBins", {VARIABLE_WIDTH, 0.0f, 1.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f}, "Mixing bins - z-vertex"}; + ConfigurableAxis binsImpactPar{"binsImpactPar", {VARIABLE_WIDTH, 0.0, 3.00065, 4.28798, 6.14552, 7.6196, 8.90942, 10.0897, 11.2002, 12.2709, 13.3167, 14.4173, 23.2518}, "Binning of the impact parameter axis"}; // cuts on mother Configurable cfgCutsOnMother{"cfgCutsOnMother", false, "Enamble additional cuts on mother"}; @@ -122,9 +140,10 @@ struct k892analysis_PbPb { Configurable additionalMEPlots{"additionalMEPlots", false, "Additional Mixed event plots"}; // MC - Configurable genacceptancecut{"genacceptancecut", false, "Acceptance cut on generated MC particles"}; Configurable avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"}; + TRandom* rand = new TRandom(); + void init(o2::framework::InitContext&) { AxisSpec centAxis = {binsCent, "V0M (%)"}; @@ -133,10 +152,14 @@ struct k892analysis_PbPb { AxisSpec mcLabelAxis = {5, -0.5, 4.5, "MC Label"}; AxisSpec ptAxis = {binsPt, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec ptAxisQA = {binsPtQA, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec ptAxisMom = {binsPt, "Mom #it{p}_{T} (GeV/#it{c})"}; + AxisSpec ptAxisDau = {binsPtQA, "Dau #it{p}_{T} (GeV/#it{c})"}; AxisSpec invMassAxis = {cInvMassBins, cInvMassStart, cInvMassEnd, "Invariant Mass (GeV/#it{c}^2)"}; AxisSpec pidQAAxis = {cPIDBins, -cPIDQALimit, cPIDQALimit}; + AxisSpec pdgCodeAxis = {cPDGbins, 0, cPDGMax}; + AxisSpec impactParAxis = {binsImpactPar, "Impact Parameter"}; - if (doprocessSameEvent || doprocessSameEventRun2 || doprocessMixedEvent || doprocessMixedEventRun2) { + if ((!doprocessMC && !doprocessMCRun2) || doprocessMixedEventMC || doprocessMixedEventMCRun2) { // event histograms histos.add("QAevent/hEvtCounterSameE", "Number of analyzed Same Events", HistType::kTH1F, {{1, 0.5, 1.5}}); histos.add("QAevent/hMultiplicityPercentSameE", "Multiplicity percentile of collision", HistType::kTH1F, {{120, 0.0f, 120.0f}}); @@ -163,7 +186,7 @@ struct k892analysis_PbPb { histos.add("k892invmassDSAnti", "Invariant mass of Anti-K(892)0 different sign", kTH1F, {invMassAxis}); histos.add("k892invmassLS", "Invariant mass of K(892)0 like sign", kTH1F, {invMassAxis}); histos.add("k892invmassLSAnti", "Invariant mass of Anti-K(892)0 like sign", kTH1F, {invMassAxis}); - if (doprocessMixedEvent || doprocessMixedEventRun2) { + if (doprocessMixedEvent || doprocessMixedEventRun2 || doprocessMixedEventMC || doprocessMixedEventMCRun2) { histos.add("k892invmassME", "Invariant mass of K(892)0 mixed event", kTH1F, {invMassAxis}); if (additionalMEPlots) { histos.add("k892invmassME_DS", "Invariant mass of K(892)0 mixed event DS", kTH1F, {invMassAxis}); @@ -173,10 +196,24 @@ struct k892analysis_PbPb { if (additionalQAplots) { // TPC ncluster distirbutions - histos.add("TPCncluster/TPCnclusterpi", "TPC ncluster distribution", kTH1F, {{160, 0, 160, "TPC nCluster"}}); - histos.add("TPCncluster/TPCnclusterka", "TPC ncluster distribution", kTH1F, {{160, 0, 160, "TPC nCluster"}}); - histos.add("TPCncluster/TPCnclusterPhipi", "TPC ncluster vs phi", kTH2F, {{160, 0, 160, "TPC nCluster"}, {63, 0, 6.28, "#phi"}}); - histos.add("TPCncluster/TPCnclusterPhika", "TPC ncluster vs phi", kTH2F, {{160, 0, 160, "TPC nCluster"}, {63, 0, 6.28, "#phi"}}); + histos.add("Ncluster/TPCnclusterpi", "TPC ncluster distribution", kTH1F, {{160, 0, 160, "TPC nCluster"}}); + histos.add("Ncluster/TPCnclusterka", "TPC ncluster distribution", kTH1F, {{160, 0, 160, "TPC nCluster"}}); + histos.add("Ncluster/TPCnclusterPhipi", "TPC ncluster vs phi", kTH2F, {{160, 0, 160, "TPC nCluster"}, {63, 0, 6.28, "#phi"}}); + histos.add("Ncluster/TPCnclusterPhika", "TPC ncluster vs phi", kTH2F, {{160, 0, 160, "TPC nCluster"}, {63, 0, 6.28, "#phi"}}); + + histos.add("Ncluster/TPCChi2ncluster", "TPC Chi2ncluster distribution", kTH1F, {{100, 0, 10, "TPC Chi2nCluster"}}); + histos.add("Ncluster/ITSChi2ncluster", "ITS Chi2ncluster distribution", kTH1F, {{100, 0, 40, "ITS Chi2nCluster"}}); + histos.add("Ncluster/ITSncluster", "ITS ncluster distribution", kTH1F, {{10, 0, 10, "ITS nCluster"}}); + + histos.add("QA/h2k892ptMothervsptPiDS", "Pt of K(892)0 differnt sign vs pt pion daughter", kTH2F, {ptAxisMom, ptAxisDau}); + histos.add("QA/h2k892ptMothervsptPiDSAnti", "Pt of Anti-K(892)0 differnt sign vs pt pion daughter", kTH2F, {ptAxisMom, ptAxisDau}); + histos.add("QA/h2k892ptMothervsptKaDS", "Pt of K(892)0 differnt sign vs pt kaon daughter", kTH2F, {ptAxisMom, ptAxisDau}); + histos.add("QA/h2k892ptMothervsptKaDSAnti", "Pt of Anti-K(892)0 differnt sign vs pt kaon daughter", kTH2F, {ptAxisMom, ptAxisDau}); + + histos.add("QAME/h2k892ptMothervsptPiDS", "Pt of Mother vs pt pion daughter, Mixed Event", kTH2F, {ptAxisMom, ptAxisDau}); + histos.add("QAME/h2k892ptMothervsptPiDSAnti", "Pt of Anti-Mother vs pt pion daughter, Mixed Event", kTH2F, {ptAxisMom, ptAxisDau}); + histos.add("QAME/h2k892ptMothervsptKaDS", "Pt of Mother vs pt kaon daughter, Mixed Event", kTH2F, {ptAxisMom, ptAxisDau}); + histos.add("QAME/h2k892ptMothervsptKaDSAnti", "Pt of Anti-Mother vs pt pion daughter, Mixed Event", kTH2F, {ptAxisMom, ptAxisDau}); } // DCA QA @@ -195,12 +232,21 @@ struct k892analysis_PbPb { histos.add("QA/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); histos.add("QA/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); - // 3d histogram + // inv mass histograms histos.add("h3k892invmassDS", "Invariant mass of K(892)0 differnt sign", kTH3F, {centAxis, ptAxis, invMassAxis}); histos.add("h3k892invmassDSAnti", "Invariant mass of Anti-K(892)0 differnt sign", kTH3F, {centAxis, ptAxis, invMassAxis}); histos.add("h3k892invmassLS", "Invariant mass of K(892)0 same sign", kTH3F, {centAxis, ptAxis, invMassAxis}); histos.add("h3k892invmassLSAnti", "Invariant mass of Anti-K(892)0 same sign", kTH3F, {centAxis, ptAxis, invMassAxis}); - if (doprocessMixedEvent || doprocessMixedEventRun2) { + + if (doprocessRotationalBkg || doprocessRotationalBkgMC) { + histos.add("k892invmassRotDS", "Invariant mass of K(892)0 RotBkg", kTH1F, {invMassAxis}); + histos.add("k892invmassRotDSAnti", "Invariant mass of Anti-K(892)0 RotBkg", kTH1F, {invMassAxis}); + + histos.add("h3k892invmassRotDS", "Invariant mass of K(892)0 Rotational Bkg", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassRotDSAnti", "Invariant mass of Anti-K(892)0 Rotational Bkg", kTH3F, {centAxis, ptAxis, invMassAxis}); + } + + if (doprocessMixedEvent || doprocessMixedEventRun2 || doprocessMixedEventMC || doprocessMixedEventMCRun2) { histos.add("h3k892invmassME", "Invariant mass of K(892)0 mixed event", kTH3F, {centAxis, ptAxis, invMassAxis}); if (additionalMEPlots) { @@ -216,8 +262,15 @@ struct k892analysis_PbPb { } } + if (doprocessMixedEventMC || doprocessMixedEventMCRun2) { + histos.add("h3k892invmassWrongDaughtersME_DS", "Invariant mass ME with wrong daughters DS", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassWrongDaughtersME_DSAnti", "Invariant mass ME with wrong daughters DS anti", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassRightDaughtersME_DS", "Invariant mass ME with right daughters DS", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassRightDaughtersME_DSAnti", "Invariant mass ME with right daughters DS anti", kTH3F, {centAxis, ptAxis, invMassAxis}); + } + if (doprocessMC || doprocessMCRun2) { - histos.add("hMCrecCollSels", "MC Event statistics", HistType::kTH1F, {{10, 0.0f, 10.0f}}); + histos.add("QAevent/hMCrecCollSels", "MC Event statistics", HistType::kTH1F, {{10, 0.0f, 10.0f}}); histos.add("QAevent/hMultiplicityPercentMC", "Multiplicity percentile of MCrec collision", HistType::kTH1F, {{120, 0.0f, 120.0f}}); histos.add("h1k892Recsplit", "k892 Rec split", HistType::kTH1F, {{200, 0.0f, 20.0f}}); @@ -242,7 +295,33 @@ struct k892analysis_PbPb { histos.add("k892RecAnti", "pT distribution of Reconstructed MC Anti-K(892)0", kTH2F, {ptAxis, centAxis}); histos.add("h3k892GenInvmass", "Invariant mass of generated K(892)0", kTH3F, {centAxis, ptAxis, invMassAxis}); histos.add("h3k892GenInvmassAnti", "Invariant mass of generated Anti-K(892)0", kTH3F, {centAxis, ptAxis, invMassAxis}); + + histos.add("h3Reck892invmassPtGen", "Invariant mass of Reconstructed MC K(892)0 with Pt Gen", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3Reck892invmassAntiPtGen", "Invariant mass of Reconstructed MC Anti-K(892)0 with Pt Gen", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3PtRecvsPtGenAnti", "reconstructed K* Pt vs generated K* pt", kTH3F, {centAxis, ptAxis, ptAxis}); + histos.add("h3PtRecvsPtGen", "reconstructed Anti-K* Pt vs generated Anti-K* pt", kTH3F, {centAxis, ptAxis, ptAxis}); + + histos.add("h3k892invmassWrongDaughters_DS", "Invariant mass of K*0 with wrong daughters DS", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassWrongDaughters_DSAnti", "Invariant mass of K*0 with wrong daughters DS anti", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassRightDaughters_DS", "Invariant mass of K*0 with right daughters DS", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassRightDaughters_DSAnti", "Invariant mass of K*0 with right daughters DS anti", kTH3F, {centAxis, ptAxis, invMassAxis}); + + histos.add("h3k892invmassSameMother_DS", "Invariant mass same mother DS", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassSameMother_DSAnti", "Invariant mass same mother DS anti", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3PdgCodeSameMother_DS", "PDG code same mother DS", kTH3F, {centAxis, ptAxis, pdgCodeAxis}); + histos.add("h3PdgCodeSameMother_DSAnti", "PDG code same mother DS anti", kTH3F, {centAxis, ptAxis, pdgCodeAxis}); } + + if (doprocessEvtLossSigLossMC) { + histos.add("QAevent/hImpactParameterGen", "Impact parameter of generated MC events", kTH1F, {impactParAxis}); + histos.add("QAevent/hImpactParameterRec", "Impact parameter of selected MC events", kTH1F, {impactParAxis}); + histos.add("QAevent/hImpactParvsCentrRec", "Impact parameter of selected MC events vs centrality", kTH2F, {{120, 0.0f, 120.0f}, impactParAxis}); + histos.add("QAevent/k892genBeforeEvtSel", "K* before event selections", kTH2F, {ptAxis, impactParAxis}); + histos.add("QAevent/k892genBeforeEvtSelAnti", "K* before event selections", kTH2F, {ptAxis, impactParAxis}); + histos.add("QAevent/k892genAfterEvtSel", "K* after event selections", kTH2F, {ptAxis, impactParAxis}); + histos.add("QAevent/k892genAfterEvtSelAnti", "K* after event selections", kTH2F, {ptAxis, impactParAxis}); + } + // Print output histograms statistics LOG(info) << "Size of the histograms in spectraTOF"; histos.print(); @@ -251,14 +330,56 @@ struct k892analysis_PbPb { double massKa = o2::constants::physics::MassKPlus; double massPi = o2::constants::physics::MassPiPlus; + template + bool myEventSelections(const CollType& coll) + { + if (!coll.sel8()) + return false; + if (std::abs(coll.posZ()) > cfgCutVertex) + return false; + if (timFrameEvsel && (!coll.selection_bit(aod::evsel::kNoTimeFrameBorder) || !coll.selection_bit(aod::evsel::kNoITSROFrameBorder))) + return false; + if (additionalEvSel2 && (!coll.selection_bit(aod::evsel::kNoSameBunchPileup) || !coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) + return false; + if (additionalEvSel3 && (!coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) + return false; + auto centrality = coll.centFT0C(); + if (centrality > cfgCutCentrality) + return false; + auto occupancy = coll.trackOccupancyInTimeRange(); + if (cfgApplyOccupancyCut && (occupancy > cfgCutMaxOccupancy)) + return false; + + return true; + } + + template + bool myEventSelectionsRun2(const CollType& coll, const bcType&) + { + auto bc = coll.template bc_as(); + if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) + return false; + if (std::abs(coll.posZ()) > cfgCutVertex) + return false; + auto centrality = coll.centRun2V0M(); + if (centrality > cfgCutCentrality) + return false; + + return true; + } + template - bool trackCut(const TrackType track) + bool trackCut(const TrackType& track) { // basic track cuts if (track.itsNCls() < cfgITScluster) return false; if (track.tpcNClsFound() < cfgTPCcluster) return false; + if (track.itsChi2NCl() > cfgITSChi2Ncl) + return false; + if (track.tpcChi2NCl() > cfgTPCChi2Ncl) + return false; if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) return false; if (cfgPVContributor && !track.isPVContributor()) @@ -269,6 +390,8 @@ struct k892analysis_PbPb { return false; if (cfgGlobalTrack && !track.isGlobalTrack()) return false; + if (cfgUseITSTPCrefit && (!(o2::aod::track::ITSrefit) || !(o2::aod::track::TPCrefit))) + return false; return true; } @@ -276,8 +399,13 @@ struct k892analysis_PbPb { template bool selectionPIDKaon(const T& candidate) { + if (cTOFonlyHighpt) { + + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) <= cMaxTOFnSigmaKaon) { // tof cut only + return true; + } - if (TofandTpcPID) { + } else if (cTOFandTPCHighpt) { if (candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) <= cMaxTOFnSigmaKaon && candidate.hasTPC() && std::abs(candidate.tpcNSigmaKa()) <= cMaxTPCnSigmaKaon) { // tof and tpc cut return true; @@ -287,6 +415,9 @@ struct k892analysis_PbPb { if (candidate.hasTPC() && std::abs(candidate.tpcNSigmaKa()) <= cMaxTPCnSigmaKaon) { // tpc cut, tof when available + if (cTofBetaCut && candidate.hasTOF() && (candidate.beta() + 3 * candidate.betaerror() > 1)) + return false; + if (cByPassTOF) // skip tof selection return true; @@ -306,8 +437,13 @@ struct k892analysis_PbPb { template bool selectionPIDPion(const T& candidate) { + if (cTOFonlyHighpt) { - if (TofandTpcPID) { + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) <= cMaxTOFnSigmaPion) { // tof cut only + return true; + } + + } else if (cTOFandTPCHighpt) { if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) <= cMaxTOFnSigmaPion && candidate.hasTPC() && std::abs(candidate.tpcNSigmaPi()) <= cMaxTPCnSigmaPion) { // tof and tpc cut return true; @@ -317,6 +453,9 @@ struct k892analysis_PbPb { if (candidate.hasTPC() && std::abs(candidate.tpcNSigmaPi()) <= cMaxTPCnSigmaPion) { // tpc cut, tof when available + if (cTofBetaCut && candidate.hasTOF() && (candidate.beta() + 3 * candidate.betaerror() > 1)) + return false; + if (cByPassTOF) // skip tof selection return true; @@ -333,7 +472,7 @@ struct k892analysis_PbPb { return false; } - template + template void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2) { @@ -345,15 +484,14 @@ struct k892analysis_PbPb { multiplicity = collision.centRun2V0M(); auto oldindex = -999; - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; - for (auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { - + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance, ldaughterRot, lResonanceRot; + for (const auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { // Full index policy is needed to consider all possible combinations if (trk1.index() == trk2.index()) continue; // We need to run (0,1), (1,0) pairs as well. but same id pairs are not needed. if (additionalQAeventPlots) { - if constexpr (!IsMC) { + if constexpr (!IsMC && !IsRot) { if constexpr (!IsMix) { histos.fill(HIST("TestME/hPairsCounterSameE"), 1.0); } else { @@ -381,24 +519,27 @@ struct k892analysis_PbPb { continue; if constexpr (IsMC) { - if (tpclowpt) { + if (cTPClowpt) { if (trk1ptPi >= cMaxPtTPC || trk2ptKa >= cMaxPtTPC) continue; - } else if (tofhighpt) { + } else if (cTOFonlyHighpt || cTOFandTPCHighpt) { if (trk1ptPi <= cMinPtTOF || trk2ptKa <= cMinPtTOF) continue; } } - if (additionalQAplots) { + if (additionalQAplots && !IsMix && !IsRot) { // TPCncluster distributions - histos.fill(HIST("TPCncluster/TPCnclusterpi"), trk1.tpcNClsFound()); - histos.fill(HIST("TPCncluster/TPCnclusterka"), trk2.tpcNClsFound()); - histos.fill(HIST("TPCncluster/TPCnclusterPhipi"), trk1.tpcNClsFound(), trk1.phi()); - histos.fill(HIST("TPCncluster/TPCnclusterPhika"), trk2.tpcNClsFound(), trk2.phi()); + histos.fill(HIST("Ncluster/TPCnclusterpi"), trk1.tpcNClsFound()); + histos.fill(HIST("Ncluster/TPCnclusterka"), trk2.tpcNClsFound()); + histos.fill(HIST("Ncluster/TPCnclusterPhipi"), trk1.tpcNClsFound(), trk1.phi()); + histos.fill(HIST("Ncluster/TPCnclusterPhika"), trk2.tpcNClsFound(), trk2.phi()); + histos.fill(HIST("Ncluster/TPCChi2ncluster"), trk1.tpcChi2NCl()); + histos.fill(HIST("Ncluster/ITSChi2ncluster"), trk1.itsChi2NCl()); + histos.fill(HIST("Ncluster/ITSncluster"), trk1.itsNCls()); } - if constexpr (!IsMix) { + if constexpr (!IsMix && !IsRot) { //// QA plots after the selection // --- PID QA Pion histos.fill(HIST("QA/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); @@ -418,7 +559,7 @@ struct k892analysis_PbPb { histos.fill(HIST("QA/trkDCAxy_ka"), trk2.dcaXY()); histos.fill(HIST("QA/trkDCAz_pi"), trk1.dcaZ()); histos.fill(HIST("QA/trkDCAz_ka"), trk2.dcaZ()); - } else if (additionalMEPlots) { + } else if (IsMix && additionalMEPlots) { // --- PID QA Pion histos.fill(HIST("QAME/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); if (isTrk1hasTOF) { @@ -433,109 +574,208 @@ struct k892analysis_PbPb { } } + int track1Sign = trk1.sign(); + int track2Sign = trk2.sign(); + //// Resonance reconstruction lDecayDaughter1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi); lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); lResonance = lDecayDaughter1 + lDecayDaughter2; // Rapidity cut - if (abs(lResonance.Rapidity()) >= 0.5) + if (std::abs(lResonance.Rapidity()) >= 0.5) continue; - if (cfgCutsOnMother) { + if (cfgCutsOnMother && !IsRot) { if (lResonance.Pt() >= cMaxPtMotherCut) // excluding candidates in overflow continue; if (lResonance.M() >= cMaxMinvMotherCut) // excluding candidates in overflow continue; } - int track1Sign = trk1.sign(); - int track2Sign = trk2.sign(); //// Un-like sign pair only - if (track1Sign * track2Sign < 0) { - if constexpr (!IsMix) { + if constexpr (IsRot) { // rotational background + for (int i = 0; i < cfgNoRotations; i++) { + float theta = rand->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); + if (cfgRotPi) { + ldaughterRot.SetPtEtaPhiM(trk1.pt(), trk1.eta(), trk1.phi() + theta, massPi); + lResonanceRot = lDecayDaughter2 + ldaughterRot; + } else { + ldaughterRot.SetPtEtaPhiM(trk2.pt(), trk2.eta(), trk2.phi() + theta, massKa); + lResonanceRot = lDecayDaughter1 + ldaughterRot; + } + if (std::abs(lResonanceRot.Rapidity()) >= 0.5) + continue; + if (cfgCutsOnMother) { + if (lResonanceRot.Pt() >= cMaxPtMotherCut) // excluding candidates in overflow + continue; + if (lResonanceRot.M() >= cMaxMinvMotherCut) // excluding candidates in overflow + continue; + } + + if (track1Sign < 0) { + histos.fill(HIST("k892invmassRotDS"), lResonanceRot.M()); + histos.fill(HIST("h3k892invmassRotDS"), multiplicity, lResonanceRot.Pt(), lResonanceRot.M()); + } else if (track1Sign > 0) { + histos.fill(HIST("k892invmassRotDSAnti"), lResonance.M()); + histos.fill(HIST("h3k892invmassRotDSAnti"), multiplicity, lResonanceRot.Pt(), lResonanceRot.M()); + } + } + + } else if constexpr (!IsMix) { // same event if (track1Sign < 0) { histos.fill(HIST("k892invmassDS"), lResonance.M()); histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M()); + if (additionalQAplots) { + histos.fill(HIST("QA/h2k892ptMothervsptPiDS"), lResonance.Pt(), lDecayDaughter1.Pt()); + histos.fill(HIST("QA/h2k892ptMothervsptKaDS"), lResonance.Pt(), lDecayDaughter2.Pt()); + } } else if (track1Sign > 0) { histos.fill(HIST("k892invmassDSAnti"), lResonance.M()); histos.fill(HIST("h3k892invmassDSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + if (additionalQAplots) { + histos.fill(HIST("QA/h2k892ptMothervsptPiDSAnti"), lResonance.Pt(), lDecayDaughter1.Pt()); + histos.fill(HIST("QA/h2k892ptMothervsptKaDSAnti"), lResonance.Pt(), lDecayDaughter2.Pt()); + } } - } else { + + } else { // mixed event histos.fill(HIST("k892invmassME"), lResonance.M()); histos.fill(HIST("h3k892invmassME"), multiplicity, lResonance.Pt(), lResonance.M()); if (additionalMEPlots) { if (track1Sign < 0) { histos.fill(HIST("k892invmassME_DS"), lResonance.M()); histos.fill(HIST("h3k892invmassME_DS"), multiplicity, lResonance.Pt(), lResonance.M()); + if (additionalQAplots) { + histos.fill(HIST("QAME/h2k892ptMothervsptPiDS"), lResonance.Pt(), lDecayDaughter1.Pt()); + histos.fill(HIST("QAME/h2k892ptMothervsptKaDS"), lResonance.Pt(), lDecayDaughter2.Pt()); + } } else if (track1Sign > 0) { histos.fill(HIST("k892invmassME_DSAnti"), lResonance.M()); histos.fill(HIST("h3k892invmassME_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + if (additionalQAplots) { + histos.fill(HIST("QAME/h2k892ptMothervsptPiDSAnti"), lResonance.Pt(), lDecayDaughter1.Pt()); + histos.fill(HIST("QAME/h2k892ptMothervsptKaDSAnti"), lResonance.Pt(), lDecayDaughter2.Pt()); + } } } } // MC - if constexpr (IsMC) { + if constexpr (IsMC && !IsRot) { if (!trk1.has_mcParticle() || !trk2.has_mcParticle()) continue; const auto mctrack1 = trk1.mcParticle(); const auto mctrack2 = trk2.mcParticle(); - int track1PDG = TMath::Abs(mctrack1.pdgCode()); - int track2PDG = TMath::Abs(mctrack2.pdgCode()); + int track1PDG = std::abs(mctrack1.pdgCode()); + int track2PDG = std::abs(mctrack2.pdgCode()); - if (!mctrack1.isPhysicalPrimary() || !mctrack2.isPhysicalPrimary()) + if (cfgIsPhysicalPrimary && (!mctrack1.isPhysicalPrimary() || !mctrack2.isPhysicalPrimary())) continue; - if (track1PDG != 211 || track2PDG != 321) - continue; + if (track1PDG != 211 || track2PDG != 321) { - bool ismotherok = false; - int pdgcodeMother = -999; - for (auto& mothertrack1 : mctrack1.template mothers_as()) { - for (auto& mothertrack2 : mctrack2.template mothers_as()) { - if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) - continue; - if (mothertrack1.globalIndex() != mothertrack2.globalIndex()) - continue; - if (TMath::Abs(mothertrack1.pdgCode()) != 313) - continue; - if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { - histos.fill(HIST("h1k892Recsplit"), mothertrack1.pt()); - continue; - } - oldindex = mothertrack1.globalIndex(); - pdgcodeMother = mothertrack1.pdgCode(); - ismotherok = true; + if (track1Sign < 0) { + if constexpr (IsMix) + histos.fill(HIST("h3k892invmassWrongDaughtersME_DS"), multiplicity, lResonance.Pt(), lResonance.M()); + else + histos.fill(HIST("h3k892invmassWrongDaughters_DS"), multiplicity, lResonance.Pt(), lResonance.M()); + } else if (track1Sign > 0) { + if constexpr (IsMix) + histos.fill(HIST("h3k892invmassWrongDaughtersME_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + else + histos.fill(HIST("h3k892invmassWrongDaughters_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); } - } - if (!ismotherok) continue; - - histos.fill(HIST("QAMCTrue/hGlobalIndexMotherRec"), oldindex); - // Track selection check. - histos.fill(HIST("QAMCTrue/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); - if (isTrk1hasTOF) { - histos.fill(HIST("QAMCTrue/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); } - histos.fill(HIST("QAMCTrue/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); - if (isTrk2hasTOF) { - histos.fill(HIST("QAMCTrue/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + + if (track1Sign < 0) { + if constexpr (IsMix) + histos.fill(HIST("h3k892invmassRightDaughtersME_DS"), multiplicity, lResonance.Pt(), lResonance.M()); + else + histos.fill(HIST("h3k892invmassRightDaughters_DS"), multiplicity, lResonance.Pt(), lResonance.M()); + } else if (track1Sign > 0) { + if constexpr (IsMix) + histos.fill(HIST("h3k892invmassRightDaughtersME_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + else + histos.fill(HIST("h3k892invmassRightDaughters_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); } - // MC histograms - if (pdgcodeMother > 0) { - histos.fill(HIST("k892Rec"), lResonance.Pt(), multiplicity); - histos.fill(HIST("k892Recinvmass"), lResonance.M()); - histos.fill(HIST("h3Reck892invmass"), multiplicity, lResonance.Pt(), lResonance.M()); - } else { - histos.fill(HIST("k892RecAnti"), lResonance.Pt(), multiplicity); - histos.fill(HIST("k892RecinvmassAnti"), lResonance.M()); - histos.fill(HIST("h3Reck892invmassAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + if constexpr (!IsMix) { + + bool isSameMother = false; + bool isMotherOk = false; + int pdgCodeMother = -999; + float ptMother = -9999.; + for (const auto& mothertrack1 : mctrack1.template mothers_as()) { + for (const auto& mothertrack2 : mctrack2.template mothers_as()) { + if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) + continue; + if (mothertrack1.globalIndex() != mothertrack2.globalIndex()) + continue; + + if (std::abs(mothertrack1.pdgCode()) == 1000822080) // Pb PDG code + continue; + + pdgCodeMother = mothertrack1.pdgCode(); + ptMother = mothertrack1.pt(); + isSameMother = true; + + if (std::abs(mothertrack1.pdgCode()) != 313) + continue; + + if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { + histos.fill(HIST("h1k892Recsplit"), mothertrack1.pt()); + continue; + } + oldindex = mothertrack1.globalIndex(); + isMotherOk = true; + } + } + + if (isSameMother) { + if (track1Sign < 0) { + histos.fill(HIST("h3k892invmassSameMother_DS"), multiplicity, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("h3PdgCodeSameMother_DS"), multiplicity, lResonance.Pt(), pdgCodeMother); + } else if (track1Sign > 0) { + histos.fill(HIST("h3k892invmassSameMother_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("h3PdgCodeSameMother_DSAnti"), multiplicity, lResonance.Pt(), pdgCodeMother); + } + } + + if (!isMotherOk) + continue; + + histos.fill(HIST("QAMCTrue/hGlobalIndexMotherRec"), oldindex); + // Track selection check. + histos.fill(HIST("QAMCTrue/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QAMCTrue/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); + } + histos.fill(HIST("QAMCTrue/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QAMCTrue/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + } + + // MC histograms + if (pdgCodeMother > 0) { + histos.fill(HIST("k892Rec"), lResonance.Pt(), multiplicity); + histos.fill(HIST("k892Recinvmass"), lResonance.M()); + histos.fill(HIST("h3Reck892invmass"), multiplicity, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("h3Reck892invmassPtGen"), multiplicity, ptMother, lResonance.M()); + histos.fill(HIST("h3PtRecvsPtGen"), multiplicity, lResonance.Pt(), ptMother); + } else { + histos.fill(HIST("k892RecAnti"), lResonance.Pt(), multiplicity); + histos.fill(HIST("k892RecinvmassAnti"), lResonance.M()); + histos.fill(HIST("h3Reck892invmassAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("h3Reck892invmassAntiPtGen"), multiplicity, ptMother, lResonance.M()); + histos.fill(HIST("h3PtRecvsPtGenAnti"), multiplicity, lResonance.Pt(), ptMother); + } } - } + } // end of IsMC + } else if (track1Sign * track2Sign > 0) { if constexpr (!IsMix) { if (track1Sign < 0) { @@ -546,18 +786,32 @@ struct k892analysis_PbPb { histos.fill(HIST("h3k892invmassLSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); } } - } // end on DS or LS if tenses - } // end of loop on tracks combinations - } // ennd on fill histograms + } // end on DS or LS if + } // end of loop on track combinations + } // end of fill histograms Filter collisionFilter = nabs(aod::collision::posZ) <= cfgCutVertex; Filter centralityFilter = nabs(aod::cent::centFT0C) <= cfgCutCentrality; Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) >= cfgCutPT); - Filter DCAcutFilter = (nabs(aod::track::dcaXY) <= cfgCutDCAxy) && (nabs(aod::track::dcaZ) <= cfgCutDCAz); + Filter dcaCutFilter = (nabs(aod::track::dcaXY) <= cfgCutDCAxy) && (nabs(aod::track::dcaZ) <= cfgCutDCAz); + // Data using EventCandidates = soa::Filtered>; using TrackCandidates = soa::Filtered>; + aod::pidTPCFullKa, aod::pidTOFFullKa, aod::pidTPCFullPi, aod::pidTOFFullPi, aod::pidTOFbeta>>; + // MC + using EventCandidatesMCrec = soa::Join; + using TrackCandidatesMCrec = soa::Filtered>; + // ME run 3 + using BinningTypeVtxCent = ColumnBinningPolicy; + + // Data Run 2 + using Run2Events = soa::Join; //, aod::TrackletMults>; + using BCsWithRun2Info = soa::Join; + // MC Run2 + using EventCandidatesMCrecRun2 = soa::Join; // aod::TrackletMults>; + // ME run 2 + using BinningTypeVtxCentRun2 = ColumnBinningPolicy; // partitions tpc low pt Partition negPitpc = (aod::track::signed1Pt < static_cast(0)) && (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion) && (nabs(aod::track::pt) < cMaxPtTPC); @@ -567,153 +821,138 @@ struct k892analysis_PbPb { Partition negKatpc = (aod::track::signed1Pt < static_cast(0)) && (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon) && (nabs(aod::track::pt) < cMaxPtTPC); // tpc & tof, high pt - Partition negPitof = (aod::track::signed1Pt < static_cast(0)) && (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion) && (nabs(aod::track::pt) > cMinPtTOF); - Partition posKatof = (aod::track::signed1Pt > static_cast(0)) && (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon) && (nabs(aod::track::pt) > cMinPtTOF); + Partition negPitoftpc = (aod::track::signed1Pt < static_cast(0)) && (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion) && (nabs(aod::track::pt) > cMinPtTOF); + Partition posKatoftpc = (aod::track::signed1Pt > static_cast(0)) && (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon) && (nabs(aod::track::pt) > cMinPtTOF); - Partition posPitof = (aod::track::signed1Pt > static_cast(0)) && (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion) && (nabs(aod::track::pt) > cMinPtTOF); - Partition negKatof = (aod::track::signed1Pt < static_cast(0)) && (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon) && (nabs(aod::track::pt) > cMinPtTOF); + Partition posPitoftpc = (aod::track::signed1Pt > static_cast(0)) && (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion) && (nabs(aod::track::pt) > cMinPtTOF); + Partition negKatoftpc = (aod::track::signed1Pt < static_cast(0)) && (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon) && (nabs(aod::track::pt) > cMinPtTOF); - void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + // tof only, high pt + Partition negPitof = (aod::track::signed1Pt < static_cast(0)) && (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (nabs(aod::track::pt) > cMinPtTOF); + Partition posKatof = (aod::track::signed1Pt > static_cast(0)) && (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (nabs(aod::track::pt) > cMinPtTOF); + + Partition posPitof = (aod::track::signed1Pt > static_cast(0)) && (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (nabs(aod::track::pt) > cMinPtTOF); + Partition negKatof = (aod::track::signed1Pt < static_cast(0)) && (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (nabs(aod::track::pt) > cMinPtTOF); + + template + void callFillHistoswithPartitions(const CollisionType& collision1, const TracksType&, const CollisionType& collision2, const TracksType&) { - if (!collision.sel8()) { - return; - } - auto centrality = collision.centFT0C(); - if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - return; - } - if (additionalEvSel2 && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { - return; - } - if (additionalEvSel3 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { - return; - } - // int occupancy = collision.trackOccupancyInTimeRange(); + if (cTPClowpt) { + //+- + auto candPosPitpc = posPitpc->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto candNegKatpc = negKatpc->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); - histos.fill(HIST("QAevent/hEvtCounterSameE"), 1); - histos.fill(HIST("QAevent/hVertexZSameE"), collision.posZ()); - histos.fill(HIST("QAevent/hMultiplicityPercentSameE"), centrality); + fillHistograms(collision1, candPosPitpc, candNegKatpc); - if (additionalQAeventPlots) { - histos.fill(HIST("TestME/hCollisionIndexSameE"), collision.globalIndex()); - histos.fill(HIST("TestME/hnTrksSameE"), tracks.size()); - } + //-+ + auto candNegPitpc = negPitpc->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto candPosKatpc = posKatpc->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + + fillHistograms(collision1, candNegPitpc, candPosKatpc); - if (tpclowpt) { + } else if (cTOFandTPCHighpt) { //+- - auto candPosPitpc = posPitpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto candNegKatpc = negKatpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto candPosPitoftpc = posPitoftpc->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto candNegKatoftpc = negKatoftpc->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); - fillHistograms(collision, candPosPitpc, candNegKatpc); + fillHistograms(collision1, candPosPitoftpc, candNegKatoftpc); //-+ - auto candNegPitpc = negPitpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto candPosKatpc = posKatpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto candNegPitoftpc = negPitoftpc->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto candPosKatoftpc = posKatoftpc->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); - fillHistograms(collision, candNegPitpc, candPosKatpc); + fillHistograms(collision1, candNegPitoftpc, candPosKatoftpc); - } else if (tofhighpt) { + } else if (cTOFonlyHighpt) { //+- - auto candPosPitof = posPitof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto candNegKatof = negKatof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto candPosPitof = posPitof->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto candNegKatof = negKatof->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); - fillHistograms(collision, candPosPitof, candNegKatof); + fillHistograms(collision1, candPosPitof, candNegKatof); //-+ - auto candNegPitof = negPitof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto candPosKatof = posKatof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto candNegPitof = negPitof->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto candPosKatof = posKatof->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); - fillHistograms(collision, candNegPitof, candPosKatof); + fillHistograms(collision1, candNegPitof, candPosKatof); } } - PROCESS_SWITCH(k892analysis_PbPb, processSameEvent, "Process Same event", false); - - ///////*************************************** - - using Run2Events = soa::Join; //, aod::TrackletMults>; - using BCsWithRun2Info = soa::Join; - void processSameEventRun2(Run2Events::iterator const& collision, TrackCandidates const& tracks, BCsWithRun2Info const&) + void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) { - auto bc = collision.bc_as(); - // if (!collision.alias_bit(kINT7)) - // return; + if (!myEventSelections(collision)) + return; - // if (!collision.sel7()) - // return; + auto centrality = collision.centFT0C(); - if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) - return; + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1); + histos.fill(HIST("QAevent/hVertexZSameE"), collision.posZ()); + histos.fill(HIST("QAevent/hMultiplicityPercentSameE"), centrality); - if (std::abs(collision.posZ()) > cfgCutVertex) - return; + if (additionalQAeventPlots) { + histos.fill(HIST("TestME/hCollisionIndexSameE"), collision.globalIndex()); + histos.fill(HIST("TestME/hnTrksSameE"), tracks.size()); + } + // + callFillHistoswithPartitions(collision, tracks, collision, tracks); + } + PROCESS_SWITCH(K892analysispbpb, processSameEvent, "Process Same event", true); - auto centrality = collision.centRun2V0M(); + void processSameEventRun2(Run2Events::iterator const& collision, TrackCandidates const& tracks, BCsWithRun2Info const& bcs) + { - if (centrality > cfgCutCentrality) + if (!myEventSelectionsRun2(collision, bcs)) return; histos.fill(HIST("QAevent/hEvtCounterSameE"), 1); histos.fill(HIST("QAevent/hVertexZSameE"), collision.posZ()); - histos.fill(HIST("QAevent/hMultiplicityPercentSameE"), centrality); + histos.fill(HIST("QAevent/hMultiplicityPercentSameE"), collision.centRun2V0M()); if (additionalQAeventPlots) { histos.fill(HIST("TestME/hCollisionIndexSameE"), collision.globalIndex()); histos.fill(HIST("TestME/hnTrksSameE"), tracks.size()); } - if (tpclowpt) { - //+- - auto candPosPitpc = posPitpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto candNegKatpc = negKatpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - - fillHistograms(collision, candPosPitpc, candNegKatpc); + // + callFillHistoswithPartitions(collision, tracks, collision, tracks); + } + PROCESS_SWITCH(K892analysispbpb, processSameEventRun2, "Process Same event Run2", false); - //-+ - auto candNegPitpc = negPitpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto candPosKatpc = posKatpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + void processRotationalBkg(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + { - fillHistograms(collision, candNegPitpc, candPosKatpc); + if (!myEventSelections(collision)) + return; - } else if (tofhighpt) { - //+- - auto candPosPitof = posPitof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto candNegKatof = negKatof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + // + callFillHistoswithPartitions(collision, tracks, collision, tracks); + } + PROCESS_SWITCH(K892analysispbpb, processRotationalBkg, "Process Rotational Background", false); - fillHistograms(collision, candPosPitof, candNegKatof); + void processRotationalBkgMC(EventCandidatesMCrec::iterator const& recCollision, TrackCandidatesMCrec const& RecTracks) + { - //-+ - auto candNegPitof = negPitof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto candPosKatof = posKatof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + if (!myEventSelections(recCollision)) + return; - fillHistograms(collision, candNegPitof, candPosKatof); - } + // + fillHistograms(recCollision, RecTracks, RecTracks); } - PROCESS_SWITCH(k892analysis_PbPb, processSameEventRun2, "Process Same event Run2", false); + PROCESS_SWITCH(K892analysispbpb, processRotationalBkgMC, "Process Rotational Background MC", false); - using BinningTypeVtxCent = ColumnBinningPolicy; void processMixedEvent(EventCandidates const& collisions, TrackCandidates const& tracks) { auto tracksTuple = std::make_tuple(tracks); - BinningTypeVtxCent colBinning{{CfgVtxBins, CfgMultBins}, true}; + BinningTypeVtxCent colBinning{{cfgVtxBins, cfgMultBins}, true}; SameKindPair pairs{colBinning, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; - for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { - if (!collision1.sel8() || !collision2.sel8()) { - continue; - } - auto centrality = collision1.centFT0C(); + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { - if (timFrameEvsel && (!collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + if (!myEventSelections(collision1) || !myEventSelections(collision2)) continue; - } - if (additionalEvSel2 && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { - continue; - } - if (additionalEvSel3 && (!collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) || !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { - continue; - } + + auto centrality = collision1.centFT0C(); if (additionalQAeventPlots) { histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); @@ -723,149 +962,169 @@ struct k892analysis_PbPb { histos.fill(HIST("TestME/hnTrksMixedE"), tracks1.size()); } - if (tpclowpt) { + // + callFillHistoswithPartitions(collision1, tracks1, collision2, tracks2); + } + } + PROCESS_SWITCH(K892analysispbpb, processMixedEvent, "Process Mixed event", true); - //+- - auto candPosPitpc = posPitpc->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto candNegKatpc = negKatpc->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + void processMixedEventRun2(Run2Events const& collisions, TrackCandidates const& tracks, BCsWithRun2Info const& bcs) + { + auto tracksTuple = std::make_tuple(tracks); + BinningTypeVtxCentRun2 colBinning{{cfgVtxBins, cfgMultBins}, true}; + SameKindPair pairs{colBinning, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; - fillHistograms(collision1, candPosPitpc, candNegKatpc); + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { - //-+ - auto candNegPitpc = negPitpc->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto candPosKatpc = posKatpc->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + if (!myEventSelectionsRun2(collision1, bcs) || !myEventSelectionsRun2(collision2, bcs)) + continue; - fillHistograms(collision1, candNegPitpc, candPosKatpc); + if (additionalQAeventPlots) { + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); + histos.fill(HIST("QAevent/hVertexZMixedE"), collision1.posZ()); + histos.fill(HIST("QAevent/hMultiplicityPercentMixedE"), collision1.centRun2V0M()); + histos.fill(HIST("TestME/hCollisionIndexMixedE"), collision1.globalIndex()); + histos.fill(HIST("TestME/hnTrksMixedE"), tracks1.size()); + } - } else if (tofhighpt) { + // + callFillHistoswithPartitions(collision1, tracks1, collision2, tracks2); + } + } + PROCESS_SWITCH(K892analysispbpb, processMixedEventRun2, "Process Mixed event Run2", false); - //+- - auto candPosPitof = posPitof->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto candNegKatof = negKatof->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + void processMixedEventMC(EventCandidatesMCrec const& recCollisions, TrackCandidatesMCrec const& RecTracks, aod::McParticles const&) + { + auto tracksTuple = std::make_tuple(RecTracks); + BinningTypeVtxCent colBinning{{cfgVtxBins, cfgMultBins}, true}; + SameKindPair pairs{colBinning, cfgNoMixedEvents, -1, recCollisions, tracksTuple, &cache}; - fillHistograms(collision1, candPosPitof, candNegKatof); + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { - //-+ - auto candNegPitof = negPitof->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto candPosKatof = posKatof->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + if (!myEventSelections(collision1) || !myEventSelections(collision2)) + continue; - fillHistograms(collision1, candNegPitof, candPosKatof); + if (additionalQAeventPlots) { + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); + histos.fill(HIST("QAevent/hVertexZMixedE"), collision1.posZ()); + histos.fill(HIST("QAevent/hMultiplicityPercentMixedE"), collision1.centFT0C()); + histos.fill(HIST("TestME/hCollisionIndexMixedE"), collision1.globalIndex()); + histos.fill(HIST("TestME/hnTrksMixedE"), tracks1.size()); } + + // + fillHistograms(collision1, tracks1, tracks2); } } - PROCESS_SWITCH(k892analysis_PbPb, processMixedEvent, "Process Mixed event", true); + PROCESS_SWITCH(K892analysispbpb, processMixedEventMC, "Process Mixed event MC", false); - using BinningTypeVtxCentRun2 = ColumnBinningPolicy; - void processMixedEventRun2(Run2Events const& collisions, TrackCandidates const& tracks, BCsWithRun2Info const&) + void processMixedEventMCRun2(EventCandidatesMCrecRun2 const& recCollisions, TrackCandidatesMCrec const& RecTracks, BCsWithRun2Info const& bcs, aod::McParticles const&) { - auto tracksTuple = std::make_tuple(tracks); - BinningTypeVtxCentRun2 colBinning{{CfgVtxBins, CfgMultBins}, true}; - SameKindPair pairs{colBinning, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; - - for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { - - auto bc1 = collision1.bc_as(); - auto bc2 = collision2.bc_as(); - - if (!(bc1.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted)) || !(bc2.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) - continue; - - if ((std::abs(collision1.posZ()) > cfgCutVertex) || (std::abs(collision2.posZ()) > cfgCutVertex)) - continue; + auto tracksTuple = std::make_tuple(RecTracks); + BinningTypeVtxCentRun2 colBinning{{cfgVtxBins, cfgMultBins}, true}; + SameKindPair pairs{colBinning, cfgNoMixedEvents, -1, recCollisions, tracksTuple, &cache}; - auto centrality1 = collision1.centRun2V0M(); - auto centrality2 = collision2.centRun2V0M(); + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { - if ((centrality1 > cfgCutCentrality) || (centrality2 > cfgCutCentrality)) + if (!myEventSelectionsRun2(collision1, bcs) || !myEventSelectionsRun2(collision2, bcs)) continue; if (additionalQAeventPlots) { histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); histos.fill(HIST("QAevent/hVertexZMixedE"), collision1.posZ()); - histos.fill(HIST("QAevent/hMultiplicityPercentMixedE"), centrality1); + histos.fill(HIST("QAevent/hMultiplicityPercentMixedE"), collision1.centRun2V0M()); histos.fill(HIST("TestME/hCollisionIndexMixedE"), collision1.globalIndex()); histos.fill(HIST("TestME/hnTrksMixedE"), tracks1.size()); } - if (tpclowpt) { - - //+- - auto candPosPitpc = posPitpc->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto candNegKatpc = negKatpc->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + // + fillHistograms(collision1, tracks1, tracks2); + } + } + PROCESS_SWITCH(K892analysispbpb, processMixedEventMCRun2, "Process Mixed event MC Run2", false); - fillHistograms(collision1, candPosPitpc, candNegKatpc); + void processEvtLossSigLossMC(aod::McCollisions::iterator const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& recCollisions) + { - //-+ - auto candNegPitpc = negPitpc->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto candPosKatpc = posKatpc->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + // Event loss estimation + auto impactPar = mcCollision.impactParameter(); + histos.fill(HIST("QAevent/hImpactParameterGen"), impactPar); - fillHistograms(collision1, candNegPitpc, candPosKatpc); + bool isSel = false; + auto centrality = -999.; + if (recCollisions.size() > 0) { + auto numcontributors = -999; + for (const auto& RecCollision : recCollisions) { + if (!myEventSelections(RecCollision)) + continue; - } else if (tofhighpt) { + if (RecCollision.numContrib() <= numcontributors) + continue; + else + numcontributors = RecCollision.numContrib(); - //+- - auto candPosPitof = posPitof->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto candNegKatof = negKatof->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + centrality = RecCollision.centFT0C(); + isSel = true; + } + } - fillHistograms(collision1, candPosPitof, candNegKatof); + if (isSel) { + histos.fill(HIST("QAevent/hImpactParameterRec"), impactPar); + histos.fill(HIST("QAevent/hImpactParvsCentrRec"), centrality, impactPar); + } - //-+ - auto candNegPitof = negPitof->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto candPosKatof = posKatof->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + // Generated MC + for (const auto& mcPart : mcParticles) { + if (std::abs(mcPart.y()) >= 0.5 || std::abs(mcPart.pdgCode()) != 313) + continue; - fillHistograms(collision1, candNegPitof, candPosKatof); + // signal loss estimation + if (mcPart.pdgCode() > 0) // no cuts, purely generated + histos.fill(HIST("QAevent/k892genBeforeEvtSel"), mcPart.pt(), impactPar); + else + histos.fill(HIST("QAevent/k892genBeforeEvtSelAnti"), mcPart.pt(), impactPar); + + if (isSel) { + // signal loss estimation + if (mcPart.pdgCode() > 0) // no cuts, purely generated + histos.fill(HIST("QAevent/k892genAfterEvtSel"), mcPart.pt(), impactPar); + else + histos.fill(HIST("QAevent/k892genAfterEvtSelAnti"), mcPart.pt(), impactPar); } - } + } // end loop on gen particles } - PROCESS_SWITCH(k892analysis_PbPb, processMixedEventRun2, "Process Mixed event Run2", true); - - // MC - - using EventCandidatesMCrec = soa::Join; - using TrackCandidatesMCrec = soa::Filtered>; + PROCESS_SWITCH(K892analysispbpb, processEvtLossSigLossMC, "Process Signal Loss, Event Loss", false); - void processMC(aod::McCollisions::iterator const& /*mcCollision*/, aod::McParticles& mcParticles, const soa::SmallGroups& recCollisions, TrackCandidatesMCrec const& RecTracks) + void processMC(aod::McCollisions::iterator const& /*mcCollision*/, aod::McParticles const& mcParticles, const soa::SmallGroups& recCollisions, TrackCandidatesMCrec const& RecTracks) { - histos.fill(HIST("hMCrecCollSels"), 0); + + histos.fill(HIST("QAevent/hMCrecCollSels"), 0); if (recCollisions.size() == 0) { - histos.fill(HIST("hMCrecCollSels"), 1); + histos.fill(HIST("QAevent/hMCrecCollSels"), 1); return; } if (recCollisions.size() > 1) { - histos.fill(HIST("hMCrecCollSels"), 2); + histos.fill(HIST("QAevent/hMCrecCollSels"), 2); return; } - for (auto& RecCollision : recCollisions) { - histos.fill(HIST("hMCrecCollSels"), 3); - if (!RecCollision.sel8()) { - continue; - } - histos.fill(HIST("hMCrecCollSels"), 4); - if (TMath::Abs(RecCollision.posZ()) > cfgCutVertex) { - continue; - } - histos.fill(HIST("hMCrecCollSels"), 5); - if (timFrameEvsel && (!RecCollision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - continue; - } - histos.fill(HIST("hMCrecCollSels"), 6); - if (additionalEvSel2 && (!RecCollision.selection_bit(aod::evsel::kNoSameBunchPileup) || !RecCollision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { - continue; - } - histos.fill(HIST("hMCrecCollSels"), 7); - if (additionalEvSel3 && (!RecCollision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + for (const auto& RecCollision : recCollisions) { + histos.fill(HIST("QAevent/hMCrecCollSels"), 3); + + if (!myEventSelections(RecCollision)) continue; - } - histos.fill(HIST("hMCrecCollSels"), 8); + histos.fill(HIST("QAevent/hMCrecCollSels"), 8); auto centrality = RecCollision.centFT0C(); histos.fill(HIST("QAevent/hMultiplicityPercentMC"), centrality); + auto tracks = RecTracks.sliceByCached(aod::track::collisionId, RecCollision.globalIndex(), cache); - fillHistograms(RecCollision, tracks, tracks); + + // + fillHistograms(RecCollision, tracks, tracks); // Generated MC - for (auto& mcPart : mcParticles) { - if (abs(mcPart.y()) >= 0.5 || abs(mcPart.pdgCode()) != 313) + for (const auto& mcPart : mcParticles) { + if (std::abs(mcPart.y()) >= 0.5 || std::abs(mcPart.pdgCode()) != 313) continue; auto kDaughters = mcPart.daughters_as(); @@ -877,16 +1136,14 @@ struct k892analysis_PbPb { auto daughtp = false; auto daughtk = false; - for (auto kCurrentDaughter : kDaughters) { + for (const auto& kCurrentDaughter : kDaughters) { if (!kCurrentDaughter.isPhysicalPrimary()) break; - if (genacceptancecut && (kCurrentDaughter.pt() < cfgCutPT || TMath::Abs(kCurrentDaughter.eta()) > cfgCutEta)) - break; - if (abs(kCurrentDaughter.pdgCode()) == 211) { + if (std::abs(kCurrentDaughter.pdgCode()) == 211) { daughtp = true; lDecayDaughter1.SetXYZM(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massPi); - } else if (abs(kCurrentDaughter.pdgCode()) == 321) { + } else if (std::abs(kCurrentDaughter.pdgCode()) == 321) { daughtk = true; lDecayDaughter2.SetXYZM(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); } @@ -913,44 +1170,36 @@ struct k892analysis_PbPb { } // end loop on rec collisions } - PROCESS_SWITCH(k892analysis_PbPb, processMC, "Process Monte Carlo", false); - - // MC Run2 + PROCESS_SWITCH(K892analysispbpb, processMC, "Process Monte Carlo", false); - using EventCandidatesMCrecRun2 = soa::Join; // aod::TrackletMults>; - - void processMCRun2(aod::McCollisions::iterator const& /*mcCollision*/, aod::McParticles& mcParticles, const soa::SmallGroups& recCollisions, TrackCandidatesMCrec const& RecTracks, BCsWithRun2Info const&) + void processMCRun2(aod::McCollisions::iterator const& /*mcCollision*/, aod::McParticles const& mcParticles, const soa::SmallGroups& recCollisions, TrackCandidatesMCrec const& RecTracks, BCsWithRun2Info const& bcs) { - histos.fill(HIST("hMCrecCollSels"), 0); + histos.fill(HIST("QAevent/hMCrecCollSels"), 0); if (recCollisions.size() == 0) { - histos.fill(HIST("hMCrecCollSels"), 1); + histos.fill(HIST("QAevent/hMCrecCollSels"), 1); return; } if (recCollisions.size() > 1) { - histos.fill(HIST("hMCrecCollSels"), 2); + histos.fill(HIST("QAevent/hMCrecCollSels"), 2); return; } - for (auto& RecCollision : recCollisions) { - auto bc = RecCollision.bc_as(); - histos.fill(HIST("hMCrecCollSels"), 3); - - if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) - continue; - histos.fill(HIST("hMCrecCollSels"), 4); + for (const auto& RecCollision : recCollisions) { + histos.fill(HIST("QAevent/hMCrecCollSels"), 3); - if (std::abs(RecCollision.posZ()) > cfgCutVertex) + if (!myEventSelectionsRun2(RecCollision, bcs)) continue; - histos.fill(HIST("hMCrecCollSels"), 5); + histos.fill(HIST("QAevent/hMCrecCollSels"), 8); auto centrality = RecCollision.centRun2V0M(); - histos.fill(HIST("QAevent/hMultiplicityPercentMC"), centrality); auto tracks = RecTracks.sliceByCached(aod::track::collisionId, RecCollision.globalIndex(), cache); - fillHistograms(RecCollision, tracks, tracks); + + // + fillHistograms(RecCollision, tracks, tracks); // Generated MC - for (auto& mcPart : mcParticles) { - if (abs(mcPart.y()) >= 0.5 || abs(mcPart.pdgCode()) != 313) + for (const auto& mcPart : mcParticles) { + if (std::abs(mcPart.y()) >= 0.5 || std::abs(mcPart.pdgCode()) != 313) continue; auto kDaughters = mcPart.daughters_as(); @@ -962,16 +1211,14 @@ struct k892analysis_PbPb { auto daughtp = false; auto daughtk = false; - for (auto kCurrentDaughter : kDaughters) { + for (const auto& kCurrentDaughter : kDaughters) { if (!kCurrentDaughter.isPhysicalPrimary()) break; - if (genacceptancecut && (kCurrentDaughter.pt() < cfgCutPT || TMath::Abs(kCurrentDaughter.eta()) > cfgCutEta)) - break; - if (abs(kCurrentDaughter.pdgCode()) == 211) { + if (std::abs(kCurrentDaughter.pdgCode()) == 211) { daughtp = true; lDecayDaughter1.SetXYZM(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massPi); - } else if (abs(kCurrentDaughter.pdgCode()) == 321) { + } else if (std::abs(kCurrentDaughter.pdgCode()) == 321) { daughtk = true; lDecayDaughter2.SetXYZM(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); } @@ -998,10 +1245,9 @@ struct k892analysis_PbPb { } // end loop on rec collisions } - PROCESS_SWITCH(k892analysis_PbPb, processMCRun2, "Process Monte Carlo Run2", false); + PROCESS_SWITCH(K892analysispbpb, processMCRun2, "Process Monte Carlo Run2", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"k892analysis_PbPb"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Resonances/kaonkaonanalysis.cxx b/PWGLF/Tasks/Resonances/kaonkaonanalysis.cxx index 81af59575ab..7db6d327c15 100644 --- a/PWGLF/Tasks/Resonances/kaonkaonanalysis.cxx +++ b/PWGLF/Tasks/Resonances/kaonkaonanalysis.cxx @@ -12,77 +12,86 @@ // (1) For Run3 // (2) Event and track selection need to be optimized // (3) particle = 0 --> phi -// (4) particle = 1 --> kstar +// (4) particle = 1 --> Phi // (5) particle = 2 --> lambdastar // (6) 4 process function (a) Data same event (b) Data mixed event (c) MC generated (d) MC reconstructed /// \brief kaon kaon analysis for higher mass resonances (code taken from phianalysisrun3) /// \author Sawan (sawan.sawan@cern.ch) -#include +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TRandom3.h" +#include #include +#include +#include +#include #include -#include #include #include -#include -#include -#include #include -#include -#include + #include +#include #include -#include "TF1.h" -#include "TRandom3.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/Core/TrackSelection.h" -#include "Framework/ASoAHelpers.h" +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using std::array; +using namespace o2::aod::rctsel; + struct kaonkaonAnalysisRun3 { + struct : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } rctCut; + RCTFlagsChecker rctChecker; + SliceCache cache; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry hInvMass{"hInvMass", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // For histograms + Configurable calcLikeSign{"calcLikeSign", true, "Calculate Like Sign"}; + Configurable calcRotational{"calcRotational", false, "Calculate Rotational"}; // events Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; - Configurable piluprejection{"piluprejection", false, "Pileup rejection"}; - Configurable goodzvertex{"goodzvertex", false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference."}; - Configurable itstpctracks{"itstpctracks", false, "selects collisions with at least one ITS-TPC track,"}; + // Configurable piluprejection{"piluprejection", false, "Pileup rejection"}; + // Configurable goodzvertex{"goodzvertex", false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference."}; + // Configurable itstpctracks{"itstpctracks", false, "selects collisions with at least one ITS-TPC track,"}; Configurable timFrameEvsel{"timFrameEvsel", true, "TPC Time frame boundary cut"}; - Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; Configurable otherQAplots{"otherQAplots", true, "Other QA plots"}; Configurable QAPID{"QAPID", true, "QA PID plots"}; Configurable QAevents{"QAevents", true, "QA events"}; Configurable cfgMultFT0M{"cfgMultFT0M", true, "true for pp (FT0M estimator) and false for PbPb (FT0C estimator)"}; - // Event selection cuts - Alex (Temporary, need to fix!) - TF1* fMultPVCutLow = nullptr; - TF1* fMultPVCutHigh = nullptr; - TF1* fMultCutLow = nullptr; - TF1* fMultCutHigh = nullptr; - TF1* fMultMultPVCut = nullptr; - // track - Configurable rotational_cut{"rotational_cut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; + Configurable rotationalCut{"rotationalCut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; Configurable cfgCutPT{"cfgCutPT", 0.2, "PT cut on daughter track"}; Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; @@ -94,24 +103,16 @@ struct kaonkaonAnalysisRun3 { Configurable iscustomDCAcut{"iscustomDCAcut", false, "iscustomDCAcut"}; Configurable isNoTOF{"isNoTOF", false, "isNoTOF"}; Configurable ismanualDCAcut{"ismanualDCAcut", true, "ismanualDCAcut"}; - Configurable isITSOnlycut{"isITSOnlycut", true, "isITSOnlycut"}; + Configurable isITSOnlycut{"isITSOnlycut", false, "isITSOnlycut"}; Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; Configurable isDeepAngle{"isDeepAngle", false, "Deep Angle cut"}; Configurable cfgDeepAngle{"cfgDeepAngle", 0.04, "Deep Angle cut value"}; - Configurable cmultLow{"cmultLow", 0.0f, "Low centrality percentile"}; - Configurable cmultHigh{"cmultHigh", 150.0f, "High centrality percentile"}; - Configurable cmultBins{"cmultBins", 150, "Number of centrality bins"}; - Configurable cpTlow{"cpTlow", 0.0f, "Low pT"}; - Configurable cpThigh{"cpThigh", 10.0f, "High pT"}; - Configurable cpTbins{"cpTbins", 100, "Number of pT bins"}; - Configurable cMasslow{"cMasslow", 0.9f, "Low mass"}; - Configurable cMasshigh{"cMasshigh", 2.5f, "High mass"}; - Configurable cMassbins{"cMassbins", 320, "Number of mass bins"}; - Configurable c_nof_rotations{"c_nof_rotations", 3, "Number of random rotations in the rotational background"}; - ConfigurableAxis axisdEdx{"axisdEdx", {20000, 0.0f, 200.0f}, "dE/dx (a.u.)"}; - ConfigurableAxis axisPtfordEbydx{"axisPtfordEbydx", {2000, 0, 20}, "pT (GeV/c)"}; - ConfigurableAxis axisMultdist{"axisMultdist", {3500, 0, 70000}, "Multiplicity distribution"}; + + Configurable cRotations{"cRotations", 3, "Number of random rotations in the rotational background"}; + ConfigurableAxis axisdEdx{"axisdEdx", {1, 0.0f, 200.0f}, "dE/dx (a.u.)"}; + ConfigurableAxis axisPtfordEbydx{"axisPtfordEbydx", {1, 0, 20}, "pT (GeV/c)"}; + ConfigurableAxis axisMultdist{"axisMultdist", {1, 0, 70000}, "Multiplicity distribution"}; // different frames Configurable activateTHnSparseCosThStarHelicity{"activateTHnSparseCosThStarHelicity", true, "Activate the THnSparse with cosThStar w.r.t. helicity axis"}; @@ -119,6 +120,9 @@ struct kaonkaonAnalysisRun3 { Configurable activateTHnSparseCosThStarBeam{"activateTHnSparseCosThStarBeam", false, "Activate the THnSparse with cosThStar w.r.t. beam axis (Gottified jackson frame)"}; Configurable activateTHnSparseCosThStarRandom{"activateTHnSparseCosThStarRandom", false, "Activate the THnSparse with cosThStar w.r.t. random axis"}; ConfigurableAxis configThnAxisPOL{"configThnAxisPOL", {20, -1.0, 1.0}, "Costheta axis"}; + ConfigurableAxis invMassKKAxis{"invMassKKAxis", {200, 1.0f, 3.0f}, "KK pair invariant mass axis"}; + ConfigurableAxis ptAxisKK{"ptAxisKK", {200, 0.0f, 20.0f}, "KK pair pT axis"}; + ConfigurableAxis multAxis{"multAxis", {110, 0.0f, 110.0f}, "THnSparse multiplicity axis"}; // MC Configurable isMC{"isMC", false, "Run MC"}; @@ -127,9 +131,10 @@ struct kaonkaonAnalysisRun3 { void init(o2::framework::InitContext&) { - AxisSpec axisMult{cmultBins, cmultLow, cmultHigh, "Multiplicity"}; - AxisSpec axisPt{cpTbins, cpTlow, cpThigh, "pT (GeV/c)"}; - AxisSpec axisMass{cMassbins, cMasslow, cMasshigh, "Invariant mass (GeV/c^2)"}; + rctChecker.init(rctCut.cfgEvtRCTFlagCheckerLabel, rctCut.cfgEvtRCTFlagCheckerZDCCheck, rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + AxisSpec axisMult{multAxis, "Multiplicity"}; + AxisSpec axisPt{ptAxisKK, "pT (GeV/c)"}; + AxisSpec axisMass{invMassKKAxis, "Invariant mass (GeV/c^2)"}; const AxisSpec thnAxisPOL{configThnAxisPOL, "Frame axis"}; // THnSparses @@ -189,46 +194,30 @@ struct kaonkaonAnalysisRun3 { histos.add("Chi2perclusterTOF", "Chi2 / cluster for the TOF track segment", kTH1F, {{50, 0.0f, 50.0f}}); } if (!isMC) { - histos.add("h3PhiInvMassUnlikeSign", "KK Unlike Sign", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); - histos.add("h3PhiInvMassLikeSignPP", "KK Like Sign +", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); - histos.add("h3PhiInvMassLikeSignMM", "KK Like Sign -", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); - histos.add("h3PhiInvMassMixed", "KK Mixed", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); - histos.add("h3PhiInvMassRotation", "KK Rotation", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); + hInvMass.add("h3PhiInvMassUnlikeSign", "KK Unlike Sign", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); + hInvMass.add("h3PhiInvMassLikeSignPP", "KK Like Sign +", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); + hInvMass.add("h3PhiInvMassLikeSignMM", "KK Like Sign -", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); + hInvMass.add("h3PhiInvMassMixed", "KK Mixed", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); + hInvMass.add("h3PhiInvMassRotated", "KK Rotation", kTHnSparseF, {axisMult, axisPt, axisMass, thnAxisPOL}, true); } else if (isMC) { + hInvMass.add("h1PhiGen", "Phi meson Gen", kTH1F, {axisMult, axisPt}); + hInvMass.add("h3PhiRec", "Phi meson Rec", kTHnSparseF, {axisMult, axisPt, axisMass}); histos.add("hMC", "MC Event statistics", kTH1F, {{6, 0.0f, 6.0f}}); - histos.add("h1PhiGen", "Phi meson Gen", kTH1F, {axisPt}); histos.add("h1PhiRecsplit", "Phi meson Rec split", kTH1F, {axisPt}); - histos.add("h3PhiRec", "Phi meson Rec", kTHnSparseF, {axisPt, axisPt, {200, -0.1, 0.1}}, true); - } - if (additionalEvsel) { - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); - fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x)", 0, 100); - fMultCutLow->SetParameters(1893.94, -53.86, 0.502913, -0.0015122, 109.625, -1.19253); - fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x)", 0, 100); - fMultCutHigh->SetParameters(1893.94, -53.86, 0.502913, -0.0015122, 109.625, -1.19253); - fMultMultPVCut = new TF1("fMultMultPVCut", "[0]+[1]*x+[2]*x*x", 0, 5000); - fMultMultPVCut->SetParameters(-0.1, 0.785, -4.7e-05); + histos.add("Recmutiplicity", "Reconstructed multiplicity distribution", kTH1F, {axisMult}); + histos.add("Genmutiplicity", "Generated multiplicity distribution", kTH1F, {axisMult}); } } double massKa = o2::constants::physics::MassKPlus; - double rapidity; - double genMass, recMass, resolution; - double mass{0.}; - double massrotation1{0.}; - double massrotation2{0.}; - double pT{0.}; - array pvec0; - array pvec1; - array pvec1rotation; - array pvec2rotation; - ROOT::Math::PxPyPzMVector daughter1, daughter2; + double rapidity{0.0}, mass{0.}, massrotation1{0.}, massrotation2{0.}, pT{0.}; + float theta2; + ROOT::Math::PxPyPzMVector daughter1, daughter2, daughterRot, mother, motherRot, daughterSelected, fourVecDauCM, daughterRotCM; + ROOT::Math::XYZVector randomVec, beamVec, normalVec; + bool isMix = false; template - bool eventselection(Collision const& collision, const float& multiplicity) + bool eventselection(Collision const& collision) { if (!collision.sel8()) { return false; @@ -236,32 +225,15 @@ struct kaonkaonAnalysisRun3 { if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { return false; } - if (piluprejection && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return false; - } - if (goodzvertex && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return false; - } - if (itstpctracks && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - return false; - } - // if (collision.alias_bit(kTVXinTRD)) { - // // TRD triggered - // // return 0; + // if (piluprejection && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // return false; + // } + // if (goodzvertex && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // return false; + // } + // if (itstpctracks && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + // return false; // } - auto multNTracksPV = collision.multNTracksPV(); - if (additionalEvsel && multNTracksPV < fMultPVCutLow->Eval(multiplicity)) { - return false; - } - if (additionalEvsel && multNTracksPV > fMultPVCutHigh->Eval(multiplicity)) { - return false; - } - // if (multTrk < fMultCutLow->Eval(multiplicity)) - // return 0; - // if (multTrk > fMultCutHigh->Eval(multiplicity)) - // return 0; - // if (multTrk > fMultMultPVCut->Eval(multNTracksPV)) - // return 0; return true; } @@ -310,73 +282,141 @@ struct kaonkaonAnalysisRun3 { } return true; } - template - void FillinvMass(const T1& candidate1, const T2& candidate2, const T3& framecalculation, float multiplicity, bool unlike, bool mix, bool likesign, bool rotation, float massd1, float massd2) + + template + void fillInvMass(const T1& daughter1, const T1& daughter2, const T1& mother, float multiplicity, bool isMix, const T2& track1, const T2& track2) { - int track1Sign = candidate1.sign(); - int track2Sign = candidate2.sign(); - TLorentzVector vec1, vec2, vec3, vec4, vec5; - vec1.SetPtEtaPhiM(candidate1.pt(), candidate1.eta(), candidate1.phi(), massd1); - vec2.SetPtEtaPhiM(candidate2.pt(), candidate2.eta(), candidate2.phi(), massd2); - vec3 = vec1 + vec2; - // daughter1 = ROOT::Math::PxPyPzMVector(candidate1.px(), candidate1.py(), candidate1.pz(), massd1); // Kplus - // daughter2 = ROOT::Math::PxPyPzMVector(candidate2.px(), candidate2.py(), candidate2.pz(), massd2); // Kminus - double rapidity = vec3.Rapidity(); + ROOT::Math::Boost boost{mother.BoostToCM()}; + fourVecDauCM = boost(daughter1); - if (otherQAplots) { - histos.fill(HIST("Chi2perclusterITS"), candidate1.itsChi2NCl()); - histos.fill(HIST("Chi2perclusterITS"), candidate2.itsChi2NCl()); - histos.fill(HIST("Chi2perclusterTPC"), candidate1.tpcChi2NCl()); - histos.fill(HIST("Chi2perclusterTPC"), candidate2.tpcChi2NCl()); - histos.fill(HIST("Chi2perclusterTRD"), candidate1.trdChi2()); - histos.fill(HIST("Chi2perclusterTRD"), candidate2.trdChi2()); - histos.fill(HIST("Chi2perclusterTOF"), candidate1.tofChi2()); - histos.fill(HIST("Chi2perclusterTOF"), candidate2.tofChi2()); - } - if (QAPID) { - histos.fill(HIST("dE_by_dx_TPC"), candidate1.p(), candidate1.tpcSignal()); - histos.fill(HIST("dE_by_dx_TPC"), candidate2.p(), candidate2.tpcSignal()); - } + if (std::abs(mother.Rapidity()) < 0.5) { + if (activateTHnSparseCosThStarHelicity) { + auto cosThetaStarHelicity = mother.Vect().Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(mother.Vect().Mag2())); - // polarization calculations - // auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); - // auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - // ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massd1); // Kaon - - // ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(vec3.Px(), vec3.Py(), vec3.Pz(), vec3.M()); // mass of KaonKaon pair - // ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - // ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - // ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother - - // default filling - // if (activateTHnSparseCosThStarHelicity) { - // ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame - // auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); - if (std::abs(rapidity) < 0.5 && track1Sign * track2Sign < 0) { - if (unlike) { - histos.fill(HIST("h3PhiInvMassUnlikeSign"), multiplicity, vec3.Pt(), vec3.M(), framecalculation); - } - if (mix) { - histos.fill(HIST("h3PhiInvMassMixed"), multiplicity, vec3.Pt(), vec3.M(), framecalculation); - } + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + hInvMass.fill(HIST("h3PhiInvMassUnlikeSign"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity); + + for (int i = 0; i < cRotations; i++) { + theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); - if (rotation) { - for (int i = 0; i < c_nof_rotations; i++) { - float theta2 = rn->Uniform(TMath::Pi() - TMath::Pi() / rotational_cut, TMath::Pi() + TMath::Pi() / rotational_cut); - vec4.SetPtEtaPhiM(candidate1.pt(), candidate1.eta(), candidate1.phi() + theta2, massd1); // for rotated background - vec5 = vec4 + vec2; - histos.fill(HIST("h3PhiInvMassRotation"), multiplicity, vec5.Pt(), vec5.M(), framecalculation); + daughterRot = ROOT::Math::PxPyPzMVector(daughter1.Px() * std::cos(theta2) - daughter1.Py() * std::sin(theta2), daughter1.Px() * std::sin(theta2) + daughter1.Py() * std::cos(theta2), daughter1.Pz(), daughter1.M()); + + motherRot = daughterRot + daughter2; + + ROOT::Math::Boost boost2{motherRot.BoostToCM()}; + daughterRotCM = boost2(daughterRot); + + auto cosThetaStarHelicityRot = motherRot.Vect().Dot(daughterRotCM.Vect()) / (std::sqrt(daughterRotCM.Vect().Mag2()) * std::sqrt(motherRot.Vect().Mag2())); + + if (calcRotational) + hInvMass.fill(HIST("h3PhiInvMassRotated"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarHelicityRot); + } + } else { + hInvMass.fill(HIST("h3PhiInvMassMixed"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity); + } + } else { + if (!isMix) { + if (calcLikeSign) { + if (track1.sign() * track2.sign() > 0) { + hInvMass.fill(HIST("h3PhiInvMasslikeSignPP"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity); + } else { + hInvMass.fill(HIST("h3PhiInvMasslikeSignMM"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity); + } + } + } + } + + } else if (activateTHnSparseCosThStarProduction) { + normalVec = ROOT::Math::XYZVector(mother.Py(), -mother.Px(), 0.f); + auto cosThetaStarProduction = normalVec.Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(normalVec.Mag2())); + + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + hInvMass.fill(HIST("h3PhiInvMassUnlikeSign"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction); + for (int i = 0; i < cRotations; i++) { + theta2 = rn->Uniform(0, o2::constants::math::PI); + daughterRot = ROOT::Math::PxPyPzMVector(daughter1.Px() * std::cos(theta2) - daughter1.Py() * std::sin(theta2), daughter1.Px() * std::sin(theta2) + daughter1.Py() * std::cos(theta2), daughter1.Pz(), daughter1.M()); + + motherRot = daughterRot + daughter2; + if (calcRotational) + hInvMass.fill(HIST("h3PhiInvMassRotated"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarProduction); + } + } else { + hInvMass.fill(HIST("h3PhiInvMassMixed"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction); + } + } else { + if (!isMix) { + if (calcLikeSign) { + if (track1.sign() * track2.sign() > 0) { + hInvMass.fill(HIST("h3PhiInvMasslikeSignPP"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction); + } else { + hInvMass.fill(HIST("h3PhiInvMasslikeSignMM"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction); + } + } + } + } + } else if (activateTHnSparseCosThStarBeam) { + beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); + auto cosThetaStarBeam = beamVec.Dot(fourVecDauCM.Vect()) / std::sqrt(fourVecDauCM.Vect().Mag2()); + + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + hInvMass.fill(HIST("h3PhiInvMassUnlikeSign"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam); + for (int i = 0; i < cRotations; i++) { + theta2 = rn->Uniform(0, o2::constants::math::PI); + daughterRot = ROOT::Math::PxPyPzMVector(daughter1.Px() * std::cos(theta2) - daughter1.Py() * std::sin(theta2), daughter1.Px() * std::sin(theta2) + daughter1.Py() * std::cos(theta2), daughter1.Pz(), daughter1.M()); + + motherRot = daughterRot + daughter2; + if (calcRotational) + hInvMass.fill(HIST("h3PhiInvMassRotated"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarBeam); + } + } else { + hInvMass.fill(HIST("h3PhiInvMassMixed"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam); + } + } else { + if (calcLikeSign) { + if (track1.sign() * track2.sign() > 0) { + hInvMass.fill(HIST("h3PhiInvMasslikeSignPP"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam); + } else { + hInvMass.fill(HIST("h3PhiInvMasslikeSignMM"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam); + } + } + } + } else if (activateTHnSparseCosThStarRandom) { + auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); + auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); + + randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); + auto cosThetaStarRandom = randomVec.Dot(fourVecDauCM.Vect()) / std::sqrt(fourVecDauCM.Vect().Mag2()); + + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + hInvMass.fill(HIST("h3PhiInvMassUnlikeSign"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom); + for (int i = 0; i < cRotations; i++) { + theta2 = rn->Uniform(0, o2::constants::math::PI); + daughterRot = ROOT::Math::PxPyPzMVector(daughter1.Px() * std::cos(theta2) - daughter1.Py() * std::sin(theta2), daughter1.Px() * std::sin(theta2) + daughter1.Py() * std::cos(theta2), daughter1.Pz(), daughter1.M()); + + motherRot = daughterRot + daughter2; + if (calcRotational) + hInvMass.fill(HIST("h3PhiInvMassRotated"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarRandom); + } + } else { + hInvMass.fill(HIST("h3PhiInvMassMixed"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom); + } + } else { + if (!isMix) { + if (calcLikeSign) { + if (track1.sign() * track2.sign() > 0) { + hInvMass.fill(HIST("h3PhiInvMasslikeSignPP"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom); + } else { + hInvMass.fill(HIST("h3PhiInvMasslikeSignMM"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom); + } + } + } } } } - if (std::abs(rapidity) < 0.5 && track1Sign * track2Sign > 0 && likesign) { - if (track1Sign > 0 && track2Sign > 0) { - histos.fill(HIST("h3PhiInvMassLikeSignPP"), multiplicity, vec3.Pt(), vec3.M(), framecalculation); - } else { - histos.fill(HIST("h3PhiInvMassLikeSignMM"), multiplicity, vec3.Pt(), vec3.M(), framecalculation); - } - } - // } } Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; @@ -387,12 +427,15 @@ struct kaonkaonAnalysisRun3 { using TrackCandidates = soa::Filtered>; // using EventCandidatesMC = soa::Join; - using EventCandidatesMC = soa::Join; + using EventCandidatesMC = soa::Join; using TrackCandidatesMC = soa::Filtered>; void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) { - if (!eventselection(collision, collision.centFT0M())) { + if (rctCut.requireRCTFlagChecker && !rctChecker(collision)) { + return; + } + if (!eventselection(collision)) { return; } float multiplicity; @@ -433,74 +476,16 @@ struct kaonkaonAnalysisRun3 { continue; } - // calculation of event planes - daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); // Kplus - daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); // Kminus - - ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massKa); // Kaon - TLorentzVector lv1, lv2, lv3; - lv1.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi(), massKa); - lv2.SetPtEtaPhiM(track2.pt(), track2.eta(), track2.phi(), massKa); - lv3 = lv1 + lv2; - - ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KaonKaon pair - ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother - - bool unlike = true; - bool mix = false; - bool likesign = true; - bool rotation = true; - if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame - auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); - - if (isITSOnlycut) { - FillinvMass(track1, track2, cosThetaStarHelicity, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(track1) && selectionPID(track2)) { - FillinvMass(track1, track2, cosThetaStarHelicity, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } else if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); - auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); - - if (isITSOnlycut) { - FillinvMass(track1, track2, cosThetaStarProduction, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(track1) && selectionPID(track2)) { - FillinvMass(track1, track2, cosThetaStarProduction, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } else if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); - auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - - if (isITSOnlycut) { - FillinvMass(track1, track2, cosThetaStarBeam, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(track1) && selectionPID(track2)) { - FillinvMass(track1, track2, cosThetaStarBeam, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } else if (activateTHnSparseCosThStarRandom) { - auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); - auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); - auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - - if (isITSOnlycut) { - FillinvMass(track1, track2, cosThetaStarRandom, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(track1) && selectionPID(track2)) { - FillinvMass(track1, track2, cosThetaStarRandom, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } + if (!selectionPID(track1)) // Track 1 is checked with Kaon + continue; + if (!selectionPID(track2)) // Track 2 is checked with Pion + continue; - // if (!isITSOnlycut && selectionPID(track1) && selectionPID(track2)) { - // // histos.fill(HIST("hNsigmaKaonTPC_after"), track1.pt(), track1.tpcNSigmaKa()); - // // histos.fill(HIST("hNsigmaKaonTOF_after"), track1.pt(), track1.tofNSigmaKa()); - // // histos.fill(HIST("hNsigmaKaonTOF_TPC_after"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); - // } + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + mother = daughter1 + daughter2; // Kstar meson + isMix = false; + fillInvMass(daughter1, daughter2, mother, multiplicity, isMix, track1, track2); } } } @@ -516,204 +501,53 @@ struct kaonkaonAnalysisRun3 { { auto tracksTuple = std::make_tuple(tracks); //////// currently mixing the event with similar TPC multiplicity //////// - BinningTypeVertexContributor1 binningOnPositions1{{axisVertex, axisMultiplicity}, true}; - BinningTypeVertexContributor2 binningOnPositions2{{axisVertex, axisMultiplicity}, true}; + BinningTypeVertexContributor1 binningOnPositions1{{axisVertex, axisMultiplicity}, true}; // for pp + BinningTypeVertexContributor2 binningOnPositions2{{axisVertex, axisMultiplicity}, true}; // for PbPb SameKindPair pair1{binningOnPositions1, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; SameKindPair pair2{binningOnPositions2, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; - if (cfgMultFT0M == true) { - for (auto& [c1, tracks1, c2, tracks2] : pair1) { - float multiplicity = c1.centFT0M(); - if (!eventselection(c1, multiplicity)) { - continue; - } - if (!eventselection(c2, multiplicity)) { - continue; - } - - for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - bool unlike = false; - bool mix = true; - bool likesign = false; - bool rotation = false; - if (!selectionTrack(t1)) { - continue; - } - if (!selectionTrack(t2)) { - continue; - } - if (!selectionPair(t1, t2)) { - continue; - } + for (auto& [c1, tracks1, c2, tracks2] : pair1) { + float multiplicity = c1.centFT0M(); - // calculation of event planes - daughter1 = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), massKa); // Kplus - daughter2 = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), massKa); // Kminus - - ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massKa); // Kaon - TLorentzVector lv1, lv2, lv3; - lv1.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massKa); - lv2.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massKa); - lv3 = lv1 + lv2; - - ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KaonKaon pair - ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother - - if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame - auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); - - if (isITSOnlycut) { - FillinvMass(t1, t2, cosThetaStarHelicity, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, cosThetaStarHelicity, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } else if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); - auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); + if (rctCut.requireRCTFlagChecker && !rctChecker(c1)) { + continue; + } + if (rctCut.requireRCTFlagChecker && !rctChecker(c2)) { + continue; + } - if (isITSOnlycut) { - FillinvMass(t1, t2, cosThetaStarProduction, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, cosThetaStarProduction, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } else if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); - auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); + if (!eventselection(c1)) { + continue; + } + if (!eventselection(c2)) { + continue; + } - if (isITSOnlycut) { - FillinvMass(t1, t2, cosThetaStarBeam, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, cosThetaStarBeam, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } else if (activateTHnSparseCosThStarRandom) { - auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); - auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); - auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - - if (isITSOnlycut) { - FillinvMass(t1, t2, cosThetaStarRandom, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, cosThetaStarRandom, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } + for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - // if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - // histos.fill(HIST("hNsigmaKaonTPC_after"), t1.pt(), t1.tpcNSigmaKa()); - // histos.fill(HIST("hNsigmaKaonTOF_after"), t1.pt(), t1.tofNSigmaKa()); - // histos.fill(HIST("hNsigmaKaonTOF_TPC_after"), t1.tofNSigmaKa(), t1.tpcNSigmaKa()); - // } - // if (isITSOnlycut) { - // FillinvMass(t1, t2, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - // } - // if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - // FillinvMass(t1, t2, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - // } + if (!selectionTrack(t1)) { + continue; } - } - } else { - for (auto& [c1, tracks1, c2, tracks2] : pair2) { - float multiplicity = c1.centFT0C(); - - if (!eventselection(c1, multiplicity)) { + if (!selectionTrack(t2)) { continue; } - if (!eventselection(c2, multiplicity)) { + if (!selectionPair(t1, t2)) { continue; } - for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - bool unlike = false; - bool mix = true; - bool likesign = false; - bool rotation = false; - if (!selectionTrack(t1)) { - continue; - } - if (!selectionTrack(t2)) { - continue; - } - if (!selectionPair(t1, t2)) { - continue; - } - // calculation of event planes - daughter1 = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), massKa); // Kplus - daughter2 = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), massKa); // Kminus - - ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massKa); // Kaon - TLorentzVector lv1, lv2, lv3; - lv1.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massKa); - lv2.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massKa); - lv3 = lv1 + lv2; - - ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KaonKaon pair - ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother - - if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame - auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); + if (!selectionPID(t1)) + continue; + if (!selectionPID(t2)) + continue; - if (isITSOnlycut) { - FillinvMass(t1, t2, cosThetaStarHelicity, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, cosThetaStarHelicity, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } else if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); - auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); + daughter1 = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), massKa); + mother = daughter1 + daughter2; // Kstar meson - if (isITSOnlycut) { - FillinvMass(t1, t2, cosThetaStarProduction, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, cosThetaStarProduction, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } else if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); - auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); + isMix = true; - if (isITSOnlycut) { - FillinvMass(t1, t2, cosThetaStarBeam, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, cosThetaStarBeam, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } else if (activateTHnSparseCosThStarRandom) { - auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); - auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); - auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - - if (isITSOnlycut) { - FillinvMass(t1, t2, cosThetaStarRandom, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, cosThetaStarRandom, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - } - - // if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - // histos.fill(HIST("hNsigmaKaonTPC_after"), t1.pt(), t1.tpcNSigmaKa()); - // histos.fill(HIST("hNsigmaKaonTOF_after"), t1.pt(), t1.tofNSigmaKa()); - // histos.fill(HIST("hNsigmaKaonTOF_TPC_after"), t1.tofNSigmaKa(), t1.tpcNSigmaKa()); - // } - - // if (isITSOnlycut) { - // FillinvMass(t1, t2, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - // } - // if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - // FillinvMass(t1, t2, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - // } + if (std::abs(mother.Rapidity()) < 0.5) { + fillInvMass(daughter1, daughter2, mother, multiplicity, isMix, t1, t2); } } } @@ -726,6 +560,7 @@ struct kaonkaonAnalysisRun3 { if (std::abs(mcCollision.posZ()) < cfgCutVertex) { histos.fill(HIST("hMC"), 1.5); } + auto multiplicity = -1; int Nchinel = 0; for (auto& mcParticle : mcParticles) { auto pdgcode = std::abs(mcParticle.pdgCode()); @@ -744,6 +579,7 @@ struct kaonkaonAnalysisRun3 { continue; } SelectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); + multiplicity = collision.centFT0M(); } SelectedEvents.resize(nevts); const auto evtReconstructedAndSelected = std::find(SelectedEvents.begin(), SelectedEvents.end(), mcCollision.globalIndex()) != SelectedEvents.end(); @@ -751,6 +587,7 @@ struct kaonkaonAnalysisRun3 { if (!evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection return; } + histos.fill(HIST("Genmutiplicity"), multiplicity); histos.fill(HIST("hMC"), 4.5); for (auto& mcParticle : mcParticles) { if (std::abs(mcParticle.y()) > 0.5) { @@ -776,7 +613,7 @@ struct kaonkaonAnalysisRun3 { } } if (daughtp && daughtm) { - histos.fill(HIST("h1PhiGen"), mcParticle.pt()); + hInvMass.fill(HIST("h1PhiGen"), multiplicity, mcParticle.pt()); } } } @@ -790,6 +627,8 @@ struct kaonkaonAnalysisRun3 { if (std::abs(collision.mcCollision().posZ()) > cfgCutVertex || !collision.sel8()) { return; } + auto multiplicity = collision.centFT0M(); + histos.fill(HIST("Recmutiplicity"), multiplicity); histos.fill(HIST("hMC"), 5.5); auto oldindex = -999; for (auto track1 : tracks) { @@ -847,23 +686,27 @@ struct kaonkaonAnalysisRun3 { if (std::abs(mothertrack1.pdgCode()) != 333) { continue; } - if (!isITSOnlycut && !(selectionPID(track1) && selectionPID(track2))) { + if (!(selectionPID(track1))) { + continue; + } + if (!(selectionPID(track2))) { continue; } if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { histos.fill(HIST("h1PhiRecsplit"), mothertrack1.pt()); continue; } - oldindex = mothertrack1.globalIndex(); - pvec0 = array{track1.px(), track1.py(), track1.pz()}; - pvec1 = array{track2.px(), track2.py(), track2.pz()}; - auto arrMomrec = array{pvec0, pvec1}; - auto motherP = mothertrack1.p(); - auto motherE = mothertrack1.e(); - genMass = std::sqrt(motherE * motherE - motherP * motherP); - recMass = RecoDecay::m(arrMomrec, array{massKa, massKa}); - auto recpt = TMath::Sqrt((track1.px() + track2.px()) * (track1.px() + track2.px()) + (track1.py() + track2.py()) * (track1.py() + track2.py())); - histos.fill(HIST("h3PhiRec"), mothertrack1.pt(), recpt, recMass - genMass); + + if (track1.sign() * track2.sign() < 0) { + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } + mother = daughter1 + daughter2; + + if (TMath::Abs(mother.Rapidity()) >= 0.5) { + continue; + } + hInvMass.fill(HIST("h3PhiRec"), multiplicity, mother.Pt(), mother.M()); } } } diff --git a/PWGLF/Tasks/Resonances/kshortlambda.cxx b/PWGLF/Tasks/Resonances/kshortlambda.cxx index 71361129905..225ea15e447 100644 --- a/PWGLF/Tasks/Resonances/kshortlambda.cxx +++ b/PWGLF/Tasks/Resonances/kshortlambda.cxx @@ -498,6 +498,11 @@ struct Kshortlambda { return true; } + double massK0s = o2::constants::physics::MassK0Short; + double massLambda = o2::constants::physics::MassLambda; + double massPr = o2::constants::physics::MassProton; + double massPi = o2::constants::physics::MassPionCharged; + // Defining filters for events (event selection) // Filter eventFilter = (o2::aod::evsel::sel8 == true); @@ -516,14 +521,13 @@ struct Kshortlambda { ROOT::Math::PxPyPzMVector daughter1, daughter2; ROOT::Math::PxPyPzMVector protonVec, pionVec, lambdaVec; + ROOT::Math::PxPyPzMVector fourVecDau, fourVecMother, fourVecDauCM; + ROOT::Math::XYZVector threeVecDauCM; + ROOT::Math::XYZVector helicityVec, normalVec, randomVec, beamVec; void processSE(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::V0Datas const& V0s) { hvzero.fill(HIST("heventscheck"), 0.5); - const double massK0s = o2::constants::physics::MassK0Short; - const double massLambda = o2::constants::physics::MassLambda; - const double massPr = o2::constants::physics::MassProton; - const double massPi = o2::constants::physics::MassPionCharged; float multiplicity = 0.0f; if (cfgMultFOTM) { @@ -550,7 +554,7 @@ struct Kshortlambda { } std::vector v0indexes; - + TLorentzVector lv1, lv3, lvLambda, lv4, lv5; for (const auto& [v1, v2] : combinations(CombinationsStrictlyUpperIndexPolicy(V0s, V0s))) { hvzero.fill(HIST("heventscheck"), 2.5); if (v1.size() == 0 || v2.size() == 0) { @@ -610,9 +614,9 @@ struct Kshortlambda { } lambdaVec = protonVec + pionVec; - TLorentzVector lv1, lv2, lv3, lvLambda, lv4, lv5; lv1.SetPtEtaPhiM(v1.pt(), v1.eta(), v1.phi(), massK0s); lvLambda.SetPtEtaPhiM(lambdaVec.pt(), lambdaVec.eta(), lambdaVec.phi(), massLambda); + lv3 = lv1 + lvLambda; if (qAv0daughters) { @@ -628,48 +632,47 @@ struct Kshortlambda { daughter2 = ROOT::Math::PxPyPzMVector(v2.px(), v2.py(), v2.pz(), massLambda); // V02 // polarization calculations - ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massK0s); // Kshort - ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KshortKshort pair - ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother + fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massK0s); // Kshort + fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KshortKshort pair + ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame + fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother + threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother + if (std::abs(lv3.Rapidity()) < 0.5) { if (invMass1D) { hvzero.fill(HIST("h1vzeropairInvMassRot"), lv3.M()); } if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame + helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); hvzero.fill(HIST("h3vzeropairInvMassDS"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity, occupancyno); for (int i = 0; i < cnofrotations; i++) { float theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); lv4.SetPtEtaPhiM(lambdaVec.pt(), lambdaVec.eta(), lambdaVec.phi() + theta2, massLambda); // for rotated background - lv5 = lv1 + lv4; - hvzero.fill(HIST("h3vzeropairInvMassRot"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarHelicity, occupancyno); } } else if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); + normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); hvzero.fill(HIST("h3vzeropairInvMassDS"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction, occupancyno); for (int i = 0; i < cnofrotations; i++) { - float theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); + auto theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); lv4.SetPtEtaPhiM(lambdaVec.pt(), lambdaVec.eta(), lambdaVec.phi() + theta2, massLambda); // for rotated background lv5 = lv1 + lv4; hvzero.fill(HIST("h3vzeropairInvMassRot"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarProduction, occupancyno); } } else if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); + beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); hvzero.fill(HIST("h3vzeropairInvMassDS"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam, occupancyno); for (int i = 0; i < cnofrotations; i++) { - float theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); + auto theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); lv4.SetPtEtaPhiM(lambdaVec.pt(), lambdaVec.eta(), lambdaVec.phi() + theta2, massLambda); // for rotated background lv5 = lv1 + lv4; hvzero.fill(HIST("h3vzeropairInvMassRot"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarBeam, occupancyno); @@ -677,12 +680,12 @@ struct Kshortlambda { } else if (activateTHnSparseCosThStarRandom) { auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); + randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); hvzero.fill(HIST("h3vzeropairInvMassDS"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom, occupancyno); for (int i = 0; i < cnofrotations; i++) { - float theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); + auto theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); lv4.SetPtEtaPhiM(lambdaVec.pt(), lambdaVec.eta(), lambdaVec.phi() + theta2, massLambda); // for rotated background lv5 = lv1 + lv4; hvzero.fill(HIST("h3vzeropairInvMassRot"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarRandom, occupancyno); @@ -707,11 +710,6 @@ struct Kshortlambda { void processME(EventCandidates const& collisions, TrackCandidates const& /*tracks*/, V0TrackCandidate const& v0s) { - const double massK0s = o2::constants::physics::MassK0Short; - const double massLambda = o2::constants::physics::MassLambda; - const double massPr = o2::constants::physics::MassProton; - const double massPi = o2::constants::physics::MassPionCharged; - auto tracksTuple = std::make_tuple(v0s); BinningTypeVertexContributor binningOnPositions1{{mevz, memult}, true}; BinningTypeCentralityM binningOnPositions2{{mevz, memult}, true}; @@ -720,6 +718,8 @@ struct Kshortlambda { SameKindPair pair2{binningOnPositions2, cfgNmixedEvents, -1, collisions, tracksTuple, &cache}; // for pp if (cfgMultFOTM) { + TLorentzVector lv1, lv3, lvLambda, lv4, lv5; + for (const auto& [c1, tracks1, c2, tracks2] : pair2) // two different centrality c1 and c2 and tracks corresponding to them { @@ -733,7 +733,7 @@ struct Kshortlambda { auto occupancyno = c1.trackOccupancyInTimeRange(); auto occupancyno2 = c2.trackOccupancyInTimeRange(); if (applyOccupancyCut && (occupancyno < occupancyCut || occupancyno2 < occupancyCut)) { - return; + continue; } for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { @@ -792,33 +792,32 @@ struct Kshortlambda { pionVec = ROOT::Math::PxPyPzMVector(postrack2.px(), postrack2.py(), postrack2.pz(), massPi); } lambdaVec = protonVec + pionVec; - - TLorentzVector lv1, lv2, lv3, lvLambda, lv4, lv5; lv1.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massK0s); lvLambda.SetPtEtaPhiM(lambdaVec.pt(), lambdaVec.eta(), lambdaVec.phi(), massLambda); lv3 = lv1 + lvLambda; - ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massK0s); // Kshort - ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KshortKshort pair + fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massK0s); // Kshort + fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KshortKshort pair ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother + fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother + threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother + if (std::abs(lv3.Rapidity()) < 0.5) { if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame + helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); hvzero.fill(HIST("h3vzeropairInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity, occupancyno); } else if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); + normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); hvzero.fill(HIST("h3vzeropairInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction, occupancyno); } else if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); + beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); hvzero.fill(HIST("h3vzeropairInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam, occupancyno); } else if (activateTHnSparseCosThStarRandom) { auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); + randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); hvzero.fill(HIST("h3vzeropairInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom, occupancyno); } @@ -836,10 +835,11 @@ struct Kshortlambda { } auto occupancyno = c1.trackOccupancyInTimeRange(); auto occupancyno2 = c2.trackOccupancyInTimeRange(); + if (applyOccupancyCut && (occupancyno < occupancyCut || occupancyno2 < occupancyCut)) { - return; + continue; } - + TLorentzVector lv1, lv3, lvLambda, lv4, lv5; for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { if (t1.size() == 0 || t2.size() == 0) { @@ -897,34 +897,34 @@ struct Kshortlambda { } lambdaVec = protonVec + pionVec; - TLorentzVector lv1, lv2, lv3, lvLambda, lv4, lv5; lv1.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massK0s); lvLambda.SetPtEtaPhiM(lambdaVec.pt(), lambdaVec.eta(), lambdaVec.phi(), massLambda); lv3 = lv1 + lvLambda; - ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massK0s); // Kshort - ROOT::Math::PxPyPzMVector fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KshortKshort pair + fourVecDau = ROOT::Math::PxPyPzMVector(daughter1.Px(), daughter1.Py(), daughter1.Pz(), massK0s); // Kshort + fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KshortKshort pair ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - ROOT::Math::PxPyPzMVector fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother - ROOT::Math::XYZVector threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother + fourVecDauCM = boost(fourVecDau); // boost the frame of daughter same as mother + threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother + if (std::abs(lv3.Rapidity()) < 0.5) { if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame + helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); hvzero.fill(HIST("h3vzeropairInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity, occupancyno); } else if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); + normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); hvzero.fill(HIST("h3vzeropairInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction, occupancyno); } else if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); + beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); hvzero.fill(HIST("h3vzeropairInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam, occupancyno); } else if (activateTHnSparseCosThStarRandom) { auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - ROOT::Math::XYZVector randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); + randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); hvzero.fill(HIST("h3vzeropairInvMassME"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom, occupancyno); } diff --git a/PWGLF/Tasks/Resonances/kstar892analysis.cxx b/PWGLF/Tasks/Resonances/kstar892analysis.cxx index eb75690babd..0a43e73bb5b 100644 --- a/PWGLF/Tasks/Resonances/kstar892analysis.cxx +++ b/PWGLF/Tasks/Resonances/kstar892analysis.cxx @@ -36,6 +36,7 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::constants::physics; +using namespace o2::aod::resodaughter; struct kstar892analysis { HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -88,11 +89,7 @@ struct kstar892analysis { Configurable additionalMEPlots{"additionalMEPlots", false, "Additional Mixed event plots"}; Configurable tof_at_high_pt{"tof_at_high_pt", false, "Use TOF at high pT"}; - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; - Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; - Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; - Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; @@ -111,7 +108,6 @@ struct kstar892analysis { void init(o2::framework::InitContext&) { - // LOG(info) << "\n cfgITScluster ============>"<< static_cast(cfgITScluster); // LOG(info)<< "\n cfgTPCcluster ============>"<< static_cast(cfgTPCcluster); AxisSpec centAxis = {binsCent, "V0M (%)"}; @@ -248,30 +244,71 @@ struct kstar892analysis { // Filters Filter acceptanceFilter = nabs(aod::resodaughter::pt) >= cMinPtcut; - Filter qualityFilter = (aod::track::itsChi2NCl <= cfgITSChi2NCl) && (aod::track::tpcChi2NCl <= cfgTPCChi2NCl) && (aod::resodaughter::tpcCrossedRowsOverFindableCls >= cfgRatioTPCRowsOverFindableCls); Filter DCAcutFilter = (nabs(aod::track::dcaXY) <= cMaxDCArToPVcut) && (nabs(aod::track::dcaZ) <= cMaxDCAzToPVcut); - Filter hasTPCfilter = aod::resodaughter::hasTPC == true; - Filter primarytrackFilter = aod::resodaughter::isPVContributor && aod::resodaughter::isPrimaryTrack && aod::resodaughter::isGlobalTrackWoDCA; + // Filter primarytrackFilter = aod::resodaughter::isPVContributor && aod::resodaughter::isPrimaryTrack && aod::resodaughter::isGlobalTrackWoDCA; + Filter primarytrackFilter = requirePVContributor() && requirePrimaryTrack() && requireGlobalTrackWoDCA(); // partitions for data - Partition> resoKaWithTof = (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (aod::resodaughter::hasTOF == true); - Partition> resoPiWithTof = (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (aod::resodaughter::hasTOF == true); - Partition> resoKa = (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon); - Partition> resoPi = (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion); - Partition> resoKaTPClowPt = (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon) && (nabs(aod::resodaughter::pt) < cMaxPtTPC); - Partition> resoPiTPClowPt = (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion) && (nabs(aod::resodaughter::pt) < cMaxPtTPC); - Partition> resoKaTOFhighPt = (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (aod::resodaughter::hasTOF == true) && (nabs(aod::resodaughter::pt) >= cMinPtTOF); - Partition> resoPiTOFhighPt = (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (aod::resodaughter::hasTOF == true) && (nabs(aod::resodaughter::pt) >= cMinPtTOF); + Partition resoKaWithTof = + (nabs(aod::resodaughter::tofNSigmaKa10) <= 10 * cMaxTOFnSigmaKaon) && + requireHasTOF(); + + Partition resoPiWithTof = + (nabs(aod::resodaughter::tofNSigmaPi10) <= 10 * cMaxTOFnSigmaPion) && + requireHasTOF(); + + Partition resoKa = + (nabs(aod::resodaughter::tpcNSigmaKa10) <= 10 * cMaxTPCnSigmaKaon); + + Partition resoPi = + (nabs(aod::resodaughter::tpcNSigmaPi10) <= 10 * cMaxTPCnSigmaPion); + + Partition resoKaTPClowPt = + (nabs(aod::resodaughter::tpcNSigmaKa10) <= 10 * cMaxTPCnSigmaKaon) && + (nabs(aod::resodaughter::pt) < cMaxPtTPC); + + Partition resoPiTPClowPt = + (nabs(aod::resodaughter::tpcNSigmaPi10) <= 10 * cMaxTPCnSigmaPion) && + (nabs(aod::resodaughter::pt) < cMaxPtTPC); + + Partition resoKaTOFhighPt = + (nabs(aod::resodaughter::tofNSigmaKa10) <= 10 * cMaxTOFnSigmaKaon) && + requireHasTOF() && (nabs(aod::resodaughter::pt) >= cMinPtTOF); + + Partition resoPiTOFhighPt = + (nabs(aod::resodaughter::tofNSigmaPi10) <= 10 * cMaxTOFnSigmaPion) && + requireHasTOF() && (nabs(aod::resodaughter::pt) >= cMinPtTOF); // Partitions for mc - Partition>> resoMCrecKaWithTof = (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (aod::resodaughter::hasTOF == true); - Partition>> resoMCrecPiWithTof = (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (aod::resodaughter::hasTOF == true); - Partition>> resoMCrecKa = (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon); - Partition>> resoMCrecPi = (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion); - Partition>> resoMCrecKaTPClowPt = (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon) && (nabs(aod::resodaughter::pt) < cMaxPtTPC); - Partition>> resoMCrecPiTPClowPt = (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion) && (nabs(aod::resodaughter::pt) < cMaxPtTPC); - Partition>> resoMCrecKaTOFhighPt = (nabs(aod::pidtof::tofNSigmaKa) <= cMaxTOFnSigmaKaon) && (aod::resodaughter::hasTOF == true) && (nabs(aod::resodaughter::pt) >= cMinPtTOF); - Partition>> resoMCrecPiTOFhighPt = (nabs(aod::pidtof::tofNSigmaPi) <= cMaxTOFnSigmaPion) && (aod::resodaughter::hasTOF == true) && (nabs(aod::resodaughter::pt) >= cMinPtTOF); + Partition> resoMCrecKaWithTof = + (nabs(aod::resodaughter::tofNSigmaKa10) <= 10 * cMaxTOFnSigmaKaon) && + requireHasTOF(); + + Partition> resoMCrecPiWithTof = + (nabs(aod::resodaughter::tofNSigmaPi10) <= 10 * cMaxTOFnSigmaPion) && + requireHasTOF(); + + Partition> resoMCrecKa = + (nabs(aod::resodaughter::tpcNSigmaKa10) <= 10 * cMaxTPCnSigmaKaon); + + Partition> resoMCrecPi = + (nabs(aod::resodaughter::tpcNSigmaPi10) <= 10 * cMaxTPCnSigmaPion); + + Partition> resoMCrecKaTPClowPt = + (nabs(aod::resodaughter::tpcNSigmaKa10) <= 10 * cMaxTPCnSigmaKaon) && + (nabs(aod::resodaughter::pt) < cMaxPtTPC); + + Partition> resoMCrecPiTPClowPt = + (nabs(aod::resodaughter::tpcNSigmaPi10) <= 10 * cMaxTPCnSigmaPion) && + (nabs(aod::resodaughter::pt) < cMaxPtTPC); + + Partition> resoMCrecKaTOFhighPt = + (nabs(aod::resodaughter::tofNSigmaKa10) <= 10 * cMaxTOFnSigmaKaon) && + requireHasTOF() && (nabs(aod::resodaughter::pt) >= cMinPtTOF); + + Partition> resoMCrecPiTOFhighPt = + (nabs(aod::resodaughter::tofNSigmaPi10) <= 10 * cMaxTOFnSigmaPion) && + requireHasTOF() && (nabs(aod::resodaughter::pt) >= cMinPtTOF); using ResoMCCols = soa::Join; @@ -283,11 +320,10 @@ struct kstar892analysis { template bool trackCut(const TrackType track) { - if (track.itsNCls() < cfgITScluster) - return false; + // TPC if (track.tpcNClsFound() < cfgTPCcluster) return false; - + // ITS if (cfgUseITSRefit && !track.passedITSRefit()) return false; if (cfgUseTPCRefit && !track.passedTPCRefit()) diff --git a/PWGLF/Tasks/Resonances/kstarFlowv1.cxx b/PWGLF/Tasks/Resonances/kstarFlowv1.cxx new file mode 100644 index 00000000000..08139c3c2d2 --- /dev/null +++ b/PWGLF/Tasks/Resonances/kstarFlowv1.cxx @@ -0,0 +1,356 @@ +// 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. +/// +/// \file kstarFlowv1.cxx +/// \brief first order flow harmonic for resonance +/// \author Prottay Das , Dukhishyam Mallick +/// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// #include +#include +#include +#include + +#include "TRandom3.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "Math/GenVector/Boost.h" +#include "TF1.h" + +#include "Common/Core/trackUtilities.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/RecoDecay.h" + +#include "PWGLF/DataModel/SPCalibrationTables.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/trackUtilities.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/TrackSelection.h" +#include "Framework/ASoAHelpers.h" +#include "ReconstructionDataFormats/Track.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/BasicCCDBManager.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; +using namespace o2::constants::physics; +struct KstarFlowv1 { + + Service ccdb; + // Service pdg; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutCentrality{"cfgCutCentrality", 80.0f, "Accepted maximum Centrality"}; + // track + Configurable cfgCutCharge{"cfgCutCharge", 0.0, "cut on Charge"}; + Configurable cfgCutPT{"cfgCutPT", 0.2, "PT cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; + Configurable useGlobalTrack{"useGlobalTrack", true, "use Global track"}; + Configurable nsigmaCutTOF{"nsigmaCutTOF", 3.0, "Value of the TOF Nsigma cut"}; + Configurable nsigmaCutTPC{"nsigmaCutTPC", 3.0, "Value of the TPC Nsigma cut"}; + Configurable nsigmaCutCombined{"nsigmaCutCombined", 3.0, "Value of the TOF Nsigma cut"}; + Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 1, "Number of mixed events per event"}; + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; + // Configurable removefaketrak{"removefaketrack", true, "Remove fake track from momentum difference"}; + Configurable confFakeKaonCut{"confFakeKaonCut", 0.1, "Cut based on track from momentum difference"}; + Configurable ispTdepPID{"ispTdepPID", true, "pT dependent PID"}; + Configurable onlyTOF{"onlyTOF", true, "onlyTOF"}; + Configurable strategyPID{"strategyPID", 2, "PID strategy"}; + Configurable cfgCutTOFBeta{"cfgCutTOFBeta", 0.0, "cut TOF beta"}; + Configurable confMinRot{"confMinRot", 5.0 * o2::constants::math::PI / 6.0, "Minimum of rotation"}; + Configurable confMaxRot{"confMaxRot", 7.0 * o2::constants::math::PI / 6.0, "Maximum of rotation"}; + Configurable nBkgRotations{"nBkgRotations", 9, "Number of rotated copies (background) per each original candidate"}; + Configurable fillRotation{"fillRotation", true, "fill rotation"}; + Configurable like{"like", true, "fill rotation"}; + Configurable spNbins{"spNbins", 2000, "Number of bins in sp"}; + Configurable lbinsp{"lbinsp", -1.0, "lower bin value in sp histograms"}; + Configurable hbinsp{"hbinsp", 1.0, "higher bin value in sp histograms"}; + + ConfigurableAxis configcentAxis{"configcentAxis", {VARIABLE_WIDTH, 0.0, 10.0, 30.0, 50.0, 80.0}, "Cent V0M"}; + ConfigurableAxis configthnAxisPt{"configthnAxisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 50.0}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis configetaAxis{"configetaAxis", {VARIABLE_WIDTH, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8}, "Eta"}; + ConfigurableAxis configIMAxis{"configIMAxis", {VARIABLE_WIDTH, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.05, 1.1, 1.15, 1.2}, "IM"}; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter centralityFilter = nabs(aod::cent::centFT0C) < cfgCutCentrality; + Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPT); + Filter dCAcutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + + using EventCandidates = soa::Filtered>; + using TrackCandidates = soa::Filtered>; + + SliceCache cache; + Partition posTracks = aod::track::signed1Pt > cfgCutCharge; + Partition negTracks = aod::track::signed1Pt < cfgCutCharge; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + AxisSpec spAxis = {spNbins, lbinsp, hbinsp, "Sp"}; + + histos.add("hpQxtQxpvscent", "hpQxtQxpvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); + histos.add("hpQytQypvscent", "hpQytQypvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); + histos.add("hpQxytpvscent", "hpQxytpvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); + histos.add("hpQxtQypvscent", "hpQxtQypvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); + histos.add("hpQxpQytvscent", "hpQxpQytvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); + + histos.add("hpv1vscentpteta", "hpv1vscentpteta", HistType::kTHnSparseF, {configIMAxis, configcentAxis, configthnAxisPt, configetaAxis, spAxis}, true); + histos.add("hpv1vscentptetarot", "hpv1vscentptetarot", HistType::kTHnSparseF, {configIMAxis, configcentAxis, configthnAxisPt, configetaAxis, spAxis}, true); + histos.add("hpv1vscentptetalike", "hpv1vscentptetalike", HistType::kTHnSparseF, {configIMAxis, configcentAxis, configthnAxisPt, configetaAxis, spAxis}, true); + } + + double massKa = o2::constants::physics::MassKPlus; + double massPi = o2::constants::physics::MassPiMinus; + + template + bool selectionTrack(const T& candidate) + { + if (useGlobalTrack && !(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster)) { + return false; + } + if (!useGlobalTrack && !(candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster)) { + return false; + } + return true; + } + + template + bool strategySelectionPID(const T& candidate, int PID, int strategy) + { + if (PID == 0) { + if (strategy == 0) { + if (candidate.pt() < 0.5 && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > 0.5) { + return true; + } + } else if (strategy == 1) { + if (candidate.pt() < 0.5 && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && std::sqrt(candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > 0.5) { + return true; + } + } else if (strategy == 2) { + if (candidate.pt() < 0.5 && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > 0.5) { + return true; + } + if (candidate.pt() >= 0.5 && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && !candidate.hasTOF()) { + return true; + } + } + } + if (PID == 1) { + if (strategy == 0) { + if (candidate.pt() < 0.5 && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < nsigmaCutTOF && candidate.beta() > 0.5) { + return true; + } + } else if (strategy == 1) { + if (candidate.pt() < 0.5 && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && std::sqrt(candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + candidate.tofNSigmaPi() * candidate.tofNSigmaPi()) < nsigmaCutTOF && candidate.beta() > 0.5) { + return true; + } + } else if (strategy == 2) { + if (candidate.pt() < 0.5 && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < nsigmaCutTOF && candidate.beta() > 0.5) { + return true; + } + if (candidate.pt() >= 0.5 && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && !candidate.hasTOF()) { + return true; + } + } + } + return false; + } + + double getPhiInRange(double phi) + { + double pi = o2::constants::math::PI; + double twoPi = 2.0 * pi; + double result = phi; + // Normalize to [-pi, pi] + // double result = std::fmod(phi + pi, twoPi); + // if (result < 0) { + // result += twoPi; + // } + // result -= pi; // Now result is in [-pi, pi] + + // Convert from [-pi, pi] to [0, pi] + if (result < 0) { + result += pi; // Shift negative values to positive + } + + // If phi > 2π, subtract π instead of normalizing by 2π + if (phi > twoPi) { + result -= pi; + } + + return result; // Ensures range is [0, π] + } + + template + bool isFakeKaon(T const& track, int /*PID*/) + { + const auto pglobal = track.p(); + const auto ptpc = track.tpcInnerParam(); + if (std::abs(pglobal - ptpc) > confFakeKaonCut) { + return true; + } + return false; + } + + ROOT::Math::PxPyPzMVector KstarMother, daughter1, daughter2, kaonrot, kstarrot; + + void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + { + if (!collision.sel8() || !collision.triggereventsp() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return; + } + auto centrality = collision.centFT0C(); + + auto qxZDCA = collision.qxZDCA(); + auto qxZDCC = collision.qxZDCC(); + auto qyZDCA = collision.qyZDCA(); + auto qyZDCC = collision.qyZDCC(); + + auto proQxtQxp = qxZDCA * qxZDCC; + auto proQytQyp = qyZDCA * qyZDCC; + auto proQxytp = proQxtQxp + proQytQyp; + auto proQxpQyt = qxZDCA * qyZDCC; + auto proQxtQyp = qxZDCC * qyZDCA; + + histos.fill(HIST("hpQxtQxpvscent"), centrality, proQxtQxp); + histos.fill(HIST("hpQytQypvscent"), centrality, proQytQyp); + histos.fill(HIST("hpQxytpvscent"), centrality, proQxytp); + histos.fill(HIST("hpQxpQytvscent"), centrality, proQxpQyt); + histos.fill(HIST("hpQxtQypvscent"), centrality, proQxtQyp); + + for (const auto& track1 : tracks) { + if (!selectionTrack(track1)) { + continue; + } + bool track1kaon = false; + auto track1ID = track1.globalIndex(); + if (!strategySelectionPID(track1, 0, strategyPID)) { + continue; + } + track1kaon = true; + for (const auto& track2 : tracks) { + if (!selectionTrack(track2)) { + continue; + } + bool track2pion = false; + auto track2ID = track2.globalIndex(); + if (!strategySelectionPID(track2, 1, strategyPID)) { + continue; + } + track2pion = true; + if (track2ID == track1ID) { + continue; + } + if (!track1kaon || !track2pion) { + continue; + } + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); + KstarMother = daughter1 + daughter2; + if (std::abs(KstarMother.Rapidity()) > 0.9) { + continue; + } + + // // constrain angle to 0 -> [0,0+2pi] + // auto phi = RecoDecay::constrainAngle(KstarMother.Phi(), 0,o2::constants::math::TwoPI); + + auto ux = std::cos(getPhiInRange(KstarMother.Phi())); + auto uy = std::sin(getPhiInRange(KstarMother.Phi())); + auto v1 = ux * (qxZDCA - qxZDCC) + uy * (qyZDCA - qyZDCC); + + // unlike sign + if (track1.sign() * track2.sign() < 0) { + histos.fill(HIST("hpv1vscentpteta"), KstarMother.M(), centrality, KstarMother.Pt(), KstarMother.Rapidity(), v1); + if (fillRotation) { + for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { + auto anglestart = confMinRot; + auto angleend = confMaxRot; + auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); + auto rotangle = anglestart + nrotbkg * anglestep; + auto rotkaonPx = track1.px() * std::cos(rotangle) - track1.py() * std::sin(rotangle); + auto rotkaonPy = track1.px() * std::sin(rotangle) + track1.py() * std::cos(rotangle); + kaonrot = ROOT::Math::PxPyPzMVector(rotkaonPx, rotkaonPy, track1.pz(), massKa); + kstarrot = kaonrot + daughter2; + + if (std::abs(kstarrot.Rapidity()) > 0.9) { + continue; + } + + auto uxrot = std::cos(getPhiInRange(KstarMother.Phi())); + auto uyrot = std::sin(getPhiInRange(KstarMother.Phi())); + + auto v1rot = uxrot * (qxZDCA - qxZDCC) + uyrot * (qyZDCA - qyZDCC); + + histos.fill(HIST("hpv1vscentptetarot"), kstarrot.M(), centrality, kstarrot.Pt(), kstarrot.Rapidity(), v1rot); + } + } + } + // like sign + if (track1.sign() * track2.sign() > 0) { + histos.fill(HIST("hpv1vscentptetalike"), kstarrot.M(), centrality, kstarrot.Pt(), kstarrot.Rapidity(), v1); + } + } + } + } + PROCESS_SWITCH(KstarFlowv1, processSE, "Process Same event", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Resonances/kstarInOO.cxx b/PWGLF/Tasks/Resonances/kstarInOO.cxx new file mode 100644 index 00000000000..dc70ae02010 --- /dev/null +++ b/PWGLF/Tasks/Resonances/kstarInOO.cxx @@ -0,0 +1,440 @@ +// 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. + +/// \file kstarInOO.cxx +/// \brief the pT spectra of k*0(892) resonance analysis in OO collisions +/// \author Jimun Lee + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "ReconstructionDataFormats/Track.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct kstarInOO { + SliceCache cache; + Preslice perCollision = aod::track::collisionId; + HistogramRegistry OOhistos{"OOhistos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + //================================== + //|| + //|| Selection + //|| + //================================== + + // Event Selection + Configurable cfg_Event_Selections{"cfg_Event_Selections", "sel8", "choose event selection"}; + Configurable cfg_Event_VtxCut{"cfg_Event_VtxCut", 10.0, "V_z cut selection"}; + + ConfigurableAxis cfg_CentAxis{"cfg_CentAxis", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; + + // Track Selection + // General + Configurable cfg_Track_Selections{"cfg_Track_Selections", "globalTracks", "set track selections"}; + Configurable cfg_Track_MinPt{"cfg_Track_MinPt", 0.15, "set track min pT"}; + Configurable cfg_Track_MaxEta{"cfg_Track_MaxEta", 0.9, "set track max Eta"}; + Configurable cfg_Track_MaxDCArToPVcut{"cfg_Track_MaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; + Configurable cfg_Track_MaxDCAzToPVcut{"cfg_Track_MaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; + Configurable cfg_Track_PrimaryTrack{"cfg_Track_PrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfg_Track_ConnectedToPV{"cfg_Track_ConnectedToPV", true, "PV contributor track selection"}; // PV Contriuibutor + Configurable cfg_Track_GlobalWoDCATrack{"cfg_Track_GlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + // TPC + Configurable cfg_Track_nFindableTPCClusters{"cfg_Track_FindableTPCClusters", 50, "nFindable TPC Clusters"}; + Configurable cfg_Track_nTPCCrossedRows{"cfg_Track_TPCCrossedRows", 70, "nCrossed TPC Rows"}; + Configurable cfg_Track_nRowsOverFindable{"cfg_Track_RowsOverFindable", 1.2, "nRowsOverFindable TPC CLusters"}; + Configurable cfg_Track_nTPCChi2{"cfg_Track_TPCChi2", 4.0, "nTPC Chi2 per Cluster"}; + + // ITS + Configurable cfg_Track_nITSChi2{"cfg_Track_ITSChi2", 36.0, "nITS Chi2 per Cluster"}; + + // PID + Configurable cfg_Track_TPCPID{"cfg_Track_TPCPID", true, "Enables TPC PID"}; + Configurable cfg_Track_TOFPID{"cfg_Track_TOFPID", true, "Enables TOF PID"}; + Configurable cfg_Track_TPCPID_nSig{"cfg_Track_TPCPID_nSig", 4.0, "nTPC PID sigma"}; + Configurable cfg_Track_TOFPID_nSig{"cfg_Track_TOFPID_nSig", 4.0, "nTOF PID sigma"}; + Configurable cDebugLevel{"cDebugLevel", 0, "Resolution of Debug"}; + + // Mixing + ConfigurableAxis cfg_bins_MixMult{"cfg_bins_Cent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; + ConfigurableAxis cfg_bins_MixVtx{"cfg_bins_MixVtx", {VARIABLE_WIDTH, -10.0f, -5.f, 0.f, 5.f, 10.f}, "Mixing bins - z-vertex"}; + Configurable cfg_Mix_NMixedEvents{"cfg_Mix_NMixedEvents", 10, "Number of mixed events per event"}; + + // Pair + Configurable cfg_MinvNBins{"cfg_MinvNBins", 300, "Number of bins for Minv axis"}; + Configurable cfg_MinvMin{"cfg_MinvMin", 0.60, "Minimum Minv value"}; + Configurable cfg_MinvMax{"cfg_MinvMax", 1.20, "Maximum Minv value"}; + + // Histogram + Configurable cfg_Event_CutQA{"cfg_Event_CutsQA", false, "Enable Event QA Hists"}; + Configurable cfg_Track_CutQA{"cfg_Track_CutQA", false, "Enable Track QA Hists"}; + + // std::vector eventSelectionBits; + + void init(o2::framework::InitContext&) + { + // HISTOGRAMS + const AxisSpec axisEta{30, -1.5, +1.5, "#eta"}; + const AxisSpec axisPhi{200, -1, +7, "#phi"}; + const AxisSpec PtAxis = {200, 0, 20.0}; + const AxisSpec PIDAxis = {120, -6, 6}; + const AxisSpec MinvAxis = {cfg_MinvNBins, cfg_MinvMin, cfg_MinvMax}; + + if (cfg_Event_CutQA) { + OOhistos.add("hPosZ_BC", "PosZ_Bc", kTH1F, {{100, 0.0, 15.0}}); + OOhistos.add("hPosZ_AC", "PosZ_AC", kTH1F, {{100, 0.0, 15.0}}); + } + + if (cfg_Track_CutQA) { + OOhistos.add("h_rawpT", "h_rawpT", kTH1F, {{1000, 0.0, 10.0}}); + OOhistos.add("h_rawpT_Kaon", "h_rawpT_Kaon", kTH1F, {{1000, 0.0, 10.0}}); + OOhistos.add("h_rawpT_Pion", "h_rawpT_Pion", kTH1F, {{1000, 0.0, 10.0}}); + OOhistos.add("h_eta", "h_eta", kTH1F, {axisEta}); + OOhistos.add("h_phi", "h_phi", kTH1F, {axisPhi}); + + OOhistos.add("QA_nSigma_pion_TPC", "QA_nSigma_pion_TPC", {HistType::kTH2F, {PtAxis, PIDAxis}}); + OOhistos.add("QA_nSigma_pion_TOF", "QA_nSigma_pion_TOF", {HistType::kTH2F, {PtAxis, PIDAxis}}); + OOhistos.add("QA_pion_TPC_TOF", "QA_pion_TPC_TOF", {HistType::kTH2F, {PIDAxis, PIDAxis}}); + OOhistos.add("QA_nSigma_kaon_TPC", "QA_nSigma_kaon_TPC", {HistType::kTH2F, {PtAxis, PIDAxis}}); + OOhistos.add("QA_nSigma_kaon_TOF", "QA_nSigma_kaon_TOF", {HistType::kTH2F, {PtAxis, PIDAxis}}); + OOhistos.add("QA_kaon_TPC_TOF", "QA_kaon_TPC_TOF", {HistType::kTH2F, {PIDAxis, PIDAxis}}); + } + + // MC histos + OOhistos.add("hMC_USS", "hMC_USS", kTHnSparseF, {cfg_CentAxis, PtAxis, MinvAxis}); + OOhistos.add("hMC_LSS", "hMC_LSS", kTHnSparseF, {cfg_CentAxis, PtAxis, MinvAxis}); + OOhistos.add("hMC_USS_Mix", "hMC_USS_Mix", kTHnSparseF, {cfg_CentAxis, PtAxis, MinvAxis}); + OOhistos.add("hMC_LSS_Mix", "hMC_LSS_Mix", kTHnSparseF, {cfg_CentAxis, PtAxis, MinvAxis}); + + // OOhistos.add("hMC_pt_Pion", "hMC_pt_Pion", kTH1F, {PtAxis}); + // OOhistos.add("hMC_pt_Kaon", "hMC_pt_Kaon", kTH1F, {PtAxis}); + // OOhistos.add("hMC_pt_Proton", "hMC_pt_Proton", kTH1F, {PtAxis}); + + // Event Histograms + OOhistos.add("nEvents_MC", "nEvents_MC", kTH1F, {{4, 0.0, 4.0}}); + OOhistos.add("nEvents_MC_Mix", "nEvents_MC_Mix", kTH1F, {{4, 0.0, 4.0}}); + + } // end of init + + using EventCandidates = soa::Join; //, aod::CentFT0Ms, aod::CentFT0As + using TrackCandidates = soa::Join; + using TrackCandidates_MC = soa::Join; + + // For Mixed Event + using BinningType = ColumnBinningPolicy; + + Partition Kaon_MC = nabs(aod::pidtpc::tpcNSigmaKa) <= cfg_Track_TPCPID_nSig; + Partition Pion_MC = nabs(aod::pidtpc::tpcNSigmaPi) <= cfg_Track_TPCPID_nSig; + + double massKa = o2::constants::physics::MassKPlus; + double massPi = o2::constants::physics::MassPiMinus; + + //================================== + //|| + //|| Helper Templates + //|| + //================================== + template + bool eventSelection(const EventType event) + { + if (!event.sel8()) + return false; + if (std::abs(event.posZ()) > cfg_Event_VtxCut) + return false; + if (!event.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) + return false; + if (!event.selection_bit(aod::evsel::kNoSameBunchPileup)) + return false; + if (!event.selection_bit(aod::evsel::kNoTimeFrameBorder)) + return false; + if (!event.selection_bit(aod::evsel::kNoITSROFrameBorder)) + return false; + if (!event.selection_bit(aod::evsel::kNoCollInTimeRangeStandard)) + return false; + + return true; + }; + + template + bool trackSelection(const TracksType track) + { + if (track.pt() < cfg_Track_MinPt) + return false; + + if (std::abs(track.eta()) > cfg_Track_MaxEta) + return false; + + if (std::abs(track.dcaXY()) > cfg_Track_MaxDCArToPVcut) + return false; + + if (std::abs(track.dcaZ()) > cfg_Track_MaxDCAzToPVcut) + return false; + + if (cfg_Track_PrimaryTrack && !track.isPrimaryTrack()) + return false; + + if (cfg_Track_GlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + + if (track.tpcNClsFindable() < cfg_Track_nFindableTPCClusters) + return false; + + if (track.tpcNClsCrossedRows() < cfg_Track_nTPCCrossedRows) + return false; + + if (track.tpcCrossedRowsOverFindableCls() > cfg_Track_nRowsOverFindable) + return false; + + if (track.tpcChi2NCl() > cfg_Track_nTPCChi2) + return false; + + if (track.itsChi2NCl() > cfg_Track_nITSChi2) + return false; + + if (cfg_Track_ConnectedToPV && !track.isPVContributor()) + return false; + + return true; + }; + + template + bool trackPIDKaon(const TrackPID& candidate) + { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + // TPC + if (cfg_Track_CutQA) { + OOhistos.fill(HIST("QA_nSigma_kaon_TPC"), candidate.pt(), candidate.tpcNSigmaKa()); + OOhistos.fill(HIST("QA_nSigma_kaon_TOF"), candidate.pt(), candidate.tofNSigmaKa()); + OOhistos.fill(HIST("QA_kaon_TPC_TOF"), candidate.tpcNSigmaKa(), candidate.tofNSigmaKa()); + } + if (std::abs(candidate.tpcNSigmaKa()) < cfg_Track_TPCPID_nSig) + tpcPIDPassed = true; + + // TOF + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaKa()) < cfg_Track_TOFPID_nSig) + tofPIDPassed = true; + else + tofPIDPassed = true; + } + + // TPC & TOF + if (tpcPIDPassed && tofPIDPassed) + return true; + + return false; + } + + template + bool trackPIDPion(const TrackPID& candidate) + { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + // TPC + if (cfg_Track_CutQA) { + OOhistos.fill(HIST("QA_nSigma_pion_TPC"), candidate.pt(), candidate.tpcNSigmaPi()); + OOhistos.fill(HIST("QA_nSigma_pion_TOF"), candidate.pt(), candidate.tofNSigmaPi()); + OOhistos.fill(HIST("QA_pion_TPC_TOF"), candidate.tpcNSigmaPi(), candidate.tofNSigmaPi()); + } + + if (std::abs(candidate.tpcNSigmaPi()) < cfg_Track_TPCPID_nSig) + tpcPIDPassed = true; + + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaPi()) < cfg_Track_TOFPID_nSig) + tofPIDPassed = true; + else + tofPIDPassed = true; + } + + // TPC & TOF + if (tpcPIDPassed && tofPIDPassed) + return true; + + return false; + } + + template + void TrackSlicing_MC(const CollisionType& collision1, const TracksType&, const CollisionType& collision2, const TracksType&, const bool IsMix) + { + auto tracks1 = Kaon_MC->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto tracks2 = Pion_MC->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + auto centrality = collision1.centFT0C(); + + for (auto& [trk1, trk2] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + auto [KstarPt, Minv] = minvReconstruction(trk1, trk2); + if (Minv < 0) + continue; + + double conjugate = trk1.sign() * trk2.sign(); + if (!IsMix) { + if (conjugate < 0) { + OOhistos.fill(HIST("hMC_USS"), centrality, KstarPt, Minv); + } else if (conjugate > 0) { + OOhistos.fill(HIST("hMC_LSS"), centrality, KstarPt, Minv); + } + } else { + if (conjugate < 0) { + OOhistos.fill(HIST("hMC_USS_Mix"), centrality, KstarPt, Minv); + } else if (conjugate > 0) { + OOhistos.fill(HIST("hMC_LSS_Mix"), centrality, KstarPt, Minv); + } + } + } + } + + template + std::pair minvReconstruction(const TracksType& trk1, const TracksType& trk2) + { + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + + if (!trackSelection(trk1) || !trackSelection(trk2)) + return {-1.0, -1.0}; + if (!trackPIDKaon(trk1) || !trackPIDPion(trk2)) + return {-1.0, -1.0}; + + if (trk1.globalIndex() == trk2.globalIndex()) { + // std::cout<<"This happens"< cfg_Track_MaxEta) + return {-1.0, -1.0}; + + return {lResonance.Pt(), lResonance.M()}; + } + + //======================================================= + //| + //| MC STUFF (SE) + //| + //======================================================= + + int nEvents_MC = 0; + void processSameEvent_MC(EventCandidates::iterator const& collision, TrackCandidates_MC const& tracks, aod::McParticles const&) + { + if (cDebugLevel > 0) { + nEvents_MC++; + if ((nEvents_MC + 1) % 10000 == 0) { + double histmem = OOhistos.getSize(); + std::cout << histmem << std::endl; + std::cout << "process_SameEvent_MC: " << nEvents_MC << std::endl; + } + } + + auto goodEv = eventSelection(collision); + OOhistos.fill(HIST("nEvents_MC"), 0.5); + if (!goodEv) + return; + + bool INELgt0 = false; + for (const auto& track : tracks) { + if (std::fabs(track.eta()) < cfg_Track_MaxEta) { + INELgt0 = true; + break; + } + } + if (!INELgt0) + return; + + OOhistos.fill(HIST("nEvents_MC"), 1.5); + TrackSlicing_MC(collision, tracks, collision, tracks, false); + + } // processSameEvents_MC + PROCESS_SWITCH(kstarInOO, processSameEvent_MC, "process Same Event MC", true); + + //======================================================= + //| + //| MC STUFF (ME) + //| + //======================================================= + + int nEvents_MC_Mix = 0; + void processMixedEvent_MC(EventCandidates const& collisions, TrackCandidates_MC const& tracks, aod::McParticles const&) + { + auto tracksTuple = std::make_tuple(tracks); + BinningType colBinning{{cfg_bins_MixVtx, cfg_bins_MixMult}, true}; // true is for 'ignore overflows' (true by default) + SameKindPair pairs{colBinning, cfg_Mix_NMixedEvents, -1, collisions, tracksTuple, &cache}; + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + if (cDebugLevel > 0) { + nEvents_MC_Mix++; + if ((nEvents_MC_Mix + 1) % 10000 == 0) { + std::cout << "Processed Mixed Events: " << nEvents_MC_Mix << std::endl; + } + } + auto goodEv1 = eventSelection(collision1); + auto goodEv2 = eventSelection(collision2); + OOhistos.fill(HIST("nEvents_MC_Mix"), 0.5); + + if (!goodEv1 || !goodEv2) + continue; + + OOhistos.fill(HIST("nEvents_MC_Mix"), 1.5); + + TrackSlicing_MC(collision1, tracks1, collision2, tracks2, true); + } // mixing + } // processMixedEvent_MC + PROCESS_SWITCH(kstarInOO, processMixedEvent_MC, "process Mixed Event MC", false); + + void processEventsDummy(EventCandidates::iterator const&, TrackCandidates const&) + { + return; + } + PROCESS_SWITCH(kstarInOO, processEventsDummy, "dummy", false); + +}; // kstarInOO + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +}; diff --git a/PWGLF/Tasks/Resonances/kstarpbpb.cxx b/PWGLF/Tasks/Resonances/kstarpbpb.cxx index 1a433a1fc6b..e650e1f8d91 100644 --- a/PWGLF/Tasks/Resonances/kstarpbpb.cxx +++ b/PWGLF/Tasks/Resonances/kstarpbpb.cxx @@ -10,68 +10,85 @@ // or submit itself to any jurisdiction. // sourav.kundu@cern.ch , sarjeeta.gami@cern.ch -#include +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGMM/Mult/DataModel/Index.h" // for Particles2Tracks table + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TRandom3.h" #include +#include +#include +#include #include #include #include #include -#include -#include -#include #include -#include -#include -#include -#include + #include +#include #include - -#include "TRandom3.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" -#include "TF1.h" - -#include "PWGLF/DataModel/EPCalibrationTables.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/Core/TrackSelection.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using std::array; +using namespace o2::aod::rctsel; struct kstarpbpb { - int mRunNumber; - int multEstimator; - float d_bz; + struct : ConfigurableGroup { + Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; + } cfgCcdbParam; + + // Enable access to the CCDB for the offset and correction constants and save them in dedicated variables. Service ccdb; - Service pdg; + o2::ccdb::CcdbApi ccdbApi; + // Service pdg; + struct RCTCut : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + + RCTFlagsChecker rctChecker; + }; + + RCTCut rctCut; // CCDB options - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + // Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + // Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + // Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + // Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + // Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; // events Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; @@ -85,8 +102,10 @@ struct kstarpbpb { Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; Configurable useGlobalTrack{"useGlobalTrack", true, "use Global track"}; + Configurable usepolar{"usepolar", true, "flag to fill type of SA"}; Configurable nsigmaCutTOF{"nsigmacutTOF", 3.0, "Value of the TOF Nsigma cut"}; Configurable nsigmaCutTPC{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"}; + Configurable isTOFOnly{"isTOFOnly", false, "use TOF only PID"}; Configurable nsigmaCutCombined{"nsigmaCutCombined", 3.0, "Value of the TOF Nsigma cut"}; Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 1, "Number of mixed events per event"}; Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; @@ -95,16 +114,17 @@ struct kstarpbpb { ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {180, 0.6, 1.5}, "#it{M} (GeV/#it{c}^{2})"}; ConfigurableAxis configThnAxisPt{"configThnAxisPt", {100, 0.0, 10.}, "#it{p}_{T} (GeV/#it{c})"}; ConfigurableAxis configThnAxisCentrality{"configThnAxisCentrality", {8, 0., 80}, "Centrality"}; + ConfigurableAxis configrapAxis{"configrapAxis", {VARIABLE_WIDTH, -0.8, -0.4, 0.4, 0.8}, "Rapidity"}; Configurable removefaketrak{"removefaketrack", true, "Remove fake track from momentum difference"}; Configurable ConfFakeKaonCut{"ConfFakeKaonCut", 0.1, "Cut based on track from momentum difference"}; - ConfigurableAxis configThnAxisPhiminusPsi{"configThnAxisPhiminusPsi", {6, 0.0, TMath::Pi()}, "#phi - #psi"}; - ConfigurableAxis configThnAxisV2{"configThnAxisV2", {200, -1, 1}, "V2"}; + ConfigurableAxis configThnAxisV2{"configThnAxisV2", {400, -16, 16}, "V2"}; Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; + Configurable additionalEvselITS{"additionalEvselITS", true, "Additional event selcection for ITS"}; Configurable ispTdepPID{"ispTdepPID", true, "pT dependent PID"}; - Configurable OnlyTOF{"OnlyTOF", true, "OnlyTOF"}; + Configurable isNoTOF{"isNoTOF", true, "isNoTOF"}; + Configurable PDGcheck{"PDGcheck", true, "PDGcheck"}; Configurable strategyPID{"strategyPID", 2, "PID strategy"}; - Configurable isGI{"isGI", false, "pT dependent PID"}; Configurable cfgCutTOFBeta{"cfgCutTOFBeta", 0.0, "cut TOF beta"}; Configurable additionalQAplots{"additionalQAplots", true, "Additional QA plots"}; Configurable additionalQAplots1{"additionalQAplots1", true, "Additional QA plots"}; @@ -112,10 +132,17 @@ struct kstarpbpb { Configurable confMaxRot{"confMaxRot", 7.0 * TMath::Pi() / 6.0, "Maximum of rotation"}; Configurable nBkgRotations{"nBkgRotations", 9, "Number of rotated copies (background) per each original candidate"}; Configurable fillRotation{"fillRotation", true, "fill rotation"}; - Configurable like{"like", true, "fill rotation"}; + Configurable same{"same", true, "same event"}; + Configurable like{"like", false, "like-sign"}; + Configurable fillSA{"fillSA", true, "same event SA"}; Configurable fillOccupancy{"fillOccupancy", false, "fill Occupancy"}; Configurable cfgOccupancyCut{"cfgOccupancyCut", 500, "Occupancy cut"}; - Configurable useSP{"useSP", true, "useSP"}; + Configurable useWeight{"useWeight", false, "use EP dep effi weight"}; + Configurable useSP{"useSP", false, "use SP"}; + Configurable genacceptancecut{"genacceptancecut", true, "use acceptance cut for generated"}; + Configurable avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"}; + Configurable ConfWeightPath{"ConfWeightPath", "Users/s/skundu/My/Object/fitweight", "Path to gain calibration"}; + ConfigurableAxis axisPtKaonWeight{"axisPtKaonWeight", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f}, "pt axis"}; Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter centralityFilter = nabs(aod::cent::centFT0C) < cfgCutCentrality; @@ -125,9 +152,17 @@ struct kstarpbpb { using EventCandidates = soa::Filtered>; using TrackCandidates = soa::Filtered>; + using CollisionMCTrueTable = aod::McCollisions; + using TrackMCTrueTable = aod::McParticles; + using CollisionMCRecTableCentFT0C = soa::SmallGroups>; + using TrackMCRecTable = soa::Join; + using FilTrackMCRecTable = soa::Filtered; + + Preslice perCollision = aod::track::collisionId; + SliceCache cache; - Partition posTracks = aod::track::signed1Pt > cfgCutCharge; - Partition negTracks = aod::track::signed1Pt < cfgCutCharge; + // Partition posTracks = aod::track::signed1Pt > cfgCutCharge; + // Partition negTracks = aod::track::signed1Pt < cfgCutCharge; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -140,27 +175,60 @@ struct kstarpbpb { void init(o2::framework::InitContext&) { + rctCut.rctChecker.init( + rctCut.cfgEvtRCTFlagCheckerLabel, + rctCut.cfgEvtRCTFlagCheckerZDCCheck, + rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + std::vector occupancyBinning = {0.0, 500.0, 1000.0, 1500.0, 2000.0, 3000.0, 4000.0, 5000.0, 50000.0}; - const AxisSpec thnAxisInvMass{configThnAxisInvMass, "#it{M} (GeV/#it{c}^{2})"}; - const AxisSpec thnAxisPt{configThnAxisPt, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec thnAxisPhiminusPsi{configThnAxisPhiminusPsi, "#phi - #psi"}; - const AxisSpec thnAxisCentrality{configThnAxisCentrality, "Centrality (%)"}; - const AxisSpec thnAxisV2{configThnAxisV2, "V2"}; AxisSpec phiAxis = {500, -6.28, 6.28, "phi"}; - AxisSpec resAxis = {400, -2, 2, "Res"}; + AxisSpec resAxis = {6000, -30, 30, "Res"}; AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; AxisSpec occupancyAxis = {occupancyBinning, "Occupancy"}; + histos.add("hEvtSelInfo", "hEvtSelInfo", kTH1F, {{10, 0, 10.0}}); + if (!fillSA) { + if (same) { + histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configThnAxisCentrality}); + } + if (like) { + histos.add("hSparseV2SAlikeEventNN_V2", "hSparseV2SAlikeEventNN_V2", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configThnAxisCentrality}); + histos.add("hSparseV2SAlikeEventPP_V2", "hSparseV2SAlikeEventPP_V2", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configThnAxisCentrality}); + } + } + if (fillRotation) { + if (!fillSA) { + histos.add("hRotation", "hRotation", kTH1F, {{360, 0.0, 2.0 * TMath::Pi()}}); + histos.add("hSparseV2SASameEventRotational_V2", "hSparseV2SASameEventRotational_V2", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configThnAxisCentrality}); + } + } - histos.add("hpTvsRapidity", "pT vs Rapidity", kTH2F, {{100, 0.0f, 10.0f}, {300, -1.5f, 1.5f}}); - histos.add("TPC_Nsigma_pi", "TPC_Nsigma_pi", kTH2F, {{60, 0.0f, 6.0f}, {500, -5, 5}}); - histos.add("TPC_Nsigma_ka", "TPC_Nsigma_ka", kTH2F, {{60, 0.0f, 6.0f}, {500, -5, 5}}); - histos.add("TOF_Nsigma_pi", "TOF_Nsigma_pi", kTH2F, {{60, 0.0f, 6.0f}, {500, -5, 5}}); - histos.add("TOF_Nsigma_ka", "TOF_Nsigma_ka", kTH2F, {{60, 0.0f, 6.0f}, {500, -5, 5}}); - histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2SAlikeEventNN_V2", "hSparseV2SAlikeEventNN_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2SAlikeEventPP_V2", "hSparseV2SAlikeEventPP_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2SASameEventRotational_V2", "hSparseV2SASameEventRotational_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + if (fillSA) { + histos.add("hSparseSAvsrapsameunlike", "hSparseSAvsrapsameunlike", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configrapAxis, configThnAxisCentrality}, true); + histos.add("hSparseSAvsrapsamelike", "hSparseSAvsrapsamelike", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configrapAxis, configThnAxisCentrality}, true); + histos.add("hSparseSAvsraprot", "hSparseSAvsraprot", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configrapAxis, configThnAxisCentrality}, true); + histos.add("hSparseSAvsrapmix", "hSparseSAvsrapmix", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configrapAxis, configThnAxisCentrality}, true); + } + if (!fillSA) { + histos.add("hSparseV2SAGen_V2", "hSparseV2SAGen_V2", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configThnAxisCentrality}); + histos.add("hSparseV2SARec_V2", "hSparseV2SARec_V2", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configThnAxisCentrality}); + histos.add("hpt", "hpt", kTH1F, {configThnAxisPt}); + histos.add("hMC", "MC Event statistics", kTH1F, {{10, 0.0f, 10.0f}}); + histos.add("h1PhiRecsplit", "Phi meson Rec split", kTH1F, {{100, 0.0f, 10.0f}}); + histos.add("CentPercentileMCRecHist", "MC Centrality", kTH1F, {{100, 0.0f, 100.0f}}); + histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configThnAxisCentrality}); + histos.add("h2PhiGen2", "Phi meson gen", kTH2F, {configThnAxisPt, configThnAxisCentrality}); + histos.add("h2PhiRec2", "Phi meson Rec", kTH2F, {configThnAxisPt, configThnAxisCentrality}); + histos.add("hImpactParameter", "Impact parameter", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hEventPlaneAngle", "hEventPlaneAngle", kTH1F, {{200, -2.0f * TMath::Pi(), 2.0f * TMath::Pi()}}); + histos.add("hSparseKstarMCGenWeight", "hSparseKstarMCGenWeight", HistType::kTHnSparseD, {configThnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, 0.0f, 1}, configThnAxisPt, {8, -0.8, 0.8}}); + histos.add("hSparseKstarMCRecWeight", "hSparseKstarMCRecWeight", HistType::kTHnSparseD, {configThnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, 0.0f, 1}, configThnAxisPt, {8, -0.8, 0.8}}); + histos.add("hSparseKstarMCGenKaonWeight", "hSparseKstarMCGenKaonWeight", HistType::kTHnSparseD, {configThnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, 0.0f, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + histos.add("hSparseKstarMCRecKaonWeight", "hSparseKstarMCRecKaonWeight", HistType::kTHnSparseD, {configThnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, 0.0f, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + histos.add("hSparseKstarMCRecKaonMissMatchWeight", "hSparseKstarMCRecKaonMissMatchWeight", HistType::kTHnSparseD, {configThnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, 0.0f, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + histos.add("hSparseKstarMCGenPionWeight", "hSparseKstarMCGenPionWeight", HistType::kTHnSparseD, {configThnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, 0.0f, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + histos.add("hSparseKstarMCRecPionWeight", "hSparseKstarMCRecPionWeight", HistType::kTHnSparseD, {configThnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, 0.0f, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + histos.add("hSparseKstarMCRecPionMissMatchWeight", "hSparseKstarMCRecPionMissMatchWeight", HistType::kTHnSparseD, {configThnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, 0.0f, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + } if (additionalQAplots1) { histos.add("hFTOCvsTPCSelected", "Mult correlation FT0C vs. TPC after selection", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); histos.add("hCentrality", "Centrality distribution", kTH1F, {{200, 0.0, 200.0}}); @@ -175,39 +243,41 @@ struct kstarpbpb { histos.add("ResFT0CTPCSP", "ResFT0CTPCSP", kTH2F, {centAxis, resAxis}); histos.add("ResFT0CFT0ASP", "ResFT0CFT0ASP", kTH2F, {centAxis, resAxis}); histos.add("ResFT0ATPCSP", "ResFT0ATPCSP", kTH2F, {centAxis, resAxis}); + histos.add("ResTrackSPFT0CTPC", "ResTrackSPFT0CTPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResTrackSPFT0CFT0A", "ResTrackSPFT0CFT0A", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResTrackSPFT0ATPC", "ResTrackSPFT0ATPC", kTH3F, {centAxis, occupancyAxis, resAxis}); } if (additionalQAplots) { // DCA QA - histos.add("QAbefore/trkDCAxyka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); - histos.add("QAbefore/trkDCAzka", "DCAz distribution of kaon track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); - histos.add("QAafter/trkDCAxyka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); - histos.add("QAafter/trkDCAzka", "DCAz distribution of kaon track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); + histos.add("QAbefore/trkDCAxyka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAbefore/trkDCAzka", "DCAz distribution of kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAafter/trkDCAxyka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAafter/trkDCAzka", "DCAz distribution of kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + // PID QA before cuts histos.add("QAbefore/TOF_TPC_Mapka_allka", "TOF + TPC Combined PID for Kaon;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); - histos.add("QAbefore/TOF_Nsigma_allka", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); - histos.add("QAbefore/TPC_Nsigma_allka", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); + histos.add("QAbefore/TOF_Nsigma_allka", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3D, {{200, 0.0, 20.0}, {100, -6, 6}, {100, 0.0, 100.0}}}); + histos.add("QAbefore/TPC_Nsigma_allka", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3D, {{200, 0.0, 20.0}, {100, -6, 6}, {100, 0.0, 100.0}}}); // PID QA after cuts histos.add("QAafter/TOF_TPC_Mapka_allka", "TOF + TPC Combined PID for Kaon;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); - histos.add("QAafter/TOF_Nsigma_allka", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); - histos.add("QAafter/TPC_Nsigma_allka", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); + histos.add("QAafter/TOF_Nsigma_allka", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3D, {{200, 0.0, 20.0}, {100, -6, 6}, {100, 0.0, 100.0}}}); + histos.add("QAafter/TPC_Nsigma_allka", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3D, {{200, 0.0, 20.0}, {100, -6, 6}, {100, 0.0, 100.0}}}); // DCA QA - histos.add("QAbefore/trkDCAxypi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); - histos.add("QAbefore/trkDCAzpi", "DCAz distribution of pion track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); - histos.add("QAafter/trkDCAxypi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); - histos.add("QAafter/trkDCAzpi", "DCAz distribution of pion track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); + histos.add("QAbefore/trkDCAxypi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAbefore/trkDCAzpi", "DCAz distribution of pion track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAafter/trkDCAxypi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAafter/trkDCAzpi", "DCAz distribution of pion track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); // PID QA before cuts histos.add("QAbefore/TOF_TPC_Mapka_allpi", "TOF + TPC Combined PID for pion;#sigma_{TOF}^{pion};#sigma_{TPC}^{pion}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); - histos.add("QAbefore/TOF_Nsigma_allpi", "TOF NSigma for pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{pion};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); - histos.add("QAbefore/TPC_Nsigma_allpi", "TPC NSigma for pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{pion};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); + histos.add("QAbefore/TOF_Nsigma_allpi", "TOF NSigma for pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{pion};", {HistType::kTH3D, {{200, 0.0, 20.0}, {100, -6, 6}, {100, 0.0, 100.0}}}); + histos.add("QAbefore/TPC_Nsigma_allpi", "TPC NSigma for pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{pion};", {HistType::kTH3D, {{200, 0.0, 20.0}, {100, -6, 6}, {100, 0.0, 100.0}}}); // PID QA after cuts histos.add("QAafter/TOF_TPC_Mapka_allpi", "TOF + TPC Combined PID for pion;#sigma_{TOF}^{pion};#sigma_{TPC}^{pion}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); - histos.add("QAafter/TOF_Nsigma_allpi", "TOF NSigma for pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{pion};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); - histos.add("QAafter/TPC_Nsigma_allpi", "TPC NSigma for pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{pion};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); - } - if (fillRotation) { - histos.add("hRotation", "hRotation", kTH1F, {{360, 0.0, 2.0 * TMath::Pi()}}); + histos.add("QAafter/TOF_Nsigma_allpi", "TOF NSigma for pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{pion};", {HistType::kTH3D, {{200, 0.0, 20.0}, {100, -6, 6}, {100, 0.0, 100.0}}}); + histos.add("QAafter/TPC_Nsigma_allpi", "TPC NSigma for pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{pion};", {HistType::kTH3D, {{200, 0.0, 20.0}, {100, -6, 6}, {100, 0.0, 100.0}}}); } + // Event selection cut additional - Alex if (additionalEvsel) { fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); @@ -221,6 +291,11 @@ struct kstarpbpb { fMultMultPVCut = new TF1("fMultMultPVCut", "[0]+[1]*x+[2]*x*x", 0, 5000); fMultMultPVCut->SetParameters(-0.1, 0.785, -4.7e-05); } + ccdb->setURL(cfgCcdbParam.cfgURL); + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); } double massKa = o2::constants::physics::MassKPlus; @@ -263,44 +338,64 @@ struct kstarpbpb { bool selectionPIDNew(const T& candidate, int PID) { if (PID == 0) { - if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > cfgCutTOFBeta) { return true; } - if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && !candidate.hasTOF()) { return true; } } else if (PID == 1) { - if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { + if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { return true; } - if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF) { + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF && candidate.beta() > cfgCutTOFBeta) { + return true; + } + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && !candidate.hasTOF()) { + return true; + } + } + return false; + } + template + bool selectionPID2(const T& candidate, int PID) + { + if (PID == 0) { + if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { + return true; + } + } + if (PID == 1) { + if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF) { return true; } } return false; } - template bool selectionPID(const T& candidate, int PID) { if (PID == 0) { - if (!OnlyTOF && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (!isNoTOF && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { return true; } - if (!OnlyTOF && candidate.hasTOF() && ((candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) + (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa())) < (nsigmaCutCombined * nsigmaCutCombined)) { + if (!isNoTOF && candidate.hasTOF() && ((candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) + (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa())) < (nsigmaCutCombined * nsigmaCutCombined)) { return true; } - if (OnlyTOF && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { + if (isNoTOF && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { return true; } } else if (PID == 1) { - if (!OnlyTOF && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { + if (!isNoTOF && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { return true; } - if (!OnlyTOF && candidate.hasTOF() && ((candidate.tofNSigmaPi() * candidate.tofNSigmaPi()) + (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi())) < (nsigmaCutCombined * nsigmaCutCombined)) { + if (!isNoTOF && candidate.hasTOF() && ((candidate.tofNSigmaPi() * candidate.tofNSigmaPi()) + (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi())) < (nsigmaCutCombined * nsigmaCutCombined)) { return true; } - if (OnlyTOF && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF) { + if (isNoTOF && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { return true; } } @@ -312,24 +407,30 @@ struct kstarpbpb { { if (PID == 0) { if (strategy == 0) { - if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (!isNoTOF && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (!isNoTOF && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { return true; } - if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > 0.5) { + if (isNoTOF && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { return true; } } else if (strategy == 1) { if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { return true; } - if (candidate.pt() >= 0.5 && TMath::Sqrt(candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > 0.5) { + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > cfgCutTOFBeta) { + return true; + } + if (!useGlobalTrack && !candidate.hasTPC()) { return true; } } else if (strategy == 2) { if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { return true; } - if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > 0.5) { + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > cfgCutTOFBeta) { return true; } if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && !candidate.hasTOF()) { @@ -339,24 +440,30 @@ struct kstarpbpb { } if (PID == 1) { if (strategy == 0) { - if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { + if (!isNoTOF && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { return true; } - if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF && candidate.beta() > 0.5) { + if (!isNoTOF && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF) { + return true; + } + if (isNoTOF && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { return true; } } else if (strategy == 1) { if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { return true; } - if (candidate.pt() >= 0.5 && TMath::Sqrt(candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + candidate.tofNSigmaPi() * candidate.tofNSigmaPi()) < nsigmaCutTOF && candidate.beta() > 0.5) { + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF && candidate.beta() > cfgCutTOFBeta) { + return true; + } + if (!useGlobalTrack && !candidate.hasTPC()) { return true; } } else if (strategy == 2) { if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { return true; } - if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF && candidate.beta() > 0.5) { + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF && candidate.beta() > cfgCutTOFBeta) { return true; } if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && !candidate.hasTOF()) { @@ -390,17 +497,30 @@ struct kstarpbpb { } ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for bin"}; ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {20, 0, 100}, "multiplicity percentile for bin"}; - ConfigurableAxis axisEPAngle{"axisEPAngle", {9, -TMath::Pi() / 2, TMath::Pi() / 2}, "event plane angle"}; + ConfigurableAxis axisEPAngle{"axisEPAngle", {6, -TMath::Pi() / 2, TMath::Pi() / 2}, "event plane angle"}; + ConfigurableAxis axisOccup{"axisOccup", {20, -0.5, 40000.0}, "occupancy axis"}; double v2, v2Rot; using BinningTypeVertexContributor = ColumnBinningPolicy; - ROOT::Math::PxPyPzMVector KstarMother, daughter1, daughter2, kaonrot, kstarrot; + ROOT::Math::PxPyPzMVector KstarMother, fourVecDauCM, daughter1, daughter2, kaonrot, kstarrot, KaonPlus, PionMinus; + ROOT::Math::XYZVector threeVecDauCM, threeVecDauCMXY, eventplaneVec, eventplaneVecNorm; + ROOT::Math::PxPyPzMVector daughter2rot, fourVecDauCMrot; + ROOT::Math::XYZVector threeVecDauCMrot, threeVecDauCMXYrot; - void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + int currentRunNumber = -999; + int lastRunNumber = -999; + TH2D* hweight; + void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCsWithTimestamps const&) { + histos.fill(HIST("hEvtSelInfo"), 0.5); + if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(collision)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 1.5); if (!collision.sel8() || !collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { return; } + histos.fill(HIST("hEvtSelInfo"), 2.5); auto centrality = collision.centFT0C(); auto multTPC = collision.multNTracksPV(); int occupancy = collision.trackOccupancyInTimeRange(); @@ -410,12 +530,18 @@ struct kstarpbpb { auto QFT0C = collision.qFT0C(); auto QFT0A = collision.qFT0A(); auto QTPC = collision.qTPC(); - if (fillOccupancy && occupancy >= cfgOccupancyCut) { + if (fillOccupancy && occupancy > cfgOccupancyCut) { return; } + histos.fill(HIST("hEvtSelInfo"), 3.5); if (additionalEvsel && !eventSelected(collision, centrality)) { return; } + histos.fill(HIST("hEvtSelInfo"), 4.5); + if (additionalEvselITS && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 5.5); if (additionalQAplots1) { histos.fill(HIST("hFTOCvsTPCSelected"), centrality, multTPC); histos.fill(HIST("hPsiFT0C"), centrality, psiFT0C); @@ -431,19 +557,34 @@ struct kstarpbpb { histos.fill(HIST("hOccupancy"), occupancy); histos.fill(HIST("hVtxZ"), collision.posZ()); } + auto bc = collision.bc_as(); + currentRunNumber = collision.bc_as().runNumber(); + if (useWeight && (currentRunNumber != lastRunNumber)) { + hweight = ccdb->getForTimeStamp(ConfWeightPath.value, bc.timestamp()); + } + lastRunNumber = currentRunNumber; + float weight1 = 1.0; + float weight2 = 1.0; for (auto track1 : tracks) { if (!selectionTrack(track1)) { continue; } bool track1kaon = false; auto track1ID = track1.globalIndex(); - if (!strategySelectionPID(track1, 0, strategyPID)) { + if (!isTOFOnly && !strategySelectionPID(track1, 0, strategyPID)) { + continue; + } + if (isTOFOnly && !selectionPID2(track1, 0)) { continue; } track1kaon = true; - histos.fill(HIST("TPC_Nsigma_ka"), track1.p(), track1.tpcNSigmaKa()); - if (track1.hasTOF()) { - histos.fill(HIST("TOF_Nsigma_ka"), track1.p(), track1.tofNSigmaKa()); + + if (useWeight) { + if (track1.pt() < 10.0 && track1.pt() > 0.15) { + weight1 = 1 + hweight->GetBinContent(hweight->FindBin(centrality, track1.pt() + 0.000005)) * TMath::Cos(2.0 * GetPhiInRange(track1.phi() - psiFT0C)); + } else { + weight1 = 1; + } } for (auto track2 : tracks) { if (!selectionTrack(track2)) { @@ -451,20 +592,38 @@ struct kstarpbpb { } bool track2pion = false; auto track2ID = track2.globalIndex(); - if (!strategySelectionPID(track2, 1, strategyPID)) { + if (!isTOFOnly && !strategySelectionPID(track2, 1, strategyPID)) { continue; } - track2pion = true; - histos.fill(HIST("TPC_Nsigma_pi"), track2.p(), track1.tpcNSigmaPi()); - if (track2.hasTOF()) { - histos.fill(HIST("TOF_Nsigma_pi"), track2.p(), track1.tofNSigmaPi()); + if (isTOFOnly && !selectionPID2(track2, 1)) { + continue; } + track2pion = true; if (track2ID == track1ID) { continue; } if (!track1kaon || !track2pion) { continue; } + if (additionalQAplots) { + histos.fill(HIST("QAafter/TPC_Nsigma_allka"), track1.pt(), track1.tpcNSigmaKa(), centrality); + histos.fill(HIST("QAafter/TOF_Nsigma_allka"), track1.pt(), track1.tofNSigmaKa(), centrality); + histos.fill(HIST("QAafter/trkDCAxyka"), track1.dcaXY()); + histos.fill(HIST("QAafter/trkDCAzka"), track1.dcaZ()); + histos.fill(HIST("QAafter/TOF_TPC_Mapka_allka"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + histos.fill(HIST("QAafter/TOF_TPC_Mapka_allpi"), track2.tofNSigmaPi(), track2.tpcNSigmaPi()); + histos.fill(HIST("QAafter/TPC_Nsigma_allpi"), track2.pt(), track2.tpcNSigmaPi(), centrality); + histos.fill(HIST("QAafter/TOF_Nsigma_allpi"), track2.pt(), track2.tofNSigmaPi(), centrality); + histos.fill(HIST("QAafter/trkDCAxypi"), track2.dcaXY()); + histos.fill(HIST("QAafter/trkDCAzpi"), track2.dcaZ()); + } + if (useWeight) { + if (track2.pt() < 10.0 && track2.pt() > 0.15) { + weight2 = 1 + hweight->GetBinContent(hweight->FindBin(centrality, track2.pt() + 0.000005)) * TMath::Cos(2.0 * GetPhiInRange(track2.phi() - psiFT0C)); + } else { + weight2 = 1; + } + } daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); KstarMother = daughter1 + daughter2; @@ -472,55 +631,110 @@ struct kstarpbpb { continue; } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); + if (useSP) { v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; } if (!useSP) { v2 = TMath::Cos(2.0 * phiminuspsi); } - // unlike sign - if (track1.sign() * track2.sign() < 0) { - histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); - if (fillRotation) { - for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { - auto anglestart = confMinRot; - auto angleend = confMaxRot; - auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); - auto rotangle = anglestart + nrotbkg * anglestep; - histos.fill(HIST("hRotation"), rotangle); - auto rotkaonPx = track1.px() * std::cos(rotangle) - track1.py() * std::sin(rotangle); - auto rotkaonPy = track1.px() * std::sin(rotangle) + track1.py() * std::cos(rotangle); - kaonrot = ROOT::Math::PxPyPzMVector(rotkaonPx, rotkaonPy, track1.pz(), massKa); - kstarrot = kaonrot + daughter2; - if (TMath::Abs(kstarrot.Rapidity()) > confRapidity) { - continue; - } - auto phiminuspsiRot = GetPhiInRange(kstarrot.Phi() - psiFT0C); - if (useSP) { - v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; - } - if (!useSP) { - v2Rot = TMath::Cos(2.0 * phiminuspsiRot); - } - histos.fill(HIST("hSparseV2SASameEventRotational_V2"), kstarrot.M(), kstarrot.Pt(), v2Rot, centrality); + auto totalweight = weight1 * weight2; + if (totalweight <= 0.0000005) { + totalweight = 1.0; + } + if (additionalQAplots1) { + histos.fill(HIST("ResTrackSPFT0CTPC"), centrality, occupancy, QFT0C * QTPC * TMath::Cos(2.0 * (psiFT0C - psiTPC))); + histos.fill(HIST("ResTrackSPFT0CFT0A"), centrality, occupancy, QFT0C * QFT0A * TMath::Cos(2.0 * (psiFT0C - psiFT0A))); + histos.fill(HIST("ResTrackSPFT0ATPC"), centrality, occupancy, QTPC * QFT0A * TMath::Cos(2.0 * (psiTPC - psiFT0A))); + } + if (!fillSA) { + if (same) { + if (useWeight) { + histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality, 1 / totalweight); + } else { + histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); } } } - // like sign - if (track1.sign() * track2.sign() > 0) { - if (track1.sign() > 0 && track2.sign() > 0) { - histos.fill(HIST("hSparseV2SAlikeEventPP_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); + int track1Sign = track1.sign(); + int track2Sign = track2.sign(); + + if (fillSA) { + ROOT::Math::Boost boost{KstarMother.BoostToCM()}; + fourVecDauCM = boost(daughter1); + threeVecDauCM = fourVecDauCM.Vect(); + threeVecDauCMXY = ROOT::Math::XYZVector(threeVecDauCM.X(), threeVecDauCM.Y(), 0.); + eventplaneVec = ROOT::Math::XYZVector(std::cos(2.0 * psiFT0C), std::sin(2.0 * psiFT0C), 0); + eventplaneVecNorm = ROOT::Math::XYZVector(std::sin(2.0 * psiFT0C), -std::cos(2.0 * psiFT0C), 0); + auto cosPhistarminuspsi = GetPhiInRange(fourVecDauCM.Phi() - psiFT0C); + auto SA = TMath::Cos(2.0 * cosPhistarminuspsi); + auto cosThetaStar = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); + + if (track1Sign * track2Sign < 0) { + if (usepolar) { + histos.fill(HIST("hSparseSAvsrapsameunlike"), KstarMother.M(), KstarMother.Pt(), cosThetaStar, KstarMother.Rapidity(), centrality); + } else { + histos.fill(HIST("hSparseSAvsrapsameunlike"), KstarMother.M(), KstarMother.Pt(), SA, KstarMother.Rapidity(), centrality); + } + } else if (track1Sign * track2Sign > 0) { + if (usepolar) { + histos.fill(HIST("hSparseSAvsrapsamelike"), KstarMother.M(), KstarMother.Pt(), cosThetaStar, KstarMother.Rapidity(), centrality); + } else { + histos.fill(HIST("hSparseSAvsrapsamelike"), KstarMother.M(), KstarMother.Pt(), SA, KstarMother.Rapidity(), centrality); + } } - if (track1.sign() < 0 && track2.sign() < 0) { - histos.fill(HIST("hSparseV2SAlikeEventNN_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); + } + if (fillRotation) { + for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { + auto anglestart = confMinRot; + auto angleend = confMaxRot; + auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); + auto rotangle = anglestart + nrotbkg * anglestep; + if (!fillSA) { + histos.fill(HIST("hRotation"), rotangle); + } + auto rotkaonPx = track1.px() * std::cos(rotangle) - track1.py() * std::sin(rotangle); + auto rotkaonPy = track1.px() * std::sin(rotangle) + track1.py() * std::cos(rotangle); + kaonrot = ROOT::Math::PxPyPzMVector(rotkaonPx, rotkaonPy, track1.pz(), massKa); + kstarrot = kaonrot + daughter2; + if (TMath::Abs(kstarrot.Rapidity()) > confRapidity) { + continue; + } + auto phiminuspsiRot = GetPhiInRange(kstarrot.Phi() - psiFT0C); + + if (useSP) { + v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; + } + if (!useSP) { + v2Rot = TMath::Cos(2.0 * phiminuspsiRot); + } + if (!fillSA) { + histos.fill(HIST("hSparseV2SASameEventRotational_V2"), kstarrot.M(), kstarrot.Pt(), v2Rot, centrality); + } + if (fillSA) { + if (track1Sign * track2Sign < 0) { + ROOT::Math::Boost boost{kstarrot.BoostToCM()}; + fourVecDauCMrot = boost(kaonrot); + threeVecDauCMrot = fourVecDauCMrot.Vect(); + threeVecDauCMXYrot = ROOT::Math::XYZVector(threeVecDauCMrot.X(), threeVecDauCMrot.Y(), 0.); + auto cosPhistarminuspsirot = GetPhiInRange(fourVecDauCMrot.Phi() - psiFT0C); + auto SArot = TMath::Cos(2.0 * cosPhistarminuspsirot); + auto cosThetaStarrot = eventplaneVecNorm.Dot(threeVecDauCMrot) / std::sqrt(threeVecDauCMrot.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); + if (usepolar) { + histos.fill(HIST("hSparseSAvsraprot"), kstarrot.M(), kstarrot.Pt(), cosThetaStarrot, kstarrot.Rapidity(), centrality); + } else { + histos.fill(HIST("hSparseSAvsraprot"), kstarrot.M(), kstarrot.Pt(), SArot, kstarrot.Rapidity(), centrality); + } + } + } } } } } } PROCESS_SWITCH(kstarpbpb, processSE, "Process Same event latest", true); - - void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::BCs const&) + /* + void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& , aod::BCsWithTimestamps const&) { if (!collision.sel8()) { return; @@ -540,6 +754,9 @@ struct kstarpbpb { if (additionalEvSel3 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { return; } + if (additionalEvselITS && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } int occupancy = collision.trackOccupancyInTimeRange(); auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); @@ -570,8 +787,8 @@ struct kstarpbpb { continue; } if (additionalQAplots) { - histos.fill(HIST("QAbefore/TPC_Nsigma_allka"), track1.pt(), track1.tpcNSigmaKa()); - histos.fill(HIST("QAbefore/TOF_Nsigma_allka"), track1.pt(), track1.tofNSigmaKa()); + histos.fill(HIST("QAbefore/TPC_Nsigma_allka"), track1.pt(), track1.tpcNSigmaKa(), centrality); + histos.fill(HIST("QAbefore/TOF_Nsigma_allka"), track1.pt(), track1.tofNSigmaKa(), centrality); histos.fill(HIST("QAbefore/trkDCAxyka"), track1.dcaXY()); histos.fill(HIST("QAbefore/trkDCAzka"), track1.dcaZ()); histos.fill(HIST("QAbefore/TOF_TPC_Mapka_allka"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); @@ -579,10 +796,13 @@ struct kstarpbpb { bool track1pion = false; bool track1kaon = false; - if (ispTdepPID && !(selectionPIDNew(track1, 0) || selectionPIDNew(track1, 1))) { + if (ispTdepPID && !isTOFOnly && !(selectionPIDNew(track1, 0) || selectionPIDNew(track1, 1))) { + continue; + } + if (!ispTdepPID && !isTOFOnly && !(selectionPID(track1, 0) || selectionPID(track1, 1))) { continue; } - if (!ispTdepPID && !(selectionPID(track1, 0) || selectionPID(track1, 1))) { + if (isTOFOnly && !(selectionPID2(track1, 0) || selectionPID2(track1, 1))) { continue; } auto track1ID = track1.globalIndex(); @@ -594,26 +814,29 @@ struct kstarpbpb { } if (additionalQAplots) { histos.fill(HIST("QAbefore/TOF_TPC_Mapka_allpi"), track2.tofNSigmaPi(), track2.tpcNSigmaPi()); - histos.fill(HIST("QAbefore/TPC_Nsigma_allpi"), track2.pt(), track2.tpcNSigmaPi()); - histos.fill(HIST("QAbefore/TOF_Nsigma_allpi"), track2.pt(), track2.tofNSigmaPi()); + histos.fill(HIST("QAbefore/TPC_Nsigma_allpi"), track2.pt(), track2.tpcNSigmaPi(), centrality); + histos.fill(HIST("QAbefore/TOF_Nsigma_allpi"), track2.pt(), track2.tofNSigmaPi(), centrality); histos.fill(HIST("QAbefore/trkDCAxypi"), track2.dcaXY()); histos.fill(HIST("QAbefore/trkDCAzpi"), track2.dcaZ()); } - if (ispTdepPID && !(selectionPIDNew(track2, 0) || selectionPIDNew(track2, 1))) { + if (ispTdepPID && !isTOFOnly && !(selectionPIDNew(track2, 0) || selectionPIDNew(track2, 1))) { continue; } - if (!ispTdepPID && !(selectionPID(track2, 0) || selectionPID(track2, 1))) { + if (!ispTdepPID && !isTOFOnly && !(selectionPID(track2, 0) || selectionPID(track2, 1))) { + continue; + } + if (isTOFOnly && !(selectionPID2(track2, 0) || selectionPID2(track2, 1))) { continue; } auto track2ID = track2.globalIndex(); - if (isGI && (track2ID <= track1ID)) { + if (track2ID == track1ID) { continue; } if (track1.sign() * track2.sign() > 0) { continue; } - if (ispTdepPID) { + if (ispTdepPID && !isTOFOnly) { if (selectionPIDNew(track1, 1) && selectionPIDNew(track2, 0)) { track1pion = true; track2kaon = true; @@ -629,7 +852,7 @@ struct kstarpbpb { } } } - if (!ispTdepPID) { + if (!ispTdepPID && !isTOFOnly) { if (selectionPID(track1, 1) && selectionPID(track2, 0)) { track1pion = true; track2kaon = true; @@ -645,42 +868,60 @@ struct kstarpbpb { } } } - - if (track1kaon && track2pion) { - if (additionalQAplots) { - histos.fill(HIST("QAafter/TPC_Nsigma_allka"), track1.pt(), track1.tpcNSigmaKa()); - histos.fill(HIST("QAafter/TOF_Nsigma_allka"), track1.pt(), track1.tofNSigmaKa()); - histos.fill(HIST("QAafter/trkDCAxyka"), track1.dcaXY()); - histos.fill(HIST("QAafter/trkDCAzka"), track1.dcaZ()); - histos.fill(HIST("QAafter/TOF_TPC_Mapka_allka"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); - histos.fill(HIST("QAafter/TOF_TPC_Mapka_allpi"), track2.tofNSigmaPi(), track2.tpcNSigmaPi()); - histos.fill(HIST("QAafter/TPC_Nsigma_allpi"), track2.pt(), track2.tpcNSigmaPi()); - histos.fill(HIST("QAafter/TOF_Nsigma_allpi"), track2.pt(), track2.tofNSigmaPi()); - histos.fill(HIST("QAafter/trkDCAxypi"), track2.dcaXY()); - histos.fill(HIST("QAafter/trkDCAzpi"), track2.dcaZ()); - } - daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); - daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); - } else if (track1pion && track2kaon) { - daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massPi); - daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); - } else { - continue; + if (isTOFOnly) { + if (selectionPID2(track1, 1) && selectionPID2(track2, 0)) { + track1pion = true; + track2kaon = true; + if (removefaketrak && isFakeKaon(track2, 0)) { + continue; + } + } + if (selectionPID2(track2, 1) && selectionPID2(track1, 0)) { + track2pion = true; + track1kaon = true; + if (removefaketrak && isFakeKaon(track1, 0)) { + continue; + } + } } + if (same) { + if (track1kaon && track2pion) { + if (additionalQAplots) { + histos.fill(HIST("QAafter/TPC_Nsigma_allka"), track1.pt(), track1.tpcNSigmaKa(), centrality); + histos.fill(HIST("QAafter/TOF_Nsigma_allka"), track1.pt(), track1.tofNSigmaKa(), centrality); + histos.fill(HIST("QAafter/trkDCAxyka"), track1.dcaXY()); + histos.fill(HIST("QAafter/trkDCAzka"), track1.dcaZ()); + histos.fill(HIST("QAafter/TOF_TPC_Mapka_allka"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + histos.fill(HIST("QAafter/TOF_TPC_Mapka_allpi"), track2.tofNSigmaPi(), track2.tpcNSigmaPi()); + histos.fill(HIST("QAafter/TPC_Nsigma_allpi"), track2.pt(), track2.tpcNSigmaPi(), centrality); + histos.fill(HIST("QAafter/TOF_Nsigma_allpi"), track2.pt(), track2.tofNSigmaPi(), centrality); + histos.fill(HIST("QAafter/trkDCAxypi"), track2.dcaXY()); + histos.fill(HIST("QAafter/trkDCAzpi"), track2.dcaZ()); + } + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); + } else if (track1pion && track2kaon) { + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massPi); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } else { + continue; + } - KstarMother = daughter1 + daughter2; - histos.fill(HIST("hpTvsRapidity"), KstarMother.Pt(), KstarMother.Rapidity()); - if (TMath::Abs(KstarMother.Rapidity()) > confRapidity) { - continue; - } - auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); - if (useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; - } - if (!useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi); + KstarMother = daughter1 + daughter2; + if (TMath::Abs(KstarMother.Rapidity()) > confRapidity) { + continue; + } + auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); + + if (useSP) { + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; + } + if (!useSP) { + v2 = TMath::Cos(2.0 * phiminuspsi); + } + + histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); } - histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); if (fillRotation) { for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { auto anglestart = confMinRot; @@ -706,12 +947,14 @@ struct kstarpbpb { continue; } auto phiminuspsiRot = GetPhiInRange(kstarrot.Phi() - psiFT0C); + if (useSP) { v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; } if (!useSP) { v2Rot = TMath::Cos(2.0 * phiminuspsiRot); } + histos.fill(HIST("hSparseV2SASameEventRotational_V2"), kstarrot.M(), kstarrot.Pt(), v2Rot, centrality); } } @@ -719,6 +962,7 @@ struct kstarpbpb { } } PROCESS_SWITCH(kstarpbpb, processSameEvent, "Process Same event", false); + void processlikeEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) { if (!collision.sel8()) { @@ -738,6 +982,9 @@ struct kstarpbpb { if (additionalEvSel3 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { return; } + if (additionalEvselITS && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } int occupancy = collision.trackOccupancyInTimeRange(); auto psiFT0C = collision.psiFT0C(); if (fillOccupancy && occupancy >= cfgOccupancyCut) // occupancy info is available for this collision (*) @@ -754,10 +1001,13 @@ struct kstarpbpb { } bool track1pion = false; bool track1kaon = false; - if (ispTdepPID && !(selectionPIDNew(track1, 0) || selectionPIDNew(track1, 1))) { + if (ispTdepPID && !isTOFOnly && !(selectionPIDNew(track1, 0) || selectionPIDNew(track1, 1))) { + continue; + } + if (!ispTdepPID && !isTOFOnly && !(selectionPID(track1, 0) || selectionPID(track1, 1))) { continue; } - if (!ispTdepPID && !(selectionPID(track1, 0) || selectionPID(track1, 1))) { + if (isTOFOnly && !(selectionPID2(track1, 0) || selectionPID2(track1, 1))) { continue; } for (auto track2 : tracks) { @@ -766,17 +1016,20 @@ struct kstarpbpb { if (!selectionTrack(track2)) { continue; } - if (ispTdepPID && !(selectionPIDNew(track2, 0) || selectionPIDNew(track2, 1))) { + if (ispTdepPID && !isTOFOnly && !(selectionPIDNew(track2, 0) || selectionPIDNew(track2, 1))) { continue; } - if (!ispTdepPID && !(selectionPID(track2, 0) || selectionPID(track2, 1))) { + if (!ispTdepPID && !isTOFOnly && !(selectionPID(track2, 0) || selectionPID(track2, 1))) { + continue; + } + if (isTOFOnly && !(selectionPID2(track2, 0) || selectionPID2(track2, 1))) { continue; } if (track1.sign() * track2.sign() < 0) { continue; } - if (ispTdepPID) { + if (ispTdepPID && !isTOFOnly) { if (selectionPIDNew(track1, 1) && selectionPIDNew(track2, 0)) { track1pion = true; track2kaon = true; @@ -792,7 +1045,7 @@ struct kstarpbpb { } } } - if (!ispTdepPID) { + if (!ispTdepPID && !isTOFOnly) { if (selectionPID(track1, 1) && selectionPID(track2, 0)) { track1pion = true; track2kaon = true; @@ -808,6 +1061,22 @@ struct kstarpbpb { } } } + if (isTOFOnly) { + if (selectionPID2(track1, 1) && selectionPID2(track2, 0)) { + track1pion = true; + track2kaon = true; + if (removefaketrak && isFakeKaon(track2, 0)) { + continue; + } + } + if (selectionPID2(track2, 1) && selectionPID2(track1, 0)) { + track2pion = true; + track1kaon = true; + if (removefaketrak && isFakeKaon(track1, 0)) { + continue; + } + } + } if (track1kaon && track2pion) { if (track1.sign() < 0 && track2.sign() < 0) { @@ -819,6 +1088,7 @@ struct kstarpbpb { continue; } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); + if (useSP) { v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; } @@ -836,12 +1106,14 @@ struct kstarpbpb { continue; } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); + if (useSP) { v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; } if (!useSP) { v2 = TMath::Cos(2.0 * phiminuspsi); } + histos.fill(HIST("hSparseV2SAlikeEventPP_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); } } @@ -850,134 +1122,478 @@ struct kstarpbpb { } PROCESS_SWITCH(kstarpbpb, processlikeEvent, "Process like event", false); - void processMixedEvent(EventCandidates const& collisions, TrackCandidates const& /*tracks*/) + */ + + void processMixedEvent(EventCandidates const& collisions, TrackCandidates const& tracks) { - BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicityClass, axisEPAngle}, true}; - for (auto const& [collision1, collision2] : o2::soa::selfCombinations(binningOnPositions, cfgNoMixedEvents, -1, collisions, collisions)) { - if (!collision1.sel8() || !collision2.sel8()) { - // printf("Mix = %d\n", 1); - continue; - } - if (!collision1.triggereventep() || !collision2.triggereventep()) { - // printf("Mix = %d\n", 2); - continue; - } - if (timFrameEvsel && (!collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - // printf("Mix = %d\n", 3); + + auto tracksTuple = std::make_tuple(tracks); + BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicityClass, axisOccup}, true}; + SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; + for (auto& [collision1, tracks1, collision2, tracks2] : pair) { + if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(collision1)) { continue; } - if (additionalEvSel2 && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + if (rctCut.requireRCTFlagChecker && !rctCut.rctChecker(collision2)) { continue; } - if (additionalEvSel2 && (!collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + if (!collision1.sel8() || !collision1.triggereventep() || !collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { continue; } - if (additionalEvSel3 && (!collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + if (!collision2.sel8() || !collision2.triggereventep() || !collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { continue; } - if (additionalEvSel3 && (!collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + if (collision1.bcId() == collision2.bcId()) { continue; } int occupancy1 = collision1.trackOccupancyInTimeRange(); int occupancy2 = collision2.trackOccupancyInTimeRange(); - auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + if (fillOccupancy && occupancy1 >= cfgOccupancyCut && occupancy2 >= cfgOccupancyCut) // occupancy info is available for this collision (*) + { + continue; + } auto centrality = collision1.centFT0C(); auto centrality2 = collision2.centFT0C(); auto psiFT0C = collision1.psiFT0C(); auto QFT0C = collision1.qFT0C(); - bool track1pion = false; - bool track1kaon = false; - bool track2pion = false; - bool track2kaon = false; if (additionalEvsel && !eventSelected(collision1, centrality)) { - // printf("Mix = %d\n", 4); continue; } if (additionalEvsel && !eventSelected(collision2, centrality2)) { - // printf("Mix = %d\n", 5); continue; } - if (fillOccupancy && occupancy1 >= cfgOccupancyCut && occupancy2 >= cfgOccupancyCut) // occupancy info is available for this collision (*) - { + if (additionalEvselITS && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { continue; } - for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posThisColl, negThisColl))) { - // track selection + if (additionalEvselITS && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + + for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (track1.sign() * track2.sign() > 0) { + continue; + } if (!selectionTrack(track1) || !selectionTrack(track2)) { - // printf("Mix = %d\n", 6); + continue; } - if (ispTdepPID && !(selectionPIDNew(track1, 0) || selectionPIDNew(track1, 1))) { + if (ispTdepPID && !isTOFOnly && !(selectionPIDNew(track1, 0))) { continue; } - if (ispTdepPID && !(selectionPIDNew(track2, 1) || selectionPIDNew(track2, 0))) { + if (ispTdepPID && !isTOFOnly && !(selectionPIDNew(track2, 1))) { continue; } - if (!ispTdepPID && !(selectionPID(track1, 0) || selectionPID(track1, 1))) { + if (!ispTdepPID && !isTOFOnly && !(selectionPID(track1, 0))) { continue; } - if (!ispTdepPID && !(selectionPID(track2, 1) || selectionPID(track2, 0))) { + if (!ispTdepPID && !isTOFOnly && !(selectionPID(track2, 1))) { + continue; + } + if (isTOFOnly && !selectionPID2(track1, 0)) { + continue; + } + if (isTOFOnly && !selectionPID2(track2, 1)) { + continue; + } + // if (track1.sign() > 0 && track2.sign() < 0) { + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); + /*} else if (track1.sign() < 0 && track2.sign() > 0) { + daughter2 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter1 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); + }*/ + KstarMother = daughter1 + daughter2; + if (TMath::Abs(KstarMother.Rapidity()) > confRapidity) { continue; } + auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); - if (ispTdepPID) { - if (selectionPIDNew(track1, 1) && selectionPIDNew(track2, 0)) { - track1pion = true; - track2kaon = true; - if (removefaketrak && isFakeKaon(track2, 0)) { - continue; - } + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; + if (!fillSA) { + if (track1.sign() * track2.sign() < 0) + histos.fill(HIST("hSparseV2SAMixedEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); + } + if (fillSA) { + ROOT::Math::Boost boost{KstarMother.BoostToCM()}; + fourVecDauCM = boost(daughter1); + threeVecDauCM = fourVecDauCM.Vect(); + threeVecDauCMXY = ROOT::Math::XYZVector(threeVecDauCM.X(), threeVecDauCM.Y(), 0.); + eventplaneVec = ROOT::Math::XYZVector(std::cos(2.0 * psiFT0C), std::sin(2.0 * psiFT0C), 0); + eventplaneVecNorm = ROOT::Math::XYZVector(std::sin(2.0 * psiFT0C), -std::cos(2.0 * psiFT0C), 0); + auto cosPhistarminuspsi = GetPhiInRange(fourVecDauCM.Phi() - psiFT0C); + auto SA = TMath::Cos(2.0 * cosPhistarminuspsi); + auto cosThetaStar = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); + if (usepolar) { + histos.fill(HIST("hSparseSAvsrapmix"), KstarMother.M(), KstarMother.Pt(), cosThetaStar, KstarMother.Rapidity(), centrality); + } else { + histos.fill(HIST("hSparseSAvsrapmix"), KstarMother.M(), KstarMother.Pt(), SA, KstarMother.Rapidity(), centrality); } - if (selectionPIDNew(track2, 1) && selectionPIDNew(track1, 0)) { - track2pion = true; - track1kaon = true; - if (removefaketrak && isFakeKaon(track1, 0)) { - continue; + } + } + } + } + PROCESS_SWITCH(kstarpbpb, processMixedEvent, "Process Mixed event", true); + void processMC(CollisionMCTrueTable::iterator const& /*TrueCollision*/, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + { + histos.fill(HIST("hMC"), 0); + if (RecCollisions.size() == 0) { + histos.fill(HIST("hMC"), 1); + return; + } + if (RecCollisions.size() > 1) { + histos.fill(HIST("hMC"), 2); + return; + } + for (auto& RecCollision : RecCollisions) { + auto psiFT0C = 0.0; + histos.fill(HIST("hMC"), 3); + if (!RecCollision.sel8()) { + histos.fill(HIST("hMC"), 4); + continue; + } + + if (!RecCollision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + histos.fill(HIST("hMC"), 5); + continue; + } + if (TMath::Abs(RecCollision.posZ()) > cfgCutVertex) { + histos.fill(HIST("hMC"), 6); + continue; + } + histos.fill(HIST("hMC"), 7); + auto centrality = RecCollision.centFT0C(); + histos.fill(HIST("CentPercentileMCRecHist"), centrality); + auto oldindex = -999; + auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); + // loop over reconstructed particle + for (auto track1 : Rectrackspart) { + if (!selectionTrack(track1)) { + continue; + } + if (ispTdepPID && !(selectionPIDNew(track1, 0))) { + continue; + } + if (!ispTdepPID && !(selectionPID(track1, 0))) { + continue; + } + if (!track1.has_mcParticle()) { + continue; + } + auto track1ID = track1.index(); + for (auto track2 : Rectrackspart) { + auto track2ID = track2.index(); + if (track2ID <= track1ID) { + continue; + } + if (!selectionTrack(track2)) { + continue; + } + if (ispTdepPID && !(selectionPIDNew(track2, 1))) { + continue; + } + if (!ispTdepPID && !(selectionPID(track2, 1))) { + continue; + } + if (!track2.has_mcParticle()) { + continue; + } + if (track1.sign() * track2.sign() > 0) { + continue; + } + const auto mctrack1 = track1.mcParticle(); + const auto mctrack2 = track2.mcParticle(); + int track1PDG = TMath::Abs(mctrack1.pdgCode()); + int track2PDG = TMath::Abs(mctrack2.pdgCode()); + if (!mctrack1.isPhysicalPrimary()) { + continue; + } + if (!mctrack2.isPhysicalPrimary()) { + continue; + } + if (!(track1PDG == 321 && track2PDG == 211)) { + continue; + } + for (auto& mothertrack1 : mctrack1.mothers_as()) { + for (auto& mothertrack2 : mctrack2.mothers_as()) { + if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) { + continue; + } + if (mothertrack1 != mothertrack2) { + continue; + } + if (TMath::Abs(mothertrack1.y()) > confRapidity) { + continue; + } + if (PDGcheck && TMath::Abs(mothertrack1.pdgCode()) != 313) { + continue; + } + if (ispTdepPID && !(selectionPIDNew(track1, 0) || selectionPIDNew(track2, 1))) { + continue; + } + if (!ispTdepPID && !(selectionPID(track1, 0) || selectionPID(track2, 1))) { + continue; + } + if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { + continue; + } + oldindex = mothertrack1.globalIndex(); + if (track1.sign() > 0 && track2.sign() < 0) { + KaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + PionMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); + } + if (track1.sign() < 0 && track2.sign() > 0) { + PionMinus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + KaonPlus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); + } + KstarMother = KaonPlus + PionMinus; + if (TMath::Abs(KstarMother.Rapidity()) > confRapidity) { + continue; + } + auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); + + v2 = TMath::Cos(2.0 * phiminuspsi); + + histos.fill(HIST("hSparseV2SARec_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); + histos.fill(HIST("h2PhiRec2"), KstarMother.pt(), centrality); + histos.fill(HIST("hpt"), KstarMother.Pt()); } } } - if (!ispTdepPID) { - if (selectionPID(track1, 1) && selectionPID(track2, 0)) { - track1pion = true; - track2kaon = true; - if (removefaketrak && isFakeKaon(track2, 0)) { - continue; + } + // loop over generated particle + for (auto& mcParticle : GenParticles) { + if (TMath::Abs(mcParticle.y()) > confRapidity) { + continue; + } + if (PDGcheck && mcParticle.pdgCode() != 313) { + continue; + } + auto kDaughters = mcParticle.daughters_as(); + if (kDaughters.size() != 2) { + continue; + } + auto daughtp = false; + auto daughtm = false; + for (auto kCurrentDaughter : kDaughters) { + if (!kCurrentDaughter.isPhysicalPrimary()) { + continue; + } + if (kCurrentDaughter.pdgCode() == +321) { + if (genacceptancecut && kCurrentDaughter.pt() > cfgCutPT && TMath::Abs(kCurrentDaughter.eta()) < cfgCutEta) { + daughtp = true; + } + if (!genacceptancecut) { + daughtp = true; } + KaonPlus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); + } else if (kCurrentDaughter.pdgCode() == -211) { + if (genacceptancecut && kCurrentDaughter.pt() > cfgCutPT && TMath::Abs(kCurrentDaughter.eta()) < cfgCutEta) { + daughtm = true; + } + if (!genacceptancecut) { + daughtm = true; + } + PionMinus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massPi); } - if (selectionPID(track2, 1) && selectionPID(track1, 0)) { - track2pion = true; - track1kaon = true; - if (removefaketrak && isFakeKaon(track1, 0)) { - continue; + } + if (daughtp && daughtm) { + KstarMother = KaonPlus + PionMinus; + if (TMath::Abs(KstarMother.Rapidity()) > confRapidity) { + continue; + } + auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); + + v2 = TMath::Cos(2.0 * phiminuspsi); + + histos.fill(HIST("hSparseV2SAGen_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); + histos.fill(HIST("h2PhiGen2"), KstarMother.pt(), centrality); + } + } + } // rec collision loop + + } // process MC + PROCESS_SWITCH(kstarpbpb, processMC, "Process MC", false); + + void processMCkstarWeight(CollisionMCTrueTable::iterator const& TrueCollision, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + { + float imp = TrueCollision.impactParameter(); + float evPhi = TrueCollision.eventPlaneAngle() / 2.0; + float centclass = -999; + if (imp >= 0 && imp < 3.49) { + centclass = 2.5; + } + if (imp >= 3.49 && imp < 4.93) { + centclass = 7.5; + } + if (imp >= 4.93 && imp < 6.98) { + centclass = 15.0; + } + if (imp >= 6.98 && imp < 8.55) { + centclass = 25.0; + } + if (imp >= 8.55 && imp < 9.87) { + centclass = 35.0; + } + if (imp >= 9.87 && imp < 11) { + centclass = 45.0; + } + if (imp >= 11 && imp < 12.1) { + centclass = 55.0; + } + if (imp >= 12.1 && imp < 13.1) { + centclass = 65.0; + } + if (imp >= 13.1 && imp < 14) { + centclass = 75.0; + } + histos.fill(HIST("hImpactParameter"), imp); + histos.fill(HIST("hEventPlaneAngle"), evPhi); + if (centclass < 0.0 || centclass > 80.0) { + return; + } + for (auto& RecCollision : RecCollisions) { + auto psiFT0C = TrueCollision.eventPlaneAngle(); + /* + if (!RecCollision.sel8()) { + continue; + } + if (!RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + continue; + } + */ + if (TMath::Abs(RecCollision.posZ()) > cfgCutVertex) { + continue; + } + auto oldindex = -999; + auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); + // loop over reconstructed particle + for (auto track1 : Rectrackspart) { + if (!track1.has_mcParticle()) { + continue; + } + + const auto mctrack1 = track1.mcParticle(); + + if (selectionTrack(track1) && strategySelectionPID(track1, 0, strategyPID) && TMath::Abs(mctrack1.pdgCode()) == 321 && mctrack1.isPhysicalPrimary()) { + histos.fill(HIST("hSparseKstarMCRecKaonWeight"), centclass, GetPhiInRange(mctrack1.phi() - psiFT0C), TMath::Power(TMath::Cos(2.0 * GetPhiInRange(mctrack1.phi() - psiFT0C)), 2.0), mctrack1.pt(), mctrack1.eta()); + } + if (selectionTrack(track1) && track1.pt() > 0.5 && track1.hasTOF() && TMath::Abs(track1.tofNSigmaKa()) > nsigmaCutTOF && TMath::Abs(track1.tpcNSigmaKa()) < nsigmaCutTPC && TMath::Abs(mctrack1.pdgCode()) == 321 && mctrack1.isPhysicalPrimary()) { + histos.fill(HIST("hSparseKstarMCRecKaonMissMatchWeight"), centclass, GetPhiInRange(mctrack1.phi() - psiFT0C), TMath::Power(TMath::Cos(2.0 * GetPhiInRange(mctrack1.phi() - psiFT0C)), 2.0), mctrack1.pt(), mctrack1.eta()); + } + if (selectionTrack(track1) && strategySelectionPID(track1, 1, strategyPID) && TMath::Abs(mctrack1.pdgCode()) == 211 && mctrack1.isPhysicalPrimary()) { + histos.fill(HIST("hSparseKstarMCRecPionWeight"), centclass, GetPhiInRange(mctrack1.phi() - psiFT0C), TMath::Power(TMath::Cos(2.0 * GetPhiInRange(mctrack1.phi() - psiFT0C)), 2.0), mctrack1.pt(), mctrack1.eta()); + } + if (selectionTrack(track1) && track1.pt() > 0.5 && track1.hasTOF() && TMath::Abs(track1.tofNSigmaPi()) > nsigmaCutTOF && TMath::Abs(track1.tpcNSigmaPi()) < nsigmaCutTPC && TMath::Abs(mctrack1.pdgCode()) == 211 && mctrack1.isPhysicalPrimary()) { + histos.fill(HIST("hSparseKstarMCRecPionMissMatchWeight"), centclass, GetPhiInRange(mctrack1.phi() - psiFT0C), TMath::Power(TMath::Cos(2.0 * GetPhiInRange(mctrack1.phi() - psiFT0C)), 2.0), mctrack1.pt(), mctrack1.eta()); + } + auto track1ID = track1.index(); + for (auto track2 : Rectrackspart) { + if (!track2.has_mcParticle()) { + continue; + } + auto track2ID = track2.index(); + if (track2ID <= track1ID) { + continue; + } + const auto mctrack2 = track2.mcParticle(); + int track1PDG = TMath::Abs(mctrack1.pdgCode()); + int track2PDG = TMath::Abs(mctrack2.pdgCode()); + if (!mctrack1.isPhysicalPrimary()) { + continue; + } + if (!mctrack2.isPhysicalPrimary()) { + continue; + } + if (!(track1PDG == 321 && track2PDG == 211)) { + continue; + } + if (!selectionTrack(track1) || !selectionTrack(track2) || track1.sign() * track2.sign() > 0) { + continue; + } + // PID check + if (ispTdepPID && !isTOFOnly && (!strategySelectionPID(track1, 0, strategyPID) || !strategySelectionPID(track2, 1, strategyPID))) { + continue; + } + if (!ispTdepPID && !isTOFOnly && (!selectionPID(track1, 0) || !selectionPID(track2, 1))) { + continue; + } + if (isTOFOnly && (!selectionPID2(track1, 0) || !selectionPID2(track2, 1))) { + continue; + } + for (auto& mothertrack1 : mctrack1.mothers_as()) { + for (auto& mothertrack2 : mctrack2.mothers_as()) { + if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) { + continue; + } + if (mothertrack1 != mothertrack2) { + continue; + } + if (TMath::Abs(mothertrack1.y()) > confRapidity) { + continue; + } + if (TMath::Abs(mothertrack1.pdgCode()) != 313) { + continue; + } + // if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { + if (avoidsplitrackMC && oldindex == mothertrack1.index()) { + histos.fill(HIST("h1PhiRecsplit"), mothertrack1.pt()); + continue; + } + // oldindex = mothertrack1.globalIndex(); + oldindex = mothertrack1.index(); + auto PhiMinusPsi = GetPhiInRange(mothertrack1.phi() - psiFT0C); + histos.fill(HIST("hSparseKstarMCRecWeight"), centclass, PhiMinusPsi, TMath::Power(TMath::Cos(2.0 * PhiMinusPsi), 2.0), mothertrack1.pt(), mothertrack1.eta()); } } } - if (track1kaon && track2pion) { - daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); - daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); - } else if (track1pion && track2kaon) { - daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massPi); - daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); - } else { + } + // loop over generated particle + for (auto& mcParticle : GenParticles) { + if (TMath::Abs(mcParticle.eta()) > 0.8) // main acceptance continue; + if (TMath::Abs(mcParticle.pdgCode()) == 321 && mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("hSparseKstarMCGenKaonWeight"), centclass, GetPhiInRange(mcParticle.phi() - psiFT0C), TMath::Power(TMath::Cos(2.0 * GetPhiInRange(mcParticle.phi() - psiFT0C)), 2.0), mcParticle.pt(), mcParticle.eta()); } - KstarMother = daughter1 + daughter2; - if (TMath::Abs(KstarMother.Rapidity()) > confRapidity) { + if (TMath::Abs(mcParticle.pdgCode()) == 211 && mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("hSparseKstarMCGenPionWeight"), centclass, GetPhiInRange(mcParticle.phi() - psiFT0C), TMath::Power(TMath::Cos(2.0 * GetPhiInRange(mcParticle.phi() - psiFT0C)), 2.0), mcParticle.pt(), mcParticle.eta()); + } + if (TMath::Abs(mcParticle.y()) > confRapidity) { continue; } - auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); - if (useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; + if (mcParticle.pdgCode() != 313) { + continue; } - if (!useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi); + auto kDaughters = mcParticle.daughters_as(); + if (kDaughters.size() != 2) { + continue; + } + auto daughtp = false; + auto daughtm = false; + for (auto kCurrentDaughter : kDaughters) { + if (!kCurrentDaughter.isPhysicalPrimary()) { + continue; + } + if (kCurrentDaughter.pdgCode() == +321) { + if (kCurrentDaughter.pt() > cfgCutPT && TMath::Abs(kCurrentDaughter.eta()) < cfgCutEta) { + daughtp = true; + } + KaonPlus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); + } else if (kCurrentDaughter.pdgCode() == -211) { + if (kCurrentDaughter.pt() > cfgCutPT && TMath::Abs(kCurrentDaughter.eta()) < cfgCutEta) { + daughtm = true; + } + PionMinus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massPi); + } + } + if (daughtp && daughtm) { + auto PhiMinusPsiGen = GetPhiInRange(mcParticle.phi() - psiFT0C); + histos.fill(HIST("hSparseKstarMCGenWeight"), centclass, PhiMinusPsiGen, TMath::Power(TMath::Cos(2.0 * PhiMinusPsiGen), 2.0), mcParticle.pt(), mcParticle.eta()); } - histos.fill(HIST("hSparseV2SAMixedEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); } - } - } - PROCESS_SWITCH(kstarpbpb, processMixedEvent, "Process Mixed event", false); + } // rec collision loop + + } // process MC + PROCESS_SWITCH(kstarpbpb, processMCkstarWeight, "Process MC kstar Weight", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGLF/Tasks/Resonances/kstarqa.cxx b/PWGLF/Tasks/Resonances/kstarqa.cxx index 804e8538824..45e63edae2e 100644 --- a/PWGLF/Tasks/Resonances/kstarqa.cxx +++ b/PWGLF/Tasks/Resonances/kstarqa.cxx @@ -15,22 +15,8 @@ /// \since 13/03/2024 // #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "TRandom3.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" -#include "CCDB/BasicCCDBManager.h" -#include "CCDB/CcdbApi.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + #include "Common/Core/TrackSelection.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" @@ -38,6 +24,9 @@ #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" #include "CommonConstants/PhysicsConstants.h" #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" @@ -45,19 +34,100 @@ #include "Framework/HistogramRegistry.h" #include "Framework/StepTHn.h" #include "Framework/runDataProcessing.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" #include "ReconstructionDataFormats/Track.h" +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TRandom3.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; using std::array; +using namespace o2::aod::rctsel; struct Kstarqa { SliceCache cache; + struct : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } rctCut; + RCTFlagsChecker rctChecker; + + struct : ConfigurableGroup { + // Configurables for event selections + Configurable isINELgt0{"isINELgt0", true, "INEL>0 selection"}; + Configurable isTriggerTVX{"isTriggerTVX", false, "TriggerTVX"}; + Configurable isGoodZvtxFT0vsPV{"isGoodZvtxFT0vsPV", false, "IsGoodZvtxFT0vsPV"}; + Configurable isApplyOccCut{"isApplyOccCut", true, "Apply occupancy cut"}; + Configurable isNoSameBunchPileup{"isNoSameBunchPileup", true, "kNoSameBunchPileup"}; + Configurable isAllLayersGoodITS{"isAllLayersGoodITS", true, "Require all ITS layers to be good"}; + Configurable isNoTimeFrameBorder{"isNoTimeFrameBorder", true, "kNoTimeFrameBorder"}; + Configurable isNoITSROFrameBorder{"isNoITSROFrameBorder", true, "kNoITSROFrameBorder"}; + + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable configOccCut{"configOccCut", 1000., "Occupancy cut"}; + + // Configurables for track selections + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", false, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable isGlobalTracks{"isGlobalTracks", true, "isGlobalTracks"}; + + Configurable rotationalCut{"rotationalCut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; + Configurable cfgCutPT{"cfgCutPT", 0.2f, "PT cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta cut on daughter track"}; + Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; + Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 5, "Number of mixed events per event"}; + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; + Configurable cfgRCRFC{"cfgRCRFC", 0.8f, "Crossed Rows to Findable Clusters"}; + Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 36.0, "ITS Chi2/NCl"}; + Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 4.0, "TPC Chi2/NCl"}; + Configurable cfgUseITSTPCRefit{"cfgUseITSTPCRefit", false, "Require ITS Refit"}; + Configurable isNoCollInTimeRangeStandard{"isNoCollInTimeRangeStandard", false, "No collision in time range standard"}; + Configurable isApplyPtDepDCAxyCut{"isApplyPtDepDCAxyCut", false, "Apply pT dependent DCAxy cut"}; + + // cuts on mother + Configurable isApplyCutsOnMother{"isApplyCutsOnMother", false, "Enable additional cuts on Kstar mother"}; + Configurable cMaxPtMotherCut{"cMaxPtMotherCut", 15.0, "Maximum pt of mother cut"}; + Configurable cMaxMinvMotherCut{"cMaxMinvMotherCut", 1.5, "Maximum mass of mother cut"}; + + // Other fixed variables + float lowPtCutPID = 0.5; + int noOfDaughters = 2; + float rapidityMotherData = 0.5; + + } selectionConfig; + + enum MultEstimator { + kFT0M, + kFT0A, + kFT0C, + kFV0A, + kFV0C, + kFV0M, + kNEstimators // useful if you want to iterate or size things + }; + // Histograms are defined with HistogramRegistry HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry hInvMass{"hInvMass", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; @@ -66,62 +136,42 @@ struct Kstarqa { // Confugrable for QA histograms Configurable calcLikeSign{"calcLikeSign", true, "Calculate Like Sign"}; - Configurable calcRotational{"calcRotational", true, "Calculate Rotational"}; + Configurable calcRotational{"calcRotational", false, "Calculate Rotational"}; Configurable cQAplots{"cQAplots", true, "cQAplots"}; Configurable cQAevents{"cQAevents", true, "Multiplicity dist, DCAxy, DCAz"}; Configurable onlyTOF{"onlyTOF", false, "only TOF tracks"}; Configurable onlyTOFHIT{"onlyTOFHIT", false, "accept only TOF hit tracks at high pt"}; Configurable onlyTPC{"onlyTPC", true, "only TPC tracks"}; + Configurable cRotations{"cRotations", 3, "Number of random rotations in the rotational background"}; + Configurable cSelectMultEstimator{"cSelectMultEstimator", 0, "Select multiplicity estimator: 0 - FT0M, 1 - FT0A, 2 - FT0C"}; + Configurable applyRecMotherRapidity{"applyRecMotherRapidity", true, "Apply rapidity cut on reconstructed mother track"}; + Configurable applypTdepPID{"applypTdepPID", false, "Apply pT dependent PID"}; - // Configurables for track selections - Configurable rotationalCut{"rotationalCut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; - Configurable cfgCutPT{"cfgCutPT", 0.2f, "PT cut on daughter track"}; - Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta cut on daughter track"}; - Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; - Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; - Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 5, "Number of mixed events per event"}; - Configurable ismanualDCAcut{"ismanualDCAcut", true, "ismanualDCAcut"}; - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; - Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; - Configurable cfgRCRFC{"cfgRCRFC", 0.8f, "Crossed Rows to Findable Clusters"}; - Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 36.0, "ITS Chi2/NCl"}; - Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 4.0, "TPC Chi2/NCl"}; - Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor - Configurable cfgPrimaryTrack{"cfgPrimaryTrack", false, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz - Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", false, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) - Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + // Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", false, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) Configurable cBetaCutTOF{"cBetaCutTOF", 0.0, "cut TOF beta"}; + Configurable cFakeTrack{"cFakeTrack", true, "Fake track selection"}; Configurable cFakeTrackCutKa{"cFakeTrackCutKa", 0.5, "Cut based on momentum difference in global and TPC tracks for Kaons"}; Configurable cFakeTrackCutPi{"cFakeTrackCutPi", 0.5, "Cut based on momentum difference in global and TPC tracks for Pions"}; - Configurable cFakeTrack{"cFakeTrack", true, "Fake track selection"}; // PID selections Configurable nsigmaCutTPCPi{"nsigmaCutTPCPi", 3.0, "TPC Nsigma cut for pions"}; Configurable nsigmaCutTPCKa{"nsigmaCutTPCKa", 3.0, "TPC Nsigma cut for kaons"}; Configurable nsigmaCutTOFPi{"nsigmaCutTOFPi", 3.0, "TOF Nsigma cut for pions"}; Configurable nsigmaCutTOFKa{"nsigmaCutTOFKa", 3.0, "TOF Nsigma cut for kaons"}; - Configurable nsigmaCutCombined{"nsigmaCutCombined", 3.0, "Combined Nsigma cut"}; - - // Event selection configurables - Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; - Configurable cTVXEvsel{"cTVXEvsel", false, "Triggger selection"}; - Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; - // Configurable cMID{"cMID", false, "Misidentification of tracks"}; + Configurable nsigmaCutCombinedKa{"nsigmaCutCombinedKa", 3.0, "Combined Nsigma cut for kaon"}; + Configurable nsigmaCutCombinedPi{"nsigmaCutCombinedPi", 3.0, "Combined Nsigma cut for pion"}; // Configurable for histograms - Configurable nBins{"nBins", 100, "No. of bins in Vz distribution"}; - Configurable nBinsinvMass{"nBinsinvMass", 180, "N bins in invMass hInvMass"}; - Configurable invMassbinlow{"invMassbinlow", 0.6, "invMass bin low"}; - Configurable invMassbinhigh{"invMassbinhigh", 1.5, "invMass bin high"}; - Configurable nBinspT{"nBinspT", 200, "N bins in pT hInvMass"}; - Configurable pTbinlow{"pTbinlow", 0.0, "pT bin low"}; - Configurable pTbinhigh{"pTbinhigh", 20.0, "pT bin high"}; Configurable avoidsplitrackMC{"avoidsplitrackMC", true, "avoid split track in MC"}; Configurable cAllGenCollisions{"cAllGenCollisions", false, "To fill all generated collisions for the signal loss calculations"}; - ConfigurableAxis binsMultPlot{"binsMultPlot", {201, -0.5f, 200.5f}, "centrality axis bins"}; + ConfigurableAxis binsMultPlot{"binsMultPlot", {110, 0.0, 110}, "THnSpare multiplicity axis"}; ConfigurableAxis axisdEdx{"axisdEdx", {1, 0.0f, 200.0f}, "dE/dx (a.u.)"}; ConfigurableAxis axisPtfordEbydx{"axisPtfordEbydx", {1, 0, 20}, "pT (GeV/c)"}; ConfigurableAxis axisMultdist{"axisMultdist", {1, 0, 70000}, "Multiplicity distribution"}; + ConfigurableAxis configThnAxisPOL{"configThnAxisPOL", {20, -1.0, 1.0}, "Costheta axis"}; + ConfigurableAxis invMassKstarAxis{"invMassKstarAxis", {300, 0.7f, 1.3f}, "Kstar invariant mass axis"}; + ConfigurableAxis ptAxisKstar{"ptAxisKstar", {200, 0.0f, 20.0f}, "Kstar pT axis"}; + ConfigurableAxis binsImpactPar{"binsImpactPar", {100, 0, 25}, "Binning of the impact parameter axis"}; // Event plane configurables Configurable boostDaugter1{"boostDaugter1", false, "Boost daughter Kaon in the COM frame"}; @@ -130,24 +180,41 @@ struct Kstarqa { Configurable activateTHnSparseCosThStarProduction{"activateTHnSparseCosThStarProduction", false, "Activate the THnSparse with cosThStar w.r.t. production axis"}; Configurable activateTHnSparseCosThStarBeam{"activateTHnSparseCosThStarBeam", false, "Activate the THnSparse with cosThStar w.r.t. beam axis (Gottified jackson frame)"}; Configurable activateTHnSparseCosThStarRandom{"activateTHnSparseCosThStarRandom", false, "Activate the THnSparse with cosThStar w.r.t. random axis"}; - Configurable cRotations{"cRotations", 3, "Number of random rotations in the rotational background"}; - ConfigurableAxis configThnAxisPOL{"configThnAxisPOL", {20, -1.0, 1.0}, "Costheta axis"}; + TRandom* rn = new TRandom(); void init(InitContext const&) { + rctChecker.init(rctCut.cfgEvtRCTFlagCheckerLabel, rctCut.cfgEvtRCTFlagCheckerZDCCheck, rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); // Axes - AxisSpec vertexZAxis = {nBins, -15., 15., "vrtx_{Z} [cm] for plots"}; - AxisSpec ptAxis = {nBinspT, pTbinlow, pTbinhigh, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec invmassAxis = {nBinsinvMass, invMassbinlow, invMassbinhigh, "Invariant mass (GeV/#it{c}^{2})"}; + AxisSpec vertexZAxis = {60, -15., 15., "vrtx_{Z} [cm] for plots"}; + AxisSpec ptAxis = {ptAxisKstar, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec invmassAxis = {invMassKstarAxis, "Invariant mass (GeV/#it{c}^{2})"}; AxisSpec thnAxisPOL{configThnAxisPOL, "cos(#theta)"}; + AxisSpec multiplicityAxis = {binsMultPlot, "Multiplicity Axis"}; + AxisSpec impactParAxis = {binsImpactPar, "Impact Parameter (cm)"}; // Histograms // Event selection rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); - rEventSelection.add("hmult", "Multiplicity percentile", kTH1F, {{binsMultPlot}}); - - // for primary tracks + rEventSelection.add("hMultiplicity", "Multiplicity percentile", kTH1F, {{110, 0, 110}}); + + rEventSelection.add("hEventCut", "No. of event after cuts", kTH1I, {{20, 0, 20}}); + std::shared_ptr hCutFlow = rEventSelection.get(HIST("hEventCut")); + hCutFlow->GetXaxis()->SetBinLabel(1, "All Events"); + hCutFlow->GetXaxis()->SetBinLabel(2, "|Vz| < cut"); + hCutFlow->GetXaxis()->SetBinLabel(3, "sel8"); + hCutFlow->GetXaxis()->SetBinLabel(4, "kNoTimeFrameBorder"); + hCutFlow->GetXaxis()->SetBinLabel(5, "kNoITSROFrameBorder"); + hCutFlow->GetXaxis()->SetBinLabel(6, "kNoSameBunchPileup"); + hCutFlow->GetXaxis()->SetBinLabel(7, "kIsGoodITSLayersAll"); + hCutFlow->GetXaxis()->SetBinLabel(8, "Occupancy Cut"); + hCutFlow->GetXaxis()->SetBinLabel(9, "rctChecker"); + hCutFlow->GetXaxis()->SetBinLabel(10, "kIsTriggerTVX"); + hCutFlow->GetXaxis()->SetBinLabel(11, "kIsGoodZvtxFT0vsPV"); + hCutFlow->GetXaxis()->SetBinLabel(12, "IsINELgt0"); + + // for primary tracksbinsMultPlot if (cQAplots) { hOthers.add("dE_by_dx_TPC", "dE/dx signal in the TPC as a function of pT", kTH2F, {axisPtfordEbydx, axisdEdx}); hOthers.add("hphi", "Phi distribution", kTH1F, {{65, 0, 6.5}}); @@ -155,49 +222,110 @@ struct Kstarqa { hOthers.add("hCRFC_after", "CRFC after distribution", kTH1F, {{100, 0.0f, 10.0f}}); hOthers.add("hCRFC_before", "CRFC before distribution", kTH1F, {{100, 0.0f, 10.0f}}); - hPID.add("Before/hNsigmaTPC_Ka_before", "N #sigma Kaon TPC before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - hPID.add("Before/hNsigmaTOF_Ka_before", "N #sigma Kaon TOF before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - hPID.add("Before/hNsigmaTPC_Pi_before", "N #sigma Pion TPC before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - hPID.add("Before/hNsigmaTOF_Pi_before", "N #sigma Pion TOF before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - hPID.add("Before/hNsigma_TPC_TOF_Ka_before", "N #sigma Kaon TOF before", kTH2F, {{100, -5.0f, 5.0f}, {100, -5.0f, 5.0f}}); - hPID.add("Before/hNsigma_TPC_TOF_Pi_before", "N #sigma Pion TOF before", kTH2F, {{100, -5.0f, 5.0f}, {100, -5.0f, 5.0f}}); - hPID.add("h1PID_TPC_kaon_data", "Kaon PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); - hPID.add("h1PID_TPC_pion_data", "Pion PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); - hPID.add("h1PID_TPC_kaon_MC", "Kaon PID distribution in MC", kTH1F, {{100, -10.0f, 10.0f}}); - hPID.add("h1PID_TPC_pion_MC", "Pion PID distribution in MC", kTH1F, {{100, -10.0f, 10.0f}}); - hPID.add("h1PID_TOF_kaon_data", "Kaon PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); - hPID.add("h1PID_TOF_pion_data", "Pion PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); - hPID.add("h1PID_TOF_kaon_MC", "Kaon PID distribution in MC", kTH1F, {{100, -10.0f, 10.0f}}); - hPID.add("h1PID_TOF_pion_MC", "Pion PID distribution in MC", kTH1F, {{100, -10.0f, 10.0f}}); - - hPID.add("After/hNsigmaPionTPC_after", "N #Pi TPC after", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - hPID.add("After/hNsigmaPionTOF_after", "N #Pi TOF after", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - hPID.add("After/hNsigmaKaonTPC_after", "N #sigma Kaon TPC after", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - hPID.add("After/hNsigmaKaonTOF_after", "N #sigma Kaon TOF after", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - hPID.add("After/hNsigma_TPC_TOF_Ka_after", "N #sigma Kaon TOF after", kTH2F, {{100, -5.0f, 5.0f}, {100, -5.0f, 5.0f}}); - hPID.add("After/hNsigma_TPC_TOF_Pi_after", "N #sigma Pion TOF after", kTH2F, {{100, -5.0f, 5.0f}, {100, -5.0f, 5.0f}}); + hOthers.add("hKstar_Rap", "Pair rapidity distribution; y; Counts", kTH1F, {{1000, -5.0f, 5.0f}}); + hOthers.add("hKstar_Eta", "Pair eta distribution; #eta; Counts", kTH1F, {{1000, -5.0f, 5.0f}}); + + hPID.add("Before/hNsigmaTPC_Ka_before", "N #sigma Kaon TPC before", kTH2F, {{50, 0.0f, 10.0f}, {100, -10.0f, 10.0f}}); + hPID.add("Before/hNsigmaTOF_Ka_before", "N #sigma Kaon TOF before", kTH2F, {{50, 0.0f, 10.0f}, {100, -10.0f, 10.0f}}); + hPID.add("Before/hNsigmaTPC_Pi_before", "N #sigma Pion TPC before", kTH2F, {{50, 0.0f, 10.0f}, {100, -10.0f, 10.0f}}); + hPID.add("Before/hNsigmaTOF_Pi_before", "N #sigma Pion TOF before", kTH2F, {{50, 0.0f, 10.0f}, {100, -10.0f, 10.0f}}); + hPID.add("Before/hNsigma_TPC_TOF_Ka_before", "N #sigma Kaon TOF before", kTH2F, {{50, -5.0f, 5.0f}, {50, -5.0f, 5.0f}}); + hPID.add("Before/hNsigma_TPC_TOF_Pi_before", "N #sigma Pion TOF before", kTH2F, {{50, -5.0f, 5.0f}, {50, -5.0f, 5.0f}}); + + hPID.add("Before/h1PID_TPC_pos_kaon", "Kaon PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); + hPID.add("Before/h1PID_TPC_pos_pion", "Pion PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); + hPID.add("Before/h1PID_TOF_pos_kaon", "Kaon PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); + hPID.add("Before/h1PID_TOF_pos_pion", "Pion PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); + hPID.add("Before/h1PID_TPC_neg_kaon", "Kaon PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); + hPID.add("Before/h1PID_TPC_neg_pion", "Pion PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); + hPID.add("Before/h1PID_TOF_neg_kaon", "Kaon PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); + hPID.add("Before/h1PID_TOF_neg_pion", "Pion PID distribution in data", kTH1F, {{100, -10.0f, 10.0f}}); + + hPID.add("Before/hTPCnsigKa_mult_pt", "TPC nsigma of Kaon brfore PID with pt and multiplicity", kTH3F, {{100, -10.0f, 10.0f}, multiplicityAxis, ptAxis}); + hPID.add("Before/hTPCnsigPi_mult_pt", "TPC nsigma of Pion brfore PID with pt and multiplicity", kTH3F, {{100, -10.0f, 10.0f}, multiplicityAxis, ptAxis}); + hPID.add("Before/hTOFnsigKa_mult_pt", "TPC nsigma of Kaon brfore PID with pt and multiplicity", kTH3F, {{100, -10.0f, 10.0f}, multiplicityAxis, ptAxis}); + hPID.add("Before/hTOFnsigPi_mult_pt", "TPC nsigma of Pion brfore PID with pt and multiplicity", kTH3F, {{100, -10.0f, 10.0f}, multiplicityAxis, ptAxis}); + + hPID.add("After/hNsigmaPionTPC_after", "N #Pi TPC after", kTH2F, {{50, 0.0f, 10.0f}, {100, -10.0f, 10.0f}}); + hPID.add("After/hNsigmaPionTOF_after", "N #Pi TOF after", kTH2F, {{50, 0.0f, 10.0f}, {100, -10.0f, 10.0f}}); + hPID.add("After/hNsigmaKaonTPC_after", "N #sigma Kaon TPC after", kTH2F, {{50, 0.0f, 10.0f}, {100, -10.0f, 10.0f}}); + hPID.add("After/hNsigmaKaonTOF_after", "N #sigma Kaon TOF after", kTH2F, {{50, 0.0f, 10.0f}, {100, -10.0f, 10.0f}}); + hPID.add("After/hNsigma_TPC_TOF_Ka_after", "N #sigma Kaon TOF after", kTH2F, {{50, -5.0f, 5.0f}, {50, -5.0f, 5.0f}}); + hPID.add("After/hNsigma_TPC_TOF_Pi_after", "N #sigma Pion TOF after", kTH2F, {{50, -5.0f, 5.0f}, {50, -5.0f, 5.0f}}); + + hPID.add("After/hDcaxyPi", "Dcaxy distribution of selected Pions", kTH1F, {{200, -1.0f, 1.0f}}); + hPID.add("After/hDcaxyKa", "Dcaxy distribution of selected Kaons", kTH1F, {{200, -1.0f, 1.0f}}); + hPID.add("After/hDcazPi", "Dcaz distribution of selected Pions", kTH1F, {{200, -1.0f, 1.0f}}); + hPID.add("After/hDcazKa", "Dcaz distribution of selected Kaons", kTH1F, {{200, -1.0f, 1.0f}}); + + hPID.add("After/hTPCnsigKa_mult_pt", "TPC nsigma of Kaon after PID with pt and multiplicity", kTH3F, {{100, -10.0f, 10.0f}, multiplicityAxis, ptAxis}); + hPID.add("After/hTPCnsigPi_mult_pt", "TPC nsigma of Pion after PID with pt and multiplicity", kTH3F, {{100, -10.0f, 10.0f}, multiplicityAxis, ptAxis}); + hPID.add("After/hTOFnsigKa_mult_pt", "TPC nsigma of Kaon after PID with pt and multiplicity", kTH3F, {{100, -10.0f, 10.0f}, multiplicityAxis, ptAxis}); + hPID.add("After/hTOFnsigPi_mult_pt", "TPC nsigma of Pion after PID with pt and multiplicity", kTH3F, {{100, -10.0f, 10.0f}, multiplicityAxis, ptAxis}); } // KStar histograms - hInvMass.add("h3KstarInvMassUnlikeSign", "kstar Unlike Sign", kTHnSparseF, {binsMultPlot, ptAxis, invmassAxis, thnAxisPOL}); - hInvMass.add("h3KstarInvMassMixed", "kstar Mixed", kTHnSparseF, {binsMultPlot, ptAxis, invmassAxis, thnAxisPOL}); - if (calcLikeSign) - hInvMass.add("h3KstarInvMasslikeSign", "kstar like Sign", kTHnSparseF, {binsMultPlot, ptAxis, invmassAxis, thnAxisPOL}); + hInvMass.add("h3KstarInvMassUnlikeSign", "kstar Unlike Sign", kTHnSparseF, {multiplicityAxis, ptAxis, invmassAxis, thnAxisPOL}); + hInvMass.add("h3KstarInvMassMixed", "kstar Mixed", kTHnSparseF, {multiplicityAxis, ptAxis, invmassAxis, thnAxisPOL}); + if (calcLikeSign) { + hInvMass.add("h3KstarInvMasslikeSignPP", "kstar like Sign", kTHnSparseF, {multiplicityAxis, ptAxis, invmassAxis, thnAxisPOL}); + hInvMass.add("h3KstarInvMasslikeSignMM", "kstar like Sign", kTHnSparseF, {multiplicityAxis, ptAxis, invmassAxis, thnAxisPOL}); + } if (calcRotational) - hInvMass.add("h3KstarInvMassRotated", "kstar rotated", kTHnSparseF, {binsMultPlot, ptAxis, invmassAxis, thnAxisPOL}); + hInvMass.add("h3KstarInvMassRotated", "kstar rotated", kTHnSparseF, {multiplicityAxis, ptAxis, invmassAxis, thnAxisPOL}); - // MC generated histograms - hInvMass.add("hk892GenpT", "pT distribution of True MC K(892)0", kTH2F, {ptAxis, binsMultPlot}); - // hInvMass.add("hk892GenpTAnti", "pT distribution of True MC Anti-K(892)0", kTH2F, {ptAxis}, {binsMultPlot}); - // Reconstructed MC histogram + // MC histograms + hInvMass.add("hk892GenpT", "pT distribution of True MC K(892)0", kTHnSparseF, {ptAxis, multiplicityAxis}); + hInvMass.add("hk892GenpT2", "pT distribution of True MC K(892)0", kTHnSparseF, {ptAxis, multiplicityAxis}); hInvMass.add("h1KstarRecMass", "Invariant mass of kstar meson", kTH1F, {invmassAxis}); - hInvMass.add("h2KstarRecpt1", "pT of kstar meson", kTH2F, {ptAxis, binsMultPlot}); - hInvMass.add("h2KstarRecpt2", "pT of generated kstar meson", kTH2F, {ptAxis, binsMultPlot}); + hInvMass.add("h2KstarRecpt1", "pT of kstar meson", kTHnSparseF, {ptAxis, multiplicityAxis, invmassAxis}); + hInvMass.add("h2KstarRecpt2", "pT of generated kstar meson", kTHnSparseF, {ptAxis, multiplicityAxis, invmassAxis}); hInvMass.add("h1genmass", "Invariant mass of generated kstar meson", kTH1F, {invmassAxis}); - rEventSelection.add("events_check_data", "No. of events in the data", kTH1I, {{20, 0, 20}}); - rEventSelection.add("events_check", "No. of events in the generated MC", kTH1I, {{20, 0, 20}}); - rEventSelection.add("events_checkrec", "No. of events in the reconstructed MC", kTH1I, {{20, 0, 20}}); + hInvMass.add("h1GenMult", "Multiplicity generated", kTH1F, {multiplicityAxis}); + hInvMass.add("h1RecMult", "Multiplicity reconstructed", kTH1F, {multiplicityAxis}); hInvMass.add("h1KSRecsplit", "KS meson Rec split", kTH1F, {{100, 0.0f, 10.0f}}); + hInvMass.add("MCcorrections/hSignalLossDenominator", "Kstar generated before event selection", kTH2F, {{ptAxis}, {impactParAxis}}); + hInvMass.add("MCcorrections/hSignalLossNumerator", "Kstar generated after event selection", kTH2F, {{ptAxis}, {impactParAxis}}); + // hInvMass.add("hAllGenCollisionsImpact", "All generated collisions vs impact parameter", kTH1F, {multiplicityAxis}); + hInvMass.add("hAllGenCollisions", "All generated events", kTH1F, {multiplicityAxis}); + hInvMass.add("hAllGenCollisions1Rec", "All gen events with at least one rec event", kTH1F, {multiplicityAxis}); + hInvMass.add("hAllKstarGenCollisisons", "All generated Kstar in events with rapidity in 0.5", kTH2F, {{multiplicityAxis}, {ptAxis}}); + hInvMass.add("hAllKstarGenCollisisons1Rec", "All generated Kstar in events with at least one rec event in rapidity in 0.5", kTH2F, {{multiplicityAxis}, {ptAxis}}); + hInvMass.add("hAllRecCollisions", "All reconstructed events", kTH1F, {multiplicityAxis}); + hInvMass.add("MCcorrections/hImpactParameterRec", "Impact parameter in reconstructed MC", kTH1F, {impactParAxis}); + hInvMass.add("MCcorrections/hImpactParameterGen", "Impact parameter in generated MC", kTH1F, {impactParAxis}); + hInvMass.add("MCcorrections/hImpactParametervsMultiplicity", "Impact parameter vs multiplicity in reconstructed MC", kTH2F, {{impactParAxis}, {multiplicityAxis}}); + rEventSelection.add("tracksCheckData", "No. of events in the data", kTH1I, {{10, 0, 10}}); + rEventSelection.add("eventsCheckGen", "No. of events in the generated MC", kTH1I, {{10, 0, 10}}); + rEventSelection.add("recMCparticles", "No. of events in the reconstructed MC", kTH1I, {{20, 0, 20}}); + rEventSelection.add("hOccupancy", "Occupancy distribution", kTH1F, {{1000, 0, 15000}}); + + std::shared_ptr hrecLabel = rEventSelection.get(HIST("hEventCut")); + hrecLabel->GetXaxis()->SetBinLabel(1, "All tracks"); + hrecLabel->GetXaxis()->SetBinLabel(2, "Track selection"); + hrecLabel->GetXaxis()->SetBinLabel(3, "has_MC"); + hrecLabel->GetXaxis()->SetBinLabel(4, "StrictlyUpperIndex"); + hrecLabel->GetXaxis()->SetBinLabel(5, "Unlike Sign"); + hrecLabel->GetXaxis()->SetBinLabel(6, "Physical Primary"); + hrecLabel->GetXaxis()->SetBinLabel(7, "PID Cut"); + hrecLabel->GetXaxis()->SetBinLabel(8, "Same mother"); + hrecLabel->GetXaxis()->SetBinLabel(9, "Generator"); + hrecLabel->GetXaxis()->SetBinLabel(10, "Rapidity"); + hrecLabel->GetXaxis()->SetBinLabel(11, "MotherPID313"); + hrecLabel->GetXaxis()->SetBinLabel(12, "Split track"); + + std::shared_ptr hDataTracks = rEventSelection.get(HIST("tracksCheckData")); + hDataTracks->GetXaxis()->SetBinLabel(1, "All tracks"); + hDataTracks->GetXaxis()->SetBinLabel(2, "Track selection"); + hDataTracks->GetXaxis()->SetBinLabel(3, "PID Cut"); + hDataTracks->GetXaxis()->SetBinLabel(4, "RmFakeTracks"); + hDataTracks->GetXaxis()->SetBinLabel(5, "Global Index"); + + std::shared_ptr hGenTracks = rEventSelection.get(HIST("eventsCheckGen")); + hGenTracks->GetXaxis()->SetBinLabel(1, "All events"); + hGenTracks->GetXaxis()->SetBinLabel(2, "INELgt0+vtz"); + hGenTracks->GetXaxis()->SetBinLabel(3, "INELgt0"); + hGenTracks->GetXaxis()->SetBinLabel(4, "Event Reconstructed"); // Multplicity distribution if (cQAevents) { @@ -214,35 +342,129 @@ struct Kstarqa { double massPi = o2::constants::physics::MassPiPlus; double massKa = o2::constants::physics::MassKPlus; + template + bool selectionEvent(const Coll& collision, bool fillHist = true) + { + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 0); + + if (std::abs(collision.posZ()) > selectionConfig.cutzvertex) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 1); + + if (!collision.sel8()) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 2); + + if (selectionConfig.isNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 3); + + if (selectionConfig.isNoITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 4); + + if (selectionConfig.isNoSameBunchPileup && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup))) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 5); + + if (selectionConfig.isAllLayersGoodITS && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 6); + + if (selectionConfig.isNoCollInTimeRangeStandard && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) + return false; + + if (selectionConfig.isApplyOccCut && (std::abs(collision.trackOccupancyInTimeRange()) > selectionConfig.configOccCut)) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 7); + + if (rctCut.requireRCTFlagChecker && !rctChecker(collision)) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 8); + + if (selectionConfig.isTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 9); + + if (selectionConfig.isGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) + return false; + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 10); + + if (selectionConfig.isINELgt0 && !collision.isInelGt0()) { + return false; + } + if (fillHist) + rEventSelection.fill(HIST("hEventCut"), 11); + + return true; + } + template bool selectionTrack(const T& candidate) { - if (ismanualDCAcut && !(candidate.isGlobalTrackWoDCA() && candidate.isPVContributor() && std::abs(candidate.dcaXY()) < cfgCutDCAxy && std::abs(candidate.dcaZ()) < cfgCutDCAz && candidate.itsNCls() > cfgITScluster)) { - return false; - } else if (!ismanualDCAcut) { - if (std::abs(candidate.pt()) < cfgCutPT) + if (selectionConfig.isGlobalTracks) { + if (!candidate.isGlobalTrackWoDCA()) + return false; + if (std::abs(candidate.pt()) < selectionConfig.cfgCutPT) + return false; + if (std::abs(candidate.eta()) > selectionConfig.cfgCutEta) + return false; + if (!selectionConfig.isApplyPtDepDCAxyCut) { + if (std::abs(candidate.dcaXY()) > selectionConfig.cfgCutDCAxy) + return false; + } else { + if (std::abs(candidate.dcaXY()) > (0.0105 + 0.035 / std::pow(candidate.pt(), 1.1))) + return false; + } + if (std::abs(candidate.dcaZ()) > selectionConfig.cfgCutDCAz) + return false; + if (candidate.tpcCrossedRowsOverFindableCls() < selectionConfig.cfgRCRFC) return false; - if (std::abs(candidate.dcaXY()) > cfgCutDCAxy) + if (candidate.itsNCls() < selectionConfig.cfgITScluster) return false; - if (std::abs(candidate.dcaZ()) > cfgCutDCAz) + if (candidate.tpcNClsFound() < selectionConfig.cfgTPCcluster) return false; - if (candidate.tpcCrossedRowsOverFindableCls() < cfgRCRFC) + if (candidate.itsChi2NCl() >= selectionConfig.cfgITSChi2NCl) return false; - if (candidate.itsNCls() < cfgITScluster) + if (candidate.tpcChi2NCl() >= selectionConfig.cfgTPCChi2NCl) return false; - if (candidate.tpcNClsFound() < cfgTPCcluster) + if (selectionConfig.cfgPVContributor && !candidate.isPVContributor()) return false; - if (candidate.itsChi2NCl() >= cfgITSChi2NCl) + if (selectionConfig.cfgUseITSTPCRefit && (!(o2::aod::track::ITSrefit) || !(o2::aod::track::TPCrefit))) return false; - if (candidate.tpcChi2NCl() >= cfgTPCChi2NCl) + } else if (!selectionConfig.isGlobalTracks) { + if (std::abs(candidate.pt()) < selectionConfig.cfgCutPT) return false; - if (cfgPVContributor && !candidate.isPVContributor()) + if (std::abs(candidate.eta()) > selectionConfig.cfgCutEta) return false; - if (cfgPrimaryTrack && !candidate.isPrimaryTrack()) + if (std::abs(candidate.dcaXY()) > selectionConfig.cfgCutDCAxy) return false; - if (cfgGlobalWoDCATrack && !candidate.isGlobalTrackWoDCA()) + if (std::abs(candidate.dcaZ()) > selectionConfig.cfgCutDCAz) return false; - if (cfgGlobalTrack && !candidate.isGlobalTrack()) + if (candidate.tpcCrossedRowsOverFindableCls() < selectionConfig.cfgRCRFC) + return false; + if (candidate.itsNCls() < selectionConfig.cfgITScluster) + return false; + if (candidate.tpcNClsFound() < selectionConfig.cfgTPCcluster) + return false; + if (candidate.itsChi2NCl() >= selectionConfig.cfgITSChi2NCl) + return false; + if (candidate.tpcChi2NCl() >= selectionConfig.cfgTPCChi2NCl) + return false; + if (selectionConfig.cfgPVContributor && !candidate.isPVContributor()) + return false; + if (selectionConfig.cfgPrimaryTrack && !candidate.isPrimaryTrack()) return false; } @@ -283,7 +505,7 @@ struct Kstarqa { return true; } } else { - if (candidate.hasTOF() && (candidate.tofNSigmaPi() * candidate.tofNSigmaPi() + candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi()) < (nsigmaCutCombined * nsigmaCutCombined) && candidate.beta() > cBetaCutTOF) { + if (candidate.hasTOF() && (candidate.tofNSigmaPi() * candidate.tofNSigmaPi() + candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi()) < (nsigmaCutCombinedPi * nsigmaCutCombinedPi) && candidate.beta() > cBetaCutTOF) { return true; } if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi) { @@ -307,7 +529,7 @@ struct Kstarqa { return true; } } else { - if (candidate.hasTOF() && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < (nsigmaCutCombined * nsigmaCutCombined) && candidate.beta() > cBetaCutTOF) { + if (candidate.hasTOF() && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < (nsigmaCutCombinedKa * nsigmaCutCombinedKa) && candidate.beta() > cBetaCutTOF) { return true; } if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa) { @@ -318,6 +540,34 @@ struct Kstarqa { return false; } + template + bool selectionPIDNew(const T& candidate, int PID) + { + if (PID == 0) { + if (candidate.pt() < selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi) { + return true; + } + if (candidate.pt() >= selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi && candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < nsigmaCutTOFPi) { + return true; + } + if (candidate.pt() >= selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi && !candidate.hasTOF()) { + return true; + } + } else if (PID == 1) { + if (candidate.pt() < selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa) { + return true; + } + if (candidate.pt() >= selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa && candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < nsigmaCutTOFKa) { + return true; + } + if (candidate.pt() >= selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa && !candidate.hasTOF()) { + return true; + } + } + + return false; + } + // template // bool cMIDselectionPID(const T& candidate, int PID) // { @@ -405,170 +655,221 @@ struct Kstarqa { // Processed events will be already fulfilling the event selection // requirements // Filter eventFilter = (o2::aod::evsel::sel8 == true); - Filter posZFilter = (nabs(o2::aod::collision::posZ) < cutzvertex); + Filter posZFilter = (nabs(o2::aod::collision::posZ) < selectionConfig.cutzvertex); - Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPT); - Filter fDCAcutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + Filter acceptanceFilter = (nabs(aod::track::eta) < selectionConfig.cfgCutEta && nabs(aod::track::pt) > selectionConfig.cfgCutPT); + Filter fDCAcutFilter = (nabs(aod::track::dcaXY) < selectionConfig.cfgCutDCAxy) && (nabs(aod::track::dcaZ) < selectionConfig.cfgCutDCAz); - using EventCandidates = soa::Filtered>; + using EventCandidates = soa::Join; // aod::CentNGlobals, aod::CentNTPVs, aod::CentMFTs + using EventCandidatesMix = soa::Filtered>; // aod::CentNGlobals, aod::CentNTPVs, aod::CentMFTs using TrackCandidates = soa::Filtered>; - using EventCandidatesMC = soa::Join; + using EventCandidatesMC = soa::Join; using TrackCandidatesMC = soa::Filtered>; + using EventMCGenerated = soa::Join; // aod::CentNGlobals, aod::CentNTPVs, aod::CentMFTs //*********Varibles declaration*************** - TLorentzVector lv1, lv2, lv3, lv4, lv5; - float multiplicity = 0.0f; - float theta2; - ROOT::Math::PxPyPzMVector daughter1, daughter2, daughterSelected, fourVecDau1, fourVecMother, fourVecDauCM; - ROOT::Math::XYZVector threeVecDauCM, helicityVec, randomVec, beamVec, normalVec; + float multiplicity{-1.0}, theta2; + ROOT::Math::PxPyPzMVector daughter1, daughter2, daughterRot, mother, motherRot, daughterSelected, fourVecDauCM, daughterRotCM; + ROOT::Math::XYZVector randomVec, beamVec, normalVec; bool isMix = false; - template - void fillInvMass(const T1& track1, const T2& track2, const T3& lv2, const T4& lv3, float multiplicity, bool isMix) + template + void fillInvMass(const T1& daughter1, const T1& daughter2, const T1& mother, float multiplicity, bool isMix, const T2& track1, const T2& track2) { - daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); // Kaon - daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); // Pion - daughterSelected = (boostDaugter1) ? daughter1 : daughter2; - auto selectedDauMass = (boostDaugter1) ? massKa : massPi; - - // polarization calculations - - fourVecDau1 = ROOT::Math::PxPyPzMVector(daughterSelected.Px(), daughterSelected.Py(), daughterSelected.Pz(), selectedDauMass); // Kaon or Pion - - fourVecMother = ROOT::Math::PxPyPzMVector(lv3.Px(), lv3.Py(), lv3.Pz(), lv3.M()); // mass of KshortKshort pair - ROOT::Math::Boost boost{fourVecMother.BoostToCM()}; // boost mother to center of mass frame - fourVecDauCM = boost(fourVecDau1); // boost the frame of daughter same as mother - threeVecDauCM = fourVecDauCM.Vect(); // get the 3 vector of daughter in the frame of mother - - if (std::abs(lv3.Rapidity()) < 0.5) { - if (activateTHnSparseCosThStarHelicity) { - helicityVec = fourVecMother.Vect(); // 3 vector of mother in COM frame - auto cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(helicityVec.Mag2())); - - if (track1.sign() * track2.sign() < 0) { - if (!isMix) { - hInvMass.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity); - - for (int i = 0; i < cRotations; i++) { - theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalCut, o2::constants::math::PI + o2::constants::math::PI / rotationalCut); - lv4.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi() + theta2, massKa); // for rotated background - lv5 = lv2 + lv4; - if (calcRotational) - hInvMass.fill(HIST("h3KstarInvMassRotated"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarHelicity); - } - } else { - hInvMass.fill(HIST("h3KstarInvMassMixed"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity); + daughterSelected = (boostDaugter1) ? daughter1 : daughter2; // polarization calculations + ROOT::Math::Boost boost{mother.BoostToCM()}; // boost mother to center of mass frame + fourVecDauCM = boost(daughterSelected); // boost the frame of daughter same as mother + + // if (std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + if (activateTHnSparseCosThStarHelicity) { + auto cosThetaStarHelicity = mother.Vect().Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(mother.Vect().Mag2())); + + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + if (std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + hInvMass.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity); } - } else { - if (!isMix) { - if (calcLikeSign) - hInvMass.fill(HIST("h3KstarInvMasslikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity); + + for (int i = 0; i < cRotations; i++) { + theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / selectionConfig.rotationalCut, o2::constants::math::PI + o2::constants::math::PI / selectionConfig.rotationalCut); + + daughterRot = ROOT::Math::PxPyPzMVector(daughter1.Px() * std::cos(theta2) - daughter1.Py() * std::sin(theta2), daughter1.Px() * std::sin(theta2) + daughter1.Py() * std::cos(theta2), daughter1.Pz(), daughter1.M()); + + motherRot = daughterRot + daughter2; + + ROOT::Math::Boost boost2{motherRot.BoostToCM()}; + daughterRotCM = boost2(daughterRot); + + auto cosThetaStarHelicityRot = motherRot.Vect().Dot(daughterRotCM.Vect()) / (std::sqrt(daughterRotCM.Vect().Mag2()) * std::sqrt(motherRot.Vect().Mag2())); + + if (calcRotational && motherRot.Rapidity() < selectionConfig.rapidityMotherData) + hInvMass.fill(HIST("h3KstarInvMassRotated"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarHelicityRot); + } + } else if (isMix && std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + hInvMass.fill(HIST("h3KstarInvMassMixed"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity); + } + } else { + if (!isMix) { + if (calcLikeSign && std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + if (track1.sign() > 0 && track2.sign() > 0) { + hInvMass.fill(HIST("h3KstarInvMasslikeSignPP"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity); + } else if (track1.sign() < 0 && track2.sign() < 0) { + hInvMass.fill(HIST("h3KstarInvMasslikeSignMM"), multiplicity, mother.Pt(), mother.M(), cosThetaStarHelicity); + } } } + } - } else if (activateTHnSparseCosThStarProduction) { - normalVec = ROOT::Math::XYZVector(lv3.Py(), -lv3.Px(), 0.f); - auto cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / (std::sqrt(threeVecDauCM.Mag2()) * std::sqrt(normalVec.Mag2())); + } else if (activateTHnSparseCosThStarProduction) { + normalVec = ROOT::Math::XYZVector(mother.Py(), -mother.Px(), 0.f); + auto cosThetaStarProduction = normalVec.Dot(fourVecDauCM.Vect()) / (std::sqrt(fourVecDauCM.Vect().Mag2()) * std::sqrt(normalVec.Mag2())); - if (track1.sign() * track2.sign() < 0) { - if (!isMix) { - hInvMass.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction); - for (int i = 0; i < cRotations; i++) { - theta2 = rn->Uniform(0, o2::constants::math::PI); - lv4.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi() + theta2, massKa); // for rotated background - lv5 = lv2 + lv4; - if (calcRotational) - hInvMass.fill(HIST("h3KstarInvMassRotated"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarProduction); - } - } else { - hInvMass.fill(HIST("h3KstarInvMassMixed"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction); + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + if (std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + hInvMass.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction); } - } else { - if (!isMix) { - if (calcLikeSign) - hInvMass.fill(HIST("h3KstarInvMasslikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction); + for (int i = 0; i < cRotations; i++) { + theta2 = rn->Uniform(0, o2::constants::math::PI); + daughterRot = ROOT::Math::PxPyPzMVector(daughter1.Px() * std::cos(theta2) - daughter1.Py() * std::sin(theta2), daughter1.Px() * std::sin(theta2) + daughter1.Py() * std::cos(theta2), daughter1.Pz(), daughter1.M()); + + motherRot = daughterRot + daughter2; + if (calcRotational && std::abs(motherRot.Rapidity()) < selectionConfig.rapidityMotherData) + hInvMass.fill(HIST("h3KstarInvMassRotated"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarProduction); } + } else if (isMix && std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + hInvMass.fill(HIST("h3KstarInvMassMixed"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction); } - } else if (activateTHnSparseCosThStarBeam) { - beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); - auto cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - - if (track1.sign() * track2.sign() < 0) { - if (!isMix) { - hInvMass.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam); - for (int i = 0; i < cRotations; i++) { - theta2 = rn->Uniform(0, o2::constants::math::PI); - lv4.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi() + theta2, massKa); // for rotated background - lv5 = lv2 + lv4; - if (calcRotational) - hInvMass.fill(HIST("h3KstarInvMassRotated"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarBeam); + } else { + if (!isMix) { + if (calcLikeSign && std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + if (track1.sign() > 0 && track2.sign() > 0) { + hInvMass.fill(HIST("h3KstarInvMasslikeSignPP"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction); + } else if (track1.sign() < 0 && track2.sign() < 0) { + hInvMass.fill(HIST("h3KstarInvMasslikeSignMM"), multiplicity, mother.Pt(), mother.M(), cosThetaStarProduction); } - } else { - hInvMass.fill(HIST("h3KstarInvMassMixed"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam); } - } else { - if (calcLikeSign) - hInvMass.fill(HIST("h3KstarInvMasslikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam); - } - } else if (activateTHnSparseCosThStarRandom) { - auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); - auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); - - randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); - auto cosThetaStarRandom = randomVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - - if (track1.sign() * track2.sign() < 0) { - if (!isMix) { - hInvMass.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom); - for (int i = 0; i < cRotations; i++) { - theta2 = rn->Uniform(0, o2::constants::math::PI); - lv4.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi() + theta2, massKa); // for rotated background - lv5 = lv2 + lv4; - if (calcRotational) - hInvMass.fill(HIST("h3KstarInvMassRotated"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarRandom); - } - } else { - hInvMass.fill(HIST("h3KstarInvMassMixed"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom); + } + } + } else if (activateTHnSparseCosThStarBeam) { + beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); + auto cosThetaStarBeam = beamVec.Dot(fourVecDauCM.Vect()) / std::sqrt(fourVecDauCM.Vect().Mag2()); + + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + if (std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + hInvMass.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam); } - } else { - if (!isMix) { - if (calcLikeSign) - hInvMass.fill(HIST("h3KstarInvMasslikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom); + for (int i = 0; i < cRotations; i++) { + theta2 = rn->Uniform(0, o2::constants::math::PI); + daughterRot = ROOT::Math::PxPyPzMVector(daughter1.Px() * std::cos(theta2) - daughter1.Py() * std::sin(theta2), daughter1.Px() * std::sin(theta2) + daughter1.Py() * std::cos(theta2), daughter1.Pz(), daughter1.M()); + + motherRot = daughterRot + daughter2; + if (calcRotational && std::abs(motherRot.Rapidity()) < selectionConfig.rapidityMotherData) + hInvMass.fill(HIST("h3KstarInvMassRotated"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarBeam); + } + } else if (isMix && std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + hInvMass.fill(HIST("h3KstarInvMassMixed"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam); + } + } else { + if (calcLikeSign && std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + if (track1.sign() > 0 && track2.sign() > 0) { + hInvMass.fill(HIST("h3KstarInvMasslikeSignPP"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam); + } else if (track1.sign() < 0 && track2.sign() < 0) { + hInvMass.fill(HIST("h3KstarInvMasslikeSignMM"), multiplicity, mother.Pt(), mother.M(), cosThetaStarBeam); + } + } + } + } else if (activateTHnSparseCosThStarRandom) { + auto phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); + auto thetaRandom = gRandom->Uniform(0.f, constants::math::PI); + + randomVec = ROOT::Math::XYZVector(std::sin(thetaRandom) * std::cos(phiRandom), std::sin(thetaRandom) * std::sin(phiRandom), std::cos(thetaRandom)); + auto cosThetaStarRandom = randomVec.Dot(fourVecDauCM.Vect()) / std::sqrt(fourVecDauCM.Vect().Mag2()); + + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + if (std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + hInvMass.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom); + } + for (int i = 0; i < cRotations; i++) { + theta2 = rn->Uniform(0, o2::constants::math::PI); + daughterRot = ROOT::Math::PxPyPzMVector(daughter1.Px() * std::cos(theta2) - daughter1.Py() * std::sin(theta2), daughter1.Px() * std::sin(theta2) + daughter1.Py() * std::cos(theta2), daughter1.Pz(), daughter1.M()); + + motherRot = daughterRot + daughter2; + if (calcRotational && std::abs(motherRot.Rapidity()) < selectionConfig.rapidityMotherData) + hInvMass.fill(HIST("h3KstarInvMassRotated"), multiplicity, motherRot.Pt(), motherRot.M(), cosThetaStarRandom); + } + } else if (isMix && std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + hInvMass.fill(HIST("h3KstarInvMassMixed"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom); + } + } else { + if (!isMix) { + if (calcLikeSign && std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + if (track1.sign() > 0 && track2.sign() > 0) { + hInvMass.fill(HIST("h3KstarInvMasslikeSignPP"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom); + } else if (track1.sign() < 0 && track2.sign() < 0) { + hInvMass.fill(HIST("h3KstarInvMasslikeSignMM"), multiplicity, mother.Pt(), mother.M(), cosThetaStarRandom); + } } } } } + // } } // int counter = 0; - void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) { - rEventSelection.fill(HIST("events_check_data"), 0.5); - if (cTVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { - return; - } - rEventSelection.fill(HIST("events_check_data"), 1.5); + // if (cTVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { + // return; + // } + + // if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + // return; + // } - if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + // if (!collision.sel8()) { + // return; + // } + int occupancy = collision.trackOccupancyInTimeRange(); + rEventSelection.fill(HIST("hOccupancy"), occupancy); + + if (!selectionEvent(collision, true)) { return; } - rEventSelection.fill(HIST("events_check_data"), 2.5); - if (!collision.sel8()) { - return; + multiplicity = -1; + + if (cSelectMultEstimator == kFT0M) { + multiplicity = collision.centFT0M(); + } else if (cSelectMultEstimator == kFT0A) { + multiplicity = collision.centFT0A(); + } else if (cSelectMultEstimator == kFT0C) { + multiplicity = collision.centFT0C(); + } else if (cSelectMultEstimator == kFV0A) { + multiplicity = collision.centFV0A(); + } else { + multiplicity = collision.centFT0M(); // default } - rEventSelection.fill(HIST("events_check_data"), 3.5); - multiplicity = collision.centFT0M(); + /* else if (cSelectMultEstimator == 4) { + multiplicity = collision.centMFT(); + } */ + /* else if (cSelectMultEstimator == 5) { + multiplicity = collision.centNGlobal(); + } */ + /* else if (cSelectMultEstimator == 6) { + multiplicity = collision.centNTPV(); + } */ // Fill the event counter if (cQAevents) { rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); - rEventSelection.fill(HIST("hmult"), multiplicity); + rEventSelection.fill(HIST("hMultiplicity"), multiplicity); rEventSelection.fill(HIST("multdist_FT0M"), collision.multFT0M()); // rEventSelection.fill(HIST("multdist_FT0A"), collision.multFT0A()); // rEventSelection.fill(HIST("multdist_FT0C"), collision.multFT0C()); @@ -576,6 +877,15 @@ struct Kstarqa { } for (const auto& [track1, track2] : combinations(CombinationsFullIndexPolicy(tracks, tracks))) { + rEventSelection.fill(HIST("tracksCheckData"), 0.5); + if (!selectionTrack(track1)) { + continue; + } + if (!selectionTrack(track2)) { + continue; + } + rEventSelection.fill(HIST("tracksCheckData"), 1.5); + if (cQAplots) { hPID.fill(HIST("Before/hNsigmaTPC_Ka_before"), track1.pt(), track1.tpcNSigmaKa()); hPID.fill(HIST("Before/hNsigmaTOF_Ka_before"), track1.pt(), track1.tofNSigmaKa()); @@ -583,27 +893,28 @@ struct Kstarqa { hPID.fill(HIST("Before/hNsigmaTOF_Pi_before"), track2.pt(), track2.tofNSigmaPi()); hPID.fill(HIST("Before/hNsigma_TPC_TOF_Ka_before"), track1.tpcNSigmaKa(), track1.tofNSigmaKa()); hPID.fill(HIST("Before/hNsigma_TPC_TOF_Pi_before"), track2.tpcNSigmaPi(), track2.tofNSigmaPi()); - hPID.fill(HIST("h1PID_TPC_kaon_data"), track1.tpcNSigmaKa()); - hPID.fill(HIST("h1PID_TPC_pion_data"), track2.tpcNSigmaPi()); - hPID.fill(HIST("h1PID_TOF_kaon_data"), track1.tofNSigmaKa()); - hPID.fill(HIST("h1PID_TOF_pion_data"), track2.tofNSigmaPi()); + + hPID.fill(HIST("Before/hTPCnsigKa_mult_pt"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + hPID.fill(HIST("Before/hTPCnsigPi_mult_pt"), track2.tpcNSigmaPi(), multiplicity, track2.pt()); + hPID.fill(HIST("Before/hTOFnsigKa_mult_pt"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + hPID.fill(HIST("Before/hTOFnsigPi_mult_pt"), track2.tofNSigmaKa(), multiplicity, track2.pt()); hOthers.fill(HIST("hCRFC_before"), track1.tpcCrossedRowsOverFindableCls()); hOthers.fill(HIST("dE_by_dx_TPC"), track1.p(), track1.tpcSignal()); hOthers.fill(HIST("hphi"), track1.phi()); - } - rEventSelection.fill(HIST("events_check_data"), 4.5); - if (!selectionTrack(track1)) { - continue; - } - if (!selectionTrack(track2)) { - continue; + if (track1.sign() < 0) { + hPID.fill(HIST("Before/h1PID_TPC_neg_kaon"), track1.tpcNSigmaKa()); + hPID.fill(HIST("Before/h1PID_TPC_neg_pion"), track2.tpcNSigmaPi()); + hPID.fill(HIST("Before/h1PID_TOF_neg_kaon"), track1.tofNSigmaKa()); + hPID.fill(HIST("Before/h1PID_TOF_neg_pion"), track2.tofNSigmaPi()); + } else { + hPID.fill(HIST("Before/h1PID_TPC_pos_kaon"), track1.tpcNSigmaKa()); + hPID.fill(HIST("Before/h1PID_TPC_pos_pion"), track2.tpcNSigmaPi()); + hPID.fill(HIST("Before/h1PID_TOF_pos_kaon"), track1.tofNSigmaKa()); + hPID.fill(HIST("Before/h1PID_TOF_pos_pion"), track2.tofNSigmaPi()); + } } - rEventSelection.fill(HIST("events_check_data"), 5.5); - // if (counter < 1e4) - // std::cout << "TOF beta value is " << track1.beta() << std::endl; - // counter++; if (cQAevents) { rEventSelection.fill(HIST("hDcaxy"), track1.dcaXY()); @@ -611,12 +922,17 @@ struct Kstarqa { } // since we are using combinations full index policy, so repeated pairs are allowed, so we can check one with Kaon and other with pion - if (!selectionPID(track1, 1)) // Track 1 is checked with Kaon + if (!applypTdepPID && !selectionPID(track1, 1)) // Track 1 is checked with Kaon continue; - if (!selectionPID(track2, 0)) // Track 2 is checked with Pion + if (!applypTdepPID && !selectionPID(track2, 0)) // Track 2 is checked with Pion continue; - rEventSelection.fill(HIST("events_check_data"), 6.5); + if (applypTdepPID && !selectionPIDNew(track1, 1)) // Track 1 is checked with Kaon + continue; + if (applypTdepPID && !selectionPIDNew(track2, 0)) // Track 2 is checked with Pion + continue; + + rEventSelection.fill(HIST("tracksCheckData"), 2.5); if (cFakeTrack && isFakeTrack(track1, 1)) // Kaon continue; @@ -632,9 +948,18 @@ struct Kstarqa { // continue; // } - rEventSelection.fill(HIST("events_check_data"), 7.5); + rEventSelection.fill(HIST("tracksCheckData"), 3.5); if (cQAplots) { + hPID.fill(HIST("After/hDcaxyPi"), track2.dcaXY()); + hPID.fill(HIST("After/hDcaxyKa"), track1.dcaXY()); + hPID.fill(HIST("After/hDcazPi"), track2.dcaZ()); + hPID.fill(HIST("After/hDcazKa"), track1.dcaZ()); + + hPID.fill(HIST("After/hTPCnsigKa_mult_pt"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + hPID.fill(HIST("After/hTPCnsigPi_mult_pt"), track2.tpcNSigmaPi(), multiplicity, track2.pt()); + hPID.fill(HIST("After/hTOFnsigKa_mult_pt"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + hPID.fill(HIST("After/hTOFnsigPi_mult_pt"), track2.tofNSigmaKa(), multiplicity, track2.pt()); hOthers.fill(HIST("hEta_after"), track1.eta()); hOthers.fill(HIST("hCRFC_after"), track1.tpcCrossedRowsOverFindableCls()); hPID.fill(HIST("After/hNsigmaKaonTPC_after"), track1.pt(), track1.tpcNSigmaKa()); @@ -648,14 +973,24 @@ struct Kstarqa { if (track1.globalIndex() == track2.globalIndex()) continue; - rEventSelection.fill(HIST("events_check_data"), 8.5); + rEventSelection.fill(HIST("tracksCheckData"), 4.5); + + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); + mother = daughter1 + daughter2; // Kstar meson + + if (selectionConfig.isApplyCutsOnMother) { + if (mother.Pt() >= selectionConfig.cMaxPtMotherCut) // excluding candidates in overflow + continue; + if (mother.M() >= selectionConfig.cMaxMinvMotherCut) // excluding candidates in overflow + continue; + } + + hOthers.fill(HIST("hKstar_Rap"), mother.Rapidity()); + hOthers.fill(HIST("hKstar_Eta"), mother.Eta()); - lv3.SetPtEtaPhiM(0.0, 0.0, 0.0, 0.0); - lv1.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi(), massKa); - lv2.SetPtEtaPhiM(track2.pt(), track2.eta(), track2.phi(), massPi); - lv3 = lv1 + lv2; isMix = false; - fillInvMass(track1, track2, lv2, lv3, multiplicity, isMix); + fillInvMass(daughter1, daughter2, mother, multiplicity, isMix, track1, track2); } } @@ -666,144 +1001,172 @@ struct Kstarqa { ConfigurableAxis axisMultiplicity{"axisMultiplicity", {2000, 0, 10000}, "TPC multiplicity axis for ME mixing"}; // using BinningTypeTPCMultiplicity = ColumnBinningPolicy; - // using BinningTypeCentralityM = ColumnBinningPolicy; + using BinningTypeCentralityM = ColumnBinningPolicy; using BinningTypeVertexContributor = ColumnBinningPolicy; + using BinningTypeFT0A = ColumnBinningPolicy; + using BinningTypeFV0A = ColumnBinningPolicy; BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicity}, true}; - // BinningTypeCentralityM binningOnCentrality{{axisVertex, axisMultiplicity}, true}; + BinningTypeCentralityM binningOnCentrality{{axisVertex, axisMultiplicity}, true}; + BinningTypeFT0A binningOnFT0A{{axisVertex, axisMultiplicity}, true}; + BinningTypeFV0A binningOnFV0A{{axisVertex, axisMultiplicity}, true}; - SameKindPair pair1{binningOnPositions, cfgNoMixedEvents, -1, &cache}; - // SameKindPair pair2{binningOnCentrality, cfgNoMixedEvents, -1, &cache}; + SameKindPair pair1{binningOnPositions, selectionConfig.cfgNoMixedEvents, -1, &cache}; + SameKindPair pair2{binningOnCentrality, selectionConfig.cfgNoMixedEvents, -1, &cache}; + SameKindPair pair3{binningOnFT0A, selectionConfig.cfgNoMixedEvents, -1, &cache}; + SameKindPair pair4{binningOnFV0A, selectionConfig.cfgNoMixedEvents, -1, &cache}; - void processME(EventCandidates const&, TrackCandidates const&) + void processME(EventCandidatesMix const&, TrackCandidates const&) { - for (const auto& [c1, tracks1, c2, tracks2] : pair1) { - - if (!c1.sel8()) { - continue; - } - if (!c2.sel8()) { - continue; - } - - if (timFrameEvsel && (!c1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !c2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - continue; - } - - if (cTVXEvsel && (!c1.selection_bit(aod::evsel::kIsTriggerTVX) || !c2.selection_bit(aod::evsel::kIsTriggerTVX))) { - return; - } - - multiplicity = c1.centFT0M(); - - for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + // Map estimator to pair and multiplicity accessor + auto runMixing = [&](auto& pair, auto multiplicityGetter) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { + // if (!c1.sel8() || !c2.sel8()) + // continue; - if (!selectionTrack(t1)) // Kaon - continue; - if (!selectionTrack(t2)) // Pion - continue; - if (!selectionPID(t1, 1)) // Kaon - continue; - if (!selectionPID(t2, 0)) // Pion + if (!selectionEvent(c1, false) || !selectionEvent(c2, false)) { continue; + } - // if (cMID) { - // if (cMIDselectionPID(t1, 0)) // misidentified as pion - // continue; - // if (cMIDselectionPID(t1, 2)) // misidentified as proton - // continue; - // if (cMIDselectionPID(t2, 1)) // misidentified as kaon - // continue; - // } + multiplicity = multiplicityGetter(c1); - // TLorentzVector vKAON; - // vKAON.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massKa); - // TLorentzVector vPION; - // vPION.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massPi); - lv3.SetPtEtaPhiM(0.0, 0.0, 0.0, 0.0); - lv1.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massKa); - lv2.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massPi); + for (const auto& [t1, t2] : o2::soa::combinations( + o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (!selectionTrack(t1) || !selectionTrack(t2)) + continue; + if (!selectionPID(t1, 1) || !selectionPID(t2, 0)) + continue; - // TLorentzVector kstar = vKAON + vPION; - lv3 = lv1 + lv2; - isMix = true; + daughter1 = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), massPi); + mother = daughter1 + daughter2; - // if (std::abs(kstar.Rapidity()) < 0.5) { - // fillInvMass(t1, t2, vPION, kstar, multiplicity, isMix); + isMix = true; - if (std::abs(lv3.Rapidity()) < 0.5) { - fillInvMass(t1, t2, lv2, lv3, multiplicity, isMix); + if (std::abs(mother.Rapidity()) < selectionConfig.rapidityMotherData) { + fillInvMass(daughter1, daughter2, mother, multiplicity, isMix, t1, t2); + } } } + }; + + // Call mixing based on selected estimator + if (cSelectMultEstimator == kFT0M) { + runMixing(pair1, [](const auto& c) { return c.centFT0M(); }); + } else if (cSelectMultEstimator == kFT0A) { + runMixing(pair2, [](const auto& c) { return c.centFT0A(); }); + } else if (cSelectMultEstimator == kFT0C) { + runMixing(pair3, [](const auto& c) { return c.centFT0C(); }); + } else if (cSelectMultEstimator == kFV0A) { + runMixing(pair4, [](const auto& c) { return c.centFV0A(); }); } } PROCESS_SWITCH(Kstarqa, processME, "Process Mixed event", true); + // void processGen(EventMCGenerated::iterator const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& collisions) void processGen(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& collisions) { - rEventSelection.fill(HIST("events_check"), 0.5); - if (std::abs(mcCollision.posZ()) < cutzvertex) { - rEventSelection.fill(HIST("events_check"), 1.5); - } + rEventSelection.fill(HIST("eventsCheckGen"), 0.5); int nChInel = 0; for (const auto& mcParticle : mcParticles) { auto pdgcode = std::abs(mcParticle.pdgCode()); - if (mcParticle.isPhysicalPrimary() && (pdgcode == 211 || pdgcode == 321 || pdgcode == 2212 || pdgcode == 11 || pdgcode == 13)) { + if (mcParticle.isPhysicalPrimary() && (pdgcode == PDG_t::kPiPlus || pdgcode == PDG_t::kKPlus || pdgcode == PDG_t::kProton || pdgcode == std::abs(PDG_t::kElectron) || pdgcode == std::abs(PDG_t::kMuonMinus))) { if (std::abs(mcParticle.eta()) < 1.0) { nChInel = nChInel + 1; } } } - if (nChInel > 0 && std::abs(mcCollision.posZ()) < cutzvertex) - rEventSelection.fill(HIST("events_check"), 2.5); + if (nChInel > 0 && std::abs(mcCollision.posZ()) < selectionConfig.cutzvertex) + rEventSelection.fill(HIST("eventsCheckGen"), 1.5); std::vector selectedEvents(collisions.size()); int nevts = 0; + multiplicity = -1.0; + // float impactParameter = mcCollision.impactParameter(); - multiplicity = 0; - for (const auto& collision : collisions) { - // if (!collision.sel8() || std::abs(collision.mcCollision().posZ()) > cutzvertex) { - if (std::abs(collision.mcCollision().posZ()) > cutzvertex) { - continue; - } + // if (selectionConfig.isINELgt0 && !mcCollision.isInelGt0()) { + // return; + // } + rEventSelection.fill(HIST("eventsCheckGen"), 2.5); - if (timFrameEvsel && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { - continue; - } - if (cTVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { + for (const auto& collision : collisions) { + // if (!collision.sel8() || std::abs(collision.mcCollision().posZ()) > selectionConfig.cutzvertex) { + // if (std::abs(collision.mcCollision().posZ()) > selectionConfig.cutzvertex) { + // continue; + // } + // if (!collision.sel8()) { + // continue; + // } + // if (selectionConfig.isNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + // continue; + // } + // if (selectionConfig.isTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + // continue; + // } + // if (selectionConfig.isINELgt0 && !collision.isInelGt0()) { + // continue; + // } + // if (selectionConfig.isNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + // continue; + // } + // if (selectionConfig.isGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + // continue; + // } + if (!selectionEvent(collision, true)) { continue; } multiplicity = collision.centFT0M(); + hInvMass.fill(HIST("h1GenMult"), multiplicity); + + int occupancy = collision.trackOccupancyInTimeRange(); + rEventSelection.fill(HIST("hOccupancy"), occupancy); + selectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); } selectedEvents.resize(nevts); - rEventSelection.fill(HIST("events_check"), 3.5); - const auto evtReconstructedAndSelected = std::find(selectedEvents.begin(), selectedEvents.end(), mcCollision.globalIndex()) != selectedEvents.end(); + for (const auto& mcParticle : mcParticles) { + if (std::abs(mcParticle.y()) < selectionConfig.rapidityMotherData && std::abs(mcParticle.pdgCode()) == o2::constants::physics::kK0Star892) { + // if (inelgt0MCgen) { + hInvMass.fill(HIST("hAllKstarGenCollisisons"), multiplicity, mcParticle.pt()); + // } + } + } + const auto evtReconstructedAndSelected = std::find(selectedEvents.begin(), selectedEvents.end(), mcCollision.globalIndex()) != selectedEvents.end(); + // if (inelgt0MCgen) { + hInvMass.fill(HIST("hAllGenCollisions"), multiplicity); + // } if (!cAllGenCollisions && !evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection return; } - rEventSelection.fill(HIST("events_check"), 4.5); + hInvMass.fill(HIST("hAllGenCollisions1Rec"), multiplicity); + rEventSelection.fill(HIST("eventsCheckGen"), 3.5); for (const auto& mcParticle : mcParticles) { - if (std::abs(mcParticle.y()) >= 0.5) { + + if (std::abs(mcParticle.y()) >= selectionConfig.rapidityMotherData) { continue; } - rEventSelection.fill(HIST("events_check"), 5.5); - if (std::abs(mcParticle.pdgCode()) != 313) { + if (selectionConfig.isApplyCutsOnMother) { + if (mcParticle.pt() >= selectionConfig.cMaxPtMotherCut) // excluding candidates in overflow + continue; + if ((std::sqrt(mcParticle.e() * mcParticle.e() - mcParticle.p() * mcParticle.p())) >= selectionConfig.cMaxMinvMotherCut) // excluding candidates in overflow + continue; + } + + if (std::abs(mcParticle.pdgCode()) != o2::constants::physics::kK0Star892) { continue; } - rEventSelection.fill(HIST("events_check"), 6.5); + hInvMass.fill(HIST("hAllKstarGenCollisisons1Rec"), multiplicity, mcParticle.pt()); auto kDaughters = mcParticle.daughters_as(); - if (kDaughters.size() != 2) { + if (kDaughters.size() != selectionConfig.noOfDaughters) { continue; } - rEventSelection.fill(HIST("events_check"), 7.5); auto passkaon = false; auto passpion = false; @@ -811,187 +1174,265 @@ struct Kstarqa { if (!kCurrentDaughter.isPhysicalPrimary()) { continue; } - rEventSelection.fill(HIST("events_check"), 8.5); - if (std::abs(kCurrentDaughter.pdgCode()) == 321) { - // if (kCurrentDaughter.pdgCode() == +321) { + if (std::abs(kCurrentDaughter.pdgCode()) == PDG_t::kKPlus) { passkaon = true; - rEventSelection.fill(HIST("events_check"), 9.5); + daughter1 = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); - } else if (std::abs(kCurrentDaughter.pdgCode()) == 211) { - //} else if (kCurrentDaughter.pdgCode() == -321) { + } else if (std::abs(kCurrentDaughter.pdgCode()) == PDG_t::kPiPlus) { passpion = true; - // rEventSelection.fill(HIST("events_check"), 10.5); + daughter2 = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massPi); } } if (passkaon && passpion) { - // if (mcParticle.pdgCode() > 0) + mother = daughter1 + daughter2; // Kstar meson hInvMass.fill(HIST("hk892GenpT"), mcParticle.pt(), multiplicity); - // else - // hInvMass.fill(HIST("hk892GenpTAnti"), mcParticle.pt()); + hInvMass.fill(HIST("hk892GenpT2"), mother.Pt(), multiplicity); + hInvMass.fill(HIST("h1genmass"), mother.M()); } } } PROCESS_SWITCH(Kstarqa, processGen, "Process Generated", false); - void processRec(EventCandidatesMC::iterator const& collision, TrackCandidatesMC const& tracks, aod::McParticles const&, aod::McCollisions const& /*mcCollisions*/) + // void processEvtLossSigLossMC(EventMCGenerated::iterator const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& recCollisions) + void processEvtLossSigLossMC(aod::McCollisions::iterator const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& recCollisions) { + // if (selectionConfig.isINELgt0 && !mcCollision.isInelGt0()) { + // return; + // } - // TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; - multiplicity = collision.centFT0M(); + auto impactPar = mcCollision.impactParameter(); + hInvMass.fill(HIST("MCcorrections/hImpactParameterGen"), impactPar); - rEventSelection.fill(HIST("events_checkrec"), 0.5); + bool isSelectedEvent = false; + auto multiplicity1 = -999.; + for (const auto& RecCollision : recCollisions) { + if (!selectionEvent(RecCollision, false)) + continue; + multiplicity1 = RecCollision.centFT0M(); + isSelectedEvent = true; + } - if (!collision.has_mcCollision()) { - return; + // Event loss + if (isSelectedEvent) { + hInvMass.fill(HIST("MCcorrections/hImpactParameterRec"), impactPar); + hInvMass.fill(HIST("MCcorrections/hImpactParametervsMultiplicity"), impactPar, multiplicity1); } - rEventSelection.fill(HIST("events_checkrec"), 1.5); - // if (std::abs(collision.mcCollision().posZ()) > cutzvertex || !collision.sel8()) { - if (std::abs(collision.mcCollision().posZ()) > cutzvertex) { + // Generated MC + for (const auto& mcPart : mcParticles) { + if (std::abs(mcPart.y()) >= selectionConfig.rapidityMotherData || std::abs(mcPart.pdgCode()) != o2::constants::physics::kK0Star892) + continue; + + // signal loss estimation + hInvMass.fill(HIST("MCcorrections/hSignalLossDenominator"), mcPart.pt(), impactPar); + if (isSelectedEvent) { + hInvMass.fill(HIST("MCcorrections/hSignalLossNumerator"), mcPart.pt(), impactPar); + } + } // end loop on gen particles + } + PROCESS_SWITCH(Kstarqa, processEvtLossSigLossMC, "Process Signal Loss, Event Loss", false); + + void processRec(EventCandidatesMC::iterator const& collision, TrackCandidatesMC const& tracks, aod::McParticles const&, aod::McCollisions const& /*mcCollisions*/) + { + + if (!collision.has_mcCollision()) { return; } - rEventSelection.fill(HIST("events_checkrec"), 2.5); - if (timFrameEvsel && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + if (selectionConfig.isINELgt0 && !collision.isInelGt0()) { return; } - rEventSelection.fill(HIST("events_checkrec"), 3.5); + multiplicity = collision.centFT0M(); + hInvMass.fill(HIST("hAllRecCollisions"), multiplicity); - if (cTVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { + if (!selectionEvent(collision, false)) { return; } - rEventSelection.fill(HIST("events_checkrec"), 4.5); + + // // if (std::abs(collision.mcCollision().posZ()) > selectionConfig.cutzvertex || !collision.sel8()) { + // if (std::abs(collision.mcCollision().posZ()) > selectionConfig.cutzvertex) { + // return; + // } + + // if (selectionConfig.isNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + // return; + // } + + // if (selectionConfig.isTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + // return; + // } + + // if (!collision.sel8()) { + // return; + // } + + // if (selectionConfig.isNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + // return; + // } + // if (selectionConfig.isGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + // return; + // } + + multiplicity = collision.centFT0M(); + hInvMass.fill(HIST("h1RecMult"), multiplicity); auto oldindex = -999; for (const auto& track1 : tracks) { if (!selectionTrack(track1)) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 5.5); if (!track1.has_mcParticle()) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 6.5); auto track1ID = track1.index(); for (const auto& track2 : tracks) { + rEventSelection.fill(HIST("recMCparticles"), 0.5); if (!track2.has_mcParticle()) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 7.5); + rEventSelection.fill(HIST("recMCparticles"), 1.5); if (!selectionTrack(track2)) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 8.5); + rEventSelection.fill(HIST("recMCparticles"), 2.5); auto track2ID = track2.index(); if (track2ID <= track1ID) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 9.5); + rEventSelection.fill(HIST("recMCparticles"), 3.5); if (track1.sign() * track2.sign() >= 0) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 10.5); + rEventSelection.fill(HIST("recMCparticles"), 4.5); const auto mctrack1 = track1.mcParticle(); const auto mctrack2 = track2.mcParticle(); int track1PDG = std::abs(mctrack1.pdgCode()); int track2PDG = std::abs(mctrack2.pdgCode()); - if (cQAplots && track1PDG == 211) { - hPID.fill(HIST("h1PID_TPC_kaon_MC"), track1.tpcNSigmaKa()); - hPID.fill(HIST("h1PID_TOF_kaon_MC"), track1.tofNSigmaKa()); + if (cQAplots && (mctrack2.pdgCode() == PDG_t::kPiPlus)) { // pion + hPID.fill(HIST("Before/h1PID_TPC_pos_pion"), track2.tpcNSigmaPi()); + hPID.fill(HIST("Before/h1PID_TOF_pos_pion"), track2.tofNSigmaPi()); + hPID.fill(HIST("Before/hNsigmaTPC_Pi_before"), track2.pt(), track2.tpcNSigmaPi()); + hPID.fill(HIST("Before/hNsigmaTOF_Pi_before"), track2.pt(), track2.tofNSigmaPi()); + } + if (cQAplots && (mctrack2.pdgCode() == PDG_t::kKPlus)) { // kaon + hPID.fill(HIST("Before/h1PID_TPC_pos_kaon"), track2.tpcNSigmaKa()); + hPID.fill(HIST("Before/h1PID_TOF_pos_kaon"), track2.tofNSigmaKa()); + hPID.fill(HIST("Before/hNsigmaTPC_Ka_before"), track2.pt(), track2.tpcNSigmaKa()); + hPID.fill(HIST("Before/hNsigmaTOF_Ka_before"), track2.pt(), track2.tofNSigmaKa()); + } + if (cQAplots && (mctrack2.pdgCode() == -PDG_t::kPiMinus)) { // negative track pion + hPID.fill(HIST("Before/h1PID_TPC_neg_pion"), track2.tpcNSigmaPi()); + hPID.fill(HIST("Before/h1PID_TOF_neg_pion"), track2.tofNSigmaPi()); + hPID.fill(HIST("Before/hNsigmaTPC_Pi_before"), track2.pt(), track2.tpcNSigmaPi()); + hPID.fill(HIST("Before/hNsigmaTOF_Pi_before"), track2.pt(), track2.tofNSigmaPi()); } - if (cQAplots && track1PDG == 321) { - hPID.fill(HIST("h1PID_TPC_pion_MC"), track1.tpcNSigmaPi()); - hPID.fill(HIST("h1PID_TOF_pion_MC"), track1.tofNSigmaPi()); + if (cQAplots && (mctrack2.pdgCode() == -PDG_t::kKMinus)) { // negative track kaon + hPID.fill(HIST("Before/h1PID_TPC_neg_kaon"), track2.tpcNSigmaKa()); + hPID.fill(HIST("Before/h1PID_TOF_neg_kaon"), track2.tofNSigmaKa()); + hPID.fill(HIST("Before/hNsigmaTPC_Ka_before"), track2.pt(), track2.tpcNSigmaKa()); + hPID.fill(HIST("Before/hNsigmaTOF_Ka_before"), track2.pt(), track2.tofNSigmaKa()); + } + if (cQAplots && (std::abs(mctrack1.pdgCode()) == PDG_t::kKPlus && std::abs(mctrack2.pdgCode()) == PDG_t::kPiPlus)) { + hPID.fill(HIST("Before/hNsigma_TPC_TOF_Ka_before"), track1.tpcNSigmaKa(), track1.tofNSigmaKa()); + hPID.fill(HIST("Before/hNsigma_TPC_TOF_Pi_before"), track2.tpcNSigmaPi(), track2.tofNSigmaPi()); } if (!mctrack1.isPhysicalPrimary()) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 11.5); if (!mctrack2.isPhysicalPrimary()) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 12.5); + rEventSelection.fill(HIST("recMCparticles"), 5.5); - // if (!(track1PDG == 321 && track2PDG == 211)) { + // if (!(track1PDG == PDG_t::kKPlus && track2PDG == PDG_t::kPiPlus)) { // continue; // } - if (!(track1PDG == 211) && !(track1PDG == 321)) { + if ((track1PDG != PDG_t::kPiPlus) && (track1PDG != PDG_t::kKPlus)) { continue; } - if (!(track2PDG == 211) && !(track2PDG == 321)) { + if ((track2PDG != PDG_t::kPiPlus) && (track2PDG != PDG_t::kKPlus)) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 13.5); - - if (track1PDG == 211) { - if (!(selectionPID(track1, 0) && selectionPID(track2, 1))) { // pion and kaon - continue; - } - } else { - if (!(selectionPID(track1, 1) && selectionPID(track2, 0))) { // kaon and pion - continue; - } - } - rEventSelection.fill(HIST("events_checkrec"), 14.5); + rEventSelection.fill(HIST("recMCparticles"), 6.5); for (const auto& mothertrack1 : mctrack1.mothers_as()) { for (const auto& mothertrack2 : mctrack2.mothers_as()) { if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 15.5); if (mothertrack1.globalIndex() != mothertrack2.globalIndex()) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 16.5); + rEventSelection.fill(HIST("recMCparticles"), 7.5); if (!mothertrack1.producedByGenerator()) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 17.5); + rEventSelection.fill(HIST("recMCparticles"), 8.5); - if (std::abs(mothertrack1.y()) >= 0.5) { + if (std::abs(mothertrack1.y()) >= selectionConfig.rapidityMotherData) { continue; } - rEventSelection.fill(HIST("events_checkrec"), 18.5); + rEventSelection.fill(HIST("recMCparticles"), 9.5); - if (std::abs(mothertrack1.pdgCode()) != 313) { + if (std::abs(mothertrack1.pdgCode()) != o2::constants::physics::kK0Star892) { continue; } + rEventSelection.fill(HIST("recMCparticles"), 10.5); + + if (track1PDG == PDG_t::kPiPlus) { + if (!applypTdepPID && !(selectionPID(track1, 0) && selectionPID(track2, 1))) { // pion and kaon + continue; + } else if (applypTdepPID && !(selectionPIDNew(track1, 0) && selectionPIDNew(track2, 1))) { // pion and kaon + continue; + } + } else { + if (!applypTdepPID && !(selectionPID(track1, 1) && selectionPID(track2, 0))) { // kaon and pion + continue; + } else if (applypTdepPID && !(selectionPIDNew(track1, 1) && selectionPIDNew(track2, 0))) { // kaon and pion + continue; + } + } + + if (selectionConfig.isApplyCutsOnMother) { + if (mothertrack1.pt() >= selectionConfig.cMaxPtMotherCut) // excluding candidates in overflow + continue; + if ((std::sqrt(mothertrack1.e() * mothertrack1.e() - mothertrack1.p() * mothertrack1.p())) >= selectionConfig.cMaxMinvMotherCut) // excluding candidates in overflow + continue; + } if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { hInvMass.fill(HIST("h1KSRecsplit"), mothertrack1.pt()); continue; } + rEventSelection.fill(HIST("recMCparticles"), 11.5); + oldindex = mothertrack1.globalIndex(); - pvec0 = std::array{track1.px(), track1.py(), track1.pz()}; - pvec1 = std::array{track2.px(), track2.py(), track2.pz()}; - auto arrMomrec = std::array{pvec0, pvec1}; - auto motherP = mothertrack1.p(); - auto motherE = mothertrack1.e(); - auto genMass = std::sqrt(motherE * motherE - motherP * motherP); - auto recMass = RecoDecay::m(arrMomrec, std::array{massKa, massPi}); - auto recpt = std::sqrt((track1.px() + track2.px()) * (track1.px() + track2.px()) + (track1.py() + track2.py()) * (track1.py() + track2.py())); - //// Resonance reconstruction - // lDecayDaughter1.SetXYZM(track1.px(), track1.py(), track1.pz(), massKa); - // lDecayDaughter2.SetXYZM(track2.px(), track2.py(), track2.pz(), massPi); - // lResonance = lDecayDaughter1 + lDecayDaughter2; - - hInvMass.fill(HIST("h1KstarRecMass"), recMass); - hInvMass.fill(HIST("h1genmass"), genMass); - hInvMass.fill(HIST("h2KstarRecpt1"), mothertrack1.pt(), multiplicity); - hInvMass.fill(HIST("h2KstarRecpt2"), recpt, multiplicity); + if (track1.sign() * track2.sign() < 0) { + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); + mother = daughter1 + daughter2; // Kstar meson + + hInvMass.fill(HIST("h2KstarRecpt2"), mothertrack1.pt(), multiplicity, std::sqrt(mothertrack1.e() * mothertrack1.e() - mothertrack1.p() * mothertrack1.p())); + + if (applyRecMotherRapidity && mother.Rapidity() >= selectionConfig.rapidityMotherData) { + continue; + } + + hInvMass.fill(HIST("h1KstarRecMass"), mother.M()); + hInvMass.fill(HIST("h2KstarRecpt1"), mother.Pt(), multiplicity, mother.M()); + } } } } diff --git a/PWGLF/Tasks/Resonances/lambda1405analysis.cxx b/PWGLF/Tasks/Resonances/lambda1405analysis.cxx new file mode 100644 index 00000000000..dc134339d63 --- /dev/null +++ b/PWGLF/Tasks/Resonances/lambda1405analysis.cxx @@ -0,0 +1,465 @@ +// 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. + +/// \file lambda1405analysis.cxx +/// \brief Analysis task for lambda1405 via sigma kink decay +/// \author Francesco Mazzaschi + +#include "PWGLF/DataModel/LFKinkDecayTables.h" +#include "PWGLF/DataModel/LFLambda1405Table.h" + +#include "Common/Core/PID/PIDTOF.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/PID.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using TracksFull = soa::Join; +using CollisionsFull = soa::Join; +using CollisionsFullMC = soa::Join; + +struct lambda1405candidate { + // Columns for Lambda(1405) candidate + float mass = -1; // Invariant mass of the Lambda(1405) candidate + float massXi1530 = -1; // Invariant mass of the Xi(1530) candidate + float px = -1; // Px of the Lambda(1405) candidate + float py = -1; // Py of the Lambda(1405) candidate + float pz = -1; // Pz of the Lambda(1405) candidate + float pt() const { return std::sqrt(px * px + py * py); } // pT of the Lambda(1405 candidate + + bool isSigmaPlus = false; // True if compatible with Sigma+ + bool isSigmaMinus = false; // True if compatible with Sigma- + float sigmaMinusMass = -1; // Invariant mass of the Sigma- candidate + float sigmaPlusMass = -1; // Invariant mass of the Sigma+ candidate + float xiMinusMass = -1; // Invariant mass of the Xi- candidate + int sigmaSign = 0; // Sign of the Sigma candidate: 1 for matter, -1 for antimatter + float sigmaPt = -1; // pT of the Sigma daughter + float sigmaAlphaAP = -1; // Alpha of the Sigma + float sigmaQtAP = -1; // qT of the Sigma + float kinkPt = -1; // pT of the kink daughter + float kinkTPCNSigmaPi = -1; // Number of sigmas for the pion candidate from Sigma kink in TPC + float kinkTOFNSigmaPi = -1; // Number of sigmas for the pion candidate from Sigma kink in TOF + float kinkTPCNSigmaPr = -1; // Number of sigmas for the proton candidate from Sigma kink in TPC + float kinkTOFNSigmaPr = -1; // Number of sigmas for the proton candidate from Sigma kink in TOF + float dcaKinkDauToPV = -1; // DCA of the kink daughter to the primary vertex + float sigmaRadius = -1; // Radius of the Sigma decay vertex + + float piPt = -1; // pT of the pion daughter + float nSigmaTPCPi = -1; // Number of sigmas for the pion candidate + float nSigmaTOFPi = -1; // Number of sigmas for the pion candidate using TOF + int kinkDauID = 0; // ID of the pion from Sigma decay in MC + int sigmaID = 0; // ID of the Sigma candidate in MC + int piID = 0; // ID of the pion candidate in MC +}; + +struct lambda1405analysis { + int lambda1405PdgCode = 102132; // PDG code for Lambda(1405) + lambda1405candidate lambda1405Cand; // Lambda(1405) candidate structure + Produces outputDataTable; // Output table for Lambda(1405) candidates + Produces outputDataTableMC; // Output table for Lambda(1405) candidates in MC + // Histograms are defined with HistogramRegistry + HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rLambda1405{"lambda1405", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + // Configurable for event selection + Configurable cutzvertex{"cutZVertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable cutEtaDaught{"cutEtaDaughter", 0.8f, "Eta cut for daughter tracks"}; + Configurable cutDCAtoPVSigma{"cutDCAtoPVSigma", 0.1f, "Max DCA to primary vertex for Sigma candidates (cm)"}; + Configurable cutDCAtoPVPiFromSigma{"cutDCAtoPVPiFromSigma", 2., "Min DCA to primary vertex for pion from Sigma candidates (cm)"}; + + Configurable cutUpperMass{"cutUpperMass", 1.6f, "Upper mass cut for Lambda(1405) candidates (GeV/c^2)"}; + Configurable cutSigmaRadius{"cutSigmaRadius", 20.f, "Minimum radius for Sigma candidates (cm)"}; + Configurable cutSigmaMass{"cutSigmaMass", 0.1, "Sigma mass window (MeV/c^2)"}; + Configurable cutNITSClusPi{"cutNITSClusPi", 5, "Minimum number of ITS clusters for pion candidate"}; + Configurable cutNTPCClusPi{"cutNTPCClusPi", 90, "Minimum number of TPC clusters for pion candidate"}; + Configurable cutNSigmaTPC{"cutNSigmaTPC", 3, "NSigmaTPCPion"}; + Configurable cutNSigmaTOF{"cutNSigmaTOF", 3, "NSigmaTOFPion"}; + + Configurable fillOutputTree{"fillOutputTree", true, "If true, fill the output tree with Lambda(1405) candidates"}; + Configurable doLSBkg{"doLikeSignBkg", false, "Use like-sign background"}; + Configurable useTOF{"useTOF", false, "Use TOF for PID for pion candidates"}; + + Preslice mKinkPerCol = aod::track::collisionId; + Preslice mPerColTracks = aod::track::collisionId; + + void init(InitContext const&) + { + // Axes + const AxisSpec ptAxis{100, -10, 10, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec ptPiAxis{100, -5, 5, "#it{p}_{T}^{#pi} (GeV/#it{c})"}; + const AxisSpec ptResolutionAxis{100, -0.5, 0.5, "#it{p}_{T}^{rec} - #it{p}_{T}^{gen} (GeV/#it{c})"}; + const AxisSpec massAxis{100, 1.3, 1.6, "m (GeV/#it{c}^{2})"}; + const AxisSpec massResolutionAxis{100, -0.1, 0.1, "m_{rec} - m_{gen} (GeV/#it{c}^{2})"}; + const AxisSpec nSigmaPiAxis{100, -5, 5, "n#sigma_{#pi}"}; + const AxisSpec sigmaMassAxis{100, 1.1, 1.4, "m (GeV/#it{c}^{2})"}; + const AxisSpec vertexZAxis{100, -15., 15., "vrtx_{Z} [cm]"}; + rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + + // lambda1405 to sigmaminus + rLambda1405.add("h2PtMass_0", "h2PtMass_0", {HistType::kTH2F, {ptAxis, massAxis}}); + rLambda1405.add("h2PtMassSigmaBeforeCuts_0", "h2PtMassSigmaBeforeCuts_0", {HistType::kTH2F, {ptAxis, sigmaMassAxis}}); + rLambda1405.add("h2PtMassSigma_0", "h2PtMassSigma_0", {HistType::kTH2F, {ptAxis, sigmaMassAxis}}); + rLambda1405.add("h2SigmaMassVsMass_0", "h2SigmaMassVsMass_0", {HistType::kTH2F, {massAxis, sigmaMassAxis}}); + rLambda1405.add("h2PtPiNSigma_0", "h2PtPiNSigma_0", {HistType::kTH2F, {ptPiAxis, nSigmaPiAxis}}); + rLambda1405.add("h2PtPiNSigmaTOF_0", "h2PtPiNSigmaTOF_0", {HistType::kTH2F, {ptPiAxis, nSigmaPiAxis}}); + // lambda1405 to sigmaplus + rLambda1405.add("h2PtMass_1", "h2PtMass_1", {HistType::kTH2F, {ptAxis, massAxis}}); + rLambda1405.add("h2PtMassSigmaBeforeCuts_1", "h2PtMassSigmaBeforeCuts_1", {HistType::kTH2F, {ptAxis, sigmaMassAxis}}); + rLambda1405.add("h2PtMassSigma_1", "h2PtMassSigma_1", {HistType::kTH2F, {ptAxis, sigmaMassAxis}}); + rLambda1405.add("h2SigmaMassVsMass_1", "h2SigmaMassVsMass_1", {HistType::kTH2F, {massAxis, sigmaMassAxis}}); + rLambda1405.add("h2PtPiNSigma_1", "h2PtPiNSigma_1", {HistType::kTH2F, {ptPiAxis, nSigmaPiAxis}}); + rLambda1405.add("h2PtPiNSigmaTOF_1", "h2PtPiNSigmaTOF_1", {HistType::kTH2F, {ptPiAxis, nSigmaPiAxis}}); + + if (doprocessMC) { + // Add MC histograms if needed, to sigmaminus + rLambda1405.add("h2MassResolution_0", "h2MassResolution_0", {HistType::kTH2F, {massAxis, massResolutionAxis}}); + rLambda1405.add("h2PtResolution_0", "h2PtResolution_0", {HistType::kTH2F, {ptAxis, ptResolutionAxis}}); + rLambda1405.add("h2PtMassMC_0", "h2PtMassMC_0", {HistType::kTH2F, {ptAxis, massAxis}}); + // Add MC histograms if needed, to sigmaplus + rLambda1405.add("h2MassResolution_1", "h2MassResolution_1", {HistType::kTH2F, {massAxis, massResolutionAxis}}); + rLambda1405.add("h2PtResolution_1", "h2PtResolution_1", {HistType::kTH2F, {ptAxis, ptResolutionAxis}}); + rLambda1405.add("h2PtMassMC_1", "h2PtMassMC_1", {HistType::kTH2F, {ptAxis, massAxis}}); + } + } + + float alphaAP(const std::array& momMother, const std::array& momKink) + { + std::array momMissing = {momMother[0] - momKink[0], momMother[1] - momKink[1], momMother[2] - momKink[2]}; + float lQlP = std::inner_product(momMother.begin(), momMother.end(), momKink.begin(), 0.f); + float lQlN = std::inner_product(momMother.begin(), momMother.end(), momMissing.begin(), 0.f); + return (lQlP - lQlN) / (lQlP + lQlN); + } + + float qtAP(const std::array& momMother, const std::array& momKink) + { + float dp = std::inner_product(momMother.begin(), momMother.end(), momKink.begin(), 0.f); + float p2V0 = std::inner_product(momMother.begin(), momMother.end(), momMother.begin(), 0.f); + float p2A = std::inner_product(momKink.begin(), momKink.end(), momKink.begin(), 0.f); + return std::sqrt(p2A - dp * dp / p2V0); + } + + template + bool selectPiTrack(const Ttrack& candidate, bool piFromSigma) + { + if (std::abs(candidate.tpcNSigmaPi()) > cutNSigmaTPC || candidate.tpcNClsFound() < cutNTPCClusPi || std::abs(candidate.eta()) > cutEtaDaught) { + return false; + } + if (piFromSigma) { + return true; + } + + if (candidate.itsNCls() < cutNITSClusPi) { + return false; + } + + if (useTOF && !candidate.hasTOF()) { + return false; + } + + if (useTOF && std::abs(candidate.tofNSigmaPi()) > cutNSigmaTOF) { + return false; + } + + return true; // Track is selected + } + + template + bool selectProTrack(const Ttrack& candidate, bool prFromSigma) + { + if (std::abs(candidate.tpcNSigmaPr()) > cutNSigmaTPC || candidate.tpcNClsFound() < cutNTPCClusPi || std::abs(candidate.eta()) > cutEtaDaught) { + return false; + } + if (prFromSigma) { + return true; + } + if (candidate.itsNCls() < cutNITSClusPi) { + return false; + } + if (useTOF && !candidate.hasTOF()) { + return false; + } + if (useTOF && std::abs(candidate.tofNSigmaPr()) > cutNSigmaTOF) { + return false; + } + return true; // Track is selected + } + + bool selectCandidate(aod::KinkCands::iterator const& sigmaCand, TracksFull const& tracks) + { + auto kinkDauTrack = sigmaCand.trackDaug_as(); + bool isPiKink = selectPiTrack(kinkDauTrack, true); + bool isProKink = selectProTrack(kinkDauTrack, true); + if (!isPiKink && !isProKink) { + return false; + } + + if (isPiKink) { + rLambda1405.fill(HIST("h2PtMassSigmaBeforeCuts_0"), sigmaCand.mothSign() * sigmaCand.ptMoth(), sigmaCand.mSigmaMinus()); + rLambda1405.fill(HIST("h2PtPiNSigma_0"), sigmaCand.mothSign() * kinkDauTrack.pt(), kinkDauTrack.tpcNSigmaPi()); + } + if (isProKink) { + rLambda1405.fill(HIST("h2PtMassSigmaBeforeCuts_1"), sigmaCand.mothSign() * sigmaCand.ptMoth(), sigmaCand.mSigmaPlus()); + rLambda1405.fill(HIST("h2PtPiNSigma_1"), sigmaCand.mothSign() * kinkDauTrack.pt(), kinkDauTrack.tpcNSigmaPr()); + } + + lambda1405Cand.isSigmaPlus = isProKink && (sigmaCand.mSigmaPlus() > o2::constants::physics::MassSigmaPlus - cutSigmaMass && sigmaCand.mSigmaPlus() < o2::constants::physics::MassSigmaPlus + cutSigmaMass); + lambda1405Cand.isSigmaMinus = isPiKink && (sigmaCand.mSigmaMinus() > o2::constants::physics::MassSigmaMinus - cutSigmaMass && sigmaCand.mSigmaMinus() < o2::constants::physics::MassSigmaMinus + cutSigmaMass); + if (!lambda1405Cand.isSigmaPlus && !lambda1405Cand.isSigmaMinus) { + return false; + } + float sigmaRad = std::hypot(sigmaCand.xDecVtx(), sigmaCand.yDecVtx()); + if (std::abs(sigmaCand.dcaMothPv()) > cutDCAtoPVSigma || std::abs(sigmaCand.dcaDaugPv()) < cutDCAtoPVPiFromSigma || sigmaRad < cutSigmaRadius) { + return false; + } + + for (const auto& piTrack : tracks) { + if (!doLSBkg) { + if (piTrack.sign() == sigmaCand.mothSign()) { + continue; + } + } else { + if (piTrack.sign() != sigmaCand.mothSign()) { + continue; + } + } + + if (!selectPiTrack(piTrack, false)) { + continue; + } + + auto kinkDauMom = std::array{sigmaCand.pxDaug(), sigmaCand.pyDaug(), sigmaCand.pzDaug()}; + auto sigmaMom = std::array{sigmaCand.pxMoth(), sigmaCand.pyMoth(), sigmaCand.pzMoth()}; + auto piMom = std::array{piTrack.px(), piTrack.py(), piTrack.pz()}; + float invMass = RecoDecay::m(std::array{sigmaMom, piMom}, std::array{o2::constants::physics::MassSigmaMinus, o2::constants::physics::MassPiPlus}); + float invMassXiPi = RecoDecay::m(std::array{sigmaMom, kinkDauMom}, std::array{o2::constants::physics::MassXiMinus, o2::constants::physics::MassPiPlus}); + if (invMass > cutUpperMass) { + continue; + } + + lambda1405Cand.kinkDauID = kinkDauTrack.globalIndex(); + lambda1405Cand.sigmaID = sigmaCand.globalIndex(); + lambda1405Cand.piID = piTrack.globalIndex(); + + lambda1405Cand.px = sigmaMom[0] + piMom[0]; + lambda1405Cand.py = sigmaMom[1] + piMom[1]; + lambda1405Cand.pz = sigmaMom[2] + piMom[2]; + lambda1405Cand.mass = invMass; + lambda1405Cand.massXi1530 = invMassXiPi; + + lambda1405Cand.sigmaMinusMass = sigmaCand.mSigmaMinus(); + lambda1405Cand.sigmaPlusMass = sigmaCand.mSigmaPlus(); + lambda1405Cand.xiMinusMass = sigmaCand.mXiMinus(); + lambda1405Cand.sigmaSign = sigmaCand.mothSign(); + lambda1405Cand.sigmaAlphaAP = alphaAP(sigmaMom, kinkDauMom); + lambda1405Cand.sigmaQtAP = qtAP(sigmaMom, kinkDauMom); + lambda1405Cand.sigmaPt = sigmaCand.ptMoth(); + lambda1405Cand.sigmaRadius = sigmaRad; + lambda1405Cand.kinkPt = kinkDauTrack.pt(); + lambda1405Cand.kinkTPCNSigmaPi = kinkDauTrack.tpcNSigmaPi(); + lambda1405Cand.kinkTOFNSigmaPi = kinkDauTrack.tofNSigmaPi(); + lambda1405Cand.kinkTPCNSigmaPr = kinkDauTrack.tpcNSigmaPr(); + lambda1405Cand.kinkTOFNSigmaPr = kinkDauTrack.tofNSigmaPr(); + lambda1405Cand.dcaKinkDauToPV = sigmaCand.dcaDaugPv(); + + lambda1405Cand.piPt = piTrack.pt(); + lambda1405Cand.nSigmaTPCPi = piTrack.tpcNSigmaPi(); + if (useTOF) { + lambda1405Cand.nSigmaTOFPi = piTrack.tofNSigmaPi(); + } else { + lambda1405Cand.nSigmaTOFPi = -999; // Not used if TOF is not enabled + } + return true; // Candidate is selected + } + return false; // No valid pion track found + } + + template + bool checkSigmaKinkMC(const mcTrack& mcTrackSigma, const mcTrack& mcTrackKinkDau, float sigmaAbsPDG, float kinkAbsPDG, aod::McParticles const&) + { + if (std::abs(mcTrackSigma.pdgCode()) != sigmaAbsPDG || std::abs(mcTrackKinkDau.pdgCode()) != kinkAbsPDG) { + return false; // Not a valid Sigma kink decay + } + if (!mcTrackKinkDau.has_mothers()) { + return false; // No mothers found + } + // Check if the kink comes from the Sigma + bool isKinkFromSigma = false; + for (const auto& mcMother : mcTrackKinkDau.template mothers_as()) { + if (mcMother.globalIndex() == mcTrackSigma.globalIndex()) { + isKinkFromSigma = true; + break; + } + } + return isKinkFromSigma; // Return true if the kink comes from the Sigma + } + + void processData(CollisionsFull::iterator const& collision, aod::KinkCands const& kinkCands, TracksFull const& tracks) + { + if (std::abs(collision.posZ()) > cutzvertex || !collision.sel8()) { + return; + } + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + for (const auto& sigmaCand : kinkCands) { + if (selectCandidate(sigmaCand, tracks)) { + if (lambda1405Cand.isSigmaMinus) { + rLambda1405.fill(HIST("h2PtMass_0"), lambda1405Cand.sigmaSign * lambda1405Cand.pt(), lambda1405Cand.mass); + rLambda1405.fill(HIST("h2PtMassSigma_0"), lambda1405Cand.sigmaSign * lambda1405Cand.sigmaPt, lambda1405Cand.sigmaMinusMass); + rLambda1405.fill(HIST("h2SigmaMassVsMass_0"), lambda1405Cand.mass, lambda1405Cand.sigmaMinusMass); + rLambda1405.fill(HIST("h2PtPiNSigmaTOF_0"), lambda1405Cand.sigmaSign * lambda1405Cand.piPt, lambda1405Cand.nSigmaTOFPi); + } + if (lambda1405Cand.isSigmaPlus) { + rLambda1405.fill(HIST("h2PtMass_1"), lambda1405Cand.sigmaSign * lambda1405Cand.pt(), lambda1405Cand.mass); + rLambda1405.fill(HIST("h2PtMassSigma_1"), lambda1405Cand.sigmaSign * lambda1405Cand.sigmaPt, lambda1405Cand.sigmaPlusMass); + rLambda1405.fill(HIST("h2SigmaMassVsMass_1"), lambda1405Cand.mass, lambda1405Cand.sigmaPlusMass); + rLambda1405.fill(HIST("h2PtPiNSigmaTOF_1"), lambda1405Cand.sigmaSign * lambda1405Cand.piPt, lambda1405Cand.nSigmaTOFPi); + } + if (fillOutputTree) { + outputDataTable(lambda1405Cand.px, lambda1405Cand.py, lambda1405Cand.pz, + lambda1405Cand.mass, lambda1405Cand.massXi1530, + lambda1405Cand.sigmaMinusMass, lambda1405Cand.sigmaPlusMass, lambda1405Cand.xiMinusMass, + lambda1405Cand.sigmaPt, lambda1405Cand.sigmaAlphaAP, lambda1405Cand.sigmaQtAP, lambda1405Cand.sigmaRadius, + lambda1405Cand.kinkPt, + lambda1405Cand.kinkTPCNSigmaPi, lambda1405Cand.kinkTOFNSigmaPi, + lambda1405Cand.kinkTPCNSigmaPr, lambda1405Cand.kinkTOFNSigmaPr, + lambda1405Cand.dcaKinkDauToPV, + lambda1405Cand.nSigmaTPCPi, lambda1405Cand.nSigmaTOFPi); + } + } + } + } + PROCESS_SWITCH(lambda1405analysis, processData, "Data processing", true); + + void processMC(CollisionsFullMC const& collisions, aod::KinkCands const& kinkCands, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const& particlesMC, TracksFull const& tracks) + { + for (const auto& collision : collisions) { + if (std::abs(collision.posZ()) > cutzvertex || !collision.sel8()) { + continue; + } + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + auto sigmaCandsPerCol = kinkCands.sliceBy(mKinkPerCol, collision.globalIndex()); + auto tracksPerCol = tracks.sliceBy(mPerColTracks, collision.globalIndex()); + for (const auto& sigmaCand : sigmaCandsPerCol) { + if (selectCandidate(sigmaCand, tracksPerCol)) { + // Do MC association + auto mcLabPiKink = trackLabelsMC.rawIteratorAt(lambda1405Cand.kinkDauID); + auto mcLabSigma = trackLabelsMC.rawIteratorAt(lambda1405Cand.sigmaID); + auto mcLabPi = trackLabelsMC.rawIteratorAt(lambda1405Cand.piID); + if (!mcLabSigma.has_mcParticle() || mcLabPiKink.has_mcParticle() || mcLabPi.has_mcParticle()) { + continue; // Skip if no valid MC association + } + auto mcTrackKink = mcLabPiKink.mcParticle_as(); + auto mcTrackSigma = mcLabSigma.mcParticle_as(); + auto mcTrackPi = mcLabPi.mcParticle_as(); + + bool isSigmaMinusKink = checkSigmaKinkMC(mcTrackSigma, mcTrackKink, 3122, 211, particlesMC); + bool isSigmaPlusToPiKink = checkSigmaKinkMC(mcTrackSigma, mcTrackKink, 3222, 211, particlesMC); + bool isSigmaPlusToPrKink = checkSigmaKinkMC(mcTrackSigma, mcTrackKink, 3222, 2212, particlesMC); + + if (!isSigmaMinusKink && !isSigmaPlusToPiKink && !isSigmaPlusToPrKink) { + continue; // Skip if not a valid Sigma kink decay + } + + if (std::abs(mcTrackPi.pdgCode()) != 211) { + continue; // Skip if not a valid pion candidate + } + + if (!mcTrackSigma.has_mothers() || !mcTrackPi.has_mothers()) { + continue; // Skip if no mothers found + } + + // check that labpi and labsigma have the same mother (a lambda1405 candidate) + int lambda1405Id = -1; + for (const auto& piMother : mcTrackPi.mothers_as()) { + for (const auto& sigmaMother : mcTrackSigma.mothers_as()) { + if (piMother.globalIndex() == sigmaMother.globalIndex() && std::abs(piMother.pdgCode()) == lambda1405PdgCode) { + lambda1405Id = piMother.globalIndex(); + break; // Found the mother, exit loop + } + } + } + if (lambda1405Id == -1) { + continue; // Skip if the Sigma and pion do not share the same lambda1405 candidate + } + auto lambda1405Mother = particlesMC.rawIteratorAt(lambda1405Id); + float lambda1405Mass = std::sqrt(lambda1405Mother.e() * lambda1405Mother.e() - lambda1405Mother.p() * lambda1405Mother.p()); + if (lambda1405Cand.isSigmaMinus) { + rLambda1405.fill(HIST("h2PtMass_0"), lambda1405Cand.sigmaSign * lambda1405Cand.pt(), lambda1405Cand.mass); + rLambda1405.fill(HIST("h2PtMassSigma_0"), lambda1405Cand.sigmaSign * lambda1405Cand.sigmaPt, lambda1405Cand.sigmaMinusMass); + rLambda1405.fill(HIST("h2SigmaMassVsMass_0"), lambda1405Cand.mass, lambda1405Cand.sigmaMinusMass); + rLambda1405.fill(HIST("h2PtPiNSigma_0"), lambda1405Cand.piPt, lambda1405Cand.nSigmaTPCPi); + rLambda1405.fill(HIST("h2MassResolution_0"), lambda1405Mass, lambda1405Mass - lambda1405Cand.mass); + rLambda1405.fill(HIST("h2PtResolution_0"), lambda1405Cand.pt(), lambda1405Cand.pt() - lambda1405Mother.pt()); + } + if (lambda1405Cand.isSigmaPlus) { + rLambda1405.fill(HIST("h2PtMass_1"), lambda1405Cand.sigmaSign * lambda1405Cand.pt(), lambda1405Cand.mass); + rLambda1405.fill(HIST("h2PtMassSigma_1"), lambda1405Cand.sigmaSign * lambda1405Cand.sigmaPt, lambda1405Cand.sigmaPlusMass); + rLambda1405.fill(HIST("h2SigmaMassVsMass_1"), lambda1405Cand.mass, lambda1405Cand.sigmaPlusMass); + rLambda1405.fill(HIST("h2PtPiNSigma_1"), lambda1405Cand.piPt, lambda1405Cand.nSigmaTPCPi); + rLambda1405.fill(HIST("h2MassResolution_1"), lambda1405Mass, lambda1405Mass - lambda1405Cand.mass); + rLambda1405.fill(HIST("h2PtResolution_1"), lambda1405Cand.pt(), lambda1405Cand.pt() - lambda1405Mother.pt()); + } + + if (fillOutputTree) { + outputDataTableMC(lambda1405Cand.px, lambda1405Cand.py, lambda1405Cand.pz, + lambda1405Cand.mass, lambda1405Cand.massXi1530, + lambda1405Cand.sigmaMinusMass, lambda1405Cand.sigmaPlusMass, lambda1405Cand.xiMinusMass, + lambda1405Cand.sigmaPt, lambda1405Cand.sigmaAlphaAP, lambda1405Cand.sigmaQtAP, lambda1405Cand.sigmaRadius, + lambda1405Cand.kinkPt, + lambda1405Cand.kinkTPCNSigmaPi, lambda1405Cand.kinkTOFNSigmaPi, + lambda1405Cand.kinkTPCNSigmaPr, lambda1405Cand.kinkTOFNSigmaPr, + lambda1405Cand.dcaKinkDauToPV, + lambda1405Cand.nSigmaTPCPi, lambda1405Cand.nSigmaTOFPi, + lambda1405Mother.pt(), lambda1405Mass, mcTrackSigma.pdgCode(), mcTrackKink.pdgCode()); + } + } + } + } + + // Loop over generated particles to fill MC histograms + for (const auto& mcPart : particlesMC) { + if (std::abs(mcPart.pdgCode()) != lambda1405PdgCode) { + continue; // Only consider Lambda(1405) candidates + } + + if (!mcPart.has_daughters()) { + continue; // Skip if no daughters + } + + // Check if the Lambda(1405) has a Sigma daughter + bool hasSigmaDaughter = false; + int dauPdgCode = 0; + for (const auto& daughter : mcPart.daughters_as()) { + if (std::abs(daughter.pdgCode()) == 3122 || std::abs(daughter.pdgCode()) == 3222) { // Sigma PDG code + hasSigmaDaughter = true; + dauPdgCode = daughter.pdgCode(); + break; // Found a Sigma daughter, exit loop + } + } + if (!hasSigmaDaughter) { + continue; // Skip if no Sigma daughter found + } + + float mcMass = std::sqrt(mcPart.e() * mcPart.e() - mcPart.p() * mcPart.p()); + dauPdgCode ? rLambda1405.fill(HIST("h2PtMassMC_0"), mcPart.pt(), mcMass) : rLambda1405.fill(HIST("h2PtMassMC_1"), mcPart.pt(), mcMass); + } + } + PROCESS_SWITCH(lambda1405analysis, processMC, "MC processing", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Resonances/lambda1520SpherocityAnalysis.cxx b/PWGLF/Tasks/Resonances/lambda1520SpherocityAnalysis.cxx index d7303f3e5fd..b8d6cfeae29 100644 --- a/PWGLF/Tasks/Resonances/lambda1520SpherocityAnalysis.cxx +++ b/PWGLF/Tasks/Resonances/lambda1520SpherocityAnalysis.cxx @@ -15,6 +15,7 @@ #include #include +#include #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Centrality.h" @@ -515,7 +516,7 @@ struct lambdaAnalysis { } } - using resoCols = aod::ResoCollisions; + using resoCols = soa::Join; using resoTracks = aod::ResoTracks; void processData(resoCols::iterator const& collision, resoTracks const& tracks) diff --git a/PWGLF/Tasks/Resonances/lambda1520_PbPb.cxx b/PWGLF/Tasks/Resonances/lambda1520_PbPb.cxx index e7fc0ee3de9..d032d0c90aa 100644 --- a/PWGLF/Tasks/Resonances/lambda1520_PbPb.cxx +++ b/PWGLF/Tasks/Resonances/lambda1520_PbPb.cxx @@ -43,7 +43,7 @@ struct lambdaAnalysis_pb { Preslice perCollision = aod::track::collisionId; // Configurables. - Configurable ConfEvtOccupancyInTimeRange{"ConfEvtOccupancyInTimeRange", -1, "Evt sel: maximum track occupancy"}; + Configurable ConfEvtOccupancyInTimeRange{"ConfEvtOccupancyInTimeRange", false, "occupancy selection true or false"}; Configurable nBinsPt{"nBinsPt", 100, "N bins in pT histogram"}; Configurable nBinsInvM{"nBinsInvM", 120, "N bins in InvMass histogram"}; Configurable lambda1520id{"lambda1520id", 3124, "pdg"}; @@ -71,10 +71,8 @@ struct lambdaAnalysis_pb { Configurable cRejNsigmaTpcPi{"cRejNsigmaTpcPi", 3.0, "Reject tracks to improve purity of TPC PID"}; // TPC And TOF tracks // Configurable cRejNsigmaTpcPr{"cRejNsigmaTpcPr", 3.0, "Reject tracks to improve purity of TPC PID"}; Configurable cRejNsigmaTpcKa{"cRejNsigmaTpcKa", 3.0, "Reject tracks to improve purity of TPC PID"}; - Configurable cRejNsigmaTpcEl{"cRejNsigmaTpcEl", 3.0, "Reject tracks to improve purity of TPC PID"}; Configurable cRejNsigmakTpcPi{"cRejNsigmakTpcPi", 3.0, "Reject tracks to improve purity of TPC PID"}; Configurable cRejNsigmakTpcPr{"cRejNsigmakTpcPr", 3.0, "Reject tracks to improve purity of TPC PID"}; - Configurable cRejNsigmakTpcEl{"cRejNsigmakTpcEl", 3.0, "Reject tracks to improve purity of TPC PID"}; Configurable minnsigmatpcKa{"minnsigmatpcKa", -6.0, "Reject tracks to improve purity of TPC PID"}; Configurable minnsigmatpcPr{"minnsigmatpcPr", -6.0, "Reject tracks to improve purity of TPC PID"}; Configurable minnsigmatofKa{"minnsigmatofKa", -6.0, "Reject tracks to improve purity of TofPID"}; @@ -106,7 +104,7 @@ struct lambdaAnalysis_pb { ConfigurableAxis cMixVtxBins{"cMixVtxBins", {VARIABLE_WIDTH, -10.0f, -9.f, -8.f, -7.f, -6.f, -5.f, -4.f, -3.f, -2.f, -1.f, 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f}, "Mixing bins - z-vertex"}; ConfigurableAxis cMixMultBins{"cMixMultBins", {VARIABLE_WIDTH, 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 200.0f}, "Mixing bins - multiplicity"}; ConfigurableAxis cMixEPAngle{"cMixEPAngle", {VARIABLE_WIDTH, -1.5708f, -1.25664f, -0.942478f, -0.628319f, 0.f, 0.628319f, 0.942478f, 1.25664f, 1.5708f}, "event plane"}; - + ConfigurableAxis occupancy_bins{"occupancy_bins", {VARIABLE_WIDTH, 0.0, 100, 500, 600, 1000, 1100, 1500, 1600, 2000, 2100, 2500, 2600, 3000, 3100, 3500, 3600, 4000, 4100, 4500, 4600, 5000, 5100, 9999}, "Binning of the occupancy axis"}; // Histogram Registry. HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -126,8 +124,9 @@ struct lambdaAnalysis_pb { const AxisSpec axisVz(120, -12, 12, {"vz"}); const AxisSpec axisEP(120, -3.14, 3.14, {"#theta"}); const AxisSpec axisInvM(nBinsInvM, 1.44, 2.04, {"M_{inv} (GeV/c^{2})"}); + AxisSpec axisOccupancy = {occupancy_bins, "Occupancy [-40,100]"}; - histos.add("Event/h1d_ft0_mult_percentile", "FT0 (%)", kTH1F, {axisCent}); + histos.add("Event/h1d_ft0_mult_percentile", "FT0 (%)", kTH2F, {axisCent, axisOccupancy}); if (doprocessMix || doprocessMixDF || doprocessMixepDF) { histos.add("Event/mixing_vzVsmultpercentile", "FT0(%)", kTH3F, {axisCent, axisVz, axisEP}); } @@ -147,13 +146,11 @@ struct lambdaAnalysis_pb { histos.add("QAafter/Proton/h2d_pr_nsigma_tpc_pt", " Protons", kTH2F, {axisPt_pid, axisTPCNsigma}); histos.add("QAafter/Proton/h2d_Prpi_nsigma_tpc_p", " Protons pion", kTH2F, {axisPt_pid, axisTPCNsigma}); histos.add("QAafter/Proton/h2d_Prka_nsigma_tpc_p", " Protons kaon", kTH2F, {axisPt_pid, axisTPCNsigma}); - histos.add("QAafter/Proton/h2d_Prel_nsigma_tpc_p", " Protons electron", kTH2F, {axisPt_pid, axisTPCNsigma}); histos.add("QAafter/Proton/h2d_pr_nsigma_tpc_p", " Protons", kTH2F, {axisP_pid, axisTPCNsigma}); histos.add("QAafter/Proton/h2d_pr_nsigma_tof_pt", " Protons", kTH2F, {axisPt_pid, axisTOFNsigma}); histos.add("QAafter/Proton/h2d_pr_nsigma_tof_p", " Protons", kTH2F, {axisP_pid, axisTOFNsigma}); histos.add("QAafter/Proton/h2d_Prpi_nsigma_tof_p", " Protons pion", kTH2F, {axisP_pid, axisTOFNsigma}); histos.add("QAafter/Proton/h2d_Prka_nsigma_tof_p", " Protons kaon", kTH2F, {axisP_pid, axisTOFNsigma}); - histos.add("QAafter/Proton/h2d_Prel_nsigma_tof_p", " Protons electron", kTH2F, {axisP_pid, axisTOFNsigma}); histos.add("QAafter/Proton/h2d_pr_nsigma_tof_vs_tpc", "n#sigma(TOF) vs n#sigma(TPC) Protons", kTH2F, {axisTPCNsigma, axisTOFNsigma}); histos.add("QAafter/Kaon/hd_ka_pt", "p_{T}-spectra Kaons", kTH2F, {axisPt_pid, axisCent}); histos.add("QAafter/Kaon/h2d_ka_dca_z", "dca_{z} Kaons", kTH2F, {axisPt_pid, axisDCAz}); @@ -161,28 +158,26 @@ struct lambdaAnalysis_pb { histos.add("QAafter/Kaon/h2d_ka_dEdx_p", "TPC Signal Kaon", kTH2F, {axisP_pid, axisdEdx}); histos.add("QAafter/Kaon/h2d_Kapi_nsigma_tpc_p", " Kaons pion", kTH2F, {axisPt_pid, axisTPCNsigma}); histos.add("QAafter/Kaon/h2d_Kapr_nsigma_tpc_p", " Kaons proton", kTH2F, {axisP_pid, axisTPCNsigma}); - histos.add("QAafter/Kaon/h2d_Kael_nsigma_tpc_p", " Kaons electron", kTH2F, {axisP_pid, axisTPCNsigma}); histos.add("QAafter/Kaon/h2d_ka_nsigma_tpc_pt", " Kaons", kTH2F, {axisPt_pid, axisTPCNsigma}); histos.add("QAafter/Kaon/h2d_ka_nsigma_tpc_p", " Kaons", kTH2F, {axisP_pid, axisTPCNsigma}); histos.add("QAafter/Kaon/h2d_ka_nsigma_tof_pt", " Kaons", kTH2F, {axisPt_pid, axisTOFNsigma}); histos.add("QAafter/Kaon/h2d_ka_nsigma_tof_p", " Kaons", kTH2F, {axisP_pid, axisTOFNsigma}); histos.add("QAafter/Kaon/h2d_Kapi_nsigma_tof_p", " Kaons pion", kTH2F, {axisP_pid, axisTOFNsigma}); histos.add("QAafter/Kaon/h2d_Kapr_nsigma_tof_p", " Kaons proton", kTH2F, {axisP_pid, axisTOFNsigma}); - histos.add("QAafter/Kaon/h2d_Kael_nsigma_tof_p", " Kaons electron", kTH2F, {axisP_pid, axisTOFNsigma}); histos.add("QAafter/Kaon/h2d_ka_nsigma_tof_vs_tpc", "n#sigma(TOF) vs n#sigma(TPC) Kaons", kTH2F, {axisTPCNsigma, axisTOFNsigma}); // Analysis // Lambda Invariant Mass if (!doprocessMC) { - histos.add("Analysis/h4d_lstar_invm_US_PM", "THn #Lambda(1520)", kTHnSparseF, {axisInvM, axisPt, axisCent}); - histos.add("Analysis/h4d_lstar_invm_US_MP", "THn #bar #Lambda(1520)", kTHnSparseF, {axisInvM, axisPt, axisCent}); - histos.add("Analysis/h4d_lstar_invm_PP", "THn Like Signs p K^{+}", kTHnSparseF, {axisInvM, axisPt, axisCent}); - histos.add("Analysis/h4d_lstar_invm_MM", "THn Like Signs #bar{p} K^{-}", kTHnSparseF, {axisInvM, axisPt, axisCent}); - histos.add("Analysis/h4d_lstar_invm_rot", "THn Rotated", kTHnSparseF, {axisInvM, axisPt, axisCent}); - histos.add("Analysis/h4d_lstar_invm_US_PM_mix", "THn Mixed Events", kTHnSparseF, {axisInvM, axisPt, axisCent}); - histos.add("Analysis/h4d_lstar_invm_US_MP_mix", "THn anti Mixed Events", kTHnSparseF, {axisInvM, axisPt, axisCent}); - histos.add("Analysis/h4d_lstar_invm_LS_PP_mix", "THn Mixed Events PP", kTHnSparseF, {axisInvM, axisPt, axisCent}); - histos.add("Analysis/h4d_lstar_invm_LS_MM_mix", "THn Mixed Events MM", kTHnSparseF, {axisInvM, axisPt, axisCent}); + histos.add("Analysis/h4d_lstar_invm_US_PM", "THn #Lambda(1520)", kTHnSparseF, {axisInvM, axisPt, axisCent, axisOccupancy}); + histos.add("Analysis/h4d_lstar_invm_US_MP", "THn #bar #Lambda(1520)", kTHnSparseF, {axisInvM, axisPt, axisCent, axisOccupancy}); + histos.add("Analysis/h4d_lstar_invm_PP", "THn Like Signs p K^{+}", kTHnSparseF, {axisInvM, axisPt, axisCent, axisOccupancy}); + histos.add("Analysis/h4d_lstar_invm_MM", "THn Like Signs #bar{p} K^{-}", kTHnSparseF, {axisInvM, axisPt, axisCent, axisOccupancy}); + histos.add("Analysis/h4d_lstar_invm_rot", "THn Rotated", kTHnSparseF, {axisInvM, axisPt, axisCent, axisOccupancy}); + histos.add("Analysis/h4d_lstar_invm_US_PM_mix", "THn Mixed Events", kTHnSparseF, {axisInvM, axisPt, axisCent, axisOccupancy}); + histos.add("Analysis/h4d_lstar_invm_US_MP_mix", "THn anti Mixed Events", kTHnSparseF, {axisInvM, axisPt, axisCent, axisOccupancy}); + histos.add("Analysis/h4d_lstar_invm_LS_PP_mix", "THn Mixed Events PP", kTHnSparseF, {axisInvM, axisPt, axisCent, axisOccupancy}); + histos.add("Analysis/h4d_lstar_invm_LS_MM_mix", "THn Mixed Events MM", kTHnSparseF, {axisInvM, axisPt, axisCent, axisOccupancy}); } // MC if (doprocessMC) { @@ -241,16 +236,13 @@ struct lambdaAnalysis_pb { float tpcNsigmaPi = std::abs(candidate.tpcNSigmaPi()); float tpcNsigmaKa = std::abs(candidate.tpcNSigmaKa()); float tpcNsigmaPr = std::abs(candidate.tpcNSigmaPr()); - float tpcNsigmaEl = std::abs(candidate.tpcNSigmaEl()); float tofNsigmaPi = std::abs(candidate.tofNSigmaPi()); float tofNsigmaKa = std::abs(candidate.tofNSigmaKa()); float tofNsigmaPr = std::abs(candidate.tofNSigmaPr()); - float tofNsigmaEl = std::abs(candidate.tofNSigmaEl()); float tpcTofNsigmaPi = tpcNsigmaPi * tpcNsigmaPi + tofNsigmaPi * tofNsigmaPi; float tpcTofNsigmaKa = tpcNsigmaKa * tpcNsigmaKa + tofNsigmaKa * tofNsigmaKa; float tpcTofNsigmaPr = tpcNsigmaPr * tpcNsigmaPr + tofNsigmaPr * tofNsigmaPr; - float tpcTofNsigmaEl = tpcNsigmaEl * tpcNsigmaEl + tofNsigmaEl * tofNsigmaEl; float combinedCut = nsigmaCutCombinedProton * nsigmaCutCombinedProton; float combinedRejCut = cRejNsigmaTof * cRejNsigmaTpc; @@ -260,17 +252,17 @@ struct lambdaAnalysis_pb { if (nsigmaCutCombinedProton < 0 && p >= cPMin) { for (int i = 0; i < nitrtof - 1; ++i) { - if (p >= tofPIDp[i] && p < tofPIDp[i + 1] && (tofNsigmaPr < tofPIDcut[i] && tofNsigmaPi > cRejNsigmaTof && tofNsigmaKa > cRejNsigmaTof && tofNsigmaEl > cRejNsigmaTof)) + if (p >= tofPIDp[i] && p < tofPIDp[i + 1] && (tofNsigmaPr < tofPIDcut[i] && tofNsigmaPi > cRejNsigmaTof && tofNsigmaKa > cRejNsigmaTof)) tofPIDPassed = true; } if (candidate.tpcNSigmaPr() < minnsigmatpctofPr) return false; - if (tpcNsigmaPr < cMaxTPCnSigmaProton && tpcNsigmaPi > cRejNsigmaTpcVeto && tpcNsigmaKa > cRejNsigmaTpcVeto && tpcNsigmaEl > cRejNsigmaTpcVeto) + if (tpcNsigmaPr < cMaxTPCnSigmaProton && tpcNsigmaPi > cRejNsigmaTpcVeto && tpcNsigmaKa > cRejNsigmaTpcVeto) tpcPIDPassed = true; } // circular cut - if ((nsigmaCutCombinedProton > 0) && p >= cPMin && (tpcTofNsigmaPr < combinedCut && tpcTofNsigmaPi > combinedRejCut && tpcTofNsigmaKa > combinedRejCut && tpcTofNsigmaEl > combinedRejCut)) { + if ((nsigmaCutCombinedProton > 0) && p >= cPMin && (tpcTofNsigmaPr < combinedCut && tpcTofNsigmaPi > combinedRejCut && tpcTofNsigmaKa > combinedRejCut)) { tofPIDPassed = true; tpcPIDPassed = true; } @@ -285,7 +277,7 @@ struct lambdaAnalysis_pb { if (candidate.tpcNSigmaPr() < minnsigmatpcPr) return false; for (int i = 0; i < nitr - 1; ++i) { - if (p >= tpcPIDp[i] && p < tpcPIDp[i + 1] && (tpcNsigmaPr < tpcPIDcut[i] && tpcNsigmaPi > cRejNsigmaTpcPi && tpcNsigmaKa > cRejNsigmaTpcKa && tpcNsigmaEl > cRejNsigmaTpcEl)) { + if (p >= tpcPIDp[i] && p < tpcPIDp[i + 1] && (tpcNsigmaPr < tpcPIDcut[i] && tpcNsigmaPi > cRejNsigmaTpcPi && tpcNsigmaKa > cRejNsigmaTpcKa)) { tpcPIDPassed = true; } } @@ -309,16 +301,13 @@ struct lambdaAnalysis_pb { float tpcNsigmaPi = std::abs(candidate.tpcNSigmaPi()); float tpcNsigmaKa = std::abs(candidate.tpcNSigmaKa()); float tpcNsigmaPr = std::abs(candidate.tpcNSigmaPr()); - float tpcNsigmaEl = std::abs(candidate.tpcNSigmaEl()); float tofNsigmaPi = std::abs(candidate.tofNSigmaPi()); float tofNsigmaKa = std::abs(candidate.tofNSigmaKa()); float tofNsigmaPr = std::abs(candidate.tofNSigmaPr()); - float tofNsigmaEl = std::abs(candidate.tofNSigmaEl()); float tpcTofNsigmaPi = tpcNsigmaPi * tpcNsigmaPi + tofNsigmaPi * tofNsigmaPi; float tpcTofNsigmaKa = tpcNsigmaKa * tpcNsigmaKa + tofNsigmaKa * tofNsigmaKa; float tpcTofNsigmaPr = tpcNsigmaPr * tpcNsigmaPr + tofNsigmaPr * tofNsigmaPr; - float tpcTofNsigmaEl = tpcNsigmaEl * tpcNsigmaEl + tofNsigmaEl * tofNsigmaEl; float combinedCut = nsigmaCutCombinedKaon * nsigmaCutCombinedKaon; float combinedRejCut = cRejNsigmaTpc * cRejNsigmaTof; @@ -328,17 +317,17 @@ struct lambdaAnalysis_pb { if (nsigmaCutCombinedKaon < 0 && p >= cPMin) { for (int i = 0; i < nitrtof - 1; ++i) { - if (p >= tofPIDp[i] && p < tofPIDp[i + 1] && (tofNsigmaKa < tofPIDcut[i] && tofNsigmaPi > cRejNsigmaTof && tofNsigmaPr > cRejNsigmaTof && tofNsigmaEl > cRejNsigmaTof)) + if (p >= tofPIDp[i] && p < tofPIDp[i + 1] && (tofNsigmaKa < tofPIDcut[i] && tofNsigmaPi > cRejNsigmaTof && tofNsigmaPr > cRejNsigmaTof)) tofPIDPassed = true; } if (candidate.tpcNSigmaKa() < minnsigmatpctofKa) return false; - if (tpcNsigmaKa < cMaxTPCnSigmaKaon && tpcNsigmaPi > cRejNsigmaTpcVeto && tpcNsigmaPr > cRejNsigmaTpcVeto && tpcNsigmaEl > cRejNsigmaTpcVeto) + if (tpcNsigmaKa < cMaxTPCnSigmaKaon && tpcNsigmaPi > cRejNsigmaTpcVeto && tpcNsigmaPr > cRejNsigmaTpcVeto) tpcPIDPassed = true; } // circular - if ((nsigmaCutCombinedKaon > 0) && p >= cPMin && (tpcTofNsigmaKa < combinedCut && tpcTofNsigmaPi > combinedRejCut && tpcTofNsigmaPr > combinedRejCut && tpcTofNsigmaEl > combinedRejCut)) { + if ((nsigmaCutCombinedKaon > 0) && p >= cPMin && (tpcTofNsigmaKa < combinedCut && tpcTofNsigmaPi > combinedRejCut && tpcTofNsigmaPr > combinedRejCut)) { tofPIDPassed = true; tpcPIDPassed = true; } @@ -354,7 +343,7 @@ struct lambdaAnalysis_pb { if (candidate.tpcNSigmaKa() < minnsigmatpcKa) return false; for (int i = 0; i < nitr - 1; ++i) { - if (p >= tpcPIDp[i] && p < tpcPIDp[i + 1] && (tpcNsigmaKa < tpcPIDcut[i] && tpcNsigmaPi > cRejNsigmakTpcPi && tpcNsigmaPr > cRejNsigmakTpcPr && tpcNsigmaEl > cRejNsigmakTpcEl)) { + if (p >= tpcPIDp[i] && p < tpcPIDp[i + 1] && (tpcNsigmaKa < tpcPIDcut[i] && tpcNsigmaPi > cRejNsigmakTpcPi && tpcNsigmaPr > cRejNsigmakTpcPr)) { tpcPIDPassed = true; } } @@ -366,7 +355,7 @@ struct lambdaAnalysis_pb { } template - void fillDataHistos(trackType const& trk1, trackType const& trk2, float const& mult) + void fillDataHistos(trackType const& trk1, trackType const& trk2, float mult, int occup = 100) { TLorentzVector p1, p2, p; @@ -398,7 +387,6 @@ struct lambdaAnalysis_pb { auto _tpcnsigmaPr = trkPr.tpcNSigmaPr(); histos.fill(HIST("QAbefore/Proton/h2d_pr_nsigma_tpc_p"), p_ptot, _tpcnsigmaPr); - // histos.fill(HIST("QAbefore/Proton/h2d_prel_nsigma_tpc_p"), p_ptot, trkPr.tpcNSigmaEl()); if (trkPr.hasTOF()) { auto _tofnsigmaPr = trkPr.tofNSigmaPr(); histos.fill(HIST("QAbefore/Proton/h2d_pr_nsigma_tof_p"), p_ptot, _tofnsigmaPr); @@ -435,7 +423,6 @@ struct lambdaAnalysis_pb { histos.fill(HIST("QAafter/Proton/h2d_pr_dEdx_p"), p_ptot, trkPr.tpcSignal()); histos.fill(HIST("QAafter/Proton/h2d_Prpi_nsigma_tpc_p"), p_ptot, trkPr.tpcNSigmaPi()); histos.fill(HIST("QAafter/Proton/h2d_Prka_nsigma_tpc_p"), p_ptot, trkPr.tpcNSigmaKa()); - histos.fill(HIST("QAafter/Proton/h2d_Prel_nsigma_tpc_p"), p_ptot, trkPr.tpcNSigmaEl()); histos.fill(HIST("QAafter/Proton/h2d_pr_nsigma_tpc_p"), p_ptot, _tpcnsigmaPr); histos.fill(HIST("QAafter/Proton/h2d_pr_nsigma_tpc_pt"), _ptPr, _tpcnsigmaPr); if (!cUseTpcOnly && trkPr.hasTOF()) { @@ -444,7 +431,6 @@ struct lambdaAnalysis_pb { histos.fill(HIST("QAafter/Proton/h2d_pr_nsigma_tof_pt"), _ptPr, _tofnsigmaPr); histos.fill(HIST("QAafter/Proton/h2d_Prpi_nsigma_tof_p"), p_ptot, trkPr.tofNSigmaPi()); histos.fill(HIST("QAafter/Proton/h2d_Prka_nsigma_tof_p"), p_ptot, trkPr.tofNSigmaKa()); - histos.fill(HIST("QAafter/Proton/h2d_Prel_nsigma_tof_p"), p_ptot, trkPr.tofNSigmaEl()); histos.fill(HIST("QAafter/Proton/h2d_pr_nsigma_tof_vs_tpc"), _tpcnsigmaPr, _tofnsigmaPr); } auto _ptKa = trkKa.pt(); @@ -457,7 +443,6 @@ struct lambdaAnalysis_pb { histos.fill(HIST("QAafter/Kaon/h2d_ka_dEdx_p"), k_ptot, trkKa.tpcSignal()); histos.fill(HIST("QAafter/Kaon/h2d_Kapi_nsigma_tpc_p"), k_ptot, trkKa.tpcNSigmaPi()); histos.fill(HIST("QAafter/Kaon/h2d_Kapr_nsigma_tpc_p"), k_ptot, trkKa.tpcNSigmaPr()); - histos.fill(HIST("QAafter/Kaon/h2d_Kael_nsigma_tpc_p"), k_ptot, trkKa.tpcNSigmaEl()); histos.fill(HIST("QAafter/Kaon/h2d_ka_nsigma_tpc_p"), k_ptot, _tpcnsigmaKa); histos.fill(HIST("QAafter/Kaon/h2d_ka_nsigma_tpc_pt"), _ptKa, _tpcnsigmaKa); if (!cUseTpcOnly && trkKa.hasTOF()) { @@ -466,7 +451,6 @@ struct lambdaAnalysis_pb { histos.fill(HIST("QAafter/Kaon/h2d_ka_nsigma_tof_pt"), _ptKa, _tofnsigmaKa); histos.fill(HIST("QAafter/Kaon/h2d_Kapi_nsigma_tof_p"), k_ptot, trkKa.tofNSigmaPi()); histos.fill(HIST("QAafter/Kaon/h2d_Kapr_nsigma_tof_p"), k_ptot, trkKa.tofNSigmaPr()); - histos.fill(HIST("QAafter/Kaon/h2d_Kael_nsigma_tof_p"), k_ptot, trkKa.tofNSigmaEl()); histos.fill(HIST("QAafter/Kaon/h2d_ka_nsigma_tof_vs_tpc"), _tpcnsigmaKa, _tofnsigmaKa); } } @@ -497,22 +481,22 @@ struct lambdaAnalysis_pb { if constexpr (!mix && !mc) { if (trkPr.sign() * trkKa.sign() < 0) { if (trkPr.sign() > 0) - histos.fill(HIST("Analysis/h4d_lstar_invm_US_PM"), _M, _pt, mult); + histos.fill(HIST("Analysis/h4d_lstar_invm_US_PM"), _M, _pt, mult, occup); else - histos.fill(HIST("Analysis/h4d_lstar_invm_US_MP"), _M, _pt, mult); + histos.fill(HIST("Analysis/h4d_lstar_invm_US_MP"), _M, _pt, mult, occup); if (doRotate) { float theta = rn->Uniform(1.56, 1.58); p1.RotateZ(theta); p = p1 + p2; if (std::abs(p.Rapidity()) < 0.5) { - histos.fill(HIST("Analysis/h4d_lstar_invm_rot"), p.M(), p.Pt(), mult); + histos.fill(HIST("Analysis/h4d_lstar_invm_rot"), p.M(), p.Pt(), mult, occup); } } } else { if (trkPr.sign() > 0) { - histos.fill(HIST("Analysis/h4d_lstar_invm_PP"), _M, _pt, mult); + histos.fill(HIST("Analysis/h4d_lstar_invm_PP"), _M, _pt, mult, occup); } else { - histos.fill(HIST("Analysis/h4d_lstar_invm_MM"), _M, _pt, mult); + histos.fill(HIST("Analysis/h4d_lstar_invm_MM"), _M, _pt, mult, occup); } } } @@ -520,14 +504,14 @@ struct lambdaAnalysis_pb { if constexpr (mix) { if (trkPr.sign() * trkKa.sign() < 0) { if (trkPr.sign() > 0) - histos.fill(HIST("Analysis/h4d_lstar_invm_US_PM_mix"), _M, _pt, mult); + histos.fill(HIST("Analysis/h4d_lstar_invm_US_PM_mix"), _M, _pt, mult, occup); else - histos.fill(HIST("Analysis/h4d_lstar_invm_US_MP_mix"), _M, _pt, mult); + histos.fill(HIST("Analysis/h4d_lstar_invm_US_MP_mix"), _M, _pt, mult, occup); } else { if (trkPr.sign() > 0) - histos.fill(HIST("Analysis/h4d_lstar_invm_LS_PP_mix"), _M, _pt, mult); + histos.fill(HIST("Analysis/h4d_lstar_invm_LS_PP_mix"), _M, _pt, mult, occup); else - histos.fill(HIST("Analysis/h4d_lstar_invm_LS_MM_mix"), _M, _pt, mult); + histos.fill(HIST("Analysis/h4d_lstar_invm_LS_MM_mix"), _M, _pt, mult, occup); } } @@ -553,16 +537,14 @@ struct lambdaAnalysis_pb { } } - using resoCols = aod::ResoCollisions; + using resoCols = soa::Join; using resoTracks = aod::ResoTracks; void processData(resoCols::iterator const& collision, resoTracks const& tracks) { // LOGF(info, " collisions: Index = %d %d", collision.globalIndex(),tracks.size()); - if (ConfEvtOccupancyInTimeRange > 0 && collision.trackOccupancyInTimeRange() > ConfEvtOccupancyInTimeRange) - return; - histos.fill(HIST("Event/h1d_ft0_mult_percentile"), collision.cent()); + histos.fill(HIST("Event/h1d_ft0_mult_percentile"), collision.cent(), 100); fillDataHistos(tracks, tracks, collision.cent()); } @@ -643,8 +625,6 @@ struct lambdaAnalysis_pb { SameKindPair pairs{binningPositions2, cNumMixEv, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip for (auto& [c1, t1, c2, t2] : pairs) { - if (ConfEvtOccupancyInTimeRange > 0 && c1.trackOccupancyInTimeRange() > ConfEvtOccupancyInTimeRange && c2.trackOccupancyInTimeRange() > ConfEvtOccupancyInTimeRange) - return; // LOGF(info, "processMCMixedDerived: Mixed collisions : %d (%.3f, %.3f,%d), %d (%.3f, %.3f,%d)",c1.globalIndex(), c1.posZ(), c1.cent(),c1.mult(), c2.globalIndex(), c2.posZ(), c2.cent(),c2.mult()); histos.fill(HIST("Event/mixing_vzVsmultpercentile"), c1.cent(), c1.posZ(), c1.evtPl()); fillDataHistos(t1, t2, c1.cent()); @@ -653,9 +633,9 @@ struct lambdaAnalysis_pb { PROCESS_SWITCH(lambdaAnalysis_pb, processMix, "Process for Mixed Events", false); - Preslice perRColdf = aod::resodaughter::resoCollisionId; + Preslice perRColdf = aod::resodaughter::resoCollisionDFId; - using resoColDFs = aod::ResoCollisions; + using resoColDFs = aod::ResoCollisionDFs; using resoTrackDFs = aod::ResoTrackDFs; void processDatadf(resoColDFs::iterator const& collision, resoTrackDFs const& tracks) @@ -663,11 +643,13 @@ struct lambdaAnalysis_pb { if (doprocessData) LOG(error) << "Disable processData() first!"; - if (ConfEvtOccupancyInTimeRange > 0 && collision.trackOccupancyInTimeRange() > ConfEvtOccupancyInTimeRange) - return; + auto _occup = 100; + if (ConfEvtOccupancyInTimeRange) + _occup = collision.trackOccupancyInTimeRange(); + // LOGF(info, "inside df collisions: Index = %d %d", collision.globalIndex(),tracks.size()); - histos.fill(HIST("Event/h1d_ft0_mult_percentile"), collision.cent()); - fillDataHistos(tracks, tracks, collision.cent()); + histos.fill(HIST("Event/h1d_ft0_mult_percentile"), collision.cent(), _occup); + fillDataHistos(tracks, tracks, collision.cent(), _occup); } PROCESS_SWITCH(lambdaAnalysis_pb, processDatadf, "Process for data merged DF", false); @@ -684,12 +666,13 @@ struct lambdaAnalysis_pb { SameKindPair pairs{binningPositions2, cNumMixEv, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip for (auto& [c1, t1, c2, t2] : pairs) { - if (ConfEvtOccupancyInTimeRange > 0 && c1.trackOccupancyInTimeRange() > ConfEvtOccupancyInTimeRange && c2.trackOccupancyInTimeRange() > ConfEvtOccupancyInTimeRange) - return; + auto _occup = 100; + if (ConfEvtOccupancyInTimeRange) + _occup = c1.trackOccupancyInTimeRange(); // LOGF(info, "processMCMixedDerived: Mixed collisions : %d (%.3f, %.3f,%d), %d (%.3f, %.3f,%d)",c1.globalIndex(), c1.posZ(), c1.cent(),c1.mult(), c2.globalIndex(), c2.posZ(), c2.cent(),c2.mult()); histos.fill(HIST("Event/mixing_vzVsmultpercentile"), c1.cent(), c1.posZ(), c1.evtPl()); - fillDataHistos(t1, t2, c1.cent()); + fillDataHistos(t1, t2, c1.cent(), _occup); } } @@ -706,8 +689,6 @@ struct lambdaAnalysis_pb { SameKindPair pairs{binningPositions2, cNumMixEv, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip for (auto& [c1, t1, c2, t2] : pairs) { - if (ConfEvtOccupancyInTimeRange > 0 && c1.trackOccupancyInTimeRange() > ConfEvtOccupancyInTimeRange && c2.trackOccupancyInTimeRange() > ConfEvtOccupancyInTimeRange) - return; // LOGF(info, "processMCMixedDerived: Mixed collisions : %d (%.3f, %.3f,%.3f), %d (%.3f, %.3f, %.3f)",c1.globalIndex(), c1.posZ(), c1.cent(),c1.evtPl(), c2.globalIndex(), c2.posZ(), c2.cent(),c2.evtPl()); histos.fill(HIST("Event/mixing_vzVsmultpercentile"), c1.cent(), c1.posZ(), c1.evtPl()); fillDataHistos(t1, t2, c1.cent()); diff --git a/PWGLF/Tasks/Resonances/lambda1520analysis.cxx b/PWGLF/Tasks/Resonances/lambda1520analysis.cxx index 97cec72b2c2..3e6749d451d 100644 --- a/PWGLF/Tasks/Resonances/lambda1520analysis.cxx +++ b/PWGLF/Tasks/Resonances/lambda1520analysis.cxx @@ -26,7 +26,7 @@ using namespace o2::framework; using namespace o2::soa; using namespace o2::constants::physics; -struct lambda1520analysis { +struct Lambda1520analysis { // Define slice per Resocollision SliceCache cache; Preslice perResoCollision = aod::resodaughter::resoCollisionId; @@ -41,8 +41,8 @@ struct lambda1520analysis { Configurable cEtaAssym{"cEtaAssym", false, "Turn on/off EtaAssym calculation"}; Configurable isFilladditionalQA{"isFilladditionalQA", false, "Turn on/off additional QA plots"}; Configurable cOldPIDcut{"cOldPIDcut", false, "Switch to turn on/off old PID cut to apply pt dependent cut"}; - Configurable FixedPIDcut{"FixedPIDcut", false, "Switch to turn on/off FIXED PID cut to apply pt dependent cut"}; - Configurable cRejectPion{"cRejectPion", false, "Switch to turn on/off pion contamination"}; + Configurable fixedPIDcut{"fixedPIDcut", false, "Switch to turn on/off FIXED PID cut to apply pt dependent cut"}; + Configurable crejectPion{"crejectPion", false, "Switch to turn on/off pion contamination"}; Configurable cDCAr7SigCut{"cDCAr7SigCut", false, "Track DCAr 7 Sigma cut to PV Maximum"}; Configurable cKinCuts{"cKinCuts", false, "Kinematic Cuts for p-K pair opening angle"}; Configurable cTPCNClsFound{"cTPCNClsFound", false, "Switch to turn on/off TPCNClsFound cut"}; @@ -51,11 +51,7 @@ struct lambda1520analysis { // Pre-selection Track cuts Configurable cMinPtcut{"cMinPtcut", 0.15f, "Minimal pT for tracks"}; - Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.8f, "minimum ratio of number of Xrows to findable clusters in TPC"}; - Configurable cMaxChi2ITScut{"cMaxChi2ITScut", 36.0f, "Maximal pT for Chi2/cluster for ITS"}; - Configurable cMaxChi2TPCcut{"cMaxChi2TPCcut", 4.0f, "Maximal pT for Chi2/cluster for TPC"}; Configurable cMinTPCNClsFound{"cMinTPCNClsFound", 120, "minimum TPCNClsFound value for good track"}; - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; Configurable cMinTPCncr{"cMinTPCncr", 70, "Minimum number of TPC X rows"}; // DCA Selections @@ -69,8 +65,6 @@ struct lambda1520analysis { Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor - Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; - Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; @@ -79,15 +73,18 @@ struct lambda1520analysis { Configurable cRejNsigmaTpc{"cRejNsigmaTpc", 3.0, "Reject tracks to improve purity of TPC PID"}; // Reject missidentified particles when tpc bands merge Configurable cRejNsigmaTof{"cRejNsigmaTof", 3.0, "Reject tracks to improve purity of TOF PID"}; // Reject missidentified particles when tpc bands merge Configurable cUseRejNsigma{"cUseRejNsigma", false, "Switch on/off track rejection method to improve purity"}; - Configurable tof_at_high_pt{"tof_at_high_pt", false, "Use TOF at high pT"}; - Configurable cByPassTOF{"cByPassTOF", false, "By pass TOF PID selection"}; // By pass TOF PID selection + Configurable tofAtHighPt{"tofAtHighPt", false, "Use TOF at high pT"}; + Configurable cByPassTOF{"cByPassTOF", false, "By pass TOF PID selection"}; // By pass TOF PID selection + Configurable pidCutType{"pidCutType", 2, "pidCutType = 1 for square cut, 2 for circular cut"}; // By pass TOF PID selection // Kaon // Old PID use case Configurable> kaonTPCPIDpTintv{"kaonTPCPIDpTintv", {999.}, "pT intervals for Kaon TPC PID cuts"}; - Configurable> kaonTPCPIDcuts{"kaonTPCPIDcuts", {2}, "nSigma list for Kaon TPC PID cuts"}; + Configurable> kaonTPCPIDcuts{"kaonTPCPIDcuts", {3}, "nSigma list for Kaon TPC PID cuts"}; Configurable> kaonTOFPIDpTintv{"kaonTOFPIDpTintv", {999.}, "pT intervals for Kaon TOF PID cuts"}; - Configurable> kaonTOFPIDcuts{"kaonTOFPIDcuts", {2}, "nSigma list for Kaon TOF PID cuts"}; + Configurable> kaonTOFPIDcuts{"kaonTOFPIDcuts", {3}, "nSigma list for Kaon TOF PID cuts"}; + Configurable> kaonTPCTOFCombinedpTintv{"kaonTPCTOFCombinedpTintv", {999.}, "pT intervals for Kaon TPC-TOF PID cuts"}; + Configurable> kaonTPCTOFCombinedPIDcuts{"kaonTPCTOFCombinedPIDcuts", {3}, "nSigma list for Kaon TPC-TOF PID cuts"}; Configurable cMaxTPCnSigmaKaonVETO{"cMaxTPCnSigmaKaonVETO", 3.0, "TPC nSigma VETO cut for Kaon"}; // TPC // New PID use case @@ -99,9 +96,11 @@ struct lambda1520analysis { // Proton // Old PID use case Configurable> protonTPCPIDpTintv{"protonTPCPIDpTintv", {999.}, "pT intervals for Kaon TPC PID cuts"}; - Configurable> protonTPCPIDcuts{"protonTPCPIDcuts", {2}, "nSigma list for Kaon TPC PID cuts"}; + Configurable> protonTPCPIDcuts{"protonTPCPIDcuts", {3}, "nSigma list for Kaon TPC PID cuts"}; Configurable> protonTOFPIDpTintv{"protonTOFPIDpTintv", {999.}, "pT intervals for Kaon TOF PID cuts"}; - Configurable> protonTOFPIDcuts{"protonTOFPIDcuts", {2}, "nSigma list for Kaon TOF PID cuts"}; + Configurable> protonTOFPIDcuts{"protonTOFPIDcuts", {3}, "nSigma list for Kaon TOF PID cuts"}; + Configurable> protonTPCTOFCombinedpTintv{"protonTPCTOFCombinedpTintv", {999.}, "pT intervals for Proton TPC-TOF PID cuts"}; + Configurable> protonTPCTOFCombinedPIDcuts{"protonTPCTOFCombinedPIDcuts", {3}, "nSigma list for Proton TPC-TOF PID cuts"}; Configurable cMaxTPCnSigmaProtonVETO{"cMaxTPCnSigmaProtonVETO", 3.0, "TPC nSigma VETO cut for Proton"}; // TPC // New PID use case @@ -112,8 +111,8 @@ struct lambda1520analysis { /// Event Mixing Configurable nEvtMixing{"nEvtMixing", 10, "Number of events to mix"}; - ConfigurableAxis CfgVtxBins{"CfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; - ConfigurableAxis CfgMultBins{"CfgMultBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - multiplicity"}; + ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgMultBins{"cfgMultBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - multiplicity"}; // MC Event selection Configurable cZvertCutMC{"cZvertCutMC", 10.0, "MC Z-vertex cut"}; @@ -126,26 +125,29 @@ struct lambda1520analysis { Configurable cetaphiBins{"cetaphiBins", 400, "number of eta and phi bins"}; Configurable cMaxDeltaEtaCut{"cMaxDeltaEtaCut", 0.7, "Maximum deltaEta between daughters"}; Configurable cMaxDeltaPhiCut{"cMaxDeltaPhiCut", 1.5, "Maximum deltaPhi between daughters"}; + Configurable invmass1D{"invmass1D", false, "Invariant mass 1D"}; + Configurable cAdditionalMCPlots{"cAdditionalMCPlots", false, "Draw additional plots related to MC"}; + TRandom* rn = new TRandom(); /// Figures - ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; + ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 0.0, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.25, 1.3, 1.4, 1.5, 1.6, 1.7, 1.75, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.5, 4.6, 4.8, 4.9, 5.0, 5.5, 5.6, 6.0, 6.4, 6.5, 7.0, 7.2, 8.0, 9.0, 9.5, 9.6, 10.0, 11.0, 11.5, 12.0, 13.0, 14.0, 14.4, 15.0, 16.0, 18.0, 19.2, 20.}, "Binning of the pT axis"}; ConfigurableAxis binsEta{"binsEta", {100, -1, 1}, ""}; - ConfigurableAxis binsMass{"binsMass", {1700, 1.3, 3.0}, "Invariant Mass (GeV/#it{c}^2)"}; + ConfigurableAxis binsMass{"binsMass", {500, 1.3, 2.3}, "Invariant Mass (GeV/#it{c}^2)"}; ConfigurableAxis binsMult{"binsMult", {110, 0.0, 110.0}, "mult_{FT0M}"}; - ConfigurableAxis binsDCAz{"binsDCAz", {600, -3, 3}, ""}; - ConfigurableAxis binsDCAxy{"binsDCAxy", {300, -1.5, 1.5}, ""}; - ConfigurableAxis binsTPCXrows{"binsTPCXrows", {200, 0, 200}, ""}; + ConfigurableAxis binsDCAz{"binsDCAz", {40, -0.2, 0.2}, ""}; + ConfigurableAxis binsDCAxy{"binsDCAxy", {40, -0.2, 0.2}, ""}; + ConfigurableAxis binsTPCXrows{"binsTPCXrows", {100, 60, 160}, ""}; ConfigurableAxis binsnSigma{"binsnSigma", {130, -6.5, 6.5}, ""}; ConfigurableAxis binsnTPCSignal{"binsnTPCSignal", {1000, 0, 1000}, ""}; - ConfigurableAxis occupancy_bins{"occupancy_bins", {VARIABLE_WIDTH, 0.0, 100, 500, 600, 1000, 1100, 1500, 1600, 2000, 2100, 2500, 2600, 3000, 3100, 3500, 3600, 4000, 4100, 4500, 4600, 5000, 5100, 9999}, "Binning of the occupancy axis"}; + ConfigurableAxis occupancybins{"occupancybins", {VARIABLE_WIDTH, 0.0, 100, 500, 600, 1000, 1100, 1500, 1600, 2000, 2100, 2500, 2600, 3000, 3100, 3500, 3600, 4000, 4100, 4500, 4600, 5000, 5100, 9999}, "Binning of the occupancy axis"}; Configurable applyOccupancyCut{"applyOccupancyCut", false, "Apply occupancy cut"}; - Configurable OccupancyCut{"OccupancyCut", 1000, "Mimimum Occupancy cut"}; + Configurable occupancyCut{"occupancyCut", 1000, "Mimimum Occupancy cut"}; // Rotational background - Configurable IsCalcRotBkg{"IsCalcRotBkg", true, "Calculate rotational background"}; - Configurable rotational_cut{"rotational_cut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; - Configurable c_nof_rotations{"c_nof_rotations", 3, "Number of random rotations in the rotational background"}; + Configurable isCalcRotBkg{"isCalcRotBkg", true, "Calculate rotational background"}; + Configurable rotationalcut{"rotationalcut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; + Configurable cNofRotations{"cNofRotations", 3, "Number of random rotations in the rotational background"}; void init(o2::framework::InitContext&) { @@ -160,7 +162,7 @@ struct lambda1520analysis { AxisSpec pidQAAxis = {binsnSigma, "#sigma"}; AxisSpec axisTPCSignal = {binsnTPCSignal, ""}; AxisSpec mcLabelAxis = {5, -0.5, 4.5, "MC Label"}; - AxisSpec occupancy_axis = {occupancy_bins, "Occupancy [-40,100]"}; + // AxisSpec occupancyaxis = {occupancybins, "Occupancy [-40,100]"}; if (additionalQAeventPlots) { // Test on Mixed event @@ -238,11 +240,12 @@ struct lambda1520analysis { histos.add("QA/QAafter/Proton/TPC_Signal_pr_all", "TPC Signal for Proton;#it{p}_{T} (GeV/#it{c});TPC Signal (A.U.)", {HistType::kTH2F, {axisPt, axisTPCSignal}}); // Mass QA 1D for quick check - histos.add("Result/Data/lambda1520invmass", "Invariant mass of #Lambda(1520) K^{#pm}p^{#mp}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); - histos.add("Result/Data/antilambda1520invmass", "Invariant mass of #Lambda(1520) K^{#mp}p^{#pm}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); - histos.add("Result/Data/lambda1520invmassLSPP", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K+ + Pr - histos.add("Result/Data/lambda1520invmassLSMM", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K- + anti-Pr - + if (invmass1D) { + histos.add("Result/Data/lambda1520invmass", "Invariant mass of #Lambda(1520) K^{#pm}p^{#mp}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + histos.add("Result/Data/antilambda1520invmass", "Invariant mass of #Lambda(1520) K^{#mp}p^{#pm}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + histos.add("Result/Data/lambda1520invmassLSPP", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K+ + Pr + histos.add("Result/Data/lambda1520invmassLSMM", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K- + anti-Pr + } // eta phi QA if (cfgCutsOnDaughters) { histos.add("QAbefore/deltaEta", "deltaEta of kaon and proton candidates", HistType::kTH1F, {{cetaphiBins, 0.0, 3.15}}); @@ -259,25 +262,27 @@ struct lambda1520analysis { histos.add("QAafter/PhiKaafter", "Phi of kaon candidates", HistType::kTH1F, {{cetaphiBins, 0.0, 6.30}}); } - if (IsCalcRotBkg) { - histos.add("Result/Data/h3lambda1520InvMassRotation", "Invariant mass of #Lambda(1520) rotation", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520, occupancy_axis}); + if (isCalcRotBkg) { + histos.add("Result/Data/h3lambda1520InvMassRotation", "Invariant mass of #Lambda(1520) rotation", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); } // 3d histogram - histos.add("Result/Data/h3lambda1520invmass", "Invariant mass of #Lambda(1520) K^{#pm}p^{#mp}", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); - histos.add("Result/Data/h3antilambda1520invmass", "Invariant mass of #Lambda(1520) K^{#mp}p^{#pm}", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); - histos.add("Result/Data/h3lambda1520invmassLSPP", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); // K+ + Pr - histos.add("Result/Data/h3lambda1520invmassLSMM", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); // K- + anti-Pr + histos.add("Result/Data/h3lambda1520invmass", "Invariant mass of #Lambda(1520) K^{#pm}p^{#mp}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3antilambda1520invmass", "Invariant mass of #Lambda(1520) K^{#mp}p^{#pm}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassLSPP", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); // K+ + Pr + histos.add("Result/Data/h3lambda1520invmassLSMM", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); // K- + anti-Pr } if (doprocessME) { - histos.add("Result/Data/lambda1520invmassME", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); - histos.add("Result/Data/h3lambda1520invmassME", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); + if (invmass1D) { + histos.add("Result/Data/lambda1520invmassME", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + } + histos.add("Result/Data/h3lambda1520invmassME", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); if (additionalMEPlots) { histos.add("Result/Data/lambda1520invmassME_DS", "Invariant mass of #Lambda(1520) mixed event DS", kTH1F, {axisMassLambda1520}); histos.add("Result/Data/lambda1520invmassME_DSAnti", "Invariant mass of #Lambda(1520) mixed event DSAnti", kTH1F, {axisMassLambda1520}); - histos.add("Result/Data/h3lambda1520invmassME_DS", "Invariant mass of #Lambda(1520) mixed event DS", kTH3F, {axisMult, axisPt, axisMassLambda1520}); - histos.add("Result/Data/h3lambda1520invmassME_DSAnti", "Invariant mass of #Lambda(1520) mixed event DSAnti", kTH3F, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassME_DS", "Invariant mass of #Lambda(1520) mixed event DS", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassME_DSAnti", "Invariant mass of #Lambda(1520) mixed event DSAnti", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); } } @@ -287,16 +292,16 @@ struct lambda1520analysis { histos.add("Result/Data/hlambda1520invmassUnlikeSignCside", "Invariant mass of #Lambda(1520) Unlike Sign C side", {HistType::kTH1F, {axisMassLambda1520}}); histos.add("Result/Data/hlambda1520invmassLikeSignCside", "Invariant mass of #Lambda(1520) Like Sign C side", {HistType::kTH1F, {axisMassLambda1520}}); - histos.add("Result/Data/h3lambda1520invmassUnlikeSignAside", "Invariant mass of #Lambda(1520) Unlike Sign A side", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); - histos.add("Result/Data/h3lambda1520invmassLikeSignAside", "Invariant mass of #Lambda(1520) Like Sign A side", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); - histos.add("Result/Data/h3lambda1520invmassUnlikeSignCside", "Invariant mass of #Lambda(1520) Unlike Sign C side", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); - histos.add("Result/Data/h3lambda1520invmassLikeSignCside", "Invariant mass of #Lambda(1520) Like Sign C side", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassUnlikeSignAside", "Invariant mass of #Lambda(1520) Unlike Sign A side", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassLikeSignAside", "Invariant mass of #Lambda(1520) Like Sign A side", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassUnlikeSignCside", "Invariant mass of #Lambda(1520) Unlike Sign C side", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassLikeSignCside", "Invariant mass of #Lambda(1520) Like Sign C side", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); if (doprocessME) { histos.add("Result/Data/hlambda1520invmassMixedAside", "Invariant mass of #Lambda(1520) Mixed A side", {HistType::kTH1F, {axisMassLambda1520}}); histos.add("Result/Data/hlambda1520invmassMixedCside", "Invariant mass of #Lambda(1520) Mixed C side", {HistType::kTH1F, {axisMassLambda1520}}); - histos.add("Result/Data/h3lambda1520invmassMixedAside", "Invariant mass of #Lambda(1520) Mixed A side", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); - histos.add("Result/Data/h3lambda1520invmassMixedCside", "Invariant mass of #Lambda(1520) Mixed C side", HistType::kTH3F, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassMixedAside", "Invariant mass of #Lambda(1520) Mixed A side", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassMixedCside", "Invariant mass of #Lambda(1520) Mixed C side", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); } } //} @@ -306,10 +311,10 @@ struct lambda1520analysis { histos.add("Result/MC/Genantilambda1520pt", "pT distribution of True MC Anti-#Lambda(1520)0", kTH3F, {mcLabelAxis, axisPt, axisMult}); } if (doprocessMC) { - histos.add("QA/MC/trkDCAxy_pr", "DCAxy distribution of proton track candidates", HistType::kTH1F, {axisDCAxy}); - histos.add("QA/MC/trkDCAxy_ka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {axisDCAxy}); - histos.add("QA/MC/trkDCAz_pr", "DCAz distribution of proton track candidates", HistType::kTH1F, {axisDCAz}); - histos.add("QA/MC/trkDCAz_ka", "DCAz distribution of kaon track candidates", HistType::kTH1F, {axisDCAz}); + histos.add("QA/MC/trkDCAxy_pr", "DCAxy distribution of proton track candidates", HistType::kTH2F, {axisPt, axisDCAxy}); + histos.add("QA/MC/trkDCAxy_ka", "DCAxy distribution of kaon track candidates", HistType::kTH2F, {axisPt, axisDCAxy}); + histos.add("QA/MC/trkDCAz_pr", "DCAz distribution of proton track candidates", HistType::kTH2F, {axisPt, axisDCAz}); + histos.add("QA/MC/trkDCAz_ka", "DCAz distribution of kaon track candidates", HistType::kTH2F, {axisPt, axisDCAz}); histos.add("QA/MC/TOF_Nsigma_pr_all", "TOF NSigma for Proton;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Proton};", {HistType::kTH3F, {axisMult, axisPt, pidQAAxis}}); histos.add("QA/MC/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Proton};", {HistType::kTH3F, {axisMult, axisPt, pidQAAxis}}); histos.add("QA/MC/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {axisMult, axisPt, pidQAAxis}}); @@ -317,10 +322,12 @@ struct lambda1520analysis { histos.add("Result/MC/h3lambda1520Recoinvmass", "Invariant mass of Reconstructed MC #Lambda(1520)0", kTH3F, {axisMult, axisPt, axisMassLambda1520}); histos.add("Result/MC/h3antilambda1520Recoinvmass", "Invariant mass of Reconstructed MC Anti-#Lambda(1520)0", kTH3F, {axisMult, axisPt, axisMassLambda1520}); - histos.add("Result/MC/lambda1520Reco", "pT distribution of Reconstructed MC #Lambda(1520)0", kTH2F, {axisPt, axisMult}); - histos.add("Result/MC/antilambda1520Reco", "pT distribution of Reconstructed MC Anti-#Lambda(1520)0", kTH2F, {axisPt, axisMult}); - histos.add("Result/MC/hlambda1520Recoinvmass", "Inv mass distribution of Reconstructed MC #Lambda(1520)", kTH1F, {axisMassLambda1520}); - histos.add("Result/MC/hantilambda1520Recoinvmass", "Inv mass distribution of Reconstructed MC Anti-#Lambda(1520)", kTH1F, {axisMassLambda1520}); + if (cAdditionalMCPlots) { + histos.add("Result/MC/lambda1520Reco", "pT distribution of Reconstructed MC #Lambda(1520)0", kTH2F, {axisPt, axisMult}); + histos.add("Result/MC/antilambda1520Reco", "pT distribution of Reconstructed MC Anti-#Lambda(1520)0", kTH2F, {axisPt, axisMult}); + histos.add("Result/MC/hlambda1520Recoinvmass", "Inv mass distribution of Reconstructed MC #Lambda(1520)", kTH1F, {axisMassLambda1520}); + histos.add("Result/MC/hantilambda1520Recoinvmass", "Inv mass distribution of Reconstructed MC Anti-#Lambda(1520)", kTH1F, {axisMassLambda1520}); + } } // Print output histograms statistics @@ -346,20 +353,8 @@ struct lambda1520analysis { } if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) return false; - if (track.itsNCls() < cfgITScluster) - return false; if (cTPCNClsFound && (track.tpcNClsFound() < cMinTPCNClsFound)) return false; - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) - return false; - if (track.itsChi2NCl() > cMaxChi2ITScut) - return false; - if (track.tpcChi2NCl() > cMaxChi2TPCcut) - return false; - if (cfgHasITS && !track.hasITS()) - return false; - if (cfgHasTPC && !track.hasTPC()) - return false; if (cfgHasTOF && !track.hasTOF()) return false; if (cfgPrimaryTrack && !track.isPrimaryTrack()) @@ -384,7 +379,7 @@ struct lambda1520analysis { template bool selectionnewPIDProton(const T& candidate) { - if (tof_at_high_pt) { + if (tofAtHighPt) { if (candidate.hasTOF() && (std::abs(candidate.tofNSigmaPr()) < cMaxTOFnSigmaProton)) { return true; } @@ -436,7 +431,7 @@ struct lambda1520analysis { template bool selectionnewPIDKaon(const T& candidate) { - if (tof_at_high_pt) { + if (tofAtHighPt) { if (candidate.hasTOF() && (std::abs(candidate.tofNSigmaKa()) < cMaxTOFnSigmaKaon)) { return true; } @@ -493,24 +488,43 @@ struct lambda1520analysis { vProtonTPCPIDpTintv.insert(vProtonTPCPIDpTintv.begin(), cMinPtcut); auto vProtonTPCPIDcuts = static_cast>(protonTPCPIDcuts); auto vProtonTOFPIDpTintv = static_cast>(protonTOFPIDpTintv); + auto vProtonTPCTOFCombinedpTintv = static_cast>(protonTPCTOFCombinedpTintv); + auto vProtonTPCTOFCombinedPIDcuts = static_cast>(protonTPCTOFCombinedPIDcuts); auto vProtonTOFPIDcuts = static_cast>(protonTOFPIDcuts); auto lengthOfprotonTPCPIDpTintv = static_cast(vProtonTPCPIDpTintv.size()); auto lengthOfprotonTOFPIDpTintv = static_cast(vProtonTOFPIDpTintv.size()); + auto lengthOfprotonTPCTOFCombinedPIDpTintv = static_cast(vProtonTPCTOFCombinedpTintv.size()); bool isTrk1Selected{true}; // For Proton candidate: if (candidate.hasTOF()) { - if (lengthOfprotonTOFPIDpTintv > 0) { - if (candidate.pt() > vProtonTOFPIDpTintv[lengthOfprotonTOFPIDpTintv - 1]) { - isTrk1Selected = false; - } else { - for (int i = 0; i < lengthOfprotonTOFPIDpTintv; i++) { - if (candidate.pt() < vProtonTOFPIDpTintv[i]) { - if (std::abs(candidate.tofNSigmaPr()) > vProtonTOFPIDcuts[i]) - isTrk1Selected = false; - if (std::abs(candidate.tpcNSigmaPr()) > cMaxTPCnSigmaProtonVETO) - isTrk1Selected = false; + if (pidCutType == 1) { + if (lengthOfprotonTOFPIDpTintv > 0) { + if (candidate.pt() > vProtonTOFPIDpTintv[lengthOfprotonTOFPIDpTintv - 1]) { + isTrk1Selected = false; + } else { + for (int i = 0; i < lengthOfprotonTOFPIDpTintv; i++) { + if (candidate.pt() < vProtonTOFPIDpTintv[i]) { + + if (std::abs(candidate.tofNSigmaPr()) > vProtonTOFPIDcuts[i]) + isTrk1Selected = false; + if (std::abs(candidate.tpcNSigmaPr()) > cMaxTPCnSigmaProtonVETO) + isTrk1Selected = false; + } + } + } + } + } else if (pidCutType == 2) { + if (lengthOfprotonTPCTOFCombinedPIDpTintv > 0) { + if (candidate.pt() > vProtonTPCTOFCombinedpTintv[lengthOfprotonTPCTOFCombinedPIDpTintv - 1]) { + isTrk1Selected = false; + } else { + for (int i = 0; i < lengthOfprotonTPCTOFCombinedPIDpTintv; i++) { + if (candidate.pt() < vProtonTPCTOFCombinedpTintv[i]) { + if ((candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr() + candidate.tofNSigmaPr() * candidate.tofNSigmaPr()) > (vProtonTPCTOFCombinedPIDcuts[i] * vProtonTPCTOFCombinedPIDcuts[i])) + isTrk1Selected = false; + } } } } @@ -539,24 +553,43 @@ struct lambda1520analysis { vKaonTPCPIDpTintv.insert(vKaonTPCPIDpTintv.begin(), cMinPtcut); auto vKaonTPCPIDcuts = static_cast>(kaonTPCPIDcuts); auto vKaonTOFPIDpTintv = static_cast>(kaonTOFPIDpTintv); + auto vKaonTPCTOFCombinedpTintv = static_cast>(kaonTPCTOFCombinedpTintv); + auto vKaonTPCTOFCombinedPIDcuts = static_cast>(kaonTPCTOFCombinedPIDcuts); auto vKaonTOFPIDcuts = static_cast>(kaonTOFPIDcuts); auto lengthOfkaonTPCPIDpTintv = static_cast(vKaonTPCPIDpTintv.size()); auto lengthOfkaonTOFPIDpTintv = static_cast(vKaonTOFPIDpTintv.size()); + auto lengthOfkaonTPCTOFCombinedPIDpTintv = static_cast(vKaonTPCTOFCombinedpTintv.size()); bool isTrk2Selected{true}; // For Kaon candidate: if (candidate.hasTOF()) { - if (lengthOfkaonTOFPIDpTintv > 0) { - if (candidate.pt() > vKaonTOFPIDpTintv[lengthOfkaonTOFPIDpTintv - 1]) { - isTrk2Selected = false; - } else { - for (int i = 0; i < lengthOfkaonTOFPIDpTintv; i++) { - if (candidate.pt() < vKaonTOFPIDpTintv[i]) { - if (std::abs(candidate.tofNSigmaKa()) > vKaonTOFPIDcuts[i]) - isTrk2Selected = false; - if (std::abs(candidate.tpcNSigmaKa()) > cMaxTPCnSigmaKaonVETO) - isTrk2Selected = false; + if (pidCutType == 1) { + if (lengthOfkaonTOFPIDpTintv > 0) { + if (candidate.pt() > vKaonTOFPIDpTintv[lengthOfkaonTOFPIDpTintv - 1]) { + isTrk2Selected = false; + } else { + for (int i = 0; i < lengthOfkaonTOFPIDpTintv; i++) { + if (candidate.pt() < vKaonTOFPIDpTintv[i]) { + + if (std::abs(candidate.tofNSigmaKa()) > vKaonTOFPIDcuts[i]) + isTrk2Selected = false; + if (std::abs(candidate.tpcNSigmaKa()) > cMaxTPCnSigmaKaonVETO) + isTrk2Selected = false; + } + } + } + } + } else if (pidCutType == 2) { + if (lengthOfkaonTPCTOFCombinedPIDpTintv > 0) { + if (candidate.pt() > vKaonTPCTOFCombinedpTintv[lengthOfkaonTPCTOFCombinedPIDpTintv - 1]) { + isTrk2Selected = false; + } else { + for (int i = 0; i < lengthOfkaonTPCTOFCombinedPIDpTintv; i++) { + if (candidate.pt() < vKaonTPCTOFCombinedpTintv[i]) { + if ((candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) > (vKaonTPCTOFCombinedPIDcuts[i] * vKaonTPCTOFCombinedPIDcuts[i])) + isTrk2Selected = false; + } } } } @@ -583,27 +616,27 @@ struct lambda1520analysis { bool selectionPIDProtonFixed(const T& candidate) { if (candidate.hasTOF()) { - if (candidate.pt() < 1.5 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && TMath::Abs(candidate.tofNSigmaPr()) < 4.0) { + if (candidate.pt() < 1.5 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < 3.0 && std::abs(candidate.tofNSigmaPr()) < 4.0) { return true; } - if (candidate.pt() >= 1.5 && candidate.pt() < 2.0 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -3.0 && candidate.tofNSigmaPr() < 4.0) { + if (candidate.pt() >= 1.5 && candidate.pt() < 2.0 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -3.0 && candidate.tofNSigmaPr() < 4.0) { return true; } - if (candidate.pt() >= 2.0 && candidate.pt() < 2.5 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < 4.0) { + if (candidate.pt() >= 2.0 && candidate.pt() < 2.5 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < 4.0) { return true; } - if (candidate.pt() >= 2.5 && candidate.pt() < 3.0 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -1.5 && candidate.tofNSigmaPr() < 3.0) { + if (candidate.pt() >= 2.5 && candidate.pt() < 3.0 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -1.5 && candidate.tofNSigmaPr() < 3.0) { return true; } - if (candidate.pt() >= 3.0 && candidate.pt() < 4.0 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -1.0 && candidate.tofNSigmaPr() < 2.0) { + if (candidate.pt() >= 3.0 && candidate.pt() < 4.0 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -1.0 && candidate.tofNSigmaPr() < 2.0) { return true; } } if (!candidate.hasTOF()) { - if (candidate.pt() < 0.4 && TMath::Abs(candidate.tpcNSigmaPr()) < 4.0) { + if (candidate.pt() < 0.4 && std::abs(candidate.tpcNSigmaPr()) < 4.0) { return true; } - if (candidate.pt() >= 0.4 && candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { + if (candidate.pt() >= 0.4 && candidate.pt() < 0.5 && std::abs(candidate.tpcNSigmaPr()) < 3.0) { return true; } if (candidate.pt() >= 0.5 && candidate.pt() < 0.7 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < 2.5) { @@ -623,24 +656,24 @@ struct lambda1520analysis { bool selectionPIDKaonFixed(const T& candidate) { if (candidate.hasTOF()) { - if (candidate.pt() < 0.8 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < 3.0 && TMath::Abs(candidate.tofNSigmaKa()) < 4.0) { + if (candidate.pt() < 0.8 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < 3.0 && std::abs(candidate.tofNSigmaKa()) < 4.0) { return true; } - if (candidate.pt() >= 0.8 && candidate.pt() < 1.3 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < 3.0 && candidate.tofNSigmaKa() > -3.0 && candidate.tofNSigmaKa() < 4.0) { + if (candidate.pt() >= 0.8 && candidate.pt() < 1.3 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < 3.0 && candidate.tofNSigmaKa() > -3.0 && candidate.tofNSigmaKa() < 4.0) { return true; } - if (candidate.pt() >= 1.3 && candidate.pt() < 1.6 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < 3.0 && candidate.tofNSigmaKa() > -2.0 && candidate.tofNSigmaKa() < 3.0) { + if (candidate.pt() >= 1.3 && candidate.pt() < 1.6 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < 3.0 && candidate.tofNSigmaKa() > -2.0 && candidate.tofNSigmaKa() < 3.0) { return true; } - if (candidate.pt() >= 1.6 && candidate.pt() < 1.8 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < 3.0 && candidate.tofNSigmaKa() > -1.5 && candidate.tofNSigmaKa() < 2.5) { + if (candidate.pt() >= 1.6 && candidate.pt() < 1.8 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < 3.0 && candidate.tofNSigmaKa() > -1.5 && candidate.tofNSigmaKa() < 2.5) { return true; } - if (candidate.pt() >= 1.8 && candidate.pt() < 2.5 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < 3.0 && candidate.tofNSigmaKa() > -1.0 && candidate.tofNSigmaKa() < 2.0) { + if (candidate.pt() >= 1.8 && candidate.pt() < 2.5 && candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < 3.0 && candidate.tofNSigmaKa() > -1.0 && candidate.tofNSigmaKa() < 2.0) { return true; } } if (!candidate.hasTOF()) { - if (candidate.pt() < 0.3 && TMath::Abs(candidate.tpcNSigmaKa()) < 3.0) { + if (candidate.pt() < 0.3 && std::abs(candidate.tpcNSigmaKa()) < 3.0) { return true; } if (candidate.pt() >= 0.3 && candidate.pt() < 0.4 && candidate.tpcNSigmaKa() > -2.0 && candidate.tpcNSigmaKa() < 2.5) { @@ -654,7 +687,7 @@ struct lambda1520analysis { } template - bool RejectPion(const T& candidate) + bool rejectPion(const T& candidate) { if (candidate.pt() > 1.0 && candidate.pt() < 2.0 && !candidate.hasTOF() && candidate.tpcNSigmaPi() < 2) { return false; @@ -669,10 +702,10 @@ struct lambda1520analysis { // LOG(info) << "Before pass, Collision index:" << collision.index() << "multiplicity: " << collision.cent() << std::endl; - auto occupancy_no = collision.trackOccupancyInTimeRange(); - if (applyOccupancyCut && occupancy_no < OccupancyCut) { - return; - } + // auto occupancyNo = collision.trackOccupancyInTimeRange(); + // if (applyOccupancyCut && occupancyNo < occupancyCut) { + // return; + // } // Multiplicity correlation calibration plots if (isFilladditionalQA) { @@ -698,9 +731,9 @@ struct lambda1520analysis { } } // LOG(info) << "After pass, Collision index:" << collision.index() << "multiplicity: " << collision.cent() << std::endl; - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance, ldaughter_rot, lresonance_rot; + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance, ldaughterRot, lresonanceRot; - for (auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { + for (const auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { // Full index policy is needed to consider all possible combinations if (trk1.index() == trk2.index()) continue; // We need to run (0,1), (1,0) pairs as well. but same id pairs are not needed. @@ -729,9 +762,9 @@ struct lambda1520analysis { auto trk2NSigmaKaTPC = trk2.tpcNSigmaKa(); auto trk2NSigmaKaTOF = (isTrk2hasTOF) ? trk2.tofNSigmaKa() : -999.; - auto deltaEta = TMath::Abs(trk1.eta() - trk2.eta()); - auto deltaPhi = TMath::Abs(trk1.phi() - trk2.phi()); - deltaPhi = (deltaPhi > TMath::Pi()) ? (2 * TMath::Pi() - deltaPhi) : deltaPhi; + auto deltaEta = std::abs(trk1.eta() - trk2.eta()); + auto deltaPhi = std::abs(trk1.phi() - trk2.phi()); + deltaPhi = (deltaPhi > o2::constants::math::PI) ? (o2::constants::math::TwoPI - deltaPhi) : deltaPhi; //// QA plots before the selection // --- Track QA all @@ -769,15 +802,15 @@ struct lambda1520analysis { continue; if (cUseOnlyTOFTrackKa && !isTrk2hasTOF) continue; - if (cRejectPion && RejectPion(trk2)) + if (crejectPion && rejectPion(trk2)) continue; if (cOldPIDcut) { if (!selectionoldPIDProton(trk1) || !selectionoldPIDKaon(trk2)) continue; - } else if (!cOldPIDcut && !FixedPIDcut) { + } else if (!cOldPIDcut && !fixedPIDcut) { if (!selectionnewPIDProton(trk1) || !selectionnewPIDKaon(trk2)) continue; - } else if (FixedPIDcut) { + } else if (fixedPIDcut) { if (!selectionPIDProtonFixed(trk1) || !selectionPIDKaonFixed(trk2)) continue; } @@ -841,7 +874,7 @@ struct lambda1520analysis { lDecayDaughter2.SetPtEtaPhiM(trk2.pt(), trk2.eta(), trk2.phi(), massKa); lResonance = lDecayDaughter1 + lDecayDaughter2; // Rapidity cut - if (abs(lResonance.Rapidity()) > 0.5) + if (std::abs(lResonance.Rapidity()) > 0.5) continue; if (cfgCutsOnMother) { @@ -870,20 +903,24 @@ struct lambda1520analysis { //// Un-like sign pair only if (trk1.sign() * trk2.sign() < 0) { if constexpr (IsData) { - if (IsCalcRotBkg) { - for (int i = 0; i < c_nof_rotations; i++) { - float theta2 = rn->Uniform(TMath::Pi() - TMath::Pi() / rotational_cut, TMath::Pi() + TMath::Pi() / rotational_cut); - ldaughter_rot.SetPtEtaPhiM(trk2.pt(), trk2.eta(), trk2.phi() + theta2, massKa); // for rotated background - lresonance_rot = lDecayDaughter1 + ldaughter_rot; - histos.fill(HIST("Result/Data/h3lambda1520InvMassRotation"), multiplicity, lresonance_rot.Pt(), lresonance_rot.M(), occupancy_no); + if (isCalcRotBkg) { + for (int i = 0; i < cNofRotations; i++) { + float theta2 = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / rotationalcut, o2::constants::math::PI + o2::constants::math::PI / rotationalcut); + ldaughterRot.SetPtEtaPhiM(trk2.pt(), trk2.eta(), trk2.phi() + theta2, massKa); // for rotated background + lresonanceRot = lDecayDaughter1 + ldaughterRot; + histos.fill(HIST("Result/Data/h3lambda1520InvMassRotation"), multiplicity, lresonanceRot.Pt(), lresonanceRot.M()); } } if (trk1.sign() < 0) { - histos.fill(HIST("Result/Data/lambda1520invmass"), lResonance.M()); + if (invmass1D) { + histos.fill(HIST("Result/Data/lambda1520invmass"), lResonance.M()); + } histos.fill(HIST("Result/Data/h3lambda1520invmass"), multiplicity, lResonance.Pt(), lResonance.M()); } else if (trk1.sign() > 0) { - histos.fill(HIST("Result/Data/antilambda1520invmass"), lResonance.M()); + if (invmass1D) { + histos.fill(HIST("Result/Data/antilambda1520invmass"), lResonance.M()); + } histos.fill(HIST("Result/Data/h3antilambda1520invmass"), multiplicity, lResonance.Pt(), lResonance.M()); } if (cEtaAssym && trk1.eta() > 0.2 && trk1.eta() < 0.8 && trk2.eta() > 0.2 && trk2.eta() < 0.8) { // Eta-range will be updated @@ -894,7 +931,9 @@ struct lambda1520analysis { histos.fill(HIST("Result/Data/h3lambda1520invmassUnlikeSignCside"), multiplicity, lResonance.Pt(), lResonance.M()); } } else if (IsMix) { - histos.fill(HIST("Result/Data/lambda1520invmassME"), lResonance.M()); + if (invmass1D) { + histos.fill(HIST("Result/Data/lambda1520invmassME"), lResonance.M()); + } histos.fill(HIST("Result/Data/h3lambda1520invmassME"), multiplicity, lResonance.Pt(), lResonance.M()); if (cEtaAssym && trk1.eta() > 0.2 && trk1.eta() < 0.8 && trk2.eta() > 0.2 && trk2.eta() < 0.8) { // Eta-range will be updated histos.fill(HIST("Result/Data/hlambda1520invmassMixedAside"), lResonance.M()); @@ -918,18 +957,18 @@ struct lambda1520analysis { if constexpr (IsMC) { // LOG(info) << "trk1 pdgcode: " << trk1.pdgCode() << "trk2 pdgcode: " << trk2.pdgCode() << std::endl; - if (abs(trk1.pdgCode()) != 2212 || abs(trk2.pdgCode()) != 321) + if (std::abs(trk1.pdgCode()) != 2212 || std::abs(trk2.pdgCode()) != 321) continue; if (trk1.motherId() != trk2.motherId()) // Same mother continue; - if (abs(trk1.motherPDG()) != 102134) + if (std::abs(trk1.motherPDG()) != 102134) continue; // Track selection check. - histos.fill(HIST("QA/MC/trkDCAxy_pr"), trk1.dcaXY()); - histos.fill(HIST("QA/MC/trkDCAxy_ka"), trk2.dcaXY()); - histos.fill(HIST("QA/MC/trkDCAz_pr"), trk1.dcaZ()); - histos.fill(HIST("QA/MC/trkDCAz_ka"), trk2.dcaZ()); + histos.fill(HIST("QA/MC/trkDCAxy_pr"), trk1ptPr, trk1.dcaXY()); + histos.fill(HIST("QA/MC/trkDCAxy_ka"), trk2ptKa, trk2.dcaXY()); + histos.fill(HIST("QA/MC/trkDCAz_pr"), trk1ptPr, trk1.dcaZ()); + histos.fill(HIST("QA/MC/trkDCAz_ka"), trk2ptKa, trk2.dcaZ()); histos.fill(HIST("QA/MC/TPC_Nsigma_pr_all"), multiplicity, trk1ptPr, trk1NSigmaPrTPC); if (isTrk1hasTOF) { @@ -942,12 +981,16 @@ struct lambda1520analysis { // MC histograms if (trk1.motherPDG() > 0) { - histos.fill(HIST("Result/MC/lambda1520Reco"), lResonance.Pt(), multiplicity); - histos.fill(HIST("Result/MC/hlambda1520Recoinvmass"), lResonance.M()); + if (cAdditionalMCPlots) { + histos.fill(HIST("Result/MC/lambda1520Reco"), lResonance.Pt(), multiplicity); + histos.fill(HIST("Result/MC/hlambda1520Recoinvmass"), lResonance.M()); + } histos.fill(HIST("Result/MC/h3lambda1520Recoinvmass"), multiplicity, lResonance.Pt(), lResonance.M()); } else { - histos.fill(HIST("Result/MC/antilambda1520Reco"), lResonance.Pt(), multiplicity); - histos.fill(HIST("Result/MC/hantilambda1520Recoinvmass"), lResonance.M()); + if (cAdditionalMCPlots) { + histos.fill(HIST("Result/MC/antilambda1520Reco"), lResonance.Pt(), multiplicity); + histos.fill(HIST("Result/MC/hantilambda1520Recoinvmass"), lResonance.M()); + } histos.fill(HIST("Result/MC/h3antilambda1520Recoinvmass"), multiplicity, lResonance.Pt(), lResonance.M()); } } @@ -962,10 +1005,14 @@ struct lambda1520analysis { } // Like sign pair ++ if (trk1.sign() > 0) { - histos.fill(HIST("Result/Data/lambda1520invmassLSPP"), lResonance.M()); + if (invmass1D) { + histos.fill(HIST("Result/Data/lambda1520invmassLSPP"), lResonance.M()); + } histos.fill(HIST("Result/Data/h3lambda1520invmassLSPP"), multiplicity, lResonance.Pt(), lResonance.M()); } else { // Like sign pair -- - histos.fill(HIST("Result/Data/lambda1520invmassLSMM"), lResonance.M()); + if (invmass1D) { + histos.fill(HIST("Result/Data/lambda1520invmassLSMM"), lResonance.M()); + } histos.fill(HIST("Result/Data/h3lambda1520invmassLSMM"), multiplicity, lResonance.Pt(), lResonance.M()); } } @@ -973,35 +1020,35 @@ struct lambda1520analysis { } } - void processData(aod::ResoCollision& collision, + void processData(aod::ResoCollision const& collision, aod::ResoTracks const& resotracks) { if (additionalQAeventPlots) histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); fillHistograms(collision, resotracks, resotracks); } - PROCESS_SWITCH(lambda1520analysis, processData, "Process Event for data without partition", false); + PROCESS_SWITCH(Lambda1520analysis, processData, "Process Event for data without partition", false); void processMC(ResoMCCols::iterator const& collision, soa::Join const& resotracks) { - if (!collision.isInAfterAllCuts() || (abs(collision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut + if (!collision.isInAfterAllCuts() || (std::abs(collision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut return; fillHistograms(collision, resotracks, resotracks); } - PROCESS_SWITCH(lambda1520analysis, processMC, "Process Event for MC Light without partition", false); + PROCESS_SWITCH(Lambda1520analysis, processMC, "Process Event for MC Light without partition", false); - void processMCTrue(ResoMCCols::iterator const& collision, aod::ResoMCParents& resoParents) + void processMCTrue(ResoMCCols::iterator const& collision, aod::ResoMCParents const& resoParents) { auto multiplicity = collision.cent(); // Not related to the real collisions - for (auto& part : resoParents) { // loop over all MC particles - if (abs(part.pdgCode()) != 102134) // Lambda1520(0) + for (const auto& part : resoParents) { // loop over all MC particles + if (std::abs(part.pdgCode()) != 102134) // Lambda1520(0) continue; - if (abs(part.y()) > 0.5) // rapidity cut + if (std::abs(part.y()) > 0.5) // rapidity cut continue; - bool pass1 = abs(part.daughterPDG1()) == 321 || abs(part.daughterPDG2()) == 321; // At least one decay to Kaon - bool pass2 = abs(part.daughterPDG1()) == 2212 || abs(part.daughterPDG2()) == 2212; // At least one decay to Proton + bool pass1 = std::abs(part.daughterPDG1()) == 321 || std::abs(part.daughterPDG2()) == 321; // At least one decay to Kaon + bool pass2 = std::abs(part.daughterPDG1()) == 2212 || std::abs(part.daughterPDG2()) == 2212; // At least one decay to Proton if (!pass1 || !pass2) // If we have both decay products continue; @@ -1036,26 +1083,26 @@ struct lambda1520analysis { } } } - PROCESS_SWITCH(lambda1520analysis, processMCTrue, "Process Event for MC only", false); + PROCESS_SWITCH(Lambda1520analysis, processMCTrue, "Process Event for MC only", false); // Processing Event Mixing using BinningTypeVtxZT0M = ColumnBinningPolicy; - void processME(o2::aod::ResoCollisions& collisions, aod::ResoTracks const& resotracks) + void processME(o2::aod::ResoCollisions const& collisions, aod::ResoTracks const& resotracks) { auto tracksTuple = std::make_tuple(resotracks); - BinningTypeVtxZT0M colBinning{{CfgVtxBins, CfgMultBins}, true}; + BinningTypeVtxZT0M colBinning{{cfgVtxBins, cfgMultBins}, true}; SameKindPair pairs{colBinning, nEvtMixing, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip - for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { if (additionalQAeventPlots) histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); fillHistograms(collision1, tracks1, tracks2); } }; - PROCESS_SWITCH(lambda1520analysis, processME, "Process EventMixing light without partition", false); + PROCESS_SWITCH(Lambda1520analysis, processME, "Process EventMixing light without partition", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"lf-lambda1520analysis"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Resonances/lambda1520analysisinOO.cxx b/PWGLF/Tasks/Resonances/lambda1520analysisinOO.cxx new file mode 100644 index 00000000000..d280d3c1da3 --- /dev/null +++ b/PWGLF/Tasks/Resonances/lambda1520analysisinOO.cxx @@ -0,0 +1,1181 @@ +// 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. + +/// \file lstaranalysis.cxx +/// \brief This standalone task reconstructs track-track decay of lambda(1520) resonance candidate +/// \author Hirak Kumar Koley + +// 1. Own header (doesn't exist) + +// 2. C system headers (none) + +// 3. C++ system headers +#include + +// 4. Other includes: O2 framework, ROOT, etc. +#include "PWGLF/Utils/collisionCuts.h" + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" +#include "TPDGCode.h" +#include "TRandom.h" +#include "TVector3.h" + +using namespace o2; +using namespace o2::soa; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +using LorentzVectorPtEtaPhiMass = ROOT::Math::PtEtaPhiMVector; + +enum { + kINEL = 1, + kINEL10, + kINELg0, + kINELg010, + kTrig, + kTrig10, + kTrigINELg0, + kTrigINELg010, + kSel8, + kSel810, + kSel8INELg0, + kSel8INELg010, + kAllCuts, + kAllCuts10, + kAllCutsINELg0, + kAllCutsINELg010, +}; + +struct Lstaranalysis { + // Define slice per Resocollision + SliceCache cache; + Preslice perCollision = o2::aod::track::collisionId; + Preslice perMcCollision = o2::aod::mcparticle::mcCollisionId; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Service pdg; + + /// Event cuts + o2::analysis::CollisonCuts colCuts; + + Configurable cfgEvtZvtx{"cfgEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable cfgEvtOccupancyInTimeRangeMax{"cfgEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; + Configurable cfgEvtOccupancyInTimeRangeMin{"cfgEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; + Configurable cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"}; + Configurable cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"}; + Configurable cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; + Configurable cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; + Configurable cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; + Configurable cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", false, "Evt sel: apply Z-vertex time difference"}; + Configurable cfgEvtPileupRejection{"cfgEvtPileupRejection", false, "Evt sel: apply pileup rejection"}; + Configurable cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + Configurable cfgEvtCollInTimeRangeStandard{"cfgEvtCollInTimeRangeStandard", false, "Evt sel: apply NoCollInTimeRangeStandard"}; + + Configurable cfgEventCentralityMin{"cfgEventCentralityMin", 0.0f, "Event sel: minimum centrality"}; + Configurable cfgEventCentralityMax{"cfgEventCentralityMax", 100.0f, "Event sel: maximum centrality"}; + + // Configurables + // Pre-selection Track cuts + Configurable trackSelection{"trackSelection", 0, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; + Configurable cMinPtcut{"cMinPtcut", 0.15f, "Minimal pT for tracks"}; + Configurable cMinTPCNClsFound{"cMinTPCNClsFound", 120, "minimum TPCNClsFound value for good track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"}; + Configurable cfgMinCrossedRows{"cfgMinCrossedRows", 70, "min crossed rows for good track"}; + + // DCA Selections + // DCAr to PV + Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.1f, "Track DCAr cut to PV Maximum"}; + // DCAz to PV + Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 0.1f, "Track DCAz cut to PV Maximum"}; + + // Track selections + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor + Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; + Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; + Configurable cTPCNClsFound{"cTPCNClsFound", false, "Switch to turn on/off TPCNClsFound cut"}; + Configurable cDCAr7SigCut{"cDCAr7SigCut", false, "Track DCAr 7 Sigma cut to PV Maximum"}; + + /// PID Selections + Configurable cByPassTOF{"cByPassTOF", false, "By pass TOF PID selection"}; // By pass TOF PID selection + Configurable cPIDcutType{"cPIDcutType", 2, "cPIDcutType = 1 for square cut, 2 for circular cut"}; // By pass TOF PID selection + + // Kaon + Configurable> kaonTPCPIDpTintv{"kaonTPCPIDpTintv", {0.5}, "pT intervals for Kaon TPC PID cuts"}; + Configurable> kaonTPCPIDcuts{"kaonTPCPIDcuts", {2}, "nSigma list for Kaon TPC PID cuts"}; + Configurable> kaonTOFPIDpTintv{"kaonTOFPIDpTintv", {999.}, "pT intervals for Kaon TOF PID cuts"}; + Configurable> kaonTOFPIDcuts{"kaonTOFPIDcuts", {2}, "nSigma list for Kaon TOF PID cuts"}; + Configurable> kaonTPCTOFCombinedpTintv{"kaonTPCTOFCombinedpTintv", {999.}, "pT intervals for Kaon TPC-TOF PID cuts"}; + Configurable> kaonTPCTOFCombinedPIDcuts{"kaonTPCTOFCombinedPIDcuts", {2}, "nSigma list for Kaon TPC-TOF PID cuts"}; + + // Proton + Configurable> protonTPCPIDpTintv{"protonTPCPIDpTintv", {0.9}, "pT intervals for Kaon TPC PID cuts"}; + Configurable> protonTPCPIDcuts{"protonTPCPIDcuts", {2}, "nSigma list for Kaon TPC PID cuts"}; + Configurable> protonTOFPIDpTintv{"protonTOFPIDpTintv", {999.}, "pT intervals for Kaon TOF PID cuts"}; + Configurable> protonTOFPIDcuts{"protonTOFPIDcuts", {2}, "nSigma list for Kaon TOF PID cuts"}; + Configurable> protonTPCTOFCombinedpTintv{"protonTPCTOFCombinedpTintv", {999.}, "pT intervals for Proton TPC-TOF PID cuts"}; + Configurable> protonTPCTOFCombinedPIDcuts{"protonTPCTOFCombinedPIDcuts", {2}, "nSigma list for Proton TPC-TOF PID cuts"}; + + // Additional purity check + Configurable crejectPion{"crejectPion", false, "Switch to turn on/off pion contamination"}; + Configurable cApplyOpeningAngle{"cApplyOpeningAngle", false, "Kinematic Cuts for p-K pair opening angle"}; + Configurable cMinOpeningAngle{"cMinOpeningAngle", 1.4, "Maximum deltaEta between daughters"}; + Configurable cMaxOpeningAngle{"cMaxOpeningAngle", 2.4, "Maximum deltaPhi between daughters"}; + + /// Event Mixing + Configurable nEvtMixing{"nEvtMixing", 10, "Number of events to mix"}; + ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgMultBins{"cfgMultBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - multiplicity"}; + + // Rotational background + Configurable isCalcRotBkg{"isCalcRotBkg", true, "Calculate rotational background"}; + Configurable rotationalcut{"rotationalcut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; + Configurable cNofRotations{"cNofRotations", 3, "Number of random rotations in the rotational background"}; + + // MC selection cut + Configurable cZvertCutMC{"cZvertCutMC", 10.0, "MC Z-vertex cut"}; + Configurable cEtacutMC{"cEtacutMC", 0.5, "MC eta cut"}; + Configurable cUseRapcutMC{"cUseRapcutMC", true, "MC eta cut"}; + Configurable cUseEtacutMC{"cUseEtacutMC", true, "MC eta cut"}; + + // cuts on mother + Configurable cfgCutsOnMother{"cfgCutsOnMother", false, "Enable additional cuts on mother"}; + Configurable cMaxPtMotherCut{"cMaxPtMotherCut", 10.0, "Maximum pt of mother cut"}; + Configurable cMaxMinvMotherCut{"cMaxMinvMotherCut", 3.0, "Maximum Minv of mother cut"}; + Configurable cMaxDeltaEtaCut{"cMaxDeltaEtaCut", 0.7, "Maximum deltaEta between daughters"}; + Configurable cMaxDeltaPhiCut{"cMaxDeltaPhiCut", 1.5, "Maximum deltaPhi between daughters"}; + + // switches + Configurable cFillMultQA{"cFillMultQA", false, "Turn on/off additional QA plots"}; + Configurable cFilladditionalQAeventPlots{"cFilladditionalQAeventPlots", false, "Additional QA event plots"}; + Configurable cFilladditionalMEPlots{"cFilladditionalMEPlots", false, "Additional Mixed event plots"}; + Configurable cFilldeltaEtaPhiPlots{"cFilldeltaEtaPhiPlots", false, "Enamble additional cuts on daughters"}; + Configurable cFillinvmass1DPlots{"cFillinvmass1DPlots", false, "Invariant mass 1D"}; + Configurable multEstimator{"multEstimator", 0, "Select multiplicity estimator: 0 - FT0M, 1 - FT0A, 2 - FT0C"}; + + Configurable cfgCentEst{"cfgCentEst", 2, "Centrality estimator, 1: FT0C, 2: FT0M"}; + + TRandom* rn = new TRandom(); + + // Pre-filters for efficient process + // Filter tofPIDFilter = aod::track::tofExpMom < 0.f || ((aod::track::tofExpMom > 0.f) && ((nabs(aod::pidtof::tofNSigmaPi) < pidnSigmaPreSelectionCut) || (nabs(aod::pidtof::tofNSigmaKa) < pidnSigmaPreSelectionCut) || (nabs(aod::pidtof::tofNSigmaPr) < pidnSigmaPreSelectionCut))); // TOF + // Filter tpcPIDFilter = nabs(aod::pidtpc::tpcNSigmaPi) < pidnSigmaPreSelectionCut || nabs(aod::pidtpc::tpcNSigmaKa) < pidnSigmaPreSelectionCut || nabs(aod::pidtpc::tpcNSigmaPr) < pidnSigmaPreSelectionCut; // TPC + /* Filter trackFilter = (trackSelection == 0) || + ((trackSelection == 1) && requireGlobalTrackInFilter()) || + ((trackSelection == 2) && requireGlobalTrackWoPtEtaInFilter()) || + ((trackSelection == 3) && requireGlobalTrackWoDCAInFilter()) || + ((trackSelection == 4) && requireQualityTracksInFilter()) || + ((trackSelection == 5) && requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks)); */ + Filter trackEtaFilter = nabs(aod::track::eta) < cfgCutEta; // Eta cut + + using EventCandidates = soa::Join; + using TrackCandidates = soa::Filtered>; + + using MCEventCandidates = soa::Join; + using MCTrackCandidates = soa::Filtered>; + + /// Figures + ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 0.0, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.25, 1.3, 1.4, 1.5, 1.6, 1.7, 1.75, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.5, 4.6, 4.8, 4.9, 5.0, 5.5, 5.6, 6.0, 6.4, 6.5, 7.0, 7.2, 8.0, 9.0, 9.5, 9.6, 10.0, 11.0, 11.5, 12.0, 13.0, 14.0, 14.4, 15.0, 16.0, 18.0, 19.2, 20.}, "Binning of the pT axis"}; + ConfigurableAxis binsPtQA{"binsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0, 10.2, 10.4, 10.6, 10.8, 11, 11.2, 11.4, 11.6, 11.8, 12, 12.2, 12.4, 12.6, 12.8, 13, 13.2, 13.4, 13.6, 13.8, 14, 14.2, 14.4, 14.6, 14.8, 15, 15.2, 15.4, 15.6, 15.8, 16, 16.2, 16.4, 16.6, 16.8, 17, 17.2, 17.4, 17.6, 17.8, 18, 18.2, 18.4, 18.6, 18.8, 19, 19.2, 19.4, 19.6, 19.8, 20}, "Binning of the pT axis"}; + ConfigurableAxis binsEta{"binsEta", {150, -1.5, 1.5}, ""}; + ConfigurableAxis binsMass{"binsMass", {70, 1.3, 2.0}, "Invariant Mass (GeV/#it{c}^2)"}; + ConfigurableAxis binsMult{"binsMult", {105, 0.0, 105.0}, "mult_{FT0M}"}; + ConfigurableAxis binsDCAz{"binsDCAz", {40, -0.2, 0.2}, ""}; + ConfigurableAxis binsDCAxy{"binsDCAxy", {40, -0.2, 0.2}, ""}; + ConfigurableAxis binsTPCXrows{"binsTPCXrows", {100, 60, 160}, ""}; + ConfigurableAxis binsnSigma{"binsnSigma", {130, -6.5, 6.5}, ""}; + ConfigurableAxis binsnTPCSignal{"binsnTPCSignal", {1000, 0, 1000}, ""}; + ConfigurableAxis binsEtaPhi{"binsEtaPhi", {350, -3.5, 3.5}, ""}; + + float centrality; + + void init(framework::InitContext&) + { + centrality = -999; + + colCuts.setCuts(cfgEvtZvtx, cfgEvtTriggerCheck, cfgEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, cfgEvtOccupancyInTimeRangeMax, cfgEvtOccupancyInTimeRangeMin); + + colCuts.init(&histos); + colCuts.setTriggerTVX(cfgEvtTriggerTVXSel); + colCuts.setApplyTFBorderCut(cfgEvtTFBorderCut); + colCuts.setApplyITSTPCvertex(cfgEvtUseITSTPCvertex); + colCuts.setApplyZvertexTimedifference(cfgEvtZvertexTimedifference); + colCuts.setApplyPileupRejection(cfgEvtPileupRejection); + colCuts.setApplyNoITSROBorderCut(cfgEvtNoITSROBorderCut); + colCuts.setApplyCollInTimeRangeStandard(cfgEvtCollInTimeRangeStandard); + colCuts.printCuts(); + + // axes + AxisSpec axisPt{binsPt, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisPtQA{binsPtQA, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisEta{binsEta, "#eta"}; + AxisSpec axisRap{binsEta, "#it{y}"}; + AxisSpec axisMassLambda1520{binsMass, "Invariant Mass (GeV/#it{c}^2)"}; + AxisSpec axisMult{binsMult, "mult_{V0M}"}; + AxisSpec axisDCAz{binsDCAz, "DCA_{z}"}; + AxisSpec axisDCAxy{binsDCAxy, "DCA_{XY}"}; + AxisSpec axisTPCXrow{binsTPCXrows, "#Xrows_{TPC}"}; + AxisSpec axisPIDQA{binsnSigma, "#sigma"}; + AxisSpec axisTPCSignal{binsnTPCSignal, ""}; + AxisSpec axisMClabel{6, -1.5, 5.5, "MC Label"}; + AxisSpec axisEtaPhi{binsEtaPhi, ""}; + AxisSpec axisPhi{350, 0, 7, "#Phi"}; + AxisSpec axisMultMix{cfgMultBins, "Multiplicity"}; + AxisSpec axisVtxMix{cfgVtxBins, "Vertex Z (cm)"}; + AxisSpec idxMCAxis = {26, -0.5, 25.5, "Index"}; + + if (cFilladditionalQAeventPlots) { + // event histograms + if (doprocessData) { + histos.add("TestME/hPairsCounterSameE", "tot n pairs sameE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + histos.add("QAevent/hEvtCounterSameE", "Number of analyzed Same Events", HistType::kTH1F, {{1, 0.5, 1.5}}); + histos.add("QAevent/hVertexZSameE", "Collision Vertex Z position", HistType::kTH1F, {{100, -15., 15.}}); + histos.add("QAevent/hMultiplicityPercentSameE", "Multiplicity percentile of collision", HistType::kTH1F, {{120, 0.0f, 120.0f}}); + histos.add("TestME/hCollisionIndexSameE", "coll index sameE", HistType::kTH1F, {{500, 0.0f, 500.0f}}); + histos.add("TestME/hnTrksSameE", "n tracks per event SameE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}}); + } + // Test on Mixed event + if (doprocessME) { + + // Histograms for Mixed Event Pool characteristics + histos.add("QAevent/hMixPool_VtxZ", "Mixed Event Pool: Vertex Z;Vtx Z (cm);Counts", HistType::kTH1F, {axisVtxMix}); + histos.add("QAevent/hMixPool_Multiplicity", "Mixed Event Pool: Multiplicity;Multiplicity;Counts", HistType::kTH1F, {axisMultMix}); + histos.add("QAevent/hMixPool_VtxZ_vs_Multiplicity", "Mixed Event Pool: Vertex Z vs Multiplicity;Counts", HistType::kTH2F, {axisVtxMix, axisMultMix}); + + histos.add("TestME/hPairsCounterMixedE", "tot n pairs mixedE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + histos.add("QAevent/hEvtCounterMixedE", "Number of analyzed Mixed Events", HistType::kTH1F, {{1, 0.5, 1.5}}); + histos.add("QAevent/hVertexZMixedE", "Collision Vertex Z position", HistType::kTH1F, {{100, -15., 15.}}); + histos.add("QAevent/hMultiplicityPercentMixedE", "Multiplicity percentile of collision", HistType::kTH1F, {{120, 0.0f, 120.0f}}); + histos.add("TestME/hCollisionIndexMixedE", "coll index mixedE", HistType::kTH1F, {{500, 0.0f, 500.0f}}); + histos.add("TestME/hnTrksMixedE", "n tracks per event MixedE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}}); + } + } + + if (doprocessData) { + // Track QA before cuts + // --- Track + histos.add("QA/QAbefore/Track/TOF_TPC_Map_ka_all", "TOF + TPC Combined PID for Kaon;{#sigma_{TOF}^{Kaon}};{#sigma_{TPC}^{Kaon}}", {HistType::kTH2F, {axisPIDQA, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TPC_Nsigma_ka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TPConly_Nsigma_ka", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTH2F, {axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TOF_TPC_Map_pr_all", "TOF + TPC Combined PID for Proton;{#sigma_{TOF}^{Proton}};{#sigma_{TPC}^{Proton}}", {HistType::kTH2F, {axisPIDQA, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TOF_Nsigma_pr_all", "TOF NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TPConly_Nsigma_pr", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTH2F, {axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/dcaZ", "DCA_{Z} distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); DCA_{Z} (cm); ", HistType::kTH2F, {axisPt, axisDCAz}); + histos.add("QA/QAbefore/Track/dcaXY", "DCA_{XY} momentum distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); DCA_{XY} (cm);", HistType::kTH2F, {axisPt, axisDCAxy}); + histos.add("QA/QAbefore/Track/TPC_CR", "# TPC Xrows distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); TPC X rows", HistType::kTH2F, {axisPt, axisTPCXrow}); + histos.add("QA/QAbefore/Track/pT", "pT distribution of Kaons; #it{p}_{T} (GeV/#it{c}); Counts;", {HistType::kTH1F, {axisPt}}); + histos.add("QA/QAbefore/Track/eta", "#eta distribution of Kaons; #eta; Counts;", {HistType::kTH1F, {axisEta}}); + + if (cFillMultQA) { + // Multiplicity correlation calibrations + histos.add("MultCalib/centGloPVpr", "Centrality vs Global-Tracks", kTHnSparseF, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}, {500, 0, 5000, "PV tracks"}}); + histos.add("MultCalib/centGloPVka", "Centrality vs Global-Tracks", kTHnSparseF, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}, {500, 0, 5000, "PV tracks"}}); + } + + // PID QA after cuts + // --- Kaon + histos.add("QA/QAafter/Kaon/TOF_TPC_Map_ka_all", "TOF + TPC Combined PID for Kaon;{#sigma_{TOF}^{Kaon}};{#sigma_{TPC}^{Kaon}}", {HistType::kTH2F, {axisPIDQA, axisPIDQA}}); + histos.add("QA/QAafter/Kaon/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Kaon/TPC_Nsigma_ka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Kaon/TPC_Nsigma_ka_TPConly", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTH2F, {axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Kaon/dcaZ", "DCA_{Z} distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); DCA_{Z} (cm); ", HistType::kTH2F, {axisPt, axisDCAz}); + histos.add("QA/QAafter/Kaon/dcaXY", "DCA_{XY} momentum distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); DCA_{XY} (cm);", HistType::kTH2F, {axisPt, axisDCAxy}); + histos.add("QA/QAafter/Kaon/TPC_CR", "# TPC Xrows distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); TPC X rows", HistType::kTH2F, {axisPt, axisTPCXrow}); + histos.add("QA/QAafter/Kaon/pT", "pT distribution of Kaons; #it{p}_{T} (GeV/#it{c}); Counts;", {HistType::kTH1F, {axisPt}}); + histos.add("QA/QAafter/Kaon/eta", "#eta distribution of Kaons; #eta; Counts;", {HistType::kTH1F, {axisEta}}); + histos.add("QA/QAafter/Kaon/TPC_Signal_ka_all", "TPC Signal for Kaon;#it{p} (GeV/#it{c});TPC Signal (A.U.)", {HistType::kTH2F, {axisPt, axisTPCSignal}}); + histos.add("QA/QAafter/Kaon/TPCnclusterPhika", "TPC ncluster vs phi", kTHnSparseF, {{160, 0, 160, "TPC nCluster"}, {63, 0, 6.28, "#phi"}}); + + // --- Proton + histos.add("QA/QAafter/Proton/TOF_TPC_Map_pr_all", "TOF + TPC Combined PID for Proton;{#sigma_{TOF}^{Proton}};{#sigma_{TPC}^{Proton}}", {HistType::kTH2F, {axisPIDQA, axisPIDQA}}); + histos.add("QA/QAafter/Proton/TOF_Nsigma_pr_all", "TOF NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Proton/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Proton/TPC_Nsigma_pr_TPConly", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTH2F, {axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Proton/dcaZ", "DCA_{Z} distribution of selected Protons; #it{p}_{T} (GeV/#it{c}); DCA_{Z} (cm);", HistType::kTH2F, {axisPt, axisDCAz}); + histos.add("QA/QAafter/Proton/dcaXY", "DCA_{XY} momentum distribution of selected Protons; #it{p}_{T} (GeV/#it{c}); DCA_{XY} (cm);", HistType::kTH2F, {axisPt, axisDCAxy}); + histos.add("QA/QAafter/Proton/TPC_CR", "# TPC Xrows distribution of selected Protons; #it{p}_{T} (GeV/#it{c}); TPC X rows", HistType::kTH2F, {axisPt, axisTPCXrow}); + histos.add("QA/QAafter/Proton/pT", "pT distribution of Protons; #it{p}_{T} (GeV/#it{c}); Counts;", {HistType::kTH1F, {axisPt}}); + histos.add("QA/QAafter/Proton/eta", "#eta distribution of Protons; #eta; Counts;", {HistType::kTH1F, {axisEta}}); + histos.add("QA/QAafter/Proton/TPC_Signal_pr_all", "TPC Signal for Proton;#it{p} (GeV/#it{c});TPC Signal (A.U.)", {HistType::kTH2F, {axisPt, axisTPCSignal}}); + histos.add("QA/QAafter/Proton/TPCnclusterPhipr", "TPC ncluster vs phi", kTHnSparseF, {{160, 0, 160, "TPC nCluster"}, {63, 0, 6.28, "#phi"}}); + + // Mass QA 1D for quick check + if (cFillinvmass1DPlots) { + histos.add("Result/Data/lambda1520invmass", "Invariant mass of #Lambda(1520) K^{#pm}p^{#mp}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + histos.add("Result/Data/antilambda1520invmass", "Invariant mass of #Lambda(1520) K^{#mp}p^{#pm}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + histos.add("Result/Data/lambda1520invmassLSPP", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K+ + Pr + histos.add("Result/Data/lambda1520invmassLSMM", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K- + anti-Pr + } + // eta phi QA + if (cFilldeltaEtaPhiPlots) { + histos.add("QAbefore/deltaEta", "deltaEta of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + histos.add("QAbefore/deltaPhi", "deltaPhi of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + + histos.add("QAafter/deltaEta", "deltaEta of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + histos.add("QAafter/deltaPhi", "deltaPhi of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + + histos.add("QAafter/deltaEtaafter", "deltaEta of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + histos.add("QAafter/deltaPhiafter", "deltaPhi of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + histos.add("QAafter/EtaPrafter", "Eta of proton candidates", HistType::kTH1F, {axisEta}); + histos.add("QAafter/PhiPrafter", "Phi of proton candidates", HistType::kTH1F, {axisPhi}); + histos.add("QAafter/EtaKaafter", "Eta of kaon candidates", HistType::kTH1F, {axisEta}); + histos.add("QAafter/PhiKaafter", "Phi of kaon candidates", HistType::kTH1F, {axisPhi}); + } + + if (isCalcRotBkg) { + histos.add("Result/Data/h3lambda1520InvMassRotation", "Invariant mass of #Lambda(1520) rotation", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + } + + // 3d histogram + histos.add("Result/Data/h3lambda1520invmass", "Invariant mass of #Lambda(1520) K^{#pm}p^{#mp}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3antilambda1520invmass", "Invariant mass of #Lambda(1520) K^{#mp}p^{#pm}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassLSPP", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); // K+ + Pr + histos.add("Result/Data/h3lambda1520invmassLSMM", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); // K- + anti-Pr + } + if (doprocessME) { + if (cFillinvmass1DPlots) { + histos.add("Result/Data/lambda1520invmassME", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + } + histos.add("Result/Data/h3lambda1520invmassME", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + + if (cFilladditionalMEPlots) { + histos.add("Result/Data/h3lambda1520invmassME_DS", "Invariant mass of #Lambda(1520) mixed event DS", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassME_DSAnti", "Invariant mass of #Lambda(1520) mixed event DSAnti", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + } + } + + // MC QA + histos.add("Event/hMCEventIndices", "hMCEventIndices", kTH2D, {axisMult, idxMCAxis}); + if (doprocessMCTrue) { + histos.add("QA/MC/h2GenEtaPt_beforeanycut", " #eta-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPtQA}); + histos.add("QA/MC/h2GenPhiRapidity_beforeanycut", " #phi-y distribution of Generated #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap}); + histos.add("QA/MC/h2GenEtaPt_afterEtaRapCut", " #eta-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPtQA}); + histos.add("QA/MC/h2GenPhiRapidity_afterEtaRapCut", " #phi-y distribution of Generated #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap}); + histos.add("QA/MC/h2GenEtaPt_afterRapcut", " #phi-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPtQA}); + histos.add("QA/MC/h2GenPhiRapidity_afterRapcut", " #phi-y distribution of Generated #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap}); + + histos.add("Result/MC/Genlambda1520pt", "pT distribution of True MC #Lambda(1520)0", kTHnSparseF, {axisMClabel, axisPt, axisMult}); + histos.add("Result/MC/Genantilambda1520pt", "pT distribution of True MC Anti-#Lambda(1520)0", kTHnSparseF, {axisMClabel, axisPt, axisMult}); + } + if (doprocessMC) { + histos.add("QA/MC/h2RecoEtaPt_after", " #eta-#it{p}_{T} distribution of Reconstructed #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPt}); + histos.add("QA/MC/h2RecoPhiRapidity_after", " #phi-y distribution of Reconstructed #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap}); + + histos.add("QA/MC/trkDCAxy_pr", "DCAxy distribution of proton track candidates", HistType::kTHnSparseF, {axisPt, axisDCAxy}); + histos.add("QA/MC/trkDCAxy_ka", "DCAxy distribution of kaon track candidates", HistType::kTHnSparseF, {axisPt, axisDCAxy}); + histos.add("QA/MC/trkDCAz_pr", "DCAz distribution of proton track candidates", HistType::kTHnSparseF, {axisPt, axisDCAz}); + histos.add("QA/MC/trkDCAz_ka", "DCAz distribution of kaon track candidates", HistType::kTHnSparseF, {axisPt, axisDCAz}); + histos.add("QA/MC/TOF_Nsigma_pr_all", "TOF NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/MC/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/MC/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/MC/TPC_Nsigma_ka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + + histos.add("Result/MC/h3lambda1520Recoinvmass", "Invariant mass of Reconstructed MC #Lambda(1520)0", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/MC/h3antilambda1520Recoinvmass", "Invariant mass of Reconstructed MC Anti-#Lambda(1520)0", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + } + + // Print output histograms statistics + LOG(info) << "Size of the histograms in LstarAnalysis:"; + histos.print(); + } + + float massKa = MassKaonCharged; + float massPr = MassProton; + + int kLambda1520PDG = static_cast(102134); // PDG code for Lambda(1520) + + template + float getCentrality(CollisionType const& collision) + { + if (cfgCentEst == static_cast(1)) { + return collision.multFT0C(); + } else if (cfgCentEst == static_cast(2)) { + return collision.multFT0M(); + } else { + return -999; + } + } + + // Centralicity estimator selection + template + float centEst(ResoColl ResoEvents) + { + float returnValue = -999.0; + switch (multEstimator) { + case 0: + returnValue = ResoEvents.centFT0M(); + break; + case 1: + returnValue = ResoEvents.centFT0A(); + break; + case 2: + returnValue = ResoEvents.centFT0C(); + break; + default: + returnValue = ResoEvents.centFT0M(); + break; + } + return returnValue; + } + + // Check if the collision is INEL>0 + template + bool isTrueINEL0(MCColl const& /*mccoll*/, MCPart const& mcparts) + { + for (auto const& mcparticle : mcparts) { + if (!mcparticle.isPhysicalPrimary()) + continue; + auto p = pdg->GetParticle(mcparticle.pdgCode()); + if (p != nullptr) { + if (std::abs(p->Charge()) >= 3) { + if (std::abs(mcparticle.eta()) < 1) + return true; + } + } + } + return false; + } + + template + bool trackCut(const TrackType track) + { + // basic track cuts + if (std::abs(track.pt()) < cMinPtcut) + return false; + if (cDCAr7SigCut) { + if (std::abs(track.dcaXY()) > (0.004f + 0.0130f / (track.pt()))) // 7 - Sigma cut + return false; + } else { + if (std::abs(track.dcaXY()) > cMaxDCArToPVcut) + return false; + } + if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) + return false; + if (cTPCNClsFound && (track.tpcNClsFound() < cMinTPCNClsFound)) + return false; + if (track.tpcNClsCrossedRows() < cfgMinCrossedRows) + return false; + if (cfgHasTOF && !track.hasTOF()) + return false; + if (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + return false; + if (cfgGlobalTrack && !track.isGlobalTrack()) + return false; + if (cfgUseITSRefit && !track.passedITSRefit()) + return false; + if (cfgUseTPCRefit && !track.passedTPCRefit()) + return false; + + return true; + } + + // LOGF(info, "AFTER: pt: %f, hasTOF: %d, TPCSigma: %f, TOFSigma: %f, boolTPC: %d, boolTOF: %d, bool: %d", pt, candidate.hasTOF(), + // candidate.tpcNSigmaPr(), candidate.tofNSigmaPr(), tpcPIDPassed, tofPIDPassed, tpcPIDPassed || tofPIDPassed); + + template + bool pTdependentPIDProton(const T& candidate) + { + auto vProtonTPCPIDpTintv = static_cast>(protonTPCPIDpTintv); + vProtonTPCPIDpTintv.insert(vProtonTPCPIDpTintv.begin(), cMinPtcut); + auto vProtonTPCPIDcuts = static_cast>(protonTPCPIDcuts); + auto vProtonTOFPIDpTintv = static_cast>(protonTOFPIDpTintv); + auto vProtonTPCTOFCombinedpTintv = static_cast>(protonTPCTOFCombinedpTintv); + auto vProtonTPCTOFCombinedPIDcuts = static_cast>(protonTPCTOFCombinedPIDcuts); + auto vProtonTOFPIDcuts = static_cast>(protonTOFPIDcuts); + + float pt = candidate.pt(); + float ptSwitchToTOF = vProtonTPCPIDpTintv.back(); + + bool tpcPIDPassed = false; + + // TPC PID (interval check) + for (size_t i = 0; i < vProtonTPCPIDpTintv.size() - 1; ++i) { + if (pt > vProtonTPCPIDpTintv[i] && pt < vProtonTPCPIDpTintv[i + 1]) { + if (std::abs(candidate.tpcNSigmaPr()) < vProtonTPCPIDcuts[i]) + tpcPIDPassed = true; + } + } + + // TOF bypass option (for QA or MC) + if (cByPassTOF) { + return std::abs(candidate.tpcNSigmaPr()) < vProtonTPCPIDcuts.back(); + } + + // Case 1: No TOF and pt ≤ threshold → accept only via TPC PID + if (!candidate.hasTOF() && pt <= ptSwitchToTOF) { + return tpcPIDPassed; + } + + // Case 2: No TOF but pt > threshold → reject + if (!candidate.hasTOF() && pt > ptSwitchToTOF) { + return false; + } + + // Case 3: Has TOF → use TPC + TOF (square or circular) + if (candidate.hasTOF()) { + if (cPIDcutType == 1) { + // Rectangular cut + for (size_t i = 0; i < vProtonTOFPIDpTintv.size(); ++i) { + if (pt < vProtonTOFPIDpTintv[i]) { + if (std::abs(candidate.tofNSigmaPr()) < vProtonTOFPIDcuts[i] && + std::abs(candidate.tpcNSigmaPr()) < vProtonTPCPIDcuts.back()) + return true; + } + } + } else if (cPIDcutType == 2) { + // Circular cut + for (size_t i = 0; i < vProtonTPCTOFCombinedpTintv.size(); ++i) { + if (pt < vProtonTPCTOFCombinedpTintv[i]) { + float combinedSigma2 = + candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr() + + candidate.tofNSigmaPr() * candidate.tofNSigmaPr(); + if (combinedSigma2 < vProtonTPCTOFCombinedPIDcuts[i] * vProtonTPCTOFCombinedPIDcuts[i]) + return true; + } + } + } + } + + return false; + } + + template + bool pTdependentPIDKaon(const T& candidate) + { + auto vKaonTPCPIDpTintv = static_cast>(kaonTPCPIDpTintv); + vKaonTPCPIDpTintv.insert(vKaonTPCPIDpTintv.begin(), cMinPtcut); + auto vKaonTPCPIDcuts = static_cast>(kaonTPCPIDcuts); + auto vKaonTOFPIDpTintv = static_cast>(kaonTOFPIDpTintv); + auto vKaonTPCTOFCombinedpTintv = static_cast>(kaonTPCTOFCombinedpTintv); + auto vKaonTPCTOFCombinedPIDcuts = static_cast>(kaonTPCTOFCombinedPIDcuts); + auto vKaonTOFPIDcuts = static_cast>(kaonTOFPIDcuts); + + float pt = candidate.pt(); + float ptSwitchToTOF = vKaonTPCPIDpTintv.back(); + + bool tpcPIDPassed = false; + + // TPC PID interval-based check + for (size_t i = 0; i < vKaonTPCPIDpTintv.size() - 1; ++i) { + if (pt > vKaonTPCPIDpTintv[i] && pt < vKaonTPCPIDpTintv[i + 1]) { + if (std::abs(candidate.tpcNSigmaKa()) < vKaonTPCPIDcuts[i]) { + tpcPIDPassed = true; + break; + } + } + } + + // TOF bypass option + if (cByPassTOF) { + return std::abs(candidate.tpcNSigmaKa()) < vKaonTPCPIDcuts.back(); + } + + // Case 1: No TOF and pt ≤ ptSwitch → use TPC-only + if (!candidate.hasTOF() && pt <= ptSwitchToTOF) { + return tpcPIDPassed; + } + + // Case 2: No TOF but pt > ptSwitch → reject + if (!candidate.hasTOF() && pt > ptSwitchToTOF) { + return false; + } + + // Case 3: TOF is available → apply TPC+TOF PID logic + if (candidate.hasTOF()) { + if (cPIDcutType == 1) { + // Rectangular cut + for (size_t i = 0; i < vKaonTOFPIDpTintv.size(); ++i) { + if (pt < vKaonTOFPIDpTintv[i]) { + if (std::abs(candidate.tofNSigmaKa()) < vKaonTOFPIDcuts[i] && + std::abs(candidate.tpcNSigmaKa()) < vKaonTPCPIDcuts.back()) { + return true; + } + } + } + } else if (cPIDcutType == 2) { + // Circular cut + for (size_t i = 0; i < vKaonTPCTOFCombinedpTintv.size(); ++i) { + if (pt < vKaonTPCTOFCombinedpTintv[i]) { + float combinedSigma2 = candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + + candidate.tofNSigmaKa() * candidate.tofNSigmaKa(); + if (combinedSigma2 < vKaonTPCTOFCombinedPIDcuts[i] * vKaonTPCTOFCombinedPIDcuts[i]) { + return true; + } + } + } + } + } + + return false; + } + + template + bool rejectPion(const T& candidate) + { + if (candidate.pt() > static_cast(1.0) && candidate.pt() < static_cast(2.0) && !candidate.hasTOF() && candidate.tpcNSigmaPi() < static_cast(2)) { + return false; + } + return true; + } + + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2) + { + auto multiplicity = collision.centFT0M(); + + // Multiplicity correlation calibration plots + if (cFillMultQA) { + if constexpr (IsData) { + histos.fill(HIST("MultCalib/centGloPVpr"), multiplicity, dTracks1.size(), collision.multNTracksPV()); + histos.fill(HIST("MultCalib/centGloPVka"), multiplicity, dTracks2.size(), collision.multNTracksPV()); + } + } + + if (cFilladditionalQAeventPlots) { + if constexpr (!IsMix) { + histos.fill(HIST("QAevent/hVertexZSameE"), collision.posZ()); + histos.fill(HIST("QAevent/hMultiplicityPercentSameE"), multiplicity); + histos.fill(HIST("TestME/hCollisionIndexSameE"), collision.globalIndex()); + histos.fill(HIST("TestME/hnTrksSameE"), dTracks1.size()); + } else { + histos.fill(HIST("QAevent/hVertexZMixedE"), collision.posZ()); + histos.fill(HIST("QAevent/hMultiplicityPercentMixedE"), multiplicity); + histos.fill(HIST("TestME/hCollisionIndexMixedE"), collision.globalIndex()); + histos.fill(HIST("TestME/hnTrksMixedE"), dTracks1.size()); + } + } + // LOG(info) << "After pass, Collision index:" << collision.index() << "multiplicity: " << collision.centFT0M() << endl; + + LorentzVectorPtEtaPhiMass lDecayDaughter1, lDecayDaughter2, lResonance, ldaughterRot, lresonanceRot; + + for (const auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { + // Full index policy is needed to consider all possible combinations + if (trk1.index() == trk2.index()) + continue; // We need to run (0,1), (1,0) pairs as well. but same id pairs are not needed. + + if (cFilladditionalQAeventPlots) { + if constexpr (IsData) { + histos.fill(HIST("TestME/hPairsCounterSameE"), 1.0); + } else if (IsMix) { + histos.fill(HIST("TestME/hPairsCounterMixedE"), 1.0); + } + } + + // apply the track cut + if (!trackCut(trk1) || !trackCut(trk2)) + continue; + + //// Initialize variables + // Trk1: Proton, Trk2: Kaon + auto isTrk1hasTOF = trk1.hasTOF(); + auto isTrk2hasTOF = trk2.hasTOF(); + + auto trk1ptPr = trk1.pt(); + auto trk1NSigmaPrTPC = trk1.tpcNSigmaPr(); + auto trk1NSigmaPrTOF = (isTrk1hasTOF) ? trk1.tofNSigmaPr() : -999.; + auto trk2ptKa = trk2.pt(); + auto trk2NSigmaKaTPC = trk2.tpcNSigmaKa(); + auto trk2NSigmaKaTOF = (isTrk2hasTOF) ? trk2.tofNSigmaKa() : -999.; + + auto deltaEta = std::abs(trk1.eta() - trk2.eta()); + auto deltaPhi = std::abs(trk1.phi() - trk2.phi()); + deltaPhi = (deltaPhi > constants::math::PI) ? (constants::math::TwoPI - deltaPhi) : deltaPhi; + + //// QA plots before the selection + // --- Track QA all + if constexpr (IsData) { + histos.fill(HIST("QA/QAbefore/Track/TPC_Nsigma_pr_all"), multiplicity, trk1ptPr, trk1NSigmaPrTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/QAbefore/Track/TOF_Nsigma_pr_all"), multiplicity, trk1ptPr, trk1NSigmaPrTOF); + histos.fill(HIST("QA/QAbefore/Track/TOF_TPC_Map_pr_all"), trk1NSigmaPrTOF, trk1NSigmaPrTPC); + } + if (!isTrk1hasTOF) { + histos.fill(HIST("QA/QAbefore/Track/TPConly_Nsigma_pr"), trk1ptPr, trk1NSigmaPrTPC); + } + histos.fill(HIST("QA/QAbefore/Track/TPC_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/QAbefore/Track/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QA/QAbefore/Track/TOF_TPC_Map_ka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } + if (!isTrk2hasTOF) { + histos.fill(HIST("QA/QAbefore/Track/TPConly_Nsigma_ka"), trk2ptKa, trk2NSigmaKaTPC); + } + + histos.fill(HIST("QA/QAbefore/Track/dcaZ"), trk1ptPr, trk1.dcaZ()); + histos.fill(HIST("QA/QAbefore/Track/dcaXY"), trk1ptPr, trk1.dcaXY()); + histos.fill(HIST("QA/QAbefore/Track/TPC_CR"), trk1ptPr, trk1.tpcNClsCrossedRows()); + histos.fill(HIST("QA/QAbefore/Track/pT"), trk1ptPr); + histos.fill(HIST("QA/QAbefore/Track/eta"), trk1.eta()); + if (cFilldeltaEtaPhiPlots) { + histos.fill(HIST("QAbefore/deltaEta"), deltaEta); + histos.fill(HIST("QAbefore/deltaPhi"), deltaPhi); + } + } + + //// Apply the pid selection + if (crejectPion && rejectPion(trk2)) + continue; + + if (!pTdependentPIDProton(trk1) || !pTdependentPIDKaon(trk2)) + continue; + + //// QA plots after the selection + if constexpr (IsData) { // --- PID QA Proton + histos.fill(HIST("QA/QAafter/Proton/TPC_Nsigma_pr_all"), multiplicity, trk1ptPr, trk1NSigmaPrTPC); + histos.fill(HIST("QA/QAafter/Proton/TPC_Signal_pr_all"), trk1.tpcInnerParam(), trk1.tpcSignal()); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/QAafter/Proton/TOF_Nsigma_pr_all"), multiplicity, trk1ptPr, trk1NSigmaPrTOF); + histos.fill(HIST("QA/QAafter/Proton/TOF_TPC_Map_pr_all"), trk1NSigmaPrTOF, trk1NSigmaPrTPC); + } + if (!isTrk1hasTOF) { + histos.fill(HIST("QA/QAafter/Proton/TPC_Nsigma_pr_TPConly"), trk1ptPr, trk1NSigmaPrTPC); + } + histos.fill(HIST("QA/QAafter/Proton/dcaZ"), trk1ptPr, trk1.dcaZ()); + histos.fill(HIST("QA/QAafter/Proton/dcaXY"), trk1ptPr, trk1.dcaXY()); + histos.fill(HIST("QA/QAafter/Proton/TPC_CR"), trk1ptPr, trk1.tpcNClsCrossedRows()); + histos.fill(HIST("QA/QAafter/Proton/pT"), trk1ptPr); + histos.fill(HIST("QA/QAafter/Proton/eta"), trk1.eta()); + histos.fill(HIST("QA/QAafter/Proton/TPCnclusterPhipr"), trk1.tpcNClsFound(), trk1.phi()); + + // --- PID QA Kaon + histos.fill(HIST("QA/QAafter/Kaon/TPC_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + histos.fill(HIST("QA/QAafter/Kaon/TPC_Signal_ka_all"), trk2.tpcInnerParam(), trk2.tpcSignal()); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/QAafter/Kaon/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QA/QAafter/Kaon/TOF_TPC_Map_ka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } + if (!isTrk2hasTOF) { + histos.fill(HIST("QA/QAafter/Kaon/TPC_Nsigma_ka_TPConly"), trk2ptKa, trk2NSigmaKaTPC); + } + histos.fill(HIST("QA/QAafter/Kaon/dcaZ"), trk2ptKa, trk2.dcaZ()); + histos.fill(HIST("QA/QAafter/Kaon/dcaXY"), trk2ptKa, trk2.dcaXY()); + histos.fill(HIST("QA/QAafter/Kaon/TPC_CR"), trk2ptKa, trk2.tpcNClsCrossedRows()); + histos.fill(HIST("QA/QAafter/Kaon/pT"), trk2ptKa); + histos.fill(HIST("QA/QAafter/Kaon/eta"), trk2.eta()); + histos.fill(HIST("QA/QAafter/Kaon/TPCnclusterPhika"), trk2.tpcNClsFound(), trk2.phi()); + + if (cFilldeltaEtaPhiPlots) { + histos.fill(HIST("QAafter/deltaEta"), deltaEta); + histos.fill(HIST("QAafter/deltaPhi"), deltaPhi); + } + } + + // Apply kinematic opening angle cut + if (cApplyOpeningAngle) { + TVector3 v1(trk1.px(), trk1.py(), trk1.pz()); + TVector3 v2(trk2.px(), trk2.py(), trk2.pz()); + float alpha = v1.Angle(v2); + if (alpha > cMinOpeningAngle && alpha < cMaxOpeningAngle) + continue; + } + + //// Resonance reconstruction + lDecayDaughter1 = LorentzVectorPtEtaPhiMass(trk1.pt(), trk1.eta(), trk1.phi(), massPr); + lDecayDaughter2 = LorentzVectorPtEtaPhiMass(trk2.pt(), trk2.eta(), trk2.phi(), massKa); + lResonance = lDecayDaughter1 + lDecayDaughter2; + + if constexpr (IsData || IsMix) { + // Rapidity cut + if (std::abs(lResonance.Rapidity()) > static_cast(0.5)) + continue; + } + + if (cfgCutsOnMother) { + if (lResonance.Pt() >= cMaxPtMotherCut) // excluding candidates in overflow + continue; + if (lResonance.M() >= cMaxMinvMotherCut) // excluding candidates in overflow + continue; + } + + if (cFilldeltaEtaPhiPlots) { + if (deltaEta >= cMaxDeltaEtaCut) + continue; + if (deltaPhi >= cMaxDeltaPhiCut) + continue; + + if constexpr (!IsMix) { + histos.fill(HIST("QAafter/EtaPrafter"), trk1.eta()); + histos.fill(HIST("QAafter/PhiPrafter"), trk1.phi()); + histos.fill(HIST("QAafter/EtaKaafter"), trk2.eta()); + histos.fill(HIST("QAafter/PhiKaafter"), trk2.phi()); + histos.fill(HIST("QAafter/deltaEtaafter"), deltaEta); + histos.fill(HIST("QAafter/deltaPhiafter"), deltaPhi); + } + } + + //// Un-like sign pair only + if (trk1.sign() * trk2.sign() < 0) { + if constexpr (IsData) { + if (isCalcRotBkg) { + for (int i = 0; i < cNofRotations; i++) { + float theta2 = rn->Uniform(constants::math::PI - constants::math::PI / rotationalcut, constants::math::PI + constants::math::PI / rotationalcut); + ldaughterRot = LorentzVectorPtEtaPhiMass(trk2.pt(), trk2.eta(), trk2.phi() + theta2, massKa); // for rotated background + lresonanceRot = lDecayDaughter1 + ldaughterRot; + histos.fill(HIST("Result/Data/h3lambda1520InvMassRotation"), multiplicity, lresonanceRot.Pt(), lresonanceRot.M()); + } + } + + if (trk1.sign() < 0) { + if (cFillinvmass1DPlots) { + histos.fill(HIST("Result/Data/lambda1520invmass"), lResonance.M()); + } + histos.fill(HIST("Result/Data/h3lambda1520invmass"), multiplicity, lResonance.Pt(), lResonance.M()); + } else if (trk1.sign() > 0) { + if (cFillinvmass1DPlots) { + histos.fill(HIST("Result/Data/antilambda1520invmass"), lResonance.M()); + } + histos.fill(HIST("Result/Data/h3antilambda1520invmass"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } else if (IsMix) { + if (cFillinvmass1DPlots) { + histos.fill(HIST("Result/Data/lambda1520invmassME"), lResonance.M()); + } + histos.fill(HIST("Result/Data/h3lambda1520invmassME"), multiplicity, lResonance.Pt(), lResonance.M()); + if (cFilladditionalMEPlots) { + if (trk1.sign() < 0) { + histos.fill(HIST("Result/Data/h3lambda1520invmassME_DS"), multiplicity, lResonance.Pt(), lResonance.M()); + } else if (trk1.sign() > 0) { + histos.fill(HIST("Result/Data/h3lambda1520invmassME_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } + } + + // MC + if constexpr (IsMC) { + + // ------ Temporal lambda function to prevent error in build + auto getMothersIndeces = [&](auto const& theMcParticle) { + std::vector lMothersIndeces{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother index lMother: %d", lMother.globalIndex()); + lMothersIndeces.push_back(lMother.globalIndex()); + } + return lMothersIndeces; + }; + auto getMothersPDGCodes = [&](auto const& theMcParticle) { + std::vector lMothersPDGs{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother pdgcode lMother: %d", lMother.pdgCode()); + lMothersPDGs.push_back(lMother.pdgCode()); + } + return lMothersPDGs; + }; + // ------ + std::vector motherstrk1 = {-1, -1}; + std::vector mothersPDGtrk1 = {-1, -1}; + + std::vector motherstrk2 = {-1, -1}; + std::vector mothersPDGtrk2 = {-1, -1}; + + // + // Get the MC particle + const auto& mctrk1 = trk1.mcParticle(); + if (mctrk1.has_mothers()) { + motherstrk1 = getMothersIndeces(mctrk1); + mothersPDGtrk1 = getMothersPDGCodes(mctrk1); + } + while (motherstrk1.size() > 2) { + motherstrk1.pop_back(); + mothersPDGtrk1.pop_back(); + } + + const auto& mctrk2 = trk2.mcParticle(); + if (mctrk2.has_mothers()) { + motherstrk2 = getMothersIndeces(mctrk2); + mothersPDGtrk2 = getMothersPDGCodes(mctrk2); + } + while (motherstrk2.size() > 2) { + motherstrk2.pop_back(); + mothersPDGtrk2.pop_back(); + } + + if (std::abs(mctrk1.pdgCode()) != 2212 || std::abs(mctrk2.pdgCode()) != 321) + continue; + + if (motherstrk1[0] != motherstrk2[0]) // Same mother + continue; + + if (std::abs(mothersPDGtrk1[0]) != 102134) + continue; + + // LOGF(info, "mother trk1 id: %d, mother trk1: %d, trk1 id: %d, trk1 pdgcode: %d, mother trk2 id: %d, mother trk2: %d, trk2 id: %d, trk2 pdgcode: %d", motherstrk1[0], mothersPDGtrk1[0], trk1.globalIndex(), mctrk1.pdgCode(), motherstrk2[0], mothersPDGtrk2[0], trk2.globalIndex(), mctrk2.pdgCode()); + + if (cUseEtacutMC && std::abs(lResonance.Eta()) > cEtacutMC) // eta cut + continue; + + if (cUseRapcutMC && std::abs(lResonance.Rapidity()) > static_cast(0.5)) // rapidity cut + continue; + + histos.fill(HIST("QA/MC/h2RecoEtaPt_after"), lResonance.Eta(), lResonance.Pt()); + histos.fill(HIST("QA/MC/h2RecoPhiRapidity_after"), lResonance.Phi(), lResonance.Rapidity()); + + // Track selection check. + histos.fill(HIST("QA/MC/trkDCAxy_pr"), trk1ptPr, trk1.dcaXY()); + histos.fill(HIST("QA/MC/trkDCAxy_ka"), trk2ptKa, trk2.dcaXY()); + histos.fill(HIST("QA/MC/trkDCAz_pr"), trk1ptPr, trk1.dcaZ()); + histos.fill(HIST("QA/MC/trkDCAz_ka"), trk2ptKa, trk2.dcaZ()); + + histos.fill(HIST("QA/MC/TPC_Nsigma_pr_all"), multiplicity, trk1ptPr, trk1NSigmaPrTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/MC/TOF_Nsigma_pr_all"), multiplicity, trk1ptPr, trk1NSigmaPrTOF); + } + histos.fill(HIST("QA/MC/TPC_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/MC/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + } + + // MC histograms + if (mothersPDGtrk1[0] > 0) { + histos.fill(HIST("Result/MC/h3lambda1520Recoinvmass"), multiplicity, lResonance.Pt(), lResonance.M()); + } else { + histos.fill(HIST("Result/MC/h3antilambda1520Recoinvmass"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } + } else { + if constexpr (IsData) { + // Like sign pair ++ + if (trk1.sign() > 0) { + if (cFillinvmass1DPlots) { + histos.fill(HIST("Result/Data/lambda1520invmassLSPP"), lResonance.M()); + } + histos.fill(HIST("Result/Data/h3lambda1520invmassLSPP"), multiplicity, lResonance.Pt(), lResonance.M()); + } else { // Like sign pair -- + if (cFillinvmass1DPlots) { + histos.fill(HIST("Result/Data/lambda1520invmassLSMM"), lResonance.M()); + } + histos.fill(HIST("Result/Data/h3lambda1520invmassLSMM"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } + } + } + } + + void processData(EventCandidates::iterator const& collision, + TrackCandidates const& tracks) + { + if (!colCuts.isSelected(collision)) // Default event selection + return; + + colCuts.fillQA(collision); + + if (cFilladditionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); + fillHistograms(collision, tracks, tracks); + } + PROCESS_SWITCH(Lstaranalysis, processData, "Process Event for data without partition", false); + + void processMC(MCEventCandidates::iterator const& collision, + aod::McCollisions const&, + MCTrackCandidates const& tracks, aod::McParticles const&) + { + colCuts.fillQA(collision); + + if (std::abs(collision.posZ()) > cZvertCutMC) // Z-vertex cut + return; + + fillHistograms(collision, tracks, tracks); + } + PROCESS_SWITCH(Lstaranalysis, processMC, "Process Event for MC Light without partition", false); + + Partition selectedMCParticles = (nabs(aod::mcparticle::pdgCode) == 102134); // Lambda(1520) + + void processMCTrue(MCEventCandidates::iterator const& collision, aod::McCollisions const&, aod::McParticles const& mcParticles) + { + bool isInAfterAllCuts = colCuts.isSelected(collision); + bool inVtx10 = (std::abs(collision.mcCollision().posZ()) > 10.) ? false : true; + bool isTriggerTVX = collision.selection_bit(aod::evsel::kIsTriggerTVX); + bool isSel8 = collision.sel8(); + bool isTrueINELgt0 = isTrueINEL0(collision, mcParticles); + centrality = centEst(collision); + + auto multiplicity = collision.centFT0M(); + + auto mcParts = selectedMCParticles->sliceBy(perMcCollision, collision.mcCollision().globalIndex()); + + // Not related to the real collisions + for (const auto& part : mcParts) { // loop over all MC particles + + if (std::abs(part.pdgCode()) != kLambda1520PDG) // Lambda1520(0) + continue; + + std::vector daughterPDGs; + if (part.has_daughters()) { + auto daughter01 = mcParticles.rawIteratorAt(part.daughtersIds()[0] - mcParticles.offset()); + auto daughter02 = mcParticles.rawIteratorAt(part.daughtersIds()[1] - mcParticles.offset()); + daughterPDGs = {daughter01.pdgCode(), daughter02.pdgCode()}; + } else { + daughterPDGs = {-1, -1}; + } + + bool pass1 = std::abs(daughterPDGs[0]) == kKPlus || std::abs(daughterPDGs[1]) == kKPlus; // At least one decay to Kaon + bool pass2 = std::abs(daughterPDGs[0]) == kProton || std::abs(daughterPDGs[1]) == kProton; // At least one decay to Proton + + // Checking if we have both decay products + if (!pass1 || !pass2) + continue; + + // LOGF(info, "Part PDG: %d", part.pdgCode(), "DAU_ID1: %d", pass1, "DAU_ID2: %d", pass2); + + histos.fill(HIST("QA/MC/h2GenEtaPt_beforeanycut"), part.eta(), part.pt()); + histos.fill(HIST("QA/MC/h2GenPhiRapidity_beforeanycut"), part.phi(), part.y()); + + if (cUseRapcutMC && std::abs(part.y()) > static_cast(0.5)) // rapidity cut + continue; + + histos.fill(HIST("QA/MC/h2GenEtaPt_afterRapcut"), part.eta(), part.pt()); + histos.fill(HIST("QA/MC/h2GenPhiRapidity_afterRapcut"), part.phi(), part.y()); + + if (cUseEtacutMC && std::abs(part.eta()) > cEtacutMC) // eta cut + continue; + + histos.fill(HIST("QA/MC/h2GenEtaPt_afterEtaRapCut"), part.eta(), part.pt()); + histos.fill(HIST("QA/MC/h2GenPhiRapidity_afterEtaRapCut"), part.phi(), part.y()); + + // without any event selection + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 0, part.pt(), multiplicity); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 0, part.pt(), multiplicity); + + if (inVtx10) // INEL10 + { + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 1, part.pt(), multiplicity); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 1, part.pt(), multiplicity); + } + if (inVtx10 && isSel8) // INEL>10, vtx10 + { + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 2, part.pt(), multiplicity); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 2, part.pt(), multiplicity); + } + if (inVtx10 && isTriggerTVX) // vtx10, TriggerTVX + { + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 3, part.pt(), multiplicity); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 3, part.pt(), multiplicity); + } + if (isInAfterAllCuts) // after all event selection + { + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 4, part.pt(), multiplicity); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 4, part.pt(), multiplicity); + } + } + + // QA for Trigger efficiency + histos.fill(HIST("Event/hMCEventIndices"), centrality, kINEL); + if (inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kINEL10); + if (isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kINELg0); + if (inVtx10 && isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kINELg010); + + // TVX MB trigger + if (isTriggerTVX) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kTrig); + if (isTriggerTVX && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kTrig10); + if (isTriggerTVX && isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kTrigINELg0); + if (isTriggerTVX && isTrueINELgt0 && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kTrigINELg010); + + // Sel8 event selection + if (isSel8) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kSel8); + if (isSel8 && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kSel810); + if (isSel8 && isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kSel8INELg0); + if (isSel8 && isTrueINELgt0 && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kSel8INELg010); + + // CollisionCuts selection + if (isInAfterAllCuts) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kAllCuts); + if (isInAfterAllCuts && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kAllCuts10); + if (isInAfterAllCuts && isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kAllCutsINELg0); + if (isInAfterAllCuts && isTrueINELgt0 && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, kAllCutsINELg010); + } + PROCESS_SWITCH(Lstaranalysis, processMCTrue, "Process Event for MC only", false); + + // Processing Event Mixing + using BinningTypeVtxZT0M = ColumnBinningPolicy; + BinningTypeVtxZT0M colBinning{{cfgVtxBins, cfgMultBins}, true}; + + void processME(EventCandidates const& collision, + TrackCandidates const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + SameKindPair pairs{colBinning, nEvtMixing, -1, collision, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.globalIndex(), collision2.globalIndex()); + + // for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d)", t1.index(), t2.index(), collision1.index(), collision2.index()); + // } + + if (cFilladditionalQAeventPlots) { + // Fill histograms for the characteristics of the *mixed* events (collision1 and collision2) + // This will show the distribution of events that are actually being mixed. + histos.fill(HIST("QAevent/hMixPool_VtxZ"), collision1.posZ()); + histos.fill(HIST("QAevent/hMixPool_Multiplicity"), collision1.centFT0M()); // Assuming getCentrality() gives multiplicity + histos.fill(HIST("QAevent/hMixPool_VtxZ_vs_Multiplicity"), collision1.posZ(), collision1.centFT0M()); + + // You might also want to fill for collision2 if you want to see both partners' distributions + // histos.fill(HIST("QAevent/hMixPool_VtxZ"), collision2.posZ()); + // histos.fill(HIST("QAevent/hMixPool_Multiplicity"), collision2.getCentrality()); + // histos.fill(HIST("QAevent/hMixPool_VtxZ_vs_Multiplicity"), collision2.posZ(), collision2.getCentrality()); + + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.f); + } + fillHistograms(collision1, tracks1, tracks2); + } + } + PROCESS_SWITCH(Lstaranalysis, processME, "Process EventMixing light without partition", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Resonances/lambda1520analysisinpp.cxx b/PWGLF/Tasks/Resonances/lambda1520analysisinpp.cxx new file mode 100644 index 00000000000..0348751dae9 --- /dev/null +++ b/PWGLF/Tasks/Resonances/lambda1520analysisinpp.cxx @@ -0,0 +1,1252 @@ +// 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. + +/// \file lambda1520analysisinpp.cxx +/// \brief This standalone task reconstructs track-track decay of lambda(1520) resonance candidate +/// \author Hirak Kumar Koley + +#include "PWGLF/Utils/collisionCuts.h" + +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" +#include "TPDGCode.h" +#include "TRandom.h" + +#include +#include + +using namespace o2; +using namespace o2::soa; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +using LorentzVectorPtEtaPhiMass = ROOT::Math::PtEtaPhiMVector; + +enum { + Inel = 1, + Inel10, + Inelg0, + Inelg010, + Trig, + Trig10, + TrigINELg0, + TrigINELg010, + Sel8, + Sel810, + Sel8INELg0, + Sel8INELg010, + AllCuts, + AllCuts10, + AllCutsINELg0, + AllCutsINELg010, +}; + +enum TrackSelectionType { + AllTracks = 0, + GlobalTracks, + GlobalTracksWoPtEta, + GlobalTracksWoDCA, + QualityTracks, + InAcceptanceTracks, +}; + +enum PIDCutType { + SquareType = 1, + CircularType, +}; + +struct Lambda1520analysisinpp { + // Define slice per Resocollision + SliceCache cache; + Preslice perCollision = o2::aod::track::collisionId; + Preslice perMcCollision = o2::aod::mcparticle::mcCollisionId; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Service pdg; + + /// Event cuts + o2::analysis::CollisonCuts colCuts; + + struct : ConfigurableGroup { + Configurable cfgEvtZvtx{"cfgEvtZvtx", 10.0f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable cfgEvtOccupancyInTimeRangeMax{"cfgEvtOccupancyInTimeRangeMax", -1, "Evt sel: maximum track occupancy"}; + Configurable cfgEvtOccupancyInTimeRangeMin{"cfgEvtOccupancyInTimeRangeMin", -1, "Evt sel: minimum track occupancy"}; + Configurable cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"}; + Configurable cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"}; + Configurable cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; + Configurable cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; + Configurable cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; + Configurable cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", false, "Evt sel: apply Z-vertex time difference"}; + Configurable cfgEvtPileupRejection{"cfgEvtPileupRejection", false, "Evt sel: apply pileup rejection"}; + Configurable cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + Configurable cfgEvtCollInTimeRangeStandard{"cfgEvtCollInTimeRangeStandard", false, "Evt sel: apply NoCollInTimeRangeStandard"}; + } configEvents; + + struct : ConfigurableGroup { + // Pre-selection Track cuts + Configurable trackSelection{"trackSelection", 0, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; + Configurable cMinPtcut{"cMinPtcut", 0.15f, "Minimal pT for tracks"}; + Configurable cMinTPCNClsFound{"cMinTPCNClsFound", 120, "minimum TPCNClsFound value for good track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"}; + Configurable cfgCutRapidity{"cfgCutRapidity", 0.5f, "rapidity range for particles"}; + Configurable cfgMinCrossedRows{"cfgMinCrossedRows", 70, "min crossed rows for good track"}; + + // DCA Selections + // DCAr to PV + Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.1f, "Track DCAr cut to PV Maximum"}; + // DCAz to PV + Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 0.1f, "Track DCAz cut to PV Maximum"}; + + // Track selections + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; // PV Contriuibutor + Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; + Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; + Configurable cTPCNClsFound{"cTPCNClsFound", false, "Switch to turn on/off TPCNClsFound cut"}; + Configurable cDCAr7SigCut{"cDCAr7SigCut", false, "Track DCAr 7 Sigma cut to PV Maximum"}; + } configTracks; + + struct : ConfigurableGroup { + /// PID Selections + Configurable pidnSigmaPreSelectionCut{"pidnSigmaPreSelectionCut", 4.0f, "pidnSigma Cut for pre-selection of tracks"}; + Configurable cByPassTOF{"cByPassTOF", false, "By pass TOF PID selection"}; // By pass TOF PID selection + Configurable cPIDcutType{"cPIDcutType", 2, "cPIDcutType = 1 for square cut, 2 for circular cut"}; // By pass TOF PID selection + + // Kaon + Configurable> kaonTPCPIDpTintv{"kaonTPCPIDpTintv", {0.5f}, "pT intervals for Kaon TPC PID cuts"}; + Configurable> kaonTPCPIDcuts{"kaonTPCPIDcuts", {2}, "nSigma list for Kaon TPC PID cuts"}; + Configurable> kaonTOFPIDpTintv{"kaonTOFPIDpTintv", {999.0f}, "pT intervals for Kaon TOF PID cuts"}; + Configurable> kaonTOFPIDcuts{"kaonTOFPIDcuts", {2}, "nSigma list for Kaon TOF PID cuts"}; + Configurable> kaonTPCTOFCombinedpTintv{"kaonTPCTOFCombinedpTintv", {999.0f}, "pT intervals for Kaon TPC-TOF PID cuts"}; + Configurable> kaonTPCTOFCombinedPIDcuts{"kaonTPCTOFCombinedPIDcuts", {2}, "nSigma list for Kaon TPC-TOF PID cuts"}; + + // Proton + Configurable> protonTPCPIDpTintv{"protonTPCPIDpTintv", {0.9f}, "pT intervals for Kaon TPC PID cuts"}; + Configurable> protonTPCPIDcuts{"protonTPCPIDcuts", {2}, "nSigma list for Kaon TPC PID cuts"}; + Configurable> protonTOFPIDpTintv{"protonTOFPIDpTintv", {999.0f}, "pT intervals for Kaon TOF PID cuts"}; + Configurable> protonTOFPIDcuts{"protonTOFPIDcuts", {2}, "nSigma list for Kaon TOF PID cuts"}; + Configurable> protonTPCTOFCombinedpTintv{"protonTPCTOFCombinedpTintv", {999.0f}, "pT intervals for Proton TPC-TOF PID cuts"}; + Configurable> protonTPCTOFCombinedPIDcuts{"protonTPCTOFCombinedPIDcuts", {2}, "nSigma list for Proton TPC-TOF PID cuts"}; + } configPID; + + struct : ConfigurableGroup { + /// Event Mixing + Configurable nEvtMixing{"nEvtMixing", 10, "Number of events to mix"}; + ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.0f, -6.0f, -4.0f, -2.0f, 0.0f, 2.0f, 4.0f, 6.0f, 8.0f, 10.0f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgMultBins{"cfgMultBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - multiplicity"}; + + // Rotational background + Configurable rotationalcut{"rotationalcut", 10, "Cut value (Rotation angle pi - pi/cut and pi + pi/cut)"}; + Configurable cNofRotations{"cNofRotations", 3, "Number of random rotations in the rotational background"}; + Configurable cfgRotPr{"cfgRotPr", true, "rotate Proton"}; + } configBkg; + + // Additional purity check + Configurable crejectPion{"crejectPion", false, "Switch to turn on/off pion contamination"}; + Configurable cUseOpeningAngleCut{"cUseOpeningAngleCut", false, "Kinematic Cuts for p-K pair opening angle"}; + Configurable cMinOpeningAngle{"cMinOpeningAngle", 1.4f, "Minimum opening angle between daughters"}; + Configurable cMaxOpeningAngle{"cMaxOpeningAngle", 2.4f, "Maximum opening angle between daughters"}; + Configurable cfgUseDeltaEtaPhiCuts{"cfgUseDeltaEtaPhiCuts", false, "Switch to turn on/off delta eta and delta phi cuts"}; + Configurable cfgUseDaughterEtaCutMC{"cfgUseDaughterEtaCutMC", false, "Switch to turn on/off eta cuts for daughters in MC"}; + + // MC selection cut + Configurable cZvertCutMC{"cZvertCutMC", 10.0f, "MC Z-vertex cut"}; + Configurable cEtacutMC{"cEtacutMC", 0.5f, "MC eta cut"}; + Configurable cUseRapcutMC{"cUseRapcutMC", true, "MC eta cut"}; + Configurable cUseEtacutMC{"cUseEtacutMC", true, "MC eta cut"}; + + // cuts on mother + Configurable cfgUseCutsOnMother{"cfgUseCutsOnMother", false, "Enable additional cuts on mother"}; + Configurable cMaxPtMotherCut{"cMaxPtMotherCut", 10.0f, "Maximum pt of mother cut"}; + Configurable cMaxMinvMotherCut{"cMaxMinvMotherCut", 3.0f, "Maximum Minv of mother cut"}; + Configurable cMaxDeltaEtaCut{"cMaxDeltaEtaCut", 0.7f, "Maximum deltaEta between daughters"}; + Configurable cMaxDeltaPhiCut{"cMaxDeltaPhiCut", 1.5f, "Maximum deltaPhi between daughters"}; + + // switches + Configurable cFillMultQA{"cFillMultQA", false, "Turn on/off additional QA plots"}; + Configurable cFilladditionalQAeventPlots{"cFilladditionalQAeventPlots", false, "Additional QA event plots"}; + Configurable cFilladditionalMEPlots{"cFilladditionalMEPlots", false, "Additional Mixed event plots"}; + Configurable cFilldeltaEtaPhiPlots{"cFilldeltaEtaPhiPlots", false, "Enamble additional cuts on daughters"}; + Configurable cFill1DQAs{"cFill1DQAs", false, "Invariant mass 1D"}; + Configurable centEstimator{"centEstimator", 0, "Select centrality estimator: 0 - FT0M, 1 - FT0A, 2 - FT0C"}; + + TRandom* rn = new TRandom(); + + // Pre-filters for efficient process + Filter zVtxFilter = (nabs(o2::aod::collision::posZ) <= configEvents.cfgEvtZvtx); + Filter collisionFilterMC = nabs(aod::mccollision::posZ) <= configEvents.cfgEvtZvtx; + // Filter centralityFilter = nabs(aod::cent::centFT0C) <= cfg_Event_CentralityMax; + // Filter triggerFilter = (o2::aod::evsel::sel8 == true); + + Filter tofPIDFilter = aod::track::tofExpMom < 0.0f || ((aod::track::tofExpMom > 0.0f) && (/* (nabs(aod::pidtof::tofNSigmaPi) < configPID.pidnSigmaPreSelectionCut) || */ (nabs(aod::pidtof::tofNSigmaKa) < configPID.pidnSigmaPreSelectionCut) || (nabs(aod::pidtof::tofNSigmaPr) < configPID.pidnSigmaPreSelectionCut))); // TOF + Filter tpcPIDFilter = /* nabs(aod::pidtpc::tpcNSigmaPi) < configPID.pidnSigmaPreSelectionCut || */ nabs(aod::pidtpc::tpcNSigmaKa) < configPID.pidnSigmaPreSelectionCut || nabs(aod::pidtpc::tpcNSigmaPr) < configPID.pidnSigmaPreSelectionCut; // TPC + Filter trackFilter = (configTracks.trackSelection == AllTracks) || + ((configTracks.trackSelection == GlobalTracks) && requireGlobalTrackInFilter()) || + ((configTracks.trackSelection == GlobalTracksWoPtEta) && requireGlobalTrackWoPtEtaInFilter()) || + ((configTracks.trackSelection == GlobalTracksWoDCA) && requireGlobalTrackWoDCAInFilter()) || + ((configTracks.trackSelection == QualityTracks) && requireQualityTracksInFilter()) || + ((configTracks.trackSelection == InAcceptanceTracks) && requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks)); + + Filter acceptanceFilter = (nabs(aod::track::eta) < configTracks.cfgCutEta && nabs(aod::track::pt) > configTracks.cMinPtcut); + // Filter DCAcutFilter = (nabs(aod::track::dcaXY) < configTracks.cfgCutDCAxy) && (nabs(aod::track::dcaZ) < configTracks.cfgCutDCAz); + // Filter primarytrackFilter = requirePVContributor() && requirePrimaryTrack() && requireGlobalTrackWoDCA(); + + using EventCandidates = soa::Join; + using TrackCandidates = soa::Filtered>; + + using MCEventCandidates = soa::Join; + using MCTrackCandidates = soa::Filtered>; + + /// Figures + ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.12f, 0.14f, 0.16f, 0.18f, 0.2f, 0.25f, 0.3f, 0.35f, 0.4f, 0.45f, 0.5f, 0.55f, 0.6f, 0.65f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 0.95f, 1.0f, 1.1f, 1.2f, 1.25f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.75f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 2.5f, 2.6f, 2.7f, 2.8f, 2.9f, 3.0f, 3.1f, 3.2f, 3.3f, 3.4f, 3.6f, 3.7f, 3.8f, 3.9f, 4.0f, 4.1f, 4.2f, 4.5f, 4.6f, 4.8f, 4.9f, 5.0f, 5.5f, 5.6f, 6.0f, 6.4f, 6.5f, 7.0f, 7.2f, 8.0f, 9.0f, 9.5f, 9.6f, 10.0f, 11.0f, 11.5f, 12.0f, 13.0f, 14.0f, 14.4f, 15.0f, 16.0f, 18.0f, 19.2f, 20.0f}, "Binning of the pT axis"}; + ConfigurableAxis binsPtQA{"binsPtQA", {VARIABLE_WIDTH, 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f, 1.2f, 1.4f, 1.6f, 1.8f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.2f, 4.4f, 4.6f, 4.8f, 5.0f, 5.2f, 5.4f, 5.6f, 5.8f, 6.0f, 6.2f, 6.4f, 6.6f, 6.8f, 7.0f, 7.2f, 7.4f, 7.6f, 7.8f, 8.0f, 8.2f, 8.4f, 8.6f, 8.8f, 9.0f, 9.2f, 9.4f, 9.6f, 9.8f, 10.0f, 10.2f, 10.4f, 10.6f, 10.8f, 11.0f, 11.2f, 11.4f, 11.6f, 11.8f, 12.0f, 12.2f, 12.4f, 12.6f, 12.8f, 13.0f, 13.2f, 13.4f, 13.6f, 13.8f, 14.0f, 14.2f, 14.4f, 14.6f, 14.8f, 15.0f, 15.2f, 15.4f, 15.6f, 15.8f, 16.0f, 16.2f, 16.4f, 16.6f, 16.8f, 17.0f, 17.2f, 17.4f, 17.6f, 17.8f, 18.0f, 18.2f, 18.4f, 18.6f, 18.8f, 19.0f, 19.2f, 19.4f, 19.6f, 19.8f, 20.0f}, "Binning of the pT axis"}; + ConfigurableAxis binsEta{"binsEta", {150, -1.5f, 1.5f}, ""}; + ConfigurableAxis binsMass{"binsMass", {70, 1.3f, 2.0f}, "Invariant Mass (GeV/#it{c}^2)"}; + ConfigurableAxis binsMult{"binsMult", {105, 0.0f, 105.0f}, "mult_{FT0M}"}; + ConfigurableAxis binsDCAz{"binsDCAz", {40, -0.2f, 0.2f}, ""}; + ConfigurableAxis binsDCAxy{"binsDCAxy", {40, -0.2f, 0.2f}, ""}; + ConfigurableAxis binsTPCXrows{"binsTPCXrows", {100, 60, 160}, ""}; + ConfigurableAxis binsnSigma{"binsnSigma", {130, -6.5f, 6.5f}, ""}; + ConfigurableAxis binsnTPCSignal{"binsnTPCSignal", {1000, 0, 1000}, ""}; + ConfigurableAxis binsEtaPhi{"binsEtaPhi", {350, -3.5f, 3.5f}, ""}; + + void init(framework::InitContext&) + { + colCuts.setCuts(configEvents.cfgEvtZvtx, configEvents.cfgEvtTriggerCheck, configEvents.cfgEvtOfflineCheck, /*checkRun3*/ true, /*triggerTVXsel*/ false, configEvents.cfgEvtOccupancyInTimeRangeMax, configEvents.cfgEvtOccupancyInTimeRangeMin); + + colCuts.init(&histos); + colCuts.setTriggerTVX(configEvents.cfgEvtTriggerTVXSel); + colCuts.setApplyTFBorderCut(configEvents.cfgEvtTFBorderCut); + colCuts.setApplyITSTPCvertex(configEvents.cfgEvtUseITSTPCvertex); + colCuts.setApplyZvertexTimedifference(configEvents.cfgEvtZvertexTimedifference); + colCuts.setApplyPileupRejection(configEvents.cfgEvtPileupRejection); + colCuts.setApplyNoITSROBorderCut(configEvents.cfgEvtNoITSROBorderCut); + colCuts.setApplyCollInTimeRangeStandard(configEvents.cfgEvtCollInTimeRangeStandard); + colCuts.printCuts(); + + // axes + AxisSpec axisPt{binsPt, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisPtQA{binsPtQA, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisEta{binsEta, "#eta"}; + AxisSpec axisRap{binsEta, "#it{y}"}; + AxisSpec axisMassLambda1520{binsMass, "Invariant Mass (GeV/#it{c}^2)"}; + AxisSpec axisMult{binsMult, "mult_{V0M}"}; + AxisSpec axisDCAz{binsDCAz, "DCA_{z}"}; + AxisSpec axisDCAxy{binsDCAxy, "DCA_{XY}"}; + AxisSpec axisTPCXrow{binsTPCXrows, "#Xrows_{TPC}"}; + AxisSpec axisPIDQA{binsnSigma, "#sigma"}; + AxisSpec axisTPCSignal{binsnTPCSignal, ""}; + AxisSpec axisMClabel{6, -1.5f, 5.5f, "MC Label"}; + AxisSpec axisEtaPhi{binsEtaPhi, ""}; + AxisSpec axisPhi{350, 0, 7, "#Phi"}; + AxisSpec axisMultMix{configBkg.cfgMultBins, "Multiplicity"}; + AxisSpec axisVtxMix{configBkg.cfgVtxBins, "Vertex Z (cm)"}; + AxisSpec idxMCAxis = {26, -0.5f, 25.5f, "Index"}; + + if (cFilladditionalQAeventPlots) { + // event histograms + if (doprocessData) { + histos.add("QAevent/hPairsCounterSameE", "total valid no. of pairs sameE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + histos.add("QAevent/hnTrksSameE", "n tracks per event SameE", HistType::kTH1F, {{1000, 0.0, 1000.0}}); + } + // Test on Mixed event + if (doprocessME) { + + // Histograms for Mixed Event Pool characteristics + histos.add("QAevent/hMixPool_VtxZ", "Mixed Event Pool: Vertex Z;Vtx Z (cm);Counts", HistType::kTH1F, {axisVtxMix}); + histos.add("QAevent/hMixPool_Multiplicity", "Mixed Event Pool: Multiplicity;Multiplicity;Counts", HistType::kTH1F, {axisMultMix}); + histos.add("QAevent/hMixPool_VtxZ_vs_Multiplicity", "Mixed Event Pool: Vertex Z vs Multiplicity;Counts", HistType::kTH2F, {axisVtxMix, axisMultMix}); + + histos.add("QAevent/hPairsCounterMixedE", "total valid no. of pairs mixedE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + histos.add("QAevent/hVertexZMixedE", "Collision Vertex Z position", HistType::kTH1F, {{100, -15.0f, 15.0f}}); + histos.add("QAevent/hMultiplicityPercentMixedE", "Multiplicity percentile of collision", HistType::kTH1F, {{120, 0.0f, 120.0f}}); + histos.add("QAevent/hnTrksMixedE", "n tracks per event MixedE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}}); + } + } + + if (doprocessData) { + // Track QA before cuts + // --- Track + histos.add("QA/QAbefore/Track/TOF_TPC_Map_ka_all", "TOF + TPC Combined PID for Kaon;{#sigma_{TOF}^{Kaon}};{#sigma_{TPC}^{Kaon}}", {HistType::kTH2F, {axisPIDQA, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TPC_Nsigma_ka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TPConly_Nsigma_ka", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTH2F, {axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TOF_TPC_Map_pr_all", "TOF + TPC Combined PID for Proton;{#sigma_{TOF}^{Proton}};{#sigma_{TPC}^{Proton}}", {HistType::kTH2F, {axisPIDQA, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TOF_Nsigma_pr_all", "TOF NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/TPConly_Nsigma_pr", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTH2F, {axisPt, axisPIDQA}}); + histos.add("QA/QAbefore/Track/dcaZ", "DCA_{Z} distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); DCA_{Z} (cm); ", HistType::kTH2F, {axisPt, axisDCAz}); + histos.add("QA/QAbefore/Track/dcaXY", "DCA_{XY} momentum distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); DCA_{XY} (cm);", HistType::kTH2F, {axisPt, axisDCAxy}); + histos.add("QA/QAbefore/Track/TPC_CR", "# TPC Xrows distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); TPC X rows", HistType::kTH2F, {axisPt, axisTPCXrow}); + histos.add("QA/QAbefore/Track/pT", "pT distribution of Kaons; #it{p}_{T} (GeV/#it{c}); Counts;", {HistType::kTH1F, {axisPt}}); + histos.add("QA/QAbefore/Track/eta", "#eta distribution of Kaons; #eta; Counts;", {HistType::kTH1F, {axisEta}}); + + if (cFillMultQA) { + // Multiplicity correlation calibrations + histos.add("MultCalib/centGloPVpr", "Centrality vs Global-Tracks", kTHnSparseF, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}, {500, 0, 5000, "PV tracks"}}); + histos.add("MultCalib/centGloPVka", "Centrality vs Global-Tracks", kTHnSparseF, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}, {500, 0, 5000, "PV tracks"}}); + } + + // PID QA after cuts + // --- Kaon + histos.add("QA/QAafter/Kaon/TOF_TPC_Map_ka_all", "TOF + TPC Combined PID for Kaon;{#sigma_{TOF}^{Kaon}};{#sigma_{TPC}^{Kaon}}", {HistType::kTH2F, {axisPIDQA, axisPIDQA}}); + histos.add("QA/QAafter/Kaon/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Kaon/TPC_Nsigma_ka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Kaon/TPC_Nsigma_ka_TPConly", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTH2F, {axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Kaon/dcaZ", "DCA_{Z} distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); DCA_{Z} (cm); ", HistType::kTH2F, {axisPt, axisDCAz}); + histos.add("QA/QAafter/Kaon/dcaXY", "DCA_{XY} momentum distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); DCA_{XY} (cm);", HistType::kTH2F, {axisPt, axisDCAxy}); + histos.add("QA/QAafter/Kaon/TPC_CR", "# TPC Xrows distribution of selected Kaons; #it{p}_{T} (GeV/#it{c}); TPC X rows", HistType::kTH2F, {axisPt, axisTPCXrow}); + histos.add("QA/QAafter/Kaon/pT", "pT distribution of Kaons; #it{p}_{T} (GeV/#it{c}); Counts;", {HistType::kTH1F, {axisPt}}); + histos.add("QA/QAafter/Kaon/eta", "#eta distribution of Kaons; #eta; Counts;", {HistType::kTH1F, {axisEta}}); + histos.add("QA/QAafter/Kaon/TPC_Signal_ka_all", "TPC Signal for Kaon;#it{p} (GeV/#it{c});TPC Signal (A.U.)", {HistType::kTH2F, {axisPt, axisTPCSignal}}); + histos.add("QA/QAafter/Kaon/TPCnclusterPhika", "TPC ncluster vs phi", kTHnSparseF, {{160, 0, 160, "TPC nCluster"}, {63, 0.0f, 6.28f, "#phi"}}); + + // --- Proton + histos.add("QA/QAafter/Proton/TOF_TPC_Map_pr_all", "TOF + TPC Combined PID for Proton;{#sigma_{TOF}^{Proton}};{#sigma_{TPC}^{Proton}}", {HistType::kTH2F, {axisPIDQA, axisPIDQA}}); + histos.add("QA/QAafter/Proton/TOF_Nsigma_pr_all", "TOF NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Proton/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Proton/TPC_Nsigma_pr_TPConly", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTH2F, {axisPt, axisPIDQA}}); + histos.add("QA/QAafter/Proton/dcaZ", "DCA_{Z} distribution of selected Protons; #it{p}_{T} (GeV/#it{c}); DCA_{Z} (cm);", HistType::kTH2F, {axisPt, axisDCAz}); + histos.add("QA/QAafter/Proton/dcaXY", "DCA_{XY} momentum distribution of selected Protons; #it{p}_{T} (GeV/#it{c}); DCA_{XY} (cm);", HistType::kTH2F, {axisPt, axisDCAxy}); + histos.add("QA/QAafter/Proton/TPC_CR", "# TPC Xrows distribution of selected Protons; #it{p}_{T} (GeV/#it{c}); TPC X rows", HistType::kTH2F, {axisPt, axisTPCXrow}); + histos.add("QA/QAafter/Proton/pT", "pT distribution of Protons; #it{p}_{T} (GeV/#it{c}); Counts;", {HistType::kTH1F, {axisPt}}); + histos.add("QA/QAafter/Proton/eta", "#eta distribution of Protons; #eta; Counts;", {HistType::kTH1F, {axisEta}}); + histos.add("QA/QAafter/Proton/TPC_Signal_pr_all", "TPC Signal for Proton;#it{p} (GeV/#it{c});TPC Signal (A.U.)", {HistType::kTH2F, {axisPt, axisTPCSignal}}); + histos.add("QA/QAafter/Proton/TPCnclusterPhipr", "TPC ncluster vs phi", kTHnSparseF, {{160, 0, 160, "TPC nCluster"}, {63, 0.0f, 6.28f, "#phi"}}); + + // Mass QA 1D for quick check + if (cFill1DQAs) { + histos.add("Result/Data/lambda1520invmass", "Invariant mass of #Lambda(1520) K^{#pm}p^{#mp}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + histos.add("Result/Data/antilambda1520invmass", "Invariant mass of #Lambda(1520) K^{#mp}p^{#pm}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + histos.add("Result/Data/lambda1520invmassLSPP", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K+ + Pr + histos.add("Result/Data/lambda1520invmassLSMM", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K- + anti-Pr + } + // eta phi QA + if (cFilldeltaEtaPhiPlots) { + histos.add("QAbefore/deltaEta", "deltaEta of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + histos.add("QAbefore/deltaPhi", "deltaPhi of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + + histos.add("QAafter/deltaEta", "deltaEta of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + histos.add("QAafter/deltaPhi", "deltaPhi of kaon and proton candidates", HistType::kTH1F, {axisEtaPhi}); + + histos.add("QAafter/PhiPrafter", "Phi of proton candidates", HistType::kTH1F, {axisPhi}); + histos.add("QAafter/PhiKaafter", "Phi of kaon candidates", HistType::kTH1F, {axisPhi}); + } + + // 3d histogram + histos.add("Result/Data/h3lambda1520invmass", "Invariant mass of #Lambda(1520) K^{#pm}p^{#mp}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3antilambda1520invmass", "Invariant mass of #Lambda(1520) K^{#mp}p^{#pm}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3lambda1520invmassLSPP", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); // K+ + Pr + histos.add("Result/Data/h3lambda1520invmassLSMM", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); // K- + anti-Pr + } + + if (doprocessRotational) { + if (cFill1DQAs) { + histos.add("Result/Data/lambda1520InvMassRotation", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K+ + Pr + histos.add("Result/Data/antilambda1520InvMassRotation", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K- + anti-Pr + } + histos.add("Result/Data/h3lambda1520InvMassRotation", "Invariant mass of #Lambda(1520) rotation", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3antilambda1520InvMassRotation", "Invariant mass of #Lambda(1520) rotation", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + } + // Mixed event histograms + if (doprocessME) { + if (cFill1DQAs) { + histos.add("Result/Data/lambda1520invmassME_UnlikeSign", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + histos.add("Result/Data/antilambda1520invmassME_UnlikeSign", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); + } + histos.add("Result/Data/h3lambda1520invmassME_UnlikeSign", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/Data/h3antilambda1520invmassME_UnlikeSign", "Invariant mass of #Lambda(1520) mixed event K^{#pm}p^{#mp}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + + if (cFilladditionalMEPlots) { + if (cFill1DQAs) { + histos.add("Result/Data/lambda1520invmassME_LSPP", "Invariant mass of #Lambda(1520) Like Sign Method K^{#plus}p^{#plus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K+ + Pr + histos.add("Result/Data/lambda1520invmassME_LSMM", "Invariant mass of #Lambda(1520) Like Sign Method K^{#minus}p^{#minus}; Invariant Mass (GeV/#it{c}^2); Counts;", {HistType::kTH1F, {axisMassLambda1520}}); // K- + anti-Pr + } + histos.add("Result/Data/h3lambda1520invmassME_LSPP", "Invariant mass of #Lambda(1520) mixed event Like Sign Method K^{#plus}p^{#plus}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); // K+ + Pr + histos.add("Result/Data/h3lambda1520invmassME_LSMM", "Invariant mass of #Lambda(1520) mixed event Like Sign Method K^{#minus}p^{#minus}", HistType::kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); // K- + anti-Pr + } + } + + // MC QA + histos.add("Event/hMCEventIndices", "hMCEventIndices", kTH2D, {axisMult, idxMCAxis}); + if (doprocessMCTrue) { + histos.add("QA/MC/h2GenEtaPt_beforeanycut", " #eta-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPtQA}); + histos.add("QA/MC/h2GenPhiRapidity_beforeanycut", " #phi-y distribution of Generated #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap}); + histos.add("QA/MC/h2GenEtaPt_afterEtaRapCut", " #eta-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPtQA}); + histos.add("QA/MC/h2GenPhiRapidity_afterEtaRapCut", " #phi-y distribution of Generated #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap}); + histos.add("QA/MC/h2GenEtaPt_afterRapcut", " #phi-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPtQA}); + histos.add("QA/MC/h2GenPhiRapidity_afterRapcut", " #phi-y distribution of Generated #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap}); + + histos.add("Result/MC/Genlambda1520pt", "pT distribution of True MC #Lambda(1520)0", kTHnSparseF, {axisMClabel, axisPt, axisMult}); + histos.add("Result/MC/Genantilambda1520pt", "pT distribution of True MC Anti-#Lambda(1520)0", kTHnSparseF, {axisMClabel, axisPt, axisMult}); + } + if (doprocessMC) { + histos.add("QA/MC/h2RecoEtaPt_after", " #eta-#it{p}_{T} distribution of Reconstructed #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPt}); + histos.add("QA/MC/h2RecoPhiRapidity_after", " #phi-y distribution of Reconstructed #Lambda(1520); #phi; y; Counts;", HistType::kTHnSparseF, {axisPhi, axisRap}); + + histos.add("QA/MC/trkDCAxy_pr", "DCAxy distribution of proton track candidates", HistType::kTHnSparseF, {axisPt, axisDCAxy}); + histos.add("QA/MC/trkDCAxy_ka", "DCAxy distribution of kaon track candidates", HistType::kTHnSparseF, {axisPt, axisDCAxy}); + histos.add("QA/MC/trkDCAz_pr", "DCAz distribution of proton track candidates", HistType::kTHnSparseF, {axisPt, axisDCAz}); + histos.add("QA/MC/trkDCAz_ka", "DCAz distribution of kaon track candidates", HistType::kTHnSparseF, {axisPt, axisDCAz}); + histos.add("QA/MC/TOF_Nsigma_pr_all", "TOF NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/MC/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Proton}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/MC/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TOF}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + histos.add("QA/MC/TPC_Nsigma_ka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});{#sigma_{TPC}^{Kaon}};", {HistType::kTHnSparseF, {axisMult, axisPt, axisPIDQA}}); + + histos.add("Result/MC/h3lambda1520Recoinvmass", "Invariant mass of Reconstructed MC #Lambda(1520)0", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + histos.add("Result/MC/h3antilambda1520Recoinvmass", "Invariant mass of Reconstructed MC Anti-#Lambda(1520)0", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); + } + + // Print output histograms statistics + LOG(info) << "Size of the histograms in Lambda1520analysisinpp:"; + histos.print(); + } + + float massKa = MassKaonCharged; + float massPr = MassProton; + + // Centralicity estimator selection + template + float centEst(Coll collisions) + { + float returnValue = -999.0f; + switch (centEstimator) { + case 0: + returnValue = collisions.centFT0M(); + break; + case 1: + returnValue = collisions.centFT0A(); + break; + case 2: + returnValue = collisions.centFT0C(); + break; + default: + returnValue = collisions.centFT0M(); + break; + } + return returnValue; + } + + auto static constexpr TripleCharge = 3.0f; + + // Check if the collision is INEL>0 + template + bool isTrueINEL0(MCColl const& /*mccoll*/, MCPart const& mcparts) + { + for (auto const& mcparticle : mcparts) { + if (!mcparticle.isPhysicalPrimary()) + continue; + auto p = pdg->GetParticle(mcparticle.pdgCode()); + if (p != nullptr) { + if (std::abs(p->Charge()) >= TripleCharge) { // check if the particle is charged + if (std::abs(mcparticle.eta()) < 1.0f) + return true; + } + } + } + return false; + } + + template + bool trackCut(const TrackType track) + { + // basic track cuts + if (std::abs(track.pt()) < configTracks.cMinPtcut) + return false; + if (configTracks.cDCAr7SigCut) { + if (std::abs(track.dcaXY()) > (0.004f + 0.013f / (track.pt()))) // 7 - Sigma cut + return false; + } else { + if (std::abs(track.dcaXY()) > configTracks.cMaxDCArToPVcut) + return false; + } + if (std::abs(track.dcaZ()) > configTracks.cMaxDCAzToPVcut) + return false; + if (configTracks.cTPCNClsFound && (track.tpcNClsFound() < configTracks.cMinTPCNClsFound)) + return false; + if (track.tpcNClsCrossedRows() < configTracks.cfgMinCrossedRows) + return false; + if (configTracks.cfgHasTOF && !track.hasTOF()) + return false; + if (configTracks.cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (configTracks.cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (configTracks.cfgPVContributor && !track.isPVContributor()) + return false; + if (configTracks.cfgGlobalTrack && !track.isGlobalTrack()) + return false; + if (configTracks.cfgUseITSRefit && !track.passedITSRefit()) + return false; + if (configTracks.cfgUseTPCRefit && !track.passedTPCRefit()) + return false; + + return true; + } + + // LOGF(info, "AFTER: pt: %f, hasTOF: %d, TPCSigma: %f, TOFSigma: %f, boolTPC: %d, boolTOF: %d, bool: %d", pt, candidate.hasTOF(), + // candidate.tpcNSigmaPr(), candidate.tofNSigmaPr(), tpcPIDPassed, tofPIDPassed, tpcPIDPassed || tofPIDPassed); + + template + bool ptDependentPidProton(const T& candidate) + { + auto vProtonTPCPIDpTintv = configPID.protonTPCPIDpTintv.value; + vProtonTPCPIDpTintv.insert(vProtonTPCPIDpTintv.begin(), configTracks.cMinPtcut); + auto vProtonTPCPIDcuts = configPID.protonTPCPIDcuts.value; + auto vProtonTOFPIDpTintv = configPID.protonTOFPIDpTintv.value; + auto vProtonTPCTOFCombinedpTintv = configPID.protonTPCTOFCombinedpTintv.value; + auto vProtonTPCTOFCombinedPIDcuts = configPID.protonTPCTOFCombinedPIDcuts.value; + auto vProtonTOFPIDcuts = configPID.protonTOFPIDcuts.value; + + float pt = candidate.pt(); + float ptSwitchToTOF = vProtonTPCPIDpTintv.back(); + float tpcNsigmaPr = candidate.tpcNSigmaPr(); + float tofNsigmaPr = candidate.tofNSigmaPr(); + + bool tpcPIDPassed = false; + + // TPC PID (interval check) + for (size_t i = 0; i < vProtonTPCPIDpTintv.size() - 1; ++i) { + if (pt > vProtonTPCPIDpTintv[i] && pt < vProtonTPCPIDpTintv[i + 1]) { + if (std::abs(tpcNsigmaPr) < vProtonTPCPIDcuts[i]) + tpcPIDPassed = true; + } + } + + // TOF bypass option (for QA or MC) + if (configPID.cByPassTOF) { + return std::abs(tpcNsigmaPr) < vProtonTPCPIDcuts.back(); + } + + // Case 1: No TOF and pt ≤ threshold → accept only via TPC PID + if (!candidate.hasTOF() && pt <= ptSwitchToTOF) { + return tpcPIDPassed; + } + + // Case 2: No TOF but pt > threshold → reject + if (!candidate.hasTOF() && pt > ptSwitchToTOF) { + return false; + } + + // Case 3: Has TOF → use TPC + TOF (square or circular) + if (candidate.hasTOF()) { + if (configPID.cPIDcutType == SquareType) { + // Rectangular cut + for (size_t i = 0; i < vProtonTOFPIDpTintv.size(); ++i) { + if (pt < vProtonTOFPIDpTintv[i]) { + if (std::abs(tofNsigmaPr) < vProtonTOFPIDcuts[i] && + std::abs(tpcNsigmaPr) < vProtonTPCPIDcuts.back()) + return true; + } + } + } else if (configPID.cPIDcutType == CircularType) { + // Circular cut + for (size_t i = 0; i < vProtonTPCTOFCombinedpTintv.size(); ++i) { + if (pt < vProtonTPCTOFCombinedpTintv[i]) { + float combinedSigma2 = + tpcNsigmaPr * tpcNsigmaPr + + tofNsigmaPr * tofNsigmaPr; + if (combinedSigma2 < vProtonTPCTOFCombinedPIDcuts[i] * vProtonTPCTOFCombinedPIDcuts[i]) + return true; + } + } + } + } + + return false; + } + + template + bool ptDependentPidKaon(const T& candidate) + { + auto vKaonTPCPIDpTintv = configPID.kaonTPCPIDpTintv.value; + vKaonTPCPIDpTintv.insert(vKaonTPCPIDpTintv.begin(), configTracks.cMinPtcut); + auto vKaonTPCPIDcuts = configPID.kaonTPCPIDcuts.value; + auto vKaonTOFPIDpTintv = configPID.kaonTOFPIDpTintv.value; + auto vKaonTPCTOFCombinedpTintv = configPID.kaonTPCTOFCombinedpTintv.value; + auto vKaonTPCTOFCombinedPIDcuts = configPID.kaonTPCTOFCombinedPIDcuts.value; + auto vKaonTOFPIDcuts = configPID.kaonTOFPIDcuts.value; + + float pt = candidate.pt(); + float ptSwitchToTOF = vKaonTPCPIDpTintv.back(); + float tpcNsigmaKa = candidate.tpcNSigmaKa(); + float tofNsigmaKa = candidate.tofNSigmaKa(); + + bool tpcPIDPassed = false; + + // TPC PID interval-based check + for (size_t i = 0; i < vKaonTPCPIDpTintv.size() - 1; ++i) { + if (pt > vKaonTPCPIDpTintv[i] && pt < vKaonTPCPIDpTintv[i + 1]) { + if (std::abs(tpcNsigmaKa) < vKaonTPCPIDcuts[i]) { + tpcPIDPassed = true; + break; + } + } + } + + // TOF bypass option + if (configPID.cByPassTOF) { + return std::abs(tpcNsigmaKa) < vKaonTPCPIDcuts.back(); + } + + // Case 1: No TOF and pt ≤ ptSwitch → use TPC-only + if (!candidate.hasTOF() && pt <= ptSwitchToTOF) { + return tpcPIDPassed; + } + + // Case 2: No TOF but pt > ptSwitch → reject + if (!candidate.hasTOF() && pt > ptSwitchToTOF) { + return false; + } + + // Case 3: TOF is available → apply TPC+TOF PID logic + if (candidate.hasTOF()) { + if (configPID.cPIDcutType == SquareType) { + // Rectangular cut + for (size_t i = 0; i < vKaonTOFPIDpTintv.size(); ++i) { + if (pt < vKaonTOFPIDpTintv[i]) { + if (std::abs(tofNsigmaKa) < vKaonTOFPIDcuts[i] && + std::abs(tpcNsigmaKa) < vKaonTPCPIDcuts.back()) { + return true; + } + } + } + } else if (configPID.cPIDcutType == CircularType) { + // Circular cut + for (size_t i = 0; i < vKaonTPCTOFCombinedpTintv.size(); ++i) { + if (pt < vKaonTPCTOFCombinedpTintv[i]) { + float combinedSigma2 = tpcNsigmaKa * tpcNsigmaKa + + tofNsigmaKa * tofNsigmaKa; + if (combinedSigma2 < vKaonTPCTOFCombinedPIDcuts[i] * vKaonTPCTOFCombinedPIDcuts[i]) { + return true; + } + } + } + } + } + + return false; + } + + auto static constexpr MinPtforPionRejection = 1.0f; + auto static constexpr MaxPtforPionRejection = 2.0f; + auto static constexpr MaxnSigmaforPionRejection = 2.0f; + + template + bool rejectPion(const T& candidate) + { + if (candidate.pt() > MinPtforPionRejection && candidate.pt() < MaxPtforPionRejection && !candidate.hasTOF() && candidate.tpcNSigmaPi() < MaxnSigmaforPionRejection) { + return false; + } + return true; + } + + auto static constexpr MaxNoLambda1520Daughters = 2; + + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2) + { + auto centrality = centEst(collision); + + // Multiplicity correlation calibration plots + if (cFillMultQA) { + if constexpr (IsData) { + histos.fill(HIST("MultCalib/centGloPVpr"), centrality, dTracks1.size(), collision.multNTracksPV()); + histos.fill(HIST("MultCalib/centGloPVka"), centrality, dTracks2.size(), collision.multNTracksPV()); + } + } + + if (cFilladditionalQAeventPlots) { + if constexpr (IsData) { + histos.fill(HIST("QAevent/hnTrksSameE"), dTracks1.size()); + } else if constexpr (IsMix) { + histos.fill(HIST("QAevent/hVertexZMixedE"), collision.posZ()); + histos.fill(HIST("QAevent/hMultiplicityPercentMixedE"), centrality); + histos.fill(HIST("QAevent/hnTrksMixedE"), dTracks1.size()); + } + } + // LOG(info) << "After pass, Collision index:" << collision.index() << "multiplicity: " << collision.centFT0M() << endl; + + LorentzVectorPtEtaPhiMass lDecayDaughter1, lDecayDaughter2, lResonance, ldaughterRot, lResonanceRot; + + for (const auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { + // Full index policy is needed to consider all possible combinations + if (trk1.index() == trk2.index()) + continue; // We need to run (0,1), (1,0) pairs as well. but same id pairs are not needed. + + // apply the track cut + if (!trackCut(trk1) || !trackCut(trk2)) + continue; + + //// Initialize variables + // Trk1: Proton + auto isTrk1hasTOF = trk1.hasTOF(); + auto trk1ptPr = trk1.pt(); + auto trk1etaPr = trk1.eta(); + auto trk1phiPr = trk1.phi(); + auto trk1NSigmaPrTPC = trk1.tpcNSigmaPr(); + auto trk1NSigmaPrTOF = (isTrk1hasTOF) ? trk1.tofNSigmaPr() : -999.0f; + + // Trk2: Kaon + auto isTrk2hasTOF = trk2.hasTOF(); + auto trk2ptKa = trk2.pt(); + auto trk2etaKa = trk2.eta(); + auto trk2phiKa = trk2.phi(); + auto trk2NSigmaKaTPC = trk2.tpcNSigmaKa(); + auto trk2NSigmaKaTOF = (isTrk2hasTOF) ? trk2.tofNSigmaKa() : -999.0f; + + auto deltaEta = 0.0f; + auto deltaPhi = 0.0f; + + if (cfgUseDeltaEtaPhiCuts) { + deltaEta = std::abs(trk1etaPr - trk2etaKa); + deltaPhi = std::abs(trk1phiPr - trk2phiKa); + deltaPhi = (deltaPhi > o2::constants::math::PI) ? (o2::constants::math::TwoPI - deltaPhi) : deltaPhi; + if (deltaEta >= cMaxDeltaEtaCut) + continue; + if (deltaPhi >= cMaxDeltaPhiCut) + continue; + } + + //// QA plots before the selection + // --- Track QA all + if constexpr (IsData) { + histos.fill(HIST("QA/QAbefore/Track/TPC_Nsigma_pr_all"), centrality, trk1ptPr, trk1NSigmaPrTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/QAbefore/Track/TOF_Nsigma_pr_all"), centrality, trk1ptPr, trk1NSigmaPrTOF); + histos.fill(HIST("QA/QAbefore/Track/TOF_TPC_Map_pr_all"), trk1NSigmaPrTOF, trk1NSigmaPrTPC); + } + if (!isTrk1hasTOF) { + histos.fill(HIST("QA/QAbefore/Track/TPConly_Nsigma_pr"), trk1ptPr, trk1NSigmaPrTPC); + } + histos.fill(HIST("QA/QAbefore/Track/TPC_Nsigma_ka_all"), centrality, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/QAbefore/Track/TOF_Nsigma_ka_all"), centrality, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QA/QAbefore/Track/TOF_TPC_Map_ka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } + if (!isTrk2hasTOF) { + histos.fill(HIST("QA/QAbefore/Track/TPConly_Nsigma_ka"), trk2ptKa, trk2NSigmaKaTPC); + } + + histos.fill(HIST("QA/QAbefore/Track/dcaZ"), trk1ptPr, trk1.dcaZ()); + histos.fill(HIST("QA/QAbefore/Track/dcaXY"), trk1ptPr, trk1.dcaXY()); + histos.fill(HIST("QA/QAbefore/Track/TPC_CR"), trk1ptPr, trk1.tpcNClsCrossedRows()); + histos.fill(HIST("QA/QAbefore/Track/pT"), trk1ptPr); + histos.fill(HIST("QA/QAbefore/Track/eta"), trk1etaPr); + if (cFilldeltaEtaPhiPlots) { + histos.fill(HIST("QAbefore/deltaEta"), deltaEta); + histos.fill(HIST("QAbefore/deltaPhi"), deltaPhi); + } + } + + //// Apply the pid selection + if (crejectPion && rejectPion(trk2)) // to remove pion contamination from the kaon track + continue; + + if (!ptDependentPidProton(trk1) || !ptDependentPidKaon(trk2)) + continue; + + //// QA plots after the selection + if constexpr (IsData) { // --- PID QA Proton + histos.fill(HIST("QA/QAafter/Proton/TPC_Nsigma_pr_all"), centrality, trk1ptPr, trk1NSigmaPrTPC); + histos.fill(HIST("QA/QAafter/Proton/TPC_Signal_pr_all"), trk1.tpcInnerParam(), trk1.tpcSignal()); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/QAafter/Proton/TOF_Nsigma_pr_all"), centrality, trk1ptPr, trk1NSigmaPrTOF); + histos.fill(HIST("QA/QAafter/Proton/TOF_TPC_Map_pr_all"), trk1NSigmaPrTOF, trk1NSigmaPrTPC); + } + if (!isTrk1hasTOF) { + histos.fill(HIST("QA/QAafter/Proton/TPC_Nsigma_pr_TPConly"), trk1ptPr, trk1NSigmaPrTPC); + } + histos.fill(HIST("QA/QAafter/Proton/dcaZ"), trk1ptPr, trk1.dcaZ()); + histos.fill(HIST("QA/QAafter/Proton/dcaXY"), trk1ptPr, trk1.dcaXY()); + histos.fill(HIST("QA/QAafter/Proton/TPC_CR"), trk1ptPr, trk1.tpcNClsCrossedRows()); + histos.fill(HIST("QA/QAafter/Proton/pT"), trk1ptPr); + histos.fill(HIST("QA/QAafter/Proton/eta"), trk1etaPr); + histos.fill(HIST("QA/QAafter/Proton/TPCnclusterPhipr"), trk1.tpcNClsFound(), trk1phiPr); + + // --- PID QA Kaon + histos.fill(HIST("QA/QAafter/Kaon/TPC_Nsigma_ka_all"), centrality, trk2ptKa, trk2NSigmaKaTPC); + histos.fill(HIST("QA/QAafter/Kaon/TPC_Signal_ka_all"), trk2.tpcInnerParam(), trk2.tpcSignal()); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/QAafter/Kaon/TOF_Nsigma_ka_all"), centrality, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QA/QAafter/Kaon/TOF_TPC_Map_ka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } + if (!isTrk2hasTOF) { + histos.fill(HIST("QA/QAafter/Kaon/TPC_Nsigma_ka_TPConly"), trk2ptKa, trk2NSigmaKaTPC); + } + histos.fill(HIST("QA/QAafter/Kaon/dcaZ"), trk2ptKa, trk2.dcaZ()); + histos.fill(HIST("QA/QAafter/Kaon/dcaXY"), trk2ptKa, trk2.dcaXY()); + histos.fill(HIST("QA/QAafter/Kaon/TPC_CR"), trk2ptKa, trk2.tpcNClsCrossedRows()); + histos.fill(HIST("QA/QAafter/Kaon/pT"), trk2ptKa); + histos.fill(HIST("QA/QAafter/Kaon/eta"), trk2etaKa); + histos.fill(HIST("QA/QAafter/Kaon/TPCnclusterPhika"), trk2.tpcNClsFound(), trk2phiKa); + + if (cFilldeltaEtaPhiPlots) { + histos.fill(HIST("QAafter/PhiPrafter"), trk1phiPr); + histos.fill(HIST("QAafter/PhiKaafter"), trk2phiKa); + histos.fill(HIST("QAafter/deltaEta"), deltaEta); + histos.fill(HIST("QAafter/deltaPhi"), deltaPhi); + } + } + + //// Resonance reconstruction + lDecayDaughter1 = LorentzVectorPtEtaPhiMass(trk1ptPr, trk1etaPr, trk1phiPr, massPr); + lDecayDaughter2 = LorentzVectorPtEtaPhiMass(trk2ptKa, trk2etaKa, trk2phiKa, massKa); + + // Apply kinematic opening angle cut + if (cUseOpeningAngleCut) { + auto v1 = lDecayDaughter1.Vect(); + auto v2 = lDecayDaughter2.Vect(); + float alpha = std::acos(v1.Dot(v2) / (v1.R() * v2.R())); + if (alpha > cMinOpeningAngle && alpha < cMaxOpeningAngle) + continue; + } + + lResonance = lDecayDaughter1 + lDecayDaughter2; + + auto resonanceMass = lResonance.M(); + auto resonancePt = lResonance.Pt(); + auto resonanceRapidity = lResonance.Rapidity(); + + if constexpr (IsData || IsMix) { + // Rapidity cut + if (std::abs(resonanceRapidity) > configTracks.cfgCutRapidity) + continue; + } + + if (cfgUseCutsOnMother) { + if (resonancePt >= cMaxPtMotherCut) // excluding candidates in overflow + continue; + if (resonanceMass >= cMaxMinvMotherCut) // excluding candidates in overflow + continue; + } + + if (cFilladditionalQAeventPlots) { + if constexpr (IsData) { + histos.fill(HIST("QAevent/hPairsCounterSameE"), 1.0f); + } else if (IsMix) { + histos.fill(HIST("QAevent/hPairsCounterMixedE"), 1.0f); + } + } + + //// Un-like sign pair only + if (trk1.sign() * trk2.sign() < 0) { + if constexpr (IsRot) { + for (int i = 0; i < configBkg.cNofRotations; i++) { + float theta = rn->Uniform(o2::constants::math::PI - o2::constants::math::PI / configBkg.rotationalcut, o2::constants::math::PI + o2::constants::math::PI / configBkg.rotationalcut); + if (configBkg.cfgRotPr) { + ldaughterRot = LorentzVectorPtEtaPhiMass(trk1ptPr, trk1etaPr, trk1phiPr + theta, massPr); + lResonanceRot = ldaughterRot + lDecayDaughter2; + } else { + ldaughterRot = LorentzVectorPtEtaPhiMass(trk2ptKa, trk2etaKa, trk2phiKa + theta, massKa); + lResonanceRot = lDecayDaughter1 + ldaughterRot; + } + auto resonanceRotMass = lResonanceRot.M(); + auto resonanceRotPt = lResonanceRot.Pt(); + + // Rapidity cut + if (std::abs(lResonanceRot.Rapidity()) >= configTracks.cfgCutRapidity) + continue; + + if (cfgUseCutsOnMother) { + if (resonanceRotPt >= cMaxPtMotherCut) // excluding candidates in overflow + continue; + if (resonanceRotMass >= cMaxMinvMotherCut) // excluding candidates in overflow + continue; + } + if (trk1.sign() < 0) { + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/lambda1520InvMassRotation"), resonanceRotMass); + } + histos.fill(HIST("Result/Data/h3lambda1520InvMassRotation"), centrality, resonanceRotPt, resonanceRotMass); + } else if (trk1.sign() > 0) { + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/antilambda1520InvMassRotation"), resonanceRotMass); + } + histos.fill(HIST("Result/Data/h3antilambda1520InvMassRotation"), centrality, resonanceRotPt, resonanceRotMass); + } + } + } + if constexpr (IsData) { + if (trk1.sign() < 0) { + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/lambda1520invmass"), resonanceMass); + } + histos.fill(HIST("Result/Data/h3lambda1520invmass"), centrality, resonancePt, resonanceMass); + } else if (trk1.sign() > 0) { + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/antilambda1520invmass"), resonanceMass); + } + histos.fill(HIST("Result/Data/h3antilambda1520invmass"), centrality, resonancePt, resonanceMass); + } + } else if (IsMix) { + if (trk1.sign() < 0) { + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/lambda1520invmassME_UnlikeSign"), resonanceMass); + } + histos.fill(HIST("Result/Data/h3lambda1520invmassME_UnlikeSign"), centrality, resonancePt, resonanceMass); + } else if (trk1.sign() > 0) { + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/antilambda1520invmassME_UnlikeSign"), resonanceMass); + } + histos.fill(HIST("Result/Data/h3antilambda1520invmassME_UnlikeSign"), centrality, resonancePt, resonanceMass); + } + } + + // MC + if constexpr (IsMC) { + // now we do mc true + // ------ Temporal lambda function to prevent error in build + auto getMothersIndeces = [&](auto const& theMcParticle) { + std::vector lMothersIndeces{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother index lMother: %d", lMother.globalIndex()); + lMothersIndeces.push_back(lMother.globalIndex()); + } + return lMothersIndeces; + }; + auto getMothersPDGCodes = [&](auto const& theMcParticle) { + std::vector lMothersPDGs{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother pdgcode lMother: %d", lMother.pdgCode()); + lMothersPDGs.push_back(lMother.pdgCode()); + } + return lMothersPDGs; + }; + // ------ + std::vector motherstrk1 = {-1, -1}; + std::vector mothersPDGtrk1 = {-1, -1}; + + std::vector motherstrk2 = {-1, -1}; + std::vector mothersPDGtrk2 = {-1, -1}; + + // + // Get the MC particle + const auto& mctrk1 = trk1.mcParticle(); + if (mctrk1.has_mothers()) { + motherstrk1 = getMothersIndeces(mctrk1); + mothersPDGtrk1 = getMothersPDGCodes(mctrk1); + } + while (motherstrk1.size() > MaxNoLambda1520Daughters) { + motherstrk1.pop_back(); + mothersPDGtrk1.pop_back(); + } + + const auto& mctrk2 = trk2.mcParticle(); + if (mctrk2.has_mothers()) { + motherstrk2 = getMothersIndeces(mctrk2); + mothersPDGtrk2 = getMothersPDGCodes(mctrk2); + } + while (motherstrk2.size() > MaxNoLambda1520Daughters) { + motherstrk2.pop_back(); + mothersPDGtrk2.pop_back(); + } + + if (std::abs(mctrk1.pdgCode()) != kProton || std::abs(mctrk2.pdgCode()) != kKPlus) + continue; + + if (motherstrk1[0] != motherstrk2[0]) // Same mother + continue; + + if (std::abs(mothersPDGtrk1[0]) != Pdg::kLambda1520_Py) + continue; + + // LOGF(info, "mother trk1 id: %d, mother trk1: %d, trk1 id: %d, trk1 pdgcode: %d, mother trk2 id: %d, mother trk2: %d, trk2 id: %d, trk2 pdgcode: %d", motherstrk1[0], mothersPDGtrk1[0], trk1.globalIndex(), mctrk1.pdgCode(), motherstrk2[0], mothersPDGtrk2[0], trk2.globalIndex(), mctrk2.pdgCode()); + + if (cUseEtacutMC && std::abs(lResonance.Eta()) > cEtacutMC) // eta cut + continue; + + if (cUseRapcutMC && std::abs(resonanceRapidity) > configTracks.cfgCutRapidity) // rapidity cut + continue; + + histos.fill(HIST("QA/MC/h2RecoEtaPt_after"), lResonance.Eta(), resonancePt); + histos.fill(HIST("QA/MC/h2RecoPhiRapidity_after"), lResonance.Phi(), resonanceRapidity); + + // Track selection check. + histos.fill(HIST("QA/MC/trkDCAxy_pr"), trk1ptPr, trk1.dcaXY()); + histos.fill(HIST("QA/MC/trkDCAxy_ka"), trk2ptKa, trk2.dcaXY()); + histos.fill(HIST("QA/MC/trkDCAz_pr"), trk1ptPr, trk1.dcaZ()); + histos.fill(HIST("QA/MC/trkDCAz_ka"), trk2ptKa, trk2.dcaZ()); + + histos.fill(HIST("QA/MC/TPC_Nsigma_pr_all"), centrality, trk1ptPr, trk1NSigmaPrTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/MC/TOF_Nsigma_pr_all"), centrality, trk1ptPr, trk1NSigmaPrTOF); + } + histos.fill(HIST("QA/MC/TPC_Nsigma_ka_all"), centrality, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/MC/TOF_Nsigma_ka_all"), centrality, trk2ptKa, trk2NSigmaKaTOF); + } + + // MC histograms + if (mothersPDGtrk1[0] > 0) { + histos.fill(HIST("Result/MC/h3lambda1520Recoinvmass"), centrality, resonancePt, resonanceMass); + } else { + histos.fill(HIST("Result/MC/h3antilambda1520Recoinvmass"), centrality, resonancePt, resonanceMass); + } + } + } else { + if constexpr (IsData) { + // Like sign pair ++ + if (trk1.sign() > 0) { + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/lambda1520invmassLSPP"), resonanceMass); + } + histos.fill(HIST("Result/Data/h3lambda1520invmassLSPP"), centrality, resonancePt, resonanceMass); + } else { // Like sign pair -- + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/lambda1520invmassLSMM"), resonanceMass); + } + histos.fill(HIST("Result/Data/h3lambda1520invmassLSMM"), centrality, resonancePt, resonanceMass); + } + } else if (IsMix) { + if (cFilladditionalMEPlots) { + // Like sign pair ++ + if (trk1.sign() > 0) { + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/lambda1520invmassME_LSPP"), resonanceMass); + } + histos.fill(HIST("Result/Data/h3lambda1520invmassME_LSPP"), centrality, resonancePt, resonanceMass); + } else { // Like sign pair -- + if (cFill1DQAs) { + histos.fill(HIST("Result/Data/lambda1520invmassME_LSMM"), resonanceMass); + } + histos.fill(HIST("Result/Data/h3lambda1520invmassME_LSMM"), centrality, resonancePt, resonanceMass); + } + } + } + } + } + } + + void processData(EventCandidates::iterator const& collision, + TrackCandidates const& tracks) + { + if (!colCuts.isSelected(collision)) // Default event selection + return; + + colCuts.fillQA(collision); + + fillHistograms(collision, tracks, tracks); + } + PROCESS_SWITCH(Lambda1520analysisinpp, processData, "Process Event for data without partition", false); + + void processRotational(EventCandidates::iterator const& collision, TrackCandidates const& tracks) + { + if (!colCuts.isSelected(collision, false)) // Default event selection + return; + + fillHistograms(collision, tracks, tracks); + } + PROCESS_SWITCH(Lambda1520analysisinpp, processRotational, "Process Rotational Background", false); + + void processMC(MCEventCandidates::iterator const& collision, + aod::McCollisions const&, + MCTrackCandidates const& tracks, aod::McParticles const&) + { + colCuts.fillQA(collision); + + if (std::abs(collision.posZ()) > cZvertCutMC) // Z-vertex cut + return; + + fillHistograms(collision, tracks, tracks); + } + PROCESS_SWITCH(Lambda1520analysisinpp, processMC, "Process Event for MC Light without partition", false); + + Partition selectedMCParticles = (nabs(aod::mcparticle::pdgCode) == static_cast(Pdg::kLambda1520_Py)); // Lambda(1520) + + void processMCTrue(MCEventCandidates::iterator const& collision, aod::McCollisions const&, aod::McParticles const& mcParticles) + { + bool isInAfterAllCuts = colCuts.isSelected(collision); + bool inVtx10 = (std::abs(collision.mcCollision().posZ()) > configEvents.cfgEvtZvtx) ? false : true; + bool isTriggerTVX = collision.selection_bit(aod::evsel::kIsTriggerTVX); + bool isSel8 = collision.sel8(); + bool isTrueINELgt0 = isTrueINEL0(collision, mcParticles); + auto centrality = centEst(collision); + + auto mcParts = selectedMCParticles->sliceBy(perMcCollision, collision.mcCollision().globalIndex()); + + // Not related to the real collisions + for (const auto& part : mcParts) { // loop over all MC particles + + std::vector daughterPDGs; + if (part.has_daughters()) { + auto daughter01 = mcParticles.rawIteratorAt(part.daughtersIds()[0] - mcParticles.offset()); + auto daughter02 = mcParticles.rawIteratorAt(part.daughtersIds()[1] - mcParticles.offset()); + daughterPDGs = {daughter01.pdgCode(), daughter02.pdgCode()}; + } else { + daughterPDGs = {-1, -1}; + } + + bool pass1 = std::abs(daughterPDGs[0]) == kKPlus || std::abs(daughterPDGs[1]) == kKPlus; // At least one decay to Kaon + bool pass2 = std::abs(daughterPDGs[0]) == kProton || std::abs(daughterPDGs[1]) == kProton; // At least one decay to Proton + + // Checking if we have both decay products + if (!pass1 || !pass2) + continue; + + // LOGF(info, "Part PDG: %d", part.pdgCode(), "DAU_ID1: %d", pass1, "DAU_ID2: %d", pass2); + + histos.fill(HIST("QA/MC/h2GenEtaPt_beforeanycut"), part.eta(), part.pt()); + histos.fill(HIST("QA/MC/h2GenPhiRapidity_beforeanycut"), part.phi(), part.y()); + + if (cUseRapcutMC && std::abs(part.y()) > configTracks.cfgCutRapidity) // rapidity cut + continue; + + if (cfgUseDaughterEtaCutMC) { + for (auto const& daughters : part.daughters_as()) { + if (std::fabs(daughters.eta()) > configTracks.cfgCutEta) + continue; // eta cut for daughters + } // loop over daughters + } + + histos.fill(HIST("QA/MC/h2GenEtaPt_afterRapcut"), part.eta(), part.pt()); + histos.fill(HIST("QA/MC/h2GenPhiRapidity_afterRapcut"), part.phi(), part.y()); + + if (cUseEtacutMC && std::abs(part.eta()) > cEtacutMC) // eta cut + continue; + + histos.fill(HIST("QA/MC/h2GenEtaPt_afterEtaRapCut"), part.eta(), part.pt()); + histos.fill(HIST("QA/MC/h2GenPhiRapidity_afterEtaRapCut"), part.phi(), part.y()); + + // without any event selection + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 0, part.pt(), centrality); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 0, part.pt(), centrality); + + if (inVtx10) // INEL10 + { + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 1, part.pt(), centrality); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 1, part.pt(), centrality); + } + if (inVtx10 && isSel8) // INEL>10, vtx10 + { + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 2, part.pt(), centrality); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 2, part.pt(), centrality); + } + if (inVtx10 && isTriggerTVX) // vtx10, TriggerTVX + { + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 3, part.pt(), centrality); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 3, part.pt(), centrality); + } + if (isInAfterAllCuts) // after all event selection + { + if (part.pdgCode() > 0) + histos.fill(HIST("Result/MC/Genlambda1520pt"), 4, part.pt(), centrality); + else + histos.fill(HIST("Result/MC/Genantilambda1520pt"), 4, part.pt(), centrality); + } + } + + // QA for Trigger efficiency + histos.fill(HIST("Event/hMCEventIndices"), centrality, Inel); + if (inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Inel10); + if (isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Inelg0); + if (inVtx10 && isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Inelg010); + + // TVX MB trigger + if (isTriggerTVX) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Trig); + if (isTriggerTVX && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Trig10); + if (isTriggerTVX && isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, TrigINELg0); + if (isTriggerTVX && isTrueINELgt0 && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, TrigINELg010); + + // Sel8 event selection + if (isSel8) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Sel8); + if (isSel8 && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Sel810); + if (isSel8 && isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Sel8INELg0); + if (isSel8 && isTrueINELgt0 && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Sel8INELg010); + + // CollisionCuts selection + if (isInAfterAllCuts) + histos.fill(HIST("Event/hMCEventIndices"), centrality, AllCuts); + if (isInAfterAllCuts && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, AllCuts10); + if (isInAfterAllCuts && isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, AllCutsINELg0); + if (isInAfterAllCuts && isTrueINELgt0 && inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, AllCutsINELg010); + } + PROCESS_SWITCH(Lambda1520analysisinpp, processMCTrue, "Process Event for MC only", false); + + // Processing Event Mixing + using BinningTypeVtxZT0M = ColumnBinningPolicy; + + void processME(EventCandidates const& collision, + TrackCandidates const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + + BinningTypeVtxZT0M colBinning{{configBkg.cfgVtxBins, configBkg.cfgMultBins}, true}; + SameKindPair pairs{colBinning, configBkg.nEvtMixing, -1, collision, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.globalIndex(), collision2.globalIndex()); + + // for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d)", t1.index(), t2.index(), collision1.index(), collision2.index()); + // } + + if (cFilladditionalQAeventPlots) { + // Fill histograms for the characteristics of the *mixed* events (collision1 and collision2) + // This will show the distribution of events that are actually being mixed. + if (cFill1DQAs) { + histos.fill(HIST("QAevent/hMixPool_VtxZ"), collision1.posZ()); + histos.fill(HIST("QAevent/hMixPool_Multiplicity"), collision1.centFT0M()); + } + histos.fill(HIST("QAevent/hMixPool_VtxZ_vs_Multiplicity"), collision1.posZ(), collision1.centFT0M()); + + // You might also want to fill for collision2 if you want to see both partners' distributions + // histos.fill(HIST("QAevent/hMixPool_VtxZ"), collision2.posZ()); + // histos.fill(HIST("QAevent/hMixPool_Multiplicity"), collision2.centFT0M()); + // histos.fill(HIST("QAevent/hMixPool_VtxZ_vs_Multiplicity"), collision2.posZ(), collision2.centFT0M()); + } + fillHistograms(collision1, tracks1, tracks2); + } + } + PROCESS_SWITCH(Lambda1520analysisinpp, processME, "Process EventMixing light without partition", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Resonances/lstarpbpbv2.cxx b/PWGLF/Tasks/Resonances/lstarpbpbv2.cxx new file mode 100644 index 00000000000..4b9bdb5aede --- /dev/null +++ b/PWGLF/Tasks/Resonances/lstarpbpbv2.cxx @@ -0,0 +1,530 @@ +// 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. +// L* baryon v2 +// Prottay Das (prottay.das@cern.ch) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "TRandom3.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "Math/GenVector/Boost.h" +#include "TF1.h" + +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/trackUtilities.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/TrackSelection.h" +#include "Framework/ASoAHelpers.h" +#include "ReconstructionDataFormats/Track.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "CCDB/BasicCCDBManager.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; +struct lstarpbpbv2 { + + Service ccdb; + Service pdg; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutCentrality{"cfgCutCentrality", 80.0f, "Accepted maximum Centrality"}; + // track + Configurable cfgCutCharge{"cfgCutCharge", 0.0, "cut on Charge"}; + Configurable cfgCutPT{"cfgCutPT", 0.2, "PT cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; + Configurable useGlobalTrack{"useGlobalTrack", true, "use Global track"}; + Configurable nsigmaCutTOF{"nsigmacutTOF", 3.0, "Value of the TOF Nsigma cut"}; + Configurable nsigmaCutTPC{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"}; + Configurable nsigmaCutCombined{"nsigmaCutCombined", 3.0, "Value of the TOF Nsigma cut"}; + Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 1, "Number of mixed events per event"}; + Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; + Configurable removefaketrak{"removefaketrack", true, "Remove fake track from momentum difference"}; + Configurable ConfFakeKaonCut{"ConfFakeKaonCut", 0.1, "Cut based on track from momentum difference"}; + Configurable ispTdepPID{"ispTdepPID", true, "pT dependent PID"}; + Configurable OnlyTOF{"OnlyTOF", true, "OnlyTOF"}; + Configurable strategyPID{"strategyPID", 2, "PID strategy"}; + Configurable cfgCutTOFBeta{"cfgCutTOFBeta", 0.0, "cut TOF beta"}; + Configurable confMinRot{"confMinRot", 5.0 * TMath::Pi() / 6.0, "Minimum of rotation"}; + Configurable confMaxRot{"confMaxRot", 7.0 * TMath::Pi() / 6.0, "Maximum of rotation"}; + Configurable nBkgRotations{"nBkgRotations", 9, "Number of rotated copies (background) per each original candidate"}; + Configurable fillRotation{"fillRotation", true, "fill rotation"}; + Configurable like{"like", true, "fill rotation"}; + Configurable spNbins{"spNbins", 2000, "Number of bins in sp"}; + Configurable lbinsp{"lbinsp", -1.0, "lower bin value in sp histograms"}; + Configurable hbinsp{"hbinsp", 1.0, "higher bin value in sp histograms"}; + Configurable nsigmaCutITS{"nsigmaCutITS", 3.0, "Value of the ITS Nsigma cut"}; + Configurable PIDstrategy{"PIDstrategy", 0, "0: TOF Veto, 1: TOF Veto opti, 2: TOF, 3: TOF loose 1, 4: TOF loose 2, 5: old pt dep"}; + + ConfigurableAxis configcentAxis{"configcentAxis", {VARIABLE_WIDTH, 0.0, 10.0, 40.0, 80.0}, "Cent V0M"}; + ConfigurableAxis configresAxis{"configresAxis", {VARIABLE_WIDTH, -2.0, -1.5, -1.0, -0.6, -0.2, 0.2, 0.6, 1.0, 1.5, 2.0}, "Resolution"}; + ConfigurableAxis configthnAxispT{"configthnAxisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis configIMAxis{"configIMAxis", {VARIABLE_WIDTH, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.5, 1.7, 1.8, 1.9, 2.0}, "IM"}; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter centralityFilter = nabs(aod::cent::centFT0C) < cfgCutCentrality; + Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPT); + Filter DCAcutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + + using EventCandidates = soa::Filtered>; + using TrackCandidates = soa::Filtered>; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + AxisSpec spAxis = {spNbins, lbinsp, hbinsp, "Sp"}; + + histos.add("hCentrality", "Centrality distribution", kTH1F, {{20, 0.0, 100.0}}); + + histos.add("ResFT0CTPCSP", "ResFT0CTPCSP", HistType::kTHnSparseF, {configcentAxis, configresAxis}); + histos.add("ResFT0CFT0ASP", "ResFT0CFT0ASP", HistType::kTHnSparseF, {configcentAxis, configresAxis}); + histos.add("ResFT0ATPCSP", "ResFT0ATPCSP", HistType::kTHnSparseF, {configcentAxis, configresAxis}); + histos.add("hpv2vscentpt", "hpv2vscentpt", HistType::kTHnSparseF, {configIMAxis, configcentAxis, configthnAxispT, spAxis}, true); + histos.add("hpv2vscentptrot", "hpv2vscentptrot", HistType::kTHnSparseF, {configIMAxis, configcentAxis, configthnAxispT, spAxis}, true); + histos.add("hpv2vscentptlike", "hpv2vscentptlike", HistType::kTHnSparseF, {configIMAxis, configcentAxis, configthnAxispT, spAxis}, true); + } + + double massKa = o2::constants::physics::MassKPlus; + double massPr = o2::constants::physics::MassProton; + + template + bool selectionTrack(const T& candidate) + { + if (useGlobalTrack && !(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster)) { + return false; + } + if (!useGlobalTrack && !(candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster)) { + return false; + } + return true; + } + + template + bool strategySelectionPID(const T& candidate, int PID, int strategy) + { + if (PID == 0) { + if (strategy == 0) { + if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > 0.5) { + return true; + } + } else if (strategy == 1) { + if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && TMath::Sqrt(candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa() + candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > 0.5) { + return true; + } + } else if (strategy == 2) { + if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF && candidate.beta() > 0.5) { + return true; + } + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && !candidate.hasTOF()) { + return true; + } + } + } + return false; + } + + // TOF Veto + template + bool selectionPID1(const T& candidate) + { + if (candidate.hasTOF()) { + if (candidate.p() < 0.5 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + if (candidate.p() >= 0.5 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + } + if (!candidate.hasTOF()) { + if (std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + } + return false; + } + + // TPC TOF + template + bool selectionPID2(const T& candidate) + { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.7 && candidate.pt() < 1.4) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (!candidate.hasTOF()) { + if (candidate.pt() >= 0.7 && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -1.8 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.8 && candidate.pt() < 0.9 && candidate.tpcNSigmaPr() > -1.7 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.9 && candidate.pt() < 1.0 && candidate.tpcNSigmaPr() > -1.6 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 1.0 && candidate.pt() < 1.4 && candidate.tpcNSigmaPr() > -1.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + } + } + if (candidate.pt() >= 1.4) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + } + return false; + } + + // TPC TOF + template + bool selectionPID3(const T& candidate) + { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.7 && candidate.pt() < 1.8) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (!candidate.hasTOF()) { + if (candidate.pt() >= 0.7 && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -1.8 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.8 && candidate.pt() < 0.9 && candidate.tpcNSigmaPr() > -1.7 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.9 && candidate.pt() < 1.0 && candidate.tpcNSigmaPr() > -1.6 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + } + } + if (candidate.pt() >= 1.8) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + } + return false; + } + + // TPC TOF + template + bool selectionPID4(const T& candidate) + { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.7 && candidate.pt() < 1.4) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (!candidate.hasTOF()) { + if (candidate.pt() >= 0.7 && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -1.8 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.8 && candidate.pt() < 0.9 && candidate.tpcNSigmaPr() > -1.7 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.9 && candidate.pt() < 1.0 && candidate.tpcNSigmaPr() > -1.6 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 1.0 && candidate.pt() < 1.4 && candidate.tpcNSigmaPr() > -1.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + } + } + if (candidate.pt() >= 1.4) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + if (candidate.pt() < 2.5 && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 2.5 && candidate.pt() < 4 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 4 && candidate.pt() < 5 && candidate.tofNSigmaPr() > -1.5 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 5 && candidate.tofNSigmaPr() > -1.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + } + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + } + return false; + } + + // TPC TOF + template + bool selectionPID5(const T& candidate) + { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.7 && candidate.pt() < 1.8) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (!candidate.hasTOF()) { + if (candidate.pt() >= 0.7 && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -1.8 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.8 && candidate.pt() < 0.9 && candidate.tpcNSigmaPr() > -1.7 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.9 && candidate.pt() < 1.0 && candidate.tpcNSigmaPr() > -1.6 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + } + } + if (candidate.pt() >= 1.8) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + if (candidate.pt() < 2.5 && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 2.5 && candidate.pt() < 4 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 4 && candidate.pt() < 5 && candidate.tofNSigmaPr() > -1.5 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 5 && candidate.tofNSigmaPr() > -1.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + } + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + } + return false; + } + // TPC TOF + template + bool selectionPID6(const T& candidate) + { + if (candidate.pt() < 0.7 && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.7) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { + if (candidate.pt() < 2.5 && std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 2.5 && candidate.pt() < 4 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 4 && candidate.pt() < 5 && candidate.tofNSigmaPr() > -1.5 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + if (candidate.pt() >= 5 && candidate.tofNSigmaPr() > -1.0 && candidate.tofNSigmaPr() < nsigmaCutTOF) { + return true; + } + } + if (!candidate.hasTOF()) { + if (candidate.pt() >= 0.7 && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -1.8 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.8 && candidate.pt() < 0.9 && candidate.tpcNSigmaPr() > -1.7 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + if (candidate.pt() >= 0.9 && candidate.pt() < 1.0 && candidate.tpcNSigmaPr() > -1.6 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + } + } + return false; + } + + double GetPhiInRange(double phi) + { + double result = phi; + while (result < 0) { + result = result + 2. * TMath::Pi() / 2; + } + while (result > 2. * TMath::Pi() / 2) { + result = result - 2. * TMath::Pi() / 2; + } + return result; + } + + ROOT::Math::PxPyPzMVector LstarMother, daughter1, daughter2, kaonrot, lstarrot; + + void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + { + if (!collision.sel8() || !collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return; + } + + o2::aod::ITSResponse itsResponse; + + auto centrality = collision.centFT0C(); + auto QFT0C = collision.qFT0C(); + auto QFT0A = collision.qFT0A(); + auto QTPC = collision.qTPC(); + auto psiFT0C = collision.psiFT0C(); + auto psiFT0A = collision.psiFT0A(); + auto psiTPC = collision.psiTPC(); + + histos.fill(HIST("hCentrality"), centrality); + + histos.fill(HIST("ResFT0CTPCSP"), centrality, QFT0C * QTPC * TMath::Cos(2.0 * (psiFT0C - psiTPC))); + histos.fill(HIST("ResFT0CFT0ASP"), centrality, QFT0C * QFT0A * TMath::Cos(2.0 * (psiFT0C - psiFT0A))); + histos.fill(HIST("ResFT0ATPCSP"), centrality, QTPC * QFT0A * TMath::Cos(2.0 * (psiTPC - psiFT0A))); + + for (auto track1 : tracks) { + if (!selectionTrack(track1)) { + continue; + } + bool track1kaon = false; + auto track1ID = track1.globalIndex(); + if (!strategySelectionPID(track1, 0, strategyPID)) { + continue; + } + track1kaon = true; + + for (auto track2 : tracks) { + if (!selectionTrack(track2)) { + continue; + } + + if (track2.p() < 0.5 && !(itsResponse.nSigmaITS(track2) > -nsigmaCutITS && itsResponse.nSigmaITS(track2) < nsigmaCutITS)) { // required for protons only + continue; + } + + bool track2proton = false; + if (PIDstrategy == 0 && !selectionPID1(track2)) { + continue; + } + if (PIDstrategy == 1 && !selectionPID2(track2)) { + continue; + } + if (PIDstrategy == 2 && !selectionPID3(track2)) { + continue; + } + if (PIDstrategy == 3 && !selectionPID4(track2)) { + continue; + } + if (PIDstrategy == 4 && !selectionPID5(track2)) { + continue; + } + if (PIDstrategy == 5 && !selectionPID6(track2)) { + continue; + } + + track2proton = true; + auto track2ID = track2.globalIndex(); + + if (track2ID == track1ID) { + continue; + } + if (!track1kaon || !track2proton) { + continue; + } + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPr); + LstarMother = daughter1 + daughter2; + if (TMath::Abs(LstarMother.Rapidity()) >= 0.5) { + continue; + } + + auto phiminuspsi = GetPhiInRange(LstarMother.Phi() - psiFT0C); + auto v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; + + // unlike sign + if (track1.sign() * track2.sign() < 0) { + histos.fill(HIST("hpv2vscentpt"), LstarMother.M(), centrality, LstarMother.Pt(), v2); + if (fillRotation) { + for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { + auto anglestart = confMinRot; + auto angleend = confMaxRot; + auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); + auto rotangle = anglestart + nrotbkg * anglestep; + auto rotkaonPx = track1.px() * std::cos(rotangle) - track1.py() * std::sin(rotangle); + auto rotkaonPy = track1.px() * std::sin(rotangle) + track1.py() * std::cos(rotangle); + kaonrot = ROOT::Math::PxPyPzMVector(rotkaonPx, rotkaonPy, track1.pz(), massKa); + lstarrot = kaonrot + daughter2; + if (TMath::Abs(lstarrot.Rapidity()) >= 0.5) { + continue; + } + + auto phiminuspsirot = GetPhiInRange(lstarrot.Phi() - psiFT0C); + auto v2rot = TMath::Cos(2.0 * phiminuspsirot) * QFT0C; + + histos.fill(HIST("hpv2vscentptrot"), lstarrot.M(), centrality, lstarrot.Pt(), v2rot); + } + } + } + // like sign + if (track1.sign() * track2.sign() > 0) { + histos.fill(HIST("hpv2vscentptlike"), lstarrot.M(), centrality, lstarrot.Pt(), v2); + } + } + } + } + PROCESS_SWITCH(lstarpbpbv2, processSE, "Process Same event", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"lstarpbpbv2"})}; +} diff --git a/PWGLF/Tasks/Resonances/phiOO.cxx b/PWGLF/Tasks/Resonances/phiOO.cxx new file mode 100644 index 00000000000..9c7e6005264 --- /dev/null +++ b/PWGLF/Tasks/Resonances/phiOO.cxx @@ -0,0 +1,675 @@ +// 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. + +/// \file phiInJets.cxx +/// \brief Reconstruction of Phi yield through track-track Minv correlations for resonance OO analysis +/// +/// +/// \author Adrian Fereydon Nassirpour +#include +#include +#include +#include +#include + +#include "TRandom.h" +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct phiOO { + + SliceCache cache; + Preslice perCollision = aod::track::collisionId; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Event configurables + Configurable cfg_Event_Sel{"cfg_Event_Sel", "sel8", "choose event selection"}; + Configurable cfg_Event_VtxCut{"cfg_Event_VtxCut", 10.0, "V_z cut selection"}; + Configurable cfg_Event_Timeframe{"cfg_Event_Timeframe", true, "Timeframe border cut"}; + Configurable cfg_Event_Timerange{"cfg_Event_Timerange", true, "Timerange border cut"}; + Configurable cfg_Event_Centrality{"cfg_Event_Centrality", true, "Centrality cut"}; + Configurable cfg_Event_CentralityMax{"cfg_Event_CentralityMax", 100, "CentralityMax cut"}; + Configurable cfg_Event_Pileup{"cfg_Event_Pileup", true, "Pileup border cut"}; + Configurable cfg_Event_OccupancyCut{"cfg_Event_OccupancyCut", true, "Occupancy border cut"}; + Configurable cfg_Event_MaxOccupancy{"cfg_Event_MaxOccupancy", 1, "Max TPC Occupancy"}; + + // Track configurables + Configurable cfg_Track_Sel{"cfg_Track_Sel", "globalTracks", "set track selections"}; + Configurable cfg_Track_MinPt{"cfg_Track_MinPt", 0.15, "set track min pT"}; + Configurable cfg_Track_MaxEta{"cfg_Track_MaxEta", 0.9, "set track max Eta"}; + Configurable cfg_Track_MaxDCArToPVcut{"cfg_Track_MaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; + Configurable cfg_Track_MaxDCAzToPVcut{"cfg_Track_MaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; + Configurable cfg_Track_PrimaryTrack{"cfg_Track_PrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable cfg_Track_ConnectedToPV{"cfg_Track_ConnectedToPV", true, "PV contributor track selection"}; // PV Contributor + Configurable cfg_Track_GlobalWoDCATrack{"cfg_Track_GlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + Configurable cfg_Track_nFindableTPCClusters{"cfg_Track_FindableTPCClusters", 50, "nFindable TPC Clusters"}; + Configurable cfg_Track_nTPCCrossedRows{"cfg_Track_TPCCrossedRows", 70, "nCrossed TPC Rows"}; + Configurable cfg_Track_nRowsOverFindable{"cfg_Track_RowsOverFindable", 1.2, "nRowsOverFindable TPC CLusters"}; + Configurable cfg_Track_nTPCChi2{"cfg_Track_TPCChi2", 4.0, "nTPC Chi2 per Cluster"}; + Configurable cfg_Track_nITSChi2{"cfg_Track_ITSChi2", 36.0, "nITS Chi2 per Cluster"}; + Configurable cfg_Track_TPCPID{"cfg_Track_TPCPID", true, "Enables TPC PID"}; + Configurable cfg_Track_TOFPID{"cfg_Track_TOFPID", true, "Enables TOF PID"}; + Configurable cfg_Track_Hard_TOFPID{"cfg_Track_Hard_TOFPID", true, "Enables STRICT TOF Reqruirement"}; + Configurable cfg_Track_TPCPID_nSig{"cfg_Track_TPCPID_nSig", 4, "nTPC PID sigma"}; + Configurable cfg_Track_TOFPID_nSig{"cfg_Track_TOFPID_nSig", 4, "nTOF PID sigma"}; + Configurable cfg_Track_Explicit_PID{"cfg_Track_Explicit_PID", true, "Enables explicit pid cehck"}; + Configurable cDebugLevel{"cDebugLevel", 0, "Resolution of Debug"}; + + // Pair configurables + Configurable cfg_Pair_MinvBins{"cfg_Pair_MinvBins", 300, "Number of bins for Minv axis"}; + Configurable cfg_Pair_MinvMin{"cfg_Pair_MinvMin", 0.90, "Minimum Minv value"}; + Configurable cfg_Pair_MinvMax{"cfg_Pair_MinvMax", 1.50, "Maximum Minv value"}; + + Configurable cfg_Mix_NMixedEvents{"cfg_Mix_NMixedEvents", 5, "Number of mixed events per event"}; + + // MCGen configurables + Configurable cfg_Force_GenReco{"cfg_Force_GenReco", false, "Only consider events which are reconstructed (neglect event-loss)"}; + Configurable cfg_Force_BR{"cfg_Force_BR", false, "Only consider phi->K+K-"}; + Configurable cfg_Force_Kaon_Acceptence{"cfg_Force_Kaon_Acceptence", false, "Only consider phi's whose daughters decay inside acceptence (no signal loss)"}; + + // Histogram Configurables + Configurable cfg_Event_CutQA{"cfg_Event_CutsQA", true, "Enables Track QA plots"}; + Configurable cfg_Track_CutQA{"cfg_Track_CutsQA", true, "Enables Track QA plots"}; + + // Configurables for axis + ConfigurableAxis binsDCAz{"binsDCAz", {40, -0.2, 0.2}, ""}; + ConfigurableAxis binsDCAxy{"binsDCAxy", {40, -0.2, 0.2}, ""}; + ConfigurableAxis cfg_bins_Cent{"cfg_bins_Cent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; + ConfigurableAxis cfg_bins_MixVtx{"cfg_bins_MixVtx", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfg_bins_MixMult{"cfg_bins_MixMult", {VARIABLE_WIDTH, 0.0f, 1.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f}, "Mixing bins - z-vertex"}; + + void init(o2::framework::InitContext&) + { + const AxisSpec MinvAxis = {cfg_Pair_MinvBins, cfg_Pair_MinvMin, cfg_Pair_MinvMax}; + const AxisSpec PtAxis = {200, 0, 20.0}; + const AxisSpec MultAxis = {100, 0, 100}; + const AxisSpec dRAxis = {100, 0, 100}; + const AxisSpec pidAxis = {100, -5, 5}; + const AxisSpec axisDCAz{binsDCAz, "DCA_{z}"}; + const AxisSpec axisDCAxy{binsDCAxy, "DCA_{XY}"}; + + // Event QA + if (cfg_Event_CutQA) { + histos.add("hPosZ_BC", "PosZ_BC", kTH1F, {{240, -12.0, 12.0}}); + histos.add("hcentFT0C_BC", "centFT0C_BC", kTH1F, {{110, 0.0, 110.0}}); + histos.add("hOccupancy_BC", "Occupancy_BC", kTH1F, {{100, 0.0, 20000}}); + // + histos.add("hcentFT0C_AC", "centFT0C_AC", kTH1F, {{110, 0.0, 110.0}}); + histos.add("hPosZ_AC", "PosZ_AC", kTH1F, {{240, -12.0, 12.0}}); + histos.add("hOccupancy_AC", "Occupancy_AC", kTH1F, {{100, 0.0, 20000}}); + } + // Track QA + if (cfg_Track_CutQA) { + histos.add("hDCArToPv_BC", "DCArToPv_BC", kTH1F, {axisDCAxy}); + histos.add("hDCAzToPv_BC", "DCAzToPv_BC", kTH1F, {axisDCAz}); + histos.add("hIsPrim_BC", "hIsPrim_BC", kTH1F, {{2, -0.5, 1.5}}); + histos.add("hIsGood_BC", "hIsGood_BC", kTH1F, {{2, -0.5, 1.5}}); + histos.add("hIsPrimCont_BC", "hIsPrimCont_BC", kTH1F, {{2, -0.5, 1.5}}); + histos.add("hFindableTPCClusters_BC", "hFindableTPCClusters_BC", kTH1F, {{200, 0, 200}}); + histos.add("hFindableTPCRows_BC", "hFindableTPCRows_BC", kTH1F, {{200, 0, 200}}); + histos.add("hClustersVsRows_BC", "hClustersVsRows_BC", kTH1F, {{200, 0, 2}}); + histos.add("hTPCChi2_BC", "hTPCChi2_BC", kTH1F, {{200, 0, 100}}); + histos.add("hITSChi2_BC", "hITSChi2_BC", kTH1F, {{200, 0, 100}}); + histos.add("hTPC_nSigma_BC", "hTPC_nSigma_BC", kTH1F, {pidAxis}); + histos.add("hTOF_nSigma_BC", "hTOF_nSigma_BC", kTH1F, {pidAxis}); + histos.add("hTPC_nSigma_v_pt_BC", "hTPC_nSigma_v_pt_BC", HistType::kTHnSparseD, {pidAxis, PtAxis}); + histos.add("hTOF_nSigma_v_pt_BC", "hTOF_nSigma_v_pt_BC", HistType::kTHnSparseD, {pidAxis, PtAxis}); + // + histos.add("hDCArToPv_AC", "DCArToPv_AC", kTH1F, {axisDCAxy}); + histos.add("hDCAzToPv_AC", "DCAzToPv_AC", kTH1F, {axisDCAz}); + histos.add("hIsPrim_AC", "hIsPrim_AC", kTH1F, {{2, -0.5, 1.5}}); + histos.add("hIsGood_AC", "hIsGood_AC", kTH1F, {{2, -0.5, 1.5}}); + histos.add("hIsPrimCont_AC", "hIsPrimCont_AC", kTH1F, {{2, -0.5, 1.5}}); + histos.add("hFindableTPCClusters_AC", "hFindableTPCClusters_AC", kTH1F, {{200, 0, 200}}); + histos.add("hFindableTPCRows_AC", "hFindableTPCRows_AC", kTH1F, {{200, 0, 200}}); + histos.add("hClustersVsRows_AC", "hClustersVsRows_AC", kTH1F, {{200, 0, 2}}); + histos.add("hTPCChi2_AC", "hTPCChi2_AC", kTH1F, {{200, 0, 100}}); + histos.add("hITSChi2_AC", "hITSChi2_AC", kTH1F, {{200, 0, 100}}); + histos.add("hTPC_nSigma_AC", "hTPC_nSigma_AC", kTH1F, {pidAxis}); + histos.add("hTOF_nSigma_AC", "hTOF_nSigma_AC", kTH1F, {pidAxis}); + histos.add("hTPC_nSigma_v_pt_AC", "hTPC_nSigma_v_pt_AC", HistType::kTHnSparseD, {pidAxis, PtAxis}); + histos.add("hTOF_nSigma_v_pt_AC", "hTOF_nSigma_v_pt_AC", HistType::kTHnSparseD, {pidAxis, PtAxis}); + } + // Data histos + histos.add("hUSS", "hUSS", HistType::kTHnSparseD, {cfg_bins_Cent, MinvAxis, PtAxis}); + histos.add("hLSS", "hLSS", HistType::kTHnSparseD, {cfg_bins_Cent, MinvAxis, PtAxis}); + histos.add("hUSS_Mix", "hUSS_Mix", HistType::kTHnSparseD, {cfg_bins_Cent, MinvAxis, PtAxis}); + histos.add("hLSS_Mix", "hLSS_Mix", HistType::kTHnSparseD, {cfg_bins_Cent, MinvAxis, PtAxis}); + + // MC histos + histos.add("hMC_USS", "hMC_USS", HistType::kTHnSparseD, {cfg_bins_Cent, MinvAxis, PtAxis}); + histos.add("hMC_LSS", "hMC_LSS", HistType::kTHnSparseD, {cfg_bins_Cent, MinvAxis, PtAxis}); + histos.add("hMC_USS_Mix", "hMC_USS_Mix", HistType::kTHnSparseD, {cfg_bins_Cent, MinvAxis, PtAxis}); + histos.add("hMC_LSS_Mix", "hMC_LSS_Mix", HistType::kTHnSparseD, {cfg_bins_Cent, MinvAxis, PtAxis}); + histos.add("hMC_USS_True", "hMC_USS_True", HistType::kTHnSparseD, {cfg_bins_Cent, MinvAxis, PtAxis}); + histos.add("hMC_Phi_True", "hMC_Phi_True", HistType::kTHnSparseD, {cfg_bins_Cent, PtAxis}); + + // Event Histograms + histos.add("hnEvents", "Event selection decision", kTH1I, {{10, -0.5, 9.5}}); + histos.add("hnEvents_MC", "Event selection decision", kTH1I, {{10, -0.5, 9.5}}); + histos.add("hnEvents_MC_True", "Event selection decision", kTH1I, {{10, -0.5, 9.5}}); + + } // end of init + + Filter collisionFilter = nabs(aod::collision::posZ) <= cfg_Event_VtxCut; + Filter collisionFilter_MC = nabs(aod::mccollision::posZ) <= cfg_Event_VtxCut; + Filter centralityFilter = nabs(aod::cent::centFT0C) <= cfg_Event_CentralityMax; + Filter acceptanceFilter = (nabs(aod::track::eta) < cfg_Track_MaxEta && nabs(aod::track::pt) >= cfg_Track_MinPt); + using EventCandidates = soa::Filtered>; + using EventCandidates_True = soa::Filtered; + + using TrackCandidates = soa::Filtered>; + using TrackCandidates_MC = soa::Filtered>; + + using BinningTypeVtxCent = ColumnBinningPolicy; + + Partition PosKaon_MC = + (aod::track::signed1Pt > static_cast(0)) && + (!cfg_Track_TPCPID || (nabs(aod::pidtpc::tpcNSigmaKa) <= cfg_Track_TPCPID_nSig)); + Partition NegKaon_MC = + (aod::track::signed1Pt < static_cast(0)) && + (!cfg_Track_TPCPID || (nabs(aod::pidtpc::tpcNSigmaKa) <= cfg_Track_TPCPID_nSig)); + Partition PosKaon = + (aod::track::signed1Pt > static_cast(0)) && + (!cfg_Track_TPCPID || (nabs(aod::pidtpc::tpcNSigmaKa) <= cfg_Track_TPCPID_nSig)); + Partition NegKaon = + (aod::track::signed1Pt < static_cast(0)) && + (!cfg_Track_TPCPID || (nabs(aod::pidtpc::tpcNSigmaKa) <= cfg_Track_TPCPID_nSig)); + + double massKa = o2::constants::physics::MassKPlus; + //***********************************// + // First, we declare some helper functions + template + void fillQA(const bool pass, const objType& obj, const int objecttype = 0) + { + + if (objecttype == 1) { + if constexpr (requires { obj.posZ(); }) { + if (!pass) { + histos.fill(HIST("hPosZ_BC"), obj.posZ()); + histos.fill(HIST("hcentFT0C_BC"), obj.centFT0C()); + } else { + histos.fill(HIST("hPosZ_AC"), obj.posZ()); + histos.fill(HIST("hcentFT0C_AC"), obj.centFT0C()); + } + } + } + if constexpr (requires { obj.tpcCrossedRowsOverFindableCls(); }) { + if (objecttype == 2) { + if (!pass) { + histos.fill(HIST("hDCArToPv_BC"), obj.dcaXY()); + histos.fill(HIST("hDCAzToPv_BC"), obj.dcaZ()); + histos.fill(HIST("hIsPrim_BC"), obj.isPrimaryTrack()); + histos.fill(HIST("hIsGood_BC"), obj.isGlobalTrackWoDCA()); + histos.fill(HIST("hIsPrimCont_BC"), obj.isPVContributor()); + histos.fill(HIST("hFindableTPCClusters_BC"), obj.tpcNClsFindable()); + histos.fill(HIST("hFindableTPCRows_BC"), obj.tpcNClsCrossedRows()); + histos.fill(HIST("hClustersVsRows_BC"), obj.tpcCrossedRowsOverFindableCls()); + histos.fill(HIST("hTPCChi2_BC"), obj.tpcChi2NCl()); + } else { + histos.fill(HIST("hDCArToPv_AC"), obj.dcaXY()); + histos.fill(HIST("hDCAzToPv_AC"), obj.dcaZ()); + histos.fill(HIST("hIsPrim_AC"), obj.isPrimaryTrack()); + histos.fill(HIST("hIsGood_AC"), obj.isGlobalTrackWoDCA()); + histos.fill(HIST("hIsPrimCont_AC"), obj.isPVContributor()); + histos.fill(HIST("hFindableTPCClusters_AC"), obj.tpcNClsFindable()); + histos.fill(HIST("hFindableTPCRows_AC"), obj.tpcNClsCrossedRows()); + histos.fill(HIST("hClustersVsRows_AC"), obj.tpcCrossedRowsOverFindableCls()); + histos.fill(HIST("hTPCChi2_AC"), obj.tpcChi2NCl()); + } + } + if (objecttype == 3) { + if (!pass) { + histos.fill(HIST("hTPC_nSigma_BC"), obj.tpcNSigmaKa()); + histos.fill(HIST("hTOF_nSigma_BC"), obj.tofNSigmaKa()); + histos.fill(HIST("hTPC_nSigma_v_pt_BC"), obj.tpcNSigmaKa(), obj.pt()); + histos.fill(HIST("hTOF_nSigma_v_pt_BC"), obj.tofNSigmaKa(), obj.pt()); + } else { + histos.fill(HIST("hTPC_nSigma_AC"), obj.tpcNSigmaKa()); + histos.fill(HIST("hTOF_nSigma_AC"), obj.tofNSigmaKa()); + histos.fill(HIST("hTPC_nSigma_v_pt_AC"), obj.tpcNSigmaKa(), obj.pt()); + histos.fill(HIST("hTOF_nSigma_v_pt_AC"), obj.tofNSigmaKa(), obj.pt()); + } + } + } + }; + //***********************************// + + // evsel + template + std::pair eventSelection(const EventType event, const bool QA) + { + + if (cfg_Track_CutQA && QA) + fillQA(false, event, 1); + + if (!event.sel8()) + return {false, 1}; + if (std::abs(event.posZ()) > cfg_Event_VtxCut) + return {false, 2}; + if (cfg_Event_Timeframe && (!event.selection_bit(aod::evsel::kNoTimeFrameBorder) || !event.selection_bit(aod::evsel::kNoITSROFrameBorder))) + return {false, 3}; + if (cfg_Event_Timerange && (!event.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) + return {false, 4}; + if (cfg_Event_Pileup && (!event.selection_bit(aod::evsel::kNoSameBunchPileup) || !event.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) + return {false, 5}; + if (cfg_Event_Centrality && (event.centFT0C() > cfg_Event_CentralityMax)) + return {false, 6}; + if (cfg_Event_OccupancyCut && (event.trackOccupancyInTimeRange() > cfg_Event_MaxOccupancy)) + return {false, 7}; + + if (cfg_Track_CutQA && QA) + fillQA(true, event, 1); + + return {true, 8}; + }; + + // tracksel + template + bool trackSelection(const TrackType track, const bool QA) + { + if (cfg_Track_CutQA && QA) + fillQA(false, track, 2); + + // basic track cuts + if (track.pt() < cfg_Track_MinPt) + return false; + if (std::abs(track.eta()) > cfg_Track_MaxEta) + return false; + if (std::abs(track.dcaXY()) > cfg_Track_MaxDCArToPVcut) + return false; + if (std::abs(track.dcaZ()) > cfg_Track_MaxDCAzToPVcut) + return false; + if (cfg_Track_PrimaryTrack && !track.isPrimaryTrack()) + return false; + if (track.tpcNClsFindable() < cfg_Track_nFindableTPCClusters) + return false; + if (track.tpcNClsCrossedRows() < cfg_Track_nTPCCrossedRows) + return false; + if (track.tpcCrossedRowsOverFindableCls() > cfg_Track_nRowsOverFindable) + return false; + if (track.tpcChi2NCl() > cfg_Track_nTPCChi2) + return false; + if (track.itsChi2NCl() > cfg_Track_nITSChi2) + return false; + if (cfg_Track_ConnectedToPV && !track.isPVContributor()) + return false; + + if (cfg_Track_CutQA && QA) + fillQA(true, track, 2); + return true; + }; + + // trackpid + + template + bool trackPIDKaon(const TrackPID& candidate, const bool QA) + { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + + if (cfg_Track_CutQA && QA) + fillQA(false, candidate, 3); + + if (!cfg_Track_TPCPID) { + tpcPIDPassed = true; + } else { + if (std::abs(candidate.tpcNSigmaKa()) < cfg_Track_TPCPID_nSig) + tpcPIDPassed = true; + } + + if (!cfg_Track_TOFPID) { + tofPIDPassed = true; + } else { + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaKa()) < cfg_Track_TOFPID_nSig) { + tofPIDPassed = true; + } + } else if (!cfg_Track_Hard_TOFPID) { + tofPIDPassed = true; + } + if (!candidate.hasTOF()) { + std::cout << candidate.tofNSigmaKa() << std::endl; + } + } + if (tpcPIDPassed && tofPIDPassed) { + if (cfg_Track_CutQA && QA) { + fillQA(true, candidate, 3); + } + return true; + } + return false; + } + + template + void TrackSlicing(const CollisionType& collision1, const TracksType&, const CollisionType& collision2, const TracksType&, const bool QA, const bool IsMix) + { + auto slicedtracks1 = PosKaon->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto slicedtracks2 = NegKaon->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + auto centrality = collision1.centFT0C(); + for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(slicedtracks1, slicedtracks2))) { + auto [Minv, PhiPt] = minvReconstruction(track1, track2, QA); + if (Minv < 0) + continue; + double conjugate = track1.sign() * track2.sign(); + if (!IsMix) { + if (conjugate < 0) { + histos.fill(HIST("hUSS"), centrality, Minv, PhiPt); + } else if (conjugate > 0) { + histos.fill(HIST("hLSS"), centrality, Minv, PhiPt); + } + } else { + if (conjugate < 0) { + histos.fill(HIST("hUSS_Mix"), centrality, Minv, PhiPt); + } else if (conjugate > 0) { + histos.fill(HIST("hLSS_Mix"), centrality, Minv, PhiPt); + } + } + } + } // TrackSlicing + + template + void TrackSlicing_MC(const CollisionType& collision1, const TracksType&, const CollisionType& collision2, const TracksType&, const bool QA, const bool IsMix) + { + auto slicedtracks1 = PosKaon_MC->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto slicedtracks2 = NegKaon_MC->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + auto centrality = collision1.centFT0C(); + for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(slicedtracks1, slicedtracks2))) { + auto [Minv, PhiPt] = minvReconstruction(track1, track2, QA); + if (Minv < 0) + continue; + double conjugate = track1.sign() * track2.sign(); + if (!IsMix) { + if (conjugate < 0) { + histos.fill(HIST("hMC_USS"), centrality, Minv, PhiPt); + } else if (conjugate > 0) { + histos.fill(HIST("hMC_LSS"), centrality, Minv, PhiPt); + } + } else { + if (conjugate < 0) { + histos.fill(HIST("hMC_USS_Mix"), centrality, Minv, PhiPt); + } else if (conjugate > 0) { + histos.fill(HIST("hMC_LSS_Mix"), centrality, Minv, PhiPt); + } + } + // now we do mc true + if (!track1.has_mcParticle() || !track2.has_mcParticle()) + continue; + auto part1 = track1.mcParticle(); + auto part2 = track2.mcParticle(); + if (std::fabs(part1.pdgCode()) != 321) + continue; // Not Kaon + if (std::fabs(part2.pdgCode()) != 321) + continue; // Not Kaon + + if (!part1.has_mothers()) + continue; // Not decaying Kaon + if (!part2.has_mothers()) + continue; // Not decaying Kaon + + std::vector mothers1{}; + std::vector mothers1PDG{}; + for (auto& part1_mom : part1.template mothers_as()) { + mothers1.push_back(part1_mom.globalIndex()); + mothers1PDG.push_back(part1_mom.pdgCode()); + } + + std::vector mothers2{}; + std::vector mothers2PDG{}; + for (auto& part2_mom : part2.template mothers_as()) { + mothers2.push_back(part2_mom.globalIndex()); + mothers2PDG.push_back(part2_mom.pdgCode()); + } + + if (mothers1PDG[0] != 333) + continue; // mother not phi + if (mothers2PDG[0] != 333) + continue; // mother not phi + + if (mothers1[0] != mothers2[0]) + continue; // Kaons not from the same phi + + histos.fill(HIST("hMC_USS_True"), centrality, Minv, PhiPt); + } + } // TrackSlicing + + // Invariant mass + template + std::pair minvReconstruction(const TracksType& trk1, const TracksType& trk2, const bool QA) + { + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + //==================================================== + + if (!trackSelection(trk1, QA) || !trackSelection(trk2, false)) + return {-1.0, -1.0}; + + if (cfg_Track_Explicit_PID) { + if (!trackPIDKaon(trk1, QA) || !trackPIDKaon(trk2, false)) + return {-1.0, -1.0}; + } + + if (trk1.globalIndex() >= trk2.globalIndex()) + return {-1.0, -1.0}; + + lDecayDaughter1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massKa); + lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); + lResonance = lDecayDaughter1 + lDecayDaughter2; + + return {lResonance.M(), lResonance.Pt()}; + } // MinvReconstruction + + //***************// + // DATA + //***************// + + int nEvents = 0; + void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks) + { + if (cDebugLevel > 0) { + ++nEvents; + if (nEvents % 10000 == 0) { + std::cout << "Processed Data Events: " << nEvents << std::endl; + } + } + + auto [goodEv, code] = eventSelection(collision, true); + histos.fill(HIST("hnEvents"), code); + if (!goodEv) + return; + TrackSlicing(collision, tracks, collision, tracks, true, false); + + } // end of process + + PROCESS_SWITCH(phiOO, processSameEvent, "Process Same events", true); + + //***************// + // DATA (MIX) + //***************// + + int nEvents_Mix = 0; + void processMixedEvent(EventCandidates const& collisions, TrackCandidates const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + BinningTypeVtxCent colBinning{{cfg_bins_MixVtx, cfg_bins_MixMult}, true}; + SameKindPair pairs{colBinning, cfg_Mix_NMixedEvents, -1, collisions, tracksTuple, &cache}; + + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + if (cDebugLevel > 0) { + ++nEvents_Mix; + if (nEvents_Mix % 10000 == 0) { + std::cout << "Processed Mixed Events: " << nEvents_Mix << std::endl; + } + } + auto [goodEv1, code1] = eventSelection(collision1, false); + auto [goodEv2, code2] = eventSelection(collision2, false); + if (!goodEv1 || !goodEv2) + continue; + TrackSlicing(collision1, tracks1, collision2, tracks2, false, true); + } // mixing + } // end of process + PROCESS_SWITCH(phiOO, processMixedEvent, "Process Mixed events", false); + + //***************// + // RECONSTRUCTED MC + //***************// + + int nEvents_MC = 0; + void processSameEvent_MC(EventCandidates::iterator const& collision, TrackCandidates_MC const& tracks, aod::McParticles const&) + { + if (cDebugLevel > 0) { + ++nEvents_MC; + if (nEvents_MC % 10000 == 0) { + std::cout << "Processed MC (REC) Events: " << nEvents_MC << std::endl; + } + } + + auto [goodEv, code] = eventSelection(collision, true); + histos.fill(HIST("hnEvents_MC"), code); + if (!goodEv) + return; + TrackSlicing_MC(collision, tracks, collision, tracks, true, false); + + } // end of process + PROCESS_SWITCH(phiOO, processSameEvent_MC, "Process Same events (MC)", true); + + //***************// + // RECONSTRUCTED MC (MIX) + //***************// + + int nEvents_MC_Mix = 0; + void processMixedEvent_MC(EventCandidates const& collisions, TrackCandidates_MC const& tracks, aod::McParticles const&) + { + auto tracksTuple = std::make_tuple(tracks); + BinningTypeVtxCent colBinning{{cfg_bins_MixVtx, cfg_bins_MixMult}, true}; + SameKindPair pairs{colBinning, cfg_Mix_NMixedEvents, -1, collisions, tracksTuple, &cache}; + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + if (cDebugLevel > 0) { + ++nEvents_MC_Mix; + if (nEvents_MC_Mix % 10000 == 0) { + std::cout << "Processed Mixed Events: " << nEvents_MC_Mix << std::endl; + } + } + auto [goodEv1, code1] = eventSelection(collision1, false); + auto [goodEv2, code2] = eventSelection(collision2, false); + if (!goodEv1 || !goodEv2) + continue; + TrackSlicing_MC(collision1, tracks1, collision2, tracks2, false, true); + } // mixing + } // end of process + PROCESS_SWITCH(phiOO, processMixedEvent_MC, "Process Mixed events (MC)", false); + + //***************// + // GENERATED MC + //***************// + + int nEvents_True = 0; + void processParticles(EventCandidates_True::iterator const& collision, soa::SmallGroups> const& recocolls, aod::McParticles const& particles) + { + if (cDebugLevel > 0) { + ++nEvents_True; + if (nEvents_True % 10000 == 0) { + std::cout << "Processed MC (GEN) Events: " << nEvents_True << std::endl; + } + } + + if (fabs(collision.posZ()) > cfg_Event_VtxCut) + return; + + if (recocolls.size() <= 0) { // not reconstructed + if (cfg_Force_GenReco) { + return; + } + } + + double centrality = -1; + for (auto& recocoll : recocolls) { // poorly reconstructed + centrality = recocoll.centFT0C(); + auto [goodEv, code] = eventSelection(recocoll, false); + histos.fill(HIST("hnEvents_MC_True"), code); + if (!goodEv) + return; + } + + for (auto& particle : particles) { + if (particle.pdgCode() != 333) + continue; + if (std::fabs(particle.eta()) > cfg_Track_MaxEta) + continue; + + if (cfg_Force_BR) { + bool baddecay = false; + for (auto& phidaughter : particle.daughters_as()) { + if (std::fabs(phidaughter.pdgCode()) != 321) { + baddecay = true; + break; + } + if (cfg_Force_Kaon_Acceptence) { + if (std::fabs(phidaughter.eta()) > cfg_Track_MaxEta) { + baddecay = true; + break; + } + } + } // loop over daughters + + if (baddecay) + continue; + } // enforce BR restriction + + histos.fill(HIST("hMC_Phi_True"), centrality, particle.pt()); + } // loop over particles + + } // end of process + PROCESS_SWITCH(phiOO, processParticles, "Process Particles", false); + +}; // end of main struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +}; diff --git a/PWGLF/Tasks/Resonances/phianalysis.cxx b/PWGLF/Tasks/Resonances/phianalysis.cxx index 57d4d24fad6..b529cc1fb81 100644 --- a/PWGLF/Tasks/Resonances/phianalysis.cxx +++ b/PWGLF/Tasks/Resonances/phianalysis.cxx @@ -66,8 +66,6 @@ struct phianalysis { Configurable cUseOnlyTOFTrackKa{"cUseOnlyTOFTrackKa", false, "Use only TOF track for PID selection"}; // Use only TOF track for PID selection /// TPC nCluster cut Configurable cMinTPCNclsFound{"cMinTPCNclsFound", 70, "Minimum TPC cluster found"}; - /// ITS nCluster cut - Configurable cMinITSNcls{"cMinITSNcls", 0, "Minimum ITS nCluster"}; // Kaon Configurable cMaxTPCnSigmaKaon{"cMaxTPCnSigmaKaon", 3.0, "TPC nSigma cut for Kaon"}; // TPC Configurable cMaxTOFnSigmaKaon{"cMaxTOFnSigmaKaon", 3.0, "TOF nSigma cut for Kaon"}; // TOF @@ -142,8 +140,6 @@ struct phianalysis { return false; if (track.tpcNClsFound() < cMinTPCNclsFound) return false; - if (track.itsNCls() < cMinITSNcls) - return false; if (cfgPrimaryTrack && !track.isPrimaryTrack()) return false; if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) diff --git a/PWGLF/Tasks/Resonances/phianalysisTHnSparse.cxx b/PWGLF/Tasks/Resonances/phianalysisTHnSparse.cxx index 24f86f940e4..f9fa43c1d7f 100644 --- a/PWGLF/Tasks/Resonances/phianalysisTHnSparse.cxx +++ b/PWGLF/Tasks/Resonances/phianalysisTHnSparse.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -9,10 +9,13 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// +/// \file phianalysisTHnSparse.cxx +/// \brief Analysis of phi resonance using THnSparse histograms. /// \author Veronika Barbasova (veronika.barbasova@cern.ch) -/// \since April 3, 2024 #include +#include +#include #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" @@ -25,76 +28,80 @@ #include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/PID.h" #include "PWGLF/Utils/rsnOutput.h" -#include "TDatabasePDG.h" +// #include "TDatabasePDG.h" using namespace o2; using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; -struct phianalysisTHnSparse { +struct PhianalysisTHnSparse { SliceCache cache; struct : ConfigurableGroup { - Configurable QA{"produce-qa", false, "Produce QA histograms."}; - Configurable True{"produce-true", false, "Produce True and Gen histograms."}; - Configurable Likesign{"produce-likesign", false, "Produce Like sign histograms."}; - Configurable eventMixing{"produce-event-mixing", false, "Produce Event Mixing histograms."}; + Configurable produceQA{"produceQA", false, "Produce qa histograms."}; + Configurable produceTrue{"produceTrue", false, "Produce True and Gen histograms."}; + Configurable produceLikesign{"produceLikesign", false, "Produce Like sign histograms."}; + Configurable eventMixing{"eventMixing", "none", "Produce Event Mixing histograms of type."}; } produce; struct : ConfigurableGroup { - Configurable verboselevel{"verbose-level", 0, "Verbose level"}; - Configurable refresh{"print-refresh", 0, "Freqency of print event information."}; - Configurable refresh_index{"print-refresh-index", 0, "Freqency of print event information index."}; + Configurable verboselevel{"verboselevel", 0, "Verbose level"}; + Configurable refresh{"refresh", 0, "Freqency of print event information."}; + Configurable refreshIndex{"refreshIndex", 0, "Freqency of print event information index."}; } verbose; - Configurable dautherPos{"dauther-type-pos", 3, "Particle type of the positive dauther according to ReconstructionDataFormats/PID.h (Default = Kaon)"}; - Configurable dautherNeg{"dauther-type-neg", 3, "Particle type of the negative dauther according to ReconstructionDataFormats/PID.h (Default = Kaon)"}; - Configurable motherPDG{"mother-pdg", 333, "PDG code of mother particle."}; - Configurable dautherPosPDG{"dauther-pdg-pos", 321, "PDG code of positive dauther particle."}; - Configurable dautherNegPDG{"dauther-pdg-neg", 321, "PDG code of negative dauther particle."}; + Configurable dautherPos{"dautherPos", 3, "Particle type of the positive dauther according to ReconstructionDataFormats/PID.h (Default = Kaon)"}; + Configurable dautherNeg{"dautherNeg", 3, "Particle type of the negative dauther according to ReconstructionDataFormats/PID.h (Default = Kaon)"}; + Configurable motherPDG{"motherPDG", 333, "PDG code of mother particle."}; + Configurable dautherPosPDG{"dautherPosPDG", 321, "PDG code of positive dauther particle."}; + Configurable dautherNegPDG{"dautherNegPDG", 321, "PDG code of negative dauther particle."}; struct : ConfigurableGroup { - Configurable tpcnSigmaPos{"tpc-ns-pos", 3.0f, "TPC NSigma cut of the positive particle."}; - Configurable tpcnSigmaNeg{"tpc-ns-neg", 3.0f, "TPC NSigma cut of the negative particle."}; - Configurable vZ{"zvertex-cut", 10.0f, "Z vertex range."}; - Configurable y{"rapidity-cut", 0.5, "Rapidity cut (maximum)."}; - Configurable etatrack{"eta-track-cut", 0.8, "Eta cut for track."}; - Configurable etapair{"eta-pair-cut", 0.8, "Eta cut for pair."}; - Configurable pt{"pt-cut", 0.15f, "Cut: Minimal value of tracks pt."}; - Configurable dcaXY{"dcaXY-cut", 1.0f, "Cut: Maximal value of tracks DCA XY."}; - Configurable dcaZ{"dcaZ-cut", 1.0f, "Cut: Maximal value of tracks DCA Z."}; - Configurable tpcNClsFound{"tpc-ncl-found-cut", 70, "Cut: Minimal value of found TPC clasters"}; + Configurable tpcnSigmaPos{"tpcnSigmaPos", 3.0f, "TPC NSigma cut of the positive particle."}; + Configurable tpcnSigmaNeg{"tpcnSigmaNeg", 3.0f, "TPC NSigma cut of the negative particle."}; + Configurable vZ{"vZ", 10.0f, "Z vertex range."}; + Configurable y{"y", 0.5, "Rapidity cut (maximum)."}; + Configurable etatrack{"etatrack", 0.8, "Eta cut for track."}; + Configurable etapair{"etapair", 0.8, "Eta cut for pair."}; + Configurable pt{"pt", 0.15f, "Cut: Minimal value of tracks pt."}; + Configurable dcaXY{"dcaXY", 1.0f, "Cut: Maximal value of tracks DCA XY."}; + Configurable dcaZ{"dcaZ", 1.0f, "Cut: Maximal value of tracks DCA Z."}; + Configurable tpcNClsFound{"tpcNClsFound", 70, "Cut: Minimal value of found TPC clasters"}; } cut; - Configurable> sparseAxes{"sparse-axes", std::vector{o2::analysis::rsn::PairAxis::names}, "Axes."}; - Configurable> sysAxes{"systematics-axes", std::vector{o2::analysis::rsn::SystematicsAxis::names}, "Axes."}; + Configurable> sparseAxes{"sparseAxes", std::vector{o2::analysis::rsn::pair_axis::names}, "Axes."}; + Configurable> sysAxes{"sysAxes", std::vector{o2::analysis::rsn::systematic_axis::names}, "Axes."}; - ConfigurableAxis invaxis{"inv-axis", {130, 0.97, 1.1}, "Invariant mass axis binning."}; - ConfigurableAxis ptaxis{"pt-axis", {20, 0., 20.}, "Pt axis binning."}; - ConfigurableAxis vzaxis{"vz-axis", {40, -20., 20.}, "Z vertex position axis binning."}; - ConfigurableAxis multiplicityaxis{"multiplicity-axis", {50, 0., 5000.}, "Multiplicity axis binning."}; - ConfigurableAxis centralityaxis{"centrality-axis", {20, 0., 100.}, "Centrality axis binning."}; - ConfigurableAxis etaaxis{"eta-axis", {16., -1.0 * static_cast(cut.etatrack), static_cast(cut.etatrack)}, "Pseudorapidity axis binning."}; - ConfigurableAxis rapidityaxis{"rapidity-axis", {10., -1.0 * static_cast(cut.y), static_cast(cut.y)}, "Rapidity axis binning."}; - ConfigurableAxis nsigmaaxisPos{"nsigma-pos-axis", {1, 0., static_cast(cut.tpcnSigmaPos)}, "NSigma of positive particle axis binning in THnSparse."}; - ConfigurableAxis nsigmaaxisNeg{"nsigma-neg-axis", {1, 0., static_cast(cut.tpcnSigmaNeg)}, "NSigma of negative particle axis binning in THnSparse."}; + ConfigurableAxis invaxis{"invaxis", {130, 0.97, 1.1}, "Invariant mass axis binning."}; + ConfigurableAxis ptaxis{"ptaxis", {20, 0., 20.}, "Pt axis binning."}; + ConfigurableAxis vzaxis{"vzaxis", {40, -20., 20.}, "Z vertex position axis binning."}; + ConfigurableAxis multiplicityaxis{"multiplicityaxis", {50, 0., 5000.}, "Multiplicity axis binning."}; + ConfigurableAxis centralityaxis{"centralityaxis", {20, 0., 100.}, "Centrality axis binning."}; + ConfigurableAxis etaaxis{"etaaxis", {16., -1.0 * static_cast(cut.etatrack), static_cast(cut.etatrack)}, "Pseudorapidity axis binning."}; + ConfigurableAxis rapidityaxis{"rapidityaxis", {10., -1.0 * static_cast(cut.y), static_cast(cut.y)}, "Rapidity axis binning."}; + ConfigurableAxis nsigmaaxisPos{"nsigmaaxisPos", {1, 0., static_cast(cut.tpcnSigmaPos)}, "NSigma of positive particle axis binning in THnSparse."}; + ConfigurableAxis nsigmaaxisNeg{"nsigmaaxisNeg", {1, 0., static_cast(cut.tpcnSigmaNeg)}, "NSigma of negative particle axis binning in THnSparse."}; // mixing - using BinningType = ColumnBinningPolicy>; - Configurable numberofMixedEvents{"number-of-mixed-events", 5, "Number of events that should be mixed."}; - ConfigurableAxis axisVertexMixing{"vertex-axis-mixing", {5, -10, 10}, "Z vertex axis for bin"}; - ConfigurableAxis axisMultiplicityMixing{"multiplicity-axis-mixing", {5, 0, 5000}, "TPC multiplicity for bin"}; + using BinningTypeVzMu = ColumnBinningPolicy>; + using BinningTypeVzCe = ColumnBinningPolicy; + Configurable numberofMixedEvents{"numberofMixedEvents", 5, "Number of events that should be mixed."}; + ConfigurableAxis axisVertexMixing{"axisVertexMixing", {5, -10, 10}, "Z vertex axis binning for mixing"}; + ConfigurableAxis axisMultiplicityMixing{"axisMultiplicityMixing", {5, 0, 5000}, "TPC multiplicity for bin"}; + ConfigurableAxis axisCentralityMixing{"axisCentralityMixing", {10, 0, 100}, "Multiplicity percentil binning for mixing"}; // defined in DataFormats/Reconstruction/include/ReconstructionDataFormats/PID.h float massPos = o2::track::PID::getMass(dautherPos); float massNeg = o2::track::PID::getMass(dautherNeg); // Axes specifications - AxisSpec posZaxis = {400, -20., 20., "V_z (cm)"}; + AxisSpec posZaxis = {400, -20., 20., "V_{z} (cm)"}; AxisSpec dcaXYaxis = {120, -3.0, 3.0, "DCA_{xy} (cm)"}; AxisSpec dcaZaxis = {120, -3.0, 3.0, "DCA_{z} (cm)"}; + AxisSpec etaQAaxis = {1000, -1.0, 1.0, "#eta"}; + AxisSpec tpcNClsFoundQAaxis = {110, 50., 160., "tpcNClsFound"}; HistogramRegistry registry{"registry"}; o2::analysis::rsn::Output* rsnOutput = nullptr; @@ -105,12 +112,15 @@ struct phianalysisTHnSparse { double* pointPair = nullptr; double* pointSys = nullptr; TLorentzVector d1, d2, mother; - bool QA = false; + bool produceQA, dataQA, MCTruthQA, t1, t2 = false; + int id; float etapair = 0.8; float tpcnSigmaPos = 3.0f; float tpcnSigmaNeg = 3.0f; int tpcNClsFound = 70; + rsn::MixingType mixingType = rsn::MixingType::none; + Filter triggerFilter = (o2::aod::evsel::sel8 == true); Filter vtxFilter = (nabs(o2::aod::collision::posZ) < static_cast(cut.vZ)); @@ -125,6 +135,11 @@ struct phianalysisTHnSparse { using EventCandidatesMC = soa::Filtered>; using TrackCandidatesMC = soa::Filtered>; + using EventCandidatesMCGen = soa::Join; + + using LabeledTracks = soa::Join; + Preslice perCollision = aod::track::collisionId; + Partition positive = (aod::track::signed1Pt > 0.0f) && (nabs(o2::aod::pidtpc::tpcNSigmaKa) < std::abs(static_cast(cut.tpcnSigmaPos))); Partition negative = (aod::track::signed1Pt < 0.0f) && (nabs(o2::aod::pidtpc::tpcNSigmaKa) < std::abs(static_cast(cut.tpcnSigmaNeg))); @@ -148,14 +163,15 @@ struct phianalysisTHnSparse { AxisSpec vzmAxis = {vzaxis, "V_{z} (cm)", "vzm"}; // Systematics axes - std::vector tpcNClsFound_bins = {65., 66., 67., 68., 69., 70., 71., 72., 73.}; - AxisSpec tpcNClsFoundAxis = {tpcNClsFound_bins, "TPC NCl", "ncl"}; + std::vector tpcNClsFoundBins = {65., 66., 67., 68., 69., 70., 71., 72., 73.}; + AxisSpec tpcNClsFoundAxis = {tpcNClsFoundBins, "TPC NCl", "ncl"}; // All axes has to have same order as defined enum o2::analysis::rsn::PairAxisType (name from AxisSpec is taken to compare in o2::analysis::rsn::Output::init()) std::vector allAxes = {invAxis, ptAxis, muAxis, ceAxis, nsAxisPos, nsAxisNeg, etaAxis, yAxis, vzAxis, mumAxis, cemAxis, vzmAxis}; - std::vector allAxes_sys = {tpcNClsFoundAxis}; + std::vector allAxesSys = {tpcNClsFoundAxis}; - QA = static_cast(produce.QA); + produceQA = static_cast(produce.produceQA); + mixingType = rsn::mixingTypeName(static_cast(produce.eventMixing)); etapair = static_cast(cut.etapair); tpcnSigmaPos = static_cast(cut.tpcnSigmaPos); tpcnSigmaNeg = static_cast(cut.tpcnSigmaNeg); @@ -164,35 +180,157 @@ struct phianalysisTHnSparse { pointPair = new double[static_cast(o2::analysis::rsn::PairAxisType::unknown)]; pointSys = new double[static_cast(o2::analysis::rsn::SystematicsAxisType::unknown)]; rsnOutput = new o2::analysis::rsn::OutputSparse(); - rsnOutput->init(sparseAxes, allAxes, sysAxes, allAxes_sys, static_cast(produce.True), static_cast(produce.eventMixing), static_cast(produce.Likesign), ®istry); + rsnOutput->init(sparseAxes, allAxes, sysAxes, allAxesSys, static_cast(produce.produceTrue), mixingType, static_cast(produce.produceLikesign), ®istry); - if (QA) { + if (produceQA) { // Event QA - registry.add("QAEvent/hVtxZ", "", kTH1F, {posZaxis}); - registry.add("QAEvent/hCent", "", kTH1F, {{20, 0., 100.}}); - registry.add("QAEvent/hMult", "", kTH1F, {{50, 0., 10000.}}); - registry.add("QAEvent/s4Size", "", kTHnSparseF, {{30, 0., 30.}, {30, 0., 30.}, muAxis, vzAxis}); - registry.add("QAEvent/s2Mult_Vz", "", kTHnSparseF, {axisMultiplicityMixing, axisVertexMixing}); - // Track QA - registry.add("QATrack/unlikepm/beforeSelection/hTrack1pt", "", kTH1F, {ptAxis}); - registry.add("QATrack/unlikepm/beforeSelection/hTrackDCAxy", "", kTH1F, {dcaXYaxis}); - registry.add("QATrack/unlikepm/beforeSelection/hTrackDCAz", "", kTH1F, {dcaZaxis}); - registry.add("QATrack/unlikepm/beforeSelection/hTrack1eta", "", kTH1F, {{100, -1.0, 1.0}}); - registry.add("QATrack/unlikepm/beforeSelection/hTrack1tpcNClsFound", "", kTH1F, {{110, 50., 160.}}); - - registry.add("QATrack/unlikepm/afterSelection/hTrack1pt", "", kTH1F, {ptAxis}); - registry.add("QATrack/unlikepm/afterSelection/hTrackDCAxy", "", kTH1F, {dcaXYaxis}); - registry.add("QATrack/unlikepm/afterSelection/hTrackDCAz", "", kTH1F, {dcaZaxis}); - registry.add("QATrack/unlikepm/afterSelection/hTrack1eta", "", kTH1F, {{100, -1.0, 1.0}}); - registry.add("QATrack/unlikepm/afterSelection/hTrack1tpcNClsFound", "", kTH1F, {{110, 50., 160.}}); - - registry.add("QATrack/unlikepm/TPCPID/h2TracknSigma", "", kTH2F, {{120, -6, 6}, {120, -6, 6}}); + registry.add("QAEvent/hSelection", "Event selection statistics", kTH1F, {{1, 0.0f, 1.0f}}); + auto hEvent = registry.get(HIST("QAEvent/hSelection")); + hEvent->GetXaxis()->SetBinLabel(1, "Full event statistics"); + hEvent->SetMinimum(0.1); - registry.add("QAMC/hInvMassTrueFalse", "", kTH1F, {invAxis}); + registry.add("QAEvent/hVtxZ", "Vertex position along the z-axis", kTH1F, {posZaxis}); + registry.add("QAEvent/hCent", "Distribution of multiplicity percentile", kTH1F, {{100, 0., 100.}}); + registry.add("QAEvent/hMult", "Multiplicity (amplitude of non-zero channels in the FV0A + FV0C) ", kTH1F, {{300, 0., 30000.}}); + registry.add("QAEvent/h2Size", "Number of positive vs. negative Kaons per collision", kTH2F, {{30, 0., 30.}, {30, 0., 30.}}); + // Track QA + registry.add("QATrack/hSelection", "Tracks combinations statistics", kTH1F, {{11, 0.0f, 11.0f}}); + auto hTrack = registry.get(HIST("QATrack/hSelection")); + hTrack->GetXaxis()->SetBinLabel(1, "all K^{+} K^{-} combinations"); + hTrack->GetXaxis()->SetBinLabel(2, "all K^{+}"); + hTrack->GetXaxis()->SetBinLabel(3, "all K^{-}"); + hTrack->GetXaxis()->SetBinLabel(4, "K^{+} tpcNClsFound"); + hTrack->GetXaxis()->SetBinLabel(5, "K^{-} tpcNClsFound"); + hTrack->GetXaxis()->SetBinLabel(6, "K^{+} isPrimaryTrack"); + hTrack->GetXaxis()->SetBinLabel(7, "K^{-} isPrimaryTrack"); + hTrack->GetXaxis()->SetBinLabel(8, "K^{+} isPVContributor"); + hTrack->GetXaxis()->SetBinLabel(9, "K^{-} isPVContributor"); + hTrack->GetXaxis()->SetBinLabel(10, "selected combinations"); + hTrack->GetXaxis()->SetBinLabel(11, "selected pairs (eta cut)"); + hTrack->SetMinimum(0.1); + + // Track1 + registry.add("QATrack/bs/hTrack1pt", "K^{+} p_{T} before selection", kTH1F, {ptAxis}); + registry.add("QATrack/bs/hTrack1DCAxy", "K^{+} DCA_{xy} before selection", kTH1F, {dcaXYaxis}); + registry.add("QATrack/bs/hTrack1DCAz", "K^{+} DCA_{z} before selection", kTH1F, {dcaZaxis}); + registry.add("QATrack/bs/hTrack1eta", "K^{+} #eta before selection", kTH1F, {{etaQAaxis}}); + registry.add("QATrack/bs/hTrack1tpcNClsFound", "K^{+} tpcNClsFound before selection", kTH1F, {{tpcNClsFoundQAaxis}}); + + registry.add("QATrack/as/hTrack1pt", "K^{+} p_{T} after selection", kTH1F, {ptAxis}); + registry.add("QATrack/as/hTrack1DCAxy", "K^{+} DCA_{xy} after selection", kTH1F, {dcaXYaxis}); + registry.add("QATrack/as/hTrack1DCAz", "K^{+} DCA_{z} after selection", kTH1F, {dcaZaxis}); + registry.add("QATrack/as/hTrack1eta", "K^{+} #eta after selection", kTH1F, {{etaQAaxis}}); + registry.add("QATrack/as/hTrack1tpcNClsFound", "K^{+} tpcNClsFound after selection", kTH1F, {{tpcNClsFoundQAaxis}}); + + // Track2 + registry.add("QATrack/bs/hTrack2pt", "K^{-} p_{T} before selection", kTH1F, {ptAxis}); + registry.add("QATrack/bs/hTrack2DCAxy", "K^{-} DCA_{xy} before selection", kTH1F, {dcaXYaxis}); + registry.add("QATrack/bs/hTrack2DCAz", "K^{-} DCA_{z} before selection", kTH1F, {dcaZaxis}); + registry.add("QATrack/bs/hTrack2eta", "K^{-} #eta before selection", kTH1F, {{etaQAaxis}}); + registry.add("QATrack/bs/hTrack2tpcNClsFound", "K^{-} tpcNClsFound before selection", kTH1F, {{tpcNClsFoundQAaxis}}); + + registry.add("QATrack/as/hTrack2pt", "K^{-} p_{T} after selection", kTH1F, {ptAxis}); + registry.add("QATrack/as/hTrack2DCAxy", "K^{-} DCA_{xy} after selection", kTH1F, {dcaXYaxis}); + registry.add("QATrack/as/hTrack2DCAz", "K^{-} DCA_{z} after selection", kTH1F, {dcaZaxis}); + registry.add("QATrack/as/hTrack2eta", "K^{-} #eta after selection", kTH1F, {{etaQAaxis}}); + registry.add("QATrack/as/hTrack2tpcNClsFound", "K^{-} tpcNClsFound after selection", kTH1F, {{tpcNClsFoundQAaxis}}); + + // TPC PID + registry.add("QATrack/TPCPID/h2TracknSigma", "", kTH2F, {{120, -6, 6}, {120, -6, 6}}); + auto h2TracknSigma = registry.get(HIST("QATrack/TPCPID/h2TracknSigma")); + h2TracknSigma->GetXaxis()->SetTitle("n#sigma_{TPC} K^{+}"); + h2TracknSigma->GetYaxis()->SetTitle("n#sigma_{TPC} K^{-}"); + + registry.add("QATrack/TPCPID/h2nTrack1SigmaPt", "", kTH2F, {{100, 0, 10}, {120, -6, 6}}); + auto h2nTrack1SigmaPt = registry.get(HIST("QATrack/TPCPID/h2nTrack1SigmaPt")); + h2nTrack1SigmaPt->GetXaxis()->SetTitle("p_{T} (GeV/c)"); + h2nTrack1SigmaPt->GetYaxis()->SetTitle("n#sigma_{TPC} K^{+}"); + + registry.add("QATrack/TPCPID/h2nTrack2SigmaPt", "", kTH2F, {{100, 0, 10}, {120, -6, 6}}); + auto h2nTrack2SigmaPt = registry.get(HIST("QATrack/TPCPID/h2nTrack2SigmaPt")); + h2nTrack2SigmaPt->GetXaxis()->SetTitle("p_{T} (GeV/c)"); + h2nTrack2SigmaPt->GetYaxis()->SetTitle("n#sigma_{TPC} K^{-}"); + + // MC Truth + if (static_cast(produce.produceTrue)) { + registry.add("QAMC/Truth/hMCEvent", "MC Truth Event statistics", kTH1F, {{1, 0.0f, 1.0f}}); + auto hMCEventTruth = registry.get(HIST("QAMC/Truth/hMCEvent")); + hMCEventTruth->GetXaxis()->SetBinLabel(1, "Full MC Truth event statistics"); + hMCEventTruth->SetMinimum(0.1); + + registry.add("QAMC/Truth/hMCTrack", "MC Truth Track statistics", kTH1F, {{17, 0.0f, 17.0f}}); + auto hMCTrackTruth = registry.get(HIST("QAMC/Truth/hMCTrack")); + hMCTrackTruth->GetXaxis()->SetBinLabel(1, "all K^{+} K^{-} combinations"); + hMCTrackTruth->GetXaxis()->SetBinLabel(2, "all K^{+}"); + hMCTrackTruth->GetXaxis()->SetBinLabel(3, "all K^{-}"); + hMCTrackTruth->GetXaxis()->SetBinLabel(4, "K^{+} tpcNClsFound"); + hMCTrackTruth->GetXaxis()->SetBinLabel(5, "K^{-} tpcNClsFound"); + hMCTrackTruth->GetXaxis()->SetBinLabel(6, "K^{+} isPrimaryTrack"); + hMCTrackTruth->GetXaxis()->SetBinLabel(7, "K^{-} isPrimaryTrack"); + hMCTrackTruth->GetXaxis()->SetBinLabel(8, "K^{+} isPVContributor"); + hMCTrackTruth->GetXaxis()->SetBinLabel(9, "K^{-} isPVContributor"); + hMCTrackTruth->GetXaxis()->SetBinLabel(10, "selected combinations"); + hMCTrackTruth->GetXaxis()->SetBinLabel(11, "MCtrack PDG = 321"); + hMCTrackTruth->GetXaxis()->SetBinLabel(12, "all mothers"); + hMCTrackTruth->GetXaxis()->SetBinLabel(13, "equal mother PDGs"); + hMCTrackTruth->GetXaxis()->SetBinLabel(14, "equal mother IDs"); + hMCTrackTruth->GetXaxis()->SetBinLabel(15, "mother rapidity cut"); + hMCTrackTruth->GetXaxis()->SetBinLabel(16, "mother PDG = 333"); + hMCTrackTruth->GetXaxis()->SetBinLabel(17, "selected pairs (eta cut)"); + hMCTrackTruth->SetMinimum(0.1); + + registry.add("QAMC/hInvMassTrueFalse", "", kTH1F, {invAxis}); // not written events in True distribution due to repetition of mothers?? + + // MC Gen + registry.add("QAMC/Gen/hMCEvent", "MC Gen Event statistics", kTH1F, {{3, 0.0f, 3.0f}}); + auto hMCEventGen = registry.get(HIST("QAMC/Gen/hMCEvent")); + hMCEventGen->GetXaxis()->SetBinLabel(1, "Full McCollision statistics"); + hMCEventGen->GetXaxis()->SetBinLabel(2, "McCollision V_{z} cut"); + hMCEventGen->GetXaxis()->SetBinLabel(3, "collisions"); + hMCEventGen->SetMinimum(0.1); + + registry.add("QAMC/Gen/hMCTrack", "MC Gen Track statistics", kTH1D, {{7, 0.0f, 7.0f}}); + auto hMCTrackGen = registry.get(HIST("QAMC/Gen/hMCTrack")); + hMCTrackGen->GetXaxis()->SetBinLabel(1, "all mcParticles"); + hMCTrackGen->GetXaxis()->SetBinLabel(2, "rapidity cut"); + hMCTrackGen->GetXaxis()->SetBinLabel(3, "particle PDG = 333"); + hMCTrackGen->GetXaxis()->SetBinLabel(4, "has 2 dauthers"); + hMCTrackGen->GetXaxis()->SetBinLabel(5, "all dauthers"); + hMCTrackGen->GetXaxis()->SetBinLabel(6, "isPhysicalPrimary"); + hMCTrackGen->GetXaxis()->SetBinLabel(7, "selected pairs"); + hMCTrackGen->SetMinimum(0.1); + } // Mixing QA - registry.add("QAMixing/s4Mult_Vz", "", kTHnSparseF, {axisMultiplicityMixing, axisMultiplicityMixing, axisVertexMixing, axisVertexMixing}); - registry.add("QAMixing/s2Mult_Vz", "", kTHnSparseF, {axisMultiplicityMixing, axisVertexMixing}); + if (mixingType != rsn::MixingType::none) { + registry.add("QAMixing/hSelection", "Event mixing selection statistics", kTH1F, {{1, 0.0f, 1.0f}}); + auto hEM = registry.get(HIST("QAMixing/hSelection")); + hEM->GetXaxis()->SetBinLabel(1, "Full event mixing statistics"); + hEM->SetMinimum(0.1); + + registry.add("QAMixing/hTrackSelection", "Event mixing tracks combinations statistics", kTH1F, {{4, 0.0f, 4.0f}}); + auto hEMTrack = registry.get(HIST("QAMixing/hTrackSelection")); + hEMTrack->GetXaxis()->SetBinLabel(1, "all K^{+} K^{-} combinations"); + hEMTrack->GetXaxis()->SetBinLabel(2, "all K^{+}"); + hEMTrack->GetXaxis()->SetBinLabel(3, "all K^{-}"); + hEMTrack->GetXaxis()->SetBinLabel(4, "selected pairs (eta cut)"); + hEMTrack->SetMinimum(0.1); + + registry.add("QAMixing/h2mu1_mu2", "Event Mixing Multiplicity", kTH2F, {axisMultiplicityMixing, axisMultiplicityMixing}); + auto h2EMmu = registry.get(HIST("QAMixing/h2mu1_mu2")); + h2EMmu->GetXaxis()->SetTitle("1.Event multiplicity"); + h2EMmu->GetYaxis()->SetTitle("2.Event multiplicity"); + + registry.add("QAMixing/h2ce1_ce2", "Event Mixing Centrality", kTH2F, {axisCentralityMixing, axisCentralityMixing}); + auto h2EMce = registry.get(HIST("QAMixing/h2ce1_ce2")); + h2EMce->GetXaxis()->SetTitle("1.Event centrality"); + h2EMce->GetYaxis()->SetTitle("2.Event centrality"); + + registry.add("QAMixing/h2vz1_vz2", "Event Mixing Vertex z", kTH2F, {axisVertexMixing, axisVertexMixing}); + auto hEMTvz = registry.get(HIST("QAMixing/h2vz1_vz2")); + hEMTvz->GetXaxis()->SetTitle("1.Event V_{z}"); + hEMTvz->GetYaxis()->SetTitle("2.Event V_{z}"); + } } pointSys[static_cast(o2::analysis::rsn::SystematicsAxisType::ncl)] = tpcNClsFound; @@ -202,15 +340,71 @@ struct phianalysisTHnSparse { template bool selectedTrack(const T& track) { + if (produceQA) { + if (t1) { + if (dataQA) + registry.fill(HIST("QATrack/hSelection"), 1.5); + if (MCTruthQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 1.5); + } + if (t2) { + if (dataQA) + registry.fill(HIST("QATrack/hSelection"), 2.5); + if (MCTruthQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 2.5); + } + } + if (track.tpcNClsFound() < tpcNClsFound) return false; + if (produceQA) { + if (t1) { + if (dataQA) + registry.fill(HIST("QATrack/hSelection"), 3.5); + if (MCTruthQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 3.5); + } + if (t2) { + if (dataQA) + registry.fill(HIST("QATrack/hSelection"), 4.5); + if (MCTruthQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 4.5); + } + } if (!track.isPrimaryTrack()) return false; + if (produceQA) { + if (t1) { + if (dataQA) + registry.fill(HIST("QATrack/hSelection"), 5.5); + if (MCTruthQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 5.5); + } + if (t2) { + if (dataQA) + registry.fill(HIST("QATrack/hSelection"), 6.5); + if (MCTruthQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 6.5); + } + } if (!track.isPVContributor()) return false; + if (produceQA) { + if (t1) { + if (dataQA) + registry.fill(HIST("QATrack/hSelection"), 7.5); + if (MCTruthQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 7.5); + } + if (t2) { + if (dataQA) + registry.fill(HIST("QATrack/hSelection"), 8.5); + if (MCTruthQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 8.5); + } + } return true; } - template bool selectedPair(TLorentzVector& mother, const T& track1, const T& track2) { @@ -222,21 +416,20 @@ struct phianalysisTHnSparse { return false; return true; } - template - float GetMultiplicity(const T& collision) + float getMultiplicity(const T& collision) { float multiplicity = collision.multFT0C() + collision.multFT0A(); return multiplicity; } template - float GetCentrality(const T& collision) + float getCentrality(const T& collision) { float centrality = collision.centFT0M(); return centrality; } - double* FillPointPair(double im, double pt, double mu, double ce, double ns1, double ns2, double eta, double y, double vz, double mum, double cem, double vzm) + double* fillPointPair(double im, double pt, double mu, double ce, double ns1, double ns2, double eta, double y, double vz, double mum, double cem, double vzm) { pointPair[static_cast(o2::analysis::rsn::PairAxisType::im)] = im; pointPair[static_cast(o2::analysis::rsn::PairAxisType::pt)] = pt; @@ -259,55 +452,76 @@ struct phianalysisTHnSparse { auto posDauthers = positive->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); auto negDauthers = negative->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - if (QA) { - registry.fill(HIST("QAEvent/s4Size"), posDauthers.size(), negDauthers.size(), GetMultiplicity(collision), collision.posZ()); - registry.fill(HIST("QAEvent/s2Mult_Vz"), GetMultiplicity(collision), collision.posZ()); + if (produceQA) { + registry.fill(HIST("QAEvent/hSelection"), 0.5); + registry.fill(HIST("QAEvent/h2Size"), posDauthers.size(), negDauthers.size()); + registry.fill(HIST("QAEvent/hVtxZ"), collision.posZ()); + registry.fill(HIST("QAEvent/hMult"), getMultiplicity(collision)); + registry.fill(HIST("QAEvent/hCent"), getCentrality(collision)); } - if (static_cast(verbose.verboselevel) > 0 && static_cast(verbose.refresh) > 0 && collision.globalIndex() % static_cast(verbose.refresh) == static_cast(verbose.refresh_index)) - LOGF(info, "pos=%lld neg=%lld, Z vertex position: %f [cm], %d, mult:%f.0", posDauthers.size(), negDauthers.size(), collision.posZ(), - collision.globalIndex(), GetMultiplicity(collision)); + if (static_cast(verbose.verboselevel) > 0 && static_cast(verbose.refresh) > 0 && collision.globalIndex() % static_cast(verbose.refresh) == static_cast(verbose.refreshIndex)) + LOGF(info, "%d pos=%lld neg=%lld, Z vertex position: %f [cm]", collision.globalIndex(), posDauthers.size(), negDauthers.size(), collision.posZ()); - if (QA) { - registry.fill(HIST("QAEvent/hVtxZ"), collision.posZ()); - registry.fill(HIST("QAEvent/hMult"), GetMultiplicity(collision)); - registry.fill(HIST("QAEvent/hCent"), GetCentrality(collision)); - } + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthers, negDauthers))) { + if (produceQA) { + registry.fill(HIST("QATrack/hSelection"), 0.5); - for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthers, negDauthers))) { - if (QA) { - registry.fill(HIST("QATrack/unlikepm/beforeSelection/hTrack1pt"), track1.pt()); - registry.fill(HIST("QATrack/unlikepm/beforeSelection/hTrackDCAxy"), track1.dcaXY()); - registry.fill(HIST("QATrack/unlikepm/beforeSelection/hTrackDCAz"), track1.dcaZ()); - registry.fill(HIST("QATrack/unlikepm/beforeSelection/hTrack1eta"), track1.eta()); - registry.fill(HIST("QATrack/unlikepm/beforeSelection/hTrack1tpcNClsFound"), track1.tpcNClsFound()); + registry.fill(HIST("QATrack/bs/hTrack1pt"), track1.pt()); + registry.fill(HIST("QATrack/bs/hTrack1DCAxy"), track1.dcaXY()); + registry.fill(HIST("QATrack/bs/hTrack1DCAz"), track1.dcaZ()); + registry.fill(HIST("QATrack/bs/hTrack1eta"), track1.eta()); + registry.fill(HIST("QATrack/bs/hTrack1tpcNClsFound"), track1.tpcNClsFound()); + + registry.fill(HIST("QATrack/bs/hTrack2pt"), track2.pt()); + registry.fill(HIST("QATrack/bs/hTrack2DCAxy"), track2.dcaXY()); + registry.fill(HIST("QATrack/bs/hTrack2DCAz"), track2.dcaZ()); + registry.fill(HIST("QATrack/bs/hTrack2eta"), track2.eta()); + registry.fill(HIST("QATrack/bs/hTrack2tpcNClsFound"), track2.tpcNClsFound()); } + dataQA = true; + t1 = true; if (!selectedTrack(track1)) continue; - + t1 = false; + t2 = true; if (!selectedTrack(track2)) continue; - - if (QA) { - registry.fill(HIST("QATrack/unlikepm/afterSelection/hTrack1pt"), track1.pt()); - registry.fill(HIST("QATrack/unlikepm/afterSelection/hTrackDCAxy"), track1.dcaXY()); - registry.fill(HIST("QATrack/unlikepm/afterSelection/hTrackDCAz"), track1.dcaZ()); - registry.fill(HIST("QATrack/unlikepm/afterSelection/hTrack1eta"), track1.eta()); - registry.fill(HIST("QATrack/unlikepm/afterSelection/hTrack1tpcNClsFound"), track1.tpcNClsFound()); + t2 = false; + dataQA = false; + + if (produceQA) { + registry.fill(HIST("QATrack/hSelection"), 9.5); + + registry.fill(HIST("QATrack/as/hTrack1pt"), track1.pt()); + registry.fill(HIST("QATrack/as/hTrack1DCAxy"), track1.dcaXY()); + registry.fill(HIST("QATrack/as/hTrack1DCAz"), track1.dcaZ()); + registry.fill(HIST("QATrack/as/hTrack1eta"), track1.eta()); + registry.fill(HIST("QATrack/as/hTrack1tpcNClsFound"), track1.tpcNClsFound()); + + registry.fill(HIST("QATrack/as/hTrack2pt"), track2.pt()); + registry.fill(HIST("QATrack/as/hTrack2DCAxy"), track2.dcaXY()); + registry.fill(HIST("QATrack/as/hTrack2DCAz"), track2.dcaZ()); + registry.fill(HIST("QATrack/as/hTrack2eta"), track2.eta()); + registry.fill(HIST("QATrack/as/hTrack2tpcNClsFound"), track2.tpcNClsFound()); } if (!selectedPair(mother, track1, track2)) continue; - if (QA) { - registry.fill(HIST("QATrack/unlikepm/TPCPID/h2TracknSigma"), track1.tpcNSigmaKa(), track2.tpcNSigmaKa()); + if (produceQA) { + registry.fill(HIST("QATrack/hSelection"), 10.5); + + registry.fill(HIST("QATrack/TPCPID/h2TracknSigma"), track1.tpcNSigmaKa(), track2.tpcNSigmaKa()); + registry.fill(HIST("QATrack/TPCPID/h2nTrack1SigmaPt"), track1.pt(), track1.tpcNSigmaKa()); + registry.fill(HIST("QATrack/TPCPID/h2nTrack2SigmaPt"), track2.pt(), track2.tpcNSigmaKa()); } - pointPair = FillPointPair(mother.Mag(), + pointPair = fillPointPair(mother.Mag(), mother.Pt(), - GetMultiplicity(collision), - GetCentrality(collision), + getMultiplicity(collision), + getCentrality(collision), (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), mother.Eta(), @@ -319,9 +533,9 @@ struct phianalysisTHnSparse { rsnOutput->fillUnlikepm(pointPair); } - if (static_cast(produce.Likesign)) { + if (static_cast(produce.produceLikesign)) { - for (auto& [track1, track2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(posDauthers, posDauthers))) { + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(posDauthers, posDauthers))) { if (!selectedTrack(track1)) continue; if (!selectedTrack(track2)) @@ -333,10 +547,10 @@ struct phianalysisTHnSparse { if (static_cast(verbose.verboselevel) > 1) LOGF(info, "Like-sign positive: d1=%ld , d2=%ld , mother=%f", track1.globalIndex(), track2.globalIndex(), mother.Mag()); - pointPair = FillPointPair(mother.Mag(), + pointPair = fillPointPair(mother.Mag(), mother.Pt(), - GetMultiplicity(collision), - GetCentrality(collision), + getMultiplicity(collision), + getCentrality(collision), (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), mother.Eta(), @@ -349,7 +563,7 @@ struct phianalysisTHnSparse { rsnOutput->fillLikepp(pointPair); } - for (auto& [track1, track2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(negDauthers, negDauthers))) { + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(negDauthers, negDauthers))) { if (!selectedTrack(track1)) continue; if (!selectedTrack(track2)) @@ -361,10 +575,10 @@ struct phianalysisTHnSparse { if (static_cast(verbose.verboselevel) > 1) LOGF(info, "Like-sign negative: d1=%ld , d2=%ld , mother=%f", track1.globalIndex(), track2.globalIndex(), mother.Mag()); - pointPair = FillPointPair(mother.Mag(), + pointPair = fillPointPair(mother.Mag(), mother.Pt(), - GetMultiplicity(collision), - GetCentrality(collision), + getMultiplicity(collision), + getCentrality(collision), (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), mother.Eta(), @@ -378,13 +592,15 @@ struct phianalysisTHnSparse { } } } - PROCESS_SWITCH(phianalysisTHnSparse, processData, "Process Event for Data", true); + PROCESS_SWITCH(PhianalysisTHnSparse, processData, "Process Event for Data", true); void processTrue(EventCandidatesMC::iterator const& collision, TrackCandidatesMC const& /*tracks*/, aod::McParticles const& /*mcParticles*/, aod::McCollisions const& /*mcCollisions*/) { - if (!static_cast(produce.True)) + if (!static_cast(produce.produceTrue)) return; + registry.fill(HIST("QAMC/Truth/hMCEvent"), 0.5); + auto posDauthersMC = positiveMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); auto negDauthersMC = negativeMC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); @@ -393,10 +609,8 @@ struct phianalysisTHnSparse { return; } - if (std::abs(collision.posZ()) > static_cast(cut.vZ)) - return; - - for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersMC, negDauthersMC))) { + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersMC, negDauthersMC))) { + registry.fill(HIST("QAMC/Truth/hMCTrack"), 0.5); if (!track1.has_mcParticle()) { LOGF(warning, "No MC particle for track, skip..."); @@ -408,11 +622,18 @@ struct phianalysisTHnSparse { continue; } + MCTruthQA = true; + t1 = true; if (!selectedTrack(track1)) continue; - + t1 = false; + t2 = true; if (!selectedTrack(track2)) continue; + t2 = false; + MCTruthQA = false; + + registry.fill(HIST("QAMC/Truth/hMCTrack"), 9.5); const auto mctrack1 = track1.mcParticle(); const auto mctrack2 = track2.mcParticle(); @@ -422,24 +643,34 @@ struct phianalysisTHnSparse { if (!(track1PDG == dautherPosPDG && track2PDG == dautherNegPDG)) { continue; } + if (produceQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 10.5); + n = 0; - for (auto& mothertrack1 : mctrack1.mothers_as()) { - for (auto& mothertrack2 : mctrack2.mothers_as()) { + for (const auto& mothertrack1 : mctrack1.mothers_as()) { + for (const auto& mothertrack2 : mctrack2.mothers_as()) { + if (produceQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 11.5); if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) continue; + if (produceQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 12.5); if (mothertrack1.globalIndex() != mothertrack2.globalIndex()) continue; + if (produceQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 13.5); if (std::abs(mothertrack1.y()) > static_cast(cut.y)) continue; - - if (std::abs(mothertrack2.y()) > static_cast(cut.y)) - continue; + if (produceQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 14.5); if (std::abs(mothertrack1.pdgCode()) != motherPDG) continue; + if (produceQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 15.5); if (static_cast(verbose.verboselevel) > 1) { LOGF(info, "True: %d, d1=%d (%ld), d2=%d (%ld), mother=%d (%ld)", n, mctrack1.pdgCode(), mctrack1.globalIndex(), mctrack2.pdgCode(), mctrack2.globalIndex(), mothertrack1.pdgCode(), mothertrack1.globalIndex()); @@ -448,17 +679,19 @@ struct phianalysisTHnSparse { if (!selectedPair(mother, mctrack1, mctrack2)) continue; + if (produceQA) + registry.fill(HIST("QAMC/Truth/hMCTrack"), 16.5); if (n > 0) { - if (QA) + if (produceQA) registry.fill(HIST("QAMC/hInvMassTrueFalse"), mother.Mag()); continue; } - pointPair = FillPointPair(mother.Mag(), + pointPair = fillPointPair(mother.Mag(), mother.Pt(), - GetMultiplicity(collision), - GetCentrality(collision), + getMultiplicity(collision), + getCentrality(collision), (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), mother.Eta(), @@ -474,140 +707,214 @@ struct phianalysisTHnSparse { } } } + PROCESS_SWITCH(PhianalysisTHnSparse, processTrue, "Process Event for MC reconstruction.", false); - PROCESS_SWITCH(phianalysisTHnSparse, processTrue, "Process Event for MC reconstruction.", false); - - int numberofEntries = 0; - - void processGen(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles) + void processGen(aod::McCollision const& mcCollision, soa::SmallGroups const& collisions, LabeledTracks const& /*particles*/, aod::McParticles const& mcParticles) { - - if (!static_cast(produce.True)) + registry.fill(HIST("QAMC/Gen/hMCEvent"), 0.5); + if (std::abs(mcCollision.posZ()) > static_cast(cut.vZ)) return; + registry.fill(HIST("QAMC/Gen/hMCEvent"), 1.5); - if (std::abs(mcCollision.posZ()) > static_cast(cut.vZ)) + if (collisions.size() == 0) return; - int nuberofPhi = 0; + for (const auto& collision : collisions) { + registry.fill(HIST("QAMC/Gen/hMCEvent"), 2.5); - for (auto& particle : mcParticles) { - if (std::abs(particle.y()) > static_cast(cut.y)) - continue; + if (!collision.has_mcCollision()) { + LOGF(warning, "No McCollision for this collision, skip..."); + return; + } - if (particle.pdgCode() == motherPDG) { - auto daughters = particle.daughters_as(); - if (daughters.size() != 2) + auto centralityGen = 0; + centralityGen = getCentrality(collision); + auto multiplicityGen = 0; + multiplicityGen = getMultiplicity(collision); + + for (const auto& particle : mcParticles) { + registry.fill(HIST("QAMC/Gen/hMCTrack"), 0.5); + + if (std::abs(particle.y()) > static_cast(cut.y)) continue; - auto daup = false; - auto daun = false; + registry.fill(HIST("QAMC/Gen/hMCTrack"), 1.5); - for (auto& dau : daughters) { - if (!dau.isPhysicalPrimary()) + if (particle.pdgCode() == motherPDG) { + registry.fill(HIST("QAMC/Gen/hMCTrack"), 2.5); + + auto daughters = particle.daughters_as(); + if (daughters.size() != 2) continue; - if (dau.pdgCode() == dautherPosPDG) { - daup = true; - d1.SetXYZM(dau.px(), dau.py(), dau.pz(), massPos); - } else if (dau.pdgCode() == -dautherNegPDG) { - daun = true; - d2.SetXYZM(dau.px(), dau.py(), dau.pz(), massNeg); - } - } - if (!daup && !daun) - continue; + registry.fill(HIST("QAMC/Gen/hMCTrack"), 3.5); - mother = d1 + d2; + auto daup = false; + auto daun = false; - pointPair = FillPointPair(mother.Mag(), - mother.Pt(), - 0, - 0, - std::abs(static_cast(cut.tpcnSigmaPos) / 2.0), - std::abs(static_cast(cut.tpcnSigmaNeg) / 2.0), - mother.Eta(), - mother.Rapidity(), - mcCollision.posZ(), - 0, - 0, - 0); + for (const auto& dau : daughters) { + registry.fill(HIST("QAMC/Gen/hMCTrack"), 4.5); - rsnOutput->fillUnlikegen(pointPair); + if (!dau.isPhysicalPrimary()) + continue; - nuberofPhi++; - numberofEntries++; + registry.fill(HIST("QAMC/Gen/hMCTrack"), 5.5); - if (static_cast(verbose.verboselevel) > 1) - LOGF(info, "Gen: %d, #Phi =%d, mother=%d (%ld), Inv.mass:%f, Pt= %f", numberofEntries, nuberofPhi, particle.pdgCode(), particle.globalIndex(), mother.Mag(), mother.Pt()); + if (dau.pdgCode() == dautherPosPDG) { + daup = true; + d1.SetXYZM(dau.px(), dau.py(), dau.pz(), massPos); + } else if (dau.pdgCode() == -dautherNegPDG) { + daun = true; + d2.SetXYZM(dau.px(), dau.py(), dau.pz(), massNeg); + } + } + if (!daup && !daun) + continue; + + registry.fill(HIST("QAMC/Gen/hMCTrack"), 6.5); + + mother = d1 + d2; + + pointPair = fillPointPair(mother.Mag(), + mother.Pt(), + multiplicityGen, + centralityGen, + std::abs(static_cast(cut.tpcnSigmaPos) / 2.0), + std::abs(static_cast(cut.tpcnSigmaNeg) / 2.0), + mother.Eta(), + mother.Rapidity(), + mcCollision.posZ(), + 0, + 0, + 0); + + rsnOutput->fillUnlikegen(pointPair); + } } } } - - PROCESS_SWITCH(phianalysisTHnSparse, processGen, "Process generated.", false); - - int id; + PROCESS_SWITCH(PhianalysisTHnSparse, processGen, "Process MC Mateched.", true); void processMixed(EventCandidates const& collisions, TrackCandidates const& tracks) { - if (!static_cast(produce.eventMixing)) + if (mixingType == rsn::MixingType::none) return; - BinningType binning{{axisVertexMixing, axisMultiplicityMixing}, true}; + auto tracksTuple = std::make_tuple(tracks); - SameKindPair pair{binning, numberofMixedEvents, -1, collisions, tracksTuple, &cache}; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + BinningTypeVzCe binningVzCe{{axisVertexMixing, axisCentralityMixing}, true}; + SameKindPair pairVzCe{binningVzCe, numberofMixedEvents, -1, collisions, tracksTuple, &cache}; - if (!c1.sel8()) { - continue; - } - if (!c2.sel8()) { - continue; - } - if (QA) { - if (!(id == c1.globalIndex())) { - registry.fill(HIST("QAMixing/s2Mult_Vz"), GetMultiplicity(c1), c1.posZ()); - id = c1.globalIndex(); + BinningTypeVzMu binningVzMu{{axisVertexMixing, axisMultiplicityMixing}, true}; + SameKindPair pairVzMu{binningVzMu, numberofMixedEvents, -1, collisions, tracksTuple, &cache}; + + if (mixingType == rsn::MixingType::ce) { + for (const auto& [c1, tracks1, c2, tracks2] : pairVzCe) { + if (produceQA) + registry.fill(HIST("QAMixing/hSelection"), 0.5); + + auto posDauthersc1 = positive->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); + auto posDauthersc2 = positive->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); + auto negDauthersc1 = negative->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); + auto negDauthersc2 = negative->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); + + if (produceQA) { + registry.fill(HIST("QAMixing/h2mu1_mu2"), getMultiplicity(c1), getMultiplicity(c2)); + registry.fill(HIST("QAMixing/h2ce1_ce2"), getCentrality(c1), getCentrality(c2)); + registry.fill(HIST("QAMixing/h2vz1_vz2"), c1.posZ(), c2.posZ()); } - } - auto posDauthersc1 = positive->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto posDauthersc2 = positive->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); - auto negDauthersc1 = negative->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); - auto negDauthersc2 = negative->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersc1, negDauthersc2))) { + if (produceQA) + registry.fill(HIST("QAMixing/hTrackSelection"), 0.5); + + if (!selectedTrack(track1)) + continue; + if (produceQA) + registry.fill(HIST("QAMixing/hTrackSelection"), 1.5); + if (!selectedTrack(track2)) + continue; + if (produceQA) + registry.fill(HIST("QAMixing/hTrackSelection"), 2.5); + + if (!selectedPair(mother, track1, track2)) + continue; + if (produceQA) + registry.fill(HIST("QAMixing/hTrackSelection"), 3.5); - if (QA) - registry.fill(HIST("QAMixing/s4Mult_Vz"), GetMultiplicity(c1), GetMultiplicity(c2), c1.posZ(), c2.posZ()); + pointPair = fillPointPair(mother.Mag(), + mother.Pt(), + getMultiplicity(c1), + getCentrality(c1), + (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), + (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), + mother.Eta(), + mother.Rapidity(), + c1.posZ(), + getMultiplicity(c2), + getCentrality(c2), + c2.posZ()); - for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersc1, negDauthersc2))) { + rsnOutput->fillMixingpm(pointPair); + } - if (!selectedTrack(track1)) + if (static_cast(produce.produceLikesign)) { - continue; - if (!selectedTrack(track2)) - continue; + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersc1, posDauthersc2))) { - if (!selectedPair(mother, track1, track2)) - continue; + if (!selectedTrack(track1)) - pointPair = FillPointPair(mother.Mag(), - mother.Pt(), - GetMultiplicity(c1), - GetCentrality(c1), - (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), - (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), - mother.Eta(), - mother.Rapidity(), - c1.posZ(), - GetMultiplicity(c2), - GetCentrality(c2), - c2.posZ()); + continue; + if (!selectedTrack(track2)) + continue; - rsnOutput->fillMixingpm(pointPair); - } + if (!selectedPair(mother, track1, track2)) + continue; - if (static_cast(produce.Likesign)) { + pointPair = fillPointPair(mother.Mag(), + mother.Pt(), + getMultiplicity(c1), + getCentrality(c1), + (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), + (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), + mother.Eta(), + mother.Rapidity(), + c1.posZ(), + getMultiplicity(c2), + getCentrality(c2), + c2.posZ()); + + rsnOutput->fillMixingpp(pointPair); + } + + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(negDauthersc1, negDauthersc2))) { + + if (!selectedTrack(track1)) + + continue; + if (!selectedTrack(track2)) + continue; + + if (!selectedPair(mother, track1, track2)) + continue; + pointPair = fillPointPair(mother.Mag(), + mother.Pt(), + getMultiplicity(c1), + getCentrality(c1), + (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), + (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), + mother.Eta(), + mother.Rapidity(), + c1.posZ(), + getMultiplicity(c2), + getCentrality(c2), + c2.posZ()); + + rsnOutput->fillMixingmm(pointPair); + } + } - for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersc1, posDauthersc2))) { + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersc2, negDauthersc1))) { if (!selectedTrack(track1)) @@ -618,23 +925,130 @@ struct phianalysisTHnSparse { if (!selectedPair(mother, track1, track2)) continue; - pointPair = FillPointPair(mother.Mag(), + pointPair = fillPointPair(mother.Mag(), mother.Pt(), - GetMultiplicity(c1), - GetCentrality(c1), + getMultiplicity(c1), + getCentrality(c1), (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), mother.Eta(), mother.Rapidity(), c1.posZ(), - GetMultiplicity(c2), - GetCentrality(c2), + getMultiplicity(c2), + getCentrality(c2), c2.posZ()); - rsnOutput->fillMixingpp(pointPair); + rsnOutput->fillMixingmp(pointPair); + } + } + } + if (mixingType == rsn::MixingType::mu) { + for (const auto& [c1, tracks1, c2, tracks2] : pairVzMu) { + if (produceQA) + registry.fill(HIST("QAMixing/hSelection"), 0.5); + + auto posDauthersc1 = positive->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); + auto posDauthersc2 = positive->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); + auto negDauthersc1 = negative->sliceByCached(aod::track::collisionId, c1.globalIndex(), cache); + auto negDauthersc2 = negative->sliceByCached(aod::track::collisionId, c2.globalIndex(), cache); + + if (produceQA) { + registry.fill(HIST("QAMixing/h2mu1_mu2"), getMultiplicity(c1), getMultiplicity(c2)); + registry.fill(HIST("QAMixing/h2ce1_ce2"), getCentrality(c1), getCentrality(c2)); + registry.fill(HIST("QAMixing/h2vz1_vz2"), c1.posZ(), c2.posZ()); + } + + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersc1, negDauthersc2))) { + if (produceQA) + registry.fill(HIST("QAMixing/hTrackSelection"), 0.5); + + if (!selectedTrack(track1)) + continue; + if (produceQA) + registry.fill(HIST("QAMixing/hTrackSelection"), 1.5); + if (!selectedTrack(track2)) + continue; + if (produceQA) + registry.fill(HIST("QAMixing/hTrackSelection"), 2.5); + + if (!selectedPair(mother, track1, track2)) + continue; + if (produceQA) + registry.fill(HIST("QAMixing/hTrackSelection"), 3.5); + + pointPair = fillPointPair(mother.Mag(), + mother.Pt(), + getMultiplicity(c1), + getCentrality(c1), + (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), + (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), + mother.Eta(), + mother.Rapidity(), + c1.posZ(), + getMultiplicity(c2), + getCentrality(c2), + c2.posZ()); + + rsnOutput->fillMixingpm(pointPair); + } + + if (static_cast(produce.produceLikesign)) { + + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersc1, posDauthersc2))) { + + if (!selectedTrack(track1)) + + continue; + if (!selectedTrack(track2)) + continue; + + if (!selectedPair(mother, track1, track2)) + continue; + + pointPair = fillPointPair(mother.Mag(), + mother.Pt(), + getMultiplicity(c1), + getCentrality(c1), + (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), + (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), + mother.Eta(), + mother.Rapidity(), + c1.posZ(), + getMultiplicity(c2), + getCentrality(c2), + c2.posZ()); + + rsnOutput->fillMixingpp(pointPair); + } + + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(negDauthersc1, negDauthersc2))) { + + if (!selectedTrack(track1)) + + continue; + if (!selectedTrack(track2)) + continue; + + if (!selectedPair(mother, track1, track2)) + continue; + pointPair = fillPointPair(mother.Mag(), + mother.Pt(), + getMultiplicity(c1), + getCentrality(c1), + (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), + (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), + mother.Eta(), + mother.Rapidity(), + c1.posZ(), + getMultiplicity(c2), + getCentrality(c2), + c2.posZ()); + + rsnOutput->fillMixingmm(pointPair); + } } - for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(negDauthersc1, negDauthersc2))) { + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersc2, negDauthersc1))) { if (!selectedTrack(track1)) @@ -644,56 +1058,97 @@ struct phianalysisTHnSparse { if (!selectedPair(mother, track1, track2)) continue; - pointPair = FillPointPair(mother.Mag(), + + pointPair = fillPointPair(mother.Mag(), mother.Pt(), - GetMultiplicity(c1), - GetCentrality(c1), + getMultiplicity(c1), + getCentrality(c1), (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), mother.Eta(), mother.Rapidity(), c1.posZ(), - GetMultiplicity(c2), - GetCentrality(c2), + getMultiplicity(c2), + getCentrality(c2), c2.posZ()); - rsnOutput->fillMixingmm(pointPair); + rsnOutput->fillMixingmp(pointPair); } } + } + } + PROCESS_SWITCH(PhianalysisTHnSparse, processMixed, "Process Mixing Event.", true); - for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(posDauthersc2, negDauthersc1))) { + void processGenOld(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles) + { + if (!static_cast(produce.produceTrue)) + return; - if (!selectedTrack(track1)) + registry.fill(HIST("QAMC/hMC"), 0.5); - continue; - if (!selectedTrack(track2)) + if (std::abs(mcCollision.posZ()) > static_cast(cut.vZ)) + return; + + registry.fill(HIST("QAMC/hMC"), 1.5); + + for (const auto& particle : mcParticles) { + registry.fill(HIST("QAMC/hMC"), 2.5); + if (std::abs(particle.y()) > static_cast(cut.y)) + continue; + + registry.fill(HIST("QAMC/hMC"), 3.5); + + if (particle.pdgCode() == motherPDG) { + auto daughters = particle.daughters_as(); + if (daughters.size() != 2) continue; - if (!selectedPair(mother, track1, track2)) + registry.fill(HIST("QAMC/hMC"), 4.5); + + auto daup = false; + auto daun = false; + + for (const auto& dau : daughters) { + if (!dau.isPhysicalPrimary()) + continue; + + if (dau.pdgCode() == dautherPosPDG) { + daup = true; + d1.SetXYZM(dau.px(), dau.py(), dau.pz(), massPos); + } else if (dau.pdgCode() == -dautherNegPDG) { + daun = true; + d2.SetXYZM(dau.px(), dau.py(), dau.pz(), massNeg); + } + } + if (!daup && !daun) continue; - pointPair = FillPointPair(mother.Mag(), + registry.fill(HIST("QAMC/hMC"), 5.5); + + mother = d1 + d2; + + pointPair = fillPointPair(mother.Mag(), mother.Pt(), - GetMultiplicity(c1), - GetCentrality(c1), - (tpcnSigmaPos > 0) ? std::abs(track1.tpcNSigmaKa()) : track1.tpcNSigmaKa(), - (tpcnSigmaNeg > 0) ? std::abs(track2.tpcNSigmaKa()) : track2.tpcNSigmaKa(), + 0, + 0, + std::abs(static_cast(cut.tpcnSigmaPos) / 2.0), + std::abs(static_cast(cut.tpcnSigmaNeg) / 2.0), mother.Eta(), mother.Rapidity(), - c1.posZ(), - GetMultiplicity(c2), - GetCentrality(c2), - c2.posZ()); + mcCollision.posZ(), + 0, + 0, + 0); - rsnOutput->fillMixingmp(pointPair); + rsnOutput->fillUnlikegenOld(pointPair); } } } - PROCESS_SWITCH(phianalysisTHnSparse, processMixed, "Process Mixing Event.", true); + PROCESS_SWITCH(PhianalysisTHnSparse, processGenOld, "Process generated.", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Resonances/phianalysisrun3_PbPb.cxx b/PWGLF/Tasks/Resonances/phianalysisrun3_PbPb.cxx index 51af74455f2..85a44210307 100644 --- a/PWGLF/Tasks/Resonances/phianalysisrun3_PbPb.cxx +++ b/PWGLF/Tasks/Resonances/phianalysisrun3_PbPb.cxx @@ -16,55 +16,65 @@ // (5) particle = 2 --> lambdastar // (6) 4 process function (a) Data same event (b) Data mixed event (c) MC generated (d) MC reconstructed -#include +#include "PWGLF/DataModel/EPCalibrationTables.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TRandom3.h" +#include #include +#include +#include +#include #include #include #include #include -#include -#include -#include #include -#include -#include + #include +#include #include +#include #include -#include "TRandom3.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" -#include "TF1.h" - -#include "PWGLF/DataModel/EPCalibrationTables.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/Core/TrackSelection.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" - using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using std::array; -struct phianalysisrun3_PbPb { +using namespace o2::aod::rctsel; +struct phianalysisrun3_PbPb { + struct : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } rctCut; + RCTFlagsChecker rctChecker; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; // events Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; @@ -73,16 +83,18 @@ struct phianalysisrun3_PbPb { Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; - Configurable nsigmaCutTPC{"nsigmacutTPC", 2.0, "Value of the TPC Nsigma cut"}; - Configurable nsigmaCutTOF{"nsigmacutTOF", 2.0, "Value of the TOF Nsigma cut"}; + Configurable nsigmacutTPC{"nsigmacutTPC", 2.0f, "Value of the TPC Nsigma cut"}; + Configurable nsigmacutTOF{"nsigmacutTOF", 2.0f, "Value of the TOF Nsigma cut"}; Configurable nsigmaCutCombined{"nsigmaCutCombined", 3.0, "Value of the TOF Nsigma cut"}; Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 5, "Number of mixed events per event"}; Configurable fillOccupancy{"fillOccupancy", true, "fill Occupancy"}; - Configurable cfgOccupancyCut1{"cfgOccupancyCut1", 500, "Occupancy cut"}; - Configurable cfgOccupancyCut2{"cfgOccupancyCut2", 1500, "Occupancy cut"}; Configurable isNoTOF{"isNoTOF", false, "isNoTOF"}; + Configurable additionalEvSel1{"additionalEvSel1", true, "Additional evsel1"}; Configurable additionalEvSel2{"additionalEvSel2", true, "Additional evsel2"}; Configurable additionalEvSel3{"additionalEvSel3", true, "Additional evsel3"}; + Configurable additionalEvSel4{"additionalEvSel4", true, "Additional evsel4"}; + Configurable additionalEvSel5{"additionalEvSel5", true, "Additional evsel5"}; + Configurable additionalEvSel6{"additionalEvSel6", true, "Additional evsel6"}; Configurable cfgMultFT0{"cfgMultFT0", true, "cfgMultFT0"}; Configurable iscustomDCAcut{"iscustomDCAcut", false, "iscustomDCAcut"}; Configurable ismanualDCAcut{"ismanualDCAcut", true, "ismanualDCAcut"}; @@ -92,6 +104,17 @@ struct phianalysisrun3_PbPb { Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; Configurable isDeepAngle{"isDeepAngle", false, "Deep Angle cut"}; Configurable cfgDeepAngle{"cfgDeepAngle", 0.04, "Deep Angle cut value"}; + Configurable nBkgRotations{"nBkgRotations", 3, "Number of rotated copies (background) per each original candidate"}; + Configurable fillRotation{"fillRotation", true, "fill rotation"}; + Configurable confMinRot{"confMinRot", 5.0f * TMath::Pi() / 6.0f, "Minimum of rotation"}; + Configurable confMaxRot{"confMaxRot", 7.0f * TMath::Pi() / 6.0f, "Maximum of rotation"}; + Configurable pdgcheck{"pdgcheck", true, "pdgcheck"}; + Configurable reco{"reco", true, "reco"}; + ConfigurableAxis binsImpactPar{"binsImpactPar", {VARIABLE_WIDTH, 0, 3.5, 5.67, 7.45, 8.85, 10.0, 11.21, 12.26, 13.28, 14.23, 15.27}, "Binning of the impact parameter axis"}; + ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 0.0, 0.1, 0.2, 0.3, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0}, "Binning of the pT axis"}; + ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; + Configurable cfgCutOccupancy{"cfgCutOccupancy", 3000, "Occupancy cut"}; + Configurable centestimator{"centestimator", 0, "Select multiplicity estimator: 0 - FT0C, 1 - FT0A, 2 - FT0M, 3 - FV0A, 4 - PVTracks"}; Configurable genacceptancecut{"genacceptancecut", true, "use acceptance cut for generated"}; // MC @@ -99,47 +122,130 @@ struct phianalysisrun3_PbPb { Configurable avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"}; void init(o2::framework::InitContext&) { - + rctChecker.init(rctCut.cfgEvtRCTFlagCheckerLabel, rctCut.cfgEvtRCTFlagCheckerZDCCheck, rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + AxisSpec impactParAxis = {binsImpactPar, "Impact Parameter"}; + AxisSpec ptAxis = {binsPt, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec centAxis = {binsCent, "V0M (%)"}; histos.add("hCentrality", "Centrality distribution", kTH1F, {{200, 0.0, 200.0}}); histos.add("hVtxZ", "Vertex distribution in Z;Z (cm)", kTH1F, {{400, -20.0, 20.0}}); histos.add("hOccupancy", "Occupancy distribution", kTH1F, {{500, 0, 50000}}); + histos.add("hEvtSelInfo", "hEvtSelInfo", kTH1F, {{10, 0, 10.0}}); if (!isMC) { histos.add("h3PhiInvMassUnlikeSign", "Invariant mass of Phi meson Unlike Sign", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); histos.add("h3PhiInvMassMixed", "Invariant mass of Phi meson Mixed", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); + histos.add("h3PhiInvMassRot", "Invariant mass of Phi meson Rotation", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); + histos.add("h3PhiInvMassSame", "Invariant mass of Phi meson same", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); + histos.add("h2PhiRapidity", "phi meson Rapidity", kTH2F, {{200, 0.0f, 20.0f}, {200, -4, 4}}); } else if (isMC) { histos.add("hMC", "MC Event statistics", kTH1F, {{10, 0.0f, 10.0f}}); + histos.add("EL1", "MC Event statistics", kTH1F, {impactParAxis}); + histos.add("EL2", "MC Event statistics", kTH1F, {centAxis}); + histos.add("ES1", "MC Event statistics", kTH1F, {impactParAxis}); + histos.add("ES3", "MC Event statistics", kTH1F, {impactParAxis}); + histos.add("ES2", "MC Event statistics", kTH1F, {centAxis}); + histos.add("ES4", "MC Event statistics", kTH1F, {centAxis}); histos.add("h1PhiGen", "Phi meson Gen", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("h1PhiGen1", "Phi meson Gen", kTH1F, {{200, 0.0f, 20.0f}}); histos.add("h1PhiRecsplit", "Phi meson Rec split", kTH1F, {{200, 0.0f, 20.0f}}); histos.add("Centrec", "MC Centrality", kTH1F, {{200, 0.0, 200.0}}); histos.add("Centgen", "MC Centrality", kTH1F, {{200, 0.0, 200.0}}); + histos.add("hVtxZgen", "Vertex distribution in Z;Z (cm)", kTH1F, {{400, -20.0, 20.0}}); + histos.add("hVtxZrec", "Vertex distribution in Z;Z (cm)", kTH1F, {{400, -20.0, 20.0}}); histos.add("h2PhiRec2", "Phi meson Rec", kTH2F, {{200, 0.0f, 20.0f}, {200, 0.0, 200.0}}); histos.add("h3PhiRec3", "Phi meson Rec", kTH3F, {{200, 0.0f, 20.0f}, {200, 0.0, 200.0}, {200, 0.9, 1.1}}); + histos.add("h3Phi1Rec3", "Phi meson Rec", kTH3F, {{200, 0.0f, 20.0f}, {200, 0.0, 200.0}, {200, 0.9, 1.1}}); + histos.add("h3PhiGen3", "Phi meson Gen", kTH3F, {{200, 0.0f, 20.0f}, {200, 0.0, 200.0}, {200, 0.9, 1.1}}); + histos.add("h3PhiInvMassMixedMC", "Invariant mass of Phi meson Mixed", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); + histos.add("h3PhiInvMassSameMC", "Invariant mass of Phi meson same", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); + histos.add("h3PhiInvMassRotMC", "Invariant mass of Phi meson Rotation", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); histos.add("h2PhiGen2", "Phi meson gen", kTH2F, {{200, 0.0f, 20.0f}, {200, 0.0, 200.0}}); + histos.add("h2PhiGen1", "Phi meson gen", kTH2F, {ptAxis, impactParAxis}); histos.add("h1PhiRec1", "Phi meson Rec", kTH1F, {{200, 0.0f, 20.0f}}); histos.add("h1Phimassgen", "Phi meson gen", kTH1F, {{200, 0.9, 1.1}}); histos.add("h1Phimassrec", "Phi meson Rec", kTH1F, {{200, 0.9, 1.1}}); + histos.add("h1Phimasssame", "Phi meson Rec", kTH1F, {{200, 0.9, 1.1}}); + histos.add("h1Phimassmix", "Phi meson Rec", kTH1F, {{200, 0.9, 1.1}}); + histos.add("h1Phimassrot", "Phi meson Rec", kTH1F, {{200, 0.9, 1.1}}); + histos.add("h1Phi1massrec", "Phi meson Rec", kTH1F, {{200, 0.9, 1.1}}); histos.add("h1Phipt", "Phi meson Rec", kTH1F, {{200, 0.0f, 20.0f}}); histos.add("hOccupancy1", "Occupancy distribution", kTH1F, {{500, 0, 50000}}); + histos.add("h1PhifinalRec", "Phi meson Rec", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("h1Phifinalgenmass", "Phi meson gen mass", kTH1F, {{200, 0.9, 1.1}}); + histos.add("h3PhifinalRec", "Phi meson Rec", kTH3F, {{200, 0.0f, 20.0f}, {200, 0.0, 200.0}, {200, 0.9, 1.1}}); + histos.add("h1PhifinalGen", "Phi meson Gen", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("h2PhifinalGen", "Phi meson Gen", kTH2F, {{200, 0.0f, 20.0f}, {200, 0.0, 200.0}}); + histos.add("hMC1", "MC Event statistics", kTH1F, {{15, 0.0f, 15.0f}}); + histos.add("Centrec1", "MC Centrality", kTH1F, {{200, 0.0, 200.0}}); + histos.add("Centgen1", "MC Centrality", kTH1F, {{200, 0.0, 200.0}}); + histos.add("h1PhiRecsplit1", "Phi meson Rec split", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hImpactParameterGen", "Impact parameter of generated MC events", kTH1F, {impactParAxis}); + histos.add("hImpactParameterRec", "Impact parameter of generated MC events", kTH1F, {impactParAxis}); + histos.add("hImpactParameterGenCen", "Impact parameter of generated MC events", kTH2F, {impactParAxis, centAxis}); + histos.add("hImpactParameterRecCen", "Impact parameter of generated MC events", kTH2F, {impactParAxis, centAxis}); + histos.add("TOF_Nsigma_MC", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + histos.add("TPC_Nsigma_MC", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + histos.add("TOF_Nsigma1_MC", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + histos.add("TPC_Nsigma1_MC", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + histos.add("trkDCAxy", "DCAxy distribution of positive kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("trkDCAz", "DCAxy distribution of negative kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + if (doprocessEvtLossSigLossMC) { + histos.add("QAevent/hImpactParameterGen", "Impact parameter of generated MC events", kTH1F, {impactParAxis}); + histos.add("QAevent/hImpactParameterRec", "Impact parameter of selected MC events", kTH1F, {impactParAxis}); + histos.add("QAevent/hImpactParvsCentrRec", "Impact parameter of selected MC events vs centrality", kTH2F, {{120, 0.0f, 120.0f}, impactParAxis}); + histos.add("QAevent/phigenBeforeEvtSel", "phi before event selections", kTH2F, {ptAxis, impactParAxis}); + histos.add("QAevent/phigenAfterEvtSel", "phi after event selections", kTH2F, {ptAxis, impactParAxis}); + } } + histos.add("hEta", "eta of kaon track candidates", HistType::kTH2F, {{200, -1.0f, 1.0f}, {200, 0.0f, 20.0f}}); + histos.add("hPhi", "phi of kaon track candidates", HistType::kTH2F, {{65, 0, 6.5}, {200, 0.0f, 20.0f}}); + // DCA QA - histos.add("QAbefore/trkDCAxy", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); - histos.add("QAbefore/trkDCAz", "DCAz distribution of kaon track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); - histos.add("QAafter/trkDCAxy", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); - histos.add("QAafter/trkDCAz", "DCAz distribution of kaon track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); + // DCA histograms: separate for positive and negative kaons, range [-1.0, 1.0] + histos.add("QAbefore/trkDCAxy_pos", "DCAxy distribution of positive kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAbefore/trkDCAxy_neg", "DCAxy distribution of negative kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAbefore/trkDCAz_pos", "DCAz distribution of positive kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAbefore/trkDCAz_neg", "DCAz distribution of negative kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + + histos.add("QAbefore/trkDCAxypt_pos", "DCAxy distribution of positive kaon track candidates", HistType::kTH2F, {{150, -1.0f, 1.0f}, {200, 0.0f, 20.0f}}); + histos.add("QAbefore/trkDCAxypt_neg", "DCAxy distribution of negative kaon track candidates", HistType::kTH2F, {{150, -1.0f, 1.0f}, {200, 0.0f, 20.0f}}); + histos.add("QAbefore/trkDCAzpt_pos", "DCAz distribution of positive kaon track candidates", HistType::kTH2F, {{150, -1.0f, 1.0f}, {200, 0.0f, 20.0f}}); + histos.add("QAbefore/trkDCAzpt_neg", "DCAz distribution of negative kaon track candidates", HistType::kTH2F, {{150, -1.0f, 1.0f}, {200, 0.0f, 20.0f}}); + + histos.add("QAafter/trkDCAxy_pos", "DCAxy distribution of positive kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAafter/trkDCAxy_neg", "DCAxy distribution of negative kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAafter/trkDCAz_pos", "DCAz distribution of positive kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + histos.add("QAafter/trkDCAz_neg", "DCAz distribution of negative kaon track candidates", HistType::kTH1F, {{150, -1.0f, 1.0f}}); + + histos.add("QAafter/trkDCAxypt_pos", "DCAxy distribution of positive kaon track candidates", HistType::kTH2F, {{150, -1.0f, 1.0f}, {200, 0.0f, 20.0f}}); + histos.add("QAafter/trkDCAxypt_neg", "DCAxy distribution of negative kaon track candidates", HistType::kTH2F, {{150, -1.0f, 1.0f}, {200, 0.0f, 20.0f}}); + histos.add("QAafter/trkDCAzpt_pos", "DCAz distribution of positive kaon track candidates", HistType::kTH2F, {{150, -1.0f, 1.0f}, {200, 0.0f, 20.0f}}); + histos.add("QAafter/trkDCAzpt_neg", "DCAz distribution of negative kaon track candidates", HistType::kTH2F, {{150, -1.0f, 1.0f}, {200, 0.0f, 20.0f}}); // PID QA before cuts - histos.add("QAbefore/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Kaon;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); - histos.add("QAbefore/TOF_Nsigma_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); - histos.add("QAbefore/TPC_Nsigma_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); + histos.add("QAbefore/TOF_TPC_Mapka_all_pos", "TOF + TPC Combined PID for positive Kaon;#sigma_{TOF}^{K^{+}};#sigma_{TPC}^{K^{+}}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); + histos.add("QAbefore/TOF_TPC_Mapka_all_neg", "TOF + TPC Combined PID for negative Kaon;#sigma_{TOF}^{K^{-}};#sigma_{TPC}^{K^{-}}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); + + histos.add("QAbefore/TOF_Nsigma_all_pos", "TOF NSigma for positive Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{K^{+}}", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + histos.add("QAbefore/TOF_Nsigma_all_neg", "TOF NSigma for negative Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{K^{-}}", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + + histos.add("QAbefore/TPC_Nsigma_all_pos", "TPC NSigma for positive Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{K^{+}}", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + histos.add("QAbefore/TPC_Nsigma_all_neg", "TPC NSigma for negative Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{K^{-}}", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + // PID QA after cuts - histos.add("QAafter/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Kaon;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); - histos.add("QAafter/TOF_Nsigma_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); - histos.add("QAafter/TPC_Nsigma_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH2D, {{200, 0.0, 20.0}, {100, -6, 6}}}); + histos.add("QAafter/TOF_TPC_Mapka_all_pos", "TOF + TPC Combined PID for positive Kaon;#sigma_{TOF}^{K^{+}};#sigma_{TPC}^{K^{+}}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); + histos.add("QAafter/TOF_TPC_Mapka_all_neg", "TOF + TPC Combined PID for negative Kaon;#sigma_{TOF}^{K^{-}};#sigma_{TPC}^{K^{-}}", {HistType::kTH2D, {{100, -6, 6}, {100, -6, 6}}}); + + histos.add("QAafter/TOF_Nsigma_all_pos", "TOF NSigma for positive Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{K^{+}}", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + histos.add("QAafter/TOF_Nsigma_all_neg", "TOF NSigma for negative Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{K^{-}}", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + + histos.add("QAafter/TPC_Nsigma_all_pos", "TPC NSigma for positive Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{K^{+}}", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); + histos.add("QAafter/TPC_Nsigma_all_neg", "TPC NSigma for negative Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{K^{-}}", {HistType::kTH3D, {{200, -12, 12}, {200, 0.0, 200.0}, {200, 0.0f, 20.0f}}}); } double massKa = o2::constants::physics::MassKPlus; double rapidity; double genMass, recMass, resolution; + ROOT::Math::PxPyPzMVector phiMother, daughter1, daughter2; double mass{0.}; double massrotation{0.}; double pT{0.}; @@ -164,10 +270,10 @@ struct phianalysisrun3_PbPb { if (!isNoTOF && candidate.hasTOF() && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < (nsigmaCutCombined * nsigmaCutCombined)) { return true; } - if (!isNoTOF && !candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (!isNoTOF && !candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < nsigmacutTPC) { return true; } - if (isNoTOF && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (isNoTOF && std::abs(candidate.tpcNSigmaKa()) < nsigmacutTPC) { return true; } return false; @@ -175,14 +281,45 @@ struct phianalysisrun3_PbPb { template bool selectionPIDpTdependent(const T& candidate) { - if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < nsigmacutTPC) { return true; } - if (candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < nsigmacutTPC && std::abs(candidate.tofNSigmaKa()) < nsigmacutTOF) { return true; } return false; } + template + bool myEventSelections(const CollType& collision) + { + if (std::abs(collision.posZ()) > cfgCutVertex) + return false; + + if (!collision.sel8()) + return false; + + if (additionalEvSel1 && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) + return false; + + if (additionalEvSel2 && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) + return false; + + if (additionalEvSel3 && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) + return false; + + if (additionalEvSel4 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) + return false; + if (additionalEvSel5 && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) + return false; + if (additionalEvSel6 && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) + return false; + int occupancy = collision.trackOccupancyInTimeRange(); + if (fillOccupancy && (occupancy > cfgCutOccupancy)) + return false; + + return true; + } + // deep angle cut on pair to remove photon conversion template bool selectionPair(const T1& candidate1, const T2& candidate2) @@ -194,28 +331,42 @@ struct phianalysisrun3_PbPb { pz2 = candidate2.pz(); p1 = candidate1.p(); p2 = candidate2.p(); - angle = TMath::ACos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); + angle = std::acos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); if (isDeepAngle && angle < cfgDeepAngle) { return false; } return true; } template - void FillinvMass(const T1& candidate1, const T2& candidate2, float multiplicity, bool unlike, bool mix, float massd1, float massd2) + void fillinvMass(const T1& candidate1, const T2& candidate2, float multiplicity, bool unlike, bool mix, float massd1, float massd2) { - pvec0 = array{candidate1.px(), candidate1.py(), candidate1.pz()}; - pvec1 = array{candidate2.px(), candidate2.py(), candidate2.pz()}; - auto arrMom = array{pvec0, pvec1}; + pvec0 = std::array{candidate1.px(), candidate1.py(), candidate1.pz()}; + pvec1 = std::array{candidate2.px(), candidate2.py(), candidate2.pz()}; + auto arrMom = std::array, 2>{pvec0, pvec1}; + int track1Sign = candidate1.sign(); int track2Sign = candidate2.sign(); - mass = RecoDecay::m(arrMom, array{massd1, massd2}); - pT = RecoDecay::pt(array{candidate1.px() + candidate2.px(), candidate1.py() + candidate2.py()}); - rapidity = RecoDecay::y(array{candidate1.px() + candidate2.px(), candidate1.py() + candidate2.py(), candidate1.pz() + candidate2.pz()}, mass); + mass = RecoDecay::m(arrMom, std::array{massd1, massd2}); + + pT = RecoDecay::pt(std::array{ + candidate1.px() + candidate2.px(), + candidate1.py() + candidate2.py()}); + + rapidity = RecoDecay::y(std::array{ + candidate1.px() + candidate2.px(), + candidate1.py() + candidate2.py(), + candidate1.pz() + candidate2.pz()}, + mass); + + constexpr float kRapidityCut = 0.5; + constexpr int kOppositeCharge = 0; // default filling - if (std::abs(rapidity) < 0.5 && track1Sign * track2Sign < 0) { + if (std::abs(rapidity) < kRapidityCut && track1Sign * track2Sign < kOppositeCharge) { + if (unlike) { histos.fill(HIST("h3PhiInvMassUnlikeSign"), multiplicity, pT, mass); + histos.fill(HIST("h2PhiRapidity"), pT, rapidity); } if (mix) { histos.fill(HIST("h3PhiInvMassMixed"), multiplicity, pT, mass); @@ -224,13 +375,13 @@ struct phianalysisrun3_PbPb { } Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPT); - Filter DCAcutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + Filter dcacutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); - using EventCandidates = soa::Filtered>; + using EventCandidates = soa::Filtered>; using TrackCandidates = soa::Filtered>; // using EventCandidatesMC = soa::Join; - using EventCandidatesMC = soa::Join; + using EventCandidatesMC = soa::Join; using TrackCandidatesMC = soa::Filtered>; @@ -241,48 +392,104 @@ struct phianalysisrun3_PbPb { using FilTrackMCRecTable = soa::Filtered; ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for bin"}; - ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {20, 0, 100}, "multiplicity percentile for bin"}; - ConfigurableAxis axisMultiplicity{"axisMultiplicity", {2000, 0, 10000}, "TPC multiplicity for bin"}; + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {2000, 0, 10000}, "multiplicity for bin"}; Preslice perCollision = aod::track::collisionId; SliceCache cache; - using BinningTypeVertexContributor = ColumnBinningPolicy; - ROOT::Math::PxPyPzMVector PhiMesonMother, KaonPlus, KaonMinus; + using BinningTypeVertexContributor1 = ColumnBinningPolicy; + using BinningTypeVertexContributor2 = ColumnBinningPolicy; + using BinningTypeVertexContributor3 = ColumnBinningPolicy; + using BinningTypeVertexContributor4 = ColumnBinningPolicy; + ROOT::Math::PxPyPzMVector phiMesonMother, kaonPlus, kaonMinus; void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) { + histos.fill(HIST("hEvtSelInfo"), 0.5); + if (rctCut.requireRCTFlagChecker && !rctChecker(collision)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 1.5); if (!collision.sel8()) { return; } - if (additionalEvSel2 && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + histos.fill(HIST("hEvtSelInfo"), 2.5); + if (additionalEvSel1 && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { return; } - if (additionalEvSel3 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + histos.fill(HIST("hEvtSelInfo"), 3.5); + if (additionalEvSel2 && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 4.5); + if (additionalEvSel3 && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 5.5); + if (additionalEvSel4 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 6.5); + if (additionalEvSel5 && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 7.5); + if (additionalEvSel6 && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { return; } + histos.fill(HIST("hEvtSelInfo"), 8.5); int occupancy = collision.trackOccupancyInTimeRange(); - if (fillOccupancy && !(occupancy > cfgOccupancyCut1 && occupancy < cfgOccupancyCut2)) { + if (fillOccupancy && (occupancy > cfgCutOccupancy)) { return; } + histos.fill(HIST("hEvtSelInfo"), 9.5); float multiplicity{-1}; - if (cfgMultFT0) + const int kCentFT0C = 0; + const int kCentFT0A = 1; + const int kCentFT0M = 2; + const int kCentFV0A = 3; + + if (centestimator == kCentFT0C) { multiplicity = collision.centFT0C(); + } else if (centestimator == kCentFT0A) { + multiplicity = collision.centFT0A(); + } else if (centestimator == kCentFT0M) { + multiplicity = collision.centFT0M(); + } else if (centestimator == kCentFV0A) { + multiplicity = collision.centFV0A(); + } + histos.fill(HIST("hCentrality"), multiplicity); histos.fill(HIST("hVtxZ"), collision.posZ()); histos.fill(HIST("hOccupancy"), occupancy); - for (auto track1 : tracks) { + for (const auto& track1 : tracks) { if (!selectionTrack(track1)) { continue; } - histos.fill(HIST("QAbefore/TPC_Nsigma_all"), track1.pt(), track1.tpcNSigmaKa()); - histos.fill(HIST("QAbefore/TOF_Nsigma_all"), track1.pt(), track1.tofNSigmaKa()); - histos.fill(HIST("QAbefore/trkDCAxy"), track1.dcaXY()); - histos.fill(HIST("QAbefore/trkDCAz"), track1.dcaZ()); - histos.fill(HIST("QAbefore/TOF_TPC_Mapka_all"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + int track1Sign = track1.sign(); // or track1.charge(), assuming it returns ±1 + + histos.fill(HIST("hEta"), track1.eta(), track1.pt()); + histos.fill(HIST("hPhi"), track1.phi(), track1.pt()); + if (track1Sign > 0) { // Positive kaon + histos.fill(HIST("QAbefore/TPC_Nsigma_all_pos"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAbefore/TOF_Nsigma_all_pos"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAbefore/trkDCAxy_pos"), track1.dcaXY()); + histos.fill(HIST("QAbefore/trkDCAz_pos"), track1.dcaZ()); + histos.fill(HIST("QAbefore/trkDCAxypt_pos"), track1.dcaXY(), track1.pt()); + histos.fill(HIST("QAbefore/trkDCAzpt_pos"), track1.dcaZ(), track1.pt()); + histos.fill(HIST("QAbefore/TOF_TPC_Mapka_all_pos"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + } else if (track1Sign < 0) { // Negative kaon + histos.fill(HIST("QAbefore/TPC_Nsigma_all_neg"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAbefore/TOF_Nsigma_all_neg"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAbefore/trkDCAxy_neg"), track1.dcaXY()); + histos.fill(HIST("QAbefore/trkDCAz_neg"), track1.dcaZ()); + histos.fill(HIST("QAbefore/trkDCAxypt_neg"), track1.dcaXY(), track1.pt()); + histos.fill(HIST("QAbefore/trkDCAzpt_neg"), track1.dcaZ(), track1.pt()); + histos.fill(HIST("QAbefore/TOF_TPC_Mapka_all_neg"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + } auto track1ID = track1.globalIndex(); - for (auto track2 : tracks) { + for (const auto& track2 : tracks) { if (!selectionTrack(track2)) { continue; } @@ -296,66 +503,103 @@ struct phianalysisrun3_PbPb { bool unlike = true; bool mix = false; if (!ispTdepPID && selectionPID(track1) && selectionPID(track2)) { - histos.fill(HIST("QAafter/TPC_Nsigma_all"), track1.pt(), track1.tpcNSigmaKa()); - histos.fill(HIST("QAafter/TOF_Nsigma_all"), track1.pt(), track1.tofNSigmaKa()); - histos.fill(HIST("QAafter/trkDCAxy"), track1.dcaXY()); - histos.fill(HIST("QAafter/trkDCAz"), track1.dcaZ()); - histos.fill(HIST("QAafter/TOF_TPC_Mapka_all"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); - FillinvMass(track1, track2, multiplicity, unlike, mix, massKa, massKa); + int track1Sign = track1.sign(); // Assuming `charge()` gives +1 or -1 + + if (track1Sign > 0) { // Positive kaon + histos.fill(HIST("QAafter/TPC_Nsigma_all_pos"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAafter/TOF_Nsigma_all_pos"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAafter/trkDCAxy_pos"), track1.dcaXY()); + histos.fill(HIST("QAafter/trkDCAz_pos"), track1.dcaZ()); + histos.fill(HIST("QAafter/trkDCAxypt_pos"), track1.dcaXY(), track1.pt()); + histos.fill(HIST("QAafter/trkDCAzpt_pos"), track1.dcaZ(), track1.pt()); + histos.fill(HIST("QAafter/TOF_TPC_Mapka_all_pos"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + } else if (track1Sign < 0) { // Negative kaon + histos.fill(HIST("QAafter/TPC_Nsigma_all_neg"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAafter/TOF_Nsigma_all_neg"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAafter/trkDCAxy_neg"), track1.dcaXY()); + histos.fill(HIST("QAafter/trkDCAz_neg"), track1.dcaZ()); + histos.fill(HIST("QAafter/trkDCAxypt_neg"), track1.dcaXY(), track1.pt()); + histos.fill(HIST("QAafter/trkDCAzpt_neg"), track1.dcaZ(), track1.pt()); + histos.fill(HIST("QAafter/TOF_TPC_Mapka_all_neg"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + } + + fillinvMass(track1, track2, multiplicity, unlike, mix, massKa, massKa); } + if (ispTdepPID && selectionPIDpTdependent(track1) && selectionPIDpTdependent(track2)) { - histos.fill(HIST("QAafter/TPC_Nsigma_all"), track1.pt(), track1.tpcNSigmaKa()); - histos.fill(HIST("QAafter/TOF_Nsigma_all"), track1.pt(), track1.tofNSigmaKa()); - histos.fill(HIST("QAafter/trkDCAxy"), track1.dcaXY()); - histos.fill(HIST("QAafter/trkDCAz"), track1.dcaZ()); - histos.fill(HIST("QAafter/TOF_TPC_Mapka_all"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); - FillinvMass(track1, track2, multiplicity, unlike, mix, massKa, massKa); + int track1Sign = track1.sign(); // Same assumption as above + + if (track1Sign > 0) { // Positive kaon + histos.fill(HIST("QAafter/TPC_Nsigma_all_pos"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAafter/TOF_Nsigma_all_pos"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAafter/trkDCAxy_pos"), track1.dcaXY()); + histos.fill(HIST("QAafter/trkDCAz_pos"), track1.dcaZ()); + histos.fill(HIST("QAafter/trkDCAxypt_pos"), track1.dcaXY(), track1.pt()); + histos.fill(HIST("QAafter/trkDCAzpt_pos"), track1.dcaZ(), track1.pt()); + histos.fill(HIST("QAafter/TOF_TPC_Mapka_all_pos"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + } else if (track1Sign < 0) { // Negative kaon + histos.fill(HIST("QAafter/TPC_Nsigma_all_neg"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAafter/TOF_Nsigma_all_neg"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAafter/trkDCAxy_neg"), track1.dcaXY()); + histos.fill(HIST("QAafter/trkDCAz_neg"), track1.dcaZ()); + histos.fill(HIST("QAafter/trkDCAxypt_neg"), track1.dcaXY(), track1.pt()); + histos.fill(HIST("QAafter/trkDCAzpt_neg"), track1.dcaZ(), track1.pt()); + histos.fill(HIST("QAafter/TOF_TPC_Mapka_all_neg"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + } + + fillinvMass(track1, track2, multiplicity, unlike, mix, massKa, massKa); } } } } PROCESS_SWITCH(phianalysisrun3_PbPb, processSameEvent, "Process Same event", false); - void processMixedEvent(EventCandidates const& collisions, TrackCandidates const& tracks) + void processMixedEvent1(EventCandidates const& collisions, TrackCandidates const& tracks) { auto tracksTuple = std::make_tuple(tracks); //////// currently mixing the event with similar TPC multiplicity //////// - BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicity}, true}; - SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + BinningTypeVertexContributor1 binningOnPositions{{axisVertex, axisMultiplicity}, true}; + SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; + for (const auto& [c1, tracks1, c2, tracks2] : pair) { + if (rctCut.requireRCTFlagChecker && !rctChecker(c1)) { + continue; + } + if (rctCut.requireRCTFlagChecker && !rctChecker(c2)) { + continue; + } if (!c1.sel8()) { continue; } if (!c2.sel8()) { continue; } - if (additionalEvSel2 && (!c1.selection_bit(aod::evsel::kNoSameBunchPileup) || !c1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + if (additionalEvSel1 && (!c1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c2.selection_bit(aod::evsel::kNoTimeFrameBorder))) { + continue; + } + if (additionalEvSel2 && (!c1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !c2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel3 && (!c1.selection_bit(aod::evsel::kNoSameBunchPileup) || !c2.selection_bit(aod::evsel::kNoSameBunchPileup))) { continue; } - if (additionalEvSel2 && (!c2.selection_bit(aod::evsel::kNoSameBunchPileup) || !c2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + if (additionalEvSel4 && (!c1.selection_bit(aod::evsel::kIsGoodITSLayersAll) || !c2.selection_bit(aod::evsel::kIsGoodITSLayersAll))) { continue; } - if (additionalEvSel3 && (!c1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + if (additionalEvSel5 && (!c1.selection_bit(aod::evsel::kNoCollInTimeRangeStandard) || !c2.selection_bit(aod::evsel::kNoCollInTimeRangeStandard))) { continue; } - if (additionalEvSel3 && (!c2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + if (additionalEvSel6 && (!c1.selection_bit(aod::evsel::kNoCollInRofStandard) || !c2.selection_bit(aod::evsel::kNoCollInRofStandard))) { continue; } int occupancy1 = c1.trackOccupancyInTimeRange(); int occupancy2 = c2.trackOccupancyInTimeRange(); - if (fillOccupancy && !(occupancy1 > cfgOccupancyCut1 && occupancy1 < cfgOccupancyCut2)) { - return; - } - if (fillOccupancy && !(occupancy2 > cfgOccupancyCut1 && occupancy2 < cfgOccupancyCut2)) { - return; + + if (fillOccupancy && (occupancy1 > cfgCutOccupancy || occupancy2 > cfgCutOccupancy)) { + continue; } float multiplicity; - if (cfgMultFT0) - multiplicity = c1.centFT0C(); - if (!cfgMultFT0) - multiplicity = c1.numContrib(); - - for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + multiplicity = c1.centFT0C(); + for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { bool unlike = false; bool mix = true; if (!selectionTrack(t1)) { @@ -368,74 +612,361 @@ struct phianalysisrun3_PbPb { continue; } if (!ispTdepPID && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); + fillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); } if (ispTdepPID && selectionPIDpTdependent(t1) && selectionPIDpTdependent(t2)) { - FillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); + fillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); } } } } + PROCESS_SWITCH(phianalysisrun3_PbPb, processMixedEvent1, "Process Mixed event", false); + void processMixedEvent2(EventCandidates const& collisions, TrackCandidates const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + //////// currently mixing the event with similar TPC multiplicity //////// + BinningTypeVertexContributor2 binningOnPositions{{axisVertex, axisMultiplicity}, true}; + SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; + for (const auto& [c1, tracks1, c2, tracks2] : pair) { + if (rctCut.requireRCTFlagChecker && !rctChecker(c1)) { + continue; + } + if (rctCut.requireRCTFlagChecker && !rctChecker(c2)) { + continue; + } + if (!c1.sel8()) { + continue; + } + if (!c2.sel8()) { + continue; + } + if (additionalEvSel1 && (!c1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c2.selection_bit(aod::evsel::kNoTimeFrameBorder))) { + continue; + } + if (additionalEvSel2 && (!c1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !c2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel3 && (!c1.selection_bit(aod::evsel::kNoSameBunchPileup) || !c2.selection_bit(aod::evsel::kNoSameBunchPileup))) { + continue; + } + if (additionalEvSel4 && (!c1.selection_bit(aod::evsel::kIsGoodITSLayersAll) || !c2.selection_bit(aod::evsel::kIsGoodITSLayersAll))) { + continue; + } + if (additionalEvSel5 && (!c1.selection_bit(aod::evsel::kNoCollInTimeRangeStandard) || !c2.selection_bit(aod::evsel::kNoCollInTimeRangeStandard))) { + continue; + } + if (additionalEvSel6 && (!c1.selection_bit(aod::evsel::kNoCollInRofStandard) || !c2.selection_bit(aod::evsel::kNoCollInRofStandard))) { + continue; + } + int occupancy1 = c1.trackOccupancyInTimeRange(); + int occupancy2 = c2.trackOccupancyInTimeRange(); - PROCESS_SWITCH(phianalysisrun3_PbPb, processMixedEvent, "Process Mixed event", false); + if (fillOccupancy && (occupancy1 > cfgCutOccupancy || occupancy2 > cfgCutOccupancy)) { + continue; + } + float multiplicity; + multiplicity = c1.centFT0A(); + for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + bool unlike = false; + bool mix = true; + if (!selectionTrack(t1)) { + continue; + } + if (!selectionTrack(t2)) { + continue; + } + if (!selectionPair(t1, t2)) { + continue; + } + if (!ispTdepPID && selectionPID(t1) && selectionPID(t2)) { + fillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); + } + if (ispTdepPID && selectionPIDpTdependent(t1) && selectionPIDpTdependent(t2)) { + fillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); + } + } + } + } - void processMC(CollisionMCTrueTable::iterator const& /*TrueCollision*/, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + PROCESS_SWITCH(phianalysisrun3_PbPb, processMixedEvent2, "Process Mixed event", false); + void processMixedEvent3(EventCandidates const& collisions, TrackCandidates const& tracks) { - histos.fill(HIST("hMC"), 0); - if (RecCollisions.size() == 0) { - histos.fill(HIST("hMC"), 1); - return; - } - if (RecCollisions.size() > 1) { - histos.fill(HIST("hMC"), 2); - return; - } - for (auto& RecCollision : RecCollisions) { - histos.fill(HIST("hMC"), 3); - if (!RecCollision.sel8()) { - histos.fill(HIST("hMC"), 4); + auto tracksTuple = std::make_tuple(tracks); + //////// currently mixing the event with similar TPC multiplicity //////// + BinningTypeVertexContributor3 binningOnPositions{{axisVertex, axisMultiplicity}, true}; + SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; + for (const auto& [c1, tracks1, c2, tracks2] : pair) { + if (rctCut.requireRCTFlagChecker && !rctChecker(c1)) { continue; } - if (timFrameEvsel && (!RecCollision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - histos.fill(HIST("hMC"), 5); + if (rctCut.requireRCTFlagChecker && !rctChecker(c2)) { continue; } - int occupancy = RecCollision.trackOccupancyInTimeRange(); - if (fillOccupancy && !(occupancy > cfgOccupancyCut1 && occupancy < cfgOccupancyCut2)) { - return; + if (!c1.sel8()) { + continue; } - if (TMath::Abs(RecCollision.posZ()) > cfgCutVertex) { - histos.fill(HIST("hMC"), 6); + if (!c2.sel8()) { continue; } - histos.fill(HIST("hMC"), 7); - auto centrality = RecCollision.centFT0C(); - histos.fill(HIST("Centrec"), centrality); - auto oldindex = -999; - auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); - // loop over reconstructed particle - for (auto track1 : Rectrackspart) { - if (!selectionTrack(track1)) { + if (additionalEvSel1 && (!c1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c2.selection_bit(aod::evsel::kNoTimeFrameBorder))) { + continue; + } + if (additionalEvSel2 && (!c1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !c2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel3 && (!c1.selection_bit(aod::evsel::kNoSameBunchPileup) || !c2.selection_bit(aod::evsel::kNoSameBunchPileup))) { + continue; + } + if (additionalEvSel4 && (!c1.selection_bit(aod::evsel::kIsGoodITSLayersAll) || !c2.selection_bit(aod::evsel::kIsGoodITSLayersAll))) { + continue; + } + if (additionalEvSel5 && (!c1.selection_bit(aod::evsel::kNoCollInTimeRangeStandard) || !c2.selection_bit(aod::evsel::kNoCollInTimeRangeStandard))) { + continue; + } + if (additionalEvSel6 && (!c1.selection_bit(aod::evsel::kNoCollInRofStandard) || !c2.selection_bit(aod::evsel::kNoCollInRofStandard))) { + continue; + } + int occupancy1 = c1.trackOccupancyInTimeRange(); + int occupancy2 = c2.trackOccupancyInTimeRange(); + + if (fillOccupancy && (occupancy1 > cfgCutOccupancy || occupancy2 > cfgCutOccupancy)) { + continue; + } + float multiplicity; + multiplicity = c1.centFT0M(); + for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + bool unlike = false; + bool mix = true; + if (!selectionTrack(t1)) { continue; } - if (!ispTdepPID && !selectionPID(track1)) { + if (!selectionTrack(t2)) { continue; } - if (ispTdepPID && !selectionPIDpTdependent(track1)) { + if (!selectionPair(t1, t2)) { continue; } - if (!track1.has_mcParticle()) { - continue; + if (!ispTdepPID && selectionPID(t1) && selectionPID(t2)) { + fillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); } - auto track1ID = track1.index(); - for (auto track2 : Rectrackspart) { - auto track2ID = track2.index(); - if (track2ID <= track1ID) { - continue; - } - if (!selectionTrack(track2)) { - continue; - } + if (ispTdepPID && selectionPIDpTdependent(t1) && selectionPIDpTdependent(t2)) { + fillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); + } + } + } + } + + PROCESS_SWITCH(phianalysisrun3_PbPb, processMixedEvent3, "Process Mixed event", false); + void processMixedEvent4(EventCandidates const& collisions, TrackCandidates const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + //////// currently mixing the event with similar TPC multiplicity //////// + BinningTypeVertexContributor4 binningOnPositions{{axisVertex, axisMultiplicity}, true}; + SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; + for (const auto& [c1, tracks1, c2, tracks2] : pair) { + if (rctCut.requireRCTFlagChecker && !rctChecker(c1)) { + continue; + } + if (rctCut.requireRCTFlagChecker && !rctChecker(c2)) { + continue; + } + if (!c1.sel8()) { + continue; + } + if (!c2.sel8()) { + continue; + } + if (additionalEvSel1 && (!c1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c2.selection_bit(aod::evsel::kNoTimeFrameBorder))) { + continue; + } + if (additionalEvSel2 && (!c1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !c2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel3 && (!c1.selection_bit(aod::evsel::kNoSameBunchPileup) || !c2.selection_bit(aod::evsel::kNoSameBunchPileup))) { + continue; + } + if (additionalEvSel4 && (!c1.selection_bit(aod::evsel::kIsGoodITSLayersAll) || !c2.selection_bit(aod::evsel::kIsGoodITSLayersAll))) { + continue; + } + if (additionalEvSel5 && (!c1.selection_bit(aod::evsel::kNoCollInTimeRangeStandard) || !c2.selection_bit(aod::evsel::kNoCollInTimeRangeStandard))) { + continue; + } + if (additionalEvSel6 && (!c1.selection_bit(aod::evsel::kNoCollInRofStandard) || !c2.selection_bit(aod::evsel::kNoCollInRofStandard))) { + continue; + } + int occupancy1 = c1.trackOccupancyInTimeRange(); + int occupancy2 = c2.trackOccupancyInTimeRange(); + + if (fillOccupancy && (occupancy1 > cfgCutOccupancy || occupancy2 > cfgCutOccupancy)) { + continue; + } + float multiplicity; + multiplicity = c1.centFV0A(); + for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + bool unlike = false; + bool mix = true; + if (!selectionTrack(t1)) { + continue; + } + if (!selectionTrack(t2)) { + continue; + } + if (!selectionPair(t1, t2)) { + continue; + } + if (!ispTdepPID && selectionPID(t1) && selectionPID(t2)) { + fillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); + } + if (ispTdepPID && selectionPIDpTdependent(t1) && selectionPIDpTdependent(t2)) { + fillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); + } + } + } + } + + PROCESS_SWITCH(phianalysisrun3_PbPb, processMixedEvent4, "Process Mixed event", false); + void processRotEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + { + if (!collision.sel8()) { + return; + } + if (additionalEvSel2 && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + return; + } + if (additionalEvSel3 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + return; + } + int occupancy = collision.trackOccupancyInTimeRange(); + if (fillOccupancy && (occupancy > cfgCutOccupancy)) { + return; + } + float multiplicity{-1}; + if (cfgMultFT0) + multiplicity = collision.centFT0C(); + histos.fill(HIST("hCentrality"), multiplicity); + histos.fill(HIST("hVtxZ"), collision.posZ()); + histos.fill(HIST("hOccupancy"), occupancy); + for (const auto& track1 : tracks) { + + if (!selectionTrack(track1)) { + continue; + } + histos.fill(HIST("QAbefore/TPC_Nsigma_all"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAbefore/TOF_Nsigma_all"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("QAbefore/trkDCAxy"), track1.dcaXY()); + histos.fill(HIST("QAbefore/trkDCAz"), track1.dcaZ()); + histos.fill(HIST("QAbefore/TOF_TPC_Mapka_all"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + + auto track1ID = track1.globalIndex(); + for (const auto& track2 : tracks) { + if (!selectionTrack(track2)) { + continue; + } + auto track2ID = track2.globalIndex(); + if (track2ID <= track1ID) { + continue; + } + if (!selectionPair(track1, track2)) { + continue; + } + if (!ispTdepPID && (!selectionPID(track1) || !selectionPID(track2))) { + continue; + } + if (ispTdepPID && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { + continue; + } + if (track1.sign() * track2.sign() < 0) { + kaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + kaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } + phiMesonMother = kaonPlus + kaonMinus; + if (std::abs(phiMesonMother.Rapidity()) > confRapidity) { + continue; + } + histos.fill(HIST("h3PhiInvMassSame"), multiplicity, phiMesonMother.pt(), phiMesonMother.M()); + if (fillRotation) { + for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { + auto anglestart = confMinRot; + auto angleend = confMaxRot; + auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); + auto rotangle = anglestart + nrotbkg * anglestep; + if (track1.sign() * track2.sign() < 0) { + auto rotkaonPx = track1.px() * std::cos(rotangle) - track1.py() * std::sin(rotangle); + auto rotkaonPy = track1.px() * std::sin(rotangle) + track1.py() * std::cos(rotangle); + kaonPlus = ROOT::Math::PxPyPzMVector(rotkaonPx, rotkaonPy, track1.pz(), massKa); + kaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } + phiMesonMother = kaonPlus + kaonMinus; + if (std::abs(phiMesonMother.Rapidity()) > confRapidity) { + continue; + } + histos.fill(HIST("h3PhiInvMassRot"), multiplicity, phiMesonMother.pt(), phiMesonMother.M()); + } + } + } + } + } + + PROCESS_SWITCH(phianalysisrun3_PbPb, processRotEvent, "Process Rot event", false); + void processMC(CollisionMCTrueTable::iterator const& /*TrueCollision*/, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + { + histos.fill(HIST("hMC"), 0); + if (RecCollisions.size() == 0) { + histos.fill(HIST("hMC"), 1); + return; + } + if (RecCollisions.size() > 1) { + histos.fill(HIST("hMC"), 2); + return; + } + for (const auto& RecCollision : RecCollisions) { + histos.fill(HIST("hMC"), 3); + if (!RecCollision.sel8()) { + histos.fill(HIST("hMC"), 4); + continue; + } + if (timFrameEvsel && (!RecCollision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + histos.fill(HIST("hMC"), 5); + continue; + } + if (additionalEvSel2 && (!RecCollision.selection_bit(aod::evsel::kNoSameBunchPileup) || !RecCollision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + int occupancy = RecCollision.trackOccupancyInTimeRange(); + if (fillOccupancy && (occupancy > cfgCutOccupancy)) { + continue; + } + if (std::abs(RecCollision.posZ()) > cfgCutVertex) { + histos.fill(HIST("hMC"), 6); + continue; + } + histos.fill(HIST("hMC"), 7); + auto centrality = RecCollision.centFT0C(); + auto oldindex = -999; + auto rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); + // loop over reconstructed particle + for (const auto& track1 : rectrackspart) { + if (!selectionTrack(track1)) { + continue; + } + if (!ispTdepPID && !selectionPID(track1)) { + continue; + } + if (ispTdepPID && !selectionPIDpTdependent(track1)) { + continue; + } + if (!track1.has_mcParticle()) { + continue; + } + auto track1ID = track1.index(); + for (const auto& track2 : rectrackspart) { + auto track2ID = track2.index(); + if (track2ID <= track1ID) { + continue; + } + if (!selectionTrack(track2)) { + continue; + } if (!ispTdepPID && !selectionPID(track2)) { continue; } @@ -453,29 +984,29 @@ struct phianalysisrun3_PbPb { } const auto mctrack1 = track1.mcParticle(); const auto mctrack2 = track2.mcParticle(); - int track1PDG = TMath::Abs(mctrack1.pdgCode()); - int track2PDG = TMath::Abs(mctrack2.pdgCode()); + int track1PDG = std::abs(mctrack1.pdgCode()); + int track2PDG = std::abs(mctrack2.pdgCode()); if (!mctrack1.isPhysicalPrimary()) { continue; } if (!mctrack2.isPhysicalPrimary()) { continue; } - if (!(track1PDG == 321 && track2PDG == 321)) { + if (!(track1PDG == PDG_t::kKPlus && track2PDG == PDG_t::kKPlus)) { continue; } - for (auto& mothertrack1 : mctrack1.mothers_as()) { - for (auto& mothertrack2 : mctrack2.mothers_as()) { + for (const auto& mothertrack1 : mctrack1.mothers_as()) { + for (const auto& mothertrack2 : mctrack2.mothers_as()) { if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) { continue; } if (mothertrack1 != mothertrack2) { continue; } - if (TMath::Abs(mothertrack1.y()) > confRapidity) { + if (std::abs(mothertrack1.y()) > confRapidity) { continue; } - if (TMath::Abs(mothertrack1.pdgCode()) != 333) { + if (pdgcheck && std::abs(mothertrack1.pdgCode()) != o2::constants::physics::kPhi) { continue; } if (!ispTdepPID && (!selectionPID(track1) || !selectionPID(track2))) { @@ -489,68 +1020,69 @@ struct phianalysisrun3_PbPb { continue; } oldindex = mothertrack1.globalIndex(); - if (track1.sign() > 0 && track2.sign() < 0) { - KaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); - KaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); - } - if (track1.sign() < 0 && track2.sign() > 0) { - KaonMinus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); - KaonPlus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + if (track1.sign() * track2.sign() < 0) { + kaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + kaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); } - PhiMesonMother = KaonPlus + KaonMinus; + phiMesonMother = kaonPlus + kaonMinus; - if (TMath::Abs(PhiMesonMother.Rapidity()) > confRapidity) { + if (std::abs(phiMesonMother.Rapidity()) > confRapidity) { continue; } - histos.fill(HIST("h1PhiRec1"), PhiMesonMother.pt()); - histos.fill(HIST("h2PhiRec2"), PhiMesonMother.pt(), centrality); - histos.fill(HIST("h1Phimassrec"), PhiMesonMother.M()); - histos.fill(HIST("h3PhiRec3"), PhiMesonMother.pt(), centrality, PhiMesonMother.M()); + histos.fill(HIST("h1PhiRec1"), phiMesonMother.pt()); + histos.fill(HIST("h2PhiRec2"), phiMesonMother.pt(), centrality); + histos.fill(HIST("h1Phimassrec"), phiMesonMother.M()); + histos.fill(HIST("h3PhiRec3"), phiMesonMother.pt(), centrality, phiMesonMother.M()); + histos.fill(HIST("Centrec"), centrality); } } } } // loop over generated particle - for (auto& mcParticle : GenParticles) { - if (TMath::Abs(mcParticle.y()) > confRapidity) { + for (const auto& mcParticle : GenParticles) { + if (std::abs(mcParticle.y()) > confRapidity) { continue; } - if (mcParticle.pdgCode() != 333) { + if (pdgcheck && mcParticle.pdgCode() != o2::constants::physics::kPhi) { continue; } auto kDaughters = mcParticle.daughters_as(); - if (kDaughters.size() != 2) { + const size_t kExpectedDaughterCount = 2; + + if (kDaughters.size() != kExpectedDaughterCount) { + continue; } auto daughtp = false; auto daughtm = false; - for (auto kCurrentDaughter : kDaughters) { + for (const auto& kCurrentDaughter : kDaughters) { if (!kCurrentDaughter.isPhysicalPrimary()) { continue; } - if (kCurrentDaughter.pdgCode() == +321) { - if (genacceptancecut && kCurrentDaughter.pt() > cfgCutPT && TMath::Abs(kCurrentDaughter.eta()) < cfgCutEta) { + if (kCurrentDaughter.pdgCode() == PDG_t::kKPlus) { + if (genacceptancecut && kCurrentDaughter.pt() > cfgCutPT && std::abs(kCurrentDaughter.eta()) < cfgCutEta) { daughtp = true; } if (!genacceptancecut) { daughtp = true; } - KaonPlus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); - } else if (kCurrentDaughter.pdgCode() == -321) { - if (genacceptancecut && kCurrentDaughter.pt() > cfgCutPT && TMath::Abs(kCurrentDaughter.eta()) < cfgCutEta) { + kaonPlus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); + } else if (kCurrentDaughter.pdgCode() == PDG_t::kKMinus) { + if (genacceptancecut && kCurrentDaughter.pt() > cfgCutPT && std::abs(kCurrentDaughter.eta()) < cfgCutEta) { daughtm = true; } if (!genacceptancecut) { daughtm = true; } - KaonMinus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); + kaonMinus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); } } if (daughtp && daughtm) { - PhiMesonMother = KaonPlus + KaonMinus; - histos.fill(HIST("h1PhiGen"), PhiMesonMother.pt()); - histos.fill(HIST("h2PhiGen2"), PhiMesonMother.pt(), centrality); - histos.fill(HIST("h1Phimassgen"), PhiMesonMother.M()); + phiMesonMother = kaonPlus + kaonMinus; + histos.fill(HIST("h1PhiGen"), phiMesonMother.pt()); + histos.fill(HIST("h2PhiGen2"), phiMesonMother.pt(), centrality); + histos.fill(HIST("Centgen"), centrality); + histos.fill(HIST("h1Phimassgen"), phiMesonMother.M()); } } } // rec collision loop @@ -559,70 +1091,84 @@ struct phianalysisrun3_PbPb { PROCESS_SWITCH(phianalysisrun3_PbPb, processMC, "Process Reconstructed", false); void processGen(aod::McCollision const& mcCollision, aod::McParticles& mcParticles, const soa::SmallGroups& collisions) { + histos.fill(HIST("hMC"), 0.5); if (std::abs(mcCollision.posZ()) < cfgCutVertex) { histos.fill(HIST("hMC"), 1.5); } - int Nchinel = 0; - for (auto& mcParticle : mcParticles) { - auto pdgcode = std::abs(mcParticle.pdgCode()); - if (mcParticle.isPhysicalPrimary() && (pdgcode == 211 || pdgcode == 321 || pdgcode == 2212 || pdgcode == 11 || pdgcode == 13)) { - if (std::abs(mcParticle.eta()) < 1.0) { - Nchinel = Nchinel + 1; - } - } - } - if (Nchinel > 0 && std::abs(mcCollision.posZ()) < cfgCutVertex) - histos.fill(HIST("hMC"), 2.5); - std::vector SelectedEvents(collisions.size()); + float imp = mcCollision.impactParameter(); + histos.fill(HIST("hImpactParameterGen"), imp); + std::vector selectedEvents(collisions.size()); int nevts = 0; auto multiplicity = 0; for (const auto& collision : collisions) { if (!collision.sel8() || std::abs(collision.mcCollision().posZ()) > cfgCutVertex) { continue; } + if (additionalEvSel2 && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } int occupancy = collision.trackOccupancyInTimeRange(); - if (fillOccupancy && !(occupancy > cfgOccupancyCut1 && occupancy < cfgOccupancyCut2)) { - return; + if (fillOccupancy && (occupancy > cfgCutOccupancy)) { + continue; } histos.fill(HIST("hOccupancy1"), occupancy); multiplicity = collision.centFT0C(); histos.fill(HIST("Centgen"), multiplicity); - SelectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); + histos.fill(HIST("hVtxZgen"), collision.mcCollision().posZ()); + histos.fill(HIST("hImpactParameterGenCen"), imp, multiplicity); + + selectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); + histos.fill(HIST("hMC"), 2.5); } - SelectedEvents.resize(nevts); - const auto evtReconstructedAndSelected = std::find(SelectedEvents.begin(), SelectedEvents.end(), mcCollision.globalIndex()) != SelectedEvents.end(); - histos.fill(HIST("hMC"), 3.5); - if (!evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection + selectedEvents.resize(nevts); + + const auto evtReconstructedAndSelected = std::find(selectedEvents.begin(), selectedEvents.end(), mcCollision.globalIndex()) != selectedEvents.end(); + histos.fill(HIST("EL1"), imp); + histos.fill(HIST("EL2"), multiplicity); + if (reco && !evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection return; } - histos.fill(HIST("hMC"), 4.5); - for (auto& mcParticle : mcParticles) { - if (std::abs(mcParticle.y()) >= 0.5) { + histos.fill(HIST("ES1"), imp); + histos.fill(HIST("ES2"), multiplicity); + for (const auto& mcParticle : mcParticles) { + const double kMaxAcceptedRapidity = 0.5; + + if (std::abs(mcParticle.y()) >= kMaxAcceptedRapidity) { + continue; } - if (mcParticle.pdgCode() != 333) { + if (pdgcheck && mcParticle.pdgCode() != o2::constants::physics::kPhi) { continue; } auto kDaughters = mcParticle.daughters_as(); - if (kDaughters.size() != 2) { + const size_t kExpectedNumberOfDaughters = 2; + + if (kDaughters.size() != kExpectedNumberOfDaughters) { + continue; } auto daughtp = false; auto daughtm = false; - for (auto kCurrentDaughter : kDaughters) { + for (const auto& kCurrentDaughter : kDaughters) { if (!kCurrentDaughter.isPhysicalPrimary()) { continue; } - if (kCurrentDaughter.pdgCode() == +321) { + if (kCurrentDaughter.pdgCode() == PDG_t::kKPlus) { daughtp = true; - } else if (kCurrentDaughter.pdgCode() == -321) { + kaonPlus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); + } else if (kCurrentDaughter.pdgCode() == PDG_t::kKMinus) { daughtm = true; + kaonMinus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); } } if (daughtp && daughtm) { - histos.fill(HIST("h1PhiGen"), mcParticle.pt()); - histos.fill(HIST("h2PhiGen2"), mcParticle.pt(), multiplicity); + phiMesonMother = kaonPlus + kaonMinus; + histos.fill(HIST("h1PhiGen"), phiMesonMother.pt()); + histos.fill(HIST("h2PhiGen2"), phiMesonMother.pt(), multiplicity); + histos.fill(HIST("h2PhiGen1"), phiMesonMother.pt(), imp); + histos.fill(HIST("h1Phimassgen"), phiMesonMother.M()); + histos.fill(HIST("h3PhiGen3"), phiMesonMother.pt(), multiplicity, phiMesonMother.M()); } } } @@ -635,15 +1181,23 @@ struct phianalysisrun3_PbPb { if (std::abs(collision.mcCollision().posZ()) > cfgCutVertex || !collision.sel8()) { return; } + if (additionalEvSel2 && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + return; + } int occupancy = collision.trackOccupancyInTimeRange(); - if (fillOccupancy && !(occupancy > cfgOccupancyCut1 && occupancy < cfgOccupancyCut2)) { + if (fillOccupancy && (occupancy > cfgCutOccupancy)) { return; } auto multiplicity = collision.centFT0C(); histos.fill(HIST("Centrec"), multiplicity); - histos.fill(HIST("hMC"), 5.5); + histos.fill(HIST("hVtxZrec"), collision.posZ()); + float imp = collision.mcCollision().impactParameter(); + histos.fill(HIST("hImpactParameterRec"), imp); + histos.fill(HIST("hImpactParameterRecCen"), imp, multiplicity); + histos.fill(HIST("ES3"), imp); + histos.fill(HIST("ES4"), multiplicity); auto oldindex = -999; - for (auto track1 : tracks) { + for (const auto& track1 : tracks) { if (!selectionTrack(track1)) { continue; } @@ -651,7 +1205,7 @@ struct phianalysisrun3_PbPb { continue; } auto track1ID = track1.index(); - for (auto track2 : tracks) { + for (const auto& track2 : tracks) { if (!track2.has_mcParticle()) { continue; } @@ -678,11 +1232,17 @@ struct phianalysisrun3_PbPb { if (!mctrack2.isPhysicalPrimary()) { continue; } - if (!(track1PDG == 321 && track2PDG == 321)) { + if (!(track1PDG == PDG_t::kKPlus && track2PDG == PDG_t::kKPlus)) { continue; } - for (auto& mothertrack1 : mctrack1.mothers_as()) { - for (auto& mothertrack2 : mctrack2.mothers_as()) { + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + + phiMother = daughter1 + daughter2; + histos.fill(HIST("h1Phi1massrec"), phiMother.M()); + histos.fill(HIST("h3Phi1Rec3"), phiMother.pt(), multiplicity, phiMother.M()); + for (const auto& mothertrack1 : mctrack1.mothers_as()) { + for (const auto& mothertrack2 : mctrack2.mothers_as()) { if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) { continue; } @@ -692,10 +1252,13 @@ struct phianalysisrun3_PbPb { if (!mothertrack1.producedByGenerator()) { continue; } - if (std::abs(mothertrack1.y()) >= 0.5) { + const double kMaxRapidityCut = 0.5; + + if (std::abs(mothertrack1.y()) >= kMaxRapidityCut) { continue; } - if (std::abs(mothertrack1.pdgCode()) != 333) { + + if (pdgcheck && std::abs(mothertrack1.pdgCode()) != o2::constants::physics::kPhi) { continue; } if (!ispTdepPID && (!selectionPID(track1) || !selectionPID(track2))) { @@ -704,31 +1267,448 @@ struct phianalysisrun3_PbPb { if (ispTdepPID && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { continue; } + + histos.fill(HIST("TPC_Nsigma_MC"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("TOF_Nsigma_MC"), track1.tofNSigmaKa(), multiplicity, track1.pt()); if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { histos.fill(HIST("h1PhiRecsplit"), mothertrack1.pt()); continue; } oldindex = mothertrack1.globalIndex(); - pvec0 = array{track1.px(), track1.py(), track1.pz()}; - pvec1 = array{track2.px(), track2.py(), track2.pz()}; - auto arrMomrec = array{pvec0, pvec1}; + if (track1.sign() * track2.sign() < 0) { + kaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + kaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } + phiMesonMother = kaonPlus + kaonMinus; + + if (std::abs(phiMesonMother.Rapidity()) > confRapidity) { + continue; + } + histos.fill(HIST("h1PhiRec1"), phiMesonMother.pt()); + histos.fill(HIST("h2PhiRec2"), phiMesonMother.pt(), multiplicity); + histos.fill(HIST("h1Phimassrec"), phiMesonMother.M()); + histos.fill(HIST("h3PhiRec3"), phiMesonMother.pt(), multiplicity, phiMesonMother.M()); + } + } + } + } + } + + PROCESS_SWITCH(phianalysisrun3_PbPb, processRec, "Process Reconstructed", false); + void processSameEventMC(EventCandidatesMC::iterator const& collision, TrackCandidatesMC const& tracks, aod::McParticles const& /*mcParticles*/, aod::McCollisions const& /*mcCollisions*/) + { + if (!collision.sel8()) { + return; + } + if (additionalEvSel1 && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return; + } + if (additionalEvSel2 && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return; + } + if (additionalEvSel3 && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return; + } + if (additionalEvSel4 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + if (additionalEvSel5 && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return; + } + if (additionalEvSel6 && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return; + } + int occupancy = collision.trackOccupancyInTimeRange(); + if (fillOccupancy && (occupancy > cfgCutOccupancy)) { + return; + } + float multiplicity{-1}; + multiplicity = collision.centFT0C(); + for (const auto& track1 : tracks) { + if (!selectionTrack(track1)) { + continue; + } + auto track1ID = track1.globalIndex(); + for (const auto& track2 : tracks) { + if (!selectionTrack(track2)) { + continue; + } + auto track2ID = track2.globalIndex(); + if (track2ID <= track1ID) { + continue; + } + if (!selectionPair(track1, track2)) { + continue; + } + if (!ispTdepPID && (!selectionPID(track1) || !selectionPID(track2))) { + continue; + } + if (ispTdepPID && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { + continue; + } + if (track1.sign() * track2.sign() < 0) { + kaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + kaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } + phiMesonMother = kaonPlus + kaonMinus; + if (std::abs(phiMesonMother.Rapidity()) > confRapidity) { + continue; + } + histos.fill(HIST("h3PhiInvMassSameMC"), multiplicity, phiMesonMother.pt(), phiMesonMother.M()); + histos.fill(HIST("h1Phimasssame"), phiMesonMother.M()); + if (fillRotation) { + for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { + auto anglestart = confMinRot; + auto angleend = confMaxRot; + auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); + auto rotangle = anglestart + nrotbkg * anglestep; + if (track1.sign() * track2.sign() < 0) { + auto rotkaonPx = track1.px() * std::cos(rotangle) - track1.py() * std::sin(rotangle); + auto rotkaonPy = track1.px() * std::sin(rotangle) + track1.py() * std::cos(rotangle); + kaonPlus = ROOT::Math::PxPyPzMVector(rotkaonPx, rotkaonPy, track1.pz(), massKa); + kaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } + phiMesonMother = kaonPlus + kaonMinus; + if (std::abs(phiMesonMother.Rapidity()) > confRapidity) { + continue; + } + histos.fill(HIST("h3PhiInvMassRotMC"), multiplicity, phiMesonMother.pt(), phiMesonMother.M()); + histos.fill(HIST("h1Phimassrot"), phiMesonMother.M()); + } + } + } + } + } + + PROCESS_SWITCH(phianalysisrun3_PbPb, processSameEventMC, "Process Same event", false); + void processMixedEventMC(EventCandidatesMC const& recCollisions, TrackCandidatesMC const& RecTracks, aod::McParticles const&) + { + + auto tracksTuple = std::make_tuple(RecTracks); + BinningTypeVertexContributor1 binningOnPositions{{axisVertex, axisMultiplicity}, true}; + SameKindPair pairs{binningOnPositions, cfgNoMixedEvents, -1, recCollisions, tracksTuple, &cache}; + + for (const auto& [c1, tracks1, c2, tracks2] : pairs) { + if (!c1.sel8()) { + continue; + } + if (!c2.sel8()) { + continue; + } + if (additionalEvSel1 && (!c1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !c2.selection_bit(aod::evsel::kNoTimeFrameBorder))) { + continue; + } + if (additionalEvSel2 && (!c1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !c2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel3 && (!c1.selection_bit(aod::evsel::kNoSameBunchPileup) || !c2.selection_bit(aod::evsel::kNoSameBunchPileup))) { + continue; + } + if (additionalEvSel4 && (!c1.selection_bit(aod::evsel::kIsGoodITSLayersAll) || !c2.selection_bit(aod::evsel::kIsGoodITSLayersAll))) { + continue; + } + if (additionalEvSel5 && (!c1.selection_bit(aod::evsel::kNoCollInTimeRangeStandard) || !c2.selection_bit(aod::evsel::kNoCollInTimeRangeStandard))) { + continue; + } + if (additionalEvSel6 && (!c1.selection_bit(aod::evsel::kNoCollInRofStandard) || !c2.selection_bit(aod::evsel::kNoCollInRofStandard))) { + continue; + } + int occupancy1 = c1.trackOccupancyInTimeRange(); + int occupancy2 = c2.trackOccupancyInTimeRange(); + if (fillOccupancy && (occupancy1 > cfgCutOccupancy)) { + continue; + } + if (fillOccupancy && (occupancy2 > cfgCutOccupancy)) { + continue; + } + auto multiplicity = c1.centFT0C(); + for (const auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + histos.fill(HIST("hMC"), 6.5); + if (!selectionTrack(t1)) { + continue; + } + if (!selectionTrack(t2)) { + continue; + } + if (!selectionPair(t1, t2)) { + continue; + } + if (!ispTdepPID && (!selectionPID(t1) || !selectionPID(t2))) { + continue; + } + if (ispTdepPID && (!selectionPIDpTdependent(t1) || !selectionPIDpTdependent(t2))) { + continue; + } + if (t1.sign() * t2.sign() < 0) { + kaonPlus = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), massKa); + kaonMinus = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), massKa); + } + phiMesonMother = kaonPlus + kaonMinus; + if (std::abs(phiMesonMother.Rapidity()) > confRapidity) { + continue; + } + histos.fill(HIST("h3PhiInvMassMixedMC"), multiplicity, phiMesonMother.pt(), phiMesonMother.M()); + histos.fill(HIST("h1Phimassmix"), phiMesonMother.M()); + } + } + } + PROCESS_SWITCH(phianalysisrun3_PbPb, processMixedEventMC, "Process Mixed event MC", true); + void processGen1(aod::McCollision const& mcCollision, aod::McParticles& mcParticles, const soa::SmallGroups& collisions) + { + histos.fill(HIST("hMC1"), 0.5); + if (std::abs(mcCollision.posZ()) < cfgCutVertex) { + histos.fill(HIST("hMC1"), 1.5); + } + std::vector selectedEvents(collisions.size()); + int nevts = 0; + auto multiplicity = -1.0; + histos.fill(HIST("Centgen1"), multiplicity); + histos.fill(HIST("hMC1"), 2.5); + for (const auto& collision : collisions) { + if (!collision.sel8() || std::abs(collision.mcCollision().posZ()) > cfgCutVertex) { + continue; + } + histos.fill(HIST("hMC1"), 3.5); + if (additionalEvSel1 && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + continue; + } + histos.fill(HIST("hMC1"), 4.5); + if (additionalEvSel2 && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + continue; + } + histos.fill(HIST("hMC1"), 5.5); + if (additionalEvSel3 && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + continue; + } + histos.fill(HIST("hMC1"), 6.5); + if (additionalEvSel4 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + histos.fill(HIST("hMC1"), 7.5); + if (additionalEvSel5 && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + histos.fill(HIST("hMC1"), 8.5); + if (additionalEvSel6 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + histos.fill(HIST("hMC1"), 9.5); + int occupancy = collision.trackOccupancyInTimeRange(); + if (fillOccupancy && (occupancy > cfgCutOccupancy)) { + continue; + } + histos.fill(HIST("hMC1"), 10.5); + multiplicity = collision.centFT0C(); + selectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); + } + selectedEvents.resize(nevts); + const auto evtReconstructedAndSelected = std::find(selectedEvents.begin(), selectedEvents.end(), mcCollision.globalIndex()) != selectedEvents.end(); + histos.fill(HIST("hMC1"), 11.5); + if (!evtReconstructedAndSelected) { // Check that the event is reconstructed and that the reconstructed events pass the selection + return; + } + histos.fill(HIST("hMC1"), 12.5); + for (const auto& mcParticle : mcParticles) { + const double kMaxRapidityCut = 0.5; + + if (std::abs(mcParticle.y()) >= kMaxRapidityCut) { + continue; + } + + if (mcParticle.pdgCode() != o2::constants::physics::kPhi) { + continue; + } + auto kDaughters = mcParticle.daughters_as(); + const size_t kExpectedNumberOfDaughters = 2; + + if (kDaughters.size() != kExpectedNumberOfDaughters) { + + continue; + } + auto daughtp = false; + auto daughtm = false; + for (const auto& kCurrentDaughter : kDaughters) { + if (!kCurrentDaughter.isPhysicalPrimary()) { + continue; + } + if (kCurrentDaughter.pdgCode() == PDG_t::kKPlus) { + daughtp = true; + } else if (kCurrentDaughter.pdgCode() == PDG_t::kKMinus) { + daughtm = true; + } + } + if (daughtp && daughtm) { + histos.fill(HIST("h1PhifinalGen"), mcParticle.pt()); + histos.fill(HIST("h2PhifinalGen"), mcParticle.pt(), multiplicity); + } + } + } + + PROCESS_SWITCH(phianalysisrun3_PbPb, processGen1, "Process Generated", false); + void processRec1(EventCandidatesMC::iterator const& collision, TrackCandidatesMC const& tracks, aod::McParticles const& /*mcParticles*/, aod::McCollisions const& /*mcCollisions*/) + { + if (!collision.has_mcCollision()) { + return; + } + if (std::abs(collision.mcCollision().posZ()) > cfgCutVertex || !collision.sel8()) { + return; + } + if (additionalEvSel1 && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return; + } + + if (additionalEvSel2 && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return; + } + + if (additionalEvSel3 && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return; + } + + if (additionalEvSel4 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + if (additionalEvSel5 && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return; + } + if (additionalEvSel6 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + int occupancy = collision.trackOccupancyInTimeRange(); + if (fillOccupancy && (occupancy > cfgCutOccupancy)) { + return; + } + auto multiplicity = collision.centFT0C(); + histos.fill(HIST("Centrec1"), multiplicity); + histos.fill(HIST("hMC1"), 13.5); + auto oldindex = -999; + for (const auto& track1 : tracks) { + if (!selectionTrack(track1)) { + continue; + } + if (!track1.has_mcParticle()) { + continue; + } + auto track1ID = track1.index(); + for (const auto& track2 : tracks) { + if (!track2.has_mcParticle()) { + continue; + } + if (!selectionTrack(track2)) { + continue; + } + auto track2ID = track2.index(); + if (track2ID <= track1ID) { + continue; + } + if (!selectionPair(track1, track2)) { + continue; + } + if (track1.sign() * track2.sign() > 0) { + continue; + } + const auto mctrack1 = track1.mcParticle(); + const auto mctrack2 = track2.mcParticle(); + int track1PDG = std::abs(mctrack1.pdgCode()); + int track2PDG = std::abs(mctrack2.pdgCode()); + if (!mctrack1.isPhysicalPrimary()) { + continue; + } + if (!mctrack2.isPhysicalPrimary()) { + continue; + } + if (!(track1PDG == PDG_t::kKPlus && track2PDG == PDG_t::kKPlus)) { + continue; + } + for (const auto& mothertrack1 : mctrack1.mothers_as()) { + for (const auto& mothertrack2 : mctrack2.mothers_as()) { + if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) { + continue; + } + if (mothertrack1.globalIndex() != mothertrack2.globalIndex()) { + continue; + } + if (!mothertrack1.producedByGenerator()) { + continue; + } + const double kMaxRapidityCut = 0.5; + + if (std::abs(mothertrack1.y()) >= kMaxRapidityCut) { + continue; + } + + if (std::abs(mothertrack1.pdgCode()) != o2::constants::physics::kPhi) { + continue; + } + if (!(selectionPID(track1) && selectionPID(track2))) { + continue; + } + histos.fill(HIST("TPC_Nsigma1_MC"), track1.tpcNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("TOF_Nsigma1_MC"), track1.tofNSigmaKa(), multiplicity, track1.pt()); + histos.fill(HIST("trkDCAxy"), track1.dcaXY()); + histos.fill(HIST("trkDCAz"), track1.dcaZ()); + if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { + histos.fill(HIST("h1PhiRecsplit1"), mothertrack1.pt()); + continue; + } + oldindex = mothertrack1.globalIndex(); + std::array pvec0 = {track1.px(), track1.py(), track1.pz()}; + std::array pvec1 = {track2.px(), track2.py(), track2.pz()}; + std::array, 2> arrMomrec = {pvec0, pvec1}; + auto motherP = mothertrack1.p(); auto motherE = mothertrack1.e(); genMass = std::sqrt(motherE * motherE - motherP * motherP); recMass = RecoDecay::m(arrMomrec, array{massKa, massKa}); - auto recpt = TMath::Sqrt((track1.px() + track2.px()) * (track1.px() + track2.px()) + (track1.py() + track2.py()) * (track1.py() + track2.py())); - histos.fill(HIST("h1PhiRec1"), mothertrack1.pt()); - histos.fill(HIST("h2PhiRec2"), mothertrack1.pt(), multiplicity); - histos.fill(HIST("h1Phimassgen"), genMass); - histos.fill(HIST("h1Phimassrec"), recMass); - histos.fill(HIST("h1Phipt"), recpt); + + histos.fill(HIST("h1PhifinalRec"), mothertrack1.pt()); + histos.fill(HIST("h3PhifinalRec"), mothertrack1.pt(), multiplicity, recMass); + histos.fill(HIST("h1Phifinalgenmass"), genMass); } } } } } - PROCESS_SWITCH(phianalysisrun3_PbPb, processRec, "Process Reconstructed", false); + PROCESS_SWITCH(phianalysisrun3_PbPb, processRec1, "Process Reconstructed", false); + void processEvtLossSigLossMC(aod::McCollisions::iterator const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& recCollisions) + { + + // Event loss estimation + auto impactPar = mcCollision.impactParameter(); + histos.fill(HIST("QAevent/hImpactParameterGen"), impactPar); + + bool isSel = false; + auto centrality = -999.; + for (const auto& RecCollision : recCollisions) { + if (!myEventSelections(RecCollision)) + continue; + centrality = RecCollision.centFT0C(); + isSel = true; + } + + if (isSel) { + histos.fill(HIST("QAevent/hImpactParameterRec"), impactPar); + histos.fill(HIST("QAevent/hImpactParvsCentrRec"), centrality, impactPar); + } + + // Generated MC + for (const auto& mcPart : mcParticles) { + const double kMaxRapidity = 0.5; + + if (std::abs(mcPart.y()) >= kMaxRapidity || std::abs(mcPart.pdgCode()) != o2::constants::physics::kPhi) + + continue; + + // signal loss estimation + histos.fill(HIST("QAevent/phigenBeforeEvtSel"), mcPart.pt(), impactPar); + if (isSel) { + // signal loss estimation + histos.fill(HIST("QAevent/phigenAfterEvtSel"), mcPart.pt(), impactPar); + } + } // end loop on gen particles + } + PROCESS_SWITCH(phianalysisrun3_PbPb, processEvtLossSigLossMC, "Process Signal Loss, Event Loss", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGLF/Tasks/Resonances/phipbpb.cxx b/PWGLF/Tasks/Resonances/phipbpb.cxx index 350d6664115..521e505ebd2 100644 --- a/PWGLF/Tasks/Resonances/phipbpb.cxx +++ b/PWGLF/Tasks/Resonances/phipbpb.cxx @@ -11,49 +11,54 @@ // Phi meson spin alignment task // sourav.kundu@cern.ch -#include +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/SPCalibrationTables.h" +#include "PWGMM/Mult/DataModel/Index.h" // for Particles2Tracks table + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TRandom3.h" +#include #include +#include +#include +#include #include #include #include #include -#include -#include -#include #include -#include -#include + #include +#include #include -#include #include - -#include "TRandom3.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" -#include "TF1.h" - -#include "PWGLF/DataModel/EPCalibrationTables.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/Core/TrackSelection.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" +#include using namespace o2; using namespace o2::framework; @@ -64,22 +69,38 @@ struct phipbpb { int mRunNumber; int multEstimator; float d_bz; + + struct : ConfigurableGroup { + Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; + } cfgCcdbParam; + + // Enable access to the CCDB for the offset and correction constants and save them in dedicated variables. Service ccdb; + o2::ccdb::CcdbApi ccdbApi; Service pdg; // CCDB options - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + // Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + // Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + // Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + // Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + // Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + // filling + Configurable fillSA{"fillSA", false, "fill spin alignment"}; // events Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgCutCentrality{"cfgCutCentrality", 80.0f, "Accepted maximum Centrality"}; Configurable cfgCutOccupancy{"cfgCutOccupancy", 3000, "Occupancy cut"}; // track + Configurable cqvas{"cqvas", false, "change q vectors after shift correction"}; + Configurable fillv1{"fillv1", false, "flag to fill v1 histograms"}; + Configurable fillLOCC{"fillLOCC", false, "flag to fill LOCC histograms"}; + Configurable useSP{"useSP", false, "use SP"}; + Configurable useDcaSyst{"useDcaSyst", false, "useDcaSyst"}; Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; + Configurable additionalEvselITS{"additionalEvselITS", true, "Additional event selcection for ITS"}; Configurable removefaketrak{"removefaketrack", true, "Remove fake track from momentum difference"}; Configurable ConfFakeKaonCut{"ConfFakeKaonCut", 0.1, "Cut based on track from momentum difference"}; Configurable useGlobalTrack{"useGlobalTrack", true, "use Global track"}; @@ -94,23 +115,35 @@ struct phipbpb { Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 1, "Number of mixed events per event"}; Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; + Configurable cfgTPCSharedcluster{"cfgTPCSharedcluster", 0.4, "Maximum Number of TPC shared cluster"}; Configurable isDeepAngle{"isDeepAngle", false, "Deep Angle cut"}; Configurable ispTdepPID{"ispTdepPID", true, "pT dependent PID"}; + Configurable isTOFOnly{"isTOFOnly", false, "use TOF only PID"}; + Configurable checkAllCharge{"checkAllCharge", true, "check all charge for MC weight"}; Configurable cfgDeepAngle{"cfgDeepAngle", 0.04, "Deep Angle cut value"}; Configurable confRapidity{"confRapidity", 0.5, "Rapidity cut"}; - ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {120, 0.98, 1.1}, "#it{M} (GeV/#it{c}^{2})"}; - ConfigurableAxis configThnAxisPt{"configThnAxisPt", {100, 0.0, 10.}, "#it{p}_{T} (GeV/#it{c})"}; - ConfigurableAxis configThnAxisCosThetaStar{"configThnAxisCosThetaStar", {10, -1.0, 1.}, "cos(#vartheta)"}; - ConfigurableAxis configThnAxisCentrality{"configThnAxisCentrality", {8, 0., 80}, "Centrality"}; - ConfigurableAxis configThnAxisPhiminusPsi{"configThnAxisPhiminusPsi", {6, 0.0, TMath::Pi()}, "#phi - #psi"}; - ConfigurableAxis configThnAxisV2{"configThnAxisV2", {200, -1, 1}, "V2"}; - ConfigurableAxis configThnAxisRapidity{"configThnAxisRapidity", {8, 0, 0.8}, "Rapidity"}; - ConfigurableAxis configThnAxisSA{"configThnAxisSA", {200, -1, 1}, "SA"}; - ConfigurableAxis configThnAxiscosthetaSA{"configThnAxiscosthetaSA", {200, 0, 1}, "costhetaSA"}; + struct : ConfigurableGroup { + ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {120, 0.98, 1.1}, "#it{M} (GeV/#it{c}^{2})"}; + ConfigurableAxis configThnAxisPt{"configThnAxisPt", {100, 0.0, 10.}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis configThnAxisCosThetaStar{"configThnAxisCosThetaStar", {10, -1.0, 1.}, "cos(#vartheta)"}; + ConfigurableAxis configThnAxisCentrality{"configThnAxisCentrality", {8, 0., 80}, "Centrality"}; + ConfigurableAxis configThnAxisPhiminusPsi{"configThnAxisPhiminusPsi", {6, 0.0, TMath::Pi()}, "#phi - #psi"}; + ConfigurableAxis configThnAxisV2{"configThnAxisV2", {200, -6, 6}, "V2"}; + ConfigurableAxis configThnAxisRapidity{"configThnAxisRapidity", {8, 0, 0.8}, "Rapidity"}; + ConfigurableAxis configThnAxisSA{"configThnAxisSA", {200, -1, 1}, "SA"}; + ConfigurableAxis configThnAxiscosthetaSA{"configThnAxiscosthetaSA", {200, 0, 1}, "costhetaSA"}; + } cnfgaxis; + ConfigurableAxis axisPtKaonWeight{"axisPtKaonWeight", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f}, "pt axis"}; Configurable isMC{"isMC", false, "use MC"}; Configurable genacceptancecut{"genacceptancecut", true, "use acceptance cut for generated"}; Configurable avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"}; Configurable islike{"islike", false, "use like"}; + Configurable useWeight{"useWeight", true, "use EP dep effi weight"}; + Configurable ConfWeightPath{"ConfWeightPath", "Users/s/skundu/My/Object/mcweight", "Path to gain calibration"}; + Configurable spNbins{"spNbins", 2000, "Number of bins in sp"}; + Configurable lbinsp{"lbinsp", -1.0, "lower bin value in sp histograms"}; + Configurable hbinsp{"hbinsp", 1.0, "higher bin value in sp histograms"}; + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter centralityFilter = nabs(aod::cent::centFT0C) < cfgCutCentrality; Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPT); @@ -118,14 +151,15 @@ struct phipbpb { Filter PIDcutFilter = nabs(aod::pidtpc::tpcNSigmaKa) < nsigmaCutTPC; using EventCandidates = soa::Filtered>; + using EventCandidatesv1 = soa::Filtered>; using TrackCandidates = soa::Filtered>; using CollisionMCTrueTable = aod::McCollisions; using TrackMCTrueTable = aod::McParticles; + using CollisionMCRecTableCentFT0C = soa::SmallGroups>; using TrackMCRecTable = soa::Join; using FilTrackMCRecTable = soa::Filtered; - Preslice perCollision = aod::track::collisionId; SliceCache cache; @@ -144,84 +178,183 @@ struct phipbpb { void init(o2::framework::InitContext&) { // std::vector occupancyBinning = {0.0, 500.0, 1000.0, 3000.0, 6000.0, 50000.0}; - std::vector occupancyBinning = {0.0, 500.0, 1000.0, 1500.0, 2000.0, 3000.0, 4000.0, 5000.0, 50000.0}; - const AxisSpec thnAxisInvMass{configThnAxisInvMass, "#it{M} (GeV/#it{c}^{2})"}; - const AxisSpec thnAxisPt{configThnAxisPt, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec thnAxisCosThetaStar{configThnAxisCosThetaStar, "cos(#vartheta_{OP})"}; - const AxisSpec thnAxisCentrality{configThnAxisCentrality, "Centrality (%)"}; - const AxisSpec thnAxisV2{configThnAxisV2, "V2"}; - const AxisSpec thnAxisRapidity{configThnAxisRapidity, "Rapidity"}; - const AxisSpec thnAxisSA{configThnAxisSA, "SA"}; + std::vector occupancyBinning = {-0.5, 500.0, 1000.0, 1500.0, 2000.0, 3000.0, 4000.0, 5000.0, 50000.0}; + const AxisSpec thnAxisInvMass{cnfgaxis.configThnAxisInvMass, "#it{M} (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisPt{cnfgaxis.configThnAxisPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisCosThetaStar{cnfgaxis.configThnAxisCosThetaStar, "cos(#vartheta_{OP})"}; + const AxisSpec thnAxisCentrality{cnfgaxis.configThnAxisCentrality, "Centrality (%)"}; + const AxisSpec thnAxisV2{cnfgaxis.configThnAxisV2, "V2"}; + const AxisSpec thnAxisRapidity{cnfgaxis.configThnAxisRapidity, "Rapidity"}; + const AxisSpec thnAxisSA{cnfgaxis.configThnAxisSA, "SA"}; AxisSpec cumulantAxis = {200, -1, 1, "phi"}; + AxisSpec itsAxis = {8, -0.5, 7.5, "its"}; + AxisSpec tpcAxis = {130, 69.5, 199.5, "its"}; + AxisSpec squareAxis = {200, 0, 1, "aossquare"}; AxisSpec phiAxis = {500, -6.28, 6.28, "phi"}; - AxisSpec resAxis = {2000, -10, 10, "Res"}; + AxisSpec resAxis = {6000, -30, 30, "Res"}; + AxisSpec resAxisSquare = {800, -1, 1, "Res"}; AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; AxisSpec occupancyAxis = {occupancyBinning, "Occupancy"}; + AxisSpec spAxis = {spNbins, lbinsp, hbinsp, "Sp"}; + + if (fillv1) { + histos.add("hpQxtQxpvscent", "hpQxtQxpvscent", HistType::kTHnSparseF, {cnfgaxis.configThnAxisCentrality, spAxis}, true); + histos.add("hpQytQypvscent", "hpQytQypvscent", HistType::kTHnSparseF, {cnfgaxis.configThnAxisCentrality, spAxis}, true); + histos.add("hpQxytpvscent", "hpQxytpvscent", HistType::kTHnSparseF, {cnfgaxis.configThnAxisCentrality, spAxis}, true); + histos.add("hpQxtQypvscent", "hpQxtQypvscent", HistType::kTHnSparseF, {cnfgaxis.configThnAxisCentrality, spAxis}, true); + histos.add("hpQxpQytvscent", "hpQxpQytvscent", HistType::kTHnSparseF, {cnfgaxis.configThnAxisCentrality, spAxis}, true); + + histos.add("hpQxpvscent", "hpQxpvscent", HistType::kTHnSparseF, {cnfgaxis.configThnAxisCentrality, spAxis}, true); + histos.add("hpQxtvscent", "hpQxtvscent", HistType::kTHnSparseF, {cnfgaxis.configThnAxisCentrality, spAxis}, true); + histos.add("hpQypvscent", "hpQypvscent", HistType::kTHnSparseF, {cnfgaxis.configThnAxisCentrality, spAxis}, true); + histos.add("hpQytvscent", "hpQytvscent", HistType::kTHnSparseF, {cnfgaxis.configThnAxisCentrality, spAxis}, true); + + histos.add("hpoddvscentpteta", "hpoddvscentpteta", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuxyQxypvscentpteta", "hpuxyQxypvscentpteta", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuxyQxytvscentpteta", "hpuxyQxytvscentpteta", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuxvscentpteta", "hpuxvscentpteta", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuyvscentpteta", "hpuyvscentpteta", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpoddvscentptetamixacc", "hpoddvscentptetamixacc", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuxyQxypvscentptetamixacc", "hpuxyQxypvscentptetamixacc", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuxyQxytvscentptetamixacc", "hpuxyQxytvscentptetamixacc", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuxvscentptetamixacc", "hpuxvscentptetamixacc", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuyvscentptetamixacc", "hpuyvscentptetamixacc", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpoddvscentptetamixopti", "hpoddvscentptetamixopti", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuxyQxypvscentptetamixopti", "hpuxyQxypvscentptetamixopti", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuxyQxytvscentptetamixopti", "hpuxyQxytvscentptetamixopti", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuxvscentptetamixopti", "hpuxvscentptetamixopti", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + histos.add("hpuyvscentptetamixopti", "hpuyvscentptetamixopti", HistType::kTHnSparseF, {cnfgaxis.configThnAxisInvMass, cnfgaxis.configThnAxisCentrality, cnfgaxis.configThnAxisPt, cnfgaxis.configThnAxisRapidity, spAxis}, true); + } - histos.add("hTPCglobalmomcorr", "Momentum correlation", kTH3F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}, {8, 0.0f, 80.0f}}); - histos.add("hpTvsRapidity", "pT vs Rapidity", kTH2F, {{100, 0.0f, 10.0f}, {300, -1.5f, 1.5f}}); - histos.add("hFTOCvsTPCNoCut", "Mult correlation FT0C vs. TPC without any cut", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); - histos.add("hFTOCvsTPC", "Mult correlation FT0C vs. TPC", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); - histos.add("hFTOCvsTPCSelected", "Mult correlation FT0C vs. TPC after selection", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); histos.add("hCentrality", "Centrality distribution", kTH1F, {{200, 0.0, 200.0}}); histos.add("hVtxZ", "Vertex distribution in Z;Z (cm)", kTH1F, {{400, -20.0, 20.0}}); - histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); - histos.add("hDcaxy", "Dcaxy distribution", kTH1F, {{200, -1.0f, 1.0f}}); - histos.add("hDcaz", "Dcaz distribution", kTH1F, {{200, -1.0f, 1.0f}}); - histos.add("hNsigmaKaonTPC", "NsigmaKaon TPC distribution", kTH1F, {{200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTOF", "NsigmaKaon TOF distribution", kTH1F, {{200, -10.0f, 10.0f}}); - histos.add("hPsiFT0C", "PsiFT0C", kTH3F, {centAxis, occupancyAxis, phiAxis}); - histos.add("hPsiFT0A", "PsiFT0A", kTH3F, {centAxis, occupancyAxis, phiAxis}); - histos.add("hPsiTPC", "PsiTPC", kTH3F, {centAxis, occupancyAxis, phiAxis}); - histos.add("hPsiTPCR", "PsiTPCR", kTH3F, {centAxis, occupancyAxis, phiAxis}); - histos.add("hPsiTPCL", "PsiTPCL", kTH3F, {centAxis, occupancyAxis, phiAxis}); - - histos.add("hSparseV2SameEventCosPhi", "hSparseV2SameEventCosPhi", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, cumulantAxis, thnAxisCentrality}); - histos.add("hSparseV2SameEventSinPhi", "hSparseV2SameEventSinPhi", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, cumulantAxis, thnAxisCentrality}); - histos.add("hSparseV2SameEventCosPsi", "hSparseV2SameEventCosPsi", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, cumulantAxis, thnAxisCentrality}); - histos.add("hSparseV2SameEventSinPsi", "hSparseV2SameEventSinPsi", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, cumulantAxis, thnAxisCentrality}); - - histos.add("hSparseV2SameEventCosDeltaPhi", "hSparseV2SameEventCosDeltaPhi", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2MixedEventCosDeltaPhi", "hSparseV2MixedEventCosDeltaPhi", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - - histos.add("hSparseV2SameEventCosDeltaPhiSquare", "hSparseV2SameEventCosDeltaPhiSquare", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2MixedEventCosDeltaPhiSquare", "hSparseV2MixedEventCosDeltaPhiSquare", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - - histos.add("hSparseV2SameEventSinDeltaPhi", "hSparseV2SameEventSinDeltaPhi", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2MixedEventSinDeltaPhi", "hSparseV2MixedEventSinDeltaPhi", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - - histos.add("hSparseV2SameEventSA", "hSparseV2SameEventSA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2MixedEventSA", "hSparseV2MixedEventSA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - - histos.add("hSparseV2SameEventCosThetaStar", "hSparseV2SameEventCosThetaStar", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStar, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2MixedEventCosThetaStar", "hSparseV2MixedEventCosThetaStar", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStar, thnAxisRapidity, thnAxisCentrality}); - - // histogram for resolution - histos.add("ResFT0CTPC", "ResFT0CTPC", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResFT0CTPCR", "ResFT0CTPCR", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResFT0CTPCL", "ResFT0CTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResTPCRTPCL", "ResTPCRTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResFT0CFT0A", "ResFT0CFT0A", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResFT0ATPC", "ResFT0ATPC", kTH3F, {centAxis, occupancyAxis, resAxis}); - - histos.add("ResSPFT0CTPC", "ResSPFT0CTPC", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResSPFT0CTPCR", "ResSPFT0CTPCR", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResSPFT0CTPCL", "ResSPFT0CTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResSPTPCRTPCL", "ResSPTPCRTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResSPFT0CFT0A", "ResSPFT0CFT0A", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResSPFT0ATPC", "ResSPFT0ATPC", kTH3F, {centAxis, occupancyAxis, resAxis}); - - // MC histogram - if (isMC) { - histos.add("hMC", "MC Event statistics", kTH1F, {{10, 0.0f, 10.0f}}); - histos.add("h1PhiRecsplit", "Phi meson Rec split", kTH1F, {{100, 0.0f, 10.0f}}); - histos.add("CentPercentileMCRecHist", "MC Centrality", kTH1F, {{100, 0.0f, 100.0f}}); - - histos.add("hSparseV2MCGenSA", "hSparseV2SameEventSA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2MCGenCosThetaStar_effy", "hSparseV2SameEventCosThetaStar_effy", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStar, thnAxisRapidity, thnAxisCentrality}); - - histos.add("hSparseV2MCRecSA", "hSparseV2SameEventSA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2MCRecCosThetaStar_effy", "hSparseV2SameEventCosThetaStar_effy", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStar, thnAxisRapidity, thnAxisCentrality}); + + if (!fillv1) { + histos.add("hTPCglobalmomcorr", "Momentum correlation", kTH3F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}, {8, 0.0f, 80.0f}}); + histos.add("hpTvsRapidity", "pT vs Rapidity", kTH2F, {{100, 0.0f, 10.0f}, {300, -1.5f, 1.5f}}); + histos.add("hFTOCvsTPCNoCut", "Mult correlation FT0C vs. TPC without any cut", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); + histos.add("hFTOCvsTPC", "Mult correlation FT0C vs. TPC", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); + histos.add("hFTOCvsTPCSelected", "Mult correlation FT0C vs. TPC after selection", kTH2F, {{80, 0.0f, 80.0f}, {100, -0.5f, 5999.5f}}); + histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); + histos.add("hDcaxy", "Dcaxy distribution", kTH1F, {{200, -1.0f, 1.0f}}); + histos.add("hDcaz", "Dcaz distribution", kTH1F, {{200, -1.0f, 1.0f}}); + + histos.add("hITS", "ITS cluster", kTH2F, {{10, -0.5f, 9.5f}, {200, -1.0, 1.0}}); + histos.add("hTPC", "TPC crossed rows", kTH2F, {{90, 69.5f, 159.5f}, {200, -1.0, 1.0}}); + histos.add("hTPCScls", "TPC Shared cluster", kTH2F, {{16, -0.5f, 159.5f}, {200, -1.0, 1.0}}); + histos.add("hTPCSclsFrac", "Fraction of TPC Shared cluster", kTH2F, {{100, -0.0f, 2.0f}, {200, -1.0, 1.0}}); + + histos.add("hNsigmaKaonTPC", "NsigmaKaon TPC distribution", kTH1F, {{200, -10.0f, 10.0f}}); + histos.add("hNsigmaKaonTOF", "NsigmaKaon TOF distribution", kTH1F, {{200, -10.0f, 10.0f}}); + histos.add("hPsiFT0C", "PsiFT0C", kTH3F, {centAxis, occupancyAxis, phiAxis}); + histos.add("hPsiFT0A", "PsiFT0A", kTH3F, {centAxis, occupancyAxis, phiAxis}); + histos.add("hPsiTPC", "PsiTPC", kTH3F, {centAxis, occupancyAxis, phiAxis}); + histos.add("hPsiTPCR", "PsiTPCR", kTH3F, {centAxis, occupancyAxis, phiAxis}); + histos.add("hPsiTPCL", "PsiTPCL", kTH3F, {centAxis, occupancyAxis, phiAxis}); + + histos.add("hSparseV2SameEventCosPhi", "hSparseV2SameEventCosPhi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, cumulantAxis, thnAxisCentrality}); + histos.add("hSparseV2SameEventSinPhi", "hSparseV2SameEventSinPhi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, cumulantAxis, thnAxisCentrality}); + histos.add("hSparseV2SameEventCosPsi", "hSparseV2SameEventCosPsi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, cumulantAxis, thnAxisCentrality}); + histos.add("hSparseV2SameEventSinPsi", "hSparseV2SameEventSinPsi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, cumulantAxis, thnAxisCentrality}); + + histos.add("hSparseV2SameEventCosDeltaPhi", "hSparseV2SameEventCosDeltaPhi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + histos.add("hSparseV2MixedEventCosDeltaPhi", "hSparseV2MixedEventCosDeltaPhi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + histos.add("hSparseV2MixEPAngleCosDeltaPhi", "hSparseV2MixEPAngleCosDeltaPhi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + + histos.add("hSparseV2SameEventCos2DeltaPhi", "hSparseV2SameEventCos2DeltaPhi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + histos.add("hSparseV2MixedEventCos2DeltaPhi", "hSparseV2MixedEventCos2DeltaPhi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + + histos.add("hSparseV2SameEventCosDeltaPhiSquare", "hSparseV2SameEventCosDeltaPhiSquare", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, squareAxis, thnAxisCentrality}); + histos.add("hSparseV2SameEventCosDeltaPhiCube", "hSparseV2SameEventCosDeltaPhiCube", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + histos.add("hSparseV2MixedEventCosDeltaPhiSquare", "hSparseV2MixedEventCosDeltaPhiSquare", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, squareAxis, thnAxisCentrality}); + + histos.add("hSparseV2SameEventSinDeltaPhi", "hSparseV2SameEventSinDeltaPhi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + histos.add("hSparseV2MixedEventSinDeltaPhi", "hSparseV2MixedEventSinDeltaPhi", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + + if (fillSA) { + histos.add("hSparseV2SameEventSA", "hSparseV2SameEventSA", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); + histos.add("hSparseV2MixedEventSA", "hSparseV2MixedEventSA", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); + histos.add("hSparseV2SameEventCosThetaStar", "hSparseV2SameEventCosThetaStar", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStar, thnAxisRapidity, thnAxisCentrality}); + histos.add("hSparseV2MixedEventCosThetaStar", "hSparseV2MixedEventCosThetaStar", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStar, thnAxisRapidity, thnAxisCentrality}); + } + // histogram for resolution + histos.add("ResFT0CTPC", "ResFT0CTPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResFT0CTPCR", "ResFT0CTPCR", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResFT0CTPCL", "ResFT0CTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResTPCRTPCL", "ResTPCRTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResFT0CFT0A", "ResFT0CFT0A", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResFT0ATPC", "ResFT0ATPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + + histos.add("Res4FT0CTPC", "Res4FT0CTPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4FT0CTPCR", "Res4FT0CTPCR", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4FT0CTPCL", "Res4FT0CTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4TPCRTPCL", "Res4TPCRTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4FT0CFT0A", "Res4FT0CFT0A", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4FT0ATPC", "Res4FT0ATPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + + histos.add("ResFT0CTPCSquare", "ResFT0CTPCSquare", kTH3F, {centAxis, occupancyAxis, resAxisSquare}); + histos.add("ResFT0CTPCRSquare", "ResFT0CTPCRSquare", kTH3F, {centAxis, occupancyAxis, resAxisSquare}); + histos.add("ResFT0CTPCLSquare", "ResFT0CTPCLSquare", kTH3F, {centAxis, occupancyAxis, resAxisSquare}); + histos.add("ResTPCRTPCLSquare", "ResTPCRTPCLSquare", kTH3F, {centAxis, occupancyAxis, resAxisSquare}); + histos.add("ResFT0CFT0ASquare", "ResFT0CFT0ASquare", kTH3F, {centAxis, occupancyAxis, resAxisSquare}); + histos.add("ResFT0ATPCSquare", "ResFT0ATPCSquare", kTH3F, {centAxis, occupancyAxis, resAxisSquare}); + + histos.add("ResSPFT0CTPC", "ResSPFT0CTPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResSPFT0CTPCR", "ResSPFT0CTPCR", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResSPFT0CTPCL", "ResSPFT0CTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResSPTPCRTPCL", "ResSPTPCRTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResSPFT0CFT0A", "ResSPFT0CFT0A", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResSPFT0ATPC", "ResSPFT0ATPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + + histos.add("Res4SPFT0CTPC", "Res4SPFT0CTPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4SPFT0CTPCR", "Res4SPFT0CTPCR", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4SPFT0CTPCL", "Res4SPFT0CTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4SPTPCRTPCL", "Res4SPTPCRTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4SPFT0CFT0A", "Res4SPFT0CFT0A", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("Res4SPFT0ATPC", "Res4SPFT0ATPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + + histos.add("ResTrackSPFT0CTPC", "ResTrackSPFT0CTPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResTrackSPFT0CTPCR", "ResTrackSPFT0CTPCR", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResTrackSPFT0CTPCL", "ResTrackSPFT0CTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResTrackSPTPCRTPCL", "ResTrackSPTPCRTPCL", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResTrackSPFT0CFT0A", "ResTrackSPFT0CFT0A", kTH3F, {centAxis, occupancyAxis, resAxis}); + histos.add("ResTrackSPFT0ATPC", "ResTrackSPFT0ATPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + + // MC histogram + if (isMC) { + histos.add("hMC", "MC Event statistics", kTH1F, {{10, 0.0f, 10.0f}}); + histos.add("h1PhiRecsplit", "Phi meson Rec split", kTH1F, {{100, 0.0f, 10.0f}}); + histos.add("CentPercentileMCRecHist", "MC Centrality", kTH1F, {{100, 0.0f, 100.0f}}); + + histos.add("hSparseV2MCGenSA", "hSparseV2SameEventSA", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); + histos.add("hSparseV2MCGenCosThetaStar_effy", "hSparseV2SameEventCosThetaStar_effy", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStar, thnAxisRapidity, thnAxisCentrality}); + + histos.add("hSparseV2MCRecSA", "hSparseV2SameEventSA", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); + histos.add("hSparseV2MCRecCosThetaStar_effy", "hSparseV2SameEventCosThetaStar_effy", HistType::kTHnSparseD, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStar, thnAxisRapidity, thnAxisCentrality}); + + // weight + + histos.add("hSparsePhiMCGenWeight", "hSparsePhiMCGenWeight", HistType::kTHnSparseD, {thnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, -1.0, 1}, thnAxisPt, {8, -0.8, 0.8}}); + histos.add("hSparsePhiMCRecWeight", "hSparsePhiMCRecWeight", HistType::kTHnSparseD, {thnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, -1.0, 1}, thnAxisPt, {8, -0.8, 0.8}}); + histos.add("hSparsePhiMCGenKaonWeight", "hSparsePhiMCGenKaonWeight", HistType::kTHnSparseD, {thnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, -1.0, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + histos.add("hSparsePhiMCRecKaonWeight", "hSparsePhiMCRecKaonWeight", HistType::kTHnSparseD, {thnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, -1.0, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + histos.add("hSparsePhiMCRecKaonMissMatchWeight", "hSparsePhiMCRecKaonMissMatchWeight", HistType::kTHnSparseD, {thnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, -1.0, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + + histos.add("hSparseMCGenWeight", "hSparseMCGenWeight", HistType::kTHnSparseD, {thnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, -1.0, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + histos.add("hSparseMCRecWeight", "hSparseMCRecWeight", HistType::kTHnSparseD, {thnAxisCentrality, {36, 0.0f, TMath::Pi()}, {400, -1.0, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + histos.add("hSparseMCRecAllTrackWeight", "hSparseMCRecAllTrackWeight", HistType::kTHnSparseD, {thnAxisCentrality, {36, 0.0, TMath::Pi()}, {400, -1.0, 1}, axisPtKaonWeight, {8, -0.8, 0.8}}); + + histos.add("hImpactParameter", "Impact parameter", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hEventPlaneAngle", "hEventPlaneAngle", kTH1F, {{200, -2.0f * TMath::Pi(), 2.0f * TMath::Pi()}}); + histos.add("hEventPlaneAngleRec", "hEventPlaneAngleRec", kTH1F, {{200, -2.0f * TMath::Pi(), 2.0f * TMath::Pi()}}); + histos.add("hNchVsImpactParameter", "hNchVsImpactParameter", kTH2F, {{200, 0.0f, 20.0f}, {500, -0.5f, 5000.5f}}); + histos.add("hSparseMCGenV2", "hSparseMCGenV2", HistType::kTHnSparseD, {thnAxisCentrality, {200, -1.0, 1.0}, axisPtKaonWeight}); + histos.add("hSparseMCRecV2", "hSparseMCRecV2", HistType::kTHnSparseD, {thnAxisCentrality, {200, -1.0, 1.0}, axisPtKaonWeight}); + // histos.add("hSparseMCGenV2Square", "hSparseMCGenV2Square", HistType::kTHnSparseD, {thnAxisCentrality, {1000, 0.0, 1.0}, axisPtKaonWeight}); + // histos.add("hSparseMCRecV2Square", "hSparseMCRecV2Square", HistType::kTHnSparseD, {thnAxisCentrality, {1000, 0.0, 1.0}, axisPtKaonWeight}); + histos.add("hSparseMCGenV2Square", "hSparseMCGenV2Square", HistType::kTH3D, {thnAxisCentrality, {1000, 0.0, 1.0}, axisPtKaonWeight}); + histos.add("hSparseMCRecV2Square", "hSparseMCRecV2Square", HistType::kTH3D, {thnAxisCentrality, {1000, 0.0, 1.0}, axisPtKaonWeight}); + } } // Event selection cut additional - Alex if (additionalEvsel) { @@ -236,6 +369,12 @@ struct phipbpb { fMultMultPVCut = new TF1("fMultMultPVCut", "[0]+[1]*x+[2]*x*x", 0, 5000); fMultMultPVCut->SetParameters(-0.1, 0.785, -4.7e-05); } + + ccdb->setURL(cfgCcdbParam.cfgURL); + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); } double massKa = o2::constants::physics::MassKPlus; @@ -265,10 +404,13 @@ struct phipbpb { template bool selectionTrack(const T& candidate) { - if (useGlobalTrack && !(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster)) { + if (useGlobalTrack && !useDcaSyst && !(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsCrossedRows() > cfgTPCcluster && candidate.tpcFractionSharedCls() < cfgTPCSharedcluster)) { + return false; + } + if (useGlobalTrack && useDcaSyst && !(candidate.itsNCls() > cfgITScluster && candidate.tpcNClsCrossedRows() > cfgTPCcluster && candidate.tpcFractionSharedCls() < cfgTPCSharedcluster)) { return false; } - if (!useGlobalTrack && !(candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster)) { + if (!useGlobalTrack && !(candidate.tpcNClsFound() > cfgTPCcluster)) { return false; } return true; @@ -298,6 +440,15 @@ struct phipbpb { } return false; } + + template + bool selectionPID2(const T& candidate) + { + if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { + return true; + } + return false; + } // deep angle cut on pair to remove photon conversion template bool selectionPair(const T1& candidate1, const T2& candidate2) @@ -353,15 +504,24 @@ struct phipbpb { ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for bin"}; ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {20, 0, 100}, "multiplicity percentile for bin"}; ConfigurableAxis axisEPAngle{"axisEPAngle", {6, -TMath::Pi() / 2, TMath::Pi() / 2}, "event plane angle"}; - ConfigurableAxis axisOccup{"axisOccup", {20, 0.0, 40000.0}, "occupancy axis"}; + ConfigurableAxis axisSPAngle{"axisSPAngle", {6, -TMath::Pi(), TMath::Pi()}, "spectator plane angle"}; + ConfigurableAxis axisOccup{"axisOccup", {20, -0.5, 40000.0}, "occupancy axis"}; - using BinningTypeVertexContributor = ColumnBinningPolicy; + // using BinningTypeVertexContributor = ColumnBinningPolicy; + using BinningTypeVertexContributor = ColumnBinningPolicy; + using BinningTypeVertexContributorv1 = ColumnBinningPolicy; ROOT::Math::PxPyPzMVector PhiMesonMother, KaonPlus, KaonMinus, fourVecDauCM; ROOT::Math::XYZVector threeVecDauCM, threeVecDauCMXY, eventplaneVec, eventplaneVecNorm, beamvector; - - void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::BCs const&) + int currentRunNumber = -999; + int lastRunNumber = -999; + // TH3D* hweight; + TH2D* hweight; + void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks, aod::BCs const&*/, aod::BCsWithTimestamps const&) { - if (!collision.sel8() || !collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // if (!collision.sel8() || !collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // return; + // } + if (!collision.sel8() || !collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { return; } auto centrality = collision.centFT0C(); @@ -380,11 +540,15 @@ struct phipbpb { auto QTPCR = collision.qTPCR(); auto QTPCL = collision.qTPCL(); int occupancy = collision.trackOccupancyInTimeRange(); + o2::aod::ITSResponse itsResponse; if (occupancy > cfgCutOccupancy) { return; } histos.fill(HIST("hFTOCvsTPC"), centrality, multTPC); - if (additionalEvsel && !eventSelected(collision, centrality)) { + if (additionalEvsel && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return; + } + if (additionalEvselITS && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { return; } histos.fill(HIST("hFTOCvsTPCSelected"), centrality, multTPC); @@ -401,6 +565,20 @@ struct phipbpb { histos.fill(HIST("ResFT0CFT0A"), centrality, occupancy, TMath::Cos(2.0 * (psiFT0C - psiFT0A))); histos.fill(HIST("ResFT0ATPC"), centrality, occupancy, TMath::Cos(2.0 * (psiTPC - psiFT0A))); + histos.fill(HIST("Res4FT0CTPC"), centrality, occupancy, TMath::Cos(4.0 * (psiFT0C - psiTPC))); + histos.fill(HIST("Res4FT0CTPCR"), centrality, occupancy, TMath::Cos(4.0 * (psiFT0C - psiTPCR))); + histos.fill(HIST("Res4FT0CTPCL"), centrality, occupancy, TMath::Cos(4.0 * (psiFT0C - psiTPCL))); + histos.fill(HIST("Res4TPCRTPCL"), centrality, occupancy, TMath::Cos(4.0 * (psiTPCR - psiTPCL))); + histos.fill(HIST("Res4FT0CFT0A"), centrality, occupancy, TMath::Cos(4.0 * (psiFT0C - psiFT0A))); + histos.fill(HIST("Res4FT0ATPC"), centrality, occupancy, TMath::Cos(4.0 * (psiTPC - psiFT0A))); + + histos.fill(HIST("ResFT0CTPCSquare"), centrality, occupancy, TMath::Power(TMath::Cos(2.0 * (psiFT0C - psiTPC)), 2.0)); + histos.fill(HIST("ResFT0CTPCRSquare"), centrality, occupancy, TMath::Power(TMath::Cos(2.0 * (psiFT0C - psiTPCR)), 2.0)); + histos.fill(HIST("ResFT0CTPCLSquare"), centrality, occupancy, TMath::Power(TMath::Cos(2.0 * (psiFT0C - psiTPCL)), 2.0)); + histos.fill(HIST("ResTPCRTPCLSquare"), centrality, occupancy, TMath::Power(TMath::Cos(2.0 * (psiTPCR - psiTPCL)), 2.0)); + histos.fill(HIST("ResFT0CFT0ASquare"), centrality, occupancy, TMath::Power(TMath::Cos(2.0 * (psiFT0C - psiFT0A)), 2.0)); + histos.fill(HIST("ResFT0ATPCSquare"), centrality, occupancy, TMath::Power(TMath::Cos(2.0 * (psiTPC - psiFT0A)), 2.0)); + histos.fill(HIST("ResSPFT0CTPC"), centrality, occupancy, QFT0C * QTPC * TMath::Cos(2.0 * (psiFT0C - psiTPC))); histos.fill(HIST("ResSPFT0CTPCR"), centrality, occupancy, QFT0C * QTPCR * TMath::Cos(2.0 * (psiFT0C - psiTPCR))); histos.fill(HIST("ResSPFT0CTPCL"), centrality, occupancy, QFT0C * QTPCL * TMath::Cos(2.0 * (psiFT0C - psiTPCL))); @@ -408,19 +586,43 @@ struct phipbpb { histos.fill(HIST("ResSPFT0CFT0A"), centrality, occupancy, QFT0C * QFT0A * TMath::Cos(2.0 * (psiFT0C - psiFT0A))); histos.fill(HIST("ResSPFT0ATPC"), centrality, occupancy, QTPC * QFT0A * TMath::Cos(2.0 * (psiTPC - psiFT0A))); + histos.fill(HIST("Res4SPFT0CTPC"), centrality, occupancy, QFT0C * QTPC * TMath::Cos(4.0 * (psiFT0C - psiTPC))); + histos.fill(HIST("Res4SPFT0CTPCR"), centrality, occupancy, QFT0C * QTPCR * TMath::Cos(4.0 * (psiFT0C - psiTPCR))); + histos.fill(HIST("Res4SPFT0CTPCL"), centrality, occupancy, QFT0C * QTPCL * TMath::Cos(4.0 * (psiFT0C - psiTPCL))); + histos.fill(HIST("Res4SPTPCRTPCL"), centrality, occupancy, QTPCR * QTPCL * TMath::Cos(4.0 * (psiTPCR - psiTPCL))); + histos.fill(HIST("Res4SPFT0CFT0A"), centrality, occupancy, QFT0C * QFT0A * TMath::Cos(4.0 * (psiFT0C - psiFT0A))); + histos.fill(HIST("Res4SPFT0ATPC"), centrality, occupancy, QTPC * QFT0A * TMath::Cos(4.0 * (psiTPC - psiFT0A))); + histos.fill(HIST("hCentrality"), centrality); histos.fill(HIST("hVtxZ"), collision.posZ()); + + auto bc = collision.bc_as(); + currentRunNumber = collision.bc_as().runNumber(); + if (useWeight && (currentRunNumber != lastRunNumber)) { + // hweight = ccdb->getForTimeStamp(ConfWeightPath.value, bc.timestamp()); + hweight = ccdb->getForTimeStamp(ConfWeightPath.value, bc.timestamp()); + } + lastRunNumber = currentRunNumber; + int Npostrack = 0; + float weight1 = 1.0; + float weight2 = 1.0; for (auto track1 : posThisColl) { // track selection if (!selectionTrack(track1)) { continue; } // PID check - if (ispTdepPID && !selectionPIDpTdependent(track1)) { + if (ispTdepPID && !isTOFOnly && !selectionPIDpTdependent(track1)) { continue; } - if (!ispTdepPID && !selectionPID(track1)) { + if (!ispTdepPID && !isTOFOnly && !selectionPID(track1)) { + continue; + } + if (isTOFOnly && !selectionPID2(track1)) { + continue; + } + if (useGlobalTrack && track1.p() < 1.0 && !(itsResponse.nSigmaITS(track1) > -2.5 && itsResponse.nSigmaITS(track1) < 2.5)) { continue; } histos.fill(HIST("hTPCglobalmomcorr"), track1.p() / track1.sign(), track1.p() - track1.tpcInnerParam(), centrality); @@ -429,17 +631,33 @@ struct phipbpb { histos.fill(HIST("hDcaz"), track1.dcaZ()); histos.fill(HIST("hNsigmaKaonTPC"), track1.tpcNSigmaKa()); histos.fill(HIST("hNsigmaKaonTOF"), track1.tofNSigmaKa()); + auto V2Track = TMath::Cos(2.0 * GetPhiInRange(track1.phi() - psiFT0C)); + histos.fill(HIST("hITS"), track1.itsNCls(), V2Track); + histos.fill(HIST("hTPC"), track1.tpcNClsCrossedRows(), V2Track); + histos.fill(HIST("hTPCScls"), track1.tpcNClsShared(), V2Track); + histos.fill(HIST("hTPCSclsFrac"), track1.tpcFractionSharedCls(), V2Track); auto track1ID = track1.globalIndex(); + if (useWeight) { + if (track1.pt() < 10.0 && track1.pt() > 0.15) { + // weight1 = hweight->GetBinContent(hweight->FindBin(centrality, GetPhiInRange(track1.phi() - psiFT0C), track1.pt() + 0.000005)); + weight1 = 1 + hweight->GetBinContent(hweight->FindBin(centrality, track1.pt() + 0.000005)) * TMath::Cos(2.0 * GetPhiInRange(track1.phi() - psiFT0C)); + } else { + weight1 = 1; + } + } for (auto track2 : negThisColl) { // track selection if (!selectionTrack(track2)) { continue; } // PID check - if (ispTdepPID && !selectionPIDpTdependent(track2)) { + if (ispTdepPID && !isTOFOnly && !selectionPIDpTdependent(track2)) { + continue; + } + if (!ispTdepPID && !isTOFOnly && !selectionPID(track2)) { continue; } - if (!ispTdepPID && !selectionPID(track2)) { + if (isTOFOnly && !selectionPID2(track2)) { continue; } auto track2ID = track2.globalIndex(); @@ -458,86 +676,195 @@ struct phipbpb { if (removefaketrak && isFakeKaon(track2)) { continue; } + if (useGlobalTrack && track2.p() < 1.0 && !(itsResponse.nSigmaITS(track2) > -2.5 && itsResponse.nSigmaITS(track2) < 2.5)) { + continue; + } + if (useWeight) { + if (track2.pt() < 10.0 && track2.pt() > 0.15) { + // weight2 = hweight->GetBinContent(hweight->FindBin(centrality, GetPhiInRange(track2.phi() - psiFT0C), track2.pt() + 0.000005)); + weight2 = 1 + hweight->GetBinContent(hweight->FindBin(centrality, track2.pt() + 0.000005)) * TMath::Cos(2.0 * GetPhiInRange(track2.phi() - psiFT0C)); + } else { + weight2 = 1; + } + } KaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); KaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); PhiMesonMother = KaonPlus + KaonMinus; auto phiminuspsi = GetPhiInRange(PhiMesonMother.Phi() - psiFT0C); auto v2 = TMath::Cos(2.0 * phiminuspsi); + auto v2acc = TMath::Cos(4.0 * phiminuspsi); auto v2sin = TMath::Sin(2.0 * phiminuspsi); auto phimother = PhiMesonMother.Phi(); histos.fill(HIST("hpTvsRapidity"), PhiMesonMother.Pt(), PhiMesonMother.Rapidity()); + auto totalweight = weight1 * weight2; + if (totalweight <= 0.0000005) { + totalweight = 1.0; + } + + // LOGF(info, Form("weight %f %f",weight1, weight2)); if (TMath::Abs(PhiMesonMother.Rapidity()) < confRapidity) { - histos.fill(HIST("hSparseV2SameEventCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality); - histos.fill(HIST("hSparseV2SameEventCosDeltaPhiSquare"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * v2, centrality); - histos.fill(HIST("hSparseV2SameEventSinDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2sin * QFT0C, centrality); - - histos.fill(HIST("hSparseV2SameEventCosPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Cos(2.0 * phimother), centrality); - histos.fill(HIST("hSparseV2SameEventSinPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Sin(2.0 * phimother), centrality); - histos.fill(HIST("hSparseV2SameEventCosPsi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Cos(2.0 * psiFT0C), centrality); - histos.fill(HIST("hSparseV2SameEventSinPsi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Sin(2.0 * psiFT0C), centrality); - } - ROOT::Math::Boost boost{PhiMesonMother.BoostToCM()}; - fourVecDauCM = boost(KaonMinus); - threeVecDauCM = fourVecDauCM.Vect(); - threeVecDauCMXY = ROOT::Math::XYZVector(threeVecDauCM.X(), threeVecDauCM.Y(), 0.); - eventplaneVec = ROOT::Math::XYZVector(std::cos(2.0 * psiFT0C), std::sin(2.0 * psiFT0C), 0); - eventplaneVecNorm = ROOT::Math::XYZVector(std::sin(2.0 * psiFT0C), -std::cos(2.0 * psiFT0C), 0); - auto cosPhistarminuspsi = GetPhiInRange(fourVecDauCM.Phi() - psiFT0C); - auto SA = TMath::Cos(2.0 * cosPhistarminuspsi); - auto cosThetaStar = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); - histos.fill(HIST("hSparseV2SameEventSA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SameEventCosThetaStar"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStar, TMath::Abs(PhiMesonMother.Rapidity()), centrality); + histos.fill(HIST("ResTrackSPFT0CTPC"), centrality, occupancy, QFT0C * QTPC * TMath::Cos(2.0 * (psiFT0C - psiTPC))); + histos.fill(HIST("ResTrackSPFT0CTPCR"), centrality, occupancy, QFT0C * QTPCR * TMath::Cos(2.0 * (psiFT0C - psiTPCR))); + histos.fill(HIST("ResTrackSPFT0CTPCL"), centrality, occupancy, QFT0C * QTPCL * TMath::Cos(2.0 * (psiFT0C - psiTPCL))); + histos.fill(HIST("ResTrackSPTPCRTPCL"), centrality, occupancy, QTPCR * QTPCL * TMath::Cos(2.0 * (psiTPCR - psiTPCL))); + histos.fill(HIST("ResTrackSPFT0CFT0A"), centrality, occupancy, QFT0C * QFT0A * TMath::Cos(2.0 * (psiFT0C - psiFT0A))); + histos.fill(HIST("ResTrackSPFT0ATPC"), centrality, occupancy, QTPC * QFT0A * TMath::Cos(2.0 * (psiTPC - psiFT0A))); + if (useWeight) { + histos.fill(HIST("hSparseV2SameEventCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality, 1 / totalweight); + histos.fill(HIST("hSparseV2SameEventCos2DeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2acc * QFT0C, centrality, 1 / totalweight); + + histos.fill(HIST("hSparseV2SameEventCosDeltaPhiSquare"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * v2, centrality, 1 / totalweight); + histos.fill(HIST("hSparseV2SameEventSinDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2sin * QFT0C, centrality, 1 / totalweight); + + histos.fill(HIST("hSparseV2SameEventCosPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Cos(2.0 * phimother), centrality, 1 / totalweight); + histos.fill(HIST("hSparseV2SameEventSinPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Sin(2.0 * phimother), centrality, 1 / totalweight); + histos.fill(HIST("hSparseV2SameEventCosPsi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Cos(2.0 * psiFT0C), centrality, 1 / totalweight); + histos.fill(HIST("hSparseV2SameEventSinPsi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Sin(2.0 * psiFT0C), centrality, 1 / totalweight); + } else { + if (useSP) { + histos.fill(HIST("hSparseV2SameEventCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality); + histos.fill(HIST("hSparseV2SameEventCos2DeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2acc * QFT0C, centrality); + } else { + histos.fill(HIST("hSparseV2SameEventCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); + histos.fill(HIST("hSparseV2SameEventCos2DeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2acc, centrality); + } + histos.fill(HIST("hSparseV2SameEventCosDeltaPhiSquare"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * v2, centrality); + histos.fill(HIST("hSparseV2SameEventCosDeltaPhiCube"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * v2 * v2, centrality); + histos.fill(HIST("hSparseV2SameEventSinDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2sin * QFT0C, centrality); + + histos.fill(HIST("hSparseV2SameEventCosPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Cos(2.0 * phimother), centrality); + histos.fill(HIST("hSparseV2SameEventSinPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Sin(2.0 * phimother), centrality); + histos.fill(HIST("hSparseV2SameEventCosPsi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Cos(2.0 * psiFT0C), centrality); + histos.fill(HIST("hSparseV2SameEventSinPsi"), PhiMesonMother.M(), PhiMesonMother.Pt(), TMath::Sin(2.0 * psiFT0C), centrality); + } + } + + if (fillSA) { + ROOT::Math::Boost boost{PhiMesonMother.BoostToCM()}; + fourVecDauCM = boost(KaonMinus); + threeVecDauCM = fourVecDauCM.Vect(); + threeVecDauCMXY = ROOT::Math::XYZVector(threeVecDauCM.X(), threeVecDauCM.Y(), 0.); + eventplaneVec = ROOT::Math::XYZVector(std::cos(2.0 * psiFT0C), std::sin(2.0 * psiFT0C), 0); + eventplaneVecNorm = ROOT::Math::XYZVector(std::sin(2.0 * psiFT0C), -std::cos(2.0 * psiFT0C), 0); + auto cosPhistarminuspsi = GetPhiInRange(fourVecDauCM.Phi() - psiFT0C); + auto SA = TMath::Cos(2.0 * cosPhistarminuspsi); + auto cosThetaStar = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); + if (useWeight) { + histos.fill(HIST("hSparseV2SameEventSA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality, 1 / totalweight); + histos.fill(HIST("hSparseV2SameEventCosThetaStar"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStar, TMath::Abs(PhiMesonMother.Rapidity()), centrality, 1 / totalweight); + } else { + histos.fill(HIST("hSparseV2SameEventSA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); + histos.fill(HIST("hSparseV2SameEventCosThetaStar"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStar, TMath::Abs(PhiMesonMother.Rapidity())); + } + } } Npostrack = Npostrack + 1; } } PROCESS_SWITCH(phipbpb, processSameEvent, "Process Same event", true); - void processMixedEventOpti(EventCandidates const& collisions, TrackCandidates const& tracks) + + void processSameEventv1(EventCandidatesv1::iterator const& collision, TrackCandidates const& /*tracks, aod::BCs const&*/, aod::BCsWithTimestamps const&) { - auto tracksTuple = std::make_tuple(tracks); - BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicityClass, axisOccup}, true}; - SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; - for (auto& [collision1, tracks1, collision2, tracks2] : pair) { - if (!collision1.sel8() || !collision1.triggereventep() || !collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - continue; - } - if (!collision2.sel8() || !collision2.triggereventep() || !collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - continue; - } - if (collision1.bcId() == collision2.bcId()) { + if (!collision.sel8() || !collision.triggereventsp() || !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return; + } + auto centrality = collision.centFT0C(); + auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + int occupancy = collision.trackOccupancyInTimeRange(); + o2::aod::ITSResponse itsResponse; + if (occupancy > cfgCutOccupancy) { + return; + } + if (additionalEvsel && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return; + } + if (additionalEvselITS && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + + histos.fill(HIST("hCentrality"), centrality); + histos.fill(HIST("hVtxZ"), collision.posZ()); + + auto qxZDCA = collision.qxZDCA(); + auto qxZDCC = collision.qxZDCC(); + auto qyZDCA = collision.qyZDCA(); + auto qyZDCC = collision.qyZDCC(); + auto psiZDCC = collision.psiZDCC(); + auto psiZDCA = collision.psiZDCA(); + + double modqxZDCA; + double modqyZDCA; + double modqxZDCC; + double modqyZDCC; + + if (cqvas) { + modqxZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Cos(psiZDCA); + modqyZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Sin(psiZDCA); + modqxZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Cos(psiZDCC); + modqyZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Sin(psiZDCC); + } else { + modqxZDCA = qxZDCA; + modqyZDCA = qyZDCA; + modqxZDCC = qxZDCC; + modqyZDCC = qyZDCC; + } + + auto QxtQxp = modqxZDCA * modqxZDCC; + auto QytQyp = modqyZDCA * modqyZDCC; + auto Qxytp = QxtQxp + QytQyp; + auto QxpQyt = modqxZDCA * modqyZDCC; + auto QxtQyp = modqxZDCC * modqyZDCA; + + if (fillv1) { + histos.fill(HIST("hpQxtQxpvscent"), centrality, QxtQxp); + histos.fill(HIST("hpQytQypvscent"), centrality, QytQyp); + histos.fill(HIST("hpQxytpvscent"), centrality, Qxytp); + histos.fill(HIST("hpQxpQytvscent"), centrality, QxpQyt); + histos.fill(HIST("hpQxtQypvscent"), centrality, QxtQyp); + histos.fill(HIST("hpQxpvscent"), centrality, modqxZDCA); + histos.fill(HIST("hpQxtvscent"), centrality, modqxZDCC); + histos.fill(HIST("hpQypvscent"), centrality, modqyZDCA); + histos.fill(HIST("hpQytvscent"), centrality, modqyZDCC); + } + + int Npostrack = 0; + for (auto track1 : posThisColl) { + // track selection + if (!selectionTrack(track1)) { continue; } - int occupancy1 = collision1.trackOccupancyInTimeRange(); - int occupancy2 = collision2.trackOccupancyInTimeRange(); - if (occupancy1 > cfgCutOccupancy) { + // PID check + if (ispTdepPID && !isTOFOnly && !selectionPIDpTdependent(track1)) { continue; } - if (occupancy2 > cfgCutOccupancy) { + if (!ispTdepPID && !isTOFOnly && !selectionPID(track1)) { continue; } - auto centrality = collision1.centFT0C(); - auto centrality2 = collision2.centFT0C(); - auto psiFT0C = collision1.psiFT0C(); - auto QFT0C = collision1.qFT0C(); - if (additionalEvsel && !eventSelected(collision1, centrality)) { + if (isTOFOnly && !selectionPID2(track1)) { continue; } - if (additionalEvsel && !eventSelected(collision2, centrality2)) { + if (useGlobalTrack && track1.p() < 1.0 && !(itsResponse.nSigmaITS(track1) > -2.5 && itsResponse.nSigmaITS(track1) < 2.5)) { continue; } - - for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - if (track1.sign() * track2.sign() > 0) { + auto track1ID = track1.globalIndex(); + for (auto track2 : negThisColl) { + // track selection + if (!selectionTrack(track2)) { continue; } - if (!selectionTrack(track1) || !selectionTrack(track2)) { + // PID check + if (ispTdepPID && !isTOFOnly && !selectionPIDpTdependent(track2)) { continue; } - // PID check - if (ispTdepPID && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { + if (!ispTdepPID && !isTOFOnly && !selectionPID(track2)) { + continue; + } + if (isTOFOnly && !selectionPID2(track2)) { continue; } - if (!ispTdepPID && (!selectionPID(track1) || !selectionPID(track2))) { + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) { continue; } if (!selectionPair(track1, track2)) { @@ -549,63 +876,554 @@ struct phipbpb { if (removefaketrak && isFakeKaon(track2)) { continue; } - if (track1.sign() > 0 && track2.sign() < 0) { - KaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); - KaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); - } else if (track1.sign() < 0 && track2.sign() > 0) { - KaonMinus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); - KaonPlus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + if (useGlobalTrack && track2.p() < 1.0 && !(itsResponse.nSigmaITS(track2) > -2.5 && itsResponse.nSigmaITS(track2) < 2.5)) { + continue; } + KaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + KaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); PhiMesonMother = KaonPlus + KaonMinus; - auto phiminuspsi = GetPhiInRange(PhiMesonMother.Phi() - psiFT0C); - auto v2 = TMath::Cos(2.0 * phiminuspsi); - auto v2sin = TMath::Sin(2.0 * phiminuspsi); - histos.fill(HIST("hpTvsRapidity"), PhiMesonMother.Pt(), PhiMesonMother.Rapidity()); - if (TMath::Abs(PhiMesonMother.Rapidity()) < confRapidity) { - histos.fill(HIST("hSparseV2MixedEventCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality); - histos.fill(HIST("hSparseV2MixedEventCosDeltaPhiSquare"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * v2, centrality); - histos.fill(HIST("hSparseV2MixedEventSinDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2sin * QFT0C, centrality); + + if (fillv1) { + auto ux = TMath::Cos(GetPhiInRange(PhiMesonMother.Phi())); + auto uy = TMath::Sin(GetPhiInRange(PhiMesonMother.Phi())); + auto uxQxp = ux * modqxZDCA; + auto uyQyp = uy * modqyZDCA; // correlations of particle and ZDC q vectors + auto uxyQxyp = uxQxp + uyQyp; + auto uxQxt = ux * modqxZDCC; + auto uyQyt = uy * modqyZDCC; + auto uxyQxyt = uxQxt + uyQyt; + auto oddv1 = ux * (modqxZDCA - modqxZDCC) + uy * (modqyZDCA - modqyZDCC); + + histos.fill(HIST("hpoddvscentpteta"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), oddv1); + if (fillLOCC) { + histos.fill(HIST("hpuxyQxypvscentpteta"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), uxyQxyp); + histos.fill(HIST("hpuxyQxytvscentpteta"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), uxyQxyt); + histos.fill(HIST("hpuxvscentpteta"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), ux); + histos.fill(HIST("hpuyvscentpteta"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), uy); + } } - ROOT::Math::Boost boost{PhiMesonMother.BoostToCM()}; - fourVecDauCM = boost(KaonMinus); - threeVecDauCM = fourVecDauCM.Vect(); - threeVecDauCMXY = ROOT::Math::XYZVector(threeVecDauCM.X(), threeVecDauCM.Y(), 0.); - eventplaneVec = ROOT::Math::XYZVector(std::cos(2.0 * psiFT0C), std::sin(2.0 * psiFT0C), 0); - eventplaneVecNorm = ROOT::Math::XYZVector(std::sin(2.0 * psiFT0C), -std::cos(2.0 * psiFT0C), 0); - auto cosPhistarminuspsi = GetPhiInRange(fourVecDauCM.Phi() - psiFT0C); - auto SA = TMath::Cos(2.0 * cosPhistarminuspsi); - auto cosThetaStar = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); - histos.fill(HIST("hSparseV2MixedEventSA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2MixedEventCosThetaStar"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStar, TMath::Abs(PhiMesonMother.Rapidity()), centrality); } + Npostrack = Npostrack + 1; } } - PROCESS_SWITCH(phipbpb, processMixedEventOpti, "Process Mixed event new", true); - void processMC(CollisionMCTrueTable::iterator const& /*TrueCollision*/, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + PROCESS_SWITCH(phipbpb, processSameEventv1, "Process Same event for v1", false); + + BinningTypeVertexContributor binningOnEPAngle{{axisVertex, axisMultiplicityClass, axisEPAngle}, true}; + BinningTypeVertexContributorv1 binningOnSPAngle{{axisVertex, axisMultiplicityClass, axisSPAngle}, true}; + Preslice tracksPerCollision = aod::track::collisionId; + void processMEAcc(EventCandidates const& collisions, TrackCandidates const& tracks) { - histos.fill(HIST("hMC"), 0); - if (RecCollisions.size() == 0) { - histos.fill(HIST("hMC"), 1); - return; - } - if (RecCollisions.size() > 1) { - histos.fill(HIST("hMC"), 2); - return; - } - for (auto& RecCollision : RecCollisions) { - auto psiFT0C = 0.0; - histos.fill(HIST("hMC"), 3); - if (!RecCollision.sel8()) { - histos.fill(HIST("hMC"), 4); + for (auto& [collision1, collision2] : selfCombinations(binningOnEPAngle, cfgNoMixedEvents, -1, collisions, collisions)) { + + if (!collision1.sel8() || !collision1.triggereventep() || !collision1.selection_bit(aod::evsel::kNoSameBunchPileup)) { continue; } - - if (!RecCollision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { - histos.fill(HIST("hMC"), 5); + if (!collision2.sel8() || !collision2.triggereventep() || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup)) { continue; } - if (TMath::Abs(RecCollision.posZ()) > cfgCutVertex) { - histos.fill(HIST("hMC"), 6); + int occupancy1 = collision1.trackOccupancyInTimeRange(); + int occupancy2 = collision2.trackOccupancyInTimeRange(); + if (occupancy1 > cfgCutOccupancy) { + continue; + } + if (occupancy2 > cfgCutOccupancy) { + continue; + } + if (additionalEvsel && !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvsel && !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvselITS && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + if (additionalEvselITS && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + auto centrality = collision1.centFT0C(); + auto psiFT0C = collision1.psiFT0C(); + auto QFT0C = collision1.qFT0C(); + + o2::aod::ITSResponse itsResponse; + auto grouptrack1 = tracks.sliceBy(tracksPerCollision, collision2.globalIndex()); + auto grouptrack2 = tracks.sliceBy(tracksPerCollision, collision2.globalIndex()); + for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(grouptrack1, grouptrack2))) { + if (t2.index() <= t1.index()) { + continue; + } + if (t1.sign() * t2.sign() > 0) { + continue; + } + if (!selectionTrack(t1)) { + continue; + } + if (ispTdepPID && !isTOFOnly && !selectionPIDpTdependent(t1)) { + continue; + } + if (!ispTdepPID && !isTOFOnly && !selectionPID(t1)) { + continue; + } + if (isTOFOnly && !selectionPID2(t1)) { + continue; + } + if (useGlobalTrack && t1.p() < 1.0 && !(itsResponse.nSigmaITS(t1) > -2.5 && itsResponse.nSigmaITS(t1) < 2.5)) { + continue; + } + + if (!selectionTrack(t2)) { + continue; + } + if (ispTdepPID && !isTOFOnly && !selectionPIDpTdependent(t2)) { + continue; + } + if (!ispTdepPID && !isTOFOnly && !selectionPID(t2)) { + continue; + } + if (isTOFOnly && !selectionPID2(t2)) { + continue; + } + if (useGlobalTrack && t2.p() < 1.0 && !(itsResponse.nSigmaITS(t2) > -2.5 && itsResponse.nSigmaITS(t2) < 2.5)) { + continue; + } + + if (!selectionPair(t1, t2)) { + continue; + } + if (removefaketrak && isFakeKaon(t1)) { + continue; + } + if (removefaketrak && isFakeKaon(t2)) { + continue; + } + + KaonPlus = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), massKa); + KaonMinus = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), massKa); + PhiMesonMother = KaonPlus + KaonMinus; + auto phiminuspsi = GetPhiInRange(PhiMesonMother.Phi() - psiFT0C); + auto v2 = TMath::Cos(2.0 * phiminuspsi); + if (TMath::Abs(PhiMesonMother.Rapidity()) > confRapidity) { + continue; + } + + if (useSP) { + histos.fill(HIST("hSparseV2MixEPAngleCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality); + } else { + histos.fill(HIST("hSparseV2MixEPAngleCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); + } + } + } + } + PROCESS_SWITCH(phipbpb, processMEAcc, "Process ME Acceptance", true); + + void processMEAccv1(EventCandidatesv1 const& collisions, TrackCandidates const& tracks) + { + for (auto& [collision1, collision2] : selfCombinations(binningOnSPAngle, cfgNoMixedEvents, -1, collisions, collisions)) { + + if (!collision1.sel8() || !collision1.triggereventsp() || !collision1.selection_bit(aod::evsel::kNoSameBunchPileup)) { + continue; + } + if (!collision2.sel8() || !collision2.triggereventsp() || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup)) { + continue; + } + int occupancy1 = collision1.trackOccupancyInTimeRange(); + int occupancy2 = collision2.trackOccupancyInTimeRange(); + if (occupancy1 > cfgCutOccupancy) { + continue; + } + if (occupancy2 > cfgCutOccupancy) { + continue; + } + if (additionalEvsel && !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvsel && !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvselITS && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + if (additionalEvselITS && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + auto centrality = collision1.centFT0C(); + + auto qxZDCA = collision1.qxZDCA(); + auto qxZDCC = collision1.qxZDCC(); + auto qyZDCA = collision1.qyZDCA(); + auto qyZDCC = collision1.qyZDCC(); + auto psiZDCC = collision1.psiZDCC(); + auto psiZDCA = collision1.psiZDCA(); + + double modqxZDCA; + double modqyZDCA; + double modqxZDCC; + double modqyZDCC; + + if (cqvas) { + modqxZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Cos(psiZDCA); + modqyZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Sin(psiZDCA); + modqxZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Cos(psiZDCC); + modqyZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Sin(psiZDCC); + } else { + modqxZDCA = qxZDCA; + modqyZDCA = qyZDCA; + modqxZDCC = qxZDCC; + modqyZDCC = qyZDCC; + } + + o2::aod::ITSResponse itsResponse; + auto grouptrack1 = tracks.sliceBy(tracksPerCollision, collision1.globalIndex()); + auto grouptrack2 = tracks.sliceBy(tracksPerCollision, collision2.globalIndex()); + for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(grouptrack1, grouptrack2))) { + if (t2.index() <= t1.index()) { + continue; + } + if (t1.sign() * t2.sign() > 0) { + continue; + } + if (!selectionTrack(t1)) { + continue; + } + if (ispTdepPID && !isTOFOnly && !selectionPIDpTdependent(t1)) { + continue; + } + if (!ispTdepPID && !isTOFOnly && !selectionPID(t1)) { + continue; + } + if (isTOFOnly && !selectionPID2(t1)) { + continue; + } + if (useGlobalTrack && t1.p() < 1.0 && !(itsResponse.nSigmaITS(t1) > -2.5 && itsResponse.nSigmaITS(t1) < 2.5)) { + continue; + } + + if (!selectionTrack(t2)) { + continue; + } + if (ispTdepPID && !isTOFOnly && !selectionPIDpTdependent(t2)) { + continue; + } + if (!ispTdepPID && !isTOFOnly && !selectionPID(t2)) { + continue; + } + if (isTOFOnly && !selectionPID2(t2)) { + continue; + } + if (useGlobalTrack && t2.p() < 1.0 && !(itsResponse.nSigmaITS(t2) > -2.5 && itsResponse.nSigmaITS(t2) < 2.5)) { + continue; + } + + if (!selectionPair(t1, t2)) { + continue; + } + if (removefaketrak && isFakeKaon(t1)) { + continue; + } + if (removefaketrak && isFakeKaon(t2)) { + continue; + } + + KaonPlus = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), massKa); + KaonMinus = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), massKa); + PhiMesonMother = KaonPlus + KaonMinus; + + if (fillv1) { + auto ux = TMath::Cos(GetPhiInRange(PhiMesonMother.Phi())); + auto uy = TMath::Sin(GetPhiInRange(PhiMesonMother.Phi())); + auto uxQxp = ux * modqxZDCA; + auto uyQyp = uy * modqyZDCA; // correlations of particle and ZDC q vectors + auto uxyQxyp = uxQxp + uyQyp; + auto uxQxt = ux * modqxZDCC; + auto uyQyt = uy * modqyZDCC; + auto uxyQxyt = uxQxt + uyQyt; + auto oddv1 = ux * (modqxZDCA - modqxZDCC) + uy * (modqyZDCA - modqyZDCC); + + histos.fill(HIST("hpoddvscentptetamixacc"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), oddv1); + if (fillLOCC) { + histos.fill(HIST("hpuxyQxypvscentptetamixacc"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), uxyQxyp); + histos.fill(HIST("hpuxyQxytvscentptetamixacc"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), uxyQxyt); + histos.fill(HIST("hpuxvscentptetamixacc"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), ux); + histos.fill(HIST("hpuyvscentptetamixacc"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), uy); + } + } + } + } + } + PROCESS_SWITCH(phipbpb, processMEAccv1, "Process ME Acceptance v1", false); + + void processMixedEventOpti(EventCandidates const& collisions, TrackCandidates const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicityClass, axisEPAngle}, true}; + SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; + for (auto& [collision1, tracks1, collision2, tracks2] : pair) { + // if (!collision1.sel8() || !collision1.triggereventep() || !collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // continue; + // } + // if (!collision2.sel8() || !collision2.triggereventep() || !collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // continue; + // } + if (!collision1.sel8() || !collision1.triggereventep() || !collision1.selection_bit(aod::evsel::kNoSameBunchPileup)) { + continue; + } + if (!collision2.sel8() || !collision2.triggereventep() || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup)) { + continue; + } + // if (collision1.bcId() == collision2.bcId()) { + // continue; + // } + o2::aod::ITSResponse itsResponse; + int occupancy1 = collision1.trackOccupancyInTimeRange(); + int occupancy2 = collision2.trackOccupancyInTimeRange(); + if (occupancy1 > cfgCutOccupancy) { + continue; + } + if (occupancy2 > cfgCutOccupancy) { + continue; + } + auto centrality = collision1.centFT0C(); + // auto centrality2 = collision2.centFT0C(); + auto psiFT0C = collision1.psiFT0C(); + auto QFT0C = collision1.qFT0C(); + if (additionalEvsel && !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvsel && !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvselITS && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + if (additionalEvselITS && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + + for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (track1.sign() * track2.sign() > 0) { + continue; + } + if (useGlobalTrack && track1.p() < 1.0 && !(itsResponse.nSigmaITS(track1) > -2.5 && itsResponse.nSigmaITS(track1) < 2.5)) { + continue; + } + if (useGlobalTrack && track2.p() < 1.0 && !(itsResponse.nSigmaITS(track2) > -2.5 && itsResponse.nSigmaITS(track2) < 2.5)) { + continue; + } + if (!selectionTrack(track1) || !selectionTrack(track2)) { + continue; + } + // PID check + if (ispTdepPID && !isTOFOnly && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { + continue; + } + if (!ispTdepPID && !isTOFOnly && (!selectionPID(track1) || !selectionPID(track2))) { + continue; + } + if (isTOFOnly && (!selectionPID2(track1) || !selectionPID2(track2))) { + continue; + } + if (!selectionPair(track1, track2)) { + continue; + } + if (removefaketrak && isFakeKaon(track1)) { + continue; + } + if (removefaketrak && isFakeKaon(track2)) { + continue; + } + if (track1.sign() > 0 && track2.sign() < 0) { + KaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + KaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } else if (track1.sign() < 0 && track2.sign() > 0) { + KaonMinus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + KaonPlus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } + PhiMesonMother = KaonPlus + KaonMinus; + auto phiminuspsi = GetPhiInRange(PhiMesonMother.Phi() - psiFT0C); + auto v2 = TMath::Cos(2.0 * phiminuspsi); + auto v2acc = TMath::Cos(4.0 * phiminuspsi); + auto v2sin = TMath::Sin(2.0 * phiminuspsi); + histos.fill(HIST("hpTvsRapidity"), PhiMesonMother.Pt(), PhiMesonMother.Rapidity()); + + if (TMath::Abs(PhiMesonMother.Rapidity()) < confRapidity) { + if (useSP) { + histos.fill(HIST("hSparseV2MixedEventCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality); + histos.fill(HIST("hSparseV2MixedEventCos2DeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2acc * QFT0C, centrality); + } else { + histos.fill(HIST("hSparseV2MixedEventCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); + histos.fill(HIST("hSparseV2MixedEventCos2DeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2acc, centrality); + } + histos.fill(HIST("hSparseV2MixedEventCosDeltaPhiSquare"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * v2, centrality); + histos.fill(HIST("hSparseV2MixedEventSinDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2sin * QFT0C, centrality); + } + if (fillSA) { + ROOT::Math::Boost boost{PhiMesonMother.BoostToCM()}; + fourVecDauCM = boost(KaonMinus); + threeVecDauCM = fourVecDauCM.Vect(); + threeVecDauCMXY = ROOT::Math::XYZVector(threeVecDauCM.X(), threeVecDauCM.Y(), 0.); + eventplaneVec = ROOT::Math::XYZVector(std::cos(2.0 * psiFT0C), std::sin(2.0 * psiFT0C), 0); + eventplaneVecNorm = ROOT::Math::XYZVector(std::sin(2.0 * psiFT0C), -std::cos(2.0 * psiFT0C), 0); + auto cosPhistarminuspsi = GetPhiInRange(fourVecDauCM.Phi() - psiFT0C); + auto SA = TMath::Cos(2.0 * cosPhistarminuspsi); + auto cosThetaStar = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); + histos.fill(HIST("hSparseV2MixedEventSA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); + histos.fill(HIST("hSparseV2MixedEventCosThetaStar"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStar, TMath::Abs(PhiMesonMother.Rapidity()), centrality); + } + } + } + } + PROCESS_SWITCH(phipbpb, processMixedEventOpti, "Process Mixed event new", true); + + void processMixedEventOptiv1(EventCandidatesv1 const& collisions, TrackCandidates const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + BinningTypeVertexContributorv1 binningOnPositions{{axisVertex, axisMultiplicityClass, axisSPAngle}, true}; + SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; + for (auto& [collision1, tracks1, collision2, tracks2] : pair) { + if (!collision1.sel8() || !collision1.triggereventsp() || !collision1.selection_bit(aod::evsel::kNoSameBunchPileup)) { + continue; + } + if (!collision2.sel8() || !collision2.triggereventsp() || !collision2.selection_bit(aod::evsel::kNoSameBunchPileup)) { + continue; + } + o2::aod::ITSResponse itsResponse; + int occupancy1 = collision1.trackOccupancyInTimeRange(); + int occupancy2 = collision2.trackOccupancyInTimeRange(); + if (occupancy1 > cfgCutOccupancy) { + continue; + } + if (occupancy2 > cfgCutOccupancy) { + continue; + } + auto centrality = collision1.centFT0C(); + + if (additionalEvsel && !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvsel && !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvselITS && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + if (additionalEvselITS && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + + auto qxZDCA = collision1.qxZDCA(); + auto qxZDCC = collision1.qxZDCC(); + auto qyZDCA = collision1.qyZDCA(); + auto qyZDCC = collision1.qyZDCC(); + auto psiZDCC = collision1.psiZDCC(); + auto psiZDCA = collision1.psiZDCA(); + + double modqxZDCA; + double modqyZDCA; + double modqxZDCC; + double modqyZDCC; + + if (cqvas) { + modqxZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Cos(psiZDCA); + modqyZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Sin(psiZDCA); + modqxZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Cos(psiZDCC); + modqyZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Sin(psiZDCC); + } else { + modqxZDCA = qxZDCA; + modqyZDCA = qyZDCA; + modqxZDCC = qxZDCC; + modqyZDCC = qyZDCC; + } + + for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (track1.sign() * track2.sign() > 0) { + continue; + } + if (useGlobalTrack && track1.p() < 1.0 && !(itsResponse.nSigmaITS(track1) > -2.5 && itsResponse.nSigmaITS(track1) < 2.5)) { + continue; + } + if (useGlobalTrack && track2.p() < 1.0 && !(itsResponse.nSigmaITS(track2) > -2.5 && itsResponse.nSigmaITS(track2) < 2.5)) { + continue; + } + if (!selectionTrack(track1) || !selectionTrack(track2)) { + continue; + } + // PID check + if (ispTdepPID && !isTOFOnly && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { + continue; + } + if (!ispTdepPID && !isTOFOnly && (!selectionPID(track1) || !selectionPID(track2))) { + continue; + } + if (isTOFOnly && (!selectionPID2(track1) || !selectionPID2(track2))) { + continue; + } + if (!selectionPair(track1, track2)) { + continue; + } + if (removefaketrak && isFakeKaon(track1)) { + continue; + } + if (removefaketrak && isFakeKaon(track2)) { + continue; + } + if (track1.sign() > 0 && track2.sign() < 0) { + KaonPlus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + KaonMinus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } else if (track1.sign() < 0 && track2.sign() > 0) { + KaonMinus = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); + KaonPlus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + } + PhiMesonMother = KaonPlus + KaonMinus; + + if (fillv1) { + auto ux = TMath::Cos(GetPhiInRange(PhiMesonMother.Phi())); + auto uy = TMath::Sin(GetPhiInRange(PhiMesonMother.Phi())); + auto uxQxp = ux * modqxZDCA; + auto uyQyp = uy * modqyZDCA; // correlations of particle and ZDC q vectors + auto uxyQxyp = uxQxp + uyQyp; + auto uxQxt = ux * modqxZDCC; + auto uyQyt = uy * modqyZDCC; + auto uxyQxyt = uxQxt + uyQyt; + auto oddv1 = ux * (modqxZDCA - modqxZDCC) + uy * (modqyZDCA - modqyZDCC); + + histos.fill(HIST("hpoddvscentptetamixopti"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), oddv1); + if (fillLOCC) { + histos.fill(HIST("hpuxyQxypvscentptetamixopti"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), uxyQxyp); + histos.fill(HIST("hpuxyQxytvscentptetamixopti"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), uxyQxyt); + histos.fill(HIST("hpuxvscentptetamixopti"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), ux); + histos.fill(HIST("hpuyvscentptetamixopti"), PhiMesonMother.M(), centrality, PhiMesonMother.Pt(), PhiMesonMother.Rapidity(), uy); + } + } + } + } + } + PROCESS_SWITCH(phipbpb, processMixedEventOptiv1, "Process Mixed event new v1", false); + + void processMC(CollisionMCTrueTable::iterator const& /*TrueCollision*/, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + { + histos.fill(HIST("hMC"), 0); + if (RecCollisions.size() == 0) { + histos.fill(HIST("hMC"), 1); + return; + } + if (RecCollisions.size() > 1) { + histos.fill(HIST("hMC"), 2); + return; + } + for (auto& RecCollision : RecCollisions) { + auto psiFT0C = 0.0; + histos.fill(HIST("hMC"), 3); + if (!RecCollision.sel8()) { + histos.fill(HIST("hMC"), 4); + continue; + } + + if (!RecCollision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + histos.fill(HIST("hMC"), 5); + continue; + } + if (TMath::Abs(RecCollision.posZ()) > cfgCutVertex) { + histos.fill(HIST("hMC"), 6); continue; } histos.fill(HIST("hMC"), 7); @@ -767,6 +1585,267 @@ struct phipbpb { } // process MC PROCESS_SWITCH(phipbpb, processMC, "Process MC", false); + using recoTracks = soa::Join; + void processMCweight(aod::McCollision const& mcCollision, soa::Join const& mcParticles, recoTracks const&) + { + float imp = mcCollision.impactParameter(); + float evPhi = mcCollision.eventPlaneAngle() / 2.0; + float centclass = -999; + if (imp >= 0 && imp < 3.49) { + centclass = 2.5; + } + if (imp >= 3.49 && imp < 4.93) { + centclass = 7.5; + } + if (imp >= 4.93 && imp < 6.98) { + centclass = 15.0; + } + if (imp >= 6.98 && imp < 8.55) { + centclass = 25.0; + } + if (imp >= 8.55 && imp < 9.87) { + centclass = 35.0; + } + if (imp >= 9.87 && imp < 11) { + centclass = 45.0; + } + if (imp >= 11 && imp < 12.1) { + centclass = 55.0; + } + if (imp >= 12.1 && imp < 13.1) { + centclass = 65.0; + } + if (imp >= 13.1 && imp < 14) { + centclass = 75.0; + } + // if (evPhi < 0) + // evPhi += 2. * TMath::Pi(); + + int nCh = 0; + + if (centclass > 0 && centclass < 80) { + // event within range + histos.fill(HIST("hImpactParameter"), imp); + histos.fill(HIST("hEventPlaneAngle"), evPhi); + for (auto const& mcParticle : mcParticles) { + + float deltaPhi = mcParticle.phi() - mcCollision.eventPlaneAngle(); + // focus on bulk: e, mu, pi, k, p + int pdgCode = TMath::Abs(mcParticle.pdgCode()); + if (checkAllCharge && pdgCode != 11 && pdgCode != 13 && pdgCode != 211 && pdgCode != 321 && pdgCode != 2212) + continue; + if (!checkAllCharge && pdgCode != 321) + continue; + if (!mcParticle.isPhysicalPrimary()) + continue; + if (TMath::Abs(mcParticle.eta()) > 0.8) // main acceptance + continue; + histos.fill(HIST("hSparseMCGenWeight"), centclass, GetPhiInRange(deltaPhi), TMath::Power(TMath::Cos(4.0 * GetPhiInRange(deltaPhi)), 1.0), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hSparseMCGenV2"), centclass, TMath::Cos(2.0 * GetPhiInRange(deltaPhi)), mcParticle.pt()); + histos.fill(HIST("hSparseMCGenV2Square"), centclass, TMath::Power(TMath::Cos(2.0 * GetPhiInRange(deltaPhi)), 2.0), mcParticle.pt()); + nCh++; + bool validGlobal = false; + bool validAny = false; + if (mcParticle.has_tracks()) { + auto const& tracks = mcParticle.tracks_as(); + for (auto const& track : tracks) { + if (track.hasTPC() && track.hasITS()) { + validGlobal = true; + } + if (track.hasTPC() || track.hasITS()) { + validAny = true; + } + } + } + // if valid global, fill + if (validGlobal) { + histos.fill(HIST("hSparseMCRecWeight"), centclass, GetPhiInRange(deltaPhi), TMath::Power(TMath::Cos(4.0 * GetPhiInRange(deltaPhi)), 1.0), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hSparseMCRecV2"), centclass, TMath::Cos(2.0 * GetPhiInRange(deltaPhi)), mcParticle.pt()); + histos.fill(HIST("hSparseMCRecV2Square"), centclass, TMath::Power(TMath::Cos(2.0 * GetPhiInRange(deltaPhi)), 2.0), mcParticle.pt()); + } + if (validAny) { + histos.fill(HIST("hSparseMCRecAllTrackWeight"), centclass, GetPhiInRange(deltaPhi), TMath::Power(TMath::Cos(4.0 * GetPhiInRange(deltaPhi)), 1.0), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hEventPlaneAngleRec"), GetPhiInRange(deltaPhi)); + } + // if any track present, fill + } + } + histos.fill(HIST("hNchVsImpactParameter"), imp, nCh); + } + PROCESS_SWITCH(phipbpb, processMCweight, "Process MC Weight", false); + + void processMCPhiWeight(CollisionMCTrueTable::iterator const& TrueCollision, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + { + float imp = TrueCollision.impactParameter(); + float evPhi = TrueCollision.eventPlaneAngle() / 2.0; + float centclass = -999; + if (imp >= 0 && imp < 3.49) { + centclass = 2.5; + } + if (imp >= 3.49 && imp < 4.93) { + centclass = 7.5; + } + if (imp >= 4.93 && imp < 6.98) { + centclass = 15.0; + } + if (imp >= 6.98 && imp < 8.55) { + centclass = 25.0; + } + if (imp >= 8.55 && imp < 9.87) { + centclass = 35.0; + } + if (imp >= 9.87 && imp < 11) { + centclass = 45.0; + } + if (imp >= 11 && imp < 12.1) { + centclass = 55.0; + } + if (imp >= 12.1 && imp < 13.1) { + centclass = 65.0; + } + if (imp >= 13.1 && imp < 14) { + centclass = 75.0; + } + histos.fill(HIST("hImpactParameter"), imp); + histos.fill(HIST("hEventPlaneAngle"), evPhi); + if (centclass < 0.0 || centclass > 80.0) { + return; + } + for (auto& RecCollision : RecCollisions) { + auto psiFT0C = TrueCollision.eventPlaneAngle(); + /* + if (!RecCollision.sel8()) { + continue; + } + if (!RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + continue; + } + */ + if (TMath::Abs(RecCollision.posZ()) > cfgCutVertex) { + continue; + } + auto oldindex = -999; + auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); + // loop over reconstructed particle + for (auto track1 : Rectrackspart) { + if (!track1.has_mcParticle()) { + continue; + } + + const auto mctrack1 = track1.mcParticle(); + + if (selectionTrack(track1) && selectionPIDpTdependent(track1) && TMath::Abs(mctrack1.pdgCode()) == 321 && mctrack1.isPhysicalPrimary()) { + histos.fill(HIST("hSparsePhiMCRecKaonWeight"), centclass, GetPhiInRange(mctrack1.phi() - psiFT0C), TMath::Power(TMath::Cos(4.0 * GetPhiInRange(mctrack1.phi() - psiFT0C)), 1.0), mctrack1.pt(), mctrack1.eta()); + } + + if (selectionTrack(track1) && track1.pt() > 0.5 && track1.hasTOF() && TMath::Abs(track1.tofNSigmaKa()) > nsigmaCutTOF && TMath::Abs(track1.tpcNSigmaKa()) < nsigmaCutTPC && TMath::Abs(mctrack1.pdgCode()) == 321 && mctrack1.isPhysicalPrimary()) { + histos.fill(HIST("hSparsePhiMCRecKaonMissMatchWeight"), centclass, GetPhiInRange(mctrack1.phi() - psiFT0C), TMath::Power(TMath::Cos(4.0 * GetPhiInRange(mctrack1.phi() - psiFT0C)), 1.0), mctrack1.pt(), mctrack1.eta()); + } + auto track1ID = track1.index(); + for (auto track2 : Rectrackspart) { + if (!track2.has_mcParticle()) { + continue; + } + auto track2ID = track2.index(); + if (track2ID <= track1ID) { + continue; + } + const auto mctrack2 = track2.mcParticle(); + int track1PDG = TMath::Abs(mctrack1.pdgCode()); + int track2PDG = TMath::Abs(mctrack2.pdgCode()); + if (!mctrack1.isPhysicalPrimary()) { + continue; + } + if (!mctrack2.isPhysicalPrimary()) { + continue; + } + if (!(track1PDG == 321 && track2PDG == 321)) { + continue; + } + if (!selectionTrack(track1) || !selectionTrack(track2) || track1.sign() * track2.sign() > 0) { + continue; + } + // PID check + if (ispTdepPID && !isTOFOnly && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { + continue; + } + if (!ispTdepPID && !isTOFOnly && (!selectionPID(track1) || !selectionPID(track2))) { + continue; + } + if (isTOFOnly && (!selectionPID2(track1) || !selectionPID2(track2))) { + continue; + } + for (auto& mothertrack1 : mctrack1.mothers_as()) { + for (auto& mothertrack2 : mctrack2.mothers_as()) { + if (mothertrack1.pdgCode() != mothertrack2.pdgCode()) { + continue; + } + if (mothertrack1 != mothertrack2) { + continue; + } + if (TMath::Abs(mothertrack1.y()) > confRapidity) { + continue; + } + if (TMath::Abs(mothertrack1.pdgCode()) != 333) { + continue; + } + // if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { + if (avoidsplitrackMC && oldindex == mothertrack1.index()) { + histos.fill(HIST("h1PhiRecsplit"), mothertrack1.pt()); + continue; + } + // oldindex = mothertrack1.globalIndex(); + oldindex = mothertrack1.index(); + auto PhiMinusPsi = GetPhiInRange(mothertrack1.phi() - psiFT0C); + histos.fill(HIST("hSparsePhiMCRecWeight"), centclass, PhiMinusPsi, TMath::Power(TMath::Cos(4.0 * PhiMinusPsi), 1.0), mothertrack1.pt(), mothertrack1.eta()); + } + } + } + } + // loop over generated particle + for (auto& mcParticle : GenParticles) { + if (TMath::Abs(mcParticle.eta()) > 0.8) // main acceptance + continue; + if (TMath::Abs(mcParticle.pdgCode()) == 321 && mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("hSparsePhiMCGenKaonWeight"), centclass, GetPhiInRange(mcParticle.phi() - psiFT0C), TMath::Power(TMath::Cos(4.0 * GetPhiInRange(mcParticle.phi() - psiFT0C)), 1.0), mcParticle.pt(), mcParticle.eta()); + } + if (TMath::Abs(mcParticle.y()) > confRapidity) { + continue; + } + if (mcParticle.pdgCode() != 333) { + continue; + } + auto kDaughters = mcParticle.daughters_as(); + if (kDaughters.size() != 2) { + continue; + } + auto daughtp = false; + auto daughtm = false; + for (auto kCurrentDaughter : kDaughters) { + if (!kCurrentDaughter.isPhysicalPrimary()) { + continue; + } + if (kCurrentDaughter.pdgCode() == +321) { + if (kCurrentDaughter.pt() > cfgCutPT && TMath::Abs(kCurrentDaughter.eta()) < cfgCutEta) { + daughtp = true; + } + KaonPlus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); + } else if (kCurrentDaughter.pdgCode() == -321) { + if (kCurrentDaughter.pt() > cfgCutPT && TMath::Abs(kCurrentDaughter.eta()) < cfgCutEta) { + daughtm = true; + } + KaonMinus = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); + } + } + if (daughtp && daughtm) { + auto PhiMinusPsiGen = GetPhiInRange(mcParticle.phi() - psiFT0C); + histos.fill(HIST("hSparsePhiMCGenWeight"), centclass, PhiMinusPsiGen, TMath::Power(TMath::Cos(4.0 * PhiMinusPsiGen), 1.0), mcParticle.pt(), mcParticle.eta()); + } + } + } // rec collision loop + + } // process MC + PROCESS_SWITCH(phipbpb, processMCPhiWeight, "Process MC Phi Weight", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGLF/Tasks/Resonances/rho770analysis.cxx b/PWGLF/Tasks/Resonances/rho770analysis.cxx index 8e7932fdb81..07531afc724 100644 --- a/PWGLF/Tasks/Resonances/rho770analysis.cxx +++ b/PWGLF/Tasks/Resonances/rho770analysis.cxx @@ -12,7 +12,7 @@ /// \file rho770analysis.cxx /// \brief rho(770)0 analysis in pp 13 & 13.6 TeV /// \author Hyunji Lim (hyunji.lim@cern.ch) -/// \since 12/04/2024 +/// \since 03/12/2025 #include #include @@ -38,12 +38,14 @@ struct rho770analysis { SliceCache cache; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + using ResoMCCols = soa::Join; + Configurable cfgMinPt{"cfgMinPt", 0.15, "Minimum transverse momentum for charged track"}; Configurable cfgMaxEta{"cfgMaxEta", 0.8, "Maximum pseudorapidiy for charged track"}; Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.15, "Maximum transverse DCA"}; Configurable cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 2.0, "Maximum longitudinal DCA"}; Configurable cfgMaxTPC{"cfgMaxTPC", 5.0, "Maximum TPC PID with TOF"}; - Configurable cfgMaxTOF{"cfgMaxTOF", 3.0, "Maximum TOF PID with TPC"}; + Configurable cfgMaxTOF{"cfgMaxTOF", 5.0, "Maximum TOF PID with TPC"}; Configurable cfgMinRap{"cfgMinRap", -0.5, "Minimum rapidity for pair"}; Configurable cfgMaxRap{"cfgMaxRap", 0.5, "Maximum rapidity for pair"}; @@ -59,20 +61,15 @@ struct rho770analysis { // kEtaRange) Configurable cfgPVContributor{"cfgPVContributor", true, "PV contributor track selection"}; // PV Contriuibutor Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz - Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; Configurable cfgTPCcluster{"cfgTPCcluster", 0, "Number of TPC cluster"}; - Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.0f, "TPC Crossed Rows to Findable Clusters"}; - Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 999.0, "ITS Chi2/NCl"}; - Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 999.0, "TPC Chi2/NCl"}; Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; - Configurable cfgHasITS{"cfgHasITS", false, "Require ITS"}; - Configurable cfgHasTPC{"cfgHasTPC", false, "Require TPC"}; Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; // PID Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF - Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC + Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 5.0, "TPC nSigma cut for Pion"}; // TPC + Configurable cMaxTPCnSigmaPionnoTOF{"cMaxTPCnSigmaPionnoTOF", 2.0, "TPC nSigma cut for Pion in no TOF case"}; // TPC Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", 3.0, "Combined nSigma cut for Pion"}; Configurable selectType{"selectType", 0, "PID selection type"}; @@ -87,6 +84,7 @@ struct rho770analysis { { AxisSpec pidqaAxis = {120, -6, 6}; AxisSpec pTqaAxis = {200, 0, 20}; + AxisSpec mcLabelAxis = {5, -0.5, 4.5, "MC Label"}; histos.add("hInvMass_rho770_US", "unlike invariant mass", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis}}); histos.add("hInvMass_rho770_LSpp", "++ invariant mass", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis}}); @@ -100,12 +98,16 @@ struct rho770analysis { histos.add("hInvMass_Kstar_LSpp", "Kstar ++ invariant mass", {HistType::kTHnSparseF, {massKstarAxis, ptAxis, centAxis}}); histos.add("hInvMass_Kstar_LSmm", "Kstar -- invariant mass", {HistType::kTHnSparseF, {massKstarAxis, ptAxis, centAxis}}); + histos.add("QA/Nsigma_TPC_BF", "", {HistType::kTH2F, {pTqaAxis, pidqaAxis}}); + histos.add("QA/Nsigma_TOF_BF", "", {HistType::kTH2F, {pTqaAxis, pidqaAxis}}); + histos.add("QA/TPC_TOF_BF", "", {HistType::kTH2F, {pidqaAxis, pidqaAxis}}); + histos.add("QA/Nsigma_TPC", "", {HistType::kTH2F, {pTqaAxis, pidqaAxis}}); histos.add("QA/Nsigma_TOF", "", {HistType::kTH2F, {pTqaAxis, pidqaAxis}}); histos.add("QA/TPC_TOF", "", {HistType::kTH2F, {pidqaAxis, pidqaAxis}}); if (doprocessMCLight) { - histos.add("MCL/hpT_rho770_GEN", "generated rho770 signals", HistType::kTH1F, {ptAxis}); + histos.add("MCL/hpT_rho770_GEN", "generated rho770 signals", HistType::kTHnSparseF, {mcLabelAxis, massAxis, ptAxis, centAxis}); histos.add("MCL/hpT_rho770_REC", "reconstructed rho770 signals", HistType::kTHnSparseF, {massAxis, ptAxis, centAxis}); histos.add("MCL/hpT_omega_REC", "reconstructed omega signals", HistType::kTHnSparseF, {massAxis, ptAxis, centAxis}); histos.add("MCL/hpT_K0s_REC", "reconstructed K0s signals", HistType::kTHnSparseF, {massAxis, ptAxis, centAxis}); @@ -131,20 +133,8 @@ struct rho770analysis { return false; if (std::abs(track.dcaZ()) > cfgMaxDCAzToPVcut) return false; - if (track.itsNCls() < cfgITScluster) - return false; if (track.tpcNClsFound() < cfgTPCcluster) return false; - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) - return false; - if (track.itsChi2NCl() >= cfgITSChi2NCl) - return false; - if (track.tpcChi2NCl() >= cfgTPCChi2NCl) - return false; - if (cfgHasITS && !track.hasITS()) - return false; - if (cfgHasTPC && !track.hasTPC()) - return false; if (cfgHasTOF && !track.hasTOF()) return false; if (cfgUseITSRefit && !track.passedITSRefit()) @@ -178,6 +168,15 @@ struct rho770analysis { if (track.tpcNSigmaPi() * track.tpcNSigmaPi() + track.tofNSigmaPi() * track.tofNSigmaPi() >= nsigmaCutCombinedPion * nsigmaCutCombinedPion) return false; } + if (selectType == 3) { + if (track.hasTOF()) { + if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPion || std::fabs(track.tofNSigmaPi()) >= cMaxTOFnSigmaPion) + return false; + } else if (!track.hasTOF()) { + if (std::fabs(track.tpcNSigmaPi()) >= cMaxTPCnSigmaPionnoTOF) + return false; + } + } return true; } @@ -196,6 +195,15 @@ struct rho770analysis { if (track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa() >= nsigmaCutCombinedPion * nsigmaCutCombinedPion) return false; } + if (selectType == 3) { + if (track.hasTOF()) { + if (std::fabs(track.tpcNSigmaKa()) >= cMaxTPCnSigmaPion || std::fabs(track.tofNSigmaKa()) >= cMaxTOFnSigmaPion) + return false; + } else if (!track.hasTOF()) { + if (std::fabs(track.tpcNSigmaKa()) >= cMaxTPCnSigmaPionnoTOF) + return false; + } + } return true; } @@ -204,7 +212,12 @@ struct rho770analysis { { TLorentzVector part1, part2, reco; for (const auto& [trk1, trk2] : combinations(CombinationsUpperIndexPolicy(dTracks, dTracks))) { + if (trk1.index() == trk2.index()) { + histos.fill(HIST("QA/Nsigma_TPC_BF"), trk1.pt(), trk1.tpcNSigmaPi()); + histos.fill(HIST("QA/Nsigma_TOF_BF"), trk1.pt(), trk1.tofNSigmaPi()); + histos.fill(HIST("QA/TPC_TOF_BF"), trk1.tpcNSigmaPi(), trk1.tofNSigmaPi()); + if (!selTrack(trk1)) continue; @@ -242,84 +255,8 @@ struct rho770analysis { histos.fill(HIST("MCL/hpT_K0s_pipi_REC"), reco.M(), reco.Pt(), collision.cent()); } } else if ((std::abs(trk1.pdgCode()) == 211 && std::abs(trk2.pdgCode()) == 321) || (std::abs(trk1.pdgCode()) == 321 && std::abs(trk2.pdgCode()) == 211)) { - if (std::abs(trk1.motherPDG()) == 313) + if (std::abs(trk1.motherPDG()) == 313) { histos.fill(HIST("MCL/hpT_Kstar_REC"), reco.M(), reco.Pt(), collision.cent()); - histos.fill(HIST("QA/Nsigma_TPC"), trk1.pt(), trk1.tpcNSigmaPi()); - histos.fill(HIST("QA/Nsigma_TOF"), trk1.pt(), trk1.tofNSigmaPi()); - histos.fill(HIST("QA/TPC_TOF"), trk1.tpcNSigmaPi(), trk1.tofNSigmaPi()); - continue; - } - - if (!selTrack(trk1) || !selTrack(trk2)) - continue; - - if (selPion(trk1) && selPion(trk2)) { - part1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi); - part2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi); - reco = part1 + part2; - - if (reco.Rapidity() > cfgMaxRap || reco.Rapidity() < cfgMinRap) - continue; - - if (trk1.sign() * trk2.sign() < 0) { - histos.fill(HIST("hInvMass_rho770_US"), reco.M(), reco.Pt(), collision.cent()); - histos.fill(HIST("hInvMass_K0s_US"), reco.M(), reco.Pt(), collision.cent()); - - if constexpr (IsMC) { - if (trk1.motherId() != trk2.motherId()) - continue; - if (std::abs(trk1.pdgCode()) == 211 && std::abs(trk2.pdgCode()) == 211) { - if (std::abs(trk1.motherPDG()) == 113) { - histos.fill(HIST("MCL/hpT_rho770_REC"), reco.M(), reco.Pt(), collision.cent()); - } else if (std::abs(trk1.motherPDG()) == 223) { - histos.fill(HIST("MCL/hpT_omega_REC"), reco.M(), reco.Pt(), collision.cent()); - } else if (std::abs(trk1.motherPDG()) == 310) { - histos.fill(HIST("MCL/hpT_K0s_REC"), reco.M(), reco.Pt(), collision.cent()); - histos.fill(HIST("MCL/hpT_K0s_pipi_REC"), reco.M(), reco.Pt(), collision.cent()); - } - } else if ((std::abs(trk1.pdgCode()) == 211 && std::abs(trk2.pdgCode()) == 321) || (std::abs(trk1.pdgCode()) == 321 && std::abs(trk2.pdgCode()) == 211)) { - if (std::abs(trk1.motherPDG()) == 313) - histos.fill(HIST("MCL/hpT_Kstar_REC"), reco.M(), reco.Pt(), collision.cent()); - } - } - } else if (trk1.sign() > 0 && trk2.sign() > 0) { - histos.fill(HIST("hInvMass_rho770_LSpp"), reco.M(), reco.Pt(), collision.cent()); - histos.fill(HIST("hInvMass_K0s_LSpp"), reco.M(), reco.Pt(), collision.cent()); - } else if (trk1.sign() < 0 && trk2.sign() < 0) { - histos.fill(HIST("hInvMass_rho770_LSmm"), reco.M(), reco.Pt(), collision.cent()); - histos.fill(HIST("hInvMass_K0s_LSmm"), reco.M(), reco.Pt(), collision.cent()); - } - } - - if ((selPion(trk1) && selKaon(trk2)) || (selKaon(trk1) && selPion(trk2))) { - if (selPion(trk1)) { - part1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi); - part2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); - } else if (selPion(trk2)) { - part1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massKa); - part2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi); - } - reco = part1 + part2; - - if (reco.Rapidity() > cfgMaxRap || reco.Rapidity() < cfgMinRap) - continue; - - if (trk1.sign() * trk2.sign() < 0) { - histos.fill(HIST("hInvMass_Kstar_US"), reco.M(), reco.Pt(), collision.cent()); - - if constexpr (IsMC) { - if (trk1.motherId() != trk2.motherId()) - continue; - - if ((std::abs(trk1.pdgCode()) == 211 && std::abs(trk2.pdgCode()) == 321) || (std::abs(trk1.pdgCode()) == 321 && std::abs(trk2.pdgCode()) == 211)) { - if (std::abs(trk1.motherPDG()) == 313) - histos.fill(HIST("MCL/hpT_Kstar_Kpi_REC"), reco.M(), reco.Pt(), collision.cent()); - } - } - } else if (trk1.sign() > 0 && trk2.sign() > 0) { - histos.fill(HIST("hInvMass_Kstar_LSpp"), reco.M(), reco.Pt(), collision.cent()); - } else if (trk1.sign() < 0 && trk2.sign() < 0) { - histos.fill(HIST("hInvMass_Kstar_LSmm"), reco.M(), reco.Pt(), collision.cent()); } } } @@ -333,10 +270,10 @@ struct rho770analysis { } if ((selPion(trk1) && selKaon(trk2)) || (selKaon(trk1) && selPion(trk2))) { - if (selPion(trk1)) { + if (selPion(trk1) && selKaon(trk2)) { part1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi); part2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); - } else if (selPion(trk2)) { + } else if (selKaon(trk1) && selPion(trk2)) { part1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massKa); part2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi); } @@ -351,10 +288,10 @@ struct rho770analysis { if constexpr (IsMC) { if (trk1.motherId() != trk2.motherId()) continue; - if ((std::abs(trk1.pdgCode()) == 211 && std::abs(trk2.pdgCode()) == 321) || (std::abs(trk1.pdgCode()) == 321 && std::abs(trk2.pdgCode()) == 211)) { - if (std::abs(trk1.motherPDG()) == 313) + if (std::abs(trk1.motherPDG()) == 313) { histos.fill(HIST("MCL/hpT_Kstar_Kpi_REC"), reco.M(), reco.Pt(), collision.cent()); + } } } } else if (trk1.sign() > 0 && trk2.sign() > 0) { @@ -378,8 +315,10 @@ struct rho770analysis { } PROCESS_SWITCH(rho770analysis, processMCLight, "Process Event for MC", false); - void processMCTrue(aod::ResoMCParents const& resoParents) + void processMCTrue(ResoMCCols::iterator const& collision, aod::ResoMCParents const& resoParents) { + auto multiplicity = collision.cent(); + for (const auto& part : resoParents) { // loop over all pre-filtered MC particles if (std::abs(part.pdgCode()) != 113) continue; @@ -387,13 +326,27 @@ struct rho770analysis { continue; if (part.y() < cfgMinRap || part.y() > cfgMaxRap) continue; - bool pass = false; - if ((std::abs(part.daughterPDG1()) == 211 && std::abs(part.daughterPDG2()) == 211)) - pass = true; - if (!pass) // If we have both decay products + if (!(std::abs(part.daughterPDG1()) == 211 && std::abs(part.daughterPDG2()) == 211)) continue; - histos.fill(HIST("MCL/hpT_rho770_GEN"), part.pt()); + TLorentzVector truthpar; + truthpar.SetPxPyPzE(part.px(), part.py(), part.pz(), part.e()); + auto mass = truthpar.M(); + + histos.fill(HIST("MCL/hpT_rho770_GEN"), 0, mass, part.pt(), multiplicity); + + if (collision.isVtxIn10()) { + histos.fill(HIST("MCL/hpT_rho770_GEN"), 1, mass, part.pt(), multiplicity); + } + if (collision.isVtxIn10() && collision.isInSel8()) { + histos.fill(HIST("MCL/hpT_rho770_GEN"), 2, mass, part.pt(), multiplicity); + } + if (collision.isVtxIn10() && collision.isTriggerTVX()) { + histos.fill(HIST("MCL/hpT_rho770_GEN"), 3, mass, part.pt(), multiplicity); + } + if (collision.isInAfterAllCuts()) { + histos.fill(HIST("MCL/hpT_rho770_GEN"), 4, mass, part.pt(), multiplicity); + } } }; PROCESS_SWITCH(rho770analysis, processMCTrue, "Process Event for MC", false); @@ -401,6 +354,5 @@ struct rho770analysis { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx b/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx index 0e90a84101e..42773fa2947 100644 --- a/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx +++ b/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx @@ -13,7 +13,8 @@ /// \brief Reconstruction of Xi* resonance. /// /// \author Min-jae Kim , Bong-Hwi Lim -#include +// #include +#include "Math/Vector4D.h" #include "TF1.h" #include "TRandom3.h" @@ -34,7 +35,8 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::constants::physics; -Service pdgDB; +using LorentzVectorPtEtaPhiMass = ROOT::Math::PtEtaPhiMVector; +// Service pdgDB; enum { kData = 0, @@ -45,111 +47,110 @@ enum { kMCTruePS, kINEL10, kINELg010, - kAllType + kAllType, + kXiStar = 3324 }; -enum { - PionPID = 211, - XiPID = 3312, - XiStarPID = 3324 -}; - -struct xi1530analysisqa { +struct Xi1530Analysisqa { // Basic set-up // - Configurable cMassXiminus{"cMassXiminus", 1.32171, "Mass of Xi baryon"}; SliceCache cache; Preslice perRCol = aod::resodaughter::resoCollisionId; Preslice perCollision = aod::track::collisionId; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; using ResoMCCols = soa::Join; + Configurable cMassXiminus{"cMassXiminus", 1.32171, "Mass of Xi baryon"}; - // associated with histograms + // Associated with histograms ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 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, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"}; ConfigurableAxis binsPtQA{"binsPtQA", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8, 5.0, 5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0}, "Binning of the pT axis"}; ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}, "Binning of the centrality axis"}; Configurable cInvMassStart{"cInvMassStart", 1.4, "Invariant mass start"}; - Configurable cInvMassEnd{"cInvMassEnd", 1.8, "Invariant mass end"}; - Configurable cInvMassBins{"cInvMassBins", 200, "Invariant mass binning"}; - - Configurable cPIDBins{"cPIDBins", 130, "PID binning"}; - Configurable cPIDQALimit{"cPIDQALimit", 6.5, "PID QA limit"}; - Configurable cDCABins{"cDCABins", 150, "DCA binning"}; - - Configurable invmass1D{"invmass1D", true, "Invariant mass 1D"}; - Configurable study_antiparticle{"study_antiparticle", true, "Study anti-particles separately"}; - Configurable PIDplots{"PIDplots", true, "Make TPC and TOF PID plots"}; + Configurable cInvMassEnd{"cInvMassEnd", 3.0, "Invariant mass end"}; + Configurable cInvMassBins{"cInvMassBins", 800, "Invariant mass binning"}; + Configurable invMass1D{"invMass1D", true, "Invariant mass 1D"}; + Configurable studyAntiparticle{"studyAntiparticle", true, "Study anti-particles separately"}; + Configurable pidPlots{"pidPlots", true, "Make TPC and TOF PID plots"}; Configurable additionalQAplots{"additionalQAplots", true, "Additional QA plots"}; - Configurable additionalQAeventPlots{"additionalQAeventPlots", true, "Additional QA event plots"}; - Configurable additionalMEPlots{"additionalMEPlots", true, "Additional Mixed event plots"}; // Event Mixing Configurable nEvtMixing{"nEvtMixing", 10, "Number of events to mix"}; - ConfigurableAxis CfgVtxBins{"CfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; - ConfigurableAxis CfgMultBins{"CfgMultBins", {VARIABLE_WIDTH, 0.0f, 1.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; + ConfigurableAxis cfgMultBins{"cfgMultBins", {VARIABLE_WIDTH, 0.0f, 1.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Mixing bins - z-vertex"}; //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// - // Track selections (Execpt DCA selelctions) // + // Track selections (Except DCA selelctions) // // Primary track selections - Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"}; - Configurable cMaxetacut{"cMaxetacut", 0.8, "Track maximum eta cut"}; + Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"}; + Configurable cMaxetacut{"cMaxetacut", 0.8, "Track maximum eta cut"}; Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; - Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; - Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; - Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; - - Configurable tof_at_high_pt{"tof_at_high_pt", false, "Use TOF at high pT"}; + Configurable cfgPVContributor{"cfgPVContributor", true, "PV contributor track selection"}; - Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; // Minmimum + Configurable tofAtHighPt{"tofAtHighPt", false, "Use TOF at high pT"}; Configurable cfgTPCcluster{"cfgTPCcluster", 1, "Minimum Number of TPC cluster"}; // Minmimum - Configurable cfgTPCRows{"cfgTPCRows", 70, "Minimum Number of TPC Crossed Rows "}; + Configurable cfgTPCRows{"cfgTPCRows", 80, "Minimum Number of TPC Crossed Rows "}; Configurable cfgRatioTPCRowsOverFindableCls{"cfgRatioTPCRowsOverFindableCls", 0.8, "Minimum of TPC Crossed Rows to Findable Clusters"}; // Minmimum - Configurable cfgITSChi2NCl{"cfgITSChi2NCl", 4.0, "Maximum ITS Chi2/NCl"}; // Maximum - Configurable cfgTPCChi2NCl{"cfgTPCChi2NCl", 4.0, "Maximum TPC Chi2/NCl"}; // Maximum + Configurable cfgUseTPCRefit{"cfgUseTPCRefit", true, "Require TPC Refit"}; + Configurable cfgUseITSRefit{"cfgUseITSRefit", true, "Require ITS Refit"}; - Configurable cfgUseTPCRefit{"cfgUseTPCRefit", false, "Require TPC Refit"}; - Configurable cfgUseITSRefit{"cfgUseITSRefit", false, "Require ITS Refit"}; - - Configurable cfgHasITS{"cfgHasITS", true, "Require ITS"}; - Configurable cfgHasTPC{"cfgHasTPC", true, "Require TPC"}; Configurable cfgHasTOF{"cfgHasTOF", false, "Require TOF"}; + Configurable cfgRapidityCut{"cfgRapidityCut", 0.5, "Rapidity cut for tracks"}; + //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// - // DCA selections // + // Cascade and V0 selections // - // Primary track DCAr to PV - Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; + // Primary track DCAxy to PV + Configurable cDCAxytoPVByPtPiFirstP0{"cDCAxytoPVByPtPiFirstP0", 0.004, "Coeff. Track DCAxy cut to PV by pt for Pion First (p0)"}; + Configurable cDCAxyToPVByPtPiFirstExp{"cDCAxyToPVByPtPiFirstExp", 0.013, "Coeff. Track DCAxy cut to PV by pt for Pion First (exp)"}; + + Configurable cDCAxyToPVAsPtForCasc{"cDCAxyToPVAsPtForCasc", true, "Set DCAxy to PV selection as pt cut"}; + Configurable cDCAxyToPVByPtCascP0{"cDCAxyToPVByPtCascP0", 999., "Coeff. for Track DCAxy cut to PV by pt for Cascade (p0)"}; + Configurable cDCAxyToPVByPtCascExp{"cDCAxyToPVByPtCascExp", 1., "Coeff. Track DCAxy cut to PV by pt for Cascade (exp)"}; // Primary track DCAz to PV - Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; - Configurable cMinDCAzToPVcut{"cMinDCAzToPVcut", 0.0, "Track DCAz cut to PV Minimum"}; + Configurable cDCAzToPVAsPt{"cDCAzToPVAsPt", true, "DCAz to PV selection as pt"}; + Configurable cDCAzToPVAsPtForCasc{"cDCAzToPVAsPtForCasc", true, "Set DCA to PV selection as pt cut"}; + Configurable cMaxDCAzToPVCut{"cMaxDCAzToPVCut", 0.5, "Track DCAz cut to PV Maximum"}; + Configurable cMaxDCAzToPVCutCasc{"cMaxDCAzToPVCutCasc", 0.5, "Track DCAz cut to PV Maximum for casc"}; // Topological selections for V0 - Configurable cDCALambdaDaugtherscut{"cDCALambdaDaugtherscut", 1.4, "Lambda dauthers DCA cut"}; - Configurable cDCALambdaToPVcut{"cDCALambdaToPVcut", 0.07, "Lambda DCA cut to PV"}; - Configurable cDCAPionToPVcut{"cMinDCApion", 0.05, "pion DCA cut to PV"}; - Configurable cDCAProtonToPVcut{"cMinDCAproton", 0.05, "proton DCA cut to PV"}; - Configurable cCosV0cut{"cCosV0cut", 0.97, "Cosine Pointing angle for V0"}; - Configurable cMaxV0radiuscut{"cMaxV0radiuscut", 100., "V0 radius cut Maximum"}; - Configurable cMinV0radiuscut{"cMinV0radiuscut", 0.2, "V0 radius cut Minimum"}; - // Configurable cMasswindowV0cut{"cV0Masswindowcut", 0.007, "V0 Mass window cut"}; // How to ? + Configurable cDCALambdaDaugtherscut{"cDCALambdaDaugtherscut", 0.7, "Lambda dauthers DCA cut"}; + Configurable cDCALambdaToPVcut{"cDCALambdaToPVcut", 0.02, "Lambda DCA cut to PV"}; + Configurable cDCAPionToPVcut{"cDCAPionToPVcut", 0.06, "pion DCA cut to PV"}; + Configurable cDCAProtonToPVcut{"cDCAProtonToPVcut", 0.07, "proton DCA cut to PV"}; + + Configurable cV0CosPACutPtDepP0{"cV0CosPACutPtDepP0", 0.25, "Coeff. for Cosine Pointing angle for V0 as pt (p0)"}; + Configurable cV0CosPACutPtDepP1{"cV0CosPACutPtDepP1", 0.022, "Coeff. for Cosine Pointing angle for V0 as pt (p1)"}; + + Configurable cMaxV0radiuscut{"cMaxV0radiuscut", 200., "V0 radius cut Maximum"}; + Configurable cMinV0radiuscut{"cMinV0radiuscut", 2.5, "V0 radius cut Minimum"}; + Configurable cMasswindowV0cut{"cMasswindowV0cut", 0.005, "V0 Mass window cut"}; // Topological selections for Cascade - Configurable cDCABachlorToPVcut{"cDCABachlorToPVcut", 0.015, "Bachelor DCA cut to PV"}; - Configurable cDCAXiDaugtherscut{"cDCAXiDaugtherscut", 1.6, "Xi- DCA cut to PV"}; - Configurable cCosPACasc{"cCosPACasc", 0.97, "Cosine Pointing angle for Cascade"}; - Configurable cMaxCascradiuscut{"cMaxCascradiuscut", 100., "Cascade radius cut Maximum"}; - Configurable cMinCascradiuscut{"cMinCascradiuscut", 0.2, "Cascade radius cut Minimum"}; - Configurable cMasswindowCasccut{"cMasswindowCasccut", 0.007, "Cascade Mass window cut"}; + + Configurable cDCABachlorToPVcut{"cDCABachlorToPVcut", 0.06, "Bachelor DCA cut to PV"}; + Configurable cDCAXiDaugthersCutPtRangeLower{"cDCAXiDaugthersCutPtRangeLower", 1., "Xi- DCA cut to PV as pt range lower"}; + Configurable cDCAXiDaugthersCutPtRangeUpper{"cDCAXiDaugthersCutPtRangeUpper", 4., "Xi- DCA cut to PV as pt range upper"}; + Configurable cDCAXiDaugthersCutPtDepLower{"cDCAXiDaugthersCutPtDepLower", 0.8, "Xi- DCA cut to PV as pt Under 1 GeV/c"}; + Configurable cDCAXiDaugthersCutPtDepMiddle{"cDCAXiDaugthersCutPtDepMiddle", 0.5, "Xi- DCA cut to PV as pt 1 - 4 GeV/c"}; + Configurable cDCAXiDaugthersCutPtDepUpper{"cDCAXiDaugthersCutPtDepUpper", 0.2, "Xi- DCA cut to PV as pt Over 4 GeV/c"}; + + Configurable cCosPACascCutPtDepP0{"cCosPACascCutPtDepP0", 0.2, "Coeff. for Cosine Pointing angle for Cascade as pt (p0)"}; + Configurable cCosPACascCutPtDepP1{"cCosPACascCutPtDepP1", 0.022, "Coeff. for Cosine Pointing angle for Cascade as pt (p1)"}; + + Configurable cMaxCascradiuscut{"cMaxCascradiuscut", 200., "Cascade radius cut Maximum"}; + Configurable cMinCascradiuscut{"cMinCascradiuscut", 1.1, "Cascade radius cut Minimum"}; + Configurable cMasswindowCasccut{"cMasswindowCasccut", 0.008, "Cascade Mass window cut"}; //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// @@ -157,58 +158,64 @@ struct xi1530analysisqa { Configurable cPIDBound{"cPIDBound", 6.349, "configurable for replacing to .has"}; + Configurable cMinTOFpt{"cMinTOFpt", 0.5, "Maximum TOF pt cut"}; + // PID Selections for Pion First - Configurable cMaxTPCnSigmaPionFirst{"cMaxTPCnSigmaPionFirst", 3.0, "TPC nSigma cut for Pion First"}; - Configurable cMaxTOFnSigmaPionFirst{"cMaxTOFnSigmaPionFirst", 3.0, "TOF nSigma cut for Pion First"}; + Configurable cMaxtpcnSigmaPionFirst{"cMaxtpcnSigmaPionFirst", 4.0, "TPC nSigma cut for Pion First"}; + Configurable cMaxtofnSigmaPionFirst{"cMaxtofnSigmaPionFirst", 3.0, "TOF nSigma cut for Pion First"}; - Configurable nsigmaCutCombinedPionFirst{"nsigmaCutCombinedPionFirst", -4.0, "Combined nSigma cut for Pion First"}; + Configurable nsigmaCutCombinedPionFirst{"nsigmaCutCombinedPionFirst", -4.0, "Combined nSigma cut for Pion First"}; Configurable cUseOnlyTOFTrackPionFirst{"cUseOnlyTOFTrackPionFirst", false, "Use only TOF track for PID selection Pion First"}; - Configurable cByPassTOFPionFirst{"cByPassTOFPionFirst", false, "By pass TOF Pion First PID selection"}; + Configurable cByPassTOFPionFirst{"cByPassTOFPionFirst", true, "By pass TOF Pion First PID selection"}; // PID Selections for Pion Bachelor - Configurable cMaxTPCnSigmaPionBachelor{"cMaxTPCnSigmaPionBachelor", 3.0, "TPC nSigma cut for Pion Bachelor"}; - Configurable cMaxTOFnSigmaPionBachelor{"cMaxTOFnSigmaPionBachelor", 3.0, "TOF nSigma cut for Pion Bachelor"}; + Configurable cMaxtpcnSigmaPionBachelor{"cMaxtpcnSigmaPionBachelor", 4.0, "TPC nSigma cut for Pion Bachelor"}; + Configurable cMaxtofnSigmaPionBachelor{"cMaxtofnSigmaPionBachelor", 3.0, "TOF nSigma cut for Pion Bachelor"}; - Configurable nsigmaCutCombinedPionBachelor{"nsigmaCutCombinedPionBachelor", -4.0, "Combined nSigma cut for Pion Bachelor"}; + Configurable nsigmaCutCombinedPionBachelor{"nsigmaCutCombinedPionBachelor", -4.0, "Combined nSigma cut for Pion Bachelor"}; Configurable cUseOnlyTOFTrackPionBachelor{"cUseOnlyTOFTrackPionBachelor", false, "Use only TOF track for PID selection Pion Bachelor"}; - Configurable cByPassTOFPionBachelor{"cByPassTOFPionBachelor", false, "By pass TOF Pion Bachelor PID selection"}; + Configurable cByPassTOFPionBachelor{"cByPassTOFPionBachelor", true, "By pass TOF Pion Bachelor PID selection"}; // PID Selections for Pion - Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; - Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; + Configurable cMaxtpcnSigmaPion{"cMaxtpcnSigmaPion", 4.0, "TPC nSigma cut for Pion"}; + Configurable cMaxtofnSigmaPion{"cMaxtofnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; - Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -4.0, "Combined nSigma cut for Pion"}; + Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -4.0, "Combined nSigma cut for Pion"}; Configurable cUseOnlyTOFTrackPion{"cUseOnlyTOFTrackPion", false, "Use only TOF track for PID selection Pion"}; - Configurable cByPassTOFPion{"cByPassTOFPion", false, "By pass TOF Pion PID selection"}; + Configurable cByPassTOFPion{"cByPassTOFPion", true, "By pass TOF Pion PID selection"}; // PID Selections for Proton - Configurable cMaxTPCnSigmaProton{"cMaxTPCnSigmaProton", 3.0, "TPC nSigma cut for Proton"}; - Configurable cMaxTOFnSigmaProton{"cMaxTOFnSigmaProton", 3.0, "TOF nSigma cut for Proton"}; + Configurable cMaxtpcnSigmaProton{"cMaxtpcnSigmaProton", 4.0, "TPC nSigma cut for Proton"}; + Configurable cMaxtofnSigmaProton{"cMaxtofnSigmaProton", 3.0, "TOF nSigma cut for Proton"}; - Configurable nsigmaCutCombinedProton{"nsigmaCutCombinedProton", -4.0, "Combined nSigma cut for Proton"}; + Configurable nsigmaCutCombinedProton{"nsigmaCutCombinedProton", -4.0, "Combined nSigma cut for Proton"}; Configurable cUseOnlyTOFTrackProton{"cUseOnlyTOFTrackProton", false, "Use only TOF track for PID selection Proton"}; - Configurable cByPassTOFProton{"cByPassTOFProton", false, "By pass TOF Proton PID selection"}; + Configurable cByPassTOFProton{"cByPassTOFProton", true, "By pass TOF Proton PID selection"}; //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// // MC Event selection // Configurable cZvertCutMC{"cZvertCutMC", 10.0, "MC Z-vertex cut"}; + Configurable cIsPhysicalPrimaryMC{"cIsPhysicalPrimaryMC", true, "Physical primary selection for a MC Parent"}; //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// - // Cuts on mother particle + // Cuts on mother particle and others Configurable cfgCutsOnMother{"cfgCutsOnMother", true, "Enamble additional cuts on mother"}; - Configurable cMaxPtMotherCut{"cMaxPtMotherCut", 15.0, "Maximum pt of mother cut"}; - Configurable cMaxMinvMotherCut{"cMaxMinvMotherCut", 2.1, "Maximum Minv of mother cut"}; + Configurable cMaxPtMotherCut{"cMaxPtMotherCut", 9.0, "Maximum pt of mother cut"}; + Configurable cMaxMinvMotherCut{"cMaxMinvMotherCut", 3.0, "Maximum Minv of mother cut"}; + + Configurable cMicroTrack{"cMicroTrack", false, "Using Micro track for first pion"}; + Configurable studyStableXi{"studyStableXi", true, "Study stable Xi"}; TRandom* rn = new TRandom(); //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// - struct PIDSelectionParam { + struct PidSelectionParam { double cMaxTPCnSigma; double cMaxTOFnSigma; bool cByPassTOF; @@ -218,16 +225,19 @@ struct xi1530analysisqa { void init(o2::framework::InitContext&) { AxisSpec centAxis = {binsCent, "FT0M (%)"}; - AxisSpec dcaxyAxis = {cDCABins, 0.0, 3.0, "DCA_{#it{xy}} (cm)"}; - AxisSpec dcazAxis = {cDCABins, 0.0, 3.0, "DCA_{#it{z}} (cm)"}; - AxisSpec mcLabelAxis = {5, -0.5, 4.5, "MC Label"}; + AxisSpec dcaxyAxis = {1500, 0.0, 0.3, "DCA_{#it{xy}} (cm)"}; + AxisSpec dcazAxis = {1500, 0.0, 0.3, "DCA_{#it{z}} (cm)"}; + AxisSpec dcaDaugAxis = {1000, 0.0, 1, "DCA_{#it{Daughter}} (cm)"}; + AxisSpec cosPAAxis = {3000, 0.0, 0.06, "1-cos(PA)"}; + AxisSpec mcLabelAxis = {6, -1.5, 4.5, "MC Label"}; AxisSpec ptAxis = {binsPt, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec ptAxisQA = {binsPtQA, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec invMassAxis = {cInvMassBins, cInvMassStart, cInvMassEnd, "Invariant Mass (GeV/#it{c}^2)"}; - AxisSpec pidQAAxis = {cPIDBins, -cPIDQALimit, cPIDQALimit}; - AxisSpec FlagAxis = {9, 0, 9, "Flags"}; + AxisSpec invMassAxisCasc = {800, 1.25, 1.65, "Invariant Mass for Casc. (GeV/#it{c}^2)"}; + AxisSpec pidQAAxis = {65, -6.5, 6.5}; + AxisSpec flagAxis = {9, 0, 9, "Flags"}; - if (additionalQAeventPlots) { + { // Test on Mixed event histos.add("TestME/hCollisionIndexSameE", "coll index sameE", HistType::kTH1F, {{500, 0.0f, 500.0f}}); histos.add("TestME/hCollisionIndexMixedE", "coll index mixedE", HistType::kTH1F, {{500, 0.0f, 500.0f}}); @@ -248,51 +258,36 @@ struct xi1530analysisqa { histos.add("QAevent/hMultiplicityPercentMixedE", "Multiplicity percentile of collision", HistType::kTH1F, {{120, 0.0f, 120.0f}}); } - if (invmass1D) { + if (invMass1D) { histos.add("Xi1530invmassDS", "Invariant mass of Xi(1530)0 differnt sign", kTH1F, {invMassAxis}); histos.add("Xi1530invmassLS", "Invariant mass of Xi(1530)0 like sign", kTH1F, {invMassAxis}); histos.add("Xi1530invmassME", "Invariant mass of Xi(1530)0 mixed event", kTH1F, {invMassAxis}); - if (study_antiparticle) { + if (studyAntiparticle) { histos.add("Xi1530invmassDSAnti", "Invariant mass of Anti-Xi(1530)0 differnt sign", kTH1F, {invMassAxis}); histos.add("Xi1530invmassLSAnti", "Invariant mass of Anti-Xi(1530)0 like sign", kTH1F, {invMassAxis}); } } - if (additionalMEPlots) { + if (doprocessMEDF || doprocessMEMicro) { histos.add("Xi1530invmassME_DS", "Invariant mass of Xi(1530)0 mixed event DS", kTH1F, {invMassAxis}); histos.add("Xi1530invmassME_DSAnti", "Invariant mass of Xi(1530)0 mixed event DSAnti", kTH1F, {invMassAxis}); } - if (additionalQAplots) { - // TPC ncluster distirbutions - histos.add("TPCncluster/TPCnclusterpifirst", "TPC ncluster distribution", kTH1F, {{160, 0, 160, "TPC nCluster"}}); - - histos.add("TPCncluster/TPCnclusterPhipifirst", "TPC ncluster vs phi", kTH2F, {{160, 0, 160, "TPC nCluster"}, {63, 0, 6.28, "#phi"}}); - } - // DCA QA to candidates for first pion and Xi- - histos.add("QAbefore/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {dcaxyAxis}); - histos.add("QAbefore/trkDCAxy_Xi", "DCAxy distribution of Xi- track candidates", HistType::kTH1F, {dcaxyAxis}); - - histos.add("QAbefore/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH1F, {dcazAxis}); - histos.add("QAbefore/trkDCAz_Xi", "DCAz distribution of Xi- track candidates", HistType::kTH1F, {dcazAxis}); - - histos.add("QAafter/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {dcaxyAxis}); - histos.add("QAafter/trkDCAxy_Xi", "DCAxy distribution of Xi- track candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QAbefore/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH2F, {ptAxis, dcaxyAxis}); + histos.add("QAbefore/trkDCAxy_Xi", "DCAxy distribution of Xi- track candidates", HistType::kTH2F, {ptAxis, dcaxyAxis}); - histos.add("QAafter/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH1F, {dcazAxis}); - histos.add("QAafter/trkDCAz_Xi", "DCAz distribution of Xi- track candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QAbefore/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH2F, {ptAxis, dcazAxis}); + histos.add("QAbefore/trkDCAz_Xi", "DCAz distribution of Xi- track candidates", HistType::kTH2F, {ptAxis, dcazAxis}); - // pT QA to candidates for first pion, Xi - histos.add("QAbefore/trkpT_pi", "pT distribution of pion track candidates", kTH1F, {ptAxis}); - histos.add("QAbefore/trkpT_Xi", "pT distribution of Xi- track candidates", kTH1F, {ptAxis}); + histos.add("QAafter/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH2F, {ptAxis, dcaxyAxis}); + histos.add("QAafter/trkDCAxy_Xi", "DCAxy distribution of Xi- track candidates", HistType::kTH2F, {ptAxis, dcaxyAxis}); - histos.add("QAafter/trkpT_pi", "pT distribution of pion track candidates", kTH1F, {ptAxis}); - histos.add("QAafter/trkpT_Xi", "pT distribution of Xi- track candidates", kTH1F, {ptAxis}); - - if (PIDplots) { + histos.add("QAafter/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH2F, {ptAxis, dcazAxis}); + histos.add("QAafter/trkDCAz_Xi", "DCAz distribution of Xi- track candidates", HistType::kTH2F, {ptAxis, dcazAxis}); + if (pidPlots) { // Plots for QA before, Need to pt info. for the daugthers histos.add("QAbefore/TOF_TPC_Map_pi_first_all", "TOF + TPC Combined PID for Pion_{First};#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); histos.add("QAbefore/TOF_Nsigma_pi_first_all", "TOF NSigma for Pion_{First};#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); @@ -335,29 +330,40 @@ struct xi1530analysisqa { } // 3d histogram + Flags - histos.add("h3Xi1530invmassDS", "Invariant mass of Xi(1530)0 differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, FlagAxis}); - histos.add("h3Xi1530invmassLS", "Invariant mass of Xi(1530)0 same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, FlagAxis}); - histos.add("h3Xi1530invmassME", "Invariant mass of Xi(1530)0 mixed event", kTHnSparseF, {centAxis, ptAxis, invMassAxis, FlagAxis}); + histos.add("h3Xi1530invmassDS", "Invariant mass of Xi- differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, flagAxis}); + histos.add("h3XiinvmassDS", "Invariant mass of Xi- differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxisCasc, flagAxis}); + + histos.add("h3Xi1530invmassLS", "Invariant mass of Xi(1530)0 same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, flagAxis}); + histos.add("h3XiinvmassLS", "Invariant mass of Xi- same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxisCasc, flagAxis}); + + histos.add("h3Xi1530invmassME", "Invariant mass of Xi(1530)0 mixed event", kTHnSparseF, {centAxis, ptAxis, invMassAxis, flagAxis}); + histos.add("h3XiinvmassME", "Invariant mass of Xi- mixed event", kTHnSparseF, {centAxis, ptAxis, invMassAxisCasc, flagAxis}); - if (study_antiparticle) { - histos.add("h3Xi1530invmassDSAnti", "Invariant mass of Anti-Xi(1530)0 differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, FlagAxis}); - histos.add("h3Xi1530invmassLSAnti", "Invariant mass of Anti-Xi(1530)0 same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, FlagAxis}); + if (studyAntiparticle) { + histos.add("h3Xi1530invmassDSAnti", "Invariant mass of Anti-Xi(1530)0 differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, flagAxis}); + histos.add("h3XiinvmassDSAnti", "Invariant mass of Anti-Xi- differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxisCasc, flagAxis}); + + histos.add("h3Xi1530invmassLSAnti", "Invariant mass of Anti-Xi(1530)0 same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, flagAxis}); + histos.add("h3XiinvmassLSAnti", "Invariant mass of Anti-Xi- same sign", kTHnSparseF, {centAxis, ptAxis, invMassAxisCasc, flagAxis}); } - if (additionalMEPlots) { - histos.add("h3Xi1530invmassME_DS", "Invariant mass of Xi(1530)0 mixed event DS", kTHnSparseF, {centAxis, ptAxis, invMassAxis, FlagAxis}); - histos.add("h3Xi1530invmassME_DSAnti", "Invariant mass of Xi(1530)0 mixed event DSAnti", kTHnSparseF, {centAxis, ptAxis, invMassAxis, FlagAxis}); + if (doprocessMEDF || doprocessMEMicro) { + histos.add("h3Xi1530invmassME_DS", "Invariant mass of Xi(1530)0 mixed event DS", kTHnSparseF, {centAxis, ptAxis, invMassAxis, flagAxis}); + histos.add("h3XiinvmassME_DS", "Invariant mass of Xi- mixed event DS", kTHnSparseF, {centAxis, ptAxis, invMassAxisCasc, flagAxis}); + + histos.add("h3Xi1530invmassME_DSAnti", "Invariant mass of Xi(1530)0 mixed event DSAnti", kTHnSparseF, {centAxis, ptAxis, invMassAxis, flagAxis}); + histos.add("h3XiinvmassME_DSAnti", "Invariant mass of Xi- mixed event DSAnti", kTHnSparseF, {centAxis, ptAxis, invMassAxisCasc, flagAxis}); } if (doprocessMC) { // MC QA - histos.add("QAMCTrue/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {dcaxyAxis}); - histos.add("QAMCTrue/trkDCAxy_xi", "DCAxy distribution of Xi- track candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QAMCTrue/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH2F, {ptAxis, dcaxyAxis}); + histos.add("QAMCTrue/trkDCAxy_xi", "DCAxy distribution of Xi- track candidates", HistType::kTH2F, {ptAxis, dcaxyAxis}); - histos.add("QAMCTrue/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH1F, {dcazAxis}); - histos.add("QAMCTrue/trkDCAz_xi", "DCAz distribution of Xi- track candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QAMCTrue/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH2F, {ptAxis, dcazAxis}); + histos.add("QAMCTrue/trkDCAz_xi", "DCAz distribution of Xi- track candidates", HistType::kTH2F, {ptAxis, dcazAxis}); - if (PIDplots) { + if (pidPlots) { histos.add("QAMCTrue/TOF_TPC_Map_pi_first_all", "TOF + TPC Combined PID for Pion_{First};#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); histos.add("QAMCTrue/TOF_Nsigma_pi_first_all", "TOF NSigma for Pion_{First};#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); histos.add("QAMCTrue/TPC_Nsigma_pi_first_all", "TPC NSigma for Pion_{First};#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); @@ -378,48 +384,76 @@ struct xi1530analysisqa { histos.add("QAMCTrue/TPC_Nsigma_piminus_all", "TPC NSigma for Pion -;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); } - histos.add("h3RecXi1530invmass", "Invariant mass of Reconstructed MC Xi(1530)0", kTHnSparseF, {centAxis, ptAxis, invMassAxis, FlagAxis}); - histos.add("h3RecXi1530invmassAnti", "Invariant mass of Reconstructed MC Anti-Xi(1530)0", kTHnSparseF, {centAxis, ptAxis, invMassAxis, FlagAxis}); + histos.add("h3RecXi1530invmass", "Invariant mass of Reconstructed MC Xi(1530)0", kTHnSparseF, {centAxis, ptAxis, invMassAxis, flagAxis}); + histos.add("h3RecXiinvmass", "Invariant mass of Reconstructed MC Xi-", kTHnSparseF, {centAxis, ptAxis, invMassAxisCasc, flagAxis}); - histos.add("h3Xi1530Gen", "pT distribution of True MC Xi(1530)0", kTHnSparseF, {mcLabelAxis, ptAxis, centAxis, FlagAxis}); - histos.add("h3Xi1530GenAnti", "pT distribution of True MC Anti-Xi(1530)0", kTHnSparseF, {mcLabelAxis, ptAxis, centAxis, FlagAxis}); + histos.add("h3RecXi1530invmassAnti", "Invariant mass of Reconstructed MC Anti-Xi(1530)0", kTHnSparseF, {centAxis, ptAxis, invMassAxis, flagAxis}); + histos.add("h3RecXiinvmassAnti", "Invariant mass of Reconstructed MC Anti-Xi-", kTHnSparseF, {centAxis, ptAxis, invMassAxisCasc, flagAxis}); + + histos.add("h3Xi1530Gen", "pT distribution of True MC Xi(1530)0", kTHnSparseF, {mcLabelAxis, ptAxis, centAxis}); + histos.add("h3Xi1530GenAnti", "pT distribution of True MC Anti-Xi(1530)0", kTHnSparseF, {mcLabelAxis, ptAxis, centAxis}); histos.add("Xi1530Rec", "pT distribution of Reconstructed MC Xi(1530)0", kTH2F, {ptAxis, centAxis}); histos.add("Xi1530RecAnti", "pT distribution of Reconstructed MC Anti-Xi(1530)0", kTH2F, {ptAxis, centAxis}); histos.add("Xi1530Recinvmass", "Inv mass distribution of Reconstructed MC Xi(1530)0", kTH1F, {invMassAxis}); } + + if (additionalQAplots) { + histos.add("QAbefore/V0sDCADoughter_aspt", "V0s DCA Doughter distribution as pt", HistType::kTH2F, {ptAxis, dcaDaugAxis}); + histos.add("QAbefore/CascDCADoughter_aspt", "Casc DCA Doughter distribution as pt", HistType::kTH2F, {ptAxis, dcaDaugAxis}); + histos.add("QAbefore/CascMass_aspt", "Casc DCA Bachlor distribution as pt", HistType::kTH2F, {ptAxis, invMassAxisCasc}); + histos.add("QAbefore/V0sCosPA_aspt", "V0s CosPA distribution as pt", HistType::kTH2F, {ptAxis, cosPAAxis}); + histos.add("QAbefore/CascCosPA_aspt", "Casc CosPA distribution as pt", HistType::kTH2F, {ptAxis, cosPAAxis}); + + histos.add("QAafter/V0sDCADoughter_aspt", "V0s DCA Doughter distribution as pt", HistType::kTH2F, {ptAxis, dcaDaugAxis}); + histos.add("QAafter/CascDCADoughter_aspt", "Casc DCA Doughter distribution as pt", HistType::kTH2F, {ptAxis, dcaDaugAxis}); + histos.add("QAafter/CascMass_aspt", "Casc DCA Bachlor distribution as pt", HistType::kTH2F, {ptAxis, invMassAxisCasc}); + histos.add("QAafter/V0sCosPA_aspt", "V0s CosPA distribution as pt", HistType::kTH2F, {ptAxis, cosPAAxis}); + histos.add("QAafter/CascCosPA_aspt", "Casc CosPA distribution as pt", HistType::kTH2F, {ptAxis, cosPAAxis}); + + histos.add("QAMCTrue/V0sDCADoughter_aspt", "V0s DCA Doughter distribution as pt", HistType::kTH2F, {ptAxis, dcaDaugAxis}); + histos.add("QAMCTrue/CascDCADoughter_aspt", "Casc DCA Doughter distribution as pt", HistType::kTH2F, {ptAxis, dcaDaugAxis}); + histos.add("QAMCTrue/CascMass_aspt", "Casc DCA Bachlor distribution as pt", HistType::kTH2F, {ptAxis, invMassAxisCasc}); + histos.add("QAMCTrue/V0sCosPA_aspt", "V0s CosPA distribution as pt", HistType::kTH2F, {ptAxis, cosPAAxis}); + histos.add("QAMCTrue/CascCosPA_aspt", "Casc CosPA distribution as pt", HistType::kTH2F, {ptAxis, cosPAAxis}); + } } double massPi = MassPionCharged; // Primary track selection for the first pion // - template - bool PtrackCut(const TrackType track) + template + bool primaryTrackCut(const TrackType track) { if (std::abs(track.eta()) > cMaxetacut) return false; if (std::abs(track.pt()) < cMinPtcut) return false; - if (std::abs(track.dcaXY()) > cMaxDCArToPVcut) - return false; - if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) - return false; - if (track.itsNCls() < cfgITScluster) - return false; - if (track.tpcNClsFound() < cfgTPCcluster) - return false; - if (track.tpcNClsCrossedRows() < cfgTPCRows) - return false; - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) - return false; - if (track.itsChi2NCl() >= cfgITSChi2NCl) - return false; - if (track.tpcChi2NCl() >= cfgTPCChi2NCl) - return false; - if (cfgHasITS && !track.hasITS()) - return false; - if (cfgHasTPC && !track.hasTPC()) - return false; + if constexpr (IsResoMicrotrack) { + if (std::abs(o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(track.trackSelectionFlags())) > (cDCAxytoPVByPtPiFirstP0 + cDCAxyToPVByPtPiFirstExp * std::pow(track.pt(), -1.1))) + return false; + if (cDCAzToPVAsPt) { + if (std::abs(o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(track.trackSelectionFlags())) > (cDCAxytoPVByPtPiFirstP0 + cDCAxyToPVByPtPiFirstExp * std::pow(track.pt(), -1.1))) + return false; + } else { + if (std::abs(o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(track.trackSelectionFlags())) > cMaxDCAzToPVCut) + return false; + } + } else { + if (std::abs(track.dcaXY()) > (cDCAxytoPVByPtPiFirstP0 + cDCAxyToPVByPtPiFirstExp * std::pow(track.pt(), -1.1))) + return false; + if (cDCAzToPVAsPt) { + if (std::abs(track.dcaZ()) > (cDCAxytoPVByPtPiFirstP0 + cDCAxyToPVByPtPiFirstExp * std::pow(track.pt(), -1.1))) + return false; + } else { + if (std::abs(track.dcaZ()) > cMaxDCAzToPVCut) + return false; + } + if (track.tpcNClsFound() < cfgTPCcluster) + return false; + if (track.tpcNClsCrossedRows() < cfgTPCRows) + return false; + } if (cfgHasTOF && !track.hasTOF()) return false; if (cfgUseITSRefit && !track.passedITSRefit()) @@ -430,11 +464,6 @@ struct xi1530analysisqa { return false; if (cfgPrimaryTrack && !track.isPrimaryTrack()) return false; - if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) - return false; - if (cfgGlobalTrack && !track.isGlobalTrack()) - return false; - return true; } @@ -445,16 +474,20 @@ struct xi1530analysisqa { // Primary track selection for cascades, Need to more informations for cascades // template - bool cascPtrackCut(const TracksTypeCasc track) + bool cascprimaryTrackCut(const TracksTypeCasc track) { if (std::abs(track.eta()) > cMaxetacut) return false; if (std::abs(track.pt()) < cMinPtcut) return false; - if (std::abs(track.dcaXYCascToPV()) > cMaxDCArToPVcut) - return false; - if (std::abs(track.dcaZCascToPV()) > cMaxDCAzToPVcut) - return false; + if (cDCAxyToPVAsPtForCasc) { + if (std::abs(track.dcaXYCascToPV()) > (cDCAxyToPVByPtCascP0 + cDCAxyToPVByPtCascExp * track.pt())) + return false; + } + if (cDCAzToPVAsPtForCasc) { + if (std::abs(track.dcaZCascToPV()) > (cDCAxyToPVByPtCascP0 + cDCAxyToPVByPtCascExp * std::pow(track.pt(), -1.1))) + return false; + } return true; } @@ -481,41 +514,64 @@ struct xi1530analysisqa { if (std::abs(track.dcapostopv()) < cDCAPionToPVcut) return false; } - if (track.v0CosPA() < cCosV0cut) + if (track.v0CosPA() < std::cos(cV0CosPACutPtDepP0 - cV0CosPACutPtDepP1 * track.pt())) return false; if (track.transRadius() > cMaxV0radiuscut || track.transRadius() < cMinV0radiuscut) return false; + if (std::abs(track.mLambda() - MassLambda) > cMasswindowV0cut) + return false; // Topological Cuts for Cascades - if (track.dcabachtopv() < cDCABachlorToPVcut) - return false; - if (track.cascDaughDCA() > cDCAXiDaugtherscut) + if (std::abs(track.dcabachtopv()) < cDCABachlorToPVcut) return false; - if (track.cascCosPA() < cCosPACasc) + if (track.pt() < cDCAXiDaugthersCutPtRangeLower) { + if (track.cascDaughDCA() > cDCAXiDaugthersCutPtDepLower) + return false; + } + if (track.pt() >= cDCAXiDaugthersCutPtRangeLower && track.pt() < cDCAXiDaugthersCutPtRangeUpper) { + if (track.cascDaughDCA() > cDCAXiDaugthersCutPtDepMiddle) + return false; + } + if (track.pt() >= cDCAXiDaugthersCutPtRangeUpper) { + if (track.cascDaughDCA() > cDCAXiDaugthersCutPtDepUpper) + return false; + } + if (track.cascCosPA() < std::cos(cCosPACascCutPtDepP0 - cCosPACascCutPtDepP1 * track.pt())) return false; + if (track.cascTransRadius() > cMaxCascradiuscut || track.cascTransRadius() < cMinCascradiuscut) return false; - // if (std::abs(track.mXi() - XiMass) > cMasswindowCasccut) - // return false; if (std::abs(track.mXi() - cMassXiminus) > cMasswindowCasccut) return false; return true; } - bool PIDSelector(float TPCNsigma, float TOFNsigma, const PIDSelectionParam& params, bool tofAtHighPt) + bool pidSelector(float TPCNsigma, float TOFNsigma, const PidSelectionParam& params, bool tofAtHighPt, float trackPt) { bool tpcPIDPassed{false}, tofPIDPassed{false}; - if (tofAtHighPt) { - // TOF based PID - if (hasSubsystemInfo(TOFNsigma) && std::abs(TOFNsigma) < params.cMaxTOFnSigma) { - return true; + if (tofAtHighPt && trackPt > cMinTOFpt) { + if (std::abs(TPCNsigma) < params.cMaxTPCnSigma) { + tpcPIDPassed = true; } - if (!hasSubsystemInfo(TOFNsigma) && std::abs(TPCNsigma) < params.cMaxTPCnSigma) { + + if (params.cByPassTOF && tpcPIDPassed) { return true; } - return false; + + if (hasSubsystemInfo(TOFNsigma)) { + if (std::abs(TOFNsigma) < params.cMaxTOFnSigma) { + tofPIDPassed = true; + } + if ((params.nsigmaCutCombined > 0) && + (TPCNsigma * TPCNsigma + TOFNsigma * TOFNsigma < params.nsigmaCutCombined * params.nsigmaCutCombined)) { + tofPIDPassed = true; + } + } else { + tofPIDPassed = true; + } + return tpcPIDPassed && tofPIDPassed; } else { if (std::abs(TPCNsigma) < params.cMaxTPCnSigma) { @@ -543,18 +599,24 @@ struct xi1530analysisqa { } // PID selection for the First Pion // - template + template bool selectionPIDPionFirst(const T& candidate) { - float TPCNsigmaPionFirst, TOFNsigmaPionFirst; + float tpcNsigmaPionFirst, tofNsigmaPionFirst; + float trackPt = candidate.pt(); - TPCNsigmaPionFirst = candidate.tpcNSigmaPi(); - TOFNsigmaPionFirst = candidate.tofNSigmaPi(); + if constexpr (IsResoMicrotrack) { + tpcNsigmaPionFirst = o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(candidate.pidNSigmaPiFlag()); + tofNsigmaPionFirst = o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(candidate.pidNSigmaPiFlag()); + } else { + tpcNsigmaPionFirst = candidate.tpcNSigmaPi(); + tofNsigmaPionFirst = candidate.tofNSigmaPi(); + } - PIDSelectionParam PionFirstParams = {cMaxTPCnSigmaPionFirst, cMaxTOFnSigmaPionFirst, cByPassTOFPionFirst, nsigmaCutCombinedPionFirst}; + PidSelectionParam pionFirstParams = {cMaxtpcnSigmaPionFirst, cMaxtofnSigmaPionFirst, cByPassTOFPionFirst, nsigmaCutCombinedPionFirst}; - return PIDSelector(TPCNsigmaPionFirst, TOFNsigmaPionFirst, PionFirstParams, tof_at_high_pt); + return pidSelector(tpcNsigmaPionFirst, tofNsigmaPionFirst, pionFirstParams, tofAtHighPt, trackPt); } template @@ -562,50 +624,51 @@ struct xi1530analysisqa { { bool lConsistentWithXi{false}, lConsistentWithLambda{false}, lConsistentWithPion{false}, lConsistentWithProton{false}; - float TPCNsigmaBachelor, TOFNsigmaBachelor; - float TPCNsigmaPion, TOFNsigmaPion; - float TPCNsigmaProton, TOFNsigmaProton; + float tpcNsigmaBachelor, tofNsigmaBachelor; + float tpcNsigmaPion, tofNsigmaPion; + float tpcNsigmaProton, tofNsigmaProton; + float trackPt = candidate.pt(); if (candidate.sign() < 0) { // Xi- candidates - TPCNsigmaBachelor = candidate.daughterTPCNSigmaBachPi(); - TOFNsigmaBachelor = candidate.daughterTOFNSigmaBachPi(); + tpcNsigmaBachelor = candidate.daughterTPCNSigmaBachPi(); + tofNsigmaBachelor = candidate.daughterTOFNSigmaBachPi(); - TPCNsigmaPion = candidate.daughterTPCNSigmaNegPi(); - TOFNsigmaPion = candidate.daughterTOFNSigmaNegPi(); + tpcNsigmaPion = candidate.daughterTPCNSigmaNegPi(); + tofNsigmaPion = candidate.daughterTOFNSigmaNegPi(); - TPCNsigmaProton = candidate.daughterTPCNSigmaPosPr(); - TOFNsigmaProton = candidate.daughterTOFNSigmaPosPr(); + tpcNsigmaProton = candidate.daughterTPCNSigmaPosPr(); + tofNsigmaProton = candidate.daughterTOFNSigmaPosPr(); } else { // Anti-Xi- candidates - TPCNsigmaBachelor = candidate.daughterTPCNSigmaBachPi(); - TOFNsigmaBachelor = candidate.daughterTOFNSigmaBachPi(); + tpcNsigmaBachelor = candidate.daughterTPCNSigmaBachPi(); + tofNsigmaBachelor = candidate.daughterTOFNSigmaBachPi(); - TPCNsigmaPion = candidate.daughterTPCNSigmaPosPi(); - TOFNsigmaPion = candidate.daughterTOFNSigmaPosPi(); + tpcNsigmaPion = candidate.daughterTPCNSigmaPosPi(); + tofNsigmaPion = candidate.daughterTOFNSigmaPosPi(); - TPCNsigmaProton = candidate.daughterTPCNSigmaNegPr(); - TOFNsigmaProton = candidate.daughterTOFNSigmaNegPr(); + tpcNsigmaProton = candidate.daughterTPCNSigmaNegPr(); + tofNsigmaProton = candidate.daughterTOFNSigmaNegPr(); } - PIDSelectionParam bachelorParams = {cMaxTPCnSigmaPionBachelor, cMaxTOFnSigmaPionBachelor, cByPassTOFPionBachelor, nsigmaCutCombinedPionBachelor}; - PIDSelectionParam pionParams = {cMaxTPCnSigmaPion, cMaxTOFnSigmaPion, cByPassTOFPion, nsigmaCutCombinedPion}; - PIDSelectionParam protonParams = {cMaxTPCnSigmaProton, cMaxTOFnSigmaProton, cByPassTOFProton, nsigmaCutCombinedProton}; + PidSelectionParam bachelorParams = {cMaxtpcnSigmaPionBachelor, cMaxtofnSigmaPionBachelor, cByPassTOFPionBachelor, nsigmaCutCombinedPionBachelor}; + PidSelectionParam pionParams = {cMaxtpcnSigmaPion, cMaxtofnSigmaPion, cByPassTOFPion, nsigmaCutCombinedPion}; + PidSelectionParam protonParams = {cMaxtpcnSigmaProton, cMaxtofnSigmaProton, cByPassTOFProton, nsigmaCutCombinedProton}; - lConsistentWithXi = PIDSelector(TPCNsigmaBachelor, TOFNsigmaBachelor, bachelorParams, tof_at_high_pt); - lConsistentWithPion = PIDSelector(TPCNsigmaPion, TOFNsigmaPion, pionParams, tof_at_high_pt); - lConsistentWithProton = PIDSelector(TPCNsigmaProton, TOFNsigmaProton, protonParams, tof_at_high_pt); + lConsistentWithXi = pidSelector(tpcNsigmaBachelor, tofNsigmaBachelor, bachelorParams, tofAtHighPt, trackPt); + lConsistentWithPion = pidSelector(tpcNsigmaPion, tofNsigmaPion, pionParams, tofAtHighPt, trackPt); + lConsistentWithProton = pidSelector(tpcNsigmaProton, tofNsigmaProton, protonParams, tofAtHighPt, trackPt); lConsistentWithLambda = lConsistentWithProton && lConsistentWithPion; return lConsistentWithXi && lConsistentWithLambda; } - template + template void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksTypeCasc& dTracks2) // Order: ResoColl, ResoTrack, ResoCascTrack { auto multiplicity = collision.cent(); - if (additionalQAeventPlots) { + { if constexpr (!IsMix) { histos.fill(HIST("QAevent/hVertexZSameE"), collision.posZ()); histos.fill(HIST("QAevent/hMultiplicityPercentSameE"), collision.cent()); @@ -619,11 +682,11 @@ struct xi1530analysisqa { } } - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; // It will be replaced to use RecoDecay (In fixing...) + LorentzVectorPtEtaPhiMass lDecayDaughter1, lDecayDaughter2, lResonance; // It will be replaced to use RecoDecay (In fixing...) - for (auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { + for (const auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { - if (additionalQAeventPlots) { + { if constexpr (!IsMix) { histos.fill(HIST("TestME/hPairsCounterSameE"), 1.0); } else { @@ -631,14 +694,34 @@ struct xi1530analysisqa { } } - if (!PtrackCut(trk1) || !cascPtrackCut(trk2)) // Primary track selections - continue; - auto trk1ptPi = trk1.pt(); - auto trk1NSigmaPiTPC = trk1.tpcNSigmaPi(); - auto trk1NSigmaPiTOF = trk1.tofNSigmaPi(); + static float trk1DCAXY; + static float trk1DCAZ; + static float trk1NSigmaPiTPC; + static float trk1NSigmaPiTOF; + if constexpr (IsResoMicrotrack) { + trk1DCAXY = o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(trk1.trackSelectionFlags()); + trk1DCAZ = o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(trk1.trackSelectionFlags()); + trk1NSigmaPiTPC = o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(trk1.pidNSigmaPiFlag()); + trk1NSigmaPiTOF = o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(trk1.pidNSigmaPiFlag()); + } else { + trk1DCAXY = trk1.dcaXY(); + trk1DCAZ = trk1.dcaZ(); + trk1NSigmaPiTPC = trk1.tpcNSigmaPi(); + trk1NSigmaPiTOF = trk1.tofNSigmaPi(); + } auto trk2ptXi = trk2.pt(); + + auto trk2DCAXY = trk2.dcaXYCascToPV(); + auto trk2DCAZ = trk2.dcaZCascToPV(); + + auto trk2DCAV0sDougthers = trk2.daughDCA(); + auto trk2DCACascDougthers = trk2.cascDaughDCA(); + auto trk2Mass = trk2.mXi(); + auto trk2CascCosPA = trk2.cascCosPA(); + auto trk2V0sCosPA = trk2.v0CosPA(); + // Need to daughther's pt info. in the table // auto trk2ptPiBachelor = trk2.pt(); float trk2NSigmaPiBachelorTPC = trk2.daughterTPCNSigmaBachPi(); @@ -661,7 +744,7 @@ struct xi1530analysisqa { if constexpr (!IsMix) { //// QA plots before the selection // need to pt for cascade tracks // --- PID QA - if (PIDplots) { + if (pidPlots) { histos.fill(HIST("QAbefore/TPC_Nsigma_pi_first_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); if (hasSubsystemInfo(trk1NSigmaPiTOF)) { histos.fill(HIST("QAbefore/TOF_Nsigma_pi_first_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); @@ -695,16 +778,24 @@ struct xi1530analysisqa { } } - histos.fill(HIST("QAbefore/trkpT_pi"), trk1ptPi); - histos.fill(HIST("QAbefore/trkpT_Xi"), trk2ptXi); + histos.fill(HIST("QAbefore/trkDCAxy_pi"), trk1ptPi, trk1DCAXY); + histos.fill(HIST("QAbefore/trkDCAxy_Xi"), trk2ptXi, trk2DCAXY); - histos.fill(HIST("QAbefore/trkDCAxy_pi"), trk1.dcaXY()); - histos.fill(HIST("QAbefore/trkDCAxy_Xi"), trk2.dcaXYCascToPV()); + histos.fill(HIST("QAbefore/trkDCAz_pi"), trk1ptPi, trk1DCAZ); + histos.fill(HIST("QAbefore/trkDCAz_Xi"), trk2ptXi, trk2DCAZ); - histos.fill(HIST("QAbefore/trkDCAz_pi"), trk1.dcaZ()); - histos.fill(HIST("QAbefore/trkDCAz_Xi"), trk2.dcaZCascToPV()); + if (additionalQAplots) { + histos.fill(HIST("QAbefore/V0sDCADoughter_aspt"), trk2ptXi, trk2DCAV0sDougthers); + histos.fill(HIST("QAbefore/CascDCADoughter_aspt"), trk2ptXi, trk2DCACascDougthers); + histos.fill(HIST("QAbefore/CascMass_aspt"), trk2ptXi, trk2Mass); + histos.fill(HIST("QAbefore/V0sCosPA_aspt"), trk2ptXi, 1. - trk2V0sCosPA); + histos.fill(HIST("QAbefore/CascCosPA_aspt"), trk2ptXi, 1. - trk2CascCosPA); + } } + if (!primaryTrackCut(trk1) || !cascprimaryTrackCut(trk2)) // Primary track selections + continue; + // PID selection if (cUseOnlyTOFTrackPionFirst && !hasSubsystemInfo(trk1NSigmaPiTOF)) continue; @@ -722,22 +813,20 @@ struct xi1530analysisqa { if (cUseOnlyTOFTrackPion && !hasSubsystemInfo(trk2NSigmaPiNegTOF)) continue; - if (!selectionPIDPionFirst(trk1) || !selectionPIDCascades(trk2)) + if (!selectionPIDPionFirst(trk1) || !selectionPIDCascades(trk2)) continue; if (!casctopCut(trk2)) continue; - if (additionalQAplots) { - // TPCncluster distributions - histos.fill(HIST("TPCncluster/TPCnclusterpifirst"), trk1.tpcNClsFound()); - histos.fill(HIST("TPCncluster/TPCnclusterPhipifirst"), trk1.tpcNClsFound(), trk1.phi()); - } + // TPCncluster distributions + // histos.fill(HIST("TPCncluster/TPCnclusterpifirst"), trk1.tpcNClsFound()); + // histos.fill(HIST("TPCncluster/TPCnclusterPhipifirst"), trk1.tpcNClsFound(), trk1.phi()); if constexpr (!IsMix) { - //// QA plots before the selection + //// QA plots after the selection // --- PID QA - if (PIDplots) { + if (pidPlots) { histos.fill(HIST("QAafter/TPC_Nsigma_pi_first_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); if (hasSubsystemInfo(trk1NSigmaPiTOF)) { @@ -780,24 +869,29 @@ struct xi1530analysisqa { } } - histos.fill(HIST("QAafter/trkpT_pi"), trk1ptPi); - histos.fill(HIST("QAafter/trkpT_Xi"), trk2ptXi); + histos.fill(HIST("QAafter/trkDCAxy_pi"), trk1ptPi, trk1DCAXY); + histos.fill(HIST("QAafter/trkDCAxy_Xi"), trk2ptXi, trk2DCAXY); - histos.fill(HIST("QAafter/trkDCAxy_pi"), trk1.dcaXY()); - histos.fill(HIST("QAafter/trkDCAxy_Xi"), trk2.dcaXYCascToPV()); + histos.fill(HIST("QAafter/trkDCAz_pi"), trk1ptPi, trk1DCAZ); + histos.fill(HIST("QAafter/trkDCAz_Xi"), trk2ptXi, trk2DCAZ); - histos.fill(HIST("QAafter/trkDCAz_pi"), trk1.dcaZ()); - histos.fill(HIST("QAafter/trkDCAz_Xi"), trk2.dcaZCascToPV()); + if (additionalQAplots) { + histos.fill(HIST("QAafter/V0sDCADoughter_aspt"), trk2ptXi, trk2DCAV0sDougthers); + histos.fill(HIST("QAafter/CascDCADoughter_aspt"), trk2ptXi, trk2DCACascDougthers); + histos.fill(HIST("QAafter/CascMass_aspt"), trk2ptXi, trk2Mass); + histos.fill(HIST("QAafter/V0sCosPA_aspt"), trk2ptXi, 1. - trk2V0sCosPA); + histos.fill(HIST("QAafter/CascCosPA_aspt"), trk2ptXi, 1. - trk2CascCosPA); + } } - lDecayDaughter1.SetPtEtaPhiM(trk1ptPi, trk1.eta(), trk1.phi(), massPi); - lDecayDaughter2.SetPtEtaPhiM(trk2ptXi, trk2.eta(), trk2.phi(), trk2.mXi()); + lDecayDaughter1 = LorentzVectorPtEtaPhiMass(trk1ptPi, trk1.eta(), trk1.phi(), massPi); + lDecayDaughter2 = LorentzVectorPtEtaPhiMass(trk2ptXi, trk2.eta(), trk2.phi(), trk2.mXi()); lResonance = lDecayDaughter1 + lDecayDaughter2; auto lResonancePt = lResonance.Pt(); auto lResonanceInMass = lResonance.M(); - if (std::abs(lResonance.Rapidity()) >= 0.5) + if (std::abs(lResonance.Rapidity()) >= cfgRapidityCut) continue; if (cfgCutsOnMother) { @@ -810,48 +904,72 @@ struct xi1530analysisqa { if (trk1.sign() * trk2.sign() < 0) { if constexpr (!IsMix) { - if (study_antiparticle) { + if (studyAntiparticle) { if (trk1.sign() > 0) { - if (invmass1D) + if (invMass1D) histos.fill(HIST("Xi1530invmassDS"), lResonanceInMass); histos.fill(HIST("h3Xi1530invmassDS"), multiplicity, lResonancePt, lResonanceInMass, kData); } else if (trk1.sign() < 0) { - if (invmass1D) + if (invMass1D) histos.fill(HIST("Xi1530invmassDSAnti"), lResonanceInMass); histos.fill(HIST("h3Xi1530invmassDSAnti"), multiplicity, lResonancePt, lResonanceInMass, kData); } } else { - if (invmass1D) + if (invMass1D) histos.fill(HIST("Xi1530invmassDS"), lResonanceInMass); histos.fill(HIST("h3Xi1530invmassDS"), multiplicity, lResonancePt, lResonanceInMass, kData); } + + if (studyStableXi) { + if (trk1.sign() > 0) { + histos.fill(HIST("h3XiinvmassDS"), multiplicity, trk2ptXi, trk2Mass, kData); + } else if (trk1.sign() < 0) { + histos.fill(HIST("h3XiinvmassDSAnti"), multiplicity, trk2ptXi, trk2Mass, kData); + } + } } else { - if (invmass1D) + if (invMass1D) histos.fill(HIST("Xi1530invmassME"), lResonanceInMass); if (trk1.sign() > 0) { - if (invmass1D) + if (invMass1D) histos.fill(HIST("Xi1530invmassME_DS"), lResonanceInMass); histos.fill(HIST("h3Xi1530invmassME_DS"), multiplicity, lResonancePt, lResonanceInMass, kMixing); } else if (trk1.sign() < 0) { - if (invmass1D) + if (invMass1D) histos.fill(HIST("Xi1530invmassME_DSAnti"), lResonanceInMass); histos.fill(HIST("h3Xi1530invmassME_DSAnti"), multiplicity, lResonancePt, lResonanceInMass, kMixing); } histos.fill(HIST("h3Xi1530invmassME"), multiplicity, lResonancePt, lResonanceInMass, kMixing); - } + if (studyStableXi) { + if (trk1.sign() > 0) { + histos.fill(HIST("h3XiinvmassME_DS"), multiplicity, trk2ptXi, trk2Mass, kMixing); + } else if (trk1.sign() < 0) { + histos.fill(HIST("h3XiinvmassME_DSAnti"), multiplicity, trk2ptXi, trk2Mass, kMixing); + } + } + } if constexpr (IsMC) { - if (std::abs(trk2.motherPDG()) != XiStarPID) + if (std::abs(trk2.motherPDG()) != kXiStar) continue; - if (std::abs(trk1.pdgCode()) != PionPID || std::abs(trk2.pdgCode()) != XiPID) + if (std::abs(trk1.pdgCode()) != kPiPlus || std::abs(trk2.pdgCode()) != kXiMinus) continue; if (trk1.motherId() != trk2.motherId()) continue; - histos.fill(HIST("QAMCTrue/trkDCAxy_pi"), trk1.dcaXY()); - histos.fill(HIST("QAMCTrue/trkDCAxy_xi"), trk2.dcaXYCascToPV()); - histos.fill(HIST("QAMCTrue/trkDCAz_pi"), trk1.dcaZ()); - histos.fill(HIST("QAMCTrue/trkDCAz_xi"), trk2.dcaZCascToPV()); + histos.fill(HIST("QAMCTrue/trkDCAxy_pi"), trk1ptPi, trk1DCAXY); + histos.fill(HIST("QAMCTrue/trkDCAxy_xi"), trk2ptXi, trk2DCAXY); + histos.fill(HIST("QAMCTrue/trkDCAz_pi"), trk1ptPi, trk1DCAZ); + histos.fill(HIST("QAMCTrue/trkDCAz_xi"), trk2ptXi, trk2DCAZ); + + if (additionalQAplots) { + histos.fill(HIST("QAMCTrue/V0sDCADoughter_aspt"), trk2ptXi, trk2DCAV0sDougthers); + histos.fill(HIST("QAMCTrue/CascDCADoughter_aspt"), trk2ptXi, trk2DCACascDougthers); + histos.fill(HIST("QAMCTrue/CascMass_aspt"), trk2ptXi, trk2Mass); + histos.fill(HIST("QAMCTrue/V0sCosPA_aspt"), trk2ptXi, 1. - trk2V0sCosPA); + histos.fill(HIST("QAMCTrue/CascCosPA_aspt"), trk2ptXi, 1. - trk2CascCosPA); + } + histos.fill(HIST("QAMCTrue/TPC_Nsigma_pi_first_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); if (hasSubsystemInfo(trk1NSigmaPiTOF)) { histos.fill(HIST("QAMCTrue/TOF_Nsigma_pi_first_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); @@ -859,36 +977,36 @@ struct xi1530analysisqa { } if (trk2.sign() < 0) { - histos.fill(HIST("QAafter/TPC_Nsigma_pi_bachelor_all"), multiplicity, 0, trk2NSigmaPiBachelorTPC); // not exist pt information in resocascade yet. + histos.fill(HIST("QAMCTrue/TPC_Nsigma_pi_bachelor_all"), multiplicity, 0, trk2NSigmaPiBachelorTPC); // not exist pt information in resocascade yet. if (hasSubsystemInfo(trk2NSigmaPiBachelorTOF)) { - histos.fill(HIST("QAafter/TOF_TPC_Map_pi_bachelor_all"), trk2NSigmaPiBachelorTOF, trk2NSigmaPiBachelorTPC); + histos.fill(HIST("QAMCTrue/TOF_TPC_Map_pi_bachelor_all"), trk2NSigmaPiBachelorTOF, trk2NSigmaPiBachelorTPC); } - histos.fill(HIST("QAafter/TPC_Nsigma_pr_all"), multiplicity, 0, trk2NSigmaPrPosTPC); + histos.fill(HIST("QAMCTrue/TPC_Nsigma_pr_all"), multiplicity, 0, trk2NSigmaPrPosTPC); if (hasSubsystemInfo(trk2NSigmaPrPosTOF)) { - histos.fill(HIST("QAafter/TOF_TPC_Map_pr_all"), trk2NSigmaPrPosTOF, trk2NSigmaPrPosTPC); + histos.fill(HIST("QAMCTrue/TOF_TPC_Map_pr_all"), trk2NSigmaPrPosTOF, trk2NSigmaPrPosTPC); } - histos.fill(HIST("QAafter/TPC_Nsigma_piminus_all"), multiplicity, 0, trk2NSigmaPiNegTPC); + histos.fill(HIST("QAMCTrue/TPC_Nsigma_piminus_all"), multiplicity, 0, trk2NSigmaPiNegTPC); if (hasSubsystemInfo(trk2NSigmaPiNegTOF)) { - histos.fill(HIST("QAafter/TOF_TPC_Map_piminus_all"), trk2NSigmaPiNegTOF, trk2NSigmaPiNegTPC); + histos.fill(HIST("QAMCTrue/TOF_TPC_Map_piminus_all"), trk2NSigmaPiNegTOF, trk2NSigmaPiNegTPC); } } else { - histos.fill(HIST("QAafter/TPC_Nsigma_pi_bachelor_all"), multiplicity, 0, trk2NSigmaPiBachelorTPC); // not exist pt information in resocascade yet. + histos.fill(HIST("QAMCTrue/TPC_Nsigma_pi_bachelor_all"), multiplicity, 0, trk2NSigmaPiBachelorTPC); // not exist pt information in resocascade yet. if (hasSubsystemInfo(trk2NSigmaPiBachelorTOF)) { - histos.fill(HIST("QAafter/TOF_TPC_Map_pi_bachelor_all"), trk2NSigmaPiBachelorTOF, trk2NSigmaPiBachelorTPC); + histos.fill(HIST("QAMCTrue/TOF_TPC_Map_pi_bachelor_all"), trk2NSigmaPiBachelorTOF, trk2NSigmaPiBachelorTPC); } - histos.fill(HIST("QAafter/TPC_Nsigma_antipr_all"), multiplicity, 0, trk2NSigmaPrNegTPC); + histos.fill(HIST("QAMCTrue/TPC_Nsigma_antipr_all"), multiplicity, 0, trk2NSigmaPrNegTPC); if (hasSubsystemInfo(trk2NSigmaPrNegTOF)) { - histos.fill(HIST("QAafter/TOF_TPC_Map_antipr_all"), trk2NSigmaPrNegTOF, trk2NSigmaPrNegTPC); + histos.fill(HIST("QAMCTrue/TOF_TPC_Map_antipr_all"), trk2NSigmaPrNegTOF, trk2NSigmaPrNegTPC); } - histos.fill(HIST("QAafter/TPC_Nsigma_pi_all"), multiplicity, 0, trk2NSigmaPiPosTPC); + histos.fill(HIST("QAMCTrue/TPC_Nsigma_pi_all"), multiplicity, 0, trk2NSigmaPiPosTPC); if (hasSubsystemInfo(trk2NSigmaPiPosTOF)) { - histos.fill(HIST("QAafter/TOF_TPC_Map_pi_all"), trk2NSigmaPiPosTOF, trk2NSigmaPiPosTPC); + histos.fill(HIST("QAMCTrue/TOF_TPC_Map_pi_all"), trk2NSigmaPiPosTOF, trk2NSigmaPiPosTPC); } } // MC histograms @@ -896,40 +1014,45 @@ struct xi1530analysisqa { histos.fill(HIST("Xi1530Rec"), lResonancePt, multiplicity); histos.fill(HIST("Xi1530Recinvmass"), lResonanceInMass); histos.fill(HIST("h3RecXi1530invmass"), multiplicity, lResonancePt, lResonanceInMass, kMCReco); + histos.fill(HIST("h3RecXiinvmass"), multiplicity, trk2ptXi, trk2Mass, kMCReco); } else { histos.fill(HIST("Xi1530RecAnti"), lResonancePt, multiplicity); histos.fill(HIST("Xi1530Recinvmass"), lResonanceInMass); histos.fill(HIST("h3RecXi1530invmassAnti"), multiplicity, lResonancePt, lResonanceInMass, kMCReco); + histos.fill(HIST("h3RecXiinvmassAnti"), multiplicity, trk2ptXi, trk2Mass, kMCReco); } } } else { if constexpr (!IsMix) { - if (study_antiparticle) { + if (studyAntiparticle) { if (trk1.sign() < 0) { - if (invmass1D) + if (invMass1D) histos.fill(HIST("Xi1530invmassLS"), lResonanceInMass); histos.fill(HIST("h3Xi1530invmassLS"), multiplicity, lResonancePt, lResonanceInMass, kLS); + histos.fill(HIST("h3XiinvmassLS"), multiplicity, trk2ptXi, trk2Mass, kLS); } else if (trk1.sign() > 0) { - if (invmass1D) + if (invMass1D) histos.fill(HIST("Xi1530invmassLSAnti"), lResonanceInMass); histos.fill(HIST("h3Xi1530invmassLSAnti"), multiplicity, lResonancePt, lResonanceInMass, kLS); + histos.fill(HIST("h3XiinvmassLSAnti"), multiplicity, trk2ptXi, trk2Mass, kLS); } } else { - if (invmass1D) + if (invMass1D) histos.fill(HIST("Xi1530invmassLS"), lResonanceInMass); histos.fill(HIST("h3Xi1530invmassLS"), multiplicity, lResonancePt, lResonanceInMass, kLS); + histos.fill(HIST("h3XiinvmassLS"), multiplicity, trk2ptXi, trk2Mass, kLS); } } } } } - void processData(aod::ResoCollision& resoCollision, aod::ResoTracks const& resoTracks, aod::ResoCascades const& cascTracks) + void processData(aod::ResoCollision const& resoCollision, aod::ResoTracks const& resoTracks, aod::ResoCascades const& cascTracks) { - if (additionalQAeventPlots) - histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); - fillHistograms(resoCollision, resoTracks, cascTracks); + + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); + fillHistograms(resoCollision, resoTracks, cascTracks); } void processMC(ResoMCCols::iterator const& resoCollision, @@ -938,74 +1061,115 @@ struct xi1530analysisqa { { if (!resoCollision.isInAfterAllCuts() || (std::abs(resoCollision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut return; - fillHistograms(resoCollision, resoTracks, cascTracks); + fillHistograms(resoCollision, resoTracks, cascTracks); } - void processMCTrue(ResoMCCols::iterator const& resoCollision, aod::ResoMCParents& resoParents) + void processMCTrue(ResoMCCols::iterator const& resoCollision, aod::ResoMCParents const& resoParents) { auto multiplicity = resoCollision.cent(); - for (auto& part : resoParents) { // loop over all pre-filtered MC particles - if (std::abs(part.pdgCode()) != XiStarPID || std::abs(part.y()) >= 0.5) + for (const auto& part : resoParents) { // loop over all pre-filtered MC particles + if (std::abs(part.pdgCode()) != kXiStar || std::abs(part.y()) >= cfgRapidityCut) continue; - bool pass1 = std::abs(part.daughterPDG1()) == PionPID || std::abs(part.daughterPDG2()) == PionPID; - bool pass2 = std::abs(part.daughterPDG1()) == XiPID || std::abs(part.daughterPDG2()) == XiPID; + bool pass1 = std::abs(part.daughterPDG1()) == kPiPlus || std::abs(part.daughterPDG2()) == kPiPlus; + bool pass2 = std::abs(part.daughterPDG1()) == kXiMinus || std::abs(part.daughterPDG2()) == kXiMinus; if (!pass1 || !pass2) continue; - if (resoCollision.isVtxIn10()) // INEL10 + if (cIsPhysicalPrimaryMC && !part.isPhysicalPrimary()) + continue; + + if (part.pdgCode() > 0) // INELt0 or INEL + histos.fill(HIST("h3Xi1530Gen"), -1, part.pt(), multiplicity); + else + histos.fill(HIST("h3Xi1530GenAnti"), -1, part.pt(), multiplicity); + + if (resoCollision.isVtxIn10()) // vtx10 { if (part.pdgCode() > 0) - histos.fill(HIST("h3Xi1530Gen"), 0, part.pt(), multiplicity, kINEL10); + histos.fill(HIST("h3Xi1530Gen"), 0, part.pt(), multiplicity); else - histos.fill(HIST("h3Xi1530GenAnti"), 0, part.pt(), multiplicity, kINEL10); + histos.fill(HIST("h3Xi1530GenAnti"), 0, part.pt(), multiplicity); } - if (resoCollision.isVtxIn10() && resoCollision.isInSel8()) // INEL>10, vtx10 + if (resoCollision.isVtxIn10() && resoCollision.isInSel8()) // vtx10 && sel8 { if (part.pdgCode() > 0) - histos.fill(HIST("h3Xi1530Gen"), 1, part.pt(), multiplicity, kINELg010); + histos.fill(HIST("h3Xi1530Gen"), 1, part.pt(), multiplicity); else - histos.fill(HIST("h3Xi1530GenAnti"), 1, part.pt(), multiplicity, kINELg010); + histos.fill(HIST("h3Xi1530GenAnti"), 1, part.pt(), multiplicity); } - if (resoCollision.isVtxIn10() && resoCollision.isTriggerTVX()) // vtx10, TriggerTVX + if (resoCollision.isVtxIn10() && resoCollision.isTriggerTVX()) // vtx10 && TriggerTVX { if (part.pdgCode() > 0) - histos.fill(HIST("h3Xi1530Gen"), 2, part.pt(), multiplicity, kMCTruePS); + histos.fill(HIST("h3Xi1530Gen"), 2, part.pt(), multiplicity); else - histos.fill(HIST("h3Xi1530GenAnti"), 2, part.pt(), multiplicity, kMCTruePS); + histos.fill(HIST("h3Xi1530GenAnti"), 2, part.pt(), multiplicity); } if (resoCollision.isInAfterAllCuts()) // after all event selection { if (part.pdgCode() > 0) - histos.fill(HIST("h3Xi1530Gen"), 3, part.pt(), multiplicity, kAllType); + histos.fill(HIST("h3Xi1530Gen"), 3, part.pt(), multiplicity); else - histos.fill(HIST("h3Xi1530GenAnti"), 3, part.pt(), multiplicity, kAllType); + histos.fill(HIST("h3Xi1530GenAnti"), 3, part.pt(), multiplicity); } } } + void processDataMicro(aod::ResoCollision const& resoCollision, aod::ResoMicroTracks const& resomicrotracks, aod::ResoCascades const& cascTracks) + { + + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); + fillHistograms(resoCollision, resomicrotracks, cascTracks); + } + using BinningTypeVtxZT0M = ColumnBinningPolicy; - void processME(aod::ResoCollisions const& resoCollisions, aod::ResoTracks const& resoTracks, aod::ResoCascades const& cascTracks) + Preslice perRColdf = aod::resodaughter::resoCollisionDFId; + Preslice perRColdfCasc = aod::resodaughter::resoCollisionDFId; + + void processMEDF(aod::ResoCollisionDFs const& resoCollisions, aod::ResoTrackDFs const& resotracks, aod::ResoCascadeDFs const& cascTracks) + { + + auto tracksTuple = std::make_tuple(resotracks, cascTracks); + + BinningTypeVtxZT0M colBinning{{cfgVtxBins, cfgMultBins}, true}; + Pair pairs{colBinning, nEvtMixing, -1, resoCollisions, tracksTuple, &cache}; + + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); + fillHistograms(collision1, tracks1, tracks2); + } + } + void processDataDF(aod::ResoCollisionDF const& resoCollision, aod::ResoTrackDFs const& resotracks, aod::ResoCascadeDFs const& cascTracks) { - auto tracksTuple = std::make_tuple(resoTracks, cascTracks); - BinningTypeVtxZT0M colBinning{{CfgVtxBins, CfgMultBins}, true}; - Pair pairs{colBinning, nEvtMixing, -1, resoCollisions, tracksTuple, &cache}; + fillHistograms(resoCollision, resotracks, cascTracks); + } + + void processMEMicro(aod::ResoCollisions const& resoCollisions, aod::ResoMicroTracks const& resomicrotracks, aod::ResoCascades const& cascTracks) + { + auto tracksTuple = std::make_tuple(resomicrotracks, cascTracks); + + BinningTypeVtxZT0M colBinning{{cfgVtxBins, cfgMultBins}, true}; + Pair pairs{colBinning, nEvtMixing, -1, resoCollisions, tracksTuple, &cache}; + + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { - for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { - if (additionalQAeventPlots) - histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); - fillHistograms(collision1, tracks1, tracks2); + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); + fillHistograms(collision1, tracks1, tracks2); } } - PROCESS_SWITCH(xi1530analysisqa, processData, "Process Event for Data", true); - PROCESS_SWITCH(xi1530analysisqa, processMC, "Process Event for MC (Reconstructed)", true); - PROCESS_SWITCH(xi1530analysisqa, processMCTrue, "Process Event for MC (Generated)", true); - PROCESS_SWITCH(xi1530analysisqa, processME, "Process EventMixing light without partition", true); + PROCESS_SWITCH(Xi1530Analysisqa, processData, "Process Event for Data", false); + PROCESS_SWITCH(Xi1530Analysisqa, processMC, "Process Event for MC (Reconstructed)", false); + PROCESS_SWITCH(Xi1530Analysisqa, processMCTrue, "Process Event for MC (Generated)", false); + PROCESS_SWITCH(Xi1530Analysisqa, processDataMicro, "Process Event for Data (MicroTrack)", false); + PROCESS_SWITCH(Xi1530Analysisqa, processMEMicro, "Process EventMixing (MicroTrack) ", false); + PROCESS_SWITCH(Xi1530Analysisqa, processMEDF, "Process EventMixing (DF) ", true); + PROCESS_SWITCH(Xi1530Analysisqa, processDataDF, "Process Event for Data (DF) ", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Strangeness/CMakeLists.txt b/PWGLF/Tasks/Strangeness/CMakeLists.txt index ff899776b3f..5f88145c01d 100644 --- a/PWGLF/Tasks/Strangeness/CMakeLists.txt +++ b/PWGLF/Tasks/Strangeness/CMakeLists.txt @@ -16,7 +16,7 @@ o2physics_add_dpl_workflow(hyperon-reco-test o2physics_add_dpl_workflow(derivedlambdakzeroanalysis SOURCES derivedlambdakzeroanalysis.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(lambdakzeroanalysis-mc @@ -29,11 +29,6 @@ o2physics_add_dpl_workflow(cascadeanalysis PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(sigmaminus-task - SOURCES sigmaminustask.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(cascadeanalysismc SOURCES cascadeanalysisMC.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -51,7 +46,7 @@ o2physics_add_dpl_workflow(cascadecorrelations o2physics_add_dpl_workflow(non-prompt-cascade SOURCES nonPromptCascade.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::ReconstructionDataFormats O2Physics::AnalysisCore O2::DetectorsBase + PUBLIC_LINK_LIBRARIES O2::Framework O2::ReconstructionDataFormats O2Physics::AnalysisCore O2::DetectorsBase O2::DetectorsVertexing O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(k0mixedevents @@ -66,7 +61,7 @@ o2physics_add_dpl_workflow(vzero-cascade-absorption o2physics_add_dpl_workflow(derivedcascadeanalysis SOURCES derivedcascadeanalysis.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(cascpostprocessing @@ -81,7 +76,7 @@ o2physics_add_dpl_workflow(hstrangecorrelation o2physics_add_dpl_workflow(sigmaanalysis SOURCES sigmaanalysis.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(phik0shortanalysis @@ -99,11 +94,23 @@ o2physics_add_dpl_workflow(lambdapolsp PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(strangeness-in-jets - SOURCES strangeness_in_jets.cxx +o2physics_add_dpl_workflow(task-lambda-spin-corr + SOURCES taskLambdaSpinCorr.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(cascpolsp + SOURCES cascpolsp.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +if(FastJet_FOUND) +o2physics_add_dpl_workflow(strangeness-in-jets + SOURCES strangenessInJets.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGJECore FastJet::FastJet FastJet::Contrib O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) +endif() + o2physics_add_dpl_workflow(v0topologicalcuts SOURCES v0topologicalcuts.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -114,8 +121,8 @@ o2physics_add_dpl_workflow(v0ptinvmassplots PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(strange-yield-pbpb - SOURCES strange-yield-pbpb.cxx +o2physics_add_dpl_workflow(derivedupcanalysis + SOURCES derivedupcanalysis.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -128,3 +135,23 @@ o2physics_add_dpl_workflow(lambdalambda SOURCES lambdalambda.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(lambdajetpolarization + SOURCES lambdaJetpolarization.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGJECore FastJet::FastJet FastJet::Contrib O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(lambdaspincorrderived + SOURCES lambdaspincorrderived.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(strangenessderivedbinnedinfo + SOURCES strangenessderivedbinnedinfo.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(lambdatwopartpolarization + SOURCES lambdaTwoPartPolarization.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGLF/Tasks/Strangeness/cascadeanalysisMC.cxx b/PWGLF/Tasks/Strangeness/cascadeanalysisMC.cxx index 896d366a1fa..a1947c8b6b5 100644 --- a/PWGLF/Tasks/Strangeness/cascadeanalysisMC.cxx +++ b/PWGLF/Tasks/Strangeness/cascadeanalysisMC.cxx @@ -31,6 +31,11 @@ // david.dobrigkeit.chinellato@cern.ch // +#include +#include +#include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -49,13 +54,8 @@ #include #include #include -#include #include #include -#include -#include -#include -#include "Framework/ASoAHelpers.h" using namespace o2; using namespace o2::framework; @@ -80,6 +80,7 @@ struct cascadeGenerated { Configurable nPtBins{"nPtBins", 200, "number of pT bins"}; Configurable rapidityCut{"rapidityCut", 0.5, "max (absolute) rapidity of generated cascade"}; Configurable nRapidityBins{"nRapidityBins", 200, "number of pT bins"}; + Configurable requirePhysicalPrimary{"requirePhysicalPrimary", false, "require the generated cascade to be a physical primary"}; void init(InitContext const&) { @@ -108,6 +109,8 @@ struct cascadeGenerated { for (auto& particle : mcparts) { if (TMath::Abs(particle.y()) > rapidityCut) continue; + if (requirePhysicalPrimary && !particle.isPhysicalPrimary()) + continue; if (particle.pdgCode() == 3312) { registry.fill(HIST("hPtXiMinus"), particle.pt()); registry.fill(HIST("h2DXiMinus"), particle.pt(), particle.y()); @@ -469,7 +472,7 @@ struct cascadeAnalysisMC { } PROCESS_SWITCH(cascadeAnalysisMC, processRun2VsMultiplicity, "Process Run 2 data vs multiplicity", false); - void processRun3WithPID(soa::Join::iterator const& collision, soa::Filtered const& Cascades, aod::V0sLinked const&, FullTracksExtIUWithPID const&, aod::McParticles const&) + void processRun3WithPID(soa::Join::iterator const& collision, soa::Filtered const& Cascades, FullTracksExtIUWithPID const&, aod::McParticles const&) // process function subscribing to Run 3-like analysis objects { // Run 3 event selection criteria @@ -484,7 +487,7 @@ struct cascadeAnalysisMC { } PROCESS_SWITCH(cascadeAnalysisMC, processRun3WithPID, "Process Run 3 data with PID", false); - void processRun2WithPID(soa::Join::iterator const& collision, soa::Filtered const& Cascades, aod::V0sLinked const&, FullTracksExtWithPID const&, aod::McParticles const&) + void processRun2WithPID(soa::Join::iterator const& collision, soa::Filtered const& Cascades, FullTracksExtWithPID const&, aod::McParticles const&) // process function subscribing to Run 3-like analysis objects { // Run 2 event selection criteria diff --git a/PWGLF/Tasks/Strangeness/cascadecorrelations.cxx b/PWGLF/Tasks/Strangeness/cascadecorrelations.cxx index 7cb9a984d9d..c062c2f1a0d 100644 --- a/PWGLF/Tasks/Strangeness/cascadecorrelations.cxx +++ b/PWGLF/Tasks/Strangeness/cascadecorrelations.cxx @@ -15,36 +15,40 @@ // Author: Rik Spijkers (rik.spijkers@cern.ch) // -#include -#include -#include -#include -#include -#include +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/Utils/inelGt.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" #include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" #include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" +#include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" -#include "CCDB/BasicCCDBManager.h" +#include "Common/DataModel/TrackSelectionTables.h" #include "EventFiltering/Zorro.h" +#include "CCDB/BasicCCDBManager.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include #include -#include #include -#include +#include #include #include +#include + +#include +#include +#include +#include +#include // #include using namespace o2; @@ -75,12 +79,14 @@ DECLARE_SOA_TABLE(CascadeFlags, "AOD", "CASCADEFLAGS", //! using CascDataExtSelected = soa::Join; } // namespace o2::aod -using MyCollisions = soa::Join; +using MyCollisions = soa::Join; using MyCollisionsMult = soa::Join; using MyCascades = soa::Filtered; +using LabeledCascades = soa::Join; struct CascadeSelector { Service ccdb; + Service pdgDB; Produces cascflags; @@ -90,6 +96,12 @@ struct CascadeSelector { Configurable triggerList{"triggerList", "fDoubleXi, fDoubleOmega, fOmegaXi", "List of triggers used to select events"}; Configurable doTFBorderCut{"doTFBorderCut", true, "Switch to apply TimeframeBorderCut event selection"}; Configurable doSel8{"doSel8", true, "Switch to apply sel8 event selection"}; + Configurable doNoSameBunchPileUp{"doNoSameBunchPileUp", true, "Switch to apply NoSameBunchPileUp event selection"}; + Configurable INEL{"INEL", 0, "Number of charged tracks within |eta| < 1 has to be greater than value"}; + Configurable maxVertexZ{"maxVertexZ", 10., "Maximum value of z coordinate of PV"}; + Configurable etaCascades{"etaCascades", 0.8, "min/max of eta for cascades"}; + Configurable doCompetingMassCut{"doCompetingMassCut", true, "Switch to apply a competing mass cut for the Omega's"}; + Configurable competingMassWindow{"competingMassWindow", 0.01, "Mass window for the competing mass cut"}; // Tracklevel Configurable tpcNsigmaBachelor{"tpcNsigmaBachelor", 3, "TPC NSigma bachelor"}; @@ -98,6 +110,8 @@ struct CascadeSelector { Configurable minTPCCrossedRows{"minTPCCrossedRows", 80, "min N TPC crossed rows"}; // TODO: finetune! 80 > 159/2, so no split tracks? Configurable minITSClusters{"minITSClusters", 4, "minimum number of ITS clusters"}; Configurable etaTracks{"etaTracks", 1.0, "min/max of eta for tracks"}; + Configurable tpcChi2{"tpcChi2", 4, "TPC Chi2"}; + Configurable itsChi2{"itsChi2", 36, "ITS Chi2"}; // Selection criteria - compatible with core wagon autodetect - copied from cascadeanalysis.cxx //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* @@ -115,41 +129,59 @@ struct CascadeSelector { //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* // TODO: variables as function of Omega mass, only do Xi for now - AxisSpec vertexAxis = {100, -10.0f, 10.0f, "cm"}; - AxisSpec dcaAxis = {50, 0.0f, 5.0f, "cm"}; - AxisSpec invMassAxis = {100, 1.25f, 1.45f, "Inv. Mass (GeV/c^{2})"}; - AxisSpec ptAxis = {100, 0, 15, "#it{p}_{T}"}; + ConfigurableAxis radiusAxis = {"radiusAxis", {100, 0.0f, 50.0f}, "cm"}; + ConfigurableAxis cpaAxis = {"cpaAxis", {100, 0.95f, 1.0f}, "CPA"}; + ConfigurableAxis vertexAxis = {"vertexAxis", {100, -10.0f, 10.0f}, "cm"}; + ConfigurableAxis dcaAxis = {"dcaAxis", {100, 0.0f, 2.0f}, "cm"}; + ConfigurableAxis invXiMassAxis = {"invXiMassAxis", {100, 1.28f, 1.38f}, "Inv. Mass (GeV/c^{2})"}; + ConfigurableAxis invOmegaMassAxis = {"invOmegaMassAxis", {100, 1.62f, 1.72f}, "Inv. Mass (GeV/c^{2})"}; + ConfigurableAxis ptAxis = {"ptAxis", {150, 0, 15}, "#it{p}_{T}"}; + ConfigurableAxis rapidityAxis{"rapidityAxis", {100, -1.f, 1.f}, "y"}; + ConfigurableAxis invLambdaMassAxis{"invLambdaMassAxis", {100, 1.07f, 1.17f}, "Inv. Mass (GeV/c^{2})"}; + AxisSpec itsClustersAxis{8, -0.5, 7.5, "number of ITS clusters"}; + AxisSpec tpcRowsAxis{160, -0.5, 159.5, "TPC crossed rows"}; HistogramRegistry registry{ "registry", { // basic selection variables - {"hV0Radius", "hV0Radius", {HistType::kTH3F, {{100, 0.0f, 100.0f, "cm"}, invMassAxis, ptAxis}}}, - {"hCascRadius", "hCascRadius", {HistType::kTH3F, {{100, 0.0f, 100.0f, "cm"}, invMassAxis, ptAxis}}}, - {"hV0CosPA", "hV0CosPA", {HistType::kTH3F, {{100, 0.95f, 1.0f}, invMassAxis, ptAxis}}}, - {"hCascCosPA", "hCascCosPA", {HistType::kTH3F, {{100, 0.95f, 1.0f}, invMassAxis, ptAxis}}}, - {"hDCAPosToPV", "hDCAPosToPV", {HistType::kTH3F, {vertexAxis, invMassAxis, ptAxis}}}, - {"hDCANegToPV", "hDCANegToPV", {HistType::kTH3F, {vertexAxis, invMassAxis, ptAxis}}}, - {"hDCABachToPV", "hDCABachToPV", {HistType::kTH3F, {vertexAxis, invMassAxis, ptAxis}}}, - {"hDCAV0ToPV", "hDCAV0ToPV", {HistType::kTH3F, {vertexAxis, invMassAxis, ptAxis}}}, - {"hDCAV0Dau", "hDCAV0Dau", {HistType::kTH3F, {dcaAxis, invMassAxis, ptAxis}}}, - {"hDCACascDau", "hDCACascDau", {HistType::kTH3F, {dcaAxis, invMassAxis, ptAxis}}}, - {"hLambdaMass", "hLambdaMass", {HistType::kTH3F, {{100, 1.0f, 1.2f, "Inv. Mass (GeV/c^{2})"}, invMassAxis, ptAxis}}}, - - // invariant mass per cut, start with Xi - {"hMassXi0", "Xi inv mass before selections", {HistType::kTH2F, {invMassAxis, ptAxis}}}, - {"hMassXi1", "Xi inv mass after TPCnCrossedRows cut", {HistType::kTH2F, {invMassAxis, ptAxis}}}, - {"hMassXi2", "Xi inv mass after ITSnClusters cut", {HistType::kTH2F, {invMassAxis, ptAxis}}}, - {"hMassXi3", "Xi inv mass after topo cuts", {HistType::kTH2F, {invMassAxis, ptAxis}}}, - {"hMassXi4", "Xi inv mass after V0 daughters PID cut", {HistType::kTH2F, {invMassAxis, ptAxis}}}, - {"hMassXi5", "Xi inv mass after bachelor PID cut", {HistType::kTH2F, {invMassAxis, ptAxis}}}, + {"hV0Radius", "hV0Radius", {HistType::kTH3F, {radiusAxis, invXiMassAxis, ptAxis}}}, + {"hCascRadius", "hCascRadius", {HistType::kTH3F, {radiusAxis, invXiMassAxis, ptAxis}}}, + {"hV0CosPA", "hV0CosPA", {HistType::kTH3F, {cpaAxis, invXiMassAxis, ptAxis}}}, + {"hCascCosPA", "hCascCosPA", {HistType::kTH3F, {cpaAxis, invXiMassAxis, ptAxis}}}, + {"hDCAPosToPV", "hDCAPosToPV", {HistType::kTH3F, {vertexAxis, invXiMassAxis, ptAxis}}}, + {"hDCANegToPV", "hDCANegToPV", {HistType::kTH3F, {vertexAxis, invXiMassAxis, ptAxis}}}, + {"hDCABachToPV", "hDCABachToPV", {HistType::kTH3F, {vertexAxis, invXiMassAxis, ptAxis}}}, + {"hDCAV0ToPV", "hDCAV0ToPV", {HistType::kTH3F, {vertexAxis, invXiMassAxis, ptAxis}}}, + {"hDCAV0Dau", "hDCAV0Dau", {HistType::kTH3F, {dcaAxis, invXiMassAxis, ptAxis}}}, + {"hDCACascDau", "hDCACascDau", {HistType::kTH3F, {dcaAxis, invXiMassAxis, ptAxis}}}, + {"hLambdaMass", "hLambdaMass", {HistType::kTH3F, {invLambdaMassAxis, invXiMassAxis, ptAxis}}}, + + {"hMassXiMinus", "hMassXiMinus", {HistType::kTH3F, {invXiMassAxis, ptAxis, rapidityAxis}}}, + {"hMassXiPlus", "hMassXiPlus", {HistType::kTH3F, {invXiMassAxis, ptAxis, rapidityAxis}}}, + {"hMassOmegaMinus", "hMassOmegaMinus", {HistType::kTH3F, {invOmegaMassAxis, ptAxis, rapidityAxis}}}, + {"hMassOmegaPlus", "hMassOmegaPlus", {HistType::kTH3F, {invOmegaMassAxis, ptAxis, rapidityAxis}}}, + + // // invariant mass per cut, start with Xi + // {"hMassXi0", "Xi inv mass before selections", {HistType::kTH2F, {invMassAxis, ptAxis}}}, + // {"hMassXi1", "Xi inv mass after TPCnCrossedRows cut", {HistType::kTH2F, {invMassAxis, ptAxis}}}, + // {"hMassXi2", "Xi inv mass after ITSnClusters cut", {HistType::kTH2F, {invMassAxis, ptAxis}}}, + // {"hMassXi3", "Xi inv mass after topo cuts", {HistType::kTH2F, {invMassAxis, ptAxis}}}, + // {"hMassXi4", "Xi inv mass after V0 daughters PID cut", {HistType::kTH2F, {invMassAxis, ptAxis}}}, + // {"hMassXi5", "Xi inv mass after bachelor PID cut", {HistType::kTH2F, {invMassAxis, ptAxis}}}, // ITS & TPC clusters, with Xi inv mass - {"hTPCnCrossedRowsPos", "hTPCnCrossedRowsPos", {HistType::kTH3F, {{160, -0.5, 159.5, "TPC crossed rows"}, invMassAxis, ptAxis}}}, - {"hTPCnCrossedRowsNeg", "hTPCnCrossedRowsNeg", {HistType::kTH3F, {{160, -0.5, 159.5, "TPC crossed rows"}, invMassAxis, ptAxis}}}, - {"hTPCnCrossedRowsBach", "hTPCnCrossedRowsBach", {HistType::kTH3F, {{160, -0.5, 159.5, "TPC crossed rows"}, invMassAxis, ptAxis}}}, - {"hITSnClustersPos", "hITSnClustersPos", {HistType::kTH3F, {{8, -0.5, 7.5, "number of ITS clusters"}, invMassAxis, ptAxis}}}, - {"hITSnClustersNeg", "hITSnClustersNeg", {HistType::kTH3F, {{8, -0.5, 7.5, "number of ITS clusters"}, invMassAxis, ptAxis}}}, - {"hITSnClustersBach", "hITSnClustersBach", {HistType::kTH3F, {{8, -0.5, 7.5, "number of ITS clusters"}, invMassAxis, ptAxis}}}, + {"hTPCnCrossedRowsPos", "hTPCnCrossedRowsPos", {HistType::kTH3F, {tpcRowsAxis, invXiMassAxis, ptAxis}}}, + {"hTPCnCrossedRowsNeg", "hTPCnCrossedRowsNeg", {HistType::kTH3F, {tpcRowsAxis, invXiMassAxis, ptAxis}}}, + {"hTPCnCrossedRowsBach", "hTPCnCrossedRowsBach", {HistType::kTH3F, {tpcRowsAxis, invXiMassAxis, ptAxis}}}, + {"hITSnClustersPos", "hITSnClustersPos", {HistType::kTH3F, {itsClustersAxis, invXiMassAxis, ptAxis}}}, + {"hITSnClustersNeg", "hITSnClustersNeg", {HistType::kTH3F, {itsClustersAxis, invXiMassAxis, ptAxis}}}, + {"hITSnClustersBach", "hITSnClustersBach", {HistType::kTH3F, {itsClustersAxis, invXiMassAxis, ptAxis}}}, + {"hTPCChi2Pos", "hTPCChi2Pos", {HistType::kTH1F, {{100, 0, 10, "TPC Chi2 Pos"}}}}, + {"hTPCChi2Neg", "hTPCChi2Neg", {HistType::kTH1F, {{100, 0, 10, "TPC Chi2 Neg"}}}}, + {"hTPCChi2Bach", "hTPCChi2Bach", {HistType::kTH1F, {{100, 0, 10, "TPC Chi2 Bach"}}}}, + {"hITSChi2Pos", "hITSChi2Pos", {HistType::kTH1F, {{100, 0, 100, "ITS Chi2 Pos"}}}}, + {"hITSChi2Neg", "hITSChi2Neg", {HistType::kTH1F, {{100, 0, 100, "ITS Chi2 Neg"}}}}, + {"hITSChi2Bach", "hITSChi2Bach", {HistType::kTH1F, {{100, 0, 100, "ITS Chi2 Bach"}}}}, {"hTriggerQA", "hTriggerQA", {HistType::kTH1F, {{2, -0.5, 1.5, "Trigger y/n"}}}}, }, @@ -165,155 +197,404 @@ struct CascadeSelector { h->GetXaxis()->SetBinLabel(1, "All"); h->GetXaxis()->SetBinLabel(2, "nTPC OK"); h->GetXaxis()->SetBinLabel(3, "nITS OK"); - h->GetXaxis()->SetBinLabel(4, "Topo OK"); - h->GetXaxis()->SetBinLabel(5, "Track eta OK"); - h->GetXaxis()->SetBinLabel(6, "V0 PID OK"); - h->GetXaxis()->SetBinLabel(7, "Bach PID OK"); + h->GetXaxis()->SetBinLabel(4, "track Chi2 OK"); + h->GetXaxis()->SetBinLabel(5, "Topo OK"); + h->GetXaxis()->SetBinLabel(6, "Track eta OK"); + h->GetXaxis()->SetBinLabel(7, "Cascade eta OK"); + h->GetXaxis()->SetBinLabel(8, "V0 PID OK"); + h->GetXaxis()->SetBinLabel(9, "Bach PID OK"); + + auto hEventSel = registry.add("hEventSel", "hEventSel", HistType::kTH1I, {{10, 0, 10, "selection criteria"}}); + hEventSel->GetXaxis()->SetBinLabel(1, "All"); + hEventSel->GetXaxis()->SetBinLabel(2, "sel8"); + hEventSel->GetXaxis()->SetBinLabel(3, "INEL0"); + hEventSel->GetXaxis()->SetBinLabel(4, "V_z"); + hEventSel->GetXaxis()->SetBinLabel(5, "NoSameBunchPileUp"); + hEventSel->GetXaxis()->SetBinLabel(6, "Selected events"); + + if (doprocessRecMC) { + // only create the rec matched to gen histograms if relevant + registry.add("truerec/hV0Radius", "hV0Radius", HistType::kTH1F, {radiusAxis}); + registry.add("truerec/hCascRadius", "hCascRadius", HistType::kTH1F, {radiusAxis}); + registry.add("truerec/hV0CosPA", "hV0CosPA", HistType::kTH1F, {cpaAxis}); + registry.add("truerec/hCascCosPA", "hCascCosPA", HistType::kTH1F, {cpaAxis}); + registry.add("truerec/hDCAPosToPV", "hDCAPosToPV", HistType::kTH1F, {vertexAxis}); + registry.add("truerec/hDCANegToPV", "hDCANegToPV", HistType::kTH1F, {vertexAxis}); + registry.add("truerec/hDCABachToPV", "hDCABachToPV", HistType::kTH1F, {vertexAxis}); + registry.add("truerec/hDCAV0ToPV", "hDCAV0ToPV", HistType::kTH1F, {vertexAxis}); + registry.add("truerec/hDCAV0Dau", "hDCAV0Dau", HistType::kTH1F, {dcaAxis}); + registry.add("truerec/hDCACascDau", "hDCACascDau", HistType::kTH1F, {dcaAxis}); + registry.add("truerec/hLambdaMass", "hLambdaMass", HistType::kTH1F, {invLambdaMassAxis}); + registry.add("truerec/hTPCnCrossedRowsPos", "hTPCnCrossedRowsPos", HistType::kTH1F, {tpcRowsAxis}); + registry.add("truerec/hTPCnCrossedRowsNeg", "hTPCnCrossedRowsNeg", HistType::kTH1F, {tpcRowsAxis}); + registry.add("truerec/hTPCnCrossedRowsBach", "hTPCnCrossedRowsBach", HistType::kTH1F, {tpcRowsAxis}); + registry.add("truerec/hITSnClustersPos", "hITSnClustersPos", HistType::kTH1F, {itsClustersAxis}); + registry.add("truerec/hITSnClustersNeg", "hITSnClustersNeg", HistType::kTH1F, {itsClustersAxis}); + registry.add("truerec/hITSnClustersBach", "hITSnClustersBach", HistType::kTH1F, {itsClustersAxis}); + registry.add("truerec/hTPCChi2Pos", "hTPCChi2Pos", HistType::kTH1F, {{100, 0, 10, "TPC Chi2 Pos"}}); + registry.add("truerec/hTPCChi2Neg", "hTPCChi2Neg", HistType::kTH1F, {{100, 0, 10, "TPC Chi2 Neg"}}); + registry.add("truerec/hTPCChi2Bach", "hTPCChi2Bach", HistType::kTH1F, {{100, 0, 10, "TPC Chi2 Bach"}}); + registry.add("truerec/hITSChi2Pos", "hITSChi2Pos", HistType::kTH1F, {{100, 0, 100, "ITS Chi2 Pos"}}); + registry.add("truerec/hITSChi2Neg", "hITSChi2Neg", HistType::kTH1F, {{100, 0, 100, "ITS Chi2 Neg"}}); + registry.add("truerec/hITSChi2Bach", "hITSChi2Bach", HistType::kTH1F, {{100, 0, 100, "ITS Chi2 Bach"}}); + registry.add("truerec/hXiMinus", "hXiMinus", HistType::kTH2F, {ptAxis, rapidityAxis}); + registry.add("truerec/hXiPlus", "hXiPlus", HistType::kTH2F, {ptAxis, rapidityAxis}); + registry.add("truerec/hOmegaMinus", "hOmegaMinus", HistType::kTH2F, {ptAxis, rapidityAxis}); + registry.add("truerec/hOmegaPlus", "hOmegaPlus", HistType::kTH2F, {ptAxis, rapidityAxis}); + } + + if (doprocessGenMC) { + // only create the MC gen histograms if relevant + registry.add("gen/hXiMinus", "hXiMinus", HistType::kTH2F, {ptAxis, rapidityAxis}); + registry.add("gen/hXiPlus", "hXiPlus", HistType::kTH2F, {ptAxis, rapidityAxis}); + registry.add("gen/hOmegaMinus", "hOmegaMinus", HistType::kTH2F, {ptAxis, rapidityAxis}); + registry.add("gen/hOmegaPlus", "hOmegaPlus", HistType::kTH2F, {ptAxis, rapidityAxis}); + + registry.add("genwithrec/hXiMinus", "hXiMinus", HistType::kTH2F, {ptAxis, rapidityAxis}); + registry.add("genwithrec/hXiPlus", "hXiPlus", HistType::kTH2F, {ptAxis, rapidityAxis}); + registry.add("genwithrec/hOmegaMinus", "hOmegaMinus", HistType::kTH2F, {ptAxis, rapidityAxis}); + registry.add("genwithrec/hOmegaPlus", "hOmegaPlus", HistType::kTH2F, {ptAxis, rapidityAxis}); + + registry.add("genwithrec/hNevents", "hNevents", HistType::kTH1F, {{1, 0, 1, "N generated events with reconstructed event"}}); + registry.add("gen/hNevents", "hNevents", HistType::kTH1F, {{1, 0, 1, "N generated events"}}); + } } - void process(MyCollisions::iterator const& collision, aod::CascDataExt const& Cascades, FullTracksExtIUWithPID const&, aod::BCsWithTimestamps const&) + + template + bool eventSelection(TCollision const& collision) { - bool evSel = true; if (useTrigger) { - auto bc = collision.bc_as(); + auto bc = collision.template bc_as(); zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), triggerList); bool eventTrigger = zorro.isSelected(bc.globalBC()); if (eventTrigger) { registry.fill(HIST("hTriggerQA"), 1); } else { registry.fill(HIST("hTriggerQA"), 0); - evSel = false; + return false; } } - - if ((doSel8 && !collision.sel8()) || (doTFBorderCut && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { - evSel = false; // do not skip the collision - this will lead to the cascadeFlag table having less entries than the Cascade table, and therefor not joinable. + // fill event selection based on which selection criteria are applied and passed + registry.fill(HIST("hEventSel"), 0); + if (doSel8 && !collision.sel8()) { + registry.fill(HIST("hEventSel"), 1); + return false; + } else if (collision.multNTracksPVeta1() <= INEL) { + registry.fill(HIST("hEventSel"), 2); + return false; + } else if (std::abs(collision.posZ()) > maxVertexZ) { + registry.fill(HIST("hEventSel"), 3); + return false; + } else if (doNoSameBunchPileUp && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + registry.fill(HIST("hEventSel"), 4); + return false; } + // passes all selections + registry.fill(HIST("hEventSel"), 5); + return true; + } - for (auto const& casc : Cascades) { - if (!evSel) { - cascflags(0); - continue; + template + void fillMatchedHistos(LabeledCascades::iterator rec, int flag, TCollision collision) + { + if (flag == 0) + return; + if (!rec.has_mcParticle()) + return; + auto gen = rec.mcParticle(); + if (!gen.isPhysicalPrimary()) + return; + int genpdg = gen.pdgCode(); + if ((flag < 3 && std::abs(genpdg) == 3312) || (flag > 1 && std::abs(genpdg) == 3334)) { + // if casc is consistent with Xi and has matched gen Xi OR cand is consistent with Omega and has matched gen omega + // have to do this in case we reco true Xi with only Omega hypothesis (or vice versa) (very unlikely) + registry.fill(HIST("truerec/hV0Radius"), rec.v0radius()); + registry.fill(HIST("truerec/hCascRadius"), rec.cascradius()); + registry.fill(HIST("truerec/hV0CosPA"), rec.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("truerec/hCascCosPA"), rec.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("truerec/hDCAPosToPV"), rec.dcapostopv()); + registry.fill(HIST("truerec/hDCANegToPV"), rec.dcanegtopv()); + registry.fill(HIST("truerec/hDCABachToPV"), rec.dcabachtopv()); + registry.fill(HIST("truerec/hDCAV0ToPV"), rec.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + registry.fill(HIST("truerec/hDCAV0Dau"), rec.dcaV0daughters()); + registry.fill(HIST("truerec/hDCACascDau"), rec.dcacascdaughters()); + registry.fill(HIST("truerec/hLambdaMass"), rec.mLambda()); + registry.fill(HIST("truerec/hITSnClustersPos"), rec.posTrack_as().itsNCls()); + registry.fill(HIST("truerec/hITSnClustersNeg"), rec.negTrack_as().itsNCls()); + registry.fill(HIST("truerec/hITSnClustersBach"), rec.bachelor_as().itsNCls()); + registry.fill(HIST("truerec/hTPCnCrossedRowsPos"), rec.posTrack_as().tpcNClsCrossedRows()); + registry.fill(HIST("truerec/hTPCnCrossedRowsNeg"), rec.negTrack_as().tpcNClsCrossedRows()); + registry.fill(HIST("truerec/hTPCnCrossedRowsBach"), rec.bachelor_as().tpcNClsCrossedRows()); + registry.fill(HIST("truerec/hITSChi2Pos"), rec.posTrack_as().itsChi2NCl()); + registry.fill(HIST("truerec/hITSChi2Neg"), rec.negTrack_as().itsChi2NCl()); + registry.fill(HIST("truerec/hITSChi2Bach"), rec.bachelor_as().itsChi2NCl()); + registry.fill(HIST("truerec/hTPCChi2Pos"), rec.posTrack_as().tpcChi2NCl()); + registry.fill(HIST("truerec/hTPCChi2Neg"), rec.negTrack_as().tpcChi2NCl()); + registry.fill(HIST("truerec/hTPCChi2Bach"), rec.bachelor_as().tpcChi2NCl()); + switch (genpdg) { // is matched so we can use genpdg + case 3312: + registry.fill(HIST("truerec/hXiMinus"), rec.pt(), rec.yXi()); + break; + case -3312: + registry.fill(HIST("truerec/hXiPlus"), rec.pt(), rec.yXi()); + break; + case 3334: + registry.fill(HIST("truerec/hOmegaMinus"), rec.pt(), rec.yOmega()); + break; + case -3334: + registry.fill(HIST("truerec/hOmegaPlus"), rec.pt(), rec.yOmega()); + break; } + } + } - // these are the tracks: - auto bachTrack = casc.bachelor_as(); - auto posTrack = casc.posTrack_as(); - auto negTrack = casc.negTrack_as(); - - // topo variables before cuts: - registry.fill(HIST("hV0Radius"), casc.v0radius(), casc.mXi(), casc.pt()); - registry.fill(HIST("hCascRadius"), casc.cascradius(), casc.mXi(), casc.pt()); - registry.fill(HIST("hV0CosPA"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()), casc.mXi(), casc.pt()); - registry.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()), casc.mXi(), casc.pt()); - registry.fill(HIST("hDCAPosToPV"), casc.dcapostopv(), casc.mXi(), casc.pt()); - registry.fill(HIST("hDCANegToPV"), casc.dcanegtopv(), casc.mXi(), casc.pt()); - registry.fill(HIST("hDCABachToPV"), casc.dcabachtopv(), casc.mXi(), casc.pt()); - registry.fill(HIST("hDCAV0ToPV"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()), casc.mXi(), casc.pt()); - registry.fill(HIST("hDCAV0Dau"), casc.dcaV0daughters(), casc.mXi(), casc.pt()); - registry.fill(HIST("hDCACascDau"), casc.dcacascdaughters(), casc.mXi(), casc.pt()); - registry.fill(HIST("hLambdaMass"), casc.mLambda(), casc.mXi(), casc.pt()); - - registry.fill(HIST("hITSnClustersPos"), posTrack.itsNCls(), casc.mXi(), casc.pt()); - registry.fill(HIST("hITSnClustersNeg"), negTrack.itsNCls(), casc.mXi(), casc.pt()); - registry.fill(HIST("hITSnClustersBach"), bachTrack.itsNCls(), casc.mXi(), casc.pt()); - registry.fill(HIST("hTPCnCrossedRowsPos"), posTrack.tpcNClsCrossedRows(), casc.mXi(), casc.pt()); - registry.fill(HIST("hTPCnCrossedRowsNeg"), negTrack.tpcNClsCrossedRows(), casc.mXi(), casc.pt()); - registry.fill(HIST("hTPCnCrossedRowsBach"), bachTrack.tpcNClsCrossedRows(), casc.mXi(), casc.pt()); - - registry.fill(HIST("hSelectionStatus"), 0); // all the cascade before selections - registry.fill(HIST("hMassXi0"), casc.mXi(), casc.pt()); - - // TPC N crossed rows todo: check if minTPCCrossedRows > 50 - if (posTrack.tpcNClsCrossedRows() < minTPCCrossedRows || negTrack.tpcNClsCrossedRows() < minTPCCrossedRows || bachTrack.tpcNClsCrossedRows() < minTPCCrossedRows) { - cascflags(0); - continue; - } - registry.fill(HIST("hSelectionStatus"), 1); // passes nTPC crossed rows - registry.fill(HIST("hMassXi1"), casc.mXi(), casc.pt()); + template + int processCandidate(TCascade const& casc, TCollision const& collision) + { + // these are the tracks: + auto bachTrack = casc.template bachelor_as(); + auto posTrack = casc.template posTrack_as(); + auto negTrack = casc.template negTrack_as(); + + // topo variables before cuts: + registry.fill(HIST("hV0Radius"), casc.v0radius(), casc.mXi(), casc.pt()); + registry.fill(HIST("hCascRadius"), casc.cascradius(), casc.mXi(), casc.pt()); + registry.fill(HIST("hV0CosPA"), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()), casc.mXi(), casc.pt()); + registry.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()), casc.mXi(), casc.pt()); + registry.fill(HIST("hDCAPosToPV"), casc.dcapostopv(), casc.mXi(), casc.pt()); + registry.fill(HIST("hDCANegToPV"), casc.dcanegtopv(), casc.mXi(), casc.pt()); + registry.fill(HIST("hDCABachToPV"), casc.dcabachtopv(), casc.mXi(), casc.pt()); + registry.fill(HIST("hDCAV0ToPV"), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()), casc.mXi(), casc.pt()); + registry.fill(HIST("hDCAV0Dau"), casc.dcaV0daughters(), casc.mXi(), casc.pt()); + registry.fill(HIST("hDCACascDau"), casc.dcacascdaughters(), casc.mXi(), casc.pt()); + registry.fill(HIST("hLambdaMass"), casc.mLambda(), casc.mXi(), casc.pt()); + + registry.fill(HIST("hITSnClustersPos"), posTrack.itsNCls(), casc.mXi(), casc.pt()); + registry.fill(HIST("hITSnClustersNeg"), negTrack.itsNCls(), casc.mXi(), casc.pt()); + registry.fill(HIST("hITSnClustersBach"), bachTrack.itsNCls(), casc.mXi(), casc.pt()); + registry.fill(HIST("hTPCnCrossedRowsPos"), posTrack.tpcNClsCrossedRows(), casc.mXi(), casc.pt()); + registry.fill(HIST("hTPCnCrossedRowsNeg"), negTrack.tpcNClsCrossedRows(), casc.mXi(), casc.pt()); + registry.fill(HIST("hTPCnCrossedRowsBach"), bachTrack.tpcNClsCrossedRows(), casc.mXi(), casc.pt()); + registry.fill(HIST("hITSChi2Pos"), posTrack.itsChi2NCl()); + registry.fill(HIST("hITSChi2Neg"), negTrack.itsChi2NCl()); + registry.fill(HIST("hITSChi2Bach"), bachTrack.itsChi2NCl()); + registry.fill(HIST("hTPCChi2Pos"), posTrack.tpcChi2NCl()); + registry.fill(HIST("hTPCChi2Neg"), negTrack.tpcChi2NCl()); + registry.fill(HIST("hTPCChi2Bach"), bachTrack.tpcChi2NCl()); + + registry.fill(HIST("hSelectionStatus"), 0); // all the cascade before selections + // registry.fill(HIST("hMassXi0"), casc.mXi(), casc.pt()); + + // TPC N crossed rows todo: check if minTPCCrossedRows > 50 + if (posTrack.tpcNClsCrossedRows() < minTPCCrossedRows || negTrack.tpcNClsCrossedRows() < minTPCCrossedRows || bachTrack.tpcNClsCrossedRows() < minTPCCrossedRows) + return 0; + + registry.fill(HIST("hSelectionStatus"), 1); // passes nTPC crossed rows + // registry.fill(HIST("hMassXi1"), casc.mXi(), casc.pt()); + + // ITS N clusters todo: check if minITSClusters > 0 + if (posTrack.itsNCls() < minITSClusters || negTrack.itsNCls() < minITSClusters || bachTrack.itsNCls() < minITSClusters) + return 0; + + registry.fill(HIST("hSelectionStatus"), 2); // passes nITS clusters + // registry.fill(HIST("hMassXi2"), casc.mXi(), casc.pt()); + + // Chi2 cuts + if (posTrack.itsChi2NCl() > itsChi2 || negTrack.itsChi2NCl() > itsChi2 || bachTrack.itsChi2NCl() > itsChi2) + return 0; + if (posTrack.tpcChi2NCl() > tpcChi2 || negTrack.tpcChi2NCl() > tpcChi2 || bachTrack.tpcChi2NCl() > tpcChi2) + return 0; + + registry.fill(HIST("hSelectionStatus"), 3); // passes Chi2 cuts + + //// TOPO CUTS //// TODO: improve! + double pvx = collision.posX(); + double pvy = collision.posY(); + double pvz = collision.posZ(); + if (casc.v0radius() < v0setting_radius || + casc.cascradius() < cascadesetting_cascradius || + casc.v0cosPA(pvx, pvy, pvz) < v0setting_cospa || + casc.casccosPA(pvx, pvy, pvz) < cascadesetting_cospa || + casc.dcav0topv(pvx, pvy, pvz) < cascadesetting_mindcav0topv || + std::abs(casc.mLambda() - 1.115683) > cascadesetting_v0masswindow) + return 0; // It failed at least one topo selection + + registry.fill(HIST("hSelectionStatus"), 4); // passes topo + // registry.fill(HIST("hMassXi3"), casc.mXi(), casc.pt()); + + if (std::abs(posTrack.eta()) > etaTracks || std::abs(negTrack.eta()) > etaTracks || std::abs(bachTrack.eta()) > etaTracks) + return 0; + + registry.fill(HIST("hSelectionStatus"), 5); // passes track eta + + if (std::abs(casc.eta()) > etaCascades) + return 0; + + registry.fill(HIST("hSelectionStatus"), 6); // passes candidate eta + + // TODO: TOF (for pT > 2 GeV per track?) + + //// TPC PID //// + // Lambda check + if (casc.sign() < 0) { + // Proton check: + if (std::abs(posTrack.tpcNSigmaPr()) > tpcNsigmaProton) + return 0; + // Pion check: + if (std::abs(negTrack.tpcNSigmaPi()) > tpcNsigmaPion) + return 0; + } else { + // Proton check: + if (std::abs(negTrack.tpcNSigmaPr()) > tpcNsigmaProton) + return 0; + // Pion check: + if (std::abs(posTrack.tpcNSigmaPi()) > tpcNsigmaPion) + return 0; + } + registry.fill(HIST("hSelectionStatus"), 7); // passes V0 daughters PID + // registry.fill(HIST("hMassXi4"), casc.mXi(), casc.pt()); + + // setting selection flag based on bachelor PID (and competing mass cut for omega's) + int flag = 0; + if (std::abs(bachTrack.tpcNSigmaPi()) < tpcNsigmaBachelor) + flag = 1; + if (std::abs(bachTrack.tpcNSigmaKa()) < tpcNsigmaBachelor && (!doCompetingMassCut || std::abs(pdgDB->Mass(3312) - casc.mXi()) > competingMassWindow)) + flag = 3 - flag; // 3 if only consistent with omega, 2 if consistent with both + + switch (flag) { + case 1: // only Xi + registry.fill(HIST("hSelectionStatus"), 8); // passes bach PID + if (casc.sign() < 0) { + registry.fill(HIST("hMassXiMinus"), casc.mXi(), casc.pt(), casc.yXi()); + } else { + registry.fill(HIST("hMassXiPlus"), casc.mXi(), casc.pt(), casc.yXi()); + } + break; + case 2: // Xi or Omega + registry.fill(HIST("hSelectionStatus"), 8); // passes bach PID + if (casc.sign() < 0) { + registry.fill(HIST("hMassXiMinus"), casc.mXi(), casc.pt(), casc.yXi()); + registry.fill(HIST("hMassOmegaMinus"), casc.mOmega(), casc.pt(), casc.yOmega()); + } else { + registry.fill(HIST("hMassXiPlus"), casc.mXi(), casc.pt(), casc.yXi()); + registry.fill(HIST("hMassOmegaPlus"), casc.mOmega(), casc.pt(), casc.yOmega()); + } + break; + case 3: // only Omega + registry.fill(HIST("hSelectionStatus"), 8); // passes bach PID + if (casc.sign() < 0) { + registry.fill(HIST("hMassOmegaMinus"), casc.mOmega(), casc.pt(), casc.yOmega()); + } else { + registry.fill(HIST("hMassOmegaPlus"), casc.mOmega(), casc.pt(), casc.yOmega()); + } + break; + } - // ITS N clusters todo: check if minITSClusters > 0 - if (posTrack.itsNCls() < minITSClusters || negTrack.itsNCls() < minITSClusters || bachTrack.itsNCls() < minITSClusters) { - cascflags(0); + return flag; + + } // processCandidate + + void processGenMC(aod::McCollision const&, soa::SmallGroups> const& collisions, aod::McParticles const& mcParticles) + { + // N gen events without any event selection or matched reco event + registry.fill(HIST("gen/hNevents"), 0); + + for (auto const& mcPart : mcParticles) { + if (!mcPart.isPhysicalPrimary()) continue; - } - registry.fill(HIST("hSelectionStatus"), 2); // passes nITS clusters - registry.fill(HIST("hMassXi2"), casc.mXi(), casc.pt()); - - //// TOPO CUTS //// TODO: improve! - double pvx = collision.posX(); - double pvy = collision.posY(); - double pvz = collision.posZ(); - if (casc.v0radius() < v0setting_radius || - casc.cascradius() < cascadesetting_cascradius || - casc.v0cosPA(pvx, pvy, pvz) < v0setting_cospa || - casc.casccosPA(pvx, pvy, pvz) < cascadesetting_cospa || - casc.dcav0topv(pvx, pvy, pvz) < cascadesetting_mindcav0topv || - TMath::Abs(casc.mLambda() - 1.115683) > cascadesetting_v0masswindow) { - // It failed at least one topo selection - cascflags(0); + if (std::abs(mcPart.eta()) > etaCascades) continue; + + switch (mcPart.pdgCode()) { + case 3312: + registry.fill(HIST("gen/hXiMinus"), mcPart.pt(), mcPart.y()); + break; + case -3312: + registry.fill(HIST("gen/hXiPlus"), mcPart.pt(), mcPart.y()); + break; + case 3334: + registry.fill(HIST("gen/hOmegaMinus"), mcPart.pt(), mcPart.y()); + break; + case -3334: + registry.fill(HIST("gen/hOmegaPlus"), mcPart.pt(), mcPart.y()); + break; } - registry.fill(HIST("hSelectionStatus"), 3); // passes topo - registry.fill(HIST("hMassXi3"), casc.mXi(), casc.pt()); + } - if (TMath::Abs(posTrack.eta()) > etaTracks || TMath::Abs(negTrack.eta()) > etaTracks || TMath::Abs(bachTrack.eta()) > etaTracks) { - cascflags(0); - continue; + // Do the same thing, but now making sure there is at least one matched reconstructed event: + if (collisions.size() < 1) { + return; + } else { + bool evSel = false; // will be true if at least one rec. collision passes evsel + for (auto const& collision : collisions) { + // can be more than 1 rec. collisions due to event splitting + evSel = eventSelection(collision); + if (evSel) // exit loop if we find 1 rec. event that passes evsel + break; } - registry.fill(HIST("hSelectionStatus"), 4); // passes track eta + if (evSel) { + // N gen events with a reconstructed event + registry.fill(HIST("genwithrec/hNevents"), 0); - // TODO: TOF (for pT > 2 GeV per track?) + for (auto const& mcPart : mcParticles) { + if (!mcPart.isPhysicalPrimary()) + continue; + if (std::abs(mcPart.eta()) > etaCascades) + continue; - //// TPC PID //// - // Lambda check - if (casc.sign() < 0) { - // Proton check: - if (TMath::Abs(posTrack.tpcNSigmaPr()) > tpcNsigmaProton) { - cascflags(0); - continue; - } - // Pion check: - if (TMath::Abs(negTrack.tpcNSigmaPi()) > tpcNsigmaPion) { - cascflags(0); - continue; - } - } else { - // Proton check: - if (TMath::Abs(negTrack.tpcNSigmaPr()) > tpcNsigmaProton) { - cascflags(0); - continue; - } - // Pion check: - if (TMath::Abs(posTrack.tpcNSigmaPi()) > tpcNsigmaPion) { - cascflags(0); - continue; + switch (mcPart.pdgCode()) { + case 3312: + registry.fill(HIST("genwithrec/hXiMinus"), mcPart.pt(), mcPart.y()); + break; + case -3312: + registry.fill(HIST("genwithrec/hXiPlus"), mcPart.pt(), mcPart.y()); + break; + case 3334: + registry.fill(HIST("genwithrec/hOmegaMinus"), mcPart.pt(), mcPart.y()); + break; + case -3334: + registry.fill(HIST("genwithrec/hOmegaPlus"), mcPart.pt(), mcPart.y()); + break; + } } } - registry.fill(HIST("hSelectionStatus"), 5); // passes V0 daughters PID - registry.fill(HIST("hMassXi4"), casc.mXi(), casc.pt()); - - // Bachelor check - if (TMath::Abs(bachTrack.tpcNSigmaPi()) < tpcNsigmaBachelor) { - if (TMath::Abs(bachTrack.tpcNSigmaKa()) < tpcNsigmaBachelor) { - // consistent with both! - cascflags(2); - registry.fill(HIST("hSelectionStatus"), 6); // passes bach PID - registry.fill(HIST("hMassXi5"), casc.mXi(), casc.pt()); - continue; - } - cascflags(1); - registry.fill(HIST("hSelectionStatus"), 6); // passes bach PID - registry.fill(HIST("hMassXi5"), casc.mXi(), casc.pt()); + } + } // processGen + + // wrappers for data/MC processes on reco level + void processRecData(MyCollisions::iterator const& collision, aod::CascDataExt const& Cascades, FullTracksExtIUWithPID const&, aod::BCsWithTimestamps const&) + { + bool evSel = eventSelection(collision); + // do not skip the collision if event selection fails - this will lead to the cascadeFlag table having less entries than the Cascade table, and therefor not joinable. + for (auto const& casc : Cascades) { + if (!evSel) { + cascflags(0); continue; - } else if (TMath::Abs(bachTrack.tpcNSigmaKa()) < tpcNsigmaBachelor) { - cascflags(3); - registry.fill(HIST("hSelectionStatus"), 6); // passes bach PID + } + int flag = processCandidate(casc, collision); + cascflags(flag); + } + } + + void processRecMC(MyCollisions::iterator const& collision, LabeledCascades const& Cascades, FullTracksExtIUWithPID const&, aod::BCsWithTimestamps const&, aod::McParticles const&) + { + bool evSel = eventSelection(collision); + // do not skip the collision if event selection fails - this will lead to the cascadeFlag table having less entries than the Cascade table, and therefor not joinable. + for (auto const& casc : Cascades) { + if (!evSel) { + cascflags(0); continue; } - // if we reach here, the bachelor was neither pion nor kaon - cascflags(0); - } // cascade loop - } // process + int flag = processCandidate(casc, collision); + cascflags(flag); + // do mc matching here + fillMatchedHistos(casc, flag, collision); // if sign < 0 then pdg > 0 + } + } + + PROCESS_SWITCH(CascadeSelector, processRecData, "Process rec data", true); + PROCESS_SWITCH(CascadeSelector, processRecMC, "Process rec MC", false); + PROCESS_SWITCH(CascadeSelector, processGenMC, "Process gen MC", false); }; // struct struct CascadeCorrelations { @@ -332,14 +613,21 @@ struct CascadeCorrelations { Configurable doTFBorderCut{"doTFBorderCut", true, "Switch to apply TimeframeBorderCut event selection"}; Configurable doSel8{"doSel8", true, "Switch to apply sel8 event selection"}; - AxisSpec invMassAxis = {1000, 1.0f, 2.0f, "Inv. Mass (GeV/c^{2})"}; - AxisSpec deltaPhiAxis = {180, -PIHalf, 3 * PIHalf, "#Delta#varphi"}; // 180 is divisible by 18 (tpc sectors) and 20 (run 2 binning) - AxisSpec deltaYAxis = {40, -2 * maxRapidity, 2 * maxRapidity, "#Delta y"}; // TODO: narrower range? - AxisSpec ptAxis = {150, 0, 15, "#it{p}_{T}"}; - AxisSpec selectionFlagAxis = {4, -0.5f, 3.5f, "Selection flag of casc candidate"}; - AxisSpec vertexAxis = {200, -10.0f, 10.0f, "cm"}; - AxisSpec multiplicityAxis{100, 0, 100, "Multiplicity (MultFT0M?)"}; - AxisSpec rapidityAxis{100, -maxRapidity, maxRapidity, "y"}; + ConfigurableAxis radiusAxis = {"radiusAxis", {100, 0.0f, 50.0f}, "cm"}; + ConfigurableAxis cpaAxis = {"cpaAxis", {100, 0.95f, 1.0f}, "CPA"}; + ConfigurableAxis invMassAxis = {"invMassAxis", {1000, 1.0f, 2.0f}, "Inv. Mass (GeV/c^{2})"}; + ConfigurableAxis deltaPhiAxis = {"deltaPhiAxis", {180, -PIHalf, 3 * PIHalf}, "#Delta#varphi"}; // 180 is divisible by 18 (tpc sectors) and 20 (run 2 binning) + ConfigurableAxis ptAxis = {"ptAxis", {150, 0, 15}, "#it{p}_{T}"}; + ConfigurableAxis vertexAxis = {"vertexAxis", {200, -10.0f, 10.0f}, "cm"}; + ConfigurableAxis dcaAxis = {"dcaAxis", {100, 0.0f, 2.0f}, "cm"}; + ConfigurableAxis multiplicityAxis{"multiplicityAxis", {100, 0, 100}, "Multiplicity (MultFT0M?)"}; + ConfigurableAxis invLambdaMassAxis{"invLambdaMassAxis", {100, 1.07f, 1.17f}, "Inv. Mass (GeV/c^{2})"}; + AxisSpec signAxis{3, -1.5, 1.5, "sign of cascade"}; + AxisSpec deltaYAxis{40, -2.f, 2.f, "#Delta y"}; + AxisSpec rapidityAxis{100, -1.f, 1.f, "y"}; + AxisSpec selectionFlagAxis{4, -0.5f, 3.5f, "Selection flag of casc candidate"}; + AxisSpec itsClustersAxis{8, -0.5, 7.5, "number of ITS clusters"}; + AxisSpec tpcRowsAxis{160, -0.5, 159.5, "TPC crossed rows"}; // initialize efficiency maps TH1D* hEffXiMin; @@ -347,6 +635,10 @@ struct CascadeCorrelations { TH1D* hEffOmegaMin; TH1D* hEffOmegaPlus; + // used in MC closure test + Service pdgDB; + o2::pwglf::ParticleCounter mCounter; + void init(InitContext const&) { ccdb->setURL(ccdbUrl); @@ -363,12 +655,31 @@ struct CascadeCorrelations { } zorroSummary.setObject(zorro.getZorroSummary()); + + mCounter.mPdgDatabase = pdgDB.service; + mCounter.mSelectPrimaries = true; } - double getEfficiency(TH1D* h, double pT) - { // TODO: make 2D (rapidity) - // This function returns the value of histogram h corresponding to the x-coordinate pT - return h->GetBinContent(h->GetXaxis()->FindFixBin(pT)); + double getEfficiency(TH1* h, double pT, double y = 0) + { + // This function returns 1 / eff + double eff = h->GetBinContent(h->FindFixBin(pT, y)); + if (eff == 0) + return 0; + else + return 1. / eff; + } + + bool autoCorrelation(std::array triggerTracks, std::array assocTracks) + { + // function that loops over 2 arrays of track indices, checking for common elements + for (int triggerTrack : triggerTracks) { + for (int assocTrack : assocTracks) { + if (triggerTrack == assocTrack) + return true; + } + } + return false; } HistogramRegistry registry{ @@ -380,24 +691,30 @@ struct CascadeCorrelations { {"hMassOmegaMinus", "hMassOmegaMinus", {HistType::kTH2F, {invMassAxis, ptAxis}}}, {"hMassOmegaPlus", "hMassOmegaPlus", {HistType::kTH2F, {invMassAxis, ptAxis}}}, // efficiency corrected inv mass - {"hMassXiEffCorrected", "hMassXiEffCorrected", {HistType::kTHnSparseF, {invMassAxis, ptAxis, rapidityAxis, vertexAxis, multiplicityAxis}}, true}, - {"hMassOmegaEffCorrected", "hMassOmegaEffCorrected", {HistType::kTHnSparseF, {invMassAxis, ptAxis, rapidityAxis, vertexAxis, multiplicityAxis}}, true}, + {"hMassXiEffCorrected", "hMassXiEffCorrected", {HistType::kTHnSparseF, {invMassAxis, signAxis, ptAxis, rapidityAxis, vertexAxis, multiplicityAxis}}, true}, + {"hMassOmegaEffCorrected", "hMassOmegaEffCorrected", {HistType::kTHnSparseF, {invMassAxis, signAxis, ptAxis, rapidityAxis, vertexAxis, multiplicityAxis}}, true}, // trigger QA {"hTriggerQA", "hTriggerQA", {HistType::kTH1F, {{2, -0.5, 1.5, "Trigger y/n"}}}}, - // basic selection variables - {"hV0Radius", "hV0Radius", {HistType::kTH1F, {{1000, 0.0f, 100.0f, "cm"}}}}, - {"hCascRadius", "hCascRadius", {HistType::kTH1F, {{1000, 0.0f, 100.0f, "cm"}}}}, - {"hV0CosPA", "hV0CosPA", {HistType::kTH1F, {{100, 0.95f, 1.0f}}}}, - {"hCascCosPA", "hCascCosPA", {HistType::kTH1F, {{100, 0.95f, 1.0f}}}}, + // basic selection variables (after cuts) + {"hV0Radius", "hV0Radius", {HistType::kTH1F, {radiusAxis}}}, + {"hCascRadius", "hCascRadius", {HistType::kTH1F, {radiusAxis}}}, + {"hV0CosPA", "hV0CosPA", {HistType::kTH1F, {cpaAxis}}}, + {"hCascCosPA", "hCascCosPA", {HistType::kTH1F, {cpaAxis}}}, {"hDCAPosToPV", "hDCAPosToPV", {HistType::kTH1F, {vertexAxis}}}, {"hDCANegToPV", "hDCANegToPV", {HistType::kTH1F, {vertexAxis}}}, {"hDCABachToPV", "hDCABachToPV", {HistType::kTH1F, {vertexAxis}}}, {"hDCAV0ToPV", "hDCAV0ToPV", {HistType::kTH1F, {vertexAxis}}}, - {"hDCAV0Dau", "hDCAV0Dau", {HistType::kTH1F, {{100, 0.0f, 10.0f, "cm^{2}"}}}}, - {"hDCACascDau", "hDCACascDau", {HistType::kTH1F, {{100, 0.0f, 10.0f, "cm^{2}"}}}}, - {"hLambdaMass", "hLambdaMass", {HistType::kTH1F, {{500, 1.0f, 1.5f, "Inv. Mass (GeV/c^{2})"}}}}, + {"hDCAV0Dau", "hDCAV0Dau", {HistType::kTH1F, {dcaAxis}}}, + {"hDCACascDau", "hDCACascDau", {HistType::kTH1F, {dcaAxis}}}, + {"hLambdaMass", "hLambdaMass", {HistType::kTH1F, {invLambdaMassAxis}}}, + {"hTPCnCrossedRowsPos", "hTPCnCrossedRowsPos", {HistType::kTH1F, {tpcRowsAxis}}}, + {"hTPCnCrossedRowsNeg", "hTPCnCrossedRowsNeg", {HistType::kTH1F, {tpcRowsAxis}}}, + {"hTPCnCrossedRowsBach", "hTPCnCrossedRowsBach", {HistType::kTH1F, {tpcRowsAxis}}}, + {"hITSnClustersPos", "hITSnClustersPos", {HistType::kTH1F, {itsClustersAxis}}}, + {"hITSnClustersNeg", "hITSnClustersNeg", {HistType::kTH1F, {itsClustersAxis}}}, + {"hITSnClustersBach", "hITSnClustersBach", {HistType::kTH1F, {itsClustersAxis}}}, {"hSelectionFlag", "hSelectionFlag", {HistType::kTH1I, {selectionFlagAxis}}}, {"hAutoCorrelation", "hAutoCorrelation", {HistType::kTH1I, {{4, -0.5f, 3.5f, "Types of SS autocorrelation"}}}}, @@ -411,14 +728,9 @@ struct CascadeCorrelations { {"hDeltaPhiSS", "hDeltaPhiSS", {HistType::kTH1F, {deltaPhiAxis}}}, {"hDeltaPhiOS", "hDeltaPhiOS", {HistType::kTH1F, {deltaPhiAxis}}}, - {"hXiXiOS", "hXiXiOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"hXiXiSS", "hXiXiSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"hXiOmOS", "hXiOmOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"hXiOmSS", "hXiOmSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"hOmXiOS", "hOmXiOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"hOmXiSS", "hOmXiSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"hOmOmOS", "hOmOmOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"hOmOmSS", "hOmOmSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, + {"hXiXi", "hXiXi", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, signAxis, signAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, + {"hXiOm", "hXiOm", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, signAxis, signAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, + {"hOmOm", "hOmOm", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, signAxis, signAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, // Mixed events {"MixedEvents/hMEVz1", "hMEVz1", {HistType::kTH1F, {vertexAxis}}}, @@ -429,14 +741,24 @@ struct CascadeCorrelations { {"MixedEvents/hMEAutoCorrelation", "hMEAutoCorrelation", {HistType::kTH1I, {{4, -0.5f, 3.5f, "Types of SS autocorrelation"}}}}, {"MixedEvents/hMEAutoCorrelationOS", "hMEAutoCorrelationOS", {HistType::kTH1I, {{2, -1.f, 1.f, "Charge of OS autocorrelated track"}}}}, - {"MixedEvents/hMEXiXiOS", "hMEXiXiOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"MixedEvents/hMEXiXiSS", "hMEXiXiSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"MixedEvents/hMEXiOmOS", "hMEXiOmOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"MixedEvents/hMEXiOmSS", "hMEXiOmSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"MixedEvents/hMEOmXiOS", "hMEOmXiOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"MixedEvents/hMEOmXiSS", "hMEOmXiSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"MixedEvents/hMEOmOmOS", "hMEOmOmOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, - {"MixedEvents/hMEOmOmSS", "hMEOmOmSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, + {"MixedEvents/hMEXiXi", "hMEXiXi", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, signAxis, signAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, + {"MixedEvents/hMEXiOm", "hMEXiOm", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, signAxis, signAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, + {"MixedEvents/hMEOmOm", "hMEOmOm", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, signAxis, signAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, vertexAxis, multiplicityAxis}}, true}, + + // MC closure + {"MC/hMCPlusMinus", "hMCPlusMinus", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, vertexAxis, multiplicityAxis}}, true}, + {"MC/hMCPlusPlus", "hMCPlusPlus", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, vertexAxis, multiplicityAxis}}, true}, + {"MC/hMCMinusPlus", "hMCMinusPlus", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, vertexAxis, multiplicityAxis}}, true}, + {"MC/hMCMinusMinus", "hMCMinusMinus", {HistType::kTHnSparseF, {deltaPhiAxis, deltaYAxis, ptAxis, ptAxis, vertexAxis, multiplicityAxis}}, true}, + + {"MC/hGenMultNoReco", "hGenMultNoReco", {HistType::kTH1I, {{100, 0, 100, "Number of generated charged primaries"}}}}, + {"MC/hGenMultOneReco", "hGenMultOneReco", {HistType::kTH1I, {{100, 0, 100, "Number of generated charged primaries"}}}}, + {"MC/hSplitEvents", "hSplitEvents", {HistType::kTH1I, {{10, 0, 10, "Number of rec. events per gen event"}}}}, + + // debug + {"MC/hPhi", "hPhi", {HistType::kTH1F, {{180, 0, TwoPI}}}}, + {"MC/hEta", "hEta", {HistType::kTH1F, {{100, -2, 2}}}}, + {"MC/hRapidity", "hRapidity", {HistType::kTH1F, {{100, -2, 2}}}}, }, }; @@ -451,9 +773,8 @@ struct CascadeCorrelations { // BinningType colBinning{{axisVtxZ, axisMult}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. using BinningType = ColumnBinningPolicy; BinningType colBinning{{axisVtxZ}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. - SameKindPair pair{colBinning, nMixedEvents, -1, &cache}; - void processSameEvent(MyCollisionsMult::iterator const& collision, MyCascades const& Cascades, aod::V0sLinked const&, aod::V0Datas const&, FullTracksExtIU const&, aod::BCsWithTimestamps const&) + void processSameEvent(MyCollisionsMult::iterator const& collision, MyCascades const& Cascades, FullTracksExtIU const&, aod::BCsWithTimestamps const&) { if (useTrigger) { auto bc = collision.bc_as(); @@ -467,34 +788,30 @@ struct CascadeCorrelations { } } - if ((doSel8 && !collision.sel8()) || (doTFBorderCut && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { - return; - } - double weight; // Some QA on the cascades for (auto const& casc : Cascades) { if (casc.isSelected() <= 2) { // not exclusively an Omega --> consistent with Xi or both if (casc.sign() < 0) { registry.fill(HIST("hMassXiMinus"), casc.mXi(), casc.pt()); - weight = 1. / getEfficiency(hEffXiMin, casc.pt()); + weight = getEfficiency(hEffXiMin, casc.pt()); } else { registry.fill(HIST("hMassXiPlus"), casc.mXi(), casc.pt()); - weight = 1. / getEfficiency(hEffXiPlus, casc.pt()); + weight = getEfficiency(hEffXiPlus, casc.pt()); } // LOGF(info, "casc pt %f, weight %f", casc.pt(), weight); - registry.fill(HIST("hMassXiEffCorrected"), casc.mXi(), casc.pt(), casc.yXi(), collision.posZ(), collision.multFT0M(), weight); + registry.fill(HIST("hMassXiEffCorrected"), casc.mXi(), casc.sign(), casc.pt(), casc.yXi(), collision.posZ(), collision.multFT0M(), weight); registry.fill(HIST("hRapidityXi"), casc.yXi()); } if (casc.isSelected() >= 2) { // consistent with Omega or both if (casc.sign() < 0) { registry.fill(HIST("hMassOmegaMinus"), casc.mOmega(), casc.pt()); - weight = 1. / getEfficiency(hEffOmegaMin, casc.pt()); + weight = getEfficiency(hEffOmegaMin, casc.pt()); } else { registry.fill(HIST("hMassOmegaPlus"), casc.mOmega(), casc.pt()); - weight = 1. / getEfficiency(hEffOmegaPlus, casc.pt()); + weight = getEfficiency(hEffOmegaPlus, casc.pt()); } - registry.fill(HIST("hMassOmegaEffCorrected"), casc.mOmega(), casc.pt(), casc.yOmega(), collision.posZ(), collision.multFT0M(), weight); + registry.fill(HIST("hMassOmegaEffCorrected"), casc.mOmega(), casc.sign(), casc.pt(), casc.yOmega(), collision.posZ(), collision.multFT0M(), weight); registry.fill(HIST("hRapidityOmega"), casc.yOmega()); } registry.fill(HIST("hV0Radius"), casc.v0radius()); @@ -508,6 +825,12 @@ struct CascadeCorrelations { registry.fill(HIST("hDCAV0Dau"), casc.dcaV0daughters()); registry.fill(HIST("hDCACascDau"), casc.dcacascdaughters()); registry.fill(HIST("hLambdaMass"), casc.mLambda()); + registry.fill(HIST("hITSnClustersPos"), casc.posTrack_as().itsNCls()); + registry.fill(HIST("hITSnClustersNeg"), casc.negTrack_as().itsNCls()); + registry.fill(HIST("hITSnClustersBach"), casc.bachelor_as().itsNCls()); + registry.fill(HIST("hTPCnCrossedRowsPos"), casc.posTrack_as().tpcNClsCrossedRows()); + registry.fill(HIST("hTPCnCrossedRowsNeg"), casc.negTrack_as().tpcNClsCrossedRows()); + registry.fill(HIST("hTPCnCrossedRowsBach"), casc.bachelor_as().tpcNClsCrossedRows()); registry.fill(HIST("hSelectionFlag"), casc.isSelected()); registry.fill(HIST("hPhi"), casc.phi()); @@ -524,12 +847,11 @@ struct CascadeCorrelations { auto trigger = *triggerAddress; auto assoc = *assocAddress; - // track indices for posterior checks - // retains logic of V0 index while being safe wrt data model - int posIdTrigg = trigger.posTrackId(); - int negIdTrigg = trigger.negTrackId(); - int posIdAssoc = assoc.posTrackId(); - int negIdAssoc = assoc.negTrackId(); + // autocorrelation check + std::array triggerTracks = {trigger.posTrackId(), trigger.negTrackId(), trigger.bachelorId()}; + std::array assocTracks = {assoc.posTrackId(), assoc.negTrackId(), assoc.bachelorId()}; + if (autoCorrelation(triggerTracks, assocTracks)) + continue; // calculate angular correlations double dphi = RecoDecay::constrainAngle(trigger.phi() - assoc.phi(), -PIHalf); @@ -542,144 +864,59 @@ struct CascadeCorrelations { double weightTrigg = 1.; double weightAssoc = 1.; - // split into opposite-sign or same-sign - if (trigger.sign() * assoc.sign() < 0) { // opposite-sign - // check for autocorrelations between mis-identified kaons (omega bach) and protons (lambda daughter) TODO: improve logic? - if (trigger.isSelected() >= 2) { - if (trigger.sign() > 0 && trigger.bachelorId() == posIdAssoc) { - // K+ from trigger Omega is the same as proton from assoc lambda - registry.fill(HIST("hAutoCorrelationOS"), 1); - continue; - } - if (trigger.sign() < 0 && trigger.bachelorId() == negIdAssoc) { - // K- from trigger Omega is the same as antiproton from assoc antilambda - registry.fill(HIST("hAutoCorrelationOS"), -1); - continue; - } - } - if (assoc.isSelected() >= 2) { - if (assoc.sign() > 0 && assoc.bachelorId() == posIdTrigg) { - // K+ from assoc Omega is the same as proton from trigger lambda - registry.fill(HIST("hAutoCorrelationOS"), 1); - continue; - } - if (assoc.sign() < 0 && assoc.bachelorId() == negIdTrigg) { - // K- from assoc Omega is the same as antiproton from trigger antilambda - registry.fill(HIST("hAutoCorrelationOS"), -1); - continue; - } - } - registry.fill(HIST("hDeltaPhiOS"), dphi); - // Fill the different THnSparses depending on PID logic (important for rapidity & inv mass information) - if (trigger.isSelected() <= 2 && TMath::Abs(trigger.yXi()) < maxRapidity) { // trigger Xi + if (trigger.isSelected() <= 2 && std::abs(trigger.yXi()) < maxRapidity) { // trigger Xi + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? getEfficiency(hEffXiMin, trigger.pt()) : getEfficiency(hEffXiPlus, trigger.pt()); + if (assoc.isSelected() <= 2 && std::abs(assoc.yXi()) < maxRapidity) { // assoc Xi if (doEfficiencyCorrection) - weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffXiMin, trigger.pt()) : 1. / getEfficiency(hEffXiPlus, trigger.pt()); - if (assoc.isSelected() <= 2 && TMath::Abs(assoc.yXi()) < maxRapidity) { // assoc Xi - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffXiMin, assoc.pt()) : 1. / getEfficiency(hEffXiPlus, assoc.pt()); - registry.fill(HIST("hXiXiOS"), dphi, trigger.yXi() - assoc.yXi(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); - } - if (assoc.isSelected() >= 2 && TMath::Abs(assoc.yOmega()) < maxRapidity) { // assoc Omega - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, assoc.pt()) : 1. / getEfficiency(hEffOmegaPlus, assoc.pt()); - registry.fill(HIST("hXiOmOS"), dphi, trigger.yXi() - assoc.yOmega(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); - } + weightAssoc = assoc.sign() < 0 ? getEfficiency(hEffXiMin, assoc.pt()) : getEfficiency(hEffXiPlus, assoc.pt()); + registry.fill(HIST("hXiXi"), dphi, trigger.yXi() - assoc.yXi(), trigger.sign(), assoc.sign(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); } - if (trigger.isSelected() >= 2 && TMath::Abs(trigger.yOmega()) < maxRapidity) { // trigger Omega + if (assoc.isSelected() >= 2 && std::abs(assoc.yOmega()) < maxRapidity) { // assoc Omega if (doEfficiencyCorrection) - weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, trigger.pt()) : 1. / getEfficiency(hEffOmegaPlus, trigger.pt()); - if (assoc.isSelected() <= 2 && TMath::Abs(assoc.yXi()) < maxRapidity) { // assoc Xi - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffXiMin, assoc.pt()) : 1. / getEfficiency(hEffXiPlus, assoc.pt()); - registry.fill(HIST("hOmXiOS"), dphi, trigger.yOmega() - assoc.yXi(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassXiAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); - } - if (assoc.isSelected() >= 2 && TMath::Abs(assoc.yOmega()) < maxRapidity) { // assoc Omega - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, assoc.pt()) : 1. / getEfficiency(hEffOmegaPlus, assoc.pt()); - registry.fill(HIST("hOmOmOS"), dphi, trigger.yOmega() - assoc.yOmega(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); - } - } - } else { // same-sign - // make sure to check for autocorrelations - only possible in same-sign correlations (if PID is correct) - if (posIdTrigg == posIdAssoc && negIdTrigg == negIdAssoc) { - // LOGF(info, "same v0 in SS correlation! %d %d", v0dataTrigg.v0Id(), v0dataAssoc.v0Id()); - registry.fill(HIST("hAutoCorrelation"), 0); - continue; - } - int bachIdTrigg = trigger.bachelorId(); - int bachIdAssoc = assoc.bachelorId(); - - if (bachIdTrigg == bachIdAssoc) { - // LOGF(info, "same bachelor in SS correlation! %d %d", bachIdTrigg, bachIdAssoc); - registry.fill(HIST("hAutoCorrelation"), 1); - continue; - } - // check for same tracks in v0's of cascades - if (negIdTrigg == negIdAssoc || posIdTrigg == posIdAssoc) { - // LOGF(info, "cascades have a v0-track in common in SS correlation!"); - registry.fill(HIST("hAutoCorrelation"), 2); - continue; + weightAssoc = assoc.sign() < 0 ? getEfficiency(hEffOmegaMin, assoc.pt()) : getEfficiency(hEffOmegaPlus, assoc.pt()); + registry.fill(HIST("hXiOm"), dphi, trigger.yXi() - assoc.yOmega(), trigger.sign(), assoc.sign(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); } - if (trigger.sign() < 0) { // neg cascade - if (negIdTrigg == bachIdAssoc || negIdAssoc == bachIdTrigg) { - // LOGF(info, "bach of casc == v0-pion of other casc in neg SS correlation!"); - registry.fill(HIST("hAutoCorrelation"), 3); - continue; - } - } else { // pos cascade - if (posIdTrigg == bachIdAssoc || posIdAssoc == bachIdTrigg) { - // LOGF(info, "bach of casc == v0-pion of other casc in pos SS correlation!"); - registry.fill(HIST("hAutoCorrelation"), 3); - continue; - } - } - registry.fill(HIST("hDeltaPhiSS"), dphi); - // Fill the different THnSparses depending on PID logic (important for rapidity & inv mass information) - if (trigger.isSelected() <= 2 && TMath::Abs(trigger.yXi()) < maxRapidity) { // trigger Xi + } + if (trigger.isSelected() >= 2 && std::abs(trigger.yOmega()) < maxRapidity) { // trigger Omega + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? getEfficiency(hEffOmegaMin, trigger.pt()) : getEfficiency(hEffOmegaPlus, trigger.pt()); + if (assoc.isSelected() <= 2 && std::abs(assoc.yXi()) < maxRapidity) { // assoc Xi if (doEfficiencyCorrection) - weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffXiMin, trigger.pt()) : 1. / getEfficiency(hEffXiPlus, trigger.pt()); - if (assoc.isSelected() <= 2 && TMath::Abs(assoc.yXi()) < maxRapidity) { // assoc Xi - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffXiMin, assoc.pt()) : 1. / getEfficiency(hEffXiPlus, assoc.pt()); - registry.fill(HIST("hXiXiSS"), dphi, trigger.yXi() - assoc.yXi(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); - } - if (assoc.isSelected() >= 2 && TMath::Abs(assoc.yOmega()) < maxRapidity) { // assoc Omega - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, assoc.pt()) : 1. / getEfficiency(hEffOmegaPlus, assoc.pt()); - registry.fill(HIST("hXiOmSS"), dphi, trigger.yXi() - assoc.yOmega(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); - } + weightAssoc = assoc.sign() < 0 ? getEfficiency(hEffXiMin, assoc.pt()) : getEfficiency(hEffXiPlus, assoc.pt()); + // if Omega-Xi, fill the Xi-Omega histogram (flip the trigger/assoc and dphy,dy signs) + registry.fill(HIST("hXiOm"), RecoDecay::constrainAngle(assoc.phi() - trigger.phi(), -PIHalf), -(trigger.yOmega() - assoc.yXi()), assoc.sign(), trigger.sign(), assoc.pt(), trigger.pt(), invMassXiAssoc, invMassOmTrigg, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); } - if (trigger.isSelected() >= 2 && TMath::Abs(trigger.yOmega()) < maxRapidity) { // trigger Omega + if (assoc.isSelected() >= 2 && std::abs(assoc.yOmega()) < maxRapidity) { // assoc Omega if (doEfficiencyCorrection) - weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, trigger.pt()) : 1. / getEfficiency(hEffOmegaPlus, trigger.pt()); - if (assoc.isSelected() <= 2 && TMath::Abs(assoc.yXi()) < maxRapidity) { // assoc Xi - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffXiMin, assoc.pt()) : 1. / getEfficiency(hEffXiPlus, assoc.pt()); - registry.fill(HIST("hOmXiSS"), dphi, trigger.yOmega() - assoc.yXi(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassXiAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); - } - if (assoc.isSelected() >= 2 && TMath::Abs(assoc.yOmega()) < maxRapidity) { // assoc Omega - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, assoc.pt()) : 1. / getEfficiency(hEffOmegaPlus, assoc.pt()); - registry.fill(HIST("hOmOmSS"), dphi, trigger.yOmega() - assoc.yOmega(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); - } + weightAssoc = assoc.sign() < 0 ? getEfficiency(hEffOmegaMin, assoc.pt()) : getEfficiency(hEffOmegaPlus, assoc.pt()); + registry.fill(HIST("hOmOm"), dphi, trigger.yOmega() - assoc.yOmega(), trigger.sign(), assoc.sign(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, collision.posZ(), collision.multFT0M(), weightTrigg * weightAssoc); } } + + // QA plots + if (trigger.sign() * assoc.sign() < 0) { + registry.fill(HIST("hDeltaPhiOS"), dphi); + } else { + registry.fill(HIST("hDeltaPhiSS"), dphi); + } } // correlations - } // process same event + } // process same event - void processMixedEvent(MyCollisionsMult const& /*collisions*/, MyCascades const& /*Cascades*/, - aod::V0sLinked const&, aod::V0Datas const&, FullTracksExtIU const&) + void processMixedEvent(MyCollisionsMult const& collisions, MyCascades const& Cascades, FullTracksExtIU const&) { + auto cascadesTuple = std::make_tuple(Cascades); + SameKindPair pair{colBinning, nMixedEvents, -1, collisions, cascadesTuple, &cache}; + for (auto const& [col1, cascades1, col2, cascades2] : pair) { if (!col1.sel8() || !col2.sel8()) continue; - if (TMath::Abs(col1.posZ()) > zVertexCut || TMath::Abs(col2.posZ()) > zVertexCut) + if (std::abs(col1.posZ()) > zVertexCut || std::abs(col2.posZ()) > zVertexCut) continue; if (col1.globalIndex() == col2.globalIndex()) { registry.fill(HIST("hMEQA"), 0.5); continue; } - registry.fill(HIST("MixedEvents/hMEVz1"), col1.posZ()); registry.fill(HIST("MixedEvents/hMEVz2"), col2.posZ()); @@ -698,6 +935,11 @@ struct CascadeCorrelations { continue; } + std::array triggerTracks = {trigger.posTrackId(), trigger.negTrackId(), trigger.bachelorId()}; + std::array assocTracks = {assoc.posTrackId(), assoc.negTrackId(), assoc.bachelorId()}; + if (autoCorrelation(triggerTracks, assocTracks)) + continue; + double dphi = RecoDecay::constrainAngle(trigger.phi() - assoc.phi(), -PIHalf); double invMassXiTrigg = trigger.mXi(); @@ -705,146 +947,118 @@ struct CascadeCorrelations { double invMassXiAssoc = assoc.mXi(); double invMassOmAssoc = assoc.mOmega(); - // V0 daughter track ID's used for autocorrelation check - int posIdTrigg = trigger.posTrackId(); - int negIdTrigg = trigger.negTrackId(); - int posIdAssoc = assoc.posTrackId(); - int negIdAssoc = assoc.negTrackId(); - double weightTrigg = 1.; double weightAssoc = 1.; - if (trigger.sign() * assoc.sign() < 0) { // opposite-sign - - // check for autocorrelations between mis-identified kaons (omega bach) and protons (lambda daughter) TODO: improve logic? - if (trigger.isSelected() >= 2) { - if (trigger.sign() > 0 && trigger.bachelorId() == posIdAssoc) { - // K+ from trigger Omega is the same as proton from assoc lambda - registry.fill(HIST("MixedEvents/hMEAutoCorrelationOS"), 1); - continue; - } - if (trigger.sign() < 0 && trigger.bachelorId() == negIdAssoc) { - // K- from trigger Omega is the same as antiproton from assoc antilambda - registry.fill(HIST("MixedEvents/hMEAutoCorrelationOS"), -1); - continue; - } - } - if (assoc.isSelected() >= 2) { - if (assoc.sign() > 0 && assoc.bachelorId() == posIdTrigg) { - // K+ from assoc Omega is the same as proton from trigger lambda - registry.fill(HIST("MixedEvents/hMEAutoCorrelationOS"), 1); - continue; - } - if (assoc.sign() < 0 && assoc.bachelorId() == negIdTrigg) { - // K- from assoc Omega is the same as antiproton from trigger antilambda - registry.fill(HIST("MixedEvents/hMEAutoCorrelationOS"), -1); - continue; - } - } - - registry.fill(HIST("MixedEvents/hMEDeltaPhiOS"), dphi); - - // Fill the different THnSparses depending on PID logic (important for rapidity & inv mass information) - if (trigger.isSelected() <= 2 && TMath::Abs(trigger.yXi()) < maxRapidity) { // trigger Xi + if (trigger.isSelected() <= 2 && std::abs(trigger.yXi()) < maxRapidity) { // trigger Xi + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? getEfficiency(hEffXiMin, trigger.pt()) : getEfficiency(hEffXiPlus, trigger.pt()); + if (assoc.isSelected() <= 2 && std::abs(assoc.yXi()) < maxRapidity) { // assoc Xi if (doEfficiencyCorrection) - weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffXiMin, trigger.pt()) : 1. / getEfficiency(hEffXiPlus, trigger.pt()); - if (assoc.isSelected() <= 2 && TMath::Abs(assoc.yXi()) < maxRapidity) { // assoc Xi - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffXiMin, assoc.pt()) : 1. / getEfficiency(hEffXiPlus, assoc.pt()); - registry.fill(HIST("MixedEvents/hMEXiXiOS"), dphi, trigger.yXi() - assoc.yXi(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); - } - if (assoc.isSelected() >= 2 && TMath::Abs(assoc.yOmega()) < maxRapidity) { // assoc Omega - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, assoc.pt()) : 1. / getEfficiency(hEffOmegaPlus, assoc.pt()); - registry.fill(HIST("MixedEvents/hMEXiOmOS"), dphi, trigger.yXi() - assoc.yOmega(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); - } + weightAssoc = assoc.sign() < 0 ? getEfficiency(hEffXiMin, assoc.pt()) : getEfficiency(hEffXiPlus, assoc.pt()); + registry.fill(HIST("MixedEvents/hMEXiXi"), dphi, trigger.yXi() - assoc.yXi(), trigger.sign(), assoc.sign(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); } - if (trigger.isSelected() >= 2 && TMath::Abs(trigger.yOmega()) < maxRapidity) { // trigger Omega + if (assoc.isSelected() >= 2 && std::abs(assoc.yOmega()) < maxRapidity) { // assoc Omega if (doEfficiencyCorrection) - weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, trigger.pt()) : 1. / getEfficiency(hEffOmegaPlus, trigger.pt()); - if (assoc.isSelected() <= 2 && TMath::Abs(assoc.yXi()) < maxRapidity) { // assoc Xi - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffXiMin, assoc.pt()) : 1. / getEfficiency(hEffXiPlus, assoc.pt()); - registry.fill(HIST("MixedEvents/hMEOmXiOS"), dphi, trigger.yOmega() - assoc.yXi(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassXiAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); - } - if (assoc.isSelected() >= 2 && TMath::Abs(assoc.yOmega()) < maxRapidity) { // assoc Omega - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, assoc.pt()) : 1. / getEfficiency(hEffOmegaPlus, assoc.pt()); - registry.fill(HIST("MixedEvents/hMEOmOmOS"), dphi, trigger.yOmega() - assoc.yOmega(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); - } - } - } else { // same sign - // make sure to check for autocorrelations - only possible in same-sign correlations (if PID is correct) - if (posIdTrigg == posIdAssoc && negIdTrigg == negIdAssoc) { - // LOGF(info, "same v0 in SS correlation! %d %d", v0dataTrigg.v0Id(), v0dataAssoc.v0Id()); - registry.fill(HIST("MixedEvents/hMEAutoCorrelation"), 0); - continue; - } - int bachIdTrigg = trigger.bachelorId(); - int bachIdAssoc = assoc.bachelorId(); - - if (bachIdTrigg == bachIdAssoc) { - // LOGF(info, "same bachelor in SS correlation! %d %d", bachIdTrigg, bachIdAssoc); - registry.fill(HIST("MixedEvents/hMEAutoCorrelation"), 1); - continue; + weightAssoc = assoc.sign() < 0 ? getEfficiency(hEffOmegaMin, assoc.pt()) : getEfficiency(hEffOmegaPlus, assoc.pt()); + registry.fill(HIST("MixedEvents/hMEXiOm"), dphi, trigger.yXi() - assoc.yOmega(), trigger.sign(), assoc.sign(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); } - // check for same tracks in v0's of cascades - if (negIdTrigg == negIdAssoc || posIdTrigg == posIdAssoc) { - // LOGF(info, "cascades have a v0-track in common in SS correlation!"); - registry.fill(HIST("MixedEvents/hMEAutoCorrelation"), 2); - continue; - } - if (trigger.sign() < 0) { // neg cascade - if (negIdTrigg == bachIdAssoc || negIdAssoc == bachIdTrigg) { - // LOGF(info, "bach of casc == v0-pion of other casc in neg SS correlation!"); - registry.fill(HIST("MixedEvents/hMEAutoCorrelation"), 3); - continue; - } - } else { // pos cascade - if (posIdTrigg == bachIdAssoc || posIdAssoc == bachIdTrigg) { - // LOGF(info, "bach of casc == v0-pion of other casc in pos SS correlation!"); - registry.fill(HIST("MixedEvents/hMEAutoCorrelation"), 3); - continue; - } - } - - registry.fill(HIST("MixedEvents/hMEDeltaPhiSS"), dphi); - - if (trigger.isSelected() <= 2 && TMath::Abs(trigger.yXi()) < maxRapidity) { // trigger Xi + } + if (trigger.isSelected() >= 2 && std::abs(trigger.yOmega()) < maxRapidity) { // trigger Omega + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? getEfficiency(hEffOmegaMin, trigger.pt()) : getEfficiency(hEffOmegaPlus, trigger.pt()); + if (assoc.isSelected() <= 2 && std::abs(assoc.yXi()) < maxRapidity) { // assoc Xi if (doEfficiencyCorrection) - weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffXiMin, trigger.pt()) : 1. / getEfficiency(hEffXiPlus, trigger.pt()); - if (assoc.isSelected() <= 2 && TMath::Abs(assoc.yXi()) < maxRapidity) { // assoc Xi - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffXiMin, assoc.pt()) : 1. / getEfficiency(hEffXiPlus, assoc.pt()); - registry.fill(HIST("MixedEvents/hMEXiXiSS"), dphi, trigger.yXi() - assoc.yXi(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); - } - if (assoc.isSelected() >= 2 && TMath::Abs(assoc.yOmega()) < maxRapidity) { // assoc Omega - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, assoc.pt()) : 1. / getEfficiency(hEffOmegaPlus, assoc.pt()); - registry.fill(HIST("MixedEvents/hMEXiOmSS"), dphi, trigger.yXi() - assoc.yOmega(), trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); - } + weightAssoc = assoc.sign() < 0 ? getEfficiency(hEffXiMin, assoc.pt()) : getEfficiency(hEffXiPlus, assoc.pt()); + // if Omega-Xi, fill the Xi-Omega histogram (flip the trigger/assoc and dphy,dy signs) + registry.fill(HIST("MixedEvents/hMEXiOm"), RecoDecay::constrainAngle(assoc.phi() - trigger.phi(), -PIHalf), -(trigger.yOmega() - assoc.yXi()), assoc.sign(), trigger.sign(), assoc.pt(), trigger.pt(), invMassXiAssoc, invMassOmTrigg, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); } - if (trigger.isSelected() >= 2 && TMath::Abs(trigger.yOmega()) < maxRapidity) { // trigger Omega + if (assoc.isSelected() >= 2 && std::abs(assoc.yOmega()) < maxRapidity) { // assoc Omega if (doEfficiencyCorrection) - weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, trigger.pt()) : 1. / getEfficiency(hEffOmegaPlus, trigger.pt()); - if (assoc.isSelected() <= 2 && TMath::Abs(assoc.yXi()) < maxRapidity) { // assoc Xi - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffXiMin, assoc.pt()) : 1. / getEfficiency(hEffXiPlus, assoc.pt()); - registry.fill(HIST("MixedEvents/hMEOmXiSS"), dphi, trigger.yOmega() - assoc.yXi(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassXiAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); - } - if (assoc.isSelected() >= 2 && TMath::Abs(assoc.yOmega()) < maxRapidity) { // assoc Omega - if (doEfficiencyCorrection) - weightAssoc = assoc.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, assoc.pt()) : 1. / getEfficiency(hEffOmegaPlus, assoc.pt()); - registry.fill(HIST("MixedEvents/hMEOmOmSS"), dphi, trigger.yOmega() - assoc.yOmega(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); - } + weightAssoc = assoc.sign() < 0 ? getEfficiency(hEffOmegaMin, assoc.pt()) : getEfficiency(hEffOmegaPlus, assoc.pt()); + registry.fill(HIST("MixedEvents/hMEOmOm"), dphi, trigger.yOmega() - assoc.yOmega(), trigger.sign(), assoc.sign(), trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, col1.posZ(), col1.multFT0M(), weightTrigg * weightAssoc); } - } // same sign + } + + // QA plots + if (trigger.sign() * assoc.sign() < 0) { + registry.fill(HIST("MixedEvents/hMEDeltaPhiOS"), dphi); + } else { + registry.fill(HIST("MixedEvents/hMEDeltaPhiSS"), dphi); + } } // correlations } // collisions } // process mixed events + Configurable etaGenCascades{"etaGenCascades", 0.8, "min/max of eta for generated cascades"}; + Filter genCascadesFilter = nabs(aod::mcparticle::pdgCode) == 3312; + + void processMC(aod::McCollision const&, soa::SmallGroups> const& collisions, soa::Filtered const& genCascades, aod::McParticles const& mcParticles) + { + // Let's do some logic on matched reconstructed collisions - if there less or more than one, fill some QA and skip the rest + double FT0mult = -1; // non-sensible default value just in case + double vtxz = -999.; // non-sensible default value just in case + if (collisions.size() < 1) { + registry.fill(HIST("MC/hSplitEvents"), 0); + registry.fill(HIST("MC/hGenMultNoReco"), mCounter.countFT0A(mcParticles) + mCounter.countFT0C(mcParticles)); + return; + } else if (collisions.size() == 1) { + registry.fill(HIST("MC/hSplitEvents"), 1); + registry.fill(HIST("MC/hGenMultOneReco"), mCounter.countFT0A(mcParticles) + mCounter.countFT0C(mcParticles)); + for (auto const& collision : collisions) { // not really a loop, as there is only one collision + FT0mult = collision.multFT0M(); + vtxz = collision.posZ(); + } + } else if (collisions.size() > 1) { + registry.fill(HIST("MC/hSplitEvents"), collisions.size()); + return; + } + + // QA + for (auto& casc : genCascades) { + if (!casc.isPhysicalPrimary()) + continue; + registry.fill(HIST("MC/hPhi"), casc.phi()); + registry.fill(HIST("MC/hEta"), casc.eta()); + registry.fill(HIST("MC/hRapidity"), casc.y()); + } + + for (auto& [c0, c1] : combinations(genCascades, genCascades)) { // combinations automatically applies strictly upper in case of 2 identical tables + // Define the trigger as the particle with the highest pT. As we can't swap the cascade tables themselves, we swap the addresses and later dereference them + auto* triggerAddress = &c0; + auto* assocAddress = &c1; + if (assocAddress->pt() > triggerAddress->pt()) { + std::swap(triggerAddress, assocAddress); + } + auto trigger = *triggerAddress; + auto assoc = *assocAddress; + + if (!trigger.isPhysicalPrimary() || !assoc.isPhysicalPrimary()) + continue; // require the cascades to be primaries + if (std::abs(trigger.eta()) > etaGenCascades) + continue; // only apply eta cut to trigger - trigger normalization still valid without introducing 2-particle-acceptance effects + + double dphi = RecoDecay::constrainAngle(trigger.phi() - assoc.phi(), -PIHalf); + + if (trigger.pdgCode() < 0) { // anti-trigg --> Plus + if (assoc.pdgCode() < 0) { // anti-assoc --> Plus + registry.fill(HIST("MC/hMCPlusPlus"), dphi, trigger.y() - assoc.y(), trigger.pt(), assoc.pt(), vtxz, FT0mult); + } else { // assoc --> Minus + registry.fill(HIST("MC/hMCPlusMinus"), dphi, trigger.y() - assoc.y(), trigger.pt(), assoc.pt(), vtxz, FT0mult); + } + } else { // trig --> Minus + if (assoc.pdgCode() < 0) { // anti-assoc --> Plus + registry.fill(HIST("MC/hMCMinusPlus"), dphi, trigger.y() - assoc.y(), trigger.pt(), assoc.pt(), vtxz, FT0mult); + } else { + registry.fill(HIST("MC/hMCMinusMinus"), dphi, trigger.y() - assoc.y(), trigger.pt(), assoc.pt(), vtxz, FT0mult); + } + } + } + } + PROCESS_SWITCH(CascadeCorrelations, processSameEvent, "Process same events", true); PROCESS_SWITCH(CascadeCorrelations, processMixedEvent, "Process mixed events", true); + PROCESS_SWITCH(CascadeCorrelations, processMC, "Process MC", false); }; // struct diff --git a/PWGLF/Tasks/Strangeness/cascpolsp.cxx b/PWGLF/Tasks/Strangeness/cascpolsp.cxx new file mode 100644 index 00000000000..237fe8ba375 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/cascpolsp.cxx @@ -0,0 +1,462 @@ +// 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. +// Cascade polarisation task +// prottay.das@cern.ch + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "TRandom3.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "Math/GenVector/Boost.h" +#include "TF1.h" + +#include "PWGLF/DataModel/SPCalibrationTables.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/trackUtilities.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/TrackSelection.h" +#include "Framework/ASoAHelpers.h" +#include "ReconstructionDataFormats/Track.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/BasicCCDBManager.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "Common/DataModel/FT0Corrected.h" +#include "PWGLF/DataModel/cascqaanalysis.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; + +using dauTracks = soa::Join; +using v0Candidates = soa::Join; + +struct cascpolsp { + + Service ccdb; + Service pdg; + + // fill output + Configurable additionalEvSel{"additionalEvSel", false, "additionalEvSel"}; + Configurable additionalEvSel3{"additionalEvSel3", false, "additionalEvSel3"}; + Configurable QxyNbins{"QxyNbins", 100, "Number of bins in QxQy histograms"}; + Configurable lbinQxy{"lbinQxy", -5.0, "lower bin value in QxQy histograms"}; + Configurable hbinQxy{"hbinQxy", 5.0, "higher bin value in QxQy histograms"}; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutCentralityMax{"cfgCutCentralityMax", 50.0f, "Accepted maximum Centrality"}; + Configurable cfgCutCentralityMin{"cfgCutCentralityMin", 30.0f, "Accepted minimum Centrality"}; + // track cut + Configurable cfgCutPT{"cfgCutPT", 0.15, "PT cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + + // Configs for V0 + Configurable ConfV0PtMin{"ConfV0PtMin", 0.f, "Minimum transverse momentum of V0"}; + Configurable ConfV0Rap{"ConfV0Rap", 0.8f, "Rapidity range of V0"}; + Configurable ConfV0DCADaughMax{"ConfV0DCADaughMax", 0.2f, "Maximum DCA between the V0 daughters"}; + Configurable ConfV0CPAMin{"ConfV0CPAMin", 0.9998f, "Minimum CPA of V0"}; + Configurable ConfV0TranRadV0Min{"ConfV0TranRadV0Min", 1.5f, "Minimum transverse radius"}; + Configurable ConfV0TranRadV0Max{"ConfV0TranRadV0Max", 100.f, "Maximum transverse radius"}; + Configurable cMaxV0DCA{"cMaxV0DCA", 1.2, "Maximum V0 DCA to PV"}; + Configurable cMinV0DCA{"cMinV0DCA", 0.05, "Minimum V0 daughters DCA to PV"}; + Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 20, "Maximum V0 life time"}; + + // config for V0 daughters + Configurable ConfDaughEta{"ConfDaughEta", 0.8f, "V0 Daugh sel: max eta"}; + Configurable cfgDaughPrPt{"cfgDaughPrPt", 0.4, "minimum daughter proton pt"}; + Configurable cfgDaughPiPt{"cfgDaughPiPt", 0.2, "minimum daughter pion pt"}; + Configurable ConfDaughTPCnclsMin{"ConfDaughTPCnclsMin", 50.f, "V0 Daugh sel: Min. nCls TPC"}; + Configurable ConfDaughDCAMin{"ConfDaughDCAMin", 0.08f, "V0 Daugh sel: Max. DCA Daugh to PV (cm)"}; + Configurable ConfDaughPIDCuts{"ConfDaughPIDCuts", 3, "PID selections for Lambda daughters"}; + + // config for cascades + Configurable cfgcasc_radius{"cfgcasc_radius", 0.8f, "Cascade radius"}; + Configurable cfgcasc_casccospa{"cfgcasc_casccospa", 0.99f, "Cascade cosPA"}; + Configurable cfgcasc_v0cospa{"cfgcasc_v0cospa", 0.99f, "Cascade v0cosPA"}; + Configurable cfgcasc_dcav0topv{"cfgcasc_dcav0topv", 0.3f, "Cascade dcav0"}; + Configurable cfgcasc_dcabachtopv{"cfgcasc_dcabachtopv", 0.3f, "Cascade dcabach"}; + Configurable cfgcasc_dcacascdau{"cfgcasc_dcacascdau", 0.3f, "Cascade dcadau"}; + Configurable cfgcasc_dcav0dau{"cfgcasc_dcav0dau", 0.3f, "Cascade dcav0dau"}; + Configurable cfgcasc_mlambdawindow{"cfgcasc_mlambdawindow", 0.43f, "Cascade masswindow"}; + Configurable cfgcascv0_radius{"cfgcascv0_radius", 0.8f, "Cascade v0 radius"}; + Configurable cfgcasc_dcapostopv{"cfgcasc_dcapostopv", 0.3f, "Cascade dcapostoPV"}; + Configurable cfgcasc_dcanegtopv{"cfgcasc_dcanegtopv", 0.3f, "Cascade dcanegtoPV"}; + Configurable cfgcasc_lowmass{"cfgcasc_lowmass", 1.311, "Cascade lowmass cut"}; + Configurable cfgcasc_highmass{"cfgcasc_highmass", 1.331, "Cascade highmass cut"}; + + // config for histograms + Configurable IMNbins{"IMNbins", 100, "Number of bins in invariant mass"}; + Configurable lbinIM{"lbinIM", 1.0, "lower bin value in IM histograms"}; + Configurable hbinIM{"hbinIM", 1.2, "higher bin value in IM histograms"}; + Configurable resNbins{"resNbins", 50, "Number of bins in reso"}; + Configurable lbinres{"lbinres", 0.0, "lower bin value in reso histograms"}; + Configurable hbinres{"hbinres", 10.0, "higher bin value in reso histograms"}; + + ConfigurableAxis configcentAxis{"configcentAxis", {VARIABLE_WIDTH, 0.0, 10.0, 40.0, 80.0}, "Cent V0M"}; + ConfigurableAxis configthnAxispT{"configthnAxisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis configetaAxis{"configetaAxis", {VARIABLE_WIDTH, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8}, "Eta"}; + ConfigurableAxis configthnAxisPol{"configthnAxisPol", {VARIABLE_WIDTH, -1.0, -0.6, -0.2, 0, 0.2, 0.4, 0.8}, "Pol"}; + ConfigurableAxis configphiAxis{"configphiAxis", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.8, 1.0, 2.0, 2.5, 3.0, 4.0, 5.0, 5.5, 6.28}, "PhiAxis"}; + + SliceCache cache; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + AxisSpec thnAxisres{resNbins, lbinres, hbinres, "Reso"}; + AxisSpec thnAxisInvMass{IMNbins, lbinIM, hbinIM, "#it{M} (GeV/#it{c}^{2})"}; + + histos.add("hCentrality", "Centrality distribution", kTH1F, {{configcentAxis}}); + histos.add("hpRes", "hpRes", HistType::kTHnSparseF, {configcentAxis, thnAxisres}); + + histos.add("hSparseLambdaPolA", "hSparseLambdaPolA", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseLambdaPolC", "hSparseLambdaPolC", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseAntiLambdaPolA", "hSparseAntiLambdaPolA", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseAntiLambdaPolC", "hSparseAntiLambdaPolC", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + + histos.add("hSparseLambda_corr1a", "hSparseLambda_corr1a", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseLambda_corr1b", "hSparseLambda_corr1b", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseLambda_corr1c", "hSparseLambda_corr1c", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configphiAxis, configcentAxis}, true); + histos.add("hSparseAntiLambda_corr1a", "hSparseAntiLambda_corr1a", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseAntiLambda_corr1b", "hSparseAntiLambda_corr1b", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseAntiLambda_corr1c", "hSparseAntiLambda_corr1c", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configphiAxis, configcentAxis}, true); + + histos.add("hSparseLambda_corr2a", "hSparseLambda_corr2a", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseLambda_corr2b", "hSparseLambda_corr2b", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseAntiLambda_corr2a", "hSparseAntiLambda_corr2a", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hSparseAntiLambda_corr2b", "hSparseAntiLambda_corr2b", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + } + + template + bool SelectionV0(Collision const& collision, V0 const& candidate) + { + if (TMath::Abs(candidate.dcav0topv()) > cMaxV0DCA) { + return false; + } + const float pT = candidate.pt(); + const float tranRad = candidate.v0radius(); + const float dcaDaughv0 = TMath::Abs(candidate.dcaV0daughters()); + const float cpav0 = candidate.v0cosPA(); + + float CtauLambda = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massLambda; + + if (pT < ConfV0PtMin) { + return false; + } + if (TMath::Abs(candidate.dcapostopv()) < cMinV0DCA) { + return false; + } + if (TMath::Abs(candidate.dcanegtopv()) < cMinV0DCA) { + return false; + } + if (dcaDaughv0 > ConfV0DCADaughMax) { + return false; + } + if (cpav0 < ConfV0CPAMin) { + return false; + } + if (tranRad < ConfV0TranRadV0Min) { + return false; + } + if (tranRad > ConfV0TranRadV0Max) { + return false; + } + if (TMath::Abs(CtauLambda) > cMaxV0LifeTime) { + return false; + } + if (TMath::Abs(candidate.yLambda()) > ConfV0Rap) { + return false; + } + return true; + } + template + bool isSelectedV0Daughter(T const& track, int pid) + { + const auto eta = track.eta(); + const auto pt = track.pt(); + const auto tpcNClsF = track.tpcNClsFound(); + if (track.tpcNClsCrossedRows() < 70) { + return false; + } + if (TMath::Abs(eta) > ConfDaughEta) { + return false; + } + if (tpcNClsF < ConfDaughTPCnclsMin) { + return false; + } + if (track.tpcCrossedRowsOverFindableCls() < 0.8) { + return false; + } + /* + if (TMath::Abs(dcaXY) < ConfDaughDCAMin) { + return false; + }*/ + + if (pid == 0 && TMath::Abs(track.tpcNSigmaPr()) > ConfDaughPIDCuts) { + return false; + } + if (pid == 1 && TMath::Abs(track.tpcNSigmaPi()) > ConfDaughPIDCuts) { + return false; + } + + if (pid == 0 && pt < cfgDaughPrPt) { + return false; + } + if (pid == 1 && pt < cfgDaughPiPt) { + return false; + } + + return true; + } + + double GetPhiInRange(double phi) + { + double result = phi; + while (result < 0) { + result = result + 2. * TMath::Pi(); + } + while (result > 2. * TMath::Pi()) { + result = result - 2. * TMath::Pi(); + } + return result; + } + + template + bool IsCascAccepted(TCascade casc, collision_t collision) + { + + if (casc.cascradius() < cfgcasc_radius) + return false; + if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cfgcasc_casccospa) + return false; + if (casc.dcabachtopv() < cfgcasc_dcabachtopv) + return false; + if (casc.dcacascdaughters() > cfgcasc_dcacascdau) + return false; + if (std::fabs(casc.mLambda() - o2::constants::physics::MassLambda0) > cfgcasc_mlambdawindow) + return false; + + if (casc.v0radius() < cfgcascv0_radius) + return false; + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cfgcasc_v0cospa) + return false; + if (TMath::Abs(casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ())) < cfgcasc_dcav0topv) + return false; + if (TMath::Abs(casc.dcaV0daughters()) > cfgcasc_dcav0dau) + return false; + if (TMath::Abs(casc.dcapostopv()) < cfgcasc_dcapostopv) + return false; + if (TMath::Abs(casc.dcanegtopv()) < cfgcasc_dcanegtopv) + return false; + if (casc.mXi() < cfgcasc_lowmass || casc.mXi() > cfgcasc_highmass) + return false; + + return true; + } + + bool shouldReject(bool LambdaTag, bool aLambdaTag, + const ROOT::Math::PxPyPzMVector& Lambdadummy, + const ROOT::Math::PxPyPzMVector& AntiLambdadummy) + { + const double minMass = 1.105; + const double maxMass = 1.125; + return (LambdaTag && aLambdaTag && + (Lambdadummy.M() > minMass && Lambdadummy.M() < maxMass) && + (AntiLambdadummy.M() > minMass && AntiLambdadummy.M() < maxMass)); + } + + void fillHistograms(bool tag1, bool tag2, const ROOT::Math::PxPyPzMVector& particle, + const ROOT::Math::PxPyPzMVector& daughter, + double psiZDCC, double psiZDCA, double centrality, + double candmass, double candpt, double candeta) + { + + ROOT::Math::Boost boost{particle.BoostToCM()}; + auto fourVecDauCM = boost(daughter); + auto phiangle = TMath::ATan2(fourVecDauCM.Py(), fourVecDauCM.Px()); + + auto phiminuspsiC = GetPhiInRange(phiangle - psiZDCC); + auto phiminuspsiA = GetPhiInRange(phiangle - psiZDCA); + auto cosThetaStar = fourVecDauCM.Pz() / fourVecDauCM.P(); + auto sinThetaStar = TMath::Sqrt(1 - (cosThetaStar * cosThetaStar)); + auto PolC = TMath::Sin(phiminuspsiC); + auto PolA = TMath::Sin(phiminuspsiA); + + auto sinPhiStar = TMath::Sin(GetPhiInRange(phiangle)); + auto cosPhiStar = TMath::Cos(GetPhiInRange(phiangle)); + auto sinThetaStarcosphiphiStar = sinThetaStar * TMath::Cos(2 * GetPhiInRange(particle.Phi() - phiangle)); + auto phiphiStar = GetPhiInRange(particle.Phi() - phiangle); + + // Fill histograms using constructed names + if (tag2) { + histos.fill(HIST("hSparseAntiLambdaPolA"), candmass, candpt, candeta, PolA, centrality); + histos.fill(HIST("hSparseAntiLambdaPolC"), candmass, candpt, candeta, PolC, centrality); + histos.fill(HIST("hSparseAntiLambda_corr1a"), candmass, candpt, candeta, sinPhiStar, centrality); + histos.fill(HIST("hSparseAntiLambda_corr1b"), candmass, candpt, candeta, cosPhiStar, centrality); + histos.fill(HIST("hSparseAntiLambda_corr1c"), candmass, candpt, candeta, phiphiStar, centrality); + histos.fill(HIST("hSparseAntiLambda_corr2a"), candmass, candpt, candeta, sinThetaStar, centrality); + histos.fill(HIST("hSparseAntiLambda_corr2b"), candmass, candpt, candeta, sinThetaStarcosphiphiStar, centrality); + } + if (tag1) { + histos.fill(HIST("hSparseLambdaPolA"), candmass, candpt, candeta, PolA, centrality); + histos.fill(HIST("hSparseLambdaPolC"), candmass, candpt, candeta, PolC, centrality); + histos.fill(HIST("hSparseLambda_corr1a"), candmass, candpt, candeta, sinPhiStar, centrality); + histos.fill(HIST("hSparseLambda_corr1b"), candmass, candpt, candeta, cosPhiStar, centrality); + histos.fill(HIST("hSparseLambda_corr1c"), candmass, candpt, candeta, phiphiStar, centrality); + histos.fill(HIST("hSparseLambda_corr2a"), candmass, candpt, candeta, sinThetaStar, centrality); + histos.fill(HIST("hSparseLambda_corr2b"), candmass, candpt, candeta, sinThetaStarcosphiphiStar, centrality); + } + } + + ROOT::Math::PxPyPzMVector Lambda, AntiLambda, Lambdadummy, AntiLambdadummy, Proton, Pion, AntiProton, AntiPion, fourVecDauCM, LC; + ROOT::Math::XYZVector threeVecDauCM, threeVecDauCMXY; + double phiangle = 0.0; + double massLambda = o2::constants::physics::MassLambda; + double massPr = o2::constants::physics::MassProton; + double massPi = o2::constants::physics::MassPionCharged; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter centralityFilter = (nabs(aod::cent::centFT0C) < cfgCutCentralityMax && nabs(aod::cent::centFT0C) > cfgCutCentralityMin); + Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPT); + + using EventCandidates = soa::Filtered>; + using AllTrackCandidates = soa::Filtered>; + using CascCandidates = soa::Join; + + void processcascData(EventCandidates::iterator const& collision, aod::CascDataExt const& Cascades, AllTrackCandidates const&, aod::BCs const&) + { + + if (!collision.sel8()) { + return; + } + auto centrality = collision.centFT0C(); + if (!collision.triggereventsp()) { + return; + } + + if (additionalEvSel && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + return; + } + + if (additionalEvSel3 && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + return; + } + + auto psiZDCC = collision.psiZDCC(); + auto psiZDCA = collision.psiZDCA(); + + histos.fill(HIST("hCentrality"), centrality); + histos.fill(HIST("hpRes"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA - psiZDCC)))); + + for (auto& casc : Cascades) { + + auto negtrack = casc.negTrack_as(); + auto postrack = casc.posTrack_as(); + auto bachtrack = casc.bachelor_as(); + + bool CascAcc = IsCascAccepted(casc, collision); + + if (!CascAcc) + continue; + + int LambdaTag = 0; + int aLambdaTag = 0; + + const auto signpos = postrack.sign(); + const auto signneg = negtrack.sign(); + const auto signbach = bachtrack.sign(); + + if (signpos < 0 || signneg > 0 || signbach == 0) { + continue; + } + + if (isSelectedV0Daughter(postrack, 0) && isSelectedV0Daughter(negtrack, 1)) { + LambdaTag = 1; + } + if (isSelectedV0Daughter(negtrack, 0) && isSelectedV0Daughter(postrack, 1)) { + aLambdaTag = 1; + } + + if (!isSelectedV0Daughter(bachtrack, 1)) // quality track selection for bachelor track + continue; + + if (!LambdaTag && !aLambdaTag) + continue; + + if (casc.sign() != signbach) // cascade sign to be equal to bachelor sign + continue; + + if (casc.sign() > 0) { + AntiProton = ROOT::Math::PxPyPzMVector(casc.pxneg(), casc.pyneg(), casc.pzneg(), massPr); + Pion = ROOT::Math::PxPyPzMVector(casc.pxpos(), casc.pypos(), casc.pzpos(), massPi); + AntiLambdadummy = AntiProton + Pion; + + } else { + Proton = ROOT::Math::PxPyPzMVector(casc.pxpos(), casc.pypos(), casc.pzpos(), massPr); + AntiPion = ROOT::Math::PxPyPzMVector(casc.pxneg(), casc.pyneg(), casc.pzneg(), massPi); + Lambdadummy = Proton + AntiPion; + } + + if (shouldReject(LambdaTag, aLambdaTag, Lambdadummy, AntiLambdadummy)) { + continue; + } + + int taga = LambdaTag; + int tagb = aLambdaTag; + + if (LambdaTag) { + Lambda = Proton + AntiPion; + tagb = 0; + fillHistograms(taga, tagb, Lambda, Proton, psiZDCC, psiZDCA, centrality, Lambda.M(), Lambda.Pt(), Lambda.Eta()); + } + + tagb = aLambdaTag; + if (aLambdaTag) { + AntiLambda = AntiProton + Pion; + taga = 0; + fillHistograms(taga, tagb, AntiLambda, AntiProton, psiZDCC, psiZDCA, centrality, AntiLambda.M(), AntiLambda.Pt(), AntiLambda.Eta()); + } + } + } + PROCESS_SWITCH(cascpolsp, processcascData, "Process cascade data", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"cascpolsp"})}; +} diff --git a/PWGLF/Tasks/Strangeness/derivedcascadeanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedcascadeanalysis.cxx index e076f0e011e..95a25f589e3 100644 --- a/PWGLF/Tasks/Strangeness/derivedcascadeanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/derivedcascadeanalysis.cxx @@ -23,6 +23,7 @@ #include "ReconstructionDataFormats/Track.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" +#include "Common/CCDB/ctpRateFetcher.h" #include "PWGLF/DataModel/LFStrangenessTables.h" #include "PWGLF/DataModel/LFStrangenessPIDTables.h" #include "Common/Core/TrackSelection.h" @@ -72,19 +73,18 @@ struct Derivedcascadeanalysis { ConfigurableAxis axisNch{"axisNch", {500, 0.0f, +5000.0f}, "Number of charged particles in |y| < 0.5"}; ConfigurableAxis vertexZ{"vertexZ", {30, -15.0f, 15.0f}, ""}; ConfigurableAxis axisMass{"axisMass", {200, 1.222f, 1.422f}, "range of invariant mass, in case of omega take 1.572f, 1.772f"}; + ConfigurableAxis axisIR{"axisIR", {510, -1, 50}, "Binning for the interaction rate (kHz)"}; Configurable isXi{"isXi", 1, "Apply cuts for Xi identification"}; - Configurable usePbPbCentrality{"usePbPbCentrality", 0, "If true, use centFt0C, else use centFT0M"}; - Configurable minOccupancy{"minOccupancy", -1, "Minimal occupancy"}; - Configurable maxOccupancy{"maxOccupancy", -1, "Maximal occupancy"}; - Configurable minOccupancyFT0{"minOccupancyFT0", -1, "Minimal occupancy"}; - Configurable maxOccupancyFT0{"maxOccupancyFT0", -1, "Maximal occupancy"}; + Configurable useCentralityFT0M{"useCentralityFT0M", 0, "If true, use centFT0M"}; + Configurable useCentralityFT0A{"useCentralityFT0A", 0, "If true, use centFT0A"}; + Configurable useCentralityFT0Cvar1{"useCentralityFT0Cvar1", 0, "If true, use centFT0FT0Cvar1"}; Configurable useTrackOccupancyDef{"useTrackOccupancyDef", true, "Use occupancy definition based on the tracks"}; Configurable useFT0OccupancyDef{"useFT0OccupancyDef", false, "se occupancy definition based on the FT0 signals"}; - Configurable centMin{"centMin", 0, "Minimal accepted centrality"}; - Configurable centMax{"centMax", 100, "Maximal accepted centrality"}; Configurable minPt{"minPt", 0.0f, "minPt"}; Configurable nPtBinsForNsigmaTPC{"nPtBinsForNsigmaTPC", 100, ""}; + Configurable irSource{"irSource", "T0VTX", "Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"}; + Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; struct : ConfigurableGroup { std::string prefix = "qa"; @@ -96,14 +96,14 @@ struct Derivedcascadeanalysis { Configurable doPtDepCutStudy{"doPtDepCutStudy", false, "Fill histogram with a cutting paramer"}; Configurable doBefSelEventMultCorr{"doBefSelEventMultCorr", false, "Enable histogram of multiplicity correlation before cuts"}; Configurable doOccupancyCheck{"doOccupancyCheck", true, ""}; + Configurable doIRCheck{"doIRCheck", true, ""}; + Configurable doITSTPCmatchingCheck{"doITSTPCmatchingCheck", true, "fill histogram for ITS-TPC matching check"}; } qaFlags; struct : ConfigurableGroup { - std::string prefix = "evSelection"; + std::string prefix = "evSelectionRun3"; Configurable doTFeventCut{"doTFeventCut", false, "Enable TF event Cut"}; Configurable doITSFrameBorderCut{"doITSFrameBorderCut", false, "Enable ITSFrame event cut"}; - Configurable doTriggerTVXEventCut{"doTriggerTVXEventCut", false, "Minimal MB event selection, for MC"}; - Configurable doTriggerSel8EventCut{"doTriggerSel8EventCut", true, "Standard MB event selection"}; Configurable doGoodPVFT0EventCut{"doGoodPVFT0EventCut", true, "check for the PV position diffrence when estimated from tracks and FT0"}; Configurable doITSTPCvertexEventCut{"doITSTPCvertexEventCut", true, "checks the presence of at least one ITS-TPC track"}; Configurable doSameBunchPileUpEventCut{"doSameBunchPileUpEventCut", true, "removes events associated with the same \"found-by-T0\" bunch crossing"}; @@ -111,13 +111,45 @@ struct Derivedcascadeanalysis { Configurable doVertexTRDmatch{"doVertexTRDmatch", false, "Checks wherher at least one of vertex contributors is matched to TRD"}; Configurable doTimeRangeStandardCut{"doTimeRangeStandardCut", true, "It rejects a given collision if there are other events nearby in dtime +/- 2 μs, or mult above some threshold in -4..-2 μs"}; Configurable doTimeRangeStrictCut{"doTimeRangeStrictCut", false, "It rejects a given collision if there are other events nearby in |dt|< 10 μs"}; - Configurable doTimeRangeVzDependent{"doTimeRangeVzDependent", false, "It rejects collision with pvZ of drifting TPC tracks from past/future collisions within 2.5 cm the current pvZ"}; Configurable doNoCollInRofStrictCut{"doNoCollInRofStrictCut", false, "Enable an evevnt selection which rejects a collision if there are other events within the same ITS ROF"}; Configurable doNoCollInRofStandardCut{"doNoCollInRofStandardCut", true, "Enable an evevnt selection which rejects a collision if there are other events within the same ITS ROF with mult above threshold"}; Configurable doMultiplicityCorrCut{"doMultiplicityCorrCut", false, "Enable multiplicity vs centrality correlation cut"}; - Configurable doInel1{"doInel1", true, "Enable INEL > 1 selection"}; + Configurable doITSallLayersCut{"doITSallLayersCut", false, "Enable event selection which rejects collisions when ITS was rebooting."}; + Configurable minOccupancy{"minOccupancy", -1, "Minimal occupancy"}; + Configurable maxOccupancy{"maxOccupancy", -1, "Maximal occupancy"}; + Configurable minOccupancyFT0{"minOccupancyFT0", -1, "Minimal occupancy"}; + Configurable maxOccupancyFT0{"maxOccupancyFT0", -1, "Maximal occupancy"}; + } eventSelectionRun3Flags; + + struct : ConfigurableGroup { + std::string prefix = "evSelectionCommon"; + Configurable doTriggerSel8EventCut{"doTriggerSel8EventCut", true, "Standard MB event selection"}; + Configurable doTriggerTVXEventCut{"doTriggerTVXEventCut", false, "Minimal MB event selection, for MC"}; + Configurable doInel0{"doInel0", true, "Enable INEL > 0 selection"}; Configurable zVertexCut{"zVertexCut", 10, "Cut on PV position"}; - } eventSelectionFlags; + Configurable centMin{"centMin", 0, "Minimal accepted centrality"}; + Configurable centMax{"centMax", 100, "Maximal accepted centrality"}; + Configurable doInel0MCGen{"doInel0MCGen", true, "Enable INEL > 0 selection for MC gen events"}; + Configurable applyZVtxSelOnMCPV{"applyZVtxSelOnMCPV", false, "Enable z vertex cut selection on generated events"}; + } eventSelectionCommonFlags; + + struct : ConfigurableGroup { + std::string prefix = "evSelectionRun2"; + Configurable doSel7{"doSel7", true, "require sel7 event selection (Run 2 only: event selection decision based on V0A & V0C)"}; + Configurable doINT7{"doINT7", true, "require INT7 trigger selection (Run 2 only)"}; + Configurable doIncompleteDAQCut{"doIncompleteDAQCut", true, "reject events with incomplete DAQ (Run 2 only)"}; + Configurable doConsistentSPDAndTrackVtx{"doConsistentSPDAndTrackVtx", true, "reject events with inconsistent in SPD and Track vertices (Run 2 only)"}; + Configurable doPileupFromSPDCut{"doPileupFromSPDCut", true, "reject events with pileup according to SPD vertexer (Run 2 only)"}; + Configurable doV0PFPileupCut{"doV0PFPileupCut", false, "reject events tagged as OOB pileup according to V0 past-future info (Run 2 only)"}; + Configurable doPileupInMultBinsCut{"doPileupInMultBinsCut", true, "reject events tagged as pileup according to multiplicity-differential pileup checks (Run 2 only)"}; + Configurable doPileupMVCut{"doPileupMVCut", true, "reject events tagged as pileup according to according to multi-vertexer (Run 2 only)"}; + Configurable doTPCPileupCut{"doTPCPileupCut", false, "reject events tagged as pileup according to pileup in TPC (Run 2 only)"}; + Configurable doNoV0MOnVsOffPileup{"doNoV0MOnVsOffPileup", false, "reject events tagged as OOB pileup according to online-vs-offline VOM correlation (Run 2 only)"}; + Configurable doNoSPDOnVsOffPileup{"doNoSPDOnVsOffPileup", false, "reject events tagged as pileup according to online-vs-offline SPD correlation (Run 2 only)"}; + Configurable doNoSPDClsVsTklBG{"doNoSPDClsVsTklBG", true, "reject events tagged as beam-gas and pileup according to cluster-vs-tracklet correlation (Run 2 only)"}; + + Configurable useSPDTrackletsCent{"useSPDTrackletsCent", false, "Use SPD tracklets for estimating centrality? If not, use V0M-based centrality (Run 2 only)"}; + } eventSelectionRun2Flags; struct : ConfigurableGroup { std::string prefix = "candidateSelFlag"; @@ -126,7 +158,9 @@ struct Derivedcascadeanalysis { Configurable doPtDepV0RadiusCut{"doPtDepV0RadiusCut", false, "Enable pt dependent V0 radius cut"}; Configurable doPtDepV0CosPaCut{"doPtDepV0CosPaCut", false, "Enable pt dependent cos PA cut of the V0 daughter"}; Configurable doPtDepDCAcascDauCut{"doPtDepDCAcascDauCut", false, "Enable pt dependent DCA cascade daughter cut"}; - Configurable doDCAdauToPVCut{"doDCAdauToPVCut", true, "Enable cut DCA daughter track to PV"}; + Configurable doDCAbachToPVCut{"doDCAbachToPVCut", true, "Enable cut DCA daughter track to PV"}; + Configurable doDCAmesonToPVCut{"doDCAmesonToPVCut", true, "Enable cut DCA daughter track to PV"}; + Configurable doDCAbaryonToPVCut{"doDCAbaryonToPVCut", true, "Enable cut DCA daughter track to PV"}; Configurable doCascadeCosPaCut{"doCascadeCosPaCut", true, "Enable cos PA cut"}; Configurable doV0CosPaCut{"doV0CosPaCut", true, "Enable cos PA cut for the V0 daughter"}; Configurable doDCACascadeDauCut{"doDCACascadeDauCut", true, "Enable cut DCA betweenn daughter tracks"}; @@ -141,6 +175,9 @@ struct Derivedcascadeanalysis { Configurable doNTOFSigmaV0PionCut{"doNTOFSigmaV0PionCut", false, "Enable n sigma TOF PID cut for pion from V0"}; Configurable doNTOFSigmaBachelorCut{"doNTOFSigmaBachelorCut", false, "Enable n sigma TOF PID cut for bachelor track"}; Configurable dooobrej{"dooobrej", 0, "OOB rejection: 0 no selection, 1 = ITS||TOF, 2 = TOF only for pT > ptthrtof"}; + Configurable doAtLeastOneTrackAB{"doAtLeastOneTrackAB", false, "require that at least one of the daughter tracks is from Afterburner"}; + Configurable doBachelorITSTracking{"doBachelorITSTracking", false, "require that the bachelor track is from the ITS tracking"}; + Configurable doAllTracksMinITSClusters{"doAllTracksMinITSClusters", false, "require that all daughter tracks have minimal ITS hits"}; } candidateSelectionFlags; struct : ConfigurableGroup { @@ -183,11 +220,19 @@ struct Derivedcascadeanalysis { Configurable masswin{"masswin", 0.05, "Mass window limit"}; Configurable rapCut{"rapCut", 0.5, "Rapidity acceptance"}; Configurable etaDauCut{"etaDauCut", 0.8, "Pseudorapidity acceptance of the cascade daughters"}; + Configurable minITSclusters{"minITSclusters", 3, "minimal number of ITS hits for the daughter tracks"}; } candidateSelectionValues; + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + ctpRateFetcher rateFetcher; + Service pdgDB; - static constexpr std::string_view Index[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; + uint16_t selectionCheckMask; + double selectionCheck; + + static constexpr std::string_view kCentIndex[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; static constexpr float kCentralityIntervals[11] = {0., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90.}; static constexpr std::string_view kCharge[] = {"Positive", "Negative"}; static constexpr std::string_view kSelectionNames[] = {"BachelorBaryonDCA", "DCAV0ToPV", "V0Radius", "CascadeRadius", "DCAV0Daughters", "DCACascDaughters", "V0pa", "CascPA", "DCABachelorToPV", "DCAMesonToPV", "DCABaryonToPV", "CascadeProperLifeTime"}; @@ -195,15 +240,68 @@ struct Derivedcascadeanalysis { // For manual sliceBy // Preslice> perMcCollision = aod::v0data::straMCCollisionId; PresliceUnsorted> perMcCollision = aod::v0data::straMCCollisionId; + PresliceUnsorted> perMcCollisionRun2 = aod::v0data::straMCCollisionId; void init(InitContext const&) { + if ((doprocessCascades || doprocessCascadesMCrec || doprocessCascadesMCforEff) && (doprocessCascadesRun2 || doprocessCascadesMCrecRun2 || doprocessCascadesMCforEffRun2)) { + LOGF(fatal, "Cannot enable Run2 and Run3 processes at the same time. Please choose one."); + } + + // setting CCDB service + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setFatalWhenNull(false); + + selectionCheck = -1; + selectionCheckMask = 0; + if (!candidateSelectionFlags.doBachelorBaryonCut) + SETBIT(selectionCheckMask, 0); + if (!candidateSelectionFlags.doDCAV0ToPVCut) + SETBIT(selectionCheckMask, 1); + if (!candidateSelectionFlags.doV0RadiusCut) + SETBIT(selectionCheckMask, 2); + if (!candidateSelectionFlags.doCascadeRadiusCut) + SETBIT(selectionCheckMask, 3); + if (!candidateSelectionFlags.doDCAV0DauCut) + SETBIT(selectionCheckMask, 4); + if (!candidateSelectionFlags.doDCACascadeDauCut) + SETBIT(selectionCheckMask, 5); + if (!candidateSelectionFlags.doV0CosPaCut) + SETBIT(selectionCheckMask, 6); + if (!candidateSelectionFlags.doCascadeCosPaCut) + SETBIT(selectionCheckMask, 7); + if (!candidateSelectionFlags.doDCAbachToPVCut) + SETBIT(selectionCheckMask, 8); + if (!candidateSelectionFlags.doDCAmesonToPVCut) + SETBIT(selectionCheckMask, 9); + if (!candidateSelectionFlags.doDCAbaryonToPVCut) + SETBIT(selectionCheckMask, 10); + if (!candidateSelectionFlags.doProperLifeTimeCut) + SETBIT(selectionCheckMask, 11); + histos.add("hEventVertexZ", "hEventVertexZ", kTH1F, {vertexZ}); histos.add("hEventMultFt0C", "", kTH1F, {{500, 0, 5000}}); histos.add("hEventCentrality", "hEventCentrality", kTH1F, {{101, 0, 101}}); + histos.add("hEventSelection", "hEventSelection", kTH1F, {{22, 0, 22}}); + // TODO adjust labels + TString eventSelLabelRun3[22] = {"all", "sel8", "TVX", "PV_{z}", "cent", "kNoSameBunchPileup", "kIsGoodZvtxFT0vsPV", "kIsVertexITSTPC", "kIsVertexTOFmatched", "kIsVertexTRDmatched", "kNoITSROFrameBorder", "kNoTimeFrameBorder", "MultCorrCut", "kNoCollInTimeRangeStrict", "kNoCollInTimeRangeStandard", "min Occup", "mxOccup", "kNoCollInRofStrict", "kNoCollInRofStandard", "kIsGoodITSLayersAll", "occupFt0", "-"}; + TString eventSelLabelRun2[22] = {"all", "sel8", "TVX", "PV_{z}", "cent", "sel7", "kINT7", "kNoIncompleteDAQ", "kNoInconsistentVtx", "kNoPileupFromSPD", "kNoV0PFPileup", "kNoPileupInMultBins", "kNoPileupMV", "kNoPileupTPC", "kNoV0MOnVsOfPileup", "kNoSPDOnVsOfPileup", "kNoSPDClsVsTklBG", "INEL0", "-", "-", "-", "-"}; + for (int i = 1; i <= histos.get(HIST("hEventSelection"))->GetNbinsX(); i++) { + if (doprocessCascades || doprocessCascadesMCrec || doprocessCascadesMCforEff) { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(i, eventSelLabelRun3[i - 1]); + } else { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(i, eventSelLabelRun2[i - 1]); + } + } + histos.add("hOccupancyVsOccupFt0VsCentrality", "", kTH3F, {axisOccupancy, axisOccupancyFt0, {100, 0, 100}}); + histos.add("hNCrossedRowsNegative", "", kTH1F, {{400, -200, 200}}); + histos.add("hNCrossedRowsPositive", "", kTH1F, {{400, -200, 200}}); + histos.add("hNCrossedRowsBachelor", "", kTH1F, {{400, -200, 200}}); + histos.add("hEventNchCorrelationAfCuts", "hEventNchCorrelationAfCuts", kTH2F, {{5000, 0, 5000}, {5000, 0, 2500}}); histos.add("hEventPVcontributorsVsCentrality", "hEventPVcontributorsVsCentrality", kTH2F, {{100, 0, 100}, {5000, 0, 5000}}); histos.add("hEventGlobalTracksVsCentrality", "hEventGlobalTracksVsCentrality", kTH2F, {{100, 0, 100}, {2500, 0, 2500}}); @@ -254,10 +352,30 @@ struct Derivedcascadeanalysis { if (qaFlags.doOccupancyCheck) { histos.add("InvMassAfterSelCent1/hNegativeCascade", "hNegativeCascade", HistType::kTH3F, {axisPt, axisMass, axisOccupancy}); histos.add("InvMassAfterSelCent1/hPositiveCascade", "hPositiveCascade", HistType::kTH3F, {axisPt, axisMass, axisOccupancy}); - if (doprocessCascadesMCrec) { + if (doprocessCascadesMCrec || doprocessCascadesMCrecRun2) { histos.add("InvMassAfterSelCent1/hNegativeCascadeMCTruth", "hNegativeCascadeMCTruth", HistType::kTH3F, {axisPt, axisMass, axisOccupancy}); histos.add("InvMassAfterSelCent1/hPositiveCascadeMCTruth", "hPositiveCascadeMCTruth", HistType::kTH3F, {axisPt, axisMass, axisOccupancy}); } + if (!qaFlags.doIRCheck) { + histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent2/"); + histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent3/"); + histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent4/"); + histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent5/"); + histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent6/"); + histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent7/"); + histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent8/"); + histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent9/"); + histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent10/"); + } + } + + if (qaFlags.doIRCheck) { + histos.add("InvMassAfterSelCent1/hNegativeCascadeIR", "hNegativeCascadeIR", HistType::kTH3F, {axisPt, axisMass, axisIR}); + histos.add("InvMassAfterSelCent1/hPositiveCascadeIR", "hPositiveCascadeIR", HistType::kTH3F, {axisPt, axisMass, axisIR}); + if (doprocessCascadesMCrec || doprocessCascadesMCrecRun2) { + histos.add("InvMassAfterSelCent1/hNegativeCascadeMCTruthIR", "hNegativeCascadeMCTruthIR", HistType::kTH3F, {axisPt, axisMass, axisIR}); + histos.add("InvMassAfterSelCent1/hPositiveCascadeMCTruthIR", "hPositiveCascadeMCTruthIR", HistType::kTH3F, {axisPt, axisMass, axisIR}); + } histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent2/"); histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent3/"); histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent4/"); @@ -269,10 +387,13 @@ struct Derivedcascadeanalysis { histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent10/"); } + histos.add("hInteractionRate", "hInteractionRate", kTH1F, {axisIR}); + histos.add("hCentralityVsInteractionRate", "hCentralityVsInteractionRate", kTH2F, {{101, 0.0f, 101.0f}, axisIR}); + if (qaFlags.doBefSelCheck) histos.addClone("InvMassAfterSel/", "InvMassBefSel/"); - if (doprocessCascadesMCrec) + if (doprocessCascadesMCrec || doprocessCascadesMCrecRun2) histos.addClone("InvMassAfterSel/", "InvMassAfterSelMCrecTruth/"); if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doProperLifeTimeCut) { @@ -310,59 +431,104 @@ struct Derivedcascadeanalysis { histos.add("PtDepCutStudy/hNegativeV0pa", "hNegativeV0pa", HistType::kTH3F, {axisPt, axisMass, {40, 0, 0.4}}); histos.add("PtDepCutStudy/hPositiveV0pa", "hPositiveV0pa", {HistType::kTH3F, {axisPt, axisMass, {40, 0, 0.4}}}); } - if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doDCAdauToPVCut) { + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doDCAbachToPVCut) { histos.add("PtDepCutStudy/hNegativeDCABachelorToPV", "hNegativeDCABachelorToPV", HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}); - histos.add("PtDepCutStudy/hNegativeDCABaryonToPV", "hNegativeDCABaryonToPV", HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}); - histos.add("PtDepCutStudy/hNegativeDCAMesonToPV", "hNegativeDCAMesonToPV", HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}); histos.add("PtDepCutStudy/hPositiveDCABachelorToPV", "hPositiveDCABachelorToPV", {HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}}); - histos.add("PtDepCutStudy/hPositiveDCABaryonToPV", "hPositiveDCABaryonToPV", HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}); + } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doDCAmesonToPVCut) { + histos.add("PtDepCutStudy/hNegativeDCAMesonToPV", "hNegativeDCAMesonToPV", HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}); histos.add("PtDepCutStudy/hPositiveDCAMesonToPV", "hPositiveDCAMesonToPV", HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}); } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doDCAbaryonToPVCut) { + histos.add("PtDepCutStudy/hNegativeDCABaryonToPV", "hNegativeDCABaryonToPV", HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}); + histos.add("PtDepCutStudy/hPositiveDCABaryonToPV", "hPositiveDCABaryonToPV", HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}); + } if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doCascadeCosPaCut) { histos.add("PtDepCutStudy/hNegativeCascPA", "hNegativeCascPA", HistType::kTH3F, {axisPt, axisMass, {40, 0, 0.4}}); histos.add("PtDepCutStudy/hPositiveCascPA", "hPositiveCascPA", {HistType::kTH3F, {axisPt, axisMass, {40, 0, 0.4}}}); } + if (qaFlags.doITSTPCmatchingCheck) { + histos.add("histITSTPCmatchPosTrack", "", HistType::kTH3F, {axisPt, {101, 0, 101}, {3, 0, 3}}); + histos.add("histITSTPCmatchNegTrack", "", HistType::kTH3F, {axisPt, {101, 0, 101}, {3, 0, 3}}); + histos.add("histITSTPCmatchBachTrack", "", HistType::kTH3F, {axisPt, {101, 0, 101}, {3, 0, 3}}); + } - if (doprocessCascadesMCrec) { + if (doprocessCascadesMCrec || doprocessCascadesMCrecRun2) { histos.addClone("PtDepCutStudy/", "PtDepCutStudyMCTruth/"); histos.add("hNegativeCascadePtForEfficiency", "hNegativeCascadePtForEfficiency", HistType::kTH3F, {axisPt, axisMass, {101, 0, 101}}); histos.add("hPositiveCascadePtForEfficiency", "hPositiveCascadePtForEfficiency", {HistType::kTH3F, {axisPt, axisMass, {101, 0, 101}}}); + histos.add("hNegativeCascadePtForEfficiencyVsNch", "hNegativeCascadePtForEfficiencyVsNch", HistType::kTH3F, {axisPt, axisMass, axisNch}); + histos.add("hPositiveCascadePtForEfficiencyVsNch", "hPositiveCascadePtForEfficiencyVsNch", {HistType::kTH3F, {axisPt, axisMass, axisNch}}); + if (qaFlags.doBefSelCheck) { + histos.add("hNegativeCascadePtForEfficiencyBefSel", "hNegativeCascadePtForEfficiencyBefSel", HistType::kTH3F, {axisPt, axisMass, {101, 0, 101}}); + histos.add("hPositiveCascadePtForEfficiencyBefSel", "hPositiveCascadePtForEfficiencyBefSel", {HistType::kTH3F, {axisPt, axisMass, {101, 0, 101}}}); + histos.add("hNegativeCascadePtForEfficiencyVsNchBefSel", "hNegativeCascadePtForEfficiencyVsNchBefSel", HistType::kTH3F, {axisPt, axisMass, axisNch}); + histos.add("hPositiveCascadePtForEfficiencyVsNchBefSel", "hPositiveCascadePtForEfficiencyVsNchBefSel", {HistType::kTH3F, {axisPt, axisMass, axisNch}}); + } } - if (doprocessCascadesMCforEff) { - histos.add("hGenEvents", "", HistType::kTH2F, {{axisNch}, {2, 0, 2}}); + if (doprocessCascadesMCforEff || doprocessCascadesMCforEffRun2) { + histos.add("hGenEvents", "", HistType::kTH2F, {{axisNch}, {4, 0, 4}}); histos.add("hCentralityVsMultMC", "", kTH2F, {{101, 0.0f, 101.0f}, axisNch}); + histos.add("hRecMultVsMultMC", "", kTH2F, {axisNch, axisNch}); histos.add("hGenMultMCFT0C", "", kTH1F, {{500, 0, 5000}}); histos.add("hGenMCNParticlesEta10", "", kTH1F, {{500, 0, 5000}}); + histos.add("hCentralityVsIRGen", "", kTH2F, {{101, 0.0f, 101.0f}, axisIR}); + histos.add("hMultMCVsCentralityVsIRGen", "", kTH3F, {axisNch, {101, 0.0f, 101.0f}, axisIR}); histos.add("hCentralityVsNcoll_beforeEvSel", "", kTH2F, {{101, 0.0f, 101.0f}, {50, 0.f, 50.f}}); histos.add("hCentralityVsNcoll_afterEvSel", "", kTH2F, {{101, 0.0f, 101.0f}, {50, 0.f, 50.f}}); - histos.add("h2dGenXiMinusEta", "", kTH1F, {{30, -2, 2}}); - histos.add("h2dGenXiMinusEtaPosDaughter", "", kTH1F, {{30, -2, 2}}); - histos.add("h2dGenXiMinusEtaNegDaughter", "", kTH1F, {{30, -2, 2}}); - histos.add("h2dGenXiMinusEtaBach", "", kTH1F, {{30, -2, 2}}); - - histos.add("h2dGenOmegaMinusEta", "", kTH1F, {{30, -2, 2}}); - histos.add("h2dGenOmegaMinusEtaPosDaughter", "", kTH1F, {{30, -2, 2}}); - histos.add("h2dGenOmegaMinusEtaNegDaughter", "", kTH1F, {{30, -2, 2}}); - histos.add("h2dGenOmegaMinusEtaBach", "", kTH1F, {{30, -2, 2}}); - - histos.add("h2dGenXiMinus", "h2dGenXiMinus", kTH2D, {{101, 0.0f, 101.0f}, axisPt}); - histos.add("h2dGenXiPlus", "h2dGenXiPlus", kTH2D, {{101, 0.0f, 101.0f}, axisPt}); - histos.add("h2dGenOmegaMinus", "h2dGenOmegaMinus", kTH2D, {{101, 0.0f, 101.0f}, axisPt}); - histos.add("h2dGenOmegaPlus", "h2dGenOmegaPlus", kTH2D, {{101, 0.0f, 101.0f}, axisPt}); - - histos.add("h2dGenXiMinusVsCentOccupancy", "h2dGenXiMinusVsCentOccupancy", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisOccupancy}); - histos.add("h2dGenXiPlusVsCentOccupancy", "h2dGenXiPlusVsCentOccupancy", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisOccupancy}); - histos.add("h2dGenOmegaMinusVsCentOccupancy", "h2dGenOmegaMinusVsCentOccupancy", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisOccupancy}); - histos.add("h2dGenOmegaPlusVsCentOccupancy", "h2dGenOmegaPlusVsCentOccupancy", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisOccupancy}); - - histos.add("h2dGenXiMinusVsMultMC", "h2dGenXiMinusVsMultMC", kTH2D, {axisNch, axisPt}); - histos.add("h2dGenXiPlusVsMultMC", "h2dGenXiPlusVsMultMC", kTH2D, {axisNch, axisPt}); - histos.add("h2dGenOmegaMinusVsMultMC", "h2dGenOmegaMinusVsMultMC", kTH2D, {axisNch, axisPt}); - histos.add("h2dGenOmegaPlusVsMultMC", "h2dGenOmegaPlusVsMultMC", kTH2D, {axisNch, axisPt}); + if (isXi) { + histos.add("h2dGenXiMinusEta", "", kTH1F, {{30, -2, 2}}); + histos.add("h2dGenXiMinusEtaPosDaughter", "", kTH1F, {{30, -2, 2}}); + histos.add("h2dGenXiMinusEtaNegDaughter", "", kTH1F, {{30, -2, 2}}); + histos.add("h2dGenXiMinusEtaBach", "", kTH1F, {{30, -2, 2}}); + histos.add("h2dGenXiMinus", "h2dGenXiMinus", kTH2D, {{101, 0.0f, 101.0f}, axisPt}); + histos.add("h2dGenXiPlus", "h2dGenXiPlus", kTH2D, {{101, 0.0f, 101.0f}, axisPt}); + histos.add("h2dGenXiMinusVsNch", "h2dGenXiMinusVsNch", kTH2D, {axisNch, axisPt}); + histos.add("h2dGenXiPlusVsNch", "h2dGenXiPlusVsNch", kTH2D, {axisNch, axisPt}); + histos.add("h2dGenXiMinusVsCentOccupancy", "h2dGenXiMinusVsCentOccupancy", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisOccupancy}); + histos.add("h2dGenXiPlusVsCentOccupancy", "h2dGenXiPlusVsCentOccupancy", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisOccupancy}); + histos.add("h2dGenXiMinusVsNchVsOccupancy", "h2dGenXiMinusVsNchVsOccupancy", kTH3D, {axisPt, axisNch, axisOccupancy}); + histos.add("h2dGenXiPlusVsNchVsOccupancy", "h2dGenXiPlusVsNchVsOccupancy", kTH3D, {axisPt, axisNch, axisOccupancy}); + histos.add("h2dGenXiMinusVsMultMCVsCentrality", "h2dGenXiMinusVsMultMCVsCentrality", kTH3D, {axisNch, {101, 0.0f, 101.0f}, axisPt}); + histos.add("h2dGenXiPlusVsMultMCVsCentrality", "h2dGenXiPlusVsMultMCVsCentrality", kTH3D, {axisNch, {101, 0.0f, 101.0f}, axisPt}); + histos.add("h2dGenXiMinusVsCentIR", "h2dGenXiMinusVsCentIR", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisIR}); + histos.add("h2dGenXiPlusVsCentIR", "h2dGenXiPlusVsCentIR", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisIR}); + histos.add("h2dGenXiMinusVsMultMCVsIR", "h2dGenXiMinusVsMultMCVsIR", kTH3D, {axisNch, axisIR, axisPt}); + histos.add("h2dGenXiPlusVsMultMCVsIR", "h2dGenXiPlusVsMultMCVsIR", kTH3D, {axisNch, axisIR, axisPt}); + } else { + histos.add("h2dGenOmegaMinusEta", "", kTH1F, {{30, -2, 2}}); + histos.add("h2dGenOmegaMinusEtaPosDaughter", "", kTH1F, {{30, -2, 2}}); + histos.add("h2dGenOmegaMinusEtaNegDaughter", "", kTH1F, {{30, -2, 2}}); + histos.add("h2dGenOmegaMinusEtaBach", "", kTH1F, {{30, -2, 2}}); + histos.add("h2dGenOmegaMinus", "h2dGenOmegaMinus", kTH2D, {{101, 0.0f, 101.0f}, axisPt}); + histos.add("h2dGenOmegaPlus", "h2dGenOmegaPlus", kTH2D, {{101, 0.0f, 101.0f}, axisPt}); + histos.add("h2dGenOmegaMinusVsNch", "h2dGenOmegaMinusVsNch", kTH2D, {axisNch, axisPt}); + histos.add("h2dGenOmegaPlusVsNch", "h2dGenOmegaPlusVsNch", kTH2D, {axisNch, axisPt}); + histos.add("h2dGenOmegaMinusVsCentOccupancy", "h2dGenOmegaMinusVsCentOccupancy", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisOccupancy}); + histos.add("h2dGenOmegaPlusVsCentOccupancy", "h2dGenOmegaPlusVsCentOccupancy", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisOccupancy}); + histos.add("h2dGenOmegaMinusVsNchVsOccupancy", "h2dGenOmegaMinusVsNchVsOccupancy", kTH3D, {axisPt, axisNch, axisOccupancy}); + histos.add("h2dGenOmegaPlusVsNchVsOccupancy", "h2dGenOmegaPlusVsNchVsOccupancy", kTH3D, {axisPt, axisNch, axisOccupancy}); + histos.add("h2dGenOmegaMinusVsMultMCVsCentrality", "h2dGenOmegaMinusVsMultMCVsCentrality", kTH3D, {axisNch, {101, 0.0f, 101.0f}, axisPt}); + histos.add("h2dGenOmegaPlusVsMultMCVsCentrality", "h2dGenOmegaPlusVsMultMCVsCentrality", kTH3D, {axisNch, {101, 0.0f, 101.0f}, axisPt}); + histos.add("h2dGenOmegaMinusVsCentIR", "h2dGenOmegaMinusVsCentIR", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisIR}); + histos.add("h2dGenOmegaPlusVsCentIR", "h2dGenOmegaPlusVsCentIR", kTH3D, {axisPt, {101, 0.0f, 101.0f}, axisIR}); + histos.add("h2dGenOmegaMinusVsMultMCVsIR", "h2dGenOmegaMinusVsMultMCVsIR", kTH3D, {axisNch, axisIR, axisPt}); + histos.add("h2dGenOmegaPlusVsMultMCVsIR", "h2dGenOmegaPlusVsMultMCVsIR", kTH3D, {axisNch, axisIR, axisPt}); + } + } + } + // Return slicing output + template + auto getGroupedCollisions(TCollisions const& collisions, int globalIndex) + { + if constexpr (run3) { // check if we are in Run 3 + return collisions.sliceBy(perMcCollision, globalIndex); + } else { // we are in Run2 + return collisions.sliceBy(perMcCollisionRun2, globalIndex); } } template @@ -409,150 +575,239 @@ struct Derivedcascadeanalysis { if (fillHists) histos.fill(HIST("hEventSelection"), 0.5 /* all collisions */); - float centrality = coll.centFT0C(); - if (!usePbPbCentrality) - centrality = coll.centFT0M(); - - if (qaFlags.doBefSelEventMultCorr) { - histos.fill(HIST("hEventNchCorrelationBefCuts"), coll.multNTracksPVeta1(), coll.multNTracksGlobal()); - histos.fill(HIST("hEventPVcontributorsVsCentralityBefCuts"), centrality, coll.multNTracksPVeta1()); - histos.fill(HIST("hEventGlobalTracksVsCentralityBefCuts"), centrality, coll.multNTracksGlobal()); - } - - if (eventSelectionFlags.doTriggerTVXEventCut && !coll.selection_bit(aod::evsel::kIsTriggerTVX)) { + if (eventSelectionCommonFlags.doTriggerSel8EventCut && !coll.sel8()) { return false; } if (fillHists) - histos.fill(HIST("hEventSelection"), 1.5 /* collisions after sel*/); + histos.fill(HIST("hEventSelection"), 1.5 /* collisions after sel8*/); - if (eventSelectionFlags.doTriggerSel8EventCut && !coll.sel8()) { + if (eventSelectionCommonFlags.doTriggerTVXEventCut && !coll.selection_bit(aod::evsel::kIsTriggerTVX)) { return false; } if (fillHists) - histos.fill(HIST("hEventSelection"), 2.5 /* collisions after sel*/); - - if (std::abs(coll.posZ()) > eventSelectionFlags.zVertexCut) { + histos.fill(HIST("hEventSelection"), 2.5 /* collisions after TVX cut*/); + if (std::abs(coll.posZ()) > eventSelectionCommonFlags.zVertexCut) { return false; } if (fillHists) histos.fill(HIST("hEventSelection"), 3.5 /* collisions after sel pvz sel*/); + float centrality = -10; + double interactionRate = -10; + int occupancy = -2; + float occupancyFT0 = -2; + + if constexpr (requires { coll.centFT0C(); }) { + centrality = coll.centFT0C(); + if (useCentralityFT0M) + centrality = coll.centFT0M(); + if (useCentralityFT0A) + centrality = coll.centFV0A(); + if (useCentralityFT0Cvar1) + centrality = coll.centFT0CVariant1(); + + if (qaFlags.doBefSelEventMultCorr) { + histos.fill(HIST("hEventNchCorrelationBefCuts"), coll.multNTracksPVeta1(), coll.multNTracksGlobal()); + histos.fill(HIST("hEventPVcontributorsVsCentralityBefCuts"), centrality, coll.multNTracksPVeta1()); + histos.fill(HIST("hEventGlobalTracksVsCentralityBefCuts"), centrality, coll.multNTracksGlobal()); + } - if (centrality > centMax || centrality < centMin) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 4.5 /* collisions after centrality sel*/); + if (centrality > eventSelectionCommonFlags.centMax || centrality < eventSelectionCommonFlags.centMin) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 4.5 /* collisions after centrality sel*/); - if (eventSelectionFlags.doSameBunchPileUpEventCut && !coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 5.5 /* Not same Bunch pile up */); + if (eventSelectionRun3Flags.doSameBunchPileUpEventCut && !coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 5.5 /* Not same Bunch pile up */); - if (eventSelectionFlags.doGoodPVFT0EventCut && !coll.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 6.5 /* No large vertexZ difference from tracks and FT0*/); + if (eventSelectionRun3Flags.doGoodPVFT0EventCut && !coll.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 6.5 /* No large vertexZ difference from tracks and FT0*/); - if (eventSelectionFlags.doITSTPCvertexEventCut && !coll.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 7.5 /* At least one ITS-TPC track in the event*/); + if (eventSelectionRun3Flags.doITSTPCvertexEventCut && !coll.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 7.5 /* At least one ITS-TPC track in the event*/); - if (eventSelectionFlags.doVertexTOFmatch && !coll.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 8.5 /* At least one of vertex contributors is matched to TOF*/); + if (eventSelectionRun3Flags.doVertexTOFmatch && !coll.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 8.5 /* At least one of vertex contributors is matched to TOF*/); - if (eventSelectionFlags.doVertexTRDmatch && !coll.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 9.5 /* At least one of vertex contributors is matched to TRD*/); + if (eventSelectionRun3Flags.doVertexTRDmatch && !coll.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 9.5 /* At least one of vertex contributors is matched to TRD*/); - if (eventSelectionFlags.doITSFrameBorderCut && !coll.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 10.5 /* Not at ITS ROF border */); + if (eventSelectionRun3Flags.doITSFrameBorderCut && !coll.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 10.5 /* Not at ITS ROF border */); - if (eventSelectionFlags.doTFeventCut && !coll.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 11.5 /* Not at TF border */); + if (eventSelectionRun3Flags.doTFeventCut && !coll.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 11.5 /* Not at TF border */); - if (eventSelectionFlags.doMultiplicityCorrCut) { - if (coll.multNTracksGlobal() < (1343.3 * std::exp(-0.0443259 * centrality) - 50) || coll.multNTracksGlobal() > (2098.9 * std::exp(-0.0332444 * centrality))) + if (eventSelectionRun3Flags.doMultiplicityCorrCut) { + if (coll.multNTracksGlobal() < (1343.3 * std::exp(-0.0443259 * centrality) - 50) || coll.multNTracksGlobal() > (2098.9 * std::exp(-0.0332444 * centrality))) + return false; + if (coll.multNTracksPVeta1() < (3703 * std::exp(-0.0455483 * centrality) - 150) || coll.multNTracksPVeta1() > (4937.33 * std::exp(-0.0372668 * centrality) + 20)) + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 12.5 /* Remove outlyers */); + + if (eventSelectionRun3Flags.doTimeRangeStrictCut && !coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { return false; - if (coll.multNTracksPVeta1() < (3703 * std::exp(-0.0455483 * centrality) - 150) || coll.multNTracksPVeta1() > (4937.33 * std::exp(-0.0372668 * centrality) + 20)) + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 13.5 /* Rejection of events too close in time, dtime +/- 10 μs */); + + if (eventSelectionRun3Flags.doTimeRangeStandardCut && !coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 12.5 /* Remove outlyers */); + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 14.5 /* No other collision within +/- 2 μs, or mult above some threshold in -4..-2 μs */); - if (eventSelectionFlags.doTimeRangeStrictCut && !coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 13.5 /* Rejection of events too close in time, dtime +/- 10 μs */); + occupancy = coll.trackOccupancyInTimeRange(); + if (eventSelectionRun3Flags.minOccupancy > 0 && occupancy < eventSelectionRun3Flags.minOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 15.5 /* Below min occupancy */); + if (eventSelectionRun3Flags.maxOccupancy > 0 && occupancy > eventSelectionRun3Flags.maxOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 16.5 /* Above max occupancy */); - if (eventSelectionFlags.doTimeRangeStandardCut && !coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 14.5 /* No other collision within +/- 2 μs, or mult above some threshold in -4..-2 μs */); + if (eventSelectionRun3Flags.doNoCollInRofStrictCut && !coll.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 17.5 /*rejects a collision if there are other events within the same ITS ROF*/); - int occupancy = coll.trackOccupancyInTimeRange(); - if (minOccupancy > 0 && occupancy < minOccupancy) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 15.5 /* Below min occupancy */); - if (maxOccupancy > 0 && occupancy > maxOccupancy) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 16.5 /* Above max occupancy */); + if (eventSelectionRun3Flags.doNoCollInRofStandardCut && !coll.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 18.5 /*rejects a collision if there are other events within the same ITS ROF above mult threshold*/); - if (eventSelectionFlags.doNoCollInRofStrictCut && !coll.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 17.5 /*rejects a collision if there are other events within the same ITS ROF*/); + if (eventSelectionRun3Flags.doITSallLayersCut && !coll.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 19.5 /*rejects collisions if ITS was in rebooting stage*/); - if (eventSelectionFlags.doNoCollInRofStandardCut && !coll.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 18.5 /*rejects a collision if there are other events within the same ITS ROF above mult threshold*/); + occupancyFT0 = coll.ft0cOccupancyInTimeRange(); + if (eventSelectionRun3Flags.minOccupancyFT0 > -1 && occupancyFT0 < eventSelectionRun3Flags.minOccupancyFT0) { + return false; + } + if (eventSelectionRun3Flags.maxOccupancyFT0 > -1 && occupancyFT0 > eventSelectionRun3Flags.maxOccupancyFT0) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 20.5 /* Occupancy FT0 selection */); - if (eventSelectionFlags.doTimeRangeVzDependent && !coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeVzDependent)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 19.5 /*rejects collision with pvZ of drifting TPC tracks from past/future collisions within 2.5 cm the current pvZ*/); + interactionRate = rateFetcher.fetch(ccdb.service, coll.timestamp(), coll.runNumber(), irSource) * 1.e-3; + } else { + centrality = eventSelectionRun2Flags.useSPDTrackletsCent ? coll.centRun2SPDTracklets() : coll.centRun2V0M(); - float occupancyFT0 = coll.ft0cOccupancyInTimeRange(); - if (minOccupancyFT0 > 0 && occupancyFT0 < minOccupancyFT0) { - return false; - } - if (maxOccupancyFT0 > 0 && occupancyFT0 > maxOccupancyFT0) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 20.5 /* Occupancy FT0 selection */); + if (centrality > eventSelectionCommonFlags.centMax || centrality < eventSelectionCommonFlags.centMin) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 4.5 /* collisions after centrality sel*/); + + if (eventSelectionRun2Flags.doSel7 && !coll.sel7()) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 5.5 /* sel7 selection */); + + if (eventSelectionRun2Flags.doINT7 && !coll.alias_bit(kINT7)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 6.5 /* INT7-triggered collisions */); + if (eventSelectionRun2Flags.doIncompleteDAQCut && !coll.selection_bit(o2::aod::evsel::kNoIncompleteDAQ)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 7.5 /* Complete events according to DAQ flags */); + + if (eventSelectionRun2Flags.doConsistentSPDAndTrackVtx && !coll.selection_bit(o2::aod::evsel::kNoInconsistentVtx)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 8.5 /* No inconsistency in SPD and Track vertices */); + if (eventSelectionRun2Flags.doPileupFromSPDCut && !coll.selection_bit(o2::aod::evsel::kNoPileupFromSPD)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 9.5 /* No pileup according to SPD vertexer */); + if (eventSelectionRun2Flags.doV0PFPileupCut && !coll.selection_bit(o2::aod::evsel::kNoV0PFPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 10.5 /* No out-of-bunch pileup according to V0 past-future info */); + + if (eventSelectionRun2Flags.doPileupInMultBinsCut && !coll.selection_bit(o2::aod::evsel::kNoPileupInMultBins)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 11.5 /* No pileup according to multiplicity-differential pileup checks */); + + if (eventSelectionRun2Flags.doPileupMVCut && !coll.selection_bit(o2::aod::evsel::kNoPileupMV)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 12.5 /* No pileup according to multi-vertexer */); - if (eventSelectionFlags.doInel1 && coll.multNTracksPVeta1() <= 1) { + if (eventSelectionRun2Flags.doTPCPileupCut && !coll.selection_bit(o2::aod::evsel::kNoPileupTPC)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 13.5 /* No pileup in TPC */); + + if (eventSelectionRun2Flags.doNoV0MOnVsOffPileup && !coll.selection_bit(o2::aod::evsel::kNoV0MOnVsOfPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 14.5 /* No out-of-bunch pileup according to online-vs-offline VOM correlation */); + + if (eventSelectionRun2Flags.doNoSPDOnVsOffPileup && !coll.selection_bit(o2::aod::evsel::kNoSPDOnVsOfPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 15.5 /* No out-of-bunch pileup according to online-vs-offline SPD correlation */); + + if (eventSelectionRun2Flags.doNoSPDClsVsTklBG && !coll.selection_bit(o2::aod::evsel::kNoSPDClsVsTklBG)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 16.5 /* No beam-gas according to cluster-vs-tracklet correlation */); + } + if (eventSelectionCommonFlags.doInel0 && coll.multNTracksPVeta1() < 1) { return false; } if (fillHists) - histos.fill(HIST("hEventSelection"), 21.5 /* INEL > 1 selection */); + histos.fill(HIST("hEventSelection"), 27.5 /* INEL > 0 selection */); if (fillHists) { + histos.fill(HIST("hInteractionRate"), interactionRate); + histos.fill(HIST("hCentralityVsInteractionRate"), centrality, interactionRate); histos.fill(HIST("hOccupancyVsOccupFt0VsCentrality"), occupancy, occupancyFT0, centrality); histos.fill(HIST("hEventCentrality"), centrality); histos.fill(HIST("hEventVertexZ"), coll.posZ()); @@ -608,6 +863,8 @@ struct Derivedcascadeanalysis { } histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = casc.dcacascdaughters(); ++counter; } @@ -618,6 +875,8 @@ struct Derivedcascadeanalysis { return false; histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = casc.dcaV0daughters(); ++counter; } @@ -639,6 +898,8 @@ struct Derivedcascadeanalysis { return false; histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = casc.cascradius(); counter += 2; } @@ -659,6 +920,8 @@ struct Derivedcascadeanalysis { return false; histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = casc.v0radius(); counter += 2; } @@ -676,6 +939,8 @@ struct Derivedcascadeanalysis { } histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = casc.bachBaryonDCAxyToPV(); ++counter; } @@ -684,6 +949,8 @@ struct Derivedcascadeanalysis { return false; histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = std::acos(casc.v0cosPA(casc.x(), casc.y(), casc.z())); ++counter; } @@ -705,36 +972,123 @@ struct Derivedcascadeanalysis { histos.fill(HIST("hCutValue"), 13, cut); cut = candidateSelectionValues.dcaBaryonToPV; histos.fill(HIST("hCutValue"), 13, cut); - if (candidateSelectionFlags.doDCAdauToPVCut) { - if (std::abs(casc.dcabachtopv()) < candidateSelectionValues.dcaBachToPV) + if (candidateSelectionFlags.doDCAbachToPVCut || candidateSelectionFlags.doDCAmesonToPVCut || candidateSelectionFlags.doDCAbaryonToPVCut) { + if (candidateSelectionFlags.doDCAbachToPVCut && std::abs(casc.dcabachtopv()) < candidateSelectionValues.dcaBachToPV) return false; - if (casc.sign() > 0 && (std::abs(casc.dcanegtopv()) < candidateSelectionValues.dcaBaryonToPV || std::abs(casc.dcapostopv()) < candidateSelectionValues.dcaMesonToPV)) + if (casc.sign() > 0 && ((std::abs(casc.dcanegtopv()) < candidateSelectionValues.dcaBaryonToPV && candidateSelectionFlags.doDCAbaryonToPVCut) || (std::abs(casc.dcapostopv()) < candidateSelectionValues.dcaMesonToPV && candidateSelectionFlags.doDCAmesonToPVCut))) return false; - if (casc.sign() < 0 && (std::abs(casc.dcapostopv()) < candidateSelectionValues.dcaBaryonToPV || std::abs(casc.dcanegtopv()) < candidateSelectionValues.dcaMesonToPV)) + if (casc.sign() < 0 && ((std::abs(casc.dcapostopv()) < candidateSelectionValues.dcaBaryonToPV && candidateSelectionFlags.doDCAbaryonToPVCut) || (std::abs(casc.dcanegtopv()) < candidateSelectionValues.dcaMesonToPV && candidateSelectionFlags.doDCAmesonToPVCut))) return false; histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) { + if (!candidateSelectionFlags.doDCAbachToPVCut) + selectionCheck = std::abs(casc.dcabachtopv()); + if (!candidateSelectionFlags.doDCAbaryonToPVCut && casc.sign() > 0) + selectionCheck = std::abs(casc.dcanegtopv()); + if (!candidateSelectionFlags.doDCAbaryonToPVCut && casc.sign() < 0) + selectionCheck = std::abs(casc.dcapostopv()); + if (!candidateSelectionFlags.doDCAmesonToPVCut && casc.sign() > 0) + selectionCheck = std::abs(casc.dcapostopv()); + if (!candidateSelectionFlags.doDCAmesonToPVCut && casc.sign() < 0) + selectionCheck = std::abs(casc.dcanegtopv()); + } ++counter; } return true; } - - void processCascades(soa::Join::iterator const& coll, soa::Join const& Cascades, soa::Join const&) + void fillHistOccupancyCheck(double pt, double mass, float occup, float centrality, bool isPos) + { + static_for<0, 9>([&](auto i) { + constexpr int In = i.value; + if (centrality < kCentralityIntervals[In + 1] && centrality > kCentralityIntervals[In]) { + if (isPos) + histos.fill(HIST("InvMassAfterSelCent") + HIST(kCentIndex[In]) + HIST("/hPositiveCascade"), pt, mass, occup); + else + histos.fill(HIST("InvMassAfterSelCent") + HIST(kCentIndex[In]) + HIST("/hNegativeCascade"), pt, mass, occup); + } + }); + } + void fillHistIRCheckData(double pt, double mass, double ir, float centrality, bool isPos) + { + static_for<0, 9>([&](auto i) { + constexpr int In = i.value; + if (centrality < kCentralityIntervals[In + 1] && centrality > kCentralityIntervals[In]) { + if (isPos) + histos.fill(HIST("InvMassAfterSelCent") + HIST(kCentIndex[In]) + HIST("/hPositiveCascadeIR"), pt, mass, ir); + else + histos.fill(HIST("InvMassAfterSelCent") + HIST(kCentIndex[In]) + HIST("/hNegativeCascadeIR"), pt, mass, ir); + } + }); + } + void fillHistIRCheckMC(double pt, double mass, double ir, float centrality, bool isPos) + { + static_for<0, 9>([&](auto i) { + constexpr int In = i.value; + if (centrality < kCentralityIntervals[In + 1] && centrality > kCentralityIntervals[In]) { + if (isPos) + histos.fill(HIST("InvMassAfterSelCent") + HIST(kCentIndex[In]) + HIST("/hPositiveCascadeMCTruthIR"), pt, mass, ir); + else + histos.fill(HIST("InvMassAfterSelCent") + HIST(kCentIndex[In]) + HIST("/hNegativeCascadeMCTruthIR"), pt, mass, ir); + } + }); + } + void fillHistPtDepSelectionStudy(double pt, double mass, double sel, uint64_t selectionCheckMask, bool isPos) + { + static_for<0, 11>([&](auto i) { + constexpr int In = i.value; + if (TESTBIT(selectionCheckMask, In)) { + if (isPos) + histos.fill(HIST("PtDepCutStudy/hPositive") + HIST(kSelectionNames[In]), pt, mass, sel); + else + histos.fill(HIST("PtDepCutStudy/hNegative") + HIST(kSelectionNames[In]), pt, mass, sel); + } + }); + } + void fillHistPtDepSelectionStudyMC(double pt, double mass, double sel, uint64_t selectionCheckMask, bool isPos) + { + static_for<0, 11>([&](auto i) { + constexpr int In = i.value; + if (TESTBIT(selectionCheckMask, In)) { + if (isPos) + histos.fill(HIST("PtDepCutStudyMCTruth/hPositive") + HIST(kSelectionNames[In]), pt, mass, sel); + else + histos.fill(HIST("PtDepCutStudyMCTruth/hNegative") + HIST(kSelectionNames[In]), pt, mass, sel); + } + }); + } + template + void analyseCascades(TCollision const& coll, TCascade const& Cascades) //(soa::Join::iterator const& coll, soa::Join const& Cascades, DauTracks const&)//(TCollision const& coll, TCascade const& Cascades) { if (!isEventAccepted(coll, true)) return; - - float centrality = coll.centFT0C(); - if (!usePbPbCentrality) - centrality = coll.centFT0M(); + float centrality = -1; + float nChEta1 = -1; + float occupancy = -2; + + if constexpr (requires { coll.centFT0C(); }) { + nChEta1 = coll.multNTracksPVeta1(); + centrality = coll.centFT0C(); + if (useCentralityFT0M) + centrality = coll.centFT0M(); + if (useCentralityFT0A) + centrality = coll.centFV0A(); + if (useCentralityFT0Cvar1) + centrality = coll.centFT0CVariant1(); + occupancy = useTrackOccupancyDef ? coll.trackOccupancyInTimeRange() : coll.ft0cOccupancyInTimeRange(); + } else { + centrality = eventSelectionRun2Flags.useSPDTrackletsCent ? coll.centRun2SPDTracklets() : coll.centRun2V0M(); + } for (const auto& casc : Cascades) { int counter = -1; histos.fill(HIST("hCandidate"), ++counter); + double recoPt = casc.pt(); + bool isNegative = false; bool isPositive = false; if (casc.sign() > 0) @@ -744,27 +1098,54 @@ struct Derivedcascadeanalysis { if (!isNegative && !isPositive) continue; - double invmass; - if (isXi) - invmass = casc.mXi(); - else - invmass = casc.mOmega(); + double invmass = -10; + invmass = isXi ? casc.mXi() : casc.mOmega(); // To have trace of how it was before selections - if (qaFlags.doBefSelCheck) { if (isPositive) - histos.fill(HIST("InvMassBefSel/h") + HIST(kCharge[0]) + HIST("Cascade"), casc.pt(), invmass, centrality); + histos.fill(HIST("InvMassBefSel/hPositiveCascade"), recoPt, invmass, centrality); if (isNegative) - histos.fill(HIST("InvMassBefSel/h") + HIST(kCharge[1]) + HIST("Cascade"), casc.pt(), invmass, centrality); + histos.fill(HIST("InvMassBefSel/hNegativeCascade"), recoPt, invmass, centrality); + } + + bool isTrueMCCascade = false; + bool isTrueMCCascadeDecay = false; + bool isCorrectLambdaDecay = false; + float ptmc = -1; + + // MC part + if constexpr (requires { casc.has_cascMCCore(); }) { + if (!casc.has_cascMCCore()) + continue; + auto cascMC = casc.template cascMCCore_as>(); + ptmc = RecoDecay::sqrtSumOfSquares(cascMC.pxMC(), cascMC.pyMC()); + + if (cascMC.isPhysicalPrimary() && ((isXi && std::abs(cascMC.pdgCode()) == 3312) || (!isXi && std::abs(cascMC.pdgCode()) == 3334))) + isTrueMCCascade = true; + if (isTrueMCCascade && ((isPositive && cascMC.pdgCodePositive() == 211 && cascMC.pdgCodeNegative() == -2212) || (isNegative && cascMC.pdgCodePositive() == 2212 && cascMC.pdgCodeNegative() == -211))) + isCorrectLambdaDecay = true; + if (isTrueMCCascade && isCorrectLambdaDecay && ((isXi && std::abs(cascMC.pdgCodeBachelor()) == 211) || (!isXi && std::abs(cascMC.pdgCodeBachelor()) == 321))) + isTrueMCCascadeDecay = true; + + if (qaFlags.doBefSelCheck && isTrueMCCascade) { + if (isPositive) { + histos.fill(HIST("InvMassBefSel/hPositiveCascadePtForEfficiencyVsNchBefSel"), ptmc, invmass, nChEta1); + histos.fill(HIST("InvMassBefSel/hPositiveCascadePtForEfficiencyBefSel"), ptmc, invmass, centrality); + } + if (isNegative) { + histos.fill(HIST("InvMassBefSel/hNegativeCascadePtForEfficiencyVsNchBefSel"), ptmc, invmass, nChEta1); + histos.fill(HIST("InvMassBefSel/hNegativeCascadePtForEfficiencyBefSel"), ptmc, invmass, centrality); + } + } } if (!isCascadeCandidateAccepted(casc, counter, centrality)) continue; counter += 13; - auto negExtra = casc.negTrackExtra_as>(); - auto posExtra = casc.posTrackExtra_as>(); - auto bachExtra = casc.bachTrackExtra_as>(); + auto negExtra = casc.template negTrackExtra_as>(); + auto posExtra = casc.template posTrackExtra_as>(); + auto bachExtra = casc.template bachTrackExtra_as>(); auto poseta = RecoDecay::eta(std::array{casc.pxpos(), casc.pypos(), casc.pzpos()}); auto negeta = RecoDecay::eta(std::array{casc.pxneg(), casc.pyneg(), casc.pzneg()}); @@ -785,6 +1166,8 @@ struct Derivedcascadeanalysis { continue; histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = std::acos(casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ())); ++counter; } @@ -795,10 +1178,12 @@ struct Derivedcascadeanalysis { continue; histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = std::abs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())); ++counter; } - if (casc.sign() < 0) { + if (isNegative) { if (qaFlags.doFillNsigmaTPCHistProton) histos.fill(HIST("hNsigmaProton"), posExtra.tpcNSigmaPr(), fullMomentumPosDaugh, centrality); if (qaFlags.doFillNsigmaTPCHistV0Pion) @@ -808,7 +1193,7 @@ struct Derivedcascadeanalysis { if (qaFlags.doFillNsigmaTPCHistPionBach && !isXi) histos.fill(HIST("hNsigmaKaon"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, centrality); - } else if (casc.sign() > 0) { + } else { if (qaFlags.doFillNsigmaTPCHistV0Pion) histos.fill(HIST("hNsigmaPionPos"), posExtra.tpcNSigmaPi(), fullMomentumPosDaugh, centrality); if (qaFlags.doFillNsigmaTPCHistProton) @@ -819,7 +1204,7 @@ struct Derivedcascadeanalysis { histos.fill(HIST("hNsigmaKaon"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, centrality); } - if (casc.sign() < 0) { + if (isNegative) { if (candidateSelectionFlags.doNTPCSigmaCut) { if (std::abs(posExtra.tpcNSigmaPr()) > candidateSelectionValues.nsigmatpcPr || std::abs(negExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi) continue; @@ -827,7 +1212,7 @@ struct Derivedcascadeanalysis { } else { ++counter; } - } else if (casc.sign() > 0) { + } else { if (candidateSelectionFlags.doNTPCSigmaCut) { if (std::abs(posExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi || std::abs(negExtra.tpcNSigmaPr()) > candidateSelectionValues.nsigmatpcPr) continue; @@ -837,6 +1222,41 @@ struct Derivedcascadeanalysis { } } + histos.fill(HIST("hNCrossedRowsBachelor"), bachExtra.tpcCrossedRows()); + histos.fill(HIST("hNCrossedRowsNegative"), negExtra.tpcCrossedRows()); + histos.fill(HIST("hNCrossedRowsPositive"), posExtra.tpcCrossedRows()); + + if (qaFlags.doITSTPCmatchingCheck) { + auto ptPosDaugh = std::sqrt(std::pow(casc.pxpos(), 2) + std::pow(casc.pypos(), 2)); + auto ptNegDaugh = std::sqrt(std::pow(casc.pxneg(), 2) + std::pow(casc.pyneg(), 2)); + auto ptBachelor = std::sqrt(std::pow(casc.pxbach(), 2) + std::pow(casc.pybach(), 2)); + + histos.fill(HIST("histITSTPCmatchPosTrack"), ptPosDaugh, centrality, 0.5); + histos.fill(HIST("histITSTPCmatchNegTrack"), ptNegDaugh, centrality, 0.5); + histos.fill(HIST("histITSTPCmatchBachTrack"), ptBachelor, centrality, 0.5); + if (candidateSelectionFlags.doAllTracksMinITSClusters) { + if (posExtra.hasITS() && posExtra.itsNCls() >= candidateSelectionValues.minITSclusters) + histos.fill(HIST("histITSTPCmatchPosTrack"), ptPosDaugh, centrality, 1.5); + if (negExtra.hasITS() && negExtra.itsNCls() >= candidateSelectionValues.minITSclusters) + histos.fill(HIST("histITSTPCmatchNegTrack"), ptNegDaugh, centrality, 1.5); + if (bachExtra.hasITS() && bachExtra.itsNCls() >= candidateSelectionValues.minITSclusters) + histos.fill(HIST("histITSTPCmatchBachTrack"), ptBachelor, centrality, 1.5); + if (posExtra.hasITS() && posExtra.itsNCls() >= candidateSelectionValues.minITSclusters && posExtra.hasTPC() && std::abs(posExtra.tpcCrossedRows()) >= candidateSelectionValues.mintpccrrows) + histos.fill(HIST("histITSTPCmatchPosTrack"), ptPosDaugh, centrality, 2.5); + if (negExtra.hasITS() && negExtra.itsNCls() >= candidateSelectionValues.minITSclusters && negExtra.hasTPC() && std::abs(negExtra.tpcCrossedRows()) >= candidateSelectionValues.mintpccrrows) + histos.fill(HIST("histITSTPCmatchNegTrack"), ptNegDaugh, centrality, 2.5); + if (bachExtra.hasITS() && bachExtra.itsNCls() >= candidateSelectionValues.minITSclusters && bachExtra.hasTPC() && std::abs(bachExtra.tpcCrossedRows()) >= candidateSelectionValues.mintpccrrows) + histos.fill(HIST("histITSTPCmatchBachTrack"), ptBachelor, centrality, 2.5); + } else { + if (posExtra.hasTPC() && std::abs(posExtra.tpcCrossedRows()) >= candidateSelectionValues.mintpccrrows) + histos.fill(HIST("histITSTPCmatchPosTrack"), ptPosDaugh, centrality, 2.5); + if (negExtra.hasTPC() && std::abs(negExtra.tpcCrossedRows()) >= candidateSelectionValues.mintpccrrows) + histos.fill(HIST("histITSTPCmatchNegTrack"), ptNegDaugh, centrality, 2.5); + if (bachExtra.hasTPC() && std::abs(bachExtra.tpcCrossedRows()) >= candidateSelectionValues.mintpccrrows) + histos.fill(HIST("histITSTPCmatchBachTrack"), ptBachelor, centrality, 2.5); + } + } + if (std::abs(posExtra.tpcCrossedRows()) < candidateSelectionValues.mintpccrrows || std::abs(negExtra.tpcCrossedRows()) < candidateSelectionValues.mintpccrrows || std::abs(bachExtra.tpcCrossedRows()) < candidateSelectionValues.mintpccrrows) continue; histos.fill(HIST("hCandidate"), ++counter); @@ -890,6 +1310,19 @@ struct Derivedcascadeanalysis { } } + if (candidateSelectionFlags.doAtLeastOneTrackAB) { + if (bachExtra.hasITSTracker() && negExtra.hasITSTracker() && posExtra.hasITSTracker()) + continue; + } + if (candidateSelectionFlags.doBachelorITSTracking) { + if (!bachExtra.hasITSTracker()) + continue; + } + if (candidateSelectionFlags.doAllTracksMinITSClusters) { + if (bachExtra.itsNCls() < candidateSelectionValues.minITSclusters || posExtra.itsNCls() < candidateSelectionValues.minITSclusters || negExtra.itsNCls() < candidateSelectionValues.minITSclusters) + continue; + } + if (isXi) { if (candidateSelectionFlags.doNTPCSigmaCut) { @@ -912,6 +1345,8 @@ struct Derivedcascadeanalysis { continue; histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = ctau; ++counter; } } else { @@ -935,385 +1370,55 @@ struct Derivedcascadeanalysis { continue; histos.fill(HIST("hCandidate"), ++counter); } else { + if (qaFlags.doPtDepCutStudy) + selectionCheck = ctau; ++counter; } } - if (isPositive) - histos.fill(HIST("InvMassAfterSel/h") + HIST(kCharge[0]) + HIST("Cascade"), casc.pt(), invmass, centrality); - if (isNegative) - histos.fill(HIST("InvMassAfterSel/h") + HIST(kCharge[1]) + HIST("Cascade"), casc.pt(), invmass, centrality); if (qaFlags.doOccupancyCheck) { - float occupancy = -1; - if (useTrackOccupancyDef) - occupancy = coll.trackOccupancyInTimeRange(); - if (useFT0OccupancyDef) - occupancy = coll.ft0cOccupancyInTimeRange(); - static_for<0, 9>([&](auto i) { - constexpr int In = i.value; - if (centrality < kCentralityIntervals[In + 1] && centrality > kCentralityIntervals[In]) { - if (isPositive) - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[In]) + HIST("/h") + HIST(kCharge[0]) + HIST("Cascade"), casc.pt(), invmass, occupancy); - if (isNegative) - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[In]) + HIST("/h") + HIST(kCharge[1]) + HIST("Cascade"), casc.pt(), invmass, occupancy); - } - }); + fillHistOccupancyCheck(recoPt, invmass, occupancy, centrality, isPositive); } - - float dcaMesonToPV = -10; - float dcaBaryonToPV = -10; if (isPositive) { - dcaMesonToPV = casc.dcanegtopv(); - dcaBaryonToPV = casc.dcapostopv(); - } - if (isNegative) { - dcaBaryonToPV = casc.dcanegtopv(); - dcaMesonToPV = casc.dcapostopv(); - } - double selections[] = {casc.bachBaryonDCAxyToPV(), - std::abs(casc.dcav0topv(casc.x(), casc.y(), casc.z())), - casc.v0radius(), - casc.cascradius(), - casc.dcaV0daughters(), - casc.dcacascdaughters(), - std::acos(casc.v0cosPA(casc.x(), casc.y(), casc.z())), - casc.dcabachtopv(), - dcaMesonToPV, - dcaBaryonToPV, - ctau}; - bool selectionToBeTested[] = {candidateSelectionFlags.doBachelorBaryonCut, - candidateSelectionFlags.doDCAV0ToPVCut, - candidateSelectionFlags.doV0RadiusCut, - candidateSelectionFlags.doCascadeRadiusCut, - candidateSelectionFlags.doDCAV0DauCut, - candidateSelectionFlags.doDCACascadeDauCut, - candidateSelectionFlags.doV0CosPaCut, - candidateSelectionFlags.doCascadeCosPaCut, - candidateSelectionFlags.doDCAdauToPVCut, - candidateSelectionFlags.doDCAdauToPVCut, - candidateSelectionFlags.doDCAdauToPVCut, - candidateSelectionFlags.doProperLifeTimeCut}; - - if (qaFlags.doPtDepCutStudy) { - static_for<0, 10>([&](auto i) { - constexpr int In = i.value; - if (!selectionToBeTested[In]) { - if (isPositive) - histos.fill(HIST("PtDepCutStudy/h") + HIST(kCharge[0]) + HIST(kSelectionNames[In]), casc.pt(), invmass, selections[In]); - if (isNegative) - histos.fill(HIST("PtDepCutStudy/h") + HIST(kCharge[1]) + HIST(kSelectionNames[In]), casc.pt(), invmass, selections[In]); - } - }); - } - } - } - void processCascadesMCrec(soa::Join::iterator const& coll, CascMCCandidates const& Cascades, DauTracks const&, soa::Join const&) //, , , soa::Join const& /*mccollisions*/, soa::Join const&) - // soa::Join const& Cascades, soa::Join const&) - { - if (!isEventAccepted(coll, true)) - return; - float centrality = coll.centFT0C(); - if (!usePbPbCentrality) - centrality = coll.centFT0M(); - for (const auto& casc : Cascades) { - float mass = -1; - if (isXi) - mass = casc.mXi(); - else - mass = casc.mOmega(); - - int counter = -1; - histos.fill(HIST("hCandidate"), ++counter); - - bool isNegative = false; - bool isPositive = false; - if (casc.sign() > 0) - isPositive = true; - if (casc.sign() < 0) - isNegative = true; - if (!isNegative && !isPositive) - continue; - // To have trace of how it was before selections - if (qaFlags.doBefSelCheck) { - if (isPositive) - histos.fill(HIST("InvMassBefSel/h") + HIST(kCharge[0]) + HIST("Cascade"), casc.pt(), mass, centrality); - if (isNegative) - histos.fill(HIST("InvMassBefSel/h") + HIST(kCharge[1]) + HIST("Cascade"), casc.pt(), mass, centrality); - } - - if (!casc.has_cascMCCore()) - continue; - auto cascMC = casc.cascMCCore_as>(); - - bool isTrueMCCascade = false; - bool isTrueMCCascadeDecay = false; - bool isCorrectLambdaDecay = false; - if (cascMC.isPhysicalPrimary() && ((isXi && std::abs(cascMC.pdgCode()) == 3312) || (!isXi && std::abs(cascMC.pdgCode()) == 3334))) - isTrueMCCascade = true; - if (isTrueMCCascade && ((isPositive && cascMC.pdgCodePositive() == 211 && cascMC.pdgCodeNegative() == -2212) || (isNegative && cascMC.pdgCodePositive() == 2212 && cascMC.pdgCodeNegative() == -211))) - isCorrectLambdaDecay = true; - if (isTrueMCCascade && isCorrectLambdaDecay && ((isXi && std::abs(cascMC.pdgCodeBachelor()) == 211) || (!isXi && std::abs(cascMC.pdgCodeBachelor()) == 321))) - isTrueMCCascadeDecay = true; - float ptmc = RecoDecay::sqrtSumOfSquares(cascMC.pxMC(), cascMC.pyMC()); - - if (!isCascadeCandidateAccepted(casc, counter, centrality)) - continue; - counter += 13; - - auto negExtra = casc.negTrackExtra_as>(); - auto posExtra = casc.posTrackExtra_as>(); - auto bachExtra = casc.bachTrackExtra_as>(); - - auto poseta = RecoDecay::eta(std::array{casc.pxpos(), casc.pypos(), casc.pzpos()}); - auto negeta = RecoDecay::eta(std::array{casc.pxneg(), casc.pyneg(), casc.pzneg()}); - auto bacheta = RecoDecay::eta(std::array{casc.pxbach(), casc.pybach(), casc.pzbach()}); - - auto fullMomentumPosDaugh = std::sqrt(std::pow(casc.pxpos(), 2) + std::pow(casc.pypos(), 2) + std::pow(casc.pzpos(), 2)); - auto fullmomentumNegDaugh = std::sqrt(std::pow(casc.pxneg(), 2) + std::pow(casc.pyneg(), 2) + std::pow(casc.pzneg(), 2)); - auto fullmomentumBachelor = std::sqrt(std::pow(casc.pxbach(), 2) + std::pow(casc.pybach(), 2) + std::pow(casc.pzbach(), 2)); - - if (std::abs(poseta) > candidateSelectionValues.etaDauCut || std::abs(negeta) > candidateSelectionValues.etaDauCut || std::abs(bacheta) > candidateSelectionValues.etaDauCut) - continue; - histos.fill(HIST("hCandidate"), ++counter); - - if (candidateSelectionFlags.doCascadeCosPaCut) { - if (!isCosPAAccepted(casc, coll.posX(), coll.posY(), coll.posZ(), candidateSelectionFlags.doPtDepCosPaCut, true)) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else { - ++counter; - } - - if (candidateSelectionFlags.doDCAV0ToPVCut) { - if (std::abs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())) < candidateSelectionValues.dcaV0ToPV) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else { - ++counter; - } - - if (isNegative) { - if (qaFlags.doFillNsigmaTPCHistProton) - histos.fill(HIST("hNsigmaProton"), posExtra.tpcNSigmaPr(), fullMomentumPosDaugh, centrality); - if (qaFlags.doFillNsigmaTPCHistV0Pion) - histos.fill(HIST("hNsigmaPionNeg"), negExtra.tpcNSigmaPi(), fullmomentumNegDaugh, centrality); - if (qaFlags.doFillNsigmaTPCHistPionBach && isXi) - histos.fill(HIST("hNsigmaPionNegBach"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, centrality); - if (qaFlags.doFillNsigmaTPCHistPionBach && !isXi) - histos.fill(HIST("hNsigmaKaon"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, centrality); - - if (candidateSelectionFlags.doNTPCSigmaCut) { - if (std::abs(posExtra.tpcNSigmaPr()) > candidateSelectionValues.nsigmatpcPr || std::abs(negExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else { - ++counter; + histos.fill(HIST("InvMassAfterSel/hPositiveCascade"), recoPt, invmass, centrality); + if (isTrueMCCascadeDecay) { + histos.fill(HIST("hPositiveCascadePtForEfficiency"), ptmc, invmass, centrality); + histos.fill(HIST("hPositiveCascadePtForEfficiencyVsNch"), ptmc, invmass, nChEta1); } - } - if (isPositive) { - if (qaFlags.doFillNsigmaTPCHistV0Pion) - histos.fill(HIST("hNsigmaPionPos"), posExtra.tpcNSigmaPi(), fullMomentumPosDaugh, centrality); - if (qaFlags.doFillNsigmaTPCHistProton) - histos.fill(HIST("hNsigmaProtonNeg"), negExtra.tpcNSigmaPr(), fullmomentumNegDaugh, centrality); - if (qaFlags.doFillNsigmaTPCHistPionBach && isXi) - histos.fill(HIST("hNsigmaPionPosBach"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, centrality); - if (qaFlags.doFillNsigmaTPCHistPionBach && !isXi) - histos.fill(HIST("hNsigmaKaon"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, centrality); - - if (candidateSelectionFlags.doNTPCSigmaCut) { - if (std::abs(posExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi || std::abs(negExtra.tpcNSigmaPr()) > candidateSelectionValues.nsigmatpcPr) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else { - ++counter; - } - } - - if (std::abs(posExtra.tpcCrossedRows()) < candidateSelectionValues.mintpccrrows || std::abs(negExtra.tpcCrossedRows()) < candidateSelectionValues.mintpccrrows || std::abs(bachExtra.tpcCrossedRows()) < candidateSelectionValues.mintpccrrows) - continue; - histos.fill(HIST("hCandidate"), ++counter); - - bool kHasTOF = (posExtra.hasTOF() || negExtra.hasTOF() || bachExtra.hasTOF()); - bool kHasITS = (posExtra.hasITS() || negExtra.hasITS() || bachExtra.hasITS()); - if (candidateSelectionFlags.dooobrej == 1) { - if (!kHasTOF && !kHasITS) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else if (candidateSelectionFlags.dooobrej == 2) { - if (!kHasTOF && (casc.pt() > candidateSelectionValues.ptthrtof)) - continue; - histos.fill(HIST("hCandidate"), ++counter); + if (isTrueMCCascadeDecay) + histos.fill(HIST("InvMassAfterSelMCrecTruth/hPositiveCascade"), ptmc, invmass, centrality); } else { - ++counter; - } - - float cascpos = std::hypot(casc.x() - coll.posX(), casc.y() - coll.posY(), casc.z() - coll.posZ()); - float cascptotmom = std::hypot(casc.px(), casc.py(), casc.pz()); - float ctau = -10; - - if (posExtra.hasTOF()) { - if (candidateSelectionFlags.doNTOFSigmaProtonCut && isNegative) { - histos.fill(HIST("hNsigmaTOFProton"), casc.tofNSigmaXiLaPr(), fullMomentumPosDaugh, centrality); - if (std::abs(casc.tofNSigmaXiLaPr()) > candidateSelectionValues.nsigmatofPr && fullMomentumPosDaugh > 0.6) - continue; - } - if (candidateSelectionFlags.doNTOFSigmaV0PionCut && isPositive) { - histos.fill(HIST("hNsigmaTOFV0Pion"), casc.tofNSigmaXiLaPi(), fullMomentumPosDaugh, centrality); - if (std::abs(casc.tofNSigmaXiLaPi()) > candidateSelectionValues.nsigmatofPion) - continue; + histos.fill(HIST("InvMassAfterSel/hNegativeCascade"), recoPt, invmass, centrality); + if (isTrueMCCascadeDecay) { + histos.fill(HIST("hNegativeCascadePtForEfficiency"), ptmc, invmass, centrality); + histos.fill(HIST("hNegativeCascadePtForEfficiencyVsNch"), ptmc, invmass, nChEta1); } + if (isTrueMCCascadeDecay) + histos.fill(HIST("InvMassAfterSelMCrecTruth/hNegativeCascade"), ptmc, invmass, centrality); } - if (negExtra.hasTOF()) { - if (candidateSelectionFlags.doNTOFSigmaProtonCut && isPositive) { - histos.fill(HIST("hNsigmaTOFProton"), casc.tofNSigmaXiLaPr(), fullmomentumNegDaugh, centrality); - if (std::abs(casc.tofNSigmaXiLaPr()) > candidateSelectionValues.nsigmatofPr && fullmomentumNegDaugh > 0.6) - continue; - } - if (candidateSelectionFlags.doNTOFSigmaV0PionCut && isNegative) { - histos.fill(HIST("hNsigmaTOFV0Pion"), casc.tofNSigmaXiLaPi(), fullmomentumNegDaugh, centrality); - if (std::abs(casc.tofNSigmaXiLaPi()) > candidateSelectionValues.nsigmatofPion) - continue; + if (qaFlags.doIRCheck) { + double interactionRate = -2; + if constexpr (requires { coll.trackOccupancyInTimeRange(); }) { + interactionRate = rateFetcher.fetch(ccdb.service, coll.timestamp(), coll.runNumber(), irSource) * 1.e-3; + fillHistIRCheckData(recoPt, invmass, interactionRate, centrality, isPositive); + if (isTrueMCCascadeDecay) + fillHistIRCheckMC(ptmc, invmass, interactionRate, centrality, isPositive); } } - if (isXi) { - if (candidateSelectionFlags.doNTPCSigmaCut) { - if (std::abs(bachExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else { - ++counter; - } - - if (bachExtra.hasTOF() && candidateSelectionFlags.doNTOFSigmaBachelorCut) { - histos.fill(HIST("hNsigmaTOFBachelorPion"), casc.tofNSigmaXiPi(), fullmomentumBachelor, centrality); - if (std::abs(casc.tofNSigmaXiPi()) > candidateSelectionValues.nsigmatofBachPion) - continue; - } - - ctau = o2::constants::physics::MassXiMinus * cascpos / ((cascptotmom + 1e-13) * ctauxiPDG); - } else { - if (candidateSelectionFlags.doNTPCSigmaCut) { - if (std::abs(bachExtra.tpcNSigmaKa()) > candidateSelectionValues.nsigmatpcKa) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else { - ++counter; - } - - if (bachExtra.hasTOF() && candidateSelectionFlags.doNTOFSigmaBachelorCut) { - histos.fill(HIST("hNsigmaTOFBachelorKaon"), casc.tofNSigmaOmKa(), fullmomentumBachelor, centrality); - if (std::abs(casc.tofNSigmaOmKa()) > candidateSelectionValues.nsigmatofBachKaon) - continue; - } - - ctau = o2::constants::physics::MassOmegaMinus * cascpos / ((cascptotmom + 1e-13) * ctauomegaPDG); - } - - if (candidateSelectionFlags.doProperLifeTimeCut) { - if (ctau > candidateSelectionValues.proplifetime) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else { - ++counter; - } - - if (isPositive) { - histos.fill(HIST("InvMassAfterSel/h") + HIST(kCharge[0]) + HIST("Cascade"), casc.pt(), mass, centrality); - if (isTrueMCCascadeDecay) - histos.fill(HIST("hPositiveCascadePtForEfficiency"), ptmc, mass, centrality); - } - if (isNegative) { - histos.fill(HIST("InvMassAfterSel/h") + HIST(kCharge[1]) + HIST("Cascade"), casc.pt(), mass, centrality); - if (isTrueMCCascadeDecay) - histos.fill(HIST("hNegativeCascadePtForEfficiency"), ptmc, mass, centrality); - } - if (isTrueMCCascade) { - if (isPositive) - histos.fill(HIST("InvMassAfterSelMCrecTruth/h") + HIST(kCharge[0]) + HIST("Cascade"), ptmc, mass, centrality); - if (isNegative) - histos.fill(HIST("InvMassAfterSelMCrecTruth/h") + HIST(kCharge[1]) + HIST("Cascade"), ptmc, mass, centrality); - } - if (qaFlags.doOccupancyCheck) { - float occupancy = -1; - if (useTrackOccupancyDef) - occupancy = coll.trackOccupancyInTimeRange(); - if (useFT0OccupancyDef) - occupancy = coll.ft0cOccupancyInTimeRange(); - static_for<0, 9>([&](auto i) { - constexpr int In = i.value; - if (centrality < kCentralityIntervals[In + 1] && centrality > kCentralityIntervals[In]) { - if (isPositive) { - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[In]) + HIST("/h") + HIST(kCharge[0]) + HIST("Cascade"), casc.pt(), mass, occupancy); - if (isTrueMCCascadeDecay) - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[In]) + HIST("/h") + HIST(kCharge[0]) + HIST("CascadeMCTruth"), casc.pt(), mass, occupancy); - } - if (isNegative) { - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[In]) + HIST("/h") + HIST(kCharge[1]) + HIST("Cascade"), casc.pt(), mass, occupancy); - if (isTrueMCCascadeDecay) - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[In]) + HIST("/h") + HIST(kCharge[1]) + HIST("CascadeMCTruth"), casc.pt(), mass, occupancy); - } - } - }); - } - float dcaMesonToPV = -10; - float dcaBaryonToPV = -10; - if (isPositive) { - dcaMesonToPV = casc.dcanegtopv(); - dcaBaryonToPV = casc.dcapostopv(); - } - if (isNegative) { - dcaBaryonToPV = casc.dcanegtopv(); - dcaMesonToPV = casc.dcapostopv(); - } - double selections[] = {casc.bachBaryonDCAxyToPV(), - std::abs(casc.dcav0topv(casc.x(), casc.y(), casc.z())), - casc.v0radius(), - casc.cascradius(), - casc.dcaV0daughters(), - casc.dcacascdaughters(), - std::acos(casc.v0cosPA(casc.x(), casc.y(), casc.z())), - casc.dcabachtopv(), - dcaMesonToPV, - dcaBaryonToPV, - ctau}; - bool selectionToBeTested[] = {candidateSelectionFlags.doBachelorBaryonCut, - candidateSelectionFlags.doDCAV0ToPVCut, - candidateSelectionFlags.doV0RadiusCut, - candidateSelectionFlags.doCascadeRadiusCut, - candidateSelectionFlags.doDCAV0DauCut, - candidateSelectionFlags.doDCACascadeDauCut, - candidateSelectionFlags.doV0CosPaCut, - candidateSelectionFlags.doCascadeCosPaCut, - candidateSelectionFlags.doDCAdauToPVCut, - candidateSelectionFlags.doDCAdauToPVCut, - candidateSelectionFlags.doDCAdauToPVCut, - candidateSelectionFlags.doProperLifeTimeCut}; - - if (qaFlags.doPtDepCutStudy) { - static_for<0, 10>([&](auto i) { - constexpr int In = i.value; - if (!selectionToBeTested[In]) { - if (isPositive) - histos.fill(HIST("PtDepCutStudy/h") + HIST(kCharge[0]) + HIST(kSelectionNames[In]), casc.pt(), mass, selections[In]); - if (isNegative) - histos.fill(HIST("PtDepCutStudy/h") + HIST(kCharge[1]) + HIST(kSelectionNames[In]), casc.pt(), mass, selections[In]); - if (isTrueMCCascade) { - if (isPositive) - histos.fill(HIST("PtDepCutStudyMCTruth/h") + HIST(kCharge[0]) + HIST(kSelectionNames[In]), ptmc, mass, selections[In]); - if (isNegative) - histos.fill(HIST("PtDepCutStudyMCTruth/h") + HIST(kCharge[1]) + HIST(kSelectionNames[In]), ptmc, mass, selections[In]); - } - } - }); + if (qaFlags.doPtDepCutStudy && selectionCheck != -1) { + fillHistPtDepSelectionStudy(recoPt, invmass, selectionCheck, selectionCheckMask, isPositive); + if (isTrueMCCascade) + fillHistPtDepSelectionStudyMC(ptmc, invmass, selectionCheck, selectionCheckMask, isPositive); } } } - void processCascadesMCforEff(soa::Join const& mcCollisions, soa::Join const& Cascades, soa::Join const& collisions) + template + void analyseCascadesMCforEff(TMCCollisions const& mcCollisions, TCascMCs const& Cascades, TCollisions const& collisions) { - std::vector listBestCollisionIdx = fillGenEventHist(mcCollisions, collisions); + std::vector listBestCollisionIdx = fillGenEventHist(mcCollisions, collisions); for (auto const& cascMC : Cascades) { if (!cascMC.has_straMCCollision()) @@ -1332,58 +1437,107 @@ struct Derivedcascadeanalysis { if (std::abs(ymc) > candidateSelectionValues.rapCut) continue; - auto mcCollision = cascMC.straMCCollision_as>(); + auto mcCollision = cascMC.template straMCCollision_as>(); + if (eventSelectionCommonFlags.applyZVtxSelOnMCPV && std::abs(mcCollision.posZ()) > eventSelectionCommonFlags.zVertexCut) { + continue; + } + + if (eventSelectionCommonFlags.doInel0MCGen && mcCollision.multMCNParticlesEta10() < 1) { + continue; + } + float centrality = 100.5f; - float occupancy = 49000; + float occupancy = -2; + float nChEta1 = -1; + double intRate = -1; if (listBestCollisionIdx[mcCollision.globalIndex()] > -1) { auto collision = collisions.iteratorAt(listBestCollisionIdx[mcCollision.globalIndex()]); - centrality = collision.centFT0C(); - if (useTrackOccupancyDef) - occupancy = collision.trackOccupancyInTimeRange(); - if (useFT0OccupancyDef) - occupancy = collision.ft0cOccupancyInTimeRange(); + if constexpr (requires { collision.centFT0C(); }) { + intRate = rateFetcher.fetch(ccdb.service, collision.timestamp(), collision.runNumber(), irSource) * 1.e-3; + centrality = collision.centFT0C(); + if (useCentralityFT0M) + centrality = collision.centFT0M(); + if (useCentralityFT0A) + centrality = collision.centFV0A(); + if (useCentralityFT0Cvar1) + centrality = collision.centFT0CVariant1(); + if (useTrackOccupancyDef) + occupancy = collision.trackOccupancyInTimeRange(); + if (useFT0OccupancyDef) + occupancy = collision.ft0cOccupancyInTimeRange(); + } else { + centrality = eventSelectionRun2Flags.useSPDTrackletsCent ? collision.centRun2SPDTracklets() : collision.centRun2V0M(); + } + nChEta1 = collision.multNTracksPVeta1(); } - if (cascMC.pdgCode() == 3312) { + if (cascMC.pdgCode() == 3312 && isXi) { histos.fill(HIST("h2dGenXiMinus"), centrality, ptmc); + histos.fill(HIST("h2dGenXiMinusVsNch"), nChEta1, ptmc); histos.fill(HIST("h2dGenXiMinusEta"), RecoDecay::eta(std::array{cascMC.pxMC(), cascMC.pyMC(), cascMC.pzMC()})); histos.fill(HIST("h2dGenXiMinusEtaPosDaughter"), RecoDecay::eta(std::array{cascMC.pxPosMC(), cascMC.pyPosMC(), cascMC.pzPosMC()})); histos.fill(HIST("h2dGenXiMinusEtaNegDaughter"), RecoDecay::eta(std::array{cascMC.pxNegMC(), cascMC.pyNegMC(), cascMC.pzNegMC()})); histos.fill(HIST("h2dGenXiMinusEtaBach"), RecoDecay::eta(std::array{cascMC.pxBachMC(), cascMC.pyBachMC(), cascMC.pzBachMC()})); - histos.fill(HIST("h2dGenXiMinusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + histos.fill(HIST("h2dGenXiMinusVsMultMCVsCentrality"), mcCollision.multMCNParticlesEta05(), centrality, ptmc); + histos.fill(HIST("h2dGenXiMinusVsMultMCVsIR"), mcCollision.multMCNParticlesEta05(), intRate, ptmc); histos.fill(HIST("h2dGenXiMinusVsCentOccupancy"), ptmc, centrality, occupancy); + histos.fill(HIST("h2dGenXiMinusVsCentIR"), ptmc, centrality, intRate); + histos.fill(HIST("h2dGenXiMinusVsNchVsOccupancy"), ptmc, nChEta1, occupancy); } - if (cascMC.pdgCode() == -3312) { + if (cascMC.pdgCode() == -3312 && isXi) { histos.fill(HIST("h2dGenXiPlus"), centrality, ptmc); - histos.fill(HIST("h2dGenXiPlusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + histos.fill(HIST("h2dGenXiPlusVsNch"), nChEta1, ptmc); + histos.fill(HIST("h2dGenXiPlusVsMultMCVsCentrality"), mcCollision.multMCNParticlesEta05(), centrality, ptmc); + histos.fill(HIST("h2dGenXiPlusVsMultMCVsIR"), mcCollision.multMCNParticlesEta05(), intRate, ptmc); histos.fill(HIST("h2dGenXiPlusVsCentOccupancy"), ptmc, centrality, occupancy); + histos.fill(HIST("h2dGenXiPlusVsNchVsOccupancy"), ptmc, nChEta1, occupancy); + histos.fill(HIST("h2dGenXiPlusVsCentIR"), ptmc, centrality, intRate); } - if (cascMC.pdgCode() == 3334) { + if (cascMC.pdgCode() == 3334 && !isXi) { histos.fill(HIST("h2dGenOmegaMinus"), centrality, ptmc); + histos.fill(HIST("h2dGenOmegaMinusVsNch"), nChEta1, ptmc); histos.fill(HIST("h2dGenOmegaMinusEta"), RecoDecay::eta(std::array{cascMC.pxMC(), cascMC.pyMC(), cascMC.pzMC()})); histos.fill(HIST("h2dGenOmegaMinusEtaPosDaughter"), RecoDecay::eta(std::array{cascMC.pxPosMC(), cascMC.pyPosMC(), cascMC.pzPosMC()})); histos.fill(HIST("h2dGenOmegaMinusEtaNegDaughter"), RecoDecay::eta(std::array{cascMC.pxNegMC(), cascMC.pyNegMC(), cascMC.pzNegMC()})); histos.fill(HIST("h2dGenOmegaMinusEtaBach"), RecoDecay::eta(std::array{cascMC.pxBachMC(), cascMC.pyBachMC(), cascMC.pzBachMC()})); - histos.fill(HIST("h2dGenOmegaMinusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + histos.fill(HIST("h2dGenOmegaMinusVsMultMCVsCentrality"), mcCollision.multMCNParticlesEta05(), centrality, ptmc); + histos.fill(HIST("h2dGenOmegaMinusVsMultMCVsIR"), mcCollision.multMCNParticlesEta05(), intRate, ptmc); histos.fill(HIST("h2dGenOmegaMinusVsCentOccupancy"), ptmc, centrality, occupancy); + histos.fill(HIST("h2dGenOmegaMinusVsNchVsOccupancy"), ptmc, nChEta1, occupancy); + histos.fill(HIST("h2dGenOmegaMinusVsCentIR"), ptmc, centrality, intRate); } - if (cascMC.pdgCode() == -3334) { + if (cascMC.pdgCode() == -3334 && !isXi) { histos.fill(HIST("h2dGenOmegaPlus"), centrality, ptmc); - histos.fill(HIST("h2dGenOmegaPlusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + histos.fill(HIST("h2dGenOmegaPlusVsNch"), nChEta1, ptmc); + histos.fill(HIST("h2dGenOmegaPlusVsMultMCVsCentrality"), mcCollision.multMCNParticlesEta05(), centrality, ptmc); + histos.fill(HIST("h2dGenOmegaPlusVsMultMCVsIR"), mcCollision.multMCNParticlesEta05(), intRate, ptmc); histos.fill(HIST("h2dGenOmegaPlusVsCentOccupancy"), ptmc, centrality, occupancy); + histos.fill(HIST("h2dGenOmegaPlusVsNchVsOccupancy"), ptmc, nChEta1, occupancy); + histos.fill(HIST("h2dGenOmegaPlusVsCentIR"), ptmc, centrality, intRate); } } } // ______________________________________________________ // Simulated processing // Fill event information (for event loss estimation) and return the index to the recoed collision associated to a given MC collision. - std::vector fillGenEventHist(soa::Join const& mcCollisions, soa::Join const& collisions) + template + std::vector fillGenEventHist(TMCCollisions const& mcCollisions, TCollisions const& collisions) { std::vector listBestCollisionIdx(mcCollisions.size()); for (auto const& mcCollision : mcCollisions) { histos.fill(HIST("hGenEvents"), mcCollision.multMCNParticlesEta05(), 0.5 /* all gen. events*/); - auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex()); + if (eventSelectionCommonFlags.applyZVtxSelOnMCPV && std::abs(mcCollision.posZ()) > eventSelectionCommonFlags.zVertexCut) { + continue; + } + histos.fill(HIST("hGenEvents"), mcCollision.multMCNParticlesEta05(), 1.5 /* gen. events with vertex cut*/); + + if (eventSelectionCommonFlags.doInel0MCGen && mcCollision.multMCNParticlesEta10() < 1) { + continue; + } + histos.fill(HIST("hGenEvents"), mcCollision.multMCNParticlesEta05(), 2.5 /* gen. events with INEL>0t*/); + + auto groupedCollisions = getGroupedCollisions(collisions, mcCollision.globalIndex()); // Check if there is at least one of the reconstructed collisions associated to this MC collision // If so, we consider it bool atLeastOne = false; @@ -1391,6 +1545,8 @@ struct Derivedcascadeanalysis { int bestCollisionIndex = -1; float centrality = 100.5f; int nCollisions = 0; + float nChEta05 = -1; + double intRate = -1; for (auto const& collision : groupedCollisions) { if (!isEventAccepted(collision, false)) { continue; @@ -1399,7 +1555,18 @@ struct Derivedcascadeanalysis { if (biggestNContribs < collision.multPVTotalContributors()) { biggestNContribs = collision.multPVTotalContributors(); bestCollisionIndex = collision.globalIndex(); - centrality = collision.centFT0C(); + if constexpr (requires { collision.centFT0C(); }) { + centrality = collision.centFT0C(); + intRate = rateFetcher.fetch(ccdb.service, collision.timestamp(), collision.runNumber(), irSource) * 1.e-3; + if (useCentralityFT0M) + centrality = collision.centFT0M(); + if (useCentralityFT0A) + centrality = collision.centFV0A(); + if (useCentralityFT0Cvar1) + centrality = collision.centFT0CVariant1(); + } else { + centrality = eventSelectionRun2Flags.useSPDTrackletsCent ? collision.centRun2SPDTracklets() : collision.centRun2V0M(); + } } nCollisions++; @@ -1410,20 +1577,54 @@ struct Derivedcascadeanalysis { histos.fill(HIST("hCentralityVsNcoll_beforeEvSel"), centrality, groupedCollisions.size() + 0.5); histos.fill(HIST("hCentralityVsNcoll_afterEvSel"), centrality, nCollisions + 0.5); + histos.fill(HIST("hCentralityVsIRGen"), centrality, intRate); + histos.fill(HIST("hMultMCVsCentralityVsIRGen"), mcCollision.multMCNParticlesEta05(), centrality, intRate); + histos.fill(HIST("hCentralityVsMultMC"), centrality, mcCollision.multMCNParticlesEta05()); + histos.fill(HIST("hRecMultVsMultMC"), nChEta05, mcCollision.multMCNParticlesEta05()); histos.fill(HIST("hGenMultMCFT0C"), mcCollision.multMCFT0C()); histos.fill(HIST("hGenMCNParticlesEta10"), mcCollision.multMCNParticlesEta10()); if (atLeastOne) { - histos.fill(HIST("hGenEvents"), mcCollision.multMCNParticlesEta05(), 1.5 /* at least 1 rec. event*/); + histos.fill(HIST("hGenEvents"), mcCollision.multMCNParticlesEta05(), 3.5 /* at least 1 rec. event*/); } } return listBestCollisionIdx; } + + void processCascades(soa::Join::iterator const& coll, soa::Join const& Cascades, DauTracks const&) + { + analyseCascades(coll, Cascades); + } + void processCascadesRun2(soa::Join::iterator const& coll, soa::Join const& Cascades, DauTracks const&) + { + analyseCascades(coll, Cascades); + } + + void processCascadesMCrec(soa::Join::iterator const& coll, CascMCCandidates const& Cascades, DauTracks const&, soa::Join const&) + { + analyseCascades(coll, Cascades); + } + void processCascadesMCrecRun2(soa::Join::iterator const& coll, CascMCCandidates const& Cascades, DauTracks const&, soa::Join const&) + { + analyseCascades(coll, Cascades); + } + + void processCascadesMCforEff(soa::Join const& mcCollisions, soa::Join const& Cascades, soa::Join const& collisions) + { + analyseCascadesMCforEff(mcCollisions, Cascades, collisions); + } + void processCascadesMCforEffRun2(soa::Join const& mcCollisions, soa::Join const& Cascades, soa::Join const& collisions) + { + analyseCascadesMCforEff(mcCollisions, Cascades, collisions); + } PROCESS_SWITCH(Derivedcascadeanalysis, processCascades, "cascade analysis, run3 data ", true); + PROCESS_SWITCH(Derivedcascadeanalysis, processCascadesRun2, "cascade analysis, run2 data ", false); PROCESS_SWITCH(Derivedcascadeanalysis, processCascadesMCrec, "cascade analysis, run3 rec MC", false); + PROCESS_SWITCH(Derivedcascadeanalysis, processCascadesMCrecRun2, "cascade analysis, run2 rec MC", false); PROCESS_SWITCH(Derivedcascadeanalysis, processCascadesMCforEff, "cascade analysis, run3 rec MC", false); + PROCESS_SWITCH(Derivedcascadeanalysis, processCascadesMCforEffRun2, "cascade analysis, run2 rec MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx index d6e77a1bdc9..544ed23807a 100644 --- a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx @@ -9,6 +9,12 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // +/// \file derivedlambdakzeroanalysis.cxx +/// \brief V0s (K0s, Lambda and antiLambda) analysis task using derived data +/// +/// \author David Dobrigkeit Chinellato , Austrian Academy of Sciences & SMI +/// \author Romain Schotter , Austrian Academy of Sciences & SMI +// // V0 analysis task // ================ // @@ -26,13 +32,16 @@ #include #include #include +#include +#include +#include +#include #include -#include +#include #include #include #include -#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -42,6 +51,8 @@ #include "CommonConstants/MathConstants.h" #include "CommonConstants/PhysicsConstants.h" #include "Common/Core/trackUtilities.h" +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/DataModel/EventSelection.h" #include "PWGLF/DataModel/LFStrangenessTables.h" #include "PWGLF/DataModel/LFStrangenessMLTables.h" #include "PWGLF/DataModel/LFStrangenessPIDTables.h" @@ -60,19 +71,23 @@ using namespace o2::framework; using namespace o2::framework::expressions; using std::array; -using dauTracks = soa::Join; -using dauMCTracks = soa::Join; -using v0Candidates = soa::Join; -// using v0MCCandidates = soa::Join; -using v0MCCandidates = soa::Join; +using namespace o2::aod::rctsel; + +using DauTracks = soa::Join; +using DauMCTracks = soa::Join; +using V0Candidates = soa::Join; +// using V0McCandidates = soa::Join; +using V0McCandidates = soa::Join; // simple checkers, but ensure 64 bit integers -#define bitset(var, nbit) ((var) |= (static_cast(1) << static_cast(nbit))) -#define bitcheck(var, nbit) ((var) & (static_cast(1) << static_cast(nbit))) +#define BITSET(var, nbit) ((var) |= (static_cast(1) << static_cast(nbit))) +#define BITCHECK(var, nbit) ((var) & (static_cast(1) << static_cast(nbit))) struct derivedlambdakzeroanalysis { HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + bool isRun3; + // master analysis switches Configurable analyseK0Short{"analyseK0Short", true, "process K0Short-like candidates"}; Configurable analyseLambda{"analyseLambda", true, "process Lambda-like candidates"}; @@ -80,32 +95,53 @@ struct derivedlambdakzeroanalysis { Configurable calculateFeeddownMatrix{"calculateFeeddownMatrix", true, "fill feeddown matrix if MC"}; Configurable doPPAnalysis{"doPPAnalysis", false, "if in pp, set to true"}; + Configurable irSource{"irSource", "T0VTX", "Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"}; struct : ConfigurableGroup { Configurable requireSel8{"requireSel8", true, "require sel8 event selection"}; Configurable requireTriggerTVX{"requireTriggerTVX", true, "require FT0 vertex (acceptable FT0C-FT0A time difference) at trigger level"}; - Configurable rejectITSROFBorder{"rejectITSROFBorder", true, "reject events at ITS ROF border"}; - Configurable rejectTFBorder{"rejectTFBorder", true, "reject events at TF border"}; - Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "require events with at least one ITS-TPC track"}; - Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", true, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference"}; - Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", false, "require events with at least one of vertex contributors matched to TOF"}; - Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", false, "require events with at least one of vertex contributors matched to TRD"}; - Configurable rejectSameBunchPileup{"rejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC"}; - Configurable requireNoCollInTimeRangeStd{"requireNoCollInTimeRangeStd", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds"}; - Configurable requireNoCollInTimeRangeStrict{"requireNoCollInTimeRangeStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 10 microseconds"}; - Configurable requireNoCollInTimeRangeNarrow{"requireNoCollInTimeRangeNarrow", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds"}; - Configurable requireNoCollInTimeRangeVzDep{"requireNoCollInTimeRangeVzDep", false, "reject collisions corrupted by the cannibalism, with other collisions with pvZ of drifting TPC tracks from past/future collisions within 2.5 cm the current pvZ"}; - Configurable requireNoCollInROFStd{"requireNoCollInROFStd", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF with mult. above a certain threshold"}; - Configurable requireNoCollInROFStrict{"requireNoCollInROFStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF"}; + Configurable rejectITSROFBorder{"rejectITSROFBorder", true, "reject events at ITS ROF border (Run 3 only)"}; + Configurable rejectTFBorder{"rejectTFBorder", true, "reject events at TF border (Run 3 only)"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "require events with at least one ITS-TPC track (Run 3 only)"}; + Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", true, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference (Run 3 only)"}; + Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", false, "require events with at least one of vertex contributors matched to TOF (Run 3 only)"}; + Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", false, "require events with at least one of vertex contributors matched to TRD (Run 3 only)"}; + Configurable rejectSameBunchPileup{"rejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC (Run 3 only)"}; + Configurable requireNoCollInTimeRangeStd{"requireNoCollInTimeRangeStd", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds (Run 3 only)"}; + Configurable requireNoCollInTimeRangeStrict{"requireNoCollInTimeRangeStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 10 microseconds (Run 3 only)"}; + Configurable requireNoCollInTimeRangeNarrow{"requireNoCollInTimeRangeNarrow", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds (Run 3 only)"}; + Configurable requireNoCollInROFStd{"requireNoCollInROFStd", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF with mult. above a certain threshold (Run 3 only)"}; + Configurable requireNoCollInROFStrict{"requireNoCollInROFStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF (Run 3 only)"}; Configurable requireINEL0{"requireINEL0", true, "require INEL>0 event selection"}; Configurable requireINEL1{"requireINEL1", false, "require INEL>1 event selection"}; Configurable maxZVtxPosition{"maxZVtxPosition", 10., "max Z vtx position"}; + Configurable useEvtSelInDenomEff{"useEvtSelInDenomEff", false, "Consider event selections in the recoed <-> gen collision association for the denominator (or numerator) of the acc. x eff. (or signal loss)?"}; + Configurable applyZVtxSelOnMCPV{"applyZVtxSelOnMCPV", false, "Apply Z-vtx cut on the PV of the generated collision?"}; Configurable useFT0CbasedOccupancy{"useFT0CbasedOccupancy", false, "Use sum of FT0-C amplitudes for estimating occupancy? (if not, use track-based definition)"}; // fast check on occupancy Configurable minOccupancy{"minOccupancy", -1, "minimum occupancy from neighbouring collisions"}; Configurable maxOccupancy{"maxOccupancy", -1, "maximum occupancy from neighbouring collisions"}; + // fast check on interaction rate + Configurable minIR{"minIR", -1, "minimum IR collisions"}; + Configurable maxIR{"maxIR", -1, "maximum IR collisions"}; + + // Run 2 specific event selections + Configurable requireSel7{"requireSel7", true, "require sel7 event selection (Run 2 only: event selection decision based on V0A & V0C)"}; + Configurable requireINT7{"requireINT7", true, "require INT7 trigger selection (Run 2 only)"}; + Configurable rejectIncompleteDAQ{"rejectIncompleteDAQ", true, "reject events with incomplete DAQ (Run 2 only)"}; + Configurable requireConsistentSPDAndTrackVtx{"requireConsistentSPDAndTrackVtx", true, "reject events with inconsistent in SPD and Track vertices (Run 2 only)"}; + Configurable rejectPileupFromSPD{"rejectPileupFromSPD", true, "reject events with pileup according to SPD vertexer (Run 2 only)"}; + Configurable rejectV0PFPileup{"rejectV0PFPileup", false, "reject events tagged as OOB pileup according to V0 past-future info (Run 2 only)"}; + Configurable rejectPileupInMultBins{"rejectPileupInMultBins", true, "reject events tagged as pileup according to multiplicity-differential pileup checks (Run 2 only)"}; + Configurable rejectPileupMV{"rejectPileupMV", true, "reject events tagged as pileup according to according to multi-vertexer (Run 2 only)"}; + Configurable rejectTPCPileup{"rejectTPCPileup", false, "reject events tagged as pileup according to pileup in TPC (Run 2 only)"}; + Configurable requireNoV0MOnVsOffPileup{"requireNoV0MOnVsOffPileup", false, "reject events tagged as OOB pileup according to online-vs-offline VOM correlation (Run 2 only)"}; + Configurable requireNoSPDOnVsOffPileup{"requireNoSPDOnVsOffPileup", false, "reject events tagged as pileup according to online-vs-offline SPD correlation (Run 2 only)"}; + Configurable requireNoSPDClsVsTklBG{"requireNoSPDClsVsTklBG", true, "reject events tagged as beam-gas and pileup according to cluster-vs-tracklet correlation (Run 2 only)"}; + + Configurable useSPDTrackletsCent{"useSPDTrackletsCent", false, "Use SPD tracklets for estimating centrality? If not, use V0M-based centrality (Run 2 only)"}; } eventSelections; struct : ConfigurableGroup { @@ -130,17 +166,24 @@ struct derivedlambdakzeroanalysis { // Track quality Configurable minTPCrows{"minTPCrows", 70, "minimum TPC crossed rows"}; Configurable minITSclusters{"minITSclusters", -1, "minimum ITS clusters"}; + Configurable minTPCrowsOverFindableClusters{"minTPCrowsOverFindableClusters", -1, "minimum nbr of TPC crossed rows over findable clusters"}; + Configurable minTPCfoundOverFindableClusters{"minTPCfoundOverFindableClusters", -1, "minimum nbr of found over findable TPC clusters"}; + Configurable maxFractionTPCSharedClusters{"maxFractionTPCSharedClusters", 1e+09, "maximum fraction of TPC shared clusters"}; + Configurable maxITSchi2PerNcls{"maxITSchi2PerNcls", 1e+09, "maximum ITS chi2 per clusters"}; + Configurable maxTPCchi2PerNcls{"maxTPCchi2PerNcls", 1e+09, "maximum TPC chi2 per clusters"}; Configurable skipTPConly{"skipTPConly", false, "skip V0s comprised of at least one TPC only prong"}; Configurable requirePosITSonly{"requirePosITSonly", false, "require that positive track is ITSonly (overrides TPC quality)"}; Configurable requireNegITSonly{"requireNegITSonly", false, "require that negative track is ITSonly (overrides TPC quality)"}; Configurable rejectPosITSafterburner{"rejectPosITSafterburner", false, "reject positive track formed out of afterburner ITS tracks"}; Configurable rejectNegITSafterburner{"rejectNegITSafterburner", false, "reject negative track formed out of afterburner ITS tracks"}; + Configurable requirePosITSafterburnerOnly{"requirePosITSafterburnerOnly", false, "require positive track formed out of afterburner ITS tracks"}; + Configurable requireNegITSafterburnerOnly{"requireNegITSafterburnerOnly", false, "require negative track formed out of afterburner ITS tracks"}; // PID (TPC/TOF) - Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; - Configurable TofPidNsigmaCutLaPr{"TofPidNsigmaCutLaPr", 1e+6, "TofPidNsigmaCutLaPr"}; - Configurable TofPidNsigmaCutLaPi{"TofPidNsigmaCutLaPi", 1e+6, "TofPidNsigmaCutLaPi"}; - Configurable TofPidNsigmaCutK0Pi{"TofPidNsigmaCutK0Pi", 1e+6, "TofPidNsigmaCutK0Pi"}; + Configurable tpcPidNsigmaCut{"tpcPidNsigmaCut", 5, "tpcPidNsigmaCut"}; + Configurable tofPidNsigmaCutLaPr{"tofPidNsigmaCutLaPr", 1e+6, "tofPidNsigmaCutLaPr"}; + Configurable tofPidNsigmaCutLaPi{"tofPidNsigmaCutLaPi", 1e+6, "tofPidNsigmaCutLaPi"}; + Configurable tofPidNsigmaCutK0Pi{"tofPidNsigmaCutK0Pi", 1e+6, "tofPidNsigmaCutK0Pi"}; // PID (TOF) Configurable maxDeltaTimeProton{"maxDeltaTimeProton", 1e+9, "check maximum allowed time"}; @@ -162,6 +205,15 @@ struct derivedlambdakzeroanalysis { Configurable doTreatPiToMuon{"doTreatPiToMuon", false, "Take pi decay into muon into account in MC"}; Configurable doCollisionAssociationQA{"doCollisionAssociationQA", true, "check collision association"}; + struct : ConfigurableGroup { + std::string prefix = "rctConfigurations"; // JSON group name + Configurable cfgRCTLabel{"cfgRCTLabel", "", "Which detector condition requirements? (CBT, CBT_hadronPID, CBT_electronPID, CBT_calo, CBT_muon, CBT_muon_glo)"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "Include ZDC flags in the bit selection (for Pb-Pb only)"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; + } rctConfigurations; + + RCTFlagsChecker rctFlagsChecker{rctConfigurations.cfgRCTLabel.value}; + // Machine learning evaluation for pre-selection and corresponding information generation o2::ml::OnnxModel mlCustomModelK0Short; o2::ml::OnnxModel mlCustomModelLambda; @@ -169,48 +221,52 @@ struct derivedlambdakzeroanalysis { o2::ml::OnnxModel mlCustomModelGamma; struct : ConfigurableGroup { + std::string prefix = "mlConfigurations"; // JSON group name // ML classifiers: master flags to control whether we should use custom ML classifiers or the scores in the derived data - Configurable useK0ShortScores{"mlConfigurations.useK0ShortScores", false, "use ML scores to select K0Short"}; - Configurable useLambdaScores{"mlConfigurations.useLambdaScores", false, "use ML scores to select Lambda"}; - Configurable useAntiLambdaScores{"mlConfigurations.useAntiLambdaScores", false, "use ML scores to select AntiLambda"}; + Configurable useK0ShortScores{"useK0ShortScores", false, "use ML scores to select K0Short"}; + Configurable useLambdaScores{"useLambdaScores", false, "use ML scores to select Lambda"}; + Configurable useAntiLambdaScores{"useAntiLambdaScores", false, "use ML scores to select AntiLambda"}; - Configurable calculateK0ShortScores{"mlConfigurations.calculateK0ShortScores", false, "calculate K0Short ML scores"}; - Configurable calculateLambdaScores{"mlConfigurations.calculateLambdaScores", false, "calculate Lambda ML scores"}; - Configurable calculateAntiLambdaScores{"mlConfigurations.calculateAntiLambdaScores", false, "calculate AntiLambda ML scores"}; + Configurable calculateK0ShortScores{"calculateK0ShortScores", false, "calculate K0Short ML scores"}; + Configurable calculateLambdaScores{"calculateLambdaScores", false, "calculate Lambda ML scores"}; + Configurable calculateAntiLambdaScores{"calculateAntiLambdaScores", false, "calculate AntiLambda ML scores"}; // ML input for ML calculation - Configurable customModelPathCCDB{"mlConfigurations.customModelPathCCDB", "", "Custom ML Model path in CCDB"}; - Configurable timestampCCDB{"mlConfigurations.timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB. Exceptions: > 0 for the specific timestamp, 0 gets the run dependent timestamp"}; - Configurable loadCustomModelsFromCCDB{"mlConfigurations.loadCustomModelsFromCCDB", false, "Flag to enable or disable the loading of custom models from CCDB"}; - Configurable enableOptimizations{"mlConfigurations.enableOptimizations", false, "Enables the ONNX extended model-optimization: sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED)"}; + Configurable customModelPathCCDB{"customModelPathCCDB", "", "Custom ML Model path in CCDB"}; + Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB. Exceptions: > 0 for the specific timestamp, 0 gets the run dependent timestamp"}; + Configurable loadCustomModelsFromCCDB{"loadCustomModelsFromCCDB", false, "Flag to enable or disable the loading of custom models from CCDB"}; + Configurable enableOptimizations{"enableOptimizations", false, "Enables the ONNX extended model-optimization: sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED)"}; // Local paths for test purposes - Configurable localModelPathLambda{"mlConfigurations.localModelPathLambda", "Lambda_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; - Configurable localModelPathAntiLambda{"mlConfigurations.localModelPathAntiLambda", "AntiLambda_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; - Configurable localModelPathK0Short{"mlConfigurations.localModelPathK0Short", "KZeroShort_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; + Configurable localModelPathLambda{"localModelPathLambda", "Lambda_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; + Configurable localModelPathAntiLambda{"localModelPathAntiLambda", "AntiLambda_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; + Configurable localModelPathK0Short{"localModelPathK0Short", "KZeroShort_BDTModel.onnx", "(std::string) Path to the local .onnx file."}; // Thresholds for choosing to populate V0Cores tables with pre-selections - Configurable thresholdLambda{"mlConfigurations.thresholdLambda", -1.0f, "Threshold to keep Lambda candidates"}; - Configurable thresholdAntiLambda{"mlConfigurations.thresholdAntiLambda", -1.0f, "Threshold to keep AntiLambda candidates"}; - Configurable thresholdK0Short{"mlConfigurations.thresholdK0Short", -1.0f, "Threshold to keep K0Short candidates"}; + Configurable thresholdLambda{"thresholdLambda", -1.0f, "Threshold to keep Lambda candidates"}; + Configurable thresholdAntiLambda{"thresholdAntiLambda", -1.0f, "Threshold to keep AntiLambda candidates"}; + Configurable thresholdK0Short{"thresholdK0Short", -1.0f, "Threshold to keep K0Short candidates"}; } mlConfigurations; // CCDB options struct : ConfigurableGroup { - Configurable ccdburl{"ccdbConfigurations.ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"ccdbConfigurations.grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"ccdbConfigurations.grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable lutPath{"ccdbConfigurations.lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable geoPath{"ccdbConfigurations.geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - Configurable mVtxPath{"ccdbConfigurations.mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; + std::string prefix = "ccdbConfigurations"; // JSON group name + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; } ccdbConfigurations; o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + ctpRateFetcher rateFetcher; int mRunNumber; std::map metadata; - static constexpr float defaultLifetimeCuts[1][2] = {{30., 20.}}; - Configurable> lifetimecut{"lifetimecut", {defaultLifetimeCuts[0], 2, {"lifetimecutLambda", "lifetimecutK0S"}}, "lifetimecut"}; + static constexpr float DefaultLifetimeCuts[1][2] = {{30., 20.}}; + Configurable> lifetimecut{"lifetimecut", {DefaultLifetimeCuts[0], 2, {"lifetimecutLambda", "lifetimecutK0S"}}, "lifetimecut"}; ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for analysis"}; ConfigurableAxis axisPtXi{"axisPtXi", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for feeddown from Xi"}; @@ -219,6 +275,7 @@ struct derivedlambdakzeroanalysis { ConfigurableAxis axisLambdaMass{"axisLambdaMass", {200, 1.101f, 1.131f}, ""}; ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f}, "Centrality"}; ConfigurableAxis axisNch{"axisNch", {500, 0.0f, +5000.0f}, "Number of charged particles"}; + ConfigurableAxis axisIRBinning{"axisIRBinning", {500, 0, 50}, "Binning for the interaction rate (kHz)"}; ConfigurableAxis axisRawCentrality{"axisRawCentrality", {VARIABLE_WIDTH, 0.000f, 52.320f, 75.400f, 95.719f, 115.364f, 135.211f, 155.791f, 177.504f, 200.686f, 225.641f, 252.645f, 281.906f, 313.850f, 348.302f, 385.732f, 426.307f, 470.146f, 517.555f, 568.899f, 624.177f, 684.021f, 748.734f, 818.078f, 892.577f, 973.087f, 1058.789f, 1150.915f, 1249.319f, 1354.279f, 1465.979f, 1584.790f, 1710.778f, 1844.863f, 1985.746f, 2134.643f, 2291.610f, 2456.943f, 2630.653f, 2813.959f, 3006.631f, 3207.229f, 3417.641f, 3637.318f, 3865.785f, 4104.997f, 4354.938f, 4615.786f, 4885.335f, 5166.555f, 5458.021f, 5762.584f, 6077.881f, 6406.834f, 6746.435f, 7097.958f, 7462.579f, 7839.165f, 8231.629f, 8635.640f, 9052.000f, 9484.268f, 9929.111f, 10389.350f, 10862.059f, 11352.185f, 11856.823f, 12380.371f, 12920.401f, 13476.971f, 14053.087f, 14646.190f, 15258.426f, 15890.617f, 16544.433f, 17218.024f, 17913.465f, 18631.374f, 19374.983f, 20136.700f, 20927.783f, 21746.796f, 22590.880f, 23465.734f, 24372.274f, 25314.351f, 26290.488f, 27300.899f, 28347.512f, 29436.133f, 30567.840f, 31746.818f, 32982.664f, 34276.329f, 35624.859f, 37042.588f, 38546.609f, 40139.742f, 41837.980f, 43679.429f, 45892.130f, 400000.000f}, "raw centrality signal"}; // for QA @@ -235,6 +292,11 @@ struct derivedlambdakzeroanalysis { ConfigurableAxis axisTOFdeltaT{"axisTOFdeltaT", {200, -5000.0f, 5000.0f}, "TOF Delta T (ps)"}; ConfigurableAxis axisPhi{"axisPhi", {18, 0.0f, constants::math::TwoPI}, "Azimuth angle (rad)"}; ConfigurableAxis axisEta{"axisEta", {10, -1.0f, 1.0f}, "#eta"}; + ConfigurableAxis axisITSchi2{"axisITSchi2", {100, 0.0f, 100.0f}, "#chi^{2} per ITS clusters"}; + ConfigurableAxis axisTPCchi2{"axisTPCchi2", {100, 0.0f, 100.0f}, "#chi^{2} per TPC clusters"}; + ConfigurableAxis axisTPCrowsOverFindable{"axisTPCrowsOverFindable", {120, 0.0f, 1.2f}, "Fraction of TPC crossed rows over findable clusters"}; + ConfigurableAxis axisTPCfoundOverFindable{"axisTPCfoundOverFindable", {120, 0.0f, 1.2f}, "Fraction of TPC found over findable clusters"}; + ConfigurableAxis axisTPCsharedClusters{"axisTPCsharedClusters", {101, -0.005f, 1.005f}, "Fraction of TPC shared clusters"}; // UPC axes ConfigurableAxis axisSelGap{"axisSelGap", {4, -1.5, 2.5}, "Gap side"}; @@ -242,11 +304,12 @@ struct derivedlambdakzeroanalysis { // UPC selections SGSelector sgSelector; struct : ConfigurableGroup { - Configurable FV0cut{"upcCuts.FV0cut", 100., "FV0A threshold"}; - Configurable FT0Acut{"upcCuts.FT0Acut", 200., "FT0A threshold"}; - Configurable FT0Ccut{"upcCuts.FT0Ccut", 100., "FT0C threshold"}; - Configurable ZDCcut{"upcCuts.ZDCcut", 10., "ZDC threshold"}; - // Configurable gapSel{"upcCuts.gapSel", 2, "Gap selection"}; + std::string prefix = "upcCuts"; // JSON group name + Configurable fv0Cut{"fv0Cut", 100., "FV0A threshold"}; + Configurable ft0Acut{"ft0Acut", 200., "FT0A threshold"}; + Configurable ft0Ccut{"ft0Ccut", 100., "FT0C threshold"}; + Configurable zdcCut{"zdcCut", 10., "ZDC threshold"}; + // Configurable gapSel{"gapSel", 2, "Gap selection"}; } upcCuts; // AP plot axes @@ -256,7 +319,7 @@ struct derivedlambdakzeroanalysis { // Track quality axes ConfigurableAxis axisTPCrows{"axisTPCrows", {160, 0.0f, 160.0f}, "N TPC rows"}; ConfigurableAxis axisITSclus{"axisITSclus", {7, 0.0f, 7.0f}, "N ITS Clusters"}; - ConfigurableAxis axisITScluMap{"axisITSMap", {128, -0.5f, 127.5f}, "ITS Cluster map"}; + ConfigurableAxis axisITScluMap{"axisITScluMap", {128, -0.5f, 127.5f}, "ITS Cluster map"}; ConfigurableAxis axisDetMap{"axisDetMap", {16, -0.5f, 15.5f}, "Detector use map"}; ConfigurableAxis axisITScluMapCoarse{"axisITScluMapCoarse", {16, -3.5f, 12.5f}, "ITS Coarse cluster map"}; ConfigurableAxis axisDetMapCoarse{"axisDetMapCoarse", {5, -0.5f, 4.5f}, "Detector Coarse user map"}; @@ -267,8 +330,9 @@ struct derivedlambdakzeroanalysis { // For manual sliceBy // Preslice> perMcCollision = aod::v0data::straMCCollisionId; PresliceUnsorted> perMcCollision = aod::v0data::straMCCollisionId; + PresliceUnsorted> perMcCollisionRun2 = aod::v0data::straMCCollisionId; - enum selection : uint64_t { selCosPA = 0, + enum Selection : uint64_t { selCosPA = 0, selRadius, selRadiusMax, selDCANegToPV, @@ -332,390 +396,542 @@ struct derivedlambdakzeroanalysis { void init(InitContext const&) { - // initialise bit masks - maskTopological = (uint64_t(1) << selCosPA) | (uint64_t(1) << selRadius) | (uint64_t(1) << selDCANegToPV) | (uint64_t(1) << selDCAPosToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); - maskTopoNoV0Radius = (uint64_t(1) << selCosPA) | (uint64_t(1) << selDCANegToPV) | (uint64_t(1) << selDCAPosToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); - maskTopoNoDCANegToPV = (uint64_t(1) << selCosPA) | (uint64_t(1) << selRadius) | (uint64_t(1) << selDCAPosToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); - maskTopoNoDCAPosToPV = (uint64_t(1) << selCosPA) | (uint64_t(1) << selRadius) | (uint64_t(1) << selDCANegToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); - maskTopoNoCosPA = (uint64_t(1) << selRadius) | (uint64_t(1) << selDCANegToPV) | (uint64_t(1) << selDCAPosToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); - maskTopoNoDCAV0Dau = (uint64_t(1) << selCosPA) | (uint64_t(1) << selRadius) | (uint64_t(1) << selDCANegToPV) | (uint64_t(1) << selDCAPosToPV) | (uint64_t(1) << selRadiusMax); + // Determine if we are dealing with Run3 or Run2 processing + if ((doprocessRealDataRun3 || doprocessMonteCarloRun3 || doprocessGeneratedRun3) && (doprocessRealDataRun2 || doprocessMonteCarloRun2 || doprocessGeneratedRun2)) { + LOGF(fatal, "Cannot enable Run2 and Run3 processes at the same time. Please choose one."); + } + if (doprocessRealDataRun3 || doprocessMonteCarloRun3 || doprocessGeneratedRun3) { + isRun3 = true; + } else { + isRun3 = false; + } + // setting CCDB service + ccdb->setURL(ccdbConfigurations.ccdbUrl); + ccdb->setCaching(true); + ccdb->setFatalWhenNull(false); - maskK0ShortSpecific = (uint64_t(1) << selK0ShortRapidity) | (uint64_t(1) << selK0ShortCTau) | (uint64_t(1) << selK0ShortArmenteros) | (uint64_t(1) << selConsiderK0Short); - maskLambdaSpecific = (uint64_t(1) << selLambdaRapidity) | (uint64_t(1) << selLambdaCTau) | (uint64_t(1) << selConsiderLambda); - maskAntiLambdaSpecific = (uint64_t(1) << selLambdaRapidity) | (uint64_t(1) << selLambdaCTau) | (uint64_t(1) << selConsiderAntiLambda); + // initialise bit masks + // Mask with all topologic selections + maskTopological = 0; + BITSET(maskTopological, selCosPA); + BITSET(maskTopological, selRadius); + BITSET(maskTopological, selDCANegToPV); + BITSET(maskTopological, selDCAPosToPV); + BITSET(maskTopological, selDCAV0Dau); + BITSET(maskTopological, selRadiusMax); + // Mask with all topologic selections, except for V0 radius + maskTopoNoV0Radius = 0; + BITSET(maskTopoNoV0Radius, selCosPA); + BITSET(maskTopoNoV0Radius, selDCANegToPV); + BITSET(maskTopoNoV0Radius, selDCAPosToPV); + BITSET(maskTopoNoV0Radius, selDCAV0Dau); + BITSET(maskTopoNoV0Radius, selRadiusMax); + // Mask with all topologic selections, except for DCA neg. to PV + maskTopoNoDCANegToPV = 0; + BITSET(maskTopoNoDCANegToPV, selCosPA); + BITSET(maskTopoNoDCANegToPV, selRadius); + BITSET(maskTopoNoDCANegToPV, selDCAPosToPV); + BITSET(maskTopoNoDCANegToPV, selDCAV0Dau); + BITSET(maskTopoNoDCANegToPV, selRadiusMax); + // Mask with all topologic selections, except for DCA pos. to PV + maskTopoNoDCAPosToPV = 0; + BITSET(maskTopoNoDCAPosToPV, selCosPA); + BITSET(maskTopoNoDCAPosToPV, selRadius); + BITSET(maskTopoNoDCAPosToPV, selDCANegToPV); + BITSET(maskTopoNoDCAPosToPV, selDCAV0Dau); + BITSET(maskTopoNoDCAPosToPV, selRadiusMax); + // Mask with all topologic selections, except for cosPA + maskTopoNoCosPA = 0; + BITSET(maskTopoNoCosPA, selRadius); + BITSET(maskTopoNoCosPA, selDCANegToPV); + BITSET(maskTopoNoCosPA, selDCAPosToPV); + BITSET(maskTopoNoCosPA, selDCAV0Dau); + BITSET(maskTopoNoCosPA, selRadiusMax); + // Mask with all topologic selections, except for DCA between V0 dau + maskTopoNoDCAV0Dau = 0; + BITSET(maskTopoNoDCAV0Dau, selCosPA); + BITSET(maskTopoNoDCAV0Dau, selRadius); + BITSET(maskTopoNoDCAV0Dau, selDCANegToPV); + BITSET(maskTopoNoDCAV0Dau, selDCAPosToPV); + BITSET(maskTopoNoDCAV0Dau, selRadiusMax); + + // Mask for specifically selecting K0Short + maskK0ShortSpecific = 0; + BITSET(maskK0ShortSpecific, selK0ShortRapidity); + BITSET(maskK0ShortSpecific, selK0ShortCTau); + BITSET(maskK0ShortSpecific, selK0ShortArmenteros); + BITSET(maskK0ShortSpecific, selConsiderK0Short); + // Mask for specifically selecting Lambda + maskLambdaSpecific = 0; + BITSET(maskLambdaSpecific, selLambdaRapidity); + BITSET(maskLambdaSpecific, selLambdaCTau); + BITSET(maskLambdaSpecific, selConsiderLambda); + // Mask for specifically selecting AntiLambda + maskAntiLambdaSpecific = 0; + BITSET(maskAntiLambdaSpecific, selLambdaRapidity); + BITSET(maskAntiLambdaSpecific, selLambdaCTau); + BITSET(maskAntiLambdaSpecific, selConsiderAntiLambda); // ask for specific TPC/TOF PID selections maskTrackProperties = 0; if (v0Selections.requirePosITSonly) { - maskTrackProperties = maskTrackProperties | (uint64_t(1) << selPosItsOnly) | (uint64_t(1) << selPosGoodITSTrack); + BITSET(maskTrackProperties, selPosItsOnly); + BITSET(maskTrackProperties, selPosGoodITSTrack); } else { - maskTrackProperties = maskTrackProperties | (uint64_t(1) << selPosGoodTPCTrack) | (uint64_t(1) << selPosGoodITSTrack); + BITSET(maskTrackProperties, selPosGoodTPCTrack); + BITSET(maskTrackProperties, selPosGoodITSTrack); // TPC signal is available: ask for positive track PID - if (v0Selections.TpcPidNsigmaCut < 1e+5) { // safeguard for no cut - maskK0ShortSpecific = maskK0ShortSpecific | (uint64_t(1) << selTPCPIDPositivePion); - maskLambdaSpecific = maskLambdaSpecific | (uint64_t(1) << selTPCPIDPositiveProton); - maskAntiLambdaSpecific = maskAntiLambdaSpecific | (uint64_t(1) << selTPCPIDPositivePion); + if (v0Selections.tpcPidNsigmaCut < 1e+5) { // safeguard for no cut + BITSET(maskK0ShortSpecific, selTPCPIDPositivePion); + BITSET(maskLambdaSpecific, selTPCPIDPositiveProton); + BITSET(maskAntiLambdaSpecific, selTPCPIDPositivePion); } // TOF PID - if (v0Selections.TofPidNsigmaCutK0Pi < 1e+5) // safeguard for no cut - maskK0ShortSpecific = maskK0ShortSpecific | (uint64_t(1) << selTOFNSigmaPositivePionK0Short) | (uint64_t(1) << selTOFDeltaTPositivePionK0Short); - if (v0Selections.TofPidNsigmaCutLaPr < 1e+5) // safeguard for no cut - maskLambdaSpecific = maskLambdaSpecific | (uint64_t(1) << selTOFNSigmaPositiveProtonLambda) | (uint64_t(1) << selTOFDeltaTPositiveProtonLambda); - if (v0Selections.TofPidNsigmaCutLaPi < 1e+5) // safeguard for no cut - maskAntiLambdaSpecific = maskAntiLambdaSpecific | (uint64_t(1) << selTOFNSigmaPositivePionLambda) | (uint64_t(1) << selTOFDeltaTPositivePionLambda); + if (v0Selections.tofPidNsigmaCutK0Pi < 1e+5) { // safeguard for no cut + BITSET(maskK0ShortSpecific, selTOFNSigmaPositivePionK0Short); + BITSET(maskK0ShortSpecific, selTOFDeltaTPositivePionK0Short); + } + if (v0Selections.tofPidNsigmaCutLaPr < 1e+5) { // safeguard for no cut + BITSET(maskLambdaSpecific, selTOFNSigmaPositiveProtonLambda); + BITSET(maskLambdaSpecific, selTOFDeltaTPositiveProtonLambda); + } + if (v0Selections.tofPidNsigmaCutLaPi < 1e+5) { // safeguard for no cut + BITSET(maskAntiLambdaSpecific, selTOFNSigmaPositivePionLambda); + BITSET(maskAntiLambdaSpecific, selTOFDeltaTPositivePionLambda); + } } if (v0Selections.requireNegITSonly) { - maskTrackProperties = maskTrackProperties | (uint64_t(1) << selNegItsOnly) | (uint64_t(1) << selNegGoodITSTrack); + BITSET(maskTrackProperties, selNegItsOnly); + BITSET(maskTrackProperties, selNegGoodITSTrack); } else { - maskTrackProperties = maskTrackProperties | (uint64_t(1) << selNegGoodTPCTrack) | (uint64_t(1) << selNegGoodITSTrack); + BITSET(maskTrackProperties, selNegGoodTPCTrack); + BITSET(maskTrackProperties, selNegGoodITSTrack); // TPC signal is available: ask for negative track PID - if (v0Selections.TpcPidNsigmaCut < 1e+5) { // safeguard for no cut - maskK0ShortSpecific = maskK0ShortSpecific | (uint64_t(1) << selTPCPIDNegativePion); - maskLambdaSpecific = maskLambdaSpecific | (uint64_t(1) << selTPCPIDNegativePion); - maskAntiLambdaSpecific = maskAntiLambdaSpecific | (uint64_t(1) << selTPCPIDNegativeProton); + if (v0Selections.tpcPidNsigmaCut < 1e+5) { // safeguard for no cut + BITSET(maskK0ShortSpecific, selTPCPIDNegativePion); + BITSET(maskLambdaSpecific, selTPCPIDNegativePion); + BITSET(maskAntiLambdaSpecific, selTPCPIDNegativeProton); } // TOF PID - if (v0Selections.TofPidNsigmaCutK0Pi < 1e+5) // safeguard for no cut - maskK0ShortSpecific = maskK0ShortSpecific | (uint64_t(1) << selTOFNSigmaNegativePionK0Short) | (uint64_t(1) << selTOFDeltaTNegativePionK0Short); - if (v0Selections.TofPidNsigmaCutLaPi < 1e+5) // safeguard for no cut - maskLambdaSpecific = maskLambdaSpecific | (uint64_t(1) << selTOFNSigmaNegativePionLambda) | (uint64_t(1) << selTOFDeltaTNegativePionLambda); - if (v0Selections.TofPidNsigmaCutLaPr < 1e+5) // safeguard for no cut - maskAntiLambdaSpecific = maskAntiLambdaSpecific | (uint64_t(1) << selTOFNSigmaNegativeProtonLambda) | (uint64_t(1) << selTOFDeltaTNegativeProtonLambda); + if (v0Selections.tofPidNsigmaCutK0Pi < 1e+5) { // safeguard for no cut + BITSET(maskK0ShortSpecific, selTOFNSigmaNegativePionK0Short); + BITSET(maskK0ShortSpecific, selTOFDeltaTNegativePionK0Short); + } + if (v0Selections.tofPidNsigmaCutLaPi < 1e+5) { // safeguard for no cut + BITSET(maskLambdaSpecific, selTOFNSigmaNegativePionLambda); + BITSET(maskLambdaSpecific, selTOFDeltaTNegativePionLambda); + } + if (v0Selections.tofPidNsigmaCutLaPr < 1e+5) { // safeguard for no cut + BITSET(maskAntiLambdaSpecific, selTOFNSigmaNegativeProtonLambda); + BITSET(maskAntiLambdaSpecific, selTOFDeltaTNegativeProtonLambda); + } } if (v0Selections.skipTPConly) { - maskK0ShortSpecific = maskK0ShortSpecific | (uint64_t(1) << selPosNotTPCOnly) | (uint64_t(1) << selNegNotTPCOnly); - maskLambdaSpecific = maskLambdaSpecific | (uint64_t(1) << selPosNotTPCOnly) | (uint64_t(1) << selNegNotTPCOnly); - maskAntiLambdaSpecific = maskAntiLambdaSpecific | (uint64_t(1) << selPosNotTPCOnly) | (uint64_t(1) << selNegNotTPCOnly); + BITSET(maskK0ShortSpecific, selPosNotTPCOnly); + BITSET(maskLambdaSpecific, selPosNotTPCOnly); + BITSET(maskAntiLambdaSpecific, selPosNotTPCOnly); + + BITSET(maskK0ShortSpecific, selNegNotTPCOnly); + BITSET(maskLambdaSpecific, selNegNotTPCOnly); + BITSET(maskAntiLambdaSpecific, selNegNotTPCOnly); } // Primary particle selection, central to analysis - maskSelectionK0Short = maskTopological | maskTrackProperties | maskK0ShortSpecific | (uint64_t(1) << selPhysPrimK0Short); - maskSelectionLambda = maskTopological | maskTrackProperties | maskLambdaSpecific | (uint64_t(1) << selPhysPrimLambda); - maskSelectionAntiLambda = maskTopological | maskTrackProperties | maskAntiLambdaSpecific | (uint64_t(1) << selPhysPrimAntiLambda); + maskSelectionK0Short = maskTopological | maskTrackProperties | maskK0ShortSpecific | (static_cast(1) << selPhysPrimK0Short); + maskSelectionLambda = maskTopological | maskTrackProperties | maskLambdaSpecific | (static_cast(1) << selPhysPrimLambda); + maskSelectionAntiLambda = maskTopological | maskTrackProperties | maskAntiLambdaSpecific | (static_cast(1) << selPhysPrimAntiLambda); + + BITSET(maskSelectionK0Short, selPhysPrimK0Short); + BITSET(maskSelectionLambda, selPhysPrimLambda); + BITSET(maskSelectionAntiLambda, selPhysPrimAntiLambda); // No primary requirement for feeddown matrix secondaryMaskSelectionLambda = maskTopological | maskTrackProperties | maskLambdaSpecific; secondaryMaskSelectionAntiLambda = maskTopological | maskTrackProperties | maskAntiLambdaSpecific; + // Initialise the RCTFlagsChecker + rctFlagsChecker.init(rctConfigurations.cfgRCTLabel.value, rctConfigurations.cfgCheckZDC, rctConfigurations.cfgTreatLimitedAcceptanceAsBad); + // Event Counters - histos.add("hEventSelection", "hEventSelection", kTH1F, {{20, -0.5f, +19.5f}}); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(3, "kIsTriggerTVX"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(5, "kNoTimeFrameBorder"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(6, "posZ cut"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(7, "kIsVertexITSTPC"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(8, "kIsGoodZvtxFT0vsPV"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(9, "kIsVertexTOFmatched"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(10, "kIsVertexTRDmatched"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(11, "kNoSameBunchPileup"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(12, "kNoCollInTimeRangeStd"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(13, "kNoCollInTimeRangeStrict"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(14, "kNoCollInTimeRangeNarrow"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(15, "kNoCollInTimeRangeVzDep"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(16, "kNoCollInRofStd"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(17, "kNoCollInRofStrict"); - if (doPPAnalysis) { - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "INEL>0"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(19, "INEL>1"); + histos.add("hEventSelection", "hEventSelection", kTH1D, {{21, -0.5f, +20.5f}}); + if (isRun3) { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(3, "kIsTriggerTVX"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(5, "kNoTimeFrameBorder"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(6, "posZ cut"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(7, "kIsVertexITSTPC"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(8, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(9, "kIsVertexTOFmatched"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(10, "kIsVertexTRDmatched"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(11, "kNoSameBunchPileup"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(12, "kNoCollInTimeRangeStd"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(13, "kNoCollInTimeRangeStrict"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(14, "kNoCollInTimeRangeNarrow"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(15, "kNoCollInRofStd"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(16, "kNoCollInRofStrict"); + if (doPPAnalysis) { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(17, "INEL>0"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "INEL>1"); + } else { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(17, "Below min occup."); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "Above max occup."); + } + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(19, "Below min IR"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(20, "Above max IR"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(21, "RCT flags"); } else { - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "Below min occup."); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(19, "Above max occup."); - } - - histos.add("hEventCentrality", "hEventCentrality", kTH1F, {{100, 0.0f, +100.0f}}); - histos.add("hCentralityVsNch", "hCentralityVsNch", kTH2F, {axisCentrality, axisNch}); - - histos.add("hEventPVz", "hEventPVz", kTH1F, {{100, -20.0f, +20.0f}}); - histos.add("hCentralityVsPVz", "hCentralityVsPVz", kTH2F, {axisCentrality, {100, -20.0f, +20.0f}}); - if (doprocessGenerated) { - histos.add("hEventPVzMC", "hEventPVzMC", kTH1F, {{100, -20.0f, +20.0f}}); - histos.add("hCentralityVsPVzMC", "hCentralityVsPVzMC", kTH2F, {axisCentrality, {100, -20.0f, +20.0f}}); - } - - histos.add("hEventOccupancy", "hEventOccupancy", kTH1F, {axisOccupancy}); - histos.add("hCentralityVsOccupancy", "hCentralityVsOccupancy", kTH2F, {axisCentrality, axisOccupancy}); - - histos.add("hGapSide", "Gap side; Entries", kTH1F, {{5, -0.5, 4.5}}); - histos.add("hSelGapSide", "Selected gap side; Entries", kTH1F, {axisSelGap}); - histos.add("hEventCentralityVsSelGapSide", ";Centrality (%); Selected gap side", kTH2F, {{100, 0.0f, +100.0f}, axisSelGap}); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(3, "sel7 cut"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(4, "kINT7"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(5, "kIsTriggerTVX"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(6, "kNoIncompleteDAQ"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(7, "posZ cut"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(8, "kNoInconsistentVtx"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(9, "kNoPileupFromSPD"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(10, "kNoV0PFPileup"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(11, "kNoPileupInMultBins"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(12, "kNoPileupMV"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(13, "kNoPileupTPC"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(14, "kNoV0MOnVsOfPileup"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(15, "kNoSPDOnVsOfPileup"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(16, "kNoSPDClsVsTklBG"); + if (doPPAnalysis) { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(17, "INEL>0"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "INEL>1"); + } + } + + histos.add("hEventCentrality", "hEventCentrality", kTH1D, {{101, 0.0f, 101.0f}}); + histos.add("hCentralityVsNch", "hCentralityVsNch", kTH2D, {{101, 0.0f, 101.0f}, axisNch}); + + histos.add("hEventPVz", "hEventPVz", kTH1D, {{100, -20.0f, +20.0f}}); + histos.add("hCentralityVsPVz", "hCentralityVsPVz", kTH2D, {{101, 0.0f, 101.0f}, {100, -20.0f, +20.0f}}); + if (doprocessGeneratedRun3 || doprocessGeneratedRun2) { + histos.add("hEventPVzMC", "hEventPVzMC", kTH1D, {{100, -20.0f, +20.0f}}); + histos.add("hCentralityVsPVzMC", "hCentralityVsPVzMC", kTH2D, {{101, 0.0f, 101.0f}, {100, -20.0f, +20.0f}}); + } + + histos.add("hEventOccupancy", "hEventOccupancy", kTH1D, {axisOccupancy}); + histos.add("hCentralityVsOccupancy", "hCentralityVsOccupancy", kTH2D, {{101, 0.0f, 101.0f}, axisOccupancy}); + + histos.add("hGapSide", "Gap side; Entries", kTH1D, {{5, -0.5, 4.5}}); + histos.add("hSelGapSide", "Selected gap side; Entries", kTH1D, {axisSelGap}); + histos.add("hEventCentralityVsSelGapSide", ";Centrality (%); Selected gap side", kTH2D, {{101, 0.0f, 101.0f}, axisSelGap}); + + histos.add("hInteractionRate", "hInteractionRate", kTH1D, {axisIRBinning}); + histos.add("hCentralityVsInteractionRate", "hCentralityVsInteractionRate", kTH2D, {{101, 0.0f, 101.0f}, axisIRBinning}); + + histos.add("hInteractionRateVsOccupancy", "hInteractionRateVsOccupancy", kTH2D, {axisIRBinning, axisOccupancy}); // for QA and test purposes - auto hRawCentrality = histos.add("hRawCentrality", "hRawCentrality", kTH1F, {axisRawCentrality}); + auto hRawCentrality = histos.add("hRawCentrality", "hRawCentrality", kTH1D, {axisRawCentrality}); for (int ii = 1; ii < 101; ii++) { float value = 100.5f - static_cast(ii); hRawCentrality->SetBinContent(ii, value); } + auto hPrimaryV0s = histos.add("hPrimaryV0s", "hPrimaryV0s", kTH1D, {{2, -0.5f, 1.5f}}); + hPrimaryV0s->GetXaxis()->SetBinLabel(1, "All V0s"); + hPrimaryV0s->GetXaxis()->SetBinLabel(2, "Primary V0s"); + // histograms versus mass if (analyseK0Short) { - histos.add("h2dNbrOfK0ShortVsCentrality", "h2dNbrOfK0ShortVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); - histos.add("h3dMassK0Short", "h3dMassK0Short", kTH3F, {axisCentrality, axisPt, axisK0Mass}); + histos.add("h2dNbrOfK0ShortVsCentrality", "h2dNbrOfK0ShortVsCentrality", kTH2D, {axisCentrality, {10, -0.5f, 9.5f}}); + histos.add("h3dMassK0Short", "h3dMassK0Short", kTH3D, {axisCentrality, axisPt, axisK0Mass}); // Non-UPC info - histos.add("h3dMassK0ShortHadronic", "h3dMassK0ShortHadronic", kTH3F, {axisCentrality, axisPt, axisK0Mass}); + histos.add("h3dMassK0ShortHadronic", "h3dMassK0ShortHadronic", kTH3D, {axisCentrality, axisPt, axisK0Mass}); // UPC info - histos.add("h3dMassK0ShortSGA", "h3dMassK0ShortSGA", kTH3F, {axisCentrality, axisPt, axisK0Mass}); - histos.add("h3dMassK0ShortSGC", "h3dMassK0ShortSGC", kTH3F, {axisCentrality, axisPt, axisK0Mass}); - histos.add("h3dMassK0ShortDG", "h3dMassK0ShortDG", kTH3F, {axisCentrality, axisPt, axisK0Mass}); + histos.add("h3dMassK0ShortSGA", "h3dMassK0ShortSGA", kTH3D, {axisCentrality, axisPt, axisK0Mass}); + histos.add("h3dMassK0ShortSGC", "h3dMassK0ShortSGC", kTH3D, {axisCentrality, axisPt, axisK0Mass}); + histos.add("h3dMassK0ShortDG", "h3dMassK0ShortDG", kTH3D, {axisCentrality, axisPt, axisK0Mass}); if (doTPCQA) { - histos.add("K0Short/h3dPosNsigmaTPC", "h3dPosNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("K0Short/h3dNegNsigmaTPC", "h3dNegNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("K0Short/h3dPosTPCsignal", "h3dPosTPCsignal", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("K0Short/h3dNegTPCsignal", "h3dNegTPCsignal", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("K0Short/h3dPosNsigmaTPCvsTrackPtot", "h3dPosNsigmaTPCvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("K0Short/h3dNegNsigmaTPCvsTrackPtot", "h3dNegNsigmaTPCvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("K0Short/h3dPosTPCsignalVsTrackPtot", "h3dPosTPCsignalVsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("K0Short/h3dNegTPCsignalVsTrackPtot", "h3dNegTPCsignalVsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("K0Short/h3dPosNsigmaTPCvsTrackPt", "h3dPosNsigmaTPCvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("K0Short/h3dNegNsigmaTPCvsTrackPt", "h3dNegNsigmaTPCvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("K0Short/h3dPosTPCsignalVsTrackPt", "h3dPosTPCsignalVsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("K0Short/h3dNegTPCsignalVsTrackPt", "h3dNegTPCsignalVsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("K0Short/h3dPosNsigmaTPC", "h3dPosNsigmaTPC", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("K0Short/h3dNegNsigmaTPC", "h3dNegNsigmaTPC", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("K0Short/h3dPosTPCsignal", "h3dPosTPCsignal", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("K0Short/h3dNegTPCsignal", "h3dNegTPCsignal", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("K0Short/h3dPosNsigmaTPCvsTrackPtot", "h3dPosNsigmaTPCvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("K0Short/h3dNegNsigmaTPCvsTrackPtot", "h3dNegNsigmaTPCvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("K0Short/h3dPosTPCsignalVsTrackPtot", "h3dPosTPCsignalVsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("K0Short/h3dNegTPCsignalVsTrackPtot", "h3dNegTPCsignalVsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("K0Short/h3dPosNsigmaTPCvsTrackPt", "h3dPosNsigmaTPCvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("K0Short/h3dNegNsigmaTPCvsTrackPt", "h3dNegNsigmaTPCvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("K0Short/h3dPosTPCsignalVsTrackPt", "h3dPosTPCsignalVsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("K0Short/h3dNegTPCsignalVsTrackPt", "h3dNegTPCsignalVsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); } if (doTOFQA) { - histos.add("K0Short/h3dPosNsigmaTOF", "h3dPosNsigmaTOF", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("K0Short/h3dNegNsigmaTOF", "h3dNegNsigmaTOF", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("K0Short/h3dPosTOFdeltaT", "h3dPosTOFdeltaT", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("K0Short/h3dNegTOFdeltaT", "h3dNegTOFdeltaT", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("K0Short/h3dPosNsigmaTOFvsTrackPtot", "h3dPosNsigmaTOFvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("K0Short/h3dNegNsigmaTOFvsTrackPtot", "h3dNegNsigmaTOFvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("K0Short/h3dPosTOFdeltaTvsTrackPtot", "h3dPosTOFdeltaTvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("K0Short/h3dNegTOFdeltaTvsTrackPtot", "h3dNegTOFdeltaTvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("K0Short/h3dPosNsigmaTOFvsTrackPt", "h3dPosNsigmaTOFvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("K0Short/h3dNegNsigmaTOFvsTrackPt", "h3dNegNsigmaTOFvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("K0Short/h3dPosTOFdeltaTvsTrackPt", "h3dPosTOFdeltaTvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("K0Short/h3dNegTOFdeltaTvsTrackPt", "h3dNegTOFdeltaTvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("K0Short/h3dPosNsigmaTOF", "h3dPosNsigmaTOF", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("K0Short/h3dNegNsigmaTOF", "h3dNegNsigmaTOF", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("K0Short/h3dPosTOFdeltaT", "h3dPosTOFdeltaT", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("K0Short/h3dNegTOFdeltaT", "h3dNegTOFdeltaT", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("K0Short/h3dPosNsigmaTOFvsTrackPtot", "h3dPosNsigmaTOFvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("K0Short/h3dNegNsigmaTOFvsTrackPtot", "h3dNegNsigmaTOFvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("K0Short/h3dPosTOFdeltaTvsTrackPtot", "h3dPosTOFdeltaTvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("K0Short/h3dNegTOFdeltaTvsTrackPtot", "h3dNegTOFdeltaTvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("K0Short/h3dPosNsigmaTOFvsTrackPt", "h3dPosNsigmaTOFvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("K0Short/h3dNegNsigmaTOFvsTrackPt", "h3dNegNsigmaTOFvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("K0Short/h3dPosTOFdeltaTvsTrackPt", "h3dPosTOFdeltaTvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("K0Short/h3dNegTOFdeltaTvsTrackPt", "h3dNegTOFdeltaTvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); } if (doCollisionAssociationQA) { - histos.add("K0Short/h2dPtVsNch", "h2dPtVsNch", kTH2F, {axisMonteCarloNch, axisPt}); - histos.add("K0Short/h2dPtVsNch_BadCollAssig", "h2dPtVsNch_BadCollAssig", kTH2F, {axisMonteCarloNch, axisPt}); + histos.add("K0Short/h2dPtVsNch", "h2dPtVsNch", kTH2D, {axisMonteCarloNch, axisPt}); + histos.add("K0Short/h2dPtVsNch_BadCollAssig", "h2dPtVsNch_BadCollAssig", kTH2D, {axisMonteCarloNch, axisPt}); } if (doDetectPropQA == 1) { - histos.add("K0Short/h6dDetectPropVsCentrality", "h6dDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); - histos.add("K0Short/h4dPosDetectPropVsCentrality", "h4dPosDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); - histos.add("K0Short/h4dNegDetectPropVsCentrality", "h4dNegDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); + histos.add("K0Short/h6dDetectPropVsCentrality", "h6dDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); + histos.add("K0Short/h4dPosDetectPropVsCentrality", "h4dPosDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); + histos.add("K0Short/h4dNegDetectPropVsCentrality", "h4dNegDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); } if (doDetectPropQA == 2) { - histos.add("K0Short/h7dDetectPropVsCentrality", "h7dDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisK0Mass}); - histos.add("K0Short/h5dPosDetectPropVsCentrality", "h5dPosDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisK0Mass}); - histos.add("K0Short/h5dNegDetectPropVsCentrality", "h5dNegDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisK0Mass}); + histos.add("K0Short/h7dDetectPropVsCentrality", "h7dDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisK0Mass}); + histos.add("K0Short/h5dPosDetectPropVsCentrality", "h5dPosDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisK0Mass}); + histos.add("K0Short/h5dNegDetectPropVsCentrality", "h5dNegDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisK0Mass}); } if (doDetectPropQA == 3) { - histos.add("K0Short/h3dPositiveITSclusters", "h3dPositiveITSclusters", kTH3F, {axisCentrality, axisPtCoarse, axisITSclus}); - histos.add("K0Short/h3dNegativeITSclusters", "h3dNegativeITSclusters", kTH3F, {axisCentrality, axisPtCoarse, axisITSclus}); - histos.add("K0Short/h3dPositiveTPCcrossedRows", "h3dPositiveTPCcrossedRows", kTH3F, {axisCentrality, axisPtCoarse, axisTPCrows}); - histos.add("K0Short/h3dNegativeTPCcrossedRows", "h3dNegativeTPCcrossedRows", kTH3F, {axisCentrality, axisPtCoarse, axisTPCrows}); + histos.add("K0Short/h3dITSchi2", "h3dMaxITSchi2", kTH3D, {axisCentrality, axisPtCoarse, axisITSchi2}); + histos.add("K0Short/h3dTPCchi2", "h3dMaxTPCchi2", kTH3D, {axisCentrality, axisPtCoarse, axisTPCchi2}); + histos.add("K0Short/h3dTPCFoundOverFindable", "h3dTPCFoundOverFindable", kTH3D, {axisCentrality, axisPtCoarse, axisTPCfoundOverFindable}); + histos.add("K0Short/h3dTPCrowsOverFindable", "h3dTPCrowsOverFindable", kTH3D, {axisCentrality, axisPtCoarse, axisTPCrowsOverFindable}); + histos.add("K0Short/h3dTPCsharedCls", "h3dTPCsharedCls", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsharedClusters}); + histos.add("K0Short/h3dPositiveITSchi2", "h3dPositiveITSchi2", kTH3D, {axisCentrality, axisPtCoarse, axisITSchi2}); + histos.add("K0Short/h3dNegativeITSchi2", "h3dNegativeITSchi2", kTH3D, {axisCentrality, axisPtCoarse, axisITSchi2}); + histos.add("K0Short/h3dPositiveTPCchi2", "h3dPositiveTPCchi2", kTH3D, {axisCentrality, axisPtCoarse, axisTPCchi2}); + histos.add("K0Short/h3dNegativeTPCchi2", "h3dNegativeTPCchi2", kTH3D, {axisCentrality, axisPtCoarse, axisTPCchi2}); + histos.add("K0Short/h3dPositiveITSclusters", "h3dPositiveITSclusters", kTH3D, {axisCentrality, axisPtCoarse, axisITSclus}); + histos.add("K0Short/h3dNegativeITSclusters", "h3dNegativeITSclusters", kTH3D, {axisCentrality, axisPtCoarse, axisITSclus}); + histos.add("K0Short/h3dPositiveTPCcrossedRows", "h3dPositiveTPCcrossedRows", kTH3D, {axisCentrality, axisPtCoarse, axisTPCrows}); + histos.add("K0Short/h3dNegativeTPCcrossedRows", "h3dNegativeTPCcrossedRows", kTH3D, {axisCentrality, axisPtCoarse, axisTPCrows}); } } if (analyseLambda) { - histos.add("h2dNbrOfLambdaVsCentrality", "h2dNbrOfLambdaVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); - histos.add("h3dMassLambda", "h3dMassLambda", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h2dNbrOfLambdaVsCentrality", "h2dNbrOfLambdaVsCentrality", kTH2D, {axisCentrality, {10, -0.5f, 9.5f}}); + histos.add("h3dMassLambda", "h3dMassLambda", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); // Non-UPC info - histos.add("h3dMassLambdaHadronic", "h3dMassLambdaHadronic", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h3dMassLambdaHadronic", "h3dMassLambdaHadronic", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); // UPC info - histos.add("h3dMassLambdaSGA", "h3dMassLambdaSGA", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); - histos.add("h3dMassLambdaSGC", "h3dMassLambdaSGC", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); - histos.add("h3dMassLambdaDG", "h3dMassLambdaDG", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h3dMassLambdaSGA", "h3dMassLambdaSGA", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h3dMassLambdaSGC", "h3dMassLambdaSGC", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h3dMassLambdaDG", "h3dMassLambdaDG", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); if (doTPCQA) { - histos.add("Lambda/h3dPosNsigmaTPC", "h3dPosNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("Lambda/h3dNegNsigmaTPC", "h3dNegNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("Lambda/h3dPosTPCsignal", "h3dPosTPCsignal", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("Lambda/h3dNegTPCsignal", "h3dNegTPCsignal", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("Lambda/h3dPosNsigmaTPCvsTrackPtot", "h3dPosNsigmaTPCvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("Lambda/h3dNegNsigmaTPCvsTrackPtot", "h3dNegNsigmaTPCvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("Lambda/h3dPosTPCsignalVsTrackPtot", "h3dPosTPCsignalVsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("Lambda/h3dNegTPCsignalVsTrackPtot", "h3dNegTPCsignalVsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("Lambda/h3dPosNsigmaTPCvsTrackPt", "h3dPosNsigmaTPCvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("Lambda/h3dNegNsigmaTPCvsTrackPt", "h3dNegNsigmaTPCvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("Lambda/h3dPosTPCsignalVsTrackPt", "h3dPosTPCsignalVsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("Lambda/h3dNegTPCsignalVsTrackPt", "h3dNegTPCsignalVsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("Lambda/h3dPosNsigmaTPC", "h3dPosNsigmaTPC", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("Lambda/h3dNegNsigmaTPC", "h3dNegNsigmaTPC", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("Lambda/h3dPosTPCsignal", "h3dPosTPCsignal", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("Lambda/h3dNegTPCsignal", "h3dNegTPCsignal", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("Lambda/h3dPosNsigmaTPCvsTrackPtot", "h3dPosNsigmaTPCvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("Lambda/h3dNegNsigmaTPCvsTrackPtot", "h3dNegNsigmaTPCvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("Lambda/h3dPosTPCsignalVsTrackPtot", "h3dPosTPCsignalVsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("Lambda/h3dNegTPCsignalVsTrackPtot", "h3dNegTPCsignalVsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("Lambda/h3dPosNsigmaTPCvsTrackPt", "h3dPosNsigmaTPCvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("Lambda/h3dNegNsigmaTPCvsTrackPt", "h3dNegNsigmaTPCvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("Lambda/h3dPosTPCsignalVsTrackPt", "h3dPosTPCsignalVsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("Lambda/h3dNegTPCsignalVsTrackPt", "h3dNegTPCsignalVsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); } if (doTOFQA) { - histos.add("Lambda/h3dPosNsigmaTOF", "h3dPosNsigmaTOF", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("Lambda/h3dNegNsigmaTOF", "h3dNegNsigmaTOF", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("Lambda/h3dPosTOFdeltaT", "h3dPosTOFdeltaT", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("Lambda/h3dNegTOFdeltaT", "h3dNegTOFdeltaT", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("Lambda/h3dPosNsigmaTOFvsTrackPtot", "h3dPosNsigmaTOFvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("Lambda/h3dNegNsigmaTOFvsTrackPtot", "h3dNegNsigmaTOFvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("Lambda/h3dPosTOFdeltaTvsTrackPtot", "h3dPosTOFdeltaTvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("Lambda/h3dNegTOFdeltaTvsTrackPtot", "h3dNegTOFdeltaTvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("Lambda/h3dPosNsigmaTOFvsTrackPt", "h3dPosNsigmaTOFvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("Lambda/h3dNegNsigmaTOFvsTrackPt", "h3dNegNsigmaTOFvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("Lambda/h3dPosTOFdeltaTvsTrackPt", "h3dPosTOFdeltaTvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("Lambda/h3dNegTOFdeltaTvsTrackPt", "h3dNegTOFdeltaTvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("Lambda/h3dPosNsigmaTOF", "h3dPosNsigmaTOF", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("Lambda/h3dNegNsigmaTOF", "h3dNegNsigmaTOF", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("Lambda/h3dPosTOFdeltaT", "h3dPosTOFdeltaT", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("Lambda/h3dNegTOFdeltaT", "h3dNegTOFdeltaT", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("Lambda/h3dPosNsigmaTOFvsTrackPtot", "h3dPosNsigmaTOFvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("Lambda/h3dNegNsigmaTOFvsTrackPtot", "h3dNegNsigmaTOFvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("Lambda/h3dPosTOFdeltaTvsTrackPtot", "h3dPosTOFdeltaTvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("Lambda/h3dNegTOFdeltaTvsTrackPtot", "h3dNegTOFdeltaTvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("Lambda/h3dPosNsigmaTOFvsTrackPt", "h3dPosNsigmaTOFvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("Lambda/h3dNegNsigmaTOFvsTrackPt", "h3dNegNsigmaTOFvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("Lambda/h3dPosTOFdeltaTvsTrackPt", "h3dPosTOFdeltaTvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("Lambda/h3dNegTOFdeltaTvsTrackPt", "h3dNegTOFdeltaTvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); } if (doCollisionAssociationQA) { - histos.add("Lambda/h2dPtVsNch", "h2dPtVsNch", kTH2F, {axisMonteCarloNch, axisPt}); - histos.add("Lambda/h2dPtVsNch_BadCollAssig", "h2dPtVsNch_BadCollAssig", kTH2F, {axisMonteCarloNch, axisPt}); + histos.add("Lambda/h2dPtVsNch", "h2dPtVsNch", kTH2D, {axisMonteCarloNch, axisPt}); + histos.add("Lambda/h2dPtVsNch_BadCollAssig", "h2dPtVsNch_BadCollAssig", kTH2D, {axisMonteCarloNch, axisPt}); } if (doDetectPropQA == 1) { - histos.add("Lambda/h6dDetectPropVsCentrality", "h6dDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); - histos.add("Lambda/h4dPosDetectPropVsCentrality", "h4dPosDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); - histos.add("Lambda/h4dNegDetectPropVsCentrality", "h4dNegDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); + histos.add("Lambda/h6dDetectPropVsCentrality", "h6dDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); + histos.add("Lambda/h4dPosDetectPropVsCentrality", "h4dPosDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); + histos.add("Lambda/h4dNegDetectPropVsCentrality", "h4dNegDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); } if (doDetectPropQA == 2) { - histos.add("Lambda/h7dDetectPropVsCentrality", "h7dDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisLambdaMass}); - histos.add("Lambda/h5dPosDetectPropVsCentrality", "h5dPosDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisLambdaMass}); - histos.add("Lambda/h5dNegDetectPropVsCentrality", "h5dNegDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisLambdaMass}); + histos.add("Lambda/h7dDetectPropVsCentrality", "h7dDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisLambdaMass}); + histos.add("Lambda/h5dPosDetectPropVsCentrality", "h5dPosDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisLambdaMass}); + histos.add("Lambda/h5dNegDetectPropVsCentrality", "h5dNegDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisLambdaMass}); } if (doDetectPropQA == 3) { - histos.add("Lambda/h3dPositiveITSclusters", "h3dPositiveITSclusters", kTH3F, {axisCentrality, axisPtCoarse, axisITSclus}); - histos.add("Lambda/h3dNegativeITSclusters", "h3dNegativeITSclusters", kTH3F, {axisCentrality, axisPtCoarse, axisITSclus}); - histos.add("Lambda/h3dPositiveTPCcrossedRows", "h3dPositiveTPCcrossedRows", kTH3F, {axisCentrality, axisPtCoarse, axisTPCrows}); - histos.add("Lambda/h3dNegativeTPCcrossedRows", "h3dNegativeTPCcrossedRows", kTH3F, {axisCentrality, axisPtCoarse, axisTPCrows}); + histos.add("Lambda/h3dITSchi2", "h3dMaxITSchi2", kTH3D, {axisCentrality, axisPtCoarse, axisITSchi2}); + histos.add("Lambda/h3dTPCchi2", "h3dMaxTPCchi2", kTH3D, {axisCentrality, axisPtCoarse, axisTPCchi2}); + histos.add("Lambda/h3dTPCFoundOverFindable", "h3dTPCFoundOverFindable", kTH3D, {axisCentrality, axisPtCoarse, axisTPCfoundOverFindable}); + histos.add("Lambda/h3dTPCrowsOverFindable", "h3dTPCrowsOverFindable", kTH3D, {axisCentrality, axisPtCoarse, axisTPCrowsOverFindable}); + histos.add("Lambda/h3dTPCsharedCls", "h3dTPCsharedCls", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsharedClusters}); + histos.add("Lambda/h3dPositiveITSchi2", "h3dPositiveITSchi2", kTH3D, {axisCentrality, axisPtCoarse, axisITSchi2}); + histos.add("Lambda/h3dNegativeITSchi2", "h3dNegativeITSchi2", kTH3D, {axisCentrality, axisPtCoarse, axisITSchi2}); + histos.add("Lambda/h3dPositiveTPCchi2", "h3dPositiveTPCchi2", kTH3D, {axisCentrality, axisPtCoarse, axisTPCchi2}); + histos.add("Lambda/h3dNegativeTPCchi2", "h3dNegativeTPCchi2", kTH3D, {axisCentrality, axisPtCoarse, axisTPCchi2}); + histos.add("Lambda/h3dPositiveITSclusters", "h3dPositiveITSclusters", kTH3D, {axisCentrality, axisPtCoarse, axisITSclus}); + histos.add("Lambda/h3dNegativeITSclusters", "h3dNegativeITSclusters", kTH3D, {axisCentrality, axisPtCoarse, axisITSclus}); + histos.add("Lambda/h3dPositiveTPCcrossedRows", "h3dPositiveTPCcrossedRows", kTH3D, {axisCentrality, axisPtCoarse, axisTPCrows}); + histos.add("Lambda/h3dNegativeTPCcrossedRows", "h3dNegativeTPCcrossedRows", kTH3D, {axisCentrality, axisPtCoarse, axisTPCrows}); } } if (analyseAntiLambda) { - histos.add("h2dNbrOfAntiLambdaVsCentrality", "h2dNbrOfAntiLambdaVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); - histos.add("h3dMassAntiLambda", "h3dMassAntiLambda", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h2dNbrOfAntiLambdaVsCentrality", "h2dNbrOfAntiLambdaVsCentrality", kTH2D, {axisCentrality, {10, -0.5f, 9.5f}}); + histos.add("h3dMassAntiLambda", "h3dMassAntiLambda", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); // Non-UPC info - histos.add("h3dMassAntiLambdaHadronic", "h3dMassAntiLambdaHadronic", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h3dMassAntiLambdaHadronic", "h3dMassAntiLambdaHadronic", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); // UPC info - histos.add("h3dMassAntiLambdaSGA", "h3dMassAntiLambdaSGA", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); - histos.add("h3dMassAntiLambdaSGC", "h3dMassAntiLambdaSGC", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); - histos.add("h3dMassAntiLambdaDG", "h3dMassAntiLambdaDG", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h3dMassAntiLambdaSGA", "h3dMassAntiLambdaSGA", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h3dMassAntiLambdaSGC", "h3dMassAntiLambdaSGC", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); + histos.add("h3dMassAntiLambdaDG", "h3dMassAntiLambdaDG", kTH3D, {axisCentrality, axisPt, axisLambdaMass}); if (doTPCQA) { - histos.add("AntiLambda/h3dPosNsigmaTPC", "h3dPosNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("AntiLambda/h3dNegNsigmaTPC", "h3dNegNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("AntiLambda/h3dPosTPCsignal", "h3dPosTPCsignal", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("AntiLambda/h3dNegTPCsignal", "h3dNegTPCsignal", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("AntiLambda/h3dPosNsigmaTPCvsTrackPtot", "h3dPosNsigmaTPCvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("AntiLambda/h3dNegNsigmaTPCvsTrackPtot", "h3dNegNsigmaTPCvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("AntiLambda/h3dPosTPCsignalVsTrackPtot", "h3dPosTPCsignalVsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("AntiLambda/h3dNegTPCsignalVsTrackPtot", "h3dNegTPCsignalVsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("AntiLambda/h3dPosNsigmaTPCvsTrackPt", "h3dPosNsigmaTPCvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("AntiLambda/h3dNegNsigmaTPCvsTrackPt", "h3dNegNsigmaTPCvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); - histos.add("AntiLambda/h3dPosTPCsignalVsTrackPt", "h3dPosTPCsignalVsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); - histos.add("AntiLambda/h3dNegTPCsignalVsTrackPt", "h3dNegTPCsignalVsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("AntiLambda/h3dPosNsigmaTPC", "h3dPosNsigmaTPC", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("AntiLambda/h3dNegNsigmaTPC", "h3dNegNsigmaTPC", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("AntiLambda/h3dPosTPCsignal", "h3dPosTPCsignal", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("AntiLambda/h3dNegTPCsignal", "h3dNegTPCsignal", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("AntiLambda/h3dPosNsigmaTPCvsTrackPtot", "h3dPosNsigmaTPCvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("AntiLambda/h3dNegNsigmaTPCvsTrackPtot", "h3dNegNsigmaTPCvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("AntiLambda/h3dPosTPCsignalVsTrackPtot", "h3dPosTPCsignalVsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("AntiLambda/h3dNegTPCsignalVsTrackPtot", "h3dNegTPCsignalVsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("AntiLambda/h3dPosNsigmaTPCvsTrackPt", "h3dPosNsigmaTPCvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("AntiLambda/h3dNegNsigmaTPCvsTrackPt", "h3dNegNsigmaTPCvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); + histos.add("AntiLambda/h3dPosTPCsignalVsTrackPt", "h3dPosTPCsignalVsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); + histos.add("AntiLambda/h3dNegTPCsignalVsTrackPt", "h3dNegTPCsignalVsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsignal}); } if (doTOFQA) { - histos.add("AntiLambda/h3dPosNsigmaTOF", "h3dPosNsigmaTOF", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("AntiLambda/h3dNegNsigmaTOF", "h3dNegNsigmaTOF", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("AntiLambda/h3dPosTOFdeltaT", "h3dPosTOFdeltaT", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("AntiLambda/h3dNegTOFdeltaT", "h3dNegTOFdeltaT", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("AntiLambda/h3dPosNsigmaTOFvsTrackPtot", "h3dPosNsigmaTOFvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("AntiLambda/h3dNegNsigmaTOFvsTrackPtot", "h3dNegNsigmaTOFvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("AntiLambda/h3dPosTOFdeltaTvsTrackPtot", "h3dPosTOFdeltaTvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("AntiLambda/h3dNegTOFdeltaTvsTrackPtot", "h3dNegTOFdeltaTvsTrackPtot", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("AntiLambda/h3dPosNsigmaTOFvsTrackPt", "h3dPosNsigmaTOFvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("AntiLambda/h3dNegNsigmaTOFvsTrackPt", "h3dNegNsigmaTOFvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); - histos.add("AntiLambda/h3dPosTOFdeltaTvsTrackPt", "h3dPosTOFdeltaTvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); - histos.add("AntiLambda/h3dNegTOFdeltaTvsTrackPt", "h3dNegTOFdeltaTvsTrackPt", kTH3F, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("AntiLambda/h3dPosNsigmaTOF", "h3dPosNsigmaTOF", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("AntiLambda/h3dNegNsigmaTOF", "h3dNegNsigmaTOF", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("AntiLambda/h3dPosTOFdeltaT", "h3dPosTOFdeltaT", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("AntiLambda/h3dNegTOFdeltaT", "h3dNegTOFdeltaT", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("AntiLambda/h3dPosNsigmaTOFvsTrackPtot", "h3dPosNsigmaTOFvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("AntiLambda/h3dNegNsigmaTOFvsTrackPtot", "h3dNegNsigmaTOFvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("AntiLambda/h3dPosTOFdeltaTvsTrackPtot", "h3dPosTOFdeltaTvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("AntiLambda/h3dNegTOFdeltaTvsTrackPtot", "h3dNegTOFdeltaTvsTrackPtot", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("AntiLambda/h3dPosNsigmaTOFvsTrackPt", "h3dPosNsigmaTOFvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("AntiLambda/h3dNegNsigmaTOFvsTrackPt", "h3dNegNsigmaTOFvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisNsigmaTOF}); + histos.add("AntiLambda/h3dPosTOFdeltaTvsTrackPt", "h3dPosTOFdeltaTvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); + histos.add("AntiLambda/h3dNegTOFdeltaTvsTrackPt", "h3dNegTOFdeltaTvsTrackPt", kTH3D, {axisCentrality, axisPtCoarse, axisTOFdeltaT}); } if (doCollisionAssociationQA) { - histos.add("AntiLambda/h2dPtVsNch", "h2dPtVsNch", kTH2F, {axisMonteCarloNch, axisPt}); - histos.add("AntiLambda/h2dPtVsNch_BadCollAssig", "h2dPtVsNch_BadCollAssig", kTH2F, {axisMonteCarloNch, axisPt}); + histos.add("AntiLambda/h2dPtVsNch", "h2dPtVsNch", kTH2D, {axisMonteCarloNch, axisPt}); + histos.add("AntiLambda/h2dPtVsNch_BadCollAssig", "h2dPtVsNch_BadCollAssig", kTH2D, {axisMonteCarloNch, axisPt}); } if (doDetectPropQA == 1) { - histos.add("AntiLambda/h6dDetectPropVsCentrality", "h6dDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); - histos.add("AntiLambda/h4dPosDetectPropVsCentrality", "h4dPosDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); - histos.add("AntiLambda/h4dNegDetectPropVsCentrality", "h4dNegDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); + histos.add("AntiLambda/h6dDetectPropVsCentrality", "h6dDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); + histos.add("AntiLambda/h4dPosDetectPropVsCentrality", "h4dPosDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); + histos.add("AntiLambda/h4dNegDetectPropVsCentrality", "h4dNegDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse}); } if (doDetectPropQA == 2) { - histos.add("AntiLambda/h7dDetectPropVsCentrality", "h7dDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisLambdaMass}); - histos.add("AntiLambda/h5dPosDetectPropVsCentrality", "h5dPosDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisLambdaMass}); - histos.add("AntiLambda/h5dNegDetectPropVsCentrality", "h5dNegDetectPropVsCentrality", kTHnF, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisLambdaMass}); + histos.add("AntiLambda/h7dDetectPropVsCentrality", "h7dDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisLambdaMass}); + histos.add("AntiLambda/h5dPosDetectPropVsCentrality", "h5dPosDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisLambdaMass}); + histos.add("AntiLambda/h5dNegDetectPropVsCentrality", "h5dNegDetectPropVsCentrality", kTHnD, {axisCentrality, axisDetMap, axisITScluMap, axisPtCoarse, axisLambdaMass}); } if (doDetectPropQA == 3) { - histos.add("AntiLambda/h3dPositiveITSclusters", "h3dPositiveITSclusters", kTH3F, {axisCentrality, axisPtCoarse, axisITSclus}); - histos.add("AntiLambda/h3dNegativeITSclusters", "h3dNegativeITSclusters", kTH3F, {axisCentrality, axisPtCoarse, axisITSclus}); - histos.add("AntiLambda/h3dPositiveTPCcrossedRows", "h3dPositiveTPCcrossedRows", kTH3F, {axisCentrality, axisPtCoarse, axisTPCrows}); - histos.add("AntiLambda/h3dNegativeTPCcrossedRows", "h3dNegativeTPCcrossedRows", kTH3F, {axisCentrality, axisPtCoarse, axisTPCrows}); - } - } - - if (analyseLambda && calculateFeeddownMatrix && doprocessMonteCarlo) - histos.add("h3dLambdaFeeddown", "h3dLambdaFeeddown", kTH3F, {axisCentrality, axisPt, axisPtXi}); - if (analyseAntiLambda && calculateFeeddownMatrix && doprocessMonteCarlo) - histos.add("h3dAntiLambdaFeeddown", "h3dAntiLambdaFeeddown", kTH3F, {axisCentrality, axisPt, axisPtXi}); + histos.add("AntiLambda/h3dITSchi2", "h3dMaxITSchi2", kTH3D, {axisCentrality, axisPtCoarse, axisITSchi2}); + histos.add("AntiLambda/h3dTPCchi2", "h3dMaxTPCchi2", kTH3D, {axisCentrality, axisPtCoarse, axisTPCchi2}); + histos.add("AntiLambda/h3dTPCFoundOverFindable", "h3dTPCFoundOverFindable", kTH3D, {axisCentrality, axisPtCoarse, axisTPCfoundOverFindable}); + histos.add("AntiLambda/h3dTPCrowsOverFindable", "h3dTPCrowsOverFindable", kTH3D, {axisCentrality, axisPtCoarse, axisTPCrowsOverFindable}); + histos.add("AntiLambda/h3dTPCsharedCls", "h3dTPCsharedCls", kTH3D, {axisCentrality, axisPtCoarse, axisTPCsharedClusters}); + histos.add("AntiLambda/h3dPositiveITSchi2", "h3dPositiveITSchi2", kTH3D, {axisCentrality, axisPtCoarse, axisITSchi2}); + histos.add("AntiLambda/h3dNegativeITSchi2", "h3dNegativeITSchi2", kTH3D, {axisCentrality, axisPtCoarse, axisITSchi2}); + histos.add("AntiLambda/h3dPositiveTPCchi2", "h3dPositiveTPCchi2", kTH3D, {axisCentrality, axisPtCoarse, axisTPCchi2}); + histos.add("AntiLambda/h3dNegativeTPCchi2", "h3dNegativeTPCchi2", kTH3D, {axisCentrality, axisPtCoarse, axisTPCchi2}); + histos.add("AntiLambda/h3dPositiveITSclusters", "h3dPositiveITSclusters", kTH3D, {axisCentrality, axisPtCoarse, axisITSclus}); + histos.add("AntiLambda/h3dNegativeITSclusters", "h3dNegativeITSclusters", kTH3D, {axisCentrality, axisPtCoarse, axisITSclus}); + histos.add("AntiLambda/h3dPositiveTPCcrossedRows", "h3dPositiveTPCcrossedRows", kTH3D, {axisCentrality, axisPtCoarse, axisTPCrows}); + histos.add("AntiLambda/h3dNegativeTPCcrossedRows", "h3dNegativeTPCcrossedRows", kTH3D, {axisCentrality, axisPtCoarse, axisTPCrows}); + } + } + + if (analyseLambda && calculateFeeddownMatrix && (doprocessMonteCarloRun3 || doprocessMonteCarloRun2)) + histos.add("h3dLambdaFeeddown", "h3dLambdaFeeddown", kTH3D, {axisCentrality, axisPt, axisPtXi}); + if (analyseAntiLambda && calculateFeeddownMatrix && (doprocessMonteCarloRun3 || doprocessMonteCarloRun2)) + histos.add("h3dAntiLambdaFeeddown", "h3dAntiLambdaFeeddown", kTH3D, {axisCentrality, axisPt, axisPtXi}); // demo // fast - histos.add("hMassK0Short", "hMassK0Short", kTH1F, {axisK0Mass}); + histos.add("hMassK0Short", "hMassK0Short", kTH1D, {axisK0Mass}); // QA histograms if requested if (doCompleteTopoQA) { // initialize for K0short... if (analyseK0Short) { - histos.add("K0Short/h4dPosDCAToPV", "h4dPosDCAToPV", kTHnF, {axisCentrality, axisPtCoarse, axisK0Mass, axisDCAtoPV}); - histos.add("K0Short/h4dNegDCAToPV", "h4dNegDCAToPV", kTHnF, {axisCentrality, axisPtCoarse, axisK0Mass, axisDCAtoPV}); - histos.add("K0Short/h4dDCADaughters", "h4dDCADaughters", kTHnF, {axisCentrality, axisPtCoarse, axisK0Mass, axisDCAdau}); - histos.add("K0Short/h4dPointingAngle", "h4dPointingAngle", kTHnF, {axisCentrality, axisPtCoarse, axisK0Mass, axisPointingAngle}); - histos.add("K0Short/h4dV0Radius", "h4dV0Radius", kTHnF, {axisCentrality, axisPtCoarse, axisK0Mass, axisV0Radius}); - histos.add("K0Short/h4dV0PhiVsEta", "h4dV0PhiVsEta", kTHnF, {axisPtCoarse, axisK0Mass, axisPhi, axisEta}); + histos.add("K0Short/h4dPosDCAToPV", "h4dPosDCAToPV", kTHnD, {axisCentrality, axisPtCoarse, axisK0Mass, axisDCAtoPV}); + histos.add("K0Short/h4dNegDCAToPV", "h4dNegDCAToPV", kTHnD, {axisCentrality, axisPtCoarse, axisK0Mass, axisDCAtoPV}); + histos.add("K0Short/h4dDCADaughters", "h4dDCADaughters", kTHnD, {axisCentrality, axisPtCoarse, axisK0Mass, axisDCAdau}); + histos.add("K0Short/h4dPointingAngle", "h4dPointingAngle", kTHnD, {axisCentrality, axisPtCoarse, axisK0Mass, axisPointingAngle}); + histos.add("K0Short/h4dV0Radius", "h4dV0Radius", kTHnD, {axisCentrality, axisPtCoarse, axisK0Mass, axisV0Radius}); + histos.add("K0Short/h4dV0PhiVsEta", "h4dV0PhiVsEta", kTHnD, {axisPtCoarse, axisK0Mass, axisPhi, axisEta}); } if (analyseLambda) { - histos.add("Lambda/h4dPosDCAToPV", "h4dPosDCAToPV", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); - histos.add("Lambda/h4dNegDCAToPV", "h4dNegDCAToPV", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); - histos.add("Lambda/h4dDCADaughters", "h4dDCADaughters", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAdau}); - histos.add("Lambda/h4dPointingAngle", "h4dPointingAngle", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisPointingAngle}); - histos.add("Lambda/h4dV0Radius", "h4dV0Radius", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisV0Radius}); - histos.add("Lambda/h4dV0PhiVsEta", "h4dV0PhiVsEta", kTHnF, {axisPtCoarse, axisK0Mass, axisPhi, axisEta}); + histos.add("Lambda/h4dPosDCAToPV", "h4dPosDCAToPV", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); + histos.add("Lambda/h4dNegDCAToPV", "h4dNegDCAToPV", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); + histos.add("Lambda/h4dDCADaughters", "h4dDCADaughters", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAdau}); + histos.add("Lambda/h4dPointingAngle", "h4dPointingAngle", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisPointingAngle}); + histos.add("Lambda/h4dV0Radius", "h4dV0Radius", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisV0Radius}); + histos.add("Lambda/h4dV0PhiVsEta", "h4dV0PhiVsEta", kTHnD, {axisPtCoarse, axisK0Mass, axisPhi, axisEta}); } if (analyseAntiLambda) { - histos.add("AntiLambda/h4dPosDCAToPV", "h4dPosDCAToPV", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); - histos.add("AntiLambda/h4dNegDCAToPV", "h4dNegDCAToPV", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); - histos.add("AntiLambda/h4dDCADaughters", "h4dDCADaughters", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAdau}); - histos.add("AntiLambda/h4dPointingAngle", "h4dPointingAngle", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisPointingAngle}); - histos.add("AntiLambda/h4dV0Radius", "h4dV0Radius", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisV0Radius}); - histos.add("AntiLambda/h4dV0PhiVsEta", "h4dV0PhiVsEta", kTHnF, {axisPtCoarse, axisK0Mass, axisPhi, axisEta}); + histos.add("AntiLambda/h4dPosDCAToPV", "h4dPosDCAToPV", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); + histos.add("AntiLambda/h4dNegDCAToPV", "h4dNegDCAToPV", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); + histos.add("AntiLambda/h4dDCADaughters", "h4dDCADaughters", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAdau}); + histos.add("AntiLambda/h4dPointingAngle", "h4dPointingAngle", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisPointingAngle}); + histos.add("AntiLambda/h4dV0Radius", "h4dV0Radius", kTHnD, {axisCentrality, axisPtCoarse, axisLambdaMass, axisV0Radius}); + histos.add("AntiLambda/h4dV0PhiVsEta", "h4dV0PhiVsEta", kTHnD, {axisPtCoarse, axisK0Mass, axisPhi, axisEta}); } } if (doPlainTopoQA) { // All candidates received - histos.add("hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("hDCADaughters", "hDCADaughters", kTH1F, {axisDCAdau}); - histos.add("hPointingAngle", "hPointingAngle", kTH1F, {axisPointingAngle}); - histos.add("hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); - histos.add("h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("hPosDCAToPV", "hPosDCAToPV", kTH1D, {axisDCAtoPV}); + histos.add("hNegDCAToPV", "hNegDCAToPV", kTH1D, {axisDCAtoPV}); + histos.add("hDCADaughters", "hDCADaughters", kTH1D, {axisDCAdau}); + histos.add("hPointingAngle", "hPointingAngle", kTH1D, {axisPointingAngle}); + histos.add("hV0Radius", "hV0Radius", kTH1D, {axisV0Radius}); + histos.add("h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2D, {axisTPCrows, axisITSclus}); + histos.add("h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2D, {axisTPCrows, axisITSclus}); if (analyseK0Short) { - histos.add("K0Short/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("K0Short/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("K0Short/hDCADaughters", "hDCADaughters", kTH1F, {axisDCAdau}); - histos.add("K0Short/hPointingAngle", "hPointingAngle", kTH1F, {axisPointingAngle}); - histos.add("K0Short/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); - histos.add("K0Short/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("K0Short/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("K0Short/hPosDCAToPV", "hPosDCAToPV", kTH1D, {axisDCAtoPV}); + histos.add("K0Short/hNegDCAToPV", "hNegDCAToPV", kTH1D, {axisDCAtoPV}); + histos.add("K0Short/hDCADaughters", "hDCADaughters", kTH1D, {axisDCAdau}); + histos.add("K0Short/hPointingAngle", "hPointingAngle", kTH1D, {axisPointingAngle}); + histos.add("K0Short/hV0Radius", "hV0Radius", kTH1D, {axisV0Radius}); + histos.add("K0Short/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2D, {axisTPCrows, axisITSclus}); + histos.add("K0Short/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2D, {axisTPCrows, axisITSclus}); } if (analyseLambda) { - histos.add("Lambda/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("Lambda/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("Lambda/hDCADaughters", "hDCADaughters", kTH1F, {axisDCAdau}); - histos.add("Lambda/hPointingAngle", "hPointingAngle", kTH1F, {axisPointingAngle}); - histos.add("Lambda/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); - histos.add("Lambda/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("Lambda/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("Lambda/hPosDCAToPV", "hPosDCAToPV", kTH1D, {axisDCAtoPV}); + histos.add("Lambda/hNegDCAToPV", "hNegDCAToPV", kTH1D, {axisDCAtoPV}); + histos.add("Lambda/hDCADaughters", "hDCADaughters", kTH1D, {axisDCAdau}); + histos.add("Lambda/hPointingAngle", "hPointingAngle", kTH1D, {axisPointingAngle}); + histos.add("Lambda/hV0Radius", "hV0Radius", kTH1D, {axisV0Radius}); + histos.add("Lambda/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2D, {axisTPCrows, axisITSclus}); + histos.add("Lambda/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2D, {axisTPCrows, axisITSclus}); } if (analyseAntiLambda) { - histos.add("AntiLambda/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("AntiLambda/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("AntiLambda/hDCADaughters", "hDCADaughters", kTH1F, {axisDCAdau}); - histos.add("AntiLambda/hPointingAngle", "hPointingAngle", kTH1F, {axisPointingAngle}); - histos.add("AntiLambda/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); - histos.add("AntiLambda/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("AntiLambda/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("AntiLambda/hPosDCAToPV", "hPosDCAToPV", kTH1D, {axisDCAtoPV}); + histos.add("AntiLambda/hNegDCAToPV", "hNegDCAToPV", kTH1D, {axisDCAtoPV}); + histos.add("AntiLambda/hDCADaughters", "hDCADaughters", kTH1D, {axisDCAdau}); + histos.add("AntiLambda/hPointingAngle", "hPointingAngle", kTH1D, {axisPointingAngle}); + histos.add("AntiLambda/hV0Radius", "hV0Radius", kTH1D, {axisV0Radius}); + histos.add("AntiLambda/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2D, {axisTPCrows, axisITSclus}); + histos.add("AntiLambda/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2D, {axisTPCrows, axisITSclus}); } } // Check if doing the right thing in AP space please - histos.add("GeneralQA/h2dArmenterosAll", "h2dArmenterosAll", kTH2F, {axisAPAlpha, axisAPQt}); - histos.add("GeneralQA/h2dArmenterosSelected", "h2dArmenterosSelected", kTH2F, {axisAPAlpha, axisAPQt}); + histos.add("GeneralQA/h2dArmenterosAll", "h2dArmenterosAll", kTH2D, {axisAPAlpha, axisAPQt}); + histos.add("GeneralQA/h2dArmenterosSelected", "h2dArmenterosSelected", kTH2D, {axisAPAlpha, axisAPQt}); // Creation of histograms: MC generated - if (doprocessGenerated) { - histos.add("hGenEvents", "hGenEvents", kTH2F, {{axisNch}, {2, -0.5f, +1.5f}}); + if ((doprocessGeneratedRun3 || doprocessGeneratedRun2)) { + histos.add("hGenEvents", "hGenEvents", kTH2D, {{axisNch}, {2, -0.5f, +1.5f}}); histos.get(HIST("hGenEvents"))->GetYaxis()->SetBinLabel(1, "All gen. events"); histos.get(HIST("hGenEvents"))->GetYaxis()->SetBinLabel(2, "Gen. with at least 1 rec. events"); - histos.add("hGenEventCentrality", "hGenEventCentrality", kTH1F, {{100, 0.0f, +100.0f}}); + histos.add("hGenEventCentrality", "hGenEventCentrality", kTH1D, {{101, 0.0f, 101.0f}}); - histos.add("hCentralityVsNcoll_beforeEvSel", "hCentralityVsNcoll_beforeEvSel", kTH2F, {axisCentrality, {50, -0.5f, 49.5f}}); - histos.add("hCentralityVsNcoll_afterEvSel", "hCentralityVsNcoll_afterEvSel", kTH2F, {axisCentrality, {50, -0.5f, 49.5f}}); + histos.add("hCentralityVsNcoll_beforeEvSel", "hCentralityVsNcoll_beforeEvSel", kTH2D, {axisCentrality, {50, -0.5f, 49.5f}}); + histos.add("hCentralityVsNcoll_afterEvSel", "hCentralityVsNcoll_afterEvSel", kTH2D, {axisCentrality, {50, -0.5f, 49.5f}}); - histos.add("hCentralityVsMultMC", "hCentralityVsMultMC", kTH2F, {{100, 0.0f, 100.0f}, axisNch}); + histos.add("hCentralityVsMultMC", "hCentralityVsMultMC", kTH2D, {{101, 0.0f, 101.0f}, axisNch}); histos.add("h2dGenK0Short", "h2dGenK0Short", kTH2D, {axisCentrality, axisPt}); histos.add("h2dGenLambda", "h2dGenLambda", kTH2D, {axisCentrality, axisPt}); @@ -755,6 +971,18 @@ struct derivedlambdakzeroanalysis { histos.print(); } + // ______________________________________________________ + // Return slicing output + template + auto getGroupedCollisions(TCollisions const& collisions, int globalIndex) + { + if constexpr (run3) { // check if we are in Run 3 + return collisions.sliceBy(perMcCollision, globalIndex); + } else { // we are in Run2 + return collisions.sliceBy(perMcCollisionRun2, globalIndex); + } + } + template void initCCDB(TCollision collision) { @@ -771,7 +999,7 @@ struct derivedlambdakzeroanalysis { int64_t timeStampML = collision.timestamp(); if (mlConfigurations.timestampCCDB.value != -1) timeStampML = mlConfigurations.timestampCCDB.value; - LoadMachines(timeStampML); + loadMachines(timeStampML); } } @@ -782,106 +1010,120 @@ struct derivedlambdakzeroanalysis { uint64_t bitMap = 0; // Base topological variables if (v0.v0radius() > v0Selections.v0radius) - bitset(bitMap, selRadius); + BITSET(bitMap, selRadius); if (v0.v0radius() < v0Selections.v0radiusMax) - bitset(bitMap, selRadiusMax); - if (TMath::Abs(v0.dcapostopv()) > v0Selections.dcapostopv) - bitset(bitMap, selDCAPosToPV); - if (TMath::Abs(v0.dcanegtopv()) > v0Selections.dcanegtopv) - bitset(bitMap, selDCANegToPV); + BITSET(bitMap, selRadiusMax); + if (std::abs(v0.dcapostopv()) > v0Selections.dcapostopv) + BITSET(bitMap, selDCAPosToPV); + if (std::abs(v0.dcanegtopv()) > v0Selections.dcanegtopv) + BITSET(bitMap, selDCANegToPV); if (v0.v0cosPA() > v0Selections.v0cospa) - bitset(bitMap, selCosPA); + BITSET(bitMap, selCosPA); if (v0.dcaV0daughters() < v0Selections.dcav0dau) - bitset(bitMap, selDCAV0Dau); + BITSET(bitMap, selDCAV0Dau); // rapidity - if (TMath::Abs(rapidityLambda) < v0Selections.rapidityCut) - bitset(bitMap, selLambdaRapidity); - if (TMath::Abs(rapidityK0Short) < v0Selections.rapidityCut) - bitset(bitMap, selK0ShortRapidity); + if (std::abs(rapidityLambda) < v0Selections.rapidityCut) + BITSET(bitMap, selLambdaRapidity); + if (std::abs(rapidityK0Short) < v0Selections.rapidityCut) + BITSET(bitMap, selK0ShortRapidity); - auto posTrackExtra = v0.template posTrackExtra_as(); - auto negTrackExtra = v0.template negTrackExtra_as(); + auto posTrackExtra = v0.template posTrackExtra_as(); + auto negTrackExtra = v0.template negTrackExtra_as(); // ITS quality flags - bool posIsFromAfterburner = posTrackExtra.itsChi2PerNcl() < 0; - bool negIsFromAfterburner = negTrackExtra.itsChi2PerNcl() < 0; - - // check minimum number of ITS clusters + reject ITS afterburner tracks if requested - if (posTrackExtra.itsNCls() >= v0Selections.minITSclusters && (!v0Selections.rejectPosITSafterburner || !posIsFromAfterburner)) - bitset(bitMap, selPosGoodITSTrack); - if (negTrackExtra.itsNCls() >= v0Selections.minITSclusters && (!v0Selections.rejectNegITSafterburner || !negIsFromAfterburner)) - bitset(bitMap, selNegGoodITSTrack); + bool posIsFromAfterburner = posTrackExtra.hasITSAfterburner(); + bool negIsFromAfterburner = negTrackExtra.hasITSAfterburner(); + + // check minimum number of ITS clusters + maximum ITS chi2 per clusters + reject or select ITS afterburner tracks if requested + if (posTrackExtra.itsNCls() >= v0Selections.minITSclusters && // check minium ITS clusters + posTrackExtra.itsChi2NCl() < v0Selections.maxITSchi2PerNcls && // check maximum ITS chi2 per clusters + (!v0Selections.rejectPosITSafterburner || !posIsFromAfterburner) && // reject afterburner track or not + (!v0Selections.requirePosITSafterburnerOnly || posIsFromAfterburner)) // keep afterburner track or not + BITSET(bitMap, selPosGoodITSTrack); + if (negTrackExtra.itsNCls() >= v0Selections.minITSclusters && // check minium ITS clusters + negTrackExtra.itsChi2NCl() < v0Selections.maxITSchi2PerNcls && // check maximum ITS chi2 per clusters + (!v0Selections.rejectNegITSafterburner || !negIsFromAfterburner) && // reject afterburner track or not + (!v0Selections.requireNegITSafterburnerOnly || negIsFromAfterburner)) // select only afterburner track or not + BITSET(bitMap, selNegGoodITSTrack); // TPC quality flags - if (posTrackExtra.tpcCrossedRows() >= v0Selections.minTPCrows) - bitset(bitMap, selPosGoodTPCTrack); - if (negTrackExtra.tpcCrossedRows() >= v0Selections.minTPCrows) - bitset(bitMap, selNegGoodTPCTrack); + if (posTrackExtra.tpcCrossedRows() >= v0Selections.minTPCrows && // check minimum TPC crossed rows + posTrackExtra.tpcChi2NCl() < v0Selections.maxTPCchi2PerNcls && // check maximum TPC chi2 per clusters + posTrackExtra.tpcCrossedRowsOverFindableCls() >= v0Selections.minTPCrowsOverFindableClusters && // check minimum fraction of TPC rows over findable + posTrackExtra.tpcFoundOverFindableCls() >= v0Selections.minTPCfoundOverFindableClusters && // check minimum fraction of found over findable TPC clusters + posTrackExtra.tpcFractionSharedCls() < v0Selections.maxFractionTPCSharedClusters) // check the maximum fraction of allowed shared TPC clusters + BITSET(bitMap, selPosGoodTPCTrack); + if (negTrackExtra.tpcCrossedRows() >= v0Selections.minTPCrows && // check minimum TPC crossed rows + negTrackExtra.tpcChi2NCl() < v0Selections.maxTPCchi2PerNcls && // check maximum TPC chi2 per clusters + negTrackExtra.tpcCrossedRowsOverFindableCls() >= v0Selections.minTPCrowsOverFindableClusters && // check minimum fraction of TPC rows over findable + negTrackExtra.tpcFoundOverFindableCls() >= v0Selections.minTPCfoundOverFindableClusters && // check minimum fraction of found over findable TPC clusters + negTrackExtra.tpcFractionSharedCls() < v0Selections.maxFractionTPCSharedClusters) // check the maximum fraction of allowed shared TPC clusters + BITSET(bitMap, selNegGoodTPCTrack); // TPC PID - if (fabs(posTrackExtra.tpcNSigmaPi()) < v0Selections.TpcPidNsigmaCut) - bitset(bitMap, selTPCPIDPositivePion); - if (fabs(posTrackExtra.tpcNSigmaPr()) < v0Selections.TpcPidNsigmaCut) - bitset(bitMap, selTPCPIDPositiveProton); - if (fabs(negTrackExtra.tpcNSigmaPi()) < v0Selections.TpcPidNsigmaCut) - bitset(bitMap, selTPCPIDNegativePion); - if (fabs(negTrackExtra.tpcNSigmaPr()) < v0Selections.TpcPidNsigmaCut) - bitset(bitMap, selTPCPIDNegativeProton); + if (std::fabs(posTrackExtra.tpcNSigmaPi()) < v0Selections.tpcPidNsigmaCut) + BITSET(bitMap, selTPCPIDPositivePion); + if (std::fabs(posTrackExtra.tpcNSigmaPr()) < v0Selections.tpcPidNsigmaCut) + BITSET(bitMap, selTPCPIDPositiveProton); + if (std::fabs(negTrackExtra.tpcNSigmaPi()) < v0Selections.tpcPidNsigmaCut) + BITSET(bitMap, selTPCPIDNegativePion); + if (std::fabs(negTrackExtra.tpcNSigmaPr()) < v0Selections.tpcPidNsigmaCut) + BITSET(bitMap, selTPCPIDNegativeProton); // TOF PID in DeltaT // Positive track - if (fabs(v0.posTOFDeltaTLaPr()) < v0Selections.maxDeltaTimeProton) - bitset(bitMap, selTOFDeltaTPositiveProtonLambda); - if (fabs(v0.posTOFDeltaTLaPi()) < v0Selections.maxDeltaTimePion) - bitset(bitMap, selTOFDeltaTPositivePionLambda); - if (fabs(v0.posTOFDeltaTK0Pi()) < v0Selections.maxDeltaTimePion) - bitset(bitMap, selTOFDeltaTPositivePionK0Short); + if (std::fabs(v0.posTOFDeltaTLaPr()) < v0Selections.maxDeltaTimeProton) + BITSET(bitMap, selTOFDeltaTPositiveProtonLambda); + if (std::fabs(v0.posTOFDeltaTLaPi()) < v0Selections.maxDeltaTimePion) + BITSET(bitMap, selTOFDeltaTPositivePionLambda); + if (std::fabs(v0.posTOFDeltaTK0Pi()) < v0Selections.maxDeltaTimePion) + BITSET(bitMap, selTOFDeltaTPositivePionK0Short); // Negative track - if (fabs(v0.negTOFDeltaTLaPr()) < v0Selections.maxDeltaTimeProton) - bitset(bitMap, selTOFDeltaTNegativeProtonLambda); - if (fabs(v0.negTOFDeltaTLaPi()) < v0Selections.maxDeltaTimePion) - bitset(bitMap, selTOFDeltaTNegativePionLambda); - if (fabs(v0.negTOFDeltaTK0Pi()) < v0Selections.maxDeltaTimePion) - bitset(bitMap, selTOFDeltaTNegativePionK0Short); + if (std::fabs(v0.negTOFDeltaTLaPr()) < v0Selections.maxDeltaTimeProton) + BITSET(bitMap, selTOFDeltaTNegativeProtonLambda); + if (std::fabs(v0.negTOFDeltaTLaPi()) < v0Selections.maxDeltaTimePion) + BITSET(bitMap, selTOFDeltaTNegativePionLambda); + if (std::fabs(v0.negTOFDeltaTK0Pi()) < v0Selections.maxDeltaTimePion) + BITSET(bitMap, selTOFDeltaTNegativePionK0Short); // TOF PID in NSigma // Positive track - if (fabs(v0.tofNSigmaLaPr()) < v0Selections.TofPidNsigmaCutLaPr) - bitset(bitMap, selTOFNSigmaPositiveProtonLambda); - if (fabs(v0.tofNSigmaALaPi()) < v0Selections.TofPidNsigmaCutLaPi) - bitset(bitMap, selTOFNSigmaPositivePionLambda); - if (fabs(v0.tofNSigmaK0PiPlus()) < v0Selections.TofPidNsigmaCutK0Pi) - bitset(bitMap, selTOFNSigmaPositivePionK0Short); + if (std::fabs(v0.tofNSigmaLaPr()) < v0Selections.tofPidNsigmaCutLaPr) + BITSET(bitMap, selTOFNSigmaPositiveProtonLambda); + if (std::fabs(v0.tofNSigmaALaPi()) < v0Selections.tofPidNsigmaCutLaPi) + BITSET(bitMap, selTOFNSigmaPositivePionLambda); + if (std::fabs(v0.tofNSigmaK0PiPlus()) < v0Selections.tofPidNsigmaCutK0Pi) + BITSET(bitMap, selTOFNSigmaPositivePionK0Short); // Negative track - if (fabs(v0.tofNSigmaALaPr()) < v0Selections.TofPidNsigmaCutLaPr) - bitset(bitMap, selTOFNSigmaNegativeProtonLambda); - if (fabs(v0.tofNSigmaLaPi()) < v0Selections.TofPidNsigmaCutLaPi) - bitset(bitMap, selTOFNSigmaNegativePionLambda); - if (fabs(v0.tofNSigmaK0PiMinus()) < v0Selections.TofPidNsigmaCutK0Pi) - bitset(bitMap, selTOFNSigmaNegativePionK0Short); + if (std::fabs(v0.tofNSigmaALaPr()) < v0Selections.tofPidNsigmaCutLaPr) + BITSET(bitMap, selTOFNSigmaNegativeProtonLambda); + if (std::fabs(v0.tofNSigmaLaPi()) < v0Selections.tofPidNsigmaCutLaPi) + BITSET(bitMap, selTOFNSigmaNegativePionLambda); + if (std::fabs(v0.tofNSigmaK0PiMinus()) < v0Selections.tofPidNsigmaCutK0Pi) + BITSET(bitMap, selTOFNSigmaNegativePionK0Short); // ITS only tag if (posTrackExtra.tpcCrossedRows() < 1) - bitset(bitMap, selPosItsOnly); + BITSET(bitMap, selPosItsOnly); if (negTrackExtra.tpcCrossedRows() < 1) - bitset(bitMap, selNegItsOnly); + BITSET(bitMap, selNegItsOnly); // TPC only tag if (posTrackExtra.detectorMap() != o2::aod::track::TPC) - bitset(bitMap, selPosNotTPCOnly); + BITSET(bitMap, selPosNotTPCOnly); if (negTrackExtra.detectorMap() != o2::aod::track::TPC) - bitset(bitMap, selNegNotTPCOnly); + BITSET(bitMap, selNegNotTPCOnly); // proper lifetime if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0 < lifetimecut->get("lifetimecutLambda")) - bitset(bitMap, selLambdaCTau); + BITSET(bitMap, selLambdaCTau); if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecut->get("lifetimecutK0S")) - bitset(bitMap, selK0ShortCTau); + BITSET(bitMap, selK0ShortCTau); // armenteros - if (v0.qtarm() * v0Selections.armPodCut > TMath::Abs(v0.alpha()) || v0Selections.armPodCut < 1e-4) - bitset(bitMap, selK0ShortArmenteros); + if (v0.qtarm() * v0Selections.armPodCut > std::abs(v0.alpha()) || v0Selections.armPodCut < 1e-4) + BITSET(bitMap, selK0ShortArmenteros); return bitMap; } @@ -897,19 +1139,19 @@ struct derivedlambdakzeroanalysis { bool isNegativePion = v0.pdgCodeNegative() == -211 || (doTreatPiToMuon && v0.pdgCodeNegative() == 13); if (v0.pdgCode() == 310 && isPositivePion && isNegativePion) { - bitset(bitMap, selConsiderK0Short); + BITSET(bitMap, selConsiderK0Short); if (v0.isPhysicalPrimary()) - bitset(bitMap, selPhysPrimK0Short); + BITSET(bitMap, selPhysPrimK0Short); } if (v0.pdgCode() == 3122 && isPositiveProton && isNegativePion) { - bitset(bitMap, selConsiderLambda); + BITSET(bitMap, selConsiderLambda); if (v0.isPhysicalPrimary()) - bitset(bitMap, selPhysPrimLambda); + BITSET(bitMap, selPhysPrimLambda); } if (v0.pdgCode() == -3122 && isPositivePion && isNegativeProton) { - bitset(bitMap, selConsiderAntiLambda); + BITSET(bitMap, selConsiderAntiLambda); if (v0.isPhysicalPrimary()) - bitset(bitMap, selPhysPrimAntiLambda); + BITSET(bitMap, selPhysPrimAntiLambda); } return bitMap; } @@ -1026,10 +1268,10 @@ struct derivedlambdakzeroanalysis { } // function to load models for ML-based classifiers - void LoadMachines(int64_t timeStampML) + void loadMachines(int64_t timeStampML) { if (mlConfigurations.loadCustomModelsFromCCDB) { - ccdbApi.init(ccdbConfigurations.ccdburl); + ccdbApi.init(ccdbConfigurations.ccdbUrl); LOG(info) << "Fetching models for timestamp: " << timeStampML; if (mlConfigurations.calculateLambdaScores) { @@ -1127,8 +1369,8 @@ struct derivedlambdakzeroanalysis { passAntiLambdaSelections = verifyMask(selMap, maskSelectionAntiLambda); } - auto posTrackExtra = v0.template posTrackExtra_as(); - auto negTrackExtra = v0.template negTrackExtra_as(); + auto posTrackExtra = v0.template posTrackExtra_as(); + auto negTrackExtra = v0.template negTrackExtra_as(); bool posIsFromAfterburner = posTrackExtra.itsChi2PerNcl() < 0; bool negIsFromAfterburner = negTrackExtra.itsChi2PerNcl() < 0; @@ -1144,7 +1386,7 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("hPosDCAToPV"), v0.dcapostopv()); histos.fill(HIST("hNegDCAToPV"), v0.dcanegtopv()); histos.fill(HIST("hDCADaughters"), v0.dcaV0daughters()); - histos.fill(HIST("hPointingAngle"), TMath::ACos(v0.v0cosPA())); + histos.fill(HIST("hPointingAngle"), std::acos(v0.v0cosPA())); histos.fill(HIST("hV0Radius"), v0.v0radius()); histos.fill(HIST("h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); histos.fill(HIST("h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); @@ -1168,7 +1410,7 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("K0Short/hPosDCAToPV"), v0.dcapostopv()); histos.fill(HIST("K0Short/hNegDCAToPV"), v0.dcanegtopv()); histos.fill(HIST("K0Short/hDCADaughters"), v0.dcaV0daughters()); - histos.fill(HIST("K0Short/hPointingAngle"), TMath::ACos(v0.v0cosPA())); + histos.fill(HIST("K0Short/hPointingAngle"), std::acos(v0.v0cosPA())); histos.fill(HIST("K0Short/hV0Radius"), v0.v0radius()); histos.fill(HIST("K0Short/h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); histos.fill(HIST("K0Short/h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); @@ -1184,6 +1426,15 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("K0Short/h5dNegDetectPropVsCentrality"), centrality, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pt, v0.mK0Short()); } if (doDetectPropQA == 3) { + histos.fill(HIST("K0Short/h3dITSchi2"), centrality, pt, std::max(posTrackExtra.itsChi2NCl(), negTrackExtra.itsChi2NCl())); + histos.fill(HIST("K0Short/h3dTPCchi2"), centrality, pt, std::max(posTrackExtra.tpcChi2NCl(), negTrackExtra.tpcChi2NCl())); + histos.fill(HIST("K0Short/h3dTPCFoundOverFindable"), centrality, pt, std::min(posTrackExtra.tpcFoundOverFindableCls(), negTrackExtra.tpcFoundOverFindableCls())); + histos.fill(HIST("K0Short/h3dTPCrowsOverFindable"), centrality, pt, std::min(posTrackExtra.tpcCrossedRowsOverFindableCls(), negTrackExtra.tpcCrossedRowsOverFindableCls())); + histos.fill(HIST("K0Short/h3dTPCsharedCls"), centrality, pt, std::max(posTrackExtra.tpcFractionSharedCls(), negTrackExtra.tpcFractionSharedCls())); + histos.fill(HIST("K0Short/h3dPositiveITSchi2"), centrality, pt, posTrackExtra.itsChi2NCl()); + histos.fill(HIST("K0Short/h3dNegativeITSchi2"), centrality, pt, negTrackExtra.itsChi2NCl()); + histos.fill(HIST("K0Short/h3dPositiveTPCchi2"), centrality, pt, posTrackExtra.tpcChi2NCl()); + histos.fill(HIST("K0Short/h3dNegativeTPCchi2"), centrality, pt, negTrackExtra.tpcChi2NCl()); histos.fill(HIST("K0Short/h3dPositiveITSclusters"), centrality, pt, posTrackExtra.itsNCls()); histos.fill(HIST("K0Short/h3dNegativeITSclusters"), centrality, pt, negTrackExtra.itsNCls()); histos.fill(HIST("K0Short/h3dPositiveTPCcrossedRows"), centrality, pt, posTrackExtra.tpcCrossedRows()); @@ -1194,10 +1445,10 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("K0Short/h3dNegNsigmaTPC"), centrality, pt, negTrackExtra.tpcNSigmaPi()); histos.fill(HIST("K0Short/h3dPosTPCsignal"), centrality, pt, posTrackExtra.tpcSignal()); histos.fill(HIST("K0Short/h3dNegTPCsignal"), centrality, pt, negTrackExtra.tpcSignal()); - histos.fill(HIST("K0Short/h3dPosNsigmaTPCvsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), posTrackExtra.tpcNSigmaPi()); - histos.fill(HIST("K0Short/h3dNegNsigmaTPCvsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), negTrackExtra.tpcNSigmaPi()); - histos.fill(HIST("K0Short/h3dPosTPCsignalVsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), posTrackExtra.tpcSignal()); - histos.fill(HIST("K0Short/h3dNegTPCsignalVsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), negTrackExtra.tpcSignal()); + histos.fill(HIST("K0Short/h3dPosNsigmaTPCvsTrackPtot"), centrality, v0.pfracpos() * v0.p(), posTrackExtra.tpcNSigmaPi()); + histos.fill(HIST("K0Short/h3dNegNsigmaTPCvsTrackPtot"), centrality, v0.pfracneg() * v0.p(), negTrackExtra.tpcNSigmaPi()); + histos.fill(HIST("K0Short/h3dPosTPCsignalVsTrackPtot"), centrality, v0.pfracpos() * v0.p(), posTrackExtra.tpcSignal()); + histos.fill(HIST("K0Short/h3dNegTPCsignalVsTrackPtot"), centrality, v0.pfracneg() * v0.p(), negTrackExtra.tpcSignal()); histos.fill(HIST("K0Short/h3dPosNsigmaTPCvsTrackPt"), centrality, v0.positivept(), posTrackExtra.tpcNSigmaPi()); histos.fill(HIST("K0Short/h3dNegNsigmaTPCvsTrackPt"), centrality, v0.negativept(), negTrackExtra.tpcNSigmaPi()); histos.fill(HIST("K0Short/h3dPosTPCsignalVsTrackPt"), centrality, v0.positivept(), posTrackExtra.tpcSignal()); @@ -1208,10 +1459,10 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("K0Short/h3dNegNsigmaTOF"), centrality, pt, v0.tofNSigmaK0PiMinus()); histos.fill(HIST("K0Short/h3dPosTOFdeltaT"), centrality, pt, v0.posTOFDeltaTK0Pi()); histos.fill(HIST("K0Short/h3dNegTOFdeltaT"), centrality, pt, v0.negTOFDeltaTK0Pi()); - histos.fill(HIST("K0Short/h3dPosNsigmaTOFvsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), v0.tofNSigmaK0PiPlus()); - histos.fill(HIST("K0Short/h3dNegNsigmaTOFvsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), v0.tofNSigmaK0PiMinus()); - histos.fill(HIST("K0Short/h3dPosTOFdeltaTvsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), v0.posTOFDeltaTK0Pi()); - histos.fill(HIST("K0Short/h3dNegTOFdeltaTvsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), v0.negTOFDeltaTK0Pi()); + histos.fill(HIST("K0Short/h3dPosNsigmaTOFvsTrackPtot"), centrality, v0.pfracpos() * v0.p(), v0.tofNSigmaK0PiPlus()); + histos.fill(HIST("K0Short/h3dNegNsigmaTOFvsTrackPtot"), centrality, v0.pfracneg() * v0.p(), v0.tofNSigmaK0PiMinus()); + histos.fill(HIST("K0Short/h3dPosTOFdeltaTvsTrackPtot"), centrality, v0.pfracpos() * v0.p(), v0.posTOFDeltaTK0Pi()); + histos.fill(HIST("K0Short/h3dNegTOFdeltaTvsTrackPtot"), centrality, v0.pfracneg() * v0.p(), v0.negTOFDeltaTK0Pi()); histos.fill(HIST("K0Short/h3dPosNsigmaTOFvsTrackPt"), centrality, v0.positivept(), v0.tofNSigmaK0PiPlus()); histos.fill(HIST("K0Short/h3dNegNsigmaTOFvsTrackPt"), centrality, v0.negativept(), v0.tofNSigmaK0PiMinus()); histos.fill(HIST("K0Short/h3dPosTOFdeltaTvsTrackPt"), centrality, v0.positivept(), v0.posTOFDeltaTK0Pi()); @@ -1233,7 +1484,7 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("Lambda/hPosDCAToPV"), v0.dcapostopv()); histos.fill(HIST("Lambda/hNegDCAToPV"), v0.dcanegtopv()); histos.fill(HIST("Lambda/hDCADaughters"), v0.dcaV0daughters()); - histos.fill(HIST("Lambda/hPointingAngle"), TMath::ACos(v0.v0cosPA())); + histos.fill(HIST("Lambda/hPointingAngle"), std::acos(v0.v0cosPA())); histos.fill(HIST("Lambda/hV0Radius"), v0.v0radius()); histos.fill(HIST("Lambda/h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); histos.fill(HIST("Lambda/h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); @@ -1249,6 +1500,15 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("Lambda/h5dNegDetectPropVsCentrality"), centrality, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pt, v0.mLambda()); } if (doDetectPropQA == 3) { + histos.fill(HIST("Lambda/h3dITSchi2"), centrality, pt, std::max(posTrackExtra.itsChi2NCl(), negTrackExtra.itsChi2NCl())); + histos.fill(HIST("Lambda/h3dTPCchi2"), centrality, pt, std::max(posTrackExtra.tpcChi2NCl(), negTrackExtra.tpcChi2NCl())); + histos.fill(HIST("Lambda/h3dTPCFoundOverFindable"), centrality, pt, std::min(posTrackExtra.tpcFoundOverFindableCls(), negTrackExtra.tpcFoundOverFindableCls())); + histos.fill(HIST("Lambda/h3dTPCrowsOverFindable"), centrality, pt, std::min(posTrackExtra.tpcCrossedRowsOverFindableCls(), negTrackExtra.tpcCrossedRowsOverFindableCls())); + histos.fill(HIST("Lambda/h3dTPCsharedCls"), centrality, pt, std::max(posTrackExtra.tpcFractionSharedCls(), negTrackExtra.tpcFractionSharedCls())); + histos.fill(HIST("Lambda/h3dPositiveITSchi2"), centrality, pt, posTrackExtra.itsChi2NCl()); + histos.fill(HIST("Lambda/h3dNegativeITSchi2"), centrality, pt, negTrackExtra.itsChi2NCl()); + histos.fill(HIST("Lambda/h3dPositiveTPCchi2"), centrality, pt, posTrackExtra.tpcChi2NCl()); + histos.fill(HIST("Lambda/h3dNegativeTPCchi2"), centrality, pt, negTrackExtra.tpcChi2NCl()); histos.fill(HIST("Lambda/h3dPositiveITSclusters"), centrality, pt, posTrackExtra.itsNCls()); histos.fill(HIST("Lambda/h3dNegativeITSclusters"), centrality, pt, negTrackExtra.itsNCls()); histos.fill(HIST("Lambda/h3dPositiveTPCcrossedRows"), centrality, pt, posTrackExtra.tpcCrossedRows()); @@ -1259,10 +1519,10 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("Lambda/h3dNegNsigmaTPC"), centrality, pt, negTrackExtra.tpcNSigmaPi()); histos.fill(HIST("Lambda/h3dPosTPCsignal"), centrality, pt, posTrackExtra.tpcSignal()); histos.fill(HIST("Lambda/h3dNegTPCsignal"), centrality, pt, negTrackExtra.tpcSignal()); - histos.fill(HIST("Lambda/h3dPosNsigmaTPCvsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), posTrackExtra.tpcNSigmaPr()); - histos.fill(HIST("Lambda/h3dNegNsigmaTPCvsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), negTrackExtra.tpcNSigmaPi()); - histos.fill(HIST("Lambda/h3dPosTPCsignalVsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), posTrackExtra.tpcSignal()); - histos.fill(HIST("Lambda/h3dNegTPCsignalVsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), negTrackExtra.tpcSignal()); + histos.fill(HIST("Lambda/h3dPosNsigmaTPCvsTrackPtot"), centrality, v0.pfracpos() * v0.p(), posTrackExtra.tpcNSigmaPr()); + histos.fill(HIST("Lambda/h3dNegNsigmaTPCvsTrackPtot"), centrality, v0.pfracneg() * v0.p(), negTrackExtra.tpcNSigmaPi()); + histos.fill(HIST("Lambda/h3dPosTPCsignalVsTrackPtot"), centrality, v0.pfracpos() * v0.p(), posTrackExtra.tpcSignal()); + histos.fill(HIST("Lambda/h3dNegTPCsignalVsTrackPtot"), centrality, v0.pfracneg() * v0.p(), negTrackExtra.tpcSignal()); histos.fill(HIST("Lambda/h3dPosNsigmaTPCvsTrackPt"), centrality, v0.positivept(), posTrackExtra.tpcNSigmaPr()); histos.fill(HIST("Lambda/h3dNegNsigmaTPCvsTrackPt"), centrality, v0.negativept(), negTrackExtra.tpcNSigmaPi()); histos.fill(HIST("Lambda/h3dPosTPCsignalVsTrackPt"), centrality, v0.positivept(), posTrackExtra.tpcSignal()); @@ -1273,10 +1533,10 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("Lambda/h3dNegNsigmaTOF"), centrality, pt, v0.tofNSigmaLaPi()); histos.fill(HIST("Lambda/h3dPosTOFdeltaT"), centrality, pt, v0.posTOFDeltaTLaPr()); histos.fill(HIST("Lambda/h3dNegTOFdeltaT"), centrality, pt, v0.negTOFDeltaTLaPi()); - histos.fill(HIST("Lambda/h3dPosNsigmaTOFvsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), v0.tofNSigmaLaPr()); - histos.fill(HIST("Lambda/h3dNegNsigmaTOFvsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), v0.tofNSigmaLaPi()); - histos.fill(HIST("Lambda/h3dPosTOFdeltaTvsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), v0.posTOFDeltaTLaPr()); - histos.fill(HIST("Lambda/h3dNegTOFdeltaTvsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), v0.negTOFDeltaTLaPi()); + histos.fill(HIST("Lambda/h3dPosNsigmaTOFvsTrackPtot"), centrality, v0.pfracpos() * v0.p(), v0.tofNSigmaLaPr()); + histos.fill(HIST("Lambda/h3dNegNsigmaTOFvsTrackPtot"), centrality, v0.pfracneg() * v0.p(), v0.tofNSigmaLaPi()); + histos.fill(HIST("Lambda/h3dPosTOFdeltaTvsTrackPtot"), centrality, v0.pfracpos() * v0.p(), v0.posTOFDeltaTLaPr()); + histos.fill(HIST("Lambda/h3dNegTOFdeltaTvsTrackPtot"), centrality, v0.pfracneg() * v0.p(), v0.negTOFDeltaTLaPi()); histos.fill(HIST("Lambda/h3dPosNsigmaTOFvsTrackPt"), centrality, v0.positivept(), v0.tofNSigmaLaPr()); histos.fill(HIST("Lambda/h3dNegNsigmaTOFvsTrackPt"), centrality, v0.negativept(), v0.tofNSigmaLaPi()); histos.fill(HIST("Lambda/h3dPosTOFdeltaTvsTrackPt"), centrality, v0.positivept(), v0.posTOFDeltaTLaPr()); @@ -1298,7 +1558,7 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("AntiLambda/hPosDCAToPV"), v0.dcapostopv()); histos.fill(HIST("AntiLambda/hNegDCAToPV"), v0.dcanegtopv()); histos.fill(HIST("AntiLambda/hDCADaughters"), v0.dcaV0daughters()); - histos.fill(HIST("AntiLambda/hPointingAngle"), TMath::ACos(v0.v0cosPA())); + histos.fill(HIST("AntiLambda/hPointingAngle"), std::acos(v0.v0cosPA())); histos.fill(HIST("AntiLambda/hV0Radius"), v0.v0radius()); histos.fill(HIST("AntiLambda/h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); histos.fill(HIST("AntiLambda/h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); @@ -1314,6 +1574,15 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("AntiLambda/h5dNegDetectPropVsCentrality"), centrality, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pt, v0.mAntiLambda()); } if (doDetectPropQA == 3) { + histos.fill(HIST("AntiLambda/h3dITSchi2"), centrality, pt, std::max(posTrackExtra.itsChi2NCl(), negTrackExtra.itsChi2NCl())); + histos.fill(HIST("AntiLambda/h3dTPCchi2"), centrality, pt, std::max(posTrackExtra.tpcChi2NCl(), negTrackExtra.tpcChi2NCl())); + histos.fill(HIST("AntiLambda/h3dTPCFoundOverFindable"), centrality, pt, std::min(posTrackExtra.tpcFoundOverFindableCls(), negTrackExtra.tpcFoundOverFindableCls())); + histos.fill(HIST("AntiLambda/h3dTPCrowsOverFindable"), centrality, pt, std::min(posTrackExtra.tpcCrossedRowsOverFindableCls(), negTrackExtra.tpcCrossedRowsOverFindableCls())); + histos.fill(HIST("AntiLambda/h3dTPCsharedCls"), centrality, pt, std::max(posTrackExtra.tpcFractionSharedCls(), negTrackExtra.tpcFractionSharedCls())); + histos.fill(HIST("AntiLambda/h3dPositiveITSchi2"), centrality, pt, posTrackExtra.itsChi2NCl()); + histos.fill(HIST("AntiLambda/h3dNegativeITSchi2"), centrality, pt, negTrackExtra.itsChi2NCl()); + histos.fill(HIST("AntiLambda/h3dPositiveTPCchi2"), centrality, pt, posTrackExtra.tpcChi2NCl()); + histos.fill(HIST("AntiLambda/h3dNegativeTPCchi2"), centrality, pt, negTrackExtra.tpcChi2NCl()); histos.fill(HIST("AntiLambda/h3dPositiveITSclusters"), centrality, pt, posTrackExtra.itsNCls()); histos.fill(HIST("AntiLambda/h3dNegativeITSclusters"), centrality, pt, negTrackExtra.itsNCls()); histos.fill(HIST("AntiLambda/h3dPositiveTPCcrossedRows"), centrality, pt, posTrackExtra.tpcCrossedRows()); @@ -1324,10 +1593,10 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("AntiLambda/h3dNegNsigmaTPC"), centrality, pt, negTrackExtra.tpcNSigmaPr()); histos.fill(HIST("AntiLambda/h3dPosTPCsignal"), centrality, pt, posTrackExtra.tpcSignal()); histos.fill(HIST("AntiLambda/h3dNegTPCsignal"), centrality, pt, negTrackExtra.tpcSignal()); - histos.fill(HIST("AntiLambda/h3dPosNsigmaTPCvsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), posTrackExtra.tpcNSigmaPi()); - histos.fill(HIST("AntiLambda/h3dNegNsigmaTPCvsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), negTrackExtra.tpcNSigmaPr()); - histos.fill(HIST("AntiLambda/h3dPosTPCsignalVsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), posTrackExtra.tpcSignal()); - histos.fill(HIST("AntiLambda/h3dNegTPCsignalVsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), negTrackExtra.tpcSignal()); + histos.fill(HIST("AntiLambda/h3dPosNsigmaTPCvsTrackPtot"), centrality, v0.pfracpos() * v0.p(), posTrackExtra.tpcNSigmaPi()); + histos.fill(HIST("AntiLambda/h3dNegNsigmaTPCvsTrackPtot"), centrality, v0.pfracneg() * v0.p(), negTrackExtra.tpcNSigmaPr()); + histos.fill(HIST("AntiLambda/h3dPosTPCsignalVsTrackPtot"), centrality, v0.pfracpos() * v0.p(), posTrackExtra.tpcSignal()); + histos.fill(HIST("AntiLambda/h3dNegTPCsignalVsTrackPtot"), centrality, v0.pfracneg() * v0.p(), negTrackExtra.tpcSignal()); histos.fill(HIST("AntiLambda/h3dPosNsigmaTPCvsTrackPt"), centrality, v0.positivept(), posTrackExtra.tpcNSigmaPi()); histos.fill(HIST("AntiLambda/h3dNegNsigmaTPCvsTrackPt"), centrality, v0.negativept(), negTrackExtra.tpcNSigmaPr()); histos.fill(HIST("AntiLambda/h3dPosTPCsignalVsTrackPt"), centrality, v0.positivept(), posTrackExtra.tpcSignal()); @@ -1338,10 +1607,10 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("AntiLambda/h3dNegNsigmaTOF"), centrality, pt, v0.tofNSigmaALaPr()); histos.fill(HIST("AntiLambda/h3dPosTOFdeltaT"), centrality, pt, v0.posTOFDeltaTLaPi()); histos.fill(HIST("AntiLambda/h3dNegTOFdeltaT"), centrality, pt, v0.negTOFDeltaTLaPr()); - histos.fill(HIST("AntiLambda/h3dPosNsigmaTOFvsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), v0.tofNSigmaALaPi()); - histos.fill(HIST("AntiLambda/h3dNegNsigmaTOFvsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), v0.tofNSigmaALaPr()); - histos.fill(HIST("AntiLambda/h3dPosTOFdeltaTvsTrackPtot"), centrality, v0.positivept() * TMath::CosH(v0.positiveeta()), v0.posTOFDeltaTLaPi()); - histos.fill(HIST("AntiLambda/h3dNegTOFdeltaTvsTrackPtot"), centrality, v0.negativept() * TMath::CosH(v0.negativeeta()), v0.negTOFDeltaTLaPr()); + histos.fill(HIST("AntiLambda/h3dPosNsigmaTOFvsTrackPtot"), centrality, v0.pfracpos() * v0.p(), v0.tofNSigmaALaPi()); + histos.fill(HIST("AntiLambda/h3dNegNsigmaTOFvsTrackPtot"), centrality, v0.pfracneg() * v0.p(), v0.tofNSigmaALaPr()); + histos.fill(HIST("AntiLambda/h3dPosTOFdeltaTvsTrackPtot"), centrality, v0.pfracpos() * v0.p(), v0.posTOFDeltaTLaPi()); + histos.fill(HIST("AntiLambda/h3dNegTOFdeltaTvsTrackPtot"), centrality, v0.pfracneg() * v0.p(), v0.negTOFDeltaTLaPr()); histos.fill(HIST("AntiLambda/h3dPosNsigmaTOFvsTrackPt"), centrality, v0.positivept(), v0.tofNSigmaALaPi()); histos.fill(HIST("AntiLambda/h3dNegNsigmaTOFvsTrackPt"), centrality, v0.negativept(), v0.tofNSigmaALaPr()); histos.fill(HIST("AntiLambda/h3dPosTOFdeltaTvsTrackPt"), centrality, v0.positivept(), v0.posTOFDeltaTLaPi()); @@ -1357,11 +1626,11 @@ struct derivedlambdakzeroanalysis { if (verifyMask(selMap, maskTopoNoV0Radius | maskK0ShortSpecific)) histos.fill(HIST("K0Short/h4dV0Radius"), centrality, pt, v0.mK0Short(), v0.v0radius()); if (verifyMask(selMap, maskTopoNoDCAPosToPV | maskK0ShortSpecific)) - histos.fill(HIST("K0Short/h4dPosDCAToPV"), centrality, pt, v0.mK0Short(), TMath::Abs(v0.dcapostopv())); + histos.fill(HIST("K0Short/h4dPosDCAToPV"), centrality, pt, v0.mK0Short(), std::abs(v0.dcapostopv())); if (verifyMask(selMap, maskTopoNoDCANegToPV | maskK0ShortSpecific)) - histos.fill(HIST("K0Short/h4dNegDCAToPV"), centrality, pt, v0.mK0Short(), TMath::Abs(v0.dcanegtopv())); + histos.fill(HIST("K0Short/h4dNegDCAToPV"), centrality, pt, v0.mK0Short(), std::abs(v0.dcanegtopv())); if (verifyMask(selMap, maskTopoNoCosPA | maskK0ShortSpecific)) - histos.fill(HIST("K0Short/h4dPointingAngle"), centrality, pt, v0.mK0Short(), TMath::ACos(v0.v0cosPA())); + histos.fill(HIST("K0Short/h4dPointingAngle"), centrality, pt, v0.mK0Short(), std::acos(v0.v0cosPA())); if (verifyMask(selMap, maskTopoNoDCAV0Dau | maskK0ShortSpecific)) histos.fill(HIST("K0Short/h4dDCADaughters"), centrality, pt, v0.mK0Short(), v0.dcaV0daughters()); @@ -1373,11 +1642,11 @@ struct derivedlambdakzeroanalysis { if (verifyMask(selMap, maskTopoNoV0Radius | maskLambdaSpecific)) histos.fill(HIST("Lambda/h4dV0Radius"), centrality, pt, v0.mLambda(), v0.v0radius()); if (verifyMask(selMap, maskTopoNoDCAPosToPV | maskLambdaSpecific)) - histos.fill(HIST("Lambda/h4dPosDCAToPV"), centrality, pt, v0.mLambda(), TMath::Abs(v0.dcapostopv())); + histos.fill(HIST("Lambda/h4dPosDCAToPV"), centrality, pt, v0.mLambda(), std::abs(v0.dcapostopv())); if (verifyMask(selMap, maskTopoNoDCANegToPV | maskLambdaSpecific)) - histos.fill(HIST("Lambda/h4dNegDCAToPV"), centrality, pt, v0.mLambda(), TMath::Abs(v0.dcanegtopv())); + histos.fill(HIST("Lambda/h4dNegDCAToPV"), centrality, pt, v0.mLambda(), std::abs(v0.dcanegtopv())); if (verifyMask(selMap, maskTopoNoCosPA | maskLambdaSpecific)) - histos.fill(HIST("Lambda/h4dPointingAngle"), centrality, pt, v0.mLambda(), TMath::ACos(v0.v0cosPA())); + histos.fill(HIST("Lambda/h4dPointingAngle"), centrality, pt, v0.mLambda(), std::acos(v0.v0cosPA())); if (verifyMask(selMap, maskTopoNoDCAV0Dau | maskLambdaSpecific)) histos.fill(HIST("Lambda/h4dDCADaughters"), centrality, pt, v0.mLambda(), v0.dcaV0daughters()); @@ -1388,11 +1657,11 @@ struct derivedlambdakzeroanalysis { if (verifyMask(selMap, maskTopoNoV0Radius | maskAntiLambdaSpecific)) histos.fill(HIST("AntiLambda/h4dV0Radius"), centrality, pt, v0.mAntiLambda(), v0.v0radius()); if (verifyMask(selMap, maskTopoNoDCAPosToPV | maskAntiLambdaSpecific)) - histos.fill(HIST("AntiLambda/h4dPosDCAToPV"), centrality, pt, v0.mAntiLambda(), TMath::Abs(v0.dcapostopv())); + histos.fill(HIST("AntiLambda/h4dPosDCAToPV"), centrality, pt, v0.mAntiLambda(), std::abs(v0.dcapostopv())); if (verifyMask(selMap, maskTopoNoDCANegToPV | maskAntiLambdaSpecific)) - histos.fill(HIST("AntiLambda/h4dNegDCAToPV"), centrality, pt, v0.mAntiLambda(), TMath::Abs(v0.dcanegtopv())); + histos.fill(HIST("AntiLambda/h4dNegDCAToPV"), centrality, pt, v0.mAntiLambda(), std::abs(v0.dcanegtopv())); if (verifyMask(selMap, maskTopoNoCosPA | maskAntiLambdaSpecific)) - histos.fill(HIST("AntiLambda/h4dPointingAngle"), centrality, pt, v0.mAntiLambda(), TMath::ACos(v0.v0cosPA())); + histos.fill(HIST("AntiLambda/h4dPointingAngle"), centrality, pt, v0.mAntiLambda(), std::acos(v0.v0cosPA())); if (verifyMask(selMap, maskTopoNoDCAV0Dau | maskAntiLambdaSpecific)) histos.fill(HIST("AntiLambda/h4dDCADaughters"), centrality, pt, v0.mAntiLambda(), v0.dcaV0daughters()); @@ -1435,7 +1704,7 @@ struct derivedlambdakzeroanalysis { auto v0mother = v0.motherMCPart(); float rapidityXi = RecoDecay::y(std::array{v0mother.px(), v0mother.py(), v0mother.pz()}, o2::constants::physics::MassXiMinus); - if (fabs(rapidityXi) > 0.5f) + if (std::fabs(rapidityXi) > 0.5f) return; // not a valid mother rapidity (PDG selection is later) // __________________________________________ @@ -1450,134 +1719,255 @@ struct derivedlambdakzeroanalysis { } template - bool IsEventAccepted(TCollision collision, bool fillHists) + bool isEventAccepted(TCollision collision, bool fillHists) // check whether the collision passes our collision selections { if (fillHists) histos.fill(HIST("hEventSelection"), 0. /* all collisions */); - if (eventSelections.requireSel8 && !collision.sel8()) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 1 /* sel8 collisions */); + if constexpr (requires { collision.centFT0C(); }) { // check if we are in Run 3 + if (eventSelections.requireSel8 && !collision.sel8()) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 1 /* sel8 collisions */); - if (eventSelections.requireTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 2 /* FT0 vertex (acceptable FT0C-FT0A time difference) collisions */); + if (eventSelections.requireTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 2 /* FT0 vertex (acceptable FT0C-FT0A time difference) collisions */); - if (eventSelections.rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 3 /* Not at ITS ROF border */); + if (eventSelections.rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 3 /* Not at ITS ROF border */); - if (eventSelections.rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 4 /* Not at TF border */); + if (eventSelections.rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 4 /* Not at TF border */); - if (std::abs(collision.posZ()) > eventSelections.maxZVtxPosition) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 5 /* vertex-Z selected */); + if (std::abs(collision.posZ()) > eventSelections.maxZVtxPosition) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 5 /* vertex-Z selected */); - if (eventSelections.requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 6 /* Contains at least one ITS-TPC track */); + if (eventSelections.requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 6 /* Contains at least one ITS-TPC track */); - if (eventSelections.requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 7 /* PV position consistency check */); + if (eventSelections.requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 7 /* PV position consistency check */); - if (eventSelections.requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 8 /* PV with at least one contributor matched with TOF */); + if (eventSelections.requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 8 /* PV with at least one contributor matched with TOF */); - if (eventSelections.requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 9 /* PV with at least one contributor matched with TRD */); + if (eventSelections.requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 9 /* PV with at least one contributor matched with TRD */); - if (eventSelections.rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 10 /* Not at same bunch pile-up */); + if (eventSelections.rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 10 /* Not at same bunch pile-up */); - if (eventSelections.requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 11 /* No other collision within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds*/); + if (eventSelections.requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 11 /* No other collision within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds*/); - if (eventSelections.requireNoCollInTimeRangeStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 12 /* No other collision within +/- 10 microseconds */); + if (eventSelections.requireNoCollInTimeRangeStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 12 /* No other collision within +/- 10 microseconds */); - if (eventSelections.requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 13 /* No other collision within +/- 2 microseconds */); + if (eventSelections.requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 13 /* No other collision within +/- 2 microseconds */); - if (eventSelections.requireNoCollInTimeRangeVzDep && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeVzDependent)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 14 /* No other collision with pvZ of drifting TPC tracks from past/future collisions within 2.5 cm the current pvZ */); + if (eventSelections.requireNoCollInROFStd && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 14 /* No other collision within the same ITS ROF with mult. above a certain threshold */); - if (eventSelections.requireNoCollInROFStd && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 15 /* No other collision within the same ITS ROF with mult. above a certain threshold */); + if (eventSelections.requireNoCollInROFStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 15 /* No other collision within the same ITS ROF */); - if (eventSelections.requireNoCollInROFStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { - return false; - } - if (fillHists) - histos.fill(HIST("hEventSelection"), 16 /* No other collision within the same ITS ROF */); + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && collision.multNTracksPVeta1() < 1) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 16 /* INEL > 0 */); + + if (eventSelections.requireINEL1 && collision.multNTracksPVeta1() < 2) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 17 /* INEL > 1 */); + + } else { // we are in Pb-Pb + float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + if (eventSelections.minOccupancy >= 0 && collisionOccupancy < eventSelections.minOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 16 /* Below min occupancy */); + + if (eventSelections.maxOccupancy >= 0 && collisionOccupancy > eventSelections.maxOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 17 /* Above max occupancy */); + } + + // Fetch interaction rate only if required (in order to limit ccdb calls) + double interactionRate = (eventSelections.minIR >= 0 || eventSelections.maxIR >= 0) ? rateFetcher.fetch(ccdb.service, collision.timestamp(), collision.runNumber(), irSource) * 1.e-3 : -1; + if (eventSelections.minIR >= 0 && interactionRate < eventSelections.minIR) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 18 /* Below min IR */); + + if (eventSelections.maxIR >= 0 && interactionRate > eventSelections.maxIR) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 19 /* Above max IR */); + + if (!rctConfigurations.cfgRCTLabel.value.empty() && !rctFlagsChecker(collision)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 20 /* Pass CBT condition */); + + } else { // we are in Run 2 + if (eventSelections.requireSel8 && !collision.sel8()) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 1 /* sel8 collisions */); + + if (eventSelections.requireSel7 && !collision.sel7()) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 2 /* sel7 collisions */); + + if (eventSelections.requireINT7 && !collision.alias_bit(kINT7)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 3 /* INT7-triggered collisions */); - if (doPPAnalysis) { // we are in pp - if (eventSelections.requireINEL0 && collision.multNTracksPVeta1() < 1) { + if (eventSelections.requireTriggerTVX && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { return false; } if (fillHists) - histos.fill(HIST("hEventSelection"), 17 /* INEL > 0 */); + histos.fill(HIST("hEventSelection"), 4 /* FT0 vertex (acceptable FT0C-FT0A time difference) at trigger level */); - if (eventSelections.requireINEL1 && collision.multNTracksPVeta1() < 2) { + if (eventSelections.rejectIncompleteDAQ && !collision.selection_bit(o2::aod::evsel::kNoIncompleteDAQ)) { return false; } if (fillHists) - histos.fill(HIST("hEventSelection"), 18 /* INEL > 1 */); + histos.fill(HIST("hEventSelection"), 5 /* Complete events according to DAQ flags */); - } else { // we are in Pb-Pb - float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); - if (eventSelections.minOccupancy >= 0 && collisionOccupancy < eventSelections.minOccupancy) { + if (std::abs(collision.posZ()) > eventSelections.maxZVtxPosition) { return false; } if (fillHists) - histos.fill(HIST("hEventSelection"), 17 /* Below min occupancy */); + histos.fill(HIST("hEventSelection"), 6 /* vertex-Z selected */); - if (eventSelections.maxOccupancy >= 0 && collisionOccupancy > eventSelections.maxOccupancy) { + if (eventSelections.requireConsistentSPDAndTrackVtx && !collision.selection_bit(o2::aod::evsel::kNoInconsistentVtx)) { return false; } if (fillHists) - histos.fill(HIST("hEventSelection"), 18 /* Above max occupancy */); + histos.fill(HIST("hEventSelection"), 7 /* No inconsistency in SPD and Track vertices */); + + if (eventSelections.rejectPileupFromSPD && !collision.selection_bit(o2::aod::evsel::kNoPileupFromSPD)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 8 /* No pileup according to SPD vertexer */); + + if (eventSelections.rejectV0PFPileup && !collision.selection_bit(o2::aod::evsel::kNoV0PFPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 9 /* No out-of-bunch pileup according to V0 past-future info */); + + if (eventSelections.rejectPileupInMultBins && !collision.selection_bit(o2::aod::evsel::kNoPileupInMultBins)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 10 /* No pileup according to multiplicity-differential pileup checks */); + + if (eventSelections.rejectPileupMV && !collision.selection_bit(o2::aod::evsel::kNoPileupMV)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 11 /* No pileup according to multi-vertexer */); + + if (eventSelections.rejectTPCPileup && !collision.selection_bit(o2::aod::evsel::kNoPileupTPC)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 12 /* No pileup in TPC */); + + if (eventSelections.requireNoV0MOnVsOffPileup && !collision.selection_bit(o2::aod::evsel::kNoV0MOnVsOfPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 13 /* No out-of-bunch pileup according to online-vs-offline VOM correlation */); + + if (eventSelections.requireNoSPDOnVsOffPileup && !collision.selection_bit(o2::aod::evsel::kNoSPDOnVsOfPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 14 /* No out-of-bunch pileup according to online-vs-offline SPD correlation */); + + if (eventSelections.requireNoSPDClsVsTklBG && !collision.selection_bit(o2::aod::evsel::kNoSPDClsVsTklBG)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 15 /* No beam-gas according to cluster-vs-tracklet correlation */); + + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && collision.multNTracksPVeta1() < 1) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 16 /* INEL > 0 */); + + if (eventSelections.requireINEL1 && collision.multNTracksPVeta1() < 2) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 17 /* INEL > 1 */); + } } return true; @@ -1586,18 +1976,30 @@ struct derivedlambdakzeroanalysis { // ______________________________________________________ // Simulated processing // Return the list of indices to the recoed collision associated to a given MC collision. - std::vector getListOfRecoCollIndices(soa::Join const& mcCollisions, soa::Join const& collisions) + template + std::vector getListOfRecoCollIndices(TMCollisions const& mcCollisions, TCollisions const& collisions) { std::vector listBestCollisionIdx(mcCollisions.size()); for (auto const& mcCollision : mcCollisions) { - auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex()); - // Find the collision with the biggest nbr of PV contributors - // Follows what was done here: https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/mcCollsExtra.cxx#L93 + auto groupedCollisions = getGroupedCollisions(collisions, mcCollision.globalIndex()); int biggestNContribs = -1; int bestCollisionIndex = -1; for (auto const& collision : groupedCollisions) { - if (biggestNContribs < collision.multPVTotalContributors()) { - biggestNContribs = collision.multPVTotalContributors(); + // consider event selections in the recoed <-> gen collision association, for the denominator (or numerator) of the efficiency (or signal loss)? + if (eventSelections.useEvtSelInDenomEff) { + if (!isEventAccepted(collision, false)) { + continue; + } + } + + if constexpr (run3) { // check if we are in Run 3 + // Find the collision with the biggest nbr of PV contributors + // Follows what was done here: https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/mcCollsExtra.cxx#L93 + if (biggestNContribs < collision.multPVTotalContributors()) { + biggestNContribs = collision.multPVTotalContributors(); + bestCollisionIndex = collision.globalIndex(); + } + } else { // we are in Run 2: there should be only one collision in groupedCollisions bestCollisionIndex = collision.globalIndex(); } } @@ -1606,16 +2008,81 @@ struct derivedlambdakzeroanalysis { return listBestCollisionIdx; } + // ______________________________________________________ + // Reconstructed data processing + // Fill reconstructed event information + // Return centrality, occupancy, interaction rate, gap side and selGapside via reference-passing in arguments + template + void fillReconstructedEventProperties(TCollision const& collision, float& centrality, float& collisionOccupancy, double& interactionRate, int& gapSide, int& selGapSide) + { + if constexpr (requires { collision.centFT0C(); }) { // check if we are in Run 3 + centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + // Fetch interaction rate only if required (in order to limit ccdb calls) + interactionRate = !irSource.value.empty() ? rateFetcher.fetch(ccdb.service, collision.timestamp(), collision.runNumber(), irSource) * 1.e-3 : -1; + + if (qaCentrality) { + auto hRawCentrality = histos.get(HIST("hRawCentrality")); + centrality = hRawCentrality->GetBinContent(hRawCentrality->FindBin(doPPAnalysis ? collision.multFT0A() + collision.multFT0C() : collision.multFT0C())); + } + + // gap side + gapSide = collision.gapSide(); + // -1 --> Hadronic + // 0 --> Single Gap - A side + // 1 --> Single Gap - C side + // 2 --> Double Gap - both A & C sides + selGapSide = sgSelector.trueGap(collision, upcCuts.fv0Cut, upcCuts.ft0Acut, upcCuts.ft0Ccut, upcCuts.zdcCut); + } else { // no, we are in Run 2 + centrality = eventSelections.useSPDTrackletsCent ? collision.centRun2SPDTracklets() : collision.centRun2V0M(); + } + + histos.fill(HIST("hGapSide"), gapSide); + histos.fill(HIST("hSelGapSide"), selGapSide); + histos.fill(HIST("hEventCentralityVsSelGapSide"), centrality, selGapSide <= 2 ? selGapSide : -1); + + histos.fill(HIST("hEventCentrality"), centrality); + + histos.fill(HIST("hCentralityVsNch"), centrality, collision.multNTracksPVeta1()); + + histos.fill(HIST("hCentralityVsPVz"), centrality, collision.posZ()); + histos.fill(HIST("hEventPVz"), collision.posZ()); + + histos.fill(HIST("hEventOccupancy"), collisionOccupancy); + histos.fill(HIST("hCentralityVsOccupancy"), centrality, collisionOccupancy); + + histos.fill(HIST("hInteractionRate"), interactionRate); + histos.fill(HIST("hCentralityVsInteractionRate"), centrality, interactionRate); + + histos.fill(HIST("hInteractionRateVsOccupancy"), interactionRate, collisionOccupancy); + return; + } + // ______________________________________________________ // Simulated processing // Fill generated event information (for event loss/splitting estimation) - void fillGeneratedEventProperties(soa::Join const& mcCollisions, soa::Join const& collisions) + template + void fillGeneratedEventProperties(TMCCollisions const& mcCollisions, TCollisions const& collisions) { std::vector listBestCollisionIdx(mcCollisions.size()); for (auto const& mcCollision : mcCollisions) { + // Apply selections on MC collisions + if (eventSelections.applyZVtxSelOnMCPV && std::abs(mcCollision.posZ()) > eventSelections.maxZVtxPosition) { + continue; + } + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && mcCollision.multMCNParticlesEta10() < 1) { + continue; + } + + if (eventSelections.requireINEL1 && mcCollision.multMCNParticlesEta10() < 2) { + continue; + } + } + histos.fill(HIST("hGenEvents"), mcCollision.multMCNParticlesEta05(), 0 /* all gen. events*/); - auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex()); + auto groupedCollisions = getGroupedCollisions(collisions, mcCollision.globalIndex()); // Check if there is at least one of the reconstructed collisions associated to this MC collision // If so, we consider it bool atLeastOne = false; @@ -1624,13 +2091,17 @@ struct derivedlambdakzeroanalysis { int nCollisions = 0; for (auto const& collision : groupedCollisions) { - if (!IsEventAccepted(collision, false)) { + if (!isEventAccepted(collision, false)) { continue; } - if (biggestNContribs < collision.multPVTotalContributors()) { - biggestNContribs = collision.multPVTotalContributors(); - centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + if constexpr (run3) { // check if we are in Run 3 + if (biggestNContribs < collision.multPVTotalContributors()) { + biggestNContribs = collision.multPVTotalContributors(); + centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + } + } else { // we are in Run 2: there should be only one collision in groupedCollisions + centrality = eventSelections.useSPDTrackletsCent ? collision.centRun2SPDTracklets() : collision.centRun2V0M(); } nCollisions++; @@ -1655,7 +2126,8 @@ struct derivedlambdakzeroanalysis { // ______________________________________________________ // Real data processing - no MC subscription - void processRealData(soa::Join::iterator const& collision, v0Candidates const& fullV0s, dauTracks const&) + template + void analyzeRecoedV0sInRealData(TCollision const& collision, TV0s const& fullV0s) { // Fire up CCDB if ((mlConfigurations.useK0ShortScores && mlConfigurations.calculateK0ShortScores) || @@ -1664,45 +2136,27 @@ struct derivedlambdakzeroanalysis { initCCDB(collision); } - if (!IsEventAccepted(collision, true)) { + if (!isEventAccepted(collision, true)) { return; } - float centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); - if (qaCentrality) { - auto hRawCentrality = histos.get(HIST("hRawCentrality")); - centrality = hRawCentrality->GetBinContent(hRawCentrality->FindBin(doPPAnalysis ? collision.multFT0A() + collision.multFT0C() : collision.multFT0C())); - } - float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); - + float centrality = -1; + float collisionOccupancy = -2; // -1 already taken for the case where occupancy cannot be evaluated + double interactionRate = -1; // gap side - int gapSide = collision.gapSide(); - int selGapSide = -1; - // -1 --> Hadronic - // 0 --> Single Gap - A side - // 1 --> Single Gap - C side - // 2 --> Double Gap - both A & C sides - selGapSide = sgSelector.trueGap(collision, upcCuts.FV0cut, upcCuts.FT0Acut, upcCuts.FT0Ccut, upcCuts.ZDCcut); - histos.fill(HIST("hGapSide"), gapSide); - histos.fill(HIST("hSelGapSide"), selGapSide); - histos.fill(HIST("hEventCentralityVsSelGapSide"), centrality, selGapSide <= 2 ? selGapSide : -1); - - histos.fill(HIST("hEventCentrality"), centrality); - - histos.fill(HIST("hCentralityVsNch"), centrality, collision.multNTracksPVeta1()); + int gapSide = -1; + int selGapSide = -1; // -1 --> Hadronic ; 0 --> Single Gap - A side ; 1 --> Single Gap - C side ; 2 --> Double Gap - both A & C sides + // Fill recoed event properties + fillReconstructedEventProperties(collision, centrality, collisionOccupancy, interactionRate, gapSide, selGapSide); - histos.fill(HIST("hCentralityVsPVz"), centrality, collision.posZ()); - histos.fill(HIST("hEventPVz"), collision.posZ()); - - histos.fill(HIST("hEventOccupancy"), collisionOccupancy); - histos.fill(HIST("hCentralityVsOccupancy"), centrality, collisionOccupancy); + histos.fill(HIST("hInteractionRateVsOccupancy"), interactionRate, collisionOccupancy); // __________________________________________ // perform main analysis int nK0Shorts = 0; int nLambdas = 0; int nAntiLambdas = 0; - for (auto& v0 : fullV0s) { + for (auto const& v0 : fullV0s) { if (std::abs(v0.negativeeta()) > v0Selections.daughterEtaCut || std::abs(v0.positiveeta()) > v0Selections.daughterEtaCut) continue; // remove acceptance that's badly reproduced by MC / superfluous in future @@ -1715,8 +2169,13 @@ struct derivedlambdakzeroanalysis { uint64_t selMap = computeReconstructionBitmap(v0, collision, v0.yLambda(), v0.yK0Short(), v0.pt()); // consider for histograms for all species - selMap = selMap | (uint64_t(1) << selConsiderK0Short) | (uint64_t(1) << selConsiderLambda) | (uint64_t(1) << selConsiderAntiLambda); - selMap = selMap | (uint64_t(1) << selPhysPrimK0Short) | (uint64_t(1) << selPhysPrimLambda) | (uint64_t(1) << selPhysPrimAntiLambda); + BITSET(selMap, selConsiderK0Short); + BITSET(selMap, selConsiderLambda); + BITSET(selMap, selConsiderAntiLambda); + + BITSET(selMap, selPhysPrimK0Short); + BITSET(selMap, selPhysPrimLambda); + BITSET(selMap, selPhysPrimAntiLambda); analyseCandidate(v0, v0.pt(), centrality, selMap, selGapSide, nK0Shorts, nLambdas, nAntiLambdas); } // end v0 loop @@ -1735,7 +2194,8 @@ struct derivedlambdakzeroanalysis { // ______________________________________________________ // Simulated processing (subscribes to MC information too) - void processMonteCarlo(soa::Join::iterator const& collision, v0MCCandidates const& fullV0s, dauTracks const&, aod::MotherMCParts const&, soa::Join const& /*mccollisions*/, soa::Join const&) + template + void analyzeRecoedV0sInMonteCarlo(TCollision const& collision, TV0s const& fullV0s) { // Fire up CCDB if ((mlConfigurations.useK0ShortScores && mlConfigurations.calculateK0ShortScores) || @@ -1744,45 +2204,27 @@ struct derivedlambdakzeroanalysis { initCCDB(collision); } - if (!IsEventAccepted(collision, true)) { + if (!isEventAccepted(collision, true)) { return; } - float centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); - if (qaCentrality) { - auto hRawCentrality = histos.get(HIST("hRawCentrality")); - centrality = hRawCentrality->GetBinContent(hRawCentrality->FindBin(doPPAnalysis ? collision.multFT0A() + collision.multFT0C() : collision.multFT0C())); - } - float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); - + float centrality = -1; + float collisionOccupancy = -2; // -1 already taken for the case where occupancy cannot be evaluated + double interactionRate = -1; // gap side - int gapSide = collision.gapSide(); - int selGapSide = -1; - // -1 --> Hadronic - // 0 --> Single Gap - A side - // 1 --> Single Gap - C side - // 2 --> Double Gap - both A & C sides - selGapSide = sgSelector.trueGap(collision, upcCuts.FV0cut, upcCuts.FT0Acut, upcCuts.FT0Ccut, upcCuts.ZDCcut); - histos.fill(HIST("hGapSide"), gapSide); - histos.fill(HIST("hSelGapSide"), selGapSide); - histos.fill(HIST("hEventCentralityVsSelGapSide"), centrality, selGapSide <= 2 ? selGapSide : -1); - - histos.fill(HIST("hEventCentrality"), centrality); - - histos.fill(HIST("hCentralityVsNch"), centrality, collision.multNTracksPVeta1()); + int gapSide = -1; + int selGapSide = -1; // -1 --> Hadronic ; 0 --> Single Gap - A side ; 1 --> Single Gap - C side ; 2 --> Double Gap - both A & C sides + // Fill recoed event properties + fillReconstructedEventProperties(collision, centrality, collisionOccupancy, interactionRate, gapSide, selGapSide); - histos.fill(HIST("hCentralityVsPVz"), centrality, collision.posZ()); - histos.fill(HIST("hEventPVz"), collision.posZ()); - - histos.fill(HIST("hEventOccupancy"), collisionOccupancy); - histos.fill(HIST("hCentralityVsOccupancy"), centrality, collisionOccupancy); + histos.fill(HIST("hInteractionRateVsOccupancy"), interactionRate, collisionOccupancy); // __________________________________________ // perform main analysis int nK0Shorts = 0; int nLambdas = 0; int nAntiLambdas = 0; - for (auto& v0 : fullV0s) { + for (auto const& v0 : fullV0s) { if (std::abs(v0.negativeeta()) > v0Selections.daughterEtaCut || std::abs(v0.positiveeta()) > v0Selections.daughterEtaCut) continue; // remove acceptance that's badly reproduced by MC / superfluous in future @@ -1792,7 +2234,7 @@ struct derivedlambdakzeroanalysis { if (!v0.has_v0MCCore()) continue; - auto v0MC = v0.v0MCCore_as>(); + auto v0MC = v0.template v0MCCore_as>(); // fill AP plot for all V0s histos.fill(HIST("GeneralQA/h2dArmenterosAll"), v0.alpha(), v0.qtarm()); @@ -1801,7 +2243,7 @@ struct derivedlambdakzeroanalysis { float ymc = 1e-3; if (v0MC.pdgCode() == 310) ymc = RecoDecay::y(std::array{v0MC.pxPosMC() + v0MC.pxNegMC(), v0MC.pyPosMC() + v0MC.pyNegMC(), v0MC.pzPosMC() + v0MC.pzNegMC()}, o2::constants::physics::MassKaonNeutral); - else if (TMath::Abs(v0MC.pdgCode()) == 3122) + else if (std::abs(v0MC.pdgCode()) == 3122) ymc = RecoDecay::y(std::array{v0MC.pxPosMC() + v0MC.pxNegMC(), v0MC.pyPosMC() + v0MC.pyNegMC(), v0MC.pzPosMC() + v0MC.pzNegMC()}, o2::constants::physics::MassLambda); uint64_t selMap = computeReconstructionBitmap(v0, collision, ymc, ymc, ptmc); @@ -1813,8 +2255,13 @@ struct derivedlambdakzeroanalysis { // consider only associated candidates if asked to do so, disregard association if (!doMCAssociation) { - selMap = selMap | (uint64_t(1) << selConsiderK0Short) | (uint64_t(1) << selConsiderLambda) | (uint64_t(1) << selConsiderAntiLambda); - selMap = selMap | (uint64_t(1) << selPhysPrimK0Short) | (uint64_t(1) << selPhysPrimLambda) | (uint64_t(1) << selPhysPrimAntiLambda); + BITSET(selMap, selConsiderK0Short); + BITSET(selMap, selConsiderLambda); + BITSET(selMap, selConsiderAntiLambda); + + BITSET(selMap, selPhysPrimK0Short); + BITSET(selMap, selPhysPrimLambda); + BITSET(selMap, selPhysPrimAntiLambda); } analyseCandidate(v0, ptmc, centrality, selMap, selGapSide, nK0Shorts, nLambdas, nAntiLambdas); @@ -1824,7 +2271,7 @@ struct derivedlambdakzeroanalysis { bool correctCollision = false; int mcNch = -1; if (collision.has_straMCCollision()) { - auto mcCollision = collision.straMCCollision_as>(); + auto mcCollision = collision.template straMCCollision_as>(); mcNch = mcCollision.multMCNParticlesEta05(); correctCollision = (v0MC.straMCCollisionId() == mcCollision.globalIndex()); } @@ -1847,28 +2294,35 @@ struct derivedlambdakzeroanalysis { // ______________________________________________________ // Simulated processing (subscribes to MC information too) - void processGenerated(soa::Join const& mcCollisions, soa::Join const& V0MCCores, soa::Join const& CascMCCores, soa::Join const& collisions) + template + void analyzeGeneratedV0s(TMCCollisions const& mcCollisions, TV0MCs const& V0MCCores, TCascMCs const& CascMCCores, TCollisions const& collisions) { - fillGeneratedEventProperties(mcCollisions, collisions); - std::vector listBestCollisionIdx = getListOfRecoCollIndices(mcCollisions, collisions); + fillGeneratedEventProperties(mcCollisions, collisions); + std::vector listBestCollisionIdx = getListOfRecoCollIndices(mcCollisions, collisions); for (auto const& v0MC : V0MCCores) { if (!v0MC.has_straMCCollision()) continue; + histos.fill(HIST("hPrimaryV0s"), 0); if (!v0MC.isPhysicalPrimary()) continue; + histos.fill(HIST("hPrimaryV0s"), 1); + float ptmc = v0MC.ptMC(); float ymc = 1e3; if (v0MC.pdgCode() == 310) ymc = v0MC.rapidityMC(0); - else if (TMath::Abs(v0MC.pdgCode()) == 3122) + else if (std::abs(v0MC.pdgCode()) == 3122) ymc = v0MC.rapidityMC(1); - if (TMath::Abs(ymc) > v0Selections.rapidityCut) + if (std::abs(ymc) > v0Selections.rapidityCut) continue; - auto mcCollision = v0MC.straMCCollision_as>(); + auto mcCollision = v0MC.template straMCCollision_as>(); + if (eventSelections.applyZVtxSelOnMCPV && std::abs(mcCollision.posZ()) > eventSelections.maxZVtxPosition) { + continue; + } if (doPPAnalysis) { // we are in pp if (eventSelections.requireINEL0 && mcCollision.multMCNParticlesEta10() < 1) { continue; @@ -1882,14 +2336,10 @@ struct derivedlambdakzeroanalysis { float centrality = 100.5f; if (listBestCollisionIdx[mcCollision.globalIndex()] > -1) { auto collision = collisions.iteratorAt(listBestCollisionIdx[mcCollision.globalIndex()]); - centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); - float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); - - if (eventSelections.minOccupancy >= 0 && collisionOccupancy < eventSelections.minOccupancy) { - continue; - } - if (eventSelections.maxOccupancy >= 0 && collisionOccupancy > eventSelections.maxOccupancy) { - continue; + if constexpr (requires { collision.centFT0C(); }) { // check if we are in Run 3 + centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + } else { // no, we are in Run 2 + centrality = eventSelections.useSPDTrackletsCent ? collision.centRun2SPDTracklets() : collision.centRun2V0M(); } if (v0MC.pdgCode() == 310) { @@ -1926,15 +2376,18 @@ struct derivedlambdakzeroanalysis { float ptmc = cascMC.ptMC(); float ymc = 1e3; - if (TMath::Abs(cascMC.pdgCode()) == 3312) + if (std::abs(cascMC.pdgCode()) == 3312) ymc = cascMC.rapidityMC(0); - else if (TMath::Abs(cascMC.pdgCode()) == 3334) + else if (std::abs(cascMC.pdgCode()) == 3334) ymc = cascMC.rapidityMC(2); - if (TMath::Abs(ymc) > v0Selections.rapidityCut) + if (std::abs(ymc) > v0Selections.rapidityCut) continue; - auto mcCollision = cascMC.straMCCollision_as>(); + auto mcCollision = cascMC.template straMCCollision_as>(); + if (eventSelections.applyZVtxSelOnMCPV && std::abs(mcCollision.posZ()) > eventSelections.maxZVtxPosition) { + continue; + } if (doPPAnalysis) { // we are in pp if (eventSelections.requireINEL0 && mcCollision.multMCNParticlesEta10() < 1) { continue; @@ -1948,14 +2401,10 @@ struct derivedlambdakzeroanalysis { float centrality = 100.5f; if (listBestCollisionIdx[mcCollision.globalIndex()] > -1) { auto collision = collisions.iteratorAt(listBestCollisionIdx[mcCollision.globalIndex()]); - centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); - float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); - - if (eventSelections.minOccupancy >= 0 && collisionOccupancy < eventSelections.minOccupancy) { - continue; - } - if (eventSelections.maxOccupancy >= 0 && collisionOccupancy > eventSelections.maxOccupancy) { - continue; + if constexpr (requires { collision.centFT0C(); }) { // check if we are in Run 3 + centrality = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); + } else { // no, we are in Run 2 + centrality = eventSelections.useSPDTrackletsCent ? collision.centRun2SPDTracklets() : collision.centRun2V0M(); } if (cascMC.pdgCode() == 3312) { @@ -1991,6 +2440,48 @@ struct derivedlambdakzeroanalysis { } } + // ______________________________________________________ + // Real data processing in Run 3 - no MC subscription + void processRealDataRun3(soa::Join::iterator const& collision, V0Candidates const& fullV0s, DauTracks const&) + { + analyzeRecoedV0sInRealData(collision, fullV0s); + } + + // ______________________________________________________ + // Real data processing in Run 2 - no MC subscription + void processRealDataRun2(soa::Join::iterator const& collision, V0Candidates const& fullV0s, DauTracks const&) + { + analyzeRecoedV0sInRealData(collision, fullV0s); + } + + // ______________________________________________________ + // Simulated processing in Run 3 (subscribes to MC information too) + void processMonteCarloRun3(soa::Join::iterator const& collision, V0McCandidates const& fullV0s, DauTracks const&, aod::MotherMCParts const&, soa::Join const& /*mccollisions*/, soa::Join const&) + { + analyzeRecoedV0sInMonteCarlo(collision, fullV0s); + } + + // ______________________________________________________ + // Simulated processing in Run 2 (subscribes to MC information too) + void processMonteCarloRun2(soa::Join::iterator const& collision, V0McCandidates const& fullV0s, DauTracks const&, aod::MotherMCParts const&, soa::Join const& /*mccollisions*/, soa::Join const&) + { + analyzeRecoedV0sInMonteCarlo(collision, fullV0s); + } + + // ______________________________________________________ + // Simulated processing in Run 3 (subscribes to MC information too) + void processGeneratedRun3(soa::Join const& mcCollisions, soa::Join const& V0MCCores, soa::Join const& CascMCCores, soa::Join const& collisions) + { + analyzeGeneratedV0s(mcCollisions, V0MCCores, CascMCCores, collisions); + } + + // ______________________________________________________ + // Simulated processing in Run 2 (subscribes to MC information too) + void processGeneratedRun2(soa::Join const& mcCollisions, soa::Join const& V0MCCores, soa::Join const& CascMCCores, soa::Join const& collisions) + { + analyzeGeneratedV0s(mcCollisions, V0MCCores, CascMCCores, collisions); + } + // ______________________________________________________ // Simulated processing (subscribes to MC information too) void processBinnedGenerated( @@ -2005,49 +2496,49 @@ struct derivedlambdakzeroanalysis { auto hXiPlus = histos.get(HIST("h2dGeneratedXiPlus")); auto hOmegaMinus = histos.get(HIST("h2dGeneratedOmegaMinus")); auto hOmegaPlus = histos.get(HIST("h2dGeneratedOmegaPlus")); - for (auto& gVec : geK0Short) { + for (auto const& gVec : geK0Short) { if (static_cast(gVec.generatedK0Short().size()) != hK0Short->GetNcells()) LOGF(fatal, "K0Short: Number of elements in generated array and number of cells in receiving histogram differ: %i vs %i!", gVec.generatedK0Short().size(), hK0Short->GetNcells()); for (int iv = 0; iv < hK0Short->GetNcells(); iv++) { hK0Short->SetBinContent(iv, hK0Short->GetBinContent(iv) + gVec.generatedK0Short()[iv]); } } - for (auto& gVec : geLambda) { + for (auto const& gVec : geLambda) { if (static_cast(gVec.generatedLambda().size()) != hLambda->GetNcells()) LOGF(fatal, "Lambda: Number of elements in generated array and number of cells in receiving histogram differ: %i vs %i!", gVec.generatedLambda().size(), hLambda->GetNcells()); for (int iv = 0; iv < hLambda->GetNcells(); iv++) { hLambda->SetBinContent(iv, hLambda->GetBinContent(iv) + gVec.generatedLambda()[iv]); } } - for (auto& gVec : geAntiLambda) { + for (auto const& gVec : geAntiLambda) { if (static_cast(gVec.generatedAntiLambda().size()) != hAntiLambda->GetNcells()) LOGF(fatal, "AntiLambda: Number of elements in generated array and number of cells in receiving histogram differ: %i vs %i!", gVec.generatedAntiLambda().size(), hAntiLambda->GetNcells()); for (int iv = 0; iv < hAntiLambda->GetNcells(); iv++) { hAntiLambda->SetBinContent(iv, hAntiLambda->GetBinContent(iv) + gVec.generatedAntiLambda()[iv]); } } - for (auto& gVec : geXiMinus) { + for (auto const& gVec : geXiMinus) { if (static_cast(gVec.generatedXiMinus().size()) != hXiMinus->GetNcells()) LOGF(fatal, "XiMinus: Number of elements in generated array and number of cells in receiving histogram differ: %i vs %i!", gVec.generatedXiMinus().size(), hXiMinus->GetNcells()); for (int iv = 0; iv < hXiMinus->GetNcells(); iv++) { hXiMinus->SetBinContent(iv, hXiMinus->GetBinContent(iv) + gVec.generatedXiMinus()[iv]); } } - for (auto& gVec : geXiPlus) { + for (auto const& gVec : geXiPlus) { if (static_cast(gVec.generatedXiPlus().size()) != hXiPlus->GetNcells()) LOGF(fatal, "XiPlus: Number of elements in generated array and number of cells in receiving histogram differ: %i vs %i!", gVec.generatedXiPlus().size(), hXiPlus->GetNcells()); for (int iv = 0; iv < hXiPlus->GetNcells(); iv++) { hXiPlus->SetBinContent(iv, hXiPlus->GetBinContent(iv) + gVec.generatedXiPlus()[iv]); } } - for (auto& gVec : geOmegaMinus) { + for (auto const& gVec : geOmegaMinus) { if (static_cast(gVec.generatedOmegaMinus().size()) != hOmegaMinus->GetNcells()) LOGF(fatal, "OmegaMinus: Number of elements in generated array and number of cells in receiving histogram differ: %i vs %i!", gVec.generatedOmegaMinus().size(), hOmegaMinus->GetNcells()); for (int iv = 0; iv < hOmegaMinus->GetNcells(); iv++) { hOmegaMinus->SetBinContent(iv, hOmegaMinus->GetBinContent(iv) + gVec.generatedOmegaMinus()[iv]); } } - for (auto& gVec : geOmegaPlus) { + for (auto const& gVec : geOmegaPlus) { if (static_cast(gVec.generatedOmegaPlus().size()) != hOmegaPlus->GetNcells()) LOGF(fatal, "OmegaPlus: Number of elements in generated array and number of cells in receiving histogram differ: %i vs %i!", gVec.generatedOmegaPlus().size(), hOmegaPlus->GetNcells()); for (int iv = 0; iv < hOmegaPlus->GetNcells(); iv++) { @@ -2056,10 +2547,13 @@ struct derivedlambdakzeroanalysis { } } - PROCESS_SWITCH(derivedlambdakzeroanalysis, processRealData, "process as if real data", true); - PROCESS_SWITCH(derivedlambdakzeroanalysis, processMonteCarlo, "process as if MC", false); + PROCESS_SWITCH(derivedlambdakzeroanalysis, processRealDataRun3, "process as if real data in Run 3", true); + PROCESS_SWITCH(derivedlambdakzeroanalysis, processRealDataRun2, "process as if real data in Run 2", false); + PROCESS_SWITCH(derivedlambdakzeroanalysis, processMonteCarloRun3, "process as if MC in Run 3", false); + PROCESS_SWITCH(derivedlambdakzeroanalysis, processMonteCarloRun2, "process as if MC in Run 2", false); PROCESS_SWITCH(derivedlambdakzeroanalysis, processBinnedGenerated, "process MC generated", false); - PROCESS_SWITCH(derivedlambdakzeroanalysis, processGenerated, "process MC generated", false); + PROCESS_SWITCH(derivedlambdakzeroanalysis, processGeneratedRun3, "process MC generated Run 3", false); + PROCESS_SWITCH(derivedlambdakzeroanalysis, processGeneratedRun2, "process MC generated Run 2", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Strangeness/derivedupcanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedupcanalysis.cxx new file mode 100644 index 00000000000..b3021033d32 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/derivedupcanalysis.cxx @@ -0,0 +1,2285 @@ +// Copyright 2019-2025 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. +// +/// \file derivedupcanalysis.cxx +/// \brief Analysis of strangeness production in UPC collisions +/// \author Roman Nepeivoda (roman.nepeivoda@cern.ch) + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "ReconstructionDataFormats/Track.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" +#include "Framework/StaticFor.h" +#include "PWGUD/Core/SGSelector.h" +#include "PWGLF/Utils/strangenessMasks.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::rctsel; + +using std::array; + +using DauTracks = soa::Join; +using DauMCTracks = soa::Join; + +using V0Candidates = soa::Join; +using V0CandidatesMC = soa::Join; + +using CascadeCandidates = soa::Join; +using CascadeCandidatesMC = soa::Join; + +using NeutronsMC = soa::Join; + +using CascMCCoresFull = soa::Join; + +using StraCollisonFull = soa::Join::iterator; +using StraCollisonFullMC = soa::Join::iterator; + +using StraCollisonsFullMC = soa::Join; + +using StraMCCollisionsFull = soa::Join; +using V0MCCoresFull = soa::Join; + +struct Derivedupcanalysis { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // master analysis switches + Configurable analyseK0Short{"analyseK0Short", true, "process K0Short-like candidates"}; + Configurable analyseLambda{"analyseLambda", true, "process Lambda-like candidates"}; + Configurable analyseAntiLambda{"analyseAntiLambda", true, "process AntiLambda-like candidates"}; + Configurable analyseXi{"analyseXi", true, "process Xi-like candidates"}; + Configurable analyseAntiXi{"analyseAntiXi", true, "process AntiXi-like candidates"}; + Configurable analyseOmega{"analyseOmega", true, "process Omega-like candidates"}; + Configurable analyseAntiOmega{"analyseAntiOmega", true, "process AntiOmega-like candidates"}; + + Configurable> generatorIds{"generatorIds", std::vector{-1}, "MC generatorIds to process"}; + + // Event selections + struct : ConfigurableGroup { + Configurable rejectITSROFBorder{"rejectITSROFBorder", true, "reject events at ITS ROF border"}; + Configurable rejectTFBorder{"rejectTFBorder", true, "reject events at TF border"}; + Configurable rejectSameBunchPileup{"rejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC"}; + Configurable requireIsTriggerTVX{"requireIsTriggerTVX", false, "require coincidence in FT0A and FT0C"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "require events with at least one ITS-TPC track"}; + Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", false, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference"}; + Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", false, "require events with at least one of vertex contributors matched to TOF"}; + Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", false, "require events with at least one of vertex contributors matched to TRD"}; + Configurable requireNoCollInTimeRangeStd{"requireNoCollInTimeRangeStd", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 10 microseconds"}; + Configurable requireNoCollInTimeRangeNarrow{"requireNoCollInTimeRangeNarrow", true, "reject collisions corrupted by the cannibalism, with other collisions within +/- 10 microseconds"}; + Configurable studyUPConly{"studyUPConly", true, "is UPC-only analysis"}; + Configurable useUPCflag{"useUPCflag", false, "select UPC flagged events"}; + + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", true, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", false, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } evSels; + + RCTFlagsChecker rctChecker; + + Configurable verbose{"verbose", false, "additional printouts"}; + + // Acceptance selections + Configurable rapidityCut{"rapidityCut", 0.5, "rapidity"}; + Configurable daughterEtaCut{"daughterEtaCut", 0.8, "max eta for daughters"}; + + Configurable doDaughterDCA{"doDaughterDCA", true, "dcaXY cut for daughter tracks"}; + + // Standard V0 topological criteria + struct : ConfigurableGroup { + Configurable v0cospa{"v0cospa", 0.97, "min V0 CosPA"}; + Configurable dcav0dau{"dcav0dau", 1.5, "max DCA V0 Daughters (cm)"}; + Configurable dcanegtopv{"dcanegtopv", .05, "min DCA Neg To PV (cm)"}; + Configurable dcapostopv{"dcapostopv", .05, "min DCA Pos To PV (cm)"}; + Configurable v0radius{"v0radius", 1.2, "minimum V0 radius (cm)"}; + Configurable v0radiusMax{"v0radiusMax", 1E5, "maximum V0 radius (cm)"}; + // Additional selection on the AP plot (exclusive for K0Short) + // original equation: lArmPt*5>std::fabs(lArmAlpha) + Configurable armPodCut{"armPodCut", 5.0f, "pT * (cut) > |alpha|, AP cut. Negative: no cut"}; + Configurable v0TypeSelection{"v0TypeSelection", 1, "select on a certain V0 type (leave negative if no selection desired)"}; + } v0cuts; + static constexpr float kNCtauCutsV0[1][2] = {{6, 6.}}; + Configurable> nCtauCutV0{"nCtauCutV0", {kNCtauCutsV0[0], 2, {"lifetimecutLambda", "lifetimecutK0S"}}, "nCtauCutV0"}; + + // Standard cascade topological criteria + struct : ConfigurableGroup { + Configurable casccospa{"casccospa", 0.97, "Casc CosPA"}; + Configurable dcacascdau{"dcacascdau", 1.2, "DCA Casc Daughters"}; + Configurable cascradius{"cascradius", 0.6, "minimum cascade radius (cm)"}; + Configurable cascradiusMax{"cascradiusMax", 1E5, "maximum cascade radius (cm)"}; + Configurable bachbaryoncospa{"bachbaryoncospa", 2, "Bachelor baryon CosPA"}; + Configurable bachbaryondcaxytopv{"bachbaryondcaxytopv", -1, "DCA bachelor baryon to PV"}; + Configurable dcamesontopv{"dcamesontopv", 0.1, "DCA of meson doughter track To PV"}; + Configurable dcabaryontopv{"dcabaryontopv", 0.05, "DCA of baryon doughter track To PV"}; + Configurable dcabachtopv{"dcabachtopv", 0.04, "DCA Bach To PV"}; + Configurable dcav0topv{"dcav0topv", 0.06, "DCA V0 To PV"}; + // Cascade specific selections + Configurable masswin{"masswin", 0.05, "mass window limit"}; + Configurable lambdamasswin{"lambdamasswin", 0.005, "V0 Mass window limit"}; + Configurable rejcomp{"rejcomp", 0.008, "competing Cascade rejection"}; + } casccuts; + Configurable doBachelorBaryonCut{"doBachelorBaryonCut", false, "Enable Bachelor-Baryon cut "}; + static constexpr float kNCtauCutsCasc[1][2] = {{6., 6.}}; + Configurable> nCtauCutCasc{"nCtauCutCasc", {kNCtauCutsCasc[0], 2, {"lifetimecutXi", "lifetimecutOmega"}}, "nCtauCutCasc"}; + + // UPC selections + SGSelector sgSelector; + struct : ConfigurableGroup { + Configurable fv0a{"fv0a", 50., "FV0A threshold"}; + Configurable ft0a{"ft0a", 100., "FT0A threshold"}; + Configurable ft0c{"ft0c", 50., "FT0C threshold"}; + Configurable zdc{"zdc", 1., "ZDC threshold"}; + Configurable genGapSide{"genGapSide", 0, "0 -- A, 1 -- C, 2 -- double"}; + } upcCuts; + + // Track quality + struct : ConfigurableGroup { + Configurable minTPCrows{"minTPCrows", 70, "minimum TPC crossed rows"}; + Configurable minITSclusters{"minITSclusters", -1, "minimum ITS clusters"}; + Configurable skipTPConly{"skipTPConly", false, "skip V0s comprised of at least one TPC only prong"}; + Configurable requireBachITSonly{"requireBachITSonly", false, "require that bachelor track is ITSonly (overrides TPC quality)"}; + Configurable requirePosITSonly{"requirePosITSonly", false, "require that positive track is ITSonly (overrides TPC quality)"}; + Configurable requireNegITSonly{"requireNegITSonly", false, "require that negative track is ITSonly (overrides TPC quality)"}; + } TrackConfigurations; + + // PID (TPC/TOF) + struct : ConfigurableGroup { + Configurable tpcPidNsigmaCut{"tpcPidNsigmaCut", 1e+6, "tpcPidNsigmaCut"}; + Configurable tofPidNsigmaCutLaPr{"tofPidNsigmaCutLaPr", 1e+6, "tofPidNsigmaCutLaPr"}; + Configurable tofPidNsigmaCutLaPi{"tofPidNsigmaCutLaPi", 1e+6, "tofPidNsigmaCutLaPi"}; + Configurable tofPidNsigmaCutK0Pi{"tofPidNsigmaCutK0Pi", 1e+6, "tofPidNsigmaCutK0Pi"}; + + Configurable tofPidNsigmaCutXiPi{"tofPidNsigmaCutXiPi", 1e+6, "tofPidNsigmaCutXiPi"}; + Configurable tofPidNsigmaCutOmegaKaon{"tofPidNsigmaCutOmegaKaon", 1e+6, "tofPidNsigmaCutOmegaKaon"}; + + Configurable doTPCQA{"doTPCQA", false, "do TPC QA histograms"}; + Configurable doTOFQA{"doTOFQA", false, "do TOF QA histograms"}; + + // PID (TOF) + Configurable maxDeltaTimeProton{"maxDeltaTimeProton", 1e+9, "check maximum allowed time"}; + Configurable maxDeltaTimePion{"maxDeltaTimePion", 1e+9, "check maximum allowed time"}; + Configurable maxDeltaTimeKaon{"maxDeltaTimeKaon", 1e+9, "check maximum allowed time"}; + } PIDConfigurations; + + Configurable doKienmaticQA{"doKienmaticQA", true, "do Kinematic QA histograms"}; + Configurable doDetectPropQA{"doDetectPropQA", 0, "do Detector/ITS map QA: 0: no, 1: 4D, 2: 5D with mass"}; + Configurable doPlainTopoQA{"doPlainTopoQA", true, "do simple 1D QA of candidates"}; + + struct : ConfigurableGroup { + ConfigurableAxis axisFT0Aampl{"axisFT0Aampl", {100, 0.0f, 2000.0f}, "FT0Aamplitude"}; + ConfigurableAxis axisFT0Campl{"axisFT0Campl", {100, 0.0f, 2000.0f}, "FT0Camplitude"}; + ConfigurableAxis axisFT0ampl{"axisFT0ampl", {2002, -1.5f, 2000.5f}, "axisFT0ampl"}; + ConfigurableAxis axisFV0Aampl{"axisFV0Aampl", {100, 0.0f, 2000.0f}, "FV0Aamplitude"}; + ConfigurableAxis axisFDDAampl{"axisFDDAampl", {100, 0.0f, 2000.0f}, "FDDAamplitude"}; + ConfigurableAxis axisFDDCampl{"axisFDDCampl", {100, 0.0f, 2000.0f}, "FDDCamplitude"}; + ConfigurableAxis axisZNAampl{"axisZNAampl", {100, 0.0f, 250.0f}, "ZNAamplitude"}; + ConfigurableAxis axisZNCampl{"axisZNCampl", {100, 0.0f, 250.0f}, "ZNCamplitude"}; + } axisDetectors; + + // for MC + Configurable doMCAssociation{"doMCAssociation", true, "if MC, do MC association"}; + Configurable doTreatPiToMuon{"doTreatPiToMuon", false, "Take pi decay into muon into account in MC"}; + Configurable calculateFeeddownMatrix{"calculateFeeddownMatrix", true, "fill feeddown matrix if MC"}; + ConfigurableAxis axisGeneratorIds{"axisGeneratorIds", {256, -0.5f, 255.5f}, "axis for generatorIds"}; + Configurable checkNeutronsInMC{"checkNeutronsInMC", true, "require no neutrons for single-gap in MC"}; + Configurable neutronEtaCut{"neutronEtaCut", 8.8, "ZN acceptance"}; + + // Occupancy cut + Configurable minOccupancy{"minOccupancy", -1, "minimum occupancy from neighbouring collisions"}; + Configurable maxOccupancy{"maxOccupancy", 1000, "maximum occupancy from neighbouring collisions"}; + + // z vertex cut + Configurable maxZVtxPosition{"maxZVtxPosition", 10.0f, "max Z vtx position"}; + + // Kinematic axes + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for v0 analysis"}; + ConfigurableAxis axisPtXi{"axisPtXi", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for cascade analysis"}; + ConfigurableAxis axisPtCoarse{"axisPtCoarse", {VARIABLE_WIDTH, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 7.0f, 10.0f, 15.0f}, "pt axis for QA"}; + ConfigurableAxis axisEta{"axisEta", {100, -2.0f, 2.0f}, "#eta"}; + ConfigurableAxis axisRap{"axisRap", {100, -2.0f, 2.0f}, "y"}; + + // Invariant mass axes + ConfigurableAxis axisK0Mass{"axisK0Mass", {200, 0.4f, 0.6f}, ""}; + ConfigurableAxis axisLambdaMass{"axisLambdaMass", {200, 1.101f, 1.131f}, ""}; + ConfigurableAxis axisXiMass{"axisXiMass", {200, 1.28f, 1.36f}, ""}; + ConfigurableAxis axisOmegaMass{"axisOmegaMass", {200, 1.59f, 1.75f}, ""}; + std::vector axisInvMass = {axisK0Mass, + axisLambdaMass, + axisLambdaMass, + axisXiMass, + axisXiMass, + axisOmegaMass, + axisOmegaMass}; + + ConfigurableAxis axisNTracksGlobal{"axisNTracksGlobal", {101, -1.5f, 99.5f}, "Number of global tracks"}; + ConfigurableAxis axisNTracksPVeta1{"axisNTracksPVeta1", {100, -0.5f, 99.5f}, "Number of PV contributors in |eta| < 1"}; + ConfigurableAxis axisNTracksPVeta05{"axisNTracksPVeta05", {100, -0.5f, 99.5f}, "Number of PV contributors in |eta| < 0.5"}; + ConfigurableAxis axisNAssocColl{"axisNAssocColl", {10, -0.5f, 9.5f}, "Number of assoc. rec. collisions"}; + ConfigurableAxis axisNTracksTotalExceptITSonly{"axisNTracksTotalExceptITSonly", {100, -0.5f, 99.5f}, "Number of ITS-TPC and TPC only tracks"}; + ConfigurableAxis axisNchInvMass{"axisNchInvMass", {201, -1.5f, 199.5f}, "Number of charged particles for kTHnSparseF"}; + + ConfigurableAxis axisFT0Cqa{"axisFT0Cqa", + {VARIABLE_WIDTH, -1.5, -0.5, 0., 1., 5, 10, 20, 30, 40, 50, 60, 70, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 105.5}, + "FT0C (%)"}; + + ConfigurableAxis axisFT0C{"axisFT0C", + {VARIABLE_WIDTH, 0., 0.01, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 105.5}, + "FT0C (%)"}; + + ConfigurableAxis axisOccupancy{"axisOccupancy", {VARIABLE_WIDTH, 0.0f, 250.0f, 500.0f, 750.0f, 1000.0f, 1500.0f, 2000.0f, 3000.0f, 4500.0f, 6000.0f, 8000.0f, 10000.0f, 50000.0f}, "Occupancy"}; + + // UPC axes + ConfigurableAxis axisSelGap{"axisSelGap", {4, -1.5, 2.5}, "Gap side"}; + + // AP plot axes + ConfigurableAxis axisAPAlpha{"axisAPAlpha", {220, -1.1f, 1.1f}, "V0 AP alpha"}; + ConfigurableAxis axisAPQt{"axisAPQt", {220, 0.0f, 0.5f}, "V0 AP alpha"}; + + // MC coll assoc QA axis + ConfigurableAxis axisMonteCarloNch{"axisMonteCarloNch", {300, 0.0f, 3000.0f}, "N_{ch} MC"}; + + // Track quality axes + ConfigurableAxis axisTPCrows{"axisTPCrows", {160, -0.5f, 159.5f}, "N TPC rows"}; + ConfigurableAxis axisITSclus{"axisITSclus", {7, -0.5f, 6.5f}, "N ITS Clusters"}; + ConfigurableAxis axisITScluMap{"axisITScluMap", {128, -0.5f, 127.5f}, "ITS Cluster map"}; + ConfigurableAxis axisDetMap{"axisDetMap", {16, -0.5f, 15.5f}, "Detector use map"}; + ConfigurableAxis axisITScluMapCoarse{"axisITScluMapCoarse", {16, -3.5f, 12.5f}, "ITS Coarse cluster map"}; + ConfigurableAxis axisDetMapCoarse{"axisDetMapCoarse", {5, -0.5f, 4.5f}, "Detector Coarse user map"}; + + // Topological variable QA axes + ConfigurableAxis axisDCAtoPV{"axisDCAtoPV", {80, -4.0f, 4.0f}, "DCA (cm)"}; + ConfigurableAxis axisDCAdau{"axisDCAdau", {48, 0.0f, 1.2f}, "DCA (cm)"}; + ConfigurableAxis axisPointingAngle{"axisPointingAngle", {100, 0.0f, 0.5f}, "pointing angle (rad)"}; + ConfigurableAxis axisCosPA{"axisCosPA", {300, 0.97f, 1.0f}, "cosPA"}; + ConfigurableAxis axisV0Radius{"axisV0Radius", {100, 0.0f, 10.0f}, "V0 2D radius (cm)"}; + ConfigurableAxis axisNsigmaTPC{"axisNsigmaTPC", {200, -10.0f, 10.0f}, "N sigma TPC"}; + ConfigurableAxis axisTPCsignal{"axisTPCsignal", {200, 0.0f, 200.0f}, "TPC signal"}; + ConfigurableAxis axisTOFdeltaT{"axisTOFdeltaT", {200, -5000.0f, 5000.0f}, "TOF Delta T (ps)"}; + ConfigurableAxis axisCtau{"axisCtau", {200, 0.0f, 20.0f}, "c x tau (cm)"}; + + static constexpr std::string_view kParticlenames[] = {"K0Short", "Lambda", "AntiLambda", "Xi", "AntiXi", "Omega", "AntiOmega"}; + + void setBits(std::bitset& mask, std::initializer_list selections) + { + for (const int& sel : selections) { + mask.set(sel); + } + } + + template + void addTopoHistograms(HistogramRegistry& histos) + { + const bool isCascade = (partID > 2.5) ? true : false; + if (isCascade) { + histos.add(Form("%s/hCascCosPA", kParticlenames[partID].data()), "hCascCosPA", kTH2F, {axisPtCoarse, {100, 0.9f, 1.0f}}); + histos.add(Form("%s/hDCACascDaughters", kParticlenames[partID].data()), "hDCACascDaughters", kTH2F, {axisPtCoarse, {44, 0.0f, 2.2f}}); + histos.add(Form("%s/hCascRadius", kParticlenames[partID].data()), "hCascRadius", kTH2D, {axisPtCoarse, {500, 0.0f, 50.0f}}); + histos.add(Form("%s/hMesonDCAToPV", kParticlenames[partID].data()), "hMesonDCAToPV", kTH2F, {axisPtCoarse, axisDCAtoPV}); + histos.add(Form("%s/hBaryonDCAToPV", kParticlenames[partID].data()), "hBaryonDCAToPV", kTH2F, {axisPtCoarse, axisDCAtoPV}); + histos.add(Form("%s/hBachDCAToPV", kParticlenames[partID].data()), "hBachDCAToPV", kTH2F, {axisPtCoarse, {200, -1.0f, 1.0f}}); + histos.add(Form("%s/hV0CosPA", kParticlenames[partID].data()), "hV0CosPA", kTH2F, {axisPtCoarse, {100, 0.9f, 1.0f}}); + histos.add(Form("%s/hV0Radius", kParticlenames[partID].data()), "hV0Radius", kTH2D, {axisPtCoarse, axisV0Radius}); + histos.add(Form("%s/hDCAV0Daughters", kParticlenames[partID].data()), "hDCAV0Daughters", kTH2F, {axisPtCoarse, axisDCAdau}); + histos.add(Form("%s/hDCAV0ToPV", kParticlenames[partID].data()), "hDCAV0ToPV", kTH2F, {axisPtCoarse, {44, 0.0f, 2.2f}}); + histos.add(Form("%s/hMassLambdaDau", kParticlenames[partID].data()), "hMassLambdaDau", kTH2F, {axisPtCoarse, axisLambdaMass}); + histos.add(Form("%s/hCtau", kParticlenames[partID].data()), "hCtau", kTH2F, {axisPtCoarse, axisCtau}); + if (doBachelorBaryonCut) { + histos.add(Form("%s/hBachBaryonCosPA", kParticlenames[partID].data()), "hBachBaryonCosPA", kTH2F, {axisPtCoarse, {100, 0.0f, 1.0f}}); + histos.add(Form("%s/hBachBaryonDCAxyToPV", kParticlenames[partID].data()), "hBachBaryonDCAxyToPV", kTH2F, {axisPtCoarse, {300, -3.0f, 3.0f}}); + } + } else { + histos.add(Form("%s/hPosDCAToPV", kParticlenames[partID].data()), "hPosDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add(Form("%s/hNegDCAToPV", kParticlenames[partID].data()), "hNegDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add(Form("%s/hDCADaughters", kParticlenames[partID].data()), "hDCADaughters", kTH1F, {axisDCAdau}); + histos.add(Form("%s/hPointingAngle", kParticlenames[partID].data()), "hPointingAngle", kTH1F, {axisPointingAngle}); + histos.add(Form("%s/hCosPA", kParticlenames[partID].data()), "hCosPA", kTH1F, {axisCosPA}); + histos.add(Form("%s/hV0Radius", kParticlenames[partID].data()), "hV0Radius", kTH1F, {axisV0Radius}); + histos.add(Form("%s/h2dPositiveITSvsTPCpts", kParticlenames[partID].data()), "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add(Form("%s/h2dNegativeITSvsTPCpts", kParticlenames[partID].data()), "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add(Form("%s/hCtau", kParticlenames[partID].data()), "hCtau", kTH2F, {axisPtCoarse, axisCtau}); + } + } + + template + void addTPCQAHistograms(HistogramRegistry& histos) + { + const bool isCascade = (partID > 2.5) ? true : false; + histos.add(Form("%s/h3dPosNsigmaTPC", kParticlenames[partID].data()), "h3dPosNsigmaTPC", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisNsigmaTPC}); + histos.add(Form("%s/h3dNegNsigmaTPC", kParticlenames[partID].data()), "h3dNegNsigmaTPC", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisNsigmaTPC}); + histos.add(Form("%s/h3dPosTPCsignal", kParticlenames[partID].data()), "h3dPosTPCsignal", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTPCsignal}); + histos.add(Form("%s/h3dNegTPCsignal", kParticlenames[partID].data()), "h3dNegTPCsignal", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTPCsignal}); + + histos.add(Form("%s/h3dPosNsigmaTPCvsTrackPtot", kParticlenames[partID].data()), "h3dPosNsigmaTPCvsTrackPtot", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisNsigmaTPC}); + histos.add(Form("%s/h3dNegNsigmaTPCvsTrackPtot", kParticlenames[partID].data()), "h3dNegNsigmaTPCvsTrackPtot", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisNsigmaTPC}); + + histos.add(Form("%s/h3dPosTPCsignalVsTrackPtot", kParticlenames[partID].data()), "h3dPosTPCsignalVsTrackPtot", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTPCsignal}); + histos.add(Form("%s/h3dNegTPCsignalVsTrackPtot", kParticlenames[partID].data()), "h3dNegTPCsignalVsTrackPtot", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTPCsignal}); + + histos.add(Form("%s/h3dPosNsigmaTPCvsTrackPt", kParticlenames[partID].data()), "h3dPosNsigmaTPCvsTrackPt", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisNsigmaTPC}); + histos.add(Form("%s/h3dNegNsigmaTPCvsTrackPt", kParticlenames[partID].data()), "h3dNegNsigmaTPCvsTrackPt", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisNsigmaTPC}); + + histos.add(Form("%s/h3dPosTPCsignalVsTrackPt", kParticlenames[partID].data()), "h3dPosTPCsignalVsTrackPt", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTPCsignal}); + histos.add(Form("%s/h3dNegTPCsignalVsTrackPt", kParticlenames[partID].data()), "h3dNegTPCsignalVsTrackPt", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTPCsignal}); + + if (isCascade) { + histos.add(Form("%s/h3dBachTPCsignal", kParticlenames[partID].data()), "h3dBachTPCsignal", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTPCsignal}); + histos.add(Form("%s/h3dBachNsigmaTPC", kParticlenames[partID].data()), "h3dBachNsigmaTPC", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisNsigmaTPC}); + histos.add(Form("%s/h3dBachNsigmaTPCvsTrackPtot", kParticlenames[partID].data()), "h3dBachNsigmaTPCvsTrackPtot", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisNsigmaTPC}); + histos.add(Form("%s/h3dBachTPCsignalVsTrackPtot", kParticlenames[partID].data()), "h3dBachTPCsignalVsTrackPtot", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTPCsignal}); + histos.add(Form("%s/h3dBachNsigmaTPCvsTrackPt", kParticlenames[partID].data()), "h3dBachNsigmaTPCvsTrackPt", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisNsigmaTPC}); + histos.add(Form("%s/h3dBachTPCsignalVsTrackPt", kParticlenames[partID].data()), "h3dBachTPCsignalVsTrackPt", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTPCsignal}); + } + } + + template + void addTOFQAHistograms(HistogramRegistry& histos) + { + const bool isCascade = (partID > 2.5) ? true : false; + histos.add(Form("%s/h3dPosTOFdeltaT", kParticlenames[partID].data()), "h3dPosTOFdeltaT", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTOFdeltaT}); + histos.add(Form("%s/h3dNegTOFdeltaT", kParticlenames[partID].data()), "h3dNegTOFdeltaT", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTOFdeltaT}); + histos.add(Form("%s/h3dPosTOFdeltaTvsTrackPtot", kParticlenames[partID].data()), "h3dPosTOFdeltaTvsTrackPtot", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTOFdeltaT}); + histos.add(Form("%s/h3dNegTOFdeltaTvsTrackPtot", kParticlenames[partID].data()), "h3dNegTOFdeltaTvsTrackPtot", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTOFdeltaT}); + histos.add(Form("%s/h3dPosTOFdeltaTvsTrackPt", kParticlenames[partID].data()), "h3dPosTOFdeltaTvsTrackPt", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTOFdeltaT}); + histos.add(Form("%s/h3dNegTOFdeltaTvsTrackPt", kParticlenames[partID].data()), "h3dNegTOFdeltaTvsTrackPt", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTOFdeltaT}); + if (isCascade) { + histos.add(Form("%s/h3dBachTOFdeltaT", kParticlenames[partID].data()), "h3dBachTOFdeltaT", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTOFdeltaT}); + histos.add(Form("%s/h3dBachTOFdeltaTvsTrackPtot", kParticlenames[partID].data()), "h3dBachTOFdeltaTvsTrackPtot", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTOFdeltaT}); + histos.add(Form("%s/h3dBachTOFdeltaTvsTrackPt", kParticlenames[partID].data()), "h3dBachTOFdeltaTvsTrackPt", kTH3F, {axisDetectors.axisFT0ampl, axisPtCoarse, axisTOFdeltaT}); + } + } + + template + void addKinematicQAHistograms(HistogramRegistry& histos) + { + const bool isCascade = (partID > 2.5) ? true : false; + histos.add(Form("%s/h3dPosEtaPt", kParticlenames[partID].data()), "h3dPosEtaPt", kTH3F, {axisPtCoarse, axisEta, axisSelGap}); + histos.add(Form("%s/h3dNegEtaPt", kParticlenames[partID].data()), "h3dNegEtaPt", kTH3F, {axisPtCoarse, axisEta, axisSelGap}); + histos.add(Form("%s/h3dRapPt", kParticlenames[partID].data()), "h3dRapPt", kTH3F, {axisPtCoarse, axisRap, axisSelGap}); + if (isCascade) { + histos.add(Form("%s/h3dBachEtaPt", kParticlenames[partID].data()), "h3dBachEtaPt", kTH3F, {axisPtCoarse, axisEta, axisSelGap}); + } + } + + template + void addDetectorPropHistograms(HistogramRegistry& histos) + { + const bool isCascade = (partID > 2.5) ? true : false; + if (doDetectPropQA == 1) { + if (isCascade) { + histos.add(Form("%s/h8dDetectPropVsCentrality", kParticlenames[partID].data()), "h8dDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); + } else { + histos.add(Form("%s/h6dDetectPropVsCentrality", kParticlenames[partID].data()), "h6dDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); + } + histos.add(Form("%s/h4dPosDetectPropVsCentrality", kParticlenames[partID].data()), "h4dPosDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMap, axisITScluMap, axisPtCoarse}); + histos.add(Form("%s/h4dNegDetectPropVsCentrality", kParticlenames[partID].data()), "h4dNegDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMap, axisITScluMap, axisPtCoarse}); + histos.add(Form("%s/h4dBachDetectPropVsCentrality", kParticlenames[partID].data()), "h4dBachDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMap, axisITScluMap, axisPtCoarse}); + } + if (doDetectPropQA == 2) { + if (isCascade) { + histos.add(Form("%s/h9dDetectPropVsCentrality", kParticlenames[partID].data()), "h9dDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisInvMass.at(partID)}); + } else { + histos.add(Form("%s/h7dDetectPropVsCentrality", kParticlenames[partID].data()), "h7dDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisInvMass.at(partID)}); + } + histos.add(Form("%s/h5dPosDetectPropVsCentrality", kParticlenames[partID].data()), "h5dPosDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMap, axisITScluMap, axisPtCoarse, axisInvMass.at(partID)}); + histos.add(Form("%s/h5dNegDetectPropVsCentrality", kParticlenames[partID].data()), "h5dNegDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMap, axisITScluMap, axisPtCoarse, axisInvMass.at(partID)}); + histos.add(Form("%s/h5dBachDetectPropVsCentrality", kParticlenames[partID].data()), "h5dBachDetectPropVsCentrality", kTHnSparseF, {axisDetectors.axisFT0ampl, axisDetMap, axisITScluMap, axisPtCoarse, axisInvMass.at(partID)}); + } + } + + template + void addHistograms(HistogramRegistry& histos) + { + histos.add(Form("%s/h7dMass", kParticlenames[partID].data()), "h7dMass", kTHnSparseF, {axisDetectors.axisFT0ampl, axisPt, axisInvMass.at(partID), axisSelGap, axisNchInvMass, axisRap, axisEta}); + histos.add(Form("%s/h2dMass", kParticlenames[partID].data()), "h2dMass", kTH2F, {axisInvMass.at(partID), axisSelGap}); + if (doPlainTopoQA) { + addTopoHistograms(histos); + } + if (PIDConfigurations.doTPCQA) { + addTPCQAHistograms(histos); + } + if (PIDConfigurations.doTOFQA) { + addTOFQAHistograms(histos); + } + if (doKienmaticQA) { + addKinematicQAHistograms(histos); + } + addDetectorPropHistograms(histos); + } + + template + void fillHistogramsV0(TCand cand, TCollision coll, int gap) + { + float invMass = 0; + float ft0ampl = -1.f; + if (gap == 0) { + ft0ampl = coll.totalFT0AmplitudeC(); + } else if (gap == 1) { + ft0ampl = coll.totalFT0AmplitudeA(); + } + float pT = cand.pt(); + float rapidity = 1e6; + + // c x tau + float ctau = 0; + + float tpcNsigmaPos = 0; + float tpcNsigmaNeg = 0; + float tofDeltaTPos = 0; + float tofDeltaTNeg = 0; + + auto posTrackExtra = cand.template posTrackExtra_as(); + auto negTrackExtra = cand.template negTrackExtra_as(); + + bool posIsFromAfterburner = posTrackExtra.itsChi2PerNcl() < 0; + bool negIsFromAfterburner = negTrackExtra.itsChi2PerNcl() < 0; + + uint posDetMap = computeDetBitmap(posTrackExtra.detectorMap()); + int posITSclusMap = computeITSclusBitmap(posTrackExtra.itsClusterMap(), posIsFromAfterburner); + uint negDetMap = computeDetBitmap(negTrackExtra.detectorMap()); + int negITSclusMap = computeITSclusBitmap(negTrackExtra.itsClusterMap(), negIsFromAfterburner); + + if (partID == 0) { + histos.fill(HIST("generalQA/h2dArmenterosSelected"), cand.alpha(), cand.qtarm()); + invMass = cand.mK0Short(); + rapidity = cand.yK0Short(); + ctau = cand.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassK0Short; + if (PIDConfigurations.doTOFQA) { + tofDeltaTPos = cand.posTOFDeltaTK0Pi(); + tofDeltaTNeg = cand.negTOFDeltaTK0Pi(); + } + if (PIDConfigurations.doTPCQA) { + tpcNsigmaPos = posTrackExtra.tpcNSigmaPi(); + tpcNsigmaNeg = negTrackExtra.tpcNSigmaPi(); + } + } else if (partID == 1) { + invMass = cand.mLambda(); + rapidity = cand.yLambda(); + ctau = cand.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0; + if (PIDConfigurations.doTOFQA) { + tofDeltaTPos = cand.posTOFDeltaTLaPr(); + tofDeltaTNeg = cand.negTOFDeltaTLaPi(); + } + if (PIDConfigurations.doTPCQA) { + tpcNsigmaPos = posTrackExtra.tpcNSigmaPr(); + tpcNsigmaNeg = negTrackExtra.tpcNSigmaPi(); + } + } else if (partID == 2) { + invMass = cand.mAntiLambda(); + rapidity = cand.yLambda(); + ctau = cand.distovertotmom(coll.posX(), coll.posY(), coll.posZ()) * o2::constants::physics::MassLambda0Bar; + if (PIDConfigurations.doTOFQA) { + tofDeltaTPos = cand.posTOFDeltaTLaPi(); + tofDeltaTNeg = cand.negTOFDeltaTLaPr(); + } + if (PIDConfigurations.doTPCQA) { + tpcNsigmaPos = posTrackExtra.tpcNSigmaPi(); + tpcNsigmaNeg = negTrackExtra.tpcNSigmaPr(); + } + } else { + LOG(fatal) << "Particle is unknown!"; + } + + histos.fill(HIST(kParticlenames[partID]) + HIST("/h2dMass"), invMass, gap); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h7dMass"), ft0ampl, pT, invMass, gap, coll.multNTracksGlobal(), rapidity, cand.eta()); + if (doKienmaticQA) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosEtaPt"), pT, cand.positiveeta(), gap); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegEtaPt"), pT, cand.negativeeta(), gap); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dRapPt"), pT, rapidity, gap); + } + if (doPlainTopoQA) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/hPosDCAToPV"), cand.dcapostopv()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hNegDCAToPV"), cand.dcanegtopv()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hDCADaughters"), cand.dcaV0daughters()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hPointingAngle"), std::acos(cand.v0cosPA())); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hCosPA"), cand.v0cosPA()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hV0Radius"), cand.v0radius()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hCtau"), pT, ctau); + } + if (doDetectPropQA == 1) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h6dDetectPropVsCentrality"), ft0ampl, posDetMap, posITSclusMap, negDetMap, negITSclusMap, pT); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h4dPosDetectPropVsCentrality"), ft0ampl, posTrackExtra.detectorMap(), posTrackExtra.itsClusterMap(), pT); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h4dNegDetectPropVsCentrality"), ft0ampl, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pT); + } + if (doDetectPropQA == 2) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h7dPosDetectPropVsCentrality"), ft0ampl, posDetMap, posITSclusMap, negDetMap, negITSclusMap, pT, invMass); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h5dPosDetectPropVsCentrality"), ft0ampl, posTrackExtra.detectorMap(), posTrackExtra.itsClusterMap(), pT, invMass); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h5dNegDetectPropVsCentrality"), ft0ampl, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pT, invMass); + } + if (PIDConfigurations.doTPCQA) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTPCsignal"), ft0ampl, pT, posTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTPCsignal"), ft0ampl, pT, negTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTPCsignalVsTrackPtot"), ft0ampl, cand.positivept() * std::cosh(cand.positiveeta()), posTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTPCsignalVsTrackPtot"), ft0ampl, cand.negativept() * std::cosh(cand.negativeeta()), negTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTPCsignalVsTrackPt"), ft0ampl, cand.positivept(), posTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTPCsignalVsTrackPt"), ft0ampl, cand.negativept(), negTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosNsigmaTPCvsTrackPt"), ft0ampl, cand.positivept(), posTrackExtra.tpcNSigmaPi()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegNsigmaTPCvsTrackPt"), ft0ampl, cand.negativept(), negTrackExtra.tpcNSigmaPi()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosNsigmaTPCvsTrackPtot"), ft0ampl, cand.positivept() * std::cosh(cand.positiveeta()), tpcNsigmaPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegNsigmaTPCvsTrackPtot"), ft0ampl, cand.negativept() * std::cosh(cand.negativeeta()), tpcNsigmaNeg); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosNsigmaTPC"), ft0ampl, pT, tpcNsigmaPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegNsigmaTPC"), ft0ampl, pT, tpcNsigmaNeg); + } + if (PIDConfigurations.doTOFQA) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTOFdeltaTvsTrackPt"), ft0ampl, cand.positivept(), tofDeltaTPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTOFdeltaTvsTrackPt"), ft0ampl, cand.negativept(), tofDeltaTNeg); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTOFdeltaT"), ft0ampl, pT, tofDeltaTPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTOFdeltaT"), ft0ampl, pT, tofDeltaTNeg); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTOFdeltaTvsTrackPtot"), ft0ampl, cand.positivept() * std::cosh(cand.positiveeta()), tofDeltaTPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTOFdeltaTvsTrackPtot"), ft0ampl, cand.negativept() * std::cosh(cand.negativeeta()), tofDeltaTNeg); + } + } + + template + void fillHistogramsCasc(TCand cand, TCollision coll, const int gap) + { + float invMass = 0; + float centrality = -1.f; + if (gap == 0) { + centrality = coll.totalFT0AmplitudeC(); + } else if (gap == 1) { + centrality = coll.totalFT0AmplitudeA(); + } + float pT = cand.pt(); + float rapidity = 1e6; + + // Access daughter tracks + auto posTrackExtra = cand.template posTrackExtra_as(); + auto negTrackExtra = cand.template negTrackExtra_as(); + auto bachTrackExtra = cand.template bachTrackExtra_as(); + + bool posIsFromAfterburner = posTrackExtra.itsChi2PerNcl() < 0; + bool negIsFromAfterburner = negTrackExtra.itsChi2PerNcl() < 0; + bool bachIsFromAfterburner = bachTrackExtra.itsChi2PerNcl() < 0; + + uint posDetMap = computeDetBitmap(posTrackExtra.detectorMap()); + int posITSclusMap = computeITSclusBitmap(posTrackExtra.itsClusterMap(), posIsFromAfterburner); + uint negDetMap = computeDetBitmap(negTrackExtra.detectorMap()); + int negITSclusMap = computeITSclusBitmap(negTrackExtra.itsClusterMap(), negIsFromAfterburner); + uint bachDetMap = computeDetBitmap(bachTrackExtra.detectorMap()); + int bachITSclusMap = computeITSclusBitmap(bachTrackExtra.itsClusterMap(), bachIsFromAfterburner); + + // c x tau + float decayPos = std::hypot(cand.x() - coll.posX(), cand.y() - coll.posY(), cand.z() - coll.posZ()); + float totalMom = std::hypot(cand.px(), cand.py(), cand.pz()); + + float ctau = 0; + + float tpcNsigmaPos = 0; + float tpcNsigmaNeg = 0; + float tpcNsigmaBach = 0; + float tofDeltaTPos = 0; + float tofDeltaTNeg = 0; + float tofDeltaTBach = 0; + + if (partID == 3) { + invMass = cand.mXi(); + ctau = totalMom != 0 ? o2::constants::physics::MassXiMinus * decayPos / (totalMom * ctauxiPDG) : 1e6; + rapidity = cand.yXi(); + + if (PIDConfigurations.doTPCQA) { + tpcNsigmaPos = posTrackExtra.tpcNSigmaPr(); + tpcNsigmaNeg = negTrackExtra.tpcNSigmaPi(); + tpcNsigmaBach = bachTrackExtra.tpcNSigmaPi(); + } + if (PIDConfigurations.doTOFQA) { + tofDeltaTPos = cand.posTOFDeltaTXiPr(); + tofDeltaTNeg = cand.negTOFDeltaTXiPi(); + tofDeltaTBach = cand.bachTOFDeltaTXiPi(); + } + } else if (partID == 4) { + invMass = cand.mXi(); + ctau = totalMom != 0 ? o2::constants::physics::MassXiPlusBar * decayPos / (totalMom * ctauxiPDG) : 1e6; + rapidity = cand.yXi(); + + if (PIDConfigurations.doTPCQA) { + tpcNsigmaPos = posTrackExtra.tpcNSigmaPi(); + tpcNsigmaNeg = negTrackExtra.tpcNSigmaPr(); + tpcNsigmaBach = bachTrackExtra.tpcNSigmaPi(); + } + if (PIDConfigurations.doTOFQA) { + tofDeltaTPos = cand.posTOFDeltaTXiPi(); + tofDeltaTNeg = cand.negTOFDeltaTXiPr(); + tofDeltaTBach = cand.bachTOFDeltaTXiPi(); + } + + } else if (partID == 5) { + invMass = cand.mOmega(); + ctau = totalMom != 0 ? o2::constants::physics::MassOmegaMinus * decayPos / (totalMom * ctauomegaPDG) : 1e6; + rapidity = cand.yOmega(); + + if (PIDConfigurations.doTPCQA) { + tpcNsigmaPos = posTrackExtra.tpcNSigmaPr(); + tpcNsigmaNeg = negTrackExtra.tpcNSigmaPi(); + tpcNsigmaBach = bachTrackExtra.tpcNSigmaKa(); + } + if (PIDConfigurations.doTOFQA) { + tofDeltaTPos = cand.posTOFDeltaTOmPi(); + tofDeltaTNeg = cand.posTOFDeltaTOmPr(); + tofDeltaTBach = cand.bachTOFDeltaTOmKa(); + } + + } else if (partID == 6) { + invMass = cand.mOmega(); + ctau = totalMom != 0 ? o2::constants::physics::MassOmegaPlusBar * decayPos / (totalMom * ctauomegaPDG) : 1e6; + rapidity = cand.yOmega(); + + if (PIDConfigurations.doTPCQA) { + tpcNsigmaPos = posTrackExtra.tpcNSigmaPi(); + tpcNsigmaNeg = negTrackExtra.tpcNSigmaPr(); + tpcNsigmaBach = bachTrackExtra.tpcNSigmaKa(); + } + if (PIDConfigurations.doTOFQA) { + tofDeltaTPos = cand.posTOFDeltaTOmPr(); + tofDeltaTNeg = cand.posTOFDeltaTOmPi(); + tofDeltaTBach = cand.bachTOFDeltaTOmKa(); + } + } + histos.fill(HIST(kParticlenames[partID]) + HIST("/h2dMass"), invMass, gap); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h7dMass"), centrality, pT, invMass, gap, coll.multNTracksGlobal(), rapidity, cand.eta()); + if (doKienmaticQA) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosEtaPt"), pT, cand.positiveeta(), gap); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegEtaPt"), pT, cand.negativeeta(), gap); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachEtaPt"), pT, cand.bacheloreta(), gap); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dRapPt"), pT, rapidity, gap); + } + if (doPlainTopoQA) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/hCascCosPA"), pT, cand.casccosPA(coll.posX(), coll.posY(), coll.posZ())); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hDCACascDaughters"), pT, cand.dcacascdaughters()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hCascRadius"), pT, cand.cascradius()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hMesonDCAToPV"), pT, cand.dcanegtopv()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hBaryonDCAToPV"), pT, cand.dcapostopv()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hBachDCAToPV"), pT, cand.dcabachtopv()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hV0CosPA"), pT, cand.v0cosPA(coll.posX(), coll.posY(), coll.posZ())); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hV0Radius"), pT, cand.v0radius()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hDCAV0Daughters"), pT, cand.dcaV0daughters()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hDCAV0ToPV"), pT, std::fabs(cand.dcav0topv(coll.posX(), coll.posY(), coll.posZ()))); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hMassLambdaDau"), pT, cand.mLambda()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/hCtau"), pT, ctau); + } + if (PIDConfigurations.doTPCQA) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosNsigmaTPC"), centrality, pT, tpcNsigmaPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegNsigmaTPC"), centrality, pT, tpcNsigmaNeg); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachNsigmaTPC"), centrality, pT, tpcNsigmaBach); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTPCsignal"), centrality, pT, posTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTPCsignal"), centrality, pT, negTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachTPCsignal"), centrality, pT, bachTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosNsigmaTPCvsTrackPtot"), centrality, cand.positivept() * std::cosh(cand.positiveeta()), tpcNsigmaPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegNsigmaTPCvsTrackPtot"), centrality, cand.negativept() * std::cosh(cand.negativeeta()), tpcNsigmaNeg); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachNsigmaTPCvsTrackPtot"), centrality, cand.bachelorpt() * std::cosh(cand.bacheloreta()), tpcNsigmaBach); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTPCsignalVsTrackPtot"), centrality, cand.positivept() * std::cosh(cand.positiveeta()), posTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTPCsignalVsTrackPtot"), centrality, cand.negativept() * std::cosh(cand.negativeeta()), negTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachTPCsignalVsTrackPtot"), centrality, cand.bachelorpt() * std::cosh(cand.bacheloreta()), bachTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosNsigmaTPCvsTrackPt"), centrality, cand.positivept(), tpcNsigmaPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegNsigmaTPCvsTrackPt"), centrality, cand.negativept(), tpcNsigmaNeg); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachNsigmaTPCvsTrackPt"), centrality, cand.bachelorpt(), tpcNsigmaBach); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTPCsignalVsTrackPt"), centrality, cand.positivept(), posTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTPCsignalVsTrackPt"), centrality, cand.negativept(), negTrackExtra.tpcSignal()); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachTPCsignalVsTrackPt"), centrality, cand.bachelorpt(), bachTrackExtra.tpcSignal()); + } + if (PIDConfigurations.doTOFQA) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTOFdeltaT"), centrality, pT, tofDeltaTPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTOFdeltaT"), centrality, pT, tofDeltaTNeg); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachTOFdeltaT"), centrality, pT, tofDeltaTBach); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTOFdeltaTvsTrackPtot"), centrality, cand.positivept() * std::cosh(cand.positiveeta()), tofDeltaTPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTOFdeltaTvsTrackPtot"), centrality, cand.negativept() * std::cosh(cand.negativeeta()), tofDeltaTNeg); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachTOFdeltaTvsTrackPtot"), centrality, cand.bachelorpt() * std::cosh(cand.bacheloreta()), tofDeltaTBach); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dPosTOFdeltaTvsTrackPt"), centrality, cand.positivept(), tofDeltaTPos); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dNegTOFdeltaTvsTrackPt"), centrality, cand.negativept(), tofDeltaTNeg); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h3dBachTOFdeltaTvsTrackPt"), centrality, cand.bachelorpt(), tofDeltaTBach); + } + if (doDetectPropQA == 1) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h8dDetectPropVsCentrality"), centrality, posDetMap, posITSclusMap, negDetMap, negITSclusMap, bachDetMap, bachITSclusMap, pT); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h4dPosDetectPropVsCentrality"), centrality, posTrackExtra.detectorMap(), posTrackExtra.itsClusterMap(), pT); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h4dNegDetectPropVsCentrality"), centrality, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pT); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h4dBachDetectPropVsCentrality"), centrality, bachTrackExtra.detectorMap(), bachTrackExtra.itsClusterMap(), pT); + } + if (doDetectPropQA == 2) { + histos.fill(HIST(kParticlenames[partID]) + HIST("/h9dDetectPropVsCentrality"), centrality, posDetMap, posITSclusMap, negDetMap, negITSclusMap, bachDetMap, bachITSclusMap, pT, invMass); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h5dPosDetectPropVsCentrality"), centrality, posTrackExtra.detectorMap(), posTrackExtra.itsClusterMap(), pT, invMass); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h5dNegDetectPropVsCentrality"), centrality, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pT, invMass); + histos.fill(HIST(kParticlenames[partID]) + HIST("/h5dBachDetectPropVsCentrality"), centrality, bachTrackExtra.detectorMap(), bachTrackExtra.itsClusterMap(), pT, invMass); + } + } + + void init(InitContext const&) + { + if (doprocessV0s && doprocessCascades) { + LOG(fatal) << "Unable to analyze both v0s and cascades simultaneously. Please enable only one process at a time"; + } + + if ((doprocessV0sMC || doprocessCascadesMC || doprocessGenerated) && (doprocessV0s || doprocessCascades)) { + LOG(fatal) << "Cannot analyze both data and MC simultaneously. Please select one of them."; + } + + rctChecker.init(evSels.cfgEvtRCTFlagCheckerLabel, evSels.cfgEvtRCTFlagCheckerZDCCheck, evSels.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + + // initialise bit masks + setBits(maskTopologicalV0, {selV0CosPA, selDCANegToPV, selDCAPosToPV, selDCAV0Dau, selV0Radius, selV0RadiusMax}); + setBits(maskTopologicalCasc, {selCascCosPA, selDCACascDau, selCascRadius, selCascRadiusMax, selBachToPV, selMesonToPV, selBaryonToPV, + selDCAV0ToPV, selV0CosPA, selDCAV0Dau, selV0Radius, selV0RadiusMax, selLambdaMassWin}); + + if (doBachelorBaryonCut) + maskTopologicalCasc.set(selBachBaryon); + + setBits(maskKinematicV0, {selPosEta, selNegEta}); + setBits(maskKinematicCasc, {selPosEta, selNegEta, selBachEta}); + + if (doDaughterDCA) { + maskKinematicV0.set(selDauDCA); + maskKinematicCasc.set(selDauDCA); + } + + // Specific masks + setBits(maskK0ShortSpecific, {selK0ShortRapidity, selK0ShortCTau, selK0ShortArmenteros, selConsiderK0Short}); + setBits(maskLambdaSpecific, {selLambdaRapidity, selLambdaCTau, selConsiderLambda}); + setBits(maskAntiLambdaSpecific, {selLambdaRapidity, selLambdaCTau, selConsiderAntiLambda}); + setBits(maskXiSpecific, {selXiRapidity, selXiCTau, selRejCompXi, selMassWinXi, selConsiderXi}); + setBits(maskAntiXiSpecific, {selXiRapidity, selXiCTau, selRejCompXi, selMassWinXi, selConsiderAntiXi}); + setBits(maskOmegaSpecific, {selOmegaRapidity, selOmegaCTau, selRejCompOmega, selMassWinOmega, selConsiderOmega}); + setBits(maskAntiOmegaSpecific, {selOmegaRapidity, selOmegaCTau, selRejCompOmega, selMassWinOmega, selConsiderAntiOmega}); + + // ask for specific TPC/TOF PID selections + // positive track + if (TrackConfigurations.requirePosITSonly) { + setBits(maskTrackPropertiesV0, {selPosItsOnly, selPosGoodITSTrack}); + } else { + setBits(maskTrackPropertiesV0, {selPosGoodTPCTrack, selPosGoodITSTrack}); + // TPC signal is available: ask for positive track PID + if (PIDConfigurations.tpcPidNsigmaCut < 1e+5) { // safeguard for no cut + maskK0ShortSpecific.set(selTPCPIDPositivePion); + maskLambdaSpecific.set(selTPCPIDPositiveProton); + maskAntiLambdaSpecific.set(selTPCPIDPositivePion); + + maskXiSpecific.set(selTPCPIDPositiveProton); + maskAntiXiSpecific.set(selTPCPIDPositivePion); + maskOmegaSpecific.set(selTPCPIDPositiveProton); + maskAntiOmegaSpecific.set(selTPCPIDPositivePion); + } + // TOF PID + if (PIDConfigurations.tofPidNsigmaCutK0Pi < 1e+5) { // safeguard for no cut + setBits(maskK0ShortSpecific, {selTOFNSigmaPositivePionK0Short, selTOFDeltaTPositivePionK0Short}); + } + if (PIDConfigurations.tofPidNsigmaCutLaPr < 1e+5) { // safeguard for no cut + setBits(maskLambdaSpecific, {selTOFNSigmaPositiveProtonLambda, selTOFDeltaTPositiveProtonLambda}); + setBits(maskXiSpecific, {selTOFNSigmaPositiveProtonLambdaXi, selTOFDeltaTPositiveProtonLambdaXi}); + setBits(maskOmegaSpecific, {selTOFNSigmaPositiveProtonLambdaOmega, selTOFDeltaTPositiveProtonLambdaOmega}); + } + if (PIDConfigurations.tofPidNsigmaCutLaPi < 1e+5) { // safeguard for no cut + setBits(maskAntiLambdaSpecific, {selTOFNSigmaPositivePionLambda, selTOFDeltaTPositivePionLambda}); + setBits(maskAntiXiSpecific, {selTOFNSigmaPositivePionLambdaXi, selTOFDeltaTPositivePionLambdaXi}); + setBits(maskAntiOmegaSpecific, {selTOFNSigmaPositivePionLambdaOmega, selTOFDeltaTPositivePionLambdaOmega}); + } + } + // negative track + if (TrackConfigurations.requireNegITSonly) { + setBits(maskTrackPropertiesV0, {selNegItsOnly, selNegGoodITSTrack}); + } else { + setBits(maskTrackPropertiesV0, {selNegGoodTPCTrack, selNegGoodITSTrack}); + // TPC signal is available: ask for negative track PID + if (PIDConfigurations.tpcPidNsigmaCut < 1e+5) { // safeguard for no cut + maskK0ShortSpecific.set(selTPCPIDNegativePion); + maskLambdaSpecific.set(selTPCPIDNegativePion); + maskAntiLambdaSpecific.set(selTPCPIDNegativeProton); + + maskXiSpecific.set(selTPCPIDNegativePion); + maskAntiXiSpecific.set(selTPCPIDPositiveProton); + maskOmegaSpecific.set(selTPCPIDNegativePion); + maskAntiOmegaSpecific.set(selTPCPIDPositiveProton); + } + // TOF PID + if (PIDConfigurations.tofPidNsigmaCutK0Pi < 1e+5) { // safeguard for no cut + setBits(maskK0ShortSpecific, {selTOFNSigmaNegativePionK0Short, selTOFDeltaTNegativePionK0Short}); + } + if (PIDConfigurations.tofPidNsigmaCutLaPr < 1e+5) { // safeguard for no cut + setBits(maskAntiLambdaSpecific, {selTOFNSigmaNegativeProtonLambda, selTOFDeltaTNegativeProtonLambda}); + setBits(maskAntiXiSpecific, {selTOFNSigmaNegativeProtonLambdaXi, selTOFDeltaTNegativeProtonLambdaXi}); + setBits(maskAntiOmegaSpecific, {selTOFNSigmaNegativeProtonLambdaOmega, selTOFDeltaTNegativeProtonLambdaOmega}); + } + if (PIDConfigurations.tofPidNsigmaCutLaPi < 1e+5) { // safeguard for no cut + setBits(maskLambdaSpecific, {selTOFNSigmaNegativePionLambda, selTOFDeltaTNegativePionLambda}); + setBits(maskXiSpecific, {selTOFNSigmaNegativePionLambdaXi, selTOFDeltaTNegativePionLambdaXi}); + setBits(maskOmegaSpecific, {selTOFNSigmaNegativePionLambdaOmega, selTOFDeltaTNegativePionLambdaOmega}); + } + } + // bachelor track + maskTrackPropertiesCasc = maskTrackPropertiesV0; + if (TrackConfigurations.requireBachITSonly) { + setBits(maskTrackPropertiesCasc, {selBachItsOnly, selBachGoodITSTrack}); + } else { + setBits(maskTrackPropertiesCasc, {selBachGoodTPCTrack, selBachGoodITSTrack}); + // TPC signal is available: ask for positive track PID + if (PIDConfigurations.tpcPidNsigmaCut < 1e+5) { // safeguard for no cut + maskXiSpecific.set(selTPCPIDBachPion); + maskAntiXiSpecific.set(selTPCPIDBachPion); + maskOmegaSpecific.set(selTPCPIDBachKaon); + maskAntiOmegaSpecific.set(selTPCPIDBachKaon); + } + // TOF PID + if (PIDConfigurations.tofPidNsigmaCutXiPi < 1e+5) { // safeguard for no cut + setBits(maskXiSpecific, {selTOFNSigmaBachPionXi, selTOFDeltaTBachPionXi}); + setBits(maskAntiXiSpecific, {selTOFNSigmaBachPionXi, selTOFDeltaTBachPionXi}); + } + if (PIDConfigurations.tofPidNsigmaCutOmegaKaon < 1e+5) { // safeguard for no cut + setBits(maskOmegaSpecific, {selTOFNSigmaBachKaonOmega, selTOFDeltaTBachKaonOmega}); + setBits(maskAntiOmegaSpecific, {selTOFNSigmaBachKaonOmega, selTOFDeltaTBachKaonOmega}); + } + } + + if (TrackConfigurations.skipTPConly) { + setBits(maskK0ShortSpecific, {selPosNotTPCOnly, selNegNotTPCOnly}); + setBits(maskLambdaSpecific, {selPosNotTPCOnly, selNegNotTPCOnly}); + setBits(maskAntiLambdaSpecific, {selPosNotTPCOnly, selNegNotTPCOnly}); + setBits(maskXiSpecific, {selPosNotTPCOnly, selNegNotTPCOnly, selBachNotTPCOnly}); + setBits(maskOmegaSpecific, {selPosNotTPCOnly, selNegNotTPCOnly, selBachNotTPCOnly}); + setBits(maskAntiXiSpecific, {selPosNotTPCOnly, selNegNotTPCOnly, selBachNotTPCOnly}); + setBits(maskAntiOmegaSpecific, {selPosNotTPCOnly, selNegNotTPCOnly, selBachNotTPCOnly}); + } + + // Primary particle selection, central to analysis + maskSelectionK0Short = maskTopologicalV0 | maskKinematicV0 | maskTrackPropertiesV0 | maskK0ShortSpecific | (std::bitset(1) << selPhysPrimK0Short); + maskSelectionLambda = maskTopologicalV0 | maskKinematicV0 | maskTrackPropertiesV0 | maskLambdaSpecific | (std::bitset(1) << selPhysPrimLambda); + maskSelectionAntiLambda = maskTopologicalV0 | maskKinematicV0 | maskTrackPropertiesV0 | maskAntiLambdaSpecific | (std::bitset(1) << selPhysPrimAntiLambda); + maskSelectionXi = maskTopologicalCasc | maskKinematicCasc | maskTrackPropertiesCasc | maskXiSpecific | (std::bitset(1) << selPhysPrimXi); + maskSelectionAntiXi = maskTopologicalCasc | maskKinematicCasc | maskTrackPropertiesCasc | maskAntiXiSpecific | (std::bitset(1) << selPhysPrimAntiXi); + maskSelectionOmega = maskTopologicalCasc | maskKinematicCasc | maskTrackPropertiesCasc | maskOmegaSpecific | (std::bitset(1) << selPhysPrimOmega); + maskSelectionAntiOmega = maskTopologicalCasc | maskKinematicCasc | maskTrackPropertiesCasc | maskAntiOmegaSpecific | (std::bitset(1) << selPhysPrimAntiOmega); + + // No primary requirement for feeddown matrix + secondaryMaskSelectionLambda = maskTopologicalV0 | maskKinematicV0 | maskTrackPropertiesV0 | maskLambdaSpecific; + secondaryMaskSelectionAntiLambda = maskTopologicalV0 | maskKinematicV0 | maskTrackPropertiesV0 | maskAntiLambdaSpecific; + + // Event Counter + histos.add("eventQA/hEventSelection", "hEventSelection", kTH1D, {{17, -0.5f, 16.5f}}); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(2, "kIsTriggerTVX"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(3, "posZ cut"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(5, "kNoTimeFrameBorder"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(6, "kIsVertexITSTPC"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(7, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(8, "kIsVertexTOFmatched"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(9, "kIsVertexTRDmatched"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(10, "kNoSameBunchPileup"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(11, "kNoCollInTimeRangeStd"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(12, "kNoCollInTimeRangeNarrow"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(13, "Below min occup."); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(14, "Above max occup."); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(15, "RCTFlagsChecker"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(16, "isUPC"); + histos.get(HIST("eventQA/hEventSelection"))->GetXaxis()->SetBinLabel(17, "has UPC flag"); + + // Event QA + histos.add("eventQA/hCentralityVsFT0ampl", "hCentralityVsFT0ampl", kTH3D, {axisFT0Cqa, axisDetectors.axisFT0Aampl, axisSelGap}); + histos.add("eventQA/hCentrality", "hCentrality", kTH2D, {axisFT0Cqa, axisSelGap}); + histos.add("eventQA/hFT0ampl", "hFT0ampl", kTH2D, {axisDetectors.axisFT0Aampl, axisSelGap}); + histos.add("eventQA/hCentralityVsTracksPVeta1", "hCentralityVsTracksPVeta1", kTH3D, {axisFT0Cqa, axisNTracksPVeta1, axisSelGap}); + histos.add("eventQA/hCentralityVsTracksTotalExceptITSonly", "hCentralityVsTracksTotalExceptITSonly", kTH3D, {axisFT0Cqa, axisNTracksTotalExceptITSonly, axisSelGap}); + histos.add("eventQA/hOccupancy", "hOccupancy", kTH2D, {axisOccupancy, axisSelGap}); + histos.add("eventQA/hCentralityVsOccupancy", "hCentralityVsOccupancy", kTH3D, {axisFT0Cqa, axisOccupancy, axisSelGap}); + histos.add("eventQA/hTracksPVeta1VsTracksGlobal", "hTracksPVeta1VsTracksGlobal", kTH3D, {axisNTracksPVeta1, axisNTracksGlobal, axisSelGap}); + histos.add("eventQA/hCentralityVsTracksGlobal", "hCentralityVsTracksGlobal", kTH3D, {axisFT0Cqa, axisNTracksGlobal, axisSelGap}); + histos.add("eventQA/hFT0amplVsTracksGlobal", "hFT0amplVsTracksGlobal", kTH3D, {axisDetectors.axisFT0Aampl, axisNTracksGlobal, axisSelGap}); + histos.add("eventQA/hRawGapSide", "Raw Gap side; Entries", kTH1D, {{6, -1.5, 4.5}}); + histos.add("eventQA/hSelGapSide", "Selected gap side (with n); Entries", kTH1D, {axisSelGap}); + histos.add("eventQA/hPosX", "Vertex position in x", kTH2D, {{100, -0.1, 0.1}, axisSelGap}); + histos.add("eventQA/hPosY", "Vertex position in y", kTH2D, {{100, -0.1, 0.1}, axisSelGap}); + histos.add("eventQA/hPosZ", "Vertex position in z", kTH2D, {{100, -20., 20.}, axisSelGap}); + histos.add("eventQA/hFT0", "hFT0", kTH3D, {axisDetectors.axisFT0Aampl, axisDetectors.axisFT0Campl, axisSelGap}); + histos.add("eventQA/hFDD", "hFDD", kTH3D, {axisDetectors.axisFDDAampl, axisDetectors.axisFDDCampl, axisSelGap}); + histos.add("eventQA/hZN", "hZN", kTH3D, {axisDetectors.axisZNAampl, axisDetectors.axisZNCampl, axisSelGap}); + + if (doprocessGenerated) { + histos.add("eventQA/mc/hEventSelectionMC", "hEventSelectionMC", kTH3D, {{3, -0.5, 2.5}, axisNTracksPVeta1, axisGeneratorIds}); + histos.get(HIST("eventQA/mc/hEventSelectionMC"))->GetXaxis()->SetBinLabel(1, "All collisions"); + histos.get(HIST("eventQA/mc/hEventSelectionMC"))->GetXaxis()->SetBinLabel(2, "posZ cut"); + histos.get(HIST("eventQA/mc/hEventSelectionMC"))->GetXaxis()->SetBinLabel(3, "rec. at least once"); + histos.add("eventQA/mc/hTracksGlobalvsMCNParticlesEta08gen", "hTracksGlobalvsMCNParticlesEta08gen", kTH2D, {axisNTracksGlobal, axisNTracksGlobal}); + histos.add("eventQA/mc/hTracksGlobalVsNcoll_beforeEvSel", "hTracksGlobalVsNcoll_beforeEvSel", kTH2D, {axisNTracksGlobal, axisNAssocColl}); + histos.add("eventQA/mc/hTracksGlobalVsNcoll_afterEvSel", "hTracksGlobalVsNcoll_afterEvSel", kTH2D, {axisNTracksGlobal, axisNAssocColl}); + histos.add("eventQA/mc/hTracksGlobalVsPVzMC", "hTracksGlobalVsPVzMC", kTH2D, {axisNTracksGlobal, {100, -20., 20.}}); + histos.add("eventQA/mc/hEventPVzMC", "hEventPVzMC", kTH1D, {{100, -20., 20.}}); + histos.add("eventQA/mc/hGenEventFT0ampl", "hGenEventFT0ampl", kTH1D, {axisDetectors.axisFT0Aampl}); + histos.add("eventQA/mc/hGenEventCentrality", "hGenEventCentrality", kTH1D, {axisFT0Cqa}); + histos.add("eventQA/mc/hGeneratorsId", "hGeneratorsId", kTH1D, {axisGeneratorIds}); + } + + if (doprocessV0sMC || doprocessCascadesMC) { + // Event QA + histos.add("eventQA/mc/hFakeEvents", "hFakeEvents", {kTH1D, {{1, -0.5f, 0.5f}}}); + histos.add("eventQA/mc/hNTracksGlobalvsMCNParticlesEta08rec", "hNTracksGlobalvsMCNParticlesEta08rec", kTH2D, {axisNTracksGlobal, axisNTracksGlobal}); + histos.add("eventQA/mc/hNTracksPVeta1vsMCNParticlesEta10rec", "hNTracksPVeta1vsMCNParticlesEta10rec", kTH2D, {axisNTracksPVeta1, axisNTracksPVeta1}); + histos.add("eventQA/mc/hNTracksGlobalvstotalMultMCParticles", "hNTracksGlobalvstotalMultMCParticles", kTH2D, {axisNTracksGlobal, axisNchInvMass}); + histos.add("eventQA/mc/hNTracksPVeta1vstotalMultMCParticles", "hNTracksPVeta1vstotalMultMCParticles", kTH2D, {axisNTracksPVeta1, axisNchInvMass}); + histos.add("eventQA/hSelGapSideNoNeutrons", "Selected gap side (no n); Entries", kTH1D, {{5, -0.5, 4.5}}); + } + + if (doprocessV0sMC) { + if (analyseLambda && calculateFeeddownMatrix) + histos.add(Form("%s/h3dLambdaFeeddown", kParticlenames[1].data()), "h3dLambdaFeeddown", kTH3F, {axisNTracksGlobal, axisPt, axisPt}); + if (analyseAntiLambda && calculateFeeddownMatrix) + histos.add(Form("%s/h3dAntiLambdaFeeddown", kParticlenames[2].data()), "h3dAntiLambdaFeeddown", kTH3F, {axisNTracksGlobal, axisPt, axisPt}); + } + + if (doprocessGenerated) { + for (int partID = 0; partID <= 6; partID++) { + histos.add(Form("%s/mc/h7dGen", kParticlenames[partID].data()), "h7dGen", kTHnSparseF, {axisDetectors.axisFT0ampl, axisNchInvMass, axisNchInvMass, axisPt, axisSelGap, axisRap, axisGeneratorIds}); + } + } + + if (doprocessV0s || doprocessV0sMC) { + // For all candidates + if (doPlainTopoQA) { + histos.add("generalQA/hPt", "hPt", kTH1F, {axisPtCoarse}); + histos.add("generalQA/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("generalQA/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("generalQA/hDCADaughters", "hDCADaughters", kTH1F, {axisDCAdau}); + histos.add("generalQA/hPointingAngle", "hPointingAngle", kTH1F, {axisPointingAngle}); + histos.add("generalQA/hCosPA", "hCosPA", kTH1F, {axisCosPA}); + histos.add("generalQA/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); + histos.add("generalQA/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("generalQA/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("generalQA/h2dArmenterosAll", "h2dArmenterosAll", kTH2F, {axisAPAlpha, axisAPQt}); + histos.add("generalQA/h2dArmenterosSelected", "h2dArmenterosSelected", kTH2F, {axisAPAlpha, axisAPQt}); + } + + // K0s + if (analyseK0Short) { + addHistograms<0>(histos); + } + + // Lambda + if (analyseLambda) { + addHistograms<1>(histos); + } + + // Anti-Lambda + if (analyseAntiLambda) { + addHistograms<2>(histos); + } + } + + if (doprocessCascades || doprocessCascadesMC) { + // For all candidates + if (doPlainTopoQA) { + histos.add("generalQA/hPt", "hPt", kTH1F, {axisPtCoarse}); + histos.add("generalQA/hCascCosPA", "hCascCosPA", kTH2F, {axisPtCoarse, {100, 0.9f, 1.0f}}); + histos.add("generalQA/hDCACascDaughters", "hDCACascDaughters", kTH2F, {axisPtCoarse, {44, 0.0f, 2.2f}}); + histos.add("generalQA/hCascRadius", "hCascRadius", kTH2D, {axisPtCoarse, {500, 0.0f, 50.0f}}); + histos.add("generalQA/hMesonDCAToPV", "hMesonDCAToPV", kTH2F, {axisPtCoarse, axisDCAtoPV}); + histos.add("generalQA/hBaryonDCAToPV", "hBaryonDCAToPV", kTH2F, {axisPtCoarse, axisDCAtoPV}); + histos.add("generalQA/hBachDCAToPV", "hBachDCAToPV", kTH2F, {axisPtCoarse, {200, -1.0f, 1.0f}}); + histos.add("generalQA/hV0CosPA", "hV0CosPA", kTH2F, {axisPtCoarse, {100, 0.9f, 1.0f}}); + histos.add("generalQA/hV0Radius", "hV0Radius", kTH2D, {axisPtCoarse, axisV0Radius}); + histos.add("generalQA/hDCAV0Daughters", "hDCAV0Daughters", kTH2F, {axisPtCoarse, axisDCAdau}); + histos.add("generalQA/hDCAV0ToPV", "hDCAV0ToPV", kTH2F, {axisPtCoarse, {44, 0.0f, 2.2f}}); + histos.add("generalQA/hMassLambdaDau", "hMassLambdaDau", kTH2F, {axisPtCoarse, axisLambdaMass}); + histos.add("generalQA/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("generalQA/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("generalQA/h2dBachITSvsTPCpts", "h2dBachITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + } + + // Xi + if (analyseXi) { + addHistograms<3>(histos); + } + + // Anti-Xi + if (analyseAntiXi) { + addHistograms<4>(histos); + } + + // Omega + if (analyseOmega) { + addHistograms<5>(histos); + } + + // Anti-Omega + if (analyseAntiOmega) { + addHistograms<6>(histos); + } + } + + if (verbose) { + histos.print(); + } + } + + template + int getGapSide(TCollision const& collision) + { + int selGapSide = sgSelector.trueGap(collision, upcCuts.fv0a, upcCuts.ft0a, upcCuts.ft0c, upcCuts.zdc); + return selGapSide; + } + + template + void fillHistogramsQA(TCollision const& collision, int const& gap) + { + // QA histograms + float centrality = collision.centFT0C(); + float ft0ampl = -1.f; + + if (gap == 0) { + ft0ampl = collision.totalFT0AmplitudeC(); + } else if (gap == 1) { + ft0ampl = collision.totalFT0AmplitudeA(); + } + + histos.fill(HIST("eventQA/hCentralityVsFT0ampl"), centrality, ft0ampl, gap); + histos.fill(HIST("eventQA/hCentrality"), centrality, gap); + histos.fill(HIST("eventQA/hFT0ampl"), ft0ampl, gap); + histos.fill(HIST("eventQA/hCentralityVsTracksTotalExceptITSonly"), centrality, collision.multAllTracksTPCOnly() + collision.multAllTracksITSTPC(), gap); + histos.fill(HIST("eventQA/hCentralityVsTracksPVeta1"), centrality, collision.multNTracksPVeta1(), gap); + histos.fill(HIST("eventQA/hOccupancy"), collision.trackOccupancyInTimeRange(), gap); + histos.fill(HIST("eventQA/hCentralityVsOccupancy"), centrality, collision.trackOccupancyInTimeRange(), gap); + histos.fill(HIST("eventQA/hTracksPVeta1VsTracksGlobal"), collision.multNTracksPVeta1(), collision.multNTracksGlobal(), gap); + histos.fill(HIST("eventQA/hCentralityVsTracksGlobal"), centrality, collision.multNTracksGlobal(), gap); + histos.fill(HIST("eventQA/hFT0amplVsTracksGlobal"), ft0ampl, collision.multNTracksGlobal(), gap); + histos.fill(HIST("eventQA/hPosX"), collision.posX(), gap); + histos.fill(HIST("eventQA/hPosY"), collision.posY(), gap); + histos.fill(HIST("eventQA/hPosZ"), collision.posZ(), gap); + + histos.fill(HIST("eventQA/hSelGapSide"), gap); + histos.fill(HIST("eventQA/hFT0"), collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), gap); + histos.fill(HIST("eventQA/hFDD"), collision.totalFDDAmplitudeA(), collision.totalFDDAmplitudeC(), gap); + histos.fill(HIST("eventQA/hZN"), collision.energyCommonZNA(), collision.energyCommonZNC(), gap); + } + + template + bool acceptEvent(TCollision const& collision, bool fillQA) + { + struct SelectionCheck { + bool selection; + bool condition; + float qaBin; + }; + + const std::array selections = {{ + {true, true, 0.0}, // All collisions + {evSels.requireIsTriggerTVX, collision.selection_bit(aod::evsel::kIsTriggerTVX), 1.0}, // Triggered by FT0M + {true, std::fabs(collision.posZ()) < maxZVtxPosition, 2.0}, // Vertex-Z selected + {evSels.rejectITSROFBorder, collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder), 3.0}, // Not at ITS ROF border + {evSels.rejectTFBorder, collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder), 4.0}, // Not at TF border + {evSels.requireIsVertexITSTPC, collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC), 5.0}, // At least one ITS-TPC track + {evSels.requireIsGoodZvtxFT0VsPV, collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV), 6.0}, // PV position consistency + {evSels.requireIsVertexTOFmatched, collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched), 7.0}, // PV with TOF match + {evSels.requireIsVertexTRDmatched, collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched), 8.0}, // PV with TRD match + {evSels.rejectSameBunchPileup, collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup), 9.0}, // No same-bunch pileup + {evSels.requireNoCollInTimeRangeStd, collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard), 10.0}, // No collision within +-10 µs + {evSels.requireNoCollInTimeRangeNarrow, collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow), 11.0}, // No collision within +-4 µs + {minOccupancy >= 0, collision.trackOccupancyInTimeRange() >= minOccupancy, 12.0}, // Above min occupancy + {maxOccupancy > 0, collision.trackOccupancyInTimeRange() < maxOccupancy, 13.0}, // Below max occupancy + {evSels.requireRCTFlagChecker, rctChecker(collision), 14.0}, // Verify collision in RCT + }}; + + for (const auto& sel : selections) { + if (sel.selection && !sel.condition) { + return false; + } + if (fillQA && sel.selection) { + histos.fill(HIST("eventQA/hEventSelection"), sel.qaBin); + } + } + + if (evSels.studyUPConly && !collision.isUPC()) { + return false; + } else if (collision.isUPC() && fillQA) { + histos.fill(HIST("eventQA/hEventSelection"), 15.0); // is UPC compatible + } + + // Additional check for UPC collision flag + if (evSels.useUPCflag && collision.flags() < 1) { + return false; + } + if (collision.flags() >= 1 && fillQA) { + histos.fill(HIST("eventQA/hEventSelection"), 16.0); // UPC event + } + + return true; + } + + bool verifyMask(std::bitset bitmap, std::bitset mask) + { + return (bitmap & mask) == mask; + } + + int computeITSclusBitmap(uint8_t itsClusMap, bool fromAfterburner) + { + int bitMap = 0; + + struct MaskBitmapPair { + uint8_t mask; + int bitmap; + int afterburnerBitmap; + }; + + constexpr MaskBitmapPair kConfigs[] = { + // L6 <-- L0 + {0x7F, 12, 12}, // 01111 111 (L0 to L6) + {0x7E, 11, 11}, // 01111 110 (L1 to L6) + {0x7C, 10, 10}, // 01111 100 (L2 to L6) + {0x78, 9, -3}, // 01111 000 (L3 to L6) + {0x70, 8, -2}, // 01110 000 (L4 to L6) + {0x60, 7, -1}, // 01100 000 (L5 to L6) + {0x3F, 6, 6}, // 00111 111 (L0 to L5) + {0x3E, 5, 5}, // 00111 110 (L1 to L5) + {0x3C, 4, 4}, // 00111 100 (L2 to L5) + {0x1F, 3, 3}, // 00011 111 (L0 to L4) + {0x1E, 2, 2}, // 00011 110 (L1 to L4) + {0x0F, 1, 1}, // 00001 111 (L0 to L3) + }; + + for (const auto& config : kConfigs) { + if (verifyMask(itsClusMap, config.mask)) { + bitMap = fromAfterburner ? config.afterburnerBitmap : config.bitmap; + break; + } + } + + return bitMap; + } + + uint computeDetBitmap(uint8_t detMap) + { + uint bitMap = 0; + + struct MaskBitmapPair { + uint8_t mask; + int bitmap; + }; + + constexpr MaskBitmapPair kConfigs[] = { + {o2::aod::track::ITS | o2::aod::track::TPC | o2::aod::track::TRD | o2::aod::track::TOF, 4}, // ITS-TPC-TRD-TOF + {o2::aod::track::ITS | o2::aod::track::TPC | o2::aod::track::TOF, 3}, // ITS-TPC-TOF + {o2::aod::track::ITS | o2::aod::track::TPC | o2::aod::track::TRD, 2}, // ITS-TPC-TRD + {o2::aod::track::ITS | o2::aod::track::TPC, 1} // ITS-TPC + }; + + for (const auto& config : kConfigs) { + if (verifyMask(detMap, config.mask)) { + bitMap = config.bitmap; + break; + } + } + + return bitMap; + } + + template + std::bitset computeBitmapCascade(TCasc const& casc, TCollision const& coll) + { + float rapidityXi = casc.yXi(); + float rapidityOmega = casc.yOmega(); + + // Access daughter tracks + auto posTrackExtra = casc.template posTrackExtra_as(); + auto negTrackExtra = casc.template negTrackExtra_as(); + auto bachTrackExtra = casc.template bachTrackExtra_as(); + + // c x tau + float decayPos = std::hypot(casc.x() - coll.posX(), casc.y() - coll.posY(), casc.z() - coll.posZ()); + float totalMom = std::hypot(casc.px(), casc.py(), casc.pz()); + float ctauXi = totalMom != 0 ? o2::constants::physics::MassXiMinus * decayPos / totalMom : 1e6; + float ctauOmega = totalMom != 0 ? o2::constants::physics::MassOmegaMinus * decayPos / totalMom : 1e6; + + std::bitset bitMap = 0; + + if (casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()) > casccuts.casccospa) + bitMap.set(selCascCosPA); + if (casc.dcacascdaughters() < casccuts.dcacascdau) + bitMap.set(selDCACascDau); + if (casc.cascradius() > casccuts.cascradius) + bitMap.set(selCascRadius); + if (casc.cascradius() < casccuts.cascradiusMax) + bitMap.set(selCascRadiusMax); + if (doBachelorBaryonCut && (casc.bachBaryonCosPA() < casccuts.bachbaryoncospa) && (std::fabs(casc.bachBaryonDCAxyToPV()) > casccuts.bachbaryondcaxytopv)) + bitMap.set(selBachBaryon); + if (std::fabs(casc.dcabachtopv()) > casccuts.dcabachtopv) + bitMap.set(selBachToPV); + + if (casc.sign() > 0) { + if (std::fabs(casc.dcanegtopv()) > casccuts.dcabaryontopv) + bitMap.set(selBaryonToPV); + if (std::fabs(casc.dcapostopv()) > casccuts.dcamesontopv) + bitMap.set(selMesonToPV); + } else { // no sign == 0, in principle + if (std::fabs(casc.dcapostopv()) > casccuts.dcabaryontopv) + bitMap.set(selBaryonToPV); + if (std::fabs(casc.dcanegtopv()) > casccuts.dcamesontopv) + bitMap.set(selMesonToPV); + } + + if (std::fabs(casc.mXi() - o2::constants::physics::MassXiMinus) < casccuts.masswin) + bitMap.set(selMassWinXi); + if (std::fabs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) < casccuts.masswin) + bitMap.set(selMassWinOmega); + if (std::fabs(casc.mLambda() - o2::constants::physics::MassLambda0) < casccuts.lambdamasswin) + bitMap.set(selLambdaMassWin); + + if (std::fabs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())) > casccuts.dcav0topv) + bitMap.set(selDCAV0ToPV); + if (casc.v0radius() > v0cuts.v0radius) + bitMap.set(selV0Radius); + if (casc.v0radius() < v0cuts.v0radiusMax) + bitMap.set(selV0RadiusMax); + if (casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ()) > v0cuts.v0cospa) + bitMap.set(selV0CosPA); + if (casc.dcaV0daughters() < v0cuts.dcav0dau) + bitMap.set(selDCAV0Dau); + + // proper lifetime + if (ctauXi < nCtauCutCasc->get("lifetimecutXi") * ctauxiPDG) + bitMap.set(selXiCTau); + if (ctauOmega < nCtauCutCasc->get("lifetimecutOmega") * ctauomegaPDG) + bitMap.set(selOmegaCTau); + + auto poseta = RecoDecay::eta(std::array{casc.pxpos(), casc.pypos(), casc.pzpos()}); + auto negeta = RecoDecay::eta(std::array{casc.pxneg(), casc.pyneg(), casc.pzneg()}); + auto bacheta = RecoDecay::eta(std::array{casc.pxbach(), casc.pybach(), casc.pzbach()}); + + // kinematic + if (std::fabs(rapidityXi) < rapidityCut) + bitMap.set(selXiRapidity); + if (std::fabs(rapidityOmega) < rapidityCut) + bitMap.set(selOmegaRapidity); + if (std::fabs(poseta) < daughterEtaCut) + bitMap.set(selNegEta); + if (std::fabs(negeta) < daughterEtaCut) + bitMap.set(selPosEta); + if (std::fabs(bacheta) < daughterEtaCut) + bitMap.set(selBachEta); + + // DCA cuts + auto pospt = std::sqrt(std::pow(casc.pxpos(), 2) + std::pow(casc.pypos(), 2)); + auto negpt = std::sqrt(std::pow(casc.pxneg(), 2) + std::pow(casc.pyneg(), 2)); + auto bachpt = std::sqrt(std::pow(casc.pxbach(), 2) + std::pow(casc.pybach(), 2)); + + double posDcaXYLimit = 0.0105f + 0.035f / std::pow(pospt, 1.1f); + double negDcaXYLimit = 0.0105f + 0.035f / std::pow(negpt, 1.1f); + double bachDcaXYLimit = 0.0105f + 0.035f / std::pow(bachpt, 1.1f); + + // TODO: separate xy and z // + if ((std::abs(casc.dcapostopv()) > posDcaXYLimit) && + (std::abs(casc.dcanegtopv()) > negDcaXYLimit) && + (std::abs(casc.dcabachtopv()) > bachDcaXYLimit)) { + bitMap.set(selDauDCA); + } + + // ITS quality flags + if (posTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) + bitMap.set(selPosGoodITSTrack); + if (negTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) + bitMap.set(selNegGoodITSTrack); + if (bachTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) + bitMap.set(selBachGoodITSTrack); + + // TPC quality flags + if (posTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) + bitMap.set(selPosGoodTPCTrack); + if (negTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) + bitMap.set(selNegGoodTPCTrack); + if (bachTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) + bitMap.set(selBachGoodTPCTrack); + + // TPC PID + // positive track + if (std::fabs(posTrackExtra.tpcNSigmaPi()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDPositivePion); + if (std::fabs(posTrackExtra.tpcNSigmaPr()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDPositiveProton); + // negative track + if (std::fabs(negTrackExtra.tpcNSigmaPi()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDNegativePion); + if (std::fabs(negTrackExtra.tpcNSigmaPr()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDNegativeProton); + // bachelor track + if (std::fabs(bachTrackExtra.tpcNSigmaPi()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDBachPion); + if (std::fabs(bachTrackExtra.tpcNSigmaKa()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDBachKaon); + + // TOF PID in DeltaT + // positive track + if (std::fabs(casc.posTOFDeltaTXiPr()) < PIDConfigurations.maxDeltaTimeProton) + bitMap.set(selTOFDeltaTPositiveProtonLambdaXi); + if (std::fabs(casc.posTOFDeltaTXiPi()) < PIDConfigurations.maxDeltaTimePion) + bitMap.set(selTOFDeltaTPositivePionLambdaXi); + if (std::fabs(casc.posTOFDeltaTOmPr()) < PIDConfigurations.maxDeltaTimeProton) + bitMap.set(selTOFDeltaTPositiveProtonLambdaOmega); + if (std::fabs(casc.posTOFDeltaTOmPi()) < PIDConfigurations.maxDeltaTimePion) + bitMap.set(selTOFDeltaTPositivePionLambdaOmega); + // negative track + if (std::fabs(casc.negTOFDeltaTXiPr()) < PIDConfigurations.maxDeltaTimeProton) + bitMap.set(selTOFDeltaTNegativeProtonLambdaXi); + if (std::fabs(casc.negTOFDeltaTXiPi()) < PIDConfigurations.maxDeltaTimePion) + bitMap.set(selTOFDeltaTNegativePionLambdaXi); + if (std::fabs(casc.negTOFDeltaTOmPr()) < PIDConfigurations.maxDeltaTimeProton) + bitMap.set(selTOFDeltaTNegativeProtonLambdaOmega); + if (std::fabs(casc.negTOFDeltaTOmPi()) < PIDConfigurations.maxDeltaTimePion) + bitMap.set(selTOFDeltaTNegativePionLambdaOmega); + // bachelor track + if (std::fabs(casc.bachTOFDeltaTOmKa()) < PIDConfigurations.maxDeltaTimeKaon) + bitMap.set(selTOFDeltaTBachKaonOmega); + if (std::fabs(casc.bachTOFDeltaTXiPi()) < PIDConfigurations.maxDeltaTimePion) + bitMap.set(selTOFDeltaTBachPionXi); + + // TOF PID in NSigma + // meson track + if (std::fabs(casc.tofNSigmaXiLaPi()) < PIDConfigurations.tofPidNsigmaCutLaPi) { + bitMap.set(selTOFNSigmaPositivePionLambdaXi); + bitMap.set(selTOFNSigmaNegativePionLambdaXi); + } + if (std::fabs(casc.tofNSigmaOmLaPi()) < PIDConfigurations.tofPidNsigmaCutLaPi) { + bitMap.set(selTOFNSigmaPositivePionLambdaOmega); + bitMap.set(selTOFNSigmaNegativePionLambdaOmega); + } + // baryon track + if (std::fabs(casc.tofNSigmaXiLaPr()) < PIDConfigurations.tofPidNsigmaCutLaPr) { + bitMap.set(selTOFNSigmaNegativeProtonLambdaXi); + bitMap.set(selTOFNSigmaPositiveProtonLambdaXi); + } + if (std::fabs(casc.tofNSigmaOmLaPr()) < PIDConfigurations.tofPidNsigmaCutLaPr) { + bitMap.set(selTOFNSigmaNegativePionLambdaOmega); + bitMap.set(selTOFNSigmaPositivePionLambdaOmega); + } + // bachelor track + if (std::fabs(casc.tofNSigmaXiPi()) < PIDConfigurations.tofPidNsigmaCutXiPi) { + bitMap.set(selTOFNSigmaBachPionXi); + } + if (std::fabs(casc.tofNSigmaOmKa()) < PIDConfigurations.tofPidNsigmaCutOmegaKaon) { + bitMap.set(selTOFNSigmaBachKaonOmega); + } + + // ITS only tag + if (posTrackExtra.tpcCrossedRows() < 1) + bitMap.set(selPosItsOnly); + if (negTrackExtra.tpcCrossedRows() < 1) + bitMap.set(selNegItsOnly); + if (bachTrackExtra.tpcCrossedRows() < 1) + bitMap.set(selBachItsOnly); + + // rej. comp. + if (std::fabs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > casccuts.rejcomp) + bitMap.set(selRejCompXi); + if (std::fabs(casc.mXi() - o2::constants::physics::MassXiMinus) > casccuts.rejcomp) + bitMap.set(selRejCompOmega); + + // TPC only tag + if (posTrackExtra.detectorMap() != o2::aod::track::TPC) + bitMap.set(selPosNotTPCOnly); + if (negTrackExtra.detectorMap() != o2::aod::track::TPC) + bitMap.set(selNegNotTPCOnly); + if (bachTrackExtra.detectorMap() != o2::aod::track::TPC) + bitMap.set(selBachNotTPCOnly); + + return bitMap; + } + + template + std::bitset computeBitmapV0(TV0 const& v0, TCollision const& collision) + { + float rapidityLambda = v0.yLambda(); + float rapidityK0Short = v0.yK0Short(); + + std::bitset bitMap = 0; + + // base topological variables + if (v0.v0radius() > v0cuts.v0radius) + bitMap.set(selV0Radius); + if (v0.v0radius() < v0cuts.v0radiusMax) + bitMap.set(selV0RadiusMax); + if (std::fabs(v0.dcapostopv()) > v0cuts.dcapostopv) + bitMap.set(selDCAPosToPV); + if (std::fabs(v0.dcanegtopv()) > v0cuts.dcanegtopv) + bitMap.set(selDCANegToPV); + if (v0.v0cosPA() > v0cuts.v0cospa) + bitMap.set(selV0CosPA); + if (v0.dcaV0daughters() < v0cuts.dcav0dau) + bitMap.set(selDCAV0Dau); + + // kinematic + if (std::fabs(rapidityLambda) < rapidityCut) + bitMap.set(selLambdaRapidity); + if (std::fabs(rapidityK0Short) < rapidityCut) + bitMap.set(selK0ShortRapidity); + if (std::fabs(v0.negativeeta()) < daughterEtaCut) + bitMap.set(selNegEta); + if (std::fabs(v0.positiveeta()) < daughterEtaCut) + bitMap.set(selPosEta); + + // c x tau + float ctauK0short = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short; + float ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; + + auto posTrackExtra = v0.template posTrackExtra_as(); + auto negTrackExtra = v0.template negTrackExtra_as(); + + // DCA cuts + auto pospt = std::sqrt(std::pow(v0.pxpos(), 2) + std::pow(v0.pypos(), 2)); + auto negpt = std::sqrt(std::pow(v0.pxneg(), 2) + std::pow(v0.pyneg(), 2)); + + double posDcaXYLimit = 0.0105f + 0.035f / std::pow(pospt, 1.1f); + double negDcaXYLimit = 0.0105f + 0.035f / std::pow(negpt, 1.1f); + + // TODO: separate xy and z // + if ((std::abs(v0.dcapostopv()) > posDcaXYLimit) && + (std::abs(v0.dcanegtopv()) > negDcaXYLimit)) { + bitMap.set(selDauDCA); + } + + // ITS quality flags + if (posTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) + bitMap.set(selPosGoodITSTrack); + if (negTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) + bitMap.set(selNegGoodITSTrack); + + // TPC quality flags + if (posTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) + bitMap.set(selPosGoodTPCTrack); + if (negTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) + bitMap.set(selNegGoodTPCTrack); + + // TPC PID + if (std::fabs(posTrackExtra.tpcNSigmaPi()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDPositivePion); + if (std::fabs(posTrackExtra.tpcNSigmaPr()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDPositiveProton); + if (std::fabs(negTrackExtra.tpcNSigmaPi()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDNegativePion); + if (std::fabs(negTrackExtra.tpcNSigmaPr()) < PIDConfigurations.tpcPidNsigmaCut) + bitMap.set(selTPCPIDNegativeProton); + + // TOF PID in DeltaT + // positive track + if (std::fabs(v0.posTOFDeltaTLaPr()) < PIDConfigurations.maxDeltaTimeProton) + bitMap.set(selTOFDeltaTPositiveProtonLambda); + if (std::fabs(v0.posTOFDeltaTLaPi()) < PIDConfigurations.maxDeltaTimePion) + bitMap.set(selTOFDeltaTPositivePionLambda); + if (std::fabs(v0.posTOFDeltaTK0Pi()) < PIDConfigurations.maxDeltaTimePion) + bitMap.set(selTOFDeltaTPositivePionK0Short); + // negative track + if (std::fabs(v0.negTOFDeltaTLaPr()) < PIDConfigurations.maxDeltaTimeProton) + bitMap.set(selTOFDeltaTNegativeProtonLambda); + if (std::fabs(v0.negTOFDeltaTLaPi()) < PIDConfigurations.maxDeltaTimePion) + bitMap.set(selTOFDeltaTNegativePionLambda); + if (std::fabs(v0.negTOFDeltaTK0Pi()) < PIDConfigurations.maxDeltaTimePion) + bitMap.set(selTOFDeltaTNegativePionK0Short); + + // TOF PID in NSigma + // positive track + if (std::fabs(v0.tofNSigmaLaPr()) < PIDConfigurations.tofPidNsigmaCutLaPr) + bitMap.set(selTOFNSigmaPositiveProtonLambda); + if (std::fabs(v0.tofNSigmaALaPi()) < PIDConfigurations.tofPidNsigmaCutLaPi) + bitMap.set(selTOFNSigmaPositivePionLambda); + if (std::fabs(v0.tofNSigmaK0PiPlus()) < PIDConfigurations.tofPidNsigmaCutK0Pi) + bitMap.set(selTOFNSigmaPositivePionK0Short); + // negative track + if (std::fabs(v0.tofNSigmaALaPr()) < PIDConfigurations.tofPidNsigmaCutLaPr) + bitMap.set(selTOFNSigmaNegativeProtonLambda); + if (std::fabs(v0.tofNSigmaLaPi()) < PIDConfigurations.tofPidNsigmaCutLaPi) + bitMap.set(selTOFNSigmaNegativePionLambda); + if (std::fabs(v0.tofNSigmaK0PiMinus()) < PIDConfigurations.tofPidNsigmaCutK0Pi) + bitMap.set(selTOFNSigmaNegativePionK0Short); + + // ITS only tag + if (posTrackExtra.tpcCrossedRows() < 1) + bitMap.set(selPosItsOnly); + if (negTrackExtra.tpcCrossedRows() < 1) + bitMap.set(selNegItsOnly); + + // TPC only tag + if (posTrackExtra.detectorMap() != o2::aod::track::TPC) + bitMap.set(selPosNotTPCOnly); + if (negTrackExtra.detectorMap() != o2::aod::track::TPC) + bitMap.set(selNegNotTPCOnly); + + // proper lifetime + if (ctauLambda < nCtauCutV0->get("lifetimecutLambda") * ctaulambdaPDG) + bitMap.set(selLambdaCTau); + if (ctauK0short < nCtauCutV0->get("lifetimecutK0S") * ctauk0shortPDG) + bitMap.set(selK0ShortCTau); + + // armenteros + if (v0.qtarm() * v0cuts.armPodCut > std::fabs(v0.alpha()) || v0cuts.armPodCut < 1e-4) + bitMap.set(selK0ShortArmenteros); + + return bitMap; + } + + template + void analyseCascCandidate(TCasc const& casc, TCollision const& coll, int const& gap, std::bitset const& selMap) + { + // Access daughter tracks + auto posTrackExtra = casc.template posTrackExtra_as(); + auto negTrackExtra = casc.template negTrackExtra_as(); + auto bachTrackExtra = casc.template bachTrackExtra_as(); + + if (doPlainTopoQA) { + histos.fill(HIST("generalQA/hPt"), casc.pt()); + histos.fill(HIST("generalQA/hCascCosPA"), casc.pt(), casc.casccosPA(coll.posX(), coll.posY(), coll.posZ())); + histos.fill(HIST("generalQA/hDCACascDaughters"), casc.pt(), casc.dcacascdaughters()); + histos.fill(HIST("generalQA/hCascRadius"), casc.pt(), casc.cascradius()); + histos.fill(HIST("generalQA/hMesonDCAToPV"), casc.pt(), casc.dcanegtopv()); + histos.fill(HIST("generalQA/hBaryonDCAToPV"), casc.pt(), casc.dcapostopv()); + histos.fill(HIST("generalQA/hBachDCAToPV"), casc.pt(), casc.dcabachtopv()); + histos.fill(HIST("generalQA/hV0CosPA"), casc.pt(), casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ())); + histos.fill(HIST("generalQA/hV0Radius"), casc.pt(), casc.v0radius()); + histos.fill(HIST("generalQA/hDCAV0Daughters"), casc.pt(), casc.dcaV0daughters()); + histos.fill(HIST("generalQA/hDCAV0ToPV"), casc.pt(), std::fabs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ()))); + histos.fill(HIST("generalQA/hMassLambdaDau"), casc.pt(), casc.mLambda()); + histos.fill(HIST("generalQA/h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); + histos.fill(HIST("generalQA/h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); + histos.fill(HIST("generalQA/h2dBachITSvsTPCpts"), bachTrackExtra.tpcCrossedRows(), bachTrackExtra.itsNCls()); + } + + // Xi + if (verifyMask(selMap, maskSelectionXi) && analyseXi) { + fillHistogramsCasc<3>(casc, coll, gap); + } + + // Anti-Xi + if (verifyMask(selMap, maskSelectionAntiXi) && analyseAntiXi) { + fillHistogramsCasc<4>(casc, coll, gap); + } + + // Omega + if (verifyMask(selMap, maskSelectionOmega) && analyseOmega) { + fillHistogramsCasc<5>(casc, coll, gap); + } + + // Anti-Omega + if (verifyMask(selMap, maskSelectionAntiOmega) && analyseAntiOmega) { + fillHistogramsCasc<6>(casc, coll, gap); + } + } + + template + void computeV0MCAssociation(const TV0& v0, std::bitset& bitMap) + { + const int pdgPos = v0.pdgCodePositive(); + const int pdgNeg = v0.pdgCodeNegative(); + const int pdgV0 = v0.pdgCode(); + const bool isPhysPrim = v0.isPhysicalPrimary(); + + const bool isPositiveProton = (pdgPos == PDG_t::kProton); + const bool isPositivePion = (pdgPos == PDG_t::kPiPlus) || (doTreatPiToMuon && pdgPos == PDG_t::kMuonPlus); + const bool isNegativeProton = (pdgNeg == kProtonBar); + const bool isNegativePion = (pdgNeg == PDG_t::kPiMinus) || (doTreatPiToMuon && pdgNeg == PDG_t::kMuonMinus); + + switch (pdgV0) { + case PDG_t::kK0Short: // K0Short + if (isPositivePion && isNegativePion) { + bitMap.set(selConsiderK0Short); + if (isPhysPrim) + bitMap.set(selPhysPrimK0Short); + } + break; + case PDG_t::kLambda0: // Lambda + if (isPositiveProton && isNegativePion) { + bitMap.set(selConsiderLambda); + if (isPhysPrim) + bitMap.set(selPhysPrimLambda); + } + break; + case PDG_t::kLambda0Bar: // AntiLambda + if (isPositivePion && isNegativeProton) { + bitMap.set(selConsiderAntiLambda); + if (isPhysPrim) + bitMap.set(selPhysPrimAntiLambda); + } + break; + } + } + + template + void computeCascadeMCAssociation(const TCasc& casc, std::bitset& bitMap) + { + const int pdgPos = casc.pdgCodePositive(); + const int pdgNeg = casc.pdgCodeNegative(); + const int pdgBach = casc.pdgCodeBachelor(); + const int pdgCasc = casc.pdgCode(); + const bool isPhysPrim = casc.isPhysicalPrimary(); + + const bool isPositiveProton = (pdgPos == PDG_t::kProton); + + const bool isPositivePion = (pdgPos == PDG_t::kPiPlus); + const bool isBachelorPositivePion = (pdgBach == PDG_t::kPiPlus); + + const bool isNegativeProton = (pdgNeg == kProtonBar); + + const bool isNegativePion = (pdgNeg == PDG_t::kPiMinus); + const bool isBachelorNegativePion = (pdgBach == PDG_t::kPiMinus); + + const bool isBachelorPositiveKaon = (pdgBach == PDG_t::kKPlus); + const bool isBachelorNegativeKaon = (pdgBach == PDG_t::kKMinus); + + switch (pdgCasc) { + case PDG_t::kXiMinus: // Xi + if (isPositiveProton && isNegativePion && isBachelorNegativePion) { + bitMap.set(selConsiderXi); + if (isPhysPrim) + bitMap.set(selPhysPrimXi); + } + break; + case PDG_t::kXiPlusBar: // Anti-Xi + if (isNegativeProton && isPositivePion && isBachelorPositivePion) { + bitMap.set(selConsiderAntiXi); + if (isPhysPrim) + bitMap.set(selPhysPrimAntiXi); + } + break; + case PDG_t::kOmegaMinus: // Omega + if (isPositiveProton && isNegativePion && isBachelorNegativeKaon) { + bitMap.set(selConsiderOmega); + if (isPhysPrim) + bitMap.set(selPhysPrimOmega); + } + break; + case PDG_t::kOmegaPlusBar: // Anti-Omega + if (isNegativeProton && isPositivePion && isBachelorPositiveKaon) { + bitMap.set(selConsiderAntiOmega); + if (isPhysPrim) + bitMap.set(selPhysPrimAntiOmega); + } + break; + } + } + + template + void analyseV0Candidate(TV0 const& v0, TCollision const& coll, int const& gap, std::bitset const& selMap) + { + auto posTrackExtra = v0.template posTrackExtra_as(); + auto negTrackExtra = v0.template negTrackExtra_as(); + + // QA plots + if (doPlainTopoQA) { + histos.fill(HIST("generalQA/hPt"), v0.pt()); + histos.fill(HIST("generalQA/hPosDCAToPV"), v0.dcapostopv()); + histos.fill(HIST("generalQA/hNegDCAToPV"), v0.dcanegtopv()); + histos.fill(HIST("generalQA/hDCADaughters"), v0.dcaV0daughters()); + histos.fill(HIST("generalQA/hPointingAngle"), std::acos(v0.v0cosPA())); + histos.fill(HIST("generalQA/hCosPA"), v0.v0cosPA()); + histos.fill(HIST("generalQA/hV0Radius"), v0.v0radius()); + histos.fill(HIST("generalQA/h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); + histos.fill(HIST("generalQA/h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); + } + + histos.fill(HIST("generalQA/h2dArmenterosAll"), v0.alpha(), v0.qtarm()); + + // K0s + if (verifyMask(selMap, maskSelectionK0Short) && analyseK0Short) { + fillHistogramsV0<0>(v0, coll, gap); + } + + // Lambda + if (verifyMask(selMap, maskSelectionLambda) && analyseLambda) { + fillHistogramsV0<1>(v0, coll, gap); + } + + // Anti-Lambda + if (verifyMask(selMap, maskSelectionAntiLambda) && analyseAntiLambda) { + fillHistogramsV0<2>(v0, coll, gap); + } + } + + PresliceUnsorted perMcCollision = aod::v0data::straMCCollisionId; + PresliceUnsorted neutronsPerMcCollision = aod::zdcneutrons::straMCCollisionId; + + std::vector getListOfRecoCollIds(StraMCCollisionsFull const& mcCollisions, + StraCollisonsFullMC const& collisions, + NeutronsMC const& neutrons) + { + std::vector listBestCollisionIds(mcCollisions.size(), -1); + + for (auto const& mcCollision : mcCollisions) { + if (std::find(generatorIds->begin(), generatorIds->end(), mcCollision.generatorsID()) == generatorIds->end()) { + continue; + } + + // Group collisions and neutrons by MC collision index + auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex()); + auto groupedNeutrons = neutrons.sliceBy(neutronsPerMcCollision, mcCollision.globalIndex()); + // Find the collision with the biggest nbr of PV contributors + // Follows what was done here: https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/mcCollsExtra.cxx#L93 + int biggestNContribs = -1; + int bestCollisionIndex = -1; + for (auto const& collision : groupedCollisions) { + if (!acceptEvent(collision, false)) { + continue; + } + + int selGapSide = collision.isUPC() ? getGapSide(collision) : -1; + if (checkNeutronsInMC) { + for (const auto& neutron : groupedNeutrons) { + if (selGapSide < -0.5) + break; + + const float eta = neutron.eta(); + switch (selGapSide) { + case 0: // SGA + if (eta > neutronEtaCut) + selGapSide = -1; + break; + case 1: // SGC + if (eta < -neutronEtaCut) + selGapSide = -1; + break; + case 2: // DG + if (eta > neutronEtaCut) + selGapSide = 1; + else if (eta < -neutronEtaCut) + selGapSide = 0; + break; + } + } + } + + if (evSels.studyUPConly && (selGapSide != static_cast(upcCuts.genGapSide))) + continue; + + if (biggestNContribs < collision.multPVTotalContributors()) { + biggestNContribs = collision.multPVTotalContributors(); + bestCollisionIndex = collision.globalIndex(); + } + } + listBestCollisionIds[mcCollision.globalIndex()] = bestCollisionIndex; + } + + return listBestCollisionIds; + } + + void fillGenMCHistogramsQA(StraMCCollisionsFull const& mcCollisions, + StraCollisonsFullMC const& collisions, + NeutronsMC const& neutrons) + { + for (auto const& mcCollision : mcCollisions) { + // LOGF(info, "Generator ID is %i", mcCollision.generatorsID()); + histos.fill(HIST("eventQA/mc/hGeneratorsId"), mcCollision.generatorsID()); + + if (std::find(generatorIds->begin(), generatorIds->end(), mcCollision.generatorsID()) == generatorIds->end()) { + continue; + } + + histos.fill(HIST("eventQA/mc/hEventSelectionMC"), 0.0, mcCollision.multMCNParticlesEta08(), mcCollision.generatorsID()); + + if (std::abs(mcCollision.posZ()) > maxZVtxPosition) + continue; + + histos.fill(HIST("eventQA/mc/hEventSelectionMC"), 1.0, mcCollision.multMCNParticlesEta08(), mcCollision.generatorsID()); + + // Group collisions and neutrons by MC collision index + auto groupedCollisions = collisions.sliceBy(perMcCollision, mcCollision.globalIndex()); + auto groupedNeutrons = neutrons.sliceBy(neutronsPerMcCollision, mcCollision.globalIndex()); + + bool atLeastOne = false; + float centrality = -1.f; + float ft0ampl = -1.f; + int nCollisions = 0; + int biggestNContribs = -1; + int nTracksGlobal = -1; + + // Find the max contributors and count accepted collisions + for (auto const& collision : groupedCollisions) { + if (!acceptEvent(collision, false)) { + continue; + } + + int selGapSide = collision.isUPC() ? getGapSide(collision) : -1; + if (checkNeutronsInMC) { + for (const auto& neutron : groupedNeutrons) { + if (selGapSide < -0.5) + break; + + const float eta = neutron.eta(); + switch (selGapSide) { + case 0: // SGA + if (eta > neutronEtaCut) + selGapSide = -1; + break; + case 1: // SGC + if (eta < -neutronEtaCut) + selGapSide = -1; + break; + case 2: // DG + if (eta > neutronEtaCut) + selGapSide = 1; + else if (eta < -neutronEtaCut) + selGapSide = 0; + break; + } + } + } + + if (evSels.studyUPConly && (selGapSide != static_cast(upcCuts.genGapSide))) + continue; + + ++nCollisions; + atLeastOne = true; + + if (biggestNContribs < collision.multPVTotalContributors()) { + biggestNContribs = collision.multPVTotalContributors(); + if (static_cast(upcCuts.genGapSide) == 0) { + ft0ampl = collision.totalFT0AmplitudeC(); + centrality = collision.centFT0C(); + } else if (static_cast(upcCuts.genGapSide) == 1) { + ft0ampl = collision.totalFT0AmplitudeA(); + centrality = collision.centFT0A(); + } + nTracksGlobal = collision.multNTracksGlobal(); + } + } + + // Fill histograms + histos.fill(HIST("eventQA/mc/hTracksGlobalVsNcoll_beforeEvSel"), nTracksGlobal, groupedCollisions.size()); + histos.fill(HIST("eventQA/mc/hTracksGlobalVsNcoll_afterEvSel"), nTracksGlobal, nCollisions); + histos.fill(HIST("eventQA/mc/hTracksGlobalvsMCNParticlesEta08gen"), nTracksGlobal, mcCollision.multMCNParticlesEta08()); + histos.fill(HIST("eventQA/mc/hTracksGlobalVsPVzMC"), nTracksGlobal, mcCollision.posZ()); + histos.fill(HIST("eventQA/mc/hEventPVzMC"), mcCollision.posZ()); + + if (atLeastOne) { + histos.fill(HIST("eventQA/mc/hEventSelectionMC"), 2.0, mcCollision.multMCNParticlesEta08(), mcCollision.generatorsID()); + histos.fill(HIST("eventQA/mc/hGenEventCentrality"), centrality); + histos.fill(HIST("eventQA/mc/hGenEventFT0ampl"), ft0ampl); + } + } + } + + template + void fillFeeddownMatrix(TCollision const& collision, TV0 const& v0, std::bitset const& selMap) + { + if (!v0.has_motherMCPart()) { + return; + } + + const auto v0mother = v0.template motherMCPart_as(); + if (v0mother.size() < 1) { + return; + } + + const float rapidityXi = RecoDecay::y(std::array{v0mother.px(), v0mother.py(), v0mother.pz()}, o2::constants::physics::MassXiMinus); + if (std::fabs(rapidityXi) > 0.5f) { + return; + } + + const float mult = collision.multNTracksGlobal(); + const float v0pt = v0.pt(); + const float motherPt = std::hypot(v0mother.px(), v0mother.py()); + + if (analyseLambda && verifyMask(selMap, secondaryMaskSelectionLambda) && + (v0mother.pdgCode() == PDG_t::kXiMinus) && v0mother.isPhysicalPrimary()) { + histos.fill(HIST(kParticlenames[1]) + HIST("/h3dLambdaFeeddown"), mult, v0pt, motherPt); + } + + if (analyseAntiLambda && verifyMask(selMap, secondaryMaskSelectionAntiLambda) && + (v0mother.pdgCode() == PDG_t::kXiPlusBar) && v0mother.isPhysicalPrimary()) { + histos.fill(HIST(kParticlenames[2]) + HIST("/h3dAntiLambdaFeeddown"), mult, v0pt, motherPt); + } + } + + void processV0s(StraCollisonFull const& collision, V0Candidates const& fullV0s, DauTracks const&) + { + if (!acceptEvent(collision, true)) { + return; + } // event is accepted + + histos.fill(HIST("eventQA/hRawGapSide"), collision.gapSide()); + + int selGapSide = collision.isUPC() ? getGapSide(collision) : -1; + if (evSels.studyUPConly && (selGapSide < -0.5)) + return; + + fillHistogramsQA(collision, selGapSide); + + for (const auto& v0 : fullV0s) { + if ((v0.v0Type() != v0cuts.v0TypeSelection) && (v0cuts.v0TypeSelection > 0)) + continue; // skip V0s that are not standard + + std::bitset selMap = computeBitmapV0(v0, collision); + + // consider all species for the candidate + setBits(selMap, {selConsiderK0Short, selConsiderLambda, selConsiderAntiLambda, + selPhysPrimK0Short, selPhysPrimLambda, selPhysPrimAntiLambda}); + + analyseV0Candidate(v0, collision, selGapSide, selMap); + } // end v0 loop + } + + void processV0sMC(StraCollisonFullMC const& collision, + V0CandidatesMC const& fullV0s, + DauTracks const&, + aod::MotherMCParts const&, + StraMCCollisionsFull const&, + V0MCCoresFull const&, + NeutronsMC const& neutrons) + { + if (!collision.has_straMCCollision()) { + histos.fill(HIST("eventQA/mc/hFakeEvents"), 0); // no assoc. MC collisions + return; + } + + const auto& mcCollision = collision.straMCCollision_as(); // take gen. collision associated to the rec. collision + + if (std::find(generatorIds->begin(), generatorIds->end(), mcCollision.generatorsID()) == generatorIds->end()) { + return; + } + + if (!acceptEvent(collision, true)) { + return; + } // event is accepted + + histos.fill(HIST("eventQA/hRawGapSide"), collision.gapSide()); + + int selGapSide = collision.isUPC() ? getGapSide(collision) : -1; + int selGapSideNoNeutrons = selGapSide; + + auto groupedNeutrons = neutrons.sliceBy(neutronsPerMcCollision, mcCollision.globalIndex()); + if (checkNeutronsInMC) { + for (const auto& neutron : groupedNeutrons) { + if (selGapSide < -0.5) + break; + + const float eta = neutron.eta(); + switch (selGapSide) { + case 0: // SGA + if (eta > neutronEtaCut) + selGapSide = -1; + break; + case 1: // SGC + if (eta < -neutronEtaCut) + selGapSide = -1; + break; + case 2: // DG + if (eta > neutronEtaCut) + selGapSide = 1; + else if (eta < -neutronEtaCut) + selGapSide = 0; + break; + } + } + } + + if (evSels.studyUPConly && (selGapSide < -0.5)) + return; + + histos.fill(HIST("eventQA/hSelGapSideNoNeutrons"), selGapSideNoNeutrons); + fillHistogramsQA(collision, selGapSide); + + histos.fill(HIST("eventQA/mc/hNTracksGlobalvsMCNParticlesEta08rec"), collision.multNTracksGlobal(), mcCollision.multMCNParticlesEta08()); + histos.fill(HIST("eventQA/mc/hNTracksPVeta1vsMCNParticlesEta10rec"), collision.multNTracksPVeta1(), mcCollision.multMCNParticlesEta10()); + histos.fill(HIST("eventQA/mc/hNTracksGlobalvstotalMultMCParticles"), collision.multNTracksGlobal(), mcCollision.totalMultMCParticles()); + histos.fill(HIST("eventQA/mc/hNTracksPVeta1vstotalMultMCParticles"), collision.multNTracksPVeta1(), mcCollision.totalMultMCParticles()); + + for (const auto& v0 : fullV0s) { + if ((v0.v0Type() != v0cuts.v0TypeSelection) && (v0cuts.v0TypeSelection > 0)) + continue; // skip V0s that are not standard + + std::bitset selMap = computeBitmapV0(v0, collision); + + if (doMCAssociation) { + if (v0.has_v0MCCore()) { + const auto& v0MC = v0.v0MCCore_as(); + computeV0MCAssociation(v0MC, selMap); + if (calculateFeeddownMatrix) { + fillFeeddownMatrix(collision, v0, selMap); + } + } + } else { + // consider all species for the candidate + setBits(selMap, {selConsiderK0Short, selConsiderLambda, selConsiderAntiLambda, + selPhysPrimK0Short, selPhysPrimLambda, selPhysPrimAntiLambda}); + } + + analyseV0Candidate(v0, collision, selGapSide, selMap); + } // end v0 loop + } + + void processCascades(StraCollisonFull const& collision, + CascadeCandidates const& fullCascades, + DauTracks const&) + { + if (!acceptEvent(collision, true)) { + return; + } // event is accepted + + histos.fill(HIST("eventQA/hRawGapSide"), collision.gapSide()); + + int selGapSide = collision.isUPC() ? getGapSide(collision) : -1; + if (evSels.studyUPConly && (selGapSide < -0.5)) + return; + + fillHistogramsQA(collision, selGapSide); + + for (const auto& casc : fullCascades) { + std::bitset selMap = computeBitmapCascade(casc, collision); + // the candidate may belong to any particle species + setBits(selMap, {selConsiderXi, selConsiderAntiXi, selConsiderOmega, selConsiderAntiOmega, + selPhysPrimXi, selPhysPrimAntiXi, selPhysPrimOmega, selPhysPrimAntiOmega}); + + analyseCascCandidate(casc, collision, selGapSide, selMap); + } // end casc loop + } + + void processCascadesMC(StraCollisonFullMC const& collision, + CascadeCandidatesMC const& fullCascades, + DauTracks const&, + aod::MotherMCParts const&, + StraMCCollisionsFull const&, + CascMCCoresFull const&, + NeutronsMC const& neutrons) + { + if (!collision.has_straMCCollision()) { + histos.fill(HIST("eventQA/mc/hFakeEvents"), 0); // no assoc. MC collisions + return; + } + + const auto& mcCollision = collision.straMCCollision_as(); // take gen. collision associated to the rec. collision + + if (std::find(generatorIds->begin(), generatorIds->end(), mcCollision.generatorsID()) == generatorIds->end()) { + return; + } + + if (!acceptEvent(collision, true)) { + return; + } // event is accepted + + histos.fill(HIST("eventQA/hRawGapSide"), collision.gapSide()); + + int selGapSide = collision.isUPC() ? getGapSide(collision) : -1; + int selGapSideNoNeutrons = selGapSide; + + auto groupedNeutrons = neutrons.sliceBy(neutronsPerMcCollision, mcCollision.globalIndex()); + if (checkNeutronsInMC) { + for (const auto& neutron : groupedNeutrons) { + if (selGapSide < -0.5) + break; + + const float eta = neutron.eta(); + switch (selGapSide) { + case 0: // SGA + if (eta > neutronEtaCut) + selGapSide = -1; + break; + case 1: // SGC + if (eta < -neutronEtaCut) + selGapSide = -1; + break; + case 2: // DG + if (eta > neutronEtaCut) + selGapSide = 1; + else if (eta < -neutronEtaCut) + selGapSide = 0; + break; + } + } + } + + if (evSels.studyUPConly && (selGapSide < -0.5)) + return; + + histos.fill(HIST("eventQA/hSelGapSideNoNeutrons"), selGapSideNoNeutrons); + fillHistogramsQA(collision, selGapSide); + + histos.fill(HIST("eventQA/mc/hNTracksGlobalvsMCNParticlesEta08rec"), collision.multNTracksGlobal(), mcCollision.multMCNParticlesEta08()); + histos.fill(HIST("eventQA/mc/hNTracksPVeta1vsMCNParticlesEta10rec"), collision.multNTracksPVeta1(), mcCollision.multMCNParticlesEta10()); + histos.fill(HIST("eventQA/mc/hNTracksGlobalvstotalMultMCParticles"), collision.multNTracksGlobal(), mcCollision.totalMultMCParticles()); + histos.fill(HIST("eventQA/mc/hNTracksPVeta1vstotalMultMCParticles"), collision.multNTracksPVeta1(), mcCollision.totalMultMCParticles()); + + for (const auto& casc : fullCascades) { + std::bitset selMap = computeBitmapCascade(casc, collision); + + if (doMCAssociation) { + if (casc.has_cascMCCore()) { + const auto& cascMC = casc.cascMCCore_as(); + computeCascadeMCAssociation(cascMC, selMap); + } + } else { + // the candidate may belong to any particle species + setBits(selMap, {selConsiderXi, selConsiderAntiXi, selConsiderOmega, selConsiderAntiOmega, + selPhysPrimXi, selPhysPrimAntiXi, selPhysPrimOmega, selPhysPrimAntiOmega}); + } + + analyseCascCandidate(casc, collision, selGapSide, selMap); + } // end casc loop + } + + void processGenerated(StraMCCollisionsFull const& mcCollisions, + V0MCCoresFull const& V0MCCores, + CascMCCoresFull const& CascMCCores, + StraCollisonsFullMC const& collisions, + NeutronsMC const& neutrons) + { + fillGenMCHistogramsQA(mcCollisions, collisions, neutrons); + std::vector listBestCollisionIds = getListOfRecoCollIds(mcCollisions, collisions, neutrons); + // V0 start + for (auto const& v0MC : V0MCCores) { + // Consider only primaries + if (!v0MC.has_straMCCollision() || !v0MC.isPhysicalPrimary()) + continue; + + // Kinematics (|y| < rapidityCut) + float pTmc = v0MC.ptMC(); + float ymc = 1e3; + if (v0MC.pdgCode() == PDG_t::kK0Short) + ymc = v0MC.rapidityMC(0); + else if ((v0MC.pdgCode() == PDG_t::kLambda0) || (v0MC.pdgCode() == PDG_t::kLambda0Bar)) + ymc = v0MC.rapidityMC(1); + if (std::abs(ymc) > rapidityCut) + continue; + + const auto& mcCollision = v0MC.straMCCollision_as(); // take gen. collision + + if (std::abs(mcCollision.posZ()) > maxZVtxPosition) + continue; + + // Collision is of the proccess of interest + if (std::find(generatorIds->begin(), generatorIds->end(), mcCollision.generatorsID()) == generatorIds->end()) { + continue; + } + + // float centrality = -1.f; + float ft0ampl = -1.f; + int nTracksGlobal = -1; + + if (listBestCollisionIds[mcCollision.globalIndex()] > -1) { + auto collision = collisions.iteratorAt(listBestCollisionIds[mcCollision.globalIndex()]); + // centrality = collision.centFT0C(); + if (static_cast(upcCuts.genGapSide) == 0) { + ft0ampl = collision.totalFT0AmplitudeC(); + } else if (static_cast(upcCuts.genGapSide) == 1) { + ft0ampl = collision.totalFT0AmplitudeA(); + } + nTracksGlobal = collision.multNTracksGlobal(); + } + + const int pdgPos = v0MC.pdgCodePositive(); + const int pdgNeg = v0MC.pdgCodeNegative(); + const int pdgV0 = v0MC.pdgCode(); + + const bool isPositiveProton = (pdgPos == PDG_t::kProton); + const bool isPositivePion = (pdgPos == PDG_t::kPiPlus) || (doTreatPiToMuon && pdgPos == PDG_t::kMuonPlus); + const bool isNegativeProton = (pdgNeg == kProtonBar); + const bool isNegativePion = (pdgNeg == PDG_t::kPiMinus) || (doTreatPiToMuon && pdgNeg == PDG_t::kMuonMinus); + + // Fill histograms + if ((pdgV0 == PDG_t::kK0Short) && isPositivePion && isNegativePion) { + histos.fill(HIST(kParticlenames[0]) + HIST("/mc/h7dGen"), ft0ampl, nTracksGlobal, mcCollision.multMCNParticlesEta08(), pTmc, static_cast(upcCuts.genGapSide), ymc, mcCollision.generatorsID()); + } + if ((pdgV0 == PDG_t::kLambda0) && isPositiveProton && isNegativePion) { + histos.fill(HIST(kParticlenames[1]) + HIST("/mc/h7dGen"), ft0ampl, nTracksGlobal, mcCollision.multMCNParticlesEta08(), pTmc, static_cast(upcCuts.genGapSide), ymc, mcCollision.generatorsID()); + } + if ((pdgV0 == PDG_t::kLambda0Bar) && isPositivePion && isNegativeProton) { + histos.fill(HIST(kParticlenames[2]) + HIST("/mc/h7dGen"), ft0ampl, nTracksGlobal, mcCollision.multMCNParticlesEta08(), pTmc, static_cast(upcCuts.genGapSide), ymc, mcCollision.generatorsID()); + } + } // V0 end + + // Cascade start + for (auto const& cascMC : CascMCCores) { + // Consider only primaries + if (!cascMC.has_straMCCollision() || !cascMC.isPhysicalPrimary()) + continue; + // Kinematics (|y| < rapidityCut) + float pTmc = cascMC.ptMC(); + float ymc = 1e3; + if ((cascMC.pdgCode() == PDG_t::kXiMinus) || (cascMC.pdgCode() == PDG_t::kXiPlusBar)) { + ymc = cascMC.rapidityMC(0); + } else if ((cascMC.pdgCode() == PDG_t::kOmegaMinus) || (cascMC.pdgCode() == PDG_t::kOmegaPlusBar)) { + ymc = cascMC.rapidityMC(2); + } + if (std::abs(ymc) > rapidityCut) + continue; + + const auto& mcCollision = cascMC.straMCCollision_as(); // take gen. collision + if (std::abs(mcCollision.posZ()) > maxZVtxPosition) + continue; + + // float centrality = -1.f; + float ft0ampl = -1.f; + int nTracksGlobal = -1; + + if (listBestCollisionIds[mcCollision.globalIndex()] > -1) { + auto collision = collisions.iteratorAt(listBestCollisionIds[mcCollision.globalIndex()]); + // centrality = collision.centFT0C(); + if (static_cast(upcCuts.genGapSide) == 0) { + ft0ampl = collision.totalFT0AmplitudeC(); + } else if (static_cast(upcCuts.genGapSide) == 1) { + ft0ampl = collision.totalFT0AmplitudeA(); + } + } + + const int pdgPos = cascMC.pdgCodePositive(); + const int pdgNeg = cascMC.pdgCodeNegative(); + const int pdgBach = cascMC.pdgCodeBachelor(); + const int pdgCasc = cascMC.pdgCode(); + + const bool isPositiveProton = (pdgPos == PDG_t::kProton); + + const bool isPositivePion = (pdgPos == PDG_t::kPiPlus); + const bool isBachelorPositivePion = (pdgBach == PDG_t::kPiPlus); + + const bool isNegativeProton = (pdgNeg == kProtonBar); + + const bool isNegativePion = (pdgNeg == PDG_t::kPiMinus); + const bool isBachelorNegativePion = (pdgBach == PDG_t::kPiMinus); + + const bool isBachelorPositiveKaon = (pdgBach == PDG_t::kKPlus); + const bool isBachelorNegativeKaon = (pdgBach == PDG_t::kKMinus); + + // Fill histograms + if ((pdgCasc == PDG_t::kXiMinus) && isPositiveProton && isNegativePion && isBachelorNegativePion) { + histos.fill(HIST(kParticlenames[3]) + HIST("/mc/h7dGen"), ft0ampl, nTracksGlobal, mcCollision.multMCNParticlesEta08(), pTmc, static_cast(upcCuts.genGapSide), ymc, mcCollision.generatorsID()); + } + if ((pdgCasc == PDG_t::kXiPlusBar) && isNegativeProton && isPositivePion && isBachelorPositivePion) { + histos.fill(HIST(kParticlenames[4]) + HIST("/mc/h7dGen"), ft0ampl, nTracksGlobal, mcCollision.multMCNParticlesEta08(), pTmc, static_cast(upcCuts.genGapSide), ymc, mcCollision.generatorsID()); + } + if ((pdgCasc == PDG_t::kOmegaMinus) && isPositiveProton && isNegativePion && isBachelorNegativeKaon) { + histos.fill(HIST(kParticlenames[5]) + HIST("/mc/h7dGen"), ft0ampl, nTracksGlobal, mcCollision.multMCNParticlesEta08(), pTmc, static_cast(upcCuts.genGapSide), ymc, mcCollision.generatorsID()); + } + if ((pdgCasc == PDG_t::kOmegaPlusBar) && isNegativeProton && isPositivePion && isBachelorPositiveKaon) { + histos.fill(HIST(kParticlenames[6]) + HIST("/mc/h7dGen"), ft0ampl, nTracksGlobal, mcCollision.multMCNParticlesEta08(), pTmc, static_cast(upcCuts.genGapSide), ymc, mcCollision.generatorsID()); + } + } // Cascade end + } + + PROCESS_SWITCH(Derivedupcanalysis, processV0s, "Process V0s", true); + PROCESS_SWITCH(Derivedupcanalysis, processV0sMC, "Process V0s MC", false); + PROCESS_SWITCH(Derivedupcanalysis, processCascades, "Process Cascades", false); + PROCESS_SWITCH(Derivedupcanalysis, processCascadesMC, "Process Cascades MC", false); + PROCESS_SWITCH(Derivedupcanalysis, processGenerated, "Process Generated Level", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Strangeness/hStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/hStrangeCorrelation.cxx index 0126854b3b5..09dbb89bb22 100644 --- a/PWGLF/Tasks/Strangeness/hStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/hStrangeCorrelation.cxx @@ -8,7 +8,8 @@ // 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. -/// +// +/// \file hStrangeCorrelation.cxx /// \brief This task serves to do hadron-(strange hadron) correlation studies. /// The yield will be calculated using the two-particle correlation method. /// Trigger particle : Hadrons @@ -20,38 +21,39 @@ /// \author David Dobrigkeit Chinellato (david.dobrigkeit.chinellato@cern.ch) /// \author Zhongbao Yin (Zhong-Bao.Yin@cern.ch) -#include -#include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" #include "PWGLF/DataModel/LFHStrangeCorrelationTables.h" + +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisTask.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" #include "Framework/StaticFor.h" -#include "CCDB/BasicCCDBManager.h" +#include "Framework/runDataProcessing.h" -#include "EventFiltering/Zorro.h" -#include "EventFiltering/ZorroSummary.h" +#include + +#include +#include using namespace o2; using namespace o2::constants::math; using namespace o2::framework; using namespace o2::framework::expressions; -// simple checkers -#define bitset(var, nbit) ((var) |= (1 << (nbit))) -#define bitcheck(var, nbit) ((var) & (1 << (nbit))) - using TracksComplete = soa::Join; using V0DatasWithoutTrackX = soa::Join; +using V0DatasWithoutTrackXMC = soa::Join; -struct correlateStrangeness { +struct HStrangeCorrelation { // for efficiency corrections if requested Service ccdb; @@ -65,6 +67,8 @@ struct correlateStrangeness { Zorro zorro; OutputObj zorroSummary{"zorroSummary"}; + // master analysis switches + Configurable doPPAnalysis{"doPPAnalysis", true, "if in pp, set to true"}; Configurable doCorrelationHadron{"doCorrelationHadron", false, "do Hadron correlation"}; Configurable doCorrelationK0Short{"doCorrelationK0Short", true, "do K0Short correlation"}; Configurable doCorrelationLambda{"doCorrelationLambda", false, "do Lambda correlation"}; @@ -77,21 +81,32 @@ struct correlateStrangeness { Configurable doGenEventSelection{"doGenEventSelection", true, "use event selections when performing closure test for the gen events"}; Configurable selectINELgtZERO{"selectINELgtZERO", true, "select INEL>0 events"}; Configurable zVertexCut{"zVertexCut", 10, "Cut on PV position"}; + Configurable requireAllGoodITSLayers{"requireAllGoodITSLayers", false, " require that in the event all ITS are good"}; Configurable skipUnderOverflowInTHn{"skipUnderOverflowInTHn", false, "skip under/overflow in THns"}; Configurable mixingParameter{"mixingParameter", 10, "how many events are mixed"}; Configurable doMCassociation{"doMCassociation", false, "fill everything only for MC associated"}; Configurable doTriggPhysicalPrimary{"doTriggPhysicalPrimary", false, "require physical primary for trigger particles"}; Configurable doAssocPhysicalPrimary{"doAssocPhysicalPrimary", false, "require physical primary for associated particles"}; + Configurable doAssocPhysicalPrimaryInGen{"doAssocPhysicalPrimaryInGen", false, "require physical primary for associated particles in Generated Partilces"}; Configurable doLambdaPrimary{"doLambdaPrimary", false, "do primary selection for lambda"}; Configurable doAutocorrelationRejection{"doAutocorrelationRejection", true, "reject pairs where trigger Id is the same as daughter particle Id"}; + Configurable doMixingQAandEventQA{"doMixingQAandEventQA", true, "if true, add EvnetQA and MixingQA hist to histos"}; + Configurable doITSClustersQA{"doITSClustersQA", true, "if true, add ITSCluster hist to histos"}; + Configurable doDeltaPhiStarCheck{"doDeltaPhiStarCheck", false, "if true, create and fill delta phi star histograms"}; Configurable triggerBinToSelect{"triggerBinToSelect", 0, "trigger bin to select on if processSelectEventWithTrigger enabled"}; Configurable triggerParticleCharge{"triggerParticleCharge", 0, "For checks, if 0 all charged tracks, if -1 only neg., if 1 only positive"}; + Configurable etaSel{"etaSel", 0.8, "Selection in eta for trigger and associated particles"}; + Configurable ySel{"ySel", 0.5, "Selection in rapidity for consistency checks"}; + + // used for event selections in Pb-Pb + Configurable cfgCutOccupancyHigh{"cfgCutOccupancyHigh", 3000, "High cut on TPC occupancy"}; + Configurable cfgCutOccupancyLow{"cfgCutOccupancyLow", 0, "Low cut on TPC occupancy"}; // Axes - configurable for smaller sizes ConfigurableAxis axisMult{"axisMult", {VARIABLE_WIDTH, 0.0f, 0.01f, 1.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 70.0f, 100.0f}, "Mixing bins - multiplicity"}; ConfigurableAxis axisVtxZ{"axisVtxZ", {VARIABLE_WIDTH, -10.0f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"}; - ConfigurableAxis axisPhi{"axisPhi", {72, 0, 2 * M_PI}, "#phi"}; + ConfigurableAxis axisPhi{"axisPhi", {72, 0, TwoPI}, "#phi"}; ConfigurableAxis axisEta{"axisEta", {80, -0.8, +0.8}, "#eta"}; ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta #varphi axis for histograms"}; ConfigurableAxis axisDeltaEta{"axisDeltaEta", {50, -1.6, 1.6}, "delta eta axis for histograms"}; @@ -111,7 +126,7 @@ struct correlateStrangeness { // Implementation of on-the-spot efficiency correction Configurable applyEfficiencyCorrection{"applyEfficiencyCorrection", false, "apply efficiency correction"}; Configurable applyEfficiencyForTrigger{"applyEfficiencyForTrigger", false, "apply efficiency correction for the trigger particle"}; - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository to use"}; + Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository to use"}; Configurable efficiencyCCDBPath{"efficiencyCCDBPath", "GLO/Config/GeometryAligned", "Path of the efficiency corrections"}; // Configurables for doing subwagon systematics @@ -122,31 +137,70 @@ struct correlateStrangeness { Configurable minTPCNCrossedRowsTrigger{"minTPCNCrossedRowsTrigger", 70, "Minimum TPC crossed rows (trigger)"}; Configurable minTPCNCrossedRowsAssociated{"minTPCNCrossedRowsAssociated", 70, "Minimum TPC crossed rows (associated)"}; Configurable triggerRequireITS{"triggerRequireITS", true, "require ITS signal in trigger tracks"}; + Configurable assocRequireITS{"assocRequireITS", true, "require ITS signal in associated primary tracks"}; Configurable triggerMaxTPCSharedClusters{"triggerMaxTPCSharedClusters", 200, "maximum number of shared TPC clusters (inclusive)"}; + Configurable assocMaxTPCSharedClusters{"assocMaxTPCSharedClusters", 200, "maximum number of shared TPC clusters (inclusive) for assoc primary tracks"}; Configurable triggerRequireL0{"triggerRequireL0", false, "require ITS L0 cluster for trigger"}; + Configurable assocRequireL0{"assocRequireL0", true, "require ITS L0 cluster for assoc primary track"}; + // Track quality in PbPb + Configurable tpcPidNsigmaCut{"tpcPidNsigmaCut", 5, "tpcPidNsigmaCut"}; // --- Trigger: DCA variation from basic formula: |DCAxy| < 0.004f + (0.013f / pt) Configurable dcaXYconstant{"dcaXYconstant", 0.004, "[0] in |DCAxy| < [0]+[1]/pT"}; Configurable dcaXYpTdep{"dcaXYpTdep", 0.013, "[1] in |DCAxy| < [0]+[1]/pT"}; + Configurable dcaXYconstantAssoc{"dcaXYconstantAssoc", 0.004, "[0] in |DCAxy| < [0]+[1]/pT"}; + Configurable dcaXYpTdepAssoc{"dcaXYpTdepAssoc", 0.013, "[1] in |DCAxy| < [0]+[1]/pT"}; + // --- Associated: topological variable variation (OK to vary all-at-once, at least for first study) Configurable v0cospa{"v0cospa", 0.97, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0) - Configurable dcaV0dau{"dcav0dau", 1.0, "DCA V0 Daughters"}; + Configurable dcaV0dau{"dcaV0dau", 1.0, "DCA V0 Daughters"}; Configurable dcanegtopv{"dcanegtopv", 0.06, "DCA Neg To PV"}; Configurable dcapostopv{"dcapostopv", 0.06, "DCA Pos To PV"}; - Configurable v0RadiusMin{"v0radiusmin", 0.5, "v0radius"}; - Configurable v0RadiusMax{"v0radiusmax", 200, "v0radius"}; + Configurable v0RadiusMin{"v0RadiusMin", 0.5, "v0radius"}; + Configurable v0RadiusMax{"v0RadiusMax", 200, "v0radius"}; + // more V0 selections in PbPb + Configurable lifetimecutK0S{"lifetimecutK0S", 20, "lifetimecutK0S"}; + Configurable lifetimecutLambda{"lifetimecutLambda", 30, "lifetimecutLambda"}; + Configurable dcanegtopvK0S{"dcanegtopvK0S", 0.1, "DCA Neg To PV"}; + Configurable dcapostopvK0S{"dcapostopvK0S", 0.1, "DCA Pos To PV"}; + Configurable dcanegtopvLambda{"dcanegtopvLambda", 0.05, "DCA Neg To PV"}; + Configurable dcapostopvLambda{"dcapostopvLambda", 0.2, "DCA Pos To PV"}; + Configurable dcanegtopvAntiLambda{"dcanegtopvAntiLambda", 0.2, "DCA Neg To PV"}; + Configurable dcapostopvAntiLambda{"dcapostopvAntiLambda", 0.05, "DCA Pos To PV"}; + // original equation: lArmPt*2>TMath::Abs(lArmAlpha) only for K0S + Configurable armPodCut{"armPodCut", 5.0f, "pT * (cut) > |alpha|, AP cut. Negative: no cut"}; // cascade selections - Configurable casc_cospa{"casc_cospa", 0.95, "casc_cospa"}; - Configurable casc_dcacascdau{"casc_dcacascdau", 1.0, "casc_dcacascdau"}; - Configurable casc_dcabachtopv{"casc_dcabachtopv", 0.1, "casc_dcabachtopv"}; - Configurable casc_cascradius{"casc_cascradius", 0.5, "casc_cascradius"}; - Configurable casc_v0masswindow{"casc_v0masswindow", 0.01, "casc_v0masswindow"}; - Configurable casc_mindcav0topv{"casc_mindcav0topv", 0.01, "casc_mindcav0topv"}; + Configurable cascCospa{"cascCospa", 0.95, "cascCospa"}; + Configurable cascDcacascdau{"cascDcacascdau", 1.0, "cascDcacascdau"}; + Configurable cascDcabachtopv{"cascDcabachtopv", 0.1, "cascDcabachtopv"}; + Configurable cascRadius{"cascRadius", 0.5, "cascRadius"}; + Configurable cascV0masswindow{"cascV0masswindow", 0.01, "cascV0masswindow"}; + Configurable cascMindcav0topv{"cascMindcav0topv", 0.01, "cascMindcav0topv"}; + // more cascade selections in PbPb + Configurable bachBaryonCosPA{"bachBaryonCosPA", 0.9999, "Bachelor baryon CosPA"}; + Configurable bachBaryonDCAxyToPV{"bachBaryonDCAxyToPV", 0.08, "DCA bachelor baryon to PV"}; + Configurable dcaBaryonToPV{"dcaBaryonToPV", 0.05, "DCA of baryon doughter track To PV"}; + Configurable dcaMesonToPV{"dcaMesonToPV", 0.1, "DCA of meson doughter track To PV"}; + Configurable dcaBachToPV{"dcaBachToPV", 0.07, "DCA Bach To PV"}; + Configurable cascdcaV0dau{"cascdcaV0dau", 0.5, "DCA V0 Daughters"}; + Configurable dcaCacsDauPar0{"dcaCacsDauPar0", 0.8, " par for pt dep DCA cascade daughter cut, p_T < 1 GeV/c"}; + Configurable dcaCacsDauPar1{"dcaCacsDauPar1", 0.5, " par for pt dep DCA cascade daughter cut, 1< p_T < 4 GeV/c"}; + Configurable dcaCacsDauPar2{"dcaCacsDauPar2", 0.2, " par for pt dep DCA cascade daughter cut, p_T > 4 GeV/c"}; + Configurable cascdcaV0ToPV{"cascdcaV0ToPV", 0.06, "DCA V0 To PV"}; + Configurable cascv0cospa{"cascv0cospa", 0.98, "V0 CosPA"}; + Configurable cascv0RadiusMin{"cascv0RadiusMin", 2.5, "v0radius"}; + Configurable proplifetime{"proplifetime", 3, "ctau/"}; + Configurable lambdaMassWin{"lambdaMassWin", 0.005, "V0 Mass window limit"}; + Configurable rejcomp{"rejcomp", 0.008, "Competing Cascade rejection"}; + Configurable rapCut{"rapCut", 0.8, "Rapidity acceptance"}; // dE/dx for associated daughters - Configurable dEdxCompatibility{"dEdxCompatibility", 1, "0: loose, 1: normal, 2: tight. Defined in hStrangeCorrelationFilter"}; + Configurable dEdxCompatibility{"dEdxCompatibility", 1, "0: loose, 1: normal, 2: tight. Defined in HStrangeCorrelationFilter"}; + + // on the fly correction instead of mixingParameter + Configurable doOnTheFlyFlattening{"doOnTheFlyFlattening", 0, "enable an on-the-fly correction instead of using mixing"}; // (N.B.: sources that can be investigated in post are not listed!) } systCuts; @@ -161,10 +215,12 @@ struct correlateStrangeness { TH2F* hEfficiencyXiPlus; TH2F* hEfficiencyOmegaMinus; TH2F* hEfficiencyOmegaPlus; - TH2F* hEfficiencyHadron; + TH1F* hPurityHadron; using BinningType = ColumnBinningPolicy; + using BinningTypePbPb = ColumnBinningPolicy; + // std::variant colBinning; BinningType colBinning{{axisVtxZ, axisMult}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. // collision slicing for mixed events @@ -175,10 +231,10 @@ struct correlateStrangeness { Preslice collisionSliceHadrons = aod::assocHadrons::collisionId; Preslice perCollision = aod::mcparticle::mcCollisionId; - static constexpr std::string_view v0names[] = {"K0Short", "Lambda", "AntiLambda"}; - static constexpr std::string_view cascadenames[] = {"XiMinus", "XiPlus", "OmegaMinus", "OmegaPlus"}; - static constexpr std::string_view particlenames[] = {"K0Short", "Lambda", "AntiLambda", "XiMinus", "XiPlus", "OmegaMinus", "OmegaPlus", "Pion", "Hadron"}; - static constexpr int pdgCodes[] = {310, 3122, -3122, 3312, -3312, 3334, -3334, 211}; + static constexpr std::string_view kV0names[] = {"K0Short", "Lambda", "AntiLambda"}; + static constexpr std::string_view kCascadenames[] = {"XiMinus", "XiPlus", "OmegaMinus", "OmegaPlus"}; + static constexpr std::string_view kParticlenames[] = {"K0Short", "Lambda", "AntiLambda", "XiMinus", "XiPlus", "OmegaMinus", "OmegaPlus", "Pion", "Hadron"}; + static constexpr int kPdgCodes[] = {310, 3122, -3122, 3312, -3312, 3334, -3334, 211}; uint16_t doCorrelation; int mRunNumber; @@ -186,19 +242,17 @@ struct correlateStrangeness { std::vector> axisRanges; + const float ctauxiPDG = 4.91; // from PDG + const float ctauomegaPDG = 2.461; // from PDG + /// Function to aid in calculating delta-phi /// \param phi1 first phi value /// \param phi2 second phi value - Double_t ComputeDeltaPhi(Double_t phi1, Double_t phi2) + double computeDeltaPhi(double phi1, double phi2) { - Double_t deltaPhi = phi1 - phi2; - if (deltaPhi < -TMath::Pi() / 2.) { - deltaPhi += 2. * TMath::Pi(); - } - if (deltaPhi > 3 * TMath::Pi() / 2.) { - deltaPhi -= 2. * TMath::Pi(); - } - return deltaPhi; + double deltaPhi = phi1 - phi2; + double shiftedDeltaPhi = RecoDecay::constrainAngle(deltaPhi, -PIHalf); + return shiftedDeltaPhi; } /// Function to load zorro @@ -240,8 +294,116 @@ struct correlateStrangeness { hEfficiencyXiPlus = static_cast(listEfficiencies->FindObject("hEfficiencyXiPlus")); hEfficiencyOmegaMinus = static_cast(listEfficiencies->FindObject("hEfficiencyOmegaMinus")); hEfficiencyOmegaPlus = static_cast(listEfficiencies->FindObject("hEfficiencyOmegaPlus")); + hEfficiencyHadron = static_cast(listEfficiencies->FindObject("hEfficiencyHadron")); + hEfficiencyPion = static_cast(listEfficiencies->FindObject("hEfficiencyPion")); + hPurityHadron = static_cast(listEfficiencies->FindObject("hPurityHadron")); LOG(info) << "Efficiencies now loaded for " << mRunNumber; } + + template + uint64_t V0selectionBitmap(TV0 v0, float pvx, float pvy, float pvz) + // precalculate this information so that a check is one mask operation, not many + { + uint64_t bitMap = 0; + // proper lifetime , DCA daughter to prim.vtx + if (doCorrelationK0Short) { + // proper lifetime + if (v0.distovertotmom(pvx, pvy, pvz) * o2::constants::physics::MassK0Short < systCuts.lifetimecutK0S) + SETBIT(bitMap, 0); + // DCA daughter to prim.vtx and armenteros + if (std::abs(v0.dcapostopv()) > systCuts.dcapostopvK0S && std::abs(v0.dcanegtopv()) > systCuts.dcanegtopvK0S && v0.qtarm() * systCuts.armPodCut > std::abs(v0.alpha())) + SETBIT(bitMap, 3); + } + if (doCorrelationLambda) { + // proper lifetime + if (v0.distovertotmom(pvx, pvy, pvz) * o2::constants::physics::MassLambda0 < systCuts.lifetimecutLambda) + SETBIT(bitMap, 1); + // DCA daughter to prim.vtx + if (std::abs(v0.dcapostopv()) > systCuts.dcapostopvLambda && std::abs(v0.dcanegtopv()) > systCuts.dcanegtopvLambda) + SETBIT(bitMap, 4); + } + if (doCorrelationAntiLambda) { + // proper lifetime + if (v0.distovertotmom(pvx, pvy, pvz) * o2::constants::physics::MassLambda0 < systCuts.lifetimecutLambda) + SETBIT(bitMap, 2); + // DCA daughter to prim.vtx + if (std::abs(v0.dcapostopv()) > systCuts.dcapostopvAntiLambda && std::abs(v0.dcanegtopv()) > systCuts.dcanegtopvAntiLambda) + SETBIT(bitMap, 5); + } + return bitMap; + } + + template + uint64_t CascadeselectionBitmap(TCascade casc, float pvx, float pvy, float pvz) + { + uint64_t bitMap = 0; + float cascpos = std::hypot(casc.x() - pvx, casc.y() - pvy, casc.z() - pvz); + float cascptotmom = std::hypot(casc.px(), casc.py(), casc.pz()); + float ctauXi = o2::constants::physics::MassXiMinus * cascpos / ((cascptotmom + 1e-13) * ctauxiPDG); + float ctauOmega = o2::constants::physics::MassOmegaMinus * cascpos / ((cascptotmom + 1e-13) * ctauomegaPDG); + // TPC PID and DCA daughter to prim.vtx and comopeting casc.rej and life time + if (doCorrelationXiMinus) { + // DCA daughter to prim.vtx + if (std::abs(casc.dcabachtopv()) > systCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > systCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > systCuts.dcaMesonToPV) + SETBIT(bitMap, 0); + // comopeting casc.rej + if (std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > systCuts.rejcomp) + SETBIT(bitMap, 4); + if (ctauXi < systCuts.proplifetime) + SETBIT(bitMap, 8); + // y cut + if (std::abs(casc.yXi()) < systCuts.rapCut) + SETBIT(bitMap, 12); + } + if (doCorrelationXiPlus) { + // DCA daughter to prim.vtx + if (std::abs(casc.dcabachtopv()) > systCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > systCuts.dcaMesonToPV && + std::abs(casc.dcanegtopv()) > systCuts.dcaBaryonToPV) + SETBIT(bitMap, 1); + // comopeting casc.rej + if (std::abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > systCuts.rejcomp) + SETBIT(bitMap, 5); + // life time + if (ctauXi < systCuts.proplifetime) + SETBIT(bitMap, 9); + // y cut + if (std::abs(casc.yXi()) > systCuts.rapCut) + SETBIT(bitMap, 13); + } + if (doCorrelationOmegaMinus) { + // DCA daughter to prim.vtx + if (std::abs(casc.dcabachtopv()) > systCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > systCuts.dcaBaryonToPV && + std::abs(casc.dcanegtopv()) > systCuts.dcaMesonToPV) + SETBIT(bitMap, 2); + // comopeting casc.rej + if (std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > systCuts.rejcomp) + SETBIT(bitMap, 6); + // life time + if (ctauOmega < systCuts.proplifetime) + SETBIT(bitMap, 10); + // y cut + if (std::abs(casc.yOmega()) < systCuts.rapCut) + SETBIT(bitMap, 14); + } + if (doCorrelationOmegaPlus) { + // DCA daughter to prim.vtx + if (std::abs(casc.dcabachtopv()) > systCuts.dcaBachToPV && std::abs(casc.dcapostopv()) > systCuts.dcaMesonToPV && + std::abs(casc.dcanegtopv()) > systCuts.dcaBaryonToPV) + SETBIT(bitMap, 3); + // comopeting casc.rej + if (std::abs(casc.mXi() - o2::constants::physics::MassXiMinus) > systCuts.rejcomp) + SETBIT(bitMap, 7); + // life time + if (ctauOmega < systCuts.proplifetime) + SETBIT(bitMap, 11); + // y cut + if (std::abs(casc.yOmega()) > systCuts.rapCut) + SETBIT(bitMap, 15); + } + return bitMap; + } + template bool isValidTrigger(TTrack track) { @@ -254,7 +416,7 @@ struct correlateStrangeness { if (track.tpcNClsShared() > systCuts.triggerMaxTPCSharedClusters) { return false; // skip, has shared clusters } - if (!(bitcheck(track.itsClusterMap(), 0)) && systCuts.triggerRequireL0) { + if (!(TESTBIT(track.itsClusterMap(), 0)) && systCuts.triggerRequireL0) { return false; // skip, doesn't have cluster in ITS L0 } // systematic variations: trigger DCAxy @@ -272,9 +434,108 @@ struct correlateStrangeness { } return true; } - void fillCorrelationsV0(aod::TriggerTracks const& triggers, aod::AssocV0s const& assocs, bool mixing, float pvz, float mult) + template + bool isValidAssocHadron(TTrack track) + { + if (track.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated) { + return false; // crossed rows + } + if (!track.hasITS() && systCuts.assocRequireITS) { + return false; // skip, doesn't have ITS signal (skips lots of TPC-only!) + } + if (track.tpcNClsShared() > systCuts.assocMaxTPCSharedClusters) { + return false; // skip, has shared clusters + } + if (!(TESTBIT(track.itsClusterMap(), 0)) && systCuts.assocRequireL0) { + return false; // skip, doesn't have cluster in ITS L0 + } + // systematic variations: trigger DCAxy + if (std::abs(track.dcaXY()) > systCuts.dcaXYconstantAssoc + systCuts.dcaXYpTdepAssoc * std::abs(track.signed1Pt())) { + return false; + } + if (track.pt() > axisRanges[2][1] || track.pt() < axisRanges[2][0]) { + return false; + } + return true; + } + // V0selection in PbPb + template + bool V0SelectedPbPb(TV0 v0) + { + // v0radius + if (v0.v0radius() < systCuts.v0RadiusMin) + return false; + if (v0.v0radius() > systCuts.v0RadiusMax) + return false; + // v0cosPA + if (v0.v0cosPA() < systCuts.v0cospa) + return false; + // dcaV0daughters + if (v0.dcaV0daughters() > systCuts.dcaV0dau) + return false; + return true; + } + + // cascadeselection in PbPb + template + bool CascadeSelectedPbPb(TCascade casc, float pvx, float pvy, float pvz) + { + // bachBaryonCosPA + if (casc.bachBaryonCosPA() < systCuts.bachBaryonCosPA) + return false; + // bachBaryonDCAxyToPV + if (std::abs(casc.bachBaryonDCAxyToPV()) > systCuts.bachBaryonDCAxyToPV) + return false; + // casccosPA + if (casc.casccosPA(pvx, pvy, pvz) < systCuts.cascCospa) + return false; + // dcacascdaughters + float ptDepCut = systCuts.dcaCacsDauPar0; + if (casc.pt() > 1 && casc.pt() < 4) + ptDepCut = systCuts.dcaCacsDauPar1; + else if (casc.pt() > 4) + ptDepCut = systCuts.dcaCacsDauPar2; + if (casc.dcacascdaughters() > ptDepCut) + return false; + // dcaV0daughters + if (casc.dcaV0daughters() > systCuts.dcaV0dau) + return false; + // dcav0topv + if (std::abs(casc.dcav0topv(pvx, pvy, pvz)) < systCuts.cascdcaV0ToPV) + return false; + // cascradius + if (casc.cascradius() < systCuts.cascRadius) + return false; + // v0radius + if (casc.v0radius() < systCuts.cascv0RadiusMin) + return false; + // v0cosPA + if (casc.v0cosPA(casc.x(), casc.y(), casc.z()) < systCuts.cascv0cospa) + return false; + // lambdaMassWin + if (std::abs(casc.mLambda() - o2::constants::physics::MassLambda0) > systCuts.lambdaMassWin) + return false; + return true; + } + double calculateAverageDeltaPhiStar(double* trigg, double* assoc, double B) { - for (auto& triggerTrack : triggers) { + double dPhiStar = 0; + double dPhiStarMean = 0; + + double dPhi = assoc[0] - trigg[0]; + double phaseProton = (-0.3 * B * assoc[2]) / (2 * assoc[1]); + double phaseTrack = (-0.3 * B * trigg[2]) / (2 * trigg[1]); + + for (double r = 0.8; r <= 2.5; r += 0.05) { + dPhiStar = dPhi + std::asin(phaseProton * r) - std::asin(phaseTrack * r); + dPhiStarMean += (dPhiStar / 34); + } + + return dPhiStarMean; + } + void fillCorrelationsV0(aod::TriggerTracks const& triggers, aod::AssocV0s const& assocs, bool mixing, float pvx, float pvy, float pvz, float mult, double bField) + { + for (auto const& triggerTrack : triggers) { if (doTriggPhysicalPrimary && !triggerTrack.mcPhysicalPrimary()) continue; auto trigg = triggerTrack.track_as(); @@ -285,20 +546,31 @@ struct correlateStrangeness { float efficiency = 1.0f; if (applyEfficiencyForTrigger) { efficiency = hEfficiencyTrigger->Interpolate(trigg.pt(), trigg.eta()); + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; + } } float weight = (applyEfficiencyForTrigger) ? 1. / efficiency : 1.0f; histos.fill(HIST("sameEvent/TriggerParticlesV0"), trigg.pt(), mult, weight); } - for (auto& assocCandidate : assocs) { + double triggSign = trigg.sign(); + double triggForDeltaPhiStar[] = {trigg.phi(), trigg.pt(), triggSign}; + + for (auto const& assocCandidate : assocs) { auto assoc = assocCandidate.v0Core_as(); //---] syst cuts [--- - if (assoc.v0radius() < systCuts.v0RadiusMin || assoc.v0radius() > systCuts.v0RadiusMax || - std::abs(assoc.dcapostopv()) < systCuts.dcapostopv || std::abs(assoc.dcanegtopv()) < systCuts.dcanegtopv || - assoc.v0cosPA() < systCuts.v0cospa || assoc.dcaV0daughters() > systCuts.dcaV0dau) + if ((doPPAnalysis && (assoc.v0radius() < systCuts.v0RadiusMin || assoc.v0radius() > systCuts.v0RadiusMax || + std::abs(assoc.dcapostopv()) < systCuts.dcapostopv || std::abs(assoc.dcanegtopv()) < systCuts.dcanegtopv || + assoc.v0cosPA() < systCuts.v0cospa || assoc.dcaV0daughters() > systCuts.dcaV0dau))) continue; + if (!doPPAnalysis && !V0SelectedPbPb(assoc)) + continue; + + uint64_t selMap = V0selectionBitmap(assoc, pvx, pvy, pvz); + //---] removing autocorrelations [--- auto postrack = assoc.posTrack_as(); auto negtrack = assoc.negTrack_as(); @@ -317,7 +589,7 @@ struct correlateStrangeness { if (postrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated || negtrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated) continue; - float deltaphi = ComputeDeltaPhi(trigg.phi(), assoc.phi()); + float deltaphi = computeDeltaPhi(trigg.phi(), assoc.phi()); float deltaeta = trigg.eta() - assoc.eta(); float ptassoc = assoc.pt(); float pttrigger = trigg.pt(); @@ -334,48 +606,122 @@ struct correlateStrangeness { hEfficiencyV0[0] = hEfficiencyK0Short; hEfficiencyV0[1] = hEfficiencyLambda; hEfficiencyV0[2] = hEfficiencyAntiLambda; + + float etaWeight = 1; + if (systCuts.doOnTheFlyFlattening) { + float preWeight = 1 - std::abs(deltaeta) / 1.6; + etaWeight = preWeight != 0 ? 1.0f / preWeight : 1.0f; + } + + double phiProton = postrack.phi(); // in Case of K0, both are pions, but the one in proton tagged is the positive one + double phiPion = negtrack.phi(); + double etaProton = postrack.eta(); + double etaPion = negtrack.eta(); + double ptProton = postrack.pt(); + double ptPion = negtrack.pt(); + double signProton = postrack.sign(); + if (assocCandidate.compatible(2, systCuts.dEdxCompatibility)) { + phiProton = negtrack.phi(); + etaProton = negtrack.eta(); + ptProton = negtrack.pt(); + signProton = negtrack.sign(); + } + double assocForDeltaPhiStar[] = {phiProton, ptProton, signProton}; + double assocForDeltaPhiStarPion[] = {phiPion, ptPion, -1}; + static_for<0, 2>([&](auto i) { - constexpr int index = i.value; + constexpr int Index = i.value; float efficiency = 1.0f; if (applyEfficiencyCorrection) { - efficiency = hEfficiencyV0[index]->Interpolate(ptassoc, assoc.eta()); + efficiency = hEfficiencyV0[Index]->Interpolate(ptassoc, assoc.eta()); } if (applyEfficiencyForTrigger) { efficiency = efficiency * hEfficiencyTrigger->Interpolate(pttrigger, trigg.eta()); } + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; + } float weight = (applyEfficiencyCorrection || applyEfficiencyForTrigger) ? 1. / efficiency : 1.0f; - if (bitcheck(doCorrelation, index) && (!applyEfficiencyCorrection || efficiency != 0)) { - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && -massWindowConfigurations.maxBgNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < -massWindowConfigurations.minBgNSigma) - histos.fill(HIST("sameEvent/LeftBg/") + HIST(v0names[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && -massWindowConfigurations.maxPeakNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < +massWindowConfigurations.maxPeakNSigma) { - histos.fill(HIST("sameEvent/Signal/") + HIST(v0names[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (std::abs(deltaphi) < 0.8) { - histos.fill(HIST("hITSClusters") + HIST(v0names[index]) + HIST("NegativeDaughterToward"), ptassoc, negtrack.itsNCls(), assoc.v0radius()); - histos.fill(HIST("hITSClusters") + HIST(v0names[index]) + HIST("PositiveDaughterToward"), ptassoc, postrack.itsNCls(), assoc.v0radius()); + weight = weight * etaWeight; + if (TESTBIT(doCorrelation, Index) && (!applyEfficiencyCorrection || efficiency != 0) && (doPPAnalysis || (TESTBIT(selMap, Index) && TESTBIT(selMap, Index + 3)))) { + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && -massWindowConfigurations.maxBgNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < -massWindowConfigurations.minBgNSigma) { + histos.fill(HIST("sameEvent/LeftBg/") + HIST(kV0names[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (doDeltaPhiStarCheck) { + double deltaPhiStar = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStar, bField); + double deltaPhiStarPion = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStarPion, bField); + if ((Index == 0 && triggSign > 0) || (Index == 1 && triggSign > 0) || (Index == 2 && triggSign < 0)) { + histos.fill(HIST("sameEvent/LeftBg/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, 0.5); + if (Index == 0) { + histos.fill(HIST("sameEvent/LeftBg/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStarPion, trigg.eta() - etaPion, -0.5); + } + } else { + histos.fill(HIST("sameEvent/LeftBg/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, -0.5); + if (Index == 0) { + histos.fill(HIST("sameEvent/LeftBg/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStarPion, trigg.eta() - etaPion, 0.5); + } + } + } + } + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && -massWindowConfigurations.maxPeakNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < +massWindowConfigurations.maxPeakNSigma) { + histos.fill(HIST("sameEvent/Signal/") + HIST(kV0names[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (std::abs(deltaphi) < 0.8 && doITSClustersQA) { + histos.fill(HIST("hITSClusters") + HIST(kV0names[Index]) + HIST("NegativeDaughterToward"), ptassoc, negtrack.itsNCls(), assoc.v0radius()); + histos.fill(HIST("hITSClusters") + HIST(kV0names[Index]) + HIST("PositiveDaughterToward"), ptassoc, postrack.itsNCls(), assoc.v0radius()); + } + if (std::abs(deltaphi) > 1 && std::abs(deltaphi) < 2 && doITSClustersQA) { + histos.fill(HIST("hITSClusters") + HIST(kV0names[Index]) + HIST("NegativeDaughterTransverse"), ptassoc, negtrack.itsNCls(), assoc.v0radius()); + histos.fill(HIST("hITSClusters") + HIST(kV0names[Index]) + HIST("PositiveDaughterTransverse"), ptassoc, postrack.itsNCls(), assoc.v0radius()); } - if (std::abs(deltaphi) > 1 && std::abs(deltaphi) < 2) { - histos.fill(HIST("hITSClusters") + HIST(v0names[index]) + HIST("NegativeDaughterTransverse"), ptassoc, negtrack.itsNCls(), assoc.v0radius()); - histos.fill(HIST("hITSClusters") + HIST(v0names[index]) + HIST("PositiveDaughterTransverse"), ptassoc, postrack.itsNCls(), assoc.v0radius()); + if (doDeltaPhiStarCheck) { + double deltaPhiStar = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStar, bField); + double deltaPhiStarPion = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStarPion, bField); + if ((Index == 0 && triggSign > 0) || (Index == 1 && triggSign > 0) || (Index == 2 && triggSign < 0)) { + histos.fill(HIST("sameEvent/Signal/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, 0.5); + if (Index == 0) { + histos.fill(HIST("sameEvent/Signal/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStarPion, trigg.eta() - etaPion, -0.5); + } + } else { + histos.fill(HIST("sameEvent/Signal/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, -0.5); + if (Index == 0) { + histos.fill(HIST("sameEvent/Signal/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStarPion, trigg.eta() - etaPion, 0.5); + } + } } } - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && +massWindowConfigurations.minBgNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < +massWindowConfigurations.maxBgNSigma) - histos.fill(HIST("sameEvent/RightBg/") + HIST(v0names[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && -massWindowConfigurations.maxBgNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < -massWindowConfigurations.minBgNSigma) - histos.fill(HIST("mixedEvent/LeftBg/") + HIST(v0names[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && -massWindowConfigurations.maxPeakNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < +massWindowConfigurations.maxPeakNSigma) - histos.fill(HIST("mixedEvent/Signal/") + HIST(v0names[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && +massWindowConfigurations.minBgNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < +massWindowConfigurations.maxBgNSigma) - histos.fill(HIST("mixedEvent/RightBg/") + HIST(v0names[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && +massWindowConfigurations.minBgNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < +massWindowConfigurations.maxBgNSigma) { + histos.fill(HIST("sameEvent/RightBg/") + HIST(kV0names[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (doDeltaPhiStarCheck) { + double deltaPhiStar = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStar, bField); + double deltaPhiStarPion = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStarPion, bField); + if ((Index == 0 && triggSign > 0) || (Index == 1 && triggSign > 0) || (Index == 2 && triggSign < 0)) { + histos.fill(HIST("sameEvent/RightBg/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, 0.5); + if (Index == 0) { + histos.fill(HIST("sameEvent/RightBg/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStarPion, trigg.eta() - etaPion, -0.5); + } + } else { + histos.fill(HIST("sameEvent/RightBg/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, -0.5); + if (Index == 0) { + histos.fill(HIST("sameEvent/RightBg/") + HIST(kV0names[Index]) + HIST("DeltaPhiStar"), deltaPhiStarPion, trigg.eta() - etaPion, 0.5); + } + } + } + } + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && -massWindowConfigurations.maxBgNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < -massWindowConfigurations.minBgNSigma) + histos.fill(HIST("mixedEvent/LeftBg/") + HIST(kV0names[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && -massWindowConfigurations.maxPeakNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < +massWindowConfigurations.maxPeakNSigma) + histos.fill(HIST("mixedEvent/Signal/") + HIST(kV0names[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && +massWindowConfigurations.minBgNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < +massWindowConfigurations.maxBgNSigma) + histos.fill(HIST("mixedEvent/RightBg/") + HIST(kV0names[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); } }); } } } - void fillCorrelationsCascade(aod::TriggerTracks const& triggers, aod::AssocCascades const& assocs, bool mixing, float pvx, float pvy, float pvz, float mult) + void fillCorrelationsCascade(aod::TriggerTracks const& triggers, aod::AssocCascades const& assocs, bool mixing, float pvx, float pvy, float pvz, float mult, double bField) { - for (auto& triggerTrack : triggers) { + for (auto const& triggerTrack : triggers) { if (doTriggPhysicalPrimary && !triggerTrack.mcPhysicalPrimary()) continue; auto trigg = triggerTrack.track_as(); @@ -386,26 +732,34 @@ struct correlateStrangeness { float efficiency = 1.0f; if (applyEfficiencyForTrigger) { efficiency = hEfficiencyTrigger->Interpolate(trigg.pt(), trigg.eta()); + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; + } } float weight = (applyEfficiencyForTrigger) ? 1. / efficiency : 1.0f; histos.fill(HIST("sameEvent/TriggerParticlesCascade"), trigg.pt(), mult, weight); } - for (auto& assocCandidate : assocs) { + double triggSign = trigg.sign(); + double triggForDeltaPhiStar[] = {trigg.phi(), trigg.pt(), triggSign}; + + for (auto const& assocCandidate : assocs) { auto assoc = assocCandidate.cascData(); //---] syst cuts [--- - if (std::abs(assoc.dcapostopv()) < systCuts.dcapostopv || - std::abs(assoc.dcanegtopv()) < systCuts.dcanegtopv || - assoc.dcabachtopv() < systCuts.casc_dcabachtopv || - assoc.dcaV0daughters() > systCuts.dcaV0dau || - assoc.dcacascdaughters() > systCuts.casc_dcacascdau || - assoc.v0cosPA(pvx, pvy, pvz) < systCuts.v0cospa || - assoc.casccosPA(pvx, pvy, pvz) < systCuts.casc_cospa || - assoc.cascradius() < systCuts.casc_cascradius || - std::abs(assoc.dcav0topv(pvx, pvy, pvz)) < systCuts.casc_mindcav0topv || - std::abs(assoc.mLambda() - pdgDB->Mass(3122)) > systCuts.casc_v0masswindow) + if (doPPAnalysis && (std::abs(assoc.dcapostopv()) < systCuts.dcapostopv || + std::abs(assoc.dcanegtopv()) < systCuts.dcanegtopv || + assoc.dcabachtopv() < systCuts.cascDcabachtopv || + assoc.dcaV0daughters() > systCuts.dcaV0dau || + assoc.dcacascdaughters() > systCuts.cascDcacascdau || + assoc.v0cosPA(pvx, pvy, pvz) < systCuts.v0cospa || + assoc.casccosPA(pvx, pvy, pvz) < systCuts.cascCospa || + assoc.cascradius() < systCuts.cascRadius || + std::abs(assoc.dcav0topv(pvx, pvy, pvz)) < systCuts.cascMindcav0topv || + std::abs(assoc.mLambda() - o2::constants::physics::MassLambda0) > systCuts.cascV0masswindow)) continue; - + if (!doPPAnalysis && !CascadeSelectedPbPb(assoc, pvx, pvy, pvz)) + continue; + uint64_t CascselMap = CascadeselectionBitmap(assoc, pvx, pvy, pvz); //---] removing autocorrelations [--- auto postrack = assoc.posTrack_as(); auto negtrack = assoc.negTrack_as(); @@ -424,12 +778,22 @@ struct correlateStrangeness { continue; } } - + double phiProton = postrack.phi(); + double etaProton = postrack.eta(); + double ptProton = postrack.pt(); + double signProton = postrack.sign(); + if (assoc.sign() > 0) { + phiProton = negtrack.phi(); + etaProton = negtrack.eta(); + ptProton = negtrack.pt(); + signProton = negtrack.sign(); + } + double assocForDeltaPhiStar[] = {phiProton, ptProton, signProton}; //---] track quality check [--- if (postrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated || negtrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated || bachtrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated) continue; - float deltaphi = ComputeDeltaPhi(trigg.phi(), assoc.phi()); + float deltaphi = computeDeltaPhi(trigg.phi(), assoc.phi()); float deltaeta = trigg.eta() - assoc.eta(); float ptassoc = assoc.pt(); float pttrigger = trigg.pt(); @@ -448,72 +812,128 @@ struct correlateStrangeness { hEfficiencyCascade[2] = hEfficiencyOmegaMinus; hEfficiencyCascade[3] = hEfficiencyOmegaPlus; + float etaWeight = 1; + if (systCuts.doOnTheFlyFlattening) { + float preWeight = 1 - std::abs(deltaeta) / 1.6; + etaWeight = preWeight != 0 ? 1.0f / preWeight : 1.0f; + } + static_for<0, 3>([&](auto i) { - constexpr int index = i.value; + constexpr int Index = i.value; float efficiency = 1.0f; if (applyEfficiencyCorrection) { - efficiency = hEfficiencyCascade[index]->GetBinContent(hEfficiencyCascade[index]->GetXaxis()->FindBin(ptassoc), hEfficiencyCascade[index]->GetYaxis()->FindBin(assoc.eta())); + efficiency = hEfficiencyCascade[Index]->Interpolate(ptassoc, assoc.eta()); } if (applyEfficiencyForTrigger) { efficiency = efficiency * hEfficiencyTrigger->Interpolate(pttrigger, trigg.eta()); } + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; + } float weight = (applyEfficiencyCorrection || applyEfficiencyForTrigger) ? 1. / efficiency : 1.0f; - if (bitcheck(doCorrelation, index + 3) && (!applyEfficiencyCorrection || efficiency != 0)) { - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && -massWindowConfigurations.maxBgNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < -massWindowConfigurations.minBgNSigma) - histos.fill(HIST("sameEvent/LeftBg/") + HIST(cascadenames[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && -massWindowConfigurations.maxPeakNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < +massWindowConfigurations.maxPeakNSigma) - histos.fill(HIST("sameEvent/Signal/") + HIST(cascadenames[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && +massWindowConfigurations.minBgNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < +massWindowConfigurations.maxBgNSigma) - histos.fill(HIST("sameEvent/RightBg/") + HIST(cascadenames[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && -massWindowConfigurations.maxBgNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < -massWindowConfigurations.minBgNSigma) - histos.fill(HIST("mixedEvent/LeftBg/") + HIST(cascadenames[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && -massWindowConfigurations.maxPeakNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < +massWindowConfigurations.maxPeakNSigma) - histos.fill(HIST("mixedEvent/Signal/") + HIST(cascadenames[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); - if (assocCandidate.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && +massWindowConfigurations.minBgNSigma < assocCandidate.invMassNSigma(index) && assocCandidate.invMassNSigma(index) < +massWindowConfigurations.maxBgNSigma) - histos.fill(HIST("mixedEvent/RightBg/") + HIST(cascadenames[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + weight = weight * etaWeight; + if (TESTBIT(doCorrelation, Index + 3) && (!applyEfficiencyCorrection || efficiency != 0) && (doPPAnalysis || (TESTBIT(CascselMap, Index) && TESTBIT(CascselMap, Index + 4) && TESTBIT(CascselMap, Index + 8) && TESTBIT(CascselMap, Index + 12)))) { + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && -massWindowConfigurations.maxBgNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < -massWindowConfigurations.minBgNSigma) { + histos.fill(HIST("sameEvent/LeftBg/") + HIST(kCascadenames[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (doDeltaPhiStarCheck) { + double deltaPhiStar = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStar, bField); + if ((Index == 0 && triggSign > 0) || (Index == 1 && triggSign < 0) || (Index == 2 && triggSign > 0) || (Index == 3 && triggSign < 0)) + histos.fill(HIST("sameEvent/LeftBg/") + HIST(kCascadenames[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, 0.5); + else + histos.fill(HIST("sameEvent/LeftBg/") + HIST(kCascadenames[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, -0.5); + } + } + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && -massWindowConfigurations.maxPeakNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < +massWindowConfigurations.maxPeakNSigma) { + histos.fill(HIST("sameEvent/Signal/") + HIST(kCascadenames[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (doDeltaPhiStarCheck) { + double deltaPhiStar = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStar, bField); + if ((Index == 0 && triggSign > 0) || (Index == 1 && triggSign < 0) || (Index == 2 && triggSign > 0) || (Index == 3 && triggSign < 0)) + histos.fill(HIST("sameEvent/Signal/") + HIST(kCascadenames[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, 0.5); + else + histos.fill(HIST("sameEvent/Signal/") + HIST(kCascadenames[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, -0.5); + } + } + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && !mixing && +massWindowConfigurations.minBgNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < +massWindowConfigurations.maxBgNSigma) { + histos.fill(HIST("sameEvent/RightBg/") + HIST(kCascadenames[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (doDeltaPhiStarCheck) { + double deltaPhiStar = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStar, bField); + if ((Index == 0 && triggSign > 0) || (Index == 1 && triggSign < 0) || (Index == 2 && triggSign > 0) || (Index == 3 && triggSign < 0)) + histos.fill(HIST("sameEvent/RightBg/") + HIST(kCascadenames[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, 0.5); + else + histos.fill(HIST("sameEvent/RightBg/") + HIST(kCascadenames[Index]) + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - etaProton, -0.5); + } + } + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && -massWindowConfigurations.maxBgNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < -massWindowConfigurations.minBgNSigma) + histos.fill(HIST("mixedEvent/LeftBg/") + HIST(kCascadenames[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && -massWindowConfigurations.maxPeakNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < +massWindowConfigurations.maxPeakNSigma) + histos.fill(HIST("mixedEvent/Signal/") + HIST(kCascadenames[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + if (assocCandidate.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || assocCandidate.mcTrue(Index)) && (!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary()) && mixing && +massWindowConfigurations.minBgNSigma < assocCandidate.invMassNSigma(Index) && assocCandidate.invMassNSigma(Index) < +massWindowConfigurations.maxBgNSigma) + histos.fill(HIST("mixedEvent/RightBg/") + HIST(kCascadenames[Index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); } }); } } } - - void fillCorrelationsHadron(aod::TriggerTracks const& triggers, aod::AssocHadrons const& assocs, bool mixing, float pvz, float mult, int /*indexAssoc*/) + template + void fillCorrelationsHadron(TTriggers const& triggers, THadrons const& assocs, bool mixing, float pvz, float mult, double bField) { - for (auto& triggerTrack : triggers) { + for (auto const& triggerTrack : triggers) { if (doTriggPhysicalPrimary && !triggerTrack.mcPhysicalPrimary()) continue; - auto trigg = triggerTrack.track_as(); + auto trigg = triggerTrack.template track_as(); if (!isValidTrigger(trigg)) continue; - static_for<7, 8>([&](auto i) { - constexpr int index = i.value; - if (bitcheck(doCorrelation, i)) { - if (!mixing) - histos.fill(HIST("sameEvent/TriggerParticles") + HIST(particlenames[index]), trigg.pt(), mult); - for (auto& assocTrack : assocs) { - auto assoc = assocTrack.track_as(); - - + if (!mixing) { + float efficiency = 1.0f; + if (applyEfficiencyForTrigger) { + efficiency = hEfficiencyTrigger->Interpolate(trigg.pt(), trigg.eta()); + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; + } + } + float weight = (applyEfficiencyForTrigger) ? 1. / efficiency : 1.0f; + if constexpr (requires { triggerTrack.extra(); }) + histos.fill(HIST("sameEvent/TriggerParticlesPion"), trigg.pt(), mult, weight); + else + histos.fill(HIST("sameEvent/TriggerParticlesHadron"), trigg.pt(), mult, weight); + } + double triggSign = trigg.sign(); + double triggForDeltaPhiStar[] = {trigg.phi(), trigg.pt(), triggSign}; + for (auto const& assocTrack : assocs) { + auto assoc = assocTrack.template track_as(); //---] removing autocorrelations [--- if (doAutocorrelationRejection) { if (trigg.globalIndex() == assoc.globalIndex()) { - histos.fill(HIST("hNumberOfRejectedPairs") + HIST(particlenames[index]), 0.5); + if constexpr (requires { assocTrack.nSigmaTPCPi(); }) + histos.fill(HIST("hNumberOfRejectedPairsPion"), 0.5); + else + histos.fill(HIST("hNumberOfRejectedPairsHadron"), 0.5); continue; } } - //---] track quality check [--- - if (assoc.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated) + if (!isValidAssocHadron(assoc)) continue; - - float deltaphi = ComputeDeltaPhi(trigg.phi(), assoc.phi()); + if (doAssocPhysicalPrimary && !assocTrack.mcPhysicalPrimary()) { + continue; + } + float deltaphi = computeDeltaPhi(trigg.phi(), assoc.phi()); float deltaeta = trigg.eta() - assoc.eta(); float ptassoc = assoc.pt(); float pttrigger = trigg.pt(); + double assocSign = assoc.sign(); + double assocForDeltaPhiStar[] = {assoc.phi(), assoc.pt(), assocSign}; + + float etaWeight = 1.; + if (systCuts.doOnTheFlyFlattening) { + float preWeight = 1 - std::abs(deltaeta) / 1.6; + etaWeight = preWeight != 0 ? 1.0f / preWeight : 1.0f; + } + // skip if basic ranges not met if (deltaphi < axisRanges[0][0] || deltaphi > axisRanges[0][1]) continue; @@ -522,12 +942,49 @@ struct correlateStrangeness { if (ptassoc < axisRanges[2][0] || ptassoc > axisRanges[2][1]) continue; - if (!mixing) - histos.fill(HIST("sameEvent/Signal/") + HIST(particlenames[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult); - else - histos.fill(HIST("mixedEvent/Signal/") + HIST(particlenames[index]), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult); + float efficiency = 1; + float purity = 1.0f; + if (applyEfficiencyCorrection) { + if constexpr (requires { assocTrack.nSigmaTPCPi(); }) { + efficiency = hEfficiencyPion->Interpolate(ptassoc, assoc.eta()); + } else { + efficiency = hEfficiencyHadron->Interpolate(ptassoc, assoc.eta()); + purity = hPurityHadron->Interpolate(ptassoc); + } + } + if (applyEfficiencyForTrigger) { + efficiency = efficiency * hEfficiencyTrigger->Interpolate(pttrigger, trigg.eta()); + purity = purity * hPurityHadron->Interpolate(pttrigger); + } + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; + } + float weight = (applyEfficiencyCorrection || applyEfficiencyForTrigger) ? purity / efficiency : 1.0f; + double deltaPhiStar = calculateAverageDeltaPhiStar(triggForDeltaPhiStar, assocForDeltaPhiStar, bField); + if (!mixing) { + if constexpr (requires { assocTrack.nSigmaTPCPi(); }) { + histos.fill(HIST("sameEvent/Signal/Pion"), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight * etaWeight); + if (triggSign == assocSign && doDeltaPhiStarCheck) { + histos.fill(HIST("sameEvent/Signal/Pion") + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - assoc.eta(), 0.5); + } else if (doDeltaPhiStarCheck) { + histos.fill(HIST("sameEvent/Signal/Pion") + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - assoc.eta(), -0.5); + } + } else { + if (triggSign == assocSign && doDeltaPhiStarCheck) { + histos.fill(HIST("sameEvent/Signal/Hadron") + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - assoc.eta(), 0.5); + } else if (doDeltaPhiStarCheck) { + histos.fill(HIST("sameEvent/Signal/Hadron") + HIST("DeltaPhiStar"), deltaPhiStar, trigg.eta() - assoc.eta(), -0.5); + } + histos.fill(HIST("sameEvent/Signal/Hadron"), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight * etaWeight); + } + } else { + if constexpr (requires { assocTrack.nSigmaTPCPi(); }) { + histos.fill(HIST("mixedEvent/Signal/Pion"), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + } else { + histos.fill(HIST("mixedEvent/Signal/Hadron"), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult, weight); + } + } } - } }); } } @@ -546,27 +1003,28 @@ struct correlateStrangeness { hEfficiencyOmegaPlus = 0x0; hEfficiencyHadron = 0x0; + hPurityHadron = 0x0; // set bitmap for convenience doCorrelation = 0; if (doCorrelationK0Short) - bitset(doCorrelation, 0); + SETBIT(doCorrelation, 0); if (doCorrelationLambda) - bitset(doCorrelation, 1); + SETBIT(doCorrelation, 1); if (doCorrelationAntiLambda) - bitset(doCorrelation, 2); + SETBIT(doCorrelation, 2); if (doCorrelationXiMinus) - bitset(doCorrelation, 3); + SETBIT(doCorrelation, 3); if (doCorrelationXiPlus) - bitset(doCorrelation, 4); + SETBIT(doCorrelation, 4); if (doCorrelationOmegaMinus) - bitset(doCorrelation, 5); + SETBIT(doCorrelation, 5); if (doCorrelationOmegaPlus) - bitset(doCorrelation, 6); + SETBIT(doCorrelation, 6); if (doCorrelationPion) - bitset(doCorrelation, 7); + SETBIT(doCorrelation, 7); if (doCorrelationHadron) - bitset(doCorrelation, 8); + SETBIT(doCorrelation, 8); // Store axis ranges to prevent spurious filling // axis status: @@ -583,6 +1041,8 @@ struct correlateStrangeness { const AxisSpec preAxisPtTrigger{axisPtTrigger, "#it{p}_{T}^{trigger} (GeV/c)"}; const AxisSpec preAxisVtxZ{axisVtxZ, "vertex Z (cm)"}; const AxisSpec preAxisMult{axisMult, "mult percentile"}; + const AxisSpec axisPtLambda{axisPtAssoc, "#it{p}_{T}^{#Lambda} (GeV/c)"}; + const AxisSpec axisPtCascade{axisPtAssoc, "#it{p}_{T}^{Mother} (GeV/c)"}; // store the original axes in specific TH1Cs for completeness histos.add("axes/hDeltaPhiAxis", "", kTH1C, {preAxisDeltaPhi}); @@ -717,62 +1177,90 @@ struct correlateStrangeness { const AxisSpec axisPtTriggerNDim{edgesPtTrigger, "#it{p}_{T}^{trigger} (GeV/c)"}; const AxisSpec axisVtxZNDim{edgesVtxZ, "vertex Z (cm)"}; const AxisSpec axisMultNDim{edgesMult, "mult percentile"}; - + if (!doPPAnalysis) { + // event selections in Pb-Pb + histos.add("hEventSelection", "hEventSelection", kTH1F, {{10, 0, 10}}); + TString eventSelLabel[] = {"all", "sel8", "kIsTriggerTVX", "PV_{z}", "kIsGoodITSLayersAll", "kIsGoodZvtxFT0vsPV", "OccupCut", "kNoITSROFrameBorder", "kNoSameBunchPileup ", " kNoCollInTimeRangeStandard"}; + for (int i = 1; i <= histos.get(HIST("hEventSelection"))->GetNbinsX(); i++) { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(i, eventSelLabel[i - 1]); + } + } // Some QA plots - histos.add("hGeneratedQAPtTrigger", "hGeneratedQAPtTrigger", kTH2F, {axisPtQA, {5, -0.5f, 4.5f}}); - histos.add("hGeneratedQAPtAssociatedK0", "hGeneratedQAPtAssociatedK0", kTH2F, {axisPtQA, {5, -0.5f, 4.5f}}); - histos.add("hClosureQAPtTrigger", "hClosureQAPtTrigger", kTH2F, {axisPtQA, {5, -0.5f, 4.5f}}); - histos.add("hClosureQAPtAssociatedK0", "hClosureQAPtAssociatedK0", kTH2F, {axisPtQA, {5, -0.5f, 4.5f}}); - - histos.add("hTriggerAllSelectedEtaVsPt", "hTriggerAllSelectedEtaVsPt", kTH3F, {axisPtQA, axisEta, axisMult}); - - histos.add("hClosureTestEventCounter", "hClosureTestEventCounter", kTH1F, {{10, 0, 10}}); - - histos.add("hNumberOfRejectedPairsHadron", "hNumberOfRejectedPairsHadron", kTH1F, {{1, 0, 1}}); - histos.add("hNumberOfRejectedPairsV0", "hNumberOfRejectedPairsV0", kTH1F, {{1, 0, 1}}); - histos.add("hNumberOfRejectedPairsCascades", "hNumberOfRejectedPairsCascades", kTH1F, {{1, 0, 1}}); - histos.add("hNumberOfRejectedPairsPion", "hNumberOfRejectedPairsPion", kTH1F, {{1, 0, 1}}); - - histos.add("sameEvent/TriggerParticlesHadron", "TriggersHadron", kTH2F, {axisPtQA, axisMult}); - histos.add("sameEvent/TriggerParticlesV0", "TriggersV0", kTH2F, {axisPtQA, axisMult}); - histos.add("sameEvent/TriggerParticlesCascade", "TriggersCascade", kTH2F, {axisPtQA, axisMult}); - histos.add("sameEvent/TriggerParticlesPion", "TriggersPion", kTH2F, {axisPtQA, axisMult}); - - // mixing QA - histos.add("MixingQA/hSECollisionBins", ";bin;Entries", kTH1F, {{140, -0.5, 139.5}}); - histos.add("MixingQA/hMECollisionBins", ";bin;Entries", kTH1F, {{140, -0.5, 139.5}}); - histos.add("MixingQA/hMEpvz1", ";pvz;Entries", kTH1F, {{30, -15, 15}}); - histos.add("MixingQA/hMEpvz2", ";pvz;Entries", kTH1F, {{30, -15, 15}}); - - // Event QA - histos.add("EventQA/hMixingQA", "mixing QA", kTH1F, {{2, -0.5, 1.5}}); - histos.add("EventQA/hMult", "Multiplicity", kTH1F, {axisMult}); - histos.add("EventQA/hPvz", ";pvz;Entries", kTH1F, {{30, -15, 15}}); - histos.add("EventQA/hMultFT0vsTPC", ";centFT0M;multNTracksPVeta1", kTH2F, {{100, 0, 100}, {300, 0, 300}}); - - // QA and THn Histograms - histos.add("hTriggerPtResolution", ";p_{T}^{reconstructed} (GeV/c); p_{T}^{generated} (GeV/c)", kTH2F, {axisPtQA, axisPtQA}); - histos.add("hTriggerPrimaryEtaVsPt", "hTriggerPrimaryEtaVsPt", kTH3F, {axisPtQA, axisEta, axisMult}); - histos.add("hTrackEtaVsPtVsPhi", "hTrackEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("hTrackAttempt", "Attempt", kTH3F, {axisPtQA, axisEta, axisPhi}); + if (doprocessMCGenerated) { + histos.add("hGeneratedQAPtTrigger", "hGeneratedQAPtTrigger", kTH2F, {axisPtQA, {5, -0.5f, 4.5f}}); + histos.add("hGeneratedQAPtAssociatedK0", "hGeneratedQAPtAssociatedK0", kTH2F, {axisPtQA, {5, -0.5f, 4.5f}}); + } + if (doprocessClosureTest) { + histos.add("hClosureQAPtTrigger", "hClosureQAPtTrigger", kTH2F, {axisPtQA, {5, -0.5f, 4.5f}}); + histos.add("hClosureQAPtAssociatedK0", "hClosureQAPtAssociatedK0", kTH2F, {axisPtQA, {5, -0.5f, 4.5f}}); + } + if (doprocessMCGenerated || doprocessClosureTest) { + histos.add("hClosureTestEventCounter", "hClosureTestEventCounter", kTH1F, {{10, 0, 10}}); + } + if (doprocessSameEventHV0s || doprocessSameEventHCascades || doprocessSameEventHPions || doprocessSameEventHHadrons) { + histos.add("hTriggerAllSelectedEtaVsPt", "hTriggerAllSelectedEtaVsPt", kTH3F, {axisPtQA, axisEta, axisMult}); + // QA and THn Histograms + histos.add("hTriggerPtResolution", ";p_{T}^{reconstructed} (GeV/c); p_{T}^{generated} (GeV/c)", kTH2F, {axisPtQA, axisPtQA}); + histos.add("hTriggerPrimaryEtaVsPt", "hTriggerPrimaryEtaVsPt", kTH3F, {axisPtQA, axisEta, axisMult}); + histos.add("hTrackEtaVsPtVsPhi", "hTrackEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); + histos.add("hAssocTrackEtaVsPtVsPhi", "hAssocTrackEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); + // histos.add("hTrackAttempt", "Attempt", kTH3F, {axisPtQA, axisEta, axisPhi}); + } + if (doprocessSameEventHPions || doprocessSameEventHHadrons || doprocessMixedEventHPions || doprocessMixedEventHHadrons) { + histos.add("hNumberOfRejectedPairsHadron", "hNumberOfRejectedPairsHadron", kTH1F, {{1, 0, 1}}); + histos.add("hNumberOfRejectedPairsPion", "hNumberOfRejectedPairsPion", kTH1F, {{1, 0, 1}}); + } + if (doprocessSameEventHV0s || doprocessMixedEventHV0s) { + histos.add("hNumberOfRejectedPairsV0", "hNumberOfRejectedPairsV0", kTH1F, {{1, 0, 1}}); + } + if (doprocessSameEventHCascades || doprocessMixedEventHCascades) { + histos.add("hNumberOfRejectedPairsCascades", "hNumberOfRejectedPairsCascades", kTH1F, {{1, 0, 1}}); + } + + if (doMixingQAandEventQA) { + // mixing QA + histos.add("MixingQA/hSECollisionBins", ";bin;Entries", kTH1F, {{140, -0.5, 139.5}}); + histos.add("MixingQA/hMECollisionBins", ";bin;Entries", kTH1F, {{140, -0.5, 139.5}}); + histos.add("MixingQA/hMEpvz1", ";pvz;Entries", kTH1F, {{30, -15, 15}}); + histos.add("MixingQA/hMEpvz2", ";pvz;Entries", kTH1F, {{30, -15, 15}}); + + // Event QA + histos.add("EventQA/hMixingQA", "mixing QA", kTH1F, {{2, -0.5, 1.5}}); + histos.add("EventQA/hMult", "Multiplicity", kTH1F, {axisMult}); + histos.add("EventQA/hPvz", ";pvz;Entries", kTH1F, {{30, -15, 15}}); + histos.add("EventQA/hMultFT0vsTPC", ";centFT0M;multNTracksPVeta1", kTH2F, {{100, 0, 100}, {300, 0, 300}}); + } bool hStrange = false; for (int i = 0; i < 9; i++) { - if (bitcheck(doCorrelation, i)) { - histos.add(fmt::format("h{}EtaVsPtVsPhi", particlenames[i]).c_str(), "", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add(fmt::format("h3d{}Spectrum", particlenames[i]).c_str(), fmt::format("h3d{}Spectrum", particlenames[i]).c_str(), kTH3F, {axisPtQA, axisMult, axisMassNSigma}); - histos.add(fmt::format("h3d{}SpectrumY", particlenames[i]).c_str(), fmt::format("h3d{}SpectrumY", particlenames[i]).c_str(), kTH3F, {axisPtQA, axisMult, axisMassNSigma}); - histos.add(fmt::format("sameEvent/Signal/{}", particlenames[i]).c_str(), "", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); + if (TESTBIT(doCorrelation, i)) { + histos.add(fmt::format("h{}EtaVsPtVsPhi", kParticlenames[i]).c_str(), "", kTH3F, {axisPtQA, axisEta, axisPhi}); + histos.add(fmt::format("h3d{}Spectrum", kParticlenames[i]).c_str(), fmt::format("h3d{}Spectrum", kParticlenames[i]).c_str(), kTH3F, {axisPtQA, axisMult, axisMassNSigma}); + histos.add(fmt::format("h3d{}SpectrumY", kParticlenames[i]).c_str(), fmt::format("h3d{}SpectrumY", kParticlenames[i]).c_str(), kTH3F, {axisPtQA, axisMult, axisMassNSigma}); + histos.add(fmt::format("sameEvent/Signal/{}", kParticlenames[i]).c_str(), "", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); + if (doDeltaPhiStarCheck) { + histos.add(fmt::format("sameEvent/Signal/{}DeltaPhiStar", kParticlenames[i]).c_str(), "", kTH3F, {{100, -0.3, 0.3}, {50, -0.05, 0.05}, {2, -1, 1}}); // -1 oposite charge, 1 same charge + } if (i < 7) { hStrange = true; - histos.add(fmt::format("h{}EtaVsPtVsPhiBg", particlenames[i]).c_str(), "", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add(fmt::format("hITSClusters{}NegativeDaughterToward", particlenames[i]).c_str(), "", kTH3F, {axisPtAssoc, {8, -0.5, 7.5}, {20, 0, 10}}); - histos.add(fmt::format("hITSClusters{}PositiveDaughterToward", particlenames[i]).c_str(), "", kTH3F, {axisPtAssoc, {8, -0.5, 7.5}, {20, 0, 10}}); - histos.add(fmt::format("hITSClusters{}NegativeDaughterTransverse", particlenames[i]).c_str(), "", kTH3F, {axisPtAssoc, {8, -0.5, 7.5}, {20, 0, 10}}); - histos.add(fmt::format("hITSClusters{}PositiveDaughterTransverse", particlenames[i]).c_str(), "", kTH3F, {axisPtAssoc, {8, -0.5, 7.5}, {20, 0, 10}}); + histos.add(fmt::format("h{}EtaVsPtVsPhiBg", kParticlenames[i]).c_str(), "", kTH3F, {axisPtQA, axisEta, axisPhi}); + if (doITSClustersQA) { + histos.add(fmt::format("hITSClusters{}NegativeDaughterToward", kParticlenames[i]).c_str(), "", kTH3F, {axisPtAssoc, {8, -0.5, 7.5}, {20, 0, 10}}); + histos.add(fmt::format("hITSClusters{}PositiveDaughterToward", kParticlenames[i]).c_str(), "", kTH3F, {axisPtAssoc, {8, -0.5, 7.5}, {20, 0, 10}}); + histos.add(fmt::format("hITSClusters{}NegativeDaughterTransverse", kParticlenames[i]).c_str(), "", kTH3F, {axisPtAssoc, {8, -0.5, 7.5}, {20, 0, 10}}); + histos.add(fmt::format("hITSClusters{}PositiveDaughterTransverse", kParticlenames[i]).c_str(), "", kTH3F, {axisPtAssoc, {8, -0.5, 7.5}, {20, 0, 10}}); + } } } } + + if (TESTBIT(doCorrelation, 8)) { + histos.add("hAsssocTrackEtaVsPtVsPhi", "", kTH3F, {axisPtQA, axisEta, axisPhi}); + histos.add("hAssocPrimaryEtaVsPt", "", kTH3F, {axisPtQA, axisEta, axisMult}); + histos.add("hAssocHadronsAllSelectedEtaVsPt", "", kTH3F, {axisPtQA, axisEta, axisMult}); + histos.add("hAssocPtResolution", ";p_{T}^{reconstructed} (GeV/c); p_{T}^{generated} (GeV/c)", kTH2F, {axisPtQA, axisPtQA}); + } + if (hStrange) { histos.addClone("sameEvent/Signal/", "sameEvent/LeftBg/"); histos.addClone("sameEvent/Signal/", "sameEvent/RightBg/"); @@ -783,30 +1271,54 @@ struct correlateStrangeness { if (doprocessMixedEventHV0s || doprocessMixedEventHCascades || doprocessMixedEventHPions || doprocessMixedEventHHadrons) { histos.addClone("sameEvent/", "mixedEvent/"); } + if (doprocessSameEventHHadrons) + histos.add("sameEvent/TriggerParticlesHadron", "TriggersHadron", kTH2F, {axisPtQA, axisMult}); + if (doprocessSameEventHV0s) + histos.add("sameEvent/TriggerParticlesV0", "TriggersV0", kTH2F, {axisPtQA, axisMult}); + if (doprocessSameEventHCascades) + histos.add("sameEvent/TriggerParticlesCascade", "TriggersCascade", kTH2F, {axisPtQA, axisMult}); + if (doprocessSameEventHPions) + histos.add("sameEvent/TriggerParticlesPion", "TriggersPion", kTH2F, {axisPtQA, axisMult}); // MC generated plots if (doprocessMCGenerated) { histos.add("Generated/hTrigger", "", kTH2F, {axisPtQA, axisEta}); - for (int i = 0; i < 8; i++) { - histos.add(fmt::format("Generated/h{}", particlenames[i]).c_str(), "", kTH2F, {axisPtQA, axisEta}); + for (int i = 0; i < 9; i++) { + histos.add(fmt::format("Generated/h{}", kParticlenames[i]).c_str(), "", kTH2F, {axisPtQA, axisEta}); } histos.addClone("Generated/", "GeneratedWithPV/"); // histograms within |y|<0.5, vs multiplicity for (int i = 0; i < 8; i++) { - histos.add(fmt::format("GeneratedWithPV/h{}_MidYVsMult", particlenames[i]).c_str(), "", kTH2F, {axisPtQA, axisMult}); - histos.add(fmt::format("GeneratedWithPV/h{}_MidYVsMult_TwoPVsOrMore", particlenames[i]).c_str(), "", kTH2F, {axisPtQA, axisMult}); + histos.add(fmt::format("GeneratedWithPV/h{}_MidYVsMult", kParticlenames[i]).c_str(), "", kTH2F, {axisPtQA, axisMult}); + histos.add(fmt::format("GeneratedWithPV/h{}_MidYVsMult_TwoPVsOrMore", kParticlenames[i]).c_str(), "", kTH2F, {axisPtQA, axisMult}); } + histos.add("GeneratedWithPV/hLambdaFromXiZero", "", kTH2F, {axisPtQA, axisEta}); + histos.add("GeneratedWithPV/hLambdaFromXiMinus", "", kTH2F, {axisPtQA, axisEta}); + histos.add("GeneratedWithPV/hAntiLambdaFromXiZero", "", kTH2F, {axisPtQA, axisEta}); + histos.add("GeneratedWithPV/hAntiLambdaFromXiPlus", "", kTH2F, {axisPtQA, axisEta}); } if (doprocessClosureTest) { - for (int i = 0; i < 8; i++) { - if (bitcheck(doCorrelation, i)) - histos.add(fmt::format("ClosureTest/sameEvent/{}", particlenames[i]).c_str(), "", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); - if (bitcheck(doCorrelation, i)) - histos.add(fmt::format("ClosureTest/h{}", particlenames[i]).c_str(), "", kTH3F, {axisPtQA, axisEta, axisPhi}); + for (int i = 0; i < 9; i++) { + if (TESTBIT(doCorrelation, i)) + histos.add(fmt::format("ClosureTest/sameEvent/{}", kParticlenames[i]).c_str(), "", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); + if (TESTBIT(doCorrelation, i)) + histos.add(fmt::format("ClosureTest/h{}", kParticlenames[i]).c_str(), "", kTH3F, {axisPtQA, axisEta, axisPhi}); } histos.add("ClosureTest/hTrigger", "Trigger Tracks", kTH3F, {axisPtQA, axisEta, axisMult}); } + if (doprocessFeedDown) { + histos.add("hLambdaXiMinusFeeddownMatrix", "hLambdaXiMinusFeeddownMatrix", kTH2F, {axisPtLambda, axisPtCascade}); + histos.add("hLambdaXiZeroFeeddownMatrix", "hLambdaXiZeroFeeddownMatrix", kTH2F, {axisPtLambda, axisPtCascade}); + histos.add("hLambdaOmegaFeeddownMatrix", "hLambdaOmegaFeeddownMatrix", kTH2F, {axisPtLambda, axisPtCascade}); + histos.add("hAntiLambdaXiPlusFeeddownMatrix", "hAntiLambdaXiPlusFeeddownMatrix", kTH2F, {axisPtLambda, axisPtCascade}); + histos.add("hAntiLambdaXiZeroFeeddownMatrix", "hAntiLambdaXiZeroFeeddownMatrix", kTH2F, {axisPtLambda, axisPtCascade}); + histos.add("hAntiLambdaOmegaFeeddownMatrix", "hAntiLambdaOmegaFeeddownMatrix", kTH2F, {axisPtLambda, axisPtCascade}); + histos.add("hLambdaFromXiMinusEtaVsPtVsPhi", "hLambdaFromXiMinusEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); + histos.add("hLambdaFromXiZeroEtaVsPtVsPhi", "hLambdaFromXiZeroEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); + histos.add("hAntiLambdaFromXiPlusEtaVsPtVsPhi", "hAntiLambdaFromXiPlusEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); + histos.add("hAntiLambdaFromXiZeroEtaVsPtVsPhi", "hAntiLambdaFromXiZeroEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); + } // visual inspection of sizes histos.print(); @@ -830,7 +1342,7 @@ struct correlateStrangeness { if (!collision.sel8()) { return false; } - if (TMath::Abs(collision.posZ()) > zVertexCut) { + if (std::abs(collision.posZ()) > zVertexCut) { return false; } if (collision.centFT0M() > axisRanges[5][1] || collision.centFT0M() < axisRanges[5][0]) { @@ -839,6 +1351,9 @@ struct correlateStrangeness { if (!collision.isInelGt0() && selectINELgtZERO) { return false; } + if (!collision.selection_bit(aod::evsel::kIsGoodITSLayersAll) && requireAllGoodITSLayers) { + return false; + } if (zorroMask.value != "") { auto bc = collision.template bc_as(); initZorro(bc); @@ -850,6 +1365,100 @@ struct correlateStrangeness { return true; } + // event selections in Pb-Pb + template + bool isCollisionSelectedPbPb(TCollision collision, bool fillHists) + { + if (fillHists) + histos.fill(HIST("hEventSelection"), 0.5 /* all collisions */); + + // Perform basic event selection + if (!collision.sel8()) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 1.5 /* collisions after sel8*/); + + if (!collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 2.5 /* FT0 vertex (acceptable FT0C-FT0A time difference) collisions */); + + if (std::abs(collision.posZ()) > zVertexCut) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 3.5 /* collisions after sel pvz sel*/); + + if (!collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // cut time intervals with dead ITS staves + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 4.5 /* collisions after cut time intervals with dead ITS staves*/); + + if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 5.5 /* removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference*/); + + auto occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh) + return false; + if (fillHists) + histos.fill(HIST("hEventSelection"), 6.5 /* Below min occupancy and Above max occupancy*/); + + /* + if (collision.alias_bit(kTVXinTRD)) { + // TRD triggered + return false; + } + */ + + if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + // reject collisions close to Time Frame borders + // O2-4623 + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 7.5 /* reject collisions close to Time Frame borders*/); + + if (!collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + // reject events affected by the ITS ROF border + // O2-4309 + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 8.5 /* reject events affected by the ITS ROF border*/); + + if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 9.5 /* rejects collisions which are associated with the same "found-by-T0" bunch crossing*/); + return true; + } + + double getMagneticField(uint64_t timestamp) + { + static parameters::GRPMagField* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp("GLO/Config/GRPMagField", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + } + + return 0.1 * (grpo->getNominalL3Field()); // 1 T = 10 kG + } // if this process function is enabled, it will be such that only events with trigger particles within a given // trigger pt bin are taken for the entire processing. This allows for the calculation of e.g. efficiencies // within an event class that has a trigger (which may differ with respect to other cases, to be checked) @@ -880,7 +1489,7 @@ struct correlateStrangeness { continue; } auto binNumber = histos.get(HIST("axes/hPtTriggerAxis"))->FindFixBin(track.pt()) - 1; - bitset(triggerPresenceMap[collision.globalIndex()], binNumber); + SETBIT(triggerPresenceMap[collision.globalIndex()], binNumber); } } } @@ -891,17 +1500,24 @@ struct correlateStrangeness { { // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && !bitcheck(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { + if (triggerPresenceMap.size() > 0 && !TESTBIT(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { return; } + auto bc = collision.bc_as(); + auto bField = getMagneticField(bc.timestamp()); + + if (applyEfficiencyCorrection) { + initEfficiencyFromCCDB(bc); + } + // ________________________________________________ // Perform basic event selection if (!isCollisionSelected(collision)) { return; } // ________________________________________________ - if (!doprocessSameEventHCascades && !doprocessSameEventHV0s && !doprocessSameEventHPions) { + if (!doprocessSameEventHCascades && !doprocessSameEventHV0s && !doprocessSameEventHPions && doMixingQAandEventQA) { histos.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({collision.posZ(), collision.centFT0M()})); histos.fill(HIST("EventQA/hMult"), collision.centFT0M()); histos.fill(HIST("EventQA/hPvz"), collision.posZ()); @@ -917,46 +1533,79 @@ struct correlateStrangeness { auto track = triggerTrack.track_as(); if (!isValidTrigger(track)) continue; + float efficiency = 1.0f; + if (applyEfficiencyCorrection) { + efficiency = hEfficiencyTrigger->Interpolate(track.pt(), track.eta()); + } + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; + } + float weight = applyEfficiencyCorrection ? 1. / efficiency : 1.0f; histos.fill(HIST("hTriggerAllSelectedEtaVsPt"), track.pt(), track.eta(), collision.centFT0M()); histos.fill(HIST("hTriggerPtResolution"), track.pt(), triggerTrack.mcOriginalPt()); if (doTriggPhysicalPrimary && !triggerTrack.mcPhysicalPrimary()) continue; histos.fill(HIST("hTriggerPrimaryEtaVsPt"), track.pt(), track.eta(), collision.centFT0M()); - histos.fill(HIST("hTrackEtaVsPtVsPhi"), track.pt(), track.eta(), track.phi()); + histos.fill(HIST("hTrackEtaVsPtVsPhi"), track.pt(), track.eta(), track.phi(), weight); + } + for (auto const& assocTrack : assocHadrons) { + auto assoc = assocTrack.track_as(); + if (!isValidAssocHadron(assoc)) + continue; + float efficiency = 1.0f; + float purity = 1.0f; + if (applyEfficiencyCorrection) { + efficiency = hEfficiencyHadron->Interpolate(assoc.pt(), assoc.eta()); + purity = hPurityHadron->Interpolate(assoc.pt()); + } + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; + } + float weight = applyEfficiencyCorrection ? purity / efficiency : 1.0f; + histos.fill(HIST("hAssocHadronsAllSelectedEtaVsPt"), assoc.pt(), assoc.eta(), collision.centFT0M()); + histos.fill(HIST("hAssocPtResolution"), assoc.pt(), assocTrack.mcOriginalPt()); + if (doAssocPhysicalPrimary && !assocTrack.mcPhysicalPrimary()) + continue; + histos.fill(HIST("hAssocPrimaryEtaVsPt"), assoc.pt(), assoc.eta(), collision.centFT0M()); + histos.fill(HIST("hAsssocTrackEtaVsPtVsPhi"), assoc.pt(), assoc.eta(), assoc.phi(), weight); } } // ________________________________________________ // Do hadron - hadron correlations - fillCorrelationsHadron(triggerTracks, assocHadrons, false, collision.posZ(), collision.centFT0M(), 7); + fillCorrelationsHadron(triggerTracks, assocHadrons, false, collision.posZ(), collision.centFT0M(), bField); } - void processSameEventHV0s(soa::Join::iterator const& collision, + void processSameEventHV0s(soa::Join::iterator const& collision, aod::AssocV0s const& associatedV0s, aod::TriggerTracks const& triggerTracks, - V0DatasWithoutTrackX const&, aod::V0sLinked const&, TracksComplete const&, aod::BCsWithTimestamps const&) + V0DatasWithoutTrackX const&, TracksComplete const&, aod::BCsWithTimestamps const&) { + if (!doPPAnalysis) { + BinningTypePbPb colBinning{{axisVtxZ, axisMult}, true}; + } + double cent = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && !bitcheck(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { + if (triggerPresenceMap.size() > 0 && !TESTBIT(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { return; } // ________________________________________________ // Perform basic event selection - if (!isCollisionSelected(collision)) { + if (((doPPAnalysis && !isCollisionSelected(collision))) || (!doPPAnalysis && !isCollisionSelectedPbPb(collision, true))) { return; } // ________________________________________________ - if (!doprocessSameEventHCascades) { - histos.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({collision.posZ(), collision.centFT0M()})); - histos.fill(HIST("EventQA/hMult"), collision.centFT0M()); + if (!doprocessSameEventHCascades && doMixingQAandEventQA) { + histos.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({collision.posZ(), cent})); + histos.fill(HIST("EventQA/hMult"), cent); histos.fill(HIST("EventQA/hPvz"), collision.posZ()); - histos.fill(HIST("EventQA/hMultFT0vsTPC"), collision.centFT0M(), collision.multNTracksPVeta1()); + histos.fill(HIST("EventQA/hMultFT0vsTPC"), cent, collision.multNTracksPVeta1()); } // Do basic QA - + auto bc = collision.bc_as(); + auto bField = getMagneticField(bc.timestamp()); if (applyEfficiencyCorrection) { - auto bc = collision.bc_as(); initEfficiencyFromCCDB(bc); } TH2F* hEfficiencyV0[3]; @@ -974,29 +1623,36 @@ struct correlateStrangeness { continue; //---] syst cuts [--- - if (v0Data.v0radius() < systCuts.v0RadiusMin || v0Data.v0radius() > systCuts.v0RadiusMax || - std::abs(v0Data.dcapostopv()) < systCuts.dcapostopv || std::abs(v0Data.dcanegtopv()) < systCuts.dcanegtopv || - v0Data.v0cosPA() < systCuts.v0cospa || v0Data.dcaV0daughters() > systCuts.dcaV0dau) + if (doPPAnalysis && (v0Data.v0radius() < systCuts.v0RadiusMin || v0Data.v0radius() > systCuts.v0RadiusMax || + std::abs(v0Data.dcapostopv()) < systCuts.dcapostopv || std::abs(v0Data.dcanegtopv()) < systCuts.dcanegtopv || + v0Data.v0cosPA() < systCuts.v0cospa || v0Data.dcaV0daughters() > systCuts.dcaV0dau)) + continue; + if (!doPPAnalysis && !V0SelectedPbPb(v0Data)) continue; + uint64_t selMap = V0selectionBitmap(v0Data, collision.posX(), collision.posY(), collision.posZ()); static_for<0, 2>([&](auto i) { - constexpr int index = i.value; + constexpr int Index = i.value; float efficiency = 1.0f; if (applyEfficiencyCorrection) { - efficiency = hEfficiencyV0[index]->Interpolate(v0Data.pt(), v0Data.eta()); + efficiency = hEfficiencyV0[Index]->Interpolate(v0Data.pt(), v0Data.eta()); + } + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; } float weight = applyEfficiencyCorrection ? 1. / efficiency : 1.0f; - if (v0.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || v0.mcTrue(index)) && (!doAssocPhysicalPrimary || v0.mcPhysicalPrimary()) && (!applyEfficiencyCorrection || efficiency != 0)) { - if (bitcheck(doCorrelation, index)) { - histos.fill(HIST("h3d") + HIST(v0names[index]) + HIST("Spectrum"), v0Data.pt(), collision.centFT0M(), v0.invMassNSigma(index), weight); - if (std::abs(v0Data.rapidity(index)) < 0.5) { - histos.fill(HIST("h3d") + HIST(v0names[index]) + HIST("SpectrumY"), v0Data.pt(), collision.centFT0M(), v0.invMassNSigma(index), weight); + if (v0.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || v0.mcTrue(Index)) && (!doAssocPhysicalPrimary || v0.mcPhysicalPrimary()) && (!applyEfficiencyCorrection || efficiency != 0)) { + if ((TESTBIT(doCorrelation, Index)) && (doPPAnalysis || (TESTBIT(selMap, Index) && TESTBIT(selMap, Index + 3)))) { + histos.fill(HIST("h3d") + HIST(kV0names[Index]) + HIST("Spectrum"), v0Data.pt(), cent, v0.invMassNSigma(Index), weight); + if (std::abs(v0Data.rapidity(Index)) < ySel) { + histos.fill(HIST("h3d") + HIST(kV0names[Index]) + HIST("SpectrumY"), v0Data.pt(), cent, v0.invMassNSigma(Index), weight); + } + if ((-massWindowConfigurations.maxBgNSigma < v0.invMassNSigma(Index) && v0.invMassNSigma(Index) < -massWindowConfigurations.minBgNSigma) || (+massWindowConfigurations.minBgNSigma < v0.invMassNSigma(Index) && v0.invMassNSigma(Index) < +massWindowConfigurations.maxBgNSigma)) { + histos.fill(HIST("h") + HIST(kV0names[Index]) + HIST("EtaVsPtVsPhiBg"), v0Data.pt(), v0Data.eta(), v0Data.phi(), weight); + } + if (-massWindowConfigurations.maxPeakNSigma < v0.invMassNSigma(Index) && v0.invMassNSigma(Index) < +massWindowConfigurations.maxPeakNSigma) { + histos.fill(HIST("h") + HIST(kV0names[Index]) + HIST("EtaVsPtVsPhi"), v0Data.pt(), v0Data.eta(), v0Data.phi(), weight); } - } - if ((-massWindowConfigurations.maxBgNSigma < v0.invMassNSigma(index) && v0.invMassNSigma(index) < -massWindowConfigurations.minBgNSigma) || (+massWindowConfigurations.minBgNSigma < v0.invMassNSigma(index) && v0.invMassNSigma(index) < +massWindowConfigurations.maxBgNSigma)) - histos.fill(HIST("h") + HIST(v0names[index]) + HIST("EtaVsPtVsPhiBg"), v0Data.pt(), v0Data.eta(), v0Data.phi(), weight); - if (-massWindowConfigurations.maxPeakNSigma < v0.invMassNSigma(index) && v0.invMassNSigma(index) < +massWindowConfigurations.maxPeakNSigma) { - histos.fill(HIST("h") + HIST(v0names[index]) + HIST("EtaVsPtVsPhi"), v0Data.pt(), v0Data.eta(), v0Data.phi(), weight); } } }); @@ -1006,42 +1662,49 @@ struct correlateStrangeness { auto track = triggerTrack.track_as(); if (!isValidTrigger(track)) continue; - histos.fill(HIST("hTriggerAllSelectedEtaVsPt"), track.pt(), track.eta(), collision.centFT0M()); + histos.fill(HIST("hTriggerAllSelectedEtaVsPt"), track.pt(), track.eta(), cent); histos.fill(HIST("hTriggerPtResolution"), track.pt(), triggerTrack.mcOriginalPt()); if (doTriggPhysicalPrimary && !triggerTrack.mcPhysicalPrimary()) continue; - histos.fill(HIST("hTriggerPrimaryEtaVsPt"), track.pt(), track.eta(), collision.centFT0M()); + histos.fill(HIST("hTriggerPrimaryEtaVsPt"), track.pt(), track.eta(), cent); histos.fill(HIST("hTrackEtaVsPtVsPhi"), track.pt(), track.eta(), track.phi()); } } // ________________________________________________ // Do hadron - V0 correlations - fillCorrelationsV0(triggerTracks, associatedV0s, false, collision.posZ(), collision.centFT0M()); + fillCorrelationsV0(triggerTracks, associatedV0s, false, collision.posX(), collision.posY(), collision.posZ(), cent, bField); } - void processSameEventHCascades(soa::Join::iterator const& collision, + void processSameEventHCascades(soa::Join::iterator const& collision, aod::AssocV0s const&, aod::AssocCascades const& associatedCascades, aod::TriggerTracks const& triggerTracks, - V0DatasWithoutTrackX const&, aod::V0sLinked const&, aod::CascDatas const&, TracksComplete const&, aod::BCsWithTimestamps const&) + V0DatasWithoutTrackX const&, aod::CascDatas const&, TracksComplete const&, aod::BCsWithTimestamps const&) { + if (!doPPAnalysis) { + BinningTypePbPb colBinning{{axisVtxZ, axisMult}, true}; + } + double cent = doPPAnalysis ? collision.centFT0M() : collision.centFT0C(); // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && !bitcheck(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { + if (triggerPresenceMap.size() > 0 && !TESTBIT(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { return; } // ________________________________________________ // Perform basic event selection - if (!isCollisionSelected(collision)) { + if (((doPPAnalysis && !isCollisionSelected(collision))) || (!doPPAnalysis && !isCollisionSelectedPbPb(collision, true))) { return; } // ________________________________________________ - histos.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({collision.posZ(), collision.centFT0M()})); - histos.fill(HIST("EventQA/hMult"), collision.centFT0M()); - histos.fill(HIST("EventQA/hPvz"), collision.posZ()); + if (doMixingQAandEventQA) { + histos.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({collision.posZ(), cent})); + histos.fill(HIST("EventQA/hMult"), cent); + histos.fill(HIST("EventQA/hPvz"), collision.posZ()); + } // Do basic QA + auto bc = collision.bc_as(); + auto bField = getMagneticField(bc.timestamp()); if (applyEfficiencyCorrection) { - auto bc = collision.bc_as(); initEfficiencyFromCCDB(bc); } TH2F* hEfficiencyCascade[4]; @@ -1054,18 +1717,20 @@ struct correlateStrangeness { auto cascData = casc.cascData(); //---] syst cuts [--- - if (std::abs(cascData.dcapostopv()) < systCuts.dcapostopv || - std::abs(cascData.dcanegtopv()) < systCuts.dcanegtopv || - cascData.dcabachtopv() < systCuts.casc_dcabachtopv || - cascData.dcaV0daughters() > systCuts.dcaV0dau || - cascData.dcacascdaughters() > systCuts.casc_dcacascdau || - cascData.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < systCuts.v0cospa || - cascData.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < systCuts.casc_cospa || - cascData.cascradius() < systCuts.casc_cascradius || - std::abs(cascData.dcav0topv(collision.posX(), collision.posY(), collision.posZ())) < systCuts.casc_mindcav0topv || - std::abs(cascData.mLambda() - pdgDB->Mass(3122)) > systCuts.casc_v0masswindow) + if (doPPAnalysis && (std::abs(cascData.dcapostopv()) < systCuts.dcapostopv || + std::abs(cascData.dcanegtopv()) < systCuts.dcanegtopv || + cascData.dcabachtopv() < systCuts.cascDcabachtopv || + cascData.dcaV0daughters() > systCuts.dcaV0dau || + cascData.dcacascdaughters() > systCuts.cascDcacascdau || + cascData.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < systCuts.v0cospa || + cascData.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < systCuts.cascCospa || + cascData.cascradius() < systCuts.cascRadius || + std::abs(cascData.dcav0topv(collision.posX(), collision.posY(), collision.posZ())) < systCuts.cascMindcav0topv || + std::abs(cascData.mLambda() - o2::constants::physics::MassLambda0) > systCuts.cascV0masswindow)) continue; - + if (!doPPAnalysis && !CascadeSelectedPbPb(cascData, collision.posX(), collision.posY(), collision.posZ())) + continue; + uint64_t CascselMap = CascadeselectionBitmap(cascData, collision.posX(), collision.posY(), collision.posZ()); //---] track quality check [--- auto postrack = cascData.posTrack_as(); auto negtrack = cascData.negTrack_as(); @@ -1074,25 +1739,28 @@ struct correlateStrangeness { continue; static_for<0, 3>([&](auto i) { - constexpr int index = i.value; + constexpr int Index = i.value; float efficiency = 1.0f; if (applyEfficiencyCorrection) { - efficiency = hEfficiencyCascade[index]->Interpolate(cascData.pt(), cascData.eta()); + efficiency = hEfficiencyCascade[Index]->Interpolate(cascData.pt(), cascData.eta()); + } + if (efficiency == 0) { // check for zero efficiency, do not apply if the case + efficiency = 1; } float weight = applyEfficiencyCorrection ? 1. / efficiency : 1.0f; - if (casc.compatible(index, systCuts.dEdxCompatibility) && (!doMCassociation || casc.mcTrue(index)) && (!doAssocPhysicalPrimary || casc.mcPhysicalPrimary()) && (!applyEfficiencyCorrection || efficiency != 0)) { - if (bitcheck(doCorrelation, index + 3)) { - histos.fill(HIST("h3d") + HIST(cascadenames[index]) + HIST("Spectrum"), cascData.pt(), collision.centFT0M(), casc.invMassNSigma(index), weight); - if (std::abs(cascData.rapidity(index)) < 0.5) { - histos.fill(HIST("h3d") + HIST(cascadenames[index]) + HIST("SpectrumY"), cascData.pt(), collision.centFT0M(), casc.invMassNSigma(index), weight); + if (casc.compatible(Index, systCuts.dEdxCompatibility) && (!doMCassociation || casc.mcTrue(Index)) && (!doAssocPhysicalPrimary || casc.mcPhysicalPrimary()) && (!applyEfficiencyCorrection || efficiency != 0)) { + if (TESTBIT(doCorrelation, Index + 3) && (doPPAnalysis || (TESTBIT(CascselMap, Index) && TESTBIT(CascselMap, Index + 4) && TESTBIT(CascselMap, Index + 8) && TESTBIT(CascselMap, Index + 12)))) { + histos.fill(HIST("h3d") + HIST(kCascadenames[Index]) + HIST("Spectrum"), cascData.pt(), cent, casc.invMassNSigma(Index), weight); + if (std::abs(cascData.rapidity(Index)) < ySel) { + histos.fill(HIST("h3d") + HIST(kCascadenames[Index]) + HIST("SpectrumY"), cascData.pt(), cent, casc.invMassNSigma(Index), weight); + } + if (-massWindowConfigurations.maxPeakNSigma < casc.invMassNSigma(Index) && casc.invMassNSigma(Index) < +massWindowConfigurations.maxPeakNSigma) { + histos.fill(HIST("h") + HIST(kCascadenames[Index]) + HIST("EtaVsPtVsPhi"), cascData.pt(), cascData.eta(), cascData.phi(), weight); + } + if ((-massWindowConfigurations.maxBgNSigma < casc.invMassNSigma(Index) && casc.invMassNSigma(Index) < -massWindowConfigurations.minBgNSigma) || (+massWindowConfigurations.minBgNSigma < casc.invMassNSigma(Index) && casc.invMassNSigma(Index) < +massWindowConfigurations.maxBgNSigma)) { + histos.fill(HIST("h") + HIST(kCascadenames[Index]) + HIST("EtaVsPtVsPhiBg"), cascData.pt(), cascData.eta(), cascData.phi(), weight); } } - if (-massWindowConfigurations.maxPeakNSigma < casc.invMassNSigma(index) && casc.invMassNSigma(index) < +massWindowConfigurations.maxPeakNSigma) { - histos.fill(HIST("h") + HIST(cascadenames[index]) + HIST("EtaVsPtVsPhi"), cascData.pt(), cascData.eta(), cascData.phi(), weight); - } - - if ((-massWindowConfigurations.maxBgNSigma < casc.invMassNSigma(index) && casc.invMassNSigma(index) < -massWindowConfigurations.minBgNSigma) || (+massWindowConfigurations.minBgNSigma < casc.invMassNSigma(index) && casc.invMassNSigma(index) < +massWindowConfigurations.maxBgNSigma)) - histos.fill(HIST("h") + HIST(cascadenames[index]) + HIST("EtaVsPtVsPhiBg"), cascData.pt(), cascData.eta(), cascData.phi(), weight); } }); } @@ -1100,27 +1768,33 @@ struct correlateStrangeness { auto track = triggerTrack.track_as(); if (!isValidTrigger(track)) continue; - histos.fill(HIST("hTriggerAllSelectedEtaVsPt"), track.pt(), track.eta(), collision.centFT0M()); + histos.fill(HIST("hTriggerAllSelectedEtaVsPt"), track.pt(), track.eta(), cent); histos.fill(HIST("hTriggerPtResolution"), track.pt(), triggerTrack.mcOriginalPt()); if (doTriggPhysicalPrimary && !triggerTrack.mcPhysicalPrimary()) continue; - histos.fill(HIST("hTriggerPrimaryEtaVsPt"), track.pt(), track.eta(), collision.centFT0M()); + histos.fill(HIST("hTriggerPrimaryEtaVsPt"), track.pt(), track.eta(), cent); histos.fill(HIST("hTrackEtaVsPtVsPhi"), track.pt(), track.eta(), track.phi()); } // ________________________________________________ // Do hadron - cascade correlations - fillCorrelationsCascade(triggerTracks, associatedCascades, false, collision.posX(), collision.posY(), collision.posZ(), collision.centFT0M()); + fillCorrelationsCascade(triggerTracks, associatedCascades, false, collision.posX(), collision.posY(), collision.posZ(), cent, bField); } void processSameEventHPions(soa::Join::iterator const& collision, - aod::AssocHadrons const& associatedPions, aod::TriggerTracks const& triggerTracks, + soa::Join const& associatedPions, soa::Join const& triggerTracks, TracksComplete const&, aod::BCsWithTimestamps const&) { // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && !bitcheck(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { + if (triggerPresenceMap.size() > 0 && !TESTBIT(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { return; } + auto bc = collision.bc_as(); + auto bField = getMagneticField(bc.timestamp()); + + if (applyEfficiencyCorrection) { + initEfficiencyFromCCDB(bc); + } // ________________________________________________ // Perform basic event selection @@ -1128,7 +1802,7 @@ struct correlateStrangeness { return; } // ________________________________________________ - if (!doprocessSameEventHCascades && !doprocessSameEventHV0s) { + if (!doprocessSameEventHCascades && !doprocessSameEventHV0s && doMixingQAandEventQA) { histos.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({collision.posZ(), collision.centFT0M()})); histos.fill(HIST("EventQA/hMult"), collision.centFT0M()); histos.fill(HIST("EventQA/hPvz"), collision.posZ()); @@ -1154,18 +1828,23 @@ struct correlateStrangeness { // ________________________________________________ // Do hadron - Pion correlations - fillCorrelationsHadron(triggerTracks, associatedPions, false, collision.posZ(), collision.centFT0M(), 8); + fillCorrelationsHadron(triggerTracks, associatedPions, false, collision.posZ(), collision.centFT0M(), bField); } void processMixedEventHHadrons(soa::Join const& collisions, aod::AssocHadrons const& assocHadrons, aod::TriggerTracks const& triggerTracks, - TracksComplete const&) + TracksComplete const&, aod::BCsWithTimestamps const&) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, mixingParameter, -1, collisions, collisions)) { - + for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, mixingParameter, -1, collisions, collisions)) { + auto bc = collision1.bc_as(); + auto bField = getMagneticField(bc.timestamp()); + // ________________________________________________ + if (applyEfficiencyCorrection) { + initEfficiencyFromCCDB(bc); + } // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && (!bitcheck(triggerPresenceMap[collision1.globalIndex()], triggerBinToSelect) || !bitcheck(triggerPresenceMap[collision2.globalIndex()], triggerBinToSelect))) { + if (triggerPresenceMap.size() > 0 && (!TESTBIT(triggerPresenceMap[collision1.globalIndex()], triggerBinToSelect) || !TESTBIT(triggerPresenceMap[collision2.globalIndex()], triggerBinToSelect))) { return; } @@ -1178,56 +1857,62 @@ struct correlateStrangeness { continue; if (collision2.centFT0M() > axisRanges[5][1] || collision2.centFT0M() < axisRanges[5][0]) continue; - - if (collision1.globalIndex() == collision2.globalIndex()) { - histos.fill(HIST("MixingQA/hMixingQA"), 0.0f); // same-collision pair counting + if (doMixingQAandEventQA) { + if (collision1.globalIndex() == collision2.globalIndex()) { + histos.fill(HIST("MixingQA/hMixingQA"), 0.0f); // same-collision pair counting + } + histos.fill(HIST("MixingQA/hMEpvz1"), collision1.posZ()); + histos.fill(HIST("MixingQA/hMEpvz2"), collision2.posZ()); + histos.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), collision1.centFT0M()})); } - - histos.fill(HIST("MixingQA/hMEpvz1"), collision1.posZ()); - histos.fill(HIST("MixingQA/hMEpvz2"), collision2.posZ()); - histos.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), collision1.centFT0M()})); // ________________________________________________ // Do slicing auto slicedTriggerTracks = triggerTracks.sliceBy(collisionSliceTracks, collision1.globalIndex()); auto slicedAssocHadrons = assocHadrons.sliceBy(collisionSliceHadrons, collision2.globalIndex()); // ________________________________________________ // Do hadron - hadron correlations - fillCorrelationsHadron(slicedTriggerTracks, slicedAssocHadrons, true, collision1.posZ(), collision1.centFT0M(), 7); + fillCorrelationsHadron(slicedTriggerTracks, slicedAssocHadrons, true, collision1.posZ(), collision1.centFT0M(), bField); } } - void processMixedEventHV0s(soa::Join const& collisions, + void processMixedEventHV0s(soa::Join const& collisions, aod::AssocV0s const& associatedV0s, aod::TriggerTracks const& triggerTracks, - V0DatasWithoutTrackX const&, aod::V0sLinked const&, TracksComplete const&, aod::BCsWithTimestamps const&) + V0DatasWithoutTrackX const&, TracksComplete const&, aod::BCsWithTimestamps const&) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, mixingParameter, -1, collisions, collisions)) { + if (!doPPAnalysis) { + BinningTypePbPb colBinning{{axisVtxZ, axisMult}, true}; + } + for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, mixingParameter, -1, collisions, collisions)) { + double cent1 = doPPAnalysis ? collision1.centFT0M() : collision1.centFT0C(); + double cent2 = doPPAnalysis ? collision2.centFT0M() : collision2.centFT0C(); + auto bc = collision1.bc_as(); + auto bField = getMagneticField(bc.timestamp()); // ________________________________________________ if (applyEfficiencyCorrection) { - auto bc = collision1.bc_as(); initEfficiencyFromCCDB(bc); } // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && (!bitcheck(triggerPresenceMap[collision1.globalIndex()], triggerBinToSelect) || !bitcheck(triggerPresenceMap[collision2.globalIndex()], triggerBinToSelect))) { + if (triggerPresenceMap.size() > 0 && (!TESTBIT(triggerPresenceMap[collision1.globalIndex()], triggerBinToSelect) || !TESTBIT(triggerPresenceMap[collision2.globalIndex()], triggerBinToSelect))) { continue; } // Perform basic event selection on both collisions - if (!isCollisionSelected(collision1) || !isCollisionSelected(collision2)) { + if ((doPPAnalysis && (!isCollisionSelected(collision1) || !isCollisionSelected(collision2))) || (!doPPAnalysis && (!isCollisionSelectedPbPb(collision1, true) || (!isCollisionSelectedPbPb(collision2, true))))) { continue; } - if (collision1.centFT0M() > axisRanges[5][1] || collision1.centFT0M() < axisRanges[5][0]) + if (cent1 > axisRanges[5][1] || cent1 < axisRanges[5][0]) continue; - if (collision2.centFT0M() > axisRanges[5][1] || collision2.centFT0M() < axisRanges[5][0]) + if (cent2 > axisRanges[5][1] || cent2 < axisRanges[5][0]) continue; - if (!doprocessMixedEventHCascades) { + if (!doprocessMixedEventHCascades && doMixingQAandEventQA) { if (collision1.globalIndex() == collision2.globalIndex()) { histos.fill(HIST("MixingQA/hMixingQA"), 0.0f); // same-collision pair counting } histos.fill(HIST("MixingQA/hMEpvz1"), collision1.posZ()); histos.fill(HIST("MixingQA/hMEpvz2"), collision2.posZ()); - histos.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), collision1.centFT0M()})); + histos.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), cent1})); } // ________________________________________________ // Do slicing @@ -1235,59 +1920,70 @@ struct correlateStrangeness { auto slicedAssocV0s = associatedV0s.sliceBy(collisionSliceV0s, collision2.globalIndex()); // ________________________________________________ // Do hadron - V0 correlations - fillCorrelationsV0(slicedTriggerTracks, slicedAssocV0s, true, collision1.posZ(), collision1.centFT0M()); + fillCorrelationsV0(slicedTriggerTracks, slicedAssocV0s, true, collision1.posX(), collision1.posY(), collision1.posZ(), cent1, bField); } } - void processMixedEventHCascades(soa::Join const& collisions, + void processMixedEventHCascades(soa::Join const& collisions, aod::AssocV0s const&, aod::AssocCascades const& associatedCascades, aod::TriggerTracks const& triggerTracks, - V0DatasWithoutTrackX const&, aod::V0sLinked const&, aod::CascDatas const&, TracksComplete const&, aod::BCsWithTimestamps const&) + V0DatasWithoutTrackX const&, aod::CascDatas const&, TracksComplete const&, aod::BCsWithTimestamps const&) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, mixingParameter, -1, collisions, collisions)) { + if (!doPPAnalysis) { + BinningTypePbPb colBinning{{axisVtxZ, axisMult}, true}; + } + for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, mixingParameter, -1, collisions, collisions)) { + double cent1 = doPPAnalysis ? collision1.centFT0M() : collision1.centFT0C(); + double cent2 = doPPAnalysis ? collision2.centFT0M() : collision2.centFT0C(); // ________________________________________________ + auto bc = collision1.bc_as(); + auto bField = getMagneticField(bc.timestamp()); if (applyEfficiencyCorrection) { - auto bc = collision1.bc_as(); initEfficiencyFromCCDB(bc); } // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && (!bitcheck(triggerPresenceMap[collision1.globalIndex()], triggerBinToSelect) || !bitcheck(triggerPresenceMap[collision2.globalIndex()], triggerBinToSelect))) { + if (triggerPresenceMap.size() > 0 && (!TESTBIT(triggerPresenceMap[collision1.globalIndex()], triggerBinToSelect) || !TESTBIT(triggerPresenceMap[collision2.globalIndex()], triggerBinToSelect))) { continue; } // Perform basic event selection on both collisions - if (!isCollisionSelected(collision1) || !isCollisionSelected(collision2)) { + if ((doPPAnalysis && (!isCollisionSelected(collision1) || !isCollisionSelected(collision2))) || (!doPPAnalysis && (!isCollisionSelectedPbPb(collision1, true) || (!isCollisionSelectedPbPb(collision2, true))))) { continue; } - if (collision1.centFT0M() > axisRanges[5][1] || collision1.centFT0M() < axisRanges[5][0]) + if (cent1 > axisRanges[5][1] || cent1 < axisRanges[5][0]) continue; - if (collision2.centFT0M() > axisRanges[5][1] || collision2.centFT0M() < axisRanges[5][0]) + if (cent2 > axisRanges[5][1] || cent2 < axisRanges[5][0]) continue; - - if (collision1.globalIndex() == collision2.globalIndex()) { - histos.fill(HIST("MixingQA/hMixingQA"), 0.0f); // same-collision pair counting + if (doMixingQAandEventQA) { + if (collision1.globalIndex() == collision2.globalIndex()) { + histos.fill(HIST("MixingQA/hMixingQA"), 0.0f); // same-collision pair counting + } + histos.fill(HIST("MixingQA/hMEpvz1"), collision1.posZ()); + histos.fill(HIST("MixingQA/hMEpvz2"), collision2.posZ()); + histos.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), cent1})); } - - histos.fill(HIST("MixingQA/hMEpvz1"), collision1.posZ()); - histos.fill(HIST("MixingQA/hMEpvz2"), collision2.posZ()); - histos.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), collision1.centFT0M()})); // ________________________________________________ // Do slicing auto slicedTriggerTracks = triggerTracks.sliceBy(collisionSliceTracks, collision1.globalIndex()); auto slicedAssocCascades = associatedCascades.sliceBy(collisionSliceCascades, collision2.globalIndex()); // ________________________________________________ // Do hadron - cascade correlations - fillCorrelationsCascade(slicedTriggerTracks, slicedAssocCascades, true, collision1.posX(), collision1.posY(), collision1.posZ(), collision1.centFT0M()); + fillCorrelationsCascade(slicedTriggerTracks, slicedAssocCascades, true, collision1.posX(), collision1.posY(), collision1.posZ(), cent1, bField); } } void processMixedEventHPions(soa::Join const& collisions, - aod::AssocHadrons const& assocPions, aod::TriggerTracks const& triggerTracks, - TracksComplete const&) + soa::Join const& assocPions, soa::Join const& triggerTracks, + TracksComplete const&, aod::BCsWithTimestamps const&) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, mixingParameter, -1, collisions, collisions)) { - + for (auto const& [collision1, collision2] : soa::selfCombinations(colBinning, mixingParameter, -1, collisions, collisions)) { + auto bc = collision1.bc_as(); + auto bField = getMagneticField(bc.timestamp()); + // ________________________________________________ + if (applyEfficiencyCorrection) { + initEfficiencyFromCCDB(bc); + } // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && (!bitcheck(triggerPresenceMap[collision1.globalIndex()], triggerBinToSelect) || !bitcheck(triggerPresenceMap[collision2.globalIndex()], triggerBinToSelect))) { + if (triggerPresenceMap.size() > 0 && (!TESTBIT(triggerPresenceMap[collision1.globalIndex()], triggerBinToSelect) || !TESTBIT(triggerPresenceMap[collision2.globalIndex()], triggerBinToSelect))) { continue; } @@ -1300,21 +1996,21 @@ struct correlateStrangeness { continue; if (collision2.centFT0M() > axisRanges[5][1] || collision2.centFT0M() < axisRanges[5][0]) continue; - - if (collision1.globalIndex() == collision2.globalIndex()) { - histos.fill(HIST("MixingQA/hMixingQA"), 0.0f); // same-collision pair counting + if (doMixingQAandEventQA) { + if (collision1.globalIndex() == collision2.globalIndex()) { + histos.fill(HIST("MixingQA/hMixingQA"), 0.0f); // same-collision pair counting + } + histos.fill(HIST("MixingQA/hMEpvz1"), collision1.posZ()); + histos.fill(HIST("MixingQA/hMEpvz2"), collision2.posZ()); + histos.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), collision1.centFT0M()})); } - - histos.fill(HIST("MixingQA/hMEpvz1"), collision1.posZ()); - histos.fill(HIST("MixingQA/hMEpvz2"), collision2.posZ()); - histos.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), collision1.centFT0M()})); // ________________________________________________ // Do slicing auto slicedTriggerTracks = triggerTracks.sliceBy(collisionSliceTracks, collision1.globalIndex()); auto slicedAssocPions = assocPions.sliceBy(collisionSliceHadrons, collision2.globalIndex()); // ________________________________________________ // Do hadron - cascade correlations - fillCorrelationsHadron(slicedTriggerTracks, slicedAssocPions, true, collision1.posZ(), collision1.centFT0M(), 8); + fillCorrelationsHadron(slicedTriggerTracks, slicedAssocPions, true, collision1.posZ(), collision1.centFT0M(), bField); } } @@ -1323,35 +2019,35 @@ struct correlateStrangeness { histos.fill(HIST("hClosureTestEventCounter"), 2.5f); for (auto const& mcParticle : mcParticles) { - Double_t geta = mcParticle.eta(); - if (std::abs(geta) > 0.8f) { + double geta = mcParticle.eta(); + if (std::abs(geta) > etaSel) { continue; } - Double_t gpt = mcParticle.pt(); - if (abs(mcParticle.pdgCode()) == 211 || abs(mcParticle.pdgCode()) == 321 || abs(mcParticle.pdgCode()) == 2212 || abs(mcParticle.pdgCode()) == 11 || abs(mcParticle.pdgCode()) == 13) { + double gpt = mcParticle.pt(); + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kKPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kProton || std::abs(mcParticle.pdgCode()) == PDG_t::kElectron || std::abs(mcParticle.pdgCode()) == PDG_t::kMuonMinus) { if (!doTriggPhysicalPrimary || mcParticle.isPhysicalPrimary()) { histos.fill(HIST("hGeneratedQAPtTrigger"), gpt, 0.0f); // step 1: before all selections } } if (!doAssocPhysicalPrimary || mcParticle.isPhysicalPrimary()) { - if (abs(mcParticle.pdgCode()) == 310 && doCorrelationK0Short) { + if (mcParticle.pdgCode() == PDG_t::kK0Short && doCorrelationK0Short) { histos.fill(HIST("hGeneratedQAPtAssociatedK0"), gpt, 0.0f); // step 1: before all selections } } } for (auto const& mcParticle : mcParticles) { - if (!mcParticle.isPhysicalPrimary()) + if (doAssocPhysicalPrimaryInGen && !mcParticle.isPhysicalPrimary()) continue; static_for<0, 7>([&](auto i) { - constexpr int index = i.value; + constexpr int Index = i.value; if (i == 0 || i == 7) { - if (abs(mcParticle.pdgCode()) == pdgCodes[i]) - histos.fill(HIST("Generated/h") + HIST(particlenames[index]), mcParticle.pt(), mcParticle.eta()); + if (std::abs(mcParticle.pdgCode()) == kPdgCodes[i]) + histos.fill(HIST("Generated/h") + HIST(kParticlenames[Index]), mcParticle.pt(), mcParticle.eta()); } else { - if (mcParticle.pdgCode() == pdgCodes[i]) - histos.fill(HIST("Generated/h") + HIST(particlenames[index]), mcParticle.pt(), mcParticle.eta()); + if (mcParticle.pdgCode() == kPdgCodes[i]) + histos.fill(HIST("Generated/h") + HIST(kParticlenames[Index]), mcParticle.pt(), mcParticle.eta()); } }); } @@ -1366,7 +2062,7 @@ struct correlateStrangeness { bool bestCollisionINELgtZERO = false; uint32_t bestCollisionTriggerPresenceMap = 0; - for (auto& collision : collisions) { + for (auto const& collision : collisions) { if (biggestNContribs < collision.numContrib()) { biggestNContribs = collision.numContrib(); bestCollisionFT0Mpercentile = collision.centFT0M(); @@ -1380,18 +2076,18 @@ struct correlateStrangeness { if (collisions.size() > 1) { for (auto const& mcParticle : mcParticles) { - if (!mcParticle.isPhysicalPrimary()) + if (doAssocPhysicalPrimaryInGen && !mcParticle.isPhysicalPrimary()) continue; - if (abs(mcParticle.y()) > 0.5) + if (std::abs(mcParticle.y()) > ySel) continue; static_for<0, 7>([&](auto i) { - constexpr int index = i.value; + constexpr int Index = i.value; if (i == 0 || i == 7) { - if (abs(mcParticle.pdgCode()) == pdgCodes[i]) - histos.fill(HIST("GeneratedWithPV/h") + HIST(particlenames[index]) + HIST("_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); + if (std::abs(mcParticle.pdgCode()) == kPdgCodes[i]) + histos.fill(HIST("GeneratedWithPV/h") + HIST(kParticlenames[Index]) + HIST("_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); } else { - if (mcParticle.pdgCode() == pdgCodes[i]) - histos.fill(HIST("GeneratedWithPV/h") + HIST(particlenames[index]) + HIST("_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); + if (mcParticle.pdgCode() == kPdgCodes[i]) + histos.fill(HIST("GeneratedWithPV/h") + HIST(kParticlenames[Index]) + HIST("_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); } }); } @@ -1403,7 +2099,7 @@ struct correlateStrangeness { // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && !bitcheck(bestCollisionTriggerPresenceMap, triggerBinToSelect)) { + if (triggerPresenceMap.size() > 0 && !TESTBIT(bestCollisionTriggerPresenceMap, triggerBinToSelect)) { return; } if (!bestCollisionSel8) @@ -1416,46 +2112,87 @@ struct correlateStrangeness { histos.fill(HIST("hClosureTestEventCounter"), 3.5f); for (auto const& mcParticle : mcParticles) { - Double_t geta = mcParticle.eta(); - if (std::abs(geta) > 0.8f) { + double geta = mcParticle.eta(); + if (std::abs(geta) > etaSel) { continue; } - Double_t gpt = mcParticle.pt(); - if (abs(mcParticle.pdgCode()) == 211 || abs(mcParticle.pdgCode()) == 321 || abs(mcParticle.pdgCode()) == 2212 || abs(mcParticle.pdgCode()) == 11 || abs(mcParticle.pdgCode()) == 13) { + double gpt = mcParticle.pt(); + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kKPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kProton || std::abs(mcParticle.pdgCode()) == PDG_t::kElectron || std::abs(mcParticle.pdgCode()) == PDG_t::kMuonMinus) { if (!doTriggPhysicalPrimary || mcParticle.isPhysicalPrimary()) { histos.fill(HIST("hGeneratedQAPtTrigger"), gpt, 1.0f); // step 2: after event selection } } if (!doAssocPhysicalPrimary || mcParticle.isPhysicalPrimary()) { - if (abs(mcParticle.pdgCode()) == 310 && doCorrelationK0Short) { + if (mcParticle.pdgCode() == PDG_t::kK0Short && doCorrelationK0Short) { histos.fill(HIST("hGeneratedQAPtAssociatedK0"), gpt, 1.0f); // step 2: before all selections } } } for (auto const& mcParticle : mcParticles) { - if (!mcParticle.isPhysicalPrimary()) { + if (doAssocPhysicalPrimaryInGen && !mcParticle.isPhysicalPrimary()) { continue; } - Double_t geta = mcParticle.eta(); - Double_t gpt = mcParticle.pt(); - if (abs(mcParticle.pdgCode()) == 211 || abs(mcParticle.pdgCode()) == 321 || abs(mcParticle.pdgCode()) == 2212 || abs(mcParticle.pdgCode()) == 11 || abs(mcParticle.pdgCode()) == 13) + double geta = mcParticle.eta(); + double gpt = mcParticle.pt(); + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kKPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kProton || std::abs(mcParticle.pdgCode()) == PDG_t::kElectron || std::abs(mcParticle.pdgCode()) == PDG_t::kMuonMinus) histos.fill(HIST("GeneratedWithPV/hTrigger"), gpt, geta); + if (mcParticle.pdgCode() == PDG_t::kLambda0 && !doAssocPhysicalPrimaryInGen && !mcParticle.isPhysicalPrimary()) { + if (std::abs(geta) > etaSel) { + continue; + } + auto lamMothers = mcParticle.mothers_as(); + if (lamMothers.size() == 1) { + for (const auto& lamParticleMother : lamMothers) { + if (std::abs(lamParticleMother.eta()) > etaSel) { + continue; + } + if (lamParticleMother.pdgCode() == PDG_t::kXiMinus) // Xi Minus Mother Matched + { + histos.fill(HIST("GeneratedWithPV/hLambdaFromXiMinus"), gpt, geta); + } + if (lamParticleMother.pdgCode() == o2::constants::physics::Pdg::kXi0) // Xi Zero Mother Matched + { + histos.fill(HIST("GeneratedWithPV/hLambdaFromXiZero"), gpt, geta); + } + } + } + } + if (mcParticle.pdgCode() == PDG_t::kLambda0Bar && !doAssocPhysicalPrimaryInGen && !mcParticle.isPhysicalPrimary()) { + if (std::abs(geta) > etaSel) { + continue; + } + auto lamMothers = mcParticle.mothers_as(); + if (lamMothers.size() == 1) { + for (const auto& lamParticleMother : lamMothers) { + if (std::abs(lamParticleMother.eta()) > etaSel) { + continue; + } + if (lamParticleMother.pdgCode() == PDG_t::kXiPlusBar) { + histos.fill(HIST("GeneratedWithPV/hAntiLambdaFromXiPlus"), gpt, geta); + } + if (lamParticleMother.pdgCode() == -o2::constants::physics::Pdg::kXi0) // Xi Zero Mother Matched + { + histos.fill(HIST("GeneratedWithPV/hAntiLambdaFromXiZero"), gpt, geta); + } + } + } + } static_for<0, 7>([&](auto i) { - constexpr int index = i.value; + constexpr int Index = i.value; if (i == 0 || i == 7) { - if (abs(mcParticle.pdgCode()) == pdgCodes[i]) { - histos.fill(HIST("GeneratedWithPV/h") + HIST(particlenames[index]), gpt, geta); - if (abs(mcParticle.y()) < 0.5) - histos.fill(HIST("GeneratedWithPV/h") + HIST(particlenames[index]) + HIST("_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); + if (std::abs(mcParticle.pdgCode()) == kPdgCodes[i]) { + histos.fill(HIST("GeneratedWithPV/h") + HIST(kParticlenames[Index]), gpt, geta); + if (std::abs(mcParticle.y()) < ySel) + histos.fill(HIST("GeneratedWithPV/h") + HIST(kParticlenames[Index]) + HIST("_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); } } else { - if (mcParticle.pdgCode() == pdgCodes[i]) { - histos.fill(HIST("GeneratedWithPV/h") + HIST(particlenames[index]), gpt, geta); - if (abs(mcParticle.y()) < 0.5) - histos.fill(HIST("GeneratedWithPV/h") + HIST(particlenames[index]) + HIST("_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); + if (mcParticle.pdgCode() == kPdgCodes[i]) { + histos.fill(HIST("GeneratedWithPV/h") + HIST(kParticlenames[Index]), gpt, geta); + if (std::abs(mcParticle.y()) < ySel) + histos.fill(HIST("GeneratedWithPV/h") + HIST(kParticlenames[Index]) + HIST("_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); } } }); @@ -1466,6 +2203,7 @@ struct correlateStrangeness { std::vector triggerIndices; std::vector> associatedIndices; + std::vector assocHadronIndices; std::vector piIndices; std::vector k0ShortIndices; std::vector lambdaIndices; @@ -1476,19 +2214,19 @@ struct correlateStrangeness { std::vector omegaPlusIndices; for (auto const& mcParticle : mcParticles) { - Double_t geta = mcParticle.eta(); - if (std::abs(geta) > 0.8f) { + double geta = mcParticle.eta(); + if (std::abs(geta) > etaSel) { continue; } - Double_t gpt = mcParticle.pt(); - if (abs(mcParticle.pdgCode()) == 211 || abs(mcParticle.pdgCode()) == 321 || abs(mcParticle.pdgCode()) == 2212 || abs(mcParticle.pdgCode()) == 11 || abs(mcParticle.pdgCode()) == 13) { + double gpt = mcParticle.pt(); + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kKPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kProton || std::abs(mcParticle.pdgCode()) == PDG_t::kElectron || std::abs(mcParticle.pdgCode()) == PDG_t::kMuonMinus) { if (!doTriggPhysicalPrimary || mcParticle.isPhysicalPrimary()) { histos.fill(HIST("hClosureQAPtTrigger"), gpt, 0.0f); // step 1: no event selection whatsoever } } if (!doAssocPhysicalPrimary || mcParticle.isPhysicalPrimary()) { - if (abs(mcParticle.pdgCode()) == 310 && doCorrelationK0Short) { + if (mcParticle.pdgCode() == PDG_t::kK0Short && doCorrelationK0Short) { histos.fill(HIST("hClosureQAPtAssociatedK0"), gpt, 0.0f); // step 1: no event selection whatsoever } } @@ -1503,7 +2241,7 @@ struct correlateStrangeness { int biggestNContribs = -1; uint32_t bestCollisionTriggerPresenceMap = 0; - for (auto& recCollision : recCollisions) { + for (auto const& recCollision : recCollisions) { if (biggestNContribs < recCollision.numContrib()) { biggestNContribs = recCollision.numContrib(); bestCollisionFT0Mpercentile = recCollision.centFT0M(); @@ -1516,7 +2254,7 @@ struct correlateStrangeness { } // ________________________________________________ // skip if desired trigger not found - if (triggerPresenceMap.size() > 0 && !bitcheck(bestCollisionTriggerPresenceMap, triggerBinToSelect)) { + if (triggerPresenceMap.size() > 0 && !TESTBIT(bestCollisionTriggerPresenceMap, triggerBinToSelect)) { return; } @@ -1535,19 +2273,19 @@ struct correlateStrangeness { histos.fill(HIST("hClosureTestEventCounter"), 1.5f); for (auto const& mcParticle : mcParticles) { - Double_t geta = mcParticle.eta(); - if (std::abs(geta) > 0.8f) { + double geta = mcParticle.eta(); + if (std::abs(geta) > etaSel) { continue; } - Double_t gpt = mcParticle.pt(); - if (abs(mcParticle.pdgCode()) == 211 || abs(mcParticle.pdgCode()) == 321 || abs(mcParticle.pdgCode()) == 2212 || abs(mcParticle.pdgCode()) == 11 || abs(mcParticle.pdgCode()) == 13) { + double gpt = mcParticle.pt(); + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kKPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kProton || std::abs(mcParticle.pdgCode()) == PDG_t::kElectron || std::abs(mcParticle.pdgCode()) == PDG_t::kMuonMinus) { if (!doTriggPhysicalPrimary || mcParticle.isPhysicalPrimary()) { histos.fill(HIST("hClosureQAPtTrigger"), gpt, 1.0f); // step 2: after event selection } } if (!doAssocPhysicalPrimary || mcParticle.isPhysicalPrimary()) { - if (abs(mcParticle.pdgCode()) == 310 && doCorrelationK0Short) { + if (mcParticle.pdgCode() == PDG_t::kK0Short && doCorrelationK0Short) { histos.fill(HIST("hClosureQAPtAssociatedK0"), gpt, 1.0f); // step 2: after event selection } } @@ -1556,48 +2294,52 @@ struct correlateStrangeness { int iteratorNum = -1; for (auto const& mcParticle : mcParticles) { iteratorNum = iteratorNum + 1; - Double_t geta = mcParticle.eta(); - Double_t gpt = mcParticle.pt(); - Double_t gphi = mcParticle.phi(); - if (std::abs(geta) > 0.8f) { + double geta = mcParticle.eta(); + double gpt = mcParticle.pt(); + double gphi = mcParticle.phi(); + if (std::abs(geta) > etaSel) { continue; } - if (abs(mcParticle.pdgCode()) == 211 || abs(mcParticle.pdgCode()) == 321 || abs(mcParticle.pdgCode()) == 2212 || abs(mcParticle.pdgCode()) == 11 || abs(mcParticle.pdgCode()) == 13) { + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kKPlus || std::abs(mcParticle.pdgCode()) == PDG_t::kProton || std::abs(mcParticle.pdgCode()) == PDG_t::kElectron || std::abs(mcParticle.pdgCode()) == PDG_t::kMuonMinus) { if (!doTriggPhysicalPrimary || mcParticle.isPhysicalPrimary()) { triggerIndices.emplace_back(iteratorNum); histos.fill(HIST("ClosureTest/hTrigger"), gpt, geta, bestCollisionFT0Mpercentile); + if (doCorrelationHadron) { + assocHadronIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hHadron"), gpt, geta, bestCollisionFT0Mpercentile); + } } } if (!doAssocPhysicalPrimary || mcParticle.isPhysicalPrimary()) { - if (abs(mcParticle.pdgCode()) == 211 && doCorrelationPion) { + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus && doCorrelationPion) { piIndices.emplace_back(iteratorNum); histos.fill(HIST("ClosureTest/hPion"), gpt, geta, gphi); } - if (abs(mcParticle.pdgCode()) == 310 && doCorrelationK0Short) { + if (mcParticle.pdgCode() == PDG_t::kK0Short && doCorrelationK0Short) { k0ShortIndices.emplace_back(iteratorNum); histos.fill(HIST("ClosureTest/hK0Short"), gpt, geta, gphi); } - if (mcParticle.pdgCode() == 3122 && doCorrelationLambda) { + if (mcParticle.pdgCode() == PDG_t::kLambda0 && doCorrelationLambda) { lambdaIndices.emplace_back(iteratorNum); histos.fill(HIST("ClosureTest/hLambda"), gpt, geta, gphi); } - if (mcParticle.pdgCode() == -3122 && doCorrelationAntiLambda) { + if (mcParticle.pdgCode() == PDG_t::kLambda0Bar && doCorrelationAntiLambda) { antiLambdaIndices.emplace_back(iteratorNum); histos.fill(HIST("ClosureTest/hAntiLambda"), gpt, geta, gphi); } - if (mcParticle.pdgCode() == 3312 && doCorrelationXiMinus) { + if (mcParticle.pdgCode() == PDG_t::kXiMinus && doCorrelationXiMinus) { xiMinusIndices.emplace_back(iteratorNum); histos.fill(HIST("ClosureTest/hXiMinus"), gpt, geta, gphi); } - if (mcParticle.pdgCode() == -3312 && doCorrelationXiPlus) { + if (mcParticle.pdgCode() == PDG_t::kXiPlusBar && doCorrelationXiPlus) { xiPlusIndices.emplace_back(iteratorNum); histos.fill(HIST("ClosureTest/hXiPlus"), gpt, geta, gphi); } - if (mcParticle.pdgCode() == 3334 && doCorrelationOmegaMinus) { + if (mcParticle.pdgCode() == PDG_t::kOmegaMinus && doCorrelationOmegaMinus) { omegaMinusIndices.emplace_back(iteratorNum); histos.fill(HIST("ClosureTest/hOmegaMinus"), gpt, geta, gphi); } - if (mcParticle.pdgCode() == -3334 && doCorrelationOmegaPlus) { + if (mcParticle.pdgCode() == PDG_t::kOmegaPlusBar && doCorrelationOmegaPlus) { omegaPlusIndices.emplace_back(iteratorNum); histos.fill(HIST("ClosureTest/hOmegaPlus"), gpt, geta, gphi); } @@ -1612,6 +2354,7 @@ struct correlateStrangeness { associatedIndices.emplace_back(omegaMinusIndices); associatedIndices.emplace_back(omegaPlusIndices); associatedIndices.emplace_back(piIndices); + associatedIndices.emplace_back(assocHadronIndices); for (std::size_t iTrigger = 0; iTrigger < triggerIndices.size(); iTrigger++) { auto triggerParticle = mcParticles.iteratorAt(triggerIndices[iTrigger]); @@ -1619,21 +2362,21 @@ struct correlateStrangeness { if (triggerParticle.pt() > axisRanges[3][1] || triggerParticle.pt() < axisRanges[3][0]) { continue; } - Double_t getatrigger = triggerParticle.eta(); - Double_t gphitrigger = triggerParticle.phi(); - Double_t pttrigger = triggerParticle.pt(); + double getatrigger = triggerParticle.eta(); + double gphitrigger = triggerParticle.phi(); + double pttrigger = triggerParticle.pt(); auto const& mother = triggerParticle.mothers_first_as(); auto globalIndex = mother.globalIndex(); - static_for<0, 7>([&](auto i) { // associated loop - constexpr int index = i.value; - for (std::size_t iassoc = 0; iassoc < associatedIndices[index].size(); iassoc++) { - auto assocParticle = mcParticles.iteratorAt(associatedIndices[index][iassoc]); - if (triggerIndices[iTrigger] != associatedIndices[index][iassoc] && globalIndex != assocParticle.globalIndex()) { // avoid self - Double_t getaassoc = assocParticle.eta(); - Double_t gphiassoc = assocParticle.phi(); - Double_t ptassoc = assocParticle.pt(); - Double_t deltaphi = ComputeDeltaPhi(gphitrigger, gphiassoc); - Double_t deltaeta = getatrigger - getaassoc; + static_for<0, 8>([&](auto i) { // associated loop + constexpr int Index = i.value; + for (std::size_t iassoc = 0; iassoc < associatedIndices[Index].size(); iassoc++) { + auto assocParticle = mcParticles.iteratorAt(associatedIndices[Index][iassoc]); + if (triggerIndices[iTrigger] != associatedIndices[Index][iassoc] && globalIndex != assocParticle.globalIndex()) { // avoid self + double getaassoc = assocParticle.eta(); + double gphiassoc = assocParticle.phi(); + double ptassoc = assocParticle.pt(); + double deltaphi = computeDeltaPhi(gphitrigger, gphiassoc); + double deltaeta = getatrigger - getaassoc; // skip if basic ranges not met if (deltaphi < axisRanges[0][0] || deltaphi > axisRanges[0][1]) @@ -1642,31 +2385,111 @@ struct correlateStrangeness { continue; if (ptassoc < axisRanges[2][0] || ptassoc > axisRanges[2][1]) continue; - if (bitcheck(doCorrelation, i)) - histos.fill(HIST("ClosureTest/sameEvent/") + HIST(particlenames[index]), ComputeDeltaPhi(gphitrigger, gphiassoc), deltaeta, ptassoc, pttrigger, bestCollisionVtxZ, bestCollisionFT0Mpercentile); + if (TESTBIT(doCorrelation, i)) + histos.fill(HIST("ClosureTest/sameEvent/") + HIST(kParticlenames[Index]), computeDeltaPhi(gphitrigger, gphiassoc), deltaeta, ptassoc, pttrigger, bestCollisionVtxZ, bestCollisionFT0Mpercentile); } } }); } } - PROCESS_SWITCH(correlateStrangeness, processSelectEventWithTrigger, "Select events with trigger only", true); - PROCESS_SWITCH(correlateStrangeness, processSameEventHV0s, "Process same events, h-V0s", true); - PROCESS_SWITCH(correlateStrangeness, processSameEventHCascades, "Process same events, h-Cascades", true); - PROCESS_SWITCH(correlateStrangeness, processSameEventHPions, "Process same events, h-Pion", true); - PROCESS_SWITCH(correlateStrangeness, processSameEventHHadrons, "Process same events, h-h", true); + void processFeedDown(soa::Join::iterator const& collision, aod::AssocV0s const& associatedV0s, aod::McParticles const&, V0DatasWithoutTrackXMC const&, TracksComplete const&, aod::BCsWithTimestamps const&) + { + + // ________________________________________________ + // Perform basic event selection + if (!isCollisionSelected(collision)) { + return; + } + + for (auto const& v0 : associatedV0s) { + auto v0Data = v0.v0Core_as(); + + //---] track quality check [--- + auto postrack = v0Data.posTrack_as(); + auto negtrack = v0Data.negTrack_as(); + if (postrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated || negtrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated) + continue; - PROCESS_SWITCH(correlateStrangeness, processMixedEventHV0s, "Process mixed events, h-V0s", true); - PROCESS_SWITCH(correlateStrangeness, processMixedEventHCascades, "Process mixed events, h-Cascades", true); - PROCESS_SWITCH(correlateStrangeness, processMixedEventHPions, "Process mixed events, h-Pion", true); - PROCESS_SWITCH(correlateStrangeness, processMixedEventHHadrons, "Process mixed events, h-h", true); + //---] syst cuts [--- + if (v0Data.v0radius() < systCuts.v0RadiusMin || v0Data.v0radius() > systCuts.v0RadiusMax || + std::abs(v0Data.dcapostopv()) < systCuts.dcapostopv || std::abs(v0Data.dcanegtopv()) < systCuts.dcanegtopv || + v0Data.v0cosPA() < systCuts.v0cospa || v0Data.dcaV0daughters() > systCuts.dcaV0dau) + continue; - PROCESS_SWITCH(correlateStrangeness, processMCGenerated, "Process MC generated", false); - PROCESS_SWITCH(correlateStrangeness, processClosureTest, "Process Closure Test", false); + if (v0Data.has_mcParticle()) { + auto v0mcParticle = v0Data.mcParticle_as(); + int mcParticlePdg = v0mcParticle.pdgCode(); + if (mcParticlePdg == PDG_t::kLambda0 && !v0mcParticle.isPhysicalPrimary()) { + auto v0mothers = v0mcParticle.mothers_as(); + if (v0mothers.size() == 1) { + for (const auto& v0mcParticleMother : v0mothers) { + // auto& v0mcParticleMother = v0mothers.front(); + if (std::abs(v0mcParticleMother.eta()) > etaSel) { + continue; + } + if (v0mcParticleMother.pdgCode() == PDG_t::kXiMinus) // Xi Minus Mother Matched + { + histos.fill(HIST("hLambdaXiMinusFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + histos.fill(HIST("hLambdaFromXiMinusEtaVsPtVsPhi"), v0mcParticle.pt(), v0mcParticle.eta(), v0mcParticle.phi()); + } + if (v0mcParticleMother.pdgCode() == o2::constants::physics::Pdg::kXi0) // Xi Zero Mother Matched + { + histos.fill(HIST("hLambdaXiZeroFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + histos.fill(HIST("hLambdaFromXiZeroEtaVsPtVsPhi"), v0mcParticle.pt(), v0mcParticle.eta(), v0mcParticle.phi()); + } + if (v0mcParticleMother.pdgCode() == PDG_t::kOmegaMinus) // Omega Mother Matched + { + histos.fill(HIST("hLambdaOmegaFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + } + } + } + } + if (mcParticlePdg == PDG_t::kLambda0Bar && !v0mcParticle.isPhysicalPrimary()) { + auto v0mothers = v0mcParticle.mothers_as(); + if (v0mothers.size() == 1) { + for (const auto& v0mcParticleMother : v0mothers) { + if (std::abs(v0mcParticleMother.eta()) > etaSel) { + continue; + } + if (v0mcParticleMother.pdgCode() == PDG_t::kXiPlusBar) // Xi Plus Mother Matched + { + histos.fill(HIST("hAntiLambdaXiPlusFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + histos.fill(HIST("hAntiLambdaFromXiPlusEtaVsPtVsPhi"), v0mcParticle.pt(), v0mcParticle.eta(), v0mcParticle.phi()); + } + if (v0mcParticleMother.pdgCode() == -o2::constants::physics::Pdg::kXi0) // Anti Xi Zero Mother Matched + { + histos.fill(HIST("hAntiLambdaXiZeroFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + histos.fill(HIST("hAntiLambdaFromXiZeroEtaVsPtVsPhi"), v0mcParticle.pt(), v0mcParticle.eta(), v0mcParticle.phi()); + } + if (v0mcParticleMother.pdgCode() == PDG_t::kOmegaPlusBar) // Omega Mother Matched + { + histos.fill(HIST("hAntiLambdaOmegaFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + } + } + } + } + } + } + } + PROCESS_SWITCH(HStrangeCorrelation, processSelectEventWithTrigger, "Select events with trigger only", true); + PROCESS_SWITCH(HStrangeCorrelation, processSameEventHV0s, "Process same events, h-V0s", true); + PROCESS_SWITCH(HStrangeCorrelation, processSameEventHCascades, "Process same events, h-Cascades", true); + PROCESS_SWITCH(HStrangeCorrelation, processSameEventHPions, "Process same events, h-Pion", true); + PROCESS_SWITCH(HStrangeCorrelation, processSameEventHHadrons, "Process same events, h-h", true); + + PROCESS_SWITCH(HStrangeCorrelation, processMixedEventHV0s, "Process mixed events, h-V0s", true); + PROCESS_SWITCH(HStrangeCorrelation, processMixedEventHCascades, "Process mixed events, h-Cascades", true); + PROCESS_SWITCH(HStrangeCorrelation, processMixedEventHPions, "Process mixed events, h-Pion", true); + PROCESS_SWITCH(HStrangeCorrelation, processMixedEventHHadrons, "Process mixed events, h-h", true); + + PROCESS_SWITCH(HStrangeCorrelation, processMCGenerated, "Process MC generated", false); + PROCESS_SWITCH(HStrangeCorrelation, processClosureTest, "Process Closure Test", false); + PROCESS_SWITCH(HStrangeCorrelation, processFeedDown, "process Feed Down", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Strangeness/hyperon-reco-test.cxx b/PWGLF/Tasks/Strangeness/hyperon-reco-test.cxx index da2a9b0bd0b..5605730d709 100644 --- a/PWGLF/Tasks/Strangeness/hyperon-reco-test.cxx +++ b/PWGLF/Tasks/Strangeness/hyperon-reco-test.cxx @@ -1,4 +1,4 @@ -// Copyright 2020-2022 CERN and copyright holders of ALICE O2. +// Copyright 2020-2025 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. // diff --git a/PWGLF/Tasks/Strangeness/k0_mixed_events.cxx b/PWGLF/Tasks/Strangeness/k0_mixed_events.cxx index 90ff4382b41..5de8a32c122 100644 --- a/PWGLF/Tasks/Strangeness/k0_mixed_events.cxx +++ b/PWGLF/Tasks/Strangeness/k0_mixed_events.cxx @@ -9,6 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // +/// \file k0_mixed_events.cxx /// \brief Femto3D pair mixing task /// \author Sofia Tomassini, Gleb Romanenko, Nicolò Jacazio /// \since 31 May 2023 @@ -16,6 +17,7 @@ #include #include #include +#include #include #include @@ -36,6 +38,16 @@ #include "PWGCF/Femto3D/DataModel/singletrackselector.h" #include "PWGCF/Femto3D/Core/femto3dPairTask.h" +#include "Common/DataModel/Centrality.h" +#include "PWGLF/DataModel/mcCentrality.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "PWGLF/Utils/inelGt.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/PIDResponse.h" +#include "CCDB/BasicCCDBManager.h" +#include "DetectorsBase/Propagator.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" using namespace o2; using namespace o2::soa; @@ -44,9 +56,21 @@ using namespace o2::framework; using namespace o2::framework::expressions; using FilteredCollisions = soa::Filtered; -using FilteredTracks = soa::Filtered; +using FilteredTracks = soa::Filtered>; + +using RecoTracks = soa::Join; typedef std::shared_ptr trkType; +typedef std::shared_ptr trkTypeData; + typedef std::shared_ptr colType; using MyFemtoPair = o2::aod::singletrackselector::FemtoPair; @@ -57,46 +81,53 @@ class ResoPair : public MyFemtoPair ResoPair() {} ResoPair(trkType const& first, trkType const& second) : MyFemtoPair(first, second) { - SetPair(first, second); + setPair(first, second); } ResoPair(trkType const& first, trkType const& second, const bool& isidentical) : MyFemtoPair(first, second, isidentical) {} - bool IsClosePair() const { return MyFemtoPair::IsClosePair(_deta, _dphi, _radius); } - void SetEtaDiff(const float deta) { _deta = deta; } - void SetPhiStarDiff(const float dphi) { _dphi = dphi; } - void SetPair(trkType const& first, trkType const& second) + bool isClosePair() const { return MyFemtoPair::IsClosePair(mDeltaEta, mDeltaPhi, mRadius); } + void setEtaDiff(const float deta) { mDeltaEta = deta; } + void setPhiStarDiff(const float dphi) { mDeltaPhi = dphi; } + void setRadius(const float r) { mRadius = r; } + void setPair(trkType const& first, trkType const& second) { MyFemtoPair::SetPair(first, second); lDecayDaughter1.SetPtEtaPhiM(first->pt(), first->eta(), first->phi(), particle_mass(GetPDG1())); lDecayDaughter2.SetPtEtaPhiM(second->pt(), second->eta(), second->phi(), particle_mass(GetPDG2())); lResonance = lDecayDaughter1 + lDecayDaughter2; } - float GetInvMass() const + void setPair(trkTypeData const& first, trkTypeData const& second) + { + // MyFemtoPair::SetPair(first, second); + lDecayDaughter1.SetPtEtaPhiM(first->pt(), first->eta(), first->phi(), particle_mass(GetPDG1())); + lDecayDaughter2.SetPtEtaPhiM(second->pt(), second->eta(), second->phi(), particle_mass(GetPDG2())); + lResonance = lDecayDaughter1 + lDecayDaughter2; + } + float getInvMass() const { // LOG(info) << "Mass = " << lResonance.M() << " 1 " << lDecayDaughter1.M() << " 2 " << lDecayDaughter2.M(); return lResonance.M(); } - float GetPt() const { return lResonance.Pt(); } - float GetRapidity() const { return lResonance.Rapidity(); } + float getPt() const { return lResonance.Pt(); } + float getRapidity() const { return lResonance.Rapidity(); } private: TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; - float _deta = 0.01; - float _dphi = 0.01; - float _radius = 1.2; + float mDeltaEta = 0.01; + float mDeltaPhi = 0.01; + float mRadius = 1.2; }; struct K0MixedEvents { - // using allinfo = soa::Join; // aod::pidTPCPr - /// Construct a registry object with direct declaration HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; - Configurable _min_P{"min_P", 0.0, "lower mometum limit"}; - Configurable _max_P{"max_P", 100.0, "upper mometum limit"}; + Configurable> multPercentileCut{"multPercentileCut", std::pair{-100.f, 1000.f}, "[min., max.] centrality range to keep events within"}; + Configurable> momentumCut{"momentumCut", std::pair{0.f, 100.f}, "[min., max.] momentum range to keep candidates within"}; + Configurable dcaxyCut{"dcaxyCut", -100.f, "dcaXY range to keep candidates within"}; + Configurable dcazCut{"dcazCut", -100.f, "dcaZ range to keep candidates within"}; + Configurable dcaxyExclusionCut{"dcaxyExclusionCut", 100.f, "dcaXY range to discard candidates within"}; + Configurable dcazExclusionCut{"dcazExclusionCut", 100.f, "dcaZ range to discard candidates within"}; + Configurable _eta{"eta", 100.0, "abs eta value limit"}; - Configurable _dcaXY{"dcaXY", 1000.0, "abs dcaXY value limit"}; - Configurable _dcaXYmin{"dcaXYmin", -0.1, "abs dcaXY min. value limit"}; - Configurable _dcaZ{"dcaZ", 1000.0, "abs dcaZ value limit"}; - Configurable _dcaZmin{"dcaZmin", -0.1, "abs dcaZ min. value limit"}; Configurable _tpcNClsFound{"minTpcNClsFound", 0, "minimum allowed number of TPC clasters"}; Configurable _tpcChi2NCl{"tpcChi2NCl", 100.0, "upper limit for chi2 value of a fit over TPC clasters"}; Configurable _tpcCrossedRowsOverFindableCls{"tpcCrossedRowsOverFindableCls", 0, "lower limit of TPC CrossedRows/FindableCls value"}; @@ -121,18 +152,34 @@ struct K0MixedEvents { Configurable _particlePDGtoReject{"particlePDGtoRejectFromSecond", 0, "applied only if the particles are non-identical and only to the second particle in the pair!!!"}; Configurable> _rejectWithinNsigmaTOF{"rejectWithinNsigmaTOF", std::vector{-0.0f, 0.0f}, "TOF rejection Nsigma range for the particle specified with PDG to be rejected"}; - Configurable _deta{"deta", 0.01, "minimum allowed defference in eta between two tracks in a pair"}; - Configurable _dphi{"dphi", 0.01, "minimum allowed defference in phi_star between two tracks in a pair"}; + Configurable _deta{"deta", 1, "minimum allowed defference in eta between two tracks in a pair"}; + Configurable _dphi{"dphi", 1, "minimum allowed defference in phi_star between two tracks in a pair"}; Configurable _radiusTPC{"radiusTPC", 1.2, "TPC radius to calculate phi_star for"}; Configurable doMixedEvent{"doMixedEvent", false, "Do the mixed event"}; Configurable _multbinwidth{"multbinwidth", 50, "width of multiplicity bins within which the mixing is done"}; Configurable _vertexbinwidth{"vertexbinwidth", 2, "width of vertexZ bins within which the mixing is done"}; + // Mag field + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + + // Event selections + Configurable sel8{"evSelsel8", 0, "Apply sel8 event selection"}; + Configurable isTriggerTVX{"evSelisTriggerTVX", 1, "Is Trigger TVX"}; + Configurable isNoTimeFrameBorder{"evSelisNoTimeFrameBorder", 1, "Is No Time Frame Border"}; + Configurable isNoITSROFrameBorder{"evSelisNoITSROFrameBorder", 1, "Is No ITS Readout Frame Border"}; + Configurable isVertexTOFmatched{"evSelisVertexTOFmatched", 0, "Is Vertex TOF matched"}; + Configurable isGoodZvtxFT0vsPV{"evSelisGoodZvtxFT0vsPV", 0, "isGoodZvtxFT0vsPV"}; + Configurable isNoSameBunchPileup{"isNoSameBunchPileup", 0, "isNoSameBunchPileup"}; + Configurable isInelGt0{"evSelisInelGt0", 0, "isInelGt0"}; + // Binnings - ConfigurableAxis CFkStarBinning{"CFkStarBinning", {500, 0.4, 0.6}, "k* binning of the CF (Nbins, lowlimit, uplimit)"}; + ConfigurableAxis invMassBinning{"invMassBinning", {500, 0.4, 0.6}, "k* binning of the CF (Nbins, lowlimit, uplimit)"}; ConfigurableAxis ptBinning{"ptBinning", {1000, 0.f, 10.f}, "pT binning (Nbins, lowlimit, uplimit)"}; ConfigurableAxis dcaXyBinning{"dcaXyBinning", {100, -1.f, 1.f}, "dcaXY binning (Nbins, lowlimit, uplimit)"}; + ConfigurableAxis multPercentileBinning{"multPercentileBinning", {VARIABLE_WIDTH, 0.0, 1.0, 5.0, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, 70.0, 100.0}, "Binning in multiplicity percentile"}; bool IsIdentical; @@ -142,18 +189,16 @@ struct K0MixedEvents { std::pair> TPCcuts_2; std::pair> TOFcuts_2; - std::map> selectedtracks_1; - std::map> selectedtracks_2; - std::map, std::vector> mixbins; - std::unique_ptr Pair = std::make_unique(); - Filter pFilter = o2::aod::singletrackselector::p > _min_P&& o2::aod::singletrackselector::p < _max_P; + Filter pFilter = o2::aod::singletrackselector::p > momentumCut.value.first&& o2::aod::singletrackselector::p < momentumCut.value.second; Filter etaFilter = nabs(o2::aod::singletrackselector::eta) < _eta; Filter tpcTrkFilter = o2::aod::singletrackselector::tpcNClsFound >= _tpcNClsFound && o2::aod::singletrackselector::tpcNClsShared <= (uint8_t)_tpcNClsShared; - Filter itsNClsFilter = o2::aod::singletrackselector::itsNCls >= (uint8_t)_itsNCls; + + // Filter itsNClsFilter = o2::aod::singletrackselector::itsNCls >= (uint8_t)_itsNCls; Filter vertexFilter = nabs(o2::aod::singletrackselector::posZ) < _vertexZ; + Filter multPercentileFilter = o2::aod::singletrackselector::multPerc > multPercentileCut.value.first&& o2::aod::singletrackselector::multPerc < multPercentileCut.value.second; const char* pdgToSymbol(const int pdg) { @@ -172,149 +217,343 @@ struct K0MixedEvents { void init(o2::framework::InitContext&) { + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + IsIdentical = (_sign_1 * _particlePDG_1 == _sign_2 * _particlePDG_2); LOG(info) << "IsIdentical=" << IsIdentical << "; sign1=" << _sign_1 << "; Pdg1=" << _particlePDG_1 << "; total1=" << _sign_1 * _particlePDG_1 << " -- Pdg2=" << _particlePDG_2 << "; sign2=" << _sign_2 << "; total2=" << _sign_2 * _particlePDG_2; Pair->SetIdentical(IsIdentical); Pair->SetPDG1(_particlePDG_1); Pair->SetPDG2(_particlePDG_2); - Pair->SetEtaDiff(1); + Pair->setEtaDiff(_deta); + Pair->setPhiStarDiff(_dphi); + Pair->setRadius(_radiusTPC); TPCcuts_1 = std::make_pair(_particlePDG_1, _tpcNSigma_1); TOFcuts_1 = std::make_pair(_particlePDG_1, _tofNSigma_1); TPCcuts_2 = std::make_pair(_particlePDG_2, _tpcNSigma_2); TOFcuts_2 = std::make_pair(_particlePDG_2, _tofNSigma_2); - const AxisSpec invMassAxis{CFkStarBinning, "Inv. mass (GeV/c^{2})"}; + const AxisSpec invMassAxis{invMassBinning, "Inv. mass (GeV/c^{2})"}; const AxisSpec ptAxis{ptBinning, "#it{p}_{T} (GeV/c)"}; const AxisSpec dcaXyAxis{dcaXyBinning, "DCA_{xy} (cm)"}; + const AxisSpec dcaZAxis{dcaXyBinning, "DCA_{z} (cm)"}; + const AxisSpec multPercentileAxis{multPercentileBinning, "Mult. Perc."}; + + registry.add("hNEvents", "hNEvents", {HistType::kTH1D, {{14, 0.f, 14.f}}}); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "all"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "sel8"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "TVX"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(4, "zvertex"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(5, "TFBorder"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(6, "ITSROFBorder"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(7, "isTOFVertexMatched"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(8, "isGoodZvtxFT0vsPV"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(9, "isNoSameBunchPileup"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(10, "InelGT0"); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(11, Form("collision.centFT0M() < %f", multPercentileCut.value.second)); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(12, Form("collision.centFT0M() > %f", multPercentileCut.value.first)); + registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(13, "Applied selection"); registry.add("Trks", "Trks", kTH1D, {{2, 0.5, 2.5, "Tracks"}}); - registry.add("VTXc", "VTXc", kTH1F, {{100, -20., 20., "vtx"}}); - registry.add("VTX", "VTX", kTH1F, {{100, -20., 20., "vtx"}}); - registry.add("SEcand", "SEcand", kTH1F, {{2, 0.5, 2.5}}); - registry.add("SE", "SE", kTH1F, {invMassAxis}); - registry.add("ME", "ME", kTH1F, {invMassAxis}); - registry.add("SEvsPt", "SEvsPt", kTH2D, {invMassAxis, ptAxis}); - registry.add("MEvsPt", "MEvsPt", kTH2D, {invMassAxis, ptAxis}); - registry.add("eta", Form("eta_%i", _particlePDG_1.value), kTH2F, {ptAxis, {100, -10., 10., "#eta"}}); - registry.add("p_first", Form("p_%i", _particlePDG_1.value), kTH1F, {ptAxis}); - registry.add("dcaXY_first", Form("dca_%i", _particlePDG_1.value), kTH2F, {ptAxis, dcaXyAxis}); + registry.add("VTXc", "VTXc", kTH1D, {{100, -20., 20., "vtx"}}); + registry.add("VTX", "VTX", kTH1D, {{100, -20., 20., "vtx"}}); + registry.add("multPerc", "multPerc", kTH1D, {multPercentileAxis}); + + registry.add("SEcand", "SEcand", kTH1D, {{2, 0.5, 2.5}}); + registry.add("SE", "SE", kTH1D, {invMassAxis}); + registry.add("ME", "ME", kTH1D, {invMassAxis}); + registry.add("SEvsPt", "SEvsPt", kTH3F, {invMassAxis, ptAxis, multPercentileAxis}); + if (doMixedEvent) { + registry.add("MEvsPt", "MEvsPt", kTH3F, {invMassAxis, ptAxis, multPercentileAxis}); + } + registry.add("eta_first", Form("eta_%i", _particlePDG_1.value), kTH2F, {ptAxis, {100, -10., 10., "#eta"}}); + registry.add("p_first", Form("p_%i", _particlePDG_1.value), kTH1D, {ptAxis}); + registry.add("dcaXY_first", Form("dcaXY_%i", _particlePDG_1.value), kTH2F, {ptAxis, dcaXyAxis}); + registry.add("dcaZ_first", Form("dcaZ_%i", _particlePDG_1.value), kTH2F, {ptAxis, dcaZAxis}); registry.add("nsigmaTOF_first", Form("nsigmaTOF_%i", _particlePDG_1.value), kTH2F, {ptAxis, {100, -10., 10., Form("N#sigma_{TOF}(%s))", pdgToSymbol(_particlePDG_1))}}); registry.add("nsigmaTPC_first", Form("nsigmaTPC_%i", _particlePDG_1.value), kTH2F, {ptAxis, {100, -10., 10., Form("N#sigma_{TPC}(%s))", pdgToSymbol(_particlePDG_1))}}); registry.add("rapidity_first", Form("rapidity_%i", _particlePDG_1.value), kTH2F, {ptAxis, {100, -10., 10., Form("y(%s)", pdgToSymbol(_particlePDG_1))}}); if (!IsIdentical) { - registry.add("p_second", Form("p_%i", _particlePDG_2.value), kTH1F, {ptAxis}); - registry.add("dcaXY_second", Form("dca_%i", _particlePDG_2.value), kTH2F, {ptAxis, dcaXyAxis}); + registry.add("p_second", Form("p_%i", _particlePDG_2.value), kTH1D, {ptAxis}); + registry.add("dcaXY_second", Form("dcaXY_%i", _particlePDG_2.value), kTH2F, {ptAxis, dcaXyAxis}); + registry.add("dcaZ_second", Form("dcaZ_%i", _particlePDG_1.value), kTH2F, {ptAxis, dcaZAxis}); registry.add("nsigmaTOF_second", Form("nsigmaTOF_%i", _particlePDG_2.value), kTH2F, {ptAxis, {100, -10., 10., Form("N#sigma_{TOF}(%s))", pdgToSymbol(_particlePDG_2))}}); registry.add("nsigmaTPC_second", Form("nsigmaTPC_%i", _particlePDG_2.value), kTH2F, {ptAxis, {100, -10., 10., Form("N#sigma_{TPC}(%s))", pdgToSymbol(_particlePDG_2))}}); registry.add("rapidity_second", Form("rapidity_%i", _particlePDG_2.value), kTH2F, {ptAxis, {100, -10., 10., Form("y(%s)", pdgToSymbol(_particlePDG_2))}}); } + + if (!doprocessMC) { + return; + } + registry.add("MC/multPerc", "multPerc", kTH1D, {multPercentileAxis}); + registry.add("MC/multPercWMcCol", "multPercWMcCol", kTH1D, {multPercentileAxis}); + registry.add("MC/generatedInRecoEvs", "generatedInRecoEvs", kTH2D, {ptAxis, multPercentileAxis}); + registry.add("MC/SE", "SE", kTH1D, {invMassAxis}); + registry.add("MC/SEvsPt", "SEvsPt", kTH3F, {invMassAxis, ptAxis, multPercentileAxis}); + registry.addClone("MC/", "MCCent/"); + registry.add("MCCent/generatedInGenEvs", "generatedInGenEvs", kTH2D, {ptAxis, multPercentileAxis}); + } + + int mRunNumber = 0; + float d_bz = 0.f; + Service ccdb; + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) // inspired by PWGLF/TableProducer/lambdakzerobuilder.cxx + { + if (mRunNumber == bc.runNumber()) { + return; + } + d_bz = 0.f; + + auto run3grp_timestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + o2::parameters::GRPMagField* grpmag = 0x0; + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + // Fetch magnetic field from ccdb for current collision + d_bz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + // Fetch magnetic field from ccdb for current collision + d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + } + mRunNumber = bc.runNumber(); + d_bz = 0.1 * d_bz; } template - void mixTracks(Type const& tracks) + void mixTracks(Type const& tracks, const float centrality) { // template for identical particles from the same collision LOG(debug) << "Mixing tracks of the same event"; - for (uint32_t ii = 0; ii < tracks.size(); ii++) { // nested loop for all the combinations - for (uint32_t iii = ii + 1; iii < tracks.size(); iii++) { + for (uint32_t trk1 = 0; trk1 < tracks.size(); trk1++) { // nested loop for all the combinations + for (uint32_t trk2 = trk1 + 1; trk2 < tracks.size(); trk2++) { - Pair->SetPair(tracks[ii], tracks[iii]); + Pair->setPair(tracks[trk1], tracks[trk2]); registry.fill(HIST("SEcand"), 1.f); - if (!Pair->IsClosePair()) { - continue; - } - if (std::abs(Pair->GetRapidity()) > 0.5f) { + // if (!Pair->isClosePair()) { + // continue; + // } + if (std::abs(Pair->getRapidity()) > 0.5f) { continue; } registry.fill(HIST("SEcand"), 2.f); - registry.fill(HIST("SE"), Pair->GetInvMass()); // close pair rejection and fillig the SE histo - registry.fill(HIST("SEvsPt"), Pair->GetInvMass(), Pair->GetPt()); // close pair rejection and fillig the SE histo + registry.fill(HIST("SE"), Pair->getInvMass()); // close pair rejection and fillig the SE histo + registry.fill(HIST("SEvsPt"), Pair->getInvMass(), Pair->getPt(), centrality); // close pair rejection and fillig the SE histo } } } template - void mixTracks(Type const& tracks1, Type const& tracks2) + void mixTracks(Type const& tracks1, Type const& tracks2, const float centrality) { LOG(debug) << "Mixing tracks of two different events"; - for (auto ii : tracks1) { - for (auto iii : tracks2) { + for (auto trk1 : tracks1) { + for (auto trk2 : tracks2) { - Pair->SetPair(ii, iii); + Pair->setPair(trk1, trk2); if constexpr (isSameEvent) { registry.fill(HIST("SEcand"), 1.f); } - if (!Pair->IsClosePair()) { - continue; - } - if (std::abs(Pair->GetRapidity()) > 0.5f) { + // if (!Pair->isClosePair()) { + // continue; + // } + if (std::abs(Pair->getRapidity()) > 0.5f) { continue; } if constexpr (isSameEvent) { registry.fill(HIST("SEcand"), 2.f); - registry.fill(HIST("SE"), Pair->GetInvMass()); - registry.fill(HIST("SEvsPt"), Pair->GetInvMass(), Pair->GetPt()); + registry.fill(HIST("SE"), Pair->getInvMass()); + registry.fill(HIST("SEvsPt"), Pair->getInvMass(), Pair->getPt(), centrality); } else { - registry.fill(HIST("ME"), Pair->GetInvMass()); - registry.fill(HIST("MEvsPt"), Pair->GetInvMass(), Pair->GetPt()); + registry.fill(HIST("ME"), Pair->getInvMass()); + registry.fill(HIST("MEvsPt"), Pair->getInvMass(), Pair->getPt(), centrality); } } } } - void process(FilteredTracks const& tracks, FilteredCollisions const& collisions) + template + bool isTrackSelected(TrkType const& track) { - LOG(debug) << "Processing " << collisions.size() << " collisions and " << tracks.size() << " tracks"; + if (track.itsChi2NCl() > 36.f) + return false; + if (track.itsChi2NCl() < 0.f) + return false; + if (track.tpcChi2NCl() < 0.f) + return false; + if (track.tpcChi2NCl() > 4.f) + return false; + if (track.itsNCls() < _itsNCls) { + return false; + } + if (track.itsChi2NCl() > _itsChi2NCl) { + return false; + } + if (track.tpcChi2NCl() > _tpcChi2NCl) { + return false; + } + if (track.tpcCrossedRowsOverFindableCls() < _tpcCrossedRowsOverFindableCls) { + return false; + } + if (std::abs(track.dcaXY()) > dcaxyCut) { + return false; + } + if (std::abs(track.dcaXY()) < dcaxyExclusionCut) { + return false; + } + if (std::abs(track.dcaZ()) > dcazCut) { + return false; + } + if (std::abs(track.dcaZ()) < dcazExclusionCut) { + return false; + } + if (track.p() < momentumCut.value.first) { + return false; + } + if (track.p() > momentumCut.value.second) { + return false; + } + if (std::abs(track.eta()) >= _eta) { + return false; + } + if (track.tpcNClsFound() < _tpcNClsFound) { + return false; + } + if (track.tpcNClsShared() > _tpcNClsShared) { + return false; + } + + return true; + } + + // Event selection + template + bool acceptEvent(TCollision const& collision, bool fill = true) + { + if (fill) { + registry.fill(HIST("hNEvents"), 0.5); + } + if (sel8 && !collision.sel8()) { + return false; + } + if (fill) { + registry.fill(HIST("hNEvents"), 1.5); + } + if (isTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + if (fill) { + registry.fill(HIST("hNEvents"), 2.5); + } + if (TMath::Abs(collision.posZ()) > _vertexZ) { + return false; + } + if (fill) { + registry.fill(HIST("hNEvents"), 3.5); + } + if (isNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (fill) { + registry.fill(HIST("hNEvents"), 4.5); + } + if (isNoITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return false; + } + if (fill) { + registry.fill(HIST("hNEvents"), 5.5); + } + if (isVertexTOFmatched && !collision.selection_bit(aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if (fill) { + registry.fill(HIST("hNEvents"), 6.5); + } + if (isGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if (fill) { + registry.fill(HIST("hNEvents"), 7.5); + } + if (isNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return false; + } + if (fill) { + registry.fill(HIST("hNEvents"), 8.5); + } + if (isInelGt0 && !collision.isInelGt0()) { + return false; + } + if (fill) { + registry.fill(HIST("hNEvents"), 9.5); + } + if (collision.centFT0M() > multPercentileCut.value.second) + return false; + if (fill) { + registry.fill(HIST("hNEvents"), 10.5); + } + if (collision.centFT0M() < multPercentileCut.value.first) + return false; + if (fill) { + registry.fill(HIST("hNEvents"), 11.5); + } + if (fill) { + registry.fill(HIST("hNEvents"), 12.5); + } + return true; + } + void processDerived(FilteredTracks const& tracks, FilteredCollisions const& collisions) + { + LOG(debug) << "Processing " << collisions.size() << " collisions and " << tracks.size() << " tracks"; + std::map> selectedtracks_1; + std::map> selectedtracks_2; + std::map, std::vector> mixbins; if (_particlePDG_1 == 0 || _particlePDG_2 == 0) { LOGF(fatal, "One of passed PDG is 0!!!"); } registry.fill(HIST("Trks"), 2.f, tracks.size()); - for (auto collision : collisions) { + for (const auto& collision : collisions) { LOG(debug) << "Collision index " << collision.globalIndex(); registry.fill(HIST("VTXc"), collision.posZ()); + registry.fill(HIST("multPerc"), collision.multPerc()); } for (auto track : tracks) { LOG(debug) << "Track index " << track.singleCollSelId(); - if (track.itsChi2NCl() > _itsChi2NCl) { - continue; - } - if (track.tpcChi2NCl() > _tpcChi2NCl) { - continue; - } - if (track.tpcCrossedRowsOverFindableCls() < _tpcCrossedRowsOverFindableCls) { + if (!isTrackSelected(track)) { continue; } - if (track.dcaXY() < _dcaXYmin || track.dcaXY() > _dcaXY) { - continue; - } - if (track.dcaZ() < _dcaZmin || track.dcaZ() > _dcaZ) { - continue; - } - registry.fill(HIST("Trks"), 1); - const float vtxZ = track.singleCollSel_as().posZ(); - registry.fill(HIST("VTX"), vtxZ); - if (std::abs(vtxZ) > _vertexZ) + const auto& col = track.singleCollSel_as(); + if (std::abs(col.posZ()) > _vertexZ) continue; - registry.fill(HIST("eta"), track.pt(), track.eta()); - if (std::abs(track.rapidity(particle_mass(_particlePDG_1))) > _maxy) { + if (col.multPerc() > multPercentileCut.value.second || col.multPerc() < multPercentileCut.value.first) continue; - } + registry.fill(HIST("VTX"), col.posZ()); + registry.fill(HIST("eta_first"), track.pt(), track.eta()); registry.fill(HIST("rapidity_first"), track.pt(), track.rapidity(particle_mass(_particlePDG_1))); if ((track.sign() == _sign_1) && - (track.p() < _PIDtrshld_1 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_1) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_1))) { // filling the map: eventID <-> selected particles1 + (track.p() < _PIDtrshld_1 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_1) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_1))) { // filling the map: eventID <-> selected particles1 selectedtracks_1[track.singleCollSelId()].push_back(std::make_shared(track)); registry.fill(HIST("p_first"), track.p()); registry.fill(HIST("dcaXY_first"), track.pt(), track.dcaXY()); + registry.fill(HIST("dcaZ_first"), track.pt(), track.dcaZ()); switch (_particlePDG_1) { case 211: registry.fill(HIST("nsigmaTOF_first"), track.p(), track.tofNSigmaPi()); @@ -340,12 +579,13 @@ struct K0MixedEvents { if (IsIdentical) { continue; } else if ((track.sign() == _sign_2) && - (_particlePDGtoReject != 0 || !TOFselection(track, std::make_pair(_particlePDGtoReject, _rejectWithinNsigmaTOF))) && - (track.p() < _PIDtrshld_2 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_2) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_2))) { // filling the map: eventID <-> selected particles2 if (see condition above ^) + (_particlePDGtoReject != 0 || !o2::aod::singletrackselector::TOFselection(track, std::make_pair(_particlePDGtoReject, _rejectWithinNsigmaTOF))) && + (track.p() < _PIDtrshld_2 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_2) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_2))) { // filling the map: eventID <-> selected particles2 if (see condition above ^) selectedtracks_2[track.singleCollSelId()].push_back(std::make_shared(track)); registry.fill(HIST("p_second"), track.p()); registry.fill(HIST("dcaXY_second"), track.pt(), track.dcaXY()); + registry.fill(HIST("dcaZ_second"), track.pt(), track.dcaZ()); switch (_particlePDG_2) { case 211: registry.fill(HIST("nsigmaTOF_second"), track.p(), track.tofNSigmaPi()); @@ -393,7 +633,7 @@ struct K0MixedEvents { Pair->SetMagField1(col1->magField()); Pair->SetMagField2(col1->magField()); - mixTracks(selectedtracks_1[col1->index()]); // mixing SE identical + mixTracks(selectedtracks_1[col1->index()], col1->multPerc()); // mixing SE identical if (!doMixedEvent) { continue; } @@ -403,7 +643,7 @@ struct K0MixedEvents { auto col2 = (i->second)[indx2]; Pair->SetMagField2(col2->magField()); - mixTracks(selectedtracks_1[col1->index()], selectedtracks_1[col2->index()]); // mixing ME identical + mixTracks(selectedtracks_1[col1->index()], selectedtracks_1[col2->index()], col1->multPerc()); // mixing ME identical } } } @@ -421,7 +661,7 @@ struct K0MixedEvents { Pair->SetMagField1(col1->magField()); Pair->SetMagField2(col1->magField()); - mixTracks(selectedtracks_1[col1->index()], selectedtracks_2[col1->index()]); // mixing SE non-identical + mixTracks(selectedtracks_1[col1->index()], selectedtracks_2[col1->index()], col1->multPerc()); // mixing SE non-identical if (!doMixedEvent) { continue; } @@ -431,7 +671,205 @@ struct K0MixedEvents { auto col2 = (i->second)[indx2]; Pair->SetMagField2(col2->magField()); - mixTracks(selectedtracks_1[col1->index()], selectedtracks_2[col2->index()]); // mixing ME non-identical + mixTracks(selectedtracks_1[col1->index()], selectedtracks_2[col2->index()], col1->multPerc()); // mixing ME non-identical + } + } + } + + } //====================================== end of mixing non-identical ====================================== + + // clearing up + for (auto i = selectedtracks_1.begin(); i != selectedtracks_1.end(); i++) + (i->second).clear(); + selectedtracks_1.clear(); + + if (!IsIdentical) { + for (auto i = selectedtracks_2.begin(); i != selectedtracks_2.end(); i++) + (i->second).clear(); + selectedtracks_2.clear(); + } + + for (auto i = mixbins.begin(); i != mixbins.end(); i++) + (i->second).clear(); + mixbins.clear(); + } + PROCESS_SWITCH(K0MixedEvents, processDerived, "process derived", true); + + using RecoCollisions = soa::Join; + + void processData(RecoTracks const& tracks, RecoCollisions const& collisions, BCsWithTimestamps const& bcs) + { + initCCDB(bcs.iteratorAt(0)); + LOG(debug) << "Processing " << collisions.size() << " collisions and " << tracks.size() << " tracks"; + std::map> selectedtracks_1; + std::map> selectedtracks_2; + std::map, std::vector>> mixbins; + if (_particlePDG_1 == 0 || _particlePDG_2 == 0) { + LOGF(fatal, "One of passed PDG is 0!!!"); + } + + registry.fill(HIST("Trks"), 2.f, tracks.size()); + for (auto collision : collisions) { + if (!acceptEvent(collision)) + continue; + LOG(debug) << "Collision index " << collision.globalIndex(); + registry.fill(HIST("VTXc"), collision.posZ()); + registry.fill(HIST("multPerc"), collision.centFT0M()); + } + + for (auto track : tracks) { + if (!isTrackSelected(track)) { + continue; + } + // if (!track.isGlobalTrackWoDCA()) { + // continue; + // } + if (track.trackType() != aod::track::Track) { + continue; + } + if (track.tofChi2() >= 10.f) { + continue; + } + if (!track.has_collision()) { + continue; + } + registry.fill(HIST("Trks"), 1); + const auto& col = track.collision_as(); + if (!acceptEvent(col, false)) + continue; + if (std::abs(col.posZ()) > _vertexZ) + continue; + if (col.centFT0M() > multPercentileCut.value.second || col.centFT0M() < multPercentileCut.value.first) + continue; + registry.fill(HIST("VTX"), col.posZ()); + registry.fill(HIST("eta_first"), track.pt(), track.eta()); + registry.fill(HIST("rapidity_first"), track.pt(), track.rapidity(particle_mass(_particlePDG_1))); + + if ((track.sign() == _sign_1) && + (track.p() < _PIDtrshld_1 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_1) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_1))) { // filling the map: eventID <-> selected particles1 + selectedtracks_1[track.collisionId()].push_back(std::make_shared(track)); + + registry.fill(HIST("p_first"), track.p()); + registry.fill(HIST("dcaXY_first"), track.pt(), track.dcaXY()); + registry.fill(HIST("dcaZ_first"), track.pt(), track.dcaZ()); + switch (_particlePDG_1) { + case 211: + registry.fill(HIST("nsigmaTOF_first"), track.p(), track.tofNSigmaPi()); + registry.fill(HIST("nsigmaTPC_first"), track.p(), track.tpcNSigmaPi()); + break; + case 321: + registry.fill(HIST("nsigmaTOF_first"), track.p(), track.tofNSigmaKa()); + registry.fill(HIST("nsigmaTPC_first"), track.p(), track.tpcNSigmaKa()); + break; + case 2212: + registry.fill(HIST("nsigmaTOF_first"), track.p(), track.tofNSigmaPr()); + registry.fill(HIST("nsigmaTPC_first"), track.p(), track.tpcNSigmaPr()); + break; + case 1000010020: + registry.fill(HIST("nsigmaTOF_first"), track.p(), track.tofNSigmaDe()); + registry.fill(HIST("nsigmaTPC_first"), track.p(), track.tpcNSigmaDe()); + break; + default: + LOG(fatal) << "PDG code 1: " << _particlePDG_1 << " is not supported!!!"; + } + } + + if (IsIdentical) { + continue; + } else if ((track.sign() == _sign_2) && + (_particlePDGtoReject != 0 || !o2::aod::singletrackselector::TOFselection(track, std::make_pair(_particlePDGtoReject, _rejectWithinNsigmaTOF))) && + (track.p() < _PIDtrshld_2 ? o2::aod::singletrackselector::TPCselection(track, TPCcuts_2) : o2::aod::singletrackselector::TOFselection(track, TOFcuts_2))) { // filling the map: eventID <-> selected particles2 if (see condition above ^) + selectedtracks_2[track.collisionId()].push_back(std::make_shared(track)); + + registry.fill(HIST("p_second"), track.p()); + registry.fill(HIST("dcaXY_second"), track.pt(), track.dcaXY()); + registry.fill(HIST("dcaZ_second"), track.pt(), track.dcaZ()); + switch (_particlePDG_2) { + case 211: + registry.fill(HIST("nsigmaTOF_second"), track.p(), track.tofNSigmaPi()); + registry.fill(HIST("nsigmaTPC_second"), track.p(), track.tpcNSigmaPi()); + break; + case 321: + registry.fill(HIST("nsigmaTOF_second"), track.p(), track.tofNSigmaKa()); + registry.fill(HIST("nsigmaTPC_second"), track.p(), track.tpcNSigmaKa()); + break; + case 2212: + registry.fill(HIST("nsigmaTOF_second"), track.p(), track.tofNSigmaPr()); + registry.fill(HIST("nsigmaTPC_second"), track.p(), track.tpcNSigmaPr()); + break; + case 1000010020: + registry.fill(HIST("nsigmaTOF_second"), track.p(), track.tofNSigmaDe()); + registry.fill(HIST("nsigmaTPC_second"), track.p(), track.tpcNSigmaDe()); + break; + default: + LOG(fatal) << "PDG code 2: " << _particlePDG_2 << " is not supported!!!"; + } + } + } + + for (auto collision : collisions) { + if (selectedtracks_1.find(collision.globalIndex()) == selectedtracks_1.end()) { + if (IsIdentical) + continue; + else if (selectedtracks_2.find(collision.globalIndex()) == selectedtracks_2.end()) + continue; + } + + mixbins[std::pair{round(collision.posZ() / _vertexbinwidth), floor(collision.multNTracksPVeta1() / _multbinwidth)}].push_back(std::make_shared(collision)); + } + + //====================================== mixing starts here ====================================== + + if (IsIdentical) { //====================================== mixing identical ====================================== + + for (auto i = mixbins.begin(); i != mixbins.end(); i++) { // iterating over all vertex&mult bins + + for (uint32_t indx1 = 0; indx1 < (i->second).size(); indx1++) { // loop over all the events in each vertex&mult bin + + auto col1 = (i->second)[indx1]; + + Pair->SetMagField1(d_bz); + Pair->SetMagField2(d_bz); + + mixTracks(selectedtracks_1[col1->index()], col1->centFT0M()); // mixing SE identical + if (!doMixedEvent) { + continue; + } + + for (uint32_t indx2 = indx1 + 1; indx2 < (i->second).size(); indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin + + auto col2 = (i->second)[indx2]; + + Pair->SetMagField2(d_bz); + mixTracks(selectedtracks_1[col1->index()], selectedtracks_1[col2->index()], col1->centFT0M()); // mixing ME identical + } + } + } + + //====================================== end of mixing identical ====================================== + } else { + //====================================== mixing non-identical ====================================== + + for (auto i = mixbins.begin(); i != mixbins.end(); i++) { // iterating over all vertex&mult bins + + for (uint32_t indx1 = 0; indx1 < (i->second).size(); indx1++) { // loop over all the events in each vertex&mult bin + + auto col1 = (i->second)[indx1]; + + Pair->SetMagField1(d_bz); + Pair->SetMagField2(d_bz); + + mixTracks(selectedtracks_1[col1->index()], selectedtracks_2[col1->index()], col1->centFT0M()); // mixing SE non-identical + if (!doMixedEvent) { + continue; + } + + for (uint32_t indx2 = indx1 + 1; indx2 < (i->second).size(); indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin + + auto col2 = (i->second)[indx2]; + + Pair->SetMagField2(d_bz); + mixTracks(selectedtracks_1[col1->index()], selectedtracks_2[col2->index()], col1->centFT0M()); // mixing ME non-identical } } } @@ -453,9 +891,143 @@ struct K0MixedEvents { (i->second).clear(); mixbins.clear(); } + PROCESS_SWITCH(K0MixedEvents, processData, "process data", false); + + using RecoMCCollisions = soa::Join; + using RecoMCTracks = soa::Join; + using GenMCCollisions = soa::Join; + + Service pdgDB; + Preslice perMCCol = aod::mcparticle::mcCollisionId; + Preslice perCollision = aod::track::collisionId; + SliceCache cache; + void processMC(RecoMCCollisions const& collisions, + RecoMCTracks const& tracks, + GenMCCollisions const& mcCollisions, + aod::McParticles const& mcParticles) + { + // Loop on reconstructed tracks + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + std::vector> trkPool1; + std::vector> trkPool2; + // Loop on reconstructed collisions + for (const auto& col : collisions) { + if (!col.sel8()) { + continue; + } + if (std::abs(col.posZ()) > _vertexZ) { + continue; + } + // Loop on tracks + const auto& tracksInCollision = tracks.sliceByCached(aod::track::collisionId, col.globalIndex(), cache); + for (const auto& trk : tracksInCollision) { + if (!trk.has_mcParticle()) { + continue; + } + if (!isTrackSelected(trk)) { + continue; + } + // if (!trk.isGlobalTrackWoDCA()) { + // continue; + // } + if (trk.trackType() != aod::track::Track) { + continue; + } + if (trk.tofChi2() >= 10.f) { + continue; + } + const auto& part = trk.mcParticle(); + switch (part.pdgCode()) { + case 211: + trkPool1.push_back(std::make_shared(trk)); + break; + case -211: + trkPool2.push_back(std::make_shared(trk)); + break; + default: + continue; + } + } + + for (uint32_t trk1 = 0; trk1 < trkPool1.size(); trk1++) { // nested loop for all the combinations + lDecayDaughter1.SetPtEtaPhiM(trkPool1[trk1]->pt(), trkPool1[trk1]->eta(), trkPool1[trk1]->phi(), particle_mass(_particlePDG_1)); + for (uint32_t trk2 = 0; trk2 < trkPool2.size(); trk2++) { + lDecayDaughter2.SetPtEtaPhiM(trkPool2[trk2]->pt(), trkPool2[trk2]->eta(), trkPool2[trk2]->phi(), particle_mass(_particlePDG_2)); + // if (!Pair->isClosePair()) { + // continue; + // } + lResonance = lDecayDaughter1 + lDecayDaughter2; + if (std::abs(lResonance.Rapidity()) > 0.5f) { + continue; + } + registry.fill(HIST("MC/SE"), lResonance.M()); // close pair rejection and fillig the SE histo + registry.fill(HIST("MC/SEvsPt"), lResonance.M(), lResonance.Pt(), col.centFT0M()); // close pair rejection and fillig the SE histo + if (col.has_mcCollision()) { + registry.fill(HIST("MCCent/SE"), lResonance.M()); // close pair rejection and fillig the SE histo + registry.fill(HIST("MCCent/SEvsPt"), lResonance.M(), lResonance.Pt(), col.mcCollision_as().centFT0M()); // close pair rejection and fillig the SE histo + } + } + } + trkPool1.clear(); + trkPool2.clear(); + + registry.fill(HIST("MC/multPerc"), col.centFT0M()); + if (!col.has_mcCollision()) { + continue; + } + const auto& mcCollision = col.mcCollision_as(); + registry.fill(HIST("MC/multPercWMcCol"), col.centFT0M()); + registry.fill(HIST("MCCent/multPercWMcCol"), mcCollision.centFT0M()); + + // Loop on particles + const auto& particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + for (const auto& mcParticle : particlesInCollision) { + switch (mcParticle.pdgCode()) { + case 310: + break; + default: + continue; + } + if (mcParticle.pdgCode() != 310) { + LOG(fatal) << "Fatal in PDG"; + } + if (std::abs(mcParticle.y()) > 0.5) { + continue; + } + registry.fill(HIST("MC/generatedInRecoEvs"), mcParticle.pt(), col.centFT0M()); + registry.fill(HIST("MCCent/generatedInRecoEvs"), mcParticle.pt(), mcCollision.centFT0M()); + } + } + + // Loop on generated collisions + for (const auto& mcCollision : mcCollisions) { + if (std::abs(mcCollision.posZ()) > _vertexZ) { + continue; + } + const auto& particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + if (!o2::pwglf::isINELgt0mc(particlesInCollision, pdgDB)) { + continue; + } + registry.fill(HIST("MCCent/multPerc"), mcCollision.centFT0M()); + for (const auto& mcParticle : particlesInCollision) { + switch (mcParticle.pdgCode()) { + case 310: + break; + default: + continue; + } + if (mcParticle.pdgCode() != 310) { + LOG(fatal) << "Fatal in PDG"; + } + if (std::abs(mcParticle.y()) > 0.5) { + continue; + } + registry.fill(HIST("MCCent/generatedInGenEvs"), mcParticle.pt(), mcCollision.centFT0M()); + } + } + } + + PROCESS_SWITCH(K0MixedEvents, processMC, "process mc", false); }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Strangeness/lambdaJetpolarization.cxx b/PWGLF/Tasks/Strangeness/lambdaJetpolarization.cxx new file mode 100644 index 00000000000..cca1bdf193e --- /dev/null +++ b/PWGLF/Tasks/Strangeness/lambdaJetpolarization.cxx @@ -0,0 +1,1298 @@ +// 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 +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include +#include +#include +#include "TProfile2D.h" +#include "PWGLF/DataModel/lambdaJetpolarization.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "Math/GenVector/Boost.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include "PWGJE/Core/JetBkgSubUtils.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/Jet.h" +#include "Common/Core/trackUtilities.h" + +using std::cout; +using std::endl; +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct LfMyV0s { + HistogramRegistry registry{"registry"}; + HistogramRegistry registryData{"registryData", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry registryV0Data{"registryV0Data", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry registryLongitudinalPolarization{"registryLongitudinalPolarization", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + Configurable zVtx{"zVtx", 10.0, "Maximum zVertex"}; + Configurable rJet{"rJet", 0.4, "Jet resolution parameter R"}; + Configurable etaMin{"etaMin", -0.9f, "eta min"}; + Configurable etaMax{"etaMax", +0.9f, "eta max"}; + Configurable deltaEtaEdge{"deltaEtaEdge", 0.00, "eta gap from the edge"}; + // track parameters + 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 minTpcNcrossedRowsOverFindable{"minTpcNcrossedRowsOverFindable", 0.8, "crossed rows/findable"}; + Configurable maxChi2TPC{"maxChi2TPC", 4.0f, "max chi2 per cluster TPC"}; + Configurable maxChi2ITS{"maxChi2ITS", 36.0f, "max chi2 per cluster ITS"}; + Configurable requireTOF{"requireTOF", false, "require TOF hit"}; + Configurable requireITS{"requireITS", false, "require ITS hit"}; + + Configurable ptMinV0Proton{"ptMinV0Proton", 0.3f, "pt min of proton from V0"}; + Configurable ptMaxV0Proton{"ptMaxV0Proton", 10.0f, "pt max of proton from V0"}; + Configurable ptMinV0Pion{"ptMinV0Pion", 0.1f, "pt min of pion from V0"}; + Configurable ptMaxV0Pion{"ptMaxV0Pion", 1.5f, "pt max of pion from V0"}; + + 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 cfgtrkMinPt{"cfgtrkMinPt", 0.10, "set track min pT"}; + + // v0 parameters + Configurable v0cospaMin{"v0cospaMin", 0.995f, "Minimum V0 CosPA"}; + Configurable minimumV0Radius{"minimumV0Radius", 0.2f, "Minimum V0 Radius"}; + Configurable maximumV0Radius{"maximumV0Radius", 40.0f, "Maximum V0 Radius"}; + Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 1.0f, "Maximum DCA Daughters"}; + Configurable dcanegtoPVmin{"dcanegtoPVmin", 0.1f, "Minimum DCA Neg To PV"}; + Configurable dcapostoPVmin{"dcapostoPVmin", 0.1f, "Minimum DCA Pos To PV"}; + + // jet selection + Configurable cfgjetPtMin{"cfgjetPtMin", 8.0, "minimum jet pT cut"}; + Configurable ispassdTrackSelectionForJetReconstruction{"ispassdTrackSelectionForJetReconstruction", 1, "do track selection"}; + + // v0Event selection + Configurable sel8{"sel8", 1, "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", 1, "isGoodZvtxFT0vsPV"}; + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable CtauLambda{"ctauLambda", 30, "C tau Lambda (cm)"}; + Configurable requirepassedSingleTrackSelection{"requirepassedSingleTrackSelection", false, "requirepassedSingleTrackSelection"}; + Configurable V0tracketaMin{"V0tracketaMin", -0.8f, "eta min track"}; + Configurable V0tracketaMax{"V0tracketaMax", +0.8f, "eta max track"}; + Configurable requireTPC{"requireTPC", true, "require TPC hit"}; + Configurable yMin{"V0yMin", -0.5f, "minimum y"}; + Configurable yMax{"V0yMax", +0.5f, "maximum y"}; + Configurable v0rejLambda{"v0rejLambda", 0.01, "V0 rej Lambda"}; + Configurable v0accLambda{"v0accLambda", 0.075, "V0 acc Lambda"}; + Configurable ifinitpasslambda{"ifinitpasslambda", 0, "ifinitpasslambda"}; + Configurable ifpasslambda{"passedLambdaSelection", 1, "passedLambdaSelection"}; + Configurable paramArmenterosCut{"paramArmenterosCut", 0.2, "parameter Armenteros Cut"}; + Configurable doArmenterosCut{"doArmenterosCut", 0, "do Armenteros Cut"}; + Configurable noSameBunchPileUp{"noSameBunchPileUp", true, "reject SameBunchPileUp"}; + + // Jet background subtraction + JetBkgSubUtils backgroundSub; + void init(InitContext const&) + { + const AxisSpec axisPx{100, -10, 10, "#px (GeV/c)"}; + const AxisSpec axisPy{100, -10, 10, "#py (GeV/c)"}; + const AxisSpec axisPz{100, -10, 10, "#pz (GeV/c)"}; + const AxisSpec axisPT{200, 0, 50, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisPhi{100, -3.14, 3.14, "#Phi"}; + const AxisSpec axisMass{100, 0, 2, "Mass(GeV/c^{2})"}; + + const AxisSpec JetaxisEta{30, -1.5, +1.5, "#eta"}; + const AxisSpec JetaxisPhi{200, -1, +7, "#phi"}; + const AxisSpec JetaxisPt{200, 0, +200, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec ptAxis{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec invMassLambdaAxis{200, 1.09, 1.14, "m_{p#pi} (GeV/#it{c}^{2})"}; + + ConfigurableAxis TProfile2DaxisPt{"#it{p}_{T} (GeV/#it{c})", {VARIABLE_WIDTH, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.2, 3.7, 4.2, 5, 6, 8, 10, 12}, "pt axis for histograms"}; + ConfigurableAxis TProfile2DaxisMass{"Mass p#pi (GeV/#it{c^{2}})", {VARIABLE_WIDTH, 1.10068, 1.10668, 1.11068, 1.11268, 1.11368, 1.11468, 1.11568, 1.11668, 1.11768, 1.11868, 1.12068, 1.12468, 1.13068}, "Mass axis for histograms"}; + + registry.add("hMassLambda", "hMassLambda", {HistType::kTH1F, {{200, 0.9f, 1.2f}}}); + registry.add("V0pTInLab", "V0pTInLab", kTH1F, {axisPT}); + registry.add("hMassVsPtLambda", "hMassVsPtLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {200, 1.016f, 1.216f}}}); + registry.add("hMassVsPtAntiLambda", "hMassVsPtAntiLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {200, 1.016f, 1.216f}}}); + + registry.add("V0pxInLab", "V0pxInLab", kTH1F, {axisPx}); + registry.add("V0pyInLab", "V0pyInLab", kTH1F, {axisPy}); + registry.add("V0pzInLab", "V0pzInLab", kTH1F, {axisPz}); + + registry.add("V0pxInRest_frame", "V0pxInRest_frame", kTH1F, {axisPx}); + registry.add("V0pyInRest_frame", "V0pyInRest_frame", kTH1F, {axisPy}); + registry.add("V0pzInRest_frame", "V0pzInRest_frame", kTH1F, {axisPz}); + + registry.add("JetpxInLab", "JetpxInLab", kTH1F, {axisPx}); + registry.add("JetpyInLab", "JetpyInLab", kTH1F, {axisPy}); + registry.add("JetpzInLab", "JetpzInLab", kTH1F, {axisPz}); + registry.add("JetpTInLab", "JetpTInLab", kTH1F, {axisPT}); + + registry.add("LeadingJetpx", "LeadingJetpx", kTH1F, {axisPx}); + registry.add("LeadingJetpy", "LeadingJetpy", kTH1F, {axisPy}); + registry.add("LeadingJetpz", "LeadingJetpz", kTH1F, {axisPz}); + registry.add("LeadingJetpT", "LeadingJetpT", kTH1F, {axisPT}); + + registry.add("V0protonpxInLab", "V0protonpxInLab", kTH1F, {axisPx}); + registry.add("V0protonpyInLab", "V0protonpyInLab", kTH1F, {axisPy}); + registry.add("V0protonpzInLab", "V0protonpzInLab", kTH1F, {axisPz}); + registry.add("V0protonphiInLab", "V0protonphiInLab", kTH1F, {axisPhi}); + + registry.add("V0protonpxInRest_frame", "V0protonpxInRest_frame", kTH1F, {axisPx}); + registry.add("V0protonpyInRest_frame", "V0protonpyInRest_frame", kTH1F, {axisPy}); + registry.add("V0protonpzInRest_frame", "V0protonpzInRest_frame", kTH1F, {axisPz}); + registry.add("V0protonMassInRest_frame", "V0protonMassInRest_frame", kTH1F, {axisMass}); + registry.add("V0protonphiInRest_frame", "V0protonphiInRest_frame", kTH1F, {axisPhi}); + + registry.add("V0protonpxInJetV0frame", "V0protonpxInJetV0frame", kTH1F, {axisPx}); + registry.add("V0protonpyInJetV0frame", "V0protonpyInJetV0frame", kTH1F, {axisPy}); + registry.add("V0protonpzInJetV0frame", "V0protonpzInJetV0frame", kTH1F, {axisPz}); + registry.add("V0protonphiInJetV0frame", "V0protonphiInJetV0frame", kTH1F, {axisPhi}); + registry.add("V0antiprotonphiInJetV0frame", "V0antiprotonphiInJetV0frame", kTH1F, {axisPhi}); + + registry.add("V0LambdapxInJetV0frame", "V0LambdapxInJetV0frame", kTH1F, {axisPx}); + registry.add("V0LambdapyInJetV0frame", "V0LambdapyInJetV0frame", kTH1F, {axisPy}); + registry.add("V0LambdapzInJetV0frame", "V0LambdapzInJetV0frame", kTH1F, {axisPz}); + + registry.add("hLambdamassandSinPhi", "hLambdamassandSinPhi", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + registry.add("hAntiLambdamassandSinPhi", "hAntiLambdamassandSinPhi", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + registry.add("profile", "Invariant Mass vs sin(phi)", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + registry.add("profileAntiV0", "Invariant Mass vs sin(phi)", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + registry.add("hLambdaPhiandSinPhi", "hLambdaPhiandSinPhi", kTH2F, {{200, -TMath::Pi() / 2, TMath::Pi() / 2}, {200, -1, 1}}); + registry.add("hAntiLambdaPhiandSinPhi", "hAntiLambdaPhiandSinPhi", kTH2F, {{200, -TMath::Pi() / 2, TMath::Pi() / 2}, {200, -1, 1}}); + + registry.add("V0LambdaprotonPhi", "V0LambdaprotonPhi", {HistType::kTH1F, {{200, -TMath::Pi() / 2, TMath::Pi() / 2}}}); + registry.add("V0AntiLambdaprotonPhi", "V0AntiLambdaprotonPhi", {HistType::kTH1F, {{200, -TMath::Pi() / 2, TMath::Pi() / 2}}}); + + registryData.add("number_of_events_data", "number of events in data", HistType::kTH1D, {{20, 0, 20, "Event Cuts"}}); + registryData.add("number_of_events_vsmultiplicity", "number of events in data vs multiplicity", HistType::kTH1D, {{101, 0, 101, "Multiplicity percentile"}}); + registryData.add("h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", kTH1F, {{200, 0., 200.}}); + registryData.add("h_track_eta", "track #eta;#eta_{track};entries", kTH1F, {{100, -1.f, 1.f}}); + registryData.add("h_track_phi", "track #varphi;#varphi_{track};entries", kTH1F, {{80, -1.f, 7.f}}); + registryData.add("h_track_pt_sel", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", kTH1F, {{200, 0., 200.}}); + registryData.add("h_track_eta_sel", "track #eta;#eta_{track};entries", kTH1F, {{100, -1.f, 1.f}}); + registryData.add("h_track_phi_sel", "track #varphi;#varphi_{track};entries", kTH1F, {{80, -1.f, 7.f}}); + + registryData.add("FJetaHistogram", "FJetaHistogram", kTH1F, {JetaxisEta}); + registryData.add("FJphiHistogram", "FJphiHistogram", kTH1F, {JetaxisPhi}); + registryData.add("FJptHistogram", "FJptHistogram", kTH1F, {JetaxisPt}); + registryData.add("nJetsPerEvent", "nJetsPerEvent", kTH1F, {{10, 0.0, 10.0}}); + registryData.add("nJetsPerEventsel", "nJetsPerEventsel", kTH1F, {{10, 0.0, 10.0}}); + registryData.add("nV0sPerEvent", "nV0sPerEvent", kTH1F, {{10, 0.0, 10.0}}); + registryData.add("FJetaHistogramsel", "FJetaHistogramsel", kTH1F, {JetaxisEta}); + registryData.add("FJphiHistogramsel", "FJphiHistogramsel", kTH1F, {JetaxisPhi}); + registryData.add("FJptHistogramsel", "FJptHistogramsel", kTH1F, {JetaxisPt}); + + registryData.add("FLeadingJetaHistogramsel", "FLeadingJetaHistogramsel", kTH1F, {JetaxisEta}); + registryData.add("FLeadingJphiHistogramsel", "FLeadingJphiHistogramsel", kTH1F, {JetaxisPhi}); + registryData.add("FLeadingJptHistogramsel", "FLeadingJptHistogramsel", kTH1F, {JetaxisPt}); + + registryData.add("LambdaPtMass", "LambdaPtMass", HistType::kTH2F, {ptAxis, invMassLambdaAxis}); + registryData.add("AntiLambdaPtMass", "AntiLambdaPtMass", HistType::kTH2F, {ptAxis, invMassLambdaAxis}); + + registryData.add("hMassLambda", "hMassLambda", {HistType::kTH1F, {{200, 0.9f, 1.2f}}}); + registryData.add("hMassAntiLambda", "hMassAntiLambda", {HistType::kTH1F, {{200, 0.9f, 1.2f}}}); + registryData.add("V0pTInLab", "V0pTInLab", kTH1F, {axisPT}); + + registryData.add("V0pxInLab", "V0pxInLab", kTH1F, {axisPx}); + registryData.add("V0pyInLab", "V0pyInLab", kTH1F, {axisPy}); + registryData.add("V0pzInLab", "V0pzInLab", kTH1F, {axisPz}); + + registryData.add("V0pxInRest_frame", "V0pxInRest_frame", kTH1F, {axisPx}); + registryData.add("V0pyInRest_frame", "V0pyInRest_frame", kTH1F, {axisPy}); + registryData.add("V0pzInRest_frame", "V0pzInRest_frame", kTH1F, {axisPz}); + + registryData.add("V0protonpxInLab", "V0protonpxInLab", kTH1F, {axisPx}); + registryData.add("V0protonpyInLab", "V0protonpyInLab", kTH1F, {axisPy}); + registryData.add("V0protonpzInLab", "V0protonpzInLab", kTH1F, {axisPz}); + registryData.add("V0protonphiInLab", "V0protonphiInLab", kTH1F, {axisPhi}); + + registryData.add("V0protonpxInRest_frame", "V0protonpxInRest_frame", kTH1F, {axisPx}); + registryData.add("V0protonpyInRest_frame", "V0protonpyInRest_frame", kTH1F, {axisPy}); + registryData.add("V0protonpzInRest_frame", "V0protonpzInRest_frame", kTH1F, {axisPz}); + registryData.add("V0protonMassInRest_frame", "V0protonMassInRest_frame", kTH1F, {axisMass}); + registryData.add("V0protonphiInRest_frame", "V0protonphiInRest_frame", kTH1F, {axisPhi}); + + registryData.add("V0protonpxInJetV0frame", "V0protonpxInJetV0frame", kTH1F, {axisPx}); + registryData.add("V0protonpyInJetV0frame", "V0protonpyInJetV0frame", kTH1F, {axisPy}); + registryData.add("V0protonpzInJetV0frame", "V0protonpzInJetV0frame", kTH1F, {axisPz}); + + registryData.add("V0LambdapxInJetV0frame", "V0LambdapxInJetV0frame", kTH1F, {axisPx}); + registryData.add("V0LambdapyInJetV0frame", "V0LambdapyInJetV0frame", kTH1F, {axisPy}); + registryData.add("V0LambdapzInJetV0frame", "V0LambdapzInJetV0frame", kTH1F, {axisPz}); + registryData.add("hLambdamassandSinPhi", "hLambdamassandSinPhi", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + registryData.add("profileLambda", "Invariant Mass vs sin(phi)", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + registryData.add("hLambdaPhiandSinPhi", "hLambdaPhiandSinPhi", kTH2F, {{200, -TMath::Pi() / 2, TMath::Pi() / 2}, {200, -1, 1}}); + registryData.add("V0LambdaprotonPhi", "V0LambdaprotonPhi", {HistType::kTH1F, {{200, -TMath::Pi() / 2, TMath::Pi() / 2}}}); + + registryData.add("profileAntiLambda", "Invariant Mass vs sin(phi)", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + registryData.add("hAntiLambdamassandSinPhi", "hAntiLambdaPhiandSinPhi", kTH2F, {{200, -TMath::Pi() / 2, TMath::Pi() / 2}, {200, -1, 1}}); + + registryData.add("TProfile2DLambdaPtMassSinPhi", "", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + registryData.add("TProfile2DAntiLambdaPtMassSinPhi", "", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + registryData.add("TProfile2DLambdaPtMassSintheta", "", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + registryData.add("TProfile2DAntiLambdaPtMassSintheta", "", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + + registryData.add("TProfile2DLambdaPtMassCosSquareTheta", "", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + registryData.add("TProfile2DAntiLambdaPtMassCosSquareTheta", "", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + + registryData.add("hNEvents", "hNEvents", {HistType::kTH1I, {{10, 0.f, 10.f}}}); + registryData.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "all"); + registryData.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "sel8"); + registryData.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "TVX"); + registryData.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(4, "zvertex"); + registryData.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(5, "TFBorder"); + registryData.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(6, "ITSROFBorder"); + registryData.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(7, "isTOFVertexMatched"); + registryData.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(8, "isGoodZvtxFT0vsPV"); + registryData.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(9, "Applied selected"); + + registryV0Data.add("hLambdaPt", "hLambdaPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}); + registryV0Data.add("hAntiLambdaPt", "hAntiLambdaPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}); + + registryV0Data.add("hMassVsPtLambda", "hMassVsPtLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {200, 1.016f, 1.216f}}}); + registryV0Data.add("hMassVsPtAntiLambda", "hMassVsPtAntiLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {200, 1.016f, 1.216f}}}); + registryV0Data.add("hMassLambda", "hMassLambda", {HistType::kTH1F, {{200, 0.9f, 1.2f}}}); + registryV0Data.add("hMassAntiLambda", "hMassAntiLambda", {HistType::kTH1F, {{200, 0.9f, 1.2f}}}); + registryV0Data.add("nV0sPerEvent", "nV0sPerEvent", kTH1F, {{10, 0.0, 10.0}}); + registryV0Data.add("nV0sPerEventsel", "nV0sPerEventsel", kTH1F, {{10, 0.0, 10.0}}); + + registryV0Data.add("hprotoncosthetainLab", "hprotoncosthetainLab", kTH1F, {{200, -1.f, 1.f}}); + registryV0Data.add("hprotonsinthetainLab", "hprotonsinthetainLab", kTH1F, {{200, -1.f, 1.f}}); + registryV0Data.add("hprotonthetainLab", "hprotonthetainLab", kTH1F, {{200, 0.f, TMath::Pi()}}); + + registryV0Data.add("hprotoncosthetainV0", "hprotoncosthetainV0", kTH1F, {{200, -1.f, 1.f}}); + registryV0Data.add("hprotonsinthetainV0", "hprotonsinthetainV0", kTH1F, {{200, -1.f, 1.f}}); + registryV0Data.add("hprotonthetainV0", "hprotonthetainV0", kTH1F, {{200, 0.f, TMath::Pi()}}); + + registryV0Data.add("hprotoncosthetainJetV0", "hprotoncosthetainJetV0", kTH1F, {{200, -1.f, 1.f}}); + registryV0Data.add("hprotonsinthetainJetV0", "hprotonsinthetainJetV0", kTH1F, {{200, -1.f, 1.f}}); + registryV0Data.add("hprotonthetainJetV0", "hprotonthetainJetV0", kTH1F, {{200, 0.f, TMath::Pi()}}); + + registryV0Data.add("hprotoncosSquarethetainLab", "hprotoncosSquarethetainLab", kTH1F, {{200, -1.f, 1.f}}); + registryV0Data.add("hprotoncosSquarethetainV0", "hprotoncosSquarethetainV0", kTH1F, {{200, -1.f, 1.f}}); + registryV0Data.add("hprotoncosSquarethetainJetV0", "hprotoncosSquarethetainJetV0", kTH1F, {{200, -1.f, 1.f}}); + + registryV0Data.add("hLambdamassandSinthetainV0", "hLambdamassandSinthetainV0", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + registryV0Data.add("hLambdamassandCosthetainV0", "hLambdamassandCosthetainV0", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + registryV0Data.add("hLambdamassandCosSquarethetainV0", "hLambdamassandCosSquarethetainV0", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + + registryV0Data.add("hLambdamassandSinthetainJetV0", "hLambdamassandSinthetainJetV0", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + registryV0Data.add("hLambdamassandCosthetainJetV0", "hLambdamassandCosthetainJetV0", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + registryV0Data.add("hLambdamassandCosSquarethetainJetV0", "hLambdamassandCosSquarethetainJetV0", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + + registryV0Data.add("AverageSinthetainV0", "AverageSinthetainV0", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + registryV0Data.add("AverageCosSquarethetainV0", "AverageCosSquarethetainV0", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + + registryV0Data.add("AverageSinthetainJetV0", "AverageSinthetainJetV0", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + registryV0Data.add("AverageCosSquarethetainJetV0", "AverageCosSquarethetainJetV0", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + + // LongitudinalPolarization event selection + registryLongitudinalPolarization.add("hNEvents", "hNEvents", {HistType::kTH1I, {{5, 0.f, 5.f}}}); + registryLongitudinalPolarization.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "all"); + registryLongitudinalPolarization.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "sel8"); + registryLongitudinalPolarization.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "zvertex"); + registryLongitudinalPolarization.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(4, "isGoodZvtxFT0vsPV"); + registryLongitudinalPolarization.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(5, "isNoSameBunchPileup"); + registryLongitudinalPolarization.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(6, "Applied selected"); + + registryLongitudinalPolarization.add("hMassVsPtLambda", "hMassVsPtLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {200, 1.016f, 1.216f}}}); + registryLongitudinalPolarization.add("hMassVsPtAntiLambda", "hMassVsPtAntiLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {200, 1.016f, 1.216f}}}); + + registryLongitudinalPolarization.add("V0pxInRest_frame", "V0pxInRest_frame", kTH1F, {axisPx}); + registryLongitudinalPolarization.add("V0pyInRest_frame", "V0pyInRest_frame", kTH1F, {axisPy}); + registryLongitudinalPolarization.add("V0pzInRest_frame", "V0pzInRest_frame", kTH1F, {axisPz}); + + registryLongitudinalPolarization.add("nV0sPerEvent", "nV0sPerEvent", kTH1F, {{10, 0.0, 10.0}}); + registryLongitudinalPolarization.add("nV0sPerEventsel", "nV0sPerEventsel", kTH1F, {{10, 0.0, 10.0}}); + + registryLongitudinalPolarization.add("hprotoncosthetainV0", "hprotoncosthetainV0", kTH1F, {{200, -1.f, 1.f}}); + registryLongitudinalPolarization.add("hprotoncosSquarethetainV0", "hprotoncosSquarethetainV0", kTH1F, {{200, -1.f, 1.f}}); + registryLongitudinalPolarization.add("hLambdamassandCosthetaInV0", "hLambdamassandCosthetaInV0", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + registryLongitudinalPolarization.add("TProfile2DLambdaPtMassCostheta", "", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + registryLongitudinalPolarization.add("TProfile2DLambdaPtMassCosSquareTheta", "", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + + registryLongitudinalPolarization.add("hantiprotoncosthetainV0", "hantiprotoncosthetainV0", kTH1F, {{200, -1.f, 1.f}}); + registryLongitudinalPolarization.add("hantiprotoncosSquarethetainV0", "hantiprotoncosSquarethetainV0", kTH1F, {{200, -1.f, 1.f}}); + registryLongitudinalPolarization.add("hAntiLambdamassandCosthetaInV0", "hAntiLambdamassandCosthetaInV0", kTH2F, {{200, 0.9, 1.2}, {200, -1, 1}}); + registryLongitudinalPolarization.add("TProfile2DAntiLambdaPtMassCostheta", "TProfile2DAntiLambdaPtMassCostheta", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + registryLongitudinalPolarization.add("TProfile2DAntiLambdaPtMassCosSquareTheta", "TProfile2DAntiLambdaPtMassCosSquareTheta", kTProfile2D, {TProfile2DaxisMass, TProfile2DaxisPt}); + + registryLongitudinalPolarization.add("TProfile1DLambdaPtMassCostheta", "Invariant Mass vs cos(#theta)", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + registryLongitudinalPolarization.add("TProfile1DAntiLambdaPtMassCostheta", "Invariant Mass vs cos(#theta)", {HistType::kTProfile, {{200, 0.9, 1.2}}}); + } + double massPr = o2::constants::physics::MassProton; + double massLambda = o2::constants::physics::MassLambda; + double massPi = o2::constants::physics::MassPionCharged; + ROOT::Math::PxPyPzMVector ProtonVec, PionVec, LambdaVec, ProtonBoostedVec, LambdaBoostedVec; + + TMatrixD LorentzTransInV0frame(double ELambda, double Lambdapx, double Lambdapy, double Lambdapz) + { + double PLambda = sqrt(Lambdapx * Lambdapx + Lambdapy * Lambdapy + Lambdapz * Lambdapz); + double LambdaMass = sqrt(ELambda * ELambda - PLambda * PLambda); + double Alpha = 1 / (LambdaMass * (ELambda + LambdaMass)); + TMatrixD matrixLabToLambda(4, 4); + matrixLabToLambda(0, 0) = ELambda / LambdaMass; + matrixLabToLambda(0, 1) = -Lambdapx / LambdaMass; + matrixLabToLambda(0, 2) = -Lambdapy / LambdaMass; + matrixLabToLambda(0, 3) = -Lambdapz / LambdaMass; + matrixLabToLambda(1, 0) = -Lambdapx / LambdaMass; + matrixLabToLambda(1, 1) = 1 + Alpha * Lambdapx * Lambdapx; + matrixLabToLambda(1, 2) = Alpha * Lambdapx * Lambdapy; + matrixLabToLambda(1, 3) = Alpha * Lambdapx * Lambdapz; + matrixLabToLambda(2, 0) = -Lambdapy / LambdaMass; + matrixLabToLambda(2, 1) = Alpha * Lambdapy * Lambdapx; + matrixLabToLambda(2, 2) = 1 + Alpha * Lambdapy * Lambdapy; + matrixLabToLambda(2, 3) = Alpha * Lambdapy * Lambdapz; + matrixLabToLambda(3, 0) = -Lambdapz / LambdaMass; + matrixLabToLambda(3, 1) = Alpha * Lambdapz * Lambdapx; + matrixLabToLambda(3, 2) = Alpha * Lambdapz * Lambdapy; + matrixLabToLambda(3, 3) = 1 + Alpha * Lambdapz * Lambdapz; + return matrixLabToLambda; + } + TMatrixD MyTMatrixTranslationToJet(double Jetpx, double Jetpy, double Jetpz, double Lambdapx, double Lambdapy, double Lambdapz) + { + TVector3 UnitX(1.0, 0.0, 0.0); + TVector3 UnitY(0.0, 1.0, 0.0); + TVector3 UnitZ(0.0, 0.0, 1.0); + TVector3 JetP(Jetpx, Jetpy, Jetpz); + TVector3 V0LambdaP(Lambdapx, Lambdapy, Lambdapz); + TVector3 vortex_y = (JetP.Cross(V0LambdaP)); + + TVector3 z_hat = JetP.Unit(); + TVector3 y_hat = vortex_y.Unit(); + TVector3 x_hat1 = y_hat.Cross(z_hat); + TVector3 x_hat = x_hat1.Unit(); + + TMatrixD matrixLabToJet(4, 4); + matrixLabToJet(0, 0) = 1; + matrixLabToJet(0, 1) = 0.0; + matrixLabToJet(0, 2) = 0.0; + matrixLabToJet(0, 3) = 0.0; + matrixLabToJet(1, 0) = 0.0; + matrixLabToJet(1, 1) = x_hat.X(); + matrixLabToJet(1, 2) = x_hat.Y(); + matrixLabToJet(1, 3) = x_hat.Z(); + matrixLabToJet(2, 0) = 0.0; + matrixLabToJet(2, 1) = y_hat.X(); + matrixLabToJet(2, 2) = y_hat.Y(); + matrixLabToJet(2, 3) = y_hat.Z(); + matrixLabToJet(3, 0) = 0.0; + matrixLabToJet(3, 1) = z_hat.X(); + matrixLabToJet(3, 2) = z_hat.Y(); + matrixLabToJet(3, 3) = z_hat.Z(); + return matrixLabToJet; + } + // aod::MyCollision const& collision + void processJetV0Analysis(aod::MyTable const& myv0s, aod::MyTableJet const& myJets) + { + for (auto& candidate : myv0s) { + registry.fill(HIST("hMassLambda"), candidate.v0Lambdamass()); + registry.fill(HIST("V0pTInLab"), candidate.v0pt()); + registry.fill(HIST("hMassVsPtLambda"), candidate.v0pt(), candidate.v0Lambdamass()); + registry.fill(HIST("V0pxInLab"), candidate.v0px()); + registry.fill(HIST("V0pyInLab"), candidate.v0py()); + registry.fill(HIST("V0pzInLab"), candidate.v0pz()); + registry.fill(HIST("V0protonpxInLab"), candidate.v0protonpx()); + registry.fill(HIST("V0protonpyInLab"), candidate.v0protonpy()); + registry.fill(HIST("V0protonpzInLab"), candidate.v0protonpz()); + double protonsinPhiInLab = candidate.v0protonpy() / sqrt(candidate.v0protonpx() * candidate.v0protonpx() + candidate.v0protonpy() * candidate.v0protonpy()); + registry.fill(HIST("V0protonphiInLab"), protonsinPhiInLab); + double PLambda = sqrt(candidate.v0px() * candidate.v0px() + candidate.v0py() * candidate.v0py() + candidate.v0pz() * candidate.v0pz()); + double ELambda = sqrt(candidate.v0Lambdamass() * candidate.v0Lambdamass() + PLambda * PLambda); + TMatrixD pLabV0(4, 1); + pLabV0(0, 0) = ELambda; + pLabV0(1, 0) = candidate.v0px(); + pLabV0(2, 0) = candidate.v0py(); + pLabV0(3, 0) = candidate.v0pz(); + TMatrixD V0InV0(4, 1); + V0InV0 = LorentzTransInV0frame(ELambda, candidate.v0px(), candidate.v0py(), candidate.v0pz()) * pLabV0; + registry.fill(HIST("V0pxInRest_frame"), V0InV0(1, 0)); + registry.fill(HIST("V0pyInRest_frame"), V0InV0(2, 0)); + registry.fill(HIST("V0pzInRest_frame"), V0InV0(3, 0)); + } + for (auto& candidate : myv0s) { + double PLambda = sqrt(candidate.v0px() * candidate.v0px() + candidate.v0py() * candidate.v0py() + candidate.v0pz() * candidate.v0pz()); + double ELambda = sqrt(candidate.v0Lambdamass() * candidate.v0Lambdamass() + PLambda * PLambda); + TMatrixD pLabproton(4, 1); + double protonE = sqrt(massPr * massPr + candidate.v0protonpx() * candidate.v0protonpx() + candidate.v0protonpy() * candidate.v0protonpy() + candidate.v0protonpz() * candidate.v0protonpz()); + pLabproton(0, 0) = protonE; + pLabproton(1, 0) = candidate.v0protonpx(); + pLabproton(2, 0) = candidate.v0protonpy(); + pLabproton(3, 0) = candidate.v0protonpz(); + TMatrixD protonInV0(4, 1); + protonInV0 = LorentzTransInV0frame(ELambda, candidate.v0px(), candidate.v0py(), candidate.v0pz()) * pLabproton; + double protonMassInV0 = sqrt(protonInV0(0, 0) * protonInV0(0, 0) - protonInV0(1, 0) * protonInV0(1, 0) - protonInV0(2, 0) * protonInV0(2, 0) - protonInV0(3, 0) * protonInV0(3, 0)); + registry.fill(HIST("V0protonMassInRest_frame"), protonMassInV0); + registry.fill(HIST("V0protonpxInRest_frame"), protonInV0(1, 0)); + registry.fill(HIST("V0protonpyInRest_frame"), protonInV0(2, 0)); + registry.fill(HIST("V0protonpzInRest_frame"), protonInV0(3, 0)); + double protonsinPhiInV0frame = protonInV0(2, 0) / sqrt(protonInV0(1, 0) * protonInV0(1, 0) + protonInV0(2, 0) * protonInV0(2, 0)); + registry.fill(HIST("V0protonphiInRest_frame"), protonsinPhiInV0frame); + } + + for (auto& Jet : myJets) { + registry.fill(HIST("JetpxInLab"), Jet.jetpx()); + registry.fill(HIST("JetpyInLab"), Jet.jetpy()); + registry.fill(HIST("JetpzInLab"), Jet.jetpz()); + registry.fill(HIST("JetpTInLab"), Jet.jetpt()); + } + } + PROCESS_SWITCH(LfMyV0s, processJetV0Analysis, "processJetV0Analysis", true); + void processLeadingJetV0Analysis(aod::MyTable const& myv0s, aod::MyTableLeadingJet const& myleadingJets) + { + for (auto& LeadingJet : myleadingJets) { + int V0Numbers = 0; + double protonsinPhiInJetV0frame = 0; + for (auto& candidate : myv0s) { + if (candidate.mycollisionv0() == LeadingJet.mycollisionleadingjet()) { + V0Numbers = V0Numbers + 1; + double PLambda = sqrt(candidate.v0px() * candidate.v0px() + candidate.v0py() * candidate.v0py() + candidate.v0pz() * candidate.v0pz()); + double ELambda = sqrt(candidate.v0Lambdamass() * candidate.v0Lambdamass() + PLambda * PLambda); + double protonE = sqrt(massPr * massPr + candidate.v0protonpx() * candidate.v0protonpx() + candidate.v0protonpy() * candidate.v0protonpy() + candidate.v0protonpz() * candidate.v0protonpz()); + + TMatrixD pLabV0(4, 1); + pLabV0(0, 0) = ELambda; + pLabV0(1, 0) = candidate.v0px(); + pLabV0(2, 0) = candidate.v0py(); + pLabV0(3, 0) = candidate.v0pz(); + + TMatrixD lambdaInJet(4, 1); + lambdaInJet = MyTMatrixTranslationToJet(LeadingJet.leadingjetpx(), LeadingJet.leadingjetpy(), LeadingJet.leadingjetpz(), candidate.v0px(), candidate.v0py(), candidate.v0pz()) * pLabV0; + + TMatrixD lambdaInJetV0(4, 1); + lambdaInJetV0 = LorentzTransInV0frame(ELambda, lambdaInJet(1, 0), lambdaInJet(2, 0), lambdaInJet(3, 0)) * MyTMatrixTranslationToJet(LeadingJet.leadingjetpx(), LeadingJet.leadingjetpy(), LeadingJet.leadingjetpz(), candidate.v0px(), candidate.v0py(), candidate.v0pz()) * pLabV0; + registry.fill(HIST("V0LambdapxInJetV0frame"), lambdaInJetV0(1, 0)); + registry.fill(HIST("V0LambdapyInJetV0frame"), lambdaInJetV0(2, 0)); + registry.fill(HIST("V0LambdapzInJetV0frame"), lambdaInJetV0(3, 0)); + + TMatrixD pLabproton(4, 1); + pLabproton(0, 0) = protonE; + pLabproton(1, 0) = candidate.v0protonpx(); + pLabproton(2, 0) = candidate.v0protonpy(); + pLabproton(3, 0) = candidate.v0protonpz(); + TMatrixD protonInJetV0(4, 1); + protonInJetV0 = LorentzTransInV0frame(ELambda, lambdaInJet(1, 0), lambdaInJet(2, 0), lambdaInJet(3, 0)) * MyTMatrixTranslationToJet(LeadingJet.leadingjetpx(), LeadingJet.leadingjetpy(), LeadingJet.leadingjetpz(), candidate.v0px(), candidate.v0py(), candidate.v0pz()) * pLabproton; + registry.fill(HIST("V0protonpxInJetV0frame"), protonInJetV0(1, 0)); + registry.fill(HIST("V0protonpyInJetV0frame"), protonInJetV0(2, 0)); + registry.fill(HIST("V0protonpzInJetV0frame"), protonInJetV0(3, 0)); + protonsinPhiInJetV0frame = protonsinPhiInJetV0frame + protonInJetV0(2, 0) / sqrt(protonInJetV0(1, 0) * protonInJetV0(1, 0) + protonInJetV0(2, 0) * protonInJetV0(2, 0)); + } + } + for (auto& candidate : myv0s) { + if (candidate.mycollisionv0() == LeadingJet.mycollisionleadingjet()) { + registry.fill(HIST("V0protonphiInJetV0frame"), protonsinPhiInJetV0frame / V0Numbers); + registry.fill(HIST("hLambdamassandSinPhi"), candidate.v0Lambdamass(), protonsinPhiInJetV0frame / V0Numbers); + registry.fill(HIST("hLambdaPhiandSinPhi"), TMath::ASin(protonsinPhiInJetV0frame / V0Numbers), protonsinPhiInJetV0frame / V0Numbers); + registry.fill(HIST("V0LambdaprotonPhi"), TMath::ASin(protonsinPhiInJetV0frame / V0Numbers)); + registry.fill(HIST("profile"), candidate.v0Lambdamass(), protonsinPhiInJetV0frame / V0Numbers); + } + } + } + for (auto& LeadingJet : myleadingJets) { + registry.fill(HIST("LeadingJetpx"), LeadingJet.leadingjetpx()); + registry.fill(HIST("LeadingJetpy"), LeadingJet.leadingjetpy()); + registry.fill(HIST("LeadingJetpz"), LeadingJet.leadingjetpz()); + registry.fill(HIST("LeadingJetpT"), LeadingJet.leadingjetpt()); + } + } + PROCESS_SWITCH(LfMyV0s, processLeadingJetV0Analysis, "processLeadingJetV0Analysis", true); + + void processLeadingJetAntiV0Analysis(aod::MyTableAnti const& myv0s, aod::MyTableLeadingJet const& myleadingJets) + { + for (auto& LeadingJet : myleadingJets) { + int V0Numbers = 0; + double protonsinPhiInJetV0frame = 0; + for (auto& candidate : myv0s) { + if (candidate.mycollisionv0() == LeadingJet.mycollisionleadingjet()) { + V0Numbers = V0Numbers + 1; + double PLambda = sqrt(candidate.v0px() * candidate.v0px() + candidate.v0py() * candidate.v0py() + candidate.v0pz() * candidate.v0pz()); + double ELambda = sqrt(candidate.v0Lambdamass() * candidate.v0Lambdamass() + PLambda * PLambda); + double protonE = sqrt(massPr * massPr + candidate.v0protonpx() * candidate.v0protonpx() + candidate.v0protonpy() * candidate.v0protonpy() + candidate.v0protonpz() * candidate.v0protonpz()); + + TMatrixD pLabV0(4, 1); + pLabV0(0, 0) = ELambda; + pLabV0(1, 0) = candidate.v0px(); + pLabV0(2, 0) = candidate.v0py(); + pLabV0(3, 0) = candidate.v0pz(); + + TMatrixD lambdaInJet(4, 1); + lambdaInJet = MyTMatrixTranslationToJet(LeadingJet.leadingjetpx(), LeadingJet.leadingjetpy(), LeadingJet.leadingjetpz(), candidate.v0px(), candidate.v0py(), candidate.v0pz()) * pLabV0; + + TMatrixD lambdaInJetV0(4, 1); + lambdaInJetV0 = LorentzTransInV0frame(ELambda, lambdaInJet(1, 0), lambdaInJet(2, 0), lambdaInJet(3, 0)) * MyTMatrixTranslationToJet(LeadingJet.leadingjetpx(), LeadingJet.leadingjetpy(), LeadingJet.leadingjetpz(), candidate.v0px(), candidate.v0py(), candidate.v0pz()) * pLabV0; + + TMatrixD pLabproton(4, 1); + pLabproton(0, 0) = protonE; + pLabproton(1, 0) = candidate.v0protonpx(); + pLabproton(2, 0) = candidate.v0protonpy(); + pLabproton(3, 0) = candidate.v0protonpz(); + TMatrixD protonInJetV0(4, 1); + protonInJetV0 = LorentzTransInV0frame(ELambda, lambdaInJet(1, 0), lambdaInJet(2, 0), lambdaInJet(3, 0)) * MyTMatrixTranslationToJet(LeadingJet.leadingjetpx(), LeadingJet.leadingjetpy(), LeadingJet.leadingjetpz(), candidate.v0px(), candidate.v0py(), candidate.v0pz()) * pLabproton; + protonsinPhiInJetV0frame = protonsinPhiInJetV0frame + protonInJetV0(2, 0) / sqrt(protonInJetV0(1, 0) * protonInJetV0(1, 0) + protonInJetV0(2, 0) * protonInJetV0(2, 0)); + } + } + for (auto& candidate : myv0s) { + if (candidate.mycollisionv0() == LeadingJet.mycollisionleadingjet()) { + registry.fill(HIST("V0antiprotonphiInJetV0frame"), protonsinPhiInJetV0frame / V0Numbers); + registry.fill(HIST("hAntiLambdamassandSinPhi"), candidate.v0Lambdamass(), protonsinPhiInJetV0frame / V0Numbers); + registry.fill(HIST("hAntiLambdaPhiandSinPhi"), TMath::ASin(protonsinPhiInJetV0frame / V0Numbers), protonsinPhiInJetV0frame / V0Numbers); + registry.fill(HIST("V0AntiLambdaprotonPhi"), TMath::ASin(protonsinPhiInJetV0frame / V0Numbers)); + registry.fill(HIST("profileAntiV0"), candidate.v0Lambdamass(), protonsinPhiInJetV0frame / V0Numbers); + } + } + } + for (auto& candidate : myv0s) { + registry.fill(HIST("hMassVsPtAntiLambda"), candidate.v0pt(), candidate.v0Lambdamass()); + } + } + PROCESS_SWITCH(LfMyV0s, processLeadingJetAntiV0Analysis, "processLeadingJetAntiV0Analysis", true); + + // ITS hit + template + bool hasITSHit(const TrackIts& track, int layer) + { + int ibit = layer - 1; + return (track.itsClusterMap() & (1 << ibit)); + } + + // Single-Track Selection for Particles inside Jets + template + bool passedTrackSelectionForJetReconstruction(const JetTrack& track) + { + const int minTpcCr = 70; + const double minCrFindable = 0.8; + const double maxChi2Tpc = 4.0; + const double maxChi2Its = 36.0; + const double maxPseudorapidity = 0.9; + const double minPtTrack = 0.1; + const double dcaxyMaxTrackPar0 = 0.0105; + const double dcaxyMaxTrackPar1 = 0.035; + const double dcaxyMaxTrackPar2 = 1.1; + const double dcazMaxTrack = 2.0; + + if (!track.hasITS()) + return false; + if ((!hasITSHit(track, 1)) && (!hasITSHit(track, 2)) && (!hasITSHit(track, 3))) + return false; + if (!track.hasTPC()) + return false; + if (track.tpcNClsCrossedRows() < minTpcCr) + return false; + if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < minCrFindable) + return false; + if (track.tpcChi2NCl() > maxChi2Tpc) + return false; + if (track.itsChi2NCl() > maxChi2Its) + return false; + if (track.eta() < -maxPseudorapidity || track.eta() > maxPseudorapidity) + return false; + if (track.pt() < minPtTrack) + return false; + if (std::fabs(track.dcaXY()) > (dcaxyMaxTrackPar0 + dcaxyMaxTrackPar1 / std::pow(track.pt(), dcaxyMaxTrackPar2))) + return false; + if (std::fabs(track.dcaZ()) > dcazMaxTrack) + return false; + return true; + } + + // init Selection + template + bool passedInitLambdaSelection(const Lambda& v0, const TrackPos& ptrack, const TrackNeg& ntrack) + { + if (v0.v0radius() < minimumV0Radius || v0.v0cosPA() < v0cospaMin || + TMath::Abs(ptrack.eta()) > V0tracketaMax || + TMath::Abs(ntrack.eta()) > V0tracketaMax) { + return false; + } + if (v0.dcaV0daughters() > dcaV0DaughtersMax) { + return false; + } + if (TMath::Abs(v0.dcanegtopv()) < dcanegtoPVmin) { + return false; + } + if (TMath::Abs(v0.dcapostopv()) < dcapostoPVmin) { + 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; + + // Momentum of Lambda Daughters + TVector3 proton(v0.pxpos(), v0.pypos(), v0.pzpos()); + TVector3 pion(v0.pxneg(), v0.pyneg(), v0.pzneg()); + + if (proton.Pt() < ptMinV0Proton) + return false; + if (proton.Pt() > ptMaxV0Proton) + return false; + if (pion.Pt() < ptMinV0Pion) + return false; + if (pion.Pt() > ptMaxV0Pion) + return false; + + // V0 Selections + if (v0.v0cosPA() < v0cospaMin) + return false; + if (v0.v0radius() < minimumV0Radius) + return false; + if (std::fabs(v0.dcaV0daughters()) > dcaV0DaughtersMax) + return false; + if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) + return false; + if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) + return false; + + if (TMath::Abs(ptrack.eta()) > V0tracketaMax || TMath::Abs(ntrack.eta()) > V0tracketaMax) { + 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; + } + // PID Selections (TOF) + 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) > v0accLambda) { + return false; + } + if (doArmenterosCut && v0.qtarm() > (paramArmenterosCut * std::abs(v0.alpha()))) + 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; + + // Momentum AntiLambda Daughters + TVector3 pion(v0.pxpos(), v0.pypos(), v0.pzpos()); + TVector3 proton(v0.pxneg(), v0.pyneg(), v0.pzneg()); + + if (proton.Pt() < ptMinV0Proton) + return false; + if (proton.Pt() > ptMaxV0Proton) + return false; + if (pion.Pt() < ptMinV0Pion) + return false; + if (pion.Pt() > ptMaxV0Pion) + return false; + + // V0 Selections + if (v0.v0cosPA() < v0cospaMin) + return false; + if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) + return false; + if (std::fabs(v0.dcaV0daughters()) > dcaV0DaughtersMax) + return false; + if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) + return false; + if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) + return false; + + if (TMath::Abs(ptrack.eta()) > V0tracketaMax || TMath::Abs(ntrack.eta()) > V0tracketaMax) { + return false; + } + + // PID Selections (TPC) + if (requireTPC) { + if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + if (ntrack.tpcNSigmaPr() < nsigmaTPCmin || ntrack.tpcNSigmaPr() > nsigmaTPCmax) + 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; + } + 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) > v0accLambda) { + return false; + } + if (doArmenterosCut && v0.qtarm() > (paramArmenterosCut * std::abs(v0.alpha()))) + return false; + return true; + } + + // 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 ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < minTpcNcrossedRowsOverFindable) + 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; + } + + ///////Event selection + template + bool AcceptEvent(TCollision const& collision) + { + if (sel8 && !collision.sel8()) { + return false; + } + registryData.fill(HIST("hNEvents"), 1.5); + + if (isTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + registryData.fill(HIST("hNEvents"), 2.5); + + if (iscutzvertex && TMath::Abs(collision.posZ()) > cutzvertex) { + return false; + } + registryData.fill(HIST("hNEvents"), 3.5); + + if (isNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return false; + } + + registryData.fill(HIST("hNEvents"), 4.5); + + if (isNoITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return false; + } + registryData.fill(HIST("hNEvents"), 5.5); + if (isVertexTOFmatched && !collision.selection_bit(aod::evsel::kIsVertexTOFmatched)) { + return false; + } + registryData.fill(HIST("hNEvents"), 6.5); + if (isGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + registryData.fill(HIST("hNEvents"), 7.5); + + return true; + } + + template + bool AcceptEventForLongitudinalPolarization(TCollision const& collision) + { + if (sel8 && !collision.sel8()) { + return false; + } + registryLongitudinalPolarization.fill(HIST("hNEvents"), 1.5); + + if (iscutzvertex && TMath::Abs(collision.posZ()) > cutzvertex) { + return false; + } + registryLongitudinalPolarization.fill(HIST("hNEvents"), 2.5); + + if (noSameBunchPileUp && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return false; + } + registryLongitudinalPolarization.fill(HIST("hNEvents"), 3.5); + // check vertex matching to FT0 + if (isGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + registryLongitudinalPolarization.fill(HIST("hNEvents"), 4.5); + + return true; + } + + using SelCollisions = soa::Join; + using StrHadronDaughterTracks = soa::Join; + void processData(SelCollisions::iterator const& collision, aod::V0Datas const& fullV0s, StrHadronDaughterTracks const& tracks) + { + registryData.fill(HIST("number_of_events_data"), 0.5); + // event selection + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) { + return; + } + // event counter: after event selection + registryData.fill(HIST("number_of_events_data"), 1.5); + // loop over reconstructed tracks + std::vector fjParticles; + for (auto const& track : tracks) { + registryData.fill(HIST("h_track_pt"), track.pt()); + registryData.fill(HIST("h_track_eta"), track.eta()); + registryData.fill(HIST("h_track_phi"), track.phi()); + if (ispassdTrackSelectionForJetReconstruction && !passedTrackSelectionForJetReconstruction(track)) { + continue; + } + registryData.fill(HIST("h_track_pt_sel"), track.pt()); + registryData.fill(HIST("h_track_eta_sel"), track.eta()); + registryData.fill(HIST("h_track_phi_sel"), track.phi()); + + // 4-momentum representation of a particle + fastjet::PseudoJet fourMomentum(track.px(), track.py(), track.pz(), track.energy(o2::constants::physics::MassPionCharged)); + fjParticles.emplace_back(fourMomentum); + } + // reject empty events + if (fjParticles.size() < 1) + return; + registryData.fill(HIST("number_of_events_data"), 2.5); + + // cluster particles using the anti-kt algorithm + fastjet::RecombinationScheme recombScheme = fastjet::E_scheme; + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet, recombScheme); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // jet selection + bool isAtLeastOneJetSelected = false; + int nJets = 0; + int nJetssel = 0; + // select most large momentum jet + float maxJetpx = 0; + float maxJetpy = 0; + float maxJetpz = 0; + float maxJeteta = 0; + float maxJetphi = 0; + float maxJetpT = 0; + float maxJetPt = -999; + for (auto& jet : jets) { + nJets++; + registryData.fill(HIST("FJetaHistogram"), jet.eta()); + registryData.fill(HIST("FJphiHistogram"), jet.phi()); + registryData.fill(HIST("FJptHistogram"), jet.pt()); + // jet must be fully contained in the acceptance + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jet, rhoPerp, rhoMPerp); + if ((std::fabs(jet.eta()) + rJet) > (etaMax - deltaEtaEdge)) { + continue; + } + + if (jet.pt() < cfgjetPtMin) + continue; + nJetssel++; + registryData.fill(HIST("FJetaHistogramsel"), jet.eta()); + registryData.fill(HIST("FJphiHistogramsel"), jet.phi()); + registryData.fill(HIST("FJptHistogramsel"), jet.pt()); + + if (jet.pt() > maxJetPt) { + maxJetpx = jet.px(); + maxJetpy = jet.py(); + maxJetpz = jet.pz(); + maxJeteta = jet.eta(); + maxJetphi = jet.phi(); + maxJetpT = jet.pt(); + maxJetPt = maxJetpT; + } + } + if (maxJetpT > 0) { + registryData.fill(HIST("FLeadingJetaHistogramsel"), maxJeteta); + registryData.fill(HIST("FLeadingJphiHistogramsel"), maxJetphi); + registryData.fill(HIST("FLeadingJptHistogramsel"), maxJetpT); + } + registryData.fill(HIST("nJetsPerEvent"), nJets); + registryData.fill(HIST("nJetsPerEventsel"), nJetssel); + isAtLeastOneJetSelected = true; + if (!isAtLeastOneJetSelected) { + return; + } + registryData.fill(HIST("number_of_events_data"), 3.5); + // Event multiplicity + const float multiplicity = collision.centFT0M(); + registryData.fill(HIST("number_of_events_vsmultiplicity"), multiplicity); + // v0 loop + int V0Numbers = 0; + int AntiV0Numbers = 0; + for (const auto& v0 : fullV0s) { + const auto& pos = v0.posTrack_as(); + const auto& neg = v0.negTrack_as(); + TVector3 v0dir(v0.px(), v0.py(), v0.pz()); + if (passedLambdaSelection(v0, pos, neg)) { + V0Numbers = V0Numbers + 1; + registryData.fill(HIST("LambdaPtMass"), v0.pt(), v0.mLambda()); + } + if (passedAntiLambdaSelection(v0, pos, neg)) { + AntiV0Numbers = AntiV0Numbers + 1; + registryData.fill(HIST("AntiLambdaPtMass"), v0.pt(), v0.mAntiLambda()); + } + } + registryData.fill(HIST("nV0sPerEvent"), V0Numbers); + + // calculate lambda polarization induced by jet + + if (V0Numbers == 0) { + return; + } + if (maxJetpx == 0) { + return; + } + double protonsinPhiInJetV0frame = 0; + double AntiprotonsinPhiInJetV0frame = 0; + cout << maxJetpx << endl; + for (const auto& candidate : fullV0s) { + const auto& pos = candidate.posTrack_as(); + const auto& neg = candidate.negTrack_as(); + TVector3 v0dir(candidate.px(), candidate.py(), candidate.pz()); + + if (passedLambdaSelection(candidate, pos, neg)) { + registryData.fill(HIST("hMassLambda"), candidate.mLambda()); + registryData.fill(HIST("V0pTInLab"), candidate.pt()); + registryData.fill(HIST("V0pxInLab"), candidate.px()); + registryData.fill(HIST("V0pyInLab"), candidate.py()); + registryData.fill(HIST("V0pzInLab"), candidate.pz()); + registryData.fill(HIST("V0protonpxInLab"), pos.px()); + registryData.fill(HIST("V0protonpyInLab"), pos.py()); + registryData.fill(HIST("V0protonpzInLab"), pos.pz()); + + double PLambda = sqrt(candidate.px() * candidate.px() + candidate.py() * candidate.py() + candidate.pz() * candidate.pz()); + double ELambda = sqrt(candidate.mLambda() * candidate.mLambda() + PLambda * PLambda); + double protonE = sqrt(massPr * massPr + pos.px() * pos.px() + pos.py() * pos.py() + pos.pz() * pos.pz()); + + TMatrixD pLabV0(4, 1); + pLabV0(0, 0) = ELambda; + pLabV0(1, 0) = candidate.px(); + pLabV0(2, 0) = candidate.py(); + pLabV0(3, 0) = candidate.pz(); + + TMatrixD V0InV0(4, 1); + V0InV0 = LorentzTransInV0frame(ELambda, candidate.px(), candidate.py(), candidate.pz()) * pLabV0; + registryData.fill(HIST("V0pxInRest_frame"), V0InV0(1, 0)); + registryData.fill(HIST("V0pyInRest_frame"), V0InV0(2, 0)); + registryData.fill(HIST("V0pzInRest_frame"), V0InV0(3, 0)); + + double protonsinPhiInLab = candidate.py() / sqrt(candidate.px() * candidate.px() + candidate.py() * candidate.py()); + registryData.fill(HIST("V0protonphiInLab"), protonsinPhiInLab); + + TMatrixD lambdaInJet(4, 1); + lambdaInJet = MyTMatrixTranslationToJet(maxJetpx, maxJetpy, maxJetpz, candidate.px(), candidate.py(), candidate.pz()) * pLabV0; + + TMatrixD lambdaInJetV0(4, 1); + lambdaInJetV0 = LorentzTransInV0frame(ELambda, lambdaInJet(1, 0), lambdaInJet(2, 0), lambdaInJet(3, 0)) * MyTMatrixTranslationToJet(maxJetpx, maxJetpy, maxJetpz, candidate.px(), candidate.py(), candidate.pz()) * pLabV0; + registryData.fill(HIST("V0LambdapxInJetV0frame"), lambdaInJetV0(1, 0)); + registryData.fill(HIST("V0LambdapyInJetV0frame"), lambdaInJetV0(2, 0)); + registryData.fill(HIST("V0LambdapzInJetV0frame"), lambdaInJetV0(3, 0)); + + TMatrixD pLabproton(4, 1); + pLabproton(0, 0) = protonE; + pLabproton(1, 0) = pos.px(); + pLabproton(2, 0) = pos.py(); + pLabproton(3, 0) = pos.pz(); + + TMatrixD protonInV0(4, 1); + protonInV0 = LorentzTransInV0frame(ELambda, candidate.px(), candidate.py(), candidate.pz()) * pLabproton; + double protonMassInV0 = sqrt(protonInV0(0, 0) * protonInV0(0, 0) - protonInV0(1, 0) * protonInV0(1, 0) - protonInV0(2, 0) * protonInV0(2, 0) - protonInV0(3, 0) * protonInV0(3, 0)); + registryData.fill(HIST("V0protonMassInRest_frame"), protonMassInV0); + registryData.fill(HIST("V0protonpxInRest_frame"), protonInV0(1, 0)); + registryData.fill(HIST("V0protonpyInRest_frame"), protonInV0(2, 0)); + registryData.fill(HIST("V0protonpzInRest_frame"), protonInV0(3, 0)); + double protonsinPhiInV0frame = protonInV0(2, 0) / sqrt(protonInV0(1, 0) * protonInV0(1, 0) + protonInV0(2, 0) * protonInV0(2, 0)); + registryData.fill(HIST("V0protonphiInRest_frame"), protonsinPhiInV0frame); + + TMatrixD protonInJetV0(4, 1); + protonInJetV0 = LorentzTransInV0frame(ELambda, lambdaInJet(1, 0), lambdaInJet(2, 0), lambdaInJet(3, 0)) * MyTMatrixTranslationToJet(maxJetpx, maxJetpy, maxJetpz, candidate.px(), candidate.py(), candidate.pz()) * pLabproton; + registryData.fill(HIST("V0protonpxInJetV0frame"), protonInJetV0(1, 0)); + registryData.fill(HIST("V0protonpyInJetV0frame"), protonInJetV0(2, 0)); + registryData.fill(HIST("V0protonpzInJetV0frame"), protonInJetV0(3, 0)); + + double protonPinJetV0 = sqrt(protonInJetV0(1, 0) * protonInJetV0(1, 0) + protonInJetV0(2, 0) * protonInJetV0(2, 0) + protonInJetV0(3, 0) * protonInJetV0(3, 0)); + double protonPtinJetV0 = sqrt(protonInJetV0(1, 0) * protonInJetV0(1, 0) + protonInJetV0(2, 0) * protonInJetV0(2, 0)); + + double protonCosThetainJetV0 = protonInJetV0(3, 0) / protonPinJetV0; + double protonSinThetainJetV0 = protonPtinJetV0 / protonPinJetV0; + double protonthetainJetV0 = TMath::ASin(protonSinThetainJetV0); + registryV0Data.fill(HIST("hprotoncosthetainJetV0"), protonCosThetainJetV0); + registryV0Data.fill(HIST("hprotonsinthetainJetV0"), protonSinThetainJetV0); + registryV0Data.fill(HIST("hprotonthetainJetV0"), protonthetainJetV0); + registryV0Data.fill(HIST("hprotoncosSquarethetainJetV0"), protonCosThetainJetV0 * protonCosThetainJetV0); + + registryV0Data.fill(HIST("hLambdamassandSinthetainJetV0"), candidate.mLambda(), protonSinThetainJetV0); + registryV0Data.fill(HIST("hLambdamassandCosthetainJetV0"), candidate.mLambda(), protonCosThetainJetV0); + registryV0Data.fill(HIST("hLambdamassandCosSquarethetainJetV0"), candidate.mLambda(), protonCosThetainJetV0 * protonCosThetainJetV0); + + registryV0Data.fill(HIST("AverageSinthetainJetV0"), candidate.mLambda(), protonSinThetainJetV0); + registryV0Data.fill(HIST("AverageCosSquarethetainJetV0"), candidate.mLambda(), protonCosThetainJetV0 * protonCosThetainJetV0); + protonsinPhiInJetV0frame = protonsinPhiInJetV0frame + protonInJetV0(2, 0) / sqrt(protonInJetV0(1, 0) * protonInJetV0(1, 0) + protonInJetV0(2, 0) * protonInJetV0(2, 0)); + + registryData.fill(HIST("TProfile2DLambdaPtMassSinPhi"), candidate.mLambda(), candidate.pt(), protonInJetV0(2, 0) / sqrt(protonInJetV0(1, 0) * protonInJetV0(1, 0) + protonInJetV0(2, 0) * protonInJetV0(2, 0))); + registryData.fill(HIST("TProfile2DLambdaPtMassSintheta"), candidate.mLambda(), candidate.pt(), (4.0 / TMath::Pi()) * protonSinThetainJetV0); + registryData.fill(HIST("TProfile2DLambdaPtMassCosSquareTheta"), candidate.mLambda(), candidate.pt(), 3.0 * protonCosThetainJetV0 * protonCosThetainJetV0); + } + if (passedAntiLambdaSelection(candidate, pos, neg)) { + registryData.fill(HIST("hMassAntiLambda"), candidate.mAntiLambda()); + double PAntiLambda = sqrt(candidate.px() * candidate.px() + candidate.py() * candidate.py() + candidate.pz() * candidate.pz()); + double EAntiLambda = sqrt(candidate.mAntiLambda() * candidate.mAntiLambda() + PAntiLambda * PAntiLambda); + double AntiprotonE = sqrt(massPr * massPr + neg.px() * neg.px() + neg.py() * neg.py() + neg.pz() * neg.pz()); + TMatrixD pLabAntiV0(4, 1); + pLabAntiV0(0, 0) = EAntiLambda; + pLabAntiV0(1, 0) = candidate.px(); + pLabAntiV0(2, 0) = candidate.py(); + pLabAntiV0(3, 0) = candidate.pz(); + + TMatrixD AntilambdaInJet(4, 1); + AntilambdaInJet = MyTMatrixTranslationToJet(maxJetpx, maxJetpy, maxJetpz, candidate.px(), candidate.py(), candidate.pz()) * pLabAntiV0; + + TMatrixD pLabAntiproton(4, 1); + pLabAntiproton(0, 0) = AntiprotonE; + pLabAntiproton(1, 0) = neg.px(); + pLabAntiproton(2, 0) = neg.py(); + pLabAntiproton(3, 0) = neg.pz(); + TMatrixD AntiprotonInJetV0(4, 1); + AntiprotonInJetV0 = LorentzTransInV0frame(EAntiLambda, AntilambdaInJet(1, 0), AntilambdaInJet(2, 0), AntilambdaInJet(3, 0)) * MyTMatrixTranslationToJet(maxJetpx, maxJetpy, maxJetpz, candidate.px(), candidate.py(), candidate.pz()) * pLabAntiproton; + AntiprotonsinPhiInJetV0frame = AntiprotonsinPhiInJetV0frame + AntiprotonInJetV0(2, 0) / sqrt(AntiprotonInJetV0(1, 0) * AntiprotonInJetV0(1, 0) + AntiprotonInJetV0(2, 0) * AntiprotonInJetV0(2, 0)); + TMatrixD AntiprotonInV0(4, 1); + AntiprotonInV0 = LorentzTransInV0frame(EAntiLambda, candidate.px(), candidate.py(), candidate.pz()) * pLabAntiproton; + double AntiprotonPinJetV0 = sqrt(AntiprotonInJetV0(1, 0) * AntiprotonInJetV0(1, 0) + AntiprotonInJetV0(2, 0) * AntiprotonInJetV0(2, 0) + AntiprotonInJetV0(3, 0) * AntiprotonInJetV0(3, 0)); + double AntiprotonPtinJetV0 = sqrt(AntiprotonInJetV0(1, 0) * AntiprotonInJetV0(1, 0) + AntiprotonInJetV0(2, 0) * AntiprotonInJetV0(2, 0)); + double AntiprotonCosThetainJetV0 = AntiprotonInJetV0(3, 0) / AntiprotonPinJetV0; + double AntiprotonSinThetainJetV0 = AntiprotonPtinJetV0 / AntiprotonPinJetV0; + registryData.fill(HIST("TProfile2DAntiLambdaPtMassSinPhi"), candidate.mAntiLambda(), candidate.pt(), AntiprotonInJetV0(2, 0) / sqrt(AntiprotonInJetV0(1, 0) * AntiprotonInJetV0(1, 0) + AntiprotonInJetV0(2, 0) * AntiprotonInJetV0(2, 0))); + registryData.fill(HIST("TProfile2DAntiLambdaPtMassSintheta"), candidate.mAntiLambda(), candidate.pt(), (4.0 / TMath::Pi()) * AntiprotonSinThetainJetV0); + registryData.fill(HIST("TProfile2DAntiLambdaPtMassCosSquareTheta"), candidate.mAntiLambda(), candidate.pt(), 3.0 * AntiprotonCosThetainJetV0 * AntiprotonCosThetainJetV0); + } + } + + for (const auto& candidate : fullV0s) { + const auto& pos = candidate.posTrack_as(); + const auto& neg = candidate.negTrack_as(); + if (passedLambdaSelection(candidate, pos, neg)) { + registryData.fill(HIST("hLambdamassandSinPhi"), candidate.mLambda(), protonsinPhiInJetV0frame / V0Numbers); + registryData.fill(HIST("hLambdaPhiandSinPhi"), TMath::ASin(protonsinPhiInJetV0frame / V0Numbers), protonsinPhiInJetV0frame / V0Numbers); + registryData.fill(HIST("V0LambdaprotonPhi"), TMath::ASin(protonsinPhiInJetV0frame / V0Numbers)); + registryData.fill(HIST("profileLambda"), candidate.mLambda(), protonsinPhiInJetV0frame / V0Numbers); + } + if (passedAntiLambdaSelection(candidate, pos, neg)) { + registryData.fill(HIST("hAntiLambdamassandSinPhi"), candidate.mAntiLambda(), AntiprotonsinPhiInJetV0frame / AntiV0Numbers); + registryData.fill(HIST("profileAntiLambda"), candidate.mAntiLambda(), AntiprotonsinPhiInJetV0frame / AntiV0Numbers); + } + } + } + PROCESS_SWITCH(LfMyV0s, processData, "processData", true); + + void processDataV0(SelCollisions::iterator const& collision, aod::V0Datas const& fullV0s, StrHadronDaughterTracks const&) + { + registryData.fill(HIST("hNEvents"), 0.5); + if (!AcceptEvent(collision)) { + return; + } + registryData.fill(HIST("hNEvents"), 8.5); + int V0NumbersPerEvent = 0; + int V0NumbersPerEventsel = 0; + for (const auto& v0 : fullV0s) { + V0NumbersPerEvent++; + 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(); + if (passedLambdaSelection(v0, pos, neg) && ctauLambda < CtauLambda && ifpasslambda) { + V0NumbersPerEventsel++; + registryV0Data.fill(HIST("hLambdaPt"), v0.pt()); + registryV0Data.fill(HIST("hMassVsPtLambda"), v0.pt(), v0.mLambda()); + registryV0Data.fill(HIST("hMassLambda"), v0.mLambda()); + } else if (passedInitLambdaSelection(v0, pos, neg) && ifinitpasslambda) { + registryV0Data.fill(HIST("hLambdaPt"), v0.pt()); + registryV0Data.fill(HIST("hMassVsPtLambda"), v0.pt(), v0.mLambda()); + registryV0Data.fill(HIST("hMassLambda"), v0.mLambda()); + double PLambda = sqrt(v0.px() * v0.px() + v0.py() * v0.py() + v0.pz() * v0.pz()); + double ELambda = sqrt(v0.mLambda() * v0.mLambda() + PLambda * PLambda); + double protonE = sqrt(massPr * massPr + pos.px() * pos.px() + pos.py() * pos.py() + pos.pz() * pos.pz()); + TMatrixD pLabproton(4, 1); + pLabproton(0, 0) = protonE; + pLabproton(1, 0) = pos.px(); + pLabproton(2, 0) = pos.py(); + pLabproton(3, 0) = pos.pz(); + double protonCosThetainLab = pLabproton(3, 0) / pos.p(); + double protonSinThetainLab = pos.pt() / pos.p(); + double protonthetainLab = TMath::ASin(protonSinThetainLab); + registryV0Data.fill(HIST("hprotoncosthetainLab"), protonCosThetainLab); + registryV0Data.fill(HIST("hprotonsinthetainLab"), protonSinThetainLab); + registryV0Data.fill(HIST("hprotonthetainLab"), protonthetainLab); + registryV0Data.fill(HIST("hprotoncosSquarethetainLab"), protonCosThetainLab * protonCosThetainLab); + + TMatrixD protonInV0(4, 1); + protonInV0 = LorentzTransInV0frame(ELambda, v0.px(), v0.py(), v0.pz()) * pLabproton; + double protonPinV0 = sqrt(protonInV0(1, 0) * protonInV0(1, 0) + protonInV0(2, 0) * protonInV0(2, 0) + protonInV0(3, 0) * protonInV0(3, 0)); + double protonPtinV0 = sqrt(protonInV0(1, 0) * protonInV0(1, 0) + protonInV0(2, 0) * protonInV0(2, 0)); + double protonCosThetainV0 = protonInV0(3, 0) / protonPinV0; + double protonSinThetainV0 = protonPtinV0 / protonPinV0; + double protonthetainV0 = TMath::ASin(protonSinThetainV0); + registryV0Data.fill(HIST("hprotoncosthetainV0"), protonCosThetainV0); + registryV0Data.fill(HIST("hprotonsinthetainV0"), protonSinThetainV0); + registryV0Data.fill(HIST("hprotonthetainV0"), protonthetainV0); + registryV0Data.fill(HIST("hprotoncosSquarethetainV0"), protonCosThetainV0 * protonCosThetainV0); + + registryV0Data.fill(HIST("hLambdamassandSinthetainV0"), v0.mLambda(), protonSinThetainV0); + registryV0Data.fill(HIST("hLambdamassandCosthetainV0"), v0.mLambda(), protonCosThetainV0); + registryV0Data.fill(HIST("hLambdamassandCosSquarethetainV0"), v0.mLambda(), protonCosThetainV0 * protonCosThetainV0); + + registryV0Data.fill(HIST("AverageSinthetainV0"), v0.mLambda(), protonSinThetainV0); + registryV0Data.fill(HIST("AverageCosSquarethetainV0"), v0.mLambda(), protonCosThetainV0 * protonCosThetainV0); + } + if (passedAntiLambdaSelection(v0, pos, neg) && ctauAntiLambda < CtauLambda && ifpasslambda) { + registryV0Data.fill(HIST("hAntiLambdaPt"), v0.pt()); + registryV0Data.fill(HIST("hMassVsPtAntiLambda"), v0.pt(), v0.mAntiLambda()); + registryV0Data.fill(HIST("hMassAntiLambda"), v0.mAntiLambda()); + } else if (passedInitLambdaSelection(v0, pos, neg) && ifinitpasslambda) { + registryV0Data.fill(HIST("hAntiLambdaPt"), v0.pt()); + registryV0Data.fill(HIST("hMassVsPtAntiLambda"), v0.pt(), v0.mAntiLambda()); + registryV0Data.fill(HIST("hMassAntiLambda"), v0.mAntiLambda()); + } + } + registryV0Data.fill(HIST("nV0sPerEvent"), V0NumbersPerEvent); + registryV0Data.fill(HIST("nV0sPerEventsel"), V0NumbersPerEventsel); + } + PROCESS_SWITCH(LfMyV0s, processDataV0, "processDataV0", true); + + void processLongitudinalPolarization(SelCollisions::iterator const& collision, aod::V0Datas const& fullV0s, StrHadronDaughterTracks const&) + { + registryLongitudinalPolarization.fill(HIST("hNEvents"), 0.5); + if (!AcceptEventForLongitudinalPolarization(collision)) { + return; + } + registryLongitudinalPolarization.fill(HIST("hNEvents"), 5.5); + int V0NumbersPerEvent = 0; + int V0NumbersPerEventsel = 0; + for (const auto& v0 : fullV0s) { + V0NumbersPerEvent++; + 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(); + + if (passedLambdaSelection(v0, pos, neg) && ctauLambda < CtauLambda && ifpasslambda) { + V0NumbersPerEventsel++; + registryLongitudinalPolarization.fill(HIST("hMassVsPtLambda"), v0.pt(), v0.mLambda()); + + ProtonVec = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPr); + PionVec = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPi); + LambdaVec = ProtonVec + PionVec; + LambdaVec.SetM(massLambda); + ROOT::Math::Boost boost{LambdaVec.BoostToCM()}; + ProtonBoostedVec = boost(ProtonVec); + LambdaBoostedVec = boost(LambdaVec); + + registryLongitudinalPolarization.fill(HIST("V0pxInRest_frame"), LambdaBoostedVec.Px()); + registryLongitudinalPolarization.fill(HIST("V0pyInRest_frame"), LambdaBoostedVec.Py()); + registryLongitudinalPolarization.fill(HIST("V0pzInRest_frame"), LambdaBoostedVec.Pz()); + + double protonCosThetainV0 = ProtonBoostedVec.Pz() / ProtonBoostedVec.P(); + + registryLongitudinalPolarization.fill(HIST("hprotoncosthetainV0"), protonCosThetainV0); + registryLongitudinalPolarization.fill(HIST("hprotoncosSquarethetainV0"), protonCosThetainV0 * protonCosThetainV0); + registryLongitudinalPolarization.fill(HIST("hLambdamassandCosthetaInV0"), v0.mLambda(), protonCosThetainV0); + + registryLongitudinalPolarization.fill(HIST("TProfile2DLambdaPtMassCostheta"), v0.mLambda(), v0.pt(), protonCosThetainV0); + registryLongitudinalPolarization.fill(HIST("TProfile2DLambdaPtMassCosSquareTheta"), v0.mLambda(), v0.pt(), protonCosThetainV0 * protonCosThetainV0); + + registryLongitudinalPolarization.fill(HIST("TProfile1DLambdaPtMassCostheta"), v0.mLambda(), protonCosThetainV0); + } + if (passedAntiLambdaSelection(v0, pos, neg) && ctauAntiLambda < CtauLambda && ifpasslambda) { + registryLongitudinalPolarization.fill(HIST("hMassVsPtAntiLambda"), v0.pt(), v0.mAntiLambda()); + + ProtonVec = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPr); + PionVec = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPi); + LambdaVec = ProtonVec + PionVec; + LambdaVec.SetM(massLambda); + ROOT::Math::Boost boost{LambdaVec.BoostToCM()}; + ProtonBoostedVec = boost(ProtonVec); + LambdaBoostedVec = boost(LambdaVec); + + double protonCosThetainV0 = ProtonBoostedVec.Pz() / ProtonBoostedVec.P(); + + registryLongitudinalPolarization.fill(HIST("hantiprotoncosthetainV0"), protonCosThetainV0); + registryLongitudinalPolarization.fill(HIST("hantiprotoncosSquarethetainV0"), protonCosThetainV0 * protonCosThetainV0); + registryLongitudinalPolarization.fill(HIST("hAntiLambdamassandCosthetaInV0"), v0.mAntiLambda(), protonCosThetainV0); + + registryLongitudinalPolarization.fill(HIST("TProfile2DAntiLambdaPtMassCostheta"), v0.mAntiLambda(), v0.pt(), protonCosThetainV0); + registryLongitudinalPolarization.fill(HIST("TProfile2DAntiLambdaPtMassCosSquareTheta"), v0.mAntiLambda(), v0.pt(), protonCosThetainV0 * protonCosThetainV0); + registryLongitudinalPolarization.fill(HIST("TProfile1DAntiLambdaPtMassCostheta"), v0.mAntiLambda(), protonCosThetainV0); + } + } + registryLongitudinalPolarization.fill(HIST("nV0sPerEvent"), V0NumbersPerEvent); + registryLongitudinalPolarization.fill(HIST("nV0sPerEventsel"), V0NumbersPerEventsel); + } + PROCESS_SWITCH(LfMyV0s, processLongitudinalPolarization, "processLongitudinalPolarization", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"lf-my-v0s"}), + }; +} diff --git a/PWGLF/Tasks/Strangeness/lambdaTwoPartPolarization.cxx b/PWGLF/Tasks/Strangeness/lambdaTwoPartPolarization.cxx new file mode 100644 index 00000000000..43e10b719b8 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/lambdaTwoPartPolarization.cxx @@ -0,0 +1,412 @@ +// 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 Junlee Kim (jikim1290@gmail.com) + +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/StaticFor.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TLorentzVector.h" +#include "TRandom3.h" +#include "TVector3.h" +#include + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::constants::physics; + +struct lambdaTwoPartPolarization { + using EventCandidates = soa::Join; + using TrackCandidates = soa::Join; + using V0TrackCandidate = aod::V0Datas; + + HistogramRegistry histos{ + "histos", + {}, + OutputObjHandlingPolicy::AnalysisObject}; + + struct : ConfigurableGroup { + Configurable cfgURL{"cfgURL", + "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + Configurable nolaterthan{"ccdb-no-later-than", + std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), + "Latest acceptable timestamp of creation for the object"}; + } cfgCcdbParam; + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + + Configurable cfgCentSel{"cfgCentSel", 100., "Centrality selection"}; + Configurable cfgCentEst{"cfgCentEst", 2, "Centrality estimator, 1: FT0C, 2: FT0M"}; + + Configurable cfgEvtSel{"cfgEvtSel", true, "event selection flag"}; + Configurable cfgPVSel{"cfgPVSel", true, "Additional PV selection flag for syst"}; + Configurable cfgPV{"cfgPV", 10.0, "Additional PV selection range for syst"}; + Configurable cfgAddEvtSelPileup{"cfgAddEvtSelPileup", true, "flag for additional pileup selection"}; + Configurable cfgMaxOccupancy{"cfgMaxOccupancy", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; + Configurable cfgMinOccupancy{"cfgMinOccupancy", 0, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; + + Configurable cfgv0radiusMin{"cfgv0radiusMin", 1.2, "minimum decay radius"}; + Configurable cfgDCAPrToPVMin{"cfgDCAPrToPVMin", 0.05, "minimum DCA to PV for proton track"}; + Configurable cfgDCAPiToPVMin{"cfgDCAPiToPVMin", 0.1, "minimum DCA to PV for pion track"}; + Configurable cfgv0CosPA{"cfgv0CosPA", 0.99, "minimum v0 cosine"}; + Configurable cfgDCAV0Dau{"cfgDCAV0Dau", 1.0, "maximum DCA between daughters"}; + + Configurable cfgV0PtMin{"cfgV0PtMin", 0, "minimum pT for lambda"}; + Configurable cfgV0EtaMin{"cfgV0EtaMin", -0.5, "maximum rapidity"}; + Configurable cfgV0EtaMax{"cfgV0EtaMax", 0.5, "maximum rapidity"}; + Configurable cfgV0LifeTime{"cfgV0LifeTime", 30., "maximum lambda lifetime"}; + + Configurable cfgQAv0{"cfgQAv0", false, "QA plot"}; + + Configurable cfgDaughTPCnclsMin{"cfgDaughTPCnclsMin", 50, "minimum fired crossed rows"}; + Configurable cfgDaughPIDCutsTPCPr{"cfgDaughPIDCutsTPCPr", 5, "proton nsigma for TPC"}; + Configurable cfgDaughPIDCutsTPCPi{"cfgDaughPIDCutsTPCPi", 5, "pion nsigma for TPC"}; + Configurable cfgDaughEtaMin{"cfgDaughEtaMin", -0.8, "minimum daughter eta"}; + Configurable cfgDaughEtaMax{"cfgDaughEtaMax", 0.8, "maximum daughter eta"}; + Configurable cfgDaughPrPt{"cfgDaughPrPt", 0.5, "minimum daughter proton pt"}; + Configurable cfgDaughPiPt{"cfgDaughPiPt", 0.2, "minimum daughter pion pt"}; + + Configurable cfgHypMassWindow{"cfgHypMassWindow", 0.005, "single lambda mass selection"}; + + Configurable cfgEffCor{"cfgEffCor", false, "flag to apply efficiency correction"}; + Configurable cfgEffCorPath{"cfgEffCorPath", "", "path for pseudo efficiency correction"}; + + Configurable cfgAccCor{"cfgAccCor", false, "flag to apply acceptance correction"}; + Configurable cfgAccCorPath{"cfgAccCorPath", "", "path for pseudo acceptance correction"}; + + Configurable cfgRotBkg{"cfgRotBkg", true, "flag to construct rotational backgrounds"}; + Configurable cfgNRotBkg{"cfgNRotBkg", 10, "the number of rotational backgrounds"}; + Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 10, "Number of mixed events per event"}; + + ConfigurableAxis ptAxis{"ptAxis", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "Transverse momentum bins"}; + ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0, 10, 20, 30, 40, 50, 60, 70, 100}, "Centrality interval"}; + ConfigurableAxis RapAxis{"RapAxis", {10, -0.5, 0.5}, "Rapidity axis"}; + ConfigurableAxis detaAxis{"dyAxis", {20, -1, 1}, "relative rapidity axis"}; + ConfigurableAxis dphiAxis{"dphiAxis", {20, -constants::math::PI * 0.5, constants::math::PI * 1.5}, "relative azimuth axis"}; + + ConfigurableAxis cosSigAxis{"cosSigAxis", {110, -1.05, 1.05}, "Signal cosine axis"}; + ConfigurableAxis cosAccAxis{"cosAccAxis", {110, -7.05, 7.05}, "Accepatance cosine axis"}; + + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + + float centrality; + float dphi; + float weight; + + TProfile2D* EffMap = nullptr; + TProfile2D* AccMap = nullptr; + + void init(o2::framework::InitContext&) + { + AxisSpec centQaAxis = {100, 0.0, 100.0}; + AxisSpec PVzQaAxis = {300, -15.0, 15.0}; + AxisSpec epAxis = {6, 0.0, 2.0 * constants::math::PI}; + + AxisSpec pidAxis = {100, -10, 10}; + + AxisSpec shiftAxis = {10, 0, 10, "shift"}; + AxisSpec basisAxis = {20, 0, 20, "basis"}; + + if (cfgQAv0) { + histos.add("QA/CentDist", "", {HistType::kTH1F, {centQaAxis}}); + histos.add("QA/PVzDist", "", {HistType::kTH1F, {PVzQaAxis}}); + + histos.add("QA/nsigma_tpc_pt_ppr", "", {HistType::kTH2F, {ptAxis, pidAxis}}); + histos.add("QA/nsigma_tpc_pt_ppi", "", {HistType::kTH2F, {ptAxis, pidAxis}}); + histos.add("QA/nsigma_tpc_pt_mpr", "", {HistType::kTH2F, {ptAxis, pidAxis}}); + histos.add("QA/nsigma_tpc_pt_mpi", "", {HistType::kTH2F, {ptAxis, pidAxis}}); + } + + histos.add("Ana/Signal", "", {HistType::kTHnSparseF, {ptAxis, ptAxis, detaAxis, dphiAxis, centAxis, cosSigAxis}}); + histos.add("Ana/Acceptance", "", {HistType::kTHnSparseF, {ptAxis, centAxis, RapAxis, cosAccAxis}}); + + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 2.5*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(2834.66, -87.0127, 0.915126, -0.00330136, 332.513, -12.3476, 0.251663, -0.00272819, 1.12242e-05); + + ccdb->setURL(cfgCcdbParam.cfgURL); + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + } + + double massLambda = o2::constants::physics::MassLambda; + double massPr = o2::constants::physics::MassProton; + double massPi = o2::constants::physics::MassPionCharged; + + ROOT::Math::PxPyPzMVector ProtonVec1, PionVec1, LambdaVec1, ProtonBoostedVec1, PionBoostedVec1; + ROOT::Math::PxPyPzMVector ProtonVec2, PionVec2, LambdaVec2, ProtonBoostedVec2, PionBoostedVec2; + int V01Tag; + int V02Tag; + double costhetastar1; + double costhetastar2; + + template + bool eventSelected(TCollision collision) + { + if (!collision.sel8()) { + return 0; + } + if (cfgCentSel < centrality) { + return 0; + } + if (!collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return 0; + } + if (!collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return 0; + } + if (cfgPVSel && std::abs(collision.posZ()) > cfgPV) { + return 0; + } + if (cfgAddEvtSelPileup && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return 0; + } + if (collision.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision.trackOccupancyInTimeRange() < cfgMinOccupancy) { + return 0; + } + + return 1; + } // event selection + + template + bool SelectionV0(TCollision const& collision, V0 const& candidate, int LambdaTag) + { + if (candidate.v0radius() < cfgv0radiusMin) + return false; + if (LambdaTag) { + if (std::abs(candidate.dcapostopv()) < cfgDCAPrToPVMin) + return false; + if (std::abs(candidate.dcanegtopv()) < cfgDCAPiToPVMin) + return false; + } else if (!LambdaTag) { + if (std::abs(candidate.dcapostopv()) < cfgDCAPiToPVMin) + return false; + if (std::abs(candidate.dcanegtopv()) < cfgDCAPrToPVMin) + return false; + } + if (candidate.v0cosPA() < cfgv0CosPA) + return false; + if (std::abs(candidate.dcaV0daughters()) > cfgDCAV0Dau) + return false; + if (candidate.pt() < cfgV0PtMin) + return false; + if (candidate.yLambda() < cfgV0EtaMin) + return false; + if (candidate.yLambda() > cfgV0EtaMax) + return false; + if (candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massLambda > cfgV0LifeTime) + return false; + + return true; + } + + template + bool isSelectedV0Daughter(T const& track, int pid) // pid 0: proton, pid 1: pion + { + if (track.tpcNClsFound() < cfgDaughTPCnclsMin) + return false; + if (pid == 0 && std::abs(track.tpcNSigmaPr()) > cfgDaughPIDCutsTPCPr) + return false; + if (pid == 1 && std::abs(track.tpcNSigmaPi()) > cfgDaughPIDCutsTPCPi) + return false; + if (track.eta() > cfgDaughEtaMax) + return false; + if (track.eta() < cfgDaughEtaMin) + return false; + if (pid == 0 && track.pt() < cfgDaughPrPt) + return false; + if (pid == 1 && track.pt() < cfgDaughPiPt) + return false; + + return true; + } + + template + void FillHistograms(C1 const& c1, C2 const& c2, V01 const& V01s, V02 const& V02s) + { + for (auto& v01 : V01s) { + auto postrack_v01 = v01.template posTrack_as(); + auto negtrack_v01 = v01.template negTrack_as(); + + int LambdaTag = 0; + int aLambdaTag = 0; + + if (isSelectedV0Daughter(postrack_v01, 0) && isSelectedV0Daughter(negtrack_v01, 1)) { + LambdaTag = 1; + } + if (isSelectedV0Daughter(negtrack_v01, 0) && isSelectedV0Daughter(postrack_v01, 1)) { + aLambdaTag = 1; + } + + if (LambdaTag == aLambdaTag) + continue; + + if (!SelectionV0(c1, v01, LambdaTag)) + continue; + + if (LambdaTag) { + ProtonVec1 = ROOT::Math::PxPyPzMVector(v01.pxpos(), v01.pypos(), v01.pzpos(), massPr); + PionVec1 = ROOT::Math::PxPyPzMVector(v01.pxneg(), v01.pyneg(), v01.pzneg(), massPi); + V01Tag = 0; + } + if (aLambdaTag) { + ProtonVec1 = ROOT::Math::PxPyPzMVector(v01.pxneg(), v01.pyneg(), v01.pzneg(), massPr); + PionVec1 = ROOT::Math::PxPyPzMVector(v01.pxpos(), v01.pypos(), v01.pzpos(), massPi); + V01Tag = 1; + } + LambdaVec1 = ProtonVec1 + PionVec1; + LambdaVec1.SetM(massLambda); + + ROOT::Math::Boost boost1{LambdaVec1.BoostToCM()}; + ProtonBoostedVec1 = boost1(ProtonVec1); + + costhetastar1 = ProtonBoostedVec1.Pz() / ProtonBoostedVec1.P(); + + histos.fill(HIST("Ana/Acceptance"), v01.pt(), centrality, v01.yLambda(), costhetastar1 * costhetastar1); + + for (auto& v02 : V02s) { + if (v01.v0Id() <= v02.v0Id() && doprocessDataSame) + continue; + auto postrack_v02 = v02.template posTrack_as(); + auto negtrack_v02 = v02.template negTrack_as(); + + LambdaTag = 0; + aLambdaTag = 0; + + if (isSelectedV0Daughter(postrack_v02, 0) && isSelectedV0Daughter(negtrack_v02, 1)) { + LambdaTag = 1; + } + if (isSelectedV0Daughter(negtrack_v02, 0) && isSelectedV0Daughter(postrack_v02, 1)) { + aLambdaTag = 1; + } + + if (LambdaTag == aLambdaTag) + continue; + + if (!SelectionV0(c2, v02, LambdaTag)) + continue; + + if (doprocessDataSame) { + if (postrack_v01.globalIndex() == postrack_v02.globalIndex() || postrack_v01.globalIndex() == negtrack_v02.globalIndex() || negtrack_v01.globalIndex() == postrack_v02.globalIndex() || negtrack_v01.globalIndex() == negtrack_v02.globalIndex()) + continue; // no shared decay products + } + + if (LambdaTag) { + ProtonVec2 = ROOT::Math::PxPyPzMVector(v02.pxpos(), v02.pypos(), v02.pzpos(), massPr); + PionVec2 = ROOT::Math::PxPyPzMVector(v02.pxneg(), v02.pyneg(), v02.pzneg(), massPi); + V02Tag = 0; + } + if (aLambdaTag) { + ProtonVec2 = ROOT::Math::PxPyPzMVector(v02.pxneg(), v02.pyneg(), v02.pzneg(), massPr); + PionVec2 = ROOT::Math::PxPyPzMVector(v02.pxpos(), v02.pypos(), v02.pzpos(), massPi); + V02Tag = 1; + } + LambdaVec2 = ProtonVec2 + PionVec2; + LambdaVec2.SetM(massLambda); + + ROOT::Math::Boost boost2{LambdaVec2.BoostToCM()}; + ProtonBoostedVec2 = boost2(ProtonVec2); + + costhetastar2 = ProtonBoostedVec2.Pz() / ProtonBoostedVec2.P(); + + weight = 1.0; + weight *= cfgEffCor ? 1.0 / EffMap->GetBinContent(EffMap->GetXaxis()->FindBin(v01.pt()), EffMap->GetYaxis()->FindBin(centrality)) : 1.; + weight *= cfgAccCor ? 1.0 / AccMap->GetBinContent(AccMap->GetXaxis()->FindBin(v01.pt()), AccMap->GetYaxis()->FindBin(v01.yLambda())) : 1.; + weight *= cfgEffCor ? 1.0 / EffMap->GetBinContent(EffMap->GetXaxis()->FindBin(v02.pt()), EffMap->GetYaxis()->FindBin(centrality)) : 1.; + weight *= cfgAccCor ? 1.0 / AccMap->GetBinContent(AccMap->GetXaxis()->FindBin(v02.pt()), AccMap->GetYaxis()->FindBin(v02.yLambda())) : 1.; + + if (V01Tag != V02Tag) { + weight *= -1.0; + } + + dphi = TVector2::Phi_0_2pi(v01.phi() - v02.phi()); + if (dphi > constants::math::PI * 1.5) { + dphi -= constants::math::PI * 2.0; + } + + histos.fill(HIST("Ana/Signal"), v01.pt(), v02.pt(), v01.yLambda() - v02.yLambda(), dphi, centrality, costhetastar1 * costhetastar2 * weight); + } + } + } + + void processDataSame(EventCandidates::iterator const& collision, + TrackCandidates const& /*tracks*/, aod::V0Datas const& V0s, + aod::BCsWithTimestamps const&) + { + if (cfgCentEst == 1) { + centrality = collision.centFT0C(); + } else if (cfgCentEst == 2) { + centrality = collision.centFT0M(); + } + if (!eventSelected(collision) && cfgEvtSel) { + return; + } + + histos.fill(HIST("QA/CentDist"), centrality, 1.0); + histos.fill(HIST("QA/PVzDist"), collision.posZ(), 1.0); + + auto bc = collision.bc_as(); + if (cfgEffCor) { + EffMap = ccdb->getForTimeStamp(cfgEffCorPath.value, bc.timestamp()); + } + if (cfgAccCor) { + AccMap = ccdb->getForTimeStamp(cfgAccCorPath.value, bc.timestamp()); + } + + FillHistograms(collision, collision, V0s, V0s); + } + PROCESS_SWITCH(lambdaTwoPartPolarization, processDataSame, "Process Event for same data", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"lf-lambdaTwoPartPolarization"})}; +} diff --git a/PWGLF/Tasks/Strangeness/lambdak0sflattenicity.cxx b/PWGLF/Tasks/Strangeness/lambdak0sflattenicity.cxx index 0b1d48aad85..4114d614b90 100755 --- a/PWGLF/Tasks/Strangeness/lambdak0sflattenicity.cxx +++ b/PWGLF/Tasks/Strangeness/lambdak0sflattenicity.cxx @@ -13,31 +13,28 @@ /// The code is still in development mode /// Flattenicity part of the code is adopted from /// https://github.com/AliceO2Group/O2Physics/blob/master/PWGMM/Mult/Tasks/flatenicityFV0.cxx -/// For any suggestions, commets or questions, Please write to Suraj Prasad -/// (Suraj.Prasad@cern.ch) +/// \file lambdak0sflattenicity.cxx +/// \brief V0 task for production of strange hadrons as a function of flattenicity +/// \author Suraj Prasad (suraj.prasad@cern.ch) +#include +#include #include -// #include #include +#include +#include -// #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -// #include "Framework/StaticFor.h" #include "Framework/runDataProcessing.h" +#include "Framework/O2DatabasePDGPlugin.h" -// #include "Common/Core/TrackSelection.h" -// #include "Common/Core/TrackSelectionDefaults.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/TrackSelectionTables.h" -// #include "ReconstructionDataFormats/Track.h" -#include "Framework/O2DatabasePDGPlugin.h" - -#include - #include "Common/DataModel/PIDResponse.h" + #include "PWGLF/DataModel/LFStrangenessTables.h" #include "PWGLF/Utils/inelGt.h" @@ -45,7 +42,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -struct lambdak0sflattenicity { +struct Lambdak0sflattenicity { // Histograms are defined with HistogramRegistry Service pdg; HistogramRegistry rEventSelection{"eventSelection", @@ -71,6 +68,18 @@ struct lambdak0sflattenicity { OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rXi{ + "Xi", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + HistogramRegistry rCommonHist{ + "commonhists", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; HistogramRegistry rFlattenicity{ "flattenicity", {}, @@ -78,13 +87,13 @@ struct lambdak0sflattenicity { true, true}; - static constexpr std::string_view nhEst[8] = { + static constexpr std::string_view kHEst[8] = { "eGlobaltrack", "eFV0", "e1flatencityFV0", "eFT0", "e1flatencityFT0", "eFV0FT0C", "e1flatencityFV0FT0C", "ePtTrig"}; - static constexpr std::string_view tEst[8] = { + static constexpr std::string_view kTEst[8] = { "GlobalTrk", "FV0", "1-flatencity_FV0", "FT0", "1-flatencityFT0", "FV0_FT0C", "1-flatencity_FV0_FT0C", "PtTrig"}; - static constexpr std::string_view nhPtEst[8] = { + static constexpr std::string_view kHPtEst[8] = { "ptVsGlobaltrack", "ptVsFV0", "ptVs1flatencityFV0", "ptVsFT0", "ptVs1flatencityFT0", "ptVsFV0FT0C", @@ -92,9 +101,15 @@ struct lambdak0sflattenicity { // Configurable for histograms Configurable nBinsVz{"nBinsVz", 100, "N bins in Vz"}; - Configurable nBinsK0sMass{"nBinsK0sMass", 200, "N bins in K0sMass"}; - Configurable nBinsLambdaMass{"nBinsLambdaMass", 200, + Configurable nBinsK0sMass{"nBinsK0sMass", 400, "N bins in K0sMass"}; + Configurable nBinsLambdaMass{"nBinsLambdaMass", 400, "N bins in LambdaMass"}; + Configurable nBinsXiMass{"nBinsXiMass", 400, "N bins in XiMass"}; + + Configurable kK0sEPshiftfromMass{"kK0sEPshiftfromMass", 0.1, "distance of K0s Inv mass histogram start and end points from PDG mass"}; + Configurable kLambdaEPshiftfromMass{"kLambdaEPshiftfromMass", 0.05, "distance of Lambda Inv mass histogram start and end points from PDG mass"}; + Configurable kXiEPshiftfromMass{"kXiEPshiftfromMass", 0.05, "distance of Xi Inv mass histogram start and end points from PDG mass"}; + Configurable nBinspT{"nBinspT", 250, "N bins in pT"}; Configurable nBinsFlattenicity{"nBinsFlattenicity", 100, "N bins in Flattenicity"}; @@ -102,24 +117,22 @@ struct lambdak0sflattenicity { Configurable applyEvSel{"applyEvSel", true, "Apply event selection to Data and MCRec"}; - Configurable Issel8{"Issel8", true, + Configurable issel8{"issel8", true, "Accept events that pass sel8 selection"}; Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; - Configurable IsINELgt0{"isINELgt0", true, "is INEL gt 0"}; - Configurable IsNoTimeFrameBorder{ - "IsNoTimeFrameBorder", true, - "cut branch crossing at the beginning/end of TF"}; - Configurable IsNoITSROFrameBorder{ - "IsNoITSROFrameBorder", true, - "cut branch crossing at the beginning/end of ITS ROF"}; - Configurable IsVertexITSTPC{"IsVertexITSTPC", false, + Configurable isINELgt0{"isINELgt0", true, "is INEL gt 0"}; + Configurable isNoTimeFrameBorder{"isNoTimeFrameBorder", true, + "cut branch crossing at the beginning/end of TF"}; + Configurable isNoITSROFrameBorder{"isNoITSROFrameBorder", true, + "cut branch crossing at the beginning/end of ITS ROF"}; + Configurable isVertexITSTPC{"isVertexITSTPC", false, "Is Vertex ITSTPC"}; - Configurable IsNoSameBunchPileup{"IsNoSameBunchPileup", false, + Configurable isNoSameBunchPileup{"isNoSameBunchPileup", false, "Is No Same Bunch Pileup"}; - Configurable IsGoodZvtxFT0vsPV{"IsGoodZvtxFT0vsPV", false, + Configurable isGoodZvtxFT0vsPV{"isGoodZvtxFT0vsPV", false, "Is Good Zvtx FT0 vs PV"}; - Configurable IsTriggerTVX{"IsTriggerTVX", true, + Configurable isTriggerTVX{"isTriggerTVX", true, "coincidence of a signal in FT0A and FT0C"}; // Configurables for Flattenicity @@ -132,68 +145,88 @@ struct lambdak0sflattenicity { "Calculate Flattenicity with FV0"}; Configurable isflattenicitywithFT0{"isflattenicitywithFT0", true, "Calculate Flattenicity with FT0"}; - Configurable isflattenicitywithFV0FT0C{ - "isflattenicitywithFV0FT0C", true, - "Calculate Flattenicity with FV0+FT0C"}; - - Configurable flattenicityforanalysis{ - "flattenicityforanalysis", 0, - "Which Flattenicity to be used for analysis, 0 for FV0, 1 for FT0, 2 for FV0+FT0C"}; + Configurable isflattenicitywithFV0FT0C{"isflattenicitywithFV0FT0C", true, + "Calculate Flattenicity with FV0+FT0C"}; + Configurable flattenicityforanalysis{"flattenicityforanalysis", 0, + "Which Flattenicity to be used for analysis, 0 for FV0, 1 for FT0, 2 for FV0+FT0C"}; + Configurable flattenicityforLossCorrRec{"flattenicityforLossCorrRec", true, + "Flattenicity from Rec Tracks are used for Signal and Event loss calculations"}; // Common Configurable parameters for V0 selection - Configurable v0setting_dcav0dau{"v0setting_dcav0dau", 1, - "DCA V0 Daughters"}; - Configurable v0setting_dcapostopv{"v0setting_dcapostopv", 0.06, - "DCA Pos To PV"}; - Configurable v0setting_dcanegtopv{"v0setting_dcanegtopv", 0.06, - "DCA Neg To PV"}; - Configurable v0setting_rapidity{"v0setting_rapidity", 0.5, - "V0 rapidity cut"}; + Configurable v0settingDCAv0dau{"v0settingDCAv0dau", 1, + "DCA V0 Daughters"}; + Configurable v0settingDCApostopv{"v0settingDCApostopv", 0.06, + "DCA Pos To PV"}; + Configurable v0settingDCAnegtopv{"v0settingDCAnegtopv", 0.06, + "DCA Neg To PV"}; + Configurable v0settingDCAbactopv{"v0settingDCAbactopv", 0.06, + "DCA Bchelor To PV"}; + Configurable v0settingRapidity{"v0settingRapidity", 0.5, + "V0 rapidity cut"}; // Configurable parameters for V0 selection for KOs - Configurable v0setting_cospaK0s{"v0setting_cospa_K0s", 0.97, - "V0 CosPA for K0s"}; - Configurable v0setting_radiusK0s{"v0setting_radius_K0s", 0.5, - "v0radius for K0s"}; - Configurable v0setting_ctauK0s{"v0setting_ctau_K0s", 20, - "v0ctau for K0s"}; - Configurable v0setting_massrejectionK0s{ - "v0setting_massrejection_K0s", 0.005, - "Competing Mass Rejection cut for K0s"}; + Configurable v0settingCosPAK0s{"v0settingCosPAK0s", 0.97, + "V0 CosPA for K0s"}; + Configurable v0settingRadiusK0s{"v0settingRadiusK0s", 0.5, + "v0radius for K0s"}; + Configurable v0settingcTauK0s{"v0settingcTauK0s", 20, + "v0ctau for K0s"}; + Configurable v0settingMassRejectionK0s{"v0settingMassRejectionK0s", 0.005, + "Competing Mass Rejection cut for K0s"}; + Configurable v0settingArmePodoK0s{"v0settingArmePodoK0s", 0.2, + "Armenteros-Podolanski cut for K0s"}; // Configurable parameters for V0 selection for Lambda - Configurable v0setting_cospaLambda{"v0setting_cospa_Lambda", 0.995, - "V0 CosPA for Lambda"}; - Configurable v0setting_radiusLambda{"v0setting_radius_Lambda", 0.5, - "v0radius for Lambda"}; - Configurable v0setting_ctauLambda{"v0setting_ctau_Lambda", 30, - "v0ctau for Lambda"}; - Configurable v0setting_massrejectionLambda{ - "v0setting_massrejection_Lambda", 0.01, - "Competing Mass Rejection cut for Lambda"}; + Configurable v0settingCosPALambda{"v0settingCosPALambda", 0.995, + "V0 CosPA for Lambda"}; + Configurable v0settingRadiusLambda{"v0settingRadiusLambda", 0.5, + "v0radius for Lambda"}; + Configurable v0settingcTauLambda{"v0settingcTauLambda", 30, + "v0ctau for Lambda"}; + Configurable v0settingMassRejectionLambda{"v0settingMassRejectionLambda", 0.01, + "Competing Mass Rejection cut for Lambda"}; // Configurable parameters for PID selection - Configurable NSigmaTPCPion{"NSigmaTPCPion", 5, "NSigmaTPCPion"}; - Configurable NSigmaTPCProton{"NSigmaTPCProton", 5, "NSigmaTPCProton"}; + Configurable nSigmaTPCPion{"nSigmaTPCPion", 5, "nSigmaTPCPion"}; + Configurable nSigmaTPCProton{"nSigmaTPCProton", 5, "nSigmaTPCProton"}; + Configurable nSigmaTPCKaon{"nSigmaTPCKaon", 5, "nSigmaTPCKaon"}; // Configurable v0daughter_etacut{"V0DaughterEtaCut", 0.8, // "V0DaughterEtaCut"}; - Configurable v0_etacut{"v0EtaCut", 0.8, "v0EtaCut"}; + // Configurable v0etacut{"v0etacut", 0.8, "v0etacut"}; // acceptance cuts for Flattenicity correlation Configurable cfgTrkEtaCut{"cfgTrkEtaCut", 0.8f, "Eta range for tracks"}; Configurable cfgTrkLowPtCut{"cfgTrkLowPtCut", 0.0f, "Minimum pT"}; + // Additional Cut configurables for Cascades + Configurable nTPCcrossedRows{"nTPCcrossedRows", 52, "Number of TPC crossed pad raws"}; + Configurable cascsettingDCAv0toPV{"cascsettingDCAv0toPV", 0.03, "DCA V0 To PV"}; + Configurable cascsettingDCAv0bach{"cascsettingDCAv0bach", 0.25, "DCA V0 To bachelor"}; + Configurable cascsettingDCAxybaryonbach{"cascsettingDCAxybaryonbach", 0.02, "DCA Baryon To bachelor"}; + Configurable cascsettingCosPAcascPV{"cascsettingCosPAcascPV", 0.9947, "CosThetap for Cascade to PV"}; + Configurable cascsettingCosPAv0PV{"cascsettingCosPAv0PV", 0.9876, "CosThetap for V0 to PV"}; + Configurable cascsettingv0radius{"cascsettingv0radius", 0.55, "V0 decay radius for cadcades in cm"}; + Configurable cascsettingcascradius{"cascsettingcascradius", 1.01, "Cascade decay radius for cadcades in cm"}; + Configurable cascsettingRapidity{"cascsettingRapidity", 0.5, "Cascade rapidity cut"}; + Configurable cascsettingMassRejectionLambdaXi{"cascsettingMassRejectionLambdaXi", 0.0116, "Casc Mass Rejection cut of Lambda for Xi"}; + Configurable cascsettingMassRejectioOmegaXi{"cascsettingMassRejectioOmegaXi", -1, "Casc Mass Rejection cut of Omega for Xi"}; + Configurable cascsettingproplifetime{"cascsettingproplifetime", 4.6, "Scale for lifetime cut on ctau Xi"}; + + int nbin = 1; + void init(InitContext const&) { // Axes - AxisSpec K0sMassAxis = {nBinsK0sMass, 0.45f, 0.55f, + AxisSpec k0sMassAxis = {nBinsK0sMass, 0.49f - kK0sEPshiftfromMass, 0.49f + kK0sEPshiftfromMass, "#it{M}_{#pi^{+}#pi^{-}} [GeV/#it{c}^{2}]"}; - AxisSpec LambdaMassAxis = {nBinsLambdaMass, 1.015f, 1.215f, + AxisSpec lambdaMassAxis = {nBinsLambdaMass, 1.115f - kLambdaEPshiftfromMass, 1.115f + kLambdaEPshiftfromMass, "#it{M}_{p#pi^{-}} [GeV/#it{c}^{2}]"}; - AxisSpec AntiLambdaMassAxis = {nBinsLambdaMass, 1.015f, 1.215f, + AxisSpec antilambdaMassAxis = {nBinsLambdaMass, 1.115f - kLambdaEPshiftfromMass, 1.115f + kLambdaEPshiftfromMass, "#it{M}_{#pi^{+}#bar{p}} [GeV/#it{c}^{2}]"}; + AxisSpec xiMassAxis = {nBinsXiMass, 1.32f - kXiEPshiftfromMass, 1.32f + kXiEPshiftfromMass, + "#it{M}_{#Lambda#pi} [GeV/#it{c}^{2}]"}; AxisSpec vertexZAxis = {nBinsVz, -15., 15., "vrtx_{Z} [cm]"}; AxisSpec ptAxis = {nBinspT, 0.0f, 25.0f, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec flatAxis = {nBinsFlattenicity, 0.0f, 1.0f, "1-#rho_{ch}"}; @@ -209,33 +242,189 @@ struct lambdak0sflattenicity { rEventSelection.add("hEventsSelected", "hEventsSelected", {HistType::kTH1D, {{12, 0, 12}}}); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(1, "all"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(2, "sel8"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(3, "zvertex"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(4, "TFBorder"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(5, "ITSROFBorder"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(6, "VertexITSTPC"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(7, "SameBunchPileup"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(8, "isGoodZvtxFT0vsPV"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(9, "TVX"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(10, "INEL>0"); - rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(11, "Applied selection"); + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "all"); + if (issel8) { + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "sel8"); + } + + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "zvertex"); + + if (isNoTimeFrameBorder) { + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "TFBorder"); + } + if (isNoITSROFrameBorder) { + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "ITSROFBorder"); + } + if (isVertexITSTPC) { + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "VertexITSTPC"); + } + if (isNoSameBunchPileup) { + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "SameBunchPileup"); + } + if (isGoodZvtxFT0vsPV) { + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "isGoodZvtxFT0vsPV"); + } + if (isTriggerTVX) { + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "TVX"); + } + if (isINELgt0) { + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin++, "INEL>0"); + } rEventSelection.add("hFlattenicityDistribution", "hFlattenicityDistribution", {HistType::kTH1D, {flatAxis}}); - if (doprocessRecMC) { + if (doprocessRecMCLambdaK0s || doprocessRecMCRun3Cascade) { rEventSelection.add("hFlattenicityDistributionMCGen_Rec", "hFlattenicityDistributionMCGen_Rec", {HistType::kTH1D, {flatAxis}}); rEventSelection.add("hFlattenicity_Corr_Gen_vs_Rec", "hFlattenicity_Corr_Gen_vs_Rec", {HistType::kTH2D, {flatAxis, flatAxis}}); } + + if (doprocessDataRun3LambdaK0s || doprocessRecMCLambdaK0s) { + // K0s reconstruction + // Mass + rKzeroShort.add("hMassK0s", "hMassK0s", {HistType::kTH1D, {k0sMassAxis}}); + rKzeroShort.add("hMassK0sSelected", "hMassK0sSelected", + {HistType::kTH1D, {k0sMassAxis}}); + + // K0s topological/PID cuts + rKzeroShort.add("hrapidityK0s", "hrapidityK0s", + {HistType::kTH1D, {{40, -2.0f, 2.0f, "y"}}}); + rKzeroShort.add("hctauK0s", "hctauK0s", + {HistType::kTH1D, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); + rKzeroShort.add( + "h2DdecayRadiusK0s", "h2DdecayRadiusK0s", + {HistType::kTH1D, {{100, 0.0f, 1.0f, "Decay Radius (cm)"}}}); + rKzeroShort.add("hDCAV0DaughtersK0s", "hDCAV0DaughtersK0s", + {HistType::kTH1D, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); + rKzeroShort.add("hV0CosPAK0s", "hV0CosPAK0s", + {HistType::kTH1D, {{100, 0.95f, 1.f, "CosPA"}}}); + rKzeroShort.add("hNSigmaPosPionFromK0s", "hNSigmaPosPionFromK0s", + {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); + rKzeroShort.add("hNSigmaNegPionFromK0s", "hNSigmaNegPionFromK0s", + {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); + rKzeroShort.add("hMassK0spT", "hMassK0spT", + {HistType::kTH2D, {{k0sMassAxis}, {ptAxis}}}); + rKzeroShort.add("hMassK0spTFlat", "hMassK0spTFlat", + {HistType::kTH3D, {{k0sMassAxis}, {ptAxis}, {flatAxis}}}); + rKzeroShort.add("hArmPodoAlphavsQTK0sAfterCut", "hArmPodoAlphavsQTK0sAfterCut", + {HistType::kTH2D, {{200, -1, 1, "#alpha"}, {70, 0, 0.35, "Q_{T}"}}}); + + if (doprocessRecMCLambdaK0s) { + rKzeroShort.add("Generated_MCRecoCollCheck_INEL_K0Short", "Generated_MCRecoCollCheck_INEL_K0Short", + {HistType::kTH2D, {{ptAxis}, {flatAxis}}}); + } + + // Lambda reconstruction Mass + rLambda.add("hMassLambda", "hMassLambda", + {HistType::kTH1D, {lambdaMassAxis}}); + rLambda.add("hMassLambdaSelected", "hMassLambdaSelected", + {HistType::kTH1D, {lambdaMassAxis}}); + + // Lambda topological/PID cuts + rLambda.add("hDCAV0DaughtersLambda", "hDCAV0DaughtersLambda", + {HistType::kTH1D, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); + rLambda.add("hV0CosPALambda", "hV0CosPALambda", + {HistType::kTH1D, {{100, 0.95f, 1.f, "CosPA"}}}); + rLambda.add("hNSigmaPosPionFromLambda", "hNSigmaPosPionFromLambda", + {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); + rLambda.add("hNSigmaNegPionFromLambda", "hNSigmaNegPionFromLambda", + {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); + rLambda.add("hrapidityLambda", "hrapidityLambda", + {HistType::kTH1D, {{40, -2.0f, 2.0f, "y"}}}); + rLambda.add("hctauLambda", "hctauLambda", + {HistType::kTH1D, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); + rLambda.add("h2DdecayRadiusLambda", "h2DdecayRadiusLambda", + {HistType::kTH1D, {{100, 0.0f, 1.0f, "c#tau (cm)"}}}); + rLambda.add("hMassLambdapT", "hMassLambdapT", + {HistType::kTH2D, {{lambdaMassAxis}, {ptAxis}}}); + rLambda.add("hMassLambdapTFlat", "hMassLambdapTFlat", + {HistType::kTH3D, {{lambdaMassAxis}, {ptAxis}, {flatAxis}}}); + if (doprocessRecMCLambdaK0s) { + rLambda.add("Generated_MCRecoCollCheck_INEL_Lambda", "Generated_MCRecoCollCheck_INEL_Lambda", + {HistType::kTH2D, {{ptAxis}, {flatAxis}}}); + } + + // AntiLambda reconstruction + // Mass + rAntiLambda.add("hMassAntiLambda", "hMassAntiLambda", + {HistType::kTH1D, {antilambdaMassAxis}}); + rAntiLambda.add("hMassAntiLambdaSelected", "hMassAntiLambdaSelected", + {HistType::kTH1D, {antilambdaMassAxis}}); + + // AntiLambda topological/PID cuts + rAntiLambda.add("hDCAV0DaughtersAntiLambda", "hDCAV0DaughtersAntiLambda", + {HistType::kTH1D, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); + rAntiLambda.add("hV0CosPAAntiLambda", "hV0CosPAAntiLambda", + {HistType::kTH1D, {{100, 0.95f, 1.f, "CosPA"}}}); + rAntiLambda.add("hNSigmaPosPionFromAntiLambda", + "hNSigmaPosPionFromAntiLambda", + {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); + rAntiLambda.add("hNSigmaNegPionFromAntiLambda", + "hNSigmaNegPionFromAntiLambda", + {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); + rAntiLambda.add("hrapidityAntiLambda", "hrapidityAntiLambda", + {HistType::kTH1D, {{40, -2.0f, 2.0f, "y"}}}); + rAntiLambda.add("hctauAntiLambda", "hctauAntiLambda", + {HistType::kTH1D, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); + rAntiLambda.add("h2DdecayRadiusAntiLambda", "h2DdecayRadiusAntiLambda", + {HistType::kTH1D, {{100, 0.0f, 1.0f, "c#tau (cm)"}}}); + rAntiLambda.add("hMassAntiLambdapT", "hMassAntiLambdapT", + {HistType::kTH2D, {{antilambdaMassAxis}, {ptAxis}}}); + rAntiLambda.add("hMassAntiLambdapTFlat", "hMassAntiLambdapTFlat", + {HistType::kTH3D, {{antilambdaMassAxis}, {ptAxis}, {flatAxis}}}); + if (doprocessRecMCLambdaK0s) { + rAntiLambda.add("Generated_MCRecoCollCheck_INEL_AntiLambda", "Generated_MCRecoCollCheck_INEL_AntiLambda", + {HistType::kTH2D, {{ptAxis}, {flatAxis}}}); + } + + rCommonHist.add("hArmPodoAlphavsQT", "hArmPodoAlphavsQT", + {HistType::kTH2D, {{200, -1, 1, "#alpha"}, {70, 0, 0.35, "Q_{T}"}}}); + } + + if (doprocessRecMCRun3Cascade || doprocessDataRun3Cascade) { + rXi.add("hMassXi", "hMassXi", {HistType::kTH1D, {xiMassAxis}}); + rXi.add("hMassXiSelected", "hMassXiSelected", + {HistType::kTH1D, {xiMassAxis}}); + + // Xi topological/PID cuts + rXi.add("hrapidityXi", "hrapidityXi", + {HistType::kTH1D, {{40, -2.0f, 2.0f, "y"}}}); + rXi.add("hctauXi", "hctauXi", + {HistType::kTH1D, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); + rXi.add( + "h2DdecayRadiusXi", "h2DdecayRadiusXi", + {HistType::kTH1D, {{100, 0.0f, 1.0f, "Decay Radius (cm)"}}}); + rXi.add("hDCAV0DaughtersXi", "hDCAV0DaughtersXi", + {HistType::kTH1D, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); + rXi.add("hV0CosPAXi", "hV0CosPAXi", + {HistType::kTH1D, {{100, 0.95f, 1.f, "CosPA"}}}); + rXi.add("hNSigmaPosPionFromXi", "hNSigmaPosPionFromXi", + {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); + rXi.add("hNSigmaNegPionFromXi", "hNSigmaNegPionFromXi", + {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); + rXi.add("hMassXipT", "hMassXipT", + {HistType::kTH2D, {{xiMassAxis}, {ptAxis}}}); + rXi.add("hMassXipTFlat", "hMassXipTFlat", + {HistType::kTH3D, {{xiMassAxis}, {ptAxis}, {flatAxis}}}); + if (doprocessRecMCRun3Cascade) { + rXi.add("Generated_MCRecoCollCheck_INEL_Xi", "Generated_MCRecoCollCheck_INEL_Xi", + {HistType::kTH2D, {{ptAxis}, {flatAxis}}}); + } + } if (doprocessGenMC) { + + rEventSelection.get(HIST("hEventsSelected"))->GetXaxis()->SetBinLabel(nbin, "Applied selection"); + rEventSelection.add("hVertexZGen", "hVertexZGen", {HistType::kTH1D, {vertexZAxis}}); rEventSelection.add("hFlattenicityDistributionMCGen", "hFlattenicityDistributionMCGen", {HistType::kTH1D, {flatAxis}}); + rEventSelection.add("hFlattenicityDistributionRecMCGen", "hFlattenicityDistributionRecMCGen", + {HistType::kTH1D, {flatAxis}}); + rEventSelection.add("hFlat_RecoColl_MC", "hFlat_RecoColl_MC", {HistType::kTH1D, {flatAxis}}); rEventSelection.add("hFlat_RecoColl_MC_INELgt0", "hFlat_RecoColl_MC_INELgt0", {HistType::kTH1D, {flatAxis}}); rEventSelection.add("hFlat_GenRecoColl_MC", "hFlat_GenRecoColl_MC", {HistType::kTH1D, {flatAxis}}); @@ -254,39 +443,9 @@ struct lambdak0sflattenicity { rEventSelection.get(HIST("hNEventsMCReco"))->GetXaxis()->SetBinLabel(2, "pass ev sel"); rEventSelection.get(HIST("hNEventsMCReco"))->GetXaxis()->SetBinLabel(3, "INELgt0"); rEventSelection.get(HIST("hNEventsMCReco"))->GetXaxis()->SetBinLabel(4, "check"); - } - // K0s reconstruction - // Mass - rKzeroShort.add("hMassK0s", "hMassK0s", {HistType::kTH1D, {K0sMassAxis}}); - rKzeroShort.add("hMassK0sSelected", "hMassK0sSelected", - {HistType::kTH1D, {K0sMassAxis}}); - - // K0s topological/PID cuts - rKzeroShort.add("hrapidityK0s", "hrapidityK0s", - {HistType::kTH1D, {{40, -2.0f, 2.0f, "y"}}}); - rKzeroShort.add("hctauK0s", "hctauK0s", - {HistType::kTH1D, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); - rKzeroShort.add( - "h2DdecayRadiusK0s", "h2DdecayRadiusK0s", - {HistType::kTH1D, {{100, 0.0f, 1.0f, "Decay Radius (cm)"}}}); - rKzeroShort.add("hDCAV0DaughtersK0s", "hDCAV0DaughtersK0s", - {HistType::kTH1D, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); - rKzeroShort.add("hV0CosPAK0s", "hV0CosPAK0s", - {HistType::kTH1D, {{100, 0.95f, 1.f, "CosPA"}}}); - rKzeroShort.add("hNSigmaPosPionFromK0s", "hNSigmaPosPionFromK0s", - {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); - rKzeroShort.add("hNSigmaNegPionFromK0s", "hNSigmaNegPionFromK0s", - {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); - rKzeroShort.add("hMassK0spT", "hMassK0spT", - {HistType::kTH2D, {{K0sMassAxis}, {ptAxis}}}); - rKzeroShort.add("hMassK0spTFlat", "hMassK0spTFlat", - {HistType::kTH3D, {{K0sMassAxis}, {ptAxis}, {flatAxis}}}); - if (doprocessRecMC) { - rKzeroShort.add("Generated_MCRecoCollCheck_INEL_K0Short", "Generated_MCRecoCollCheck_INEL_K0Short", - {HistType::kTH2D, {{ptAxis}, {flatAxis}}}); - } + rEventSelection.add("hTrueFV0amplvsFlat", "TrueFV0MvsFlat", HistType::kTH2D, + {{500, -0.5, +499.5, "True Nch in FV0 region"}, flatAxis}); - if (doprocessGenMC) { rKzeroShort.add("pGen_MCGenRecoColl_INEL_K0Short", "pGen_MCGenRecoColl_INEL_K0Short", {HistType::kTH2D, {ptAxis, flatAxis}}); rKzeroShort.add("Generated_MCRecoColl_INEL_K0Short", "Generated_MCRecoColl_INEL_K0Short", @@ -301,38 +460,7 @@ struct lambdak0sflattenicity { {HistType::kTH2D, {ptAxis, flatAxis}}); rKzeroShort.add("pGen_MCGenColl_INELgt0_K0Short", "pGen_MCGenColl_INELgt0_K0Short", {HistType::kTH2D, {ptAxis, flatAxis}}); - } - // Lambda reconstruction Mass - rLambda.add("hMassLambda", "hMassLambda", - {HistType::kTH1D, {LambdaMassAxis}}); - rLambda.add("hMassLambdaSelected", "hMassLambdaSelected", - {HistType::kTH1D, {LambdaMassAxis}}); - - // Lambda topological/PID cuts - rLambda.add("hDCAV0DaughtersLambda", "hDCAV0DaughtersLambda", - {HistType::kTH1D, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); - rLambda.add("hV0CosPALambda", "hV0CosPALambda", - {HistType::kTH1D, {{100, 0.95f, 1.f, "CosPA"}}}); - rLambda.add("hNSigmaPosPionFromLambda", "hNSigmaPosPionFromLambda", - {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); - rLambda.add("hNSigmaNegPionFromLambda", "hNSigmaNegPionFromLambda", - {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); - rLambda.add("hrapidityLambda", "hrapidityLambda", - {HistType::kTH1D, {{40, -2.0f, 2.0f, "y"}}}); - rLambda.add("hctauLambda", "hctauLambda", - {HistType::kTH1D, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); - rLambda.add("h2DdecayRadiusLambda", "h2DdecayRadiusLambda", - {HistType::kTH1D, {{100, 0.0f, 1.0f, "c#tau (cm)"}}}); - rLambda.add("hMassLambdapT", "hMassLambdapT", - {HistType::kTH2D, {{LambdaMassAxis}, {ptAxis}}}); - rLambda.add("hMassLambdapTFlat", "hMassLambdapTFlat", - {HistType::kTH3D, {{LambdaMassAxis}, {ptAxis}, {flatAxis}}}); - if (doprocessRecMC) { - rLambda.add("Generated_MCRecoCollCheck_INEL_Lambda", "Generated_MCRecoCollCheck_INEL_Lambda", - {HistType::kTH2D, {{ptAxis}, {flatAxis}}}); - } - if (doprocessGenMC) { rLambda.add("pGen_MCGenRecoColl_INEL_Lambda", "pGen_MCGenRecoColl_INEL_Lambda", {HistType::kTH2D, {ptAxis, flatAxis}}); rLambda.add("Generated_MCRecoColl_INEL_Lambda", "Generated_MCRecoColl_INEL_Lambda", @@ -347,41 +475,7 @@ struct lambdak0sflattenicity { {HistType::kTH2D, {ptAxis, flatAxis}}); rLambda.add("pGen_MCGenColl_INELgt0_Lambda", "pGen_MCGenColl_INELgt0_Lambda", {HistType::kTH2D, {ptAxis, flatAxis}}); - } - // AntiLambda reconstruction - // Mass - rAntiLambda.add("hMassAntiLambda", "hMassAntiLambda", - {HistType::kTH1D, {AntiLambdaMassAxis}}); - rAntiLambda.add("hMassAntiLambdaSelected", "hMassAntiLambdaSelected", - {HistType::kTH1D, {AntiLambdaMassAxis}}); - - // AntiLambda topological/PID cuts - rAntiLambda.add("hDCAV0DaughtersAntiLambda", "hDCAV0DaughtersAntiLambda", - {HistType::kTH1D, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); - rAntiLambda.add("hV0CosPAAntiLambda", "hV0CosPAAntiLambda", - {HistType::kTH1D, {{100, 0.95f, 1.f, "CosPA"}}}); - rAntiLambda.add("hNSigmaPosPionFromAntiLambda", - "hNSigmaPosPionFromAntiLambda", - {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); - rAntiLambda.add("hNSigmaNegPionFromAntiLambda", - "hNSigmaNegPionFromAntiLambda", - {HistType::kTH2D, {{100, -5.f, 5.f}, {ptAxis}}}); - rAntiLambda.add("hrapidityAntiLambda", "hrapidityAntiLambda", - {HistType::kTH1D, {{40, -2.0f, 2.0f, "y"}}}); - rAntiLambda.add("hctauAntiLambda", "hctauAntiLambda", - {HistType::kTH1D, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); - rAntiLambda.add("h2DdecayRadiusAntiLambda", "h2DdecayRadiusAntiLambda", - {HistType::kTH1D, {{100, 0.0f, 1.0f, "c#tau (cm)"}}}); - rAntiLambda.add("hMassAntiLambdapT", "hMassAntiLambdapT", - {HistType::kTH2D, {{AntiLambdaMassAxis}, {ptAxis}}}); - rAntiLambda.add("hMassAntiLambdapTFlat", "hMassAntiLambdapTFlat", - {HistType::kTH3D, {{AntiLambdaMassAxis}, {ptAxis}, {flatAxis}}}); - if (doprocessRecMC) { - rAntiLambda.add("Generated_MCRecoCollCheck_INEL_AntiLambda", "Generated_MCRecoCollCheck_INEL_AntiLambda", - {HistType::kTH2D, {{ptAxis}, {flatAxis}}}); - } - if (doprocessGenMC) { rAntiLambda.add("pGen_MCGenRecoColl_INEL_AntiLambda", "pGen_MCGenRecoColl_INEL_AntiLambda", {HistType::kTH2D, {ptAxis, flatAxis}}); rAntiLambda.add("Generated_MCRecoColl_INEL_AntiLambda", "Generated_MCRecoColl_INEL_AntiLambda", @@ -396,6 +490,21 @@ struct lambdak0sflattenicity { {HistType::kTH2D, {ptAxis, flatAxis}}); rAntiLambda.add("pGen_MCGenColl_INELgt0_AntiLambda", "pGen_MCGenColl_INELgt0_AntiLambda", {HistType::kTH2D, {ptAxis, flatAxis}}); + + rXi.add("pGen_MCGenRecoColl_INEL_Xi", "pGen_MCGenRecoColl_INEL_Xi", + {HistType::kTH2D, {ptAxis, flatAxis}}); + rXi.add("Generated_MCRecoColl_INEL_Xi", "Generated_MCRecoColl_INEL_Xi", + {HistType::kTH2D, {ptAxis, flatAxis}}); + rXi.add("pGen_MCGenColl_INEL_Xi", "pGen_MCGenColl_INEL_Xi", + {HistType::kTH2D, {ptAxis, flatAxis}}); + rXi.add("pGen_MCGenRecoColl_INELgt0_Xi", "pGen_MCGenRecoColl_INELgt0_Xi", + {HistType::kTH2D, {ptAxis, flatAxis}}); + rXi.add("Generated_MCRecoColl_INELgt0_Xi", "Generated_MCRecoColl_INELgt0_Xi", + {HistType::kTH2D, {ptAxis, flatAxis}}); + rXi.add("Generated_MCRecoCollCheck_INELgt0_Xi", "Generated_MCRecoCollCheck_INELgt0_Xi", + {HistType::kTH2D, {ptAxis, flatAxis}}); + rXi.add("pGen_MCGenColl_INELgt0_Xi", "pGen_MCGenColl_INELgt0_Xi", + {HistType::kTH2D, {ptAxis, flatAxis}}); } if (flattenicityQA) { @@ -411,20 +520,22 @@ struct lambdak0sflattenicity { {{50000, -0.5, 199999.5, "FT0C amplitudes"}}); rFlattenicity.add("hFT0A", "FT0A", HistType::kTH1D, {{2000, -0.5, 1999.5, "FT0A amplitudes"}}); + rFlattenicity.add("hFV0amplvsFlat", "FV0MvsFlat", HistType::kTH2D, + {{4000, -0.5, +49999.5, "FV0 amplitude"}, flatAxis}); // estimators - for (int i_e = 0; i_e < 8; ++i_e) { + for (int iEe = 0; iEe < 8; ++iEe) { rFlattenicity.add( - nhEst[i_e].data(), "", HistType::kTH2D, - {{nBinsEst[i_e], lowEdgeEst[i_e], upEdgeEst[i_e], tEst[i_e].data()}, + kHEst[iEe].data(), "", HistType::kTH2D, + {{nBinsEst[iEe], lowEdgeEst[iEe], upEdgeEst[iEe], kTEst[iEe].data()}, {100, -0.5, +99.5, "Global track"}}); } // vs pT - for (int i_e = 0; i_e < 8; ++i_e) { + for (int iEe = 0; iEe < 8; ++iEe) { rFlattenicity.add( - nhPtEst[i_e].data(), "", HistType::kTProfile, - {{nBinsEst[i_e], lowEdgeEst[i_e], upEdgeEst[i_e], tEst[i_e].data()}}); + kHPtEst[iEe].data(), "", HistType::kTProfile, + {{nBinsEst[iEe], lowEdgeEst[iEe], upEdgeEst[iEe], kTEst[iEe].data()}}); } rFlattenicity.add("fMultFv0", "FV0 amp", HistType::kTH1D, @@ -455,7 +566,7 @@ struct lambdak0sflattenicity { {20, -0.01, +1.01, "flatenicity (FT0A)"}}); rFlattenicity.add( "fEtaPhiFv0", "eta vs phi", HistType::kTH2D, - {{8, 0.0, 2 * M_PI, "#phi (rad)"}, {5, 2.2, 5.1, "#eta"}}); + {{8, 0.0, constants::math::TwoPI, "#phi (rad)"}, {5, 2.2, 5.1, "#eta"}}); rFlattenicity.add("hAmpV0vsVtxBeforeCalibration", "", HistType::kTH2D, {{30, -15.0, +15.0, "Trk mult"}, @@ -477,162 +588,154 @@ struct lambdak0sflattenicity { "hAmpT0CvsVtx", "", HistType::kTH2D, {{30, -15.0, +15.0, "Vtx_z"}, {600, -0.5, +5999.5, "FT0C amplitude"}}); } - if (doprocessDataRun3 && (doprocessRecMC || doprocessGenMC)) { - LOGF(fatal, - "Both Data and MC are both set to true; try again with only " - "one of them set to true"); - } - if (!doprocessDataRun3 && !(doprocessRecMC || doprocessGenMC)) { - LOGF(fatal, - "Both Data and MC set to false; try again with only one of " - "them set to false"); + + if ((doprocessDataRun3LambdaK0s || doprocessRecMCLambdaK0s) && (doprocessDataRun3Cascade || doprocessRecMCRun3Cascade)) { + LOGF(fatal, "Can not run both LambdaK0s and Cascade process functions simulatenously. Try one at a time."); } - if ((doprocessRecMC && !doprocessGenMC) || - (!doprocessRecMC && doprocessGenMC)) { - LOGF(fatal, - "MCRec and MCGen are set to opposite switches, try again " - "with both set to either true or false"); + + if ((doprocessDataRun3LambdaK0s || doprocessDataRun3Cascade) && doprocessGenMC) { + LOGF(fatal, "Can not run MCGen and Data process functions together. Try one of these at a time"); } } - int getT0ASector(int i_ch) + int getT0ASector(int iCh) { - int i_sec_t0a = -1; - for (int i_sec = 0; i_sec < 24; ++i_sec) { - if (i_ch >= 4 * i_sec && i_ch <= 3 + 4 * i_sec) { - i_sec_t0a = i_sec; + int iSecT0a = -1; + for (int iSec = 0; iSec < 24; ++iSec) { + if (iCh >= 4 * iSec && iCh <= 3 + 4 * iSec) { + iSecT0a = iSec; break; } } - return i_sec_t0a; + return iSecT0a; } - int getT0CSector(int i_ch) + int getT0CSector(int iCh) { - int i_sec_t0c = -1; - for (int i_sec = 0; i_sec < 28; ++i_sec) { - if (i_ch >= 4 * i_sec && i_ch <= 3 + 4 * i_sec) { - i_sec_t0c = i_sec; + int iSecT0c = -1; + for (int iSec = 0; iSec < 28; ++iSec) { + if (iCh >= 4 * iSec && iCh <= 3 + 4 * iSec) { + iSecT0c = iSec; break; } } - return i_sec_t0c; + return iSecT0c; } - int getFV0Ring(int i_ch) + int getFV0Ring(int iCh) { - int i_ring = -1; - if (i_ch < 8) { - i_ring = 0; - } else if (i_ch >= 8 && i_ch < 16) { - i_ring = 1; - } else if (i_ch >= 16 && i_ch < 24) { - i_ring = 2; - } else if (i_ch >= 24 && i_ch < 32) { - i_ring = 3; + int iRing = -1; + if (iCh < 8) { + iRing = 0; + } else if (iCh >= 8 && iCh < 16) { + iRing = 1; + } else if (iCh >= 16 && iCh < 24) { + iRing = 2; + } else if (iCh >= 24 && iCh < 32) { + iRing = 3; } else { - i_ring = 4; + iRing = 4; } - return i_ring; + return iRing; } - int getFV0IndexPhi(int i_ch) + int getFV0IndexPhi(int iCh) { - int i_ring = -1; + int iRing = -1; - if (i_ch >= 0 && i_ch < 8) { - if (i_ch < 4) { - i_ring = i_ch; + if (iCh >= 0 && iCh < 8) { + if (iCh < 4) { + iRing = iCh; } else { - if (i_ch == 7) { - i_ring = 4; - } else if (i_ch == 6) { - i_ring = 5; - } else if (i_ch == 5) { - i_ring = 6; - } else if (i_ch == 4) { - i_ring = 7; + if (iCh == 7) { + iRing = 4; + } else if (iCh == 6) { + iRing = 5; + } else if (iCh == 5) { + iRing = 6; + } else if (iCh == 4) { + iRing = 7; } } - } else if (i_ch >= 8 && i_ch < 16) { - if (i_ch < 12) { - i_ring = i_ch; + } else if (iCh >= 8 && iCh < 16) { + if (iCh < 12) { + iRing = iCh; } else { - if (i_ch == 15) { - i_ring = 12; - } else if (i_ch == 14) { - i_ring = 13; - } else if (i_ch == 13) { - i_ring = 14; - } else if (i_ch == 12) { - i_ring = 15; + if (iCh == 15) { + iRing = 12; + } else if (iCh == 14) { + iRing = 13; + } else if (iCh == 13) { + iRing = 14; + } else if (iCh == 12) { + iRing = 15; } } - } else if (i_ch >= 16 && i_ch < 24) { - if (i_ch < 20) { - i_ring = i_ch; + } else if (iCh >= 16 && iCh < 24) { + if (iCh < 20) { + iRing = iCh; } else { - if (i_ch == 23) { - i_ring = 20; - } else if (i_ch == 22) { - i_ring = 21; - } else if (i_ch == 21) { - i_ring = 22; - } else if (i_ch == 20) { - i_ring = 23; + if (iCh == 23) { + iRing = 20; + } else if (iCh == 22) { + iRing = 21; + } else if (iCh == 21) { + iRing = 22; + } else if (iCh == 20) { + iRing = 23; } } - } else if (i_ch >= 24 && i_ch < 32) { - if (i_ch < 28) { - i_ring = i_ch; + } else if (iCh >= 24 && iCh < 32) { + if (iCh < 28) { + iRing = iCh; } else { - if (i_ch == 31) { - i_ring = 28; - } else if (i_ch == 30) { - i_ring = 29; - } else if (i_ch == 29) { - i_ring = 30; - } else if (i_ch == 28) { - i_ring = 31; + if (iCh == 31) { + iRing = 28; + } else if (iCh == 30) { + iRing = 29; + } else if (iCh == 29) { + iRing = 30; + } else if (iCh == 28) { + iRing = 31; } } - } else if (i_ch == 32) { - i_ring = 32; - } else if (i_ch == 40) { - i_ring = 33; - } else if (i_ch == 33) { - i_ring = 34; - } else if (i_ch == 41) { - i_ring = 35; - } else if (i_ch == 34) { - i_ring = 36; - } else if (i_ch == 42) { - i_ring = 37; - } else if (i_ch == 35) { - i_ring = 38; - } else if (i_ch == 43) { - i_ring = 39; - } else if (i_ch == 47) { - i_ring = 40; - } else if (i_ch == 39) { - i_ring = 41; - } else if (i_ch == 46) { - i_ring = 42; - } else if (i_ch == 38) { - i_ring = 43; - } else if (i_ch == 45) { - i_ring = 44; - } else if (i_ch == 37) { - i_ring = 45; - } else if (i_ch == 44) { - i_ring = 46; - } else if (i_ch == 36) { - i_ring = 47; - } - return i_ring; + } else if (iCh == 32) { + iRing = 32; + } else if (iCh == 40) { + iRing = 33; + } else if (iCh == 33) { + iRing = 34; + } else if (iCh == 41) { + iRing = 35; + } else if (iCh == 34) { + iRing = 36; + } else if (iCh == 42) { + iRing = 37; + } else if (iCh == 35) { + iRing = 38; + } else if (iCh == 43) { + iRing = 39; + } else if (iCh == 47) { + iRing = 40; + } else if (iCh == 39) { + iRing = 41; + } else if (iCh == 46) { + iRing = 42; + } else if (iCh == 38) { + iRing = 43; + } else if (iCh == 45) { + iRing = 44; + } else if (iCh == 37) { + iRing = 45; + } else if (iCh == 44) { + iRing = 46; + } else if (iCh == 36) { + iRing = 47; + } + return iRing; } - float GetFlatenicity(std::span signals) + float getFlatenicity(std::span signals) { int entries = signals.size(); float flat = 9999; @@ -643,12 +746,12 @@ struct lambdak0sflattenicity { // average activity per cell mRho /= (1.0 * entries); // get sigma - float sRho_tmp = 0; + float sRhoTmp = 0; for (int iCell = 0; iCell < entries; ++iCell) { - sRho_tmp += TMath::Power(1.0 * signals[iCell] - mRho, 2); + sRhoTmp += std::pow(1.0 * signals[iCell] - mRho, 2); } - sRho_tmp /= (1.0 * entries * entries); - float sRho = TMath::Sqrt(sRho_tmp); + sRhoTmp /= (1.0 * entries * entries); + float sRho = std::sqrt(sRhoTmp); if (mRho > 0) { flat = sRho / mRho; } @@ -656,8 +759,10 @@ struct lambdak0sflattenicity { } float pdgmassK0s = 0.497614; float pdgmassLambda = 1.115683; + float pdgmassXi = 1.3217; + float pdgmassOmega = 1.67243; // V0A signal and flatenicity calculation - static constexpr float calib[48] = { + static constexpr float kCalib[48] = { 1.01697, 1.122, 1.03854, 1.108, 1.11634, 1.14971, 1.19321, 1.06866, 0.954675, 0.952695, 0.969853, 0.957557, 0.989784, 1.01549, 1.02182, 0.976005, 1.01865, 1.06871, 1.06264, 1.02969, 1.07378, @@ -666,153 +771,177 @@ struct lambdak0sflattenicity { 1.00122, 1.03303, 0.887866, 0.892437, 0.906278, 0.884976, 0.864251, 0.917221, 1.10618, 1.04028, 0.893184, 0.915734, 0.892676}; // calibration T0C - static constexpr float calibT0C[28] = { + static constexpr float kCalibT0C[28] = { 0.949829, 1.05408, 1.00681, 1.00724, 0.990663, 0.973571, 0.9855, 1.03726, 1.02526, 1.00467, 0.983008, 0.979349, 0.952352, 0.985775, 1.013, 1.01721, 0.993948, 0.996421, 0.971871, 1.02921, 0.989641, 1.01885, 1.01259, 0.929502, 1.03969, 1.02496, 1.01385, 1.01711}; // calibration T0A - static constexpr float calibT0A[24] = { + static constexpr float kCalibT0A[24] = { 0.86041, 1.10607, 1.17724, 0.756397, 1.14954, 1.0879, 0.829438, 1.09014, 1.16515, 0.730077, 1.06722, 0.906344, 0.824167, 1.14716, 1.20692, 0.755034, 1.11734, 1.00556, 0.790522, 1.09138, 1.16225, 0.692458, 1.12428, 1.01127}; // calibration factor MFT vs vtx - static constexpr float biningVtxt[30] = { + static constexpr float kBiningVtxt[30] = { -14.5, -13.5, -12.5, -11.5, -10.5, -9.5, -8.5, -7.5, -6.5, -5.5, -4.5, -3.5, -2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5}; // calibration factor FV0 vs vtx - static constexpr float calibFV0vtx[30] = { + static constexpr float kCalibFV0vtx[30] = { 0.907962, 0.934607, 0.938929, 0.950987, 0.950817, 0.966362, 0.968509, 0.972741, 0.982412, 0.984872, 0.994543, 0.996003, 0.99435, 1.00266, 0.998245, 1.00584, 1.01078, 1.01003, 1.00726, 1.00872, 1.01726, 1.02015, 1.0193, 1.01106, 1.02229, 1.02104, 1.03435, 1.00822, 1.01921, 1.01736}; // calibration FT0A vs vtx - static constexpr float calibFT0Avtx[30] = { + static constexpr float kCalibFT0Avtx[30] = { 0.924334, 0.950988, 0.959604, 0.965607, 0.970016, 0.979057, 0.978384, 0.982005, 0.992825, 0.990048, 0.998588, 0.997338, 1.00102, 1.00385, 0.99492, 1.01083, 1.00703, 1.00494, 1.00063, 1.0013, 1.00777, 1.01238, 1.01179, 1.00577, 1.01028, 1.017, 1.02975, 1.0085, 1.00856, 1.01662}; // calibration FT0C vs vtx - static constexpr float calibFT0Cvtx[30] = { + static constexpr float kCalibFT0Cvtx[30] = { 1.02096, 1.01245, 1.02148, 1.03605, 1.03561, 1.03667, 1.04229, 1.0327, 1.03674, 1.02764, 1.01828, 1.02331, 1.01864, 1.015, 1.01197, 1.00615, 0.996845, 0.993051, 0.985635, 0.982883, 0.981914, 0.964635, 0.967812, 0.95475, 0.956687, 0.932816, 0.92773, 0.914892, 0.891724, 0.872382}; - static constexpr int nEta5 = 2; // FT0C + FT0A - static constexpr float weigthsEta5[nEta5] = {0.0490638, 0.010958415}; - static constexpr float deltaEeta5[nEta5] = {1.1, 1.2}; - - static constexpr int nEta6 = 2; // FT0C + FV0 - static constexpr float weigthsEta6[nEta6] = {0.0490638, 0.00353962}; - static constexpr float deltaEeta6[nEta6] = {1.1, 2.9}; - - static constexpr int innerFV0 = 32; - static constexpr float maxEtaFV0 = 5.1; - static constexpr float minEtaFV0 = 2.2; - static constexpr float detaFV0 = (maxEtaFV0 - minEtaFV0) / 5.0; - - static constexpr int nCells = 48; // 48 sectors in FV0 - std::array RhoLattice; - std::array RhoLatticeFV0AMC; - std::array ampchannel; - std::array ampchannelBefore; - static constexpr int nCellsT0A = 24; - std::array RhoLatticeT0A; - static constexpr int nCellsT0C = 28; - std::array RhoLatticeT0C; + static constexpr int kNeta5 = 2; // FT0C + FT0A + static constexpr float kWeigthsEta5[kNeta5] = {0.0490638, 0.010958415}; + static constexpr float kDeltaEeta5[kNeta5] = {1.1, 1.2}; + + static constexpr int kNeta6 = 2; // FT0C + FV0 + static constexpr float kWeigthsEta6[kNeta6] = {0.0490638, 0.00353962}; + static constexpr float kDeltaEeta6[kNeta6] = {1.1, 2.9}; + + static constexpr int kInnerFV0 = 32; + static constexpr float kMaxEtaFV0 = 5.1; + static constexpr float kMinEtaFV0 = 2.2; + static constexpr float kDetaFV0 = (kMaxEtaFV0 - kMinEtaFV0) / 5.0; + + static constexpr int kNCells = 48; // 48 sectors in FV0 + std::array rhoLattice; + std::array rhoLatticeFV0AMC; + std::array ampchannel; + std::array ampchannelBefore; + static constexpr int kNCellsT0A = 24; + std::array rhoLatticeT0A; + static constexpr int kNCellsT0C = 28; + std::array rhoLatticeT0C; std::array estimator; template bool isEventSelected(TCollision const& collision) { - rEventSelection.fill(HIST("hEventsSelected"), 0.5); + float nbinev = 0.5; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); - if (Issel8 && !collision.sel8()) { + if (issel8 && !collision.sel8()) { return false; } + if (issel8) { + nbinev++; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); + } - rEventSelection.fill(HIST("hEventsSelected"), 1.5); - if (TMath::Abs(collision.posZ()) > cutzvertex) { + if (std::abs(collision.posZ()) > cutzvertex) { return false; } - rEventSelection.fill(HIST("hEventsSelected"), 2.5); + nbinev++; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); - if (IsNoTimeFrameBorder && + if (isNoTimeFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { return false; } - rEventSelection.fill(HIST("hEventsSelected"), 3.5); + if (isNoTimeFrameBorder) { + nbinev++; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); + } - if (IsNoITSROFrameBorder && + if (isNoITSROFrameBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { return false; } - rEventSelection.fill(HIST("hEventsSelected"), 4.5); - - if (IsVertexITSTPC && + if (isNoITSROFrameBorder) { + nbinev++; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); + } + if (isVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { return false; } - rEventSelection.fill(HIST("hEventsSelected"), 5.5); + if (isVertexITSTPC) { + nbinev++; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); + } - if (IsNoSameBunchPileup && + if (isNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { return false; } - rEventSelection.fill(HIST("hEventsSelected"), 6.5); + if (isNoSameBunchPileup) { + nbinev++; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); + } - if (IsGoodZvtxFT0vsPV && + if (isGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { return false; } - rEventSelection.fill(HIST("hEventsSelected"), 7.5); - - if (IsTriggerTVX && + if (isGoodZvtxFT0vsPV) { + nbinev++; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); + } + if (isTriggerTVX && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { return false; } - rEventSelection.fill(HIST("hEventsSelected"), 8.5); + if (isTriggerTVX) { + nbinev++; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); + } - if (IsINELgt0 && (collision.isInelGt0() == false)) { + if (isINELgt0 && (collision.isInelGt0() == false)) { return false; } - rEventSelection.fill(HIST("hEventsSelected"), 9.5); + if (isINELgt0) { + nbinev++; + rEventSelection.fill(HIST("hEventsSelected"), nbinev); + } return true; } // ============== Flattenicity estimation begins ===================== // template - float EstimateFlattenicity(TCollision const& collision, Tracks const& tracks) + float estimateFlattenicity(TCollision const& collision, Tracks const& tracks) { const int nDetVtx = 3; TGraph* gVtx[nDetVtx]; const char* nameDet[nDetVtx] = {"AmpV0", "AmpT0A", "AmpT0C"}; - float ampl5[nEta5] = {0, 0}; - float ampl6[nEta6] = {0, 0}; + float ampl5[kNeta5] = {0, 0}; + float ampl6[kNeta6] = {0, 0}; for (int i_d = 0; i_d < nDetVtx; ++i_d) { gVtx[i_d] = 0; gVtx[i_d] = new TGraph(); } for (int i_v = 0; i_v < 30; ++i_v) { - gVtx[0]->SetPoint(i_v, biningVtxt[i_v], calibFV0vtx[i_v]); + gVtx[0]->SetPoint(i_v, kBiningVtxt[i_v], kCalibFV0vtx[i_v]); } for (int i_v = 0; i_v < 30; ++i_v) { - gVtx[1]->SetPoint(i_v, biningVtxt[i_v], calibFT0Avtx[i_v]); + gVtx[1]->SetPoint(i_v, kBiningVtxt[i_v], kCalibFT0Avtx[i_v]); } for (int i_v = 0; i_v < 30; ++i_v) { - gVtx[2]->SetPoint(i_v, biningVtxt[i_v], calibFT0Cvtx[i_v]); + gVtx[2]->SetPoint(i_v, kBiningVtxt[i_v], kCalibFT0Cvtx[i_v]); } for (int i_d = 0; i_d < nDetVtx; ++i_d) { @@ -825,7 +954,7 @@ struct lambdak0sflattenicity { ampchannel.fill(0.0); ampchannelBefore.fill(0.0); - RhoLattice.fill(0); + rhoLattice.fill(0); if ((isflattenicitywithFV0 || isflattenicitywithFV0FT0C) && collision.has_foundFV0()) { @@ -835,32 +964,32 @@ struct lambdak0sflattenicity { float phiv0 = -999.0; float etav0 = -999.0; int channelv0 = fv0.channel()[ich]; - float ampl_ch = fv0.amplitude()[ich]; + float amplCh = fv0.amplitude()[ich]; int ringindex = getFV0Ring(channelv0); int channelv0phi = getFV0IndexPhi(channelv0); - etav0 = maxEtaFV0 - (detaFV0 / 2.0) * (2.0 * ringindex + 1); - if (channelv0 < innerFV0) { - phiv0 = (2.0 * (channelv0phi - 8 * ringindex) + 1) * M_PI / (8.0); + etav0 = kMaxEtaFV0 - (kDetaFV0 / 2.0) * (2.0 * ringindex + 1); + if (channelv0 < kInnerFV0) { + phiv0 = (2.0 * (channelv0phi - 8 * ringindex) + 1) * constants::math::PI / (8.0); } else { - phiv0 = ((2.0 * channelv0phi) + 1 - 64.0) * 2.0 * M_PI / (32.0); + phiv0 = ((2.0 * channelv0phi) + 1 - 64.0) * constants::math::TwoPI / (32.0); } - ampchannelBefore[channelv0phi] = ampl_ch; + ampchannelBefore[channelv0phi] = amplCh; if (applyCalibCh) { - ampl_ch *= calib[channelv0phi]; + amplCh *= kCalib[channelv0phi]; } - sumAmpFV0 += ampl_ch; + sumAmpFV0 += amplCh; if (channelv0 >= 8) { // exclude the 1st ch, eta 2.2,4.52 - sumAmpFV01to4Ch += ampl_ch; + sumAmpFV01to4Ch += amplCh; } if (flattenicityQA) { - rFlattenicity.fill(HIST("fEtaPhiFv0"), phiv0, etav0, ampl_ch); + rFlattenicity.fill(HIST("fEtaPhiFv0"), phiv0, etav0, amplCh); } - ampchannel[channelv0phi] = ampl_ch; - if (channelv0 < innerFV0) { - RhoLattice[channelv0phi] = ampl_ch; + ampchannel[channelv0phi] = amplCh; + if (channelv0 < kInnerFV0) { + rhoLattice[channelv0phi] = amplCh; } else { - RhoLattice[channelv0phi] = ampl_ch / 2.0; // two channels per bin + rhoLattice[channelv0phi] = amplCh / 2.0; // two channels per bin } } @@ -878,13 +1007,13 @@ struct lambdak0sflattenicity { float flattenicityfv0 = 9999; if (isflattenicitywithFV0 || isflattenicitywithFV0FT0C) { - flattenicityfv0 = GetFlatenicity({RhoLattice.data(), RhoLattice.size()}); + flattenicityfv0 = getFlatenicity({rhoLattice.data(), rhoLattice.size()}); } // global tracks float ptT = 0.; int multGlob = 0; - for (auto& track : tracks) { + for (const auto& track : tracks) { if (!track.isGlobalTrack()) { continue; } @@ -898,8 +1027,8 @@ struct lambdak0sflattenicity { float sumAmpFT0A = 0.f; float sumAmpFT0C = 0.f; - RhoLatticeT0A.fill(0); - RhoLatticeT0C.fill(0); + rhoLatticeT0A.fill(0); + rhoLatticeT0C.fill(0); if ((isflattenicitywithFT0 || isflattenicitywithFV0FT0C) && collision.has_foundFT0()) { @@ -910,13 +1039,13 @@ struct lambdak0sflattenicity { uint8_t channel = ft0.channelA()[i_a]; int sector = getT0ASector(channel); if (sector >= 0 && sector < 24) { - RhoLatticeT0A[sector] += amplitude; + rhoLatticeT0A[sector] += amplitude; if (flattenicityQA) { rFlattenicity.fill(HIST("hAmpT0AVsChBeforeCalibration"), sector, amplitude); } if (applyCalibCh) { - amplitude *= calibT0A[sector]; + amplitude *= kCalibT0A[sector]; } if (flattenicityQA) { rFlattenicity.fill(HIST("hAmpT0AVsCh"), sector, amplitude); @@ -935,13 +1064,13 @@ struct lambdak0sflattenicity { uint8_t channel = ft0.channelC()[i_c]; int sector = getT0CSector(channel); if (sector >= 0 && sector < 28) { - RhoLatticeT0C[sector] += amplitude; + rhoLatticeT0C[sector] += amplitude; if (flattenicityQA) { rFlattenicity.fill(HIST("hAmpT0CVsChBeforeCalibration"), sector, amplitude); } if (applyCalibCh) { - amplitude *= calibT0C[sector]; + amplitude *= kCalibT0C[sector]; } if (flattenicityQA) { rFlattenicity.fill(HIST("hAmpT0CVsCh"), sector, amplitude); @@ -966,46 +1095,46 @@ struct lambdak0sflattenicity { rFlattenicity.fill(HIST("hAmpT0CvsVtx"), vtxZ, sumAmpFT0C); } } - float flatenicity_t0a = 9999; + float flatenicityT0a = 9999; if (isflattenicitywithFT0) { - flatenicity_t0a = - GetFlatenicity({RhoLatticeT0A.data(), RhoLatticeT0A.size()}); + flatenicityT0a = + getFlatenicity({rhoLatticeT0A.data(), rhoLatticeT0A.size()}); } - float flatenicity_t0c = 9999; + float flatenicityT0c = 9999; if (isflattenicitywithFT0 || isflattenicitywithFV0FT0C) { - flatenicity_t0c = - GetFlatenicity({RhoLatticeT0C.data(), RhoLatticeT0C.size()}); + flatenicityT0c = + getFlatenicity({rhoLatticeT0C.data(), rhoLatticeT0C.size()}); } - bool isOK_estimator5 = false; - bool isOK_estimator6 = false; - float combined_estimator5 = 0; - float combined_estimator6 = 0; + bool isOKEstimator5 = false; + bool isOKEstimator6 = false; + float combinedEstimator5 = 0; + float combinedEstimator6 = 0; - for (int i_e = 0; i_e < 8; ++i_e) { - estimator[i_e] = 0; + for (int iEe = 0; iEe < 8; ++iEe) { + estimator[iEe] = 0; } if (collision.has_foundFV0() && collision.has_foundFT0()) { - float all_weights = 0; + float allWeights = 0; // option 5 ampl5[0] = sumAmpFT0C; ampl5[1] = sumAmpFT0A; if (sumAmpFT0C > 0 && sumAmpFT0A > 0) { - isOK_estimator5 = true; + isOKEstimator5 = true; } - if (isOK_estimator5) { + if (isOKEstimator5) { if (applyNorm) { - all_weights = 0; - for (int i_5 = 0; i_5 < nEta5; ++i_5) { - combined_estimator5 += - ampl5[i_5] * weigthsEta5[i_5] / deltaEeta5[i_5]; - all_weights += weigthsEta5[i_5]; + allWeights = 0; + for (int i5 = 0; i5 < kNeta5; ++i5) { + combinedEstimator5 += + ampl5[i5] * kWeigthsEta5[i5] / kDeltaEeta5[i5]; + allWeights += kWeigthsEta5[i5]; } - combined_estimator5 /= all_weights; + combinedEstimator5 /= allWeights; } else { - for (int i_5 = 0; i_5 < nEta5; ++i_5) { - combined_estimator5 += ampl5[i_5] * weigthsEta5[i_5]; + for (int i5 = 0; i5 < kNeta5; ++i5) { + combinedEstimator5 += ampl5[i5] * kWeigthsEta5[i5]; } } } @@ -1013,20 +1142,20 @@ struct lambdak0sflattenicity { ampl6[0] = sumAmpFT0C; ampl6[1] = sumAmpFV0; if (sumAmpFT0C > 0 && sumAmpFV0 > 0) { - isOK_estimator6 = true; + isOKEstimator6 = true; } - if (isOK_estimator6) { + if (isOKEstimator6) { if (applyNorm) { - all_weights = 0; - for (int i_6 = 0; i_6 < nEta6; ++i_6) { - combined_estimator6 += - ampl6[i_6] * weigthsEta6[i_6] / deltaEeta6[i_6]; - all_weights += weigthsEta6[i_6]; + allWeights = 0; + for (int i6 = 0; i6 < kNeta6; ++i6) { + combinedEstimator6 += + ampl6[i6] * kWeigthsEta6[i6] / kDeltaEeta6[i6]; + allWeights += kWeigthsEta6[i6]; } - combined_estimator6 /= all_weights; + combinedEstimator6 /= allWeights; } else { - for (int i_6 = 0; i_6 < nEta6; ++i_6) { - combined_estimator6 += ampl6[i_6] * weigthsEta6[i_6]; + for (int i6 = 0; i6 < kNeta6; ++i6) { + combinedEstimator6 += ampl6[i6] * kWeigthsEta6[i6]; } } } @@ -1039,37 +1168,37 @@ struct lambdak0sflattenicity { estimator[0] = multGlob; estimator[1] = sumAmpFV0; estimator[2] = 1.0 - flattenicityfv0; - estimator[3] = combined_estimator5; - float flatenicity_ft0 = (flatenicity_t0a + flatenicity_t0c) / 2.0; - estimator[4] = 1.0 - flatenicity_ft0; - estimator[5] = combined_estimator6; - float flatenicity_ft0v0 = 0.5 * flattenicityfv0 + 0.5 * flatenicity_t0c; - estimator[6] = 1.0 - flatenicity_ft0v0; + estimator[3] = combinedEstimator5; + float flatenicityFT0 = (flatenicityT0a + flatenicityT0c) / 2.0; + estimator[4] = 1.0 - flatenicityFT0; + estimator[5] = combinedEstimator6; + float flatenicityFT0v0 = 0.5 * flattenicityfv0 + 0.5 * flatenicityT0c; + estimator[6] = 1.0 - flatenicityFT0v0; estimator[7] = ptT; if (flattenicityQA) { - rFlattenicity.fill(HIST(nhEst[0]), estimator[0], estimator[0]); - rFlattenicity.fill(HIST(nhEst[1]), estimator[1], estimator[0]); - rFlattenicity.fill(HIST(nhEst[2]), estimator[2], estimator[0]); - rFlattenicity.fill(HIST(nhEst[3]), estimator[3], estimator[0]); - rFlattenicity.fill(HIST(nhEst[4]), estimator[4], estimator[0]); - rFlattenicity.fill(HIST(nhEst[5]), estimator[5], estimator[0]); - rFlattenicity.fill(HIST(nhEst[6]), estimator[6], estimator[0]); - rFlattenicity.fill(HIST(nhEst[7]), estimator[7], estimator[0]); + rFlattenicity.fill(HIST(kHEst[0]), estimator[0], estimator[0]); + rFlattenicity.fill(HIST(kHEst[1]), estimator[1], estimator[0]); + rFlattenicity.fill(HIST(kHEst[2]), estimator[2], estimator[0]); + rFlattenicity.fill(HIST(kHEst[3]), estimator[3], estimator[0]); + rFlattenicity.fill(HIST(kHEst[4]), estimator[4], estimator[0]); + rFlattenicity.fill(HIST(kHEst[5]), estimator[5], estimator[0]); + rFlattenicity.fill(HIST(kHEst[6]), estimator[6], estimator[0]); + rFlattenicity.fill(HIST(kHEst[7]), estimator[7], estimator[0]); // plot pt vs estimators - for (auto& track : tracks) { + for (const auto& track : tracks) { if (!track.isGlobalTrack()) { continue; } float pt = track.pt(); - rFlattenicity.fill(HIST(nhPtEst[0]), estimator[0], pt); - rFlattenicity.fill(HIST(nhPtEst[1]), estimator[1], pt); - rFlattenicity.fill(HIST(nhPtEst[2]), estimator[2], pt); - rFlattenicity.fill(HIST(nhPtEst[3]), estimator[3], pt); - rFlattenicity.fill(HIST(nhPtEst[4]), estimator[4], pt); - rFlattenicity.fill(HIST(nhPtEst[5]), estimator[5], pt); - rFlattenicity.fill(HIST(nhPtEst[6]), estimator[6], pt); - rFlattenicity.fill(HIST(nhPtEst[7]), estimator[7], pt); + rFlattenicity.fill(HIST(kHPtEst[0]), estimator[0], pt); + rFlattenicity.fill(HIST(kHPtEst[1]), estimator[1], pt); + rFlattenicity.fill(HIST(kHPtEst[2]), estimator[2], pt); + rFlattenicity.fill(HIST(kHPtEst[3]), estimator[3], pt); + rFlattenicity.fill(HIST(kHPtEst[4]), estimator[4], pt); + rFlattenicity.fill(HIST(kHPtEst[5]), estimator[5], pt); + rFlattenicity.fill(HIST(kHPtEst[6]), estimator[6], pt); + rFlattenicity.fill(HIST(kHPtEst[7]), estimator[7], pt); } if (isflattenicitywithFV0) { @@ -1081,11 +1210,13 @@ struct lambdak0sflattenicity { } rFlattenicity.fill(HIST("fMultFv0"), sumAmpFV0); - rFlattenicity.fill(HIST("hFlatFT0CvsFlatFT0A"), flatenicity_t0c, - flatenicity_t0a); + rFlattenicity.fill(HIST("hFlatFT0CvsFlatFT0A"), flatenicityT0c, + flatenicityT0a); } } float finalflattenicity = estimator[2]; + rFlattenicity.fill(HIST("hFV0amplvsFlat"), sumAmpFV0, estimator[2]); + if (flattenicityforanalysis == 1) { finalflattenicity = estimator[4]; } @@ -1096,12 +1227,14 @@ struct lambdak0sflattenicity { } template - float EstimateFlattenicityFV0MC(McParticles const& mcParticles) + float estimateFlattenicityFV0MC(McParticles const& mcParticles) { - RhoLatticeFV0AMC.fill(0); + rhoLatticeFV0AMC.fill(0); float flattenicity = -1; float etamin, etamax, minphi, maxphi, dphi; int isegment = 0, nsectors; + int multFV0 = 0; + for (const auto& mcParticle : mcParticles) { if (!(mcParticle.isPhysicalPrimary() && mcParticle.pt() > 0)) { continue; @@ -1115,25 +1248,27 @@ struct lambdak0sflattenicity { float etap = mcParticle.eta(); float phip = mcParticle.phi(); isegment = 0; + for (int ieta = 0; ieta < 5; ieta++) { - etamax = maxEtaFV0 - ieta * detaFV0; + etamax = kMaxEtaFV0 - ieta * kDetaFV0; if (ieta == 0) { - etamax = maxEtaFV0; + etamax = kMaxEtaFV0; } - etamin = maxEtaFV0 - (ieta + 1) * detaFV0; + etamin = kMaxEtaFV0 - (ieta + 1) * kDetaFV0; if (ieta == 4) { - etamin = minEtaFV0; + etamin = kMinEtaFV0; } nsectors = 8; if (ieta == 4) { nsectors = 16; } for (int iphi = 0; iphi < nsectors; iphi++) { - minphi = iphi * 2.0 * TMath::Pi() / nsectors; - maxphi = (iphi + 1) * 2.0 * TMath::Pi() / nsectors; - dphi = TMath::Abs(maxphi - minphi); + minphi = iphi * constants::math::TwoPI / nsectors; + maxphi = (iphi + 1) * constants::math::TwoPI / nsectors; + dphi = std::abs(maxphi - minphi); if (etap >= etamin && etap < etamax && phip >= minphi && phip < maxphi) { - RhoLatticeFV0AMC[isegment] += 1.0 / TMath::Abs(dphi * detaFV0); + rhoLatticeFV0AMC[isegment] += 1.0 / std::abs(dphi * kDetaFV0); + multFV0++; } isegment++; } @@ -1141,7 +1276,8 @@ struct lambdak0sflattenicity { } flattenicity = - 1.0 - GetFlatenicity({RhoLatticeFV0AMC.data(), RhoLatticeFV0AMC.size()}); + 1.0 - getFlatenicity({rhoLatticeFV0AMC.data(), rhoLatticeFV0AMC.size()}); + rEventSelection.fill(HIST("hTrueFV0amplvsFlat"), multFV0, estimator[2]); return flattenicity; } // ====================== Flattenicity estimation ends ===================== @@ -1149,9 +1285,9 @@ struct lambdak0sflattenicity { // Filters on V0s // Cannot filter on dynamic columns, so we cut on DCA to PV and DCA between // daughters only - Filter preFilterV0 = (nabs(aod::v0data::dcapostopv) > v0setting_dcapostopv && - nabs(aod::v0data::dcanegtopv) > v0setting_dcanegtopv && - aod::v0data::dcaV0daughters < v0setting_dcav0dau); + Filter preFilterV0 = (nabs(aod::v0data::dcapostopv) > v0settingDCApostopv && + nabs(aod::v0data::dcanegtopv) > v0settingDCAnegtopv && + aod::v0data::dcaV0daughters < v0settingDCAv0dau); Filter trackFilter = (nabs(aod::track::eta) < cfgTrkEtaCut && aod::track::pt > cfgTrkLowPtCut); @@ -1160,12 +1296,11 @@ struct lambdak0sflattenicity { soa::Join>; - void processDataRun3( + void processDataRun3LambdaK0s( soa::Join::iterator const& collision, soa::Filtered const& V0s, TrackCandidates const& tracks, - soa::Join const& /*bcs*/, - aod::MFTTracks const& /*mfttracks*/, aod::FT0s const& /*ft0s*/, + soa::Join const& /*bcs*/, aod::FT0s const& /*ft0s*/, aod::FV0As const& /*fv0s*/) { if (applyEvSel && @@ -1178,7 +1313,7 @@ struct lambdak0sflattenicity { auto vtxY = collision.posY(); auto vtxX = collision.posX(); - float flattenicity = EstimateFlattenicity(collision, tracks); + float flattenicity = estimateFlattenicity(collision, tracks); rEventSelection.fill(HIST("hVertexZ"), vtxZ); rEventSelection.fill(HIST("hFlattenicityDistribution"), flattenicity); @@ -1187,8 +1322,8 @@ struct lambdak0sflattenicity { const auto& posDaughterTrack = v0.posTrack_as(); const auto& negDaughterTrack = v0.negTrack_as(); - if (TMath::Abs(posDaughterTrack.eta()) > cfgTrkEtaCut || - TMath::Abs(negDaughterTrack.eta()) > cfgTrkEtaCut || + if (std::abs(posDaughterTrack.eta()) > cfgTrkEtaCut || + std::abs(negDaughterTrack.eta()) > cfgTrkEtaCut || negDaughterTrack.pt() < cfgTrkLowPtCut || posDaughterTrack.pt() < cfgTrkLowPtCut) { continue; @@ -1205,26 +1340,31 @@ struct lambdak0sflattenicity { float decayvtxY = v0.y(); float decayvtxZ = v0.z(); - float decaylength = TMath::Sqrt(TMath::Power(decayvtxX - vtxX, 2) + - TMath::Power(decayvtxY - vtxY, 2) + - TMath::Power(decayvtxZ - vtxZ, 2)); - float v0p = TMath::Sqrt(v0.pt() * v0.pt() + v0.pz() * v0.pz()); + float decaylength = std::sqrt(std::pow(decayvtxX - vtxX, 2) + + std::pow(decayvtxY - vtxY, 2) + + std::pow(decayvtxZ - vtxZ, 2)); + float v0p = std::sqrt(v0.pt() * v0.pt() + v0.pz() * v0.pz()); float ctauK0s = decaylength * massK0s / v0p; float ctauLambda = decaylength * massLambda / v0p; float ctauAntiLambda = decaylength * massAntiLambda / v0p; - // Cut on dynamic columns for K0s + float alpha = v0.alpha(); + float qtarm = v0.qtarm(); - if (v0.v0cosPA() >= v0setting_cospaK0s && - v0.v0radius() >= v0setting_radiusK0s && - TMath::Abs(posDaughterTrack.tpcNSigmaPi()) <= NSigmaTPCPion && - TMath::Abs(negDaughterTrack.tpcNSigmaPi()) <= NSigmaTPCPion && - ctauK0s < v0setting_ctauK0s && - TMath::Abs(v0.rapidity(0)) <= v0setting_rapidity && - TMath::Abs(massLambda - pdgmassLambda) > v0setting_massrejectionK0s && - TMath::Abs(massAntiLambda - pdgmassLambda) > - v0setting_massrejectionK0s) { + // Cut on dynamic columns for K0s + rCommonHist.fill(HIST("hArmPodoAlphavsQT"), alpha, qtarm); + + if (v0.v0cosPA() >= v0settingCosPAK0s && + v0.v0radius() >= v0settingRadiusK0s && + std::abs(posDaughterTrack.tpcNSigmaPi()) <= nSigmaTPCPion && + std::abs(negDaughterTrack.tpcNSigmaPi()) <= nSigmaTPCPion && + ctauK0s < v0settingcTauK0s && + std::abs(v0.rapidity(0)) <= v0settingRapidity && + std::abs(massLambda - pdgmassLambda) > v0settingMassRejectionK0s && + std::abs(massAntiLambda - pdgmassLambda) > + v0settingMassRejectionK0s && + qtarm > v0settingArmePodoK0s * std::abs(alpha)) { rKzeroShort.fill(HIST("hMassK0sSelected"), massK0s); rKzeroShort.fill(HIST("hDCAV0DaughtersK0s"), v0.dcaV0daughters()); @@ -1234,6 +1374,7 @@ struct lambdak0sflattenicity { rKzeroShort.fill(HIST("h2DdecayRadiusK0s"), v0.v0radius()); rKzeroShort.fill(HIST("hMassK0spT"), massK0s, v0.pt()); rKzeroShort.fill(HIST("hMassK0spTFlat"), massK0s, v0.pt(), flattenicity); + rKzeroShort.fill(HIST("hArmPodoAlphavsQTK0sAfterCut"), alpha, qtarm); // Filling the PID of the V0 daughters in the region of the K0s peak if (0.45 < massK0s && massK0s < 0.55) { @@ -1247,13 +1388,13 @@ struct lambdak0sflattenicity { } // Cut on dynamic columns for Lambda - if (v0.v0cosPA() >= v0setting_cospaLambda && - v0.v0radius() >= v0setting_radiusLambda && - TMath::Abs(posDaughterTrack.tpcNSigmaPr()) <= NSigmaTPCProton && - TMath::Abs(negDaughterTrack.tpcNSigmaPi()) <= NSigmaTPCPion && - ctauLambda < v0setting_ctauLambda && - TMath::Abs(v0.rapidity(1)) <= v0setting_rapidity && - TMath::Abs(massK0s - pdgmassK0s) > v0setting_massrejectionLambda) { + if (v0.v0cosPA() >= v0settingCosPALambda && + v0.v0radius() >= v0settingRadiusLambda && + std::abs(posDaughterTrack.tpcNSigmaPr()) <= nSigmaTPCProton && + std::abs(negDaughterTrack.tpcNSigmaPi()) <= nSigmaTPCPion && + ctauLambda < v0settingcTauLambda && + std::abs(v0.rapidity(1)) <= v0settingRapidity && + std::abs(massK0s - pdgmassK0s) > v0settingMassRejectionLambda) { rLambda.fill(HIST("hMassLambdaSelected"), massLambda); rLambda.fill(HIST("hDCAV0DaughtersLambda"), v0.dcaV0daughters()); @@ -1276,13 +1417,13 @@ struct lambdak0sflattenicity { } // Cut on dynamic columns for AntiLambda - if (v0.v0cosPA() >= v0setting_cospaLambda && - v0.v0radius() >= v0setting_radiusLambda && - TMath::Abs(posDaughterTrack.tpcNSigmaPi()) <= NSigmaTPCPion && - TMath::Abs(negDaughterTrack.tpcNSigmaPr()) <= NSigmaTPCProton && - ctauAntiLambda < v0setting_ctauLambda && - TMath::Abs(v0.rapidity(2)) <= v0setting_rapidity && - TMath::Abs(massK0s - pdgmassK0s) > v0setting_massrejectionLambda) { + if (v0.v0cosPA() >= v0settingCosPALambda && + v0.v0radius() >= v0settingRadiusLambda && + std::abs(posDaughterTrack.tpcNSigmaPi()) <= nSigmaTPCPion && + std::abs(negDaughterTrack.tpcNSigmaPr()) <= nSigmaTPCProton && + ctauAntiLambda < v0settingcTauLambda && + std::abs(v0.rapidity(2)) <= v0settingRapidity && + std::abs(massK0s - pdgmassK0s) > v0settingMassRejectionLambda) { rAntiLambda.fill(HIST("hMassAntiLambdaSelected"), massAntiLambda); rAntiLambda.fill(HIST("hDCAV0DaughtersAntiLambda"), @@ -1317,12 +1458,11 @@ struct lambdak0sflattenicity { Preslice perMCCol = aod::mcparticle::mcCollisionId; SliceCache cache1; - void processRecMC( + void processRecMCLambdaK0s( soa::Join const& collisions, soa::Filtered> const& V0s, aod::McCollisions const&, TrackCandidatesMC const& tracks, - soa::Join const& /*bcs*/, - aod::MFTTracks const& /*mfttracks*/, aod::FT0s const& /*ft0s*/, + soa::Join const& /*bcs*/, aod::FT0s const& /*ft0s*/, aod::FV0As const& /*fv0s*/, aod::McParticles const& mcParticles) { for (const auto& collision : collisions) { @@ -1336,7 +1476,7 @@ struct lambdak0sflattenicity { auto vtxY = collision.posY(); auto vtxX = collision.posX(); - float flattenicity = EstimateFlattenicity(collision, tracks); + float flattenicity = estimateFlattenicity(collision, tracks); rEventSelection.fill(HIST("hVertexZ"), vtxZ); rEventSelection.fill(HIST("hFlattenicityDistribution"), flattenicity); @@ -1349,8 +1489,8 @@ struct lambdak0sflattenicity { const auto& posDaughterTrack = v0.posTrack_as(); const auto& negDaughterTrack = v0.negTrack_as(); - if (TMath::Abs(posDaughterTrack.eta()) > cfgTrkEtaCut || - TMath::Abs(negDaughterTrack.eta()) > cfgTrkEtaCut || + if (std::abs(posDaughterTrack.eta()) > cfgTrkEtaCut || + std::abs(negDaughterTrack.eta()) > cfgTrkEtaCut || negDaughterTrack.pt() < cfgTrkLowPtCut || posDaughterTrack.pt() < cfgTrkLowPtCut) { continue; @@ -1372,26 +1512,32 @@ struct lambdak0sflattenicity { float decayvtxY = v0.y(); float decayvtxZ = v0.z(); - float decaylength = TMath::Sqrt(TMath::Power(decayvtxX - vtxX, 2) + - TMath::Power(decayvtxY - vtxY, 2) + - TMath::Power(decayvtxZ - vtxZ, 2)); - float v0p = TMath::Sqrt(v0.pt() * v0.pt() + v0.pz() * v0.pz()); + float decaylength = std::sqrt(std::pow(decayvtxX - vtxX, 2) + + std::pow(decayvtxY - vtxY, 2) + + std::pow(decayvtxZ - vtxZ, 2)); + float v0p = std::sqrt(v0.pt() * v0.pt() + v0.pz() * v0.pz()); float ctauK0s = decaylength * massK0s / v0p; float ctauLambda = decaylength * massLambda / v0p; float ctauAntiLambda = decaylength * massAntiLambda / v0p; + + float alpha = v0.alpha(); + float qtarm = v0.qtarm(); + rCommonHist.fill(HIST("hArmPodoAlphavsQT"), alpha, qtarm); + auto v0mcParticle = v0.mcParticle(); // Cut on dynamic columns for K0s - if (v0mcParticle.pdgCode() == 310 && v0.v0cosPA() >= v0setting_cospaK0s && - v0.v0radius() >= v0setting_radiusK0s && - TMath::Abs(posDaughterTrack.tpcNSigmaPi()) <= NSigmaTPCPion && - TMath::Abs(negDaughterTrack.tpcNSigmaPi()) <= NSigmaTPCPion && - ctauK0s < v0setting_ctauK0s && - TMath::Abs(v0.rapidity(0)) <= v0setting_rapidity && - TMath::Abs(massLambda - pdgmassLambda) > v0setting_massrejectionK0s && - TMath::Abs(massAntiLambda - pdgmassLambda) > - v0setting_massrejectionK0s) { + if (v0mcParticle.pdgCode() == PDG_t::kK0Short && v0.v0cosPA() >= v0settingCosPAK0s && + v0.v0radius() >= v0settingRadiusK0s && + std::abs(posDaughterTrack.tpcNSigmaPi()) <= nSigmaTPCPion && + std::abs(negDaughterTrack.tpcNSigmaPi()) <= nSigmaTPCPion && + ctauK0s < v0settingcTauK0s && + std::abs(v0.rapidity(0)) <= v0settingRapidity && + std::abs(massLambda - pdgmassLambda) > v0settingMassRejectionK0s && + std::abs(massAntiLambda - pdgmassLambda) > + v0settingMassRejectionK0s && + qtarm > v0settingArmePodoK0s * std::abs(alpha)) { rKzeroShort.fill(HIST("hMassK0sSelected"), massK0s); rKzeroShort.fill(HIST("hDCAV0DaughtersK0s"), v0.dcaV0daughters()); @@ -1401,6 +1547,7 @@ struct lambdak0sflattenicity { rKzeroShort.fill(HIST("h2DdecayRadiusK0s"), v0.v0radius()); rKzeroShort.fill(HIST("hMassK0spT"), massK0s, v0.pt()); rKzeroShort.fill(HIST("hMassK0spTFlat"), massK0s, v0.pt(), flattenicity); + rKzeroShort.fill(HIST("hArmPodoAlphavsQTK0sAfterCut"), alpha, qtarm); // Filling the PID of the V0 daughters in the region of the K0s peak if (0.45 < massK0s && massK0s < 0.55) { @@ -1414,14 +1561,14 @@ struct lambdak0sflattenicity { } // Cut on dynamic columns for Lambda - if (v0mcParticle.pdgCode() == 3122 && - v0.v0cosPA() >= v0setting_cospaLambda && - v0.v0radius() >= v0setting_radiusLambda && - TMath::Abs(posDaughterTrack.tpcNSigmaPr()) <= NSigmaTPCProton && - TMath::Abs(negDaughterTrack.tpcNSigmaPi()) <= NSigmaTPCPion && - ctauLambda < v0setting_ctauLambda && - TMath::Abs(v0.rapidity(1)) <= v0setting_rapidity && - TMath::Abs(massK0s - pdgmassK0s) > v0setting_massrejectionLambda) { + if (v0mcParticle.pdgCode() == PDG_t::kLambda0 && + v0.v0cosPA() >= v0settingCosPALambda && + v0.v0radius() >= v0settingRadiusLambda && + std::abs(posDaughterTrack.tpcNSigmaPr()) <= nSigmaTPCProton && + std::abs(negDaughterTrack.tpcNSigmaPi()) <= nSigmaTPCPion && + ctauLambda < v0settingcTauLambda && + std::abs(v0.rapidity(1)) <= v0settingRapidity && + std::abs(massK0s - pdgmassK0s) > v0settingMassRejectionLambda) { rLambda.fill(HIST("hMassLambdaSelected"), massLambda); rLambda.fill(HIST("hDCAV0DaughtersLambda"), v0.dcaV0daughters()); @@ -1444,14 +1591,14 @@ struct lambdak0sflattenicity { } // Cut on dynamic columns for AntiLambda - if (v0mcParticle.pdgCode() == -3122 && - v0.v0cosPA() >= v0setting_cospaLambda && - v0.v0radius() >= v0setting_radiusLambda && - TMath::Abs(posDaughterTrack.tpcNSigmaPi()) <= NSigmaTPCPion && - TMath::Abs(negDaughterTrack.tpcNSigmaPr()) <= NSigmaTPCProton && - ctauAntiLambda < v0setting_ctauLambda && - TMath::Abs(v0.rapidity(2)) <= v0setting_rapidity && - TMath::Abs(massK0s - pdgmassK0s) > v0setting_massrejectionLambda) { + if (v0mcParticle.pdgCode() == PDG_t::kLambda0Bar && + v0.v0cosPA() >= v0settingCosPALambda && + v0.v0radius() >= v0settingRadiusLambda && + std::abs(posDaughterTrack.tpcNSigmaPi()) <= nSigmaTPCPion && + std::abs(negDaughterTrack.tpcNSigmaPr()) <= nSigmaTPCProton && + ctauAntiLambda < v0settingcTauLambda && + std::abs(v0.rapidity(2)) <= v0settingRapidity && + std::abs(massK0s - pdgmassK0s) > v0settingMassRejectionLambda) { rAntiLambda.fill(HIST("hMassAntiLambdaSelected"), massAntiLambda); rAntiLambda.fill(HIST("hDCAV0DaughtersAntiLambda"), @@ -1477,11 +1624,11 @@ struct lambdak0sflattenicity { } const auto particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache1); - float flattenicityMCGen = EstimateFlattenicityFV0MC(particlesInCollision); + float flattenicityMCGen = estimateFlattenicityFV0MC(particlesInCollision); rEventSelection.fill(HIST("hFlattenicityDistributionMCGen_Rec"), flattenicityMCGen); rEventSelection.fill(HIST("hFlattenicity_Corr_Gen_vs_Rec"), flattenicityMCGen, flattenicity); - for (auto& mcParticle : particlesInCollision) { + for (const auto& mcParticle : particlesInCollision) { if (!mcParticle.isPhysicalPrimary()) { continue; } @@ -1490,13 +1637,13 @@ struct lambdak0sflattenicity { continue; } - if (mcParticle.pdgCode() == 310) { + if (mcParticle.pdgCode() == PDG_t::kK0Short) { rKzeroShort.fill(HIST("Generated_MCRecoCollCheck_INEL_K0Short"), mcParticle.pt(), flattenicity); // K0s } - if (mcParticle.pdgCode() == 3122) { + if (mcParticle.pdgCode() == PDG_t::kLambda0) { rLambda.fill(HIST("Generated_MCRecoCollCheck_INEL_Lambda"), mcParticle.pt(), flattenicity); // Lambda } - if (mcParticle.pdgCode() == -3122) { + if (mcParticle.pdgCode() == PDG_t::kLambda0Bar) { rAntiLambda.fill(HIST("Generated_MCRecoCollCheck_INEL_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda } } @@ -1505,20 +1652,32 @@ struct lambdak0sflattenicity { // Filter posZFilterMC = (nabs(o2::aod::mccollision::posZ) < cutzvertex); void processGenMC( - o2::aod::McCollision const& mcCollision, - const soa::SmallGroups>& collisions, - o2::aod::McParticles const& mcParticles) + o2::aod::McCollision const& mcCollision, const soa::SmallGroups>& collisions, TrackCandidatesMC const& tracks, aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0s*/, o2::aod::McParticles const& mcParticles) { - float flattenicity = EstimateFlattenicityFV0MC(mcParticles); - rEventSelection.fill(HIST("hFlattenicityDistributionMCGen"), flattenicity); + + float flattenicity; + if (flattenicityforLossCorrRec) { + float flattenicityRec = 999.0; + for (const auto& collision : collisions) { + flattenicityRec = estimateFlattenicity(collision, tracks); + // printf("FoundFlattenicity, Gen=%f, Rec=%f \n", flattenicity, flattenicityRec); + } + rEventSelection.fill(HIST("hFlattenicityDistributionRecMCGen"), flattenicityRec); + flattenicity = flattenicityRec; + } else { + float flattenicityGen = estimateFlattenicityFV0MC(mcParticles); + rEventSelection.fill(HIST("hFlattenicityDistributionMCGen"), flattenicityGen); + flattenicity = flattenicityGen; + } + //==================================== //===== Event Loss Denominator ======= //==================================== rEventSelection.fill(HIST("hNEventsMCGen"), 0.5); - if (TMath::Abs(mcCollision.posZ()) > cutzvertex) { + if (std::abs(mcCollision.posZ()) > cutzvertex) { return; } rEventSelection.fill(HIST("hNEventsMCGen"), 1.5); @@ -1536,7 +1695,7 @@ struct lambdak0sflattenicity { //===== Signal Loss Denominator ======= //===================================== - for (auto& mcParticle : mcParticles) { + for (const auto& mcParticle : mcParticles) { if (!mcParticle.isPhysicalPrimary()) { continue; @@ -1545,29 +1704,35 @@ struct lambdak0sflattenicity { continue; } - if (mcParticle.pdgCode() == 310) { + if (mcParticle.pdgCode() == PDG_t::kK0Short) { rKzeroShort.fill(HIST("pGen_MCGenColl_INEL_K0Short"), mcParticle.pt(), flattenicity); // K0s if (isINELgt0true) { rKzeroShort.fill(HIST("pGen_MCGenColl_INELgt0_K0Short"), mcParticle.pt(), flattenicity); // K0s } } - if (mcParticle.pdgCode() == 3122) { + if (mcParticle.pdgCode() == PDG_t::kLambda0) { rLambda.fill(HIST("pGen_MCGenColl_INEL_Lambda"), mcParticle.pt(), flattenicity); // Lambda if (isINELgt0true) { rLambda.fill(HIST("pGen_MCGenColl_INELgt0_Lambda"), mcParticle.pt(), flattenicity); // Lambda } } - if (mcParticle.pdgCode() == -3122) { + if (mcParticle.pdgCode() == PDG_t::kLambda0Bar) { rAntiLambda.fill(HIST("pGen_MCGenColl_INEL_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda if (isINELgt0true) { rAntiLambda.fill(HIST("pGen_MCGenColl_INELgt0_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda } } + if (std::abs(mcParticle.pdgCode()) == PDG_t::kXiPlusBar) { + rXi.fill(HIST("pGen_MCGenColl_INEL_Xi"), mcParticle.pt(), flattenicity); // Xi + if (isINELgt0true) { + rXi.fill(HIST("pGen_MCGenColl_INELgt0_Xi"), mcParticle.pt(), flattenicity); // Xi + } + } } - int recoCollIndex_INEL = 0; - int recoCollIndex_INELgt0 = 0; - for (auto& collision : collisions) { // loop on reconstructed collisions + int recoCollIndexINEL = 0; + int recoCollIndexINELgt0 = 0; + for (const auto& collision : collisions) { // loop on reconstructed collisions //===================================== //====== Event Split Numerator ======== @@ -1577,24 +1742,24 @@ struct lambdak0sflattenicity { if (applyEvSel && !isEventSelected(collision)) { continue; } - rEventSelection.fill(HIST("hEventsSelected"), 10.5); + rEventSelection.fill(HIST("hEventsSelected"), nbin - 0.5); rEventSelection.fill(HIST("hNEventsMCReco"), 1.5); rEventSelection.fill(HIST("hFlat_RecoColl_MC"), flattenicity); - recoCollIndex_INEL++; + recoCollIndexINEL++; if (collision.isInelGt0() && isINELgt0true) { rEventSelection.fill(HIST("hNEventsMCReco"), 2.5); rEventSelection.fill(HIST("hFlat_RecoColl_MC_INELgt0"), flattenicity); - recoCollIndex_INELgt0++; + recoCollIndexINELgt0++; } //===================================== //======== Sgn Split Numerator ======== //===================================== - for (auto& mcParticle : mcParticles) { + for (const auto& mcParticle : mcParticles) { if (!mcParticle.isPhysicalPrimary()) { continue; @@ -1604,29 +1769,35 @@ struct lambdak0sflattenicity { continue; } - if (mcParticle.pdgCode() == 310) { + if (mcParticle.pdgCode() == PDG_t::kK0Short) { rKzeroShort.fill(HIST("Generated_MCRecoColl_INEL_K0Short"), mcParticle.pt(), flattenicity); // K0s - if (recoCollIndex_INELgt0 > 0) { + if (recoCollIndexINELgt0 > 0) { rKzeroShort.fill(HIST("Generated_MCRecoColl_INELgt0_K0Short"), mcParticle.pt(), flattenicity); // K0s } } - if (mcParticle.pdgCode() == 3122) { + if (mcParticle.pdgCode() == PDG_t::kLambda0) { rLambda.fill(HIST("Generated_MCRecoColl_INEL_Lambda"), mcParticle.pt(), flattenicity); // Lambda - if (recoCollIndex_INELgt0 > 0) { + if (recoCollIndexINELgt0 > 0) { rLambda.fill(HIST("Generated_MCRecoColl_INELgt0_Lambda"), mcParticle.pt(), flattenicity); // Lambda } } - if (mcParticle.pdgCode() == -3122) { + if (mcParticle.pdgCode() == PDG_t::kLambda0Bar) { rAntiLambda.fill(HIST("Generated_MCRecoColl_INEL_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda - if (recoCollIndex_INELgt0 > 0) { + if (recoCollIndexINELgt0 > 0) { rAntiLambda.fill(HIST("Generated_MCRecoColl_INELgt0_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda } } + if (std::abs(mcParticle.pdgCode()) == PDG_t::kXiPlusBar) { + rXi.fill(HIST("Generated_MCRecoColl_INEL_Xi"), mcParticle.pt(), flattenicity); // Xi + if (recoCollIndexINELgt0 > 0) { + rXi.fill(HIST("Generated_MCRecoColl_INELgt0_Xi"), mcParticle.pt(), flattenicity); // Xi + } + } } } // From now on keep only mc collisions with at least one reconstructed collision (INEL) - if (recoCollIndex_INEL < 1) { + if (recoCollIndexINEL < 1) { return; } @@ -1637,7 +1808,7 @@ struct lambdak0sflattenicity { rEventSelection.fill(HIST("hNEventsMCGenReco"), 0.5); rEventSelection.fill(HIST("hFlat_GenRecoColl_MC"), flattenicity); - if (recoCollIndex_INELgt0 > 0) { + if (recoCollIndexINELgt0 > 0) { rEventSelection.fill(HIST("hNEventsMCGenReco"), 1.5); rEventSelection.fill(HIST("hFlat_GenRecoColl_MC_INELgt0"), flattenicity); } @@ -1646,7 +1817,7 @@ struct lambdak0sflattenicity { //===== Signal Loss Numerator ========= //===================================== - for (auto& mcParticle : mcParticles) { + for (const auto& mcParticle : mcParticles) { if (!mcParticle.isPhysicalPrimary()) { continue; @@ -1656,36 +1827,186 @@ struct lambdak0sflattenicity { continue; } - if (mcParticle.pdgCode() == 310) { + if (mcParticle.pdgCode() == PDG_t::kK0Short) { rKzeroShort.fill(HIST("pGen_MCGenRecoColl_INEL_K0Short"), mcParticle.pt(), flattenicity); // K0s - if (recoCollIndex_INELgt0 > 0) { + if (recoCollIndexINELgt0 > 0) { rKzeroShort.fill(HIST("pGen_MCGenRecoColl_INELgt0_K0Short"), mcParticle.pt(), flattenicity); // K0s } } - if (mcParticle.pdgCode() == 3122) { + if (mcParticle.pdgCode() == PDG_t::kLambda0) { rLambda.fill(HIST("pGen_MCGenRecoColl_INEL_Lambda"), mcParticle.pt(), flattenicity); // Lambda - if (recoCollIndex_INELgt0 > 0) { + if (recoCollIndexINELgt0 > 0) { rLambda.fill(HIST("pGen_MCGenRecoColl_INELgt0_Lambda"), mcParticle.pt(), flattenicity); // Lambda } } - if (mcParticle.pdgCode() == -3122) { + if (mcParticle.pdgCode() == PDG_t::kLambda0Bar) { rAntiLambda.fill(HIST("pGen_MCGenRecoColl_INEL_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda - if (recoCollIndex_INELgt0 > 0) { + if (recoCollIndexINELgt0 > 0) { rAntiLambda.fill(HIST("pGen_MCGenRecoColl_INELgt0_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda } } + if (std::abs(mcParticle.pdgCode()) == PDG_t::kXiPlusBar) { + rXi.fill(HIST("pGen_MCGenRecoColl_INEL_Xi"), mcParticle.pt(), flattenicity); // Xi + if (recoCollIndexINELgt0 > 0) { + rXi.fill(HIST("pGen_MCGenRecoColl_INELgt0_Xi"), mcParticle.pt(), flattenicity); // Xi + } + } + } + } + TRandom2* fRand = new TRandom2(); + // Cascade Analysis Starts here + using DauTracks = soa::Join; + using LabeledCascades = soa::Join; + // float ctauxiPDG = 4.91; // from PDG + // float ctauomegaPDG = 2.461; // from PDG + + void processDataRun3Cascade(soa::Join::iterator const& collision, + aod::CascDataExt const& Cascades, + aod::V0Datas const&, DauTracks const& tracks, + soa::Join const& /*bcs*/, aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0s*/) + { + if (applyEvSel && + !(isEventSelected(collision))) { // Checking if the event passes the + // selection criteria + return; + } + + auto vtxZ = collision.posZ(); + auto vtxY = collision.posY(); + auto vtxX = collision.posX(); + + float flattenicity = estimateFlattenicity(collision, tracks); + + rEventSelection.fill(HIST("hVertexZ"), vtxZ); + rEventSelection.fill(HIST("hFlattenicityDistribution"), flattenicity); + + for (const auto& casc : Cascades) { + + auto posDaughterTrack = casc.posTrack_as(); + auto negDaughterTrack = casc.negTrack_as(); + auto bacDaughterTrack = casc.bachelor_as(); + + float cascPos = std::hypot(casc.x() - vtxX, casc.y() - vtxY, casc.z() - vtxZ); + float cascTotMom = std::hypot(casc.px(), casc.py(), casc.pz()); + float ctauXi = pdgmassXi * cascPos / (cascTotMom + 1e-13); + // float ctauOmega =pdgmassOmega * cascPos / (cascTotMom + 1e-13); + float dcav0pv = casc.dcav0topv(vtxX, vtxY, vtxZ); + float cosPAcasc = casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()); + float cosPAv0 = casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()); + float massXi = casc.mXi(); + rXi.fill(HIST("hMassXi"), massXi); + // Cascade + if (posDaughterTrack.tpcNSigmaPi() < nSigmaTPCPion && negDaughterTrack.tpcNSigmaPi() < nSigmaTPCPion && bacDaughterTrack.tpcNSigmaPi() < nSigmaTPCPion && + posDaughterTrack.tpcNSigmaKa() < nSigmaTPCKaon && negDaughterTrack.tpcNSigmaKa() < nSigmaTPCKaon && bacDaughterTrack.tpcNSigmaKa() < nSigmaTPCKaon && + posDaughterTrack.tpcNSigmaPr() < nSigmaTPCProton && negDaughterTrack.tpcNSigmaPr() < nSigmaTPCProton && bacDaughterTrack.tpcNSigmaPr() < nSigmaTPCProton && + posDaughterTrack.tpcNClsCrossedRows() > nTPCcrossedRows && negDaughterTrack.tpcNClsCrossedRows() > nTPCcrossedRows && bacDaughterTrack.tpcNClsCrossedRows() > nTPCcrossedRows && + std::abs(posDaughterTrack.eta()) < cfgTrkEtaCut && std::abs(negDaughterTrack.eta()) < cfgTrkEtaCut && std::abs(bacDaughterTrack.eta()) < cfgTrkEtaCut && + casc.dcapostopv() > v0settingDCApostopv && casc.dcanegtopv() > v0settingDCAnegtopv && casc.dcabachtopv() > v0settingDCAbactopv && casc.dcaV0daughters() < v0settingDCAv0dau && dcav0pv > cascsettingDCAv0toPV && + casc.dcacascdaughters() < cascsettingDCAv0bach && casc.bachBaryonDCAxyToPV() < cascsettingDCAxybaryonbach && cosPAcasc > cascsettingCosPAcascPV && cosPAv0 > cascsettingCosPAv0PV && + casc.cascradius() > cascsettingcascradius && casc.v0radius() > cascsettingv0radius && + std::abs(casc.yXi()) < cascsettingRapidity && ctauXi < 4.91 * cascsettingproplifetime && + std::abs(casc.mLambda() - pdgmassLambda) < cascsettingMassRejectionLambdaXi && std::abs(casc.mOmega() - pdgmassOmega) > cascsettingMassRejectioOmegaXi) { + + rXi.fill(HIST("hMassXiSelected"), massXi); + rXi.fill(HIST("hDCAV0DaughtersXi"), casc.dcaV0daughters()); + rXi.fill(HIST("hV0CosPAXi"), cosPAv0); + rXi.fill(HIST("hrapidityXi"), casc.rapidity(1)); + rXi.fill(HIST("hctauXi"), ctauXi); + rXi.fill(HIST("h2DdecayRadiusXi"), casc.v0radius()); + rXi.fill(HIST("hMassXipT"), massXi, casc.pt()); + rXi.fill(HIST("hMassXipTFlat"), massXi, casc.pt(), flattenicity); + } + } + } + Preslice> perColCasc = aod::track::collisionId; + SliceCache cacheCasc; + + void processRecMCRun3Cascade(soa::Join const& collisions, + soa::Join const& Cascades, + aod::V0Datas const&, soa::Join const& tracks, + soa::Join const& /*bcs*/, aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0s*/, aod::McCollisions const&, aod::McParticles const& mcParticles) + { + for (const auto& collision : collisions) { + if (applyEvSel && + !(isEventSelected(collision))) { // Checking if the event passes the + // selection criteria + return; + } + + auto vtxZ = collision.posZ(); + auto vtxY = collision.posY(); + auto vtxX = collision.posX(); + + float flattenicity = estimateFlattenicity(collision, tracks); + + rEventSelection.fill(HIST("hVertexZ"), vtxZ); + rEventSelection.fill(HIST("hFlattenicityDistribution"), flattenicity); + + auto cascsThisCollision = Cascades.sliceBy(perColCasc, collision.globalIndex()); + const auto& mcCollision = collision.mcCollision_as(); + + for (const auto& casc : cascsThisCollision) { + + auto posDaughterTrack = casc.posTrack_as(); + auto negDaughterTrack = casc.negTrack_as(); + auto bacDaughterTrack = casc.bachelor_as(); + + float cascPos = std::hypot(casc.x() - vtxX, casc.y() - vtxY, casc.z() - vtxZ); + float cascTotMom = std::hypot(casc.px(), casc.py(), casc.pz()); + float ctauXi = pdgmassXi * cascPos / (cascTotMom + 1e-13); + // float ctauOmega =pdgmassOmega * cascPos / (cascTotMom + 1e-13); + float dcav0pv = casc.dcav0topv(vtxX, vtxY, vtxZ); + float cosPAcasc = casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()); + float cosPAv0 = casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()); + float massXi = casc.mXi(); + rXi.fill(HIST("hMassXi"), massXi); + // Cascade + if (posDaughterTrack.tpcNSigmaPi() < nSigmaTPCPion && negDaughterTrack.tpcNSigmaPi() < nSigmaTPCPion && bacDaughterTrack.tpcNSigmaPi() < nSigmaTPCPion && + posDaughterTrack.tpcNSigmaKa() < nSigmaTPCKaon && negDaughterTrack.tpcNSigmaKa() < nSigmaTPCKaon && bacDaughterTrack.tpcNSigmaKa() < nSigmaTPCKaon && + posDaughterTrack.tpcNSigmaPr() < nSigmaTPCProton && negDaughterTrack.tpcNSigmaPr() < nSigmaTPCProton && bacDaughterTrack.tpcNSigmaPr() < nSigmaTPCProton && + posDaughterTrack.tpcNClsCrossedRows() > nTPCcrossedRows && negDaughterTrack.tpcNClsCrossedRows() > nTPCcrossedRows && bacDaughterTrack.tpcNClsCrossedRows() > nTPCcrossedRows && + std::abs(posDaughterTrack.eta()) < cfgTrkEtaCut && std::abs(negDaughterTrack.eta()) < cfgTrkEtaCut && std::abs(bacDaughterTrack.eta()) < cfgTrkEtaCut && + casc.dcapostopv() > v0settingDCApostopv && casc.dcanegtopv() > v0settingDCAnegtopv && casc.dcabachtopv() > v0settingDCAbactopv && casc.dcaV0daughters() < v0settingDCAv0dau && dcav0pv > cascsettingDCAv0toPV && + casc.dcacascdaughters() < cascsettingDCAv0bach && casc.bachBaryonDCAxyToPV() < cascsettingDCAxybaryonbach && cosPAcasc > cascsettingCosPAcascPV && cosPAv0 > cascsettingCosPAv0PV && + casc.cascradius() > cascsettingcascradius && casc.v0radius() > cascsettingv0radius && + std::abs(casc.yXi()) < cascsettingRapidity && ctauXi < 4.91 * cascsettingproplifetime && + std::abs(casc.mLambda() - pdgmassLambda) < cascsettingMassRejectionLambdaXi && std::abs(casc.mOmega() - pdgmassOmega) > cascsettingMassRejectioOmegaXi) { + + rXi.fill(HIST("hMassXiSelected"), massXi); + rXi.fill(HIST("hDCAV0DaughtersXi"), casc.dcaV0daughters()); + rXi.fill(HIST("hV0CosPAXi"), cosPAv0); + rXi.fill(HIST("hrapidityXi"), casc.rapidity(1)); + rXi.fill(HIST("hctauXi"), ctauXi); + rXi.fill(HIST("h2DdecayRadiusXi"), casc.v0radius()); + rXi.fill(HIST("hMassXipT"), massXi, casc.pt()); + rXi.fill(HIST("hMassXipTFlat"), massXi, casc.pt(), flattenicity); + } + } + const auto particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cacheCasc); + float flattenicityMCGen = estimateFlattenicityFV0MC(particlesInCollision); + rEventSelection.fill(HIST("hFlattenicityDistributionMCGen_Rec"), flattenicityMCGen); + rEventSelection.fill(HIST("hFlattenicity_Corr_Gen_vs_Rec"), flattenicityMCGen, flattenicity); + + for (const auto& mcParticle : particlesInCollision) { + if (mcParticle.isPhysicalPrimary() && std::abs(mcParticle.y()) < 0.5f && std::abs(mcParticle.pdgCode()) == PDG_t::kXiPlusBar) { + rXi.fill(HIST("Generated_MCRecoCollCheck_INEL_Xi"), mcParticle.pt(), flattenicity); // K0s + } + } } } - PROCESS_SWITCH(lambdak0sflattenicity, processDataRun3, "Process Run 3 Data", - false); - PROCESS_SWITCH(lambdak0sflattenicity, processRecMC, - "Process Run 3 mc, reconstructed", true); - PROCESS_SWITCH(lambdak0sflattenicity, processGenMC, - "Process Run 3 mc, generated", true); + PROCESS_SWITCH(Lambdak0sflattenicity, processDataRun3LambdaK0s, "Process Run 3 Data LambdaK0s", false); + PROCESS_SWITCH(Lambdak0sflattenicity, processRecMCLambdaK0s, "Process Run 3 MC reconstructed LambdaK0s", false); + PROCESS_SWITCH(Lambdak0sflattenicity, processGenMC, "Process Run 3 MC generated", false); + PROCESS_SWITCH(Lambdak0sflattenicity, processDataRun3Cascade, "Process Run 3 Data Cascade", true); + PROCESS_SWITCH(Lambdak0sflattenicity, processRecMCRun3Cascade, "Process Run 3 mc Rec Cascade", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Strangeness/lambdalambda.cxx b/PWGLF/Tasks/Strangeness/lambdalambda.cxx index e974b812990..bf8579f105d 100644 --- a/PWGLF/Tasks/Strangeness/lambdalambda.cxx +++ b/PWGLF/Tasks/Strangeness/lambdalambda.cxx @@ -86,6 +86,7 @@ struct lambdalambda { Configurable cfgCentSel{"cfgCentSel", 100., "Centrality selection"}; Configurable cfgCentEst{"cfgCentEst", 1, "Centrality estimator, 1: FT0C, 2: FT0M"}; + Configurable cfgEvtSel{"cfgEvtSel", true, "event selection flag"}; Configurable cfgPVSel{"cfgPVSel", false, "Additional PV selection flag for syst"}; Configurable cfgPV{"cfgPV", 8.0, "Additional PV selection range for syst"}; Configurable cfgAddEvtSelPileup{"cfgAddEvtSelPileup", false, "flag for additional pileup selection"}; @@ -117,25 +118,33 @@ struct lambdalambda { Configurable cfgV0V0RapMax{"cfgV0V0RapMax", 0.5, "rapidity selection for V0V0"}; Configurable cfgV0V0Sel{"cfgV0V0Sel", false, "application of V0V0 selections"}; - Configurable cfgV0V0Radius{"cfgV0V0Radius", 1.0, "maximum radius of v0v0"}; - Configurable cfgV0V0CPA{"cfgV0V0CPA", 0.6, "minimum CPA of v0v0"}; - Configurable cfgV0V0Distance{"cfgV0V0Distance", 1, "minimum distance of v0v0"}; - Configurable cfgV0V0DCA{"cfgV0V0DCA", 1.0, "maximum DCA of v0v0"}; + + Configurable cfgV0V0RadiusMin{"cfgV0V0RadiusMin", 1.0, "maximum radius of v0v0"}; + Configurable cfgV0V0CPAMin{"cfgV0V0CPAMin", 0.6, "minimum CPA of v0v0"}; + Configurable cfgV0V0DistanceMin{"cfgV0V0DistanceMin", 1, "minimum distance of v0v0"}; + Configurable cfgV0V0DCAMin{"cfgV0V0DCAMin", 1.0, "maximum DCA of v0v0 R"}; + + Configurable cfgV0V0RadiusMax{"cfgV0V0RadiusMax", 1.0, "maximum radius of v0v0"}; + Configurable cfgV0V0CPAMax{"cfgV0V0CPAMax", 0.6, "maximum CPA of v0v0"}; + Configurable cfgV0V0DistanceMax{"cfgV0V0DistanceMax", 1, "maximum distance of v0v0"}; + Configurable cfgV0V0DCAMax{"cfgV0V0DCAMax", 1.0, "maximum DCA of v0v0 R"}; Configurable cfgEffCor{"cfgEffCor", false, "flag to apply efficiency correction"}; Configurable cfgEffCorPath{"cfgEffCorPath", "", "path for pseudo efficiency correction"}; - Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 5, "Number of mixed events per event"}; + Configurable cfgRotBkg{"cfgRotBkg", true, "flag to construct rotational backgrounds"}; + Configurable cfgNRotBkg{"cfgNRotBkg", 10, "the number of rotational backgrounds"}; + Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 10, "Number of mixed events per event"}; ConfigurableAxis massAxis{"massAxis", {110, 2.22, 2.33}, "Invariant mass axis"}; ConfigurableAxis ptAxis{"ptAxis", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "Transverse momentum bins"}; - ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "Centrality interval"}; + ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0, 10, 20, 50, 100}, "Centrality interval"}; ConfigurableAxis vertexAxis{"vertexAxis", {10, -10, 10}, "vertex axis for mixing"}; ConfigurableAxis RadiusAxis{"RadiusAxis", {100, 0, 5}, "radius of v0v0"}; ConfigurableAxis CPAAxis{"CPAAxis", {102, -1.02, 1.02}, "CPA of v0v0"}; ConfigurableAxis DistanceAxis{"DistanceAxis", {100, 0, 10}, "distance of v0v0"}; - ConfigurableAxis DCAAxis{"DCAAxis", {100, 0, 5}, "DCA of v0v0"}; + ConfigurableAxis DCAAxis{"DCAAxis", {100, 0, 2}, "DCA of v0v0R"}; TF1* fMultPVCutLow = nullptr; TF1* fMultPVCutHigh = nullptr; @@ -143,12 +152,19 @@ struct lambdalambda { float centrality; TProfile2D* EffMap = nullptr; + TRandom* rn = new TRandom(); + + bool IsTriggered; + bool IsSelected; + void init(o2::framework::InitContext&) { AxisSpec centQaAxis = {80, 0.0, 80.0}; AxisSpec PVzQaAxis = {300, -15.0, 15.0}; AxisSpec combAxis = {3, -0.5, 2.5}; + histos.add("hEventstat", "", {HistType::kTH1F, {{4, 0, 4}}}); + histos.add("Radius_V0V0_full", "", {HistType::kTHnSparseF, {massAxis, ptAxis, RadiusAxis, combAxis}}); histos.add("CPA_V0V0_full", "", {HistType::kTHnSparseF, {massAxis, ptAxis, CPAAxis, combAxis}}); histos.add("Distance_V0V0_full", "", {HistType::kTHnSparseF, {massAxis, ptAxis, DistanceAxis, combAxis}}); @@ -161,6 +177,12 @@ struct lambdalambda { histos.add("h_InvMass_same", "", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, combAxis}}); histos.add("h_InvMass_mixed", "", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, combAxis}}); + histos.add("h_InvMass_rot", "", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, combAxis}}); + + histos.add("h_InvMass_same_sel", "", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, combAxis}}); + histos.add("h_InvMass_mixed_sel", "", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, combAxis}}); + histos.add("h_InvMass_rot_sel", "", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, combAxis}}); + if (cfgQAv0) { histos.add("QA/CentDist", "", {HistType::kTH1F, {centQaAxis}}); histos.add("QA/PVzDist", "", {HistType::kTH1F, {PVzQaAxis}}); @@ -180,6 +202,7 @@ struct lambdalambda { double massLambda = o2::constants::physics::MassLambda; ROOT::Math::PxPyPzMVector RecoV01, RecoV02, RecoV0V0; + ROOT::Math::PxPyPzMVector RecoV02Rot, RecoV0V0Rot; template bool eventSelected(TCollision collision) @@ -268,13 +291,21 @@ struct lambdalambda { template bool isSelectedV0V0(V01 const& v01, V02 const& v02) { - if (getDCAofV0V0(v01, v02) > cfgV0V0DCA) + if (getDCAofV0V0(v01, v02) > cfgV0V0DCAMax) + return false; + if (getDCAofV0V0(v01, v02) < cfgV0V0DCAMin) + return false; + if (getCPA(v01, v02) > cfgV0V0CPAMax) return false; - if (getCPA(v01, v02) < cfgV0V0CPA) + if (getCPA(v01, v02) < cfgV0V0CPAMin) return false; - if (getDistance(v01, v02) < cfgV0V0Distance) + if (getDistance(v01, v02) > cfgV0V0DistanceMax) return false; - if (getRadius(v01, v02) > cfgV0V0Radius) + if (getDistance(v01, v02) < cfgV0V0DistanceMin) + return false; + if (getRadius(v01, v02) > cfgV0V0RadiusMax) + return false; + if (getRadius(v01, v02) < cfgV0V0RadiusMin) return false; return true; @@ -291,9 +322,8 @@ struct lambdalambda { ROOT::Math::XYZVector posdiff = v02pos - v01pos; ROOT::Math::XYZVector cross = v01mom.Cross(v02mom); - if (std::sqrt(cross.Mag2()) < 1e-6) - return 999.; - return std::abs(posdiff.Dot(cross)) / std::sqrt(cross.Mag2()); + ROOT::Math::XYZVector dcaVec = (posdiff.Dot(cross) / cross.Mag2()) * cross; + return std::sqrt(dcaVec.Mag2()); } template @@ -338,6 +368,9 @@ struct lambdalambda { template void FillHistograms(C1 const& c1, C2 const& c2, V01 const& V01s, V02 const& V02s) { + IsTriggered = false; + IsSelected = false; + for (auto& v01 : V01s) { auto postrack_v01 = v01.template posTrack_as(); auto negtrack_v01 = v01.template negTrack_as(); @@ -412,8 +445,10 @@ struct lambdalambda { } RecoV0V0 = RecoV01 + RecoV02; + if (std::abs(RecoV0V0.Rapidity()) > cfgV0V0RapMax) continue; + IsTriggered = true; histos.fill(HIST("Radius_V0V0_full"), RecoV0V0.M(), RecoV0V0.Pt(), getRadius(v01, v02), V01Tag + V02Tag); histos.fill(HIST("CPA_V0V0_full"), RecoV0V0.M(), RecoV0V0.Pt(), getCPA(v01, v02), V01Tag + V02Tag); @@ -425,16 +460,29 @@ struct lambdalambda { histos.fill(HIST("CPA_V0V0_sel"), RecoV0V0.M(), RecoV0V0.Pt(), getCPA(v01, v02), V01Tag + V02Tag); histos.fill(HIST("Distance_V0V0_sel"), RecoV0V0.M(), RecoV0V0.Pt(), getDistance(v01, v02), V01Tag + V02Tag); histos.fill(HIST("DCA_V0V0_sel"), RecoV0V0.M(), RecoV0V0.Pt(), getDCAofV0V0(v01, v02), V01Tag + V02Tag); + IsSelected = true; } - if (cfgV0V0Sel && !isSelectedV0V0(v01, v02)) - continue; - if (doprocessDataSame) { histos.fill(HIST("h_InvMass_same"), RecoV0V0.M(), RecoV0V0.Pt(), centrality, V01Tag + V02Tag); + if (cfgV0V0Sel && isSelectedV0V0(v01, v02)) { + histos.fill(HIST("h_InvMass_same_sel"), RecoV0V0.M(), RecoV0V0.Pt(), centrality, V01Tag + V02Tag); + if (cfgRotBkg) { + for (int nr = 0; nr < cfgNRotBkg; nr++) { + auto RanPhi = rn->Uniform(o2::constants::math::PI * 5.0 / 6.0, o2::constants::math::PI * 7.0 / 6.0); + RanPhi += RecoV02.Phi(); + RecoV02Rot = ROOT::Math::PxPyPzMVector(RecoV02.Pt() * std::cos(RanPhi), RecoV02.Pt() * std::sin(RanPhi), RecoV02.Pz(), RecoV02.M()); + RecoV0V0Rot = RecoV01 + RecoV02Rot; + histos.fill(HIST("h_InvMass_rot"), RecoV0V0Rot.M(), RecoV0V0Rot.Pt(), centrality, V01Tag + V02Tag); + } + } + } } if (doprocessDataMixed) { histos.fill(HIST("h_InvMass_mixed"), RecoV0V0.M(), RecoV0V0.Pt(), centrality, V01Tag + V02Tag); + if (cfgV0V0Sel && isSelectedV0V0(v01, v02)) { + histos.fill(HIST("h_InvMass_mixed_sel"), RecoV0V0.M(), RecoV0V0.Pt(), centrality, V01Tag + V02Tag); + } } } } @@ -449,9 +497,11 @@ struct lambdalambda { } else if (cfgCentEst == 2) { centrality = collision.centFT0M(); } - if (!eventSelected(collision)) { + histos.fill(HIST("hEventstat"), 0.5); + if (!eventSelected(collision) && cfgEvtSel) { return; } + histos.fill(HIST("hEventstat"), 1.5); histos.fill(HIST("QA/CentDist"), centrality, 1.0); histos.fill(HIST("QA/PVzDist"), collision.posZ(), 1.0); @@ -461,6 +511,11 @@ struct lambdalambda { EffMap = ccdb->getForTimeStamp(cfgEffCorPath.value, bc.timestamp()); } FillHistograms(collision, collision, V0s, V0s); + + if (IsTriggered) + histos.fill(HIST("hEventstat"), 2.5); + if (IsSelected) + histos.fill(HIST("hEventstat"), 3.5); } PROCESS_SWITCH(lambdalambda, processDataSame, "Process Event for same data", true); @@ -483,6 +538,9 @@ struct lambdalambda { continue; if (!eventSelected(c2)) continue; + if (c1.bcId() == c2.bcId()) + continue; + FillHistograms(c1, c2, tracks1, tracks2); } } diff --git a/PWGLF/Tasks/Strangeness/lambdapolarization.cxx b/PWGLF/Tasks/Strangeness/lambdapolarization.cxx index 309c18c43f8..38e17ba338a 100644 --- a/PWGLF/Tasks/Strangeness/lambdapolarization.cxx +++ b/PWGLF/Tasks/Strangeness/lambdapolarization.cxx @@ -42,6 +42,7 @@ #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/PIDResponseITS.h" #include "Common/Core/trackUtilities.h" #include "Common/Core/TrackSelection.h" @@ -57,6 +58,7 @@ #include "CCDB/BasicCCDBManager.h" #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGMM/Mult/DataModel/Index.h" // for Particles2Tracks table using namespace o2; using namespace o2::framework; @@ -95,8 +97,8 @@ struct lambdapolarization { Configurable cfgMinOccupancy{"cfgMinOccupancy", 0, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; Configurable cfgv0radiusMin{"cfgv0radiusMin", 1.2, "minimum decay radius"}; - Configurable cfgDCAPosToPVMin{"cfgDCAPosToPVMin", 0.05, "minimum DCA to PV for positive track"}; - Configurable cfgDCANegToPVMin{"cfgDCANegToPVMin", 0.2, "minimum DCA to PV for negative track"}; + Configurable cfgDCAPrToPVMin{"cfgDCAPrToPVMin", 0.05, "minimum DCA to PV for proton track"}; + Configurable cfgDCAPiToPVMin{"cfgDCAPiToPVMin", 0.1, "minimum DCA to PV for pion track"}; Configurable cfgv0CosPA{"cfgv0CosPA", 0.995, "minimum v0 cosine"}; Configurable cfgDCAV0Dau{"cfgDCAV0Dau", 1.0, "maximum DCA between daughters"}; @@ -123,6 +125,7 @@ struct lambdapolarization { Configurable cfgQvecRefBName{"cfgQvecRefBName", "TPCneg", "The name of detector for reference B"}; Configurable cfgPhiDepStudy{"cfgPhiDepStudy", false, "cfg for phi dependent study"}; + Configurable cfgUSESP{"cfgUSESP", false, "cfg for sp"}; Configurable cfgPhiDepSig{"cfgPhiDepSig", 0.2, "cfg for significance on phi dependent study"}; Configurable cfgShiftCorr{"cfgShiftCorr", false, "additional shift correction"}; @@ -132,11 +135,21 @@ struct lambdapolarization { Configurable cfgEffCor{"cfgEffCor", false, "flag to apply efficiency correction"}; Configurable cfgEffCorPath{"cfgEffCorPath", "", "path for pseudo efficiency correction"}; - Configurable cfgCalcCum{"cfgCalcCum", false, "flag to calculate cumulants"}; + Configurable cfgAccCor{"cfgAccCor", false, "flag to apply acceptance correction"}; + Configurable cfgAccCorPath{"cfgAccCorPath", "", "path for pseudo acceptance correction"}; + + Configurable cfgCalcCum{"cfgCalcCum", false, "flag to calculate cumulants of cossin"}; + Configurable cfgCalcCum1{"cfgCalcCum1", false, "flag to calculate cumulants of coscos"}; + + Configurable cfgRapidityDep{"cfgRapidityDep", false, "flag for rapidity dependent study"}; + Configurable cfgAccAzimuth{"cfgAccAzimuth", false, "flag for azimuth closure study"}; ConfigurableAxis massAxis{"massAxis", {30, 1.1, 1.13}, "Invariant mass axis"}; ConfigurableAxis ptAxis{"ptAxis", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "Transverse momentum bins"}; ConfigurableAxis centAxis{"centAxis", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "Centrality interval"}; + ConfigurableAxis cosAxis{"cosAxis", {110, -1.05, 1.05}, "Cosine axis"}; + ConfigurableAxis RapAxis{"RapAxis", {10, -0.5, 0.5}, "Rapidity axis"}; + ConfigurableAxis qqAxis{"qqAxis", {100, -0.1, 0.1}, "qq axis"}; TF1* fMultPVCutLow = nullptr; TF1* fMultPVCutHigh = nullptr; @@ -159,9 +172,22 @@ struct lambdapolarization { int lastRunNumber = -999; std::vector shiftprofile{}; TProfile2D* EffMap = nullptr; + TProfile2D* AccMap = nullptr; std::string fullCCDBShiftCorrPath; + double GetPhiInRange(double phi) + { + double result = phi; + while (result < 0) { + result = result + 2. * TMath::Pi() / 2; + } + while (result > 2. * TMath::Pi() / 2) { + result = result - 2. * TMath::Pi() / 2; + } + return result; + } + template int GetDetId(const T& name) { @@ -186,7 +212,6 @@ struct lambdapolarization { void init(o2::framework::InitContext&) { - AxisSpec cosAxis = {110, -1.05, 1.05}; AxisSpec centQaAxis = {80, 0.0, 80.0}; AxisSpec PVzQaAxis = {300, -15.0, 15.0}; AxisSpec epAxis = {6, 0.0, 2.0 * constants::math::PI}; @@ -203,9 +228,19 @@ struct lambdapolarization { histos.add(Form("psi%d/h_lambda_cos2", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis, epAxis}}); histos.add(Form("psi%d/h_alambda_cos2", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis, epAxis}}); + if (cfgRapidityDep) { + histos.add(Form("psi%d/h_lambda_cos2_rap", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis, RapAxis}}); + histos.add(Form("psi%d/h_alambda_cos2_rap", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis, RapAxis}}); + } + histos.add(Form("psi%d/h_lambda_cossin", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); histos.add(Form("psi%d/h_alambda_cossin", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + if (cfgAccAzimuth) { + histos.add(Form("psi%d/h_lambda_coscos", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add(Form("psi%d/h_alambda_coscos", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + } + histos.add(Form("psi%d/h_lambda_vncos", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); histos.add(Form("psi%d/h_lambda_vnsin", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); histos.add(Form("psi%d/h_alambda_vncos", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); @@ -250,6 +285,38 @@ struct lambdapolarization { histos.add("psi2/QA/sinPhi_cosPsi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); } + if (cfgCalcCum1) { + histos.add("psi2/QA/cosTheta_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosPsi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosPhi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + + histos.add("psi2/QA/cosPhi_cosPsi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosTheta_cosPhi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosTheta_cosPsi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + + histos.add("psi2/QA/sinPhi_sinPsi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosTheta_sinPhi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosTheta_sinPsi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + + histos.add("psi2/QA/sinPsi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/sinPhi_l", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + + histos.add("psi2/QA/cosTheta_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosPsi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosPhi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + + histos.add("psi2/QA/cosPhi_cosPsi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosTheta_cosPhi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosTheta_cosPsi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + + histos.add("psi2/QA/sinPhi_sinPsi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosTheta_sinPhi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/cosTheta_sinPsi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + + histos.add("psi2/QA/sinPsi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + histos.add("psi2/QA/sinPhi_al", "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); + } + if (cfgQAv0) { histos.add("QA/CentDist", "", {HistType::kTH1F, {centQaAxis}}); histos.add("QA/PVzDist", "", {HistType::kTH1F, {PVzQaAxis}}); @@ -264,6 +331,14 @@ struct lambdapolarization { histos.add(Form("psi%d/QA/EP_RefA", i), "", {HistType::kTH2F, {centQaAxis, epQaAxis}}); histos.add(Form("psi%d/QA/EP_RefB", i), "", {HistType::kTH2F, {centQaAxis, epQaAxis}}); + histos.add(Form("psi%d/QA/qqAxis_Det_RefA_xx", i), "", {HistType::kTH2F, {centQaAxis, qqAxis}}); + histos.add(Form("psi%d/QA/qqAxis_Det_RefB_xx", i), "", {HistType::kTH2F, {centQaAxis, qqAxis}}); + histos.add(Form("psi%d/QA/qqAxis_RefA_RefB_xx", i), "", {HistType::kTH2F, {centQaAxis, qqAxis}}); + + histos.add(Form("psi%d/QA/qqAxis_Det_RefA_yy", i), "", {HistType::kTH2F, {centQaAxis, qqAxis}}); + histos.add(Form("psi%d/QA/qqAxis_Det_RefB_yy", i), "", {HistType::kTH2F, {centQaAxis, qqAxis}}); + histos.add(Form("psi%d/QA/qqAxis_RefA_RefB_yy", i), "", {HistType::kTH2F, {centQaAxis, qqAxis}}); + histos.add(Form("psi%d/QA/EPRes_Det_RefA", i), "", {HistType::kTH2F, {centQaAxis, cosAxis}}); histos.add(Form("psi%d/QA/EPRes_Det_RefB", i), "", {HistType::kTH2F, {centQaAxis, cosAxis}}); histos.add(Form("psi%d/QA/EPRes_RefA_RefB", i), "", {HistType::kTH2F, {centQaAxis, cosAxis}}); @@ -278,6 +353,16 @@ struct lambdapolarization { } } + if (doprocessMC_ITSTPC) { + histos.add("hImpactParameter", "Impact parameter", kTH1F, {{200, 0.0f, 20.0f}}); + histos.add("hEventPlaneAngle", "hEventPlaneAngle", kTH1F, {{200, -2.0f * TMath::Pi(), 2.0f * TMath::Pi()}}); + histos.add("hEventPlaneAngleRec", "hEventPlaneAngleRec", kTH1F, {{200, -2.0f * TMath::Pi(), 2.0f * TMath::Pi()}}); + histos.add("hNchVsImpactParameter", "hNchVsImpactParameter", kTH2F, {{200, 0.0f, 20.0f}, {500, -0.5f, 5000.5f}}); + histos.add("hSparseMCGenWeight", "hSparseMCGenWeight", HistType::kTHnSparseF, {centAxis, {36, 0.0f, TMath::Pi()}, {50, 0.0f, 1}, ptAxis, {8, -0.8, 0.8}}); + histos.add("hSparseMCRecWeight", "hSparseMCRecWeight", HistType::kTHnSparseF, {centAxis, {36, 0.0f, TMath::Pi()}, {50, 0.0f, 1}, ptAxis, {8, -0.8, 0.8}}); + histos.add("hSparseMCRecAllTrackWeight", "hSparseMCRecAllTrackWeight", HistType::kTHnSparseF, {centAxis, {36, 0.0, TMath::Pi()}, {50, 0.0f, 1}, ptAxis, {8, -0.8, 0.8}}); + } + if (cfgShiftCorrDef) { for (auto i = 2; i < cfgnMods + 2; i++) { histos.add(Form("psi%d/ShiftFIT", i), "", kTProfile3D, {centQaAxis, basisAxis, shiftAxis}); @@ -352,14 +437,21 @@ struct lambdapolarization { } // event selection template - bool SelectionV0(TCollision const& collision, V0 const& candidate) + bool SelectionV0(TCollision const& collision, V0 const& candidate, int LambdaTag) { if (candidate.v0radius() < cfgv0radiusMin) return false; - if (std::abs(candidate.dcapostopv()) < cfgDCAPosToPVMin) - return false; - if (std::abs(candidate.dcanegtopv()) < cfgDCANegToPVMin) - return false; + if (LambdaTag) { + if (std::abs(candidate.dcapostopv()) < cfgDCAPrToPVMin) + return false; + if (std::abs(candidate.dcanegtopv()) < cfgDCAPiToPVMin) + return false; + } else if (!LambdaTag) { + if (std::abs(candidate.dcapostopv()) < cfgDCAPiToPVMin) + return false; + if (std::abs(candidate.dcanegtopv()) < cfgDCAPrToPVMin) + return false; + } if (candidate.v0cosPA() < cfgv0CosPA) return false; if (std::abs(candidate.dcaV0daughters()) > cfgDCAV0Dau) @@ -450,6 +542,14 @@ struct lambdapolarization { histos.fill(HIST("psi2/QA/EP_RefA"), centrality, TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) / static_cast(nmode)); histos.fill(HIST("psi2/QA/EP_RefB"), centrality, TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]) / static_cast(nmode)); + histos.fill(HIST("psi2/QA/qqAxis_Det_RefA_xx"), centrality, collision.qvecRe()[QvecDetInd] * collision.qvecRe()[QvecRefAInd]); + histos.fill(HIST("psi2/QA/qqAxis_Det_RefB_xx"), centrality, collision.qvecRe()[QvecDetInd] * collision.qvecRe()[QvecRefBInd]); + histos.fill(HIST("psi2/QA/qqAxis_RefA_RefB_xx"), centrality, collision.qvecRe()[QvecRefAInd] * collision.qvecRe()[QvecRefBInd]); + + histos.fill(HIST("psi2/QA/qqAxis_Det_RefA_yy"), centrality, collision.qvecIm()[QvecDetInd] * collision.qvecIm()[QvecRefAInd]); + histos.fill(HIST("psi2/QA/qqAxis_Det_RefB_yy"), centrality, collision.qvecIm()[QvecDetInd] * collision.qvecIm()[QvecRefBInd]); + histos.fill(HIST("psi2/QA/qqAxis_RefA_RefB_yy"), centrality, collision.qvecIm()[QvecRefAInd] * collision.qvecIm()[QvecRefBInd]); + histos.fill(HIST("psi2/QA/EPRes_Det_RefA"), centrality, TMath::Cos(TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) - TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]))); histos.fill(HIST("psi2/QA/EPRes_Det_RefB"), centrality, TMath::Cos(TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) - TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]))); histos.fill(HIST("psi2/QA/EPRes_RefA_RefB"), centrality, TMath::Cos(TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) - TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]))); @@ -458,6 +558,14 @@ struct lambdapolarization { histos.fill(HIST("psi3/QA/EP_RefA"), centrality, TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) / static_cast(nmode)); histos.fill(HIST("psi3/QA/EP_RefB"), centrality, TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]) / static_cast(nmode)); + histos.fill(HIST("psi3/QA/qqAxis_Det_RefA_xx"), centrality, collision.qvecRe()[QvecDetInd] * collision.qvecRe()[QvecRefAInd]); + histos.fill(HIST("psi3/QA/qqAxis_Det_RefB_xx"), centrality, collision.qvecRe()[QvecDetInd] * collision.qvecRe()[QvecRefBInd]); + histos.fill(HIST("psi3/QA/qqAxis_RefA_RefB_xx"), centrality, collision.qvecRe()[QvecRefAInd] * collision.qvecRe()[QvecRefBInd]); + + histos.fill(HIST("psi3/QA/qqAxis_Det_RefA_yy"), centrality, collision.qvecIm()[QvecDetInd] * collision.qvecIm()[QvecRefAInd]); + histos.fill(HIST("psi3/QA/qqAxis_Det_RefB_yy"), centrality, collision.qvecIm()[QvecDetInd] * collision.qvecIm()[QvecRefBInd]); + histos.fill(HIST("psi3/QA/qqAxis_RefA_RefB_yy"), centrality, collision.qvecIm()[QvecRefAInd] * collision.qvecIm()[QvecRefBInd]); + histos.fill(HIST("psi3/QA/EPRes_Det_RefA"), centrality, TMath::Cos(TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) - TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]))); histos.fill(HIST("psi3/QA/EPRes_Det_RefB"), centrality, TMath::Cos(TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) - TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]))); histos.fill(HIST("psi3/QA/EPRes_RefA_RefB"), centrality, TMath::Cos(TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) - TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]))); @@ -466,6 +574,14 @@ struct lambdapolarization { histos.fill(HIST("psi4/QA/EP_RefA"), centrality, TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) / static_cast(nmode)); histos.fill(HIST("psi4/QA/EP_RefB"), centrality, TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]) / static_cast(nmode)); + histos.fill(HIST("psi4/QA/qqAxis_Det_RefA_xx"), centrality, collision.qvecRe()[QvecDetInd] * collision.qvecRe()[QvecRefAInd]); + histos.fill(HIST("psi4/QA/qqAxis_Det_RefB_xx"), centrality, collision.qvecRe()[QvecDetInd] * collision.qvecRe()[QvecRefBInd]); + histos.fill(HIST("psi4/QA/qqAxis_RefA_RefB_xx"), centrality, collision.qvecRe()[QvecRefAInd] * collision.qvecRe()[QvecRefBInd]); + + histos.fill(HIST("psi4/QA/qqAxis_Det_RefA_yy"), centrality, collision.qvecIm()[QvecDetInd] * collision.qvecIm()[QvecRefAInd]); + histos.fill(HIST("psi4/QA/qqAxis_Det_RefB_yy"), centrality, collision.qvecIm()[QvecDetInd] * collision.qvecIm()[QvecRefBInd]); + histos.fill(HIST("psi4/QA/qqAxis_RefA_RefB_yy"), centrality, collision.qvecIm()[QvecRefAInd] * collision.qvecIm()[QvecRefBInd]); + histos.fill(HIST("psi4/QA/EPRes_Det_RefA"), centrality, TMath::Cos(TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) - TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]))); histos.fill(HIST("psi4/QA/EPRes_Det_RefB"), centrality, TMath::Cos(TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) - TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]))); histos.fill(HIST("psi4/QA/EPRes_RefA_RefB"), centrality, TMath::Cos(TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) - TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]))); @@ -557,7 +673,7 @@ struct lambdapolarization { if (LambdaTag == aLambdaTag) continue; - if (!SelectionV0(collision, v0)) + if (!SelectionV0(collision, v0, LambdaTag)) continue; if (LambdaTag) { @@ -583,9 +699,9 @@ struct lambdapolarization { auto deltapsiFT0A = 0.0; auto deltapsiFV0A = 0.0; - auto psidefFT0C = TMath::ATan2(collision.qvecIm()[3 + (nmode - 2) * 28], collision.qvecRe()[3 + (nmode - 2) * 28]) / static_cast(nmode); - auto psidefFT0A = TMath::ATan2(collision.qvecIm()[3 + 4 + (nmode - 2) * 28], collision.qvecRe()[3 + 4 + (nmode - 2) * 28]) / static_cast(nmode); - auto psidefFV0A = TMath::ATan2(collision.qvecIm()[3 + 12 + (nmode - 2) * 28], collision.qvecRe()[3 + 12 + (nmode - 2) * 28]) / static_cast(nmode); + auto psidefFT0C = TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) / static_cast(nmode); + auto psidefFT0A = TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) / static_cast(nmode); + auto psidefFV0A = TMath::ATan2(collision.qvecIm()[QvecRefBInd], collision.qvecRe()[QvecRefBInd]) / static_cast(nmode); for (int ishift = 1; ishift <= 10; ishift++) { auto coeffshiftxFT0C = shiftprofile.at(nmode - 2)->GetBinContent(shiftprofile.at(nmode - 2)->FindBin(centrality, 0.5, ishift - 0.5)); auto coeffshiftyFT0C = shiftprofile.at(nmode - 2)->GetBinContent(shiftprofile.at(nmode - 2)->FindBin(centrality, 1.5, ishift - 0.5)); @@ -598,6 +714,7 @@ struct lambdapolarization { deltapsiFT0A += ((1 / (1.0 * ishift)) * (-coeffshiftxFT0A * TMath::Cos(ishift * static_cast(nmode) * psidefFT0A) + coeffshiftyFT0A * TMath::Sin(ishift * static_cast(nmode) * psidefFT0A))); deltapsiFV0A += ((1 / (1.0 * ishift)) * (-coeffshiftxFV0A * TMath::Cos(ishift * static_cast(nmode) * psidefFV0A) + coeffshiftyFV0A * TMath::Sin(ishift * static_cast(nmode) * psidefFV0A))); } + psi += deltapsiFT0C; relphi = TVector2::Phi_0_2pi(static_cast(nmode) * (LambdaVec.Phi() - psidefFT0C - deltapsiFT0C)); } @@ -619,17 +736,29 @@ struct lambdapolarization { 1.0 / EffMap->GetBinContent(EffMap->GetXaxis()->FindBin(v0.pt()), EffMap->GetYaxis()->FindBin(centrality))); } } + double weight = 1.0; + weight *= cfgEffCor ? 1.0 / EffMap->GetBinContent(EffMap->GetXaxis()->FindBin(v0.pt()), EffMap->GetYaxis()->FindBin(centrality)) : 1.; + weight *= cfgAccCor ? 1.0 / AccMap->GetBinContent(AccMap->GetXaxis()->FindBin(v0.pt()), AccMap->GetYaxis()->FindBin(v0.yLambda())) : 1.; - double weight = cfgEffCor ? 1.0 / EffMap->GetBinContent(EffMap->GetXaxis()->FindBin(v0.pt()), EffMap->GetYaxis()->FindBin(centrality)) : 1.; - double qvecMag = TMath::Sqrt(TMath::Power(collision.qvecIm()[3 + (nmode - 2) * 28], 2) + TMath::Power(collision.qvecRe()[3 + (nmode - 2) * 28], 2)); + double qvecMag = 1.0; + if (cfgUSESP) + qvecMag *= TMath::Sqrt(TMath::Power(collision.qvecIm()[3 + (nmode - 2) * 28], 2) + TMath::Power(collision.qvecRe()[3 + (nmode - 2) * 28], 2)); if (nmode == 2) { //////////// if (LambdaTag) { - histos.fill(HIST("psi2/h_lambda_cos"), v0.mLambda(), v0.pt(), angle, centrality, relphi, weight); - histos.fill(HIST("psi2/h_lambda_cos2"), v0.mLambda(), v0.pt(), angle * angle, centrality, relphi, weight); - histos.fill(HIST("psi2/h_lambda_cossin"), v0.mLambda(), v0.pt(), angle * TMath::Sin(relphi), centrality, weight); - histos.fill(HIST("psi2/h_lambda_vncos"), v0.mLambda(), v0.pt(), qvecMag * TMath::Cos(relphi), centrality, weight); - histos.fill(HIST("psi2/h_lambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); + histos.fill(HIST("psi2/h_lambda_cos"), v0.mLambda(), v0.pt(), angle * weight, centrality, relphi); + histos.fill(HIST("psi2/h_lambda_cos2"), v0.mLambda(), v0.pt(), angle * angle, centrality, relphi); + histos.fill(HIST("psi2/h_lambda_cossin"), v0.mLambda(), v0.pt(), angle * TMath::Sin(relphi) * weight, centrality); + histos.fill(HIST("psi2/h_lambda_vncos"), v0.mLambda(), v0.pt(), qvecMag * TMath::Cos(relphi) * weight, centrality); + histos.fill(HIST("psi2/h_lambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality); + + if (cfgRapidityDep) { + histos.fill(HIST("psi2/h_lambda_cos2_rap"), v0.mLambda(), v0.pt(), angle * angle, centrality, v0.yLambda(), weight); + } + + if (cfgAccAzimuth) { + histos.fill(HIST("psi2/h_lambda_coscos"), v0.mLambda(), v0.pt(), angle * TMath::Cos(relphi), centrality, weight); + } if (cfgCalcCum) { histos.fill(HIST("psi2/QA/cosTheta_l"), v0.mLambda(), v0.pt(), angle, centrality); @@ -648,61 +777,133 @@ struct lambdapolarization { histos.fill(HIST("psi2/QA/cosPhi_sinPsi_l"), v0.mLambda(), v0.pt(), TMath::Cos(v0.phi() * 2.0) * TMath::Sin(psi * 2.0), centrality); histos.fill(HIST("psi2/QA/sinPhi_cosPsi_l"), v0.mLambda(), v0.pt(), TMath::Sin(v0.phi() * 2.0) * TMath::Cos(psi * 2.0), centrality); } + if (cfgCalcCum1) { + histos.fill(HIST("psi2/QA/cosTheta_l"), v0.mLambda(), v0.pt(), angle, centrality); + histos.fill(HIST("psi2/QA/cosPsi_l"), v0.mLambda(), v0.pt(), TMath::Cos(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosPhi_l"), v0.mLambda(), v0.pt(), TMath::Cos(v0.phi() * 2.0), centrality); + + histos.fill(HIST("psi2/QA/cosPhi_cosPsi_l"), v0.mLambda(), v0.pt(), TMath::Cos(v0.phi() * 2.0) * TMath::Cos(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_cosPhi_l"), v0.mLambda(), v0.pt(), angle * TMath::Cos(v0.phi() * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_cosPsi_l"), v0.mLambda(), v0.pt(), angle * TMath::Cos(psi * 2.0), centrality); + + histos.fill(HIST("psi2/QA/sinPhi_sinPsi_l"), v0.mLambda(), v0.pt(), TMath::Sin(v0.phi() * 2.0) * TMath::Sin(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_sinPhi_l"), v0.mLambda(), v0.pt(), angle * TMath::Sin(v0.phi() * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_sinPsi_l"), v0.mLambda(), v0.pt(), angle * TMath::Sin(psi * 2.0), centrality); + + histos.fill(HIST("psi2/QA/sinPsi_l"), v0.mLambda(), v0.pt(), TMath::Sin(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/sinPhi_l"), v0.mLambda(), v0.pt(), TMath::Sin(v0.phi() * 2.0), centrality); + } } if (aLambdaTag) { - histos.fill(HIST("psi2/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle, centrality, relphi, weight); - histos.fill(HIST("psi2/h_alambda_cos2"), v0.mAntiLambda(), v0.pt(), angle * angle, centrality, relphi, weight); - histos.fill(HIST("psi2/h_alambda_cossin"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(relphi), centrality, weight); - histos.fill(HIST("psi2/h_alambda_vncos"), v0.mAntiLambda(), v0.pt(), qvecMag * TMath::Cos(relphi), centrality, weight); - histos.fill(HIST("psi2/h_alambda_vnsin"), v0.mAntiLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); + histos.fill(HIST("psi2/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle * weight, centrality, relphi); + histos.fill(HIST("psi2/h_alambda_cos2"), v0.mAntiLambda(), v0.pt(), angle * angle, centrality, relphi); + histos.fill(HIST("psi2/h_alambda_cossin"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(relphi) * weight, centrality); + histos.fill(HIST("psi2/h_alambda_vncos"), v0.mAntiLambda(), v0.pt(), qvecMag * TMath::Cos(relphi) * weight, centrality); + histos.fill(HIST("psi2/h_alambda_vnsin"), v0.mAntiLambda(), v0.pt(), TMath::Sin(relphi), centrality); + + if (cfgRapidityDep) { + histos.fill(HIST("psi2/h_alambda_cos2_rap"), v0.mAntiLambda(), v0.pt(), angle * angle, centrality, v0.yLambda(), weight); + } + + if (cfgAccAzimuth) { + histos.fill(HIST("psi2/h_alambda_coscos"), v0.mAntiLambda(), v0.pt(), angle * TMath::Cos(relphi), centrality, weight); + } if (cfgCalcCum) { - histos.fill(HIST("psi2/QA/cosTheta_al"), v0.mLambda(), v0.pt(), angle, centrality); - histos.fill(HIST("psi2/QA/cosPsi_al"), v0.mLambda(), v0.pt(), TMath::Cos(psi * 2.0), centrality); - histos.fill(HIST("psi2/QA/cosPhi_al"), v0.mLambda(), v0.pt(), TMath::Cos(v0.phi() * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_al"), v0.mAntiLambda(), v0.pt(), angle, centrality); + histos.fill(HIST("psi2/QA/cosPsi_al"), v0.mAntiLambda(), v0.pt(), TMath::Cos(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosPhi_al"), v0.mAntiLambda(), v0.pt(), TMath::Cos(v0.phi() * 2.0), centrality); - histos.fill(HIST("psi2/QA/sinPsi_al"), v0.mLambda(), v0.pt(), TMath::Sin(psi * 2.0), centrality); - histos.fill(HIST("psi2/QA/sinPhi_al"), v0.mLambda(), v0.pt(), TMath::Sin(v0.phi() * 2.0), centrality); + histos.fill(HIST("psi2/QA/sinPsi_al"), v0.mAntiLambda(), v0.pt(), TMath::Sin(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/sinPhi_al"), v0.mAntiLambda(), v0.pt(), TMath::Sin(v0.phi() * 2.0), centrality); - histos.fill(HIST("psi2/QA/cosTheta_cosPhi_al"), v0.mLambda(), v0.pt(), angle * TMath::Cos(v0.phi() * 2.0), centrality); - histos.fill(HIST("psi2/QA/cosTheta_cosPsi_al"), v0.mLambda(), v0.pt(), angle * TMath::Cos(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_cosPhi_al"), v0.mAntiLambda(), v0.pt(), angle * TMath::Cos(v0.phi() * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_cosPsi_al"), v0.mAntiLambda(), v0.pt(), angle * TMath::Cos(psi * 2.0), centrality); - histos.fill(HIST("psi2/QA/cosTheta_sinPhi_al"), v0.mLambda(), v0.pt(), angle * TMath::Sin(v0.phi() * 2.0), centrality); - histos.fill(HIST("psi2/QA/cosTheta_sinPsi_al"), v0.mLambda(), v0.pt(), angle * TMath::Sin(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_sinPhi_al"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(v0.phi() * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_sinPsi_al"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(psi * 2.0), centrality); - histos.fill(HIST("psi2/QA/cosPhi_sinPsi_al"), v0.mLambda(), v0.pt(), TMath::Cos(v0.phi() * 2.0) * TMath::Sin(psi * 2.0), centrality); - histos.fill(HIST("psi2/QA/sinPhi_cosPsi_al"), v0.mLambda(), v0.pt(), TMath::Sin(v0.phi() * 2.0) * TMath::Cos(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosPhi_sinPsi_al"), v0.mAntiLambda(), v0.pt(), TMath::Cos(v0.phi() * 2.0) * TMath::Sin(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/sinPhi_cosPsi_al"), v0.mAntiLambda(), v0.pt(), TMath::Sin(v0.phi() * 2.0) * TMath::Cos(psi * 2.0), centrality); + } + if (cfgCalcCum1) { + histos.fill(HIST("psi2/QA/cosTheta_al"), v0.mAntiLambda(), v0.pt(), angle, centrality); + histos.fill(HIST("psi2/QA/cosPsi_al"), v0.mAntiLambda(), v0.pt(), TMath::Cos(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosPhi_al"), v0.mAntiLambda(), v0.pt(), TMath::Cos(v0.phi() * 2.0), centrality); + + histos.fill(HIST("psi2/QA/cosPhi_cosPsi_al"), v0.mAntiLambda(), v0.pt(), TMath::Cos(v0.phi() * 2.0) * TMath::Cos(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_cosPhi_al"), v0.mAntiLambda(), v0.pt(), angle * TMath::Cos(v0.phi() * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_cosPsi_al"), v0.mAntiLambda(), v0.pt(), angle * TMath::Cos(psi * 2.0), centrality); + + histos.fill(HIST("psi2/QA/sinPhi_sinPsi_al"), v0.mAntiLambda(), v0.pt(), TMath::Sin(v0.phi() * 2.0) * TMath::Sin(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_sinPhi_al"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(v0.phi() * 2.0), centrality); + histos.fill(HIST("psi2/QA/cosTheta_sinPsi_al"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(psi * 2.0), centrality); + + histos.fill(HIST("psi2/QA/sinPsi_al"), v0.mAntiLambda(), v0.pt(), TMath::Sin(psi * 2.0), centrality); + histos.fill(HIST("psi2/QA/sinPhi_al"), v0.mAntiLambda(), v0.pt(), TMath::Sin(v0.phi() * 2.0), centrality); } } } else if (nmode == 3) { if (LambdaTag) { - histos.fill(HIST("psi3/h_lambda_cos"), v0.mLambda(), v0.pt(), angle, centrality, relphi, weight); - histos.fill(HIST("psi3/h_lambda_cos2"), v0.mLambda(), v0.pt(), angle * angle, centrality, relphi, weight); - histos.fill(HIST("psi3/h_lambda_cossin"), v0.mLambda(), v0.pt(), angle * TMath::Sin(relphi), centrality, weight); - histos.fill(HIST("psi3/h_lambda_vncos"), v0.mLambda(), v0.pt(), qvecMag * TMath::Cos(relphi), centrality, weight); - histos.fill(HIST("psi3/h_lambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); + histos.fill(HIST("psi3/h_lambda_cos"), v0.mLambda(), v0.pt(), angle * weight, centrality, relphi); + histos.fill(HIST("psi3/h_lambda_cos2"), v0.mLambda(), v0.pt(), angle * angle, centrality, relphi); + histos.fill(HIST("psi3/h_lambda_cossin"), v0.mLambda(), v0.pt(), angle * TMath::Sin(relphi) * weight, centrality); + histos.fill(HIST("psi3/h_lambda_vncos"), v0.mLambda(), v0.pt(), qvecMag * TMath::Cos(relphi) * weight, centrality); + histos.fill(HIST("psi3/h_lambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality); + + if (cfgRapidityDep) { + histos.fill(HIST("psi3/h_lambda_cos2_rap"), v0.mLambda(), v0.pt(), angle * angle, centrality, v0.yLambda(), weight); + } + + if (cfgAccAzimuth) { + histos.fill(HIST("psi3/h_lambda_coscos"), v0.mLambda(), v0.pt(), angle * TMath::Cos(relphi), centrality, weight); + } } if (aLambdaTag) { - histos.fill(HIST("psi3/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle, centrality, relphi, weight); + histos.fill(HIST("psi3/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle * weight, centrality, relphi); histos.fill(HIST("psi3/h_alambda_cos2"), v0.mAntiLambda(), v0.pt(), angle * angle, centrality, relphi, weight); - histos.fill(HIST("psi3/h_alambda_cossin"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(relphi), centrality, weight); - histos.fill(HIST("psi3/h_alambda_vncos"), v0.mAntiLambda(), v0.pt(), qvecMag * TMath::Cos(relphi), centrality, weight); - histos.fill(HIST("psi3/h_alambda_vnsin"), v0.mAntiLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); + histos.fill(HIST("psi3/h_alambda_cossin"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(relphi) * weight, centrality); + histos.fill(HIST("psi3/h_alambda_vncos"), v0.mAntiLambda(), v0.pt(), qvecMag * TMath::Cos(relphi) * weight, centrality); + histos.fill(HIST("psi3/h_alambda_vnsin"), v0.mAntiLambda(), v0.pt(), TMath::Sin(relphi), centrality); + + if (cfgRapidityDep) { + histos.fill(HIST("psi3/h_alambda_cos2_rap"), v0.mAntiLambda(), v0.pt(), angle * angle, centrality, v0.yLambda(), weight); + } + + if (cfgAccAzimuth) { + histos.fill(HIST("psi3/h_alambda_coscos"), v0.mAntiLambda(), v0.pt(), angle * TMath::Cos(relphi), centrality, weight); + } } } else if (nmode == 4) { if (LambdaTag) { - histos.fill(HIST("psi4/h_lambda_cos"), v0.mLambda(), v0.pt(), angle, centrality, relphi, weight); - histos.fill(HIST("psi4/h_lambda_cos2"), v0.mLambda(), v0.pt(), angle * angle, centrality, relphi, weight); - histos.fill(HIST("psi4/h_lambda_cossin"), v0.mLambda(), v0.pt(), angle * TMath::Sin(relphi), centrality, weight); - histos.fill(HIST("psi4/h_lambda_vncos"), v0.mLambda(), v0.pt(), qvecMag * TMath::Cos(relphi), centrality, weight); - histos.fill(HIST("psi4/h_lambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); + histos.fill(HIST("psi4/h_lambda_cos"), v0.mLambda(), v0.pt(), angle * weight, centrality, relphi); + histos.fill(HIST("psi4/h_lambda_cos2"), v0.mLambda(), v0.pt(), angle * angle, centrality, relphi); + histos.fill(HIST("psi4/h_lambda_cossin"), v0.mLambda(), v0.pt(), angle * TMath::Sin(relphi) * weight, centrality); + histos.fill(HIST("psi4/h_lambda_vncos"), v0.mLambda(), v0.pt(), qvecMag * TMath::Cos(relphi) * weight, centrality); + histos.fill(HIST("psi4/h_lambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality); + + if (cfgRapidityDep) { + histos.fill(HIST("psi4/h_lambda_cos2_rap"), v0.mLambda(), v0.pt(), angle * angle, centrality, v0.yLambda(), weight); + } + + if (cfgAccAzimuth) { + histos.fill(HIST("psi4/h_lambda_coscos"), v0.mLambda(), v0.pt(), angle * TMath::Cos(relphi), centrality, weight); + } } if (aLambdaTag) { - histos.fill(HIST("psi4/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle, centrality, relphi, weight); - histos.fill(HIST("psi4/h_alambda_cos2"), v0.mAntiLambda(), v0.pt(), angle * angle, centrality, relphi, weight); - histos.fill(HIST("psi4/h_alambda_cossin"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(relphi), centrality, weight); - histos.fill(HIST("psi4/h_alambda_vncos"), v0.mAntiLambda(), v0.pt(), qvecMag * TMath::Cos(relphi), centrality, weight); - histos.fill(HIST("psi4/h_alambda_vnsin"), v0.mAntiLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); + histos.fill(HIST("psi4/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle * weight, centrality, relphi); + histos.fill(HIST("psi4/h_alambda_cos2"), v0.mAntiLambda(), v0.pt(), angle * angle, centrality, relphi); + histos.fill(HIST("psi4/h_alambda_cossin"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(relphi) * weight, centrality); + histos.fill(HIST("psi4/h_alambda_vncos"), v0.mAntiLambda(), v0.pt(), qvecMag * TMath::Cos(relphi) * weight, centrality); + histos.fill(HIST("psi4/h_alambda_vnsin"), v0.mAntiLambda(), v0.pt(), TMath::Sin(relphi), centrality); + + if (cfgRapidityDep) { + histos.fill(HIST("psi4/h_alambda_cos2_rap"), v0.mAntiLambda(), v0.pt(), angle * angle, centrality, v0.yLambda(), weight); + } + + if (cfgAccAzimuth) { + histos.fill(HIST("psi4/h_alambda_coscos"), v0.mAntiLambda(), v0.pt(), angle * TMath::Cos(relphi), centrality, weight); + } } } ////////// FIXME: not possible to get histograms using nmode } @@ -738,10 +939,13 @@ struct lambdapolarization { lastRunNumber = currentRunNumber; } } + auto bc = collision.bc_as(); if (cfgEffCor) { - auto bc = collision.bc_as(); EffMap = ccdb->getForTimeStamp(cfgEffCorPath.value, bc.timestamp()); } + if (cfgAccCor) { + AccMap = ccdb->getForTimeStamp(cfgAccCorPath.value, bc.timestamp()); + } for (int i = 2; i < cfgnMods + 2; i++) { if (cfgShiftCorrDef) { FillShiftCorrection(collision, i); @@ -753,6 +957,89 @@ struct lambdapolarization { } // FIXME: need to fill different histograms for different harmonic } PROCESS_SWITCH(lambdapolarization, processData, "Process Event for data", true); + + using recoTracks = soa::Join; + void processMC_ITSTPC(aod::McCollision const& mcCollision, soa::Join const& mcParticles, recoTracks const&) + { + float imp = mcCollision.impactParameter(); + float evPhi = mcCollision.eventPlaneAngle() / 2.0; + float centclass = -999; + if (imp >= 0 && imp < 3.49) { + centclass = 2.5; + } + if (imp >= 3.49 && imp < 4.93) { + centclass = 7.5; + } + if (imp >= 4.93 && imp < 6.98) { + centclass = 15.0; + } + if (imp >= 6.98 && imp < 8.55) { + centclass = 25.0; + } + if (imp >= 8.55 && imp < 9.87) { + centclass = 35.0; + } + if (imp >= 9.87 && imp < 11) { + centclass = 45.0; + } + if (imp >= 11 && imp < 12.1) { + centclass = 55.0; + } + if (imp >= 12.1 && imp < 13.1) { + centclass = 65.0; + } + if (imp >= 13.1 && imp < 14) { + centclass = 75.0; + } + // if (evPhi < 0) + // evPhi += 2. * TMath::Pi(); + + int nCh = 0; + + if (centclass > 0 && centclass < 80) { + // event within range + histos.fill(HIST("hImpactParameter"), imp); + histos.fill(HIST("hEventPlaneAngle"), evPhi); + for (auto const& mcParticle : mcParticles) { + + float deltaPhi = mcParticle.phi() - mcCollision.eventPlaneAngle(); + // focus on bulk: e, mu, pi, k, p + int pdgCode = TMath::Abs(mcParticle.pdgCode()); + if (pdgCode != 3122) + continue; + if (!mcParticle.isPhysicalPrimary()) + continue; + if (TMath::Abs(mcParticle.eta()) > 0.8) // main acceptance + continue; + histos.fill(HIST("hSparseMCGenWeight"), centclass, GetPhiInRange(deltaPhi), TMath::Power(TMath::Cos(2.0 * GetPhiInRange(deltaPhi)), 2.0), mcParticle.pt(), mcParticle.eta()); + nCh++; + bool validGlobal = false; + bool validAny = false; + if (mcParticle.has_tracks()) { + auto const& tracks = mcParticle.tracks_as(); + for (auto const& track : tracks) { + if (track.hasTPC() && track.hasITS()) { + validGlobal = true; + } + if (track.hasTPC() || track.hasITS()) { + validAny = true; + } + } + } + // if valid global, fill + if (validGlobal) { + histos.fill(HIST("hSparseMCRecWeight"), centclass, GetPhiInRange(deltaPhi), TMath::Power(TMath::Cos(2.0 * GetPhiInRange(deltaPhi)), 2.0), mcParticle.pt(), mcParticle.eta()); + } + if (validAny) { + histos.fill(HIST("hSparseMCRecAllTrackWeight"), centclass, GetPhiInRange(deltaPhi), TMath::Power(TMath::Cos(2.0 * GetPhiInRange(deltaPhi)), 2.0), mcParticle.pt(), mcParticle.eta()); + histos.fill(HIST("hEventPlaneAngleRec"), GetPhiInRange(deltaPhi)); + } + // if any track present, fill + } + } + histos.fill(HIST("hNchVsImpactParameter"), imp, nCh); + } + PROCESS_SWITCH(lambdapolarization, processMC_ITSTPC, "Process MC for ITSTPC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Strangeness/lambdapolsp.cxx b/PWGLF/Tasks/Strangeness/lambdapolsp.cxx index ae7771415e5..7377271460e 100644 --- a/PWGLF/Tasks/Strangeness/lambdapolsp.cxx +++ b/PWGLF/Tasks/Strangeness/lambdapolsp.cxx @@ -11,56 +11,67 @@ // Lambda polarisation task // prottay.das@cern.ch -#include +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/SPCalibrationTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TF1.h" +#include "TRandom3.h" #include +#include +#include +#include #include #include #include #include -#include -#include -#include #include -#include -#include + +#include #include +#include #include - -#include "TRandom3.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" -#include "Math/GenVector/Boost.h" -#include "TF1.h" - -// #include "Common/DataModel/Qvectors.h" -#include "PWGLF/DataModel/SPCalibrationTables.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StepTHn.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/Core/trackUtilities.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Common/Core/TrackSelection.h" -#include "Framework/ASoAHelpers.h" -#include "ReconstructionDataFormats/Track.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/LFStrangenessPIDTables.h" -#include "Common/DataModel/FT0Corrected.h" +#include +#include +#include +#include // <<< CHANGED: for dedup sets +#include +#include +#include // <<< CHANGED: for seenMap +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using std::array; +using namespace o2::aod::rctsel; using dauTracks = soa::Join; using v0Candidates = soa::Join; @@ -68,8 +79,6 @@ using v0Candidates = soa::Join; struct lambdapolsp { int mRunNumber; - int multEstimator; - float d_bz; Service ccdb; Service pdg; @@ -77,25 +86,28 @@ struct lambdapolsp { Configurable additionalEvSel{"additionalEvSel", false, "additionalEvSel"}; Configurable additionalEvSel2{"additionalEvSel2", false, "additionalEvSel2"}; Configurable additionalEvSel3{"additionalEvSel3", false, "additionalEvSel3"}; - Configurable QA{"QA", false, "flag for QA"}; - // Configurable mycut{"mycut", false, "select tracks based on my cuts"}; - Configurable tofhit{"tofhit", true, "select tracks based on tof hit"}; + Configurable additionalEvSel4{"additionalEvSel4", false, "additionalEvSel4"}; Configurable globalpt{"globalpt", true, "select tracks based on pt global vs tpc"}; - Configurable useglobal{"useglobal", true, "flag to use global vs v0 momentum"}; - Configurable checksign{"checksign", true, "check sign of daughter tracks"}; + Configurable cqvas{"cqvas", false, "change q vectors after shift correction"}; Configurable useprofile{"useprofile", 3, "flag to select profile vs Sparse"}; - Configurable QxyNbins{"QxyNbins", 100, "Number of bins in QxQy histograms"}; - Configurable lbinQxy{"lbinQxy", -5.0, "lower bin value in QxQy histograms"}; - Configurable hbinQxy{"hbinQxy", 5.0, "higher bin value in QxQy histograms"}; Configurable cfgMaxOccupancy{"cfgMaxOccupancy", 1000, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; Configurable cfgMinOccupancy{"cfgMinOccupancy", 0, "maximum occupancy of tracks in neighbouring collisions in a given time range"}; - + Configurable sys{"sys", 1, "flag to select systematic source"}; + Configurable dosystematic{"dosystematic", false, "flag to perform systematic study"}; + Configurable needetaaxis{"needetaaxis", false, "flag to use last axis"}; + struct : ConfigurableGroup { + Configurable doRandomPsi{"doRandomPsi", true, "randomize psi"}; + Configurable doRandomPsiAC{"doRandomPsiAC", true, "randomize psiAC"}; + Configurable doRandomPhi{"doRandomPhi", true, "randomize phi"}; + Configurable etaMix{"etaMix", 0.1, "eta difference in mixing"}; + Configurable ptMix{"ptMix", 0.1, "pt difference in mixing"}; + Configurable phiMix{"phiMix", 0.1, "phi difference in mixing"}; + } randGrp; // events Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgCutCentralityMax{"cfgCutCentralityMax", 50.0f, "Accepted maximum Centrality"}; Configurable cfgCutCentralityMin{"cfgCutCentralityMin", 30.0f, "Accepted minimum Centrality"}; // proton track cut - Configurable confRapidity{"confRapidity", 0.8, "cut on Rapidity"}; Configurable cfgCutPT{"cfgCutPT", 0.15, "PT cut on daughter track"}; Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; Configurable cfgCutDCAxy{"cfgCutDCAxy", 0.1f, "DCAxy range for tracks"}; @@ -113,173 +125,193 @@ struct lambdapolsp { Configurable ConfV0TranRadV0Min{"ConfV0TranRadV0Min", 1.5f, "Minimum transverse radius"}; Configurable ConfV0TranRadV0Max{"ConfV0TranRadV0Max", 100.f, "Maximum transverse radius"}; Configurable cMaxV0DCA{"cMaxV0DCA", 1.2, "Maximum V0 DCA to PV"}; - Configurable cMinV0DCA{"cMinV0DCA", 0.05, "Minimum V0 daughters DCA to PV"}; + Configurable cMinV0DCAPr{"cMinV0DCAPr", 0.05, "Minimum V0 daughters DCA to PV for Pr"}; + Configurable cMinV0DCAPi{"cMinV0DCAPi", 0.05, "Minimum V0 daughters DCA to PV for Pi"}; Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 20, "Maximum V0 life time"}; + Configurable analyzeLambda{"analyzeLambda", true, "flag for lambda analysis"}; + Configurable analyzeK0s{"analyzeK0s", false, "flag for K0s analysis"}; + Configurable qtArmenterosMinForK0{"qtArmenterosMinForK0", 0.2, "Armenterous cut for K0s"}; // config for V0 daughters Configurable ConfDaughEta{"ConfDaughEta", 0.8f, "V0 Daugh sel: max eta"}; Configurable cfgDaughPrPt{"cfgDaughPrPt", 0.4, "minimum daughter proton pt"}; Configurable cfgDaughPiPt{"cfgDaughPiPt", 0.2, "minimum daughter pion pt"}; + Configurable rcrfc{"rcrfc", 0.8f, "Ratio of CR to FC"}; Configurable ConfDaughTPCnclsMin{"ConfDaughTPCnclsMin", 50.f, "V0 Daugh sel: Min. nCls TPC"}; - Configurable ConfDaughDCAMin{"ConfDaughDCAMin", 0.08f, "V0 Daugh sel: Max. DCA Daugh to PV (cm)"}; Configurable ConfDaughPIDCuts{"ConfDaughPIDCuts", 3, "PID selections for Lambda daughters"}; - - Configurable CentNbins{"CentNbins", 16, "Number of bins in cent histograms"}; - Configurable lbinCent{"lbinCent", 0.0, "lower bin value in cent histograms"}; - Configurable hbinCent{"hbinCent", 80.0, "higher bin value in cent histograms"}; - Configurable SANbins{"SANbins", 20, "Number of bins in costhetastar"}; - Configurable lbinSA{"lbinSA", -1.0, "lower bin value in costhetastar histograms"}; - Configurable hbinSA{"hbinSA", 1.0, "higher bin value in costhetastar histograms"}; - Configurable PolNbins{"PolNbins", 20, "Number of bins in polarisation"}; - Configurable lbinPol{"lbinPol", -1.0, "lower bin value in #phi-#psi histograms"}; - Configurable hbinPol{"hbinPol", 1.0, "higher bin value in #phi-#psi histograms"}; - Configurable IMNbins{"IMNbins", 100, "Number of bins in invariant mass"}; - Configurable lbinIM{"lbinIM", 1.0, "lower bin value in IM histograms"}; - Configurable hbinIM{"hbinIM", 1.2, "higher bin value in IM histograms"}; - Configurable ptNbins{"ptNbins", 50, "Number of bins in pt"}; - Configurable lbinpt{"lbinpt", 0.0, "lower bin value in pt histograms"}; - Configurable hbinpt{"hbinpt", 10.0, "higher bin value in pt histograms"}; - Configurable resNbins{"resNbins", 50, "Number of bins in reso"}; - Configurable lbinres{"lbinres", 0.0, "lower bin value in reso histograms"}; - Configurable hbinres{"hbinres", 10.0, "higher bin value in reso histograms"}; - Configurable etaNbins{"etaNbins", 20, "Number of bins in eta"}; - Configurable lbineta{"lbineta", -1.0, "lower bin value in eta histograms"}; - Configurable hbineta{"hbineta", 1.0, "higher bin value in eta histograms"}; - Configurable spNbins{"spNbins", 2000, "Number of bins in sp"}; - Configurable lbinsp{"lbinsp", -1.0, "lower bin value in sp histograms"}; - Configurable hbinsp{"hbinsp", 1.0, "higher bin value in sp histograms"}; - Configurable phiNbins{"phiNbins", 30, "Number of bins in phi"}; - + Configurable usesubdet{"usesubdet", false, "use subdet"}; + Configurable useAccCorr{"useAccCorr", false, "use acceptance correction"}; + Configurable ConfAccPathL{"ConfAccPathL", "Users/p/prottay/My/Object/From379780/Fulldata/NewPbPbpass4_28032025/acccorrL", "Path to acceptance correction for Lambda"}; + Configurable ConfAccPathAL{"ConfAccPathAL", "Users/p/prottay/My/Object/From379780/Fulldata/NewPbPbpass4_28032025/acccorrAL", "Path to acceptance correction for AntiLambda"}; + + struct : ConfigurableGroup { + Configurable QxyNbins{"QxyNbins", 100, "Number of bins in QxQy histograms"}; + Configurable lbinQxy{"lbinQxy", -5.0, "lower bin value in QxQy histograms"}; + Configurable hbinQxy{"hbinQxy", 5.0, "higher bin value in QxQy histograms"}; + Configurable PolNbins{"PolNbins", 20, "Number of bins in polarisation"}; + Configurable lbinPol{"lbinPol", -1.0, "lower bin value in #phi-#psi histograms"}; + Configurable hbinPol{"hbinPol", 1.0, "higher bin value in #phi-#psi histograms"}; + Configurable IMNbins{"IMNbins", 100, "Number of bins in invariant mass"}; + Configurable lbinIM{"lbinIM", 1.0, "lower bin value in IM histograms"}; + Configurable hbinIM{"hbinIM", 1.2, "higher bin value in IM histograms"}; + Configurable resNbins{"resNbins", 50, "Number of bins in reso"}; + Configurable lbinres{"lbinres", 0.0, "lower bin value in reso histograms"}; + Configurable hbinres{"hbinres", 10.0, "higher bin value in reso histograms"}; + Configurable spNbins{"spNbins", 2000, "Number of bins in sp"}; + Configurable lbinsp{"lbinsp", -1.0, "lower bin value in sp histograms"}; + Configurable hbinsp{"hbinsp", 1.0, "higher bin value in sp histograms"}; + // Configurable CentNbins{"CentNbins", 16, "Number of bins in cent histograms"}; + // Configurable lbinCent{"lbinCent", 0.0, "lower bin value in cent histograms"}; + // Configurable hbinCent{"hbinCent", 80.0, "higher bin value in cent histograms"}; + } binGrp; + /* ConfigurableAxis configcentAxis{"configcentAxis", {VARIABLE_WIDTH, 0.0, 10.0, 40.0, 80.0}, "Cent V0M"}; ConfigurableAxis configthnAxispT{"configthnAxisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "#it{p}_{T} (GeV/#it{c})"}; ConfigurableAxis configetaAxis{"configetaAxis", {VARIABLE_WIDTH, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8}, "Eta"}; ConfigurableAxis configthnAxisPol{"configthnAxisPol", {VARIABLE_WIDTH, -1.0, -0.6, -0.2, 0, 0.2, 0.4, 0.8}, "Pol"}; - ConfigurableAxis configphiAxis{"configphiAxis", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.8, 1.0, 2.0, 2.5, 3.0, 4.0, 5.0, 5.5, 6.28}, "PhiAxis"}; + ConfigurableAxis configbinAxis{"configbinAxis", {VARIABLE_WIDTH, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8}, "BA"}; + */ + // ConfigurableAxis configphiAxis{"configphiAxis", {VARIABLE_WIDTH, 0.0, 0.2, 0.4, 0.8, 1.0, 2.0, 2.5, 3.0, 4.0, 5.0, 5.5, 6.28}, "PhiAxis"}; + struct : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", true, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", false, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } rctCut; + struct : ConfigurableGroup { + ConfigurableAxis configcentAxis{"configcentAxis", {VARIABLE_WIDTH, 0.0, 10.0, 40.0, 80.0}, "Cent V0M"}; + ConfigurableAxis configthnAxispT{"configthnAxisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis configetaAxis{"configetaAxis", {VARIABLE_WIDTH, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8}, "Eta"}; + ConfigurableAxis configthnAxisPol{"configthnAxisPol", {VARIABLE_WIDTH, -1.0, -0.6, -0.2, 0, 0.2, 0.4, 0.8}, "Pol"}; + ConfigurableAxis configbinAxis{"configbinAxis", {VARIABLE_WIDTH, -0.8, -0.4, -0.2, 0, 0.2, 0.4, 0.8}, "BA"}; + } axisGrp; + struct : ConfigurableGroup { + ConfigurableAxis axisVertex{"axisVertex", {5, -10, 10}, "vertex axis for bin"}; + ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {8, 0, 80}, "multiplicity percentile for bin"}; + Configurable nMix{"nMix", 5, "number of event mixing"}; + } meGrp; + + RCTFlagsChecker rctChecker; SliceCache cache; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(o2::framework::InitContext&) { - AxisSpec thnAxispT{ptNbins, lbinpt, hbinpt, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec thnAxisRap{100, -0.5, 0.5, "Rapidity"}; - AxisSpec thnAxisres{resNbins, lbinres, hbinres, "Reso"}; - AxisSpec thnAxisInvMass{IMNbins, lbinIM, hbinIM, "#it{M} (GeV/#it{c}^{2})"}; - AxisSpec thnAxisPol{PolNbins, lbinPol, hbinPol, "Sin(#phi - #psi)"}; - AxisSpec thnAxisCosThetaStar{SANbins, lbinSA, hbinSA, "SA"}; - AxisSpec centAxis = {CentNbins, lbinCent, hbinCent, "V0M (%)"}; - AxisSpec etaAxis = {etaNbins, lbineta, hbineta, "Eta"}; - AxisSpec spAxis = {spNbins, lbinsp, hbinsp, "Sp"}; - AxisSpec qxZDCAxis = {QxyNbins, lbinQxy, hbinQxy, "Qx"}; - AxisSpec phiAxis = {phiNbins, 0.0, 6.28, "phi-phiStar"}; + + rctChecker.init(rctCut.cfgEvtRCTFlagCheckerLabel, rctCut.cfgEvtRCTFlagCheckerZDCCheck, rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + + AxisSpec thnAxisres{binGrp.resNbins, binGrp.lbinres, binGrp.hbinres, "Reso"}; + AxisSpec thnAxisInvMass{binGrp.IMNbins, binGrp.lbinIM, binGrp.hbinIM, "#it{M} (GeV/#it{c}^{2})"}; + AxisSpec spAxis = {binGrp.spNbins, binGrp.lbinsp, binGrp.hbinsp, "Sp"}; + // AxisSpec qxZDCAxis = {binGrp.QxyNbins, binGrp.lbinQxy, binGrp.hbinQxy, "Qx"}; + // AxisSpec centAxis = {CentNbins, lbinCent, hbinCent, "V0M (%)"}; + + std::vector runaxes = {thnAxisInvMass, axisGrp.configthnAxispT, axisGrp.configthnAxisPol, axisGrp.configcentAxis}; + if (needetaaxis) + runaxes.insert(runaxes.end(), {axisGrp.configbinAxis}); if (checkwithpub) { - if (useprofile == 1) { - histos.add("hpuxQxpvscentpteta", "hpuxQxpvscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuyQypvscentpteta", "hpuyQypvscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuxQxtvscentpteta", "hpuxQxtvscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuyQytvscentpteta", "hpuyQytvscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuxyQxytvscentpteta", "hpuxyQxytvscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuxyQxypvscentpteta", "hpuxyQxypvscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpoddv1vscentpteta", "hpoddv1vscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpevenv1vscentpteta", "hpevenv1vscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - - histos.add("hpuxvscentpteta", "hpuxvscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuyvscentpteta", "hpuyvscentpteta", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuxvscentptetaneg", "hpuxvscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuyvscentptetaneg", "hpuyvscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - - histos.add("hpuxQxpvscentptetaneg", "hpuxQxpvscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuyQypvscentptetaneg", "hpuyQypvscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuxQxtvscentptetaneg", "hpuxQxtvscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuyQytvscentptetaneg", "hpuyQytvscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuxyQxytvscentptetaneg", "hpuxyQxytvscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpuxyQxypvscentptetaneg", "hpuxyQxypvscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpoddv1vscentptetaneg", "hpoddv1vscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - histos.add("hpevenv1vscentptetaneg", "hpevenv1vscentptetaneg", kTProfile3D, {centAxis, thnAxispT, etaAxis}, true); - - histos.add("hpQxtQxpvscent", "hpQxtQxpvscent", kTProfile, {centAxis}, true); - histos.add("hpQytQypvscent", "hpQytQypvscent", kTProfile, {centAxis}, true); - histos.add("hpQxytpvscent", "hpQxytpvscent", kTProfile, {centAxis}, true); - histos.add("hpQxtQypvscent", "hpQxtQypvscent", kTProfile, {centAxis}, true); - histos.add("hpQxpQytvscent", "hpQxpQytvscent", kTProfile, {centAxis}, true); - - histos.add("hpQxpvscent", "hpQxpvscent", kTProfile, {centAxis}, true); - histos.add("hpQxtvscent", "hpQxtvscent", kTProfile, {centAxis}, true); - histos.add("hpQypvscent", "hpQypvscent", kTProfile, {centAxis}, true); - histos.add("hpQytvscent", "hpQytvscent", kTProfile, {centAxis}, true); - } else if (useprofile == 2) { - histos.add("hpuxQxpvscentpteta", "hpuxQxpvscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuyQypvscentpteta", "hpuyQypvscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuxQxtvscentpteta", "hpuxQxtvscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuyQytvscentpteta", "hpuyQytvscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuxyQxytvscentpteta", "hpuxyQxytvscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuxyQxypvscentpteta", "hpuxyQxypvscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpoddv1vscentpteta", "hpoddv1vscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpevenv1vscentpteta", "hpevenv1vscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - - histos.add("hpuxvscentpteta", "hpuxvscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuyvscentpteta", "hpuyvscentpteta", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuxvscentptetaneg", "hpuxvscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuyvscentptetaneg", "hpuyvscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - - histos.add("hpuxQxpvscentptetaneg", "hpuxQxpvscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuyQypvscentptetaneg", "hpuyQypvscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuxQxtvscentptetaneg", "hpuxQxtvscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuyQytvscentptetaneg", "hpuyQytvscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuxyQxytvscentptetaneg", "hpuxyQxytvscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpuxyQxypvscentptetaneg", "hpuxyQxypvscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpoddv1vscentptetaneg", "hpoddv1vscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - histos.add("hpevenv1vscentptetaneg", "hpevenv1vscentptetaneg", HistType::kTHnSparseF, {centAxis, thnAxispT, etaAxis, spAxis}, true); - - histos.add("hpQxtQxpvscent", "hpQxtQxpvscent", HistType::kTHnSparseF, {centAxis, spAxis}, true); - histos.add("hpQytQypvscent", "hpQytQypvscent", HistType::kTHnSparseF, {centAxis, spAxis}, true); - histos.add("hpQxytpvscent", "hpQxytpvscent", HistType::kTHnSparseF, {centAxis, spAxis}, true); - histos.add("hpQxtQypvscent", "hpQxtQypvscent", HistType::kTHnSparseF, {centAxis, spAxis}, true); - histos.add("hpQxpQytvscent", "hpQxpQytvscent", HistType::kTHnSparseF, {centAxis, spAxis}, true); - - histos.add("hpQxpvscent", "hpQxpvscent", HistType::kTHnSparseF, {centAxis, spAxis}, true); - histos.add("hpQxtvscent", "hpQxtvscent", HistType::kTHnSparseF, {centAxis, spAxis}, true); - histos.add("hpQypvscent", "hpQypvscent", HistType::kTHnSparseF, {centAxis, spAxis}, true); - histos.add("hpQytvscent", "hpQytvscent", HistType::kTHnSparseF, {centAxis, spAxis}, true); + if (useprofile == 2) { + histos.add("hpuxQxpvscentpteta", "hpuxQxpvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuyQypvscentpteta", "hpuyQypvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuxQxtvscentpteta", "hpuxQxtvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuyQytvscentpteta", "hpuyQytvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuxyQxytvscentpteta", "hpuxyQxytvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuxyQxypvscentpteta", "hpuxyQxypvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpoddv1vscentpteta", "hpoddv1vscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpevenv1vscentpteta", "hpevenv1vscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpv21", "hpv21", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpv22", "hpv22", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpv23", "hpv23", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx2Tx1Ax1Cvscentpteta", "hpx2Tx1Ax1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx2Ty1Ay1Cvscentpteta", "hpx2Ty1Ay1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy2Tx1Ay1Cvscentpteta", "hpy2Tx1Ay1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy2Ty1Ax1Cvscentpteta", "hpy2Ty1Ax1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx1Ax1Cvscentpteta", "hpx1Ax1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy1Ay1Cvscentpteta", "hpy1Ay1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx1Avscentpteta", "hpx1Avscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx1Cvscentpteta", "hpx1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy1Avscentpteta", "hpy1Avscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy1Cvscentpteta", "hpy1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + + histos.add("hpx2Tx1Avscentpteta", "hpx2Tx1Avscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx2Tx1Cvscentpteta", "hpx2Tx1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx2Ty1Avscentpteta", "hpx2Ty1Avscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx2Ty1Cvscentpteta", "hpx2Ty1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy2Tx1Avscentpteta", "hpy2Tx1Avscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy2Ty1Cvscentpteta", "hpy2Ty1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy2Ty1Avscentpteta", "hpy2Ty1Avscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy2Tx1Cvscentpteta", "hpy2Tx1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx1Ay1Cvscentpteta", "hpx1Ay1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy1Ax1Cvscentpteta", "hpy1Ax1Cvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpx2Tvscentpteta", "hpx2Tvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpy2Tvscentpteta", "hpy2Tvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + + histos.add("hpuxvscentpteta", "hpuxvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuyvscentpteta", "hpuyvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + /* + histos.add("hpuxvscentptetaneg", "hpuxvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + histos.add("hpuyvscentptetaneg", "hpuyvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + + histos.add("hpuxQxpvscentptetaneg", "hpuxQxpvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + histos.add("hpuyQypvscentptetaneg", "hpuyQypvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + histos.add("hpuxQxtvscentptetaneg", "hpuxQxtvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + histos.add("hpuyQytvscentptetaneg", "hpuyQytvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + histos.add("hpuxyQxytvscentptetaneg", "hpuxyQxytvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + histos.add("hpuxyQxypvscentptetaneg", "hpuxyQxypvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + histos.add("hpoddv1vscentptetaneg", "hpoddv1vscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + histos.add("hpevenv1vscentptetaneg", "hpevenv1vscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); + */ + + histos.add("hpQxtQxpvscent", "hpQxtQxpvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQytQypvscent", "hpQytQypvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQxytpvscent", "hpQxytpvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQxtQypvscent", "hpQxtQypvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQxpQytvscent", "hpQxpQytvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + + histos.add("hpQxpvscent", "hpQxpvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQxtvscent", "hpQxtvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQypvscent", "hpQypvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQytvscent", "hpQytvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); } else { - histos.add("hpuxQxpvscentpteta", "hpuxQxpvscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuyQypvscentpteta", "hpuyQypvscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuxQxtvscentpteta", "hpuxQxtvscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuyQytvscentpteta", "hpuyQytvscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuxyQxytvscentpteta", "hpuxyQxytvscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuxyQxypvscentpteta", "hpuxyQxypvscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpoddv1vscentpteta", "hpoddv1vscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpevenv1vscentpteta", "hpevenv1vscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - - histos.add("hpuxvscentpteta", "hpuxvscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuyvscentpteta", "hpuyvscentpteta", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuxvscentptetaneg", "hpuxvscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuyvscentptetaneg", "hpuyvscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - - histos.add("hpuxQxpvscentptetaneg", "hpuxQxpvscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuyQypvscentptetaneg", "hpuyQypvscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuxQxtvscentptetaneg", "hpuxQxtvscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuyQytvscentptetaneg", "hpuyQytvscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuxyQxytvscentptetaneg", "hpuxyQxytvscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpuxyQxypvscentptetaneg", "hpuxyQxypvscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpoddv1vscentptetaneg", "hpoddv1vscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - histos.add("hpevenv1vscentptetaneg", "hpevenv1vscentptetaneg", HistType::kTHnSparseF, {configcentAxis, configthnAxispT, configetaAxis, spAxis}, true); - - histos.add("hpQxtQxpvscent", "hpQxtQxpvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); - histos.add("hpQytQypvscent", "hpQytQypvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); - histos.add("hpQxytpvscent", "hpQxytpvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); - histos.add("hpQxtQypvscent", "hpQxtQypvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); - histos.add("hpQxpQytvscent", "hpQxpQytvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); - - histos.add("hpQxpvscent", "hpQxpvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); - histos.add("hpQxtvscent", "hpQxtvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); - histos.add("hpQypvscent", "hpQypvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); - histos.add("hpQytvscent", "hpQytvscent", HistType::kTHnSparseF, {configcentAxis, spAxis}, true); - } - } - - histos.add("hCentrality", "Centrality distribution", kTH1F, {{centAxis}}); + histos.add("hpuxQxpvscentpteta", "hpuxQxpvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuyQypvscentpteta", "hpuyQypvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuxQxtvscentpteta", "hpuxQxtvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuyQytvscentpteta", "hpuyQytvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuxyQxytvscentpteta", "hpuxyQxytvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuxyQxypvscentpteta", "hpuxyQxypvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpoddv1vscentpteta", "hpoddv1vscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpevenv1vscentpteta", "hpevenv1vscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + + histos.add("hpuxvscentpteta", "hpuxvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuyvscentpteta", "hpuyvscentpteta", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + /*histos.add("hpuxvscentptetaneg", "hpuxvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuyvscentptetaneg", "hpuyvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + + histos.add("hpuxQxpvscentptetaneg", "hpuxQxpvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuyQypvscentptetaneg", "hpuyQypvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuxQxtvscentptetaneg", "hpuxQxtvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuyQytvscentptetaneg", "hpuyQytvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuxyQxytvscentptetaneg", "hpuxyQxytvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpuxyQxypvscentptetaneg", "hpuxyQxypvscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpoddv1vscentptetaneg", "hpoddv1vscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true); + histos.add("hpevenv1vscentptetaneg", "hpevenv1vscentptetaneg", HistType::kTHnSparseF, {axisGrp.configcentAxis, axisGrp.configthnAxispT, axisGrp.configetaAxis, spAxis}, true);*/ + + histos.add("hpQxtQxpvscent", "hpQxtQxpvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQytQypvscent", "hpQytQypvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQxytpvscent", "hpQxytpvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQxtQypvscent", "hpQxtQypvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQxpQytvscent", "hpQxpQytvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + + histos.add("hpQxpvscent", "hpQxpvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQxtvscent", "hpQxtvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQypvscent", "hpQypvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + histos.add("hpQytvscent", "hpQytvscent", HistType::kTHnSparseF, {axisGrp.configcentAxis, spAxis}, true); + } + } + + histos.add("hCentrality", "Centrality distribution", kTH1F, {{axisGrp.configcentAxis}}); // histos.add("hpsiApsiC", "hpsiApsiC", kTHnSparseF, {psiACAxis, psiACAxis}); // histos.add("hpsiApsiC", "hpsiApsiC", kTH2F, {psiACAxis, psiACAxis}); // histos.add("hphiminuspsiA", "hphiminuspisA", kTH1F, {{50, 0, 6.28}}, true); @@ -291,46 +323,63 @@ struct lambdapolsp { if (!checkwithpub) { // histos.add("hVtxZ", "Vertex distribution in Z;Z (cm)", kTH1F, {{20, -10.0, 10.0}}); - histos.add("hpRes", "hpRes", HistType::kTHnSparseF, {configcentAxis, thnAxisres}); - if (QA) { - histos.add("hpResSin", "hpResSin", HistType::kTHnSparseF, {configcentAxis, thnAxisres}); - histos.add("hpCosPsiA", "hpCosPsiA", HistType::kTHnSparseF, {configcentAxis, thnAxisres}); - histos.add("hpCosPsiC", "hpCosPsiC", HistType::kTHnSparseF, {configcentAxis, thnAxisres}); - histos.add("hpSinPsiA", "hpSinPsiA", HistType::kTHnSparseF, {configcentAxis, thnAxisres}); - histos.add("hpSinPsiC", "hpSinPsiC", HistType::kTHnSparseF, {configcentAxis, thnAxisres}); - /*histos.add("hcentQxZDCA", "hcentQxZDCA", kTH2F, {{centAxis}, {qxZDCAxis}}); - histos.add("hcentQyZDCA", "hcentQyZDCA", kTH2F, {{centAxis}, {qxZDCAxis}}); - histos.add("hcentQxZDCC", "hcentQxZDCC", kTH2F, {{centAxis}, {qxZDCAxis}}); - histos.add("hcentQyZDCC", "hcentQyZDCC", kTH2F, {{centAxis}, {qxZDCAxis}});*/ - } - histos.add("hSparseLambdaPolA", "hSparseLambdaPolA", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseLambdaPolC", "hSparseLambdaPolC", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseAntiLambdaPolA", "hSparseAntiLambdaPolA", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseAntiLambdaPolC", "hSparseAntiLambdaPolC", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - - histos.add("hSparseLambda_corr1a", "hSparseLambda_corr1a", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseLambda_corr1b", "hSparseLambda_corr1b", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseLambda_corr1c", "hSparseLambda_corr1c", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configphiAxis, configcentAxis}, true); - histos.add("hSparseAntiLambda_corr1a", "hSparseAntiLambda_corr1a", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseAntiLambda_corr1b", "hSparseAntiLambda_corr1b", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseAntiLambda_corr1c", "hSparseAntiLambda_corr1c", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configphiAxis, configcentAxis}, true); - - histos.add("hSparseLambda_corr2a", "hSparseLambda_corr2a", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseLambda_corr2b", "hSparseLambda_corr2b", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseAntiLambda_corr2a", "hSparseAntiLambda_corr2a", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); - histos.add("hSparseAntiLambda_corr2b", "hSparseAntiLambda_corr2b", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configetaAxis, configthnAxisPol, configcentAxis}, true); + histos.add("hpRes", "hpRes", HistType::kTHnSparseF, {axisGrp.configcentAxis, thnAxisres}); + histos.add("hpResSin", "hpResSin", HistType::kTHnSparseF, {axisGrp.configcentAxis, thnAxisres}); + /*histos.add("hpCosPsiA", "hpCosPsiA", HistType::kTHnSparseF, {axisGrp.configcentAxis, thnAxisres}); + histos.add("hpCosPsiC", "hpCosPsiC", HistType::kTHnSparseF, {axisGrp.configcentAxis, thnAxisres}); + histos.add("hpSinPsiA", "hpSinPsiA", HistType::kTHnSparseF, {axisGrp.configcentAxis, thnAxisres}); + histos.add("hpSinPsiC", "hpSinPsiC", HistType::kTHnSparseF, {axisGrp.configcentAxis, thnAxisres});*/ + /*histos.add("hcentQxZDCA", "hcentQxZDCA", kTH2F, {{centAxis}, {qxZDCAxis}}); + histos.add("hcentQyZDCA", "hcentQyZDCA", kTH2F, {{centAxis}, {qxZDCAxis}}); + histos.add("hcentQxZDCC", "hcentQxZDCC", kTH2F, {{centAxis}, {qxZDCAxis}}); + histos.add("hcentQyZDCC", "hcentQyZDCC", kTH2F, {{centAxis}, {qxZDCAxis}});*/ + + if (usesubdet) { + histos.add("hSparseLambdaCosPsiA", "hSparseLambdaCosPsiA", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseLambdaSinPsiA", "hSparseLambdaSinPsiA", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseLambdaCosPsiC", "hSparseLambdaCosPsiC", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseLambdaSinPsiC", "hSparseLambdaSinPsiC", HistType::kTHnSparseF, runaxes, true); + } + histos.add("hSparseLambdaCosPsi", "hSparseLambdaCosPsi", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseLambdaSinPsi", "hSparseLambdaSinPsi", HistType::kTHnSparseF, runaxes, true); + if (usesubdet) { + histos.add("hSparseAntiLambdaCosPsiA", "hSparseAntiLambdaCosPsiA", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseAntiLambdaSinPsiA", "hSparseAntiLambdaSinPsiA", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseAntiLambdaCosPsiC", "hSparseAntiLambdaCosPsiC", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseAntiLambdaSinPsiC", "hSparseAntiLambdaSinPsiC", HistType::kTHnSparseF, runaxes, true); + } + histos.add("hSparseAntiLambdaCosPsi", "hSparseAntiLambdaCosPsi", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseAntiLambdaSinPsi", "hSparseAntiLambdaSinPsi", HistType::kTHnSparseF, runaxes, true); + + histos.add("hSparseLambdaPol", "hSparseLambdaPol", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseLambdaPolwgt", "hSparseLambdaPolwgt", HistType::kTHnSparseF, runaxes, true); + if (usesubdet) { + histos.add("hSparseLambdaPolA", "hSparseLambdaPolA", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseLambdaPolC", "hSparseLambdaPolC", HistType::kTHnSparseF, runaxes, true); + } + histos.add("hSparseAntiLambdaPol", "hSparseAntiLambdaPol", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseAntiLambdaPolwgt", "hSparseAntiLambdaPolwgt", HistType::kTHnSparseF, runaxes, true); + if (usesubdet) { + histos.add("hSparseAntiLambdaPolA", "hSparseAntiLambdaPolA", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseAntiLambdaPolC", "hSparseAntiLambdaPolC", HistType::kTHnSparseF, runaxes, true); + } + histos.add("hSparseLambda_corr1a", "hSparseLambda_corr1a", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseLambda_corr1b", "hSparseLambda_corr1b", HistType::kTHnSparseF, runaxes, true); + // histos.add("hSparseLambda_corr1c", "hSparseLambda_corr1c", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configphiAxis, configcentAxis, configbinAxis}, true); + histos.add("hSparseAntiLambda_corr1a", "hSparseAntiLambda_corr1a", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseAntiLambda_corr1b", "hSparseAntiLambda_corr1b", HistType::kTHnSparseF, runaxes, true); + // histos.add("hSparseAntiLambda_corr1c", "hSparseAntiLambda_corr1c", HistType::kTHnSparseF, {thnAxisInvMass, configthnAxispT, configphiAxis, configcentAxis, configbinAxis}, true); + + histos.add("hSparseLambda_corr2a", "hSparseLambda_corr2a", HistType::kTHnSparseF, runaxes, true); + // histos.add("hSparseLambda_corr2b", "hSparseLambda_corr2b", HistType::kTHnSparseF, runaxes, true); + histos.add("hSparseAntiLambda_corr2a", "hSparseAntiLambda_corr2a", HistType::kTHnSparseF, runaxes, true); + // histos.add("hSparseAntiLambda_corr2b", "hSparseAntiLambda_corr2b", HistType::kTHnSparseF, runaxes, true); } } template bool selectionTrack(const T& candidate) { - /* - if (mycut) { - if (!candidate.isGlobalTrack() || !candidate.isPVContributor() || !(candidate.itsNCls() > cfgITScluster) || !(candidate.tpcNClsFound() > cfgTPCcluster) || !(candidate.itsNClsInnerBarrel() >= 1)) { - return false; - } - } else {*/ if (!(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster && candidate.itsNClsInnerBarrel() >= 1)) { return false; } @@ -344,24 +393,18 @@ struct lambdapolsp { return false; } const float pT = candidate.pt(); - // const std::vector decVtx = {candidate.x(), candidate.y(), candidate.z()}; const float tranRad = candidate.v0radius(); const float dcaDaughv0 = TMath::Abs(candidate.dcaV0daughters()); const float cpav0 = candidate.v0cosPA(); float CtauLambda = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massLambda; + float CtauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massK0s; // float lowmasscutlambda = cMinLambdaMass; // float highmasscutlambda = cMaxLambdaMass; if (pT < ConfV0PtMin) { return false; } - if (TMath::Abs(candidate.dcapostopv()) < cMinV0DCA) { - return false; - } - if (TMath::Abs(candidate.dcanegtopv()) < cMinV0DCA) { - return false; - } if (dcaDaughv0 > ConfV0DCADaughMax) { return false; } @@ -374,45 +417,39 @@ struct lambdapolsp { if (tranRad > ConfV0TranRadV0Max) { return false; } - if (TMath::Abs(CtauLambda) > cMaxV0LifeTime) { + if (analyzeLambda && TMath::Abs(CtauLambda) > cMaxV0LifeTime) { return false; } - if (TMath::Abs(candidate.yLambda()) > ConfV0Rap) { + if (analyzeK0s && TMath::Abs(CtauK0s) > cMaxV0LifeTime) { + return false; + } + if (analyzeLambda && TMath::Abs(candidate.yLambda()) > ConfV0Rap) { + return false; + } + if (analyzeK0s && TMath::Abs(candidate.yK0Short()) > ConfV0Rap) { return false; } return true; } - template - bool isSelectedV0Daughter(T const& track, int pid) + + template + bool isSelectedV0Daughter(V0 const& candidate, T const& track, int pid) { - const auto eta = track.eta(); - const auto pt = track.pt(); + // const auto eta = track.eta(); + // const auto pt = track.pt(); const auto tpcNClsF = track.tpcNClsFound(); - // const auto dcaXY = track.dcaXY(); - // const auto sign = track.sign(); - /* - if (charge < 0 && sign > 0) { - return false; - } - if (charge > 0 && sign < 0) { - return false; - }*/ - if (track.tpcNClsCrossedRows() < 70) { + if (track.tpcNClsCrossedRows() < cfgTPCcluster) { return false; } - if (TMath::Abs(eta) > ConfDaughEta) { + /*if (TMath::Abs(eta) > ConfDaughEta) { return false; - } + }*/ if (tpcNClsF < ConfDaughTPCnclsMin) { return false; } - if (track.tpcCrossedRowsOverFindableCls() < 0.8) { + if (track.tpcCrossedRowsOverFindableCls() < rcrfc) { return false; } - /* - if (TMath::Abs(dcaXY) < ConfDaughDCAMin) { - return false; - }*/ if (pid == 0 && TMath::Abs(track.tpcNSigmaPr()) > ConfDaughPIDCuts) { return false; @@ -420,11 +457,20 @@ struct lambdapolsp { if (pid == 1 && TMath::Abs(track.tpcNSigmaPi()) > ConfDaughPIDCuts) { return false; } + if (pid == 0 && (candidate.positivept() < cfgDaughPrPt || candidate.negativept() < cfgDaughPiPt)) { + return false; // doesn´t pass lambda pT sels + } + if (pid == 1 && (candidate.positivept() < cfgDaughPiPt || candidate.negativept() < cfgDaughPrPt)) { + return false; // doesn´t pass antilambda pT sels + } + if (std::abs(candidate.positiveeta()) > ConfDaughEta || std::abs(candidate.negativeeta()) > ConfDaughEta) { + return false; + } - if (pid == 0 && pt < cfgDaughPrPt) { + if (pid == 0 && (TMath::Abs(candidate.dcapostopv()) < cMinV0DCAPr || TMath::Abs(candidate.dcanegtopv()) < cMinV0DCAPi)) { return false; } - if (pid == 1 && pt < cfgDaughPiPt) { + if (pid == 1 && (TMath::Abs(candidate.dcapostopv()) < cMinV0DCAPi || TMath::Abs(candidate.dcanegtopv()) < cMinV0DCAPr)) { return false; } @@ -452,13 +498,14 @@ struct lambdapolsp { } // check TPC tracking properties - if (posTrackExtra.tpcNClsCrossedRows() < 70 || negTrackExtra.tpcNClsCrossedRows() < 70) { + + if (posTrackExtra.tpcNClsCrossedRows() < cfgTPCcluster || negTrackExtra.tpcNClsCrossedRows() < cfgTPCcluster) { return false; } if (posTrackExtra.tpcNClsFound() < ConfDaughTPCnclsMin || negTrackExtra.tpcNClsFound() < ConfDaughTPCnclsMin) { return false; } - if (posTrackExtra.tpcCrossedRowsOverFindableCls() < 0.8 || negTrackExtra.tpcCrossedRowsOverFindableCls() < 0.8) { + if (posTrackExtra.tpcCrossedRowsOverFindableCls() < rcrfc || negTrackExtra.tpcCrossedRowsOverFindableCls() < rcrfc) { return false; } @@ -470,19 +517,70 @@ struct lambdapolsp { return false; } + if (pid == 0 && (TMath::Abs(v0.dcapostopv()) < cMinV0DCAPr || TMath::Abs(v0.dcanegtopv()) < cMinV0DCAPi)) { + return false; + } + if (pid == 1 && (TMath::Abs(v0.dcapostopv()) < cMinV0DCAPi || TMath::Abs(v0.dcanegtopv()) < cMinV0DCAPr)) { + return false; + } + // if we made it this far, it's good return true; } - double GetPhiInRange(double phi) + template + bool isCompatibleK0s(TV0 const& v0) { - double result = phi; - while (result < 0) { - result = result + 2. * TMath::Pi(); + // checks if this V0 is compatible with the requested hypothesis + + // de-ref track extras + auto posTrackExtra = v0.template posTrackExtra_as(); + auto negTrackExtra = v0.template negTrackExtra_as(); + + // check for desired kinematics + if ((v0.positivept() < cfgDaughPrPt || v0.negativept() < cfgDaughPiPt)) { + return false; // doesn´t pass lambda pT sels + } + if (std::abs(v0.positiveeta()) > ConfDaughEta || std::abs(v0.negativeeta()) > ConfDaughEta) { + return false; } - while (result > 2. * TMath::Pi()) { - result = result - 2. * TMath::Pi(); + // check TPC tracking properties + if (posTrackExtra.tpcNClsCrossedRows() < cfgTPCcluster || negTrackExtra.tpcNClsCrossedRows() < cfgTPCcluster) { + return false; + } + if (posTrackExtra.tpcNClsFound() < ConfDaughTPCnclsMin || negTrackExtra.tpcNClsFound() < ConfDaughTPCnclsMin) { + return false; + } + if (posTrackExtra.tpcCrossedRowsOverFindableCls() < rcrfc || negTrackExtra.tpcCrossedRowsOverFindableCls() < rcrfc) { + return false; } + // check TPC PID + if (((std::abs(posTrackExtra.tpcNSigmaPi()) > ConfDaughPIDCuts) || (std::abs(negTrackExtra.tpcNSigmaPi()) > ConfDaughPIDCuts))) { + return false; + } + if ((TMath::Abs(v0.dcapostopv()) < cMinV0DCAPi || TMath::Abs(v0.dcanegtopv()) < cMinV0DCAPi)) { + return false; + } + if ((v0.qtarm() / (std::abs(v0.alpha()))) < qtArmenterosMinForK0) { + return false; + } + // if we made it this far, it's good + return true; + } + + double GetPhiInRange(double phi) + { + double result = RecoDecay::constrainAngle(phi); + /* + double result = phi; + while (result < 0) { + // result = result + 2. * TMath::Pi(); + result = result + 2. * o2::constants::math::PI; + } + while (result > 2. * TMath::Pi()) { + // result = result - 2. * TMath::Pi(); + result = result - 2. * o2::constants::math::PI; + }*/ return result; } @@ -499,51 +597,133 @@ struct lambdapolsp { void fillHistograms(bool tag1, bool tag2, const ROOT::Math::PxPyPzMVector& particle, const ROOT::Math::PxPyPzMVector& daughter, - double psiZDCC, double psiZDCA, double centrality, - double candmass, double candpt, double candeta) + double psiZDCC, double psiZDCA, double psiZDC, double centrality, + double candmass, double candpt, float desbinvalue, double acvalue) { + TRandom3 randPhi(0); ROOT::Math::Boost boost{particle.BoostToCM()}; auto fourVecDauCM = boost(daughter); auto phiangle = TMath::ATan2(fourVecDauCM.Py(), fourVecDauCM.Px()); - + if (randGrp.doRandomPhi) { + phiangle = randPhi.Uniform(0, 2 * TMath::Pi()); + } auto phiminuspsiC = GetPhiInRange(phiangle - psiZDCC); auto phiminuspsiA = GetPhiInRange(phiangle - psiZDCA); + auto phiminuspsi = GetPhiInRange(phiangle - psiZDC); auto cosThetaStar = fourVecDauCM.Pz() / fourVecDauCM.P(); auto sinThetaStar = TMath::Sqrt(1 - (cosThetaStar * cosThetaStar)); auto PolC = TMath::Sin(phiminuspsiC); auto PolA = TMath::Sin(phiminuspsiA); + auto Pol = TMath::Sin(phiminuspsi); auto sinPhiStar = TMath::Sin(GetPhiInRange(phiangle)); auto cosPhiStar = TMath::Cos(GetPhiInRange(phiangle)); - auto sinThetaStarcosphiphiStar = sinThetaStar * TMath::Cos(2 * GetPhiInRange(particle.Phi() - phiangle)); - auto phiphiStar = GetPhiInRange(particle.Phi() - phiangle); + // auto sinThetaStarcosphiphiStar = sinThetaStar * TMath::Cos(2 * GetPhiInRange(particle.Phi() - phiangle)); + // auto phiphiStar = GetPhiInRange(particle.Phi() - phiangle); + + acvalue = (4 / 3.14) * acvalue; + // PolC = PolC / acvalue; + // PolA = PolA / acvalue; + // Pol = Pol / acvalue; + auto Polwgt = Pol / acvalue; // Fill histograms using constructed names if (tag2) { - histos.fill(HIST("hSparseAntiLambdaPolA"), candmass, candpt, candeta, PolA, centrality); - histos.fill(HIST("hSparseAntiLambdaPolC"), candmass, candpt, candeta, PolC, centrality); - histos.fill(HIST("hSparseAntiLambda_corr1a"), candmass, candpt, candeta, sinPhiStar, centrality); - histos.fill(HIST("hSparseAntiLambda_corr1b"), candmass, candpt, candeta, cosPhiStar, centrality); - histos.fill(HIST("hSparseAntiLambda_corr1c"), candmass, candpt, candeta, phiphiStar, centrality); - histos.fill(HIST("hSparseAntiLambda_corr2a"), candmass, candpt, candeta, sinThetaStar, centrality); - histos.fill(HIST("hSparseAntiLambda_corr2b"), candmass, candpt, candeta, sinThetaStarcosphiphiStar, centrality); + if (needetaaxis) { + if (usesubdet) { + histos.fill(HIST("hSparseAntiLambdaCosPsiA"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDCA))), centrality, desbinvalue); + histos.fill(HIST("hSparseAntiLambdaCosPsiC"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDCC))), centrality, desbinvalue); + histos.fill(HIST("hSparseAntiLambdaSinPsiA"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDCA))), centrality, desbinvalue); + histos.fill(HIST("hSparseAntiLambdaSinPsiC"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDCC))), centrality, desbinvalue); + } + histos.fill(HIST("hSparseAntiLambdaCosPsi"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDC))), centrality, desbinvalue); + histos.fill(HIST("hSparseAntiLambdaSinPsi"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDC))), centrality, desbinvalue); + if (usesubdet) { + histos.fill(HIST("hSparseAntiLambdaPolA"), candmass, candpt, PolA, centrality, desbinvalue); + histos.fill(HIST("hSparseAntiLambdaPolC"), candmass, candpt, PolC, centrality, desbinvalue); + } + histos.fill(HIST("hSparseAntiLambdaPol"), candmass, candpt, Pol, centrality, desbinvalue); + histos.fill(HIST("hSparseAntiLambdaPolwgt"), candmass, candpt, Polwgt, centrality, desbinvalue); + histos.fill(HIST("hSparseAntiLambda_corr1a"), candmass, candpt, sinPhiStar, centrality, desbinvalue); + histos.fill(HIST("hSparseAntiLambda_corr1b"), candmass, candpt, cosPhiStar, centrality, desbinvalue); + // histos.fill(HIST("hSparseAntiLambda_corr1c"), candmass, candpt, phiphiStar, centrality, desbinvalue); + histos.fill(HIST("hSparseAntiLambda_corr2a"), candmass, candpt, sinThetaStar, centrality, desbinvalue); + // histos.fill(HIST("hSparseAntiLambda_corr2b"), candmass, candpt, sinThetaStarcosphiphiStar, centrality, desbinvalue); + } else { + if (usesubdet) { + histos.fill(HIST("hSparseAntiLambdaCosPsiA"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDCA))), centrality); + histos.fill(HIST("hSparseAntiLambdaCosPsiC"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDCC))), centrality); + histos.fill(HIST("hSparseAntiLambdaSinPsiA"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDCA))), centrality); + histos.fill(HIST("hSparseAntiLambdaSinPsiC"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDCC))), centrality); + } + histos.fill(HIST("hSparseAntiLambdaCosPsi"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDC))), centrality); + histos.fill(HIST("hSparseAntiLambdaSinPsi"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDC))), centrality); + if (usesubdet) { + histos.fill(HIST("hSparseAntiLambdaPolA"), candmass, candpt, PolA, centrality); + histos.fill(HIST("hSparseAntiLambdaPolC"), candmass, candpt, PolC, centrality); + } + histos.fill(HIST("hSparseAntiLambdaPol"), candmass, candpt, Pol, centrality); + histos.fill(HIST("hSparseAntiLambdaPolwgt"), candmass, candpt, Polwgt, centrality); + histos.fill(HIST("hSparseAntiLambda_corr1a"), candmass, candpt, sinPhiStar, centrality); + histos.fill(HIST("hSparseAntiLambda_corr1b"), candmass, candpt, cosPhiStar, centrality); + // histos.fill(HIST("hSparseAntiLambda_corr1c"), candmass, candpt, phiphiStar, centrality); + histos.fill(HIST("hSparseAntiLambda_corr2a"), candmass, candpt, sinThetaStar, centrality); + // histos.fill(HIST("hSparseAntiLambda_corr2b"), candmass, candpt, sinThetaStarcosphiphiStar, centrality); + } } if (tag1) { - histos.fill(HIST("hSparseLambdaPolA"), candmass, candpt, candeta, PolA, centrality); - histos.fill(HIST("hSparseLambdaPolC"), candmass, candpt, candeta, PolC, centrality); - histos.fill(HIST("hSparseLambda_corr1a"), candmass, candpt, candeta, sinPhiStar, centrality); - histos.fill(HIST("hSparseLambda_corr1b"), candmass, candpt, candeta, cosPhiStar, centrality); - histos.fill(HIST("hSparseLambda_corr1c"), candmass, candpt, candeta, phiphiStar, centrality); - histos.fill(HIST("hSparseLambda_corr2a"), candmass, candpt, candeta, sinThetaStar, centrality); - histos.fill(HIST("hSparseLambda_corr2b"), candmass, candpt, candeta, sinThetaStarcosphiphiStar, centrality); + if (needetaaxis) { + if (usesubdet) { + histos.fill(HIST("hSparseLambdaCosPsiA"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDCA))), centrality, desbinvalue); + histos.fill(HIST("hSparseLambdaCosPsiC"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDCC))), centrality, desbinvalue); + histos.fill(HIST("hSparseLambdaSinPsiA"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDCA))), centrality, desbinvalue); + histos.fill(HIST("hSparseLambdaSinPsiC"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDCC))), centrality, desbinvalue); + } + histos.fill(HIST("hSparseLambdaCosPsi"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDC))), centrality, desbinvalue); + histos.fill(HIST("hSparseLambdaSinPsi"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDC))), centrality, desbinvalue); + if (usesubdet) { + histos.fill(HIST("hSparseLambdaPolA"), candmass, candpt, PolA, centrality, desbinvalue); + histos.fill(HIST("hSparseLambdaPolC"), candmass, candpt, PolC, centrality, desbinvalue); + } + histos.fill(HIST("hSparseLambdaPol"), candmass, candpt, Pol, centrality, desbinvalue); + histos.fill(HIST("hSparseLambdaPolwgt"), candmass, candpt, Polwgt, centrality, desbinvalue); + histos.fill(HIST("hSparseLambda_corr1a"), candmass, candpt, sinPhiStar, centrality, desbinvalue); + histos.fill(HIST("hSparseLambda_corr1b"), candmass, candpt, cosPhiStar, centrality, desbinvalue); + // histos.fill(HIST("hSparseLambda_corr1c"), candmass, candpt, phiphiStar, centrality, desbinvalue); + histos.fill(HIST("hSparseLambda_corr2a"), candmass, candpt, sinThetaStar, centrality, desbinvalue); + // histos.fill(HIST("hSparseLambda_corr2b"), candmass, candpt, sinThetaStarcosphiphiStar, centrality, desbinvalue); + } else { + if (usesubdet) { + histos.fill(HIST("hSparseLambdaCosPsiA"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDCA))), centrality); + histos.fill(HIST("hSparseLambdaCosPsiC"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDCC))), centrality); + histos.fill(HIST("hSparseLambdaSinPsiA"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDCA))), centrality); + histos.fill(HIST("hSparseLambdaSinPsiC"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDCC))), centrality); + } + histos.fill(HIST("hSparseLambdaCosPsi"), candmass, candpt, (TMath::Cos(GetPhiInRange(psiZDC))), centrality); + histos.fill(HIST("hSparseLambdaSinPsi"), candmass, candpt, (TMath::Sin(GetPhiInRange(psiZDC))), centrality); + if (usesubdet) { + histos.fill(HIST("hSparseLambdaPolA"), candmass, candpt, PolA, centrality); + histos.fill(HIST("hSparseLambdaPolC"), candmass, candpt, PolC, centrality); + } + histos.fill(HIST("hSparseLambdaPol"), candmass, candpt, Pol, centrality); + histos.fill(HIST("hSparseLambdaPolwgt"), candmass, candpt, Polwgt, centrality); + histos.fill(HIST("hSparseLambda_corr1a"), candmass, candpt, sinPhiStar, centrality); + histos.fill(HIST("hSparseLambda_corr1b"), candmass, candpt, cosPhiStar, centrality); + // histos.fill(HIST("hSparseLambda_corr1c"), candmass, candpt, phiphiStar, centrality); + histos.fill(HIST("hSparseLambda_corr2a"), candmass, candpt, sinThetaStar, centrality); + // histos.fill(HIST("hSparseLambda_corr2b"), candmass, candpt, sinThetaStarcosphiphiStar, centrality); + } } } - ROOT::Math::PxPyPzMVector Lambda, AntiLambda, Lambdadummy, AntiLambdadummy, Proton, Pion, AntiProton, AntiPion, fourVecDauCM; + ROOT::Math::PxPyPzMVector Lambda, AntiLambda, Lambdadummy, AntiLambdadummy, Proton, Pion, AntiProton, AntiPion, fourVecDauCM, K0sdummy, K0s; ROOT::Math::XYZVector threeVecDauCM, threeVecDauCMXY; double phiangle = 0.0; + // double angleLambda=0.0; + // double angleAntiLambda=0.0; double massLambda = o2::constants::physics::MassLambda; + double massK0s = o2::constants::physics::MassK0Short; double massPr = o2::constants::physics::MassProton; double massPi = o2::constants::physics::MassPionCharged; @@ -553,13 +733,17 @@ struct lambdapolsp { Filter dcaCutFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz); using EventCandidates = soa::Filtered>; - // using AllTrackCandidates = soa::Join; - // using AllTrackCandidates = soa::Filtered>; using AllTrackCandidates = soa::Filtered>; using ResoV0s = aod::V0Datas; - // void processData(EventCandidates::iterator const& collision, AllTrackCandidates const&, ResoV0s const& V0s, aod::BCs const&) - void processData(EventCandidates::iterator const& collision, AllTrackCandidates const& tracks, ResoV0s const& V0s, aod::BCs const&) + TProfile2D* accprofileL; + TProfile2D* accprofileAL; + // int currentRunNumber = -999; + // int lastRunNumber = -999; + + using BCsRun3 = soa::Join; + + void processData(EventCandidates::iterator const& collision, AllTrackCandidates const& tracks, ResoV0s const& V0s, BCsRun3 const&) { if (!collision.sel8()) { @@ -576,7 +760,7 @@ struct lambdapolsp { return; } // histos.fill(HIST("hCentrality2"), centrality); - // if (additionalEvSel2 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + // if (additionalEvSel2 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { if (additionalEvSel2 && (collision.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision.trackOccupancyInTimeRange() < cfgMinOccupancy)) { return; } @@ -585,6 +769,16 @@ struct lambdapolsp { return; } + if (additionalEvSel4 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + + if (rctCut.requireRCTFlagChecker && !rctChecker(collision)) { + return; + } + // currentRunNumber = collision.foundBC_as().runNumber(); + auto bc = collision.foundBC_as(); + auto qxZDCA = collision.qxZDCA(); auto qxZDCC = collision.qxZDCC(); auto qyZDCA = collision.qyZDCA(); @@ -592,31 +786,51 @@ struct lambdapolsp { auto psiZDCC = collision.psiZDCC(); auto psiZDCA = collision.psiZDCA(); + double modqxZDCA; + double modqyZDCA; + double modqxZDCC; + double modqyZDCC; + + if (cqvas) { + modqxZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Cos(psiZDCA); + modqyZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Sin(psiZDCA); + modqxZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Cos(psiZDCC); + modqyZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Sin(psiZDCC); + } else { + modqxZDCA = qxZDCA; + modqyZDCA = qyZDCA; + modqxZDCC = qxZDCC; + modqyZDCC = qyZDCC; + } + + auto psiZDC = TMath::ATan2((modqyZDCC - modqyZDCA), (modqxZDCC - modqxZDCA)); // full event plane + /*if (useonlypsis) { + psiZDC = psiZDCC - psiZDCA; + }*/ + histos.fill(HIST("hCentrality"), centrality); if (!checkwithpub) { // histos.fill(HIST("hVtxZ"), collision.posZ()); histos.fill(HIST("hpRes"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA - psiZDCC)))); - if (QA) { - histos.fill(HIST("hpResSin"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA - psiZDCC)))); - histos.fill(HIST("hpCosPsiA"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA)))); - histos.fill(HIST("hpCosPsiC"), centrality, (TMath::Cos(GetPhiInRange(psiZDCC)))); - histos.fill(HIST("hpSinPsiA"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA)))); - histos.fill(HIST("hpSinPsiC"), centrality, (TMath::Sin(GetPhiInRange(psiZDCC)))); - /*histos.fill(HIST("hcentQxZDCA"), centrality, qxZDCA); + histos.fill(HIST("hpResSin"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA - psiZDCC)))); + /*histos.fill(HIST("hpCosPsiA"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA)))); + histos.fill(HIST("hpCosPsiC"), centrality, (TMath::Cos(GetPhiInRange(psiZDCC)))); + histos.fill(HIST("hpSinPsiA"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA)))); + histos.fill(HIST("hpSinPsiC"), centrality, (TMath::Sin(GetPhiInRange(psiZDCC))));*/ + /*histos.fill(HIST("hcentQxZDCA"), centrality, qxZDCA); histos.fill(HIST("hcentQyZDCA"), centrality, qyZDCA); histos.fill(HIST("hcentQxZDCC"), centrality, qxZDCC); histos.fill(HIST("hcentQyZDCC"), centrality, qyZDCC);*/ - } } ///////////checking v1//////////////////////////////// if (checkwithpub) { - auto QxtQxp = qxZDCA * qxZDCC; - auto QytQyp = qyZDCA * qyZDCC; + auto QxtQxp = modqxZDCA * modqxZDCC; + auto QytQyp = modqyZDCA * modqyZDCC; auto Qxytp = QxtQxp + QytQyp; - auto QxpQyt = qxZDCA * qyZDCC; - auto QxtQyp = qxZDCC * qyZDCA; + auto QxpQyt = modqxZDCA * modqyZDCC; + auto QxtQyp = modqxZDCC * modqyZDCA; histos.fill(HIST("hpQxtQxpvscent"), centrality, QxtQxp); histos.fill(HIST("hpQytQypvscent"), centrality, QytQyp); @@ -624,12 +838,12 @@ struct lambdapolsp { histos.fill(HIST("hpQxpQytvscent"), centrality, QxpQyt); histos.fill(HIST("hpQxtQypvscent"), centrality, QxtQyp); - histos.fill(HIST("hpQxpvscent"), centrality, qxZDCA); - histos.fill(HIST("hpQxtvscent"), centrality, qxZDCC); - histos.fill(HIST("hpQypvscent"), centrality, qyZDCA); - histos.fill(HIST("hpQytvscent"), centrality, qyZDCC); + histos.fill(HIST("hpQxpvscent"), centrality, modqxZDCA); + histos.fill(HIST("hpQxtvscent"), centrality, modqxZDCC); + histos.fill(HIST("hpQypvscent"), centrality, modqyZDCA); + histos.fill(HIST("hpQytvscent"), centrality, modqyZDCC); - for (auto track : tracks) { + for (const auto& track : tracks) { if (!selectionTrack(track)) { continue; } @@ -640,93 +854,118 @@ struct lambdapolsp { auto ux = TMath::Cos(GetPhiInRange(track.phi())); auto uy = TMath::Sin(GetPhiInRange(track.phi())); + // auto py=track.py(); - auto uxQxp = ux * qxZDCA; - auto uyQyp = uy * qyZDCA; + auto uxQxp = ux * modqxZDCA; + auto uyQyp = uy * modqyZDCA; auto uxyQxyp = uxQxp + uyQyp; - auto uxQxt = ux * qxZDCC; - auto uyQyt = uy * qyZDCC; + auto uxQxt = ux * modqxZDCC; + auto uyQyt = uy * modqyZDCC; auto uxyQxyt = uxQxt + uyQyt; - auto oddv1 = ux * (qxZDCA - qxZDCC) + uy * (qyZDCA - qyZDCC); - auto evenv1 = ux * (qxZDCA + qxZDCC) + uy * (qyZDCA + qyZDCC); - - if (tofhit) { - if (track.hasTOF()) { - if (globalpt) { - histos.fill(HIST("hpuxQxpvscentpteta"), centrality, track.pt(), track.eta(), uxQxp); - histos.fill(HIST("hpuyQypvscentpteta"), centrality, track.pt(), track.eta(), uyQyp); - histos.fill(HIST("hpuxQxtvscentpteta"), centrality, track.pt(), track.eta(), uxQxt); - histos.fill(HIST("hpuyQytvscentpteta"), centrality, track.pt(), track.eta(), uyQyt); - - histos.fill(HIST("hpuxvscentpteta"), centrality, track.pt(), track.eta(), ux); - histos.fill(HIST("hpuyvscentpteta"), centrality, track.pt(), track.eta(), uy); - - histos.fill(HIST("hpuxyQxytvscentpteta"), centrality, track.pt(), track.eta(), uxyQxyt); - histos.fill(HIST("hpuxyQxypvscentpteta"), centrality, track.pt(), track.eta(), uxyQxyp); - histos.fill(HIST("hpoddv1vscentpteta"), centrality, track.pt(), track.eta(), oddv1); - histos.fill(HIST("hpevenv1vscentpteta"), centrality, track.pt(), track.eta(), evenv1); - } else { - histos.fill(HIST("hpuxQxpvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxQxp); - histos.fill(HIST("hpuyQypvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uyQyp); - histos.fill(HIST("hpuxQxtvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxQxt); - histos.fill(HIST("hpuyQytvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uyQyt); - - histos.fill(HIST("hpuxvscentpteta"), centrality, track.pt(), track.eta(), ux); - histos.fill(HIST("hpuyvscentpteta"), centrality, track.pt(), track.eta(), uy); - - histos.fill(HIST("hpuxyQxytvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxyQxyt); - histos.fill(HIST("hpuxyQxypvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxyQxyp); - histos.fill(HIST("hpoddv1vscentpteta"), centrality, track.pt(), track.eta(), oddv1); - histos.fill(HIST("hpevenv1vscentpteta"), centrality, track.pt(), track.eta(), evenv1); - } - } + auto oddv1 = ux * (modqxZDCA - modqxZDCC) + uy * (modqyZDCA - modqyZDCC); + auto evenv1 = ux * (modqxZDCA + modqxZDCC) + uy * (modqyZDCA + modqyZDCC); + auto v21 = TMath::Cos(2 * (GetPhiInRange(track.phi()) - psiZDCA - psiZDCC)); + auto v22 = TMath::Cos(2 * (GetPhiInRange(track.phi()) + psiZDCA - psiZDCC)); + auto v23 = TMath::Cos(2 * (GetPhiInRange(track.phi()) - psiZDC)); + + auto x2Tx1Ax1C = TMath::Cos(2 * GetPhiInRange(track.phi())) * modqxZDCA * modqxZDCC; + auto x2Ty1Ay1C = TMath::Cos(2 * GetPhiInRange(track.phi())) * modqyZDCA * modqyZDCC; + auto y2Tx1Ay1C = TMath::Sin(2 * GetPhiInRange(track.phi())) * modqxZDCA * modqyZDCC; + auto y2Ty1Ax1C = TMath::Sin(2 * GetPhiInRange(track.phi())) * modqyZDCA * modqxZDCC; + auto x1Ax1C = modqxZDCA * modqxZDCC; + auto y1Ay1C = modqyZDCA * modqyZDCC; + auto x1Ay1C = modqxZDCA * modqyZDCC; + auto x1Cy1A = modqxZDCC * modqyZDCA; + + // detector acceptance corrections to match v2{ZDC} + auto x1A = modqxZDCA; + auto x1C = modqxZDCC; + auto y1A = modqyZDCA; + auto y1C = modqyZDCC; + auto x2T = TMath::Cos(2 * GetPhiInRange(track.phi())); + auto y2T = TMath::Sin(2 * GetPhiInRange(track.phi())); + auto x2Tx1A = TMath::Cos(2 * GetPhiInRange(track.phi())) * modqxZDCA; + auto x2Tx1C = TMath::Cos(2 * GetPhiInRange(track.phi())) * modqxZDCC; + auto x2Ty1A = TMath::Cos(2 * GetPhiInRange(track.phi())) * modqyZDCA; + auto x2Ty1C = TMath::Cos(2 * GetPhiInRange(track.phi())) * modqyZDCC; + auto y2Tx1A = TMath::Sin(2 * GetPhiInRange(track.phi())) * modqxZDCA; + auto y2Tx1C = TMath::Sin(2 * GetPhiInRange(track.phi())) * modqxZDCC; + auto y2Ty1A = TMath::Sin(2 * GetPhiInRange(track.phi())) * modqyZDCA; + auto y2Ty1C = TMath::Sin(2 * GetPhiInRange(track.phi())) * modqyZDCC; + + if (globalpt) { + // if (sign > 0) { + histos.fill(HIST("hpuxQxpvscentpteta"), centrality, track.pt(), track.eta(), uxQxp); + histos.fill(HIST("hpuyQypvscentpteta"), centrality, track.pt(), track.eta(), uyQyp); + histos.fill(HIST("hpuxQxtvscentpteta"), centrality, track.pt(), track.eta(), uxQxt); + histos.fill(HIST("hpuyQytvscentpteta"), centrality, track.pt(), track.eta(), uyQyt); + + histos.fill(HIST("hpuxvscentpteta"), centrality, track.pt(), track.eta(), ux); + histos.fill(HIST("hpuyvscentpteta"), centrality, track.pt(), track.eta(), uy); + + histos.fill(HIST("hpuxyQxytvscentpteta"), centrality, track.pt(), track.eta(), uxyQxyt); + histos.fill(HIST("hpuxyQxypvscentpteta"), centrality, track.pt(), track.eta(), uxyQxyp); + histos.fill(HIST("hpoddv1vscentpteta"), centrality, track.pt(), track.eta(), oddv1); + histos.fill(HIST("hpevenv1vscentpteta"), centrality, track.pt(), track.eta(), evenv1); + + histos.fill(HIST("hpv21"), centrality, track.pt(), track.eta(), v21); + histos.fill(HIST("hpv22"), centrality, track.pt(), track.eta(), v22); + histos.fill(HIST("hpv23"), centrality, track.pt(), track.eta(), v23); + + histos.fill(HIST("hpx2Tx1Ax1Cvscentpteta"), centrality, track.pt(), track.eta(), x2Tx1Ax1C); + histos.fill(HIST("hpx2Ty1Ay1Cvscentpteta"), centrality, track.pt(), track.eta(), x2Ty1Ay1C); + histos.fill(HIST("hpy2Tx1Ay1Cvscentpteta"), centrality, track.pt(), track.eta(), y2Tx1Ay1C); + histos.fill(HIST("hpy2Ty1Ax1Cvscentpteta"), centrality, track.pt(), track.eta(), y2Ty1Ax1C); + histos.fill(HIST("hpx2Tvscentpteta"), centrality, track.pt(), track.eta(), x2T); + histos.fill(HIST("hpy2Tvscentpteta"), centrality, track.pt(), track.eta(), y2T); + histos.fill(HIST("hpx2Tx1Avscentpteta"), centrality, track.pt(), track.eta(), x2Tx1A); + histos.fill(HIST("hpx2Tx1Cvscentpteta"), centrality, track.pt(), track.eta(), x2Tx1C); + histos.fill(HIST("hpx2Ty1Avscentpteta"), centrality, track.pt(), track.eta(), x2Ty1A); + histos.fill(HIST("hpx2Ty1Cvscentpteta"), centrality, track.pt(), track.eta(), x2Ty1C); + histos.fill(HIST("hpy2Tx1Avscentpteta"), centrality, track.pt(), track.eta(), y2Tx1A); + histos.fill(HIST("hpy2Ty1Cvscentpteta"), centrality, track.pt(), track.eta(), y2Ty1C); + histos.fill(HIST("hpy2Ty1Avscentpteta"), centrality, track.pt(), track.eta(), y2Ty1A); + histos.fill(HIST("hpy2Tx1Cvscentpteta"), centrality, track.pt(), track.eta(), y2Tx1C); + histos.fill(HIST("hpx1Ax1Cvscentpteta"), centrality, track.pt(), track.eta(), x1Ax1C); + histos.fill(HIST("hpy1Ay1Cvscentpteta"), centrality, track.pt(), track.eta(), y1Ay1C); + histos.fill(HIST("hpx1Ay1Cvscentpteta"), centrality, track.pt(), track.eta(), x1Ay1C); + histos.fill(HIST("hpy1Ax1Cvscentpteta"), centrality, track.pt(), track.eta(), x1Cy1A); + histos.fill(HIST("hpx1Avscentpteta"), centrality, track.pt(), track.eta(), x1A); + histos.fill(HIST("hpx1Cvscentpteta"), centrality, track.pt(), track.eta(), x1C); + histos.fill(HIST("hpy1Avscentpteta"), centrality, track.pt(), track.eta(), y1A); + histos.fill(HIST("hpy1Cvscentpteta"), centrality, track.pt(), track.eta(), y1C); + + /*} else { + histos.fill(HIST("hpuxQxpvscentptetaneg"), centrality, track.pt(), track.eta(), uxQxp); + histos.fill(HIST("hpuyQypvscentptetaneg"), centrality, track.pt(), track.eta(), uyQyp); + histos.fill(HIST("hpuxQxtvscentptetaneg"), centrality, track.pt(), track.eta(), uxQxt); + histos.fill(HIST("hpuyQytvscentptetaneg"), centrality, track.pt(), track.eta(), uyQyt); + + histos.fill(HIST("hpuxvscentptetaneg"), centrality, track.pt(), track.eta(), ux); + histos.fill(HIST("hpuyvscentptetaneg"), centrality, track.pt(), track.eta(), uy); + + histos.fill(HIST("hpuxyQxytvscentptetaneg"), centrality, track.pt(), track.eta(), uxyQxyt); + histos.fill(HIST("hpuxyQxypvscentptetaneg"), centrality, track.pt(), track.eta(), uxyQxyp); + histos.fill(HIST("hpoddv1vscentptetaneg"), centrality, track.pt(), track.eta(), oddv1); + histos.fill(HIST("hpevenv1vscentptetaneg"), centrality, track.pt(), track.eta(), evenv1); + }*/ } else { - if (globalpt) { - if (sign > 0) { - histos.fill(HIST("hpuxQxpvscentpteta"), centrality, track.pt(), track.eta(), uxQxp); - histos.fill(HIST("hpuyQypvscentpteta"), centrality, track.pt(), track.eta(), uyQyp); - histos.fill(HIST("hpuxQxtvscentpteta"), centrality, track.pt(), track.eta(), uxQxt); - histos.fill(HIST("hpuyQytvscentpteta"), centrality, track.pt(), track.eta(), uyQyt); - - histos.fill(HIST("hpuxvscentpteta"), centrality, track.pt(), track.eta(), ux); - histos.fill(HIST("hpuyvscentpteta"), centrality, track.pt(), track.eta(), uy); - - histos.fill(HIST("hpuxyQxytvscentpteta"), centrality, track.pt(), track.eta(), uxyQxyt); - histos.fill(HIST("hpuxyQxypvscentpteta"), centrality, track.pt(), track.eta(), uxyQxyp); - histos.fill(HIST("hpoddv1vscentpteta"), centrality, track.pt(), track.eta(), oddv1); - histos.fill(HIST("hpevenv1vscentpteta"), centrality, track.pt(), track.eta(), evenv1); - } else { - histos.fill(HIST("hpuxQxpvscentptetaneg"), centrality, track.pt(), track.eta(), uxQxp); - histos.fill(HIST("hpuyQypvscentptetaneg"), centrality, track.pt(), track.eta(), uyQyp); - histos.fill(HIST("hpuxQxtvscentptetaneg"), centrality, track.pt(), track.eta(), uxQxt); - histos.fill(HIST("hpuyQytvscentptetaneg"), centrality, track.pt(), track.eta(), uyQyt); - - histos.fill(HIST("hpuxvscentptetaneg"), centrality, track.pt(), track.eta(), ux); - histos.fill(HIST("hpuyvscentptetaneg"), centrality, track.pt(), track.eta(), uy); - - histos.fill(HIST("hpuxyQxytvscentptetaneg"), centrality, track.pt(), track.eta(), uxyQxyt); - histos.fill(HIST("hpuxyQxypvscentptetaneg"), centrality, track.pt(), track.eta(), uxyQxyp); - histos.fill(HIST("hpoddv1vscentptetaneg"), centrality, track.pt(), track.eta(), oddv1); - histos.fill(HIST("hpevenv1vscentptetaneg"), centrality, track.pt(), track.eta(), evenv1); - } - } else { - histos.fill(HIST("hpuxQxpvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxQxp); - histos.fill(HIST("hpuyQypvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uyQyp); - histos.fill(HIST("hpuxQxtvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxQxt); - histos.fill(HIST("hpuyQytvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uyQyt); - - histos.fill(HIST("hpuxvscentpteta"), centrality, track.pt(), track.eta(), ux); - histos.fill(HIST("hpuyvscentpteta"), centrality, track.pt(), track.eta(), uy); - - histos.fill(HIST("hpuxyQxytvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxyQxyt); - histos.fill(HIST("hpuxyQxypvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxyQxyp); - histos.fill(HIST("hpoddv1vscentpteta"), centrality, track.pt(), track.eta(), oddv1); - histos.fill(HIST("hpevenv1vscentpteta"), centrality, track.pt(), track.eta(), evenv1); - } + histos.fill(HIST("hpuxQxpvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxQxp); + histos.fill(HIST("hpuyQypvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uyQyp); + histos.fill(HIST("hpuxQxtvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxQxt); + histos.fill(HIST("hpuyQytvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uyQyt); + + histos.fill(HIST("hpuxvscentpteta"), centrality, track.pt(), track.eta(), ux); + histos.fill(HIST("hpuyvscentpteta"), centrality, track.pt(), track.eta(), uy); + + histos.fill(HIST("hpuxyQxytvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxyQxyt); + histos.fill(HIST("hpuxyQxypvscentpteta"), centrality, track.tpcInnerParam(), track.eta(), uxyQxyp); + histos.fill(HIST("hpoddv1vscentpteta"), centrality, track.pt(), track.eta(), oddv1); + histos.fill(HIST("hpevenv1vscentpteta"), centrality, track.pt(), track.eta(), evenv1); } } } else { - for (auto v0 : V0s) { + for (const auto& v0 : V0s) { auto postrack = v0.template posTrack_as(); auto negtrack = v0.template negTrack_as(); @@ -737,16 +976,14 @@ struct lambdapolsp { const auto signpos = postrack.sign(); const auto signneg = negtrack.sign(); - if (checksign) { - if (signpos < 0 || signneg > 0) { - continue; - } + if (signpos < 0 || signneg > 0) { + continue; } - if (isSelectedV0Daughter(postrack, 0) && isSelectedV0Daughter(negtrack, 1)) { + if (isSelectedV0Daughter(v0, postrack, 0) && isSelectedV0Daughter(v0, negtrack, 1)) { LambdaTag = 1; } - if (isSelectedV0Daughter(negtrack, 0) && isSelectedV0Daughter(postrack, 1)) { + if (isSelectedV0Daughter(v0, negtrack, 0) && isSelectedV0Daughter(v0, postrack, 1)) { aLambdaTag = 1; } @@ -761,34 +998,124 @@ struct lambdapolsp { Proton = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPr); AntiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPi); Lambdadummy = Proton + AntiPion; + // angleLambda = calculateAngleBetweenLorentzVectors(Proton, AntiPion); } if (aLambdaTag) { AntiProton = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPr); Pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPi); AntiLambdadummy = AntiProton + Pion; + // angleAntiLambda = calculateAngleBetweenLorentzVectors(AntiProton, Pion); } if (shouldReject(LambdaTag, aLambdaTag, Lambdadummy, AntiLambdadummy)) { continue; } + if (TMath::Abs(v0.eta()) > 0.8) + continue; + int taga = LambdaTag; int tagb = aLambdaTag; - if (LambdaTag) { - Lambda = Proton + AntiPion; - tagb = 0; - fillHistograms(taga, tagb, Lambda, Proton, psiZDCC, psiZDCA, centrality, v0.mLambda(), v0.pt(), v0.eta()); + // if (useAccCorr && (currentRunNumber != lastRunNumber)) { + if (useAccCorr) { + accprofileL = ccdb->getForTimeStamp(ConfAccPathL.value, bc.timestamp()); + accprofileAL = ccdb->getForTimeStamp(ConfAccPathAL.value, bc.timestamp()); } - tagb = aLambdaTag; - if (aLambdaTag) { - AntiLambda = AntiProton + Pion; - taga = 0; - fillHistograms(taga, tagb, AntiLambda, AntiProton, psiZDCC, psiZDCA, centrality, v0.mAntiLambda(), v0.pt(), v0.eta()); + float desbinvalue = 0.0; + if (dosystematic) { + //////////////////////////////////////////////////// + float LTsys = TMath::Abs(v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massLambda); + float CPAsys = v0.v0cosPA(); + float DCADaughsys = TMath::Abs(v0.dcaV0daughters()); + float DCApossys = TMath::Abs(v0.dcapostopv()); + float DCAnegsys = TMath::Abs(v0.dcanegtopv()); + float sysvar = -999.9; + double syst[10]; + if (sys == 1) { + double temp[10] = {26, 27, 28, 29, 30, 31, 32, 33, 34, 35}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = LTsys; + } + if (sys == 2) { + double temp[10] = {0.992, 0.993, 0.9935, 0.994, 0.9945, 0.995, 0.9955, 0.996, 0.9965, 0.997}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = CPAsys; + } + if (sys == 3) { + double temp[10] = {0.8, 0.85, 0.9, 0.95, 1.0, 1.05, 1.1, 1.15, 1.2, 1.25}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = DCADaughsys; + } + if (sys == 4) { + double temp[10] = {0.05, 0.07, 0.1, 0.15, 0.18, 0.2, 0.22, 0.25, 0.28, 0.3}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = DCApossys; + } + if (sys == 5) { + double temp[10] = {0.05, 0.07, 0.1, 0.15, 0.18, 0.2, 0.22, 0.25, 0.28, 0.3}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = DCAnegsys; + } + + for (int i = 0; i < 10; i++) { + if (sys == 1 || sys == 3) { + if (sysvar < syst[i]) + desbinvalue = i + 0.5; + else + continue; + } + if (sys == 2 || sys == 4 || sys == 5) { + if (sysvar > syst[i]) + desbinvalue = i + 0.5; + else + continue; + } + + /////////////////////////////////////////////////// + if (LambdaTag) { + Lambda = Proton + AntiPion; + tagb = 0; + int binx = accprofileL->GetXaxis()->FindBin(v0.eta()); + int biny = accprofileL->GetYaxis()->FindBin(v0.pt()); + double acvalue = accprofileL->GetBinContent(binx, biny); + fillHistograms(taga, tagb, Lambda, Proton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mLambda(), v0.pt(), desbinvalue, acvalue); + } + + tagb = aLambdaTag; + if (aLambdaTag) { + AntiLambda = AntiProton + Pion; + taga = 0; + int binx = accprofileAL->GetXaxis()->FindBin(v0.eta()); + int biny = accprofileAL->GetYaxis()->FindBin(v0.pt()); + double acvalue = accprofileAL->GetBinContent(binx, biny); + fillHistograms(taga, tagb, AntiLambda, AntiProton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mAntiLambda(), v0.pt(), desbinvalue, acvalue); + } + } + } else { + if (LambdaTag) { + Lambda = Proton + AntiPion; + tagb = 0; + int binx = accprofileL->GetXaxis()->FindBin(v0.eta()); + int biny = accprofileL->GetYaxis()->FindBin(v0.pt()); + double acvalue = accprofileL->GetBinContent(binx, biny); + fillHistograms(taga, tagb, Lambda, Proton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mLambda(), v0.pt(), v0.eta(), acvalue); + } + + tagb = aLambdaTag; + if (aLambdaTag) { + AntiLambda = AntiProton + Pion; + taga = 0; + int binx = accprofileAL->GetXaxis()->FindBin(v0.eta()); + int biny = accprofileAL->GetYaxis()->FindBin(v0.pt()); + double acvalue = accprofileAL->GetBinContent(binx, biny); + fillHistograms(taga, tagb, AntiLambda, AntiProton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mAntiLambda(), v0.pt(), v0.eta(), acvalue); + } } } } + // lastRunNumber = currentRunNumber; } PROCESS_SWITCH(lambdapolsp, processData, "Process data", true); @@ -805,6 +1132,10 @@ struct lambdapolsp { return; } + if (rctCut.requireRCTFlagChecker && !rctChecker(collision)) { + return; + } + if (additionalEvSel && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { return; } @@ -818,73 +1149,642 @@ struct lambdapolsp { return; } + if (additionalEvSel4 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + + /*currentRunNumber = collision.foundBC_as().runNumber(); + auto bc = collision.foundBC_as(); + + if (useAccCorr && (currentRunNumber != lastRunNumber)) { + accprofileL = ccdb->getForTimeStamp(ConfAccPathL.value, bc.timestamp()); + accprofileAL = ccdb->getForTimeStamp(ConfAccPathAL.value, bc.timestamp()); + } + */ //___________________________________________________________________________________________________ // retrieve further info provided by StraZDCSP + auto qxZDCA = collision.qxZDCA(); + auto qxZDCC = collision.qxZDCC(); + auto qyZDCA = collision.qyZDCA(); + auto qyZDCC = collision.qyZDCC(); auto psiZDCC = collision.psiZDCC(); auto psiZDCA = collision.psiZDCA(); + double modqxZDCA; + double modqyZDCA; + double modqxZDCC; + double modqyZDCC; + + if (cqvas) { + modqxZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Cos(psiZDCA); + modqyZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Sin(psiZDCA); + modqxZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Cos(psiZDCC); + modqyZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Sin(psiZDCC); + } else { + modqxZDCA = qxZDCA; + modqyZDCA = qyZDCA; + modqxZDCC = qxZDCC; + modqyZDCC = qyZDCC; + } + + auto psiZDC = TMath::ATan2((modqyZDCC - modqyZDCA), (modqxZDCC - modqxZDCA)); // full event plane // fill histograms histos.fill(HIST("hCentrality"), centrality); if (!checkwithpub) { // histos.fill(HIST("hVtxZ"), collision.posZ()); histos.fill(HIST("hpRes"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA - psiZDCC)))); - if (QA) { - histos.fill(HIST("hpResSin"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA - psiZDCC)))); - histos.fill(HIST("hpCosPsiA"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA)))); - histos.fill(HIST("hpCosPsiC"), centrality, (TMath::Cos(GetPhiInRange(psiZDCC)))); - histos.fill(HIST("hpSinPsiA"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA)))); - histos.fill(HIST("hpSinPsiC"), centrality, (TMath::Sin(GetPhiInRange(psiZDCC)))); - } + histos.fill(HIST("hpResSin"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA - psiZDCC)))); + /*histos.fill(HIST("hpCosPsiA"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA)))); + histos.fill(HIST("hpCosPsiC"), centrality, (TMath::Cos(GetPhiInRange(psiZDCC)))); + histos.fill(HIST("hpSinPsiA"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA)))); + histos.fill(HIST("hpSinPsiC"), centrality, (TMath::Sin(GetPhiInRange(psiZDCC))));*/ } //___________________________________________________________________________________________________ // loop over V0s as necessary - for (auto v0 : V0s) { + for (const auto& v0 : V0s) { + + if (analyzeLambda && analyzeK0s) + continue; + if (!analyzeLambda && !analyzeK0s) + continue; + bool LambdaTag = isCompatible(v0, 0); bool aLambdaTag = isCompatible(v0, 1); - if (!LambdaTag && !aLambdaTag) + bool K0sTag = isCompatibleK0s(v0); + + if (analyzeLambda && !LambdaTag && !aLambdaTag) + continue; + + if (analyzeK0s && !K0sTag) continue; if (!SelectionV0(collision, v0)) { continue; } + if (analyzeLambda) { + if (LambdaTag) { + Proton = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPr); + AntiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPi); + Lambdadummy = Proton + AntiPion; + // angleLambda = calculateAngleBetweenLorentzVectors(Proton, AntiPion); + } + if (aLambdaTag) { + AntiProton = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPr); + Pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPi); + AntiLambdadummy = AntiProton + Pion; + // angleAntiLambda = calculateAngleBetweenLorentzVectors(AntiProton, Pion); + } - if (LambdaTag) { - Proton = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPr); - AntiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPi); - Lambdadummy = Proton + AntiPion; + if (shouldReject(LambdaTag, aLambdaTag, Lambdadummy, AntiLambdadummy)) { + continue; + } } - if (aLambdaTag) { - AntiProton = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPr); - Pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPi); - AntiLambdadummy = AntiProton + Pion; + + if (analyzeK0s) { + if (K0sTag) { + Pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPi); + AntiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPi); + K0sdummy = Pion + AntiPion; + } } - if (shouldReject(LambdaTag, aLambdaTag, Lambdadummy, AntiLambdadummy)) { + if (TMath::Abs(v0.eta()) > 0.8) continue; - } int taga = LambdaTag; int tagb = aLambdaTag; + int tagc = K0sTag; - if (LambdaTag) { - Lambda = Proton + AntiPion; - tagb = 0; - fillHistograms(taga, tagb, Lambda, Proton, psiZDCC, psiZDCA, centrality, - v0.mLambda(), v0.pt(), v0.eta()); + float desbinvalue = 0.0; + + if (analyzeK0s && K0sTag) { + K0s = Pion + AntiPion; + double acvalue = 1.0; + fillHistograms(tagc, 0, K0s, Pion, psiZDCC, psiZDCA, psiZDC, centrality, v0.mK0Short(), v0.pt(), v0.eta(), acvalue); } - tagb = aLambdaTag; - if (aLambdaTag) { - AntiLambda = AntiProton + Pion; - taga = 0; - fillHistograms(taga, tagb, AntiLambda, AntiProton, psiZDCC, psiZDCA, centrality, - v0.mAntiLambda(), v0.pt(), v0.eta()); + if (analyzeLambda && dosystematic) { + //////////////////////////////////////////////////// + float LTsys = TMath::Abs(v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massLambda); + float CPAsys = v0.v0cosPA(); + float DCADaughsys = TMath::Abs(v0.dcaV0daughters()); + float DCApossys = TMath::Abs(v0.dcapostopv()); + float DCAnegsys = TMath::Abs(v0.dcanegtopv()); + float sysvar = -999.9; + double syst[10]; + if (sys == 1) { + double temp[10] = {26, 27, 28, 29, 30, 31, 32, 33, 34, 35}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = LTsys; + } + if (sys == 2) { + double temp[10] = {0.992, 0.993, 0.9935, 0.994, 0.9945, 0.995, 0.9955, 0.996, 0.9965, 0.997}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = CPAsys; + } + if (sys == 3) { + double temp[10] = {0.8, 0.85, 0.9, 0.95, 1.0, 1.05, 1.1, 1.15, 1.2, 1.25}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = DCADaughsys; + } + if (sys == 4) { + double temp[10] = {0.05, 0.07, 0.1, 0.15, 0.18, 0.2, 0.22, 0.25, 0.28, 0.3}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = DCApossys; + } + if (sys == 5) { + double temp[10] = {0.05, 0.07, 0.1, 0.15, 0.18, 0.2, 0.22, 0.25, 0.28, 0.3}; + std::copy(std::begin(temp), std::end(temp), std::begin(syst)); + sysvar = DCAnegsys; + } + + for (int i = 0; i < 10; i++) { + if (sys == 1 || sys == 3) { + if (sysvar < syst[i]) + desbinvalue = i + 0.5; + else + continue; + } + if (sys == 2 || sys == 4 || sys == 5) { + if (sysvar > syst[i]) + desbinvalue = i + 0.5; + else + continue; + } + + /////////////////////////////////////////////////// + if (analyzeLambda && LambdaTag) { + Lambda = Proton + AntiPion; + tagb = 0; + double acvalue = 1.0; + fillHistograms(taga, tagb, Lambda, Proton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mLambda(), v0.pt(), desbinvalue, acvalue); + } + + tagb = aLambdaTag; + if (analyzeLambda && aLambdaTag) { + AntiLambda = AntiProton + Pion; + taga = 0; + double acvalue = 1.0; + fillHistograms(taga, tagb, AntiLambda, AntiProton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mAntiLambda(), v0.pt(), desbinvalue, acvalue); + } + } + } else { + if (analyzeLambda && LambdaTag) { + Lambda = Proton + AntiPion; + tagb = 0; + double acvalue = 1.0; + fillHistograms(taga, tagb, Lambda, Proton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mLambda(), v0.pt(), v0.eta(), acvalue); + } + + tagb = aLambdaTag; + if (analyzeLambda && aLambdaTag) { + AntiLambda = AntiProton + Pion; + taga = 0; + double acvalue = 1.0; + fillHistograms(taga, tagb, AntiLambda, AntiProton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mAntiLambda(), v0.pt(), v0.eta(), acvalue); + } } - } // end loop over V0s + } + // lastRunNumber = currentRunNumber; } PROCESS_SWITCH(lambdapolsp, processDerivedData, "Process derived data", false); + + // Processing Event Mixing + using BinningType = ColumnBinningPolicy; + BinningType colBinning{{meGrp.axisVertex, meGrp.axisMultiplicityClass}, true}; + Preslice tracksPerCollisionV0Mixed = o2::aod::v0data::straCollisionId; // for derived data only + + void processDerivedDataMixed(soa::Join const& collisions, v0Candidates const& V0s, dauTracks const&) + { + TRandom3 randGen(0); + + for (auto& [collision1, collision2] : selfCombinations(colBinning, meGrp.nMix, -1, collisions, collisions)) { + + if (collision1.index() == collision2.index()) { + continue; + } + + if (!collision1.sel8()) { + continue; + } + if (!collision2.sel8()) { + continue; + } + + if (!collision1.triggereventsp()) { // provided by StraZDCSP + continue; + } + if (!collision2.triggereventsp()) { // provided by StraZDCSP + continue; + } + + if (rctCut.requireRCTFlagChecker && !rctChecker(collision1)) { + continue; + } + if (rctCut.requireRCTFlagChecker && !rctChecker(collision2)) { + continue; + } + + if (additionalEvSel && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (additionalEvSel && (!collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (additionalEvSel2 && (collision1.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision1.trackOccupancyInTimeRange() < cfgMinOccupancy)) { + continue; + } + if (additionalEvSel2 && (collision2.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision2.trackOccupancyInTimeRange() < cfgMinOccupancy)) { + continue; + } + if (additionalEvSel3 && (!collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel3 && (!collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel4 && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + if (additionalEvSel4 && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + + auto centrality = collision1.centFT0C(); + auto qxZDCA = collision2.qxZDCA(); + auto qxZDCC = collision2.qxZDCC(); + auto qyZDCA = collision2.qyZDCA(); + auto qyZDCC = collision2.qyZDCC(); + auto psiZDCC = collision2.psiZDCC(); + auto psiZDCA = collision2.psiZDCA(); + double modqxZDCA; + double modqyZDCA; + double modqxZDCC; + double modqyZDCC; + + modqxZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Cos(psiZDCA); + modqyZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Sin(psiZDCA); + modqxZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Cos(psiZDCC); + modqyZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Sin(psiZDCC); + + auto psiZDC = TMath::ATan2((modqyZDCC - modqyZDCA), (modqxZDCC - modqxZDCA)); // full event plane from collision 2 + auto groupV0 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision1.index()); + + histos.fill(HIST("hCentrality"), centrality); + + if (randGrp.doRandomPsi) { + psiZDC = randGen.Uniform(0, 2 * TMath::Pi()); + } + if (randGrp.doRandomPsiAC) { + psiZDCA = randGen.Uniform(0, 2 * TMath::Pi()); + psiZDCC = randGen.Uniform(0, 2 * TMath::Pi()); + } + + histos.fill(HIST("hpRes"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA - psiZDCC)))); + histos.fill(HIST("hpResSin"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA - psiZDCC)))); + + for (const auto& v0 : groupV0) { + + bool LambdaTag = isCompatible(v0, 0); + bool aLambdaTag = isCompatible(v0, 1); + if (!LambdaTag && !aLambdaTag) + continue; + if (!SelectionV0(collision1, v0)) + continue; + if (LambdaTag) { + Proton = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPr); + AntiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPi); + Lambdadummy = Proton + AntiPion; + } + if (aLambdaTag) { + AntiProton = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), massPr); + Pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), massPi); + AntiLambdadummy = AntiProton + Pion; + } + if (shouldReject(LambdaTag, aLambdaTag, Lambdadummy, AntiLambdadummy)) { + continue; + } + if (TMath::Abs(v0.eta()) > 0.8) + continue; + int taga = LambdaTag; + int tagb = aLambdaTag; + + if (LambdaTag) { + Lambda = Proton + AntiPion; + tagb = 0; + double acvalue = 1.0; + fillHistograms(taga, tagb, Lambda, Proton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mLambda(), v0.pt(), v0.eta(), acvalue); + } + + tagb = aLambdaTag; + if (aLambdaTag) { + AntiLambda = AntiProton + Pion; + taga = 0; + double acvalue = 1.0; + fillHistograms(taga, tagb, AntiLambda, AntiProton, psiZDCC, psiZDCA, psiZDC, centrality, v0.mAntiLambda(), v0.pt(), v0.eta(), acvalue); + } + } + } + } + PROCESS_SWITCH(lambdapolsp, processDerivedDataMixed, "Process mixed event using derived data", false); + + void processDerivedDataMixed2(soa::Join const& collisions, v0Candidates const& V0s, dauTracks const&) + { + TRandom3 randGen(0); + + for (auto& [collision1, collision2] : selfCombinations(colBinning, meGrp.nMix, -1, collisions, collisions)) { + + if (collision1.index() == collision2.index()) { + continue; + } + + if (!collision1.sel8()) { + continue; + } + if (!collision2.sel8()) { + continue; + } + + if (!collision1.triggereventsp()) { // provided by StraZDCSP + continue; + } + if (!collision2.triggereventsp()) { // provided by StraZDCSP + continue; + } + + if (rctCut.requireRCTFlagChecker && !rctChecker(collision1)) { + continue; + } + if (rctCut.requireRCTFlagChecker && !rctChecker(collision2)) { + continue; + } + + if (additionalEvSel && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (additionalEvSel && (!collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (additionalEvSel2 && (collision1.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision1.trackOccupancyInTimeRange() < cfgMinOccupancy)) { + continue; + } + if (additionalEvSel2 && (collision2.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision2.trackOccupancyInTimeRange() < cfgMinOccupancy)) { + continue; + } + if (additionalEvSel3 && (!collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel3 && (!collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel4 && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + if (additionalEvSel4 && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + + auto centrality = collision1.centFT0C(); + auto qxZDCA = collision1.qxZDCA(); + auto qxZDCC = collision1.qxZDCC(); + auto qyZDCA = collision1.qyZDCA(); + auto qyZDCC = collision1.qyZDCC(); + auto psiZDCC = collision1.psiZDCC(); + auto psiZDCA = collision1.psiZDCA(); + double modqxZDCA; + double modqyZDCA; + double modqxZDCC; + double modqyZDCC; + + modqxZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Cos(psiZDCA); + modqyZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Sin(psiZDCA); + modqxZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Cos(psiZDCC); + modqyZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Sin(psiZDCC); + + auto psiZDC = TMath::ATan2((modqyZDCC - modqyZDCA), (modqxZDCC - modqxZDCA)); // full event plane from collision 2 + + histos.fill(HIST("hCentrality"), centrality); + histos.fill(HIST("hpRes"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA - psiZDCC)))); + histos.fill(HIST("hpResSin"), centrality, (TMath::Sin(GetPhiInRange(psiZDCA - psiZDCC)))); + + // V0s from collision1 to match kinematics + auto v0sCol1 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision1.index()); + // V0s from collision2 to test + auto v0sCol2 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision2.index()); + + for (const auto& v0_2 : v0sCol2) { + + bool LambdaTag = isCompatible(v0_2, 0); + bool aLambdaTag = isCompatible(v0_2, 1); + if (!LambdaTag && !aLambdaTag) + continue; + if (!SelectionV0(collision2, v0_2)) + continue; + if (LambdaTag) { + Proton = ROOT::Math::PxPyPzMVector(v0_2.pxpos(), v0_2.pypos(), v0_2.pzpos(), massPr); + AntiPion = ROOT::Math::PxPyPzMVector(v0_2.pxneg(), v0_2.pyneg(), v0_2.pzneg(), massPi); + Lambdadummy = Proton + AntiPion; + } + if (aLambdaTag) { + AntiProton = ROOT::Math::PxPyPzMVector(v0_2.pxneg(), v0_2.pyneg(), v0_2.pzneg(), massPr); + Pion = ROOT::Math::PxPyPzMVector(v0_2.pxpos(), v0_2.pypos(), v0_2.pzpos(), massPi); + AntiLambdadummy = AntiProton + Pion; + } + if (shouldReject(LambdaTag, aLambdaTag, Lambdadummy, AntiLambdadummy)) { + continue; + } + if (TMath::Abs(v0_2.eta()) > 0.8) + continue; + + // Check if lambda kinematics from collision2 matches with collision1 + bool matched = false; + for (const auto& v0_1 : v0sCol1) { + bool LambdaTag1 = isCompatible(v0_1, 0); + bool aLambdaTag1 = isCompatible(v0_1, 1); + if (!LambdaTag1 && !aLambdaTag1) + continue; + if (!SelectionV0(collision1, v0_1)) + continue; + if (TMath::Abs(v0_1.eta()) > 0.8) + continue; + + double deta = std::abs(v0_1.eta() - v0_2.eta()); + double dpt = std::abs(v0_1.pt() - v0_2.pt()); + double dphi = RecoDecay::constrainAngle(v0_1.phi() - v0_2.phi(), 0.0); + if (deta < randGrp.etaMix && dpt < randGrp.ptMix && dphi < randGrp.phiMix && ((v0_1.eta() * v0_2.eta()) > 0.0)) { + matched = true; + break; + } + } + if (!matched) + continue; + + int taga = LambdaTag; + int tagb = aLambdaTag; + + if (LambdaTag) { + Lambda = Proton + AntiPion; + tagb = 0; + double acvalue = 1.0; + fillHistograms(taga, tagb, Lambda, Proton, psiZDCC, psiZDCA, psiZDC, centrality, v0_2.mLambda(), v0_2.pt(), v0_2.eta(), acvalue); + } + + tagb = aLambdaTag; + if (aLambdaTag) { + AntiLambda = AntiProton + Pion; + taga = 0; + double acvalue = 1.0; + fillHistograms(taga, tagb, AntiLambda, AntiProton, psiZDCC, psiZDCA, psiZDC, centrality, v0_2.mAntiLambda(), v0_2.pt(), v0_2.eta(), acvalue); + } + } + } + } + PROCESS_SWITCH(lambdapolsp, processDerivedDataMixed2, "Process mixed event2 using derived data", false); + + void processDerivedDataMixedFIFO(soa::Join const& collisions, v0Candidates const& V0s, dauTracks const&) + { + + auto nBins = colBinning.getAllBinsCount(); + std::vector> eventPools(nBins); // Pool per bin holding just event indices + + for (auto& collision1 : collisions) { + + if (!collision1.sel8()) { + continue; + } + if (!collision1.triggereventsp()) { // provided by StraZDCSP + continue; + } + if (rctCut.requireRCTFlagChecker && !rctChecker(collision1)) { + continue; + } + + if (additionalEvSel && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (additionalEvSel2 && (collision1.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision1.trackOccupancyInTimeRange() < cfgMinOccupancy)) { + continue; + } + if (additionalEvSel3 && (!collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel4 && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + + int bin = colBinning.getBin(std::make_tuple(collision1.posZ(), collision1.centFT0C())); + auto groupV0_evt1 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision1.index()); + float centrality = collision1.centFT0C(); + auto qxZDCA = collision1.qxZDCA(); + auto qxZDCC = collision1.qxZDCC(); + auto qyZDCA = collision1.qyZDCA(); + auto qyZDCC = collision1.qyZDCC(); + auto psiZDCC = collision1.psiZDCC(); + auto psiZDCA = collision1.psiZDCA(); + double modqxZDCA; + double modqyZDCA; + double modqxZDCC; + double modqyZDCC; + + if (bin < 0) + continue; + modqxZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Cos(psiZDCA); + modqyZDCA = TMath::Sqrt((qxZDCA * qxZDCA) + (qyZDCA * qyZDCA)) * TMath::Sin(psiZDCA); + modqxZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Cos(psiZDCC); + modqyZDCC = TMath::Sqrt((qxZDCC * qxZDCC) + (qyZDCC * qyZDCC)) * TMath::Sin(psiZDCC); + + auto psiZDC = TMath::ATan2((modqyZDCC - modqyZDCA), (modqxZDCC - modqxZDCA)); // full event plane from collision + + histos.fill(HIST("hCentrality"), centrality); + histos.fill(HIST("hpRes"), centrality, (TMath::Cos(GetPhiInRange(psiZDCA - psiZDCC)))); + + // For deduplication of (v0_evt1, v0_evt2) pairs per mixed event + std::unordered_map>> seenMap; + + // Loop over Λ candidates in collision1 (keep psi from here) + + for (auto& v0_evt1 : groupV0_evt1) { + if (!SelectionV0(collision1, v0_evt1)) + continue; + bool LambdaTag1 = isCompatible(v0_evt1, 0); + bool aLambdaTag1 = isCompatible(v0_evt1, 1); + ROOT::Math::PxPyPzMVector proton1, pion1, antiproton1, antipion1, LambdaTag1dummy, AntiLambdaTag1dummy; + if (LambdaTag1) { + proton1 = {v0_evt1.pxpos(), v0_evt1.pypos(), v0_evt1.pzpos(), massPr}; + antipion1 = {v0_evt1.pxneg(), v0_evt1.pyneg(), v0_evt1.pzneg(), massPi}; + LambdaTag1dummy = proton1 + antipion1; + } + if (aLambdaTag1) { + antiproton1 = {v0_evt1.pxneg(), v0_evt1.pyneg(), v0_evt1.pzneg(), massPr}; + pion1 = {v0_evt1.pxpos(), v0_evt1.pypos(), v0_evt1.pzpos(), massPi}; + AntiLambdaTag1dummy = antiproton1 + pion1; + } + if (shouldReject(LambdaTag1, aLambdaTag1, LambdaTag1dummy, AntiLambdaTag1dummy)) { + continue; + } + if (TMath::Abs(v0_evt1.eta()) > 0.8) + continue; + + // Loop over all FIFO pool events (mixed events) for this centrality bin + int nMixedEvents = 0; + for (auto it = eventPools[bin].rbegin(); it != eventPools[bin].rend() && nMixedEvents < meGrp.nMix; ++it, ++nMixedEvents) { + int collision2idx = *it; + if (collision1.index() == collision2idx) + continue; + auto groupV0_evt2 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision2idx); + + // Now loop over Λ candidates in collision2 to randomize proton phi* (randomize decay angle) + for (auto& v0_evt2 : groupV0_evt2) { + if (!SelectionV0(collision1, v0_evt2)) + continue; + bool LambdaTag2 = isCompatible(v0_evt2, 0); + bool aLambdaTag2 = isCompatible(v0_evt2, 1); + if (!LambdaTag2 && !aLambdaTag2) + continue; + + // Deduplicate (v0_evt1, v0_evt2) pairs per collision2idx + auto key = std::make_pair(v0_evt1.index(), v0_evt2.index()); + if (!seenMap[collision2idx].insert(key).second) + continue; + + ROOT::Math::PxPyPzMVector proton_mix, antiproton_mix, pion_mix, antipion_mix, LambdaTag2dummy, AntiLambdaTag2dummy; + if (LambdaTag2) { + proton_mix = {v0_evt2.pxpos(), v0_evt2.pypos(), v0_evt2.pzpos(), massPr}; + antipion_mix = {v0_evt2.pxneg(), v0_evt2.pyneg(), v0_evt2.pzneg(), massPi}; + LambdaTag2dummy = proton_mix + antipion_mix; + } + if (aLambdaTag2) { + antiproton_mix = {v0_evt2.pxneg(), v0_evt2.pyneg(), v0_evt2.pzneg(), massPr}; + pion_mix = {v0_evt2.pxpos(), v0_evt2.pypos(), v0_evt2.pzpos(), massPi}; + AntiLambdaTag2dummy = antiproton_mix + pion_mix; + } + if (shouldReject(LambdaTag2, aLambdaTag2, LambdaTag2dummy, AntiLambdaTag2dummy)) { + continue; + } + if (TMath::Abs(v0_evt2.eta()) > 0.8) + continue; + if (LambdaTag1) { + double acvalue = 1.0; + fillHistograms(1, 0, LambdaTag1dummy, proton_mix, psiZDCC, psiZDCA, psiZDC, centrality, v0_evt1.mLambda(), v0_evt1.pt(), v0_evt1.eta(), acvalue); + } + if (aLambdaTag1) { + double acvalue = 1.0; + fillHistograms(0, 1, AntiLambdaTag1dummy, antiproton_mix, psiZDCC, psiZDCA, psiZDC, centrality, v0_evt1.mAntiLambda(), v0_evt1.pt(), v0_evt1.eta(), acvalue); + } + } + } + } + // After processing all mixes, add current event V0s to pool for future mixing + eventPools[bin].push_back(collision1.index()); + // Keep only N last events in FIFO queue + if (static_cast(eventPools[bin].size()) > meGrp.nMix) { + eventPools[bin].pop_front(); + } + } + } + PROCESS_SWITCH(lambdapolsp, processDerivedDataMixedFIFO, "Process mixed event using derived data with FIFO method", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx new file mode 100644 index 00000000000..5db586eb880 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/lambdaspincorrderived.cxx @@ -0,0 +1,501 @@ +// 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. + +/// \file taskLambdaSpinCorr.cxx +/// \brief Analysis task for Lambda spin spin correlation +/// +/// \author sourav.kundu@cern.ch + +#include "PWGLF/DataModel/LFSpincorrelationTables.h" + +#include "Common/Core/trackUtilities.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/BinningPolicy.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include + +#include +#include +#include +#include +#include + +#include + +#include // for std::fabs +#include +#include +#include +#include // <<< CHANGED: for dedup sets +#include +#include +#include // <<< CHANGED: for seenMap +#include +#include + +// o2 includes. +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct lambdaspincorrderived { + // BinningType colBinning; + struct : ConfigurableGroup { + Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; + } cfgCcdbParam; + + // Enable access to the CCDB for the offset and correction constants and save them in dedicated variables. + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + TH3D* hweight1; + TH3D* hweight2; + TH3D* hweight3; + + Configurable ConfWeightPathLL{"ConfWeightPathLL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + Configurable ConfWeightPathALAL{"ConfWeightPathALAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + Configurable ConfWeightPathLAL{"ConfWeightPathLAL", "Users/s/skundu/My/Object/spincorr/cent010LL", "Weight path"}; + + // event sel///////// + Configurable centMin{"centMin", 0, "Minimum Centrality"}; + Configurable centMax{"centMax", 80, "Maximum Centrality"}; + + // Lambda selection //////////// + Configurable harmonic{"harmonic", 1, "Harmonic delta phi"}; + Configurable useweight{"useweight", 1, "Use weight"}; + Configurable usePDGM{"usePDGM", 1, "Use PDG mass"}; + Configurable checkDoubleStatus{"checkDoubleStatus", 0, "Check Double status"}; + Configurable cosPA{"cosPA", 0.995, "Cosine Pointing Angle"}; + Configurable radiusMin{"radiusMin", 3, "Minimum V0 radius"}; + Configurable radiusMax{"radiusMax", 30, "Maximum V0 radius"}; + Configurable dcaProton{"dcaProton", 0.1, "DCA Proton"}; + Configurable dcaPion{"dcaPion", 0.2, "DCA Pion"}; + Configurable dcaDaughters{"dcaDaughters", 1.0, "DCA between daughters"}; + Configurable ptMin{"ptMin", 0.5, "V0 Pt minimum"}; + Configurable ptMax{"ptMax", 3.0, "V0 Pt maximum"}; + Configurable rapidity{"rapidity", 0.5, "Rapidity cut on lambda"}; + Configurable v0eta{"v0eta", 0.8, "Eta cut on lambda"}; + + // Event Mixing + Configurable nEvtMixing{"nEvtMixing", 10, "Number of events to mix"}; + ConfigurableAxis CfgVtxBins{"CfgVtxBins", {10, -10, 10}, "Mixing bins - z-vertex"}; + ConfigurableAxis CfgMultBins{"CfgMultBins", {8, 0.0, 80}, "Mixing bins - centrality"}; + Configurable etaMix{"etaMix", 0.1, "Eta cut on event mixing"}; + Configurable ptMix{"ptMix", 0.1, "Pt cut on event mixing"}; + Configurable phiMix{"phiMix", 0.1, "Phi cut on event mixing"}; + Configurable massMix{"massMix", 0.0028, "Masscut on event mixing"}; + + // THnsparse bining + ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {50, 1.09, 1.14}, "#it{M} (GeV/#it{c}^{2})"}; + ConfigurableAxis configThnAxisR{"configThnAxisR", {80, 0.0, 8.0}, "#it{R}"}; + ConfigurableAxis configThnAxisPol{"configThnAxisPol", {80, 0.0, 8.0}, "cos#it{#theta *}"}; + ConfigurableAxis configThnAxisCentrality{"configThnAxisCentrality", {8, 0.0, 80.0}, "Centrality"}; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + histos.add("hPtYSame", "hPtYSame", kTH2F, {{100, 0.0, 10.0}, {200, -1.0, 1.0}}); + histos.add("hPtYMix", "hPtYMix", kTH2F, {{100, 0.0, 10.0}, {200, -1.0, 1.0}}); + histos.add("hCentrality", "Centrality distribution", kTH1F, {{configThnAxisCentrality}}); + histos.add("deltaPhiSame", "deltaPhiSame", HistType::kTH1D, {{72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("deltaPhiMix", "deltaPhiMix", HistType::kTH1D, {{72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("ptCent", "ptCent", HistType::kTH2D, {{100, 0.0, 10.0}, {8, 0.0, 80.0}}, true); + histos.add("etaCent", "etaCent", HistType::kTH2D, {{32, -0.8, 0.8}, {8, 0.0, 80.0}}, true); + + histos.add("hLambdaSameForLL", "hLambdaSameForLL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hLambdaSameForLAL", "hLambdaSameForLAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hAntiLambdaSameForALAL", "hAntiLambdaSameForALAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + + histos.add("hLambdaMixForLL", "hLambdaMixForLL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hLambdaMixForLAL", "hLambdaMixForLAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + histos.add("hAntiLambdaMixForALAL", "hAntiLambdaMixForALAL", HistType::kTH3D, {{50, 0.0, 5.0}, {32, -0.8, 0.8}, {72, 0.0, 2.0 * TMath::Pi()}}, true); + + histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); + histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); + histos.add("hSparseAntiLambdaAntiLambda", "hSparseAntiLambdaAntiLambda", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); + + histos.add("hSparseLambdaLambdaMixed", "hSparseLambdaLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); + histos.add("hSparseLambdaAntiLambdaMixed", "hSparseLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); + histos.add("hSparseAntiLambdaAntiLambdaMixed", "hSparseAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {configThnAxisInvMass, configThnAxisInvMass, configThnAxisPol, configThnAxisCentrality, configThnAxisR}, true); + + ccdb->setURL(cfgCcdbParam.cfgURL); + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + LOGF(info, "Getting alignment offsets from the CCDB..."); + hweight1 = ccdb->getForTimeStamp(ConfWeightPathLL.value, cfgCcdbParam.nolaterthan.value); + hweight2 = ccdb->getForTimeStamp(ConfWeightPathALAL.value, cfgCcdbParam.nolaterthan.value); + hweight3 = ccdb->getForTimeStamp(ConfWeightPathLAL.value, cfgCcdbParam.nolaterthan.value); + } + + template + bool selectionV0(T const& candidate) + { + auto particle = ROOT::Math::PtEtaPhiMVector(candidate.lambdaPt(), candidate.lambdaEta(), candidate.lambdaPhi(), candidate.lambdaMass()); + if (std::abs(particle.Rapidity()) > rapidity || std::abs(particle.Eta()) > v0eta) { + return false; + } + if (candidate.v0Cospa() < cosPA) { + return false; + } + if (checkDoubleStatus && candidate.doubleStatus()) { + return false; + } + if (candidate.v0Radius() > radiusMax) { + return false; + } + if (candidate.v0Radius() < radiusMin) { + return false; + } + if (candidate.dcaBetweenDaughter() > dcaDaughters) { + return false; + } + if (candidate.v0Status() == 0 && std::abs(candidate.dcaPositive()) < dcaProton && std::abs(candidate.dcaNegative()) < dcaPion) { + return false; + } + if (candidate.v0Status() == 1 && std::abs(candidate.dcaPositive()) < dcaPion && std::abs(candidate.dcaNegative()) < dcaProton) { + return false; + } + if (candidate.lambdaPt() < ptMin) { + return false; + } + if (candidate.lambdaPt() > ptMax) { + return false; + } + return true; + } + + template + bool checkKinematics(T1 const& candidate1, T2 const& candidate2) + { + if (candidate1.v0Status() != candidate2.v0Status()) { + return false; + } + if (std::abs(candidate1.lambdaPt() - candidate2.lambdaPt()) > ptMix) { + return false; + } + if (std::abs(candidate1.lambdaEta() - candidate2.lambdaEta()) > etaMix) { + return false; + } + if (std::abs(RecoDecay::constrainAngle(candidate1.lambdaPhi(), 0.0F, harmonic) - RecoDecay::constrainAngle(candidate2.lambdaPhi(), 0.0F, harmonic)) > phiMix) { + return false; + } + if (std::abs(candidate1.lambdaMass() - candidate2.lambdaMass()) > massMix) { + return false; + } + return true; + } + + void fillHistograms(int tag1, int tag2, + const ROOT::Math::PtEtaPhiMVector& particle1, const ROOT::Math::PtEtaPhiMVector& particle2, + const ROOT::Math::PtEtaPhiMVector& daughpart1, const ROOT::Math::PtEtaPhiMVector& daughpart2, + double centrality, int datatype, float mixpairweight) + { + + auto lambda1Mass = 0.0; + auto lambda2Mass = 0.0; + if (!usePDGM) { + lambda1Mass = particle1.M(); + lambda2Mass = particle2.M(); + } else { + lambda1Mass = o2::constants::physics::MassLambda; + lambda2Mass = o2::constants::physics::MassLambda; + } + auto particle1Dummy = ROOT::Math::PtEtaPhiMVector(particle1.Pt(), particle1.Eta(), particle1.Phi(), lambda1Mass); + auto particle2Dummy = ROOT::Math::PtEtaPhiMVector(particle2.Pt(), particle2.Eta(), particle2.Phi(), lambda2Mass); + auto pairDummy = particle1Dummy + particle2Dummy; + ROOT::Math::Boost boostPairToCM{pairDummy.BoostToCM()}; // boosting vector for pair CM + + // Step1: Boosting both Lambdas to Lambda-Lambda pair rest frame + auto lambda1CM = boostPairToCM(particle1Dummy); + auto lambda2CM = boostPairToCM(particle2Dummy); + + // Step 2: Boost Each Lambda to its Own Rest Frame + ROOT::Math::Boost boostLambda1ToCM{lambda1CM.BoostToCM()}; + ROOT::Math::Boost boostLambda2ToCM{lambda2CM.BoostToCM()}; + + // Also boost the daughter protons to the same frame + auto proton1pairCM = boostPairToCM(daughpart1); // proton1 to pair CM + auto proton2pairCM = boostPairToCM(daughpart2); // proton2 to pair CM + + // Boost protons into their respective Lambda rest frames + auto proton1LambdaRF = boostLambda1ToCM(proton1pairCM); + auto proton2LambdaRF = boostLambda2ToCM(proton2pairCM); + + auto cosThetaDiff = -999.0; + cosThetaDiff = proton1LambdaRF.Vect().Unit().Dot(proton2LambdaRF.Vect().Unit()); + double deltaPhi = std::abs(RecoDecay::constrainAngle(particle1Dummy.Phi(), 0.0F, harmonic) - RecoDecay::constrainAngle(particle2Dummy.Phi(), 0.0F, harmonic)); + double deltaEta = particle1Dummy.Eta() - particle2Dummy.Eta(); + double deltaR = TMath::Sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi); + + if (datatype == 0) { + mixpairweight = 1.0; + histos.fill(HIST("hPtYSame"), particle1.Pt(), particle1.Rapidity(), mixpairweight); + if (tag1 == 0 && tag2 == 0) { + histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, mixpairweight); + histos.fill(HIST("hLambdaSameForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); + } else if ((tag1 == 0 && tag2 == 1) || (tag1 == 1 && tag2 == 0)) { + histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, mixpairweight); + histos.fill(HIST("hLambdaSameForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); + } else if (tag1 == 1 && tag2 == 1) { + histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, mixpairweight); + histos.fill(HIST("hAntiLambdaSameForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), mixpairweight); + } + } else if (datatype == 1) { + double weight1 = mixpairweight; + double weight2 = mixpairweight; + double weight3 = mixpairweight; + if (useweight) { + weight1 = mixpairweight * hweight1->GetBinContent(hweight1->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); + weight2 = mixpairweight * hweight2->GetBinContent(hweight2->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); + weight3 = mixpairweight * hweight3->GetBinContent(hweight3->FindBin(particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic))); + } + histos.fill(HIST("hPtYMix"), particle1.Pt(), particle1.Rapidity()); + if (tag1 == 0 && tag2 == 0) { + histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, weight1); + histos.fill(HIST("hLambdaMixForLL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight1); + } else if ((tag1 == 0 && tag2 == 1) || (tag1 == 1 && tag2 == 0)) { + histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, weight2); + histos.fill(HIST("hLambdaMixForLAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight2); + } else if (tag1 == 1 && tag2 == 1) { + histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR, weight3); + histos.fill(HIST("hAntiLambdaMixForALAL"), particle1.Pt(), particle1.Eta(), RecoDecay::constrainAngle(particle1.Phi(), 0.0F, harmonic), weight3); + } + } + } + + ROOT::Math::PtEtaPhiMVector lambda0, proton0; + ROOT::Math::PtEtaPhiMVector lambda, proton; + ROOT::Math::PtEtaPhiMVector lambda2, proton2; + + Filter centralityFilter = (nabs(aod::lambdaevent::cent) < centMax && nabs(aod::lambdaevent::cent) > centMin); + + using EventCandidates = soa::Filtered; + using AllTrackCandidates = aod::LambdaPairs; + + void processData(EventCandidates::iterator const& collision, AllTrackCandidates const& V0s) + { + auto centrality = collision.cent(); + for (const auto& v0 : V0s) { + if (!selectionV0(v0)) { + continue; + } + histos.fill(HIST("ptCent"), v0.lambdaPt(), centrality); + histos.fill(HIST("etaCent"), v0.lambdaEta(), centrality); + proton = ROOT::Math::PtEtaPhiMVector(v0.protonPt(), v0.protonEta(), v0.protonPhi(), o2::constants::physics::MassProton); + lambda = ROOT::Math::PtEtaPhiMVector(v0.lambdaPt(), v0.lambdaEta(), v0.lambdaPhi(), v0.lambdaMass()); + for (const auto& v02 : V0s) { + if (v02.index() <= v0.index()) { + continue; + } + if (!selectionV0(v02)) { + continue; + } + if (v0.protonIndex() == v02.protonIndex()) { + continue; + } + if (v0.pionIndex() == v02.pionIndex()) { + continue; + } + proton2 = ROOT::Math::PtEtaPhiMVector(v02.protonPt(), v02.protonEta(), v02.protonPhi(), o2::constants::physics::MassProton); + lambda2 = ROOT::Math::PtEtaPhiMVector(v02.lambdaPt(), v02.lambdaEta(), v02.lambdaPhi(), v02.lambdaMass()); + histos.fill(HIST("deltaPhiSame"), std::abs(RecoDecay::constrainAngle(v0.lambdaPhi(), 0.0F, harmonic) - RecoDecay::constrainAngle(v02.lambdaPhi(), 0.0F, harmonic))); + if (v0.v0Status() == 0 && v02.v0Status() == 0) { + fillHistograms(0, 0, lambda, lambda2, proton, proton2, centrality, 0, 1.0); + } + if (v0.v0Status() == 0 && v02.v0Status() == 1) { + fillHistograms(0, 1, lambda, lambda2, proton, proton2, centrality, 0, 1.0); + } + if (v0.v0Status() == 1 && v02.v0Status() == 0) { + fillHistograms(1, 0, lambda2, lambda, proton2, proton, centrality, 0, 1.0); + } + if (v0.v0Status() == 1 && v02.v0Status() == 1) { + fillHistograms(1, 1, lambda, lambda2, proton, proton2, centrality, 0, 1.0); + } + } + } + } + PROCESS_SWITCH(lambdaspincorrderived, processData, "Process data", true); + + // Processing Event Mixing + SliceCache cache; + using BinningType = ColumnBinningPolicy; + BinningType colBinning{{CfgVtxBins, CfgMultBins}, true}; + Preslice tracksPerCollisionV0 = aod::lambdapair::lambdaeventId; + void processME(EventCandidates const& collisions, AllTrackCandidates const& V0s) + { + auto collOldIndex = -999; + std::vector t1Used; + for (auto& [collision1, collision2] : selfCombinations(colBinning, nEvtMixing, -1, collisions, collisions)) { + // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.index(), collision2.index()); + auto centrality = collision1.cent(); + auto groupV01 = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); + auto groupV02 = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); + auto groupV03 = V0s.sliceBy(tracksPerCollisionV0, collision2.index()); + auto collNewIndex = collision1.index(); + // LOGF(info, "Mixed event collisions: (%d, %d)", collNewIndex, collOldIndex); + if (collOldIndex != collNewIndex) { + t1Used.resize(groupV01.size(), false); + // std::fill(t1Used.begin(), t1Used.end(), false); + // std::vector t1Used(groupV01.size(), false); // <-- reset here + collOldIndex = collNewIndex; + } + for (auto& [t1, t3] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(groupV01, groupV03))) { + if (t1Used[t1.index()]) { + continue; + } + if (!checkKinematics(t1, t3)) { + continue; + } + if (!selectionV0(t1)) { + continue; + } + if (!selectionV0(t3)) { + continue; + } + t1Used[t1.index()] = true; + for (const auto& t2 : groupV02) { + if (t2.index() <= t1.index()) { + continue; + } + if (!selectionV0(t2)) { + continue; + } + if (t1.protonIndex() == t2.protonIndex()) { + continue; + } + if (t1.pionIndex() == t2.pionIndex()) { + continue; + } + proton = ROOT::Math::PtEtaPhiMVector(t3.protonPt(), t3.protonEta(), t3.protonPhi(), o2::constants::physics::MassProton); + lambda = ROOT::Math::PtEtaPhiMVector(t3.lambdaPt(), t3.lambdaEta(), t3.lambdaPhi(), t3.lambdaMass()); + proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); + lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); + histos.fill(HIST("deltaPhiMix"), std::abs(RecoDecay::constrainAngle(t3.lambdaPhi(), 0.0F, harmonic) - RecoDecay::constrainAngle(t2.lambdaPhi(), 0.0F, harmonic))); + if (t3.v0Status() == 0 && t2.v0Status() == 0) { + fillHistograms(0, 0, lambda, lambda2, proton, proton2, centrality, 1, 1.0); + } + if (t3.v0Status() == 0 && t2.v0Status() == 1) { + fillHistograms(0, 1, lambda, lambda2, proton, proton2, centrality, 1, 1.0); + } + if (t3.v0Status() == 1 && t2.v0Status() == 0) { + fillHistograms(1, 0, lambda2, lambda, proton2, proton, centrality, 1, 1.0); + } + if (t3.v0Status() == 1 && t2.v0Status() == 1) { + fillHistograms(1, 1, lambda, lambda2, proton, proton2, centrality, 1, 1.0); + } + } + } // replacement track pair + } // collision pair + } + PROCESS_SWITCH(lambdaspincorrderived, processME, "Process data ME", false); + + void processMEV2(EventCandidates const& collisions, AllTrackCandidates const& V0s) + { + auto nBins = colBinning.getAllBinsCount(); + std::vector>> eventPools(nBins); + + for (auto& collision1 : collisions) { + int bin = colBinning.getBin(std::make_tuple(collision1.posz(), collision1.cent())); + auto poolA = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); + float centrality = collision1.cent(); + + // <<< CHANGED: map old collision index → set of (t2.idx, t3.idx) we've already filled + std::unordered_map>> seenMap; + + for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(poolA, poolA))) { + if (!selectionV0(t1) || !selectionV0(t2)) + continue; + if (t2.index() <= t1.index()) + continue; + if (t1.protonIndex() == t2.protonIndex()) + continue; + if (t1.pionIndex() == t2.pionIndex()) + continue; + + int mixes = 0; + for (auto it = eventPools[bin].rbegin(); it != eventPools[bin].rend() && mixes < nEvtMixing; ++it, ++mixes) { + int collision2idx = it->first; + AllTrackCandidates& poolB = it->second; + + int nRepl = 0; + for (auto& t3 : poolB) { + if (selectionV0(t3) && checkKinematics(t1, t3)) { + ++nRepl; + } + } + if (nRepl == 0) + continue; + float invN = 1.0f / static_cast(nRepl); + + for (auto& t3 : poolB) { + if (!(selectionV0(t3) && checkKinematics(t1, t3))) { + continue; + } + if (collision1.index() == collision2idx) { + continue; + } + + // <<< CHANGED: dedupe (t2, t3) pairs per prior collision + auto key = std::make_pair(t2.index(), t3.index()); + auto& seen = seenMap[collision2idx]; + if (!seen.insert(key).second) { + continue; + } + + // reconstruct 4-vectors + proton = ROOT::Math::PtEtaPhiMVector(t3.protonPt(), t3.protonEta(), t3.protonPhi(), o2::constants::physics::MassProton); + lambda = ROOT::Math::PtEtaPhiMVector(t3.lambdaPt(), t3.lambdaEta(), t3.lambdaPhi(), t3.lambdaMass()); + proton2 = ROOT::Math::PtEtaPhiMVector(t2.protonPt(), t2.protonEta(), t2.protonPhi(), o2::constants::physics::MassProton); + lambda2 = ROOT::Math::PtEtaPhiMVector(t2.lambdaPt(), t2.lambdaEta(), t2.lambdaPhi(), t2.lambdaMass()); + + float dPhi = std::fabs(RecoDecay::constrainAngle(lambda.Phi(), 0.0F, harmonic) - RecoDecay::constrainAngle(lambda2.Phi(), 0.0F, harmonic)); + histos.fill(HIST("deltaPhiMix"), dPhi, invN); + + if (t3.v0Status() == 0 && t2.v0Status() == 0) { + fillHistograms(0, 0, lambda, lambda2, proton, proton2, centrality, 1, invN); + } + if (t3.v0Status() == 0 && t2.v0Status() == 1) { + fillHistograms(0, 1, lambda, lambda2, proton, proton2, centrality, 1, invN); + } + if (t3.v0Status() == 1 && t2.v0Status() == 0) { + fillHistograms(1, 0, lambda2, lambda, proton2, proton, centrality, 1, invN); + } + if (t3.v0Status() == 1 && t2.v0Status() == 1) { + fillHistograms(1, 1, lambda, lambda2, proton, proton2, centrality, 1, invN); + } + } + } // end mixing-event loop + } // end same-event pair loop + + auto sliced = V0s.sliceBy(tracksPerCollisionV0, collision1.index()); + eventPools[bin].emplace_back(collision1.index(), std::move(sliced)); + if (static_cast(eventPools[bin].size()) > nEvtMixing) { + eventPools[bin].pop_front(); + } + } // end primary-event loop + } + PROCESS_SWITCH(lambdaspincorrderived, processMEV2, "Process data ME", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Strangeness/nonPromptCascade.cxx b/PWGLF/Tasks/Strangeness/nonPromptCascade.cxx index 67be5f07532..488e5815ce0 100644 --- a/PWGLF/Tasks/Strangeness/nonPromptCascade.cxx +++ b/PWGLF/Tasks/Strangeness/nonPromptCascade.cxx @@ -14,18 +14,25 @@ #include #include +#include "Math/Vector4D.h" + #include "CCDB/BasicCCDBManager.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Multiplicity.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" +#include "DetectorsVertexing/PVertexer.h" +#include "ReconstructionDataFormats/Vertex.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" #include "DataFormatsTPC/BetheBlochAleph.h" #include "DCAFitter/DCAFitterN.h" #include "DetectorsBase/Propagator.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" @@ -50,9 +57,11 @@ struct NPCascCandidate { int64_t trackITSID; int64_t collisionID; float matchingChi2; + float deltaPtITS; float deltaPt; float itsClusSize; bool hasReassociatedCluster; + bool hasFakeReassociation; bool isGoodMatch; bool isGoodCascade; int pdgCodeMom; @@ -60,6 +69,7 @@ struct NPCascCandidate { bool isFromBeauty; bool isFromCharm; uint16_t pvContributors; + uint8_t cascPVContribs; float pvTimeResolution; float pvX; float pvY; @@ -93,40 +103,31 @@ struct NPCascCandidate { int cascNClusITS; int protonNClusITS; int pionNClusITS; - int bachKaonNClusITS; - int bachPionNClusITS; + int bachNClusITS; int protonNClusTPC; int pionNClusTPC; - int bachKaonNClusTPC; - int bachPionNClusTPC; + int bachNClusTPC; float protonTPCNSigma; float pionTPCNSigma; float bachKaonTPCNSigma; float bachPionTPCNSigma; bool protonHasTOF; bool pionHasTOF; - bool bachKaonHasTOF; - bool bachPionHasTOF; + bool bachHasTOF; float protonTOFNSigma; float pionTOFNSigma; float bachKaonTOFNSigma; float bachPionTOFNSigma; + bool sel8; + float multFT0C; + float multFT0A; + float multFT0M; + float centFT0C; + float centFT0A; + float centFT0M; + int multNTracksGlobal; + uint32_t toiMask; }; - -struct motherDCA { - float DCAxy; - float DCAz; -}; - -struct daughtersDCA { - float bachDCAxy; - float bachDCAz; - float protonDCAxy; - float protonDCAz; - float pionDCAxy; - float pionDCAz; -}; - std::array isFromHF(auto& particle) { bool fromBeauty = false; @@ -158,13 +159,9 @@ static constexpr float cutsPID[nParticles][nCutsPID]{ {-4.f, +4.f}, /*Pr*/ {-4.f, +4.f}, /*Pi*/ }; -std::shared_ptr h2TPCsignal[nParticles]; -std::shared_ptr h2TPCnSigma[nParticles]; - -std::shared_ptr invMassBCV0; -std::shared_ptr invMassACV0; -std::vector candidates; +std::vector gCandidates; +std::vector gCandidatesNT; } // namespace @@ -172,76 +169,46 @@ struct NonPromptCascadeTask { Produces NPCTable; Produces NPCTableMC; + Produces NPCTableNT; + Produces NPCTableMCNT; Produces NPCTableGen; using TracksExtData = soa::Join; using TracksExtMC = soa::Join; - using CollisionCandidatesRun3 = soa::Join; - using CollisionCandidatesRun3MC = soa::Join; + using CollisionCandidatesRun3 = soa::Join; + using CollisionCandidatesRun3MC = soa::Join; + + Preslice perCollision = aod::track::collisionId; + Preslice perCollisionMC = aod::track::collisionId; + + HistogramRegistry mRegistry; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable propToDCA{"propToDCA", true, "create tracks version propagated to PCA"}; - Configurable useAbsDCA{"useAbsDCA", true, "Minimise abs. distance rather than chi2"}; - Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; - Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; - Configurable minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"}; - Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations if chi2/chi2old > this"}; + Configurable cfgPropToPCA{"cfgPropToPCA", true, "create tracks version propagated to PCA"}; + Configurable cfgRedoPV{"cfgRedoPV", true, "redo PV"}; + Configurable cfgUseAbsDCA{"cfgUseAbsDCA", true, "Minimise abs. distance rather than chi2"}; + Configurable cfgMaxR{"cfgMaxR", 200., "reject PCA's above this radius"}; + Configurable cfgMaxDZIni{"cfgMaxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; + Configurable cfgMinParamChange{"cfgMinParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"}; + Configurable cfgMinRelChi2Change{"cfgMinRelChi2Change", 0.9, "stop iterations if chi2/chi2old > this"}; Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrLUT), "Type of material correction"}; Configurable cfgGRPmagPath{"cfgGRPmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable cfgSelectOnlyOmegas{"cfgSelectOnlyOmegas", false, "Toggle to select only Omegas"}; - Configurable cfgCutNclusTPC{"cfgCutNclusTPC", 70, "Minimum number of TPC clusters"}; + Configurable cfgCutNclusTPC{"cfgCutNclusTPC", 70, "Minimum number of TPC clusters"}; + Configurable cfgMinCosPA{"cfgMinCosPA", -1.f, "Minimum cosine of pointing angle"}; Configurable> cfgCutsPID{"particlesCutsPID", {cutsPID[0], nParticles, nCutsPID, particlesNames, cutsNames}, "Nuclei PID selections"}; + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", true, "Skimmed dataset processing"}; + Configurable cfgTriggersOfInterest{"cfgTriggersOfInterest", "fTrackedOmega,fOmegaHighMult", "Triggers of interest, comma separated for Zorro"}; - Service ccdb; + Zorro mZorro; + OutputObj mZorroSummary{"ZorroSummary"}; + SliceCache cache; + + Service mCCDB; int mRunNumber = 0; - float bz = 0.f; - - HistogramRegistry registry{ - "registry", - { - {"h_PV_x", "Primary vertex x;x (cm)", {HistType::kTH1D, {{100, -1., 1.}}}}, - {"h_PV_y", "Primary vertex y;y (cm)", {HistType::kTH1D, {{100, -1., 1.}}}}, - {"h_PV_z", "Primary vertex z;z (cm)", {HistType::kTH1D, {{100, -1., 1.}}}}, - - {"h_dca_Omega", "DCA;DCA (cm)", {HistType::kTH1D, {{200, 0., .5}}}}, - {"h_dcaxy_Omega", "DCA xy;DCA_{xy} (cm)", {HistType::kTH1D, {{200, -.5, .5}}}}, - {"h_dcaz_Omega", "DCA z;DCA_{z} (cm)", {HistType::kTH1D, {{200, -.5, .5}}}}, - {"h_bachdcaxyM_Omega", "Bachelor DCA xy;DCA_{xy} (cm)", {HistType::kTH1D, {{200, -1., 1.}}}}, - {"h_bachdcaxyAM_Omega", "Bachelor DCA xy;DCA_{xy} (cm)", {HistType::kTH1D, {{200, -1., 1.}}}}, - {"h_bachdcazM_Omega", "Bachelor DCA z;DCA_{z} (cm)", {HistType::kTH1D, {{200, -1., 1.}}}}, - {"h_bachdcazAM_Omega", "Bachelor DCA z;DCA_{z} (cm)", {HistType::kTH1D, {{200, -1., 1.}}}}, - {"h_dcavspt_Omega", "DCA vs p_{T};DCA (cm);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{100, -0.1, 0.1}, {50, 0., 10.}}}}, - {"h_bachdcavspt_Omega", "Bachelor DCA vs p_{T};DCA (cm);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{200, -1., 1.}, {50, 0., 10.}}}}, - {"h_bachdcavsr_Omega", "Bachelor DCA vs R (cm);DCA (cm);R (cm)", {HistType::kTH2D, {{200, -1., 1.}, {50, 0., 30.}}}}, - {"h_ntrackdcavspt_Omega", "N track DCA vs p_{T};DCA (cm);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{200, -1., 1.}, {50, 0., 10.}}}}, - {"h_ptrackdcavspt_Omega", "P track DCA vs p_{T};DCA (cm);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{200, -1., 1.}, {50, 0., 10.}}}}, - {"h_dcavsr_Omega", "DCA vs R;DCA (cm);R (cm)", {HistType::kTH2D, {{200, -.5, .5}, {200, 0., 5.}}}}, - {"h_massvspt_Omega", "Mass vs p_{T};Mass (GeV/#it{c}^2);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{125, 1.650, 1.700}, {50, 0., 10.}}}}, - {"h_buildermassvspt_Omega", "Mass (from builder) vs p_{T};Mass (GeV/#it{c}^2);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{125, 1.650, 1.700}, {50, 0., 10.}}}}, - {"h_massvsmass_Omega", "Mass vs mass;Mass (GeV/#it{c}^{2});Mass (GeV/#it{c}^{2})", {HistType::kTH2D, {{125, 1.650, 1.700}, {125, 1.650, 1.700}}}}, - {"h_bachelorsign_Omega", "Bachelor sign;Sign;Counts", {HistType::kTH1D, {{6, -3., 3.}}}}, - - {"h_dca_Xi", "DCA;DCA (cm)", {HistType::kTH1D, {{200, 0., .5}}}}, - {"h_dcaxy_Xi", "DCA xy;DCA_{xy} (cm)", {HistType::kTH1D, {{200, -.5, .5}}}}, - {"h_dcaz_Xi", "DCA z;DCA_{z} (cm)", {HistType::kTH1D, {{200, -.5, .5}}}}, - {"h_bachdcaxyM_Xi", "Bachelor DCA xy;DCA_{xy} (cm)", {HistType::kTH1D, {{200, -1., 1.}}}}, - {"h_bachdcaxyAM_Xi", "Bachelor DCA xy;DCA_{xy} (cm)", {HistType::kTH1D, {{200, -1., 1.}}}}, - {"h_bachdcazM_Xi", "Bachelor DCA z;DCA_{z} (cm)", {HistType::kTH1D, {{200, -1., 1.}}}}, - {"h_bachdcazAM_Xi", "Bachelor DCA z;DCA_{z} (cm)", {HistType::kTH1D, {{200, -1., 1.}}}}, - {"h_dcavspt_Xi", "DCA vs p_{T};DCA (cm);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{100, -0.1, 0.1}, {50, 0., 10.}}}}, - {"h_bachdcavspt_Xi", "Bachelor DCA vs p_{T};DCA (cm);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{200, -1., 1.}, {50, 0., 10.}}}}, - {"h_bachdcavsr_Xi", "Bachelor DCA vs R (cm);DCA (cm);R (cm)", {HistType::kTH2D, {{200, -1., 1.}, {50, 0., 30.}}}}, - {"h_ntrackdcavspt_Xi", "N track DCA vs p_{T};DCA (cm);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{200, -1., 1.}, {50, 0., 10.}}}}, - {"h_ptrackdcavspt_Xi", "P track DCA vs p_{T};DCA (cm);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{200, -1., 1.}, {50, 0., 10.}}}}, - {"h_dcavsr_Xi", "DCA vs R;DCA (cm);R (cm)", {HistType::kTH2D, {{200, -.5, .5}, {200, 0., 5.}}}}, - {"h_massvspt_Xi", "Mass vs p_{T};Mass (GeV/#it{c}^2);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{125, 1.296, 1.346}, {50, 0., 10.}}}}, - {"h_buildermassvspt_Xi", "Mass (from builder) vs p_{T};Mass (GeV/#it{c}^2);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{125, 1.296, 1.346}, {50, 0., 10.}}}}, - {"h_massvsmass_Xi", "Mass vs mass;Mass (GeV/#it{c}^{2});Mass (GeV/#it{c}^{2})", {HistType::kTH2D, {{125, 1.296, 1.346}, {125, 1.296, 1.346}}}}, - {"h_bachelorsign_Xi", "Bachelor sign;Sign;Counts", {HistType::kTH1D, {{6, -3., 3.}}}}, - - {"h_massvspt_V0", "Mass vs p_{T};Mass (GeV/#it{c}^2);p_{T} (GeV/#it{c})", {HistType::kTH2D, {{125, 1.090, 1.140}, {50, 0., 10.}}}}, - - }}; + float mBz = 0.f; + o2::vertexing::DCAFitterN<2> mDCAFitter; void initCCDB(aod::BCsWithTimestamps::iterator const& bc) { @@ -250,205 +217,237 @@ struct NonPromptCascadeTask { } mRunNumber = bc.runNumber(); - if (o2::parameters::GRPMagField* grpmag = ccdb->getForRun(cfgGRPmagPath, mRunNumber)) { + if (o2::parameters::GRPMagField* grpmag = mCCDB->getForRun(cfgGRPmagPath, mRunNumber)) { o2::base::Propagator::initFieldFromGRP(grpmag); + mBz = static_cast(grpmag->getNominalL3Field()); } + mDCAFitter.setBz(mBz); if (static_cast(cfgMaterialCorrection.value) == o2::base::Propagator::MatCorrType::USEMatCorrLUT) { - auto* lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForRun("GLO/Param/MatLUT", mRunNumber)); - o2::base::Propagator::Instance(true)->setMatLUT(lut); + auto* lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(mCCDB->getForRun("GLO/Param/MatLUT", mRunNumber)); + o2::base::Propagator::Instance()->setMatLUT(lut); } } void init(InitContext const&) { - ccdb->setURL(ccdbUrl); - ccdb->setFatalWhenNull(true); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); + mZorroSummary.setObject(mZorro.getZorroSummary()); + mCCDB->setURL(ccdbUrl); + mCCDB->setFatalWhenNull(true); + mCCDB->setCaching(true); + mCCDB->setLocalObjectValidityChecking(); + + mDCAFitter.setPropagateToPCA(cfgPropToPCA); + mDCAFitter.setMaxR(cfgMaxR); + mDCAFitter.setMaxDZIni(cfgMaxDZIni); + mDCAFitter.setMinParamChange(cfgMinParamChange); + mDCAFitter.setMinRelChi2Change(cfgMinRelChi2Change); + mDCAFitter.setUseAbsDCA(cfgUseAbsDCA); std::vector ptBinning = {0.4, 0.8, 1.2, 1.6, 2.0, 2.4, 2.8, 3.2, 3.6, 4.0, 4.4, 4.8, 5.2, 5.6, 6.0}; - AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/#it{c})"}; - - auto cutsOmega{std::get>(registry.add("h_PIDcutsOmega", ";;Invariant mass (GeV/#it{c}^{2})", HistType::kTH2D, {{6, -0.5, 5.5}, {125, 1.650, 1.700}}))}; - cutsOmega->GetXaxis()->SetBinLabel(1, "Tot #Omega"); - cutsOmega->GetXaxis()->SetBinLabel(2, "hasTof"); - cutsOmega->GetXaxis()->SetBinLabel(3, "nClusTPC"); - cutsOmega->GetXaxis()->SetBinLabel(4, "nSigmaTPCbach"); - cutsOmega->GetXaxis()->SetBinLabel(5, "nSigmaTPCprotontrack"); - cutsOmega->GetXaxis()->SetBinLabel(6, "nSigmaTPCpiontrack"); - - auto cutsXi{std::get>(registry.add("h_PIDcutsXi", ";;Invariant mass (GeV/#it{c}^{2})", HistType::kTH2D, {{6, -0.5, 5.5}, {125, 1.296, 1.346}}))}; - cutsXi->GetXaxis()->SetBinLabel(1, "Tot #Xi"); - cutsXi->GetXaxis()->SetBinLabel(2, "hasTof"); - cutsXi->GetXaxis()->SetBinLabel(3, "nClusTPC"); - cutsXi->GetXaxis()->SetBinLabel(4, "nSigmaTPCbach"); - cutsXi->GetXaxis()->SetBinLabel(5, "nSigmaTPCprotontrack"); - cutsXi->GetXaxis()->SetBinLabel(6, "nSigmaTPCpiontrack"); - - invMassBCV0 = registry.add("h_invariantmass_beforeCuts_V0", "Invariant Mass (GeV/#it{c}^{2})", HistType::kTH1D, {{125, 1.090, 1.140, "Invariant Mass (GeV/#it{c}^{2})"}}); - invMassACV0 = registry.add("h_invariantmass_afterCuts_V0", "Invariant Mass (GeV/#it{c}^{2})", HistType::kTH1D, {{125, 1.090, 1.140, "Invariant Mass (GeV/#it{c}^{2})"}}); + // AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec centAxis = {101, 0., 101., "Centrality"}; + AxisSpec centAxisZoom = {100, 0., 10., "Centrality"}; + AxisSpec multAxis = {10000, 0, 10000, "Multiplicity FT0M"}; + AxisSpec multAxisZoom = {7000, 3000, 10000, "Multiplicity FT0M"}; + AxisSpec nTracksAxis = {100, 0., 100., "NTracksGlobal"}; + + std::array cutsNames{"# candidates", "hasTOF", "nClusTPC", "nSigmaTPCbach", "nSigmaTPCprotontrack", "nSigmaTPCpiontrack", "cosPA"}; + auto cutsOmega{std::get>(mRegistry.add("h_PIDcutsOmega", ";;Invariant mass (GeV/#it{c}^{2})", HistType::kTH2D, {{cutsNames.size(), -0.5, -0.5 + cutsNames.size()}, {125, 1.650, 1.700}}))}; + auto cutsXi{std::get>(mRegistry.add("h_PIDcutsXi", ";;Invariant mass (GeV/#it{c}^{2})", HistType::kTH2D, {{6, -0.5, 5.5}, {125, 1.296, 1.346}}))}; + mRegistry.add("hMultVsCent", "hMultVsCent", HistType::kTH2F, {centAxis, multAxis}); + mRegistry.add("hMultVsCentZoom", "hMultVsCentZoom", HistType::kTH2F, {centAxisZoom, multAxisZoom}); + mRegistry.add("hNTracksVsCent", "hNTracksVsCent", HistType::kTH2F, {centAxis, nTracksAxis}); + mRegistry.add("hNTracksVsCentZoom", "hNTracksVsCentZoom", HistType::kTH2F, {centAxisZoom, nTracksAxis}); + + for (size_t iBin{0}; iBin < cutsNames.size(); ++iBin) { + cutsOmega->GetYaxis()->SetBinLabel(iBin + 1, cutsNames[iBin].c_str()); + cutsXi->GetYaxis()->SetBinLabel(iBin + 1, cutsNames[iBin].c_str()); + } } - template - void fillCascadeDCA(T const track, PR const& protonTrack, PI const& pionTrack, o2::dataformats::VertexBase primaryVertex, bool isOmega, motherDCA& mDCA) + template + bool recalculatePV(CollisionType const& collision, TrackType const& tracks, int idToRemove, o2::dataformats::VertexBase& primaryVertex) { - const auto matCorr = static_cast(cfgMaterialCorrection.value); - auto trackCovTrk = getTrackParCov(track); - o2::dataformats::DCA impactParameterTrk; - - if (o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, trackCovTrk, bz, 2.f, matCorr, &impactParameterTrk)) { - if (protonTrack.hasTPC() && pionTrack.hasTPC()) { - if (isOmega) { - registry.fill(HIST("h_dca_Omega"), std::sqrt(impactParameterTrk.getR2())); - registry.fill(HIST("h_dcaxy_Omega"), impactParameterTrk.getY()); - registry.fill(HIST("h_dcaz_Omega"), impactParameterTrk.getZ()); - registry.fill(HIST("h_dcavspt_Omega"), impactParameterTrk.getY(), track.pt()); - registry.fill(HIST("h_dcavsr_Omega"), impactParameterTrk.getY(), std::hypot(track.x(), track.y())); - } - } - - if (protonTrack.hasTPC() && pionTrack.hasTPC()) { - registry.fill(HIST("h_dca_Xi"), std::sqrt(impactParameterTrk.getR2())); - registry.fill(HIST("h_dcaxy_Xi"), impactParameterTrk.getY()); - registry.fill(HIST("h_dcaz_Xi"), impactParameterTrk.getZ()); - registry.fill(HIST("h_dcavspt_Xi"), impactParameterTrk.getY(), track.pt()); - registry.fill(HIST("h_dcavsr_Xi"), impactParameterTrk.getY(), std::hypot(track.x(), track.y())); + // slice tracks by collision + o2::vertexing::PVertexer vertexer; + std::vector pvContributors = {}; + std::vector pvContributorsMask = {}; + + auto tracksInCollision = doprocessTrackedCascadesMC ? tracks.sliceBy(perCollisionMC, collision.globalIndex()) : tracks.sliceBy(perCollision, collision.globalIndex()); + // loop over tracks + for (auto const& trkInColl : tracksInCollision) { // Loop on tracks + if (trkInColl.isPVContributor()) { + pvContributors.push_back(getTrackParCov(trkInColl)); + idToRemove == trkInColl.globalIndex() ? pvContributorsMask.push_back(false) : pvContributorsMask.push_back(true); } } - mDCA.DCAxy = impactParameterTrk.getY(); - mDCA.DCAz = impactParameterTrk.getZ(); + LOG(debug) << "Tracks pushed to the vector: " << pvContributors.size(); + vertexer.init(); + bool canRefit = vertexer.prepareVertexRefit(pvContributors, primaryVertex); + if (!canRefit) { + return false; + } + // refit the vertex + auto newPV = vertexer.refitVertex(pvContributorsMask, primaryVertex); + // set the new vertex to primaryVertex + primaryVertex.setX(newPV.getX()); + primaryVertex.setY(newPV.getY()); + primaryVertex.setZ(newPV.getZ()); + primaryVertex.setCov(newPV.getCov()); + return true; } - template - void fillDauDCA(TC const& trackedCascade, B const& bachelor, PR const& protonTrack, PI const& pionTrack, o2::dataformats::VertexBase primaryVertex, bool isOmega, daughtersDCA& dDCA) + void zorroAccounting(const auto& collisions, auto& toiMap) { - const auto matCorr = static_cast(cfgMaterialCorrection.value); - - auto trackCovBach = getTrackParCov(bachelor); - o2::dataformats::DCA impactParameterBach; - if (o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, trackCovBach, bz, 2.f, matCorr, &impactParameterBach)) { - if (isOmega) { - if (bachelor.sign() < 0) { - registry.fill(HIST("h_bachdcaxyM_Omega"), impactParameterBach.getY()); - registry.fill(HIST("h_bachdcazM_Omega"), impactParameterBach.getZ()); - } else if (bachelor.sign() > 0) { - registry.fill(HIST("h_bachdcaxyAM_Omega"), impactParameterBach.getY()); - registry.fill(HIST("h_bachdcazAM_Omega"), impactParameterBach.getZ()); + if (cfgSkimmedProcessing) { + int runNumber{-1}; + for (const auto& coll : collisions) { + auto bc = coll.template bc_as(); + if (runNumber != bc.runNumber()) { + mZorro.initCCDB(mCCDB.service, bc.runNumber(), bc.timestamp(), cfgTriggersOfInterest.value); + if (mZorro.getNTOIs() > 32) { + LOG(fatal) << "N TOIs:" << mZorro.getNTOIs() << " Max 32 TOIs possible."; + } + mZorro.populateHistRegistry(mRegistry, bc.runNumber()); + runNumber = bc.runNumber(); + } + bool sel = mZorro.isSelected(bc.globalBC()); /// Just let Zorro do the accounting + if (sel) { + std::vector toivect = mZorro.getTriggerOfInterestResults(); + uint32_t toiMask = 0; + for (size_t i{0}; i < toivect.size(); i++) { + toiMask += toivect[i] << i; + } + toiMap[bc.globalBC()] = toiMask; } - registry.fill(HIST("h_bachdcavspt_Omega"), impactParameterBach.getY(), bachelor.pt()); - registry.fill(HIST("h_bachdcavsr_Omega"), impactParameterBach.getY(), std::hypot(trackedCascade.decayX(), trackedCascade.decayY())); - registry.fill(HIST("h_bachelorsign_Omega"), bachelor.sign()); - } - if (bachelor.sign() < 0) { - registry.fill(HIST("h_bachdcaxyM_Xi"), impactParameterBach.getY()); - registry.fill(HIST("h_bachdcazM_Xi"), impactParameterBach.getZ()); - } else if (bachelor.sign() > 0) { - registry.fill(HIST("h_bachdcaxyAM_Xi"), impactParameterBach.getY()); - registry.fill(HIST("h_bachdcazAM_Xi"), impactParameterBach.getZ()); - } - registry.fill(HIST("h_bachdcavspt_Xi"), impactParameterBach.getY(), bachelor.pt()); - registry.fill(HIST("h_bachdcavsr_Xi"), impactParameterBach.getY(), std::hypot(trackedCascade.decayX(), trackedCascade.decayY())); - registry.fill(HIST("h_bachelorsign_Xi"), bachelor.sign()); - } - - auto trackCovNtrack = getTrackParCov(pionTrack); - o2::dataformats::DCA impactParameterPiontrack; - if (o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, trackCovNtrack, bz, 2.f, matCorr, &impactParameterPiontrack)) { - if (isOmega) { - registry.fill(HIST("h_ntrackdcavspt_Omega"), impactParameterPiontrack.getY(), pionTrack.pt()); - } - registry.fill(HIST("h_ntrackdcavspt_Xi"), impactParameterPiontrack.getY(), pionTrack.pt()); - } - - auto trackCovPtrack = getTrackParCov(protonTrack); - o2::dataformats::DCA impactParameterProtontrack; - if (o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, trackCovPtrack, bz, 2.f, matCorr, &impactParameterProtontrack)) { - if (isOmega) { - registry.fill(HIST("h_ptrackdcavspt_Omega"), impactParameterProtontrack.getY(), protonTrack.pt()); } - registry.fill(HIST("h_ptrackdcavspt_Xi"), impactParameterProtontrack.getY(), protonTrack.pt()); } - - dDCA.bachDCAxy = impactParameterBach.getY(); - dDCA.bachDCAz = impactParameterBach.getZ(); - dDCA.protonDCAxy = impactParameterProtontrack.getY(); - dDCA.protonDCAz = impactParameterProtontrack.getZ(); - dDCA.pionDCAxy = impactParameterPiontrack.getY(); - dDCA.pionDCAz = impactParameterPiontrack.getZ(); } + void fillMultHistos(const auto& collisions) + { + // std::cout << "Filling mult histos" << std::endl; + for (const auto& coll : collisions) { + // std::cout << coll.centFT0M() << " mult, cent " << coll.multNTracksGlobal() << std::endl; + mRegistry.fill(HIST("hMultVsCent"), coll.centFT0M(), coll.multFT0M()); + mRegistry.fill(HIST("hMultVsCentZoom"), coll.centFT0M(), coll.multFT0M()); + mRegistry.fill(HIST("hNTracksVsCent"), coll.centFT0M(), (float)coll.multNTracksGlobal()); + mRegistry.fill(HIST("hNTracksVsCentZoom"), coll.centFT0M(), coll.multNTracksGlobal()); + } + }; template - void fillCandidatesVector(CollisionType const&, auto const& trackedCascades) + void fillCandidatesVector(CollisionType const&, TrackType const& tracks, auto const& cascades, auto& candidates, std::map toiMap = {}) { + + const auto& getCascade = [](auto const& candidate) { + if constexpr (requires { candidate.cascade(); }) { + return candidate.cascade(); + } else { + return candidate; + } + }; + candidates.clear(); - for (const auto& trackedCascade : trackedCascades) { + for (const auto& candidate : cascades) { - auto collision = trackedCascade.template collision_as(); + auto collision = candidate.template collision_as(); auto bc = collision.template bc_as(); initCCDB(bc); - const auto primaryVertex = getPrimaryVertex(collision); + auto primaryVertex = getPrimaryVertex(collision); - o2::vertexing::DCAFitterN<2> df2; - df2.setBz(bz); - df2.setPropagateToPCA(propToDCA); - df2.setMaxR(maxR); - df2.setMaxDZIni(maxDZIni); - df2.setMinParamChange(minParamChange); - df2.setMinRelChi2Change(minRelChi2Change); - df2.setUseAbsDCA(useAbsDCA); - - const auto& track = trackedCascade.template track_as(); - const auto& ITStrack = trackedCascade.template itsTrack_as(); - const auto& casc = trackedCascade.cascade(); + const auto& casc = getCascade(candidate); const auto& bachelor = casc.template bachelor_as(); const auto& v0 = casc.v0(); const auto& ptrack = v0.template posTrack_as(); const auto& ntrack = v0.template negTrack_as(); const auto& protonTrack = bachelor.sign() > 0 ? ntrack : ptrack; const auto& pionTrack = bachelor.sign() > 0 ? ptrack : ntrack; - bool hasReassociatedClusters = (track.itsNCls() != ITStrack.itsNCls()); - std::array, 2> momenta; - std::array v0Pos; - std::array masses; + // first bit for the strange track, second for pos v0, third for neg v0, fourth for bachelor + uint8_t cascPVContribs = 0; + cascPVContribs |= ptrack.isPVContributor() << 1; + cascPVContribs |= ntrack.isPVContributor() << 2; + cascPVContribs |= bachelor.isPVContributor() << 3; - // track propagation - o2::track::TrackParCov trackParCovV0; - o2::track::TrackPar trackParV0; - o2::track::TrackPar trackParBachelor; - std::array cascadeMomentum; + mRegistry.fill(HIST("h_PIDcutsXi"), 0, 1.322); + mRegistry.fill(HIST("h_PIDcutsOmega"), 0, 1.675); + + mRegistry.fill(HIST("h_PIDcutsXi"), 1, 1.322); + mRegistry.fill(HIST("h_PIDcutsOmega"), 1, 1.675); + + if (protonTrack.tpcNClsFound() < cfgCutNclusTPC || pionTrack.tpcNClsFound() < cfgCutNclusTPC || bachelor.tpcNClsFound() < cfgCutNclusTPC) { + continue; + } + mRegistry.fill(HIST("h_PIDcutsXi"), 2, 1.322); + mRegistry.fill(HIST("h_PIDcutsOmega"), 2, 1.675); - float cascCpa = -1; - float v0Cpa = -1; - if (df2.process(getTrackParCov(pionTrack), getTrackParCov(protonTrack))) { - trackParCovV0 = df2.createParentTrackParCov(0); // V0 track retrieved from p and pi daughters - v0Pos = {trackParCovV0.getX(), trackParCovV0.getY(), trackParCovV0.getZ()}; - if (df2.process(trackParCovV0, getTrackParCov(bachelor))) { - trackParV0 = df2.getTrackParamAtPCA(0); - trackParBachelor = df2.getTrackParamAtPCA(1); - trackParV0.getPxPyPzGlo(momenta[0]); // getting the V0 momentum - trackParBachelor.getPxPyPzGlo(momenta[1]); // getting the bachelor momentum - df2.createParentTrackParCov().getPxPyPzGlo(cascadeMomentum); + // QA PID + float nSigmaTPC[nParticles]{bachelor.tpcNSigmaKa(), bachelor.tpcNSigmaPi(), protonTrack.tpcNSigmaPr(), pionTrack.tpcNSigmaPi()}; + + bool isBachelorSurvived = false; + if (nSigmaTPC[0] > cfgCutsPID->get(0u, 0u) && nSigmaTPC[0] < cfgCutsPID->get(0u, 1u)) { + mRegistry.fill(HIST("h_PIDcutsOmega"), 3, 1.675); + isBachelorSurvived = true; + } + + if (!cfgSelectOnlyOmegas && nSigmaTPC[1] > cfgCutsPID->get(1u, 0u) && nSigmaTPC[1] < cfgCutsPID->get(1u, 1u)) { + mRegistry.fill(HIST("h_PIDcutsXi"), 3, 1.322); + isBachelorSurvived = true; + } + + if (!isBachelorSurvived) { + continue; + } + + if (nSigmaTPC[2] < cfgCutsPID->get(2u, 0u) || nSigmaTPC[2] > cfgCutsPID->get(2u, 1u)) { + continue; + } + + mRegistry.fill(HIST("h_PIDcutsOmega"), 4, 1.675); + mRegistry.fill(HIST("h_PIDcutsXi"), 4, 1.322); + + if (nSigmaTPC[3] < cfgCutsPID->get(3u, 0u) || nSigmaTPC[3] > cfgCutsPID->get(3u, 1u)) { + continue; + } + + mRegistry.fill(HIST("h_PIDcutsOmega"), 5, 1.675); + mRegistry.fill(HIST("h_PIDcutsXi"), 5, 1.322); + + auto protonTrkParCov = getTrackParCov(protonTrack); + auto pionTrkParCov = getTrackParCov(pionTrack); + auto bachTrkParCov = getTrackParCov(bachelor); + + std::array, 2> momenta; + std::array cascadeMomentum; + o2::math_utils::SVector cascadePos, v0Pos; + + float cascCpa = -1, v0Cpa = -1; + o2::track::TrackParCov ntCascadeTrack; + if (mDCAFitter.process(pionTrkParCov, protonTrkParCov)) { + auto trackParCovV0 = mDCAFitter.createParentTrackParCov(0); // V0 track retrieved from p and pi daughters + v0Pos = mDCAFitter.getPCACandidate(); + if (mDCAFitter.process(trackParCovV0, bachTrkParCov)) { + mDCAFitter.getTrackParamAtPCA(0).getPxPyPzGlo(momenta[0]); + mDCAFitter.getTrackParamAtPCA(1).getPxPyPzGlo(momenta[1]); + ntCascadeTrack = mDCAFitter.createParentTrackParCov(); + ntCascadeTrack.getPxPyPzGlo(cascadeMomentum); std::array pvPos = {primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}; - cascCpa = RecoDecay::cpa(pvPos, df2.getPCACandidate(), cascadeMomentum); - v0Cpa = RecoDecay::cpa(pvPos, df2.getPCACandidate(), momenta[0]); + cascadePos = mDCAFitter.getPCACandidate(); + cascCpa = RecoDecay::cpa(pvPos, mDCAFitter.getPCACandidate(), cascadeMomentum); + v0Cpa = RecoDecay::cpa(pvPos, v0Pos, momenta[0]); } else { continue; } } else { continue; } - float deltaPtITSCascade = std::hypot(cascadeMomentum[0], cascadeMomentum[1]) - ITStrack.pt(); - - // PV - registry.fill(HIST("h_PV_x"), primaryVertex.getX()); - registry.fill(HIST("h_PV_y"), primaryVertex.getY()); - registry.fill(HIST("h_PV_z"), primaryVertex.getZ()); + ROOT::Math::LorentzVector> cascadeLvector; + cascadeLvector.SetPxPyPzE(cascadeMomentum[0], cascadeMomentum[1], cascadeMomentum[2], std::hypot(cascadeMomentum[0], cascadeMomentum[1], cascadeMomentum[2])); /// 0 mass, used only for the momentum // Omega - masses = {o2::constants::physics::MassLambda0, o2::constants::physics::MassKPlus}; + std::array masses{o2::constants::physics::MassLambda0, o2::constants::physics::MassKPlus}; const auto massOmega = RecoDecay::m(momenta, masses); // Xi @@ -463,6 +462,9 @@ struct NonPromptCascadeTask { //// Omega hypohesis -> rejecting Xi, we don't do it in the MC as we can identify the particle with the MC truth bool isOmega{std::abs(massXi - constants::physics::MassXiMinus) > 0.005}; + if (cfgSelectOnlyOmegas && !isOmega) { + continue; + } std::array fromHF{false, false}; bool isGoodMatch{false}, isGoodCascade{false}; @@ -478,6 +480,7 @@ struct NonPromptCascadeTask { if (v0part.mothersIds()[0] == bachelor.mcParticle().mothersIds()[0]) { if (std::abs(motherV0.pdgCode()) == 3312 || std::abs(motherV0.pdgCode()) == 3334) { isGoodCascade = true; + isOmega = (std::abs(motherV0.pdgCode()) == 3334); fromHF = isFromHF(motherV0); mcParticleID = v0part.mothersIds()[0]; @@ -486,188 +489,226 @@ struct NonPromptCascadeTask { } } } - isGoodMatch = ((mcParticleID == ITStrack.mcParticleId())) ? true : false; - - if (isGoodMatch) { - pdgCodeMom = track.mcParticle().has_mothers() ? track.mcParticle().template mothers_as()[0].pdgCode() : 0; - } - itsTrackPDG = ITStrack.has_mcParticle() ? ITStrack.mcParticle().pdgCode() : 0; - } - - invMassBCV0->Fill(v0mass); - - registry.fill(HIST("h_PIDcutsXi"), 0, massXi); - registry.fill(HIST("h_PIDcutsOmega"), 0, massOmega); - - int bachKaonNClusTPC = -1; - int bachPionNClusTPC = -1; - int bachKaonNClusITS = -1; - int bachPionNClusITS = -1; - if (isOmega) { - bachKaonNClusTPC = bachelor.tpcNClsFound(); - bachKaonNClusITS = bachelor.itsNCls(); - } - bachPionNClusTPC = bachelor.tpcNClsFound(); /// by default cascade = Xi - bachPionNClusITS = bachelor.itsNCls(); /// by default cascade = Xi - - bool bachKaonHasTOF = 0; - bool bachPionHasTOF = 0; - if (isOmega) { - bachKaonHasTOF = bachelor.hasTOF(); } - bachPionHasTOF = bachelor.hasTOF(); - registry.fill(HIST("h_PIDcutsXi"), 1, massXi); - registry.fill(HIST("h_PIDcutsOmega"), 1, massOmega); - - if (protonTrack.tpcNClsFound() < cfgCutNclusTPC || pionTrack.tpcNClsFound() < cfgCutNclusTPC) { - LOG(debug) << "no tpcNClsFound: " << bachelor.tpcNClsFound() << "/" << protonTrack.tpcNClsFound() << "/" << pionTrack.tpcNClsFound(); + if (cascCpa < cfgMinCosPA) { continue; } - registry.fill(HIST("h_PIDcutsXi"), 2, massXi); - registry.fill(HIST("h_PIDcutsOmega"), 2, massOmega); - - // QA PID - float nSigmaTPC[nParticles]{bachelor.tpcNSigmaKa(), bachelor.tpcNSigmaPi(), protonTrack.tpcNSigmaPr(), pionTrack.tpcNSigmaPi()}; - - bool isBachelorSurvived = false; if (isOmega) { - if (bachelor.hasTPC()) { - LOG(debug) << "TPCSignal bachelor " << bachelor.sign() << "/" << bachelor.tpcInnerParam() << "/" << bachelor.tpcSignal(); - if (nSigmaTPC[0] > cfgCutsPID->get(0u, 0u) && nSigmaTPC[0] < cfgCutsPID->get(0u, 1u)) { - registry.fill(HIST("h_PIDcutsOmega"), 3, massOmega); - isBachelorSurvived = true; + mRegistry.fill(HIST("h_PIDcutsOmega"), 6, massOmega); + } + mRegistry.fill(HIST("h_PIDcutsXi"), 6, massXi); + + const auto matCorr = static_cast(cfgMaterialCorrection.value); + o2::dataformats::DCA motherDCA{-999.f, -999.f}, protonDCA{-999.f, -999.f}, pionDCA{-999.f, -999.f}, bachDCA{-999.f, -999.f}; + o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, protonTrkParCov, mBz, 2.f, matCorr, &protonDCA); + o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, pionTrkParCov, mBz, 2.f, matCorr, &pionDCA); + o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, bachTrkParCov, mBz, 2.f, matCorr, &bachDCA); + + float deltaPtITSCascade{-1.e10f}, deltaPtCascade{-1.e10f}, cascITSclsSize{-1.e10f}, matchingChi2{-1.e10f}; + bool hasReassociatedClusters{false}, hasFakeReassociation{false}; + int trackedCascGlobalIndex{-1}, itsTrackGlobalIndex{-1}, cascITSclusters{-1}; + if constexpr (requires { candidate.track(); }) { + const auto& track = candidate.template track_as(); + const auto& ITStrack = candidate.template itsTrack_as(); + if (cfgRedoPV && ITStrack.isPVContributor()) { + if (!recalculatePV(collision, tracks, ITStrack.globalIndex(), primaryVertex)) { + continue; } } - } - - if (bachelor.hasTPC()) { - LOG(debug) << "TPCSignal bachelor " << bachelor.sign() << "/" << bachelor.tpcInnerParam() << "/" << bachelor.tpcSignal(); - if (nSigmaTPC[1] > cfgCutsPID->get(1u, 0u) && nSigmaTPC[1] < cfgCutsPID->get(1u, 1u)) { - registry.fill(HIST("h_PIDcutsXi"), 3, massXi); - isBachelorSurvived = true; + cascPVContribs |= ITStrack.isPVContributor() << 0; + auto trackTrkParCov = getTrackParCov(track); + o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, trackTrkParCov, mBz, 2.f, matCorr, &motherDCA); + hasReassociatedClusters = (track.itsNCls() != ITStrack.itsNCls()); + cascadeLvector.SetCoordinates(track.pt(), track.eta(), track.phi(), 0); + deltaPtITSCascade = std::hypot(cascadeMomentum[0], cascadeMomentum[1]) - ITStrack.pt(); + deltaPtCascade = std::hypot(cascadeMomentum[0], cascadeMomentum[1]) - track.pt(); + trackedCascGlobalIndex = track.globalIndex(); + itsTrackGlobalIndex = ITStrack.globalIndex(); + cascITSclusters = track.itsNCls(); + cascITSclsSize = candidate.itsClsSize(); + matchingChi2 = candidate.matchingChi2(); + cascadePos = {candidate.decayX(), candidate.decayY(), candidate.decayZ()}; + if constexpr (TrackType::template contains()) { + isGoodMatch = ((mcParticleID == ITStrack.mcParticleId())) ? true : false; + + if (isGoodMatch) { + pdgCodeMom = track.mcParticle().has_mothers() ? track.mcParticle().template mothers_as()[0].pdgCode() : 0; + hasFakeReassociation = track.mcMask() & (1 << 15); + } + itsTrackPDG = ITStrack.has_mcParticle() ? ITStrack.mcParticle().pdgCode() : 0; } + } else { + o2::base::Propagator::Instance()->propagateToDCA(primaryVertex, ntCascadeTrack, mBz, 2.f, matCorr, &motherDCA); } - - if (!isBachelorSurvived) { - continue; - } - - LOG(debug) << "TPCSignal protonTrack " << protonTrack.sign() << "/" << protonTrack.tpcInnerParam() << "/" << protonTrack.tpcSignal(); - if (nSigmaTPC[2] < cfgCutsPID->get(2u, 0u) || nSigmaTPC[2] > cfgCutsPID->get(2u, 1u)) { - continue; + uint32_t toiMask = 0x0; + if (toiMap.count(bc.globalBC())) { + toiMask = toiMap[bc.globalBC()]; } + candidates.emplace_back(NPCascCandidate{mcParticleID, trackedCascGlobalIndex, itsTrackGlobalIndex, candidate.collisionId(), matchingChi2, deltaPtITSCascade, deltaPtCascade, cascITSclsSize, hasReassociatedClusters, hasFakeReassociation, isGoodMatch, isGoodCascade, pdgCodeMom, itsTrackPDG, fromHF[0], fromHF[1], + collision.numContrib(), cascPVContribs, collision.collisionTimeRes(), primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ(), + cascadeLvector.pt(), cascadeLvector.eta(), cascadeLvector.phi(), + protonTrack.pt(), protonTrack.eta(), pionTrack.pt(), pionTrack.eta(), bachelor.pt(), bachelor.eta(), + motherDCA.getY(), motherDCA.getZ(), protonDCA.getY(), protonDCA.getZ(), pionDCA.getY(), pionDCA.getZ(), bachDCA.getY(), bachDCA.getZ(), + cascCpa, v0Cpa, massXi, massOmega, v0mass, + static_cast(std::hypot(cascadePos[0], cascadePos[1])), static_cast(std::hypot(v0Pos[0], v0Pos[1])), static_cast(std::hypot(cascadePos[0], cascadePos[1], cascadePos[2])), static_cast(std::hypot(v0Pos[0], v0Pos[1], v0Pos[2])), + cascITSclusters, protonTrack.itsNCls(), pionTrack.itsNCls(), bachelor.itsNCls(), protonTrack.tpcNClsFound(), pionTrack.tpcNClsFound(), bachelor.tpcNClsFound(), + protonTrack.tpcNSigmaPr(), pionTrack.tpcNSigmaPi(), bachelor.tpcNSigmaKa(), bachelor.tpcNSigmaPi(), + protonTrack.hasTOF(), pionTrack.hasTOF(), bachelor.hasTOF(), + protonTrack.tofNSigmaPr(), pionTrack.tofNSigmaPi(), bachelor.tofNSigmaKa(), bachelor.tofNSigmaPi(), collision.sel8(), collision.multFT0C(), collision.multFT0A(), collision.multFT0M(), collision.centFT0C(), collision.centFT0A(), collision.centFT0M(), collision.multNTracksGlobal(), toiMask}); + } + } - if (isOmega) { - registry.fill(HIST("h_PIDcutsOmega"), 4, massOmega); - } - registry.fill(HIST("h_PIDcutsXi"), 4, massXi); + template + void fillDataTable(auto const& candidates) + { + for (const auto& c : candidates) { + getDataTable()(c.matchingChi2, c.deltaPtITS, c.deltaPt, c.itsClusSize, c.hasReassociatedCluster, + c.pvContributors, c.cascPVContribs, c.pvTimeResolution, c.pvX, c.pvY, c.pvZ, + c.cascPt, c.cascEta, c.cascPhi, + c.protonPt, c.protonEta, c.pionPt, c.pionEta, c.bachPt, c.bachEta, + c.cascDCAxy, c.cascDCAz, c.protonDCAxy, c.protonDCAz, c.pionDCAxy, c.pionDCAz, c.bachDCAxy, c.bachDCAz, + c.casccosPA, c.v0cosPA, + c.massXi, c.massOmega, c.massV0, + c.cascRadius, c.v0radius, c.cascLength, c.v0length, + c.cascNClusITS, c.protonNClusITS, c.pionNClusITS, c.bachNClusITS, c.protonNClusTPC, c.pionNClusTPC, c.bachNClusTPC, + c.protonTPCNSigma, c.pionTPCNSigma, c.bachKaonTPCNSigma, c.bachPionTPCNSigma, + c.protonHasTOF, c.pionHasTOF, c.bachHasTOF, + c.protonTOFNSigma, c.pionTOFNSigma, c.bachKaonTOFNSigma, c.bachPionTOFNSigma, + c.sel8, c.multFT0C, c.multFT0A, c.multFT0M, c.centFT0C, c.centFT0A, c.centFT0M, c.multNTracksGlobal, c.toiMask); + } + } - LOG(debug) << "TPCSignal ntrack " << pionTrack.sign() << "/" << pionTrack.tpcInnerParam() << "/" << pionTrack.tpcSignal(); - if (nSigmaTPC[3] < cfgCutsPID->get(3u, 0u) || nSigmaTPC[3] > cfgCutsPID->get(3u, 1u)) { + template + void fillMCtable(auto const& mcParticles, auto const& collisions, auto const& candidates) + { + for (size_t i = 0; i < candidates.size(); ++i) { + auto& c = candidates[i]; + if (c.mcParticleId < 0) { continue; } - - if (isOmega) { - registry.fill(HIST("h_PIDcutsOmega"), 5, massOmega); - registry.fill(HIST("h_massvspt_Omega"), massOmega, track.pt()); + auto particle = mcParticles.iteratorAt(c.mcParticleId); + int motherDecayDaughters{0}; + if (c.isFromBeauty || c.isFromCharm) { + auto mom = particle.template mothers_as()[0]; + auto daughters = mom.template daughters_as(); + motherDecayDaughters = daughters.size(); + for (const auto& d : daughters) { + if (std::abs(d.pdgCode()) == 11 || std::abs(d.pdgCode()) == 13) { + motherDecayDaughters *= -1; + break; + } + } } + auto mcCollision = particle.template mcCollision_as(); + auto recCollision = collisions.iteratorAt(c.collisionID); + + getMCtable()(c.matchingChi2, c.deltaPtITS, c.deltaPt, c.itsClusSize, c.hasReassociatedCluster, c.isGoodMatch, c.isGoodCascade, c.pdgCodeMom, c.pdgCodeITStrack, c.isFromBeauty, c.isFromCharm, + c.pvContributors, c.cascPVContribs, c.pvTimeResolution, c.pvX, c.pvY, c.pvZ, c.cascPt, c.cascEta, c.cascPhi, + c.protonPt, c.protonEta, c.pionPt, c.pionEta, c.bachPt, c.bachEta, + c.cascDCAxy, c.cascDCAz, c.protonDCAxy, c.protonDCAz, c.pionDCAxy, c.pionDCAz, c.bachDCAxy, c.bachDCAz, + c.casccosPA, c.v0cosPA, c.massXi, c.massOmega, c.massV0, c.cascRadius, c.v0radius, c.cascLength, c.v0length, + c.cascNClusITS, c.protonNClusITS, c.pionNClusITS, c.bachNClusITS, c.protonNClusTPC, c.pionNClusTPC, c.bachNClusTPC, c.protonTPCNSigma, + c.pionTPCNSigma, c.bachKaonTPCNSigma, c.bachPionTPCNSigma, c.protonHasTOF, c.pionHasTOF, c.bachHasTOF, + c.protonTOFNSigma, c.pionTOFNSigma, c.bachKaonTOFNSigma, c.bachPionTOFNSigma, + c.sel8, c.multFT0C, c.multFT0A, c.multFT0M, c.centFT0C, c.centFT0A, c.centFT0M, + particle.pt(), particle.eta(), particle.phi(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), + particle.pdgCode(), mcCollision.posX() - particle.vx(), mcCollision.posY() - particle.vy(), + mcCollision.posZ() - particle.vz(), mcCollision.globalIndex() == recCollision.mcCollisionId(), c.hasFakeReassociation, motherDecayDaughters, c.multNTracksGlobal, c.toiMask); + } + } - registry.fill(HIST("h_PIDcutsXi"), 5, massXi); - registry.fill(HIST("h_massvspt_Xi"), massXi, track.pt()); - - invMassACV0->Fill(v0mass); - registry.fill(HIST("h_massvspt_V0"), v0mass, track.pt()); - - motherDCA mDCA; - fillCascadeDCA(track, protonTrack, pionTrack, primaryVertex, isOmega, mDCA); - daughtersDCA dDCA; - fillDauDCA(trackedCascade, bachelor, protonTrack, pionTrack, primaryVertex, isOmega, dDCA); + template + auto& getMCtable() + { + if constexpr (std::is_same_v) { + return NPCTableMCNT; + } else { + return NPCTableMC; + } + } - candidates.emplace_back(NPCascCandidate{mcParticleID, track.globalIndex(), ITStrack.globalIndex(), trackedCascade.collisionId(), trackedCascade.matchingChi2(), deltaPtITSCascade, trackedCascade.itsClsSize(), hasReassociatedClusters, isGoodMatch, isGoodCascade, pdgCodeMom, itsTrackPDG, fromHF[0], fromHF[1], - collision.numContrib(), collision.collisionTimeRes(), primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ(), - track.pt(), track.eta(), track.phi(), - protonTrack.pt(), protonTrack.eta(), pionTrack.pt(), pionTrack.eta(), bachelor.pt(), bachelor.eta(), - mDCA.DCAxy, mDCA.DCAz, dDCA.protonDCAxy, dDCA.protonDCAz, dDCA.pionDCAxy, dDCA.pionDCAz, dDCA.bachDCAxy, dDCA.bachDCAz, - cascCpa, v0Cpa, - massXi, massOmega, v0mass, - std::hypot(trackedCascade.decayX(), trackedCascade.decayY()), std::hypot(v0Pos[0], v0Pos[1]), std::hypot(trackedCascade.decayX(), trackedCascade.decayY(), trackedCascade.decayZ()), std::hypot(v0Pos[0], v0Pos[1], v0Pos[2]), - track.itsNCls(), protonTrack.itsNCls(), pionTrack.itsNCls(), bachKaonNClusITS, bachPionNClusITS, protonTrack.tpcNClsFound(), pionTrack.tpcNClsFound(), bachKaonNClusTPC, bachPionNClusTPC, - protonTrack.tpcNSigmaPr(), pionTrack.tpcNSigmaPi(), bachelor.tpcNSigmaKa(), bachelor.tpcNSigmaPi(), - protonTrack.hasTOF(), pionTrack.hasTOF(), bachKaonHasTOF, bachPionHasTOF, - protonTrack.tofNSigmaPr(), pionTrack.tofNSigmaPi(), bachelor.tofNSigmaKa(), bachelor.tofNSigmaPi()}); + template + auto& getDataTable() + { + if constexpr (std::is_same_v) { + return NPCTableNT; + } else { + return NPCTable; } } void processTrackedCascadesMC(CollisionCandidatesRun3MC const& collisions, aod::AssignedTrackedCascades const& trackedCascades, aod::Cascades const& /*cascades*/, - aod::V0s const& /*v0s*/, TracksExtMC const& /*tracks*/, + aod::V0s const& /*v0s*/, TracksExtMC const& tracks, aod::McParticles const& mcParticles, aod::McCollisions const&, aod::BCsWithTimestamps const&) { + fillCandidatesVector(collisions, tracks, trackedCascades, gCandidates); + fillMCtable(mcParticles, collisions, gCandidates); + } + PROCESS_SWITCH(NonPromptCascadeTask, processTrackedCascadesMC, "process cascades from strangeness tracking: MC analysis", true); - fillCandidatesVector(collisions, trackedCascades); - - for (size_t i = 0; i < candidates.size(); ++i) { - - if (candidates[i].mcParticleId < 0) { - continue; - } - auto particle = mcParticles.iteratorAt(candidates[i].mcParticleId); - auto& c = candidates[i]; - auto mcCollision = particle.mcCollision_as(); - auto label = collisions.iteratorAt(c.collisionID); - - NPCTableMC(c.matchingChi2, c.deltaPt, c.itsClusSize, c.hasReassociatedCluster, c.isGoodMatch, c.isGoodCascade, c.pdgCodeMom, c.pdgCodeITStrack, c.isFromBeauty, c.isFromCharm, - c.pvContributors, c.pvTimeResolution, c.pvX, c.pvY, c.pvZ, - c.cascPt, c.cascEta, c.cascPhi, - c.protonPt, c.protonEta, c.pionPt, c.pionEta, c.bachPt, c.bachEta, - c.cascDCAxy, c.cascDCAz, c.protonDCAxy, c.protonDCAz, c.pionDCAxy, c.pionDCAz, c.bachDCAxy, c.bachDCAz, - c.casccosPA, c.v0cosPA, - c.massXi, c.massOmega, c.massV0, - c.cascRadius, c.v0radius, c.cascLength, c.v0length, - c.cascNClusITS, c.protonNClusITS, c.pionNClusITS, c.bachKaonNClusITS, c.bachPionNClusITS, c.protonNClusTPC, c.pionNClusTPC, c.bachKaonNClusTPC, c.bachPionNClusTPC, - c.protonTPCNSigma, c.pionTPCNSigma, c.bachKaonTPCNSigma, c.bachPionTPCNSigma, - c.protonHasTOF, c.pionHasTOF, c.bachKaonHasTOF, c.bachPionHasTOF, - c.protonTOFNSigma, c.pionTOFNSigma, c.bachKaonTOFNSigma, c.bachPionTOFNSigma, - particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), mcCollision.posX() - particle.vx(), mcCollision.posY() - particle.vy(), mcCollision.posZ() - particle.vz(), mcCollision.globalIndex() == label.mcCollisionId()); - } + void processCascadesMC(CollisionCandidatesRun3MC const& collisions, aod::Cascades const& cascades, + aod::V0s const& /*v0s*/, TracksExtMC const& tracks, + aod::McParticles const& mcParticles, aod::McCollisions const&, aod::BCsWithTimestamps const&) + { + fillCandidatesVector(collisions, tracks, cascades, gCandidatesNT); + fillMCtable(mcParticles, collisions, gCandidatesNT); + } + PROCESS_SWITCH(NonPromptCascadeTask, processCascadesMC, "process cascades: MC analysis", false); + void processGenParticles(aod::McParticles const& mcParticles, aod::McCollisions const&) + { for (const auto& p : mcParticles) { auto absCode = std::abs(p.pdgCode()); if (absCode != 3312 && absCode != 3334) { continue; } auto fromHF = isFromHF(p); - int pdgCodeMom = p.has_mothers() ? p.mothers_as()[0].pdgCode() : 0; - auto mcCollision = p.mcCollision_as(); + int pdgCodeMom = p.has_mothers() ? p.template mothers_as()[0].pdgCode() : 0; + auto mcCollision = p.template mcCollision_as(); + + int motherDecayDaughters{0}; + if (fromHF[0] || fromHF[1]) { + auto mom = p.template mothers_as()[0]; + auto daughters = mom.template daughters_as(); + motherDecayDaughters = daughters.size(); + for (const auto& d : daughters) { + if (std::abs(d.pdgCode()) == 11 || std::abs(d.pdgCode()) == 13) { + motherDecayDaughters *= -1; + break; + } + } + } - NPCTableGen(p.pt(), p.eta(), p.phi(), p.pdgCode(), pdgCodeMom, mcCollision.posX() - p.vx(), mcCollision.posY() - p.vy(), mcCollision.posZ() - p.vz(), fromHF[0], fromHF[1]); + NPCTableGen(p.pt(), p.eta(), p.phi(), p.pdgCode(), pdgCodeMom, mcCollision.posX() - p.vx(), mcCollision.posY() - p.vy(), mcCollision.posZ() - p.vz(), fromHF[0], fromHF[1], motherDecayDaughters); } } - PROCESS_SWITCH(NonPromptCascadeTask, processTrackedCascadesMC, "process cascades from strangeness tracking: MC analysis", true); + PROCESS_SWITCH(NonPromptCascadeTask, processGenParticles, "process gen cascades: MC analysis", false); void processTrackedCascadesData(CollisionCandidatesRun3 const& collisions, aod::AssignedTrackedCascades const& trackedCascades, aod::Cascades const& /*cascades*/, - aod::V0s const& /*v0s*/, TracksExtData const& /*tracks*/, + aod::V0s const& /*v0s*/, TracksExtData const& tracks, aod::BCsWithTimestamps const&) { - fillCandidatesVector(collisions, trackedCascades); - for (const auto& c : candidates) { - NPCTable(c.matchingChi2, c.deltaPt, c.itsClusSize, c.hasReassociatedCluster, - c.pvContributors, c.pvTimeResolution, c.pvX, c.pvY, c.pvZ, - c.cascPt, c.cascEta, c.cascPhi, - c.protonPt, c.protonEta, c.pionPt, c.pionEta, c.bachPt, c.bachEta, - c.cascDCAxy, c.cascDCAz, c.protonDCAxy, c.protonDCAz, c.pionDCAxy, c.pionDCAz, c.bachDCAxy, c.bachDCAz, - c.casccosPA, c.v0cosPA, - c.massXi, c.massOmega, c.massV0, - c.cascRadius, c.v0radius, c.cascLength, c.v0length, - c.cascNClusITS, c.protonNClusITS, c.pionNClusITS, c.bachKaonNClusITS, c.bachPionNClusITS, c.protonNClusTPC, c.pionNClusTPC, c.bachKaonNClusTPC, c.bachPionNClusTPC, - c.protonTPCNSigma, c.pionTPCNSigma, c.bachKaonTPCNSigma, c.bachPionTPCNSigma, - c.protonHasTOF, c.pionHasTOF, c.bachKaonHasTOF, c.bachPionHasTOF, - c.protonTOFNSigma, c.pionTOFNSigma, c.bachKaonTOFNSigma, c.bachPionTOFNSigma); - } + fillMultHistos(collisions); + std::map toiMap; + zorroAccounting(collisions, toiMap); + fillCandidatesVector(collisions, tracks, trackedCascades, gCandidates, toiMap); + fillDataTable(gCandidates); } PROCESS_SWITCH(NonPromptCascadeTask, processTrackedCascadesData, "process cascades from strangeness tracking: Data analysis", false); + + void processCascadesData(CollisionCandidatesRun3 const& collisions, aod::Cascades const& cascades, + aod::V0s const& /*v0s*/, TracksExtData const& tracks, + aod::BCsWithTimestamps const&) + { + std::map toiMap; + zorroAccounting(collisions, toiMap); + fillCandidatesVector(collisions, tracks, cascades, gCandidatesNT, toiMap); + fillDataTable(gCandidatesNT); + } + PROCESS_SWITCH(NonPromptCascadeTask, processCascadesData, "process cascades: Data analysis", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Strangeness/phik0shortanalysis.cxx b/PWGLF/Tasks/Strangeness/phik0shortanalysis.cxx index bb0c1ee04b4..b38931be584 100644 --- a/PWGLF/Tasks/Strangeness/phik0shortanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/phik0shortanalysis.cxx @@ -13,63 +13,107 @@ /// \brief Analysis task for the Phi and K0S rapidity correlations analysis /// \author Stefano Cannito (stefano.cannito@cern.ch) -#include -#include +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/mcCentrality.h" +#include "PWGLF/Utils/inelGt.h" + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include #include +#include +#include +#include +#include +#include #include -#include +#include #include #include -#include -#include -#include #include -#include +#include + +#include #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/ASoAHelpers.h" -#include "CommonConstants/PhysicsConstants.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/TrackSelection.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "PWGLF/Utils/inelGt.h" -#include "PWGLF/DataModel/mcCentrality.h" +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::aod::track; + +enum { + kGlobalplusITSonly = 0, + kGlobalonly, + kITSonly +}; + +enum { + kSpAll = 0, + kSpPion, + kSpKaon, + kSpProton, + kSpOther, + kSpStrangeDecay, + kSpNotPrimary +}; + +enum { + kNoGenpTVar = 0, + kGenpTup, + kGenpTdown +}; struct Phik0shortanalysis { // Histograms are defined with HistogramRegistry HistogramRegistry dataEventHist{"dataEventHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry mcEventHist{"mcEventHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry candPhiHist{"candPhiHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry candK0SHist{"candK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry dataPhiHist{"dataPhiHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry mcPhiHist{"mcPhiHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry closureMCPhiHist{"closureMCPhiHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry dataK0SHist{"dataK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry mcK0SHist{"mcK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry dataPhiK0SHist{"dataPhiK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry mcPhiK0SHist{"mcPhiK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry closureMCPhiK0SHist{"closureMCPhiK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry dataPionHist{"dataPionHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry mcPionHist{"mcPionHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry dataPhiPionHist{"dataPhiPionHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry mcPhiPionHist{"mcPhiPionHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry mcPhiHist{"mcPhiHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry mcK0SHist{"mcK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry mcPionHist{"mcPionHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry closureMCPhiHist{"closureMCPhiHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry closureMCPhiK0SHist{"closureMCPhiK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry closureMCPhiPionHist{"closureMCPhiPionHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry mePhiK0SHist{"mePhiK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry mePhiPionHist{"mePhiPionHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + struct : ConfigurableGroup { + Configurable isData{"isData", true, "Data"}; + Configurable isMC{"isMC", true, "MC"}; + Configurable isClosure{"isClosure", true, "MC Closure"}; + + Configurable isDataNewProc{"isDataNewProc", true, "New procedure for Data"}; + Configurable isMCNewProc{"isMCNewProc", true, "New procedure for MC"}; + Configurable isClosureNewProc{"isClosureNewProc", true, "New procedure for MC Closure"}; + Configurable isMENewProc{"isMENewProc", true, "New procedure for ME"}; + } analysisModeConfigs; // Configurable for event selection Configurable cutZVertex{"cutZVertex", 10.0f, "Accepted z-vertex range (cm)"}; @@ -77,68 +121,128 @@ struct Phik0shortanalysis { // Configurable on multiplicity bins Configurable> binsMult{"binsMult", {0.0, 1.0, 5.0, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, 70.0, 100.0}, "Multiplicity bin limits"}; + // Configurables for track selection (not necessarily common for trigger and the two associated particles) + struct : ConfigurableGroup { + Configurable cfgCutCharge{"cfgCutCharge", 0.0f, "Cut on charge"}; + Configurable cfgMinAbsCharge{"cfgMinAbsCharge", 3.0f, "Cut on absolute charge"}; + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; + Configurable cfgPVContributor{"cfgPVContributor", true, "PV contributor track selection"}; + Configurable cMinChargedParticlePtcut{"cMinChargedParticlePtcut", 0.1f, "Track minimum pt cut"}; + Configurable cMinKaonPtcut{"cMinKaonPtcut", 0.15f, "Track minimum pt cut"}; + Configurable etaMax{"etaMax", 0.8f, "eta max"}; + Configurable pTToUseTOF{"pTToUseTOF", 0.5f, "pT above which use TOF"}; + Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 2.0f, "Track DCAz cut to PV Maximum"}; + Configurable cMaxDCArToPV1Phi{"cMaxDCArToPV1Phi", 0.004f, "Track DCAr cut to PV config 1 for Phi"}; + Configurable cMaxDCArToPV2Phi{"cMaxDCArToPV2Phi", 0.013f, "Track DCAr cut to PV config 2 for Phi"}; + Configurable cMaxDCArToPV3Phi{"cMaxDCArToPV3Phi", 1.0f, "Track DCAr cut to PV config 3 for Phi"}; + Configurable cMaxDCArToPV1Pion{"cMaxDCArToPV1Pion", 0.004f, "Track DCAr cut to PV config 1 for Pions"}; + Configurable cMaxDCArToPV2Pion{"cMaxDCArToPV2Pion", 0.013f, "Track DCAr cut to PV config 2 for Pions"}; + Configurable cMaxDCArToPV3Pion{"cMaxDCArToPV3Pion", 1.0f, "Track DCAr cut to PV config 3 for Pions"}; + + Configurable cfgIsDCAzParameterized{"cfgIsDCAzParameterized", false, "IsDCAzParameterized"}; + Configurable cMaxDCAzToPV1Pion{"cMaxDCAzToPV1Pion", 0.004f, "Track DCAz cut to PV config 1 for Pion"}; + Configurable cMaxDCAzToPV2Pion{"cMaxDCAzToPV2Pion", 0.013f, "Track DCAz cut to PV config 2 for Pion"}; + Configurable cMaxDCAzToPV3Pion{"cMaxDCAzToPV3Pion", 1.0f, "Track DCAz cut to PV config 3 for Pion"}; + + Configurable isNoTOF{"isNoTOF", false, "isNoTOF"}; + Configurable nSigmaCutTPCKa{"nSigmaCutTPCKa", 3.0f, "Value of the TPC Nsigma cut for Kaons"}; + Configurable nSigmaCutCombinedKa{"nSigmaCutCombinedKa", 3.0f, "Value of the TOF Nsigma cut for Kaons"}; + + Configurable nSigmaCutTPCPion{"nSigmaCutTPCPion", 4.0f, "Value of the TPC Nsigma cut for Pions"}; + Configurable cMinPionPtcut{"cMinPionPtcut", 0.2f, "Track minimum pt cut"}; + Configurable minTPCnClsFound{"minTPCnClsFound", 70, "min number of found TPC clusters"}; + Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 70, "min number of TPC crossed rows"}; + Configurable maxChi2TPC{"maxChi2TPC", 4.0f, "max chi2 per cluster TPC"}; + Configurable minITSnCls{"minITSnCls", 4, "min number of ITS clusters"}; + Configurable maxChi2ITS{"maxChi2ITS", 36.0f, "max chi2 per cluster ITS"}; + + Configurable applyExtraPhiCuts{"applyExtraPhiCuts", false, "Enable extra phi cut"}; + Configurable> extraPhiCuts{"extraPhiCuts", {3.07666f, 3.12661f, 0.03f, 6.253f}, "Extra phi cuts"}; + } trackConfigs; + + // Configurables on phi pT bins + Configurable> binspTPhi{"binspTPhi", {0.4, 0.8, 1.4, 2.0, 2.8, 4.0, 6.0, 10.0}, "pT bin limits for Phi"}; + Configurable minPhiPt{"minPhiPt", 0.4f, "Minimum pT for Phi"}; + Configurable maxPhiPt{"maxPhiPt", 10.0f, "Maximum pT for Phi"}; + + // Configurables on phi mass + Configurable nBinsMPhi{"nBinsMPhi", 13, "N bins in cfgmassPhiaxis"}; + Configurable lowMPhi{"lowMPhi", 1.0095f, "Upper limits on Phi mass for signal extraction"}; + Configurable upMPhi{"upMPhi", 1.029f, "Upper limits on Phi mass for signal extraction"}; + // Configurables for V0 selection - Configurable minTPCnClsFound{"minTPCnClsFound", 70, "min number of found TPC clusters"}; - Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 80, "min number of TPC crossed rows"}; - Configurable maxChi2TPC{"maxChi2TPC", 4.0f, "max chi2 per cluster TPC"}; - Configurable etaMax{"etaMax", 0.8f, "eta max"}; - - Configurable v0SettingCosPA{"v0SettingCosPA", 0.98, "V0 CosPA"}; - Configurable v0SettingRadius{"v0SettingRadius", 0.5, "v0radius"}; - Configurable v0SettingDCAV0Dau{"v0SettingDCAV0Dau", 1, "DCA V0 Daughters"}; - Configurable v0SettingDCAPosToPV{"v0SettingDCAPosToPV", 0.06, "DCA Pos To PV"}; - Configurable v0SettingDCANegToPV{"v0SettingDCANegToPV", 0.06, "DCA Neg To PV"}; - Configurable nSigmaCutTPCPion{"nSigmaCutTPCPion", 4.0, "Value of the TPC Nsigma cut for Pions"}; + struct : ConfigurableGroup { + Configurable v0SettingCosPA{"v0SettingCosPA", 0.98f, "V0 CosPA"}; + Configurable v0SettingRadius{"v0SettingRadius", 0.5f, "v0radius"}; + Configurable v0SettingDCAV0Dau{"v0SettingDCAV0Dau", 1.0f, "DCA V0 Daughters"}; + Configurable v0SettingDCAPosToPV{"v0SettingDCAPosToPV", 0.1f, "DCA Pos To PV"}; + Configurable v0SettingDCANegToPV{"v0SettingDCANegToPV", 0.1f, "DCA Neg To PV"}; + Configurable v0SettingMinPt{"v0SettingMinPt", 0.1f, "V0 min pt"}; + + Configurable cfgisV0ForData{"cfgisV0ForData", true, "isV0ForData"}; + + Configurable cfgFurtherV0Selection{"cfgFurtherV0Selection", false, "Further V0 selection"}; + Configurable ctauK0s{"ctauK0s", 20.0f, "C tau K0s(cm)"}; + Configurable paramArmenterosCut{"paramArmenterosCut", 0.2f, "parameter Armenteros Cut"}; + Configurable v0rejK0s{"v0rejK0s", 0.005f, "V0 rej K0s"}; + } v0Configs; // Configurables on K0S mass - Configurable lowMK0S{"lowMK0S", 0.48, "Lower limit on K0Short mass"}; - Configurable upMK0S{"upMK0S", 0.52, "Upper limit on K0Short mass"}; + Configurable lowMK0S{"lowMK0S", 0.48f, "Lower limit on K0Short mass"}; + Configurable upMK0S{"upMK0S", 0.52f, "Upper limit on K0Short mass"}; // Configurable on K0S pT bins - Configurable> binspTK0S{"binspTK0S", {0.0, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0}, "pT bin limits for K0S"}; - - // Configurables on Phi mass - Configurable nBinsMPhi{"nBinsMPhi", 13, "N bins in cfgmassPhiaxis"}; - Configurable lowMPhi{"lowMPhi", 1.0095, "Upper limits on Phi mass for signal extraction"}; - Configurable upMPhi{"upMPhi", 1.029, "Upper limits on Phi mass for signal extraction"}; - - // Configurables for phi selection - Configurable cfgCutCharge{"cfgCutCharge", 0.0, "Cut on charge"}; - Configurable cfgPrimaryTrack{"cfgPrimaryTrack", false, "Primary track selection"}; - Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; - Configurable cfgPVContributor{"cfgPVContributor", true, "PV contributor track selection"}; - Configurable cMinKaonPtcut{"cMinKaonPtcut", 0.15f, "Track minimum pt cut"}; - Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 2.0f, "Track DCAz cut to PV Maximum"}; - Configurable cMaxDCArToPV1{"cMaxDCArToPV1", 0.004f, "Track DCAr cut to PV config 1"}; - Configurable cMaxDCArToPV2{"cMaxDCArToPV2", 0.013f, "Track DCAr cut to PV config 2"}; - Configurable cMaxDCArToPV3{"cMaxDCArToPV3", 1.0f, "Track DCAr cut to PV config 3"}; - - Configurable isNoTOF{"isNoTOF", false, "isNoTOF"}; - Configurable nSigmaCutTPCKa{"nSigmaCutTPCKa", 3.0, "Value of the TPC Nsigma cut for Kaons"}; - Configurable nSigmaCutCombinedKa{"nSigmaCutCombinedKa", 3.0, "Value of the TOF Nsigma cut for Kaons"}; - - // Configurables for pions selection(extra with respect to a few of those defined for V0) - Configurable minITSnCls{"minITSnCls", 4, "min number of ITS clusters"}; - Configurable maxChi2ITS{"maxChi2ITS", 36.0f, "max chi2 per cluster ITS"}; - Configurable dcaxyMax{"dcaxyMax", 0.1f, "Maximum DCAxy to primary vertex"}; - Configurable dcazMax{"dcazMax", 0.1f, "Maximum DCAz to primary vertex"}; + Configurable> binspTK0S{"binspTK0S", {0.1, 0.5, 0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for K0S"}; // Configurable on pion pT bins - Configurable> binspTPi{"binspTPi", {0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0, 3.0}, "pT bin limits for pions"}; + Configurable> binspTPi{"binspTPi", {0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0, 3.0}, "pT bin limits for pions"}; // Configurables for delta y selection - Configurable nBinsy{"nBinsy", 80, "Number of bins in y and deltay axis"}; - Configurable cfgYAcceptance{"cfgYAcceptance", 0.5f, "Rapidity acceptance"}; - Configurable cfgFCutOnDeltaY{"cfgFCutOnDeltaY", 0.5f, "First upper bound on Deltay selection"}; - Configurable cfgSCutOnDeltaY{"cfgSCutOnDeltaY", 0.1f, "Second upper bound on Deltay selection"}; - Configurable cfgYAcceptanceSmear{"cfgYAcceptanceSmear", 0.8f, "Rapidity acceptance for smearing matrix study"}; + struct : ConfigurableGroup { + Configurable nBinsY{"nBinsY", 20, "Number of bins in y axis"}; + Configurable nBinsDeltaY{"nBinsDeltaY", 20, "Number of bins in deltay axis"}; + Configurable cfgYAcceptance{"cfgYAcceptance", 0.5f, "Rapidity acceptance"}; + Configurable cfgFCutOnDeltaY{"cfgFCutOnDeltaY", 0.5f, "First upper bound on Deltay selection"}; + Configurable cfgSCutOnDeltaY{"cfgSCutOnDeltaY", 0.1f, "Second upper bound on Deltay selection"}; + Configurable> cfgDeltaYAcceptanceBins{"cfgDeltaYAcceptanceBins", {0.5f}, "Rapidity acceptance bins"}; + } deltaYConfigs; // Configurable for RecMC Configurable cfgiskNoITSROFrameBorder{"cfgiskNoITSROFrameBorder", false, "kNoITSROFrameBorder request on RecMC collisions"}; + // Configurables for MC closure + Configurable cfgisRecMCWPDGForClosure1{"cfgisRecMCWPDGForClosure1", false, "RecoMC with PDG Codes for Closure only for Associated particles"}; + Configurable cfgisRecMCWPDGForClosure2{"cfgisRecMCWPDGForClosure2", false, "RecoMC with PDG Codes for Closure"}; + Configurable cfgisGenMCForClosure{"cfgisGenMCForClosure", false, "GenMC for Closure"}; + + // Configurables to choose the filling method + Configurable fillMethodMultipleWeights{"fillMethodMultipleWeights", true, "Fill method Multiple Weights"}; + Configurable fillMethodSingleWeight{"fillMethodSingleWeight", false, "Fill method Single Weight"}; + Configurable applyEfficiency{"applyEfficiency", false, "Use efficiency for filling histograms"}; + + // Configurables for dN/deta with phi computation + Configurable furtherCheckonMcCollision{"furtherCheckonMcCollision", true, "Further check on MC collisions"}; + Configurable filterOnMcPhi{"filterOnMcPhi", true, "Filter on MC Phi"}; + + // Configurable for event mixing + Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 5, "Number of mixed events per event"}; + + // Configurable for CCDB + Configurable useCCDB{"useCCDB", false, "Use CCDB for corrections"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository to use"}; + Configurable ccdbPurityPath{"ccdbPurityPath", "Users/s/scannito/PhiPuritiesData", "Correction path to file"}; + Configurable ccdbEfficiencyPath{"ccdbEfficiencyPath", "Users/s/scannito/Efficiencies", "Correction path to file"}; + // Constants double massKa = o2::constants::physics::MassKPlus; double massPi = o2::constants::physics::MassPiPlus; + double massK0S = o2::constants::physics::MassK0Short; + double massLambda = o2::constants::physics::MassLambda0; + + // Defining track flags + static constexpr TrackSelectionFlags::flagtype TrackSelectionITS = TrackSelectionFlags::kITSNCls | TrackSelectionFlags::kITSChi2NDF | TrackSelectionFlags::kITSHits; + static constexpr TrackSelectionFlags::flagtype TrackSelectionTPC = TrackSelectionFlags::kTPCNCls | TrackSelectionFlags::kTPCCrossedRowsOverNCls | TrackSelectionFlags::kTPCChi2NDF; + static constexpr TrackSelectionFlags::flagtype TrackSelectionDCA = TrackSelectionFlags::kDCAz | TrackSelectionFlags::kDCAxy; // Defining filters for events (event selection) // Processed events will be already fulfilling the event selection requirements @@ -146,7 +250,14 @@ struct Phik0shortanalysis { Filter posZFilter = (nabs(o2::aod::collision::posZ) < cutZVertex); // Defining filters on V0s (cannot filter on dynamic columns) - Filter preFilterV0 = (nabs(aod::v0data::dcapostopv) > v0SettingDCAPosToPV && nabs(aod::v0data::dcanegtopv) > v0SettingDCANegToPV && aod::v0data::dcaV0daughters < v0SettingDCAV0Dau); + Filter preFilterV0 = (nabs(aod::v0data::dcapostopv) > v0Configs.v0SettingDCAPosToPV && nabs(aod::v0data::dcanegtopv) > v0Configs.v0SettingDCANegToPV && aod::v0data::dcaV0daughters < v0Configs.v0SettingDCAV0Dau); + + // Defining filters on tracks + Filter trackFilter = ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) && + ncheckbit(aod::track::trackCutFlag, TrackSelectionITS) && + ifnode(ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC), ncheckbit(aod::track::trackCutFlag, TrackSelectionTPC), true) && + ncheckbit(aod::track::trackCutFlag, TrackSelectionDCA) && + ncheckbit(aod::track::trackCutFlag, TrackSelectionFlags::kInAcceptanceTracks); // Defining the type of the collisions for data and MC using SelCollisions = soa::Join; @@ -159,56 +270,96 @@ struct Phik0shortanalysis { // Defining the type of the tracks for data and MC using FullTracks = soa::Join; + using FilteredTracks = soa::Filtered; using FullMCTracks = soa::Join; + using FilteredMCTracks = soa::Filtered; using V0DauTracks = soa::Join; using V0DauMCTracks = soa::Join; - // Defining the binning policy for mixed event - using BinningTypeVertexContributor = ColumnBinningPolicy; + // Defining binning policy and axis for mixed event + ConfigurableAxis axisVertexMixing{"axisVertexMixing", {20, -10, 10}, "Z vertex axis binning for mixing"}; + ConfigurableAxis axisCentralityMixing{"axisCentralityMixing", {20, 0, 100}, "Multiplicity percentil binning for mixing"}; + using BinningTypeVertexCent = ColumnBinningPolicy; + BinningTypeVertexCent binningOnVertexAndCent{{axisVertexMixing, axisCentralityMixing}, true}; + + // Cache for manual slicing SliceCache cache; - Partition posTracks = aod::track::signed1Pt > cfgCutCharge; - Partition negTracks = aod::track::signed1Pt < cfgCutCharge; + // Preslice for manual slicing + struct : PresliceGroup { + Preslice perColl = aod::track::collisionId; + Preslice perMCColl = aod::mcparticle::mcCollisionId; + } preslices; + + // Positive and negative tracks partitions + Partition posTracks = aod::track::signed1Pt > trackConfigs.cfgCutCharge; + Partition negTracks = aod::track::signed1Pt < trackConfigs.cfgCutCharge; - Partition posMCTracks = aod::track::signed1Pt > cfgCutCharge; - Partition negMCTracks = aod::track::signed1Pt < cfgCutCharge; + Partition posFiltTracks = aod::track::signed1Pt > trackConfigs.cfgCutCharge; + Partition negFiltTracks = aod::track::signed1Pt < trackConfigs.cfgCutCharge; + + Partition posMCTracks = aod::track::signed1Pt > trackConfigs.cfgCutCharge; + Partition negMCTracks = aod::track::signed1Pt < trackConfigs.cfgCutCharge; // Necessary to flag INEL>0 events in GenMC Service pdgDB; + // Necessary to get the CCDB for phi purities + Service ccdb; + + // Set of functions for phi purity + std::vector> phiPurityFunctions = std::vector>(binsMult->size(), std::vector(binspTPhi->size(), nullptr)); + + // Efficiecy maps + TH3F* effMapPhi; + TH3F* effMapK0S; + TH3F* effMapPionTPC; + TH3F* effMapPionTPCTOF; + void init(InitContext&) { // Axes - AxisSpec massK0SAxis = {200, 0.45f, 0.55f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; AxisSpec massPhiAxis = {200, 0.9f, 1.2f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; AxisSpec sigmassPhiAxis = {nBinsMPhi, lowMPhi, upMPhi, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; - AxisSpec vertexZAxis = {100, -15.f, 15.f, "vrtx_{Z} [cm]"}; - AxisSpec yAxis = {nBinsy, -cfgYAcceptanceSmear, cfgYAcceptanceSmear, "#it{y}"}; - AxisSpec deltayAxis = {nBinsy, 0.0f, 1.6f, "|#it{#Deltay}|"}; + AxisSpec massK0SAxis = {200, 0.45f, 0.55f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec nSigmaPiAxis = {100, -10.0f, 10.0f, "N#sigma #pi"}; + AxisSpec vertexZAxis = {100, -cutZVertex, cutZVertex, "vrtx_{Z} [cm]"}; + AxisSpec etaAxis = {16, -trackConfigs.etaMax, trackConfigs.etaMax, "#eta"}; + AxisSpec yAxis = {deltaYConfigs.nBinsY, -deltaYConfigs.cfgYAcceptance, deltaYConfigs.cfgYAcceptance, "#it{y}"}; + AxisSpec deltayAxis = {deltaYConfigs.nBinsDeltaY, -1.0f, 1.0f, "#Delta#it{y}"}; + AxisSpec phiAxis = {629, 0, o2::constants::math::TwoPI, "#phi"}; AxisSpec multAxis = {120, 0.0f, 120.0f, "centFT0M"}; AxisSpec binnedmultAxis{(std::vector)binsMult, "centFT0M"}; - AxisSpec ptK0SAxis = {60, 0.0f, 6.0f, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec binnedptK0SAxis{(std::vector)binspTK0S, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec ptPiAxis = {30, 0.0f, 3.0f, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec binnedptPiAxis{(std::vector)binspTPi, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec pTPhiAxis = {120, 0.0f, 12.0f, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec binnedpTPhiAxis{(std::vector)binspTPhi, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec pTK0SAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec binnedpTK0SAxis{(std::vector)binspTK0S, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec pTPiAxis = {50, 0.0f, 5.0f, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec binnedpTPiAxis{(std::vector)binspTPi, "#it{p}_{T} (GeV/#it{c})"}; // Histograms // Number of events per selection - dataEventHist.add("hEventSelection", "hEventSelection", kTH1F, {{5, -0.5f, 4.5f}}); + dataEventHist.add("hEventSelection", "hEventSelection", kTH1F, {{6, -0.5f, 5.5f}}); dataEventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); dataEventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); dataEventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(3, "posZ cut"); dataEventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(4, "INEL>0 cut"); dataEventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(5, "With at least a #phi cand"); + dataEventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(6, "With at least a #phi"); // Event information dataEventHist.add("hVertexZ", "hVertexZ", kTH1F, {vertexZAxis}); dataEventHist.add("hMultiplicityPercent", "Multiplicity Percentile", kTH1F, {multAxis}); + dataEventHist.add("hMultiplicityPercentWithPhi", "Multiplicity Percentile in Events with a Phi Candidate", kTH1F, {multAxis}); + dataEventHist.add("h2VertexZvsMult", "Vertex Z vs Multiplicity Percentile", kTH2F, {vertexZAxis, binnedmultAxis}); + + // Eta distribution for dN/deta values estimation in Data + dataEventHist.add("h5EtaDistribution", "Eta vs multiplicity in Data", kTHnSparseF, {vertexZAxis, binnedmultAxis, etaAxis, phiAxis, {3, -0.5f, 2.5f}}); // Number of MC events per selection for Rec and Gen - mcEventHist.add("hRecMCEventSelection", "hRecMCEventSelection", kTH1F, {{8, -0.5f, 7.5f}}); + mcEventHist.add("hRecMCEventSelection", "hRecMCEventSelection", kTH1F, {{9, -0.5f, 8.5f}}); mcEventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); mcEventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(2, "kIsTriggerTVX"); mcEventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(3, "kNoTimeFrameBorder"); @@ -216,7 +367,8 @@ struct Phik0shortanalysis { mcEventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(5, "posZ cut"); mcEventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(6, "INEL>0 cut"); mcEventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(7, "With at least a gen coll"); - mcEventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(8, "With at least a #phi"); + mcEventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(8, "With at least a #phi cand"); + mcEventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(9, "With at least a #phi"); mcEventHist.add("hGenMCEventSelection", "hGenMCEventSelection", kTH1F, {{5, -0.5f, 4.5f}}); mcEventHist.get(HIST("hGenMCEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); @@ -226,145 +378,334 @@ struct Phik0shortanalysis { mcEventHist.get(HIST("hGenMCEventSelection"))->GetXaxis()->SetBinLabel(5, "With at least a reco coll"); // MC Event information for Rec and Gen - mcEventHist.add("hRecMCVertexZ", "hRecMCVertexZ", kTH1F, {vertexZAxis}); - mcEventHist.add("hRecMCMultiplicityPercent", "RecMC Multiplicity Percentile", kTH1F, {multAxis}); - mcEventHist.add("hRecMCGenMultiplicityPercent", "RecMC Gen Multiplicity Percentile", kTH1F, {binnedmultAxis}); + mcEventHist.add("hRecoMCVertexZ", "hRecoMCVertexZ", kTH1F, {vertexZAxis}); + mcEventHist.add("hUnbinnedRecoMCMultiplicityPercent", "RecoMC Multiplicity Percentile", kTH1F, {multAxis}); + mcEventHist.add("hRecoMCMultiplicityPercent", "RecoMC Multiplicity Percentile", kTH1F, {binnedmultAxis}); + mcEventHist.add("hRecoMCMultiplicityPercentWithPhi", "RecoMC Multiplicity Percentile in Events with a Phi Candidate", kTH1F, {binnedmultAxis}); + mcEventHist.add("h2RecoMCVertexZvsMult", "RecoMC Vertex Z vs Multiplicity Percentile", kTH2F, {vertexZAxis, binnedmultAxis}); mcEventHist.add("hGenMCVertexZ", "hGenMCVertexZ", kTH1F, {vertexZAxis}); mcEventHist.add("hGenMCMultiplicityPercent", "GenMC Multiplicity Percentile", kTH1F, {binnedmultAxis}); + mcEventHist.add("hGenMCAssocRecoMultiplicityPercent", "GenMC AssocReco Multiplicity Percentile", kTH1F, {binnedmultAxis}); + mcEventHist.add("hGenMCRecoMultiplicityPercent", "GenMCReco Multiplicity Percentile", kTH1F, {binnedmultAxis}); + mcEventHist.add("h2GenMCRecoVertexZvsMult", "GenMCReco Vertex Z vs Multiplicity Percentile", kTH2F, {vertexZAxis, binnedmultAxis}); + + // Eta distribution for dN/deta values estimation in MC + mcEventHist.add("h6RecoMCEtaDistribution", "Eta vs multiplicity in MCReco", kTHnSparseF, {vertexZAxis, binnedmultAxis, etaAxis, phiAxis, {6, -0.5f, 5.5f}, {3, -0.5f, 2.5f}}); + mcEventHist.add("h6RecoCheckMCEtaDistribution", "Eta vs multiplicity in MCReco Check", kTHnSparseF, {vertexZAxis, binnedmultAxis, etaAxis, phiAxis, {6, -0.5f, 5.5f}, {3, -0.5f, 2.5f}}); + + mcEventHist.add("h2GenMCEtaDistribution", "Eta vs multiplicity in MCGen", kTH2F, {binnedmultAxis, etaAxis}); + mcEventHist.add("h2GenMCEtaDistributionAssocReco", "Eta vs multiplicity in MCGen Assoc Reco", kTH2F, {binnedmultAxis, etaAxis}); + mcEventHist.add("h6GenMCEtaDistributionReco", "Eta vs multiplicity in MCGen Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, etaAxis, phiAxis, {6, -0.5f, 5.5f}, {3, -0.5f, 2.5f}}); + mcEventHist.add("h6GenMCEtaDistributionRecoCheck", "Eta vs multiplicity in MCGen Reco Check", kTHnSparseF, {vertexZAxis, binnedmultAxis, etaAxis, phiAxis, {6, -0.5f, 5.5f}, {3, -0.5f, 2.5f}}); + + // Phi topological/PID cuts + dataPhiHist.add("h2DauTracksPhiDCAxyPreCutData", "Dcaxy distribution vs pt before DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + dataPhiHist.add("h2DauTracksPhiDCAzPreCutData", "Dcaz distribution vs pt before DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); + dataPhiHist.add("h2DauTracksPhiDCAxyPostCutData", "Dcaxy distribution vs pt after DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + dataPhiHist.add("h2DauTracksPhiDCAzPostCutData", "Dcaz distribution vs pt after DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); + + dataPhiHist.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); + dataPhiHist.add("hNsigmaKaonTPC", "NsigmaKaon TPC distribution", kTH2F, {{100, 0.0, 5.0, "#it{p} (GeV/#it{c})"}, {100, -10.0f, 10.0f}}); + dataPhiHist.add("hNsigmaKaonTOF", "NsigmaKaon TOF distribution", kTH2F, {{100, 0.0, 5.0, "#it{p} (GeV/#it{c})"}, {100, -10.0f, 10.0f}}); + + if (analysisModeConfigs.isData) { + // Phi invariant mass for computing purities and normalisation + dataPhiHist.add("h3PhipurData", "Invariant mass of Phi for Purity (no K0S/Pi) in Data", kTH3F, {binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + + dataPhiHist.add("h4PhipurK0SData", "Invariant mass of Phi for Purity (K0S) in Data", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + dataPhiHist.get(HIST("h4PhipurK0SData"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + dataPhiHist.get(HIST("h4PhipurK0SData"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + dataPhiHist.add("h4PhipurPiData", "Invariant mass of Phi for Purity (Pi) in Data", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + dataPhiHist.get(HIST("h4PhipurPiData"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + dataPhiHist.get(HIST("h4PhipurPiData"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + } + + // DCA plots for phi daughters in MCReco + mcPhiHist.add("h2DauTracksPhiDCAxyPreCutMCReco", "Dcaxy distribution vs pt before DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + mcPhiHist.add("h2DauTracksPhiDCAzPreCutMCReco", "Dcaz distribution vs pt before DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); + mcPhiHist.add("h2DauTracksPhiDCAxyPostCutMCReco", "Dcaxy distribution vs pt after DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + mcPhiHist.add("h2DauTracksPhiDCAzPostCutMCReco", "Dcaz distribution vs pt after DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); - // Phi tpological/PID cuts - candPhiHist.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); - candPhiHist.add("hDcaxy", "Dcaxy distribution", kTH1F, {{200, -1.0f, 1.0f}}); - candPhiHist.add("hDcaz", "Dcaz distribution", kTH1F, {{200, -1.0f, 1.0f}}); - candPhiHist.add("hNsigmaKaonTPC", "NsigmaKaon TPC distribution", kTH2F, {ptK0SAxis, {100, -10.0f, 10.0f}}); - candPhiHist.add("hNsigmaKaonTOF", "NsigmaKaon TOF distribution", kTH2F, {ptK0SAxis, {100, -10.0f, 10.0f}}); + if (analysisModeConfigs.isClosure) { + // MCPhi invariant mass for computing purities + closureMCPhiHist.add("h3PhipurMCClosure", "Invariant mass of Phi for Purity (no K0S/Pi)", kTH3F, {binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + + closureMCPhiHist.add("h4PhipurK0SMCClosure", "Invariant mass of Phi for Purity (K0S) in MCClosure", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + closureMCPhiHist.get(HIST("h4PhipurK0SMCClosure"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + closureMCPhiHist.get(HIST("h4PhipurK0SMCClosure"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + closureMCPhiHist.add("h4PhipurPiMCClosure", "Invariant mass of Phi for Purity (Pi) in MCClosure", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + closureMCPhiHist.get(HIST("h4PhipurPiMCClosure"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + closureMCPhiHist.get(HIST("h4PhipurPiMCClosure"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + } // K0S topological/PID cuts - candK0SHist.add("hDCAV0Daughters", "hDCAV0Daughters", kTH1F, {{55, 0.0f, 2.2f}}); - candK0SHist.add("hV0CosPA", "hV0CosPA", kTH1F, {{100, 0.95f, 1.f}}); - candK0SHist.add("hNSigmaPosPionFromK0S", "hNSigmaPosPionFromK0Short", kTH2F, {ptK0SAxis, {100, -5.f, 5.f}}); - candK0SHist.add("hNSigmaNegPionFromK0S", "hNSigmaNegPionFromK0Short", kTH2F, {ptK0SAxis, {100, -5.f, 5.f}}); - - // Phi invariant mass for computing purities and normalisation - dataPhiHist.add("h2PhipurInvMass", "Invariant mass of Phi for Purity (no K0S/Pi)", kTH2F, {binnedmultAxis, massPhiAxis}); - - dataPhiHist.add("h3PhipurK0SInvMassInc", "Invariant mass of Phi for Purity (K0S) Inclusive", kTH3F, {binnedmultAxis, binnedptK0SAxis, massPhiAxis}); - dataPhiHist.add("h3PhipurK0SInvMassFCut", "Invariant mass of Phi for Purity (K0S) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, massPhiAxis}); - dataPhiHist.add("h3PhipurK0SInvMassSCut", "Invariant mass of Phi for Purity (K0S) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, massPhiAxis}); - - dataPhiHist.add("h3PhipurPiInvMassInc", "Invariant mass of Phi for Purity (Pi) Inclusive", kTH3F, {binnedmultAxis, binnedptPiAxis, massPhiAxis}); - dataPhiHist.add("h3PhipurPiInvMassFCut", "Invariant mass of Phi for Purity (Pi) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptPiAxis, massPhiAxis}); - dataPhiHist.add("h3PhipurPiInvMassSCut", "Invariant mass of Phi for Purity (Pi) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptPiAxis, massPhiAxis}); - - // MCPhi invariant mass for computing purities - closureMCPhiHist.add("h2MCPhipurInvMass", "Invariant mass of Phi for Purity (no K0S/Pi)", kTH2F, {binnedmultAxis, massPhiAxis}); - - closureMCPhiHist.add("h3MCPhipurK0SInvMassInc", "Invariant mass of Phi for Purity (K0S) Inclusive", kTH3F, {binnedmultAxis, binnedptK0SAxis, massPhiAxis}); - closureMCPhiHist.add("h3MCPhipurK0SInvMassFCut", "Invariant mass of Phi for Purity (K0S) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, massPhiAxis}); - closureMCPhiHist.add("h3MCPhipurK0SInvMassSCut", "Invariant mass of Phi for Purity (K0S) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, massPhiAxis}); - - closureMCPhiHist.add("h3MCPhipurPiInvMassInc", "Invariant mass of Phi for Purity (Pi) Inclusive", kTH3F, {binnedmultAxis, binnedptPiAxis, massPhiAxis}); - closureMCPhiHist.add("h3MCPhipurPiInvMassFCut", "Invariant mass of Phi for Purity (Pi) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptPiAxis, massPhiAxis}); - closureMCPhiHist.add("h3MCPhipurPiInvMassSCut", "Invariant mass of Phi for Purity (Pi) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptPiAxis, massPhiAxis}); - - // 2D mass for Phi and K0S for Data - dataPhiK0SHist.add("h4PhiK0SSEInc", "2D Invariant mass of Phi and K0Short for Same Event Inclusive", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, massK0SAxis, sigmassPhiAxis}); - dataPhiK0SHist.add("h4PhiK0SSEFCut", "2D Invariant mass of Phi and K0Short for Same Event Deltay < FirstCut", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, massK0SAxis, sigmassPhiAxis}); - dataPhiK0SHist.add("h4PhiK0SSESCut", "2D Invariant mass of Phi and K0Short for Same Event Deltay < SecondCut", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, massK0SAxis, sigmassPhiAxis}); - - // RecMC K0S coupled to Phi - mcPhiK0SHist.add("h3RecMCPhiK0SSEInc", "2D Invariant mass of Phi and K0Short for RecMC Inclusive", kTH3F, {binnedmultAxis, binnedptK0SAxis, massK0SAxis}); - mcPhiK0SHist.add("h3RecMCPhiK0SSEFCut", "2D Invariant mass of Phi and K0Short for RecMC Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, massK0SAxis}); - mcPhiK0SHist.add("h3RecMCPhiK0SSESCut", "2D Invariant mass of Phi and K0Short for RecMC Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, massK0SAxis}); - - // GenMC K0S coupled to Phi - mcPhiK0SHist.add("h2PhiK0SGenMCInc", "K0Short coupled to Phi for GenMC Inclusive", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - mcPhiK0SHist.add("h2PhiK0SGenMCFCut", "K0Short coupled to Phi for GenMC Deltay < FirstCut", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - mcPhiK0SHist.add("h2PhiK0SGenMCSCut", "K0Short coupled to Phi for GenMC Deltay < SecondCut", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - - mcPhiK0SHist.add("h2PhiK0SGenMCIncAssocReco", "K0Short coupled to Phi for GenMC Inclusive Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - mcPhiK0SHist.add("h2PhiK0SGenMCFCutAssocReco", "K0Short coupled to Phi for GenMC Deltay < FirstCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - mcPhiK0SHist.add("h2PhiK0SGenMCSCutAssocReco", "K0Short coupled to Phi for GenMC Deltay < SecondCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - - // 2D mass for Phi and K0S for Closure Test - closureMCPhiK0SHist.add("h4ClosureMCPhiK0SSEInc", "2D Invariant mass of Phi and K0Short for Same Event Inclusive for Closure Test", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, massK0SAxis, sigmassPhiAxis}); - closureMCPhiK0SHist.add("h4ClosureMCPhiK0SSEFCut", "2D Invariant mass of Phi and K0Short for Same Event Deltay < FirstCut for Closure Test", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, massK0SAxis, sigmassPhiAxis}); - closureMCPhiK0SHist.add("h4ClosureMCPhiK0SSESCut", "2D Invariant mass of Phi and K0Short for Same Event Deltay < SecondCut for Closure Test", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, massK0SAxis, sigmassPhiAxis}); - - // Phi mass vs Pion NSigma dE/dx for Data - dataPhiPionHist.add("h5PhiPiSEInc", "Phi Invariant mass vs Pion nSigma TPC/TOF for Same Event Inclusive", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}, sigmassPhiAxis}); - dataPhiPionHist.add("h5PhiPiSEFCut", "Phi Invariant mass vs Pion nSigma TPC/TOF for Same Event Deltay < FirstCut", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}, sigmassPhiAxis}); - dataPhiPionHist.add("h5PhiPiSESCut", "Phi Invariant mass vs Pion nSigma TPC/TOF for Same Event Deltay < SecondCut", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}, sigmassPhiAxis}); - - // RecMC Pion coupled to Phi - mcPhiPionHist.add("h4RecMCPhiPiSEInc", "Phi Invariant mass vs Pion nSigma TPC/TOF for RecMC Inclusive", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); - mcPhiPionHist.add("h4RecMCPhiPiSEFCut", "Phi Invariant mass vs Pion nSigma TPC/TOF for RecMC Deltay < FirstCut", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); - mcPhiPionHist.add("h4RecMCPhiPiSESCut", "Phi Invariant mass vs Pion nSigma TPC/TOF for RecMC Deltay < SecondCut", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); - - // GenMC Pion coupled to Phi - mcPhiPionHist.add("h2PhiPiGenMCInc", "Pion coupled to Phi for GenMC Inclusive", kTH2F, {binnedmultAxis, binnedptPiAxis}); - mcPhiPionHist.add("h2PhiPiGenMCFCut", "Pion coupled to Phi for GenMC Deltay < FirstCut", kTH2F, {binnedmultAxis, binnedptPiAxis}); - mcPhiPionHist.add("h2PhiPiGenMCSCut", "Pion coupled to Phi for GenMC Deltay < SecondCut", kTH2F, {binnedmultAxis, binnedptPiAxis}); - - mcPhiPionHist.add("h2PhiPiGenMCIncAssocReco", "Pion coupled to Phi for GenMC Inclusive Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); - mcPhiPionHist.add("h2PhiPiGenMCFCutAssocReco", "Pion coupled to Phi for GenMC Deltay < FirstCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); - mcPhiPionHist.add("h2PhiPiGenMCSCutAssocReco", "Pion coupled to Phi for GenMC Deltay < SecondCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); - - // Phi mass vs Pion NSigma dE/dx for Closure Test - closureMCPhiPionHist.add("h5ClosureMCPhiPiSEInc", "Phi Invariant mass vs Pion nSigma TPC/TOF for Same Event Inclusive for Closure Test", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}, sigmassPhiAxis}); - closureMCPhiPionHist.add("h5ClosureMCPhiPiSEFCut", "Phi Invariant mass vs Pion nSigma TPC/TOF for Same Event Deltay < FirstCut for Closure Test", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}, sigmassPhiAxis}); - closureMCPhiPionHist.add("h5ClosureMCPhiPiSESCut", "Phi Invariant mass vs Pion nSigma TPC/TOF for Same Event Deltay < SecondCut for Closure Test", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}, sigmassPhiAxis}); - - // MCPhi invariant mass for computing efficiencies and MCnormalisation - mcPhiHist.add("h2PhieffInvMass", "Invariant mass of Phi for Efficiency (no K0S/Pi)", kTH2F, {binnedmultAxis, massPhiAxis}); - - mcPhiHist.add("h3PhieffK0SInvMassInc", "Invariant mass of Phi for Efficiency (K0S) Inclusive", kTH3F, {binnedmultAxis, binnedptK0SAxis, massPhiAxis}); - mcPhiHist.add("h3PhieffK0SInvMassFCut", "Invariant mass of Phi for Efficiency (K0S) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, massPhiAxis}); - mcPhiHist.add("h3PhieffK0SInvMassSCut", "Invariant mass of Phi for Efficiency (K0S) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, massPhiAxis}); - - mcPhiHist.add("h3PhieffPiInvMassInc", "Invariant mass of Phi for Efficiency (Pi) Inclusive", kTH3F, {binnedmultAxis, binnedptPiAxis, massPhiAxis}); - mcPhiHist.add("h3PhieffPiInvMassFCut", "Invariant mass of Phi for Efficiency (Pi) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptPiAxis, massPhiAxis}); - mcPhiHist.add("h3PhieffPiInvMassSCut", "Invariant mass of Phi for Efficiency (Pi) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptPiAxis, massPhiAxis}); - - // GenMC Phi and Phi coupled to K0S and Pion - mcPhiHist.add("h1PhiGenMC", "Phi for GenMC", kTH1F, {binnedmultAxis}); - mcPhiHist.add("h1PhiGenMCAssocReco", "Phi for GenMC Associated Reco Collision", kTH1F, {binnedmultAxis}); - - mcPhiHist.add("h2PhieffK0SGenMCInc", "Phi coupled to K0Short for GenMC Inclusive", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - mcPhiHist.add("h2PhieffK0SGenMCFCut", "Phi coupled to K0Short for GenMC Deltay < FirstCut", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - mcPhiHist.add("h2PhieffK0SGenMCSCut", "Phi coupled to K0Short for GenMC Deltay < SecondCut", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - - mcPhiHist.add("h2PhieffK0SGenMCIncAssocReco", "Phi coupled to K0Short for GenMC Inclusive Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - mcPhiHist.add("h2PhieffK0SGenMCFCutAssocReco", "Phi coupled to K0Short for GenMC Deltay < FirstCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - mcPhiHist.add("h2PhieffK0SGenMCSCutAssocReco", "Phi coupled to K0Short for GenMC Deltay < SecondCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - - mcPhiHist.add("h2PhieffPiGenMCInc", "Phi coupled to Pion for GenMC Inclusive", kTH2F, {binnedmultAxis, binnedptPiAxis}); - mcPhiHist.add("h2PhieffPiGenMCFCut", "Phi coupled to Pion for GenMC Deltay < FirstCut", kTH2F, {binnedmultAxis, binnedptPiAxis}); - mcPhiHist.add("h2PhieffPiGenMCSCut", "Phi coupled to Pion for GenMC Deltay < SecondCut", kTH2F, {binnedmultAxis, binnedptPiAxis}); - - mcPhiHist.add("h2PhieffPiGenMCIncAssocReco", "Phi coupled to Pion for GenMC Inclusive Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); - mcPhiHist.add("h2PhieffPiGenMCFCutAssocReco", "Phi coupled to Pion for GenMC Deltay < FirstCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); - mcPhiHist.add("h2PhieffPiGenMCSCutAssocReco", "Phi coupled to Pion for GenMC Deltay < SecondCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); - - // Rapidity smearing matrix for Phi - mcPhiHist.add("h3PhiRapiditySmearing", "Rapidity Smearing Matrix for Phi", kTH3F, {binnedmultAxis, yAxis, yAxis}); - - // MCK0S invariant mass and GenMC K0S for computing efficiencies - mcK0SHist.add("h3K0SeffInvMass", "Invariant mass of K0Short for Efficiency", kTH3F, {binnedmultAxis, binnedptK0SAxis, massK0SAxis}); - mcK0SHist.add("h2K0SGenMC", "K0Short for GenMC", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - mcK0SHist.add("h2K0SGenMCAssocReco", "K0Short for GenMC Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); - - // Rapidity smearing matrix for K0S - mcK0SHist.add("h4K0SRapiditySmearing", "Rapidity Smearing Matrix for K0Short", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, yAxis, yAxis}); - - // MCPion invariant mass and GenMC Pion for computing efficiencies - mcPionHist.add("h4PieffInvMass", "Invariant mass of Pion for Efficiency", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); - mcPionHist.add("h2PiGenMC", "Pion for GenMC", kTH2F, {binnedmultAxis, binnedptPiAxis}); - mcPionHist.add("h2PiGenMCAssocReco", "Pion for GenMC Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); - - // Rapidity smearing matrix for Pion - mcPionHist.add("h4PiRapiditySmearing", "Rapidity Smearing Matrix for Pion", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, yAxis, yAxis}); + dataK0SHist.add("hDCAV0Daughters", "hDCAV0Daughters", kTH1F, {{55, 0.0f, 2.2f}}); + dataK0SHist.add("hV0CosPA", "hV0CosPA", kTH1F, {{100, 0.95f, 1.f}}); + dataK0SHist.add("hNSigmaPosPionFromK0S", "hNSigmaPosPionFromK0Short", kTH2F, {{100, 0.0, 5.0, "#it{p} (GeV/#it{c})"}, {100, -10.0f, 10.0f}}); + dataK0SHist.add("hNSigmaNegPionFromK0S", "hNSigmaNegPionFromK0Short", kTH2F, {{100, 0.0, 5.0, "#it{p} (GeV/#it{c})"}, {100, -10.0f, 10.0f}}); + + if (analysisModeConfigs.isData) { + // 2D mass of Phi and K0S for Data + dataPhiK0SHist.add("h5PhiK0SData", "2D Invariant mass of Phi and K0Short for Data", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTK0SAxis, massK0SAxis, sigmassPhiAxis}); + dataPhiK0SHist.get(HIST("h5PhiK0SData"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + dataPhiK0SHist.get(HIST("h5PhiK0SData"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + // 1D mass of K0S for Data + dataPhiK0SHist.add("h3PhiK0SSEIncNew", "Invariant mass of K0Short for Same Event Inclusive", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massK0SAxis}); + dataPhiK0SHist.add("h3PhiK0SSEFCutNew", "Invariant mass of K0Short for Same Event Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massK0SAxis}); + dataPhiK0SHist.add("h3PhiK0SSESCutNew", "Invariant mass of K0Short for Same Event Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massK0SAxis}); + } + + // K0S rapidity in Data + dataK0SHist.add("h3K0SRapidityData", "K0Short rapidity for Data", kTH3F, {binnedmultAxis, binnedpTK0SAxis, yAxis}); + + if (analysisModeConfigs.isMC) { + // RecMC K0S coupled to Phi + mcPhiK0SHist.add("h4PhiK0SMCReco", "K0S coupled to Phi in MCReco", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTK0SAxis, massK0SAxis}); + mcPhiK0SHist.get(HIST("h4PhiK0SMCReco"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + mcPhiK0SHist.get(HIST("h4PhiK0SMCReco"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + // GenMC K0S coupled to Phi + mcPhiK0SHist.add("h3PhiK0SMCGen", "K0S coupled toPhi in MCGen", kTH3F, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTK0SAxis}); + mcPhiK0SHist.get(HIST("h3PhiK0SMCGen"))->GetXaxis()->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + mcPhiK0SHist.get(HIST("h3PhiK0SMCGen"))->GetXaxis()->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + mcPhiK0SHist.add("h3PhiK0SMCGenAssocReco", "K0S coupled toPhi in MCGen Associated MCReco Collision", kTH3F, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTK0SAxis}); + mcPhiK0SHist.get(HIST("h3PhiK0SMCGenAssocReco"))->GetXaxis()->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + mcPhiK0SHist.get(HIST("h3PhiK0SMCGenAssocReco"))->GetXaxis()->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + } + + if (analysisModeConfigs.isClosure) { + // 2D mass of Phi and K0S for Closure Test + closureMCPhiK0SHist.add("h5PhiK0SMCClosure", "2D Invariant mass of Phi and K0Short for MC Closure Test", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTK0SAxis, massK0SAxis, sigmassPhiAxis}); + closureMCPhiK0SHist.get(HIST("h5PhiK0SMCClosure"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + closureMCPhiK0SHist.get(HIST("h5PhiK0SMCClosure"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + // 1D mass of K0S for Closure Test + closureMCPhiK0SHist.add("h3ClosureMCPhiK0SSEIncNew", "Invariant mass of K0Short for Inclusive for Closure Test", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massK0SAxis}); + closureMCPhiK0SHist.add("h3ClosureMCPhiK0SSEFCutNew", "Invariant mass of K0Short for Deltay < FirstCut for Closure Test", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massK0SAxis}); + closureMCPhiK0SHist.add("h3ClosureMCPhiK0SSESCutNew", "Invariant mass of K0Short for Deltay < SecondCut for Closure Test", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massK0SAxis}); + } + + if (analysisModeConfigs.isData) { + // Phi mass vs Pion NSigma dE/dx for Data + dataPhiPionHist.add("h6PhiPiData", "Phi Invariant mass vs Pion nSigma TPC/TOF for Data", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}, sigmassPhiAxis}); + dataPhiPionHist.get(HIST("h6PhiPiData"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + dataPhiPionHist.get(HIST("h6PhiPiData"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + // Pion NSigma dE/dx for Data + dataPhiPionHist.add("h4PhiPiSEIncNew", "Pion nSigma TPC/TOF for Same Event Inclusive", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); + dataPhiPionHist.add("h4PhiPiSEFCutNew", "Pion nSigma TPC/TOF for Same Event Deltay < FirstCut", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); + dataPhiPionHist.add("h4PhiPiSESCutNew", "Pion nSigma TPC/TOF for Same Event Deltay < SecondCut", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); + } + + // Pion rapidity in Data + dataPionHist.add("h3PiRapidityData", "Pion rapidity for Data", kTH3F, {binnedmultAxis, binnedpTPiAxis, yAxis}); + + // DCA plots for pions in Data + dataPionHist.add("h2TracksPiDCAxyPreCutData", "Dcaxy distribution vs pt before DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + dataPionHist.add("h2TracksPiDCAzPreCutData", "Dcaz distribution vs pt before DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); + dataPionHist.add("h2TracksPiDCAxyPostCutData", "Dcaxy distribution vs pt after DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + dataPionHist.add("h2TracksPiDCAzPostCutData", "Dcaz distribution vs pt after DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); + + // DCA plots for pions in MCReco + mcPionHist.add("h2TracksPiDCAxyPreCutMCReco", "Dcaxy distribution vs pt before DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + mcPionHist.add("h2TracksPiDCAzPreCutMCReco", "Dcaz distribution vs pt before DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); + mcPionHist.add("h2TracksPiDCAxyPostCutMCReco", "Dcaxy distribution vs pt after DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + mcPionHist.add("h2TracksPiDCAzPostCutMCReco", "Dcaz distribution vs pt after DCAxy cut", kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); + + // DCA plots for pions in MCReco distinguishing Primaries, Secondaries from Weak Decay and Secondaries from Material + mcPionHist.add("h3RecMCDCAxyPrimPi", "Dcaxy distribution vs pt for Primary Pions", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + mcPionHist.add("h3RecMCDCAxySecWeakDecayPi", "Dcaz distribution vs pt for Secondary Pions from Weak Decay", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + mcPionHist.add("h3RecMCDCAxySecMaterialPi", "Dcaxy distribution vs pt for Secondary Pions from Material", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + + if (analysisModeConfigs.isMC) { + // RecMC Pion coupled to Phi with TPC + mcPhiPionHist.add("h4PhiPiTPCMCReco", "Pion coupled to Phi in MCReco (TPC)", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}}); + mcPhiPionHist.get(HIST("h4PhiPiTPCMCReco"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + mcPhiPionHist.get(HIST("h4PhiPiTPCMCReco"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + // RecMC Pion coupled to Phi with TPC and TOF + mcPhiPionHist.add("h5PhiPiTPCTOFMCReco", "Pion coupled to Phi in MCReco (TPC and TOF)", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); + mcPhiPionHist.get(HIST("h5PhiPiTPCTOFMCReco"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + mcPhiPionHist.get(HIST("h5PhiPiTPCTOFMCReco"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + mcPhiPionHist.add("h3PhiPiMCGen", "Pion coupled to Phi in MCGen", kTH3F, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPiAxis}); + mcPhiPionHist.get(HIST("h3PhiPiMCGen"))->GetXaxis()->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + mcPhiPionHist.get(HIST("h3PhiPiMCGen"))->GetXaxis()->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + mcPhiPionHist.add("h3PhiPiMCGenAssocReco", "Pion coupled to Phi in MCGen Associated Reco Collision", kTH3F, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPiAxis}); + mcPhiPionHist.get(HIST("h3PhiPiMCGenAssocReco"))->GetXaxis()->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + mcPhiPionHist.get(HIST("h3PhiPiMCGenAssocReco"))->GetXaxis()->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + } + + if (analysisModeConfigs.isClosure) { + // Phi mass vs Pion NSigma dE/dx for Closure Test + closureMCPhiPionHist.add("h6PhiPiMCClosure", "Phi Invariant mass vs Pion nSigma TPC/TOF for MC Closure Test", kTHnSparseF, {{static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1), -0.5f, static_cast(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1.0f - 0.5f)}, binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}, sigmassPhiAxis}); + closureMCPhiPionHist.get(HIST("h6PhiPiMCClosure"))->GetAxis(0)->SetBinLabel(1, "Inclusive"); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + closureMCPhiPionHist.get(HIST("h6PhiPiMCClosure"))->GetAxis(0)->SetBinLabel(i + 2, Form("|Delta#it{y}| < %.1f", deltaYConfigs.cfgDeltaYAcceptanceBins->at(i))); + } + + // Phi mass vs Pion NSigma dE/dx for Closure Test + closureMCPhiPionHist.add("h4ClosureMCPhiPiSEIncNew", "Pion nSigma TPC/TOF for Inclusive for Closure Test", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); + closureMCPhiPionHist.add("h4ClosureMCPhiPiSEFCutNew", "Pion nSigma TPC/TOF for Deltay < FirstCut for Closure Test", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); + closureMCPhiPionHist.add("h4ClosureMCPhiPiSESCutNew", "Pion nSigma TPC/TOF for Deltay < SecondCut for Closure Test", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); + } + + if (analysisModeConfigs.isMC) { + // MCPhi invariant mass for computing efficiencies and MCnormalisation + mcPhiHist.add("h2PhieffInvMass", "Invariant mass of Phi for Efficiency (no K0S/Pi)", kTH2F, {binnedmultAxis, massPhiAxis}); + + mcPhiHist.add("h3PhieffK0SInvMassInc", "Invariant mass of Phi for Efficiency (K0S) Inclusive", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massPhiAxis}); + mcPhiHist.add("h3PhieffK0SInvMassFCut", "Invariant mass of Phi for Efficiency (K0S) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massPhiAxis}); + mcPhiHist.add("h3PhieffK0SInvMassSCut", "Invariant mass of Phi for Efficiency (K0S) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massPhiAxis}); + + mcPhiHist.add("h3PhieffPiInvMassInc", "Invariant mass of Phi for Efficiency (Pi) Inclusive", kTH3F, {binnedmultAxis, binnedpTPiAxis, massPhiAxis}); + mcPhiHist.add("h3PhieffPiInvMassFCut", "Invariant mass of Phi for Efficiency (Pi) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedpTPiAxis, massPhiAxis}); + mcPhiHist.add("h3PhieffPiInvMassSCut", "Invariant mass of Phi for Efficiency (Pi) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedpTPiAxis, massPhiAxis}); + + // GenMC Phi and Phi coupled to K0S and Pion + mcPhiHist.add("h1PhiGenMC", "Phi for GenMC", kTH1F, {binnedmultAxis}); + mcPhiHist.add("h1PhiGenMCAssocReco", "Phi for GenMC Associated Reco Collision", kTH1F, {binnedmultAxis}); + + mcPhiHist.add("h2PhieffK0SGenMCInc", "Phi coupled to K0Short for GenMC Inclusive", kTH2F, {binnedmultAxis, binnedpTK0SAxis}); + mcPhiHist.add("h2PhieffK0SGenMCFCut", "Phi coupled to K0Short for GenMC Deltay < FirstCut", kTH2F, {binnedmultAxis, binnedpTK0SAxis}); + mcPhiHist.add("h2PhieffK0SGenMCSCut", "Phi coupled to K0Short for GenMC Deltay < SecondCut", kTH2F, {binnedmultAxis, binnedpTK0SAxis}); + + mcPhiHist.add("h2PhieffK0SGenMCIncAssocReco", "Phi coupled to K0Short for GenMC Inclusive Associated Reco Collision", kTH2F, {binnedmultAxis, binnedpTK0SAxis}); + mcPhiHist.add("h2PhieffK0SGenMCFCutAssocReco", "Phi coupled to K0Short for GenMC Deltay < FirstCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedpTK0SAxis}); + mcPhiHist.add("h2PhieffK0SGenMCSCutAssocReco", "Phi coupled to K0Short for GenMC Deltay < SecondCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedpTK0SAxis}); + + mcPhiHist.add("h2PhieffPiGenMCInc", "Phi coupled to Pion for GenMC Inclusive", kTH2F, {binnedmultAxis, binnedpTPiAxis}); + mcPhiHist.add("h2PhieffPiGenMCFCut", "Phi coupled to Pion for GenMC Deltay < FirstCut", kTH2F, {binnedmultAxis, binnedpTPiAxis}); + mcPhiHist.add("h2PhieffPiGenMCSCut", "Phi coupled to Pion for GenMC Deltay < SecondCut", kTH2F, {binnedmultAxis, binnedpTPiAxis}); + + mcPhiHist.add("h2PhieffPiGenMCIncAssocReco", "Phi coupled to Pion for GenMC Inclusive Associated Reco Collision", kTH2F, {binnedmultAxis, binnedpTPiAxis}); + mcPhiHist.add("h2PhieffPiGenMCFCutAssocReco", "Phi coupled to Pion for GenMC Deltay < FirstCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedpTPiAxis}); + mcPhiHist.add("h2PhieffPiGenMCSCutAssocReco", "Phi coupled to Pion for GenMC Deltay < SecondCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedpTPiAxis}); + + // Rapidity smearing matrix for Phi + mcPhiHist.add("h3PhiRapiditySmearing", "Rapidity Smearing Matrix for Phi", kTH3F, {binnedmultAxis, yAxis, yAxis}); + + // MCK0S invariant mass and GenMC K0S for computing efficiencies + mcK0SHist.add("h3K0SMCReco", "K0S for MCReco", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massK0SAxis}); + + mcK0SHist.add("h2K0SMCGen", "K0S for MCGen", kTH2F, {binnedmultAxis, binnedpTK0SAxis}); + mcK0SHist.add("h2K0SMCGenAssocReco", "K0S for MCGen Associated Reco Collision", kTH2F, {binnedmultAxis, binnedpTK0SAxis}); + + // Rapidity smearing matrix for K0S and rapidity in GenMC + mcK0SHist.add("h4K0SRapiditySmearing", "Rapidity Smearing Matrix for K0Short", kTHnSparseF, {binnedmultAxis, binnedpTK0SAxis, yAxis, yAxis}); + + mcK0SHist.add("h3K0SRapidityGenMC", "Rapidity for K0Short for GenMC", kTH3F, {binnedmultAxis, binnedpTK0SAxis, yAxis}); + + // MCPion invariant mass and GenMC Pion for computing efficiencies + mcPionHist.add("h3PiTPCMCReco", "Pion for MCReco (TPC)", kTH3F, {binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}}); + mcPionHist.add("h4PiTPCTOFMCReco", "Pion for MCReco (TPC and TOF)", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); + + mcPionHist.add("h2PiMCGen", "Pion for GenMC", kTH2F, {binnedmultAxis, binnedpTPiAxis}); + mcPionHist.add("h2PiMCGenAssocReco", "Pion for GenMC Associated Reco Collision", kTH2F, {binnedmultAxis, binnedpTPiAxis}); + + // Rapidity smearing matrix for Pion and rapidity in GenMC + mcPionHist.add("h4PiRapiditySmearing", "Rapidity Smearing Matrix for Pion", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, yAxis, yAxis}); + + mcPionHist.add("h3PiRapidityGenMC", "Rapidity for Pion for GenMC", kTH3F, {binnedmultAxis, binnedpTPiAxis, yAxis}); + } + + if (analysisModeConfigs.isDataNewProc) { + // Histograms for new analysis procedure (to be finalized and renamed deleting other histograms) + dataPhiHist.add("h3PhiDataNewProc", "Invariant mass of Phi in Data", kTH3F, {binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + dataPhiK0SHist.add("h5PhiK0SDataNewProc", "2D Invariant mass of Phi and K0Short in Data", kTHnSparseF, {deltayAxis, binnedmultAxis, binnedpTK0SAxis, massK0SAxis, massPhiAxis}); + dataPhiPionHist.add("h5PhiPiTPCDataNewProc", "Phi Invariant mass vs Pion nSigma TPC in Data", kTHnSparseF, {deltayAxis, binnedmultAxis, binnedpTPiAxis, nSigmaPiAxis, massPhiAxis}); + dataPhiPionHist.add("h5PhiPiTOFDataNewProc", "Phi Invariant mass vs Pion nSigma TOF in Data", kTHnSparseF, {deltayAxis, binnedmultAxis, binnedpTPiAxis, nSigmaPiAxis, massPhiAxis}); + } + + if (analysisModeConfigs.isClosureNewProc) { + closureMCPhiHist.add("h3PhiMCClosureNewProc", "Invariant mass of Phi in MC Closure test", kTH3F, {binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + closureMCPhiK0SHist.add("h5PhiK0SMCClosureNewProc", "2D Invariant mass of Phi and K0Short in MC Closure Test", kTHnSparseF, {deltayAxis, binnedmultAxis, binnedpTK0SAxis, massK0SAxis, massPhiAxis}); + closureMCPhiPionHist.add("h5PhiPiTPCMCClosureNewProc", "Phi Invariant mass vs Pion nSigma TPC in MC Closure Test", kTHnSparseF, {deltayAxis, binnedmultAxis, binnedpTPiAxis, nSigmaPiAxis, massPhiAxis}); + closureMCPhiPionHist.add("h5PhiPiTOFMCClosureNewProc", "Phi Invariant mass vs Pion nSigma TOF in MC Closure Test", kTHnSparseF, {deltayAxis, binnedmultAxis, binnedpTPiAxis, nSigmaPiAxis, massPhiAxis}); + } + + if (analysisModeConfigs.isMENewProc) { + mePhiK0SHist.add("h5PhiK0SMENewProc", "2D Invariant mass of Phi and K0Short in Mixed Event", kTHnSparseF, {deltayAxis, binnedmultAxis, binnedpTK0SAxis, massK0SAxis, massPhiAxis}); + mePhiPionHist.add("h5PhiPiTPCMENewProc", "Phi Invariant mass vs Pion nSigma TPC in Mixed Event", kTHnSparseF, {deltayAxis, binnedmultAxis, binnedpTPiAxis, nSigmaPiAxis, massPhiAxis}); + mePhiPionHist.add("h5PhiPiTOFMENewProc", "Phi Invariant mass vs Pion nSigma TOF in Mixed Event", kTHnSparseF, {deltayAxis, binnedmultAxis, binnedpTPiAxis, nSigmaPiAxis, massPhiAxis}); + } + + if (analysisModeConfigs.isMCNewProc) { + mcPhiHist.add("h3PhiMCRecoNewProc", "Phi in MCReco", kTH3F, {binnedmultAxis, pTPhiAxis, yAxis}); + mcK0SHist.add("h3K0SMCRecoNewProc", "K0S in MCReco", kTH3F, {binnedmultAxis, pTK0SAxis, yAxis}); + mcPionHist.add("h3PiMCRecoNewProc", "Pion in MCReco", kTH3F, {binnedmultAxis, pTPiAxis, yAxis}); + mcPionHist.add("h3PiMCReco2NewProc", "Pion in MCReco", kTH3F, {binnedmultAxis, pTPiAxis, yAxis}); + + mcPhiHist.add("h3PhiMCGenNewProc", "Phi in MCGen", kTH3F, {binnedmultAxis, pTPhiAxis, yAxis}); + mcK0SHist.add("h3K0SMCGenNewProc", "K0S in MCGen", kTH3F, {binnedmultAxis, pTK0SAxis, yAxis}); + mcPionHist.add("h3PiMCGenNewProc", "Pion in MCGen", kTH3F, {binnedmultAxis, pTPiAxis, yAxis}); + + mcPhiHist.add("h3PhiMCGenAssocRecoNewProc", "Phi in MCGen Associated MCReco", kTH3F, {binnedmultAxis, pTPhiAxis, yAxis}); + mcK0SHist.add("h3K0SMCGenAssocRecoNewProc", "K0S in MCGen Associated MCReco", kTH3F, {binnedmultAxis, pTK0SAxis, yAxis}); + mcPionHist.add("h3PiMCGenAssocRecoNewProc", "Pion in MCGen Associated MCReco", kTH3F, {binnedmultAxis, pTPiAxis, yAxis}); + + mcPhiHist.add("h3PhiMCGenRecoNewProc", "Phi in MCGen MCReco", kTH3F, {binnedmultAxis, pTPhiAxis, yAxis}); + mcK0SHist.add("h3K0SMCGenRecoNewProc", "K0S in MCGen MCReco", kTH3F, {binnedmultAxis, pTK0SAxis, yAxis}); + mcPionHist.add("h3PiMCGenRecoNewProc", "Pion in MCGen MCReco", kTH3F, {binnedmultAxis, pTPiAxis, yAxis}); + + mcPhiHist.add("h3PhiMCGenRecoCheckNewProc", "Phi in MCGen MCReco Check", kTH3F, {binnedmultAxis, pTPhiAxis, yAxis}); + mcK0SHist.add("h3K0SMCGenRecoCheckNewProc", "K0S in MCGen MCReco Check", kTH3F, {binnedmultAxis, pTK0SAxis, yAxis}); + mcPionHist.add("h3PiMCGenRecoCheckNewProc", "Pion in MCGen MCReco Check", kTH3F, {binnedmultAxis, pTPiAxis, yAxis}); + } + + // Initialize CCDB only if purity or efficiencies are requested in the task + if (useCCDB) { + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + if (fillMethodSingleWeight) + getPhiPurityFunctionsFromCCDB(); + + if (applyEfficiency) { + getEfficiencyMapsFromCCDB(); + } else { + effMapPhi = nullptr; + effMapK0S = nullptr; + effMapPionTPC = nullptr; + effMapPionTPCTOF = nullptr; + } + } } // Event selection and QA filling @@ -408,7 +749,7 @@ struct Phik0shortanalysis { return false; if (QA) { mcEventHist.fill(HIST("hRecMCEventSelection"), 4); // vertex-Z selected - mcEventHist.fill(HIST("hRecMCVertexZ"), collision.posZ()); + mcEventHist.fill(HIST("hRecoMCVertexZ"), collision.posZ()); } if (!collision.isInelGt0()) return false; @@ -424,11 +765,14 @@ struct Phik0shortanalysis { { if (!track.hasTPC()) return false; - if (track.tpcNClsFound() < minTPCnClsFound) + if (track.tpcNClsFound() < trackConfigs.minTPCnClsFound) return false; - if (track.tpcNClsCrossedRows() < minNCrossedRowsTPC) + if (track.tpcNClsCrossedRows() < trackConfigs.minNCrossedRowsTPC) return false; - if (track.tpcChi2NCl() > maxChi2TPC) + if (track.tpcChi2NCl() > trackConfigs.maxChi2TPC) + return false; + + if (std::abs(track.eta()) > trackConfigs.etaMax) return false; return true; } @@ -440,215 +784,458 @@ struct Phik0shortanalysis { if (!selectionTrackStrangeness(daughter1) || !selectionTrackStrangeness(daughter2)) return false; - if (v0.v0cosPA() < v0SettingCosPA) + if (v0.v0cosPA() < v0Configs.v0SettingCosPA) return false; - if (v0.v0radius() < v0SettingRadius) + if (v0.v0radius() < v0Configs.v0SettingRadius) return false; + if (v0.pt() < v0Configs.v0SettingMinPt) + return false; + + if (v0Configs.cfgisV0ForData) { + if (std::abs(daughter1.tpcNSigmaPi()) > trackConfigs.nSigmaCutTPCPion) + return false; + if (std::abs(daughter2.tpcNSigmaPi()) > trackConfigs.nSigmaCutTPCPion) + return false; + } + return true; + } - if (std::abs(daughter1.tpcNSigmaPi()) > nSigmaCutTPCPion) + // Further V0 selection + template + bool furtherSelectionV0(const T1& v0, const T2& collision) + { + if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massK0S > v0Configs.ctauK0s) + return false; + if (v0.qtarm() < (v0Configs.paramArmenterosCut * std::abs(v0.alpha()))) return false; - if (std::abs(daughter2.tpcNSigmaPi()) > nSigmaCutTPCPion) + if (std::abs(v0.mLambda() - massLambda) < v0Configs.v0rejK0s) return false; return true; } // Topological track selection - template - bool selectionTrackResonance(const T& track) + template + bool selectionTrackResonance(const T& track, bool doQA) { - if (cfgPrimaryTrack && !track.isPrimaryTrack()) + if (trackConfigs.cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) return false; - if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) - return false; - if (cfgPVContributor && !track.isPVContributor()) + if (trackConfigs.cfgPVContributor && !track.isPVContributor()) return false; - if (track.pt() < cMinKaonPtcut) + if (track.tpcNClsFound() < trackConfigs.minTPCnClsFound) return false; - if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) + + if (track.pt() < trackConfigs.cMinKaonPtcut) return false; - if (std::abs(track.dcaXY()) > cMaxDCArToPV1 + (cMaxDCArToPV2 / std::pow(track.pt(), cMaxDCArToPV3))) + + if (doQA) { + if constexpr (!isMC) { + dataPhiHist.fill(HIST("h2DauTracksPhiDCAxyPreCutData"), track.pt(), track.dcaXY()); + dataPhiHist.fill(HIST("h2DauTracksPhiDCAzPreCutData"), track.pt(), track.dcaZ()); + } else { + mcPhiHist.fill(HIST("h2DauTracksPhiDCAxyPreCutMCReco"), track.pt(), track.dcaXY()); + mcPhiHist.fill(HIST("h2DauTracksPhiDCAzPreCutMCReco"), track.pt(), track.dcaZ()); + } + } + if (std::abs(track.dcaXY()) > trackConfigs.cMaxDCArToPV1Phi + (trackConfigs.cMaxDCArToPV2Phi / std::pow(track.pt(), trackConfigs.cMaxDCArToPV3Phi))) return false; - if (track.tpcNClsFound() < minTPCnClsFound) + if (doQA) { + if constexpr (!isMC) { + dataPhiHist.fill(HIST("h2DauTracksPhiDCAxyPostCutData"), track.pt(), track.dcaXY()); + dataPhiHist.fill(HIST("h2DauTracksPhiDCAzPostCutData"), track.pt(), track.dcaZ()); + } else { + mcPhiHist.fill(HIST("h2DauTracksPhiDCAxyPostCutMCReco"), track.pt(), track.dcaXY()); + mcPhiHist.fill(HIST("h2DauTracksPhiDCAzPostCutMCReco"), track.pt(), track.dcaZ()); + } + } + if (std::abs(track.dcaZ()) > trackConfigs.cMaxDCAzToPVcut) return false; return true; } // PIDKaon track selection template - bool selectionPIDKaon(const T& candidate) + bool selectionPIDKaon(const T& track) { - if (!isNoTOF && candidate.hasTOF() && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < (nSigmaCutCombinedKa * nSigmaCutCombinedKa)) + if (!trackConfigs.isNoTOF && track.hasTOF() && (std::pow(track.tofNSigmaKa(), 2) + std::pow(track.tpcNSigmaKa(), 2)) < std::pow(trackConfigs.nSigmaCutCombinedKa, 2)) return true; - if (!isNoTOF && !candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < nSigmaCutTPCKa) + if (!trackConfigs.isNoTOF && !track.hasTOF() && std::abs(track.tpcNSigmaKa()) < trackConfigs.nSigmaCutTPCKa) return true; - if (isNoTOF && std::abs(candidate.tpcNSigmaKa()) < nSigmaCutTPCKa) + if (trackConfigs.isNoTOF && std::abs(track.tpcNSigmaKa()) < trackConfigs.nSigmaCutTPCKa) return true; return false; } template - bool selectionPIDKaonpTdependent(const T& candidate) + bool selectionPIDKaonpTdependent(const T& track) { - if (candidate.pt() < 0.5 && std::abs(candidate.tpcNSigmaKa()) < nSigmaCutTPCKa) + if (track.pt() < trackConfigs.pTToUseTOF && std::abs(track.tpcNSigmaKa()) < trackConfigs.nSigmaCutTPCKa) return true; - if (candidate.pt() >= 0.5 && candidate.hasTOF() && ((candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) + (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa())) < (nSigmaCutCombinedKa * nSigmaCutCombinedKa)) + if (track.pt() >= trackConfigs.pTToUseTOF && track.hasTOF() && (std::pow(track.tofNSigmaKa(), 2) + std::pow(track.tpcNSigmaKa(), 2)) < std::pow(trackConfigs.nSigmaCutCombinedKa, 2)) return true; return false; } // Reconstruct the Phi template - TLorentzVector recMother(const T1& candidate1, const T2& candidate2, float masscand1, float masscand2) + ROOT::Math::PxPyPzMVector recMother(const T1& track1, const T2& track2, float masscand1, float masscand2) { - TLorentzVector daughter1, daughter2, mother; - - daughter1.SetXYZM(candidate1.px(), candidate1.py(), candidate1.pz(), masscand1); // set the daughter1 4-momentum - daughter2.SetXYZM(candidate2.px(), candidate2.py(), candidate2.pz(), masscand2); // set the daughter2 4-momentum - mother = daughter1 + daughter2; // calculate the mother 4-momentum + ROOT::Math::PxPyPzMVector daughter1(track1.px(), track1.py(), track1.pz(), masscand1); // set the daughter1 4-momentum + ROOT::Math::PxPyPzMVector daughter2(track2.px(), track2.py(), track2.pz(), masscand2); // set the daughter2 4-momentum + ROOT::Math::PxPyPzMVector mother = daughter1 + daughter2; // calculate the mother 4-momentum return mother; } // Topological selection for pions - template - bool selectionPion(const T& track) + template + bool selectionPion(const T& track, bool doQA) { - if (!track.hasITS()) + if (!track.isGlobalTrackWoDCA()) return false; - if (track.itsNCls() < minITSnCls) + + if (track.itsNCls() < trackConfigs.minITSnCls) return false; - if (track.itsChi2NCl() > maxChi2ITS) + if (track.tpcNClsFound() < trackConfigs.minTPCnClsFound) return false; - if (track.pt() < 0.2) + if (track.pt() < trackConfigs.cMinPionPtcut) return false; - if (track.pt() < 0.8) { - if (!track.hasTPC()) - return false; - if (track.tpcNClsFound() < minTPCnClsFound) - return false; - if (track.tpcNClsCrossedRows() < minNCrossedRowsTPC) - return false; - if (track.tpcChi2NCl() > maxChi2TPC) + if constexpr (isTOFChecked) { + if (track.pt() >= trackConfigs.pTToUseTOF && !track.hasTOF()) return false; } - if (track.pt() >= 0.5) { - if (!track.hasTOF()) - return false; + if (doQA) { + if constexpr (!isMC) { + dataPionHist.fill(HIST("h2TracksPiDCAxyPreCutData"), track.pt(), track.dcaXY()); + dataPionHist.fill(HIST("h2TracksPiDCAzPreCutData"), track.pt(), track.dcaZ()); + } else { + mcPionHist.fill(HIST("h2TracksPiDCAxyPreCutMCReco"), track.pt(), track.dcaXY()); + mcPionHist.fill(HIST("h2TracksPiDCAzPreCutMCReco"), track.pt(), track.dcaZ()); + } } - - if (std::abs(track.dcaXY()) > dcaxyMax) + if (std::abs(track.dcaXY()) > trackConfigs.cMaxDCArToPV1Pion + (trackConfigs.cMaxDCArToPV2Pion / std::pow(track.pt(), trackConfigs.cMaxDCArToPV3Pion))) return false; - if (std::abs(track.dcaZ()) > dcazMax) - return false; - return true; - } - - // Fill 2D invariant mass histogram for V0 and Phi - template - void fillInvMass2D(const T& V0, const std::vector& listPhi, float multiplicity, const std::array weights) - { - for (const auto& Phi : listPhi) { - if constexpr (!isMC) { // same event - dataPhiK0SHist.fill(HIST("h4PhiK0SSEInc"), multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(0)); - if (std::abs(V0.yK0Short() - Phi.Rapidity()) > cfgFCutOnDeltaY) - continue; - dataPhiK0SHist.fill(HIST("h4PhiK0SSEFCut"), multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(1)); - if (std::abs(V0.yK0Short() - Phi.Rapidity()) > cfgSCutOnDeltaY) - continue; - dataPhiK0SHist.fill(HIST("h4PhiK0SSESCut"), multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(2)); - } else { // MC event - closureMCPhiK0SHist.fill(HIST("h4ClosureMCPhiK0SSEInc"), multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(0)); - if (std::abs(V0.yK0Short() - Phi.Rapidity()) > cfgFCutOnDeltaY) - continue; - closureMCPhiK0SHist.fill(HIST("h4ClosureMCPhiK0SSEFCut"), multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(1)); - if (std::abs(V0.yK0Short() - Phi.Rapidity()) > cfgSCutOnDeltaY) - continue; - closureMCPhiK0SHist.fill(HIST("h4ClosureMCPhiK0SSESCut"), multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(2)); + if (doQA) { + if constexpr (!isMC) { + dataPionHist.fill(HIST("h2TracksPiDCAxyPostCutData"), track.pt(), track.dcaXY()); + dataPionHist.fill(HIST("h2TracksPiDCAzPostCutData"), track.pt(), track.dcaZ()); + } else { + mcPionHist.fill(HIST("h2TracksPiDCAxyPostCutMCReco"), track.pt(), track.dcaXY()); + mcPionHist.fill(HIST("h2TracksPiDCAzPostCutMCReco"), track.pt(), track.dcaZ()); } } - } - - // Fill Phi invariant mass vs Pion nSigmadE/dx histogram - template - void fillInvMassNSigma(const T& Pi, const std::vector& listPhi, float multiplicity, const std::array weights) - { - float nSigmaTPCPi = (Pi.hasTPC() ? Pi.tpcNSigmaPi() : -999); - float nSigmaTOFPi = (Pi.hasTOF() ? Pi.tofNSigmaPi() : -999); - - for (const auto& Phi : listPhi) { - if constexpr (!isMC) { // same event - dataPhiPionHist.fill(HIST("h5PhiPiSEInc"), multiplicity, Pi.pt(), nSigmaTPCPi, nSigmaTOFPi, Phi.M(), weights.at(0)); - if (std::abs(Pi.rapidity(massPi) - Phi.Rapidity()) > cfgFCutOnDeltaY) - continue; - dataPhiPionHist.fill(HIST("h5PhiPiSEFCut"), multiplicity, Pi.pt(), nSigmaTPCPi, nSigmaTOFPi, Phi.M(), weights.at(1)); - if (std::abs(Pi.rapidity(massPi) - Phi.Rapidity()) > cfgSCutOnDeltaY) - continue; - dataPhiPionHist.fill(HIST("h5PhiPiSESCut"), multiplicity, Pi.pt(), nSigmaTPCPi, nSigmaTOFPi, Phi.M(), weights.at(2)); - } else { // MC event - closureMCPhiPionHist.fill(HIST("h5ClosureMCPhiPiSEInc"), multiplicity, Pi.pt(), nSigmaTPCPi, nSigmaTOFPi, Phi.M(), weights.at(0)); - if (std::abs(Pi.rapidity(massPi) - Phi.Rapidity()) > cfgFCutOnDeltaY) - continue; - closureMCPhiPionHist.fill(HIST("h5ClosureMCPhiPiSEFCut"), multiplicity, Pi.pt(), nSigmaTPCPi, nSigmaTOFPi, Phi.M(), weights.at(1)); - if (std::abs(Pi.rapidity(massPi) - Phi.Rapidity()) > cfgSCutOnDeltaY) - continue; - closureMCPhiPionHist.fill(HIST("h5ClosureMCPhiPiSESCut"), multiplicity, Pi.pt(), nSigmaTPCPi, nSigmaTOFPi, Phi.M(), weights.at(2)); - } + if (trackConfigs.cfgIsDCAzParameterized) { + if (std::abs(track.dcaZ()) > trackConfigs.cMaxDCAzToPV1Pion + (trackConfigs.cMaxDCAzToPV2Pion / std::pow(track.pt(), trackConfigs.cMaxDCAzToPV3Pion))) + return false; + } else { + if (std::abs(track.dcaZ()) > trackConfigs.cMaxDCAzToPVcut) + return false; } + return true; } - void processQAPurity(SelCollisions::iterator const& collision, FullTracks const& fullTracks, FullV0s const& V0s, V0DauTracks const&) + template + bool eventHasPhi(const T1& posTracks, const T2& negTracks) { - // Check if the event selection is passed - if (!acceptEventQA(collision, true)) - return; - - float multiplicity = collision.centFT0M(); - dataEventHist.fill(HIST("hMultiplicityPercent"), multiplicity); - - // Defining positive and negative tracks for phi reconstruction - auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - - bool isCountedPhi = false; - bool isFilledhV0 = false; + int nPhi = 0; - for (const auto& track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + for (const auto& track1 : posTracks) { + if (!selectionTrackResonance(track1, false) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection - candPhiHist.fill(HIST("hEta"), track1.eta()); - candPhiHist.fill(HIST("hDcaxy"), track1.dcaXY()); - candPhiHist.fill(HIST("hDcaz"), track1.dcaZ()); - candPhiHist.fill(HIST("hNsigmaKaonTPC"), track1.tpcInnerParam(), track1.tpcNSigmaKa()); - candPhiHist.fill(HIST("hNsigmaKaonTOF"), track1.tpcInnerParam(), track1.tofNSigmaKa()); - auto track1ID = track1.globalIndex(); - // Loop over all negative candidates - for (const auto& track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + for (const auto& track2 : negTracks) { + if (!selectionTrackResonance(track2, false) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); if (track2ID == track1ID) continue; // condition to avoid double counting of pair - TLorentzVector recPhi = recMother(track1, track2, massKa, massKa); - if (std::abs(recPhi.Rapidity()) > cfgYAcceptance) + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) + continue; + if (recPhi.M() < lowMPhi || recPhi.M() > upMPhi) + continue; + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) continue; - if (!isCountedPhi) { - dataEventHist.fill(HIST("hEventSelection"), 4); // at least a Phi candidate in the event - isCountedPhi = true; - } + nPhi++; + } + } - dataPhiHist.fill(HIST("h2PhipurInvMass"), multiplicity, recPhi.M()); + if (nPhi > 0) + return true; + return false; + } - std::array isCountedK0S{false, false, false}; + template + bool eventHasMCPhi(const T& mcParticles) + { + int nPhi = 0; + + for (const auto& mcParticle : mcParticles) { + if (mcParticle.pdgCode() != o2::constants::physics::Pdg::kPhi) + continue; + if (mcParticle.pt() < minPhiPt || mcParticle.pt() > maxPhiPt) + continue; + if (std::abs(mcParticle.y()) > deltaYConfigs.cfgYAcceptance) + continue; + + nPhi++; + } + + if (nPhi > 0) + return true; + return false; + } + + template + bool isGenParticleCharged(const T& mcParticle) + { + if (!mcParticle.isPhysicalPrimary() || std::abs(mcParticle.eta()) > trackConfigs.etaMax) + return false; + + auto pdgTrack = pdgDB->GetParticle(mcParticle.pdgCode()); + if (pdgTrack == nullptr) + return false; + if (std::abs(pdgTrack->Charge()) < trackConfigs.cfgMinAbsCharge) + return false; + + return true; + } + + int fromPDGToEnum(int pdgCode) + { + int pid = kSpAll; + switch (std::abs(pdgCode)) { + case PDG_t::kPiPlus: + pid = kSpPion; + break; + case PDG_t::kKPlus: + pid = kSpKaon; + break; + case PDG_t::kProton: + pid = kSpProton; + break; + default: + pid = kSpOther; + break; + } + + return pid; + } + + // Get phi-meson purity functions from CCDB + void getPhiPurityFunctionsFromCCDB() + { + TList* listPhiPurityFunctions = ccdb->get(ccdbPurityPath); + if (!listPhiPurityFunctions) + LOG(error) << "Problem getting TList object with phi purity functions!"; + + for (size_t multIdx = 0; multIdx < binsMult->size() - 1; multIdx++) { + for (size_t ptIdx = 0; ptIdx < binspTPhi->size() - 1; ptIdx++) { + phiPurityFunctions[multIdx][ptIdx] = static_cast(listPhiPurityFunctions->FindObject(Form("funcFitPhiPur_%zu_%zu", multIdx, ptIdx))); + } + } + } + + // Get the phi purity choosing the correct purity function according to the multiplicity and pt of the phi + double getPhiPurity(float multiplicity, const ROOT::Math::PxPyPzMVector& Phi) + { + // Check if multiplicity is out of range + if (multiplicity < binsMult->front() || multiplicity >= binsMult->back()) { + LOG(info) << "Multiplicity out of range: " << multiplicity; + return 0; + } + + // Find the multiplicity bin using upper_bound which finds the first element strictly greater than 'multiplicity' + // Subtract 1 to get the correct bin index + auto multIt = std::upper_bound(binsMult->begin(), binsMult->end(), multiplicity); + int multIdx = std::distance(binsMult->begin(), multIt) - 1; + + // Check if pT is out of range + if (Phi.Pt() < binspTPhi->front() || Phi.Pt() >= binspTPhi->back()) { + LOG(info) << "pT out of range: " << Phi.Pt(); + return 0; + } + + // Find the pT bin using upper_bound + // The logic is the same as for multiplicity + auto pTIt = std::upper_bound(binspTPhi->begin(), binspTPhi->end(), Phi.Pt()); + int pTIdx = std::distance(binspTPhi->begin(), pTIt) - 1; + + return phiPurityFunctions[multIdx][pTIdx]->Eval(Phi.M()); + } + + void getEfficiencyMapsFromCCDB() + { + TList* listEfficiencyMaps = ccdb->get(ccdbEfficiencyPath); + if (!listEfficiencyMaps) + LOG(error) << "Problem getting TList object with efficiency maps!"; + + effMapPhi = static_cast(listEfficiencyMaps->FindObject("h3EfficiencyPhi")); + if (!effMapPhi) { + LOG(error) << "Problem getting efficiency map for Phi!"; + return; + } + effMapK0S = static_cast(listEfficiencyMaps->FindObject("h3EfficiencyK0S")); + if (!effMapK0S) { + LOG(error) << "Problem getting efficiency map for K0S!"; + return; + } + effMapPionTPC = static_cast(listEfficiencyMaps->FindObject("h3EfficiencyPionTPC")); + if (!effMapPionTPC) { + LOG(error) << "Problem getting efficiency map for Pion with TPC!"; + return; + } + effMapPionTPCTOF = static_cast(listEfficiencyMaps->FindObject("h3EfficiencyPionTPCTOF")); + if (!effMapPionTPCTOF) { + LOG(error) << "Problem getting efficiency map for Pion with TPC and TOF!"; + return; + } + } + + // Fill 2D invariant mass histogram for V0 and Phi + template + void fillInvMass2D(const T& V0, const std::vector& listPhi, float multiplicity, const std::vector& weights) + { + for (const auto& Phi : listPhi) { + if constexpr (!isMC) { // same event + dataPhiK0SHist.fill(HIST("h5PhiK0SData"), 0, multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(0)); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(V0.yK0Short() - Phi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + dataPhiK0SHist.fill(HIST("h5PhiK0SData"), i + 1, multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(i + 1)); + } + } else { // MC event + closureMCPhiK0SHist.fill(HIST("h5PhiK0SMCClosure"), 0, multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(0)); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(V0.yK0Short() - Phi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + closureMCPhiK0SHist.fill(HIST("h5PhiK0SMCClosure"), i + 1, multiplicity, V0.pt(), V0.mK0Short(), Phi.M(), weights.at(i + 1)); + } + } + } + } + + // Fill Phi invariant mass vs Pion nSigmaTPC/TOF histogram + template + void fillInvMassNSigma(const T& Pi, const std::vector& listPhi, float multiplicity, const std::vector& weights) + { + float nSigmaTOFPi = (Pi.hasTOF() ? Pi.tofNSigmaPi() : -999); + + for (const auto& Phi : listPhi) { + if constexpr (!isMC) { // same event + dataPhiPionHist.fill(HIST("h6PhiPiData"), 0, multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, Phi.M(), weights.at(0)); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(Pi.rapidity(massPi) - Phi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + dataPhiPionHist.fill(HIST("h6PhiPiData"), i + 1, multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, Phi.M(), weights.at(i + 1)); + } + } else { // MC event + closureMCPhiPionHist.fill(HIST("h6PhiPiMCClosure"), 0, multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, Phi.M(), weights.at(0)); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(Pi.rapidity(massPi) - Phi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + closureMCPhiPionHist.fill(HIST("h6PhiPiMCClosure"), i + 1, multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, Phi.M(), weights.at(i + 1)); + } + } + } + } + + // Fill invariant mass histogram for V0 + template + void fillInvMass(const T& V0, float multiplicity, const std::vector& weights) + { + if constexpr (!isMC) { // same event + dataPhiK0SHist.fill(HIST("h3PhiK0SSEIncNew"), multiplicity, V0.pt(), V0.mK0Short(), weights.at(0)); + dataPhiK0SHist.fill(HIST("h3PhiK0SSEFCutNew"), multiplicity, V0.pt(), V0.mK0Short(), weights.at(1)); + dataPhiK0SHist.fill(HIST("h3PhiK0SSESCutNew"), multiplicity, V0.pt(), V0.mK0Short(), weights.at(2)); + } else { // MC event + closureMCPhiK0SHist.fill(HIST("h3ClosureMCPhiK0SSEIncNew"), multiplicity, V0.pt(), V0.mK0Short(), weights.at(0)); + closureMCPhiK0SHist.fill(HIST("h3ClosureMCPhiK0SSEFCutNew"), multiplicity, V0.pt(), V0.mK0Short(), weights.at(1)); + closureMCPhiK0SHist.fill(HIST("h3ClosureMCPhiK0SSESCutNew"), multiplicity, V0.pt(), V0.mK0Short(), weights.at(2)); + } + } + + // Fill nSigmaTPC/TOF histogram for Pion + template + void fillNSigma(const T& Pi, float multiplicity, const std::vector& weights) + { + float nSigmaTOFPi = (Pi.hasTOF() ? Pi.tofNSigmaPi() : -999); + + if constexpr (!isMC) { // same event + dataPhiPionHist.fill(HIST("h4PhiPiSEIncNew"), multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, weights.at(0)); + dataPhiPionHist.fill(HIST("h4PhiPiSEFCutNew"), multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, weights.at(1)); + dataPhiPionHist.fill(HIST("h4PhiPiSESCutNew"), multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, weights.at(2)); + } else { // MC event + closureMCPhiPionHist.fill(HIST("h4ClosureMCPhiPiSEIncNew"), multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, weights.at(0)); + closureMCPhiPionHist.fill(HIST("h4ClosureMCPhiPiSEFCutNew"), multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, weights.at(1)); + closureMCPhiPionHist.fill(HIST("h4ClosureMCPhiPiSESCutNew"), multiplicity, Pi.pt(), Pi.tpcNSigmaPi(), nSigmaTOFPi, weights.at(2)); + } + } + + void processPhiPurityData(SelCollisions::iterator const& collision, FullTracks const& fullTracks, FullV0s const& V0s, V0DauTracks const&) + { + // Check if the event selection is passed + if (!acceptEventQA(collision, true)) + return; + + float multiplicity = collision.centFT0M(); + dataEventHist.fill(HIST("hMultiplicityPercent"), multiplicity); + + // Defining positive and negative tracks for phi reconstruction + auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + bool isCountedPhi = false; + bool isFilledhV0 = false; + + double weight{1.0}; + + // Loop over all positive tracks + for (const auto& track1 : posThisColl) { + if (!selectionTrackResonance(track1, true) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + dataPhiHist.fill(HIST("hEta"), track1.eta()); + dataPhiHist.fill(HIST("hNsigmaKaonTPC"), track1.tpcInnerParam(), track1.tpcNSigmaKa()); + dataPhiHist.fill(HIST("hNsigmaKaonTOF"), track1.tpcInnerParam(), track1.tofNSigmaKa()); + + auto track1ID = track1.globalIndex(); + + // Loop over all negative tracks + for (const auto& track2 : negThisColl) { + if (!selectionTrackResonance(track2, true) || !selectionPIDKaonpTdependent(track2)) + continue; // topological and PID selection + + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) + continue; // condition to avoid double counting of pair + + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) + continue; + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) + continue; + + if (!isCountedPhi) { + dataEventHist.fill(HIST("hEventSelection"), 4); // at least a Phi candidate in the event + dataEventHist.fill(HIST("hMultiplicityPercentWithPhi"), multiplicity); + isCountedPhi = true; + } + + if (fillMethodSingleWeight) + weight *= (1 - getPhiPurity(multiplicity, recPhi)); + + dataPhiHist.fill(HIST("h3PhipurData"), multiplicity, recPhi.Pt(), recPhi.M()); + + std::vector countsK0S(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); // V0 already reconstructed by the builder for (const auto& v0 : V0s) { @@ -658,73 +1245,70 @@ struct Phik0shortanalysis { // Cut on V0 dynamic columns if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) continue; + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision)) + continue; if (!isFilledhV0) { - candK0SHist.fill(HIST("hDCAV0Daughters"), v0.dcaV0daughters()); - candK0SHist.fill(HIST("hV0CosPA"), v0.v0cosPA()); + dataK0SHist.fill(HIST("hDCAV0Daughters"), v0.dcaV0daughters()); + dataK0SHist.fill(HIST("hV0CosPA"), v0.v0cosPA()); // Filling the PID of the V0 daughters in the region of the K0 peak if (lowMK0S < v0.mK0Short() && v0.mK0Short() < upMK0S) { - candK0SHist.fill(HIST("hNSigmaPosPionFromK0S"), posDaughterTrack.tpcInnerParam(), posDaughterTrack.tpcNSigmaPi()); - candK0SHist.fill(HIST("hNSigmaNegPionFromK0S"), negDaughterTrack.tpcInnerParam(), negDaughterTrack.tpcNSigmaPi()); + dataK0SHist.fill(HIST("hNSigmaPosPionFromK0S"), posDaughterTrack.tpcInnerParam(), posDaughterTrack.tpcNSigmaPi()); + dataK0SHist.fill(HIST("hNSigmaNegPionFromK0S"), negDaughterTrack.tpcInnerParam(), negDaughterTrack.tpcNSigmaPi()); } } - if (std::abs(v0.yK0Short()) > cfgYAcceptance) - continue; - if (!isCountedK0S.at(0)) { - dataPhiHist.fill(HIST("h3PhipurK0SInvMassInc"), multiplicity, v0.pt(), recPhi.M()); - isCountedK0S.at(0) = true; - } - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgFCutOnDeltaY) - continue; - if (!isCountedK0S.at(1)) { - dataPhiHist.fill(HIST("h3PhipurK0SInvMassFCut"), multiplicity, v0.pt(), recPhi.M()); - isCountedK0S.at(1) = true; - } - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgSCutOnDeltaY) + if (std::abs(v0.yK0Short()) > deltaYConfigs.cfgYAcceptance) continue; - if (!isCountedK0S.at(2)) { - dataPhiHist.fill(HIST("h3PhipurK0SInvMassSCut"), multiplicity, v0.pt(), recPhi.M()); - isCountedK0S.at(2) = true; + + countsK0S.at(0)++; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + countsK0S.at(i + 1)++; } } + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + if (countsK0S.at(i) > 0) + dataPhiHist.fill(HIST("h4PhipurK0SData"), i, multiplicity, recPhi.Pt(), recPhi.M()); + } + isFilledhV0 = true; - std::array isCountedPi{false, false, false}; + std::vector countsPi(deltaYConfigs.cfgDeltaYAcceptanceBins->size(), 0); // Loop over all primary pion candidates for (const auto& track : fullTracks) { - if (!selectionPion(track)) + if (!selectionPion(track, false)) continue; - if (std::abs(track.rapidity(massPi)) > cfgYAcceptance) - continue; - if (!isCountedPi.at(0)) { - dataPhiHist.fill(HIST("h3PhipurPiInvMassInc"), multiplicity, track.pt(), recPhi.M()); - isCountedPi.at(0) = true; - } - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgFCutOnDeltaY) - continue; - if (!isCountedPi.at(1)) { - dataPhiHist.fill(HIST("h3PhipurPiInvMassFCut"), multiplicity, track.pt(), recPhi.M()); - isCountedPi.at(1) = true; - } - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgSCutOnDeltaY) + if (std::abs(track.rapidity(massPi)) > deltaYConfigs.cfgYAcceptance) continue; - if (!isCountedPi.at(2)) { - dataPhiHist.fill(HIST("h3PhipurPiInvMassSCut"), multiplicity, track.pt(), recPhi.M()); - isCountedPi.at(2) = true; + + countsPi.at(0)++; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + countsPi.at(i + 1)++; } } + + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + if (countsPi.at(i) > 0) + dataPhiHist.fill(HIST("h4PhipurPiData"), i, multiplicity, recPhi.Pt(), recPhi.M()); + } } } + + weight = 1 - weight; + dataEventHist.fill(HIST("hEventSelection"), 5, weight); // at least a Phi in the event } - PROCESS_SWITCH(Phik0shortanalysis, processQAPurity, "Process for QA and Phi Purities", true); + PROCESS_SWITCH(Phik0shortanalysis, processPhiPurityData, "Process function for Phi Purities in Data", true); - void processSEPhiK0S(soa::Filtered::iterator const& collision, FullTracks const&, FullV0s const& V0s, V0DauTracks const&) + void processPhiK0SData(soa::Filtered::iterator const& collision, FullTracks const&, FullV0s const& V0s, V0DauTracks const&) { if (!collision.isInelGt0()) return; @@ -744,60 +1328,78 @@ struct Phik0shortanalysis { // Cut on V0 dynamic columns if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) continue; + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision)) + continue; - if (std::abs(v0.yK0Short()) > cfgYAcceptance) + dataK0SHist.fill(HIST("h3K0SRapidityData"), multiplicity, v0.pt(), v0.yK0Short()); + + if (std::abs(v0.yK0Short()) > deltaYConfigs.cfgYAcceptance) continue; - std::vector listrecPhi; - std::array counts{}; + std::vector listrecPhi; + std::vector counts(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); + std::vector weights(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 1); // Phi reconstruction - // Loop over positive candidates - for (const auto& track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + // Loop over positive tracks + for (const auto& track1 : posThisColl) { + if (!selectionTrackResonance(track1, false) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection auto track1ID = track1.globalIndex(); - // Loop over all negative candidates + // Loop over all negative tracks for (const auto& track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + if (!selectionTrackResonance(track2, false) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); if (track2ID == track1ID) continue; // condition to avoid double counting of pair - TLorentzVector recPhi = recMother(track1, track2, massKa, massKa); - + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) + continue; if (recPhi.M() < lowMPhi || recPhi.M() > upMPhi) continue; - - if (std::abs(recPhi.Rapidity()) > cfgYAcceptance) + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) continue; - listrecPhi.push_back(recPhi); + + double phiPurity{}; + if (fillMethodSingleWeight) + phiPurity = getPhiPurity(multiplicity, recPhi); + + if (fillMethodMultipleWeights) + listrecPhi.push_back(recPhi); + counts.at(0)++; - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgFCutOnDeltaY) - continue; - counts.at(1)++; - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgSCutOnDeltaY) - continue; - counts.at(2)++; + weights.at(0) *= (1 - phiPurity); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + counts.at(i + 1)++; + weights.at(i + 1) *= (1 - phiPurity); + } } } - std::array weights{}; - for (unsigned int i = 0; i < counts.size(); i++) { - weights.at(i) = (counts.at(i) > 0 ? 1. / static_cast(counts.at(i)) : 0); + if (fillMethodMultipleWeights) { + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + weights.at(i) = (counts.at(i) > 0 ? 1. / static_cast(counts.at(i)) : 0); + } + fillInvMass2D(v0, listrecPhi, multiplicity, weights); + } else if (fillMethodSingleWeight) { + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + weights.at(i) = (counts.at(i) > 0 ? 1 - weights.at(i) : 0); + } + fillInvMass(v0, multiplicity, weights); } - - fillInvMass2D(v0, listrecPhi, multiplicity, weights); } } - PROCESS_SWITCH(Phik0shortanalysis, processSEPhiK0S, "Process Same Event for Phi-K0S Analysis", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiK0SData, "Process function for Phi-K0S Correlations in Data", false); - void processSEPhiPion(soa::Filtered::iterator const& collision, FullTracks const& fullTracks) + void processPhiPionData(soa::Filtered::iterator const& collision, FullTracks const& fullTracks) { if (!collision.isInelGt0()) return; @@ -813,68 +1415,84 @@ struct Phik0shortanalysis { for (const auto& track : fullTracks) { // Pion selection - if (!selectionPion(track)) + if (!selectionPion(track, true)) continue; - if (std::abs(track.rapidity(massPi)) > cfgYAcceptance) + dataPionHist.fill(HIST("h3PiRapidityData"), multiplicity, track.pt(), track.rapidity(massPi)); + + if (std::abs(track.rapidity(massPi)) > deltaYConfigs.cfgYAcceptance) continue; - std::vector listrecPhi; - std::array counts{}; + std::vector listrecPhi; + std::vector counts(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); + std::vector weights(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 1); // Phi reconstruction - // Loop over positive candidates + // Loop over positive tracks for (const auto& track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + if (!selectionTrackResonance(track1, false) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection auto track1ID = track1.globalIndex(); - // Loop over all negative candidates + // Loop over all negative tracks for (const auto& track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + if (!selectionTrackResonance(track2, false) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); if (track2ID == track1ID) continue; // condition to avoid double counting of pair - TLorentzVector recPhi = recMother(track1, track2, massKa, massKa); - + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) + continue; if (recPhi.M() < lowMPhi || recPhi.M() > upMPhi) continue; - - if (std::abs(recPhi.Rapidity()) > cfgYAcceptance) + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) continue; - listrecPhi.push_back(recPhi); + + double phiPurity{}; + if (fillMethodSingleWeight) + phiPurity = getPhiPurity(multiplicity, recPhi); + + if (fillMethodMultipleWeights) + listrecPhi.push_back(recPhi); + counts.at(0)++; - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgFCutOnDeltaY) - continue; - counts.at(1)++; - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgSCutOnDeltaY) - continue; - counts.at(2)++; + weights.at(0) *= (1 - phiPurity); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + counts.at(i + 1)++; + weights.at(i + 1) *= (1 - phiPurity); + } } } - std::array weights{}; - for (unsigned int i = 0; i < counts.size(); i++) { - weights.at(i) = (counts.at(i) > 0 ? 1. / static_cast(counts.at(i)) : 0); + if (fillMethodMultipleWeights) { + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + weights.at(i) = (counts.at(i) > 0 ? 1. / static_cast(counts.at(i)) : 0); + } + fillInvMassNSigma(track, listrecPhi, multiplicity, weights); + } else if (fillMethodSingleWeight) { + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + weights.at(i) = (counts.at(i) > 0 ? 1 - weights.at(i) : 0); + } + fillNSigma(track, multiplicity, weights); } - - fillInvMassNSigma(track, listrecPhi, multiplicity, weights); } } - PROCESS_SWITCH(Phik0shortanalysis, processSEPhiPion, "Process Same Event for Phi-Pion Analysis", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiPionData, "Process function for Phi-Pion Correlations in Data", false); - void processRecMCPhiQA(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, FullMCV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const&) + void processPhiMCReco(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, FullMCV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const&) { if (!acceptEventQA(collision, true)) return; float multiplicity = collision.centFT0M(); - mcEventHist.fill(HIST("hRecMCMultiplicityPercent"), multiplicity); + mcEventHist.fill(HIST("hUnbinnedRecoMCMultiplicityPercent"), multiplicity); if (!collision.has_mcCollision()) return; @@ -882,7 +1500,7 @@ struct Phik0shortanalysis { const auto& mcCollision = collision.mcCollision_as(); float genmultiplicity = mcCollision.centFT0M(); - mcEventHist.fill(HIST("hRecMCGenMultiplicityPercent"), genmultiplicity); + mcEventHist.fill(HIST("hRecoMCMultiplicityPercent"), genmultiplicity); // Defining positive and negative tracks for phi reconstruction auto posThisColl = posMCTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); @@ -890,8 +1508,9 @@ struct Phik0shortanalysis { bool isCountedPhi = false; - for (const auto& track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + // Loop over all positive tracks + for (const auto& track1 : posThisColl) { + if (!selectionTrackResonance(track1, false) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection auto track1ID = track1.globalIndex(); @@ -899,12 +1518,12 @@ struct Phik0shortanalysis { if (!track1.has_mcParticle()) continue; auto mcTrack1 = track1.mcParticle_as(); - if (mcTrack1.pdgCode() != 321 || !mcTrack1.isPhysicalPrimary()) + if (mcTrack1.pdgCode() != PDG_t::kKPlus || !mcTrack1.isPhysicalPrimary()) continue; - // Loop over all negative candidates + // Loop over all negative tracks for (const auto& track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + if (!selectionTrackResonance(track2, false) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); @@ -914,14 +1533,14 @@ struct Phik0shortanalysis { if (!track2.has_mcParticle()) continue; auto mcTrack2 = track2.mcParticle_as(); - if (mcTrack2.pdgCode() != -321 || !mcTrack2.isPhysicalPrimary()) + if (mcTrack2.pdgCode() != PDG_t::kKMinus || !mcTrack2.isPhysicalPrimary()) continue; bool isMCMotherPhi = false; auto mcMotherPhi = mcTrack1.mothers_as()[0]; for (const auto& MotherOfmcTrack1 : mcTrack1.mothers_as()) { for (const auto& MotherOfmcTrack2 : mcTrack2.mothers_as()) { - if (MotherOfmcTrack1 == MotherOfmcTrack2 && MotherOfmcTrack1.pdgCode() == 333) { + if (MotherOfmcTrack1 == MotherOfmcTrack2 && MotherOfmcTrack1.pdgCode() == o2::constants::physics::Pdg::kPhi) { mcMotherPhi = MotherOfmcTrack1; isMCMotherPhi = true; } @@ -931,11 +1550,13 @@ struct Phik0shortanalysis { if (!isMCMotherPhi) continue; - TLorentzVector recPhi = recMother(track1, track2, massKa, massKa); + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) + continue; mcPhiHist.fill(HIST("h3PhiRapiditySmearing"), genmultiplicity, recPhi.Rapidity(), mcMotherPhi.y()); - if (std::abs(recPhi.Rapidity()) > cfgYAcceptance) + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) continue; if (!isCountedPhi) { @@ -954,7 +1575,7 @@ struct Phik0shortanalysis { } auto v0mcparticle = v0.mcParticle(); - if (v0mcparticle.pdgCode() != 310 || !v0mcparticle.isPhysicalPrimary()) + if (v0mcparticle.pdgCode() != PDG_t::kK0Short || !v0mcparticle.isPhysicalPrimary()) continue; const auto& posDaughterTrack = v0.posTrack_as(); @@ -963,20 +1584,22 @@ struct Phik0shortanalysis { // Cut on V0 dynamic columns if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) continue; + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision)) + continue; - if (std::abs(v0.yK0Short()) > cfgYAcceptance) + if (std::abs(v0.yK0Short()) > deltaYConfigs.cfgYAcceptance) continue; if (!isCountedK0S.at(0)) { mcPhiHist.fill(HIST("h3PhieffK0SInvMassInc"), genmultiplicity, v0.pt(), recPhi.M()); isCountedK0S.at(0) = true; } - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgFCutOnDeltaY) + if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > deltaYConfigs.cfgFCutOnDeltaY) continue; if (!isCountedK0S.at(1)) { mcPhiHist.fill(HIST("h3PhieffK0SInvMassFCut"), genmultiplicity, v0.pt(), recPhi.M()); isCountedK0S.at(1) = true; } - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgSCutOnDeltaY) + if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > deltaYConfigs.cfgSCutOnDeltaY) continue; if (!isCountedK0S.at(2)) { mcPhiHist.fill(HIST("h3PhieffK0SInvMassSCut"), genmultiplicity, v0.pt(), recPhi.M()); @@ -992,25 +1615,25 @@ struct Phik0shortanalysis { continue; auto mcTrack = track.mcParticle_as(); - if (std::abs(mcTrack.pdgCode()) != 211 || !mcTrack.isPhysicalPrimary()) + if (std::abs(mcTrack.pdgCode()) != PDG_t::kPiPlus || !mcTrack.isPhysicalPrimary()) continue; - if (!selectionPion(track)) + if (!selectionPion(track, false)) continue; - if (std::abs(track.rapidity(massPi)) > cfgYAcceptance) + if (std::abs(track.rapidity(massPi)) > deltaYConfigs.cfgYAcceptance) continue; if (!isCountedPi.at(0)) { mcPhiHist.fill(HIST("h3PhieffPiInvMassInc"), genmultiplicity, track.pt(), recPhi.M()); isCountedPi.at(0) = true; } - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgFCutOnDeltaY) + if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > deltaYConfigs.cfgFCutOnDeltaY) continue; if (!isCountedPi.at(1)) { mcPhiHist.fill(HIST("h3PhieffPiInvMassFCut"), genmultiplicity, track.pt(), recPhi.M()); isCountedPi.at(1) = true; } - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgSCutOnDeltaY) + if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > deltaYConfigs.cfgSCutOnDeltaY) continue; if (!isCountedPi.at(2)) { mcPhiHist.fill(HIST("h3PhieffPiInvMassSCut"), genmultiplicity, track.pt(), recPhi.M()); @@ -1021,9 +1644,9 @@ struct Phik0shortanalysis { } } - PROCESS_SWITCH(Phik0shortanalysis, processRecMCPhiQA, "Process for ReCMCQA and Phi in RecMC", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiMCReco, "Process function for Phi in MCReco (to be removed)", false); - void processRecMCPhiK0S(SimCollisions const& collisions, FullMCV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const& mcParticles) + void processPhiK0SMCReco(SimCollisions const& collisions, FullMCV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const& mcParticles) { for (const auto& collision : collisions) { if (!acceptEventQA(collision, false)) @@ -1047,7 +1670,7 @@ struct Phik0shortanalysis { continue; auto v0mcparticle = v0.mcParticle(); - if (v0mcparticle.pdgCode() != 310 || !v0mcparticle.isPhysicalPrimary()) + if (v0mcparticle.pdgCode() != PDG_t::kK0Short || !v0mcparticle.isPhysicalPrimary()) continue; const auto& posDaughterTrack = v0.posTrack_as(); @@ -1055,46 +1678,45 @@ struct Phik0shortanalysis { if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) continue; + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision)) + continue; mcK0SHist.fill(HIST("h4K0SRapiditySmearing"), genmultiplicity, v0.pt(), v0.yK0Short(), v0mcparticle.y()); - if (std::abs(v0mcparticle.y()) > cfgYAcceptance) + if (std::abs(v0mcparticle.y()) > deltaYConfigs.cfgYAcceptance) continue; - mcK0SHist.fill(HIST("h3K0SeffInvMass"), genmultiplicity, v0.pt(), v0.mK0Short()); + mcK0SHist.fill(HIST("h3K0SMCReco"), genmultiplicity, v0mcparticle.pt(), v0.mK0Short()); - std::array isCountedMCPhi{false, false, false}; + std::vector counts(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); for (const auto& mcParticle : mcParticlesThisColl) { - if (mcParticle.pdgCode() != 333) - continue; - if (std::abs(mcParticle.y()) > cfgYAcceptance) + if (mcParticle.pdgCode() != o2::constants::physics::Pdg::kPhi) continue; - - if (!isCountedMCPhi.at(0)) { - mcPhiK0SHist.fill(HIST("h3RecMCPhiK0SSEInc"), genmultiplicity, v0.pt(), v0.mK0Short()); - isCountedMCPhi.at(0) = true; - } - if (std::abs(v0mcparticle.y() - mcParticle.y()) > cfgFCutOnDeltaY) + if (mcParticle.pt() < minPhiPt || mcParticle.pt() > maxPhiPt) continue; - if (!isCountedMCPhi.at(1)) { - mcPhiK0SHist.fill(HIST("h3RecMCPhiK0SSEFCut"), genmultiplicity, v0.pt(), v0.mK0Short()); - isCountedMCPhi.at(1) = true; - } - if (std::abs(v0mcparticle.y() - mcParticle.y()) > cfgSCutOnDeltaY) + if (std::abs(mcParticle.y()) > deltaYConfigs.cfgYAcceptance) continue; - if (!isCountedMCPhi.at(2)) { - mcPhiK0SHist.fill(HIST("h3RecMCPhiK0SSESCut"), genmultiplicity, v0.pt(), v0.mK0Short()); - isCountedMCPhi.at(2) = true; + + counts.at(0)++; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(v0mcparticle.y() - mcParticle.y()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + counts.at(i + 1)++; } } + + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + if (counts.at(i) > 0) + mcPhiK0SHist.fill(HIST("h4PhiK0SMCReco"), i, genmultiplicity, v0mcparticle.pt(), v0.mK0Short()); + } } } } - PROCESS_SWITCH(Phik0shortanalysis, processRecMCPhiK0S, "Process RecMC for Phi-K0S Analysis", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiK0SMCReco, "Process function for Phi-K0S Correlations Efficiency correction in MCReco", false); - void processRecMCPhiPion(SimCollisions const& collisions, FullMCTracks const& fullMCTracks, MCCollisions const&, aod::McParticles const& mcParticles) + void processPhiPionMCReco(SimCollisions const& collisions, FullMCTracks const& fullMCTracks, MCCollisions const&, aod::McParticles const& mcParticles) { for (const auto& collision : collisions) { if (!acceptEventQA(collision, false)) @@ -1114,59 +1736,93 @@ struct Phik0shortanalysis { // Loop over all primary pion candidates for (const auto& track : mcTracksThisColl) { + // Pion selection + if (!selectionPion(track, false)) + continue; + if (!track.has_mcParticle()) continue; auto mcTrack = track.mcParticle_as(); - if (std::abs(mcTrack.pdgCode()) != 211 || !mcTrack.isPhysicalPrimary()) + if (std::abs(mcTrack.pdgCode()) != PDG_t::kPiPlus) continue; - // Pion selection - if (!selectionPion(track)) + if (std::abs(mcTrack.y()) > deltaYConfigs.cfgYAcceptance) continue; - mcPionHist.fill(HIST("h4PiRapiditySmearing"), genmultiplicity, track.pt(), track.rapidity(massPi), mcTrack.y()); - - if (std::abs(mcTrack.y()) > cfgYAcceptance) + // Primary pion selection + if (mcTrack.isPhysicalPrimary()) { + mcPionHist.fill(HIST("h3RecMCDCAxyPrimPi"), track.pt(), track.dcaXY()); + } else { + if (mcTrack.getProcess() == 4) { // Selection of secondary pions from weak decay + mcPionHist.fill(HIST("h3RecMCDCAxySecWeakDecayPi"), track.pt(), track.dcaXY()); + } else { // Selection of secondary pions from material interactions + mcPionHist.fill(HIST("h3RecMCDCAxySecMaterialPi"), track.pt(), track.dcaXY()); + } continue; + } - float nsigmaTPC = (track.hasTPC() ? track.tpcNSigmaPi() : -999); - float nsigmaTOF = (track.hasTOF() ? track.tofNSigmaPi() : -999); + mcPionHist.fill(HIST("h4PiRapiditySmearing"), genmultiplicity, track.pt(), track.rapidity(massPi), mcTrack.y()); - mcPionHist.fill(HIST("h4PieffInvMass"), genmultiplicity, track.pt(), nsigmaTPC, nsigmaTOF); + mcPionHist.fill(HIST("h3PiTPCMCReco"), genmultiplicity, mcTrack.pt(), track.tpcNSigmaPi()); - std::array isCountedMCPhi{false, false, false}; + std::vector countsTPC(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); for (const auto& mcParticle : mcParticlesThisColl) { - if (mcParticle.pdgCode() != 333) + if (mcParticle.pdgCode() != o2::constants::physics::Pdg::kPhi) continue; - if (std::abs(mcParticle.y()) > cfgYAcceptance) + if (mcParticle.pt() < minPhiPt || mcParticle.pt() > maxPhiPt) + continue; + if (std::abs(mcParticle.y()) > deltaYConfigs.cfgYAcceptance) continue; - if (!isCountedMCPhi.at(0)) { - mcPhiPionHist.fill(HIST("h4RecMCPhiPiSEInc"), genmultiplicity, track.pt(), nsigmaTPC, nsigmaTOF); - isCountedMCPhi.at(0) = true; + countsTPC.at(0)++; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(mcTrack.y() - mcParticle.y()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + countsTPC.at(i + 1)++; } - if (std::abs(mcTrack.y() - mcParticle.y()) > cfgFCutOnDeltaY) + } + + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + if (countsTPC.at(i) > 0) + mcPhiPionHist.fill(HIST("h4PhiPiTPCMCReco"), i, genmultiplicity, mcTrack.pt(), track.tpcNSigmaPi()); + } + + if (track.pt() >= trackConfigs.pTToUseTOF && !track.hasTOF()) + continue; + + mcPionHist.fill(HIST("h4PiTPCTOFMCReco"), genmultiplicity, mcTrack.pt(), track.tpcNSigmaPi(), track.tofNSigmaPi()); + + std::vector countsTPCTOF(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); + + for (const auto& mcParticle : mcParticlesThisColl) { + if (mcParticle.pdgCode() != o2::constants::physics::Pdg::kPhi) continue; - if (!isCountedMCPhi.at(1)) { - mcPhiPionHist.fill(HIST("h4RecMCPhiPiSEFCut"), genmultiplicity, track.pt(), nsigmaTPC, nsigmaTOF); - isCountedMCPhi.at(1) = true; - } - if (std::abs(mcTrack.y() - mcParticle.y()) > cfgSCutOnDeltaY) + if (mcParticle.pt() < minPhiPt || mcParticle.pt() > maxPhiPt) + continue; + if (std::abs(mcParticle.y()) > deltaYConfigs.cfgYAcceptance) continue; - if (!isCountedMCPhi.at(2)) { - mcPhiPionHist.fill(HIST("h4RecMCPhiPiSESCut"), genmultiplicity, track.pt(), nsigmaTPC, nsigmaTOF); - isCountedMCPhi.at(2) = true; + + countsTPCTOF.at(0)++; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(mcTrack.y() - mcParticle.y()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + countsTPCTOF.at(i + 1)++; } } + + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + if (countsTPCTOF.at(i) > 0) + mcPhiPionHist.fill(HIST("h5PhiPiTPCTOFMCReco"), i, genmultiplicity, mcTrack.pt(), track.tpcNSigmaPi(), track.tofNSigmaPi()); + } } } } - PROCESS_SWITCH(Phik0shortanalysis, processRecMCPhiPion, "Process RecMC for Phi-Pion Analysis", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiPionMCReco, "Process function for Phi-Pion Correlations Efficiency correction in MCReco", false); - void processRecMCClosurePhiQA(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, FullV0s const& V0s, V0DauMCTracks const&, MCCollisions const&) + void processPhiPurityMCClosure(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, FullMCV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const&) { if (!acceptEventQA(collision, true)) return; @@ -1177,7 +1833,7 @@ struct Phik0shortanalysis { const auto& mcCollision = collision.mcCollision_as(); float genmultiplicity = mcCollision.centFT0M(); - mcEventHist.fill(HIST("hRecMCGenMultiplicityPercent"), genmultiplicity); + mcEventHist.fill(HIST("hRecoMCMultiplicityPercent"), genmultiplicity); // Defining positive and negative tracks for phi reconstruction auto posThisColl = posMCTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); @@ -1185,98 +1841,117 @@ struct Phik0shortanalysis { bool isCountedPhi = false; - for (const auto& track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + double weight{1.0}; + + // Loop over all positive tracks + for (const auto& track1 : posThisColl) { + if (!selectionTrackResonance(track1, true) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection auto track1ID = track1.globalIndex(); - // Loop over all negative candidates + // Loop over all negative tracks for (const auto& track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + if (!selectionTrackResonance(track2, true) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); if (track2ID == track1ID) continue; // condition to avoid double counting of pair - TLorentzVector recPhi = recMother(track1, track2, massKa, massKa); - if (std::abs(recPhi.Rapidity()) > cfgYAcceptance) + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) + continue; + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) continue; if (!isCountedPhi) { - mcEventHist.fill(HIST("hRecMCEventSelection"), 7); // at least a Phi in the event + mcEventHist.fill(HIST("hRecMCEventSelection"), 7); // at least a Phi candidate in the event + mcEventHist.fill(HIST("hRecoMCMultiplicityPercentWithPhi"), genmultiplicity); isCountedPhi = true; } - closureMCPhiHist.fill(HIST("h2MCPhipurInvMass"), genmultiplicity, recPhi.M()); + if (fillMethodSingleWeight) + weight *= (1 - getPhiPurity(genmultiplicity, recPhi)); - std::array isCountedK0S{false, false, false}; + closureMCPhiHist.fill(HIST("h3PhipurMCClosure"), genmultiplicity, recPhi.Pt(), recPhi.M()); + + std::vector countsK0S(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); // V0 already reconstructed by the builder for (const auto& v0 : V0s) { + if (cfgisRecMCWPDGForClosure1) { + if (!v0.has_mcParticle()) + continue; + auto v0mcparticle = v0.mcParticle(); + if (v0mcparticle.pdgCode() != PDG_t::kK0Short || !v0mcparticle.isPhysicalPrimary()) + continue; + } + const auto& posDaughterTrack = v0.posTrack_as(); const auto& negDaughterTrack = v0.negTrack_as(); if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) continue; - - if (std::abs(v0.yK0Short()) > cfgYAcceptance) + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision)) continue; - if (!isCountedK0S.at(0)) { - closureMCPhiHist.fill(HIST("h3MCPhipurK0SInvMassInc"), genmultiplicity, v0.pt(), recPhi.M()); - isCountedK0S.at(0) = true; - } - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgFCutOnDeltaY) - continue; - if (!isCountedK0S.at(1)) { - closureMCPhiHist.fill(HIST("h3MCPhipurK0SInvMassFCut"), genmultiplicity, v0.pt(), recPhi.M()); - isCountedK0S.at(1) = true; - } - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgSCutOnDeltaY) + if (std::abs(v0.yK0Short()) > deltaYConfigs.cfgYAcceptance) continue; - if (!isCountedK0S.at(2)) { - closureMCPhiHist.fill(HIST("h3MCPhipurK0SInvMassSCut"), genmultiplicity, v0.pt(), recPhi.M()); - isCountedK0S.at(2) = true; + + countsK0S.at(0)++; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + countsK0S.at(i + 1)++; } } - std::array isCountedPi{false, false, false}; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + if (countsK0S.at(i) > 0) + closureMCPhiHist.fill(HIST("h4PhipurK0SInvMass"), i, genmultiplicity, recPhi.Pt(), recPhi.M()); + } + + std::vector countsPi(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); // Loop over all primary pion candidates for (const auto& track : fullMCTracks) { + if (cfgisRecMCWPDGForClosure1) { + if (!track.has_mcParticle()) + continue; + auto mcTrack = track.mcParticle_as(); + if (std::abs(mcTrack.pdgCode()) != PDG_t::kPiPlus || !mcTrack.isPhysicalPrimary()) + continue; + } - if (!selectionPion(track)) + if (!selectionPion(track, false)) continue; - if (std::abs(track.rapidity(massPi)) > cfgYAcceptance) + if (std::abs(track.rapidity(massPi)) > deltaYConfigs.cfgYAcceptance) continue; - if (!isCountedPi.at(0)) { - closureMCPhiHist.fill(HIST("h3MCPhipurPiInvMassInc"), genmultiplicity, track.pt(), recPhi.M()); - isCountedPi.at(0) = true; - } - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgFCutOnDeltaY) - continue; - if (!isCountedPi.at(1)) { - closureMCPhiHist.fill(HIST("h3MCPhipurPiInvMassFCut"), genmultiplicity, track.pt(), recPhi.M()); - isCountedPi.at(1) = true; - } - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgSCutOnDeltaY) - continue; - if (!isCountedPi.at(2)) { - closureMCPhiHist.fill(HIST("h3MCPhipurPiInvMassSCut"), genmultiplicity, track.pt(), recPhi.M()); - isCountedPi.at(2) = true; + countsPi.at(0)++; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + countsPi.at(i + 1)++; } } + + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + if (countsPi.at(i) > 0) + closureMCPhiHist.fill(HIST("h4PhipurPiInvMass"), i, genmultiplicity, recPhi.Pt(), recPhi.M()); + } } } + + weight = 1 - weight; + mcEventHist.fill(HIST("hRecMCEventSelection"), 8, weight); // at least a Phi in the event } - PROCESS_SWITCH(Phik0shortanalysis, processRecMCClosurePhiQA, "Process for ReCMCQA and Phi in RecMCClosure", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiPurityMCClosure, "Process function for Phi Purities in MCClosure", false); - void processRecMCClosurePhiK0S(SimCollisions::iterator const& collision, FullMCTracks const&, FullV0s const& V0s, V0DauMCTracks const&, MCCollisions const&) + void processPhiK0SMCClosure(SimCollisions::iterator const& collision, FullMCTracks const&, FullMCV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const&) { if (!acceptEventQA(collision, false)) return; @@ -1293,63 +1968,116 @@ struct Phik0shortanalysis { // V0 already reconstructed by the builder for (const auto& v0 : V0s) { + if (cfgisRecMCWPDGForClosure1) { + if (!v0.has_mcParticle()) + continue; + auto v0mcparticle = v0.mcParticle(); + if (v0mcparticle.pdgCode() != PDG_t::kK0Short || !v0mcparticle.isPhysicalPrimary()) + continue; + } + const auto& posDaughterTrack = v0.posTrack_as(); const auto& negDaughterTrack = v0.negTrack_as(); if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) continue; + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision)) + continue; - if (std::abs(v0.yK0Short()) > cfgYAcceptance) + if (std::abs(v0.yK0Short()) > deltaYConfigs.cfgYAcceptance) continue; - std::vector listrecPhi; - std::array counts{}; + std::vector listrecPhi; + std::vector counts(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); + std::vector weights(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 1); // Phi reconstruction for (const auto& track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + if (!selectionTrackResonance(track1, false) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection auto track1ID = track1.globalIndex(); for (const auto& track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + if (!selectionTrackResonance(track2, false) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); if (track2ID == track1ID) continue; // condition to avoid double counting of pair - TLorentzVector recPhi = recMother(track1, track2, massKa, massKa); + if (cfgisRecMCWPDGForClosure2) { + if (!track1.has_mcParticle()) + continue; + auto mcTrack1 = track1.mcParticle_as(); + if (mcTrack1.pdgCode() != PDG_t::kKPlus || !mcTrack1.isPhysicalPrimary()) + continue; + + if (!track2.has_mcParticle()) + continue; + auto mcTrack2 = track2.mcParticle_as(); + if (mcTrack2.pdgCode() != PDG_t::kKMinus || !mcTrack2.isPhysicalPrimary()) + continue; + + bool isMCMotherPhi = false; + for (const auto& motherOfMcTrack1 : mcTrack1.mothers_as()) { + for (const auto& motherOfMcTrack2 : mcTrack2.mothers_as()) { + if (motherOfMcTrack1.pdgCode() != motherOfMcTrack2.pdgCode()) + continue; + if (motherOfMcTrack1.globalIndex() != motherOfMcTrack2.globalIndex()) + continue; + if (motherOfMcTrack1.pdgCode() != o2::constants::physics::Pdg::kPhi) + continue; + isMCMotherPhi = true; + } + } + if (!isMCMotherPhi) + continue; + } + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) + continue; if (recPhi.M() < lowMPhi || recPhi.M() > upMPhi) continue; - - if (std::abs(recPhi.Rapidity()) > cfgYAcceptance) + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) continue; - listrecPhi.push_back(recPhi); + + double phiPurity{}; + if (fillMethodSingleWeight) + phiPurity = getPhiPurity(genmultiplicity, recPhi); + + if (fillMethodMultipleWeights) + listrecPhi.push_back(recPhi); + counts.at(0)++; - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgFCutOnDeltaY) - continue; - counts.at(1)++; - if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > cfgSCutOnDeltaY) - continue; - counts.at(2)++; + weights.at(0) *= (1 - phiPurity); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(v0.yK0Short() - recPhi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + counts.at(i + 1)++; + weights.at(i + 1) *= (1 - phiPurity); + } } } - std::array weights{}; - for (unsigned int i = 0; i < counts.size(); i++) { - weights.at(i) = (counts.at(i) > 0 ? 1. / static_cast(counts.at(i)) : 0); + if (fillMethodMultipleWeights) { + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + weights.at(i) = (counts.at(i) > 0 ? 1. / static_cast(counts.at(i)) : 0); + } + fillInvMass2D(v0, listrecPhi, genmultiplicity, weights); + } else if (fillMethodSingleWeight) { + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + weights.at(i) = (counts.at(i) > 0 ? 1 - weights.at(i) : 0); + } + fillInvMass(v0, genmultiplicity, weights); } - - fillInvMass2D(v0, listrecPhi, genmultiplicity, weights); } } - PROCESS_SWITCH(Phik0shortanalysis, processRecMCClosurePhiK0S, "Process RecMC for MCClosure Phi-K0S Analysis", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiK0SMCClosure, "Process function for Phi-K0S Correlations in MCClosure", false); - void processRecMCClosurePhiPion(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, MCCollisions const&) + void processPhiPionMCClosure(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, MCCollisions const&, aod::McParticles const&) { if (!acceptEventQA(collision, false)) return; @@ -1366,62 +2094,112 @@ struct Phik0shortanalysis { // Loop over all primary pion candidates for (const auto& track : fullMCTracks) { + if (cfgisRecMCWPDGForClosure1) { + if (!track.has_mcParticle()) + continue; + auto mcTrack = track.mcParticle_as(); + if (std::abs(mcTrack.pdgCode()) != PDG_t::kPiPlus || !mcTrack.isPhysicalPrimary()) + continue; + } // Pion selection - if (!selectionPion(track)) + if (!selectionPion(track, true)) continue; - if (std::abs(track.rapidity(massPi)) > cfgYAcceptance) + if (std::abs(track.rapidity(massPi)) > deltaYConfigs.cfgYAcceptance) continue; - std::vector listrecPhi; - std::array counts{}; + std::vector listrecPhi; + std::vector counts(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); + std::vector weights(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 1); // Phi reconstruction for (const auto& track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + if (!selectionTrackResonance(track1, false) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection auto track1ID = track1.globalIndex(); for (const auto& track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + if (!selectionTrackResonance(track2, false) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); if (track2ID == track1ID) continue; // condition to avoid double counting of pair - TLorentzVector recPhi = recMother(track1, track2, massKa, massKa); + if (cfgisRecMCWPDGForClosure2) { + if (!track1.has_mcParticle()) + continue; + auto mcTrack1 = track1.mcParticle_as(); + if (mcTrack1.pdgCode() != PDG_t::kKPlus || !mcTrack1.isPhysicalPrimary()) + continue; + + if (!track2.has_mcParticle()) + continue; + auto mcTrack2 = track2.mcParticle_as(); + if (mcTrack2.pdgCode() != PDG_t::kKMinus || !mcTrack2.isPhysicalPrimary()) + continue; + + bool isMCMotherPhi = false; + for (const auto& motherOfMcTrack1 : mcTrack1.mothers_as()) { + for (const auto& motherOfMcTrack2 : mcTrack2.mothers_as()) { + if (motherOfMcTrack1.pdgCode() != motherOfMcTrack2.pdgCode()) + continue; + if (motherOfMcTrack1.globalIndex() != motherOfMcTrack2.globalIndex()) + continue; + if (motherOfMcTrack1.pdgCode() != o2::constants::physics::Pdg::kPhi) + continue; + isMCMotherPhi = true; + } + } + if (!isMCMotherPhi) + continue; + } + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) + continue; if (recPhi.M() < lowMPhi || recPhi.M() > upMPhi) continue; - - if (std::abs(recPhi.Rapidity()) > cfgYAcceptance) + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) continue; - listrecPhi.push_back(recPhi); + + double phiPurity{}; + if (fillMethodSingleWeight) + phiPurity = getPhiPurity(genmultiplicity, recPhi); + + if (fillMethodMultipleWeights) + listrecPhi.push_back(recPhi); + counts.at(0)++; - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgFCutOnDeltaY) - continue; - counts.at(1)++; - if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > cfgSCutOnDeltaY) - continue; - counts.at(2)++; + weights.at(0) *= (1 - phiPurity); + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(track.rapidity(massPi) - recPhi.Rapidity()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + counts.at(i + 1)++; + weights.at(i + 1) *= (1 - phiPurity); + } } } - std::array weights{}; - for (unsigned int i = 0; i < counts.size(); i++) { - weights.at(i) = (counts.at(i) > 0 ? 1. / static_cast(counts.at(i)) : 0); + if (fillMethodMultipleWeights) { + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + weights.at(i) = (counts.at(i) > 0 ? 1. / static_cast(counts.at(i)) : 0); + } + fillInvMassNSigma(track, listrecPhi, genmultiplicity, weights); + } else if (fillMethodSingleWeight) { + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + weights.at(i) = (counts.at(i) > 0 ? 1 - weights.at(i) : 0); + } + fillNSigma(track, genmultiplicity, weights); } - - fillInvMassNSigma(track, listrecPhi, genmultiplicity, weights); } } - PROCESS_SWITCH(Phik0shortanalysis, processRecMCClosurePhiPion, "Process RecMC for MCClosure Phi-Pion Analysis", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiPionMCClosure, "Process function for Phi-Pion Correlations in MCClosure", false); - void processGenMCPhiQA(MCCollisions::iterator const& mcCollision, soa::SmallGroups const& collisions, aod::McParticles const& mcParticles) + void processPhiMCGen(MCCollisions::iterator const& mcCollision, soa::SmallGroups const& collisions, aod::McParticles const& mcParticles) { mcEventHist.fill(HIST("hGenMCEventSelection"), 0); // all collisions if (std::abs(mcCollision.posZ()) > cutZVertex) @@ -1446,21 +2224,21 @@ struct Phik0shortanalysis { bool isCountedPhi = false; for (const auto& mcParticle1 : mcParticles) { - if (mcParticle1.pdgCode() != 333) + if (mcParticle1.pdgCode() != o2::constants::physics::Pdg::kPhi) continue; auto kDaughters = mcParticle1.daughters_as(); if (kDaughters.size() != 2) continue; bool isPosKaon = false, isNegKaon = false; for (const auto& kDaughter : kDaughters) { - if (kDaughter.pdgCode() == 321) + if (kDaughter.pdgCode() == PDG_t::kKPlus) isPosKaon = true; - if (kDaughter.pdgCode() == -321) + if (kDaughter.pdgCode() == PDG_t::kKMinus) isNegKaon = true; } if (!isPosKaon || !isNegKaon) continue; - if (std::abs(mcParticle1.y()) > cfgYAcceptance) + if (std::abs(mcParticle1.y()) > deltaYConfigs.cfgYAcceptance) continue; if (!isCountedPhi) { @@ -1477,24 +2255,12 @@ struct Phik0shortanalysis { std::array isCountedK0S = {false, false, false}; for (const auto& mcParticle2 : mcParticles) { - if (mcParticle2.pdgCode() != 310) + if (mcParticle2.pdgCode() != PDG_t::kK0Short) continue; if (!mcParticle2.isPhysicalPrimary()) continue; - auto kDaughters2 = mcParticle2.daughters_as(); - if (kDaughters2.size() != 2) - continue; - bool isPosPion = false, isNegPion = false; - for (const auto& kDaughter2 : kDaughters2) { - if (kDaughter2.pdgCode() == 211) - isPosPion = true; - if (kDaughter2.pdgCode() == -211) - isNegPion = true; - } - if (!isPosPion || !isNegPion) - continue; - if (std::abs(mcParticle2.y()) > cfgYAcceptance) + if (std::abs(mcParticle2.y()) > deltaYConfigs.cfgYAcceptance) continue; if (!isCountedK0S.at(0)) { mcPhiHist.fill(HIST("h2PhieffK0SGenMCInc"), genmultiplicity, mcParticle2.pt()); @@ -1502,7 +2268,7 @@ struct Phik0shortanalysis { mcPhiHist.fill(HIST("h2PhieffK0SGenMCFCutAssocReco"), genmultiplicity, mcParticle2.pt()); isCountedK0S.at(0) = true; } - if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgFCutOnDeltaY) + if (std::abs(mcParticle1.y() - mcParticle2.y()) > deltaYConfigs.cfgFCutOnDeltaY) continue; if (!isCountedK0S.at(1)) { mcPhiHist.fill(HIST("h2PhieffK0SGenMCFCut"), genmultiplicity, mcParticle2.pt()); @@ -1510,7 +2276,7 @@ struct Phik0shortanalysis { mcPhiHist.fill(HIST("h2PhieffK0SGenMCFCutAssocReco"), genmultiplicity, mcParticle2.pt()); isCountedK0S.at(1) = true; } - if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgSCutOnDeltaY) + if (std::abs(mcParticle1.y() - mcParticle2.y()) > deltaYConfigs.cfgSCutOnDeltaY) continue; if (!isCountedK0S.at(2)) { mcPhiHist.fill(HIST("h2PhieffK0SGenMCSCut"), genmultiplicity, mcParticle2.pt()); @@ -1523,12 +2289,12 @@ struct Phik0shortanalysis { std::array isCountedPi = {false, false, false}; for (const auto& mcParticle2 : mcParticles) { - if (std::abs(mcParticle2.pdgCode()) != 211) + if (std::abs(mcParticle2.pdgCode()) != PDG_t::kPiPlus) continue; if (!mcParticle2.isPhysicalPrimary()) continue; - if (std::abs(mcParticle2.y()) > cfgYAcceptance) + if (std::abs(mcParticle2.y()) > deltaYConfigs.cfgYAcceptance) continue; if (!isCountedPi.at(0)) { mcPhiHist.fill(HIST("h2PhieffPiGenMCInc"), genmultiplicity, mcParticle2.pt()); @@ -1536,7 +2302,7 @@ struct Phik0shortanalysis { mcPhiHist.fill(HIST("h2PhieffPiGenMCIncAssocReco"), genmultiplicity, mcParticle2.pt()); isCountedPi.at(0) = true; } - if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgFCutOnDeltaY) + if (std::abs(mcParticle1.y() - mcParticle2.y()) > deltaYConfigs.cfgFCutOnDeltaY) continue; if (!isCountedPi.at(1)) { mcPhiHist.fill(HIST("h2PhieffPiGenMCFCut"), genmultiplicity, mcParticle2.pt()); @@ -1544,7 +2310,7 @@ struct Phik0shortanalysis { mcPhiHist.fill(HIST("h2PhieffPiGenMCFCutAssocReco"), genmultiplicity, mcParticle2.pt()); isCountedPi.at(1) = true; } - if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgSCutOnDeltaY) + if (std::abs(mcParticle1.y() - mcParticle2.y()) > deltaYConfigs.cfgSCutOnDeltaY) continue; if (!isCountedPi.at(2)) { mcPhiHist.fill(HIST("h2PhieffPiGenMCSCut"), genmultiplicity, mcParticle2.pt()); @@ -1556,9 +2322,9 @@ struct Phik0shortanalysis { } } - PROCESS_SWITCH(Phik0shortanalysis, processGenMCPhiQA, "Process for ReCMCQA and Phi in RecMC", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiMCGen, "Process function for Phi in MCGen (to be removed)", false); - void processGenMCPhiK0S(MCCollisions::iterator const& mcCollision, soa::SmallGroups const& collisions, aod::McParticles const& mcParticles) + void processPhiK0SMCGen(MCCollisions::iterator const& mcCollision, soa::SmallGroups const& collisions, aod::McParticles const& mcParticles) { if (std::abs(mcCollision.posZ()) > cutZVertex) return; @@ -1577,66 +2343,65 @@ struct Phik0shortanalysis { mcEventHist.fill(HIST("hGenMCMultiplicityPercent"), genmultiplicity); for (const auto& mcParticle1 : mcParticles) { - if (mcParticle1.pdgCode() != 310) + if (mcParticle1.pdgCode() != PDG_t::kK0Short) continue; - if (!mcParticle1.isPhysicalPrimary()) + if (!mcParticle1.isPhysicalPrimary() || mcParticle1.pt() < v0Configs.v0SettingMinPt) continue; - auto kDaughters1 = mcParticle1.daughters_as(); - if (kDaughters1.size() != 2) - continue; - bool isPosPion = false, isNegPion = false; - for (const auto& kDaughter1 : kDaughters1) { - if (kDaughter1.pdgCode() == 211) - isPosPion = true; - if (kDaughter1.pdgCode() == -211) - isNegPion = true; - } - if (!isPosPion || !isNegPion) - continue; - if (std::abs(mcParticle1.y()) > cfgYAcceptance) + + mcK0SHist.fill(HIST("h3K0SRapidityGenMC"), genmultiplicity, mcParticle1.pt(), mcParticle1.y()); + + if (std::abs(mcParticle1.y()) > deltaYConfigs.cfgYAcceptance) continue; - mcK0SHist.fill(HIST("h2K0SGenMC"), genmultiplicity, mcParticle1.pt()); + mcK0SHist.fill(HIST("h2K0SMCGen"), genmultiplicity, mcParticle1.pt()); if (isAssocColl) - mcK0SHist.fill(HIST("h2K0SGenMCAssocReco"), genmultiplicity, mcParticle1.pt()); + mcK0SHist.fill(HIST("h2K0SMCGenAssocReco"), genmultiplicity, mcParticle1.pt()); - std::array isCountedPhi = {false, false, false}; + std::vector counts(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); for (const auto& mcParticle2 : mcParticles) { - if (mcParticle2.pdgCode() != 333) + if (mcParticle2.pdgCode() != o2::constants::physics::Pdg::kPhi) continue; - - if (std::abs(mcParticle2.y()) > cfgYAcceptance) - continue; - if (!isCountedPhi.at(0)) { - mcPhiK0SHist.fill(HIST("h2PhiK0SGenMCInc"), genmultiplicity, mcParticle1.pt()); - if (isAssocColl) - mcPhiK0SHist.fill(HIST("h2PhiK0SGenMCIncAssocReco"), genmultiplicity, mcParticle1.pt()); - isCountedPhi.at(0) = true; + if (cfgisGenMCForClosure) { + auto kDaughters = mcParticle2.daughters_as(); + if (kDaughters.size() != 2) + continue; + bool isPosKaon = false, isNegKaon = false; + for (const auto& kDaughter : kDaughters) { + if (kDaughter.pdgCode() == PDG_t::kKPlus) + isPosKaon = true; + if (kDaughter.pdgCode() == PDG_t::kKMinus) + isNegKaon = true; + } + if (!isPosKaon || !isNegKaon) + continue; } - if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgFCutOnDeltaY) + if (mcParticle2.pt() < minPhiPt || mcParticle2.pt() > maxPhiPt) continue; - if (!isCountedPhi.at(1)) { - mcPhiK0SHist.fill(HIST("h2PhiK0SGenMCFCut"), genmultiplicity, mcParticle1.pt()); - if (isAssocColl) - mcPhiK0SHist.fill(HIST("h2PhiK0SGenMCFCutAssocReco"), genmultiplicity, mcParticle1.pt()); - isCountedPhi.at(1) = true; - } - if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgSCutOnDeltaY) + if (std::abs(mcParticle2.y()) > deltaYConfigs.cfgYAcceptance) continue; - if (!isCountedPhi.at(2)) { - mcPhiK0SHist.fill(HIST("h2PhiK0SGenMCSCut"), genmultiplicity, mcParticle1.pt()); + + counts.at(0)++; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(mcParticle1.y() - mcParticle2.y()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + counts.at(i + 1)++; + } + } + + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + if (counts.at(i) > 0) { + mcPhiK0SHist.fill(HIST("h3PhiK0SMCGen"), i, genmultiplicity, mcParticle1.pt()); if (isAssocColl) - mcPhiK0SHist.fill(HIST("h2PhiK0SGenMCSCutAssocReco"), genmultiplicity, mcParticle1.pt()); - isCountedPhi.at(2) = true; + mcPhiK0SHist.fill(HIST("h3PhiK0SMCGenAssocReco"), i, genmultiplicity, mcParticle1.pt()); } } } } - PROCESS_SWITCH(Phik0shortanalysis, processGenMCPhiK0S, "Process GenMC for Phi-K0S Analysis", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiK0SMCGen, "Process function for Phi-K0S Correlations Efficiency correction in MCGen", false); - void processGenMCPhiPion(MCCollisions::iterator const& mcCollision, soa::SmallGroups const& collisions, aod::McParticles const& mcParticles) + void processPhiPionMCGen(MCCollisions::iterator const& mcCollision, soa::SmallGroups const& collisions, aod::McParticles const& mcParticles) { if (std::abs(mcCollision.posZ()) > cutZVertex) return; @@ -1655,52 +2420,791 @@ struct Phik0shortanalysis { mcEventHist.fill(HIST("hGenMCMultiplicityPercent"), genmultiplicity); for (const auto& mcParticle1 : mcParticles) { - if (std::abs(mcParticle1.pdgCode()) != 211) + if (std::abs(mcParticle1.pdgCode()) != PDG_t::kPiPlus) continue; - if (!mcParticle1.isPhysicalPrimary()) + if (!mcParticle1.isPhysicalPrimary() || mcParticle1.pt() < trackConfigs.cMinPionPtcut) continue; - if (std::abs(mcParticle1.y()) > cfgYAcceptance) + + mcPionHist.fill(HIST("h3PiRapidityGenMC"), genmultiplicity, mcParticle1.pt(), mcParticle1.y()); + + if (std::abs(mcParticle1.y()) > deltaYConfigs.cfgYAcceptance) continue; - mcPionHist.fill(HIST("h2PiGenMC"), genmultiplicity, mcParticle1.pt()); + mcPionHist.fill(HIST("h2PiMCGen"), genmultiplicity, mcParticle1.pt()); if (isAssocColl) - mcPionHist.fill(HIST("h2PiGenMCAssocReco"), genmultiplicity, mcParticle1.pt()); + mcPionHist.fill(HIST("h2PiMCGenAssocReco"), genmultiplicity, mcParticle1.pt()); - std::array isCountedPhi = {false, false, false}; + std::vector counts(deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1, 0); for (const auto& mcParticle2 : mcParticles) { - if (mcParticle2.pdgCode() != 333) + if (mcParticle2.pdgCode() != o2::constants::physics::Pdg::kPhi) continue; - - if (std::abs(mcParticle2.y()) > cfgYAcceptance) + if (cfgisGenMCForClosure) { + auto kDaughters = mcParticle2.daughters_as(); + if (kDaughters.size() != 2) + continue; + bool isPosKaon = false, isNegKaon = false; + for (const auto& kDaughter : kDaughters) { + if (kDaughter.pdgCode() == PDG_t::kKPlus) + isPosKaon = true; + if (kDaughter.pdgCode() == PDG_t::kKMinus) + isNegKaon = true; + } + if (!isPosKaon || !isNegKaon) + continue; + } + if (mcParticle2.pt() < minPhiPt || mcParticle2.pt() > maxPhiPt) continue; - if (!isCountedPhi.at(0)) { - mcPhiPionHist.fill(HIST("h2PhiPiGenMCInc"), genmultiplicity, mcParticle1.pt()); + if (std::abs(mcParticle2.y()) > deltaYConfigs.cfgYAcceptance) + continue; + + counts.at(0)++; + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size(); i++) { + if (std::abs(mcParticle1.y() - mcParticle2.y()) > deltaYConfigs.cfgDeltaYAcceptanceBins->at(i)) + continue; + counts.at(i + 1)++; + } + } + + for (size_t i = 0; i < deltaYConfigs.cfgDeltaYAcceptanceBins->size() + 1; i++) { + if (counts.at(i) > 0) { + mcPhiPionHist.fill(HIST("h3PhiPiMCGen"), i, genmultiplicity, mcParticle1.pt()); if (isAssocColl) - mcPhiPionHist.fill(HIST("h2PhiPiGenMCIncAssocReco"), genmultiplicity, mcParticle1.pt()); - isCountedPhi.at(0) = true; + mcPhiPionHist.fill(HIST("h3PhiPiMCGenAssocReco"), i, genmultiplicity, mcParticle1.pt()); + } + } + } + } + + PROCESS_SWITCH(Phik0shortanalysis, processPhiPionMCGen, "Process function for Phi-Pion Correlations Efficiency correction in MCGen", false); + + // dN/deta procedure + void processdNdetaWPhiData(SelCollisions::iterator const& collision, FilteredTracks const& filteredTracks) + { + // Check if the event selection is passed + if (!acceptEventQA(collision, true)) + return; + + auto posThisColl = posFiltTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto negThisColl = negFiltTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + // Check if the event contains a phi candidate + if (!eventHasPhi(posThisColl, negThisColl)) + return; + + dataEventHist.fill(HIST("hMultiplicityPercent"), collision.centFT0M()); + dataEventHist.fill(HIST("h2VertexZvsMult"), collision.posZ(), collision.centFT0M()); + + for (const auto& track : filteredTracks) { + if (trackConfigs.applyExtraPhiCuts && ((track.phi() > trackConfigs.extraPhiCuts->at(0) && track.phi() < trackConfigs.extraPhiCuts->at(1)) || + track.phi() <= trackConfigs.extraPhiCuts->at(2) || track.phi() >= trackConfigs.extraPhiCuts->at(3))) + continue; + + dataEventHist.fill(HIST("h5EtaDistribution"), collision.posZ(), collision.centFT0M(), track.eta(), track.phi(), kGlobalplusITSonly); + if (track.hasTPC()) { + dataEventHist.fill(HIST("h5EtaDistribution"), collision.posZ(), collision.centFT0M(), track.eta(), track.phi(), kGlobalonly); + } else { + dataEventHist.fill(HIST("h5EtaDistribution"), collision.posZ(), collision.centFT0M(), track.eta(), track.phi(), kITSonly); + } + } + } + + PROCESS_SWITCH(Phik0shortanalysis, processdNdetaWPhiData, "Process function for dN/deta values in Data", false); + + void processdNdetaWPhiMCReco(SimCollisions::iterator const& collision, FilteredMCTracks const& filteredMCTracks, MCCollisions const&, aod::McParticles const& mcParticles) + { + if (!acceptEventQA(collision, true)) + return; + if (!collision.has_mcCollision()) + return; + + const auto& mcCollision = collision.mcCollision_as(); + auto mcParticlesThisColl = mcParticles.sliceBy(preslices.perMCColl, mcCollision.globalIndex()); + + if (furtherCheckonMcCollision && (std::abs(mcCollision.posZ()) > cutZVertex || !pwglf::isINELgtNmc(mcParticlesThisColl, 0, pdgDB))) + return; + if (filterOnMcPhi && !eventHasMCPhi(mcParticlesThisColl)) + return; + + mcEventHist.fill(HIST("hRecoMCMultiplicityPercent"), mcCollision.centFT0M()); + mcEventHist.fill(HIST("h2RecoMCVertexZvsMult"), collision.posZ(), mcCollision.centFT0M()); + + for (const auto& track : filteredMCTracks) { + if (trackConfigs.applyExtraPhiCuts && ((track.phi() > trackConfigs.extraPhiCuts->at(0) && track.phi() < trackConfigs.extraPhiCuts->at(1)) || + track.phi() <= trackConfigs.extraPhiCuts->at(2) || track.phi() >= trackConfigs.extraPhiCuts->at(3))) + continue; + if (!track.has_mcParticle()) + continue; + + auto mcTrack = track.mcParticle_as(); + if (!mcTrack.isPhysicalPrimary() || std::abs(mcTrack.eta()) > trackConfigs.etaMax) + continue; + + mcEventHist.fill(HIST("h6RecoMCEtaDistribution"), collision.posZ(), mcCollision.centFT0M(), mcTrack.eta(), mcTrack.phi(), kSpAll, kGlobalplusITSonly); + if (track.hasTPC()) { + mcEventHist.fill(HIST("h6RecoMCEtaDistribution"), collision.posZ(), mcCollision.centFT0M(), mcTrack.eta(), mcTrack.phi(), kSpAll, kGlobalonly); + } else { + mcEventHist.fill(HIST("h6RecoMCEtaDistribution"), collision.posZ(), mcCollision.centFT0M(), mcTrack.eta(), mcTrack.phi(), kSpAll, kITSonly); + } + + int pid = fromPDGToEnum(mcTrack.pdgCode()); + mcEventHist.fill(HIST("h6RecoMCEtaDistribution"), collision.posZ(), mcCollision.centFT0M(), mcTrack.eta(), mcTrack.phi(), pid, kGlobalplusITSonly); + } + + for (const auto& mcParticle : mcParticlesThisColl) { + if (!isGenParticleCharged(mcParticle)) + continue; + + mcEventHist.fill(HIST("h6GenMCEtaDistributionReco"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kNoGenpTVar); + if (mcParticle.pt() < trackConfigs.cMinChargedParticlePtcut) { + mcEventHist.fill(HIST("h6GenMCEtaDistributionReco"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kGenpTup, -10.0f * mcParticle.pt() + 2.0f); + mcEventHist.fill(HIST("h6GenMCEtaDistributionReco"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kGenpTdown, 5.0f * mcParticle.pt() + 0.5f); + } else { + mcEventHist.fill(HIST("h6GenMCEtaDistributionReco"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kGenpTup); + mcEventHist.fill(HIST("h6GenMCEtaDistributionReco"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kGenpTdown); + } + + int pid = fromPDGToEnum(mcParticle.pdgCode()); + mcEventHist.fill(HIST("h6GenMCEtaDistributionReco"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), pid, kNoGenpTVar); + } + } + + PROCESS_SWITCH(Phik0shortanalysis, processdNdetaWPhiMCReco, "Process function for dN/deta values in MCReco", false); + + void processdNdetaWPhiMCGen(MCCollisions::iterator const& mcCollision, soa::SmallGroups const& collisions, FilteredMCTracks const& filteredMCTracks, aod::McParticles const& mcParticles) + { + if (std::abs(mcCollision.posZ()) > cutZVertex) + return; + if (!pwglf::isINELgtNmc(mcParticles, 0, pdgDB)) + return; + if (filterOnMcPhi && !eventHasMCPhi(mcParticles)) + return; + + uint64_t numberAssocColl = 0; + for (const auto& collision : collisions) { + if (acceptEventQA(collision, false)) { + mcEventHist.fill(HIST("hGenMCRecoMultiplicityPercent"), mcCollision.centFT0M()); + mcEventHist.fill(HIST("h2GenMCRecoVertexZvsMult"), collision.posZ(), mcCollision.centFT0M()); + + auto filteredMCTracksThisColl = filteredMCTracks.sliceBy(preslices.perColl, collision.globalIndex()); + for (const auto& track : filteredMCTracksThisColl) { + if (trackConfigs.applyExtraPhiCuts && ((track.phi() > trackConfigs.extraPhiCuts->at(0) && track.phi() < trackConfigs.extraPhiCuts->at(1)) || + track.phi() <= trackConfigs.extraPhiCuts->at(2) || track.phi() >= trackConfigs.extraPhiCuts->at(3))) + continue; + if (!track.has_mcParticle()) + continue; + + auto mcTrack = track.mcParticle(); + if (!mcTrack.isPhysicalPrimary() || std::abs(mcTrack.eta()) > trackConfigs.etaMax) + continue; + + mcEventHist.fill(HIST("h6RecoCheckMCEtaDistribution"), collision.posZ(), mcCollision.centFT0M(), mcTrack.eta(), mcTrack.phi(), kSpAll, kGlobalplusITSonly); + if (track.hasTPC()) { + mcEventHist.fill(HIST("h6RecoCheckMCEtaDistribution"), collision.posZ(), mcCollision.centFT0M(), mcTrack.eta(), mcTrack.phi(), kSpAll, kGlobalonly); + } else { + mcEventHist.fill(HIST("h6RecoCheckMCEtaDistribution"), collision.posZ(), mcCollision.centFT0M(), mcTrack.eta(), mcTrack.phi(), kSpAll, kITSonly); + } + + int pid = fromPDGToEnum(mcTrack.pdgCode()); + mcEventHist.fill(HIST("h6RecoCheckMCEtaDistribution"), collision.posZ(), mcCollision.centFT0M(), mcTrack.eta(), mcTrack.phi(), pid, kGlobalplusITSonly); } - if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgFCutOnDeltaY) + + for (const auto& mcParticle : mcParticles) { + if (!isGenParticleCharged(mcParticle)) + continue; + + mcEventHist.fill(HIST("h6GenMCEtaDistributionRecoCheck"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kNoGenpTVar); + if (mcParticle.pt() < trackConfigs.cMinChargedParticlePtcut) { + mcEventHist.fill(HIST("h6GenMCEtaDistributionRecoCheck"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kGenpTup, -10.0f * mcParticle.pt() + 2.0f); + mcEventHist.fill(HIST("h6GenMCEtaDistributionRecoCheck"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kGenpTdown, 5.0f * mcParticle.pt() + 0.5f); + } else { + mcEventHist.fill(HIST("h6GenMCEtaDistributionRecoCheck"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kGenpTup); + mcEventHist.fill(HIST("h6GenMCEtaDistributionRecoCheck"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), kSpAll, kGenpTdown); + } + + int pid = fromPDGToEnum(mcParticle.pdgCode()); + mcEventHist.fill(HIST("h6GenMCEtaDistributionRecoCheck"), collision.posZ(), mcCollision.centFT0M(), mcParticle.eta(), mcParticle.phi(), pid, kNoGenpTVar); + } + + numberAssocColl++; + } + } + + mcEventHist.fill(HIST("hGenMCMultiplicityPercent"), mcCollision.centFT0M()); + if (numberAssocColl > 0) + mcEventHist.fill(HIST("hGenMCAssocRecoMultiplicityPercent"), mcCollision.centFT0M()); + + for (const auto& mcParticle : mcParticles) { + if (!isGenParticleCharged(mcParticle)) + continue; + + mcEventHist.fill(HIST("h2GenMCEtaDistribution"), mcCollision.centFT0M(), mcParticle.eta()); + if (numberAssocColl > 0) + mcEventHist.fill(HIST("h2GenMCEtaDistributionAssocReco"), mcCollision.centFT0M(), mcParticle.eta()); + } + } + + PROCESS_SWITCH(Phik0shortanalysis, processdNdetaWPhiMCGen, "Process function for dN/deta values in MCGen", false); + + // New 2D analysis procedure + void processPhiK0SPionData2D(SelCollisions::iterator const& collision, FullTracks const& fullTracks, FullV0s const& V0s, V0DauTracks const&) + { + // Check if the event selection is passed + if (!acceptEventQA(collision, true)) + return; + + float multiplicity = collision.centFT0M(); + dataEventHist.fill(HIST("hMultiplicityPercent"), multiplicity); + + // Defining positive and negative tracks for phi reconstruction + auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + bool isCountedPhi = false; + bool isFilledhV0 = false; + + // Loop over all positive tracks + for (const auto& track1 : posThisColl) { + if (!selectionTrackResonance(track1, true) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + dataPhiHist.fill(HIST("hEta"), track1.eta()); + dataPhiHist.fill(HIST("hNsigmaKaonTPC"), track1.tpcInnerParam(), track1.tpcNSigmaKa()); + dataPhiHist.fill(HIST("hNsigmaKaonTOF"), track1.tpcInnerParam(), track1.tofNSigmaKa()); + + auto track1ID = track1.globalIndex(); + + // Loop over all negative tracks + for (const auto& track2 : negThisColl) { + if (!selectionTrackResonance(track2, true) || !selectionPIDKaonpTdependent(track2)) + continue; // topological and PID selection + + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) + continue; // condition to avoid double counting of pair + + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) continue; - if (!isCountedPhi.at(1)) { - mcPhiPionHist.fill(HIST("h2PhiPiGenMCFCut"), genmultiplicity, mcParticle1.pt()); - if (isAssocColl) - mcPhiPionHist.fill(HIST("h2PhiPiGenMCFCutAssocReco"), genmultiplicity, mcParticle1.pt()); - isCountedPhi.at(1) = true; + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) + continue; + + if (!isCountedPhi) { + dataEventHist.fill(HIST("hEventSelection"), 4); // at least a Phi candidate in the event + dataEventHist.fill(HIST("hMultiplicityPercentWithPhi"), multiplicity); + isCountedPhi = true; + } + + float efficiencyPhi = 1.0f; + if (applyEfficiency) { + efficiencyPhi = effMapPhi->Interpolate(multiplicity, recPhi.Pt(), recPhi.Rapidity()); + if (efficiencyPhi == 0) + efficiencyPhi = 1.0f; + } + float weightPhi = applyEfficiency ? 1.0f / efficiencyPhi : 1.0f; + dataPhiHist.fill(HIST("h3PhiDataNewProc"), multiplicity, recPhi.Pt(), recPhi.M(), weightPhi); + + // V0 already reconstructed by the builder + for (const auto& v0 : V0s) { + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + + // Cut on V0 dynamic columns + if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) + continue; + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision)) + continue; + + if (!isFilledhV0) { + dataK0SHist.fill(HIST("hDCAV0Daughters"), v0.dcaV0daughters()); + dataK0SHist.fill(HIST("hV0CosPA"), v0.v0cosPA()); + + // Filling the PID of the V0 daughters in the region of the K0 peak + if (lowMK0S < v0.mK0Short() && v0.mK0Short() < upMK0S) { + dataK0SHist.fill(HIST("hNSigmaPosPionFromK0S"), posDaughterTrack.tpcInnerParam(), posDaughterTrack.tpcNSigmaPi()); + dataK0SHist.fill(HIST("hNSigmaNegPionFromK0S"), negDaughterTrack.tpcInnerParam(), negDaughterTrack.tpcNSigmaPi()); + } + } + + if (std::abs(v0.yK0Short()) > deltaYConfigs.cfgYAcceptance) + continue; + + float efficiencyPhiK0S = 1.0f; + if (applyEfficiency) { + efficiencyPhiK0S = effMapPhi->Interpolate(multiplicity, recPhi.Pt(), recPhi.Rapidity()) * effMapK0S->Interpolate(multiplicity, v0.pt(), v0.yK0Short()); + if (efficiencyPhiK0S == 0) + efficiencyPhiK0S = 1.0f; + } + float weightPhiK0S = applyEfficiency ? 1.0f / efficiencyPhiK0S : 1.0f; + dataPhiK0SHist.fill(HIST("h5PhiK0SDataNewProc"), v0.yK0Short() - recPhi.Rapidity(), multiplicity, v0.pt(), v0.mK0Short(), recPhi.M(), weightPhiK0S); + } + + isFilledhV0 = true; + + // Loop over all primary pion candidates + for (const auto& track : fullTracks) { + if (!selectionPion(track, false)) + continue; + + if (std::abs(track.rapidity(massPi)) > deltaYConfigs.cfgYAcceptance) + continue; + + float efficiencyPhiPion = 1.0f; + if (applyEfficiency) { + efficiencyPhiPion = track.pt() < trackConfigs.pTToUseTOF ? effMapPhi->Interpolate(multiplicity, recPhi.Pt(), recPhi.Rapidity()) * effMapPionTPC->Interpolate(multiplicity, track.pt(), track.rapidity(massPi)) : effMapPhi->Interpolate(multiplicity, recPhi.Pt(), recPhi.Rapidity()) * effMapPionTPCTOF->Interpolate(multiplicity, track.pt(), track.rapidity(massPi)); + if (efficiencyPhiPion == 0) + efficiencyPhiPion = 1.0f; + } + float weightPhiPion = applyEfficiency ? 1.0f / efficiencyPhiPion : 1.0f; + dataPhiPionHist.fill(HIST("h5PhiPiTPCDataNewProc"), track.rapidity(massPi) - recPhi.Rapidity(), multiplicity, track.pt(), track.tpcNSigmaPi(), recPhi.M(), weightPhiPion); + if (track.hasTOF()) + dataPhiPionHist.fill(HIST("h5PhiPiTOFDataNewProc"), track.rapidity(massPi) - recPhi.Rapidity(), multiplicity, track.pt(), track.tofNSigmaPi(), recPhi.M(), weightPhiPion); } - if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgSCutOnDeltaY) + } + } + } + + PROCESS_SWITCH(Phik0shortanalysis, processPhiK0SPionData2D, "Process function for Phi-K0S and Phi-Pion Correlations in Data2D", false); + + void processPhiK0SPionMCClosure2D(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, FullMCV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const&) + { + if (!acceptEventQA(collision, true)) + return; + + if (!collision.has_mcCollision()) + return; + mcEventHist.fill(HIST("hRecMCEventSelection"), 6); // with at least a gen collision + + const auto& mcCollision = collision.mcCollision_as(); + float genmultiplicity = mcCollision.centFT0M(); + mcEventHist.fill(HIST("hRecoMCMultiplicityPercent"), genmultiplicity); + + // Defining positive and negative tracks for phi reconstruction + auto posThisColl = posMCTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto negThisColl = negMCTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + bool isCountedPhi = false; + + // Loop over all positive tracks + for (const auto& track1 : posThisColl) { + if (!selectionTrackResonance(track1, true) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + auto track1ID = track1.globalIndex(); + + // Loop over all negative tracks + for (const auto& track2 : negThisColl) { + if (!selectionTrackResonance(track2, true) || !selectionPIDKaonpTdependent(track2)) + continue; // topological and PID selection + + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) + continue; // condition to avoid double counting of pair + + ROOT::Math::PxPyPzMVector recPhi = recMother(track1, track2, massKa, massKa); + if (recPhi.Pt() < minPhiPt || recPhi.Pt() > maxPhiPt) continue; - if (!isCountedPhi.at(2)) { - mcPhiPionHist.fill(HIST("h2PhiPiGenMCSCut"), genmultiplicity, mcParticle1.pt()); - if (isAssocColl) - mcPhiPionHist.fill(HIST("h2PhiPiGenMCSCutAssocReco"), genmultiplicity, mcParticle1.pt()); - isCountedPhi.at(2) = true; + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) + continue; + + if (!isCountedPhi) { + mcEventHist.fill(HIST("hRecMCEventSelection"), 7); // at least a Phi candidate in the event + mcEventHist.fill(HIST("hRecoMCMultiplicityPercentWithPhi"), genmultiplicity); + isCountedPhi = true; + } + + float efficiencyPhi = 1.0f; + if (applyEfficiency) { + efficiencyPhi = effMapPhi->Interpolate(genmultiplicity, recPhi.Pt(), recPhi.Rapidity()); + if (efficiencyPhi == 0) + efficiencyPhi = 1.0f; + } + float weightPhi = applyEfficiency ? 1.0f / efficiencyPhi : 1.0f; + closureMCPhiHist.fill(HIST("h3PhiMCClosureNewProc"), genmultiplicity, recPhi.Pt(), recPhi.M(), weightPhi); + + // V0 already reconstructed by the builder + for (const auto& v0 : V0s) { + if (cfgisRecMCWPDGForClosure1) { + if (!v0.has_mcParticle()) + continue; + auto v0mcparticle = v0.mcParticle(); + if (v0mcparticle.pdgCode() != PDG_t::kK0Short || !v0mcparticle.isPhysicalPrimary()) + continue; + } + + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + + if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) + continue; + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision)) + continue; + + if (std::abs(v0.yK0Short()) > deltaYConfigs.cfgYAcceptance) + continue; + + float efficiencyPhiK0S = 1.0f; + if (applyEfficiency) { + efficiencyPhiK0S = effMapPhi->Interpolate(genmultiplicity, recPhi.Pt(), recPhi.Rapidity()) * effMapK0S->Interpolate(genmultiplicity, v0.pt(), v0.yK0Short()); + if (efficiencyPhiK0S == 0) + efficiencyPhiK0S = 1.0f; + } + float weightPhiK0S = applyEfficiency ? 1.0f / efficiencyPhiK0S : 1.0f; + closureMCPhiK0SHist.fill(HIST("h5PhiK0SMCClosureNewProc"), v0.yK0Short() - recPhi.Rapidity(), genmultiplicity, v0.pt(), v0.mK0Short(), recPhi.M(), weightPhiK0S); + } + + // Loop over all primary pion candidates + for (const auto& track : fullMCTracks) { + if (cfgisRecMCWPDGForClosure1) { + if (!track.has_mcParticle()) + continue; + auto mcTrack = track.mcParticle_as(); + if (std::abs(mcTrack.pdgCode()) != PDG_t::kPiPlus || !mcTrack.isPhysicalPrimary()) + continue; + } + + if (!selectionPion(track, false)) + continue; + + if (std::abs(track.rapidity(massPi)) > deltaYConfigs.cfgYAcceptance) + continue; + + float efficiencyPhiPion = 1.0f; + if (applyEfficiency) { + efficiencyPhiPion = track.pt() < trackConfigs.pTToUseTOF ? effMapPhi->Interpolate(genmultiplicity, recPhi.Pt(), recPhi.Rapidity()) * effMapPionTPC->Interpolate(genmultiplicity, track.pt(), track.rapidity(massPi)) : effMapPhi->Interpolate(genmultiplicity, recPhi.Pt(), recPhi.Rapidity()) * effMapPionTPCTOF->Interpolate(genmultiplicity, track.pt(), track.rapidity(massPi)); + if (efficiencyPhiPion == 0) + efficiencyPhiPion = 1.0f; + } + float weightPhiPion = applyEfficiency ? 1.0f / efficiencyPhiPion : 1.0f; + closureMCPhiPionHist.fill(HIST("h5PhiPiTPCMCClosureNewProc"), track.rapidity(massPi) - recPhi.Rapidity(), genmultiplicity, track.pt(), track.tpcNSigmaPi(), recPhi.M(), weightPhiPion); + if (track.hasTOF()) + closureMCPhiPionHist.fill(HIST("h5PhiPiTOFMCClosureNewProc"), track.rapidity(massPi) - recPhi.Rapidity(), genmultiplicity, track.pt(), track.tofNSigmaPi(), recPhi.M(), weightPhiPion); + } + } + } + } + + PROCESS_SWITCH(Phik0shortanalysis, processPhiK0SPionMCClosure2D, "Process function for Phi-K0S and Phi-Pion Correlations in MCClosure2D", false); + + void processAllPartMCReco(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, FullMCV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const& mcParticles) + { + if (!acceptEventQA(collision, false)) + return; + + if (!collision.has_mcCollision()) + return; + + const auto& mcCollision = collision.mcCollision_as(); + float genmultiplicity = mcCollision.centFT0M(); + + // Defining positive and negative tracks for phi reconstruction + auto posThisColl = posMCTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto negThisColl = negMCTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + for (const auto& track1 : posThisColl) { // loop over all selected tracks + if (!selectionTrackResonance(track1, false) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + auto track1ID = track1.globalIndex(); + + if (!track1.has_mcParticle()) + continue; + auto mcTrack1 = track1.mcParticle_as(); + if (mcTrack1.pdgCode() != PDG_t::kKPlus || !mcTrack1.isPhysicalPrimary()) + continue; + + for (const auto& track2 : negThisColl) { + if (!selectionTrackResonance(track2, false) || !selectionPIDKaonpTdependent(track2)) + continue; // topological and PID selection + + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) + continue; // condition to avoid double counting of pair + + if (!track2.has_mcParticle()) + continue; + auto mcTrack2 = track2.mcParticle_as(); + if (mcTrack2.pdgCode() != PDG_t::kKMinus || !mcTrack2.isPhysicalPrimary()) + continue; + + float pTMother = -1.0f; + float yMother = -1.0f; + bool isMCMotherPhi = false; + for (const auto& motherOfMcTrack1 : mcTrack1.mothers_as()) { + for (const auto& motherOfMcTrack2 : mcTrack2.mothers_as()) { + if (motherOfMcTrack1.pdgCode() != motherOfMcTrack2.pdgCode()) + continue; + if (motherOfMcTrack1.globalIndex() != motherOfMcTrack2.globalIndex()) + continue; + if (motherOfMcTrack1.pdgCode() != o2::constants::physics::Pdg::kPhi) + continue; + + pTMother = motherOfMcTrack1.pt(); + yMother = motherOfMcTrack1.y(); + isMCMotherPhi = true; + } + } + + if (!isMCMotherPhi) + continue; + if (pTMother < minPhiPt || std::abs(yMother) > deltaYConfigs.cfgYAcceptance) + continue; + + mcPhiHist.fill(HIST("h3PhiMCRecoNewProc"), genmultiplicity, pTMother, yMother); + } + } + + for (const auto& v0 : V0s) { + if (!v0.has_mcParticle()) + continue; + + auto v0mcparticle = v0.mcParticle(); + if (v0mcparticle.pdgCode() != PDG_t::kK0Short || !v0mcparticle.isPhysicalPrimary()) + continue; + + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + + if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) + continue; + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision)) + continue; + if (std::abs(v0mcparticle.y()) > deltaYConfigs.cfgYAcceptance) + continue; + + mcK0SHist.fill(HIST("h3K0SMCRecoNewProc"), genmultiplicity, v0mcparticle.pt(), v0mcparticle.y()); + } + + for (const auto& track : fullMCTracks) { + // Pion selection + if (!selectionPion(track, false)) + continue; + + if (!track.has_mcParticle()) + continue; + + auto mcTrack = track.mcParticle_as(); + if (std::abs(mcTrack.pdgCode()) != PDG_t::kPiPlus) + continue; + + if (std::abs(mcTrack.y()) > deltaYConfigs.cfgYAcceptance) + continue; + + // Primary pion selection + if (mcTrack.isPhysicalPrimary()) { + mcPionHist.fill(HIST("h3RecMCDCAxyPrimPi"), track.pt(), track.dcaXY()); + } else { + if (mcTrack.getProcess() == 4) { // Selection of secondary pions from weak decay + mcPionHist.fill(HIST("h3RecMCDCAxySecWeakDecayPi"), track.pt(), track.dcaXY()); + } else { // Selection of secondary pions from material interactions + mcPionHist.fill(HIST("h3RecMCDCAxySecMaterialPi"), track.pt(), track.dcaXY()); + } + continue; + } + + mcPionHist.fill(HIST("h3PiMCRecoNewProc"), genmultiplicity, mcTrack.pt(), mcTrack.y()); + + if (track.pt() >= trackConfigs.pTToUseTOF && !track.hasTOF()) + continue; + + mcPionHist.fill(HIST("h3PiMCReco2NewProc"), genmultiplicity, mcTrack.pt(), mcTrack.y()); + } + + // Defining McParticles in the collision + auto mcParticlesThisColl = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + + for (const auto& mcParticle : mcParticlesThisColl) { + if (std::abs(mcParticle.y()) > deltaYConfigs.cfgYAcceptance) + continue; + + // Phi selection + if (mcParticle.pdgCode() == o2::constants::physics::Pdg::kPhi && mcParticle.pt() >= minPhiPt) + mcPhiHist.fill(HIST("h3PhiMCGenRecoCheckNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + + // K0S selection + if (mcParticle.pdgCode() == PDG_t::kK0Short && mcParticle.isPhysicalPrimary() && mcParticle.pt() >= v0Configs.v0SettingMinPt) + mcK0SHist.fill(HIST("h3K0SMCGenRecoCheckNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + + // Pion selection + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus && mcParticle.isPhysicalPrimary() && mcParticle.pt() >= trackConfigs.cMinPionPtcut) + mcPionHist.fill(HIST("h3PiMCGenRecoCheckNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + } + } + + PROCESS_SWITCH(Phik0shortanalysis, processAllPartMCReco, "Process function for all particles in MCReco", false); + + void processAllPartMCGen(MCCollisions::iterator const& mcCollision, soa::SmallGroups const& collisions, aod::McParticles const& mcParticles) + { + if (std::abs(mcCollision.posZ()) > cutZVertex) + return; + if (!pwglf::isINELgtNmc(mcParticles, 0, pdgDB)) + return; + + float genmultiplicity = mcCollision.centFT0M(); + + uint64_t numberAssocColl = 0; + for (const auto& collision : collisions) { + if (acceptEventQA(collision, false)) { + mcEventHist.fill(HIST("hGenMCRecoMultiplicityPercent"), genmultiplicity); // Event split numerator + + for (const auto& mcParticle : mcParticles) { + // The inclusive number of particles is the signal loss denominator, + // while the number of associated particles is the signal loss numerator + if (std::abs(mcParticle.y()) > deltaYConfigs.cfgYAcceptance) + continue; + + // Phi selection + if (mcParticle.pdgCode() == o2::constants::physics::Pdg::kPhi && mcParticle.pt() >= minPhiPt) + mcPhiHist.fill(HIST("h3PhiMCGenRecoNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + + // K0S selection + if (mcParticle.pdgCode() == PDG_t::kK0Short && mcParticle.isPhysicalPrimary() && mcParticle.pt() >= v0Configs.v0SettingMinPt) + mcK0SHist.fill(HIST("h3K0SMCGenRecoNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + + // Pion selection + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus && mcParticle.isPhysicalPrimary() && mcParticle.pt() >= trackConfigs.cMinPionPtcut) + mcPionHist.fill(HIST("h3PiMCGenRecoNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + } + + numberAssocColl++; + } + } + + // The inclusive number of events is the event loss denominator, + // while the number of associated events is the event loss numerator + mcEventHist.fill(HIST("hGenMCMultiplicityPercent"), genmultiplicity); + if (numberAssocColl > 0) + mcEventHist.fill(HIST("hGenMCAssocRecoMultiplicityPercent"), genmultiplicity); + + for (const auto& mcParticle : mcParticles) { + // The inclusive number of particles is the signal loss denominator, + // while the number of associated particles is the signal loss numerator + if (std::abs(mcParticle.y()) > deltaYConfigs.cfgYAcceptance) + continue; + + // Phi selection + if (mcParticle.pdgCode() == o2::constants::physics::Pdg::kPhi && mcParticle.pt() >= minPhiPt) { + mcPhiHist.fill(HIST("h3PhiMCGenNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + if (numberAssocColl > 0) + mcPhiHist.fill(HIST("h3PhiMCGenAssocRecoNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + } + + // K0S selection + if (mcParticle.pdgCode() == PDG_t::kK0Short && mcParticle.isPhysicalPrimary() && mcParticle.pt() >= v0Configs.v0SettingMinPt) { + mcK0SHist.fill(HIST("h3K0SMCGenNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + if (numberAssocColl > 0) + mcK0SHist.fill(HIST("h3K0SMCGenAssocRecoNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + } + + // Pion selection + if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus && mcParticle.isPhysicalPrimary() && mcParticle.pt() >= trackConfigs.cMinPionPtcut) { + mcPionHist.fill(HIST("h3PiMCGenNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + if (numberAssocColl > 0) + mcPionHist.fill(HIST("h3PiMCGenAssocRecoNewProc"), genmultiplicity, mcParticle.pt(), mcParticle.y()); + } + } + } + + PROCESS_SWITCH(Phik0shortanalysis, processAllPartMCGen, "Process function for all particles in MCGen", false); + + void processPhiK0SMixingEvent(SelCollisions const& collisions, FullTracks const& fullTracks, FullV0s const& V0s, V0DauTracks const&) + { + auto tracksV0sTuple = std::make_tuple(fullTracks, V0s); + Pair pairPhiK0S{binningOnVertexAndCent, cfgNoMixedEvents, -1, collisions, tracksV0sTuple, &cache}; + + for (auto const& [collision1, tracks1, collision2, v0s2] : pairPhiK0S) { + float multiplicity = collision1.centFT0M(); + + Partition posMixTracks = aod::track::signed1Pt > trackConfigs.cfgCutCharge; + posMixTracks.bindTable(tracks1); + Partition negMixTracks = aod::track::signed1Pt < trackConfigs.cfgCutCharge; + negMixTracks.bindTable(tracks1); + + for (const auto& [posTrack1, negTrack1, v0] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posMixTracks, negMixTracks, v0s2))) { + if (!selectionTrackResonance(posTrack1, true) || !selectionPIDKaonpTdependent(posTrack1)) + continue; + if (!selectionTrackResonance(negTrack1, true) || !selectionPIDKaonpTdependent(negTrack1)) + continue; + if (posTrack1.globalIndex() == negTrack1.globalIndex()) + continue; + + ROOT::Math::PxPyPzMVector recPhi = recMother(posTrack1, negTrack1, massKa, massKa); + if (recPhi.Pt() < minPhiPt) + continue; + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) + continue; + + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + + if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) + continue; + if (v0Configs.cfgFurtherV0Selection && !furtherSelectionV0(v0, collision2)) + continue; + if (std::abs(v0.yK0Short()) > deltaYConfigs.cfgYAcceptance) + continue; + + float efficiencyPhiK0S = 1.0f; + if (applyEfficiency) { + efficiencyPhiK0S = effMapPhi->Interpolate(multiplicity, recPhi.Pt(), recPhi.Rapidity()) * effMapK0S->Interpolate(multiplicity, v0.pt(), v0.yK0Short()); + if (efficiencyPhiK0S == 0) + efficiencyPhiK0S = 1.0f; + } + float weightPhiK0S = applyEfficiency ? 1.0f / efficiencyPhiK0S : 1.0f; + mePhiK0SHist.fill(HIST("h5PhiK0SMENewProc"), v0.yK0Short() - recPhi.Rapidity(), multiplicity, v0.pt(), v0.mK0Short(), recPhi.M(), weightPhiK0S); + } + } + } + + PROCESS_SWITCH(Phik0shortanalysis, processPhiK0SMixingEvent, "Process Mixed Event for Phi-K0S Analysis", false); + + void processPhiPionMixingEvent(SelCollisions const& collisions, FullTracks const& fullTracks) + { + auto tracksTuple = std::make_tuple(fullTracks); + SameKindPair pairPhiPion{binningOnVertexAndCent, cfgNoMixedEvents, -1, collisions, tracksTuple, &cache}; + + for (auto const& [collision1, tracks1, collision2, tracks2] : pairPhiPion) { + float multiplicity = collision1.centFT0M(); + + Partition posMixTracks = aod::track::signed1Pt > trackConfigs.cfgCutCharge; + posMixTracks.bindTable(tracks1); + Partition negMixTracks = aod::track::signed1Pt < trackConfigs.cfgCutCharge; + negMixTracks.bindTable(tracks1); + + for (const auto& [posTrack1, negTrack1, track] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posMixTracks, negMixTracks, tracks2))) { + if (!selectionTrackResonance(posTrack1, true) || !selectionPIDKaonpTdependent(posTrack1)) + continue; + if (!selectionTrackResonance(negTrack1, true) || !selectionPIDKaonpTdependent(negTrack1)) + continue; + if (posTrack1.globalIndex() == negTrack1.globalIndex()) + continue; + + ROOT::Math::PxPyPzMVector recPhi = recMother(posTrack1, negTrack1, massKa, massKa); + if (recPhi.Pt() < minPhiPt) + continue; + if (std::abs(recPhi.Rapidity()) > deltaYConfigs.cfgYAcceptance) + continue; + + if (!selectionPion(track, false)) + continue; + if (std::abs(track.rapidity(massPi)) > deltaYConfigs.cfgYAcceptance) + continue; + + float efficiencyPhiPion = 1.0f; + if (applyEfficiency) { + efficiencyPhiPion = track.pt() < trackConfigs.pTToUseTOF ? effMapPhi->Interpolate(multiplicity, recPhi.Pt(), recPhi.Rapidity()) * effMapPionTPC->Interpolate(multiplicity, track.pt(), track.rapidity(massPi)) : effMapPhi->Interpolate(multiplicity, recPhi.Pt(), recPhi.Rapidity()) * effMapPionTPCTOF->Interpolate(multiplicity, track.pt(), track.rapidity(massPi)); + if (efficiencyPhiPion == 0) + efficiencyPhiPion = 1.0f; } + float weightPhiPion = applyEfficiency ? 1.0f / efficiencyPhiPion : 1.0f; + mePhiPionHist.fill(HIST("h5PhiPiTPCMENewProc"), track.rapidity(massPi) - recPhi.Rapidity(), multiplicity, track.pt(), track.tpcNSigmaPi(), recPhi.M(), weightPhiPion); + if (track.hasTOF()) + mePhiPionHist.fill(HIST("h5PhiPiTOFMENewProc"), track.rapidity(massPi) - recPhi.Rapidity(), multiplicity, track.pt(), track.tofNSigmaPi(), recPhi.M(), weightPhiPion); } } } - PROCESS_SWITCH(Phik0shortanalysis, processGenMCPhiPion, "Process GenMC for Phi-Pion Analysis", false); + PROCESS_SWITCH(Phik0shortanalysis, processPhiPionMixingEvent, "Process Mixed Event for Phi-Pion Analysis", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Strangeness/sigmaanalysis.cxx b/PWGLF/Tasks/Strangeness/sigmaanalysis.cxx index f1347862b91..c01a0a71cae 100644 --- a/PWGLF/Tasks/Strangeness/sigmaanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/sigmaanalysis.cxx @@ -23,7 +23,7 @@ #include #include #include - +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -32,15 +32,15 @@ #include "ReconstructionDataFormats/Track.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/LFStrangenessPIDTables.h" -#include "PWGLF/DataModel/LFStrangenessMLTables.h" -#include "PWGLF/DataModel/LFSigmaTables.h" #include "Common/Core/TrackSelection.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/PIDResponse.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessMLTables.h" +#include "PWGLF/DataModel/LFSigmaTables.h" #include "CCDB/BasicCCDBManager.h" #include #include @@ -52,20 +52,35 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using std::array; +using std::array; using V0MCSigmas = soa::Join; using V0Sigmas = soa::Join; +static const std::vector PhotonSels = {"NoSel", "V0Type", "DaupT", "DCADauToPV", + "DCADau", "DauTPCCR", "TPCNSigmaEl", "V0pT", + "Y", "V0Radius", "RZCut", "Armenteros", "CosPA", + "PsiPair", "Phi", "Mass"}; + +static const std::vector LambdaSels = {"NoSel", "V0Radius", "DCADau", "Armenteros", + "CosPA", "Y", "TPCCR", "DauITSCls", "Lifetime", + "TPCTOFPID", "DCADauToPV", "Mass"}; + +static const std::vector DirList = {"BeforeSel", "AfterSel"}; + struct sigmaanalysis { HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable fillQAhistos{"fillQAhistos", false, "if true, fill QA histograms"}; + Configurable fillBkgQAhistos{"fillBkgQAhistos", false, "if true, fill MC QA histograms for Bkg study. Only works with MC."}; + Configurable fillpTResoQAhistos{"fillpTResoQAhistos", false, "if true, fill MC QA histograms for pT resolution study. Only works with MC."}; + // Analysis strategy: Configurable fUseMLSel{"fUseMLSel", false, "Flag to use ML selection. If False, the standard selection is applied."}; - Configurable fProcessMonteCarlo{"fProcessMonteCarlo", false, "Flag to process MC data."}; Configurable fselLambdaTPCPID{"fselLambdaTPCPID", true, "Flag to select lambda-like candidates using TPC NSigma."}; - Configurable fselLambdaTOFPID{"fselLambdaTOFPID", true, "Flag to select lambda-like candidates using TOF NSigma."}; - Configurable fLambdaTPCTOFQA{"fLambdaTPCTOFQA", false, "Flag to fill histos for Lambda TPC+TOF PID studies."}; + Configurable fselLambdaTOFPID{"fselLambdaTOFPID", false, "Flag to select lambda-like candidates using TOF NSigma."}; + Configurable doMCAssociation{"doMCAssociation", false, "Flag to process only signal candidates. Use only with processMonteCarlo!"}; + Configurable doPhotonLambdaSelQA{"doPhotonLambdaSelQA", false, "Flag to fill photon and lambda QA histos!"}; // For ML Selection Configurable Gamma_MLThreshold{"Gamma_MLThreshold", 0.1, "Decision Threshold value to select gammas"}; @@ -76,6 +91,8 @@ struct sigmaanalysis { //// Lambda standard criteria:: Configurable LambdaMinDCANegToPv{"LambdaMinDCANegToPv", .05, "min DCA Neg To PV (cm)"}; Configurable LambdaMinDCAPosToPv{"LambdaMinDCAPosToPv", .05, "min DCA Pos To PV (cm)"}; + Configurable ALambdaMinDCANegToPv{"ALambdaMinDCANegToPv", .05, "min DCA Neg To PV (cm)"}; + Configurable ALambdaMinDCAPosToPv{"ALambdaMinDCAPosToPv", .05, "min DCA Pos To PV (cm)"}; Configurable LambdaMaxDCAV0Dau{"LambdaMaxDCAV0Dau", 2.5, "Max DCA V0 Daughters (cm)"}; Configurable LambdaMinv0radius{"LambdaMinv0radius", 0.0, "Min V0 radius (cm)"}; Configurable LambdaMaxv0radius{"LambdaMaxv0radius", 40, "Max V0 radius (cm)"}; @@ -84,17 +101,24 @@ struct sigmaanalysis { Configurable LambdaMinAlpha{"LambdaMinAlpha", 0.25, "Min lambda alpha absolute value (AP plot)"}; Configurable LambdaMaxAlpha{"LambdaMaxAlpha", 1.0, "Max lambda alpha absolute value (AP plot)"}; Configurable LambdaMinv0cospa{"LambdaMinv0cospa", 0.95, "Min V0 CosPA"}; + Configurable LambdaMaxLifeTime{"LambdaMaxLifeTime", 30, "Max lifetime"}; Configurable LambdaWindow{"LambdaWindow", 0.015, "Mass window around expected (in GeV/c2)"}; Configurable LambdaMaxRap{"LambdaMaxRap", 0.8, "Max lambda rapidity"}; + Configurable LambdaMaxDauEta{"LambdaMaxDauEta", 0.8, "Max pseudorapidity of daughter tracks"}; Configurable LambdaMaxTPCNSigmas{"LambdaMaxTPCNSigmas", 1e+9, "Max TPC NSigmas for daughters"}; - Configurable LambdaMaxTOFNSigmas{"LambdaMaxTOFNSigmas", 1e+9, "Max TOF NSigmas for daughters"}; + Configurable LambdaPrMaxTOFNSigmas{"LambdaPrMaxTOFNSigmas", 1e+9, "Max TOF NSigmas for daughters"}; + Configurable LambdaPiMaxTOFNSigmas{"LambdaPiMaxTOFNSigmas", 1e+9, "Max TOF NSigmas for daughters"}; + Configurable LambdaMinTPCCrossedRows{"LambdaMinTPCCrossedRows", 50, "Min daughter TPC Crossed Rows"}; + Configurable LambdaMinITSclusters{"LambdaMinITSclusters", 1, "minimum ITS clusters"}; + Configurable LambdaRejectPosITSafterburner{"LambdaRejectPosITSafterburner", false, "reject positive track formed out of afterburner ITS tracks"}; + Configurable LambdaRejectNegITSafterburner{"LambdaRejectNegITSafterburner", false, "reject negative track formed out of afterburner ITS tracks"}; //// Photon standard criteria: - // Configurable PhotonMaxDauPseudoRap{"PhotonMaxDauPseudoRap", 0.9, "Max pseudorapidity of daughter tracks"}; + Configurable Photonv0TypeSel{"Photonv0TypeSel", 7, "select on a certain V0 type (leave negative if no selection desired)"}; Configurable PhotonDauMinPt{"PhotonDauMinPt", 0.0, "Min daughter pT (GeV/c)"}; Configurable PhotonMinDCADauToPv{"PhotonMinDCADauToPv", 0.0, "Min DCA daughter To PV (cm)"}; Configurable PhotonMaxDCAV0Dau{"PhotonMaxDCAV0Dau", 3.5, "Max DCA V0 Daughters (cm)"}; - Configurable PhotonMinTPCCrossedRows{"PhotonMinTPCCrossedRows", 0, "Min daughter TPC Crossed Rows"}; + Configurable PhotonMinTPCCrossedRows{"PhotonMinTPCCrossedRows", 30, "Min daughter TPC Crossed Rows"}; Configurable PhotonMinTPCNSigmas{"PhotonMinTPCNSigmas", -7, "Min TPC NSigmas for daughters"}; Configurable PhotonMaxTPCNSigmas{"PhotonMaxTPCNSigmas", 7, "Max TPC NSigmas for daughters"}; Configurable PhotonMinPt{"PhotonMinPt", 0.0, "Min photon pT (GeV/c)"}; @@ -107,7 +131,13 @@ struct sigmaanalysis { Configurable PhotonMaxAlpha{"PhotonMaxAlpha", 0.95, "Max photon alpha absolute value (AP plot)"}; Configurable PhotonMinV0cospa{"PhotonMinV0cospa", 0.80, "Min V0 CosPA"}; Configurable PhotonMaxMass{"PhotonMaxMass", 0.10, "Max photon mass (GeV/c^{2})"}; - // TODO: Include PsiPair selection + Configurable PhotonPsiPairMax{"PhotonPsiPairMax", 1e+9, "maximum psi angle of the track pair"}; + Configurable PhotonMaxDauEta{"PhotonMaxDauEta", 0.8, "Max pseudorapidity of daughter tracks"}; + Configurable PhotonLineCutZ0{"PhotonLineCutZ0", 7.0, "The offset for the linecute used in the Z vs R plot"}; + Configurable PhotonPhiMin1{"PhotonPhiMin1", -1, "Phi min value to reject photons, region 1 (leave negative if no selection desired)"}; + Configurable PhotonPhiMax1{"PhotonPhiMax1", -1, "Phi max value to reject photons, region 1 (leave negative if no selection desired)"}; + Configurable PhotonPhiMin2{"PhotonPhiMin2", -1, "Phi max value to reject photons, region 2 (leave negative if no selection desired)"}; + Configurable PhotonPhiMax2{"PhotonPhiMax2", -1, "Phi min value to reject photons, region 2 (leave negative if no selection desired)"}; Configurable SigmaMaxRap{"SigmaMaxRap", 0.5, "Max sigma0 rapidity"}; @@ -115,515 +145,792 @@ struct sigmaanalysis { // base properties ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Centrality"}; ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "p_{T} (GeV/c)"}; + ConfigurableAxis axisInvPt{"axisInvPt", {VARIABLE_WIDTH, 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}, ""}; + ConfigurableAxis axisDeltaPt{"axisDeltaPt", {400, -50.0, 50.0}, ""}; ConfigurableAxis axisRapidity{"axisRapidity", {100, -2.0f, 2.0f}, "Rapidity"}; + ConfigurableAxis axisIRBinning{"axisIRBinning", {150, 0, 1500}, "Binning for the interaction rate (kHz)"}; // Invariant Mass - ConfigurableAxis axisSigmaMass{"axisSigmaMass", {1000, 1.10f, 1.30f}, "M_{#Sigma^{0}} (GeV/c^{2})"}; + ConfigurableAxis axisSigmaMass{"axisSigmaMass", {500, 1.10f, 1.30f}, "M_{#Sigma^{0}} (GeV/c^{2})"}; ConfigurableAxis axisLambdaMass{"axisLambdaMass", {200, 1.05f, 1.151f}, "M_{#Lambda} (GeV/c^{2})"}; - ConfigurableAxis axisPhotonMass{"axisPhotonMass", {600, -0.1f, 0.5f}, "M_{#Gamma}"}; + ConfigurableAxis axisPhotonMass{"axisPhotonMass", {200, -0.1f, 0.5f}, "M_{#Gamma}"}; // AP plot axes ConfigurableAxis axisAPAlpha{"axisAPAlpha", {220, -1.1f, 1.1f}, "V0 AP alpha"}; ConfigurableAxis axisAPQt{"axisAPQt", {220, 0.0f, 0.5f}, "V0 AP alpha"}; - // Track quality axes + // Track quality, PID and other axes ConfigurableAxis axisTPCrows{"axisTPCrows", {160, 0.0f, 160.0f}, "N TPC rows"}; + ConfigurableAxis axisNCls{"axisNCls", {8, -0.5, 7.5}, "NCls"}; + ConfigurableAxis axisChi2PerNcl{"axisChi2PerNcl", {80, -40, 40}, "Chi2 Per Ncl"}; + ConfigurableAxis axisTPCNSigma{"axisTPCNSigma", {120, -30, 30}, "TPC NSigma"}; + ConfigurableAxis axisTOFNSigma{"axisTOFNSigma", {120, -30, 30}, "TOF NSigma"}; + ConfigurableAxis axisLifetime{"axisLifetime", {100, 0, 100}, "Chi2 Per Ncl"}; // topological variable QA axes ConfigurableAxis axisRadius{"axisRadius", {240, 0.0f, 120.0f}, "V0 radius (cm)"}; ConfigurableAxis axisDCAtoPV{"axisDCAtoPV", {500, 0.0f, 50.0f}, "DCA (cm)"}; ConfigurableAxis axisDCAdau{"axisDCAdau", {50, 0.0f, 5.0f}, "DCA (cm)"}; ConfigurableAxis axisCosPA{"axisCosPA", {200, 0.5f, 1.0f}, "Cosine of pointing angle"}; - ConfigurableAxis axisCandSel{"axisCandSel", {26, 0.5f, +26.5f}, "Candidate Selection"}; + ConfigurableAxis axisPA{"axisPA", {100, 0.0f, 1}, "Pointing angle"}; + ConfigurableAxis axisPsiPair{"axisPsiPair", {250, -5.0f, 5.0f}, "Psipair for photons"}; + ConfigurableAxis axisPhi{"axisPhi", {200, 0, 2 * o2::constants::math::PI}, "Phi for photons"}; + ConfigurableAxis axisZ{"axisZ", {120, -120.0f, 120.0f}, "V0 Z position (cm)"}; + + ConfigurableAxis axisCandSel{"axisCandSel", {20, 0.5f, +20.5f}, "Candidate Selection"}; // ML ConfigurableAxis MLProb{"MLOutput", {100, 0.0f, 1.0f}, ""}; - int nSigmaCandidates = 0; + void init(InitContext const&) { - // All candidates received - histos.add("GeneralQA/h2dArmenterosBeforeSel", "h2dArmenterosBeforeSel", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); - histos.add("GeneralQA/h2dArmenterosAfterSel", "h2dArmenterosAfterSel", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); - histos.add("GeneralQA/hMassSigma0BeforeSel", "hMassSigma0BeforeSel", kTH1F, {axisSigmaMass}); - - // Candidates Counters - histos.add("GeneralQA/hCandidateAnalysisSelection", "hCandidateAnalysisSelection", kTH1F, {axisCandSel}); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(1, "No Sel"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(2, "Photon Mass Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(3, "Photon DauPt Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(4, "Photon DCAToPV Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(5, "Photon DCADau Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(6, "Photon TPCCrossedRows Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(7, "Photon PosTPCSigma Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(8, "Photon NegTPCSigma Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(9, "Photon Pt Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(10, "Photon Y Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(11, "Photon Radius Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(12, "Photon Zconv Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(13, "Photon QT Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(14, "Photon Alpha Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(15, "Photon CosPA Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(16, "Lambda Mass Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(17, "Lambda DCAToPV Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(18, "Lambda Radius Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(19, "Lambda DCADau Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(20, "Lambda QT Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(21, "Lambda Alpha Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(22, "Lambda CosPA Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(23, "Lambda Y Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(24, "Sigma Y Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(25, "Lambda/ALambda PID Cut"); - - // Photon Selection QA histos - histos.add("GeneralQA/hPhotonMass", "hPhotonMass", kTH1F, {axisPhotonMass}); - histos.add("GeneralQA/hPhotonNegpT", "hPhotonNegpT", kTH1F, {axisPt}); - histos.add("GeneralQA/hPhotonPospT", "hPhotonPospT", kTH1F, {axisPt}); - histos.add("GeneralQA/hPhotonDCANegToPV", "hPhotonDCANegToPV", kTH1F, {axisDCAtoPV}); - histos.add("GeneralQA/hPhotonDCAPosToPV", "hPhotonDCAPosToPV", kTH1F, {axisDCAtoPV}); - histos.add("GeneralQA/hPhotonDCADau", "hPhotonDCADau", kTH1F, {axisDCAdau}); - histos.add("GeneralQA/hPhotonPosTPCCR", "hPhotonPosTPCCR", kTH1F, {axisTPCrows}); - histos.add("GeneralQA/hPhotonNegTPCCR", "hPhotonNegTPCCR", kTH1F, {axisTPCrows}); - histos.add("GeneralQA/hPhotonPosTPCNSigma", "hPhotonPosTPCNSigma", kTH1F, {{30, -15.0f, 15.0f}}); - histos.add("GeneralQA/hPhotonNegTPCNSigma", "hPhotonNegTPCNSigma", kTH1F, {{30, -15.0f, 15.0f}}); - histos.add("GeneralQA/hPhotonpT", "hPhotonpT", kTH1F, {axisPt}); - histos.add("GeneralQA/hPhotonY", "hPhotonY", kTH1F, {axisRapidity}); - histos.add("GeneralQA/hPhotonRadius", "hPhotonRadius", kTH1F, {axisRadius}); - histos.add("GeneralQA/hPhotonZ", "hPhotonZ", kTH1F, {{240, 0.0f, 120.0f}}); - histos.add("GeneralQA/h2dPhotonArmenteros", "h2dPhotonArmenteros", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); - histos.add("GeneralQA/hPhotonCosPA", "hPhotonCosPA", kTH1F, {axisCosPA}); - - // Lambda Selection QA histos - histos.add("GeneralQA/hLambdaMass", "hLambdaMass", kTH1F, {axisLambdaMass}); - histos.add("GeneralQA/hAntiLambdaMass", "hAntiLambdaMass", kTH1F, {axisLambdaMass}); - histos.add("GeneralQA/hLambdaDCANegToPV", "hLambdaDCANegToPV", kTH1F, {axisDCAtoPV}); - histos.add("GeneralQA/hLambdaDCAPosToPV", "hLambdaDCAPosToPV", kTH1F, {axisDCAtoPV}); - histos.add("GeneralQA/hLambdaRadius", "hLambdaRadius", kTH1F, {axisRadius}); - histos.add("GeneralQA/hLambdaDCADau", "hLambdaDCADau", kTH1F, {axisDCAdau}); - histos.add("GeneralQA/h2dLambdaArmenteros", "h2dLambdaArmenteros", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); - histos.add("GeneralQA/hLambdaCosPA", "hLambdaCosPA", kTH1F, {axisCosPA}); - histos.add("GeneralQA/hLambdaY", "hLambdaY", kTH1F, {axisRapidity}); - histos.add("GeneralQA/hSigmaY", "hSigmaY", kTH1F, {axisRapidity}); - histos.add("GeneralQA/hSigmaOPAngle", "hSigmaOPAngle", kTH1F, {{140, 0.0f, +7.0f}}); - histos.add("GeneralQA/h2dTPCvsTOFNSigma_LambdaPr", "h2dTPCvsTOFNSigma_LambdaPr", kTH2F, {{120, -30, 30}, {120, -30, 30}}); - histos.add("GeneralQA/h2dTPCvsTOFNSigma_LambdaPi", "h2dTPCvsTOFNSigma_LambdaPi", kTH2F, {{120, -30, 30}, {120, -30, 30}}); - histos.add("GeneralQA/h2dTPCvsTOFNSigma_ALambdaPr", "h2dTPCvsTOFNSigma_ALambdaPr", kTH2F, {{120, -30, 30}, {120, -30, 30}}); - histos.add("GeneralQA/h2dTPCvsTOFNSigma_ALambdaPi", "h2dTPCvsTOFNSigma_ALambdaPi", kTH2F, {{120, -30, 30}, {120, -30, 30}}); - - histos.add("GeneralQA/hPhotonMassSelected", "hPhotonMassSelected", kTH1F, {axisPhotonMass}); - histos.add("GeneralQA/hLambdaMassSelected", "hLambdaMassSelected", kTH1F, {axisLambdaMass}); - histos.add("GeneralQA/hAntiLambdaMassSelected", "hAntiLambdaMassSelected", kTH1F, {axisLambdaMass}); - - // For Signal Extraction - - // Sigma0 - histos.add("Sigma0/h3dMassSigma0", "h3dMassSigma0", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); - histos.add("Sigma0/hMassSigma0", "hMassSigma0", kTH1F, {axisSigmaMass}); - histos.add("Sigma0/hPtSigma0", "hPtSigma0", kTH1F, {axisPt}); - histos.add("Sigma0/hRapiditySigma0", "hRapiditySigma0", kTH1F, {axisRapidity}); - - // AntiSigma0 - histos.add("AntiSigma0/h3dMassAntiSigma0", "h3dMassAntiSigma0", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); - histos.add("AntiSigma0/hMassAntiSigma0", "hMassAntiSigma0", kTH1F, {axisSigmaMass}); - histos.add("AntiSigma0/hPtAntiSigma0", "hPtAntiSigma0", kTH1F, {axisPt}); - histos.add("AntiSigma0/hRapidityAntiSigma0", "hRapidityAntiSigma0", kTH1F, {axisRapidity}); - - if (fProcessMonteCarlo) { - - // Kinematic - histos.add("MC/h3dMassSigma0", "h3dMassSigma0", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); - histos.add("MC/h3dMassAntiSigma0", "h3dMassSigma0", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); - - histos.add("MC/h2dArmenterosBeforeSel", "h2dArmenterosBeforeSel", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); - histos.add("MC/h2dArmenterosAfterSel", "h2dArmenterosAfterSel", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); - - // Sigma0 QA - histos.add("MC/hMassSigma0BeforeSel", "hMassSigma0BeforeSel", kTH1F, {axisSigmaMass}); - histos.add("MC/hPtSigma0BeforeSel", "hPtSigma0BeforeSel", kTH1F, {axisPt}); - histos.add("MC/hMassSigma0", "hMassSigma0", kTH1F, {axisSigmaMass}); - histos.add("MC/hPtSigma0", "hPtSigma0", kTH1F, {axisPt}); - histos.add("MC/hMassAntiSigma0", "hMassAntiSigma0", kTH1F, {axisSigmaMass}); - histos.add("MC/hPtAntiSigma0", "hPtAntiSigma0", kTH1F, {axisPt}); - - // For background decomposition - histos.add("MC/h2dPtVsMassSigma_SignalBkg", "h2dPtVsMassSigma_SignalBkg", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_SignalOnly", "h2dPtVsMassSigma_SignalOnly", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_TrueDaughters", "h2dPtVsMassSigma_TrueDaughters", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_TrueGammaFakeLambda", "h2dPtVsMassSigma_TrueGammaFakeLambda", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_FakeGammaTrueLambda", "h2dPtVsMassSigma_FakeGammaTrueLambda", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dPtVsMassSigma_FakeDaughters", "h2dPtVsMassSigma_FakeDaughters", kTH2D, {axisPt, axisSigmaMass}); - histos.add("MC/h2dTrueDaughtersMatrix", "h2dTrueDaughtersMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); - - // For new selection studies: - //// Opening angle between daughters - histos.add("MC/h2dPtVsOPAngle_SignalOnly", "h2dPtVsOPAngle_SignalOnly", kTH2D, {axisPt, {140, 0.0f, +7.0f}}); - histos.add("MC/h2dPtVsOPAngle_TrueDaughters", "h2dPtVsOPAngle_TrueDaughters", kTH2D, {axisPt, {140, 0.0f, +7.0f}}); - histos.add("MC/h2dPtVsMassSigma_AfterOPAngleSel", "h2dPtVsMassSigma_AfterOPAngleSel", kTH2D, {axisPt, axisSigmaMass}); - - // For efficiency/Purity studies - // Before any selection - histos.add("MC/hPtTrueLambda_BeforeSel", "hPtTrueLambda_BeforeSel", kTH1F, {axisPt}); // Signal only - histos.add("MC/hPtTrueGamma_BeforeSel", "hPtTrueGamma_BeforeSel", kTH1F, {axisPt}); // Signal only - histos.add("MC/hPtTrueSigma_BeforeSel", "hPtTrueSigma_BeforeSel", kTH1F, {axisPt}); // Signal only - histos.add("MC/hPtLambdaCand_BeforeSel", "hPtLambdaCand_BeforeSel", kTH1F, {axisPt}); // Bkg + Signal - histos.add("MC/hPtGammaCand_BeforeSel", "hPtGammaCand_BeforeSel", kTH1F, {axisPt}); // Bkg + Signal - histos.add("MC/hPtSigmaCand_BeforeSel", "hPtGammaCand_BeforeSel", kTH1F, {axisPt}); // Bkg + Signal - - // After analysis selections - histos.add("MC/hPtTrueLambda_AfterSel", "hPtTrueLambda_AfterSel", kTH1F, {axisPt}); // Signal only - histos.add("MC/hPtTrueGamma_AfterSel", "hPtTrueGamma_AfterSel", kTH1F, {axisPt}); // Signal only - histos.add("MC/hPtTrueSigma_AfterSel", "hPtTrueSigma_AfterSel", kTH1F, {axisPt}); // Signal only - - histos.add("MC/hPtLambdaCand_AfterSel", "hPtLambdaCand_AfterSel", kTH1F, {axisPt}); - histos.add("MC/hPtGammaCand_AfterSel", "hPtGammaCand_AfterSel", kTH1F, {axisPt}); - histos.add("MC/hPtSigmaCand_AfterSel", "hPtSigmaCand_AfterSel", kTH1F, {axisPt}); - - // TPC vs TOF N Sigmas distributions - histos.add("MC/h3dTPCvsTOFNSigma_LambdaPr", "h3dTPCvsTOFNSigma_LambdaPr", kTH3F, {{120, -30, 30}, {120, -30, 30}, axisPt}); - histos.add("MC/h3dTPCvsTOFNSigma_LambdaPi", "h3dTPCvsTOFNSigma_LambdaPi", kTH3F, {{120, -30, 30}, {120, -30, 30}, axisPt}); - histos.add("MC/h3dTPCvsTOFNSigma_TrueLambdaPr", "h3dTPCvsTOFNSigma_TrueLambdaPr", kTH3F, {{120, -30, 30}, {120, -30, 30}, axisPt}); - histos.add("MC/h3dTPCvsTOFNSigma_TrueLambdaPi", "h3dTPCvsTOFNSigma_TrueLambdaPi", kTH3F, {{120, -30, 30}, {120, -30, 30}, axisPt}); - - // QA of PID selections: - //// TPC PID - histos.add("MC/hPtTrueLambda_passedTPCPID", "hPtTrueLambda_passedTPCPID", kTH1F, {axisPt}); - histos.add("MC/hPtLambdaCandidates_passedTPCPID", "hPtLambdaCandidates_passedTPCPID", kTH1F, {axisPt}); - - //// TOF PID - histos.add("MC/hPtTrueLambda_passedTOFPID", "hPtTrueLambda_passedTOFPID", kTH1F, {axisPt}); - histos.add("MC/hPtLambdaCandidates_passedTOFPID", "hPtLambdaCandidates_passedTOFPID", kTH1F, {axisPt}); - - //// TPC+TOF PID - histos.add("MC/hPtTrueLambda_passedTPCTOFPID", "hPtTrueLambda_passedTPCTOFPID", kTH1F, {axisPt}); - histos.add("MC/hPtLambdaCandidates_passedTPCTOFPID", "hPtLambdaCandidates_passedTPCTOFPID", kTH1F, {axisPt}); + + for (const auto& histodir : DirList) { + + histos.add(histodir + "/Photon/hTrackCode", "hTrackCode", kTH1F, {{11, 0.5f, 11.5f}}); + histos.add(histodir + "/Photon/hV0Type", "hV0Type", kTH1F, {{8, 0.5f, 8.5f}}); + histos.add(histodir + "/Photon/hNegpT", "hNegpT", kTH1F, {axisPt}); + histos.add(histodir + "/Photon/hPospT", "hPospT", kTH1F, {axisPt}); + histos.add(histodir + "/Photon/hDCANegToPV", "hDCANegToPV", kTH1F, {axisDCAtoPV}); + histos.add(histodir + "/Photon/hDCAPosToPV", "hDCAPosToPV", kTH1F, {axisDCAtoPV}); + histos.add(histodir + "/Photon/hDCADau", "hDCADau", kTH1F, {axisDCAdau}); + histos.add(histodir + "/Photon/hPosTPCCR", "hPosTPCCR", kTH1F, {axisTPCrows}); + histos.add(histodir + "/Photon/hNegTPCCR", "hNegTPCCR", kTH1F, {axisTPCrows}); + histos.add(histodir + "/Photon/h2dPosTPCNSigmaEl", "h2dPosTPCNSigmaEl", kTH2F, {axisPt, axisTPCNSigma}); + histos.add(histodir + "/Photon/h2dNegTPCNSigmaEl", "h2dNegTPCNSigmaEl", kTH2F, {axisPt, axisTPCNSigma}); + histos.add(histodir + "/Photon/h2dPosTPCNSigmaPi", "h2dPosTPCNSigmaPi", kTH2F, {axisPt, axisTPCNSigma}); + histos.add(histodir + "/Photon/h2dNegTPCNSigmaPi", "h2dNegTPCNSigmaPi", kTH2F, {axisPt, axisTPCNSigma}); + histos.add(histodir + "/Photon/hpT", "hpT", kTH1F, {axisPt}); + histos.add(histodir + "/Photon/hY", "hY", kTH1F, {axisRapidity}); + histos.add(histodir + "/Photon/hPosEta", "hPosEta", kTH1F, {axisRapidity}); + histos.add(histodir + "/Photon/hNegEta", "hNegEta", kTH1F, {axisRapidity}); + histos.add(histodir + "/Photon/hRadius", "hRadius", kTH1F, {axisRadius}); + histos.add(histodir + "/Photon/hZ", "hZ", kTH1F, {axisZ}); + histos.add(histodir + "/Photon/h2dRZCut", "h2dRZCut", kTH2F, {axisZ, axisRadius}); + histos.add(histodir + "/Photon/h2dRZPlane", "h2dRZPlane", kTH2F, {axisZ, axisRadius}); + histos.add(histodir + "/Photon/hCosPA", "hCosPA", kTH1F, {axisCosPA}); + histos.add(histodir + "/Photon/hPsiPair", "hPsiPair", kTH1F, {axisPsiPair}); + histos.add(histodir + "/Photon/hPhi", "hPhi", kTH1F, {axisPhi}); + histos.add(histodir + "/Photon/h3dMass", "h3dMass", kTH3F, {axisCentrality, axisPt, axisPhotonMass}); + histos.add(histodir + "/Photon/hMass", "hMass", kTH1F, {axisPhotonMass}); + + histos.add(histodir + "/Lambda/hTrackCode", "hTrackCode", kTH1F, {{11, 0.5f, 11.5f}}); + histos.add(histodir + "/Lambda/hRadius", "hRadius", kTH1F, {axisRadius}); + histos.add(histodir + "/Lambda/hDCADau", "hDCADau", kTH1F, {axisDCAdau}); + histos.add(histodir + "/Lambda/hCosPA", "hCosPA", kTH1F, {axisCosPA}); + histos.add(histodir + "/Lambda/hY", "hY", kTH1F, {axisRapidity}); + histos.add(histodir + "/Lambda/hPosEta", "hPosEta", kTH1F, {axisRapidity}); + histos.add(histodir + "/Lambda/hNegEta", "hNegEta", kTH1F, {axisRapidity}); + histos.add(histodir + "/Lambda/hPosTPCCR", "hPosTPCCR", kTH1F, {axisTPCrows}); + histos.add(histodir + "/Lambda/hNegTPCCR", "hNegTPCCR", kTH1F, {axisTPCrows}); + histos.add(histodir + "/Lambda/hPosITSCls", "hPosITSCls", kTH1F, {axisNCls}); + histos.add(histodir + "/Lambda/hNegITSCls", "hNegITSCls", kTH1F, {axisNCls}); + histos.add(histodir + "/Lambda/hPosChi2PerNc", "hPosChi2PerNc", kTH1F, {axisChi2PerNcl}); + histos.add(histodir + "/Lambda/hNegChi2PerNc", "hNegChi2PerNc", kTH1F, {axisChi2PerNcl}); + histos.add(histodir + "/Lambda/hLifeTime", "hLifeTime", kTH1F, {axisLifetime}); + histos.add(histodir + "/Lambda/h2dTPCvsTOFNSigma_LambdaPr", "h2dTPCvsTOFNSigma_LambdaPr", kTH2F, {axisTPCNSigma, axisTOFNSigma}); + histos.add(histodir + "/Lambda/h2dTPCvsTOFNSigma_LambdaPi", "h2dTPCvsTOFNSigma_LambdaPi", kTH2F, {axisTPCNSigma, axisTOFNSigma}); + histos.add(histodir + "/Lambda/hLambdaDCANegToPV", "hLambdaDCANegToPV", kTH1F, {axisDCAtoPV}); + histos.add(histodir + "/Lambda/hLambdaDCAPosToPV", "hLambdaDCAPosToPV", kTH1F, {axisDCAtoPV}); + histos.add(histodir + "/Lambda/hLambdapT", "hLambdapT", kTH1F, {axisPt}); + histos.add(histodir + "/Lambda/hLambdaMass", "hLambdaMass", kTH1F, {axisLambdaMass}); + histos.add(histodir + "/Lambda/h3dLambdaMass", "h3dLambdaMass", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + histos.add(histodir + "/Lambda/h2dTPCvsTOFNSigma_ALambdaPr", "h2dTPCvsTOFNSigma_ALambdaPr", kTH2F, {axisTPCNSigma, axisTOFNSigma}); + histos.add(histodir + "/Lambda/h2dTPCvsTOFNSigma_ALambdaPi", "h2dTPCvsTOFNSigma_ALambdaPi", kTH2F, {axisTPCNSigma, axisTOFNSigma}); + histos.add(histodir + "/Lambda/hALambdaDCANegToPV", "hALambdaDCANegToPV", kTH1F, {axisDCAtoPV}); + histos.add(histodir + "/Lambda/hALambdaDCAPosToPV", "hALambdaDCAPosToPV", kTH1F, {axisDCAtoPV}); + histos.add(histodir + "/Lambda/hALambdapT", "hALambdapT", kTH1F, {axisPt}); + histos.add(histodir + "/Lambda/hAntiLambdaMass", "hAntiLambdaMass", kTH1F, {axisLambdaMass}); + histos.add(histodir + "/Lambda/h3dAntiLambdaMass", "h3dAntiLambdaMass", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + + histos.add(histodir + "/h2dArmenteros", "h2dArmenteros", kTH2F, {axisAPAlpha, axisAPQt}); + + histos.add(histodir + "/Sigma0/hMass", "hMass", kTH1F, {axisSigmaMass}); + histos.add(histodir + "/Sigma0/hPt", "hPt", kTH1F, {axisPt}); + histos.add(histodir + "/Sigma0/hY", "hY", kTH1F, {axisRapidity}); + histos.add(histodir + "/Sigma0/h3dMass", "h3dMass", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); + histos.add(histodir + "/Sigma0/h3dPhotonRadiusVsMassSigma", "h3dPhotonRadiusVsMassSigma", kTH3F, {axisCentrality, axisRadius, axisSigmaMass}); + histos.add(histodir + "/Sigma0/h2dpTVsOPAngle", "h2dpTVsOPAngle", kTH2F, {axisPt, {140, 0.0f, +7.0f}}); + + histos.add(histodir + "/ASigma0/hMass", "hMass", kTH1F, {axisSigmaMass}); + histos.add(histodir + "/ASigma0/hPt", "hPt", kTH1F, {axisPt}); + histos.add(histodir + "/ASigma0/hY", "hY", kTH1F, {axisRapidity}); + histos.add(histodir + "/ASigma0/h3dMass", "h3dMass", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); + histos.add(histodir + "/ASigma0/h3dPhotonRadiusVsMassSigma", "h3dPhotonRadiusVsMassSigma", kTH3F, {axisCentrality, axisRadius, axisSigmaMass}); + histos.add(histodir + "/ASigma0/h2dpTVsOPAngle", "h2dpTVsOPAngle", kTH2F, {axisPt, {140, 0.0f, +7.0f}}); + + // Process MC + if (doprocessMonteCarlo) { + histos.add(histodir + "/MC/Photon/hV0ToCollAssoc", "hV0ToCollAssoc", kTH1F, {{2, 0.0f, 2.0f}}); + histos.add(histodir + "/MC/Photon/hPt", "hPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/Photon/hMCPt", "hMCPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/Photon/h2dPosTPCNSigmaEl", "h2dPosTPCNSigmaEl", kTH2F, {axisPt, axisTPCNSigma}); + histos.add(histodir + "/MC/Photon/h2dNegTPCNSigmaEl", "h2dNegTPCNSigmaEl", kTH2F, {axisPt, axisTPCNSigma}); + histos.add(histodir + "/MC/Photon/h2dPosTPCNSigmaPi", "h2dPosTPCNSigmaPi", kTH2F, {axisPt, axisTPCNSigma}); + histos.add(histodir + "/MC/Photon/h2dNegTPCNSigmaPi", "h2dNegTPCNSigmaPi", kTH2F, {axisPt, axisTPCNSigma}); + histos.add(histodir + "/MC/Photon/h2dPAVsPt", "h2dPAVsPt", kTH2F, {axisPA, axisPt}); + histos.add(histodir + "/MC/Photon/hPt_BadCollAssig", "hPt_BadCollAssig", kTH1F, {axisPt}); + histos.add(histodir + "/MC/Photon/h2dPAVsPt_BadCollAssig", "h2dPAVsPt_BadCollAssig", kTH2F, {axisPA, axisPt}); + + histos.add(histodir + "/MC/Lambda/hV0ToCollAssoc", "hV0ToCollAssoc", kTH1F, {{2, 0.0f, 2.0f}}); + histos.add(histodir + "/MC/Lambda/hPt", "hPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/Lambda/hMCPt", "hMCPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/Lambda/h3dTPCvsTOFNSigma_Pr", "h3dTPCvsTOFNSigma_Pr", kTH3F, {axisTPCNSigma, axisTOFNSigma, axisPt}); + histos.add(histodir + "/MC/Lambda/h3dTPCvsTOFNSigma_Pi", "h3dTPCvsTOFNSigma_Pi", kTH3F, {axisTPCNSigma, axisTOFNSigma, axisPt}); + + histos.add(histodir + "/MC/ALambda/hV0ToCollAssoc", "hV0ToCollAssoc", kTH1F, {{2, 0.0f, 2.0f}}); + histos.add(histodir + "/MC/ALambda/hPt", "hPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/ALambda/hMCPt", "hMCPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/ALambda/h3dTPCvsTOFNSigma_Pr", "h3dTPCvsTOFNSigma_Pr", kTH3F, {axisTPCNSigma, axisTOFNSigma, axisPt}); + histos.add(histodir + "/MC/ALambda/h3dTPCvsTOFNSigma_Pi", "h3dTPCvsTOFNSigma_Pi", kTH3F, {axisTPCNSigma, axisTOFNSigma, axisPt}); + + histos.add(histodir + "/MC/h2dArmenteros", "h2dArmenteros", kTH2F, {axisAPAlpha, axisAPQt}); + + histos.add(histodir + "/MC/Sigma0/hPt", "hPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/Sigma0/hMCPt", "hMCPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/Sigma0/h2dMCPtVsLambdaMCPt", "h2dMCPtVsLambdaMCPt", kTH2F, {axisPt, axisPt}); + histos.add(histodir + "/MC/Sigma0/h2dMCPtVsGammaMCPt", "h2dMCPtVsGammaMCPt", kTH2F, {axisPt, axisPt}); + histos.add(histodir + "/MC/Sigma0/hMass", "hMass", kTH1F, {axisSigmaMass}); + histos.add(histodir + "/MC/Sigma0/h3dMass", "h3dMass", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); + + histos.add(histodir + "/MC/ASigma0/hPt", "hPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/ASigma0/hMCPt", "hMCPt", kTH1F, {axisPt}); + histos.add(histodir + "/MC/ASigma0/h2dMCPtVsLambdaMCPt", "h2dMCPtVsLambdaMCPt", kTH2F, {axisPt, axisPt}); + histos.add(histodir + "/MC/ASigma0/h2dMCPtVsPhotonMCPt", "h2dMCPtVsPhotonMCPt", kTH2F, {axisPt, axisPt}); + histos.add(histodir + "/MC/ASigma0/hMass", "hMass", kTH1F, {axisSigmaMass}); + histos.add(histodir + "/MC/ASigma0/h3dMass", "h3dMass", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); + + // 1/pT Resolution: + if (fillpTResoQAhistos && histodir == "BeforeSel") { + histos.add(histodir + "/MC/pTReso/h3dGammaPtResoVsTPCCR", "h3dGammaPtResoVsTPCCR", kTH3F, {axisInvPt, axisDeltaPt, axisTPCrows}); + histos.add(histodir + "/MC/pTReso/h3dGammaPtResoVsTPCCR", "h3dGammaPtResoVsTPCCR", kTH3F, {axisInvPt, axisDeltaPt, axisTPCrows}); + histos.add(histodir + "/MC/pTReso/h2dGammaPtResolution", "h2dGammaPtResolution", kTH2F, {axisInvPt, axisDeltaPt}); + histos.add(histodir + "/MC/pTReso/h2dLambdaPtResolution", "h2dLambdaPtResolution", kTH2F, {axisInvPt, axisDeltaPt}); + histos.add(histodir + "/MC/pTReso/h3dLambdaPtResoVsTPCCR", "h3dLambdaPtResoVsTPCCR", kTH3F, {axisInvPt, axisDeltaPt, axisTPCrows}); + histos.add(histodir + "/MC/pTReso/h3dLambdaPtResoVsTPCCR", "h3dLambdaPtResoVsTPCCR", kTH3F, {axisInvPt, axisDeltaPt, axisTPCrows}); + histos.add(histodir + "/MC/pTReso/h2dAntiLambdaPtResolution", "h2dAntiLambdaPtResolution", kTH2F, {axisInvPt, axisDeltaPt}); + histos.add(histodir + "/MC/pTReso/h3dAntiLambdaPtResoVsTPCCR", "h3dAntiLambdaPtResoVsTPCCR", kTH3F, {axisInvPt, axisDeltaPt, axisTPCrows}); + histos.add(histodir + "/MC/pTReso/h3dAntiLambdaPtResoVsTPCCR", "h3dAntiLambdaPtResoVsTPCCR", kTH3F, {axisInvPt, axisDeltaPt, axisTPCrows}); + histos.add(histodir + "/MC/pTReso/h2dSigma0PtResolution", "h2dSigma0PtResolution", kTH2F, {axisInvPt, axisDeltaPt}); + histos.add(histodir + "/MC/pTReso/h2dAntiSigma0PtResolution", "h2dAntiSigma0PtResolution", kTH2F, {axisInvPt, axisDeltaPt}); + } + + // For background decomposition study + if (fillBkgQAhistos) { + histos.add(histodir + "/MC/BkgStudy/h2dPtVsMassSigma_All", "h2dPtVsMassSigma_All", kTH2F, {axisPt, axisSigmaMass}); + histos.add(histodir + "/MC/BkgStudy/h2dPtVsMassSigma_TrueDaughters", "h2dPtVsMassSigma_TrueDaughters", kTH2F, {axisPt, axisSigmaMass}); + histos.add(histodir + "/MC/BkgStudy/h2dTrueDaughtersMatrix", "h2dTrueDaughtersMatrix", kTHnSparseD, {{10001, -5000.5f, +5000.5f}, {10001, -5000.5f, +5000.5f}}); + histos.add(histodir + "/MC/BkgStudy/h2dPtVsMassSigma_TrueGammaFakeLambda", "h2dPtVsMassSigma_TrueGammaFakeLambda", kTH2F, {axisPt, axisSigmaMass}); + histos.add(histodir + "/MC/BkgStudy/h2dPtVsMassSigma_FakeGammaTrueLambda", "h2dPtVsMassSigma_FakeGammaTrueLambda", kTH2F, {axisPt, axisSigmaMass}); + histos.add(histodir + "/MC/BkgStudy/h2dPtVsMassSigma_FakeDaughters", "h2dPtVsMassSigma_FakeDaughters", kTH2F, {axisPt, axisSigmaMass}); + } + } + } + + // Selections + histos.add("Selection/Photon/hCandidateSel", "hCandidateSel", kTH1F, {axisCandSel}); + histos.add("Selection/Lambda/hCandidateSel", "hCandidateSel", kTH1F, {axisCandSel}); + + for (size_t i = 0; i < PhotonSels.size(); ++i) { + const auto& sel = PhotonSels[i]; + + histos.add(Form("Selection/Photon/h2d%s", sel.c_str()), ("h2d" + sel).c_str(), kTH2F, {axisPt, axisPhotonMass}); + histos.get(HIST("Selection/Photon/hCandidateSel"))->GetXaxis()->SetBinLabel(i + 1, sel.c_str()); + histos.add(Form("Selection/Sigma0/h2dPhoton%s", sel.c_str()), ("h2dPhoton" + sel).c_str(), kTH2F, {axisPt, axisSigmaMass}); + } + + for (size_t i = 0; i < LambdaSels.size(); ++i) { + const auto& sel = LambdaSels[i]; + + histos.add(Form("Selection/Lambda/h2d%s", sel.c_str()), ("h2d" + sel).c_str(), kTH2F, {axisPt, axisLambdaMass}); + histos.get(HIST("Selection/Lambda/hCandidateSel"))->GetXaxis()->SetBinLabel(i + 1, sel.c_str()); + histos.add(Form("Selection/Sigma0/h2dLambda%s", sel.c_str()), ("h2dLambda" + sel).c_str(), kTH2F, {axisPt, axisSigmaMass}); + } + } + + //__________________________________________ + template + int retrieveV0TrackCode(TV0Object const& sigma) + { + + int TrkCode = 10; // 1: TPC-only, 2: TPC+Something, 3: ITS-Only, 4: ITS+TPC + Something, 10: anything else + + if (isGamma) { + if (sigma.photonPosTrackCode() == 1 && sigma.photonNegTrackCode() == 1) + TrkCode = 1; + if ((sigma.photonPosTrackCode() != 1 && sigma.photonNegTrackCode() == 1) || (sigma.photonPosTrackCode() == 1 && sigma.photonNegTrackCode() != 1)) + TrkCode = 2; + if (sigma.photonPosTrackCode() == 3 && sigma.photonNegTrackCode() == 3) + TrkCode = 3; + if (sigma.photonPosTrackCode() == 2 || sigma.photonNegTrackCode() == 2) + TrkCode = 4; + } else { + if (sigma.lambdaPosTrackCode() == 1 && sigma.lambdaNegTrackCode() == 1) + TrkCode = 1; + if ((sigma.lambdaPosTrackCode() != 1 && sigma.lambdaNegTrackCode() == 1) || (sigma.lambdaPosTrackCode() == 1 && sigma.lambdaNegTrackCode() != 1)) + TrkCode = 2; + if (sigma.lambdaPosTrackCode() == 3 && sigma.lambdaNegTrackCode() == 3) + TrkCode = 3; + if (sigma.lambdaPosTrackCode() == 2 || sigma.lambdaNegTrackCode() == 2) + TrkCode = 4; } + + return TrkCode; } - // Apply selections in sigma candidates template - bool processSigmaCandidate(TV0Object const& cand) + void getpTResolution(TV0Object const& sigma) { - if (fUseMLSel) { - if ((cand.gammaBDTScore() == -1) || (cand.lambdaBDTScore() == -1) || (cand.antilambdaBDTScore() == -1)) { - LOGF(fatal, "ML Score is not available! Please, enable gamma and lambda selection with ML in sigmabuilder!"); + + //_______________________________________ + // Gamma MC association + if (sigma.photonCandPDGCode() == 22) { + if (sigma.photonMCPt() > 0) { + histos.fill(HIST("BeforeSel/MC/pTReso/h3dGammaPtResoVsTPCCR"), 1.f / sigma.lambdaMCPt(), 1.f / sigma.lambdaPt() - 1.f / sigma.lambdaMCPt(), -1 * sigma.photonNegTPCCrossedRows()); // 1/pT resolution + histos.fill(HIST("BeforeSel/MC/pTReso/h3dGammaPtResoVsTPCCR"), 1.f / sigma.lambdaMCPt(), 1.f / sigma.lambdaPt() - 1.f / sigma.lambdaMCPt(), sigma.photonPosTPCCrossedRows()); // 1/pT resolution + histos.fill(HIST("BeforeSel/MC/pTReso/h2dGammaPtResolution"), 1.f / sigma.photonMCPt(), 1.f / sigma.photonPt() - 1.f / sigma.photonMCPt()); // pT resolution } - // Gamma selection: - if (cand.gammaBDTScore() <= Gamma_MLThreshold) - return false; + } - // Lambda selection: - if (cand.lambdaBDTScore() <= Lambda_MLThreshold) - return false; + //_______________________________________ + // Lambda MC association + if (sigma.lambdaCandPDGCode() == 3122) { + if (sigma.lambdaMCPt() > 0) { + histos.fill(HIST("BeforeSel/MC/pTReso/h2dLambdaPtResolution"), 1.f / sigma.lambdaMCPt(), 1.f / sigma.lambdaPt() - 1.f / sigma.lambdaMCPt()); // 1/pT resolution + histos.fill(HIST("BeforeSel/MC/pTReso/h3dLambdaPtResoVsTPCCR"), 1.f / sigma.lambdaMCPt(), 1.f / sigma.lambdaPt() - 1.f / sigma.lambdaMCPt(), -1 * sigma.lambdaNegTPCCrossedRows()); // 1/pT resolution + histos.fill(HIST("BeforeSel/MC/pTReso/h3dLambdaPtResoVsTPCCR"), 1.f / sigma.lambdaMCPt(), 1.f / sigma.lambdaPt() - 1.f / sigma.lambdaMCPt(), sigma.lambdaPosTPCCrossedRows()); // 1/pT resolution + } + } - // AntiLambda selection: - if (cand.antilambdaBDTScore() <= AntiLambda_MLThreshold) - return false; + //_______________________________________ + // AntiLambda MC association + if (sigma.lambdaCandPDGCode() == -3122) { + if (sigma.lambdaMCPt() > 0) { + histos.fill(HIST("BeforeSel/MC/pTReso/h2dAntiLambdaPtResolution"), 1.f / sigma.lambdaMCPt(), 1.f / sigma.lambdaPt() - 1.f / sigma.lambdaMCPt()); // pT resolution + histos.fill(HIST("BeforeSel/MC/pTReso/h3dAntiLambdaPtResoVsTPCCR"), 1.f / sigma.lambdaMCPt(), 1.f / sigma.lambdaPt() - 1.f / sigma.lambdaMCPt(), -1 * sigma.lambdaNegTPCCrossedRows()); // 1/pT resolution + histos.fill(HIST("BeforeSel/MC/pTReso/h3dAntiLambdaPtResoVsTPCCR"), 1.f / sigma.lambdaMCPt(), 1.f / sigma.lambdaPt() - 1.f / sigma.lambdaMCPt(), sigma.lambdaPosTPCCrossedRows()); // 1/pT resolution + } + } + + //_______________________________________ + // Sigma and AntiSigma MC association + if (sigma.isSigma()) { + if (sigma.sigmaMCPt() > 0) + histos.fill(HIST("BeforeSel/MC/pTReso/h2dSigma0PtResolution"), 1.f / sigma.sigmaMCPt(), 1.f / sigma.sigmapT() - 1.f / sigma.sigmaMCPt()); // pT resolution + } + if (sigma.isAntiSigma()) { + if (sigma.sigmaMCPt() > 0) + histos.fill(HIST("BeforeSel/MC/pTReso/h2dAntiSigma0PtResolution"), 1.f / sigma.sigmaMCPt(), 1.f / sigma.sigmapT() - 1.f / sigma.sigmaMCPt()); // pT resolution + } + } + + // To save histograms for background analysis + template + void runBkgAnalysis(TV0Object const& sigma) + { + // Check whether it is before or after selections + static constexpr std::string_view MainDir[] = {"BeforeSel", "AfterSel"}; + + bool fIsSigma = sigma.isSigma(); + bool fIsAntiSigma = sigma.isAntiSigma(); + int PhotonPDGCode = sigma.photonCandPDGCode(); + int PhotonPDGCodeMother = sigma.photonCandPDGCodeMother(); + int LambdaPDGCode = sigma.lambdaCandPDGCode(); + int LambdaPDGCodeMother = sigma.lambdaCandPDGCodeMother(); + float sigmapT = sigma.sigmapT(); + float sigmaMass = sigma.sigmaMass(); + + histos.fill(HIST(MainDir[mode]) + HIST("/MC/BkgStudy/h2dPtVsMassSigma_All"), sigmapT, sigmaMass); + + //_______________________________________ + // Real Gamma x Real Lambda - but not from the same sigma0/antisigma0! + if ((PhotonPDGCode == 22) && ((LambdaPDGCode == 3122) || (LambdaPDGCode == -3122)) && (!fIsSigma && !fIsAntiSigma)) { + histos.fill(HIST(MainDir[mode]) + HIST("/MC/BkgStudy/h2dPtVsMassSigma_TrueDaughters"), sigmapT, sigmaMass); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/BkgStudy/h2dTrueDaughtersMatrix"), LambdaPDGCodeMother, PhotonPDGCodeMother); + } + + //_______________________________________ + // Real Gamma x fake Lambda + if ((PhotonPDGCode == 22) && (LambdaPDGCode != 3122) && (LambdaPDGCode != -3122)) + histos.fill(HIST(MainDir[mode]) + HIST("/MC/BkgStudy/h2dPtVsMassSigma_TrueGammaFakeLambda"), sigmapT, sigmaMass); + + //_______________________________________ + // Fake Gamma x Real Lambda + if ((PhotonPDGCode != 22) && ((LambdaPDGCode == 3122) || (LambdaPDGCode == -3122))) + histos.fill(HIST(MainDir[mode]) + HIST("/MC/BkgStudy/h2dPtVsMassSigma_FakeGammaTrueLambda"), sigmapT, sigmaMass); + + //_______________________________________ + // Fake Gamma x Fake Lambda + if ((PhotonPDGCode != 22) && (LambdaPDGCode != 3122) && (LambdaPDGCode != -3122)) + histos.fill(HIST(MainDir[mode]) + HIST("/MC/BkgStudy/h2dPtVsMassSigma_FakeDaughters"), sigmapT, sigmaMass); + } + + template + void fillQAHistos(TV0Object const& sigma) + { + + // Check whether it is before or after selections + // static std::string main_dir; + // main_dir = IsBeforeSel ? "BeforeSel" : "AfterSel"; + static constexpr std::string_view MainDir[] = {"BeforeSel", "AfterSel"}; + + // Get V0trackCode + int GammaTrkCode = retrieveV0TrackCode(sigma); + int LambdaTrkCode = retrieveV0TrackCode(sigma); + + float photonRZLineCut = TMath::Abs(sigma.photonZconv()) * TMath::Tan(2 * TMath::ATan(TMath::Exp(-PhotonMaxDauEta))) - PhotonLineCutZ0; + //_______________________________________ + // Photon + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hTrackCode"), GammaTrkCode); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hV0Type"), sigma.photonV0Type()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hNegpT"), sigma.photonNegPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hPospT"), sigma.photonPosPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hDCANegToPV"), sigma.photonDCANegPV()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hDCAPosToPV"), sigma.photonDCAPosPV()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hDCADau"), sigma.photonDCADau()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hPosTPCCR"), sigma.photonPosTPCCrossedRows()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hNegTPCCR"), sigma.photonNegTPCCrossedRows()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/h2dPosTPCNSigmaEl"), sigma.photonPosPt(), sigma.photonPosTPCNSigmaEl()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/h2dNegTPCNSigmaEl"), sigma.photonNegPt(), sigma.photonNegTPCNSigmaEl()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/h2dPosTPCNSigmaPi"), sigma.photonPosPt(), sigma.photonPosTPCNSigmaPi()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/h2dNegTPCNSigmaPi"), sigma.photonNegPt(), sigma.photonNegTPCNSigmaPi()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hpT"), sigma.photonPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hY"), sigma.photonY()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hPosEta"), sigma.photonPosEta()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hNegEta"), sigma.photonNegEta()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hRadius"), sigma.photonRadius()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hZ"), sigma.photonZconv()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/h2dRZCut"), sigma.photonRadius(), photonRZLineCut); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/h2dRZPlane"), sigma.photonZconv(), sigma.photonRadius()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hCosPA"), sigma.photonCosPA()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hPsiPair"), sigma.photonPsiPair()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hPhi"), sigma.photonPhi()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/h3dMass"), sigma.sigmaCentrality(), sigma.photonPt(), sigma.photonMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/Photon/hMass"), sigma.photonMass()); + + //_______________________________________ + // Lambdas + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hTrackCode"), LambdaTrkCode); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hRadius"), sigma.lambdaRadius()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hDCADau"), sigma.lambdaDCADau()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hCosPA"), sigma.lambdaCosPA()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hY"), sigma.lambdaY()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hPosEta"), sigma.lambdaPosEta()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hNegEta"), sigma.lambdaNegEta()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hPosTPCCR"), sigma.lambdaPosTPCCrossedRows()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hNegTPCCR"), sigma.lambdaNegTPCCrossedRows()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hPosITSCls"), sigma.lambdaPosITSCls()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hNegITSCls"), sigma.lambdaNegITSCls()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hPosChi2PerNc"), sigma.lambdaPosChi2PerNcl()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hNegChi2PerNc"), sigma.lambdaNegChi2PerNcl()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hLifeTime"), sigma.lambdaLifeTime()); + + //_______________________________________ + // Sigmas and Lambdas + histos.fill(HIST(MainDir[mode]) + HIST("/h2dArmenteros"), sigma.photonAlpha(), sigma.photonQt()); + histos.fill(HIST(MainDir[mode]) + HIST("/h2dArmenteros"), sigma.lambdaAlpha(), sigma.lambdaQt()); + + if (sigma.lambdaAlpha() > 0) { + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/h2dTPCvsTOFNSigma_LambdaPr"), sigma.lambdaPosPrTPCNSigma(), sigma.lambdaPrTOFNSigma()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/h2dTPCvsTOFNSigma_LambdaPi"), sigma.lambdaNegPiTPCNSigma(), sigma.lambdaPiTOFNSigma()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hLambdaDCANegToPV"), sigma.lambdaDCANegPV()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hLambdaDCAPosToPV"), sigma.lambdaDCAPosPV()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hLambdapT"), sigma.lambdaPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hLambdaMass"), sigma.lambdaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/h3dLambdaMass"), sigma.sigmaCentrality(), sigma.lambdaPt(), sigma.lambdaMass()); + + histos.fill(HIST(MainDir[mode]) + HIST("/Sigma0/hMass"), sigma.sigmaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/Sigma0/hPt"), sigma.sigmapT()); + histos.fill(HIST(MainDir[mode]) + HIST("/Sigma0/hY"), sigma.sigmaRapidity()); + histos.fill(HIST(MainDir[mode]) + HIST("/Sigma0/h3dMass"), sigma.sigmaCentrality(), sigma.sigmapT(), sigma.sigmaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/Sigma0/h3dPhotonRadiusVsMassSigma"), sigma.sigmaCentrality(), sigma.photonRadius(), sigma.sigmaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/Sigma0/h2dpTVsOPAngle"), sigma.sigmapT(), sigma.sigmaOPAngle()); } else { + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/h2dTPCvsTOFNSigma_ALambdaPr"), sigma.lambdaNegPrTPCNSigma(), sigma.aLambdaPrTOFNSigma()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/h2dTPCvsTOFNSigma_ALambdaPi"), sigma.lambdaPosPiTPCNSigma(), sigma.aLambdaPiTOFNSigma()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hALambdaDCANegToPV"), sigma.lambdaDCANegPV()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hALambdaDCAPosToPV"), sigma.lambdaDCAPosPV()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hALambdapT"), sigma.lambdaPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/hAntiLambdaMass"), sigma.antilambdaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/Lambda/h3dAntiLambdaMass"), sigma.sigmaCentrality(), sigma.lambdaPt(), sigma.antilambdaMass()); + + histos.fill(HIST(MainDir[mode]) + HIST("/ASigma0/hMass"), sigma.sigmaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/ASigma0/hPt"), sigma.sigmapT()); + histos.fill(HIST(MainDir[mode]) + HIST("/ASigma0/hY"), sigma.sigmaRapidity()); + histos.fill(HIST(MainDir[mode]) + HIST("/ASigma0/h3dMass"), sigma.sigmaCentrality(), sigma.sigmapT(), sigma.sigmaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/ASigma0/h3dPhotonRadiusVsMassSigma"), sigma.sigmaCentrality(), sigma.photonRadius(), sigma.sigmaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/ASigma0/h2dpTVsOPAngle"), sigma.sigmapT(), sigma.sigmaOPAngle()); + } - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 1.); - histos.fill(HIST("GeneralQA/hPhotonMass"), cand.photonMass()); - if (TMath::Abs(cand.photonMass()) > PhotonMaxMass) - return false; - histos.fill(HIST("GeneralQA/hPhotonNegpT"), cand.photonNegPt()); - histos.fill(HIST("GeneralQA/hPhotonPospT"), cand.photonPosPt()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 2.); - if ((cand.photonPosPt() < PhotonDauMinPt) || (cand.photonNegPt() < PhotonDauMinPt)) - return false; - histos.fill(HIST("GeneralQA/hPhotonDCANegToPV"), cand.photonDCANegPV()); - histos.fill(HIST("GeneralQA/hPhotonDCAPosToPV"), cand.photonDCAPosPV()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 3.); - if ((TMath::Abs(cand.photonDCAPosPV()) < PhotonMinDCADauToPv) || (TMath::Abs(cand.photonDCANegPV()) < PhotonMinDCADauToPv)) - return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 4.); - histos.fill(HIST("GeneralQA/hPhotonDCADau"), cand.photonDCADau()); - if (TMath::Abs(cand.photonDCADau()) > PhotonMaxDCAV0Dau) - return false; - histos.fill(HIST("GeneralQA/hPhotonPosTPCCR"), cand.photonPosTPCCrossedRows()); - histos.fill(HIST("GeneralQA/hPhotonNegTPCCR"), cand.photonNegTPCCrossedRows()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 5.); - if ((cand.photonPosTPCCrossedRows() < PhotonMinTPCCrossedRows) || (cand.photonNegTPCCrossedRows() < PhotonMinTPCCrossedRows)) - return false; - histos.fill(HIST("GeneralQA/hPhotonPosTPCNSigma"), cand.photonPosTPCNSigma()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 6.); - if ((cand.photonPosTPCNSigma() != -999.f) && ((cand.photonPosTPCNSigma() < PhotonMinTPCNSigmas) || (cand.photonPosTPCNSigma() > PhotonMaxTPCNSigmas))) - return false; - histos.fill(HIST("GeneralQA/hPhotonNegTPCNSigma"), cand.photonNegTPCNSigma()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 7.); - if ((cand.photonNegTPCNSigma() != -999.f) && ((cand.photonNegTPCNSigma() < PhotonMinTPCNSigmas) || (cand.photonNegTPCNSigma() > PhotonMaxTPCNSigmas))) - return false; - histos.fill(HIST("GeneralQA/hPhotonpT"), cand.photonPt()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 8.); - if ((cand.photonPt() < PhotonMinPt) || (cand.photonPt() > PhotonMaxPt)) - return false; - histos.fill(HIST("GeneralQA/hPhotonY"), cand.photonY()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 9.); - if ((TMath::Abs(cand.photonY()) > PhotonMaxRap)) - return false; - histos.fill(HIST("GeneralQA/hPhotonRadius"), cand.photonRadius()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 10.); - if ((cand.photonRadius() < PhotonMinRadius) || (cand.photonRadius() > PhotonMaxRadius)) - return false; - histos.fill(HIST("GeneralQA/hPhotonZ"), cand.photonZconv()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 11.); - if (TMath::Abs(cand.photonZconv()) > PhotonMaxZ) + //_______________________________________ + // MC specific + if (doprocessMonteCarlo) { + if constexpr (requires { sigma.lambdaCandPDGCode(); sigma.photonCandPDGCode(); }) { + + //_______________________________________ + // Gamma MC association + if (sigma.photonCandPDGCode() == 22) { + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/hV0ToCollAssoc"), sigma.photonIsCorrectlyAssoc()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/hPt"), sigma.photonPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/hMCPt"), sigma.photonMCPt()); + + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/h2dPosTPCNSigmaEl"), sigma.photonPosPt(), sigma.photonPosTPCNSigmaEl()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/h2dNegTPCNSigmaEl"), sigma.photonNegPt(), sigma.photonNegTPCNSigmaEl()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/h2dPosTPCNSigmaPi"), sigma.photonPosPt(), sigma.photonPosTPCNSigmaPi()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/h2dNegTPCNSigmaPi"), sigma.photonNegPt(), sigma.photonNegTPCNSigmaPi()); + + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/h2dPAVsPt"), TMath::ACos(sigma.photonCosPA()), sigma.photonMCPt()); + + if (!sigma.photonIsCorrectlyAssoc()) { + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/hPt_BadCollAssig"), sigma.photonMCPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Photon/h2dPAVsPt_BadCollAssig"), TMath::ACos(sigma.photonCosPA()), sigma.photonMCPt()); + } + } + + //_______________________________________ + // Lambda MC association + if (sigma.lambdaCandPDGCode() == 3122) { + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Lambda/hV0ToCollAssoc"), sigma.lambdaIsCorrectlyAssoc()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Lambda/hPt"), sigma.lambdaPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Lambda/hMCPt"), sigma.lambdaMCPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Lambda/h3dTPCvsTOFNSigma_Pr"), sigma.lambdaPosPrTPCNSigma(), sigma.lambdaPrTOFNSigma(), sigma.lambdaPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Lambda/h3dTPCvsTOFNSigma_Pi"), sigma.lambdaNegPiTPCNSigma(), sigma.lambdaPiTOFNSigma(), sigma.lambdaPt()); + } + + //_______________________________________ + // AntiLambda MC association + if (sigma.lambdaCandPDGCode() == -3122) { + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ALambda/hV0ToCollAssoc"), sigma.lambdaIsCorrectlyAssoc()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ALambda/hPt"), sigma.lambdaPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ALambda/hMCPt"), sigma.lambdaMCPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ALambda/h3dTPCvsTOFNSigma_Pr"), sigma.lambdaNegPrTPCNSigma(), sigma.aLambdaPrTOFNSigma(), sigma.lambdaPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ALambda/h3dTPCvsTOFNSigma_Pi"), sigma.lambdaPosPiTPCNSigma(), sigma.aLambdaPiTOFNSigma(), sigma.lambdaPt()); + } + + //_______________________________________ + // Sigma0 MC association + if (sigma.isSigma()) { + histos.fill(HIST(MainDir[mode]) + HIST("/MC/h2dArmenteros"), sigma.photonAlpha(), sigma.photonQt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/h2dArmenteros"), sigma.lambdaAlpha(), sigma.lambdaQt()); + + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Sigma0/hPt"), sigma.sigmapT()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Sigma0/hMCPt"), sigma.sigmaMCPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Sigma0/h2dMCPtVsLambdaMCPt"), sigma.sigmaMCPt(), sigma.lambdaMCPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Sigma0/h2dMCPtVsGammaMCPt"), sigma.sigmaMCPt(), sigma.photonMCPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Sigma0/hMass"), sigma.sigmaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/Sigma0/h3dMass"), sigma.sigmaCentrality(), sigma.sigmapT(), sigma.sigmaMass()); + } + + //_______________________________________ + // AntiSigma0 MC association + if (sigma.isAntiSigma()) { + histos.fill(HIST(MainDir[mode]) + HIST("/MC/h2dArmenteros"), sigma.photonAlpha(), sigma.photonQt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/h2dArmenteros"), sigma.lambdaAlpha(), sigma.lambdaQt()); + + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ASigma0/hPt"), sigma.sigmapT()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ASigma0/hMCPt"), sigma.sigmaMCPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ASigma0/h2dMCPtVsLambdaMCPt"), sigma.sigmaMCPt(), sigma.lambdaMCPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ASigma0/h2dMCPtVsPhotonMCPt"), sigma.sigmaMCPt(), sigma.photonMCPt()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ASigma0/hMass"), sigma.sigmaMass()); + histos.fill(HIST(MainDir[mode]) + HIST("/MC/ASigma0/h3dMass"), sigma.sigmaCentrality(), sigma.sigmapT(), sigma.sigmaMass()); + } + + // For background studies: + if (fillBkgQAhistos) + runBkgAnalysis(sigma); + + //_______________________________________ + // pT resolution histos + if ((mode == 0) && fillpTResoQAhistos) + getpTResolution(sigma); + } + } + } + + template + void fillSelHistos(TV0Object const& sigma, int PDGRequired) + { + + static constexpr std::string_view PhotonSelsLocal[] = {"NoSel", "V0Type", "DaupT", "DCADauToPV", + "DCADau", "DauTPCCR", "TPCNSigmaEl", "V0pT", + "Y", "V0Radius", "RZCut", "Armenteros", "CosPA", + "PsiPair", "Phi", "Mass"}; + + static constexpr std::string_view LambdaSelsLocal[] = {"NoSel", "V0Radius", "DCADau", "Armenteros", + "CosPA", "Y", "TPCCR", "DauITSCls", "Lifetime", + "TPCTOFPID", "DCADauToPV", "Mass"}; + + if (PDGRequired == 22) { + if constexpr (selection_index >= 0 && selection_index < (int)std::size(PhotonSelsLocal)) { + histos.fill(HIST("Selection/Photon/hCandidateSel"), selection_index); + histos.fill(HIST("Selection/Photon/h2d") + HIST(PhotonSelsLocal[selection_index]), sigma.photonPt(), sigma.photonMass()); + histos.fill(HIST("Selection/Sigma0/h2dPhoton") + HIST(PhotonSelsLocal[selection_index]), sigma.sigmapT(), sigma.sigmaMass()); + } + } + + if (PDGRequired == 3122) { + if constexpr (selection_index >= 0 && selection_index < (int)std::size(LambdaSelsLocal)) { + histos.fill(HIST("Selection/Lambda/hCandidateSel"), selection_index); + histos.fill(HIST("Selection/Lambda/h2d") + HIST(LambdaSelsLocal[selection_index]), sigma.lambdaPt(), sigma.lambdaMass()); + histos.fill(HIST("Selection/Sigma0/h2dLambda") + HIST(LambdaSelsLocal[selection_index]), sigma.sigmapT(), sigma.sigmaMass()); + } + } + } + + // Apply specific selections for photons + template + bool selectPhoton(TV0Object const& cand) + { + fillSelHistos<0>(cand, 22); + if (cand.photonV0Type() != Photonv0TypeSel && Photonv0TypeSel > -1) + return false; + + fillSelHistos<1>(cand, 22); + if ((cand.photonPosPt() < PhotonDauMinPt) || (cand.photonNegPt() < PhotonDauMinPt)) + return false; + + fillSelHistos<2>(cand, 22); + if ((TMath::Abs(cand.photonDCAPosPV()) < PhotonMinDCADauToPv) || (TMath::Abs(cand.photonDCANegPV()) < PhotonMinDCADauToPv)) + return false; + + fillSelHistos<3>(cand, 22); + if (TMath::Abs(cand.photonDCADau()) > PhotonMaxDCAV0Dau) + return false; + + fillSelHistos<4>(cand, 22); + if ((cand.photonPosTPCCrossedRows() < PhotonMinTPCCrossedRows) || (cand.photonNegTPCCrossedRows() < PhotonMinTPCCrossedRows)) + return false; + + fillSelHistos<5>(cand, 22); + if (((cand.photonPosTPCNSigmaEl() < PhotonMinTPCNSigmas) || (cand.photonPosTPCNSigmaEl() > PhotonMaxTPCNSigmas))) + return false; + + if (((cand.photonNegTPCNSigmaEl() < PhotonMinTPCNSigmas) || (cand.photonNegTPCNSigmaEl() > PhotonMaxTPCNSigmas))) + return false; + + fillSelHistos<6>(cand, 22); + if ((cand.photonPt() < PhotonMinPt) || (cand.photonPt() > PhotonMaxPt)) + return false; + + fillSelHistos<7>(cand, 22); + if ((TMath::Abs(cand.photonY()) > PhotonMaxRap) || (TMath::Abs(cand.photonPosEta()) > PhotonMaxDauEta) || (TMath::Abs(cand.photonNegEta()) > PhotonMaxDauEta)) + return false; + + fillSelHistos<8>(cand, 22); + if ((cand.photonRadius() < PhotonMinRadius) || (cand.photonRadius() > PhotonMaxRadius)) + return false; + + fillSelHistos<9>(cand, 22); + float photonRZLineCut = TMath::Abs(cand.photonZconv()) * TMath::Tan(2 * TMath::ATan(TMath::Exp(-PhotonMaxDauEta))) - PhotonLineCutZ0; + if ((TMath::Abs(cand.photonRadius()) < photonRZLineCut) || (TMath::Abs(cand.photonZconv()) > PhotonMaxZ)) + return false; + + fillSelHistos<10>(cand, 22); + if (cand.photonQt() > PhotonMaxQt) + return false; + + if (TMath::Abs(cand.photonAlpha()) > PhotonMaxAlpha) + return false; + + fillSelHistos<11>(cand, 22); + if (cand.photonCosPA() < PhotonMinV0cospa) + return false; + + fillSelHistos<12>(cand, 22); + if (TMath::Abs(cand.photonPsiPair()) > PhotonPsiPairMax) + return false; + + fillSelHistos<13>(cand, 22); + if ((((cand.photonPhi() > PhotonPhiMin1) && (cand.photonPhi() < PhotonPhiMax1)) || ((cand.photonPhi() > PhotonPhiMin2) && (cand.photonPhi() < PhotonPhiMax2))) && ((PhotonPhiMin1 != -1) && (PhotonPhiMax1 != -1) && (PhotonPhiMin2 != -1) && (PhotonPhiMax2 != -1))) + return false; + + fillSelHistos<14>(cand, 22); + if (TMath::Abs(cand.photonMass()) > PhotonMaxMass) + return false; + + fillSelHistos<15>(cand, 22); + return true; + } + + // Apply specific selections for lambdas + template + bool selectLambda(TV0Object const& cand) + { + fillSelHistos<0>(cand, 3122); + if ((cand.lambdaRadius() < LambdaMinv0radius) || (cand.lambdaRadius() > LambdaMaxv0radius)) + return false; + + fillSelHistos<1>(cand, 3122); + if (TMath::Abs(cand.lambdaDCADau()) > LambdaMaxDCAV0Dau) + return false; + + fillSelHistos<2>(cand, 3122); + if ((cand.lambdaQt() < LambdaMinQt) || (cand.lambdaQt() > LambdaMaxQt)) + return false; + + if ((TMath::Abs(cand.lambdaAlpha()) < LambdaMinAlpha) || (TMath::Abs(cand.lambdaAlpha()) > LambdaMaxAlpha)) + return false; + + fillSelHistos<3>(cand, 3122); + if (cand.lambdaCosPA() < LambdaMinv0cospa) + return false; + + fillSelHistos<4>(cand, 3122); + if ((TMath::Abs(cand.lambdaY()) > LambdaMaxRap) || (TMath::Abs(cand.lambdaPosEta()) > LambdaMaxDauEta) || (TMath::Abs(cand.lambdaNegEta()) > LambdaMaxDauEta)) + return false; + + fillSelHistos<5>(cand, 3122); + if ((cand.lambdaPosTPCCrossedRows() < LambdaMinTPCCrossedRows) || (cand.lambdaNegTPCCrossedRows() < LambdaMinTPCCrossedRows)) + return false; + + fillSelHistos<6>(cand, 3122); + // check minimum number of ITS clusters + reject ITS afterburner tracks if requested + bool posIsFromAfterburner = cand.lambdaPosChi2PerNcl() < 0; + bool negIsFromAfterburner = cand.lambdaNegChi2PerNcl() < 0; + if (cand.lambdaPosITSCls() < LambdaMinITSclusters && (!LambdaRejectPosITSafterburner || posIsFromAfterburner)) + return false; + if (cand.lambdaNegITSCls() < LambdaMinITSclusters && (!LambdaRejectNegITSafterburner || negIsFromAfterburner)) + return false; + + fillSelHistos<7>(cand, 3122); + if (cand.lambdaLifeTime() > LambdaMaxLifeTime) + return false; + + // Separating lambda and antilambda selections: + fillSelHistos<8>(cand, 3122); + if (cand.lambdaAlpha() > 0) { // Lambda selection + // TPC Selection + if (fselLambdaTPCPID && (TMath::Abs(cand.lambdaPosPrTPCNSigma()) > LambdaMaxTPCNSigmas)) return false; - histos.fill(HIST("GeneralQA/h2dPhotonArmenteros"), cand.photonAlpha(), cand.photonQt()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 12.); - if (cand.photonQt() > PhotonMaxQt) + if (fselLambdaTPCPID && (TMath::Abs(cand.lambdaNegPiTPCNSigma()) > LambdaMaxTPCNSigmas)) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 13.); - if (TMath::Abs(cand.photonAlpha()) > PhotonMaxAlpha) + + // TOF Selection + if (fselLambdaTOFPID && (TMath::Abs(cand.lambdaPrTOFNSigma()) > LambdaPrMaxTOFNSigmas)) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 14.); - histos.fill(HIST("GeneralQA/hPhotonCosPA"), cand.photonCosPA()); - if (cand.photonCosPA() < PhotonMinV0cospa) + if (fselLambdaTOFPID && (TMath::Abs(cand.lambdaPiTOFNSigma()) > LambdaPiMaxTOFNSigmas)) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 15.); - // Lambda selection - histos.fill(HIST("GeneralQA/hLambdaMass"), cand.lambdaMass()); - histos.fill(HIST("GeneralQA/hAntiLambdaMass"), cand.antilambdaMass()); - if ((TMath::Abs(cand.lambdaMass() - 1.115683) > LambdaWindow) && (TMath::Abs(cand.antilambdaMass() - 1.115683) > LambdaWindow)) - return false; - histos.fill(HIST("GeneralQA/hLambdaDCANegToPV"), cand.lambdaDCANegPV()); - histos.fill(HIST("GeneralQA/hLambdaDCAPosToPV"), cand.lambdaDCAPosPV()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 16.); + // DCA Selection + fillSelHistos<9>(cand, 3122); if ((TMath::Abs(cand.lambdaDCAPosPV()) < LambdaMinDCAPosToPv) || (TMath::Abs(cand.lambdaDCANegPV()) < LambdaMinDCANegToPv)) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 17.); - histos.fill(HIST("GeneralQA/hLambdaRadius"), cand.lambdaRadius()); - if ((cand.lambdaRadius() < LambdaMinv0radius) || (cand.lambdaRadius() > LambdaMaxv0radius)) + + // Mass Selection + fillSelHistos<10>(cand, 3122); + if (TMath::Abs(cand.lambdaMass() - o2::constants::physics::MassLambda0) > LambdaWindow) return false; - histos.fill(HIST("GeneralQA/hLambdaDCADau"), cand.lambdaDCADau()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 18.); - if (TMath::Abs(cand.lambdaDCADau()) > LambdaMaxDCAV0Dau) + + fillSelHistos<11>(cand, 3122); + + } else { // AntiLambda selection + + // TPC Selection + if (fselLambdaTPCPID && (TMath::Abs(cand.lambdaPosPiTPCNSigma()) > LambdaMaxTPCNSigmas)) return false; - histos.fill(HIST("GeneralQA/h2dLambdaArmenteros"), cand.lambdaAlpha(), cand.lambdaQt()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 19.); - if ((cand.lambdaQt() < LambdaMinQt) || (cand.lambdaQt() > LambdaMaxQt)) + if (fselLambdaTPCPID && (TMath::Abs(cand.lambdaNegPrTPCNSigma()) > LambdaMaxTPCNSigmas)) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 20.); - if ((TMath::Abs(cand.lambdaAlpha()) < LambdaMinAlpha) || (TMath::Abs(cand.lambdaAlpha()) > LambdaMaxAlpha)) + + // TOF Selection + if (fselLambdaTOFPID && (TMath::Abs(cand.aLambdaPrTOFNSigma()) > LambdaPrMaxTOFNSigmas)) return false; - histos.fill(HIST("GeneralQA/hLambdaCosPA"), cand.lambdaCosPA()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 21.); - if (cand.lambdaCosPA() < LambdaMinv0cospa) + if (fselLambdaTOFPID && (TMath::Abs(cand.aLambdaPiTOFNSigma()) > LambdaPiMaxTOFNSigmas)) return false; - histos.fill(HIST("GeneralQA/hLambdaY"), cand.lambdaY()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 22.); - if (TMath::Abs(cand.lambdaY()) > LambdaMaxRap) + + // DCA Selection + fillSelHistos<9>(cand, 3122); + if ((TMath::Abs(cand.lambdaDCAPosPV()) < ALambdaMinDCAPosToPv) || (TMath::Abs(cand.lambdaDCANegPV()) < ALambdaMinDCANegToPv)) return false; - histos.fill(HIST("GeneralQA/hSigmaY"), cand.sigmaRapidity()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 23.); - if (TMath::Abs(cand.sigmaRapidity()) > SigmaMaxRap) + + // Mass Selection + fillSelHistos<10>(cand, 3122); + if (TMath::Abs(cand.antilambdaMass() - o2::constants::physics::MassLambda0) > LambdaWindow) return false; - histos.fill(HIST("GeneralQA/hSigmaOPAngle"), cand.sigmaOPAngle()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 24.); + + fillSelHistos<11>(cand, 3122); } + return true; } - // Apply selections in sigma candidates + + // Apply selections in sigma0 candidates template - bool doLambdaPIDSel(TV0Object const& cand, bool isLambdalike, bool doPIDQA) + bool processSigmaCandidate(TV0Object const& cand) { - bool passedTPC = true; - bool passedTOF = true; - - if (isLambdalike) { // Lambda PID selection - // TPC Selection - if (fselLambdaTPCPID && (cand.lambdaPosPrTPCNSigma() != -999.f) && (TMath::Abs(cand.lambdaPosPrTPCNSigma()) > LambdaMaxTPCNSigmas)) - passedTPC = false; - if (fselLambdaTPCPID && (cand.lambdaNegPiTPCNSigma() != -999.f) && (TMath::Abs(cand.lambdaNegPiTPCNSigma()) > LambdaMaxTPCNSigmas)) - passedTPC = false; - // TOF Selection - if (fselLambdaTOFPID && (cand.lambdaPrTOFNSigma() != -1e+3) && (TMath::Abs(cand.lambdaPrTOFNSigma()) > LambdaMaxTOFNSigmas)) - passedTOF = false; - if (fselLambdaTOFPID && (cand.lambdaPiTOFNSigma() != -1e+3) && (TMath::Abs(cand.lambdaPiTOFNSigma()) > LambdaMaxTOFNSigmas)) - passedTOF = false; - - if constexpr (requires { cand.lambdaCandPDGCode(); }) { - if (doPIDQA && passedTPC) { - histos.fill(HIST("MC/hPtLambdaCandidates_passedTPCPID"), cand.lambdaPt()); - if (cand.lambdaCandPDGCode() == 3122) - histos.fill(HIST("MC/hPtTrueLambda_passedTPCPID"), cand.lambdaPt()); - } - if (doPIDQA && passedTOF) { - histos.fill(HIST("MC/hPtLambdaCandidates_passedTOFPID"), cand.lambdaPt()); - if (cand.lambdaCandPDGCode() == 3122) - histos.fill(HIST("MC/hPtTrueLambda_passedTOFPID"), cand.lambdaPt()); - } - if (doPIDQA && passedTPC && passedTOF) { - histos.fill(HIST("MC/hPtLambdaCandidates_passedTPCTOFPID"), cand.lambdaPt()); - if (cand.lambdaCandPDGCode() == 3122) - histos.fill(HIST("MC/hPtTrueLambda_passedTPCTOFPID"), cand.lambdaPt()); - } + // Do ML analysis + if (fUseMLSel) { + if ((cand.gammaBDTScore() == -1) || (cand.lambdaBDTScore() == -1) || (cand.antilambdaBDTScore() == -1)) { + LOGF(fatal, "ML Score is not available! Please, enable gamma and lambda selection with ML in sigmabuilder!"); } - } else { // AntiLambda PID selection - // TPC Selection - if (fselLambdaTPCPID && (cand.lambdaPosPiTPCNSigma() != -999.f) && (TMath::Abs(cand.lambdaPosPiTPCNSigma()) > LambdaMaxTPCNSigmas)) - passedTPC = false; - if (fselLambdaTPCPID && (cand.lambdaNegPrTPCNSigma() != -999.f) && (TMath::Abs(cand.lambdaNegPrTPCNSigma()) > LambdaMaxTPCNSigmas)) - passedTPC = false; + // Photon selection: + if (cand.gammaBDTScore() <= Gamma_MLThreshold) + return false; + + // Lambda selection: + if (cand.lambdaBDTScore() <= Lambda_MLThreshold) + return false; + + // AntiLambda selection: + if (cand.antilambdaBDTScore() <= AntiLambda_MLThreshold) + return false; - // TOF Selection - if (fselLambdaTOFPID && (cand.aLambdaPrTOFNSigma() != -1e+3) && (TMath::Abs(cand.aLambdaPrTOFNSigma()) > LambdaMaxTOFNSigmas)) - passedTOF = false; - if (fselLambdaTOFPID && (cand.aLambdaPiTOFNSigma() != -1e+3) && (TMath::Abs(cand.aLambdaPiTOFNSigma()) > LambdaMaxTOFNSigmas)) - passedTOF = false; } - return (passedTPC && passedTOF); - } - void processMonteCarlo(V0MCSigmas const& v0s) - { - for (auto& sigma : v0s) { // selecting Sigma0-like candidates - // selecting Sigma0-like candidates - histos.fill(HIST("MC/h2dArmenterosBeforeSel"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("MC/h2dArmenterosBeforeSel"), sigma.lambdaAlpha(), sigma.lambdaQt()); - histos.fill(HIST("MC/hMassSigma0BeforeSel"), sigma.sigmaMass()); - histos.fill(HIST("MC/hPtSigma0BeforeSel"), sigma.sigmapT()); - - if (sigma.photonCandPDGCode() == 22) - histos.fill(HIST("MC/hPtTrueGamma_BeforeSel"), sigma.photonPt()); - if (sigma.lambdaCandPDGCode() == 3122) - histos.fill(HIST("MC/hPtTrueLambda_BeforeSel"), sigma.lambdaPt()); - if (sigma.isSigma() || sigma.isAntiSigma()) - histos.fill(HIST("MC/hPtTrueSigma_BeforeSel"), sigma.sigmapT()); - - histos.fill(HIST("MC/hPtGammaCand_BeforeSel"), sigma.photonPt()); - histos.fill(HIST("MC/hPtLambdaCand_BeforeSel"), sigma.lambdaPt()); - histos.fill(HIST("MC/hPtSigmaCand_BeforeSel"), sigma.sigmapT()); + // Go for standard analysis + else { - if (!processSigmaCandidate(sigma)) - continue; + // Photon specific selections + if (!selectPhoton(cand)) + return false; - histos.fill(HIST("MC/hPtGammaCand_AfterSel"), sigma.photonPt()); - histos.fill(HIST("MC/hPtSigmaCand_AfterSel"), sigma.sigmapT()); + // Lambda specific selections + if (!selectLambda(cand)) + return false; - if (sigma.photonCandPDGCode() == 22) - histos.fill(HIST("MC/hPtTrueGamma_AfterSel"), sigma.photonPt()); + // Sigma0 specific selections + if (TMath::Abs(cand.sigmaRapidity()) > SigmaMaxRap) + return false; + } - // For Lambda PID Studies - if (fLambdaTPCTOFQA && (sigma.lambdaAlpha() > 0)) { - histos.fill(HIST("MC/hPtLambdaCand_AfterSel"), sigma.lambdaPt()); - histos.fill(HIST("MC/h3dTPCvsTOFNSigma_LambdaPr"), sigma.lambdaPosPrTPCNSigma(), sigma.lambdaPrTOFNSigma(), sigma.lambdaPt()); - histos.fill(HIST("MC/h3dTPCvsTOFNSigma_LambdaPi"), sigma.lambdaNegPiTPCNSigma(), sigma.lambdaPiTOFNSigma(), sigma.lambdaPt()); + return true; + } - if (sigma.lambdaCandPDGCode() == 3122) { - histos.fill(HIST("MC/hPtTrueLambda_AfterSel"), sigma.lambdaPt()); - histos.fill(HIST("MC/h3dTPCvsTOFNSigma_TrueLambdaPr"), sigma.lambdaPosPrTPCNSigma(), sigma.lambdaPrTOFNSigma(), sigma.lambdaPt()); - histos.fill(HIST("MC/h3dTPCvsTOFNSigma_TrueLambdaPi"), sigma.lambdaNegPiTPCNSigma(), sigma.lambdaPiTOFNSigma(), sigma.lambdaPt()); - } - doLambdaPIDSel(sigma, true, fLambdaTPCTOFQA); + void processMonteCarlo(V0MCSigmas const& sigmas) + { + for (auto& sigma : sigmas) { // selecting Sigma0-like candidates + if (doMCAssociation && !(sigma.isSigma() || sigma.isAntiSigma())) { + continue; } - // For background studies: - histos.fill(HIST("MC/h2dPtVsMassSigma_SignalBkg"), sigma.sigmapT(), sigma.sigmaMass()); - // Real Gamma x Real Lambda - but not from the same sigma0/antisigma0! - if ((sigma.photonCandPDGCode() == 22) && ((sigma.lambdaCandPDGCode() == 3122) || (sigma.lambdaCandPDGCode() == -3122)) && !(sigma.isSigma()) && !(sigma.isAntiSigma())) { - histos.fill(HIST("MC/h2dPtVsMassSigma_TrueDaughters"), sigma.sigmapT(), sigma.sigmaMass()); - histos.fill(HIST("MC/h2dTrueDaughtersMatrix"), sigma.lambdaCandPDGCodeMother(), sigma.photonCandPDGCodeMother()); - histos.fill(HIST("MC/h2dPtVsOPAngle_TrueDaughters"), sigma.sigmapT(), sigma.sigmaOPAngle()); - } - // Real Gamma x fake Lambda - if ((sigma.photonCandPDGCode() == 22) && (sigma.lambdaCandPDGCode() != 3122) && (sigma.lambdaCandPDGCode() != -3122)) - histos.fill(HIST("MC/h2dPtVsMassSigma_TrueGammaFakeLambda"), sigma.sigmapT(), sigma.sigmaMass()); - - // Fake Gamma x Real Lambda - if ((sigma.photonCandPDGCode() != 22) && ((sigma.lambdaCandPDGCode() == 3122) || (sigma.lambdaCandPDGCode() == -3122))) - histos.fill(HIST("MC/h2dPtVsMassSigma_FakeGammaTrueLambda"), sigma.sigmapT(), sigma.sigmaMass()); - - // Fake Gamma x Fake Lambda - if ((sigma.photonCandPDGCode() != 22) && (sigma.lambdaCandPDGCode() != 3122) && (sigma.lambdaCandPDGCode() != -3122)) - histos.fill(HIST("MC/h2dPtVsMassSigma_FakeDaughters"), sigma.sigmapT(), sigma.sigmaMass()); - - // MC association (signal study) - if (sigma.isSigma() || sigma.isAntiSigma()) { - histos.fill(HIST("MC/h2dPtVsMassSigma_SignalOnly"), sigma.sigmapT(), sigma.sigmaMass()); - histos.fill(HIST("MC/hPtTrueSigma_AfterSel"), sigma.sigmapT()); - histos.fill(HIST("GeneralQA/hPhotonMassSelected"), sigma.photonMass()); - if (sigma.isSigma()) { - // TPC + TOF PID Selections - if (!doLambdaPIDSel(sigma, true, false)) - continue; - - histos.fill(HIST("MC/h2dArmenterosAfterSel"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("MC/h2dArmenterosAfterSel"), sigma.lambdaAlpha(), sigma.lambdaQt()); - histos.fill(HIST("GeneralQA/hLambdaMassSelected"), sigma.lambdaMass()); - histos.fill(HIST("MC/hMassSigma0"), sigma.sigmaMass()); - histos.fill(HIST("MC/hPtSigma0"), sigma.sigmapT()); - histos.fill(HIST("MC/h3dMassSigma0"), sigma.sigmaCentrality(), sigma.sigmapT(), sigma.sigmaMass()); - - } else { - // TPC + TOF PID Selections - if (!doLambdaPIDSel(sigma, false, false)) - continue; - - histos.fill(HIST("MC/h2dArmenterosAfterSel"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("GeneralQA/hAntiLambdaMassSelected"), sigma.antilambdaMass()); - histos.fill(HIST("MC/h2dArmenterosAfterSel"), sigma.lambdaAlpha(), sigma.lambdaQt()); - histos.fill(HIST("MC/hMassAntiSigma0"), sigma.sigmaMass()); - histos.fill(HIST("MC/hPtAntiSigma0"), sigma.sigmapT()); - histos.fill(HIST("MC/h3dMassAntiSigma0"), sigma.sigmaCentrality(), sigma.sigmapT(), sigma.sigmaMass()); - } - } + // Fill histos before any selection + fillQAHistos<0>(sigma); + + // Select sigma0 candidates + if (!processSigmaCandidate(sigma)) + continue; + + // Fill histos after all selections + fillQAHistos<1>(sigma); } } - void processRealData(V0Sigmas const& v0s) + void processRealData(V0Sigmas const& sigmas) { - for (auto& sigma : v0s) { // selecting Sigma0-like candidates - histos.fill(HIST("GeneralQA/h2dArmenterosBeforeSel"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("GeneralQA/h2dArmenterosBeforeSel"), sigma.lambdaAlpha(), sigma.lambdaQt()); - histos.fill(HIST("GeneralQA/hMassSigma0BeforeSel"), sigma.sigmaMass()); - - nSigmaCandidates++; - if (nSigmaCandidates % 50000 == 0) { - LOG(info) << "Sigma0 Candidates processed: " << nSigmaCandidates; - } + for (auto& sigma : sigmas) { // selecting Sigma0-like candidates + + // Fill histos before any selection + fillQAHistos<0>(sigma); + + // Select sigma0 candidates if (!processSigmaCandidate(sigma)) continue; - histos.fill(HIST("GeneralQA/hPhotonMassSelected"), sigma.photonMass()); - if (sigma.lambdaAlpha() > 0) { - // PID selections - histos.fill(HIST("GeneralQA/h2dTPCvsTOFNSigma_LambdaPr"), sigma.lambdaPosPrTPCNSigma(), sigma.lambdaPrTOFNSigma()); - histos.fill(HIST("GeneralQA/h2dTPCvsTOFNSigma_LambdaPi"), sigma.lambdaNegPiTPCNSigma(), sigma.lambdaPiTOFNSigma()); - - // TPC + TOF PID Selections - if (!doLambdaPIDSel(sigma, true, false)) - continue; - - histos.fill(HIST("GeneralQA/h2dArmenterosAfterSel"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("GeneralQA/h2dArmenterosAfterSel"), sigma.lambdaAlpha(), sigma.lambdaQt()); - histos.fill(HIST("GeneralQA/hLambdaMassSelected"), sigma.lambdaMass()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 25.); - histos.fill(HIST("Sigma0/hMassSigma0"), sigma.sigmaMass()); - histos.fill(HIST("Sigma0/hPtSigma0"), sigma.sigmapT()); - histos.fill(HIST("Sigma0/hRapiditySigma0"), sigma.sigmaRapidity()); - histos.fill(HIST("Sigma0/h3dMassSigma0"), sigma.sigmaCentrality(), sigma.sigmapT(), sigma.sigmaMass()); - } else { - // PID selections - histos.fill(HIST("GeneralQA/h2dTPCvsTOFNSigma_ALambdaPr"), sigma.lambdaNegPrTPCNSigma(), sigma.aLambdaPrTOFNSigma()); - histos.fill(HIST("GeneralQA/h2dTPCvsTOFNSigma_ALambdaPi"), sigma.lambdaPosPiTPCNSigma(), sigma.aLambdaPiTOFNSigma()); - - // TPC + TOF PID Selections - if (!doLambdaPIDSel(sigma, false, false)) - continue; - - histos.fill(HIST("GeneralQA/h2dArmenterosAfterSel"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("GeneralQA/h2dArmenterosAfterSel"), sigma.lambdaAlpha(), sigma.lambdaQt()); - histos.fill(HIST("GeneralQA/hAntiLambdaMassSelected"), sigma.antilambdaMass()); - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 25.); - histos.fill(HIST("AntiSigma0/hMassAntiSigma0"), sigma.sigmaMass()); - histos.fill(HIST("AntiSigma0/hPtAntiSigma0"), sigma.sigmapT()); - histos.fill(HIST("AntiSigma0/hRapidityAntiSigma0"), sigma.sigmaRapidity()); - histos.fill(HIST("AntiSigma0/h3dMassAntiSigma0"), sigma.sigmaCentrality(), sigma.sigmapT(), sigma.sigmaMass()); - } + // Fill histos after all selections + fillQAHistos<1>(sigma); } } - // PROCESS_SWITCH(sigmaanalysis, processCounterQA, "Check standard counter correctness", true); PROCESS_SWITCH(sigmaanalysis, processMonteCarlo, "Do Monte-Carlo-based analysis", false); PROCESS_SWITCH(sigmaanalysis, processRealData, "Do real data analysis", true); }; diff --git a/PWGLF/Tasks/Strangeness/sigmaminustask.cxx b/PWGLF/Tasks/Strangeness/sigmaminustask.cxx deleted file mode 100644 index 8b309476913..00000000000 --- a/PWGLF/Tasks/Strangeness/sigmaminustask.cxx +++ /dev/null @@ -1,77 +0,0 @@ -// 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. - -/// \file sigmaminustask.cxx -/// \brief Example of a simple task for the analysis of the Sigma-minus -/// \author Francesco Mazzaschi - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Common/DataModel/EventSelection.h" -#include "PWGLF/DataModel/LFKinkDecayTables.h" -#include "Common/DataModel/PIDResponse.h" -#include "ReconstructionDataFormats/PID.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -using TracksFull = soa::Join; -using CollisionsFull = soa::Join; - -struct sigmaminustask { - // Histograms are defined with HistogramRegistry - HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rSigmaMinus{"sigmaminus", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - - // Configurable for event selection - Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; - Configurable cutNSigmaPi{"cutNSigmaPi", 4, "NSigmaTPCPion"}; - - void init(InitContext const&) - { - // Axes - const AxisSpec ptAxis{50, -10, 10, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec nSigmaPiAxis{100, -5, 5, "n#sigma_{#pi}"}; - const AxisSpec sigmaMassAxis{100, 1.1, 1.4, "m (GeV/#it{c}^{2})"}; - const AxisSpec vertexZAxis{100, -15., 15., "vrtx_{Z} [cm]"}; - - // Event selection - rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); - - // Sigma-minus reconstruction - rSigmaMinus.add("h2MassSigmaMinusPt", "h2MassSigmaMinusPt", {HistType::kTH2F, {ptAxis, sigmaMassAxis}}); - rSigmaMinus.add("h2NSigmaPiPt", "h2NSigmaPiPt", {HistType::kTH2F, {ptAxis, nSigmaPiAxis}}); - } - - void process(soa::Join::iterator const& collision, - aod::KinkCands const& KinkCands, TracksFull const&) - { - if (std::abs(collision.posZ()) > cutzvertex || !collision.sel8()) { - return; - } - rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); - for (const auto& kinkCand : KinkCands) { - auto dauTrack = kinkCand.trackDaug_as(); - if (abs(dauTrack.tpcNSigmaPi()) > cutNSigmaPi) { - continue; - } - rSigmaMinus.fill(HIST("h2MassSigmaMinusPt"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.mSigmaMinus()); - rSigmaMinus.fill(HIST("h2NSigmaPiPt"), kinkCand.mothSign() * kinkCand.ptMoth(), dauTrack.tpcNSigmaPi()); - } - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGLF/Tasks/Strangeness/strange-yield-pbpb.cxx b/PWGLF/Tasks/Strangeness/strange-yield-pbpb.cxx deleted file mode 100644 index 63c866695dc..00000000000 --- a/PWGLF/Tasks/Strangeness/strange-yield-pbpb.cxx +++ /dev/null @@ -1,1572 +0,0 @@ -// 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. -// -// Strangeness in UPC analysis task -// ================ -// This code is meant to be run over derived data. -// -// Comments, questions, complaints, suggestions? -// Please write to: -// roman.nepeivoda@cern.ch -// - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "ReconstructionDataFormats/Track.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "PWGLF/DataModel/LFStrangenessPIDTables.h" -#include "Common/Core/TrackSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/PIDResponse.h" -#include "Framework/StaticFor.h" -#include "PWGUD/Core/SGSelector.h" -#include "PWGLF/Utils/strangenessMasks.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using std::array; - -using dauTracks = soa::Join; -using dauMCTracks = soa::Join; - -using v0Candidates = soa::Join; -using v0MCCandidates = soa::Join; - -using cascadeCandidates = soa::Join; - -using straCollisonFull = soa::Join::iterator; - -struct strangeYieldPbPb { - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - // master analysis switches - Configurable analyseK0Short{"analyseK0Short", true, "process K0Short-like candidates"}; - Configurable analyseLambda{"analyseLambda", true, "process Lambda-like candidates"}; - Configurable analyseAntiLambda{"analyseAntiLambda", true, "process AntiLambda-like candidates"}; - Configurable analyseXi{"analyseXi", true, "process Xi-like candidates"}; - Configurable analyseAntiXi{"analyseAntiXi", true, "process AntiXi-like candidates"}; - Configurable analyseOmega{"analyseOmega", true, "process Omega-like candidates"}; - Configurable analyseAntiOmega{"analyseAntiOmega", true, "process AntiOmega-like candidates"}; - - // Event selections - Configurable rejectITSROFBorder{"rejectITSROFBorder", true, "reject events at ITS ROF border"}; - Configurable rejectTFBorder{"rejectTFBorder", true, "reject events at TF border"}; - Configurable rejectSameBunchPileup{"rejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC"}; - Configurable requireIsTriggerTVX{"requireIsTriggerTVX", true, "require coincidence in FT0A and FT0C"}; - Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "require events with at least one ITS-TPC track"}; - Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", true, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference"}; - Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", false, "require events with at least one of vertex contributors matched to TOF"}; - Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", false, "require events with at least one of vertex contributors matched to TRD"}; - Configurable requireNoCollInTimeRangeStd{"requireNoCollInTimeRangeStd", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 10 microseconds"}; - Configurable requireNoCollInTimeRangeNarrow{"requireNoCollInTimeRangeNarrow", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 10 microseconds"}; - Configurable studyUPConly{"studyUPConly", false, "is UPC-only analysis"}; - Configurable useUPCflag{"useUPCflag", false, "select UPC flagged events"}; - - Configurable verbose{"verbose", false, "additional printouts"}; - - // Acceptance selections - Configurable rapidityCut{"rapidityCut", 0.5, "rapidity"}; - Configurable daughterEtaCut{"daughterEtaCut", 0.8, "max eta for daughters"}; - - // Standard V0 topological criteria - struct : ConfigurableGroup { - Configurable v0cospa{"v0cospa", 0.97, "min V0 CosPA"}; - Configurable dcav0dau{"dcav0dau", 1.5, "max DCA V0 Daughters (cm)"}; - Configurable dcanegtopv{"dcanegtopv", .05, "min DCA Neg To PV (cm)"}; - Configurable dcapostopv{"dcapostopv", .05, "min DCA Pos To PV (cm)"}; - Configurable v0radius{"v0radius", 1.2, "minimum V0 radius (cm)"}; - Configurable v0radiusMax{"v0radiusMax", 1E5, "maximum V0 radius (cm)"}; - // Additional selection on the AP plot (exclusive for K0Short) - // original equation: lArmPt*5>fabs(lArmAlpha) - Configurable armPodCut{"armPodCut", 5.0f, "pT * (cut) > |alpha|, AP cut. Negative: no cut"}; - Configurable v0TypeSelection{"v0TypeSelection", 1, "select on a certain V0 type (leave negative if no selection desired)"}; - } v0cuts; - static constexpr float lifetimeCutsV0[1][2] = {{30., 20.}}; - Configurable> lifetimecutV0{"lifetimecutV0", {lifetimeCutsV0[0], 2, {"lifetimecutLambda", "lifetimecutK0S"}}, "lifetimecutV0"}; - - // Standard cascade topological criteria - struct : ConfigurableGroup { - Configurable casccospa{"casccospa", 0.97, "Casc CosPA"}; - Configurable dcacascdau{"dcacascdau", 1.2, "DCA Casc Daughters"}; - Configurable cascradius{"cascradius", 0.6, "minimum cascade radius (cm)"}; - Configurable cascradiusMax{"cascradiusMax", 1E5, "maximum cascade radius (cm)"}; - Configurable bachbaryoncospa{"bachbaryoncospa", 2, "Bachelor baryon CosPA"}; - Configurable bachbaryondcaxytopv{"bachbaryondcaxytopv", -1, "DCA bachelor baryon to PV"}; - Configurable dcamesontopv{"dcamesontopv", 0.1, "DCA of meson doughter track To PV"}; - Configurable dcabaryontopv{"dcabaryontopv", 0.05, "DCA of baryon doughter track To PV"}; - Configurable dcabachtopv{"dcabachtopv", 0.04, "DCA Bach To PV"}; - Configurable dcav0topv{"dcav0topv", 0.06, "DCA V0 To PV"}; - // Cascade specific selections - Configurable masswin{"masswin", 0.05, "mass window limit"}; - Configurable lambdamasswin{"lambdamasswin", 0.005, "V0 Mass window limit"}; - Configurable rejcomp{"rejcomp", 0.008, "competing Cascade rejection"}; - } casccuts; - Configurable doBachelorBaryonCut{"doBachelorBaryonCut", false, "Enable Bachelor-Baryon cut "}; - static constexpr float nCtauCutsCasc[1][2] = {{6., 6.}}; - Configurable> nCtauCutCasc{"nCtauCutCasc", {nCtauCutsCasc[0], 2, {"lifetimecutXi", "lifetimecutOmega"}}, "nCtauCutCasc"}; - - // UPC selections - SGSelector sgSelector; - struct : ConfigurableGroup { - Configurable FV0cut{"FV0cut", 100., "FV0A threshold"}; - Configurable FT0Acut{"FT0Acut", 200., "FT0A threshold"}; - Configurable FT0Ccut{"FT0Ccut", 100., "FT0C threshold"}; - Configurable ZDCcut{"ZDCcut", 10., "ZDC threshold"}; - // Configurable gapSel{"gapSel", 2, "Gap selection"}; - } upcCuts; - - // Track quality - struct : ConfigurableGroup { - Configurable minTPCrows{"minTPCrows", 70, "minimum TPC crossed rows"}; - Configurable minITSclusters{"minITSclusters", -1, "minimum ITS clusters"}; - Configurable skipTPConly{"skipTPConly", false, "skip V0s comprised of at least one TPC only prong"}; - Configurable requireBachITSonly{"requireBachITSonly", false, "require that bachelor track is ITSonly (overrides TPC quality)"}; - Configurable requirePosITSonly{"requirePosITSonly", false, "require that positive track is ITSonly (overrides TPC quality)"}; - Configurable requireNegITSonly{"requireNegITSonly", false, "require that negative track is ITSonly (overrides TPC quality)"}; - } TrackConfigurations; - - // PID (TPC/TOF) - struct : ConfigurableGroup { - Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 1e+6, "TpcPidNsigmaCut"}; - Configurable TofPidNsigmaCutLaPr{"TofPidNsigmaCutLaPr", 1e+6, "TofPidNsigmaCutLaPr"}; - Configurable TofPidNsigmaCutLaPi{"TofPidNsigmaCutLaPi", 1e+6, "TofPidNsigmaCutLaPi"}; - Configurable TofPidNsigmaCutK0Pi{"TofPidNsigmaCutK0Pi", 1e+6, "TofPidNsigmaCutK0Pi"}; - - Configurable TofPidNsigmaCutXiPi{"TofPidNsigmaCutXiPi", 1e+6, "TofPidNsigmaCutXiPi"}; - Configurable TofPidNsigmaCutOmegaKaon{"TofPidNsigmaCutOmegaKaon", 1e+6, "TofPidNsigmaCutOmegaKaon"}; - - Configurable doTPCQA{"doTPCQA", false, "do TPC QA histograms"}; - Configurable doTOFQA{"doTOFQA", false, "do TOF QA histograms"}; - - // PID (TOF) - Configurable maxDeltaTimeProton{"maxDeltaTimeProton", 1e+9, "check maximum allowed time"}; - Configurable maxDeltaTimePion{"maxDeltaTimePion", 1e+9, "check maximum allowed time"}; - Configurable maxDeltaTimeKaon{"maxDeltaTimeKaon", 1e+9, "check maximum allowed time"}; - } PIDConfigurations; - - Configurable doKienmaticQA{"doKienmaticQA", true, "do Kinematic QA histograms"}; - Configurable doDetectPropQA{"doDetectPropQA", 0, "do Detector/ITS map QA: 0: no, 1: 4D, 2: 5D with mass"}; - Configurable doPlainTopoQA{"doPlainTopoQA", true, "do simple 1D QA of candidates"}; - - struct : ConfigurableGroup { - ConfigurableAxis axisFT0Aampl{"axisFT0Aampl", {100, 0.0f, 2000.0f}, "FT0Aamplitude"}; - ConfigurableAxis axisFT0Campl{"axisFT0Campl", {100, 0.0f, 2000.0f}, "FT0Camplitude"}; - ConfigurableAxis axisFV0Aampl{"axisFV0Aampl", {100, 0.0f, 2000.0f}, "FV0Aamplitude"}; - ConfigurableAxis axisFDDAampl{"axisFDDAampl", {100, 0.0f, 2000.0f}, "FDDAamplitude"}; - ConfigurableAxis axisFDDCampl{"axisFDDCampl", {100, 0.0f, 2000.0f}, "FDDCamplitude"}; - ConfigurableAxis axisZNAampl{"axisZNAampl", {100, 0.0f, 250.0f}, "ZNAamplitude"}; - ConfigurableAxis axisZNCampl{"axisZNCampl", {100, 0.0f, 250.0f}, "ZNCamplitude"}; - } axisDetectors; - - // for MC - Configurable doMCAssociation{"doMCAssociation", false, "if MC, do MC association"}; - Configurable doCollisionAssociationQA{"doCollisionAssociationQA", false, "check collision association"}; - - // fast check on occupancy - Configurable minOccupancy{"minOccupancy", -1, "minimum occupancy from neighbouring collisions"}; - Configurable maxOccupancy{"maxOccupancy", -1, "maximum occupancy from neighbouring collisions"}; - - // Kinematic axes - ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for v0 analysis"}; - ConfigurableAxis axisPtXi{"axisPtCasc", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for cascade analysis"}; - ConfigurableAxis axisPtCoarse{"axisPtCoarse", {VARIABLE_WIDTH, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 7.0f, 10.0f, 15.0f}, "pt axis for QA"}; - ConfigurableAxis axisEta{"axisEta", {100, -2.0f, 2.0f}, "#eta"}; - ConfigurableAxis axisRap{"axisRap", {100, -2.0f, 2.0f}, "y"}; - - // Invariant mass axes - ConfigurableAxis axisK0Mass{"axisK0Mass", {200, 0.4f, 0.6f}, ""}; - ConfigurableAxis axisLambdaMass{"axisLambdaMass", {200, 1.101f, 1.131f}, ""}; - ConfigurableAxis axisXiMass{"axisXiMass", {200, 1.28f, 1.36f}, ""}; - ConfigurableAxis axisOmegaMass{"axisOmegaMass", {200, 1.59f, 1.75f}, ""}; - std::vector axisInvMass = {axisK0Mass, - axisLambdaMass, - axisLambdaMass, - axisXiMass, - axisXiMass, - axisOmegaMass, - axisOmegaMass}; - - ConfigurableAxis axisNTracksGlobal{"axisNTracksGlobal", {100, -0.5f, 99.5f}, "Number of global tracks"}; - ConfigurableAxis axisNTracksPVeta1{"axisNTracksPVeta1", {100, -0.5f, 99.5f}, "Number of PV contributors in |eta| < 1"}; - ConfigurableAxis axisNTracksTotalExceptITSonly{"axisNTracksTotalExceptITSonly", {100, -0.5f, 99.5f}, "Number of ITS-TPC and TPC only tracks"}; - ConfigurableAxis axisNchInvMass{"axisNchInvMass", {200, -0.5f, 199.5f}, "Number of charged particles for kTHnSparseF"}; - - ConfigurableAxis axisFT0C_QA{"axisFT0C_QA", - {VARIABLE_WIDTH, 0., 0.01, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 105.5}, - "FT0C (%)"}; - - ConfigurableAxis axisFT0C{"axisFT0C", - {VARIABLE_WIDTH, 0., 0.01, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 105.5}, - "FT0C (%)"}; - - ConfigurableAxis axisOccupancy{"axisOccupancy", {VARIABLE_WIDTH, 0.0f, 250.0f, 500.0f, 750.0f, 1000.0f, 1500.0f, 2000.0f, 3000.0f, 4500.0f, 6000.0f, 8000.0f, 10000.0f, 50000.0f}, "Occupancy"}; - - // UPC axes - ConfigurableAxis axisSelGap{"axisSelGap", {4, -1.5, 2.5}, "Gap side"}; - - // AP plot axes - ConfigurableAxis axisAPAlpha{"axisAPAlpha", {220, -1.1f, 1.1f}, "V0 AP alpha"}; - ConfigurableAxis axisAPQt{"axisAPQt", {220, 0.0f, 0.5f}, "V0 AP alpha"}; - - // MC coll assoc QA axis - ConfigurableAxis axisMonteCarloNch{"axisMonteCarloNch", {300, 0.0f, 3000.0f}, "N_{ch} MC"}; - - // Track quality axes - ConfigurableAxis axisTPCrows{"axisTPCrows", {160, -0.5f, 159.5f}, "N TPC rows"}; - ConfigurableAxis axisITSclus{"axisITSclus", {7, -0.5f, 6.5f}, "N ITS Clusters"}; - ConfigurableAxis axisITScluMap{"axisITSMap", {128, -0.5f, 127.5f}, "ITS Cluster map"}; - ConfigurableAxis axisDetMap{"axisDetMap", {16, -0.5f, 15.5f}, "Detector use map"}; - ConfigurableAxis axisITScluMapCoarse{"axisITScluMapCoarse", {16, -3.5f, 12.5f}, "ITS Coarse cluster map"}; - ConfigurableAxis axisDetMapCoarse{"axisDetMapCoarse", {5, -0.5f, 4.5f}, "Detector Coarse user map"}; - - // Topological variable QA axes - ConfigurableAxis axisDCAtoPV{"axisDCAtoPV", {80, -4.0f, 4.0f}, "DCA (cm)"}; - ConfigurableAxis axisDCAdau{"axisDCAdau", {24, 0.0f, 1.2f}, "DCA (cm)"}; - ConfigurableAxis axisPointingAngle{"axisPointingAngle", {100, 0.0f, 0.5f}, "pointing angle (rad)"}; - ConfigurableAxis axisV0Radius{"axisV0Radius", {60, 0.0f, 60.0f}, "V0 2D radius (cm)"}; - ConfigurableAxis axisNsigmaTPC{"axisNsigmaTPC", {200, -10.0f, 10.0f}, "N sigma TPC"}; - ConfigurableAxis axisTPCsignal{"axisTPCsignal", {200, 0.0f, 200.0f}, "TPC signal"}; - ConfigurableAxis axisTOFdeltaT{"axisTOFdeltaT", {200, -5000.0f, 5000.0f}, "TOF Delta T (ps)"}; - ConfigurableAxis axisNctau{"axisNctau", {100, 0.0f, 10.0f}, "n c x tau"}; - - // PDG database - Service pdgDB; - - static constexpr std::string_view particlenames[] = {"K0Short", "Lambda", "AntiLambda", "Xi", "AntiXi", "Omega", "AntiOmega"}; - - void setBits(std::bitset& mask, std::initializer_list selections) - { - for (int sel : selections) { - mask.set(sel); - } - } - - template - void addTopoHistograms(HistogramRegistry& histos) - { - const bool isCascade = (partID > 2.5) ? true : false; - if (isCascade) { - histos.add(Form("%s/hCascCosPA", particlenames[partID].data()), "hCascCosPA", kTH2F, {axisPtCoarse, {100, 0.9f, 1.0f}}); - histos.add(Form("%s/hDCACascDaughters", particlenames[partID].data()), "hDCACascDaughters", kTH2F, {axisPtCoarse, {44, 0.0f, 2.2f}}); - histos.add(Form("%s/hCascRadius", particlenames[partID].data()), "hCascRadius", kTH2D, {axisPtCoarse, {500, 0.0f, 50.0f}}); - histos.add(Form("%s/hMesonDCAToPV", particlenames[partID].data()), "hMesonDCAToPV", kTH2F, {axisPtCoarse, axisDCAtoPV}); - histos.add(Form("%s/hBaryonDCAToPV", particlenames[partID].data()), "hBaryonDCAToPV", kTH2F, {axisPtCoarse, axisDCAtoPV}); - histos.add(Form("%s/hBachDCAToPV", particlenames[partID].data()), "hBachDCAToPV", kTH2F, {axisPtCoarse, {200, -1.0f, 1.0f}}); - histos.add(Form("%s/hV0CosPA", particlenames[partID].data()), "hV0CosPA", kTH2F, {axisPtCoarse, {100, 0.9f, 1.0f}}); - histos.add(Form("%s/hV0Radius", particlenames[partID].data()), "hV0Radius", kTH2D, {axisPtCoarse, axisV0Radius}); - histos.add(Form("%s/hDCAV0Daughters", particlenames[partID].data()), "hDCAV0Daughters", kTH2F, {axisPtCoarse, axisDCAdau}); - histos.add(Form("%s/hDCAV0ToPV", particlenames[partID].data()), "hDCAV0ToPV", kTH2F, {axisPtCoarse, {44, 0.0f, 2.2f}}); - histos.add(Form("%s/hMassLambdaDau", particlenames[partID].data()), "hMassLambdaDau", kTH2F, {axisPtCoarse, axisLambdaMass}); - histos.add(Form("%s/hNctau", particlenames[partID].data()), "hNctau", kTH2F, {axisPtCoarse, axisNctau}); - if (doBachelorBaryonCut) { - histos.add(Form("%s/hBachBaryonCosPA", particlenames[partID].data()), "hBachBaryonCosPA", kTH2F, {axisPtCoarse, {100, 0.0f, 1.0f}}); - histos.add(Form("%s/hBachBaryonDCAxyToPV", particlenames[partID].data()), "hBachBaryonDCAxyToPV", kTH2F, {axisPtCoarse, {300, -3.0f, 3.0f}}); - } - } else { - histos.add(Form("%s/hPosDCAToPV", particlenames[partID].data()), "hPosDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add(Form("%s/hNegDCAToPV", particlenames[partID].data()), "hNegDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add(Form("%s/hDCADaughters", particlenames[partID].data()), "hDCADaughters", kTH1F, {axisDCAdau}); - histos.add(Form("%s/hPointingAngle", particlenames[partID].data()), "hPointingAngle", kTH1F, {axisPointingAngle}); - histos.add(Form("%s/hV0Radius", particlenames[partID].data()), "hV0Radius", kTH1F, {axisV0Radius}); - histos.add(Form("%s/h2dPositiveITSvsTPCpts", particlenames[partID].data()), "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add(Form("%s/h2dNegativeITSvsTPCpts", particlenames[partID].data()), "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - } - } - - template - void addTPCQAHistograms(HistogramRegistry& histos) - { - const bool isCascade = (partID > 2.5) ? true : false; - histos.add(Form("%s/h3dPosNsigmaTPC", particlenames[partID].data()), "h3dPosNsigmaTPC", kTH3F, {axisFT0C, axisPtCoarse, axisNsigmaTPC}); - histos.add(Form("%s/h3dNegNsigmaTPC", particlenames[partID].data()), "h3dNegNsigmaTPC", kTH3F, {axisFT0C, axisPtCoarse, axisNsigmaTPC}); - histos.add(Form("%s/h3dPosTPCsignal", particlenames[partID].data()), "h3dPosTPCsignal", kTH3F, {axisFT0C, axisPtCoarse, axisTPCsignal}); - histos.add(Form("%s/h3dNegTPCsignal", particlenames[partID].data()), "h3dNegTPCsignal", kTH3F, {axisFT0C, axisPtCoarse, axisTPCsignal}); - - histos.add(Form("%s/h3dPosNsigmaTPCvsTrackPtot", particlenames[partID].data()), "h3dPosNsigmaTPCvsTrackPtot", kTH3F, {axisFT0C, axisPtCoarse, axisNsigmaTPC}); - histos.add(Form("%s/h3dNegNsigmaTPCvsTrackPtot", particlenames[partID].data()), "h3dNegNsigmaTPCvsTrackPtot", kTH3F, {axisFT0C, axisPtCoarse, axisNsigmaTPC}); - - histos.add(Form("%s/h3dPosTPCsignalVsTrackPtot", particlenames[partID].data()), "h3dPosTPCsignalVsTrackPtot", kTH3F, {axisFT0C, axisPtCoarse, axisTPCsignal}); - histos.add(Form("%s/h3dNegTPCsignalVsTrackPtot", particlenames[partID].data()), "h3dNegTPCsignalVsTrackPtot", kTH3F, {axisFT0C, axisPtCoarse, axisTPCsignal}); - - histos.add(Form("%s/h3dPosNsigmaTPCvsTrackPt", particlenames[partID].data()), "h3dPosNsigmaTPCvsTrackPt", kTH3F, {axisFT0C, axisPtCoarse, axisNsigmaTPC}); - histos.add(Form("%s/h3dNegNsigmaTPCvsTrackPt", particlenames[partID].data()), "h3dNegNsigmaTPCvsTrackPt", kTH3F, {axisFT0C, axisPtCoarse, axisNsigmaTPC}); - - histos.add(Form("%s/h3dPosTPCsignalVsTrackPt", particlenames[partID].data()), "h3dPosTPCsignalVsTrackPt", kTH3F, {axisFT0C, axisPtCoarse, axisTPCsignal}); - histos.add(Form("%s/h3dNegTPCsignalVsTrackPt", particlenames[partID].data()), "h3dNegTPCsignalVsTrackPt", kTH3F, {axisFT0C, axisPtCoarse, axisTPCsignal}); - - if (isCascade) { - histos.add(Form("%s/h3dBachTPCsignal", particlenames[partID].data()), "h3dBachTPCsignal", kTH3F, {axisFT0C, axisPtCoarse, axisTPCsignal}); - histos.add(Form("%s/h3dBachNsigmaTPC", particlenames[partID].data()), "h3dBachNsigmaTPC", kTH3F, {axisFT0C, axisPtCoarse, axisNsigmaTPC}); - histos.add(Form("%s/h3dBachNsigmaTPCvsTrackPtot", particlenames[partID].data()), "h3dBachNsigmaTPCvsTrackPtot", kTH3F, {axisFT0C, axisPtCoarse, axisNsigmaTPC}); - histos.add(Form("%s/h3dBachTPCsignalVsTrackPtot", particlenames[partID].data()), "h3dBachTPCsignalVsTrackPtot", kTH3F, {axisFT0C, axisPtCoarse, axisTPCsignal}); - histos.add(Form("%s/h3dBachNsigmaTPCvsTrackPt", particlenames[partID].data()), "h3dBachNsigmaTPCvsTrackPt", kTH3F, {axisFT0C, axisPtCoarse, axisNsigmaTPC}); - histos.add(Form("%s/h3dBachTPCsignalVsTrackPt", particlenames[partID].data()), "h3dBachTPCsignalVsTrackPt", kTH3F, {axisFT0C, axisPtCoarse, axisTPCsignal}); - } - } - - template - void addTOFQAHistograms(HistogramRegistry& histos) - { - const bool isCascade = (partID > 2.5) ? true : false; - histos.add(Form("%s/h3dPosTOFdeltaT", particlenames[partID].data()), "h3dPosTOFdeltaT", kTH3F, {axisFT0C, axisPtCoarse, axisTOFdeltaT}); - histos.add(Form("%s/h3dNegTOFdeltaT", particlenames[partID].data()), "h3dNegTOFdeltaT", kTH3F, {axisFT0C, axisPtCoarse, axisTOFdeltaT}); - histos.add(Form("%s/h3dPosTOFdeltaTvsTrackPtot", particlenames[partID].data()), "h3dPosTOFdeltaTvsTrackPtot", kTH3F, {axisFT0C, axisPtCoarse, axisTOFdeltaT}); - histos.add(Form("%s/h3dNegTOFdeltaTvsTrackPtot", particlenames[partID].data()), "h3dNegTOFdeltaTvsTrackPtot", kTH3F, {axisFT0C, axisPtCoarse, axisTOFdeltaT}); - histos.add(Form("%s/h3dPosTOFdeltaTvsTrackPt", particlenames[partID].data()), "h3dPosTOFdeltaTvsTrackPt", kTH3F, {axisFT0C, axisPtCoarse, axisTOFdeltaT}); - histos.add(Form("%s/h3dNegTOFdeltaTvsTrackPt", particlenames[partID].data()), "h3dNegTOFdeltaTvsTrackPt", kTH3F, {axisFT0C, axisPtCoarse, axisTOFdeltaT}); - if (isCascade) { - histos.add(Form("%s/h3dBachTOFdeltaT", particlenames[partID].data()), "h3dBachTOFdeltaT", kTH3F, {axisFT0C, axisPtCoarse, axisTOFdeltaT}); - histos.add(Form("%s/h3dBachTOFdeltaTvsTrackPtot", particlenames[partID].data()), "h3dBachTOFdeltaTvsTrackPtot", kTH3F, {axisFT0C, axisPtCoarse, axisTOFdeltaT}); - histos.add(Form("%s/h3dBachTOFdeltaTvsTrackPt", particlenames[partID].data()), "h3dBachTOFdeltaTvsTrackPt", kTH3F, {axisFT0C, axisPtCoarse, axisTOFdeltaT}); - } - } - - template - void addKinematicQAHistograms(HistogramRegistry& histos) - { - const bool isCascade = (partID > 2.5) ? true : false; - histos.add(Form("%s/h3dPosEtaPt", particlenames[partID].data()), "h3dPosEtaPt", kTH3F, {axisPtCoarse, axisEta, axisSelGap}); - histos.add(Form("%s/h3dNegEtaPt", particlenames[partID].data()), "h3dNegEtaPt", kTH3F, {axisPtCoarse, axisEta, axisSelGap}); - histos.add(Form("%s/h3dRapPt", particlenames[partID].data()), "h3dRapPt", kTH3F, {axisPtCoarse, axisRap, axisSelGap}); - if (isCascade) { - histos.add(Form("%s/h3dBachEtaPt", particlenames[partID].data()), "h3dBachEtaPt", kTH3F, {axisPtCoarse, axisEta, axisSelGap}); - } - } - - template - void addDetectorPropHistograms(HistogramRegistry& histos) - { - const bool isCascade = (partID > 2.5) ? true : false; - if (doDetectPropQA == 1) { - if (isCascade) { - histos.add(Form("%s/h8dDetectPropVsCentrality", particlenames[partID].data()), "h8dDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); - } else { - histos.add(Form("%s/h6dDetectPropVsCentrality", particlenames[partID].data()), "h6dDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse}); - } - histos.add(Form("%s/h4dPosDetectPropVsCentrality", particlenames[partID].data()), "h4dPosDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMap, axisITScluMap, axisPtCoarse}); - histos.add(Form("%s/h4dNegDetectPropVsCentrality", particlenames[partID].data()), "h4dNegDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMap, axisITScluMap, axisPtCoarse}); - histos.add(Form("%s/h4dBachDetectPropVsCentrality", particlenames[partID].data()), "h4dBachDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMap, axisITScluMap, axisPtCoarse}); - } - if (doDetectPropQA == 2) { - if (isCascade) { - histos.add(Form("%s/h9dDetectPropVsCentrality", particlenames[partID].data()), "h9dDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisInvMass.at(partID)}); - } else { - histos.add(Form("%s/h7dDetectPropVsCentrality", particlenames[partID].data()), "h7dDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMapCoarse, axisITScluMapCoarse, axisDetMapCoarse, axisITScluMapCoarse, axisPtCoarse, axisInvMass.at(partID)}); - } - histos.add(Form("%s/h5dPosDetectPropVsCentrality", particlenames[partID].data()), "h5dPosDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMap, axisITScluMap, axisPtCoarse, axisInvMass.at(partID)}); - histos.add(Form("%s/h5dNegDetectPropVsCentrality", particlenames[partID].data()), "h5dNegDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMap, axisITScluMap, axisPtCoarse, axisInvMass.at(partID)}); - histos.add(Form("%s/h5dBachDetectPropVsCentrality", particlenames[partID].data()), "h5dBachDetectPropVsCentrality", kTHnSparseF, {axisFT0C, axisDetMap, axisITScluMap, axisPtCoarse, axisInvMass.at(partID)}); - } - } - - template - void addHistograms(HistogramRegistry& histos) - { - histos.add(Form("%s/h7dMass", particlenames[partID].data()), "h7dMass", kTHnSparseF, {axisFT0C, axisPt, axisInvMass.at(partID), axisSelGap, axisNchInvMass, axisRap, axisEta}); - histos.add(Form("%s/h2dMass", particlenames[partID].data()), "h2dMass", kTH2F, {axisInvMass.at(partID), axisSelGap}); - if (doPlainTopoQA) { - addTopoHistograms(histos); - } - if (PIDConfigurations.doTPCQA) { - addTPCQAHistograms(histos); - } - if (PIDConfigurations.doTOFQA) { - addTOFQAHistograms(histos); - } - if (doKienmaticQA) { - addKinematicQAHistograms(histos); - } - addDetectorPropHistograms(histos); - } - - template - void addCollisionAssocHistograms(HistogramRegistry& histos) - { - histos.add(Form("%s/h2dPtVsNch", particlenames[partID].data()), "h2dPtVsNch", kTH2F, {axisMonteCarloNch, axisPt}); - histos.add(Form("%s/h2dPtVsNch_BadCollAssig", particlenames[partID].data()), "h2dPtVsNch_BadCollAssig", kTH2F, {axisMonteCarloNch, axisPt}); - } - - template - void fillHistogramsV0(TCand cand, TCollision coll, int gap) - { - float invMass = 0; - float centrality = coll.centFT0C(); - float pT = cand.pt(); - float rapidity = 1e6; - - float tpcNsigmaPos = 0; - float tpcNsigmaNeg = 0; - float tofDeltaTPos = 0; - float tofDeltaTNeg = 0; - - auto posTrackExtra = cand.template posTrackExtra_as(); - auto negTrackExtra = cand.template negTrackExtra_as(); - - bool posIsFromAfterburner = posTrackExtra.itsChi2PerNcl() < 0; - bool negIsFromAfterburner = negTrackExtra.itsChi2PerNcl() < 0; - - uint posDetMap = computeDetBitmap(posTrackExtra.detectorMap()); - int posITSclusMap = computeITSclusBitmap(posTrackExtra.itsClusterMap(), posIsFromAfterburner); - uint negDetMap = computeDetBitmap(negTrackExtra.detectorMap()); - int negITSclusMap = computeITSclusBitmap(negTrackExtra.itsClusterMap(), negIsFromAfterburner); - - if (partID == 0) { - histos.fill(HIST("generalQA/h2dArmenterosSelected"), cand.alpha(), cand.qtarm()); - invMass = cand.mK0Short(); - rapidity = cand.yK0Short(); - if (PIDConfigurations.doTOFQA) { - tofDeltaTPos = cand.posTOFDeltaTK0Pi(); - tofDeltaTNeg = cand.negTOFDeltaTK0Pi(); - } - if (PIDConfigurations.doTPCQA) { - tpcNsigmaPos = posTrackExtra.tpcNSigmaPi(); - tpcNsigmaNeg = negTrackExtra.tpcNSigmaPi(); - } - } else if (partID == 1) { - invMass = cand.mLambda(); - rapidity = cand.yLambda(); - if (PIDConfigurations.doTOFQA) { - tofDeltaTPos = cand.posTOFDeltaTLaPr(); - tofDeltaTNeg = cand.negTOFDeltaTLaPi(); - } - if (PIDConfigurations.doTPCQA) { - tpcNsigmaPos = posTrackExtra.tpcNSigmaPr(); - tpcNsigmaNeg = negTrackExtra.tpcNSigmaPi(); - } - } else if (partID == 2) { - invMass = cand.mAntiLambda(); - rapidity = cand.yLambda(); - if (PIDConfigurations.doTOFQA) { - tofDeltaTPos = cand.posTOFDeltaTLaPi(); - tofDeltaTNeg = cand.negTOFDeltaTLaPr(); - } - if (PIDConfigurations.doTPCQA) { - tpcNsigmaPos = posTrackExtra.tpcNSigmaPi(); - tpcNsigmaNeg = negTrackExtra.tpcNSigmaPr(); - } - } else { - LOG(fatal) << "Particle is unknown!"; - } - - histos.fill(HIST(particlenames[partID]) + HIST("/h2dMass"), invMass, gap); - histos.fill(HIST(particlenames[partID]) + HIST("/h7dMass"), centrality, pT, invMass, gap, coll.multNTracksGlobal(), rapidity, cand.eta()); - if (doKienmaticQA) { - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosEtaPt"), pT, cand.positiveeta(), gap); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegEtaPt"), pT, cand.negativeeta(), gap); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dRapPt"), pT, rapidity, gap); - } - if (doPlainTopoQA) { - histos.fill(HIST(particlenames[partID]) + HIST("/hPosDCAToPV"), cand.dcapostopv()); - histos.fill(HIST(particlenames[partID]) + HIST("/hNegDCAToPV"), cand.dcanegtopv()); - histos.fill(HIST(particlenames[partID]) + HIST("/hDCADaughters"), cand.dcaV0daughters()); - histos.fill(HIST(particlenames[partID]) + HIST("/hPointingAngle"), TMath::ACos(cand.v0cosPA())); - histos.fill(HIST(particlenames[partID]) + HIST("/hV0Radius"), cand.v0radius()); - histos.fill(HIST(particlenames[partID]) + HIST("/h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); - histos.fill(HIST(particlenames[partID]) + HIST("/h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); - } - if (doDetectPropQA == 1) { - histos.fill(HIST(particlenames[partID]) + HIST("/h6dDetectPropVsCentrality"), centrality, posDetMap, posITSclusMap, negDetMap, negITSclusMap, pT); - histos.fill(HIST(particlenames[partID]) + HIST("/h4dPosDetectPropVsCentrality"), centrality, posTrackExtra.detectorMap(), posTrackExtra.itsClusterMap(), pT); - histos.fill(HIST(particlenames[partID]) + HIST("/h4dNegDetectPropVsCentrality"), centrality, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pT); - } - if (doDetectPropQA == 2) { - histos.fill(HIST(particlenames[partID]) + HIST("/h7dPosDetectPropVsCentrality"), centrality, posDetMap, posITSclusMap, negDetMap, negITSclusMap, pT, invMass); - histos.fill(HIST(particlenames[partID]) + HIST("/h5dPosDetectPropVsCentrality"), centrality, posTrackExtra.detectorMap(), posTrackExtra.itsClusterMap(), pT, invMass); - histos.fill(HIST(particlenames[partID]) + HIST("/h5dNegDetectPropVsCentrality"), centrality, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pT, invMass); - } - if (PIDConfigurations.doTPCQA) { - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTPCsignal"), centrality, pT, posTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTPCsignal"), centrality, pT, negTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTPCsignalVsTrackPtot"), centrality, cand.positivept() * TMath::CosH(cand.positiveeta()), posTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTPCsignalVsTrackPtot"), centrality, cand.negativept() * TMath::CosH(cand.negativeeta()), negTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTPCsignalVsTrackPt"), centrality, cand.positivept(), posTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTPCsignalVsTrackPt"), centrality, cand.negativept(), negTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosNsigmaTPCvsTrackPt"), centrality, cand.positivept(), posTrackExtra.tpcNSigmaPi()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegNsigmaTPCvsTrackPt"), centrality, cand.negativept(), negTrackExtra.tpcNSigmaPi()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosNsigmaTPCvsTrackPtot"), centrality, cand.positivept() * TMath::CosH(cand.positiveeta()), tpcNsigmaPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegNsigmaTPCvsTrackPtot"), centrality, cand.negativept() * TMath::CosH(cand.negativeeta()), tpcNsigmaNeg); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosNsigmaTPC"), centrality, pT, tpcNsigmaPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegNsigmaTPC"), centrality, pT, tpcNsigmaNeg); - } - if (PIDConfigurations.doTOFQA) { - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTOFdeltaTvsTrackPt"), centrality, cand.positivept(), tofDeltaTPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTOFdeltaTvsTrackPt"), centrality, cand.negativept(), tofDeltaTNeg); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTOFdeltaT"), centrality, pT, tofDeltaTPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTOFdeltaT"), centrality, pT, tofDeltaTNeg); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTOFdeltaTvsTrackPtot"), centrality, cand.positivept() * TMath::CosH(cand.positiveeta()), tofDeltaTPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTOFdeltaTvsTrackPtot"), centrality, cand.negativept() * TMath::CosH(cand.negativeeta()), tofDeltaTNeg); - } - } - - template - void fillHistogramsCasc(TCand cand, TCollision coll, int gap) - { - float invMass = 0; - float centrality = coll.centFT0C(); - float pT = cand.pt(); - float rapidity = 1e6; - - // Access daughter tracks - auto posTrackExtra = cand.template posTrackExtra_as(); - auto negTrackExtra = cand.template negTrackExtra_as(); - auto bachTrackExtra = cand.template bachTrackExtra_as(); - - bool posIsFromAfterburner = posTrackExtra.itsChi2PerNcl() < 0; - bool negIsFromAfterburner = negTrackExtra.itsChi2PerNcl() < 0; - bool bachIsFromAfterburner = bachTrackExtra.itsChi2PerNcl() < 0; - - uint posDetMap = computeDetBitmap(posTrackExtra.detectorMap()); - int posITSclusMap = computeITSclusBitmap(posTrackExtra.itsClusterMap(), posIsFromAfterburner); - uint negDetMap = computeDetBitmap(negTrackExtra.detectorMap()); - int negITSclusMap = computeITSclusBitmap(negTrackExtra.itsClusterMap(), negIsFromAfterburner); - uint bachDetMap = computeDetBitmap(bachTrackExtra.detectorMap()); - int bachITSclusMap = computeITSclusBitmap(bachTrackExtra.itsClusterMap(), bachIsFromAfterburner); - - // c x tau - float decayPos = std::hypot(cand.x() - coll.posX(), cand.y() - coll.posY(), cand.z() - coll.posZ()); - float totalMom = std::hypot(cand.px(), cand.py(), cand.pz()); - - float ctau = 0; - - float tpcNsigmaPos = 0; - float tpcNsigmaNeg = 0; - float tpcNsigmaBach = 0; - float tofDeltaTPos = 0; - float tofDeltaTNeg = 0; - float tofDeltaTBach = 0; - - if (partID == 3) { - invMass = cand.mXi(); - ctau = totalMom != 0 ? pdgDB->Mass(3312) * decayPos / (totalMom * ctauxiPDG) : 1e6; - rapidity = cand.yXi(); - - if (PIDConfigurations.doTPCQA) { - tpcNsigmaPos = posTrackExtra.tpcNSigmaPr(); - tpcNsigmaNeg = negTrackExtra.tpcNSigmaPi(); - tpcNsigmaBach = bachTrackExtra.tpcNSigmaPi(); - } - if (PIDConfigurations.doTOFQA) { - tofDeltaTPos = cand.posTOFDeltaTXiPr(); - tofDeltaTNeg = cand.negTOFDeltaTXiPi(); - tofDeltaTBach = cand.bachTOFDeltaTXiPi(); - } - } else if (partID == 4) { - invMass = cand.mXi(); - ctau = totalMom != 0 ? pdgDB->Mass(3312) * decayPos / (totalMom * ctauxiPDG) : 1e6; - rapidity = cand.yXi(); - - if (PIDConfigurations.doTPCQA) { - tpcNsigmaPos = posTrackExtra.tpcNSigmaPi(); - tpcNsigmaNeg = negTrackExtra.tpcNSigmaPr(); - tpcNsigmaBach = bachTrackExtra.tpcNSigmaPi(); - } - if (PIDConfigurations.doTOFQA) { - tofDeltaTPos = cand.posTOFDeltaTXiPi(); - tofDeltaTNeg = cand.negTOFDeltaTXiPr(); - tofDeltaTBach = cand.bachTOFDeltaTXiPi(); - } - - } else if (partID == 5) { - invMass = cand.mOmega(); - ctau = totalMom != 0 ? pdgDB->Mass(3334) * decayPos / (totalMom * ctauomegaPDG) : 1e6; - rapidity = cand.yOmega(); - - if (PIDConfigurations.doTPCQA) { - tpcNsigmaPos = posTrackExtra.tpcNSigmaPr(); - tpcNsigmaNeg = negTrackExtra.tpcNSigmaPi(); - tpcNsigmaBach = bachTrackExtra.tpcNSigmaKa(); - } - if (PIDConfigurations.doTOFQA) { - tofDeltaTPos = cand.posTOFDeltaTOmPi(); - tofDeltaTNeg = cand.posTOFDeltaTOmPr(); - tofDeltaTBach = cand.bachTOFDeltaTOmKa(); - } - - } else if (partID == 6) { - invMass = cand.mOmega(); - ctau = totalMom != 0 ? pdgDB->Mass(3334) * decayPos / (totalMom * ctauomegaPDG) : 1e6; - rapidity = cand.yOmega(); - - if (PIDConfigurations.doTPCQA) { - tpcNsigmaPos = posTrackExtra.tpcNSigmaPi(); - tpcNsigmaNeg = negTrackExtra.tpcNSigmaPr(); - tpcNsigmaBach = bachTrackExtra.tpcNSigmaKa(); - } - if (PIDConfigurations.doTOFQA) { - tofDeltaTPos = cand.posTOFDeltaTOmPr(); - tofDeltaTNeg = cand.posTOFDeltaTOmPi(); - tofDeltaTBach = cand.bachTOFDeltaTOmKa(); - } - } - histos.fill(HIST(particlenames[partID]) + HIST("/h2dMass"), invMass, gap); - histos.fill(HIST(particlenames[partID]) + HIST("/h7dMass"), centrality, pT, invMass, gap, coll.multNTracksGlobal(), rapidity, cand.eta()); - if (doKienmaticQA) { - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosEtaPt"), pT, cand.positiveeta(), gap); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegEtaPt"), pT, cand.negativeeta(), gap); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachEtaPt"), pT, cand.bacheloreta(), gap); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dRapPt"), pT, rapidity, gap); - } - if (doPlainTopoQA) { - histos.fill(HIST(particlenames[partID]) + HIST("/hCascCosPA"), pT, cand.casccosPA(coll.posX(), coll.posY(), coll.posZ())); - histos.fill(HIST(particlenames[partID]) + HIST("/hDCACascDaughters"), pT, cand.dcacascdaughters()); - histos.fill(HIST(particlenames[partID]) + HIST("/hCascRadius"), pT, cand.cascradius()); - histos.fill(HIST(particlenames[partID]) + HIST("/hMesonDCAToPV"), pT, cand.dcanegtopv()); - histos.fill(HIST(particlenames[partID]) + HIST("/hBaryonDCAToPV"), pT, cand.dcapostopv()); - histos.fill(HIST(particlenames[partID]) + HIST("/hBachDCAToPV"), pT, cand.dcabachtopv()); - histos.fill(HIST(particlenames[partID]) + HIST("/hV0CosPA"), pT, cand.v0cosPA(coll.posX(), coll.posY(), coll.posZ())); - histos.fill(HIST(particlenames[partID]) + HIST("/hV0Radius"), pT, cand.v0radius()); - histos.fill(HIST(particlenames[partID]) + HIST("/hDCAV0Daughters"), pT, cand.dcaV0daughters()); - histos.fill(HIST(particlenames[partID]) + HIST("/hDCAV0ToPV"), pT, fabs(cand.dcav0topv(coll.posX(), coll.posY(), coll.posZ()))); - histos.fill(HIST(particlenames[partID]) + HIST("/hMassLambdaDau"), pT, cand.mLambda()); - histos.fill(HIST(particlenames[partID]) + HIST("/hNctau"), pT, ctau); - } - if (PIDConfigurations.doTPCQA) { - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosNsigmaTPC"), centrality, pT, tpcNsigmaPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegNsigmaTPC"), centrality, pT, tpcNsigmaNeg); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachNsigmaTPC"), centrality, pT, tpcNsigmaBach); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTPCsignal"), centrality, pT, posTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTPCsignal"), centrality, pT, negTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachTPCsignal"), centrality, pT, bachTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosNsigmaTPCvsTrackPtot"), centrality, cand.positivept() * TMath::CosH(cand.positiveeta()), tpcNsigmaPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegNsigmaTPCvsTrackPtot"), centrality, cand.negativept() * TMath::CosH(cand.negativeeta()), tpcNsigmaNeg); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachNsigmaTPCvsTrackPtot"), centrality, cand.bachelorpt() * TMath::CosH(cand.bacheloreta()), tpcNsigmaBach); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTPCsignalVsTrackPtot"), centrality, cand.positivept() * TMath::CosH(cand.positiveeta()), posTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTPCsignalVsTrackPtot"), centrality, cand.negativept() * TMath::CosH(cand.negativeeta()), negTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachTPCsignalVsTrackPtot"), centrality, cand.bachelorpt() * TMath::CosH(cand.bacheloreta()), bachTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosNsigmaTPCvsTrackPt"), centrality, cand.positivept(), tpcNsigmaPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegNsigmaTPCvsTrackPt"), centrality, cand.negativept(), tpcNsigmaNeg); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachNsigmaTPCvsTrackPt"), centrality, cand.bachelorpt(), tpcNsigmaBach); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTPCsignalVsTrackPt"), centrality, cand.positivept(), posTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTPCsignalVsTrackPt"), centrality, cand.negativept(), negTrackExtra.tpcSignal()); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachTPCsignalVsTrackPt"), centrality, cand.bachelorpt(), bachTrackExtra.tpcSignal()); - } - if (PIDConfigurations.doTOFQA) { - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTOFdeltaT"), centrality, pT, tofDeltaTPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTOFdeltaT"), centrality, pT, tofDeltaTNeg); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachTOFdeltaT"), centrality, pT, tofDeltaTBach); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTOFdeltaTvsTrackPtot"), centrality, cand.positivept() * TMath::CosH(cand.positiveeta()), tofDeltaTPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTOFdeltaTvsTrackPtot"), centrality, cand.negativept() * TMath::CosH(cand.negativeeta()), tofDeltaTNeg); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachTOFdeltaTvsTrackPtot"), centrality, cand.bachelorpt() * TMath::CosH(cand.bacheloreta()), tofDeltaTBach); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dPosTOFdeltaTvsTrackPt"), centrality, cand.positivept(), tofDeltaTPos); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dNegTOFdeltaTvsTrackPt"), centrality, cand.negativept(), tofDeltaTNeg); - histos.fill(HIST(particlenames[partID]) + HIST("/h3dBachTOFdeltaTvsTrackPt"), centrality, cand.bachelorpt(), tofDeltaTBach); - } - if (doDetectPropQA == 1) { - histos.fill(HIST(particlenames[partID]) + HIST("/h8dDetectPropVsCentrality"), centrality, posDetMap, posITSclusMap, negDetMap, negITSclusMap, bachDetMap, bachITSclusMap, pT); - histos.fill(HIST(particlenames[partID]) + HIST("/h4dPosDetectPropVsCentrality"), centrality, posTrackExtra.detectorMap(), posTrackExtra.itsClusterMap(), pT); - histos.fill(HIST(particlenames[partID]) + HIST("/h4dNegDetectPropVsCentrality"), centrality, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pT); - histos.fill(HIST(particlenames[partID]) + HIST("/h4dBachDetectPropVsCentrality"), centrality, bachTrackExtra.detectorMap(), bachTrackExtra.itsClusterMap(), pT); - } - if (doDetectPropQA == 2) { - histos.fill(HIST(particlenames[partID]) + HIST("/h9dDetectPropVsCentrality"), centrality, posDetMap, posITSclusMap, negDetMap, negITSclusMap, bachDetMap, bachITSclusMap, pT, invMass); - histos.fill(HIST(particlenames[partID]) + HIST("/h5dPosDetectPropVsCentrality"), centrality, posTrackExtra.detectorMap(), posTrackExtra.itsClusterMap(), pT, invMass); - histos.fill(HIST(particlenames[partID]) + HIST("/h5dNegDetectPropVsCentrality"), centrality, negTrackExtra.detectorMap(), negTrackExtra.itsClusterMap(), pT, invMass); - histos.fill(HIST(particlenames[partID]) + HIST("/h5dBachDetectPropVsCentrality"), centrality, bachTrackExtra.detectorMap(), bachTrackExtra.itsClusterMap(), pT, invMass); - } - } - - void init(InitContext const&) - { - if ((doprocessV0s == true) && (doprocessCascades == true)) { - LOG(fatal) << "Unable to analyze both v0s and cascades simultaneously. Please enable only one process at a time"; - } - - // initialise bit masks - setBits(maskTopologicalV0, {selV0CosPA, selDCANegToPV, selDCAPosToPV, selDCAV0Dau, selV0Radius, selV0RadiusMax}); - setBits(maskTopologicalCasc, {selCascCosPA, selDCACascDau, selCascRadius, selCascRadiusMax, selBachToPV, selMesonToPV, selBaryonToPV, - selDCAV0ToPV, selV0CosPA, selDCAV0Dau, selV0Radius, selV0RadiusMax, selLambdaMassWin}); - - if (doBachelorBaryonCut) - maskTopologicalCasc.set(selBachBaryon); - - setBits(maskKinematicV0, {selPosEta, selNegEta}); - setBits(maskKinematicCasc, {selPosEta, selNegEta, selBachEta}); - - // Specific masks - setBits(maskK0ShortSpecific, {selK0ShortRapidity, selK0ShortCTau, selK0ShortArmenteros, selConsiderK0Short}); - setBits(maskLambdaSpecific, {selLambdaRapidity, selLambdaCTau, selConsiderLambda}); - setBits(maskAntiLambdaSpecific, {selLambdaRapidity, selLambdaCTau, selConsiderAntiLambda}); - setBits(maskXiSpecific, {selXiRapidity, selXiCTau, selRejCompXi, selMassWinXi, selConsiderXi}); - setBits(maskAntiXiSpecific, {selXiRapidity, selXiCTau, selRejCompXi, selMassWinXi, selConsiderAntiXi}); - setBits(maskOmegaSpecific, {selOmegaRapidity, selOmegaCTau, selRejCompOmega, selMassWinOmega, selConsiderOmega}); - setBits(maskAntiOmegaSpecific, {selOmegaRapidity, selOmegaCTau, selRejCompOmega, selMassWinOmega, selConsiderAntiOmega}); - - // ask for specific TPC/TOF PID selections - // positive track - if (TrackConfigurations.requirePosITSonly) { - setBits(maskTrackPropertiesV0, {selPosItsOnly, selPosGoodITSTrack}); - } else { - setBits(maskTrackPropertiesV0, {selPosGoodTPCTrack, selPosGoodITSTrack}); - // TPC signal is available: ask for positive track PID - if (PIDConfigurations.TpcPidNsigmaCut < 1e+5) { // safeguard for no cut - maskK0ShortSpecific.set(selTPCPIDPositivePion); - maskLambdaSpecific.set(selTPCPIDPositiveProton); - maskAntiLambdaSpecific.set(selTPCPIDPositivePion); - - maskXiSpecific.set(selTPCPIDPositiveProton); - maskAntiXiSpecific.set(selTPCPIDPositivePion); - maskOmegaSpecific.set(selTPCPIDPositiveProton); - maskAntiOmegaSpecific.set(selTPCPIDPositivePion); - } - // TOF PID - if (PIDConfigurations.TofPidNsigmaCutK0Pi < 1e+5) { // safeguard for no cut - setBits(maskK0ShortSpecific, {selTOFNSigmaPositivePionK0Short, selTOFDeltaTPositivePionK0Short}); - } - if (PIDConfigurations.TofPidNsigmaCutLaPr < 1e+5) { // safeguard for no cut - setBits(maskLambdaSpecific, {selTOFNSigmaPositiveProtonLambda, selTOFDeltaTPositiveProtonLambda}); - setBits(maskXiSpecific, {selTOFNSigmaPositiveProtonLambdaXi, selTOFDeltaTPositiveProtonLambdaXi}); - setBits(maskOmegaSpecific, {selTOFNSigmaPositiveProtonLambdaOmega, selTOFDeltaTPositiveProtonLambdaOmega}); - } - if (PIDConfigurations.TofPidNsigmaCutLaPi < 1e+5) { // safeguard for no cut - setBits(maskAntiLambdaSpecific, {selTOFNSigmaPositivePionLambda, selTOFDeltaTPositivePionLambda}); - setBits(maskAntiXiSpecific, {selTOFNSigmaPositivePionLambdaXi, selTOFDeltaTPositivePionLambdaXi}); - setBits(maskAntiOmegaSpecific, {selTOFNSigmaPositivePionLambdaOmega, selTOFDeltaTPositivePionLambdaOmega}); - } - } - // negative track - if (TrackConfigurations.requireNegITSonly) { - setBits(maskTrackPropertiesV0, {selNegItsOnly, selNegGoodITSTrack}); - } else { - setBits(maskTrackPropertiesV0, {selNegGoodTPCTrack, selNegGoodITSTrack}); - // TPC signal is available: ask for negative track PID - if (PIDConfigurations.TpcPidNsigmaCut < 1e+5) { // safeguard for no cut - maskK0ShortSpecific.set(selTPCPIDNegativePion); - maskLambdaSpecific.set(selTPCPIDNegativePion); - maskAntiLambdaSpecific.set(selTPCPIDNegativeProton); - - maskXiSpecific.set(selTPCPIDNegativePion); - maskAntiXiSpecific.set(selTPCPIDPositiveProton); - maskOmegaSpecific.set(selTPCPIDNegativePion); - maskAntiOmegaSpecific.set(selTPCPIDPositiveProton); - } - // TOF PID - if (PIDConfigurations.TofPidNsigmaCutK0Pi < 1e+5) { // safeguard for no cut - setBits(maskK0ShortSpecific, {selTOFNSigmaNegativePionK0Short, selTOFDeltaTNegativePionK0Short}); - } - if (PIDConfigurations.TofPidNsigmaCutLaPr < 1e+5) { // safeguard for no cut - setBits(maskAntiLambdaSpecific, {selTOFNSigmaNegativeProtonLambda, selTOFDeltaTNegativeProtonLambda}); - setBits(maskAntiXiSpecific, {selTOFNSigmaNegativeProtonLambdaXi, selTOFDeltaTNegativeProtonLambdaXi}); - setBits(maskAntiOmegaSpecific, {selTOFNSigmaNegativeProtonLambdaOmega, selTOFDeltaTNegativeProtonLambdaOmega}); - } - if (PIDConfigurations.TofPidNsigmaCutLaPi < 1e+5) { // safeguard for no cut - setBits(maskLambdaSpecific, {selTOFNSigmaNegativePionLambda, selTOFDeltaTNegativePionLambda}); - setBits(maskXiSpecific, {selTOFNSigmaNegativePionLambdaXi, selTOFDeltaTNegativePionLambdaXi}); - setBits(maskOmegaSpecific, {selTOFNSigmaNegativePionLambdaOmega, selTOFDeltaTNegativePionLambdaOmega}); - } - } - // bachelor track - maskTrackPropertiesCasc = maskTrackPropertiesV0; - if (TrackConfigurations.requireBachITSonly) { - setBits(maskTrackPropertiesCasc, {selBachItsOnly, selBachGoodITSTrack}); - } else { - setBits(maskTrackPropertiesCasc, {selBachGoodTPCTrack, selBachGoodITSTrack}); - // TPC signal is available: ask for positive track PID - if (PIDConfigurations.TpcPidNsigmaCut < 1e+5) { // safeguard for no cut - maskXiSpecific.set(selTPCPIDBachPion); - maskAntiXiSpecific.set(selTPCPIDBachPion); - maskOmegaSpecific.set(selTPCPIDBachKaon); - maskAntiOmegaSpecific.set(selTPCPIDBachKaon); - } - // TOF PID - if (PIDConfigurations.TofPidNsigmaCutXiPi < 1e+5) { // safeguard for no cut - setBits(maskXiSpecific, {selTOFNSigmaBachPionXi, selTOFDeltaTBachPionXi}); - setBits(maskAntiXiSpecific, {selTOFNSigmaBachPionXi, selTOFDeltaTBachPionXi}); - } - if (PIDConfigurations.TofPidNsigmaCutOmegaKaon < 1e+5) { // safeguard for no cut - setBits(maskOmegaSpecific, {selTOFNSigmaBachKaonOmega, selTOFDeltaTBachKaonOmega}); - setBits(maskAntiOmegaSpecific, {selTOFNSigmaBachKaonOmega, selTOFDeltaTBachKaonOmega}); - } - } - - if (TrackConfigurations.skipTPConly) { - setBits(maskK0ShortSpecific, {selPosNotTPCOnly, selNegNotTPCOnly}); - setBits(maskLambdaSpecific, {selPosNotTPCOnly, selNegNotTPCOnly}); - setBits(maskAntiLambdaSpecific, {selPosNotTPCOnly, selNegNotTPCOnly}); - setBits(maskXiSpecific, {selPosNotTPCOnly, selNegNotTPCOnly, selBachNotTPCOnly}); - setBits(maskOmegaSpecific, {selPosNotTPCOnly, selNegNotTPCOnly, selBachNotTPCOnly}); - setBits(maskAntiXiSpecific, {selPosNotTPCOnly, selNegNotTPCOnly, selBachNotTPCOnly}); - setBits(maskAntiOmegaSpecific, {selPosNotTPCOnly, selNegNotTPCOnly, selBachNotTPCOnly}); - } - - // Primary particle selection, central to analysis - maskSelectionK0Short = maskTopologicalV0 | maskKinematicV0 | maskTrackPropertiesV0 | maskK0ShortSpecific | (std::bitset(1) << selPhysPrimK0Short); - maskSelectionLambda = maskTopologicalV0 | maskKinematicV0 | maskTrackPropertiesV0 | maskLambdaSpecific | (std::bitset(1) << selPhysPrimLambda); - maskSelectionAntiLambda = maskTopologicalV0 | maskKinematicV0 | maskTrackPropertiesV0 | maskAntiLambdaSpecific | (std::bitset(1) << selPhysPrimAntiLambda); - maskSelectionXi = maskTopologicalCasc | maskKinematicCasc | maskTrackPropertiesCasc | maskXiSpecific | (std::bitset(1) << selPhysPrimXi); - maskSelectionAntiXi = maskTopologicalCasc | maskKinematicCasc | maskTrackPropertiesCasc | maskAntiXiSpecific | (std::bitset(1) << selPhysPrimAntiXi); - maskSelectionOmega = maskTopologicalCasc | maskKinematicCasc | maskTrackPropertiesCasc | maskOmegaSpecific | (std::bitset(1) << selPhysPrimOmega); - maskSelectionAntiOmega = maskTopologicalCasc | maskKinematicCasc | maskTrackPropertiesCasc | maskAntiOmegaSpecific | (std::bitset(1) << selPhysPrimAntiOmega); - - // Event Counters - histos.add("hEventSelection", "hEventSelection", kTH1F, {{16, -0.5f, +15.5f}}); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(2, "kIsTriggerTVX"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(3, "posZ cut"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(5, "kNoTimeFrameBorder"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(6, "kIsVertexITSTPC"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(7, "kIsGoodZvtxFT0vsPV"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(8, "kIsVertexTOFmatched"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(9, "kIsVertexTRDmatched"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(10, "kNoSameBunchPileup"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(11, "kNoCollInTimeRangeStd"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(12, "kNoCollInTimeRangeNarrow"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(13, "Below min occup."); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(14, "Above max occup."); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(15, "isUPC"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(16, "has UPC flag"); - - // Event QA - histos.add("eventQA/hCentrality", "hCentrality", kTH2F, {axisFT0C_QA, axisSelGap}); - histos.add("eventQA/hCentralityVsTracksPVeta1", "hCentralityVsTracksPVeta1", kTH3F, {axisFT0C_QA, axisNTracksPVeta1, axisSelGap}); - histos.add("eventQA/hCentralityVsTracksTotalExceptITSonly", "hCentralityVsTracksTotalExceptITSonly", kTH3F, {axisFT0C_QA, axisNTracksTotalExceptITSonly, axisSelGap}); - histos.add("eventQA/hOccupancy", "hOccupancy", kTH2F, {axisOccupancy, axisSelGap}); - histos.add("eventQA/hCentralityVsOccupancy", "hCentralityVsOccupancy", kTH3F, {axisFT0C_QA, axisOccupancy, axisSelGap}); - histos.add("eventQA/hTracksPVeta1VsTracksGlobal", "hTracksPVeta1VsTracksGlobal", kTH3F, {axisNTracksPVeta1, axisNTracksGlobal, axisSelGap}); - histos.add("eventQA/hCentralityVsTracksGlobal", "hCentralityVsTracksGlobal", kTH3F, {axisFT0C_QA, axisNTracksGlobal, axisSelGap}); - histos.add("eventQA/hGapSide", "Gap side; Entries", kTH1F, {{5, -0.5, 4.5}}); - histos.add("eventQA/hSelGapSide", "Selected gap side; Entries", kTH1F, {axisSelGap}); - histos.add("eventQA/hPosX", "Vertex position in x", kTH2F, {{100, -0.1, 0.1}, axisSelGap}); - histos.add("eventQA/hPosY", "Vertex position in y", kTH2F, {{100, -0.1, 0.1}, axisSelGap}); - histos.add("eventQA/hPosZ", "Vertex position in z", kTH2F, {{100, -20., 20.}, axisSelGap}); - histos.add("eventQA/hFT0", "hFT0", kTH3F, {axisDetectors.axisFT0Aampl, axisDetectors.axisFT0Campl, axisSelGap}); - histos.add("eventQA/hFDD", "hFDD", kTH3F, {axisDetectors.axisFDDAampl, axisDetectors.axisFDDCampl, axisSelGap}); - histos.add("eventQA/hZN", "hZN", kTH3F, {axisDetectors.axisZNAampl, axisDetectors.axisZNCampl, axisSelGap}); - - if (doprocessV0s) { - // For all candidates - if (doPlainTopoQA) { - histos.add("generalQA/hPt", "hPt", kTH1F, {axisPtCoarse}); - histos.add("generalQA/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("generalQA/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("generalQA/hDCADaughters", "hDCADaughters", kTH1F, {axisDCAdau}); - histos.add("generalQA/hPointingAngle", "hPointingAngle", kTH1F, {axisPointingAngle}); - histos.add("generalQA/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); - histos.add("generalQA/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("generalQA/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("generalQA/h2dArmenterosAll", "h2dArmenterosAll", kTH2F, {axisAPAlpha, axisAPQt}); - histos.add("generalQA/h2dArmenterosSelected", "h2dArmenterosSelected", kTH2F, {axisAPAlpha, axisAPQt}); - } - - // K0s - if (analyseK0Short) { - addHistograms<0>(histos); - } - - // Lambda - if (analyseLambda) { - addHistograms<1>(histos); - if (doCollisionAssociationQA) { - addCollisionAssocHistograms<1>(histos); - } - } - - // Anti-Lambda - if (analyseAntiLambda) { - addHistograms<2>(histos); - if (doCollisionAssociationQA) { - addCollisionAssocHistograms<2>(histos); - } - } - } - - if (doprocessCascades) { - // For all candidates - if (doPlainTopoQA) { - histos.add("generalQA/hPt", "hPt", kTH1F, {axisPtCoarse}); - histos.add("generalQA/hCascCosPA", "hCascCosPA", kTH2F, {axisPtCoarse, {100, 0.9f, 1.0f}}); - histos.add("generalQA/hDCACascDaughters", "hDCACascDaughters", kTH2F, {axisPtCoarse, {44, 0.0f, 2.2f}}); - histos.add("generalQA/hCascRadius", "hCascRadius", kTH2D, {axisPtCoarse, {500, 0.0f, 50.0f}}); - histos.add("generalQA/hMesonDCAToPV", "hMesonDCAToPV", kTH2F, {axisPtCoarse, axisDCAtoPV}); - histos.add("generalQA/hBaryonDCAToPV", "hBaryonDCAToPV", kTH2F, {axisPtCoarse, axisDCAtoPV}); - histos.add("generalQA/hBachDCAToPV", "hBachDCAToPV", kTH2F, {axisPtCoarse, {200, -1.0f, 1.0f}}); - histos.add("generalQA/hV0CosPA", "hV0CosPA", kTH2F, {axisPtCoarse, {100, 0.9f, 1.0f}}); - histos.add("generalQA/hV0Radius", "hV0Radius", kTH2D, {axisPtCoarse, axisV0Radius}); - histos.add("generalQA/hDCAV0Daughters", "hDCAV0Daughters", kTH2F, {axisPtCoarse, axisDCAdau}); - histos.add("generalQA/hDCAV0ToPV", "hDCAV0ToPV", kTH2F, {axisPtCoarse, {44, 0.0f, 2.2f}}); - histos.add("generalQA/hMassLambdaDau", "hMassLambdaDau", kTH2F, {axisPtCoarse, axisLambdaMass}); - histos.add("generalQA/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("generalQA/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("generalQA/h2dBachITSvsTPCpts", "h2dBachITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - } - - // Xi - if (analyseXi) { - addHistograms<3>(histos); - } - - // Anti-Xi - if (analyseAntiXi) { - addHistograms<4>(histos); - } - - // Omega - if (analyseOmega) { - addHistograms<5>(histos); - } - - // Anti-Omega - if (analyseAntiOmega) { - addHistograms<6>(histos); - } - } - - if (verbose) { - histos.print(); - } - } - - template - int getGapSide(TCollision const& collision) - { - int selGapSide = sgSelector.trueGap(collision, upcCuts.FV0cut, upcCuts.FT0Acut, upcCuts.FT0Ccut, upcCuts.ZDCcut); - histos.fill(HIST("eventQA/hGapSide"), collision.gapSide()); - histos.fill(HIST("eventQA/hSelGapSide"), selGapSide); - histos.fill(HIST("eventQA/hFT0"), collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), selGapSide); - histos.fill(HIST("eventQA/hFDD"), collision.totalFDDAmplitudeA(), collision.totalFDDAmplitudeC(), selGapSide); - histos.fill(HIST("eventQA/hZN"), collision.energyCommonZNA(), collision.energyCommonZNC(), selGapSide); - return selGapSide; - } - - template - void fillHistogramsQA(TCollision const& collision, int const& gap) - { - // QA histograms - float centrality = collision.centFT0C(); - histos.fill(HIST("eventQA/hCentrality"), centrality, gap); - histos.fill(HIST("eventQA/hCentralityVsTracksTotalExceptITSonly"), centrality, collision.multAllTracksTPCOnly() + collision.multAllTracksITSTPC(), gap); - histos.fill(HIST("eventQA/hCentralityVsTracksPVeta1"), centrality, collision.multNTracksPVeta1(), gap); - histos.fill(HIST("eventQA/hOccupancy"), collision.trackOccupancyInTimeRange(), gap); - histos.fill(HIST("eventQA/hCentralityVsOccupancy"), centrality, collision.trackOccupancyInTimeRange(), gap); - histos.fill(HIST("eventQA/hTracksPVeta1VsTracksGlobal"), collision.multNTracksPVeta1(), collision.multNTracksGlobal(), gap); - histos.fill(HIST("eventQA/hCentralityVsTracksGlobal"), centrality, collision.multNTracksGlobal(), gap); - histos.fill(HIST("eventQA/hPosX"), collision.posX(), gap); - histos.fill(HIST("eventQA/hPosY"), collision.posY(), gap); - histos.fill(HIST("eventQA/hPosZ"), collision.posZ(), gap); - } - - template - bool acceptEvent(TCollision const& collision) - { - histos.fill(HIST("hEventSelection"), 0. /* all collisions */); - - if (requireIsTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { - return false; - } - histos.fill(HIST("hEventSelection"), 1 /* triggered by FT0M */); - - if (fabs(collision.posZ()) > 10.f) { - return false; - } - histos.fill(HIST("hEventSelection"), 2 /* vertex-Z selected */); - - if (rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - return false; - } - histos.fill(HIST("hEventSelection"), 3 /* Not at ITS ROF border */); - - if (rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - return false; - } - histos.fill(HIST("hEventSelection"), 4 /* Not at TF border */); - - if (requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - return false; - } - histos.fill(HIST("hEventSelection"), 5 /* Contains at least one ITS-TPC track */); - - if (requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return false; - } - histos.fill(HIST("hEventSelection"), 6 /* PV position consistency check */); - - if (requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { - return false; - } - histos.fill(HIST("hEventSelection"), 7 /* PV with at least one contributor matched with TOF */); - - if (requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { - return false; - } - histos.fill(HIST("hEventSelection"), 8 /* PV with at least one contributor matched with TRD */); - - if (rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return false; - } - histos.fill(HIST("hEventSelection"), 9 /* Not at same bunch pile-up */); - - if (requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - return false; - } - histos.fill(HIST("hEventSelection"), 10 /* No other collision within +/- 10 microseconds */); - - if (requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { - return false; - } - histos.fill(HIST("hEventSelection"), 11 /* No other collision within +/- 4 microseconds */); - - if (minOccupancy > 0 && collision.trackOccupancyInTimeRange() < minOccupancy) { - return false; - } - histos.fill(HIST("hEventSelection"), 12 /* Above min occupancy */); - - if (maxOccupancy > 0 && collision.trackOccupancyInTimeRange() > maxOccupancy) { - return false; - } - histos.fill(HIST("hEventSelection"), 13 /* Below max occupancy */); - - if (studyUPConly && !collision.isUPC()) { - return false; - } else if (collision.isUPC()) { - histos.fill(HIST("hEventSelection"), 14 /* is UPC compatible */); - } - - if (useUPCflag && (collision.flags() < 1)) { - return false; - } else if (collision.flags() >= 1) { - histos.fill(HIST("hEventSelection"), 15 /* UPC event */); - } - - return true; - } - - bool verifyMask(std::bitset bitmap, std::bitset mask) - { - return (bitmap & mask) == mask; - } - - int computeITSclusBitmap(uint8_t itsClusMap, bool fromAfterburner) - { - int bitMap = 0; - - struct MaskBitmapPair { - uint8_t mask; - int bitmap; - int afterburnerBitmap; - }; - - constexpr MaskBitmapPair configs[] = { - // L6 <-- L0 - {0x7F, 12, 12}, // 01111 111 (L0 to L6) - {0x7E, 11, 11}, // 01111 110 (L1 to L6) - {0x7C, 10, 10}, // 01111 100 (L2 to L6) - {0x78, 9, -3}, // 01111 000 (L3 to L6) - {0x70, 8, -2}, // 01110 000 (L4 to L6) - {0x60, 7, -1}, // 01100 000 (L5 to L6) - {0x3F, 6, 6}, // 00111 111 (L0 to L5) - {0x3E, 5, 5}, // 00111 110 (L1 to L5) - {0x3C, 4, 4}, // 00111 100 (L2 to L5) - {0x1F, 3, 3}, // 00011 111 (L0 to L4) - {0x1E, 2, 2}, // 00011 110 (L1 to L4) - {0x0F, 1, 1}, // 00001 111 (L0 to L3) - }; - - for (const auto& config : configs) { - if (verifyMask(itsClusMap, config.mask)) { - bitMap = fromAfterburner ? config.afterburnerBitmap : config.bitmap; - break; - } - } - - return bitMap; - } - - uint computeDetBitmap(uint8_t detMap) - { - uint bitMap = 0; - - struct MaskBitmapPair { - uint8_t mask; - int bitmap; - }; - - constexpr MaskBitmapPair configs[] = { - {o2::aod::track::ITS | o2::aod::track::TPC | o2::aod::track::TRD | o2::aod::track::TOF, 4}, // ITS-TPC-TRD-TOF - {o2::aod::track::ITS | o2::aod::track::TPC | o2::aod::track::TOF, 3}, // ITS-TPC-TOF - {o2::aod::track::ITS | o2::aod::track::TPC | o2::aod::track::TRD, 2}, // ITS-TPC-TRD - {o2::aod::track::ITS | o2::aod::track::TPC, 1} // ITS-TPC - }; - - for (const auto& config : configs) { - if (verifyMask(detMap, config.mask)) { - bitMap = config.bitmap; - break; - } - } - - return bitMap; - } - - template - std::bitset computeBitmapCascade(TCasc const& casc, TCollision const& coll) - { - float rapidityXi = casc.yXi(); - float rapidityOmega = casc.yOmega(); - - // Access daughter tracks - auto posTrackExtra = casc.template posTrackExtra_as(); - auto negTrackExtra = casc.template negTrackExtra_as(); - auto bachTrackExtra = casc.template bachTrackExtra_as(); - - // c x tau - float decayPos = std::hypot(casc.x() - coll.posX(), casc.y() - coll.posY(), casc.z() - coll.posZ()); - float totalMom = std::hypot(casc.px(), casc.py(), casc.pz()); - float ctauXi = totalMom != 0 ? pdgDB->Mass(3312) * decayPos / totalMom : 1e6; - float ctauOmega = totalMom != 0 ? pdgDB->Mass(3334) * decayPos / totalMom : 1e6; - - std::bitset bitMap = 0; - - if (casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()) > casccuts.casccospa) - bitMap.set(selCascCosPA); - if (casc.dcacascdaughters() < casccuts.dcacascdau) - bitMap.set(selDCACascDau); - if (casc.cascradius() > casccuts.cascradius) - bitMap.set(selCascRadius); - if (casc.cascradius() < casccuts.cascradiusMax) - bitMap.set(selCascRadiusMax); - if (doBachelorBaryonCut && (casc.bachBaryonCosPA() < casccuts.bachbaryoncospa) && (fabs(casc.bachBaryonDCAxyToPV()) > casccuts.bachbaryondcaxytopv)) - bitMap.set(selBachBaryon); - if (fabs(casc.dcabachtopv()) > casccuts.dcabachtopv) - bitMap.set(selBachToPV); - - if (casc.sign() > 0) { - if (fabs(casc.dcanegtopv()) > casccuts.dcabaryontopv) - bitMap.set(selBaryonToPV); - if (fabs(casc.dcapostopv()) > casccuts.dcamesontopv) - bitMap.set(selMesonToPV); - } else { // no sign == 0, in principle - if (fabs(casc.dcapostopv()) > casccuts.dcabaryontopv) - bitMap.set(selBaryonToPV); - if (fabs(casc.dcanegtopv()) > casccuts.dcamesontopv) - bitMap.set(selMesonToPV); - } - - if (fabs(casc.mXi() - pdgDB->Mass(3312)) < casccuts.masswin) - bitMap.set(selMassWinXi); - if (fabs(casc.mOmega() - pdgDB->Mass(3334)) < casccuts.masswin) - bitMap.set(selMassWinOmega); - if (fabs(casc.mLambda() - pdgDB->Mass(3122)) < casccuts.lambdamasswin) - bitMap.set(selLambdaMassWin); - - if (fabs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())) > casccuts.dcav0topv) - bitMap.set(selDCAV0ToPV); - if (casc.v0radius() > v0cuts.v0radius) - bitMap.set(selV0Radius); - if (casc.v0radius() < v0cuts.v0radiusMax) - bitMap.set(selV0RadiusMax); - if (casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ()) > v0cuts.v0cospa) - bitMap.set(selV0CosPA); - if (casc.dcaV0daughters() < v0cuts.dcav0dau) - bitMap.set(selDCAV0Dau); - - // proper lifetime - if (ctauXi < nCtauCutCasc->get("lifetimecutXi") * ctauxiPDG) - bitMap.set(selXiCTau); - if (ctauOmega < nCtauCutCasc->get("lifetimecutOmega") * ctauomegaPDG) - bitMap.set(selOmegaCTau); - - auto poseta = RecoDecay::eta(std::array{casc.pxpos(), casc.pypos(), casc.pzpos()}); - auto negeta = RecoDecay::eta(std::array{casc.pxneg(), casc.pyneg(), casc.pzneg()}); - auto bacheta = RecoDecay::eta(std::array{casc.pxbach(), casc.pybach(), casc.pzbach()}); - - // kinematic - if (fabs(rapidityXi) < rapidityCut) - bitMap.set(selXiRapidity); - if (fabs(rapidityOmega) < rapidityCut) - bitMap.set(selOmegaRapidity); - if (fabs(poseta) < daughterEtaCut) - bitMap.set(selNegEta); - if (fabs(negeta) < daughterEtaCut) - bitMap.set(selPosEta); - if (fabs(bacheta) < daughterEtaCut) - bitMap.set(selBachEta); - - // ITS quality flags - if (posTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) - bitMap.set(selPosGoodITSTrack); - if (negTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) - bitMap.set(selNegGoodITSTrack); - if (bachTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) - bitMap.set(selBachGoodITSTrack); - - // TPC quality flags - if (posTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) - bitMap.set(selPosGoodTPCTrack); - if (negTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) - bitMap.set(selNegGoodTPCTrack); - if (bachTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) - bitMap.set(selBachGoodTPCTrack); - - // TPC PID - // positive track - if (fabs(posTrackExtra.tpcNSigmaPi()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDPositivePion); - if (fabs(posTrackExtra.tpcNSigmaPr()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDPositiveProton); - // negative track - if (fabs(negTrackExtra.tpcNSigmaPi()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDNegativePion); - if (fabs(negTrackExtra.tpcNSigmaPr()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDNegativeProton); - // bachelor track - if (fabs(bachTrackExtra.tpcNSigmaPi()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDBachPion); - if (fabs(bachTrackExtra.tpcNSigmaKa()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDBachKaon); - - // TOF PID in DeltaT - // positive track - if (fabs(casc.posTOFDeltaTXiPr()) < PIDConfigurations.maxDeltaTimeProton) - bitMap.set(selTOFDeltaTPositiveProtonLambdaXi); - if (fabs(casc.posTOFDeltaTXiPi()) < PIDConfigurations.maxDeltaTimePion) - bitMap.set(selTOFDeltaTPositivePionLambdaXi); - if (fabs(casc.posTOFDeltaTOmPr()) < PIDConfigurations.maxDeltaTimeProton) - bitMap.set(selTOFDeltaTPositiveProtonLambdaOmega); - if (fabs(casc.posTOFDeltaTOmPi()) < PIDConfigurations.maxDeltaTimePion) - bitMap.set(selTOFDeltaTPositivePionLambdaOmega); - // negative track - if (fabs(casc.negTOFDeltaTXiPr()) < PIDConfigurations.maxDeltaTimeProton) - bitMap.set(selTOFDeltaTNegativeProtonLambdaXi); - if (fabs(casc.negTOFDeltaTXiPi()) < PIDConfigurations.maxDeltaTimePion) - bitMap.set(selTOFDeltaTNegativePionLambdaXi); - if (fabs(casc.negTOFDeltaTOmPr()) < PIDConfigurations.maxDeltaTimeProton) - bitMap.set(selTOFDeltaTNegativeProtonLambdaOmega); - if (fabs(casc.negTOFDeltaTOmPi()) < PIDConfigurations.maxDeltaTimePion) - bitMap.set(selTOFDeltaTNegativePionLambdaOmega); - // bachelor track - if (fabs(casc.bachTOFDeltaTOmKa()) < PIDConfigurations.maxDeltaTimeKaon) - bitMap.set(selTOFDeltaTBachKaonOmega); - if (fabs(casc.bachTOFDeltaTXiPi()) < PIDConfigurations.maxDeltaTimePion) - bitMap.set(selTOFDeltaTBachPionXi); - - // TOF PID in NSigma - // meson track - if (fabs(casc.tofNSigmaXiLaPi()) < PIDConfigurations.TofPidNsigmaCutLaPi) { - bitMap.set(selTOFNSigmaPositivePionLambdaXi); - bitMap.set(selTOFNSigmaNegativePionLambdaXi); - } - if (fabs(casc.tofNSigmaOmLaPi()) < PIDConfigurations.TofPidNsigmaCutLaPi) { - bitMap.set(selTOFNSigmaPositivePionLambdaOmega); - bitMap.set(selTOFNSigmaNegativePionLambdaOmega); - } - // baryon track - if (fabs(casc.tofNSigmaXiLaPr()) < PIDConfigurations.TofPidNsigmaCutLaPr) { - bitMap.set(selTOFNSigmaNegativeProtonLambdaXi); - bitMap.set(selTOFNSigmaPositiveProtonLambdaXi); - } - if (fabs(casc.tofNSigmaOmLaPr()) < PIDConfigurations.TofPidNsigmaCutLaPr) { - bitMap.set(selTOFNSigmaNegativePionLambdaOmega); - bitMap.set(selTOFNSigmaPositivePionLambdaOmega); - } - // bachelor track - if (fabs(casc.tofNSigmaXiPi()) < PIDConfigurations.TofPidNsigmaCutXiPi) { - bitMap.set(selTOFNSigmaBachPionXi); - } - if (fabs(casc.tofNSigmaOmKa()) < PIDConfigurations.TofPidNsigmaCutOmegaKaon) { - bitMap.set(selTOFNSigmaBachKaonOmega); - } - - // ITS only tag - if (posTrackExtra.tpcCrossedRows() < 1) - bitMap.set(selPosItsOnly); - if (negTrackExtra.tpcCrossedRows() < 1) - bitMap.set(selNegItsOnly); - if (bachTrackExtra.tpcCrossedRows() < 1) - bitMap.set(selBachItsOnly); - - // rej. comp. - if (fabs(casc.mOmega() - pdgDB->Mass(3334)) > casccuts.rejcomp) - bitMap.set(selRejCompXi); - if (fabs(casc.mXi() - pdgDB->Mass(3312)) > casccuts.rejcomp) - bitMap.set(selRejCompOmega); - - // TPC only tag - if (posTrackExtra.detectorMap() != o2::aod::track::TPC) - bitMap.set(selPosNotTPCOnly); - if (negTrackExtra.detectorMap() != o2::aod::track::TPC) - bitMap.set(selNegNotTPCOnly); - if (bachTrackExtra.detectorMap() != o2::aod::track::TPC) - bitMap.set(selBachNotTPCOnly); - - return bitMap; - } - - template - std::bitset computeBitmapV0(TV0 const& v0, TCollision const& collision) - { - float rapidityLambda = v0.yLambda(); - float rapidityK0Short = v0.yK0Short(); - - std::bitset bitMap = 0; - - // base topological variables - if (v0.v0radius() > v0cuts.v0radius) - bitMap.set(selV0Radius); - if (v0.v0radius() < v0cuts.v0radiusMax) - bitMap.set(selV0RadiusMax); - if (fabs(v0.dcapostopv()) > v0cuts.dcapostopv) - bitMap.set(selDCAPosToPV); - if (fabs(v0.dcanegtopv()) > v0cuts.dcanegtopv) - bitMap.set(selDCANegToPV); - if (v0.v0cosPA() > v0cuts.v0cospa) - bitMap.set(selV0CosPA); - if (v0.dcaV0daughters() < v0cuts.dcav0dau) - bitMap.set(selDCAV0Dau); - - // kinematic - if (fabs(rapidityLambda) < rapidityCut) - bitMap.set(selLambdaRapidity); - if (fabs(rapidityK0Short) < rapidityCut) - bitMap.set(selK0ShortRapidity); - if (fabs(v0.negativeeta()) < daughterEtaCut) - bitMap.set(selNegEta); - if (fabs(v0.positiveeta()) < daughterEtaCut) - bitMap.set(selPosEta); - - auto posTrackExtra = v0.template posTrackExtra_as(); - auto negTrackExtra = v0.template negTrackExtra_as(); - - // ITS quality flags - if (posTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) - bitMap.set(selPosGoodITSTrack); - if (negTrackExtra.itsNCls() >= TrackConfigurations.minITSclusters) - bitMap.set(selNegGoodITSTrack); - - // TPC quality flags - if (posTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) - bitMap.set(selPosGoodTPCTrack); - if (negTrackExtra.tpcCrossedRows() >= TrackConfigurations.minTPCrows) - bitMap.set(selNegGoodTPCTrack); - - // TPC PID - if (fabs(posTrackExtra.tpcNSigmaPi()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDPositivePion); - if (fabs(posTrackExtra.tpcNSigmaPr()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDPositiveProton); - if (fabs(negTrackExtra.tpcNSigmaPi()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDNegativePion); - if (fabs(negTrackExtra.tpcNSigmaPr()) < PIDConfigurations.TpcPidNsigmaCut) - bitMap.set(selTPCPIDNegativeProton); - - // TOF PID in DeltaT - // positive track - if (fabs(v0.posTOFDeltaTLaPr()) < PIDConfigurations.maxDeltaTimeProton) - bitMap.set(selTOFDeltaTPositiveProtonLambda); - if (fabs(v0.posTOFDeltaTLaPi()) < PIDConfigurations.maxDeltaTimePion) - bitMap.set(selTOFDeltaTPositivePionLambda); - if (fabs(v0.posTOFDeltaTK0Pi()) < PIDConfigurations.maxDeltaTimePion) - bitMap.set(selTOFDeltaTPositivePionK0Short); - // negative track - if (fabs(v0.negTOFDeltaTLaPr()) < PIDConfigurations.maxDeltaTimeProton) - bitMap.set(selTOFDeltaTNegativeProtonLambda); - if (fabs(v0.negTOFDeltaTLaPi()) < PIDConfigurations.maxDeltaTimePion) - bitMap.set(selTOFDeltaTNegativePionLambda); - if (fabs(v0.negTOFDeltaTK0Pi()) < PIDConfigurations.maxDeltaTimePion) - bitMap.set(selTOFDeltaTNegativePionK0Short); - - // TOF PID in NSigma - // positive track - if (fabs(v0.tofNSigmaLaPr()) < PIDConfigurations.TofPidNsigmaCutLaPr) - bitMap.set(selTOFNSigmaPositiveProtonLambda); - if (fabs(v0.tofNSigmaALaPi()) < PIDConfigurations.TofPidNsigmaCutLaPi) - bitMap.set(selTOFNSigmaPositivePionLambda); - if (fabs(v0.tofNSigmaK0PiPlus()) < PIDConfigurations.TofPidNsigmaCutK0Pi) - bitMap.set(selTOFNSigmaPositivePionK0Short); - // negative track - if (fabs(v0.tofNSigmaALaPr()) < PIDConfigurations.TofPidNsigmaCutLaPr) - bitMap.set(selTOFNSigmaNegativeProtonLambda); - if (fabs(v0.tofNSigmaLaPi()) < PIDConfigurations.TofPidNsigmaCutLaPi) - bitMap.set(selTOFNSigmaNegativePionLambda); - if (fabs(v0.tofNSigmaK0PiMinus()) < PIDConfigurations.TofPidNsigmaCutK0Pi) - bitMap.set(selTOFNSigmaNegativePionK0Short); - - // ITS only tag - if (posTrackExtra.tpcCrossedRows() < 1) - bitMap.set(selPosItsOnly); - if (negTrackExtra.tpcCrossedRows() < 1) - bitMap.set(selNegItsOnly); - - // TPC only tag - if (posTrackExtra.detectorMap() != o2::aod::track::TPC) - bitMap.set(selPosNotTPCOnly); - if (negTrackExtra.detectorMap() != o2::aod::track::TPC) - bitMap.set(selNegNotTPCOnly); - - // proper lifetime - if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0 < lifetimecutV0->get("lifetimecutLambda")) - bitMap.set(selLambdaCTau); - if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecutV0->get("lifetimecutK0S")) - bitMap.set(selK0ShortCTau); - - // armenteros - if (v0.qtarm() * v0cuts.armPodCut > fabs(v0.alpha()) || v0cuts.armPodCut < 1e-4) - bitMap.set(selK0ShortArmenteros); - - return bitMap; - } - - template - void analyseCascCandidate(TCasc const& casc, TCollision const& coll, int const& gap, std::bitset const& selMap) - { - // Access daughter tracks - auto posTrackExtra = casc.template posTrackExtra_as(); - auto negTrackExtra = casc.template negTrackExtra_as(); - auto bachTrackExtra = casc.template bachTrackExtra_as(); - - if (doPlainTopoQA) { - histos.fill(HIST("generalQA/hPt"), casc.pt()); - histos.fill(HIST("generalQA/hCascCosPA"), casc.pt(), casc.casccosPA(coll.posX(), coll.posY(), coll.posZ())); - histos.fill(HIST("generalQA/hDCACascDaughters"), casc.pt(), casc.dcacascdaughters()); - histos.fill(HIST("generalQA/hCascRadius"), casc.pt(), casc.cascradius()); - histos.fill(HIST("generalQA/hMesonDCAToPV"), casc.pt(), casc.dcanegtopv()); - histos.fill(HIST("generalQA/hBaryonDCAToPV"), casc.pt(), casc.dcapostopv()); - histos.fill(HIST("generalQA/hBachDCAToPV"), casc.pt(), casc.dcabachtopv()); - histos.fill(HIST("generalQA/hV0CosPA"), casc.pt(), casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ())); - histos.fill(HIST("generalQA/hV0Radius"), casc.pt(), casc.v0radius()); - histos.fill(HIST("generalQA/hDCAV0Daughters"), casc.pt(), casc.dcaV0daughters()); - histos.fill(HIST("generalQA/hDCAV0ToPV"), casc.pt(), fabs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ()))); - histos.fill(HIST("generalQA/hMassLambdaDau"), casc.pt(), casc.mLambda()); - histos.fill(HIST("generalQA/h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); - histos.fill(HIST("generalQA/h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); - histos.fill(HIST("generalQA/h2dBachITSvsTPCpts"), bachTrackExtra.tpcCrossedRows(), bachTrackExtra.itsNCls()); - } - - // Xi - if (verifyMask(selMap, maskSelectionXi) && analyseXi) { - fillHistogramsCasc<3>(casc, coll, gap); - } - - // Anti-Xi - if (verifyMask(selMap, maskSelectionAntiXi) && analyseAntiXi) { - fillHistogramsCasc<4>(casc, coll, gap); - } - - // Omega - if (verifyMask(selMap, maskSelectionOmega) && analyseOmega) { - fillHistogramsCasc<5>(casc, coll, gap); - } - - // Anti-Omega - if (verifyMask(selMap, maskSelectionAntiOmega) && analyseAntiOmega) { - fillHistogramsCasc<6>(casc, coll, gap); - } - } - - template - void analyseV0Candidate(TV0 const& v0, TCollision const& coll, int const& gap, std::bitset const& selMap) - { - auto posTrackExtra = v0.template posTrackExtra_as(); - auto negTrackExtra = v0.template negTrackExtra_as(); - - // QA plots - if (doPlainTopoQA) { - histos.fill(HIST("generalQA/hPt"), v0.pt()); - histos.fill(HIST("generalQA/hPosDCAToPV"), v0.dcapostopv()); - histos.fill(HIST("generalQA/hNegDCAToPV"), v0.dcanegtopv()); - histos.fill(HIST("generalQA/hDCADaughters"), v0.dcaV0daughters()); - histos.fill(HIST("generalQA/hPointingAngle"), TMath::ACos(v0.v0cosPA())); - histos.fill(HIST("generalQA/hV0Radius"), v0.v0radius()); - histos.fill(HIST("generalQA/h2dPositiveITSvsTPCpts"), posTrackExtra.tpcCrossedRows(), posTrackExtra.itsNCls()); - histos.fill(HIST("generalQA/h2dNegativeITSvsTPCpts"), negTrackExtra.tpcCrossedRows(), negTrackExtra.itsNCls()); - } - - histos.fill(HIST("generalQA/h2dArmenterosAll"), v0.alpha(), v0.qtarm()); - - // K0s - if (verifyMask(selMap, maskSelectionK0Short) && analyseK0Short) { - fillHistogramsV0<0>(v0, coll, gap); - } - - // Lambda - if (verifyMask(selMap, maskSelectionLambda) && analyseLambda) { - fillHistogramsV0<1>(v0, coll, gap); - } - - // Anti-Lambda - if (verifyMask(selMap, maskSelectionAntiLambda) && analyseAntiLambda) { - fillHistogramsV0<2>(v0, coll, gap); - } - } - - void processV0s(straCollisonFull const& collision, v0Candidates const& fullV0s, dauTracks const&) - { - if (!acceptEvent(collision)) { - return; - } // event is accepted - - int selGapSide = collision.isUPC() ? getGapSide(collision) : -1; - if (studyUPConly && (selGapSide < -0.5)) - return; - - fillHistogramsQA(collision, selGapSide); - - for (auto& v0 : fullV0s) { - if ((v0.v0Type() != v0cuts.v0TypeSelection) && (v0cuts.v0TypeSelection > 0)) - continue; // skip V0s that are not standard - - std::bitset selMap = computeBitmapV0(v0, collision); - - // consider for histograms for all species - setBits(selMap, {selConsiderK0Short, selConsiderLambda, selConsiderAntiLambda, - selPhysPrimK0Short, selPhysPrimLambda, selPhysPrimAntiLambda}); - - analyseV0Candidate(v0, collision, selGapSide, selMap); - } // end v0 loop - } - - void processCascades(straCollisonFull const& collision, cascadeCandidates const& fullCascades, dauTracks const&) - { - if (!acceptEvent(collision)) { - return; - } // event is accepted - - int selGapSide = collision.isUPC() ? getGapSide(collision) : -1; - if (studyUPConly && (selGapSide < -0.5)) - return; - - fillHistogramsQA(collision, selGapSide); - - for (auto& casc : fullCascades) { - std::bitset selMap = computeBitmapCascade(casc, collision); - // consider for histograms for all species - setBits(selMap, {selConsiderXi, selConsiderAntiXi, selConsiderOmega, selConsiderAntiOmega, - selPhysPrimXi, selPhysPrimAntiXi, selPhysPrimOmega, selPhysPrimAntiOmega}); - - analyseCascCandidate(casc, collision, selGapSide, selMap); - } // end casc loop - } - - PROCESS_SWITCH(strangeYieldPbPb, processV0s, "Process V0s", true); - PROCESS_SWITCH(strangeYieldPbPb, processCascades, "Process Cascades", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGLF/Tasks/Strangeness/strangenessInJets.cxx b/PWGLF/Tasks/Strangeness/strangenessInJets.cxx new file mode 100644 index 00000000000..847c6421e54 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/strangenessInJets.cxx @@ -0,0 +1,1425 @@ +// 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. +/// +/// \file strangenessInJets.cxx +/// +/// \brief task for analysis of strangeness in jets +/// \author Alberto Calivà (alberto.caliva@cern.ch) +/// \author Francesca Ercolessi (francesca.ercolessi@cern.ch) +/// \author Nicolò Jacazio (nicolo.jacazio@cern.ch) +/// \author Sara Pucillo (sara.pucillo@cern.ch) +/// +/// \since May 22, 2024 + +#include "PWGJE/Core/JetBkgSubUtils.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace std; +using namespace o2; +using namespace o2::soa; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +using namespace o2::constants::math; +using std::array; + +// Define convenient aliases for joined AOD tables +using SelCollisions = soa::Join; +using SimCollisions = soa::Join; +using DaughterTracks = soa::Join; +using DaughterTracksMC = soa::Join; + +struct StrangenessInJets { + + // Instantiate the CCDB service and API interface + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + + // Instantiate the Zorro processor for skimmed data and define an output object + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + + // Define histogram registries + HistogramRegistry registryData{"registryData", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry registryMC{"registryMC", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry registryQC{"registryQC", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Global analysis parameters + Configurable particleOfInterest{"particleOfInterest", 0, "0 = K0 and Lambda, 1 = Xi and Omega"}; + Configurable minJetPt{"minJetPt", 10.0, "Minimum reconstructed pt of the jet (GeV/c)"}; + Configurable rJet{"rJet", 0.3, "Jet resolution parameter (R)"}; + Configurable zVtx{"zVtx", 10.0, "Maximum z-vertex position"}; + Configurable deltaEtaEdge{"deltaEtaEdge", 0.05, "eta gap from detector edge"}; + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "Enable processing of skimmed data"}; + Configurable triggerName{"triggerName", "fOmega", "Software trigger name"}; + + // Track analysis parameters + Configurable minITSnCls{"minITSnCls", 4, "Minimum number of ITS clusters"}; + Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 80, "Minimum number of TPC crossed rows"}; + Configurable maxChi2TPC{"maxChi2TPC", 4.0f, "Maximum chi2 per cluster TPC"}; + Configurable etaMin{"etaMin", -0.8f, "Minimum eta"}; + Configurable etaMax{"etaMax", +0.8f, "Maximum eta"}; + Configurable ptMinV0Proton{"ptMinV0Proton", 0.3f, "Minimum pt of protons from V0"}; + Configurable ptMaxV0Proton{"ptMaxV0Proton", 10.0f, "Maximum pt of protons from V0"}; + Configurable ptMinV0Pion{"ptMinV0Pion", 0.1f, "Minimum pt of pions from V0"}; + Configurable ptMaxV0Pion{"ptMaxV0Pion", 1.5f, "Maximum pt of pions from V0"}; + Configurable ptMinK0Pion{"ptMinK0Pion", 0.3f, "Minimum pt of pions from K0"}; + Configurable ptMaxK0Pion{"ptMaxK0Pion", 10.0f, "Maximum pt of pions from K0"}; + Configurable nsigmaTPCmin{"nsigmaTPCmin", -3.0f, "Minimum nsigma TPC"}; + Configurable nsigmaTPCmax{"nsigmaTPCmax", +3.0f, "Maximum nsigma TPC"}; + Configurable nsigmaTOFmin{"nsigmaTOFmin", -3.0f, "Minimum nsigma TOF"}; + Configurable nsigmaTOFmax{"nsigmaTOFmax", +3.0f, "Maximum nsigma TOF"}; + Configurable requireITS{"requireITS", false, "Require ITS hit"}; + Configurable requireTOF{"requireTOF", false, "Require TOF hit"}; + + // V0 analysis parameters + Configurable minimumV0Radius{"minimumV0Radius", 0.5f, "Minimum V0 Radius"}; + Configurable maximumV0Radius{"maximumV0Radius", 40.0f, "Maximum V0 Radius"}; + Configurable dcanegtoPVmin{"dcanegtoPVmin", 0.1f, "Minimum DCA of negative track to primary vertex"}; + Configurable dcapostoPVmin{"dcapostoPVmin", 0.1f, "Minimum DCA of positive track to primary vertex"}; + Configurable v0cospaMin{"v0cospaMin", 0.99f, "Minimum V0 cosine of pointing angle"}; + Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 0.5f, "Maximum DCA between V0 daughters"}; + + // Cascade analysis parameters + Configurable minimumCascRadius{"minimumCascRadius", 0.1f, "Minimum cascade radius"}; + Configurable maximumCascRadius{"maximumCascRadius", 40.0f, "Maximum cascade radius"}; + Configurable casccospaMin{"casccospaMin", 0.99f, "Minimum cascade cosine of pointing angle"}; + Configurable dcabachtopvMin{"dcabachtopvMin", 0.1f, "Minimum DCA of bachelor to primary vertex"}; + Configurable dcaV0topvMin{"dcaV0topvMin", 0.1f, "Minimum DCA of V0 to primary vertex"}; + Configurable dcaCascDaughtersMax{"dcaCascDaughtersMax", 0.5f, "Maximum DCA between daughters"}; + Configurable deltaMassXi{"deltaMassXi", 0.02f, "Mass window for Xi rejection"}; + Configurable deltaMassOmega{"deltaMassOmega", 0.02f, "Mass window for Omega rejection"}; + Configurable deltaMassLambda{"deltaMassLambda", 0.02f, "Mass window for Lambda inclusion"}; + + // List of Particles + enum Option { kV0Particles, + kCascades }; + + // Instantiate utility class for jet background subtraction + JetBkgSubUtils backgroundSub; + + // Initialize CCDB access and histogram registry for Zorro processing + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (cfgSkimmedProcessing) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), triggerName.value); + zorro.populateHistRegistry(registryData, bc.runNumber()); + } + } + + void init(InitContext const&) + { + if (cfgSkimmedProcessing) { + zorroSummary.setObject(zorro.getZorroSummary()); + } + + // Define binning and axis specifications for multiplicity, eta, pT, PID, and invariant mass histograms + std::vector multBinning = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; + AxisSpec multAxis = {multBinning, "FT0C percentile"}; + const AxisSpec ptAxis{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec invMassK0sAxis{200, 0.44, 0.56, "m_{#pi#pi} (GeV/#it{c}^{2})"}; + const AxisSpec invMassLambdaAxis{200, 1.09, 1.14, "m_{p#pi} (GeV/#it{c}^{2})"}; + const AxisSpec invMassXiAxis{200, 1.28, 1.36, "m_{p#pi#pi} (GeV/#it{c}^{2})"}; + const AxisSpec invMassOmegaAxis{200, 1.63, 1.71, "m_{p#piK} (GeV/#it{c}^{2})"}; + + // Histograms for real data + if (doprocessData) { + + // Event counters + registryData.add("number_of_events_data", "number of events in data", HistType::kTH1D, {{20, 0, 20, "Event Cuts"}}); + registryData.add("number_of_events_vsmultiplicity", "number of events in data vs multiplicity", HistType::kTH1D, {{101, 0, 101, "Multiplicity percentile"}}); + + // Histograms for analysis of strange hadrons + switch (particleOfInterest) { + case kV0Particles: + registryData.add("Lambda_in_jet", "Lambda_in_jet", HistType::kTH3F, {multBinning, ptAxis, invMassLambdaAxis}); + registryData.add("AntiLambda_in_jet", "AntiLambda_in_jet", HistType::kTH3F, {multBinning, ptAxis, invMassLambdaAxis}); + registryData.add("Lambda_in_ue", "Lambda_in_ue", HistType::kTH3F, {multBinning, ptAxis, invMassLambdaAxis}); + registryData.add("AntiLambda_in_ue", "AntiLambda_in_ue", HistType::kTH3F, {multBinning, ptAxis, invMassLambdaAxis}); + registryData.add("K0s_in_jet", "K0s_in_jet", HistType::kTH3F, {multBinning, ptAxis, invMassK0sAxis}); + registryData.add("K0s_in_ue", "K0s_in_ue", HistType::kTH3F, {multBinning, ptAxis, invMassK0sAxis}); + break; + case kCascades: + registryData.add("XiPos_in_jet", "XiPos_in_jet", HistType::kTH3F, {multBinning, ptAxis, invMassXiAxis}); + registryData.add("XiPos_in_ue", "XiPos_in_ue", HistType::kTH3F, {multBinning, ptAxis, invMassXiAxis}); + registryData.add("XiNeg_in_jet", "XiNeg_in_jet", HistType::kTH3F, {multBinning, ptAxis, invMassXiAxis}); + registryData.add("XiNeg_in_ue", "XiNeg_in_ue", HistType::kTH3F, {multBinning, ptAxis, invMassXiAxis}); + registryData.add("OmegaPos_in_jet", "OmegaPos_in_jet", HistType::kTH3F, {multBinning, ptAxis, invMassOmegaAxis}); + registryData.add("OmegaPos_in_ue", "OmegaPos_in_ue", HistType::kTH3F, {multBinning, ptAxis, invMassOmegaAxis}); + registryData.add("OmegaNeg_in_jet", "OmegaNeg_in_jet", HistType::kTH3F, {multBinning, ptAxis, invMassOmegaAxis}); + registryData.add("OmegaNeg_in_ue", "OmegaNeg_in_ue", HistType::kTH3F, {multBinning, ptAxis, invMassOmegaAxis}); + break; + default: + LOG(fatal) << "Cannot interpret particle " << particleOfInterest; + break; + } + } + + // Histograms for mc generated + if (doprocessMCgenerated) { + + // Event counter + registryMC.add("number_of_events_mc_gen", "number of gen events in mc", HistType::kTH1D, {{10, 0, 10, "Event Cuts"}}); + + // Histograms for analysis + registryMC.add("K0s_generated_jet", "K0s_generated_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("K0s_generated_ue", "K0s_generated_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("Lambda_generated_jet", "Lambda_generated_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("Lambda_generated_ue", "Lambda_generated_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("AntiLambda_generated_jet", "AntiLambda_generated_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("AntiLambda_generated_ue", "AntiLambda_generated_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("XiPos_generated_jet", "XiPos_generated_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("XiPos_generated_ue", "XiPos_generated_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("XiNeg_generated_jet", "XiNeg_generated_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("XiNeg_generated_ue", "XiNeg_generated_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("OmegaPos_generated_jet", "OmegaPos_generated_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("OmegaPos_generated_ue", "OmegaPos_generated_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("OmegaNeg_generated_jet", "OmegaNeg_generated_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("OmegaNeg_generated_ue", "OmegaNeg_generated_ue", HistType::kTH2F, {multBinning, ptAxis}); + } + + // Histograms for mc reconstructed + if (doprocessMCreconstructed) { + + // Event counter + registryMC.add("number_of_events_mc_rec", "number of rec events in mc", HistType::kTH1D, {{10, 0, 10, "Event Cuts"}}); + + // Histograms for analysis + registryMC.add("K0s_reconstructed_jet", "K0s_reconstructed_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("K0s_reconstructed_ue", "K0s_reconstructed_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("Lambda_reconstructed_jet", "Lambda_reconstructed_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("Lambda_reconstructed_ue", "Lambda_reconstructed_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("AntiLambda_reconstructed_jet", "AntiLambda_reconstructed_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("AntiLambda_reconstructed_ue", "AntiLambda_reconstructed_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("XiPos_reconstructed_jet", "XiPos_reconstructed_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("XiPos_reconstructed_ue", "XiPos_reconstructed_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("XiNeg_reconstructed_jet", "XiNeg_reconstructed_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("XiNeg_reconstructed_ue", "XiNeg_reconstructed_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("OmegaPos_reconstructed_jet", "OmegaPos_reconstructed_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("OmegaPos_reconstructed_ue", "OmegaPos_reconstructed_ue", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("OmegaNeg_reconstructed_jet", "OmegaNeg_reconstructed_jet", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("OmegaNeg_reconstructed_ue", "OmegaNeg_reconstructed_ue", HistType::kTH2F, {multBinning, ptAxis}); + + // Histograms for secondary hadrons + registryMC.add("K0s_reconstructed_jet_incl", "K0s_reconstructed_jet_incl", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("K0s_reconstructed_ue_incl", "K0s_reconstructed_ue_incl", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("Lambda_reconstructed_jet_incl", "Lambda_reconstructed_jet_incl", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("Lambda_reconstructed_ue_incl", "Lambda_reconstructed_ue_incl", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("AntiLambda_reconstructed_jet_incl", "AntiLambda_reconstructed_jet_incl", HistType::kTH2F, {multBinning, ptAxis}); + registryMC.add("AntiLambda_reconstructed_ue_incl", "AntiLambda_reconstructed_ue_incl", HistType::kTH2F, {multBinning, ptAxis}); + } + } + + // Calculation of perpendicular axes + void getPerpendicularAxis(TVector3 p, TVector3& u, double sign) + { + // initialization + double ux(0), uy(0), uz(0); + + // components of vector p + double px = p.X(); + double py = p.Y(); + double pz = p.Z(); + + // protection 1 + if (px == 0 && py != 0) { + uy = -(pz * pz) / py; + ux = sign * std::sqrt(py * py - (pz * pz * pz * pz) / (py * py)); + uz = pz; + u.SetXYZ(ux, uy, uz); + return; + } + + // protection 2 + if (py == 0 && px != 0) { + ux = -(pz * pz) / px; + uy = sign * std::sqrt(px * px - (pz * pz * pz * pz) / (px * px)); + uz = pz; + u.SetXYZ(ux, uy, uz); + return; + } + + // equation parameters + double a = px * px + py * py; + double b = 2.0 * px * pz * pz; + double c = pz * pz * pz * pz - py * py * py * py - px * px * py * py; + double delta = b * b - 4.0 * a * c; + + // protection agains delta<0 + if (delta < 0) { + return; + } + + // solutions + ux = (-b + sign * std::sqrt(delta)) / (2.0 * a); + uy = (-pz * pz - px * ux) / py; + uz = pz; + u.SetXYZ(ux, uy, uz); + return; + } + + // Delta phi calculation + double getDeltaPhi(double a1, double a2) + { + double deltaPhi(0); + double phi1 = TVector2::Phi_0_2pi(a1); + double phi2 = TVector2::Phi_0_2pi(a2); + double diff = std::fabs(phi1 - phi2); + + if (diff <= PI) + deltaPhi = diff; + if (diff > PI) + deltaPhi = TwoPI - diff; + + return deltaPhi; + } + + // Find ITS hit + template + bool hasITSHitOnLayer(const TrackIts& track, int layer) + { + int ibit = layer - 1; + return (track.itsClusterMap() & (1 << ibit)); + } + + // Single-track selection for particles inside jets + template + bool passedTrackSelectionForJetReconstruction(const JetTrack& track) + { + const int minTpcCr = 70; + const double maxChi2Tpc = 4.0; + const double maxChi2Its = 36.0; + const double maxPseudorapidity = 0.8; + const double minPtTrack = 0.1; + const double dcaxyMaxTrackPar0 = 0.0105; + const double dcaxyMaxTrackPar1 = 0.035; + const double dcaxyMaxTrackPar2 = 1.1; + const double dcazMaxTrack = 2.0; + + if (!track.hasITS()) + return false; + if ((!hasITSHitOnLayer(track, 1)) && (!hasITSHitOnLayer(track, 2)) && (!hasITSHitOnLayer(track, 3))) + return false; + if (!track.hasTPC()) + return false; + if (track.tpcNClsCrossedRows() < minTpcCr) + return false; + if (track.tpcChi2NCl() > maxChi2Tpc) + return false; + if (track.itsChi2NCl() > maxChi2Its) + return false; + if (std::fabs(track.eta()) > maxPseudorapidity) + return false; + if (track.pt() < minPtTrack) + return false; + if (std::fabs(track.dcaXY()) > (dcaxyMaxTrackPar0 + dcaxyMaxTrackPar1 / std::pow(track.pt(), dcaxyMaxTrackPar2))) + return false; + if (std::fabs(track.dcaZ()) > dcazMaxTrack) + return false; + return true; + } + + // Lambda selections + template + bool passedLambdaSelection(const Lambda& v0, const TrackPos& ptrack, const TrackNeg& ntrack) + { + // Single-track selections + if (!passedSingleTrackSelection(ptrack) || !passedSingleTrackSelection(ntrack)) + return false; + + // Momentum of lambda daughters + TVector3 proton(v0.pxpos(), v0.pypos(), v0.pzpos()); + TVector3 pion(v0.pxneg(), v0.pyneg(), v0.pzneg()); + + // Selection on pt of Lambda daughters + if (proton.Pt() < ptMinV0Proton || proton.Pt() > ptMaxV0Proton) + return false; + if (pion.Pt() < ptMinV0Pion || pion.Pt() > ptMaxV0Pion) + return false; + + // V0 selections + if (v0.v0cosPA() < v0cospaMin) + return false; + if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) + return false; + if (std::fabs(v0.dcaV0daughters()) > dcaV0DaughtersMax) + return false; + if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) + return false; + if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) + return false; + + // PID selections (TPC): positive track = proton, negative track = pion + if (ptrack.tpcNSigmaPr() < nsigmaTPCmin || ptrack.tpcNSigmaPr() > nsigmaTPCmax) + return false; + if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + + // PID selections (TOF): positive track = proton, negative track = pion + if (requireTOF) { + if (ptrack.tofNSigmaPr() < nsigmaTOFmin || ptrack.tofNSigmaPr() > nsigmaTOFmax) + return false; + if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + } + return true; + } + + // AntiLambda selections + template + bool passedAntiLambdaSelection(const AntiLambda& v0, const TrackPos& ptrack, const TrackNeg& ntrack) + { + // Single-track selections + if (!passedSingleTrackSelection(ptrack) || !passedSingleTrackSelection(ntrack)) + return false; + + // Momentum AntiLambda daughters + TVector3 pion(v0.pxpos(), v0.pypos(), v0.pzpos()); + TVector3 proton(v0.pxneg(), v0.pyneg(), v0.pzneg()); + + // Selections on pt of Antilambda daughters + if (proton.Pt() < ptMinV0Proton || proton.Pt() > ptMaxV0Proton) + return false; + if (pion.Pt() < ptMinV0Pion || pion.Pt() > ptMaxV0Pion) + return false; + + // V0 selections + if (v0.v0cosPA() < v0cospaMin) + return false; + if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) + return false; + if (std::fabs(v0.dcaV0daughters()) > dcaV0DaughtersMax) + return false; + if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) + return false; + if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) + return false; + + // PID selections (TPC): negative track = proton, positive track = pion + if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + if (ntrack.tpcNSigmaPr() < nsigmaTPCmin || ntrack.tpcNSigmaPr() > nsigmaTPCmax) + return false; + + // PID selections (TOF): negative track = proton, positive track = pion + if (requireTOF) { + if (ptrack.tofNSigmaPi() < nsigmaTOFmin || ptrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + if (ntrack.tofNSigmaPr() < nsigmaTOFmin || ntrack.tofNSigmaPr() > nsigmaTOFmax) + return false; + } + return true; + } + + // K0s selections + template + bool passedK0ShortSelection(const K0short& v0, const TrackPos& ptrack, const TrackNeg& ntrack) + { + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack) || !passedSingleTrackSelection(ntrack)) + return false; + + // Momentum of K0s daughters + TVector3 pionPos(v0.pxpos(), v0.pypos(), v0.pzpos()); + TVector3 pionNeg(v0.pxneg(), v0.pyneg(), v0.pzneg()); + + // Selections on pt of K0s daughters + if (pionPos.Pt() < ptMinK0Pion || pionPos.Pt() > ptMaxK0Pion) + return false; + if (pionNeg.Pt() < ptMinK0Pion || pionNeg.Pt() > ptMaxK0Pion) + return false; + + // V0 selections + if (v0.v0cosPA() < v0cospaMin) + return false; + if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) + return false; + if (std::fabs(v0.dcaV0daughters()) > dcaV0DaughtersMax) + return false; + if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) + return false; + if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) + return false; + + // PID selections (TPC) + if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + + // PID selections (TOF) + if (requireTOF) { + if (ptrack.tofNSigmaPi() < nsigmaTOFmin || ptrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + } + return true; + } + + // Xi Selections + template + bool passedXiSelection(const Xi& casc, const TrackPos& ptrack, const TrackNeg& ntrack, const TrackBac& btrack, const Coll& coll) + { + // Single-track selections on cascade daughters + if (!passedSingleTrackSelection(ptrack)) + return false; + if (!passedSingleTrackSelection(ntrack)) + return false; + if (!passedSingleTrackSelection(btrack)) + return false; + + // Xi+ selection (Xi+ -> antiL + pi+) + if (btrack.sign() > 0) { + if (ntrack.pt() < ptMinV0Proton || ntrack.pt() > ptMaxV0Proton) + return false; + if (ptrack.pt() < ptMinV0Pion || ptrack.pt() > ptMaxV0Pion) + return false; + + // PID selections (TPC) + if (ntrack.tpcNSigmaPr() < nsigmaTPCmin || ntrack.tpcNSigmaPr() > nsigmaTPCmax) + return false; + if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + + // PID selections (TOF) + if (requireTOF) { + if (ntrack.tofNSigmaPr() < nsigmaTOFmin || ntrack.tofNSigmaPr() > nsigmaTOFmax) + return false; + if (ptrack.tofNSigmaPi() < nsigmaTOFmin || ptrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + } + + // Require that V0 is compatible with Lambda + ROOT::Math::PxPyPzMVector pProton; + ROOT::Math::PxPyPzMVector pPion; + pProton.SetCoordinates(ntrack.px(), ntrack.py(), ntrack.pz(), MassProton); + pPion.SetCoordinates(ptrack.px(), ptrack.py(), ptrack.pz(), MassPionCharged); + double mLambda = (pProton + pPion).M(); + if (std::fabs(mLambda - MassLambda0) > deltaMassLambda) + return false; + } + + // Xi- selection (Xi- -> L + pi-) + if (btrack.sign() < 0) { + if (ptrack.pt() < ptMinV0Proton || ptrack.pt() > ptMaxV0Proton) + return false; + if (ntrack.pt() < ptMinV0Pion || ntrack.pt() > ptMaxV0Pion) + return false; + + // PID selections (TPC) + if (ptrack.tpcNSigmaPr() < nsigmaTPCmin || ptrack.tpcNSigmaPr() > nsigmaTPCmax) + return false; + if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + + // PID selections (TOF) + if (requireTOF) { + if (ptrack.tofNSigmaPr() < nsigmaTOFmin || ptrack.tofNSigmaPr() > nsigmaTOFmax) + return false; + if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + } + + // Require that V0 is compatible with Lambda + ROOT::Math::PxPyPzMVector pProton; + ROOT::Math::PxPyPzMVector pPion; + pProton.SetCoordinates(ptrack.px(), ptrack.py(), ptrack.pz(), MassProton); + pPion.SetCoordinates(ntrack.px(), ntrack.py(), ntrack.pz(), MassPionCharged); + double mLambda = (pProton + pPion).M(); + if (std::fabs(mLambda - MassLambda0) > deltaMassLambda) + return false; + } + + // V0 selections + if (casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ()) < v0cospaMin) + return false; + if (casc.v0radius() < minimumV0Radius || casc.v0radius() > maximumV0Radius) + return false; + if (std::fabs(casc.dcaV0daughters()) > dcaV0DaughtersMax) + return false; + if (std::fabs(casc.dcapostopv()) < dcapostoPVmin) + return false; + if (std::fabs(casc.dcanegtopv()) < dcanegtoPVmin) + return false; + + // Cascade selections + if (casc.cascradius() < minimumCascRadius || casc.cascradius() > maximumCascRadius) + return false; + if (casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()) < casccospaMin) + return false; + if (std::fabs(casc.dcabachtopv()) < dcabachtopvMin) + return false; + if (std::fabs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())) < dcaV0topvMin) + return false; + if (std::fabs(casc.dcacascdaughters()) > dcaCascDaughtersMax) + return false; + + // PID selection on bachelor + if (btrack.tpcNSigmaPi() < nsigmaTPCmin || btrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + + // PID selections (TOF) + if (requireTOF) { + if (btrack.tofNSigmaPi() < nsigmaTOFmin || btrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + } + + // Reject candidates compatible with Omega + if (std::fabs(casc.mOmega() - MassOmegaMinus) < deltaMassOmega) + return false; + return true; + } + + // Omega selections + template + bool passedOmegaSelection(const Omega& casc, const TrackPos& ptrack, const TrackNeg& ntrack, const TrackBac& btrack, const Coll& coll) + { + // Single-track selections on cascade daughters + if (!passedSingleTrackSelection(ptrack)) + return false; + if (!passedSingleTrackSelection(ntrack)) + return false; + if (!passedSingleTrackSelection(btrack)) + return false; + + // Omega+ selection (Omega+ -> antiL + K+) + if (btrack.sign() > 0) { + if (ntrack.pt() < ptMinV0Proton || ntrack.pt() > ptMaxV0Proton) + return false; + if (ptrack.pt() < ptMinV0Pion || ptrack.pt() > ptMaxV0Pion) + return false; + + // PID selections (TPC) + if (ntrack.tpcNSigmaPr() < nsigmaTPCmin || ntrack.tpcNSigmaPr() > nsigmaTPCmax) + return false; + if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + + // PID selections (TOF) + if (requireTOF) { + if (ntrack.tofNSigmaPr() < nsigmaTOFmin || ntrack.tofNSigmaPr() > nsigmaTOFmax) + return false; + if (ptrack.tofNSigmaPi() < nsigmaTOFmin || ptrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + } + + // Require that V0 is compatible with Lambda + ROOT::Math::PxPyPzMVector pProton; + ROOT::Math::PxPyPzMVector pPion; + pProton.SetCoordinates(ntrack.px(), ntrack.py(), ntrack.pz(), MassProton); + pPion.SetCoordinates(ptrack.px(), ptrack.py(), ptrack.pz(), MassPionCharged); + double mLambda = (pProton + pPion).M(); + if (std::fabs(mLambda - MassLambda0) > deltaMassLambda) + return false; + } + + // Omega- selection (Omega- -> L + K-) + if (btrack.sign() < 0) { + if (ptrack.pt() < ptMinV0Proton || ptrack.pt() > ptMaxV0Proton) + return false; + if (ntrack.pt() < ptMinV0Pion || ntrack.pt() > ptMaxV0Pion) + return false; + + // PID selections (TPC) + if (ptrack.tpcNSigmaPr() < nsigmaTPCmin || ptrack.tpcNSigmaPr() > nsigmaTPCmax) + return false; + if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + + // PID selections (TOF) + if (requireTOF) { + if (ptrack.tofNSigmaPr() < nsigmaTOFmin || ptrack.tofNSigmaPr() > nsigmaTOFmax) + return false; + if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + } + + // Require that V0 is compatible with Lambda + ROOT::Math::PxPyPzMVector pProton; + ROOT::Math::PxPyPzMVector pPion; + pProton.SetCoordinates(ptrack.px(), ptrack.py(), ptrack.pz(), MassProton); + pPion.SetCoordinates(ntrack.px(), ntrack.py(), ntrack.pz(), MassPionCharged); + double mLambda = (pProton + pPion).M(); + if (std::fabs(mLambda - MassLambda0) > deltaMassLambda) + return false; + } + + // V0 selections + if (casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ()) < v0cospaMin) + return false; + if (casc.v0radius() < minimumV0Radius || casc.v0radius() > maximumV0Radius) + return false; + if (std::fabs(casc.dcaV0daughters()) > dcaV0DaughtersMax) + return false; + if (std::fabs(casc.dcapostopv()) < dcapostoPVmin) + return false; + if (std::fabs(casc.dcanegtopv()) < dcanegtoPVmin) + return false; + + // Cascade selections + if (casc.cascradius() < minimumCascRadius || casc.cascradius() > maximumCascRadius) + return false; + if (casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()) < casccospaMin) + return false; + if (std::fabs(casc.dcabachtopv()) < dcabachtopvMin) + return false; + if (std::fabs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())) < dcaV0topvMin) + return false; + if (std::fabs(casc.dcacascdaughters()) > dcaCascDaughtersMax) + return false; + + // PID selection on bachelor + if (btrack.tpcNSigmaKa() < nsigmaTPCmin || btrack.tpcNSigmaKa() > nsigmaTPCmax) + return false; + + // PID selections (TOF) + if (requireTOF) { + if (btrack.tofNSigmaKa() < nsigmaTOFmin || btrack.tofNSigmaKa() > nsigmaTOFmax) + return false; + } + + // Reject candidates compatible with Xi + if (std::fabs(casc.mXi() - MassXiMinus) < deltaMassXi) + return false; + return true; + } + + // 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.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; + } + + // Process data + void processData(SelCollisions::iterator const& collision, aod::V0Datas const& fullV0s, + aod::CascDataExt const& Cascades, DaughterTracks const& tracks, + aod::BCsWithTimestamps const&) + { + // Fill event counter before event selection + registryData.fill(HIST("number_of_events_data"), 0.5); + + // Get the bunch crossing (BC) information associated with the collision + auto bc = collision.template bc_as(); + + // Initialize CCDB objects using the BC info + initCCDB(bc); + + // If skimmed processing is enabled, skip this event unless it passes Zorro selection + if (cfgSkimmedProcessing && !zorro.isSelected(collision.template bc_as().globalBC())) { + return; + } + + // Fill event counter after zorro selection + registryData.fill(HIST("number_of_events_data"), 1.5); + + // Event selection + if (!collision.sel8() || std::fabs(collision.posZ()) > zVtx) + return; + + // Fill event counter after event selection + registryData.fill(HIST("number_of_events_data"), 2.5); + + // Loop over reconstructed tracks + std::vector fjParticles; + for (auto const& track : tracks) { + + // Require that tracks pass selection criteria + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + + // 4-momentum representation of a particle + fastjet::PseudoJet fourMomentum(track.px(), track.py(), track.pz(), track.energy(MassPionCharged)); + fjParticles.emplace_back(fourMomentum); + } + + // Reject empty events + if (fjParticles.size() < 1) + return; + registryData.fill(HIST("number_of_events_data"), 3.5); + + // Cluster particles using the anti-kt algorithm + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // Jet selection + bool isAtLeastOneJetSelected = false; + std::vector selectedJet; + std::vector ue1; + std::vector ue2; + + // Loop over reconstructed jets + for (const auto& jet : jets) { + + // Jet must be fully contained in the acceptance + if ((std::fabs(jet.eta()) + rJet) > (etaMax - deltaEtaEdge)) + continue; + + // Jet pt must be larger than threshold + auto jetForSub = jet; + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jetForSub, rhoPerp, rhoMPerp); + if (jetMinusBkg.pt() < minJetPt) + continue; + isAtLeastOneJetSelected = true; + + // Calculation of perpendicular cones + TVector3 jetAxis(jet.px(), jet.py(), jet.pz()); + TVector3 ueAxis1(0, 0, 0); + TVector3 ueAxis2(0, 0, 0); + getPerpendicularAxis(jetAxis, ueAxis1, +1); + getPerpendicularAxis(jetAxis, ueAxis2, -1); + + // Store jet and UE axes + selectedJet.emplace_back(jetAxis); + ue1.emplace_back(ueAxis1); + ue2.emplace_back(ueAxis2); + } + if (!isAtLeastOneJetSelected) + return; + + // Fill event counter with events with at least one jet + registryData.fill(HIST("number_of_events_data"), 4.5); + + // Event multiplicity + const float multiplicity = collision.centFT0M(); + + // Fill event multiplicity + registryData.fill(HIST("number_of_events_vsmultiplicity"), multiplicity); + + // Loop over selected jets + for (int i = 0; i < static_cast(selectedJet.size()); i++) { + + // kV0Particles + if (particleOfInterest == Option::kV0Particles) { + for (const auto& v0 : fullV0s) { + + // Get V0 daughters + const auto& pos = v0.posTrack_as(); + const auto& neg = v0.negTrack_as(); + TVector3 v0dir(v0.px(), v0.py(), v0.pz()); + + // Calculate distance from jet and UE axes + float deltaEtaJet = v0dir.Eta() - selectedJet[i].Eta(); + float deltaPhiJet = getDeltaPhi(v0dir.Phi(), selectedJet[i].Phi()); + float deltaRjet = std::sqrt(deltaEtaJet * deltaEtaJet + deltaPhiJet * deltaPhiJet); + float deltaEtaUe1 = v0dir.Eta() - ue1[i].Eta(); + float deltaPhiUe1 = getDeltaPhi(v0dir.Phi(), ue1[i].Phi()); + float deltaRue1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1); + float deltaEtaUe2 = v0dir.Eta() - ue2[i].Eta(); + float deltaPhiUe2 = getDeltaPhi(v0dir.Phi(), ue2[i].Phi()); + float deltaRue2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2); + + // K0s + if (passedK0ShortSelection(v0, pos, neg)) { + if (deltaRjet < rJet) { + registryData.fill(HIST("K0s_in_jet"), multiplicity, v0.pt(), v0.mK0Short()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryData.fill(HIST("K0s_in_ue"), multiplicity, v0.pt(), v0.mK0Short()); + } + } + // Lambda + if (passedLambdaSelection(v0, pos, neg)) { + if (deltaRjet < rJet) { + registryData.fill(HIST("Lambda_in_jet"), multiplicity, v0.pt(), v0.mLambda()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryData.fill(HIST("Lambda_in_ue"), multiplicity, v0.pt(), v0.mLambda()); + } + } + // AntiLambda + if (passedAntiLambdaSelection(v0, pos, neg)) { + if (deltaRjet < rJet) { + registryData.fill(HIST("AntiLambda_in_jet"), multiplicity, v0.pt(), v0.mAntiLambda()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryData.fill(HIST("AntiLambda_in_ue"), multiplicity, v0.pt(), v0.mAntiLambda()); + } + } + } + } + + // Cascades + if (particleOfInterest == Option::kCascades) { + for (const auto& casc : Cascades) { + + // Get cascade daughters + auto bach = casc.bachelor_as(); + auto pos = casc.posTrack_as(); + auto neg = casc.negTrack_as(); + TVector3 cascadeDir(casc.px(), casc.py(), casc.pz()); + + // Calculate distance from jet and UE axes + double deltaEtaJet = cascadeDir.Eta() - selectedJet[i].Eta(); + double deltaPhiJet = getDeltaPhi(cascadeDir.Phi(), selectedJet[i].Phi()); + double deltaRjet = std::sqrt(deltaEtaJet * deltaEtaJet + deltaPhiJet * deltaPhiJet); + double deltaEtaUe1 = cascadeDir.Eta() - ue1[i].Eta(); + double deltaPhiUe1 = getDeltaPhi(cascadeDir.Phi(), ue1[i].Phi()); + double deltaRue1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1); + double deltaEtaUe2 = cascadeDir.Eta() - ue2[i].Eta(); + double deltaPhiUe2 = getDeltaPhi(cascadeDir.Phi(), ue2[i].Phi()); + double deltaRue2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2); + + // Xi+ + if (passedXiSelection(casc, pos, neg, bach, collision) && bach.sign() > 0) { + if (deltaRjet < rJet) { + registryData.fill(HIST("XiPos_in_jet"), multiplicity, casc.pt(), casc.mXi()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryData.fill(HIST("XiPos_in_ue"), multiplicity, casc.pt(), casc.mXi()); + } + } + // Xi- + if (passedXiSelection(casc, pos, neg, bach, collision) && bach.sign() < 0) { + if (deltaRjet < rJet) { + registryData.fill(HIST("XiNeg_in_jet"), multiplicity, casc.pt(), casc.mXi()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryData.fill(HIST("XiNeg_in_ue"), multiplicity, casc.pt(), casc.mXi()); + } + } + // Omega+ + if (passedOmegaSelection(casc, pos, neg, bach, collision) && bach.sign() > 0) { + if (deltaRjet < rJet) { + registryData.fill(HIST("OmegaPos_in_jet"), multiplicity, casc.pt(), casc.mOmega()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryData.fill(HIST("OmegaPos_in_ue"), multiplicity, casc.pt(), casc.mOmega()); + } + } + // Omega- + if (passedOmegaSelection(casc, pos, neg, bach, collision) && bach.sign() < 0) { + if (deltaRjet < rJet) { + registryData.fill(HIST("OmegaNeg_in_jet"), multiplicity, casc.pt(), casc.mOmega()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryData.fill(HIST("OmegaNeg_in_ue"), multiplicity, casc.pt(), casc.mOmega()); + } + } + } + } + } + } + PROCESS_SWITCH(StrangenessInJets, processData, "Process data", true); + + Preslice perCollisionV0 = o2::aod::v0data::collisionId; + Preslice perCollisionCasc = o2::aod::cascade::collisionId; + Preslice perMCCollision = o2::aod::mcparticle::mcCollisionId; + Preslice perCollisionTrk = o2::aod::track::collisionId; + + // Generated MC events + void processMCgenerated(aod::McCollisions const& collisions, aod::McParticles const& mcParticles) + { + // Loop over all simulated collision events + for (const auto& collision : collisions) { + + // Fill event counter before any selection + registryMC.fill(HIST("number_of_events_mc_gen"), 0.5); + + // Need to apply event selection to simulated events + registryMC.fill(HIST("number_of_events_mc_gen"), 1.5); + + // Require vertex position within the allowed z range + if (std::fabs(collision.posZ()) > zVtx) + continue; + + // Fill event counter after selection on z-vertex + registryMC.fill(HIST("number_of_events_mc_gen"), 2.5); + + // Multiplicity of generated event + double genMultiplicity = 0.0; + + // MC particles per collision + auto mcParticlesPerColl = mcParticles.sliceBy(perMCCollision, collision.globalIndex()); + + // Loop over all MC particles and select physical primaries within acceptance + std::vector fjParticles; + for (const auto& particle : mcParticlesPerColl) { + if (!particle.isPhysicalPrimary()) + continue; + double minPtParticle = 0.1; + if (particle.eta() < etaMin || particle.eta() > etaMax || particle.pt() < minPtParticle) + continue; + + // Build 4-momentum assuming charged pion mass + double energy = std::sqrt(particle.p() * particle.p() + MassPionCharged * MassPionCharged); + fastjet::PseudoJet fourMomentum(particle.px(), particle.py(), particle.pz(), energy); + fourMomentum.set_user_index(particle.pdgCode()); + fjParticles.emplace_back(fourMomentum); + } + + // Skip events with no particles + if (fjParticles.size() < 1) + continue; + registryMC.fill(HIST("number_of_events_mc_gen"), 3.5); + + // Cluster MC particles into jets using anti-kt algorithm + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + + // Estimate background energy density (rho) in perpendicular cone + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // Loop over clustered jets + for (const auto& jet : jets) { + + // Jet must be fully contained in acceptance + if ((std::fabs(jet.eta()) + rJet) > (etaMax - deltaEtaEdge)) + continue; + + // Subtract background energy from jet + auto jetForSub = jet; + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jetForSub, rhoPerp, rhoMPerp); + + // Apply jet pT threshold + if (jetMinusBkg.pt() < minJetPt) + continue; + registryMC.fill(HIST("number_of_events_mc_gen"), 4.5); + + // Set up two perpendicular cone axes for underlying event estimation + TVector3 jetAxis(jet.px(), jet.py(), jet.pz()); + double coneRadius = std::sqrt(jet.area() / PI); + TVector3 ueAxis1(0, 0, 0), ueAxis2(0, 0, 0); + getPerpendicularAxis(jetAxis, ueAxis1, +1); + getPerpendicularAxis(jetAxis, ueAxis2, -1); + + // Loop over MC particles + for (const auto& particle : mcParticlesPerColl) { + if (!particle.isPhysicalPrimary()) + continue; + double minPtParticle = 0.1; + if (particle.eta() < etaMin || particle.eta() > etaMax || particle.pt() < minPtParticle) + continue; + + // Compute distance of particles from jet and UE axes + double deltaEtaJet = particle.eta() - jetAxis.Eta(); + double deltaPhiJet = getDeltaPhi(particle.phi(), jetAxis.Phi()); + double deltaRJet = std::sqrt(deltaEtaJet * deltaEtaJet + deltaPhiJet * deltaPhiJet); + double deltaEtaUe1 = particle.eta() - ueAxis1.Eta(); + double deltaPhiUe1 = getDeltaPhi(particle.phi(), ueAxis1.Phi()); + double deltaRUe1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1); + double deltaEtaUe2 = particle.eta() - ueAxis2.Eta(); + double deltaPhiUe2 = getDeltaPhi(particle.phi(), ueAxis2.Phi()); + double deltaRUe2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2); + + // Select particles inside jet + if (deltaRJet < coneRadius) { + switch (particle.pdgCode()) { + case kK0Short: + registryMC.fill(HIST("K0s_generated_jet"), genMultiplicity, particle.pt()); + break; + case kLambda0: + registryMC.fill(HIST("Lambda_generated_jet"), genMultiplicity, particle.pt()); + break; + case kLambda0Bar: + registryMC.fill(HIST("AntiLambda_generated_jet"), genMultiplicity, particle.pt()); + break; + case kXiMinus: + registryMC.fill(HIST("XiNeg_generated_jet"), genMultiplicity, particle.pt()); + break; + case kXiPlusBar: + registryMC.fill(HIST("XiPos_generated_jet"), genMultiplicity, particle.pt()); + break; + case kOmegaMinus: + registryMC.fill(HIST("OmegaNeg_generated_jet"), genMultiplicity, particle.pt()); + break; + case kOmegaPlusBar: + registryMC.fill(HIST("OmegaPos_generated_jet"), genMultiplicity, particle.pt()); + break; + default: + break; + } + } + + // Select particles inside UE cones + if (deltaRUe1 < coneRadius || deltaRUe2 < coneRadius) { + switch (particle.pdgCode()) { + case kK0Short: + registryMC.fill(HIST("K0s_generated_ue"), genMultiplicity, particle.pt()); + break; + case kLambda0: + registryMC.fill(HIST("Lambda_generated_ue"), genMultiplicity, particle.pt()); + break; + case kLambda0Bar: + registryMC.fill(HIST("AntiLambda_generated_ue"), genMultiplicity, particle.pt()); + break; + case kXiMinus: + registryMC.fill(HIST("XiNeg_generated_ue"), genMultiplicity, particle.pt()); + break; + case kXiPlusBar: + registryMC.fill(HIST("XiPos_generated_ue"), genMultiplicity, particle.pt()); + break; + case kOmegaMinus: + registryMC.fill(HIST("OmegaNeg_generated_ue"), genMultiplicity, particle.pt()); + break; + case kOmegaPlusBar: + registryMC.fill(HIST("OmegaPos_generated_ue"), genMultiplicity, particle.pt()); + break; + default: + break; + } + } + } + } + } + } + PROCESS_SWITCH(StrangenessInJets, processMCgenerated, "process generated events", false); + + // Reconstructed MC events + void processMCreconstructed(SimCollisions const& collisions, DaughterTracksMC const& mcTracks, + aod::V0Datas const& fullV0s, aod::CascDataExt const& Cascades, + const aod::McParticles&) + { + for (const auto& collision : collisions) { + + // Fill event counter before any selection + registryMC.fill(HIST("number_of_events_mc_rec"), 0.5); + if (!collision.sel8()) + continue; + + // Fill event counter after event selection + registryMC.fill(HIST("number_of_events_mc_rec"), 1.5); + if (std::fabs(collision.posZ()) > zVtx) + continue; + + // Fill event counter after selection on z-vertex + registryMC.fill(HIST("number_of_events_mc_rec"), 2.5); + + // Event multiplicity + const float multiplicity = collision.centFT0M(); + + // Number of V0 and cascades per collision + auto v0sPerColl = fullV0s.sliceBy(perCollisionV0, collision.globalIndex()); + auto cascPerColl = Cascades.sliceBy(perCollisionCasc, collision.globalIndex()); + auto tracksPerColl = mcTracks.sliceBy(perCollisionTrk, collision.globalIndex()); + + // Loop over reconstructed tracks + std::vector fjParticles; + for (auto const& track : tracksPerColl) { + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + + // 4-momentum representation of a particle + fastjet::PseudoJet fourMomentum(track.px(), track.py(), track.pz(), track.energy(MassPionCharged)); + fjParticles.emplace_back(fourMomentum); + } + + // Reject empty events + if (fjParticles.size() < 1) + continue; + registryMC.fill(HIST("number_of_events_mc_rec"), 3.5); + + // Cluster particles using the anti-kt algorithm + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, rJet); + fastjet::AreaDefinition areaDef(fastjet::active_area, fastjet::GhostedAreaSpec(1.0)); + fastjet::ClusterSequenceArea cs(fjParticles, jetDef, areaDef); + std::vector jets = fastjet::sorted_by_pt(cs.inclusive_jets()); + auto [rhoPerp, rhoMPerp] = backgroundSub.estimateRhoPerpCone(fjParticles, jets); + + // Jet selection + bool isAtLeastOneJetSelected = false; + std::vector selectedJet; + std::vector ue1; + std::vector ue2; + + // Loop over clustered jets + for (const auto& jet : jets) { + + // jet must be fully contained in the acceptance + if ((std::fabs(jet.eta()) + rJet) > (etaMax - deltaEtaEdge)) + continue; + + // jet pt must be larger than threshold + auto jetForSub = jet; + fastjet::PseudoJet jetMinusBkg = backgroundSub.doRhoAreaSub(jetForSub, rhoPerp, rhoMPerp); + if (jetMinusBkg.pt() < minJetPt) + continue; + isAtLeastOneJetSelected = true; + + // Perpendicular cones + TVector3 jetAxis(jet.px(), jet.py(), jet.pz()); + TVector3 ueAxis1(0, 0, 0), ueAxis2(0, 0, 0); + getPerpendicularAxis(jetAxis, ueAxis1, +1); + getPerpendicularAxis(jetAxis, ueAxis2, -1); + + // Store selected jet and UE cone axes + selectedJet.emplace_back(jetAxis); + ue1.emplace_back(ueAxis1); + ue2.emplace_back(ueAxis2); + } + if (!isAtLeastOneJetSelected) + continue; + + // Fill event counter for events with at least one selected jet + registryMC.fill(HIST("number_of_events_mc_rec"), 4.5); + + // Loop over selected jets + for (int i = 0; i < static_cast(selectedJet.size()); i++) { + + // V0 particles + if (particleOfInterest == Option::kV0Particles) { + for (const auto& v0 : v0sPerColl) { + const auto& pos = v0.posTrack_as(); + const auto& neg = v0.negTrack_as(); + TVector3 v0dir(v0.px(), v0.py(), v0.pz()); + + // Get MC particles + if (!pos.has_mcParticle() || !neg.has_mcParticle()) + continue; + auto posParticle = pos.mcParticle_as(); + auto negParticle = neg.mcParticle_as(); + if (!posParticle.has_mothers() || !negParticle.has_mothers()) + continue; + + // Select particles originating from the same parent + int pdgParent(0); + bool isPhysPrim = false; + for (const auto& particleMotherOfNeg : negParticle.mothers_as()) { + for (const auto& particleMotherOfPos : posParticle.mothers_as()) { + if (particleMotherOfNeg == particleMotherOfPos) { + pdgParent = particleMotherOfNeg.pdgCode(); + isPhysPrim = particleMotherOfNeg.isPhysicalPrimary(); + } + } + } + if (pdgParent == 0) + continue; + + // Compute distance from jet and UE axes + double deltaEtaJet = v0dir.Eta() - selectedJet[i].Eta(); + double deltaPhiJet = getDeltaPhi(v0dir.Phi(), selectedJet[i].Phi()); + double deltaRjet = std::sqrt(deltaEtaJet * deltaEtaJet + deltaPhiJet * deltaPhiJet); + double deltaEtaUe1 = v0dir.Eta() - ue1[i].Eta(); + double deltaPhiUe1 = getDeltaPhi(v0dir.Phi(), ue1[i].Phi()); + double deltaRue1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1); + double deltaEtaUe2 = v0dir.Eta() - ue2[i].Eta(); + double deltaPhiUe2 = getDeltaPhi(v0dir.Phi(), ue2[i].Phi()); + double deltaRue2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2); + + // K0s + if (passedK0ShortSelection(v0, pos, neg) && pdgParent == kK0Short && isPhysPrim) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("K0s_reconstructed_jet"), multiplicity, v0.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("K0s_reconstructed_ue"), multiplicity, v0.pt()); + } + } + // Lambda + if (passedLambdaSelection(v0, pos, neg) && pdgParent == kLambda0 && isPhysPrim) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("Lambda_reconstructed_jet"), multiplicity, v0.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("Lambda_reconstructed_ue"), multiplicity, v0.pt()); + } + } + // AntiLambda + if (passedAntiLambdaSelection(v0, pos, neg) && pdgParent == kLambda0Bar && isPhysPrim) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("AntiLambda_reconstructed_jet"), multiplicity, v0.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("AntiLambda_reconstructed_ue"), multiplicity, v0.pt()); + } + } + + // Fill inclusive spectra + // K0s + if (passedK0ShortSelection(v0, pos, neg) && pdgParent == kK0Short) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("K0s_reconstructed_jet_incl"), multiplicity, v0.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("K0s_reconstructed_ue_incl"), multiplicity, v0.pt()); + } + } + // Lambda + if (passedLambdaSelection(v0, pos, neg) && pdgParent == kLambda0) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("Lambda_reconstructed_jet_incl"), multiplicity, v0.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("Lambda_reconstructed_ue_incl"), multiplicity, v0.pt()); + } + } + // AntiLambda + if (passedAntiLambdaSelection(v0, pos, neg) && pdgParent == kLambda0Bar) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("AntiLambda_reconstructed_jet_incl"), multiplicity, v0.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("AntiLambda_reconstructed_ue_incl"), multiplicity, v0.pt()); + } + } + } + } + + // Cascades + if (particleOfInterest == Option::kCascades) { + for (const auto& casc : cascPerColl) { + auto bach = casc.bachelor_as(); + auto pos = casc.posTrack_as(); + auto neg = casc.negTrack_as(); + + // Get MC particles + if (!bach.has_mcParticle() || !pos.has_mcParticle() || !neg.has_mcParticle()) + continue; + auto posParticle = pos.mcParticle_as(); + auto negParticle = neg.mcParticle_as(); + auto bachParticle = bach.mcParticle_as(); + if (!posParticle.has_mothers() || !negParticle.has_mothers() || !bachParticle.has_mothers()) + continue; + + // Select particles originating from the same parent + int pdgParent(0); + bool isPhysPrim = false; + for (const auto& particleMotherOfNeg : negParticle.mothers_as()) { + for (const auto& particleMotherOfPos : posParticle.mothers_as()) { + for (const auto& particleMotherOfBach : bachParticle.mothers_as()) { + if (particleMotherOfNeg != particleMotherOfPos) + continue; + if (std::abs(particleMotherOfNeg.pdgCode()) != kLambda0) + continue; + isPhysPrim = particleMotherOfBach.isPhysicalPrimary(); + pdgParent = particleMotherOfBach.pdgCode(); + } + } + } + if (pdgParent == 0) + continue; + if (!isPhysPrim) + continue; + + // Compute distances from jet and UE axes + TVector3 cascadeDir(casc.px(), casc.py(), casc.pz()); + double deltaEtaJet = cascadeDir.Eta() - selectedJet[i].Eta(); + double deltaPhiJet = getDeltaPhi(cascadeDir.Phi(), selectedJet[i].Phi()); + double deltaRjet = std::sqrt(deltaEtaJet * deltaEtaJet + deltaPhiJet * deltaPhiJet); + double deltaEtaUe1 = cascadeDir.Eta() - ue1[i].Eta(); + double deltaPhiUe1 = getDeltaPhi(cascadeDir.Phi(), ue1[i].Phi()); + double deltaRue1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1); + double deltaEtaUe2 = cascadeDir.Eta() - ue2[i].Eta(); + double deltaPhiUe2 = getDeltaPhi(cascadeDir.Phi(), ue2[i].Phi()); + double deltaRue2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2); + + // Xi+ + if (passedXiSelection(casc, pos, neg, bach, collision) && bach.sign() > 0 && pdgParent == kXiPlusBar) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("XiPos_reconstructed_jet"), multiplicity, casc.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("XiPos_reconstructed_ue"), multiplicity, casc.pt()); + } + } + // Xi- + if (passedXiSelection(casc, pos, neg, bach, collision) && bach.sign() < 0 && pdgParent == kXiMinus) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("XiNeg_reconstructed_jet"), multiplicity, casc.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("XiNeg_reconstructed_ue"), multiplicity, casc.pt()); + } + } + // Omega+ + if (passedOmegaSelection(casc, pos, neg, bach, collision) && bach.sign() > 0 && pdgParent == kOmegaPlusBar) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("OmegaPos_reconstructed_jet"), multiplicity, casc.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("OmegaPos_reconstructed_ue"), multiplicity, casc.pt()); + } + } + // Omega- + if (passedOmegaSelection(casc, pos, neg, bach, collision) && bach.sign() < 0 && pdgParent == kOmegaMinus) { + if (deltaRjet < rJet) { + registryMC.fill(HIST("OmegaNeg_reconstructed_jet"), multiplicity, casc.pt()); + } + if (deltaRue1 < rJet || deltaRue2 < rJet) { + registryMC.fill(HIST("OmegaNeg_reconstructed_ue"), multiplicity, casc.pt()); + } + } + } + } + } + } + } + PROCESS_SWITCH(StrangenessInJets, processMCreconstructed, "process reconstructed events", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Strangeness/strangeness_in_jets.cxx b/PWGLF/Tasks/Strangeness/strangeness_in_jets.cxx deleted file mode 100644 index c9d1d918fd3..00000000000 --- a/PWGLF/Tasks/Strangeness/strangeness_in_jets.cxx +++ /dev/null @@ -1,1922 +0,0 @@ -// 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. -/// -/// \file strangeness in jets.cxx -/// \author Alberto Caliva (alberto.caliva@cern.ch), Francesca Ercolessi (francesca.ercolessi@cern.ch) -/// \since May 22, 2024 - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "CCDB/BasicCCDBManager.h" -#include "CCDB/CcdbApi.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "ReconstructionDataFormats/Track.h" - -using namespace std; -using namespace o2; -using namespace o2::soa; -using namespace o2::aod; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::constants::physics; -using std::array; - -using SelCollisions = soa::Join; -using SimCollisions = soa::Join; -using StrHadronDaughterTracks = soa::Join; -using MCTracks = soa::Join; - -struct strangeness_in_jets { - - HistogramRegistry registryData{"registryData", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry registryMC{"registryMC", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry registryQC{"registryQC", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - - // Global Parameters - Configurable particle_of_interest{"particle_of_interest", 0, "0=v0, 1=cascade, 2=pions"}; - Configurable min_jet_pt{"min_jet_pt", 10.0, "Minimum pt of the jet"}; - Configurable Rjet{"Rjet", 0.3, "Jet resolution parameter R"}; - Configurable zVtx{"zVtx", 10.0, "Maximum zVertex"}; - Configurable min_nPartInJet{"min_nPartInJet", 2, "Minimum number of particles inside jet"}; - Configurable n_jets_per_event_max{"n_jets_per_event_max", 1000, "Maximum number of jets per event"}; - Configurable requireNoOverlap{"requireNoOverlap", false, "require no overlap between jets and UE cones"}; - Configurable par0{"par0", 0.004f, "par 0"}; - Configurable par1{"par1", 0.013f, "par 1"}; - - // Track Parameters - 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 nsigmaTPCmin{"nsigmaTPCmin", -3.0f, "Minimum nsigma TPC"}; - Configurable nsigmaTPCmax{"nsigmaTPCmax", +3.0f, "Maximum nsigma TPC"}; - Configurable nsigmaTOFmin{"nsigmaTOFmin", -3.0f, "Minimum nsigma TOF"}; - Configurable nsigmaTOFmax{"nsigmaTOFmax", +3.0f, "Maximum nsigma TOF"}; - Configurable dcaxyMax{"dcaxyMax", 0.1f, "Maximum DCAxy to primary vertex"}; - Configurable dcazMax{"dcazMax", 0.1f, "Maximum DCAz to primary vertex"}; - Configurable requireITS{"requireITS", false, "require ITS hit"}; - Configurable requireTOF{"requireTOF", false, "require TOF hit"}; - - // V0 Parameters - Configurable minimumV0Radius{"minimumV0Radius", 0.5f, "Minimum V0 Radius"}; - Configurable maximumV0Radius{"maximumV0Radius", 40.0f, "Maximum V0 Radius"}; - Configurable dcanegtoPVmin{"dcanegtoPVmin", 0.1f, "Minimum DCA Neg To PV"}; - Configurable dcapostoPVmin{"dcapostoPVmin", 0.1f, "Minimum DCA Pos To PV"}; - Configurable v0cospaMin{"v0cospaMin", 0.99f, "Minimum V0 CosPA"}; - Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 0.5f, "Maximum DCA Daughters"}; - - // Cascade Parameters - Configurable minimumCascRadius{"minimumCascRadius", 0.1f, "Minimum Cascade Radius"}; - Configurable maximumCascRadius{"maximumCascRadius", 40.0f, "Maximum Cascade Radius"}; - Configurable casccospaMin{"casccospaMin", 0.99f, "Minimum Cascade CosPA"}; - Configurable dcabachtopvMin{"dcabachtopvMin", 0.1f, "Minimum DCA bachelor to PV"}; - Configurable dcaV0topvMin{"dcaV0topvMin", 0.1f, "Minimum DCA V0 to PV"}; - Configurable dcaCascDaughtersMax{"dcaCascDaughtersMax", 0.5f, "Maximum DCA Daughters"}; - - // Re-weighting - Configurable applyReweighting{"applyReweighting", true, "apply reweighting"}; - Configurable url_to_ccdb{"url_to_ccdb", "http://alice-ccdb.cern.ch", "url of the personal ccdb"}; - Configurable path_to_file{"path_to_file", "", "path to file with reweighting"}; - Configurable histo_name_weight_k0_jet{"histo_name_weight_k0_jet", "", "reweighting histogram: K0 in jet"}; - Configurable histo_name_weight_k0_ue{"histo_name_weight_k0_ue", "", "reweighting histogram: K0 in ue"}; - Configurable histo_name_weight_lambda_jet{"histo_name_weight_lambda_jet", "", "reweighting histogram: lambda in jet"}; - Configurable histo_name_weight_lambda_ue{"histo_name_weight_lambda_ue", "", "reweighting histogram: lambda in ue"}; - Configurable histo_name_weight_antilambda_jet{"histo_name_weight_antilambda_jet", "", "reweighting histogram: antilambda in jet"}; - Configurable histo_name_weight_antilambda_ue{"histo_name_weight_antilambda_ue", "", "reweighting histogram: antilambda in ue"}; - - // Two-dimensional weights - TH2F* twod_weights_k0_jet; - TH2F* twod_weights_k0_ue; - TH2F* twod_weights_lambda_jet; - TH2F* twod_weights_lambda_ue; - TH2F* twod_weights_antilambda_jet; - TH2F* twod_weights_antilambda_ue; - - Service ccdb; - o2::ccdb::CcdbApi ccdbApi; - - // List of Particles - enum option { vzeros, - cascades, - pions }; - - void init(InitContext const&) - { - ccdb->setURL(url_to_ccdb.value); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); - ccdb->setFatalWhenNull(false); - - if (applyReweighting) { - GetReweightingHistograms(ccdb, TString(path_to_file), TString(histo_name_weight_k0_jet), TString(histo_name_weight_k0_ue), TString(histo_name_weight_lambda_jet), TString(histo_name_weight_lambda_ue), TString(histo_name_weight_antilambda_jet), TString(histo_name_weight_antilambda_ue)); - } else { - twod_weights_k0_jet = nullptr; - twod_weights_k0_ue = nullptr; - twod_weights_lambda_jet = nullptr; - twod_weights_lambda_ue = nullptr; - twod_weights_antilambda_jet = nullptr; - twod_weights_antilambda_ue = nullptr; - } - - // Event Counters - registryData.add("number_of_events_data", "number of events in data", HistType::kTH1D, {{20, 0, 20, "Event Cuts"}}); - registryData.add("number_of_events_vsmultiplicity", "number of events in data vs multiplicity", HistType::kTH1D, {{101, 0, 101, "Multiplicity percentile"}}); - registryMC.add("number_of_events_mc", "number of events in mc", HistType::kTH1D, {{10, 0, 10, "Event Cuts"}}); - - // QC Histograms - registryQC.add("deltaEtadeltaPhi_jet", "deltaEtadeltaPhi_jet", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, o2::constants::math::PIHalf, "#Delta#phi"}}); - registryQC.add("deltaEtadeltaPhi_ue", "deltaEtadeltaPhi_ue", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, o2::constants::math::PIHalf, "#Delta#phi"}}); - registryQC.add("NchJetPlusUE", "NchJetPlusUE", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); - registryQC.add("NchJet", "NchJet", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); - registryQC.add("NchUE", "NchUE", HistType::kTH1F, {{100, 0, 100, "#it{N}_{ch}"}}); - registryQC.add("sumPtJetPlusUE", "sumPtJetPlusUE", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQC.add("sumPtJet", "sumPtJet", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQC.add("sumPtUE", "sumPtUE", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQC.add("nJets_found", "nJets_found", HistType::kTH1F, {{10, 0, 10, "#it{n}_{Jet}"}}); - registryQC.add("nJets_selected", "nJets_selected", HistType::kTH1F, {{10, 0, 10, "#it{n}_{Jet}"}}); - registryQC.add("dcaxy_vs_pt", "dcaxy_vs_pt", HistType::kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); - registryQC.add("dcaz_vs_pt", "dcaz_vs_pt", HistType::kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {2000, -0.05, 0.05, "DCA_{z} (cm)"}}); - registryQC.add("jet_ue_overlaps", "jet_ue_overlaps", HistType::kTH2F, {{20, 0.0, 20.0, "#it{n}_{jet}"}, {200, 0.0, 200.0, "#it{n}_{overlaps}"}}); - registryQC.add("survivedK0", "survivedK0", HistType::kTH1F, {{20, 0, 20, "step"}}); - - // Multiplicity Binning - std::vector multBinning = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; - AxisSpec multAxis = {multBinning, "FT0C percentile"}; - - // Histograms for pions (data) - registryData.add("piplus_tpc_in_jet", "piplus_tpc_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -10, 10, "n#sigma_{TPC}"}}); - registryData.add("piplus_tof_in_jet", "piplus_tof_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -10, 10, "n#sigma_{TOF}"}}); - registryData.add("piplus_tpc_in_ue", "piplus_tpc_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -10, 10, "n#sigma_{TPC}"}}); - registryData.add("piplus_tof_in_ue", "piplus_tof_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -10, 10, "n#sigma_{TOF}"}}); - registryData.add("piminus_tpc_in_jet", "piminus_tpc_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -10, 10, "n#sigma_{TPC}"}}); - registryData.add("piminus_tof_in_jet", "piminus_tof_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -10, 10, "n#sigma_{TOF}"}}); - registryData.add("piminus_tpc_in_ue", "piminus_tpc_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -10, 10, "n#sigma_{TPC}"}}); - registryData.add("piminus_tof_in_ue", "piminus_tof_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -10, 10, "n#sigma_{TOF}"}}); - registryData.add("piplus_dcaxy_in_jet", "piplus_dcaxy_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); - registryData.add("piplus_dcaxy_in_ue", "piplus_dcaxy_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); - registryData.add("piminus_dcaxy_in_jet", "piminus_dcaxy_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); - registryData.add("piminus_dcaxy_in_ue", "piminus_dcaxy_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); - - // Histograms for lambda (data) - registryData.add("Lambda_in_jet", "Lambda_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.09, 1.14, "m_{p#pi} (GeV/#it{c}^{2})"}}); - registryData.add("AntiLambda_in_jet", "AntiLambda_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.09, 1.14, "m_{p#pi} (GeV/#it{c}^{2})"}}); - registryData.add("Lambda_in_ue", "Lambda_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.09, 1.14, "m_{p#pi} (GeV/#it{c}^{2})"}}); - registryData.add("AntiLambda_in_ue", "AntiLambda_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.09, 1.14, "m_{p#pi} (GeV/#it{c}^{2})"}}); - - // Histograms for K0s (data) - registryData.add("K0s_in_jet", "K0s_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 0.44, 0.56, "m_{#pi#pi} (GeV/#it{c}^{2})"}}); - registryData.add("K0s_in_ue", "K0s_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 0.44, 0.56, "m_{#pi#pi} (GeV/#it{c}^{2})"}}); - - // Histograms for xi (data) - registryData.add("XiPos_in_jet", "XiPos_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.28, 1.36, "m_{p#pi#pi} (GeV/#it{c}^{2})"}}); - registryData.add("XiPos_in_ue", "XiPos_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.28, 1.36, "m_{p#pi#pi} (GeV/#it{c}^{2})"}}); - registryData.add("XiNeg_in_jet", "XiNeg_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.28, 1.36, "m_{p#pi#pi} (GeV/#it{c}^{2})"}}); - registryData.add("XiNeg_in_ue", "XiNeg_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.28, 1.36, "m_{p#pi#pi} (GeV/#it{c}^{2})"}}); - - // Histograms for omega (data) - registryData.add("OmegaPos_in_jet", "OmegaPos_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.63, 1.71, "m_{p#piK} (GeV/#it{c}^{2})"}}); - registryData.add("OmegaPos_in_ue", "OmegaPos_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.63, 1.71, "m_{p#piK} (GeV/#it{c}^{2})"}}); - registryData.add("OmegaNeg_in_jet", "OmegaNeg_in_jet", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.63, 1.71, "m_{p#piK} (GeV/#it{c}^{2})"}}); - registryData.add("OmegaNeg_in_ue", "OmegaNeg_in_ue", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, 1.63, 1.71, "m_{p#piK} (GeV/#it{c}^{2})"}}); - - // Histograms for efficiency (generated) - registryMC.add("K0s_generated_jet", "K0s_generated_jet", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("K0s_generated_ue", "K0s_generated_ue", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("Lambda_generated_jet", "Lambda_generated_jet", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("Lambda_generated_ue", "Lambda_generated_ue", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("AntiLambda_generated_jet", "AntiLambda_generated_jet", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("AntiLambda_generated_ue", "AntiLambda_generated_ue", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("XiPos_generated", "XiPos_generated", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("XiNeg_generated", "XiNeg_generated", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("OmegaPos_generated", "OmegaPos_generated", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("OmegaNeg_generated", "OmegaNeg_generated", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - - // Histograms for efficiency (reconstructed) - registryMC.add("K0s_reconstructed_jet", "K0s_reconstructed_jet", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("K0s_reconstructed_ue", "K0s_reconstructed_ue", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("Lambda_reconstructed_jet", "Lambda_reconstructed_jet", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("Lambda_reconstructed_ue", "Lambda_reconstructed_ue", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("AntiLambda_reconstructed_jet", "AntiLambda_reconstructed_jet", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("AntiLambda_reconstructed_ue", "AntiLambda_reconstructed_ue", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("XiPos_reconstructed", "XiPos_reconstructed", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("XiNeg_reconstructed", "XiNeg_reconstructed", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("OmegaPos_reconstructed", "OmegaPos_reconstructed", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("OmegaNeg_reconstructed", "OmegaNeg_reconstructed", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - - // Histograms for secondary hadrons - registryMC.add("K0s_reconstructed_incl", "K0s_reconstructed_incl", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("Lambda_reconstructed_incl", "Lambda_reconstructed_incl", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("AntiLambda_reconstructed_incl", "AntiLambda_reconstructed_incl", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - - // Histograms for 2d reweighting (pion) - registryMC.add("Pion_eta_pt_jet", "Pion_eta_pt_jet", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("Pion_eta_pt_ue", "Pion_eta_pt_ue", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("Pion_eta_pt_pythia", "Pion_eta_pt_pythia", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - - // Histograms for 2d reweighting (K0s) - registryMC.add("K0s_eta_pt_jet", "K0s_eta_pt_jet", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("K0s_eta_pt_ue", "K0s_eta_pt_ue", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("K0s_eta_pt_pythia", "K0s_eta_pt_pythia", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - - // Histograms for 2d reweighting (Lambda) - registryMC.add("Lambda_eta_pt_jet", "Lambda_eta_pt_jet", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("Lambda_eta_pt_ue", "Lambda_eta_pt_ue", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("Lambda_eta_pt_pythia", "Lambda_eta_pt_pythia", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("AntiLambda_eta_pt_jet", "AntiLambda_eta_pt_jet", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("AntiLambda_eta_pt_ue", "AntiLambda_eta_pt_ue", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("AntiLambda_eta_pt_pythia", "AntiLambda_eta_pt_pythia", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - - // Histograms for 2d reweighting (Xi) - registryMC.add("Xi_eta_pt_jet", "Xi_eta_pt_jet", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("Xi_eta_pt_ue", "Xi_eta_pt_ue", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("Xi_eta_pt_pythia", "Xi_eta_pt_pythia", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("AntiXi_eta_pt_jet", "AntiXi_eta_pt_jet", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("AntiXi_eta_pt_ue", "AntiXi_eta_pt_ue", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("AntiXi_eta_pt_pythia", "AntiXi_eta_pt_pythia", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - - // Histograms for 2d reweighting (Omega) - registryMC.add("Omega_eta_pt_jet", "Omega_eta_pt_jet", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("Omega_eta_pt_ue", "Omega_eta_pt_ue", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("Omega_eta_pt_pythia", "Omega_eta_pt_pythia", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("AntiOmega_eta_pt_jet", "AntiOmega_eta_pt_jet", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("AntiOmega_eta_pt_ue", "AntiOmega_eta_pt_ue", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - registryMC.add("AntiOmega_eta_pt_pythia", "AntiOmega_eta_pt_pythia", HistType::kTH2F, {{100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {18, -0.9, 0.9, "#eta"}}); - - // Histograms for efficiency (pions) - registryMC.add("pi_plus_gen", "pi_plus_gen", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("pi_plus_rec_tpc", "pi_plus_rec_tpc", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("pi_plus_rec_tof", "pi_plus_rec_tof", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("pi_minus_gen", "pi_minus_gen", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("pi_minus_rec_tpc", "pi_minus_rec_tpc", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("pi_minus_rec_tof", "pi_minus_rec_tof", HistType::kTH2F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}}); - - // MC Templates - registryMC.add("piplus_dcaxy_prim", "piplus_dcaxy_prim", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); - registryMC.add("piminus_dcaxy_prim", "piminus_dcaxy_prim", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); - registryMC.add("piplus_dcaxy_sec", "piplus_dcaxy_sec", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); - registryMC.add("piminus_dcaxy_sec", "piminus_dcaxy_sec", HistType::kTH3F, {multBinning, {100, 0.0, 10.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -1, 1, "DCA_{xy} (cm)"}}); - } - - template - bool passedTrackSelectionForJetReconstruction(const chargedTrack& track) - { - if (!track.hasITS()) - return false; - if (track.itsNCls() < 3) - return false; - if (!track.hasTPC()) - return false; - if (track.tpcNClsCrossedRows() < 70) - return false; - if (track.tpcChi2NCl() > 4) - return false; - if (track.itsChi2NCl() > 36) - return false; - if (track.eta() < -0.8 || track.eta() > 0.8) - return false; - if (track.pt() < 0.15) - return false; - if (std::fabs(track.dcaXY()) > (par0 + par1 / track.pt())) - return false; - if (std::fabs(track.dcaZ()) > (par0 + par1 / track.pt())) - return false; - return true; - } - - template - bool passedTrackSelectionForPions(const pionTrack& track) - { - if (!track.hasITS()) - return false; - if (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.itsChi2NCl() > maxChi2ITS) - return false; - if (track.eta() < etaMin || track.eta() > etaMax) - return false; - if (std::fabs(track.dcaZ()) > dcazMax) - return false; - return true; - } - - // Lambda Selections - template - bool passedLambdaSelection(const Lambda& v0, const TrackPos& ptrack, const TrackNeg& ntrack) - { - // Single-Track Selections - if (!passedSingleTrackSelection(ptrack)) - return false; - if (!passedSingleTrackSelection(ntrack)) - return false; - - // Momentum of Lambda Daughters - TVector3 proton(v0.pxpos(), v0.pypos(), v0.pzpos()); - TVector3 pion(v0.pxneg(), v0.pyneg(), v0.pzneg()); - - if (proton.Pt() < ptMin_V0_proton) - return false; - if (proton.Pt() > ptMax_V0_proton) - return false; - if (pion.Pt() < ptMin_V0_pion) - return false; - if (pion.Pt() > ptMax_V0_pion) - return false; - - // V0 Selections - if (v0.v0cosPA() < v0cospaMin) - return false; - if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) - return false; - if (v0.dcaV0daughters() > dcaV0DaughtersMax) - return false; - if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) - return false; - if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) - return false; - - // PID Selections (TPC) - if (ptrack.tpcNSigmaPr() < nsigmaTPCmin || ptrack.tpcNSigmaPr() > nsigmaTPCmax) - return false; - if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) - return false; - - // PID Selections (TOF) - if (requireTOF) { - if (ptrack.tofNSigmaPr() < nsigmaTOFmin || ptrack.tofNSigmaPr() > nsigmaTOFmax) - return false; - if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) - return false; - } - return true; - } - - // AntiLambda Selections - template - bool passedAntiLambdaSelection(const AntiLambda& v0, const TrackPos& ptrack, const TrackNeg& ntrack) - { - // Single-Track Selections - if (!passedSingleTrackSelection(ptrack)) - return false; - if (!passedSingleTrackSelection(ntrack)) - return false; - - // Momentum AntiLambda Daughters - TVector3 pion(v0.pxpos(), v0.pypos(), v0.pzpos()); - TVector3 proton(v0.pxneg(), v0.pyneg(), v0.pzneg()); - - if (proton.Pt() < ptMin_V0_proton) - return false; - if (proton.Pt() > ptMax_V0_proton) - return false; - if (pion.Pt() < ptMin_V0_pion) - return false; - if (pion.Pt() > ptMax_V0_pion) - return false; - - // V0 Selections - if (v0.v0cosPA() < v0cospaMin) - return false; - if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) - return false; - if (v0.dcaV0daughters() > dcaV0DaughtersMax) - return false; - if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) - return false; - if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) - return false; - - // PID Selections (TPC) - if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) - return false; - if (ntrack.tpcNSigmaPr() < nsigmaTPCmin || ntrack.tpcNSigmaPr() > nsigmaTPCmax) - 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; - } - return true; - } - - // K0s Selections - template - bool passedK0ShortSelection(const K0short& v0, const TrackPos& ptrack, const TrackNeg& ntrack) - { - // Single-Track Selections - if (!passedSingleTrackSelection(ptrack)) - return false; - if (!passedSingleTrackSelection(ntrack)) - return false; - - // Momentum K0s Daughters - TVector3 pion_pos(v0.pxpos(), v0.pypos(), v0.pzpos()); - TVector3 pion_neg(v0.pxneg(), v0.pyneg(), v0.pzneg()); - - if (pion_pos.Pt() < ptMin_K0_pion) - return false; - if (pion_pos.Pt() > ptMax_K0_pion) - return false; - if (pion_neg.Pt() < ptMin_K0_pion) - return false; - if (pion_neg.Pt() > ptMax_K0_pion) - return false; - - // V0 Selections - if (v0.v0cosPA() < v0cospaMin) - return false; - if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) - return false; - if (v0.dcaV0daughters() > dcaV0DaughtersMax) - return false; - if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) - return false; - if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) - return false; - - // PID Selections (TPC) - if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) - return false; - if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) - return false; - - // PID Selections (TOF) - if (requireTOF) { - if (ptrack.tofNSigmaPi() < nsigmaTOFmin || ptrack.tofNSigmaPi() > nsigmaTOFmax) - return false; - if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) - return false; - } - return true; - } - - // Xi Selections - template - bool passedXiSelection(const Xi& casc, const TrackPos& ptrack, const TrackNeg& ntrack, const TrackBac& btrack, const Coll& coll) - { - if (!passedSingleTrackSelection(ptrack)) - return false; - if (!passedSingleTrackSelection(ntrack)) - return false; - if (!passedSingleTrackSelection(btrack)) - return false; - - // Xi+ Selection (Xi+ -> antiL + pi+) - if (btrack.sign() > 0) { - if (ntrack.pt() < ptMin_V0_proton) - return false; - if (ntrack.pt() > ptMax_V0_proton) - return false; - if (ptrack.pt() < ptMin_V0_pion) - return false; - if (ptrack.pt() > ptMax_V0_pion) - return false; - - // PID Selections (TPC) - if (ntrack.tpcNSigmaPr() < nsigmaTPCmin || ntrack.tpcNSigmaPr() > nsigmaTPCmax) - return false; - if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) - return false; - - // PID Selections (TOF) - if (requireTOF) { - if (ntrack.tofNSigmaPr() < nsigmaTOFmin || ntrack.tofNSigmaPr() > nsigmaTOFmax) - return false; - if (ptrack.tofNSigmaPi() < nsigmaTOFmin || ptrack.tofNSigmaPi() > nsigmaTOFmax) - return false; - } - } - - // Xi- Selection (Xi- -> L + pi-) - if (btrack.sign() < 0) { - if (ptrack.pt() < ptMin_V0_proton) - return false; - if (ptrack.pt() > ptMax_V0_proton) - return false; - if (ntrack.pt() < ptMin_V0_pion) - return false; - if (ntrack.pt() > ptMax_V0_pion) - return false; - - // PID Selections (TPC) - if (ptrack.tpcNSigmaPr() < nsigmaTPCmin || ptrack.tpcNSigmaPr() > nsigmaTPCmax) - return false; - if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) - return false; - - // PID Selections (TOF) - if (requireTOF) { - if (ptrack.tofNSigmaPr() < nsigmaTOFmin || ptrack.tofNSigmaPr() > nsigmaTOFmax) - return false; - if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) - return false; - } - } - - // V0 Selections - if (casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ()) < v0cospaMin) - return false; - if (casc.v0radius() < minimumV0Radius || casc.v0radius() > maximumV0Radius) - return false; - if (casc.dcaV0daughters() > dcaV0DaughtersMax) - return false; - if (casc.dcapostopv() < dcapostoPVmin) - return false; - if (casc.dcanegtopv() < dcanegtoPVmin) - return false; - - // Cascade Selections - if (casc.cascradius() < minimumCascRadius || casc.cascradius() > maximumCascRadius) - return false; - if (casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()) < casccospaMin) - return false; - if (casc.dcabachtopv() < dcabachtopvMin) - return false; - if (casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ()) < dcaV0topvMin) - return false; - if (casc.dcacascdaughters() > dcaCascDaughtersMax) - return false; - - // PID Selection on bachelor - if (btrack.tpcNSigmaPi() < nsigmaTPCmin || btrack.tpcNSigmaPi() > nsigmaTPCmax) - return false; - - // PID Selections (TOF) - if (requireTOF) { - if (btrack.tofNSigmaPi() < nsigmaTOFmin || btrack.tofNSigmaPi() > nsigmaTOFmax) - return false; - } - return true; - } - - // Omega Selections - template - bool passedOmegaSelection(const Omega& casc, const TrackPos& ptrack, const TrackNeg& ntrack, const TrackBac& btrack, const Coll& coll) - { - if (!passedSingleTrackSelection(ptrack)) - return false; - if (!passedSingleTrackSelection(ntrack)) - return false; - if (!passedSingleTrackSelection(btrack)) - return false; - - // Omega+ Selection (Omega+ -> antiL + K+) - if (btrack.sign() > 0) { - if (ntrack.pt() < ptMin_V0_proton) - return false; - if (ntrack.pt() > ptMax_V0_proton) - return false; - if (ptrack.pt() < ptMin_V0_pion) - return false; - if (ptrack.pt() > ptMax_V0_pion) - return false; - - // PID Selections (TPC) - if (ntrack.tpcNSigmaPr() < nsigmaTPCmin || ntrack.tpcNSigmaPr() > nsigmaTPCmax) - return false; - if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) - return false; - - // PID Selections (TOF) - if (requireTOF) { - if (ntrack.tofNSigmaPr() < nsigmaTOFmin || ntrack.tofNSigmaPr() > nsigmaTOFmax) - return false; - if (ptrack.tofNSigmaPi() < nsigmaTOFmin || ptrack.tofNSigmaPi() > nsigmaTOFmax) - return false; - } - } - - // Omega- Selection (Omega- -> L + K-) - if (btrack.sign() < 0) { - if (ptrack.pt() < ptMin_V0_proton) - return false; - if (ptrack.pt() > ptMax_V0_proton) - return false; - if (ntrack.pt() < ptMin_V0_pion) - return false; - if (ntrack.pt() > ptMax_V0_pion) - return false; - - // PID Selections (TPC) - if (ptrack.tpcNSigmaPr() < nsigmaTPCmin || ptrack.tpcNSigmaPr() > nsigmaTPCmax) - return false; - if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) - return false; - - // PID Selections (TOF) - if (requireTOF) { - if (ptrack.tofNSigmaPr() < nsigmaTOFmin || ptrack.tofNSigmaPr() > nsigmaTOFmax) - return false; - if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) - return false; - } - } - - // V0 Selections - if (casc.v0cosPA(coll.posX(), coll.posY(), coll.posZ()) < v0cospaMin) - return false; - if (casc.v0radius() < minimumV0Radius || casc.v0radius() > maximumV0Radius) - return false; - if (casc.dcaV0daughters() > dcaV0DaughtersMax) - return false; - if (casc.dcapostopv() < dcapostoPVmin) - return false; - if (casc.dcanegtopv() < dcanegtoPVmin) - return false; - - // Cascade Selections - if (casc.cascradius() < minimumCascRadius || casc.cascradius() > maximumCascRadius) - return false; - if (casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()) < casccospaMin) - return false; - if (casc.dcabachtopv() < dcabachtopvMin) - return false; - if (casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ()) < dcaV0topvMin) - return false; - if (casc.dcacascdaughters() > dcaCascDaughtersMax) - return false; - - // PID Selection on bachelor - if (btrack.tpcNSigmaKa() < nsigmaTPCmin || btrack.tpcNSigmaKa() > nsigmaTPCmax) - return false; - - // PID Selections (TOF) - if (requireTOF) { - if (btrack.tofNSigmaKa() < nsigmaTOFmin || btrack.tofNSigmaKa() > nsigmaTOFmax) - return false; - } - return true; - } - - // 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; - } - - // Pion Selection - template - bool isHighPurityPion(const pionTrack& track) - { - if (track.p() < 0.6 && std::fabs(track.tpcNSigmaPi()) < 3.0) - return true; - if (track.p() > 0.6 && std::fabs(track.tpcNSigmaPi()) < 3.0 && std::fabs(track.tofNSigmaPi()) < 3.0) - return true; - return false; - } - - float Minimum(float x1, float x2) - { - float x_min(x1); - if (x1 < x2) - x_min = x1; - if (x1 >= x2) - x_min = x2; - return x_min; - } - - double GetDeltaPhi(double a1, double a2) - { - double delta_phi(0); - double phi1 = TVector2::Phi_0_2pi(a1); - double phi2 = TVector2::Phi_0_2pi(a2); - double diff = std::fabs(phi1 - phi2); - - if (diff <= o2::constants::math::PI) - delta_phi = diff; - if (diff > o2::constants::math::PI) - delta_phi = o2::constants::math::TwoPI - diff; - - return delta_phi; - } - - void get_perpendicular_axis(TVector3 p, TVector3& u, double sign) - { - // Initialization - double ux(0), uy(0), uz(0); - - // Components of Vector p - double px = p.X(); - double py = p.Y(); - double pz = p.Z(); - - // Protection 1 - if (px == 0 && py != 0) { - - uy = -(pz * pz) / py; - ux = sign * std::sqrt(py * py - (pz * pz * pz * pz) / (py * py)); - uz = pz; - u.SetXYZ(ux, uy, uz); - return; - } - - // Protection 2 - if (py == 0 && px != 0) { - - ux = -(pz * pz) / px; - uy = sign * std::sqrt(px * px - (pz * pz * pz * pz) / (px * px)); - uz = pz; - u.SetXYZ(ux, uy, uz); - return; - } - - // Equation Parameters - double a = px * px + py * py; - double b = 2.0 * px * pz * pz; - double c = pz * pz * pz * pz - py * py * py * py - px * px * py * py; - double delta = b * b - 4.0 * a * c; - - // Protection agains delta<0 - if (delta < 0) { - return; - } - - // Solutions - ux = (-b + sign * std::sqrt(delta)) / (2.0 * a); - uy = (-pz * pz - px * ux) / py; - uz = pz; - u.SetXYZ(ux, uy, uz); - return; - } - - double calculate_dij(TVector3 t1, TVector3 t2, double R) - { - double distance_jet(0); - double x1 = 1.0 / (t1.Pt() * t1.Pt()); - double x2 = 1.0 / (t2.Pt() * t2.Pt()); - double deltaEta = t1.Eta() - t2.Eta(); - double deltaPhi = GetDeltaPhi(t1.Phi(), t2.Phi()); - double min = Minimum(x1, x2); - double Delta2 = deltaEta * deltaEta + deltaPhi * deltaPhi; - distance_jet = min * Delta2 / (R * R); - return distance_jet; - } - - bool overlap(TVector3 v1, TVector3 v2, double R) - { - double dx = v1.Eta() - v2.Eta(); - double dy = GetDeltaPhi(v1.Phi(), v2.Phi()); - double d = std::sqrt(dx * dx + dy * dy); - if (d < 2.0 * R) - return true; - return false; - } - - void GetReweightingHistograms(o2::framework::Service const& ccdbObj, TString filepath, TString histname_k0_jet, TString histname_k0_ue, TString histname_lambda_jet, TString histname_lambda_ue, TString histname_antilambda_jet, TString histname_antilambda_ue) - { - TList* l = ccdbObj->get(filepath.Data()); - if (!l) { - LOGP(error, "Could not open the file {}", Form("%s", filepath.Data())); - return; - } - twod_weights_k0_jet = static_cast(l->FindObject(Form("%s", histname_k0_jet.Data()))); - if (!twod_weights_k0_jet) { - LOGP(error, "Could not open histogram {}", Form("%s", histname_k0_jet.Data())); - return; - } - twod_weights_k0_ue = static_cast(l->FindObject(Form("%s", histname_k0_ue.Data()))); - if (!twod_weights_k0_ue) { - LOGP(error, "Could not open histogram {}", Form("%s", histname_k0_ue.Data())); - return; - } - twod_weights_lambda_jet = static_cast(l->FindObject(Form("%s", histname_lambda_jet.Data()))); - if (!twod_weights_lambda_jet) { - LOGP(error, "Could not open histogram {}", Form("%s", histname_lambda_jet.Data())); - return; - } - twod_weights_lambda_ue = static_cast(l->FindObject(Form("%s", histname_lambda_ue.Data()))); - if (!twod_weights_lambda_ue) { - LOGP(error, "Could not open histogram {}", Form("%s", histname_lambda_ue.Data())); - return; - } - twod_weights_antilambda_jet = static_cast(l->FindObject(Form("%s", histname_antilambda_jet.Data()))); - if (!twod_weights_antilambda_jet) { - LOGP(error, "Could not open histogram {}", Form("%s", histname_antilambda_jet.Data())); - return; - } - twod_weights_antilambda_ue = static_cast(l->FindObject(Form("%s", histname_antilambda_ue.Data()))); - if (!twod_weights_antilambda_ue) { - LOGP(error, "Could not open histogram {}", Form("%s", histname_antilambda_ue.Data())); - return; - } - - LOGP(info, "Opened histogram {}", Form("%s", histname_k0_jet.Data())); - LOGP(info, "Opened histogram {}", Form("%s", histname_k0_ue.Data())); - LOGP(info, "Opened histogram {}", Form("%s", histname_lambda_jet.Data())); - LOGP(info, "Opened histogram {}", Form("%s", histname_lambda_ue.Data())); - LOGP(info, "Opened histogram {}", Form("%s", histname_antilambda_jet.Data())); - LOGP(info, "Opened histogram {}", Form("%s", histname_antilambda_ue.Data())); - } - - void processData(SelCollisions::iterator const& collision, aod::V0Datas const& fullV0s, aod::CascDataExt const& Cascades, StrHadronDaughterTracks const& tracks) - { - - // Event Counter: before event selection - registryData.fill(HIST("number_of_events_data"), 0.5); - - // Event Selection - if (!collision.sel8()) - return; - - // Event Counter: after event selection sel8 - registryData.fill(HIST("number_of_events_data"), 1.5); - - // Cut on z-vertex - if (std::fabs(collision.posZ()) > zVtx) - return; - - // Event Counter: after z-vertex cut - registryData.fill(HIST("number_of_events_data"), 2.5); - - // List of Tracks - std::vector trk; - - for (auto track : tracks) { // o2-linter: disable=[const-ref-in-for-loop] - - if (!passedTrackSelectionForJetReconstruction(track)) - continue; - - TVector3 momentum(track.px(), track.py(), track.pz()); - trk.push_back(momentum); - } - - // Anti-kt Jet Finder - int n_particles_removed(0); - std::vector jet; - std::vector ue1; - std::vector ue2; - - do { - double dij_min(1e+06), diB_min(1e+06); - int i_min(0), j_min(0), iB_min(0); - for (int i = 0; i < static_cast(trk.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop] - if (trk[i].Mag() == 0) - continue; - double diB = 1.0 / (trk[i].Pt() * trk[i].Pt()); - if (diB < diB_min) { - diB_min = diB; - iB_min = i; - } - for (int j = (i + 1); j < static_cast(trk.size()); j++) { // o2-linter: disable=[const-ref-in-for-loop] - if (trk[j].Mag() == 0) - continue; - double dij = calculate_dij(trk[i], trk[j], Rjet); - if (dij < dij_min) { - dij_min = dij; - i_min = i; - j_min = j; - } - } - } - if (dij_min < diB_min) { - trk[i_min] = trk[i_min] + trk[j_min]; - trk[j_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - if (dij_min > diB_min) { - jet.push_back(trk[iB_min]); - trk[iB_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - } while (n_particles_removed < static_cast(trk.size())); - registryQC.fill(HIST("nJets_found"), static_cast(jet.size())); - - // Jet Selection - std::vector isSelected; - for (int i = 0; i < static_cast(jet.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop] - isSelected.push_back(0); - } - - int n_jets_selected(0); - for (int i = 0; i < static_cast(jet.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop] - - if ((std::fabs(jet[i].Eta()) + Rjet) > etaMax) - continue; - - // Perpendicular cones - TVector3 ue_axis1(0, 0, 0); - TVector3 ue_axis2(0, 0, 0); - get_perpendicular_axis(jet[i], ue_axis1, +1); - get_perpendicular_axis(jet[i], ue_axis2, -1); - ue1.push_back(ue_axis1); - ue2.push_back(ue_axis2); - - double nPartJetPlusUE(0); - double nPartJet(0); - double nPartUE(0); - double ptJetPlusUE(0); - double ptJet(0); - double ptUE(0); - - for (auto track : tracks) { // o2-linter: disable=[const-ref-in-for-loop] - - if (!passedTrackSelectionForJetReconstruction(track)) - continue; - TVector3 sel_track(track.px(), track.py(), track.pz()); - - double deltaEta_jet = sel_track.Eta() - jet[i].Eta(); - double deltaPhi_jet = GetDeltaPhi(sel_track.Phi(), jet[i].Phi()); - double deltaR_jet = std::sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = sel_track.Eta() - ue_axis1.Eta(); - double deltaPhi_ue1 = GetDeltaPhi(sel_track.Phi(), ue_axis1.Phi()); - double deltaR_ue1 = std::sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = sel_track.Eta() - ue_axis2.Eta(); - double deltaPhi_ue2 = GetDeltaPhi(sel_track.Phi(), ue_axis2.Phi()); - double deltaR_ue2 = std::sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - if (deltaR_jet < Rjet) { - registryQC.fill(HIST("deltaEtadeltaPhi_jet"), deltaEta_jet, deltaPhi_jet); - nPartJetPlusUE++; - ptJetPlusUE = ptJetPlusUE + sel_track.Pt(); - } - if (deltaR_ue1 < Rjet) { - registryQC.fill(HIST("deltaEtadeltaPhi_ue"), deltaEta_ue1, deltaPhi_ue1); - nPartUE++; - ptUE = ptUE + sel_track.Pt(); - } - if (deltaR_ue2 < Rjet) { - registryQC.fill(HIST("deltaEtadeltaPhi_ue"), deltaEta_ue1, deltaPhi_ue1); - nPartUE++; - ptUE = ptUE + sel_track.Pt(); - } - } - nPartJet = nPartJetPlusUE - 0.5 * nPartUE; - ptJet = ptJetPlusUE - 0.5 * ptUE; - registryQC.fill(HIST("NchJetPlusUE"), nPartJetPlusUE); - registryQC.fill(HIST("NchJet"), nPartJet); - registryQC.fill(HIST("NchUE"), nPartUE); - registryQC.fill(HIST("sumPtJetPlusUE"), ptJetPlusUE); - registryQC.fill(HIST("sumPtJet"), ptJet); - registryQC.fill(HIST("sumPtUE"), ptUE); - - if (ptJet < min_jet_pt) - continue; - if (nPartJetPlusUE < min_nPartInJet) - continue; - n_jets_selected++; - isSelected[i] = 1; - } - registryQC.fill(HIST("nJets_selected"), n_jets_selected); - - if (n_jets_selected == 0) - return; - registryData.fill(HIST("number_of_events_data"), 3.5); - - // Overlaps - int nOverlaps(0); - for (int i = 0; i < static_cast(jet.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop] - if (isSelected[i] == 0) - continue; - - for (int j = 0; j < static_cast(jet.size()); j++) { // o2-linter: disable=[const-ref-in-for-loop] - if (isSelected[j] == 0 || i == j) - continue; - if (overlap(jet[i], ue1[j], Rjet) || overlap(jet[i], ue2[j], Rjet)) - nOverlaps++; - } - } - registryQC.fill(HIST("jet_ue_overlaps"), n_jets_selected, nOverlaps); - - if (n_jets_selected > n_jets_per_event_max) - return; - registryData.fill(HIST("number_of_events_data"), 4.5); - - if (requireNoOverlap && nOverlaps > 0) - return; - registryData.fill(HIST("number_of_events_data"), 5.5); - - // Event multiplicity - float multiplicity = collision.centFT0M(); - - registryData.fill(HIST("number_of_events_vsmultiplicity"), multiplicity); - - for (int i = 0; i < static_cast(jet.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop] - - if (isSelected[i] == 0) - continue; - - // Vzeros - if (particle_of_interest == option::vzeros) { - for (auto& v0 : fullV0s) { // o2-linter: disable=[const-ref-in-for-loop] - - const auto& pos = v0.posTrack_as(); - const auto& neg = v0.negTrack_as(); - TVector3 v0dir(v0.px(), v0.py(), v0.pz()); - - float deltaEta_jet = v0dir.Eta() - jet[i].Eta(); - float deltaPhi_jet = GetDeltaPhi(v0dir.Phi(), jet[i].Phi()); - float deltaR_jet = std::sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - float deltaEta_ue1 = v0dir.Eta() - ue1[i].Eta(); - float deltaPhi_ue1 = GetDeltaPhi(v0dir.Phi(), ue1[i].Phi()); - float deltaR_ue1 = std::sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - float deltaEta_ue2 = v0dir.Eta() - ue2[i].Eta(); - float deltaPhi_ue2 = GetDeltaPhi(v0dir.Phi(), ue2[i].Phi()); - float deltaR_ue2 = std::sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - // K0s - if (passedK0ShortSelection(v0, pos, neg)) { - if (deltaR_jet < Rjet) { - registryData.fill(HIST("K0s_in_jet"), multiplicity, v0.pt(), v0.mK0Short()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryData.fill(HIST("K0s_in_ue"), multiplicity, v0.pt(), v0.mK0Short()); - } - } - // Lambda - if (passedLambdaSelection(v0, pos, neg)) { - if (deltaR_jet < Rjet) { - registryData.fill(HIST("Lambda_in_jet"), multiplicity, v0.pt(), v0.mLambda()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryData.fill(HIST("Lambda_in_ue"), multiplicity, v0.pt(), v0.mLambda()); - } - } - // AntiLambda - if (passedAntiLambdaSelection(v0, pos, neg)) { - if (deltaR_jet < Rjet) { - registryData.fill(HIST("AntiLambda_in_jet"), multiplicity, v0.pt(), v0.mAntiLambda()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryData.fill(HIST("AntiLambda_in_ue"), multiplicity, v0.pt(), v0.mAntiLambda()); - } - } - } - } - - // Cascades - if (particle_of_interest == option::cascades) { - for (auto& casc : Cascades) { // o2-linter: disable=[const-ref-in-for-loop] - - auto bach = casc.bachelor_as(); - auto pos = casc.posTrack_as(); - auto neg = casc.negTrack_as(); - - TVector3 cascade_dir(casc.px(), casc.py(), casc.pz()); - float deltaEta_jet = cascade_dir.Eta() - jet[i].Eta(); - float deltaPhi_jet = GetDeltaPhi(cascade_dir.Phi(), jet[i].Phi()); - float deltaR_jet = std::sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - float deltaEta_ue1 = cascade_dir.Eta() - ue1[i].Eta(); - float deltaPhi_ue1 = GetDeltaPhi(cascade_dir.Phi(), ue1[i].Phi()); - float deltaR_ue1 = std::sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - float deltaEta_ue2 = cascade_dir.Eta() - ue2[i].Eta(); - float deltaPhi_ue2 = GetDeltaPhi(cascade_dir.Phi(), ue2[i].Phi()); - float deltaR_ue2 = std::sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - // Xi+ - if (passedXiSelection(casc, pos, neg, bach, collision) && - bach.sign() > 0) { - if (deltaR_jet < Rjet) { - registryData.fill(HIST("XiPos_in_jet"), multiplicity, casc.pt(), casc.mXi()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryData.fill(HIST("XiPos_in_ue"), multiplicity, casc.pt(), casc.mXi()); - } - } - // Xi- - if (passedXiSelection(casc, pos, neg, bach, collision) && - bach.sign() < 0) { - if (deltaR_jet < Rjet) { - registryData.fill(HIST("XiNeg_in_jet"), multiplicity, casc.pt(), casc.mXi()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryData.fill(HIST("XiNeg_in_ue"), multiplicity, casc.pt(), casc.mXi()); - } - } - // Omega+ - if (passedOmegaSelection(casc, pos, neg, bach, collision) && - bach.sign() > 0) { - if (deltaR_jet < Rjet) { - registryData.fill(HIST("OmegaPos_in_jet"), multiplicity, casc.pt(), casc.mOmega()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryData.fill(HIST("OmegaPos_in_ue"), multiplicity, casc.pt(), casc.mOmega()); - } - } - // Omega- - if (passedOmegaSelection(casc, pos, neg, bach, collision) && - bach.sign() < 0) { - if (deltaR_jet < Rjet) { - registryData.fill(HIST("OmegaNeg_in_jet"), multiplicity, casc.pt(), casc.mOmega()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryData.fill(HIST("OmegaNeg_in_ue"), multiplicity, casc.pt(), casc.mOmega()); - } - } - } - } - - // Pions - if (particle_of_interest == option::pions) { - for (auto track : tracks) { // o2-linter: disable=[const-ref-in-for-loop] - - if (!passedTrackSelectionForPions(track)) - continue; - - TVector3 track_dir(track.px(), track.py(), track.pz()); - float deltaEta_jet = track_dir.Eta() - jet[i].Eta(); - float deltaPhi_jet = GetDeltaPhi(track_dir.Phi(), jet[i].Phi()); - float deltaR_jet = std::sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - float deltaEta_ue1 = track_dir.Eta() - ue1[i].Eta(); - float deltaPhi_ue1 = GetDeltaPhi(track_dir.Phi(), ue1[i].Phi()); - float deltaR_ue1 = std::sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - float deltaEta_ue2 = track_dir.Eta() - ue2[i].Eta(); - float deltaPhi_ue2 = GetDeltaPhi(track_dir.Phi(), ue2[i].Phi()); - float deltaR_ue2 = std::sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - bool isInJet = false; - bool isInUe = false; - if (deltaR_jet < Rjet) - isInJet = true; - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) - isInUe = true; - - if (isHighPurityPion(track) && track.sign() > 0) { - if (isInJet) - registryData.fill(HIST("piplus_dcaxy_in_jet"), multiplicity, track.pt(), track.dcaXY()); - if (isInUe) - registryData.fill(HIST("piplus_dcaxy_in_ue"), multiplicity, track.pt(), track.dcaXY()); - } - if (isHighPurityPion(track) && track.sign() < 0) { - if (isInJet) - registryData.fill(HIST("piminus_dcaxy_in_jet"), multiplicity, track.pt(), track.dcaXY()); - if (isInUe) - registryData.fill(HIST("piminus_dcaxy_in_ue"), multiplicity, track.pt(), track.dcaXY()); - } - - // DCAxy Selection - if (std::fabs(track.dcaXY()) > dcaxyMax) - continue; - - // TPC - if (isInJet && track.sign() > 0) { - registryData.fill(HIST("piplus_tpc_in_jet"), multiplicity, track.pt(), track.tpcNSigmaPi()); - } - if (isInUe && track.sign() > 0) { - registryData.fill(HIST("piplus_tpc_in_ue"), multiplicity, track.pt(), track.tpcNSigmaPi()); - } - if (isInJet && track.sign() < 0) { - registryData.fill(HIST("piminus_tpc_in_jet"), multiplicity, track.pt(), track.tpcNSigmaPi()); - } - if (isInUe && track.sign() < 0) { - registryData.fill(HIST("piminus_tpc_in_ue"), multiplicity, track.pt(), track.tpcNSigmaPi()); - } - if (track.tpcNSigmaPi() < nsigmaTPCmin || track.tpcNSigmaPi() > nsigmaTPCmax) - continue; - if (!track.hasTOF()) - continue; - - // TOF - if (isInJet && track.sign() > 0) { - registryData.fill(HIST("piplus_tof_in_jet"), multiplicity, track.pt(), track.tofNSigmaPi()); - } - if (isInUe && track.sign() > 0) { - registryData.fill(HIST("piplus_tof_in_ue"), multiplicity, track.pt(), track.tofNSigmaPi()); - } - if (isInJet && track.sign() < 0) { - registryData.fill(HIST("piminus_tof_in_jet"), multiplicity, track.pt(), track.tofNSigmaPi()); - } - if (isInUe && track.sign() < 0) { - registryData.fill(HIST("piminus_tof_in_ue"), multiplicity, track.pt(), track.tofNSigmaPi()); - } - } - } - } - } - PROCESS_SWITCH(strangeness_in_jets, processData, "Process data", true); - - void processK0s(SelCollisions::iterator const& collision, aod::V0Datas const& fullV0s, StrHadronDaughterTracks const&) - { - registryData.fill(HIST("number_of_events_data"), 10.5); - if (!collision.sel8()) - return; - registryData.fill(HIST("number_of_events_data"), 11.5); - if (std::fabs(collision.posZ()) > zVtx) - return; - registryData.fill(HIST("number_of_events_data"), 12.5); - - for (auto& v0 : fullV0s) { // o2-linter: disable=[const-ref-in-for-loop] - const auto& ptrack = v0.posTrack_as(); - const auto& ntrack = v0.negTrack_as(); - - registryQC.fill(HIST("survivedK0"), 0.5); - - // Single-Track Selections - if (!passedSingleTrackSelection(ptrack)) - continue; - registryQC.fill(HIST("survivedK0"), 1.5); - - if (!passedSingleTrackSelection(ntrack)) - continue; - registryQC.fill(HIST("survivedK0"), 2.5); - - // Momentum K0s Daughters - TVector3 pion_pos(v0.pxpos(), v0.pypos(), v0.pzpos()); - TVector3 pion_neg(v0.pxneg(), v0.pyneg(), v0.pzneg()); - - if (pion_pos.Pt() < ptMin_K0_pion) - continue; - registryQC.fill(HIST("survivedK0"), 3.5); - - if (pion_pos.Pt() > ptMax_K0_pion) - continue; - registryQC.fill(HIST("survivedK0"), 4.5); - - if (pion_neg.Pt() < ptMin_K0_pion) - continue; - registryQC.fill(HIST("survivedK0"), 5.5); - - if (pion_neg.Pt() > ptMax_K0_pion) - continue; - registryQC.fill(HIST("survivedK0"), 6.5); - - // V0 Selections - if (v0.v0cosPA() < v0cospaMin) - continue; - registryQC.fill(HIST("survivedK0"), 7.5); - - if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) - continue; - registryQC.fill(HIST("survivedK0"), 8.5); - - if (v0.dcaV0daughters() > dcaV0DaughtersMax) - continue; - registryQC.fill(HIST("survivedK0"), 9.5); - - if (std::fabs(v0.dcapostopv()) < dcapostoPVmin) - continue; - registryQC.fill(HIST("survivedK0"), 10.5); - - if (std::fabs(v0.dcanegtopv()) < dcanegtoPVmin) - continue; - registryQC.fill(HIST("survivedK0"), 11.5); - - // PID Selections (TPC) - if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) - continue; - registryQC.fill(HIST("survivedK0"), 12.5); - - if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) - continue; - registryQC.fill(HIST("survivedK0"), 13.5); - - // PID Selections (TOF) - if (requireTOF) { - if (ptrack.tofNSigmaPi() < nsigmaTOFmin || ptrack.tofNSigmaPi() > nsigmaTOFmax) - continue; - registryQC.fill(HIST("survivedK0"), 14.5); - - if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) - continue; - registryQC.fill(HIST("survivedK0"), 15.5); - } - } - - for (auto& v0 : fullV0s) { // o2-linter: disable=[const-ref-in-for-loop] - const auto& ptrack = v0.posTrack_as(); - const auto& ntrack = v0.negTrack_as(); - if (!passedK0ShortSelection(v0, ptrack, ntrack)) - continue; - registryQC.fill(HIST("survivedK0"), 16.5); - } - } - PROCESS_SWITCH(strangeness_in_jets, processK0s, "Process K0s", false); - - Preslice perCollisionV0 = o2::aod::v0data::collisionId; - Preslice perCollisionCasc = o2::aod::cascade::collisionId; - Preslice perMCCollision = o2::aod::mcparticle::mcCollisionId; - Preslice perCollisionTrk = o2::aod::track::collisionId; - - void processMCefficiency(SimCollisions const& collisions, MCTracks const& mcTracks, aod::V0Datas const& fullV0s, aod::CascDataExt const& Cascades, const aod::McParticles& mcParticles) - { - for (const auto& collision : collisions) { // o2-linter: disable=[const-ref-in-for-loop] - registryMC.fill(HIST("number_of_events_mc"), 0.5); - if (!collision.sel8()) - continue; - - registryMC.fill(HIST("number_of_events_mc"), 1.5); - if (std::fabs(collision.posZ()) > 10.0) - continue; - - registryMC.fill(HIST("number_of_events_mc"), 2.5); - float multiplicity = collision.centFT0M(); - - auto v0s_per_coll = fullV0s.sliceBy(perCollisionV0, collision.globalIndex()); - auto casc_per_coll = Cascades.sliceBy(perCollisionCasc, collision.globalIndex()); - auto mcParticles_per_coll = mcParticles.sliceBy(perMCCollision, collision.globalIndex()); - auto tracks_per_coll = mcTracks.sliceBy(perCollisionTrk, collision.globalIndex()); - - for (auto& v0 : v0s_per_coll) { // o2-linter: disable=[const-ref-in-for-loop] - - const auto& pos = v0.posTrack_as(); - const auto& neg = v0.negTrack_as(); - if (!pos.has_mcParticle()) - continue; - if (!neg.has_mcParticle()) - continue; - - auto posParticle = pos.mcParticle_as(); - auto negParticle = neg.mcParticle_as(); - if (!posParticle.has_mothers()) - continue; - if (!negParticle.has_mothers()) - continue; - - int pdg_parent(0); - bool isPhysPrim = false; - for (auto& particleMotherOfNeg : negParticle.mothers_as()) { // o2-linter: disable=[const-ref-in-for-loop] - for (auto& particleMotherOfPos : posParticle.mothers_as()) { // o2-linter: disable=[const-ref-in-for-loop] - if (particleMotherOfNeg == particleMotherOfPos) { - pdg_parent = particleMotherOfNeg.pdgCode(); - } - } - } - if (pdg_parent == 0) - continue; - - if (passedK0ShortSelection(v0, pos, neg) && pdg_parent == 310) { - registryMC.fill(HIST("K0s_reconstructed_incl"), multiplicity, v0.pt()); - } - if (passedLambdaSelection(v0, pos, neg) && pdg_parent == 3122) { - registryMC.fill(HIST("Lambda_reconstructed_incl"), multiplicity, v0.pt()); - } - if (passedAntiLambdaSelection(v0, pos, neg) && pdg_parent == -3122) { - registryMC.fill(HIST("AntiLambda_reconstructed_incl"), multiplicity, v0.pt()); - } - if (!isPhysPrim) - continue; - - // Momentum of V0 - TVector3 momentum_pos(posParticle.px(), posParticle.py(), posParticle.pz()); - TVector3 momentum_neg(negParticle.px(), negParticle.py(), negParticle.pz()); - TVector3 momentum_v0 = momentum_pos + momentum_neg; - - double w_k0_jet(1.0), w_k0_ue(1.0), w_lambda_jet(1.0), w_lambda_ue(1.0), w_antilambda_jet(1.0), w_antilambda_ue(1.0); - if (applyReweighting) { - int ix = twod_weights_k0_jet->GetXaxis()->FindBin(momentum_v0.Pt()); - int iy = twod_weights_k0_jet->GetYaxis()->FindBin(momentum_v0.Eta()); - w_k0_jet = twod_weights_k0_jet->GetBinContent(ix, iy); - w_k0_ue = twod_weights_k0_ue->GetBinContent(ix, iy); - w_lambda_jet = twod_weights_lambda_jet->GetBinContent(ix, iy); - w_lambda_ue = twod_weights_lambda_ue->GetBinContent(ix, iy); - w_antilambda_jet = twod_weights_antilambda_jet->GetBinContent(ix, iy); - w_antilambda_ue = twod_weights_antilambda_ue->GetBinContent(ix, iy); - - // protections - if (ix == 0 || ix > twod_weights_k0_jet->GetNbinsX()) { - w_k0_jet = 1.0; - w_k0_ue = 1.0; - w_lambda_jet = 1.0; - w_lambda_ue = 1.0; - w_antilambda_jet = 1.0; - w_antilambda_ue = 1.0; - } - if (iy == 0 || iy > twod_weights_k0_jet->GetNbinsY()) { - w_k0_jet = 1.0; - w_k0_ue = 1.0; - w_lambda_jet = 1.0; - w_lambda_ue = 1.0; - w_antilambda_jet = 1.0; - w_antilambda_ue = 1.0; - } - } - - if (passedK0ShortSelection(v0, pos, neg) && pdg_parent == 310) { - registryMC.fill(HIST("K0s_reconstructed_jet"), multiplicity, v0.pt(), w_k0_jet); - registryMC.fill(HIST("K0s_reconstructed_ue"), multiplicity, v0.pt(), w_k0_ue); - } - if (passedLambdaSelection(v0, pos, neg) && pdg_parent == 3122) { - registryMC.fill(HIST("Lambda_reconstructed_jet"), multiplicity, v0.pt(), w_lambda_jet); - registryMC.fill(HIST("Lambda_reconstructed_ue"), multiplicity, v0.pt(), w_lambda_ue); - } - if (passedAntiLambdaSelection(v0, pos, neg) && pdg_parent == -3122) { - registryMC.fill(HIST("AntiLambda_reconstructed_jet"), multiplicity, v0.pt(), w_antilambda_jet); - registryMC.fill(HIST("AntiLambda_reconstructed_ue"), multiplicity, v0.pt(), w_antilambda_ue); - } - } - - // Cascades - for (auto& casc : casc_per_coll) { // o2-linter: disable=[const-ref-in-for-loop] - auto bach = casc.template bachelor_as(); - auto neg = casc.template negTrack_as(); - auto pos = casc.template posTrack_as(); - - if (!bach.has_mcParticle()) - continue; - if (!pos.has_mcParticle()) - continue; - if (!neg.has_mcParticle()) - continue; - - auto posParticle = pos.mcParticle_as(); - auto negParticle = neg.mcParticle_as(); - auto bachParticle = bach.mcParticle_as(); - if (!posParticle.has_mothers()) - continue; - if (!negParticle.has_mothers()) - continue; - if (!bachParticle.has_mothers()) - continue; - - int pdg_parent(0); - for (const auto& particleMotherOfNeg : negParticle.mothers_as()) { // o2-linter: disable=[const-ref-in-for-loop] - for (const auto& particleMotherOfPos : posParticle.mothers_as()) { // o2-linter: disable=[const-ref-in-for-loop] - for (const auto& particleMotherOfBach : bachParticle.mothers_as()) { // o2-linter: disable=[const-ref-in-for-loop] - if (particleMotherOfNeg != particleMotherOfPos) - continue; - if (std::fabs(particleMotherOfNeg.pdgCode()) != 3122) - continue; - if (!particleMotherOfBach.isPhysicalPrimary()) - continue; - - pdg_parent = particleMotherOfBach.pdgCode(); - } - } - } - if (pdg_parent == 0) - continue; - - // Xi+ - if (passedXiSelection(casc, pos, neg, bach, collision) && pdg_parent == -3312) { - registryMC.fill(HIST("XiPos_reconstructed"), multiplicity, casc.pt()); - } - // Xi- - if (passedXiSelection(casc, pos, neg, bach, collision) && pdg_parent == 3312) { - registryMC.fill(HIST("XiNeg_reconstructed"), multiplicity, casc.pt()); - } - // Omega+ - if (passedOmegaSelection(casc, pos, neg, bach, collision) && pdg_parent == -3334) { - registryMC.fill(HIST("OmegaPos_reconstructed"), multiplicity, casc.pt()); - } - // Omega- - if (passedOmegaSelection(casc, pos, neg, bach, collision) && pdg_parent == 3334) { - registryMC.fill(HIST("OmegaNeg_reconstructed"), multiplicity, casc.pt()); - } - } - - // Reconstructed Tracks - for (auto track : tracks_per_coll) { // o2-linter: disable=[const-ref-in-for-loop] - - // Get MC Particle - if (!track.has_mcParticle()) - continue; - // Track Selection - if (!passedTrackSelectionForPions(track)) - continue; - - const auto particle = track.mcParticle(); - if (std::fabs(particle.pdgCode()) != 211) - continue; - - if (particle.isPhysicalPrimary()) { - if (track.sign() > 0) - registryMC.fill(HIST("piplus_dcaxy_prim"), multiplicity, track.pt(), track.dcaXY()); - if (track.sign() < 0) - registryMC.fill(HIST("piminus_dcaxy_prim"), multiplicity, track.pt(), track.dcaXY()); - } - if (!particle.isPhysicalPrimary()) { - if (track.sign() > 0) - registryMC.fill(HIST("piplus_dcaxy_sec"), multiplicity, track.pt(), track.dcaXY()); - if (track.sign() < 0) - registryMC.fill(HIST("piminus_dcaxy_sec"), multiplicity, track.pt(), track.dcaXY()); - } - - if (std::fabs(track.dcaXY()) > dcaxyMax) - continue; - - if (track.tpcNSigmaPi() < nsigmaTPCmin || track.tpcNSigmaPi() > nsigmaTPCmax) - continue; - - if (!particle.isPhysicalPrimary()) - continue; - - if (track.sign() > 0) - registryMC.fill(HIST("pi_plus_rec_tpc"), multiplicity, track.pt()); - if (track.sign() < 0) - registryMC.fill(HIST("pi_minus_rec_tpc"), multiplicity, track.pt()); - - if (!track.hasTOF()) - continue; - if (track.tofNSigmaPi() < nsigmaTOFmin || track.tofNSigmaPi() > nsigmaTOFmax) - continue; - - if (track.sign() > 0) - registryMC.fill(HIST("pi_plus_rec_tof"), multiplicity, track.pt()); - if (track.sign() < 0) - registryMC.fill(HIST("pi_minus_rec_tof"), multiplicity, track.pt()); - } - - for (auto& mcParticle : mcParticles_per_coll) { // o2-linter: disable=[const-ref-in-for-loop] - - if (mcParticle.eta() < etaMin || mcParticle.eta() > etaMax) - continue; - if (!mcParticle.isPhysicalPrimary()) - continue; - - double w_k0_jet(1.0), w_k0_ue(1.0), w_lambda_jet(1.0), w_lambda_ue(1.0), w_antilambda_jet(1.0), w_antilambda_ue(1.0); - if (applyReweighting) { - int ix = twod_weights_k0_jet->GetXaxis()->FindBin(mcParticle.pt()); - int iy = twod_weights_k0_jet->GetYaxis()->FindBin(mcParticle.eta()); - w_k0_jet = twod_weights_k0_jet->GetBinContent(ix, iy); - w_k0_ue = twod_weights_k0_ue->GetBinContent(ix, iy); - w_lambda_jet = twod_weights_lambda_jet->GetBinContent(ix, iy); - w_lambda_ue = twod_weights_lambda_ue->GetBinContent(ix, iy); - w_antilambda_jet = twod_weights_antilambda_jet->GetBinContent(ix, iy); - w_antilambda_ue = twod_weights_antilambda_ue->GetBinContent(ix, iy); - - // protections - if (ix == 0 || ix > twod_weights_k0_jet->GetNbinsX()) { - w_k0_jet = 1.0; - w_k0_ue = 1.0; - w_lambda_jet = 1.0; - w_lambda_ue = 1.0; - w_antilambda_jet = 1.0; - w_antilambda_ue = 1.0; - } - if (iy == 0 || iy > twod_weights_k0_jet->GetNbinsY()) { - w_k0_jet = 1.0; - w_k0_ue = 1.0; - w_lambda_jet = 1.0; - w_lambda_ue = 1.0; - w_antilambda_jet = 1.0; - w_antilambda_ue = 1.0; - } - } - - // Pi+ - if (mcParticle.pdgCode() == 211) { - registryMC.fill(HIST("pi_plus_gen"), multiplicity, mcParticle.pt()); - } - // Pi- - if (mcParticle.pdgCode() == -211) { - registryMC.fill(HIST("pi_minus_gen"), multiplicity, mcParticle.pt()); - } - // K0s - if (mcParticle.pdgCode() == 310) { - registryMC.fill(HIST("K0s_generated_jet"), multiplicity, mcParticle.pt(), w_k0_jet); - registryMC.fill(HIST("K0s_generated_ue"), multiplicity, mcParticle.pt(), w_k0_ue); - registryMC.fill(HIST("K0s_eta_pt_pythia"), mcParticle.pt(), mcParticle.eta()); - } - // Lambda - if (mcParticle.pdgCode() == 3122) { - registryMC.fill(HIST("Lambda_generated_jet"), multiplicity, mcParticle.pt(), w_lambda_jet); - registryMC.fill(HIST("Lambda_generated_ue"), multiplicity, mcParticle.pt(), w_lambda_ue); - registryMC.fill(HIST("Lambda_eta_pt_pythia"), mcParticle.pt(), mcParticle.eta()); - } - // AntiLambda - if (mcParticle.pdgCode() == -3122) { - registryMC.fill(HIST("AntiLambda_generated_jet"), multiplicity, mcParticle.pt(), w_antilambda_jet); - registryMC.fill(HIST("AntiLambda_generated_ue"), multiplicity, mcParticle.pt(), w_antilambda_ue); - registryMC.fill(HIST("AntiLambda_eta_pt_pythia"), mcParticle.pt(), mcParticle.eta()); - } - // Xi Pos - if (mcParticle.pdgCode() == -3312) { - registryMC.fill(HIST("XiPos_generated"), multiplicity, mcParticle.pt()); - registryMC.fill(HIST("Xi_eta_pt_pythia"), mcParticle.pt(), mcParticle.eta()); - } - // Xi Neg - if (mcParticle.pdgCode() == 3312) { - registryMC.fill(HIST("XiNeg_generated"), multiplicity, mcParticle.pt()); - registryMC.fill(HIST("AntiXi_eta_pt_pythia"), mcParticle.pt(), mcParticle.eta()); - } - // Omega Pos - if (mcParticle.pdgCode() == -3334) { - registryMC.fill(HIST("OmegaPos_generated"), multiplicity, mcParticle.pt()); - registryMC.fill(HIST("Omega_eta_pt_pythia"), mcParticle.pt(), mcParticle.eta()); - } - // Omega Neg - if (mcParticle.pdgCode() == 3334) { - registryMC.fill(HIST("OmegaNeg_generated"), multiplicity, mcParticle.pt()); - registryMC.fill(HIST("AntiOmega_eta_pt_pythia"), mcParticle.pt(), mcParticle.eta()); - } - } - } - } - PROCESS_SWITCH(strangeness_in_jets, processMCefficiency, "Process MC Efficiency", false); - - void processGen(o2::aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) - { - for (const auto& mccollision : mcCollisions) { - - registryMC.fill(HIST("number_of_events_mc"), 3.5); - - // Selection on z_{vertex} - if (std::fabs(mccollision.posZ()) > 10) - continue; - registryMC.fill(HIST("number_of_events_mc"), 4.5); - - // MC Particles per Collision - auto mcParticles_per_coll = mcParticles.sliceBy(perMCCollision, mccollision.globalIndex()); - - // List of Tracks - std::vector trk; - - for (auto& particle : mcParticles_per_coll) { // o2-linter: disable=[const-ref-in-for-loop] - - int pdg = std::fabs(particle.pdgCode()); - - // Select Primary Particles - double dx = particle.vx() - mccollision.posX(); - double dy = particle.vy() - mccollision.posY(); - double dz = particle.vz() - mccollision.posZ(); - double dcaxy = std::sqrt(dx * dx + dy * dy); - double dcaz = std::fabs(dz); - if (particle.pt() < 0.15) - continue; - if (dcaxy > (par0 + par1 / particle.pt())) - continue; - if (dcaz > (par0 + par1 / particle.pt())) - continue; - if (std::fabs(particle.eta()) > 0.8) - continue; - - // PDG Selection - if ((pdg != 11) && (pdg != 211) && (pdg != 321) && (pdg != 2212)) - continue; - - TVector3 momentum(particle.px(), particle.py(), particle.pz()); - trk.push_back(momentum); - } - - // Anti-kt Jet Finder - int n_particles_removed(0); - std::vector jet; - std::vector ue1; - std::vector ue2; - - do { - double dij_min(1e+06), diB_min(1e+06); - int i_min(0), j_min(0), iB_min(0); - for (int i = 0; i < static_cast(trk.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop] - if (trk[i].Mag() == 0) - continue; - double diB = 1.0 / (trk[i].Pt() * trk[i].Pt()); - if (diB < diB_min) { - diB_min = diB; - iB_min = i; - } - for (int j = (i + 1); j < static_cast(trk.size()); j++) { // o2-linter: disable=[const-ref-in-for-loop] - if (trk[j].Mag() == 0) - continue; - double dij = calculate_dij(trk[i], trk[j], Rjet); - if (dij < dij_min) { - dij_min = dij; - i_min = i; - j_min = j; - } - } - } - if (dij_min < diB_min) { - trk[i_min] = trk[i_min] + trk[j_min]; - trk[j_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - if (dij_min > diB_min) { - jet.push_back(trk[iB_min]); - trk[iB_min].SetXYZ(0, 0, 0); - n_particles_removed++; - } - } while (n_particles_removed < static_cast(trk.size())); - - // Jet Selection - std::vector isSelected; - for (int i = 0; i < static_cast(jet.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop] - isSelected.push_back(0); - } - - int n_jets_selected(0); - for (int i = 0; i < static_cast(jet.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop] - - if ((std::fabs(jet[i].Eta()) + Rjet) > etaMax) - continue; - - // Perpendicular cones - TVector3 ue_axis1(0, 0, 0); - TVector3 ue_axis2(0, 0, 0); - get_perpendicular_axis(jet[i], ue_axis1, +1); - get_perpendicular_axis(jet[i], ue_axis2, -1); - ue1.push_back(ue_axis1); - ue2.push_back(ue_axis2); - - double nPartJetPlusUE(0); - double ptJetPlusUE(0); - double ptJet(0); - double ptUE(0); - - for (auto& particle : mcParticles_per_coll) { // o2-linter: disable=[const-ref-in-for-loop] - - // Select Primary Particles - double dx = particle.vx() - mccollision.posX(); - double dy = particle.vy() - mccollision.posY(); - double dz = particle.vz() - mccollision.posZ(); - double dcaxy = std::sqrt(dx * dx + dy * dy); - double dcaz = std::fabs(dz); - if (particle.pt() < 0.15) - continue; - if (dcaxy > (par0 + par1 / particle.pt())) - continue; - if (dcaz > (par0 + par1 / particle.pt())) - continue; - if (std::fabs(particle.eta()) > 0.8) - continue; - - // PDG Selection - int pdg = std::fabs(particle.pdgCode()); - if ((pdg != 11) && (pdg != 211) && (pdg != 321) && (pdg != 2212)) - continue; - - TVector3 sel_track(particle.px(), particle.py(), particle.pz()); - - double deltaEta_jet = sel_track.Eta() - jet[i].Eta(); - double deltaPhi_jet = GetDeltaPhi(sel_track.Phi(), jet[i].Phi()); - double deltaR_jet = std::sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = sel_track.Eta() - ue_axis1.Eta(); - double deltaPhi_ue1 = GetDeltaPhi(sel_track.Phi(), ue_axis1.Phi()); - double deltaR_ue1 = std::sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = sel_track.Eta() - ue_axis2.Eta(); - double deltaPhi_ue2 = GetDeltaPhi(sel_track.Phi(), ue_axis2.Phi()); - double deltaR_ue2 = std::sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - if (deltaR_jet < Rjet) { - nPartJetPlusUE++; - ptJetPlusUE = ptJetPlusUE + sel_track.Pt(); - } - if (deltaR_ue1 < Rjet) { - ptUE = ptUE + sel_track.Pt(); - } - if (deltaR_ue2 < Rjet) { - ptUE = ptUE + sel_track.Pt(); - } - } - ptJet = ptJetPlusUE - 0.5 * ptUE; - - if (ptJet < min_jet_pt) - continue; - if (nPartJetPlusUE < min_nPartInJet) - continue; - n_jets_selected++; - isSelected[i] = 1; - } - if (n_jets_selected == 0) - continue; - - for (int i = 0; i < static_cast(jet.size()); i++) { // o2-linter: disable=[const-ref-in-for-loop] - - if (isSelected[i] == 0) - continue; - - // Generated Particles - for (auto& particle : mcParticles_per_coll) { // o2-linter: disable=[const-ref-in-for-loop] - - if (!particle.isPhysicalPrimary()) - continue; - - TVector3 particle_dir(particle.px(), particle.py(), particle.pz()); - double deltaEta_jet = particle_dir.Eta() - jet[i].Eta(); - double deltaPhi_jet = GetDeltaPhi(particle_dir.Phi(), jet[i].Phi()); - double deltaR_jet = std::sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = particle_dir.Eta() - ue1[i].Eta(); - double deltaPhi_ue1 = GetDeltaPhi(particle_dir.Phi(), ue1[i].Phi()); - double deltaR_ue1 = std::sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = particle_dir.Eta() - ue2[i].Eta(); - double deltaPhi_ue2 = GetDeltaPhi(particle_dir.Phi(), ue2[i].Phi()); - double deltaR_ue2 = std::sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - int pdg = std::fabs(particle.pdgCode()); - - if (pdg == 211) { - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("Pion_eta_pt_jet"), particle.pt(), particle.eta()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("Pion_eta_pt_ue"), particle.pt(), particle.eta()); - } - } - if (pdg == 310) { - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("K0s_eta_pt_jet"), particle.pt(), particle.eta()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("K0s_eta_pt_ue"), particle.pt(), particle.eta()); - } - } - if (pdg == 3122) { - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("Lambda_eta_pt_jet"), particle.pt(), particle.eta()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("Lambda_eta_pt_ue"), particle.pt(), particle.eta()); - } - } - if (pdg == -3122) { - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("AntiLambda_eta_pt_jet"), particle.pt(), particle.eta()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("AntiLambda_eta_pt_ue"), particle.pt(), particle.eta()); - } - } - if (pdg == 3312) { - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("Xi_eta_pt_jet"), particle.pt(), particle.eta()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("Xi_eta_pt_ue"), particle.pt(), particle.eta()); - } - } - if (pdg == -3312) { - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("AntiXi_eta_pt_jet"), particle.pt(), particle.eta()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("AntiXi_eta_pt_ue"), particle.pt(), particle.eta()); - } - } - if (pdg == 3334) { - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("Omega_eta_pt_jet"), particle.pt(), particle.eta()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("Omega_eta_pt_ue"), particle.pt(), particle.eta()); - } - } - if (pdg == -3334) { - if (deltaR_jet < Rjet) { - registryMC.fill(HIST("AntiOmega_eta_pt_jet"), particle.pt(), particle.eta()); - } - if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - registryMC.fill(HIST("AntiOmega_eta_pt_ue"), particle.pt(), particle.eta()); - } - } - } - } - } - } - PROCESS_SWITCH(strangeness_in_jets, processGen, "Process generated MC", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/PWGLF/Tasks/Strangeness/strangenessderivedbinnedinfo.cxx b/PWGLF/Tasks/Strangeness/strangenessderivedbinnedinfo.cxx new file mode 100644 index 00000000000..a170b942d59 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/strangenessderivedbinnedinfo.cxx @@ -0,0 +1,800 @@ +// 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. +// +/// \file strangenessderivedbinnedinfo.cxx +/// \brief analysis task producing V0/cascade info in binned format +/// +/// \author Romain Schotter , Austrian Academy of Sciences & SMI +// +// ================ +// +// This code loops over V0Cores and CascCores tables and produces some +// standard analysis output. It is meant to be run over +// derived data. +// +// +// Comments, questions, complaints, suggestions? +// Please write to: +// romain.schotter@cern.ch +// + +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +// constants +const float ctauXiPDG = 4.91; // Xi PDG lifetime +const float ctauOmegaPDG = 2.461; // Omega PDG lifetime + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; + +using namespace o2::aod::rctsel; + +using DauTracks = soa::Join; +using V0Candidates = soa::Join; +using CascadeCandidates = soa::Join; + +struct strangenessderivedbinnedinfo { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // master analysis switches + Configurable analyseK0Short{"analyseK0Short", true, "process K0Short-like candidates"}; + Configurable analyseLambda{"analyseLambda", false, "process Lambda-like candidates"}; + Configurable analyseAntiLambda{"analyseAntiLambda", false, "process AntiLambda-like candidates"}; + Configurable analyseXi{"analyseXi", false, "process Xi-like candidates"}; + Configurable analyseOmega{"analyseOmega", false, "process Omega-like candidates"}; + Configurable isPP{"isPP", true, "If running on pp collision, switch it on true"}; + + // for running over skimmed dataset + Configurable doPPAnalysis{"doPPAnalysis", false, "if in pp, set to true"}; + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "If running over skimmed data, switch it on true"}; + Configurable cfgSkimmedTrigger{"cfgSkimmedTrigger", "fDoubleXi,fTripleXi,fQuadrupleXi", "(std::string) Comma separated list of triggers of interest"}; + Configurable irSource{"irSource", "T0VTX", "Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"}; + + struct : ConfigurableGroup { + Configurable requireSel8{"requireSel8", true, "require sel8 event selection"}; + Configurable requireTriggerTVX{"requireTriggerTVX", true, "require FT0 vertex (acceptable FT0C-FT0A time difference) at trigger level"}; + Configurable rejectITSROFBorder{"rejectITSROFBorder", true, "reject events at ITS ROF border (Run 3 only)"}; + Configurable rejectTFBorder{"rejectTFBorder", true, "reject events at TF border (Run 3 only)"}; + Configurable requireIsVertexITSTPC{"requireIsVertexITSTPC", false, "require events with at least one ITS-TPC track (Run 3 only)"}; + Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", true, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference (Run 3 only)"}; + Configurable requireIsVertexTOFmatched{"requireIsVertexTOFmatched", false, "require events with at least one of vertex contributors matched to TOF (Run 3 only)"}; + Configurable requireIsVertexTRDmatched{"requireIsVertexTRDmatched", false, "require events with at least one of vertex contributors matched to TRD (Run 3 only)"}; + Configurable rejectSameBunchPileup{"rejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC (Run 3 only)"}; + Configurable requireNoCollInTimeRangeStd{"requireNoCollInTimeRangeStd", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds (Run 3 only)"}; + Configurable requireNoCollInTimeRangeStrict{"requireNoCollInTimeRangeStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 10 microseconds (Run 3 only)"}; + Configurable requireNoCollInTimeRangeNarrow{"requireNoCollInTimeRangeNarrow", false, "reject collisions corrupted by the cannibalism, with other collisions within +/- 2 microseconds (Run 3 only)"}; + Configurable requireNoCollInROFStd{"requireNoCollInROFStd", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF with mult. above a certain threshold (Run 3 only)"}; + Configurable requireNoCollInROFStrict{"requireNoCollInROFStrict", false, "reject collisions corrupted by the cannibalism, with other collisions within the same ITS ROF (Run 3 only)"}; + Configurable requireINEL0{"requireINEL0", true, "require INEL>0 event selection"}; + Configurable requireINEL1{"requireINEL1", false, "require INEL>1 event selection"}; + + Configurable maxZVtxPosition{"maxZVtxPosition", 10., "max Z vtx position"}; + + Configurable useFT0CbasedOccupancy{"useFT0CbasedOccupancy", false, "Use sum of FT0-C amplitudes for estimating occupancy? (if not, use track-based definition)"}; + // fast check on occupancy + Configurable minOccupancy{"minOccupancy", -1, "minimum occupancy from neighbouring collisions"}; + Configurable maxOccupancy{"maxOccupancy", -1, "maximum occupancy from neighbouring collisions"}; + // fast check on interaction rate + Configurable minIR{"minIR", -1, "minimum IR collisions"}; + Configurable maxIR{"maxIR", -1, "maximum IR collisions"}; + } eventSelections; + + struct : ConfigurableGroup { + Configurable v0TypeSelection{"v0Selections.v0TypeSelection", 1, "select on a certain V0 type (leave negative if no selection desired)"}; + + // Selection criteria: acceptance + Configurable rapidityCut{"v0Selections.rapidityCut", 0.5, "rapidity"}; + Configurable daughterEtaCut{"v0Selections.daughterEtaCut", 0.8, "max eta for daughters"}; + + // Standard 6 topological criteria + Configurable v0cospa{"v0Selections.v0cospa", 0.97, "min V0 CosPA"}; + Configurable dcav0dau{"v0Selections.dcav0dau", 1.0, "max DCA V0 Daughters (cm)"}; + Configurable dcav0topv{"v0Selections.dcav0topv", .05, "min DCA V0 to PV (cm)"}; + Configurable dcapiontopv{"v0Selections.dcapiontopv", .05, "min DCA Pion To PV (cm)"}; + Configurable dcaprotontopv{"v0Selections.dcaprotontopv", .05, "min DCA Proton To PV (cm)"}; + Configurable v0radius{"v0Selections.v0radius", 1.2, "minimum V0 radius (cm)"}; + Configurable v0radiusMax{"v0Selections.v0radiusMax", 1E5, "maximum V0 radius (cm)"}; + + // invariant mass selection + Configurable v0MassWindow{"v0Selections.v0MassWindow", 0.008, "#Lambda mass (GeV/#it{c}^{2})"}; + Configurable compMassRejection{"v0Selections.compMassRejection", 0.008, "Competing mass rejection (GeV/#it{c}^{2})"}; + + // Additional selection on the AP plot (exclusive for K0Short) + // original equation: lArmPt*5>TMath::Abs(lArmAlpha) + Configurable armPodCut{"v0Selections.armPodCut", 5.0f, "pT * (cut) > |alpha|, AP cut. Negative: no cut"}; + + // Track quality + Configurable minTPCrows{"v0Selections.minTPCrows", 70, "minimum TPC crossed rows"}; + Configurable minITSclusters{"v0Selections.minITSclusters", -1, "minimum ITS clusters"}; + Configurable requireTPConly{"v0Selections.requireTPConly", false, "require V0s comprised of at least one TPC only prong"}; + Configurable requirePosITSonly{"v0Selections.requirePosITSonly", false, "require that positive track is ITSonly (overrides TPC quality)"}; + Configurable requireNegITSonly{"v0Selections.requireNegITSonly", false, "require that negative track is ITSonly (overrides TPC quality)"}; + + // PID (TPC) + Configurable tpcPidNsigmaCut{"v0Selections.tpcPidNsigmaCut", 5, "tpcPidNsigmaCut"}; + } v0Selections; + + struct : ConfigurableGroup { + // Selection criteria: acceptance + Configurable rapidityCut{"cascSelections.rapidityCut", 0.5, "rapidity"}; + Configurable daughterEtaCut{"cascSelections.daughterEtaCut", 0.8, "max eta for daughters"}; + + // Standard 6 topological criteria on V0 + Configurable v0cospa{"cascSelections.v0cospa", 0.97, "min V0 CosPA"}; + Configurable dcav0dau{"cascSelections.dcav0dau", 1.0, "max DCA V0 Daughters (cm)"}; + Configurable dcav0topv{"cascSelections.dcav0topv", .05, "min DCA V0 to PV (cm)"}; + Configurable dcapiontopv{"cascSelections.dcapiontopv", .05, "min DCA Pion To PV (cm)"}; + Configurable dcaprotontopv{"cascSelections.dcaprotontopv", .05, "min DCA Proton To PV (cm)"}; + Configurable v0radius{"cascSelections.v0radius", 1.2, "minimum V0 radius (cm)"}; + Configurable v0radiusMax{"cascSelections.v0radiusMax", 1E5, "maximum V0 radius (cm)"}; + + // Standard 6 topological criteria on cascades + Configurable casccospa{"cascSelections.casccospa", 0.97, "min Cascade CosPA"}; + Configurable dcacascdau{"cascSelections.dcacascdau", 1.0, "max DCA Cascade Daughters (cm)"}; + Configurable dcaxybachbaryontopv{"cascSelections.dcaxybachbaryontopv", -1, "DCAxy Bachelor-Baryon to PV (cm)"}; + Configurable bachbaryoncospa{"cascSelections.bachbaryoncospa", -1, "Bachelor-Baryon CosPA"}; + Configurable dcabachtopv{"cascSelections.dcabachtopv", .05, "min DCA Bachelor To PV (cm)"}; + Configurable cascradius{"cascSelections.cascradius", 0.5, "minimum Cascade radius (cm)"}; + Configurable cascradiusMax{"cascSelections.cascradiusMax", 1E5, "maximum Cascade radius (cm)"}; + Configurable cascProperLifeTime{"cascSelections.cascProperLifeTime", 3, "maximum lifetime (ctau)"}; + + // invariant mass selection + Configurable v0MassWindow{"cascSelections.v0MassWindow", 0.008, "#Lambda mass (GeV/#it{c}^{2})"}; + Configurable cascMassWindow{"cascSelections.cascMassWindow", 0.008, "#Lambda mass (GeV/#it{c}^{2})"}; + Configurable compMassRejection{"cascSelections.compMassRejection", 0.008, "Competing mass rejection (GeV/#it{c}^{2})"}; + + // Track quality + Configurable minTPCrows{"cascSelections.minTPCrows", 70, "minimum TPC crossed rows"}; + Configurable minITSclusters{"cascSelections.minITSclusters", -1, "minimum ITS clusters"}; + Configurable skipTPConly{"cascSelections.skipTPConly", false, "skip V0s comprised of at least one TPC only prong"}; + Configurable requireBachITSonly{"cascSelections.requireBachITSonly", false, "require that bachelor track is ITSonly (overrides TPC quality)"}; + Configurable requirePosITSonly{"cascSelections.requirePosITSonly", false, "require that positive track is ITSonly (overrides TPC quality)"}; + Configurable requireNegITSonly{"cascSelections.requireNegITSonly", false, "require that negative track is ITSonly (overrides TPC quality)"}; + + // PID (TPC) + Configurable tpcPidNsigmaCut{"cascSelections.tpcPidNsigmaCut", 5, "tpcPidNsigmaCut"}; + } cascSelections; + + struct : ConfigurableGroup { + std::string prefix = "rctConfigurations"; // JSON group name + Configurable cfgRCTLabel{"cfgRCTLabel", "", "Which detector condition requirements? (CBT, CBT_hadronPID, CBT_electronPID, CBT_calo, CBT_muon, CBT_muon_glo)"}; + Configurable cfgCheckZDC{"cfgCheckZDC", false, "Include ZDC flags in the bit selection (for Pb-Pb only)"}; + Configurable cfgTreatLimitedAcceptanceAsBad{"cfgTreatLimitedAcceptanceAsBad", false, "reject all events where the detectors relevant for the specified Runlist are flagged as LimitedAcceptance"}; + } rctConfigurations; + + RCTFlagsChecker rctFlagsChecker{rctConfigurations.cfgRCTLabel.value}; + + // CCDB options + struct : ConfigurableGroup { + Configurable ccdburl{"ccdbConfigurations.ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"ccdbConfigurations.grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"ccdbConfigurations.grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"ccdbConfigurations.lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"ccdbConfigurations.geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable mVtxPath{"ccdbConfigurations.mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; + } ccdbConfigurations; + + Service ccdb; + o2::ccdb::CcdbApi ccdbApi; + ctpRateFetcher rateFetcher; + int mRunNumber; + std::map metadata; + + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + + static constexpr float defaultLifetimeCuts[1][2] = {{30., 20.}}; + Configurable> lifetimecut{"lifetimecut", {defaultLifetimeCuts[0], 2, {"lifetimecutLambda", "lifetimecutK0S"}}, "lifetimecut"}; + + ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0.0f, 20.0f, 40.0f, 60.0f, 80.0f, 100.0f}, "Centrality"}; + ConfigurableAxis axisOccupancy{"axisOccupancy", {VARIABLE_WIDTH, 0.0f, 1000.0f, 3000.0f, 10000.0f, 30000.0f}, "Occupancy"}; + + // topological variable QA axes + ConfigurableAxis axisMass{"axisV0Mass", {25, 0.45, 0.55f}, "Invariant mass (GeV/#it{c}^{2})"}; + ConfigurableAxis axisPhi{"axisPhi", {36, 0.0f, constants::math::TwoPI}, "#varphi (rad)"}; + ConfigurableAxis axisEta{"axisEta", {10, -1.0f, 1.0f}, "Pseudo-rapidity #eta"}; + ConfigurableAxis axisRadius{"axisRadius", {10, 0.0f, 250.0f}, "Decay radius (cm)"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 4.0f, 5.0f, 7.0f, 9.0f, 11.0f, 15.0f, 30.0f}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis axisAlphaV0{"axisAlphaV0", {1, -1.0f, 1.f}, "V0 #alpha Armenteros"}; + ConfigurableAxis axisPtArmV0{"axisPtArmV0", {1, 0.0f, 10.f}, "V0 #it{p}_{T} Armenteros"}; + + // PDG database + Service pdgDB; + + void init(InitContext const&) + { + if (analyseK0Short + analyseLambda + analyseAntiLambda + analyseXi + analyseOmega > 1) { + LOGF(fatal, "Cannot enable several particles at the same time. Please choose one."); + } + + // Initialise the RCTFlagsChecker + rctFlagsChecker.init(rctConfigurations.cfgRCTLabel.value, rctConfigurations.cfgCheckZDC, rctConfigurations.cfgTreatLimitedAcceptanceAsBad); + + // Event Counters + histos.add("hEventSelection", "hEventSelection", kTH1D, {{21, -0.5f, +20.5f}}); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(3, "kIsTriggerTVX"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(5, "kNoTimeFrameBorder"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(6, "posZ cut"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(7, "kIsVertexITSTPC"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(8, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(9, "kIsVertexTOFmatched"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(10, "kIsVertexTRDmatched"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(11, "kNoSameBunchPileup"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(12, "kNoCollInTimeRangeStd"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(13, "kNoCollInTimeRangeStrict"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(14, "kNoCollInTimeRangeNarrow"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(15, "kNoCollInRofStd"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(16, "kNoCollInRofStrict"); + if (doPPAnalysis) { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(17, "INEL>0"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "INEL>1"); + } else { + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(17, "Below min occup."); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "Above max occup."); + } + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(19, "Below min IR"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(20, "Above max IR"); + histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(21, "RCT flags"); + + histos.add("hEventCentrality", "hEventCentrality", kTH1F, {{100, 0.0f, +100.0f}}); + histos.add("hEventOccupancy", "hEventOccupancy", kTH1F, {axisOccupancy}); + + histos.add("h9dCentOccQoverPtMassRadiusPhiEtaPtArmV0AlphaV0", "h9dCentOccQoverPtMassRadiusPhiEtaPtArmV0AlphaV0", kTHnSparseF, {axisCentrality, axisOccupancy, axisPt, axisMass, axisRadius, axisPhi, axisEta, axisPtArmV0, axisAlphaV0}); + + if (cfgSkimmedProcessing) { + zorroSummary.setObject(zorro.getZorroSummary()); + } + + // inspect histogram sizes, please + histos.print(); + } + + template // TCollision should be of the type: soa::Join::iterator or so + void initCCDB(TCollision const& collision) + { + if (mRunNumber == collision.runNumber()) { + return; + } + + mRunNumber = collision.runNumber(); + if (cfgSkimmedProcessing) { + ccdb->setURL(ccdbConfigurations.ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + zorro.initCCDB(ccdb.service, collision.runNumber(), collision.timestamp(), cfgSkimmedTrigger.value); + zorro.populateHistRegistry(histos, collision.runNumber()); + } + } + + template + bool isEventAccepted(TCollision collision, bool fillHists) + // check whether the collision passes our collision selections + { + if (fillHists) + histos.fill(HIST("hEventSelection"), 0. /* all collisions */); + + if (eventSelections.requireSel8 && !collision.sel8()) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 1 /* sel8 collisions */); + + if (eventSelections.requireTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 2 /* FT0 vertex (acceptable FT0C-FT0A time difference) collisions */); + + if (eventSelections.rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 3 /* Not at ITS ROF border */); + + if (eventSelections.rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 4 /* Not at TF border */); + + if (std::abs(collision.posZ()) > eventSelections.maxZVtxPosition) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 5 /* vertex-Z selected */); + + if (eventSelections.requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 6 /* Contains at least one ITS-TPC track */); + + if (eventSelections.requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 7 /* PV position consistency check */); + + if (eventSelections.requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 8 /* PV with at least one contributor matched with TOF */); + + if (eventSelections.requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 9 /* PV with at least one contributor matched with TRD */); + + if (eventSelections.rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 10 /* Not at same bunch pile-up */); + + if (eventSelections.requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 11 /* No other collision within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds*/); + + if (eventSelections.requireNoCollInTimeRangeStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 12 /* No other collision within +/- 10 microseconds */); + + if (eventSelections.requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 13 /* No other collision within +/- 2 microseconds */); + + if (eventSelections.requireNoCollInROFStd && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 14 /* No other collision within the same ITS ROF with mult. above a certain threshold */); + + if (eventSelections.requireNoCollInROFStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 15 /* No other collision within the same ITS ROF */); + + if (doPPAnalysis) { // we are in pp + if (eventSelections.requireINEL0 && collision.multNTracksPVeta1() < 1) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 16 /* INEL > 0 */); + + if (eventSelections.requireINEL1 && collision.multNTracksPVeta1() < 2) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 17 /* INEL > 1 */); + + } else { // we are in Pb-Pb + float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + if (eventSelections.minOccupancy >= 0 && collisionOccupancy < eventSelections.minOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 16 /* Below min occupancy */); + + if (eventSelections.maxOccupancy >= 0 && collisionOccupancy > eventSelections.maxOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 17 /* Above max occupancy */); + } + + // Fetch interaction rate only if required (in order to limit ccdb calls) + double interactionRate = (eventSelections.minIR >= 0 || eventSelections.maxIR >= 0) ? rateFetcher.fetch(ccdb.service, collision.timestamp(), collision.runNumber(), irSource) * 1.e-3 : -1; + if (eventSelections.minIR >= 0 && interactionRate < eventSelections.minIR) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 18 /* Below min IR */); + + if (eventSelections.maxIR >= 0 && interactionRate > eventSelections.maxIR) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 19 /* Above max IR */); + + if (!rctConfigurations.cfgRCTLabel.value.empty() && !rctFlagsChecker(collision)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 20 /* Pass CBT condition */); + + return true; + } + + template + void fillEventHistograms(TCollision collision, float& centrality, float& occupancy) + { + if (isPP) { // + centrality = collision.centFT0M(); + } else { + centrality = collision.centFT0C(); + occupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + } + histos.fill(HIST("hEventCentrality"), centrality); + histos.fill(HIST("hEventOccupancy"), occupancy); + + return; + } + + template + bool isV0Selected(TV0 v0, TCollision collision, float rapidity) + // precalculate this information so that a check is one mask operation, not many + { + // + // Base topological variables + // + + // v0 radius min/max selections + if (v0.v0radius() < v0Selections.v0radius) + return false; + if (v0.v0radius() > v0Selections.v0radiusMax) + return false; + // DCA proton and pion to PV for Lambda and AntiLambda decay hypotheses + if (analyseK0Short) { + if (std::fabs(v0.dcapostopv()) < v0Selections.dcapiontopv) + return false; + if (std::fabs(v0.dcanegtopv()) < v0Selections.dcapiontopv) + return false; + } + if (analyseLambda) { + if (std::fabs(v0.dcapostopv()) < v0Selections.dcaprotontopv) + return false; + if (std::fabs(v0.dcanegtopv()) < v0Selections.dcapiontopv) + return false; + } + if (analyseAntiLambda) { + if (std::fabs(v0.dcapostopv()) < v0Selections.dcapiontopv) + return false; + if (std::fabs(v0.dcanegtopv()) < v0Selections.dcaprotontopv) + return false; + } + // V0 cosine of pointing angle + if (v0.v0cosPA() < v0Selections.v0cospa) + return false; + // DCA between v0 daughters + if (v0.dcaV0daughters() > v0Selections.dcav0dau) + return false; + // DCA V0 to prim vtx + if (v0.dcav0topv() < v0Selections.dcav0topv) + return false; + + // + // rapidity + // + if (std::fabs(rapidity) > v0Selections.rapidityCut) + return false; + + // + // competing mass rejection + // + if ((analyseLambda || analyseAntiLambda) && std::fabs(v0.mK0Short() - o2::constants::physics::MassK0Short) < v0Selections.compMassRejection) + return false; + if (analyseK0Short && std::fabs(v0.mLambda() - o2::constants::physics::MassLambda0) < v0Selections.compMassRejection) + return false; + + auto posTrackExtra = v0.template posTrackExtra_as(); + auto negTrackExtra = v0.template negTrackExtra_as(); + + // + // ITS quality flags + // + if (posTrackExtra.itsNCls() < v0Selections.minITSclusters) + return false; + if (negTrackExtra.itsNCls() < v0Selections.minITSclusters) + return false; + + // + // TPC quality flags + // + if (posTrackExtra.tpcCrossedRows() < v0Selections.minTPCrows) + return false; + if (negTrackExtra.tpcCrossedRows() < v0Selections.minTPCrows) + return false; + + // + // TPC PID + // + if (analyseK0Short) { + if (std::fabs(posTrackExtra.tpcNSigmaPi()) > v0Selections.tpcPidNsigmaCut) + return false; + if (std::fabs(negTrackExtra.tpcNSigmaPi()) > v0Selections.tpcPidNsigmaCut) + return false; + } + if (analyseLambda) { + if (std::fabs(posTrackExtra.tpcNSigmaPr()) > v0Selections.tpcPidNsigmaCut) + return false; + if (std::fabs(negTrackExtra.tpcNSigmaPi()) > v0Selections.tpcPidNsigmaCut) + return false; + } + if (analyseAntiLambda) { + if (std::fabs(posTrackExtra.tpcNSigmaPi()) > v0Selections.tpcPidNsigmaCut) + return false; + if (std::fabs(negTrackExtra.tpcNSigmaPr()) > v0Selections.tpcPidNsigmaCut) + return false; + } + + // + // ITS only tag + if (v0Selections.requirePosITSonly && posTrackExtra.tpcCrossedRows() > 0) + return false; + if (v0Selections.requireNegITSonly && negTrackExtra.tpcCrossedRows() > 0) + return false; + + // + // TPC only tag + if (v0Selections.requireTPConly && posTrackExtra.detectorMap() != o2::aod::track::TPC) + return false; + if (v0Selections.requireTPConly && negTrackExtra.detectorMap() != o2::aod::track::TPC) + return false; + + // + // proper lifetime + if ((analyseLambda || analyseAntiLambda) && + v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0 > lifetimecut->get("lifetimecutLambda")) + return false; + if (analyseK0Short && + v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short > lifetimecut->get("lifetimecutK0S")) + return false; + + // + // armenteros + if (v0Selections.armPodCut > 1e-4 && v0.qtarm() * v0Selections.armPodCut < std::fabs(v0.alpha())) + return false; + + return true; + } + + template + bool isCascadeSelected(TCascade casc, TCollision collision, float rapidity) + // precalculate this information so that a check is one mask operation, not many + { + // + // Base topological variables + // + + // v0 radius min/max selections + if (casc.v0radius() < cascSelections.v0radius) + return false; + if (casc.v0radius() > cascSelections.v0radiusMax) + return false; + // DCA proton and pion to PV for Lambda and AntiLambda decay hypotheses + if (casc.sign() < 0) { // Xi- or Omega- --> positive/negative daughter = proton/pion + if (std::fabs(casc.dcapostopv()) < cascSelections.dcaprotontopv) + return false; + if (std::fabs(casc.dcanegtopv()) < cascSelections.dcapiontopv) + return false; + } else { // Xi+ or Omega+ --> positive/negative daughter = pion/proton + if (std::fabs(casc.dcapostopv()) < cascSelections.dcapiontopv) + return false; + if (std::fabs(casc.dcanegtopv()) < cascSelections.dcaprotontopv) + return false; + } + // V0 cosine of pointing angle + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cascSelections.v0cospa) + return false; + // DCA between v0 daughters + if (casc.dcaV0daughters() > cascSelections.dcav0dau) + return false; + // DCA V0 to prim vtx + if (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) < cascSelections.dcav0topv) + return false; + + // casc radius min/max selections + if (casc.cascradius() < cascSelections.cascradius) + return false; + if (casc.cascradius() > cascSelections.cascradiusMax) + return false; + // DCA bachelor selection + if (std::fabs(casc.dcabachtopv()) < cascSelections.dcabachtopv) + return false; + // Bachelor-baryon cosPA selection + if (casc.bachBaryonCosPA() < cascSelections.bachbaryoncospa) + return false; + // DCA bachelor-baryon selection + if (std::fabs(casc.bachBaryonDCAxyToPV()) < cascSelections.dcaxybachbaryontopv) + return false; + // casc cosine of pointing angle + if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cascSelections.casccospa) + return false; + // DCA between casc daughters + if (casc.dcacascdaughters() > cascSelections.dcacascdau) + return false; + + // + // rapidity + // + if (std::fabs(rapidity) > cascSelections.rapidityCut) + return false; + + // + // competing mass rejection + // + if (analyseXi && std::fabs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) < cascSelections.compMassRejection) + return false; + if (analyseOmega && std::fabs(casc.mXi() - o2::constants::physics::MassXiMinus) < cascSelections.compMassRejection) + return false; + + auto bachTrackExtra = casc.template bachTrackExtra_as(); + auto posTrackExtra = casc.template posTrackExtra_as(); + auto negTrackExtra = casc.template negTrackExtra_as(); + + // + // ITS quality flags + // + if (bachTrackExtra.itsNCls() < cascSelections.minITSclusters) + return false; + if (posTrackExtra.itsNCls() < cascSelections.minITSclusters) + return false; + if (negTrackExtra.itsNCls() < cascSelections.minITSclusters) + return false; + + // + // TPC quality flags + // + if (bachTrackExtra.tpcCrossedRows() < cascSelections.minTPCrows) + return false; + if (posTrackExtra.tpcCrossedRows() < cascSelections.minTPCrows) + return false; + if (negTrackExtra.tpcCrossedRows() < cascSelections.minTPCrows) + return false; + + // + // TPC PID + // + if (analyseXi && std::fabs(bachTrackExtra.tpcNSigmaPi()) > cascSelections.tpcPidNsigmaCut) + return false; + if (analyseOmega && std::fabs(bachTrackExtra.tpcNSigmaKa()) > cascSelections.tpcPidNsigmaCut) + return false; + if (casc.sign() < 0) { // Xi- or Omega- --> positive/negative daughter = proton/pion + if (std::fabs(posTrackExtra.tpcNSigmaPr()) > cascSelections.tpcPidNsigmaCut) + return false; + if (std::fabs(negTrackExtra.tpcNSigmaPi()) > cascSelections.tpcPidNsigmaCut) + return false; + } else { // Xi+ or Omega+ --> positive/negative daughter = pion/proton + if (std::fabs(posTrackExtra.tpcNSigmaPi()) > cascSelections.tpcPidNsigmaCut) + return false; + if (std::fabs(negTrackExtra.tpcNSigmaPr()) > cascSelections.tpcPidNsigmaCut) + return false; + } + + // + // proper lifetime + float distOverTotMom = std::sqrt(std::pow(casc.x() - collision.posX(), 2) + std::pow(casc.y() - collision.posY(), 2) + std::pow(casc.z() - collision.posZ(), 2)) / (casc.p() + 1E-10); + if (analyseXi && distOverTotMom * o2::constants::physics::MassXiMinus / ctauXiPDG > cascSelections.cascProperLifeTime) + return false; + if (analyseOmega && distOverTotMom * o2::constants::physics::MassOmegaMinus / ctauOmegaPDG > cascSelections.cascProperLifeTime) + return false; + + return true; + } + + // ______________________________________________________ + // Real data processing - no MC subscription + void process(soa::Join::iterator const& collision, V0Candidates const& fullV0s, CascadeCandidates const& fullCascades, DauTracks const&) + { + // Fire up CCDB + if (cfgSkimmedProcessing) { + initCCDB(collision); + } + + if (!isEventAccepted(collision, true)) { + return; + } + + if (cfgSkimmedProcessing) { + zorro.isSelected(collision.globalBC()); /// Just let Zorro do the accounting + } + + float centrality = -1; + float occupancy = -1; + fillEventHistograms(collision, centrality, occupancy); + + // __________________________________________ + // perform main analysis + // + if (analyseK0Short || analyseLambda || analyseAntiLambda) { // Look at V0s + for (const auto& v0 : fullV0s) { + if (std::abs(v0.negativeeta()) > v0Selections.daughterEtaCut || std::abs(v0.positiveeta()) > v0Selections.daughterEtaCut) + continue; // remove acceptance that's badly reproduced by MC / superfluous in future + + if (v0.v0Type() != v0Selections.v0TypeSelection && v0Selections.v0TypeSelection > -1) + continue; // skip V0s that are not standard + + if (analyseK0Short && isV0Selected(v0, collision, v0.yK0Short())) { + histos.fill(HIST("h9dCentOccQoverPtMassRadiusPhiEtaPtArmV0AlphaV0"), centrality, occupancy, v0.pt(), v0.mK0Short(), v0.v0radius(), v0.phi(), v0.eta(), v0.qtarm(), v0.alpha()); + } + if (analyseLambda && isV0Selected(v0, collision, v0.yLambda())) { + histos.fill(HIST("h9dCentOccQoverPtMassRadiusPhiEtaPtArmV0AlphaV0"), centrality, occupancy, v0.pt(), v0.mLambda(), v0.v0radius(), v0.phi(), v0.eta(), v0.qtarm(), v0.alpha()); + } + if (analyseAntiLambda && isV0Selected(v0, collision, v0.yLambda())) { + histos.fill(HIST("h9dCentOccQoverPtMassRadiusPhiEtaPtArmV0AlphaV0"), centrality, occupancy, v0.pt(), v0.mAntiLambda(), v0.v0radius(), v0.phi(), v0.eta(), v0.qtarm(), v0.alpha()); + } + } // end v0 loop + } + + if (analyseXi || analyseOmega) { // Look at Cascades + for (const auto& cascade : fullCascades) { + if (std::abs(cascade.negativeeta()) > cascSelections.daughterEtaCut || + std::abs(cascade.positiveeta()) > cascSelections.daughterEtaCut || + std::abs(cascade.bacheloreta()) > cascSelections.daughterEtaCut) + continue; // remove acceptance that's badly reproduced by MC / superfluous in future + + if (analyseXi && isCascadeSelected(cascade, collision, cascade.yXi())) { + histos.fill(HIST("h9dCentOccQoverPtMassRadiusPhiEtaPtArmV0AlphaV0"), centrality, occupancy, cascade.pt(), cascade.m(1), cascade.cascradius(), cascade.phi(), cascade.eta(), 0., 0.); + } + if (analyseOmega && isCascadeSelected(cascade, collision, cascade.yOmega())) { + histos.fill(HIST("h9dCentOccQoverPtMassRadiusPhiEtaPtArmV0AlphaV0"), centrality, occupancy, cascade.pt(), cascade.m(2), cascade.cascradius(), cascade.phi(), cascade.eta(), 0., 0.); + } + } // end cascade loop + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Strangeness/taskLambdaSpinCorr.cxx b/PWGLF/Tasks/Strangeness/taskLambdaSpinCorr.cxx new file mode 100644 index 00000000000..be85c214406 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/taskLambdaSpinCorr.cxx @@ -0,0 +1,1358 @@ +// 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. + +/// \file taskLambdaSpinCorr.cxx +/// \brief Analysis task for Lambda spin spin correlation +/// +/// \author prottay.das@cern.ch +/// \author sourav.kundu@cern.ch + +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGMM/Mult/DataModel/Index.h" // for Particles2Tracks table + +#include "Common/Core/TrackSelection.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/StepTHn.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "Math/GenVector/Boost.h" +#include "Math/Vector2D.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" + +#include + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; +using namespace o2::aod::rctsel; + +using dauTracks = soa::Join; +using v0Candidates = soa::Join; + +struct LfTaskLambdaSpinCorr { + + Service ccdb; + + struct : ConfigurableGroup { + Configurable requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"}; + Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; + Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; + Configurable cfgEvtRCTFlagCheckerLimitAcceptAsBad{"cfgEvtRCTFlagCheckerLimitAcceptAsBad", true, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"}; + } rctCut; + // mixing + Configurable cosCalculation{"cosCalculation", 0, "cos calculation"}; + Configurable mixingCombination{"mixingCombination", 0, "mixing Combination"}; + Configurable cfgCutOccupancy{"cfgCutOccupancy", 2000, "Occupancy cut"}; + ConfigurableAxis axisVertex{"axisVertex", {5, -10, 10}, "vertex axis for bin"}; + ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {8, 0, 80}, "multiplicity percentile for bin"}; + Configurable nMix{"nMix", 5, "number of event mixing"}; + Configurable ptMix{"ptMix", 1.0, "pt cut on mixing"}; + Configurable etaMix{"etaMix", 0.4, "eta cut on mixing"}; + Configurable phiMix{"phiMix", 0.2, "phi cut on mixing"}; + // fill output + Configurable additionalEvSel{"additionalEvSel", false, "additionalEvSel"}; + Configurable additionalEvSel3{"additionalEvSel3", false, "additionalEvSel3"}; + Configurable additionalEvSel4{"additionalEvSel4", false, "additionalEvSel4"}; + Configurable additionalEvSel5{"additionalEvSel5", false, "additionalEvSel5"}; + Configurable fillGEN{"fillGEN", false, "filling generated histograms"}; + Configurable fillQA{"fillQA", false, "filling QA histograms"}; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutCentralityMax{"cfgCutCentralityMax", 50.0f, "Accepted maximum Centrality"}; + Configurable cfgCutCentralityMin{"cfgCutCentralityMin", 30.0f, "Accepted minimum Centrality"}; + + // Configs for track + Configurable cfgCutPt{"cfgCutPt", 0.2, "Pt cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + // Configs for V0 + Configurable confV0PtMin{"confV0PtMin", 0.f, "Minimum transverse momentum of V0"}; + Configurable confV0PtMax{"confV0PtMax", 0.f, "Maximum transverse momentum of V0"}; + Configurable confV0Rap{"confV0Rap", 0.8f, "Rapidity range of V0"}; + Configurable confV0DCADaughMax{"confV0DCADaughMax", 0.2f, "Maximum DCA between the V0 daughters"}; + Configurable confV0CPAMin{"confV0CPAMin", 0.9998f, "Minimum CPA of V0"}; + Configurable confV0TranRadV0Min{"confV0TranRadV0Min", 1.5f, "Minimum transverse radius"}; + Configurable confV0TranRadV0Max{"confV0TranRadV0Max", 100.f, "Maximum transverse radius"}; + Configurable cMaxV0DCA{"cMaxV0DCA", 1.2, "Maximum V0 DCA to PV"}; + Configurable cMinV0DCAPr{"cMinV0DCAPr", 0.05, "Minimum V0 daughters DCA to PV for Pr"}; + Configurable cMinV0DCAPi{"cMinV0DCAPi", 0.05, "Minimum V0 daughters DCA to PV for Pi"}; + Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 20, "Maximum V0 life time"}; + + // config for V0 daughters + Configurable confDaughEta{"confDaughEta", 0.8f, "V0 Daugh sel: max eta"}; + Configurable cfgDaughPrPt{"cfgDaughPrPt", 0.4, "minimum daughter proton pt"}; + Configurable cfgDaughPiPt{"cfgDaughPiPt", 0.2, "minimum daughter pion pt"}; + Configurable confDaughTPCnclsMin{"confDaughTPCnclsMin", 50.f, "V0 Daugh sel: Min. nCls TPC"}; + Configurable confDaughDCAMin{"confDaughDCAMin", 0.08f, "V0 Daugh sel: Max. DCA Daugh to PV (cm)"}; + Configurable confDaughPIDCuts{"confDaughPIDCuts", 3, "PID selections for Lambda daughters"}; + + Configurable iMNbins{"iMNbins", 100, "Number of bins in invariant mass"}; + Configurable lbinIM{"lbinIM", 1.0, "lower bin value in IM histograms"}; + Configurable hbinIM{"hbinIM", 1.2, "higher bin value in IM histograms"}; + Configurable iMNbinspair{"iMNbinspair", 400, "Number of bins in invariant mass pair"}; + Configurable lbinIMpair{"lbinIMpair", 0.0, "lower bin value in IMpair histograms"}; + Configurable hbinIMpair{"hbinIMpair", 8.0, "higher bin value in IMpair histograms"}; + + ConfigurableAxis configcentAxis{"configcentAxis", {VARIABLE_WIDTH, 0.0, 10.0, 40.0, 80.0}, "Cent V0M"}; + ConfigurableAxis configthnAxisPt{"configthnAxisPt", {VARIABLE_WIDTH, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.5, 8.0, 10.0, 100.0}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis configthnAxisPol{"configthnAxisPol", {VARIABLE_WIDTH, -1.0, -0.6, -0.2, 0, 0.2, 0.4, 0.8}, "Pol"}; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + RCTFlagsChecker rctChecker; + void init(o2::framework::InitContext&) + { + rctChecker.init(rctCut.cfgEvtRCTFlagCheckerLabel, rctCut.cfgEvtRCTFlagCheckerZDCCheck, rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad); + AxisSpec thnAxisInvMass{iMNbins, lbinIM, hbinIM, "#it{M} (GeV/#it{c}^{2})"}; + AxisSpec thnAxisInvMasspair{iMNbinspair, lbinIMpair, hbinIMpair, "#it{M} (GeV/#it{c}^{2})"}; + histos.add("hEvtSelInfo", "hEvtSelInfo", kTH1F, {{10, 0, 10.0}}); + histos.add("hPtDiff", "hPtDiff", kTH1F, {{1000, 0, 100.0}}); + histos.add("hPhiDiff", "hPhiDiff", kTH1F, {{800, -8.0, 8.0}}); + histos.add("hRDiff", "hRDiff", kTH1F, {{640, -16.0, 16.0}}); + histos.add("hv0Mult", "hv0Mult", kTH1F, {{10001, -0.5, 10000.5}}); + histos.add("hCentrality", "Centrality distribution", kTH1F, {{configcentAxis}}); + histos.add("hSparseLambdaLambda", "hSparseLambdaLambda", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseLambdaAntiLambda", "hSparseLambdaAntiLambda", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseAntiLambdaAntiLambda", "hSparseAntiLambdaAntiLambda", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + + histos.add("hSparseLambdaLambdaMixed", "hSparseLambdaLambdaMixed", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseLambdaAntiLambdaMixed", "hSparseLambdaAntiLambdaMixed", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseAntiLambdaAntiLambdaMixed", "hSparseAntiLambdaAntiLambdaMixed", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + + if (fillQA) { + ///////// along quantization axes/////////// + histos.add("hSparseLambdaLambdaQA", "hSparseLambdaLambdaQA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseLambdaAntiLambdaQA", "hSparseLambdaAntiLambdaQA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseAntiLambdaAntiLambdaQA", "hSparseAntiLambdaAntiLambdaQA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + } + if (fillGEN) { + histos.add("hSparseLambdaLambdaMC", "hSparseLambdaLambdaMC", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseLambdaAntiLambdaMC", "hSparseLambdaAntiLambdaMC", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseAntiLambdaAntiLambdaMC", "hSparseAntiLambdaAntiLambdaMC", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + if (fillQA) { + histos.add("hSparseLambdaLambdaMCQA", "hSparseLambdaLambdaMCQA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseLambdaAntiLambdaMCQA", "hSparseLambdaAntiLambdaMCQA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + histos.add("hSparseAntiLambdaAntiLambdaMCQA", "hSparseAntiLambdaAntiLambdaMCQA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisInvMass, configthnAxisPol, configcentAxis, thnAxisInvMasspair}, true); + } + } + } + + template + bool selectionV0(Collision const& collision, V0 const& candidate) + { + if (std::abs(candidate.dcav0topv()) > cMaxV0DCA) { + return false; + } + const float pT = candidate.pt(); + const float tranRad = candidate.v0radius(); + const float dcaDaughv0 = std::abs(candidate.dcaV0daughters()); + const float cpav0 = candidate.v0cosPA(); + + float ctauLambda = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * (o2::constants::physics::MassLambda); + + if (pT < confV0PtMin) { + return false; + } + if (pT > confV0PtMax) { + return false; + } + if (dcaDaughv0 > confV0DCADaughMax) { + return false; + } + if (cpav0 < confV0CPAMin) { + return false; + } + if (tranRad < confV0TranRadV0Min) { + return false; + } + if (tranRad > confV0TranRadV0Max) { + return false; + } + if (std::abs(ctauLambda) > cMaxV0LifeTime) { + return false; + } + if (std::abs(candidate.yLambda()) > confV0Rap) { + return false; + } + return true; + } + + template + bool isSelectedV0Daughter(V0 const& candidate, T const& track, int pid) + { + const auto tpcNClsF = track.tpcNClsFound(); + const auto ncr = 70; + const auto ncrfc = 0.8; + + if (track.tpcNClsCrossedRows() < ncr) { + return false; + } + if (tpcNClsF < confDaughTPCnclsMin) { + return false; + } + if (track.tpcCrossedRowsOverFindableCls() < ncrfc) { + return false; + } + + if (pid == 0 && std::abs(track.tpcNSigmaPr()) > confDaughPIDCuts) { + return false; + } + if (pid == 1 && std::abs(track.tpcNSigmaPi()) > confDaughPIDCuts) { + return false; + } + if (pid == 0 && (candidate.positivept() < cfgDaughPrPt || candidate.negativept() < cfgDaughPiPt)) { + return false; + } + if (pid == 1 && (candidate.positivept() < cfgDaughPiPt || candidate.negativept() < cfgDaughPrPt)) { + return false; + } + if (std::abs(candidate.positiveeta()) > confDaughEta || std::abs(candidate.negativeeta()) > confDaughEta) { + return false; + } + + if (pid == 0 && (std::abs(candidate.dcapostopv()) < cMinV0DCAPr || std::abs(candidate.dcanegtopv()) < cMinV0DCAPi)) { + return false; + } + if (pid == 1 && (std::abs(candidate.dcapostopv()) < cMinV0DCAPi || std::abs(candidate.dcanegtopv()) < cMinV0DCAPr)) { + return false; + } + + return true; + } + + bool shouldReject(bool lambdaTag, bool aLambdaTag, + const ROOT::Math::PxPyPzMVector& Lambdadummy, + const ROOT::Math::PxPyPzMVector& AntiLambdadummy) + { + const double minMass = 1.09; + const double maxMass = 1.14; + return (lambdaTag && aLambdaTag && + (Lambdadummy.M() > minMass && Lambdadummy.M() < maxMass) && + (AntiLambdadummy.M() > minMass && AntiLambdadummy.M() < maxMass)); + } + + void fillHistograms(bool tag1, bool tag2, bool tag3, bool tag4, + const ROOT::Math::PxPyPzMVector& particle1, const ROOT::Math::PxPyPzMVector& particle2, + const ROOT::Math::PxPyPzMVector& daughpart1, const ROOT::Math::PxPyPzMVector& daughpart2, + double centrality, int datatype) + { + + // auto particle1Dummy = ROOT::Math::PxPyPzMVector(particle1.Px(), particle1.Py(), particle1.Pz(), 1.115683); + // auto particle2Dummy = ROOT::Math::PxPyPzMVector(particle2.Px(), particle2.Py(), particle2.Pz(), 1.115683); + auto particle1Dummy = ROOT::Math::PxPyPzMVector(particle1.Px(), particle1.Py(), particle1.Pz(), particle1.M()); + auto particle2Dummy = ROOT::Math::PxPyPzMVector(particle2.Px(), particle2.Py(), particle2.Pz(), particle2.M()); + auto pairDummy = particle1Dummy + particle2Dummy; + + // auto pairParticle = particle1 + particle2; + + ROOT::Math::Boost boostPairToCM{pairDummy.BoostToCM()}; // boosting vector for pair CM + // Boosting both Lambdas to Lambda-Lambda pair rest frame + auto lambda1CM = boostPairToCM(particle1Dummy); + auto lambda2CM = boostPairToCM(particle2Dummy); + + // Step 2: Boost Each Lambda to its Own Rest Frame + ROOT::Math::Boost boostLambda1ToCM{lambda1CM.BoostToCM()}; + ROOT::Math::Boost boostLambda2ToCM{lambda2CM.BoostToCM()}; + + // Also boost the daughter protons to the same frame + auto proton1pairCM = boostPairToCM(daughpart1); // proton1 to pair CM + auto proton2pairCM = boostPairToCM(daughpart2); // proton2 to pair CM + + // Boost protons into their respective Lambda rest frames + auto proton1LambdaRF = boostLambda1ToCM(proton1pairCM); + auto proton2LambdaRF = boostLambda2ToCM(proton2pairCM); + + auto cosThetaDiff = -999.0; + if (cosCalculation == 0) { + cosThetaDiff = proton1LambdaRF.Vect().Unit().Dot(proton2LambdaRF.Vect().Unit()); + } + + if (cosCalculation == 1) { + ROOT::Math::XYZVector quantizationAxis = lambda1CM.Vect().Unit(); + double cosTheta1 = proton1LambdaRF.Vect().Unit().Dot(quantizationAxis); + double cosTheta2 = proton2LambdaRF.Vect().Unit().Dot(quantizationAxis); + cosThetaDiff = cosTheta1 * cosTheta2; + } + double deltaPhi = RecoDecay::constrainAngle(particle1.Phi() - particle2.Phi(), 0.0); + double deltaR = TMath::Sqrt(TMath::Power(particle1.Eta() - particle2.Eta(), 2.0) + TMath::Power(deltaPhi, 2.0)); + if (datatype == 0) { + if (tag1 && tag3) { + histos.fill(HIST("hSparseLambdaLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR); + } + if (tag2 && tag4) { + histos.fill(HIST("hSparseAntiLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR); + } + if (tag1 && tag4) { + histos.fill(HIST("hSparseLambdaAntiLambda"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR); + } + if (tag2 && tag3) { + histos.fill(HIST("hSparseLambdaAntiLambda"), particle2.M(), particle1.M(), cosThetaDiff, centrality, deltaR); + } + } + + if (datatype == 1) { + if (tag1 && tag3) { + histos.fill(HIST("hSparseLambdaLambdaMC"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR); + } + if (tag2 && tag4) { + histos.fill(HIST("hSparseAntiLambdaAntiLambdaMC"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR); + } + if (tag1 && tag4) { + histos.fill(HIST("hSparseLambdaAntiLambdaMC"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR); + } + if (tag2 && tag3) { + histos.fill(HIST("hSparseLambdaAntiLambdaMC"), particle2.M(), particle1.M(), cosThetaDiff, centrality, deltaR); + } + } + + if (datatype == 2) { + if (tag1 && tag3) { + histos.fill(HIST("hSparseLambdaLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR); + } + if (tag2 && tag4) { + histos.fill(HIST("hSparseAntiLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR); + } + if (tag1 && tag4) { + histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle1.M(), particle2.M(), cosThetaDiff, centrality, deltaR); + } + if (tag2 && tag3) { + histos.fill(HIST("hSparseLambdaAntiLambdaMixed"), particle2.M(), particle1.M(), cosThetaDiff, centrality, deltaR); + } + } + } + + std::tuple getLambdaTags(const auto& v0, const auto& collision) + { + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + + int lambdaTag = 0; + int aLambdaTag = 0; + + const auto signpos = postrack.sign(); + const auto signneg = negtrack.sign(); + + if (signpos < 0 || signneg > 0) { + return {0, 0, false}; // Invalid candidate + } + + if (isSelectedV0Daughter(v0, postrack, 0) && isSelectedV0Daughter(v0, negtrack, 1)) { + lambdaTag = 1; + } + if (isSelectedV0Daughter(v0, negtrack, 0) && isSelectedV0Daughter(v0, postrack, 1)) { + aLambdaTag = 1; + } + + if (!lambdaTag && !aLambdaTag) { + return {0, 0, false}; // No valid tags + } + + if (!selectionV0(collision, v0)) { + return {0, 0, false}; // Fails selection + } + + return {lambdaTag, aLambdaTag, true}; // Valid candidate + } + + std::tuple getLambdaTagsDD(const auto& v0, const auto& collision) + { + auto postrack = v0.template posTrackExtra_as(); + auto negtrack = v0.template negTrackExtra_as(); + + int lambdaTag = 0; + int aLambdaTag = 0; + + if (isSelectedV0Daughter(v0, postrack, 0) && isSelectedV0Daughter(v0, negtrack, 1)) { + lambdaTag = 1; + } + if (isSelectedV0Daughter(v0, negtrack, 0) && isSelectedV0Daughter(v0, postrack, 1)) { + aLambdaTag = 1; + } + + if (!lambdaTag && !aLambdaTag) { + return {0, 0, false}; // No valid tags + } + + if (!selectionV0(collision, v0)) { + return {0, 0, false}; // Fails selection + } + + return {lambdaTag, aLambdaTag, true}; // Valid candidate + } + + std::tuple getLambdaTagsMC(const auto& v0, const auto& collision) + { + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + + int lambdaTag = 0; + int aLambdaTag = 0; + + const auto signpos = postrack.sign(); + const auto signneg = negtrack.sign(); + + if (signpos < 0 || signneg > 0) { + return {0, 0, false}; // Invalid candidate + } + + if (isSelectedV0Daughter(v0, postrack, 0) && isSelectedV0Daughter(v0, negtrack, 1)) { + lambdaTag = 1; + } + if (isSelectedV0Daughter(v0, negtrack, 0) && isSelectedV0Daughter(v0, postrack, 1)) { + aLambdaTag = 1; + } + + if (!lambdaTag && !aLambdaTag) { + return {0, 0, false}; // No valid tags + } + + if (!selectionV0(collision, v0)) { + return {0, 0, false}; // Fails selection + } + + const auto netav = 0.8; + if (std::abs(v0.eta()) > netav) { + return {0, 0, false}; // Fails selection + } + + return {lambdaTag, aLambdaTag, true}; // Valid candidate + } + ROOT::Math::PxPyPzMVector lambda0, antiLambda0, proton0, pion0, antiProton0, antiPion0; + ROOT::Math::PxPyPzMVector lambda, antiLambda, proton, pion, antiProton, antiPion; + ROOT::Math::PxPyPzMVector lambda2, antiLambda2, proton2, pion2, antiProton2, antiPion2; + ROOT::Math::PxPyPzMVector lambdamc, antiLambdamc, protonmc, pionmc, antiProtonmc, antiPionmc; + ROOT::Math::PxPyPzMVector lambda2mc, antiLambda2mc, proton2mc, pion2mc, antiProton2mc, antiPion2mc; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + Filter centralityFilter = (nabs(aod::cent::centFT0C) < cfgCutCentralityMax && nabs(aod::cent::centFT0C) > cfgCutCentralityMin); + // Filter acceptanceFilter = (nabs(aod::track::eta) < cfgCutEta && nabs(aod::track::pt) > cfgCutPt); + + // using EventCandidates = soa::Filtered>; + using EventCandidates = soa::Filtered>; + using AllTrackCandidates = soa::Join; + using ResoV0s = aod::V0Datas; + + void processData(EventCandidates::iterator const& collision, AllTrackCandidates const& /*tracks*/, ResoV0s const& V0s) + { + histos.fill(HIST("hEvtSelInfo"), 0.5); + if (rctCut.requireRCTFlagChecker && !rctChecker(collision)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 1.5); + if (!collision.sel8()) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 2.5); + auto centrality = collision.centFT0C(); + int occupancy = collision.trackOccupancyInTimeRange(); + if (additionalEvSel && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 3.5); + if (additionalEvSel3 && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 4.5); + if (additionalEvSel4 && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 5.5); + if (additionalEvSel5 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 6.5); + if (occupancy > cfgCutOccupancy) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 7.5); + histos.fill(HIST("hCentrality"), centrality); + for (const auto& v0 : V0s) { + auto [lambdaTag, aLambdaTag, isValid] = getLambdaTags(v0, collision); + if (!isValid) { + continue; + } + if (lambdaTag && aLambdaTag) { + continue; + } + if (lambdaTag) { + proton = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassProton); + antiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassPionCharged); + lambda = proton + antiPion; + } + if (aLambdaTag) { + antiProton = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassProton); + pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda = antiProton + pion; + } + if (lambdaTag && (lambda.M() < lbinIM || lambda.M() > hbinIM)) { + continue; + } + if (aLambdaTag && (antiLambda.M() < lbinIM || antiLambda.M() > hbinIM)) { + continue; + } + auto postrack1 = v0.template posTrack_as(); + auto negtrack1 = v0.template negTrack_as(); + + // 2nd loop for combination of lambda lambda + for (const auto& v02 : V0s) { + if (v02.index() <= v0.index()) { + continue; + } + auto [lambdaTag2, aLambdaTag2, isValid2] = getLambdaTags(v02, collision); + if (!isValid2) { + continue; + } + if (lambdaTag2 && aLambdaTag2) { + continue; + } + if (lambdaTag2) { + proton2 = ROOT::Math::PxPyPzMVector(v02.pxpos(), v02.pypos(), v02.pzpos(), o2::constants::physics::MassProton); + antiPion2 = ROOT::Math::PxPyPzMVector(v02.pxneg(), v02.pyneg(), v02.pzneg(), o2::constants::physics::MassPionCharged); + lambda2 = proton2 + antiPion2; + } + if (aLambdaTag2) { + antiProton2 = ROOT::Math::PxPyPzMVector(v02.pxneg(), v02.pyneg(), v02.pzneg(), o2::constants::physics::MassProton); + pion2 = ROOT::Math::PxPyPzMVector(v02.pxpos(), v02.pypos(), v02.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda2 = antiProton2 + pion2; + } + if (lambdaTag2 && (lambda2.M() < lbinIM || lambda2.M() > hbinIM)) { + continue; + } + if (aLambdaTag2 && (antiLambda2.M() < lbinIM || antiLambda2.M() > hbinIM)) { + continue; + } + auto postrack2 = v02.template posTrack_as(); + auto negtrack2 = v02.template negTrack_as(); + if (postrack1.globalIndex() == postrack2.globalIndex() || negtrack1.globalIndex() == negtrack2.globalIndex()) { + continue; + } + if (lambdaTag && lambdaTag2) { + fillHistograms(1, 0, 1, 0, lambda, lambda2, proton, proton2, centrality, 0); + } + if (aLambdaTag && aLambdaTag2) { + fillHistograms(0, 1, 0, 1, antiLambda, antiLambda2, antiProton, antiProton2, centrality, 0); + } + if (lambdaTag && aLambdaTag2) { + fillHistograms(1, 0, 0, 1, lambda, antiLambda2, proton, antiProton2, centrality, 0); + } + if (aLambdaTag && lambdaTag2) { + fillHistograms(0, 1, 1, 0, antiLambda, lambda2, antiProton, proton2, centrality, 0); + } + } + } + } + PROCESS_SWITCH(LfTaskLambdaSpinCorr, processData, "Process data", false); + + // Processing Event Mixing + SliceCache cache; + using BinningType = ColumnBinningPolicy; + BinningType colBinning{{axisVertex, axisMultiplicityClass}, true}; + Preslice tracksPerCollisionV0 = aod::v0data::collisionId; + void processME(EventCandidates const& collisions, AllTrackCandidates const&, ResoV0s const& V0s) + { + for (auto& [collision1, collision2] : selfCombinations(colBinning, nMix, -1, collisions, collisions)) { + // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.index(), collision2.index()); + if (rctCut.requireRCTFlagChecker && !rctChecker(collision1)) { + continue; + } + if (rctCut.requireRCTFlagChecker && !rctChecker(collision2)) { + continue; + } + int occupancy1 = collision1.trackOccupancyInTimeRange(); + int occupancy2 = collision2.trackOccupancyInTimeRange(); + + if (collision1.index() == collision2.index()) { + continue; + } + if (!collision1.sel8() || !collision2.sel8()) { + continue; + } + if (additionalEvSel && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (occupancy1 > cfgCutOccupancy) { + continue; + } + if (additionalEvSel && (!collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (occupancy2 > cfgCutOccupancy) { + continue; + } + + if (additionalEvSel3 && (!collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel4 && !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvSel5 && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + + if (additionalEvSel3 && (!collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel4 && !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvSel5 && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + + auto centrality = collision1.centFT0C(); + auto groupV01 = V0s.sliceBy(tracksPerCollisionV0, collision1.globalIndex()); + auto groupV02 = V0s.sliceBy(tracksPerCollisionV0, collision1.globalIndex()); + auto groupV03 = V0s.sliceBy(tracksPerCollisionV0, collision2.globalIndex()); + // for (auto& [t1, t2, t3] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(groupV01, groupV02, groupV03))) { + // LOGF(info, "Mixed event collisions: (%d, %d, %d)", t1.collisionId(),t2.collisionId(),t3.collisionId()); + + // auto maxV0Size = 1400; + // if (groupV01.size() > maxV0Size || groupV02.size() > maxV0Size || groupV03.size() > maxV0Size) { + // continue; + // } + // bool pairStatus[1500][1500] = {{false}}; + + size_t rows = groupV03.size() + 20; + size_t cols = groupV01.size() + 20; + std::vector> pairStatus(rows, std::vector(cols, false)); + histos.fill(HIST("hv0Mult"), groupV01.size()); + for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(groupV01, groupV02))) { + bool pairfound = false; + if (t2.index() <= t1.index()) { + continue; + } + if (t1.collisionId() != t2.collisionId()) { + continue; + } + + auto [lambdaTag1, aLambdaTag1, isValid1] = getLambdaTags(t1, collision1); + auto [lambdaTag2, aLambdaTag2, isValid2] = getLambdaTags(t2, collision1); + if (!isValid1) { + continue; + } + if (!isValid2) { + continue; + } + if (lambdaTag1 && aLambdaTag1) { + continue; + } + if (lambdaTag2 && aLambdaTag2) { + continue; + } + auto postrack1 = t1.template posTrack_as(); + auto negtrack1 = t1.template negTrack_as(); + auto postrack2 = t2.template posTrack_as(); + auto negtrack2 = t2.template negTrack_as(); + if (postrack1.globalIndex() == postrack2.globalIndex() || negtrack1.globalIndex() == negtrack2.globalIndex()) { + continue; + } + // auto samePairSumPt = t1.pt() + t2.pt(); + double deltaPhiSame = RecoDecay::constrainAngle(t1.phi() - t2.phi(), 0.0); + auto samePairR = TMath::Sqrt(TMath::Power(deltaPhiSame, 2.0) + TMath::Power(t1.eta() - t2.eta(), 2.0)); + + if (lambdaTag1) { + proton0 = ROOT::Math::PxPyPzMVector(t1.pxpos(), t1.pypos(), t1.pzpos(), o2::constants::physics::MassProton); + antiPion0 = ROOT::Math::PxPyPzMVector(t1.pxneg(), t1.pyneg(), t1.pzneg(), o2::constants::physics::MassPionCharged); + lambda0 = proton0 + antiPion0; + } + if (aLambdaTag1) { + antiProton0 = ROOT::Math::PxPyPzMVector(t1.pxneg(), t1.pyneg(), t1.pzneg(), o2::constants::physics::MassProton); + pion0 = ROOT::Math::PxPyPzMVector(t1.pxpos(), t1.pypos(), t1.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda0 = antiProton0 + pion0; + } + if (lambdaTag1 && (lambda0.M() < lbinIM || lambda0.M() > hbinIM)) { + continue; + } + if (aLambdaTag1 && (antiLambda0.M() < lbinIM || antiLambda0.M() > hbinIM)) { + continue; + } + if (lambdaTag2) { + proton = ROOT::Math::PxPyPzMVector(t2.pxpos(), t2.pypos(), t2.pzpos(), o2::constants::physics::MassProton); + antiPion = ROOT::Math::PxPyPzMVector(t2.pxneg(), t2.pyneg(), t2.pzneg(), o2::constants::physics::MassPionCharged); + lambda = proton + antiPion; + } + if (aLambdaTag2) { + antiProton = ROOT::Math::PxPyPzMVector(t2.pxneg(), t2.pyneg(), t2.pzneg(), o2::constants::physics::MassProton); + pion = ROOT::Math::PxPyPzMVector(t2.pxpos(), t2.pypos(), t2.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda = antiProton + pion; + } + if (lambdaTag2 && (lambda.M() < lbinIM || lambda.M() > hbinIM)) { + continue; + } + if (aLambdaTag2 && (antiLambda.M() < lbinIM || antiLambda.M() > hbinIM)) { + continue; + } + for (const auto& t3 : groupV03) { + // if (pairStatus[t3.index()][t2.index()]) { + // LOGF(info, "repeat match found v0 id: (%d, %d)", t3.index(), t2.index()); + // continue; + // } + if (pairStatus[t3.index()][t2.index()]) { + continue; + } + if (t1.collisionId() == t3.collisionId()) { + continue; + } + auto [lambdaTag3, aLambdaTag3, isValid3] = getLambdaTags(t3, collision2); + if (!isValid3) { + continue; + } + if (lambdaTag3 && aLambdaTag3) { + continue; + } + if (lambdaTag1 != lambdaTag3 || aLambdaTag1 != aLambdaTag3) { + continue; + } + + if (lambdaTag3) { + proton2 = ROOT::Math::PxPyPzMVector(t3.pxpos(), t3.pypos(), t3.pzpos(), o2::constants::physics::MassProton); + antiPion2 = ROOT::Math::PxPyPzMVector(t3.pxneg(), t3.pyneg(), t3.pzneg(), o2::constants::physics::MassPionCharged); + lambda2 = proton2 + antiPion2; + } + if (aLambdaTag3) { + antiProton2 = ROOT::Math::PxPyPzMVector(t3.pxneg(), t3.pyneg(), t3.pzneg(), o2::constants::physics::MassProton); + pion2 = ROOT::Math::PxPyPzMVector(t3.pxpos(), t3.pypos(), t3.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda2 = antiProton2 + pion2; + } + if (lambdaTag3 && (lambda2.M() < lbinIM || lambda2.M() > hbinIM)) { + continue; + } + if (aLambdaTag3 && (antiLambda2.M() < lbinIM || antiLambda2.M() > hbinIM)) { + continue; + } + double deltaPhiMix = RecoDecay::constrainAngle(t3.phi() - t2.phi(), 0.0); + auto mixPairR = TMath::Sqrt(TMath::Power(deltaPhiMix, 2.0) + TMath::Power(t3.eta() - t2.eta(), 2.0)); + auto etaDiff = t1.eta() - t3.eta(); + auto phiDiff = RecoDecay::constrainAngle(t1.phi() - t3.phi(), 0.0); + + histos.fill(HIST("hPtDiff"), t1.pt() - t3.pt()); + histos.fill(HIST("hPhiDiff"), phiDiff); + histos.fill(HIST("hRDiff"), etaDiff); + + if (mixingCombination == 0 && std::abs(t1.pt() - t3.pt()) > ptMix) { + continue; + } + if (mixingCombination == 0 && t1.eta() * t3.eta() > 0 && std::abs(etaDiff) > etaMix) { + continue; + } + if (mixingCombination == 0 && phiDiff > phiMix) { + continue; + } + + if (mixingCombination == 1 && std::abs(t1.pt() - t3.pt()) > ptMix) { + continue; + } + if (mixingCombination == 1 && std::abs(mixPairR - samePairR) > etaMix) { + continue; + } + + if (lambdaTag2 && lambdaTag3) { + fillHistograms(1, 0, 1, 0, lambda, lambda2, proton, proton2, centrality, 2); + } else if (aLambdaTag2 && aLambdaTag3) { + fillHistograms(0, 1, 0, 1, antiLambda, antiLambda2, antiProton, antiProton2, centrality, 2); + } else if (lambdaTag2 && aLambdaTag3) { + fillHistograms(1, 0, 0, 1, lambda, antiLambda2, proton, antiProton2, centrality, 2); + } else if (aLambdaTag2 && lambdaTag3) { + fillHistograms(0, 1, 1, 0, antiLambda, lambda2, antiProton, proton2, centrality, 2); + } else { + continue; + } + pairfound = true; + pairStatus[t3.index()][t2.index()] = true; + // LOGF(info, "v0 id: (%d, %d)", t3.index(), t2.index()); + if (pairfound) { + // LOGF(info, "Pair found"); + break; + } + } + } + } + } + PROCESS_SWITCH(LfTaskLambdaSpinCorr, processME, "Process data ME", true); + + Filter v0der = (nabs(aod::v0data::dcapostopv) > cMinV0DCAPr && nabs(aod::v0data::dcanegtopv) > cMinV0DCAPi && nabs(aod::v0data::dcaV0daughters) < confV0DCADaughMax); + using v0Cand = soa::Filtered; + + // void processDerivedData(soa::Join::iterator const& collision, v0Candidates const& V0s, dauTracks const&) + void processDerivedData(soa::Join::iterator const& collision, v0Cand const& V0s, dauTracks const&) + { + histos.fill(HIST("hEvtSelInfo"), 0.5); + if (rctCut.requireRCTFlagChecker && !rctChecker(collision)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 1.5); + if (!collision.sel8()) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 2.5); + auto centrality = collision.centFT0C(); + int occupancy = collision.trackOccupancyInTimeRange(); + if (additionalEvSel && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 3.5); + if (additionalEvSel3 && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 4.5); + if (additionalEvSel4 && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 5.5); + if (additionalEvSel5 && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 6.5); + if (occupancy > cfgCutOccupancy) { + return; + } + histos.fill(HIST("hEvtSelInfo"), 7.5); + histos.fill(HIST("hCentrality"), centrality); + + for (const auto& v0 : V0s) { + auto [lambdaTag, aLambdaTag, isValid] = getLambdaTagsDD(v0, collision); + if (!isValid) { + continue; + } + + if (lambdaTag && aLambdaTag) { + continue; + } + + if (lambdaTag) { + proton = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassProton); + antiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassPionCharged); + lambda = proton + antiPion; + } + if (aLambdaTag) { + antiProton = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassProton); + pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda = antiProton + pion; + } + + if (lambdaTag && (lambda.M() < lbinIM || lambda.M() > hbinIM)) { + continue; + } + if (aLambdaTag && (antiLambda.M() < lbinIM || antiLambda.M() > hbinIM)) { + continue; + } + + // auto postrack1 = v0.template posTrackExtra_as(); + // auto negtrack1 = v0.template negTrackExtra_as(); + + // 2nd loop for combination of lambda lambda + for (const auto& v02 : V0s) { + if (v02.index() <= v0.index()) { + continue; + } + auto [lambdaTag2, aLambdaTag2, isValid2] = getLambdaTagsDD(v02, collision); + if (!isValid2) { + continue; + } + if (lambdaTag2 && aLambdaTag2) { + continue; + } + if (lambdaTag2) { + proton2 = ROOT::Math::PxPyPzMVector(v02.pxpos(), v02.pypos(), v02.pzpos(), o2::constants::physics::MassProton); + antiPion2 = ROOT::Math::PxPyPzMVector(v02.pxneg(), v02.pyneg(), v02.pzneg(), o2::constants::physics::MassPionCharged); + lambda2 = proton2 + antiPion2; + } + if (aLambdaTag2) { + antiProton2 = ROOT::Math::PxPyPzMVector(v02.pxneg(), v02.pyneg(), v02.pzneg(), o2::constants::physics::MassProton); + pion2 = ROOT::Math::PxPyPzMVector(v02.pxpos(), v02.pypos(), v02.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda2 = antiProton2 + pion2; + } + + if (lambdaTag2 && (lambda2.M() < lbinIM || lambda2.M() > hbinIM)) { + continue; + } + if (aLambdaTag2 && (antiLambda2.M() < lbinIM || antiLambda2.M() > hbinIM)) { + continue; + } + + // auto postrack2 = v02.template posTrackExtra_as(); + // auto negtrack2 = v02.template negTrackExtra_as(); + if (v0.posTrackExtraId() == v02.posTrackExtraId() || v0.negTrackExtraId() == v02.negTrackExtraId()) { + continue; + } + + if (lambdaTag && lambdaTag2) { + fillHistograms(1, 0, 1, 0, lambda, lambda2, proton, proton2, centrality, 0); + } + if (aLambdaTag && aLambdaTag2) { + fillHistograms(0, 1, 0, 1, antiLambda, antiLambda2, antiProton, antiProton2, centrality, 0); + } + if (lambdaTag && aLambdaTag2) { + fillHistograms(1, 0, 0, 1, lambda, antiLambda2, proton, antiProton2, centrality, 0); + } + if (aLambdaTag && lambdaTag2) { + fillHistograms(0, 1, 1, 0, antiLambda, lambda2, antiProton, proton2, centrality, 0); + } + } + } + } + PROCESS_SWITCH(LfTaskLambdaSpinCorr, processDerivedData, "Process derived data", true); + + // Preslice tracksPerCollisionV0Mixed = o2::aod::v0data::straCollisionId; // for derived data only + Preslice tracksPerCollisionV0Mixed = o2::aod::v0data::straCollisionId; // for derived data only + // void processDerivedDataMixed(soa::Join const& collisions, v0Candidates const& V0s, dauTracks const&) + void processDerivedDataMixed(soa::Join const& collisions, v0Cand const& V0s, dauTracks const&) + + { + + for (auto& [collision1, collision2] : selfCombinations(colBinning, nMix, -1, collisions, collisions)) { + // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.index(), collision2.index()); + if (rctCut.requireRCTFlagChecker && !rctChecker(collision1)) { + continue; + } + if (rctCut.requireRCTFlagChecker && !rctChecker(collision2)) { + continue; + } + int occupancy1 = collision1.trackOccupancyInTimeRange(); + int occupancy2 = collision2.trackOccupancyInTimeRange(); + + if (collision1.index() == collision2.index()) { + continue; + } + if (!collision1.sel8() || !collision2.sel8()) { + continue; + } + if (additionalEvSel && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (occupancy1 > cfgCutOccupancy) { + continue; + } + if (additionalEvSel && (!collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (occupancy2 > cfgCutOccupancy) { + continue; + } + if (additionalEvSel3 && (!collision1.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision1.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel4 && !collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvSel5 && !collision1.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + + if (additionalEvSel3 && (!collision2.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision2.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + continue; + } + if (additionalEvSel4 && !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + continue; + } + if (additionalEvSel5 && !collision2.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + continue; + } + auto centrality = collision1.centFT0C(); + // auto groupV01 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision1.globalIndex()); + // auto groupV02 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision1.globalIndex()); + // auto groupV03 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision2.globalIndex()); + auto groupV01 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision1.index()); + auto groupV02 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision1.index()); + auto groupV03 = V0s.sliceBy(tracksPerCollisionV0Mixed, collision2.index()); + + size_t rows = groupV03.size() + 1600; + size_t cols = groupV01.size() + 1600; + std::vector> pairStatus(rows, std::vector(cols, false)); + histos.fill(HIST("hv0Mult"), groupV01.size()); + for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(groupV01, groupV02))) { + bool pairfound = false; + if (t2.index() <= t1.index()) { + continue; + } + if (t1.straCollisionId() != t2.straCollisionId()) { + continue; + } + + auto [lambdaTag1, aLambdaTag1, isValid1] = getLambdaTagsDD(t1, collision1); + auto [lambdaTag2, aLambdaTag2, isValid2] = getLambdaTagsDD(t2, collision1); + if (!isValid1) { + continue; + } + if (!isValid2) { + continue; + } + if (lambdaTag1 && aLambdaTag1) { + continue; + } + if (lambdaTag2 && aLambdaTag2) { + continue; + } + // auto postrack1 = t1.template posTrackExtra_as(); + // auto negtrack1 = t1.template negTrackExtra_as(); + // auto postrack2 = t2.template posTrackExtra_as(); + // auto negtrack2 = t2.template negTrackExtra_as(); + if (t1.posTrackExtraId() == t2.posTrackExtraId() || t1.negTrackExtraId() == t2.negTrackExtraId()) { + continue; + } + // auto samePairSumPt = t1.pt() + t2.pt(); + // auto samePairR = TMath::Sqrt(TMath::Power(t1.phi() - t2.phi(), 2.0) + TMath::Power(t1.eta() - t2.eta(), 2.0)); + + double deltaPhiSame = RecoDecay::constrainAngle(t1.phi() - t2.phi(), 0.0); + auto samePairR = TMath::Sqrt(TMath::Power(deltaPhiSame, 2.0) + TMath::Power(t1.eta() - t2.eta(), 2.0)); + + if (lambdaTag1) { + proton0 = ROOT::Math::PxPyPzMVector(t1.pxpos(), t1.pypos(), t1.pzpos(), o2::constants::physics::MassProton); + antiPion0 = ROOT::Math::PxPyPzMVector(t1.pxneg(), t1.pyneg(), t1.pzneg(), o2::constants::physics::MassPionCharged); + lambda0 = proton0 + antiPion0; + } + if (aLambdaTag1) { + antiProton0 = ROOT::Math::PxPyPzMVector(t1.pxneg(), t1.pyneg(), t1.pzneg(), o2::constants::physics::MassProton); + pion0 = ROOT::Math::PxPyPzMVector(t1.pxpos(), t1.pypos(), t1.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda0 = antiProton0 + pion0; + } + if (lambdaTag1 && (lambda0.M() < lbinIM || lambda0.M() > hbinIM)) { + continue; + } + if (aLambdaTag1 && (antiLambda0.M() < lbinIM || antiLambda0.M() > hbinIM)) { + continue; + } + if (lambdaTag2) { + proton = ROOT::Math::PxPyPzMVector(t2.pxpos(), t2.pypos(), t2.pzpos(), o2::constants::physics::MassProton); + antiPion = ROOT::Math::PxPyPzMVector(t2.pxneg(), t2.pyneg(), t2.pzneg(), o2::constants::physics::MassPionCharged); + lambda = proton + antiPion; + } + if (aLambdaTag2) { + antiProton = ROOT::Math::PxPyPzMVector(t2.pxneg(), t2.pyneg(), t2.pzneg(), o2::constants::physics::MassProton); + pion = ROOT::Math::PxPyPzMVector(t2.pxpos(), t2.pypos(), t2.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda = antiProton + pion; + } + if (lambdaTag2 && (lambda.M() < lbinIM || lambda.M() > hbinIM)) { + continue; + } + if (aLambdaTag2 && (antiLambda.M() < lbinIM || antiLambda.M() > hbinIM)) { + continue; + } + + for (const auto& t3 : groupV03) { + if (pairStatus[t3.index()][t2.index()]) { + continue; + } + if (t1.straCollisionId() == t3.straCollisionId()) { + continue; + } + auto [lambdaTag3, aLambdaTag3, isValid3] = getLambdaTagsDD(t3, collision2); + if (!isValid3) { + continue; + } + if (lambdaTag3 && aLambdaTag3) { + continue; + } + if (lambdaTag1 != lambdaTag3 || aLambdaTag1 != aLambdaTag3) { + continue; + } + + if (lambdaTag3) { + proton2 = ROOT::Math::PxPyPzMVector(t3.pxpos(), t3.pypos(), t3.pzpos(), o2::constants::physics::MassProton); + antiPion2 = ROOT::Math::PxPyPzMVector(t3.pxneg(), t3.pyneg(), t3.pzneg(), o2::constants::physics::MassPionCharged); + lambda2 = proton2 + antiPion2; + } + if (aLambdaTag3) { + antiProton2 = ROOT::Math::PxPyPzMVector(t3.pxneg(), t3.pyneg(), t3.pzneg(), o2::constants::physics::MassProton); + pion2 = ROOT::Math::PxPyPzMVector(t3.pxpos(), t3.pypos(), t3.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda2 = antiProton2 + pion2; + } + if (lambdaTag3 && (lambda2.M() < lbinIM || lambda2.M() > hbinIM)) { + continue; + } + + if (aLambdaTag3 && (antiLambda2.M() < lbinIM || antiLambda2.M() > hbinIM)) { + continue; + } + + double deltaPhiMix = RecoDecay::constrainAngle(t3.phi() - t2.phi(), 0.0); + auto mixPairR = TMath::Sqrt(TMath::Power(deltaPhiMix, 2.0) + TMath::Power(t3.eta() - t2.eta(), 2.0)); + + auto etaDiff = t1.eta() - t3.eta(); + auto phiDiff = RecoDecay::constrainAngle(t1.phi() - t3.phi(), 0.0); + + histos.fill(HIST("hPtDiff"), t1.pt() - t3.pt()); + histos.fill(HIST("hPhiDiff"), phiDiff); + histos.fill(HIST("hRDiff"), etaDiff); + + if (mixingCombination == 0 && std::abs(t1.pt() - t3.pt()) > ptMix) { + continue; + } + if (mixingCombination == 0 && t1.eta() * t3.eta() > 0 && std::abs(etaDiff) > etaMix) { + continue; + } + if (mixingCombination == 0 && phiDiff > phiMix) { + continue; + } + if (mixingCombination == 1 && std::abs(t1.pt() - t3.pt()) > ptMix) { + continue; + } + if (mixingCombination == 1 && std::abs(mixPairR - samePairR) > etaMix) { + continue; + } + if (lambdaTag2 && lambdaTag3) { + fillHistograms(1, 0, 1, 0, lambda, lambda2, proton, proton2, centrality, 2); + } else if (aLambdaTag2 && aLambdaTag3) { + fillHistograms(0, 1, 0, 1, antiLambda, antiLambda2, antiProton, antiProton2, centrality, 2); + } else if (lambdaTag2 && aLambdaTag3) { + fillHistograms(1, 0, 0, 1, lambda, antiLambda2, proton, antiProton2, centrality, 2); + } else if (aLambdaTag2 && lambdaTag3) { + fillHistograms(0, 1, 1, 0, antiLambda, lambda2, antiProton, proton2, centrality, 2); + } else { + continue; + } + pairfound = true; + pairStatus[t3.index()][t2.index()] = true; + if (pairfound) { + break; + } + } + } + } + } + + PROCESS_SWITCH(LfTaskLambdaSpinCorr, processDerivedDataMixed, "Process mixed derived data", true); + + using CollisionMCRecTableCentFT0C = soa::Join; + using TrackMCRecTable = soa::Join; + using V0TrackCandidatesMC = soa::Join; + + void processMC(CollisionMCRecTableCentFT0C::iterator const& collision, TrackMCRecTable const& /*tracks*/, V0TrackCandidatesMC const& V0s) + { + + // for (const auto& RecCollis : collision) { + if (!collision.sel8()) { + return; + } + if (std::abs(collision.posZ()) > cfgCutVertex) { + return; + } + auto centrality = collision.centFT0C(); + histos.fill(HIST("hCentrality"), centrality); + for (const auto& v0 : V0s) { + auto [lambdaTag, aLambdaTag, isValid] = getLambdaTagsMC(v0, collision); + if (!isValid) { + continue; + } + if (lambdaTag) { + proton = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassProton); + antiPion = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassPionCharged); + lambda = proton + antiPion; + } + if (aLambdaTag) { + antiProton = ROOT::Math::PxPyPzMVector(v0.pxneg(), v0.pyneg(), v0.pzneg(), o2::constants::physics::MassProton); + pion = ROOT::Math::PxPyPzMVector(v0.pxpos(), v0.pypos(), v0.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda = antiProton + pion; + } + if (lambdaTag && aLambdaTag) { + continue; + } + auto postrack1 = v0.template posTrack_as(); + auto negtrack1 = v0.template negTrack_as(); + // 2nd loop for combination of lambda lambda + for (const auto& v02 : V0s) { + if (v02.index() <= v0.index()) { + continue; + } + auto [lambdaTag2, aLambdaTag2, isValid2] = getLambdaTagsMC(v02, collision); + if (!isValid2) { + continue; + } + if (lambdaTag2) { + proton2 = ROOT::Math::PxPyPzMVector(v02.pxpos(), v02.pypos(), v02.pzpos(), o2::constants::physics::MassProton); + antiPion2 = ROOT::Math::PxPyPzMVector(v02.pxneg(), v02.pyneg(), v02.pzneg(), o2::constants::physics::MassPionCharged); + lambda2 = proton2 + antiPion2; + } + if (aLambdaTag2) { + antiProton2 = ROOT::Math::PxPyPzMVector(v02.pxneg(), v02.pyneg(), v02.pzneg(), o2::constants::physics::MassProton); + pion2 = ROOT::Math::PxPyPzMVector(v02.pxpos(), v02.pypos(), v02.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda2 = antiProton2 + pion2; + } + if (lambdaTag && aLambdaTag) { + continue; + } + auto postrack2 = v02.template posTrack_as(); + auto negtrack2 = v02.template negTrack_as(); + if (postrack1.globalIndex() == postrack2.globalIndex() || negtrack1.globalIndex() == negtrack2.globalIndex()) { + continue; // no shared decay products + } + if (lambdaTag && lambdaTag2) { + fillHistograms(1, 0, 1, 0, lambda, lambda2, proton, proton2, centrality, 0); + } + if (aLambdaTag && aLambdaTag2) { + fillHistograms(0, 1, 0, 1, antiLambda, antiLambda2, antiProton, antiProton2, centrality, 0); + } + if (lambdaTag && aLambdaTag2) { + fillHistograms(1, 0, 0, 1, lambda, antiLambda2, proton, antiProton2, centrality, 0); + } + if (aLambdaTag && lambdaTag2) { + fillHistograms(0, 1, 1, 0, antiLambda, lambda2, antiProton, proton2, centrality, 0); + } + } + } + } + PROCESS_SWITCH(LfTaskLambdaSpinCorr, processMC, "Process montecarlo", false); + + // Processing Event Mixing MC + void processMEMC(CollisionMCRecTableCentFT0C const& collisions, TrackMCRecTable const&, V0TrackCandidatesMC const& V0s) + { + for (auto& [collision1, collision2] : selfCombinations(colBinning, nMix, -1, collisions, collisions)) { + // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.index(), collision2.index()); + + if (collision1.index() == collision2.index()) { + continue; + } + if (!collision1.sel8() || !collision2.sel8()) { + continue; + } + if (std::abs(collision1.posZ()) > cfgCutVertex) { + continue; + } + if (std::abs(collision2.posZ()) > cfgCutVertex) { + continue; + } + + auto centrality = collision1.centFT0C(); + auto groupV01 = V0s.sliceBy(tracksPerCollisionV0, collision1.globalIndex()); + auto groupV02 = V0s.sliceBy(tracksPerCollisionV0, collision1.globalIndex()); + auto groupV03 = V0s.sliceBy(tracksPerCollisionV0, collision2.globalIndex()); + // for (auto& [t1, t2, t3] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(groupV01, groupV02, groupV03))) { + // LOGF(info, "Mixed event collisions: (%d, %d, %d)", t1.collisionId(),t2.collisionId(),t3.collisionId()); + auto maxV0Size = 1100; + if (groupV01.size() > maxV0Size || groupV02.size() > maxV0Size || groupV03.size() > maxV0Size) { + continue; + } + bool pairStatus[1150][1150] = {{false}}; + for (auto& [t1, t2] : soa::combinations(o2::soa::CombinationsFullIndexPolicy(groupV01, groupV02))) { + bool pairfound = false; + if (t2.index() <= t1.index()) { + continue; + } + if (t1.collisionId() != t2.collisionId()) { + continue; + } + auto [lambdaTag1, aLambdaTag1, isValid1] = getLambdaTagsMC(t1, collision1); + auto [lambdaTag2, aLambdaTag2, isValid2] = getLambdaTagsMC(t2, collision1); + if (!isValid1) { + continue; + } + if (!isValid2) { + continue; + } + if (lambdaTag1 && aLambdaTag1) { + continue; + } + if (lambdaTag2 && aLambdaTag2) { + continue; + } + auto postrack1 = t1.template posTrack_as(); + auto negtrack1 = t1.template negTrack_as(); + auto postrack2 = t2.template posTrack_as(); + auto negtrack2 = t2.template negTrack_as(); + if (postrack1.globalIndex() == postrack2.globalIndex() || negtrack1.globalIndex() == negtrack2.globalIndex()) { + continue; + } + for (const auto& t3 : groupV03) { + if (pairStatus[t3.index()][t2.index()]) { + // LOGF(info, "repeat match found v0 id: (%d, %d)", t3.index(), t2.index()); + continue; + } + if (t1.collisionId() == t3.collisionId()) { + continue; + } + auto [lambdaTag3, aLambdaTag3, isValid3] = getLambdaTagsMC(t3, collision2); + if (!isValid3) { + continue; + } + if (lambdaTag3 && aLambdaTag3) { + continue; + } + if (lambdaTag1 != lambdaTag3 || aLambdaTag1 != aLambdaTag3) { + continue; + } + if (std::abs(t1.pt() - t3.pt()) > ptMix) { + continue; + } + if (std::abs(t1.eta() - t3.eta()) > etaMix) { + continue; + } + if (std::abs(t1.phi() - t3.phi()) > phiMix) { + continue; + } + if (lambdaTag2) { + proton = ROOT::Math::PxPyPzMVector(t2.pxpos(), t2.pypos(), t2.pzpos(), o2::constants::physics::MassProton); + antiPion = ROOT::Math::PxPyPzMVector(t2.pxneg(), t2.pyneg(), t2.pzneg(), o2::constants::physics::MassPionCharged); + lambda = proton + antiPion; + } + if (aLambdaTag2) { + antiProton = ROOT::Math::PxPyPzMVector(t2.pxneg(), t2.pyneg(), t2.pzneg(), o2::constants::physics::MassProton); + pion = ROOT::Math::PxPyPzMVector(t2.pxpos(), t2.pypos(), t2.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda = antiProton + pion; + } + if (lambdaTag3) { + proton2 = ROOT::Math::PxPyPzMVector(t3.pxpos(), t3.pypos(), t3.pzpos(), o2::constants::physics::MassProton); + antiPion2 = ROOT::Math::PxPyPzMVector(t3.pxneg(), t3.pyneg(), t3.pzneg(), o2::constants::physics::MassPionCharged); + lambda2 = proton2 + antiPion2; + } + if (aLambdaTag3) { + antiProton2 = ROOT::Math::PxPyPzMVector(t3.pxneg(), t3.pyneg(), t3.pzneg(), o2::constants::physics::MassProton); + pion2 = ROOT::Math::PxPyPzMVector(t3.pxpos(), t3.pypos(), t3.pzpos(), o2::constants::physics::MassPionCharged); + antiLambda2 = antiProton2 + pion2; + } + if (lambdaTag2 && lambdaTag3) { + fillHistograms(1, 0, 1, 0, lambda, lambda2, proton, proton2, centrality, 2); + } + if (aLambdaTag2 && aLambdaTag3) { + fillHistograms(0, 1, 0, 1, antiLambda, antiLambda2, antiProton, antiProton2, centrality, 2); + } + if (lambdaTag2 && aLambdaTag3) { + fillHistograms(1, 0, 0, 1, lambda, antiLambda2, proton, antiProton2, centrality, 2); + } + if (aLambdaTag2 && lambdaTag3) { + fillHistograms(0, 1, 1, 0, antiLambda, lambda2, antiProton, proton2, centrality, 2); + } + pairfound = true; + pairStatus[t3.index()][t2.index()] = true; + if (pairfound) { + // LOGF(info, "Pair found"); + break; + } + } + } + } + } + PROCESS_SWITCH(LfTaskLambdaSpinCorr, processMEMC, "Process MC ME", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Strangeness/v0postprocessing.cxx b/PWGLF/Tasks/Strangeness/v0postprocessing.cxx index d66f2814e1e..4f6ab094f46 100644 --- a/PWGLF/Tasks/Strangeness/v0postprocessing.cxx +++ b/PWGLF/Tasks/Strangeness/v0postprocessing.cxx @@ -26,11 +26,10 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using DauTracks = soa::Join; - struct v0postprocessing { Configurable radius{"radius", 0.5, "Radius"}; + Configurable maxradius{"maxradius", 100000, "Radius"}; Configurable dcanegtopv{"dcanegtopv", 0.05, "DCA Neg To PV"}; Configurable dcapostopv{"dcapostopv", 0.05, "DCA Pos To PV"}; Configurable cospaK0s{"cospaK0s", 0.97, "K0s CosPA"}; @@ -42,24 +41,74 @@ struct v0postprocessing { Configurable v0rejK0s{"v0rejK0s", 0.005, "V0 rej K0s"}; Configurable v0rejLambda{"v0rejLambda", 0.01, "V0 rej K0s"}; Configurable ntpcsigma{"ntpcsigma", 5, "N sigma TPC"}; - Configurable ntpcsigmaMC{"ntpcsigmaMC", 100, "N sigma TPC for MC"}; Configurable etadau{"etadau", 0.8, "Eta Daughters"}; + Configurable minITShits{"minITShits", 2, "min ITS hits"}; + Configurable min_TPC_nClusters{"min_TPC_nClusters", 80, "min_TPC_nClusters"}; + Configurable max_tpcSharedCls{"max_tpcSharedCls", 100, "max_tpcSharedCls"}; + Configurable max_chi2_ITS{"max_chi2_ITS", 36, "max_chi2_ITS"}; + Configurable max_chi2_TPC{"max_chi2_TPC", 4, "max_chi2_TPC"}; Configurable isMC{"isMC", 1, "isMC"}; Configurable evSel{"evSel", 1, "evSel"}; Configurable hasTOF2Leg{"hasTOF2Leg", 0, "hasTOF2Leg"}; - Configurable hasTOF1Leg{"hasTOF1Leg", 1, "hasTOF1Leg"}; + Configurable hasTOF1Leg{"hasTOF1Leg", 0, "hasTOF1Leg"}; Configurable paramArmenterosCut{"paramArmenterosCut", 0.2, "parameter Armenteros Cut"}; Configurable doArmenterosCut{"doArmenterosCut", 1, "do Armenteros Cut"}; + Configurable doQA{"doQA", 1, "fill QA histograms"}; HistogramRegistry registry{"registry"}; void init(InitContext const&) { + registry.add("hV0Cuts", ";Sel", {HistType::kTH1D, {{22, 0., 22.}}}); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(1, "all"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(2, "Event selection"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(3, "Radius"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(4, "Eta Daughters"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(5, "Dau DCA to PV"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(6, "DCA Daughters"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(7, "min ITS hits"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(8, "has TOF 1 Leg"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(9, "has TOF 2 Legs"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(10, "TPC NCl"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(11, "TPC Cls Shared"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(12, "ITS Chi2"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(13, "TPC Chi2"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(14, "cosPA K0s"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(15, "cosPA Lambda"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(16, "rapidity"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(17, "ctau K0s"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(18, "ctau Lambda"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(19, "v0 rej K0s"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(20, "v0 rej Lambda"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(21, "TPC nsigma Dau"); + registry.get(HIST("hV0Cuts"))->GetXaxis()->SetBinLabel(22, "Armenteros-Podolansky"); + + registry.get(HIST("hV0Cuts"))->SetBinContent(1, 1); + registry.get(HIST("hV0Cuts"))->SetBinContent(2, evSel); + registry.get(HIST("hV0Cuts"))->SetBinContent(3, radius); + registry.get(HIST("hV0Cuts"))->SetBinContent(4, etadau); + registry.get(HIST("hV0Cuts"))->SetBinContent(5, dcanegtopv); + registry.get(HIST("hV0Cuts"))->SetBinContent(6, dcav0dau); + registry.get(HIST("hV0Cuts"))->SetBinContent(7, minITShits); + registry.get(HIST("hV0Cuts"))->SetBinContent(8, hasTOF1Leg); + registry.get(HIST("hV0Cuts"))->SetBinContent(9, hasTOF2Leg); + registry.get(HIST("hV0Cuts"))->SetBinContent(10, min_TPC_nClusters); + registry.get(HIST("hV0Cuts"))->SetBinContent(11, max_tpcSharedCls); + registry.get(HIST("hV0Cuts"))->SetBinContent(12, max_chi2_ITS); + registry.get(HIST("hV0Cuts"))->SetBinContent(13, max_chi2_TPC); + registry.get(HIST("hV0Cuts"))->SetBinContent(14, cospaK0s); + registry.get(HIST("hV0Cuts"))->SetBinContent(15, cospaLambda); + registry.get(HIST("hV0Cuts"))->SetBinContent(16, rap); + registry.get(HIST("hV0Cuts"))->SetBinContent(17, ctauK0s); + registry.get(HIST("hV0Cuts"))->SetBinContent(18, ctauLambda); + registry.get(HIST("hV0Cuts"))->SetBinContent(19, v0rejK0s); + registry.get(HIST("hV0Cuts"))->SetBinContent(20, v0rejLambda); + registry.get(HIST("hV0Cuts"))->SetBinContent(21, ntpcsigma); + registry.get(HIST("hV0Cuts"))->SetBinContent(22, paramArmenterosCut * doArmenterosCut); registry.add("hMassK0Short", ";M_{#pi^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH1F, {{200, 0.4f, 0.6f}}}); registry.add("hMassVsPtK0Short", ";p_{T} [GeV/c];M_{#pi^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH2F, {{250, 0.0f, 25.0f}, {200, 0.4f, 0.6f}}}); registry.add("hMassVsPtK0ShortVsCentFT0M", ";p_{T} [GeV/c]; CentFT0M; M_{#pi^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {100, 0.f, 100.f}, {200, 0.4f, 0.6f}}}); - registry.add("hMassVsPtK0ShortVsCentFV0A", ";p_{T} [GeV/c]; CentFT0M; M_{#pi^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {100, 0.f, 100.f}, {200, 0.4f, 0.6f}}}); registry.add("hMassLambda", "hMassLambda", {HistType::kTH1F, {{200, 1.016f, 1.216f}}}); registry.add("hMassVsPtLambda", "hMassVsPtLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {200, 1.016f, 1.216f}}}); registry.add("hMassVsPtLambdaVsCentFT0M", ";p_{T} [GeV/c]; CentFT0M; M_{#pi^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {100, 0.f, 100.f}, {200, 1.016f, 1.216f}}}); @@ -69,250 +118,402 @@ struct v0postprocessing { if (isMC) { registry.add("hMassK0Short_MC", ";M_{#pi^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH1F, {{200, 0.4f, 0.6f}}}); - registry.add("hMassVsPtK0Short_MC", ";p_{T} [GeV/c];M_{#pi^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {100, 0.f, 100.f}, {200, 0.4f, 0.6f}}}); + registry.add("hMassVsPtK0ShortVsCentFT0M_MC", ";p_{T} [GeV/c];M_{#pi^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {100, 0.f, 100.f}, {200, 0.4f, 0.6f}}}); registry.add("hMassLambda_MC", "hMassLambda", {HistType::kTH1F, {{200, 1.016f, 1.216f}}}); - registry.add("hMassVsPtLambda_MC", ";p_{T} [GeV/c];M_{p^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {100, 0.f, 100.f}, {200, 1.016f, 1.216f}}}); + registry.add("hMassVsPtLambdaVsCentFT0M_MC", ";p_{T} [GeV/c];M_{p^{+}#pi^{-}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {100, 0.f, 100.f}, {200, 1.016f, 1.216f}}}); registry.add("hMassAntiLambda_MC", "hMassAntiLambda", {HistType::kTH1F, {{200, 1.016f, 1.216f}}}); - registry.add("hMassVsPtAntiLambda_MC", ";p_{T} [GeV/c];M_{p^{-}#pi^{+}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {100, 0.f, 100.f}, {200, 1.016f, 1.216f}}}); + registry.add("hMassVsPtLambdaVsMotherPt_DoubleCharged_MC", ";p_{T} [GeV/c] (V0);p_{T}^{gen} [GeV/c] (Xi);M_{p^{-}#pi^{+}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {250, 0.0f, 25.0f}, {200, 1.016f, 1.216f}}}); + registry.add("hMassVsPtLambdaVsMotherPt_MCRatio_MC", ";p_{T} [GeV/c] (V0);p_{T}^{gen} [GeV/c] (Xi);M_{p^{-}#pi^{+}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {250, 0.0f, 25.0f}, {200, 1.016f, 1.216f}}}); + registry.add("hMassVsPtAntiLambdaVsCentFT0M_MC", ";p_{T} [GeV/c];M_{p^{-}#pi^{+}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {100, 0.f, 100.f}, {200, 1.016f, 1.216f}}}); + registry.add("hMassVsPtAntiLambdaVsMotherPt_DoubleCharged_MC", ";p_{T} [GeV/c] (V0);p_{T}^{gen} [GeV/c] (Xi);M_{p^{-}#pi^{+}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {250, 0.0f, 25.0f}, {200, 1.016f, 1.216f}}}); + registry.add("hMassVsPtAntiLambdaVsMotherPt_MCRatio_MC", ";p_{T} [GeV/c] (V0);p_{T}^{gen} [GeV/c] (Xi);M_{p^{-}#pi^{+}} [GeV/c^{2}]", {HistType::kTH3F, {{250, 0.0f, 25.0f}, {250, 0.0f, 25.0f}, {200, 1.016f, 1.216f}}}); } - // QA - registry.add("hArmenterosPodolanski", "hArmenterosPodolanski", {HistType::kTH2F, {{1000, -1.0f, 1.0f, "#alpha"}, {1000, 0.0f, 0.30f, "#it{Q}_{T}"}}}); - registry.add("hArmenterosPodolanski_Sel", "hArmenterosPodolanski_Sel", {HistType::kTH2F, {{1000, -1.0f, 1.0f, "#alpha"}, {1000, 0.0f, 0.30f, "#it{Q}_{T}"}}}); - registry.add("hK0sV0Radius", "hK0sV0Radius", {HistType::kTH1D, {{200, 0.0f, 40.0f}}}); - registry.add("hK0sCosPA", "hK0sCosPA", {HistType::kTH1F, {{100, 0.9f, 1.0f}}}); - registry.add("hK0sV0DCANegToPV", "hK0sV0DCANegToPV", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}); - registry.add("hK0sV0DCAPosToPV", "hK0sV0DCAPosToPV", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}); - registry.add("hK0sV0DCAV0Daughters", "hK0sV0DCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.20f}}}); - registry.add("hK0sCtau", "hK0sCtau", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); - registry.add("hK0sEtaDau", "hK0sEtaDau", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); - registry.add("hK0sRap", "hK0sRap", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); - registry.add("hK0sTPCNSigmaPosPi", "hK0sTPCNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("hK0sTPCNSigmaNegPi", "hK0sTPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - - registry.add("hLambdaV0Radius", "hLambdaV0Radius", {HistType::kTH1D, {{200, 0.0f, 40.0f}}}); - registry.add("hLambdaCosPA", "hLambdaCosPA", {HistType::kTH1F, {{100, 0.9f, 1.0f}}}); - registry.add("hLambdaV0DCANegToPV", "hLambdaV0DCANegToPV", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}); - registry.add("hLambdaV0DCAPosToPV", "hLambdaV0DCAPosToPV", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}); - registry.add("hLambdaV0DCAV0Daughters", "hLambdaV0DCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.20f}}}); - registry.add("hLambdaCtau", "hLambdaCtau", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); - registry.add("hLambdaEtaDau", "hLambdaEtaDau", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); - registry.add("hLambdaRap", "hLambdaRap", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); - registry.add("hLambdaTPCNSigmaNegPi", "hLambdaTPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("hLambdaTPCNSigmaPosPr", "hLambdaTPCNSigmaPosPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - - registry.add("hAntiLambdaV0Radius", "hAntiLambdaV0Radius", {HistType::kTH1D, {{200, 0.0f, 40.0f}}}); - registry.add("hAntiLambdaCosPA", "hAntiLambdaCosPA", {HistType::kTH1F, {{100, 0.9f, 1.0f}}}); - registry.add("hAntiLambdaV0DCANegToPV", "hAntiLambdaV0DCANegToPV", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}); - registry.add("hAntiLambdaV0DCAPosToPV", "hAntiLambdaV0DCAPosToPV", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}); - registry.add("hAntiLambdaV0DCAV0Daughters", "hAntiLambdaV0DCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.20f}}}); - registry.add("hAntiLambdaCtau", "hAntiLambdaCtau", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); - registry.add("hAntiLambdaEtaDau", "hAntiLambdaEtaDau", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); - registry.add("hAntiLambdaRap", "hAntiLambdaRap", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); - registry.add("hAntiLambdaTPCNSigmaPosPi", "hAntiLambdaTPCNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("hAntiLambdaTPCNSigmaNegPr", "hAntiLambdaTPCNSigmaNegPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - - /*registry.add("TPCNSigmaPosPr", "TPCNSigmaPosPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("TPCNSigmaNegPr", "TPCNSigmaNegPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("TOFNSigmaPosPi", "TOFNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("TOFNSigmaNegPi", "TOFNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("TOFNSigmaPosPr", "TOFNSigmaPosPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("TOFNSigmaNegPr", "TOFNSigmaNegPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); */ + if (doQA) { + registry.add("QA/hK0sSelection", ";Sel", {HistType::kTH1D, {{22, 0., 22.}}}); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(1, "all"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(2, "Event selection"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(3, "Radius"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(4, "Eta Daughters"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(5, "Dau DCA to PV"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(6, "DCA Daughters"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(7, "min ITS hits"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(8, "has TOF 1 Leg"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(9, "has TOF 2 Legs"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(10, "TPC NCl"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(11, "TPC Cls Shared"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(12, "ITS Chi2"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(13, "TPC Chi2"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(14, "cosPA"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(15, "rapidity"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(16, "ctau"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(17, "v0 rej"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(18, "TPC nsigma Neg Dau"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(19, "TPC nsigma Pos Dau"); + registry.get(HIST("QA/hK0sSelection"))->GetXaxis()->SetBinLabel(20, "Armenteros-Podolansky"); + + // common + registry.add("QA/hV0_EvFlag", "hV0_EvFlag", {HistType::kTH1D, {{2, 0.0f, 2.0f}}}); + registry.add("QA/hV0_Radius", "hV0_Radius", {HistType::kTH1D, {{1000, 0.0f, 100.0f}}}); + registry.add("QA/hV0_DCADauToPV", "hV0_DCADauToPV", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}); + registry.add("QA/hV0_DCADaughters", "hV0_DCADaughters", {HistType::kTH1F, {{200, 0.0f, 2.0f}}}); + registry.add("QA/hV0_EtaDau", "hV0_EtaDau", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + registry.add("QA/hV0_ITShits", "hV0_ITShits", {HistType::kTH1F, {{10, .0f, 10.0f}}}); + registry.add("QA/hV0_TPCNCls", "hV0_TPCNCls", {HistType::kTH1F, {{200, .0f, 200.0f}}}); + registry.add("QA/hV0_TPCNClsShared", "hV0_TPCNClsShared", {HistType::kTH1F, {{150, .0f, 1.5f}}}); + registry.add("QA/hV0_ITSChi2", "hV0_ITSChi2", {HistType::kTH1F, {{10, .0f, 10.0f}}}); + registry.add("QA/hV0_TPCChi2", "hV0_TPCChi2", {HistType::kTH1F, {{100, .0f, 100.0f}}}); + // K0s + registry.add("QA/hK0s_ArmenterosPodolanski", "QA/hK0s_ArmenterosPodolanski", {HistType::kTH2F, {{1000, -1.0f, 1.0f, "#alpha"}, {1000, 0.0f, 0.30f, "#it{Q}_{T}"}}}); + registry.add("QA/hK0s_Rap", "hK0s_Rap", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + registry.add("QA/hK0s_CosPA", "hK0s_CosPA", {HistType::kTH1F, {{100, 0.95f, 1.0f}}}); + registry.add("QA/hK0s_Ctau", "hK0s_Ctau", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); + registry.add("QA/hK0s_TPCNSigmaPosPi", "hK0s_TPCNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + registry.add("QA/hK0s_TPCNSigmaNegPi", "hK0s_TPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + // Lambda + registry.add("QA/hLambda_ArmenterosPodolanski", "QA/hLambda_ArmenterosPodolanski", {HistType::kTH2F, {{1000, -1.0f, 1.0f, "#alpha"}, {1000, 0.0f, 0.30f, "#it{Q}_{T}"}}}); + registry.add("QA/hLambda_Rap", "hLambda_Rap", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + registry.add("QA/hLambda_CosPA", "hLambda_CosPA", {HistType::kTH1F, {{100, 0.95f, 1.0f}}}); + registry.add("QA/hLambda_Ctau", "hLambda_Ctau", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); + registry.add("QA/hLambda_TPCNSigmaPosPi", "hLambda_TPCNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + registry.add("QA/hLambda_TPCNSigmaNegPi", "hLambda_TPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + // AntiLambda + registry.add("QA/hAntiLambda_ArmenterosPodolanski", "QA/hAntiLambda_ArmenterosPodolanski", {HistType::kTH2F, {{1000, -1.0f, 1.0f, "#alpha"}, {1000, 0.0f, 0.30f, "#it{Q}_{T}"}}}); + registry.add("QA/hAntiLambda_Rap", "hAntiLambda_Rap", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + registry.add("QA/hAntiLambda_CosPA", "hAntiLambda_CosPA", {HistType::kTH1F, {{100, 0.95f, 1.0f}}}); + registry.add("QA/hAntiLambda_Ctau", "hAntiLambda_Ctau", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); + registry.add("QA/hAntiLambda_TPCNSigmaPosPi", "hAntiLambda_TPCNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + registry.add("QA/hAntiLambda_TPCNSigmaNegPi", "hAntiLambda_TPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + + // common + registry.add("QA/hV0_Sel_EvFlag", "hV0_Sel_EvFlag", {HistType::kTH1D, {{2, 0.0f, 2.0f}}}); + registry.add("QA/hV0_Sel_Radius", "hV0_Sel_Radius", {HistType::kTH1D, {{1000, 0.0f, 100.0f}}}); + registry.add("QA/hV0_Sel_DCADauToPV", "hV0_Sel_DCADauToPV", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}); + registry.add("QA/hV0_Sel_DCADaughters", "hV0_Sel_DCADaughters", {HistType::kTH1F, {{200, 0.0f, 2.0f}}}); + registry.add("QA/hV0_Sel_EtaDau", "hV0_Sel_EtaDau", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + registry.add("QA/hV0_Sel_ITShits", "hV0_Sel_ITShits", {HistType::kTH1F, {{10, .0f, 10.0f}}}); + registry.add("QA/hV0_Sel_TPCNCls", "hV0_Sel_TPCNCls", {HistType::kTH1F, {{200, .0f, 200.0f}}}); + registry.add("QA/hV0_Sel_TPCNClsShared", "hV0_Sel_TPCNClsShared", {HistType::kTH1F, {{150, .0f, 1.5f}}}); + registry.add("QA/hV0_Sel_ITSChi2", "hV0_Sel_ITSChi2", {HistType::kTH1F, {{10, .0f, 10.0f}}}); + registry.add("QA/hV0_Sel_TPCChi2", "hV0_Sel_TPCChi2", {HistType::kTH1F, {{100, .0f, 100.0f}}}); + // K0s + registry.add("QA/hK0s_Sel_ArmenterosPodolanski", "QA/hK0s_ArmenterosPodolanski", {HistType::kTH2F, {{1000, -1.0f, 1.0f, "#alpha"}, {1000, 0.0f, 0.30f, "#it{Q}_{T}"}}}); + registry.add("QA/hK0s_Sel_Rap", "hK0s_Sel_Rap", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + registry.add("QA/hK0s_Sel_CosPA", "hK0s_Sel_CosPA", {HistType::kTH1F, {{100, 0.95f, 1.0f}}}); + registry.add("QA/hK0s_Sel_Ctau", "hK0s_Sel_Ctau", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); + registry.add("QA/hK0s_Sel_TPCNSigmaPosPi", "hK0s_Sel_TPCNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + registry.add("QA/hK0s_Sel_TPCNSigmaNegPi", "hK0s_Sel_TPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + // Lambda + registry.add("QA/hLambda_Sel_ArmenterosPodolanski", "QA/hLambda_Sel_ArmenterosPodolanski", {HistType::kTH2F, {{1000, -1.0f, 1.0f, "#alpha"}, {1000, 0.0f, 0.30f, "#it{Q}_{T}"}}}); + registry.add("QA/hLambda_Sel_Rap", "hLambda_Sel_Rap", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + registry.add("QA/hLambda_Sel_CosPA", "hLambda_Sel_CosPA", {HistType::kTH1F, {{100, 0.95f, 1.0f}}}); + registry.add("QA/hLambda_Sel_Ctau", "hLambda_Sel_Ctau", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); + registry.add("QA/hLambda_Sel_TPCNSigmaPosPr", "hLambda_Sel_TPCNSigmaPosPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + registry.add("QA/hLambda_Sel_TPCNSigmaNegPi", "hLambda_Sel_TPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + // AntiLambda + registry.add("QA/hAntiLambda_Sel_ArmenterosPodolanski", "QA/hAntiLambda_Sel_ArmenterosPodolanski", {HistType::kTH2F, {{1000, -1.0f, 1.0f, "#alpha"}, {1000, 0.0f, 0.30f, "#it{Q}_{T}"}}}); + registry.add("QA/hAntiLambda_Sel_Rap", "hAntiLambda_Sel_Rap", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + registry.add("QA/hAntiLambda_Sel_CosPA", "hAntiLambda_Sel_CosPA", {HistType::kTH1F, {{100, 0.95f, 1.0f}}}); + registry.add("QA/hAntiLambda_Sel_Ctau", "hAntiLambda_Sel_Ctau", {HistType::kTH1F, {{100, 0.0f, 50.0f}}}); + registry.add("QA/hAntiLambda_Sel_TPCNSigmaPosPi", "hAntiLambda_Sel_TPCNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + registry.add("QA/hAntiLambda_Sel_TPCNSigmaNegPr", "hAntiLambda_Sel_TPCNSigmaNegPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + } + } + + // V0 selection + template + bool QAK0s(TV0Type const& candidate) + { + if (candidate.v0cospa() <= cospaK0s) + return false; + registry.fill(HIST("QA/hK0sSelection"), 13.5); + + if (candidate.rapk0short() >= rap) + return false; + registry.fill(HIST("QA/hK0sSelection"), 14.5); + + if (candidate.ctauk0short() >= ctauK0s) + return false; + registry.fill(HIST("QA/hK0sSelection"), 15.5); + + if (std::abs(candidate.masslambda() - o2::constants::physics::MassLambda0) <= v0rejK0s) + return false; + registry.fill(HIST("QA/hK0sSelection"), 16.5); + + if (std::abs(candidate.ntpcsigmanegpi()) > ntpcsigma) + return false; + registry.fill(HIST("QA/hK0sSelection"), 17.5); + + if (std::abs(candidate.ntpcsigmapospi()) > ntpcsigma) + return false; + registry.fill(HIST("QA/hK0sSelection"), 18.5); + + if (doArmenterosCut && candidate.qtarm() < (paramArmenterosCut * std::abs(candidate.alpha()))) + return false; + registry.fill(HIST("QA/hK0sSelection"), 19.5); + + return true; + } + + // V0 selection + template + bool AcceptV0(TV0Type const& candidate) + { + if (evSel && candidate.evflag() < 1) + return false; + registry.fill(HIST("QA/hK0sSelection"), 1.5); + + if (candidate.v0radius() < radius && candidate.v0radius() > maxradius) + return false; + registry.fill(HIST("QA/hK0sSelection"), 2.5); + + if (std::abs(candidate.v0poseta()) > etadau) + return false; + if (std::abs(candidate.v0negeta()) > etadau) + return false; + registry.fill(HIST("QA/hK0sSelection"), 3.5); + + if (std::abs(candidate.v0dcanegtopv()) < dcanegtopv) + return false; + if (std::abs(candidate.v0dcapostopv()) < dcapostopv) + return false; + registry.fill(HIST("QA/hK0sSelection"), 4.5); + + if (candidate.v0dcav0daughters() > dcav0dau) + return false; + registry.fill(HIST("QA/hK0sSelection"), 5.5); + + if (candidate.v0positshits() < minITShits) + return false; + if (candidate.v0negitshits() < minITShits) + return false; + registry.fill(HIST("QA/hK0sSelection"), 6.5); + + if (hasTOF1Leg && !candidate.poshastof() && !candidate.neghastof()) + return false; + registry.fill(HIST("QA/hK0sSelection"), 7.5); + + if (hasTOF2Leg && (!candidate.poshastof() || !candidate.neghastof())) + return false; + registry.fill(HIST("QA/hK0sSelection"), 8.5); + + if (candidate.v0postpcCrossedRows() < min_TPC_nClusters) + return false; + if (candidate.v0negtpcCrossedRows() < min_TPC_nClusters) + return false; + registry.fill(HIST("QA/hK0sSelection"), 9.5); + + if (candidate.v0postpcNClsShared() > max_tpcSharedCls) + return false; + if (candidate.v0negtpcNClsShared() > max_tpcSharedCls) + return false; + registry.fill(HIST("QA/hK0sSelection"), 10.5); + + if (candidate.v0positsChi2NCl() > max_chi2_ITS) + return false; + if (candidate.v0negitsChi2NCl() > max_chi2_ITS) + return false; + registry.fill(HIST("QA/hK0sSelection"), 11.5); + + if (candidate.v0postpcChi2NCl() > max_chi2_TPC) + return false; + if (candidate.v0negtpcChi2NCl() > max_chi2_TPC) + return false; + registry.fill(HIST("QA/hK0sSelection"), 12.5); + + return true; } void process(aod::MyV0Candidates const& myv0s) { for (auto& candidate : myv0s) { - // common selections - if (candidate.v0radius() < radius) - continue; - if (TMath::Abs(candidate.v0poseta()) > etadau) - continue; - if (TMath::Abs(candidate.v0negeta()) > etadau) - continue; - if (TMath::Abs(candidate.v0dcanegtopv()) < dcanegtopv) - continue; - if (TMath::Abs(candidate.v0dcapostopv()) < dcapostopv) - continue; - if (candidate.v0dcav0daughters() > dcav0dau) - continue; - if (evSel && candidate.evflag() < 1) - continue; - if (hasTOF1Leg && !candidate.poshastof() && !candidate.neghastof()) - continue; - if (hasTOF2Leg && (!candidate.poshastof() || !candidate.neghastof())) + if (doQA) { + registry.fill(HIST("QA/hK0sSelection"), 0.5); + registry.fill(HIST("QA/hV0_EvFlag"), candidate.evflag()); + registry.fill(HIST("QA/hV0_Radius"), candidate.v0radius()); + registry.fill(HIST("QA/hV0_DCADauToPV"), candidate.v0dcanegtopv()); + registry.fill(HIST("QA/hV0_DCADaughters"), candidate.v0dcav0daughters()); + registry.fill(HIST("QA/hV0_EtaDau"), candidate.v0poseta()); + registry.fill(HIST("QA/hV0_EtaDau"), candidate.v0negeta()); + registry.fill(HIST("QA/hV0_ITShits"), candidate.v0negitshits()); + registry.fill(HIST("QA/hV0_TPCNCls"), candidate.v0postpcCrossedRows()); + registry.fill(HIST("QA/hV0_TPCNCls"), candidate.v0negtpcCrossedRows()); + registry.fill(HIST("QA/hV0_TPCNClsShared"), candidate.v0postpcNClsShared()); + registry.fill(HIST("QA/hV0_TPCNClsShared"), candidate.v0negtpcNClsShared()); + registry.fill(HIST("QA/hV0_ITSChi2"), candidate.v0positsChi2NCl()); + registry.fill(HIST("QA/hV0_ITSChi2"), candidate.v0negitsChi2NCl()); + registry.fill(HIST("QA/hV0_TPCChi2"), candidate.v0postpcChi2NCl()); + registry.fill(HIST("QA/hV0_TPCChi2"), candidate.v0negtpcChi2NCl()); + registry.fill(HIST("QA/hK0s_ArmenterosPodolanski"), candidate.alpha(), candidate.qtarm()); + registry.fill(HIST("QA/hK0s_CosPA"), candidate.v0cospa()); + registry.fill(HIST("QA/hK0s_Rap"), candidate.rapk0short()); + registry.fill(HIST("QA/hK0s_Ctau"), candidate.ctauk0short()); + registry.fill(HIST("QA/hK0s_TPCNSigmaPosPi"), candidate.ntpcsigmapospi()); + registry.fill(HIST("QA/hK0s_TPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); + registry.fill(HIST("QA/hLambda_ArmenterosPodolanski"), candidate.alpha(), candidate.qtarm()); + registry.fill(HIST("QA/hLambda_CosPA"), candidate.v0cospa()); + registry.fill(HIST("QA/hLambda_Rap"), candidate.rapk0short()); + registry.fill(HIST("QA/hLambda_Ctau"), candidate.ctauk0short()); + registry.fill(HIST("QA/hLambda_TPCNSigmaPosPi"), candidate.ntpcsigmapospi()); + registry.fill(HIST("QA/hLambda_TPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); + registry.fill(HIST("QA/hAntiLambda_ArmenterosPodolanski"), candidate.alpha(), candidate.qtarm()); + registry.fill(HIST("QA/hAntiLambda_CosPA"), candidate.v0cospa()); + registry.fill(HIST("QA/hAntiLambda_Rap"), candidate.rapk0short()); + registry.fill(HIST("QA/hAntiLambda_Ctau"), candidate.ctauk0short()); + registry.fill(HIST("QA/hAntiLambda_TPCNSigmaPosPi"), candidate.ntpcsigmapospi()); + registry.fill(HIST("QA/hAntiLambda_TPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); + } + + // Apply common V0 selection + if (!AcceptV0(candidate)) { continue; + } + + QAK0s(candidate); + + if (doQA) { + registry.fill(HIST("QA/hV0_Sel_EvFlag"), candidate.evflag()); + registry.fill(HIST("QA/hV0_Sel_Radius"), candidate.v0radius()); + registry.fill(HIST("QA/hV0_Sel_DCADauToPV"), candidate.v0dcanegtopv()); + registry.fill(HIST("QA/hV0_Sel_DCADaughters"), candidate.v0dcav0daughters()); + registry.fill(HIST("QA/hV0_Sel_EtaDau"), candidate.v0poseta()); + registry.fill(HIST("QA/hV0_Sel_EtaDau"), candidate.v0negeta()); + registry.fill(HIST("QA/hV0_Sel_ITShits"), candidate.v0negitshits()); + registry.fill(HIST("QA/hV0_Sel_ITShits"), candidate.v0positshits()); + registry.fill(HIST("QA/hV0_Sel_TPCNCls"), candidate.v0postpcCrossedRows()); + registry.fill(HIST("QA/hV0_Sel_TPCNCls"), candidate.v0negtpcCrossedRows()); + registry.fill(HIST("QA/hV0_Sel_TPCNClsShared"), candidate.v0postpcNClsShared()); + registry.fill(HIST("QA/hV0_Sel_TPCNClsShared"), candidate.v0negtpcNClsShared()); + registry.fill(HIST("QA/hV0_Sel_ITSChi2"), candidate.v0positsChi2NCl()); + registry.fill(HIST("QA/hV0_Sel_ITSChi2"), candidate.v0negitsChi2NCl()); + registry.fill(HIST("QA/hV0_Sel_TPCChi2"), candidate.v0postpcChi2NCl()); + registry.fill(HIST("QA/hV0_Sel_TPCChi2"), candidate.v0negtpcChi2NCl()); + } + + ////////////////////////////////// + //////////// K0Short ///////////// + ////////////////////////////////// - // K0Short analysis if (candidate.v0cospa() > cospaK0s && - TMath::Abs(candidate.rapk0short()) < rap && + std::abs(candidate.rapk0short()) < rap && candidate.ctauk0short() < ctauK0s && - TMath::Abs(candidate.massk0short() - o2::constants::physics::MassK0Short) < 0.075 && - TMath::Abs(candidate.masslambda() - o2::constants::physics::MassLambda0) > v0rejK0s && - TMath::Abs(candidate.ntpcsigmanegpi()) <= ntpcsigma && - TMath::Abs(candidate.ntpcsigmapospi()) <= ntpcsigma) { - - registry.fill(HIST("hArmenterosPodolanski"), candidate.alpha(), candidate.qtarm()); - - if (doArmenterosCut && candidate.qtarm() > (paramArmenterosCut * TMath::Abs(candidate.alpha()))) { - registry.fill(HIST("hArmenterosPodolanski_Sel"), candidate.alpha(), candidate.qtarm()); - registry.fill(HIST("hMassK0Short"), candidate.massk0short()); - registry.fill(HIST("hMassVsPtK0Short"), candidate.v0pt(), candidate.massk0short()); - registry.fill(HIST("hMassVsPtK0ShortVsCentFT0M"), candidate.v0pt(), candidate.multft0m(), candidate.massk0short()); - registry.fill(HIST("hMassVsPtK0ShortVsCentFV0A"), candidate.v0pt(), candidate.multfv0a(), candidate.massk0short()); - - // QA - if (!isMC) { - registry.fill(HIST("hK0sV0Radius"), candidate.v0radius()); - registry.fill(HIST("hK0sCosPA"), candidate.v0cospa()); - registry.fill(HIST("hK0sV0DCANegToPV"), candidate.v0dcanegtopv()); - registry.fill(HIST("hK0sV0DCAPosToPV"), candidate.v0dcapostopv()); - registry.fill(HIST("hK0sV0DCAV0Daughters"), candidate.v0dcav0daughters()); - registry.fill(HIST("hK0sCtau"), candidate.ctauk0short()); - registry.fill(HIST("hK0sEtaDau"), candidate.v0poseta()); - registry.fill(HIST("hK0sRap"), candidate.rapk0short()); - registry.fill(HIST("hK0sTPCNSigmaPosPi"), candidate.ntpcsigmapospi()); - registry.fill(HIST("hK0sTPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); - } + std::abs(candidate.massk0short() - o2::constants::physics::MassK0Short) < 0.075 && + std::abs(candidate.masslambda() - o2::constants::physics::MassLambda0) > v0rejK0s && + std::abs(candidate.ntpcsigmanegpi()) <= ntpcsigma && + std::abs(candidate.ntpcsigmapospi()) <= ntpcsigma && + (doArmenterosCut && candidate.qtarm() > (paramArmenterosCut * std::abs(candidate.alpha())))) { + + registry.fill(HIST("hMassK0Short"), candidate.massk0short()); + registry.fill(HIST("hMassVsPtK0Short"), candidate.v0pt(), candidate.massk0short()); + registry.fill(HIST("hMassVsPtK0ShortVsCentFT0M"), candidate.v0pt(), candidate.multft0m(), candidate.massk0short()); + + if (isMC && + candidate.pdgcode() == 310 && + candidate.isdauk0short() && + candidate.isphysprimary() == 1) { + + registry.fill(HIST("hMassK0Short_MC"), candidate.massk0short()); + registry.fill(HIST("hMassVsPtK0ShortVsCentFT0M_MC"), candidate.v0pt(), candidate.multft0m(), candidate.massk0short()); + } + + if (doQA) { + registry.fill(HIST("QA/hK0s_Sel_ArmenterosPodolanski"), candidate.alpha(), candidate.qtarm()); + registry.fill(HIST("QA/hK0s_Sel_Rap"), candidate.rapk0short()); + registry.fill(HIST("QA/hK0s_Sel_CosPA"), candidate.v0cospa()); + registry.fill(HIST("QA/hK0s_Sel_Ctau"), candidate.ctauk0short()); + registry.fill(HIST("QA/hK0s_Sel_TPCNSigmaPosPi"), candidate.ntpcsigmapospi()); + registry.fill(HIST("QA/hK0s_Sel_TPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); } } - // Lambda analysis + ////////////////////////////////// + ////// Lambda / AntiLambda /////// + ////////////////////////////////// + if (candidate.v0cospa() > cospaLambda && - TMath::Abs(candidate.raplambda()) < rap && - TMath::Abs(candidate.massk0short() - o2::constants::physics::MassK0Short) > v0rejLambda) { + std::abs(candidate.raplambda()) < rap && + std::abs(candidate.massk0short() - o2::constants::physics::MassK0Short) > v0rejLambda) { + + ////////////////////////////////// + ///////////// Lambda ///////////// + ////////////////////////////////// - // Lambda - if (TMath::Abs(candidate.ntpcsigmanegpi()) <= ntpcsigma && TMath::Abs(candidate.ntpcsigmapospr()) <= ntpcsigma && + if (std::abs(candidate.ntpcsigmanegpi()) <= ntpcsigma && + std::abs(candidate.ntpcsigmapospr()) <= ntpcsigma && candidate.ctaulambda() < ctauLambda && - TMath::Abs(candidate.masslambda() - o2::constants::physics::MassLambda0) < 0.075) { + std::abs(candidate.masslambda() - o2::constants::physics::MassLambda0) < 0.075) { registry.fill(HIST("hMassLambda"), candidate.masslambda()); registry.fill(HIST("hMassVsPtLambda"), candidate.v0pt(), candidate.masslambda()); registry.fill(HIST("hMassVsPtLambdaVsCentFT0M"), candidate.v0pt(), candidate.multft0m(), candidate.masslambda()); - // QA - if (!isMC) { - registry.fill(HIST("hLambdaV0Radius"), candidate.v0radius()); - registry.fill(HIST("hLambdaCosPA"), candidate.v0cospa()); - registry.fill(HIST("hLambdaV0DCANegToPV"), candidate.v0dcanegtopv()); - registry.fill(HIST("hLambdaV0DCAPosToPV"), candidate.v0dcapostopv()); - registry.fill(HIST("hLambdaV0DCAV0Daughters"), candidate.v0dcav0daughters()); - registry.fill(HIST("hLambdaCtau"), candidate.ctaulambda()); - registry.fill(HIST("hLambdaEtaDau"), candidate.v0poseta()); - registry.fill(HIST("hLambdaRap"), candidate.raplambda()); - registry.fill(HIST("hLambdaTPCNSigmaPosPr"), candidate.ntpcsigmapospr()); - registry.fill(HIST("hLambdaTPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); + if (isMC) { + + if (candidate.pdgcode() == 3122 && candidate.isdaulambda()) { + + if (candidate.isphysprimary() == 1) { + registry.fill(HIST("hMassLambda_MC"), candidate.masslambda()); + registry.fill(HIST("hMassVsPtLambdaVsCentFT0M_MC"), candidate.v0pt(), candidate.multft0m(), candidate.masslambda()); + } + + if (candidate.pdgcodemother() == 3312) { + registry.fill(HIST("hMassVsPtLambdaVsMotherPt_DoubleCharged_MC"), candidate.v0pt(), candidate.v0motherpt(), candidate.masslambda()); + } + if (candidate.pdgcodemother() == 3312 || candidate.pdgcodemother() == 3322) { + registry.fill(HIST("hMassVsPtLambdaVsMotherPt_MCRatio_MC"), candidate.v0pt(), candidate.v0motherpt(), candidate.masslambda()); + } + } + } + + if (doQA) { + registry.fill(HIST("QA/hLambda_Sel_ArmenterosPodolanski"), candidate.alpha(), candidate.qtarm()); + registry.fill(HIST("QA/hLambda_Sel_Rap"), candidate.rapk0short()); + registry.fill(HIST("QA/hLambda_Sel_CosPA"), candidate.v0cospa()); + registry.fill(HIST("QA/hLambda_Sel_Ctau"), candidate.ctauk0short()); + registry.fill(HIST("QA/hLambda_Sel_TPCNSigmaPosPr"), candidate.ntpcsigmapospr()); + registry.fill(HIST("QA/hLambda_Sel_TPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); } } - // AntiLambda - if (TMath::Abs(candidate.ntpcsigmanegpr()) <= ntpcsigma && TMath::Abs(candidate.ntpcsigmapospi()) <= ntpcsigma && + + ////////////////////////////////// + /////////// AntiLambda /////////// + ////////////////////////////////// + + if (std::abs(candidate.ntpcsigmanegpr()) <= ntpcsigma && + std::abs(candidate.ntpcsigmapospi()) <= ntpcsigma && candidate.ctauantilambda() < ctauLambda && - TMath::Abs(candidate.massantilambda() - o2::constants::physics::MassLambda0) < 0.075) { + std::abs(candidate.massantilambda() - o2::constants::physics::MassLambda0) < 0.075) { registry.fill(HIST("hMassAntiLambda"), candidate.massantilambda()); registry.fill(HIST("hMassVsPtAntiLambda"), candidate.v0pt(), candidate.massantilambda()); registry.fill(HIST("hMassVsPtAntiLambdaVsCentFT0M"), candidate.v0pt(), candidate.multft0m(), candidate.massantilambda()); - // QA - if (!isMC) { - registry.fill(HIST("hAntiLambdaV0Radius"), candidate.v0radius()); - registry.fill(HIST("hAntiLambdaCosPA"), candidate.v0cospa()); - registry.fill(HIST("hAntiLambdaV0DCANegToPV"), candidate.v0dcanegtopv()); - registry.fill(HIST("hAntiLambdaV0DCAPosToPV"), candidate.v0dcapostopv()); - registry.fill(HIST("hAntiLambdaV0DCAV0Daughters"), candidate.v0dcav0daughters()); - registry.fill(HIST("hAntiLambdaCtau"), candidate.ctauantilambda()); - registry.fill(HIST("hAntiLambdaEtaDau"), candidate.v0poseta()); - registry.fill(HIST("hAntiLambdaRap"), candidate.raplambda()); - registry.fill(HIST("hAntiLambdaTPCNSigmaNegPr"), candidate.ntpcsigmanegpr()); - registry.fill(HIST("hAntiLambdaTPCNSigmaPosPi"), candidate.ntpcsigmapospi()); - } - } - } + if (candidate.pdgcode() == -3122 && candidate.isdauantilambda()) { - if (isMC) { - - if (candidate.isphysprimary() == 0) - continue; - - // K0Short analysis - if (candidate.v0cospa() > cospaK0s && - TMath::Abs(candidate.rapk0short()) < rap && - candidate.ctauk0short() < ctauK0s && - TMath::Abs(candidate.massk0short() - o2::constants::physics::MassK0Short) < 0.075 && - TMath::Abs(candidate.masslambda() - o2::constants::physics::MassLambda0) > v0rejK0s && - TMath::Abs(candidate.ntpcsigmanegpi()) <= ntpcsigmaMC && - TMath::Abs(candidate.ntpcsigmapospi()) <= ntpcsigmaMC && - (candidate.pdgcode() == 310)) { - - registry.fill(HIST("hArmenterosPodolanski"), candidate.alpha(), candidate.qtarm()); - - if (doArmenterosCut && candidate.qtarm() > (paramArmenterosCut * TMath::Abs(candidate.alpha()))) { - registry.fill(HIST("hArmenterosPodolanski_Sel"), candidate.alpha(), candidate.qtarm()); - registry.fill(HIST("hMassK0Short_MC"), candidate.massk0short()); - registry.fill(HIST("hMassVsPtK0Short_MC"), candidate.v0pt(), candidate.multft0m(), candidate.massk0short()); - - registry.fill(HIST("hK0sV0Radius"), candidate.v0radius()); - registry.fill(HIST("hK0sCosPA"), candidate.v0cospa()); - registry.fill(HIST("hK0sV0DCANegToPV"), candidate.v0dcanegtopv()); - registry.fill(HIST("hK0sV0DCAPosToPV"), candidate.v0dcapostopv()); - registry.fill(HIST("hK0sV0DCAV0Daughters"), candidate.v0dcav0daughters()); - registry.fill(HIST("hK0sCtau"), candidate.ctauk0short()); - registry.fill(HIST("hK0sEtaDau"), candidate.v0poseta()); - registry.fill(HIST("hK0sRap"), candidate.rapk0short()); - registry.fill(HIST("hK0sTPCNSigmaPosPi"), candidate.ntpcsigmapospi()); - registry.fill(HIST("hK0sTPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); - } - } // k0 - - // Lambda analysis - if (candidate.v0cospa() > cospaLambda && - TMath::Abs(candidate.raplambda()) < rap && - TMath::Abs(candidate.massk0short() - o2::constants::physics::MassK0Short) > v0rejLambda) { - - // Lambda - if (TMath::Abs(candidate.ntpcsigmanegpi()) <= ntpcsigmaMC && TMath::Abs(candidate.ntpcsigmapospr()) <= ntpcsigmaMC && - candidate.ctaulambda() < ctauLambda && - TMath::Abs(candidate.masslambda() - o2::constants::physics::MassLambda0) < 0.075 && - candidate.pdgcode() == 3122) { - - registry.fill(HIST("hMassLambda_MC"), candidate.masslambda()); - registry.fill(HIST("hMassVsPtLambda_MC"), candidate.v0pt(), candidate.multft0m(), candidate.masslambda()); - - registry.fill(HIST("hLambdaV0Radius"), candidate.v0radius()); - registry.fill(HIST("hLambdaCosPA"), candidate.v0cospa()); - registry.fill(HIST("hLambdaV0DCANegToPV"), candidate.v0dcanegtopv()); - registry.fill(HIST("hLambdaV0DCAPosToPV"), candidate.v0dcapostopv()); - registry.fill(HIST("hLambdaV0DCAV0Daughters"), candidate.v0dcav0daughters()); - registry.fill(HIST("hLambdaCtau"), candidate.ctaulambda()); - registry.fill(HIST("hLambdaEtaDau"), candidate.v0poseta()); - registry.fill(HIST("hLambdaRap"), candidate.raplambda()); - registry.fill(HIST("hLambdaTPCNSigmaPosPr"), candidate.ntpcsigmapospr()); - registry.fill(HIST("hLambdaTPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); + if (candidate.isphysprimary() == 1) { + registry.fill(HIST("hMassAntiLambda_MC"), candidate.massantilambda()); + registry.fill(HIST("hMassVsPtAntiLambdaVsCentFT0M_MC"), candidate.v0pt(), candidate.v0motherpt(), candidate.massantilambda()); + } + + if (candidate.pdgcodemother() == -3312) { + registry.fill(HIST("hMassVsPtAntiLambdaVsMotherPt_DoubleCharged_MC"), candidate.v0pt(), candidate.v0motherpt(), candidate.massantilambda()); + } + if (candidate.pdgcodemother() == -3312 || candidate.pdgcodemother() == -3322) { + registry.fill(HIST("hMassVsPtAntiLambdaVsMotherPt_MCRatio_MC"), candidate.v0pt(), candidate.v0motherpt(), candidate.massantilambda()); + } } - // AntiLambda - if (TMath::Abs(candidate.ntpcsigmanegpr()) <= ntpcsigmaMC && TMath::Abs(candidate.ntpcsigmapospi()) <= ntpcsigmaMC && - candidate.ctauantilambda() < ctauLambda && - TMath::Abs(candidate.massantilambda() - o2::constants::physics::MassLambda0) < 0.075 && - candidate.pdgcode() == -3122) { - - registry.fill(HIST("hMassAntiLambda_MC"), candidate.massantilambda()); - registry.fill(HIST("hMassVsPtAntiLambda_MC"), candidate.v0pt(), candidate.multft0m(), candidate.massantilambda()); - - registry.fill(HIST("hAntiLambdaV0Radius"), candidate.v0radius()); - registry.fill(HIST("hAntiLambdaCosPA"), candidate.v0cospa()); - registry.fill(HIST("hAntiLambdaV0DCANegToPV"), candidate.v0dcanegtopv()); - registry.fill(HIST("hAntiLambdaV0DCAPosToPV"), candidate.v0dcapostopv()); - registry.fill(HIST("hAntiLambdaV0DCAV0Daughters"), candidate.v0dcav0daughters()); - registry.fill(HIST("hAntiLambdaCtau"), candidate.ctauantilambda()); - registry.fill(HIST("hAntiLambdaEtaDau"), candidate.v0poseta()); - registry.fill(HIST("hAntiLambdaRap"), candidate.raplambda()); - registry.fill(HIST("hAntiLambdaTPCNSigmaPosPi"), candidate.ntpcsigmapospi()); - registry.fill(HIST("hAntiLambdaTPCNSigmaNegPr"), candidate.ntpcsigmanegpr()); + + if (doQA) { + registry.fill(HIST("QA/hAntiLambda_Sel_ArmenterosPodolanski"), candidate.alpha(), candidate.qtarm()); + registry.fill(HIST("QA/hAntiLambda_Sel_Rap"), candidate.rapk0short()); + registry.fill(HIST("QA/hAntiLambda_Sel_CosPA"), candidate.v0cospa()); + registry.fill(HIST("QA/hAntiLambda_Sel_Ctau"), candidate.ctauk0short()); + registry.fill(HIST("QA/hAntiLambda_Sel_TPCNSigmaPosPi"), candidate.ntpcsigmapospi()); + registry.fill(HIST("QA/hAntiLambda_Sel_TPCNSigmaNegPr"), candidate.ntpcsigmanegpr()); } - } // lambda - } // is MC + } + } } } }; diff --git a/PWGLF/Tasks/Strangeness/v0ptinvmassplots.cxx b/PWGLF/Tasks/Strangeness/v0ptinvmassplots.cxx index 0b1bb3c88ac..b6a459fab70 100644 --- a/PWGLF/Tasks/Strangeness/v0ptinvmassplots.cxx +++ b/PWGLF/Tasks/Strangeness/v0ptinvmassplots.cxx @@ -9,278 +9,892 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// +/// \file v0ptinvmassplots.cxx /// \brief V0 task for production of invariant mass plots for Pt Spectrum Analysis /// \author Nikolaos Karatzenis (nikolaos.karatzenis@cern.ch) /// \author Roman Lietava (roman.lietava@cern.ch) /*Description -This task creates 20 histograms that are filled with the V0 invariant mass under the K0, Lambda and Antilambda mass assumption -for different pt ranges (constituting bins), so 3x20=60 plots.The values are inserted as configurable strings for convinience. -Plots of the invariant masses at different stages of the analysis (ex. before and after the V0 cuts are enforced) and some pt distributions. -This analysis includes two processes, one for Real Data and one for MC Data switchable at the end of the code, only run one at a time*/ +This task creates up to 30 histograms that are filled with the V0 invariant mass under the K0, Lambda and Antilambda mass assumption +for different pt ranges (constituting bins). The values are inserted as configurable strings for convinience. +Also feed-down matrices for the Lambda and Anti-Lambda are produced. +This analysis includes three processes, one for Real Data and two for MC at the Generated and Reconstructed level*/ -#include -#include -#include +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/Utils/inelGt.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" #include "Common/DataModel/EventSelection.h" -#include "PWGLF/DataModel/LFStrangenessTables.h" #include "Common/DataModel/PIDResponse.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "CommonUtils/StringUtils.h" +#include "Framework/AnalysisTask.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + +#include "TPDGCode.h" + #include -#include #include +#include +#include // namespace to be used for pt plots and bins namespace pthistos { -std::shared_ptr KaonPt[20]; -static std::vector kaonptbins; -std::shared_ptr LambdaPt[20]; -static std::vector lambdaptbins; -std::shared_ptr AntilambdaPt[20]; -static std::vector antilambdaptbins; +std::vector> kaonPt; +static std::vector kaonPtBins; +std::vector> lambdaPt; +static std::vector lambdaPtBins; +std::vector> antilambdaPt; +static std::vector antilambdaPtBins; } // namespace pthistos using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::constants::physics; -struct v0ptinvmassplots { +struct V0PtInvMassPlots { // Histogram Registries HistogramRegistry rPtAnalysis{"PtAnalysis", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rKaonshMassPlots_per_PtBin{"KaonshMassPlots_per_PtBin", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rLambdaMassPlots_per_PtBin{"LambdaMassPlots_per_PtBin", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rAntilambdaMassPlots_per_PtBin{"AntilambdaMassPlots_per_PtBin", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rKaonshMassPlotsPerPtBin{"KaonshMassPlotsPerPtBin", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rLambdaMassPlotsPerPtBin{"LambdaMassPlotsPerPtBin", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rAntilambdaMassPlotsPerPtBin{"AntilambdaMassPlotsPerPtBin", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rFeeddownMatrices{"FeeddownMatrices", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rMCCorrections{"MCCorrections", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; // Configurable for histograms Configurable nBins{"nBins", 100, "N bins in all histos"}; - Configurable xaxisgenbins{"xaxisgenbins", 20, "Number of bins for Generated Pt Spectrum"}; - Configurable xaxismingenbin{"xaxismingenbin", 0.0, "Minimum bin value of the Generated Pt Spectrum Plot"}; - Configurable xaxismaxgenbin{"xaxismaxgenbin", 3.0, "Maximum bin value of the Generated Pt Spectrum Plot"}; - - // Configurable Kaonsh Topological Cuts (best cuts determined by v0topologicalcuts task) - Configurable kaonshsetting_dcav0dau{"kaonshsetting_dcav0dau", 100.0, "DCA V0 Daughters"}; - Configurable kaonshsetting_dcapostopv{"kaonshsetting_dcapostopv", 0.05, "DCA Pos To PV"}; - Configurable kaonshsetting_dcanegtopv{"kaonshsetting_dcanegtopv", 0.05, "DCA Neg To PV"}; - Configurable kaonshsetting_cospa{"kaonshsetting_cospa", 0.50, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0 - Configurable kaonshsetting_radius{"kaonshsetting_radius", 0.50, "v0radius"}; - - // Configurable Lambda Topological Cuts (best cuts determined by v0topologicalcuts task) - Configurable lambdasetting_dcav0dau{"lambdasetting_dcav0dau", 100.0, "DCA V0 Daughters"}; - Configurable lambdasetting_dcapostopv{"lambdasetting_dcapostopv", 0.05, "DCA Pos To PV"}; - Configurable lambdasetting_dcanegtopv{"lambdasetting_dcanegtopv", 0.05, "DCA Neg To PV"}; - Configurable lambdasetting_cospa{"lambdasetting_cospa", 0.50, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0 - Configurable lambdasetting_radius{"lambdasetting_radius", 0.50, "v0radius"}; - - // Configurable Antilambda Topological Cuts (best cuts determined by v0topologicalcuts task) - Configurable antilambdasetting_dcav0dau{"antilambdasetting_dcav0dau", 100.0, "DCA V0 Daughters"}; - Configurable antilambdasetting_dcapostopv{"antilambdasetting_dcapostopv", 0.05, "DCA Pos To PV"}; - Configurable antilambdasetting_dcanegtopv{"antilambdasetting_dcanegtopv", 0.05, "DCA Neg To PV"}; - Configurable antilambdasetting_cospa{"antilambdasetting_cospa", 0.50, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0 - Configurable antilambdasetting_radius{"antilambdasetting_radius", 0.50, "v0radius"}; + Configurable nBinsArmenteros{"nBinsArmenteros", 500, "N bins in Armenteros histos"}; + Configurable nmaxHistograms{"nmaxHistograms", 20, "N Pt Histograms"}; + + // Configurables for Cuts + Configurable cutZVertex{"cutZVertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable nSigmaTPCPion{"nSigmaTPCPion", 4, "nSigmaTPCPion"}; + Configurable nSigmaTPCProton{"nSigmaTPCProton", 4, "nSigmaTPCProton"}; + Configurable compv0masscut{"compv0masscut", 0.01, "CompetitiveV0masscut (GeV)"}; + Configurable etadau{"etadau", 0.8, "Eta Daughters"}; + Configurable rapidityCut{"rapidityCut", 0.5, "V0 Rapidity Window"}; + Configurable itsMinHits{"itsMinHits", 1.0, "Minimum Hits of Daughter Tracks in the ITS"}; + + // Configurables switches for event selection + Configurable dosel8{"dosel8", true, "Enable sel8 event selection"}; + Configurable doNoTimeFrameBorder{"doNoTimeFrameBorder", true, "Enable NoTimeFrameBorder event selection"}; + Configurable doNoITSROFrameBorder{"doNoITSROFrameBorder", true, "Enable NoITSROFrameBorder event selection"}; + Configurable doIsTriggerTVX{"doIsTriggerTVX", true, "Enable IsTriggerTVX event selection"}; + Configurable docutZVertex{"docutZVertex", true, "Enable cutZVertex event selection"}; + Configurable doIsVertexTOFmatched{"doIsVertexTOFmatched", true, "Enable IsVertexTOFmatched event selection"}; + Configurable doNoSameBunchPileup{"doNoSameBunchPileup", true, "Enable NoSameBunchPileup event selection"}; + Configurable doIsVertexITSTPC{"doIsVertexITSTPC", true, "Enable IsVertexITSTPC event selection"}; + Configurable doisInelGt0{"doisInelGt0", true, "Enable isInelGt0 event selection"}; + + // Configurables switches for v0 selection + Configurable doRapidityCut{"doRapidityCut", true, "Enable rapidity v0 selection"}; + Configurable doDaughterPseudorapidityCut{"doDaughterPseudorapidityCut", true, "Enable Daughter pseudorapidity v0 selection"}; + Configurable doisITSAfterburner{"doisITSAfterburner", true, "Enable ITS Afterburner"}; + Configurable doitsMinHits{"doitsMinHits", true, "Enable ITS Minimum hits"}; + + // Configurables switches for K0sh selection + Configurable doK0shTPCPID{"doK0shTPCPID", true, "Enable K0sh TPC PID"}; + Configurable doK0shcomptmasscut{"doK0shcomptmasscut", true, "Enable K0sh Competitive V0 Mass Cut"}; + Configurable doK0shMaxct{"doK0shMaxct", true, "Enable K0sh Max ct Cut"}; + Configurable doK0shArmenterosCut{"doK0shArmenterosCut", true, "Enable K0sh Armenteros Cut"}; + Configurable doK0shcosPACut{"doK0shcosPACut", true, "Enable K0sh cosPA Topological Cut"}; + Configurable doK0shDCAdauCut{"doK0shDCAdauCut", true, "Enable K0sh DCA daughters Topological Cut"}; + Configurable doK0shv0radiusCut{"doK0shv0radiusCut", true, "Enable K0sh v0radius Topological Cut"}; + Configurable doK0shdcaposdautopv{"doK0shdcaposdautopv", true, "Enable K0sh DCA pos daughter to PV Topological Cut"}; + Configurable doK0shdcanegdautopv{"doK0shdcanegdautopv", true, "Enable K0sh DCA neg daughter to PV Topological Cut"}; + + // Configurables switches for Lambda selection + Configurable doLambdaTPCPID{"doLambdaTPCPID", true, "Enable Lambda TPC PID"}; + Configurable doLambdacomptmasscut{"doLambdacomptmasscut", true, "Enable Lambda Competitive V0 Mass Cut"}; + Configurable doLambdaMaxct{"doLambdaMaxct", true, "Enable Lambda Max ct Cut"}; + Configurable doLambdaArmenterosCut{"doLambdaArmenterosCut", true, "Enable Lambda Armenteros Cut"}; + Configurable doLambdacosPACut{"doLambdacosPACut", true, "Enable Lambda cosPA Topological Cut"}; + Configurable doLambdaDCAdauCut{"doLambdaDCAdauCut", true, "Enable Lambda DCA daughters Topological Cut"}; + Configurable doLambdav0radiusCut{"doLambdav0radiusCut", true, "Enable Lambda v0radius Topological Cut"}; + Configurable doLambdadcaposdautopv{"doLambdadcaposdautopv", true, "Enable Lambda DCA pos daughter to PV Topological Cut"}; + Configurable doLambdadcanegdautopv{"doLambdadcanegdautopv", true, "Enable Lambda DCA neg daughter to PV Topological Cut"}; + + // Configurables switches for Lambda selection + Configurable doAntilambdaTPCPID{"doAntilambdaTPCPID", true, "Enable Antilambda TPC PID"}; + Configurable doAntilambdacomptmasscut{"doAntilambdacomptmasscut", true, "Enable Antilambda Competitive V0 Mass Cut"}; + Configurable doAntilambdaMaxct{"doAntilambdaMaxct", true, "Enable Antilambda Max ct Cut"}; + Configurable doAntilambdaArmenterosCut{"doAntilambdaArmenterosCut", true, "Enable Antilambda Armenteros Cut"}; + Configurable doAntilambdacosPACut{"doAntilambdacosPACut", true, "Enable Antilambda cosPA Topological Cut"}; + Configurable doAntilambdaDCAdauCut{"doAntilambdaDCAdauCut", true, "Enable Antilambda DCA daughters Topological Cut"}; + Configurable doAntilambdav0radiusCut{"doAntilambdav0radiusCut", true, "Enable Antilambda v0radius Topological Cut"}; + Configurable doAntilambdadcaposdautopv{"doAntilambdadcaposdautopv", true, "Enable Antilambda DCA pos daughter to PV Topological Cut"}; + Configurable doAntilambdadcanegdautopv{"doAntilambdadcanegdautopv", true, "Enable Antilambda DCA neg daughter to PV Topological Cut"}; + + // Configurable Kaonsh Cuts (best cuts determined by v0topologicalcuts task) + Configurable kaonshSettingdcav0dau{"kaonshSettingdcav0dau", 0.3, "DCA V0 Daughters"}; + Configurable kaonshSettingdcapostopv{"kaonshSettingdcapostopv", 0.05, "DCA Pos To PV"}; + Configurable kaonshSettingdcanegtopv{"kaonshSettingdcanegtopv", 0.05, "DCA Neg To PV"}; + Configurable kaonshSettingcosPA{"kaonshSettingcosPA", 0.98, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0 + Configurable kaonshSettingradius{"kaonshSettingradius", 0.50, "v0radius"}; + Configurable kaonshmaxct{"kaonshmaxct", 20.00, "K0sh maximum ct value"}; + Configurable k0shparamArmenterosCut{"k0shparamArmenterosCut", 0.2, "K0sh Armenteros Cut on parameter"}; + + // Configurable Lambda Cuts (best cuts determined by v0topologicalcuts task) + Configurable lambdaSettingdcav0dau{"lambdaSettingdcav0dau", 0.3, "DCA V0 Daughters"}; + Configurable lambdaSettingdcapostopv{"lambdaSettingdcapostopv", 0.05, "DCA Pos To PV"}; + Configurable lambdaSettingdcanegtopv{"lambdaSettingdcanegtopv", 0.09, "DCA Neg To PV"}; + Configurable lambdaSettingcosPA{"lambdaSettingcosPA", 0.98, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0 + Configurable lambdaSettingradius{"lambdaSettingradius", 0.50, "v0radius"}; + Configurable lambdamaxct{"lambdamaxct", 30.00, "Lambda maximum ct value"}; + Configurable lambdaparamArmenterosCut{"lambdaparamArmenterosCut", 0.2, "Lambda Armenteros Cut on parameter"}; + + // Configurable Antilambda Cuts (best cuts determined by v0topologicalcuts task) + Configurable antilambdaSettingdcav0dau{"antilambdaSettingdcav0dau", 0.3, "DCA V0 Daughters"}; + Configurable antilambdaSettingdcapostopv{"antilambdaSettingdcapostopv", 0.09, "DCA Pos To PV"}; + Configurable antilambdaSettingdcanegtopv{"antilambdaSettingdcanegtopv", 0.05, "DCA Neg To PV"}; + Configurable antilambdaSettingcosPA{"antilambdaSettingcosPA", 0.98, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0 + Configurable antilambdaSettingradius{"antilambdaSettingradius", 0.50, "v0radius"}; + Configurable antilambdamaxct{"antilambdamaxct", 30.00, "Antilambda maximum ct value"}; + Configurable antilambdaparamArmenterosCut{"antilambdaparamArmenterosCut", 0.2, "Antilambda Armenteros Cut on parameter"}; // Configurables for Specific V0s analysis - Configurable kzerosh_analysis{"kzerosh_analysis", true, "Enable Kzerosh Pt Analysis"}; - Configurable lambda_analysis{"lambda_analysis", true, "Enable Lambda Pt Analysis"}; - Configurable antilambda_analysis{"antilambda_analysis", true, "Enable Antilambda Pt Analysis"}; + Configurable kzeroAnalysis{"kzeroAnalysis", true, "Enable Kzerosh Pt Analysis"}; + Configurable lambdaAnalysis{"lambdaAnalysis", true, "Enable Lambda Pt Analysis"}; + Configurable antiLambdaAnalysis{"antiLambdaAnalysis", true, "Enable Antilambda Pt Analysis"}; // Configurable string for Different Pt Bins - Configurable kzeroshsetting_pt_string{"kzerosetting_ptbins", {"0_0,0_15,0_3,0_45,0_6,0_75,0_9,1_05,1_2,1_35,1_5,1_65,1_8,1_95,2_1,2_25,2_4,2_55,2_7,2_85,3_0"}, "Kzero Pt Bin Values"}; - Configurable lambdasetting_pt_string{"lambdasetting_ptbins", {"0_0,0_15,0_3,0_45,0_6,0_75,0_9,1_05,1_2,1_35,1_5,1_65,1_8,1_95,2_1,2_25,2_4,2_55,2_7,2_85,3_0"}, "Lambda Pt Bin Values"}; - Configurable antilambdasetting_pt_string{"antilambdasetting_ptbins", {"0_0,0_15,0_3,0_45,0_6,0_75,0_9,1_05,1_2,1_35,1_5,1_65,1_8,1_95,2_1,2_25,2_4,2_55,2_7,2_85,3_0"}, "Antilambda Pt Bin Values"}; + Configurable kzeroSettingPtBinsString{"kzeroSettingPtBinsString", {"0.0,0.15,0.3,0.45,0.6,0.75,0.9,1.05,1.2,1.35,1.5,1.65,1.8,1.95,2.1,2.25,2.4,2.55,2.7,2.85,3.0"}, "Kzero Pt Bin Values"}; + Configurable lambdaSettingPtBinsString{"lambdaSettingPtBinsString", {"0.0,0.15,0.3,0.45,0.6,0.75,0.9,1.05,1.2,1.35,1.5,1.65,1.8,1.95,2.1,2.25,2.4,2.55,2.7,2.85,3.0"}, "Lambda Pt Bin Values"}; + Configurable antilambdaSettingPtBinsString{"antilambdaSettingPtBinsString", {"0.0,0.15,0.3,0.45,0.6,0.75,0.9,1.05,1.2,1.35,1.5,1.65,1.8,1.95,2.1,2.25,2.4,2.55,2.7,2.85,3.0"}, "Antilambda Pt Bin Values"}; void init(InitContext const&) { + pthistos::kaonPt.resize(nmaxHistograms); // number of Kaon Pt histograms to expect + pthistos::lambdaPt.resize(nmaxHistograms); // number of Lambda histograms to expect + pthistos::antilambdaPt.resize(nmaxHistograms); // number of Antilambda histograms to expect + // tokenise strings into individual values + pthistos::kaonPtBins = o2::utils::Str::tokenize(kzeroSettingPtBinsString, ','); + pthistos::lambdaPtBins = o2::utils::Str::tokenize(lambdaSettingPtBinsString, ','); + pthistos::antilambdaPtBins = o2::utils::Str::tokenize(antilambdaSettingPtBinsString, ','); + + // initialize and convert tokenized strings into vector of doubles for AxisSpec + std::vector kaonptedgevalues(nmaxHistograms + 1); + std::vector lambdaptedgevalues(nmaxHistograms + 1); + std::vector antilambdaPtedgevalues(nmaxHistograms + 1); + for (int i = 0; i < nmaxHistograms + 1; i++) { + kaonptedgevalues[i] = std::stod(pthistos::kaonPtBins[i]); + lambdaptedgevalues[i] = std::stod(pthistos::lambdaPtBins[i]); + antilambdaPtedgevalues[i] = std::stod(pthistos::antilambdaPtBins[i]); + } + // Axes - AxisSpec K0ShortMassAxis = {nBins, 0.45f, 0.55f, "#it{M} #pi^{+}#pi^{-} [GeV/#it{c}^{2}]"}; - AxisSpec LambdaMassAxis = {nBins, 1.085f, 1.145f, "#it{M} p^{+}#pi^{-} [GeV/#it{c}^{2}]"}; - AxisSpec AntiLambdaMassAxis = {nBins, 1.085f, 1.145f, "#it{M} p^{-}#pi^{+} [GeV/#it{c}^{2}]"}; - AxisSpec ptAxis = {nBins, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec GenptAxis = {xaxisgenbins, xaxismingenbin, xaxismaxgenbin, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec k0ShortMassAxis = {nBins, 0.45f, 0.55f, "#it{M} #pi^{+}#pi^{-} [GeV/#it{c}^{2}]"}; + AxisSpec lambdaMassAxis = {nBins, 1.085f, 1.145f, "#it{M} p^{+}#pi^{-} [GeV/#it{c}^{2}]"}; + AxisSpec antiLambdaMassAxis = {nBins, 1.085f, 1.145f, "#it{M} p^{-}#pi^{+} [GeV/#it{c}^{2}]"}; + AxisSpec k0ShortPtAxis = {kaonptedgevalues, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec lambdaPtAxis = {lambdaptedgevalues, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec antilambdaPtAxis = {antilambdaPtedgevalues, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec armenterosQtAxis = {nBinsArmenteros, 0.0f, 0.3f, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec armenterosasymAxis = {nBinsArmenteros, -1.f, 1.f, "#it{p}^{+}_{||}-#it{p}^{-}_{||}/#it{p}^{+}_{||}+#it{p}^{-}_{||}"}; + AxisSpec vertexZAxis = {nBins, -11.0f, 11.0f, "vrtx_{Z} [cm]"}; + AxisSpec partCutsAxis{10, 0.0f, 10.0f, "Cut index"}; + + std::vector kaonhistvalue(nmaxHistograms + 1); + std::vector lambdahistvalue(nmaxHistograms + 1); + std::vector antilambdahistvalue(nmaxHistograms + 1); + // K0short Histogram Pt Bin Edges + for (int i = 0; i < nmaxHistograms + 1; i++) { // Histos won't accept "." character so converting it to "_" + std::string kaonptbin = pthistos::kaonPtBins[i]; // getting the value of the bin edge + size_t pos = kaonptbin.find("."); // finding the "." character + kaonptbin[pos] = '_'; // changing the "." character of the string-value to a "_" + kaonhistvalue[i] = kaonptbin; // filling bin edges list + } + // Lambda Histograms Pt Bin Edges (same as K0s above) + for (int i = 0; i < nmaxHistograms + 1; i++) { + std::string lambdaptbin = pthistos::lambdaPtBins[i]; + size_t pos = lambdaptbin.find("."); + lambdaptbin[pos] = '_'; + lambdahistvalue[i] = lambdaptbin; + } + // AntiLambda Histograms Pt Bin Edges (same as K0s above) + for (int i = 0; i < nmaxHistograms + 1; i++) { + std::string antilambdaPtbin = pthistos::antilambdaPtBins[i]; + size_t pos = antilambdaPtbin.find("."); + antilambdaPtbin[pos] = '_'; + antilambdahistvalue[i] = antilambdaPtbin; + } + + // General Plots + rPtAnalysis.add("hNEvents", "hNEvents", {HistType::kTH1D, {{10, 0.f, 10.f}}}); + rPtAnalysis.add("hNRecEvents_Data", "hNRecEvents_Data", {HistType::kTH1D, {{1, 0.f, 1.f}}}); + rPtAnalysis.add("hNV0s", "hNV0s", {HistType::kTH1D, {{10, 0.f, 10.f}}}); + rPtAnalysis.add("hNK0sh", "hNK0sh", {HistType::kTH1D, {{10, 0.f, 10.f}}}); + rPtAnalysis.add("hNLambda", "hNLambda", {HistType::kTH1D, {{10, 0.f, 10.f}}}); + rPtAnalysis.add("hNAntilambda", "hNAntilambda", {HistType::kTH1D, {{10, 0.f, 10.f}}}); - rPtAnalysis.add("hV0PtAll", "hV0PtAll", {HistType::kTH1F, {{nBins, 0.0f, 10.0f}}}); + rPtAnalysis.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + rPtAnalysis.add("hArmenterosPodolanskiPlot", "hArmenterosPodolanskiPlot", {HistType::kTH2F, {{armenterosasymAxis}, {armenterosQtAxis}}}); + rPtAnalysis.add("hV0EtaDaughters", "hV0EtaDaughters", {HistType::kTH1F, {{nBins, -1.2f, 1.2f}}}); + rPtAnalysis.add("V0Rapidity", "V0Rapidity", {HistType::kTH1F, {{nBins, -10.0f, 10.0f}}}); - // setting strings from configurable strings in order to manipulate them - size_t commapos = 0; - std::string token1; // Adding Kzerosh Histograms to registry - if (kzerosh_analysis == true) { - // getting the bin values for the names of the plots for the five topological cuts - std::string kzeroshsetting_ptbins = kzeroshsetting_pt_string; - for (int i = 0; i < 21; i++) { // we have 21 pt values (for the 20 histos) as they are the ranges - commapos = kzeroshsetting_ptbins.find(","); // find comma that separates the values in the string - token1 = kzeroshsetting_ptbins.substr(0, commapos); // store the substring (first individual value) - pthistos::kaonptbins.push_back(token1); // fill the namespace with the value - kzeroshsetting_ptbins.erase(0, commapos + 1); // erase the value from the set string so it moves to the next - } - rPtAnalysis.add("hK0ShortReconstructedPtSpectrum", "hK0ShortReconstructedPtSpectrum", {HistType::kTH1F, {ptAxis}}); - rPtAnalysis.add("hMassK0ShortAll", "hMassK0ShortAll", {HistType::kTH1F, {K0ShortMassAxis}}); - rPtAnalysis.add("hK0ShortPtSpectrumBeforeCuts", "hK0ShortPtSpectrumBeforeCuts", {HistType::kTH1F, {ptAxis}}); - rPtAnalysis.add("hMassK0ShortAllAfterCuts", "hMassK0ShortAllAfterCuts", {HistType::kTH1F, {K0ShortMassAxis}}); - rPtAnalysis.add("hK0ShGeneratedPtSpectrum", "hK0ShGeneratedPtSpectrum", {HistType::kTH1F, {GenptAxis}}); - rPtAnalysis.add("hLambdaGeneratedPtSpectrum", "hLambdaGeneratedPtSpectrum", {HistType::kTH1F, {GenptAxis}}); - rPtAnalysis.add("hAntilambdaGeneratedPtSpectrum", "hAntilambdaGeneratedPtSpectrum", {HistType::kTH1F, {GenptAxis}}); - for (int i = 0; i < 20; i++) { - pthistos::KaonPt[i] = rKaonshMassPlots_per_PtBin.add(fmt::format("hPt_from_{0}_to_{1}", pthistos::kaonptbins[i], pthistos::kaonptbins[i + 1]).data(), fmt::format("hPt from {0} to {1}", pthistos::kaonptbins[i], pthistos::kaonptbins[i + 1]).data(), {HistType::kTH1D, {{K0ShortMassAxis}}}); + if (kzeroAnalysis == true) { + rPtAnalysis.add("hMassK0ShortvsCuts", "hMassK0ShortvsCuts", {HistType::kTH2F, {{partCutsAxis}, {k0ShortMassAxis}}}); + rPtAnalysis.add("hArmenterosPodolanskiPlotK0sh", "hArmenterosPodolanskiPlotK0sh", {HistType::kTH2F, {{armenterosasymAxis}, {armenterosQtAxis}}}); + rPtAnalysis.add("hNSigmaPosPionFromK0s", "hNSigmaPosPionFromK0s", {HistType::kTH2F, {{100, -5.f, 5.f}, {k0ShortPtAxis}}}); + rPtAnalysis.add("hNSigmaNegPionFromK0s", "hNSigmaNegPionFromK0s", {HistType::kTH2F, {{100, -5.f, 5.f}, {k0ShortPtAxis}}}); + rPtAnalysis.add("hK0shV0radius", "hK0shV0radius", {HistType::kTH1F, {{nBins, 0.0f, 50.0f}}}); + rPtAnalysis.add("hK0shcosPA", "hK0shcosPA", {HistType::kTH1F, {{nBins, 0.95f, 1.0f}}}); + rPtAnalysis.add("hK0shDCAV0Daughters", "hK0shDCAV0Daughters", {HistType::kTH1F, {{nBins, 0.0f, 2.2f}}}); + rPtAnalysis.add("hK0shDCAPosDaughter", "hK0shDCAPosDaughter", {HistType::kTH1F, {{nBins, 0.0f, 2.2f}}}); + rPtAnalysis.add("hK0shDCANegDaughter", "hK0shDCANegDaughter", {HistType::kTH1F, {{nBins, 0.0f, 2.2f}}}); + for (int i = 0; i < nmaxHistograms; i++) { + pthistos::kaonPt[i] = rKaonshMassPlotsPerPtBin.add(fmt::format("hPt_from_{0}_to_{1}", kaonhistvalue[i], kaonhistvalue[i + 1]).c_str(), fmt::format("hPt_from_{0}_to_{1}", kaonhistvalue[i], kaonhistvalue[i + 1]).c_str(), {HistType::kTH1D, {{k0ShortMassAxis}}}); } + rFeeddownMatrices.add("hK0shFeeddownMatrix", "hK0shFeeddownMatrix", {HistType::kTH2F, {{k0ShortPtAxis}, {k0ShortPtAxis}}}); + rFeeddownMatrices.add("hK0shPhiFeeddownMatrix", "hK0shPhiFeeddownMatrix", {HistType::kTH2F, {{k0ShortPtAxis}, {k0ShortPtAxis}}}); } // Adding Lambda Histograms - if (lambda_analysis == true) { + if (lambdaAnalysis == true) { // same method as in Kzerosh above - std::string lambdasetting_ptbins = lambdasetting_pt_string; - for (int i = 0; i < 21; i++) { - commapos = lambdasetting_ptbins.find(","); - token1 = lambdasetting_ptbins.substr(0, commapos); - pthistos::lambdaptbins.push_back(token1); - lambdasetting_ptbins.erase(0, commapos + 1); - } - rPtAnalysis.add("hLambdaReconstructedPtSpectrum", "hLambdaReconstructedPtSpectrum", {HistType::kTH1F, {ptAxis}}); - rPtAnalysis.add("hMassLambdaAll", "hMassLambdaAll", {HistType::kTH1F, {LambdaMassAxis}}); - rPtAnalysis.add("hLambdaPtSpectrumBeforeCuts", "hLambdaPtSpectrumBeforeCuts", {HistType::kTH1F, {ptAxis}}); - rPtAnalysis.add("hMassLambdaAllAfterCuts", "hMassLambdaAllAfterCuts", {HistType::kTH1F, {LambdaMassAxis}}); - for (int i = 0; i < 20; i++) { - pthistos::LambdaPt[i] = rLambdaMassPlots_per_PtBin.add(fmt::format("hPt_from_{0}_to_{1}", pthistos::lambdaptbins[i], pthistos::lambdaptbins[i + 1]).data(), fmt::format("hPt from {0} to {1}", pthistos::lambdaptbins[i], pthistos::lambdaptbins[i + 1]).data(), {HistType::kTH1D, {{LambdaMassAxis}}}); + rPtAnalysis.add("hMassLambdavsCuts", "hMassLambdavsCuts", {HistType::kTH2F, {{partCutsAxis}, {k0ShortMassAxis}}}); + rPtAnalysis.add("hArmenterosPodolanskiPlotLambda", "hArmenterosPodolanskiPlotLambda", {HistType::kTH2F, {{armenterosasymAxis}, {armenterosQtAxis}}}); + rPtAnalysis.add("hLambdaAlphaTestPtSpectrum", "hLambdaAlphaTestPtSpectrum", {HistType::kTH1F, {lambdaPtAxis}}); + rPtAnalysis.add("hNSigmaPosProtonFromLambdas", "hNSigmaPosProtonFromLambdas", {HistType::kTH2F, {{100, -5.f, 5.f}, {lambdaPtAxis}}}); + rPtAnalysis.add("hNSigmaNegPionFromLambdas", "hNSigmaNegPionFromLambdas", {HistType::kTH2F, {{100, -5.f, 5.f}, {lambdaPtAxis}}}); + rPtAnalysis.add("hLambdaV0radius", "hLambdaV0radius", {HistType::kTH1F, {{nBins, 0.0f, 50.0f}}}); + rPtAnalysis.add("hLambdacosPA", "hLambdacosPA", {HistType::kTH1F, {{nBins, 0.95f, 1.0f}}}); + rPtAnalysis.add("hLambdaDCAV0Daughters", "hLambdaDCAV0Daughters", {HistType::kTH1F, {{nBins, 0.0f, 2.2f}}}); + rPtAnalysis.add("hLambdaDCAPosDaughter", "hLambdaDCAPosDaughter", {HistType::kTH1F, {{nBins, 0.0f, 2.2f}}}); + rPtAnalysis.add("hLambdaDCANegDaughter", "hLambdaDCANegDaughter", {HistType::kTH1F, {{nBins, 0.0f, 2.2f}}}); + for (int i = 0; i < nmaxHistograms; i++) { + pthistos::lambdaPt[i] = rLambdaMassPlotsPerPtBin.add(fmt::format("hPt_from_{0}_to_{1}", lambdahistvalue[i], lambdahistvalue[i + 1]).c_str(), fmt::format("hPt_from_{0}_to_{1}", lambdahistvalue[i], lambdahistvalue[i + 1]).c_str(), {HistType::kTH1D, {{lambdaMassAxis}}}); } + // lambdafeeddown matrices + rFeeddownMatrices.add("hLambdaFeeddownMatrix", "hLambdaFeeddownMatrix", {HistType::kTH2F, {{lambdaPtAxis}, {lambdaPtAxis}}}); + rFeeddownMatrices.add("hLambdaXiMinusFeeddownMatrix", "hLambdaXiMinusFeeddownMatrix", {HistType::kTH2F, {{lambdaPtAxis}, {lambdaPtAxis}}}); + rFeeddownMatrices.add("hLambdaXiZeroFeeddownMatrix", "hLambdaXiZeroFeeddownMatrix", {HistType::kTH2F, {{lambdaPtAxis}, {lambdaPtAxis}}}); + rFeeddownMatrices.add("hLambdaOmegaFeeddownMatrix", "hLambdaOmegaFeeddownMatrix", {HistType::kTH2F, {{lambdaPtAxis}, {lambdaPtAxis}}}); } // Adding Antilambda Histograms - if (antilambda_analysis == true) { + if (antiLambdaAnalysis == true) { // same method as in Lambda and Kzerosh above - std::string antilambdasetting_ptbins = antilambdasetting_pt_string; - for (int i = 0; i < 21; i++) { - commapos = antilambdasetting_ptbins.find(","); - token1 = antilambdasetting_ptbins.substr(0, commapos); - pthistos::antilambdaptbins.push_back(token1); - antilambdasetting_ptbins.erase(0, commapos + 1); - } - rPtAnalysis.add("hAntilambdaReconstructedPtSpectrum", "hAntilambdaReconstructedPtSpectrum", {HistType::kTH1F, {ptAxis}}); - rPtAnalysis.add("hMassAntilambdaAll", "hMassAntilambdaAll", {HistType::kTH1F, {AntiLambdaMassAxis}}); - rPtAnalysis.add("hAntilambdaPtSpectrumBeforeCuts", "hAntilambdaPtSpectrumBeforeCuts", {HistType::kTH1F, {ptAxis}}); - rPtAnalysis.add("hMassAntilambdaAllAfterCuts", "hMassAntilambdaAllAfterCuts", {HistType::kTH1F, {AntiLambdaMassAxis}}); - for (int i = 0; i < 20; i++) { - pthistos::AntilambdaPt[i] = rAntilambdaMassPlots_per_PtBin.add(fmt::format("hPt_from_{0}_to_{1}", pthistos::antilambdaptbins[i], pthistos::antilambdaptbins[i + 1]).data(), fmt::format("hPt from {0} to {1}", pthistos::antilambdaptbins[i], pthistos::antilambdaptbins[i + 1]).data(), {HistType::kTH1D, {{AntiLambdaMassAxis}}}); + rPtAnalysis.add("hMassAntilambdavsCuts", "hMassAntilambdavsCuts", {HistType::kTH2F, {{partCutsAxis}, {k0ShortMassAxis}}}); + rPtAnalysis.add("hArmenterosPodolanskiPlotAntilambda", "hArmenterosPodolanskiPlotAntilambda", {HistType::kTH2F, {{armenterosasymAxis}, {armenterosQtAxis}}}); + rPtAnalysis.add("hAntilambdaAlphaTestPtSpectrum", "hAntilambdaAlphaTestPtSpectrum", {HistType::kTH1F, {antilambdaPtAxis}}); + rPtAnalysis.add("hNSigmaPosPionFromAntilambdas", "hNSigmaPosPionFromAntilambdas", {HistType::kTH2F, {{100, -5.f, 5.f}, {antilambdaPtAxis}}}); + rPtAnalysis.add("hNSigmaNegProtonFromAntilambdas", "hNSigmaNegProtonFromAntilambdas", {HistType::kTH2F, {{100, -5.f, 5.f}, {antilambdaPtAxis}}}); + rPtAnalysis.add("hAntilambdaV0radius", "hAntilambdaV0radius", {HistType::kTH1F, {{nBins, 0.0f, 50.0f}}}); + rPtAnalysis.add("hAntilambdacosPA", "hAntilambdacosPA", {HistType::kTH1F, {{nBins, 0.95f, 1.0f}}}); + rPtAnalysis.add("hAntilambdaDCAV0Daughters", "hAntilambdaDCAV0Daughters", {HistType::kTH1F, {{nBins, 0.0f, 2.2f}}}); + rPtAnalysis.add("hAntilambdaDCAPosDaughter", "hAntilambdaDCAPosDaughter", {HistType::kTH1F, {{nBins, 0.0f, 2.2f}}}); + rPtAnalysis.add("hAntilambdaDCANegDaughter", "hAntilambdaDCANegDaughter", {HistType::kTH1F, {{nBins, 0.0f, 2.2f}}}); + for (int i = 0; i < nmaxHistograms; i++) { + pthistos::antilambdaPt[i] = rAntilambdaMassPlotsPerPtBin.add(fmt::format("hPt_from_{0}_to_{1}", antilambdahistvalue[i], antilambdahistvalue[i + 1]).c_str(), fmt::format("hPt_from_{0}_to_{1}", antilambdahistvalue[i], antilambdahistvalue[i + 1]).c_str(), {HistType::kTH1D, {{antiLambdaMassAxis}}}); } + // antilambdafeeddown matrices + rFeeddownMatrices.add("hAntiLambdaFeeddownMatrix", "hAntiLambdaFeeddownMatrix", {HistType::kTH2F, {{antilambdaPtAxis}, {antilambdaPtAxis}}}); + rFeeddownMatrices.add("hAntiLambdaXiPlusFeeddownMatrix", "hAntiLambdaXiPlusFeeddownMatrix", {HistType::kTH2F, {{antilambdaPtAxis}, {antilambdaPtAxis}}}); + rFeeddownMatrices.add("hAntiLambdaAntiXiZeroFeeddownMatrix", "hAntiLambdaAntiXiZeroFeeddownMatrix", {HistType::kTH2F, {{antilambdaPtAxis}, {antilambdaPtAxis}}}); + rFeeddownMatrices.add("hAntiLambdaAntiOmegaFeeddownMatrix", "hAntiLambdaAntiOmegaPlusFeeddownMatrix", {HistType::kTH2F, {{antilambdaPtAxis}, {antilambdaPtAxis}}}); } + + // Particle Level Corrections + rMCCorrections.add("hK0ShSplitDenominatorPtSpectrum", "hK0ShSplitDenominatorPtSpectrum", {HistType::kTH1D, {k0ShortPtAxis}}); + rMCCorrections.add("hLambdaSplitDenominatorPtSpectrum", "hLambdaSplitDenominatorPtSpectrum", {HistType::kTH1D, {lambdaPtAxis}}); + rMCCorrections.add("hAntilambdaSplitDenominatorPtSpectrum", "hAntilambdaSplitDenominatorPtSpectrum", {HistType::kTH1F, {{antilambdaPtAxis}}}); + rMCCorrections.add("hK0ShSplitNumenatorPtSpectrum", "hK0ShSplitNumenatorPtSpectrum", {HistType::kTH1D, {k0ShortPtAxis}}); + rMCCorrections.add("hLambdaSplitNumenatorPtSpectrum", "hLambdaSplitNumenatorPtSpectrum", {HistType::kTH1D, {lambdaPtAxis}}); + rMCCorrections.add("hAntilambdaSplitNumenatorPtSpectrum", "hAntilambdaSplitNumenatorPtSpectrum", {HistType::kTH1F, {{antilambdaPtAxis}}}); + rMCCorrections.add("hK0ShBeforeEventSelectionPtSpectrum", "hK0ShBeforeEventSelectionPtSpectrum", {HistType::kTH1D, {k0ShortPtAxis}}); + rMCCorrections.add("hLambdaBeforeEventSelectionPtSpectrum", "hLambdaBeforeEventSelectionPtSpectrum", {HistType::kTH1D, {lambdaPtAxis}}); + rMCCorrections.add("hAntilambdaBeforeEventSelectionPtSpectrum", "hAntilambdaBeforeEventSelectionPtSpectrum", {HistType::kTH1F, {{antilambdaPtAxis}}}); + rMCCorrections.add("hK0ShAfterEventSelectionPtSpectrum", "hK0ShAfterEventSelectionPtSpectrum", {HistType::kTH1D, {k0ShortPtAxis}}); + rMCCorrections.add("hLambdaAfterEventSelectionPtSpectrum", "hLambdaAfterEventSelectionPtSpectrum", {HistType::kTH1D, {lambdaPtAxis}}); + rMCCorrections.add("hAntilambdaAfterEventSelectionPtSpectrum", "hAntilambdaAfterEventSelectionPtSpectrum", {HistType::kTH1F, {{antilambdaPtAxis}}}); + + // Event and V0s Corrections + rMCCorrections.add("hNEvents_Corrections", "hNEvents_Corrections", {HistType::kTH1D, {{10, 0.f, 10.f}}}); + rMCCorrections.add("hNRecEvents_MC", "hNRecEvents_MC", {HistType::kTH1D, {{1, 0.f, 1.f}}}); + + // Generated Level Pt Spectrums (with rapidity cut) + rMCCorrections.add("GenParticleRapidity", "GenParticleRapidity", {HistType::kTH1F, {{nBins, -10.0f, 10.0f}}}); + rMCCorrections.add("hK0ShGeneratedPtSpectrum", "hK0ShGeneratedPtSpectrum", {HistType::kTH1F, {k0ShortPtAxis}}); + rMCCorrections.add("hLambdaGeneratedPtSpectrum", "hLambdaGeneratedPtSpectrum", {HistType::kTH1F, {lambdaPtAxis}}); + rMCCorrections.add("hAntilambdaGeneratedPtSpectrum", "hAntilambdaGeneratedPtSpectrum", {HistType::kTH1F, {{antilambdaPtAxis}}}); + rMCCorrections.add("hXiMinusGeneratedPtSpectrum", "hXiMinusGeneratedPtSpectrum", {HistType::kTH1F, {lambdaPtAxis}}); + rMCCorrections.add("hXiZeroGeneratedPtSpectrum", "hXiZeroGeneratedPtSpectrum", {HistType::kTH1F, {lambdaPtAxis}}); + rMCCorrections.add("hOmegaGeneratedPtSpectrum", "hOmegaGeneratedPtSpectrum", {HistType::kTH1F, {lambdaPtAxis}}); + rMCCorrections.add("hXiPlusGeneratedPtSpectrum", "hXiPlusGeneratedPtSpectrum", {HistType::kTH1F, {antilambdaPtAxis}}); + rMCCorrections.add("hAntiXiZeroGeneratedPtSpectrum", "hAntiXiZeroGeneratedPtSpectrum", {HistType::kTH1F, {antilambdaPtAxis}}); + rMCCorrections.add("hAntiOmegaGeneratedPtSpectrum", "hAntiOmegaGeneratedPtSpectrum", {HistType::kTH1F, {antilambdaPtAxis}}); + rMCCorrections.add("hPhiGeneratedPtSpectrum", "hPhiGeneratedPtSpectrum", {HistType::kTH1F, {k0ShortPtAxis}}); } - // Defining filters for events (event selection) - // Processed events will be already fulfilling the event selection requirements - Filter eventFilter = (o2::aod::evsel::sel8 == true); - Filter posZFilterMC = (nabs(o2::aod::mccollision::posZ) < 10.0f); - Filter posZFilter = (nabs(o2::aod::collision::posZ) < 10.0f); + // Event selection function + template + bool acceptEvent(TCollision const& collision) + { + rPtAnalysis.fill(HIST("hNEvents"), 0.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "All"); + if (!(collision.sel8() && dosel8)) { + return false; + } + rPtAnalysis.fill(HIST("hNEvents"), 1.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "sel 8"); + if (!(collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && doNoTimeFrameBorder)) { + return false; + } + rPtAnalysis.fill(HIST("hNEvents"), 2.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "NoTimeFrameBorder"); + if (!(collision.selection_bit(aod::evsel::kNoITSROFrameBorder) && doNoITSROFrameBorder)) { + return false; + } + rPtAnalysis.fill(HIST("hNEvents"), 3.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(4, "NoITSROFrameBorder"); + if (!(collision.selection_bit(aod::evsel::kIsTriggerTVX) && doIsTriggerTVX)) { + return false; + } + rPtAnalysis.fill(HIST("hNEvents"), 4.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(5, "IsTriggerTVX"); + if (!(std::abs(collision.posZ()) < cutZVertex && docutZVertex)) { + return false; + } + rPtAnalysis.fill(HIST("hNEvents"), 5.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(6, "cutZVertex"); + if (!(collision.selection_bit(aod::evsel::kIsVertexTOFmatched) && doIsVertexTOFmatched)) { + return false; + } + rPtAnalysis.fill(HIST("hNEvents"), 6.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(7, "IsVertexTOFmatched"); + if (!(collision.selection_bit(aod::evsel::kNoSameBunchPileup) && doNoSameBunchPileup)) { + return false; + } + rPtAnalysis.fill(HIST("hNEvents"), 7.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(8, "NoSameBunchPileup"); + if (!(collision.selection_bit(aod::evsel::kIsVertexITSTPC) && doIsVertexITSTPC)) { + return false; + } + rPtAnalysis.fill(HIST("hNEvents"), 8.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(9, "IsVertexITSTPC"); + if (!(collision.isInelGt0() && doisInelGt0)) { + return false; + } + rPtAnalysis.fill(HIST("hNEvents"), 9.5); + rPtAnalysis.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(10, "isInelGt0"); + return true; + + // Cut Plots + rPtAnalysis.fill(HIST("hVertexZRec"), collision.posZ()); + } + + // V0 selection function + template + bool acceptV0(TV0 const& v0) + { + const auto& posDaughterTrack = v0.template posTrack_as(); // Positive Daughter track + const auto& negDaughterTrack = v0.template negTrack_as(); // Negative Daughter track + + rPtAnalysis.fill(HIST("hNV0s"), 0.5); + rPtAnalysis.get(HIST("hNV0s"))->GetXaxis()->SetBinLabel(1, "All V0s"); + if (std::abs(v0.y()) > rapidityCut && doRapidityCut) { // V0 Rapidity Cut + return false; + } + rPtAnalysis.fill(HIST("hNV0s"), 1.5); + rPtAnalysis.get(HIST("hNV0s"))->GetXaxis()->SetBinLabel(2, "Rapidity"); + if ((std::abs(posDaughterTrack.eta()) > etadau && std::abs(negDaughterTrack.eta()) > etadau) && doDaughterPseudorapidityCut) { // Daughters Pseudorapidity Cut + return false; + } + rPtAnalysis.fill(HIST("hNV0s"), 2.5); + rPtAnalysis.get(HIST("hNV0s"))->GetXaxis()->SetBinLabel(3, "Dau Pseudorapidity"); + if ((posDaughterTrack.isITSAfterburner() || negDaughterTrack.isITSAfterburner()) && !doisITSAfterburner) { // ITS After Burner on daughter tracks + return false; + } + rPtAnalysis.fill(HIST("hNV0s"), 3.5); + rPtAnalysis.get(HIST("hNV0s"))->GetXaxis()->SetBinLabel(4, "ITS Afterburner"); + if (posDaughterTrack.itsNCls() <= itsMinHits && negDaughterTrack.itsNCls() <= itsMinHits && doitsMinHits) { // Minimum hits in the ITS + return false; + rPtAnalysis.fill(HIST("hNV0s"), 4.5); + rPtAnalysis.get(HIST("hNV0s"))->GetXaxis()->SetBinLabel(5, "ITS Min Hits"); + // Cut Plots + rPtAnalysis.fill(HIST("V0Rapidity"), v0.y()); + rPtAnalysis.fill(HIST("hV0EtaDaughters"), v0.template posTrack_as().eta()); + rPtAnalysis.fill(HIST("hV0EtaDaughters"), v0.template negTrack_as().eta()); + } + return true; + } + + // K0sh selection function + template + bool acceptK0sh(TV0 const& v0) + { + const auto& posDaughterTrack = v0.template posTrack_as(); // Positive Daughter track + const auto& negDaughterTrack = v0.template negTrack_as(); // Negative Daughter track + + rPtAnalysis.fill(HIST("hNK0sh"), 0.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(1, "All"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 0.5, v0.mK0Short()); + if ((std::abs(posDaughterTrack.tpcNSigmaPi()) > nSigmaTPCPion && std::abs(negDaughterTrack.tpcNSigmaPi()) > nSigmaTPCPion) && doK0shTPCPID) { // TPC PID for two pions + return false; + } + rPtAnalysis.fill(HIST("hNK0sh"), 1.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(2, "TPC_PID"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 1.5, v0.mK0Short()); + if (std::abs(v0.mLambda() - o2::constants::physics::MassLambda0) < compv0masscut && std::abs(v0.mAntiLambda() - o2::constants::physics::MassLambda0) < compv0masscut && doK0shcomptmasscut) { // Kzero competitive v0 mass cut (cut out Lambdas and Anti-Lambdas) + return false; + } + rPtAnalysis.fill(HIST("hNK0sh"), 2.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(3, "Compt_Mass"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 2.5, v0.mK0Short()); + if (v0.v0radius() > kaonshmaxct && doK0shMaxct) { // K0sh max ct + return false; + } + rPtAnalysis.fill(HIST("hNK0sh"), 3.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(4, "Max_ct"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 3.5, v0.mK0Short()); + if (v0.qtarm() < (k0shparamArmenterosCut * std::abs(v0.alpha())) && doK0shArmenterosCut) { // K0sh Armenteros Cut + return false; + } + rPtAnalysis.fill(HIST("hNK0sh"), 4.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(5, "Armenteros"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 4.5, v0.mK0Short()); + if (v0.v0cosPA() < kaonshSettingcosPA && doK0shcosPACut) { // K0sh cosPA Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNK0sh"), 5.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(6, "cosPA"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 5.5, v0.mK0Short()); + if (v0.dcaV0daughters() > kaonshSettingdcav0dau && doK0shDCAdauCut) { // K0sh DCAdaughters Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNK0sh"), 6.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(7, "DCAdau"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 6.5, v0.mK0Short()); + if (v0.v0radius() < kaonshSettingradius && doK0shv0radiusCut) { // K0sh v0radius Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNK0sh"), 7.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(8, "v0radius"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 7.5, v0.mK0Short()); + if (std::abs(v0.dcapostopv()) < kaonshSettingdcapostopv && doK0shdcaposdautopv) { // K0sh DCAPosDaughterToPV Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNK0sh"), 8.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(9, "DCAPosDautoPV"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 8.5, v0.mK0Short()); + if (std::abs(v0.dcanegtopv()) < kaonshSettingdcanegtopv && doK0shdcanegdautopv) { // K0sh DCANegDaughterToPV Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNK0sh"), 9.5); + rPtAnalysis.get(HIST("hNK0sh"))->GetXaxis()->SetBinLabel(10, "DCANegDautoPV"); + rPtAnalysis.fill(HIST("hMassK0ShortvsCuts"), 9.5, v0.mK0Short()); + + // Cut Plots + rPtAnalysis.fill(HIST("hArmenterosPodolanskiPlotK0sh"), v0.alpha(), v0.qtarm()); + rPtAnalysis.fill(HIST("hNSigmaPosPionFromK0s"), posDaughterTrack.tpcNSigmaPi(), posDaughterTrack.tpcInnerParam()); + rPtAnalysis.fill(HIST("hNSigmaNegPionFromK0s"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam()); + rPtAnalysis.fill(HIST("hK0shcosPA"), v0.v0cosPA()); + rPtAnalysis.fill(HIST("hK0shV0radius"), v0.v0radius()); + rPtAnalysis.fill(HIST("hK0shDCAV0Daughters"), v0.dcaV0daughters()); + rPtAnalysis.fill(HIST("hK0shDCAPosDaughter"), v0.dcapostopv()); + rPtAnalysis.fill(HIST("hK0shDCANegDaughter"), v0.dcanegtopv()); + return true; + } + + // Lambda selection function + template + bool acceptLambda(TV0 const& v0) + { + const auto& posDaughterTrack = v0.template posTrack_as(); // Positive Daughter track + const auto& negDaughterTrack = v0.template negTrack_as(); // Negative Daughter track + + rPtAnalysis.fill(HIST("hNLambda"), 0.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(1, "All"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 0.5, v0.mLambda()); + if (std::abs(posDaughterTrack.tpcNSigmaPr()) > nSigmaTPCProton && std::abs(negDaughterTrack.tpcNSigmaPi()) > nSigmaTPCPion && doLambdaTPCPID) { // TPC PID on daughter pion and proton for Lambda + return false; + } + rPtAnalysis.fill(HIST("hNLambda"), 1.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(2, "TPC_PID"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 1.5, v0.mLambda()); + if (std::abs(v0.mK0Short() - o2::constants::physics::MassK0Short) < compv0masscut && doLambdacomptmasscut) { // Lambda competitive v0 mass cut (cut out Kaons) + return false; + } + rPtAnalysis.fill(HIST("hNLambda"), 2.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(3, "Compt_Mass"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 2.5, v0.mLambda()); + if (v0.v0radius() > lambdamaxct && doLambdaMaxct) { // Lambda max ct + return false; + } + rPtAnalysis.fill(HIST("hNLambda"), 3.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(4, "Max_ct"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 3.5, v0.mLambda()); + if (v0.qtarm() < (lambdaparamArmenterosCut * std::abs(v0.alpha())) && doLambdaArmenterosCut) { // Lambda Armenteros Cut + return false; + } + rPtAnalysis.fill(HIST("hNLambda"), 4.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(5, "Armenteros"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 4.5, v0.mLambda()); + if (v0.v0cosPA() < lambdaSettingcosPA && doLambdacosPACut) { // Lambda cosPA Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNLambda"), 5.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(6, "cosPA"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 5.5, v0.mLambda()); + if (v0.dcaV0daughters() > lambdaSettingdcav0dau && doLambdaDCAdauCut) { // Lambda DCAdaughters Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNLambda"), 6.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(7, "DCAdau"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 6.5, v0.mLambda()); + if (v0.v0radius() < lambdaSettingradius && doLambdav0radiusCut) { // Lambda v0radius Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNLambda"), 7.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(8, "v0radius"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 7.5, v0.mLambda()); + if (std::abs(v0.dcapostopv()) < lambdaSettingdcapostopv && doLambdadcaposdautopv) { // Lambda DCAPosDaughterToPV Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNLambda"), 8.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(9, "DCAPosDautoPV"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 8.5, v0.mLambda()); + if (std::abs(v0.dcanegtopv()) < lambdaSettingdcanegtopv && doLambdadcanegdautopv) { // Lambda DCANegDaughterToPV Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNLambda"), 9.5); + rPtAnalysis.get(HIST("hNLambda"))->GetXaxis()->SetBinLabel(10, "DCANegDautoPV"); + rPtAnalysis.fill(HIST("hMassLambdavsCuts"), 9.5, v0.mLambda()); + + // Cut Plots + rPtAnalysis.fill(HIST("hArmenterosPodolanskiPlotLambda"), v0.alpha(), v0.qtarm()); + rPtAnalysis.fill(HIST("hNSigmaPosProtonFromLambdas"), posDaughterTrack.tpcNSigmaPr(), posDaughterTrack.tpcInnerParam()); + rPtAnalysis.fill(HIST("hNSigmaNegPionFromLambdas"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam()); + rPtAnalysis.fill(HIST("hLambdacosPA"), v0.v0cosPA()); + rPtAnalysis.fill(HIST("hLambdaV0radius"), v0.v0radius()); + rPtAnalysis.fill(HIST("hLambdaDCAV0Daughters"), v0.dcaV0daughters()); + rPtAnalysis.fill(HIST("hLambdaDCAPosDaughter"), v0.dcapostopv()); + rPtAnalysis.fill(HIST("hLambdaDCANegDaughter"), v0.dcanegtopv()); + return true; + } + + // Antilambda selection function + template + bool acceptAntilambda(TV0 const& v0) + { + const auto& posDaughterTrack = v0.template posTrack_as(); // Positive Daughter track + const auto& negDaughterTrack = v0.template negTrack_as(); // Negative Daughter track + + rPtAnalysis.fill(HIST("hNAntilambda"), 0.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(1, "All"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 0.5, v0.mAntiLambda()); + if (std::abs(negDaughterTrack.tpcNSigmaPr()) > nSigmaTPCProton && std::abs(posDaughterTrack.tpcNSigmaPi()) > nSigmaTPCPion) { // TPC PID on daughter pion and proton for AntiLambda + return false; + } + rPtAnalysis.fill(HIST("hNAntilambda"), 1.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(2, "TPC_PID"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 1.5, v0.mAntiLambda()); + if (std::abs(v0.mK0Short() - o2::constants::physics::MassK0Short) < compv0masscut && doAntilambdacomptmasscut) { // Antilambda competitive v0 mass cut (cut out Kaons) + return false; + } + rPtAnalysis.fill(HIST("hNAntilambda"), 2.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(3, "Compt_Mass"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 2.5, v0.mAntiLambda()); + if (v0.v0radius() > antilambdamaxct && doAntilambdaMaxct) { // Antilambda max ct + return false; + } + rPtAnalysis.fill(HIST("hNAntilambda"), 3.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(4, "Max_ct"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 3.5, v0.mAntiLambda()); + if (v0.qtarm() < (antilambdaparamArmenterosCut * std::abs(v0.alpha())) && doAntilambdaArmenterosCut) { // Antilambda Armenteros Cut + return false; + } + rPtAnalysis.fill(HIST("hNAntilambda"), 4.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(5, "Armenteros"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 4.5, v0.mAntiLambda()); + if (v0.v0cosPA() < antilambdaSettingcosPA && doAntilambdacosPACut) { // Antilambda cosPA Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNAntilambda"), 5.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(6, "cosPA"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 5.5, v0.mAntiLambda()); + if (v0.dcaV0daughters() > antilambdaSettingdcav0dau && doAntilambdaDCAdauCut) { // Antilambda DCAdaughters Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNAntilambda"), 6.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(7, "DCAdau"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 6.5, v0.mAntiLambda()); + if (v0.v0radius() < antilambdaSettingradius && doAntilambdav0radiusCut) { // Antilambda v0radius Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNAntilambda"), 7.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(8, "v0radius"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 7.5, v0.mAntiLambda()); + if (std::abs(v0.dcapostopv()) < antilambdaSettingdcapostopv && doAntilambdadcaposdautopv) { // Antilambda DCAPosDaughterToPV Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNAntilambda"), 8.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(9, "DCAPosDautoPV"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 8.5, v0.mAntiLambda()); + if (std::abs(v0.dcanegtopv()) < antilambdaSettingdcanegtopv && doAntilambdadcanegdautopv) { // Antilambda DCANegDaughterToPV Topological Cut + return false; + } + rPtAnalysis.fill(HIST("hNAntilambda"), 9.5); + rPtAnalysis.get(HIST("hNAntilambda"))->GetXaxis()->SetBinLabel(10, "DCANegDautoPV"); + rPtAnalysis.fill(HIST("hMassAntilambdavsCuts"), 9.5, v0.mAntiLambda()); + + // Cut plots + rPtAnalysis.fill(HIST("hArmenterosPodolanskiPlotAntilambda"), v0.alpha(), v0.qtarm()); + rPtAnalysis.fill(HIST("hNSigmaPosPionFromAntilambdas"), posDaughterTrack.tpcNSigmaPr(), posDaughterTrack.tpcInnerParam()); + rPtAnalysis.fill(HIST("hNSigmaNegProtonFromAntilambdas"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam()); + rPtAnalysis.fill(HIST("hAntilambdacosPA"), v0.v0cosPA()); + rPtAnalysis.fill(HIST("hAntilambdaV0radius"), v0.v0radius()); + rPtAnalysis.fill(HIST("hAntilambdaDCAV0Daughters"), v0.dcaV0daughters()); + rPtAnalysis.fill(HIST("hAntilambdaDCAPosDaughter"), v0.dcapostopv()); + rPtAnalysis.fill(HIST("hAntilambdaDCANegDaughter"), v0.dcanegtopv()); + return true; + } // Defining the type of the daughter tracks - using DaughterTracks = soa::Join; + using DaughterTracks = soa::Join; - // This is the Process for the MC Generated Data - void GenMCprocess(soa::Filtered::iterator const&, - const soa::SmallGroups>&, - aod::McParticles const& mcParticles) + void genMCProcess( + aod::McCollisions::iterator const& /*mcCollisions*/, + soa::SmallGroups> const& collisions, + aod::McParticles const& mcParticles) { + // Event Efficiency, Event Split and V0 Signal Loss Corrections + rMCCorrections.fill(HIST("hNEvents_Corrections"), 0.5); // Event Efficiency Denominator + + // Particles (of interest) Generated Pt Spectrum and Signal Loss Denominator Loop for (const auto& mcParticle : mcParticles) { - if (mcParticle.isPhysicalPrimary()) { - if (TMath::Abs(mcParticle.y()) < 0.5f) { - if (mcParticle.pdgCode() == 310) // kzero matched + if (std::abs(mcParticle.y()) < rapidityCut) { + if (mcParticle.isPhysicalPrimary()) { + rMCCorrections.fill(HIST("GenParticleRapidity"), mcParticle.y()); + if (mcParticle.pdgCode() == kK0Short) // kzero matched + { + rMCCorrections.fill(HIST("hK0ShGeneratedPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kLambda0) // lambda matched + { + rMCCorrections.fill(HIST("hLambdaGeneratedPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kLambda0Bar) // antilambda matched + { + rMCCorrections.fill(HIST("hAntilambdaGeneratedPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kXiMinus) // Xi Minus matched + { + rMCCorrections.fill(HIST("hXiMinusGeneratedPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kXi0) // Xi Zero matched + { + rMCCorrections.fill(HIST("hXiZeroGeneratedPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kOmegaMinus) // Omega matched + { + rMCCorrections.fill(HIST("hOmegaGeneratedPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kXiPlusBar) // Xi Plus matched { - rPtAnalysis.fill(HIST("hK0ShGeneratedPtSpectrum"), mcParticle.pt()); + rMCCorrections.fill(HIST("hXiPlusGeneratedPtSpectrum"), mcParticle.pt()); } - if (mcParticle.pdgCode() == 3122) // lambda matched + if (mcParticle.pdgCode() == -kXi0) // Anti-Xi Zero matched { - rPtAnalysis.fill(HIST("hLambdaGeneratedPtSpectrum"), mcParticle.pt()); + rMCCorrections.fill(HIST("hAntiXiZeroGeneratedPtSpectrum"), mcParticle.pt()); } - if (mcParticle.pdgCode() == -3122) // antilambda matched + if (mcParticle.pdgCode() == kOmegaPlusBar) // Anti-Omega matched { - rPtAnalysis.fill(HIST("hAntilambdaGeneratedPtSpectrum"), mcParticle.pt()); + rMCCorrections.fill(HIST("hAntiOmegaGeneratedPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kPhi) // Phi + { + rMCCorrections.fill(HIST("hPhiGeneratedPtSpectrum"), mcParticle.pt()); } } } } + // Signal Loss Numenator Loop + for (const auto& collision : collisions) { + rMCCorrections.fill(HIST("hNEvents_Corrections"), 1.5); // Number of Events Reconsctructed + if (!acceptEvent(collision)) { // Event Selection + return; + } + rMCCorrections.fill(HIST("hNEvents_Corrections"), 2.5); // Event Split Denomimator and Event Efficiency Numenator + for (const auto& mcParticle : mcParticles) { + if (!mcParticle.isPhysicalPrimary()) { + continue; + } + if (std::abs(mcParticle.y()) > rapidityCut) { + continue; + } + if (mcParticle.pdgCode() == kK0Short) // kzero matched + { + rMCCorrections.fill(HIST("hK0ShAfterEventSelectionPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kLambda0) // lambda matched + { + rMCCorrections.fill(HIST("hLambdaAfterEventSelectionPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kLambda0Bar) // antilambda matched + { + rMCCorrections.fill(HIST("hAntilambdaAfterEventSelectionPtSpectrum"), mcParticle.pt()); + } + } + } + // End of Signal Loss Numenator Loop } // This is the Process for the MC reconstructed Data - void RecMCprocess(soa::Filtered>::iterator const&, + void recMCProcess(soa::Join::iterator const& collision, soa::Join const& V0s, DaughterTracks const&, // no need to define a variable for tracks, if we don't access them directly - aod::McParticles const& /*mcParticles*/) + aod::McParticles const& mcParticles) { + // tokenise strings into individual values + pthistos::kaonPtBins = o2::utils::Str::tokenize(kzeroSettingPtBinsString, ','); + pthistos::lambdaPtBins = o2::utils::Str::tokenize(lambdaSettingPtBinsString, ','); + pthistos::antilambdaPtBins = o2::utils::Str::tokenize(antilambdaSettingPtBinsString, ','); + + // initialize and convert tokenized strings into vector of doubles for Pt Bin Edges + std::vector kaonptedgevalues(nmaxHistograms + 1); + std::vector lambdaptedgevalues(nmaxHistograms + 1); + std::vector antilambdaPtedgevalues(nmaxHistograms + 1); + + for (int i = 0; i < nmaxHistograms + 1; i++) { + kaonptedgevalues[i] = std::stod(pthistos::kaonPtBins[i]); + lambdaptedgevalues[i] = std::stod(pthistos::lambdaPtBins[i]); + antilambdaPtedgevalues[i] = std::stod(pthistos::antilambdaPtBins[i]); + } + if (!acceptEvent(collision)) { // Event Selection + return; + } + rMCCorrections.fill(HIST("hNRecEvents_MC"), 0.5); // Event Split Numenator + + // v0 Signal Splitting Numenator Start + for (const auto& mcParticle : mcParticles) { + if (mcParticle.isPhysicalPrimary()) { + if (std::abs(mcParticle.y()) < rapidityCut) { + if (mcParticle.pdgCode() == kK0Short) { // kzero matched + rMCCorrections.fill(HIST("hK0ShSplitNumenatorPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kLambda0) { // lambda matched + rMCCorrections.fill(HIST("hLambdaSplitNumenatorPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == kLambda0Bar) { // antilambda matched + rMCCorrections.fill(HIST("hAntilambdaSplitNumenatorPtSpectrum"), mcParticle.pt()); + } + } + } + } + // V0 Signal Splitting Numenator End + for (const auto& v0 : V0s) { - rPtAnalysis.fill(HIST("hV0PtAll"), v0.pt()); // Checking that the V0 is a true K0s/Lambdas/Antilambdas and then filling the parameter histograms and the invariant mass plots for different cuts (which are taken from namespace) if (v0.has_mcParticle()) { auto v0mcParticle = v0.mcParticle(); + + // signal splitting demoninator if (v0mcParticle.isPhysicalPrimary()) { - if (kzerosh_analysis == true) { - if (v0mcParticle.pdgCode() == 310) { // kzero matched - rPtAnalysis.fill(HIST("hMassK0ShortAll"), v0.mK0Short()); - rPtAnalysis.fill(HIST("hK0ShortPtSpectrumBeforeCuts"), v0.pt()); - // Implementing best kzero cuts - if (v0.v0cosPA() > kaonshsetting_cospa && v0.dcaV0daughters() < kaonshsetting_dcav0dau && v0.v0radius() > kaonshsetting_radius && TMath::Abs(v0.dcapostopv()) > kaonshsetting_dcapostopv && TMath::Abs(v0.dcanegtopv()) > kaonshsetting_dcanegtopv) { - rPtAnalysis.fill(HIST("hMassK0ShortAllAfterCuts"), v0.mK0Short()); - rPtAnalysis.fill(HIST("hK0ShortReconstructedPtSpectrum"), v0.pt()); - for (int i = 0; i < 20; i++) { - // getting the pt value in #_# for and converting it to a number #.# for use, we get two values which correspond to the range of each bin - std::string pt1 = pthistos::kaonptbins[i]; // getting the lower string-value of the bin - std::string pt2 = pthistos::kaonptbins[i + 1]; // getting the higher string-value of the bin - size_t pos1 = pt1.find("_"); // finding the "_" character of the lower string-value - size_t pos2 = pt2.find("_"); // finding the "_" character of the higher string-value - pt1[pos1] = '.'; // changing the "_" character of the lower string-value to a "." - pt2[pos2] = '.'; // changing the "_" character of the higher string-value to a "." - const float ptlowervalue = std::stod(pt1); // converting the lower string value to a double - const float pthighervalue = std::stod(pt2); // converting the higher string value to a double - if (ptlowervalue <= v0.pt() && v0.pt() < pthighervalue) { // finding v0s with pt withing the range of our lower and higher value - pthistos::KaonPt[i]->Fill(v0.mK0Short()); // filling the 20 kaon namespace histograms - } + if (v0mcParticle.pdgCode() == kK0Short) { // kzero matched + rMCCorrections.fill(HIST("hK0ShSplitDenominatorPtSpectrum"), v0mcParticle.pt()); + } + if (v0mcParticle.pdgCode() == kLambda0) { // lambda matched + rMCCorrections.fill(HIST("hLambdaSplitDenominatorPtSpectrum"), v0mcParticle.pt()); + } + if (v0mcParticle.pdgCode() == kLambda0Bar) { // antilambda matched + rMCCorrections.fill(HIST("hAntilambdaSplitDenominatorPtSpectrum"), v0mcParticle.pt()); + } + } + // signal splitting demoninator end + + if (!acceptV0(v0)) { // V0 Selections + continue; + } + rPtAnalysis.fill(HIST("hArmenterosPodolanskiPlot"), v0.alpha(), v0.qtarm()); + // kzero analysis + if (kzeroAnalysis == true) { + if (v0mcParticle.pdgCode() == kK0Short) { // kzero matched + if (!acceptK0sh(v0)) { // K0sh Selection + continue; + } + + if (v0mcParticle.isPhysicalPrimary()) { + for (int i = 0; i < nmaxHistograms; i++) { + if (kaonptedgevalues[i] <= v0.pt() && v0.pt() < kaonptedgevalues[i + 1]) { // finding v0s with pt within the range of our bin edges + pthistos::kaonPt[i]->Fill(v0.mK0Short()); // filling the k0s namespace histograms + } + } + } + if (!v0mcParticle.isPhysicalPrimary()) { + auto v0mothers = v0mcParticle.mothers_as(); // Get mothers + if (!v0mothers.empty()) { + auto& v0mcParticleMother = v0mothers.front(); // First mother + rFeeddownMatrices.fill(HIST("hK0shFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + if (v0mcParticleMother.pdgCode() == kPhi) { // Phi Mother Matched + rFeeddownMatrices.fill(HIST("hK0shPhiFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); } } } } - // lambda analysis - if (lambda_analysis == true) { - if (v0mcParticle.pdgCode() == 3122) { // lambda matched - rPtAnalysis.fill(HIST("hMassLambdaAll"), v0.mLambda()); - rPtAnalysis.fill(HIST("hLambdaPtSpectrumBeforeCuts"), v0.pt()); - // Implementing best lambda cuts - if (v0.v0cosPA() > lambdasetting_cospa && v0.dcaV0daughters() < lambdasetting_dcav0dau && v0.v0radius() > lambdasetting_radius && TMath::Abs(v0.dcapostopv()) > lambdasetting_dcapostopv && TMath::Abs(v0.dcanegtopv()) > lambdasetting_dcanegtopv) { - rPtAnalysis.fill(HIST("hMassLambdaAllAfterCuts"), v0.mLambda()); - rPtAnalysis.fill(HIST("hLambdaReconstructedPtSpectrum"), v0.pt()); - for (int i = 0; i < 20; i++) { - // same as above with kzerosh we fill the 20 lambda namespace histograms within their Pt range - std::string pt1 = pthistos::lambdaptbins[i]; - std::string pt2 = pthistos::lambdaptbins[i + 1]; - size_t pos1 = pt1.find("_"); - size_t pos2 = pt2.find("_"); - pt1[pos1] = '.'; - pt2[pos2] = '.'; - const float ptlowervalue = std::stod(pt1); - const float pthighervalue = std::stod(pt2); - if (ptlowervalue <= v0.pt() && v0.pt() < pthighervalue) { - pthistos::LambdaPt[i]->Fill(v0.mLambda()); - } + } + // lambda analysis + if (lambdaAnalysis == true) { + if (v0mcParticle.pdgCode() == kLambda0) { // lambda matched + + if (!acceptLambda(v0)) { // Lambda Selections + continue; + } + + if (v0mcParticle.isPhysicalPrimary()) { + for (int i = 0; i < nmaxHistograms; i++) { + if (lambdaptedgevalues[i] <= v0.pt() && v0.pt() < lambdaptedgevalues[i + 1]) { + pthistos::lambdaPt[i]->Fill(v0.mLambda()); + } + } + } + if (!v0mcParticle.isPhysicalPrimary()) { + auto v0mothers = v0mcParticle.mothers_as(); // Get mothers + if (!v0mothers.empty()) { + auto& v0mcParticleMother = v0mothers.front(); // First mother + rFeeddownMatrices.fill(HIST("hLambdaFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + if (v0mcParticleMother.pdgCode() == kXiMinus) { // Xi Minus Mother Matched + rFeeddownMatrices.fill(HIST("hLambdaXiMinusFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + } + if (v0mcParticleMother.pdgCode() == kXi0) { // Xi Zero Mother Matched + rFeeddownMatrices.fill(HIST("hLambdaXiZeroFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + } + if (v0mcParticleMother.pdgCode() == kOmegaMinus) { // Omega Mother Matched + rFeeddownMatrices.fill(HIST("hLambdaOmegaFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); } } } } - // antilambda analysis - if (antilambda_analysis == true) { - if (v0mcParticle.pdgCode() == -3122) { // antilambda matched - rPtAnalysis.fill(HIST("hMassAntilambdaAll"), v0.mAntiLambda()); - rPtAnalysis.fill(HIST("hAntilambdaPtSpectrumBeforeCuts"), v0.pt()); - // Implementing best antilambda cuts - if (v0.v0cosPA() > antilambdasetting_cospa && v0.dcaV0daughters() < antilambdasetting_dcav0dau && v0.v0radius() > antilambdasetting_radius && TMath::Abs(v0.dcapostopv()) > antilambdasetting_dcapostopv && TMath::Abs(v0.dcanegtopv()) > antilambdasetting_dcanegtopv) { - rPtAnalysis.fill(HIST("hMassAntilambdaAllAfterCuts"), v0.mAntiLambda()); - rPtAnalysis.fill(HIST("hAntilambdaReconstructedPtSpectrum"), v0.pt()); - for (int i = 0; i < 20; i++) { - // same as above with kzerosh and lambda we fill the 20 anti-lambda namespace histograms within their Pt range - std::string pt1 = pthistos::antilambdaptbins[i]; - std::string pt2 = pthistos::antilambdaptbins[i + 1]; - size_t pos1 = pt1.find("_"); - size_t pos2 = pt2.find("_"); - pt1[pos1] = '.'; - pt2[pos2] = '.'; - const float ptlowervalue = std::stod(pt1); - const float pthighervalue = std::stod(pt2); - if (ptlowervalue <= v0.pt() && v0.pt() < pthighervalue) { - pthistos::AntilambdaPt[i]->Fill(v0.mAntiLambda()); - } + } + // antilambda analysis + if (antiLambdaAnalysis == true) { + if (v0mcParticle.pdgCode() == kLambda0Bar) { // antilambda matched + + if (!acceptAntilambda(v0)) { // Antilambda Selections + continue; + } + + if (v0mcParticle.isPhysicalPrimary()) { + for (int i = 0; i < nmaxHistograms; i++) { + if (antilambdaPtedgevalues[i] <= v0.pt() && v0.pt() < antilambdaPtedgevalues[i + 1]) { + pthistos::antilambdaPt[i]->Fill(v0.mAntiLambda()); + } + } + } + if (!v0mcParticle.isPhysicalPrimary()) { + auto v0mothers = v0mcParticle.mothers_as(); // Get mothers + if (!v0mothers.empty()) { + auto& v0mcParticleMother = v0mothers.front(); // First mother + rFeeddownMatrices.fill(HIST("hAntiLambdaFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + if (v0mcParticleMother.pdgCode() == kXiPlusBar) { // Xi Plus Mother Matched + rFeeddownMatrices.fill(HIST("hAntiLambdaXiPlusFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + } + if (v0mcParticleMother.pdgCode() == -kXi0) { // Anti-Xi Zero Mother Matched + rFeeddownMatrices.fill(HIST("hAntiLambdaAntiXiZeroFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); + } + if (v0mcParticleMother.pdgCode() == kOmegaPlusBar) { // Anti-Omega (minus) Mother Matched + rFeeddownMatrices.fill(HIST("hAntiLambdaAntiOmegaFeeddownMatrix"), v0mcParticle.pt(), v0mcParticleMother.pt()); } } } @@ -290,85 +904,77 @@ struct v0ptinvmassplots { } } // This is the process for Real Data - void Dataprocess(soa::Filtered>::iterator const&, - aod::V0Datas const& V0s) + void dataProcess(soa::Join::iterator const& collision, + aod::V0Datas const& V0s, + DaughterTracks const&) { + // tokenise strings into individual values + pthistos::kaonPtBins = o2::utils::Str::tokenize(kzeroSettingPtBinsString, ','); + pthistos::lambdaPtBins = o2::utils::Str::tokenize(lambdaSettingPtBinsString, ','); + pthistos::antilambdaPtBins = o2::utils::Str::tokenize(antilambdaSettingPtBinsString, ','); + + // initialize and convert tokenized strings into vector of doubles for pt bin edges + std::vector kaonptedgevalues(nmaxHistograms + 1); + std::vector lambdaptedgevalues(nmaxHistograms + 1); + std::vector antilambdaPtedgevalues(nmaxHistograms + 1); + for (int i = 0; i < nmaxHistograms + 1; i++) { + kaonptedgevalues[i] = std::stod(pthistos::kaonPtBins[i]); + lambdaptedgevalues[i] = std::stod(pthistos::lambdaPtBins[i]); + antilambdaPtedgevalues[i] = std::stod(pthistos::antilambdaPtBins[i]); + } + if (!acceptEvent(collision)) { // Event Selection + return; + } + rPtAnalysis.fill(HIST("hNRecEvents_Data"), 1.0); // Number of Reconstructed Events + for (const auto& v0 : V0s) { + // Checking that the V0 is a true K0s/Lambdas/Antilambdas and then filling the parameter histograms and the invariant mass plots for different cuts (which are taken from namespace) + if (!acceptV0(v0)) { // V0 Selection + continue; + } + rPtAnalysis.fill(HIST("hArmenterosPodolanskiPlot"), v0.alpha(), v0.qtarm()); // kzero analysis - if (kzerosh_analysis == true) { - // Filling the five Kzero invariant mass plots for different cuts (which are taken from namespace), for full explanation see the first kzero cut filling in the MC process - rPtAnalysis.fill(HIST("hMassK0ShortAll"), v0.mK0Short()); - // Implementing best kzero cuts - if (v0.v0cosPA() > kaonshsetting_cospa && v0.dcaV0daughters() < kaonshsetting_dcav0dau && v0.v0radius() > kaonshsetting_radius && TMath::Abs(v0.dcapostopv()) > kaonshsetting_dcapostopv && TMath::Abs(v0.dcanegtopv()) > kaonshsetting_dcanegtopv) { - rPtAnalysis.fill(HIST("hMassK0ShortAllAfterCuts"), v0.mK0Short()); - for (int i = 0; i < 20; i++) { // same as above MC-process we fill the namespace histos with the kaon invariant mass of the particle within the pt range of the histo - std::string pt1 = pthistos::kaonptbins[i]; - std::string pt2 = pthistos::kaonptbins[i + 1]; - size_t pos1 = pt1.find("_"); - size_t pos2 = pt2.find("_"); - pt1[pos1] = '.'; - pt2[pos2] = '.'; - const float ptlowervalue = std::stod(pt1); - const float pthighervalue = std::stod(pt2); - if (ptlowervalue < v0.pt() && v0.pt() < pthighervalue) { - pthistos::KaonPt[i]->Fill(v0.mK0Short()); - } + if (kzeroAnalysis == true) { + if (!acceptK0sh(v0)) { // K0sh Selection + continue; + } + for (int i = 0; i < nmaxHistograms; i++) { + if (kaonptedgevalues[i] <= v0.pt() && v0.pt() < kaonptedgevalues[i + 1]) { // finding v0s with pt within the range of our bin edges + pthistos::kaonPt[i]->Fill(v0.mK0Short()); // filling the k0s namespace histograms } } } // lambda analysis - if (lambda_analysis == true) { - // Filling the five lambda invariant mass plots for different cuts (which are taken from namespace), for full explanation see the first kzero cut filling in the MC process - rPtAnalysis.fill(HIST("hMassLambdaAll"), v0.mLambda()); - // Implementing best lambda cuts - if (v0.v0cosPA() > lambdasetting_cospa && v0.dcaV0daughters() < lambdasetting_dcav0dau && v0.v0radius() > lambdasetting_radius && TMath::Abs(v0.dcapostopv()) > lambdasetting_dcapostopv && TMath::Abs(v0.dcanegtopv()) > lambdasetting_dcanegtopv) { - rPtAnalysis.fill(HIST("hMassLambdaAllAfterCuts"), v0.mLambda()); - for (int i = 0; i < 20; i++) { // same as above MC-process we fill the namespace histos with the lambda invariant mass of the particle within the pt range of the histo - std::string pt1 = pthistos::lambdaptbins[i]; - std::string pt2 = pthistos::lambdaptbins[i + 1]; - size_t pos1 = pt1.find("_"); - size_t pos2 = pt2.find("_"); - pt1[pos1] = '.'; - pt2[pos2] = '.'; - const float ptlowervalue = std::stod(pt1); - const float pthighervalue = std::stod(pt2); - if (ptlowervalue < v0.pt() && v0.pt() < pthighervalue) { - pthistos::LambdaPt[i]->Fill(v0.mLambda()); - } + if (lambdaAnalysis == true) { + if (!acceptLambda(v0)) { // Lambda Selection + continue; + } + for (int i = 0; i < nmaxHistograms; i++) { + if (lambdaptedgevalues[i] <= v0.pt() && v0.pt() < lambdaptedgevalues[i + 1]) { + pthistos::lambdaPt[i]->Fill(v0.mLambda()); } } } // anti-lambda analysis - if (antilambda_analysis == true) { - // Filling the five Antilambda invariant mass plots for different cuts (which are taken from namespace), for full explanation see the first kzero cut filling in the MC process - rPtAnalysis.fill(HIST("hMassAntilambdaAll"), v0.mAntiLambda()); - // implementing best antilambda cuts - if (v0.v0cosPA() > antilambdasetting_cospa && v0.dcaV0daughters() < antilambdasetting_dcav0dau && v0.v0radius() > antilambdasetting_radius && TMath::Abs(v0.dcapostopv()) > antilambdasetting_dcapostopv && TMath::Abs(v0.dcanegtopv()) > antilambdasetting_dcanegtopv) { - rPtAnalysis.fill(HIST("hMassAntilambdaAllAfterCuts"), v0.mAntiLambda()); - for (int i = 0; i < 20; i++) { // same as above MC-process we fill the namespace histos with the antilambda invariant mass of the particle within the pt range of the histo - std::string pt1 = pthistos::antilambdaptbins[i]; - std::string pt2 = pthistos::antilambdaptbins[i + 1]; - size_t pos1 = pt1.find("_"); - size_t pos2 = pt2.find("_"); - pt1[pos1] = '.'; - pt2[pos2] = '.'; - const float ptlowervalue = std::stod(pt1); - const float pthighervalue = std::stod(pt2); - if (ptlowervalue < v0.pt() && v0.pt() < pthighervalue) { - pthistos::AntilambdaPt[i]->Fill(v0.mAntiLambda()); - } + if (antiLambdaAnalysis == true) { + if (!acceptAntilambda(v0)) { // Antilambda Selection + continue; + } + for (int i = 0; i < nmaxHistograms; i++) { + if (lambdaptedgevalues[i] <= v0.pt() && v0.pt() < lambdaptedgevalues[i + 1]) { + pthistos::antilambdaPt[i]->Fill(v0.mAntiLambda()); } } } } } - PROCESS_SWITCH(v0ptinvmassplots, GenMCprocess, "Process Run 3 MC Generated", false); - PROCESS_SWITCH(v0ptinvmassplots, RecMCprocess, "Process Run 3 MC", false); - PROCESS_SWITCH(v0ptinvmassplots, Dataprocess, "Process Run 3 Data,", true); + PROCESS_SWITCH(V0PtInvMassPlots, genMCProcess, "Process Run 3 MC Generated", false); + PROCESS_SWITCH(V0PtInvMassPlots, recMCProcess, "Process Run 3 MC Reconstructed", false); + PROCESS_SWITCH(V0PtInvMassPlots, dataProcess, "Process Run 3 Data,", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/Tasks/Strangeness/v0topologicalcuts.cxx b/PWGLF/Tasks/Strangeness/v0topologicalcuts.cxx index 6fa5c8a8b82..fd351646bee 100644 --- a/PWGLF/Tasks/Strangeness/v0topologicalcuts.cxx +++ b/PWGLF/Tasks/Strangeness/v0topologicalcuts.cxx @@ -9,6 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// +/// \file v0topologicalcuts.cxx /// \brief V0 task for production of invariant mass plots for Optimised Topological Cuts Analysis /// \author Nikolaos Karatzenis (nikolaos.karatzenis@cern.ch) /// \author Roman Lietava (roman.lietava@cern.ch) @@ -21,7 +22,6 @@ that are filled with the V0 invariant mass under the K0, Lambda and Antilambda m The cuts are passed as configurable strings for convenience. This analysis includes two processes, one for Real Data and one for MC Data switchable at the end of the code, only run one at a time*/ -#include #include #include #include @@ -35,8 +35,8 @@ This analysis includes two processes, one for Real Data and one for MC Data swit // namespaces to be used for the plot names and topological cuts that will be given by a configurable string namespace cuthistoskzerosh { -std::shared_ptr cospaCut[20]; -static std::vector cospacuts; +std::shared_ptr cosPACut[20]; +static std::vector cosPAcuts; std::shared_ptr dcaCut[20]; static std::vector dcacuts; std::shared_ptr v0radiusCut[20]; @@ -48,8 +48,8 @@ static std::vector dcanegtopvcuts; } // namespace cuthistoskzerosh namespace cuthistoslambda { -std::shared_ptr cospaCut[20]; -static std::vector cospacuts; +std::shared_ptr cosPACut[20]; +static std::vector cosPAcuts; std::shared_ptr dcaCut[20]; static std::vector dcacuts; std::shared_ptr v0radiusCut[20]; @@ -61,8 +61,8 @@ static std::vector dcanegtopvcuts; } // namespace cuthistoslambda namespace cuthistosantilambda { -std::shared_ptr cospaCut[20]; -static std::vector cospacuts; +std::shared_ptr cosPACut[20]; +static std::vector cosPAcuts; std::shared_ptr dcaCut[20]; static std::vector dcacuts; std::shared_ptr v0radiusCut[20]; @@ -78,524 +78,604 @@ using namespace o2::framework::expressions; struct v0topologicalcuts { // Histogram Registry includes different V0 Parameteres for all V0s and individual MC-V0s with MC-matching - HistogramRegistry rV0Parameters_MC_V0match{"V0Parameters_MC_V0Match", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rV0Parameters_MC_K0Smatch{"V0Parameters_MC_K0SMatch", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rV0Parameters_MC_Lambdamatch{"V0Parameters_MC_LambdaMatch", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rV0Parameters_MC_AntiLambdamatch{"V0Parameters_MC_AntiLambdaMatch", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rV0Parameters_Data{"rV0Parameters_Data", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rV0ParametersMCV0match{"V0ParametersMCV0Match", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rV0ParametersMCK0Smatch{"V0ParametersMCK0SMatch", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rV0ParametersMCLambdamatch{"V0ParametersMCLambdaMatch", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rV0ParametersMCAntiLambdamatch{"V0ParametersMCAntiLambdaMatch", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rV0ParametersData{"rV0ParametersData", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; // kzero cut Histogram Registry with MC-matching, each will include 20 histograms for 20 different cuts - HistogramRegistry rKzeroShort_cospaCut{"KzeroShort_cospaCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rKzeroShort_dcaCut{"KzeroShort_dcaCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rKzeroShort_v0radiusCut{"KzeroShort_v0radiusCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rKzeroShort_dcapostopCut{"KzeroShort_dcapostopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rKzeroShort_dcanegtopCut{"KzeroShort_dcanegtopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rKzeroShortCosPACut{"KzeroShortCosPACuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rKzeroShortDCACut{"KzeroShortDCACuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rKzeroShortV0radiusCut{"KzeroShortV0radiusCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rKzeroShortDCApostopCut{"KzeroShortDCApostopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rKzeroShortDCAnegtopCut{"KzeroShortDCAnegtopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; // lambdas cut histograms with MC-matching (same as in Kzeros above) - HistogramRegistry rLambda_cospaCut{"Lambda_cospaCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rLambda_dcaCut{"Lambda_dcaCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rLambda_v0radiusCut{"Lambda_v0radiusCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rLambda_dcapostopCut{"Lambda_dcapostopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rLambda_dcanegtopCut{"Lambda_dcanegtopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rLambdaCosPACut{"LambdaCosPACuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rLambdaDCACut{"LambdaDCACuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rLambdaV0radiusCut{"LambdaV0radiusCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rLambdaDCApostopCut{"LambdaDCApostopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rLambdaDCAnegtopCut{"LambdaDCAnegtopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; // antilambdas cut histograms with MC-matching (same as in Lambdas an Kzeros above) - HistogramRegistry rAntiLambda_cospaCut{"AntiLambda_cospaCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rAntiLambda_dcaCut{"AntiLambda_dcaCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rAntiLambda_v0radiusCut{"AntiLambda_v0radiusCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rAntiLambda_dcapostopCut{"AntiLambda_dcapostopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rAntiLambda_dcanegtopCut{"AntiLambda_dcanegtopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rAntiLambdaCosPACut{"AntiLambdaCosPACuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rAntiLambdaDCACut{"AntiLambdaDCACuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rAntiLambdaV0radiusCut{"AntiLambdaV0radiusCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rAntiLambdaDCApostopCut{"AntiLambdaDCApostopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rAntiLambdaDCAnegtopCut{"AntiLambdaDCAnegtopvCuts", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; // Configurable for histograms Configurable nBins{"nBins", 100, "N bins in all histos"}; + // Configurables for Cuts + Configurable cutZVertex{"cutZVertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable nSigmaTPCPion{"nSigmaTPCPion", 4, "nSigmaTPCPion"}; + Configurable nSigmaTPCProton{"nSigmaTPCProton", 4, "nSigmaTPCProton"}; + Configurable compv0masscut{"compv0masscut", 0.01, "CompetitiveV0masscut (GeV)"}; + Configurable etadau{"etadau", 0.8, "Eta Daughters"}; + // Configurable strings for Kzero cuts - Configurable kzeroshsetting_cospacuts_string{"kzerosetting_cospacuts", {"0_98,0_981,0_982,0_983,0_984,0_985,0_986,0_987,0_988,0_989,0_99,0_991,0_992,0_993,0_994,0_995,0_996,0_997,0_998,0_999"}, "Kzero cosPA Cut Values"}; - Configurable kzeroshsetting_dcacuts_string{"kzerosetting_dcacuts", {"0_3,0_285,0_27,0_255,0_24,0_225,0_21,0_195,0_18,0_165,0_15,0_135,0_12,0_105,0_09,0_075,0_06,0_045,0_03,0_015"}, "Kzero DCA Cut Values"}; - Configurable kzeroshsetting_v0radius_string{"kzerosetting_v0radiuscuts", {"0_5,0_51,0_52,0_53,0_54,0_55,0_56,0_57,0_58,0_59,0_6,0_61,0_62,0_63,0_64,0_65,0_66,0_67,0_68,0_69"}, "Kzero V0Radius Cut Values"}; - Configurable kzeroshsetting_dcapostopv_string{"kzerosetting_dcapostopvcuts", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Kzero DCA Pos to PV Cut Values"}; - Configurable kzeroshsetting_dcanegtopv_string{"kzerosetting_dcanegtopvcuts", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "KzeroDCA Neg to PV Cut Values"}; + Configurable kzeroshSettingCosPAcutsString{"kzeroshSettingCosPAcutsString", {"0_98,0_981,0_982,0_983,0_984,0_985,0_986,0_987,0_988,0_989,0_99,0_991,0_992,0_993,0_994,0_995,0_996,0_997,0_998,0_999"}, "Kzero cosPA Cut Values"}; + Configurable kzeroshSettingDCAcutsString{"kzeroshSettingDCAcutsString", {"0_3,0_285,0_27,0_255,0_24,0_225,0_21,0_195,0_18,0_165,0_15,0_135,0_12,0_105,0_09,0_075,0_06,0_045,0_03,0_015"}, "Kzero DCA Cut Values"}; + Configurable kzeroshSettingV0radiusString{"kzeroshSettingV0radiusString", {"0_5,0_51,0_52,0_53,0_54,0_55,0_56,0_57,0_58,0_59,0_6,0_61,0_62,0_63,0_64,0_65,0_66,0_67,0_68,0_69"}, "Kzero V0Radius Cut Values"}; + Configurable kzeroshSettingDCApostopvString{"kzeroshSettingDCApostopvString", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Kzero DCA Pos to PV Cut Values"}; + Configurable kzeroshSettingDCAnegtopvString{"kzeroshSettingDCAnegtopvString", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "KzeroDCA Neg to PV Cut Values"}; // Configurable strings for Lambdacuts - Configurable lambdasetting_cospacuts_string{"lambdasetting_cospacuts", {"0_98,0_981,0_982,0_983,0_984,0_985,0_986,0_987,0_988,0_989,0_99,0_991,0_992,0_993,0_994"}, "Lambda cosPA Cut Values"}; - Configurable lambdasetting_dcacuts_string{"lambdasetting_dcacuts", {"0_3,0_285,0_27,0_255,0_24,0_225,0_21,0_195,0_18,0_165,0_15,0_135,0_12,0_105,0_09,0_075,0_06,0_045,0_03,0_015"}, "Lambda DCA Cut Values"}; - Configurable lambdasetting_v0radius_string{"lambdasetting_v0radiuscuts", {"0_5,0_51,0_52,0_53,0_54,0_55,0_56,0_57,0_58,0_59,0_6,0_61,0_62,0_63,0_64,0_65,0_66,0_67,0_68,0_69"}, "Lambda V0Radius Cut Values"}; - Configurable lambdasetting_dcapostopv_string{"lambdasetting_dcapostopvcuts", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Lambda DCA Pos to PV Cut Values"}; - Configurable lambdasetting_dcanegtopv_string{"lambdasetting_dcanegtopvcuts", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Lambda DCA Neg to PV Cut Values"}; + Configurable lambdaSettingCosPAcutsString{"lambdaSettingCosPAcutsString", {"0_98,0_981,0_982,0_983,0_984,0_985,0_986,0_987,0_988,0_989,0_99,0_991,0_992,0_993,0_994"}, "Lambda cosPA Cut Values"}; + Configurable lambdaSettingDCAcutsString{"lambdaSettingDCAcutsString", {"0_3,0_285,0_27,0_255,0_24,0_225,0_21,0_195,0_18,0_165,0_15,0_135,0_12,0_105,0_09,0_075,0_06,0_045,0_03,0_015"}, "Lambda DCA Cut Values"}; + Configurable lambdaSettingV0radiusString{"lambdaSettingV0radiusString", {"0_5,0_51,0_52,0_53,0_54,0_55,0_56,0_57,0_58,0_59,0_6,0_61,0_62,0_63,0_64,0_65,0_66,0_67,0_68,0_69"}, "Lambda V0Radius Cut Values"}; + Configurable lambdaSettingDCApostopvString{"lambdaSettingDCApostopvString", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Lambda DCA Pos to PV Cut Values"}; + Configurable lambdaSettingDCAnegtopvString{"lambdaSettingDCAnegtopvString", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Lambda DCA Neg to PV Cut Values"}; // Configurable strings for AntiLambdacuts - Configurable antilambdasetting_cospacuts_string{"antilambdasetting_cospacuts", {"0_98,0_981,0_982,0_983,0_984,0_985,0_986,0_987,0_988,0_989,0_99,0_991,0_992,0_993,0_994,0_995,0_996,0_997,0_998,0_999"}, "Antilambda cosPA Cut Values"}; - Configurable antilambdasetting_dcacuts_string{"antilambdasetting_dcacuts", {"0_3,0_285,0_27,0_255,0_24,0_225,0_21,0_195,0_18,0_165,0_15,0_135,0_12,0_105,0_09,0_075,0_06,0_045,0_03,0_015"}, "Antilambda DCA Cut Values"}; - Configurable antilambdasetting_v0radius_string{"antilambdasetting_v0radiuscuts", {"0_5,0_51,0_52,0_53,0_54,0_55,0_56,0_57,0_58,0_59,0_6,0_61,0_62,0_63,0_64,0_65,0_66,0_67,0_68,0_69"}, "Antilambda V0Radius Cut Values"}; - Configurable antilambdasetting_dcapostopv_string{"antilambdasetting_dcapostopvcuts", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Antilambda DCA Pos to PV Cut Values"}; - Configurable antilambdasetting_dcanegtopv_string{"antilambdasetting_dcanegtopvcuts", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Antilambda DCA Neg to PV Cut Values"}; + Configurable antilambdaSettingCosPAcutsString{"antilambdaSettingCosPAcutsString", {"0_98,0_981,0_982,0_983,0_984,0_985,0_986,0_987,0_988,0_989,0_99,0_991,0_992,0_993,0_994,0_995,0_996,0_997,0_998,0_999"}, "Antilambda cosPA Cut Values"}; + Configurable antilambdaSettingDCAcutsString{"antilambdaSettingDCAcutsString", {"0_3,0_285,0_27,0_255,0_24,0_225,0_21,0_195,0_18,0_165,0_15,0_135,0_12,0_105,0_09,0_075,0_06,0_045,0_03,0_015"}, "Antilambda DCA Cut Values"}; + Configurable antilambdaSettingV0radiusString{"antilambdaSettingV0radiusString", {"0_5,0_51,0_52,0_53,0_54,0_55,0_56,0_57,0_58,0_59,0_6,0_61,0_62,0_63,0_64,0_65,0_66,0_67,0_68,0_69"}, "Antilambda V0Radius Cut Values"}; + Configurable antilambdaSettingDCApostopvString{"antilambdaSettingDCApostopvString", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Antilambda DCA Pos to PV Cut Values"}; + Configurable antilambdaSettingDCAnegtopvString{"antilambdaSettingDCAnegtopvString", {"0_0,0_01,0_02,0_03,0_04,0_05,0_06,0_07,0_08,0_09,0_1,0_11,0_12,0_13,0_14,0_15,0_16,0_17,0_18,0_19"}, "Antilambda DCA Neg to PV Cut Values"}; void init(InitContext const&) { // kzero filling namespace with configurable strings - // setting strings from configurable strings in order to manipulate them + // Setting strings from configurable strings in order to manipulate them // getting the cut values for the names of the plots for the five topological cuts - cuthistoskzerosh::cospacuts = o2::utils::Str::tokenize(kzeroshsetting_cospacuts_string, ','); - cuthistoskzerosh::dcacuts = o2::utils::Str::tokenize(kzeroshsetting_dcacuts_string, ','); - cuthistoskzerosh::v0radiuscuts = o2::utils::Str::tokenize(kzeroshsetting_v0radius_string, ','); - cuthistoskzerosh::dcapostopvcuts = o2::utils::Str::tokenize(kzeroshsetting_dcapostopv_string, ','); - cuthistoskzerosh::dcanegtopvcuts = o2::utils::Str::tokenize(kzeroshsetting_dcanegtopv_string, ','); + cuthistoskzerosh::cosPAcuts = o2::utils::Str::tokenize(kzeroshSettingCosPAcutsString, ','); + cuthistoskzerosh::dcacuts = o2::utils::Str::tokenize(kzeroshSettingDCAcutsString, ','); + cuthistoskzerosh::v0radiuscuts = o2::utils::Str::tokenize(kzeroshSettingV0radiusString, ','); + cuthistoskzerosh::dcapostopvcuts = o2::utils::Str::tokenize(kzeroshSettingDCApostopvString, ','); + cuthistoskzerosh::dcanegtopvcuts = o2::utils::Str::tokenize(kzeroshSettingDCAnegtopvString, ','); // lambda filling namespace with configurable strings (same as in Kzeros above) - cuthistoslambda::cospacuts = o2::utils::Str::tokenize(lambdasetting_cospacuts_string, ','); - cuthistoslambda::dcacuts = o2::utils::Str::tokenize(lambdasetting_dcacuts_string, ','); - cuthistoslambda::v0radiuscuts = o2::utils::Str::tokenize(lambdasetting_v0radius_string, ','); - cuthistoslambda::dcapostopvcuts = o2::utils::Str::tokenize(lambdasetting_dcapostopv_string, ','); - cuthistoslambda::dcanegtopvcuts = o2::utils::Str::tokenize(lambdasetting_dcanegtopv_string, ','); + cuthistoslambda::cosPAcuts = o2::utils::Str::tokenize(lambdaSettingCosPAcutsString, ','); + cuthistoslambda::dcacuts = o2::utils::Str::tokenize(lambdaSettingDCAcutsString, ','); + cuthistoslambda::v0radiuscuts = o2::utils::Str::tokenize(lambdaSettingV0radiusString, ','); + cuthistoslambda::dcapostopvcuts = o2::utils::Str::tokenize(lambdaSettingDCApostopvString, ','); + cuthistoslambda::dcanegtopvcuts = o2::utils::Str::tokenize(lambdaSettingDCAnegtopvString, ','); // antilambda filling namespace with configurable strings (same as in Lambdas and Kzeros above) - cuthistosantilambda::cospacuts = o2::utils::Str::tokenize(antilambdasetting_cospacuts_string, ','); - cuthistosantilambda::dcacuts = o2::utils::Str::tokenize(antilambdasetting_dcacuts_string, ','); - cuthistosantilambda::v0radiuscuts = o2::utils::Str::tokenize(antilambdasetting_v0radius_string, ','); - cuthistosantilambda::dcapostopvcuts = o2::utils::Str::tokenize(antilambdasetting_dcapostopv_string, ','); - cuthistosantilambda::dcanegtopvcuts = o2::utils::Str::tokenize(antilambdasetting_dcanegtopv_string, ','); + cuthistosantilambda::cosPAcuts = o2::utils::Str::tokenize(antilambdaSettingCosPAcutsString, ','); + cuthistosantilambda::dcacuts = o2::utils::Str::tokenize(antilambdaSettingDCAcutsString, ','); + cuthistosantilambda::v0radiuscuts = o2::utils::Str::tokenize(antilambdaSettingV0radiusString, ','); + cuthistosantilambda::dcapostopvcuts = o2::utils::Str::tokenize(antilambdaSettingDCApostopvString, ','); + cuthistosantilambda::dcanegtopvcuts = o2::utils::Str::tokenize(antilambdaSettingDCAnegtopvString, ','); // Axes for the three invariant mass plots - AxisSpec K0ShortMassAxis = {nBins, 0.45f, 0.55f, "#it{M} #pi^{+}#pi^{-} [GeV/#it{c}^{2}]"}; - AxisSpec LambdaMassAxis = {nBins, 1.085f, 1.145f, "#it{M} p^{+}#pi^{-} [GeV/#it{c}^{2}]"}; - AxisSpec AntiLambdaMassAxis = {nBins, 1.085f, 1.145f, "#it{M} p^{-}#pi^{+} [GeV/#it{c}^{2}]"}; + AxisSpec k0ShortMassAxis = {nBins, 0.45f, 0.55f, "#it{M} #pi^{+}#pi^{-} [GeV/#it{c}^{2}]"}; + AxisSpec lambdaMassAxis = {nBins, 1.085f, 1.145f, "#it{M} p^{+}#pi^{-} [GeV/#it{c}^{2}]"}; + AxisSpec antiLambdaMassAxis = {nBins, 1.085f, 1.145f, "#it{M} p^{-}#pi^{+} [GeV/#it{c}^{2}]"}; + AxisSpec ptAxis = {nBins, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec vertexZAxis = {nBins, -15., 15., "vrtx_{Z} [cm]"}; // adding the invariant mass histograms to their Registries using the namespace for kzeros, lambdas and antilambdas - for (uint32_t i = 0; i < cuthistoskzerosh::cospacuts.size(); i++) { - cuthistoskzerosh::cospaCut[i] = rKzeroShort_cospaCut.add(fmt::format("hKzerocospaCut_{}", cuthistoskzerosh::cospacuts[i]).data(), fmt::format("hKzerocospaCut_{}", cuthistoskzerosh::cospacuts[i]).data(), {HistType::kTH1D, {{K0ShortMassAxis}}}); + for (uint32_t i = 0; i < cuthistoskzerosh::cosPAcuts.size(); i++) { + cuthistoskzerosh::cosPACut[i] = rKzeroShortCosPACut.add(fmt::format("hKzerocosPACut_{}", cuthistoskzerosh::cosPAcuts[i]).data(), fmt::format("hKzerocosPACut_{}", cuthistoskzerosh::cosPAcuts[i]).data(), {HistType::kTH1D, {{k0ShortMassAxis}}}); } for (uint32_t i = 0; i < cuthistoskzerosh::dcacuts.size(); i++) { - cuthistoskzerosh::dcaCut[i] = rKzeroShort_dcaCut.add(fmt::format("hKzerodcaCut_{}", cuthistoskzerosh::dcacuts[i]).data(), fmt::format("hKzerodcaCut_{}", cuthistoskzerosh::dcacuts[i]).data(), {HistType::kTH1D, {{K0ShortMassAxis}}}); + cuthistoskzerosh::dcaCut[i] = rKzeroShortDCACut.add(fmt::format("hKzerodcaCut_{}", cuthistoskzerosh::dcacuts[i]).data(), fmt::format("hKzerodcaCut_{}", cuthistoskzerosh::dcacuts[i]).data(), {HistType::kTH1D, {{k0ShortMassAxis}}}); } for (uint32_t i = 0; i < cuthistoskzerosh::v0radiuscuts.size(); i++) { - cuthistoskzerosh::v0radiusCut[i] = rKzeroShort_v0radiusCut.add(fmt::format("hKzerov0radiusCut_{}", cuthistoskzerosh::v0radiuscuts[i]).data(), fmt::format("hKzerov0radiusCut_{}", cuthistoskzerosh::v0radiuscuts[i]).data(), {HistType::kTH1D, {{K0ShortMassAxis}}}); + cuthistoskzerosh::v0radiusCut[i] = rKzeroShortV0radiusCut.add(fmt::format("hKzerov0radiusCut_{}", cuthistoskzerosh::v0radiuscuts[i]).data(), fmt::format("hKzerov0radiusCut_{}", cuthistoskzerosh::v0radiuscuts[i]).data(), {HistType::kTH1D, {{k0ShortMassAxis}}}); } for (uint32_t i = 0; i < cuthistoskzerosh::dcapostopvcuts.size(); i++) { - cuthistoskzerosh::dcapostopCut[i] = rKzeroShort_dcapostopCut.add(fmt::format("hKzerodcapostopCut_{}", cuthistoskzerosh::dcapostopvcuts[i]).data(), fmt::format("hKzerodcapostopCut_{}", cuthistoskzerosh::dcapostopvcuts[i]).data(), {HistType::kTH1D, {{K0ShortMassAxis}}}); + cuthistoskzerosh::dcapostopCut[i] = rKzeroShortDCApostopCut.add(fmt::format("hKzerodcapostopCut_{}", cuthistoskzerosh::dcapostopvcuts[i]).data(), fmt::format("hKzerodcapostopCut_{}", cuthistoskzerosh::dcapostopvcuts[i]).data(), {HistType::kTH1D, {{k0ShortMassAxis}}}); } for (uint32_t i = 0; i < cuthistoskzerosh::dcanegtopvcuts.size(); i++) { - cuthistoskzerosh::dcanegtopCut[i] = rKzeroShort_dcanegtopCut.add(fmt::format("hKzerodcanegtopCut_{}", cuthistoskzerosh::dcanegtopvcuts[i]).data(), fmt::format("hKzerodcanegtopCut_{}", cuthistoskzerosh::dcanegtopvcuts[i]).data(), {HistType::kTH1D, {{K0ShortMassAxis}}}); + cuthistoskzerosh::dcanegtopCut[i] = rKzeroShortDCAnegtopCut.add(fmt::format("hKzerodcanegtopCut_{}", cuthistoskzerosh::dcanegtopvcuts[i]).data(), fmt::format("hKzerodcanegtopCut_{}", cuthistoskzerosh::dcanegtopvcuts[i]).data(), {HistType::kTH1D, {{k0ShortMassAxis}}}); } - LOG(info) << "error size: " << cuthistoslambda::cospacuts.size() << std::endl; - for (uint32_t i = 0; i < cuthistoslambda::cospacuts.size(); i++) { - LOG(info) << "error: " << (cuthistoslambda::cospacuts[i]).data() << std::endl; - cuthistoslambda::cospaCut[i] = rLambda_cospaCut.add(fmt::format("hLambdacospaCut_{}", cuthistoslambda::cospacuts[i]).data(), fmt::format("hLambdacospaCut_{}", cuthistoslambda::cospacuts[i]).data(), {HistType::kTH1D, {{LambdaMassAxis}}}); + for (uint32_t i = 0; i < cuthistoslambda::cosPAcuts.size(); i++) { + cuthistoslambda::cosPACut[i] = rLambdaCosPACut.add(fmt::format("hLambdacosPACut_{}", cuthistoslambda::cosPAcuts[i]).data(), fmt::format("hLambdacosPACut_{}", cuthistoslambda::cosPAcuts[i]).data(), {HistType::kTH1D, {{lambdaMassAxis}}}); } for (uint32_t i = 0; i < cuthistoslambda::dcacuts.size(); i++) { - cuthistoslambda::dcaCut[i] = rLambda_dcaCut.add(fmt::format("hLambdadcaCut_{}", cuthistoslambda::dcacuts[i]).data(), fmt::format("hLambdadcaCut_{}", cuthistoslambda::dcacuts[i]).data(), {HistType::kTH1D, {{LambdaMassAxis}}}); + cuthistoslambda::dcaCut[i] = rLambdaDCACut.add(fmt::format("hLambdadcaCut_{}", cuthistoslambda::dcacuts[i]).data(), fmt::format("hLambdadcaCut_{}", cuthistoslambda::dcacuts[i]).data(), {HistType::kTH1D, {{lambdaMassAxis}}}); } for (uint32_t i = 0; i < cuthistoslambda::v0radiuscuts.size(); i++) { - cuthistoslambda::v0radiusCut[i] = rLambda_v0radiusCut.add(fmt::format("hLambdav0radiusCut_{}", cuthistoslambda::v0radiuscuts[i]).data(), fmt::format("hLambdav0radiusCut_{}", cuthistoslambda::v0radiuscuts[i]).data(), {HistType::kTH1D, {{LambdaMassAxis}}}); + cuthistoslambda::v0radiusCut[i] = rLambdaV0radiusCut.add(fmt::format("hLambdav0radiusCut_{}", cuthistoslambda::v0radiuscuts[i]).data(), fmt::format("hLambdav0radiusCut_{}", cuthistoslambda::v0radiuscuts[i]).data(), {HistType::kTH1D, {{lambdaMassAxis}}}); } for (uint32_t i = 0; i < cuthistoslambda::dcapostopvcuts.size(); i++) { - cuthistoslambda::dcapostopCut[i] = rLambda_dcapostopCut.add(fmt::format("hLambdadcapostopCut_{}", cuthistoslambda::dcapostopvcuts[i]).data(), fmt::format("hLambdadcapostopCut_{}", cuthistoslambda::dcapostopvcuts[i]).data(), {HistType::kTH1D, {{LambdaMassAxis}}}); + cuthistoslambda::dcapostopCut[i] = rLambdaDCApostopCut.add(fmt::format("hLambdadcapostopCut_{}", cuthistoslambda::dcapostopvcuts[i]).data(), fmt::format("hLambdadcapostopCut_{}", cuthistoslambda::dcapostopvcuts[i]).data(), {HistType::kTH1D, {{lambdaMassAxis}}}); } for (uint32_t i = 0; i < cuthistoslambda::dcanegtopvcuts.size(); i++) { - cuthistoslambda::dcanegtopCut[i] = rLambda_dcanegtopCut.add(fmt::format("hLambdadcanegtopCut_{}", cuthistoslambda::dcanegtopvcuts[i]).data(), fmt::format("hLambdadcanegtopCut_{}", cuthistoslambda::dcanegtopvcuts[i]).data(), {HistType::kTH1D, {{LambdaMassAxis}}}); + cuthistoslambda::dcanegtopCut[i] = rLambdaDCAnegtopCut.add(fmt::format("hLambdadcanegtopCut_{}", cuthistoslambda::dcanegtopvcuts[i]).data(), fmt::format("hLambdadcanegtopCut_{}", cuthistoslambda::dcanegtopvcuts[i]).data(), {HistType::kTH1D, {{lambdaMassAxis}}}); } - for (uint32_t i = 0; i < cuthistosantilambda::cospacuts.size(); i++) { - cuthistosantilambda::cospaCut[i] = rAntiLambda_cospaCut.add(fmt::format("hAntiLambdacospaCut_{}", cuthistosantilambda::cospacuts[i]).data(), fmt::format("hAntiLambdacospaCut_{}", cuthistosantilambda::cospacuts[i]).data(), {HistType::kTH1D, {{AntiLambdaMassAxis}}}); + for (uint32_t i = 0; i < cuthistosantilambda::cosPAcuts.size(); i++) { + cuthistosantilambda::cosPACut[i] = rAntiLambdaCosPACut.add(fmt::format("hAntiLambdacosPACut_{}", cuthistosantilambda::cosPAcuts[i]).data(), fmt::format("hAntiLambdacosPACut_{}", cuthistosantilambda::cosPAcuts[i]).data(), {HistType::kTH1D, {{antiLambdaMassAxis}}}); } for (uint32_t i = 0; i < cuthistosantilambda::dcacuts.size(); i++) { - cuthistosantilambda::dcaCut[i] = rAntiLambda_dcaCut.add(fmt::format("hAntiLambdadcaCut_{}", cuthistosantilambda::dcacuts[i]).data(), fmt::format("hAntiLambdadcaCut_{}", cuthistosantilambda::dcacuts[i]).data(), {HistType::kTH1D, {{AntiLambdaMassAxis}}}); + cuthistosantilambda::dcaCut[i] = rAntiLambdaDCACut.add(fmt::format("hAntiLambdadcaCut_{}", cuthistosantilambda::dcacuts[i]).data(), fmt::format("hAntiLambdadcaCut_{}", cuthistosantilambda::dcacuts[i]).data(), {HistType::kTH1D, {{antiLambdaMassAxis}}}); } for (uint32_t i = 0; i < cuthistosantilambda::v0radiuscuts.size(); i++) { - cuthistosantilambda::v0radiusCut[i] = rAntiLambda_v0radiusCut.add(fmt::format("hAntiLambdav0radiusCut_{}", cuthistosantilambda::v0radiuscuts[i]).data(), fmt::format("hAntiLambdav0radiusCut_{}", cuthistosantilambda::v0radiuscuts[i]).data(), {HistType::kTH1D, {{AntiLambdaMassAxis}}}); + cuthistosantilambda::v0radiusCut[i] = rAntiLambdaV0radiusCut.add(fmt::format("hAntiLambdav0radiusCut_{}", cuthistosantilambda::v0radiuscuts[i]).data(), fmt::format("hAntiLambdav0radiusCut_{}", cuthistosantilambda::v0radiuscuts[i]).data(), {HistType::kTH1D, {{antiLambdaMassAxis}}}); } for (uint32_t i = 0; i < cuthistosantilambda::dcapostopvcuts.size(); i++) { - cuthistosantilambda::dcapostopCut[i] = rAntiLambda_dcapostopCut.add(fmt::format("hAntiLambdadcapostopCut_{}", cuthistosantilambda::dcapostopvcuts[i]).data(), fmt::format("hAntiLambdadcapostopCut_{}", cuthistosantilambda::dcapostopvcuts[i]).data(), {HistType::kTH1D, {{AntiLambdaMassAxis}}}); + cuthistosantilambda::dcapostopCut[i] = rAntiLambdaDCApostopCut.add(fmt::format("hAntiLambdadcapostopCut_{}", cuthistosantilambda::dcapostopvcuts[i]).data(), fmt::format("hAntiLambdadcapostopCut_{}", cuthistosantilambda::dcapostopvcuts[i]).data(), {HistType::kTH1D, {{antiLambdaMassAxis}}}); } for (uint32_t i = 0; i < cuthistosantilambda::dcanegtopvcuts.size(); i++) { - cuthistosantilambda::dcanegtopCut[i] = rAntiLambda_dcanegtopCut.add(fmt::format("hAntiLambdadcanegtopCut_{}", cuthistosantilambda::dcanegtopvcuts[i]).data(), fmt::format("hAntiLambdadcanegtopCut_{}", cuthistosantilambda::dcanegtopvcuts[i]).data(), {HistType::kTH1D, {{AntiLambdaMassAxis}}}); + cuthistosantilambda::dcanegtopCut[i] = rAntiLambdaDCAnegtopCut.add(fmt::format("hAntiLambdadcanegtopCut_{}", cuthistosantilambda::dcanegtopvcuts[i]).data(), fmt::format("hAntiLambdadcanegtopCut_{}", cuthistosantilambda::dcanegtopvcuts[i]).data(), {HistType::kTH1D, {{antiLambdaMassAxis}}}); } // K0s topological cut histograms added and MC-matched - rV0Parameters_MC_V0match.add("hDCAV0Daughters_V0_Match", "hDCAV0Daughters_No_Match", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); - rV0Parameters_MC_V0match.add("hV0CosPA_V0_Match", "hV0CosPA_No_Match", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); - rV0Parameters_MC_V0match.add("hV0Radius_V0_Match", "hV0Radius_No_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); - rV0Parameters_MC_V0match.add("hV0Radius_V0_Match_Full", "hV0Radius_No_Match_Full", {HistType::kTH1F, {{nBins, 0.0f, 40.0f}}}); - rV0Parameters_MC_V0match.add("hDCAPostoPV_V0_Match", "hDCAPostoPV_No_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); - rV0Parameters_MC_V0match.add("hDCANegtoPV_V0_Match", "hDCANegtoPV_No_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); + rV0ParametersMCV0match.add("hDCAV0Daughters_V0_Match", "hDCAV0Daughters_No_Match", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); + rV0ParametersMCV0match.add("hV0CosPA_V0_Match", "hV0CosPA_No_Match", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); + rV0ParametersMCV0match.add("hV0Radius_V0_Match", "hV0Radius_No_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); + rV0ParametersMCV0match.add("hV0Radius_V0_Match_Full", "hV0Radius_No_Match_Full", {HistType::kTH1F, {{nBins, 0.0f, 40.0f}}}); + rV0ParametersMCV0match.add("hDCAPostoPV_V0_Match", "hDCAPostoPV_No_Match", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); + rV0ParametersMCV0match.add("hDCANegtoPV_V0_Match", "hDCANegtoPV_No_Match", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); + rV0ParametersMCV0match.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); // kzero match - rV0Parameters_MC_K0Smatch.add("hDCAV0Daughters_KzeroMC_Match", "hDCAV0Daughters_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); - rV0Parameters_MC_K0Smatch.add("hV0CosPA_KzeroMC_Match", "hV0CosPA_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); - rV0Parameters_MC_K0Smatch.add("hV0Radius_KzeroMC_Match", "hV0Radius_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.2f, 5.0f}}}); - rV0Parameters_MC_K0Smatch.add("hDCAPostoPV_KzeroMC_Match", "hDCAPostoPV_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); - rV0Parameters_MC_K0Smatch.add("hDCANegtoPV_KzeroMC_Match", "hDCANegtoPV_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); + rV0ParametersMCK0Smatch.add("hDCAV0Daughters_KzeroMC_Match", "hDCAV0Daughters_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); + rV0ParametersMCK0Smatch.add("hV0CosPA_KzeroMC_Match", "hV0CosPA_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); + rV0ParametersMCK0Smatch.add("hV0Radius_KzeroMC_Match", "hV0Radius_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.2f, 5.0f}}}); + rV0ParametersMCK0Smatch.add("hDCAPostoPV_KzeroMC_Match", "hDCAPostoPV_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); + rV0ParametersMCK0Smatch.add("hDCANegtoPV_KzeroMC_Match", "hDCANegtoPV_KzeroMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); // lambda match - rV0Parameters_MC_Lambdamatch.add("hDCAV0Daughters_LambdaMC_Match", "hDCAV0Daughters_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); - rV0Parameters_MC_Lambdamatch.add("hV0CosPA_LambdaMC_Match", "hV0CosPA_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); - rV0Parameters_MC_Lambdamatch.add("hV0Radius_LambdaMC_Match", "hV0Radius_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.2f, 5.0f}}}); - rV0Parameters_MC_Lambdamatch.add("hDCAPostoPV_LambdaMC_Match", "hDCAPostoPV_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); - rV0Parameters_MC_Lambdamatch.add("hDCANegtoPV_LambdaMC_Match", "hDCANegtoPV_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); + rV0ParametersMCLambdamatch.add("hDCAV0Daughters_LambdaMC_Match", "hDCAV0Daughters_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); + rV0ParametersMCLambdamatch.add("hV0CosPA_LambdaMC_Match", "hV0CosPA_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); + rV0ParametersMCLambdamatch.add("hV0Radius_LambdaMC_Match", "hV0Radius_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.2f, 5.0f}}}); + rV0ParametersMCLambdamatch.add("hDCAPostoPV_LambdaMC_Match", "hDCAPostoPV_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); + rV0ParametersMCLambdamatch.add("hDCANegtoPV_LambdaMC_Match", "hDCANegtoPV_LambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); // antilambda match - rV0Parameters_MC_AntiLambdamatch.add("hDCAV0Daughters_AntiLambdaMC_Match", "hDCAV0Daughters_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); - rV0Parameters_MC_AntiLambdamatch.add("hV0CosPA_AntiLambdaMC_Match", "hV0CosPA_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); - rV0Parameters_MC_AntiLambdamatch.add("hV0Radius_AntiLambdaMC_Match", "hV0Radius_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.2f, 5.0f}}}); - rV0Parameters_MC_AntiLambdamatch.add("hDCAPostoPV_AntiLambdaMC_Match", "hDCAPostoPV_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); - rV0Parameters_MC_AntiLambdamatch.add("hDCANegtoPV_AntiLambdaMC_Match", "hDCANegtoPV_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); + rV0ParametersMCAntiLambdamatch.add("hDCAV0Daughters_AntiLambdaMC_Match", "hDCAV0Daughters_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); + rV0ParametersMCAntiLambdamatch.add("hV0CosPA_AntiLambdaMC_Match", "hV0CosPA_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); + rV0ParametersMCAntiLambdamatch.add("hV0Radius_AntiLambdaMC_Match", "hV0Radius_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.2f, 5.0f}}}); + rV0ParametersMCAntiLambdamatch.add("hDCAPostoPV_AntiLambdaMC_Match", "hDCAPostoPV_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); + rV0ParametersMCAntiLambdamatch.add("hDCANegtoPV_AntiLambdaMC_Match", "hDCANegtoPV_AntiLambdaMC_Match", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); // V0s Data - rV0Parameters_Data.add("hDCAV0Daughters_V0_Data", "hDCAV0Daughters_V0_Data", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); - rV0Parameters_Data.add("hV0CosPA_V0_Data", "hV0CosPA_V0_Data", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); - rV0Parameters_Data.add("hV0Radius_V0_Data", "hV0Radius_V0_Data", {HistType::kTH1F, {{nBins, 0.2f, 5.0f}}}); - rV0Parameters_Data.add("hV0Radius_Full_V0_Data", "hV0Radius_Full_V0_Data", {HistType::kTH1F, {{nBins, 0.2f, 5.0f}}}); - rV0Parameters_Data.add("hDCAPostoPV_V0_Data", "hDCAPostoPV_V0_Data", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); - rV0Parameters_Data.add("hDCANegtoPV_V0_Data", "hDCANegtoPV_V0_Data", {HistType::kTH1F, {{nBins, 0.0f, 5.0f}}}); - rV0Parameters_Data.add("hMassK0ShortNoCuts_V0_Data", "hMassK0ShortNoCuts_V0_Data", {HistType::kTH1F, {{K0ShortMassAxis}}}); - rV0Parameters_Data.add("hMassLambdaNoCuts_V0_Data", "hMassLambdaNoCuts_V0_Data", {HistType::kTH1F, {{LambdaMassAxis}}}); - rV0Parameters_Data.add("hMassAntilambdaNoCuts_V0_Data", "hMassAntilambdaNoCuts_V0_Data", {HistType::kTH1F, {{AntiLambdaMassAxis}}}); + rV0ParametersData.add("hDCAV0Daughters_V0Data", "hDCAV0Daughters_V0Data", {HistType::kTH1F, {{nBins, 0.0f, 1.2f}}}); + rV0ParametersData.add("hV0CosPA_V0Data", "hV0CosPA_V0Data", {HistType::kTH1F, {{nBins, 0.95f, 1.f}}}); + rV0ParametersData.add("hV0Radius_V0Data", "hV0Radius_V0Data", {HistType::kTH1F, {{nBins, 0.2f, 5.0f}}}); + rV0ParametersData.add("hV0Radius_Full_V0Data", "hV0Radius_Full_V0Data", {HistType::kTH1F, {{nBins, 0.2f, 40.0f}}}); + rV0ParametersData.add("hDCAPostoPV_V0Data", "hDCAPostoPV_V0Data", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); + rV0ParametersData.add("hDCANegtoPV_V0Data", "hDCANegtoPV_V0Data", {HistType::kTH1F, {{nBins, 0.0f, 2.0f}}}); + rV0ParametersData.add("hMassK0ShortNoCuts_V0Data", "hMassK0ShortNoCuts_V0Data", {HistType::kTH1F, {{k0ShortMassAxis}}}); + rV0ParametersData.add("hMassLambdaNoCuts_V0Data", "hMassLambdaNoCuts_V0Data", {HistType::kTH1F, {{lambdaMassAxis}}}); + rV0ParametersData.add("hMassAntilambdaNoCuts_V0Data", "hMassAntilambdaNoCuts_V0Data", {HistType::kTH1F, {{antiLambdaMassAxis}}}); + rV0ParametersData.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + // K0short Data + rV0ParametersData.add("hMassK0ShortAfterEtaCut", "hMassK0ShortAfterEtaCut", {HistType::kTH1F, {k0ShortMassAxis}}); + rV0ParametersData.add("hMassK0ShortAfterCompmassCut", "hMassK0ShortAfterCompmassCut", {HistType::kTH1F, {k0ShortMassAxis}}); + rV0ParametersData.add("hMassK0ShortAfterAllCuts", "hMassK0ShortAfterAllCuts", {HistType::kTH1F, {k0ShortMassAxis}}); + rV0ParametersData.add("hNSigmaPosPiFromK0s", "hNSigmaPosPiFromK0s", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rV0ParametersData.add("hNSigmaNegPiFromK0s", "hNSigmaNegPiFromK0s", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rV0ParametersData.add("hK0shEtaPosDau", "hK0shEtaPosDau", {HistType::kTH1F, {{nBins, -1.2f, 1.2f}}}); + rV0ParametersData.add("hK0shEtaNegDau", "hK0shEtaNegDau", {HistType::kTH1F, {{nBins, -1.2f, 1.2f}}}); + rV0ParametersData.add("hK0shEtaPosDauAfterCut", "hK0shEtaPosDauAfterCut", {HistType::kTH1F, {{nBins, -1.2f, 1.2f}}}); + rV0ParametersData.add("hK0shEtaNegDauAfterCut", "hK0shEtaNegDauAfterCut", {HistType::kTH1F, {{nBins, -1.2f, 1.2f}}}); + + // Lambda Data + rV0ParametersData.add("hMassLambdaAfterEtaCut", "hMassLambdaAfterEtaCut", {HistType::kTH1F, {lambdaMassAxis}}); + rV0ParametersData.add("hMassLambdaAfterCompmassCut", "hMassLambdaAfterCompmassCut", {HistType::kTH1F, {lambdaMassAxis}}); + rV0ParametersData.add("hMassLambdaAfterAllCuts", "hMassLambdaAfterAllCuts", {HistType::kTH1F, {lambdaMassAxis}}); + rV0ParametersData.add("hNSigmaPosProtonFromLambda", "hNSigmaPosProtonFromLambda", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rV0ParametersData.add("hNSigmaNegPionFromLambda", "hNSigmaNegPionFromLambda", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + // Antilambda Data + rV0ParametersData.add("hMassAntiLambdaAfterEtaCut", "hMassAntiLambdaAfterEtaCut", {HistType::kTH1F, {antiLambdaMassAxis}}); + rV0ParametersData.add("hMassAntiLambdaAfterCompmassCut", "hMassAntiLambdaAfterCompmassCut", {HistType::kTH1F, {antiLambdaMassAxis}}); + rV0ParametersData.add("hMassAntiLambdaAfterAllCuts", "hMassAntiLambdaAfterAllCuts", {HistType::kTH1F, {antiLambdaMassAxis}}); + rV0ParametersData.add("hNSigmaNegProtonFromAntilambda", "hNSigmaNegProtonFromAntilambda", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rV0ParametersData.add("hNSigmaPosPionFromAntilambda", "hNSigmaPosPionFromAntilambda", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); } // Defining filters for events (event selection) // Processed events will be already fulfilling the event selection requirements Filter eventFilter = (o2::aod::evsel::sel8 == true); + Filter posZFilterMC = (nabs(o2::aod::mccollision::posZ) < cutZVertex); + Filter posZFilter = (nabs(o2::aod::collision::posZ) < cutZVertex); // Defining the type of the daughter tracks - using DaughterTracks = soa::Join; + using DaughterTracks = soa::Join; // This is the Process for the MC reconstructed Data - void RecMCprocess(soa::Filtered>::iterator const&, + void recMCProcess(soa::Filtered>::iterator const& collision, soa::Join const& V0s, DaughterTracks const&, // no need to define a variable for tracks, if we don't access them directly aod::McParticles const&) { + const auto& mLambdaPDG = 1.115683; + const auto& mK0shPDG = 0.497611; for (const auto& v0 : V0s) { + if (std::abs(v0.posTrack_as().eta()) < etadau && std::abs(v0.negTrack_as().eta()) < etadau) { // daughters pseudorapidity cut + // filling histograms with V0 values + rV0ParametersMCV0match.fill(HIST("hDCAV0Daughters_V0_Match"), v0.dcaV0daughters()); + rV0ParametersMCV0match.fill(HIST("hV0CosPA_V0_Match"), v0.v0cosPA()); + rV0ParametersMCV0match.fill(HIST("hV0Radius_V0_Match"), v0.v0radius()); + rV0ParametersMCV0match.fill(HIST("hV0Radius_V0_Match_Full"), v0.v0radius()); + rV0ParametersMCV0match.fill(HIST("hDCAPostoPV_V0_Match"), v0.dcapostopv()); + rV0ParametersMCV0match.fill(HIST("hDCANegtoPV_V0_Match"), v0.dcanegtopv()); + rV0ParametersMCV0match.fill(HIST("hVertexZRec"), collision.posZ()); - // filling histograms with V0 values - rV0Parameters_MC_V0match.fill(HIST("hDCAV0Daughters_V0_Match"), v0.dcaV0daughters()); - rV0Parameters_MC_V0match.fill(HIST("hV0CosPA_V0_Match"), v0.v0cosPA()); - rV0Parameters_MC_V0match.fill(HIST("hV0Radius_V0_Match"), v0.v0radius()); - rV0Parameters_MC_V0match.fill(HIST("hV0Radius_V0_Match_Full"), v0.v0radius()); - rV0Parameters_MC_V0match.fill(HIST("hDCAPostoPV_V0_Match"), v0.dcapostopv()); - rV0Parameters_MC_V0match.fill(HIST("hDCANegtoPV_V0_Match"), v0.dcanegtopv()); - - // Checking that the V0 is a true K0s/Lambdas/Antilambdas and then filling the parameter histograms and the invariant mass plots for different cuts (which are taken from namespace) - if (v0.has_mcParticle()) { - auto v0mcParticle = v0.mcParticle(); - if (v0mcParticle.pdgCode() == 310) { // kzero matched + // Checking that the V0 is a true K0s/Lambdas/Antilambdas and then filling the parameter histograms and the invariant mass plots for different cuts (which are taken from namespace) + if (v0.has_mcParticle()) { + auto v0mcParticle = v0.mcParticle(); + if (v0mcParticle.pdgCode() == 310) { // kzero matched + if (std::abs(v0.mLambda() - mLambdaPDG) > compv0masscut && std::abs(v0.mAntiLambda() - mLambdaPDG) > compv0masscut) { // Kzero competitive v0 mass cut (cut out Lambdas and Anti-Lambdas) + rV0ParametersMCK0Smatch.fill(HIST("hDCAV0Daughters_KzeroMC_Match"), v0.dcaV0daughters()); + rV0ParametersMCK0Smatch.fill(HIST("hV0CosPA_KzeroMC_Match"), v0.v0cosPA()); + rV0ParametersMCK0Smatch.fill(HIST("hV0Radius_KzeroMC_Match"), v0.v0radius()); + rV0ParametersMCK0Smatch.fill(HIST("hDCAPostoPV_KzeroMC_Match"), std::abs(v0.dcapostopv())); + rV0ParametersMCK0Smatch.fill(HIST("hDCANegtoPV_KzeroMC_Match"), std::abs(v0.dcanegtopv())); - rV0Parameters_MC_K0Smatch.fill(HIST("hDCAV0Daughters_KzeroMC_Match"), v0.dcaV0daughters()); - rV0Parameters_MC_K0Smatch.fill(HIST("hV0CosPA_KzeroMC_Match"), v0.v0cosPA()); - rV0Parameters_MC_K0Smatch.fill(HIST("hV0Radius_KzeroMC_Match"), v0.v0radius()); - rV0Parameters_MC_K0Smatch.fill(HIST("hDCAPostoPV_KzeroMC_Match"), TMath::Abs(v0.dcapostopv())); - rV0Parameters_MC_K0Smatch.fill(HIST("hDCANegtoPV_KzeroMC_Match"), TMath::Abs(v0.dcanegtopv())); - - for (uint32_t j = 0; j < cuthistoskzerosh::cospacuts.size(); j++) { - std::string cospacut = cuthistoskzerosh::cospacuts[j]; // Get the current cut value from the namespace - size_t pos = cospacut.find("_"); // find the "_" which needs to change to a "." for it to be a number - cospacut[pos] = '.'; // change the "_" into an "." - const float cospacutvalue = std::stod(cospacut); // make the string into a float value - if (v0.v0cosPA() > cospacutvalue) { // enforce the cut value - cuthistoskzerosh::cospaCut[j]->Fill(v0.mK0Short()); // fill the corresponding histo from the namespace with the invariant mass (of a Kzero here) + for (uint32_t j = 0; j < cuthistoskzerosh::cosPAcuts.size(); j++) { + std::string cosPAcut = cuthistoskzerosh::cosPAcuts[j]; // Get the current cut value from the namespace + size_t pos = cosPAcut.find("_"); // find the "_" which needs to change to a "." for it to be a number + cosPAcut[pos] = '.'; // change the "_" into an "." + const float cosPAcutvalue = std::stod(cosPAcut); // make the string into a float value + if (v0.v0cosPA() > cosPAcutvalue) { // enforce the cut value + cuthistoskzerosh::cosPACut[j]->Fill(v0.mK0Short()); // fill the corresponding histo from the namespace with the invariant mass (of a Kzero here) + } + } + for (uint32_t j = 0; j < cuthistoskzerosh::dcacuts.size(); j++) { + std::string dcacut = cuthistoskzerosh::dcacuts[j]; + size_t pos = dcacut.find("_"); + dcacut[pos] = '.'; + const float dcacutvalue = std::stod(dcacut); + if (v0.dcaV0daughters() < dcacutvalue) { + cuthistoskzerosh::dcaCut[j]->Fill(v0.mK0Short()); + } + } + for (uint32_t j = 0; j < cuthistoskzerosh::v0radiuscuts.size(); j++) { + std::string v0radiuscut = cuthistoskzerosh::v0radiuscuts[j]; + size_t pos = v0radiuscut.find("_"); + v0radiuscut[pos] = '.'; + const float v0radiuscutvalue = std::stod(v0radiuscut); + if (v0.v0radius() > v0radiuscutvalue) { + cuthistoskzerosh::v0radiusCut[j]->Fill(v0.mK0Short()); + } + } + for (uint32_t j = 0; j < cuthistoskzerosh::dcapostopvcuts.size(); j++) { + std::string dcapostopcut = cuthistoskzerosh::dcapostopvcuts[j]; + size_t pos = dcapostopcut.find("_"); + dcapostopcut[pos] = '.'; + const float dcapostopcutvalue = std::stod(dcapostopcut); + if (std::abs(v0.dcapostopv()) > dcapostopcutvalue) { + cuthistoskzerosh::dcapostopCut[j]->Fill(v0.mK0Short()); + } + } + for (uint32_t j = 0; j < cuthistoskzerosh::dcanegtopvcuts.size(); j++) { + std::string dcanegtopcut = cuthistoskzerosh::dcanegtopvcuts[j]; + size_t pos = dcanegtopcut.find("_"); + dcanegtopcut[pos] = '.'; + const float dcanegtopcutvalue = std::stod(dcanegtopcut); + if (std::abs(v0.dcanegtopv()) > dcanegtopcutvalue) { + cuthistoskzerosh::dcanegtopCut[j]->Fill(v0.mK0Short()); + } + } } } - for (uint32_t j = 0; j < cuthistoskzerosh::dcacuts.size(); j++) { - std::string dcacut = cuthistoskzerosh::dcacuts[j]; - size_t pos = dcacut.find("_"); - dcacut[pos] = '.'; - const float dcacutvalue = std::stod(dcacut); - if (v0.dcaV0daughters() < dcacutvalue) { - cuthistoskzerosh::dcaCut[j]->Fill(v0.mK0Short()); - } - } - for (uint32_t j = 0; j < cuthistoskzerosh::v0radiuscuts.size(); j++) { - std::string v0radiuscut = cuthistoskzerosh::v0radiuscuts[j]; - size_t pos = v0radiuscut.find("_"); - v0radiuscut[pos] = '.'; - const float v0radiuscutvalue = std::stod(v0radiuscut); - if (v0.v0radius() > v0radiuscutvalue) { - cuthistoskzerosh::v0radiusCut[j]->Fill(v0.mK0Short()); - } - } - for (uint32_t j = 0; j < cuthistoskzerosh::dcapostopvcuts.size(); j++) { - std::string dcapostopcut = cuthistoskzerosh::dcapostopvcuts[j]; - size_t pos = dcapostopcut.find("_"); - dcapostopcut[pos] = '.'; - const float dcapostopcutvalue = std::stod(dcapostopcut); - if (TMath::Abs(v0.dcapostopv()) > dcapostopcutvalue) { - cuthistoskzerosh::dcapostopCut[j]->Fill(v0.mK0Short()); + if (v0mcParticle.pdgCode() == 3122) { // lambda matched + if (std::abs(v0.mK0Short() - mK0shPDG) > compv0masscut) { // antilambda competitive v0 mass cut (cut out Kaons) + rV0ParametersMCLambdamatch.fill(HIST("hDCAV0Daughters_LambdaMC_Match"), v0.dcaV0daughters()); + rV0ParametersMCLambdamatch.fill(HIST("hV0CosPA_LambdaMC_Match"), v0.v0cosPA()); + rV0ParametersMCLambdamatch.fill(HIST("hV0Radius_LambdaMC_Match"), v0.v0radius()); + rV0ParametersMCLambdamatch.fill(HIST("hDCAPostoPV_LambdaMC_Match"), std::abs(v0.dcapostopv())); + rV0ParametersMCLambdamatch.fill(HIST("hDCANegtoPV_LambdaMC_Match"), std::abs(v0.dcanegtopv())); + + // for explanation look at the first Kzero plot above + for (uint32_t j = 0; j < cuthistoslambda::cosPAcuts.size(); j++) { + std::string cosPAcutlambda = cuthistoslambda::cosPAcuts[j]; + size_t pos = cosPAcutlambda.find("_"); + cosPAcutlambda[pos] = '.'; + const float cosPAcutlambdavalue = std::stod(cosPAcutlambda); + if (v0.v0cosPA() > cosPAcutlambdavalue) { + cuthistoslambda::cosPACut[j]->Fill(v0.mLambda()); + } + } + for (uint32_t j = 0; j < cuthistoslambda::dcacuts.size(); j++) { + std::string dcacutlambda = cuthistoslambda::dcacuts[j]; + size_t pos = dcacutlambda.find("_"); + dcacutlambda[pos] = '.'; + const float dcacutlambdavalue = std::stod(dcacutlambda); + if (v0.dcaV0daughters() < dcacutlambdavalue) { + cuthistoslambda::dcaCut[j]->Fill(v0.mLambda()); + } + } + for (uint32_t j = 0; j < cuthistoslambda::v0radiuscuts.size(); j++) { + std::string v0radiuscutlambda = cuthistoslambda::v0radiuscuts[j]; + size_t pos = v0radiuscutlambda.find("_"); + v0radiuscutlambda[pos] = '.'; + const float v0radiuscutlambdavalue = std::stod(v0radiuscutlambda); + if (v0.v0radius() > v0radiuscutlambdavalue) { + cuthistoslambda::v0radiusCut[j]->Fill(v0.mLambda()); + } + } + for (uint32_t j = 0; j < cuthistoslambda::dcapostopvcuts.size(); j++) { + std::string dcapostopcutlambda = cuthistoslambda::dcapostopvcuts[j]; + size_t pos = dcapostopcutlambda.find("_"); + dcapostopcutlambda[pos] = '.'; + const float dcapostopcutlambdavalue = std::stod(dcapostopcutlambda); + if (std::abs(v0.dcapostopv()) > dcapostopcutlambdavalue) { + cuthistoslambda::dcapostopCut[j]->Fill(v0.mLambda()); + } + } + for (uint32_t j = 0; j < cuthistoslambda::dcanegtopvcuts.size(); j++) { + std::string dcanegtopcutlambda = cuthistoslambda::dcanegtopvcuts[j]; + size_t pos = dcanegtopcutlambda.find("_"); + dcanegtopcutlambda[pos] = '.'; + const float dcanegtopcutlambdavalue = std::stod(dcanegtopcutlambda); + if (std::abs(v0.dcanegtopv()) > dcanegtopcutlambdavalue) { + cuthistoslambda::dcanegtopCut[j]->Fill(v0.mLambda()); + } + } } } - for (uint32_t j = 0; j < cuthistoskzerosh::dcanegtopvcuts.size(); j++) { - std::string dcanegtopcut = cuthistoskzerosh::dcanegtopvcuts[j]; - size_t pos = dcanegtopcut.find("_"); - dcanegtopcut[pos] = '.'; - const float dcanegtopcutvalue = std::stod(dcanegtopcut); - if (TMath::Abs(v0.dcanegtopv()) > dcanegtopcutvalue) { - cuthistoskzerosh::dcanegtopCut[j]->Fill(v0.mK0Short()); + if (v0mcParticle.pdgCode() == -3122) { // antilambda matched + if (std::abs(v0.mK0Short() - mK0shPDG) > compv0masscut) { // antilambda competitive v0 mass cut (cut out Kaons) + rV0ParametersMCAntiLambdamatch.fill(HIST("hDCAV0Daughters_AntiLambdaMC_Match"), v0.dcaV0daughters()); + rV0ParametersMCAntiLambdamatch.fill(HIST("hV0CosPA_AntiLambdaMC_Match"), v0.v0cosPA()); + rV0ParametersMCAntiLambdamatch.fill(HIST("hV0Radius_AntiLambdaMC_Match"), v0.v0radius()); + rV0ParametersMCAntiLambdamatch.fill(HIST("hDCAPostoPV_AntiLambdaMC_Match"), std::abs(v0.dcapostopv())); + rV0ParametersMCAntiLambdamatch.fill(HIST("hDCANegtoPV_AntiLambdaMC_Match"), std::abs(v0.dcanegtopv())); + // for explanation look at the first Kzero plot above + for (uint32_t j = 0; j < cuthistosantilambda::cosPAcuts.size(); j++) { + std::string cosPAcutantilambda = cuthistosantilambda::cosPAcuts[j]; + size_t pos = cosPAcutantilambda.find("_"); + cosPAcutantilambda[pos] = '.'; + const float cosPAcutantilambdavalue = std::stod(cosPAcutantilambda); + if (v0.v0cosPA() > cosPAcutantilambdavalue) { + cuthistosantilambda::cosPACut[j]->Fill(v0.mAntiLambda()); + } + } + for (uint32_t j = 0; j < cuthistosantilambda::dcacuts.size(); j++) { + std::string dcacutantilambda = cuthistosantilambda::dcacuts[j]; + size_t pos = dcacutantilambda.find("_"); + dcacutantilambda[pos] = '.'; + const float dcacutantilambdavalue = std::stod(dcacutantilambda); + if (v0.dcaV0daughters() < dcacutantilambdavalue) { + cuthistosantilambda::dcaCut[j]->Fill(v0.mAntiLambda()); + } + } + for (uint32_t j = 0; j < cuthistosantilambda::v0radiuscuts.size(); j++) { + std::string v0radiusantilambda = cuthistosantilambda::v0radiuscuts[j]; + size_t pos = v0radiusantilambda.find("_"); + v0radiusantilambda[pos] = '.'; + const float v0radiuscutantilambdavalue = std::stod(v0radiusantilambda); + if (v0.v0radius() > v0radiuscutantilambdavalue) { + cuthistosantilambda::v0radiusCut[j]->Fill(v0.mAntiLambda()); + } + } + for (uint32_t j = 0; j < cuthistosantilambda::dcapostopvcuts.size(); j++) { + std::string dcapostopantilambda = cuthistosantilambda::dcapostopvcuts[j]; + size_t pos = dcapostopantilambda.find("_"); + dcapostopantilambda[pos] = '.'; + const float dcapostopcutantilambdavalue = std::stod(dcapostopantilambda); + if (std::abs(v0.dcapostopv()) > dcapostopcutantilambdavalue) { + cuthistosantilambda::dcapostopCut[j]->Fill(v0.mAntiLambda()); + } + } + for (uint32_t j = 0; j < cuthistosantilambda::dcanegtopvcuts.size(); j++) { + std::string dcanegtopantilambda = cuthistosantilambda::dcanegtopvcuts[j]; + size_t pos = dcanegtopantilambda.find("_"); + dcanegtopantilambda[pos] = '.'; + const float dcanegtopcutantilambdavalue = std::stod(dcanegtopantilambda); + if (std::abs(v0.dcanegtopv()) > dcanegtopcutantilambdavalue) { + cuthistosantilambda::dcanegtopCut[j]->Fill(v0.mAntiLambda()); + } + } } } } - if (v0mcParticle.pdgCode() == 3122) { // lambda matched - rV0Parameters_MC_Lambdamatch.fill(HIST("hDCAV0Daughters_LambdaMC_Match"), v0.dcaV0daughters()); - rV0Parameters_MC_Lambdamatch.fill(HIST("hV0CosPA_LambdaMC_Match"), v0.v0cosPA()); - rV0Parameters_MC_Lambdamatch.fill(HIST("hV0Radius_LambdaMC_Match"), v0.v0radius()); - rV0Parameters_MC_Lambdamatch.fill(HIST("hDCAPostoPV_LambdaMC_Match"), TMath::Abs(v0.dcapostopv())); - rV0Parameters_MC_Lambdamatch.fill(HIST("hDCANegtoPV_LambdaMC_Match"), TMath::Abs(v0.dcanegtopv())); + } + } + } + // This is the process for Real Data + void dataProcess(soa::Filtered>::iterator const& collision, + aod::V0Datas const& V0s, + DaughterTracks const&) + { + // filling histograms with the different V0 parameters + const auto& mLambdaPDG = 1.115683; + const auto& mK0shPDG = 0.497611; + for (const auto& v0 : V0s) { + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + rV0ParametersData.fill(HIST("hMassK0ShortNoCuts_V0Data"), v0.mK0Short()); + rV0ParametersData.fill(HIST("hMassLambdaNoCuts_V0Data"), v0.mLambda()); + rV0ParametersData.fill(HIST("hMassAntilambdaNoCuts_V0Data"), v0.mAntiLambda()); + rV0ParametersData.fill(HIST("hDCAV0Daughters_V0Data"), v0.dcaV0daughters()); + rV0ParametersData.fill(HIST("hV0CosPA_V0Data"), v0.v0cosPA()); + rV0ParametersData.fill(HIST("hV0Radius_V0Data"), v0.v0radius()); + rV0ParametersData.fill(HIST("hV0Radius_Full_V0Data"), v0.v0radius()); + rV0ParametersData.fill(HIST("hDCAPostoPV_V0Data"), std::abs(v0.dcapostopv())); + rV0ParametersData.fill(HIST("hDCANegtoPV_V0Data"), std::abs(v0.dcanegtopv())); + rV0ParametersData.fill(HIST("hVertexZRec"), collision.posZ()); + rV0ParametersData.fill(HIST("hK0shEtaPosDau"), v0.posTrack_as().eta()); + rV0ParametersData.fill(HIST("hK0shEtaNegDau"), v0.negTrack_as().eta()); - // for explanation look at the first Kzero plot above - for (uint32_t j = 0; j < cuthistoslambda::cospacuts.size(); j++) { - std::string cospacutlambda = cuthistoslambda::cospacuts[j]; - size_t pos = cospacutlambda.find("_"); - cospacutlambda[pos] = '.'; - const float cospacutlambdavalue = std::stod(cospacutlambda); - if (v0.v0cosPA() > cospacutlambdavalue) { - cuthistoslambda::cospaCut[j]->Fill(v0.mLambda()); + if (std::abs(v0.posTrack_as().eta()) < etadau && std::abs(v0.negTrack_as().eta()) < etadau) { // daughters pseudorapidity cut + rV0ParametersData.fill(HIST("hMassK0ShortAfterEtaCut"), v0.mK0Short()); + rV0ParametersData.fill(HIST("hMassLambdaAfterEtaCut"), v0.mLambda()); + rV0ParametersData.fill(HIST("hMassAntiLambdaAfterEtaCut"), v0.mAntiLambda()); + rV0ParametersData.fill(HIST("hK0shEtaPosDauAfterCut"), v0.posTrack_as().eta()); + rV0ParametersData.fill(HIST("hK0shEtaNegDauAfterCut"), v0.negTrack_as().eta()); + if (std::abs(v0.mLambda() - mLambdaPDG) > compv0masscut && std::abs(v0.mAntiLambda() - mLambdaPDG) > compv0masscut) { // antilambda competitive v0 mass cut (cut out Lambdas and Anti-Lambdas) + rV0ParametersData.fill(HIST("hMassK0ShortAfterCompmassCut"), v0.mK0Short()); + if (std::abs(posDaughterTrack.tpcNSigmaPi()) < nSigmaTPCPion && std::abs(negDaughterTrack.tpcNSigmaPi()) < nSigmaTPCPion) { // TPC PID on daughter pions + rV0ParametersData.fill(HIST("hMassK0ShortAfterAllCuts"), v0.mK0Short()); + rV0ParametersData.fill(HIST("hNSigmaPosPiFromK0s"), posDaughterTrack.tpcNSigmaPi(), posDaughterTrack.tpcInnerParam()); + rV0ParametersData.fill(HIST("hNSigmaNegPiFromK0s"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam()); + // Filling the five Kzero invariant mass plots for different cuts (which are taken from namespace), for full explanation see the first kzero cut filling in the MC process + for (uint32_t j = 0; j < cuthistoskzerosh::cosPAcuts.size(); j++) { + std::string cosPAcut = cuthistoskzerosh::cosPAcuts[j]; + size_t pos = cosPAcut.find("_"); + cosPAcut[pos] = '.'; + const float cosPAcutvalue = std::stod(cosPAcut); + if (v0.v0cosPA() > cosPAcutvalue) { + cuthistoskzerosh::cosPACut[j]->Fill(v0.mK0Short()); + } } - } - for (uint32_t j = 0; j < cuthistoslambda::dcacuts.size(); j++) { - std::string dcacutlambda = cuthistoslambda::dcacuts[j]; - size_t pos = dcacutlambda.find("_"); - dcacutlambda[pos] = '.'; - const float dcacutlambdavalue = std::stod(dcacutlambda); - if (v0.dcaV0daughters() < dcacutlambdavalue) { - cuthistoslambda::dcaCut[j]->Fill(v0.mLambda()); + for (uint32_t j = 0; j < cuthistoskzerosh::dcacuts.size(); j++) { + std::string dcacut = cuthistoskzerosh::dcacuts[j]; + size_t pos = dcacut.find("_"); + dcacut[pos] = '.'; + const float dcacutvalue = std::stod(dcacut); + if (v0.dcaV0daughters() < dcacutvalue) { + cuthistoskzerosh::dcaCut[j]->Fill(v0.mK0Short()); + } } - } - for (uint32_t j = 0; j < cuthistoslambda::v0radiuscuts.size(); j++) { - std::string v0radiuscutlambda = cuthistoslambda::v0radiuscuts[j]; - size_t pos = v0radiuscutlambda.find("_"); - v0radiuscutlambda[pos] = '.'; - const float v0radiuscutlambdavalue = std::stod(v0radiuscutlambda); - if (v0.v0radius() > v0radiuscutlambdavalue) { - cuthistoslambda::v0radiusCut[j]->Fill(v0.mLambda()); + for (uint32_t j = 0; j < cuthistoskzerosh::v0radiuscuts.size(); j++) { + std::string v0radiuscut = cuthistoskzerosh::v0radiuscuts[j]; + size_t pos = v0radiuscut.find("_"); + v0radiuscut[pos] = '.'; + const float v0radiuscutvalue = std::stod(v0radiuscut); + if (v0.v0radius() > v0radiuscutvalue) { + cuthistoskzerosh::v0radiusCut[j]->Fill(v0.mK0Short()); + } } - } - for (uint32_t j = 0; j < cuthistoslambda::dcapostopvcuts.size(); j++) { - std::string dcapostopcutlambda = cuthistoslambda::dcapostopvcuts[j]; - size_t pos = dcapostopcutlambda.find("_"); - dcapostopcutlambda[pos] = '.'; - const float dcapostopcutlambdavalue = std::stod(dcapostopcutlambda); - if (TMath::Abs(v0.dcapostopv()) > dcapostopcutlambdavalue) { - cuthistoslambda::dcapostopCut[j]->Fill(v0.mLambda()); + for (uint32_t j = 0; j < cuthistoskzerosh::dcapostopvcuts.size(); j++) { + std::string dcapostopcut = cuthistoskzerosh::dcapostopvcuts[j]; + size_t pos = dcapostopcut.find("_"); + dcapostopcut[pos] = '.'; + const float dcapostopcutvalue = std::stod(dcapostopcut); + if (std::abs(v0.dcapostopv()) > dcapostopcutvalue) { + cuthistoskzerosh::dcapostopCut[j]->Fill(v0.mK0Short()); + } } - } - for (uint32_t j = 0; j < cuthistoslambda::dcanegtopvcuts.size(); j++) { - std::string dcanegtopcutlambda = cuthistoslambda::dcanegtopvcuts[j]; - size_t pos = dcanegtopcutlambda.find("_"); - dcanegtopcutlambda[pos] = '.'; - const float dcanegtopcutlambdavalue = std::stod(dcanegtopcutlambda); - if (TMath::Abs(v0.dcanegtopv()) > dcanegtopcutlambdavalue) { - cuthistoslambda::dcanegtopCut[j]->Fill(v0.mLambda()); + for (uint32_t j = 0; j < cuthistoskzerosh::dcanegtopvcuts.size(); j++) { + std::string dcanegtopcut = cuthistoskzerosh::dcanegtopvcuts[j]; + size_t pos = dcanegtopcut.find("_"); + dcanegtopcut[pos] = '.'; + const float dcanegtopcutvalue = std::stod(dcanegtopcut); + if (std::abs(v0.dcanegtopv()) > dcanegtopcutvalue) { + cuthistoskzerosh::dcanegtopCut[j]->Fill(v0.mK0Short()); + } } } } - if (v0mcParticle.pdgCode() == -3122) { // antilambda matched - rV0Parameters_MC_AntiLambdamatch.fill(HIST("hDCAV0Daughters_AntiLambdaMC_Match"), v0.dcaV0daughters()); - rV0Parameters_MC_AntiLambdamatch.fill(HIST("hV0CosPA_AntiLambdaMC_Match"), v0.v0cosPA()); - rV0Parameters_MC_AntiLambdamatch.fill(HIST("hV0Radius_AntiLambdaMC_Match"), v0.v0radius()); - rV0Parameters_MC_AntiLambdamatch.fill(HIST("hDCAPostoPV_AntiLambdaMC_Match"), TMath::Abs(v0.dcapostopv())); - rV0Parameters_MC_AntiLambdamatch.fill(HIST("hDCANegtoPV_AntiLambdaMC_Match"), TMath::Abs(v0.dcanegtopv())); - // for explanation look at the first Kzero plot above - for (uint32_t j = 0; j < cuthistosantilambda::cospacuts.size(); j++) { - std::string cospacutantilambda = cuthistosantilambda::cospacuts[j]; - size_t pos = cospacutantilambda.find("_"); - cospacutantilambda[pos] = '.'; - const float cospacutantilambdavalue = std::stod(cospacutantilambda); - if (v0.v0cosPA() > cospacutantilambdavalue) { - cuthistosantilambda::cospaCut[j]->Fill(v0.mAntiLambda()); + if (std::abs(v0.mK0Short() - mK0shPDG) > compv0masscut) { // lambda competitive v0 mass cut (cut out Kaons) + rV0ParametersData.fill(HIST("hMassLambdaAfterCompmassCut"), v0.mLambda()); + rV0ParametersData.fill(HIST("hMassAntiLambdaAfterCompmassCut"), v0.mAntiLambda()); + if (std::abs(posDaughterTrack.tpcNSigmaPr()) < nSigmaTPCProton && std::abs(negDaughterTrack.tpcNSigmaPi()) < nSigmaTPCPion) { // TPC PID on daughter pion and proton for Lambda + rV0ParametersData.fill(HIST("hMassLambdaAfterAllCuts"), v0.mLambda()); + rV0ParametersData.fill(HIST("hNSigmaPosProtonFromLambda"), posDaughterTrack.tpcNSigmaPr(), posDaughterTrack.tpcInnerParam()); + rV0ParametersData.fill(HIST("hNSigmaNegPionFromLambda"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam()); + // Filling the five Lambda invariant mass plots for different cuts (which are taken from namespace), same as with Kzeros above,for full explanation see the first kzero cut filling in the MC process + for (uint32_t j = 0; j < cuthistoslambda::cosPAcuts.size(); j++) { + std::string cosPAcutlambda = cuthistoslambda::cosPAcuts[j]; + size_t pos = cosPAcutlambda.find("_"); + cosPAcutlambda[pos] = '.'; + const float cosPAcutlambdavalue = std::stod(cosPAcutlambda); + if (v0.v0cosPA() > cosPAcutlambdavalue) { + cuthistoslambda::cosPACut[j]->Fill(v0.mLambda()); + } } - } - for (uint32_t j = 0; j < cuthistosantilambda::dcacuts.size(); j++) { - std::string dcacutantilambda = cuthistosantilambda::dcacuts[j]; - size_t pos = dcacutantilambda.find("_"); - dcacutantilambda[pos] = '.'; - const float dcacutantilambdavalue = std::stod(dcacutantilambda); - if (v0.dcaV0daughters() < dcacutantilambdavalue) { - cuthistosantilambda::dcaCut[j]->Fill(v0.mAntiLambda()); + for (uint32_t j = 0; j < cuthistoslambda::dcacuts.size(); j++) { + std::string dcacutlambda = cuthistoslambda::dcacuts[j]; + size_t pos = dcacutlambda.find("_"); + dcacutlambda[pos] = '.'; + const float dcacutlambdavalue = std::stod(dcacutlambda); + if (v0.dcaV0daughters() < dcacutlambdavalue) { + cuthistoslambda::dcaCut[j]->Fill(v0.mLambda()); + } } - } - for (uint32_t j = 0; j < cuthistosantilambda::v0radiuscuts.size(); j++) { - std::string v0radiusantilambda = cuthistosantilambda::v0radiuscuts[j]; - size_t pos = v0radiusantilambda.find("_"); - v0radiusantilambda[pos] = '.'; - const float v0radiuscutantilambdavalue = std::stod(v0radiusantilambda); - if (v0.v0radius() > v0radiuscutantilambdavalue) { - cuthistosantilambda::v0radiusCut[j]->Fill(v0.mAntiLambda()); + for (uint32_t j = 0; j < cuthistoslambda::v0radiuscuts.size(); j++) { + std::string v0radiuscutlambda = cuthistoslambda::v0radiuscuts[j]; + size_t pos = v0radiuscutlambda.find("_"); + v0radiuscutlambda[pos] = '.'; + const float v0radiuscutlambdavalue = std::stod(v0radiuscutlambda); + if (v0.v0radius() > v0radiuscutlambdavalue) { + cuthistoslambda::v0radiusCut[j]->Fill(v0.mLambda()); + } } - } - for (uint32_t j = 0; j < cuthistosantilambda::dcapostopvcuts.size(); j++) { - std::string dcapostopantilambda = cuthistosantilambda::dcapostopvcuts[j]; - size_t pos = dcapostopantilambda.find("_"); - dcapostopantilambda[pos] = '.'; - const float dcapostopcutantilambdavalue = std::stod(dcapostopantilambda); - if (TMath::Abs(v0.dcapostopv()) > dcapostopcutantilambdavalue) { - cuthistosantilambda::dcapostopCut[j]->Fill(v0.mAntiLambda()); + for (uint32_t j = 0; j < cuthistoslambda::dcanegtopvcuts.size(); j++) { + std::string dcapostopcutlambda = cuthistoslambda::dcapostopvcuts[j]; + size_t pos = dcapostopcutlambda.find("_"); + dcapostopcutlambda[pos] = '.'; + const float dcapostopcutlambdavalue = std::stod(dcapostopcutlambda); + if (std::abs(v0.dcapostopv()) > dcapostopcutlambdavalue) { + cuthistoslambda::dcapostopCut[j]->Fill(v0.mLambda()); + } + } + for (uint32_t j = 0; j < cuthistoslambda::dcanegtopvcuts.size(); j++) { + std::string dcanegtopcutlambda = cuthistoslambda::dcanegtopvcuts[j]; + size_t pos = dcanegtopcutlambda.find("_"); + dcanegtopcutlambda[pos] = '.'; + const float dcanegtopcutlambdavalue = std::stod(dcanegtopcutlambda); + if (std::abs(v0.dcanegtopv()) > dcanegtopcutlambdavalue) { + cuthistoslambda::dcanegtopCut[j]->Fill(v0.mLambda()); + } } } - for (uint32_t j = 0; j < cuthistosantilambda::dcanegtopvcuts.size(); j++) { - std::string dcanegtopantilambda = cuthistosantilambda::dcanegtopvcuts[j]; - size_t pos = dcanegtopantilambda.find("_"); - dcanegtopantilambda[pos] = '.'; - const float dcanegtopcutantilambdavalue = std::stod(dcanegtopantilambda); - if (TMath::Abs(v0.dcanegtopv()) > dcanegtopcutantilambdavalue) { - cuthistosantilambda::dcanegtopCut[j]->Fill(v0.mAntiLambda()); + // Filling the five Anti-Lambda invariant mass plots for different cuts (which are taken from namespace), same as with Kzeros and Lambdas above,for full explanation see the first kzero cut filling in the MC process + if (std::abs(negDaughterTrack.tpcNSigmaPr()) < nSigmaTPCProton && std::abs(posDaughterTrack.tpcNSigmaPi()) < nSigmaTPCPion) { // TPC PID on daughter pion and proton for AntiLambda + rV0ParametersData.fill(HIST("hMassAntiLambdaAfterAllCuts"), v0.mAntiLambda()); + rV0ParametersData.fill(HIST("hNSigmaPosPionFromAntilambda"), posDaughterTrack.tpcNSigmaPi(), posDaughterTrack.tpcInnerParam()); + rV0ParametersData.fill(HIST("hNSigmaNegProtonFromAntilambda"), negDaughterTrack.tpcNSigmaPr(), negDaughterTrack.tpcInnerParam()); + for (uint32_t j = 0; j < cuthistosantilambda::cosPAcuts.size(); j++) { + std::string cosPAcutantilambda = cuthistosantilambda::cosPAcuts[j]; + size_t pos = cosPAcutantilambda.find("_"); + cosPAcutantilambda[pos] = '.'; + const float cosPAcutantilambdavalue = std::stod(cosPAcutantilambda); + if (v0.v0cosPA() > cosPAcutantilambdavalue) { + cuthistosantilambda::cosPACut[j]->Fill(v0.mAntiLambda()); + } + } + for (uint32_t j = 0; j < cuthistosantilambda::dcacuts.size(); j++) { + std::string dcacutantilambda = cuthistosantilambda::dcacuts[j]; + size_t pos = dcacutantilambda.find("_"); + dcacutantilambda[pos] = '.'; + const float dcacutantilambdavalue = std::stod(dcacutantilambda); + if (v0.dcaV0daughters() < dcacutantilambdavalue) { + cuthistosantilambda::dcaCut[j]->Fill(v0.mAntiLambda()); + } + } + for (uint32_t j = 0; j < cuthistosantilambda::v0radiuscuts.size(); j++) { + std::string v0radiusantilambda = cuthistosantilambda::v0radiuscuts[j]; + size_t pos = v0radiusantilambda.find("_"); + v0radiusantilambda[pos] = '.'; + const float v0radiuscutantilambdavalue = std::stod(v0radiusantilambda); + if (v0.v0radius() > v0radiuscutantilambdavalue) { + cuthistosantilambda::v0radiusCut[j]->Fill(v0.mAntiLambda()); + } + } + for (uint32_t j = 0; j < cuthistosantilambda::dcapostopvcuts.size(); j++) { + std::string dcapostopantilambda = cuthistosantilambda::dcapostopvcuts[j]; + size_t pos = dcapostopantilambda.find("_"); + dcapostopantilambda[pos] = '.'; + const float dcapostopcutantilambdavalue = std::stod(dcapostopantilambda); + if (std::abs(v0.dcapostopv()) > dcapostopcutantilambdavalue) { + cuthistosantilambda::dcapostopCut[j]->Fill(v0.mAntiLambda()); + } + } + for (uint32_t j = 0; j < cuthistosantilambda::dcanegtopvcuts.size(); j++) { + std::string dcanegtopantilambda = cuthistosantilambda::dcanegtopvcuts[j]; + size_t pos = dcanegtopantilambda.find("_"); + dcanegtopantilambda[pos] = '.'; + const float dcanegtopcutantilambdavalue = std::stod(dcanegtopantilambda); + if (std::abs(v0.dcanegtopv()) > dcanegtopcutantilambdavalue) { + cuthistosantilambda::dcanegtopCut[j]->Fill(v0.mAntiLambda()); + } } } } } } } - // This is the process for Real Data - void Dataprocess(soa::Filtered>::iterator const&, - aod::V0Datas const& V0s) - { - // filling histograms with the different V0 parameters - for (const auto& v0 : V0s) { - rV0Parameters_Data.fill(HIST("hMassK0ShortNoCuts_V0_Data"), v0.mK0Short()); - rV0Parameters_Data.fill(HIST("hMassLambdaNoCuts_V0_Data"), v0.mLambda()); - rV0Parameters_Data.fill(HIST("hMassAntilambdaNoCuts_V0_Data"), v0.mAntiLambda()); - rV0Parameters_Data.fill(HIST("hDCAV0Daughters_V0_Data"), v0.dcaV0daughters()); - rV0Parameters_Data.fill(HIST("hV0CosPA_V0_Data"), v0.v0cosPA()); - rV0Parameters_Data.fill(HIST("hV0Radius_V0_Data"), v0.v0radius()); - rV0Parameters_Data.fill(HIST("hV0Radius_Full_V0_Data"), v0.v0radius()); - rV0Parameters_Data.fill(HIST("hDCAPostoPV_V0_Data"), TMath::Abs(v0.dcapostopv())); - rV0Parameters_Data.fill(HIST("hDCANegtoPV_V0_Data"), TMath::Abs(v0.dcanegtopv())); - - // Filling the five Kzero invariant mass plots for different cuts (which are taken from namespace), for full explanation see the first kzero cut filling in the MC process - for (uint32_t j = 0; j < cuthistoskzerosh::cospacuts.size(); j++) { - std::string cospacut = cuthistoskzerosh::cospacuts[j]; - size_t pos = cospacut.find("_"); - cospacut[pos] = '.'; - const float cospacutvalue = std::stod(cospacut); - if (v0.v0cosPA() > cospacutvalue) { - cuthistoskzerosh::cospaCut[j]->Fill(v0.mK0Short()); - } - } - for (uint32_t j = 0; j < cuthistoskzerosh::dcacuts.size(); j++) { - std::string dcacut = cuthistoskzerosh::dcacuts[j]; - size_t pos = dcacut.find("_"); - dcacut[pos] = '.'; - const float dcacutvalue = std::stod(dcacut); - if (v0.dcaV0daughters() < dcacutvalue) { - cuthistoskzerosh::dcaCut[j]->Fill(v0.mK0Short()); - } - } - for (uint32_t j = 0; j < cuthistoskzerosh::v0radiuscuts.size(); j++) { - std::string v0radiuscut = cuthistoskzerosh::v0radiuscuts[j]; - size_t pos = v0radiuscut.find("_"); - v0radiuscut[pos] = '.'; - const float v0radiuscutvalue = std::stod(v0radiuscut); - if (v0.v0radius() > v0radiuscutvalue) { - cuthistoskzerosh::v0radiusCut[j]->Fill(v0.mK0Short()); - } - } - for (uint32_t j = 0; j < cuthistoskzerosh::dcapostopvcuts.size(); j++) { - std::string dcapostopcut = cuthistoskzerosh::dcapostopvcuts[j]; - size_t pos = dcapostopcut.find("_"); - dcapostopcut[pos] = '.'; - const float dcapostopcutvalue = std::stod(dcapostopcut); - if (TMath::Abs(v0.dcapostopv()) > dcapostopcutvalue) { - cuthistoskzerosh::dcapostopCut[j]->Fill(v0.mK0Short()); - } - } - for (uint32_t j = 0; j < cuthistoskzerosh::dcanegtopvcuts.size(); j++) { - std::string dcanegtopcut = cuthistoskzerosh::dcanegtopvcuts[j]; - size_t pos = dcanegtopcut.find("_"); - dcanegtopcut[pos] = '.'; - const float dcanegtopcutvalue = std::stod(dcanegtopcut); - if (TMath::Abs(v0.dcanegtopv()) > dcanegtopcutvalue) { - cuthistoskzerosh::dcanegtopCut[j]->Fill(v0.mK0Short()); - } - } - // Filling the five Lambda invariant mass plots for different cuts (which are taken from namespace), same as with Kzeros above,for full explanation see the first kzero cut filling in the MC process - for (uint32_t j = 0; j < cuthistoslambda::cospacuts.size(); j++) { - std::string cospacutlambda = cuthistoslambda::cospacuts[j]; - size_t pos = cospacutlambda.find("_"); - cospacutlambda[pos] = '.'; - const float cospacutlambdavalue = std::stod(cospacutlambda); - if (v0.v0cosPA() > cospacutlambdavalue) { - cuthistoslambda::cospaCut[j]->Fill(v0.mLambda()); - } - } - for (uint32_t j = 0; j < cuthistoslambda::dcacuts.size(); j++) { - std::string dcacutlambda = cuthistoslambda::dcacuts[j]; - size_t pos = dcacutlambda.find("_"); - dcacutlambda[pos] = '.'; - const float dcacutlambdavalue = std::stod(dcacutlambda); - if (v0.dcaV0daughters() < dcacutlambdavalue) { - cuthistoslambda::dcaCut[j]->Fill(v0.mLambda()); - } - } - for (uint32_t j = 0; j < cuthistoslambda::v0radiuscuts.size(); j++) { - std::string v0radiuscutlambda = cuthistoslambda::v0radiuscuts[j]; - size_t pos = v0radiuscutlambda.find("_"); - v0radiuscutlambda[pos] = '.'; - const float v0radiuscutlambdavalue = std::stod(v0radiuscutlambda); - if (v0.v0radius() > v0radiuscutlambdavalue) { - cuthistoslambda::v0radiusCut[j]->Fill(v0.mLambda()); - } - } - for (uint32_t j = 0; j < cuthistoslambda::dcanegtopvcuts.size(); j++) { - std::string dcapostopcutlambda = cuthistoslambda::dcapostopvcuts[j]; - size_t pos = dcapostopcutlambda.find("_"); - dcapostopcutlambda[pos] = '.'; - const float dcapostopcutlambdavalue = std::stod(dcapostopcutlambda); - if (TMath::Abs(v0.dcapostopv()) > dcapostopcutlambdavalue) { - cuthistoslambda::dcapostopCut[j]->Fill(v0.mLambda()); - } - } - for (uint32_t j = 0; j < cuthistoslambda::dcanegtopvcuts.size(); j++) { - std::string dcanegtopcutlambda = cuthistoslambda::dcanegtopvcuts[j]; - size_t pos = dcanegtopcutlambda.find("_"); - dcanegtopcutlambda[pos] = '.'; - const float dcanegtopcutlambdavalue = std::stod(dcanegtopcutlambda); - if (TMath::Abs(v0.dcanegtopv()) > dcanegtopcutlambdavalue) { - cuthistoslambda::dcanegtopCut[j]->Fill(v0.mLambda()); - } - } - // Filling the five Anti-Lambda invariant mass plots for different cuts (which are taken from namespace), same as with Kzeros and Lambdas above,for full explanation see the first kzero cut filling in the MC process - for (uint32_t j = 0; j < cuthistosantilambda::cospacuts.size(); j++) { - std::string cospacutantilambda = cuthistosantilambda::cospacuts[j]; - size_t pos = cospacutantilambda.find("_"); - cospacutantilambda[pos] = '.'; - const float cospacutantilambdavalue = std::stod(cospacutantilambda); - if (v0.v0cosPA() > cospacutantilambdavalue) { - cuthistosantilambda::cospaCut[j]->Fill(v0.mAntiLambda()); - } - } - for (uint32_t j = 0; j < cuthistosantilambda::dcacuts.size(); j++) { - std::string dcacutantilambda = cuthistosantilambda::dcacuts[j]; - size_t pos = dcacutantilambda.find("_"); - dcacutantilambda[pos] = '.'; - const float dcacutantilambdavalue = std::stod(dcacutantilambda); - if (v0.dcaV0daughters() < dcacutantilambdavalue) { - cuthistosantilambda::dcaCut[j]->Fill(v0.mAntiLambda()); - } - } - for (uint32_t j = 0; j < cuthistosantilambda::v0radiuscuts.size(); j++) { - std::string v0radiusantilambda = cuthistosantilambda::v0radiuscuts[j]; - size_t pos = v0radiusantilambda.find("_"); - v0radiusantilambda[pos] = '.'; - const float v0radiuscutantilambdavalue = std::stod(v0radiusantilambda); - if (v0.v0radius() > v0radiuscutantilambdavalue) { - cuthistosantilambda::v0radiusCut[j]->Fill(v0.mAntiLambda()); - } - } - for (uint32_t j = 0; j < cuthistosantilambda::dcapostopvcuts.size(); j++) { - std::string dcapostopantilambda = cuthistosantilambda::dcapostopvcuts[j]; - size_t pos = dcapostopantilambda.find("_"); - dcapostopantilambda[pos] = '.'; - const float dcapostopcutantilambdavalue = std::stod(dcapostopantilambda); - if (TMath::Abs(v0.dcapostopv()) > dcapostopcutantilambdavalue) { - cuthistosantilambda::dcapostopCut[j]->Fill(v0.mAntiLambda()); - } - } - for (uint32_t j = 0; j < cuthistosantilambda::dcanegtopvcuts.size(); j++) { - std::string dcanegtopantilambda = cuthistosantilambda::dcanegtopvcuts[j]; - size_t pos = dcanegtopantilambda.find("_"); - dcanegtopantilambda[pos] = '.'; - const float dcanegtopcutantilambdavalue = std::stod(dcanegtopantilambda); - if (TMath::Abs(v0.dcanegtopv()) > dcanegtopcutantilambdavalue) { - cuthistosantilambda::dcanegtopCut[j]->Fill(v0.mAntiLambda()); - } - } - } - } - PROCESS_SWITCH(v0topologicalcuts, RecMCprocess, "Process Run 3 MC:Reconstructed", true); - PROCESS_SWITCH(v0topologicalcuts, Dataprocess, "Process Run 3 Data,", false); + PROCESS_SWITCH(v0topologicalcuts, recMCProcess, "Process Run 3 MC:Reconstructed", true); + PROCESS_SWITCH(v0topologicalcuts, dataProcess, "Process Run 3 Data,", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Utils/CMakeLists.txt b/PWGLF/Utils/CMakeLists.txt index bc3fd97b824..51048b896a5 100644 --- a/PWGLF/Utils/CMakeLists.txt +++ b/PWGLF/Utils/CMakeLists.txt @@ -15,4 +15,4 @@ o2physics_add_library(v0SelectionGroup o2physics_target_root_dictionary(v0SelectionGroup HEADERS v0SelectionGroup.h - LINKDEF v0SelectionGroupLinkDef.h) + LINKDEF v0SelectionGroupLinkDef.h) \ No newline at end of file diff --git a/PWGLF/Utils/collisionCuts.h b/PWGLF/Utils/collisionCuts.h index 6322e272083..b1a80cfe075 100644 --- a/PWGLF/Utils/collisionCuts.h +++ b/PWGLF/Utils/collisionCuts.h @@ -16,13 +16,17 @@ /// original author: Laura Serksnyte, TU München /// /// \author Bong-Hwi Lim +/// \author Hirak Kumar Koley #ifndef PWGLF_UTILS_COLLISIONCUTS_H_ #define PWGLF_UTILS_COLLISIONCUTS_H_ +#include "Common/DataModel/EventSelection.h" + #include "Framework/HistogramRegistry.h" #include "Framework/Logger.h" -#include "Common/DataModel/EventSelection.h" + +#include namespace o2::analysis { @@ -43,6 +47,8 @@ class CollisonCuts kFlagBunchPileup, kFlagZvtxFT0vsPV, kFlagOccupancy, + kNoCollInTimeRangeStandard, + kNoCollInTimeRangeNarrow, kAllpassed }; @@ -54,14 +60,12 @@ class CollisonCuts /// \brief Pass the selection criteria to the class /// \param zvtxMax Maximal value of the z-vertex /// \param checkTrigger whether or not to check for the trigger alias - /// \param trig Requested trigger alias /// \param checkOffline whether or not to check for offline selection criteria - void setCuts(float zvtxMax, bool checkTrigger, int trig, bool checkOffline, bool checkRun3, bool triggerTVXsel = false, int trackOccupancyInTimeRangeMax = -1, int trackOccupancyInTimeRangeMin = -1) + void setCuts(float zvtxMax, bool checkTrigger, bool checkOffline, bool checkRun3, bool triggerTVXsel = false, int trackOccupancyInTimeRangeMax = -1, int trackOccupancyInTimeRangeMin = -1) { mCutsSet = true; mZvtxMax = zvtxMax; mCheckTrigger = checkTrigger; - mTrigger = trig; mCheckOffline = checkOffline; mTriggerTVXselection = triggerTVXsel; mCheckIsRun3 = checkRun3; @@ -70,9 +74,12 @@ class CollisonCuts mApplyZvertexTimedifference = false; mApplyPileupRejection = false; mApplyNoITSROBorderCut = false; + mApplyCollInTimeRangeNarrow = false; mApplyCollInTimeRangeStandard = false; mtrackOccupancyInTimeRangeMax = trackOccupancyInTimeRangeMax; mtrackOccupancyInTimeRangeMin = trackOccupancyInTimeRangeMin; + mApplyRun2AliEventCuts = true; + mApplyRun2INELgtZERO = false; } /// Initializes histograms for the task @@ -82,11 +89,13 @@ class CollisonCuts if (!mCutsSet) { LOGF(error, "Event selection not set - quitting!"); } + for (int i = 0; i < kNaliases; i++) { + bitList.push_back(1 << i); // BIT(i) + } mHistogramRegistry = registry; mHistogramRegistry->add("Event/posZ", "; vtx_{z} (cm); Entries", o2::framework::kTH1F, {{250, -12.5, 12.5}}); // z-vertex histogram after event selections mHistogramRegistry->add("Event/posZ_noCut", "; vtx_{z} (cm); Entries", o2::framework::kTH1F, {{250, -12.5, 12.5}}); // z-vertex histogram before all selections if (mCheckIsRun3) { - mHistogramRegistry->add("Event/CentFV0A", "; vCentV0A; Entries", o2::framework::kTH1F, {{110, 0, 110}}); mHistogramRegistry->add("Event/CentFT0M", "; vCentT0M; Entries", o2::framework::kTH1F, {{110, 0, 110}}); mHistogramRegistry->add("Event/CentFT0C", "; vCentT0C; Entries", o2::framework::kTH1F, {{110, 0, 110}}); mHistogramRegistry->add("Event/CentFT0A", "; vCentT0A; Entries", o2::framework::kTH1F, {{110, 0, 110}}); @@ -96,7 +105,7 @@ class CollisonCuts } else { mHistogramRegistry->add("Event/CentRun2V0M", "; vCentV0M; Entries", o2::framework::kTH1F, {{110, 0, 110}}); } - mHistogramRegistry->add("CollCutCounts", "; ; Entries", o2::framework::kTH1F, {{11, 0., 11.}}); + mHistogramRegistry->add("CollCutCounts", "; ; Entries", o2::framework::kTH1F, {{kAllpassed + 1, 0, kAllpassed + 1}}); mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kAllEvent), "all"); mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagZvertex), "Zvtx"); mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagTrigerTVX), "IsTriggerTVX"); @@ -107,28 +116,48 @@ class CollisonCuts mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagBunchPileup), "NoSameBunchPileup"); mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagZvtxFT0vsPV), "IsGoodZvtxFT0vsPV"); mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagOccupancy), "LowOccupancy"); + mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kNoCollInTimeRangeStandard), "NoCollInTimeRangeStandard"); + mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kNoCollInTimeRangeNarrow), "NoCollInTimeRangeNarrow"); mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kAllpassed), "Allpassed"); } /// Print some debug information void printCuts() { - LOGF(info, "Debug information for Collison Cuts \n Max. z-vertex: %f \n Check trigger: %d \n Trigger: %d \n Check offline: %d \n Check Run3: %d \n Trigger TVX selection: %d \n Apply time frame border cut: %d \n Apply ITS-TPC vertex: %d \n Apply Z-vertex time difference: %d \n Apply Pileup rejection: %d \n Apply NoITSRO frame border cut: %d \n Track occupancy in time range max: %d \n Track occupancy in time range min: %d \n Apply NoCollInTimeRangeStandard: %d", - mZvtxMax, mCheckTrigger, mTrigger, mCheckOffline, mCheckIsRun3, mTriggerTVXselection, mApplyTFBorderCut, mApplyITSTPCvertex, mApplyZvertexTimedifference, mApplyPileupRejection, mApplyNoITSROBorderCut, mtrackOccupancyInTimeRangeMax, mtrackOccupancyInTimeRangeMin, mApplyCollInTimeRangeStandard); + LOGF(info, "Debug information for Collison Cuts"); + LOGF(info, "Max. z-vertex: %f", mZvtxMax); + LOGF(info, "Check trigger: %d", mCheckTrigger); + LOGF(info, "Check offline: %d", mCheckOffline); + LOGF(info, "Check Run3: %d", mCheckIsRun3); + if (mCheckIsRun3) { + LOGF(info, "Trigger TVX selection: %d", mTriggerTVXselection); + LOGF(info, "Apply time frame border cut: %d", mApplyTFBorderCut); + LOGF(info, "Apply ITS-TPC vertex: %d", mApplyITSTPCvertex); + LOGF(info, "Apply NoCollInTimeRangeNarrow: %d", mApplyCollInTimeRangeNarrow); + LOGF(info, "Apply Z-vertex time difference: %d", mApplyZvertexTimedifference); + LOGF(info, "Apply Pileup rejection: %d", mApplyPileupRejection); + LOGF(info, "Apply NoITSRO frame border cut: %d", mApplyNoITSROBorderCut); + LOGF(info, "Track occupancy in time range max: %d", mtrackOccupancyInTimeRangeMax); + LOGF(info, "Track occupancy in time range min: %d", mtrackOccupancyInTimeRangeMin); + LOGF(info, "Apply NoCollInTimeRangeStandard: %d", mApplyCollInTimeRangeStandard); + } else { + LOGF(info, "Apply Run2 AliEventCuts: %d", mApplyRun2AliEventCuts); + LOGF(info, "Apply Run2 INELgtZERO: %d", mApplyRun2INELgtZERO); + } } /// Set MB selection void setTriggerTVX(bool triggerTVXsel) { mTriggerTVXselection = triggerTVXsel; } - /// Scan the trigger alias of the event - void setInitialTriggerScan(bool checkTrigger) { mInitialTriggerScan = checkTrigger; } - /// Set the time frame border cut void setApplyTFBorderCut(bool applyTFBorderCut) { mApplyTFBorderCut = applyTFBorderCut; } /// Set the ITS-TPC matching cut void setApplyITSTPCvertex(bool applyITSTPCvertex) { mApplyITSTPCvertex = applyITSTPCvertex; } + /// Set the NoCollInTimeRangeNarrow cut + void setApplyCollInTimeRangeNarrow(bool applyCollInTimeRangeNarrow) { mApplyCollInTimeRangeNarrow = applyCollInTimeRangeNarrow; } + /// Set the Z-vertex time difference cut void setApplyZvertexTimedifference(bool applyZvertexTimedifference) { mApplyZvertexTimedifference = applyZvertexTimedifference; } @@ -144,63 +173,101 @@ class CollisonCuts mtrackOccupancyInTimeRangeMax = trackOccupancyInTimeRangeMax; mtrackOccupancyInTimeRangeMin = trackOccupancyInTimeRangeMin; } - /// Set the NoCollInTimeRangeStandard cut void setApplyCollInTimeRangeStandard(bool applyCollInTimeRangeStandard) { mApplyCollInTimeRangeStandard = applyCollInTimeRangeStandard; } + /// Set the Run2 AliEventCuts cut + void setApplyRun2AliEventCuts(bool applyRun2AliEventCuts) { mApplyRun2AliEventCuts = applyRun2AliEventCuts; } + + /// Set the Run2 INELgtZERO cut + void setApplyRun2INELgtZERO(bool applyRun2INELgtZERO) { mApplyRun2INELgtZERO = applyRun2INELgtZERO; } + /// Check whether the collisions fulfills the specified selections /// \tparam T type of the collision /// \param col Collision /// \return whether or not the collisions fulfills the specified selections template - bool isSelected(T const& col) + bool isSelected(T const& col, const bool QA = true) { - mHistogramRegistry->fill(HIST("Event/posZ_noCut"), col.posZ()); - if (mCheckIsRun3) { - mHistogramRegistry->fill(HIST("Event/trackOccupancyInTimeRange_noCut"), col.trackOccupancyInTimeRange()); + if (QA) { + mHistogramRegistry->fill(HIST("Event/posZ_noCut"), col.posZ()); + if (mCheckIsRun3) { + mHistogramRegistry->fill(HIST("Event/trackOccupancyInTimeRange_noCut"), col.trackOccupancyInTimeRange()); + } + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kAllEvent); } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kAllEvent); if (std::abs(col.posZ()) > mZvtxMax) { LOGF(debug, "Vertex out of range"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagZvertex); + if (mInitialColBitScan) { + for (const auto& bit : bitList) { + if (col.selection_bit(bit)) { + LOGF(info, "Trigger %d fired", bit); + } + } + mInitialColBitScan = false; + } + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagZvertex); + } if (mCheckIsRun3) { // Run3 case if (!col.selection_bit(aod::evsel::kIsTriggerTVX) && mTriggerTVXselection) { LOGF(debug, "Offline selection TVX failed (Run3)"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagTrigerTVX); + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagTrigerTVX); + } if (!col.selection_bit(aod::evsel::kNoTimeFrameBorder) && mApplyTFBorderCut) { LOGF(debug, "Time frame border cut failed"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagTimeFrameBorder); + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagTimeFrameBorder); + } if (!col.selection_bit(aod::evsel::kNoITSROFrameBorder) && mApplyNoITSROBorderCut) { LOGF(debug, "NoITSRO frame border cut failed"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagITSROFrameBorder); + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagITSROFrameBorder); + } if (!col.sel8() && mCheckOffline) { LOGF(debug, "Offline selection failed (Run3)"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagSel8); + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagSel8); + } if (!col.selection_bit(o2::aod::evsel::kIsVertexITSTPC) && mApplyITSTPCvertex) { LOGF(debug, "ITS-TPC matching cut failed"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagVertexITSTPC); + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagVertexITSTPC); + } if (!col.selection_bit(o2::aod::evsel::kNoSameBunchPileup) && mApplyPileupRejection) { LOGF(debug, "Pileup rejection failed"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagBunchPileup); + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagBunchPileup); + } + if (!col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow) && mApplyCollInTimeRangeNarrow) { + LOGF(debug, "NoCollInTimeRangeNarrow selection failed"); + return false; + } + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kNoCollInTimeRangeNarrow); + } if (!col.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV) && mApplyZvertexTimedifference) { LOGF(debug, "Z-vertex time difference cut failed"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagZvtxFT0vsPV); + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagZvtxFT0vsPV); + } if (mtrackOccupancyInTimeRangeMax > 0 && col.trackOccupancyInTimeRange() > mtrackOccupancyInTimeRangeMax) { LOGF(debug, "trackOccupancyInTimeRange selection failed"); return false; @@ -209,37 +276,38 @@ class CollisonCuts LOGF(debug, "trackOccupancyInTimeRange selection failed"); return false; } + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagOccupancy); + } if ((!col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) && mApplyCollInTimeRangeStandard) { LOGF(debug, "NoCollInTimeRangeStandard selection failed"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagOccupancy); + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kNoCollInTimeRangeStandard); + } } else { // Run2 case if (mCheckOffline && !col.sel7()) { LOGF(debug, "Offline selection failed (sel7)"); return false; } auto bc = col.template bc_as(); - if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) { + if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted)) && !mApplyRun2AliEventCuts) { LOGF(debug, "Offline selection failed (AliEventCuts)"); return false; } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagTrigerTVX); - } - if (mCheckTrigger && !col.alias_bit(mTrigger)) { - LOGF(debug, "Trigger selection failed"); - if (mInitialTriggerScan) { // Print out the trigger bits - LOGF(debug, "Trigger scan initialized"); - for (int i = 0; i < kNaliases; i++) { - if (col.alias_bit(i)) { - LOGF(debug, "Trigger %d fired", i); - } - } - mInitialTriggerScan = false; + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagSel8); + if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kINELgtZERO)) && !mApplyRun2INELgtZERO) { + LOGF(debug, "INELgtZERO selection failed"); + return false; } - return false; + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kAllpassed); + } + } + if (QA) { + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kAllpassed); } - mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kAllpassed); return true; } @@ -256,7 +324,6 @@ class CollisonCuts } else { mHistogramRegistry->fill(HIST("Event/posZ_ITSTPC"), col.posZ()); } - mHistogramRegistry->fill(HIST("Event/CentFV0A"), col.centFV0A()); mHistogramRegistry->fill(HIST("Event/CentFT0M"), col.centFT0M()); mHistogramRegistry->fill(HIST("Event/CentFT0C"), col.centFT0C()); mHistogramRegistry->fill(HIST("Event/CentFT0A"), col.centFT0A()); @@ -278,22 +345,25 @@ class CollisonCuts private: using BCsWithRun2Info = soa::Join; o2::framework::HistogramRegistry* mHistogramRegistry = nullptr; ///< For QA output - bool mCutsSet = false; ///< Protection against running without cuts - bool mCheckTrigger = false; ///< Check for trigger - bool mTriggerTVXselection = false; ///< Check for trigger TVX selection - bool mCheckOffline = false; ///< Check for offline criteria (might change) - bool mCheckIsRun3 = false; ///< Check if running on Pilot Beam - bool mInitialTriggerScan = false; ///< Check trigger when the event is first selected - bool mApplyTFBorderCut = false; ///< Apply time frame border cut - bool mApplyITSTPCvertex = false; ///< Apply at least one ITS-TPC track for vertexing - bool mApplyZvertexTimedifference = false; ///< removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference. - bool mApplyPileupRejection = false; ///< Pileup rejection - bool mApplyNoITSROBorderCut = false; ///< Apply NoITSRO frame border cut - bool mApplyCollInTimeRangeStandard = false; ///< Apply NoCollInTimeRangeStandard selection - int mTrigger = kINT7; ///< Trigger to check for - float mZvtxMax = 999.f; ///< Maximal deviation from nominal z-vertex (cm) - int mtrackOccupancyInTimeRangeMax = -1; ///< Maximum trackOccupancyInTimeRange cut (-1 no cut) - int mtrackOccupancyInTimeRangeMin = -1; ///< Minimum trackOccupancyInTimeRange cut (-1 no cut) + std::vector bitList; + bool mCutsSet = false; ///< Protection against running without cuts + bool mInitialColBitScan = true; ///< Scan for collision bit + bool mCheckTrigger = false; ///< Check for trigger + bool mTriggerTVXselection = false; ///< Check for trigger TVX selection + bool mCheckOffline = false; ///< Check for offline criteria (might change) + bool mCheckIsRun3 = false; ///< Check if running on Pilot Beam + bool mApplyTFBorderCut = false; ///< Apply time frame border cut + bool mApplyITSTPCvertex = false; ///< Apply at least one ITS-TPC track for vertexing + bool mApplyCollInTimeRangeNarrow = false; ///< Apply NoCollInTimeRangeNarrow selection + bool mApplyZvertexTimedifference = false; ///< removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference. + bool mApplyPileupRejection = false; ///< Pileup rejection + bool mApplyNoITSROBorderCut = false; ///< Apply NoITSRO frame border cut + bool mApplyCollInTimeRangeStandard = false; ///< Apply NoCollInTimeRangeStandard selection + bool mApplyRun2AliEventCuts = true; ///< Apply Run2 AliEventCuts + bool mApplyRun2INELgtZERO = false; ///< Apply Run2 INELgtZERO selection + float mZvtxMax = 999.f; ///< Maximal deviation from nominal z-vertex (cm) + int mtrackOccupancyInTimeRangeMax = -1; ///< Maximum trackOccupancyInTimeRange cut (-1 no cut) + int mtrackOccupancyInTimeRangeMin = -1; ///< Minimum trackOccupancyInTimeRange cut (-1 no cut) }; } // namespace o2::analysis diff --git a/PWGLF/Utils/decay3bodyBuilderHelper.h b/PWGLF/Utils/decay3bodyBuilderHelper.h new file mode 100644 index 00000000000..49131c16040 --- /dev/null +++ b/PWGLF/Utils/decay3bodyBuilderHelper.h @@ -0,0 +1,852 @@ +// 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. + +#ifndef PWGLF_UTILS_DECAY3BODYBUILDERHELPER_H_ +#define PWGLF_UTILS_DECAY3BODYBUILDERHELPER_H_ + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Tools/KFparticle/KFUtilities.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "DCAFitter/DCAFitterN.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsVertexing/SVertexHypothesis.h" +#include "Framework/AnalysisDataModel.h" +#include "ReconstructionDataFormats/Track.h" + +#include +#include +#include + +#ifndef HomogeneousField +#define HomogeneousField +#endif + +/// includes KFParticle +#include "KFPTrack.h" +#include "KFPVertex.h" +#include "KFParticle.h" +#include "KFParticleBase.h" +#include "KFVertex.h" + +namespace o2 +{ +namespace pwglf +{ + +//_______________________________________________________________________ +// Deca3body information storage +struct decay3bodyCandidate { + // indexing + int collisionID = -1; + int decay3bodyID = -1; + int protonID = -1; + int pionID = -1; + int deuteronID = -1; + + // daughter properties + std::array momProton = {0.0f, 0.0f, 0.0f}; + std::array momPion = {0.0f, 0.0f, 0.0f}; + std::array momDeuteron = {0.0f, 0.0f, 0.0f}; + std::array posProton = {0.0f, 0.0f, 0.0f}; + std::array posPion = {0.0f, 0.0f, 0.0f}; + std::array posDeuteron = {0.0f, 0.0f, 0.0f}; + std::array trackDCAxyToPV = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron + std::array trackDCAzToPV = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron + std::array tpcNsigma = {0.0f, 0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron, 3 - bach with pion hyp + double tofNsigmaDeuteron = 0.0f; + std::array averageITSClSize = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron + std::array tpcNCl = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron + int pidForTrackingDeuteron = 0; + + // vertex properties + float mass; + float massV0; + int sign; + float momentum[3]; + float position[3]; + float chi2 = 0.0f; + float trackedClSize = 0.0f; + float cosPA = 0.0f; // cosine of pointing angle + float ctau = 0.0f; // ctau of the candidate + float daughterDCAtoSVaverage = 0.0f; // average of quadratic sum of daughter DCAs to SV + std::array daughterDCAtoSV = {0.0f, 0.0f, 0.0f}; // 0 - pos, 1 - neg, 2 - bach + + // covariance matrix + float covProton[21] = {0.0f}; + float covPion[21] = {0.0f}; + float covDeuteron[21] = {0.0f}; + float covariance[21] = {0.0f}; +}; + +//_______________________________________________________________________ +// builder helper class +class decay3bodyBuilderHelper +{ + public: + decay3bodyBuilderHelper() + { + fitter3body.setPropagateToPCA(true); + fitter3body.setMaxR(200.); //->maxRIni3body + fitter3body.setMinParamChange(1e-3); + fitter3body.setMinRelChi2Change(0.9); + fitter3body.setMaxDZIni(1e9); + fitter3body.setMaxDXYIni(4.0f); + fitter3body.setMaxChi2(1e9); + fitter3body.setUseAbsDCA(true); + + fitterV0.setPropagateToPCA(true); + fitterV0.setMaxR(200.); + fitterV0.setMinParamChange(1e-3); + fitterV0.setMinRelChi2Change(0.9); + fitterV0.setMaxDZIni(1e9); + fitterV0.setMaxChi2(1e9); + fitterV0.setUseAbsDCA(true); + + // mag field has to be set later + fitter3body.setBz(-999.9f); // will NOT make sense if not changed + }; + + o2::vertexing::DCAFitterN<2> fitterV0; // 2-prong o2 dca fitter + o2::vertexing::DCAFitterN<3> fitter3body; // 3-prong o2 dca fitter + + decay3bodyCandidate decay3body; // storage for Decay3body candidate properties + + o2::dataformats::VertexBase mMeanVertex{{0., 0., 0.}, {0.1 * 0.1, 0., 0.1 * 0.1, 0., 0., 6. * 6.}}; + o2::vertexing::SVertexHypothesis mV0Hyps; // 0 - Lambda, 1 - AntiLambda + + // decay3body candidate criteria + struct { + // daughter tracks + float maxEtaDaughters; + int minTPCNClProton; + int minTPCNClPion; + int minTPCNClDeuteron; + float minDCAProtonToPV; + float minDCAPionToPV; + float minDCADeuteronToPV; + float minPtProton; + float minPtPion; + float minPtDeuteron; + float maxPtProton; + float maxPtPion; + float maxPtDeuteron; + float maxTPCnSigma; + double minTOFnSigmaDeuteron; + double maxTOFnSigmaDeuteron; + float minPDeuteronUseTOF; + float maxDCADauToSVaverage; + // candidate + float maxRapidity; + float minPt; + float maxPt; + float minMass; + float maxMass; + float minCtau; + float maxCtau; + float minCosPA; + float maxChi2; + } decay3bodyselections; + + // SVertexer selection criteria + struct { + float minPt2V0; + float maxTgl2V0; + float maxDCAXY2ToMeanVertex3bodyV0; + float minCosPAXYMeanVertex3bodyV0; + float minCosPA3bodyV0; + float maxRDiffV03body; + float minPt3Body; + float maxTgl3Body; + float maxDCAXY3Body; + float maxDCAZ3Body; + } svertexerselections; + + //_______________________________________________________________________ + // build Decay3body from three tracks, including V0 building. + template + bool buildDecay3BodyCandidate(TCollision const& collision, + TTrack const& trackProton, + TTrack const& trackPion, + TTrack const& trackDeuteron, + int decay3bodyIndex, + double tofNsigmaDeuteron, + float trackedClSize, + bool useKFParticle = false, + bool kfSetTopologicalConstraint = false, + bool useSelections = true, + bool useChi2Selection = true, + bool useTPCforPion = false, + bool acceptTPCOnly = false, + bool askOnlyITSMatch = true, + bool calculateCovariance = true, + bool isEventMixing = false) + { + int collisionIndex = collision.globalIndex(); + float pvX = collision.posX(); + float pvY = collision.posY(); + float pvZ = collision.posZ(); + + auto trackParCovProton = getTrackParCov(trackProton); + auto trackParCovPion = getTrackParCov(trackPion); + auto trackParCovDeuteron = getTrackParCov(trackDeuteron); + + decay3body.collisionID = collisionIndex; + decay3body.decay3bodyID = decay3bodyIndex; + decay3body.protonID = trackProton.globalIndex(); + decay3body.pionID = trackPion.globalIndex(); + decay3body.deuteronID = trackDeuteron.globalIndex(); + + //_______________________________________________________________________ + // track selections + if (useSelections) { + // proton track quality + if (trackProton.tpcNClsFound() < decay3bodyselections.minTPCNClProton) { + decay3body = {}; + return false; + } + // pion track quality + if (useTPCforPion) { + if (trackPion.tpcNClsFound() < decay3bodyselections.minTPCNClPion) { + decay3body = {}; + return false; + } + } + // deuteron track quality + if (trackDeuteron.tpcNClsFound() < decay3bodyselections.minTPCNClDeuteron) { + decay3body = {}; + return false; + } + + // track eta + if (std::fabs(trackProton.eta()) > decay3bodyselections.maxEtaDaughters) { + decay3body = {}; + return false; + } + if (std::fabs(trackPion.eta()) > decay3bodyselections.maxEtaDaughters) { + decay3body = {}; + return false; + } + if (std::fabs(trackDeuteron.eta()) > decay3bodyselections.maxEtaDaughters) { + decay3body = {}; + return false; + } + + // TPC only + if (!acceptTPCOnly) { + if (askOnlyITSMatch) { + if (!trackProton.hasITS() || !trackPion.hasITS() || !trackDeuteron.hasITS()) { + decay3body = {}; + return false; + } + } else { + bool isProtonTPCOnly = !trackProton.hasITS() && !trackProton.hasTOF() && !trackProton.hasTRD(); + bool isPionTPCOnly = !trackPion.hasITS() && !trackPion.hasTOF() && !trackPion.hasTRD(); + bool isDeuteronTPCOnly = !trackDeuteron.hasITS() && !trackDeuteron.hasTOF() && !trackDeuteron.hasTRD(); + if (isProtonTPCOnly || isPionTPCOnly || isDeuteronTPCOnly) { + decay3body = {}; + return false; + } + } + } + + // daughter TPC PID + if (std::fabs(trackProton.tpcNSigmaPr()) > decay3bodyselections.maxTPCnSigma) { + decay3body = {}; + return false; + } + if (useTPCforPion && std::fabs(trackPion.tpcNSigmaPi()) > decay3bodyselections.maxTPCnSigma) { + decay3body = {}; + return false; + } + if (std::fabs(trackDeuteron.tpcNSigmaDe()) > decay3bodyselections.maxTPCnSigma) { + decay3body = {}; + return false; + } + + // deuteron TOF PID + if ((tofNsigmaDeuteron < decay3bodyselections.minTOFnSigmaDeuteron || tofNsigmaDeuteron > decay3bodyselections.maxTOFnSigmaDeuteron) && trackDeuteron.p() > decay3bodyselections.minPDeuteronUseTOF) { + decay3body = {}; + return false; + } + } // end of selections + + //_______________________________________________________________________ + // daughter track DCA to PV associated with decay3body + o2::dataformats::VertexBase mPV; + o2::dataformats::DCA mDcaInfoCov; + auto trackParCovProtonCopy = trackParCovProton; + auto trackParCovPionCopy = trackParCovPion; + auto trackParCovDeuteronCopy = trackParCovDeuteron; + mPV.setPos({pvX, pvY, pvZ}); + mPV.setCov(collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + + // proton track + o2::base::Propagator::Instance()->propagateToDCABxByBz(mPV, trackParCovProtonCopy, 2.f, fitter3body.getMatCorrType(), &mDcaInfoCov); + decay3body.trackDCAxyToPV[0] = mDcaInfoCov.getY(); + decay3body.trackDCAzToPV[0] = mDcaInfoCov.getZ(); + auto trackProtonDCAToPV = std::sqrt(decay3body.trackDCAxyToPV[0] * decay3body.trackDCAxyToPV[0] + decay3body.trackDCAzToPV[0] * decay3body.trackDCAzToPV[0]); + if (useSelections) { + if (trackProtonDCAToPV < decay3bodyselections.minDCAProtonToPV) { + decay3body = {}; + return false; + } + } + // pion track + o2::base::Propagator::Instance()->propagateToDCABxByBz(mPV, trackParCovPionCopy, 2.f, fitter3body.getMatCorrType(), &mDcaInfoCov); + decay3body.trackDCAxyToPV[1] = mDcaInfoCov.getY(); + decay3body.trackDCAzToPV[1] = mDcaInfoCov.getZ(); + auto trackPionDCAToPV = std::sqrt(decay3body.trackDCAxyToPV[1] * decay3body.trackDCAxyToPV[1] + decay3body.trackDCAzToPV[1] * decay3body.trackDCAzToPV[1]); + if (useSelections) { + if (trackPionDCAToPV < decay3bodyselections.minDCAPionToPV) { + decay3body = {}; + return false; + } + } + // deuteron track + o2::base::Propagator::Instance()->propagateToDCABxByBz(mPV, trackParCovDeuteronCopy, 2.f, fitter3body.getMatCorrType(), &mDcaInfoCov); + decay3body.trackDCAxyToPV[2] = mDcaInfoCov.getY(); + decay3body.trackDCAzToPV[2] = mDcaInfoCov.getZ(); + auto trackDeuteronDCAToPV = std::sqrt(decay3body.trackDCAxyToPV[2] * decay3body.trackDCAxyToPV[2] + decay3body.trackDCAzToPV[2] * decay3body.trackDCAzToPV[2]); + if (useSelections) { + if (trackDeuteronDCAToPV < decay3bodyselections.minDCADeuteronToPV) { + decay3body = {}; + return false; + } + } + + //_______________________________________________________________________ + // fit 3body vertex + if (!useKFParticle) { + fitVertexWithDCAFitter(trackProton, trackPion, trackDeuteron, calculateCovariance); + } else { + fitVertexWithKF(collision, trackProton, trackPion, trackDeuteron, kfSetTopologicalConstraint, calculateCovariance); + } + + //_______________________________________________________________________ + // get vertex information + // daughter pT + auto trackProtonPt = std::sqrt(decay3body.momProton[0] * decay3body.momProton[0] + decay3body.momProton[1] * decay3body.momProton[1]); + auto trackPionPt = std::sqrt(decay3body.momPion[0] * decay3body.momPion[0] + decay3body.momPion[1] * decay3body.momPion[1]); + auto trackDeuteronPt = std::sqrt(decay3body.momDeuteron[0] * decay3body.momDeuteron[0] + decay3body.momDeuteron[1] * decay3body.momDeuteron[1]); + + // daughter DCA to SV + // proton daughter + decay3body.daughterDCAtoSV[0] = std::hypot( + decay3body.posProton[0] - decay3body.position[0], + decay3body.posProton[1] - decay3body.position[1], + decay3body.posProton[2] - decay3body.position[2]); + // pion daughter + decay3body.daughterDCAtoSV[1] = std::hypot( + decay3body.posPion[0] - decay3body.position[0], + decay3body.posPion[1] - decay3body.position[1], + decay3body.posPion[2] - decay3body.position[2]); + // deuteron daughter + decay3body.daughterDCAtoSV[2] = std::hypot( + decay3body.posDeuteron[0] - decay3body.position[0], + decay3body.posDeuteron[1] - decay3body.position[1], + decay3body.posDeuteron[2] - decay3body.position[2]); + + // DCA daughters to SV average of quadratic sum + decay3body.daughterDCAtoSVaverage = (decay3body.daughterDCAtoSV[0] * decay3body.daughterDCAtoSV[0] + + decay3body.daughterDCAtoSV[1] * decay3body.daughterDCAtoSV[1] + + decay3body.daughterDCAtoSV[2] * decay3body.daughterDCAtoSV[2]) / + 3; + + //_____________________________________________________ + // selections after vertex fit + if (useSelections) { + // daughter pT + // proton + if (trackProtonPt < decay3bodyselections.minPtProton || trackProtonPt > decay3bodyselections.maxPtProton) { + decay3body = {}; + return false; + } + // pion + if (trackPionPt < decay3bodyselections.minPtPion || trackPionPt > decay3bodyselections.maxPtPion) { + decay3body = {}; + return false; + } + // deuteron + if (trackDeuteronPt < decay3bodyselections.minPtDeuteron || trackDeuteronPt > decay3bodyselections.maxPtDeuteron) { + decay3body = {}; + return false; + } + + // daughter DCAs at SV + if (decay3body.daughterDCAtoSVaverage > decay3bodyselections.maxDCADauToSVaverage) { + decay3body = {}; + return false; + } + + // rapidity + float rapidity = RecoDecay::y(std::array{decay3body.momentum[0], decay3body.momentum[1], decay3body.momentum[2]}, o2::constants::physics::MassHyperTriton); + if (std::fabs(rapidity) > decay3bodyselections.maxRapidity) { + decay3body = {}; + return false; + } + + // pT + float pT = RecoDecay::pt(std::array{decay3body.momentum[0], decay3body.momentum[1], decay3body.momentum[2]}); + if (pT < decay3bodyselections.minPt || pT > decay3bodyselections.maxPt) { + decay3body = {}; + return false; + } + + // mass window + if (decay3body.mass < decay3bodyselections.minMass || decay3body.mass > decay3bodyselections.maxMass) { + decay3body = {}; + return false; + } + + // vertex chi2 + if (useChi2Selection && decay3body.chi2 > decay3bodyselections.maxChi2) { + decay3body = {}; + return false; + } + } + + // pointing angle + float cpa = RecoDecay::cpa(std::array{pvX, pvY, pvZ}, std::array{decay3body.position[0], decay3body.position[1], decay3body.position[2]}, std::array{decay3body.momentum[0], decay3body.momentum[1], decay3body.momentum[2]}); + if (useSelections) { + if (cpa < decay3bodyselections.minCosPA) { + decay3body = {}; + return false; + } + } + decay3body.cosPA = cpa; + + // ctau + float P = RecoDecay::sqrtSumOfSquares(decay3body.momentum[0], decay3body.momentum[1], decay3body.momentum[2]); + float ctau = std::sqrt(std::pow(decay3body.position[0] - pvX, 2) + std::pow(decay3body.position[1] - pvY, 2) + std::pow(decay3body.position[2] - pvZ, 2)) / (P + 1E-10) * o2::constants::physics::MassHyperTriton; + if (useSelections) { + if (ctau < decay3bodyselections.minCtau || ctau > decay3bodyselections.maxCtau) { + decay3body = {}; + return false; + } + } + decay3body.ctau = ctau; + + //_______________________________________________________________________ + // SVertexer selections in case of event mixing + if (isEventMixing) { + applySVertexerCuts(collision, trackProton, trackPion, trackDeuteron, /*applyV0Cut = */ true); + } + + //_______________________________________________________________________ + // fill remaining candidate information + // daughter PID + decay3body.tpcNsigma[0] = trackProton.tpcNSigmaPr(); + decay3body.tpcNsigma[1] = trackPion.tpcNSigmaPi(); + decay3body.tpcNsigma[2] = trackDeuteron.tpcNSigmaDe(); + decay3body.tpcNsigma[3] = trackDeuteron.tpcNSigmaPi(); + // recalculated bachelor TOF PID + decay3body.tofNsigmaDeuteron = tofNsigmaDeuteron; + + // average ITS cluster size of daughter tracks + double averageClusterSizeProton(0), averageClusterSizePion(0), averageClusterSizeDeuteron(0); + int nClsProton(0), nClsPion(0), nClsDeuteron(0); + for (int i = 0; i < 7; i++) { + int clusterSizePr = trackProton.itsClsSizeInLayer(i); + int clusterSizePi = trackPion.itsClsSizeInLayer(i); + int clusterSizeDe = trackDeuteron.itsClsSizeInLayer(i); + averageClusterSizeProton += static_cast(clusterSizePr); + averageClusterSizePion += static_cast(clusterSizePi); + averageClusterSizeDeuteron += static_cast(clusterSizeDe); + if (clusterSizePr > 0) + nClsProton++; + if (clusterSizePi > 0) + nClsPion++; + if (clusterSizeDe > 0) + nClsDeuteron++; + } + averageClusterSizeProton = averageClusterSizeProton / static_cast(nClsProton); + averageClusterSizePion = averageClusterSizePion / static_cast(nClsPion); + averageClusterSizeDeuteron = averageClusterSizeDeuteron / static_cast(nClsDeuteron); + decay3body.averageITSClSize[0] = averageClusterSizeProton; + decay3body.averageITSClSize[1] = averageClusterSizePion; + decay3body.averageITSClSize[2] = averageClusterSizeDeuteron; + + // number of TPC clusters + decay3body.tpcNCl[0] = trackProton.tpcNClsFound(); + decay3body.tpcNCl[1] = trackPion.tpcNClsFound(); + decay3body.tpcNCl[2] = trackDeuteron.tpcNClsFound(); + + // PID for tracking of deuteron track + decay3body.pidForTrackingDeuteron = trackDeuteron.pidForTracking(); + + // tracked cluster size + decay3body.trackedClSize = trackedClSize; + + return true; + } + + //___________________________________________________________________________________ + // functionality to fit 3body vertex with KFParticle and fill vertex information + template + void fitVertexWithKF(TCollision const& collision, + TTrack const& trackProton, + TTrack const& trackPion, + TTrack const& trackDeuteron, + bool kfSetTopologicalConstraint = true, + bool calculateCovariance = true) + { + // get TrackParCov daughters + auto trackParCovProton = getTrackParCov(trackProton); + auto trackParCovPion = getTrackParCov(trackPion); + auto trackParCovDeuteron = getTrackParCov(trackDeuteron); + + // initialise KF primary vertex + KFVertex kfpVertex = createKFPVertexFromCollision(collision); + KFParticle kfpv(kfpVertex); + + // create KFParticle objects + KFParticle kfpProton, kfpPion, kfpDeuteron; + kfpProton = createKFParticleFromTrackParCov(trackParCovProton, trackProton.sign(), constants::physics::MassProton); + kfpPion = createKFParticleFromTrackParCov(trackParCovPion, trackPion.sign(), constants::physics::MassPionCharged); + kfpDeuteron = createKFParticleFromTrackParCov(trackParCovDeuteron, trackDeuteron.sign(), constants::physics::MassDeuteron); + + // construct V0 vertex + KFParticle KFV0; + int nDaughtersV0 = 2; + const KFParticle* DaughtersV0[2] = {&kfpProton, &kfpPion}; + KFV0.SetConstructMethod(2); + try { + KFV0.Construct(DaughtersV0, nDaughtersV0); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to create V0 vertex." << e.what(); + return; + } + + // construct vertex + KFParticle KFH3L; + int nDaughters3body = 3; + const KFParticle* Daughters3body[3] = {&kfpProton, &kfpPion, &kfpDeuteron}; + KFH3L.SetConstructMethod(2); + try { + KFH3L.Construct(Daughters3body, nDaughters3body); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to create Hyper triton 3-body vertex." << e.what(); + return; + } + + // topological constraint + if (kfSetTopologicalConstraint) { + KFH3L.SetProductionVertex(kfpv); + KFH3L.TransportToDecayVertex(); + } + + // get vertex position and momentum + decay3body.position[0] = KFH3L.GetX(); + decay3body.position[1] = KFH3L.GetY(); + decay3body.position[2] = KFH3L.GetZ(); + decay3body.momentum[0] = KFH3L.GetPx(); + decay3body.momentum[1] = KFH3L.GetPy(); + decay3body.momentum[2] = KFH3L.GetPz(); + + // get sign + decay3body.sign = KFH3L.GetQ() / std::abs(KFH3L.GetQ()); + + // transport all daughter tracks to hypertriton vertex + kfpProton.TransportToPoint(decay3body.position); + kfpPion.TransportToPoint(decay3body.position); + kfpDeuteron.TransportToPoint(decay3body.position); + + // daughter positions + decay3body.posProton[0] = kfpProton.GetX(); + decay3body.posProton[1] = kfpProton.GetY(); + decay3body.posProton[2] = kfpProton.GetZ(); + decay3body.posPion[0] = kfpPion.GetX(); + decay3body.posPion[1] = kfpPion.GetY(); + decay3body.posPion[2] = kfpPion.GetZ(); + decay3body.posDeuteron[0] = kfpDeuteron.GetX(); + decay3body.posDeuteron[1] = kfpDeuteron.GetY(); + decay3body.posDeuteron[2] = kfpDeuteron.GetZ(); + + // daughter momenta + decay3body.momProton[0] = kfpProton.GetPx(); + decay3body.momProton[1] = kfpProton.GetPy(); + decay3body.momProton[2] = kfpProton.GetPz(); + decay3body.momPion[0] = kfpPion.GetPx(); + decay3body.momPion[1] = kfpPion.GetPy(); + decay3body.momPion[2] = kfpPion.GetPz(); + decay3body.momDeuteron[0] = kfpDeuteron.GetPx(); + decay3body.momDeuteron[1] = kfpDeuteron.GetPy(); + decay3body.momDeuteron[2] = kfpDeuteron.GetPz(); + + // candidate mass + float mass, massErr; + KFH3L.GetMass(mass, massErr); + decay3body.mass = mass; + + // V0 mass + float massV0, massV0Err; + KFV0.GetMass(massV0, massV0Err); + decay3body.massV0 = massV0; + + // vertex chi2 + decay3body.chi2 = KFH3L.GetChi2() / KFH3L.GetNDF(); + + // caluclate covariance matrices + if (calculateCovariance) { + // candidate covariance matrix + std::array covKF; + for (int i = 0; i < 21; i++) { // get covariance matrix elements (lower triangle) + covKF[i] = KFH3L.GetCovariance(i); + decay3body.covariance[i] = covKF[i]; + } + // daughter track covariance matrices + for (int i = 0; i < 21; i++) { // get covariance matrix elements (lower triangle) + decay3body.covProton[i] = kfpProton.GetCovariance(i); + decay3body.covPion[i] = kfpPion.GetCovariance(i); + decay3body.covDeuteron[i] = kfpDeuteron.GetCovariance(i); + } + } + + return; + } + + //_______________________________________________________________________ + // functionality to fit 3body vertex with DCAFitter + template + void fitVertexWithDCAFitter(TTrack const& trackProton, + TTrack const& trackPion, + TTrack const& trackDeuteron, + bool calculateCovariance = true) + { + // get TrackParCov daughters + auto trackParCovProton = getTrackParCov(trackProton); + auto trackParCovPion = getTrackParCov(trackPion); + auto trackParCovDeuteron = getTrackParCov(trackDeuteron); + + // fit the vertex + int n3bodyVtx = fitter3body.process(trackParCovProton, trackParCovPion, trackParCovDeuteron); + if (n3bodyVtx == 0) { // discard this pair + return; + } + + // get vertex position + const auto& vtxXYZ = fitter3body.getPCACandidate(); + for (int i = 0; i < 3; i++) { + decay3body.position[i] = vtxXYZ[i]; + } + + // get daughter momenta + const auto& propagatedTrackProton = fitter3body.getTrack(0); + const auto& propagatedTrackPion = fitter3body.getTrack(1); + const auto& propagatedTrackDeuteron = fitter3body.getTrack(2); + propagatedTrackProton.getPxPyPzGlo(decay3body.momProton); + propagatedTrackPion.getPxPyPzGlo(decay3body.momPion); + propagatedTrackDeuteron.getPxPyPzGlo(decay3body.momDeuteron); + propagatedTrackProton.getXYZGlo(decay3body.posProton); + propagatedTrackPion.getXYZGlo(decay3body.posPion); + propagatedTrackDeuteron.getXYZGlo(decay3body.posDeuteron); + + // get daughter positions at vertex + + // calculate candidate momentum + decay3body.momentum[0] = decay3body.momProton[0] + decay3body.momPion[0] + decay3body.momDeuteron[0]; + decay3body.momentum[1] = decay3body.momProton[1] + decay3body.momPion[1] + decay3body.momDeuteron[1]; + decay3body.momentum[2] = decay3body.momProton[2] + decay3body.momPion[2] + decay3body.momDeuteron[2]; + + // candidate and V0 mass + decay3body.mass = RecoDecay::m( + std::array{std::array{decay3body.momProton[0], decay3body.momProton[1], decay3body.momProton[2]}, + std::array{decay3body.momPion[0], decay3body.momPion[1], decay3body.momPion[2]}, + std::array{decay3body.momDeuteron[0], decay3body.momDeuteron[1], decay3body.momDeuteron[2]}}, + std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, o2::constants::physics::MassDeuteron}); + decay3body.massV0 = RecoDecay::m( + std::array{std::array{decay3body.momProton[0], decay3body.momProton[1], decay3body.momProton[2]}, + std::array{decay3body.momPion[0], decay3body.momPion[1], decay3body.momPion[2]}}, + std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); + + // vertex chi2 at PCA + decay3body.chi2 = fitter3body.getChi2AtPCACandidate(); + + // candidate sign + decay3body.sign = trackDeuteron.sign(); + + // caluclate covariance matrices + if (calculateCovariance) { + // candidate position covariance matrix + auto covVtxV = fitter3body.calcPCACovMatrix(0); + decay3body.covariance[0] = covVtxV(0, 0); + decay3body.covariance[1] = covVtxV(1, 0); + decay3body.covariance[2] = covVtxV(1, 1); + decay3body.covariance[3] = covVtxV(2, 0); + decay3body.covariance[4] = covVtxV(2, 1); + decay3body.covariance[5] = covVtxV(2, 2); + // daughter covariance matrices + std::array covTproton = {0.}; + std::array covTpion = {0.}; + std::array covTdeuteron = {0.}; + propagatedTrackProton.getCovXYZPxPyPzGlo(covTproton); + propagatedTrackPion.getCovXYZPxPyPzGlo(covTpion); + propagatedTrackDeuteron.getCovXYZPxPyPzGlo(covTdeuteron); + for (int i = 0; i < 21; i++) { + decay3body.covProton[i] = covTproton[i]; + decay3body.covPion[i] = covTpion[i]; + decay3body.covDeuteron[i] = covTdeuteron[i]; + } + // candidate momentum covairance matrix + constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int i = 0; i < 6; i++) { + decay3body.covariance[MomInd[i]] = covTproton[MomInd[i]] + covTpion[MomInd[i]] + covTdeuteron[MomInd[i]]; + } + /// WARNING: position-momentum covariances are not calculated in the DCAFitter - remain zero + } + + return; + } + + //_______________________________________________________________________ + // functionality to apply SVertexer cuts in case of event mixing + template + void applySVertexerCuts(TCollision const& collision, + TTrack const& trackProton, + TTrack const& trackPion, + TTrack const& trackDeuteron, + bool applyV0Cut = true) + { + // get TrackParCov daughters + auto trackParCovProton = getTrackParCov(trackProton); + auto trackParCovPion = getTrackParCov(trackPion); + auto trackParCovDeuteron = getTrackParCov(trackDeuteron); + + const float pidCutsLambda[o2::vertexing::SVertexHypothesis::NPIDParams] = {0., 20, 0., 5.0, 0.0, 1.09004e-03, 2.62291e-04, 8.93179e-03, 2.83121}; // Lambda + mV0Hyps.set(o2::track::PID::Lambda, o2::track::PID::Proton, o2::track::PID::Pion, pidCutsLambda, fitter3body.getBz()); + + int nV0 = fitterV0.process(trackParCovProton, trackParCovPion); + if (nV0 == 0) { + return; + } + + std::array v0pos = {0.}; + const auto& v0vtxXYZ = fitterV0.getPCACandidate(); + for (int i = 0; i < 3; i++) { + v0pos[i] = v0vtxXYZ[i]; + } + const int cand = 0; + if (!fitterV0.isPropagateTracksToVertexDone(cand) && !fitterV0.propagateTracksToVertex(cand)) { + return; + } + + const auto& trProtonProp = fitterV0.getTrack(0, cand); + const auto& trPionProp = fitterV0.getTrack(1, cand); + std::array pProtonV0{}, pPionV0{}; + trProtonProp.getPxPyPzGlo(pProtonV0); + trPionProp.getPxPyPzGlo(pPionV0); + std::array pV0 = {pProtonV0[0] + pPionV0[0], pProtonV0[1] + pPionV0[1], pProtonV0[2] + pPionV0[2]}; + // Cut for Virtual V0 + float dxv0 = v0pos[0] - mMeanVertex.getX(), dyv0 = v0pos[1] - mMeanVertex.getY(), r2v0 = dxv0 * dxv0 + dyv0 * dyv0; + float rv0 = std::sqrt(r2v0); + float pt2V0 = pV0[0] * pV0[0] + pV0[1] * pV0[1], prodXYv0 = dxv0 * pV0[0] + dyv0 * pV0[1], tDCAXY = prodXYv0 / pt2V0; + if (applyV0Cut && pt2V0 <= svertexerselections.minPt2V0) { + return; + } + if (applyV0Cut && pV0[2] * pV0[2] / pt2V0 > svertexerselections.maxTgl2V0) { // tgLambda cut + return; + } + + float p2V0 = pt2V0 + pV0[2] * pV0[2], ptV0 = std::sqrt(pt2V0); + // apply mass selections + float p2Proton = pProtonV0[0] * pProtonV0[0] + pProtonV0[1] * pProtonV0[1] + pProtonV0[2] * pProtonV0[2], p2Pion = pPionV0[0] * pPionV0[0] + pPionV0[1] * pPionV0[1] + pPionV0[2] * pPionV0[2]; + bool good3bodyV0Hyp = false; + float massForLambdaHyp = mV0Hyps.calcMass(p2Proton, p2Pion, p2V0); + if (massForLambdaHyp - mV0Hyps.getMassV0Hyp() < mV0Hyps.getMargin(ptV0)) { + good3bodyV0Hyp = true; + } + if (applyV0Cut && !good3bodyV0Hyp) { + return; + } + + float dcaX = dxv0 - pV0[0] * tDCAXY, dcaY = dyv0 - pV0[1] * tDCAXY, dca2 = dcaX * dcaX + dcaY * dcaY; + float cosPAXY = prodXYv0 / rv0 * ptV0; + if (applyV0Cut && dca2 > svertexerselections.maxDCAXY2ToMeanVertex3bodyV0) { + return; + } + // FIXME: V0 cosPA cut to be investigated + if (applyV0Cut && cosPAXY < svertexerselections.minCosPAXYMeanVertex3bodyV0) { + return; + } + // Check: CosPA Cut of Virtual V0 may not be used since the V0 may be based on another PV + float dx = v0pos[0] - collision.posX(); + float dy = v0pos[1] - collision.posY(); + float dz = v0pos[2] - collision.posZ(); + float prodXYZv0 = dx * pV0[0] + dy * pV0[1] + dz * pV0[2]; + float v0CosPA = prodXYZv0 / std::sqrt((dx * dx + dy * dy + dz * dz) * p2V0); + if (applyV0Cut && v0CosPA < svertexerselections.minCosPA3bodyV0) { + return; + } + + // 3body vertex + int n3bodyVtx = fitter3body.process(trackParCovProton, trackParCovPion, trackParCovDeuteron); + if (n3bodyVtx == 0) { // discard this pair + return; + } + const auto& vertexXYZ = fitter3body.getPCACandidatePos(); + std::array pos = {0.}; + for (int i = 0; i < 3; i++) { + pos[i] = vertexXYZ[i]; + } + + std::array pProton = {0.}, pPion = {0.}, pDeuteron{0.}; + const auto& propagatedTrackProton = fitter3body.getTrack(0); + const auto& propagatedTrackPion = fitter3body.getTrack(1); + const auto& propagatedTrackDeuteron = fitter3body.getTrack(2); + propagatedTrackProton.getPxPyPzGlo(pProton); + propagatedTrackPion.getPxPyPzGlo(pPion); + propagatedTrackDeuteron.getPxPyPzGlo(pDeuteron); + std::array p3B = {pProton[0] + pPion[0] + pDeuteron[0], pProton[1] + pPion[1] + pDeuteron[1], pProton[2] + pPion[2] + pDeuteron[2]}; + + float r3body = std::hypot(pos[0], pos[1]); + if (r3body < 0.5) { + return; + } + + // Cut for the compatibility of V0 and 3body vertex + float deltaR = std::abs(rv0 - r3body); + if (deltaR > svertexerselections.maxRDiffV03body) { + return; + } + + float pt3B = std::hypot(p3B[0], p3B[1]); + if (pt3B < svertexerselections.minPt3Body) { // pt cut + return; + } + if (p3B[2] / pt3B > svertexerselections.maxTgl3Body) { // tgLambda cut + return; + } + + // H3L DCA Check + auto track3B = o2::track::TrackParCov(vertexXYZ, p3B, trackDeuteron.sign()); + o2::dataformats::DCA dca; + if (!track3B.propagateToDCA({{collision.posX(), collision.posY(), collision.posZ()}, {collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}}, fitter3body.getBz(), &dca, 5.) || + std::abs(dca.getY()) > svertexerselections.maxDCAXY3Body || std::abs(dca.getZ()) > svertexerselections.maxDCAZ3Body) { + return; + } + + return; + } + + private: + // internal helper to calculate DCA (3D) of a straight line to a given PV analytically + float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) + { + return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz)); + } +}; + +} // namespace pwglf +} // namespace o2 + +#endif // PWGLF_UTILS_DECAY3BODYBUILDERHELPER_H_ diff --git a/PWGLF/Utils/inelGt.h b/PWGLF/Utils/inelGt.h index 2ed513a902c..70c3de8ab4f 100644 --- a/PWGLF/Utils/inelGt.h +++ b/PWGLF/Utils/inelGt.h @@ -19,6 +19,10 @@ #ifndef PWGLF_UTILS_INELGT_H_ #define PWGLF_UTILS_INELGT_H_ +#include "Framework/O2DatabasePDGPlugin.h" + +#include "TParticlePDG.h" + #include namespace o2 diff --git a/PWGLF/Utils/pidTOFGeneric.h b/PWGLF/Utils/pidTOFGeneric.h new file mode 100644 index 00000000000..3e7dfd58c23 --- /dev/null +++ b/PWGLF/Utils/pidTOFGeneric.h @@ -0,0 +1,496 @@ +// 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. + +/// +/// \file pidTOFGeneric.h +/// \brief Utilities to recalculate secondary tracks TOF PID +/// \author Yuanzhe Wang +/// + +#ifndef PWGLF_UTILS_PIDTOFGENERIC_H_ +#define PWGLF_UTILS_PIDTOFGENERIC_H_ +#include "CollisionTypeHelper.h" +#include "MetadataHelper.h" +#include "TableHelper.h" + +#include "Common/Core/PID/PIDTOF.h" + +#include "CommonDataFormat/InteractionRecord.h" + +#include +#include + +namespace o2::aod +{ + +namespace pidtofgeneric +{ + +// Configuration common to all tasks, copied from pidTOFMerge.cxx but add metadataInfo as a member variable +struct TOFCalibConfig { + template + void init(const CfgType& opt) + { + mUrl = opt.cfgUrl.value; + mPathGrpLhcIf = opt.cfgPathGrpLhcIf.value; + mTimestamp = opt.cfgTimestamp.value; + mTimeShiftCCDBPathPos = opt.cfgTimeShiftCCDBPathPos.value; + mTimeShiftCCDBPathNeg = opt.cfgTimeShiftCCDBPathNeg.value; + mTimeShiftCCDBPathPosMC = opt.cfgTimeShiftCCDBPathPosMC.value; + mTimeShiftCCDBPathNegMC = opt.cfgTimeShiftCCDBPathNegMC.value; + mParamFileName = opt.cfgParamFileName.value; + mParametrizationPath = opt.cfgParametrizationPath.value; + mReconstructionPass = opt.cfgReconstructionPass.value; + mReconstructionPassDefault = opt.cfgReconstructionPassDefault.value; + mFatalOnPassNotAvailable = opt.cfgFatalOnPassNotAvailable.value; + mEnableTimeDependentResponse = opt.cfgEnableTimeDependentResponse.value; + mCollisionSystem = opt.cfgCollisionSystem.value; + mAutoSetProcessFunctions = opt.cfgAutoSetProcessFunctions.value; + } + + template + void getCfg(o2::framework::InitContext& initContext, const std::string name, VType& v, const std::string task) + { + if (!getTaskOptionValue(initContext, task, name, v, false)) { + LOG(fatal) << "Could not get " << name << " from " << task << " task"; + } + } + + void inheritFromBaseTask(o2::framework::InitContext& initContext, const std::string task = "tof-signal") + { + mInitMode = 2; + getCfg(initContext, "ccdb-url", mUrl, task); + getCfg(initContext, "ccdb-path-grplhcif", mPathGrpLhcIf, task); + getCfg(initContext, "ccdb-timestamp", mTimestamp, task); + getCfg(initContext, "timeShiftCCDBPathPos", mTimeShiftCCDBPathPos, task); + getCfg(initContext, "timeShiftCCDBPathNeg", mTimeShiftCCDBPathNeg, task); + getCfg(initContext, "timeShiftCCDBPathPosMC", mTimeShiftCCDBPathPosMC, task); + getCfg(initContext, "timeShiftCCDBPathNegMC", mTimeShiftCCDBPathNegMC, task); + getCfg(initContext, "paramFileName", mParamFileName, task); + getCfg(initContext, "parametrizationPath", mParametrizationPath, task); + getCfg(initContext, "reconstructionPass", mReconstructionPass, task); + getCfg(initContext, "reconstructionPassDefault", mReconstructionPassDefault, task); + getCfg(initContext, "fatalOnPassNotAvailable", mFatalOnPassNotAvailable, task); + getCfg(initContext, "enableTimeDependentResponse", mEnableTimeDependentResponse, task); + getCfg(initContext, "collisionSystem", mCollisionSystem, task); + getCfg(initContext, "autoSetProcessFunctions", mAutoSetProcessFunctions, task); + } + // @brief Set up the configuration from the calibration object from the init function of the task + template + void initSetup(o2::pid::tof::TOFResoParamsV3& mRespParamsV3, + CCDBObject ccdb) + { + mInitMode = 1; + // First we set the CCDB manager + ccdb->setURL(mUrl); + ccdb->setTimestamp(mTimestamp); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + // Not later than now objects + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + + // Then the information about the metadata + if (mReconstructionPass == "metadata") { + LOG(info) << "Getting pass from metadata"; + if (metadataInfo.isMC()) { + mReconstructionPass = metadataInfo.get("AnchorPassName"); + } else { + mReconstructionPass = metadataInfo.get("RecoPassName"); + } + LOG(info) << "Passed autodetect mode for pass. Taking '" << mReconstructionPass << "'"; + } + LOG(info) << "Using parameter collection, starting from pass '" << mReconstructionPass << "'"; + + if (!mParamFileName.empty()) { // Loading the parametrization from file + LOG(info) << "Loading exp. sigma parametrization from file " << mParamFileName << ", using param: " << mParametrizationPath << " and pass " << mReconstructionPass; + o2::tof::ParameterCollection paramCollection; + paramCollection.loadParamFromFile(mParamFileName, mParametrizationPath); + LOG(info) << "+++ Loaded parameter collection from file +++"; + if (!paramCollection.retrieveParameters(mRespParamsV3, mReconstructionPass)) { + if (mFatalOnPassNotAvailable) { + LOG(fatal) << "Pass '" << mReconstructionPass << "' not available in the retrieved object from file"; + } else { + LOG(warning) << "Pass '" << mReconstructionPass << "' not available in the retrieved object from file, fetching '" << mReconstructionPassDefault << "'"; + if (!paramCollection.retrieveParameters(mRespParamsV3, mReconstructionPassDefault)) { + paramCollection.print(); + LOG(fatal) << "Cannot get default pass for calibration " << mReconstructionPassDefault; + } else { + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection.getPars(mReconstructionPassDefault)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection.getPars(mReconstructionPassDefault)); + } + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection.getPars(mReconstructionPassDefault)); + } + } + } else { // Pass is available, load non standard parameters + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection.getPars(mReconstructionPass)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection.getPars(mReconstructionPass)); + } + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection.getPars(mReconstructionPass)); + } + } else if (!mEnableTimeDependentResponse) { // Loading it from CCDB + LOG(info) << "Loading initial exp. sigma parametrization from CCDB, using path: " << mParametrizationPath << " for timestamp " << mTimestamp; + o2::tof::ParameterCollection* paramCollection = ccdb->template getSpecific(mParametrizationPath, mTimestamp); + if (!paramCollection->retrieveParameters(mRespParamsV3, mReconstructionPass)) { // Attempt at loading the parameters with the pass defined + if (mFatalOnPassNotAvailable) { + LOG(fatal) << "Pass '" << mReconstructionPass << "' not available in the retrieved CCDB object"; + } else { + LOG(warning) << "Pass '" << mReconstructionPass << "' not available in the retrieved CCDB object, fetching '" << mReconstructionPassDefault << "'"; + if (!paramCollection->retrieveParameters(mRespParamsV3, mReconstructionPassDefault)) { + paramCollection->print(); + LOG(fatal) << "Cannot get default pass for calibration " << mReconstructionPassDefault; + } else { + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPassDefault)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection->getPars(mReconstructionPassDefault)); + } + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPassDefault)); + } + } + } else { // Pass is available, load non standard parameters + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPass)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection->getPars(mReconstructionPass)); + } + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPass)); + } + } + + // Loading additional calibration objects + std::map metadata; + if (!mReconstructionPass.empty()) { + metadata["RecoPassName"] = mReconstructionPass; + } + + auto updateTimeShift = [&](const std::string& nameShift, bool isPositive) { + if (nameShift.empty()) { + return; + } + const bool isFromFile = nameShift.find(".root") != std::string::npos; + if (isFromFile) { + LOG(info) << "Initializing the time shift for " << (isPositive ? "positive" : "negative") << " from file '" << nameShift << "'"; + mRespParamsV3.setTimeShiftParameters(nameShift, "ccdb_object", isPositive); + } else if (!mEnableTimeDependentResponse) { // If the response is fixed fetch it at the init time + LOG(info) << "Initializing the time shift for " << (isPositive ? "positive" : "negative") + << " from ccdb '" << nameShift << "' and timestamp " << mTimestamp + << " and pass '" << mReconstructionPass << "'"; + ccdb->setFatalWhenNull(false); + mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(nameShift, mTimestamp, metadata), isPositive); + ccdb->setFatalWhenNull(true); + } + LOG(info) << " test getTimeShift at 0 " << (isPositive ? "pos" : "neg") << ": " + << mRespParamsV3.getTimeShift(0, isPositive); + }; + + const std::string nameShiftPos = metadataInfo.isMC() ? mTimeShiftCCDBPathPosMC : mTimeShiftCCDBPathPos; + updateTimeShift(nameShiftPos, true); + const std::string nameShiftNeg = metadataInfo.isMC() ? mTimeShiftCCDBPathNegMC : mTimeShiftCCDBPathNeg; + updateTimeShift(nameShiftNeg, false); + + // Calibration object is defined + LOG(info) << "Parametrization at init time:"; + mRespParamsV3.printFullConfig(); + } + + template + void processSetup(o2::pid::tof::TOFResoParamsV3& mRespParamsV3, + CCDBObject ccdb, + const BcType& bc) + { + LOG(debug) << "Processing setup for run number " << bc.runNumber() << " from run " << mLastRunNumber; + // First we check if this run number was already processed + if (mLastRunNumber == bc.runNumber()) { + return; + } + LOG(info) << "Updating the parametrization from last run " << mLastRunNumber << " to " << bc.runNumber() << " and timestamp from " << mTimestamp << " " << bc.timestamp(); + mLastRunNumber = bc.runNumber(); + mTimestamp = bc.timestamp(); + + // Check the beam type + if (mCollisionSystem == -1) { + o2::parameters::GRPLHCIFData* grpo = ccdb->template getSpecific(mPathGrpLhcIf, + mTimestamp); + mCollisionSystem = CollisionSystemType::getCollisionTypeFromGrp(grpo); + } else { + LOG(debug) << "Not setting collisions system as already set to " << mCollisionSystem << " " << CollisionSystemType::getCollisionSystemName(mCollisionSystem); + } + + if (!mEnableTimeDependentResponse) { + return; + } + LOG(info) << "Updating parametrization from path '" << mParametrizationPath << "' and timestamp " << mTimestamp << " and reconstruction pass '" << mReconstructionPass << "' for run number " << bc.runNumber(); + if (mParamFileName.empty()) { // Not loading if parametrization was taken from file + LOG(info) << "Updating parametrization from ccdb"; + const o2::tof::ParameterCollection* paramCollection = ccdb->template getSpecific(mParametrizationPath, mTimestamp); + if (!paramCollection->retrieveParameters(mRespParamsV3, mReconstructionPass)) { + if (mFatalOnPassNotAvailable) { + LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.data()); + } else { + LOGF(warning, "Pass '%s' not available in the retrieved CCDB object, fetching '%s'", mReconstructionPass.data(), mReconstructionPassDefault.data()); + if (!paramCollection->retrieveParameters(mRespParamsV3, mReconstructionPassDefault)) { + paramCollection->print(); + LOG(fatal) << "Cannot get default pass for calibration " << mReconstructionPassDefault; + } else { // Found the default case + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPassDefault)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection->getPars(mReconstructionPassDefault)); + } + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPassDefault)); + } + } + } else { // Found the non default case + if (metadataInfo.isRun3()) { + mRespParamsV3.setResolutionParametrization(paramCollection->getPars(mReconstructionPass)); + } else { + mRespParamsV3.setResolutionParametrizationRun2(paramCollection->getPars(mReconstructionPass)); + } + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPass)); + } + } + + // Loading additional calibration objects + std::map metadata; + if (!mReconstructionPass.empty()) { + metadata["RecoPassName"] = mReconstructionPass; + } + + auto updateTimeShift = [&](const std::string& nameShift, bool isPositive) { + if (nameShift.empty()) { + return; + } + const bool isFromFile = nameShift.find(".root") != std::string::npos; + if (isFromFile) { + return; + } + LOG(info) << "Updating the time shift for " << (isPositive ? "positive" : "negative") + << " from ccdb '" << nameShift << "' and timestamp " << mTimestamp + << " and pass '" << mReconstructionPass << "'"; + ccdb->setFatalWhenNull(false); + mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(nameShift, mTimestamp, metadata), isPositive); + ccdb->setFatalWhenNull(true); + LOG(info) << " test getTimeShift at 0 " << (isPositive ? "pos" : "neg") << ": " + << mRespParamsV3.getTimeShift(0, isPositive); + }; + + updateTimeShift(metadataInfo.isMC() ? mTimeShiftCCDBPathPosMC : mTimeShiftCCDBPathPos, true); + updateTimeShift(metadataInfo.isMC() ? mTimeShiftCCDBPathNegMC : mTimeShiftCCDBPathNeg, false); + + LOG(info) << "Parametrization at setup time:"; + mRespParamsV3.printFullConfig(); + } + + bool autoSetProcessFunctions() const { return mAutoSetProcessFunctions; } + int collisionSystem() const { return mCollisionSystem; } + + o2::common::core::MetadataHelper metadataInfo; // additional member variable to store metadata information compared to pidTOFMerge.cxx + + private: + int mLastRunNumber = -1; // Last run number for which the calibration was loaded + int mInitMode = 0; // 0: no init, 1: init, 2: inherit + + // Configurable options + std::string mUrl; + std::string mPathGrpLhcIf; + int64_t mTimestamp; + std::string mTimeShiftCCDBPathPos; + std::string mTimeShiftCCDBPathNeg; + std::string mTimeShiftCCDBPathPosMC; + std::string mTimeShiftCCDBPathNegMC; + std::string mParamFileName; + std::string mParametrizationPath; + std::string mReconstructionPass; + std::string mReconstructionPassDefault; + bool mFatalOnPassNotAvailable; + bool mEnableTimeDependentResponse; + int mCollisionSystem; + bool mAutoSetProcessFunctions; +}; + +static constexpr float kCSPEED = TMath::C() * 1.0e2f * 1.0e-12f; // c in cm/ps + +template +class TofPidNewCollision +{ + public: + TofPidNewCollision() = default; + ~TofPidNewCollision() = default; + + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + o2::track::PID::ID pidType; + + template + using ResponseImplementation = o2::pid::tof::ExpTimes; + static constexpr auto responseEl = ResponseImplementation(); + static constexpr auto responseMu = ResponseImplementation(); + static constexpr auto responsePi = ResponseImplementation(); + static constexpr auto responseKa = ResponseImplementation(); + static constexpr auto responsePr = ResponseImplementation(); + static constexpr auto responseDe = ResponseImplementation(); + static constexpr auto responseTr = ResponseImplementation(); + static constexpr auto responseHe = ResponseImplementation(); + static constexpr auto responseAl = ResponseImplementation(); + + void SetParams(o2::pid::tof::TOFResoParamsV3 const& para) + { + mRespParamsV3.setParameters(para); + } + + void SetPidType(o2::track::PID::ID pidId) + { + pidType = pidId; + } + + template + float GetTOFNSigma(o2::track::PID::ID pidId, const ParamType& parameters, TTrack const& track, TCollision const& originalcol, TCollision const& correctedcol, bool EnableBCAO2D = true); + + template + float GetTOFNSigma(const ParamType& parameters, TTrack const& track, TCollision const& originalcol, TCollision const& correctedcol, bool EnableBCAO2D = true); + + template + float GetTOFNSigma(const ParamType& parameters, TTrack const& track); + template + float GetTOFNSigma(o2::track::PID::ID pidId, const ParamType& parameters, TTrack const& track); + + template + float CalculateTOFNSigma(o2::track::PID::ID pidId, const ParamType& parameters, TTrack const& track, double tofsignal, double evTime, double evTimeErr) + { + + float expSigma, tofNsigma = -999; + + switch (pidId) { + case 0: + expSigma = responseEl.GetExpectedSigma(parameters, track, tofsignal, evTimeErr); + tofNsigma = (tofsignal - evTime - responseEl.GetCorrectedExpectedSignal(parameters, track)) / expSigma; + break; + case 1: + expSigma = responseMu.GetExpectedSigma(parameters, track, tofsignal, evTimeErr); + tofNsigma = (tofsignal - evTime - responseMu.GetCorrectedExpectedSignal(parameters, track)) / expSigma; + break; + case 2: + expSigma = responsePi.GetExpectedSigma(parameters, track, tofsignal, evTimeErr); + tofNsigma = (tofsignal - evTime - responsePi.GetCorrectedExpectedSignal(parameters, track)) / expSigma; + break; + case 3: + expSigma = responseKa.GetExpectedSigma(parameters, track, tofsignal, evTimeErr); + tofNsigma = (tofsignal - evTime - responseKa.GetCorrectedExpectedSignal(parameters, track)) / expSigma; + break; + case 4: + expSigma = responsePr.GetExpectedSigma(parameters, track, tofsignal, evTimeErr); + tofNsigma = (tofsignal - evTime - responsePr.GetCorrectedExpectedSignal(parameters, track)) / expSigma; + break; + case 5: + expSigma = responseDe.GetExpectedSigma(parameters, track, tofsignal, evTimeErr); + tofNsigma = (tofsignal - evTime - responseDe.GetCorrectedExpectedSignal(parameters, track)) / expSigma; + break; + case 6: + expSigma = responseTr.GetExpectedSigma(parameters, track, tofsignal, evTimeErr); + tofNsigma = (tofsignal - evTime - responseTr.GetCorrectedExpectedSignal(parameters, track)) / expSigma; + break; + case 7: + expSigma = responseHe.GetExpectedSigma(parameters, track, tofsignal, evTimeErr); + tofNsigma = (tofsignal - evTime - responseHe.GetCorrectedExpectedSignal(parameters, track)) / expSigma; + break; + case 8: + expSigma = responseAl.GetExpectedSigma(parameters, track, tofsignal, evTimeErr); + tofNsigma = (tofsignal - evTime - responseAl.GetCorrectedExpectedSignal(parameters, track)) / expSigma; + break; + default: + LOG(fatal) << "Wrong particle ID in TofPidSecondary class"; + return -999; + } + + return tofNsigma; + } +}; + +template +template +float TofPidNewCollision::GetTOFNSigma(o2::track::PID::ID pidId, const ParamType& parameters, TTrack const& track, TCollision const& originalcol, TCollision const& correctedcol, bool EnableBCAO2D) +{ + + if (!track.has_collision() || !track.hasTOF()) { + return -999; + } + + float mMassHyp = o2::track::pid_constants::sMasses2Z[track.pidForTracking()]; + float expTime = track.length() * std::sqrt((mMassHyp * mMassHyp) + (track.tofExpMom() * track.tofExpMom())) / (kCSPEED * track.tofExpMom()); // L*E/(p*c) = L/v + + float evTime = correctedcol.evTime(); + float evTimeErr = correctedcol.evTimeErr(); + float tofsignal = track.trackTime() * 1000 + expTime; // in ps + + if (originalcol.globalIndex() == correctedcol.globalIndex()) { + evTime = track.evTimeForTrack(); + evTimeErr = track.evTimeErrForTrack(); + } else { + if (EnableBCAO2D) { + auto originalbc = originalcol.template bc_as(); + auto correctedbc = correctedcol.template bc_as(); + o2::InteractionRecord originalIR = o2::InteractionRecord::long2IR(originalbc.globalBC()); + o2::InteractionRecord correctedIR = o2::InteractionRecord::long2IR(correctedbc.globalBC()); + tofsignal += originalIR.differenceInBCNS(correctedIR) * 1000; + } else { + auto originalbc = originalcol.template foundBC_as(); + auto correctedbc = correctedcol.template foundBC_as(); + o2::InteractionRecord originalIR = o2::InteractionRecord::long2IR(originalbc.globalBC()); + o2::InteractionRecord correctedIR = o2::InteractionRecord::long2IR(correctedbc.globalBC()); + tofsignal += originalIR.differenceInBCNS(correctedIR) * 1000; + } + } + + float tofNsigma = CalculateTOFNSigma(pidId, parameters, track, tofsignal, evTime, evTimeErr); + return tofNsigma; +} + +template +template +float TofPidNewCollision::GetTOFNSigma(const ParamType& parameters, TTrack const& track, TCollision const& originalcol, TCollision const& correctedcol, bool EnableBCAO2D) +{ + return GetTOFNSigma(pidType, parameters, track, originalcol, correctedcol, EnableBCAO2D); +} + +template +template +float TofPidNewCollision::GetTOFNSigma(o2::track::PID::ID pidId, const ParamType& parameters, TTrack const& track) +{ + + if (!track.has_collision() || !track.hasTOF()) { + return -999; + } + + float mMassHyp = o2::track::pid_constants::sMasses2Z[track.pidForTracking()]; + float expTime = track.length() * std::sqrt((mMassHyp * mMassHyp) + (track.tofExpMom() * track.tofExpMom())) / (kCSPEED * track.tofExpMom()); // L*E/(p*c) = L/v + + float evTime = track.evTimeForTrack(); + float evTimeErr = track.evTimeErrForTrack(); + float tofsignal = track.trackTime() * 1000 + expTime; // in ps + + float tofNsigma = CalculateTOFNSigma(pidId, parameters, track, tofsignal, evTime, evTimeErr); + return tofNsigma; +} + +template +template +float TofPidNewCollision::GetTOFNSigma(const ParamType& parameters, TTrack const& track) +{ + return GetTOFNSigma(pidType, parameters, track); +} + +} // namespace pidtofgeneric +} // namespace o2::aod + +#endif // PWGLF_UTILS_PIDTOFGENERIC_H_ diff --git a/PWGLF/Utils/rsnOutput.h b/PWGLF/Utils/rsnOutput.h index 7d61441462c..592eaef40cc 100644 --- a/PWGLF/Utils/rsnOutput.h +++ b/PWGLF/Utils/rsnOutput.h @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // @@ -9,8 +9,9 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// +/// \file rsnOutput.h +/// \brief Resonance output class. /// \author Veronika Barbasova (veronika.barbasova@cern.ch) -/// \since April 3, 2024 #ifndef PWGLF_UTILS_RSNOUTPUT_H_ #define PWGLF_UTILS_RSNOUTPUT_H_ @@ -22,8 +23,6 @@ #include "Framework/HistogramRegistry.h" #include "Framework/Logger.h" -using namespace o2::framework; - namespace o2::analysis { namespace rsn @@ -47,6 +46,7 @@ enum class PairType { likemm, unliketrue, unlikegen, + unlikegenold, mixingpm, mixingpp, mixingmm, @@ -70,41 +70,58 @@ enum class PairAxisType { unknown }; +enum class MixingType { + ce, + mu, + none +}; + +MixingType mixingTypeName(std::string name) +{ + if (name == "ce") + return MixingType::ce; + else if (name == "mu") + return MixingType::mu; + + return MixingType::none; +} + enum class SystematicsAxisType { ncl, unknown }; -namespace PairAxis +namespace pair_axis { std::vector names{"im", "pt", "mu", "ce", "ns1", "ns2", "eta", "y", "vz", "mum", "cem", "vzm"}; } -namespace SystematicsAxis +namespace systematic_axis { std::vector names{"ncl"}; } + class Output { public: virtual ~Output() = default; - virtual void init(std::vector const& sparseAxes, std::vector const& allAxes, std::vector const& sysAxes, std::vector const& allAxes_sys, bool /*produceTrue*/ = false, bool /*eventMixing*/ = false, bool /*produceLikesign*/ = false, HistogramRegistry* registry = nullptr) + virtual void init(std::vector const& sparseAxes, std::vector const& allAxes, std::vector const& sysAxes, std::vector const& allAxes_sys, bool /*produceTrue*/ = false, MixingType /*eventMixing*/ = MixingType::none, bool /*produceLikesign*/ = false, o2::framework::HistogramRegistry* registry = nullptr) { mHistogramRegistry = registry; if (mHistogramRegistry == nullptr) - mHistogramRegistry = new HistogramRegistry("registry"); + mHistogramRegistry = new o2::framework::HistogramRegistry("registry"); // check if all axes are added in correct order for (int i = 0; i < static_cast(PairAxisType::unknown); i++) { auto aname = *std::move(allAxes[i].name); LOGF(debug, "Check axis '%s' %d", aname.c_str(), i); - if (aname.compare(PairAxis::names[static_cast(i)])) { - LOGF(fatal, "rsn::Output::Error: Order in allAxes is not correct !!! Expected axis '%s' and has '%s'.", aname.c_str(), PairAxis::names[static_cast(i)]); + if (aname.compare(pair_axis::names[static_cast(i)])) { + LOGF(fatal, "rsn::Output::Error: Order in allAxes is not correct !!! Expected axis '%s' and has '%s'.", aname.c_str(), pair_axis::names[static_cast(i)]); } } PairAxisType currentType; - for (auto& c : sparseAxes) { + for (const auto& c : sparseAxes) { currentType = type(c); if (currentType >= PairAxisType::unknown) { LOGF(warning, "Found unknown axis (rsn::PairAxisType = %d)!!! Skipping ...", static_cast(currentType)); @@ -120,27 +137,27 @@ class Output mFillPoint = new double[mCurrentAxisTypes.size()]; LOGF(info, "Number of axis added: %d", mCurrentAxes.size()); - mPairHisto = new HistogramConfigSpec(HistType::kTHnSparseF, mCurrentAxes); + mPairHisto = new o2::framework::HistogramConfigSpec(o2::framework::HistType::kTHnSparseF, mCurrentAxes); // check if all systematic axes are added in correct order for (int i = 0; i < static_cast(SystematicsAxisType::unknown); i++) { auto aname = *std::move(allAxes_sys[i].name); LOGF(debug, "Check axis '%s' %d", aname.c_str(), i); - if (aname.compare(SystematicsAxis::names[static_cast(i)])) { - LOGF(fatal, "rsn::Output::Error: Order in allAxes_sys is not correct !!! Expected axis '%s' and has '%s'.", aname.c_str(), SystematicsAxis::names[static_cast(i)]); + if (aname.compare(systematic_axis::names[static_cast(i)])) { + LOGF(fatal, "rsn::Output::Error: Order in allAxes_sys is not correct !!! Expected axis '%s' and has '%s'.", aname.c_str(), systematic_axis::names[static_cast(i)]); } } - SystematicsAxisType currentType_sys; - for (auto& c : sysAxes) { - currentType_sys = type_sys(c); - if (currentType_sys >= SystematicsAxisType::unknown) { - LOGF(warning, "Found unknown axis (rsn::SystematicsAxisType = %d)!!! Skipping ...", static_cast(currentType_sys)); + SystematicsAxisType currentTypeSys; + for (const auto& c : sysAxes) { + currentTypeSys = typeSys(c); + if (currentTypeSys >= SystematicsAxisType::unknown) { + LOGF(warning, "Found unknown axis (rsn::SystematicsAxisType = %d)!!! Skipping ...", static_cast(currentTypeSys)); continue; } LOGF(info, "Adding axis '%s' to systematic histogram", c.c_str()); - mCurrentAxesSys.push_back(allAxes_sys[static_cast(currentType_sys)]); - mCurrentAxisTypesSys.push_back(currentType_sys); + mCurrentAxesSys.push_back(allAxes_sys[static_cast(currentTypeSys)]); + mCurrentAxisTypesSys.push_back(currentTypeSys); } if (mFillPointSys != nullptr) @@ -148,14 +165,14 @@ class Output mFillPointSys = new double[mCurrentAxisTypesSys.size()]; LOGF(info, "Number of systematic axis added: %d", mCurrentAxesSys.size()); - mPairHistoSys = new HistogramConfigSpec(HistType::kTHnSparseF, mCurrentAxesSys); + mPairHistoSys = new o2::framework::HistogramConfigSpec(o2::framework::HistType::kTHnSparseF, mCurrentAxesSys); } template void fillSparse(const T& h, double* point) { int i = 0; - for (auto& at : mCurrentAxisTypes) { + for (const auto& at : mCurrentAxisTypes) { mFillPoint[i++] = point[static_cast(at)]; } mHistogramRegistry->get(h)->Fill(mFillPoint); @@ -165,7 +182,7 @@ class Output void fillSparseSys(const T& h, double* point) { int i = 0; - for (auto& at : mCurrentAxisTypesSys) { + for (const auto& at : mCurrentAxisTypesSys) { mFillPointSys[i++] = point[static_cast(at)]; } mHistogramRegistry->get(h)->Fill(mFillPointSys); @@ -190,6 +207,7 @@ class Output virtual void fillLikemm(double* point) = 0; virtual void fillUnliketrue(double* point) = 0; virtual void fillUnlikegen(double* point) = 0; + virtual void fillUnlikegenOld(double* point) = 0; virtual void fillMixingpm(double* point) = 0; virtual void fillMixingpp(double* point) = 0; virtual void fillMixingmm(double* point) = 0; @@ -198,47 +216,47 @@ class Output PairAxisType type(std::string name) { - auto it = std::find(PairAxis::names.begin(), PairAxis::names.end(), name); - if (it == PairAxis::names.end()) { + auto it = std::find(pair_axis::names.begin(), pair_axis::names.end(), name); + if (it == pair_axis::names.end()) { return PairAxisType::unknown; } - return static_cast(std::distance(PairAxis::names.begin(), it)); + return static_cast(std::distance(pair_axis::names.begin(), it)); } - SystematicsAxisType type_sys(std::string name) + SystematicsAxisType typeSys(std::string name) { - auto it = std::find(SystematicsAxis::names.begin(), SystematicsAxis::names.end(), name); - if (it == SystematicsAxis::names.end()) { + auto it = std::find(systematic_axis::names.begin(), systematic_axis::names.end(), name); + if (it == systematic_axis::names.end()) { return SystematicsAxisType::unknown; } - return static_cast(std::distance(SystematicsAxis::names.begin(), it)); + return static_cast(std::distance(systematic_axis::names.begin(), it)); } std::string name(PairAxisType type) { - return PairAxis::names[(static_cast(type))]; + return pair_axis::names[(static_cast(type))]; } - std::string name_sys(SystematicsAxisType type) + std::string nameSys(SystematicsAxisType type) { - return SystematicsAxis::names[(static_cast(type))]; + return systematic_axis::names[(static_cast(type))]; } - AxisSpec axis(std::vector const& allAxes, PairAxisType type) + o2::framework::AxisSpec axis(std::vector const& allAxes, PairAxisType type) { - const AxisSpec unknownAxis = {1, 0., 1., "unknown axis", "unknown"}; + const o2::framework::AxisSpec unknownAxis = {1, 0., 1., "unknown axis", "unknown"}; if (type == PairAxisType::unknown) return unknownAxis; return allAxes[static_cast(type)]; } protected: - HistogramRegistry* mHistogramRegistry = nullptr; - HistogramConfigSpec* mPairHisto = nullptr; - HistogramConfigSpec* mPairHistoSys = nullptr; - std::vector mCurrentAxes; + o2::framework::HistogramRegistry* mHistogramRegistry = nullptr; + o2::framework::HistogramConfigSpec* mPairHisto = nullptr; + o2::framework::HistogramConfigSpec* mPairHistoSys = nullptr; + std::vector mCurrentAxes; std::vector mCurrentAxisTypes; - std::vector mCurrentAxesSys; + std::vector mCurrentAxesSys; std::vector mCurrentAxisTypesSys; double* mFillPoint = nullptr; double* mFillPointSys = nullptr; @@ -247,7 +265,7 @@ class Output class OutputSparse : public Output { public: - virtual void init(std::vector const& sparseAxes, std::vector const& allAxes, std::vector const& sysAxes, std::vector const& allAxes_sys, bool produceTrue = false, bool eventMixing = false, bool produceLikesign = false, HistogramRegistry* registry = nullptr) + virtual void init(std::vector const& sparseAxes, std::vector const& allAxes, std::vector const& sysAxes, std::vector const& allAxes_sys, bool produceTrue = false, MixingType eventMixing = MixingType::none, bool produceLikesign = false, o2::framework::HistogramRegistry* registry = nullptr) { Output::init(sparseAxes, allAxes, sysAxes, allAxes_sys, produceTrue, eventMixing, produceLikesign, registry); @@ -260,8 +278,9 @@ class OutputSparse : public Output if (produceTrue) { mHistogramRegistry->add("unliketrue", "Unlike True", *mPairHisto); mHistogramRegistry->add("unlikegen", "Unlike Gen", *mPairHisto); + mHistogramRegistry->add("unlikegenold", "Unlike Gen Old", *mPairHisto); } - if (eventMixing) { + if (eventMixing != MixingType::none) { mHistogramRegistry->add("mixingpm", "Event Mixing pm", *mPairHisto); if (produceLikesign) { mHistogramRegistry->add("mixingpp", "Event Mixing pp", *mPairHisto); @@ -306,6 +325,9 @@ class OutputSparse : public Output case PairType::unlikegen: fillUnlikegen(point); break; + case PairType::unlikegenold: + fillUnlikegenOld(point); + break; case PairType::mixingpm: fillMixingpm(point); break; @@ -350,6 +372,10 @@ class OutputSparse : public Output { fillSparse(HIST("unlikegen"), point); } + virtual void fillUnlikegenOld(double* point) + { + fillSparse(HIST("unlikegenold"), point); + } virtual void fillMixingpm(double* point) { fillSparse(HIST("mixingpm"), point); diff --git a/PWGLF/Utils/strangenessBuilderHelper.h b/PWGLF/Utils/strangenessBuilderHelper.h new file mode 100644 index 00000000000..6eda3c07848 --- /dev/null +++ b/PWGLF/Utils/strangenessBuilderHelper.h @@ -0,0 +1,1306 @@ +// 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. + +#ifndef PWGLF_UTILS_STRANGENESSBUILDERHELPER_H_ +#define PWGLF_UTILS_STRANGENESSBUILDERHELPER_H_ + +#include +#include +#include +#include "DCAFitter/DCAFitterN.h" +#include "Framework/AnalysisDataModel.h" +#include "ReconstructionDataFormats/Track.h" +#include "DetectorsBase/GeometryManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/trackUtilities.h" +#include "Tools/KFparticle/KFUtilities.h" + +#ifndef HomogeneousField +#define HomogeneousField +#endif + +/// includes KFParticle +#include "KFParticle.h" +#include "KFPTrack.h" +#include "KFPVertex.h" +#include "KFParticleBase.h" +#include "KFVertex.h" + +namespace o2 +{ +namespace pwglf +{ +//__________________________________________ +// V0 group: abstraction to deal with duplicates +// in an intuitive manner +struct V0group { + std::vector V0Ids; // index list to original aod::V0s + std::vector collisionIds; // coll indices + int posTrackId; + int negTrackId; + uint8_t v0Type; +}; + +//_______________________________________________________________________ +template +std::vector sort_indices_posTrack(const std::vector& v) +{ + std::vector idx(v.size()); + std::iota(idx.begin(), idx.end(), 0); + std::stable_sort(idx.begin(), idx.end(), + [&v](std::size_t i1, std::size_t i2) { return v[i1].posTrackId < v[i2].posTrackId; }); + return idx; +} + +//_______________________________________________________________________ +template +std::vector sort_indices_negTrack(const std::vector& v) +{ + std::vector idx(v.size()); + std::iota(idx.begin(), idx.end(), 0); + std::stable_sort(idx.begin(), idx.end(), + [&v](std::size_t i1, std::size_t i2) { return v[i1].negTrackId < v[i2].negTrackId; }); + return idx; +} + +//_______________________________________________________________________ +// this function deals with the fact that V0s provided in AO2Ds may +// be duplicated in several collisions and groups them into entries +// of type pwglf::V0group, each entry having the same neg/pos tracks +// but an array of compatible collisions. The original V0 indices +// are preserved in the resulting structure to allow for easy referencing +// back afterwards. Algorithmically, full N^2 loops and/or multiple +// find calls are avoided via sorting. +template +std::vector groupDuplicates(const T& V0s) +{ + std::vector v0table; + if (V0s.size() == 0) { + return v0table; + } + V0group thisV0; + thisV0.V0Ids.push_back(-1); // create one single element + thisV0.collisionIds.push_back(-1); // create one single element + for (auto const& V0 : V0s) { + thisV0.V0Ids[0] = V0.globalIndex(); + thisV0.collisionIds[0] = V0.collisionId(); + thisV0.posTrackId = V0.posTrackId(); + thisV0.negTrackId = V0.negTrackId(); + thisV0.v0Type = V0.v0Type(); + v0table.push_back(thisV0); + } + + // sort tracks according to positive track index to avoid excessive N^2 searches + auto posTrackSort = sort_indices_posTrack(v0table); + + // create a proper list of V0s including duplicates: collisionIds is now a vector + int atPosTrackId = v0table[posTrackSort[0]].posTrackId; + std::vector v0tableFixedPositive; // small list with fixed positive id + std::vector v0tableGrouped; // final list with proper grouping + for (size_t iV0 = 0; iV0 < posTrackSort.size(); iV0++) { + if (atPosTrackId != v0table[posTrackSort[iV0]].posTrackId) { + // switched pos track id. Process chunk of V0s + auto negTrackSort = sort_indices_negTrack(v0tableFixedPositive); + thisV0.collisionIds.clear(); + thisV0.V0Ids.clear(); + thisV0.negTrackId = v0tableFixedPositive[negTrackSort[0]].negTrackId; + for (size_t iPV0 = 0; iPV0 < v0tableFixedPositive.size(); iPV0++) { + if (thisV0.negTrackId != v0tableFixedPositive[negTrackSort[iPV0]].negTrackId) { + v0tableGrouped.push_back(thisV0); + thisV0.collisionIds.clear(); // clean collision Ids + thisV0.V0Ids.clear(); // clean aod::V0s Ids + } + thisV0.V0Ids.push_back(v0tableFixedPositive[negTrackSort[iPV0]].V0Ids[0]); + thisV0.collisionIds.push_back(v0tableFixedPositive[negTrackSort[iPV0]].collisionIds[0]); + thisV0.posTrackId = v0tableFixedPositive[negTrackSort[iPV0]].posTrackId; + thisV0.negTrackId = v0tableFixedPositive[negTrackSort[iPV0]].negTrackId; + thisV0.v0Type = v0tableFixedPositive[negTrackSort[iPV0]].v0Type; + } + v0tableGrouped.push_back(thisV0); // publish last + v0tableFixedPositive.clear(); + atPosTrackId = v0table[posTrackSort[iV0]].posTrackId; // move to the next pos index + } + v0tableFixedPositive.push_back(v0table[posTrackSort[iV0]]); + } + v0tableGrouped.push_back(thisV0); // publish last + + LOGF(info, "Duplicate V0s grouped. aod::V0s counted: %i, unique index pairs: %i", V0s.size(), v0tableGrouped.size()); + return v0tableGrouped; +} + +//__________________________________________ +// V0 information storage +struct v0candidate { + // indexing + int collisionId = -1; + int negativeTrack = -1; + int positiveTrack = -1; + + // daughter properties + std::array positiveMomentum = {0.0f, 0.0f, 0.0f}; + std::array negativeMomentum = {0.0f, 0.0f, 0.0f}; + std::array positivePosition = {0.0f, 0.0f, 0.0f}; + std::array negativePosition = {0.0f, 0.0f, 0.0f}; + float positiveTrackX = 0.0f; + float negativeTrackX = 0.0f; + float positiveDCAxy = 0.0f; + float negativeDCAxy = 0.0f; + + // V0 properties + std::array momentum = {0.0f, 0.0f, 0.0f}; // necessary for KF + std::array position = {0.0f, 0.0f, 0.0f}; + float daughterDCA = 1000.0f; + float pointingAngle = 1.0f; + float dcaToPV = 0.0f; + float v0DCAToPVxy = 0.0f; + float v0DCAToPVz = 0.0f; + + // calculated masses for convenience + float massGamma; + float massK0Short; + float massLambda; + float massAntiLambda; + + // stored for decay chains + float positionCovariance[6]; + float momentumCovariance[6]; +}; + +//__________________________________________ +// Cascade information storage +struct cascadeCandidate { + // indexing + int collisionId = -1; + int v0Id = -1; + int negativeTrack = -1; + int positiveTrack = -1; + int bachelorTrack = -1; + + // daughter properties + std::array positiveMomentum = {0.0f, 0.0f, 0.0f}; + std::array negativeMomentum = {0.0f, 0.0f, 0.0f}; + std::array bachelorMomentum = {0.0f, 0.0f, 0.0f}; + std::array positivePosition = {0.0f, 0.0f, 0.0f}; + std::array negativePosition = {0.0f, 0.0f, 0.0f}; + std::array bachelorPosition = {0.0f, 0.0f, 0.0f}; + float positiveDCAxy = 0.0f; + float negativeDCAxy = 0.0f; + float bachelorDCAxy = 0.0f; + float positiveTrackX = 0.0f; + float negativeTrackX = 0.0f; + float bachelorTrackX = 0.0f; + + // cascade properties + int charge = -1; // default: []Minus + float cascadeDaughterDCA = 1000.0f; + float v0DaughterDCA = 1000.0f; + + float pointingAngle = 0.0f; + float cascadeDCAxy = 0.0f; + float cascadeDCAz = 0.0f; + std::array v0Position = {0.0f, 0.0f, 0.0f}; + std::array v0Momentum = {0.0f, 0.0f, 0.0f}; + std::array cascadePosition = {0.0f, 0.0f, 0.0f}; + std::array cascadeMomentum = {0.0f, 0.0f, 0.0f}; + + float bachBaryonCosPA = 0.0f; + float bachBaryonDCAxyToPV = 1e+3; + float massXi = 0.0f; + float massOmega = 0.0f; + + // KF-specific variables + float kfV0Chi2 = 0.0f; + float kfCascadeChi2 = 0.0f; + float kfMLambda = 0.0f; + float kfTrackCovarianceV0[21]; + float kfTrackCovariancePos[21]; + float kfTrackCovarianceNeg[21]; + + // stored for decay chains + float covariance[21]; +}; + +//__________________________________________ +// builder helper class +class strangenessBuilderHelper +{ + public: + strangenessBuilderHelper() + { + // standards hardcoded in builder ... + // ...but can be changed easily since fitter is public + fitter.setPropagateToPCA(true); + fitter.setMaxR(200.); + fitter.setMinParamChange(1e-3); + fitter.setMinRelChi2Change(0.9); + fitter.setMaxDZIni(1e9); + fitter.setMaxDXYIni(4.0f); + fitter.setMaxChi2(1e9); + fitter.setUseAbsDCA(true); + fitter.setWeightedFinalPCA(false); + + v0selections.minCrossedRows = -1; + v0selections.dcanegtopv = -1.0f; + v0selections.dcapostopv = -1.0f; + v0selections.v0cospa = -2; + v0selections.dcav0dau = 1e+6; + v0selections.v0radius = 0.0f; + v0selections.maxDaughterEta = 2.0; + + // LUT has to be loaded later + lut = nullptr; + fitter.setMatCorrType(o2::base::Propagator::MatCorrType::USEMatCorrLUT); + + // mag field has to be set later + fitter.setBz(-999.9f); // will NOT make sense if not changed + }; + + //_______________________________________________________________________ + // standard build V0 function. Populates ::v0 object + // ::v0 will be initialized to defaults if build fails + template + bool buildV0Candidate(int collisionIndex, + float pvX, float pvY, float pvZ, + TTrack const& positiveTrack, + TTrack const& negativeTrack, + TTrackParametrization& positiveTrackParam, + TTrackParametrization& negativeTrackParam, + bool useCollinearFit = false, + bool calculateCovariance = false, + bool acceptTPCOnly = false) + { + if constexpr (useSelections) { + // verify track quality + if (positiveTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) { + v0 = {}; + return false; + } + if (negativeTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) { + v0 = {}; + return false; + } + // verify eta + if (std::fabs(positiveTrack.eta()) > v0selections.maxDaughterEta) { + v0 = {}; + return false; + } + if (std::fabs(negativeTrack.eta()) > v0selections.maxDaughterEta) { + v0 = {}; + return false; + } + if (!acceptTPCOnly && !positiveTrack.hasITS()) { + v0 = {}; + return false; + } + if (!acceptTPCOnly && !negativeTrack.hasITS()) { + v0 = {}; + return false; + } + } + + // Calculate DCA with respect to the collision associated to the V0 + std::array dcaInfo; + + // do DCA to PV on copies instead of originals + auto positiveTrackParamCopy = positiveTrackParam; + auto negativeTrackParamCopy = negativeTrackParam; + + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, positiveTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); + v0.positiveDCAxy = dcaInfo[0]; + + if constexpr (useSelections) { + if (std::fabs(v0.positiveDCAxy) < v0selections.dcanegtopv) { + v0 = {}; + return false; + } + } + + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, negativeTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); + v0.negativeDCAxy = dcaInfo[0]; + + if constexpr (useSelections) { + if (std::fabs(v0.negativeDCAxy) < v0selections.dcanegtopv) { + v0 = {}; + return false; + } + } + + // Perform DCA fit + int nCand = 0; + fitter.setCollinear(useCollinearFit); + try { + nCand = fitter.process(positiveTrackParam, negativeTrackParam); + } catch (...) { + v0 = {}; + return false; + } + if (nCand == 0) { + v0 = {}; + return false; + } + fitter.setCollinear(false); // proper cleaning: when exiting this loop, always reset to not collinear + + // Calculate DCAToPV of the V0 + o2::track::TrackPar V0Temp = fitter.createParentTrackPar(); + V0Temp.setAbsCharge(0); // charge zero + std::array dcaV0Info; + + // propagate to collision vertex + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, V0Temp, 2.f, fitter.getMatCorrType(), &dcaV0Info); + v0.v0DCAToPVxy = dcaV0Info[0]; + v0.v0DCAToPVz = dcaV0Info[1]; + + v0.positiveTrackX = fitter.getTrack(0).getX(); + v0.negativeTrackX = fitter.getTrack(1).getX(); + positiveTrackParam = fitter.getTrack(0); + negativeTrackParam = fitter.getTrack(1); + positiveTrackParam.getPxPyPzGlo(v0.positiveMomentum); + negativeTrackParam.getPxPyPzGlo(v0.negativeMomentum); + positiveTrackParam.getXYZGlo(v0.positivePosition); + negativeTrackParam.getXYZGlo(v0.negativePosition); + for (int i = 0; i < 3; i++) { + // avoids misuse if mixed with KF particle use + v0.momentum[i] = v0.positiveMomentum[i] + v0.negativeMomentum[i]; + } + + // get decay vertex coordinates + const auto& vtx = fitter.getPCACandidate(); + for (int i = 0; i < 3; i++) { + v0.position[i] = vtx[i]; + } + + if constexpr (useSelections) { + if (std::hypot(v0.position[0], v0.position[1]) < v0selections.v0radius) { + v0 = {}; + return false; + } + } + + v0.daughterDCA = TMath::Sqrt(fitter.getChi2AtPCACandidate()); + + if constexpr (useSelections) { + if (v0.daughterDCA > v0selections.dcav0dau) { + v0 = {}; + return false; + } + } + + double cosPA = RecoDecay::cpa( + std::array{pvX, pvY, pvZ}, + std::array{v0.position[0], v0.position[1], v0.position[2]}, + std::array{v0.positiveMomentum[0] + v0.negativeMomentum[0], v0.positiveMomentum[1] + v0.negativeMomentum[1], v0.positiveMomentum[2] + v0.negativeMomentum[2]}); + if constexpr (useSelections) { + if (cosPA < v0selections.v0cospa) { + v0 = {}; + return false; + } + } + + v0.pointingAngle = TMath::ACos(cosPA); + v0.dcaToPV = CalculateDCAStraightToPV( + v0.position[0], v0.position[1], v0.position[2], + v0.positiveMomentum[0] + v0.negativeMomentum[0], + v0.positiveMomentum[1] + v0.negativeMomentum[1], + v0.positiveMomentum[2] + v0.negativeMomentum[2], + pvX, pvY, pvZ); + + // Calculate masses + v0.massGamma = RecoDecay::m(std::array{ + std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]}, + std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassElectron}); + v0.massK0Short = RecoDecay::m(std::array{ + std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]}, + std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged}); + v0.massLambda = RecoDecay::m(std::array{ + std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]}, + std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); + v0.massAntiLambda = RecoDecay::m(std::array{ + std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]}, + std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton}); + + // calculate covariance if requested + if (calculateCovariance) { + // Calculate position covariance matrix + auto covVtxV = fitter.calcPCACovMatrix(0); + // std::array positionCovariance; + v0.positionCovariance[0] = covVtxV(0, 0); + v0.positionCovariance[1] = covVtxV(1, 0); + v0.positionCovariance[2] = covVtxV(1, 1); + v0.positionCovariance[3] = covVtxV(2, 0); + v0.positionCovariance[4] = covVtxV(2, 1); + v0.positionCovariance[5] = covVtxV(2, 2); + std::array covTpositive = {0.}; + std::array covTnegative = {0.}; + positiveTrackParam.getCovXYZPxPyPzGlo(covTpositive); + negativeTrackParam.getCovXYZPxPyPzGlo(covTnegative); + constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int i = 0; i < 6; i++) { + v0.momentumCovariance[i] = covTpositive[MomInd[i]] + covTnegative[MomInd[i]]; + } + } + + // set collision Id correctly + v0.collisionId = collisionIndex; + + // information validated, V0 built successfully. Signal OK + return true; + } + + //_______________________________________________________________________ + // build V0 with KF function. Populates ::v0 object + // ::v0 will be initialized to defaults if build fails + template + bool buildV0CandidateWithKF(TCollision const& collision, + TTrack const& positiveTrack, + TTrack const& negativeTrack, + TTrackParametrization& positiveTrackParam, + TTrackParametrization& negativeTrackParam, + int kfConstructMethod = 2, // the typical used + float kfConstrainedMassValue = 0.0f, // negative: no constraint + bool kfConstrainToPrimaryVertex = true) + { + int collisionIndex = collision.globalIndex(); + float pvX = collision.posX(); + float pvY = collision.posY(); + float pvZ = collision.posZ(); + + // verify track quality + if (positiveTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) { + v0 = {}; + return false; + } + if (negativeTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) { + v0 = {}; + return false; + } + + // verify eta + if (std::fabs(positiveTrack.eta()) > v0selections.maxDaughterEta) { + v0 = {}; + return false; + } + if (std::fabs(negativeTrack.eta()) > v0selections.maxDaughterEta) { + v0 = {}; + return false; + } + + // Calculate DCA with respect to the collision associated to the V0 + std::array dcaInfo; + + // do DCA to PV on copies instead of originals + auto positiveTrackParamCopy = positiveTrackParam; + auto negativeTrackParamCopy = negativeTrackParam; + + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, positiveTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); + v0.positiveDCAxy = dcaInfo[0]; + + if (std::fabs(v0.positiveDCAxy) < v0selections.dcanegtopv) { + v0 = {}; + return false; + } + + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, negativeTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); + v0.negativeDCAxy = dcaInfo[0]; + + if (std::fabs(v0.negativeDCAxy) < v0selections.dcanegtopv) { + v0 = {}; + return false; + } + + //__________________________________________ + //*>~<* do V0 with KF + // create KFParticle objects from trackParCovs + KFParticle kfpPos = createKFParticleFromTrackParCov(positiveTrackParam, positiveTrackParam.getCharge(), o2::constants::physics::MassElectron); + KFParticle kfpNeg = createKFParticleFromTrackParCov(negativeTrackParam, negativeTrackParam.getCharge(), o2::constants::physics::MassElectron); + + KFParticle kfpPos_DecayVtx = kfpPos; + KFParticle kfpNeg_DecayVtx = kfpNeg; + const KFParticle* V0Daughters[2] = {&kfpPos, &kfpNeg}; + + // construct V0 + KFParticle KFV0; + KFV0.SetConstructMethod(kfConstructMethod); + try { + KFV0.Construct(V0Daughters, 2); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to construct cascade V0 from daughter tracks: " << e.what(); + v0 = {}; + return false; + } + + if (kfConstrainedMassValue > -1e-4) { + // photon constraint: this one's got no mass + KFV0.SetNonlinearMassConstraint(kfConstrainedMassValue); + } + + // V0 constructed, now recovering TrackParCov for dca fitter minimization (with material correction) + KFV0.TransportToDecayVertex(); + o2::track::TrackParCov v0TrackParCov = getTrackParCovFromKFP(KFV0, o2::track::PID::Lambda, 0); + v0TrackParCov.setAbsCharge(0); // to be sure + + // estimate momentum of daughters (since KFParticle does not allow us to retrieve it directly...) + float xyz_decay[3] = {KFV0.GetX(), KFV0.GetY(), KFV0.GetZ()}; + kfpPos_DecayVtx.TransportToPoint(xyz_decay); + kfpNeg_DecayVtx.TransportToPoint(xyz_decay); + + v0.positiveMomentum = {kfpPos_DecayVtx.GetPx(), kfpPos_DecayVtx.GetPy(), kfpPos_DecayVtx.GetPz()}; + v0.negativeMomentum = {kfpNeg_DecayVtx.GetPx(), kfpNeg_DecayVtx.GetPy(), kfpNeg_DecayVtx.GetPz()}; + + v0.daughterDCA = std::hypot( + kfpPos_DecayVtx.GetX() - kfpNeg_DecayVtx.GetX(), + kfpPos_DecayVtx.GetY() - kfpNeg_DecayVtx.GetY(), + kfpPos_DecayVtx.GetZ() - kfpNeg_DecayVtx.GetZ()); + + if (v0.daughterDCA > v0selections.dcav0dau) { + v0 = {}; + return false; + } + + // check radius + for (int i = 0; i < 3; i++) { + v0.position[i] = xyz_decay[i]; + } + if (std::hypot(v0.position[0], v0.position[1]) < v0selections.v0radius) { + v0 = {}; + return false; + } + + KFPVertex kfpVertex = createKFPVertexFromCollision(collision); + KFParticle KFPV(kfpVertex); + + // deal with pointing angle + float cosPA = cpaFromKF(KFV0, KFPV); + if (cosPA < v0selections.v0cospa) { + v0 = {}; + return false; + } + v0.pointingAngle = TMath::ACos(cosPA); + + v0.dcaToPV = CalculateDCAStraightToPV( + v0.position[0], v0.position[1], v0.position[2], + v0.momentum[0], v0.momentum[1], v0.momentum[2], + pvX, pvY, pvZ); + + // apply topological constraint to PV if requested + // might adjust px py pz + KFParticle KFV0_PV = KFV0; + if (kfConstrainToPrimaryVertex) { + KFV0_PV.SetProductionVertex(KFPV); + } + v0.momentum = {KFV0_PV.GetPx(), KFV0_PV.GetPy(), KFV0_PV.GetPz()}; + + // set collision Id correctly + v0.collisionId = collisionIndex; + + // Calculate masses + v0.massGamma = RecoDecay::m(std::array{ + std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]}, + std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassElectron, o2::constants::physics::MassElectron}); + v0.massK0Short = RecoDecay::m(std::array{ + std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]}, + std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged}); + v0.massLambda = RecoDecay::m(std::array{ + std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]}, + std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); + v0.massAntiLambda = RecoDecay::m(std::array{ + std::array{v0.positiveMomentum[0], v0.positiveMomentum[1], v0.positiveMomentum[2]}, + std::array{v0.negativeMomentum[0], v0.negativeMomentum[1], v0.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton}); + + // information validated, V0 built successfully. Signal OK + return true; + } + + //_______________________________________________________________________ + // build Cascade from three tracks, including V0 building. + // Populates ::cascade object. + // ::cascade will be initialized to defaults if build fails + // cascade builder creating a cascade from plain tracks + template + bool buildCascadeCandidate(int collisionIndex, + float pvX, float pvY, float pvZ, + TTrack const& positiveTrack, + TTrack const& negativeTrack, + TTrack const& bachelorTrack, + bool calculateBachelorBaryonVariables = false, + bool useCascadeMomentumAtPV = false, + bool processCovariances = false) + { + // no special treatment of positive and negative tracks when building V0s for cascades + auto posTrackPar = getTrackParCov(positiveTrack); + auto negTrackPar = getTrackParCov(negativeTrack); + + if (!buildV0Candidate(collisionIndex, pvX, pvY, pvZ, positiveTrack, negativeTrack, posTrackPar, negTrackPar, false, processCovariances, false)) { + return false; + } + if (!buildCascadeCandidate(collisionIndex, pvX, pvY, pvZ, v0, positiveTrack, negativeTrack, bachelorTrack, calculateBachelorBaryonVariables, useCascadeMomentumAtPV, processCovariances)) { + return false; + } + return true; + } + + //_______________________________________________________________________ + // cascade builder using pre-fabricated information, thus not calling + // the DCAfitter again for the V0 contained in the cascade + // If building from scratch, prefer previous version! + // Populates ::cascade object. + // ::cascade will be initialized to defaults if build fails + // cascade builder creating a cascade from plain tracks + template + bool buildCascadeCandidate(int collisionIndex, + float pvX, float pvY, float pvZ, + v0candidate const& v0input, + TTrack const& positiveTrack, + TTrack const& negativeTrack, + TTrack const& bachelorTrack, + bool calculateBachelorBaryonVariables = false, + bool useCascadeMomentumAtPV = false, + bool processCovariances = false) + { + // verify track quality + if (positiveTrack.tpcNClsCrossedRows() < cascadeselections.minCrossedRows) { + cascade = {}; + return false; + } + if (negativeTrack.tpcNClsCrossedRows() < cascadeselections.minCrossedRows) { + cascade = {}; + return false; + } + if (bachelorTrack.tpcNClsCrossedRows() < cascadeselections.minCrossedRows) { + cascade = {}; + return false; + } + + // verify eta + if (std::fabs(positiveTrack.eta()) > cascadeselections.maxDaughterEta) { + cascade = {}; + return false; + } + if (std::fabs(negativeTrack.eta()) > cascadeselections.maxDaughterEta) { + cascade = {}; + return false; + } + if (std::fabs(bachelorTrack.eta()) > cascadeselections.maxDaughterEta) { + cascade = {}; + return false; + } + + // verify lambda mass + if (bachelorTrack.sign() < 0 && std::fabs(v0input.massLambda - 1.116) > cascadeselections.lambdaMassWindow) { + cascade = {}; + return false; + } + if (bachelorTrack.sign() > 0 && std::fabs(v0input.massAntiLambda - 1.116) > cascadeselections.lambdaMassWindow) { + cascade = {}; + return false; + } + + if (calculateBachelorBaryonVariables) { + // Calculates properties of the V0 comprised of bachelor and baryon in the cascade + // baryon: distinguished via bachelor charge + if (bachelorTrack.sign() < 0) { + processBachBaryonVariables(pvX, pvY, pvZ, bachelorTrack, positiveTrack); + } else { + processBachBaryonVariables(pvX, pvY, pvZ, bachelorTrack, negativeTrack); + } + } + + // Overall cascade charge + cascade.charge = bachelorTrack.signed1Pt() > 0 ? +1 : -1; + + // bachelor DCA track to PV + // Calculate DCA with respect to the collision associated to the V0, not individual tracks + std::array dcaInfo; + + auto bachTrackPar = getTrackPar(bachelorTrack); + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, bachTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo); + cascade.bachelorDCAxy = dcaInfo[0]; + + if (std::fabs(cascade.bachelorDCAxy) < cascadeselections.dcabachtopv) { + cascade = {}; + return false; + } + + // Do actual minimization + auto lBachelorTrack = getTrackParCov(bachelorTrack); + + // Set up covariance matrices (should in fact be optional) + std::array covV = {0.}; + constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int i = 0; i < 6; i++) { + covV[MomInd[i]] = v0input.momentumCovariance[i]; + covV[i] = v0input.positionCovariance[i]; + } + auto lV0Track = o2::track::TrackParCov( + {v0input.position[0], v0input.position[1], v0input.position[2]}, + {v0input.positiveMomentum[0] + v0input.negativeMomentum[0], v0input.positiveMomentum[1] + v0input.negativeMomentum[1], v0input.positiveMomentum[2] + v0input.negativeMomentum[2]}, + covV, 0, true); + lV0Track.setAbsCharge(0); + lV0Track.setPID(o2::track::PID::Lambda); + + //---/---/---/ + // Move close to minima + int nCand = 0; + try { + nCand = fitter.process(lV0Track, lBachelorTrack); + } catch (...) { + cascade = {}; + return false; + } + if (nCand == 0) { + cascade = {}; + return false; + } + + lV0Track = fitter.getTrack(0); + lBachelorTrack = fitter.getTrack(1); + + // DCA between cascade daughters + cascade.cascadeDaughterDCA = TMath::Sqrt(fitter.getChi2AtPCACandidate()); + if (cascade.cascadeDaughterDCA > cascadeselections.dcacascdau) { + cascade = {}; + return false; + } + + lBachelorTrack.getPxPyPzGlo(cascade.bachelorMomentum); + // get decay vertex coordinates + const auto& vtx = fitter.getPCACandidate(); + for (int i = 0; i < 3; i++) { + cascade.cascadePosition[i] = vtx[i]; + } + if (std::hypot(cascade.cascadePosition[0], cascade.cascadePosition[1]) < cascadeselections.cascradius) { + cascade = {}; + return false; + } + + double cosPA = RecoDecay::cpa( + std::array{pvX, pvY, pvZ}, + std::array{cascade.cascadePosition[0], cascade.cascadePosition[1], cascade.cascadePosition[2]}, + std::array{v0input.positiveMomentum[0] + v0input.negativeMomentum[0] + cascade.bachelorMomentum[0], + v0input.positiveMomentum[1] + v0input.negativeMomentum[1] + cascade.bachelorMomentum[1], + v0input.positiveMomentum[2] + v0input.negativeMomentum[2] + cascade.bachelorMomentum[2]}); + if (cosPA < cascadeselections.casccospa) { + cascade = {}; + return false; + } + cascade.pointingAngle = TMath::ACos(cosPA); + + // Calculate DCAxy of the cascade (with bending) + auto lCascadeTrack = fitter.createParentTrackParCov(); + lCascadeTrack.setAbsCharge(cascade.charge); // to be sure + lCascadeTrack.setPID(o2::track::PID::XiMinus); // FIXME: not OK for omegas + dcaInfo[0] = 999; + dcaInfo[1] = 999; + + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, lCascadeTrack, 2.f, fitter.getMatCorrType(), &dcaInfo); + cascade.cascadeDCAxy = dcaInfo[0]; + cascade.cascadeDCAz = dcaInfo[1]; + + // Calculate masses a priori + cascade.massXi = RecoDecay::m(std::array{std::array{cascade.bachelorMomentum[0], cascade.bachelorMomentum[1], cascade.bachelorMomentum[2]}, + std::array{v0input.positiveMomentum[0] + v0input.negativeMomentum[0], v0input.positiveMomentum[1] + v0input.negativeMomentum[1], v0input.positiveMomentum[2] + v0input.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassLambda}); + cascade.massOmega = RecoDecay::m(std::array{std::array{cascade.bachelorMomentum[0], cascade.bachelorMomentum[1], cascade.bachelorMomentum[2]}, + std::array{v0input.positiveMomentum[0] + v0input.negativeMomentum[0], v0input.positiveMomentum[1] + v0input.negativeMomentum[1], v0input.positiveMomentum[2] + v0input.negativeMomentum[2]}}, + std::array{o2::constants::physics::MassKaonCharged, o2::constants::physics::MassLambda}); + + // Populate information + // cascadecandidate.v0Id = v0index.globalIndex(); + cascade.collisionId = collisionIndex; + cascade.positiveTrack = positiveTrack.globalIndex(); + cascade.negativeTrack = negativeTrack.globalIndex(); + cascade.bachelorTrack = bachelorTrack.globalIndex(); + cascade.positiveTrackX = v0input.positiveTrackX; + cascade.negativeTrackX = v0input.negativeTrackX; + cascade.bachelorTrackX = lBachelorTrack.getX(); // from this minimization + cascade.v0Position[0] = v0input.position[0]; + cascade.v0Position[1] = v0input.position[1]; + cascade.v0Position[2] = v0input.position[2]; + cascade.v0Momentum[0] = v0input.positiveMomentum[0] + v0input.negativeMomentum[0]; + cascade.v0Momentum[1] = v0input.positiveMomentum[1] + v0input.negativeMomentum[1]; + cascade.v0Momentum[2] = v0input.positiveMomentum[2] + v0input.negativeMomentum[2]; + cascade.positiveMomentum[0] = v0input.positiveMomentum[0]; + cascade.positiveMomentum[1] = v0input.positiveMomentum[1]; + cascade.positiveMomentum[2] = v0input.positiveMomentum[2]; + cascade.negativeMomentum[0] = v0input.negativeMomentum[0]; + cascade.negativeMomentum[1] = v0input.negativeMomentum[1]; + cascade.negativeMomentum[2] = v0input.negativeMomentum[2]; + cascade.v0DaughterDCA = v0input.daughterDCA; + cascade.positiveDCAxy = v0input.positiveDCAxy; + cascade.negativeDCAxy = v0input.negativeDCAxy; + + if (useCascadeMomentumAtPV) { + lCascadeTrack.getPxPyPzGlo(cascade.cascadeMomentum); + } else { + cascade.cascadeMomentum[0] = cascade.bachelorMomentum[0] + v0input.positiveMomentum[0] + v0input.negativeMomentum[0]; + cascade.cascadeMomentum[1] = cascade.bachelorMomentum[1] + v0input.positiveMomentum[1] + v0input.negativeMomentum[1]; + cascade.cascadeMomentum[2] = cascade.bachelorMomentum[2] + v0input.positiveMomentum[2] + v0input.negativeMomentum[2]; + } + + if (processCovariances) { + // Calculate position covariance matrix + auto covVtxV = fitter.calcPCACovMatrix(0); + // std::array positionCovariance; + float positionCovariance[6]; + positionCovariance[0] = covVtxV(0, 0); + positionCovariance[1] = covVtxV(1, 0); + positionCovariance[2] = covVtxV(1, 1); + positionCovariance[3] = covVtxV(2, 0); + positionCovariance[4] = covVtxV(2, 1); + positionCovariance[5] = covVtxV(2, 2); + // store momentum covariance matrix + std::array covTv0 = {0.}; + std::array covTbachelor = {0.}; + // std::array momentumCovariance; + lV0Track.getCovXYZPxPyPzGlo(covTv0); + lBachelorTrack.getCovXYZPxPyPzGlo(covTbachelor); + constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int i = 0; i < 21; i++) { + cascade.covariance[i] = 0.0f; + } + for (int i = 0; i < 6; i++) { + cascade.covariance[i] = positionCovariance[i]; + cascade.covariance[MomInd[i]] = covTv0[MomInd[i]] + covTbachelor[MomInd[i]]; + } + } + + // Final outcome is YES if I got here! + return true; + } + + //_______________________________________________________________________ + // build KF Cascade from three tracks, including V0 building. + // Populates ::cascade object. + // ::cascade will be initialized to defaults if build fails + // cascade builder creating a cascade from plain tracks + template + bool buildCascadeCandidateWithKF(int collisionIndex, + float pvX, float pvY, float pvZ, + TTrack const& positiveTrack, + TTrack const& negativeTrack, + TTrack const& bachelorTrack, + bool calculateBachelorBaryonVariables = false, + int kfConstructMethod = 2, + bool kfTuneForOmega = false, + bool kfUseV0MassConstraint = true, + bool kfUseCascadeMassConstraint = false, + bool kfDoDCAFitterPreMinimV0 = false, + bool kfDoDCAFitterPreMinimCasc = false) + { + //*>~<*>~<*>~<*>~<*>~<*>~<*>~<*>~<*>~<* + // KF particle based rebuilding + // dispenses prior V0 generation, uses constrained (re-)fit based on bachelor charge + //*>~<*>~<*>~<*>~<*>~<*>~<*>~<*>~<*>~<* + + if (positiveTrack.tpcNClsCrossedRows() < cascadeselections.minCrossedRows) { + cascade = {}; + return false; + } + if (negativeTrack.tpcNClsCrossedRows() < cascadeselections.minCrossedRows) { + cascade = {}; + return false; + } + if (bachelorTrack.tpcNClsCrossedRows() < cascadeselections.minCrossedRows) { + cascade = {}; + return false; + } + + // verify eta + if (std::fabs(positiveTrack.eta()) > cascadeselections.maxDaughterEta) { + cascade = {}; + return false; + } + if (std::fabs(negativeTrack.eta()) > cascadeselections.maxDaughterEta) { + cascade = {}; + return false; + } + if (std::fabs(bachelorTrack.eta()) > cascadeselections.maxDaughterEta) { + cascade = {}; + return false; + } + + if (calculateBachelorBaryonVariables) { + // Calculates properties of the V0 comprised of bachelor and baryon in the cascade + // baryon: distinguished via bachelor charge + if (bachelorTrack.sign() < 0) { + processBachBaryonVariables(pvX, pvY, pvZ, bachelorTrack, positiveTrack); + } else { + processBachBaryonVariables(pvX, pvY, pvZ, bachelorTrack, negativeTrack); + } + } + + // Overall cascade charge + cascade.charge = bachelorTrack.signed1Pt() > 0 ? +1 : -1; + + // bachelor DCA track to PV + // Calculate DCA with respect to the collision associated to the V0, not individual tracks + std::array dcaInfo; + + auto bachTrackPar = getTrackPar(bachelorTrack); + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, bachTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo); + cascade.bachelorDCAxy = dcaInfo[0]; + o2::track::TrackParCov posTrackParCovForDCA = getTrackParCov(positiveTrack); + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, posTrackParCovForDCA, 2.f, fitter.getMatCorrType(), &dcaInfo); + cascade.positiveDCAxy = dcaInfo[0]; + o2::track::TrackParCov negTrackParCovForDCA = getTrackParCov(negativeTrack); + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, negTrackParCovForDCA, 2.f, fitter.getMatCorrType(), &dcaInfo); + cascade.negativeDCAxy = dcaInfo[0]; + + if (std::fabs(cascade.bachelorDCAxy) < cascadeselections.dcabachtopv) { + cascade = {}; + return false; + } + + o2::track::TrackParCov lBachelorTrack = getTrackParCov(bachelorTrack); + o2::track::TrackParCov posTrackParCov = getTrackParCov(positiveTrack); + o2::track::TrackParCov negTrackParCov = getTrackParCov(negativeTrack); + + float massPosTrack, massNegTrack; + if (cascade.charge < 0) { + massPosTrack = o2::constants::physics::MassProton; + massNegTrack = o2::constants::physics::MassPionCharged; + } else { + massPosTrack = o2::constants::physics::MassPionCharged; + massNegTrack = o2::constants::physics::MassProton; + } + + //__________________________________________ + //*>~<* step 1 : V0 with dca fitter, uses material corrections implicitly + // This is optional - move close to minima and therefore take material + if (kfDoDCAFitterPreMinimV0) { + int nCand = 0; + try { + nCand = fitter.process(posTrackParCov, negTrackParCov); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + cascade = {}; + return false; + } + if (nCand == 0) { + cascade = {}; + return false; + } + // save classical DCA daughters + cascade.v0DaughterDCA = TMath::Sqrt(fitter.getChi2AtPCACandidate()); + + // re-acquire from DCA fitter + posTrackParCov = fitter.getTrack(0); + negTrackParCov = fitter.getTrack(1); + } + + //__________________________________________ + //*>~<* step 2 : V0 with KF + // create KFParticle objects from trackParCovs + KFParticle kfpPos = createKFParticleFromTrackParCov(posTrackParCov, posTrackParCov.getCharge(), massPosTrack); + KFParticle kfpNeg = createKFParticleFromTrackParCov(negTrackParCov, negTrackParCov.getCharge(), massNegTrack); + const KFParticle* V0Daughters[2] = {&kfpPos, &kfpNeg}; + + // construct V0 + KFParticle KFV0; + KFV0.SetConstructMethod(kfConstructMethod); + try { + KFV0.Construct(V0Daughters, 2); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to construct cascade V0 from daughter tracks: " << e.what(); + cascade = {}; + return false; + } + + if (kfUseV0MassConstraint) { + KFV0.SetNonlinearMassConstraint(o2::constants::physics::MassLambda); + } + + // V0 constructed, now recovering TrackParCov for dca fitter minimization (with material correction) + KFV0.TransportToDecayVertex(); + o2::track::TrackParCov v0TrackParCov = getTrackParCovFromKFP(KFV0, o2::track::PID::Lambda, 0); + v0TrackParCov.setAbsCharge(0); // to be sure + + //__________________________________________ + //*>~<* step 3 : Cascade with dca fitter (with material corrections) + if (kfDoDCAFitterPreMinimCasc) { + int nCandCascade = 0; + try { + nCandCascade = fitter.process(v0TrackParCov, lBachelorTrack); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + cascade = {}; + return false; + } + if (nCandCascade == 0) { + cascade = {}; + return false; + } + + v0TrackParCov = fitter.getTrack(0); + lBachelorTrack = fitter.getTrack(1); + } + + //__________________________________________ + //*>~<* step 4 : Cascade with KF particle (potentially mass-constrained if asked) + float massBachelorPion = o2::constants::physics::MassPionCharged; + float massBachelorKaon = o2::constants::physics::MassKaonCharged; + + KFParticle kfpV0 = createKFParticleFromTrackParCov(v0TrackParCov, 0, o2::constants::physics::MassLambda); + KFParticle kfpBachPion = createKFParticleFromTrackParCov(lBachelorTrack, cascade.charge, massBachelorPion); + KFParticle kfpBachKaon = createKFParticleFromTrackParCov(lBachelorTrack, cascade.charge, massBachelorKaon); + const KFParticle* XiDaugthers[2] = {&kfpBachPion, &kfpV0}; + const KFParticle* OmegaDaugthers[2] = {&kfpBachKaon, &kfpV0}; + + // construct mother + KFParticle KFXi, KFOmega; + KFXi.SetConstructMethod(kfConstructMethod); + KFOmega.SetConstructMethod(kfConstructMethod); + try { + KFXi.Construct(XiDaugthers, 2); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to construct xi from V0 and bachelor track: " << e.what(); + cascade = {}; + return false; + } + try { + KFOmega.Construct(OmegaDaugthers, 2); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to construct omega from V0 and bachelor track: " << e.what(); + cascade = {}; + return false; + } + if (kfUseCascadeMassConstraint) { + // set mass constraint if requested + // WARNING: this is only adequate for decay chains, i.e. XiC -> Xi or OmegaC -> Omega + KFXi.SetNonlinearMassConstraint(o2::constants::physics::MassXiMinus); + KFOmega.SetNonlinearMassConstraint(o2::constants::physics::MassOmegaMinus); + } + KFXi.TransportToDecayVertex(); + KFOmega.TransportToDecayVertex(); + + // get DCA of daughters at vertex + cascade.cascadeDaughterDCA = kfpBachPion.GetDistanceFromParticle(kfpV0); + if (cascade.cascadeDaughterDCA > cascadeselections.dcacascdau) { + cascade = {}; + return false; + } + + //__________________________________________ + //*>~<* step 5 : propagate cascade to primary vertex with material corrections if asked + + o2::track::TrackParCov lCascadeTrack; + if (!kfTuneForOmega) { + lCascadeTrack = getTrackParCovFromKFP(KFXi, o2::track::PID::XiMinus, cascade.charge); + } else { + lCascadeTrack = getTrackParCovFromKFP(KFOmega, o2::track::PID::OmegaMinus, cascade.charge); + } + dcaInfo[0] = 999; + dcaInfo[1] = 999; + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, lCascadeTrack, 2.f, fitter.getMatCorrType(), &dcaInfo); + cascade.cascadeDCAxy = dcaInfo[0]; + cascade.cascadeDCAz = dcaInfo[1]; + + //__________________________________________ + //*>~<* step 6 : acquire all parameters for analysis + + // basic indices + cascade.collisionId = collisionIndex; + cascade.v0Id = -1; + cascade.positiveTrack = positiveTrack.globalIndex(); + cascade.negativeTrack = negativeTrack.globalIndex(); + cascade.bachelorTrack = bachelorTrack.globalIndex(); + + // KF chi2 + cascade.kfV0Chi2 = KFV0.GetChi2(); + cascade.kfCascadeChi2 = KFXi.GetChi2(); + if (kfTuneForOmega) + cascade.kfCascadeChi2 = KFOmega.GetChi2(); + + // Daughter momentum not KF-updated FIXME --> but DCA fitter updated if pre-minimisation is used + lBachelorTrack.getPxPyPzGlo(cascade.bachelorMomentum); + posTrackParCov.getPxPyPzGlo(cascade.positiveMomentum); + negTrackParCov.getPxPyPzGlo(cascade.negativeMomentum); + + // Daughter track position at vertex not KF-updated FIXME --> but DCA fitter updated if pre-minimisation is used + posTrackParCov.getXYZGlo(cascade.positivePosition); + negTrackParCov.getXYZGlo(cascade.negativePosition); + + // mother position information from KF + cascade.v0Position[0] = KFV0.GetX(); + cascade.v0Position[1] = KFV0.GetY(); + cascade.v0Position[2] = KFV0.GetZ(); + + // mother momentumm information from KF + cascade.v0Momentum[0] = KFV0.GetPx(); + cascade.v0Momentum[1] = KFV0.GetPy(); + cascade.v0Momentum[2] = KFV0.GetPz(); + + // Mother position + momentum is KF updated + if (!kfTuneForOmega) { + cascade.cascadePosition[0] = KFXi.GetX(); + cascade.cascadePosition[1] = KFXi.GetY(); + cascade.cascadePosition[2] = KFXi.GetZ(); + cascade.cascadeMomentum[0] = KFXi.GetPx(); + cascade.cascadeMomentum[1] = KFXi.GetPy(); + cascade.cascadeMomentum[2] = KFXi.GetPz(); + } else { + cascade.cascadePosition[0] = KFOmega.GetX(); + cascade.cascadePosition[1] = KFOmega.GetY(); + cascade.cascadePosition[2] = KFOmega.GetZ(); + cascade.cascadeMomentum[0] = KFOmega.GetPx(); + cascade.cascadeMomentum[1] = KFOmega.GetPy(); + cascade.cascadeMomentum[2] = KFOmega.GetPz(); + } + if (std::hypot(cascade.cascadePosition[0], cascade.cascadePosition[1]) < cascadeselections.cascradius) { + cascade = {}; + return false; + } + + // KF-aware cosPA + double cosPA = RecoDecay::cpa( + std::array{pvX, pvY, pvZ}, + std::array{cascade.cascadePosition[0], cascade.cascadePosition[1], cascade.cascadePosition[2]}, + std::array{cascade.cascadeMomentum[0], cascade.cascadeMomentum[1], cascade.cascadeMomentum[2]}); + if (cosPA < cascadeselections.casccospa) { + cascade = {}; + return false; + } + cascade.pointingAngle = TMath::ACos(cosPA); + + // Calculate masses a priori + float MLambda, SigmaLambda, MXi, SigmaXi, MOmega, SigmaOmega; + KFV0.GetMass(MLambda, SigmaLambda); + KFXi.GetMass(MXi, SigmaXi); + KFOmega.GetMass(MOmega, SigmaOmega); + cascade.kfMLambda = MLambda; + cascade.massXi = MXi; + cascade.massOmega = MOmega; + + // KF Cascade covariance matrix + std::array covCascKF; + for (int i = 0; i < 21; i++) { // get covariance matrix elements (lower triangle) + covCascKF[i] = KFXi.GetCovariance(i); + cascade.covariance[i] = covCascKF[i]; + } + + // KF V0 covariance matrix + std::array covV0KF; + for (int i = 0; i < 21; i++) { // get covariance matrix elements (lower triangle) + covV0KF[i] = KFV0.GetCovariance(i); + cascade.kfTrackCovarianceV0[i] = covV0KF[i]; + } + + // V0 daughter covariance matrices + std::array cvPosKF, cvNegKF; + posTrackParCov.getCovXYZPxPyPzGlo(cvPosKF); + negTrackParCov.getCovXYZPxPyPzGlo(cvNegKF); + for (int i = 0; i < 21; i++) { + cascade.kfTrackCovariancePos[i] = cvPosKF[i]; + cascade.kfTrackCovarianceNeg[i] = cvNegKF[i]; + } + + return true; + } + + o2::base::MatLayerCylSet* lut; // material LUT for DCA fitter + o2::vertexing::DCAFitterN<2> fitter; // 2-prong o2 dca fitter + + v0candidate v0; // storage for V0 candidate properties + cascadeCandidate cascade; // storage for cascade candidate properties + + // v0 candidate criteria + struct { + int minCrossedRows; + float dcanegtopv; + float dcapostopv; + double v0cospa; + float dcav0dau; + float v0radius; + float maxDaughterEta; + } v0selections; + + // cascade candidate criteria + struct { + int minCrossedRows; + float dcabachtopv; + float cascradius; + float casccospa; + float dcacascdau; + float lambdaMassWindow; + float maxDaughterEta; + } cascadeselections; + + private: + // internal helper to calculate DCA (3D) of a straight line to a given PV analytically + float CalculateDCAStraightToPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ) + { + return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz)); + } + + template + void processBachBaryonVariables(float pvX, float pvY, float pvZ, TTrack const& track1, TTrack const& track2) + { + cascade.bachBaryonCosPA = 0; // would ordinarily accept all + cascade.bachBaryonDCAxyToPV = 1e+3; // would ordinarily accept all + + // create tracks from table rows + o2::track::TrackParCov tr1 = getTrackParCov(track1); + o2::track::TrackParCov tr2 = getTrackParCov(track2); + + //---/---/---/ + // Move close to minima + int nCand = 0; + try { + nCand = fitter.process(tr1, tr2); + } catch (...) { + return; + } + if (nCand == 0) + return; // variables are such that candidate is accepted (not obvious...) + + // Calculate DCAxy of the cascade (with bending) + o2::track::TrackPar wrongV0 = fitter.createParentTrackPar(); + wrongV0.setAbsCharge(0); // charge zero + std::array dcaInfo; + dcaInfo[0] = 999; + dcaInfo[1] = 999; + + // bachelor-baryon DCAxy to PV + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, wrongV0, 2.f, fitter.getMatCorrType(), &dcaInfo); + cascade.bachBaryonDCAxyToPV = dcaInfo[0]; + + const auto& vtx = fitter.getPCACandidate(); + if (!fitter.isPropagateTracksToVertexDone()) + return; + + std::array tr1p; + std::array tr2p; + + fitter.getTrack(1).getPxPyPzGlo(tr1p); + fitter.getTrack(2).getPxPyPzGlo(tr2p); + + // bachelor-baryon CosPA + cascade.bachBaryonCosPA = RecoDecay::cpa( + std::array{pvX, pvY, pvZ}, + std::array{vtx[0], vtx[1], vtx[2]}, + std::array{tr1p[0] + tr2p[0], tr1p[1] + tr2p[1], tr1p[2] + tr2p[2]}); + + // Potentially also to be considered: bachelor-baryon DCA (between the two tracks) + // to be added here as complementary information in the future + } +}; + +} // namespace pwglf +} // namespace o2 + +#endif // PWGLF_UTILS_STRANGENESSBUILDERHELPER_H_ diff --git a/PWGLF/Utils/strangenessBuilderModule.h b/PWGLF/Utils/strangenessBuilderModule.h new file mode 100644 index 00000000000..4673be69592 --- /dev/null +++ b/PWGLF/Utils/strangenessBuilderModule.h @@ -0,0 +1,2564 @@ +// 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. + +/// \file strangenessBuilderModule.h +/// \brief strangeness builder module +/// \author ALICE + +// simple checkers, but ensure 8 bit integers +#define BITSET(var, nbit) ((var) |= (static_cast(1) << static_cast(nbit))) + +#ifndef PWGLF_UTILS_STRANGENESSBUILDERMODULE_H_ +#define PWGLF_UTILS_STRANGENESSBUILDERMODULE_H_ + +#include "TableHelper.h" + +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/Utils/strangenessBuilderHelper.h" + +#include "Common/Core/TPCVDriftManager.h" + +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisHelpers.h" +#include "Framework/Configurable.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/HistogramSpec.h" + +#include +#include +#include +#include +#include + +//__________________________________________ +// strangeness builder module + +namespace o2 +{ +namespace pwglf +{ +namespace strangenessbuilder // avoid polluting other namespaces +{ + +// statics necessary for the configurables in this namespace +static constexpr int nParameters = 1; +static const std::vector tableNames{ + "V0Indices", //.0 (standard analysis: V0Cores) + "V0CoresBase", //.1 (standard analyses: main table) + "V0Covs", //.2 (joinable with V0Cores) + "CascIndices", //.3 (standard analyses: CascData) + "KFCascIndices", //.4 (standard analyses: KFCascData) + "TraCascIndices", //.5 (standard analyses: TraCascData) + "StoredCascCores", //.6 (standard analyses: CascData, main table) + "StoredKFCascCores", //.7 (standard analyses: KFCascData, main table) + "StoredTraCascCores", //.8 (standard analyses: TraCascData, main table) + "CascCovs", //.9 (joinable with CascData) + "KFCascCovs", //.10 (joinable with KFCascData) + "TraCascCovs", //.11 (joinable with TraCascData) + "V0TrackXs", //.12 (joinable with V0Data) + "CascTrackXs", //.13 (joinable with CascData) + "CascBBs", //.14 (standard, bachelor-baryon vars) + "V0DauCovs", //.15 (requested: tracking studies) + "V0DauCovIUs", //.16 (requested: tracking studies) + "V0TraPosAtDCAs", //.17 (requested: tracking studies) + "V0TraPosAtIUs", //.18 (requested: tracking studies) + "V0Ivanovs", //.19 (requested: tracking studies) + "McV0Labels", //.20 (MC/standard analysis) + "V0MCCores", //.21 (MC, all generated desired V0s) + "V0CoreMCLabels", //.22 (MC, refs V0Cores to V0MCCores) + "V0MCCollRefs", //.23 (MC, refs V0MCCores to McCollisions) + "McCascLabels", //.24 (MC/standard analysis) + "McKFCascLabels", //.25 (MC, refs KFCascCores to CascMCCores) + "McTraCascLabels", //.26 (MC, refs TraCascCores to CascMCCores) + "McCascBBTags", //.27 (MC, joinable with CascCores, tags reco-ed) + "CascMCCores", //.28 (MC, all generated desired cascades) + "CascCoreMCLabels", //.29 (MC, refs CascCores to CascMCCores) + "CascMCCollRefs", // 30 (MC, refs CascMCCores to McCollisions) + "CascToTraRefs", //.31 (interlink CascCores -> TraCascCores) + "CascToKFRefs", //.32 (interlink CascCores -> KFCascCores) + "TraToCascRefs", //.33 (interlink TraCascCores -> CascCores) + "KFToCascRefs", //.34 (interlink KFCascCores -> CascCores) + "V0FoundTags", //.35 (tags found vs findable V0s in findable mode) + "CascFoundTags" //.36 (tags found vs findable Cascades in findable mode) +}; + +static constexpr int nTablesConst = 37; + +static const std::vector parameterNames{"enable"}; +static const int defaultParameters[nTablesConst][nParameters]{ + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, // index 9 + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, // index 19 + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, // index 29 + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}, + {-1}}; + +// table index : match order above +enum tableIndex { kV0Indices = 0, + kV0CoresBase, + kV0Covs, + kCascIndices, + kKFCascIndices, + kTraCascIndices, + kStoredCascCores, + kStoredKFCascCores, + kStoredTraCascCores, + kCascCovs, + kKFCascCovs, + kTraCascCovs, + kV0TrackXs, + kCascTrackXs, + kCascBBs, + kV0DauCovs, + kV0DauCovIUs, + kV0TraPosAtDCAs, + kV0TraPosAtIUs, + kV0Ivanovs, + kMcV0Labels, + kV0MCCores, + kV0CoreMCLabels, + kV0MCCollRefs, + kMcCascLabels, + kMcKFCascLabels, + kMcTraCascLabels, + kMcCascBBTags, + kCascMCCores, + kCascCoreMCLabels, + kCascMCCollRefs, + kCascToTraRefs, + kCascToKFRefs, + kTraToCascRefs, + kKFToCascRefs, + kV0FoundTags, + kCascFoundTags, + nTables }; + +enum V0PreSelection : uint8_t { selGamma = 0, + selK0Short, + selLambda, + selAntiLambda }; + +enum CascPreSelection : uint8_t { selXiMinus = 0, + selXiPlus, + selOmegaMinus, + selOmegaPlus }; + +static constexpr float defaultK0MassWindowParameters[1][4] = {{2.81882e-03, 1.14057e-03, 1.72138e-03, 5.00262e-01}}; +static constexpr float defaultLambdaWindowParameters[1][4] = {{1.17518e-03, 1.24099e-04, 5.47937e-03, 3.08009e-01}}; +static constexpr float defaultXiMassWindowParameters[1][4] = {{1.43210e-03, 2.03561e-04, 2.43187e-03, 7.99668e-01}}; +static constexpr float defaultOmMassWindowParameters[1][4] = {{1.43210e-03, 2.03561e-04, 2.43187e-03, 7.99668e-01}}; + +static constexpr float defaultLifetimeCuts[1][4] = {{20, 60, 40, 20}}; + +struct products : o2::framework::ProducesGroup { + //__________________________________________________ + // V0 tables + o2::framework::Produces v0indices; // standard part of V0Datas + o2::framework::Produces v0cores; // standard part of V0Datas + o2::framework::Produces v0covs; // for decay chain reco + + //__________________________________________________ + // cascade tables + o2::framework::Produces cascidx; // standard part of CascDatas + o2::framework::Produces kfcascidx; // standard part of KFCascDatas + o2::framework::Produces tracascidx; // standard part of TraCascDatas + o2::framework::Produces cascdata; // standard part of CascDatas + o2::framework::Produces kfcascdata; // standard part of KFCascDatas + o2::framework::Produces tracascdata; // standard part of TraCascDatas + o2::framework::Produces casccovs; // for decay chain reco + o2::framework::Produces kfcasccovs; // for decay chain reco + o2::framework::Produces tracasccovs; // for decay chain reco + + //__________________________________________________ + // interlink tables + o2::framework::Produces v0dataLink; // de-refs V0s -> V0Data + o2::framework::Produces cascdataLink; // de-refs Cascades -> CascData + o2::framework::Produces kfcascdataLink; // de-refs Cascades -> KFCascData + o2::framework::Produces tracascdataLink; // de-refs Cascades -> TraCascData + + //__________________________________________________ + // secondary auxiliary tables + o2::framework::Produces v0trackXs; // for decay chain reco + o2::framework::Produces cascTrackXs; // for decay chain reco + + //__________________________________________________ + // further auxiliary / optional if desired + o2::framework::Produces cascbb; + o2::framework::Produces v0daucovs; // covariances of daughter tracks + o2::framework::Produces v0daucovIUs; // covariances of daughter tracks + o2::framework::Produces v0dauPositions; // auxiliary debug information + o2::framework::Produces v0dauPositionsIU; // auxiliary debug information + o2::framework::Produces v0ivanovs; // information for Marian's tests + + //__________________________________________________ + // MC information: V0 + o2::framework::Produces v0labels; // MC labels for V0s + o2::framework::Produces v0mccores; // mc info storage + o2::framework::Produces v0CoreMCLabels; // interlink V0Cores -> V0MCCores + o2::framework::Produces v0mccollref; // references collisions from V0MCCores + + // MC information: Cascades + o2::framework::Produces casclabels; // MC labels for cascades + o2::framework::Produces kfcasclabels; // MC labels for KF cascades + o2::framework::Produces tracasclabels; // MC labels for tracked cascades + o2::framework::Produces bbtags; // bb tags (inv structure tagging in mc) + o2::framework::Produces cascmccores; // mc info storage + o2::framework::Produces cascCoreMClabels; // interlink CascCores -> CascMCCores + o2::framework::Produces cascmccollrefs; // references MC collisions from MC cascades + + //__________________________________________________ + // cascade interlinks + // FIXME: commented out until strangederivedbuilder adjusted accordingly + // o2::framework::Produces cascToTraRefs; // cascades -> tracked + // o2::framework::Produces cascToKFRefs; // cascades -> KF + // o2::framework::Produces traToCascRefs; // tracked -> cascades + // o2::framework::Produces kfToCascRefs; // KF -> cascades + + //__________________________________________________ + // Findable tags + o2::framework::Produces v0FoundTag; + o2::framework::Produces cascFoundTag; +}; + +// strangenessBuilder: 1st-order configurables +struct coreConfigurables : o2::framework::ConfigurableGroup { + o2::framework::Configurable> enabledTables{"enabledTables", + {defaultParameters[0], nTables, nParameters, tableNames, parameterNames}, + "Produce this table: -1 for autodetect; otherwise, 0/1 is false/true"}; + std::vector mEnabledTables; // Vector of enabled tables + + // first order deduplication implementation + // more algorithms to be added as necessary + o2::framework::Configurable deduplicationAlgorithm{"deduplicationAlgorithm", 1, "0: disabled; 1: best pointing angle wins; 2: best DCA daughters wins; 3: best pointing and best DCA wins"}; + + // V0 buffer for V0s used in cascades: master switch + // exchanges CPU (generate V0s again) with memory (save pre-generated V0s) + o2::framework::Configurable useV0BufferForCascades{"useV0BufferForCascades", false, "store array of V0s for cascades or not. False (default): save RAM, use more CPU; true: save CPU, use more RAM"}; + + o2::framework::Configurable mc_findableMode{"mc_findableMode", 0, "0: disabled; 1: add findable-but-not-found to existing V0s from AO2D; 2: reset V0s and generate only findable-but-not-found"}; +}; + +// strangenessBuilder: V0 building options +struct v0Configurables : o2::framework::ConfigurableGroup { + std::string prefix = "v0BuilderOpts"; + o2::framework::Configurable generatePhotonCandidates{"generatePhotonCandidates", false, "generate gamma conversion candidates (V0s using TPC-only tracks)"}; + o2::framework::Configurable moveTPCOnlyTracks{"moveTPCOnlyTracks", true, "if dealing with TPC-only tracks, move them according to TPC drift / time info"}; + + // baseline conditionals of V0 building + o2::framework::Configurable minCrossedRows{"minCrossedRows", 50, "minimum TPC crossed rows for daughter tracks"}; + o2::framework::Configurable dcanegtopv{"dcanegtopv", .1, "DCA Neg To PV"}; + o2::framework::Configurable dcapostopv{"dcapostopv", .1, "DCA Pos To PV"}; + o2::framework::Configurable v0cospa{"v0cospa", 0.95, "V0 CosPA"}; // double -> N.B. dcos(x)/dx = 0 at x=0) + o2::framework::Configurable dcav0dau{"dcav0dau", 1.0, "DCA V0 Daughters"}; + o2::framework::Configurable v0radius{"v0radius", 0.9, "v0radius"}; + o2::framework::Configurable maxDaughterEta{"maxDaughterEta", 5.0, "Maximum daughter eta (in abs value)"}; + + // MC builder options + o2::framework::Configurable mc_populateV0MCCoresSymmetric{"mc_populateV0MCCoresSymmetric", false, "populate V0MCCores table for derived data analysis, keep V0MCCores joinable with V0Cores"}; + o2::framework::Configurable mc_populateV0MCCoresAsymmetric{"mc_populateV0MCCoresAsymmetric", true, "populate V0MCCores table for derived data analysis, create V0Cores -> V0MCCores interlink. Saves only labeled V0s."}; + o2::framework::Configurable mc_treatPiToMuDecays{"mc_treatPiToMuDecays", true, "if true, will correctly capture pi -> mu and V0 label will still point to originating V0 decay in those cases. Nota bene: prong info will still be for the muon!"}; + o2::framework::Configurable mc_rapidityWindow{"mc_rapidityWindow", 0.5, "rapidity window to save non-recoed candidates"}; + o2::framework::Configurable mc_keepOnlyPhysicalPrimary{"mc_keepOnlyPhysicalPrimary", false, "Keep only physical primary generated V0s if not recoed"}; + o2::framework::Configurable mc_addGeneratedK0Short{"mc_addGeneratedK0Short", true, "add V0MCCore entry for generated, not-recoed K0Short"}; + o2::framework::Configurable mc_addGeneratedLambda{"mc_addGeneratedLambda", true, "add V0MCCore entry for generated, not-recoed Lambda"}; + o2::framework::Configurable mc_addGeneratedAntiLambda{"mc_addGeneratedAntiLambda", true, "add V0MCCore entry for generated, not-recoed AntiLambda"}; + o2::framework::Configurable mc_addGeneratedGamma{"mc_addGeneratedGamma", false, "add V0MCCore entry for generated, not-recoed Gamma"}; + o2::framework::Configurable mc_addGeneratedGammaMakeCollinear{"mc_addGeneratedGammaMakeCollinear", true, "when adding findable gammas, mark them as collinear"}; + o2::framework::Configurable mc_findableDetachedV0{"mc_findableDetachedV0", false, "if true, generate findable V0s that have collisionId -1. Caution advised."}; +}; + +// strangenessBuilder: cascade building options +struct cascadeConfigurables : o2::framework::ConfigurableGroup { + std::string prefix = "cascadeBuilderOpts"; + o2::framework::Configurable useCascadeMomentumAtPrimVtx{"useCascadeMomentumAtPrimVtx", false, "use cascade momentum at PV"}; + + // conditionals + o2::framework::Configurable minCrossedRows{"minCrossedRows", 50, "minimum TPC crossed rows for daughter tracks"}; + o2::framework::Configurable dcabachtopv{"dcabachtopv", .05, "DCA Bach To PV"}; + o2::framework::Configurable cascradius{"cascradius", 0.9, "cascradius"}; + o2::framework::Configurable casccospa{"casccospa", 0.95, "casccospa"}; + o2::framework::Configurable dcacascdau{"dcacascdau", 1.0, "DCA cascade Daughters"}; + o2::framework::Configurable lambdaMassWindow{"lambdaMassWindow", .010, "Distance from Lambda mass (does not apply to KF path)"}; + o2::framework::Configurable maxDaughterEta{"maxDaughterEta", 5.0, "Maximum daughter eta (in abs value)"}; + + // KF building specific + o2::framework::Configurable kfTuneForOmega{"kfTuneForOmega", false, "if enabled, take main cascade properties from Omega fit instead of Xi fit (= default)"}; + o2::framework::Configurable kfConstructMethod{"kfConstructMethod", 2, "KF Construct Method"}; + o2::framework::Configurable kfUseV0MassConstraint{"kfUseV0MassConstraint", true, "KF: use Lambda mass constraint"}; + o2::framework::Configurable kfUseCascadeMassConstraint{"kfUseCascadeMassConstraint", false, "KF: use Cascade mass constraint - WARNING: not adequate for inv mass analysis of Xi"}; + o2::framework::Configurable kfDoDCAFitterPreMinimV0{"kfDoDCAFitterPreMinimV0", true, "KF: do DCAFitter pre-optimization before KF fit to include material corrections for V0"}; + o2::framework::Configurable kfDoDCAFitterPreMinimCasc{"kfDoDCAFitterPreMinimCasc", true, "KF: do DCAFitter pre-optimization before KF fit to include material corrections for Xi"}; + + // MC builder options + o2::framework::Configurable mc_populateCascMCCoresSymmetric{"mc_populateCascMCCoresSymmetric", false, "populate CascMCCores table for derived data analysis, keep CascMCCores joinable with CascCores"}; + o2::framework::Configurable mc_populateCascMCCoresAsymmetric{"mc_populateCascMCCoresAsymmetric", true, "populate CascMCCores table for derived data analysis, create CascCores -> CascMCCores interlink. Saves only labeled Cascades."}; + o2::framework::Configurable mc_addGeneratedXiMinus{"mc_addGeneratedXiMinus", true, "add CascMCCore entry for generated, not-recoed XiMinus"}; + o2::framework::Configurable mc_addGeneratedXiPlus{"mc_addGeneratedXiPlus", true, "add CascMCCore entry for generated, not-recoed XiPlus"}; + o2::framework::Configurable mc_addGeneratedOmegaMinus{"mc_addGeneratedOmegaMinus", true, "add CascMCCore entry for generated, not-recoed OmegaMinus"}; + o2::framework::Configurable mc_addGeneratedOmegaPlus{"mc_addGeneratedOmegaPlus", true, "add CascMCCore entry for generated, not-recoed OmegaPlus"}; + o2::framework::Configurable mc_treatPiToMuDecays{"mc_treatPiToMuDecays", true, "if true, will correctly capture pi -> mu and V0 label will still point to originating V0 decay in those cases. Nota bene: prong info will still be for the muon!"}; + o2::framework::Configurable mc_rapidityWindow{"mc_rapidityWindow", 0.5, "rapidity window to save non-recoed candidates"}; + o2::framework::Configurable mc_keepOnlyPhysicalPrimary{"mc_keepOnlyPhysicalPrimary", false, "Keep only physical primary generated cascades if not recoed"}; + o2::framework::Configurable mc_findableDetachedCascade{"mc_findableDetachedCascade", false, "if true, generate findable cascades that have collisionId -1. Caution advised."}; +}; + +// preselection options +struct preSelectOpts : o2::framework::ConfigurableGroup { + std::string prefix = "preSelectOpts"; + o2::framework::Configurable preselectOnlyDesiredV0s{"preselectOnlyDesiredV0s", false, "preselect only V0s with compatible TPC PID and mass info"}; + o2::framework::Configurable preselectOnlyDesiredCascades{"preselectOnlyDesiredCascades", false, "preselect only Cascades with compatible TPC PID and mass info"}; + + // lifetime preselection options + // apply lifetime cuts to V0 and cascade candidates + // unit of measurement: centimeters + // lifetime of K0Short ~2.6844 cm, no feeddown and plenty to cut + // lifetime of Lambda ~7.9 cm but keep in mind feeddown from cascades + // lifetime of Xi ~4.91 cm + // lifetime of Omega ~2.461 cm + o2::framework::Configurable> lifetimeCut{"lifetimeCut", {defaultLifetimeCuts[0], 4, {"lifetimeCutK0S", "lifetimeCutLambda", "lifetimeCutXi", "lifetimeCutOmega"}}, "Lifetime cut for V0s and cascades (cm)"}; + + // mass preselection options + o2::framework::Configurable massCutPhoton{"massCutPhoton", 0.3, "Photon max mass"}; + o2::framework::Configurable> massCutK0{"massCutK0", {defaultK0MassWindowParameters[0], 4, {"constant", "linear", "expoConstant", "expoRelax"}}, "mass parameters for K0"}; + o2::framework::Configurable> massCutLambda{"massCutLambda", {defaultLambdaWindowParameters[0], 4, {"constant", "linear", "expoConstant", "expoRelax"}}, "mass parameters for Lambda"}; + o2::framework::Configurable> massCutXi{"massCutXi", {defaultXiMassWindowParameters[0], 4, {"constant", "linear", "expoConstant", "expoRelax"}}, "mass parameters for Xi"}; + o2::framework::Configurable> massCutOm{"massCutOm", {defaultOmMassWindowParameters[0], 4, {"constant", "linear", "expoConstant", "expoRelax"}}, "mass parameters for Omega"}; + o2::framework::Configurable massWindownumberOfSigmas{"massWindownumberOfSigmas", 20, "number of sigmas around mass peaks to keep"}; + o2::framework::Configurable massWindowSafetyMargin{"massWindowSafetyMargin", 0.001, "Extra mass window safety margin (in GeV/c2)"}; + + // TPC PID preselection options + o2::framework::Configurable maxTPCpidNsigma{"maxTPCpidNsigma", 5.0, "Maximum TPC PID N sigma (in abs value)"}; +}; + +class BuilderModule +{ + public: + BuilderModule() + { + // constructor + } + + // mass windows + float getMassSigmaK0Short(float pt) + { + return preSelectOpts.massCutK0->get("constant") + pt * preSelectOpts.massCutK0->get("linear") + preSelectOpts.massCutK0->get("expoConstant") * TMath::Exp(-pt / preSelectOpts.massCutK0->get("expoRelax")); + } + float getMassSigmaLambda(float pt) + { + return preSelectOpts.massCutLambda->get("constant") + pt * preSelectOpts.massCutLambda->get("linear") + preSelectOpts.massCutLambda->get("expoConstant") * TMath::Exp(-pt / preSelectOpts.massCutLambda->get("expoRelax")); + } + float getMassSigmaXi(float pt) + { + return preSelectOpts.massCutXi->get("constant") + pt * preSelectOpts.massCutXi->get("linear") + preSelectOpts.massCutXi->get("expoConstant") * TMath::Exp(-pt / preSelectOpts.massCutXi->get("expoRelax")); + } + float getMassSigmaOmega(float pt) + { + return preSelectOpts.massCutOm->get("constant") + pt * preSelectOpts.massCutOm->get("linear") + preSelectOpts.massCutOm->get("expoConstant") * TMath::Exp(-pt / preSelectOpts.massCutOm->get("expoRelax")); + } + + int nEnabledTables = 0; + + // helper object + o2::pwglf::strangenessBuilderHelper straHelper; + + // for handling TPC-only tracks (photons) + int mRunNumber; + o2::aod::common::TPCVDriftManager mVDriftMgr; + + // for establishing CascData/KFData/TraCascData interlinks + struct { + std::vector cascCoreToCascades; + std::vector kfCascCoreToCascades; + std::vector traCascCoreToCascades; + std::vector cascadeToCascCores; + std::vector cascadeToKFCascCores; + std::vector cascadeToTraCascCores; + } interlinks; + + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + // struct to add abstraction layer between V0s, Cascades and build indices + // desirable for adding extra (findable, etc) V0s, Cascades to built list + struct trackEntry { + int globalId = -1; + int originId = -1; + int mcCollisionId = -1; + int pdgCode = -1; + }; + struct v0Entry { + int globalId = -1; + int collisionId = -1; + int posTrackId = -1; + int negTrackId = -1; + int v0Type = 0; + int pdgCode = 0; // undefined if not MC - useful for faster finding + int particleId = -1; // de-reference the V0 particle if necessary + bool isCollinearV0 = false; + bool found = false; + }; + struct cascadeEntry { + int globalId = -1; + int collisionId = -1; + int v0Id = -1; + int posTrackId = -1; + int negTrackId = -1; + int bachTrackId = -1; + bool found = false; + }; + + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + // Helper struct to contain V0MCCore information prior to filling + struct mcV0info { + int label = -1; + int motherLabel = -1; + int pdgCode = 0; + int pdgCodeMother = 0; + int pdgCodePositive = 0; + int pdgCodeNegative = 0; + int mcCollision = -1; + bool isPhysicalPrimary = false; + int processPositive = -1; + int processNegative = -1; + std::array xyz; + std::array posP; + std::array negP; + std::array momentum; + }; + mcV0info thisInfo; + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + // Helper struct to contain CascMCCore information prior to filling + struct mcCascinfo { + int label; + int motherLabel; + int mcCollision; + int pdgCode; + int pdgCodeMother; + int pdgCodeV0; + int pdgCodePositive; + int pdgCodeNegative; + int pdgCodeBachelor; + bool isPhysicalPrimary; + int processPositive = -1; + int processNegative = -1; + int processBachelor = -1; + std::array xyz; + std::array lxyz; + std::array posP; + std::array negP; + std::array bachP; + std::array momentum; + int mcParticlePositive; + int mcParticleNegative; + int mcParticleBachelor; + }; + mcCascinfo thisCascInfo; + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + + std::vector v0List; + std::vector cascadeList; + std::vector sorted_v0; + std::vector sorted_cascade; + + // for tagging V0s used in cascades + std::vector v0sFromCascades; // Vector of v0 candidates used in cascades + std::vector ao2dV0toV0List; // index to relate v0s -> v0List + std::vector v0Map; // index to relate v0List -> v0sFromCascades + + // declaration of structs here + // (N.B.: will be invisible to the outside, create your own copies) + o2::pwglf::strangenessbuilder::coreConfigurables baseOpts; + o2::pwglf::strangenessbuilder::v0Configurables v0BuilderOpts; + o2::pwglf::strangenessbuilder::cascadeConfigurables cascadeBuilderOpts; + o2::pwglf::strangenessbuilder::preSelectOpts preSelectOpts; + + template + void init(TBaseConfigurables const& inputBaseOpts, TV0Configurables const& inputV0BuilderOpts, TCascadeConfigurables const& inputCascadeBuilderOpts, TPreSelOpts const& inputPreSelectOpts, THistoRegistry& histos, TInitContext& context) + { + // read in configurations from the task where it's used + // could be grouped even further, but should work + baseOpts = inputBaseOpts; + v0BuilderOpts = inputV0BuilderOpts; + cascadeBuilderOpts = inputCascadeBuilderOpts; + preSelectOpts = inputPreSelectOpts; + + baseOpts.mEnabledTables.resize(nTables, 0); + + LOGF(info, "Checking if strangeness building is required"); + auto& workflows = context.services().template get(); + + nEnabledTables = 0; + + TString listOfRequestors[nTables]; + for (int i = 0; i < nTables; i++) { + int f = baseOpts.enabledTables->get(tableNames[i].c_str(), "enable"); + if (f == 1) { + baseOpts.mEnabledTables[i] = 1; + listOfRequestors[i] = "manual enabling"; + } + if (f == -1) { + // autodetect this table in other devices + for (o2::framework::DeviceSpec const& device : workflows.devices) { + // Step 1: check if this device subscribed to the V0data table + for (auto const& input : device.inputs) { + if (o2::framework::DataSpecUtils::partialMatch(input.matcher, o2::header::DataOrigin("AOD"))) { + auto&& [origin, description, version] = o2::framework::DataSpecUtils::asConcreteDataMatcher(input.matcher); + std::string tableNameWithVersion = tableNames[i]; + if (version > 0) { + tableNameWithVersion += Form("_%03d", version); + } + if (input.matcher.binding == tableNameWithVersion) { + LOGF(info, "Device %s has subscribed to %s (version %i)", device.name, tableNames[i], version); + listOfRequestors[i].Append(Form("%s ", device.name.c_str())); + baseOpts.mEnabledTables[i] = 1; + nEnabledTables++; + } + } + } + } + } + } + + if (nEnabledTables == 0) { + LOGF(info, "Strangeness building not required. Will suppress all functionality, including logs, from this point forward."); + return; + } + + // setup bookkeeping histogram + auto h = histos.template add("hTableBuildingStatistics", "hTableBuildingStatistics", o2::framework::kTH1D, {{nTablesConst, -0.5f, static_cast(nTablesConst)}}); + auto h2 = histos.template add("hInputStatistics", "hInputStatistics", o2::framework::kTH1D, {{nTablesConst, -0.5f, static_cast(nTablesConst)}}); + h2->SetTitle("Input table sizes"); + + if (v0BuilderOpts.generatePhotonCandidates.value == true) { + auto hDeduplicationStatistics = histos.template add("hDeduplicationStatistics", "hDeduplicationStatistics", o2::framework::kTH1D, {{2, -0.5f, 1.5f}}); + hDeduplicationStatistics->GetXaxis()->SetBinLabel(1, "AO2D V0s"); + hDeduplicationStatistics->GetXaxis()->SetBinLabel(2, "Deduplicated V0s"); + } + + if (preSelectOpts.preselectOnlyDesiredV0s.value == true) { + auto hPreselectionV0s = histos.template add("hPreselectionV0s", "hPreselectionV0s", o2::framework::kTH1D, {{16, -0.5f, 15.5f}}); + hPreselectionV0s->GetXaxis()->SetBinLabel(1, "Not preselected"); + hPreselectionV0s->GetXaxis()->SetBinLabel(2, "#gamma"); + hPreselectionV0s->GetXaxis()->SetBinLabel(3, "K^{0}_{S}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(4, "#gamma, K^{0}_{S}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(5, "#Lambda"); + hPreselectionV0s->GetXaxis()->SetBinLabel(6, "#gamma, #Lambda"); + hPreselectionV0s->GetXaxis()->SetBinLabel(7, "K^{0}_{S}, #Lambda"); + hPreselectionV0s->GetXaxis()->SetBinLabel(8, "#gamma, K^{0}_{S}, #Lambda"); + hPreselectionV0s->GetXaxis()->SetBinLabel(9, "#bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(10, "#gamma, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(11, "K^{0}_{S}, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(12, "#gamma, K^{0}_{S}, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(13, "#Lambda, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(14, "#gamma, #Lambda, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(15, "K^{0}_{S}, #Lambda, #bar{#Lambda}"); + hPreselectionV0s->GetXaxis()->SetBinLabel(16, "#gamma, K^{0}_{S}, #Lambda, #bar{#Lambda}"); + } + + if (preSelectOpts.preselectOnlyDesiredCascades.value == true) { + auto hPreselectionCascades = histos.template add("hPreselectionCascades", "hPreselectionCascades", o2::framework::kTH1D, {{16, -0.5f, 15.5f}}); + hPreselectionCascades->GetXaxis()->SetBinLabel(1, "Not preselected"); + hPreselectionCascades->GetXaxis()->SetBinLabel(2, "#Xi^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(3, "#Xi^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(4, "#Xi^{-}, #Xi^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(5, "#Omega^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(6, "#Xi^{-}, #Omega^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(7, "#Xi^{+}, #Omega^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(8, "#Xi^{-}, #Xi^{+}, #Omega^{-}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(9, "#Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(10, "#Xi^{-}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(11, "#Xi^{+}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(12, "#Xi^{-}, #Xi^{+}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(13, "#Omega^{-}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(14, "#Xi^{-}, #Omega^{-}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(15, "#Xi^{+}, #Omega^{-}, #Omega^{+}"); + hPreselectionCascades->GetXaxis()->SetBinLabel(16, "#Xi^{-}, #Xi^{+}, #Omega^{-}, #Omega^{+}"); + } + + if (baseOpts.mc_findableMode.value > 0) { + // save statistics of findable candidate processing + auto hFindable = histos.template add("hFindableStatistics", "hFindableStatistics", o2::framework::kTH1D, {{6, -0.5f, 5.5f}}); + hFindable->SetTitle(Form("Findable mode: %i", static_cast(baseOpts.mc_findableMode.value))); + hFindable->GetXaxis()->SetBinLabel(1, "AO2D V0s"); + hFindable->GetXaxis()->SetBinLabel(2, "V0s to be built"); + hFindable->GetXaxis()->SetBinLabel(3, "V0s with collId -1"); + hFindable->GetXaxis()->SetBinLabel(4, "AO2D Cascades"); + hFindable->GetXaxis()->SetBinLabel(5, "Cascades to be built"); + hFindable->GetXaxis()->SetBinLabel(6, "Cascades with collId -1"); + } + + auto hPrimaryV0s = histos.template add("hPrimaryV0s", "hPrimaryV0s", o2::framework::kTH1D, {{2, -0.5f, 1.5f}}); + hPrimaryV0s->GetXaxis()->SetBinLabel(1, "All V0s"); + hPrimaryV0s->GetXaxis()->SetBinLabel(2, "Primary V0s"); + + mRunNumber = 0; + + for (int i = 0; i < nTables; i++) { + // adjust bookkeeping histogram + h->GetXaxis()->SetBinLabel(i + 1, tableNames[i].c_str()); + h2->GetXaxis()->SetBinLabel(i + 1, tableNames[i].c_str()); + if (baseOpts.mEnabledTables[i] == false) { + h->SetBinContent(i + 1, -1); // mark disabled tables, distinguish from zero counts + } + } + + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + LOGF(info, " Strangeness builder: basic configuration listing"); + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + + if (baseOpts.mc_findableMode.value == 1) { + LOGF(info, " ===> findable mode 1 is enabled: complement reco-ed with non-found findable"); + } + if (baseOpts.mc_findableMode.value == 2) { + LOGF(info, " ===> findable mode 2 is enabled: re-generate all findable from scratch"); + } + + // list enabled tables + + for (int i = 0; i < nTables; i++) { + // printout to be improved in the future + if (baseOpts.mEnabledTables[i]) { + LOGF(info, " -~> Table enabled: %s, requested by %s", tableNames[i], listOfRequestors[i].Data()); + h->SetBinContent(i + 1, 0); // mark enabled + } + } + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + // print base cuts + LOGF(info, "-~> V0 | min crossed rows ..............: %i", v0BuilderOpts.minCrossedRows.value); + LOGF(info, "-~> V0 | DCA pos track to PV ...........: %f", v0BuilderOpts.dcapostopv.value); + LOGF(info, "-~> V0 | DCA neg track to PV ...........: %f", v0BuilderOpts.dcanegtopv.value); + LOGF(info, "-~> V0 | V0 cosine of PA ...............: %f", v0BuilderOpts.v0cospa.value); + LOGF(info, "-~> V0 | DCA between V0 daughters ......: %f", v0BuilderOpts.dcav0dau.value); + LOGF(info, "-~> V0 | V0 2D decay radius ............: %f", v0BuilderOpts.v0radius.value); + LOGF(info, "-~> V0 | Maximum daughter eta ..........: %f", v0BuilderOpts.maxDaughterEta.value); + + LOGF(info, "-~> Cascade | min crossed rows .........: %i", cascadeBuilderOpts.minCrossedRows.value); + LOGF(info, "-~> Cascade | DCA bach track to PV .....: %f", cascadeBuilderOpts.dcabachtopv.value); + LOGF(info, "-~> Cascade | Cascade cosine of PA .....: %f", cascadeBuilderOpts.casccospa.value); + LOGF(info, "-~> Cascade | Cascade daughter DCA .....: %f", cascadeBuilderOpts.dcacascdau.value); + LOGF(info, "-~> Cascade | Cascade radius ...........: %f", cascadeBuilderOpts.cascradius.value); + LOGF(info, "-~> Cascade | Lambda mass window .......: %f", cascadeBuilderOpts.lambdaMassWindow.value); + LOGF(info, "-~> Cascade | Maximum daughter eta .....: %f", cascadeBuilderOpts.maxDaughterEta.value); + LOGF(info, "*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*"); + + // set V0 parameters in the helper + straHelper.v0selections.minCrossedRows = v0BuilderOpts.minCrossedRows; + straHelper.v0selections.dcanegtopv = v0BuilderOpts.dcanegtopv; + straHelper.v0selections.dcapostopv = v0BuilderOpts.dcapostopv; + straHelper.v0selections.v0cospa = v0BuilderOpts.v0cospa; + straHelper.v0selections.dcav0dau = v0BuilderOpts.dcav0dau; + straHelper.v0selections.v0radius = v0BuilderOpts.v0radius; + straHelper.v0selections.maxDaughterEta = v0BuilderOpts.maxDaughterEta; + + // set cascade parameters in the helper + straHelper.cascadeselections.minCrossedRows = cascadeBuilderOpts.minCrossedRows; + straHelper.cascadeselections.dcabachtopv = cascadeBuilderOpts.dcabachtopv; + straHelper.cascadeselections.cascradius = cascadeBuilderOpts.cascradius; + straHelper.cascadeselections.casccospa = cascadeBuilderOpts.casccospa; + straHelper.cascadeselections.dcacascdau = cascadeBuilderOpts.dcacascdau; + straHelper.cascadeselections.lambdaMassWindow = cascadeBuilderOpts.lambdaMassWindow; + straHelper.cascadeselections.maxDaughterEta = cascadeBuilderOpts.maxDaughterEta; + } + + // for sorting + template + std::vector sort_indices(const std::vector& v, bool doSorting = false) + { + std::vector idx(v.size()); + std::iota(idx.begin(), idx.end(), 0); + if (doSorting) { + // do sorting only if requested (not always necessary) + std::stable_sort(idx.begin(), idx.end(), + [&v](std::size_t i1, std::size_t i2) { return v[i1].collisionId < v[i2].collisionId; }); + } + return idx; + } + + template + bool initCCDB(TCCDB& ccdb, aod::BCsWithTimestamps const& bcs, TCollisions const& collisions) + { + auto bc = collisions.size() ? collisions.begin().template bc_as() : bcs.begin(); + if (!bcs.size()) { + LOGF(warn, "No BC found, skipping this DF."); + return false; // signal to skip this DF + } + + if (mRunNumber == bc.runNumber()) { + return true; + } + + auto timestamp = bc.timestamp(); + + // Fetch magnetic field from ccdb for current collision + auto magneticField = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Configuring for timestamp " << timestamp << " with magnetic field of " << magneticField << " kG"; + + // Set magnetic field value once known + straHelper.fitter.setBz(magneticField); + + LOG(info) << "Fully configured for run: " << bc.runNumber(); + // mmark this run as configured + mRunNumber = bc.runNumber(); + + if (v0BuilderOpts.generatePhotonCandidates.value && v0BuilderOpts.moveTPCOnlyTracks.value) { + // initialize only if needed, avoid unnecessary CCDB calls + mVDriftMgr.init(&ccdb->instance()); + mVDriftMgr.update(timestamp); + } + + return true; + } + + //__________________________________________________ + void resetInterlinks() + { + interlinks.cascCoreToCascades.clear(); + interlinks.kfCascCoreToCascades.clear(); + interlinks.traCascCoreToCascades.clear(); + interlinks.cascadeToCascCores.clear(); + interlinks.cascadeToKFCascCores.clear(); + interlinks.cascadeToTraCascCores.clear(); + } + + //__________________________________________________ + void populateCascadeInterlinks() + { + // if (mEnabledTables[kCascToKFRefs]) { + // for (const auto& cascCore : interlinks.cascCoreToCascades) { + // cascToKFRefs(interlinks.cascadeToKFCascCores[cascCore]); + // histos.fill(HIST("hTableBuildingStatistics"), kCascToKFRefs); + // } + // } + // if (mEnabledTables[kCascToTraRefs]) { + // for (const auto& cascCore : interlinks.cascCoreToCascades) { + // cascToTraRefs(interlinks.cascadeToTraCascCores[cascCore]); + // histos.fill(HIST("hTableBuildingStatistics"), kCascToTraRefs); + // } + // } + // if (mEnabledTables[kKFToCascRefs]) { + // for (const auto& kfCascCore : interlinks.kfCascCoreToCascades) { + // kfToCascRefs(interlinks.cascadeToCascCores[kfCascCore]); + // histos.fill(HIST("hTableBuildingStatistics"), kKFToCascRefs); + // } + // } + // if (mEnabledTables[kTraToCascRefs]) { + // for (const auto& traCascCore : interlinks.traCascCoreToCascades) { + // traToCascRefs(interlinks.cascadeToCascCores[traCascCore]); + // histos.fill(HIST("hTableBuildingStatistics"), kTraToCascRefs); + // } + // } + } + + //__________________________________________________ + template + void prepareBuildingLists(THistoRegistry& histos, TCollisions const& collisions, TMCCollisions const& mcCollisions, TV0s const& v0s, TCascades const& cascades, TTracks const& tracks, TMCParticles const& mcParticles) + { + // this function prepares the v0List and cascadeList depending on + // how the task has been set up. Standard operation simply uses + // the existing V0s and Cascades from AO2D, while findable MC + // operation either complements with all findable-but-not-found + // or resets and fills with all findable. + // + // Whenever using findable candidates, they will be appropriately + // marked for posterior analysis using 'tag' variables. + // + // findable mode legend: + // 0: simple passthrough of V0s, Cascades in AO2Ds + // (in data, this is the only mode possible!) + // 1: add extra findable that haven't been found + // 2: generate only findable (no background) + + // redo lists from scratch + v0List.clear(); + cascadeList.clear(); + sorted_v0.clear(); + sorted_cascade.clear(); + ao2dV0toV0List.clear(); + + trackEntry currentTrackEntry; + v0Entry currentV0Entry; + cascadeEntry currentCascadeEntry; + + std::vector bestCollisionArray; // stores McCollision -> Collision map + std::vector bestCollisionNContribsArray; // stores Ncontribs for biggest coll assoc to mccoll + + int collisionLessV0s = 0; + int collisionLessCascades = 0; + + if (baseOpts.mc_findableMode.value > 0) { + if constexpr (soa::is_table) { + // if mcCollisions exist, assemble mcColl -> bestRecoColl map here + bestCollisionArray.clear(); + bestCollisionNContribsArray.clear(); + bestCollisionArray.resize(mcCollisions.size(), -1); // marks not reconstructed + bestCollisionNContribsArray.resize(mcCollisions.size(), -1); // marks not reconstructed + + // single loop over double loop at a small cost in memory for extra array + for (const auto& collision : collisions) { + if (collision.has_mcCollision()) { + if (collision.numContrib() > bestCollisionNContribsArray[collision.mcCollisionId()]) { + bestCollisionArray[collision.mcCollisionId()] = collision.globalIndex(); + bestCollisionNContribsArray[collision.mcCollisionId()] = collision.numContrib(); + } + } + } // end collision loop + } // end is_table + } // end findable mode check + + if (baseOpts.mc_findableMode.value < 2) { + // keep all unless de-duplication active + ao2dV0toV0List.resize(v0s.size(), -1); // -1 means keep, -2 means do not keep + + if (baseOpts.deduplicationAlgorithm > 0 && v0BuilderOpts.generatePhotonCandidates) { + // handle duplicates explicitly: group V0s according to (p,n) indices + // will provide a list of collisionIds (in V0group), allowing for + // easy de-duplication when passing to the v0List + std::vector v0tableGrouped = o2::pwglf::groupDuplicates(v0s); + histos.fill(HIST("hDeduplicationStatistics"), 0.0, v0s.size()); + histos.fill(HIST("hDeduplicationStatistics"), 1.0, v0tableGrouped.size()); + + // process grouped duplicates, remove 'bad' ones + for (size_t iV0 = 0; iV0 < v0tableGrouped.size(); iV0++) { + auto pTrack = tracks.rawIteratorAt(v0tableGrouped[iV0].posTrackId); + auto nTrack = tracks.rawIteratorAt(v0tableGrouped[iV0].negTrackId); + + bool isPosTPCOnly = (pTrack.hasTPC() && !pTrack.hasITS() && !pTrack.hasTRD() && !pTrack.hasTOF()); + bool isNegTPCOnly = (nTrack.hasTPC() && !nTrack.hasITS() && !nTrack.hasTRD() && !nTrack.hasTOF()); + + // skip single copy V0s + if (v0tableGrouped[iV0].collisionIds.size() == 1) { + continue; + } + + // don't try to de-duplicate if no track is TPC only + if (!isPosTPCOnly && !isNegTPCOnly) { + continue; + } + + // fitness criteria defined here + float bestPointingAngle = 10; // a nonsense angle, anything's better + size_t bestPointingAngleIndex = -1; + + float bestDCADaughters = 1e+3; // an excessively large DCA + size_t bestDCADaughtersIndex = -1; + + for (size_t ic = 0; ic < v0tableGrouped[iV0].collisionIds.size(); ic++) { + // get track parametrizations, collisions + auto posTrackPar = getTrackParCov(pTrack); + auto negTrackPar = getTrackParCov(nTrack); + auto const& collision = collisions.rawIteratorAt(v0tableGrouped[iV0].collisionIds[ic]); + + // handle TPC-only tracks properly (photon conversions) + if (v0BuilderOpts.moveTPCOnlyTracks) { + if (isPosTPCOnly) { + // Nota bene: positive is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + if (!mVDriftMgr.moveTPCTrack(collision, pTrack, posTrackPar)) { + continue; + } + } + if (isNegTPCOnly) { + // Nota bene: negative is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + if (!mVDriftMgr.moveTPCTrack(collision, nTrack, negTrackPar)) { + continue; + } + } + } // end TPC drift treatment + + // process candidate with helper, generate properties for consulting + // : do not apply selections: do as much as possible to preserve + // candidate at this level and do not select with topo selections + if (straHelper.buildV0Candidate(v0tableGrouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false, true)) { + // candidate built, check pointing angle + if (straHelper.v0.pointingAngle < bestPointingAngle) { + bestPointingAngle = straHelper.v0.pointingAngle; + bestPointingAngleIndex = ic; + } + if (straHelper.v0.daughterDCA < bestDCADaughters) { + bestDCADaughters = straHelper.v0.daughterDCA; + bestDCADaughtersIndex = ic; + } + } // end build V0 + } // end candidate loop + + // mark de-duplicated candidates + for (size_t ic = 0; ic < v0tableGrouped[iV0].collisionIds.size(); ic++) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -2; + // algorithm 1: best pointing angle + if (bestPointingAngleIndex == ic && baseOpts.deduplicationAlgorithm.value == 1) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -1; // keep best only + } + if (bestDCADaughtersIndex == ic && baseOpts.deduplicationAlgorithm.value == 2) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -1; // keep best only + } + if (bestDCADaughtersIndex == ic && bestPointingAngleIndex == ic && baseOpts.deduplicationAlgorithm.value == 3) { + ao2dV0toV0List[v0tableGrouped[iV0].V0Ids[ic]] = -1; // keep best only + } + } + } // end V0 loop + } // end de-duplication process + + for (const auto& v0 : v0s) { + if (ao2dV0toV0List[v0.globalIndex()] == -1) { // keep only de-duplicated + ao2dV0toV0List[v0.globalIndex()] = v0List.size(); // maps V0s to the corresponding v0List entry + currentV0Entry.globalId = v0.globalIndex(); + currentV0Entry.collisionId = v0.collisionId(); + currentV0Entry.posTrackId = v0.posTrackId(); + currentV0Entry.negTrackId = v0.negTrackId(); + currentV0Entry.v0Type = v0.v0Type(); + currentV0Entry.pdgCode = 0; + currentV0Entry.particleId = -1; + currentV0Entry.isCollinearV0 = v0.isCollinearV0(); + currentV0Entry.found = true; + v0List.push_back(currentV0Entry); + } + } + } + // any mode other than 0 will require mcParticles + if constexpr (soa::is_table) { + if (baseOpts.mc_findableMode.value > 0) { + // for search if existing or not + int v0ListReconstructedSize = v0List.size(); + + // find extra candidates, step 1: find subset of tracks that interest + std::vector positiveTrackArray; + std::vector negativeTrackArray; + // vector elements: track index, origin index [, mc collision id, pdg code] + int dummy = -1; // unnecessary in this path + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; // skip this, it's trouble + } + auto particle = track.template mcParticle_as(); + int originParticleIndex = getOriginatingParticle(particle, dummy, v0BuilderOpts.mc_treatPiToMuDecays); + if (originParticleIndex < 0) { + continue; // skip this, it's trouble (2) + } + auto originParticle = mcParticles.rawIteratorAt(originParticleIndex); + + bool trackIsInteresting = false; + if ( + (originParticle.pdgCode() == 310 && v0BuilderOpts.mc_addGeneratedK0Short.value > 0) || + (originParticle.pdgCode() == 3122 && v0BuilderOpts.mc_addGeneratedLambda.value > 0) || + (originParticle.pdgCode() == -3122 && v0BuilderOpts.mc_addGeneratedAntiLambda.value > 0) || + (originParticle.pdgCode() == 22 && v0BuilderOpts.mc_addGeneratedGamma.value > 0)) { + trackIsInteresting = true; + } + if (!trackIsInteresting) { + continue; // skip this, it's uninteresting + } + + currentTrackEntry.globalId = static_cast(track.globalIndex()); + currentTrackEntry.originId = originParticleIndex; + currentTrackEntry.mcCollisionId = originParticle.mcCollisionId(); + currentTrackEntry.pdgCode = originParticle.pdgCode(); + + // now separate according to particle species + if (track.sign() < 0) { + negativeTrackArray.push_back(currentTrackEntry); + } else { + positiveTrackArray.push_back(currentTrackEntry); + } + } + + // Nested loop only with valuable tracks + for (const auto& positiveTrackIndex : positiveTrackArray) { + for (const auto& negativeTrackIndex : negativeTrackArray) { + if (positiveTrackIndex.originId != negativeTrackIndex.originId) { + continue; // not the same originating particle + } + // findable mode 1: add non-reconstructed as v0Type 8 + if (baseOpts.mc_findableMode.value == 1) { + bool detected = false; + for (int ii = 0; ii < v0ListReconstructedSize; ii++) { + // check if this particular combination already exists in v0List + if (v0List[ii].posTrackId == positiveTrackIndex.globalId && + v0List[ii].negTrackId == negativeTrackIndex.globalId) { + detected = true; + // override pdg code with something useful for cascade findable math + v0List[ii].pdgCode = positiveTrackIndex.pdgCode; + break; + } + } + if (detected == false) { + // collision index: from best-version-of-this-mcCollision + // nota bene: this could be negative, caution advised + currentV0Entry.globalId = -1; + currentV0Entry.collisionId = bestCollisionArray[positiveTrackIndex.mcCollisionId]; + currentV0Entry.posTrackId = positiveTrackIndex.globalId; + currentV0Entry.negTrackId = negativeTrackIndex.globalId; + currentV0Entry.v0Type = 1; + currentV0Entry.pdgCode = positiveTrackIndex.pdgCode; + currentV0Entry.particleId = positiveTrackIndex.originId; + currentV0Entry.isCollinearV0 = false; + if (v0BuilderOpts.mc_addGeneratedGammaMakeCollinear.value && currentV0Entry.pdgCode == 22) { + currentV0Entry.isCollinearV0 = true; + } + currentV0Entry.found = false; + if (bestCollisionArray[positiveTrackIndex.mcCollisionId] < 0) { + collisionLessV0s++; + } + if (v0BuilderOpts.mc_findableDetachedV0.value || currentV0Entry.collisionId >= 0) { + v0List.push_back(currentV0Entry); + } + } + } + // findable mode 2 + if (baseOpts.mc_findableMode.value == 2) { + currentV0Entry.globalId = -1; + currentV0Entry.collisionId = bestCollisionArray[positiveTrackIndex.mcCollisionId]; + currentV0Entry.posTrackId = positiveTrackIndex.globalId; + currentV0Entry.negTrackId = negativeTrackIndex.globalId; + currentV0Entry.v0Type = 1; + currentV0Entry.pdgCode = positiveTrackIndex.pdgCode; + currentV0Entry.particleId = positiveTrackIndex.originId; + currentV0Entry.isCollinearV0 = false; + if (v0BuilderOpts.mc_addGeneratedGammaMakeCollinear.value && currentV0Entry.pdgCode == 22) { + currentV0Entry.isCollinearV0 = true; + } + currentV0Entry.found = false; + for (const auto& v0 : v0s) { + if (v0.posTrackId() == positiveTrackIndex.globalId && + v0.negTrackId() == negativeTrackIndex.globalId) { + // this will override type, but not collision index + // N.B.: collision index checks still desirable! + currentV0Entry.globalId = v0.globalIndex(); + currentV0Entry.v0Type = v0.v0Type(); + currentV0Entry.isCollinearV0 = v0.isCollinearV0(); + currentV0Entry.found = true; + break; + } + } + if (v0BuilderOpts.mc_findableDetachedV0.value || currentV0Entry.collisionId >= 0) { + v0List.push_back(currentV0Entry); + } + } + } + } // end positive / negative track loops + + // fill findable statistics table + histos.fill(HIST("hFindableStatistics"), 0.0, v0s.size()); + histos.fill(HIST("hFindableStatistics"), 1.0, v0List.size()); + histos.fill(HIST("hFindableStatistics"), 2.0, collisionLessV0s); + + } // end findableMode > 0 check + } // end soa::is_table + + // determine properly collision-id-sorted index array for later use + // N.B.: necessary also before cascade part + sorted_v0.clear(); + sorted_v0 = sort_indices(v0List, (baseOpts.mc_findableMode.value > 0)); + + // Cascade part if cores are requested, skip otherwise + if (baseOpts.mEnabledTables[kStoredCascCores] || baseOpts.mEnabledTables[kStoredKFCascCores]) { + if (baseOpts.mc_findableMode.value < 2) { + // simple passthrough: copy existing cascades to build list + for (const auto& cascade : cascades) { + auto const& v0 = cascade.v0(); + currentCascadeEntry.globalId = cascade.globalIndex(); + currentCascadeEntry.collisionId = cascade.collisionId(); + currentCascadeEntry.v0Id = ao2dV0toV0List[v0.globalIndex()]; + currentCascadeEntry.posTrackId = v0.posTrackId(); + currentCascadeEntry.negTrackId = v0.negTrackId(); + currentCascadeEntry.bachTrackId = cascade.bachelorId(); + currentCascadeEntry.found = true; + cascadeList.push_back(currentCascadeEntry); + } + } + + // any mode other than 0 will require mcParticles + if constexpr (soa::is_table) { + if (baseOpts.mc_findableMode.value > 0) { + // for search if existing or not + size_t cascadeListReconstructedSize = cascadeList.size(); + + // determine which tracks are of interest + std::vector bachelorTrackArray; + // vector elements: track index, origin index, mc collision id, pdg code] + int dummy = -1; // unnecessary in this path + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; // skip this, it's trouble + } + auto particle = track.template mcParticle_as(); + int originParticleIndex = getOriginatingParticle(particle, dummy, cascadeBuilderOpts.mc_treatPiToMuDecays); + if (originParticleIndex < 0) { + continue; // skip this, it's trouble (2) + } + auto originParticle = mcParticles.rawIteratorAt(originParticleIndex); + + bool trackIsInteresting = false; + if ( + (originParticle.pdgCode() == 3312 && cascadeBuilderOpts.mc_addGeneratedXiMinus.value > 0) || + (originParticle.pdgCode() == -3312 && cascadeBuilderOpts.mc_addGeneratedXiPlus.value > 0) || + (originParticle.pdgCode() == 3334 && cascadeBuilderOpts.mc_addGeneratedOmegaMinus.value > 0) || + (originParticle.pdgCode() == -3334 && cascadeBuilderOpts.mc_addGeneratedOmegaPlus.value > 0)) { + trackIsInteresting = true; + } + if (!trackIsInteresting) { + continue; // skip this, it's uninteresting + } + + currentTrackEntry.globalId = static_cast(track.globalIndex()); + currentTrackEntry.originId = originParticleIndex; + currentTrackEntry.mcCollisionId = originParticle.mcCollisionId(); + currentTrackEntry.pdgCode = originParticle.pdgCode(); + + // populate list of bachelor tracks to pair + bachelorTrackArray.push_back(currentTrackEntry); + } + + // determine which V0s are of interest to pair and do pairing + for (size_t v0i = 0; v0i < v0List.size(); v0i++) { + auto v0 = v0List[sorted_v0[v0i]]; + + if (std::abs(v0.pdgCode) != 3122) { + continue; // this V0 isn't a lambda, can't come from a cascade: skip + } + if (v0.particleId < 0) { + continue; // no de-referencing possible (e.g. background, ...) + } + auto v0Particle = mcParticles.rawIteratorAt(v0.particleId); + + int v0OriginParticleIndex = -1; + if (v0Particle.has_mothers()) { + auto const& motherList = v0Particle.template mothers_as(); + if (motherList.size() == 1) { + for (const auto& mother : motherList) { + v0OriginParticleIndex = mother.globalIndex(); + } + } + } + if (v0OriginParticleIndex < 0) { + continue; + } + auto v0OriginParticle = mcParticles.rawIteratorAt(v0OriginParticleIndex); + + if (std::abs(v0OriginParticle.pdgCode()) != 3312 && std::abs(v0OriginParticle.pdgCode()) != 3334) { + continue; // this V0 does not come from any particle of interest, don't try + } + for (const auto& bachelorTrackIndex : bachelorTrackArray) { + if (bachelorTrackIndex.originId != v0OriginParticle.globalIndex()) { + continue; + } + // if we are here: v0 origin is 3312 or 3334, bachelor origin matches V0 origin + // findable mode 1: add non-reconstructed as cascadeType 1 + if (baseOpts.mc_findableMode.value == 1) { + bool detected = false; + for (size_t ii = 0; ii < cascadeListReconstructedSize; ii++) { + // check if this particular combination already exists in cascadeList + // caution: use track indices (immutable) but not V0 indices (re-indexing) + if (cascadeList[ii].posTrackId == v0.posTrackId && + cascadeList[ii].negTrackId == v0.negTrackId && + cascadeList[ii].bachTrackId == bachelorTrackIndex.globalId) { + detected = true; + break; + } + } + if (detected == false) { + // collision index: from best-version-of-this-mcCollision + // nota bene: this could be negative, caution advised + currentCascadeEntry.globalId = -1; + currentCascadeEntry.collisionId = bestCollisionArray[bachelorTrackIndex.mcCollisionId]; + currentCascadeEntry.v0Id = v0i; // correct information here + currentCascadeEntry.posTrackId = v0.posTrackId; + currentCascadeEntry.negTrackId = v0.negTrackId; + currentCascadeEntry.bachTrackId = bachelorTrackIndex.globalId; + currentCascadeEntry.found = false; + cascadeList.push_back(currentCascadeEntry); + if (bestCollisionArray[bachelorTrackIndex.mcCollisionId] < 0) { + collisionLessCascades++; + } + if (cascadeBuilderOpts.mc_findableDetachedCascade.value || currentCascadeEntry.collisionId >= 0) { + cascadeList.push_back(currentCascadeEntry); + } + } + } + + // findable mode 2: determine type based on cascade table, + // with type 1 being reserved to findable-but-not-found + if (baseOpts.mc_findableMode.value == 2) { + currentCascadeEntry.globalId = -1; + currentCascadeEntry.collisionId = bestCollisionArray[bachelorTrackIndex.mcCollisionId]; + currentCascadeEntry.v0Id = v0i; // fill this in one go later + currentCascadeEntry.posTrackId = v0.posTrackId; + currentCascadeEntry.negTrackId = v0.negTrackId; + currentCascadeEntry.bachTrackId = bachelorTrackIndex.globalId; + currentCascadeEntry.found = false; + if (bestCollisionArray[bachelorTrackIndex.mcCollisionId] < 0) { + collisionLessCascades++; + } + for (const auto& cascade : cascades) { + auto const& v0fromAOD = cascade.v0(); + if (v0fromAOD.posTrackId() == v0.posTrackId && + v0fromAOD.negTrackId() == v0.negTrackId && + cascade.bachelorId() == bachelorTrackIndex.globalId) { + // this will override type, but not collision index + // N.B.: collision index checks still desirable! + currentCascadeEntry.found = true; + currentCascadeEntry.globalId = cascade.globalIndex(); + break; + } + } + if (cascadeBuilderOpts.mc_findableDetachedCascade.value || currentCascadeEntry.collisionId >= 0) { + cascadeList.push_back(currentCascadeEntry); + } + } + } // end bachelorTrackArray loop + } // end v0List loop + + // at this stage, cascadeList is alright, but the v0 indices are still not + // correct. We'll have to loop over all V0s and find the appropriate matches + // ---> but only in mode 1, and only for AO2D-native V0s + if (baseOpts.mc_findableMode.value == 1) { + for (size_t casci = 0; casci < cascadeListReconstructedSize; casci++) { + // loop over v0List to find corresponding v0 index, but do it in sorted way + for (size_t v0i = 0; v0i < v0List.size(); v0i++) { + auto v0 = v0List[sorted_v0[v0i]]; + if (cascadeList[casci].posTrackId == v0.posTrackId && + cascadeList[casci].negTrackId == v0.negTrackId) { + cascadeList[casci].v0Id = v0i; // fix, point to correct V0 index + break; + } + } + } + } + // we should now be done! collect statistics + histos.fill(HIST("hFindableStatistics"), 3.0, cascades.size()); + histos.fill(HIST("hFindableStatistics"), 4.0, cascadeList.size()); + histos.fill(HIST("hFindableStatistics"), 5.0, collisionLessCascades); + + } // end findable mode check + } // end soa::is_table + + // we need to allow for sorted use of cascadeList + sorted_cascade.clear(); + sorted_cascade = sort_indices(cascadeList, (baseOpts.mc_findableMode.value > 0)); + } + + LOGF(info, "AO2D input: %i V0s, %i cascades. Building list sizes: %i V0s, %i cascades", v0s.size(), cascades.size(), v0List.size(), cascadeList.size()); + } + + //__________________________________________________ + template + void markV0sUsedInCascades(TV0s const& v0s, TCascades const& cascades, TTrackedCascades const& trackedCascades) + { + int v0sUsedInCascades = 0; + v0sFromCascades.clear(); + v0Map.clear(); + v0Map.resize(v0List.size(), -2); // marks not used + if (baseOpts.useV0BufferForCascades.value == false) { + return; // don't attempt to mark needlessly + } + if (baseOpts.mEnabledTables[kStoredCascCores]) { + for (const auto& cascade : cascadeList) { + if (cascade.v0Id < 0) + continue; + if (v0Map[cascade.v0Id] == -2) { + v0sUsedInCascades++; + } + v0Map[cascade.v0Id] = -1; // marks used (but isn't the index of a properly built V0, which would be >= 0) + } + } + int trackedCascadeCount = 0; + if constexpr (soa::is_table) { + // tracked only created outside of findable mode + if (baseOpts.mEnabledTables[kStoredTraCascCores] && baseOpts.mc_findableMode.value == 0) { + trackedCascadeCount = trackedCascades.size(); + for (const auto& trackedCascade : trackedCascades) { + auto const& cascade = trackedCascade.cascade(); + if (v0Map[ao2dV0toV0List[cascade.v0Id()]] == -2) { + v0sUsedInCascades++; + } + v0Map[ao2dV0toV0List[cascade.v0Id()]] = -1; // marks used (but isn't the index of a built V0, which would be >= 0) + } + } + } + LOGF(debug, "V0 total %i, Cascade total %i, Tracked cascade total %i, V0s flagged used in cascades: %i", v0s.size(), cascades.size(), trackedCascadeCount, v0sUsedInCascades); + } + + //__________________________________________________ + template + void buildV0s(THistoRegistry& histos, TCollisions const& collisions, TV0s const& v0s, TTracks const& tracks, TMCParticles const& mcParticles, TProducts& products) + { + // prepare MC containers (not necessarily used) + std::vector mcV0infos; // V0MCCore information + std::vector mcParticleIsReco; + + if constexpr (soa::is_table) { + // do this if provided with a mcParticle table as well + mcParticleIsReco.resize(mcParticles.size(), false); + } + + int nV0s = 0; + // Loops over all V0s in the time frame + histos.fill(HIST("hInputStatistics"), kV0CoresBase, v0s.size()); + for (size_t iv0 = 0; iv0 < v0List.size(); iv0++) { + const auto& v0 = v0List[sorted_v0[iv0]]; + + if (!baseOpts.mEnabledTables[kV0CoresBase] && v0Map[iv0] == -2) { + // this v0 hasn't been used by cascades and we're not generating V0s, so skip it + products.v0dataLink(-1, -1); + continue; + } + + // Get tracks and generate candidate + // if collisionId positive: get vertex, negative: origin + // could be replaced by mean vertex (but without much benefit...) + float pvX = 0.0f, pvY = 0.0f, pvZ = 0.0f; + if (v0.collisionId >= 0) { + auto const& collision = collisions.rawIteratorAt(v0.collisionId); + pvX = collision.posX(); + pvY = collision.posY(); + pvZ = collision.posZ(); + } + auto const& posTrack = tracks.rawIteratorAt(v0.posTrackId); + auto const& negTrack = tracks.rawIteratorAt(v0.negTrackId); + + auto posTrackPar = getTrackParCov(posTrack); + auto negTrackPar = getTrackParCov(negTrack); + + // handle TPC-only tracks properly (photon conversions) + if (v0BuilderOpts.moveTPCOnlyTracks) { + bool isPosTPCOnly = (posTrack.hasTPC() && !posTrack.hasITS() && !posTrack.hasTRD() && !posTrack.hasTOF()); + if (isPosTPCOnly) { + // Nota bene: positive is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + + auto const& collision = collisions.rawIteratorAt(v0.collisionId); + if (!mVDriftMgr.moveTPCTrack(collision, posTrack, posTrackPar)) { + products.v0dataLink(-1, -1); + continue; + } + } + + bool isNegTPCOnly = (negTrack.hasTPC() && !negTrack.hasITS() && !negTrack.hasTRD() && !negTrack.hasTOF()); + if (isNegTPCOnly) { + // Nota bene: negative is TPC-only -> this entire V0 merits treatment as photon candidate + posTrackPar.setPID(o2::track::PID::Electron); + negTrackPar.setPID(o2::track::PID::Electron); + + auto const& collision = collisions.rawIteratorAt(v0.collisionId); + if (!mVDriftMgr.moveTPCTrack(collision, negTrack, negTrackPar)) { + products.v0dataLink(-1, -1); + continue; + } + } + } + + if (!straHelper.buildV0Candidate(v0.collisionId, pvX, pvY, pvZ, posTrack, negTrack, posTrackPar, negTrackPar, v0.isCollinearV0, baseOpts.mEnabledTables[kV0Covs], true)) { + products.v0dataLink(-1, -1); + continue; + } + if constexpr (requires { posTrack.tpcNSigmaEl(); }) { + if (preSelectOpts.preselectOnlyDesiredV0s) { + float lPt = RecoDecay::sqrtSumOfSquares( + straHelper.v0.positiveMomentum[0] + straHelper.v0.negativeMomentum[0], + straHelper.v0.positiveMomentum[1] + straHelper.v0.negativeMomentum[1]); + + float lPtot = RecoDecay::sqrtSumOfSquares( + straHelper.v0.positiveMomentum[0] + straHelper.v0.negativeMomentum[0], + straHelper.v0.positiveMomentum[1] + straHelper.v0.negativeMomentum[1], + straHelper.v0.positiveMomentum[2] + straHelper.v0.negativeMomentum[2]); + + float lLengthTraveled = RecoDecay::sqrtSumOfSquares( + straHelper.v0.position[0] - pvX, + straHelper.v0.position[1] - pvY, + straHelper.v0.position[2] - pvZ); + + uint8_t maskV0Preselection = 0; + + if ( // photon PID, mass, lifetime selection + std::abs(posTrack.tpcNSigmaEl()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaEl()) < preSelectOpts.maxTPCpidNsigma && + std::abs(straHelper.v0.massGamma) < preSelectOpts.massCutPhoton) { + BITSET(maskV0Preselection, selGamma); + } + + if ( // K0Short PID, mass, lifetime selection + std::abs(posTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassKaonNeutral * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutK0S") && + std::abs(straHelper.v0.massK0Short - o2::constants::physics::MassKaonNeutral) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaK0Short(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskV0Preselection, selK0Short); + } + + if ( // Lambda PID, mass, lifetime selection + std::abs(posTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + std::abs(straHelper.v0.massLambda - o2::constants::physics::MassLambda) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaLambda(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskV0Preselection, selLambda); + } + + if ( // antiLambda PID, mass, lifetime selection + std::abs(posTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + std::abs(straHelper.v0.massAntiLambda - o2::constants::physics::MassLambda) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaLambda(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskV0Preselection, selAntiLambda); + } + + histos.fill(HIST("hPreselectionV0s"), maskV0Preselection); + + if (maskV0Preselection == 0) { + products.v0dataLink(-1, -1); + continue; + } + } + } + if (v0Map[iv0] == -1 && baseOpts.useV0BufferForCascades) { + v0Map[iv0] = v0sFromCascades.size(); // provide actual valid index in buffer + v0sFromCascades.push_back(straHelper.v0); + } + // fill requested cursors only if type is not 0 + if (v0.v0Type == 1 || (v0.v0Type > 1 && v0BuilderOpts.generatePhotonCandidates)) { + nV0s++; + if (baseOpts.mEnabledTables[kV0Indices]) { + // for referencing (especially - but not only - when using derived data) + products.v0indices(v0.posTrackId, v0.negTrackId, + v0.collisionId, iv0); + histos.fill(HIST("hTableBuildingStatistics"), kV0Indices); + } + if (baseOpts.mEnabledTables[kV0TrackXs]) { + // further decay chains may need this + products.v0trackXs(straHelper.v0.positiveTrackX, straHelper.v0.negativeTrackX); + histos.fill(HIST("hTableBuildingStatistics"), kV0TrackXs); + } + if (baseOpts.mEnabledTables[kV0CoresBase]) { + // standard analysis + products.v0cores(straHelper.v0.position[0], straHelper.v0.position[1], straHelper.v0.position[2], + straHelper.v0.positiveMomentum[0], straHelper.v0.positiveMomentum[1], straHelper.v0.positiveMomentum[2], + straHelper.v0.negativeMomentum[0], straHelper.v0.negativeMomentum[1], straHelper.v0.negativeMomentum[2], + straHelper.v0.daughterDCA, + straHelper.v0.positiveDCAxy, + straHelper.v0.negativeDCAxy, + TMath::Cos(straHelper.v0.pointingAngle), + straHelper.v0.dcaToPV, + v0.v0Type); + products.v0dataLink(products.v0cores.lastIndex(), -1); + histos.fill(HIST("hTableBuildingStatistics"), kV0CoresBase); + } + if (baseOpts.mEnabledTables[kV0TraPosAtDCAs]) { + // for tracking studies + products.v0dauPositions(straHelper.v0.positivePosition[0], straHelper.v0.positivePosition[1], straHelper.v0.positivePosition[2], + straHelper.v0.negativePosition[0], straHelper.v0.negativePosition[1], straHelper.v0.negativePosition[2]); + histos.fill(HIST("hTableBuildingStatistics"), kV0TraPosAtDCAs); + } + if (baseOpts.mEnabledTables[kV0TraPosAtIUs]) { + // for tracking studies + std::array positivePositionIU; + std::array negativePositionIU; + o2::track::TrackPar positiveTrackParam = getTrackPar(posTrack); + o2::track::TrackPar negativeTrackParam = getTrackPar(negTrack); + positiveTrackParam.getXYZGlo(positivePositionIU); + negativeTrackParam.getXYZGlo(negativePositionIU); + products.v0dauPositionsIU(positivePositionIU[0], positivePositionIU[1], positivePositionIU[2], + negativePositionIU[0], negativePositionIU[1], negativePositionIU[2]); + histos.fill(HIST("hTableBuildingStatistics"), kV0TraPosAtIUs); + } + if (baseOpts.mEnabledTables[kV0Covs]) { + products.v0covs(straHelper.v0.positionCovariance, straHelper.v0.momentumCovariance); + histos.fill(HIST("hTableBuildingStatistics"), kV0Covs); + } + + //_________________________________________________________ + // MC handling part + if constexpr (soa::is_table) { + // only worry about this if someone else worried about this + if ((baseOpts.mEnabledTables[kV0MCCores] || baseOpts.mEnabledTables[kMcV0Labels] || baseOpts.mEnabledTables[kV0MCCollRefs])) { + thisInfo.label = -1; + thisInfo.motherLabel = -1; + thisInfo.pdgCode = 0; + thisInfo.pdgCodeMother = 0; + thisInfo.pdgCodePositive = 0; + thisInfo.pdgCodeNegative = 0; + thisInfo.mcCollision = -1; + thisInfo.xyz[0] = thisInfo.xyz[1] = thisInfo.xyz[2] = 0.0f; + thisInfo.posP[0] = thisInfo.posP[1] = thisInfo.posP[2] = 0.0f; + thisInfo.negP[0] = thisInfo.negP[1] = thisInfo.negP[2] = 0.0f; + thisInfo.momentum[0] = thisInfo.momentum[1] = thisInfo.momentum[2] = 0.0f; + + // Association check + // There might be smarter ways of doing this in the future + if (negTrack.has_mcParticle() && posTrack.has_mcParticle()) { + auto lMCNegTrack = negTrack.template mcParticle_as(); + auto lMCPosTrack = posTrack.template mcParticle_as(); + + thisInfo.pdgCodePositive = lMCPosTrack.pdgCode(); + thisInfo.pdgCodeNegative = lMCNegTrack.pdgCode(); + thisInfo.processPositive = lMCPosTrack.getProcess(); + thisInfo.processNegative = lMCNegTrack.getProcess(); + thisInfo.posP[0] = lMCPosTrack.px(); + thisInfo.posP[1] = lMCPosTrack.py(); + thisInfo.posP[2] = lMCPosTrack.pz(); + thisInfo.negP[0] = lMCNegTrack.px(); + thisInfo.negP[1] = lMCNegTrack.py(); + thisInfo.negP[2] = lMCNegTrack.pz(); + + // check for pi -> mu + antineutrino decay + // if present, de-reference original V0 correctly and provide label to original object + // NOTA BENE: the prong info will still correspond to a muon, treat carefully! + int negOriginating = -1, posOriginating = -1, particleForDecayPositionIdx = -1; + negOriginating = getOriginatingParticle(lMCNegTrack, particleForDecayPositionIdx, v0BuilderOpts.mc_treatPiToMuDecays); + posOriginating = getOriginatingParticle(lMCPosTrack, particleForDecayPositionIdx, v0BuilderOpts.mc_treatPiToMuDecays); + + if (negOriginating > -1 && negOriginating == posOriginating) { + auto originatingV0 = mcParticles.rawIteratorAt(negOriginating); + auto particleForDecayPosition = mcParticles.rawIteratorAt(particleForDecayPositionIdx); + + thisInfo.label = originatingV0.globalIndex(); + thisInfo.xyz[0] = particleForDecayPosition.vx(); + thisInfo.xyz[1] = particleForDecayPosition.vy(); + thisInfo.xyz[2] = particleForDecayPosition.vz(); + + if (originatingV0.has_mcCollision()) { + thisInfo.mcCollision = originatingV0.mcCollisionId(); // save this reference, please + } + + // acquire information + thisInfo.pdgCode = originatingV0.pdgCode(); + thisInfo.isPhysicalPrimary = originatingV0.isPhysicalPrimary(); + thisInfo.momentum[0] = originatingV0.px(); + thisInfo.momentum[1] = originatingV0.py(); + thisInfo.momentum[2] = originatingV0.pz(); + + if (originatingV0.has_mothers()) { + for (const auto& lV0Mother : originatingV0.template mothers_as()) { + thisInfo.pdgCodeMother = lV0Mother.pdgCode(); + thisInfo.motherLabel = lV0Mother.globalIndex(); + } + } + } + + } // end association check + // Construct label table (note: this will be joinable with V0Datas!) + if (baseOpts.mEnabledTables[kMcV0Labels]) { + products.v0labels(thisInfo.label, thisInfo.motherLabel); + histos.fill(HIST("hTableBuildingStatistics"), kMcV0Labels); + } + + // Construct found tag + if (baseOpts.mEnabledTables[kV0FoundTags]) { + products.v0FoundTag(v0.found); + histos.fill(HIST("hTableBuildingStatistics"), kV0FoundTags); + } + + // Mark mcParticle as recoed (no searching necessary afterwards) + if (thisInfo.label > -1) { + mcParticleIsReco[thisInfo.label] = true; + } + + // ---] Symmetric populate [--- + // in this approach, V0Cores will be joinable with V0MCCores. + // this is the most pedagogical approach, but it is also more limited + // and it might use more disk space unnecessarily. + if (v0BuilderOpts.mc_populateV0MCCoresSymmetric) { + if (baseOpts.mEnabledTables[kV0MCCores]) { + products.v0mccores( + thisInfo.label, thisInfo.pdgCode, + thisInfo.pdgCodeMother, thisInfo.pdgCodePositive, thisInfo.pdgCodeNegative, + thisInfo.isPhysicalPrimary, thisInfo.xyz[0], thisInfo.xyz[1], thisInfo.xyz[2], + thisInfo.posP[0], thisInfo.posP[1], thisInfo.posP[2], + thisInfo.negP[0], thisInfo.negP[1], thisInfo.negP[2], + thisInfo.momentum[0], thisInfo.momentum[1], thisInfo.momentum[2]); + histos.fill(HIST("hTableBuildingStatistics"), kV0MCCores); + histos.fill(HIST("hPrimaryV0s"), 0); + if (thisInfo.isPhysicalPrimary) + histos.fill(HIST("hPrimaryV0s"), 1); + } + if (baseOpts.mEnabledTables[kV0MCCollRefs]) { + products.v0mccollref(thisInfo.mcCollision); + histos.fill(HIST("hTableBuildingStatistics"), kV0MCCollRefs); + } + + // n.b. placing the interlink index here allows for the writing of + // code that is agnostic with respect to the joinability of + // V0Cores and V0MCCores (always dereference -> safe) + if (baseOpts.mEnabledTables[kV0CoreMCLabels]) { + products.v0CoreMCLabels(iv0); // interlink index + histos.fill(HIST("hTableBuildingStatistics"), kV0CoreMCLabels); + } + } + // ---] Asymmetric populate [--- + // in this approach, V0Cores will NOT be joinable with V0MCCores. + // an additional reference to V0MCCore that IS joinable with V0Cores + // will be provided to the user. + if (v0BuilderOpts.mc_populateV0MCCoresAsymmetric) { + int thisV0MCCoreIndex = -1; + // step 1: check if this element is already provided in the table + // using the packedIndices variable calculated above + for (uint32_t ii = 0; ii < mcV0infos.size(); ii++) { + if (thisInfo.label == mcV0infos[ii].label && mcV0infos[ii].label > -1) { + thisV0MCCoreIndex = ii; + break; // this exists already in list + } + } + if (thisV0MCCoreIndex < 0 && thisInfo.label > -1) { + // this V0MCCore does not exist yet. Create it and reference it + thisV0MCCoreIndex = mcV0infos.size(); + mcV0infos.push_back(thisInfo); + } + if (baseOpts.mEnabledTables[kV0CoreMCLabels]) { + products.v0CoreMCLabels(thisV0MCCoreIndex); // interlink index + histos.fill(HIST("hTableBuildingStatistics"), kV0CoreMCLabels); + } + } + } // enabled tables check + } // constexpr requires check + } else { + products.v0dataLink(-1, -1); + } + } + + // finish populating V0MCCores if in asymmetric mode + if constexpr (soa::is_table) { + if (v0BuilderOpts.mc_populateV0MCCoresAsymmetric && (baseOpts.mEnabledTables[kV0MCCores] || baseOpts.mEnabledTables[kV0MCCollRefs])) { + // first step: add any un-recoed v0mmcores that were requested + for (const auto& mcParticle : mcParticles) { + thisInfo.label = -1; + thisInfo.motherLabel = -1; + thisInfo.pdgCode = 0; + thisInfo.pdgCodeMother = -1; + thisInfo.pdgCodePositive = -1; + thisInfo.pdgCodeNegative = -1; + thisInfo.mcCollision = -1; + thisInfo.xyz[0] = thisInfo.xyz[1] = thisInfo.xyz[2] = 0.0f; + thisInfo.posP[0] = thisInfo.posP[1] = thisInfo.posP[2] = 0.0f; + thisInfo.negP[0] = thisInfo.negP[1] = thisInfo.negP[2] = 0.0f; + thisInfo.momentum[0] = thisInfo.momentum[1] = thisInfo.momentum[2] = 0.0f; + + if (mcParticleIsReco[mcParticle.globalIndex()] == true) + continue; // skip if already created in list + + if (std::fabs(mcParticle.y()) > v0BuilderOpts.mc_rapidityWindow) + continue; // skip outside midrapidity + + if (v0BuilderOpts.mc_keepOnlyPhysicalPrimary && !mcParticle.isPhysicalPrimary()) + continue; // skip secondary MC V0s + + if ( + (v0BuilderOpts.mc_addGeneratedK0Short && mcParticle.pdgCode() == 310) || + (v0BuilderOpts.mc_addGeneratedLambda && mcParticle.pdgCode() == 3122) || + (v0BuilderOpts.mc_addGeneratedAntiLambda && mcParticle.pdgCode() == -3122) || + (v0BuilderOpts.mc_addGeneratedGamma && mcParticle.pdgCode() == 22)) { + thisInfo.pdgCode = mcParticle.pdgCode(); + thisInfo.isPhysicalPrimary = mcParticle.isPhysicalPrimary(); + thisInfo.label = mcParticle.globalIndex(); + + if (mcParticle.has_mcCollision()) { + thisInfo.mcCollision = mcParticle.mcCollisionId(); // save this reference, please + } + + // + thisInfo.momentum[0] = mcParticle.px(); + thisInfo.momentum[1] = mcParticle.py(); + thisInfo.momentum[2] = mcParticle.pz(); + + if (mcParticle.has_mothers()) { + auto const& mother = mcParticle.template mothers_first_as(); + thisInfo.pdgCodeMother = mother.pdgCode(); + thisInfo.motherLabel = mother.globalIndex(); + } + if (mcParticle.has_daughters()) { + auto const& daughters = mcParticle.template daughters_as(); + + for (const auto& dau : daughters) { + if (dau.getProcess() != 4) + continue; + + if (dau.pdgCode() > 0) { + thisInfo.pdgCodePositive = dau.pdgCode(); + thisInfo.processPositive = dau.getProcess(); + thisInfo.posP[0] = dau.px(); + thisInfo.posP[1] = dau.py(); + thisInfo.posP[2] = dau.pz(); + thisInfo.xyz[0] = dau.vx(); + thisInfo.xyz[1] = dau.vy(); + thisInfo.xyz[2] = dau.vz(); + } + if (dau.pdgCode() < 0) { + thisInfo.pdgCodeNegative = dau.pdgCode(); + thisInfo.processNegative = dau.getProcess(); + thisInfo.negP[0] = dau.px(); + thisInfo.negP[1] = dau.py(); + thisInfo.negP[2] = dau.pz(); + } + } + } + + // if I got here, it means this MC particle was not recoed and is of interest. Add it please + mcV0infos.push_back(thisInfo); + } + } + + for (const auto& info : mcV0infos) { + if (baseOpts.mEnabledTables[kV0MCCores]) { + products.v0mccores( + info.label, info.pdgCode, + info.pdgCodeMother, info.pdgCodePositive, info.pdgCodeNegative, + info.isPhysicalPrimary, info.xyz[0], info.xyz[1], info.xyz[2], + info.posP[0], info.posP[1], info.posP[2], + info.negP[0], info.negP[1], info.negP[2], + info.momentum[0], info.momentum[1], info.momentum[2]); + histos.fill(HIST("hTableBuildingStatistics"), kV0MCCores); + histos.fill(HIST("hPrimaryV0s"), 0); + if (info.isPhysicalPrimary) + histos.fill(HIST("hPrimaryV0s"), 1); + } + if (baseOpts.mEnabledTables[kV0MCCollRefs]) { + products.v0mccollref(info.mcCollision); + histos.fill(HIST("hTableBuildingStatistics"), kV0MCCollRefs); + } + } + } // end V0MCCores filling in case of MC + } // end constexpr requires mcParticles + + LOGF(debug, "V0s in DF: %i, V0s built: %i, V0s built and buffered for cascades: %i.", v0s.size(), nV0s, v0sFromCascades.size()); + } + + //__________________________________________________ + template + void extractMonteCarloProperties(TTrack const& posTrack, TTrack const& negTrack, TTrack const& bachTrack, TMCParticles const& mcParticles) + { + // encapsulates acquisition of MC properties from MC + thisCascInfo.pdgCode = -1, thisCascInfo.pdgCodeMother = -1; + thisCascInfo.pdgCodePositive = -1, thisCascInfo.pdgCodeNegative = -1; + thisCascInfo.pdgCodeBachelor = -1, thisCascInfo.pdgCodeV0 = -1; + thisCascInfo.isPhysicalPrimary = false; + thisCascInfo.xyz[0] = -999.0f, thisCascInfo.xyz[1] = -999.0f, thisCascInfo.xyz[2] = -999.0f; + thisCascInfo.lxyz[0] = -999.0f, thisCascInfo.lxyz[1] = -999.0f, thisCascInfo.lxyz[2] = -999.0f; + thisCascInfo.posP[0] = -999.0f, thisCascInfo.posP[1] = -999.0f, thisCascInfo.posP[2] = -999.0f; + thisCascInfo.negP[0] = -999.0f, thisCascInfo.negP[1] = -999.0f, thisCascInfo.negP[2] = -999.0f; + thisCascInfo.bachP[0] = -999.0f, thisCascInfo.bachP[1] = -999.0f, thisCascInfo.bachP[2] = -999.0f; + thisCascInfo.momentum[0] = -999.0f, thisCascInfo.momentum[1] = -999.0f, thisCascInfo.momentum[2] = -999.0f; + thisCascInfo.label = -1, thisCascInfo.motherLabel = -1; + thisCascInfo.mcParticlePositive = -1; + thisCascInfo.mcParticleNegative = -1; + thisCascInfo.mcParticleBachelor = -1; + + // Association check + // There might be smarter ways of doing this in the future + if (negTrack.has_mcParticle() && posTrack.has_mcParticle() && bachTrack.has_mcParticle()) { + auto lMCBachTrack = bachTrack.template mcParticle_as(); + auto lMCNegTrack = negTrack.template mcParticle_as(); + auto lMCPosTrack = posTrack.template mcParticle_as(); + + thisCascInfo.mcParticlePositive = lMCPosTrack.globalIndex(); + thisCascInfo.mcParticleNegative = lMCNegTrack.globalIndex(); + thisCascInfo.mcParticleBachelor = lMCBachTrack.globalIndex(); + thisCascInfo.pdgCodePositive = lMCPosTrack.pdgCode(); + thisCascInfo.pdgCodeNegative = lMCNegTrack.pdgCode(); + thisCascInfo.pdgCodeBachelor = lMCBachTrack.pdgCode(); + thisCascInfo.posP[0] = lMCPosTrack.px(); + thisCascInfo.posP[1] = lMCPosTrack.py(); + thisCascInfo.posP[2] = lMCPosTrack.pz(); + thisCascInfo.negP[0] = lMCNegTrack.px(); + thisCascInfo.negP[1] = lMCNegTrack.py(); + thisCascInfo.negP[2] = lMCNegTrack.pz(); + thisCascInfo.bachP[0] = lMCBachTrack.px(); + thisCascInfo.bachP[1] = lMCBachTrack.py(); + thisCascInfo.bachP[2] = lMCBachTrack.pz(); + thisCascInfo.processPositive = lMCPosTrack.getProcess(); + thisCascInfo.processNegative = lMCNegTrack.getProcess(); + thisCascInfo.processBachelor = lMCBachTrack.getProcess(); + + // Step 0: treat pi -> mu + antineutrino + // if present, de-reference original V0 correctly and provide label to original object + // NOTA BENE: the prong info will still correspond to a muon, treat carefully! + int negOriginating = -1, posOriginating = -1, bachOriginating = -1; + int particleForLambdaDecayPositionIdx = -1, particleForCascadeDecayPositionIdx = -1; + negOriginating = getOriginatingParticle(lMCNegTrack, particleForLambdaDecayPositionIdx, cascadeBuilderOpts.mc_treatPiToMuDecays); + posOriginating = getOriginatingParticle(lMCPosTrack, particleForLambdaDecayPositionIdx, cascadeBuilderOpts.mc_treatPiToMuDecays); + bachOriginating = getOriginatingParticle(lMCBachTrack, particleForCascadeDecayPositionIdx, cascadeBuilderOpts.mc_treatPiToMuDecays); + + if (negOriginating > -1 && negOriginating == posOriginating) { + auto originatingV0 = mcParticles.rawIteratorAt(negOriginating); + auto particleForLambdaDecayPosition = mcParticles.rawIteratorAt(particleForLambdaDecayPositionIdx); + + thisCascInfo.label = originatingV0.globalIndex(); + thisCascInfo.lxyz[0] = particleForLambdaDecayPosition.vx(); + thisCascInfo.lxyz[1] = particleForLambdaDecayPosition.vy(); + thisCascInfo.lxyz[2] = particleForLambdaDecayPosition.vz(); + thisCascInfo.pdgCodeV0 = originatingV0.pdgCode(); + + if (originatingV0.has_mothers()) { + for (const auto& lV0Mother : originatingV0.template mothers_as()) { + if (lV0Mother.globalIndex() == bachOriginating) { // found mother particle + thisCascInfo.label = lV0Mother.globalIndex(); + + if (lV0Mother.has_mcCollision()) { + thisCascInfo.mcCollision = lV0Mother.mcCollisionId(); // save this reference, please + } + + thisCascInfo.pdgCode = lV0Mother.pdgCode(); + thisCascInfo.isPhysicalPrimary = lV0Mother.isPhysicalPrimary(); + thisCascInfo.xyz[0] = originatingV0.vx(); + thisCascInfo.xyz[1] = originatingV0.vy(); + thisCascInfo.xyz[2] = originatingV0.vz(); + thisCascInfo.momentum[0] = lV0Mother.px(); + thisCascInfo.momentum[1] = lV0Mother.py(); + thisCascInfo.momentum[2] = lV0Mother.pz(); + if (lV0Mother.has_mothers()) { + for (const auto& lV0GrandMother : lV0Mother.template mothers_as()) { + thisCascInfo.pdgCodeMother = lV0GrandMother.pdgCode(); + thisCascInfo.motherLabel = lV0GrandMother.globalIndex(); + } + } + } + } // end v0 mother loop + } // end has_mothers check for V0 + } // end conditional of pos/neg originating being the same + } // end association check + } + + //__________________________________________________ + template + void buildCascades(THistoRegistry& histos, TCollisions const& collisions, TCascades const& cascades, TTracks const& tracks, TMCParticles const& mcParticles, TProducts& products) + { + // prepare MC containers (not necessarily used) + std::vector mcCascinfos; // V0MCCore information + std::vector mcParticleIsReco; + + if constexpr (soa::is_table) { + // do this if provided with a mcParticle table as well + mcParticleIsReco.resize(mcParticles.size(), false); + } + + if (!baseOpts.mEnabledTables[kStoredCascCores]) { + return; // don't do if no request for cascades in place + } + int nCascades = 0; + // Loops over all cascades in the time frame + histos.fill(HIST("hInputStatistics"), kStoredCascCores, cascades.size()); + for (size_t icascade = 0; icascade < cascades.size(); icascade++) { + // Get tracks and generate candidate + auto const& cascade = cascades[sorted_cascade[icascade]]; + // if collisionId positive: get vertex, negative: origin + // could be replaced by mean vertex (but without much benefit...) + float pvX = 0.0f, pvY = 0.0f, pvZ = 0.0f; + if (cascade.collisionId >= 0) { + auto const& collision = collisions.rawIteratorAt(cascade.collisionId); + pvX = collision.posX(); + pvY = collision.posY(); + pvZ = collision.posZ(); + } + auto const& posTrack = tracks.rawIteratorAt(cascade.posTrackId); + auto const& negTrack = tracks.rawIteratorAt(cascade.negTrackId); + auto const& bachTrack = tracks.rawIteratorAt(cascade.bachTrackId); + if (baseOpts.useV0BufferForCascades) { + // this processing path uses a buffer of V0s so that no + // additional minimization step is redone. It consumes less + // CPU at the cost of more memory. Since memory is a more + // limited commodity, this isn't the default option. + + // check if cached - if not, skip + if (cascade.v0Id < 0 || v0Map[cascade.v0Id] < 0) { + // this V0 hasn't been stored / cached + products.cascdataLink(-1); + interlinks.cascadeToCascCores.push_back(-1); + continue; // didn't work out, skip + } + + if (!straHelper.buildCascadeCandidate(cascade.collisionId, pvX, pvY, pvZ, + v0sFromCascades[v0Map[cascade.v0Id]], + posTrack, + negTrack, + bachTrack, + baseOpts.mEnabledTables[kCascBBs], + cascadeBuilderOpts.useCascadeMomentumAtPrimVtx, + baseOpts.mEnabledTables[kCascCovs])) { + products.cascdataLink(-1); + interlinks.cascadeToCascCores.push_back(-1); + continue; // didn't work out, skip + } + } else { + // this processing path generates the entire cascade + // from tracks, without any need to have V0s generated. + if (!straHelper.buildCascadeCandidate(cascade.collisionId, pvX, pvY, pvZ, + posTrack, + negTrack, + bachTrack, + baseOpts.mEnabledTables[kCascBBs], + cascadeBuilderOpts.useCascadeMomentumAtPrimVtx, + baseOpts.mEnabledTables[kCascCovs])) { + products.cascdataLink(-1); + interlinks.cascadeToCascCores.push_back(-1); + continue; // didn't work out, skip + } + } + nCascades++; + + if constexpr (requires { posTrack.tpcNSigmaEl(); }) { + if (preSelectOpts.preselectOnlyDesiredCascades) { + float lPt = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.bachelorMomentum[0] + straHelper.cascade.positiveMomentum[0] + straHelper.cascade.negativeMomentum[0], + straHelper.cascade.bachelorMomentum[1] + straHelper.cascade.positiveMomentum[1] + straHelper.cascade.negativeMomentum[1]); + + float lPtot = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.bachelorMomentum[0] + straHelper.cascade.positiveMomentum[0] + straHelper.cascade.negativeMomentum[0], + straHelper.cascade.bachelorMomentum[1] + straHelper.cascade.positiveMomentum[1] + straHelper.cascade.negativeMomentum[1], + straHelper.cascade.bachelorMomentum[2] + straHelper.cascade.positiveMomentum[2] + straHelper.cascade.negativeMomentum[2]); + + float lV0Ptot = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.positiveMomentum[0] + straHelper.cascade.negativeMomentum[0], + straHelper.cascade.positiveMomentum[1] + straHelper.cascade.negativeMomentum[1], + straHelper.cascade.positiveMomentum[2] + straHelper.cascade.negativeMomentum[2]); + + float lLengthTraveled = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.cascadePosition[0] - pvX, + straHelper.cascade.cascadePosition[1] - pvY, + straHelper.cascade.cascadePosition[2] - pvZ); + + float lV0LengthTraveled = RecoDecay::sqrtSumOfSquares( + straHelper.cascade.v0Position[0] - straHelper.cascade.cascadePosition[0], + straHelper.cascade.v0Position[1] - straHelper.cascade.cascadePosition[1], + straHelper.cascade.v0Position[2] - straHelper.cascade.cascadePosition[2]); + + uint8_t maskCascadePreselection = 0; + + if ( // XiMinus PID and mass selection + straHelper.cascade.charge < 0 && + std::abs(posTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(bachTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lV0LengthTraveled / (lV0Ptot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + o2::constants::physics::MassXiMinus * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutXi") && + std::abs(straHelper.cascade.massXi - o2::constants::physics::MassXiMinus) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaXi(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskCascadePreselection, selXiMinus); + } + + if ( // XiPlus PID and mass selection + straHelper.cascade.charge > 0 && + std::abs(posTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(bachTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lV0LengthTraveled / (lV0Ptot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + o2::constants::physics::MassXiMinus * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutXi") && + std::abs(straHelper.cascade.massXi - o2::constants::physics::MassXiMinus) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaXi(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskCascadePreselection, selXiPlus); + } + + if ( // OmegaMinus PID and mass selection + straHelper.cascade.charge < 0 && + std::abs(posTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(bachTrack.tpcNSigmaKa()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lV0LengthTraveled / (lV0Ptot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + o2::constants::physics::MassOmegaMinus * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutOmega") && + std::abs(straHelper.cascade.massOmega - o2::constants::physics::MassOmegaMinus) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaOmega(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskCascadePreselection, selOmegaMinus); + } + + if ( // OmegaPlus PID and mass selection + straHelper.cascade.charge > 0 && + std::abs(posTrack.tpcNSigmaPi()) < preSelectOpts.maxTPCpidNsigma && + std::abs(negTrack.tpcNSigmaPr()) < preSelectOpts.maxTPCpidNsigma && + std::abs(bachTrack.tpcNSigmaKa()) < preSelectOpts.maxTPCpidNsigma && + o2::constants::physics::MassLambda * lV0LengthTraveled / (lV0Ptot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutLambda") && + o2::constants::physics::MassOmegaMinus * lLengthTraveled / (lPtot + 1e-13) < preSelectOpts.lifetimeCut->get("lifetimeCutOmega") && + std::abs(straHelper.cascade.massOmega - o2::constants::physics::MassOmegaMinus) < preSelectOpts.massWindownumberOfSigmas * getMassSigmaOmega(lPt) + preSelectOpts.massWindowSafetyMargin) { + BITSET(maskCascadePreselection, selOmegaPlus); + } + + histos.fill(HIST("hPreselectionCascades"), maskCascadePreselection); + + if (maskCascadePreselection == 0) { + products.cascdataLink(-1); + interlinks.cascadeToCascCores.push_back(-1); + continue; + } + } + } + + // generate analysis tables as required + if (baseOpts.mEnabledTables[kCascIndices]) { + products.cascidx(cascade.globalId, + straHelper.cascade.positiveTrack, straHelper.cascade.negativeTrack, + straHelper.cascade.bachelorTrack, straHelper.cascade.collisionId); + histos.fill(HIST("hTableBuildingStatistics"), kCascIndices); + } + if (baseOpts.mEnabledTables[kStoredCascCores]) { + products.cascdata(straHelper.cascade.charge, straHelper.cascade.massXi, straHelper.cascade.massOmega, + straHelper.cascade.cascadePosition[0], straHelper.cascade.cascadePosition[1], straHelper.cascade.cascadePosition[2], + straHelper.cascade.v0Position[0], straHelper.cascade.v0Position[1], straHelper.cascade.v0Position[2], + straHelper.cascade.positiveMomentum[0], straHelper.cascade.positiveMomentum[1], straHelper.cascade.positiveMomentum[2], + straHelper.cascade.negativeMomentum[0], straHelper.cascade.negativeMomentum[1], straHelper.cascade.negativeMomentum[2], + straHelper.cascade.bachelorMomentum[0], straHelper.cascade.bachelorMomentum[1], straHelper.cascade.bachelorMomentum[2], + straHelper.cascade.cascadeMomentum[0], straHelper.cascade.cascadeMomentum[1], straHelper.cascade.cascadeMomentum[2], + straHelper.cascade.v0DaughterDCA, straHelper.cascade.cascadeDaughterDCA, + straHelper.cascade.positiveDCAxy, straHelper.cascade.negativeDCAxy, + straHelper.cascade.bachelorDCAxy, straHelper.cascade.cascadeDCAxy, straHelper.cascade.cascadeDCAz); + histos.fill(HIST("hTableBuildingStatistics"), kStoredCascCores); + + // interlink always produced if cascades generated + products.cascdataLink(products.cascdata.lastIndex()); + interlinks.cascCoreToCascades.push_back(cascade.globalId); + interlinks.cascadeToCascCores.push_back(products.cascdata.lastIndex()); + } + + if (baseOpts.mEnabledTables[kCascTrackXs]) { + products.cascTrackXs(straHelper.cascade.positiveTrackX, straHelper.cascade.negativeTrackX, straHelper.cascade.bachelorTrackX); + histos.fill(HIST("hTableBuildingStatistics"), kCascTrackXs); + } + if (baseOpts.mEnabledTables[kCascBBs]) { + products.cascbb(straHelper.cascade.bachBaryonCosPA, straHelper.cascade.bachBaryonDCAxyToPV); + histos.fill(HIST("hTableBuildingStatistics"), kCascBBs); + } + if (baseOpts.mEnabledTables[kCascCovs]) { + products.casccovs(straHelper.cascade.covariance); + histos.fill(HIST("hTableBuildingStatistics"), kCascCovs); + } + + //_________________________________________________________ + // MC handling part + if constexpr (soa::is_table) { + // only worry about this if someone else worried about this + if ((baseOpts.mEnabledTables[kCascMCCores] || baseOpts.mEnabledTables[kMcCascLabels] || baseOpts.mEnabledTables[kCascMCCollRefs])) { + extractMonteCarloProperties(posTrack, negTrack, bachTrack, mcParticles); + + // Construct label table (note: this will be joinable with CascDatas) + if (baseOpts.mEnabledTables[kMcCascLabels]) { + products.casclabels( + thisCascInfo.label, thisCascInfo.motherLabel); + histos.fill(HIST("hTableBuildingStatistics"), kMcCascLabels); + } + + // Construct found tag + if (baseOpts.mEnabledTables[kCascFoundTags]) { + products.cascFoundTag(cascade.found); + histos.fill(HIST("hTableBuildingStatistics"), kCascFoundTags); + } + + // Mark mcParticle as recoed (no searching necessary afterwards) + if (thisCascInfo.label > -1) { + mcParticleIsReco[thisCascInfo.label] = true; + } + + if (cascadeBuilderOpts.mc_populateCascMCCoresSymmetric) { + if (baseOpts.mEnabledTables[kCascMCCores]) { + products.cascmccores( + thisCascInfo.pdgCode, thisCascInfo.pdgCodeMother, thisCascInfo.pdgCodeV0, thisCascInfo.isPhysicalPrimary, + thisCascInfo.pdgCodePositive, thisCascInfo.pdgCodeNegative, thisCascInfo.pdgCodeBachelor, + thisCascInfo.xyz[0], thisCascInfo.xyz[1], thisCascInfo.xyz[2], + thisCascInfo.lxyz[0], thisCascInfo.lxyz[1], thisCascInfo.lxyz[2], + thisCascInfo.posP[0], thisCascInfo.posP[1], thisCascInfo.posP[2], + thisCascInfo.negP[0], thisCascInfo.negP[1], thisCascInfo.negP[2], + thisCascInfo.bachP[0], thisCascInfo.bachP[1], thisCascInfo.bachP[2], + thisCascInfo.momentum[0], thisCascInfo.momentum[1], thisCascInfo.momentum[2]); + histos.fill(HIST("hTableBuildingStatistics"), kCascMCCores); + } + if (baseOpts.mEnabledTables[kCascMCCollRefs]) { + products.cascmccollrefs(thisCascInfo.mcCollision); + histos.fill(HIST("hTableBuildingStatistics"), kCascMCCollRefs); + } + } + + if (cascadeBuilderOpts.mc_populateCascMCCoresAsymmetric) { + int thisCascMCCoreIndex = -1; + // step 1: check if this element is already provided in the table + // using the packedIndices variable calculated above + for (uint32_t ii = 0; ii < mcCascinfos.size(); ii++) { + if (thisCascInfo.label == mcCascinfos[ii].label && mcCascinfos[ii].label > -1) { + thisCascMCCoreIndex = ii; + break; // this exists already in list + } + } + if (thisCascMCCoreIndex < 0) { + // this CascMCCore does not exist yet. Create it and reference it + thisCascMCCoreIndex = mcCascinfos.size(); + mcCascinfos.push_back(thisCascInfo); + } + if (baseOpts.mEnabledTables[kCascCoreMCLabels]) { + products.cascCoreMClabels(thisCascMCCoreIndex); // interlink: reconstructed -> MC index + histos.fill(HIST("hTableBuildingStatistics"), kCascCoreMCLabels); + } + } + + } // enabled tables check + + // if BB tags requested, generate them now + if (baseOpts.mEnabledTables[kMcCascBBTags]) { + bool bbTag = false; + if (bachTrack.has_mcParticle()) { + auto bachelorParticle = bachTrack.template mcParticle_as(); + if (bachelorParticle.pdgCode() == 211) { // pi+, look for antiproton in negative prong + if (negTrack.has_mcParticle()) { + auto baryonParticle = negTrack.template mcParticle_as(); + if (baryonParticle.has_mothers() && bachelorParticle.has_mothers() && baryonParticle.pdgCode() == -2212) { + for (const auto& baryonMother : baryonParticle.template mothers_as()) { + for (const auto& pionMother : bachelorParticle.template mothers_as()) { + if (baryonMother.globalIndex() == pionMother.globalIndex() && baryonMother.pdgCode() == -3122) { + bbTag = true; + } + } + } + } + } + } // end if-pion + if (bachelorParticle.pdgCode() == -211) { // pi-, look for proton in positive prong + if (posTrack.has_mcParticle()) { + auto baryonParticle = posTrack.template mcParticle_as(); + if (baryonParticle.has_mothers() && bachelorParticle.has_mothers() && baryonParticle.pdgCode() == 2212) { + for (const auto& baryonMother : baryonParticle.template mothers_as()) { + for (const auto& pionMother : bachelorParticle.template mothers_as()) { + if (baryonMother.globalIndex() == pionMother.globalIndex() && baryonMother.pdgCode() == 3122) { + bbTag = true; + } + } + } + } + } + } // end if-pion + } // end bachelor has mcparticle + // Construct label table (note: this will be joinable with CascDatas) + products.bbtags(bbTag); + histos.fill(HIST("hTableBuildingStatistics"), kMcCascBBTags); + } // end BB tag table enabled check + + } // constexpr requires mcParticles check + } // cascades loop + + //_________________________________________________________ + // MC handling part + if constexpr (soa::is_table) { + if ((baseOpts.mEnabledTables[kCascMCCores] || baseOpts.mEnabledTables[kMcCascLabels] || baseOpts.mEnabledTables[kCascMCCollRefs])) { + // now populate V0MCCores if in asymmetric mode + if (cascadeBuilderOpts.mc_populateCascMCCoresAsymmetric) { + // first step: add any un-recoed v0mmcores that were requested + for (const auto& mcParticle : mcParticles) { + thisCascInfo.pdgCode = -1, thisCascInfo.pdgCodeMother = -1; + thisCascInfo.pdgCodePositive = -1, thisCascInfo.pdgCodeNegative = -1; + thisCascInfo.pdgCodeBachelor = -1, thisCascInfo.pdgCodeV0 = -1; + thisCascInfo.isPhysicalPrimary = false; + thisCascInfo.xyz[0] = 0.0f, thisCascInfo.xyz[1] = 0.0f, thisCascInfo.xyz[2] = 0.0f; + thisCascInfo.lxyz[0] = 0.0f, thisCascInfo.lxyz[1] = 0.0f, thisCascInfo.lxyz[2] = 0.0f; + thisCascInfo.posP[0] = 0.0f, thisCascInfo.posP[1] = 0.0f, thisCascInfo.posP[2] = 0.0f; + thisCascInfo.negP[0] = 0.0f, thisCascInfo.negP[1] = 0.0f, thisCascInfo.negP[2] = 0.0f; + thisCascInfo.bachP[0] = 0.0f, thisCascInfo.bachP[1] = 0.0f, thisCascInfo.bachP[2] = 0.0f; + thisCascInfo.momentum[0] = 0.0f, thisCascInfo.momentum[1] = 0.0f, thisCascInfo.momentum[2] = 0.0f; + thisCascInfo.label = -1, thisCascInfo.motherLabel = -1; + thisCascInfo.mcParticlePositive = -1; + thisCascInfo.mcParticleNegative = -1; + thisCascInfo.mcParticleBachelor = -1; + + if (mcParticleIsReco[mcParticle.globalIndex()] == true) + continue; // skip if already created in list + + if (std::fabs(mcParticle.y()) > cascadeBuilderOpts.mc_rapidityWindow) + continue; // skip outside midrapidity + + if (cascadeBuilderOpts.mc_keepOnlyPhysicalPrimary && !mcParticle.isPhysicalPrimary()) + continue; // skip secondary MC cascades + + if ( + (cascadeBuilderOpts.mc_addGeneratedXiMinus && mcParticle.pdgCode() == 3312) || + (cascadeBuilderOpts.mc_addGeneratedXiPlus && mcParticle.pdgCode() == -3312) || + (cascadeBuilderOpts.mc_addGeneratedOmegaMinus && mcParticle.pdgCode() == 3334) || + (cascadeBuilderOpts.mc_addGeneratedOmegaPlus && mcParticle.pdgCode() == -3334)) { + thisCascInfo.pdgCode = mcParticle.pdgCode(); + thisCascInfo.isPhysicalPrimary = mcParticle.isPhysicalPrimary(); + + if (mcParticle.has_mcCollision()) { + thisCascInfo.mcCollision = mcParticle.mcCollisionId(); // save this reference, please + } + thisCascInfo.momentum[0] = mcParticle.px(); + thisCascInfo.momentum[1] = mcParticle.py(); + thisCascInfo.momentum[2] = mcParticle.pz(); + thisCascInfo.label = mcParticle.globalIndex(); + + if (mcParticle.has_daughters()) { + auto const& daughters = mcParticle.template daughters_as(); + for (const auto& dau : daughters) { + if (dau.getProcess() != 4) // check whether the daughter comes from a decay + continue; + + if (std::abs(dau.pdgCode()) == 211 || std::abs(dau.pdgCode()) == 321) { + thisCascInfo.pdgCodeBachelor = dau.pdgCode(); + thisCascInfo.bachP[0] = dau.px(); + thisCascInfo.bachP[1] = dau.py(); + thisCascInfo.bachP[2] = dau.pz(); + thisCascInfo.xyz[0] = dau.vx(); + thisCascInfo.xyz[1] = dau.vy(); + thisCascInfo.xyz[2] = dau.vz(); + thisCascInfo.mcParticleBachelor = dau.globalIndex(); + } + if (std::abs(dau.pdgCode()) == 2212) { + thisCascInfo.pdgCodeV0 = dau.pdgCode(); + + for (const auto& v0Dau : dau.template daughters_as()) { + if (v0Dau.getProcess() != 4) + continue; + + if (v0Dau.pdgCode() > 0) { + thisCascInfo.pdgCodePositive = v0Dau.pdgCode(); + thisCascInfo.processPositive = v0Dau.getProcess(); + thisCascInfo.posP[0] = v0Dau.px(); + thisCascInfo.posP[1] = v0Dau.py(); + thisCascInfo.posP[2] = v0Dau.pz(); + thisCascInfo.lxyz[0] = v0Dau.vx(); + thisCascInfo.lxyz[1] = v0Dau.vy(); + thisCascInfo.lxyz[2] = v0Dau.vz(); + thisCascInfo.mcParticlePositive = v0Dau.globalIndex(); + } + if (v0Dau.pdgCode() < 0) { + thisCascInfo.pdgCodeNegative = v0Dau.pdgCode(); + thisCascInfo.processNegative = v0Dau.getProcess(); + thisCascInfo.negP[0] = v0Dau.px(); + thisCascInfo.negP[1] = v0Dau.py(); + thisCascInfo.negP[2] = v0Dau.pz(); + thisCascInfo.mcParticleNegative = v0Dau.globalIndex(); + } + } + } + } + } + + // if I got here, it means this MC particle was not recoed and is of interest. Add it please + mcCascinfos.push_back(thisCascInfo); + } + } + + for (const auto& thisInfoToFill : mcCascinfos) { + if (baseOpts.mEnabledTables[kCascMCCores]) { + products.cascmccores( // a lot of the info below will be compressed in case of not-recoed MC (good!) + thisInfoToFill.pdgCode, thisInfoToFill.pdgCodeMother, thisInfoToFill.pdgCodeV0, thisInfoToFill.isPhysicalPrimary, + thisInfoToFill.pdgCodePositive, thisInfoToFill.pdgCodeNegative, thisInfoToFill.pdgCodeBachelor, + thisInfoToFill.xyz[0], thisInfoToFill.xyz[1], thisInfoToFill.xyz[2], + thisInfoToFill.lxyz[0], thisInfoToFill.lxyz[1], thisInfoToFill.lxyz[2], + thisInfoToFill.posP[0], thisInfoToFill.posP[1], thisInfoToFill.posP[2], + thisInfoToFill.negP[0], thisInfoToFill.negP[1], thisInfoToFill.negP[2], + thisInfoToFill.bachP[0], thisInfoToFill.bachP[1], thisInfoToFill.bachP[2], + thisInfoToFill.momentum[0], thisInfoToFill.momentum[1], thisInfoToFill.momentum[2]); + histos.fill(HIST("hTableBuildingStatistics"), kCascMCCores); + } + if (baseOpts.mEnabledTables[kCascMCCollRefs]) { + products.cascmccollrefs(thisInfoToFill.mcCollision); + histos.fill(HIST("hTableBuildingStatistics"), kCascMCCollRefs); + } + } + } + } // enabled tables check + } // constexpr requires mcParticles check + + LOGF(debug, "Cascades in DF: %i, cascades built: %i", cascades.size(), nCascades); + } + + //__________________________________________________ + template + void buildKFCascades(THistoRegistry& histos, TCollisions const& collisions, TCascades const& cascades, TTracks const& tracks, TMCParticles const& mcParticles, TProducts& products) + { + if (!baseOpts.mEnabledTables[kStoredKFCascCores]) { + return; // don't do if no request for cascades in place + } + int nCascades = 0; + // Loops over all cascades in the time frame + histos.fill(HIST("hInputStatistics"), kStoredKFCascCores, cascades.size()); + for (size_t icascade = 0; icascade < cascades.size(); icascade++) { + // Get tracks and generate candidate + auto const& cascade = cascades[sorted_cascade[icascade]]; + // if collisionId positive: get vertex, negative: origin + // could be replaced by mean vertex (but without much benefit...) + float pvX = 0.0f, pvY = 0.0f, pvZ = 0.0f; + if (cascade.collisionId >= 0) { + auto const& collision = collisions.rawIteratorAt(cascade.collisionId); + pvX = collision.posX(); + pvY = collision.posY(); + pvZ = collision.posZ(); + } + auto const& posTrack = tracks.rawIteratorAt(cascade.posTrackId); + auto const& negTrack = tracks.rawIteratorAt(cascade.negTrackId); + auto const& bachTrack = tracks.rawIteratorAt(cascade.bachTrackId); + if (!straHelper.buildCascadeCandidateWithKF(cascade.collisionId, pvX, pvY, pvZ, + posTrack, + negTrack, + bachTrack, + baseOpts.mEnabledTables[kCascBBs], + cascadeBuilderOpts.kfConstructMethod, + cascadeBuilderOpts.kfTuneForOmega, + cascadeBuilderOpts.kfUseV0MassConstraint, + cascadeBuilderOpts.kfUseCascadeMassConstraint, + cascadeBuilderOpts.kfDoDCAFitterPreMinimV0, + cascadeBuilderOpts.kfDoDCAFitterPreMinimCasc)) { + products.kfcascdataLink(-1); + interlinks.cascadeToKFCascCores.push_back(-1); + continue; // didn't work out, skip + } + nCascades++; + + // generate analysis tables as required + if (baseOpts.mEnabledTables[kKFCascIndices]) { + products.kfcascidx(cascade.globalId, + straHelper.cascade.positiveTrack, straHelper.cascade.negativeTrack, + straHelper.cascade.bachelorTrack, straHelper.cascade.collisionId); + histos.fill(HIST("hTableBuildingStatistics"), kKFCascIndices); + } + if (baseOpts.mEnabledTables[kStoredKFCascCores]) { + products.kfcascdata(straHelper.cascade.charge, straHelper.cascade.massXi, straHelper.cascade.massOmega, + straHelper.cascade.cascadePosition[0], straHelper.cascade.cascadePosition[1], straHelper.cascade.cascadePosition[2], + straHelper.cascade.v0Position[0], straHelper.cascade.v0Position[1], straHelper.cascade.v0Position[2], + straHelper.cascade.positivePosition[0], straHelper.cascade.positivePosition[1], straHelper.cascade.positivePosition[2], + straHelper.cascade.negativePosition[0], straHelper.cascade.negativePosition[1], straHelper.cascade.negativePosition[2], + straHelper.cascade.positiveMomentum[0], straHelper.cascade.positiveMomentum[1], straHelper.cascade.positiveMomentum[2], + straHelper.cascade.negativeMomentum[0], straHelper.cascade.negativeMomentum[1], straHelper.cascade.negativeMomentum[2], + straHelper.cascade.bachelorMomentum[0], straHelper.cascade.bachelorMomentum[1], straHelper.cascade.bachelorMomentum[2], + straHelper.cascade.v0Momentum[0], straHelper.cascade.v0Momentum[1], straHelper.cascade.v0Momentum[2], + straHelper.cascade.cascadeMomentum[0], straHelper.cascade.cascadeMomentum[1], straHelper.cascade.cascadeMomentum[2], + straHelper.cascade.v0DaughterDCA, straHelper.cascade.cascadeDaughterDCA, + straHelper.cascade.positiveDCAxy, straHelper.cascade.negativeDCAxy, + straHelper.cascade.bachelorDCAxy, straHelper.cascade.cascadeDCAxy, straHelper.cascade.cascadeDCAz, + straHelper.cascade.kfMLambda, straHelper.cascade.kfV0Chi2, straHelper.cascade.kfCascadeChi2); + histos.fill(HIST("hTableBuildingStatistics"), kStoredKFCascCores); + + // interlink always produced if cascades generated + products.kfcascdataLink(products.kfcascdata.lastIndex()); + interlinks.kfCascCoreToCascades.push_back(cascade.globalId); + interlinks.cascadeToKFCascCores.push_back(products.kfcascdata.lastIndex()); + } + if (baseOpts.mEnabledTables[kKFCascCovs]) { + products.kfcasccovs(straHelper.cascade.covariance, straHelper.cascade.kfTrackCovarianceV0, straHelper.cascade.kfTrackCovariancePos, straHelper.cascade.kfTrackCovarianceNeg); + histos.fill(HIST("hTableBuildingStatistics"), kKFCascCovs); + } + + //_________________________________________________________ + // MC handling part (labels only) + if constexpr (soa::is_table) { + // only worry about this if someone else worried about this + if ((baseOpts.mEnabledTables[kMcKFCascLabels])) { + extractMonteCarloProperties(posTrack, negTrack, bachTrack, mcParticles); + + // Construct label table (note: this will be joinable with KFCascDatas) + products.kfcasclabels(thisCascInfo.label); + histos.fill(HIST("hTableBuildingStatistics"), kMcKFCascLabels); + } // enabled tables check + } // constexpr requires mcParticles check + } // end loop over cascades + + LOGF(debug, "KF Cascades in DF: %i, KF cascades built: %i", cascades.size(), nCascades); + } + + //__________________________________________________ + template + void buildTrackedCascades(THistoRegistry& histos, TCollisions const& collisions, TStrangeTracks const& cascadeTracks, TMCParticles const& mcParticles, TProducts& products) + { + if (!baseOpts.mEnabledTables[kStoredTraCascCores] || baseOpts.mc_findableMode.value != 0) { + return; // don't do if no request for cascades in place or findable mode used + } + int nCascades = 0; + // Loops over all V0s in the time frame + histos.fill(HIST("hInputStatistics"), kStoredTraCascCores, cascadeTracks.size()); + for (const auto& cascadeTrack : cascadeTracks) { + // Get tracks and generate candidate + if (!cascadeTrack.has_track()) + continue; // safety (should be fine but depends on future stratrack dev) + + auto const& strangeTrack = cascadeTrack.template track_as(); + + // if collisionId positive: get vertex, negative: origin + // could be replaced by mean vertex (but without much benefit...) + float pvX = 0.0f, pvY = 0.0f, pvZ = 0.0f; + if (strangeTrack.has_collision()) { + auto const& collision = collisions.rawIteratorAt(strangeTrack.collisionId()); + pvX = collision.posX(); + pvY = collision.posY(); + pvZ = collision.posZ(); + } + auto const& cascade = cascadeTrack.cascade(); + auto const& v0 = cascade.v0(); + auto const& posTrack = v0.template posTrack_as(); + auto const& negTrack = v0.template negTrack_as(); + auto const& bachTrack = cascade.template bachelor_as(); + if (!straHelper.buildCascadeCandidate(strangeTrack.collisionId(), pvX, pvY, pvZ, + posTrack, + negTrack, + bachTrack, + baseOpts.mEnabledTables[kCascBBs], + cascadeBuilderOpts.useCascadeMomentumAtPrimVtx, + baseOpts.mEnabledTables[kCascCovs])) { + products.tracascdataLink(-1); + interlinks.cascadeToTraCascCores.push_back(-1); + continue; // didn't work out, skip + } + + // recalculate DCAxy, DCAz with strange track + auto strangeTrackParCov = getTrackParCov(strangeTrack); + std::array dcaInfo; + strangeTrackParCov.setPID(o2::track::PID::XiMinus); // FIXME: not OK for omegas + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, strangeTrackParCov, 2.f, straHelper.fitter.getMatCorrType(), &dcaInfo); + straHelper.cascade.cascadeDCAxy = dcaInfo[0]; + straHelper.cascade.cascadeDCAz = dcaInfo[1]; + + // get momentum from strange track (should not be very different) + strangeTrackParCov.getPxPyPzGlo(straHelper.cascade.cascadeMomentum); + + // accounting + nCascades++; + + // generate analysis tables as required + if (baseOpts.mEnabledTables[kTraCascIndices]) { + products.tracascidx(cascade.globalIndex(), + straHelper.cascade.positiveTrack, straHelper.cascade.negativeTrack, + straHelper.cascade.bachelorTrack, cascadeTrack.trackId(), straHelper.cascade.collisionId); + histos.fill(HIST("hTableBuildingStatistics"), kTraCascIndices); + } + if (baseOpts.mEnabledTables[kStoredTraCascCores]) { + products.tracascdata(straHelper.cascade.charge, cascadeTrack.xiMass(), cascadeTrack.omegaMass(), + cascadeTrack.decayX(), cascadeTrack.decayY(), cascadeTrack.decayZ(), + straHelper.cascade.v0Position[0], straHelper.cascade.v0Position[1], straHelper.cascade.v0Position[2], + straHelper.cascade.positiveMomentum[0], straHelper.cascade.positiveMomentum[1], straHelper.cascade.positiveMomentum[2], + straHelper.cascade.negativeMomentum[0], straHelper.cascade.negativeMomentum[1], straHelper.cascade.negativeMomentum[2], + straHelper.cascade.bachelorMomentum[0], straHelper.cascade.bachelorMomentum[1], straHelper.cascade.bachelorMomentum[2], + straHelper.cascade.cascadeMomentum[0], straHelper.cascade.cascadeMomentum[1], straHelper.cascade.cascadeMomentum[2], + straHelper.cascade.v0DaughterDCA, straHelper.cascade.cascadeDaughterDCA, + straHelper.cascade.positiveDCAxy, straHelper.cascade.negativeDCAxy, + straHelper.cascade.bachelorDCAxy, straHelper.cascade.cascadeDCAxy, straHelper.cascade.cascadeDCAz, + cascadeTrack.matchingChi2(), cascadeTrack.topologyChi2(), cascadeTrack.itsClsSize()); + histos.fill(HIST("hTableBuildingStatistics"), kStoredTraCascCores); + + // interlink always produced if base core table generated + products.tracascdataLink(products.tracascdata.lastIndex()); + interlinks.traCascCoreToCascades.push_back(cascade.globalIndex()); + interlinks.cascadeToTraCascCores.push_back(products.tracascdata.lastIndex()); + } + if (baseOpts.mEnabledTables[kCascCovs]) { + std::array traCovMat = {0.}; + strangeTrackParCov.getCovXYZPxPyPzGlo(traCovMat); + float traCovMatArray[21]; + for (int ii = 0; ii < 21; ii++) { + traCovMatArray[ii] = traCovMat[ii]; + } + products.tracasccovs(traCovMatArray); + histos.fill(HIST("hTableBuildingStatistics"), kCascCovs); + } + + //_________________________________________________________ + // MC handling part (labels only) + if constexpr (soa::is_table) { + // only worry about this if someone else worried about this + if ((baseOpts.mEnabledTables[kMcTraCascLabels])) { + extractMonteCarloProperties(posTrack, negTrack, bachTrack, mcParticles); + + // Construct label table (note: this will be joinable with KFCascDatas) + products.tracasclabels(thisCascInfo.label); + histos.fill(HIST("hTableBuildingStatistics"), kMcTraCascLabels); + } // enabled tables check + } // constexpr requires mcParticles check + } // end loop over cascades + LOGF(debug, "Tracked cascades in DF: %i, tracked cascades built: %i", cascadeTracks.size(), nCascades); + } + + //__________________________________________________ + // MC kink handling + template + int getOriginatingParticle(mcpart const& part, int& indexForPositionOfDecay, bool treatPiToMuDecays) + { + int returnValue = -1; + if (part.has_mothers()) { + auto const& motherList = part.template mothers_as(); + if (motherList.size() == 1) { + for (const auto& mother : motherList) { + if (std::abs(part.pdgCode()) == 13 && treatPiToMuDecays) { + // muon decay, de-ref mother twice + if (mother.has_mothers()) { + auto grandMotherList = mother.template mothers_as(); + if (grandMotherList.size() == 1) { + for (const auto& grandMother : grandMotherList) { + returnValue = grandMother.globalIndex(); + indexForPositionOfDecay = mother.globalIndex(); // for V0 decay position: grab muon + } + } + } + } else { + returnValue = mother.globalIndex(); + indexForPositionOfDecay = part.globalIndex(); + } + } + } + } + return returnValue; + } + + //__________________________________________________ + template + void dataProcess(TCCDB& ccdb, THistoRegistry& histos, TCollisions const& collisions, TMCCollisions const& mccollisions, TV0s const& v0s, TCascades const& cascades, TTrackedCascades const& trackedCascades, TTracks const& tracks, TBCs const& bcs, TMCParticles const& mcParticles, TProducts& products) + { + if (nEnabledTables == 0) { + return; // fully suppressed + } + + if (!initCCDB(ccdb, bcs, collisions)) + return; + + // reset vectors for cascade interlinks + resetInterlinks(); + + // prepare v0List, cascadeList + prepareBuildingLists(histos, collisions, mccollisions, v0s, cascades, tracks, mcParticles); + + // mark V0s that will be buffered for the cascade building + markV0sUsedInCascades(v0List, cascadeList, trackedCascades); + + // build V0s + buildV0s(histos, collisions, v0List, tracks, mcParticles, products); + + // build cascades + buildCascades(histos, collisions, cascadeList, tracks, mcParticles, products); + buildKFCascades(histos, collisions, cascadeList, tracks, mcParticles, products); + + // build tracked cascades only if subscription is Run 3 like (doesn't exist in Run 2) + if constexpr (soa::is_table) { + buildTrackedCascades(histos, collisions, trackedCascades, mcParticles, products); + } + + populateCascadeInterlinks(); + } +}; // end BuilderModule + +} // namespace strangenessbuilder +} // namespace pwglf +} // namespace o2 + +#endif // PWGLF_UTILS_STRANGENESSBUILDERMODULE_H_ diff --git a/PWGLF/Utils/strangenessMasks.h b/PWGLF/Utils/strangenessMasks.h index 7b567218de6..dbf84deacd6 100644 --- a/PWGLF/Utils/strangenessMasks.h +++ b/PWGLF/Utils/strangenessMasks.h @@ -1,4 +1,4 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// 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. // @@ -8,14 +8,15 @@ // 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. -/// +// +/// \file strangenessMasks.h +/// \brief Defines selection criteria and bit masks for identifying v0 and cascade particles /// \author Roman Nepeivoda (roman.nepeivoda@cern.ch) -/// \since August 27, 2024 #ifndef PWGLF_UTILS_STRANGENESSMASKS_H_ #define PWGLF_UTILS_STRANGENESSMASKS_H_ -enum selectionsCombined : int { selV0CosPA = 0, +enum SelectionsCombined : int { selV0CosPA = 0, selV0Radius, selV0RadiusMax, selDCANegToPV, @@ -58,6 +59,7 @@ enum selectionsCombined : int { selV0CosPA = 0, selPhysPrimAntiLambda, // for mc tagging selPosEta, selNegEta, + selDauDCA, // cascade selections selCascCosPA, selMassWinXi, @@ -115,36 +117,43 @@ enum selectionsCombined : int { selV0CosPA = 0, selCount, }; -static constexpr int selNum = static_cast(selectionsCombined::selCount); +static constexpr int kSelNum = static_cast(SelectionsCombined::selCount); + +// constants in cm +const float ctauxiPDG = 4.91; +const float ctauomegaPDG = 2.46; -// constants -const float ctauxiPDG = 4.91; // from PDG -const float ctauomegaPDG = 2.461; // from PDG +const float ctauk0shortPDG = 2.68; +const float ctaulambdaPDG = 7.85; // bit masks -std::bitset maskTopologicalV0; -std::bitset maskTopologicalCasc; +std::bitset maskTopologicalV0; +std::bitset maskTopologicalCasc; + +std::bitset maskKinematicV0; +std::bitset maskKinematicCasc; + +std::bitset maskTrackPropertiesV0; +std::bitset maskTrackPropertiesCasc; -std::bitset maskKinematicV0; -std::bitset maskKinematicCasc; +std::bitset maskK0ShortSpecific; +std::bitset maskLambdaSpecific; +std::bitset maskAntiLambdaSpecific; +std::bitset maskXiSpecific; +std::bitset maskAntiXiSpecific; +std::bitset maskOmegaSpecific; +std::bitset maskAntiOmegaSpecific; -std::bitset maskTrackPropertiesV0; -std::bitset maskTrackPropertiesCasc; +std::bitset maskSelectionK0Short; +std::bitset maskSelectionLambda; +std::bitset maskSelectionAntiLambda; -std::bitset maskK0ShortSpecific; -std::bitset maskLambdaSpecific; -std::bitset maskAntiLambdaSpecific; -std::bitset maskXiSpecific; -std::bitset maskAntiXiSpecific; -std::bitset maskOmegaSpecific; -std::bitset maskAntiOmegaSpecific; +std::bitset secondaryMaskSelectionLambda; +std::bitset secondaryMaskSelectionAntiLambda; -std::bitset maskSelectionK0Short; -std::bitset maskSelectionLambda; -std::bitset maskSelectionAntiLambda; -std::bitset maskSelectionXi; -std::bitset maskSelectionAntiXi; -std::bitset maskSelectionOmega; -std::bitset maskSelectionAntiOmega; +std::bitset maskSelectionXi; +std::bitset maskSelectionAntiXi; +std::bitset maskSelectionOmega; +std::bitset maskSelectionAntiOmega; #endif // PWGLF_UTILS_STRANGENESSMASKS_H_ diff --git a/PWGLF/Utils/svPoolCreator.h b/PWGLF/Utils/svPoolCreator.h index 2414eb7e19b..c0b32c2574e 100644 --- a/PWGLF/Utils/svPoolCreator.h +++ b/PWGLF/Utils/svPoolCreator.h @@ -73,20 +73,20 @@ class svPoolCreator o2::vertexing::DCAFitterN<2>* getFitter() { return &fitter; } std::array, 4> getTrackCandPool() { return trackCandPool; } - template - void fillBC2Coll(const C& collisions, aod::BCsWithTimestamps const&) + template + void fillBC2Coll(const C& collisions, BC const&) { for (unsigned i = 0; i < collisions.size(); i++) { auto collision = collisions.rawIteratorAt(i); if (!collision.has_bc()) { continue; } - bc2Coll[collision.template bc_as().globalBC()] = i; + bc2Coll[collision.template bc_as().globalBC()] = i; } } - template - void appendTrackCand(const T& trackCand, const C& collisions, int pdgHypo, o2::aod::AmbiguousTracks const& ambiTracks, aod::BCsWithTimestamps const&) + template + void appendTrackCand(const T& trackCand, const C& collisions, int pdgHypo, o2::aod::AmbiguousTracks const& ambiTracks, BC const&) { if (pdgHypo != track0Pdg && pdgHypo != track1Pdg) { LOG(debug) << "Wrong pdg hypothesis"; @@ -97,18 +97,18 @@ class svPoolCreator uint64_t globalBC = BcInvalid; if (trackCand.has_collision()) { if (trackCand.template collision_as().has_bc()) { - globalBC = trackCand.template collision_as().template bc_as().globalBC(); + globalBC = trackCand.template collision_as().template bc_as().globalBC(); } } else if (!skipAmbiTracks) { for (const auto& ambTrack : ambiTracks) { if (ambTrack.trackId() != trackCand.globalIndex()) { continue; } - if (!ambTrack.has_bc() || ambTrack.bc_as().size() == 0) { + if (!ambTrack.has_bc() || ambTrack.bc_as().size() == 0) { globalBC = BcInvalid; break; } - globalBC = ambTrack.bc_as().begin().globalBC(); + globalBC = ambTrack.bc_as().begin().globalBC(); break; } } else { @@ -129,12 +129,16 @@ class svPoolCreator } firstBC++; } + if (firstCollIdx == -1) { + return; + } + // now loop over all the collisions to make the pool for (int i = firstCollIdx; i < collisions.size(); i++) { const auto& collision = collisions.rawIteratorAt(i); float collTime = collision.collisionTime(); float collTimeRes2 = collision.collisionTimeRes() * collision.collisionTimeRes(); - uint64_t collBC = collision.template bc_as().globalBC(); + uint64_t collBC = collision.template bc_as().globalBC(); int collIdx = collision.globalIndex(); int64_t bcOffset = globalBC - static_cast(collBC); if (static_cast(std::abs(bcOffset)) > bOffsetMax) { diff --git a/PWGMM/Lumi/Tasks/lumiStability.cxx b/PWGMM/Lumi/Tasks/lumiStability.cxx index 0c8e818fced..5938ec42cdd 100644 --- a/PWGMM/Lumi/Tasks/lumiStability.cxx +++ b/PWGMM/Lumi/Tasks/lumiStability.cxx @@ -52,14 +52,17 @@ struct LumiStabilityTask { Configurable nOrbitsPerTF{"nOrbitsPerTF", 128, "number of orbits per time frame"}; Configurable minOrbitConf{"minOrbitConf", 0, "minimum orbit"}; Configurable is2022Data{"is2022Data", true, "To 2022 data"}; + Configurable minEmpty{"minEmpty", 5, "number of BCs empty for leading BC"}; Service ccdb; int nBCsPerOrbit = 3564; int lastRunNumber = -1; int nOrbits = nOrbitsConf; double minOrbit = minOrbitConf; - int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 by default for unanchored MC - int64_t nBCsPerTF = 128 * nBCsPerOrbit; // duration of TF in bcs, should be 128*3564 or 32*3564, setting 128 orbits by default sfor unanchored MC + int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 by default for unanchored MC + int64_t tsSOR; + int64_t tsEOR; + int64_t nBCsPerTF = nOrbitsPerTF * nBCsPerOrbit; // duration of TF in bcs, should be 128*3564 or 32*3564, setting 128 orbits by default sfor unanchored MC std::bitset beamPatternA; std::bitset beamPatternC; std::bitset bcPatternA; @@ -75,59 +78,63 @@ struct LumiStabilityTask { const AxisSpec axisCounts{6, -0.5, 5.5}; const AxisSpec axisV0Counts{5, -0.5, 4.5}; - const AxisSpec axisTriggger{nBCsPerOrbit, -0.5f, nBCsPerOrbit - 0.5f}; + const AxisSpec axisTrigger{nBCsPerOrbit, -0.5f, nBCsPerOrbit - 0.5f}; const AxisSpec axisPos{1000, -1, 1}; const AxisSpec axisPosZ{1000, -25, 25}; const AxisSpec axisNumContrib{1001, -0.5, 1000}; - const AxisSpec axisColisionTime{1000, -50, 50}; + const AxisSpec axisCollisionTime{1000, -50, 50}; const AxisSpec axisTime{1000, -10, 40}; const AxisSpec axisTimeFDD{1000, -20, 100}; const AxisSpec axisCountsTime{2, -0.5, 1.5}; const AxisSpec axisOrbits{static_cast(nOrbits / nOrbitsPerTF), 0., static_cast(nOrbits), ""}; - const AxisSpec axisTimeRate{1440, 0., 86400, ""}; // t in seconds. Histo for 24 hrs. Each bin contain 1 min. + const AxisSpec axisTimeRate{int(double(43200) / (nOrbitsPerTF * 89e-6)), 0., 43200, ""}; // t in seconds. Histo for 12 hrs. Each bin contain one time frame (128/32 orbits for Run2/3). - histos.add("hBcA", "BC pattern A; BC ; It is present", kTH1F, {axisTriggger}); - histos.add("hBcC", "BC pattern C; BC ; It is present", kTH1F, {axisTriggger}); - histos.add("hBcB", "BC pattern B; BC ; It is present", kTH1F, {axisTriggger}); - histos.add("hBcE", "BC pattern Empty; BC ; It is present", kTH1F, {axisTriggger}); + histos.add("hBcA", "BC pattern A; BC ; It is present", kTH1F, {axisTrigger}); + histos.add("hBcC", "BC pattern C; BC ; It is present", kTH1F, {axisTrigger}); + histos.add("hBcB", "BC pattern B; BC ; It is present", kTH1F, {axisTrigger}); + histos.add("hBcBL", "BC pattern B - Leading BC; BC ; It is present", kTH1F, {axisTrigger}); + histos.add("hBcE", "BC pattern Empty; BC ; It is present", kTH1F, {axisTrigger}); histos.add("hvertexX", "Pos X vertex trigger; Pos x; Count ", kTH1F, {axisPos}); - histos.add("hvertexXvsTime", "Pos X vertex vs Collision Time; vertex X (cm) ; time (ns)", {HistType::kTH2F, {{axisPos}, {axisColisionTime}}}); + histos.add("hvertexXvsTime", "Pos X vertex vs Collision Time; vertex X (cm) ; time (ns)", {HistType::kTH2F, {{axisPos}, {axisCollisionTime}}}); histos.add("hvertexY", "Pos Y vertex trigger; Pos y; Count ", kTH1F, {axisPos}); histos.add("hvertexZ", "Pos Z vertex trigger; Pos z; Count ", kTH1F, {axisPosZ}); histos.add("hnumContrib", "Num of contributors; Num of contributors; Count ", kTH1I, {axisNumContrib}); - histos.add("hcollisinTime", "Collision Time; ns; Count ", kTH1F, {axisColisionTime}); + histos.add("hcollisinTime", "Collision Time; ns; Count ", kTH1F, {axisCollisionTime}); histos.add("hOrbitFDDVertexCoinc", "", kTH1F, {axisOrbits}); histos.add("hOrbitFDDVertex", "", kTH1F, {axisOrbits}); histos.add("hOrbitFT0vertex", "", kTH1F, {axisOrbits}); histos.add("hOrbitFV0Central", "", kTH1F, {axisOrbits}); + histos.add("tsValues", "", kTH1D, {{2, -0.5, 1.5}}); // time 32.766 is dummy time // histo about triggers histos.add("FDD/hCounts", "0 FDDCount - 1 FDDVertexCount - 2 FDDPPVertexCount - 3 FDDCoincidencesVertexCount - 4 FDDPPCoincidencesVertexCount - 5 FDDPPBotSidesCount; Number; counts", kTH1F, {axisCounts}); - histos.add("FDD/bcVertexTrigger", "vertex trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcVertexTriggerPP", "vertex trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcVertexTriggerCoincidence", "vertex trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcVertexTriggerCoincidencePP", "vertex trigger per BC (FDD) with coincidences and Past Protection;BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcVertexTriggerBothSidesCoincidencePP", "vertex per BC (FDD) with coincidences, at least one side trigger and Past Protection;BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcSCentralTrigger", "scentral trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcSCentralTriggerCoincidence", "scentral trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcVSCTrigger", "vertex and scentral trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcVSCTriggerCoincidence", "vertex and scentral trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcCentralTrigger", "central trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcCentralTriggerCoincidence", "central trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcVCTrigger", "vertex and central trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/bcVCTriggerCoincidence", "vertex and central trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FDD/hBcAVertex", "BC pattern A in FDD; BC in FDD ; It is present", kTH1F, {axisTriggger}); - histos.add("FDD/hBcCVertex", "BC pattern C in FDD; BC in FDD ; It is present", kTH1F, {axisTriggger}); - histos.add("FDD/hBcBVertex", "BC pattern B in FDD; BC in FDD ; It is present", kTH1F, {axisTriggger}); - histos.add("FDD/hBcEVertex", "BC pattern Empty in FDD; BC in FDD ; It is present", kTH1F, {axisTriggger}); + histos.add("FDD/bcVertexTrigger", "vertex trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcVertexTriggerPP", "vertex trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcVertexTriggerCoincidence", "vertex trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcVertexTriggerCoincidencePP", "vertex trigger per BC (FDD) with coincidences and Past Protection;BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcVertexTriggerBothSidesCoincidencePP", "vertex per BC (FDD) with coincidences, at least one side trigger and Past Protection;BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcSCentralTrigger", "scentral trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcSCentralTriggerCoincidence", "scentral trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcVSCTrigger", "vertex and scentral trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcVSCTriggerCoincidence", "vertex and scentral trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcCentralTrigger", "central trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcCentralTriggerCoincidence", "central trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcVCTrigger", "vertex and central trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/bcVCTriggerCoincidence", "vertex and central trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FDD/hBcAVertex", "BC pattern A in FDD; BC in FDD ; It is present", kTH1F, {axisTrigger}); + histos.add("FDD/hBcCVertex", "BC pattern C in FDD; BC in FDD ; It is present", kTH1F, {axisTrigger}); + histos.add("FDD/hBcBVertex", "BC pattern B in FDD; BC in FDD ; It is present", kTH1F, {axisTrigger}); + histos.add("FDD/hBcBVertexL", "BC pattern B in FDD - Leading BC; BC in FDD ; It is present", kTH1F, {axisTrigger}); + histos.add("FDD/hBcEVertex", "BC pattern Empty in FDD; BC in FDD ; It is present", kTH1F, {axisTrigger}); histos.add("FDD/timeACbcBVertex", "time bcB ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); histos.add("FDD/timeACbcAVertex", "time bcA ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); histos.add("FDD/timeACbcCVertex", "time bcC ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); histos.add("FDD/timeACbcEVertex", "time bcE ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); - histos.add("FDD/hBcA", "BC pattern A in FDD; BC in FDD ; It is present", kTH1F, {axisTriggger}); - histos.add("FDD/hBcC", "BC pattern C in FDD; BC in FDD ; It is present", kTH1F, {axisTriggger}); - histos.add("FDD/hBcB", "BC pattern B in FDD; BC in FDD ; It is present", kTH1F, {axisTriggger}); - histos.add("FDD/hBcE", "BC pattern Empty in FDD; BC in FDD ; It is present", kTH1F, {axisTriggger}); + histos.add("FDD/hBcA", "BC pattern A in FDD; BC in FDD ; It is present", kTH1F, {axisTrigger}); + histos.add("FDD/hBcC", "BC pattern C in FDD; BC in FDD ; It is present", kTH1F, {axisTrigger}); + histos.add("FDD/hBcB", "BC pattern B in FDD; BC in FDD ; It is present", kTH1F, {axisTrigger}); + histos.add("FDD/hBcBL", "BC pattern B in FDD - Leading BC; BC in FDD ; It is present", kTH1F, {axisTrigger}); + histos.add("FDD/hBcE", "BC pattern Empty in FDD; BC in FDD ; It is present", kTH1F, {axisTrigger}); histos.add("FDD/timeACbcB", "time bcB ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); histos.add("FDD/timeACbcA", "time bcA ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); histos.add("FDD/timeACbcC", "time bcC ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); @@ -139,35 +146,37 @@ struct LumiStabilityTask { histos.add("FDD/hCountsTimeA2022", "0 Dummy Time - 1 Valid Time ; Kind of Time; counts", kTH1F, {axisCounts}); histos.add("FDD/hCountsTimeC2022", "0 Dummy Time - 1 Valid Time ; Kind of Time; counts", kTH1F, {axisCounts}); histos.add("FDD/hCountsTime2022", "0 Dummy Time - 1 Valid Time ; Kind of Time; counts", kTH1F, {axisCounts}); - histos.add("FDD/hValidTimeAvsBC2022", "Valid Time A vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hInvTimeAvsBC2022", "Invalid Time A vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hValidTimeCvsBC2022", "Valid Time C vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hInvTimeCvsBC2022", "Invalid Time C vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hValidTimevsBC2022", "Valid Time vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hInvTimevsBC2022", "Invalid Time vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger}); + histos.add("FDD/hValidTimeAvsBC2022", "Valid Time A vs BC id;BC in FT0;valid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hInvTimeAvsBC2022", "Invalid Time A vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hValidTimeCvsBC2022", "Valid Time C vs BC id;BC in FT0;valid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hInvTimeCvsBC2022", "Invalid Time C vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hValidTimevsBC2022", "Valid Time vs BC id;BC in FT0;valid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hInvTimevsBC2022", "Invalid Time vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTrigger}); histos.add("FDD/hCountsTimeA", "0 Dummy Time - 1 Valid Time ; Kind of Time; counts", kTH1F, {axisCounts}); histos.add("FDD/hCountsTimeC", "0 Dummy Time - 1 Valid Time ; Kind of Time; counts", kTH1F, {axisCounts}); histos.add("FDD/hCountsTime", "0 Dummy Time - 1 Valid Time ; Kind of Time; counts", kTH1F, {axisCounts}); - histos.add("FDD/hValidTimeAvsBC", "Valid Time A vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hInvTimeAvsBC", "Invalid Time A vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hValidTimeCvsBC", "Valid Time C vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hInvTimeCvsBC", "Invalid Time C vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hValidTimevsBC", "Valid Time vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger}); - histos.add("FDD/hInvTimevsBC", "Invalid Time vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger}); + histos.add("FDD/hValidTimeAvsBC", "Valid Time A vs BC id;BC in FT0;valid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hInvTimeAvsBC", "Invalid Time A vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hValidTimeCvsBC", "Valid Time C vs BC id;BC in FT0;valid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hInvTimeCvsBC", "Invalid Time C vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hValidTimevsBC", "Valid Time vs BC id;BC in FT0;valid time counts", kTH1F, {axisTrigger}); + histos.add("FDD/hInvTimevsBC", "Invalid Time vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTrigger}); histos.add("FDD/hTimeForRate", "Counts by time in FDD;t (in seconds) in FDD; counts", kTH1F, {axisTimeRate}); + histos.add("FDD/hTimeForRateLeadingBC", "Counts by time in FDD;t (in seconds) in FDD; counts", kTH1F, {axisTimeRate}); histos.add("FT0/hCounts", "0 FT0Count - 1 FT0VertexCount - 2 FT0PPVertexCount - 3 FT0PPBothSidesCount; Number; counts", kTH1F, {axisCounts}); - histos.add("FT0/bcVertexTrigger", "vertex trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); - histos.add("FT0/bcVertexTriggerPP", "vertex trigger per BC (FT0) with Past Protection;BC in FT0; counts", kTH1F, {axisTriggger}); - histos.add("FT0/bcVertexTriggerBothSidesPP", "vertex per BC (FDD) with coincidences, at least one side trigger and Past Protection;BC in FDD; counts", kTH1F, {axisTriggger}); - histos.add("FT0/bcSCentralTrigger", "Scentral trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); - histos.add("FT0/bcVSCTrigger", "vertex and Scentral trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); - histos.add("FT0/bcCentralTrigger", "central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); - histos.add("FT0/bcVCTrigger", "vertex and central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); - histos.add("FT0/hBcA", "BC pattern A in FT0; BC in FT0 ; It is present", kTH1F, {axisTriggger}); - histos.add("FT0/hBcC", "BC pattern C in FT0; BC in FT0 ; It is present", kTH1F, {axisTriggger}); - histos.add("FT0/hBcB", "BC pattern B in FT0; BC in FT0 ; It is present", kTH1F, {axisTriggger}); - histos.add("FT0/hBcE", "BC pattern Empty in FT0; BC in FT0 ; It is present", kTH1F, {axisTriggger}); + histos.add("FT0/bcVertexTrigger", "vertex trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTrigger}); + histos.add("FT0/bcVertexTriggerPP", "vertex trigger per BC (FT0) with Past Protection;BC in FT0; counts", kTH1F, {axisTrigger}); + histos.add("FT0/bcVertexTriggerBothSidesPP", "vertex per BC (FDD) with coincidences, at least one side trigger and Past Protection;BC in FDD; counts", kTH1F, {axisTrigger}); + histos.add("FT0/bcSCentralTrigger", "Scentral trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTrigger}); + histos.add("FT0/bcVSCTrigger", "vertex and Scentral trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTrigger}); + histos.add("FT0/bcCentralTrigger", "central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTrigger}); + histos.add("FT0/bcVCTrigger", "vertex and central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTrigger}); + histos.add("FT0/hBcA", "BC pattern A in FT0; BC in FT0 ; It is present", kTH1F, {axisTrigger}); + histos.add("FT0/hBcC", "BC pattern C in FT0; BC in FT0 ; It is present", kTH1F, {axisTrigger}); + histos.add("FT0/hBcB", "BC pattern B in FT0; BC in FT0 ; It is present", kTH1F, {axisTrigger}); + histos.add("FT0/hBcBL", "BC pattern B in FT0 - Leading BC; BC in FT0 ; It is present", kTH1F, {axisTrigger}); + histos.add("FT0/hBcE", "BC pattern Empty in FT0; BC in FT0 ; It is present", kTH1F, {axisTrigger}); histos.add("FT0/timeACbcB", "time bcB ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); histos.add("FT0/timeACbcA", "time bcA ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); histos.add("FT0/timeACbcC", "time bcC ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); @@ -177,27 +186,28 @@ struct LumiStabilityTask { histos.add("FT0/hCountsTimeA", "0 Dummy Time - 1 Valid Time ; Kind of Time; counts", kTH1F, {axisCounts}); histos.add("FT0/hCountsTimeC", "0 Dummy Time - 1 Valid Time ; Kind of Time; counts", kTH1F, {axisCounts}); histos.add("FT0/hCountsTime", "0 Dummy Time - 1 Valid Time ; Kind of Time; counts", kTH1F, {axisCounts}); - histos.add("FT0/hValidTimeAvsBC", "Valid Time A vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger}); - histos.add("FT0/hInvTimeAvsBC", "Invalid Time A vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger}); - histos.add("FT0/hValidTimeCvsBC", "Valid Time C vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger}); - histos.add("FT0/hInvTimeCvsBC", "Invalid Time C vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger}); - histos.add("FT0/hValidTimevsBC", "Valid Time vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger}); - histos.add("FT0/hInvTimevsBC", "Invalid Time vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger}); - histos.add("FT0/hTimeForRate", "Counts by time in FDD;t (in seconds) in FDD; counts", kTH1F, {axisTimeRate}); + histos.add("FT0/hValidTimeAvsBC", "Valid Time A vs BC id;BC in FT0;valid time counts", kTH1F, {axisTrigger}); + histos.add("FT0/hInvTimeAvsBC", "Invalid Time A vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTrigger}); + histos.add("FT0/hValidTimeCvsBC", "Valid Time C vs BC id;BC in FT0;valid time counts", kTH1F, {axisTrigger}); + histos.add("FT0/hInvTimeCvsBC", "Invalid Time C vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTrigger}); + histos.add("FT0/hValidTimevsBC", "Valid Time vs BC id;BC in FT0;valid time counts", kTH1F, {axisTrigger}); + histos.add("FT0/hInvTimevsBC", "Invalid Time vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTrigger}); + histos.add("FT0/hTimeForRate", "Counts by time in FT0;t (in seconds) in FT0; counts", kTH1F, {axisTimeRate}); + histos.add("FT0/hTimeForRateLeadingBC", "Counts by time in FT0;t (in seconds) in FT0; counts", kTH1F, {axisTimeRate}); histos.add("FV0/hCounts", "0 CountCentralFV0 - 1 CountPFPCentralFV0 - 2 CountPFPOutInFV0 - 3 CountPPCentralFV0 - 4 CountPPOutInFV0; Number; counts", kTH1F, {axisV0Counts}); - histos.add("FV0/bcOutTrigger", "Out trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger}); - histos.add("FV0/bcInTrigger", "In trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger}); - histos.add("FV0/bcSCenTrigger", "SCen trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger}); - histos.add("FV0/bcCenTrigger", "Central trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger}); - histos.add("FV0/bcCenTriggerPFPCentral", "Central trigger per BC (FV0) with PFP in central trigger;BC in V0; counts", kTH1F, {axisTriggger}); - histos.add("FV0/bcCenTriggerPPCentral", "Central trigger per BC (FV0) with PP in central trigger;BC in V0; counts", kTH1F, {axisTriggger}); - histos.add("FV0/bcCenTriggerPFPOutIn", "Central trigger per BC (FV0) with PFP in Out and In trigger;BC in V0; counts", kTH1F, {axisTriggger}); - histos.add("FV0/bcCenTriggerPPOutIn", "Central trigger per BC (FV0) with PP in Out and In trigger;BC in V0; counts", kTH1F, {axisTriggger}); - histos.add("FV0/hBcA", "BC pattern A in FV0; BC in FV0 ; It is present", kTH1F, {axisTriggger}); - histos.add("FV0/hBcC", "BC pattern C in FV0; BC in FV0 ; It is present", kTH1F, {axisTriggger}); - histos.add("FV0/hBcB", "BC pattern B in FV0; BC in FV0 ; It is present", kTH1F, {axisTriggger}); - histos.add("FV0/hBcE", "BC pattern Empty in FV0; BC in FV0 ; It is present", kTH1F, {axisTriggger}); + histos.add("FV0/bcOutTrigger", "Out trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTrigger}); + histos.add("FV0/bcInTrigger", "In trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTrigger}); + histos.add("FV0/bcSCenTrigger", "SCen trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTrigger}); + histos.add("FV0/bcCenTrigger", "Central trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTrigger}); + histos.add("FV0/bcCenTriggerPFPCentral", "Central trigger per BC (FV0) with PFP in central trigger;BC in V0; counts", kTH1F, {axisTrigger}); + histos.add("FV0/bcCenTriggerPPCentral", "Central trigger per BC (FV0) with PP in central trigger;BC in V0; counts", kTH1F, {axisTrigger}); + histos.add("FV0/bcCenTriggerPFPOutIn", "Central trigger per BC (FV0) with PFP in Out and In trigger;BC in V0; counts", kTH1F, {axisTrigger}); + histos.add("FV0/bcCenTriggerPPOutIn", "Central trigger per BC (FV0) with PP in Out and In trigger;BC in V0; counts", kTH1F, {axisTrigger}); + histos.add("FV0/hBcA", "BC pattern A in FV0; BC in FV0 ; It is present", kTH1F, {axisTrigger}); + histos.add("FV0/hBcC", "BC pattern C in FV0; BC in FV0 ; It is present", kTH1F, {axisTrigger}); + histos.add("FV0/hBcB", "BC pattern B in FV0; BC in FV0 ; It is present", kTH1F, {axisTrigger}); + histos.add("FV0/hBcE", "BC pattern Empty in FV0; BC in FV0 ; It is present", kTH1F, {axisTrigger}); histos.add("FV0/timeAbcB", "time bcB ; A (ns)", kTH1F, {{300, -15, 15}}); histos.add("FV0/timeAbcA", "time bcA ; A (ns)", kTH1F, {{300, -15, 15}}); histos.add("FV0/timeAbcC", "time bcC ; A (ns)", kTH1F, {{300, -15, 15}}); @@ -224,6 +234,7 @@ struct LumiStabilityTask { void processMain(aod::FDDs const& fdds, aod::FT0s const& ft0s, aod::FV0As const& fv0s, aod::BCsWithTimestamps const& bcs) { int executionCounter = 0; + int nbin = o2::constants::lhc::LHCMaxBunches; uint32_t nOrbitsPerTF = 0; // 128 in 2022, 32 in 2023 if (is2022Data) { nOrbitsPerTF = 128; // 128 in 2022, 32 in 2023 @@ -231,8 +242,6 @@ struct LumiStabilityTask { nOrbitsPerTF = 32; // 128 in 2022, 32 in 2023 } int runNumber = bcs.iteratorAt(0).runNumber(); - int64_t tsSOR = 0; - int64_t tsEOR = 1; if (runNumber != lastRunNumber && executionCounter < 1) { tsSOR = 0; tsEOR = 1; @@ -260,6 +269,18 @@ struct LumiStabilityTask { } if (bcPatternB[i]) { histos.fill(HIST("hBcB"), i); + bool isLeadBC = true; + for (int jbit = i - minEmpty; jbit < i; jbit++) { + int kbit = jbit; + if (kbit < 0) + kbit += nbin; + if (bcPatternB[kbit]) { + isLeadBC = false; + break; + } + } + if (isLeadBC) + histos.fill(HIST("hBcBL"), i); } if (bcPatternE[i]) { histos.fill(HIST("hBcE"), i); @@ -291,6 +312,12 @@ struct LumiStabilityTask { // duration of TF in bcs nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches; LOGP(info, "tsOrbitReset={} us, SOR = {} ms, EOR = {} ms, orbitSOR = {}, nBCsPerTF = {}", tsOrbitReset, tsSOR, tsEOR, orbitSOR, nBCsPerTF); + + auto hTsValues = histos.get(HIST("tsValues")); + hTsValues->GetXaxis()->SetBinLabel(1, "tsSOR"); + hTsValues->GetXaxis()->SetBinLabel(2, "tsEOR"); + hTsValues->SetBinContent(1, tsSOR / 1000); // seconds + hTsValues->SetBinContent(2, tsEOR / 1000); // seconds } // create orbit-axis histograms on the fly with binning based on info from GRP if GRP is available @@ -338,7 +365,22 @@ struct LumiStabilityTask { histos.fill(HIST("FDD/bcVertexTrigger"), localBC); histos.fill(HIST("FDD/hCounts"), 1); histos.fill(HIST("hOrbitFDDVertex"), orbit - minOrbit); - histos.fill(HIST("FDD/hTimeForRate"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds + + if (bcPatternB[localBC]) { + histos.fill(HIST("FDD/hTimeForRate"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds + bool isLeadBC = true; + for (int jbit = localBC - minEmpty; jbit < localBC; jbit++) { + int kbit = jbit; + if (kbit < 0) + kbit += nbin; + if (bcPatternB[kbit]) { + isLeadBC = false; + break; + } + } + if (isLeadBC) + histos.fill(HIST("FDD/hTimeForRateLeadingBC"), (bc.timestamp() - tsSOR) * 1.e-3); + } int deltaIndex = 0; // backward move counts int deltaBC = 0; // current difference wrt globalBC @@ -375,6 +417,18 @@ struct LumiStabilityTask { if (bcPatternB[localBC]) { histos.fill(HIST("FDD/timeACbcBVertex"), fdd.timeA(), fdd.timeC()); histos.fill(HIST("FDD/hBcBVertex"), localBC); + bool isLeadBC = true; + for (int jbit = localBC - minEmpty; jbit < localBC; jbit++) { + int kbit = jbit; + if (kbit < 0) + kbit += nbin; + if (bcPatternB[kbit]) { + isLeadBC = false; + break; + } + } + if (isLeadBC) + histos.fill(HIST("FDD/hBcBVertexL"), localBC); histos.fill(HIST("FDD/hTimeAVertex"), fdd.timeA()); histos.fill(HIST("FDD/hTimeCVertex"), fdd.timeC()); if (is2022Data) { @@ -426,6 +480,18 @@ struct LumiStabilityTask { if (bcPatternB[localBC]) { histos.fill(HIST("FDD/timeACbcB"), fdd.timeA(), fdd.timeC()); histos.fill(HIST("FDD/hBcB"), localBC); + bool isLeadBC = true; + for (int jbit = localBC - minEmpty; jbit < localBC; jbit++) { + int kbit = jbit; + if (kbit < 0) + kbit += nbin; + if (bcPatternB[kbit]) { + isLeadBC = false; + break; + } + } + if (isLeadBC) + histos.fill(HIST("FDD/hBcBL"), localBC); histos.fill(HIST("FDD/hTimeACoinc"), fdd.timeA()); histos.fill(HIST("FDD/hTimeCCoinc"), fdd.timeC()); if (!is2022Data) { @@ -561,7 +627,6 @@ struct LumiStabilityTask { if (vertex) { histos.fill(HIST("FT0/bcVertexTrigger"), localBC); histos.fill(HIST("hOrbitFT0vertex"), orbit - minOrbit); - histos.fill(HIST("FT0/hTimeForRate"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds if (bcPatternA[localBC]) { histos.fill(HIST("FT0/timeACbcA"), ft0.timeA(), ft0.timeC()); @@ -574,6 +639,21 @@ struct LumiStabilityTask { if (bcPatternB[localBC]) { histos.fill(HIST("FT0/timeACbcB"), ft0.timeA(), ft0.timeC()); histos.fill(HIST("FT0/hBcB"), localBC); + histos.fill(HIST("FT0/hTimeForRate"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds + bool isLeadBC = true; + for (int jbit = localBC - minEmpty; jbit < localBC; jbit++) { + int kbit = jbit; + if (kbit < 0) + kbit += nbin; + if (bcPatternB[kbit]) { + isLeadBC = false; + break; + } + } + if (isLeadBC) { + histos.fill(HIST("FT0/hTimeForRateLeadingBC"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds + histos.fill(HIST("FT0/hBcBL"), localBC); + } histos.fill(HIST("FT0/hTimeA"), ft0.timeA()); histos.fill(HIST("FT0/hTimeC"), ft0.timeC()); diff --git a/PWGMM/Mult/Core/include/Functions.h b/PWGMM/Mult/Core/include/Functions.h index a0ef3928fa5..00d1ef0ee2a 100644 --- a/PWGMM/Mult/Core/include/Functions.h +++ b/PWGMM/Mult/Core/include/Functions.h @@ -46,9 +46,14 @@ concept iterator_with_FT0C = requires(IC const& c) { c.centFT0C(); }; +template +concept has_centFT0CVariant1 = requires(C::iterator const& c) { + c.centFT0CVariant1(); +}; + template -concept iterator_with_FT0M = requires(IC const& c) { - c.centFT0M(); +concept iterator_with_centFT0CVariant1 = requires(IC const& c) { + c.centFT0CVariant1(); }; template @@ -56,6 +61,31 @@ concept has_FT0M = requires(C::iterator const& c) { c.centFT0M(); }; +template +concept iterator_with_FT0M = requires(IC const& c) { + c.centFT0M(); +}; + +template +concept has_centNGlobal = requires(C::iterator const& c) { + c.centNGlobal(); +}; + +template +concept iterator_with_centNGlobal = requires(IC const& c) { + c.centNGlobal(); +}; + +template +concept has_centMFT = requires(C::iterator const& c) { + c.centMFT(); +}; + +template +concept iterator_with_centMFT = requires(IC const& c) { + c.centMFT(); +}; + template concept has_genFT0C = requires(C::iterator const& c) { c.gencentFT0C(); @@ -77,7 +107,7 @@ concept iterator_with_genFT0M = requires(C const& c) { }; template -concept has_reco_cent = has_FT0C || has_FT0M; +concept has_reco_cent = has_FT0C || has_centFT0CVariant1 || has_FT0M || has_centNGlobal || has_centMFT; template concept has_gen_cent = has_genFT0C && has_genFT0M; @@ -93,7 +123,7 @@ concept iterator_with_Centrality = requires(MCC const& mcc) { }; template - requires(!(iterator_with_FT0C || iterator_with_FT0M)) + requires(!(iterator_with_FT0C || iterator_with_centFT0CVariant1 || iterator_with_FT0M || iterator_with_centNGlobal || iterator_with_centMFT)) static float getRecoCent(C const&) { return -1; @@ -105,12 +135,30 @@ static float getRecoCent(C const& collision) return collision.centFT0C(); } +template +static float getRecoCent(C const& collision) +{ + return collision.centFT0CVariant1(); +} + template static float getRecoCent(C const& collision) { return collision.centFT0M(); } +template +static float getRecoCent(C const& collision) +{ + return collision.centNGlobal(); +} + +template +static float getRecoCent(C const& collision) +{ + return collision.centMFT(); +} + template requires(!iterator_with_genFT0C) static float getGenCentFT0C(MCC const&) diff --git a/PWGMM/Mult/TableProducer/trackPropagation.cxx b/PWGMM/Mult/TableProducer/trackPropagation.cxx index a1dffe08dbf..8eaa59e850b 100644 --- a/PWGMM/Mult/TableProducer/trackPropagation.cxx +++ b/PWGMM/Mult/TableProducer/trackPropagation.cxx @@ -150,7 +150,7 @@ struct AmbiguousTrackPropagation { auto bc = bcs.begin(); initCCDB(bc); - gpu::gpustd::array dcaInfo; + std::array dcaInfo; float bestDCA[2]; o2::track::TrackParametrization bestTrackPar; for (auto& track : tracks) { diff --git a/PWGMM/Mult/Tasks/CMakeLists.txt b/PWGMM/Mult/Tasks/CMakeLists.txt index 9012d14f2c1..2c56cc8fc96 100644 --- a/PWGMM/Mult/Tasks/CMakeLists.txt +++ b/PWGMM/Mult/Tasks/CMakeLists.txt @@ -35,8 +35,8 @@ o2physics_add_dpl_workflow(dndeta-mft COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(dndeta-mft-pbpb - SOURCES dndeta-mft-pbpb.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + SOURCES dndetaMFTPbPb.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(flatenicity-fv0 diff --git a/PWGMM/Mult/Tasks/dndeta-mft-pbpb.cxx b/PWGMM/Mult/Tasks/dndeta-mft-pbpb.cxx deleted file mode 100644 index a220811d105..00000000000 --- a/PWGMM/Mult/Tasks/dndeta-mft-pbpb.cxx +++ /dev/null @@ -1,1515 +0,0 @@ -// Copyright 2020-2022 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. - -/// -/// \file dndeta-mft-pbpb.cxx -/// \struct dndeta analysis at forward pseudorapidity -/// \brief Task for calculating dNdeta in Pb-Pb collisions using MFT detector -/// \author Gyula Bencedi -/// \since Nov 2024 -/// @note based on dndeta-mft.cxx -/// - -#include -#include -#include - -#include "Framework/ASoAHelpers.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/Configurable.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Framework/RuntimeError.h" -#include "Framework/runDataProcessing.h" - -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/CollisionAssociationTables.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "CommonConstants/MathConstants.h" - -#include "MathUtils/Utils.h" -#include "ReconstructionDataFormats/GlobalTrackID.h" - -#include - -#include "Index.h" -#include "bestCollisionTable.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::aod::track; -using namespace o2::aod::fwdtrack; - -AxisSpec PtAxis = {1001, -0.005, 10.005}; -AxisSpec MultAxis = {701, -0.5, 700.5, "N_{trk}"}; -AxisSpec ZAxis = {60, -30., 30.}; -AxisSpec DeltaZAxis = {61, -6.1, 6.1}; -AxisSpec DCAxyAxis = {500, -1, 50}; -AxisSpec PhiAxis = {629, 0, o2::constants::math::TwoPI, "Rad", "#phi"}; -AxisSpec EtaAxis = {20, -4., -2.}; - -struct PseudorapidityDensityMFT { - SliceCache cache; - - // Histogram registry - HistogramRegistry registry{ - "registry", - {}, - OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry QAregistry{ - "QAregistry", - {}, - OutputObjHandlingPolicy::AnalysisObject, - false, - true}; - - // analysis specific conf. - Configurable usePhiCut{"usePhiCut", false, "use azimuthal angle cut"}; - Configurable cfgPhiCut{"cfgPhiCut", 0.1f, - "Cut on azimuthal angle of MFT tracks"}; - - // track selection conf. - struct : ConfigurableGroup { - Configurable cfg_eta_min{"cfg_eta_min", -3.6f, ""}; - Configurable cfg_eta_max{"cfg_eta_max", -2.5f, ""}; - Configurable cfg_min_ncluster_mft{"cfg_min_ncluster_mft", 5, - "minimum number of MFT clusters"}; - Configurable cfg_min_pt{"cfg_min_pt", 0., - "minimum pT of the MFT tracks"}; - Configurable cfg_require_ca{ - "cfg_require_ca", false, - "Use Cellular Automaton track-finding algorithm"}; - Configurable cfg_max_dcaxy{"cfg_max_dcaxy", 2.0f, "Cut on dcaXY"}; - } trkcuts; - - // event selection conf. - Configurable cfgCutZvtx{"cfgCutZvtx", 10.0f, "Cut on z-vtx"}; - Configurable cfgCutCent{"cfgCutCent", 80.0f, - "Cut on maximum centrality"}; - Configurable useZDiffCut{"useZvtxDiffCut", false, - "use Zvtx reco-mc diff. cut"}; - Configurable maxZvtxDiff{ - "maxZvtxDiff", 1.0f, - "max allowed Z vtx difference for reconstruced collisions (cm)"}; - Configurable requireNoCollInTimeRangeStd{ - "requireNoCollInTimeRangeStd", false, - "reject collisions corrupted by the cannibalism, with other collisions " - "within +/- 10 microseconds"}; - Configurable requireNoCollInTimeRangeNarrow{ - "requireNoCollInTimeRangeNarrow", false, - "reject collisions corrupted by the cannibalism, with other collisions " - "within +/- 10 microseconds"}; - ConfigurableAxis OccupancyBins{"OccupancyBins", - {VARIABLE_WIDTH, 0.0f, 250.0f, 500.0f, 750.0f, - 1000.0f, 1500.0f, 2000.0f, 3000.0f, 4500.0f, - 6000.0f, 8000.0f, 10000.0f, 50000.0f}, - "Occupancy"}; - Configurable minOccupancy{ - "minOccupancy", -1, "minimum occupancy from neighbouring collisions"}; - Configurable maxOccupancy{ - "maxOccupancy", -1, "maximum occupancy from neighbouring collisions"}; - ConfigurableAxis CentBins{ - "CentBins", - {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, - ""}; - - Service pdg; - - /// @brief init function, definition of histograms - void init(InitContext&) - { - if (static_cast(doprocessDataInclusive) + - static_cast(doprocessDatawBestTracksInclusive) > - 1) { - LOGP(fatal, - "Either processDataInclusive OR " - "processDatawBestTracksInclusive should be enabled!"); - } - if (static_cast(doprocessDataCent) + - static_cast(doprocessDatawBestTracksCent) > - 1) { - LOGP(fatal, - "Either processDataCent OR processDatawBestTracksCent should " - "be enabled!"); - } - if (static_cast(doprocessMCInclusive) + - static_cast(doprocessMCwBestTracksInclusive) > - 1) { - LOGP(fatal, - "Either processMCInclusive OR processMCwBestTracksInclusive " - "should be enabled!"); - } - if (static_cast(doprocessMCCent) + - static_cast(doprocessMCwBestTracksCent) > - 1) { - LOGP(fatal, - "Either processMCCent OR processMCwBestTracksCent should be " - "enabled!"); - } - - auto hev = registry.add("hEvtSel", "hEvtSel", HistType::kTH1F, - {{10, -0.5f, +9.5f}}); - hev->GetXaxis()->SetBinLabel(1, "All collisions"); - hev->GetXaxis()->SetBinLabel(2, "Ev. sel."); - hev->GetXaxis()->SetBinLabel(3, "kIsGoodZvtxFT0vsPV"); - hev->GetXaxis()->SetBinLabel(4, "NoSameBunchPileup"); - hev->GetXaxis()->SetBinLabel(5, "Z-vtx cut"); - hev->GetXaxis()->SetBinLabel(6, "kNoCollInTimeRangeStd"); - hev->GetXaxis()->SetBinLabel(7, "kNoCollInTimeRangeNarrow"); - hev->GetXaxis()->SetBinLabel(8, "Below min occup."); - hev->GetXaxis()->SetBinLabel(9, "Above max occup."); - - auto hBcSel = registry.add("hBcSel", "hBcSel", HistType::kTH1F, - {{3, -0.5f, +2.5f}}); - hBcSel->GetXaxis()->SetBinLabel(1, "Good BCs"); - hBcSel->GetXaxis()->SetBinLabel(2, "BCs with collisions"); - hBcSel->GetXaxis()->SetBinLabel(3, "BCs with pile-up/splitting"); - - AxisSpec CentAxis = {CentBins, "Centrality", "CentralityAxis"}; - AxisSpec OccupancyAxis = {OccupancyBins, "Occupancy", "OccupancyAxis"}; - - if (doprocessDataInclusive || doprocessDatawBestTracksInclusive) { - registry.add({"Events/Selection", - ";status;events", - {HistType::kTH1F, {{2, 0.5, 2.5}}}}); - auto hstat = registry.get(HIST("Events/Selection")); - auto* x = hstat->GetXaxis(); - x->SetBinLabel(1, "All"); - x->SetBinLabel(2, "Selected"); - - registry.add({"Events/NtrkZvtx", - "; N_{trk}; Z_{vtx} (cm);", - {HistType::kTH2F, {MultAxis, ZAxis}}}); - registry.add({"Tracks/EtaZvtx", - "; #eta; Z_{vtx} (cm);", - {HistType::kTH2F, {EtaAxis, ZAxis}}}); - registry.add({"Tracks/PhiEta", - "; #varphi; #eta;", - {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - QAregistry.add({"Tracks/Chi2Eta", - "; #chi^{2}; #it{#eta};", - {HistType::kTH2F, {{600, 0, 20}, {100, -8, 8}}}}); - QAregistry.add( - {"Tracks/Chi2", "; #chi^{2};", {HistType::kTH1F, {{600, 0, 20}}}}); - QAregistry.add({"Tracks/NclustersEta", - "; nClusters; #eta;", - {HistType::kTH2F, {{7, 4, 10}, {100, -8, 8}}}}); - QAregistry.add("Events/Occupancy", "; Z_{vtx} (cm); Occupancy", - HistType::kTH2F, {ZAxis, OccupancyAxis}, false); - - if (doprocessDatawBestTracksInclusive) { - registry.add({"Events/NtrkZvtxBest", - "; N_{trk}; Z_{vtx} (cm);", - {HistType::kTH2F, {MultAxis, ZAxis}}}); - registry.add({"Tracks/EtaZvtxBest", - "; #eta; Z_{vtx} (cm);", - {HistType::kTH2F, {EtaAxis, ZAxis}}}); - registry.add({"Tracks/PhiEtaBest", - "; #varphi; #eta;", - {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - QAregistry.add({"Tracks/NclustersEtaBest", - "; nClusters; #eta;", - {HistType::kTH2F, {{7, 4, 10}, {100, -8, 8}}}}); - QAregistry.add({"Tracks/DCAXYPt", - " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality", - {HistType::kTH2F, {PtAxis, DCAxyAxis}}}); - QAregistry.add({"Tracks/DCAXY", - " ; DCA_{XY} (cm)", - {HistType::kTH1F, {DCAxyAxis}}}); - QAregistry.add({"Tracks/ReTracksEtaZvtx", - "; #eta; #it{z}_{vtx} (cm); tracks", - {HistType::kTH2F, {EtaAxis, ZAxis}}}); - QAregistry.add({"Tracks/ReTracksPhiEta", - "; #varphi; #eta; tracks", - {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - QAregistry.add({"Tracks/TrackAmbDegree", - " ; N_{coll}^{comp}", - {HistType::kTH1F, {{51, -0.5, 50.5}}}}); - } - } - - if (doprocessDataCent || doprocessDatawBestTracksCent) { - registry.add({"Events/Centrality/Selection", - ";status;centrality;events", - {HistType::kTH2F, {{2, 0.5, 2.5}, CentAxis}}}); - auto hstat = registry.get(HIST("Events/Centrality/Selection")); - auto* x = hstat->GetXaxis(); - x->SetBinLabel(1, "All"); - x->SetBinLabel(2, "Selected"); - - registry.add({"Events/Centrality/NtrkZvtx", - "; N_{trk}; Z_{vtx} (cm); centrality", - {HistType::kTH3F, {MultAxis, ZAxis, CentAxis}}}); - registry.add({"Tracks/Centrality/EtaZvtx", - "; #eta; Z_{vtx} (cm); centrality", - {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); - registry.add({"Tracks/Centrality/PhiEta", - "; #varphi; #eta; centrality", - {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); - QAregistry.add({"Events/Centrality/hcentFT0C", - " ; cent FT0C", - {HistType::kTH1F, {CentAxis}}, - true}); - QAregistry.add( - {"Tracks/Centrality/Chi2Eta", - "; #chi^{2}; #it{#eta}; centrality", - {HistType::kTH3F, {{600, 0, 20}, {100, -8, 8}, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/Chi2", - "; #chi^{2}; centrality", - {HistType::kTH2F, {{600, 0, 20}, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/NclustersEta", - "; nClusters; #eta; centrality", - {HistType::kTH3F, {{7, 4, 10}, {100, -8, 8}, CentAxis}}}); - QAregistry.add("Events/Centrality/Occupancy", - "; Z_{vtx} (cm); centrality; Occupancy", HistType::kTH3F, - {ZAxis, CentAxis, OccupancyAxis}, false); - QAregistry.add("Tracks/Centrality/Occupancy", "dndeta occupancy", - HistType::kTHnSparseF, - {ZAxis, CentAxis, EtaAxis, PhiAxis, OccupancyAxis}, false); - - if (doprocessDatawBestTracksCent) { - registry.add({"Events/Centrality/NtrkZvtxBest", - "; N_{trk}; Z_{vtx} (cm); centrality", - {HistType::kTH3F, {MultAxis, ZAxis, CentAxis}}}); - registry.add({"Tracks/Centrality/EtaZvtxBest", - "; #eta; Z_{vtx} (cm); centrality", - {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); - registry.add({"Tracks/Centrality/PhiEtaBest", - "; #varphi; #eta; centrality", - {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); - QAregistry.add( - {"Tracks/Centrality/NclustersEtaBest", - "; nClusters; #eta; centrality", - {HistType::kTH3F, {{7, 4, 10}, {100, -8, 8}, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/TrackAmbDegree", - " ; N_{coll}^{comp}", - {HistType::kTH2F, {{51, -0.5, 50.5}, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/DCAXY", - " ; DCA_{XY} (cm)", - {HistType::kTH2F, {DCAxyAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/DCAXYPt", - " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality", - {HistType::kTH3F, {PtAxis, DCAxyAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/ReTracksEtaZvtx", - "; #eta; #it{z}_{vtx} (cm); tracks", - {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/ReTracksPhiEta", - "; #varphi; #eta; tracks", - {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); - QAregistry.add("Events/Centrality/OccupancyBest", - "; Z_{vtx} (cm); centrality; Occupancy", HistType::kTH3F, - {ZAxis, CentAxis, OccupancyAxis}, false); - QAregistry.add("Tracks/Centrality/OccupancyBest", "dndeta occupancy", - HistType::kTHnSparseF, - {ZAxis, CentAxis, EtaAxis, PhiAxis, OccupancyAxis}, - false); - } - } - - if (doprocessMCInclusive || doprocessMCwBestTracksInclusive) { - registry.add({"Events/EvtEffGen", - ";status;events", - {HistType::kTH1F, {{3, 0.5, 3.5}}}}); - auto heff = registry.get(HIST("Events/EvtEffGen")); - auto* x = heff->GetXaxis(); - x->SetBinLabel(1, "All reconstructed"); - x->SetBinLabel(2, "Selected reconstructed"); - x->SetBinLabel(3, "All generated"); - - registry.add({"Events/NtrkZvtxGen_t", - "; N_{trk}; Z_{vtx} (cm);", - {HistType::kTH2F, {MultAxis, ZAxis}}}); - registry.add({"Events/NtrkZvtxGen", - "; N_{trk}; Z_{vtx} (cm);", - {HistType::kTH2F, {MultAxis, ZAxis}}}); - registry.add({"Tracks/EtaZvtxGen", - "; #eta; Z_{vtx} (cm);", - {HistType::kTH2F, {EtaAxis, ZAxis}}}); - registry.add({"Tracks/PhiEtaGen", - "; #varphi; #eta;", - {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - registry.add({"Tracks/EtaZvtxGen_t", - "; #eta; Z_{vtx} (cm);", - {HistType::kTH2F, {EtaAxis, ZAxis}}}); - registry.add({"Tracks/PhiEtaGen_t", - "; #varphi; #eta;", - {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - QAregistry.add({"Events/NotFoundEventZvtx", - " ; #it{z}_{vtx} (cm)", - {HistType::kTH1F, {ZAxis}}}); - QAregistry.add({"Events/ZvtxDiff", - " ; Z_{rec} - Z_{gen} (cm)", - {HistType::kTH1F, {DeltaZAxis}}}); - QAregistry.add( - {"Events/SplitMult", " ; N_{gen}", {HistType::kTH1F, {MultAxis}}}); - } - - if (doprocessMCCent || doprocessMCwBestTracksCent) { - registry.add({"Events/Centrality/EvtEffGen", - ";status;events", - {HistType::kTH2F, {{3, 0.5, 3.5}, CentAxis}}}); - auto heff = registry.get(HIST("Events/Centrality/EvtEffGen")); - auto* x = heff->GetXaxis(); - x->SetBinLabel(1, "All reconstructed"); - x->SetBinLabel(2, "Selected reconstructed"); - x->SetBinLabel(3, "All generated"); - - registry.add({"Events/Centrality/NtrkZvtxGen_t", - "; N_{trk}; Z_{vtx} (cm);", - {HistType::kTH3F, {MultAxis, ZAxis, CentAxis}}}); - registry.add({"Events/Centrality/NtrkZvtxGen", - "; N_{trk}; Z_{vtx} (cm);", - {HistType::kTH3F, {MultAxis, ZAxis, CentAxis}}}); - registry.add({"Events/Centrality/hRecCent", - "Events/Centrality/hRecCent", - {HistType::kTH1F, {CentAxis}}}); - registry.add({"Events/Centrality/hRecZvtxCent", - "Events/Centrality/hRecZvtxCent", - {HistType::kTH2F, {ZAxis, CentAxis}}}); - registry.add({"Tracks/Centrality/EtaZvtxGen", - "; #eta; Z_{vtx} (cm);", - {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); - registry.add({"Tracks/Centrality/PhiEtaGen", - "; #varphi; #eta;", - {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); - registry.add({"Tracks/Centrality/EtaZvtxGen_t", - "; #eta; Z_{vtx} (cm);", - {HistType::kTH3F, {EtaAxis, ZAxis, CentAxis}}}); - registry.add({"Tracks/Centrality/PhiEtaGen_t", - "; #varphi; #eta;", - {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); - QAregistry.add({"Events/Centrality/NotFoundEventZvtx", - " ; #it{z}_{vtx} (cm)", - {HistType::kTH2F, {ZAxis, CentAxis}}}); - QAregistry.add({"Events/Centrality/ZvtxDiff", - " ; Z_{rec} - Z_{gen} (cm)", - {HistType::kTH2F, {DeltaZAxis, CentAxis}}}); - QAregistry.add({"Events/Centrality/SplitMult", - " ; N_{gen}", - {HistType::kTH2F, {MultAxis, CentAxis}}}); - } - - if (doprocessTrkEffIdxInlusive) { - QAregistry.add( - {"Tracks/hPtPhiEtaZvtxEffGen", - "hPtPhiEtaZvtxEffGen", - {HistType::kTHnSparseF, {PtAxis, PhiAxis, EtaAxis, ZAxis}}}); - QAregistry.add( - {"Tracks/hPtPhiEtaZvtxEffRec", - "hPtPhiEtaZvtxEffRec", - {HistType::kTHnSparseF, {PtAxis, PhiAxis, EtaAxis, ZAxis}}}); - QAregistry.add({"Tracks/hPhiEtaDuplicates", - " ; p_{T} (GeV/c);", - {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - QAregistry.add( - {"Tracks/hPtPhiEtaZvtxEffDuplicates", - "hPtPhiEtaZvtxEffDuplicates", - {HistType::kTHnSparseF, {PtAxis, PhiAxis, EtaAxis, ZAxis}}}); - QAregistry.add( - {"Tracks/hPtPhiEtaZvtxEffGenDuplicates", - "hPtPhiEtaZvtxEffGenDuplicates", - {HistType::kTHnSparseF, {PtAxis, PhiAxis, EtaAxis, ZAxis}}}); - QAregistry.add({"Tracks/NmftTrkPerPart", - "; #it{N}_{mft tracks per particle};", - {HistType::kTH1F, {{200, -0.5, 200.}}}}); - } - - if (doprocessTrkEffIdxCent) { - QAregistry.add({"Tracks/Centrality/hPtPhiEtaZvtxEffGen", - "hPtPhiEtaZvtxEffGen", - {HistType::kTHnSparseF, - {PtAxis, PhiAxis, EtaAxis, ZAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/hPtPhiEtaZvtxEffRec", - "hPtPhiEtaZvtxEffRec", - {HistType::kTHnSparseF, - {PtAxis, PhiAxis, EtaAxis, ZAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/hPhiEtaDuplicates", - " ; p_{T} (GeV/c);", - {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/hPtPhiEtaZvtxEffDuplicates", - "hPtPhiEtaZvtxEffDuplicates", - {HistType::kTHnSparseF, - {PtAxis, PhiAxis, EtaAxis, ZAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/hPtPhiEtaZvtxEffGenDuplicates", - "hPtPhiEtaZvtxEffGenDuplicates", - {HistType::kTHnSparseF, - {PtAxis, PhiAxis, EtaAxis, ZAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/NmftTrkPerPart", - "; #it{N}_{mft tracks per particle};", - {HistType::kTH2F, {{200, -0.5, 200.}, CentAxis}}}); - } - - if (doprocessTrkEffBestInclusive) { - QAregistry.add( - {"Tracks/hPtPhiEtaZvtxEffBestGen", - "hPtPhiEtaZvtxEffGen", - {HistType::kTHnSparseF, {PtAxis, PhiAxis, EtaAxis, ZAxis}}}); - QAregistry.add( - {"Tracks/hPtPhiEtaZvtxEffBestRec", - "hPtPhiEtaZvtxEffRec", - {HistType::kTHnSparseF, {PtAxis, PhiAxis, EtaAxis, ZAxis}}}); - QAregistry.add({"Tracks/hPtEffBestFakeRec", - " ; p_{T} (GeV/c);", - {HistType::kTH1F, {PtAxis}}}); - } - - if (doprocessTrkEffBestCent) { - QAregistry.add({"Tracks/Centrality/hPtPhiEtaZvtxEffBestGen", - "hPtPhiEtaZvtxEffGen", - {HistType::kTHnSparseF, - {PtAxis, PhiAxis, EtaAxis, ZAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/hPtPhiEtaZvtxEffBestRec", - "hPtPhiEtaZvtxEffRec", - {HistType::kTHnSparseF, - {PtAxis, PhiAxis, EtaAxis, ZAxis, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/hPtEffBestFakeRec", - " ; p_{T} (GeV/c);", - {HistType::kTH2F, {PtAxis, CentAxis}}}); - } - - if (doprocessMcQAInclusive) { - QAregistry.add({"Events/hRecPerGenColls", - "; #it{N}_{reco collisions} / #it{N}_{gen collisions};", - {HistType::kTH1F, {{200, 0., 2.}}}}); - QAregistry.add({"Tracks/hNmftTrks", - "; #it{N}_{mft tracks};", - {HistType::kTH1F, {{200, -0.5, 200.}}}}); - QAregistry.add({"Tracks/hFracAmbiguousMftTrks", - "; #it{N}_{ambiguous tracks} / #it{N}_{tracks};", - {HistType::kTH1F, {{100, 0., 1.}}}}); - } - - if (doprocessMcQACent) { - QAregistry.add( - {"Events/Centrality/hRecPerGenColls", - "; #it{N}_{reco collisions} / #it{N}_{gen collisions}; centrality", - {HistType::kTH2F, {{200, 0., 2.}, CentAxis}}}); - QAregistry.add({"Tracks/Centrality/hNmftTrks", - "; #it{N}_{mft tracks}; centrality", - {HistType::kTH2F, {{200, -0.5, 200.}, CentAxis}}}); - QAregistry.add( - {"Tracks/Centrality/hFracAmbiguousMftTrks", - "; #it{N}_{ambiguous tracks} / #it{N}_{tracks}; centrality", - {HistType::kTH2F, {{100, 0., 1.}, CentAxis}}}); - } - } - - /// Filters - tracks - Filter filtTrkEta = (aod::fwdtrack::eta < trkcuts.cfg_eta_max) && - (aod::fwdtrack::eta > trkcuts.cfg_eta_min); - Filter filtATrackID = (aod::fwdtrack::bestCollisionId >= 0); - Filter filtATrackDCA = - (nabs(aod::fwdtrack::bestDCAXY) < trkcuts.cfg_max_dcaxy); - - /// Filters - mc particles - Filter primaries = (aod::mcparticle::flags & - (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary) == - (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary; - - /// Joined tables - using FullBCs = soa::Join; - using CollBCs = - soa::Join; - using Colls = soa::Join; - using Coll = Colls::iterator; - using CollsCent = soa::Join; - using CollCent = CollsCent::iterator; - using CollsGenCent = soa::Join; - using CollGenCent = CollsGenCent::iterator; - using MFTTracksLabeled = soa::Join; - - /// Filtered tables - using filtMftTracks = soa::Filtered; - using filtMcMftTracks = soa::Filtered; - using filtBestTracks = soa::Filtered; - using filtParticles = soa::Filtered; - - template - bool isTrackSelected(const T& track) - { - if (track.eta() < trkcuts.cfg_eta_min || track.eta() > trkcuts.cfg_eta_max) - return false; - if (trkcuts.cfg_require_ca && !track.isCA()) - return false; - if (track.nClusters() < trkcuts.cfg_min_ncluster_mft) - return false; - if (track.pt() < trkcuts.cfg_min_pt) - return false; - if (usePhiCut) { - float phi = track.phi(); - o2::math_utils::bringTo02Pi(phi); - if (phi < 0.f || 2.f * M_PI < phi) { - return false; - } - if ((phi < cfgPhiCut) || - ((phi > M_PI - cfgPhiCut) && (phi < M_PI + cfgPhiCut)) || - (phi > 2. * M_PI - cfgPhiCut) || - ((phi > ((M_PI / 2. - 0.1) * M_PI) - cfgPhiCut) && - (phi < ((M_PI / 2. - 0.1) * M_PI) + cfgPhiCut))) - return false; - } - return true; - } - - template - int countTracks(T const& tracks, float z, float c, float occ) - { - auto nTrk = 0; - if (tracks.size() > 0) { - for (auto& track : tracks) { - if (fillHis) { - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Tracks/Centrality/Chi2Eta"), track.chi2(), - track.eta(), c); - QAregistry.fill(HIST("Tracks/Centrality/Chi2"), track.chi2(), c); - QAregistry.fill(HIST("Tracks/Centrality/NclustersEta"), - track.nClusters(), track.eta(), c); - } else { - QAregistry.fill(HIST("Tracks/Chi2Eta"), track.chi2(), track.eta()); - QAregistry.fill(HIST("Tracks/Chi2"), track.chi2()); - QAregistry.fill(HIST("Tracks/NclustersEta"), track.nClusters(), - track.eta()); - } - } - if (!isTrackSelected(track)) { - continue; - } - if (fillHis) { - float phi = track.phi(); - o2::math_utils::bringTo02Pi(phi); - if (phi < 0.f || 2.f * M_PI < phi) { - continue; - } - if constexpr (C::template contains()) { - registry.fill(HIST("Tracks/Centrality/EtaZvtx"), track.eta(), z, c); - registry.fill(HIST("Tracks/Centrality/PhiEta"), phi, track.eta(), - c); - QAregistry.fill(HIST("Tracks/Centrality/Occupancy"), z, c, - track.eta(), track.phi(), occ); - } else { - registry.fill(HIST("Tracks/EtaZvtx"), track.eta(), z); - registry.fill(HIST("Tracks/PhiEta"), phi, track.eta()); - } - } - ++nTrk; - } - } - return nTrk; - } - - template - int countBestTracks(T const& /*tracks*/, B const& besttracks, float z, - float c, float occ) - { - auto nATrk = 0; - if (besttracks.size() > 0) { - for (auto& atrack : besttracks) { - auto itrack = atrack.template mfttrack_as(); - if (!isTrackSelected(itrack)) { - continue; - } - if (fillHis) { - float phi = itrack.phi(); - o2::math_utils::bringTo02Pi(phi); - if (phi < 0.f || 2.f * M_PI < phi) { - continue; - } - if constexpr (C::template contains()) { - registry.fill(HIST("Tracks/Centrality/EtaZvtxBest"), itrack.eta(), - z, c); - registry.fill(HIST("Tracks/Centrality/PhiEtaBest"), phi, - itrack.eta(), c); - QAregistry.fill(HIST("Tracks/Centrality/OccupancyBest"), z, c, - itrack.eta(), itrack.phi(), occ); - QAregistry.fill(HIST("Tracks/Centrality/DCAXYPt"), itrack.pt(), - atrack.bestDCAXY(), c); - QAregistry.fill(HIST("Tracks/Centrality/DCAXY"), atrack.bestDCAXY(), - c); - QAregistry.fill(HIST("Tracks/Centrality/NclustersEtaBest"), - itrack.nClusters(), itrack.eta(), c); - if (itrack.collisionId() != atrack.bestCollisionId()) { - QAregistry.fill(HIST("Tracks/Centrality/ReTracksEtaZvtx"), - itrack.eta(), z, c); - QAregistry.fill(HIST("Tracks/Centrality/ReTracksPhiEta"), phi, - itrack.eta(), c); - } - QAregistry.fill(HIST("Tracks/Centrality/TrackAmbDegree"), - atrack.ambDegree(), c); - } else { - registry.fill(HIST("Tracks/EtaZvtxBest"), itrack.eta(), z); - registry.fill(HIST("Tracks/PhiEtaBest"), phi, itrack.eta()); - QAregistry.fill(HIST("Tracks/DCAXYPt"), itrack.pt(), - atrack.bestDCAXY()); - QAregistry.fill(HIST("Tracks/DCAXY"), atrack.bestDCAXY()); - QAregistry.fill(HIST("Tracks/NclustersEtaBest"), itrack.nClusters(), - itrack.eta()); - if (itrack.collisionId() != atrack.bestCollisionId()) { - QAregistry.fill(HIST("Tracks/ReTracksEtaZvtx"), itrack.eta(), z); - QAregistry.fill(HIST("Tracks/ReTracksPhiEta"), phi, itrack.eta()); - } - QAregistry.fill(HIST("Tracks/TrackAmbDegree"), atrack.ambDegree()); - } - } - ++nATrk; - } - } - return nATrk; - } - - template - int countPart(P const& particles) - { - auto nCharged = 0; - for (auto& particle : particles) { - if (!isChrgParticle(particle.pdgCode())) { - continue; - } - nCharged++; - } - return nCharged; - } - - template - bool isGoodEvent(C const& collision) - { - if constexpr (fillHis) { - registry.fill(HIST("hEvtSel"), 0); - } - if (!collision.sel8()) { - return false; - } - if constexpr (fillHis) { - registry.fill(HIST("hEvtSel"), 1); - } - if (!collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { - return false; - } - if constexpr (fillHis) { - registry.fill(HIST("hEvtSel"), 2); - } - if (!collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { - return false; - } - if constexpr (fillHis) { - registry.fill(HIST("hEvtSel"), 3); - } - if (std::abs(collision.posZ()) >= cfgCutZvtx) { - return false; - } - if constexpr (fillHis) { - registry.fill(HIST("hEvtSel"), 4); - } - if (requireNoCollInTimeRangeStd && - !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - return false; - } - if constexpr (fillHis) { - registry.fill(HIST("hEvtSel"), 5); - } - if (requireNoCollInTimeRangeNarrow && - !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { - return false; - } - if constexpr (fillHis) { - registry.fill(HIST("hEvtSel"), 6); - } - if (minOccupancy > 0 && - collision.trackOccupancyInTimeRange() < minOccupancy) { - return false; - } - if constexpr (fillHis) { - registry.fill(HIST("hEvtSel"), 7); - } - if (maxOccupancy > 0 && - collision.trackOccupancyInTimeRange() > maxOccupancy) { - return false; - } - if constexpr (fillHis) { - registry.fill(HIST("hEvtSel"), 8); - } - return true; - } - - /// @brief Selection of charged particles - /// @return true: charged; false: not charged - bool isChrgParticle(int code) - { - auto p = pdg->GetParticle(code); - auto charge = 0.; - if (p != nullptr) { - charge = p->Charge(); - } - return std::abs(charge) >= 3.; - } - - template - void fillHist_MC(P const& particles, float cent, float zvtx, - bool const atLeastOne) - { - for (auto& particle : particles) { - if (!isChrgParticle(particle.pdgCode())) { - continue; - } - - float phi = particle.phi(); - o2::math_utils::bringTo02Pi(phi); - if (phi < 0.f || 2.f * M_PI < phi) { - continue; - } - if constexpr (isCent) { - registry.fill(HIST("Tracks/Centrality/EtaZvtxGen_t"), particle.eta(), - zvtx, cent); - registry.fill(HIST("Tracks/Centrality/PhiEtaGen_t"), phi, - particle.eta(), cent); - } else { - registry.fill(HIST("Tracks/EtaZvtxGen_t"), particle.eta(), zvtx); - registry.fill(HIST("Tracks/PhiEtaGen_t"), phi, particle.eta()); - } - - if (atLeastOne) { - float phi = particle.phi(); - o2::math_utils::bringTo02Pi(phi); - if (phi < 0.f || 2.f * M_PI < phi) { - continue; - } - if constexpr (isCent) { - registry.fill(HIST("Tracks/Centrality/EtaZvtxGen"), particle.eta(), - zvtx, cent); - registry.fill(HIST("Tracks/Centrality/PhiEtaGen"), phi, - particle.eta(), cent); - } else { - registry.fill(HIST("Tracks/EtaZvtxGen"), particle.eta(), zvtx); - registry.fill(HIST("Tracks/PhiEtaGen"), phi, particle.eta()); - } - } - } - } - - /// @brief process fnc. for general event statistics - void processTagging(FullBCs const& bcs, CollsCent const& collisions) - { - std::vector::iterator> cols; - for (auto& bc : bcs) { - if ((bc.selection_bit(aod::evsel::kIsBBT0A) && - bc.selection_bit(aod::evsel::kIsBBT0C)) != 0) { - registry.fill(HIST("hBcSel"), 0); - cols.clear(); - for (auto& collision : collisions) { - if (collision.has_foundBC()) { - if (collision.foundBCId() == bc.globalIndex()) { - cols.emplace_back(collision); - } - } else if (collision.bcId() == bc.globalIndex()) { - cols.emplace_back(collision); - } - } - LOGP(debug, "BC {} has {} collisions", bc.globalBC(), cols.size()); - if (!cols.empty()) { - registry.fill(HIST("hBcSel"), 1); - if (cols.size() > 1) { - registry.fill(HIST("hBcSel"), 2); - } - } - } - } - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processTagging, - "Collect event sample stats", true); - - template - void processData(typename C::iterator const& collision, - filtMftTracks const& tracks) - { - float c = -1; - if constexpr (C::template contains()) { - c = collision.centFT0C(); - registry.fill(HIST("Events/Centrality/Selection"), 1., c); - } else { - registry.fill(HIST("Events/Selection"), 1.); - } - if (!isGoodEvent(collision)) { - return; - } - auto z = collision.posZ(); - auto occ = collision.trackOccupancyInTimeRange(); - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/Selection"), 2., c); - QAregistry.fill(HIST("Events/Centrality/Occupancy"), z, c, occ); - QAregistry.fill(HIST("Events/Centrality/hcentFT0C"), c); - } else { - registry.fill(HIST("Events/Selection"), 2.); - } - - auto nTrk = countTracks( - tracks, z, c, occ); //!@note here we obtain eta-z and phi-eta - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/NtrkZvtx"), nTrk, z, c); - } else { - registry.fill(HIST("Events/NtrkZvtx"), nTrk, z); - } - } - - template - void processDatawBestTracks( - typename C::iterator const& collision, filtMftTracks const& tracks, - soa::SmallGroups const& besttracks) - { - float c = -1; - if constexpr (C::template contains()) { - c = collision.centFT0C(); - registry.fill(HIST("Events/Centrality/Selection"), 1., c); - } else { - registry.fill(HIST("Events/Selection"), 1.); - } - if (!isGoodEvent(collision)) { - return; - } - auto z = collision.posZ(); - auto occ = collision.trackOccupancyInTimeRange(); - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/Selection"), 2., c); - QAregistry.fill(HIST("Events/Centrality/OccupancyBest"), z, c, occ); - } else { - registry.fill(HIST("Events/Selection"), 2.); - } - - auto nBestTrks = - countBestTracks(tracks, besttracks, z, c, - occ); //!@note here we obtain eta-z and phi-eta - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/NtrkZvtxBest"), nBestTrks, z, c); - } else { - registry.fill(HIST("Events/NtrkZvtxBest"), nBestTrks, z); - } - } - - /// @brief process fnc. to run on DATA and REC MC w/o centrality selection - void processDataInclusive(Colls::iterator const& collision, - filtMftTracks const& tracks) - { - processData(collision, tracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processDataInclusive, "Count tracks", - false); - - /// @brief process fnc. to run on DATA and REC MC w/ FT0C centrality selection - void processDataCent(CollsCent::iterator const& collision, - filtMftTracks const& tracks) - { - processData(collision, tracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processDataCent, - "Count tracks in FT0C bins", false); - - /// @brief process fnc. to run on DATA and REC MC based on BestCollisionsFwd - /// table w/o centrality selection - void processDatawBestTracksInclusive( - Colls::iterator const& collision, filtMftTracks const& tracks, - soa::SmallGroups const& besttracks) - { - processDatawBestTracks(collision, tracks, besttracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processDatawBestTracksInclusive, - "Count tracks based on BestCollisionsFwd table", false); - - /// @brief process fnc. to run on DATA and REC MC based on BestCollisionsFwd - /// table w/ FT0C centrality selection - void processDatawBestTracksCent( - CollsCent::iterator const& collision, filtMftTracks const& tracks, - soa::SmallGroups const& besttracks) - { - processDatawBestTracks(collision, tracks, besttracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processDatawBestTracksCent, - "Count tracks in FT0C bins based on BestCollisionsFwd table", - false); - - Preslice perCol = o2::aod::fwdtrack::collisionId; - Partition mcSample = nabs(aod::mcparticle::eta) < 1.0f; - - /// @brief process template function to run on MC truth - /// @param cols subscribe to the collisions - /// @param parts subscribe to filtered MC particle table - template - void processMC( - typename MC::iterator const& mcCollision, - soa::SmallGroups> const& collisions, - filtParticles const& particles, filtMcMftTracks const& tracks) - { - float c_gen = -1; - bool atLeastOne = false; - int moreThanOne = 0; - for (auto& collision : collisions) { - float c_rec = -1; - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - registry.fill(HIST("Events/Centrality/EvtEffGen"), 1., c_rec); - } else { - registry.fill(HIST("Events/EvtEffGen"), 1.); - } - - if (isGoodEvent(collision)) { - if constexpr (C::template contains()) { - if (!atLeastOne) { - c_gen = c_rec; - } - } - atLeastOne = true; - ++moreThanOne; - auto z = collision.posZ(); - - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/EvtEffGen"), 2., c_rec); - registry.fill(HIST("Events/Centrality/hRecCent"), c_rec); - registry.fill(HIST("Events/Centrality/hRecZvtxCent"), z, c_rec); - } else { - registry.fill(HIST("Events/EvtEffGen"), 2.); - } - - auto perCollisionSample = - tracks.sliceBy(perCol, collision.globalIndex()); - auto nTrkRec = - countTracks(perCollisionSample, z, c_rec, - collision.trackOccupancyInTimeRange()); - - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Events/Centrality/ZvtxDiff"), - collision.posZ() - mcCollision.posZ(), c_rec); - } else { - QAregistry.fill(HIST("Events/ZvtxDiff"), - collision.posZ() - mcCollision.posZ()); - } - - if (useZDiffCut) { - if (std::abs(collision.posZ() - mcCollision.posZ()) > maxZvtxDiff) { - continue; - } - } - - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/NtrkZvtxGen"), nTrkRec, - collision.posZ(), c_rec); - } else { - registry.fill(HIST("Events/NtrkZvtxGen"), nTrkRec, collision.posZ()); - } - } - } - - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/EvtEffGen"), 3., c_gen); - } else { - registry.fill(HIST("Events/EvtEffGen"), 3.); - } - - auto perCollMCsample = mcSample->sliceByCached( - aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); - auto Nchrg = countPart(perCollMCsample); - if (moreThanOne > 1) { - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Events/Centrality/SplitMult"), Nchrg, c_gen); - } else { - QAregistry.fill(HIST("Events/SplitMult"), Nchrg); - } - } - - auto zvtxMC = mcCollision.posZ(); - auto nCharged = countPart(particles); - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/NtrkZvtxGen_t"), nCharged, zvtxMC, - c_gen); - } else { - registry.fill(HIST("Events/NtrkZvtxGen_t"), nCharged, zvtxMC); - } - - fillHist_MC()>(particles, c_gen, - zvtxMC, atLeastOne); - - if (collisions.size() == 0) { - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Events/Centrality/NotFoundEventZvtx"), - mcCollision.posZ(), c_gen); - } else { - QAregistry.fill(HIST("Events/NotFoundEventZvtx"), mcCollision.posZ()); - } - } - } - - /// @brief process fnc. to run on MC w/o centrality selection - void processMCInclusive( - aod::McCollisions::iterator const& mccollision, - soa::SmallGroups> const& collisions, - filtParticles const& particles, filtMcMftTracks const& tracks) - { - processMC(mccollision, collisions, particles, - tracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processMCInclusive, - "Count MC particles", false); - - /// @brief process fnc. to run on MC w FT0C centrality selection - void processMCCent( - aod::McCollisions::iterator const& mccollision, - soa::SmallGroups> const& collisions, - filtParticles const& particles, filtMcMftTracks const& tracks) - { - processMC(mccollision, collisions, particles, - tracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processMCCent, - "Count MC particles in FT0C bins", false); - - PresliceUnsorted perColU = - aod::fwdtrack::bestCollisionId; - - /// @brief process template function to run on MC truth using - /// aod::BestCollisionsFwd tracks - template - void processMCwBestTracks( - typename MC::iterator const& mcCollision, - soa::SmallGroups> const& collisions, - filtParticles const& particles, filtMcMftTracks const& tracks, - filtBestTracks const& besttracks) - { - float c_gen = -1; - bool atLeastOne = false; - // int moreThanOne = 0; - for (auto& collision : collisions) { - float c_rec = -1; - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - registry.fill(HIST("Events/Centrality/EvtEffGen"), 1., c_rec); - } else { - registry.fill(HIST("Events/EvtEffGen"), 1.); - } - - if (isGoodEvent(collision)) { - if constexpr (C::template contains()) { - if (!atLeastOne) { - c_gen = c_rec; - } - } - atLeastOne = true; - // ++moreThanOne; - auto z = collision.posZ(); - - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/EvtEffGen"), 2., c_rec); - } else { - registry.fill(HIST("Events/EvtEffGen"), 2.); - } - - auto perCollisionSample = - tracks.sliceBy(perCol, collision.globalIndex()); - auto perCollisionASample = - besttracks.sliceBy(perColU, collision.globalIndex()); - auto nTrkRec = countBestTracks( - perCollisionSample, perCollisionASample, z, c_rec, - collision.trackOccupancyInTimeRange()); - - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/NtrkZvtxGen"), nTrkRec, z, - c_rec); - } else { - registry.fill(HIST("Events/NtrkZvtxGen"), nTrkRec, z); - } - } - } - - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/EvtEffGen"), 3., c_gen); - } else { - registry.fill(HIST("Events/EvtEffGen"), 3.); - } - - auto zvtxMC = mcCollision.posZ(); - auto nCharged = countPart(particles); - if constexpr (C::template contains()) { - registry.fill(HIST("Events/Centrality/NtrkZvtxGen_t"), nCharged, zvtxMC, - c_gen); - } else { - registry.fill(HIST("Events/NtrkZvtxGen_t"), nCharged, zvtxMC); - } - - fillHist_MC()>(particles, c_gen, - zvtxMC, atLeastOne); - - if (collisions.size() == 0) { - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Events/Centrality/NotFoundEventZvtx"), - mcCollision.posZ(), c_gen); - } else { - QAregistry.fill(HIST("Events/NotFoundEventZvtx"), mcCollision.posZ()); - } - } - } - - /// @brief process fnc. to run on MC (inclusive, using aod::BestCollisionsFwd - /// tracks) - void processMCwBestTracksInclusive( - aod::McCollisions::iterator const& mccollision, - soa::SmallGroups> const& collisions, - filtParticles const& particles, filtMcMftTracks const& tracks, - // aod::BestCollisionsFwd const - // &besttracks - filtBestTracks const& besttracks) - { - processMCwBestTracks( - mccollision, collisions, particles, tracks, besttracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processMCwBestTracksInclusive, - "Count MC particles using aod::BestCollisionsFwd", false); - - /// @brief process fnc. to run on MC (FT0C centrality, using - /// aod::BestCollisionsFwd tracks) - void processMCwBestTracksCent( - aod::McCollisions::iterator const& mccollision, - soa::SmallGroups> const& collisions, - filtParticles const& particles, filtMcMftTracks const& tracks, - filtBestTracks const& besttracks) - { - processMCwBestTracks( - mccollision, collisions, particles, tracks, besttracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processMCwBestTracksCent, - "Count MC particles in FT0C bins using aod::BestCollisionsFwd", - false); - - using ParticlesI = soa::Join; - Partition primariesI = - ((aod::mcparticle::flags & - (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary) == - (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary); - - /// @brief process template function to calculate tracking efficiency (indexed - /// as particle-to-MFT-tracks) - template - void processTrkEffIdx( - typename soa::Filtered> const& collisions, - MC const& /*mccollisions*/, ParticlesI const& /*particles*/, - MFTTracksLabeled const& tracks) - { - for (auto& collision : collisions) { - if (!isGoodEvent(collision)) { - continue; - } - if (!collision.has_mcCollision()) { - continue; - } - - float c_rec = -1; - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - } - - auto mcCollision = collision.mcCollision(); - auto particlesPerCol = primariesI->sliceByCached( - aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); - particlesPerCol.bindExternalIndices(&tracks); - - for (auto& particle : particlesPerCol) { - if (!isChrgParticle(particle.pdgCode())) { - continue; - } - // MC gen - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Tracks/Centrality/hPtPhiEtaZvtxEffGen"), - particle.pt(), particle.phi(), particle.eta(), - mcCollision.posZ(), c_rec); - } else { - QAregistry.fill(HIST("Tracks/hPtPhiEtaZvtxEffGen"), particle.pt(), - particle.phi(), particle.eta(), mcCollision.posZ()); - } - // MC rec - if (particle.has_mfttracks()) { - auto iscounted = false; - auto ncnt = 0; - auto relatedTracks = - particle.template mfttracks_as(); - for (auto& track : relatedTracks) { - if (!isTrackSelected(track)) { - continue; - } - ++ncnt; - if constexpr (C::template contains()) { - if (!iscounted) { // primaries - QAregistry.fill(HIST("Tracks/Centrality/hPtPhiEtaZvtxEffRec"), - particle.pt(), particle.phi(), particle.eta(), - mcCollision.posZ(), c_rec); - iscounted = true; - } - if (ncnt > 1) { // duplicates - QAregistry.fill(HIST("Tracks/Centrality/hPhiEtaDuplicates"), - track.phi(), track.eta(), c_rec); - QAregistry.fill( - HIST("Tracks/Centrality/hPtPhiEtaZvtxEffDuplicates"), - particle.pt(), particle.phi(), particle.eta(), - mcCollision.posZ(), c_rec); - } - } else { - if (!iscounted) { // primaries - QAregistry.fill(HIST("Tracks/hPtPhiEtaZvtxEffRec"), - particle.pt(), particle.phi(), particle.eta(), - mcCollision.posZ()); - iscounted = true; - } - if (ncnt > 1) { // duplicates - QAregistry.fill(HIST("Tracks/hPhiEtaDuplicates"), track.phi(), - track.eta()); - QAregistry.fill(HIST("Tracks/hPtPhiEtaZvtxEffDuplicates"), - particle.pt(), particle.phi(), particle.eta(), - mcCollision.posZ()); - } - } - } - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Tracks/Centrality/NmftTrkPerPart"), ncnt, - c_rec); - } else { - QAregistry.fill(HIST("Tracks/NmftTrkPerPart"), ncnt); - } - if (relatedTracks.size() > 1) { - if constexpr (C::template contains()) { - QAregistry.fill( - HIST("Tracks/Centrality/hPtPhiEtaZvtxEffGenDuplicates"), - particle.pt(), particle.phi(), particle.eta(), - mcCollision.posZ(), c_rec); - } else { - QAregistry.fill(HIST("Tracks/hPtPhiEtaZvtxEffGenDuplicates"), - particle.pt(), particle.phi(), particle.eta(), - mcCollision.posZ()); - } - } - } - } - } - } - - /// @brief process function to calculate tracking efficiency (inclusive, - /// indexed) - void processTrkEffIdxInlusive( - soa::Filtered> const& collisions, - aod::McCollisions const& mccollisions, ParticlesI const& particles, - MFTTracksLabeled const& tracks) - { - processTrkEffIdx(collisions, mccollisions, - particles, tracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processTrkEffIdxInlusive, - "Process tracking efficiency (inclusive)", false); - - /// @brief process function to calculate tracking efficiency (FT0 bins, - /// indexed) - void processTrkEffIdxCent( - soa::Filtered> const& collisions, - aod::McCollisions const& mccollisions, ParticlesI const& particles, - MFTTracksLabeled const& tracks) - { - processTrkEffIdx(collisions, mccollisions, - particles, tracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processTrkEffIdxCent, - "Process tracking efficiency in FT0 bins", false); - - /// @brief process function to calculate tracking efficiency (indexed) based - /// on BestCollisionsFwd in FT0C bins - template - void processTrkEffBest( - typename soa::Filtered< - soa::Join>::iterator const& collision, - MC const& /*mccollisions*/, filtParticles const& particles, - filtMcMftTracks const& /*tracks*/, - soa::SmallGroups const& besttracks) - { - if (!isGoodEvent(collision)) { - return; - } - if (!collision.has_mcCollision()) { - return; - } - - float c_rec = -1; - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - } - - auto mcCollision = collision.mcCollision(); - auto particlesPerCol = particles.sliceByCached( - aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); - for (auto& particle : particlesPerCol) { - if (!isChrgParticle(particle.pdgCode())) { - continue; - } - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Tracks/Centrality/hPtPhiEtaZvtxEffBestGen"), - particle.pt(), particle.phi(), particle.eta(), - mcCollision.posZ(), c_rec); - } else { - QAregistry.fill(HIST("Tracks/hPtPhiEtaZvtxEffBestGen"), particle.pt(), - particle.phi(), particle.eta(), mcCollision.posZ()); - } - } - - for (auto const& track : besttracks) { - auto itrack = track.mfttrack_as(); - if (!isTrackSelected(itrack)) { - continue; - } - if (itrack.has_mcParticle()) { - auto particle = itrack.mcParticle_as(); - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Tracks/Centrality/hPtPhiEtaZvtxEffBestRec"), - particle.pt(), itrack.phi(), itrack.eta(), - mcCollision.posZ(), c_rec); - } else { - QAregistry.fill(HIST("Tracks/hPtPhiEtaZvtxEffBestRec"), particle.pt(), - itrack.phi(), itrack.eta(), mcCollision.posZ()); - } - } else { - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Tracks/Centrality/hPtEffBestFakeRec"), - itrack.pt(), c_rec); - } else { - QAregistry.fill(HIST("Tracks/hPtEffBestFakeRec"), itrack.pt()); - } - } - } - } - - /// @brief process function to calculate tracking efficiency (inclusive, based - /// on BestCollisionsFwd) - void processTrkEffBestInclusive( - soa::Filtered>::iterator const& collision, - aod::McCollisions const& mccollisions, filtParticles const& particles, - filtMcMftTracks const& tracks, - soa::SmallGroups const& besttracks) - { - processTrkEffBest(collision, mccollisions, - particles, tracks, besttracks); - } - - PROCESS_SWITCH( - PseudorapidityDensityMFT, processTrkEffBestInclusive, - "Process tracking efficiency (inclusive, based on BestCollisionsFwd)", - false); - - /// @brief process function to calculate tracking efficiency (in FT0 bins, - /// based on BestCollisionsFwd) - void processTrkEffBestCent( - soa::Filtered>:: - iterator const& collision, - aod::McCollisions const& mccollisions, filtParticles const& particles, - filtMcMftTracks const& tracks, - soa::SmallGroups const& besttracks) - { - processTrkEffBest( - collision, mccollisions, particles, tracks, besttracks); - } - - PROCESS_SWITCH( - PseudorapidityDensityMFT, processTrkEffBestCent, - "Process tracking efficiency (in FT0 bins, based on BestCollisionsFwd)", - false); - - Preslice filtTrkperCol = o2::aod::fwdtrack::collisionId; - - /// @brief process template function for MC QA checks - template - void processMcQA( - typename soa::SmallGroups> const& collisions, - aod::McCollisions const& mcCollisions, - filtParticles const& /*particles*/, MFTTracksLabeled const& tracks, - aod::AmbiguousMFTTracks const& atracks) - { - for (const auto& collision : collisions) { - float c_rec = -1; - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - QAregistry.fill( - HIST("Events/Centrality/hRecPerGenColls"), - static_cast(collisions.size()) / mcCollisions.size(), c_rec); - } else { - QAregistry.fill(HIST("Events/hRecPerGenColls"), - static_cast(collisions.size()) / - mcCollisions.size()); - } - - if (!isGoodEvent(collision)) { - return; - } - - auto trkPerColl = tracks.sliceBy(filtTrkperCol, collision.globalIndex()); - uint Ntracks{0u}, Natracks{0u}; - for (const auto& track : trkPerColl) { - Ntracks++; - for (const auto& atrack : atracks) { - if (atrack.mfttrackId() == track.globalIndex()) { - Natracks++; - break; - } - } - } - if constexpr (C::template contains()) { - QAregistry.fill(HIST("Tracks/Centrality/hNmftTrks"), Ntracks, c_rec); - QAregistry.fill(HIST("Tracks/Centrality/hFracAmbiguousMftTrks"), - static_cast(Natracks) / Ntracks, c_rec); - } else { - QAregistry.fill(HIST("Tracks/hNmftTrks"), Ntracks); - QAregistry.fill(HIST("Tracks/hFracAmbiguousMftTrks"), - static_cast(Natracks) / Ntracks); - } - } - } - - /// @brief process function for QA checks (inclusive) - void processMcQAInclusive( - soa::SmallGroups> const& collisions, - aod::McCollisions const& mcCollisions, filtParticles const& particles, - MFTTracksLabeled const& tracks, aod::AmbiguousMFTTracks const& atracks) - { - processMcQA(collisions, mcCollisions, particles, tracks, atracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processMcQAInclusive, - "Process MC QA checks (inclusive)", false); - - /// @brief process function for QA checks (in FT0 bins) - void processMcQACent( - soa::SmallGroups> const& collisions, - aod::McCollisions const& mcCollisions, filtParticles const& particles, - MFTTracksLabeled const& tracks, aod::AmbiguousMFTTracks const& atracks) - { - processMcQA(collisions, mcCollisions, particles, tracks, - atracks); - } - - PROCESS_SWITCH(PseudorapidityDensityMFT, processMcQACent, - "Process MC QA checks (in FT0 bins)", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/PWGMM/Mult/Tasks/dndeta-mft.cxx b/PWGMM/Mult/Tasks/dndeta-mft.cxx index 7d52a606226..f70cc1d638a 100644 --- a/PWGMM/Mult/Tasks/dndeta-mft.cxx +++ b/PWGMM/Mult/Tasks/dndeta-mft.cxx @@ -1,4 +1,4 @@ -// Copyright 2020-2022 CERN and copyright holders of ALICE O2. +// Copyright 2020-2025 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. // diff --git a/PWGMM/Mult/Tasks/dndetaMFTPbPb.cxx b/PWGMM/Mult/Tasks/dndetaMFTPbPb.cxx new file mode 100644 index 00000000000..f8e01e36a7e --- /dev/null +++ b/PWGMM/Mult/Tasks/dndetaMFTPbPb.cxx @@ -0,0 +1,2187 @@ +// 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. +// +/// +/// \file dndetaMFTPbPb.cxx +/// \brief Task for calculating dNdeta in Pb-Pb collisions using MFT detector +/// \author Gyula Bencedi, gyula.bencedi@cern.ch +/// \since Nov 2024 + +#include "Functions.h" +#include "Index.h" +#include "bestCollisionTable.h" + +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/MathConstants.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/RuntimeError.h" +#include "Framework/runDataProcessing.h" +#include "MathUtils/Utils.h" +#include "ReconstructionDataFormats/GlobalTrackID.h" + +#include "TPDGCode.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::track; +using namespace o2::aod::fwdtrack; +using namespace o2::constants::physics; +using namespace o2::constants::math; +using namespace pwgmm::mult; + +AxisSpec ptAxis = {1001, -0.005, 10.005}; +AxisSpec multAxis = {701, -0.5, 700.5, "N_{trk}"}; +AxisSpec zAxis = {60, -30., 30.}; +AxisSpec deltaZAxis = {61, -6.1, 6.1}; +AxisSpec dcaxyAxis = {500, -1, 50}; +AxisSpec phiAxis = {629, 0, TwoPI, "Rad", "#phi"}; +AxisSpec etaAxis = {20, -4., -2.}; +AxisSpec centAxis{100, 0, 100, "centrality"}; +AxisSpec chiSqAxis = {100, 0., 1000.}; + +struct DndetaMFTPbPb { + SliceCache cache; + + enum OccupancyEst { TrkITS = 1, + Ft0C }; + + HistogramRegistry registry{ + "registry", + {}, + OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry qaregistry{ + "qaregistry", + {}, + OutputObjHandlingPolicy::AnalysisObject, + false, + true}; + + Configurable cfgDoIR{"cfgDoIR", false, "Flag to retrieve Interaction rate from CCDB"}; + Configurable cfgUseIRCut{"cfgUseIRCut", false, "Flag to cut on IR rate"}; + Configurable cfgIRCrashOnNull{"cfgIRCrashOnNull", false, "Flag to avoid CTP RateFetcher crash"}; + Configurable cfgIRSource{"cfgIRSource", "T0VTX", "Estimator of the interaction rate (Pb-Pb: ZNC hadronic)"}; + + struct : ConfigurableGroup { + Configurable usephiCut{"usephiCut", false, "use azimuthal angle cut"}; + Configurable phiCut{"phiCut", 0.1f, + "Cut on azimuthal angle of MFT tracks"}; + Configurable minPhi{"minPhi", 0.f, ""}; + Configurable maxPhi{"maxPhi", 6.2832, ""}; + Configurable minEta{"minEta", -3.6f, ""}; + Configurable maxEta{"maxEta", -2.5f, ""}; + Configurable minNclusterMft{"minNclusterMft", 5, + "minimum number of MFT clusters"}; + Configurable useChi2Cut{"useChi2Cut", false, "use track chi2 cut"}; + Configurable maxChi2NCl{"maxChi2NCl", 1000.f, "maximum chi2 per MFT clusters"}; + Configurable minPt{"minPt", 0., "minimum pT of the MFT tracks"}; + Configurable requireCA{ + "requireCA", false, "Use Cellular Automaton track-finding algorithm"}; + Configurable maxDCAxy{"maxDCAxy", 2.0f, "Cut on dcaXY"}; + } trackCuts; + + struct : ConfigurableGroup { + Configurable maxZvtx{"maxZvtx", 10.0f, "Cut on z-vtx"}; + Configurable useZDiffCut{"useZDiffCut", false, + "use Zvtx reco-mc diff. cut"}; + Configurable maxZvtxDiff{ + "maxZvtxDiff", 1.0f, + "max allowed Z vtx difference for reconstruced collisions (cm)"}; + Configurable requireIsGoodZvtxFT0VsPV{"requireIsGoodZvtxFT0VsPV", true, "require events with PV position along z consistent (within 1 cm) between PV reconstructed using tracks and PV using FT0 A-C time difference"}; + Configurable requireRejectSameBunchPileup{"requireRejectSameBunchPileup", true, "reject collisions in case of pileup with another collision in the same foundBC"}; + Configurable requireNoCollInTimeRangeStrict{"requireNoCollInTimeRangeStrict", true, " requireNoCollInTimeRangeStrict"}; + Configurable requireNoCollInRofStrict{"requireNoCollInRofStrict", true, "requireNoCollInRofStrict"}; + Configurable requireNoCollInRofStandard{"requireNoCollInRofStandard", false, "requireNoCollInRofStandard"}; + Configurable requireNoHighMultCollInPrevRof{"requireNoHighMultCollInPrevRof", true, "requireNoHighMultCollInPrevRof"}; + Configurable requireNoCollInTimeRangeStd{ + "requireNoCollInTimeRangeStd", false, + "reject collisions corrupted by the cannibalism, with other collisions " + "within +/- 10 microseconds"}; + Configurable requireNoCollInTimeRangeNarrow{ + "requireNoCollInTimeRangeNarrow", false, + "reject collisions corrupted by the cannibalism, with other collisions " + "within +/- 10 microseconds"}; + Configurable occupancyEstimator{ + "occupancyEstimator", 1, + "Occupancy estimator: 1 = trackOccupancyInTimeRange, 2 = " + "ft0cOccupancyInTimeRange"}; + Configurable minOccupancy{ + "minOccupancy", -1, "minimum occupancy from neighbouring collisions"}; + Configurable maxOccupancy{ + "maxOccupancy", -1, "maximum occupancy from neighbouring collisions"}; + Configurable minIR{"minIR", -1, "minimum IR (kHz) collisions"}; + Configurable maxIR{"maxIR", -1, "maximum IR (kHz) collisions"}; + } eventCuts; + + ConfigurableAxis occupancyBins{"occupancyBins", + {VARIABLE_WIDTH, 0.0f, 250.0f, 500.0f, 750.0f, + 1000.0f, 1500.0f, 2000.0f, 3000.0f, 4500.0f, + 6000.0f, 8000.0f, 10000.0f, 50000.0f}, + "Occupancy"}; + ConfigurableAxis centralityBins{ + "centralityBins", + {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, + "Centrality"}; + ConfigurableAxis irBins{"irBins", {500, 0, 50}, "Interaction rate (kHz)"}; + + Service pdg; + + Service ccdb; + Configurable ccdbNoLaterThan{ + "ccdbNoLaterThan", + std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(), + "latest acceptable timestamp of creation for the object"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", + "url of the ccdb repository"}; + + int mRunNumber{-1}; + uint64_t mSOR{0}; + double mMinSeconds{-1.}; + std::unordered_map gHadronicRate; + ctpRateFetcher rateFetcher; + TH2* gCurrentHadronicRate; + + /// @brief init function, definition of histograms + void init(InitContext&) + { + ccdb->setURL(ccdbUrl.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + ccdb->setFatalWhenNull(false); + + if (static_cast(doprocessDataInclusive) + + static_cast(doprocessDatawBestTracksInclusive) > + 1) { + LOGP(fatal, + "Either processDataInclusive OR " + "processDatawBestTracksInclusive should be enabled!"); + } + if ((static_cast(doprocessDataCentFT0C) + + static_cast(doprocessDatawBestTracksCentFT0C) > + 1) || + (static_cast(doprocessDataCentFT0CVariant1) + + static_cast(doprocessDatawBestTracksCentFT0CVariant1) > + 1) || + (static_cast(doprocessDataCentFT0M) + + static_cast(doprocessDatawBestTracksCentFT0M) > + 1) || + (static_cast(doprocessDataCentNGlobal) + + static_cast(doprocessDatawBestTracksCentNGlobal) > + 1) || + (static_cast(doprocessDataCentMFT) + + static_cast(doprocessDatawBestTracksCentMFT) > + 1)) { + LOGP(fatal, + "Either processDataCent[ESTIMATOR] OR " + "processDatawBestTracksCent[ESTIMATOR] should " + "be enabled!"); + } + if (static_cast(doprocessMCInclusive) + + static_cast(doprocessMCwBestTracksInclusive) > + 1) { + LOGP(fatal, + "Either processMCInclusive OR processMCwBestTracksInclusive " + "should be enabled!"); + } + if ((static_cast(doprocessMCCentFT0C) + + static_cast(doprocessMCwBestTracksCentFT0C) > + 1) || + (static_cast(doprocessMCCentFT0CVariant1) + + static_cast(doprocessMCwBestTracksCentFT0CVariant1) > + 1) || + (static_cast(doprocessMCCentFT0M) + + static_cast(doprocessMCwBestTracksCentFT0M) > + 1) || + (static_cast(doprocessMCCentNGlobal) + + static_cast(doprocessMCwBestTracksCentNGlobal) > + 1) || + (static_cast(doprocessMCCentMFT) + + static_cast(doprocessMCwBestTracksCentMFT) > + 1)) { + LOGP(fatal, + "Either processMCCent[ESTIMATOR] OR " + "processMCwBestTracksCent[ESTIMATOR] should " + "be enabled!"); + } + + auto hev = registry.add("hEvtSel", "hEvtSel", HistType::kTH1F, + {{14, -0.5f, +13.5f}}); + hev->GetXaxis()->SetBinLabel(1, "All collisions"); + hev->GetXaxis()->SetBinLabel(2, "Ev. sel."); + hev->GetXaxis()->SetBinLabel(3, "kIsGoodZvtxFT0vsPV"); + hev->GetXaxis()->SetBinLabel(4, "NoSameBunchPileup"); + hev->GetXaxis()->SetBinLabel(5, "Z-vtx cut"); + hev->GetXaxis()->SetBinLabel(6, "kNoCollInTimeRangeStd"); + hev->GetXaxis()->SetBinLabel(7, "kNoCollInTimeRangeNarrow"); + hev->GetXaxis()->SetBinLabel(8, "kNoCollInTimeRangeStrict"); + hev->GetXaxis()->SetBinLabel(9, "kNoCollInRofStrict"); + hev->GetXaxis()->SetBinLabel(10, "kNoCollInRofStandard"); + hev->GetXaxis()->SetBinLabel(11, "kNoHighMultCollInPrevRof"); + hev->GetXaxis()->SetBinLabel(12, "Below min occup."); + hev->GetXaxis()->SetBinLabel(13, "Above max occup."); + + auto hBcSel = registry.add("hBcSel", "hBcSel", HistType::kTH1F, + {{3, -0.5f, +2.5f}}); + hBcSel->GetXaxis()->SetBinLabel(1, "Good BCs"); + hBcSel->GetXaxis()->SetBinLabel(2, "BCs with collisions"); + hBcSel->GetXaxis()->SetBinLabel(3, "BCs with pile-up/splitting"); + + AxisSpec centralityAxis = {centralityBins, "Centrality", "centralityAxis"}; + AxisSpec occupancyAxis = {occupancyBins, "Occupancy", "occupancyAxis"}; + + if (doprocessDataInclusive || doprocessDatawBestTracksInclusive || + doprocessMCInclusive || doprocessMCwBestTracksInclusive) { + registry.add({"Events/Selection", + ";status;occupancy", + {HistType::kTH2F, {{2, 0.5, 2.5}, occupancyAxis}}}); + auto hstat = registry.get(HIST("Events/Selection")); + auto* x = hstat->GetXaxis(); + x->SetBinLabel(1, "All"); + x->SetBinLabel(2, "Selected"); + + registry.add({"Events/NtrkZvtx", + "; N_{trk}; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, {multAxis, zAxis, occupancyAxis}}}); + registry.add({"Tracks/EtaZvtx", + "; #eta; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, {etaAxis, zAxis, occupancyAxis}}}); + registry.add( + {"Tracks/PhiEta", + "; #varphi; #eta; occupancy", + {HistType::kTHnSparseF, {phiAxis, etaAxis, occupancyAxis}}}); + + qaregistry.add( + {"Tracks/Chi2Eta", + "; #chi^{2}; #it{#eta}; occupancy", + {HistType::kTHnSparseF, {chiSqAxis, etaAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Chi2", + "; #chi^{2};", + {HistType::kTH2F, {chiSqAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/NclustersEta", + "; nClusters; #eta; occupancy", + {HistType::kTHnSparseF, {{7, 4, 10}, etaAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/NchSel", + "; N_{ch}; occupancy", + {HistType::kTH2F, {multAxis, occupancyAxis}}}); + + if (doprocessDatawBestTracksInclusive) { + registry.add( + {"Events/NtrkZvtxBest", + "; N_{trk}; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, {multAxis, zAxis, occupancyAxis}}}); + registry.add( + {"Tracks/EtaZvtxBest", + "; #eta; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, {etaAxis, zAxis, occupancyAxis}}}); + registry.add( + {"Tracks/PhiEtaBest", + "; #varphi; #eta; occupancy", + {HistType::kTHnSparseF, {phiAxis, etaAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/NclustersEtaBest", + "; nClusters; #eta; occupancy", + {HistType::kTHnSparseF, {{7, 4, 10}, etaAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/DCAXYPt", + "; p_{T} (GeV/c) ; DCA_{XY} (cm); occupancy", + {HistType::kTHnSparseF, {ptAxis, dcaxyAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/DCAXY", + "; DCA_{XY} (cm); occupancy", + {HistType::kTH2F, {dcaxyAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/ReTracksEtaZvtx", + "; #eta; #it{z}_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, {etaAxis, zAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/ReTracksPhiEta", + "; #varphi; #eta; occupancy", + {HistType::kTHnSparseF, {phiAxis, etaAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/TrackAmbDegree", + "; N_{coll}^{comp}; occupancy", + {HistType::kTH2F, {{51, -0.5, 50.5}, occupancyAxis}}}); + } + } + + if (doprocessDataCentFT0C || doprocessDatawBestTracksCentFT0C || + doprocessMCCentFT0C || doprocessMCwBestTracksCentFT0C || + doprocessDataCentFT0CVariant1 || + doprocessDatawBestTracksCentFT0CVariant1 || + doprocessMCCentFT0CVariant1 || doprocessMCwBestTracksCentFT0CVariant1 || + doprocessDataCentFT0M || doprocessDatawBestTracksCentFT0M || + doprocessMCCentFT0M || doprocessMCwBestTracksCentFT0M || + doprocessDataCentNGlobal || doprocessDatawBestTracksCentNGlobal || + doprocessMCCentNGlobal || doprocessMCwBestTracksCentNGlobal || + doprocessDataCentMFT || doprocessDatawBestTracksCentMFT || + doprocessMCCentMFT || doprocessMCwBestTracksCentMFT) { + registry.add({"Events/Centrality/Selection", + ";status;centrality;occupancy", + {HistType::kTHnSparseF, + {{2, 0.5, 2.5}, centralityAxis, occupancyAxis}}}); + auto hstat = registry.get(HIST("Events/Centrality/Selection")); + hstat->GetAxis(0)->SetBinLabel(1, "All"); + hstat->GetAxis(0)->SetBinLabel(2, "Selected"); + + qaregistry.add({"Events/Centrality/hCent", + "; centrality; occupancy", + {HistType::kTH2F, {centAxis, occupancyAxis}}, + true}); + qaregistry.add( + {"Events/Centrality/hZvtxCent", + "; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, {zAxis, centralityAxis, occupancyAxis}}}); + registry.add({"Events/Centrality/NtrkZvtx", + "; N_{trk}; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {multAxis, zAxis, centralityAxis, occupancyAxis}}}); + registry.add({"Tracks/Centrality/EtaZvtx", + "; #eta; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {etaAxis, zAxis, centralityAxis, occupancyAxis}}}); + registry.add({"Tracks/Centrality/PhiEta", + "; #varphi; #eta; centrality; occupancy", + {HistType::kTHnSparseF, + {phiAxis, etaAxis, centralityAxis, occupancyAxis}}}); + + qaregistry.add( + {"Tracks/Centrality/NchSel", + "; N_{ch}; centrality; occupancy", + {HistType::kTHnSparseF, {multAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/Chi2Eta", + "; #chi^{2}; #it{#eta}; centrality; occupancy", + {HistType::kTHnSparseF, + {chiSqAxis, etaAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Centrality/Chi2", + "; #chi^{2}; centrality; occupancy", + {HistType::kTHnSparseF, + {chiSqAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Centrality/NclustersEta", + "; nClusters; #eta; centrality; occupancy", + {HistType::kTHnSparseF, + {{7, 4, 10}, etaAxis, centralityAxis, occupancyAxis}}}); + + if (doprocessDatawBestTracksCentFT0C || + doprocessDatawBestTracksCentFT0CVariant1 || + doprocessDatawBestTracksCentFT0M || + doprocessDatawBestTracksCentNGlobal || + doprocessDatawBestTracksCentMFT) { + registry.add({"Events/Centrality/NtrkZvtxBest", + "; N_{trk}; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {multAxis, zAxis, centralityAxis, occupancyAxis}}}); + registry.add({"Tracks/Centrality/EtaZvtxBest", + "; #eta; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {etaAxis, zAxis, centralityAxis, occupancyAxis}}}); + registry.add({"Tracks/Centrality/PhiEtaBest", + "; #varphi; #eta; centrality; occupancy", + {HistType::kTHnSparseF, + {phiAxis, etaAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/NclustersEtaBest", + "; nClusters; #eta; centrality; occupancy", + {HistType::kTHnSparseF, + {{7, 4, 10}, etaAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Centrality/TrackAmbDegree", + "; N_{coll}^{comp}; centrality; occupancy", + {HistType::kTHnSparseF, + {{51, -0.5, 50.5}, centralityAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Centrality/DCAXY", + "; DCA_{XY} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {dcaxyAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/DCAXYPt", + "; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {ptAxis, dcaxyAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Centrality/ReTracksEtaZvtx", + "; #eta; #it{z}_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, + {etaAxis, zAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Centrality/ReTracksPhiEta", + "; #varphi; #eta; occupancy", + {HistType::kTHnSparseF, + {phiAxis, etaAxis, centralityAxis, occupancyAxis}}}); + } + } + + if (doprocessMCInclusive || doprocessMCwBestTracksInclusive) { + registry.add({"Events/EvtEffGen", + ";status;occupancy", + {HistType::kTH2F, {{3, 0.5, 3.5}, occupancyAxis}}}); + auto heff = registry.get(HIST("Events/EvtEffGen")); + auto* h = heff->GetXaxis(); + h->SetBinLabel(1, "All reconstructed"); + h->SetBinLabel(2, "Selected reconstructed"); + h->SetBinLabel(3, "All generated"); + + registry.add({"Events/NtrkZvtxGen_t", + "; N_{trk}; Z_{vtx} (cm);", + {HistType::kTH2F, {multAxis, zAxis}}}); + registry.add({"Events/NtrkZvtxGen", + "; N_{trk}; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, {multAxis, zAxis, occupancyAxis}}}); + registry.add({"Tracks/EtaZvtxGen", + "; #eta; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, {etaAxis, zAxis, occupancyAxis}}}); + registry.add( + {"Tracks/PhiEtaGen", + "; #varphi; #eta;", + {HistType::kTHnSparseF, {phiAxis, etaAxis, occupancyAxis}}}); + registry.add({"Tracks/EtaZvtxGen_t", + "; #eta; Z_{vtx} (cm);", + {HistType::kTH2F, {etaAxis, zAxis}}}); + registry.add({"Tracks/PhiEtaGen_t", + "; #varphi; #eta;", + {HistType::kTH2F, {phiAxis, etaAxis}}}); + qaregistry.add({"Events/NotFoundEventZvtx", + "; #it{z}_{vtx} (cm)", + {HistType::kTH1F, {zAxis}}}); + qaregistry.add({"Events/ZvtxDiff", + "; Z_{rec} - Z_{gen} (cm)", + {HistType::kTH1F, {deltaZAxis}}}); + qaregistry.add({"Events/SplitMult", + "; N_{gen}; #it{z}_{vtx} (cm)", + {HistType::kTH2F, {multAxis, zAxis}}}); + } + + if (doprocessMCCentFT0C || doprocessMCwBestTracksCentFT0C || + doprocessMCCentFT0CVariant1 || doprocessMCwBestTracksCentFT0CVariant1 || + doprocessMCCentFT0M || doprocessMCwBestTracksCentFT0M || + doprocessMCCentNGlobal || doprocessMCwBestTracksCentNGlobal || + doprocessMCCentMFT || doprocessMCwBestTracksCentMFT) { + registry.add({"Events/Centrality/EvtEffGen", + ";status;centrality;occupancy", + {HistType::kTHnSparseF, + {{3, 0.5, 3.5}, centralityAxis, occupancyAxis}}}); + auto heff = registry.get(HIST("Events/Centrality/EvtEffGen")); + heff->GetAxis(0)->SetBinLabel(1, "All reconstructed"); + heff->GetAxis(0)->SetBinLabel(2, "Selected reconstructed"); + heff->GetAxis(0)->SetBinLabel(3, "All generated"); + + registry.add( + {"Events/Centrality/NtrkZvtxGen_t", + "; N_{trk}; Z_{vtx} (cm); centrality", + {HistType::kTHnSparseF, {multAxis, zAxis, centralityAxis}}}); + registry.add({"Events/Centrality/NtrkZvtxGen", + "; N_{trk}; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {multAxis, zAxis, centralityAxis, occupancyAxis}}}); + registry.add({"Events/Centrality/hRecCent", + "; centrality; occupancy", + {HistType::kTH2F, {centralityAxis, occupancyAxis}}}); + registry.add( + {"Events/Centrality/hRecZvtxCent", + "; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, {zAxis, centralityAxis, occupancyAxis}}}); + registry.add({"Tracks/Centrality/EtaZvtxGen", + "; #eta; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {etaAxis, zAxis, centralityAxis, occupancyAxis}}}); + registry.add({"Tracks/Centrality/PhiEtaGen", + "; #varphi; #eta; centrality; occupancy", + {HistType::kTHnSparseF, + {phiAxis, etaAxis, centralityAxis, occupancyAxis}}}); + registry.add({"Tracks/Centrality/EtaZvtxGen_t", + "; #eta; Z_{vtx} (cm); centrality", + {HistType::kTHnSparseF, {etaAxis, zAxis, centralityAxis}}}); + registry.add( + {"Tracks/Centrality/PhiEtaGen_t", + "; #varphi; #eta; centrality", + {HistType::kTHnSparseF, {phiAxis, etaAxis, centralityAxis}}}); + qaregistry.add({"Events/Centrality/NotFoundEventZvtx", + "; #it{z}_{vtx} (cm); centrality", + {HistType::kTH2F, {zAxis, centralityAxis}}}); + qaregistry.add({"Events/Centrality/ZvtxDiff", + "; Z_{rec} - Z_{gen} (cm); centrality", + {HistType::kTH2F, {deltaZAxis, centralityAxis}}}); + qaregistry.add( + {"Events/Centrality/SplitMult", + "; N_{gen}; #it{z}_{vtx} (cm); centrality", + {HistType::kTHnSparseF, {multAxis, zAxis, centralityAxis}}}); + } + + if (doprocessTrkEffIdxInlusive) { + qaregistry.add({"Tracks/hPtEtaEffGen", + "; p_{T} (GeV/c); #eta; occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/hPtEtaEffPrim", + "; p_{T} (GeV/c); #eta; occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/hPtEtaEffSec", + "; p_{T} (GeV/c); #eta; occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/hPtEtaEffGenDupl", + "; p_{T} (GeV/c); #eta; occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/hPtEtaEffDupl", + "; p_{T} (GeV/c); #eta; occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/NmftTrkPerPart", + "; #it{N}_{mft tracks per particle}; occupancy", + {HistType::kTH2F, {multAxis, occupancyAxis}}}); + } + + if (doprocessTrkEffIdxCentFT0C) { + qaregistry.add( + {"Tracks/Centrality/hPtEtaEffGen", + "; p_{T} (GeV/c); #eta; centrality; " + "occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/hPtEtaEffPrim", + "; p_{T} (GeV/c); #eta; centrality; " + "occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/hPtEtaEffSec", + "; p_{T} (GeV/c); #eta; Z_{vtx} (cm); centrality; " + "occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/hPtEtaEffGenDupl", + "; p_{T} (GeV/c); #eta; centrality; " + "occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/hPtEtaEffDupl", + "; p_{T} (GeV/c); #eta; centrality; " + "occupancy", + {HistType::kTHnSparseF, + {ptAxis, etaAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/NmftTrkPerPart", + "; #it{N}_{mft tracks per particle}; centrality; occupancy", + {HistType::kTHnSparseF, {multAxis, centralityAxis, occupancyAxis}}}); + } + + if (doprocessTrkEffBestInclusive) { + qaregistry.add({"Tracks/hPtPhiEtaZvtxEffBestGen", + "; p_{T} (GeV/c); #varphi; #eta; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, + {ptAxis, phiAxis, etaAxis, zAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/hPtPhiEtaZvtxEffBestRec", + "; p_{T} (GeV/c); #varphi; #eta; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, + {ptAxis, phiAxis, etaAxis, zAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/hPtEffBestFakeRec", + " ; p_{T} (GeV/c); occupancy", + {HistType::kTH2F, {ptAxis, occupancyAxis}}}); + } + + if (doprocessTrkEffBestCentFT0C) { + qaregistry.add( + {"Tracks/Centrality/hPtPhiEtaZvtxEffBestGen", + "; p_{T} (GeV/c); #varphi; #eta; Z_{vtx} (cm); centrality; " + "occupancy", + {HistType::kTHnSparseF, + {ptAxis, phiAxis, etaAxis, zAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/hPtPhiEtaZvtxEffBestRec", + "; p_{T} (GeV/c); #varphi; #eta; Z_{vtx} (cm); centrality; " + "occupancy", + {HistType::kTHnSparseF, + {ptAxis, phiAxis, etaAxis, zAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/hPtEffBestFakeRec", + "; p_{T} (GeV/c); centrality; occupancy", + {HistType::kTHnSparseF, {ptAxis, centralityAxis, occupancyAxis}}}); + } + + if (doprocessMcQAInclusive) { + qaregistry.add({"Events/hRecPerGenColls", + "; #it{N}_{reco collisions} / #it{N}_{gen collisions};", + {HistType::kTH2F, {{200, 0., 2.}, occupancyAxis}}}); + qaregistry.add({"Tracks/hNmftTrks", + "; #it{N}_{mft tracks};", + {HistType::kTH2F, {{200, -0.5, 200.}, occupancyAxis}}}); + qaregistry.add({"Tracks/hFracAmbiguousMftTrks", + "; #it{N}_{ambiguous tracks} / #it{N}_{tracks};", + {HistType::kTH2F, {{100, 0., 1.}, occupancyAxis}}}); + } + + if (doprocessMcQACentFT0C) { + qaregistry.add( + {"Events/Centrality/hRecPerGenColls", + "; #it{N}_{reco collisions} / #it{N}_{gen collisions}; centrality", + {HistType::kTHnSparseF, + {{200, 0., 2.}, centralityAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Centrality/hNmftTrks", + "; #it{N}_{mft tracks}; centrality", + {HistType::kTHnSparseF, + {{200, -0.5, 200.}, centralityAxis, occupancyAxis}}}); + qaregistry.add( + {"Tracks/Centrality/hFracAmbiguousMftTrks", + "; #it{N}_{ambiguous tracks} / #it{N}_{tracks}; centrality", + {HistType::kTHnSparseF, + {{100, 0., 1.}, centralityAxis, occupancyAxis}}}); + } + + if (doprocessCheckAmbiguousMftTracksInclusive) { + qaregistry.add({"Tracks/hMftTracksAmbDegree", + " ; N_{coll}^{comp}; occupancy", + {HistType::kTH2F, {{41, -0.5, 40.5}, occupancyAxis}}}); + qaregistry.add({"Tracks/hAmbTrackType", + " ; Ambiguous track type; occupancy", + {HistType::kTH2F, {{5, -0.5, 4.5}, occupancyAxis}}}); + qaregistry.add({"Tracks/histAmbZvtx", + "#it{z}_{vtx} of collisions associated to a " + "track;#it{z}_{vtx} (cm);", + {HistType::kTH1F, {zAxis}}}); + } + + if (doprocessCheckAmbiguousMftTracksCentFT0C) { + qaregistry.add({"Tracks/Centrality/hMftTracksAmbDegree", + " ; N_{coll}^{comp}; occupancy", + {HistType::kTHnSparseF, + {{41, -0.5, 40.5}, centralityAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Centrality/hAmbTrackType", + " ; Ambiguous track type; occupancy", + {HistType::kTHnSparseF, + {{5, -0.5, 4.5}, centralityAxis, occupancyAxis}}}); + } + + if (doprocessEfficiencyInclusive) { + qaregistry.add({"Tracks/hEffRec", + "; p_{T} (GeV/c); #varphi; #eta; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, + {ptAxis, phiAxis, etaAxis, zAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/hEffFake", + "; p_{T} (GeV/c); #varphi; #eta; Z_{vtx} (cm); occupancy", + {HistType::kTHnSparseF, + {ptAxis, phiAxis, etaAxis, zAxis, occupancyAxis}}}); + } + + if (doprocessEfficiencyCentFT0C) { + qaregistry.add({"Tracks/Centrality/hEffRec", + "; p_{T} (GeV/c); #varphi; #eta; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {ptAxis, phiAxis, etaAxis, zAxis, centralityAxis, occupancyAxis}}}); + qaregistry.add({"Tracks/Centrality/hEffFake", + "; p_{T} (GeV/c); #varphi; #eta; Z_{vtx} (cm); centrality; occupancy", + {HistType::kTHnSparseF, + {ptAxis, phiAxis, etaAxis, zAxis, centralityAxis, occupancyAxis}}}); + } + } + + /// Filters - tracks + Filter filtTrkEta = (aod::fwdtrack::eta < trackCuts.maxEta) && + (aod::fwdtrack::eta > trackCuts.minEta); + Filter filtATrackID = (aod::fwdtrack::bestCollisionId >= 0); + Filter filtATrackDCA = (nabs(aod::fwdtrack::bestDCAXY) < trackCuts.maxDCAxy); + + /// Filters - mc particles + Filter primaries = (aod::mcparticle::flags & + (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary) == + (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary; + + /// Joined tables + using FullBCs = soa::Join; + using CollBCs = soa::Join; + using Colls = soa::Join; + using Coll = Colls::iterator; + using CollsCentFT0C = soa::Join; + using CollsCentFT0CVariant1 = + soa::Join; + using CollsCentFT0M = soa::Join; + using CollsCentNGlobal = + soa::Join; + using CollsCentMFT = soa::Join; + using CollCentFT0C = CollsCentFT0C::iterator; + using CollsGenCentFT0C = soa::Join; + using CollGenCent = CollsGenCentFT0C::iterator; + using MFTTracksLabeled = soa::Join; + using MftTracksWColls = soa::Join; + + /// Filtered tables + using FiltMftTracks = soa::Filtered; + using FiltMcMftTracks = soa::Filtered; + using FiltBestTracks = soa::Filtered; + using FiltParticles = soa::Filtered; + + template + bool isTrackSelected(const T& track) + { + if (track.eta() < trackCuts.minEta || track.eta() > trackCuts.maxEta) + return false; + if (trackCuts.useChi2Cut) { + float nclMft = std::max(2.0f * track.nClusters() - 5.0f, 1.0f); + float mftChi2NCl = track.chi2() / nclMft; + if (mftChi2NCl > trackCuts.maxChi2NCl) + return false; + } + if (trackCuts.requireCA && !track.isCA()) + return false; + if (track.nClusters() < trackCuts.minNclusterMft) + return false; + if (track.pt() < trackCuts.minPt) + return false; + if (trackCuts.usephiCut) { + float phi = track.phi(); + o2::math_utils::bringTo02Pi(phi); + if (phi < trackCuts.minPhi || trackCuts.maxPhi < phi) { + return false; + } + if ((phi < trackCuts.phiCut) || + ((phi > PI - trackCuts.phiCut) && (phi < PI + trackCuts.phiCut)) || + (phi > TwoPI - trackCuts.phiCut) || + ((phi > ((PIHalf - 0.1) * PI) - trackCuts.phiCut) && + (phi < ((PIHalf - 0.1) * PI) + trackCuts.phiCut))) + return false; + } + return true; + } + + template + int countTracks(T const& tracks, float z, float c, float occ) + { + auto nTrk = 0; + if (tracks.size() > 0) { + for (auto const& track : tracks) { + if (fillHis) { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/Chi2Eta"), track.chi2(), + track.eta(), c, occ); + qaregistry.fill(HIST("Tracks/Centrality/Chi2"), track.chi2(), c, + occ); + qaregistry.fill(HIST("Tracks/Centrality/NclustersEta"), + track.nClusters(), track.eta(), c, occ); + } else { + qaregistry.fill(HIST("Tracks/Chi2Eta"), track.chi2(), track.eta(), + occ); + qaregistry.fill(HIST("Tracks/Chi2"), track.chi2(), occ); + qaregistry.fill(HIST("Tracks/NclustersEta"), track.nClusters(), + track.eta(), occ); + } + } + if (!isTrackSelected(track)) { + continue; + } + if (fillHis) { + float phi = track.phi(); + o2::math_utils::bringTo02Pi(phi); + if (phi < 0.f || TwoPI < phi) { + continue; + } + if constexpr (has_reco_cent) { + registry.fill(HIST("Tracks/Centrality/EtaZvtx"), track.eta(), z, c, + occ); + registry.fill(HIST("Tracks/Centrality/PhiEta"), phi, track.eta(), c, + occ); + } else { + registry.fill(HIST("Tracks/EtaZvtx"), track.eta(), z, occ); + registry.fill(HIST("Tracks/PhiEta"), phi, track.eta(), occ); + } + } + ++nTrk; + } + } + if (fillHis) { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/NchSel"), nTrk, c, occ); + } else { + qaregistry.fill(HIST("Tracks/NchSel"), nTrk, occ); + } + } + return nTrk; + } + + template + int countBestTracks(T const& /*tracks*/, B const& besttracks, float z, + float c, float occ) + { + auto nATrk = 0; + if (besttracks.size() > 0) { + for (auto const& atrack : besttracks) { + auto itrack = atrack.template mfttrack_as(); + if (!isTrackSelected(itrack)) { + continue; + } + if (fillHis) { + float phi = itrack.phi(); + o2::math_utils::bringTo02Pi(phi); + if (phi < 0.f || TwoPI < phi) { + continue; + } + if constexpr (has_reco_cent) { + registry.fill(HIST("Tracks/Centrality/EtaZvtxBest"), itrack.eta(), + z, c, occ); + registry.fill(HIST("Tracks/Centrality/PhiEtaBest"), phi, + itrack.eta(), c, occ); + qaregistry.fill(HIST("Tracks/Centrality/DCAXYPt"), itrack.pt(), + atrack.bestDCAXY(), c, occ); + qaregistry.fill(HIST("Tracks/Centrality/DCAXY"), atrack.bestDCAXY(), + c, occ); + qaregistry.fill(HIST("Tracks/Centrality/NclustersEtaBest"), + itrack.nClusters(), itrack.eta(), c, occ); + if (itrack.collisionId() != atrack.bestCollisionId()) { + qaregistry.fill(HIST("Tracks/Centrality/ReTracksEtaZvtx"), + itrack.eta(), z, c, occ); + qaregistry.fill(HIST("Tracks/Centrality/ReTracksPhiEta"), phi, + itrack.eta(), c, occ); + } + qaregistry.fill(HIST("Tracks/Centrality/TrackAmbDegree"), + atrack.ambDegree(), c, occ); + } else { + registry.fill(HIST("Tracks/EtaZvtxBest"), itrack.eta(), z, occ); + registry.fill(HIST("Tracks/PhiEtaBest"), phi, itrack.eta(), occ); + qaregistry.fill(HIST("Tracks/DCAXYPt"), itrack.pt(), + atrack.bestDCAXY(), occ); + qaregistry.fill(HIST("Tracks/DCAXY"), atrack.bestDCAXY(), occ); + qaregistry.fill(HIST("Tracks/NclustersEtaBest"), itrack.nClusters(), + itrack.eta(), occ); + if (itrack.collisionId() != atrack.bestCollisionId()) { + qaregistry.fill(HIST("Tracks/ReTracksEtaZvtx"), itrack.eta(), z, + occ); + qaregistry.fill(HIST("Tracks/ReTracksPhiEta"), phi, itrack.eta(), + occ); + } + qaregistry.fill(HIST("Tracks/TrackAmbDegree"), atrack.ambDegree(), + occ); + } + } + ++nATrk; + } + } + return nATrk; + } + + template + int countPart(P const& particles) + { + auto nCharged = 0; + for (auto const& particle : particles) { + if (!isChrgParticle(particle.pdgCode())) { + continue; + } + nCharged++; + } + return nCharged; + } + + template + float getOccupancy(C const& collision, uint occEstimator) + { + switch (occEstimator) { + case OccupancyEst::TrkITS: + return collision.trackOccupancyInTimeRange(); + case OccupancyEst::Ft0C: + return collision.ft0cOccupancyInTimeRange(); + default: + LOG(fatal) << "No valid occupancy estimator "; + break; + } + return -1.f; + } + + void initHadronicRate(CollBCs::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + if (gHadronicRate.find(mRunNumber) == gHadronicRate.end()) { + auto runDuration = ccdb->getRunDuration(mRunNumber); + mSOR = runDuration.first; + mMinSeconds = std::floor(mSOR * 1.e-3); /// round tsSOR to the highest integer lower than tsSOR + double maxSec = std::ceil(runDuration.second * 1.e-3); /// round tsEOR to the lowest integer higher than tsEOR + const AxisSpec axisSeconds{static_cast((maxSec - mMinSeconds) / 20.f), 0, maxSec - mMinSeconds, "Seconds since SOR"}; + int hadronicRateBins = static_cast(eventCuts.maxIR - eventCuts.minIR); + gHadronicRate[mRunNumber] = registry.add(Form("HadronicRate/%i", mRunNumber), ";Time since SOR (s);Hadronic rate (kHz)", kTH2D, {axisSeconds, {hadronicRateBins, eventCuts.minIR, eventCuts.maxIR}}).get(); + } + gCurrentHadronicRate = gHadronicRate[mRunNumber]; + } + + template + bool isGoodEvent(C const& collision) + { + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 0); + } + if (!collision.sel8()) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 1); + } + if (eventCuts.requireIsGoodZvtxFT0VsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 2); + } + if (eventCuts.requireRejectSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 3); + } + if (std::abs(collision.posZ()) >= eventCuts.maxZvtx) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 4); + } + if (eventCuts.requireNoCollInTimeRangeStd && + !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 5); + } + if (eventCuts.requireNoCollInTimeRangeNarrow && + !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 6); + } + if (eventCuts.requireNoCollInTimeRangeStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 7); + } + if (eventCuts.requireNoCollInRofStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 8); + } + if (eventCuts.requireNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 9); + } + if (eventCuts.requireNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 10); + } + if (eventCuts.minOccupancy >= 0 && + getOccupancy(collision, eventCuts.occupancyEstimator) < + eventCuts.minOccupancy) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 11); + } + if (eventCuts.maxOccupancy >= 0 && + getOccupancy(collision, eventCuts.occupancyEstimator) > + eventCuts.maxOccupancy) { + return false; + } + if constexpr (fillHis) { + registry.fill(HIST("hEvtSel"), 12); + } + return true; + } + + /// @brief Selection of charged particles + /// @return true: charged; false: not charged + bool isChrgParticle(int code) + { + auto p = pdg->GetParticle(code); + auto charge = 0.; + if (p != nullptr) { + charge = p->Charge(); + } + return std::abs(charge) >= 3.; + } + + template + void fillHistMC(P const& particles, float c, float occ, float zvtx, + bool const gtZeroColl) + { + for (auto const& particle : particles) { + if (!isChrgParticle(particle.pdgCode())) { + continue; + } + + float phi = particle.phi(); + o2::math_utils::bringTo02Pi(phi); + if (phi < 0.f || TwoPI < phi) { + continue; + } + if constexpr (isCent) { + registry.fill(HIST("Tracks/Centrality/EtaZvtxGen_t"), particle.eta(), + zvtx, c); + registry.fill(HIST("Tracks/Centrality/PhiEtaGen_t"), phi, + particle.eta(), c); + } else { + registry.fill(HIST("Tracks/EtaZvtxGen_t"), particle.eta(), zvtx); + registry.fill(HIST("Tracks/PhiEtaGen_t"), phi, particle.eta()); + } + + if (gtZeroColl) { + float phi = particle.phi(); + o2::math_utils::bringTo02Pi(phi); + if (phi < 0.f || TwoPI < phi) { + continue; + } + if constexpr (isCent) { + registry.fill(HIST("Tracks/Centrality/EtaZvtxGen"), particle.eta(), + zvtx, c, occ); + registry.fill(HIST("Tracks/Centrality/PhiEtaGen"), phi, + particle.eta(), c, occ); + } else { + registry.fill(HIST("Tracks/EtaZvtxGen"), particle.eta(), zvtx, occ); + registry.fill(HIST("Tracks/PhiEtaGen"), phi, particle.eta(), occ); + } + } + } + } + + /// @brief process function for general event statistics + void processTagging(FullBCs const& bcs, CollsCentFT0C const& collisions) + { + std::vector::iterator> cols; + for (auto const& bc : bcs) { + if ((bc.selection_bit(aod::evsel::kIsBBT0A) && + bc.selection_bit(aod::evsel::kIsBBT0C)) != 0) { + registry.fill(HIST("hBcSel"), 0); + cols.clear(); + for (auto const& collision : collisions) { + if (collision.has_foundBC()) { + if (collision.foundBCId() == bc.globalIndex()) { + cols.emplace_back(collision); + } + } else if (collision.bcId() == bc.globalIndex()) { + cols.emplace_back(collision); + } + } + LOGP(debug, "BC {} has {} collisions", bc.globalBC(), cols.size()); + if (!cols.empty()) { + registry.fill(HIST("hBcSel"), 1); + if (cols.size() > 1) { + registry.fill(HIST("hBcSel"), 2); + } + } + } + } + } + + PROCESS_SWITCH(DndetaMFTPbPb, processTagging, "Collect event sample stats", + true); + + /// @brief process function for counting tracks + template + void processData(typename C::iterator const& collision, + FiltMftTracks const& tracks, CollBCs const& /*bcs*/) + { + auto occ = getOccupancy(collision, eventCuts.occupancyEstimator); + float c = getRecoCent(collision); + auto bc = collision.template foundBC_as(); + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/Selection"), 1., c, occ); + } else { + registry.fill(HIST("Events/Selection"), 1., occ); + } + + if (!isGoodEvent(collision)) { + return; + } + + if (cfgDoIR) { + initHadronicRate(bc); + double ir = rateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), cfgIRSource, cfgIRCrashOnNull) * 1.e-3; + double seconds = bc.timestamp() * 1.e-3 - mMinSeconds; + if (cfgUseIRCut && (ir < eventCuts.minIR || ir > eventCuts.maxIR)) { // cut on hadronic rate + return; + } + gCurrentHadronicRate->Fill(seconds, ir); + } + + auto z = collision.posZ(); + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/Selection"), 2., c, occ); + qaregistry.fill(HIST("Events/Centrality/hZvtxCent"), z, c, occ); + qaregistry.fill(HIST("Events/Centrality/hCent"), c, occ); + } else { + registry.fill(HIST("Events/Selection"), 2., occ); + } + + auto nTrk = countTracks(tracks, z, c, occ); + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/NtrkZvtx"), nTrk, z, c, occ); + } else { + registry.fill(HIST("Events/NtrkZvtx"), nTrk, z, occ); + } + } + + /// @brief process function for counting tracks (based on BestCollisionsFwd + /// table) + template + void processDatawBestTracks( + typename C::iterator const& collision, FiltMftTracks const& tracks, + soa::SmallGroups const& besttracks, CollBCs const& /*bcs*/) + { + auto occ = getOccupancy(collision, eventCuts.occupancyEstimator); + float c = getRecoCent(collision); + auto bc = collision.template foundBC_as(); + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/Selection"), 1., c, occ); + } else { + registry.fill(HIST("Events/Selection"), 1., occ); + } + + if (!isGoodEvent(collision)) { + return; + } + + if (cfgDoIR) { + initHadronicRate(bc); + double ir = rateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), cfgIRSource, cfgIRCrashOnNull) * 1.e-3; + double seconds = bc.timestamp() * 1.e-3 - mMinSeconds; + if (cfgUseIRCut && (ir < eventCuts.minIR || ir > eventCuts.maxIR)) { // cut on hadronic rate + return; + } + gCurrentHadronicRate->Fill(seconds, ir); + } + + auto z = collision.posZ(); + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/Selection"), 2., c, occ); + } else { + registry.fill(HIST("Events/Selection"), 2., occ); + } + + auto nBestTrks = countBestTracks(tracks, besttracks, z, c, occ); + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/NtrkZvtxBest"), nBestTrks, z, c, + occ); + } else { + registry.fill(HIST("Events/NtrkZvtxBest"), nBestTrks, z, occ); + } + } + + void processDataInclusive(Colls::iterator const& collision, + FiltMftTracks const& tracks, CollBCs const& bcs) + { + processData(collision, tracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDataInclusive, + "Count tracks (inclusive)", false); + + void processDataCentFT0C(CollsCentFT0C::iterator const& collision, + FiltMftTracks const& tracks, CollBCs const& bcs) + { + processData(collision, tracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDataCentFT0C, + "Count tracks in FT0C centrality bins", false); + + void + processDataCentFT0CVariant1(CollsCentFT0CVariant1::iterator const& collision, + FiltMftTracks const& tracks, CollBCs const& bcs) + { + processData(collision, tracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDataCentFT0CVariant1, + "Count tracks in FT0CVariant1 centrality bins", false); + + void processDataCentFT0M(CollsCentFT0M::iterator const& collision, + FiltMftTracks const& tracks, CollBCs const& bcs) + { + processData(collision, tracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDataCentFT0M, + "Count tracks in FT0M centrality bins", false); + + void processDataCentNGlobal(CollsCentNGlobal::iterator const& collision, + FiltMftTracks const& tracks, CollBCs const& bcs) + { + processData(collision, tracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDataCentNGlobal, + "Count tracks in NGlobal centrality bins", false); + + void processDataCentMFT(CollsCentMFT::iterator const& collision, + FiltMftTracks const& tracks, CollBCs const& bcs) + { + processData(collision, tracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDataCentMFT, + "Count tracks in MFT centrality bins", false); + + void processDatawBestTracksInclusive( + Colls::iterator const& collision, FiltMftTracks const& tracks, + soa::SmallGroups const& besttracks, CollBCs const& bcs) + { + processDatawBestTracks(collision, tracks, besttracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDatawBestTracksInclusive, + "Count tracks based on BestCollisionsFwd table (inclusive)", + false); + + void processDatawBestTracksCentFT0C( + CollsCentFT0C::iterator const& collision, FiltMftTracks const& tracks, + soa::SmallGroups const& besttracks, CollBCs const& bcs) + { + processDatawBestTracks(collision, tracks, besttracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDatawBestTracksCentFT0C, + "Count tracks in FT0C centrality bins based on BestCollisionsFwd table", + false); + + void processDatawBestTracksCentFT0CVariant1( + CollsCentFT0CVariant1::iterator const& collision, + FiltMftTracks const& tracks, + soa::SmallGroups const& besttracks, CollBCs const& bcs) + { + processDatawBestTracks(collision, tracks, besttracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDatawBestTracksCentFT0CVariant1, + "Count tracks in FT0CVariant1 centrality bins based on " + "BestCollisionsFwd table", + false); + + void processDatawBestTracksCentFT0M( + CollsCentFT0M::iterator const& collision, FiltMftTracks const& tracks, + soa::SmallGroups const& besttracks, CollBCs const& bcs) + { + processDatawBestTracks(collision, tracks, besttracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDatawBestTracksCentFT0M, + "Count tracks in FT0M centrality bins based on BestCollisionsFwd table", + false); + + void processDatawBestTracksCentNGlobal( + CollsCentNGlobal::iterator const& collision, FiltMftTracks const& tracks, + soa::SmallGroups const& besttracks, CollBCs const& bcs) + { + processDatawBestTracks(collision, tracks, besttracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDatawBestTracksCentNGlobal, + "Count tracks in NGlobal centrality bins based on " + "BestCollisionsFwd table", + false); + + void processDatawBestTracksCentMFT( + CollsCentMFT::iterator const& collision, FiltMftTracks const& tracks, + soa::SmallGroups const& besttracks, CollBCs const& bcs) + { + processDatawBestTracks(collision, tracks, besttracks, bcs); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processDatawBestTracksCentMFT, + "Count tracks in MFT centrality bins based on BestCollisionsFwd table", + false); + + Preslice perCol = o2::aod::fwdtrack::collisionId; + PresliceUnsorted recColPerMcCol = + aod::mccollisionlabel::mcCollisionId; + Partition mcSample = nabs(aod::mcparticle::eta) < 1.0f; + + /// @brief process template function to run on MC gen + template + void processMC( + typename MC::iterator const& mcCollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks) + { + bool gtZeroColl = false; + int gtOneColl = 0; + + float cgen = -1; + if constexpr (has_reco_cent) { + float crec_min = 105.f; + for (const auto& collision : collisions) { + if (isGoodEvent(collision)) { + float c = getRecoCent(collision); + if (c < crec_min) { + crec_min = c; + } + } + } + if (cgen < 0) + cgen = crec_min; + } + + float occgen = -1.; + for (const auto& collision : collisions) { + if (isGoodEvent(collision)) { + float o = getOccupancy(collision, eventCuts.occupancyEstimator); + if (o > occgen) { + occgen = o; + } + } + } + + for (auto const& collision : collisions) { + float occrec = getOccupancy(collision, eventCuts.occupancyEstimator); + float crec = getRecoCent(collision); + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/EvtEffGen"), 1., crec, occrec); + } else { + registry.fill(HIST("Events/EvtEffGen"), 1., occrec); + } + + if (isGoodEvent(collision)) { + gtZeroColl = true; + ++gtOneColl; + auto z = collision.posZ(); + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/EvtEffGen"), 2., crec, occrec); + registry.fill(HIST("Events/Centrality/hRecCent"), crec, occrec); + registry.fill(HIST("Events/Centrality/hRecZvtxCent"), z, crec, + occrec); + } else { + registry.fill(HIST("Events/EvtEffGen"), 2., occrec); + } + + auto perColSample = tracks.sliceBy(perCol, collision.globalIndex()); + auto nTrkRec = countTracks(perColSample, z, crec, occrec); + + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Events/Centrality/ZvtxDiff"), + collision.posZ() - mcCollision.posZ(), crec); + } else { + qaregistry.fill(HIST("Events/ZvtxDiff"), + collision.posZ() - mcCollision.posZ()); + } + + if (eventCuts.useZDiffCut) { + if (std::abs(collision.posZ() - mcCollision.posZ()) > + eventCuts.maxZvtxDiff) { + continue; + } + } + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/NtrkZvtxGen"), nTrkRec, + collision.posZ(), crec, occrec); + } else { + registry.fill(HIST("Events/NtrkZvtxGen"), nTrkRec, collision.posZ(), + occrec); + } + } + } + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/EvtEffGen"), 3., cgen, occgen); + } else { + registry.fill(HIST("Events/EvtEffGen"), 3., occgen); + } + + auto perCollMCsample = mcSample->sliceByCached( + aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + auto nchrg = countPart(perCollMCsample); + auto zvtxMC = mcCollision.posZ(); + + if (gtOneColl > 1) { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Events/Centrality/SplitMult"), nchrg, zvtxMC, cgen); + } else { + qaregistry.fill(HIST("Events/SplitMult"), nchrg, zvtxMC); + } + } + + auto nCharged = countPart(particles); + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/NtrkZvtxGen_t"), nCharged, zvtxMC, + cgen); + } else { + registry.fill(HIST("Events/NtrkZvtxGen_t"), nCharged, zvtxMC); + } + + fillHistMC>(particles, cgen, occgen, zvtxMC, gtZeroColl); + + if (collisions.size() == 0) { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Events/Centrality/NotFoundEventZvtx"), + mcCollision.posZ(), cgen); + } else { + qaregistry.fill(HIST("Events/NotFoundEventZvtx"), mcCollision.posZ()); + } + } + } + + void processMCInclusive( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks) + { + processMC(mccollision, collisions, particles, + tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCInclusive, + "Count MC particles (inclusive)", false); + + void processMCCentFT0C( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks) + { + processMC(mccollision, collisions, + particles, tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCCentFT0C, + "Count MC particles in FT0C centrality bins", false); + + void processMCCentFT0CVariant1( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks) + { + processMC(mccollision, collisions, + particles, tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCCentFT0CVariant1, + "Count MC particles in FT0CVariant1 centrality bins", false); + + void processMCCentFT0M( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks) + { + processMC(mccollision, collisions, + particles, tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCCentFT0M, + "Count MC particles in FT0M centrality bins", false); + + void processMCCentNGlobal( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks) + { + processMC(mccollision, collisions, + particles, tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCCentNGlobal, + "Count MC particles in NGlobal centrality bins", false); + + void processMCCentMFT( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks) + { + processMC(mccollision, collisions, + particles, tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCCentMFT, + "Count MC particles in MFT centrality bins", false); + + PresliceUnsorted perColU = + aod::fwdtrack::bestCollisionId; + + /// @brief process template function to run on MC truth using + /// aod::BestCollisionsFwd tracks + template + void processMCwBestTracks( + typename MC::iterator const& mcCollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks, + FiltBestTracks const& besttracks) + { + bool gtZeroColl = false; + float cgen = -1; + if constexpr (has_reco_cent) { + float crec_min = 105.f; + for (const auto& collision : collisions) { + if (isGoodEvent(collision)) { + float c = getRecoCent(collision); + if (c < crec_min) { + crec_min = c; + } + } + } + if (cgen < 0) + cgen = crec_min; + } + + float occgen = -1.; + for (const auto& collision : collisions) { + if (isGoodEvent(collision)) { + float o = getOccupancy(collision, eventCuts.occupancyEstimator); + if (o > occgen) { + occgen = o; + } + } + } + + for (auto const& collision : collisions) { + auto occrec = getOccupancy(collision, eventCuts.occupancyEstimator); + float crec = getRecoCent(collision); + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/EvtEffGen"), 1., crec, occrec); + } else { + registry.fill(HIST("Events/EvtEffGen"), 1., occrec); + } + + if (isGoodEvent(collision)) { + gtZeroColl = true; + auto z = collision.posZ(); + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/EvtEffGen"), 2., crec, occrec); + } else { + registry.fill(HIST("Events/EvtEffGen"), 2., occrec); + } + + auto perCollisionSample = + tracks.sliceBy(perCol, collision.globalIndex()); + auto perCollisionASample = + besttracks.sliceBy(perColU, collision.globalIndex()); + auto nTrkRec = countBestTracks( + perCollisionSample, perCollisionASample, z, crec, + collision.trackOccupancyInTimeRange()); + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/NtrkZvtxGen"), nTrkRec, z, + crec, occrec); + } else { + registry.fill(HIST("Events/NtrkZvtxGen"), nTrkRec, z, occrec); + } + } + } + + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/EvtEffGen"), 3., cgen, occgen); + } else { + registry.fill(HIST("Events/EvtEffGen"), 3., occgen); + } + + auto zvtxMC = mcCollision.posZ(); + auto nCharged = countPart(particles); + if constexpr (has_reco_cent) { + registry.fill(HIST("Events/Centrality/NtrkZvtxGen_t"), nCharged, zvtxMC, + cgen); + } else { + registry.fill(HIST("Events/NtrkZvtxGen_t"), nCharged, zvtxMC); + } + + fillHistMC>(particles, cgen, occgen, zvtxMC, gtZeroColl); + + if (collisions.size() == 0) { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Events/Centrality/NotFoundEventZvtx"), + mcCollision.posZ(), cgen); + } else { + qaregistry.fill(HIST("Events/NotFoundEventZvtx"), mcCollision.posZ()); + } + } + } + + void processMCwBestTracksInclusive( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks, + FiltBestTracks const& besttracks) + { + processMCwBestTracks( + mccollision, collisions, particles, tracks, besttracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCwBestTracksInclusive, + "Count MC particles using aod::BestCollisionsFwd (inclusive)", + false); + + void processMCwBestTracksCentFT0C( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks, + FiltBestTracks const& besttracks) + { + processMCwBestTracks( + mccollision, collisions, particles, tracks, besttracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCwBestTracksCentFT0C, + "Count MC particles in FT0C centrality bins using aod::BestCollisionsFwd", + false); + + void processMCwBestTracksCentFT0CVariant1( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks, + FiltBestTracks const& besttracks) + { + processMCwBestTracks( + mccollision, collisions, particles, tracks, besttracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCwBestTracksCentFT0CVariant1, + "Count MC particles in FT0CVariant1 centrality bins using " + "aod::BestCollisionsFwd", + false); + + void processMCwBestTracksCentFT0M( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks, + FiltBestTracks const& besttracks) + { + processMCwBestTracks( + mccollision, collisions, particles, tracks, besttracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCwBestTracksCentFT0M, + "Count MC particles in FT0M centrality bins using aod::BestCollisionsFwd", + false); + + void processMCwBestTracksCentNGlobal( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks, + FiltBestTracks const& besttracks) + { + processMCwBestTracks( + mccollision, collisions, particles, tracks, besttracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCwBestTracksCentNGlobal, + "Count MC particles in NGlobal centrality bins using " + "aod::BestCollisionsFwd", + false); + + void processMCwBestTracksCentMFT( + aod::McCollisions::iterator const& mccollision, + soa::SmallGroups> const& collisions, + FiltParticles const& particles, FiltMcMftTracks const& tracks, + FiltBestTracks const& besttracks) + { + processMCwBestTracks( + mccollision, collisions, particles, tracks, besttracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMCwBestTracksCentMFT, + "Count MC particles in MFT centrality bins using aod::BestCollisionsFwd", + false); + + using ParticlesI = soa::Join; + Partition primariesI = + ((aod::mcparticle::flags & + (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary) == + (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary); + + /// @brief process template function to calculate tracking efficiency (indexed + /// as particle-to-MFT-tracks) + template + void processTrkEffIdx( + typename soa::Join const& collisions, + MC const& /*mccollisions*/, ParticlesI const& /*particles*/, + MFTTracksLabeled const& tracks) + { + for (auto const& collision : collisions) { + if (!isGoodEvent(collision)) { + continue; + } + if (!collision.has_mcCollision()) { + continue; + } + + float crec = getRecoCent(collision); + auto occrec = getOccupancy(collision, eventCuts.occupancyEstimator); + auto mcCollision = collision.mcCollision(); + + auto partsPerCol = primariesI->sliceByCached( + aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + partsPerCol.bindExternalIndices(&tracks); + + for (auto const& particle : partsPerCol) { + if (!isChrgParticle(particle.pdgCode())) { + continue; + } + + // MC gen + if constexpr (has_reco_cent) { + if (particle.eta() > trackCuts.minEta && particle.eta() < trackCuts.maxEta) { + if (std::abs(mcCollision.posZ()) < eventCuts.maxZvtx) { + qaregistry.fill(HIST("Tracks/Centrality/hPtEtaEffGen"), particle.pt(), particle.eta(), crec, occrec); + } + } + } else { + if (particle.eta() > trackCuts.minEta && particle.eta() < trackCuts.maxEta) { + if (std::abs(mcCollision.posZ()) < eventCuts.maxZvtx) { + qaregistry.fill(HIST("Tracks/hPtEtaEffGen"), particle.pt(), particle.eta(), occrec); + } + } + } + // MC rec + if (particle.has_mfttracks()) { + auto iscounted = false; + auto ncnt = 0; + auto relatedTracks = particle.template mfttracks_as(); + for (auto const& track : relatedTracks) { + ++ncnt; + if constexpr (has_reco_cent) { + if (track.eta() > trackCuts.minEta && track.eta() < trackCuts.maxEta) { + if (!iscounted) { // primaries + if (std::abs(mcCollision.posZ()) < eventCuts.maxZvtx) { + qaregistry.fill(HIST("Tracks/Centrality/hPtEtaEffPrim"), particle.pt(), particle.eta(), crec, occrec); + } + iscounted = true; + } + } + if (ncnt > 1) { // secondaries + if (track.eta() > trackCuts.minEta && track.eta() < trackCuts.maxEta) { + qaregistry.fill(HIST("Tracks/Centrality/hPtEtaEffSec"), particle.pt(), particle.eta(), crec, occrec); + } + } + } else { + if (track.eta() > trackCuts.minEta && track.eta() < trackCuts.maxEta) { + if (!iscounted) { // primaries + if (std::abs(mcCollision.posZ()) < eventCuts.maxZvtx) { + qaregistry.fill(HIST("Tracks/hPtEtaEffPrim"), particle.pt(), particle.eta(), occrec); + } + iscounted = true; + } + } + if (ncnt > 1) { // secondaries + if (track.eta() > trackCuts.minEta && track.eta() < trackCuts.maxEta) { + qaregistry.fill(HIST("Tracks/hPtEtaEffSec"), particle.pt(), particle.eta(), occrec); + } + } + } + } + + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/NmftTrkPerPart"), ncnt, crec, occrec); + } else { + qaregistry.fill(HIST("Tracks/NmftTrkPerPart"), ncnt, occrec); + } + + if (relatedTracks.size() > 1) { // duplicates + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hPtEtaEffGenDupl"), particle.pt(), particle.eta(), crec, occrec); + for (auto const& track : relatedTracks) { + qaregistry.fill(HIST("Tracks/Centrality/hPtEtaEffDupl"), track.pt(), track.eta(), crec, occrec); + } + } else { + qaregistry.fill(HIST("Tracks/hPtEtaEffGenDupl"), particle.pt(), particle.eta(), occrec); + for (auto const& track : relatedTracks) { + qaregistry.fill(HIST("Tracks/hPtEtaEffDupl"), track.pt(), track.eta(), occrec); + } + } + } + } + } + } + } + + void processTrkEffIdxInlusive( + soa::Join const& collisions, + aod::McCollisions const& mccollisions, ParticlesI const& particles, + MFTTracksLabeled const& tracks) + { + processTrkEffIdx(collisions, mccollisions, + particles, tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processTrkEffIdxInlusive, + "Process tracking efficiency (inclusive, indexed)", false); + + void processTrkEffIdxCentFT0C( + soa::Join const& collisions, + aod::McCollisions const& mccollisions, ParticlesI const& particles, + MFTTracksLabeled const& tracks) + { + processTrkEffIdx(collisions, mccollisions, + particles, tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processTrkEffIdxCentFT0C, + "Process tracking efficiency (in FT0C centrality bins, indexed)", false); + + /// @brief process function to calculate tracking efficiency (indexed) based + /// on BestCollisionsFwd in FT0C bins + template + void processTrkEffBest( + typename soa::Join::iterator const& collision, + MC const& /*mccollisions*/, FiltParticles const& particles, + FiltMcMftTracks const& /*tracks*/, + soa::SmallGroups const& besttracks) + { + if (!isGoodEvent(collision)) { + return; + } + if (!collision.has_mcCollision()) { + return; + } + + float crec = getRecoCent(collision); + auto occrec = getOccupancy(collision, eventCuts.occupancyEstimator); + auto mcCollision = collision.mcCollision(); + auto partsPerCol = particles.sliceByCached( + aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); + + for (auto const& particle : partsPerCol) { + if (!isChrgParticle(particle.pdgCode())) { + continue; + } + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hPtPhiEtaZvtxEffBestGen"), + particle.pt(), particle.phi(), particle.eta(), + mcCollision.posZ(), crec, occrec); + } else { + qaregistry.fill(HIST("Tracks/hPtPhiEtaZvtxEffBestGen"), particle.pt(), + particle.phi(), particle.eta(), mcCollision.posZ(), + occrec); + } + } + + for (auto const& track : besttracks) { + auto itrack = track.mfttrack_as(); + if (!isTrackSelected(itrack)) { + continue; + } + if (itrack.has_mcParticle()) { + auto particle = itrack.mcParticle_as(); + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hPtPhiEtaZvtxEffBestRec"), + particle.pt(), itrack.phi(), itrack.eta(), + mcCollision.posZ(), crec, occrec); + } else { + qaregistry.fill(HIST("Tracks/hPtPhiEtaZvtxEffBestRec"), particle.pt(), + itrack.phi(), itrack.eta(), mcCollision.posZ(), + occrec); + } + } else { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hPtEffBestFakeRec"), + itrack.pt(), crec, occrec); + } else { + qaregistry.fill(HIST("Tracks/hPtEffBestFakeRec"), itrack.pt(), + occrec); + } + } + } + } + + void processTrkEffBestInclusive( + soa::Join::iterator const& collision, + aod::McCollisions const& mccollisions, FiltParticles const& particles, + FiltMcMftTracks const& tracks, + soa::SmallGroups const& besttracks) + { + processTrkEffBest(collision, mccollisions, + particles, tracks, besttracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processTrkEffBestInclusive, + "Process tracking efficiency (inclusive, based on BestCollisionsFwd)", + false); + + void processTrkEffBestCentFT0C( + soa::Join::iterator const& collision, + aod::McCollisions const& mccollisions, FiltParticles const& particles, + FiltMcMftTracks const& tracks, + soa::SmallGroups const& besttracks) + { + processTrkEffBest( + collision, mccollisions, particles, tracks, besttracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processTrkEffBestCentFT0C, + "Process tracking efficiency (in FT0 centrality bins, based " + "on BestCollisionsFwd)", + false); + + Preslice filtMcTrkperCol = o2::aod::fwdtrack::collisionId; + + /// @brief process function to calculate MC efficiency and fraction of fake + /// tracks + template + void processEfficiency( + typename soa::Join const& collisions, + MC const& /*mccollisions*/, FiltParticles const& /*particles*/, + FiltMcMftTracks const& tracks) + { + for (auto const& collision : collisions) { + if (!isGoodEvent(collision)) { + continue; + } + + float crec = getRecoCent(collision); + auto occrec = getOccupancy(collision, eventCuts.occupancyEstimator); + auto mcCollision = collision.mcCollision(); + auto perColTrks = + tracks.sliceBy(filtMcTrkperCol, collision.globalIndex()); + + for (auto const& track : perColTrks) { + if (!isTrackSelected(track)) { + continue; + } + if (track.has_mcParticle()) { + auto particle = track.template mcParticle_as(); + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hEffRec"), particle.pt(), + particle.phi(), particle.eta(), mcCollision.posZ(), + crec, occrec); + } else { + qaregistry.fill(HIST("Tracks/hEffRec"), particle.pt(), + particle.phi(), particle.eta(), mcCollision.posZ(), + crec, occrec); + } + } else { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hEffFake"), track.pt(), + track.phi(), track.eta(), mcCollision.posZ(), crec, + occrec); + } else { + qaregistry.fill(HIST("Tracks/hEffFake"), track.pt(), track.phi(), + track.eta(), mcCollision.posZ(), crec, occrec); + } + } + } + } + } + + void processEfficiencyInclusive( + soa::Join const& collisions, + aod::McCollisions const& mccollisions, FiltParticles const& particles, + FiltMcMftTracks const& tracks) + { + processEfficiency(collisions, mccollisions, + particles, tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processEfficiencyInclusive, + "Process efficiencies (inclusive)", false); + + void processEfficiencyCentFT0C( + soa::Join const& collisions, + aod::McCollisions const& mccollisions, FiltParticles const& particles, + FiltMcMftTracks const& tracks) + { + processEfficiency( + collisions, mccollisions, particles, tracks); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processEfficiencyCentFT0C, + "Process efficiencies in FT0C centrality bins", false); + + /// @brief process function to check ambiguous tracks + template + void processCheckAmbiguousMftTracks(typename C::iterator const& collision, + allC const& allcollisions, + MftTracksWColls const& tracks) + { + auto occ = getOccupancy(collision, eventCuts.occupancyEstimator); + float c = getRecoCent(collision); + + bool ambTrk = false; + int typeAmbTrk = 0; + for (auto const& track : tracks) { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hMftTracksAmbDegree"), + track.compatibleCollIds().size(), c, occ); + } else { + qaregistry.fill(HIST("Tracks/hMftTracksAmbDegree"), + track.compatibleCollIds().size(), occ); + } + if (track.compatibleCollIds().size() > 0) { + if (track.compatibleCollIds().size() == 1) { + if (track.collisionId() != track.compatibleCollIds()[0]) { + ambTrk = true; + typeAmbTrk = 2; + } else { + typeAmbTrk = 1; + } + } else { + ambTrk = true; + typeAmbTrk = 3; + + for (const auto& collIdx : track.compatibleCollIds()) { + auto ambColl = allcollisions.rawIteratorAt(collIdx); + qaregistry.fill(HIST("Tracks/histAmbZvtx"), ambColl.posZ()); + } + } + } + } + + if (ambTrk) { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hAmbTrackType"), typeAmbTrk, c, + occ); + } else { + qaregistry.fill(HIST("Tracks/hAmbTrackType"), typeAmbTrk, occ); + } + } else { + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hAmbTrackType"), typeAmbTrk, c, + occ); + } else { + qaregistry.fill(HIST("Tracks/hAmbTrackType"), typeAmbTrk, occ); + } + } + } + + void processCheckAmbiguousMftTracksInclusive(Colls::iterator const& collision, + Colls const& allcollisions, + MftTracksWColls const& track) + { + processCheckAmbiguousMftTracks(collision, allcollisions, + track); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processCheckAmbiguousMftTracksInclusive, + "Process checks for Ambiguous MFT tracks (inclusive)", false); + + void processCheckAmbiguousMftTracksCentFT0C( + CollsCentFT0C::iterator const& collision, + CollsCentFT0C const& allcollisions, MftTracksWColls const& track) + { + processCheckAmbiguousMftTracks( + collision, allcollisions, track); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processCheckAmbiguousMftTracksCentFT0C, + "Process checks for Ambiguous MFT tracks (in FT0C centrality bins)", + false); + + Preslice filtTrkperCol = o2::aod::fwdtrack::collisionId; + + /// @brief process template function for MC QA checks + template + void + processMcQA(typename soa::Join const& collisions, + MFTTracksLabeled const& tracks, + aod::AmbiguousMFTTracks const& atracks, + aod::McCollisions const& mcCollisions, + FiltParticles const& /*particles*/) + { + for (const auto& collision : collisions) { + float crec = getRecoCent(collision); + auto occrec = getOccupancy(collision, eventCuts.occupancyEstimator); + + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Events/Centrality/hRecPerGenColls"), + static_cast(collisions.size()) / + mcCollisions.size(), + crec, occrec); + } else { + qaregistry.fill(HIST("Events/hRecPerGenColls"), + static_cast(collisions.size()) / + mcCollisions.size(), + occrec); + } + + if (!isGoodEvent(collision)) { + return; + } + + auto trkPerColl = tracks.sliceBy(filtTrkperCol, collision.globalIndex()); + uint ntracks{0u}, nAtracks{0u}; + for (const auto& track : trkPerColl) { + ntracks++; + for (const auto& atrack : atracks) { + if (atrack.mfttrackId() == track.globalIndex()) { + nAtracks++; + break; + } + } + } + if constexpr (has_reco_cent) { + qaregistry.fill(HIST("Tracks/Centrality/hNmftTrks"), ntracks, crec, + occrec); + qaregistry.fill(HIST("Tracks/Centrality/hFracAmbiguousMftTrks"), + static_cast(nAtracks) / ntracks, crec, occrec); + } else { + qaregistry.fill(HIST("Tracks/hNmftTrks"), ntracks, occrec); + qaregistry.fill(HIST("Tracks/hFracAmbiguousMftTrks"), + static_cast(nAtracks) / ntracks, occrec); + } + } + } + + void processMcQAInclusive( + soa::Join const& collisions, + MFTTracksLabeled const& tracks, aod::AmbiguousMFTTracks const& atracks, + aod::McCollisions const& mcCollisions, FiltParticles const& particles) + { + processMcQA(collisions, tracks, atracks, mcCollisions, particles); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMcQAInclusive, + "Process MC QA checks (inclusive)", false); + + void processMcQACentFT0C( + soa::Join const& collisions, + MFTTracksLabeled const& tracks, aod::AmbiguousMFTTracks const& atracks, + aod::McCollisions const& mcCollisions, FiltParticles const& particles) + { + processMcQA(collisions, tracks, atracks, mcCollisions, + particles); + } + + PROCESS_SWITCH(DndetaMFTPbPb, processMcQACentFT0C, + "Process MC QA checks (in FT0 centrality bins)", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGMM/Mult/Tasks/flattenicty-chrg.cxx b/PWGMM/Mult/Tasks/flattenicty-chrg.cxx index 75f628f613a..fbfa4ab578d 100644 --- a/PWGMM/Mult/Tasks/flattenicty-chrg.cxx +++ b/PWGMM/Mult/Tasks/flattenicty-chrg.cxx @@ -1,4 +1,4 @@ -// Copyright 2020-2022 CERN and copyright holders of ALICE O2. +// Copyright 2020-2025 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. // diff --git a/PWGMM/Mult/Tasks/heavy-ion-mult.cxx b/PWGMM/Mult/Tasks/heavy-ion-mult.cxx index 0e0a08568e5..bb12521502d 100644 --- a/PWGMM/Mult/Tasks/heavy-ion-mult.cxx +++ b/PWGMM/Mult/Tasks/heavy-ion-mult.cxx @@ -53,12 +53,12 @@ using namespace o2::framework::expressions; using namespace o2::aod::track; using namespace o2::aod::evsel; -using CollisionDataTable = soa::Join; +using CollisionDataTable = soa::Join; using TrackDataTable = soa::Join; using FilTrackDataTable = soa::Filtered; using CollisionMCTrueTable = aod::McCollisions; using TrackMCTrueTable = aod::McParticles; -using CollisionMCRecTable = soa::SmallGroups>; +using CollisionMCRecTable = soa::SmallGroups>; using TrackMCRecTable = soa::Join; using FilTrackMCRecTable = soa::Filtered; using v0trackcandidates = soa::Join; @@ -104,7 +104,7 @@ static constexpr TrackSelectionFlags::flagtype trackSelectionDCA = static constexpr TrackSelectionFlags::flagtype trackSelectionDCAXYonly = TrackSelectionFlags::kDCAxy; -AxisSpec axisEvent{10, 0.5, 10.5, "#Event", "EventAxis"}; +AxisSpec axisEvent{12, 0.5, 12.5, "#Event", "EventAxis"}; AxisSpec axisVtxZ{40, -20, 20, "Vertex Z", "VzAxis"}; AxisSpec axisEta{40, -2, 2, "#eta", "EtaAxis"}; AxisSpec axisPhi{{0, M_PI / 4, M_PI / 2, M_PI * 3. / 4, M_PI, M_PI * 5. / 4, M_PI * 3. / 2, M_PI * 7. / 4, 2 * M_PI}, "#phi", "PhiAxis"}; @@ -152,7 +152,14 @@ struct HeavyIonMultiplicity { Configurable NPVtracksCut{"NPVtracksCut", 1.0f, "Apply extra NPVtracks cut"}; Configurable FT0CCut{"FT0CCut", 1.0f, "Apply extra FT0C cut"}; Configurable IsApplyNoCollInTimeRangeStandard{"IsApplyNoCollInTimeRangeStandard", true, "Enable NoCollInTimeRangeStandard cut"}; + Configurable IsApplyNoCollInRofStandard{"IsApplyNoCollInRofStandard", true, "Enable NoCollInRofStandard cut"}; + Configurable IsApplyNoHighMultCollInPrevRof{"IsApplyNoHighMultCollInPrevRof", true, "Enable NoHighMultCollInPrevRof cut"}; Configurable IsApplyFT0CbasedOccupancy{"IsApplyFT0CbasedOccupancy", true, "Enable FT0CbasedOccupancy cut"}; + Configurable IsApplyCentFT0C{"IsApplyCentFT0C", false, "Centrality based on FT0C"}; + Configurable IsApplyCentFT0CVariant1{"IsApplyCentFT0CVariant1", false, "Centrality based on FT0C variant1"}; + Configurable IsApplyCentFT0M{"IsApplyCentFT0M", false, "Centrality based on FT0A + FT0C"}; + Configurable IsApplyCentNGlobal{"IsApplyCentNGlobal", false, "Centrality based on global tracks"}; + Configurable IsApplyCentMFT{"IsApplyCentMFT", false, "Centrality based on MFT tracks"}; void init(InitContext const&) { @@ -180,6 +187,8 @@ struct HeavyIonMultiplicity { x->SetBinLabel(8, "Centrality"); x->SetBinLabel(9, "ApplyExtraCorrCut"); x->SetBinLabel(10, "ApplyNoCollInTimeRangeStandard"); + x->SetBinLabel(11, "ApplyNoCollInRofStandard"); + x->SetBinLabel(12, "ApplyNoHighMultCollInPrevRof"); if (doprocessData) { histos.add("CentPercentileHist", "CentPercentileHist", kTH1D, {axisCent}, false); @@ -321,9 +330,39 @@ struct HeavyIonMultiplicity { return false; } histos.fill(HIST("EventHist"), 10); + + if (IsApplyNoCollInRofStandard && !col.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; + } + histos.fill(HIST("EventHist"), 11); + + if (IsApplyNoHighMultCollInPrevRof && !col.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + return false; + } + histos.fill(HIST("EventHist"), 12); return true; } - + template + float SelectColCentrality(CheckColCent const& col) + { + auto cent = -1; + if (IsApplyCentFT0C) { + cent = col.centFT0C(); + } + if (IsApplyCentFT0CVariant1) { + cent = col.centFT0CVariant1(); + } + if (IsApplyCentFT0M) { + cent = col.centFT0M(); + } + if (IsApplyCentNGlobal) { + cent = col.centNGlobal(); + } + if (IsApplyCentMFT) { + cent = col.centMFT(); + } + return cent; + } expressions::Filter trackSelectionProperMixed = ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) && ncheckbit(aod::track::trackCutFlag, trackSelectionITS) && ifnode(ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC), @@ -337,9 +376,9 @@ struct HeavyIonMultiplicity { return; } histos.fill(HIST("VtxZHist"), collision.posZ()); - histos.fill(HIST("CentPercentileHist"), collision.centFT0C()); + histos.fill(HIST("CentPercentileHist"), SelectColCentrality(collision)); auto OccupancyValue = IsApplyFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); - histos.fill(HIST("hdatazvtxcent"), collision.posZ(), collision.centFT0C(), OccupancyValue); + histos.fill(HIST("hdatazvtxcent"), collision.posZ(), SelectColCentrality(collision), OccupancyValue); auto NchTracks = 0; for (auto& track : tracks) { @@ -348,14 +387,14 @@ struct HeavyIonMultiplicity { } histos.fill(HIST("PhiVsEtaHist"), track.phi(), track.eta()); NchTracks++; - histos.fill(HIST("hdatadndeta"), collision.posZ(), collision.centFT0C(), OccupancyValue, track.eta(), track.phi(), kGlobalplusITS); + histos.fill(HIST("hdatadndeta"), collision.posZ(), SelectColCentrality(collision), OccupancyValue, track.eta(), track.phi(), kGlobalplusITS); if (track.hasTPC()) { - histos.fill(HIST("hdatadndeta"), collision.posZ(), collision.centFT0C(), OccupancyValue, track.eta(), track.phi(), kGlobalonly); + histos.fill(HIST("hdatadndeta"), collision.posZ(), SelectColCentrality(collision), OccupancyValue, track.eta(), track.phi(), kGlobalonly); } else { - histos.fill(HIST("hdatadndeta"), collision.posZ(), collision.centFT0C(), OccupancyValue, track.eta(), track.phi(), kITSonly); + histos.fill(HIST("hdatadndeta"), collision.posZ(), SelectColCentrality(collision), OccupancyValue, track.eta(), track.phi(), kITSonly); } } - histos.fill(HIST("hdatamult"), collision.posZ(), NchTracks, collision.centFT0C()); + histos.fill(HIST("hdatamult"), collision.posZ(), NchTracks, SelectColCentrality(collision)); } PROCESS_SWITCH(HeavyIonMultiplicity, processData, "process data CentFT0C", false); @@ -391,9 +430,9 @@ struct HeavyIonMultiplicity { continue; } histos.fill(HIST("VtxZHist"), RecCollision.posZ()); - histos.fill(HIST("CentPercentileMCRecHist"), RecCollision.centFT0C()); + histos.fill(HIST("CentPercentileMCRecHist"), SelectColCentrality(RecCollision)); auto OccupancyValue = IsApplyFT0CbasedOccupancy ? RecCollision.ft0cOccupancyInTimeRange() : RecCollision.trackOccupancyInTimeRange(); - histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue); + histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), SelectColCentrality(RecCollision), OccupancyValue); auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); for (auto& Rectrack : Rectrackspart) { @@ -401,20 +440,20 @@ struct HeavyIonMultiplicity { continue; } histos.fill(HIST("MCrecPhiVsEtaHist"), Rectrack.phi(), Rectrack.eta()); - histos.fill(HIST("hmcrecdndeta"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue, Rectrack.eta(), Rectrack.phi()); + histos.fill(HIST("hmcrecdndeta"), RecCollision.posZ(), SelectColCentrality(RecCollision), OccupancyValue, Rectrack.eta(), Rectrack.phi()); } // track (mcrec) loop for (auto& particle : GenParticles) { if (!IsGenTrackSelected(particle)) { continue; } - histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), RecCollision.centFT0C(), particle.eta(), particle.phi(), kNoGenpTVar); + histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), SelectColCentrality(RecCollision), particle.eta(), particle.phi(), kNoGenpTVar); if (particle.pt() < 0.1) { - histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), RecCollision.centFT0C(), particle.eta(), particle.phi(), kGenpTup, -10.0 * particle.pt() + 2); - histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), RecCollision.centFT0C(), particle.eta(), particle.phi(), kGenpTdown, 5.0 * particle.pt() + 0.5); + histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), SelectColCentrality(RecCollision), particle.eta(), particle.phi(), kGenpTup, -10.0 * particle.pt() + 2); + histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), SelectColCentrality(RecCollision), particle.eta(), particle.phi(), kGenpTdown, 5.0 * particle.pt() + 0.5); } else { - histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), RecCollision.centFT0C(), particle.eta(), particle.phi(), kGenpTup); - histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), RecCollision.centFT0C(), particle.eta(), particle.phi(), kGenpTdown); + histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), SelectColCentrality(RecCollision), particle.eta(), particle.phi(), kGenpTup); + histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), SelectColCentrality(RecCollision), particle.eta(), particle.phi(), kGenpTdown); } } // track (mcgen) loop } // collision loop @@ -431,9 +470,9 @@ struct HeavyIonMultiplicity { continue; } histos.fill(HIST("VtxZHist"), RecCollision.posZ()); - histos.fill(HIST("CentPercentileMCRecHist"), RecCollision.centFT0C()); + histos.fill(HIST("CentPercentileMCRecHist"), SelectColCentrality(RecCollision)); auto OccupancyValue = IsApplyFT0CbasedOccupancy ? RecCollision.ft0cOccupancyInTimeRange() : RecCollision.trackOccupancyInTimeRange(); - histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue); + histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), SelectColCentrality(RecCollision), OccupancyValue); auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); for (auto& Rectrack : Rectrackspart) { @@ -443,7 +482,7 @@ struct HeavyIonMultiplicity { if (Rectrack.has_mcParticle()) { auto mcpart = Rectrack.mcParticle(); if (mcpart.isPhysicalPrimary()) { - histos.fill(HIST("hmcrecdndpt"), RecCollision.centFT0C(), mcpart.pt()); + histos.fill(HIST("hmcrecdndpt"), SelectColCentrality(RecCollision), mcpart.pt()); } } } @@ -452,13 +491,13 @@ struct HeavyIonMultiplicity { if (!IsGenTrackSelected(particle)) { continue; } - histos.fill(HIST("hmcgendndpt"), RecCollision.centFT0C(), particle.pt(), kNoGenpTVar); + histos.fill(HIST("hmcgendndpt"), SelectColCentrality(RecCollision), particle.pt(), kNoGenpTVar); if (particle.pt() < 0.1) { - histos.fill(HIST("hmcgendndpt"), RecCollision.centFT0C(), particle.pt(), kGenpTup, -10.0 * particle.pt() + 2); - histos.fill(HIST("hmcgendndpt"), RecCollision.centFT0C(), particle.pt(), kGenpTdown, 5.0 * particle.pt() + 0.5); + histos.fill(HIST("hmcgendndpt"), SelectColCentrality(RecCollision), particle.pt(), kGenpTup, -10.0 * particle.pt() + 2); + histos.fill(HIST("hmcgendndpt"), SelectColCentrality(RecCollision), particle.pt(), kGenpTdown, 5.0 * particle.pt() + 0.5); } else { - histos.fill(HIST("hmcgendndpt"), RecCollision.centFT0C(), particle.pt(), kGenpTup); - histos.fill(HIST("hmcgendndpt"), RecCollision.centFT0C(), particle.pt(), kGenpTdown); + histos.fill(HIST("hmcgendndpt"), SelectColCentrality(RecCollision), particle.pt(), kGenpTup); + histos.fill(HIST("hmcgendndpt"), SelectColCentrality(RecCollision), particle.pt(), kGenpTdown); } } } @@ -475,9 +514,9 @@ struct HeavyIonMultiplicity { continue; } histos.fill(HIST("VtxZHist"), RecCollision.posZ()); - histos.fill(HIST("CentPercentileMCRecHist"), RecCollision.centFT0C()); + histos.fill(HIST("CentPercentileMCRecHist"), SelectColCentrality(RecCollision)); auto OccupancyValue = IsApplyFT0CbasedOccupancy ? RecCollision.ft0cOccupancyInTimeRange() : RecCollision.trackOccupancyInTimeRange(); - histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue); + histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), SelectColCentrality(RecCollision), OccupancyValue); auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); for (auto& Rectrack : Rectrackspart) { @@ -487,19 +526,19 @@ struct HeavyIonMultiplicity { if (!Rectrack.hasTPC()) { continue; } - histos.fill(HIST("hTracksCount"), RecCollision.centFT0C(), 1); + histos.fill(HIST("hTracksCount"), SelectColCentrality(RecCollision), 1); bool IsFakeITStracks = false; for (int i = 0; i < 7; i++) { if (Rectrack.mcMask() & 1 << i) { IsFakeITStracks = true; - histos.fill(HIST("hTracksCount"), RecCollision.centFT0C(), i + 3); + histos.fill(HIST("hTracksCount"), SelectColCentrality(RecCollision), i + 3); break; } } if (IsFakeITStracks) { continue; } - histos.fill(HIST("hTracksCount"), RecCollision.centFT0C(), 2); + histos.fill(HIST("hTracksCount"), SelectColCentrality(RecCollision), 2); } } } @@ -515,9 +554,9 @@ struct HeavyIonMultiplicity { continue; } histos.fill(HIST("VtxZHist"), RecCollision.posZ()); - histos.fill(HIST("CentPercentileMCRecHist"), RecCollision.centFT0C()); + histos.fill(HIST("CentPercentileMCRecHist"), SelectColCentrality(RecCollision)); auto OccupancyValue = IsApplyFT0CbasedOccupancy ? RecCollision.ft0cOccupancyInTimeRange() : RecCollision.trackOccupancyInTimeRange(); - histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue); + histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), SelectColCentrality(RecCollision), OccupancyValue); auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); std::vector mclabels; @@ -525,7 +564,7 @@ struct HeavyIonMultiplicity { if (!IsTrackSelected(Rectrack)) { continue; } - histos.fill(HIST("FillMCrecSpecies"), RecCollision.centFT0C(), OccupancyValue, Rectrack.eta(), Double_t(kSpAll)); + histos.fill(HIST("FillMCrecSpecies"), SelectColCentrality(RecCollision), OccupancyValue, Rectrack.eta(), Double_t(kSpAll)); if (Rectrack.has_mcParticle()) { Int_t pid = kBkg; auto mcpart = Rectrack.template mcParticle_as(); @@ -557,9 +596,9 @@ struct HeavyIonMultiplicity { pid = kBkg; } mclabels.push_back(Rectrack.mcParticleId()); - histos.fill(HIST("FillMCrecSpecies"), RecCollision.centFT0C(), OccupancyValue, Rectrack.eta(), Double_t(pid)); + histos.fill(HIST("FillMCrecSpecies"), SelectColCentrality(RecCollision), OccupancyValue, Rectrack.eta(), Double_t(pid)); } else { - histos.fill(HIST("FillMCrecSpecies"), RecCollision.centFT0C(), OccupancyValue, Rectrack.eta(), Double_t(kBkg)); + histos.fill(HIST("FillMCrecSpecies"), SelectColCentrality(RecCollision), OccupancyValue, Rectrack.eta(), Double_t(kBkg)); } } // rec track loop @@ -567,7 +606,7 @@ struct HeavyIonMultiplicity { if (!IsGenTrackSelected(particle)) { continue; } - histos.fill(HIST("FillMCgenSpecies"), RecCollision.centFT0C(), particle.eta(), Double_t(kSpAll)); + histos.fill(HIST("FillMCgenSpecies"), SelectColCentrality(RecCollision), particle.eta(), Double_t(kSpAll)); Int_t pid = 0; switch (std::abs(particle.pdgCode())) { case 211: @@ -583,7 +622,7 @@ struct HeavyIonMultiplicity { pid = kSpOther; break; } - histos.fill(HIST("FillMCgenSpecies"), RecCollision.centFT0C(), particle.eta(), Double_t(pid)); + histos.fill(HIST("FillMCgenSpecies"), SelectColCentrality(RecCollision), particle.eta(), Double_t(pid)); } // gen track loop } // collision loop } @@ -597,7 +636,7 @@ struct HeavyIonMultiplicity { if (std::abs(collision.posZ()) >= VtxRange) { return; } - histos.fill(HIST("hzvtxcent"), collision.posZ(), collision.centFT0C()); + histos.fill(HIST("hzvtxcent"), collision.posZ(), SelectColCentrality(collision)); for (auto& v0track : v0data) { auto v0pTrack = v0track.template posTrack_as(); auto v0nTrack = v0track.template negTrack_as(); @@ -625,9 +664,9 @@ struct HeavyIonMultiplicity { if (std::abs(v0track.dcapostopv()) < dcapostopvCut || std::abs(v0track.dcanegtopv()) < dcanegtopvCut || v0track.v0radius() < v0radiusCut || v0track.v0cosPA() < v0cospaCut || std::abs(v0track.dcaV0daughters()) > dcav0daughtercut) { continue; } - histos.fill(HIST("K0sCentEtaMass"), collision.centFT0C(), v0track.eta(), v0track.mK0Short()); - histos.fill(HIST("LambdaCentEtaMass"), collision.centFT0C(), v0track.eta(), v0track.mLambda()); - histos.fill(HIST("AntiLambdaCentEtaMass"), collision.centFT0C(), v0track.eta(), v0track.mAntiLambda()); + histos.fill(HIST("K0sCentEtaMass"), SelectColCentrality(collision), v0track.eta(), v0track.mK0Short()); + histos.fill(HIST("LambdaCentEtaMass"), SelectColCentrality(collision), v0track.eta(), v0track.mLambda()); + histos.fill(HIST("AntiLambdaCentEtaMass"), SelectColCentrality(collision), v0track.eta(), v0track.mAntiLambda()); } } PROCESS_SWITCH(HeavyIonMultiplicity, processStrangeYield, "Strange particle yield", false); diff --git a/PWGMM/UE/Tasks/CMakeLists.txt b/PWGMM/UE/Tasks/CMakeLists.txt index cbf3a39ebc4..f9ee32c6e10 100644 --- a/PWGMM/UE/Tasks/CMakeLists.txt +++ b/PWGMM/UE/Tasks/CMakeLists.txt @@ -20,6 +20,6 @@ o2physics_add_dpl_workflow(ue-zdc-analysis COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(dedx-analysis - SOURCES dedx_analysys.cxx + SOURCES dedxAnalysis.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGMM/UE/Tasks/dedxAnalysis.cxx b/PWGMM/UE/Tasks/dedxAnalysis.cxx new file mode 100644 index 00000000000..11aea4031be --- /dev/null +++ b/PWGMM/UE/Tasks/dedxAnalysis.cxx @@ -0,0 +1,852 @@ +// 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 Paola Vargas Torres (paola.vargas.torres@cern.ch) +/// \since January 8, 2025 +/// \file dedxAnalysis.cxx +/// \brief Analysis to do PID + +#include "PWGLF/DataModel/LFStrangenessTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" + +#include "TF1.h" + +using namespace o2; +using namespace o2::framework; +using namespace constants::physics; + +using PIDTracks = soa::Join< + aod::Tracks, aod::TracksExtra, aod::TrackSelectionExtension, aod::TracksDCA, aod::TrackSelection, + aod::pidTOFFullPi, aod::pidTOFFullPr, aod::pidTOFFullEl, aod::pidTOFbeta>; + +using SelectedCollisions = soa::Join; + +struct DedxAnalysis { + + // dE/dx for all charged particles + HistogramRegistry registryDeDx{ + "registryDeDx", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + // Constant values + static constexpr int kEtaIntervals = 8; + static constexpr int kParticlesType = 4; + float tpcCut = 0.6; + float pionMin = 0.35; + float pionMax = 0.45; + float elTofCut = 0.1; + float pionTofCut = 1.0; + float invMassCut = 0.01; + float invMassCutGamma = 0.0015; + float magField = 1; + float pTcut = 2.0; + + // Configurable Parameters + // Tracks cuts + Configurable minTPCnClsFound{"minTPCnClsFound", 70.0f, + "min number of found TPC clusters"}; + Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 70.0f, "min number of found TPC crossed rows"}; + Configurable maxChi2TPC{"maxChi2TPC", 4.0f, + "max chi2 per cluster TPC"}; + Configurable maxChi2ITS{"maxChi2ITS", 36.0f, + "max chi2 per cluster ITS"}; + Configurable maxZDistanceToIP{"maxZDistanceToIP", 10.0f, + "max z distance to IP"}; + Configurable etaMin{"etaMin", -0.8f, "etaMin"}; + Configurable etaMax{"etaMax", +0.8f, "etaMax"}; + Configurable minNCrossedRowsOverFindableClustersTPC{"minNCrossedRowsOverFindableClustersTPC", 0.8f, "Additional cut on the minimum value of the ratio between crossed rows and findable clusters in the TPC"}; + Configurable maxDCAz{"maxDCAz", 2.f, "maxDCAz"}; + // v0 cuts + Configurable v0cospaMin{"v0cospaMin", 0.998f, "Minimum V0 CosPA"}; + Configurable minimumV0Radius{"minimumV0Radius", 0.5f, + "Minimum V0 Radius"}; + Configurable maximumV0Radius{"maximumV0Radius", 100.0f, + "Maximum V0 Radius"}; + Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 0.5f, + "Maximum DCA Daughters"}; + Configurable nsigmaTOFmax{"nsigmaTOFmax", 3.0f, "Maximum nsigma TOF"}; + Configurable minMassK0s{"minMassK0s", 0.4f, "Minimum Mass K0s"}; + Configurable maxMassK0s{"maxMassK0s", 0.6f, "Maximum Mass K0s"}; + Configurable minMassLambda{"minMassLambda", 1.1f, + "Minimum Mass Lambda"}; + Configurable maxMassLambda{"maxMassLambda", 1.2f, + "Maximum Mass Lambda"}; + Configurable minMassGamma{"minMassGamma", 0.000922f, + "Minimum Mass Gamma"}; + Configurable maxMassGamma{"maxMassGamma", 0.002022f, + "Maximum Mass Gamma"}; + Configurable nclCut{"nclCut", 135.0f, + "ncl Cut"}; + Configurable calibrationMode{"calibrationMode", false, "calibration mode"}; + Configurable additionalCuts{"additionalCuts", true, "additional cuts"}; + // Histograms names + static constexpr std::string_view kDedxvsMomentumPos[kParticlesType] = {"dEdx_vs_Momentum_all_Pos", "dEdx_vs_Momentum_Pi_v0_Pos", "dEdx_vs_Momentum_Pr_v0_Pos", "dEdx_vs_Momentum_El_v0_Pos"}; + static constexpr std::string_view kDedxvsMomentumNeg[kParticlesType] = {"dEdx_vs_Momentum_all_Neg", "dEdx_vs_Momentum_Pi_v0_Neg", "dEdx_vs_Momentum_Pr_v0_Neg", "dEdx_vs_Momentum_El_v0_Neg"}; + static constexpr std::string_view kNclDedxMomentumNegBefore[kEtaIntervals] = {"Ncl_vs_dEdx_vs_Momentum_Neg_1_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_2_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_3_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_4_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_5_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_6_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_7_Before", "Ncl_vs_dEdx_vs_Momentum_Neg_8_Before"}; + static constexpr std::string_view kNclDedxMomentumPosBefore[kEtaIntervals] = {"Ncl_vs_dEdx_vs_Momentum_Pos_1_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_2_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_3_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_4_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_5_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_6_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_7_Before", "Ncl_vs_dEdx_vs_Momentum_Pos_8_Before"}; + static constexpr std::string_view kNclDedxMomentumNegAfter[kEtaIntervals] = {"Ncl_vs_dEdx_vs_Momentum_Neg_1_After", "Ncl_vs_dEdx_vs_Momentum_Neg_2_After", "Ncl_vs_dEdx_vs_Momentum_Neg_3_After", "Ncl_vs_dEdx_vs_Momentum_Neg_4_After", "Ncl_vs_dEdx_vs_Momentum_Neg_5_After", "Ncl_vs_dEdx_vs_Momentum_Neg_6_After", "Ncl_vs_dEdx_vs_Momentum_Neg_7_After", "Ncl_vs_dEdx_vs_Momentum_Neg_8_After"}; + static constexpr std::string_view kNclDedxMomentumPosAfter[kEtaIntervals] = {"Ncl_vs_dEdx_vs_Momentum_Pos_1_After", "Ncl_vs_dEdx_vs_Momentum_Pos_2_After", "Ncl_vs_dEdx_vs_Momentum_Pos_3_After", "Ncl_vs_dEdx_vs_Momentum_Pos_4_After", "Ncl_vs_dEdx_vs_Momentum_Pos_5_After", "Ncl_vs_dEdx_vs_Momentum_Pos_6_After", "Ncl_vs_dEdx_vs_Momentum_Pos_7_After", "Ncl_vs_dEdx_vs_Momentum_Pos_8_After"}; + static constexpr double EtaCut[kEtaIntervals + 1] = {-0.8, -0.6, -0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8}; + Configurable> calibrationFactorNeg{"calibrationFactorNeg", {50.4011, 50.4764, 50.186, 49.2955, 48.8222, 49.4273, 49.9292, 50.0556}, "negative calibration factors"}; + Configurable> calibrationFactorPos{"calibrationFactorPos", {50.5157, 50.6359, 50.3198, 49.3345, 48.9197, 49.4931, 50.0188, 50.1406}, "positive calibration factors"}; + ConfigurableAxis binP{"binP", {VARIABLE_WIDTH, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 18.0, 20.0}, ""}; + + // phi cut fits + TF1* fphiCutHigh = nullptr; + TF1* fphiCutLow = nullptr; + + TrackSelection myTrackSelection() + { + TrackSelection selectedTracks; + selectedTracks.SetPtRange(0.1f, 1e10f); + selectedTracks.SetEtaRange(etaMin, etaMax); + selectedTracks.SetRequireITSRefit(true); + selectedTracks.SetRequireTPCRefit(true); + selectedTracks.SetMinNCrossedRowsTPC(minNCrossedRowsTPC); + selectedTracks.SetMinNCrossedRowsOverFindableClustersTPC(minNCrossedRowsOverFindableClustersTPC); + selectedTracks.SetMaxChi2PerClusterTPC(maxChi2TPC); + selectedTracks.SetRequireHitsInITSLayers(1, {0, 1}); + selectedTracks.SetMaxChi2PerClusterITS(maxChi2ITS); + selectedTracks.SetMaxDcaXYPtDep([](float pt) { return 0.0105f + 0.0350f / std::pow(pt, 1.1f); }); + selectedTracks.SetMaxDcaZ(maxDCAz); + selectedTracks.SetRequireGoldenChi2(true); + + return selectedTracks; + } + + TrackSelection mySelectionPrim; + + void init(InitContext const&) + { + AxisSpec dedxAxis{100, 0.0, 100.0, "dE/dx (a. u.)"}; + AxisSpec ptAxis = {binP, "pT (GeV/c)"}; + AxisSpec etaAxis{8, -0.8, 0.8, "#eta"}; + AxisSpec pAxis = {binP, "#it{p}/Z (GeV/c)"}; + fphiCutLow = new TF1("StandardPhiCutLow", "0.119297/x/x+pi/18.0-0.000379693", 0, 50); + fphiCutHigh = new TF1("StandardPhiCutHigh", "0.16685/x+pi/18.0+0.00981942", 0, 50); + if (calibrationMode) { + // MIP for pions + registryDeDx.add( + "hdEdx_vs_eta_Neg_Pi", "dE/dx", HistType::kTH2F, + {{etaAxis}, {dedxAxis}}); + registryDeDx.add( + "hdEdx_vs_eta_Pos_Pi", "dE/dx", HistType::kTH2F, + {{etaAxis}, {dedxAxis}}); + // MIP for electrons + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Neg_El", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Pos_El", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + // Pions from TOF + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Neg_TOF", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Pos_TOF", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + } else { + // MIP for pions + registryDeDx.add( + "hdEdx_vs_eta_Neg_calibrated_Pi", "dE/dx", HistType::kTH2F, + {{etaAxis}, {dedxAxis}}); + + registryDeDx.add( + "hdEdx_vs_eta_Pos_calibrated_Pi", "dE/dx", HistType::kTH2F, + {{etaAxis}, {dedxAxis}}); + + // MIP for electrons + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Neg_calibrated_El", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Pos_calibrated_El", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + // Pions from TOF + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Neg_calibrated_TOF", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + registryDeDx.add( + "hdEdx_vs_eta_vs_p_Pos_calibrated_TOF", "dE/dx", HistType::kTH3F, + {{etaAxis}, {dedxAxis}, {pAxis}}); + + // pt vs p + registryDeDx.add( + "hp_vs_pt_all_Neg", "p_vs_pT", HistType::kTH2F, + {{ptAxis}, {pAxis}}); + registryDeDx.add( + "hp_vs_pt_all_Pos", "p_vs_pT", HistType::kTH2F, + {{ptAxis}, {pAxis}}); + + // De/Dx for ch and v0 particles + for (int i = 0; i < kParticlesType; ++i) { + registryDeDx.add(kDedxvsMomentumPos[i].data(), "dE/dx", HistType::kTH3F, + {{pAxis}, {dedxAxis}, {etaAxis}}); + registryDeDx.add(kDedxvsMomentumNeg[i].data(), "dE/dx", HistType::kTH3F, + {{pAxis}, {dedxAxis}, {etaAxis}}); + } + } + + registryDeDx.add( + "hdEdx_vs_phi", "dE/dx", HistType::kTH2F, + {{100, 0.0, 6.4, "#phi"}, {dedxAxis}}); + + // phi cut + registryDeDx.add( + "hpt_vs_phi_Ncl_After", "phi cut", HistType::kTH3F, + {{ptAxis}, {100, 0.0, 0.4, "#varphi^{'}"}, {100, 0, 160, "N_{cl}"}}); + + registryDeDx.add( + "hpt_vs_phi_Ncl_Before", "phi cut", HistType::kTH3F, + {{ptAxis}, {100, 0.0, 0.4, "#varphi^{'}"}, {100, 0, 160, "N_{cl}"}}); + + // Ncl vs de/dx + + for (int i = 0; i < kEtaIntervals; ++i) { + registryDeDx.add(kNclDedxMomentumPosBefore[i].data(), "Ncl vs dE/dx vs Momentum Positive before", HistType::kTH3F, + {{100, 0, 160, "N_{cl}"}, {dedxAxis}, {pAxis}}); + registryDeDx.add(kNclDedxMomentumNegBefore[i].data(), "Ncl vs dE/dx vs Momentum Negative before", HistType::kTH3F, + {{100, 0, 160, "N_{cl}"}, {dedxAxis}, {pAxis}}); + + registryDeDx.add(kNclDedxMomentumPosAfter[i].data(), "Ncl vs dE/dx vs Momentum Positive after", HistType::kTH3F, + {{100, 0, 160, "N_{cl}"}, {dedxAxis}, {pAxis}}); + registryDeDx.add(kNclDedxMomentumNegAfter[i].data(), "Ncl vs dE/dx vs Momentum Negative after", HistType::kTH3F, + {{100, 0, 160, "N_{cl}"}, {dedxAxis}, {pAxis}}); + } + + // beta plot + registryDeDx.add( + "hbeta_vs_p_Neg", "beta", HistType::kTH2F, + {{pAxis}, {100, 0.0, 1.1, "#beta"}}); + + registryDeDx.add( + "hbeta_vs_p_Pos", "beta", HistType::kTH2F, + {{pAxis}, {100, 0.0, 1.1, "#beta"}}); + + // Event Counter + registryDeDx.add("histRecVtxZData", "collision z position", HistType::kTH1F, {{100, -20.0, +20.0, "z_{vtx} (cm)"}}); + + mySelectionPrim = myTrackSelection(); + } + + // Single-Track Selection + template + bool passedSingleTrackSelection(const T1& track, const C& /*collision*/) + { + // Single-Track Selections + 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; + + return true; + } + + // General V0 Selections + template + bool passedV0Selection(const T1& v0, const C& /*collision*/) + { + if (v0.v0cosPA() < v0cospaMin) + return false; + if (v0.v0radius() < minimumV0Radius || v0.v0radius() > maximumV0Radius) + return false; + + return true; + } + + // K0s Selections + template + bool passedK0Selection(const T1& v0, const T2& ntrack, const T2& ptrack, + const C& collision) + { + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack, collision)) + return false; + if (!passedSingleTrackSelection(ntrack, collision)) + return false; + + if (ptrack.tpcInnerParam() > tpcCut) { + if (!ptrack.hasTOF()) + return false; + if (std::abs(ptrack.tofNSigmaPi()) > nsigmaTOFmax) + return false; + } + + if (ntrack.tpcInnerParam() > tpcCut) { + if (!ntrack.hasTOF()) + return false; + if (std::abs(ntrack.tofNSigmaPi()) > nsigmaTOFmax) + return false; + } + + // Invariant-Mass Selection + if (v0.mK0Short() < minMassK0s || v0.mK0Short() > maxMassK0s) + return false; + + return true; + } + + // Lambda Selections + template + bool passedLambdaSelection(const T1& v0, const T2& ntrack, const T2& ptrack, + const C& collision) + { + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack, collision)) + return false; + if (!passedSingleTrackSelection(ntrack, collision)) + return false; + + if (ptrack.tpcInnerParam() > tpcCut) { + if (!ptrack.hasTOF()) + return false; + if (std::abs(ptrack.tofNSigmaPr()) > nsigmaTOFmax) + return false; + } + + if (ntrack.tpcInnerParam() > tpcCut) { + if (!ntrack.hasTOF()) + return false; + if (std::abs(ntrack.tofNSigmaPi()) > nsigmaTOFmax) + return false; + } + + // Invariant-Mass Selection + if (v0.mLambda() < minMassLambda || v0.mLambda() > maxMassLambda) + return false; + + return true; + } + + // AntiLambda Selections + template + bool passedAntiLambdaSelection(const T1& v0, const T2& ntrack, + const T2& ptrack, const C& collision) + { + + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack, collision)) + return false; + if (!passedSingleTrackSelection(ntrack, collision)) + return false; + + if (ptrack.tpcInnerParam() > tpcCut) { + if (!ptrack.hasTOF()) + return false; + if (std::abs(ptrack.tofNSigmaPi()) > nsigmaTOFmax) + return false; + } + + if (ntrack.tpcInnerParam() > tpcCut) { + if (!ntrack.hasTOF()) + return false; + if (std::abs(ntrack.tofNSigmaPr()) > nsigmaTOFmax) + return false; + } + + // Invariant-Mass Selection + if (v0.mAntiLambda() < minMassLambda || v0.mAntiLambda() > maxMassLambda) + return false; + + return true; + } + + // Gamma Selections + template + bool passedGammaSelection(const T1& v0, const T2& ntrack, const T2& ptrack, + const C& collision) + { + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack, collision)) + return false; + if (!passedSingleTrackSelection(ntrack, collision)) + return false; + + if (ptrack.tpcInnerParam() > tpcCut) { + if (!ptrack.hasTOF()) + return false; + if (std::abs(ptrack.tofNSigmaEl()) > nsigmaTOFmax) + return false; + } + + if (ntrack.tpcInnerParam() > tpcCut) { + if (!ntrack.hasTOF()) + return false; + if (std::abs(ntrack.tofNSigmaEl()) > nsigmaTOFmax) + return false; + } + + // Invariant-Mass Selection + if (v0.mGamma() < minMassGamma || v0.mGamma() > maxMassGamma) + return false; + + return true; + } + + // Phi cut + template + bool passedPhiCut(const T& trk, float magField, const TF1& fphiCutLow, const TF1& fphiCutHigh) + { + float pt = trk.pt(); + float phi = trk.phi(); + int charge = trk.sign(); + float eta = trk.eta(); + auto nTPCCl = trk.tpcNClsFindable() - trk.tpcNClsFindableMinusFound(); + float sigP = trk.sign() * trk.tpcInnerParam(); + + if (pt < pTcut) + return true; + + if (magField < 0) // for negatve polarity field + phi = o2::constants::math::TwoPI - phi; + if (charge < 0) // for negatve charge + phi = o2::constants::math::TwoPI - phi; + + // to center gap in the middle + phi += o2::constants::math::PI / 18.0f; + phi = std::fmod(phi, o2::constants::math::PI / 9.0f); + + registryDeDx.fill(HIST("hpt_vs_phi_Ncl_Before"), pt, phi, nTPCCl); + + // cut phi + if (phi < fphiCutHigh.Eval(pt) && phi > fphiCutLow.Eval(pt)) + return false; // reject track + + if (eta > EtaCut[0] && eta < EtaCut[1]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[0]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[0]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[1] && eta < EtaCut[2]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[1]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[1]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[2] && eta < EtaCut[3]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[2]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[2]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[3] && eta < EtaCut[4]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[3]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[3]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[4] && eta < EtaCut[5]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[4]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[4]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[5] && eta < EtaCut[6]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[5]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[5]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[6] && eta < EtaCut[7]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[6]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[6]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[7] && eta < EtaCut[8]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegBefore[7]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosBefore[7]), nTPCCl, trk.tpcSignal(), sigP); + } + } + + // cut Ncl + if (nTPCCl < nclCut) + return false; + + registryDeDx.fill(HIST("hpt_vs_phi_Ncl_After"), pt, phi, nTPCCl); + + if (eta > EtaCut[0] && eta < EtaCut[1]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[0]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[0]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[1] && eta < EtaCut[2]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[1]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[1]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[2] && eta < EtaCut[3]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[2]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[2]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[3] && eta < EtaCut[4]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[3]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[3]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[4] && eta < EtaCut[5]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[4]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[4]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[5] && eta < EtaCut[6]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[5]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[5]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[6] && eta < EtaCut[7]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[6]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[6]), nTPCCl, trk.tpcSignal(), sigP); + } + } else if (eta > EtaCut[7] && eta < EtaCut[8]) { + if (sigP < 0) { + registryDeDx.fill(HIST(kNclDedxMomentumNegAfter[7]), nTPCCl, trk.tpcSignal(), std::abs(sigP)); + } else { + registryDeDx.fill(HIST(kNclDedxMomentumPosAfter[7]), nTPCCl, trk.tpcSignal(), sigP); + } + } + + return true; + } + + // Phi cut Secondaries + template + bool passedPhiCutSecondaries(const T& trk, float magField, const TF1& fphiCutLow, const TF1& fphiCutHigh) + { + float pt = trk.pt(); + float phi = trk.phi(); + int charge = trk.sign(); + auto nTPCCl = trk.tpcNClsFindable() - trk.tpcNClsFindableMinusFound(); + + if (pt < pTcut) + return true; + + if (magField < 0) // for negatve polarity field + phi = o2::constants::math::TwoPI - phi; + if (charge < 0) // for negatve charge + phi = o2::constants::math::TwoPI - phi; + + // to center gap in the middle + phi += o2::constants::math::PI / 18.0f; + phi = std::fmod(phi, o2::constants::math::PI / 9.0f); + + // cut phi + if (phi < fphiCutHigh.Eval(pt) && phi > fphiCutLow.Eval(pt)) + return false; // reject track + + // cut Ncl + if (nTPCCl < nclCut) + return false; + + return true; + } + + // Process Data + void process(SelectedCollisions::iterator const& collision, + aod::V0Datas const& fullV0s, PIDTracks const& tracks) + { + // Event Selection + if (!collision.sel8()) + return; + + if (additionalCuts) { + if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + return; + + if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) + return; + + if (std::abs(collision.posZ()) >= maxZDistanceToIP) + return; + + if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) + return; + } + + // Event Counter + registryDeDx.fill(HIST("histRecVtxZData"), collision.posZ()); + + // Kaons + for (const auto& trk : tracks) { + + // track Selection + if (!passedSingleTrackSelection(trk, collision)) + continue; + + if (!mySelectionPrim.IsSelected(trk)) + continue; + + // phi and Ncl cut + if (!passedPhiCut(trk, magField, *fphiCutLow, *fphiCutHigh)) + continue; + + float signedP = trk.sign() * trk.tpcInnerParam(); + + // MIP calibration for pions + if (trk.tpcInnerParam() >= pionMin && trk.tpcInnerParam() <= pionMax) { + if (calibrationMode) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_Neg_Pi"), trk.eta(), trk.tpcSignal()); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_Pos_Pi"), trk.eta(), trk.tpcSignal()); + } + + } else { + for (int i = 0; i < kEtaIntervals; ++i) { + if (trk.eta() > EtaCut[i] && trk.eta() < EtaCut[i + 1]) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_Neg_calibrated_Pi"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorNeg->at(i)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_Pos_calibrated_Pi"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorPos->at(i)); + } + } + } + } + } + // Beta from TOF + if (signedP < 0) { + registryDeDx.fill(HIST("hbeta_vs_p_Neg"), std::abs(signedP), trk.beta()); + } else { + registryDeDx.fill(HIST("hbeta_vs_p_Pos"), signedP, trk.beta()); + } + // Electrons from TOF + if (std::abs(trk.beta() - 1) < elTofCut) { // beta cut + if (calibrationMode) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Neg_El"), trk.eta(), trk.tpcSignal(), std::abs(signedP)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Pos_El"), trk.eta(), trk.tpcSignal(), signedP); + } + } else { + for (int i = 0; i < kEtaIntervals; ++i) { + if (trk.eta() > EtaCut[i] && trk.eta() < EtaCut[i + 1]) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Neg_calibrated_El"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorNeg->at(i), std::abs(signedP)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Pos_calibrated_El"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorPos->at(i), signedP); + } + } + } + } + } + // pions from TOF + if (trk.beta() > pionTofCut && trk.beta() < pionTofCut + 0.05) { // beta cut + if (calibrationMode) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Neg_TOF"), trk.eta(), trk.tpcSignal(), std::abs(signedP)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Pos_TOF"), trk.eta(), trk.tpcSignal(), signedP); + } + } else { + for (int i = 0; i < kEtaIntervals; ++i) { + if (trk.eta() > EtaCut[i] && trk.eta() < EtaCut[i + 1]) { + if (signedP < 0) { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Neg_calibrated_TOF"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorNeg->at(i), std::abs(signedP)); + } else { + registryDeDx.fill(HIST("hdEdx_vs_eta_vs_p_Pos_calibrated_TOF"), trk.eta(), trk.tpcSignal() * 50 / calibrationFactorPos->at(i), signedP); + } + } + } + } + } + + registryDeDx.fill(HIST("hdEdx_vs_phi"), trk.phi(), trk.tpcSignal()); + + if (!calibrationMode) { + for (int i = 0; i < kEtaIntervals; ++i) { + if (trk.eta() > EtaCut[i] && trk.eta() < EtaCut[i + 1]) { + if (signedP > 0) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[0]), signedP, trk.tpcSignal() * 50 / calibrationFactorPos->at(i), trk.eta()); + registryDeDx.fill(HIST("hp_vs_pt_all_Pos"), trk.pt(), signedP); + } else { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[0]), std::abs(signedP), trk.tpcSignal() * 50 / calibrationFactorNeg->at(i), trk.eta()); + registryDeDx.fill(HIST("hp_vs_pt_all_Neg"), trk.pt(), std::abs(signedP)); + } + } + } + } + } + + // Loop over Reconstructed V0s + if (!calibrationMode) { + for (const auto& v0 : fullV0s) { + + // Standard V0 Selections + if (!passedV0Selection(v0, collision)) { + continue; + } + + if (v0.dcaV0daughters() > dcaV0DaughtersMax) { + continue; + } + + // Positive and Negative Tracks + const auto& posTrack = v0.posTrack_as(); + const auto& negTrack = v0.negTrack_as(); + + if (!posTrack.passedTPCRefit()) + continue; + if (!negTrack.passedTPCRefit()) + continue; + // phi and Ncl cut + if (!passedPhiCutSecondaries(posTrack, magField, *fphiCutLow, *fphiCutHigh)) + continue; + + if (!passedPhiCutSecondaries(negTrack, magField, *fphiCutLow, *fphiCutHigh)) + continue; + + float signedPpos = posTrack.sign() * posTrack.tpcInnerParam(); + float signedPneg = negTrack.sign() * negTrack.tpcInnerParam(); + + float pxPos = posTrack.px(); + float pyPos = posTrack.py(); + float pzPos = posTrack.pz(); + + float pxNeg = negTrack.px(); + float pyNeg = negTrack.py(); + float pzNeg = negTrack.pz(); + + const float gammaMass = 2 * MassElectron; // GeV/c^2 + + // K0s Selection + if (passedK0Selection(v0, negTrack, posTrack, collision)) { + float ePosPi = posTrack.energy(MassPionCharged); + float eNegPi = negTrack.energy(MassPionCharged); + + float invMass = std::sqrt((eNegPi + ePosPi) * (eNegPi + ePosPi) - ((pxNeg + pxPos) * (pxNeg + pxPos) + (pyNeg + pyPos) * (pyNeg + pyPos) + (pzNeg + pzPos) * (pzNeg + pzPos))); + + if (std::abs(invMass - MassK0Short) > invMassCut) { + continue; + } + + for (int i = 0; i < kEtaIntervals; ++i) { + if (negTrack.eta() > EtaCut[i] && negTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[1]), std::abs(signedPneg), negTrack.tpcSignal() * 50 / calibrationFactorNeg->at(i), negTrack.eta()); + } + if (posTrack.eta() > EtaCut[i] && posTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[1]), signedPpos, posTrack.tpcSignal() * 50 / calibrationFactorPos->at(i), posTrack.eta()); + } + } + } + + // Lambda Selection + if (passedLambdaSelection(v0, negTrack, posTrack, collision)) { + + float ePosPr = posTrack.energy(MassProton); + float eNegPi = negTrack.energy(MassPionCharged); + + float invMass = std::sqrt((eNegPi + ePosPr) * (eNegPi + ePosPr) - ((pxNeg + pxPos) * (pxNeg + pxPos) + (pyNeg + pyPos) * (pyNeg + pyPos) + (pzNeg + pzPos) * (pzNeg + pzPos))); + + if (std::abs(invMass - MassLambda) > invMassCut) { + continue; + } + + for (int i = 0; i < kEtaIntervals; ++i) { + if (negTrack.eta() > EtaCut[i] && negTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[1]), std::abs(signedPneg), negTrack.tpcSignal() * 50 / calibrationFactorNeg->at(i), negTrack.eta()); + } + if (posTrack.eta() > EtaCut[i] && posTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[2]), signedPpos, posTrack.tpcSignal() * 50 / calibrationFactorPos->at(i), posTrack.eta()); + } + } + } + + // AntiLambda Selection + if (passedAntiLambdaSelection(v0, negTrack, posTrack, collision)) { + + float ePosPi = posTrack.energy(MassPionCharged); + float eNegPr = negTrack.energy(MassProton); + + float invMass = std::sqrt((eNegPr + ePosPi) * (eNegPr + ePosPi) - ((pxNeg + pxPos) * (pxNeg + pxPos) + (pyNeg + pyPos) * (pyNeg + pyPos) + (pzNeg + pzPos) * (pzNeg + pzPos))); + + if (std::abs(invMass - MassLambda) > invMassCut) { + continue; + } + + for (int i = 0; i < kEtaIntervals; ++i) { + if (negTrack.eta() > EtaCut[i] && negTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[2]), std::abs(signedPneg), negTrack.tpcSignal() * 50 / calibrationFactorNeg->at(i), negTrack.eta()); + } + if (posTrack.eta() > EtaCut[i] && posTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[1]), signedPpos, posTrack.tpcSignal() * 50 / calibrationFactorPos->at(i), posTrack.eta()); + } + } + } + + // Gamma Selection + if (passedGammaSelection(v0, negTrack, posTrack, collision)) { + + float ePosEl = posTrack.energy(MassElectron); + float eNegEl = negTrack.energy(MassElectron); + + float invMass = std::sqrt((eNegEl + ePosEl) * (eNegEl + ePosEl) - ((pxNeg + pxPos) * (pxNeg + pxPos) + (pyNeg + pyPos) * (pyNeg + pyPos) + (pzNeg + pzPos) * (pzNeg + pzPos))); + + if (std::abs(invMass - gammaMass) > invMassCutGamma) { + continue; + } + + for (int i = 0; i < kEtaIntervals; ++i) { + if (negTrack.eta() > EtaCut[i] && negTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumNeg[3]), std::abs(signedPneg), negTrack.tpcSignal() * 50 / calibrationFactorNeg->at(i), negTrack.eta()); + } + if (posTrack.eta() > EtaCut[i] && posTrack.eta() < EtaCut[i + 1]) { + registryDeDx.fill(HIST(kDedxvsMomentumPos[3]), signedPpos, posTrack.tpcSignal() * 50 / calibrationFactorPos->at(i), posTrack.eta()); + } + } + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/AQC/udQC.cxx b/PWGUD/AQC/udQC.cxx index b3bc5198a0f..3da67d1f683 100644 --- a/PWGUD/AQC/udQC.cxx +++ b/PWGUD/AQC/udQC.cxx @@ -14,6 +14,7 @@ /// \author Paul Buehler, paul.buehler@oeaw.ac.at /// \since 04.05.2023 +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -68,6 +69,8 @@ struct UDQC { using ATs = aod::AmbiguousTracks; using AFTs = aod::AmbiguousFwdTracks; + Partition goodTracks = requireGlobalTrackInFilter(); + void init(InitContext& context) { // initialize global variables @@ -191,8 +194,13 @@ struct UDQC { aod::Zdcs& zdcs, aod::Calos& calos, aod::V0s const& v0s, aod::Cascades const& cascades) { - LOGF(debug, " Start %i", abcrs.size()); + // LOGF(debug, " Start %i", abcrs.size()); + + if (!tracks.size()) + return; + if (collision.numContrib() < 1) + return; bool isDGcandidate = true; registry.get(HIST("collisions/Stat"))->Fill(0., isDGcandidate * 1.); @@ -214,7 +222,7 @@ struct UDQC { // vertex tracks normally gives PV contributors from collisions registry.get(HIST("collisions/vtxTracks"))->Fill(collision.numContrib()); // global tracks - Partition goodTracks = requireGlobalTrackInFilter(); + // Partition goodTracks = requireGlobalTrackInFilter(); goodTracks.bindTable(tracks); registry.get(HIST("collisions/globalTracks"))->Fill(goodTracks.size()); @@ -248,7 +256,7 @@ struct UDQC { if (track.tpcSignal() > maxdEdxTPC) { maxdEdxTPC = track.tpcSignal(); - LOGF(debug, " New maxdEdx TPC %f", maxdEdxTPC); + // LOGF(debug, " New maxdEdx TPC %f", maxdEdxTPC); } // TOF hit? @@ -256,7 +264,7 @@ struct UDQC { registry.get(HIST("tracks/dEdxTOF"))->Fill(track.p() / track.sign(), track.beta()); if (track.tofSignal() > maxdEdxTOF) { maxdEdxTOF = track.tofSignal(); - LOGF(debug, " New maxdEdx TOF %f", maxdEdxTOF); + // LOGF(debug, " New maxdEdx TOF %f", maxdEdxTOF); } // No vertex track with TOF hit? @@ -281,7 +289,7 @@ struct UDQC { if (collision.numContrib() > 0) { rgtrwTOF /= collision.numContrib(); } - LOGF(debug, " PV tracks with TOF: %f [1]", rgtrwTOF); + // LOGF(debug, " PV tracks with TOF: %f [1]", rgtrwTOF); registry.get(HIST("collisions/tResvsrTOFTracks"))->Fill(collision.collisionTimeRes(), rgtrwTOF); registry.get(HIST("collisions/tResvsTOFTrkNoPV"))->Fill(collision.collisionTimeRes(), norgtrwTOF); @@ -429,7 +437,7 @@ struct UDQC { } // define Lorentz vector to create invariant mass lvtmp.SetPtEtaPhiM(track.pt(), track.eta(), track.phi(), mass2Use); - LOGF(debug, "mass %f track pt %f/%f eta %f/%f", mass2Use, track.pt(), lvtmp.Perp(), track.eta(), lvtmp.Eta()); + // LOGF(debug, "mass %f track pt %f/%f eta %f/%f", mass2Use, track.pt(), lvtmp.Perp(), track.eta(), lvtmp.Eta()); if (track.pt() <= diffCuts.minPt() || track.pt() >= diffCuts.maxPt()) { goodpts = false; } @@ -521,7 +529,7 @@ struct UDQC { registry.get(HIST("DG/etaminus"))->Fill(track.eta(), track.phi()); } - LOGF(debug, "dEdx TPC %f TOF %i %f", track.tpcSignal(), track.hasTOF(), track.hasTOF() ? track.tofSignal() : 0.); + // LOGF(debug, "dEdx TPC %f TOF %i %f", track.tpcSignal(), track.hasTOF(), track.hasTOF() ? track.tofSignal() : 0.); if (collision.numContrib() == 2) { registry.get(HIST("DG/dEdxTPC"))->Fill(track.tpcInnerParam() / track.sign(), track.tpcSignal()); registry.get(HIST("DG/trkDCAxy"))->Fill(track.dcaXY()); @@ -562,7 +570,7 @@ struct UDQC { void processCleanFIT1(CC const& collision, BCs const& bct0s, aod::FT0s const& /*ft0s*/, aod::FV0As const& /*fv0as*/, aod::FDDs const& /*fdds*/) { - LOGF(debug, "(); @@ -677,7 +685,7 @@ struct UDQC { // ............................................................................................................... void processFV0(aod::FV0As const& fv0s, BCs const&) { - LOGF(info, " %d", fv0s.size()); + // LOGF(info, " %d", fv0s.size()); if (fv0s.size() <= 0) { return; } @@ -695,7 +703,7 @@ struct UDQC { // ............................................................................................................... void processFT0(aod::FT0s const& ft0s, aod::FT0sCorrected const& ft0scorr, BCs const&) { - LOGF(debug, " %d", ft0s.size()); + // LOGF(debug, " %d", ft0s.size()); for (auto const& collision : ft0scorr) { if (collision.t0ACorrectedValid()) { @@ -729,7 +737,7 @@ struct UDQC { // ............................................................................................................... void processFDD(aod::FDDs const& fdds, BCs const&) { - LOGF(debug, " %d", fdds.size()); + // LOGF(debug, " %d", fdds.size()); for (auto fdd : fdds) { @@ -751,7 +759,7 @@ struct UDQC { // ............................................................................................................... void processZDC(aod::Zdc const& zdc) { - LOGF(debug, " %d", zdc.size()); + // LOGF(debug, " %d", zdc.size()); // Zdc energies registry.get(HIST("ZdcEnergies"))->Fill(0., zdc.energyZEM1()); diff --git a/PWGUD/AQC/udQCmidRap.cxx b/PWGUD/AQC/udQCmidRap.cxx index e7178cfa042..acb35f21f57 100644 --- a/PWGUD/AQC/udQCmidRap.cxx +++ b/PWGUD/AQC/udQCmidRap.cxx @@ -64,6 +64,8 @@ struct UDQCmid { using ATs = aod::AmbiguousTracks; using AFTs = aod::AmbiguousFwdTracks; + Partition goodTracks = requireGlobalTrackInFilter(); + void init(InitContext& context) { // initialize global variables @@ -132,7 +134,7 @@ struct UDQCmid { } } - // ............................................................................................................................................... + //............................................................................................................................................... void processMain(CC const& collision, BCs const& bct0s, TCs const& tracks, FWs const& fwdtracks, ATs const& /*ambtracks*/, AFTs const& /*ambfwdtracks*/, aod::FT0s const& /*ft0s*/, aod::FV0As const& /*fv0as*/, aod::FDDs const& /*fdds*/, @@ -150,7 +152,7 @@ struct UDQCmid { // vertex tracks normally gives PV contributors from collisions registry.get(HIST("collisions/vtxTracks"))->Fill(collision.numContrib()); // global tracks - Partition goodTracks = requireGlobalTrackInFilter(); + goodTracks.bindTable(tracks); registry.get(HIST("collisions/globalTracks"))->Fill(goodTracks.size()); @@ -223,7 +225,7 @@ struct UDQCmid { registry.get(HIST("DG/hMassAll"))->Fill(ivm.M()); } } // coll - } // dgcand + } // dgcand // loop over all tracks float rgtrwTOF = 0.; @@ -322,7 +324,7 @@ struct UDQCmid { if (track.hasTOF()) { registry.get(HIST("DG/dEdxTOF"))->Fill(track.p() / track.sign(), track.beta()); } // fill TOF - } // pv contributor + } // pv contributor } } // Inavariant mass after FIT @@ -489,7 +491,7 @@ struct UDQCmid { // update #PV contributors in collisions with empty FT0 && FV0&& FDCC registry.get(HIST("fpPVC2"))->Fill(collision.numContrib(), 1.); } // fdd - } // fvo + } // fvo } // ft0 } diff --git a/PWGUD/Core/CMakeLists.txt b/PWGUD/Core/CMakeLists.txt index d5ef6f9a085..7686edd8eea 100644 --- a/PWGUD/Core/CMakeLists.txt +++ b/PWGUD/Core/CMakeLists.txt @@ -56,3 +56,11 @@ o2physics_add_library(UPCCutparHolder o2physics_target_root_dictionary(UPCCutparHolder HEADERS UPCCutparHolder.h LINKDEF UPCCutparHolderLinkDef.h) + +o2physics_add_library(decayTree + SOURCES decayTree.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore ROOT::EG RapidJSON::RapidJSON) + +o2physics_target_root_dictionary(decayTree + HEADERS decayTree.h + LINKDEF decayTreeLinkDef.h) diff --git a/PWGUD/Core/SGSelector.h b/PWGUD/Core/SGSelector.h index 4845818f244..b9fc3ecf2e7 100644 --- a/PWGUD/Core/SGSelector.h +++ b/PWGUD/Core/SGSelector.h @@ -8,17 +8,26 @@ // 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. +// +/// \file SGSelector.h +/// \author Alexander Bylinkin +/// \author Adam Matyja +/// \since 2023-11-21 +/// \brief Support class holding tools to work with Single Gap selection in central barrel UPCs +/// #ifndef PWGUD_CORE_SGSELECTOR_H_ #define PWGUD_CORE_SGSELECTOR_H_ -#include -#include "TDatabasePDG.h" -#include "TLorentzVector.h" -#include "Framework/Logger.h" -#include "Framework/AnalysisTask.h" -#include "PWGUD/Core/UDHelpers.h" #include "PWGUD/Core/SGCutParHolder.h" +#include "PWGUD/Core/UDHelpers.h" + +#include "Common/CCDB/RCTSelectionFlags.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/Logger.h" + +#include template struct SelectionResult { @@ -26,10 +35,20 @@ struct SelectionResult { BC* bc; // Pointer to the BC object }; +namespace o2::aod::sgselector +{ +enum TrueGap : int { + NoGap = -1, + SingleGapA = 0, + SingleGapC = 1, + DoubleGap = 2 +}; +} + class SGSelector { public: - SGSelector() : fPDG(TDatabasePDG::Instance()) {} + SGSelector() : myRCTChecker{"CBT"}, myRCTCheckerHadron{"CBT_hadronPID"}, myRCTCheckerZDC{"CBT", true}, myRCTCheckerHadronZDC{"CBT_hadronPID", true} {} template int Print(SGCutParHolder /*diffCuts*/, CC& collision, BCs& /*bcRange*/, TCs& /*tracks*/, FWs& /*fwdtracks*/) @@ -107,7 +126,8 @@ class SGSelector template int FwdTrkSelector(TFwdTrack const& fwdtrack) { - if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3) + // if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3) + if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack || fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) return 1; else return 0; @@ -125,29 +145,68 @@ class SGSelector FT0C = collision.totalFT0AmplitudeC(); ZNA = collision.energyCommonZNA(); ZNC = collision.energyCommonZNC(); - if (gap == 0) { + if (gap == o2::aod::sgselector::SingleGapA) { // gap == 0 if (FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut) - true_gap = -1; - } else if (gap == 1) { + true_gap = o2::aod::sgselector::NoGap; // -1 + } else if (gap == o2::aod::sgselector::SingleGapC) { // gap == 1 if (FT0C > fit_cut[2] || ZNC > zdc_cut) - true_gap = -1; - } else if (gap == 2) { + true_gap = o2::aod::sgselector::NoGap; // -1 + } else if (gap == o2::aod::sgselector::DoubleGap) { // gap == 2 if ((FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut) && (FT0C > fit_cut[2] || ZNC > zdc_cut)) - true_gap = -1; + true_gap = o2::aod::sgselector::NoGap; // -1 else if ((FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut) && (FT0C <= fit_cut[2] && ZNC <= zdc_cut)) - true_gap = 1; + true_gap = o2::aod::sgselector::SingleGapC; // 1 else if ((FV0A <= fit_cut[0] && FT0A <= fit_cut[1] && ZNA <= zdc_cut) && (FT0C > fit_cut[2] || ZNC > zdc_cut)) - true_gap = 0; + true_gap = o2::aod::sgselector::SingleGapA; // 0 else if (FV0A <= fit_cut[0] && FT0A <= fit_cut[1] && ZNA <= zdc_cut && FT0C <= fit_cut[2] && ZNC <= zdc_cut) - true_gap = 2; + true_gap = o2::aod::sgselector::DoubleGap; // 2 else - std::cout << "Something wrong with DG" << std::endl; + LOGF(info, "Something wrong with DG"); } return true_gap; } + // check CBT flags + template + bool isCBTOk(CC& collision) + { + if (myRCTChecker(collision)) + return true; + return false; + } + + // check CBT+hadronPID flags + template + bool isCBTHadronOk(CC& collision) + { + if (myRCTCheckerHadron(collision)) + return true; + return false; + } + + // check CBT+ZDC flags + template + bool isCBTZdcOk(CC& collision) + { + if (myRCTCheckerZDC(collision)) + return true; + return false; + } + + // check CBT+hadronPID+ZDC flags + template + bool isCBTHadronZdcOk(CC& collision) + { + if (myRCTCheckerHadronZDC(collision)) + return true; + return false; + } + private: - TDatabasePDG* fPDG; + o2::aod::rctsel::RCTFlagsChecker myRCTChecker; + o2::aod::rctsel::RCTFlagsChecker myRCTCheckerHadron; + o2::aod::rctsel::RCTFlagsChecker myRCTCheckerZDC; + o2::aod::rctsel::RCTFlagsChecker myRCTCheckerHadronZDC; }; #endif // PWGUD_CORE_SGSELECTOR_H_ diff --git a/PWGUD/Core/SGTrackSelector.h b/PWGUD/Core/SGTrackSelector.h index 1b68ab0ddba..4288ef89e80 100644 --- a/PWGUD/Core/SGTrackSelector.h +++ b/PWGUD/Core/SGTrackSelector.h @@ -21,7 +21,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include diff --git a/PWGUD/Core/UDHelpers.h b/PWGUD/Core/UDHelpers.h index 6c77b28f007..4b692f7c5c1 100644 --- a/PWGUD/Core/UDHelpers.h +++ b/PWGUD/Core/UDHelpers.h @@ -18,6 +18,7 @@ #include #include + #include "TLorentzVector.h" #include "Framework/Logger.h" #include "DataFormatsFT0/Digit.h" @@ -42,7 +43,7 @@ template ::type* = nullptr, typenam int8_t netCharge(TCs tracks) { int8_t nch = 0; - for (auto track : tracks) { + for (const auto& track : tracks) { if (track.isPVContributor()) { nch += track.sign(); } @@ -55,7 +56,7 @@ template ::type* = nullptr, typena int8_t netCharge(TCs tracks) { int8_t nch = 0; - for (auto track : tracks) { + for (const auto& track : tracks) { nch += track.sign(); } return nch; @@ -67,7 +68,7 @@ template ::type* = nullptr, typenam float rPVtrwTOF(TCs tracks, int nPVTracks) { float rpvrwTOF = 0.; - for (auto& track : tracks) { + for (const auto& track : tracks) { if (track.isPVContributor() && track.hasTOF()) { rpvrwTOF += 1.; } @@ -83,7 +84,7 @@ template ::type* = nullptr, typena float rPVtrwTOF(TCs tracks, int nPVTracks) { float rpvrwTOF = 0.; - for (auto& track : tracks) { + for (const auto& track : tracks) { if (track.hasTOF()) { rpvrwTOF += 1.; } @@ -115,14 +116,14 @@ T compatibleBCs(B const& bc, uint64_t const& meanBC, int const& deltaBC, T const auto bcIter = bcs.iteratorAt(bc.globalIndex()); // range of BCs to consider - uint64_t minBC = (uint64_t)deltaBC < meanBC ? meanBC - (uint64_t)deltaBC : 0; - uint64_t maxBC = meanBC + (uint64_t)deltaBC; + uint64_t minBC = static_cast(deltaBC) < meanBC ? meanBC - static_cast(deltaBC) : 0; + uint64_t maxBC = meanBC + static_cast(deltaBC); LOGF(debug, " minBC %d maxBC %d bcIterator %d (%d) #BCs %d", minBC, maxBC, bcIter.globalBC(), bcIter.globalIndex(), bcs.size()); // check [min,max]BC to overlap with [bcs.iteratorAt([0,bcs.size() - 1]) if (maxBC < bcs.iteratorAt(0).globalBC() || minBC > bcs.iteratorAt(bcs.size() - 1).globalBC()) { - LOGF(info, " No overlap of [%d, %d] and [%d, %d]", minBC, maxBC, bcs.iteratorAt(0).globalBC(), bcs.iteratorAt(bcs.size() - 1).globalBC()); - return T{{bcs.asArrowTable()->Slice(0, 0)}, (uint64_t)0}; + LOGF(debug, " No overlap of [%d, %d] and [%d, %d]", minBC, maxBC, bcs.iteratorAt(0).globalBC(), bcs.iteratorAt(bcs.size() - 1).globalBC()); + return T{{bcs.asArrowTable()->Slice(0, 0)}, static_cast(0)}; } // find slice of BCs table with BC in [minBC, maxBC] @@ -156,7 +157,7 @@ T compatibleBCs(B const& bc, uint64_t const& meanBC, int const& deltaBC, T const } // create bc slice - T bcslice{{bcs.asArrowTable()->Slice(minBCId, maxBCId - minBCId + 1)}, (uint64_t)minBCId}; + T bcslice{{bcs.asArrowTable()->Slice(minBCId, maxBCId - minBCId + 1)}, static_cast(minBCId)}; bcs.copyIndexBindings(bcslice); LOGF(debug, " size of slice %d", bcslice.size()); return bcslice; @@ -171,7 +172,7 @@ T compatibleBCs(C const& collision, int ndt, T const& bcs, int nMinBCs = 7) // return if collisions has no associated BC if (!collision.has_foundBC() || ndt < 0) { - return T{{bcs.asArrowTable()->Slice(0, 0)}, (uint64_t)0}; + return T{{bcs.asArrowTable()->Slice(0, 0)}, static_cast(0)}; } // get associated BC @@ -196,7 +197,7 @@ template T compatibleBCs(uint64_t const& meanBC, int const& deltaBC, T const& bcs) { // find BC with globalBC ~ meanBC - uint64_t ind = (uint64_t)(bcs.size() / 2); + uint64_t ind = static_cast(bcs.size() / 2); auto bcIter = bcs.iteratorAt(ind); return compatibleBCs(bcIter, meanBC, deltaBC, bcs); @@ -212,7 +213,7 @@ T MCcompatibleBCs(F const& collision, int const& ndt, T const& bcs, int const& n // return if collisions has no associated BC if (!collision.has_foundBC()) { LOGF(debug, "Collision %i - no BC found!", collision.globalIndex()); - return T{{bcs.asArrowTable()->Slice(0, 0)}, (uint64_t)0}; + return T{{bcs.asArrowTable()->Slice(0, 0)}, static_cast(0)}; } // get associated BC @@ -245,19 +246,19 @@ bool hasGoodPID(DGCutparHolder diffCuts, TC track) track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()); - if (TMath::Abs(track.tpcNSigmaEl()) < diffCuts.maxNSigmaTPC()) { + if (std::abs(track.tpcNSigmaEl()) < diffCuts.maxNSigmaTPC()) { return true; } - if (TMath::Abs(track.tpcNSigmaMu()) < diffCuts.maxNSigmaTPC()) { + if (std::abs(track.tpcNSigmaMu()) < diffCuts.maxNSigmaTPC()) { return true; } - if (TMath::Abs(track.tpcNSigmaPi()) < diffCuts.maxNSigmaTPC()) { + if (std::abs(track.tpcNSigmaPi()) < diffCuts.maxNSigmaTPC()) { return true; } - if (TMath::Abs(track.tpcNSigmaKa()) < diffCuts.maxNSigmaTPC()) { + if (std::abs(track.tpcNSigmaKa()) < diffCuts.maxNSigmaTPC()) { return true; } - if (TMath::Abs(track.tpcNSigmaPr()) < diffCuts.maxNSigmaTPC()) { + if (std::abs(track.tpcNSigmaPr()) < diffCuts.maxNSigmaTPC()) { return true; } @@ -268,19 +269,19 @@ bool hasGoodPID(DGCutparHolder diffCuts, TC track) track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()); - if (TMath::Abs(track.tofNSigmaEl()) < diffCuts.maxNSigmaTOF()) { + if (std::abs(track.tofNSigmaEl()) < diffCuts.maxNSigmaTOF()) { return true; } - if (TMath::Abs(track.tofNSigmaMu()) < diffCuts.maxNSigmaTOF()) { + if (std::abs(track.tofNSigmaMu()) < diffCuts.maxNSigmaTOF()) { return true; } - if (TMath::Abs(track.tofNSigmaPi()) < diffCuts.maxNSigmaTOF()) { + if (std::abs(track.tofNSigmaPi()) < diffCuts.maxNSigmaTOF()) { return true; } - if (TMath::Abs(track.tofNSigmaKa()) < diffCuts.maxNSigmaTOF()) { + if (std::abs(track.tofNSigmaKa()) < diffCuts.maxNSigmaTOF()) { return true; } - if (TMath::Abs(track.tofNSigmaPr()) < diffCuts.maxNSigmaTOF()) { + if (std::abs(track.tofNSigmaPr()) < diffCuts.maxNSigmaTOF()) { return true; } } @@ -741,14 +742,14 @@ int64_t sameMCCollision(T tracks, aod::McCollisions, aod::McParticles) colID = mccol.globalIndex(); } else { if (colID != mccol.globalIndex()) { - return (int64_t)-1; + return static_cast(-1); } } } else { - return (int64_t)-1; + return static_cast(-1); } } else { - return (int64_t)-1; + return static_cast(-1); } } @@ -761,7 +762,7 @@ int64_t sameMCCollision(T tracks, aod::McCollisions, aod::McParticles) template bool isPythiaCDE(T MCparts) { - for (auto mcpart : MCparts) { + for (const auto& mcpart : MCparts) { if (mcpart.pdgCode() == 9900110) { return true; } @@ -780,7 +781,7 @@ bool isSTARLightJPsimumu(T MCparts) } else { if (MCparts.iteratorAt(0).pdgCode() != 443013) return false; - if (abs(MCparts.iteratorAt(1).pdgCode()) != 13) + if (std::abs(MCparts.iteratorAt(1).pdgCode()) != 13) return false; if (MCparts.iteratorAt(2).pdgCode() != -MCparts.iteratorAt(1).pdgCode()) return false; @@ -788,35 +789,48 @@ bool isSTARLightJPsimumu(T MCparts) return true; } +// ----------------------------------------------------------------------------- +// PbPb di electron production +// [15, 11, 13], [15, 11, 13] +template +bool isUpcgen(T MCparts) +{ + if (MCparts.size() < 4) { + return false; + } else { + auto pid1 = std::abs(MCparts.iteratorAt(0).pdgCode()); + auto pid2 = std::abs(MCparts.iteratorAt(1).pdgCode()); + if (pid1 != 11 && pid1 != 13 && pid1 != 15) + return false; + if (pid2 != 11 && pid2 != 13 && pid2 != 15) + return false; + } + return true; +} + // ----------------------------------------------------------------------------- // In pp events produced with GRANIITTI the stack starts with -// 22212/22212/99/22212/2212/99/90 +// 22212/22212/22212/2212/[211,321,]/[211,321,] template bool isGraniittiCDE(T MCparts) { - for (auto MCpart : MCparts) { - LOGF(debug, " MCpart.pdgCode() %d", MCpart.pdgCode()); - } - LOGF(debug, ""); + // for (auto MCpart : MCparts) { + // LOGF(info, " MCpart.pdgCode() %d", MCpart.pdgCode()); + // } + // LOGF(debug, ""); - if (MCparts.size() < 7) { + if (MCparts.size() < 6) { return false; } else { if (MCparts.iteratorAt(0).pdgCode() != 2212) return false; if (MCparts.iteratorAt(1).pdgCode() != 2212) return false; - if (MCparts.iteratorAt(2).pdgCode() != 99) + if (MCparts.iteratorAt(2).pdgCode() != 2212) return false; if (MCparts.iteratorAt(3).pdgCode() != 2212) return false; - if (MCparts.iteratorAt(4).pdgCode() != 2212) - return false; - if (MCparts.iteratorAt(5).pdgCode() != 99) - return false; - if (MCparts.iteratorAt(6).pdgCode() != 90) - return false; } return true; @@ -843,6 +857,11 @@ int isOfInterest(T MCparts) return 3; } + // Upcgen + if (isUpcgen(MCparts)) { + return 4; + } + return 0; } diff --git a/PWGUD/Core/UPCJpsiCentralBarrelCorrHelper.h b/PWGUD/Core/UPCJpsiCentralBarrelCorrHelper.h index 0857d6bab1d..955601495e6 100644 --- a/PWGUD/Core/UPCJpsiCentralBarrelCorrHelper.h +++ b/PWGUD/Core/UPCJpsiCentralBarrelCorrHelper.h @@ -19,7 +19,7 @@ #include #include #include "CommonConstants/MathConstants.h" -#include "random" +#include using namespace o2; using namespace o2::framework; diff --git a/PWGUD/Core/UPCPairCuts.h b/PWGUD/Core/UPCPairCuts.h new file mode 100644 index 00000000000..6b0e37adca0 --- /dev/null +++ b/PWGUD/Core/UPCPairCuts.h @@ -0,0 +1,346 @@ +// 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. + +/// \brief Functions which cut on particle pairs (decays, conversions, two-track cuts) adapted for data from UD tables +/// Based on the code "PWGCF/Core/PairCuts.h" made by Jan Fiete Grosse-Oetringhaus +/// Author: + +#ifndef PWGUD_CORE_UPCPAIRCUTS_H_ +#define PWGUD_CORE_UPCPAIRCUTS_H_ + +#include + +#include "Framework/Logger.h" +#include "Framework/HistogramRegistry.h" +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" + +#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" + +using namespace o2; +using namespace o2::framework; +using namespace constants::math; + +class UPCPairCuts +{ + public: + enum Particle { Photon = 0, + K0, + Lambda, + Phi, + Rho, + ParticlesLastEntry }; + + void setHistogramRegistry(HistogramRegistry* registry) { histogramRegistry = registry; } + + void setPairCut(Particle particle, float cut) + { + LOGF(info, "Enabled pair cut for %d with value %f", static_cast(particle), cut); + mCuts[particle] = cut; + if (histogramRegistry != nullptr && histogramRegistry->contains(HIST("ControlConvResonances")) == false) { + histogramRegistry->add("ControlConvResonances", "", {HistType::kTH2F, {{6, -0.5, 5.5, "id"}, {500, -0.5, 0.5, "delta mass"}}}); + } + } + + void setTwoTrackCuts(float distance = 0.02f, float radius = 0.8f) + { + LOGF(info, "Enabled two-track cut with distance %f and radius %f", distance, radius); + mTwoTrackDistance = distance; + mTwoTrackRadius = radius; + + if (histogramRegistry != nullptr && histogramRegistry->contains(HIST("TwoTrackDistancePt_0")) == false) { + histogramRegistry->add("TwoTrackDistancePt_0", "", {HistType::kTH3F, {{100, -0.15, 0.15, "#Delta#eta"}, {100, -0.05, 0.05, "#Delta#varphi^{*}_{min}"}, {20, 0, 10, "#Delta p_{T}"}}}); + histogramRegistry->addClone("TwoTrackDistancePt_0", "TwoTrackDistancePt_1"); + } + } + + template + bool conversionCuts(T const& track1, T const& track2); + + template + bool twoTrackCut(T const& track1, T const& track2); + + protected: + float mCuts[ParticlesLastEntry] = {-1}; + float mTwoTrackDistance = -1; // distance below which the pair is flagged as to be removed + float mTwoTrackRadius = 0.8f; // radius at which the two track cuts are applied + int magField = 5; // magField: B field in kG + + HistogramRegistry* histogramRegistry = nullptr; // if set, control histograms are stored here + + template + bool conversionCut(T const& track1, T const& track2, Particle conv, double cut); + + template + double getInvMassSquared(T const& track1, double m0_1, T const& track2, double m0_2); + + template + double getInvMassSquaredFast(T const& track1, double m0_1, T const& track2, double m0_2); + + template + float getDPhiStar(T const& track1, T const& track2, float radius, int magField); +}; + +template +bool UPCPairCuts::conversionCuts(T const& track1, T const& track2) +{ + // skip if like sign + if (track1.sign() * track2.sign() > 0) { + return false; + } + + for (int i = 0; i < static_cast(ParticlesLastEntry); i++) { + Particle particle = static_cast(i); + if (mCuts[i] > 0) { + if (conversionCut(track1, track2, particle, mCuts[i])) { + return true; + } + if (particle == Lambda) { + if (conversionCut(track2, track1, particle, mCuts[i])) { + return true; + } + } + } + } + + return false; +} + +template +bool UPCPairCuts::twoTrackCut(T const& track1, T const& track2) +{ + // the variables & cut have been developed in Run 1 by the CF - HBT group + // + // Parameters: + // magField: B field in kG + + auto deta = eta(track1.px(), track1.py(), track1.pz()) - eta(track2.px(), track2.py(), track2.pz()); + + // optimization + if (std::fabs(deta) < mTwoTrackDistance * 2.5 * 3) { + // check first boundaries to see if is worth to loop and find the minimum + float dphistar1 = getDPhiStar(track1, track2, mTwoTrackRadius, magField); + float dphistar2 = getDPhiStar(track1, track2, 2.5, magField); + + const float kLimit = mTwoTrackDistance * 3; + + if (std::fabs(dphistar1) < kLimit || std::fabs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0) { + float dphistarminabs = 1e5; + float dphistarmin = 1e5; + for (Double_t rad = mTwoTrackRadius; rad < 2.51; rad += 0.01) { + float dphistar = getDPhiStar(track1, track2, rad, magField); + + float dphistarabs = std::fabs(dphistar); + + if (dphistarabs < dphistarminabs) { + dphistarmin = dphistar; + dphistarminabs = dphistarabs; + } + } + + if (histogramRegistry != nullptr) { + histogramRegistry->fill(HIST("TwoTrackDistancePt_0"), deta, dphistarmin, std::fabs(track1.pt() - track2.pt())); + } + + if (dphistarminabs < mTwoTrackDistance && std::fabs(deta) < mTwoTrackDistance) { + // LOGF(debug, "Removed track pair %ld %ld with %f %f %f %f %d %f %f %d %d", track1.index(), track2.index(), deta, dphistarminabs, track1.phi2(), track1.pt(), track1.sign(), track2.phi2(), track2.pt(), track2.sign(), magField); + return true; + } + + if (histogramRegistry != nullptr) { + histogramRegistry->fill(HIST("TwoTrackDistancePt_1"), deta, dphistarmin, std::fabs(track1.pt() - track2.pt())); + } + } + } + + return false; +} + +template +bool UPCPairCuts::conversionCut(T const& track1, T const& track2, Particle conv, double cut) +{ + // LOGF(info, "pt is %f %f", track1.pt(), track2.pt()); + + if (cut < 0) { + return false; + } + + double massD1, massD2, massM; + + switch (conv) { + case Photon: + massD1 = o2::constants::physics::MassElectron; + massD2 = o2::constants::physics::MassElectron; + massM = 0; + break; + case K0: + massD1 = o2::constants::physics::MassPiPlus; + massD2 = o2::constants::physics::MassPiPlus; + massM = o2::constants::physics::MassK0; + break; + case Lambda: + massD1 = o2::constants::physics::MassProton; + massD2 = o2::constants::physics::MassPiPlus; + massM = o2::constants::physics::MassLambda0; + break; + case Phi: + massD1 = o2::constants::physics::MassKPlus; + massD2 = o2::constants::physics::MassKPlus; + massM = o2::constants::physics::MassPhi; + break; + case Rho: + massD1 = o2::constants::physics::MassPiPlus; + massD2 = o2::constants::physics::MassPiPlus; + massM = 0.770; + break; + default: + LOGF(fatal, "Particle now known"); + return false; + break; + } + + auto massC = getInvMassSquaredFast(track1, massD1, track2, massD2); + + if (std::fabs(massC - massM * massM) > cut * 5) { + return false; + } + + massC = getInvMassSquared(track1, massD1, track2, massD2); + + if (histogramRegistry != nullptr) { + histogramRegistry->fill(HIST("ControlConvResonances"), static_cast(conv), massC - massM * massM); + } + + if (massC > (massM - cut) * (massM - cut) && massC < (massM + cut) * (massM + cut)) { + return true; + } + + return false; +} + +template +double UPCPairCuts::getInvMassSquared(T const& track1, double m0_1, T const& track2, double m0_2) +{ + // calculate inv mass squared + // same can be achieved, but with more computing time with + /*TLorentzVector photon, p1, p2; + p1.SetPtEtaPhiM(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), 0.510e-3); + p2.SetPtEtaPhiM(particle->Pt(), eta[j], particle->Phi(), 0.510e-3); + photon = p1+p2; + photon.M()*/ + + float tantheta1 = 1e10; + + if (eta(track1.px(), track1.py(), track1.pz()) < -1e-10 || eta(track1.px(), track1.py(), track1.pz()) > 1e-10) { + float expTmp = std::exp(-eta(track1.px(), track1.py(), track1.pz())); + tantheta1 = 2.0 * expTmp / (1.0 - expTmp * expTmp); + } + + float tantheta2 = 1e10; + if (eta(track2.px(), track2.py(), track2.pz()) < -1e-10 || eta(track2.px(), track2.py(), track2.pz()) > 1e-10) { + float expTmp = std::exp(-eta(track2.px(), track2.py(), track2.pz())); + tantheta2 = 2.0 * expTmp / (1.0 - expTmp * expTmp); + } + + float e1squ = m0_1 * m0_1 + track1.pt() * track1.pt() * (1.0 + 1.0 / tantheta1 / tantheta1); + float e2squ = m0_2 * m0_2 + track2.pt() * track2.pt() * (1.0 + 1.0 / tantheta2 / tantheta2); + + float mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * (std::sqrt(e1squ * e2squ) - (track1.pt() * track2.pt() * (std::cos(phi(track1.px(), track1.py()) - phi(track2.px(), track2.py())) + 1.0 / tantheta1 / tantheta2))); + + // LOGF(debug, "%f %f %f %f %f %f %f %f %f", pt1, eta1, phi1, pt2, eta2, phi2, m0_1, m0_2, mass2); + + return mass2; +} + +template +double UPCPairCuts::getInvMassSquaredFast(T const& track1, double m0_1, T const& track2, double m0_2) +{ + // calculate inv mass squared approximately + + const float eta1 = eta(track1.px(), track1.py(), track1.pz()); + const float eta2 = eta(track2.px(), track2.py(), track2.pz()); + const float phi1 = phi(track1.px(), track1.py()); + const float phi2 = phi(track2.px(), track2.py()); + const float pt1 = track1.pt(); + const float pt2 = track2.pt(); + + float tantheta1 = 1e10f; + + if (eta1 < -1e-10f || eta1 > 1e-10f) { + float expTmp = 1.0f - eta1 + eta1 * eta1 / 2.0f - eta1 * eta1 * eta1 / 6.0f + eta1 * eta1 * eta1 * eta1 / 24.0f; + tantheta1 = 2.0f * expTmp / (1.0f - expTmp * expTmp); + } + + float tantheta2 = 1e10f; + if (eta2 < -1e-10f || eta2 > 1e-10f) { + float expTmp = 1.0f - eta2 + eta2 * eta2 / 2.0f - eta2 * eta2 * eta2 / 6.0f + eta2 * eta2 * eta2 * eta2 / 24.0f; + tantheta2 = 2.0f * expTmp / (1.0f - expTmp * expTmp); + } + + float e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0f + 1.0f / tantheta1 / tantheta1); + float e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0f + 1.0f / tantheta2 / tantheta2); + + // fold onto 0...pi + float deltaPhi = std::fabs(phi1 - phi2); + while (deltaPhi > TwoPI) { + deltaPhi -= TwoPI; + } + if (deltaPhi > PI) { + deltaPhi = TwoPI - deltaPhi; + } + + float cosDeltaPhi = 0; + if (deltaPhi < PI / 3.0f) { + cosDeltaPhi = 1.0 - deltaPhi * deltaPhi / 2 + deltaPhi * deltaPhi * deltaPhi * deltaPhi / 24; + } else if (deltaPhi < 2.0f * PI / 3.0f) { + cosDeltaPhi = -(deltaPhi - PI / 2) + 1.0 / 6 * std::pow((deltaPhi - PI / 2), 3); + } else { + cosDeltaPhi = -1.0f + 1.0f / 2.0f * (deltaPhi - PI) * (deltaPhi - PI) - 1.0f / 24.0f * std::pow(deltaPhi - PI, 4.0f); + } + + double mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2.0f * (std::sqrt(e1squ * e2squ) - (pt1 * pt2 * (cosDeltaPhi + 1.0f / tantheta1 / tantheta2))); + + // LOGF(debug, "%f %f %f %f %f %f %f %f %f", pt1, eta1, phi1, pt2, eta2, phi2, m0_1, m0_2, mass2); + + return mass2; +} + +template +float UPCPairCuts::getDPhiStar(T const& track1, T const& track2, float radius, int magField) +{ + // + // calculates dphistar + // + + auto phi1 = phi(track1.px(), track1.py()); + auto pt1 = track1.pt(); + auto charge1 = track1.sign(); + + auto phi2 = phi(track2.px(), track2.py()); + auto pt2 = track2.pt(); + auto charge2 = track2.sign(); + + float dphistar = phi1 - phi2 - charge1 * std::asin(0.015 * magField * radius / pt1) + charge2 * std::asin(0.015 * magField * radius / pt2); + + if (dphistar > PI) { + dphistar = TwoPI - dphistar; + } + if (dphistar < -PI) { + dphistar = -TwoPI - dphistar; + } + if (dphistar > PI) { // might look funny but is needed + dphistar = TwoPI - dphistar; + } + + return dphistar; +} + +#endif // PWGUD_CORE_UPCPAIRCUTS_H_ diff --git a/PWGUD/Core/UPCTauCentralBarrelHelperRL.h b/PWGUD/Core/UPCTauCentralBarrelHelperRL.h index 55a13a0e9c5..41af7ec5d78 100644 --- a/PWGUD/Core/UPCTauCentralBarrelHelperRL.h +++ b/PWGUD/Core/UPCTauCentralBarrelHelperRL.h @@ -8,16 +8,22 @@ // 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. -/// -/// \brief + +/// \file UPCTauCentralBarrelHelperRL.h +/// \brief Personal helper file to analyze tau events from UPC collisions /// \author Roman Lavicka, roman.lavicka@cern.ch /// \since 27.10.2022 +/// #ifndef PWGUD_CORE_UPCTAUCENTRALBARRELHELPERRL_H_ #define PWGUD_CORE_UPCTAUCENTRALBARRELHELPERRL_H_ -#include +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + #include +#include enum MyParticle { P_ELECTRON = 0, @@ -156,6 +162,25 @@ int enumMyParticle(int valuePDG) } } +int trackPDGfromEnum(int trackEnum) +// reads pdg value and returns particle number as in enumMyParticle +{ + if (trackEnum == P_ELECTRON) { + return 11; + } else if (trackEnum == P_MUON) { + return 13; + } else if (trackEnum == P_PION) { + return 211; + } else if (trackEnum == P_KAON) { + return 321; + } else if (trackEnum == P_PROTON) { + return 2212; + } else { + printDebugMessage("PDG value not found in enumMyParticle. Returning -1."); + return -1.; + } +} + float pt(float px, float py) // Just a simple function to return pt { diff --git a/PWGUD/Core/decayTree.cxx b/PWGUD/Core/decayTree.cxx new file mode 100644 index 00000000000..026c77af706 --- /dev/null +++ b/PWGUD/Core/decayTree.cxx @@ -0,0 +1,1220 @@ +// 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. + +#include +#include +#include +#include +#include + +#include "rapidjson/document.h" +#include "rapidjson/filereadstream.h" +#include "decayTree.h" + +using namespace rapidjson; + +// ----------------------------------------------------------------------------- +// pidSelector holds an array of pidcut +// pidcut +// double[8] +// 0: pid to apply +// 1: detector: 1 - TPC, 2 - TOF +// 2: cut type: +// 1: pt and nSigma within limits +// -1: nSigma out of limits within pt range +// 2: pt and detector signal within limits +// -2: detector signal out of limits within pt range +// 3: How to apply cut: +// 0: not active +// 1: if information available +// 2: return false if information not available +// 4: pT min +// 5: pT max +// 6: signal/nSigma min +// 7: signal/nSigma max +// pidSelector +pidSelector::pidSelector(std::vector>& pidcuts) +{ + fpidCuts = pidcuts; +} + +void pidSelector::clear() +{ + fpidCuts.clear(); +} + +int pidSelector::pid2ind(int pid) +{ + switch (std::abs(pid)) { + case 11: // electron + return 0; + case 211: // pion + return 1; + case 13: // muon + return 2; + case 321: // kaon + return 3; + case 2212: // proton + return 4; + default: // unknown + return -1.; + } +}; + +void pidSelector::Print() +{ + LOGF(info, " PID cuts"); + for (const auto& cut : fpidCuts) { + LOGF(info, " [ %.0f %.0f %.0f %.0f %.0f %.2f %.2f %.2f ]", cut[0], cut[1], cut[2], cut[3], cut[4], cut[5], cut[6], cut[7]); + } +} + +// ----------------------------------------------------------------------------- +// angleCut +angleCut::angleCut(std::pair rnames, double angleMin, double angleMax) +{ + fRnames = rnames; + fAngleMin = angleMin; + fAngleMax = angleMax; +} + +void angleCut::Print() +{ + LOGF(info, " %s ^ %s: %f : %f", fRnames.first, fRnames.second, fAngleMin, fAngleMax); +} + +// ----------------------------------------------------------------------------- +// Resonance +resonance::resonance() +{ + init(); +} + +// reset to default values +void resonance::init() +{ + // initialisations + fisFinal = false; + fCounter = -1; + fName = ""; + fStatus = 0; + fPID = 0; + fPIDfun = 0; + fdetectorHits = std::vector{-1, -1, -1, -1}; + fParents.clear(); + fDaughters.clear(); + + // initialize mass, pT, eta range + setMassRange(0., 100.); + setPtRange(0., 100.); + setEtaRange(-10., 10.); + setNcltpcRange(0, 200); + setChi2ncltpcRange(0., 100.); + setDCAxyzMax(100., 100.); + + // histogram axes + fnmassBins = 350; + fmassHistMin = 0.0; + fmassHistMax = 3.5; + fnmomBins = 300; + fmomHistMin = 0.0; + fmomHistMax = 3.0; + + // invariant mass + fIVM = TLorentzVector(0., 0., 0., 0.); + fCharge = 0; + + // pid cuts + fpidSelector.clear(); + fangleCuts.clear(); +} + +void resonance::reset() +{ + fStatus = 0; +} + +// check mass, pt, eta range and charge +void resonance::updateStatus() +{ + // IVM has to be computed + if (fStatus == 0) { + return; + } + + // check mass, pt, and eta range + fStatus = 2; + if (fIVM.M() < fmassMin || fIVM.M() > fmassMax) { + return; + } + if (fIVM.Perp() < fptMin || fIVM.Perp() > fptMax) { + return; + } + if (fIVM.Eta() < fetaMin || fIVM.Eta() > fetaMax) { + return; + } + + // good candidate + fStatus = 3; +} + +void resonance::Print() +{ + if (fisFinal) { + // final + LOGF(info, " %s : %d", fName, fPID); + LOGF(info, " status: %d", fStatus); + LOGF(info, " final: %d", fCounter); + LOGF(info, " nCluster TPC: %d : %d", fncltpcMin, fncltpcMax); + LOGF(info, " chi2 per cluster TPC: %f : %f", fchi2ncltpcMin, fchi2ncltpcMax); + LOGF(info, " maximum dca_XY : %f", fdcaxyMax); + LOGF(info, " maximum dca_Z: %f", fdcazMax); + LOGF(info, " parents"); + for (const auto& parent : fParents) { + LOGF(info, " %s", parent); + } + } else { + // resonance + LOGF(info, " %s", fName); + LOGF(info, " status: %d", fStatus); + LOGF(info, " parents"); + for (const auto& parent : fParents) { + LOGF(info, " %s", parent); + } + LOGF(info, " daughters"); + for (const auto& daugh : fDaughters) { + LOGF(info, " %s", daugh); + } + } + LOGF(info, " mass range: %f : %f", fmassMin, fmassMax); + LOGF(info, " pt range: %f : %f", fptMin, fptMax); + LOGF(info, " eta range: %f : %f", fetaMin, fetaMax); + if (fisFinal) { + fpidSelector.Print(); + } else { + LOGF(info, " Angle cuts"); + for (const auto& anglecut : fangleCuts) { + anglecut->Print(); + } + } + + if (fStatus > 0) { + LOGF(info, " charge: %d", fCharge); + LOGF(info, " mass: %f", fIVM.M()); + LOGF(info, " E: %f", fIVM.E()); + LOGF(info, " pT: %f", fIVM.Perp()); + LOGF(info, " eta: %f", fIVM.Eta()); + } + LOGF(info, ""); +} + +// ----------------------------------------------------------------------------- +// decayTree +decayTree::decayTree() +{ + fPDG = TDatabasePDG::Instance(); +} + +bool decayTree::init(std::string const& parFile, o2::framework::HistogramRegistry& registry) +{ + // initialisation of constants + fccs = {"ULS", "LS"}; + fdets = {"TPC", "TOF"}; + fparts = {"el", "pi", "mu", "ka", "pr"}; + + // open the decayTree file + FILE* fjson = fopen(parFile.c_str(), "r"); + if (!fjson) { + LOGF(error, "Could not open parameter file %s", parFile); + return false; + } + + // create streamer + char readBuffer[65536]; + FileReadStream jsonStream(fjson, readBuffer, sizeof(readBuffer)); + + // parse the json file + Document jsonDocument; + jsonDocument.ParseStream(jsonStream); + + // is it a proper json document? + if (jsonDocument.HasParseError()) { + LOGF(error, "Check the parameter file! There is a problem with the format!"); + return false; + } + + // check for decayTree + const char* itemName = "decayTree"; + if (!jsonDocument.HasMember(itemName)) { + LOGF(error, "Check the parameter file! Item %s is missing!", itemName); + return false; + } + const Value& decTree = jsonDocument[itemName]; + + // finals and resonance parameters + std::string name; + int pid; + int pidfun; + std::vector daughters; + std::vector charges; + std::vector> vcuts; + std::vector vanglecuts; + + itemName = "finals"; + if (!decTree.HasMember(itemName)) { + LOGF(info, "No %s defined!", itemName); + return false; + } + if (!decTree[itemName].IsArray()) { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + return false; + } + + // loop over finals + fnFinals = 0; + auto fins = decTree[itemName].GetArray(); + for (const auto& fin : fins) { + if (!fin.IsObject()) { + LOGF(error, "Check the parameter file! %s must be objects!", itemName); + return false; + } + + // create new finals (resonance) + resonance* newRes = new resonance(); + newRes->setisFinal(); + + // check for name + itemName = "name"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsString()) { + name = fin[itemName].GetString(); + newRes->setName(name); + } else { + LOGF(error, "Check the parameter file! %s must be a string!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Finals must have a %s!", itemName); + delete newRes; + return false; + } + + // check for pid + itemName = "pid"; + if (fin.HasMember(itemName)) { + pid = fin[itemName].GetInt(); + newRes->setPID(pid); + } else { + LOGF(error, "Check the parameter file! Finals must have a %s!", itemName); + delete newRes; + return false; + } + + // check for ptrange + itemName = "ptrange"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsArray()) { + auto lims = fin[itemName].GetArray(); + if (lims.Size() == 2) { + newRes->setPtRange(lims[0].GetFloat(), lims[1].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for etarange + itemName = "etarange"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsArray()) { + auto lims = fin[itemName].GetArray(); + if (lims.Size() == 2) { + newRes->setEtaRange(lims[0].GetFloat(), lims[1].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for detectorhits + // 0: ITS + // 1: TPC + // 2: TRD + // 3: TOF + itemName = "detectorhits"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsArray()) { + auto hits = fin[itemName].GetArray(); + if (hits.Size() == 4) { + newRes->setDetectorHits(hits[0].GetInt(), hits[1].GetInt(), hits[2].GetInt(), hits[3].GetInt()); + } else { + LOGF(error, "Check the parameter file! %s must have four elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for ncltpcrange + itemName = "ncltpcrange"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsArray()) { + auto lims = fin[itemName].GetArray(); + if (lims.Size() == 2) { + newRes->setNcltpcRange(lims[0].GetFloat(), lims[1].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for chi2ncltpcrange + itemName = "chi2ncltpcrange"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsArray()) { + auto lims = fin[itemName].GetArray(); + if (lims.Size() == 2) { + newRes->setChi2ncltpcRange(lims[0].GetFloat(), lims[1].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for dcaxyzmax + itemName = "dcaxyzmax"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsArray()) { + auto lims = fin[itemName].GetArray(); + if (lims.Size() == 2) { + newRes->setDCAxyzMax(lims[0].GetFloat(), lims[1].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // pid cuts + vcuts.clear(); + itemName = "pidcuts"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsArray()) { + auto pidcuts = fin[itemName].GetArray(); + for (const auto& pidcut : pidcuts) { + if (pidcut.HasMember("pidcut")) { + if (pidcut["pidcut"].IsArray()) { + auto vals = pidcut["pidcut"].GetArray(); + if (vals.Size() == 8) { + std::vector vs; + for (const auto& val : vals) { + vs.push_back(val.GetFloat()); + } + vcuts.push_back(vs); + } else { + LOGF(error, "Check the parameter file! A pidcut has %d members", vals.Size()); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item pidcuts['pidcut'] must be an array!"); + delete newRes; + return false; + } + } + } + auto pidsel = pidSelector(vcuts); + newRes->setPIDSelector(pidsel); + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for massaxis + itemName = "massaxis"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsArray()) { + auto max = fin[itemName].GetArray(); + if (max.Size() == 3) { + newRes->setMassHistAxis(max[0].GetInt(), max[1].GetFloat(), max[2].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have three elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for momaxis + itemName = "momaxis"; + if (fin.HasMember(itemName)) { + if (fin[itemName].IsArray()) { + auto momax = fin[itemName].GetArray(); + if (momax.Size() == 3) { + newRes->setMomHistAxis(momax[0].GetInt(), momax[1].GetFloat(), momax[2].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have three elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // update fResonances + fnFinals++; + newRes->setCounter(fnFinals - 1); + fResonances.push_back(newRes); + } + + itemName = "ulsstates"; + if (decTree.HasMember(itemName)) { + LOGF(info, "No %s defined!", itemName); + if (!decTree[itemName].IsArray()) { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + return false; + } + auto ulsstates = decTree[itemName].GetArray(); + for (const auto& obj : ulsstates) { + if (obj.IsArray()) { + auto ulsstate = obj.GetArray(); + if (static_cast(ulsstate.Size()) != fnFinals) { + LOGF(error, "%s with wrong number of elements!", itemName); + return false; + } + charges.clear(); + for (const auto& ch : ulsstate) { + charges.push_back(ch.GetInt()); + } + LOGF(info, "adding charge state %d", chargeState(charges)); + fULSstates.push_back(chargeState(charges)); + } else { + LOGF(error, "Check the parameter file! Elements of item %s must be arrays!", itemName); + return false; + } + } + } + + itemName = "lsstates"; + if (decTree.HasMember(itemName)) { + LOGF(info, "No %s defined!", itemName); + if (!decTree[itemName].IsArray()) { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + return false; + } + auto lsstates = decTree[itemName].GetArray(); + for (const auto& obj : lsstates) { + if (obj.IsArray()) { + auto lsstate = obj.GetArray(); + if (static_cast(lsstate.Size()) != fnFinals) { + LOGF(error, "%s with wrong number of elements!", itemName); + return false; + } + charges.clear(); + for (const auto& ch : lsstate) { + charges.push_back(ch.GetInt()); + } + fLSstates.push_back(chargeState(charges)); + } else { + LOGF(error, "Check the parameter file! Elements of item %s must be arrays!", itemName); + return false; + } + } + } + + // update permutations + permutations(fnFinals, fPermutations); + + itemName = "resonances"; + if (!decTree.HasMember(itemName)) { + LOGF(info, "No resonances defined!"); + } else { + if (!decTree[itemName].IsArray()) { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + return false; + } + + // loop over resonances + auto ress = decTree[itemName].GetArray(); + for (const auto& res : ress) { + if (!res.IsObject()) { + LOGF(error, "Check the parameter file! %s must be objects!", itemName); + return false; + } + + // create new resonance + resonance* newRes = new resonance(); + + // check for name + itemName = "name"; + if (res.HasMember(itemName)) { + if (res[itemName].IsString()) { + name = res[itemName].GetString(); + newRes->setName(name); + } else { + LOGF(error, "Check the parameter file! %s must be a string!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Resonances must have a name!"); + delete newRes; + return false; + } + + // check for daughters + itemName = "daughters"; + if (res.HasMember(itemName)) { + if (res[itemName].IsArray()) { + auto daughs = res[itemName].GetArray(); + if (daughs.Size() >= 2) { + daughters.clear(); + for (const auto& daugh : daughs) { + daughters.push_back(daugh.GetString()); + } + newRes->setDaughters(daughters); + } else { + LOGF(error, "Check the parameter file! %s must have at least two elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Resonances must have daughters!"); + delete newRes; + return false; + } + + // check for massrange + itemName = "massrange"; + if (res.HasMember(itemName)) { + if (res[itemName].IsArray()) { + auto lims = res[itemName].GetArray(); + if (lims.Size() != 2) { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + delete newRes; + return false; + } + newRes->setMassRange(lims[0].GetFloat(), lims[1].GetFloat()); + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for ptrange + itemName = "ptrange"; + if (res.HasMember(itemName)) { + if (res[itemName].IsArray()) { + auto lims = res[itemName].GetArray(); + if (lims.Size() == 2) { + newRes->setPtRange(lims[0].GetFloat(), lims[1].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for etarange + itemName = "etarange"; + if (res.HasMember(itemName)) { + if (res[itemName].IsArray()) { + auto lims = res[itemName].GetArray(); + if (lims.Size() == 2) { + newRes->setEtaRange(lims[0].GetFloat(), lims[1].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for pidfun + itemName = "pidfun"; + if (res.HasMember(itemName)) { + pidfun = res[itemName].GetInt(); + newRes->setPIDFun(pidfun); + } + + // angle cuts + vanglecuts.clear(); + itemName = "anglecuts"; + if (res.HasMember(itemName)) { + if (res[itemName].IsArray()) { + auto anglecuts = res[itemName].GetArray(); + for (const auto& anglecut : anglecuts) { + if (anglecut.HasMember("pair")) { + if (anglecut["pair"].IsArray()) { + auto daughters = anglecut["pair"].GetArray(); + if (daughters.Size() == 2) { + std::pair pair{daughters[0].GetString(), daughters[1].GetString()}; + if (anglecut.HasMember("anglerange")) { + if (anglecut["anglerange"].IsArray()) { + auto arange = anglecut["anglerange"].GetArray(); + if (arange.Size() == 2) { + vanglecuts.push_back(new angleCut(pair, arange[0].GetFloat(), arange[1].GetFloat())); + } else { + LOGF(error, "Check the parameter file! An anglecut['anglerange'] has %d members", arange.Size()); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item anglerange must be an array!"); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! An anglecut must have an anglerange!"); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! A anglecut['pair'] has %d members", daughters.Size()); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item anglecut must be an array!"); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! An anglecut must have a pair!"); + delete newRes; + return false; + } + } + newRes->setAngleCuts(vanglecuts); + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for massaxis + itemName = "massaxis"; + if (res.HasMember(itemName)) { + if (res[itemName].IsArray()) { + auto max = res[itemName].GetArray(); + if (max.Size() == 3) { + newRes->setMassHistAxis(max[0].GetInt(), max[1].GetFloat(), max[2].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have three elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // check for momaxis + itemName = "momaxis"; + if (res.HasMember(itemName)) { + if (res[itemName].IsArray()) { + auto momax = res[itemName].GetArray(); + if (momax.Size() == 3) { + newRes->setMomHistAxis(momax[0].GetInt(), momax[1].GetFloat(), momax[2].GetFloat()); + } else { + LOGF(error, "Check the parameter file! %s must have three elements!", itemName); + delete newRes; + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + delete newRes; + return false; + } + } + + // use the items to create a new resonance + fResonances.push_back(newRes); + } + } + + // update the parents information + updateParents(); + + // check for eventCuts + // set default values + fnTracksMin = fnFinals; + fnTracksMax = fnFinals; + frgtwtofMin = 0.0; + fdBCMin = 0; + fdBCMax = 0; + fFITvetos = {0, 1, 1, 0, 0}; + + itemName = "eventCuts"; + if (!jsonDocument.HasMember(itemName)) { + return true; + } + const Value& evset = jsonDocument[itemName]; + + // check for ntrackrange + itemName = "ntrackrange"; + if (evset.HasMember(itemName)) { + if (evset[itemName].IsArray()) { + auto lims = evset[itemName].GetArray(); + if (lims.Size() == 2) { + fnTracksMin = lims[0].GetFloat(); + fnTracksMax = lims[1].GetFloat(); + } else { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + return false; + } + } + + // check for rgtwtofmin + itemName = "rgtrwtofmin"; + if (evset.HasMember(itemName)) { + frgtwtofMin = evset[itemName].GetFloat(); + } + + // check for dBCrange + itemName = "dBCrange"; + if (evset.HasMember(itemName)) { + if (evset[itemName].IsArray()) { + auto lims = evset[itemName].GetArray(); + if (lims.Size() == 2) { + fdBCMin = lims[0].GetInt(); + fdBCMax = lims[1].GetInt(); + } else { + LOGF(error, "Check the parameter file! %s must have two elements!", itemName); + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + return false; + } + } + + // check for FITvetos + itemName = "FITvetos"; + if (evset.HasMember(itemName)) { + if (evset[itemName].IsArray()) { + auto vetoes = evset[itemName].GetArray(); + if (vetoes.Size() == 5) { + fFITvetos.clear(); + for (auto i = 0; i < 5; i++) { + fFITvetos.push_back(vetoes[i].GetInt()); + } + } else { + LOGF(error, "Check the parameter file! %s must have five elements!", itemName); + return false; + } + } else { + LOGF(error, "Check the parameter file! Item %s must be an array!", itemName); + return false; + } + } + + // clean up + fclose(fjson); + + // create the histograms + createHistograms(registry); + + return true; +} + +void decayTree::updateParents() +{ + // reset parents + for (const auto& res : fResonances) { + res->clearParents(); + } + + for (const auto& res : fResonances) { + for (const auto& daughName : res->getDaughters()) { + auto daugh = getResonance(daughName); + daugh->addParent(res->name()); + } + } +} + +void decayTree::reset() +{ + fStatus = 0; + fChargeState = -1; + for (const auto& res : fResonances) { + res->reset(); + } +} + +// decayTree status +// 0: unset +// 1: not accepted +// 2: ULS accepted +// 3: LS accepted +void decayTree::updateStatus() +{ + bool isULS = true; + bool isLS = true; + fStatus = 1; + for (const auto& res : fResonances) { + if (res->status() < 3) { + return; + } + + // check the charge state + updateChargeState(); + if (std::find(fULSstates.begin(), fULSstates.end(), fChargeState) == fULSstates.end()) { + isULS = false; + } + if (std::find(fLSstates.begin(), fLSstates.end(), fChargeState) == fLSstates.end()) { + isLS = false; + } + } + if (isULS) { + fStatus = 2; + } else if (isLS) { + fStatus = 3; + } +} + +void decayTree::Print() +{ + LOGF(info, "eventCuts"); + LOGF(info, " ntrkRange: %d : %d", fnTracksMin, fnTracksMax); + LOGF(info, " dBCRange: %d : %d", fdBCMin, fdBCMax); + LOGF(info, " FITVetoes: [ %d %d %d %d %d ]", fFITvetos[0], fFITvetos[1], fFITvetos[2], fFITvetos[3], fFITvetos[4]); + LOGF(info, " ULS states"); + for (const auto& chstat : fULSstates) { + LOGF(info, " %d", chstat); + } + LOGF(info, " LS states"); + for (const auto& chstat : fLSstates) { + LOGF(info, " %d", chstat); + } + LOGF(info, ""); + LOGF(info, "decayTree"); + LOGF(info, " nResonances: %d", fResonances.size()); + LOGF(info, " nFinals: %d", fnFinals); + LOGF(info, " Resonances"); + for (const auto& res : fResonances) { + res->Print(); + } +} + +resonance* decayTree::getResonance(std::string name) +{ + for (const auto& res : fResonances) { + if (res->name() == name) { + return res; + } + } + LOGF(error, "A resonance %s does not exists!", name); + return new resonance(); // is needed to satisfy return type +} + +resonance* decayTree::getFinal(int counter) +{ + for (const auto& res : fResonances) { + if (res->counter() == counter) { + return res; + } + } + LOGF(error, "The final %d does not exists!", counter); + return new resonance(); // is needed to satisfy return type +} + +std::vector decayTree::getFinals(resonance* res) +{ + std::vector resFinals; + + for (const auto& d1Name : res->getDaughters()) { + auto d1 = getResonance(d1Name); + if (d1->isFinal()) { + resFinals.push_back(d1); + } else { + for (const auto& d2Name : d1->getDaughters()) { + auto d2 = getResonance(d2Name); + for (const auto& d3 : getFinals(d2)) { + resFinals.push_back(d3); + } + } + } + } + return resFinals; +} + +// apply anglecuts +void decayTree::checkAngles() +{ + // loop over resonances + for (const auto& res : fResonances) { + auto anglecuts = res->getAngleCuts(); + // loop over angle cuts + for (const auto& anglecut : anglecuts) { + auto rnames = anglecut->rNames(); + auto anglerange = anglecut->angleRange(); + + // compute angle between two resonances + auto lv1 = getResonance(rnames.first)->IVM(); + auto lv2 = getResonance(rnames.second)->IVM(); + auto ang = lv1.Angle(lv2.Vect()); + + // apply cut + if (ang < anglerange.first || ang > anglerange.second) { + res->setStatus(2); + break; + } + } + } +} + +// compute charge state +int decayTree::chargeState(std::vector chs) +{ + int chargeState = -1; + if (static_cast(chs.size()) == fnFinals) { + // loop over elements of chargestate + chargeState = 0; + for (auto ind = 0; ind < fnFinals; ind++) { + chargeState += (chs[ind] > 0) * std::pow(2, ind); + } + } + return chargeState; +} +void decayTree::updateChargeState() +{ + fChargeState = 0; + + // loop over all finals + for (auto ind = 0; ind < fnFinals; ind++) { + fChargeState += (getFinal(ind)->charge() > 0) * std::pow(2, ind); + } +} + +std::size_t decayTree::combHash(std::vector& comb) +{ + // comb contains indices to tracks + // the combination hash is created from a string which is comprised of a sorted list of track indices + + // sort comb + std::map m_unsorted; + for (size_t cnt = 0; cnt < comb.size(); cnt++) { + m_unsorted.insert(std::pair(comb[cnt], cnt)); + } + std::vector v_sorted(comb.size()); + partial_sort_copy(begin(comb), end(comb), begin(v_sorted), end(v_sorted)); + + // create the hash + std::hash hasher; + std::string hashstr{""}; + for (size_t cnt = 0; cnt < comb.size(); cnt++) { + hashstr += std::to_string(v_sorted[cnt]); + } + + return hasher(hashstr); +} + +// find all permutations of n0 elements +void decayTree::permutations(std::vector& ref, int n0, int np, std::vector>& perms) +{ + // create local reference + auto ref2u = ref; + + // loop over np-1 rotations of last np elements of ref + for (auto ii = 0; ii < np; ii++) { + + // create a new permutation + // copy first n0-np elements from ref + // then rotate last np elements of ref + std::vector perm(n0, 0); + for (auto ii = 0; ii < n0 - np; ii++) { + perm[ii] = ref2u[ii]; + } + for (auto ii = n0 - np + 1; ii < n0; ii++) { + perm[ii - 1] = ref2u[ii]; + } + perm[n0 - 1] = ref2u[n0 - np]; + + // add new permutation to the list of permuutations + if (ii < (np - 1)) { + perms.push_back(perm); + } + + // if np>2 then do permutation of next level + // use the new combination as reference + if (np > 2) { + auto newnp = np - 1; + permutations(perm, n0, newnp, perms); + } + + // update reference + ref2u = perm; + } +} + +// find all permutations of n0 elements +int decayTree::permutations(int n0, std::vector>& perms) +{ + // initialize with first trivial combination + perms.clear(); + if (n0 == 0) { + return 0; + } + + std::vector ref(n0, 0); + for (auto ii = 0; ii < n0; ii++) { + ref[ii] = ii; + } + perms.push_back(ref); + + // iterate recursively + permutations(ref, n0, n0, perms); + + return perms.size(); +} + +void decayTree::combinations(int n0, std::vector& pool, int np, std::vector& inds, int n, + std::vector>& combs) +{ + // loop over pool + for (auto ii = 0; ii < n0 - n; ii++) { + + inds[n] = pool[ii]; + + // if all inds are defined then print them out + // else get next inds + if (np == 1) { + + std::vector comb(n + 1, 0); + for (uint ii = 0; ii < inds.size(); ii++) { + comb[ii] = inds[ii]; + } + combs.push_back(comb); + + } else { + + auto n0new = n0 - ii; + std::vector newpool(n0new, 0); + for (auto kk = 0; kk < n0new; kk++) { + newpool[kk] = pool[kk + ii + 1]; + } + + auto npnew = np - 1; + auto nnew = n + 1; + combinations(n0new, newpool, npnew, inds, nnew, combs); + } + } +} + +// find all possible selections of np out of n0 +int decayTree::combinations(int n0, int np, std::vector>& combs) +{ + // initialisations + combs.clear(); + if (n0 < np) { + return 0; + } + + std::vector pool(n0, 0); + for (auto ii = 0; ii < n0; ii++) { + pool[ii] = ii; + } + std::vector inds(np, 0); + + // iterate recursively + combinations(n0, pool, np, inds, 0, combs); + + return combs.size(); +} + +std::vector> decayTree::combinations(int nPool) +{ + // all selections of fnFinals items from nPool elements + std::vector> combs; + combinations(nPool, fnFinals, combs); + + // permute the combinations + std::vector> copes; + for (const auto& comb : combs) { + for (const auto& perm : fPermutations) { + std::vector cope(fnFinals, 0); + for (auto jj = 0; jj < fnFinals; jj++) { + cope[perm[jj]] = comb[jj]; + } + copes.push_back(cope); + } + } + + return copes; +} + +// ----------------------------------------------------------------------------- diff --git a/PWGUD/Core/decayTree.h b/PWGUD/Core/decayTree.h new file mode 100644 index 00000000000..3dd4f53578b --- /dev/null +++ b/PWGUD/Core/decayTree.h @@ -0,0 +1,999 @@ +// 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. + +#ifndef PWGUD_CORE_DECAYTREE_H_ +#define PWGUD_CORE_DECAYTREE_H_ + +#include +#include +#include +#include + +#include "Framework/AnalysisTask.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/Logger.h" +#include "TLorentzVector.h" +#include "TDatabasePDG.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// ----------------------------------------------------------------------------- +class pidSelector +{ + public: + // constructor/destructor + pidSelector() {} + explicit pidSelector(std::vector>& pidcuts); + ~pidSelector() {} + + // setter + void clear(); + + // getters + void Print(); + + // templated functions + template + double getTPCnSigma(TTs track, int pid) + { + auto hypo = pid2ind(pid); + switch (hypo) { + case 0: + return track.tpcNSigmaEl(); + case 1: + return track.tpcNSigmaPi(); + case 2: + return track.tpcNSigmaMu(); + case 3: + return track.tpcNSigmaKa(); + case 4: + return track.tpcNSigmaPr(); + default: + return 0.; + } + }; + + template + double getTOFnSigma(TTs track, int pid) + { + auto hypo = pid2ind(pid); + switch (hypo) { + case 0: + return track.tofNSigmaEl(); + case 1: + return track.tofNSigmaPi(); + case 2: + return track.tofNSigmaMu(); + case 3: + return track.tofNSigmaKa(); + case 4: + return track.tofNSigmaPr(); + default: + return 0.; + } + }; + + template + bool goodTrack(TTs track) + { + // loop over pidcuts + for (const auto& pidcut : fpidCuts) { + + float mom = 0.; + float detValue = 0.; + if (pidcut[1] == 1) { + // TPC + if (track.hasTPC()) { + mom = track.tpcInnerParam(); + if (mom < pidcut[4] || mom > pidcut[5]) { + // not in relevant momentum range + continue; + } + if (std::abs(pidcut[2]) == 1) { + // nSigma + detValue = getTPCnSigma(track, pidcut[0]); + } else { + // signal + detValue = track.tpcSignal(); + } + } else { + if (pidcut[3] == 2) { + // TPC is required + return false; + } else { + continue; + } + } + } else { + // TOF + if (track.hasTOF()) { + mom = track.tofExpMom(); + if (mom < pidcut[4] || mom > pidcut[5]) { + // not in relevant momentum range + continue; + } + if (std::abs(pidcut[2]) == 1) { + // nSigma + detValue = getTOFnSigma(track, pidcut[0]); + } else { + // signal + detValue = track.tofSignal(); + } + } else { + if (pidcut[3] == 2) { + // TOF is required + return false; + } else { + continue; + } + } + } + + // inclusive / exclusive + if (pidcut[2] > 0 && (detValue < pidcut[6] || detValue > pidcut[7])) { + return false; + } else if (pidcut[2] < 0 && (detValue > pidcut[6] && detValue < pidcut[7])) { + return false; + } + } + + // the track is good if we arrive here + return true; + } + + private: + std::vector> fpidCuts; + int pid2ind(int pid); + + // ClassDefNV(pidSelector, 1); +}; + +// ----------------------------------------------------------------------------- +class angleCut +{ + public: + // constructor/destructor + angleCut() {} + explicit angleCut(std::pair rNames, double angleMin, double angleMax); + ~angleCut() {} + + std::pair rNames() { return fRnames; } + std::pair angleRange() { return std::pair{fAngleMin, fAngleMax}; } + + void Print(); + + private: + std::pair fRnames; + double fAngleMin; + double fAngleMax; + + // ClassDefNV(angleCut, 1); +}; + +// ----------------------------------------------------------------------------- +class reconstructedParticle +{ + public: + // constructor/destructor + reconstructedParticle() {} + explicit reconstructedParticle(std::string name, TLorentzVector ivm, std::vector& comb) + { + fName = name; + fIVM = ivm; + fComb = comb; + }; + ~reconstructedParticle() {} + + std::string name() { return fName; } + TLorentzVector lv() { return fIVM; } + std::vector comb() { return fComb; } + + private: + std::string fName; + TLorentzVector fIVM; + std::vector fComb; +}; + +using recResType = std::vector>; + +class reconstructedEvent +{ + public: + // constructor/destructor + reconstructedEvent() {} + explicit reconstructedEvent(recResType recs, int chargeState, std::vector& comb) + { + fRecs = recs; + fComb = comb; + fChargeState = chargeState; + }; + ~reconstructedEvent() {} + + recResType recResonances() { return fRecs; } + std::vector comb() { return fComb; } + + private: + recResType fRecs; + std::vector fComb; + int fChargeState; +}; + +using decayTreeResType = std::map; + +// ----------------------------------------------------------------------------- +class resonance +{ + public: + // constructor/destructor + resonance(); + ~resonance() {} + + // setters + void init(); + void reset(); + + void setisFinal() { fisFinal = true; } + void setCounter(int counter) { fCounter = counter; } + void setName(std::string name) { fName = name; } + void setStatus(int status) { fStatus = status; } + void setPID(int pid) { fPID = pid; } + void setPIDFun(int pidfun) { fPIDfun = pidfun; } + void setDetectorHits(int its, int tpc, int trd, int tof) + { + fdetectorHits = std::vector{its, tpc, trd, tof}; + } + void clearParents() { fParents.clear(); } + void addParent(std::string parent) { fParents.push_back(parent); } + void setDaughters(std::vector& daughters) { fDaughters = daughters; } + void setIVM(TLorentzVector ivm) + { + fIVM = ivm; + fStatus = 1; + } + void setCharge(int charge) { fCharge = charge; } + + // selections + void setMassRange(double mmin, double mmax) + { + fmassMin = mmin; + fmassMax = mmax; + } + void setPtRange(double ptmin, double ptmax) + { + fptMin = ptmin; + fptMax = ptmax; + } + void setEtaRange(double etamin, double etamax) + { + fetaMin = etamin; + fetaMax = etamax; + } + void setNcltpcRange(int ncltpcmin, int ncltpcmax) + { + fncltpcMin = ncltpcmin; + fncltpcMax = ncltpcmax; + } + void setChi2ncltpcRange(double chi2ncltpcmin, double chi2ncltpcmax) + { + fchi2ncltpcMin = chi2ncltpcmin; + fchi2ncltpcMax = chi2ncltpcmax; + } + void setDCAxyzMax(double dcaxymax, double dcazmax) + { + fdcaxyMax = dcaxymax; + fdcazMax = dcazmax; + } + void setPIDSelector(pidSelector pidcuts) { fpidSelector = pidcuts; } + void setAngleCuts(std::vector anglecuts) { fangleCuts = anglecuts; } + + // histograms + void setMassHistAxis(int nbins, double binmin, double binmax) + { + fnmassBins = nbins; + fmassHistMin = binmin; + fmassHistMax = binmax; + } + void setMomHistAxis(int nbins, double binmin, double binmax) + { + fnmomBins = nbins; + fmomHistMin = binmin; + fmomHistMax = binmax; + } + void updateStatus(); + + // getters + bool isFinal() { return fisFinal; } + int counter() { return fCounter; } + std::string name() { return fName; } + int status() { return fStatus; } + int pid() { return fPID; } + int pidFun() { return fPIDfun; } + std::vector detectorHits() { return fdetectorHits; } + std::vector getParents() { return fParents; } + std::vector getDaughters() { return fDaughters; } + double massMin() { return fmassMin; } + double massMax() { return fmassMax; } + double ptMin() { return fptMin; } + double ptMax() { return fptMax; } + double etaMin() { return fetaMin; } + double etaMax() { return fetaMax; } + TLorentzVector IVM() { return fIVM; } + int charge() { return fCharge; } + pidSelector getPIDSelector() { return fpidSelector; } + std::vector getAngleCuts() { return fangleCuts; } + + // histograms + int nmassBins() { return fnmassBins; } + std::vector massHistRange() { return std::vector({fmassHistMin, fmassHistMax}); } + int nmomBins() { return fnmomBins; } + std::vector momHistRange() { return std::vector({fmomHistMin, fmomHistMax}); } + + void Print(); + + // templated functions + // resonance status + // 0: unset + // 1: IVM calculated + // 2: not accepted + // 3: accepted + template + void updateStatus(TTs const& track) + { + // IVM has to be computed + if (fStatus == 0) { + return; + } + + // check mass, pt, eta range and charge + updateStatus(); + + // check detector hits, track cuts + if (fStatus >= 3) { + // detector hits + if (fdetectorHits[0] >= 0) { + if ((fdetectorHits[0] == 0 && track.hasITS()) || (fdetectorHits[0] > 0 && !track.hasITS())) { + fStatus = 2; + } + } + if (fdetectorHits[1] >= 0) { + if ((fdetectorHits[1] == 0 && track.hasTPC()) || (fdetectorHits[1] > 0 && !track.hasTPC())) { + fStatus = 2; + } + } + if (fdetectorHits[2] >= 0) { + if ((fdetectorHits[2] == 0 && track.hasTRD()) || (fdetectorHits[2] > 0 && !track.hasTRD())) { + fStatus = 2; + } + } + if (fdetectorHits[3] >= 0) { + if ((fdetectorHits[3] == 0 && track.hasTOF()) || (fdetectorHits[3] > 0 && !track.hasTOF())) { + fStatus = 2; + } + } + // PID cuts + if (!fpidSelector.goodTrack(track)) { + fStatus = 2; + } + // nclTPC + auto nclTPC = track.tpcNClsFindable() - track.tpcNClsFindableMinusFound(); + if (nclTPC < fncltpcMin || nclTPC > fncltpcMax) { + fStatus = 2; + } + // chi2nclTPC + if (track.tpcChi2NCl() < fchi2ncltpcMin || track.tpcChi2NCl() > fchi2ncltpcMax) { + fStatus = 2; + } + // dcaxyz + auto lim = fdcaxyMax + std::pow(0.0350 / track.pt(), 1.1); + if (std::abs(track.dcaXY()) > lim || std::abs(track.dcaZ()) > fdcazMax) { + fStatus = 2; + } + } + } + + private: + bool fisFinal; + int fCounter; + + // resonance name + std::string fName; + int fStatus; + + // nominal pid + int fPID; + int fPIDfun; + std::vector fdetectorHits; + + // name of parents and daughters + std::vector fParents; + std::vector fDaughters; + void updateParents(); + + // mass, pT, , eta range + double fmassMin; + double fmassMax; + double fptMin; + double fptMax; + double fetaMin; + double fetaMax; + int fncltpcMin; + int fncltpcMax; + double fchi2ncltpcMin; + double fchi2ncltpcMax; + double fdcaxyMax; + double fdcazMax; + + // histogram axes + int fnmassBins; + double fmassHistMax; + double fmassHistMin; + int fnmomBins; + double fmomHistMax; + double fmomHistMin; + + // invariant mass + TLorentzVector fIVM; + int fCharge; + + // pidcuts, anglecuts + pidSelector fpidSelector; + std::vector fangleCuts; + + // ClassDefNV(resonance, 1); +}; + +// ----------------------------------------------------------------------------- +class decayTree +{ + public: + // constructor/destructor + decayTree(); + ~decayTree() {} + + // setters + // read decay tree from json file + bool init(std::string const& filename, HistogramRegistry& registry); + + // reset status of all resonances to 0 + void reset(); + void updateStatus(); + + // getters + int nFinals() { return fnFinals; } + std::vector getResonances() { return fResonances; } + resonance* getResonance(std::string name); + resonance* getFinal(int counter); + std::vector getFinals(resonance* res); + std::vector ntrackRange() { return std::vector{fnTracksMin, fnTracksMax}; } + double rgtrTOFMin() { return frgtwtofMin; } + std::vector dBCRange() { return std::vector{fdBCMin, fdBCMax}; } + std::vector FITvetos() { return fFITvetos; } + + void Print(); + + template + decayTreeResType processTree(TTs const& tracks, bool withFill = true) + { + recResType ULSresults; + recResType LSresults; + + // return if nFinals > tracks.size() + if (fnFinals > tracks.size()) { + LOGF(info, "Number of tracks (%d) is smaller than the number of finals (%d)", tracks.size(), fnFinals); + return decayTreeResType{{"ULS", ULSresults}, {"LS", LSresults}}; + } + + // create all possible track combinations including permutations + auto combs = combinations(tracks.size()); + + // a vector to keep track of successful combinations + std::vector goodCombs; + + // loop over possible combinations + LOGF(debug, "New event"); + for (auto& comb : combs) { + std::string scomb(""); + for (const auto& i : comb) { + scomb.append(" ").append(std::to_string(i)); + } + LOGF(debug, " combination:%s", scomb); + + // has an equivalent combination been accepted already? + auto newHash = combHash(comb); + if (std::find(goodCombs.begin(), goodCombs.end(), newHash) != goodCombs.end()) { + LOGF(debug, " Equivalent combination is already accepted!"); + continue; + } + + // loop over resonances and compute + reset(); + for (auto res : fResonances) { + computeResonance(res, tracks, comb); + } + + // check angles between daughters of all resonances + checkAngles(); + + // check status of all resonances + updateStatus(); + if (fStatus >= 2) { + goodCombs.push_back(newHash); + std::map recResonances; + for (const auto& res : fResonances) { + recResonances.insert({res->name(), reconstructedParticle(res->name(), res->IVM(), comb)}); + } + + if (fStatus == 2) { + ULSresults.push_back(recResonances); + } else { + LSresults.push_back(recResonances); + } + } + } + auto results = decayTreeResType{{"ULS", ULSresults}, {"LS", LSresults}}; + if (withFill) { + fillHistograms(results, tracks); + } + return results; + } + +#define getHist(type, name) std::get>(fhistPointers[name]) + template + void fillHistograms(decayTreeResType results, TTs const& tracks) + { + // fill the histograms + std::string base; + std::string hname; + + // results["ULS"] contains the ULS results + // results["LS"] contains the LS results + for (const auto& cc : fccs) { + // result is a std::vector> + for (auto result : results[cc]) { + + // loop over the reconstructed particles + // rec.first: name of the reconstructed particle + // rec.second: reconstructed particle + for (auto rec : result) { + auto lv = rec.second.lv(); + base = cc; + base.append("/").append(rec.first).append("/"); + + hname = base + "mpt"; + getHist(TH2, hname)->Fill(lv.M(), lv.Perp(), 1.); + hname = base + "meta"; + getHist(TH2, hname)->Fill(lv.M(), lv.Eta(), 1.); + hname = base + "pteta"; + getHist(TH2, hname)->Fill(lv.Perp(), lv.Eta(), 1.); + + // M vs daughters + auto res = getResonance(rec.first); + auto daughs = res->getDaughters(); + auto ndaughs = daughs.size(); + for (auto i = 0; i < static_cast(ndaughs); i++) { + auto d1 = getResonance(daughs[i]); + + // M vs pT daughter + hname = base; + hname.append("MvspT_").append(rec.first).append(d1->name()); + getHist(TH2, hname)->Fill(lv.M(), result[d1->name()].lv().Perp(), 1.); + + // M vs eta daughter + hname = base; + hname.append("Mvseta_").append(rec.first).append(d1->name()); + getHist(TH2, hname)->Fill(lv.M(), result[d1->name()].lv().Eta(), 1.); + + if (d1->isFinal()) { + auto tr = tracks.begin() + result[d1->name()].comb()[d1->counter()]; + + // M vs dca + hname = base; + hname.append("MvsdcaXY_").append(rec.first).append(d1->name()); + getHist(TH2, hname)->Fill(lv.M(), tr.dcaXY(), 1.); + hname = base; + hname.append("MvsdcaZ_").append(rec.first).append(d1->name()); + getHist(TH2, hname)->Fill(lv.M(), tr.dcaZ(), 1.); + + // M vs chi2 track + hname = base; + hname.append("Mvschi2_").append(rec.first).append(d1->name()); + getHist(TH2, hname)->Fill(lv.M(), tr.tpcChi2NCl(), 1.); + + // M vs nCl track + hname = base; + hname.append("MvsnCl_").append(rec.first).append(d1->name()); + getHist(TH2, hname)->Fill(lv.M(), tr.tpcNClsFindable() - tr.tpcNClsFindableMinusFound(), 1.); + + // M versus detector hits + hname = base; + hname.append("MvsdetHits_").append(rec.first).append(d1->name()); + auto ind = tr.hasITS() + tr.hasTPC() * 2 + tr.hasTRD() * 4 + tr.hasTOF() * 8; + getHist(TH2, hname)->Fill(lv.M(), ind, 1.); + } else { + // M vs Mi + hname = base; + hname.append("MvsM_").append(rec.first).append(d1->name()); + getHist(TH2, hname)->Fill(lv.M(), result[d1->name()].lv().M(), 1.); + } + } + + // daughters vs daughters + for (auto i = 0; i < static_cast(ndaughs - 1); i++) { + auto d1 = getResonance(daughs[i]); + auto ivm1 = result[daughs[i]].lv(); + for (auto j = i + 1; j < static_cast(ndaughs); j++) { + auto d2 = getResonance(daughs[j]); + auto ivm2 = result[daughs[j]].lv(); + + // M1 vs M2 + hname = base; + hname.append("MvsM_").append(d1->name()).append(d2->name()); + getHist(TH2, hname)->Fill(ivm1.M(), ivm2.M(), 1.); + + // angle(d1, d2) + auto ang = ivm1.Angle(ivm2.Vect()); + hname = base; + hname.append("angle_").append(d1->name()).append(d2->name()); + getHist(TH1, hname)->Fill(ang, 1.); + + // M vs angle(d1, d2) + hname = base; + hname.append("Mvsangle_").append(d1->name()).append(d2->name()); + getHist(TH2, hname)->Fill(lv.M(), ang, 1.); + + // both daughters are finals + if (d1->isFinal() && d2->isFinal()) { + auto tr1 = tracks.begin() + result[d1->name()].comb()[d1->counter()]; + auto tr2 = tracks.begin() + result[d2->name()].comb()[d2->counter()]; + + // TPC signal vs TPC signal + hname = base; + hname.append("TPCsignal_").append(d1->name()).append(d2->name()); + getHist(TH2, hname)->Fill(tr1.tpcSignal(), tr2.tpcSignal(), 1.); + } + } + } + + // finals specific histograms + if (res->isFinal()) { + auto tr = tracks.begin() + rec.second.comb()[res->counter()]; + + // dca XYZ + hname = base; + hname.append("dcaXY"); + getHist(TH1, hname)->Fill(tr.dcaXY(), 1.); + hname = base; + hname.append("dcaZ"); + getHist(TH1, hname)->Fill(tr.dcaZ(), 1.); + + // TPC + hname = base; + hname.append("nS").append(fparts[0]).append(fdets[0]); + getHist(TH2, hname)->Fill(tr.tpcInnerParam(), tr.tpcNSigmaEl(), 1.); + hname = base; + hname.append("nS").append(fparts[1]).append(fdets[0]); + getHist(TH2, hname)->Fill(tr.tpcInnerParam(), tr.tpcNSigmaPi(), 1.); + hname = base; + hname.append("nS").append(fparts[2]).append(fdets[0]); + getHist(TH2, hname)->Fill(tr.tpcInnerParam(), tr.tpcNSigmaMu(), 1.); + hname = base; + hname.append("nS").append(fparts[3]).append(fdets[0]); + getHist(TH2, hname)->Fill(tr.tpcInnerParam(), tr.tpcNSigmaKa(), 1.); + hname = base; + hname.append("nS").append(fparts[4]).append(fdets[0]); + getHist(TH2, hname)->Fill(tr.tpcInnerParam(), tr.tpcNSigmaPr(), 1.); + + // TOF + if (tr.hasTOF()) { + hname = base; + hname.append("nS").append(fparts[0]).append(fdets[1]); + getHist(TH2, hname)->Fill(tr.tofExpMom(), tr.tofNSigmaEl(), 1.); + hname = base; + hname.append("nS").append(fparts[1]).append(fdets[1]); + getHist(TH2, hname)->Fill(tr.tofExpMom(), tr.tofNSigmaPi(), 1.); + hname = base; + hname.append("nS").append(fparts[2]).append(fdets[1]); + getHist(TH2, hname)->Fill(tr.tofExpMom(), tr.tofNSigmaMu(), 1.); + hname = base; + hname.append("nS").append(fparts[3]).append(fdets[1]); + getHist(TH2, hname)->Fill(tr.tofExpMom(), tr.tofNSigmaKa(), 1.); + hname = base; + hname.append("nS").append(fparts[4]).append(fdets[1]); + getHist(TH2, hname)->Fill(tr.tofExpMom(), tr.tofNSigmaPr(), 1.); + } + + // detector hits + hname = base; + hname.append("detectorHits"); + if (tr.hasITS()) { + getHist(TH1, hname)->Fill(1, 1.); + } + if (tr.hasTPC()) { + getHist(TH1, hname)->Fill(2, 1.); + } + if (tr.hasTRD()) { + getHist(TH1, hname)->Fill(3, 1.); + } + if (tr.hasTOF()) { + getHist(TH1, hname)->Fill(4, 1.); + } + } + } + } + } + } + + private: + // decayTree status + // 0: unset + // 1: not accepted + // 2: ULS accepted + // 3: LS accepted + int fStatus; + TDatabasePDG* fPDG; + + // event requierements + int fnTracksMin; + int fnTracksMax; + double frgtwtofMin; + int fdBCMin; + int fdBCMax; + std::vector fFITvetos; + std::vector fULSstates; + std::vector fLSstates; + + // vectors of Resonances + std::vector fResonances; + int fChargeState; + + // number of finals + int fnFinals; + std::vector> fPermutations; + + // histogram registry + std::vector fccs; + std::vector fdets; + std::vector fparts; + std::map fhistPointers; + + // generate parent information for all resonances + void updateParents(); + + // helper functions to compute combinations and permutations + // combination: selection of n out of N + // permutation: order of n selected items + // create all permutations of all combinations + std::size_t combHash(std::vector& comb); + void permutations(std::vector& ref, int n0, int np, std::vector>& perms); + int permutations(int n0, std::vector>& perms); + void combinations(int n0, std::vector& pool, int np, std::vector& inds, int n, + std::vector>& combs); + int combinations(int n0, int np, std::vector>& combs); + std::vector> combinations(int nPool); + + // check all angle requirements + void checkAngles(); + + // compute the charge state + int chargeState(std::vector chs); + void updateChargeState(); + + // templated functions + template + void computeResonance(resonance* res, TTs const& tracks, std::vector& comb) + { + // if status > 0 then return + if (res->status() > 0) { + return; + } + + // initialisations + TLorentzVector ivm{0., 0., 0., 0.}; + int charge = 0; + + // is this a final state or a resonance + if (res->isFinal()) { + // is a final + auto pdgparticle = fPDG->GetParticle(res->pid()); + auto track = (tracks.begin() + comb[res->counter()]); + ivm.SetXYZM(track.px(), track.py(), track.pz(), pdgparticle->Mass()); + res->setIVM(ivm); + res->setCharge(track.sign()); + res->setStatus(1); + + // apply cuts + res->updateStatus(track); + + } else { + // is a resonance + // loop over daughters + for (const auto& daughName : res->getDaughters()) { + auto daugh = getResonance(daughName); + computeResonance(daugh, tracks, comb); + ivm += daugh->IVM(); + charge += daugh->charge(); + } + res->setIVM(ivm); + res->setCharge(charge); + res->setStatus(1); + + // apply cuts + res->updateStatus(); + } + } + + // create histograms + void createHistograms(HistogramRegistry& registry) + { + // definitions + auto etax = AxisSpec(100, -1.5, 1.5); + auto nSax = AxisSpec(300, -15.0, 15.0); + auto chi2ax = AxisSpec(100, 0.0, 5.0); + auto nClax = AxisSpec(170, 0.0, 170.0); + auto angax = AxisSpec(315, 0.0, 3.15); + auto dcaxyax = AxisSpec(400, -0.2, 0.2); + auto dcazax = AxisSpec(600, -0.3, 0.3); + auto sTPCax = AxisSpec(1000, 0., 1000.); + + std::string base; + std::string hname; + std::string annot; + fhistPointers.clear(); + for (const auto& res : getResonances()) { + auto max = AxisSpec(res->nmassBins(), res->massHistRange()[0], res->massHistRange()[1]); + auto momax = AxisSpec(res->nmomBins(), res->momHistRange()[0], res->momHistRange()[1]); + + // M-pT, M-eta, pT-eta + for (const auto& cc : fccs) { + base = cc; + base.append("/").append(res->name()).append("/"); + hname = base + "mpt"; + annot = "M versus pT; M (" + res->name() + ") GeV/c^{2}; pT (" + res->name() + ") GeV/c"; + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, momax}})}); + hname = base + "meta"; + annot = "M versus eta; M (" + res->name() + ") GeV/c^{2}; eta (" + res->name() + ")"; + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, etax}})}); + hname = base + "pteta"; + annot = "pT versus eta; pT (" + res->name() + ") GeV/c; eta (" + res->name() + ")"; + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {momax, etax}})}); + + // M versus daughters + auto daughs = res->getDaughters(); + auto ndaughs = daughs.size(); + for (auto i = 0; i < static_cast(ndaughs); i++) { + auto d1 = getResonance(daughs[i]); + + // M vs pT daughter + hname = base; + hname.append("MvspT_").append(res->name()).append(d1->name()); + annot = "M versus pT; M (" + res->name() + ") GeV/c^{2}; pT (" + d1->name() + ") GeV/c"; + auto momax1 = AxisSpec(d1->nmomBins(), d1->momHistRange()[0], d1->momHistRange()[1]); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, momax1}})}); + + // M vs eta daughter + hname = base; + hname.append("Mvseta_").append(res->name()).append(d1->name()); + annot = "M versus eta; M (" + res->name() + ") GeV/c^{2}; eta (" + d1->name() + ")"; + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, etax}})}); + + if (d1->isFinal()) { + // M vs dcaXYZ + hname = base; + hname.append("MvsdcaXY_").append(res->name()).append(d1->name()); + annot = "M versus dcaXY; M (" + res->name() + ") GeV/c^{2}; dca_{XY} (" + d1->name() + ") #mu m"; + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, dcaxyax}})}); + hname = base; + hname.append("MvsdcaZ_").append(res->name()).append(d1->name()); + annot = "M versus dcaZ; M (" + res->name() + ") GeV/c^{2}; dca_{Z} (" + d1->name() + ") #mu m"; + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, dcazax}})}); + + // M vs chi2 track + hname = base; + hname.append("Mvschi2_").append(res->name()).append(d1->name()); + annot = "M versus chi2; M (" + res->name() + ") GeV/c^{2}; chi2 (" + d1->name() + ")"; + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, chi2ax}})}); + + // M vs nCl track + hname = base; + hname.append("MvsnCl_").append(res->name()).append(d1->name()); + annot = "M versus nCl; M (" + res->name() + ") GeV/c^{2}; nCl (" + d1->name() + ")"; + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, nClax}})}); + + // M versus detector hits + hname = base; + hname.append("MvsdetHits_").append(res->name()).append(d1->name()); + annot = "M versus detector hits; M (" + res->name() + ") GeV/c^{2}; ITS + 2*TPC + 4*TRD + 8*TOF (" + d1->name() + ")"; + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, {16, -0.5, 15.5}}})}); + } else { + // M vs Mi + hname = base; + hname.append("MvsM_").append(res->name()).append(d1->name()); + annot = "M versus M; M (" + res->name() + ") GeV/c^{2}; M (" + d1->name() + ") GeV/c^{2}"; + auto max1 = AxisSpec(res->nmassBins(), d1->massHistRange()[0], d1->massHistRange()[1]); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, max1}})}); + } + } + + // daughters vs daughters + for (auto i = 0; i < static_cast(ndaughs - 1); i++) { + auto d1 = getResonance(daughs[i]); + auto max1 = AxisSpec(d1->nmassBins(), d1->massHistRange()[0], d1->massHistRange()[1]); + for (auto j = i + 1; j < static_cast(ndaughs); j++) { + auto d2 = getResonance(daughs[j]); + auto max2 = AxisSpec(d2->nmassBins(), d2->massHistRange()[0], d2->massHistRange()[1]); + + // M1 vs M2 + hname = base; + hname.append("MvsM_").append(d1->name()).append(d2->name()); + annot = std::string("M versus M; M (").append(d1->name()).append(") GeV/c^{2}; M (").append(d2->name()).append(") GeV/c^{2}"); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max1, max2}})}); + + // angle(d1, d2) + hname = base; + hname.append("angle_").append(d1->name()).append(d2->name()); + annot = std::string("angle; Angle (").append(d1->name()).append(", ").append(d2->name()).append(")"); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH1F, {angax}})}); + + // M vs angle(d1, d2) + hname = base; + hname.append("Mvsangle_").append(d1->name()).append(d2->name()); + annot = std::string("M versus angle; M (").append(res->name()).append(") GeV/c^{2}; Angle (").append(d1->name()).append(", ").append(d2->name()).append(")"); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {max, angax}})}); + + // both daughters are finals + if (d1->isFinal() && d2->isFinal()) { + hname = base; + hname.append("TPCsignal_").append(d1->name()).append(d2->name()); + annot = std::string("TPC signal of both tracks; TPCsignal (").append(d1->name()).append("); TPCsignal (").append(d2->name()).append(")"); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {sTPCax, sTPCax}})}); + } + } + } + + // for finals only + if (res->isFinal()) { + // dca + hname = base; + hname.append("dcaXY"); + annot = std::string("dcaXY; dca_{XY}(").append(res->name()).append(")"); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH1F, {dcaxyax}})}); + hname = base; + hname.append("dcaZ"); + annot = std::string("dcaZ; dca_{Z}(").append(res->name()).append(")"); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH1F, {dcazax}})}); + + // nSIgma[TPC, TOF] vs pT + for (const auto& det : fdets) { + for (const auto& part : fparts) { + hname = base; + hname.append("nS").append(part).append(det); + annot = std::string("nSigma_").append(det).append(" versus p; p (").append(res->name()).append(") GeV/c; nSigma_{").append(det).append(", ").append(part).append("} (").append(res->name()).append(")"); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH2F, {momax, nSax}})}); + } + } + + // detector hits + hname = base; + hname.append("detectorHits"); + annot = std::string("detectorHits; Detector(").append(res->name()).append(")"); + fhistPointers.insert({hname, registry.add(hname.c_str(), annot.c_str(), {HistType::kTH1F, {{4, 0.5, 4.5}}})}); + } + } + } + } + + // ClassDefNV(decayTree, 1); +}; + +#endif // PWGUD_CORE_DECAYTREE_H_ diff --git a/PWGUD/Core/decayTreeLinkDef.h b/PWGUD/Core/decayTreeLinkDef.h new file mode 100644 index 00000000000..92d99ccf1bc --- /dev/null +++ b/PWGUD/Core/decayTreeLinkDef.h @@ -0,0 +1,19 @@ +// 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. +#ifndef PWGUD_CORE_DECAYTREELINKDEF_H_ +#define PWGUD_CORE_DECAYTREELINKDEF_H_ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ class decayTree + ; + +#endif // PWGUD_CORE_DECAYTREELINKDEF_H_ diff --git a/PWGUD/DataModel/TauEventTables.h b/PWGUD/DataModel/TauEventTables.h new file mode 100644 index 00000000000..f508cbc2c4d --- /dev/null +++ b/PWGUD/DataModel/TauEventTables.h @@ -0,0 +1,224 @@ +// 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. + +/// +/// \file TauEventTables.h +/// \author Roman Lavička +/// \since 2025-04-23 +/// \brief A table to store information about events preselected to be candidates for UPC gammagamma->tautau +/// + +#ifndef ALISW_TAUEVENTTABLES_H +#define ALISW_TAUEVENTTABLES_H + +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace tau_tree +{ +// event info +DECLARE_SOA_COLUMN(RunNumber, runNumber, int32_t); +DECLARE_SOA_COLUMN(Bc, bc, int); +DECLARE_SOA_COLUMN(TotalTracks, totalTracks, int); +DECLARE_SOA_COLUMN(NumContrib, numContrib, int); +DECLARE_SOA_COLUMN(GlobalNonPVtracks, globalNonPVtracks, int); +DECLARE_SOA_COLUMN(PosX, posX, float); +DECLARE_SOA_COLUMN(PosY, posY, float); +DECLARE_SOA_COLUMN(PosZ, posZ, float); +DECLARE_SOA_COLUMN(RecoMode, recoMode, int); +DECLARE_SOA_COLUMN(OccupancyInTime, occupancyInTime, int); +DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, double); +DECLARE_SOA_COLUMN(Trs, trs, int); +DECLARE_SOA_COLUMN(Trofs, trofs, int); +DECLARE_SOA_COLUMN(Hmpr, hmpr, int); +DECLARE_SOA_COLUMN(Tfb, tfb, int); +DECLARE_SOA_COLUMN(ItsRofb, itsRofb, int); +DECLARE_SOA_COLUMN(Sbp, sbp, int); +DECLARE_SOA_COLUMN(ZvtxFT0vsPv, zvtxFT0vsPv, int); +DECLARE_SOA_COLUMN(VtxITSTPC, vtxITSTPC, int); +// FIT info +DECLARE_SOA_COLUMN(TotalFT0AmplitudeA, totalFT0AmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFT0AmplitudeC, totalFT0AmplitudeC, float); +DECLARE_SOA_COLUMN(TotalFV0AmplitudeA, totalFV0AmplitudeA, float); +DECLARE_SOA_COLUMN(EnergyCommonZNA, energyCommonZNA, float); +DECLARE_SOA_COLUMN(EnergyCommonZNC, energyCommonZNC, float); +DECLARE_SOA_COLUMN(TimeFT0A, timeFT0A, float); +DECLARE_SOA_COLUMN(TimeFT0C, timeFT0C, float); +DECLARE_SOA_COLUMN(TimeFV0A, timeFV0A, float); +DECLARE_SOA_COLUMN(TimeZNA, timeZNA, float); +DECLARE_SOA_COLUMN(TimeZNC, timeZNC, float); +// tracks +DECLARE_SOA_COLUMN(TrkPx, trkPx, float[2]); +DECLARE_SOA_COLUMN(TrkPy, trkPy, float[2]); +DECLARE_SOA_COLUMN(TrkPz, trkPz, float[2]); +DECLARE_SOA_COLUMN(TrkSign, trkSign, int[2]); +DECLARE_SOA_COLUMN(TrkDCAxy, trkDCAxy, float[2]); +DECLARE_SOA_COLUMN(TrkDCAz, trkDCAz, float[2]); +DECLARE_SOA_COLUMN(TrkTimeRes, trkTimeRes, float[2]); +DECLARE_SOA_COLUMN(Trk1ITSclusterSizes, trk1ITSclusterSizes, uint32_t); +DECLARE_SOA_COLUMN(Trk2ITSclusterSizes, trk2ITSclusterSizes, uint32_t); +DECLARE_SOA_COLUMN(TrkTPCsignal, trkTPCsignal, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaEl, trkTPCnSigmaEl, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaMu, trkTPCnSigmaMu, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaPi, trkTPCnSigmaPi, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaKa, trkTPCnSigmaKa, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaPr, trkTPCnSigmaPr, float[2]); +DECLARE_SOA_COLUMN(TrkTPCinnerParam, trkTPCinnerParam, float[2]); +DECLARE_SOA_COLUMN(TrkTOFsignal, trkTOFsignal, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaEl, trkTOFnSigmaEl, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaMu, trkTOFnSigmaMu, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaPi, trkTOFnSigmaPi, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaKa, trkTOFnSigmaKa, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaPr, trkTOFnSigmaPr, float[2]); +DECLARE_SOA_COLUMN(TrkTOFexpMom, trkTOFexpMom, float[2]); +// truth event +DECLARE_SOA_COLUMN(TrueChannel, trueChannel, int); +DECLARE_SOA_COLUMN(TrueHasRecoColl, trueHasRecoColl, bool); +DECLARE_SOA_COLUMN(TruePosX, truePosX, float); +DECLARE_SOA_COLUMN(TruePosY, truePosY, float); +DECLARE_SOA_COLUMN(TruePosZ, truePosZ, float); +// truth particles +DECLARE_SOA_COLUMN(TrueTauPx, trueTauPx, float[2]); +DECLARE_SOA_COLUMN(TrueTauPy, trueTauPy, float[2]); +DECLARE_SOA_COLUMN(TrueTauPz, trueTauPz, float[2]); +DECLARE_SOA_COLUMN(TrueDaugPx, trueDaugPx, float[2]); +DECLARE_SOA_COLUMN(TrueDaugPy, trueDaugPy, float[2]); +DECLARE_SOA_COLUMN(TrueDaugPz, trueDaugPz, float[2]); +DECLARE_SOA_COLUMN(TrueDaugPdgCode, trueDaugPdgCode, int[2]); +// additional info +DECLARE_SOA_COLUMN(ProblematicEvent, problematicEvent, bool); + +} // namespace tau_tree +DECLARE_SOA_TABLE(TauTwoTracks, "AOD", "TAUTWOTRACK", + tau_tree::RunNumber, + tau_tree::Bc, + tau_tree::TotalTracks, + tau_tree::NumContrib, + tau_tree::GlobalNonPVtracks, + tau_tree::PosX, + tau_tree::PosY, + tau_tree::PosZ, + tau_tree::RecoMode, + tau_tree::OccupancyInTime, + tau_tree::HadronicRate, + tau_tree::Trs, + tau_tree::Trofs, + tau_tree::Hmpr, + tau_tree::Tfb, + tau_tree::ItsRofb, + tau_tree::Sbp, + tau_tree::ZvtxFT0vsPv, + tau_tree::VtxITSTPC, + tau_tree::TotalFT0AmplitudeA, + tau_tree::TotalFT0AmplitudeC, + tau_tree::TotalFV0AmplitudeA, + tau_tree::EnergyCommonZNA, + tau_tree::EnergyCommonZNC, + tau_tree::TimeFT0A, + tau_tree::TimeFT0C, + tau_tree::TimeFV0A, + tau_tree::TimeZNA, + tau_tree::TimeZNC, + tau_tree::TrkPx, + tau_tree::TrkPy, + tau_tree::TrkPz, + tau_tree::TrkSign, + tau_tree::TrkDCAxy, + tau_tree::TrkDCAz, + tau_tree::TrkTimeRes, + tau_tree::Trk1ITSclusterSizes, + tau_tree::Trk2ITSclusterSizes, + tau_tree::TrkTPCsignal, + tau_tree::TrkTPCnSigmaEl, + tau_tree::TrkTPCnSigmaMu, + tau_tree::TrkTPCnSigmaPi, + tau_tree::TrkTPCnSigmaKa, + tau_tree::TrkTPCnSigmaPr, + tau_tree::TrkTPCinnerParam, + tau_tree::TrkTOFsignal, + tau_tree::TrkTOFnSigmaEl, + tau_tree::TrkTOFnSigmaMu, + tau_tree::TrkTOFnSigmaPi, + tau_tree::TrkTOFnSigmaKa, + tau_tree::TrkTOFnSigmaPr, + tau_tree::TrkTOFexpMom); + +DECLARE_SOA_TABLE(TrueTauTwoTracks, "AOD", "TRUETAUTWOTRACK", + tau_tree::RunNumber, + tau_tree::Bc, + tau_tree::TotalTracks, + tau_tree::NumContrib, + tau_tree::GlobalNonPVtracks, + tau_tree::PosX, + tau_tree::PosY, + tau_tree::PosZ, + tau_tree::RecoMode, + tau_tree::OccupancyInTime, + tau_tree::HadronicRate, + tau_tree::Trs, + tau_tree::Trofs, + tau_tree::Hmpr, + tau_tree::Tfb, + tau_tree::ItsRofb, + tau_tree::Sbp, + tau_tree::ZvtxFT0vsPv, + tau_tree::VtxITSTPC, + tau_tree::TotalFT0AmplitudeA, + tau_tree::TotalFT0AmplitudeC, + tau_tree::TotalFV0AmplitudeA, + tau_tree::EnergyCommonZNA, + tau_tree::EnergyCommonZNC, + tau_tree::TimeFT0A, + tau_tree::TimeFT0C, + tau_tree::TimeFV0A, + tau_tree::TimeZNA, + tau_tree::TimeZNC, + tau_tree::TrkPx, + tau_tree::TrkPy, + tau_tree::TrkPz, + tau_tree::TrkSign, + tau_tree::TrkDCAxy, + tau_tree::TrkDCAz, + tau_tree::TrkTimeRes, + tau_tree::Trk1ITSclusterSizes, + tau_tree::Trk2ITSclusterSizes, + tau_tree::TrkTPCsignal, + tau_tree::TrkTPCnSigmaEl, + tau_tree::TrkTPCnSigmaMu, + tau_tree::TrkTPCnSigmaPi, + tau_tree::TrkTPCnSigmaKa, + tau_tree::TrkTPCnSigmaPr, + tau_tree::TrkTPCinnerParam, + tau_tree::TrkTOFsignal, + tau_tree::TrkTOFnSigmaEl, + tau_tree::TrkTOFnSigmaMu, + tau_tree::TrkTOFnSigmaPi, + tau_tree::TrkTOFnSigmaKa, + tau_tree::TrkTOFnSigmaPr, + tau_tree::TrkTOFexpMom, + tau_tree::TrueChannel, + tau_tree::TrueHasRecoColl, + tau_tree::TruePosX, + tau_tree::TruePosY, + tau_tree::TruePosZ, + tau_tree::TrueTauPx, + tau_tree::TrueTauPy, + tau_tree::TrueTauPz, + tau_tree::TrueDaugPx, + tau_tree::TrueDaugPy, + tau_tree::TrueDaugPz, + tau_tree::TrueDaugPdgCode, + tau_tree::ProblematicEvent); + +} // namespace o2::aod + +#endif // ALISW_TAUEVENTTABLES_H diff --git a/PWGUD/DataModel/TwoTracksEventTables.h b/PWGUD/DataModel/TwoTracksEventTables.h new file mode 100644 index 00000000000..73be3f3c438 --- /dev/null +++ b/PWGUD/DataModel/TwoTracksEventTables.h @@ -0,0 +1,226 @@ +// 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. + +/// +/// \file TwoTracksEventTables.h +/// \author Roman Lavička +/// \since 2025-06-20 +/// \brief A table to store information about events preselected to have exactly two tracks. +/// \brief Good for UPC gammagamma (->elel,mumu,tautau) and gammalead (vector mesons) +/// \brief If MC, careful with filling the mother +/// + +#ifndef PWGUD_DATAMODEL_TWOTRACKSEVENTTABLES_H_ +#define PWGUD_DATAMODEL_TWOTRACKSEVENTTABLES_H_ + +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace two_tracks_tree +{ +// event info +DECLARE_SOA_COLUMN(RunNumber, runNumber, int32_t); +DECLARE_SOA_COLUMN(Bc, bc, int); +DECLARE_SOA_COLUMN(TotalTracks, totalTracks, int); +DECLARE_SOA_COLUMN(NumContrib, numContrib, int); +DECLARE_SOA_COLUMN(GlobalNonPVtracks, globalNonPVtracks, int); +DECLARE_SOA_COLUMN(PosX, posX, float); +DECLARE_SOA_COLUMN(PosY, posY, float); +DECLARE_SOA_COLUMN(PosZ, posZ, float); +DECLARE_SOA_COLUMN(RecoMode, recoMode, int); +DECLARE_SOA_COLUMN(OccupancyInTime, occupancyInTime, int); +DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, double); +DECLARE_SOA_COLUMN(Trs, trs, int); +DECLARE_SOA_COLUMN(Trofs, trofs, int); +DECLARE_SOA_COLUMN(Hmpr, hmpr, int); +DECLARE_SOA_COLUMN(Tfb, tfb, int); +DECLARE_SOA_COLUMN(ItsRofb, itsRofb, int); +DECLARE_SOA_COLUMN(Sbp, sbp, int); +DECLARE_SOA_COLUMN(ZvtxFT0vsPv, zvtxFT0vsPv, int); +DECLARE_SOA_COLUMN(VtxITSTPC, vtxITSTPC, int); +// FIT info +DECLARE_SOA_COLUMN(TotalFT0AmplitudeA, totalFT0AmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFT0AmplitudeC, totalFT0AmplitudeC, float); +DECLARE_SOA_COLUMN(TotalFV0AmplitudeA, totalFV0AmplitudeA, float); +DECLARE_SOA_COLUMN(EnergyCommonZNA, energyCommonZNA, float); +DECLARE_SOA_COLUMN(EnergyCommonZNC, energyCommonZNC, float); +DECLARE_SOA_COLUMN(TimeFT0A, timeFT0A, float); +DECLARE_SOA_COLUMN(TimeFT0C, timeFT0C, float); +DECLARE_SOA_COLUMN(TimeFV0A, timeFV0A, float); +DECLARE_SOA_COLUMN(TimeZNA, timeZNA, float); +DECLARE_SOA_COLUMN(TimeZNC, timeZNC, float); +// tracks +DECLARE_SOA_COLUMN(TrkPx, trkPx, float[2]); +DECLARE_SOA_COLUMN(TrkPy, trkPy, float[2]); +DECLARE_SOA_COLUMN(TrkPz, trkPz, float[2]); +DECLARE_SOA_COLUMN(TrkSign, trkSign, int[2]); +DECLARE_SOA_COLUMN(TrkDCAxy, trkDCAxy, float[2]); +DECLARE_SOA_COLUMN(TrkDCAz, trkDCAz, float[2]); +DECLARE_SOA_COLUMN(TrkTimeRes, trkTimeRes, float[2]); +DECLARE_SOA_COLUMN(Trk1ITSclusterSizes, trk1ITSclusterSizes, uint32_t); +DECLARE_SOA_COLUMN(Trk2ITSclusterSizes, trk2ITSclusterSizes, uint32_t); +DECLARE_SOA_COLUMN(TrkTPCsignal, trkTPCsignal, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaEl, trkTPCnSigmaEl, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaMu, trkTPCnSigmaMu, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaPi, trkTPCnSigmaPi, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaKa, trkTPCnSigmaKa, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaPr, trkTPCnSigmaPr, float[2]); +DECLARE_SOA_COLUMN(TrkTPCinnerParam, trkTPCinnerParam, float[2]); +DECLARE_SOA_COLUMN(TrkTOFsignal, trkTOFsignal, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaEl, trkTOFnSigmaEl, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaMu, trkTOFnSigmaMu, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaPi, trkTOFnSigmaPi, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaKa, trkTOFnSigmaKa, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaPr, trkTOFnSigmaPr, float[2]); +DECLARE_SOA_COLUMN(TrkTOFexpMom, trkTOFexpMom, float[2]); +// truth event +DECLARE_SOA_COLUMN(TrueChannel, trueChannel, int); +DECLARE_SOA_COLUMN(TrueHasRecoColl, trueHasRecoColl, bool); +DECLARE_SOA_COLUMN(TruePosX, truePosX, float); +DECLARE_SOA_COLUMN(TruePosY, truePosY, float); +DECLARE_SOA_COLUMN(TruePosZ, truePosZ, float); +// truth particles +DECLARE_SOA_COLUMN(TrueMotherPx, trueMotherPx, float[2]); +DECLARE_SOA_COLUMN(TrueMotherPy, trueMotherPy, float[2]); +DECLARE_SOA_COLUMN(TrueMotherPz, trueMotherPz, float[2]); +DECLARE_SOA_COLUMN(TrueDaugPx, trueDaugPx, float[2]); +DECLARE_SOA_COLUMN(TrueDaugPy, trueDaugPy, float[2]); +DECLARE_SOA_COLUMN(TrueDaugPz, trueDaugPz, float[2]); +DECLARE_SOA_COLUMN(TrueDaugPdgCode, trueDaugPdgCode, int[2]); +// additional info +DECLARE_SOA_COLUMN(ProblematicEvent, problematicEvent, bool); + +} // namespace two_tracks_tree +DECLARE_SOA_TABLE(TwoTracks, "AOD", "TWOTRACK", + two_tracks_tree::RunNumber, + two_tracks_tree::Bc, + two_tracks_tree::TotalTracks, + two_tracks_tree::NumContrib, + two_tracks_tree::GlobalNonPVtracks, + two_tracks_tree::PosX, + two_tracks_tree::PosY, + two_tracks_tree::PosZ, + two_tracks_tree::RecoMode, + two_tracks_tree::OccupancyInTime, + two_tracks_tree::HadronicRate, + two_tracks_tree::Trs, + two_tracks_tree::Trofs, + two_tracks_tree::Hmpr, + two_tracks_tree::Tfb, + two_tracks_tree::ItsRofb, + two_tracks_tree::Sbp, + two_tracks_tree::ZvtxFT0vsPv, + two_tracks_tree::VtxITSTPC, + two_tracks_tree::TotalFT0AmplitudeA, + two_tracks_tree::TotalFT0AmplitudeC, + two_tracks_tree::TotalFV0AmplitudeA, + two_tracks_tree::EnergyCommonZNA, + two_tracks_tree::EnergyCommonZNC, + two_tracks_tree::TimeFT0A, + two_tracks_tree::TimeFT0C, + two_tracks_tree::TimeFV0A, + two_tracks_tree::TimeZNA, + two_tracks_tree::TimeZNC, + two_tracks_tree::TrkPx, + two_tracks_tree::TrkPy, + two_tracks_tree::TrkPz, + two_tracks_tree::TrkSign, + two_tracks_tree::TrkDCAxy, + two_tracks_tree::TrkDCAz, + two_tracks_tree::TrkTimeRes, + two_tracks_tree::Trk1ITSclusterSizes, + two_tracks_tree::Trk2ITSclusterSizes, + two_tracks_tree::TrkTPCsignal, + two_tracks_tree::TrkTPCnSigmaEl, + two_tracks_tree::TrkTPCnSigmaMu, + two_tracks_tree::TrkTPCnSigmaPi, + two_tracks_tree::TrkTPCnSigmaKa, + two_tracks_tree::TrkTPCnSigmaPr, + two_tracks_tree::TrkTPCinnerParam, + two_tracks_tree::TrkTOFsignal, + two_tracks_tree::TrkTOFnSigmaEl, + two_tracks_tree::TrkTOFnSigmaMu, + two_tracks_tree::TrkTOFnSigmaPi, + two_tracks_tree::TrkTOFnSigmaKa, + two_tracks_tree::TrkTOFnSigmaPr, + two_tracks_tree::TrkTOFexpMom); + +DECLARE_SOA_TABLE(TrueTwoTracks, "AOD", "TRUETWOTRACK", + two_tracks_tree::RunNumber, + two_tracks_tree::Bc, + two_tracks_tree::TotalTracks, + two_tracks_tree::NumContrib, + two_tracks_tree::GlobalNonPVtracks, + two_tracks_tree::PosX, + two_tracks_tree::PosY, + two_tracks_tree::PosZ, + two_tracks_tree::RecoMode, + two_tracks_tree::OccupancyInTime, + two_tracks_tree::HadronicRate, + two_tracks_tree::Trs, + two_tracks_tree::Trofs, + two_tracks_tree::Hmpr, + two_tracks_tree::Tfb, + two_tracks_tree::ItsRofb, + two_tracks_tree::Sbp, + two_tracks_tree::ZvtxFT0vsPv, + two_tracks_tree::VtxITSTPC, + two_tracks_tree::TotalFT0AmplitudeA, + two_tracks_tree::TotalFT0AmplitudeC, + two_tracks_tree::TotalFV0AmplitudeA, + two_tracks_tree::EnergyCommonZNA, + two_tracks_tree::EnergyCommonZNC, + two_tracks_tree::TimeFT0A, + two_tracks_tree::TimeFT0C, + two_tracks_tree::TimeFV0A, + two_tracks_tree::TimeZNA, + two_tracks_tree::TimeZNC, + two_tracks_tree::TrkPx, + two_tracks_tree::TrkPy, + two_tracks_tree::TrkPz, + two_tracks_tree::TrkSign, + two_tracks_tree::TrkDCAxy, + two_tracks_tree::TrkDCAz, + two_tracks_tree::TrkTimeRes, + two_tracks_tree::Trk1ITSclusterSizes, + two_tracks_tree::Trk2ITSclusterSizes, + two_tracks_tree::TrkTPCsignal, + two_tracks_tree::TrkTPCnSigmaEl, + two_tracks_tree::TrkTPCnSigmaMu, + two_tracks_tree::TrkTPCnSigmaPi, + two_tracks_tree::TrkTPCnSigmaKa, + two_tracks_tree::TrkTPCnSigmaPr, + two_tracks_tree::TrkTPCinnerParam, + two_tracks_tree::TrkTOFsignal, + two_tracks_tree::TrkTOFnSigmaEl, + two_tracks_tree::TrkTOFnSigmaMu, + two_tracks_tree::TrkTOFnSigmaPi, + two_tracks_tree::TrkTOFnSigmaKa, + two_tracks_tree::TrkTOFnSigmaPr, + two_tracks_tree::TrkTOFexpMom, + two_tracks_tree::TrueChannel, + two_tracks_tree::TrueHasRecoColl, + two_tracks_tree::TruePosX, + two_tracks_tree::TruePosY, + two_tracks_tree::TruePosZ, + two_tracks_tree::TrueMotherPx, + two_tracks_tree::TrueMotherPy, + two_tracks_tree::TrueMotherPz, + two_tracks_tree::TrueDaugPx, + two_tracks_tree::TrueDaugPy, + two_tracks_tree::TrueDaugPz, + two_tracks_tree::TrueDaugPdgCode, + two_tracks_tree::ProblematicEvent); + +} // namespace o2::aod + +#endif // PWGUD_DATAMODEL_TWOTRACKSEVENTTABLES_H_ diff --git a/PWGUD/DataModel/UDIndex.h b/PWGUD/DataModel/UDIndex.h new file mode 100644 index 00000000000..5fdfb0596e6 --- /dev/null +++ b/PWGUD/DataModel/UDIndex.h @@ -0,0 +1,33 @@ +// 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. + +/// +/// \file UDIndex.h +/// \author Roman Lavička +/// \since 2025-04-15 +/// \brief A table to store indices for association of MC truth to MC reco +/// + +#ifndef PWGUD_DATAMODEL_UDINDEX_H_ +#define PWGUD_DATAMODEL_UDINDEX_H_ + +#include "Framework/AnalysisDataModel.h" +namespace o2::aod +{ +namespace udidx +{ +DECLARE_SOA_ARRAY_INDEX_COLUMN(UDTrack, udtracks); +DECLARE_SOA_ARRAY_INDEX_COLUMN(UDCollision, udcollisions); +} // namespace udidx +DECLARE_SOA_TABLE(UDMcParticlesToUDTracks, "AOD", "UDP2UDT", udidx::UDTrackIds); +DECLARE_SOA_TABLE(UDMcCollisionsToUDCollisions, "AOD", "UDMCC2UDC", udidx::UDCollisionIds); +} // namespace o2::aod +#endif // PWGUD_DATAMODEL_UDINDEX_H_ diff --git a/PWGUD/DataModel/UDTables.h b/PWGUD/DataModel/UDTables.h index b3f1f2354a2..8a4251ec74d 100644 --- a/PWGUD/DataModel/UDTables.h +++ b/PWGUD/DataModel/UDTables.h @@ -8,18 +8,29 @@ // 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. +// +/// \file UDTables.h +/// \brief Defines tables and colums for derived data used by UD group +/// \author Paul Buhler , Wiena +/// \since January 2023 +/// \author Sasha Bylinkin , Bergen +/// \since January 2024 +/// \author Adam Matyja , INP PAN Krakow, Poland +/// \since May 2025 #ifndef PWGUD_DATAMODEL_UDTABLES_H_ #define PWGUD_DATAMODEL_UDTABLES_H_ -#include -#include +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" #include "Framework/DataTypes.h" #include "MathUtils/Utils.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include namespace o2::aod { @@ -106,6 +117,15 @@ DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, double); DECLARE_SOA_COLUMN(Trs, trs, int); DECLARE_SOA_COLUMN(Trofs, trofs, int); DECLARE_SOA_COLUMN(Hmpr, hmpr, int); +DECLARE_SOA_COLUMN(TFb, tfb, int); +DECLARE_SOA_COLUMN(ITSROFb, itsROFb, int); +DECLARE_SOA_COLUMN(Sbp, sbp, int); +DECLARE_SOA_COLUMN(ZvtxFT0vPV, zVtxFT0vPV, int); +DECLARE_SOA_COLUMN(VtxITSTPC, vtxITSTPC, int); +// information about mask names -> Common/CCDB/RCTSelectionFlags.h +// DECLARE_SOA_COLUMN(Rct, rct, uint32_t); //! run condition table mask +DECLARE_SOA_BITMAP_COLUMN(Rct, rct, 32); //! run condition table mask + // Gap Side Information DECLARE_SOA_COLUMN(GapSide, gapSide, uint8_t); // 0 for side A, 1 for side C, 2 for both sides (or use an enum for better readability) // FIT selection flags @@ -223,9 +243,44 @@ DECLARE_SOA_TABLE_VERSIONED(UDCollisionSelExtras_001, "AOD", "UDCOLSELEXTRA", 1, udcollision::ChFV0A, //! number of active channels in FV0A udcollision::OccupancyInTime, //! Occupancy udcollision::HadronicRate, //! Interaction Rate - udcollision::Trs, - udcollision::Trofs, - udcollision::Hmpr); + udcollision::Trs, //! kNoCollInTimeRangeStandard + udcollision::Trofs, //! kNoCollInRofStandard + udcollision::Hmpr); //! kNoHighMultCollInPrevRof + +DECLARE_SOA_TABLE_VERSIONED(UDCollisionSelExtras_002, "AOD", "UDCOLSELEXTRA", 2, + udcollision::ChFT0A, //! number of active channels in FT0A + udcollision::ChFT0C, //! number of active channels in FT0C + udcollision::ChFDDA, //! number of active channels in FDDA + udcollision::ChFDDC, //! number of active channels in FDDC + udcollision::ChFV0A, //! number of active channels in FV0A + udcollision::OccupancyInTime, //! Occupancy + udcollision::HadronicRate, //! Interaction Rate + udcollision::Trs, //! kNoCollInTimeRangeStandard + udcollision::Trofs, //! kNoCollInRofStandard + udcollision::Hmpr, //! kNoHighMultCollInPrevRof + udcollision::TFb, //! kNoTimeFrameBorder + udcollision::ITSROFb, //! kNoITSROFrameBorder + udcollision::Sbp, //! kNoSameBunchPileup + udcollision::ZvtxFT0vPV, //! kIsGoodZvtxFT0vsPV + udcollision::VtxITSTPC); //! kIsVertexITSTPC + +DECLARE_SOA_TABLE_VERSIONED(UDCollisionSelExtras_003, "AOD", "UDCOLSELEXTRA", 3, + udcollision::ChFT0A, //! number of active channels in FT0A + udcollision::ChFT0C, //! number of active channels in FT0C + udcollision::ChFDDA, //! number of active channels in FDDA + udcollision::ChFDDC, //! number of active channels in FDDC + udcollision::ChFV0A, //! number of active channels in FV0A + udcollision::OccupancyInTime, //! Occupancy + udcollision::HadronicRate, //! Interaction Rate + udcollision::Trs, //! kNoCollInTimeRangeStandard + udcollision::Trofs, //! kNoCollInRofStandard + udcollision::Hmpr, //! kNoHighMultCollInPrevRof + udcollision::TFb, //! kNoTimeFrameBorder + udcollision::ITSROFb, //! kNoITSROFrameBorder + udcollision::Sbp, //! kNoSameBunchPileup + udcollision::ZvtxFT0vPV, //! kIsGoodZvtxFT0vsPV + udcollision::VtxITSTPC, //! kIsVertexITSTPC + udcollision::Rct); //! RCT mask // central barrel-specific selections DECLARE_SOA_TABLE(UDCollisionsSelsCent, "AOD", "UDCOLSELCNT", @@ -250,7 +305,7 @@ DECLARE_SOA_TABLE(UDMcCollsLabels, "AOD", "UDMCCOLLSLABEL", udcollision::UDMcCollisionId); using UDCollisions = UDCollisions_001; -using UDCollisionSelExtras = UDCollisionSelExtras_001; +using UDCollisionSelExtras = UDCollisionSelExtras_003; using UDCollision = UDCollisions::iterator; using SGCollision = SGCollisions::iterator; diff --git a/PWGUD/TableProducer/CMakeLists.txt b/PWGUD/TableProducer/CMakeLists.txt index cc9943b366d..548b052e667 100644 --- a/PWGUD/TableProducer/CMakeLists.txt +++ b/PWGUD/TableProducer/CMakeLists.txt @@ -13,7 +13,7 @@ add_subdirectory(Converters) o2physics_add_dpl_workflow(dgcand-producer SOURCES DGCandProducer.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGCutparHolder O2Physics::AnalysisCCDB + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGCutparHolder O2Physics::EventFilteringUtils O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(sgcand-producer @@ -31,7 +31,27 @@ o2physics_add_dpl_workflow(upccand-producer PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::UPCCutparHolder COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(tau-event-table-producer + SOURCES tauEventTableProducer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(two-tracks-event-table-producer + SOURCES twoTracksEventTableProducer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(fwdtrack-propagation - SOURCES fwdTrackPropagation.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::GlobalTracking - COMPONENT_NAME Analysis) + SOURCES fwdTrackPropagation.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::GlobalTracking + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(udmcparticles-to-udtracks + SOURCES udMcParticles2udTracks.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(udmccollisions-to-udcollisions + SOURCES udMcCollisions2udCollisions.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGUD/TableProducer/Converters/CMakeLists.txt b/PWGUD/TableProducer/Converters/CMakeLists.txt index 55267c0785b..7d5a6297ba1 100644 --- a/PWGUD/TableProducer/Converters/CMakeLists.txt +++ b/PWGUD/TableProducer/Converters/CMakeLists.txt @@ -24,3 +24,13 @@ o2physics_add_dpl_workflow(collisionselextras-converter SOURCES UDCollisionSelExtrasConverter.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(collisionselextras-converter-v002 + SOURCES UDCollisionSelExtrasV002Converter.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(collisionselextras-converter-v003 + SOURCES UDCollisionSelExtrasV003Converter.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGUD/TableProducer/Converters/UDCollisionSelExtrasV002Converter.cxx b/PWGUD/TableProducer/Converters/UDCollisionSelExtrasV002Converter.cxx new file mode 100644 index 00000000000..b10b467ec4d --- /dev/null +++ b/PWGUD/TableProducer/Converters/UDCollisionSelExtrasV002Converter.cxx @@ -0,0 +1,98 @@ +// 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. + +/// \file UDCollisionSelExtrasV002Converter.cxx +/// \brief Converts UDCollisionSelExtras table from version 000 to 002 and 001 to 002 +/// \author Roman Lavicka + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "PWGUD/DataModel/UDTables.h" + +using namespace o2; +using namespace o2::framework; + +// Converts UDCollisions for version 000 to 002 and 001 to 002 +struct UDCollisionSelExtrasV002Converter { + Produces udCollisionSelExtras_002; + + void init(InitContext const&) + { + if (!doprocessV000ToV002 && !doprocessV001ToV002) { + LOGF(fatal, "Neither processV000ToV002 nor processV001ToV002 is enabled. Please choose one!"); + } + if (doprocessV000ToV002 && doprocessV001ToV002) { + LOGF(fatal, "Both processV000ToV002 and processV001ToV002 are enabled. Please choose only one!"); + } + } + + void processV000ToV002(o2::aod::UDCollisionSelExtras_000 const& collisions) + { + + for (const auto& collision : collisions) { + + udCollisionSelExtras_002(collision.chFT0A(), + collision.chFT0C(), + collision.chFDDA(), + collision.chFDDC(), + collision.chFV0A(), + 0, // dummy occupancy + 0.0f, // dummy rate + 0, // dummy trs + 0, // dummy trofs + 0, // dummy hmpr + 0, // dummy tfb + 0, // dummy itsROFb + 0, // dummy sbp + 0, // dummy zVtxFT0vPV + 0); // dummy vtxITSTPC + } + } + PROCESS_SWITCH(UDCollisionSelExtrasV002Converter, processV000ToV002, "process v000-to-v002 conversion", false); + + void processV001ToV002(o2::aod::UDCollisionSelExtras_001 const& collisions) + { + + for (const auto& collision : collisions) { + + udCollisionSelExtras_002(collision.chFT0A(), + collision.chFT0C(), + collision.chFDDA(), + collision.chFDDC(), + collision.chFV0A(), + collision.occupancyInTime(), + collision.hadronicRate(), + collision.trs(), + collision.trofs(), + collision.hmpr(), + 0, // dummy tfb + 0, // dummy itsROFb + 0, // dummy sbp + 0, // dummy zVtxFT0vPV + 0); // dummy vtxITSTPC + } + } + PROCESS_SWITCH(UDCollisionSelExtrasV002Converter, processV001ToV002, "process v001-to-v002 conversion", true); +}; + +/// Spawn the extended table for UDCollisionSelExtras002 to avoid the call to the internal spawner and a consequent circular dependency +// struct UDCollisionSelExtrasSpawner { +// Spawns udCollisionSelExtras_002; +// }; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGUD/TableProducer/Converters/UDCollisionSelExtrasV003Converter.cxx b/PWGUD/TableProducer/Converters/UDCollisionSelExtrasV003Converter.cxx new file mode 100644 index 00000000000..a41b2c4efa6 --- /dev/null +++ b/PWGUD/TableProducer/Converters/UDCollisionSelExtrasV003Converter.cxx @@ -0,0 +1,126 @@ +// 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. + +/// \file UDCollisionSelExtrasV003Converter.cxx +/// \brief Converts UDCollisionSelExtras table from version 000 to 003 and 001 to 003 and 002 to 003 +/// \author Adam Matyja + +#include "PWGUD/DataModel/UDTables.h" + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +using namespace o2; +using namespace o2::framework; + +// Converts UDCollisions for version 000 to 003 and 001 to 003 and 002 to 003 +struct UDCollisionSelExtrasV003Converter { + Produces udCollisionSelExtras_003; + + void init(InitContext const&) + { + if (!doprocessV000ToV003 && !doprocessV001ToV003 && !doprocessV002ToV003) { + LOGF(fatal, "Neither processV000ToV003 nor processV001ToV003 nor processV002ToV003 is enabled. Please choose one!"); + } + if (static_cast(doprocessV000ToV003) + static_cast(doprocessV001ToV003) + static_cast(doprocessV002ToV003) > 1) { + LOGF(fatal, "More than one among processV000ToV003, processV001ToV003, processV002ToV003 is enabled. Please choose only one!"); + } + } + + void processV000ToV003(o2::aod::UDCollisionSelExtras_000 const& collisions) + { + + for (const auto& collision : collisions) { + + udCollisionSelExtras_003(collision.chFT0A(), + collision.chFT0C(), + collision.chFDDA(), + collision.chFDDC(), + collision.chFV0A(), + 0, // dummy occupancy + 0.0f, // dummy rate + 0, // dummy trs + 0, // dummy trofs + 0, // dummy hmpr + 0, // dummy tfb + 0, // dummy itsROFb + 0, // dummy sbp + 0, // dummy zVtxFT0vPV + 0, // dummy vtxITSTPC + 0); // dummy rct + } + } + PROCESS_SWITCH(UDCollisionSelExtrasV003Converter, processV000ToV003, "process v000-to-v003 conversion", false); + + void processV001ToV003(o2::aod::UDCollisionSelExtras_001 const& collisions) + { + + for (const auto& collision : collisions) { + + udCollisionSelExtras_003(collision.chFT0A(), + collision.chFT0C(), + collision.chFDDA(), + collision.chFDDC(), + collision.chFV0A(), + collision.occupancyInTime(), + collision.hadronicRate(), + collision.trs(), + collision.trofs(), + collision.hmpr(), + 0, // dummy tfb + 0, // dummy itsROFb + 0, // dummy sbp + 0, // dummy zVtxFT0vPV + 0, // dummy vtxITSTPC + 0); // dummy rct + } + } + PROCESS_SWITCH(UDCollisionSelExtrasV003Converter, processV001ToV003, "process v001-to-v003 conversion", false); + + void processV002ToV003(o2::aod::UDCollisionSelExtras_002 const& collisions) + { + + for (const auto& collision : collisions) { + + udCollisionSelExtras_003(collision.chFT0A(), + collision.chFT0C(), + collision.chFDDA(), + collision.chFDDC(), + collision.chFV0A(), + collision.occupancyInTime(), + collision.hadronicRate(), + collision.trs(), + collision.trofs(), + collision.hmpr(), + collision.tfb(), + collision.itsROFb(), + collision.sbp(), + collision.zVtxFT0vPV(), + collision.vtxITSTPC(), + 0); // dummy rct + } + } + PROCESS_SWITCH(UDCollisionSelExtrasV003Converter, processV002ToV003, "process v002-to-v003 conversion", true); +}; + +/// Spawn the extended table for UDCollisionSelExtras003 to avoid the call to the internal spawner and a consequent circular dependency +// struct UDCollisionSelExtrasSpawner { +// Spawns udCollisionSelExtras_003; +// }; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGUD/TableProducer/DGCandProducer.cxx b/PWGUD/TableProducer/DGCandProducer.cxx index f7c9ff038ec..84c892f5660 100644 --- a/PWGUD/TableProducer/DGCandProducer.cxx +++ b/PWGUD/TableProducer/DGCandProducer.cxx @@ -12,34 +12,31 @@ // \brief Saves relevant information of DG candidates // \author Paul Buehler, paul.buehler@oeaw.ac.at -#include -#include -#include +#include "PWGUD/Core/DGSelector.h" +#include "PWGUD/Core/UPCHelpers.h" +#include "PWGUD/DataModel/UDTables.h" + +#include "Common/CCDB/ctpRateFetcher.h" +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + #include "CCDB/BasicCCDBManager.h" -#include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Vertex.h" -#include "Common/CCDB/ctpRateFetcher.h" -#include "PWGUD/DataModel/UDTables.h" -#include "PWGUD/Core/UPCHelpers.h" -#include "PWGUD/Core/DGSelector.h" + +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -struct DGCandProducer { - Service ccdb; - ctpRateFetcher mRateFetcher; - // get a DGCutparHolder - DGCutparHolder diffCuts = DGCutparHolder(); - Configurable DGCuts{"DGCuts", {}, "DG event cuts"}; - Configurable saveAllTracks{"saveAllTracks", true, "save only PV contributors or all tracks associated to a collision"}; - Configurable fillFIThistos{"fillFIThistos", false, "fill the histograms with the FIT amplitudes"}; - - // DG selector - DGSelector dgSelector; +#define getHist(type, name) std::get>(histPointers[name]) +struct DGCandProducer { // data tables Produces outputCollisions; Produces outputCollisionsSels; @@ -57,10 +54,33 @@ struct DGCandProducer { Produces outputFwdTracksExtra; Produces outputTracksLabel; + // get a DGCutparHolder + DGCutparHolder diffCuts = DGCutparHolder(); + Configurable DGCuts{"DGCuts", {}, "DG event cuts"}; + + // DG selector + DGSelector dgSelector; + + // configurables + Configurable saveAllTracks{"saveAllTracks", true, "save only PV contributors or all tracks associated to a collision"}; + Configurable> generatorIds{"generatorIds", std::vector{-1}, "MC generatorIds to process"}; + + // zorro object + int mRunNumber; + Service ccdb; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + Configurable cfgCCDBurl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable cfgZorroCCDBpath{"cfgZorroCCDBpath", "/Users/m/mpuccio/EventFiltering/OTS/", "path to the zorro ccdb objects"}; + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "Skimmed dataset processing"}; + Configurable triggerName{"triggerName", "fUDiff,fUDdiffSmall,fUDiffLarge", "Name of the software trigger"}; + + // ctpRateFetcher + ctpRateFetcher mRateFetcher; + // initialize histogram registry - HistogramRegistry registry{ - "registry", - {}}; + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + std::map histPointers; // data inputs using CCs = soa::Join; @@ -73,6 +93,9 @@ struct DGCandProducer { aod::pidTOFFullEl, aod::pidTOFFullMu, aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; using FWs = aod::FwdTracks; + using MCCCs = soa::Join; + using MCCC = MCCCs::iterator; + // function to update UDFwdTracks, UDFwdTracksExtra template void updateUDFwdTrackTables(TFwdTrack const& fwdtrack, uint64_t const& bcnum) @@ -142,8 +165,54 @@ struct DGCandProducer { outputTracksLabel(track.globalIndex()); } + void createHistograms(std::string histdir) + { + const int nXbinsInStatH = 26; + std::string labels[nXbinsInStatH] = { + "all", "hasBC", "zorro", "accepted", "FITveto", "MID trk", "global not PV trk", "not global PV trk", + "ITS-only PV trk", "TOF PV trk fraction", "n PV trks", "PID", "pt", "eta", "net charge", + "inv mass", "evsel TF border", "evsel no pile-up", "evsel ITSROF", "evsel z-vtx", "evsel ITSTPC vtx", + "evsel TRD vtx", "evsel TOF vtx", "", "", ""}; + + std::string hname = histdir + "/Stat"; + histPointers.insert({hname, registry.add(hname.c_str(), "Cut statistics, Collisions", {HistType::kTH1F, {{nXbinsInStatH, -0.5, static_cast(nXbinsInStatH - 0.5)}}})}); + getHist(TH1, hname)->SetNdivisions(nXbinsInStatH, "X"); + for (int iXbin(1); iXbin < nXbinsInStatH + 1; iXbin++) { + getHist(TH1, hname)->GetXaxis()->ChangeLabel(iXbin, 45, 0.03, 33, -1, -1, labels[iXbin - 1]); + } + + hname = histdir + "/pt1Vspt2"; + histPointers.insert({hname, registry.add(hname.c_str(), "2 prong events, p_{T} versus p_{T}", {HistType::kTH2F, {{100, -3., 3.}, {100, -3., 3.0}}})}); + hname = histdir + "/TPCsignal1"; + histPointers.insert({hname, registry.add(hname.c_str(), "2 prong events, TPC signal versus p_{T} of particle 1", {HistType::kTH2F, {{200, -3., 3.}, {200, 0., 100.0}}})}); + hname = histdir + "/TPCsignal2"; + histPointers.insert({hname, registry.add(hname.c_str(), "2 prong events, TPC signal versus p_{T} of particle 2", {HistType::kTH2F, {{200, -3., 3.}, {200, 0., 100.0}}})}); + hname = histdir + "/sig1VsSig2TPC"; + histPointers.insert({hname, registry.add(hname.c_str(), "2 prong events, TPC signal versus TPC signal", {HistType::kTH2F, {{100, 0., 100.}, {100, 0., 100.}}})}); + + // FIT amplitudes + // 0: unconditional + // 1: TOR 5: no TOR + // 2: TVX 6: no TVX + // 3: TSC 7: no TSC + // 4: TCE 8: no TCE + // 9: IsBBXXX 10: !IsBBXXX + // 11: kNoBGXXX 12: !kNoBGXXX + const int nXbinsFITH = 201; + hname = histdir + "/fv0"; + histPointers.insert({hname, registry.add(hname.c_str(), "FV0 amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}})}); + hname = histdir + "/ft0A"; + histPointers.insert({hname, registry.add(hname.c_str(), "FT0A amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}})}); + hname = histdir + "/ft0C"; + histPointers.insert({hname, registry.add(hname.c_str(), "FT0C amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}})}); + hname = histdir + "/fddA"; + histPointers.insert({hname, registry.add(hname.c_str(), "FDDA amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}})}); + hname = histdir + "/fddC"; + histPointers.insert({hname, registry.add(hname.c_str(), "FDDC amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}})}); + } + template - void fillFIThistograms(TBC const& bc) + void fillFIThistograms(TBC const& bc, std::string histdir) { LOGF(debug, ""); std::array triggers{{true, !udhelpers::cleanFIT(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()), @@ -152,126 +221,80 @@ struct DGCandProducer { if (bc.has_foundFV0()) { auto fv0 = bc.foundFV0(); auto ampA = udhelpers::FV0AmplitudeA(fv0); - registry.get(HIST("reco/fv0"))->Fill(ampA, 0); - registry.get(HIST("reco/fv0"))->Fill(ampA, triggers[1] ? 1 : 5); - registry.get(HIST("reco/fv0"))->Fill(ampA, triggers[2] ? 2 : 6); - registry.get(HIST("reco/fv0"))->Fill(ampA, triggers[3] ? 3 : 7); - registry.get(HIST("reco/fv0"))->Fill(ampA, triggers[4] ? 4 : 8); - registry.get(HIST("reco/fv0"))->Fill(ampA, bc.selection_bit(o2::aod::evsel::kIsBBV0A) ? 9 : 10); - registry.get(HIST("reco/fv0"))->Fill(ampA, bc.selection_bit(o2::aod::evsel::kNoBGV0A) ? 11 : 12); + getHist(TH2, histdir + "/fv0")->Fill(ampA, 0); + getHist(TH2, histdir + "/fv0")->Fill(ampA, triggers[1] ? 1 : 5); + getHist(TH2, histdir + "/fv0")->Fill(ampA, triggers[2] ? 2 : 6); + getHist(TH2, histdir + "/fv0")->Fill(ampA, triggers[3] ? 3 : 7); + getHist(TH2, histdir + "/fv0")->Fill(ampA, triggers[4] ? 4 : 8); + getHist(TH2, histdir + "/fv0")->Fill(ampA, bc.selection_bit(o2::aod::evsel::kIsBBV0A) ? 9 : 10); + getHist(TH2, histdir + "/fv0")->Fill(ampA, bc.selection_bit(o2::aod::evsel::kNoBGV0A) ? 11 : 12); } if (bc.has_foundFT0()) { auto ft0 = bc.foundFT0(); auto ampA = udhelpers::FT0AmplitudeA(ft0); auto ampC = udhelpers::FT0AmplitudeC(ft0); - registry.get(HIST("reco/ft0A"))->Fill(ampA, 0); - registry.get(HIST("reco/ft0C"))->Fill(ampC, 0); - registry.get(HIST("reco/ft0A"))->Fill(ampA, triggers[1] ? 1 : 5); - registry.get(HIST("reco/ft0C"))->Fill(ampC, triggers[1] ? 1 : 5); - registry.get(HIST("reco/ft0A"))->Fill(ampA, triggers[2] ? 2 : 6); - registry.get(HIST("reco/ft0C"))->Fill(ampC, triggers[2] ? 2 : 6); - registry.get(HIST("reco/ft0A"))->Fill(ampA, triggers[3] ? 3 : 7); - registry.get(HIST("reco/ft0C"))->Fill(ampC, triggers[3] ? 3 : 7); - registry.get(HIST("reco/ft0A"))->Fill(ampA, triggers[4] ? 4 : 8); - registry.get(HIST("reco/ft0C"))->Fill(ampC, triggers[4] ? 4 : 8); - registry.get(HIST("reco/ft0A"))->Fill(ampA, bc.selection_bit(o2::aod::evsel::kIsBBT0A) ? 9 : 10); - registry.get(HIST("reco/ft0C"))->Fill(ampC, bc.selection_bit(o2::aod::evsel::kIsBBT0C) ? 9 : 10); - registry.get(HIST("reco/ft0A"))->Fill(ampA, bc.selection_bit(o2::aod::evsel::kNoBGT0A) ? 11 : 12); - registry.get(HIST("reco/ft0C"))->Fill(ampC, bc.selection_bit(o2::aod::evsel::kNoBGT0C) ? 11 : 12); + getHist(TH2, histdir + "/ft0A")->Fill(ampA, 0); + getHist(TH2, histdir + "/ft0C")->Fill(ampC, 0); + getHist(TH2, histdir + "/ft0A")->Fill(ampA, triggers[1] ? 1 : 5); + getHist(TH2, histdir + "/ft0C")->Fill(ampC, triggers[1] ? 1 : 5); + getHist(TH2, histdir + "/ft0A")->Fill(ampA, triggers[2] ? 2 : 6); + getHist(TH2, histdir + "/ft0C")->Fill(ampC, triggers[2] ? 2 : 6); + getHist(TH2, histdir + "/ft0A")->Fill(ampA, triggers[3] ? 3 : 7); + getHist(TH2, histdir + "/ft0C")->Fill(ampC, triggers[3] ? 3 : 7); + getHist(TH2, histdir + "/ft0A")->Fill(ampA, triggers[4] ? 4 : 8); + getHist(TH2, histdir + "/ft0C")->Fill(ampC, triggers[4] ? 4 : 8); + getHist(TH2, histdir + "/ft0A")->Fill(ampA, bc.selection_bit(o2::aod::evsel::kIsBBT0A) ? 9 : 10); + getHist(TH2, histdir + "/ft0C")->Fill(ampC, bc.selection_bit(o2::aod::evsel::kIsBBT0C) ? 9 : 10); + getHist(TH2, histdir + "/ft0A")->Fill(ampA, bc.selection_bit(o2::aod::evsel::kNoBGT0A) ? 11 : 12); + getHist(TH2, histdir + "/ft0C")->Fill(ampC, bc.selection_bit(o2::aod::evsel::kNoBGT0C) ? 11 : 12); } if (bc.has_foundFDD()) { auto fdd = bc.foundFDD(); auto ampA = udhelpers::FDDAmplitudeA(fdd); auto ampC = udhelpers::FDDAmplitudeC(fdd); - registry.get(HIST("reco/fddA"))->Fill(ampA, 0); - registry.get(HIST("reco/fddC"))->Fill(ampC, 0); - registry.get(HIST("reco/fddA"))->Fill(ampA, triggers[1] ? 1 : 5); - registry.get(HIST("reco/fddC"))->Fill(ampC, triggers[1] ? 1 : 5); - registry.get(HIST("reco/fddA"))->Fill(ampA, triggers[2] ? 2 : 6); - registry.get(HIST("reco/fddC"))->Fill(ampC, triggers[2] ? 2 : 6); - registry.get(HIST("reco/fddA"))->Fill(ampA, triggers[3] ? 3 : 7); - registry.get(HIST("reco/fddC"))->Fill(ampC, triggers[3] ? 3 : 7); - registry.get(HIST("reco/fddA"))->Fill(ampA, triggers[4] ? 4 : 8); - registry.get(HIST("reco/fddC"))->Fill(ampC, triggers[4] ? 4 : 8); - registry.get(HIST("reco/fddA"))->Fill(ampA, bc.selection_bit(o2::aod::evsel::kIsBBFDA) ? 9 : 10); - registry.get(HIST("reco/fddC"))->Fill(ampC, bc.selection_bit(o2::aod::evsel::kIsBBFDC) ? 9 : 10); - registry.get(HIST("reco/fddA"))->Fill(ampA, bc.selection_bit(o2::aod::evsel::kNoBGFDA) ? 11 : 12); - registry.get(HIST("reco/fddC"))->Fill(ampC, bc.selection_bit(o2::aod::evsel::kNoBGFDC) ? 11 : 12); - } - } - - void init(InitContext&) - { - LOGF(debug, " beginning of init reached"); - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setFatalWhenNull(false); - diffCuts = (DGCutparHolder)DGCuts; - - const int nXbinsInStatH = 25; - - // add histograms for the different process functions - registry.add("reco/Stat", "Cut statistics;; Collisions", {HistType::kTH1F, {{nXbinsInStatH, -0.5, static_cast(nXbinsInStatH - 0.5)}}}); - registry.add("reco/pt1Vspt2", "2 prong events, p_{T} versus p_{T}", {HistType::kTH2F, {{100, -3., 3.}, {100, -3., 3.0}}}); - registry.add("reco/TPCsignal1", "2 prong events, TPC signal versus p_{T} of particle 1", {HistType::kTH2F, {{200, -3., 3.}, {200, 0., 100.0}}}); - registry.add("reco/TPCsignal2", "2 prong events, TPC signal versus p_{T} of particle 2", {HistType::kTH2F, {{200, -3., 3.}, {200, 0., 100.0}}}); - registry.add("reco/sig1VsSig2TPC", "2 prong events, TPC signal versus TPC signal", {HistType::kTH2F, {{100, 0., 100.}, {100, 0., 100.}}}); - - // FIT amplitudes - // 0: unconditional - // 1: TOR 5: no TOR - // 2: TVX 6: no TVX - // 3: TSC 7: no TSC - // 4: TCE 8: no TCE - // 9: IsBBXXX 10: !IsBBXXX - // 11: kNoBGXXX 12: !kNoBGXXX - const int nXbinsFITH = 201; - registry.add("reco/fv0", "FV0 amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}}); - registry.add("reco/ft0A", "FT0A amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}}); - registry.add("reco/ft0C", "FT0C amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}}); - registry.add("reco/fddA", "FDDA amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}}); - registry.add("reco/fddC", "FDDC amplitudes", {HistType::kTH2F, {{nXbinsFITH, -0.5, nXbinsFITH - 0.5}, {13, -0.5, 12.5}}}); - - std::string labels[nXbinsInStatH] = {"all", "hasBC", "accepted", "FITveto", "MID trk", "global not PV trk", "not global PV trk", - "ITS-only PV trk", "TOF PV trk fraction", "n PV trks", "PID", "pt", "eta", "net charge", - "inv mass", "evsel TF border", "evsel no pile-up", "evsel ITSROF", "evsel z-vtx", "evsel ITSTPC vtx", "evsel TRD vtx", "evsel TOF vtx", "", "", ""}; - - registry.get(HIST("reco/Stat"))->SetNdivisions(nXbinsInStatH, "X"); - for (int iXbin(1); iXbin < nXbinsInStatH + 1; iXbin++) { - registry.get(HIST("reco/Stat"))->GetXaxis()->ChangeLabel(iXbin, 45, 0.03, 33, -1, -1, labels[iXbin - 1]); + getHist(TH2, histdir + "/fddA")->Fill(ampA, 0); + getHist(TH2, histdir + "/fddC")->Fill(ampC, 0); + getHist(TH2, histdir + "/fddA")->Fill(ampA, triggers[1] ? 1 : 5); + getHist(TH2, histdir + "/fddC")->Fill(ampC, triggers[1] ? 1 : 5); + getHist(TH2, histdir + "/fddA")->Fill(ampA, triggers[2] ? 2 : 6); + getHist(TH2, histdir + "/fddC")->Fill(ampC, triggers[2] ? 2 : 6); + getHist(TH2, histdir + "/fddA")->Fill(ampA, triggers[3] ? 3 : 7); + getHist(TH2, histdir + "/fddC")->Fill(ampC, triggers[3] ? 3 : 7); + getHist(TH2, histdir + "/fddA")->Fill(ampA, triggers[4] ? 4 : 8); + getHist(TH2, histdir + "/fddC")->Fill(ampC, triggers[4] ? 4 : 8); + getHist(TH2, histdir + "/fddA")->Fill(ampA, bc.selection_bit(o2::aod::evsel::kIsBBFDA) ? 9 : 10); + getHist(TH2, histdir + "/fddC")->Fill(ampC, bc.selection_bit(o2::aod::evsel::kIsBBFDC) ? 9 : 10); + getHist(TH2, histdir + "/fddA")->Fill(ampA, bc.selection_bit(o2::aod::evsel::kNoBGFDA) ? 11 : 12); + getHist(TH2, histdir + "/fddC")->Fill(ampC, bc.selection_bit(o2::aod::evsel::kNoBGFDC) ? 11 : 12); } - - LOGF(debug, " end of init reached"); } - // process function for real data - void process(CC const& collision, BCs const& bcs, TCs& tracks, FWs& fwdtracks, - aod::Zdcs& /*zdcs*/, aod::FV0As& fv0as, aod::FT0s& ft0s, aod::FDDs& fdds) + template + void processReco(std::string histdir, TCol const& collision, BCs const& bcs, + TCs const& tracks, FWs const& fwdtracks, + aod::FV0As const& fv0as, aod::FT0s const& ft0s, aod::FDDs const& fdds) { LOGF(debug, " collision %d", collision.globalIndex()); - registry.get(HIST("reco/Stat"))->Fill(0., 1.); + getHist(TH1, histdir + "/Stat")->Fill(0., 1.); // nominal BC if (!collision.has_foundBC()) { return; } - registry.get(HIST("reco/Stat"))->Fill(1., 1.); - auto bc = collision.foundBC_as(); - int trs = 0; - if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - trs = 1; - } - int trofs = 0; - if (collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { - trofs = 1; - } - int hmpr = 0; - if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { - hmpr = 1; - } - double ir = 0.; + getHist(TH1, histdir + "/Stat")->Fill(1., 1.); + auto bc = collision.template foundBC_as(); + LOGF(debug, " BC id %d", bc.globalBC()); const uint64_t ts = bc.timestamp(); const int runnumber = bc.runNumber(); + int trs = collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) ? 1 : 0; + int trofs = collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard) ? 1 : 0; + int hmpr = collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof) ? 1 : 0; + int tfb = collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) ? 1 : 0; + int itsROFb = collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) ? 1 : 0; + int sbp = collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup) ? 1 : 0; + int zVtxFT0vPv = collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV) ? 1 : 0; + int vtxITSTPC = collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC) ? 1 : 0; + double ir = 0.; if (bc.has_zdc()) { ir = mRateFetcher.fetch(ccdb.service, ts, runnumber, "ZNC hadronic") * 1.e-3; } @@ -280,12 +303,19 @@ struct DGCandProducer { uint8_t chFDDA = 0; uint8_t chFDDC = 0; uint8_t chFV0A = 0; - int occ = 0; - occ = collision.trackOccupancyInTimeRange(); - LOGF(debug, " BC id %d", bc.globalBC()); + int occ = collision.trackOccupancyInTimeRange(); + + if (cfgSkimmedProcessing) { + // update ccdb setting for zorro + if (mRunNumber != bc.runNumber()) { + mRunNumber = bc.runNumber(); + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), triggerName.value); + zorro.populateHistRegistry(registry, bc.runNumber()); + } + } // fill FIT histograms - fillFIThistograms(bc); + fillFIThistograms(bc, histdir); // obtain slice of compatible BCs auto bcRange = udhelpers::compatibleBCs(collision, diffCuts.NDtcoll(), bcs, diffCuts.minNBCs()); @@ -295,20 +325,26 @@ struct DGCandProducer { auto isDGEvent = dgSelector.IsSelected(diffCuts, collision, bcRange, tracks, fwdtracks); // save DG candidates - registry.get(HIST("reco/Stat"))->Fill(isDGEvent + 2, 1.); + getHist(TH1, histdir + "/Stat")->Fill(isDGEvent + 3, 1.); if (isDGEvent == 0) { LOGF(debug, " Data: good collision!"); + if (cfgSkimmedProcessing) { + // let zorro do the accounting + auto zorroDecision = zorro.isSelected(bc.globalBC()); + LOGF(info, " zorroDecision %d", zorroDecision); + if (zorroDecision) { + getHist(TH1, histdir + "/Stat")->Fill(2, 1.); + } + } + // fill FITInfo upchelpers::FITInfo fitInfo{}; udhelpers::getFITinfo(fitInfo, bc, bcs, ft0s, fv0as, fdds); // update DG candidates tables auto rtrwTOF = udhelpers::rPVtrwTOF(tracks, collision.numContrib()); - int upc_flag = 0; - ushort flags = collision.flags(); - if (flags & dataformats::Vertex>::Flags::UPCMode) - upc_flag = 1; + int upc_flag = (collision.flags() & dataformats::Vertex>::Flags::UPCMode) ? 1 : 0; outputCollisions(bc.globalBC(), bc.runNumber(), collision.posX(), collision.posY(), collision.posZ(), upc_flag, collision.numContrib(), udhelpers::netCharge(tracks), @@ -321,18 +357,18 @@ struct DGCandProducer { fitInfo.BBFT0Apf, fitInfo.BBFT0Cpf, fitInfo.BGFT0Apf, fitInfo.BGFT0Cpf, fitInfo.BBFV0Apf, fitInfo.BGFV0Apf, fitInfo.BBFDDApf, fitInfo.BBFDDCpf, fitInfo.BGFDDApf, fitInfo.BGFDDCpf); - outputCollisionSelExtras(chFT0A, chFT0C, chFDDA, chFDDC, chFV0A, occ, ir, trs, trofs, hmpr); + outputCollisionSelExtras(chFT0A, chFT0C, chFDDA, chFDDC, chFV0A, occ, ir, trs, trofs, hmpr, tfb, itsROFb, sbp, zVtxFT0vPv, vtxITSTPC, collision.rct_raw()); outputCollsLabels(collision.globalIndex()); // update DGTracks tables - for (auto& track : tracks) { + for (const auto& track : tracks) { if (saveAllTracks || track.isPVContributor()) { updateUDTrackTables(outputCollisions.lastIndex(), track, bc.globalBC()); } } // update DGFwdTracks tables - for (auto& fwdtrack : fwdtracks) { + for (const auto& fwdtrack : fwdtracks) { updateUDFwdTrackTables(fwdtrack, bc.globalBC()); } @@ -359,7 +395,7 @@ struct DGCandProducer { auto cnt = 0; float pt1 = 0., pt2 = 0.; float signalTPC1 = 0., signalTPC2 = 0.; - for (auto tr : tracks) { + for (const auto& tr : tracks) { if (tr.isPVContributor()) { cnt++; switch (cnt) { @@ -375,13 +411,61 @@ struct DGCandProducer { cnt, tr.isGlobalTrack(), tr.pt(), tr.itsNCls(), tr.tpcNClsCrossedRows(), tr.hasTRD(), tr.hasTOF()); } } - registry.get(HIST("reco/pt1Vspt2"))->Fill(pt1, pt2); - registry.get(HIST("reco/TPCsignal1"))->Fill(pt1, signalTPC1); - registry.get(HIST("reco/TPCsignal2"))->Fill(pt2, signalTPC2); - registry.get(HIST("reco/sig1VsSig2TPC"))->Fill(signalTPC1, signalTPC2); + getHist(TH2, histdir + "/pt1Vspt2")->Fill(pt1, pt2); + getHist(TH2, histdir + "/TPCsignal1")->Fill(pt1, signalTPC1); + getHist(TH2, histdir + "/TPCsignal2")->Fill(pt2, signalTPC2); + getHist(TH2, histdir + "/sig1VsSig2TPC")->Fill(signalTPC1, signalTPC2); } } } + + void init(InitContext& context) + { + // initialize zorro + mRunNumber = -1; + zorroSummary.setObject(zorro.getZorroSummary()); + zorro.setBaseCCDBPath(cfgZorroCCDBpath.value); + ccdb->setURL(cfgCCDBurl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + // DGCuts + diffCuts = (DGCutparHolder)DGCuts; + + // add histograms for the different process functions + histPointers.clear(); + if (context.mOptions.get("processData")) { + createHistograms("reco"); + } + if (context.mOptions.get("processMcData")) { + createHistograms("MCreco"); + } + } + + // process function for reconstructed data + void processData(CC const& collision, BCs const& bcs, TCs const& tracks, FWs const& fwdtracks, + aod::Zdcs const& /*zdcs*/, aod::FV0As const& fv0as, aod::FT0s const& ft0s, aod::FDDs const& fdds) + { + processReco(std::string("reco"), collision, bcs, tracks, fwdtracks, fv0as, ft0s, fdds); + } + PROCESS_SWITCH(DGCandProducer, processData, "Produce UD table with data", true); + + // process function for reconstructed MC data + void processMcData(MCCC const& collision, aod::McCollisions const& /*mccollisions*/, BCs const& bcs, + TCs const& tracks, FWs const& fwdtracks, aod::Zdcs const& /*zdcs*/, aod::FV0As const& fv0as, + aod::FT0s const& ft0s, aod::FDDs const& fdds) + { + // select specific processes with the GeneratorID + auto mccol = collision.mcCollision(); + LOGF(debug, "GeneratorId %d (%d)", mccol.getGeneratorId(), generatorIds->size()); + + if (std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end()) { + LOGF(debug, "Event with good generatorId"); + processReco(std::string("MCreco"), collision, bcs, tracks, fwdtracks, fv0as, ft0s, fdds); + } + } + PROCESS_SWITCH(DGCandProducer, processMcData, "Produce UD tables with MC data", false); }; struct McDGCandProducer { @@ -391,6 +475,10 @@ struct McDGCandProducer { Produces outputMcCollsLabels; Produces outputMcTrackLabels; + // save all McTruth, even if the collisions is not reconstructed + Configurable> generatorIds{"generatorIds", std::vector{-1}, "MC generatorIds to process"}; + Configurable saveAllMcCollisions{"saveAllMcCollisions", true, "save all McCollisions"}; + using CCs = soa::Join; using BCs = soa::Join; using TCs = soa::Join; @@ -410,6 +498,7 @@ struct McDGCandProducer { template void updateUDMcCollisions(TMcCollision const& mccol) { + LOGF(debug, ""); // save mccol auto bc = mccol.template bc_as(); outputMcCollisions(bc.globalBC(), @@ -425,6 +514,8 @@ struct McDGCandProducer { template void updateUDMcParticle(TMcParticle const& McPart, int64_t McCollisionId, std::map& mcPartIsSaved) { + LOGF(debug, " McCollisionId %d", McCollisionId); + // save McPart // mother and daughter indices are set to -1 // ATTENTION: this can be improved to also include mother and daughter indices @@ -451,7 +542,23 @@ struct McDGCandProducer { template void updateUDMcParticles(TMcParticles const& McParts, int64_t McCollisionId, std::map& mcPartIsSaved) { - LOGF(debug, "number of McParticles %d", McParts.size()); + LOGF(debug, " number of McParticles %d", McParts.size()); + LOGF(debug, " McCollisionId %d", McCollisionId); + + /* + LOGF(info, "PStack"); + for (auto const& part : McParts) { + LOGF(info, "P - Id %d PID %d", part.globalIndex(), part.pdgCode()); + for (auto const& mother : part.template mothers_as()) { + LOGF(info, " M - Id %d PID %d", mother.globalIndex(), mother.pdgCode()); + } + for (auto const& daughter : part.template daughters_as()) { + LOGF(info, " D - Id %d PID %d", daughter.globalIndex(), daughter.pdgCode()); + } + } + LOGF(info, ""); + */ + // save McParts // new mother and daughter ids std::vector newmids; @@ -463,7 +570,7 @@ struct McDGCandProducer { // This is needed to be able to assign the new daughter indices std::map oldnew; auto lastId = outputMcParticles.lastIndex(); - for (auto mcpart : McParts) { + for (const auto& mcpart : McParts) { auto oldId = mcpart.globalIndex(); if (mcPartIsSaved.find(oldId) != mcPartIsSaved.end()) { oldnew[oldId] = mcPartIsSaved[oldId]; @@ -474,13 +581,13 @@ struct McDGCandProducer { } // all particles of the McCollision are saved - for (auto mcpart : McParts) { + for (const auto& mcpart : McParts) { LOGF(debug, " p (%d) %d", mcpart.pdgCode(), mcpart.globalIndex()); if (mcPartIsSaved.find(mcpart.globalIndex()) == mcPartIsSaved.end()) { // mothers newmids.clear(); auto oldmids = mcpart.mothersIds(); - for (auto oldmid : oldmids) { + for (const auto& oldmid : oldmids) { auto m = McParts.rawIteratorAt(oldmid); LOGF(debug, " m %d", m.globalIndex()); if (mcPartIsSaved.find(oldmid) != mcPartIsSaved.end()) { @@ -549,7 +656,7 @@ struct McDGCandProducer { void updateUDMcTrackLabels(TTrack const& udtracks, std::map& mcPartIsSaved) { // loop over all tracks - for (auto udtrack : udtracks) { + for (const auto& udtrack : udtracks) { // udtrack (UDTCs) -> track (TCs) -> mcTrack (McParticles) -> udMcTrack (UDMcParticles) auto trackId = udtrack.trackId(); if (trackId >= 0) { @@ -570,30 +677,10 @@ struct McDGCandProducer { } } - void init(InitContext& context) + // updating McTruth data and links to reconstructed data + void procWithDgCand(aod::McCollisions const& mccols, aod::McParticles const& mcparts, + UDCCs const& dgcands, UDTCs const& udtracks) { - // add histograms for the different process functions - if (context.mOptions.get("processMC")) { - registry.add("mcTruth/collisions", "Number of associated collisions", {HistType::kTH1F, {{11, -0.5, 10.5}}}); - registry.add("mcTruth/collType", "Collision type", {HistType::kTH1F, {{5, -0.5, 4.5}}}); - registry.add("mcTruth/IVMpt", "Invariant mass versus p_{T}", {HistType::kTH2F, {{150, 0.0, 3.0}, {150, 0.0, 3.0}}}); - } - } - - // process function for MC data - // save the MC truth of all events of interest and of the DG events - void processMC(aod::McCollisions const& mccols, aod::McParticles const& mcparts, - UDCCs const& dgcands, UDTCs const& udtracks, - CCs const& /*collisions*/, BCs const& /*bcs*/, TCs const& /*tracks*/) - { - LOGF(info, "Number of McCollisions %d", mccols.size()); - LOGF(info, "Number of DG candidates %d", dgcands.size()); - LOGF(info, "Number of UD tracks %d", udtracks.size()); - if (dgcands.size() <= 0) { - LOGF(info, "No DG candidates to save!"); - return; - } - // use a hash table to keep track of the McCollisions which have been added to the UDMcCollision table // {McCollisionId : udMcCollisionId} // similar for the McParticles which have been added to the UDMcParticle table @@ -603,18 +690,20 @@ struct McDGCandProducer { // loop over McCollisions and UDCCs simultaneously auto mccol = mccols.iteratorAt(0); - auto dgcand = dgcands.iteratorAt(0); + auto mcOfInterest = std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end(); auto lastmccol = mccols.iteratorAt(mccols.size() - 1); + auto mccolAtEnd = false; + + auto dgcand = dgcands.iteratorAt(0); auto lastdgcand = dgcands.iteratorAt(dgcands.size() - 1); + auto dgcandAtEnd = false; // advance dgcand and mccol until both are AtEnd int64_t mccolId = mccol.globalIndex(); int64_t mcdgId = -1; int64_t colId = -1; - auto dgcandAtEnd = dgcand == lastdgcand; - auto mccolAtEnd = mccol == lastmccol; - bool goon = !dgcandAtEnd || !mccolAtEnd; + bool goon = true; while (goon) { // check if dgcand has an associated Collision and McCollision if (dgcand.has_collision()) { @@ -645,7 +734,9 @@ struct McDGCandProducer { // If the dgcand has an associated McCollision then the McCollision and all associated // McParticles are saved - if (mcdgId >= 0) { + // but only consider generated events of interest + if (mcdgId >= 0 && mcOfInterest) { + if (mcColIsSaved.find(mcdgId) == mcColIsSaved.end()) { // update UDMcCollisions LOGF(debug, " writing mcCollision %d to UDMcCollisions", mcdgId); @@ -675,12 +766,17 @@ struct McDGCandProducer { // update UDMcParticles and UDMcTrackLabels (for each UDTrack -> UDMcParticles) // loop over tracks of dgcand - for (auto dgtrack : dgTracks) { + for (const auto& dgtrack : dgTracks) { if (dgtrack.has_track()) { auto track = dgtrack.track_as(); if (track.has_mcParticle()) { auto mcPart = track.mcParticle(); - updateUDMcParticle(mcPart, -1, mcPartIsSaved); + auto mcCol = mcPart.mcCollision(); + if (mcColIsSaved.find(mcCol.globalIndex()) == mcColIsSaved.end()) { + updateUDMcCollisions(mcCol); + mcColIsSaved[mcCol.globalIndex()] = outputMcCollisions.lastIndex(); + } + updateUDMcParticle(mcPart, mcColIsSaved[mcCol.globalIndex()], mcPartIsSaved); updateUDMcTrackLabel(dgtrack, mcPartIsSaved); } else { outputMcTrackLabels(-1, track.mcMask()); @@ -700,7 +796,8 @@ struct McDGCandProducer { // this is case 2. // update UDMcCollisions and UDMcParticles - if (mcColIsSaved.find(mccolId) == mcColIsSaved.end()) { + // but only consider generated events of interest + if (mcOfInterest && mcColIsSaved.find(mccolId) == mcColIsSaved.end()) { // update UDMcCollisions LOGF(debug, " writing mcCollision %d to UDMcCollisions", mccolId); @@ -715,16 +812,81 @@ struct McDGCandProducer { // advance mccol if (mccol != lastmccol) { mccol++; + mcOfInterest = std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end(); mccolId = mccol.globalIndex(); } else { mccolAtEnd = true; } } - LOGF(debug, " UDMcCollsLabels %d (of %d) UDMcCollisions %d", outputMcCollsLabels.lastIndex(), dgcands.size() - 1, outputMcCollisions.lastIndex()); + LOGF(info, " UDMcCollsLabels %d (of %d) UDMcCollisions %d", outputMcCollsLabels.lastIndex(), dgcands.size() - 1, outputMcCollisions.lastIndex()); goon = !dgcandAtEnd || !mccolAtEnd; } } - PROCESS_SWITCH(McDGCandProducer, processMC, "Produce MC tables", false); + + // updating McTruth data only + void procWithoutDgCand(aod::McCollisions const& mccols, aod::McParticles const& mcparts) + { + // use a hash table to keep track of the McCollisions which have been added to the UDMcCollision table + // {McCollisionId : udMcCollisionId} + // similar for the McParticles which have been added to the UDMcParticle table + // {McParticleId : udMcParticleId} + std::map mcColIsSaved; + std::map mcPartIsSaved; + + // loop over McCollisions + for (auto const& mccol : mccols) { + // only consider generated events of interest + if (std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) == generatorIds->end()) + continue; + + int64_t mccolId = mccol.globalIndex(); + // update UDMcCollisions and UDMcParticles + if (mcColIsSaved.find(mccolId) == mcColIsSaved.end()) { + + // update UDMcCollisions + LOGF(debug, " writing mcCollision %d to UDMcCollisions", mccolId); + updateUDMcCollisions(mccol); + mcColIsSaved[mccolId] = outputMcCollisions.lastIndex(); + + // update UDMcParticles + auto mcPartsSlice = mcparts.sliceBy(mcPartsPerMcCollision, mccolId); + updateUDMcParticles(mcPartsSlice, mcColIsSaved[mccolId], mcPartIsSaved); + } + } + } + + void init(InitContext& context) + { + // add histograms for the different process functions + if (context.mOptions.get("processMCTruth")) { + LOGF(info, "Preparing histograms for processMCTruth."); + registry.add("mcTruth/collisions", "Number of associated collisions", {HistType::kTH1F, {{11, -0.5, 10.5}}}); + registry.add("mcTruth/collType", "Collision type", {HistType::kTH1F, {{5, -0.5, 4.5}}}); + registry.add("mcTruth/IVMpt", "Invariant mass versus p_{T}", {HistType::kTH2F, {{150, 0.0, 3.0}, {150, 0.0, 3.0}}}); + } + } + + // process function for MC data + // save the MC truth of all events of interest and of the DG events + void processMCTruth(aod::McCollisions const& mccols, aod::McParticles const& mcparts, + UDCCs const& dgcands, UDTCs const& udtracks, + CCs const& /*collisions*/, BCs const& /*bcs*/, TCs const& /*tracks*/) + { + LOGF(info, "Number of McCollisions %d", mccols.size()); + LOGF(info, "Number of DG candidates %d", dgcands.size()); + LOGF(info, "Number of UD tracks %d", udtracks.size()); + + if (mccols.size() > 0) { + if (dgcands.size() > 0) { + procWithDgCand(mccols, mcparts, dgcands, udtracks); + } else { + if (saveAllMcCollisions) { + procWithoutDgCand(mccols, mcparts); + } + } + } + } + PROCESS_SWITCH(McDGCandProducer, processMCTruth, "Produce MC tables", false); void processDummy(aod::Collisions const& /*collisions*/) { diff --git a/PWGUD/TableProducer/SGCandProducer.cxx b/PWGUD/TableProducer/SGCandProducer.cxx index 424e7d44b7f..37fba3120db 100644 --- a/PWGUD/TableProducer/SGCandProducer.cxx +++ b/PWGUD/TableProducer/SGCandProducer.cxx @@ -8,34 +8,51 @@ // 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. +// +/// \file SGCandProducer.cxx +/// \brief Produces PWGUD derived table from standard tables +/// +/// \author Alexander Bylinkin , Uniersity of Bergen +/// \since 23.11.2023 +/// \author Adam Matyja , INP PAN Krakow, Poland +/// \since May 2025 +// + +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/Core/UPCHelpers.h" +#include "PWGUD/DataModel/UDTables.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/ctpRateFetcher.h" +#include "Common/DataModel/EventSelection.h" -#include -#include -#include #include "CCDB/BasicCCDBManager.h" -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "ReconstructionDataFormats/Vertex.h" #include "CommonConstants/LHCConstants.h" #include "DataFormatsFIT/Triggers.h" +#include "DataFormatsParameters/AggregatedRunInfo.h" +#include "DataFormatsParameters/GRPLHCIFData.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" - -#include "Framework/AnalysisTask.h" +#include "Framework/ASoA.h" #include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" -#include "Common/CCDB/EventSelectionParams.h" -#include "Common/CCDB/ctpRateFetcher.h" -#include "Common/DataModel/EventSelection.h" -#include "PWGUD/DataModel/UDTables.h" -#include "PWGUD/Core/UPCHelpers.h" -#include "PWGUD/Core/SGSelector.h" +#include "ReconstructionDataFormats/Vertex.h" + +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::dataformats; +using namespace o2::aod::rctsel; + +#define getHist(type, name) std::get>(histPointers[name]) struct SGCandProducer { Service ccdb; @@ -51,6 +68,10 @@ struct SGCandProducer { aod::pidTOFFullDe, aod::pidTOFFullTr, aod::pidTOFFullHe, aod::pidTOFFullAl, aod::pidTOFFullEl, aod::pidTOFFullMu, aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; using FWs = aod::FwdTracks; + + using MCCCs = soa::Join; + using MCCC = MCCCs::iterator; + // get an SGCutparHolder SGCutParHolder sameCuts = SGCutParHolder(); // SGCutparHolder Configurable SGCuts{"SGCuts", {}, "SG event cuts"}; @@ -62,14 +83,22 @@ struct SGCandProducer { Configurable noSameBunchPileUp{"noSameBunchPileUp", true, "reject SameBunchPileUp"}; Configurable IsGoodVertex{"IsGoodVertex", false, "Select FT0 PV vertex matching"}; Configurable ITSTPCVertex{"ITSTPCVertex", true, "reject ITS-only vertex"}; // if one wants to look at Single Gap pp events + Configurable> generatorIds{"generatorIds", std::vector{-1}, "MC generatorIds to process"}; + + Configurable isGoodRCTCollision{"isGoodRCTCollision", true, "Check RCT flags for FT0,ITS,TPC and tracking"}; + Configurable isGoodRCTZdc{"isGoodRCTZdc", false, "Check RCT flags for ZDC if present in run"}; // Configurables to decide which tables are filled Configurable fillTrackTables{"fillTrackTables", true, "Fill track tables"}; Configurable fillFwdTrackTables{"fillFwdTrackTables", true, "Fill forward track tables"}; + // SG selector SGSelector sgSelector; ctpRateFetcher mRateFetcher; + // initialize RCT flag checker + RCTFlagsChecker myRCTChecker{"CBT"}; + // data tables Produces outputSGCollisions; Produces outputCollisions; @@ -93,6 +122,9 @@ struct SGCandProducer { HistogramRegistry registry{ "registry", {}}; + std::map histPointers; + + int runNumber = -1; // function to update UDFwdTracks, UDFwdTracksExtra template @@ -171,65 +203,138 @@ struct SGCandProducer { outputTracksLabel(track.globalIndex()); } - void init(InitContext&) + // function to process trigger counters, accounting for BC selection bits + void processCountersTrg(BCs const& bcs, aod::FT0s const&, aod::Zdcs const&) { - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setFatalWhenNull(false); - sameCuts = (SGCutParHolder)SGCuts; - registry.add("reco/Stat", "Cut statistics; Selection criterion; Collisions", {HistType::kTH1F, {{14, -0.5, 13.5}}}); + const auto& firstBc = bcs.iteratorAt(0); + if (runNumber != firstBc.runNumber()) + runNumber = firstBc.runNumber(); + + auto hCountersTrg = getHist(TH1, "reco/hCountersTrg"); + auto hCountersTrgBcSel = getHist(TH1, "reco/hCountersTrgBcSel"); + auto hLumi = getHist(TH1, "reco/hLumi"); + auto hLumiBcSel = getHist(TH1, "reco/hLumiBcSel"); + + // Cross sections in ub. Using dummy -1 if lumi estimator is not reliable + float csTCE = 10.36e6; + float csZEM = 415.2e6; // see AN: https://alice-notes.web.cern.ch/node/1515 + float csZNC = 214.5e6; // see AN: https://alice-notes.web.cern.ch/node/1515 + if (runNumber > 543437 && runNumber < 543514) { + csTCE = 8.3e6; + } + if (runNumber >= 543514) { + csTCE = 4.10e6; // see AN: https://alice-notes.web.cern.ch/node/1515 + } + + for (const auto& bc : bcs) { + bool hasFT0 = bc.has_foundFT0(); + bool hasZDC = bc.has_foundZDC(); + if (!hasFT0 && !hasZDC) + continue; + bool isSelectedBc = true; + if (rejectAtTFBoundary && !bc.selection_bit(aod::evsel::kNoTimeFrameBorder)) + isSelectedBc = false; + if (noITSROFrameBorder && !bc.selection_bit(aod::evsel::kNoITSROFrameBorder)) + isSelectedBc = false; + if (hasFT0) { + auto ft0TrgMask = bc.ft0().triggerMask(); + if (TESTBIT(ft0TrgMask, o2::fit::Triggers::bitVertex)) { + hCountersTrg->Fill("TVX", 1); + if (isSelectedBc) + hCountersTrgBcSel->Fill("TVX", 1); + } + if (TESTBIT(ft0TrgMask, o2::fit::Triggers::bitVertex) && TESTBIT(ft0TrgMask, o2::fit::Triggers::bitCen)) { + hCountersTrg->Fill("TCE", 1); + hLumi->Fill("TCE", 1. / csTCE); + if (isSelectedBc) { + hCountersTrgBcSel->Fill("TCE", 1); + hLumiBcSel->Fill("TCE", 1. / csTCE); + } + } + } + if (hasZDC) { + if (bc.selection_bit(aod::evsel::kIsBBZNA) || bc.selection_bit(aod::evsel::kIsBBZNC)) { + hCountersTrg->Fill("ZEM", 1); + hLumi->Fill("ZEM", 1. / csZEM); + if (isSelectedBc) { + hCountersTrgBcSel->Fill("ZEM", 1); + hLumiBcSel->Fill("ZEM", 1. / csZEM); + } + } + if (bc.selection_bit(aod::evsel::kIsBBZNC)) { + hCountersTrg->Fill("ZNC", 1); + hLumi->Fill("ZNC", 1. / csZNC); + if (isSelectedBc) { + hCountersTrgBcSel->Fill("ZNC", 1); + hLumiBcSel->Fill("ZNC", 1. / csZNC); + } + } + } + } } - // process function for real data - void process(CC const& collision, BCs const& bcs, TCs& tracks, FWs& fwdtracks, - aod::Zdcs& /*zdcs*/, aod::FT0s& ft0s, aod::FV0As& fv0as, aod::FDDs& fdds) + PROCESS_SWITCH(SGCandProducer, processCountersTrg, "Produce trigger counters and luminosity histograms", true); + + // function to process reconstructed data + template + void processReco(std::string histdir, TCol const& collision, BCs const& bcs, + TCs const& tracks, FWs const& fwdtracks, + aod::FV0As const& fv0as, aod::FT0s const& ft0s, aod::FDDs const& fdds) { if (verboseInfo) LOGF(debug, " collision %d", collision.globalIndex()); - registry.get(HIST("reco/Stat"))->Fill(0., 1.); + getHist(TH1, histdir + "/Stat")->Fill(0., 1.); // reject collisions at TF boundaries if (rejectAtTFBoundary && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { return; } - registry.get(HIST("reco/Stat"))->Fill(1., 1.); + getHist(TH1, histdir + "/Stat")->Fill(1., 1.); // reject collisions at ITS RO TF boundaries if (noITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { return; } - registry.get(HIST("reco/Stat"))->Fill(2., 1.); + getHist(TH1, histdir + "/Stat")->Fill(2., 1.); // reject Same Bunch PileUp if (noSameBunchPileUp && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { return; } - registry.get(HIST("reco/Stat"))->Fill(3., 1.); + getHist(TH1, histdir + "/Stat")->Fill(3., 1.); // check vertex matching to FT0 if (IsGoodVertex && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { return; } - registry.get(HIST("reco/Stat"))->Fill(4., 1.); + getHist(TH1, histdir + "/Stat")->Fill(4., 1.); // reject ITS Only vertices if (ITSTPCVertex && !collision.selection_bit(aod::evsel::kIsVertexITSTPC)) { return; } - registry.get(HIST("reco/Stat"))->Fill(5., 1.); + getHist(TH1, histdir + "/Stat")->Fill(5., 1.); // nominal BC if (!collision.has_foundBC()) { return; } - registry.get(HIST("reco/Stat"))->Fill(6., 1.); - int trs = 0; - if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - trs = 1; - } - int trofs = 0; - if (collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { - trofs = 1; + getHist(TH1, histdir + "/Stat")->Fill(6., 1.); + // RCT CBT for collision check + if (isGoodRCTCollision && !myRCTChecker(collision)) { + return; } - int hmpr = 0; - if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { - hmpr = 1; + getHist(TH1, histdir + "/Stat")->Fill(7., 1.); + // RCT CBT+ZDC for collision check + if (isGoodRCTZdc && !myRCTChecker(collision)) { + return; } - auto bc = collision.foundBC_as(); + getHist(TH1, histdir + "/Stat")->Fill(8., 1.); + + // + int trs = collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) ? 1 : 0; + int trofs = collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard) ? 1 : 0; + int hmpr = collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof) ? 1 : 0; + int tfb = collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) ? 1 : 0; + int itsROFb = collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) ? 1 : 0; + int sbp = collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup) ? 1 : 0; + int zVtxFT0vPv = collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV) ? 1 : 0; + int vtxITSTPC = collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC) ? 1 : 0; + auto bc = collision.template foundBC_as(); double ir = 0.; const uint64_t ts = bc.timestamp(); const int runnumber = bc.runNumber(); @@ -249,7 +354,7 @@ struct SGCandProducer { if (verboseInfo) LOGF(info, "No Newbc %i", bc.globalBC()); } - registry.get(HIST("reco/Stat"))->Fill(issgevent + 8, 1.); + getHist(TH1, histdir + "/Stat")->Fill(issgevent + 10, 1.); if (issgevent <= 2) { if (verboseInfo) LOGF(info, "Current BC: %i, %i, %i", bc.globalBC(), newbc.globalBC(), issgevent); @@ -263,14 +368,10 @@ struct SGCandProducer { uint8_t chFDDA = 0; uint8_t chFDDC = 0; uint8_t chFV0A = 0; - int occ = 0; - occ = collision.trackOccupancyInTimeRange(); + int occ = collision.trackOccupancyInTimeRange(); udhelpers::getFITinfo(fitInfo, newbc, bcs, ft0s, fv0as, fdds); + int upc_flag = (collision.flags() & dataformats::Vertex>::Flags::UPCMode) ? 1 : 0; // update SG candidates tables - int upc_flag = 0; - ushort flags = collision.flags(); - if (flags & dataformats::Vertex>::Flags::UPCMode) - upc_flag = 1; outputCollisions(bc.globalBC(), bc.runNumber(), collision.posX(), collision.posY(), collision.posZ(), upc_flag, collision.numContrib(), udhelpers::netCharge(tracks), @@ -285,7 +386,7 @@ struct SGCandProducer { fitInfo.BBFT0Apf, fitInfo.BBFT0Cpf, fitInfo.BGFT0Apf, fitInfo.BGFT0Cpf, fitInfo.BBFV0Apf, fitInfo.BGFV0Apf, fitInfo.BBFDDApf, fitInfo.BBFDDCpf, fitInfo.BGFDDApf, fitInfo.BGFDDCpf); - outputCollisionSelExtras(chFT0A, chFT0C, chFDDA, chFDDC, chFV0A, occ, ir, trs, trofs, hmpr); + outputCollisionSelExtras(chFT0A, chFT0C, chFDDA, chFDDC, chFV0A, occ, ir, trs, trofs, hmpr, tfb, itsROFb, sbp, zVtxFT0vPv, vtxITSTPC, collision.rct_raw()); outputCollsLabels(collision.globalIndex()); if (newbc.has_zdc()) { auto zdc = newbc.zdc(); @@ -295,7 +396,7 @@ struct SGCandProducer { } // update SGTracks tables if (fillTrackTables) { - for (auto& track : tracks) { + for (const auto& track : tracks) { if (track.pt() > sameCuts.minPt() && track.eta() > sameCuts.minEta() && track.eta() < sameCuts.maxEta()) { if (track.isPVContributor()) { updateUDTrackTables(outputCollisions.lastIndex(), track, bc.globalBC()); @@ -310,7 +411,7 @@ struct SGCandProducer { // update SGFwdTracks tables if (fillFwdTrackTables) { if (sameCuts.withFwdTracks()) { - for (auto& fwdtrack : fwdtracks) { + for (const auto& fwdtrack : fwdtracks) { if (!sgSelector.FwdTrkSelector(fwdtrack)) updateUDFwdTrackTables(fwdtrack, bc.globalBC()); } @@ -318,6 +419,71 @@ struct SGCandProducer { } } } + + void init(InitContext& context) + { + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setFatalWhenNull(false); + sameCuts = (SGCutParHolder)SGCuts; + + // add histograms for the different process functions + histPointers.clear(); + if (context.mOptions.get("processData")) { + histPointers.insert({"reco/Stat", registry.add("reco/Stat", "Cut statistics; Selection criterion; Collisions", {HistType::kTH1F, {{14, -0.5, 13.5}}})}); + + const AxisSpec axisCountersTrg{10, 0.5, 10.5, ""}; + histPointers.insert({"reco/hCountersTrg", registry.add("reco/hCountersTrg", "Trigger counts before selections; Trigger; Counts", {HistType::kTH1F, {axisCountersTrg}})}); + histPointers.insert({"reco/hCountersTrgBcSel", registry.add("reco/hCountersTrgSel", "Trigger counts after BC selections; Trigger; Counts", {HistType::kTH1F, {axisCountersTrg}})}); + histPointers.insert({"reco/hLumi", registry.add("reco/hLumi", "Integrated luminosity before selections; Trigger; Luminosity, 1/#mub", {HistType::kTH1F, {axisCountersTrg}})}); + histPointers.insert({"reco/hLumiBcSel", registry.add("reco/hLumiBcSel", "Integrated luminosity before selections; Trigger; Luminosity, 1/#mub", {HistType::kTH1F, {axisCountersTrg}})}); + auto hCountersTrg = getHist(TH1, "reco/hCountersTrg"); + auto hCountersTrgBcSel = getHist(TH1, "reco/hCountersTrgBcSel"); + auto hLumi = getHist(TH1, "reco/hLumi"); + auto hLumiBcSel = getHist(TH1, "reco/hLumiBcSel"); + for (const auto& h : {hCountersTrg, hCountersTrgBcSel, hLumi, hLumiBcSel}) { + h->GetXaxis()->SetBinLabel(1, "TVX"); + h->GetXaxis()->SetBinLabel(2, "TCE"); + h->GetXaxis()->SetBinLabel(3, "ZEM"); + h->GetXaxis()->SetBinLabel(4, "ZNC"); + } + } + if (context.mOptions.get("processMcData")) { + histPointers.insert({"MCreco/Stat", registry.add("MCreco/Stat", "Cut statistics; Selection criterion; Collisions", {HistType::kTH1F, {{14, -0.5, 13.5}}})}); + } + + if (isGoodRCTZdc) { + myRCTChecker.init("CBT", true); + } + } + + // process function for reconstructed data + void processData(CC const& collision, BCs const& bcs, TCs const& tracks, FWs const& fwdtracks, + aod::Zdcs const& /*zdcs*/, aod::FV0As const& fv0as, aod::FT0s const& ft0s, aod::FDDs const& fdds) + { + processReco(std::string("reco"), collision, bcs, tracks, fwdtracks, fv0as, ft0s, fdds); + } + PROCESS_SWITCH(SGCandProducer, processData, "Produce UD table with data", true); + + // process function for reconstructed MC data + void processMcData(MCCC const& collision, aod::McCollisions const& /*mccollisions*/, BCs const& bcs, + TCs const& tracks, FWs const& fwdtracks, aod::Zdcs const& /*zdcs*/, aod::FV0As const& fv0as, + aod::FT0s const& ft0s, aod::FDDs const& fdds) + { + // select specific processes with the GeneratorID + if (!collision.has_mcCollision()) + return; + auto mccol = collision.mcCollision(); + if (verboseInfo) + LOGF(info, "GeneratorId %d (%d)", mccol.getGeneratorId(), generatorIds->size()); + + if (std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end()) { + if (verboseInfo) + LOGF(info, "Event with good generatorId"); + processReco(std::string("MCreco"), collision, bcs, tracks, fwdtracks, fv0as, ft0s, fdds); + } + } + PROCESS_SWITCH(SGCandProducer, processMcData, "Produce UD tables with MC data", false); }; struct McSGCandProducer { @@ -328,6 +494,10 @@ struct McSGCandProducer { Produces outputMcCollsLabels; Produces outputMcTrackLabels; + // save all McTruth, even if the collisions is not reconstructed + Configurable> generatorIds{"generatorIds", std::vector{-1}, "MC generatorIds to process"}; + Configurable saveAllMcCollisions{"saveAllMcCollisions", true, "save all McCollisions"}; + using CCs = soa::Join; using BCs = soa::Join; using TCs = soa::Join; @@ -398,7 +568,7 @@ struct McSGCandProducer { // This is needed to be able to assign the new daughter indices std::map oldnew; auto lastId = outputMcParticles.lastIndex(); - for (auto mcpart : McParts) { + for (const auto& mcpart : McParts) { auto oldId = mcpart.globalIndex(); if (mcPartIsSaved.find(oldId) != mcPartIsSaved.end()) { oldnew[oldId] = mcPartIsSaved[oldId]; @@ -409,12 +579,12 @@ struct McSGCandProducer { } // all particles of the McCollision are saved - for (auto mcpart : McParts) { + for (const auto& mcpart : McParts) { if (mcPartIsSaved.find(mcpart.globalIndex()) == mcPartIsSaved.end()) { // mothers newmids.clear(); auto oldmids = mcpart.mothersIds(); - for (auto oldmid : oldmids) { + for (const auto& oldmid : oldmids) { auto m = McParts.rawIteratorAt(oldmid); if (verboseInfoMC) LOGF(debug, " m %d", m.globalIndex()); @@ -481,7 +651,7 @@ struct McSGCandProducer { void updateUDMcTrackLabels(TTrack const& udtracks, std::map& mcPartIsSaved) { // loop over all tracks - for (auto udtrack : udtracks) { + for (const auto& udtrack : udtracks) { // udtrack (UDTCs) -> track (TCs) -> mcTrack (McParticles) -> udMcTrack (UDMcParticles) auto trackId = udtrack.trackId(); if (trackId >= 0) { @@ -502,33 +672,10 @@ struct McSGCandProducer { } } - void init(InitContext& context) - { - // add histograms for the different process functions - if (context.mOptions.get("processMC")) { - registry.add("mcTruth/collisions", "Number of associated collisions", {HistType::kTH1F, {{11, -0.5, 10.5}}}); - registry.add("mcTruth/collType", "Collision type", {HistType::kTH1F, {{5, -0.5, 4.5}}}); - registry.add("mcTruth/IVMpt", "Invariant mass versus p_{T}", {HistType::kTH2F, {{150, 0.0, 3.0}, {150, 0.0, 3.0}}}); - } - } - - // process function for MC data - // save the MC truth of all events of interest and of the DG events - void processMC(aod::McCollisions const& mccols, aod::McParticles const& mcparts, - UDCCs const& sgcands, UDTCs const& udtracks, - CCs const& /*collisions*/, BCs const& /*bcs*/, TCs const& /*tracks*/) + // updating McTruth data and links to reconstructed data + void procWithSgCand(aod::McCollisions const& mccols, aod::McParticles const& mcparts, + UDCCs const& sgcands, UDTCs const& udtracks) { - if (verboseInfoMC) { - LOGF(info, "Number of McCollisions %d", mccols.size()); - LOGF(info, "Number of SG candidates %d", sgcands.size()); - LOGF(info, "Number of UD tracks %d", udtracks.size()); - } - if (sgcands.size() <= 0) { - if (verboseInfoMC) - LOGF(info, "No DG candidates to save!"); - return; - } - // use a hash table to keep track of the McCollisions which have been added to the UDMcCollision table // {McCollisionId : udMcCollisionId} // similar for the McParticles which have been added to the UDMcParticle table @@ -538,21 +685,20 @@ struct McSGCandProducer { // loop over McCollisions and UDCCs simultaneously auto mccol = mccols.iteratorAt(0); - auto sgcand = sgcands.iteratorAt(0); + auto mcOfInterest = std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end(); auto lastmccol = mccols.iteratorAt(mccols.size() - 1); + auto mccolAtEnd = false; + + auto sgcand = sgcands.iteratorAt(0); auto lastsgcand = sgcands.iteratorAt(sgcands.size() - 1); + auto sgcandAtEnd = false; // advance dgcand and mccol until both are AtEnd int64_t mccolId = mccol.globalIndex(); int64_t mcsgId = -1; - // int64_t colId = -1; - auto sgcandAtEnd = sgcand == lastsgcand; - auto mccolAtEnd = mccol == lastmccol; - bool goon = !sgcandAtEnd || !mccolAtEnd; + bool goon = true; while (goon) { - auto bcIter = mccol.bc_as(); - uint64_t globBC = bcIter.globalBC(); - // uint64_t globBC = 0; + auto globBC = mccol.bc_as().globalBC(); // check if dgcand has an associated McCollision if (sgcand.has_collision()) { auto sgcandCol = sgcand.collision_as(); @@ -563,7 +709,6 @@ struct McSGCandProducer { mcsgId = -1; } } else { - // colId = -1; mcsgId = -1; } if (verboseInfoMC) @@ -584,7 +729,8 @@ struct McSGCandProducer { // If the sgcand has an associated McCollision then the McCollision and all associated // McParticles are saved - if (mcsgId >= 0) { + // but only consider generated events of interest + if (mcsgId >= 0 && mcOfInterest) { if (mcColIsSaved.find(mcsgId) == mcColIsSaved.end()) { if (verboseInfoMC) LOGF(info, " Saving McCollision %d", mcsgId); @@ -615,12 +761,17 @@ struct McSGCandProducer { // update UDMcParticles and UDMcTrackLabels (for each UDTrack -> UDMcParticles) // loop over tracks of dgcand - for (auto sgtrack : sgTracks) { + for (const auto& sgtrack : sgTracks) { if (sgtrack.has_track()) { auto track = sgtrack.track_as(); if (track.has_mcParticle()) { auto mcPart = track.mcParticle(); - updateUDMcParticle(mcPart, -1, mcPartIsSaved); + auto mcCol = mcPart.mcCollision(); + if (mcColIsSaved.find(mcCol.globalIndex()) == mcColIsSaved.end()) { + updateUDMcCollisions(mcCol, globBC); + mcColIsSaved[mcCol.globalIndex()] = outputMcCollisions.lastIndex(); + } + updateUDMcParticle(mcPart, mcColIsSaved[mcCol.globalIndex()], mcPartIsSaved); updateUDMcTrackLabel(sgtrack, mcPartIsSaved); } else { outputMcTrackLabels(-1, track.mcMask()); @@ -642,7 +793,8 @@ struct McSGCandProducer { LOGF(info, "Doing case 2"); // update UDMcCollisions and UDMcParticles - if (mcColIsSaved.find(mccolId) == mcColIsSaved.end()) { + // but only consider generated events of interest + if (mcOfInterest && mcColIsSaved.find(mccolId) == mcColIsSaved.end()) { if (verboseInfoMC) LOGF(info, " Saving McCollision %d", mccolId); // update UDMcCollisions @@ -657,6 +809,7 @@ struct McSGCandProducer { // advance mccol if (mccol != lastmccol) { mccol++; + mcOfInterest = std::find(generatorIds->begin(), generatorIds->end(), mccol.getGeneratorId()) != generatorIds->end(); mccolId = mccol.globalIndex(); } else { mccolAtEnd = true; @@ -668,7 +821,71 @@ struct McSGCandProducer { LOGF(info, "End of loop mcsgId %d mccolId %d", mcsgId, mccolId); } } + + // updating McTruth data only + void procWithoutSgCand(aod::McCollisions const& mccols, aod::McParticles const& mcparts) + { + // use a hash table to keep track of the McCollisions which have been added to the UDMcCollision table + // {McCollisionId : udMcCollisionId} + // similar for the McParticles which have been added to the UDMcParticle table + // {McParticleId : udMcParticleId} + std::map mcColIsSaved; + std::map mcPartIsSaved; + + // loop over McCollisions + for (auto const& mccol : mccols) { + int64_t mccolId = mccol.globalIndex(); + uint64_t globBC = mccol.bc_as().globalBC(); + + // update UDMcCollisions and UDMcParticles + if (mcColIsSaved.find(mccolId) == mcColIsSaved.end()) { + if (verboseInfoMC) + LOGF(info, " Saving McCollision %d", mccolId); + + // update UDMcCollisions + updateUDMcCollisions(mccol, globBC); + mcColIsSaved[mccolId] = outputMcCollisions.lastIndex(); + + // update UDMcParticles + auto mcPartsSlice = mcparts.sliceBy(mcPartsPerMcCollision, mccolId); + updateUDMcParticles(mcPartsSlice, mcColIsSaved[mccolId], mcPartIsSaved); + } + } + } + + void init(InitContext& context) + { + // add histograms for the different process functions + if (context.mOptions.get("processMC")) { + registry.add("mcTruth/collisions", "Number of associated collisions", {HistType::kTH1F, {{11, -0.5, 10.5}}}); + registry.add("mcTruth/collType", "Collision type", {HistType::kTH1F, {{5, -0.5, 4.5}}}); + registry.add("mcTruth/IVMpt", "Invariant mass versus p_{T}", {HistType::kTH2F, {{150, 0.0, 3.0}, {150, 0.0, 3.0}}}); + } + } + + // process function for MC data + // save the MC truth of all events of interest and of the DG events + void processMC(aod::McCollisions const& mccols, aod::McParticles const& mcparts, + UDCCs const& sgcands, UDTCs const& udtracks, + CCs const& /*collisions*/, BCs const& /*bcs*/, TCs const& /*tracks*/) + { + if (verboseInfoMC) { + LOGF(info, "Number of McCollisions %d", mccols.size()); + LOGF(info, "Number of SG candidates %d", sgcands.size()); + LOGF(info, "Number of UD tracks %d", udtracks.size()); + } + if (mccols.size() > 0) { + if (sgcands.size() > 0) { + procWithSgCand(mccols, mcparts, sgcands, udtracks); + } else { + if (saveAllMcCollisions) { + procWithoutSgCand(mccols, mcparts); + } + } + } + } PROCESS_SWITCH(McSGCandProducer, processMC, "Produce MC tables", false); + void processDummy(aod::Collisions const& /*collisions*/) { // do nothing diff --git a/PWGUD/TableProducer/UPCCandidateProducer.cxx b/PWGUD/TableProducer/UPCCandidateProducer.cxx index 75fb8f61063..2208060bd59 100644 --- a/PWGUD/TableProducer/UPCCandidateProducer.cxx +++ b/PWGUD/TableProducer/UPCCandidateProducer.cxx @@ -12,24 +12,27 @@ /// \author Diana Krupova, diana.krupova@cern.ch /// \since 04.06.2024 -#include -#include -#include -#include -#include -#include -#include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" +#include "PWGUD/Core/UPCCutparHolder.h" +#include "PWGUD/Core/UPCHelpers.h" +#include "PWGUD/DataModel/UDTables.h" + #include "Common/CCDB/EventSelectionParams.h" #include "Common/DataModel/EventSelection.h" + #include "CommonConstants/LHCConstants.h" #include "DataFormatsFIT/Triggers.h" -#include "PWGUD/Core/UPCCutparHolder.h" -#include "PWGUD/Core/UPCHelpers.h" -#include "PWGUD/DataModel/UDTables.h" #include "DataFormatsITSMFT/ROFRecord.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include +#include +#include +#include +#include +#include +#include using namespace o2::framework; using namespace o2::framework::expressions; @@ -98,6 +101,9 @@ struct UpcCandProducer { Configurable fMinEtaMFT{"minEtaMFT", -3.6, "Minimum eta for MFT tracks"}; Configurable fMaxEtaMFT{"maxEtaMFT", -2.5, "Maximum eta for MFT tracks"}; + Configurable fRequireNoTimeFrameBorder{"requireNoTimeFrameBorder", true, "Require kNoTimeFrameBorder selection bit"}; + Configurable fRequireNoITSROFrameBorder{"requireNoITSROFrameBorder", true, "Require kNoITSROFrameBorder selection bit"}; + // QA histograms HistogramRegistry histRegistry{"HistRegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -124,6 +130,9 @@ struct UpcCandProducer { histRegistry.get(HIST("hCountersTrg"))->GetXaxis()->SetBinLabel(1, "TCE"); histRegistry.get(HIST("hCountersTrg"))->GetXaxis()->SetBinLabel(2, "ZNA"); histRegistry.get(HIST("hCountersTrg"))->GetXaxis()->SetBinLabel(3, "ZNC"); + histRegistry.get(HIST("hCountersTrg"))->GetXaxis()->SetBinLabel(4, "TCE_ROF"); + histRegistry.get(HIST("hCountersTrg"))->GetXaxis()->SetBinLabel(5, "TCE_TF"); + histRegistry.get(HIST("hCountersTrg"))->GetXaxis()->SetBinLabel(6, "TCE_ROF_TF"); const AxisSpec axisBcDist{201, 0.5, 200.5, ""}; histRegistry.add("hDistToITSTPC", "", kTH1F, {axisBcDist}); @@ -691,6 +700,46 @@ struct UpcCandProducer { } } + template + void collectForwardGlobalTracks(std::vector& bcsMatchedTrIds, + int typeFilter, + TBCs const& /*bcs*/, + o2::aod::Collisions const& /*collisions*/, + ForwardTracks const& fwdTracks, + o2::aod::AmbiguousFwdTracks const& /*ambFwdTracks*/, + std::unordered_map& ambFwdTrBCs) + { + for (const auto& trk : fwdTracks) { + if (trk.trackType() != typeFilter) + continue; + if (!applyFwdCuts(trk)) + continue; + int64_t trkId = trk.globalIndex(); + int32_t nContrib = -1; + uint64_t trackBC = 0; + auto ambIter = ambFwdTrBCs.find(trkId); + if (ambIter == ambFwdTrBCs.end()) { + const auto& col = trk.collision(); + nContrib = col.numContrib(); + trackBC = col.bc_as().globalBC(); + const auto& bc = col.bc_as(); + if (fRequireNoTimeFrameBorder && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + continue; // skip this track if the kNoTimeFrameBorder bit is required but not set + } + if (fRequireNoITSROFrameBorder && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + continue; // skip this track if the kNoITSROFrameBorder bit is required but not set + } + } else { + trackBC = ambIter->second; + } + int64_t tint = TMath::FloorNint(trk.trackTime() / o2::constants::lhc::LHCBunchSpacingNS + static_cast(fMuonTrackTShift)); + uint64_t bc = trackBC + tint; + if (nContrib > upcCuts.getMaxNContrib()) + continue; + addTrack(bcsMatchedTrIds, bc, trkId); + } + } + int32_t searchTracks(uint64_t midbc, uint64_t range, uint32_t tracksToFind, std::vector& tracks, std::vector& v, @@ -1466,7 +1515,7 @@ struct UpcCandProducer { fitInfo.BBFT0Apf, fitInfo.BBFT0Cpf, fitInfo.BGFT0Apf, fitInfo.BGFT0Cpf, fitInfo.BBFV0Apf, fitInfo.BGFV0Apf, fitInfo.BBFDDApf, fitInfo.BBFDDCpf, fitInfo.BGFDDApf, fitInfo.BGFDDCpf); - eventCandidatesSelExtras(chFT0A, chFT0C, chFDDA, chFDDC, chFV0A, 0, 0, 0, 0, 0); + eventCandidatesSelExtras(chFT0A, chFT0C, chFDDA, chFDDC, chFV0A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); eventCandidatesSelsFwd(fitInfo.distClosestBcV0A, fitInfo.distClosestBcT0A, amplitudesT0A, @@ -1519,10 +1568,10 @@ struct UpcCandProducer { bcs, collisions, fwdTracks, ambFwdTracks, ambFwdTrBCs); - collectForwardTracks(bcsMatchedTrIdsGlobal, - o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack, - bcs, collisions, - fwdTracks, ambFwdTracks, ambFwdTrBCs); + collectForwardGlobalTracks(bcsMatchedTrIdsGlobal, + o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack, + bcs, collisions, + fwdTracks, ambFwdTracks, ambFwdTrBCs); std::sort(bcsMatchedTrIdsMID.begin(), bcsMatchedTrIdsMID.end(), [](const auto& left, const auto& right) { return left.first < right.first; }); @@ -1539,6 +1588,16 @@ struct UpcCandProducer { continue; if (TESTBIT(ft0.triggerMask(), o2::fit::Triggers::bitCen)) { // TVX & TCE histRegistry.get(HIST("hCountersTrg"))->Fill("TCE", 1); + if (ft0.bc_as().selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { // TVX & TCE without ROF borders + histRegistry.get(HIST("hCountersTrg"))->Fill("TCE_ROF", 1); + } + if (ft0.bc_as().selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { // TVX & TCE without TF borders + histRegistry.get(HIST("hCountersTrg"))->Fill("TCE_TF", 1); + } + if (ft0.bc_as().selection_bit(o2::aod::evsel::kNoITSROFrameBorder) && + ft0.bc_as().selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { // TVX & TCE without ROF and TF borders + histRegistry.get(HIST("hCountersTrg"))->Fill("TCE_ROF_TF", 1); + } } if (std::abs(ft0.timeA()) > 2.f) continue; @@ -1667,6 +1726,14 @@ struct UpcCandProducer { std::vector relBCsV0A{}; uint8_t chFT0A = 0; uint8_t chFT0C = 0; + int trs = 0; + int trofs = 0; + int hmpr = 0; + int tfb = 0; + int itsROFb = 0; + int sbp = 0; + int zVtxFT0vPv = 0; + int vtxITSTPC = 0; if (nFT0s > 0) { uint64_t closestBcT0A = findClosestBC(globalBC, mapGlobalBcWithT0A); int64_t distClosestBcT0A = globalBC - static_cast(closestBcT0A); @@ -1683,6 +1750,15 @@ struct UpcCandProducer { fitInfo.ampFT0C = std::accumulate(t0AmpsC.begin(), t0AmpsC.end(), 0.f); chFT0A = ft0.amplitudeA().size(); chFT0C = ft0.amplitudeC().size(); + // get selection flags per BC + trs = ft0.bc_as().selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) ? 1 : 0; + trofs = ft0.bc_as().selection_bit(o2::aod::evsel::kNoCollInRofStandard) ? 1 : 0; + hmpr = ft0.bc_as().selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof) ? 1 : 0; + tfb = ft0.bc_as().selection_bit(o2::aod::evsel::kNoTimeFrameBorder) ? 1 : 0; + itsROFb = ft0.bc_as().selection_bit(o2::aod::evsel::kNoITSROFrameBorder) ? 1 : 0; + sbp = ft0.bc_as().selection_bit(o2::aod::evsel::kNoSameBunchPileup) ? 1 : 0; + zVtxFT0vPv = ft0.bc_as().selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV) ? 1 : 0; + vtxITSTPC = ft0.bc_as().selection_bit(o2::aod::evsel::kIsVertexITSTPC) ? 1 : 0; fillAmplitudes(ft0s, mapGlobalBcWithT0A, amplitudesT0A, relBCsT0A, globalBC); } uint8_t chFV0A = 0; @@ -1755,7 +1831,7 @@ struct UpcCandProducer { fitInfo.BBFT0Apf, fitInfo.BBFT0Cpf, fitInfo.BGFT0Apf, fitInfo.BGFT0Cpf, fitInfo.BBFV0Apf, fitInfo.BGFV0Apf, fitInfo.BBFDDApf, fitInfo.BBFDDCpf, fitInfo.BGFDDApf, fitInfo.BGFDDCpf); - eventCandidatesSelExtras(chFT0A, chFT0C, chFDDA, chFDDC, chFV0A, 0, 0, 0, 0, 0); + eventCandidatesSelExtras(chFT0A, chFT0C, chFDDA, chFDDC, chFV0A, 0, 0, trs, trofs, hmpr, tfb, itsROFb, sbp, zVtxFT0vPv, vtxITSTPC, 0); eventCandidatesSelsFwd(fitInfo.distClosestBcV0A, fitInfo.distClosestBcT0A, amplitudesT0A, diff --git a/PWGUD/TableProducer/tauEventTableProducer.cxx b/PWGUD/TableProducer/tauEventTableProducer.cxx new file mode 100644 index 00000000000..548d8701689 --- /dev/null +++ b/PWGUD/TableProducer/tauEventTableProducer.cxx @@ -0,0 +1,721 @@ +// 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. +// +/// \file tauEventTableProducer.cxx +/// \brief Produces derived table from UD tables +/// +/// \author Roman Lavicka , Austrian Academy of Sciences & SMI +/// \since 09.04.2025 +// + +// C++ headers +#include +#include +#include +#include +#include + +// O2 headers +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + +// O2Physics headers +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/DataModel/TauEventTables.h" +#include "PWGUD/Core/SGSelector.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +struct TauEventTableProducer { + Produces tauTwoTracks; + Produces trueTauTwoTracks; + + // Global varialbes + Service pdg; + SGSelector sgSelector; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // declare configurables + Configurable verboseInfo{"verboseInfo", false, {"Print general info to terminal; default it false."}}; + + struct : ConfigurableGroup { + Configurable whichGapSide{"whichGapSide", 2, {"0 for side A, 1 for side C, 2 for both sides"}}; + Configurable useTrueGap{"useTrueGap", true, {"Calculate gapSide for a given FV0/FT0/ZDC thresholds"}}; + Configurable cutNumContribs{"cutNumContribs", 2, {"How many contributors event has"}}; + Configurable useNumContribs{"useNumContribs", false, {"Use coll.numContribs as event cut"}}; + Configurable cutRecoFlag{"cutRecoFlag", 1, {"0 = std mode, 1 = upc mode"}}; + Configurable useRecoFlag{"useRecoFlag", false, {"Use coll.flags as event cut"}}; + Configurable cutRCTflag{"cutRCTflag", 0, {"0 = off, 1 = CBT, 2 = CBT+ZDC, 3 = CBThadron, 4 = CBThadron+ZDC"}}; + Configurable cutTrueGapSideFV0{"cutTrueGapSideFV0", 180000, "FV0A threshold for SG selector"}; + Configurable cutTrueGapSideFT0A{"cutTrueGapSideFT0A", 150., "FT0A threshold for SG selector"}; + Configurable cutTrueGapSideFT0C{"cutTrueGapSideFT0C", 50., "FT0C threshold for SG selector"}; + Configurable cutTrueGapSideZDC{"cutTrueGapSideZDC", 10000., "ZDC threshold for SG selector. 0 is <1n, 4.2 is <2n, 6.7 is <3n, 9.5 is <4n, 12.5 is <5n"}; + Configurable cutFITtime{"cutFITtime", 40., "Maximum FIT time allowed. Default is 40ns"}; + Configurable cutEvTFb{"cutEvTFb", true, {"Event selection bit kNoTimeFrameBorder"}}; + Configurable cutEvITSROFb{"cutEvITSROFb", true, {"Event selection bit kNoITSROFrameBorder"}}; + Configurable cutEvSbp{"cutEvSbp", true, {"Event selection bit kNoSameBunchPileup"}}; + Configurable cutEvZvtxFT0vPV{"cutEvZvtxFT0vPV", false, {"Event selection bit kIsGoodZvtxFT0vsPV"}}; + Configurable cutEvVtxITSTPC{"cutEvVtxITSTPC", true, {"Event selection bit kIsVertexITSTPC"}}; + Configurable cutEvOccupancy{"cutEvOccupancy", 100000., "Maximum allowed occupancy"}; + Configurable cutEvTrs{"cutEvTrs", false, {"Event selection bit kNoCollInTimeRangeStandard"}}; + Configurable cutEvTrofs{"cutEvTrofs", false, {"Event selection bit kNoCollInRofStandard"}}; + Configurable cutEvHmpr{"cutEvHmpr", false, {"Event selection bit kNoHighMultCollInPrevRof"}}; + } cutSample; + + struct : ConfigurableGroup { + Configurable applyGlobalTrackSelection{"applyGlobalTrackSelection", false, {"Applies cut on here defined global tracks"}}; + Configurable cutMinPt{"cutMinPt", 0.1f, {"Global track cut"}}; + Configurable cutMaxPt{"cutMaxPt", 1e10f, {"Global track cut"}}; + Configurable cutMinEta{"cutMinEta", -0.8f, {"Global track cut"}}; + Configurable cutMaxEta{"cutMaxEta", 0.8f, {"Global track cut"}}; + Configurable cutMaxDCAz{"cutMaxDCAz", 2.f, {"Global track cut"}}; + Configurable cutMaxDCAxy{"cutMaxDCAxy", 1e10f, {"Global track cut"}}; + Configurable applyPtDependentDCAxy{"applyPtDependentDCAxy", false, {"Global track cut"}}; + Configurable cutHasITS{"cutHasITS", true, {"Global track cut"}}; + Configurable cutMinITSnCls{"cutMinITSnCls", 1, {"Global track cut"}}; + Configurable cutMaxITSchi2{"cutMaxITSchi2", 36.f, {"Global track cut"}}; + Configurable cutITShitsRule{"cutITShitsRule", 0, {"Global track cut"}}; + Configurable cutHasTPC{"cutHasTPC", true, {"Global track cut"}}; + Configurable cutMinTPCnCls{"cutMinTPCnCls", 1, {"Global track cut"}}; + Configurable cutMinTPCnClsXrows{"cutMinTPCnClsXrows", 70, {"Global track cut"}}; + Configurable cutMinTPCnClsXrowsOverNcls{"cutMinTPCnClsXrowsOverNcls", 0.8f, {"Global track cut"}}; + Configurable cutMaxTPCchi2{"cutMaxTPCchi2", 4.f, {"Global track cut"}}; + Configurable cutGoodITSTPCmatching{"cutGoodITSTPCmatching", true, {"Global track cut"}}; + Configurable cutMaxTOFchi2{"cutMaxTOFchi2", 3.f, {"Global track cut"}}; + } cutGlobalTrack; + + struct : ConfigurableGroup { + Configurable preselUseTrackPID{"preselUseTrackPID", true, {"Apply weak PID check on tracks."}}; + Configurable preselNgoodPVtracs{"preselNgoodPVtracs", 2, {"How many good PV tracks to select."}}; + Configurable preselMinElectronNsigmaEl{"preselMinElectronNsigmaEl", 4.0, {"Good el candidate hypo in. Upper n sigma cut on el hypo of selected electron. What is more goes away."}}; + Configurable preselMaxElectronNsigmaEl{"preselMaxElectronNsigmaEl", -2.0, {"Good el candidate hypo in. Lower n sigma cut on el hypo of selected electron. What is less goes away."}}; + Configurable preselElectronHasTOF{"preselElectronHasTOF", true, {"Electron candidated is required to hit TOF."}}; + Configurable preselMinPionNsigmaEl{"preselMinPionNsigmaEl", 5.0, {"Good pi candidate hypo in. Upper n sigma cut on pi hypo of selected electron. What is more goes away."}}; + Configurable preselMaxPionNsigmaEl{"preselMaxPionNsigmaEl", -5.0, {"Good pi candidate hypo in. Lower n sigma cut on pi hypo of selected electron. What is less goes away."}}; + Configurable preselMinMuonNsigmaEl{"preselMinMuonNsigmaEl", 5.0, {"Good pi candidate hypo in. Upper n sigma cut on pi hypo of selected electron. What is more goes away."}}; + Configurable preselMaxMuonNsigmaEl{"preselMaxMuonNsigmaEl", -5.0, {"Good pi candidate hypo in. Lower n sigma cut on pi hypo of selected electron. What is less goes away."}}; + Configurable preselMupionHasTOF{"preselMupionHasTOF", true, {"Mupion candidate is required to hit TOF."}}; + } cutPreselect; + + using FullUDTracks = soa::Join; + using FullSGUDCollisions = soa::Join; + using FullSGUDCollision = FullSGUDCollisions::iterator; + using FullMCUDTracks = soa::Join; + using FullMCSGUDCollisions = soa::Join; + using FullMCSGUDCollision = FullMCSGUDCollisions::iterator; + + // init + void init(InitContext&) + { + if (verboseInfo) + printMediumMessage("INIT METHOD"); + + mySetITShitsRule(cutGlobalTrack.cutITShitsRule); + + histos.add("Truth/hTroubles", "Counter of unwanted issues;;Number of troubles (-)", HistType::kTH1D, {{15, 0.5, 15.5}}); + + } // end init + + template + bool isGoodFITtime(C const& coll, float maxFITtime) + { + + // FTOA + if ((std::abs(coll.timeFT0A()) > maxFITtime) && coll.timeFT0A() > -998.) + return false; + + // FTOC + if ((std::abs(coll.timeFT0C()) > maxFITtime) && coll.timeFT0C() > -998.) + return false; + + return true; + } + + template + bool isGoodRCTflag(C const& coll) + { + switch (cutSample.cutRCTflag) { + case 1: + return sgSelector.isCBTOk(coll); + case 2: + return sgSelector.isCBTZdcOk(coll); + case 3: + return sgSelector.isCBTHadronOk(coll); + case 4: + return sgSelector.isCBTHadronZdcOk(coll); + default: + return true; + } + } + + template + bool isGoodROFtime(C const& coll) + { + + // kNoTimeFrameBorder + if (cutSample.cutEvTFb && !coll.tfb()) + return false; + + // kNoITSROFrameBorder + if (cutSample.cutEvITSROFb && !coll.itsROFb()) + return false; + + // kNoSameBunchPileup + if (cutSample.cutEvSbp && !coll.sbp()) + return false; + + // kIsGoodZvtxFT0vsPV + if (cutSample.cutEvZvtxFT0vPV && !coll.zVtxFT0vPV()) + return false; + + // kIsVertexITSTPC + if (cutSample.cutEvVtxITSTPC && !coll.vtxITSTPC()) + return false; + + // Occupancy + if (coll.occupancyInTime() > cutSample.cutEvOccupancy) + return false; + + // kNoCollInTimeRangeStandard + if (cutSample.cutEvTrs && !coll.trs()) + return false; + + // kNoCollInRofStandard + if (cutSample.cutEvTrofs && !coll.trofs()) + return false; + + // kNoHighMultCollInPrevRof + if (cutSample.cutEvHmpr && !coll.hmpr()) + return false; + + return true; + } + + std::vector>> cutMyRequiredITSHits{}; + + void mySetRequireHitsInITSLayers(int8_t minNRequiredHits, std::set requiredLayers) + { + // layer 0 corresponds to the the innermost ITS layer + cutMyRequiredITSHits.push_back(std::make_pair(minNRequiredHits, requiredLayers)); + } + + void mySetITShitsRule(int matching) + { + switch (matching) { + case 0: // Run3ITSibAny + mySetRequireHitsInITSLayers(1, {0, 1, 2}); + break; + case 1: // Run3ITSibTwo + mySetRequireHitsInITSLayers(2, {0, 1, 2}); + break; + case 2: // Run3ITSallAny + mySetRequireHitsInITSLayers(1, {0, 1, 2, 3, 4, 5, 6}); + break; + case 3: // Run3ITSall7Layers + mySetRequireHitsInITSLayers(7, {0, 1, 2, 3, 4, 5, 6}); + break; + default: + LOG(fatal) << "You chose wrong ITS matching"; + break; + } + } + + bool isFulfillsITSHitRequirementsReinstatement(uint8_t itsClusterMap) const + { + constexpr uint8_t kBit = 1; + for (const auto& kITSrequirement : cutMyRequiredITSHits) { + auto hits = std::count_if(kITSrequirement.second.begin(), kITSrequirement.second.end(), [&](auto&& requiredLayer) { return itsClusterMap & (kBit << requiredLayer); }); + if ((kITSrequirement.first == -1) && (hits > 0)) { + return false; // no hits were required in specified layers + } else if (hits < kITSrequirement.first) { + return false; // not enough hits found in specified layers + } + } + return true; + } + + template + bool isGlobalTrackReinstatement(T const& track) + { + // kInAcceptance copy + if (track.pt() < cutGlobalTrack.cutMinPt || track.pt() > cutGlobalTrack.cutMaxPt) + return false; + if (eta(track.px(), track.py(), track.pz()) < cutGlobalTrack.cutMinEta || eta(track.px(), track.py(), track.pz()) > cutGlobalTrack.cutMaxEta) + return false; + // kPrimaryTracks + // GoldenChi2 cut is only for Run 2 + if (std::abs(track.dcaZ()) > cutGlobalTrack.cutMaxDCAz) + return false; + if (cutGlobalTrack.applyPtDependentDCAxy) { + float maxDCA = 0.0182f + 0.0350f / std::pow(track.pt(), 1.01f); + if (std::abs(track.dcaXY()) > maxDCA) + return false; + } else { + if (std::abs(track.dcaXY()) > cutGlobalTrack.cutMaxDCAxy) + return false; + } + // kQualityTrack + // TrackType is always 1 as per definition of processed Run3 AO2Ds + // ITS + if (cutGlobalTrack.cutHasITS && !track.hasITS()) + return false; // ITS refit + if (track.itsNCls() < cutGlobalTrack.cutMinITSnCls) + return false; + if (track.itsChi2NCl() > cutGlobalTrack.cutMaxITSchi2) + return false; + if (!isFulfillsITSHitRequirementsReinstatement(track.itsClusterMap())) + return false; + // TPC + if (cutGlobalTrack.cutHasTPC && !track.hasTPC()) + return false; // TPC refit + if ((track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()) < cutGlobalTrack.cutMinTPCnCls) + return false; // tpcNClsFound() + if (track.tpcNClsCrossedRows() < cutGlobalTrack.cutMinTPCnClsXrows) + return false; + if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < cutGlobalTrack.cutMinTPCnClsXrowsOverNcls) + return false; + if (track.tpcChi2NCl() > cutGlobalTrack.cutMaxTPCchi2) + return false; // TPC chi2 + if (cutGlobalTrack.cutGoodITSTPCmatching) { + if (track.itsChi2NCl() < 0.) + return false; // good ITS-TPC matching means ITS ch2 is not negative + } + // TOF + if (track.hasTOF()) { + if (track.tpcChi2NCl() > cutGlobalTrack.cutMaxTOFchi2) + return false; // TOF chi2 + } + + return true; + } + + template + bool isElectronCandidate(T const& electronCandidate) + // Loose criterium to find electron-like particle + // Requiring TOF to avoid double-counting pions/electrons and for better timing + { + if (electronCandidate.tpcNSigmaEl() < cutPreselect.preselMaxElectronNsigmaEl || electronCandidate.tpcNSigmaEl() > cutPreselect.preselMinElectronNsigmaEl) + return false; + if (cutPreselect.preselElectronHasTOF && !electronCandidate.hasTOF()) + return false; + return true; + } + + template + bool isMuPionCandidate(T const& muPionCandidate) + // Loose criterium to find muon/pion-like particle + // Requiring TOF for better timing + { + if (muPionCandidate.tpcNSigmaMu() < cutPreselect.preselMaxMuonNsigmaEl || muPionCandidate.tpcNSigmaMu() > cutPreselect.preselMinMuonNsigmaEl) + return false; + if (muPionCandidate.tpcNSigmaPi() < cutPreselect.preselMaxPionNsigmaEl || muPionCandidate.tpcNSigmaPi() > cutPreselect.preselMinPionNsigmaEl) + return false; + if (cutPreselect.preselMupionHasTOF && !muPionCandidate.hasTOF()) + return false; + return true; + } + + void processDataSG(FullSGUDCollision const& collision, + FullUDTracks const& tracks) + { + + if (!isGoodRCTflag(collision)) + return; + + if (!isGoodROFtime(collision)) + return; + + int gapSide = collision.gapSide(); + int trueGapSide = sgSelector.trueGap(collision, cutSample.cutTrueGapSideFV0, cutSample.cutTrueGapSideFT0A, cutSample.cutTrueGapSideFT0C, cutSample.cutTrueGapSideZDC); + if (cutSample.useTrueGap) + gapSide = trueGapSide; + if (gapSide != cutSample.whichGapSide) + return; + + if (!isGoodFITtime(collision, cutSample.cutFITtime)) + return; + + if (cutSample.useNumContribs && (collision.numContrib() != cutSample.cutNumContribs)) + return; + + if (cutSample.useRecoFlag && (collision.flags() != cutSample.cutRecoFlag)) + return; + + int countTracksPerCollision = 0; + int countGoodNonPVtracks = 0; + int countGoodPVtracks = 0; + std::vector vecTrkIdx; + // Loop over tracks with selections + for (const auto& track : tracks) { + countTracksPerCollision++; + if (!isGlobalTrackReinstatement(track)) + continue; + if (!track.isPVContributor()) { + countGoodNonPVtracks++; + continue; + } + countGoodPVtracks++; + vecTrkIdx.push_back(track.index()); + } // Loop over tracks with selections + + // Apply weak condition on track PID + int countPVGTel = 0; + int countPVGTmupi = 0; + if (countGoodPVtracks == 2) { + for (const auto& vecMember : vecTrkIdx) { + const auto& thisTrk = tracks.iteratorAt(vecMember); + if (isElectronCandidate(thisTrk)) { + countPVGTel++; + continue; + } + if (isMuPionCandidate(thisTrk)) { + countPVGTmupi++; + } + } + } + + if (cutPreselect.preselUseTrackPID ? ((countPVGTel == 2 && countPVGTmupi == 0) || (countPVGTel == 1 && countPVGTmupi == 1)) : countGoodPVtracks == cutPreselect.preselNgoodPVtracs) { + const auto& trk1 = tracks.iteratorAt(vecTrkIdx[0]); + const auto& trk2 = tracks.iteratorAt(vecTrkIdx[1]); + + float px[2] = {trk1.px(), trk2.px()}; + float py[2] = {trk1.py(), trk2.py()}; + float pz[2] = {trk1.pz(), trk2.pz()}; + int sign[2] = {trk1.sign(), trk2.sign()}; + float dcaxy[2] = {trk1.dcaXY(), trk2.dcaXY()}; + float dcaz[2] = {trk1.dcaZ(), trk2.dcaZ()}; + float trkTimeRes[2] = {trk1.trackTimeRes(), trk2.trackTimeRes()}; + uint32_t itsClusterSizesTrk1 = trk1.itsClusterSizes(); + uint32_t itsClusterSizesTrk2 = trk2.itsClusterSizes(); + float tpcSignal[2] = {trk1.tpcSignal(), trk2.tpcSignal()}; + float tpcEl[2] = {trk1.tpcNSigmaEl(), trk2.tpcNSigmaEl()}; + float tpcMu[2] = {trk1.tpcNSigmaMu(), trk2.tpcNSigmaMu()}; + float tpcPi[2] = {trk1.tpcNSigmaPi(), trk2.tpcNSigmaPi()}; + float tpcKa[2] = {trk1.tpcNSigmaKa(), trk2.tpcNSigmaKa()}; + float tpcPr[2] = {trk1.tpcNSigmaPr(), trk2.tpcNSigmaPr()}; + float tpcIP[2] = {trk1.tpcInnerParam(), trk2.tpcInnerParam()}; + float tofSignal[2] = {trk1.tofSignal(), trk2.tofSignal()}; + float tofEl[2] = {trk1.tofNSigmaEl(), trk2.tofNSigmaEl()}; + float tofMu[2] = {trk1.tofNSigmaMu(), trk2.tofNSigmaMu()}; + float tofPi[2] = {trk1.tofNSigmaPi(), trk2.tofNSigmaPi()}; + float tofKa[2] = {trk1.tofNSigmaKa(), trk2.tofNSigmaKa()}; + float tofPr[2] = {trk1.tofNSigmaPr(), trk2.tofNSigmaPr()}; + float tofEP[2] = {trk1.tofExpMom(), trk2.tofExpMom()}; + // float infoZDC[4] = {-999., -999., -999., -999.}; + // if constexpr (requires { collision.udZdcsReduced(); }) { + // infoZDC[0] = collision.energyCommonZNA(); + // infoZDC[1] = collision.energyCommonZNC(); + // infoZDC[2] = collision.timeZNA(); + // infoZDC[3] = collision.timeZNC(); + // } + float infoZDC[4] = {collision.energyCommonZNA(), collision.energyCommonZNC(), collision.timeZNA(), collision.timeZNC()}; + + tauTwoTracks(collision.runNumber(), collision.globalBC(), countTracksPerCollision, collision.numContrib(), countGoodNonPVtracks, collision.posX(), collision.posY(), collision.posZ(), + collision.flags(), collision.occupancyInTime(), collision.hadronicRate(), collision.trs(), collision.trofs(), collision.hmpr(), + collision.tfb(), collision.itsROFb(), collision.sbp(), collision.zVtxFT0vPV(), collision.vtxITSTPC(), + collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), collision.totalFV0AmplitudeA(), infoZDC[0], infoZDC[1], + collision.timeFT0A(), collision.timeFT0C(), collision.timeFV0A(), infoZDC[2], infoZDC[3], + px, py, pz, sign, dcaxy, dcaz, trkTimeRes, + itsClusterSizesTrk1, itsClusterSizesTrk2, + tpcSignal, tpcEl, tpcMu, tpcPi, tpcKa, tpcPr, tpcIP, + tofSignal, tofEl, tofMu, tofPi, tofKa, tofPr, tofEP); + } + } + PROCESS_SWITCH(TauEventTableProducer, processDataSG, "Iterate UD tables with measured data created by SG-Candidate-Producer.", false); + + PresliceUnsorted partPerMcCollision = aod::udmcparticle::udMcCollisionId; + PresliceUnsorted colPerMcCollision = aod::udcollision::udMcCollisionId; + PresliceUnsorted trackPerMcParticle = aod::udmctracklabel::udMcParticleId; + Preslice trackPerCollision = aod::udtrack::udCollisionId; // sorted preslice used because the pair track-collision is already sorted in processDataSG function + + void processMonteCarlo(aod::UDMcCollisions const& mccollisions, + aod::UDMcParticles const& parts, + FullMCSGUDCollisions const& recolls, + FullMCUDTracks const& trks) + { + // start loop over generated collisions + for (const auto& mccoll : mccollisions) { + + // prepare local variables for output table + int32_t runNumber = -999; + int bc = -999; + int nTrks[3] = {-999, -999, -999}; // totalTracks, numContrib, globalNonPVtracks + float vtxPos[3] = {-999., -999., -999.}; + int recoMode = -999; + int occupancy = -999.; + double hadronicRate = -999.; + int bcSels[8] = {-999, -999, -999, -999, -999, -999, -999, -999}; + float amplitudesFIT[3] = {-999., -999., -999.}; // FT0A, FT0C, FV0 + float timesFIT[3] = {-999., -999., -999.}; // FT0A, FT0C, FV0 + + float px[2] = {-999., -999.}; + float py[2] = {-999., -999.}; + float pz[2] = {-999., -999.}; + int sign[2] = {-999, -999}; + float dcaxy[2] = {-999., -999.}; + float dcaz[2] = {-999., -999.}; + float trkTimeRes[2] = {-999., -999.}; + uint32_t itsClusterSizesTrk1 = 4294967295; + uint32_t itsClusterSizesTrk2 = 4294967295; + float tpcSignal[2] = {-999, -999}; + float tpcEl[2] = {-999, -999}; + float tpcMu[2] = {-999, -999}; + float tpcPi[2] = {-999, -999}; + float tpcKa[2] = {-999, -999}; + float tpcPr[2] = {-999, -999}; + float tpcIP[2] = {-999, -999}; + float tofSignal[2] = {-999, -999}; + float tofEl[2] = {-999, -999}; + float tofMu[2] = {-999, -999}; + float tofPi[2] = {-999, -999}; + float tofKa[2] = {-999, -999}; + float tofPr[2] = {-999, -999}; + float tofEP[2] = {-999, -999}; + + int trueChannel = -1; + bool trueHasRecoColl = false; + float trueTauX[2] = {-999., -999.}; + float trueTauY[2] = {-999., -999.}; + float trueTauZ[2] = {-999., -999.}; + float trueDaugX[2] = {-999., -999.}; + float trueDaugY[2] = {-999., -999.}; + float trueDaugZ[2] = {-999., -999.}; + int trueDaugPdgCode[2] = {-999, -999}; + bool problem = false; + + // find reconstructed collisions associated to the generated collision + auto const& collFromMcColls = recolls.sliceBy(colPerMcCollision, mccoll.globalIndex()); + // check the generated collision was reconstructed + if (collFromMcColls.size() > 0) { // get the truth and reco-level info + trueHasRecoColl = true; + // check there is exactly one reco-level collision associated to generated collision + if (collFromMcColls.size() > 1) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 1 reco collision. Skipping this event."); + histos.get(HIST("Truth/hTroubles"))->Fill(1); + problem = true; + continue; + } + // grap reco-level collision + auto const& collFromMcColl = collFromMcColls.iteratorAt(0); + // grab tracks from the reco-level collision to get info to match measured data tables (processDataSG function) + auto const& trksFromColl = trks.sliceBy(trackPerCollision, collFromMcColl.globalIndex()); + int countTracksPerCollision = 0; + int countGoodNonPVtracks = 0; + for (auto const& trkFromColl : trksFromColl) { + countTracksPerCollision++; + if (!trkFromColl.isPVContributor()) { + countGoodNonPVtracks++; + continue; + } + } + + // fill info for reconstructed collision + runNumber = collFromMcColl.runNumber(); + bc = collFromMcColl.globalBC(); + nTrks[0] = countTracksPerCollision; + nTrks[1] = collFromMcColl.numContrib(); + nTrks[2] = countGoodNonPVtracks; + vtxPos[0] = collFromMcColl.posX(); + vtxPos[1] = collFromMcColl.posY(); + vtxPos[2] = collFromMcColl.posZ(); + recoMode = collFromMcColl.flags(); + occupancy = collFromMcColl.occupancyInTime(); + hadronicRate = collFromMcColl.hadronicRate(); + bcSels[0] = collFromMcColl.trs(); + bcSels[1] = collFromMcColl.trofs(); + bcSels[2] = collFromMcColl.hmpr(); + bcSels[3] = collFromMcColl.tfb(); + bcSels[4] = collFromMcColl.itsROFb(); + bcSels[5] = collFromMcColl.sbp(); + bcSels[6] = collFromMcColl.zVtxFT0vPV(); + bcSels[7] = collFromMcColl.vtxITSTPC(); + amplitudesFIT[0] = collFromMcColl.totalFT0AmplitudeA(); + amplitudesFIT[1] = collFromMcColl.totalFT0AmplitudeC(); + amplitudesFIT[2] = collFromMcColl.totalFV0AmplitudeA(); + timesFIT[0] = collFromMcColl.timeFT0A(); + timesFIT[1] = collFromMcColl.timeFT0C(); + timesFIT[2] = collFromMcColl.timeFV0A(); + + // get particles associated to generated collision + auto const& partsFromMcColl = parts.sliceBy(partPerMcCollision, mccoll.globalIndex()); + int countMothers = 0; + for (const auto& particle : partsFromMcColl) { + // select only tauons with checking if particle has no mother + if (particle.has_mothers()) + continue; + countMothers++; + // check the generated collision does not have more than 2 tauons + if (countMothers > 2) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 2 no mother particles. Breaking the particle loop."); + histos.get(HIST("Truth/hTroubles"))->Fill(2); + problem = true; + break; + } + // fill info for each tau + trueTauX[countMothers - 1] = particle.px(); + trueTauY[countMothers - 1] = particle.py(); + trueTauZ[countMothers - 1] = particle.pz(); + + // get daughters of the tau + const auto& daughters = particle.daughters_as(); + int countDaughters = 0; + for (const auto& daughter : daughters) { + // check if it is the charged particle (= no pi0 or neutrino) + if (enumMyParticle(daughter.pdgCode()) == -1) + continue; + countDaughters++; + // check there is only 1 charged daughter related to 1 tau + if (countDaughters > 1) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 1 charged daughters of no mother particles. Breaking the daughter loop."); + histos.get(HIST("Truth/hTroubles"))->Fill(3); + problem = true; + break; + } + // fill info for each daughter + trueDaugX[countMothers - 1] = daughter.px(); + trueDaugY[countMothers - 1] = daughter.py(); + trueDaugZ[countMothers - 1] = daughter.pz(); + trueDaugPdgCode[countMothers - 1] = daughter.pdgCode(); + + // get tracks associated to MC daughter (how well the daughter was reconstructed) + auto const& tracksFromDaughter = trks.sliceBy(trackPerMcParticle, daughter.globalIndex()); + // check there is exactly 1 track per 1 particle + if (tracksFromDaughter.size() > 1) { + if (verboseInfo) + printLargeMessage("Daughter has more than 1 associated track. Skipping this daughter."); + histos.get(HIST("Truth/hTroubles"))->Fill(4); + problem = true; + continue; + } + // grab the track and fill info for reconstructed track (should be done twice) + const auto& trk = tracksFromDaughter.iteratorAt(0); + px[countMothers - 1] = trk.px(); + py[countMothers - 1] = trk.py(); + pz[countMothers - 1] = trk.pz(); + sign[countMothers - 1] = trk.sign(); + dcaxy[countMothers - 1] = trk.dcaXY(); + dcaz[countMothers - 1] = trk.dcaZ(); + trkTimeRes[countMothers - 1] = trk.trackTimeRes(); + if (countMothers == 1) { + itsClusterSizesTrk1 = trk.itsClusterSizes(); + } else { + itsClusterSizesTrk2 = trk.itsClusterSizes(); + } + tpcSignal[countMothers - 1] = trk.tpcSignal(); + tpcEl[countMothers - 1] = trk.tpcNSigmaEl(); + tpcMu[countMothers - 1] = trk.tpcNSigmaMu(); + tpcPi[countMothers - 1] = trk.tpcNSigmaPi(); + tpcKa[countMothers - 1] = trk.tpcNSigmaKa(); + tpcPr[countMothers - 1] = trk.tpcNSigmaPr(); + tpcIP[countMothers - 1] = trk.tpcInnerParam(); + tofSignal[countMothers - 1] = trk.tofSignal(); + tofEl[countMothers - 1] = trk.tofNSigmaEl(); + tofMu[countMothers - 1] = trk.tofNSigmaMu(); + tofPi[countMothers - 1] = trk.tofNSigmaPi(); + tofKa[countMothers - 1] = trk.tofNSigmaKa(); + tofPr[countMothers - 1] = trk.tofNSigmaPr(); + tofEP[countMothers - 1] = trk.tofExpMom(); + } // daughters + } // particles + } else { // get only the truth information. The reco-level info is left on default + // get particles associated to generated collision + auto const& partsFromMcColl = parts.sliceBy(partPerMcCollision, mccoll.globalIndex()); + int countMothers = 0; + for (const auto& particle : partsFromMcColl) { + // select only tauons with checking if particle has no mother + if (particle.has_mothers()) + continue; + countMothers++; + // check the generated collision does not have more than 2 tauons + if (countMothers > 2) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 2 no mother particles. Breaking the particle loop."); + histos.get(HIST("Truth/hTroubles"))->Fill(12); + problem = true; + break; + } + // fill info for each tau + trueTauX[countMothers - 1] = particle.px(); + trueTauY[countMothers - 1] = particle.py(); + trueTauZ[countMothers - 1] = particle.pz(); + + // get daughters of the tau + const auto& daughters = particle.daughters_as(); + int countDaughters = 0; + for (const auto& daughter : daughters) { + // select only the charged particle (= no pi0 or neutrino) + if (enumMyParticle(daughter.pdgCode()) == -1) + continue; + countDaughters++; + // check there is only 1 charged daughter related to 1 tau + if (countDaughters > 1) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 1 charged daughters of no mother particles. Breaking the daughter loop."); + histos.get(HIST("Truth/hTroubles"))->Fill(13); + problem = true; + break; + } + // fill info for each daughter + trueDaugX[countMothers - 1] = daughter.px(); + trueDaugY[countMothers - 1] = daughter.py(); + trueDaugZ[countMothers - 1] = daughter.pz(); + trueDaugPdgCode[countMothers - 1] = daughter.pdgCode(); + } // daughters + } // particles + } // collisions + + // decide the channel and set the variable. Only two cahnnels suported now. + if ((enumMyParticle(trueDaugPdgCode[0]) == P_ELECTRON) && (enumMyParticle(trueDaugPdgCode[1]) == P_ELECTRON)) + trueChannel = CH_EE; + if ((enumMyParticle(trueDaugPdgCode[0]) == P_ELECTRON) && ((enumMyParticle(trueDaugPdgCode[1]) == P_PION) || (enumMyParticle(trueDaugPdgCode[1]) == P_MUON))) + trueChannel = CH_EMUPI; + if ((enumMyParticle(trueDaugPdgCode[1]) == P_ELECTRON) && ((enumMyParticle(trueDaugPdgCode[0]) == P_PION) || (enumMyParticle(trueDaugPdgCode[0]) == P_MUON))) + trueChannel = CH_EMUPI; + + trueTauTwoTracks(runNumber, bc, nTrks[0], nTrks[1], nTrks[2], vtxPos[0], vtxPos[1], vtxPos[2], + recoMode, occupancy, hadronicRate, bcSels[0], bcSels[1], bcSels[2], + bcSels[3], bcSels[4], bcSels[5], bcSels[6], bcSels[7], + amplitudesFIT[0], amplitudesFIT[1], amplitudesFIT[2], -999., -999., // no ZDC info in MC + timesFIT[0], timesFIT[1], timesFIT[2], -999., -999., // no ZDC info in MC + px, py, pz, sign, dcaxy, dcaz, trkTimeRes, + itsClusterSizesTrk1, itsClusterSizesTrk2, + tpcSignal, tpcEl, tpcMu, tpcPi, tpcKa, tpcPr, tpcIP, + tofSignal, tofEl, tofMu, tofPi, tofKa, tofPr, tofEP, + trueChannel, trueHasRecoColl, mccoll.posX(), mccoll.posY(), mccoll.posZ(), + trueTauX, trueTauY, trueTauZ, trueDaugX, trueDaugY, trueDaugZ, trueDaugPdgCode, problem); + } // mccollisions + } + PROCESS_SWITCH(TauEventTableProducer, processMonteCarlo, "Iterate UD tables with simulated data created by SG-Candidate-Producer.", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/TableProducer/twoTracksEventTableProducer.cxx b/PWGUD/TableProducer/twoTracksEventTableProducer.cxx new file mode 100644 index 00000000000..f132315c403 --- /dev/null +++ b/PWGUD/TableProducer/twoTracksEventTableProducer.cxx @@ -0,0 +1,778 @@ +// 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. +// +/// \file twoTracksEventTableProducer.cxx +/// \brief Produces derived table from UD tables +/// +/// \author Roman Lavicka , Austrian Academy of Sciences & SMI +/// \since 20.06.2025 +// + +// C++ headers +#include +#include +#include +#include +#include + +// O2 headers +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + +// O2Physics headers +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" +#include "PWGUD/DataModel/TwoTracksEventTables.h" +#include "PWGUD/DataModel/UDTables.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +// ROOT +#include "Math/Vector4D.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +struct TwoTracksEventTableProducer { + Produces twoTracks; + Produces trueTwoTracks; + + // Global varialbes + Service pdg; + SGSelector sgSelector; + int nSelection{0}; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // declare configurables + Configurable verboseInfo{"verboseInfo", false, {"Print general info to terminal; default it false."}}; + + struct : ConfigurableGroup { + Configurable whichGapSide{"whichGapSide", 2, {"0 for side A, 1 for side C, 2 for both sides"}}; + Configurable useTrueGap{"useTrueGap", true, {"Calculate gapSide for a given FV0/FT0/ZDC thresholds"}}; + Configurable cutNumContribs{"cutNumContribs", 2, {"How many contributors event has"}}; + Configurable useNumContribs{"useNumContribs", true, {"Use coll.numContribs as event cut"}}; + Configurable cutRecoFlag{"cutRecoFlag", 1, {"0 = std mode, 1 = upc mode"}}; + Configurable useRecoFlag{"useRecoFlag", false, {"Use coll.flags as event cut"}}; + Configurable cutRCTflag{"cutRCTflag", 0, {"0 = off, 1 = CBT, 2 = CBT+ZDC, 3 = CBThadron, 4 = CBThadron+ZDC"}}; + Configurable cutTrueGapSideFV0{"cutTrueGapSideFV0", 180000, "FV0A threshold for SG selector"}; + Configurable cutTrueGapSideFT0A{"cutTrueGapSideFT0A", 150., "FT0A threshold for SG selector"}; + Configurable cutTrueGapSideFT0C{"cutTrueGapSideFT0C", 50., "FT0C threshold for SG selector"}; + Configurable cutTrueGapSideZDC{"cutTrueGapSideZDC", 10000., "ZDC threshold for SG selector. 0 is <1n, 4.2 is <2n, 6.7 is <3n, 9.5 is <4n, 12.5 is <5n"}; + Configurable cutFITtime{"cutFITtime", 40., "Maximum FIT time allowed. Default is 40ns"}; + Configurable cutEvTFb{"cutEvTFb", true, {"Event selection bit kNoTimeFrameBorder"}}; + Configurable cutEvITSROFb{"cutEvITSROFb", true, {"Event selection bit kNoITSROFrameBorder"}}; + Configurable cutEvSbp{"cutEvSbp", true, {"Event selection bit kNoSameBunchPileup"}}; + Configurable cutEvZvtxFT0vPV{"cutEvZvtxFT0vPV", false, {"Event selection bit kIsGoodZvtxFT0vsPV"}}; + Configurable cutEvVtxITSTPC{"cutEvVtxITSTPC", true, {"Event selection bit kIsVertexITSTPC"}}; + Configurable cutEvOccupancy{"cutEvOccupancy", 100000., "Maximum allowed occupancy"}; + Configurable cutEvTrs{"cutEvTrs", false, {"Event selection bit kNoCollInTimeRangeStandard"}}; + Configurable cutEvTrofs{"cutEvTrofs", false, {"Event selection bit kNoCollInRofStandard"}}; + Configurable cutEvHmpr{"cutEvHmpr", false, {"Event selection bit kNoHighMultCollInPrevRof"}}; + } cutSample; + + struct : ConfigurableGroup { + Configurable applyGlobalTrackSelection{"applyGlobalTrackSelection", false, {"Applies cut on here defined global tracks"}}; + Configurable cutMinPt{"cutMinPt", 0.1f, {"Global track cut"}}; + Configurable cutMaxPt{"cutMaxPt", 1e10f, {"Global track cut"}}; + Configurable cutMinEta{"cutMinEta", -0.8f, {"Global track cut"}}; + Configurable cutMaxEta{"cutMaxEta", 0.8f, {"Global track cut"}}; + Configurable cutMaxDCAz{"cutMaxDCAz", 2.f, {"Global track cut"}}; + Configurable cutMaxDCAxy{"cutMaxDCAxy", 1e10f, {"Global track cut"}}; + Configurable applyPtDependentDCAxy{"applyPtDependentDCAxy", false, {"Global track cut"}}; + Configurable cutHasITS{"cutHasITS", true, {"Global track cut"}}; + Configurable cutMinITSnCls{"cutMinITSnCls", 1, {"Global track cut"}}; + Configurable cutMaxITSchi2{"cutMaxITSchi2", 36.f, {"Global track cut"}}; + Configurable cutITShitsRule{"cutITShitsRule", 0, {"Global track cut"}}; + Configurable cutHasTPC{"cutHasTPC", true, {"Global track cut"}}; + Configurable cutMinTPCnCls{"cutMinTPCnCls", 1, {"Global track cut"}}; + Configurable cutMinTPCnClsXrows{"cutMinTPCnClsXrows", 70, {"Global track cut"}}; + Configurable cutMinTPCnClsXrowsOverNcls{"cutMinTPCnClsXrowsOverNcls", 0.8f, {"Global track cut"}}; + Configurable cutMaxTPCchi2{"cutMaxTPCchi2", 4.f, {"Global track cut"}}; + Configurable cutGoodITSTPCmatching{"cutGoodITSTPCmatching", true, {"Global track cut"}}; + Configurable cutMaxTOFchi2{"cutMaxTOFchi2", 3.f, {"Global track cut"}}; + } cutGlobalTrack; + + struct : ConfigurableGroup { + Configurable preselAtLeastOneTOFtrack{"preselAtLeastOneTOFtrack", false, {"At least one track is required to hit TOF."}}; + Configurable preselBothAreTOFtracks{"preselBothAreTOFtracks", false, {"Both tracks are required to hit TOF."}}; + Configurable preselUseMinMomentumOnBothTracks{"preselUseMinMomentumOnBothTracks", false, {"Both tracks are required to fill requirement on minimum momentum."}}; + Configurable preselMinTrackMomentum{"preselMinTrackMomentum", 0.1, {"Requirement on minimum momentum of the track."}}; + Configurable preselSystemPtCut{"preselSystemPtCut", 0.0, {"By default, cut on maximum system pT."}}; + Configurable preselUseOppositeSystemPtCut{"preselUseOppositeSystemPtCut", false, {"Negates the system pT cut (cut on minimum system pT)."}}; + Configurable preselMinInvariantMass{"preselMinInvariantMass", 2.0, {"Requirement on minimum system invariant mass."}}; + Configurable preselMaxInvariantMass{"preselMaxInvariantMass", 5.0, {"Requirement on maximum system invariant mass."}}; + } cutPreselect; + + using FullUDTracks = soa::Join; + using FullSGUDCollisions = soa::Join; + using FullSGUDCollision = FullSGUDCollisions::iterator; + using FullMCUDTracks = soa::Join; + using FullMCSGUDCollisions = soa::Join; + using FullMCSGUDCollision = FullMCSGUDCollisions::iterator; + + // init + void init(InitContext&) + { + if (verboseInfo) + printMediumMessage("INIT METHOD"); + + mySetITShitsRule(cutGlobalTrack.cutITShitsRule); + + histos.add("Reco/hSelections", "Effect of selections;;Number of events (-)", HistType::kTH1D, {{50, 0.5, 50.5}}); + histos.add("Truth/hTroubles", "Counter of unwanted issues;;Number of troubles (-)", HistType::kTH1D, {{15, 0.5, 15.5}}); + + } // end init + + template + bool isGoodFITtime(C const& coll, float maxFITtime) + { + + // FTOA + if ((std::abs(coll.timeFT0A()) > maxFITtime) && coll.timeFT0A() > -998.) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // FTOC + if ((std::abs(coll.timeFT0C()) > maxFITtime) && coll.timeFT0C() > -998.) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + return true; + } + + template + bool isGoodRCTflag(C const& coll) + { + switch (cutSample.cutRCTflag) { + case 1: + return sgSelector.isCBTOk(coll); + case 2: + return sgSelector.isCBTZdcOk(coll); + case 3: + return sgSelector.isCBTHadronOk(coll); + case 4: + return sgSelector.isCBTHadronZdcOk(coll); + default: + return true; + } + } + + template + bool isGoodROFtime(C const& coll) + { + + // kNoTimeFrameBorder + if (cutSample.cutEvTFb && !coll.tfb()) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // kNoITSROFrameBorder + if (cutSample.cutEvITSROFb && !coll.itsROFb()) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // kNoSameBunchPileup + if (cutSample.cutEvSbp && !coll.sbp()) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // kIsGoodZvtxFT0vsPV + if (cutSample.cutEvZvtxFT0vPV && !coll.zVtxFT0vPV()) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // kIsVertexITSTPC + if (cutSample.cutEvVtxITSTPC && !coll.vtxITSTPC()) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // Occupancy + if (coll.occupancyInTime() > cutSample.cutEvOccupancy) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // kNoCollInTimeRangeStandard + if (cutSample.cutEvTrs && !coll.trs()) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // kNoCollInRofStandard + if (cutSample.cutEvTrofs && !coll.trofs()) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // kNoHighMultCollInPrevRof + if (cutSample.cutEvHmpr && !coll.hmpr()) + return false; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + return true; + } + + std::vector>> cutMyRequiredITSHits{}; + + void mySetRequireHitsInITSLayers(int8_t minNRequiredHits, std::set requiredLayers) + { + // layer 0 corresponds to the the innermost ITS layer + cutMyRequiredITSHits.push_back(std::make_pair(minNRequiredHits, requiredLayers)); + } + + void mySetITShitsRule(int matching) + { + switch (matching) { + case 0: // Run3ITSibAny + mySetRequireHitsInITSLayers(1, {0, 1, 2}); + break; + case 1: // Run3ITSibTwo + mySetRequireHitsInITSLayers(2, {0, 1, 2}); + break; + case 2: // Run3ITSallAny + mySetRequireHitsInITSLayers(1, {0, 1, 2, 3, 4, 5, 6}); + break; + case 3: // Run3ITSall7Layers + mySetRequireHitsInITSLayers(7, {0, 1, 2, 3, 4, 5, 6}); + break; + default: + LOG(fatal) << "You chose wrong ITS matching"; + break; + } + } + + bool isFulfillsITSHitRequirementsReinstatement(uint8_t itsClusterMap) const + { + constexpr uint8_t kBit = 1; + for (const auto& kITSrequirement : cutMyRequiredITSHits) { + auto hits = std::count_if(kITSrequirement.second.begin(), kITSrequirement.second.end(), [&](auto&& requiredLayer) { return itsClusterMap & (kBit << requiredLayer); }); + if ((kITSrequirement.first == -1) && (hits > 0)) { + return false; // no hits were required in specified layers + } else if (hits < kITSrequirement.first) { + return false; // not enough hits found in specified layers + } + } + return true; + } + + template + bool isGlobalTrackReinstatement(T const& track) + { + // kInAcceptance copy + if (track.pt() < cutGlobalTrack.cutMinPt || track.pt() > cutGlobalTrack.cutMaxPt) + return false; + if (eta(track.px(), track.py(), track.pz()) < cutGlobalTrack.cutMinEta || eta(track.px(), track.py(), track.pz()) > cutGlobalTrack.cutMaxEta) + return false; + // kPrimaryTracks + // GoldenChi2 cut is only for Run 2 + if (std::abs(track.dcaZ()) > cutGlobalTrack.cutMaxDCAz) + return false; + if (cutGlobalTrack.applyPtDependentDCAxy) { + float maxDCA = 0.0182f + 0.0350f / std::pow(track.pt(), 1.01f); + if (std::abs(track.dcaXY()) > maxDCA) + return false; + } else { + if (std::abs(track.dcaXY()) > cutGlobalTrack.cutMaxDCAxy) + return false; + } + // kQualityTrack + // TrackType is always 1 as per definition of processed Run3 AO2Ds + // ITS + if (cutGlobalTrack.cutHasITS && !track.hasITS()) + return false; // ITS refit + if (track.itsNCls() < cutGlobalTrack.cutMinITSnCls) + return false; + if (track.itsChi2NCl() > cutGlobalTrack.cutMaxITSchi2) + return false; + if (!isFulfillsITSHitRequirementsReinstatement(track.itsClusterMap())) + return false; + // TPC + if (cutGlobalTrack.cutHasTPC && !track.hasTPC()) + return false; // TPC refit + if ((track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()) < cutGlobalTrack.cutMinTPCnCls) + return false; // tpcNClsFound() + if (track.tpcNClsCrossedRows() < cutGlobalTrack.cutMinTPCnClsXrows) + return false; + if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < cutGlobalTrack.cutMinTPCnClsXrowsOverNcls) + return false; + if (track.tpcChi2NCl() > cutGlobalTrack.cutMaxTPCchi2) + return false; // TPC chi2 + if (cutGlobalTrack.cutGoodITSTPCmatching) { + if (track.itsChi2NCl() < 0.) + return false; // good ITS-TPC matching means ITS ch2 is not negative + } + // TOF + if (track.hasTOF()) { + if (track.tpcChi2NCl() > cutGlobalTrack.cutMaxTOFchi2) + return false; // TOF chi2 + } + + return true; + } + + template + float findRightMass(T const& trk1, T const& trk2) + // choose the right mass for the tracks based on comparing combined sigma + // good for same-type particles decays + { + float nSigmasTPCsqrt[5]; + nSigmasTPCsqrt[P_ELECTRON] = std::sqrt(trk1.tpcNSigmaEl() * trk1.tpcNSigmaEl() + trk2.tpcNSigmaEl() * trk2.tpcNSigmaEl()); + nSigmasTPCsqrt[P_MUON] = std::sqrt(trk1.tpcNSigmaMu() * trk1.tpcNSigmaMu() + trk2.tpcNSigmaMu() * trk2.tpcNSigmaMu()); + nSigmasTPCsqrt[P_PION] = std::sqrt(trk1.tpcNSigmaPi() * trk1.tpcNSigmaPi() + trk2.tpcNSigmaPi() * trk2.tpcNSigmaPi()); + nSigmasTPCsqrt[P_KAON] = std::sqrt(trk1.tpcNSigmaKa() * trk1.tpcNSigmaKa() + trk2.tpcNSigmaKa() * trk2.tpcNSigmaKa()); + nSigmasTPCsqrt[P_PROTON] = std::sqrt(trk1.tpcNSigmaPr() * trk1.tpcNSigmaPr() + trk2.tpcNSigmaPr() * trk2.tpcNSigmaPr()); + + int enumChoiceTPC = std::distance(std::begin(nSigmasTPCsqrt), + std::min_element(std::begin(nSigmasTPCsqrt), std::end(nSigmasTPCsqrt))); + + return pdg->Mass(trackPDGfromEnum(enumChoiceTPC)); + } + + void processDataSG(FullSGUDCollision const& collision, + FullUDTracks const& tracks) + { + + nSelection = 0; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + if (!isGoodRCTflag(collision)) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + if (!isGoodROFtime(collision)) + return; + + int gapSide = collision.gapSide(); + int trueGapSide = sgSelector.trueGap(collision, cutSample.cutTrueGapSideFV0, cutSample.cutTrueGapSideFT0A, cutSample.cutTrueGapSideFT0C, cutSample.cutTrueGapSideZDC); + if (cutSample.useTrueGap) + gapSide = trueGapSide; + if (gapSide != cutSample.whichGapSide) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + if (!isGoodFITtime(collision, cutSample.cutFITtime)) + return; + + if (cutSample.useNumContribs && (collision.numContrib() != cutSample.cutNumContribs)) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + if (cutSample.useRecoFlag && (collision.flags() != cutSample.cutRecoFlag)) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + int countTracksPerCollision = 0; + int countGoodNonPVtracks = 0; + int countGoodPVtracks = 0; + std::vector vecTrkIdx; + // Loop over tracks with selections + for (const auto& track : tracks) { + countTracksPerCollision++; + if (!isGlobalTrackReinstatement(track)) + continue; + if (!track.isPVContributor()) { + countGoodNonPVtracks++; + continue; + } + countGoodPVtracks++; + vecTrkIdx.push_back(track.index()); + } // Loop over tracks with selections + + // Critical selection, without it the rest of the process function will fail + if (countGoodPVtracks != 2) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + const auto& trk1 = tracks.iteratorAt(vecTrkIdx[0]); + const auto& trk2 = tracks.iteratorAt(vecTrkIdx[1]); + + float thisMass = findRightMass(trk1, trk2); + + // prepare lorentz vectors to create system + ROOT::Math::LorentzVector> twoTrackMother, daug[2]; + daug[0].SetPxPyPzE(trk1.px(), trk1.py(), trk1.pz(), energy(thisMass, trk1.px(), trk1.py(), trk1.pz())); + daug[1].SetPxPyPzE(trk2.px(), trk2.py(), trk2.pz(), energy(thisMass, trk2.px(), trk2.py(), trk2.pz())); + twoTrackMother = daug[0] + daug[1]; + float thisPt = pt(twoTrackMother.px(), twoTrackMother.py()); + + // Apply system selections + // invariant mass + if (twoTrackMother.M() < cutPreselect.preselMinInvariantMass || twoTrackMother.M() > cutPreselect.preselMaxInvariantMass) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // system pt + if (cutPreselect.preselUseOppositeSystemPtCut ? thisPt < cutPreselect.preselSystemPtCut : thisPt > cutPreselect.preselSystemPtCut) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // one track momentum + if (daug[0].P() < cutPreselect.preselMinTrackMomentum && daug[1].P() < cutPreselect.preselMinTrackMomentum) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // both tracks momentum + if (cutPreselect.preselUseMinMomentumOnBothTracks && (daug[0].P() < cutPreselect.preselMinTrackMomentum || daug[1].P() < cutPreselect.preselMinTrackMomentum)) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // track in TOF + if (cutPreselect.preselAtLeastOneTOFtrack && (!trk1.hasTOF() && !trk2.hasTOF())) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + // tracks in TOF + if (cutPreselect.preselBothAreTOFtracks && (!trk1.hasTOF() || !trk2.hasTOF())) + return; + histos.get(HIST("Reco/hSelections"))->Fill(nSelection); + nSelection++; + + float px[2] = {trk1.px(), trk2.px()}; + float py[2] = {trk1.py(), trk2.py()}; + float pz[2] = {trk1.pz(), trk2.pz()}; + int sign[2] = {trk1.sign(), trk2.sign()}; + float dcaxy[2] = {trk1.dcaXY(), trk2.dcaXY()}; + float dcaz[2] = {trk1.dcaZ(), trk2.dcaZ()}; + float trkTimeRes[2] = {trk1.trackTimeRes(), trk2.trackTimeRes()}; + uint32_t itsClusterSizesTrk1 = trk1.itsClusterSizes(); + uint32_t itsClusterSizesTrk2 = trk2.itsClusterSizes(); + float tpcSignal[2] = {trk1.tpcSignal(), trk2.tpcSignal()}; + float tpcEl[2] = {trk1.tpcNSigmaEl(), trk2.tpcNSigmaEl()}; + float tpcMu[2] = {trk1.tpcNSigmaMu(), trk2.tpcNSigmaMu()}; + float tpcPi[2] = {trk1.tpcNSigmaPi(), trk2.tpcNSigmaPi()}; + float tpcKa[2] = {trk1.tpcNSigmaKa(), trk2.tpcNSigmaKa()}; + float tpcPr[2] = {trk1.tpcNSigmaPr(), trk2.tpcNSigmaPr()}; + float tpcIP[2] = {trk1.tpcInnerParam(), trk2.tpcInnerParam()}; + float tofSignal[2] = {trk1.tofSignal(), trk2.tofSignal()}; + float tofEl[2] = {trk1.tofNSigmaEl(), trk2.tofNSigmaEl()}; + float tofMu[2] = {trk1.tofNSigmaMu(), trk2.tofNSigmaMu()}; + float tofPi[2] = {trk1.tofNSigmaPi(), trk2.tofNSigmaPi()}; + float tofKa[2] = {trk1.tofNSigmaKa(), trk2.tofNSigmaKa()}; + float tofPr[2] = {trk1.tofNSigmaPr(), trk2.tofNSigmaPr()}; + float tofEP[2] = {trk1.tofExpMom(), trk2.tofExpMom()}; + float infoZDC[4] = {collision.energyCommonZNA(), collision.energyCommonZNC(), collision.timeZNA(), collision.timeZNC()}; + + twoTracks(collision.runNumber(), collision.globalBC(), countTracksPerCollision, collision.numContrib(), countGoodNonPVtracks, collision.posX(), collision.posY(), collision.posZ(), + collision.flags(), collision.occupancyInTime(), collision.hadronicRate(), collision.trs(), collision.trofs(), collision.hmpr(), + collision.tfb(), collision.itsROFb(), collision.sbp(), collision.zVtxFT0vPV(), collision.vtxITSTPC(), + collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), collision.totalFV0AmplitudeA(), infoZDC[0], infoZDC[1], + collision.timeFT0A(), collision.timeFT0C(), collision.timeFV0A(), infoZDC[2], infoZDC[3], + px, py, pz, sign, dcaxy, dcaz, trkTimeRes, + itsClusterSizesTrk1, itsClusterSizesTrk2, + tpcSignal, tpcEl, tpcMu, tpcPi, tpcKa, tpcPr, tpcIP, + tofSignal, tofEl, tofMu, tofPi, tofKa, tofPr, tofEP); + } + PROCESS_SWITCH(TwoTracksEventTableProducer, processDataSG, "Iterate UD tables with measured data created by SG-Candidate-Producer.", false); + + PresliceUnsorted partPerMcCollision = aod::udmcparticle::udMcCollisionId; + PresliceUnsorted colPerMcCollision = aod::udcollision::udMcCollisionId; + PresliceUnsorted trackPerMcParticle = aod::udmctracklabel::udMcParticleId; + Preslice trackPerCollision = aod::udtrack::udCollisionId; // sorted preslice used because the pair track-collision is already sorted in processDataSG function + + void processMonteCarlo(aod::UDMcCollisions const& mccollisions, + aod::UDMcParticles const& parts, + FullMCSGUDCollisions const& recolls, + FullMCUDTracks const& trks) + { + // start loop over generated collisions + for (const auto& mccoll : mccollisions) { + + // prepare local variables for output table + int32_t runNumber = -999; + int bc = -999; + int nTrks[3] = {-999, -999, -999}; // totalTracks, numContrib, globalNonPVtracks + float vtxPos[3] = {-999., -999., -999.}; + int recoMode = -999; + int occupancy = -999.; + double hadronicRate = -999.; + int bcSels[8] = {-999, -999, -999, -999, -999, -999, -999, -999}; + float amplitudesFIT[3] = {-999., -999., -999.}; // FT0A, FT0C, FV0 + float timesFIT[3] = {-999., -999., -999.}; // FT0A, FT0C, FV0 + + float px[2] = {-999., -999.}; + float py[2] = {-999., -999.}; + float pz[2] = {-999., -999.}; + int sign[2] = {-999, -999}; + float dcaxy[2] = {-999., -999.}; + float dcaz[2] = {-999., -999.}; + float trkTimeRes[2] = {-999., -999.}; + uint32_t itsClusterSizesTrk1 = 4294967295; + uint32_t itsClusterSizesTrk2 = 4294967295; + float tpcSignal[2] = {-999, -999}; + float tpcEl[2] = {-999, -999}; + float tpcMu[2] = {-999, -999}; + float tpcPi[2] = {-999, -999}; + float tpcKa[2] = {-999, -999}; + float tpcPr[2] = {-999, -999}; + float tpcIP[2] = {-999, -999}; + float tofSignal[2] = {-999, -999}; + float tofEl[2] = {-999, -999}; + float tofMu[2] = {-999, -999}; + float tofPi[2] = {-999, -999}; + float tofKa[2] = {-999, -999}; + float tofPr[2] = {-999, -999}; + float tofEP[2] = {-999, -999}; + + int trueChannel = -1; + bool trueHasRecoColl = false; + float trueMotherX[2] = {-999., -999.}; + float trueMotherY[2] = {-999., -999.}; + float trueMotherZ[2] = {-999., -999.}; + float trueDaugX[2] = {-999., -999.}; + float trueDaugY[2] = {-999., -999.}; + float trueDaugZ[2] = {-999., -999.}; + int trueDaugPdgCode[2] = {-999, -999}; + bool problem = false; + + // find reconstructed collisions associated to the generated collision + auto const& collFromMcColls = recolls.sliceBy(colPerMcCollision, mccoll.globalIndex()); + // check the generated collision was reconstructed + if (collFromMcColls.size() > 0) { // get the truth and reco-level info + trueHasRecoColl = true; + // check there is exactly one reco-level collision associated to generated collision + if (collFromMcColls.size() > 1) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 1 reco collision. Skipping this event."); + histos.get(HIST("Truth/hTroubles"))->Fill(1); + problem = true; + continue; + } + // grap reco-level collision + auto const& collFromMcColl = collFromMcColls.iteratorAt(0); + // grab tracks from the reco-level collision to get info to match measured data tables (processDataSG function) + auto const& trksFromColl = trks.sliceBy(trackPerCollision, collFromMcColl.globalIndex()); + int countTracksPerCollision = 0; + int countGoodNonPVtracks = 0; + for (auto const& trkFromColl : trksFromColl) { + countTracksPerCollision++; + if (!trkFromColl.isPVContributor()) { + countGoodNonPVtracks++; + continue; + } + } + + // fill info for reconstructed collision + runNumber = collFromMcColl.runNumber(); + bc = collFromMcColl.globalBC(); + nTrks[0] = countTracksPerCollision; + nTrks[1] = collFromMcColl.numContrib(); + nTrks[2] = countGoodNonPVtracks; + vtxPos[0] = collFromMcColl.posX(); + vtxPos[1] = collFromMcColl.posY(); + vtxPos[2] = collFromMcColl.posZ(); + recoMode = collFromMcColl.flags(); + occupancy = collFromMcColl.occupancyInTime(); + hadronicRate = collFromMcColl.hadronicRate(); + bcSels[0] = collFromMcColl.trs(); + bcSels[1] = collFromMcColl.trofs(); + bcSels[2] = collFromMcColl.hmpr(); + bcSels[3] = collFromMcColl.tfb(); + bcSels[4] = collFromMcColl.itsROFb(); + bcSels[5] = collFromMcColl.sbp(); + bcSels[6] = collFromMcColl.zVtxFT0vPV(); + bcSels[7] = collFromMcColl.vtxITSTPC(); + amplitudesFIT[0] = collFromMcColl.totalFT0AmplitudeA(); + amplitudesFIT[1] = collFromMcColl.totalFT0AmplitudeC(); + amplitudesFIT[2] = collFromMcColl.totalFV0AmplitudeA(); + timesFIT[0] = collFromMcColl.timeFT0A(); + timesFIT[1] = collFromMcColl.timeFT0C(); + timesFIT[2] = collFromMcColl.timeFV0A(); + + // get particles associated to generated collision + auto const& partsFromMcColl = parts.sliceBy(partPerMcCollision, mccoll.globalIndex()); + int countMothers = 0; + for (const auto& particle : partsFromMcColl) { + // select only mothers with checking if particle has no mother + if (particle.has_mothers()) + continue; + countMothers++; + // check the generated collision does not have more than 2 mothers + if (countMothers > 2) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 2 no mother particles. Breaking the particle loop."); + histos.get(HIST("Truth/hTroubles"))->Fill(2); + problem = true; + break; + } + // fill info for each mother + trueMotherX[countMothers - 1] = particle.px(); + trueMotherY[countMothers - 1] = particle.py(); + trueMotherZ[countMothers - 1] = particle.pz(); + + // get daughters of the tau + const auto& daughters = particle.daughters_as(); + int countDaughters = 0; + for (const auto& daughter : daughters) { + // check if it is the charged particle (= no pi0 or neutrino) + if (enumMyParticle(daughter.pdgCode()) == -1) + continue; + countDaughters++; + // check there is only 1 charged daughter related to 1 tau + if (countDaughters > 1) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 1 charged daughters of no mother particles. Breaking the daughter loop."); + histos.get(HIST("Truth/hTroubles"))->Fill(3); + problem = true; + break; + } + // fill info for each daughter + trueDaugX[countMothers - 1] = daughter.px(); + trueDaugY[countMothers - 1] = daughter.py(); + trueDaugZ[countMothers - 1] = daughter.pz(); + trueDaugPdgCode[countMothers - 1] = daughter.pdgCode(); + + // get tracks associated to MC daughter (how well the daughter was reconstructed) + auto const& tracksFromDaughter = trks.sliceBy(trackPerMcParticle, daughter.globalIndex()); + // check there is exactly 1 track per 1 particle + if (tracksFromDaughter.size() > 1) { + if (verboseInfo) + printLargeMessage("Daughter has more than 1 associated track. Skipping this daughter."); + histos.get(HIST("Truth/hTroubles"))->Fill(4); + problem = true; + continue; + } + // grab the track and fill info for reconstructed track (should be done twice) + const auto& trk = tracksFromDaughter.iteratorAt(0); + px[countMothers - 1] = trk.px(); + py[countMothers - 1] = trk.py(); + pz[countMothers - 1] = trk.pz(); + sign[countMothers - 1] = trk.sign(); + dcaxy[countMothers - 1] = trk.dcaXY(); + dcaz[countMothers - 1] = trk.dcaZ(); + trkTimeRes[countMothers - 1] = trk.trackTimeRes(); + if (countMothers == 1) { + itsClusterSizesTrk1 = trk.itsClusterSizes(); + } else { + itsClusterSizesTrk2 = trk.itsClusterSizes(); + } + tpcSignal[countMothers - 1] = trk.tpcSignal(); + tpcEl[countMothers - 1] = trk.tpcNSigmaEl(); + tpcMu[countMothers - 1] = trk.tpcNSigmaMu(); + tpcPi[countMothers - 1] = trk.tpcNSigmaPi(); + tpcKa[countMothers - 1] = trk.tpcNSigmaKa(); + tpcPr[countMothers - 1] = trk.tpcNSigmaPr(); + tpcIP[countMothers - 1] = trk.tpcInnerParam(); + tofSignal[countMothers - 1] = trk.tofSignal(); + tofEl[countMothers - 1] = trk.tofNSigmaEl(); + tofMu[countMothers - 1] = trk.tofNSigmaMu(); + tofPi[countMothers - 1] = trk.tofNSigmaPi(); + tofKa[countMothers - 1] = trk.tofNSigmaKa(); + tofPr[countMothers - 1] = trk.tofNSigmaPr(); + tofEP[countMothers - 1] = trk.tofExpMom(); + } // daughters + } // particles + } else { // get only the truth information. The reco-level info is left on default + // get particles associated to generated collision + auto const& partsFromMcColl = parts.sliceBy(partPerMcCollision, mccoll.globalIndex()); + int countMothers = 0; + for (const auto& particle : partsFromMcColl) { + // select only tauons with checking if particle has no mother + if (particle.has_mothers()) + continue; + countMothers++; + // check the generated collision does not have more than 2 mothers + if (countMothers > 2) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 2 no mother particles. Breaking the particle loop."); + histos.get(HIST("Truth/hTroubles"))->Fill(12); + problem = true; + break; + } + // fill info for each tau + trueMotherX[countMothers - 1] = particle.px(); + trueMotherY[countMothers - 1] = particle.py(); + trueMotherZ[countMothers - 1] = particle.pz(); + + // get daughters of the tau + const auto& daughters = particle.daughters_as(); + int countDaughters = 0; + for (const auto& daughter : daughters) { + // select only the charged particle (= no pi0 or neutrino) + if (enumMyParticle(daughter.pdgCode()) == -1) + continue; + countDaughters++; + // check there is only 1 charged daughter related to 1 tau + if (countDaughters > 1) { + if (verboseInfo) + printLargeMessage("Truth collision has more than 1 charged daughters of no mother particles. Breaking the daughter loop."); + histos.get(HIST("Truth/hTroubles"))->Fill(13); + problem = true; + break; + } + // fill info for each daughter + trueDaugX[countMothers - 1] = daughter.px(); + trueDaugY[countMothers - 1] = daughter.py(); + trueDaugZ[countMothers - 1] = daughter.pz(); + trueDaugPdgCode[countMothers - 1] = daughter.pdgCode(); + } // daughters + } // particles + } // collisions + + // decide the channel and set the variable. Only two cahnnels suported now. + if ((enumMyParticle(trueDaugPdgCode[0]) == P_ELECTRON) && (enumMyParticle(trueDaugPdgCode[1]) == P_ELECTRON)) + trueChannel = CH_EE; + if ((enumMyParticle(trueDaugPdgCode[0]) == P_ELECTRON) && ((enumMyParticle(trueDaugPdgCode[1]) == P_PION) || (enumMyParticle(trueDaugPdgCode[1]) == P_MUON))) + trueChannel = CH_EMUPI; + if ((enumMyParticle(trueDaugPdgCode[1]) == P_ELECTRON) && ((enumMyParticle(trueDaugPdgCode[0]) == P_PION) || (enumMyParticle(trueDaugPdgCode[0]) == P_MUON))) + trueChannel = CH_EMUPI; + + trueTwoTracks(runNumber, bc, nTrks[0], nTrks[1], nTrks[2], vtxPos[0], vtxPos[1], vtxPos[2], + recoMode, occupancy, hadronicRate, bcSels[0], bcSels[1], bcSels[2], + bcSels[3], bcSels[4], bcSels[5], bcSels[6], bcSels[7], + amplitudesFIT[0], amplitudesFIT[1], amplitudesFIT[2], -999., -999., // no ZDC info in MC + timesFIT[0], timesFIT[1], timesFIT[2], -999., -999., // no ZDC info in MC + px, py, pz, sign, dcaxy, dcaz, trkTimeRes, + itsClusterSizesTrk1, itsClusterSizesTrk2, + tpcSignal, tpcEl, tpcMu, tpcPi, tpcKa, tpcPr, tpcIP, + tofSignal, tofEl, tofMu, tofPi, tofKa, tofPr, tofEP, + trueChannel, trueHasRecoColl, mccoll.posX(), mccoll.posY(), mccoll.posZ(), + trueMotherX, trueMotherY, trueMotherZ, trueDaugX, trueDaugY, trueDaugZ, trueDaugPdgCode, problem); + } // mccollisions + } + PROCESS_SWITCH(TwoTracksEventTableProducer, processMonteCarlo, "Iterate UD tables with simulated data created by SG-Candidate-Producer.", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/TableProducer/udMcCollisions2udCollisions.cxx b/PWGUD/TableProducer/udMcCollisions2udCollisions.cxx new file mode 100644 index 00000000000..cea35fb70ea --- /dev/null +++ b/PWGUD/TableProducer/udMcCollisions2udCollisions.cxx @@ -0,0 +1,75 @@ +// 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. + +/// +/// \file udMcCollisions2udCollisions.cxx +/// \author Roman Lavička +/// \since 2025-04-15 +/// \brief A task to create a reverse index from UDMcCollisions to UDCollisions +/// + +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/DataModel/UDIndex.h" + +using namespace o2; +using namespace o2::framework; + +struct UDMcCollisions2UDCollisions { + using LabeledCollisions = soa::Join; + Produces udmcc2udc; + + std::vector collisionIds; + + void init(InitContext&) + { + } + + void process(aod::UDMcCollisions const& mcCollisions) + { + if (doprocessIndexingCentral || doprocessIndexingCentralFast) { + udmcc2udc.reserve(mcCollisions.size()); + } + } + + void processIndexingCentralFast(aod::UDMcCollisions const& mcCollisions, LabeledCollisions const& collisions) + { + // faster version, but will use more memory due to pre-allocation + std::vector> mccoll2coll(mcCollisions.size()); + for (const auto& collision : collisions) { + if (collision.has_udMcCollision()) + mccoll2coll[collision.udMcCollisionId()].push_back(collision.globalIndex()); + } + for (const auto& mcCollision : mcCollisions) { + udmcc2udc(mccoll2coll[mcCollision.globalIndex()]); + } + } + PROCESS_SWITCH(UDMcCollisions2UDCollisions, processIndexingCentralFast, "Create reverse index from mccollisions to collision: more memory use but potentially faster", true); + + void processIndexingCentral(aod::UDMcCollisions const&, soa::SmallGroups const& collisions) + { + collisionIds.clear(); + for (const auto& collision : collisions) { + collisionIds.push_back(collision.globalIndex()); + } + udmcc2udc(collisionIds); + } + PROCESS_SWITCH(UDMcCollisions2UDCollisions, processIndexingCentral, "Create reverse index from mccollisions to collision", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/TableProducer/udMcParticles2udTracks.cxx b/PWGUD/TableProducer/udMcParticles2udTracks.cxx new file mode 100644 index 00000000000..4a876a72fb3 --- /dev/null +++ b/PWGUD/TableProducer/udMcParticles2udTracks.cxx @@ -0,0 +1,75 @@ +// 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. + +/// +/// \file udMcParticles2udTracks.cxx +/// \author Roman Lavička +/// \since 2025-04-15 +/// \brief A task to create a reverse index from UDMcParticles to UDTracks +/// + +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/DataModel/UDIndex.h" + +using namespace o2; +using namespace o2::framework; + +struct UDMcParticlesToUDTracks { + using LabeledTracks = soa::Join; + Produces udp2udt; + + std::vector trackIds; + + void init(InitContext&) + { + } + + void process(aod::UDMcParticles const& particles) + { + if (doprocessIndexingCentral || doprocessIndexingCentralFast) { + udp2udt.reserve(particles.size()); + } + } + + void processIndexingCentralFast(aod::UDMcParticles const& mcParticles, LabeledTracks const& tracks) + { + // faster version, but will use more memory due to pre-allocation + std::vector> part2track(mcParticles.size()); + for (const auto& track : tracks) { + if (track.has_udMcParticle()) + part2track[track.udMcParticleId()].push_back(track.globalIndex()); + } + for (const auto& mcParticle : mcParticles) { + udp2udt(part2track[mcParticle.globalIndex()]); + } + } + PROCESS_SWITCH(UDMcParticlesToUDTracks, processIndexingCentralFast, "Create reverse index from particles to tracks: more memory use but potentially faster", true); + + void processIndexingCentral(aod::UDMcParticles const&, soa::SmallGroups const& tracks) + { + trackIds.clear(); + for (const auto& track : tracks) { + trackIds.push_back(track.globalIndex()); + } + udp2udt(trackIds); + } + PROCESS_SWITCH(UDMcParticlesToUDTracks, processIndexingCentral, "Create reverse index from particles to tracks", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/Tasks/CMakeLists.txt b/PWGUD/Tasks/CMakeLists.txt index 51eacc89534..37811e8dd4e 100644 --- a/PWGUD/Tasks/CMakeLists.txt +++ b/PWGUD/Tasks/CMakeLists.txt @@ -123,8 +123,9 @@ o2physics_add_dpl_workflow(tautau13topo SOURCES upcTauTau13topo.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(upc-tau-rl - SOURCES upcTauCentralBarrelRL.cxx + SOURCES upcTauRl.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsBase O2::DetectorsCommonDataFormats COMPONENT_NAME Analysis) @@ -134,7 +135,7 @@ o2physics_add_dpl_workflow(polarisation-rho COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(upc-jpsi-corr - SOURCES upcJpsiCentralBarrelCorr.cxx + SOURCES upcJpsiCorr.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector COMPONENT_NAME Analysis) @@ -145,7 +146,7 @@ o2physics_add_dpl_workflow(exclusive-phi o2physics_add_dpl_workflow(upc-photonuclear-jmg SOURCES upcPhotonuclearAnalysisJMG.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsBase O2::DetectorsCommonDataFormats + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore O2::ReconstructionDataFormats O2::DetectorsBase O2::DetectorsCommonDataFormats COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(exclusive-two-protons @@ -194,7 +195,7 @@ o2physics_add_dpl_workflow(upc-pion-analysis COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(fwd-muons-upc - SOURCES fwdMuonsUPC.cxx + SOURCES FwdMuonsUPC.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector COMPONENT_NAME Analysis) @@ -208,6 +209,11 @@ o2physics_add_dpl_workflow(upc-rho-analysis PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(upc-rho-prime-analysis + SOURCES upcRhoPrimeAnalysis.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(event-by-event SOURCES eventByevent.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector @@ -216,4 +222,39 @@ o2physics_add_dpl_workflow(event-by-event o2physics_add_dpl_workflow(exclusive-rho-to-four-pi SOURCES exclusiveRhoTo4Pi.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector - COMPONENT_NAME Analysis) \ No newline at end of file + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(upc-quarkonia-central-barrel + SOURCES upcQuarkoniaCentralBarrel.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(test-mc-std-tabs-rl + SOURCES testMcStdTabsRl.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsBase O2::DetectorsCommonDataFormats + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(decaytree-analyzer + SOURCES decayTreeAnalyzer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::UDGoodRunSelector O2Physics::decayTree + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-cumulants-upc + SOURCES flowCumulantsUpc.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::GFWCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-correlations-upc + SOURCES flowCorrelationsUpc.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::PWGCFCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(analysis-mc-dpm-jet-sg-v3 + SOURCES analysisMCDPMJetSGv3.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(upc-test-rct-tables + SOURCES upcTestRctTables.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGUD/Tasks/fwdMuonsUPC.cxx b/PWGUD/Tasks/FwdMuonsUPC.cxx similarity index 83% rename from PWGUD/Tasks/fwdMuonsUPC.cxx rename to PWGUD/Tasks/FwdMuonsUPC.cxx index 66957899e62..0c4b3d81e3b 100644 --- a/PWGUD/Tasks/fwdMuonsUPC.cxx +++ b/PWGUD/Tasks/FwdMuonsUPC.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file fwdMuonsUPC.cxx +/// \file FwdMuonsUPC.cxx /// \brief perform some selections on fwd events and saves the results /// executable name o2-analysis-ud-fwd-muon-upc @@ -37,6 +37,7 @@ namespace dimu { // dimuon +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); DECLARE_SOA_COLUMN(M, m, float); DECLARE_SOA_COLUMN(Energy, energy, float); DECLARE_SOA_COLUMN(Px, px, float); @@ -55,6 +56,7 @@ DECLARE_SOA_COLUMN(Pzp, pzp, float); DECLARE_SOA_COLUMN(Ptp, ptp, float); DECLARE_SOA_COLUMN(Etap, etap, float); DECLARE_SOA_COLUMN(Phip, phip, float); +DECLARE_SOA_COLUMN(TrackTypep, trackTypep, int); DECLARE_SOA_COLUMN(EnergyN, energyN, float); DECLARE_SOA_COLUMN(Pxn, pxn, float); DECLARE_SOA_COLUMN(Pyn, pyn, float); @@ -62,6 +64,7 @@ DECLARE_SOA_COLUMN(Pzn, pzn, float); DECLARE_SOA_COLUMN(Ptn, ptn, float); DECLARE_SOA_COLUMN(Etan, etan, float); DECLARE_SOA_COLUMN(Phin, phin, float); +DECLARE_SOA_COLUMN(TrackTypen, trackTypen, int); // zn DECLARE_SOA_COLUMN(Tzna, tzna, float); DECLARE_SOA_COLUMN(Ezna, ezna, float); @@ -73,10 +76,11 @@ DECLARE_SOA_COLUMN(Nclass, nclass, int); namespace o2::aod { DECLARE_SOA_TABLE(DiMu, "AOD", "DIMU", + dimu::RunNumber, dimu::M, dimu::Energy, dimu::Px, dimu::Py, dimu::Pz, dimu::Pt, dimu::Rap, dimu::Phi, dimu::PhiAv, dimu::PhiCh, - dimu::EnergyP, dimu::Pxp, dimu::Pyp, dimu::Pzp, dimu::Ptp, dimu::Etap, dimu::Phip, - dimu::EnergyN, dimu::Pxn, dimu::Pyn, dimu::Pzn, dimu::Ptn, dimu::Etan, dimu::Phin, + dimu::EnergyP, dimu::Pxp, dimu::Pyp, dimu::Pzp, dimu::Ptp, dimu::Etap, dimu::Phip, dimu::TrackTypep, + dimu::EnergyN, dimu::Pxn, dimu::Pyn, dimu::Pzn, dimu::Ptn, dimu::Etan, dimu::Phin, dimu::TrackTypen, dimu::Tzna, dimu::Ezna, dimu::Tznc, dimu::Eznc, dimu::Nclass); } // namespace o2::aod @@ -84,34 +88,35 @@ DECLARE_SOA_TABLE(DiMu, "AOD", "DIMU", namespace gendimu { // dimuon -DECLARE_SOA_COLUMN(M, m, float); -DECLARE_SOA_COLUMN(Pt, pt, float); -DECLARE_SOA_COLUMN(Rap, rap, float); -DECLARE_SOA_COLUMN(Phi, phi, float); -DECLARE_SOA_COLUMN(PhiAv, phiAv, float); -DECLARE_SOA_COLUMN(PhiCh, phiCh, float); +DECLARE_SOA_COLUMN(GenM, genM, float); +DECLARE_SOA_COLUMN(GenPt, genPt, float); +DECLARE_SOA_COLUMN(GenRap, genRap, float); +DECLARE_SOA_COLUMN(GenPhi, genPhi, float); +DECLARE_SOA_COLUMN(GenPhiAv, genPhiAv, float); +DECLARE_SOA_COLUMN(GenPhiCh, genPhiCh, float); // tracks positive (p) and negative (n) -DECLARE_SOA_COLUMN(Ptp, ptp, float); -DECLARE_SOA_COLUMN(Etap, etap, float); -DECLARE_SOA_COLUMN(Phip, phip, float); -DECLARE_SOA_COLUMN(Ptn, ptn, float); -DECLARE_SOA_COLUMN(Etan, etan, float); -DECLARE_SOA_COLUMN(Phin, phin, float); +DECLARE_SOA_COLUMN(GenPtp, genPtp, float); +DECLARE_SOA_COLUMN(GenEtap, genEtap, float); +DECLARE_SOA_COLUMN(GenPhip, genPhip, float); +DECLARE_SOA_COLUMN(GenPtn, genPtn, float); +DECLARE_SOA_COLUMN(GenEtan, genEtan, float); +DECLARE_SOA_COLUMN(GenPhin, genPhin, float); } // namespace gendimu namespace o2::aod { DECLARE_SOA_TABLE(GenDimu, "AOD", "GENDIMU", - gendimu::M, gendimu::Pt, gendimu::Rap, gendimu::Phi, - gendimu::PhiAv, gendimu::PhiCh, - gendimu::Ptp, gendimu::Etap, gendimu::Phip, - gendimu::Ptn, gendimu::Etan, gendimu::Phin); + gendimu::GenM, gendimu::GenPt, gendimu::GenRap, gendimu::GenPhi, + gendimu::GenPhiAv, gendimu::GenPhiCh, + gendimu::GenPtp, gendimu::GenEtap, gendimu::GenPhip, + gendimu::GenPtn, gendimu::GenEtan, gendimu::GenPhin); } // namespace o2::aod // for saving tree with info on reco MC namespace recodimu { // dimuon +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); DECLARE_SOA_COLUMN(M, m, float); DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(Rap, rap, float); @@ -122,9 +127,11 @@ DECLARE_SOA_COLUMN(PhiCh, phiCh, float); DECLARE_SOA_COLUMN(Ptp, ptp, float); DECLARE_SOA_COLUMN(Etap, etap, float); DECLARE_SOA_COLUMN(Phip, phip, float); +DECLARE_SOA_COLUMN(TrackTypep, trackTypep, int); DECLARE_SOA_COLUMN(Ptn, ptn, float); DECLARE_SOA_COLUMN(Etan, etan, float); DECLARE_SOA_COLUMN(Phin, phin, float); +DECLARE_SOA_COLUMN(TrackTypen, trackTypen, int); // gen info dimuon DECLARE_SOA_COLUMN(GenPt, genPt, float); DECLARE_SOA_COLUMN(GenRap, genRap, float); @@ -141,10 +148,11 @@ DECLARE_SOA_COLUMN(GenPhin, genPhin, float); namespace o2::aod { DECLARE_SOA_TABLE(RecoDimu, "AOD", "RECODIMU", + recodimu::RunNumber, recodimu::M, recodimu::Pt, recodimu::Rap, recodimu::Phi, recodimu::PhiAv, recodimu::PhiCh, - recodimu::Ptp, recodimu::Etap, recodimu::Phip, - recodimu::Ptn, recodimu::Etan, recodimu::Phin, + recodimu::Ptp, recodimu::Etap, recodimu::Phip, recodimu::TrackTypep, + recodimu::Ptn, recodimu::Etan, recodimu::Phin, recodimu::TrackTypen, recodimu::GenPt, recodimu::GenRap, recodimu::GenPhi, recodimu::GenPtp, recodimu::GenEtap, recodimu::GenPhip, recodimu::GenPtn, recodimu::GenEtan, recodimu::GenPhin); @@ -160,11 +168,19 @@ const float kRAbsMid = 26.5; const float kRAbsMax = 89.5; const float kPDca1 = 200.; const float kPDca2 = 200.; -const float kEtaMin = -4.0; -const float kEtaMax = -2.5; +float kEtaMin = -4.0; +float kEtaMax = -2.5; const float kPtMin = 0.; -struct fwdMuonsUPC { +const float kMaxAmpV0A = 100.; +const int kReqMatchMIDTracks = 2; +const int kReqMatchMFTTracks = 2; +const int kMaxChi2MFTMatch = 30; +const float kMaxZDCTime = 2.; +const float kMaxZDCTimeHisto = 10.; +const int kMuonPDG = 13; + +struct FwdMuonsUPC { // a pdg object Service pdg; @@ -223,6 +239,10 @@ struct fwdMuonsUPC { Configurable nBinsZDCen{"nBinsZDCen", 200, "N bins in ZN energy"}; Configurable lowEnZN{"lowEnZN", -50., "lower limit in ZN energy histo"}; Configurable highEnZN{"highEnZN", 250., "upper limit in ZN energy histo"}; + // my track type + // 0 = MCH-MID-MFT + // 1 = MCH-MID + Configurable myTrackType{"myTrackType", 3, "My track type"}; void init(InitContext&) { @@ -233,9 +253,19 @@ struct fwdMuonsUPC { 0.60, 0.70, 0.80, 0.90, 1.00, 1.20, 1.40, 1.60, 1.80, 2.00, 2.50, 3.00, 3.50}; + std::vector ptFitBinningHalfWidth = { + 0.00, 0.005, 0.01, 0.015, 0.02, 0.025, 0.03, 0.035, 0.04, 0.045, 0.05, + 0.055, 0.06, 0.065, 0.07, 0.075, 0.08, 0.085, 0.09, 0.095, 0.10, + 0.105, 0.11, 0.115, 0.12, 0.125, 0.13, 0.135, 0.14, 0.145, 0.15, + 0.1625, 0.175, 0.1875, 0.20, 0.225, 0.25, 0.275, 0.30, 0.35, 0.40, + 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, + 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.25, + 2.50, 2.75, 3.00, 3.25, 3.50}; + // axis const AxisSpec axisPt{nBinsPt, lowPt, highPt, "#it{p}_{T} GeV/#it{c}"}; const AxisSpec axisPtFit = {ptFitBinning, "#it{p}_{T} (GeV/c)"}; + const AxisSpec axisPtFit2 = {ptFitBinningHalfWidth, "#it{p}_{T} (GeV/c)"}; const AxisSpec axisMass{nBinsMass, lowMass, highMass, "m_{#mu#mu} GeV/#it{c}^{2}"}; const AxisSpec axisEta{nBinsEta, lowEta, highEta, "#eta"}; const AxisSpec axisRapidity{nBinsRapidity, lowRapidity, highRapidity, "Rapidity"}; @@ -252,6 +282,7 @@ struct fwdMuonsUPC { registry.add("hMass", "Invariant mass of muon pairs;;#counts", kTH1D, {axisMass}); registry.add("hPt", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPt}); registry.add("hPtFit", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPtFit}); + registry.add("hPtFit2", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPtFit2}); registry.add("hEta", "Pseudorapidty of muon pairs;;#counts", kTH1D, {axisEta}); registry.add("hRapidity", "Rapidty of muon pairs;;#counts", kTH1D, {axisRapidity}); registry.add("hPhi", "#varphi of muon pairs;;#counts", kTH1D, {axisPhi}); @@ -310,6 +341,7 @@ struct fwdMuonsUPC { mcRecoRegistry.add("hMass", "Invariant mass of muon pairs;;#counts", kTH1D, {axisMass}); mcRecoRegistry.add("hPt", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPt}); mcRecoRegistry.add("hPtFit", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPtFit}); + mcRecoRegistry.add("hPtFit2", "Transverse momentum of muon pairs;;#counts", kTH1D, {axisPtFit2}); mcRecoRegistry.add("hEta", "Pseudorapidty of muon pairs;;#counts", kTH1D, {axisEta}); mcRecoRegistry.add("hRapidity", "Rapidty of muon pairs;;#counts", kTH1D, {axisRapidity}); mcRecoRegistry.add("hPhi", "#varphi of muon pairs;;#counts", kTH1D, {axisPhi}); @@ -371,9 +403,9 @@ struct fwdMuonsUPC { } } - // template function that fills a map with the collision id of each udmccollision as key - // and a vector with the tracks - // map == (key, element) == (udCollisionId, vector(track1, mcPart1, udCollisionId1, track2, mcPart2, udCollisionId2)) + // template function that fills a map with the collision id of each udcollision as key + // and a vector with the tracks and corresponding geneated particles + // map == (key, element) == (udCollisionId, vector(track1, mcPart1, track2, mcPart2)) template void collectRecoCandID(std::unordered_map>& tracksPerCand, TTracks& tracks) { @@ -383,7 +415,7 @@ struct fwdMuonsUPC { continue; if (!tr.has_udMcParticle()) { - // LOGF(info,"tr does not have mc part"); + // LOGF(debug,"tr does not have mc part"); continue; } // retrieve mc particle from the reco track @@ -391,7 +423,6 @@ struct fwdMuonsUPC { tracksPerCand[candId].push_back(tr.globalIndex()); tracksPerCand[candId].push_back(mcPart.globalIndex()); - tracksPerCand[candId].push_back(mcPart.udMcCollisionId()); } } @@ -439,7 +470,7 @@ struct fwdMuonsUPC { float rAbs = fwdTrack.rAtAbsorberEnd(); float pDca = fwdTrack.pDca(); TLorentzVector p; - auto mMu = particleMass(13); + auto mMu = particleMass(kMuonPDG); p.SetXYZM(fwdTrack.px(), fwdTrack.py(), fwdTrack.pz(), mMu); float eta = p.Eta(); float pt = p.Pt(); @@ -459,18 +490,18 @@ struct fwdMuonsUPC { // function to compute phi for azimuth anisotropy void computePhiAnis(TLorentzVector p1, TLorentzVector p2, int sign1, float& phiAverage, float& phiCharge) { - TLorentzVector tSum, tDiffAv, tDiffCh; tSum = p1 + p2; + float halfUnity = 0.5; if (sign1 > 0) { tDiffCh = p1 - p2; - if (gRandom->Rndm() > 0.5) + if (gRandom->Rndm() > halfUnity) tDiffAv = p1 - p2; else tDiffAv = p2 - p1; } else { tDiffCh = p2 - p1; - if (gRandom->Rndm() > 0.5) + if (gRandom->Rndm() > halfUnity) tDiffAv = p2 - p1; else tDiffAv = p1 - p2; @@ -495,7 +526,7 @@ struct fwdMuonsUPC { const auto& ampsRelBCsV0A = cand.ampRelBCsV0A(); for (unsigned int i = 0; i < ampsV0A.size(); ++i) { if (std::abs(ampsRelBCsV0A[i]) <= 1) { - if (ampsV0A[i] > 100.) + if (ampsV0A[i] > kMaxAmpV0A) return; } } @@ -506,24 +537,39 @@ struct fwdMuonsUPC { return; } - // track selection - if (!isMuonSelected(*tr1)) - return; - if (!isMuonSelected(*tr2)) - return; - // MCH-MID match selection int nMIDs = 0; if (tr1.chi2MatchMCHMID() > 0) nMIDs++; if (tr2.chi2MatchMCHMID() > 0) nMIDs++; - if (nMIDs != 2) + if (nMIDs != kReqMatchMIDTracks) + return; + + // MFT-MID match selection (if MFT is requested by the trackType) + if (myTrackType == 0) { + // if MFT is requested check that the tracks is inside the MFT acceptance + kEtaMin = -3.6; + kEtaMax = -2.5; + + int nMFT = 0; + if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < kMaxChi2MFTMatch) + nMFT++; + if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < kMaxChi2MFTMatch) + nMFT++; + if (nMFT != kReqMatchMFTTracks) + return; + } + + // track selection + if (!isMuonSelected(*tr1)) + return; + if (!isMuonSelected(*tr2)) return; // form Lorentz vectors TLorentzVector p1, p2; - auto mMu = particleMass(13); + auto mMu = particleMass(kMuonPDG); p1.SetXYZM(tr1.px(), tr1.py(), tr1.pz(), mMu); p2.SetXYZM(tr2.px(), tr2.py(), tr2.pz(), mMu); TLorentzVector p = p1 + p2; @@ -551,9 +597,9 @@ struct fwdMuonsUPC { computePhiAnis(p1, p2, tr1.sign(), phiAverage, phiCharge); // zdc info - if (std::abs(zdc.timeA) < 10) + if (std::abs(zdc.timeA) < kMaxZDCTimeHisto) registry.fill(HIST("hTimeZNA"), zdc.timeA); - if (std::abs(zdc.timeC) < 10) + if (std::abs(zdc.timeC) < kMaxZDCTimeHisto) registry.fill(HIST("hTimeZNC"), zdc.timeC); registry.fill(HIST("hEnergyZN"), zdc.enA, zdc.enC); @@ -562,9 +608,9 @@ struct fwdMuonsUPC { bool neutronC = false; int znClass = -1; - if (std::abs(zdc.timeA) < 2) + if (std::abs(zdc.timeA) < kMaxZDCTime) neutronA = true; - if (std::abs(zdc.timeC) < 2) + if (std::abs(zdc.timeC) < kMaxZDCTime) neutronC = true; if (std::isinf(zdc.timeC)) @@ -612,6 +658,7 @@ struct fwdMuonsUPC { registry.fill(HIST("hMass"), p.M()); registry.fill(HIST("hPt"), p.Pt()); registry.fill(HIST("hPtFit"), p.Pt()); + registry.fill(HIST("hPtFit2"), p.Pt()); registry.fill(HIST("hEta"), p.Eta()); registry.fill(HIST("hRapidity"), p.Rapidity()); registry.fill(HIST("hPhi"), p.Phi()); @@ -622,16 +669,18 @@ struct fwdMuonsUPC { // store the event to save it into a tree if (tr1.sign() > 0) { - dimuSel(p.M(), p.E(), p.Px(), p.Py(), p.Pz(), p.Pt(), p.Rapidity(), p.Phi(), + dimuSel(cand.runNumber(), + p.M(), p.E(), p.Px(), p.Py(), p.Pz(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), - p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), + p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), static_cast(myTrackType), + p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), static_cast(myTrackType), zdc.timeA, zdc.enA, zdc.timeC, zdc.enC, znClass); } else { - dimuSel(p.M(), p.E(), p.Px(), p.Py(), p.Pz(), p.Pt(), p.Rapidity(), p.Phi(), + dimuSel(cand.runNumber(), + p.M(), p.E(), p.Px(), p.Py(), p.Pz(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), - p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), + p2.E(), p2.Px(), p2.Py(), p2.Pz(), p2.Pt(), p2.PseudoRapidity(), p2.Phi(), static_cast(myTrackType), + p1.E(), p1.Px(), p1.Py(), p1.Pz(), p1.Pt(), p1.PseudoRapidity(), p1.Phi(), static_cast(myTrackType), zdc.timeA, zdc.enA, zdc.timeC, zdc.enC, znClass); } } @@ -643,12 +692,12 @@ struct fwdMuonsUPC { { // check that all pairs are mu+mu- - if (McPart1.pdgCode() + McPart2.pdgCode() != 0) - LOGF(info, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode()); + if (std::abs(McPart1.pdgCode()) != kMuonPDG && std::abs(McPart2.pdgCode()) != kMuonPDG) + LOGF(debug, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode()); // create Lorentz vectors TLorentzVector p1, p2; - auto mMu = particleMass(13); + auto mMu = particleMass(kMuonPDG); p1.SetXYZM(McPart1.px(), McPart1.py(), McPart1.pz(), mMu); p2.SetXYZM(McPart2.px(), McPart2.py(), McPart2.pz(), mMu); TLorentzVector p = p1 + p2; @@ -710,12 +759,17 @@ struct fwdMuonsUPC { CompleteFwdTracks::iterator const& tr1, aod::UDMcParticles::iterator const& McPart1, CompleteFwdTracks::iterator const& tr2, aod::UDMcParticles::iterator const& McPart2) { + + // check that all pairs are mu+mu- + if (std::abs(McPart1.pdgCode()) != kMuonPDG && std::abs(McPart2.pdgCode()) != kMuonPDG) + LOGF(debug, "PDG codes: %d | %d", McPart1.pdgCode(), McPart2.pdgCode()); + // V0 selection const auto& ampsV0A = cand.amplitudesV0A(); const auto& ampsRelBCsV0A = cand.ampRelBCsV0A(); for (unsigned int i = 0; i < ampsV0A.size(); ++i) { if (std::abs(ampsRelBCsV0A[i]) <= 1) { - if (ampsV0A[i] > 100.) + if (ampsV0A[i] > kMaxAmpV0A) return; } } @@ -726,24 +780,39 @@ struct fwdMuonsUPC { return; } - // track selection - if (!isMuonSelected(*tr1)) - return; - if (!isMuonSelected(*tr2)) - return; - // MCH-MID match selection int nMIDs = 0; if (tr1.chi2MatchMCHMID() > 0) nMIDs++; if (tr2.chi2MatchMCHMID() > 0) nMIDs++; - if (nMIDs != 2) + if (nMIDs != kReqMatchMIDTracks) + return; + + // MFT-MID match selection (if MFT is requested by the trackType) + if (myTrackType == 0) { + // if MFT is requested check that the tracks is inside the MFT acceptance + kEtaMin = -3.6; + kEtaMax = -2.5; + + int nMFT = 0; + if (tr1.chi2MatchMCHMFT() > 0 && tr1.chi2MatchMCHMFT() < kMaxChi2MFTMatch) + nMFT++; + if (tr2.chi2MatchMCHMFT() > 0 && tr2.chi2MatchMCHMFT() < kMaxChi2MFTMatch) + nMFT++; + if (nMFT != kReqMatchMFTTracks) + return; + } + + // track selection + if (!isMuonSelected(*tr1)) + return; + if (!isMuonSelected(*tr2)) return; // form Lorentz vectors TLorentzVector p1, p2; - auto mMu = particleMass(13); + auto mMu = particleMass(kMuonPDG); p1.SetXYZM(tr1.px(), tr1.py(), tr1.pz(), mMu); p2.SetXYZM(tr2.px(), tr2.py(), tr2.pz(), mMu); TLorentzVector p = p1 + p2; @@ -783,10 +852,10 @@ struct fwdMuonsUPC { // print info in case of problems if (tr1.sign() * McPart1.pdgCode() > 0 || tr2.sign() * McPart2.pdgCode() > 0) { - LOGF(info, "Problem: "); - LOGF(info, "real: %d | %d", (int)tr1.sign(), (int)tr2.sign()); - LOGF(info, "mc : %i | %i", (int)McPart1.pdgCode(), (int)McPart2.pdgCode()); - LOGF(info, "contrib: %d", (int)cand.numContrib()); + LOGF(debug, "Problem: "); + LOGF(debug, "real: %d | %d", (int)tr1.sign(), (int)tr2.sign()); + LOGF(debug, "mc : %i | %i", (int)McPart1.pdgCode(), (int)McPart2.pdgCode()); + LOGF(debug, "contrib: %d", (int)cand.numContrib()); } // fill the histos @@ -802,6 +871,7 @@ struct fwdMuonsUPC { mcRecoRegistry.fill(HIST("hMass"), p.M()); mcRecoRegistry.fill(HIST("hPt"), p.Pt()); mcRecoRegistry.fill(HIST("hPtFit"), p.Pt()); + mcRecoRegistry.fill(HIST("hPtFit2"), p.Pt()); mcRecoRegistry.fill(HIST("hEta"), p.Eta()); mcRecoRegistry.fill(HIST("hRapidity"), p.Rapidity()); mcRecoRegistry.fill(HIST("hPhi"), p.Phi()); @@ -832,19 +902,21 @@ struct fwdMuonsUPC { // store the event to save it into a tree if (tr1.sign() > 0) { - dimuReco(p.M(), p.Pt(), p.Rapidity(), p.Phi(), + dimuReco(cand.runNumber(), + p.M(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p1.Pt(), p1.PseudoRapidity(), p1.Phi(), - p2.Pt(), p2.PseudoRapidity(), p2.Phi(), + p1.Pt(), p1.PseudoRapidity(), p1.Phi(), static_cast(myTrackType), + p2.Pt(), p2.PseudoRapidity(), p2.Phi(), static_cast(myTrackType), // gen info pMc.Pt(), pMc.Rapidity(), pMc.Phi(), p1Mc.Pt(), p1Mc.PseudoRapidity(), p1Mc.Phi(), p2Mc.Pt(), p2Mc.PseudoRapidity(), p2Mc.Phi()); } else { - dimuReco(p.M(), p.Pt(), p.Rapidity(), p.Phi(), + dimuReco(cand.runNumber(), + p.M(), p.Pt(), p.Rapidity(), p.Phi(), phiAverage, phiCharge, - p2.Pt(), p2.PseudoRapidity(), p2.Phi(), - p1.Pt(), p1.PseudoRapidity(), p1.Phi(), + p2.Pt(), p2.PseudoRapidity(), p2.Phi(), static_cast(myTrackType), + p1.Pt(), p1.PseudoRapidity(), p1.Phi(), static_cast(myTrackType), // gen info pMc.Pt(), pMc.Rapidity(), pMc.Phi(), p2Mc.Pt(), p2Mc.PseudoRapidity(), p2Mc.Phi(), @@ -890,7 +962,7 @@ struct fwdMuonsUPC { } } - PROCESS_SWITCH(fwdMuonsUPC, processData, "", true); + PROCESS_SWITCH(FwdMuonsUPC, processData, "", true); // process MC Truth void processMcGen(aod::UDMcCollisions const& mccollisions, aod::UDMcParticles const& McParts) @@ -912,12 +984,12 @@ struct fwdMuonsUPC { processMcGenCand(cand, tr1, tr2); } } - PROCESS_SWITCH(fwdMuonsUPC, processMcGen, "", false); + PROCESS_SWITCH(FwdMuonsUPC, processMcGen, "", false); // process reco MC (gen info included) void processMcReco(CandidatesFwd const& eventCandidates, CompleteFwdTracks const& fwdTracks, - aod::UDMcCollisions const& mcCandidates, + aod::UDMcCollisions const&, aod::UDMcParticles const& McParts) { std::unordered_map> tracksPerCandAll; @@ -925,42 +997,39 @@ struct fwdMuonsUPC { // loop over the candidates for (const auto& item : tracksPerCandAll) { - if (item.second.size() != 6) { - // LOGF(info, "error: reco track(s) not gen"); + if (item.second.size() != 4) { + LOGF(debug, "number track (reco + gen) = %d", item.second.size()); continue; } - int32_t trId1 = item.second[0]; - int32_t trId2 = item.second[3]; //[2] - - int32_t candID = item.first; - auto cand = eventCandidates.iteratorAt(candID); - auto tr1 = fwdTracks.iteratorAt(trId1); - auto tr2 = fwdTracks.iteratorAt(trId2); + // get the reco candidate + auto cand = eventCandidates.iteratorAt(item.first); - auto trMcId1 = item.second[1]; - auto trMcId2 = item.second[4]; - auto trMc1 = McParts.iteratorAt(trMcId1); - auto trMc2 = McParts.iteratorAt(trMcId2); + // get reco tracks and corresponding gen particles + auto tr1 = fwdTracks.iteratorAt(item.second[0]); + auto trMc1 = McParts.iteratorAt(item.second[1]); + auto tr2 = fwdTracks.iteratorAt(item.second[2]); + auto trMc2 = McParts.iteratorAt(item.second[3]); - auto mcCandID1 = mcCandidates.iteratorAt(item.second[2]); - auto mcCandID2 = mcCandidates.iteratorAt(item.second[5]); + // check that the method used here gets the the MC particles + // as the one used by Nazar + auto nzTrMc1 = McParts.iteratorAt(tr1.udMcParticleId()); + auto nzTrMc2 = McParts.iteratorAt(tr2.udMcParticleId()); - if (mcCandID1 != mcCandID2) { - // LOGF(info, "mc tracks belong to different collisions"); - } + if (nzTrMc1 != trMc1) + LOGF(debug, "diff wrt Nazar!"); + if (nzTrMc2 != trMc2) + LOGF(debug, "diff wrt Nazar!"); - // auto mcTr1 = McParts.iteratorAt(tr1.udMcParticleId()); - // auto mcTr2 = McParts.iteratorAt(tr2.udMcParticleId()); processMcRecoCand(cand, tr1, trMc1, tr2, trMc2); } } - PROCESS_SWITCH(fwdMuonsUPC, processMcReco, "", false); + PROCESS_SWITCH(FwdMuonsUPC, processMcReco, "", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/PWGUD/Tasks/analysisMCDPMJetSGv3.cxx b/PWGUD/Tasks/analysisMCDPMJetSGv3.cxx new file mode 100644 index 00000000000..4347871377a --- /dev/null +++ b/PWGUD/Tasks/analysisMCDPMJetSGv3.cxx @@ -0,0 +1,412 @@ +// 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. +/// \file AnalysisMCDPMJetSGv3.cxx +/// \brief Process MC DPMJet events for inclusive studies. +/// +/// \author Simone Ragoni + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Framework/ASoAHelpers.h" +// #include "TDatabasePDG.h" +#include "PWGUD/Core/UPCHelpers.h" +#include "PWGUD/DataModel/UDTables.h" +// #include "TLorentzVector.h" +// #include "TVector3.h" +#include "Math/LorentzVector.h" // ROOT::Math::LorentzVector +#include "Math/PxPyPzM4D.h" // ROOT::Math::PxPyPzM4D +#include "TMath.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct AnalysisMCDPMJetSGv3 { + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + // TDatabasePDG* fPDG = TDatabasePDG::Instance(); + + Configurable nBinsPt{"nBinsPt", 100, "N bins in pT histo"}; + + // using myCompleteTracks = soa::Join; + // using myFilteredTracks = soa::Filtered; + using BCs = soa::Join; + + Preslice perCollision = aod::track::collisionId; + Preslice perMcCollision = o2::aod::mcparticle::mcCollisionId; + // using MCTCs = soa::Join; + // using MCTC = MCTCs::iterator; + // define abbreviations + using CCs = soa::Join; + using CC = CCs::iterator; + using MCparticles = aod::UDMcParticles::iterator; + using TCs = soa::Join; + // using TCs = soa::Join; + using TC = TCs::iterator; + using LorentzVectorM = ROOT::Math::LorentzVector>; + + double massPion = 0.; + double massKaon = 0.; + double massProton = 0.; + const int codePion = 211; + const int codeKaon = 321; + const int codeProton = 2212; + + void init(InitContext const&) + { + // TParticlePDG* pionPDG = fPDG->GetParticle(codePion); + // if (pionPDG != nullptr) { + // massPion = pionPDG->Mass(); + // } + // TParticlePDG* kaonPDG = fPDG->GetParticle(codeKaon); + // if (kaonPDG != nullptr) { + // massKaon = kaonPDG->Mass(); + // } + // TParticlePDG* protonPDG = fPDG->GetParticle(codeProton); + // if (protonPDG != nullptr) { + // massProton = protonPDG->Mass(); + // } + massPion = o2::constants::physics::MassPionCharged; + massKaon = o2::constants::physics::MassKaonCharged; + massProton = o2::constants::physics::MassProton; + + // define axes you want to use + const AxisSpec axisCounter{10, 0, 10, ""}; + const AxisSpec axisEta{100, -1.5, +1.5, "#eta"}; + const AxisSpec axisPt{5000, 0, 5, "p_{T}"}; + const AxisSpec axisPtSmall{1000, 0, 1, "p_{T}"}; + const AxisSpec axisMass{nBinsPt, 0, 5, "m_{#pi#pi}"}; + const AxisSpec axisMassSmall{nBinsPt, 0, 2, "m_{#pi#pi}"}; + const AxisSpec axisDeltaPt{100, -1.0, +1.0, "#Delta(p_{T})"}; + const AxisSpec axisBC{1000, -10000.0, +10000.0, "BCs"}; + const AxisSpec axisBCext{100000, -10000000.0, +10000000.0, "BCs"}; + const AxisSpec axisCosTheta{100, -1.0, +1.0, "cos#theta"}; + const AxisSpec axisPhi{600, -o2::constants::math::PI, -o2::constants::math::PI, "#varphi"}; + + // create histograms + histos.add("hdEdx", "p vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + histos.add("hSigmaPion", "p vs dE/dx sigma pion TPC ", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaPionTruth", "p vs dE/dx sigma pion TPC truth", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaPionTOF", "p vs dE/dx sigma pion TOF ", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaPionTruthTOF", "p vs dE/dx sigma pion TOF truth", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaKaon", "p vs dE/dx sigma kaon TPC ", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaKaonTruth", "p vs dE/dx sigma kaon TPC truth", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaKaonTOF", "p vs dE/dx sigma kaon TOF ", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaKaonTruthTOF", "p vs dE/dx sigma kaon TOF truth", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaProton", "p vs dE/dx sigma proton TPC ", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaProtonTruth", "p vs dE/dx sigma proton TPC truth", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaProtonTOF", "p vs dE/dx sigma proton TOF ", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + histos.add("hSigmaProtonTruthTOF", "p vs dE/dx sigma proton TOF truth", kTH2F, {{300, 0.0, 3.0}, {200, -10.0, 10.0}}); + + histos.add("hVisibleMultiVsGeneratedMulti", "Multiplicity correlation", kTH2F, {{10000, -0.5, 9999.5}, {1000, -0.5, 999.5}}); + + histos.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); + histos.add("ptResolution", "ptResolution", kTH2F, {axisPt, axisDeltaPt}); + + histos.add("ptGeneratedPion", "ptGeneratedPion", kTH1F, {axisPt}); + histos.add("ptGeneratedKaon", "ptGeneratedKaon", kTH1F, {axisPt}); + histos.add("ptGeneratedProton", "ptGeneratedProton", kTH1F, {axisPt}); + histos.add("ptGeneratedPionAxE", "ptGeneratedPionAxE", kTH1F, {axisPt}); + histos.add("ptGeneratedKaonAxE", "ptGeneratedKaonAxE", kTH1F, {axisPt}); + histos.add("ptGeneratedProtonAxE", "ptGeneratedProtonAxE", kTH1F, {axisPt}); + histos.add("ptGeneratedProtonAxEPos", "ptGeneratedProtonAxEPos", kTH1F, {axisPt}); + histos.add("ptGeneratedProtonAxENeg", "ptGeneratedProtonAxENeg", kTH1F, {axisPt}); + histos.add("ptReconstructedPion", "ptReconstructedPion", kTH1F, {axisPt}); + histos.add("ptReconstructedKaon", "ptReconstructedKaon", kTH1F, {axisPt}); + histos.add("ptReconstructedProton", "ptReconstructedProton", kTH1F, {axisPt}); + histos.add("ptReconstructedProtonPos", "ptReconstructedProtonPos", kTH1F, {axisPt}); + histos.add("ptReconstructedProtonNeg", "ptReconstructedProtonNeg", kTH1F, {axisPt}); + histos.add("ptReconstructedPionTOF", "ptReconstructedPionTOF", kTH1F, {axisPt}); + histos.add("ptReconstructedKaonTOF", "ptReconstructedKaonTOF", kTH1F, {axisPt}); + histos.add("ptReconstructedProtonTOF", "ptReconstructedProtonTOF", kTH1F, {axisPt}); + + histos.add("allreconstructedPFPion", "allreconstructedPFPion", kTH1F, {axisPt}); + histos.add("allreconstructedPFKaon", "allreconstructedPFKaon", kTH1F, {axisPt}); + histos.add("allreconstructedPFProton", "allreconstructedPFProton", kTH1F, {axisPt}); + histos.add("allreconstructedPFProtonPos", "allreconstructedPFProtonPos", kTH1F, {axisPt}); + histos.add("allreconstructedPFProtonNeg", "allreconstructedPFProtonNeg", kTH1F, {axisPt}); + histos.add("allreconstructedPFPionTOF", "allreconstructedPFPionTOF", kTH1F, {axisPt}); + histos.add("allreconstructedPFKaonTOF", "allreconstructedPFKaonTOF", kTH1F, {axisPt}); + histos.add("allreconstructedPFProtonTOF", "allreconstructedPFProtonTOF", kTH1F, {axisPt}); + + histos.add("numberOfRecoCollisions", "numberOfRecoCollisions", kTH1F, {{100, -0.5f, 99.5f}}); + histos.add("numberOfRecoCollisions2", "numberOfRecoCollisions2", kTH1F, {{100, -0.5f, 99.5f}}); + histos.add("numberOfTracksMC", "numberOfTracksMC", kTH1F, {{100, -0.5f, 99.5f}}); + histos.add("numberOfTracksReco", "numberOfTracksReco", kTH1F, {{100, -0.5f, 99.5f}}); + + histos.add("bcResolution", "bcResolution", kTH1F, {axisBC}); + histos.add("mcbcHistogram", "mcbcHistogram", kTH1F, {axisBCext}); + histos.add("bcHistogram", "bcHistogram", kTH1F, {axisBCext}); + histos.add("mcbcModuloOrbitHistogram", "mcbcModuloOrbitHistogram", kTH1F, {axisBC}); + histos.add("bcModuloOrbitHistogram", "bcModuloOrbitHistogram", kTH1F, {axisBC}); + } + //----------------------------------------------------------------------------------------------------------------------- + void processSim(aod::UDMcCollision const& mcCollision, aod::UDMcParticles const& mcParticles) + { + // histos.fill(HIST("eventCounter"), 0.5); + + // auto massPion = 0.; + // TParticlePDG pionPDG = fPDG->GetParticle(codePion); + // massPion = pionPDG.Mass(); + // auto massKaon = 0.; + // TParticlePDG kaonPDG = fPDG->GetParticle(codeKaon); + // massKaon = kaonPDG.Mass(); + // auto massProton = 0.; + // TParticlePDG protonPDG = fPDG->GetParticle(codeProton); + // massProton = protonPDG.Mass(); + histos.fill(HIST("numberOfTracksMC"), mcParticles.size()); + histos.fill(HIST("eventCounter"), mcCollision.size()); + // LOGF(info, "New event! mcParticles.size() = %d", mcParticles.size()); + + int counterMC = 0; + int counter = 0; + for (const auto& mcParticle : mcParticles) { + if (!mcParticle.isPhysicalPrimary()) + continue; + counterMC += 1; + // if(mcParticle.isPhysicalPrimary()) counterMC += 1; + LorentzVectorM protoMC( + mcParticle.px(), + mcParticle.py(), + mcParticle.pz(), + massPion); + double etaMax = 0.8; + double ptMin = 0.1; + if (std::fabs(protoMC.Eta()) < etaMax && protoMC.Pt() > ptMin) { + counter += 1; + } + if (!mcParticle.isPhysicalPrimary()) + continue; + // if(mcParticle.isPhysicalPrimary() && fabs(mcParticle.eta())<0.9){ // do this in the context of the MC loop ! (context matters!!!) + // LorentzVectorM pMC; + LorentzVectorM pMC(mcParticle.px(), mcParticle.py(), mcParticle.pz(), massPion); + if (std::abs(mcParticle.pdgCode()) == codePion) { + // histos.fill(HIST("ptGeneratedPion"), mcParticle.pt()); + // LorentzVectorM pMC(mcParticle.px(), mcParticle.py(), mcParticle.pz(), massPion); + histos.fill(HIST("ptGeneratedPion"), pMC.Pt()); + } + if (std::abs(mcParticle.pdgCode()) == codeKaon) { + // histos.fill(HIST("ptGenerateKaon"), mcParticle.pt()); + // LorentzVectorM pMC(mcParticle.px(), mcParticle.py(), mcParticle.pz(), massKaon); + pMC.SetM(massKaon); + histos.fill(HIST("ptGeneratedKaon"), pMC.Pt()); + } + if (std::abs(mcParticle.pdgCode()) == codeProton) { + // histos.fill(HIST("ptGeneratedProton"), mcParticle.pt()); + // LorentzVectorM pMC(mcParticle.px(), mcParticle.py(), mcParticle.pz(), massProton); + pMC.SetM(massProton); + histos.fill(HIST("ptGeneratedProton"), pMC.Pt()); + } + double yMax = 0.8; + if (std::abs(pMC.Rapidity()) < yMax) { + if (std::abs(mcParticle.pdgCode()) == codePion) + histos.fill(HIST("ptGeneratedPionAxE"), pMC.Pt()); + if (std::abs(mcParticle.pdgCode()) == codeKaon) + histos.fill(HIST("ptGeneratedKaonAxE"), pMC.Pt()); + if (std::abs(mcParticle.pdgCode()) == codeProton) + histos.fill(HIST("ptGeneratedProtonAxE"), pMC.Pt()); + if (mcParticle.pdgCode() == codeProton) { + histos.fill(HIST("ptGeneratedProtonAxEPos"), pMC.Pt()); + } else { + histos.fill(HIST("ptGeneratedProtonAxENeg"), pMC.Pt()); + } + } + } + histos.fill(HIST("hVisibleMultiVsGeneratedMulti"), counterMC, counter); + } + PROCESS_SWITCH(AnalysisMCDPMJetSGv3, processSim, "processSim", true); + + void processReco(CC const& collision, + TCs const& tracks, + // aod::UDMcCollisions const& /*mccollisions*/, + aod::UDMcParticles const& mcParticles) + { + histos.fill(HIST("numberOfRecoCollisions"), 88.); // number of times coll was reco-ed + histos.fill(HIST("numberOfRecoCollisions"), collision.size()); // number of times coll was reco-ed + histos.fill(HIST("numberOfRecoCollisions2"), mcParticles.size()); + Partition pvContributors = aod::udtrack::isPVContributor == true; + pvContributors.bindTable(tracks); + + // auto massPion = 0.; + // TParticlePDG pionPDG = fPDG->GetParticle(codePion); + // massPion = pionPDG.Mass(); + // auto massKaon = 0.; + // TParticlePDG kaonPDG = fPDG->GetParticle(codeKaon); + // massKaon = kaonPDG.Mass(); + // auto massProton = 0.; + // TParticlePDG protonPDG = fPDG->GetParticle(codeProton); + // massProton = protonPDG.Mass(); + + histos.fill(HIST("numberOfTracksReco"), tracks.size()); + // double etaMax = 0.8; + double yMax = 0.8; + double sigmaMax = 3.; + double ptMin = 0.1; + int nFindableMin = 70; + double dcaZlimit = 2.; + + // int counter = 0; + for (const auto& track : tracks) { + if (track.isPVContributor()) { + int nFindable = track.tpcNClsFindable(); + if (nFindable < nFindableMin) { + continue; + } + // int NMinusFound = track.tpcNClsFindableMinusFound(); + // int NCluster = NFindable - NMinusFound; + // if (NCluster < 70) { + // continue; + // } + if (track.pt() < ptMin) { + continue; + } + if (!(std::abs(track.dcaZ()) < dcaZlimit)) { + continue; + } + double dcaLimit = 0.0105 + 0.035 / std::pow(track.pt(), 1.1); + if (!(std::abs(track.dcaXY()) < dcaLimit)) { + continue; + } + + double momentum = std::sqrt(track.px() * track.px() + track.py() * track.py() + track.pz() * track.pz()); + double dEdx = track.tpcSignal(); + histos.fill(HIST("hdEdx"), momentum, dEdx); + + LorentzVectorM pion(track.px(), track.py(), track.pz(), o2::constants::physics::MassPionCharged); + LorentzVectorM kaon(track.px(), track.py(), track.pz(), o2::constants::physics::MassKaonCharged); + LorentzVectorM proton(track.px(), track.py(), track.pz(), o2::constants::physics::MassProton); + auto nSigmaPi = -999.; + auto nSigmaKa = -999.; + auto nSigmaPr = -999.; + auto nSigmaPiTOF = -999.; + auto nSigmaKaTOF = -999.; + auto nSigmaPrTOF = -999.; + // This section makes templates + if (track.hasTPC()) { + nSigmaPi = track.tpcNSigmaPi(); + nSigmaKa = track.tpcNSigmaKa(); + nSigmaPr = track.tpcNSigmaPr(); + if (std::abs(nSigmaPi) < sigmaMax && std::abs(pion.Rapidity()) < yMax) { + histos.fill(HIST("hSigmaPion"), track.pt(), nSigmaPi); + if (track.has_udMcParticle()) { + auto mcParticle = track.udMcParticle(); + // if(abs(mcParticle.pdgCode())==codePion && mcParticle.isPhysicalPrimary()) howManyPionsHavePionMCandPrimaries += 1; + if (std::abs(mcParticle.pdgCode()) == codePion) { + histos.fill(HIST("hSigmaPionTruth"), track.pt(), nSigmaPi); + histos.fill(HIST("allreconstructedPFPion"), track.pt()); + if (mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("ptReconstructedPion"), track.pt()); + } + } + } + } + if (std::abs(nSigmaKa) < sigmaMax && std::abs(kaon.Rapidity()) < yMax) { + histos.fill(HIST("hSigmaKaon"), track.pt(), nSigmaKa); + if (track.has_udMcParticle()) { + auto mcParticle = track.udMcParticle(); + if (std::abs(mcParticle.pdgCode()) == codeKaon) { + histos.fill(HIST("hSigmaKaonTruth"), track.pt(), nSigmaKa); + histos.fill(HIST("allreconstructedPFKaon"), track.pt()); + if (mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("ptReconstructedKaon"), track.pt()); + } + } + } + } + if (std::abs(nSigmaPr) < sigmaMax && std::abs(proton.Rapidity()) < yMax) { + histos.fill(HIST("hSigmaProton"), track.pt(), nSigmaPr); + if (track.has_udMcParticle()) { + auto mcParticle = track.udMcParticle(); + if (std::abs(mcParticle.pdgCode()) == codeProton) { + histos.fill(HIST("hSigmaProtonTruth"), track.pt(), nSigmaPr); + histos.fill(HIST("allreconstructedPFProton"), track.pt()); + if (mcParticle.pdgCode() == codeProton) { + histos.fill(HIST("allreconstructedPFProtonPos"), track.pt()); + } else { + histos.fill(HIST("allreconstructedPFProtonNeg"), track.pt()); + } + if (mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("ptReconstructedProton"), track.pt()); + if (mcParticle.pdgCode() == codeProton) { + histos.fill(HIST("ptReconstructedProtonPos"), track.pt()); + } else { + histos.fill(HIST("ptReconstructedProtonNeg"), track.pt()); + } + } + } + } + } + } + if (track.hasTPC() && track.hasTOF()) { + // if (track.hasTOF()) { + nSigmaPiTOF = track.tofNSigmaPi(); + nSigmaKaTOF = track.tofNSigmaKa(); + nSigmaPrTOF = track.tofNSigmaPr(); + if (std::abs(nSigmaPiTOF) < sigmaMax && std::abs(pion.Rapidity()) < yMax) { + histos.fill(HIST("hSigmaPionTOF"), track.pt(), nSigmaPiTOF); + if (track.has_udMcParticle()) { + auto mcParticle = track.udMcParticle(); + // if(abs(mcParticle.pdgCode())==codePion && mcParticle.isPhysicalPrimary()) howManyPionsHavePionMCandPrimaries += 1; + if (std::abs(mcParticle.pdgCode()) == codePion) { + histos.fill(HIST("hSigmaPionTruthTOF"), track.pt(), nSigmaPiTOF); + histos.fill(HIST("allreconstructedPFPionTOF"), track.pt()); + if (mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("ptReconstructedPionTOF"), track.pt()); + } + } + } + } + if (std::abs(nSigmaKaTOF) < sigmaMax && std::abs(kaon.Rapidity()) < yMax) { + histos.fill(HIST("hSigmaKaonTOF"), track.pt(), nSigmaKaTOF); + if (track.has_udMcParticle()) { + auto mcParticle = track.udMcParticle(); + if (std::abs(mcParticle.pdgCode()) == codeKaon) { + histos.fill(HIST("hSigmaKaonTruthTOF"), track.pt(), nSigmaKaTOF); + histos.fill(HIST("allreconstructedPFKaonTOF"), track.pt()); + if (mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("ptReconstructedKaonTOF"), track.pt()); + } + } + } + } + if (std::abs(nSigmaPrTOF) < sigmaMax && std::abs(proton.Rapidity()) < yMax) { + histos.fill(HIST("hSigmaProtonTOF"), track.pt(), nSigmaPrTOF); + if (track.has_udMcParticle()) { + auto mcParticle = track.udMcParticle(); + if (std::abs(mcParticle.pdgCode()) == codeProton) { + histos.fill(HIST("hSigmaProtonTruthTOF"), track.pt(), nSigmaPrTOF); + histos.fill(HIST("allreconstructedPFProtonTOF"), track.pt()); + if (mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("ptReconstructedProtonTOF"), track.pt()); + } + } + } + } + } + // counter++; + // histos.fill(HIST("hVisibleMultiVsGeneratedMulti"), counterMC, counter); + // histos.fill(HIST("hVisibleMultiVsGeneratedMulti"), mcParticles.size(), counter); + } + } // track loop + + // } // collision loop + } + PROCESS_SWITCH(AnalysisMCDPMJetSGv3, processReco, "processReco", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/Tasks/decayTreeAnalyzer.cxx b/PWGUD/Tasks/decayTreeAnalyzer.cxx new file mode 100644 index 00000000000..c725a2ca72a --- /dev/null +++ b/PWGUD/Tasks/decayTreeAnalyzer.cxx @@ -0,0 +1,143 @@ +// 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. +// +// \brief Analyses UD tables (DGCandidates, DGTracks) of DG candidates produced with DGCandProducer +// \author Paul Buehler, paul.buehler@oeaw.ac.at +// \since 01.03.2024 + +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" + +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "CommonConstants/LHCConstants.h" +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/Core/UDHelpers.h" +#include "PWGUD/Core/UDGoodRunSelector.h" +#include "PWGUD/Core/decayTree.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct decayTreeAnalyzer { + + // ccdb + Service ccdb; + int lastRun = -1; // last run number (needed to access ccdb only if run!=lastRun) + std::bitset bcPatternB; // bc pattern of colliding bunches + + // goodRun selector + Configurable goodRunsFile{"goodRunsFile", {}, "json with list of good runs"}; + UDGoodRunSelector grsel = UDGoodRunSelector(); + + // decay tree object + Configurable parsFile{"parsFile", {}, "json with parameters"}; + decayTree decTree = decayTree(); + + // initialize histogram registry + HistogramRegistry registry{ + "registry", + {}}; + + void init(InitContext&) + { + // goodRun selector + grsel.init(goodRunsFile); + grsel.Print(); + + // decay tree object + decTree.init(parsFile, registry); + decTree.Print(); + } + + using UDCollisionsFull = soa::Join; + using UDCollisionFull = UDCollisionsFull::iterator; + using UDTracksFull = soa::Join; + + // PV contributors + Filter PVContributorFilter = aod::udtrack::isPVContributor == true; + using PVTracks = soa::Filtered; + + void process(UDCollisionFull const& dgcand, UDTracksFull const& dgtracks, PVTracks const& PVContributors) + { + + // accept only selected run numbers + int run = dgcand.runNumber(); + if (!grsel.isGoodRun(run)) { + return; + } + + // extract bc pattern from CCDB for data or anchored MC only + if (run != lastRun && run >= 500000) { + LOGF(info, "Updating bcPattern %d ...", run); + auto tss = ccdb->getRunDuration(run); + auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", tss.first); + bcPatternB = grplhcif->getBunchFilling().getBCPattern(); + lastRun = run; + } + + // is BB bunch? + auto bcnum = dgcand.globalBC(); + if (run >= 500000 && bcPatternB[bcnum % o2::constants::lhc::LHCMaxBunches] == 0) { + LOGF(debug, "bcnum[1] %d is not a BB BC", bcnum % o2::constants::lhc::LHCMaxBunches); + return; + } + + // check FIT information + auto bitMin = decTree.dBCRange()[0] + 16; + auto bitMax = decTree.dBCRange()[1] + 16; + for (auto bit = bitMin; bit <= bitMax; bit++) { + if (decTree.FITvetos()[0] && TESTBIT(dgcand.bbFV0Apf(), bit)) + return; + if (decTree.FITvetos()[1] && TESTBIT(dgcand.bbFT0Apf(), bit)) + return; + if (decTree.FITvetos()[2] && TESTBIT(dgcand.bbFT0Cpf(), bit)) + return; + if (decTree.FITvetos()[3] && TESTBIT(dgcand.bbFDDApf(), bit)) + return; + if (decTree.FITvetos()[4] && TESTBIT(dgcand.bbFDDCpf(), bit)) + return; + } + + // check number of PV contributors + if (dgcand.numContrib() != PVContributors.size()) { + LOGF(info, "Missmatch of PVContributors %d != %d", dgcand.numContrib(), PVContributors.size()); + } + auto nTrackRange = decTree.ntrackRange(); + if (dgcand.numContrib() < nTrackRange[0] || dgcand.numContrib() > nTrackRange[1]) { + LOGF(debug, "Rejected 1: %d not in range [%d, %d].", dgcand.numContrib(), nTrackRange[0], nTrackRange[1]); + return; + } + + // skip events with out-of-range rgtrwTOF + auto rtrwTOF = udhelpers::rPVtrwTOF(dgtracks, PVContributors.size()); + auto minRgtrwTOF = decTree.rgtrTOFMin(); + if (rtrwTOF < minRgtrwTOF) { + LOGF(debug, "Rejected 3: %f below threshold of %f.", rtrwTOF, minRgtrwTOF); + return; + } + + // compute the decay tree + LOGF(debug, "BC %d", dgcand.globalBC()); + decayTreeResType results = decTree.processTree(PVContributors); + // decTree.fillHistograms(results, PVContributors); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"decaytree-analyzer"}), + }; +} diff --git a/PWGUD/Tasks/dgCandAnalyzer.cxx b/PWGUD/Tasks/dgCandAnalyzer.cxx index 90d4bd8e011..93c62c567d5 100644 --- a/PWGUD/Tasks/dgCandAnalyzer.cxx +++ b/PWGUD/Tasks/dgCandAnalyzer.cxx @@ -14,6 +14,8 @@ // \since 06.06.2022 #include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -277,8 +279,6 @@ struct DGCandAnalyzer { registry.fill(HIST("FIT/FDDCAmplitude"), dgcand.totalFDDAmplitudeC(), 1.); // skip events with too few/many tracks - // Partition PVContributors = aod::udtrack::isPVContributor == true; - // PVContributors.bindTable(dgtracks); if (dgcand.numContrib() != PVContributors.size()) { LOGF(info, "Missmatch of PVContributors %d != %d", dgcand.numContrib(), PVContributors.size()); } diff --git a/PWGUD/Tasks/eventByevent.cxx b/PWGUD/Tasks/eventByevent.cxx index 3df594af546..072ae2d961c 100644 --- a/PWGUD/Tasks/eventByevent.cxx +++ b/PWGUD/Tasks/eventByevent.cxx @@ -13,7 +13,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include diff --git a/PWGUD/Tasks/exclusivePentaquark.cxx b/PWGUD/Tasks/exclusivePentaquark.cxx index 95da9600f67..c63dc7fce68 100644 --- a/PWGUD/Tasks/exclusivePentaquark.cxx +++ b/PWGUD/Tasks/exclusivePentaquark.cxx @@ -11,7 +11,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include "TLorentzVector.h" diff --git a/PWGUD/Tasks/exclusivePhi.cxx b/PWGUD/Tasks/exclusivePhi.cxx index 8f764f2bfff..634d17a5d8e 100644 --- a/PWGUD/Tasks/exclusivePhi.cxx +++ b/PWGUD/Tasks/exclusivePhi.cxx @@ -13,7 +13,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include "TLorentzVector.h" diff --git a/PWGUD/Tasks/exclusivePhiLeptons.cxx b/PWGUD/Tasks/exclusivePhiLeptons.cxx index ea7e92f61dd..b212dd21723 100644 --- a/PWGUD/Tasks/exclusivePhiLeptons.cxx +++ b/PWGUD/Tasks/exclusivePhiLeptons.cxx @@ -12,7 +12,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include "TLorentzVector.h" diff --git a/PWGUD/Tasks/exclusivePhiLeptonsTrees.cxx b/PWGUD/Tasks/exclusivePhiLeptonsTrees.cxx index e1ef9b8f3b4..00abada06d4 100644 --- a/PWGUD/Tasks/exclusivePhiLeptonsTrees.cxx +++ b/PWGUD/Tasks/exclusivePhiLeptonsTrees.cxx @@ -12,7 +12,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include "TLorentzVector.h" diff --git a/PWGUD/Tasks/exclusiveRhoTo4Pi.cxx b/PWGUD/Tasks/exclusiveRhoTo4Pi.cxx index f5a44f5848e..daae60d111c 100644 --- a/PWGUD/Tasks/exclusiveRhoTo4Pi.cxx +++ b/PWGUD/Tasks/exclusiveRhoTo4Pi.cxx @@ -13,24 +13,30 @@ /// \brief Task for analyzing exclusive rho decays to 4 pions /// \author Anantha Padmanabhan M Nair -#include -#include -#include -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoA.h" -#include "Framework/ASoAHelpers.h" -#include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include "PWGUD/Core/SGTrackSelector.h" +#include "PWGUD/Core/UDHelpers.h" +#include "PWGUD/DataModel/UDTables.h" + #include "Common/DataModel/PIDResponse.h" -#include -#include "TLorentzVector.h" -#include -#include "Math/Vector4D.h" -#include "Math/Vector3D.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + #include "Math/GenVector/Boost.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "TPDGCode.h" +#include +#include + +#include +#include +#include using namespace std; using namespace o2; @@ -38,170 +44,1094 @@ using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -struct exclusiveRhoTo4Pi { // o2-linter: disable=name/workflow-file,name/struct +namespace o2::aod +{ +namespace branch +{ +// Run Number +DECLARE_SOA_COLUMN(RunNumber, runNumber, int); +// Check UPC mode +DECLARE_SOA_COLUMN(IfCheckUPCmode, ifCheckUPCmode, uint16_t); +// vertex Position +DECLARE_SOA_COLUMN(PosX, posX, double); +DECLARE_SOA_COLUMN(PosY, posY, double); +DECLARE_SOA_COLUMN(PosZ, posZ, double); +// FIT signals +DECLARE_SOA_COLUMN(Fv0signal, fv0signal, double); +DECLARE_SOA_COLUMN(Ft0asignal, ft0asignal, double); +DECLARE_SOA_COLUMN(Ft0csignal, ft0csignal, double); +DECLARE_SOA_COLUMN(Fddasignal, fddasignal, double); +DECLARE_SOA_COLUMN(Fddcsignal, fddcsignal, double); +// FIT times +DECLARE_SOA_COLUMN(TimeFv0, timeFv0, double); +DECLARE_SOA_COLUMN(TimeFt0a, timeFt0a, double); +DECLARE_SOA_COLUMN(TimeFt0c, timeFt0c, double); +DECLARE_SOA_COLUMN(TimeFdda, timeFdda, double); +DECLARE_SOA_COLUMN(TimeFddc, timeFddc, double); +// ZDC times +DECLARE_SOA_COLUMN(TimeZna, timeZna, double); +DECLARE_SOA_COLUMN(TimeZnc, timeZnc, double); +// Occupancy +DECLARE_SOA_COLUMN(Occupancy, occupancy, double); +// Atleast one pion has TOF +DECLARE_SOA_COLUMN(HasAtLeastOneTOF, hasAtLeastOneTOF, bool); +// DCA XY +DECLARE_SOA_COLUMN(Dcaxy1, dcaxy1, double); +DECLARE_SOA_COLUMN(Dcaxy2, dcaxy2, double); +DECLARE_SOA_COLUMN(Dcaxy3, dcaxy3, double); +DECLARE_SOA_COLUMN(Dcaxy4, dcaxy4, double); +// DCA Z +DECLARE_SOA_COLUMN(Dcaz1, dcaz1, double); +DECLARE_SOA_COLUMN(Dcaz2, dcaz2, double); +DECLARE_SOA_COLUMN(Dcaz3, dcaz3, double); +DECLARE_SOA_COLUMN(Dcaz4, dcaz4, double); +// TPC nSigmaPi +DECLARE_SOA_COLUMN(TpcNsigmaPi1, tpcNsigmaPi1, double); +DECLARE_SOA_COLUMN(TpcNsigmaPi2, tpcNsigmaPi2, double); +DECLARE_SOA_COLUMN(TpcNsigmaPi3, tpcNsigmaPi3, double); +DECLARE_SOA_COLUMN(TpcNsigmaPi4, tpcNsigmaPi4, double); +// TPC nSigmaKa +DECLARE_SOA_COLUMN(TpcNsigmaKa1, tpcNsigmaKa1, double); +DECLARE_SOA_COLUMN(TpcNsigmaKa2, tpcNsigmaKa2, double); +DECLARE_SOA_COLUMN(TpcNsigmaKa3, tpcNsigmaKa3, double); +DECLARE_SOA_COLUMN(TpcNsigmaKa4, tpcNsigmaKa4, double); +// TPC nSigmaPr +DECLARE_SOA_COLUMN(TpcNsigmaPr1, tpcNsigmaPr1, double); +DECLARE_SOA_COLUMN(TpcNsigmaPr2, tpcNsigmaPr2, double); +DECLARE_SOA_COLUMN(TpcNsigmaPr3, tpcNsigmaPr3, double); +DECLARE_SOA_COLUMN(TpcNsigmaPr4, tpcNsigmaPr4, double); +// TPC nSigmaEl +DECLARE_SOA_COLUMN(TpcNsigmaEl1, tpcNsigmaEl1, double); +DECLARE_SOA_COLUMN(TpcNsigmaEl2, tpcNsigmaEl2, double); +DECLARE_SOA_COLUMN(TpcNsigmaEl3, tpcNsigmaEl3, double); +DECLARE_SOA_COLUMN(TpcNsigmaEl4, tpcNsigmaEl4, double); +// TPC nSigmaMu +DECLARE_SOA_COLUMN(TpcNsigmaMu1, tpcNsigmaMu1, double); +DECLARE_SOA_COLUMN(TpcNsigmaMu2, tpcNsigmaMu2, double); +DECLARE_SOA_COLUMN(TpcNsigmaMu3, tpcNsigmaMu3, double); +DECLARE_SOA_COLUMN(TpcNsigmaMu4, tpcNsigmaMu4, double); +// TPC Chi2 +DECLARE_SOA_COLUMN(TpcChi21, tpcChi21, double); +DECLARE_SOA_COLUMN(TpcChi22, tpcChi22, double); +DECLARE_SOA_COLUMN(TpcChi23, tpcChi23, double); +DECLARE_SOA_COLUMN(TpcChi24, tpcChi24, double); +// TPC NClsFindable +DECLARE_SOA_COLUMN(TpcNClsFindable1, tpcNClsFindable1, double); +DECLARE_SOA_COLUMN(TpcNClsFindable2, tpcNClsFindable2, double); +DECLARE_SOA_COLUMN(TpcNClsFindable3, tpcNClsFindable3, double); +DECLARE_SOA_COLUMN(TpcNClsFindable4, tpcNClsFindable4, double); +// ITS Chi2 +DECLARE_SOA_COLUMN(ItsChi21, itsChi21, double); +DECLARE_SOA_COLUMN(ItsChi22, itsChi22, double); +DECLARE_SOA_COLUMN(ItsChi23, itsChi23, double); +DECLARE_SOA_COLUMN(ItsChi24, itsChi24, double); +// PionPt +DECLARE_SOA_COLUMN(PionPt1, pionPt1, double); +DECLARE_SOA_COLUMN(PionPt2, pionPt2, double); +DECLARE_SOA_COLUMN(PionPt3, pionPt3, double); +DECLARE_SOA_COLUMN(PionPt4, pionPt4, double); +// Pion Eta +DECLARE_SOA_COLUMN(PionEta1, pionEta1, double); +DECLARE_SOA_COLUMN(PionEta2, pionEta2, double); +DECLARE_SOA_COLUMN(PionEta3, pionEta3, double); +DECLARE_SOA_COLUMN(PionEta4, pionEta4, double); +// Pion Phi +DECLARE_SOA_COLUMN(PionPhi1, pionPhi1, double); +DECLARE_SOA_COLUMN(PionPhi2, pionPhi2, double); +DECLARE_SOA_COLUMN(PionPhi3, pionPhi3, double); +DECLARE_SOA_COLUMN(PionPhi4, pionPhi4, double); +// Pion Rapidity +DECLARE_SOA_COLUMN(PionRapidity1, pionRapidity1, double); +DECLARE_SOA_COLUMN(PionRapidity2, pionRapidity2, double); +DECLARE_SOA_COLUMN(PionRapidity3, pionRapidity3, double); +DECLARE_SOA_COLUMN(PionRapidity4, pionRapidity4, double); +// Four Pion Pt, Eta, Phi Rapidity +DECLARE_SOA_COLUMN(FourPionPt, fourPionPt, double); +DECLARE_SOA_COLUMN(FourPionEta, fourPionEta, double); +DECLARE_SOA_COLUMN(FourPionPhi, fourPionPhi, double); +DECLARE_SOA_COLUMN(FourPionRapidity, fourPionRapidity, double); +DECLARE_SOA_COLUMN(FourPionMass, fourPionMass, double); +// Four Pion Phi Pair 1, Pair 2, CosTheta Pair 1, CosTheta Pair 2 +DECLARE_SOA_COLUMN(FourPionPhiPair1, fourPionPhiPair1, double); +DECLARE_SOA_COLUMN(FourPionPhiPair2, fourPionPhiPair2, double); +DECLARE_SOA_COLUMN(FourPionCosThetaPair1, fourPionCosThetaPair1, double); +DECLARE_SOA_COLUMN(FourPionCosThetaPair2, fourPionCosThetaPair2, double); +} // namespace branch + +DECLARE_SOA_TABLE(SignalData, "AOD", "signalData", + branch::RunNumber, + + branch::IfCheckUPCmode, + + branch::PosX, + branch::PosY, + branch::PosZ, + + branch::Fv0signal, + branch::Ft0asignal, + branch::Ft0csignal, + branch::Fddasignal, + branch::Fddcsignal, + + branch::TimeFv0, + branch::TimeFt0a, + branch::TimeFt0c, + branch::TimeFdda, + branch::TimeFddc, + branch::TimeZna, + branch::TimeZnc, + + branch::Occupancy, + + branch::HasAtLeastOneTOF, + + branch::Dcaxy1, + branch::Dcaxy2, + branch::Dcaxy3, + branch::Dcaxy4, + + branch::Dcaz1, + branch::Dcaz2, + branch::Dcaz3, + branch::Dcaz4, + + branch::TpcNsigmaPi1, + branch::TpcNsigmaPi2, + branch::TpcNsigmaPi3, + branch::TpcNsigmaPi4, + + branch::TpcNsigmaKa1, + branch::TpcNsigmaKa2, + branch::TpcNsigmaKa3, + branch::TpcNsigmaKa4, + + branch::TpcNsigmaPr1, + branch::TpcNsigmaPr2, + branch::TpcNsigmaPr3, + branch::TpcNsigmaPr4, + + branch::TpcNsigmaEl1, + branch::TpcNsigmaEl2, + branch::TpcNsigmaEl3, + branch::TpcNsigmaEl4, + + branch::TpcNsigmaMu1, + branch::TpcNsigmaMu2, + branch::TpcNsigmaMu3, + branch::TpcNsigmaMu4, + + branch::TpcChi21, + branch::TpcChi22, + branch::TpcChi23, + branch::TpcChi24, + + branch::TpcNClsFindable1, + branch::TpcNClsFindable2, + branch::TpcNClsFindable3, + branch::TpcNClsFindable4, + + branch::ItsChi21, + branch::ItsChi22, + branch::ItsChi23, + branch::ItsChi24, + + branch::PionPt1, + branch::PionPt2, + branch::PionPt3, + branch::PionPt4, + + branch::PionEta1, + branch::PionEta2, + branch::PionEta3, + branch::PionEta4, + + branch::PionPhi1, + branch::PionPhi2, + branch::PionPhi3, + branch::PionPhi4, + + branch::PionRapidity1, + branch::PionRapidity2, + branch::PionRapidity3, + branch::PionRapidity4, + + branch::FourPionPt, + branch::FourPionEta, + branch::FourPionPhi, + branch::FourPionRapidity, + branch::FourPionMass, + branch::FourPionPhiPair1, + branch::FourPionPhiPair2, + branch::FourPionCosThetaPair1, + branch::FourPionCosThetaPair2); + +DECLARE_SOA_TABLE(BkgroundData, "AOD", "bkgroundData", + branch::RunNumber, + + branch::IfCheckUPCmode, + + branch::PosX, + branch::PosY, + branch::PosZ, + + branch::Fv0signal, + branch::Ft0asignal, + branch::Ft0csignal, + branch::Fddasignal, + branch::Fddcsignal, + + branch::TimeFv0, + branch::TimeFt0a, + branch::TimeFt0c, + branch::TimeFdda, + branch::TimeFddc, + branch::TimeZna, + branch::TimeZnc, + + branch::Occupancy, + + branch::HasAtLeastOneTOF, + + branch::Dcaxy1, + branch::Dcaxy2, + branch::Dcaxy3, + branch::Dcaxy4, + + branch::Dcaz1, + branch::Dcaz2, + branch::Dcaz3, + branch::Dcaz4, + + branch::TpcNsigmaPi1, + branch::TpcNsigmaPi2, + branch::TpcNsigmaPi3, + branch::TpcNsigmaPi4, + + branch::TpcNsigmaKa1, + branch::TpcNsigmaKa2, + branch::TpcNsigmaKa3, + branch::TpcNsigmaKa4, + + branch::TpcNsigmaPr1, + branch::TpcNsigmaPr2, + branch::TpcNsigmaPr3, + branch::TpcNsigmaPr4, + + branch::TpcNsigmaEl1, + branch::TpcNsigmaEl2, + branch::TpcNsigmaEl3, + branch::TpcNsigmaEl4, + + branch::TpcNsigmaMu1, + branch::TpcNsigmaMu2, + branch::TpcNsigmaMu3, + branch::TpcNsigmaMu4, + + branch::TpcChi21, + branch::TpcChi22, + branch::TpcChi23, + branch::TpcChi24, + + branch::TpcNClsFindable1, + branch::TpcNClsFindable2, + branch::TpcNClsFindable3, + branch::TpcNClsFindable4, + + branch::ItsChi21, + branch::ItsChi22, + branch::ItsChi23, + branch::ItsChi24, + + branch::PionPt1, + branch::PionPt2, + branch::PionPt3, + branch::PionPt4, + + branch::PionEta1, + branch::PionEta2, + branch::PionEta3, + branch::PionEta4, + + branch::PionPhi1, + branch::PionPhi2, + branch::PionPhi3, + branch::PionPhi4, + + branch::PionRapidity1, + branch::PionRapidity2, + branch::PionRapidity3, + branch::PionRapidity4, + + branch::FourPionPt, + branch::FourPionEta, + branch::FourPionPhi, + branch::FourPionRapidity, + branch::FourPionMass); +} // namespace o2::aod + +struct ExclusiveRhoTo4Pi { SGSelector sgSelector; - HistogramRegistry histos{"HistoReg", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - - //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + // Defining constants + int numFourPionTracks = 4; + int numPiPlus = 2; + int numPiMinus = 2; + float zeroPointEight = 0.8; + // Derived Data + Produces sigFromData; + Produces bkgFromData; + // Histogram Registry + HistogramRegistry histosData{"Data", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry histosCounter{"counters", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + // Configurable Event parameters + Configurable ifCheckUPCmode{"ifCheckUPCmode", false, "Enable UPC reconstruction only"}; + Configurable vZCut{"vZCut", 10., "Vertex Cut"}; Configurable fv0Cut{"fv0Cut", 50., "FV0A threshold"}; - Configurable ft0aCut{"ft0aCut", 150., "FT0A threshold"}; + Configurable ft0aCut{"ft0aCut", 50., "FT0A threshold"}; Configurable ft0cCut{"ft0cCut", 50., "FT0C threshold"}; - Configurable fddaCut{"fddaCut", 10000., "FDDA threshold"}; - Configurable fddcCut{"fddcCut", 10000., "FDDC threshold"}; - Configurable zdcCut{"zdcCut", 10., "ZDC threshold"}; - - Configurable pvCut{"pvCut", 1.0, "Use Only PV tracks"}; - Configurable dcaZcut{"dcaZcut", 3.2, "dcaZ cut"}; - Configurable dcaXYcut{"dcaXYcut", 2.4, "dcaXY cut (0 for Pt-function)"}; - Configurable tpcChi2Cut{"tpcChi2Cut", 4, "Max tpcChi2NCl"}; - Configurable tpcNClsFindableCut{"tpcNClsFindableCut", 80, "Min tpcNClsFindable"}; - Configurable itsChi2Cut{"itsChi2Cut", 36, "Max itsChi2NCl"}; + Configurable zdcCut{"zdcCut", 0., "ZDC threshold"}; + Configurable numPVContrib{"numPVContrib", 4, "Number of PV Contributors"}; + Configurable sbpCut{"sbpCut", 1, "Sbp"}; + Configurable itsROFbCut{"itsROFbCut", 1, "itsROFbCut"}; + Configurable vtxITSTPCcut{"vtxITSTPCcut", 1, "vtxITSTPCcut"}; + Configurable tfbCut{"tfbCut", 1, "tfbCut"}; + // Configurable Track parameters + Configurable useOnlyPVtracks{"useOnlyPVtracks", true, "Use Only PV tracks"}; + Configurable pTcut{"pTcut", 0.15, "Track Pt"}; Configurable etaCut{"etaCut", 0.9, "Track Pseudorapidity"}; - Configurable pTcut{"pTcut", 0, "Track Pt"}; - + Configurable dcaXYcut{"dcaXYcut", 0, "dcaXY cut"}; + Configurable dcaZcut{"dcaZcut", 2, "dcaZ cut"}; + Configurable useITStracksOnly{"useITStracksOnly", true, "only use tracks with hit in ITS"}; + Configurable useTPCtracksOnly{"useTPCtracksOnly", true, "only use tracks with hit in TPC"}; + Configurable itsChi2NClsCut{"itsChi2NClsCut", 36, "ITS Chi2NCls"}; + Configurable tpcChi2NClsCut{"tpcChi2NClsCut", 4.0, "TPC Chi2NCls"}; + Configurable tpcNClsFindableCut{"tpcNClsFindableCut", 70, "Min TPC Findable Clusters"}; + // Configurable PID parameters + Configurable useTOF{"useTOF", true, "if track has TOF use TOF"}; Configurable nSigmaTPCcut{"nSigmaTPCcut", 3, "TPC cut"}; Configurable nSigmaTOFcut{"nSigmaTOFcut", 3, "TOF cut"}; - Configurable strictEventSelection{"strictEventSelection", true, "Event Selection"}; - - Configurable nBinsPt{"nBinsPt", 1000, "Number of bins for pT"}; - Configurable nBinsInvariantMass{"nBinsInvariantMass", 1000, "Number of bins for Invariant Mass"}; - Configurable nBinsRapidity{"nBinsRapidity", 1000, "Number of bins for Rapidity"}; - Configurable nBinsPhi{"nBinsPhi", 360, "Number of bins for Phi"}; - Configurable nBinsCosTheta{"nBinsCosTheta", 360, "Number of bins for cos Theta"}; - //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + // Configurable Rho parameters + Configurable rhoRapCut{"rhoRapCut", 0.5, "Max abs Rapidity of rho"}; + Configurable rhoPtCut{"rhoPtCut", 0.15, "Min Pt of rho"}; + Configurable rhoMassMin{"rhoMassMin", 1, "Min Mass of rho"}; + Configurable rhoMassMax{"rhoMassMax", 2.5, "Max Mass of rho"}; + // Axis Configurations + ConfigurableAxis pTAxis{"pTAxis", {1000, 0, 2}, "Axis for pT histograms"}; + ConfigurableAxis etaAxis{"etaAxis", {1000, -1.1, 1.1}, "Axis for Eta histograms"}; + ConfigurableAxis rapidityAxis{"rapidityAxis", {1000, -2.5, 2.5}, "Axis for Rapidity histograms"}; + ConfigurableAxis invMassAxis{"invMassAxis", {1000, 1, 2.5}, "Axis for Phi histograms"}; + ConfigurableAxis phiAxis{"phiAxis", {360, -1 * o2::constants::math::PI, o2::constants::math::PI}, "Axis for Phi histograms"}; + ConfigurableAxis cosThetaAxis{"cosThetaAxis", {360, -1, 1}, "Axis for cos Theta histograms"}; - // Begin of Init Function----------------------------------------------------------------------------------------------------------------------------------------------------- void init(InitContext const&) { + // QA plots: Event and Track Counter + histosCounter.add("EventsCounts_vs_runNo", "Number of Selected 4-Pion Events per Run; Run Number; Number of Events", kTH2F, {{1355, 544013, 545367}, {20, 0, 20}}); + histosCounter.add("TracksCounts_vs_runNo", "Number of Selected Tracks per Run; Run Number; Number of Tracks", kTH2F, {{1355, 544013, 545367}, {20, 0, 20}}); + // QA plots: event selection + histosData.add("UPCmode", "UPC mode; Events", kTH1F, {{5, 0, 5}}); + histosData.add("FT0A", "T0A amplitude", kTH1F, {{500, 0.0, 500.0}}); + histosData.add("FT0C", "T0C amplitude", kTH1F, {{500, 0.0, 500.0}}); + histosData.add("FV0A", "V0A amplitude", kTH1F, {{100, 0.0, 100}}); + histosData.add("ZDC_A", "ZDC amplitude", kTH1F, {{1000, 0.0, 15}}); + histosData.add("ZDC_C", "ZDC amplitude", kTH1F, {{1000, 0.0, 15}}); + histosData.add("FDDA", "FDD A signal; FDD A signal; Counts", kTH1F, {{500, 0.0, 500}}); + histosData.add("FDDC", "FDD C signal; FDD C signal; Counts", kTH1F, {{500, 0.0, 500}}); + histosData.add("vertexX", "Vertex X; Vertex X [cm]; Counts", kTH1F, {{2000, -0.05, 0.05}}); + histosData.add("vertexY", "Vertex Y; Vertex Y [cm]; Counts", kTH1F, {{2000, -0.05, 0.05}}); + histosData.add("vertexZ", "Vertex Z; Vertex Z [cm]; Counts", kTH1F, {{2000, -15, 15}}); + histosData.add("GapSide", "Gap Side;Gap Side; Events", kTH1F, {{4, 0, 4}}); + histosData.add("TrueGapSide", "True Gap Side; True Gap Side; Events", kTH1F, {{4, 0, 4}}); + histosData.add("occupancy", "Occupancy; Occupancy; Counts", kTH1F, {{20000, 0, 20000}}); + // QA plots: tracks + histosData.add("dcaXY_all", "dcaXY; dcaXY [cm]; Counts", kTH1F, {{2000, -0.1, 0.1}}); + histosData.add("dcaXY_pions", "dcaXY_pions; dcaXY of Pions [cm]; Counts", kTH1F, {{2000, -0.1, 0.1}}); + histosData.add("dcaZ_all", "dcaZ; dcaZ [cm]; Counts", kTH1F, {{2000, -0.1, 0.1}}); + histosData.add("dcaZ_pions", "dcaZ_pions; dcaZ of Pions [cm]; Counts", kTH1F, {{2000, -0.1, 0.1}}); + histosData.add("itsChi2NCl_all", "ITS Chi2/NCl; Chi2/NCl; Counts", kTH1F, {{250, 0, 50}}); + histosData.add("itsChi2_all", "ITS Chi2; ITS Chi2; Counts", kTH1F, {{500, 0, 50}}); + histosData.add("tpcChi2NCl_all", "TPC Chi2/NCl; Chi2/NCl; Counts", kTH1F, {{250, 0, 50}}); + histosData.add("tpcNClsFindable_all", "TPC N Cls Findable; N Cls Findable; Counts", kTH1F, {{200, 0, 200}}); + // QA plots: PID + histosData.add("tpcSignal_all", "TPC dEdx vs p; p [GeV/c]; dEdx [a.u.]", kTH2F, {{500, 0, 10}, {5000, 0.0, 5000.0}}); + histosData.add("tpcSignal_pions", "TPC dEdx vs p for pions; p [GeV/c]; dEdx [a.u.]", kTH2F, {{500, 0, 10}, {5000, 0.0, 5000.0}}); + histosData.add("tpcNSigmaPi_all", "TPC nSigma Pion with track selection; Events", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tpcNSigmaPi_pions", "TPC nSigma Pion with track selection and PID Selection of Pi; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tpcNSigmaKa_pions", "TPC nSigma Kaon with track selection and PID Selection of Pion; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tpcNSigmaPr_pions", "TPC nSigma Proton with track selection and PID Selection of Pion; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tpcNSigmaEl_pions", "TPC nSigma Electron with track selection and PID Selection of Pion; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tpcNSigmaMu_pions", "TPC nSigma Muon with track selection and PID Selection of Pion; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tofBeta_all", "TOF beta vs p; p [GeV/c]; #beta", kTH2F, {{500, 0, 10}, {500, 0.0, 1.0}}); + histosData.add("tofBeta_pions", "TOF beta vs p for pions; p [GeV/c]; #beta", kTH2F, {{500, 0, 10}, {500, 0.0, 1.0}}); + histosData.add("tofNSigmaPi_all", "TOF nSigma Pion with track selection; Events", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tofNSigmaPi_pions", "TOF nSigma Pion with track selection and PID Selection of Pi; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tofNSigmaKa_pions", "TOF nSigma Kaon with track selection and PID Selection of Pion; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tofNSigmaPr_pions", "TOF nSigma Proton with track selection and PID Selection of Pion; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tofNSigmaEl_pions", "TOF nSigma Electron with track selection and PID Selection of Pion; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + histosData.add("tofNSigmaMu_pions", "TOF nSigma Muon with track selection and PID Selection of Pion; Entries", kTH2F, {{1000, -15, 15}, {1000, 0, 10}}); + // Track Transverse Momentum + histosData.add("pT_track_all", "pT with track selection; pT [GeV/c]; Counts", kTH1F, {pTAxis}); + histosData.add("pT_track_pions", "pT with track selection and PID selection of Pi; pT [GeV/c]; Events", kTH1F, {pTAxis}); + histosData.add("pT_track_pions_contributed", "pT with track selection and PID selection of Pi which are contributed to selected event; pT [GeV/c]; Events", kTH1F, {pTAxis}); + // Track Pseudorapidity + histosData.add("eta_track_all", "Pseudorapidity with track selection; #eta; Counts", kTH1F, {etaAxis}); + histosData.add("eta_track_pions", "Pseudorapidity with track selection and PID selection of Pi; #eta; Events", kTH1F, {etaAxis}); + histosData.add("eta_track_pions_contributed", "Pseudorapidity with track selection and PID selection of Pi which are contributed to selected event; #eta; Events", kTH1F, {etaAxis}); + // Track Phi + histosData.add("phi_track_all", "Phi with track selection; #phi [rad]; Counts", kTH1F, {phiAxis}); + histosData.add("phi_track_pions", "Phi with track selection and PID selection of Pi; #phi [rad]; Events", kTH1F, {phiAxis}); + histosData.add("phi_track_pions_contributed", "Phi with track selection and PID selection of Pi which are contributed to selected event; #phi [rad]; Events", kTH1F, {phiAxis}); + // Track Rapidity + histosData.add("rapidity_track_all", "Rapidity with track selection; y; Counts", kTH1F, {rapidityAxis}); + histosData.add("rapidity_track_pions", "Rapidity with track selection and PID selection of Pi; y; Events", kTH1F, {rapidityAxis}); + histosData.add("rapidity_track_pions_contributed", "Rapidity with track selection and PID selection of Pi which are contributed to selected event; y; Events", kTH1F, {rapidityAxis}); + // Four Pion Transverse Momentum + histosData.add("fourpion_pT_0_charge", "Event pT in 0 Charge Events With Track Selection and PID Selection of Pi; pT [GeV/c]; Events", kTH1F, {pTAxis}); + histosData.add("fourpion_pT_0_charge_within_rap", "Event pT in 0 Charge Events With Track Selection and PID Selection of Pi; pT [GeV/c]; Events", kTH1F, {pTAxis}); + histosData.add("fourpion_pT_non_0_charge", "Event pT in Non 0 Charge Events With Track Selection and PID Selection of Pi; pT [GeV/c]; Events", kTH1F, {pTAxis}); + histosData.add("fourpion_pT_non_0_charge_within_rap", "Event pT in Non 0 Charge Events With Track Selection and PID Selection of Pi; pT [GeV/c]; Events", kTH1F, {pTAxis}); + // Four Pion Eta + histosData.add("fourpion_eta_0_charge", "Four Pion #eta (0 charge); #eta; Events", kTH1F, {etaAxis}); + histosData.add("fourpion_eta_0_charge_within_rap", "Four Pion #eta (0 charge within rap); #eta; Events", kTH1F, {etaAxis}); + histosData.add("fourpion_eta_non_0_charge", "Four Pion #eta (non 0 charge); #eta; #eta; Events", kTH1F, {etaAxis}); + histosData.add("fourpion_eta_non_0_charge_within_rap", "Four Pion #eta (non 0 charge within rap); #eta; Events", kTH1F, {etaAxis}); + // Four Pion Phi + histosData.add("fourpion_phi_0_charge", "Four Pion #phi (0 charge); #phi [rad]; Events", kTH1F, {phiAxis}); + histosData.add("fourpion_phi_0_charge_within_rap", "Four Pion #phi (0 charge within rap); #phi [rad]; Events", kTH1F, {phiAxis}); + histosData.add("fourpion_phi_non_0_charge", "Four Pion #phi (non 0 charge); #phi [rad]; Events", kTH1F, {phiAxis}); + histosData.add("fourpion_phi_non_0_charge_within_rap", "Four Pion #phi (non 0 charge within rap); #phi [rad]; Events", kTH1F, {phiAxis}); + // Four Pion Rapidity + histosData.add("fourpion_rap_0_charge", "Four Pion Rapidity (0 charge); y; Events", kTH1F, {{1000, -2.5, 2.5}}); + histosData.add("fourpion_rap_0_charge_within_rap", "Four Pion Rapidity (0 charge within rap); y; Events", kTH1F, {{1000, -2.5, 2.5}}); + histosData.add("fourpion_rap_non_0_charge", "Four Pion Rapidity (non 0 charge); y; Events", kTH1F, {rapidityAxis}); + histosData.add("fourpion_rap_non_0_charge_within_rap", "Four Pion Rapidity (non 0 charge within rap); y; Events", kTH1F, {rapidityAxis}); + // Four Pion Mass + histosData.add("fourpion_mass_0_charge", "Four Pion Invariant Mass (0 charge); m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]; Events", kTH1F, {invMassAxis}); + histosData.add("fourpion_mass_0_charge_within_rap", "Four Pion Invariant Mass (0 charge within rap); m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]; Events", kTH1F, {invMassAxis}); + histosData.add("fourpion_mass_non_0_charge", "Four Pion Invariant Mass (non 0 charge); m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]; Events", kTH1F, {invMassAxis}); + histosData.add("fourpion_mass_non_0_charge_within_rap", "Four Pion Invariant Mass (non 0 charge within rap); m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]; Events", kTH1F, {invMassAxis}); + // Pair Invariant Mass + histosData.add("twopion_mass_1", "Invariant Mass Distribution of 2 pions 1 ; m(#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{5000, 0, 5}}); + histosData.add("twopion_mass_2", "Invariant Mass Distribution of 2 pions 2 ; m(#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{5000, 0, 5}}); + histosData.add("twopion_mass_3", "Invariant Mass Distribution of 2 pions 3 ; m(#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{5000, 0, 5}}); + histosData.add("twopion_mass_4", "Invariant Mass Distribution of 2 pions 4 ; m(#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{5000, 0, 5}}); + // Four Pion Invariant Mass + histosData.add("fourpion_mass_0_charge_domA", "Invariant Mass Distribution of 0 charge Events with PID Selection of Pi for p_{T} < 0.15 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {invMassAxis}); // pT < 0.15GeV + histosData.add("fourpion_mass_0_charge_domB", "Invariant Mass Distribution of 0 charge Events with PID Selection of Pi for 0.15< p_{T} < 0.80 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {invMassAxis}); // 0.15GeV < pT < 0.8GeV + histosData.add("fourpion_mass_0_charge_domC", "Invariant Mass Distribution of 0 charge Events with PID Selection of Pi for p_{T} > 0.80 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {invMassAxis}); // 0.8GeV < pT + histosData.add("fourpion_mass_non_0_charge_domA", "Invariant Mass Distribution of non 0 charge Events with PID Selection of Pi for p_{T} < 0.15 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {invMassAxis}); // pT < 0.15GeV + histosData.add("fourpion_mass_non_0_charge_domB", "Invariant Mass Distribution of non 0 charge Events with PID Selection of Pi for 0.15< p_{T} < 0.80 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {invMassAxis}); // 0.15GeV < pT < 0.8GeV + histosData.add("fourpion_mass_non_0_charge_domC", "Invariant Mass Distribution of non 0 charge Events with PID Selection of Pi for p_{T} > 0.80 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {invMassAxis}); // 0.8GeV < pT + // Collin Soper Theta and Phi + histosData.add("collin_soper_phi_1", "#phi Distribution; #phi; Events", kTH1F, {phiAxis}); + histosData.add("collin_soper_phi_2", "#phi Distribution; #phi; Events", kTH1F, {phiAxis}); + histosData.add("collin_soper_costheta_1", "#theta Distribution;cos(#theta); Counts", kTH1F, {cosThetaAxis}); + histosData.add("collin_soper_costheta_2", "#theta Distribution;cos(#theta); Counts", kTH1F, {cosThetaAxis}); + histosData.add("phi_vs_costheta_1", "Phi vs cosTheta; #phi; cos(#theta)", kTH2F, {phiAxis, cosThetaAxis}); + histosData.add("phi_vs_costheta_2", "Phi vs cosTheta; #phi; cos(#theta)", kTH2F, {phiAxis, cosThetaAxis}); + // Collin Soper Theta and Phi after selection + histosData.add("collin_soper_phi_small_mass", "#phi Distribution; #phi; Events", kTH1F, {phiAxis}); + histosData.add("collin_soper_phi_large_mass", "#phi Distribution; #phi; Events", kTH1F, {phiAxis}); + histosData.add("collin_soper_costheta_small_mass", "#theta Distribution;cos(#theta); Counts", kTH1F, {cosThetaAxis}); + histosData.add("collin_soper_costheta_large_mass", "#theta Distribution;cos(#theta); Counts", kTH1F, {cosThetaAxis}); + histosData.add("phi_vs_costheta_small_mass", "Phi vs cosTheta for small mass; #phi; cos(#theta)", kTH2F, {phiAxis, cosThetaAxis}); + histosData.add("phi_vs_costheta_large_mass", "Phi vs cosTheta for large mass; #phi; cos(#theta)", kTH2F, {phiAxis, cosThetaAxis}); + } // End of init function - histos.add("GapSide", "Gap Side; Events", kTH1F, {{4, -1.5, 2.5}}); - histos.add("TrueGapSide", "Gap Side; Events", kTH1F, {{4, -1.5, 2.5}}); - histos.add("EventCounts", "Total Events; Events", kTH1F, {{10, 0, 10}}); + //--------------------------------------------------------------------------------------------------------------------------------------------- + // Event Cuts + Filter vertexZcut = (nabs(o2::aod::collision::posZ) <= vZCut); + Filter numPVcontributorsCut = (o2::aod::collision::numContrib == numPVContrib); + Filter fitcuts = (o2::aod::udcollision::totalFV0AmplitudeA <= fv0Cut) && (o2::aod::udcollision::totalFT0AmplitudeA <= ft0aCut) && (o2::aod::udcollision::totalFT0AmplitudeC <= ft0cCut); + Filter zdcCuts = (o2::aod::udzdc::energyCommonZNA <= zdcCut) && (o2::aod::udzdc::energyCommonZNC <= zdcCut); + Filter bcSelectionCuts = (o2::aod::udcollision::sbp == sbpCut) && (o2::aod::udcollision::itsROFb == itsROFbCut) && (o2::aod::udcollision::vtxITSTPC == vtxITSTPCcut) && (o2::aod::udcollision::tfb == tfbCut); + // Track Cuts + Filter onlyPVtracks = o2::aod::udtrack::isPVContributor == useOnlyPVtracks; + //--------------------------------------------------------------------------------------------------------------------------------------------- + + using UDtracks = soa::Join; + using UDCollisions = soa::Join; + + void processData(soa::Filtered::iterator const& collision, soa::Filtered const& tracks) + { + // Check if the Event is reconstructed in UPC mode + if (ifCheckUPCmode && (collision.flags() != 1)) { + return; + } - // TPC nSigma - histos.add("tpcNSigmaPi_WOTS", "TPC nSigma Pion without track selection; Events", kTH1F, {{1000, -15, 15}}); - histos.add("tpcNSigmaPi_WTS", "TPC nSigma Pion with track selection; Events", kTH1F, {{1000, -15, 15}}); - histos.add("tpcNSigmaPi_WTS_PID_Pi", "TPC nSigma Pion with track selection and PID Selection of Pi; Entries", kTH1F, {{1000, -15, 15}}); + histosData.fill(HIST("GapSide"), collision.gapSide()); + histosData.fill(HIST("TrueGapSide"), sgSelector.trueGap(collision, fv0Cut, ft0aCut, ft0cCut, zdcCut)); + histosData.fill(HIST("vertexX"), collision.posX()); + histosData.fill(HIST("vertexY"), collision.posY()); + histosData.fill(HIST("vertexZ"), collision.posZ()); + histosData.fill(HIST("occupancy"), collision.occupancyInTime()); + histosData.fill(HIST("FV0A"), collision.totalFV0AmplitudeA()); + histosData.fill(HIST("FT0A"), collision.totalFT0AmplitudeA()); + histosData.fill(HIST("FT0C"), collision.totalFT0AmplitudeC()); + histosData.fill(HIST("ZDC_A"), collision.energyCommonZNA()); + histosData.fill(HIST("ZDC_C"), collision.energyCommonZNC()); + histosData.fill(HIST("FDDA"), collision.totalFDDAmplitudeA()); + histosData.fill(HIST("FDDC"), collision.totalFDDAmplitudeC()); + histosData.fill(HIST("UPCmode"), collision.flags()); + + std::vector selectedTracks; + std::vector selectedPionTracks; + std::vector selectedPionPlusTracks; + std::vector selectedPionMinusTracks; - // TPC nSigma of other particles with selected pion tracks - histos.add("tpcNSigmaPi_WTS_PID_Pi_Ka", "TPC nSigma Kaon with track selection and PID Selection of Pion; Entries", kTH1F, {{1000, -15, 15}}); - histos.add("tpcNSigmaPi_WTS_PID_Pi_Pr", "TPC nSigma Proton with track selection and PID Selection of Pion; Entries", kTH1F, {{1000, -15, 15}}); - histos.add("tpcNSigmaPi_WTS_PID_Pi_El", "TPC nSigma Electron with track selection and PID Selection of Pion; Entries", kTH1F, {{1000, -15, 15}}); - histos.add("tpcNSigmaPi_WTS_PID_Pi_Mu", "TPC nSigma Muon with track selection and PID Selection of Pion; Entries", kTH1F, {{1000, -15, 15}}); + for (const auto& t0 : tracks) { + if (!isSelectedTrack(t0, pTcut, etaCut, dcaXYcut, dcaZcut, useITStracksOnly, useTPCtracksOnly, itsChi2NClsCut, tpcChi2NClsCut, tpcNClsFindableCut)) { + continue; + } + selectedTracks.push_back(t0); + if (selectionPIDPion(t0, useTOF, nSigmaTPCcut, nSigmaTOFcut)) { + selectedPionTracks.push_back(t0); + if (t0.sign() == 1) { + selectedPionPlusTracks.push_back(t0); + } + if (t0.sign() == -1) { + selectedPionMinusTracks.push_back(t0); + } + } // End of Selection PID Pion + } // End of loop over tracks - // TOF nSigma - histos.add("tofNSigmaPi_WTS", "TOF nSigma Pion with track selection; Events", kTH1F, {{1000, -15, 15}}); - histos.add("tofNSigmaPi_WOTS", "TOF nSigma Pion without track selection; Events", kTH1F, {{1000, -15, 15}}); - histos.add("tofNSigmaPi_WTS_PID_Pi", "TOF nSigma Pion with track selection and PID Selection of Pi; Entries", kTH1F, {{1000, -15, 15}}); + int numSelectedTracks = static_cast(selectedTracks.size()); + int numSelectedPionTracks = static_cast(selectedPionTracks.size()); + int numPiPlusTracks = static_cast(selectedPionPlusTracks.size()); + int numPionMinusTracks = static_cast(selectedPionMinusTracks.size()); + + for (int i = 0; i < numSelectedTracks; i++) { + ROOT::Math::PxPyPzMVector selectedTrackVector(selectedTracks[i].px(), selectedTracks[i].py(), selectedTracks[i].pz(), o2::constants::physics::MassPionCharged); + histosData.fill(HIST("pT_track_all"), selectedTrackVector.Pt()); + histosData.fill(HIST("eta_track_all"), selectedTrackVector.Eta()); + histosData.fill(HIST("phi_track_all"), selectedTrackVector.Phi()); + histosData.fill(HIST("rapidity_track_all"), selectedTrackVector.Rapidity()); + + histosData.fill(HIST("dcaXY_all"), selectedTracks[i].dcaXY()); + histosData.fill(HIST("dcaZ_all"), selectedTracks[i].dcaZ()); + + histosData.fill(HIST("itsChi2NCl_all"), selectedTracks[i].itsChi2NCl()); + histosData.fill(HIST("itsChi2_all"), selectedTracks[i].itsChi2NCl() * selectedTracks[i].itsNCls()); + histosData.fill(HIST("tpcChi2NCl_all"), selectedTracks[i].tpcChi2NCl()); + histosData.fill(HIST("tpcNClsFindable_all"), selectedTracks[i].tpcNClsFindable()); + + histosData.fill(HIST("tpcSignal_all"), selectedTrackVector.P(), selectedTracks[i].tpcSignal()); + histosData.fill(HIST("tpcNSigmaPi_all"), selectedTracks[i].tpcNSigmaPi(), selectedTrackVector.Pt()); + histosData.fill(HIST("tofBeta_all"), selectedTrackVector.P(), selectedTracks[i].beta()); + histosData.fill(HIST("tofNSigmaPi_all"), selectedTracks[i].tofNSigmaPi(), selectedTrackVector.Pt()); + } // End of loop over tracks with selection only - // TOF nSigma of other particles with selected pion tracks - histos.add("tofNSigmaPi_WTS_PID_Pi_Ka", "TOF nSigma Kaon with track selection and PID Selection of Pion; Entries", kTH1F, {{1000, -15, 15}}); - histos.add("tofNSigmaPi_WTS_PID_Pi_Pr", "TOF nSigma Proton with track selection and PID Selection of Pion; Entries", kTH1F, {{1000, -15, 15}}); - histos.add("tofNSigmaPi_WTS_PID_Pi_El", "TOF nSigma Electron with track selection and PID Selection of Pion; Entries", kTH1F, {{1000, -15, 15}}); - histos.add("tofNSigmaPi_WTS_PID_Pi_Mu", "TOF nSigma Muon with track selection and PID Selection of Pion; Entries", kTH1F, {{1000, -15, 15}}); + for (int i = 0; i < numSelectedPionTracks; i++) { + ROOT::Math::PxPyPzMVector selectedPionTrackVector(selectedPionTracks[i].px(), selectedPionTracks[i].py(), selectedPionTracks[i].pz(), o2::constants::physics::MassPionCharged); + + histosData.fill(HIST("pT_track_pions"), selectedPionTrackVector.Pt()); + histosData.fill(HIST("eta_track_pions"), selectedPionTrackVector.Eta()); + histosData.fill(HIST("phi_track_pions"), selectedPionTrackVector.Phi()); + histosData.fill(HIST("rapidity_track_pions"), selectedPionTrackVector.Rapidity()); + + histosData.fill(HIST("dcaXY_pions"), selectedPionTracks[i].dcaXY()); + histosData.fill(HIST("dcaZ_pions"), selectedPionTracks[i].dcaZ()); + + histosData.fill(HIST("tpcSignal_pions"), selectedPionTrackVector.P(), selectedPionTracks[i].tpcSignal()); + histosData.fill(HIST("tpcNSigmaPi_pions"), selectedPionTracks[i].tpcNSigmaPi(), selectedPionTrackVector.Pt()); + histosData.fill(HIST("tpcNSigmaKa_pions"), selectedPionTracks[i].tpcNSigmaKa(), selectedPionTrackVector.Pt()); + histosData.fill(HIST("tpcNSigmaPr_pions"), selectedPionTracks[i].tpcNSigmaPr(), selectedPionTrackVector.Pt()); + histosData.fill(HIST("tpcNSigmaEl_pions"), selectedPionTracks[i].tpcNSigmaEl(), selectedPionTrackVector.Pt()); + histosData.fill(HIST("tpcNSigmaMu_pions"), selectedPionTracks[i].tpcNSigmaMu(), selectedPionTrackVector.Pt()); + + histosData.fill(HIST("tofBeta_pions"), selectedPionTrackVector.P(), selectedPionTracks[i].beta()); + histosData.fill(HIST("tofNSigmaPi_pions"), selectedPionTracks[i].tofNSigmaPi(), selectedPionTrackVector.Pt()); + histosData.fill(HIST("tofNSigmaKa_pions"), selectedPionTracks[i].tofNSigmaKa(), selectedPionTrackVector.Pt()); + histosData.fill(HIST("tofNSigmaPr_pions"), selectedPionTracks[i].tofNSigmaPr(), selectedPionTrackVector.Pt()); + histosData.fill(HIST("tofNSigmaEl_pions"), selectedPionTracks[i].tofNSigmaEl(), selectedPionTrackVector.Pt()); + histosData.fill(HIST("tofNSigmaMu_pions"), selectedPionTracks[i].tofNSigmaMu(), selectedPionTrackVector.Pt()); + } // End of loop over tracks with selection and PID of pions + + // event should have exactly 4 pions + if (numSelectedPionTracks != numFourPionTracks) { + return; + } - // Track Transverse Momentum - histos.add("pT_track_WOTS", "pT without track selection; pT [GeV/c]; Events", kTH1F, {{nBinsPt, 0, 2}}); - histos.add("pT_track_WTS", "pT with track selection; pT [GeV/c]; Events", kTH1F, {{nBinsPt, 0, 2}}); - histos.add("pT_track_WTS_PID_Pi", "pT with track selection and PID selection of Pi; pT [GeV/c]; Events", kTH1F, {{nBinsPt, 0, 2}}); - - // Zero charge Event Transverse Momentum - histos.add("pT_event_0charge_WTS_PID_Pi", "Event pT in 0 Charge Events With Track Selection and PID Selection of Pi; pT [GeV/c]; Counts", kTH1F, {{nBinsPt, 0, 2}}); - - // Non Zero charge Event Transverse Momentum - histos.add("pT_event_non0charge_WTS_PID_Pi", "Event pT in Non 0 Charge Events With Track Selection and PID Selection of Pi; pT [GeV/c]; Counts", kTH1F, {{nBinsPt, 0, 2}}); - - // Rapidity of 0 charge Events - histos.add("rapidity_event_0charge_WTS_PID_Pi_domainA", "Rapidity of Events With Track Selection and PID Selection of Pi for p_{T} < 0.15 GeV/c; y; Counts", kTH1F, {{1000, -2.5, 2.5}}); - histos.add("rapidity_event_0charge_WTS_PID_Pi_domainB", "Rapidity of Events With Track Selection and PID Selection of Pi for 0.15< p_{T} < 0.80 GeV/c; y; Counts", kTH1F, {{1000, -2.5, 2.5}}); - histos.add("rapidity_event_0charge_WTS_PID_Pi_domainC", "Rapidity of Events With Track Selection and PID Selection of Pi for p_{T} > 0.80 GeV/c; y; Counts", kTH1F, {{1000, -2.5, 2.5}}); - - // Rapidity of non 0 charge Events - histos.add("rapidity_event_non0charge_WTS_PID_Pi_domainA", "Rapidity of Events With Track Selection and PID Selection of Pi for p_{T} < 0.15 GeV/c; y; Counts", kTH1F, {{nBinsRapidity, -2.5, 2.5}}); - histos.add("rapidity_event_non0charge_WTS_PID_Pi_domainB", "Rapidity of Events With Track Selection and PID Selection of Pi for 0.15< p_{T} < 0.80 GeV/c$; y; Counts", kTH1F, {{nBinsRapidity, -2.5, 2.5}}); - histos.add("rapidity_event_non0charge_WTS_PID_Pi_domainC", "Rapidity of Events With Track Selection and PID Selection of Pi for p_{T} > 0.80 GeV/c; y; Counts", kTH1F, {{nBinsRapidity, -2.5, 2.5}}); - - // Invariant Mass of 0 charge events - histos.add("invMass_event_0charge_WTS_PID_Pi_domainA", "Invariant Mass Distribution of 0 charge Events with PID Selection of Pi for p_{T} < 0.15 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{nBinsInvariantMass, 0.8, 2.5}}); // pT < 0.15GeV - histos.add("invMass_event_0charge_WTS_PID_Pi_domainB", "Invariant Mass Distribution of 0 charge Events with PID Selection of Pi for 0.15< p_{T} < 0.80 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{nBinsInvariantMass, 0.8, 2.5}}); // 0.15GeV < pT < 0.8GeV - histos.add("invMass_event_0charge_WTS_PID_Pi_domainC", "Invariant Mass Distribution of 0 charge Events with PID Selection of Pi for p_{T} > 0.80 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{nBinsInvariantMass, 0.8, 2.5}}); // 0.8GeV < pT - - // Invariant mass of non 0 charge events - histos.add("invMass_event_non0charge_WTS_PID_Pi_domainA", "Invariant Mass Distribution of non 0 charge Events with PID Selection of Pi for p_{T} < 0.15 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{nBinsInvariantMass, 0.8, 2.5}}); // pT < 0.15GeV - histos.add("invMass_event_non0charge_WTS_PID_Pi_domainB", "Invariant Mass Distribution of non 0 charge Events with PID Selection of Pi for 0.15< p_{T} < 0.80 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{nBinsInvariantMass, 0.8, 2.5}}); // 0.15GeV < pT < 0.8GeV - histos.add("invMass_event_non0charge_WTS_PID_Pi_domainC", "Invariant Mass Distribution of non 0 charge Events with PID Selection of Pi for p_{T} > 0.80 GeV/c; m(#pi^{+}#pi^{-}#pi^{+}#pi^{-}) [GeV/c]", kTH1F, {{nBinsInvariantMass, 0.8, 2.5}}); // 0.8GeV < pT - - // tpc signal - histos.add("tpcSignal", "TPC dEdx vs p; p [GeV/c]; dEdx [a.u.]", kTH2F, {{500, 0, 10}, {5000, 0.0, 5000.0}}); - histos.add("tpcSignal_Pi", "TPC dEdx vs p for pions; p [GeV/c]; dEdx [a.u.]", kTH2F, {{500, 0, 10}, {5000, 0.0, 5000.0}}); - - // tof beta - histos.add("tofBeta", "TOF beta vs p; p [GeV/c]; #beta", kTH2F, {{500, 0, 10}, {500, 0.0, 1.0}}); - histos.add("tofBeta_Pi", "TOF beta vs p for pions; p [GeV/c]; #beta", kTH2F, {{500, 0, 10}, {500, 0.0, 1.0}}); - - // Other signals - histos.add("FT0A", "T0A amplitude", kTH1F, {{200, 0.0, 500.0}}); - histos.add("FT0C", "T0C amplitude", kTH1F, {{200, 0.0, 500.0}}); - histos.add("ZDC_A", "ZDC amplitude", kTH1F, {{1000, 0.0, 15}}); - histos.add("ZDC_C", "ZDC amplitude", kTH1F, {{1000, 0.0, 15}}); - histos.add("V0A", "V0A amplitude", kTH1F, {{1000, 0.0, 100}}); + // Check if there is at least one track with TOF in the selected events (for derived Data) + bool hasAtleastOneTOF = false; + for (int i = 0; i < numPiPlusTracks; i++) { + if (selectedPionPlusTracks[i].hasTOF() == true) { + hasAtleastOneTOF = true; + break; + } + } - // Collin Soper Theta and Phi - histos.add("CS_phi_pair_1", "#phi Distribution; #phi; Entries", kTH1F, {{nBinsPhi, -3.2, 3.2}}); - histos.add("CS_phi_pair_2", "#phi Distribution; #phi; Entries", kTH1F, {{nBinsPhi, -3.2, 3.2}}); - histos.add("CS_costheta_pair_1", "#theta Distribution;cos(#theta); Entries", kTH1F, {{nBinsCosTheta, -1, 1}}); - histos.add("CS_costheta_pair_2", "#theta Distribution;cos(#theta); Entries", kTH1F, {{nBinsCosTheta, -1, 1}}); + // Selecting Events with net charge = 0 + if (numPionMinusTracks == numPiMinus && numPiPlusTracks == numPiPlus) { - } // End of init function - //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + ROOT::Math::PtEtaPhiMVector k1, k2, k3, k4, k1234, k13, k14, k23, k24; + + ROOT::Math::PxPyPzMVector p1(selectedPionPlusTracks[0].px(), selectedPionPlusTracks[0].py(), selectedPionPlusTracks[0].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p2(selectedPionPlusTracks[1].px(), selectedPionPlusTracks[1].py(), selectedPionPlusTracks[1].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p3(selectedPionMinusTracks[0].px(), selectedPionMinusTracks[0].py(), selectedPionMinusTracks[0].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p4(selectedPionMinusTracks[1].px(), selectedPionMinusTracks[1].py(), selectedPionMinusTracks[1].pz(), o2::constants::physics::MassPionCharged); + + histosData.fill(HIST("pT_track_pions_contributed"), p1.Pt()); + histosData.fill(HIST("pT_track_pions_contributed"), p2.Pt()); + histosData.fill(HIST("pT_track_pions_contributed"), p3.Pt()); + histosData.fill(HIST("pT_track_pions_contributed"), p4.Pt()); - //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - // using udtracks = soa::Join; - using UDtracksfull = soa::Join; - using UDCollisionsFull = soa::Join; // - using UDCollisionFull = UDCollisionsFull::iterator; - //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + histosData.fill(HIST("eta_track_pions_contributed"), p1.Eta()); + histosData.fill(HIST("eta_track_pions_contributed"), p2.Eta()); + histosData.fill(HIST("eta_track_pions_contributed"), p3.Eta()); + histosData.fill(HIST("eta_track_pions_contributed"), p4.Eta()); + + histosData.fill(HIST("phi_track_pions_contributed"), p1.Phi()); + histosData.fill(HIST("phi_track_pions_contributed"), p2.Phi()); + histosData.fill(HIST("phi_track_pions_contributed"), p3.Phi()); + histosData.fill(HIST("phi_track_pions_contributed"), p4.Phi()); + + histosData.fill(HIST("rapidity_track_pions_contributed"), p1.Rapidity()); + histosData.fill(HIST("rapidity_track_pions_contributed"), p2.Rapidity()); + histosData.fill(HIST("rapidity_track_pions_contributed"), p3.Rapidity()); + histosData.fill(HIST("rapidity_track_pions_contributed"), p4.Rapidity()); + + k1.SetCoordinates(p1.Pt(), p1.Eta(), p1.Phi(), o2::constants::physics::MassPionCharged); + k2.SetCoordinates(p2.Pt(), p2.Eta(), p2.Phi(), o2::constants::physics::MassPionCharged); + k3.SetCoordinates(p3.Pt(), p3.Eta(), p3.Phi(), o2::constants::physics::MassPionCharged); + k4.SetCoordinates(p4.Pt(), p4.Eta(), p4.Phi(), o2::constants::physics::MassPionCharged); + + ROOT::Math::PxPyPzMVector p1234 = p1 + p2 + p3 + p4; + k1234 = k1 + k2 + k3 + k4; + + k13 = k1 + k3; + k14 = k1 + k4; + k23 = k2 + k3; + k24 = k2 + k4; + + histosData.fill(HIST("fourpion_pT_0_charge"), p1234.Pt()); + histosData.fill(HIST("fourpion_eta_0_charge"), p1234.Eta()); + histosData.fill(HIST("fourpion_phi_0_charge"), p1234.Phi()); + histosData.fill(HIST("fourpion_rap_0_charge"), p1234.Rapidity()); + histosData.fill(HIST("fourpion_mass_0_charge"), p1234.M()); + + double fourPiPhiPair1 = phiCollinsSoperFrame(k13, k24, k1234); + double fourPiPhiPair2 = phiCollinsSoperFrame(k14, k23, k1234); + double fourPiCosThetaPair1 = cosThetaCollinsSoperFrame(k13, k24, k1234); + double fourPiCosThetaPair2 = cosThetaCollinsSoperFrame(k14, k23, k1234); + + sigFromData( + // run number + collision.runNumber(), + // UPC mode + collision.flags(), + // vertex + collision.posX(), collision.posY(), collision.posZ(), + // FIT Signals + collision.totalFV0AmplitudeA(), collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), collision.totalFDDAmplitudeA(), collision.totalFDDAmplitudeC(), + // FIT and ZDC Signals + collision.timeFV0A(), collision.timeFT0A(), collision.timeFT0C(), collision.timeFDDA(), collision.timeFDDC(), collision.timeZNA(), collision.timeZNC(), + // Occupancy + collision.occupancyInTime(), + // has atleast one TOF + hasAtleastOneTOF, + // DCA XY and Z + selectedPionPlusTracks[0].dcaXY(), selectedPionPlusTracks[1].dcaXY(), selectedPionMinusTracks[0].dcaXY(), selectedPionMinusTracks[1].dcaXY(), + selectedPionPlusTracks[0].dcaZ(), selectedPionPlusTracks[1].dcaZ(), selectedPionMinusTracks[0].dcaZ(), selectedPionMinusTracks[1].dcaZ(), + // TPC N Sigma Pi + selectedPionPlusTracks[0].tpcNSigmaPi(), selectedPionPlusTracks[1].tpcNSigmaPi(), selectedPionMinusTracks[0].tpcNSigmaPi(), selectedPionMinusTracks[1].tpcNSigmaPi(), + // TPC N Sigma Ka + selectedPionPlusTracks[0].tpcNSigmaKa(), selectedPionPlusTracks[1].tpcNSigmaKa(), selectedPionMinusTracks[0].tpcNSigmaKa(), selectedPionMinusTracks[1].tpcNSigmaKa(), + // TPC N Sigma Pr + selectedPionPlusTracks[0].tpcNSigmaPr(), selectedPionPlusTracks[1].tpcNSigmaPr(), selectedPionMinusTracks[0].tpcNSigmaPr(), selectedPionMinusTracks[1].tpcNSigmaPr(), + // TPC N Sigma El + selectedPionPlusTracks[0].tpcNSigmaEl(), selectedPionPlusTracks[1].tpcNSigmaEl(), selectedPionMinusTracks[0].tpcNSigmaEl(), selectedPionMinusTracks[1].tpcNSigmaEl(), + // TPC N Sigma Mu + selectedPionPlusTracks[0].tpcNSigmaMu(), selectedPionPlusTracks[1].tpcNSigmaMu(), selectedPionMinusTracks[0].tpcNSigmaMu(), selectedPionMinusTracks[1].tpcNSigmaMu(), + // tpc Chi2 NCl + selectedPionPlusTracks[0].tpcChi2NCl(), selectedPionPlusTracks[1].tpcChi2NCl(), selectedPionMinusTracks[0].tpcChi2NCl(), selectedPionMinusTracks[1].tpcChi2NCl(), + // TPC NCls Findable + selectedPionPlusTracks[0].tpcNClsFindable(), selectedPionPlusTracks[1].tpcNClsFindable(), selectedPionMinusTracks[0].tpcNClsFindable(), selectedPionMinusTracks[1].tpcNClsFindable(), + // ITS Chi2 NCl + selectedPionPlusTracks[0].itsChi2NCl(), selectedPionPlusTracks[1].itsChi2NCl(), selectedPionMinusTracks[0].itsChi2NCl(), selectedPionMinusTracks[1].itsChi2NCl(), + // Pion Pt + p1.Pt(), p2.Pt(), p3.Pt(), p4.Pt(), + // Pion Eta + p1.Eta(), p2.Eta(), p3.Eta(), p4.Eta(), + // Pion Phi + p1.Phi(), p2.Phi(), p3.Phi(), p4.Phi(), + // Pion Rapidity + p1.Rapidity(), p2.Rapidity(), p3.Rapidity(), p4.Rapidity(), + // Four Pt + p1234.Pt(), + // Four Eta + p1234.Eta(), + // Four Phi + p1234.Phi(), + // Four Rapidity + p1234.Rapidity(), + // Four Mass + p1234.M(), + // Four Collins Soper Phi and CosTheta + fourPiPhiPair1, fourPiPhiPair2, fourPiCosThetaPair1, fourPiCosThetaPair2); + + if (std::fabs(p1234.Rapidity()) < rhoRapCut) { + histosData.fill(HIST("fourpion_pT_0_charge_within_rap"), p1234.Pt()); + histosData.fill(HIST("fourpion_eta_0_charge_within_rap"), p1234.Eta()); + histosData.fill(HIST("fourpion_phi_0_charge_within_rap"), p1234.Phi()); + histosData.fill(HIST("fourpion_rap_0_charge_within_rap"), p1234.Rapidity()); + histosData.fill(HIST("fourpion_mass_0_charge_within_rap"), p1234.M()); + if (p1234.Pt() < rhoPtCut) { + // Fill the Invariant Mass Histogram + histosData.fill(HIST("fourpion_mass_0_charge_domA"), p1234.M()); + // Two Pion Masses + histosData.fill(HIST("twopion_mass_1"), (p1 + p3).M()); + histosData.fill(HIST("twopion_mass_2"), (p1 + p4).M()); + histosData.fill(HIST("twopion_mass_3"), (p2 + p3).M()); + histosData.fill(HIST("twopion_mass_4"), (p2 + p4).M()); + // Fill the Collins-Soper Frame histograms + histosData.fill(HIST("collin_soper_phi_1"), fourPiPhiPair1); + histosData.fill(HIST("collin_soper_phi_2"), fourPiPhiPair2); + histosData.fill(HIST("collin_soper_costheta_1"), fourPiCosThetaPair1); + histosData.fill(HIST("collin_soper_costheta_2"), fourPiCosThetaPair2); + histosData.fill(HIST("phi_vs_costheta_1"), fourPiPhiPair1, fourPiCosThetaPair1); + histosData.fill(HIST("phi_vs_costheta_2"), fourPiPhiPair2, fourPiCosThetaPair2); + // Small Mass CosTheta and Phi + if ((k13.M() + k24.M()) > (k14.M() + k23.M())) { + histosData.fill(HIST("collin_soper_phi_large_mass"), fourPiPhiPair1); + histosData.fill(HIST("collin_soper_costheta_large_mass"), fourPiCosThetaPair1); + histosData.fill(HIST("phi_vs_costheta_large_mass"), fourPiPhiPair1, fourPiCosThetaPair1); + histosData.fill(HIST("collin_soper_phi_small_mass"), fourPiPhiPair2); + histosData.fill(HIST("collin_soper_costheta_small_mass"), fourPiCosThetaPair2); + histosData.fill(HIST("phi_vs_costheta_small_mass"), fourPiPhiPair2, fourPiCosThetaPair2); + } else { + histosData.fill(HIST("collin_soper_phi_small_mass"), fourPiPhiPair1); + histosData.fill(HIST("collin_soper_costheta_small_mass"), fourPiCosThetaPair1); + histosData.fill(HIST("phi_vs_costheta_small_mass"), fourPiPhiPair1, fourPiCosThetaPair1); + histosData.fill(HIST("collin_soper_phi_large_mass"), fourPiPhiPair2); + histosData.fill(HIST("collin_soper_costheta_large_mass"), fourPiCosThetaPair2); + histosData.fill(HIST("phi_vs_costheta_large_mass"), fourPiPhiPair2, fourPiCosThetaPair2); + } + } + if (p1234.Pt() > rhoPtCut && p1234.Pt() < zeroPointEight) { + histosData.fill(HIST("fourpion_mass_0_charge_domB"), p1234.M()); + } + if (p1234.Pt() > zeroPointEight) { + histosData.fill(HIST("fourpion_mass_0_charge_domC"), p1234.M()); + } + } // End of Rapidity range selection + } // End of Analysis for 0 charge events + + // Selecting Events with net charge != 0 for estimation of background + if (numPionMinusTracks != numPiMinus && numPiPlusTracks != numPiPlus) { + + ROOT::Math::PxPyPzMVector p1(selectedPionTracks[0].px(), selectedPionTracks[0].py(), selectedPionTracks[0].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p2(selectedPionTracks[1].px(), selectedPionTracks[1].py(), selectedPionTracks[1].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p3(selectedPionTracks[2].px(), selectedPionTracks[2].py(), selectedPionTracks[2].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p4(selectedPionTracks[3].px(), selectedPionTracks[3].py(), selectedPionTracks[3].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p1234 = p1 + p2 + p3 + p4; + + histosData.fill(HIST("fourpion_pT_non_0_charge"), p1234.Pt()); + histosData.fill(HIST("fourpion_eta_non_0_charge"), p1234.Eta()); + histosData.fill(HIST("fourpion_phi_non_0_charge"), p1234.Phi()); + histosData.fill(HIST("fourpion_rap_non_0_charge"), p1234.Rapidity()); + histosData.fill(HIST("fourpion_mass_non_0_charge"), p1234.M()); + + bkgFromData( + // Run Number + collision.runNumber(), + // UPC mode + collision.flags(), + // vertex + collision.posX(), collision.posY(), collision.posZ(), + // FIT Signals + collision.totalFV0AmplitudeA(), collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), collision.totalFDDAmplitudeA(), collision.totalFDDAmplitudeC(), + // FIT and ZDC Signals + collision.timeFV0A(), collision.timeFT0A(), collision.timeFT0C(), collision.timeFDDA(), collision.timeFDDC(), collision.timeZNA(), collision.timeZNC(), + // Occupancy + collision.occupancyInTime(), + // has atleast one TOF + hasAtleastOneTOF, + // DCA XY and Z + selectedPionTracks[0].dcaXY(), selectedPionTracks[1].dcaXY(), selectedPionTracks[2].dcaXY(), selectedPionTracks[3].dcaXY(), + selectedPionTracks[0].dcaZ(), selectedPionTracks[1].dcaZ(), selectedPionTracks[2].dcaZ(), selectedPionTracks[3].dcaZ(), + // TPC N Sigma Pi + selectedPionTracks[0].tpcNSigmaPi(), selectedPionTracks[1].tpcNSigmaPi(), selectedPionTracks[2].tpcNSigmaPi(), selectedPionTracks[3].tpcNSigmaPi(), + // TPC N Sigma Ka + selectedPionTracks[0].tpcNSigmaKa(), selectedPionTracks[1].tpcNSigmaKa(), selectedPionTracks[2].tpcNSigmaKa(), selectedPionTracks[3].tpcNSigmaKa(), + // TPC N Sigma Pr + selectedPionTracks[0].tpcNSigmaPr(), selectedPionTracks[1].tpcNSigmaPr(), selectedPionTracks[2].tpcNSigmaPr(), selectedPionTracks[3].tpcNSigmaPr(), + // TPC N Sigma El + selectedPionTracks[0].tpcNSigmaEl(), selectedPionTracks[1].tpcNSigmaEl(), selectedPionTracks[2].tpcNSigmaEl(), selectedPionTracks[3].tpcNSigmaEl(), + // TPC N Sigma Mu + selectedPionTracks[0].tpcNSigmaMu(), selectedPionTracks[1].tpcNSigmaMu(), selectedPionTracks[2].tpcNSigmaMu(), selectedPionTracks[3].tpcNSigmaMu(), + // tpc Chi2 NCl + selectedPionTracks[0].tpcChi2NCl(), selectedPionTracks[1].tpcChi2NCl(), selectedPionTracks[2].tpcChi2NCl(), selectedPionTracks[3].tpcChi2NCl(), + // TPC NCls Findable + selectedPionTracks[0].tpcNClsFindable(), selectedPionTracks[1].tpcNClsFindable(), selectedPionTracks[2].tpcNClsFindable(), selectedPionTracks[3].tpcNClsFindable(), + // ITS Chi2 NCl + selectedPionTracks[0].itsChi2NCl(), selectedPionTracks[1].itsChi2NCl(), selectedPionTracks[2].itsChi2NCl(), selectedPionTracks[3].itsChi2NCl(), + // Pion Pt + p1.Pt(), p2.Pt(), p3.Pt(), p4.Pt(), + // Pion Eta + p1.Eta(), p2.Eta(), p3.Eta(), p4.Eta(), + // Pion Phi + p1.Phi(), p2.Phi(), p3.Phi(), p4.Phi(), + // Pion Rapidity + p1.Rapidity(), p2.Rapidity(), p3.Rapidity(), p4.Rapidity(), + // Four Pt + p1234.Pt(), + // Four Eta + p1234.Eta(), + // Four Phi + p1234.Phi(), + // Four Rapidity + p1234.Rapidity(), + // Four Mass + p1234.M()); + + if (std::fabs(p1234.Rapidity()) < rhoRapCut) { + histosData.fill(HIST("fourpion_pT_non_0_charge_within_rap"), p1234.Pt()); + histosData.fill(HIST("fourpion_eta_non_0_charge_within_rap"), p1234.Eta()); + histosData.fill(HIST("fourpion_phi_non_0_charge_within_rap"), p1234.Phi()); + histosData.fill(HIST("fourpion_rap_non_0_charge_within_rap"), p1234.Rapidity()); + histosData.fill(HIST("fourpion_mass_non_0_charge_within_rap"), p1234.M()); + if (p1234.Pt() < rhoPtCut) { + histosData.fill(HIST("fourpion_mass_non_0_charge_domA"), p1234.M()); + } + if (p1234.Pt() > rhoPtCut && p1234.Pt() < zeroPointEight) { + histosData.fill(HIST("fourpion_mass_non_0_charge_domB"), p1234.M()); + } + if (p1234.Pt() > zeroPointEight) { + histosData.fill(HIST("fourpion_mass_non_0_charge_domC"), p1234.M()); + } + } // End of Rapidity range selection + } // End of Analysis for non 0 charge events + } // End of 4 Pion Analysis Process function for Pass5 Data + + void processEventCounter(UDCollisions::iterator const& collision, soa::Filtered const& tracks) + { + + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 0); + + // UPC mode + if (ifCheckUPCmode && collision.flags() != 1) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 1); + + // vtxITSTPC + if (collision.vtxITSTPC() != vtxITSTPCcut) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 2); + + // sbp + if (collision.sbp() != sbpCut) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 3); + + // itsROFb + if (collision.itsROFb() != itsROFbCut) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 4); + + // tfb + if (collision.tfb() != tfbCut) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 5); + + // FT0A + if (collision.totalFT0AmplitudeA() > ft0aCut) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 6); + // FT0C + if (collision.totalFT0AmplitudeC() > ft0cCut) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 7); + // FV0A + if (collision.totalFV0AmplitudeA() > fv0Cut) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 8); + + // ZDC + if (collision.energyCommonZNA() > zdcCut || collision.energyCommonZNC() > zdcCut) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 9); + + // numContributors + if (collision.numContrib() != numPVContrib) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 10); + + // vertexZ + if (std::abs(collision.posZ()) > vZCut) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 11); + + std::vector selectedPionTracks; + std::vector selectedPionPlusTracks; + std::vector selectedPionMinusTracks; + + for (const auto& t0 : tracks) { + if (!isSelectedTrack(t0, pTcut, etaCut, dcaXYcut, dcaZcut, useITStracksOnly, useTPCtracksOnly, itsChi2NClsCut, tpcChi2NClsCut, tpcNClsFindableCut)) { + continue; + } + if (selectionPIDPion(t0, useTOF, nSigmaTPCcut, nSigmaTOFcut)) { + selectedPionTracks.push_back(t0); + if (t0.sign() == 1) { + selectedPionPlusTracks.push_back(t0); + } + if (t0.sign() == -1) { + selectedPionMinusTracks.push_back(t0); + } + } // End of Selection PID Pion + } // End of loop over tracks + + int numSelectedPionTracks = static_cast(selectedPionTracks.size()); + int numPiPlusTracks = static_cast(selectedPionPlusTracks.size()); + int numPionMinusTracks = static_cast(selectedPionMinusTracks.size()); + // Events with 4 pions + if (numSelectedPionTracks != numFourPionTracks) { + return; + } + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 12); + + // Selecting Events with net charge = 0 + if (numPionMinusTracks == numPiMinus && numPiPlusTracks == numPiPlus) { + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 13); + ROOT::Math::PxPyPzMVector p1(selectedPionPlusTracks[0].px(), selectedPionPlusTracks[0].py(), selectedPionPlusTracks[0].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p2(selectedPionPlusTracks[1].px(), selectedPionPlusTracks[1].py(), selectedPionPlusTracks[1].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p3(selectedPionMinusTracks[0].px(), selectedPionMinusTracks[0].py(), selectedPionMinusTracks[0].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p4(selectedPionMinusTracks[1].px(), selectedPionMinusTracks[1].py(), selectedPionMinusTracks[1].pz(), o2::constants::physics::MassPionCharged); + ROOT::Math::PxPyPzMVector p1234 = p1 + p2 + p3 + p4; + + if ((p1234.Pt() < rhoPtCut) && (std::abs(p1234.Rapidity()) < rhoRapCut)) { + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 14); + if ((rhoMassMin < p1234.M()) && (p1234.M() < rhoMassMax)) { + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 15); + } + } + } // End of Zero Charge Events + + if (numPionMinusTracks != numPiMinus && numPiPlusTracks != numPiPlus) { + histosCounter.fill(HIST("EventsCounts_vs_runNo"), collision.runNumber(), 16); + } // End of Non Zero Charge Events + + } // End of processCounter function + + void processTrackCounter(soa::Filtered::iterator const& collision, UDtracks const& tracks) + { + // Check if the Event is reconstructed in UPC mode + if (ifCheckUPCmode && (collision.flags() != 1)) { + return; + } + for (const auto& track : tracks) { + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 0); + ROOT::Math::PxPyPzMVector trackVector(track.px(), track.py(), track.pz(), o2::constants::physics::MassPionCharged); + // is PV contributor + if (track.isPVContributor() != useOnlyPVtracks) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 1); + // pt cut + if (trackVector.Pt() < pTcut) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 2); + // eta cut + if (std::abs(trackVector.Eta()) > etaCut) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 3); + // DCA Z cut + if (std::abs(track.dcaZ()) > dcaZcut) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 4); + // DCA XY cut + float maxDCAxy = 0.0105 + 0.035 / std::pow(trackVector.Pt(), 1.1); + if (dcaXYcut == 0 && (std::fabs(track.dcaXY()) > maxDCAxy)) { + continue; + } else if (dcaXYcut != 0 && (std::fabs(track.dcaXY()) > dcaXYcut)) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 5); + // ITS Track only + if (useITStracksOnly && !track.hasITS()) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 6); + // TPC Track only + if (useTPCtracksOnly && !track.hasTPC()) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 7); + // ITS Chi2 N Clusters cut + if (track.hasITS() && track.itsChi2NCl() > itsChi2NClsCut) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 8); + // TPC Chi2 N Clusters cut + if (track.hasTPC() && track.tpcChi2NCl() > tpcChi2NClsCut) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 9); + // TPC N Clusters Findable cut + if (track.hasTPC() && track.tpcNClsFindable() < tpcNClsFindableCut) { + continue; + } + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 10); + // Selection PID Pion + if (selectionPIDPion(track, useTOF, nSigmaTPCcut, nSigmaTOFcut)) { + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 11); + if (track.sign() == 1) { + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 12); + } + if (track.sign() == -1) { + histosCounter.fill(HIST("TracksCounts_vs_runNo"), collision.runNumber(), 13); + } + } // End of Selection PID Pion + } // End of loop over tracks + } // End of processCounter function + + PROCESS_SWITCH(ExclusiveRhoTo4Pi, processData, "Data Analysis Function", true); + PROCESS_SWITCH(ExclusiveRhoTo4Pi, processEventCounter, "Event Counter Function", true); + PROCESS_SWITCH(ExclusiveRhoTo4Pi, processTrackCounter, "Track Counter Function", true); - // Calculate the Collins-Soper Frame---------------------------------------------------------------------------------------------------------------------------- double cosThetaCollinsSoperFrame(ROOT::Math::PtEtaPhiMVector pair1, ROOT::Math::PtEtaPhiMVector pair2, ROOT::Math::PtEtaPhiMVector fourpion) { double halfSqrtSnn = 2680.; double massOfLead208 = 193.6823; double momentumBeam = std::sqrt(halfSqrtSnn * halfSqrtSnn * 208 * 208 - massOfLead208 * massOfLead208); - - TLorentzVector pProjCM(0., 0., -momentumBeam, halfSqrtSnn * 208); // projectile - TLorentzVector pTargCM(0., 0., momentumBeam, halfSqrtSnn * 208); // target - - // TVector3 beta = (-1. / fourpion.E()) * fourpion.Vect(); + ROOT::Math::PxPyPzEVector pProjCM(0., 0., -momentumBeam, halfSqrtSnn * 208); // projectile + ROOT::Math::PxPyPzEVector pTargCM(0., 0., momentumBeam, halfSqrtSnn * 208); // target ROOT::Math::PtEtaPhiMVector v1 = pair1; ROOT::Math::PtEtaPhiMVector v2 = pair2; ROOT::Math::PtEtaPhiMVector v12 = fourpion; - // Boost to center of mass frame ROOT::Math::Boost boostv12{v12.BoostToCM()}; ROOT::Math::XYZVectorF v1CM{(boostv12(v1).Vect()).Unit()}; ROOT::Math::XYZVectorF v2CM{(boostv12(v2).Vect()).Unit()}; ROOT::Math::XYZVectorF beam1CM{(boostv12(pProjCM).Vect()).Unit()}; ROOT::Math::XYZVectorF beam2CM{(boostv12(pTargCM).Vect()).Unit()}; - // Axes ROOT::Math::XYZVectorF zaxisCS{((beam1CM.Unit() - beam2CM.Unit()).Unit())}; - double cosThetaCS = zaxisCS.Dot((v1CM)); return cosThetaCS; - } // End of cosThetaCollinsSoperFrame function------------------------------------------------------------------------------------------------------------------------ + } - // Calculate Phi in Collins-Soper Frame------------------------------------------------------------------------------------------------------------------------ double phiCollinsSoperFrame(ROOT::Math::PtEtaPhiMVector pair1, ROOT::Math::PtEtaPhiMVector pair2, ROOT::Math::PtEtaPhiMVector fourpion) { // Half of the energy per pair of the colliding nucleons. double halfSqrtSnn = 2680.; double massOfLead208 = 193.6823; double momentumBeam = std::sqrt(halfSqrtSnn * halfSqrtSnn * 208 * 208 - massOfLead208 * massOfLead208); - - TLorentzVector pProjCM(0., 0., -momentumBeam, halfSqrtSnn * 208); // projectile - TLorentzVector pTargCM(0., 0., momentumBeam, halfSqrtSnn * 208); // target + ROOT::Math::PxPyPzEVector pProjCM(0., 0., -momentumBeam, halfSqrtSnn * 208); // projectile + ROOT::Math::PxPyPzEVector pTargCM(0., 0., momentumBeam, halfSqrtSnn * 208); // target ROOT::Math::PtEtaPhiMVector v1 = pair1; ROOT::Math::PtEtaPhiMVector v2 = pair2; ROOT::Math::PtEtaPhiMVector v12 = fourpion; @@ -218,203 +1148,68 @@ struct exclusiveRhoTo4Pi { // o2-linter: disable=name/workflow-file,name/struct double phi = std::atan2(yaxisCS.Dot(v1CM), xaxisCS.Dot(v1CM)); return phi; - } // End of phiCollinsSoperFrame function------------------------------------------------------------------------------------------------------------------------ - - // Begin of Process function-------------------------------------------------------------------------------------------------------------------------------------------------- - void process(UDCollisionFull const& collision, UDtracksfull const& tracks) + } + + template + bool isSelectedTrack(T const& track, + float ptcut, + float etaCut, + float dcaxycut, + float dcazcut, + bool ifITS, + bool ifTPC, + float itschi2nclscut, + float tpcchi2nclscut, + float tpcnclsfindablecut) { - - int gapSide = collision.gapSide(); - float fitCuts[5] = {fv0Cut, ft0aCut, ft0cCut, fddaCut, fddcCut}; - std::vector parameters = {pvCut, dcaZcut, dcaXYcut, tpcChi2Cut, tpcNClsFindableCut, itsChi2Cut, etaCut, pTcut}; - int truegapSide = sgSelector.trueGap(collision, fitCuts[0], fitCuts[1], fitCuts[2], zdcCut); - histos.fill(HIST("GapSide"), gapSide); - histos.fill(HIST("TrueGapSide"), truegapSide); - histos.fill(HIST("EventCounts"), 1); - gapSide = truegapSide; - - if ((gapSide != 2)) { - return; + ROOT::Math::PxPyPzMVector trackVector(track.px(), track.py(), track.pz(), o2::constants::physics::MassPionCharged); + // pt cut + if (trackVector.Pt() < ptcut) { + return false; } - - histos.fill(HIST("V0A"), collision.totalFV0AmplitudeA()); - histos.fill(HIST("FT0A"), collision.totalFT0AmplitudeA()); - histos.fill(HIST("FT0C"), collision.totalFT0AmplitudeC()); - histos.fill(HIST("ZDC_A"), collision.energyCommonZNA()); - histos.fill(HIST("ZDC_C"), collision.energyCommonZNC()); - - if (strictEventSelection) { - if (collision.numContrib() != 4) { - return; - } - } else { - if (collision.numContrib() >= 10) { - return; - } + // eta cut + if (std::fabs(trackVector.Eta()) > etaCut) { + return false; } - - std::vector WOTS_tracks; - std::vector WTS_tracks; - std::vector WTS_PID_Pi_tracks; - std::vector Pi_plus_tracks; - std::vector Pi_minus_tracks; - - for (const auto& t0 : tracks) { - - WOTS_tracks.push_back(t0); - - if (trackselector(t0, parameters)) { - WTS_tracks.push_back(t0); - - if (selectionPIDPion(t0, true, nSigmaTPCcut, nSigmaTOFcut)) { - WTS_PID_Pi_tracks.push_back(t0); - if (t0.sign() == 1) { - Pi_plus_tracks.push_back(t0); - } - if (t0.sign() == -1) { - Pi_minus_tracks.push_back(t0); - } - } // End of Selection PID Pion - - } // End of track selections - - } // End of loop over tracks - - int numTracksWOTS = static_cast(WOTS_tracks.size()); - int numTracksWTS = static_cast(WTS_tracks.size()); - int numTracksWTSandPIDpi = static_cast(WTS_PID_Pi_tracks.size()); - int numPiPlusTracks = static_cast(Pi_plus_tracks.size()); - int numPionMinusTRacks = static_cast(Pi_minus_tracks.size()); - - for (int i = 0; i < numTracksWOTS; i++) { - histos.fill(HIST("tpcNSigmaPi_WOTS"), WOTS_tracks[i].tpcNSigmaPi()); - histos.fill(HIST("tofNSigmaPi_WOTS"), WOTS_tracks[i].tofNSigmaPi()); - histos.fill(HIST("pT_track_WOTS"), std::sqrt(WOTS_tracks[i].px() * WOTS_tracks[i].px() + WOTS_tracks[i].py() * WOTS_tracks[i].py())); - } // End of loop over tracks without selection - - for (int i = 0; i < numTracksWTS; i++) { - - histos.fill(HIST("tpcSignal"), std::sqrt(WTS_tracks[i].px() * WTS_tracks[i].px() + WTS_tracks[i].py() * WTS_tracks[i].py() + WTS_tracks[i].pz() * WTS_tracks[i].pz()), WTS_tracks[i].tpcSignal()); - histos.fill(HIST("tofBeta"), std::sqrt(WTS_tracks[i].px() * WTS_tracks[i].px() + WTS_tracks[i].py() * WTS_tracks[i].py() + WTS_tracks[i].pz() * WTS_tracks[i].pz()), WTS_tracks[i].beta()); - histos.fill(HIST("tpcNSigmaPi_WTS"), WTS_tracks[i].tpcNSigmaPi()); - histos.fill(HIST("tofNSigmaPi_WTS"), WTS_tracks[i].tofNSigmaPi()); - histos.fill(HIST("pT_track_WTS"), std::sqrt(WTS_tracks[i].px() * WTS_tracks[i].px() + WTS_tracks[i].py() * WTS_tracks[i].py())); - } // End of loop over tracks with selection only - - for (int i = 0; i < numTracksWTSandPIDpi; i++) { - - histos.fill(HIST("tpcSignal_Pi"), std::sqrt(WTS_PID_Pi_tracks[i].px() * WTS_PID_Pi_tracks[i].px() + WTS_PID_Pi_tracks[i].py() * WTS_PID_Pi_tracks[i].py() + WTS_PID_Pi_tracks[i].pz() * WTS_PID_Pi_tracks[i].pz()), WTS_PID_Pi_tracks[i].tpcSignal()); - histos.fill(HIST("tofBeta_Pi"), std::sqrt(WTS_PID_Pi_tracks[i].px() * WTS_PID_Pi_tracks[i].px() + WTS_PID_Pi_tracks[i].py() * WTS_PID_Pi_tracks[i].py() + WTS_PID_Pi_tracks[i].pz() * WTS_PID_Pi_tracks[i].pz()), WTS_PID_Pi_tracks[i].beta()); - - histos.fill(HIST("tpcNSigmaPi_WTS_PID_Pi"), WTS_PID_Pi_tracks[i].tpcNSigmaPi()); - histos.fill(HIST("tpcNSigmaPi_WTS_PID_Pi_Ka"), WTS_PID_Pi_tracks[i].tpcNSigmaKa()); - histos.fill(HIST("tpcNSigmaPi_WTS_PID_Pi_Pr"), WTS_PID_Pi_tracks[i].tpcNSigmaPr()); - histos.fill(HIST("tpcNSigmaPi_WTS_PID_Pi_El"), WTS_PID_Pi_tracks[i].tpcNSigmaEl()); - histos.fill(HIST("tpcNSigmaPi_WTS_PID_Pi_Mu"), WTS_PID_Pi_tracks[i].tpcNSigmaMu()); - - histos.fill(HIST("tofNSigmaPi_WTS_PID_Pi"), WTS_PID_Pi_tracks[i].tofNSigmaPi()); - histos.fill(HIST("tofNSigmaPi_WTS_PID_Pi_Ka"), WTS_PID_Pi_tracks[i].tofNSigmaKa()); - histos.fill(HIST("tofNSigmaPi_WTS_PID_Pi_Pr"), WTS_PID_Pi_tracks[i].tofNSigmaPr()); - histos.fill(HIST("tofNSigmaPi_WTS_PID_Pi_El"), WTS_PID_Pi_tracks[i].tofNSigmaEl()); - histos.fill(HIST("tofNSigmaPi_WTS_PID_Pi_Mu"), WTS_PID_Pi_tracks[i].tofNSigmaMu()); - - histos.fill(HIST("pT_track_WTS_PID_Pi"), std::sqrt(WTS_PID_Pi_tracks[i].px() * WTS_PID_Pi_tracks[i].px() + WTS_PID_Pi_tracks[i].py() * WTS_PID_Pi_tracks[i].py())); - } // End of loop over tracks with selection and PID selection of Pions - - if (numTracksWTSandPIDpi != 4) { - return; + // DCA Z cut + if (std::fabs(track.dcaZ()) > dcazcut) { + return false; } + // DCA XY cut + float maxDCAxy = 0.0105 + 0.035 / std::pow(trackVector.Pt(), 1.1); + if (dcaxycut == 0 && (std::fabs(track.dcaXY()) > maxDCAxy)) { + return false; + } else if (dcaxycut != 0 && (std::fabs(track.dcaXY()) > dcaxycut)) { + return false; + } + // ITS Track only + if (ifITS && !track.hasITS()) { + return false; + } + // TPC Track only + if (ifTPC && !track.hasTPC()) { + return false; + } + // ITS Chi2 N Clusters cut + if (track.hasITS() && track.itsChi2NCl() > itschi2nclscut) { + return false; + } + // TPC Chi2 N Clusters cut + if (track.hasTPC() && track.tpcChi2NCl() > tpcchi2nclscut) { + return false; + } + // TPC N Clusters Findable cut + if (track.hasTPC() && track.tpcNClsFindable() < tpcnclsfindablecut) { + return false; + } + // All cuts passed + return true; + } // End of Track Selection function - // Selecting Events with net charge = 0 - if (numPionMinusTRacks == 2 && numPiPlusTracks == 2) { - - TLorentzVector p1, p2, p3, p4, p1234; - ROOT::Math::PtEtaPhiMVector k1, k2, k3, k4, k1234, k13, k14, k23, k24; - - p1.SetXYZM(Pi_plus_tracks[0].px(), Pi_plus_tracks[0].py(), Pi_plus_tracks[0].pz(), o2::constants::physics::MassPionCharged); - p2.SetXYZM(Pi_plus_tracks[1].px(), Pi_plus_tracks[1].py(), Pi_plus_tracks[1].pz(), o2::constants::physics::MassPionCharged); - p3.SetXYZM(Pi_minus_tracks[0].px(), Pi_minus_tracks[0].py(), Pi_minus_tracks[0].pz(), o2::constants::physics::MassPionCharged); - p4.SetXYZM(Pi_minus_tracks[1].px(), Pi_minus_tracks[1].py(), Pi_minus_tracks[1].pz(), o2::constants::physics::MassPionCharged); - - k1.SetCoordinates(p1.Pt(), p1.Eta(), p1.Phi(), o2::constants::physics::MassPionCharged); - k2.SetCoordinates(p2.Pt(), p2.Eta(), p2.Phi(), o2::constants::physics::MassPionCharged); - k3.SetCoordinates(p3.Pt(), p3.Eta(), p3.Phi(), o2::constants::physics::MassPionCharged); - k4.SetCoordinates(p4.Pt(), p4.Eta(), p4.Phi(), o2::constants::physics::MassPionCharged); - - p1234 = p1 + p2 + p3 + p4; - k1234 = k1 + k2 + k3 + k4; - - k13 = k1 + k3; - k14 = k1 + k4; - k23 = k2 + k3; - k24 = k2 + k4; - - if (std::fabs(p1234.Rapidity()) < 0.5) { - histos.fill(HIST("pT_event_0charge_WTS_PID_Pi"), p1234.Pt()); - if (p1234.Pt() < 0.15) { - histos.fill(HIST("rapidity_event_0charge_WTS_PID_Pi_domainA"), p1234.Rapidity()); - histos.fill(HIST("invMass_event_0charge_WTS_PID_Pi_domainA"), p1234.M()); - - auto phiPair1 = phiCollinsSoperFrame(k13, k24, k1234); - auto phiPair2 = phiCollinsSoperFrame(k14, k23, k1234); - auto cosThetaPair1 = cosThetaCollinsSoperFrame(k13, k24, k1234); - auto cosThetaPair2 = cosThetaCollinsSoperFrame(k14, k23, k1234); - - histos.fill(HIST("CS_phi_pair_1"), phiPair1); - histos.fill(HIST("CS_phi_pair_2"), phiPair2); - histos.fill(HIST("CS_costheta_pair_1"), cosThetaPair1); - histos.fill(HIST("CS_costheta_pair_2"), cosThetaPair2); - } - if (p1234.Pt() > 0.15 && p1234.Pt() < 0.80) { - histos.fill(HIST("rapidity_event_0charge_WTS_PID_Pi_domainB"), p1234.Rapidity()); - histos.fill(HIST("invMass_event_0charge_WTS_PID_Pi_domainB"), p1234.M()); - } - if (p1234.Pt() > 0.80) { - histos.fill(HIST("rapidity_event_0charge_WTS_PID_Pi_domainC"), p1234.Rapidity()); - histos.fill(HIST("invMass_event_0charge_WTS_PID_Pi_domainC"), p1234.M()); - } - } // End of Rapidity range selection - - } // End of Analysis for 0 charge events - - // Selecting Events with net charge != 0 for estimation of background - if (numPionMinusTRacks != 2 && numPiPlusTracks != 2) { - - TLorentzVector p1, p2, p3, p4, p1234; - p1.SetXYZM(WTS_PID_Pi_tracks[0].px(), WTS_PID_Pi_tracks[0].py(), WTS_PID_Pi_tracks[0].pz(), o2::constants::physics::MassPionCharged); - p2.SetXYZM(WTS_PID_Pi_tracks[1].px(), WTS_PID_Pi_tracks[1].py(), WTS_PID_Pi_tracks[1].pz(), o2::constants::physics::MassPionCharged); - p3.SetXYZM(WTS_PID_Pi_tracks[2].px(), WTS_PID_Pi_tracks[2].py(), WTS_PID_Pi_tracks[2].pz(), o2::constants::physics::MassPionCharged); - p4.SetXYZM(WTS_PID_Pi_tracks[3].px(), WTS_PID_Pi_tracks[3].py(), WTS_PID_Pi_tracks[3].pz(), o2::constants::physics::MassPionCharged); - - p1234 = p1 + p2 + p3 + p4; - - if (std::fabs(p1234.Rapidity()) < 0.5) { - histos.fill(HIST("pT_event_non0charge_WTS_PID_Pi"), p1234.Pt()); - - if (p1234.Pt() < 0.15) { - histos.fill(HIST("rapidity_event_non0charge_WTS_PID_Pi_domainA"), p1234.Rapidity()); - histos.fill(HIST("invMass_event_non0charge_WTS_PID_Pi_domainA"), p1234.M()); - } - if (p1234.Pt() > 0.15 && p1234.Pt() < 0.80) { - histos.fill(HIST("rapidity_event_non0charge_WTS_PID_Pi_domainB"), p1234.Rapidity()); - histos.fill(HIST("invMass_event_non0charge_WTS_PID_Pi_domainB"), p1234.M()); - } - if (p1234.Pt() > 0.80) { - histos.fill(HIST("rapidity_event_non0charge_WTS_PID_Pi_domainC"), p1234.Rapidity()); - histos.fill(HIST("invMass_event_non0charge_WTS_PID_Pi_domainC"), p1234.M()); - } - } // End of Rapidity range selection - - } // End of Analysis for non 0 charge events - - } // End of process function - //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -}; // End of Struct UPCAnalysis -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +}; // End of Struct exclusiveRhoTo4Pi WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGUD/Tasks/exclusiveTwoProtons.cxx b/PWGUD/Tasks/exclusiveTwoProtons.cxx index 72032b06906..b7cf9b84004 100644 --- a/PWGUD/Tasks/exclusiveTwoProtons.cxx +++ b/PWGUD/Tasks/exclusiveTwoProtons.cxx @@ -11,7 +11,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include "TLorentzVector.h" diff --git a/PWGUD/Tasks/exclusiveTwoProtonsSG.cxx b/PWGUD/Tasks/exclusiveTwoProtonsSG.cxx index 0e0aa7c83dd..0ac54805c69 100644 --- a/PWGUD/Tasks/exclusiveTwoProtonsSG.cxx +++ b/PWGUD/Tasks/exclusiveTwoProtonsSG.cxx @@ -11,7 +11,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include "TLorentzVector.h" diff --git a/PWGUD/Tasks/flowCorrelationsUpc.cxx b/PWGUD/Tasks/flowCorrelationsUpc.cxx new file mode 100644 index 00000000000..baf24af6f94 --- /dev/null +++ b/PWGUD/Tasks/flowCorrelationsUpc.cxx @@ -0,0 +1,291 @@ +// 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. + +/// \file flowCorrelationsUpc.cxx +/// \brief Provides a sparse with usefull two particle correlation info +/// \author Mingrui Zhao (mingrui.zhao@cern.ch, mingrui.zhao@mail.labz0.org) +/// copied from Thor Jensen (thor.kjaersgaard.jensen@cern.ch) and Debojit Sarkar (debojit.sarkar@cern.ch) + +#include "PWGCF/Core/CorrelationContainer.h" +#include "PWGCF/Core/PairCuts.h" +#include "PWGCF/DataModel/CorrelationsDerived.h" +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/DataModel/UDTables.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/MathConstants.h" +#include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/runDataProcessing.h" + +#include "TRandom3.h" + +#include + +namespace o2::aod +{ +namespace flowcorrupc +{ +DECLARE_SOA_COLUMN(Multiplicity, multiplicity, int); +} +DECLARE_SOA_TABLE(Multiplicity, "AOD", "MULTIPLICITY", + flowcorrupc::Multiplicity); + +} // namespace o2::aod + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// define the filtered collisions and tracks +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +struct CalcNchUpc { + O2_DEFINE_CONFIGURABLE(cfgZVtxCut, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgPtCutMin, float, 0.2f, "minimum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgPtCutMax, float, 10.0f, "maximum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgEtaCut, float, 0.8f, "Eta cut") + O2_DEFINE_CONFIGURABLE(cfgMinMixEventNum, int, 5, "Minimum number of events to mix") + + // Filter trackFilter = (nabs(aod::track::eta) < cfgEtaCut) && (aod::track::pt > cfgPtCutMin) && (aod::track::pt < cfgPtCutMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)); + + using UdTracks = soa::Join; + using UdTracksFull = soa::Join; + using UDCollisionsFull = soa::Join; + + Produces multiplicityNch; + + HistogramRegistry registry{"registry"}; + + void init(InitContext&) + { + AxisSpec axisNch = {100, 0, 100}; + AxisSpec axisVrtx = {10, -10, 10}; + + registry.add("Ncharge", "N_{charge}", {HistType::kTH1D, {axisNch}}); + registry.add("zVtx_all", "zVtx_all", {HistType::kTH1D, {axisVrtx}}); + } + + void process(UDCollisionsFull::iterator const& collision, UdTracksFull const& tracks) + { + multiplicityNch(tracks.size()); + registry.fill(HIST("Ncharge"), tracks.size()); + registry.fill(HIST("zVtx_all"), collision.posZ()); + } +}; + +struct FlowCorrelationsUpc { + O2_DEFINE_CONFIGURABLE(cfgZVtxCut, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgPtCutMin, float, 0.2f, "minimum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgPtCutMax, float, 10.0f, "maximum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgEtaCut, float, 0.8f, "Eta cut") + O2_DEFINE_CONFIGURABLE(cfgMinMixEventNum, int, 5, "Minimum number of events to mix") + O2_DEFINE_CONFIGURABLE(cfgMinMult, int, 0, "Minimum multiplicity for collision") + O2_DEFINE_CONFIGURABLE(cfgMaxMult, int, 10, "Maximum multiplicity for collision") + O2_DEFINE_CONFIGURABLE(cfgSampleSize, double, 10, "Sample size for mixed event") + O2_DEFINE_CONFIGURABLE(cfgUsePtOrder, bool, true, "enable trigger pT < associated pT cut") + O2_DEFINE_CONFIGURABLE(cfgUsePtOrderInMixEvent, bool, true, "enable trigger pT < associated pT cut in mixed event") + + ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for histograms"}; + ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; + ConfigurableAxis axisPhi{"axisPhi", {72, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt axis for histograms"}; + ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"}; + ConfigurableAxis axisDeltaEta{"axisDeltaEta", {40, -2, 2}, "delta eta axis for histograms"}; + ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt trigger axis for histograms"}; + ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt associated axis for histograms"}; + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100}, "multiplicity / centrality axis for histograms"}; + ConfigurableAxis vtxMix{"vtxMix", {VARIABLE_WIDTH, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, "vertex axis for mixed event histograms"}; + ConfigurableAxis multMix{"multMix", {VARIABLE_WIDTH, 0, 5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100}, "multiplicity / centrality axis for mixed event histograms"}; + + ConfigurableAxis axisVertexEfficiency{"axisVertexEfficiency", {10, -10, 10}, "vertex axis for efficiency histograms"}; + ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"}; + ConfigurableAxis axisPtEfficiency{"axisPtEfficiency", {VARIABLE_WIDTH, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0}, "pt axis for efficiency histograms"}; + ConfigurableAxis axisSample{"axisSample", {cfgSampleSize, 0, cfgSampleSize}, "sample axis for histograms"}; + + // Added UPC Cuts + SGSelector sgSelector; + Configurable cfgCutFV0{"cfgCutFV0", 50., "FV0A threshold"}; + Configurable cfgCutFT0A{"cfgCutFT0A", 150., "FT0A threshold"}; + Configurable cfgCutFT0C{"cfgCutFT0C", 50., "FT0C threshold"}; + Configurable cfgCutZDC{"cfgCutZDC", 10., "ZDC threshold"}; + Configurable cfgGapSideSelection{"cfgGapSideSelection", 2, "gap selection"}; + + // make the filters and cuts. + // Filter collisionFilter = (nabs(aod::collision::posZ) < cfgZVtxCut) && (aod::flowcorrupc::multiplicity) > cfgMinMult && (aod::flowcorrupc::multiplicity) < cfgMaxMult && (aod::evsel::sel8) == true; + // Filter trackFilter = (nabs(aod::track::eta) < cfgEtaCut) && (aod::track::pt > cfgPtCutMin) && (aod::track::pt < cfgPtCutMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)); + + using UdTracks = soa::Join; + using UdTracksFull = soa::Join; + using UDCollisionsFull = soa::Join; + + // Define the outputs + OutputObj same{Form("sameEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + OutputObj mixed{Form("mixedEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; + + HistogramRegistry registry{"registry"}; + + void init(InitContext&) + { + LOGF(info, "Starting init"); + // Make histograms to check the distributions after cuts + registry.add("deltaEta_deltaPhi_same", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); // check to see the delta eta and delta phi distribution + registry.add("deltaEta_deltaPhi_mixed", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); + registry.add("Phi", "Phi", {HistType::kTH1D, {axisPhi}}); + registry.add("Eta", "Eta", {HistType::kTH1D, {axisEta}}); + registry.add("pT", "pT", {HistType::kTH1D, {axisPtTrigger}}); + registry.add("Nch", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}}); + registry.add("zVtx", "zVtx", {HistType::kTH1D, {axisVertex}}); + + registry.add("Trig_hist", "", {HistType::kTHnSparseF, {{axisSample, axisVertex, axisPtTrigger}}}); + + registry.add("eventcount", "bin", {HistType::kTH1F, {{3, 0, 3, "bin"}}}); // histogram to see how many events are in the same and mixed event + + std::vector corrAxis = {{axisSample, "Sample"}, + {axisVertex, "z-vtx (cm)"}, + {axisPtTrigger, "p_{T} (GeV/c)"}, + {axisPtAssoc, "p_{T} (GeV/c)"}, + {axisDeltaPhi, "#Delta#varphi (rad)"}, + {axisDeltaEta, "#Delta#eta"}}; + std::vector effAxis = { + {axisVertexEfficiency, "z-vtx (cm)"}, + {axisPtEfficiency, "p_{T} (GeV/c)"}, + {axisEtaEfficiency, "#eta"}, + }; + std::vector userAxis; + + same.setObject(new CorrelationContainer(Form("sameEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("sameEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + mixed.setObject(new CorrelationContainer(Form("mixedEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), Form("mixedEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult)), corrAxis, effAxis, userAxis)); + } + enum EventType { + SameEvent = 1, + MixedEvent = 3 + }; + + // fill multiple histograms + template + void fillYield(TCollision collision, TTracks tracks) // function to fill the yield and etaphi histograms. + { + registry.fill(HIST("Nch"), tracks.size()); + registry.fill(HIST("zVtx"), collision.posZ()); + + for (auto const& track1 : tracks) { + auto momentum1 = std::array{track1.px(), track1.py(), track1.pz()}; + registry.fill(HIST("Phi"), RecoDecay::phi(momentum1)); + registry.fill(HIST("Eta"), RecoDecay::eta(momentum1)); + registry.fill(HIST("pT"), track1.pt()); + } + } + + template + void fillCorrelations(TTracks tracks1, TTracks tracks2, float posZ, int system) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms + { + + int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); + + // loop over all tracks + for (auto const& track1 : tracks1) { + + if (system == SameEvent) { + registry.fill(HIST("Trig_hist"), fSampleIndex, posZ, track1.pt()); + } + + for (auto const& track2 : tracks2) { + + if (track1.globalIndex() == track2.globalIndex()) + continue; // For pt-differential correlations, skip if the trigger and associate are the same track + if (system == SameEvent && track1.pt() <= track2.pt()) + continue; // Without pt-differential correlations, skip if the trigger pt is less than the associate pt + + auto momentum1 = std::array{track1.px(), track1.py(), track1.pz()}; + auto momentum2 = std::array{track2.px(), track2.py(), track2.pz()}; + double phi1 = RecoDecay::phi(momentum1); + double phi2 = RecoDecay::phi(momentum2); + float deltaPhi = RecoDecay::constrainAngle(phi1 - phi2, -PIHalf); + float deltaEta = RecoDecay::eta(momentum1) - RecoDecay::eta(momentum2); + + // fill the right sparse and histograms + if (system == SameEvent) { + same->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta); + registry.fill(HIST("deltaEta_deltaPhi_same"), deltaPhi, deltaEta); + } else if (system == MixedEvent) { + mixed->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta); + registry.fill(HIST("deltaEta_deltaPhi_mixed"), deltaPhi, deltaEta); + } + } + } + } + + void processSame(UDCollisionsFull::iterator const& collision, UdTracksFull const& tracks) + { + if (std::abs(collision.posZ()) > cfgZVtxCut) { + return; + } + if (tracks.size() < cfgMinMult || tracks.size() > cfgMaxMult) { + return; + } + + int gapSide = collision.gapSide(); + const int minGapSide = 0; + const int maxGapSide = 2; + if (gapSide < minGapSide || gapSide > maxGapSide) { + return; + } + + int trueGapSide = sgSelector.trueGap(collision, cfgCutFV0, cfgCutFT0A, cfgCutFT0C, cfgCutZDC); + gapSide = trueGapSide; + if (gapSide == cfgGapSideSelection) { + return; + } + + registry.fill(HIST("eventcount"), SameEvent); // because its same event i put it in the 1 bin + fillYield(collision, tracks); + fillCorrelations(tracks, tracks, collision.posZ(), SameEvent); // fill the SE histogram and Sparse + } + PROCESS_SWITCH(FlowCorrelationsUpc, processSame, "Process same event", true); + + // event mixing + + SliceCache cache; + using MixedBinning = ColumnBinningPolicy; + + // the process for filling the mixed events + void processMixed(UDCollisionsFull const& collisions, UdTracksFull const& tracks) + { + MixedBinning binningOnVtxAndMult{{vtxMix, multMix}, true}; // true is for 'ignore overflows' (true by default) + auto tracksTuple = std::make_tuple(tracks); + SameKindPair pairs{binningOnVtxAndMult, cfgMinMixEventNum, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (auto const& [collision1, tracks1, collision2, tracks2] : pairs) { + registry.fill(HIST("eventcount"), MixedEvent); // fill the mixed event in the 3 bin + fillCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent); + } + } + PROCESS_SWITCH(FlowCorrelationsUpc, processMixed, "Process mixed events", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGUD/Tasks/flowCumulantsUpc.cxx b/PWGUD/Tasks/flowCumulantsUpc.cxx new file mode 100644 index 00000000000..155a398cd44 --- /dev/null +++ b/PWGUD/Tasks/flowCumulantsUpc.cxx @@ -0,0 +1,885 @@ +// 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. + +/// \file flowCumulantsUpc.cxx +/// \author Mingrui Zhao (mingrui.zhao@mail.labz0.org, mingrui.zhao@cern.ch) +/// \since Mar/2025 +/// \brief jira: , task to measure flow observables with cumulant method + +#include +#include +#include +#include +#include +#include +#include +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/HistogramRegistry.h" + +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/CCDB/ctpRateFetcher.h" + +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/Core/SGSelector.h" +#include "TVector3.h" + +#include "GFWPowerArray.h" +#include "GFW.h" +#include "GFWCumulant.h" +#include "GFWWeights.h" +#include "FlowContainer.h" +#include "TList.h" +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +struct FlowCumulantsUpc { + + O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FT0A") + O2_DEFINE_CONFIGURABLE(cfgCentFT0CMin, float, 0.0f, "Minimum centrality (FT0C) to cut events in filter") + O2_DEFINE_CONFIGURABLE(cfgCentFT0CMax, float, 100.0f, "Maximum centrality (FT0C) to cut events in filter") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtRefMin, float, 0.2f, "Minimal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtRefMax, float, 3.0f, "Maximal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for all tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 10.0f, "Maximal pT for all tracks") + O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") + O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5f, "max chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutTPCclu, float, 70.0f, "minimum TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutITSclu, float, 5.0f, "minimum ITS clusters") + O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "max DCA to vertex z") + O2_DEFINE_CONFIGURABLE(cfgCutDCAxyppPass3Enabled, bool, false, "switch of ppPass3 DCAxy pt dependent cut") + O2_DEFINE_CONFIGURABLE(cfgCutDCAzPtDepEnabled, bool, false, "switch of DCAz pt dependent cut") + O2_DEFINE_CONFIGURABLE(cfgTrkSelSwitch, bool, false, "switch for self-defined track selection") + O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, false, "Use additional event cut on mult correlations") + O2_DEFINE_CONFIGURABLE(cfgUseTentativeEventCounter, bool, false, "After sel8(), count events regardless of real event selection") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoSameBunchPileup, bool, false, "rejects collisions which are associated with the same found-by-T0 bunch crossing") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodZvtxFT0vsPV, bool, false, "removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference, use this cut at low multiplicities with caution") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInTimeRangeStandard, bool, false, "no collisions in specified time range") + O2_DEFINE_CONFIGURABLE(cfgEvSelkIsGoodITSLayersAll, bool, true, "cut time intervals with dead ITS staves") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoCollInRofStandard, bool, false, "no other collisions in this Readout Frame with per-collision multiplicity above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelkNoHighMultCollInPrevRof, bool, false, "veto an event if FT0C amplitude in previous ITS ROF is above threshold") + O2_DEFINE_CONFIGURABLE(cfgEvSelMultCorrelation, bool, true, "Multiplicity correlation cut") + O2_DEFINE_CONFIGURABLE(cfgEvSelV0AT0ACut, bool, true, "V0A T0A 5 sigma cut") + O2_DEFINE_CONFIGURABLE(cfgGetInteractionRate, bool, false, "Get interaction rate from CCDB") + O2_DEFINE_CONFIGURABLE(cfgUseInteractionRateCut, bool, false, "Use events with low interaction rate") + O2_DEFINE_CONFIGURABLE(cfgCutMaxIR, float, 50.0f, "maximum interaction rate (kHz)") + O2_DEFINE_CONFIGURABLE(cfgCutMinIR, float, 0.0f, "minimum interaction rate (kHz)") + O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables") + O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 30, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeightsRefPt, bool, false, "NUA weights are filled in ref pt bins") + O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgAcceptanceList, std::string, "", "CCDB path to acceptance lsit object") + O2_DEFINE_CONFIGURABLE(cfgAcceptanceListEnabled, bool, false, "switch of acceptance list") + O2_DEFINE_CONFIGURABLE(cfgEvSelOccupancy, bool, true, "Occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 500, "High cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy") + O2_DEFINE_CONFIGURABLE(cfgUseSmallMemory, bool, false, "Use small memory mode") + Configurable> cfgUserDefineGFWCorr{"cfgUserDefineGFWCorr", std::vector{"refN02 {2} refP02 {-2}", "refN12 {2} refP12 {-2}"}, "User defined GFW CorrelatorConfig"}; + Configurable> cfgUserDefineGFWName{"cfgUserDefineGFWName", std::vector{"Ch02Gap22", "Ch12Gap22"}, "User defined GFW Name"}; + Configurable> cfgRunRemoveList{"cfgRunRemoveList", std::vector{-1}, "excluded run numbers"}; + + ConfigurableAxis axisPtHist{"axisPtHist", {100, 0., 10.}, "pt axis for histograms"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}, "pt axis for histograms"}; + ConfigurableAxis axisIndependent{"axisIndependent", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "X axis for histograms"}; + ConfigurableAxis axisNch{"axisNch", {4000, 0, 4000}, "N_{ch}"}; + ConfigurableAxis axisDCAz{"axisDCAz", {200, -2, 2}, "DCA_{z} (cm)"}; + ConfigurableAxis axisDCAxy{"axisDCAxy", {200, -1, 1}, "DCA_{xy} (cm)"}; + + // Added UPC Cuts + SGSelector sgSelector; + Configurable cfgCutFV0{"cfgCutFV0", 50., "FV0A threshold"}; + Configurable cfgCutFT0A{"cfgCutFT0A", 150., "FT0A threshold"}; + Configurable cfgCutFT0C{"cfgCutFT0C", 50., "FT0C threshold"}; + Configurable cfgCutZDC{"cfgCutZDC", 10., "ZDC threshold"}; + Configurable cfgGapSideSelection{"cfgGapSideSelection", 2, "gap selection"}; + + // Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVertex) && (aod::cent::centFT0C > cfgCentFT0CMin) && (aod::cent::centFT0C < cfgCentFT0CMax); + // Filter trackFilter = ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + + // Corrections + TH1D* mEfficiency = nullptr; + GFWWeights* mAcceptance = nullptr; + TObjArray* mAcceptanceList = nullptr; + bool correctionsLoaded = false; + + // Connect to ccdb + Service ccdb; + Configurable ccdbNoLaterThan{"ccdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + // Define output + OutputObj fFC{FlowContainer("FlowContainer")}; + OutputObj fWeights{GFWWeights("weights")}; + HistogramRegistry registry{"registry"}; + + // define global variables + GFW* fGFW = new GFW(); + std::vector corrconfigs; + TAxis* fPtAxis; + TRandom3* fRndm = new TRandom3(0); + enum CentEstimators { + kCentFT0C = 0, + kCentFT0CVariant1, + kCentFT0M, + kCentFV0A, + // Count the total number of enum + kCount_CentEstimators + }; + int mRunNumber{-1}; + uint64_t mSOR{0}; + double mMinSeconds{-1.}; + std::unordered_map gHadronicRate; + ctpRateFetcher mRateFetcher; + TH2* gCurrentHadronicRate; + + // using AodCollisions = soa::Filtered>; + // using AodTracks = soa::Filtered>; + // + using UdTracks = soa::Join; + using UdTracksFull = soa::Join; + using UDCollisionsFull = soa::Join; + + // Track selection + TrackSelection myTrackSel; + TF1* fPhiCutLow = nullptr; + TF1* fPhiCutHigh = nullptr; + // Additional Event selection cuts - Copy from flowGenericFramework.cxx + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fMultMultPVCut = nullptr; + TF1* fT0AV0AMean = nullptr; + TF1* fT0AV0ASigma = nullptr; + + void init(InitContext const&) + { + const AxisSpec axisVertex{40, -20, 20, "Vtxz (cm)"}; + const AxisSpec axisPhi{60, 0.0, constants::math::TwoPI, "#varphi"}; + const AxisSpec axisEta{40, -1., 1., "#eta"}; + const AxisSpec axisCentForQA{100, 0, 100, "centrality (%)"}; + const AxisSpec axisT0C{70, 0, 70000, "N_{ch} (T0C)"}; + const AxisSpec axisT0A{200, 0, 200000, "N_{ch} (T0A)"}; + + ccdb->setURL(ccdbUrl.value); + ccdb->setCaching(true); + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + + // Add some output objects to the histogram registry + // Event QA + registry.add("hEventCount", "Number of Event;; Count", {HistType::kTH1D, {{5, 0, 5}}}); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(1, "Filtered event"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(2, "after sel8"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(3, "after supicious Runs removal"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(4, "after additional event cut"); + registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(5, "after correction loads"); + registry.add("hEventCountSpecific", "Number of Event;; Count", {HistType::kTH1D, {{10, 0, 10}}}); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(1, "after sel8"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(2, "kNoSameBunchPileup"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(3, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(4, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(5, "kIsGoodITSLayersAll"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(6, "kNoCollInRofStandard"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(7, "kNoHighMultCollInPrevRof"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(8, "occupancy"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(9, "MultCorrelation"); + registry.get(HIST("hEventCountSpecific"))->GetXaxis()->SetBinLabel(10, "cfgEvSelV0AT0ACut"); + if (cfgUseTentativeEventCounter) { + registry.add("hEventCountTentative", "Number of Event;; Count", {HistType::kTH1D, {{10, 0, 10}}}); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(1, "after sel8"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(2, "kNoSameBunchPileup"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(3, "kIsGoodZvtxFT0vsPV"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(4, "kNoCollInTimeRangeStandard"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(5, "kIsGoodITSLayersAll"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(6, "kNoCollInRofStandard"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(7, "kNoHighMultCollInPrevRof"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(8, "occupancy"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(9, "MultCorrelation"); + registry.get(HIST("hEventCountTentative"))->GetXaxis()->SetBinLabel(10, "cfgEvSelV0AT0ACut"); + } + registry.add("hVtxZ", "Vexter Z distribution", {HistType::kTH1D, {axisVertex}}); + registry.add("hMult", "Multiplicity distribution", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); + std::string hCentTitle = "Centrality distribution, Estimator " + std::to_string(cfgCentEstimator); + registry.add("hCent", hCentTitle.c_str(), {HistType::kTH1D, {{90, 0, 90}}}); + if (!cfgUseSmallMemory) { + registry.add("BeforeSel8_globalTracks_centT0C", "before sel8;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("BeforeCut_globalTracks_centT0C", "before cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("BeforeCut_PVTracks_centT0C", "before cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("BeforeCut_globalTracks_PVTracks", "before cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNch, axisNch}}); + registry.add("BeforeCut_globalTracks_multT0A", "before cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("BeforeCut_globalTracks_multV0A", "before cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("BeforeCut_multV0A_multT0A", "before cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); + registry.add("BeforeCut_multT0C_centT0C", "before cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); + registry.add("globalTracks_centT0C", "after cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("PVTracks_centT0C", "after cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); + registry.add("globalTracks_PVTracks", "after cut;mulplicity PV tracks;mulplicity global tracks", {HistType::kTH2D, {axisNch, axisNch}}); + registry.add("globalTracks_multT0A", "after cut;mulplicity T0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("globalTracks_multV0A", "after cut;mulplicity V0A;mulplicity global tracks", {HistType::kTH2D, {axisT0A, axisNch}}); + registry.add("multV0A_multT0A", "after cut;mulplicity T0A;mulplicity V0A", {HistType::kTH2D, {axisT0A, axisT0A}}); + registry.add("multT0C_centT0C", "after cut;Centrality T0C;mulplicity T0C", {HistType::kTH2D, {axisCentForQA, axisT0C}}); + registry.add("centFT0CVar_centFT0C", "after cut;Centrality T0C;Centrality T0C Var", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); + registry.add("centFT0M_centFT0C", "after cut;Centrality T0C;Centrality T0M", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); + registry.add("centFV0A_centFT0C", "after cut;Centrality T0C;Centrality V0A", {HistType::kTH2D, {axisCentForQA, axisCentForQA}}); + } + // Track QA + registry.add("hPhi", "#phi distribution", {HistType::kTH1D, {axisPhi}}); + registry.add("hPhiWeighted", "corrected #phi distribution", {HistType::kTH1D, {axisPhi}}); + registry.add("hEta", "#eta distribution", {HistType::kTH1D, {axisEta}}); + registry.add("hPt", "p_{T} distribution before cut", {HistType::kTH1D, {axisPtHist}}); + registry.add("hPtRef", "p_{T} distribution after cut", {HistType::kTH1D, {axisPtHist}}); + registry.add("hChi2prTPCcls", "#chi^{2}/cluster for the TPC track segment", {HistType::kTH1D, {{100, 0., 5.}}}); + registry.add("hChi2prITScls", "#chi^{2}/cluster for the ITS track", {HistType::kTH1D, {{100, 0., 50.}}}); + registry.add("hnTPCClu", "Number of found TPC clusters", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("hnITSClu", "Number of found ITS clusters", {HistType::kTH1D, {{100, 0, 20}}}); + registry.add("hnTPCCrossedRow", "Number of crossed TPC Rows", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("hDCAz", "DCAz after cuts; DCAz (cm); Pt", {HistType::kTH2D, {{200, -0.5, 0.5}, {200, 0, 5}}}); + registry.add("hDCAxy", "DCAxy after cuts; DCAxy (cm); Pt", {HistType::kTH2D, {{200, -0.5, 0.5}, {200, 0, 5}}}); + registry.add("hTrackCorrection2d", "Correlation table for number of tracks table; uncorrected track; corrected track", {HistType::kTH2D, {axisNch, axisNch}}); + + o2::framework::AxisSpec axis = axisPt; + int nPtBins = axis.binEdges.size() - 1; + double* ptBins = &(axis.binEdges)[0]; + fPtAxis = new TAxis(nPtBins, ptBins); + + if (cfgOutputNUAWeights) { + fWeights->setPtBins(nPtBins, ptBins); + fWeights->init(true, false); + } + + // add in FlowContainer to Get boostrap sample automatically + TObjArray* oba = new TObjArray(); + oba->Add(new TNamed("ChGap22", "ChGap22")); + oba->Add(new TNamed("ChFull22", "ChFull22")); + oba->Add(new TNamed("ChFull32", "ChFull32")); + oba->Add(new TNamed("ChFull42", "ChFull42")); + oba->Add(new TNamed("ChFull24", "ChFull24")); + oba->Add(new TNamed("ChFull26", "ChFull26")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull22_pt_%i", i + 1), "ChFull22_pTDiff")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull24_pt_%i", i + 1), "ChFull24_pTDiff")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull26_pt_%i", i + 1), "ChFull26_pTDiff")); + oba->Add(new TNamed("Ch04Gap22", "Ch04Gap22")); + oba->Add(new TNamed("Ch06Gap22", "Ch06Gap22")); + oba->Add(new TNamed("Ch08Gap22", "Ch08Gap22")); + oba->Add(new TNamed("Ch10Gap22", "Ch10Gap22")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap22_pt_%i", i + 1), "Ch10Gap22_pTDiff")); + oba->Add(new TNamed("Ch12Gap22", "Ch12Gap22")); + oba->Add(new TNamed("Ch04Gap32", "Ch04Gap32")); + oba->Add(new TNamed("Ch06Gap32", "Ch06Gap32")); + oba->Add(new TNamed("Ch08Gap32", "Ch08Gap32")); + oba->Add(new TNamed("Ch10Gap32", "Ch10Gap32")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap32_pt_%i", i + 1), "Ch10Gap32_pTDiff")); + oba->Add(new TNamed("Ch12Gap32", "Ch12Gap32")); + oba->Add(new TNamed("Ch04Gap42", "Ch04Gap42")); + oba->Add(new TNamed("Ch06Gap42", "Ch06Gap42")); + oba->Add(new TNamed("Ch08Gap42", "Ch08Gap42")); + oba->Add(new TNamed("Ch10Gap42", "Ch10Gap42")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap42_pt_%i", i + 1), "Ch10Gap42_pTDiff")); + oba->Add(new TNamed("Ch12Gap42", "Ch12Gap42")); + oba->Add(new TNamed("ChFull422", "ChFull422")); + oba->Add(new TNamed("Ch04GapA422", "Ch04GapA422")); + oba->Add(new TNamed("Ch04GapB422", "Ch04GapB422")); + oba->Add(new TNamed("Ch10GapA422", "Ch10GapA422")); + oba->Add(new TNamed("Ch10GapB422", "Ch10GapB422")); + oba->Add(new TNamed("ChFull3232", "ChFull3232")); + oba->Add(new TNamed("ChFull4242", "ChFull4242")); + oba->Add(new TNamed("Ch04Gap3232", "Ch04Gap3232")); + oba->Add(new TNamed("Ch04Gap4242", "Ch04Gap4242")); + oba->Add(new TNamed("Ch04Gap24", "Ch04Gap24")); + oba->Add(new TNamed("Ch10Gap3232", "Ch10Gap3232")); + oba->Add(new TNamed("Ch10Gap4242", "Ch10Gap4242")); + oba->Add(new TNamed("Ch10Gap24", "Ch10Gap24")); + for (auto i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("Ch10Gap24_pt_%i", i + 1), "Ch10Gap24_pTDiff")); + std::vector userDefineGFWCorr = cfgUserDefineGFWCorr; + std::vector userDefineGFWName = cfgUserDefineGFWName; + if (!userDefineGFWCorr.empty() && !userDefineGFWName.empty()) { + for (uint i = 0; i < userDefineGFWName.size(); i++) { + oba->Add(new TNamed(userDefineGFWName.at(i).c_str(), userDefineGFWName.at(i).c_str())); + } + } + fFC->SetName("FlowContainer"); + fFC->SetXAxis(fPtAxis); + fFC->Initialize(oba, axisIndependent, cfgNbootstrap); + delete oba; + + // eta region + fGFW->AddRegion("full", -0.8, 0.8, 1, 1); + fGFW->AddRegion("refN00", -0.8, 0., 1, 1); // gap0 negative region + fGFW->AddRegion("refP00", 0., 0.8, 1, 1); // gap0 positve region + fGFW->AddRegion("refN02", -0.8, -0.1, 1, 1); // gap2 negative region + fGFW->AddRegion("refP02", 0.1, 0.8, 1, 1); // gap2 positve region + fGFW->AddRegion("refN04", -0.8, -0.2, 1, 1); // gap4 negative region + fGFW->AddRegion("refP04", 0.2, 0.8, 1, 1); // gap4 positve region + fGFW->AddRegion("refN06", -0.8, -0.3, 1, 1); // gap6 negative region + fGFW->AddRegion("refP06", 0.3, 0.8, 1, 1); // gap6 positve region + fGFW->AddRegion("refN08", -0.8, -0.4, 1, 1); + fGFW->AddRegion("refP08", 0.4, 0.8, 1, 1); + fGFW->AddRegion("refN10", -0.8, -0.5, 1, 1); + fGFW->AddRegion("refP10", 0.5, 0.8, 1, 1); + fGFW->AddRegion("refN12", -0.8, -0.6, 1, 1); + fGFW->AddRegion("refP12", 0.6, 0.8, 1, 1); + fGFW->AddRegion("refN14", -0.8, -0.7, 1, 1); + fGFW->AddRegion("refP14", 0.7, 0.8, 1, 1); + fGFW->AddRegion("refN", -0.8, -0.4, 1, 1); + fGFW->AddRegion("refP", 0.4, 0.8, 1, 1); + fGFW->AddRegion("refM", -0.4, 0.4, 1, 1); + fGFW->AddRegion("poiN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 2); + fGFW->AddRegion("poiN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 2); + fGFW->AddRegion("poifull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 2); + fGFW->AddRegion("olN", -0.8, -0.4, 1 + fPtAxis->GetNbins(), 4); + fGFW->AddRegion("olN10", -0.8, -0.5, 1 + fPtAxis->GetNbins(), 4); + fGFW->AddRegion("olfull", -0.8, 0.8, 1 + fPtAxis->GetNbins(), 4); + + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {3 -3}", "ChFull32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {4 -4}", "ChFull42", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 -2 -2}", "ChFull24", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 2 2 -2 -2 -2}", "ChFull26", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN04 {2} refP04 {-2}", "Ch04Gap22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN06 {2} refP06 {-2}", "Ch06Gap22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN08 {2} refP08 {-2}", "Ch08Gap22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN12 {2} refP12 {-2}", "Ch12Gap22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN04 {3} refP04 {-3}", "Ch04Gap32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN06 {3} refP06 {-3}", "Ch06Gap32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN08 {3} refP08 {-3}", "Ch08Gap32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {3} refP10 {-3}", "Ch10Gap32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN12 {3} refP12 {-3}", "Ch12Gap32", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN04 {4} refP04 {-4}", "Ch04Gap42", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN06 {4} refP06 {-4}", "Ch06Gap42", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN08 {4} refP08 {-4}", "Ch08Gap42", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {4} refP10 {-4}", "Ch10Gap42", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN12 {4} refP12 {-4}", "Ch12Gap42", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN {2} refP {-2}", "ChGap22", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifull full | olfull {2 -2}", "ChFull22", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifull full | olfull {2 2 -2 -2}", "ChFull24", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poifull full | olfull {2 2 2 -2 -2 -2}", "ChFull26", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {2} refP10 {-2}", "Ch10Gap22", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {3} refP10 {-3}", "Ch10Gap32", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {4} refP10 {-4}", "Ch10Gap42", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {4 -2 -2}", "ChFull422", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN04 {-2 -2} refP04 {4}", "Ch04GapA422", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN04 {4} refP04 {-2 -2}", "Ch04GapB422", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {-2 -2} refP10 {4}", "Ch10GapA422", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {4} refP10 {-2 -2}", "Ch10GapB422", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {3 2 -3 -2}", "ChFull3232", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {4 2 -4 -2}", "ChFull4242", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN04 {3 2} refP04 {-3 -2}", "Ch04Gap3232", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN04 {4 2} refP04 {-4 -2}", "Ch04Gap4242", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN04 {2 2} refP04 {-2 -2}", "Ch04Gap24", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {3 2} refP10 {-3 -2}", "Ch10Gap3232", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {4 2} refP10 {-4 -2}", "Ch10Gap4242", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refN10 {2 2} refP10 {-2 -2}", "Ch10Gap24", kFALSE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("poiN10 refN10 | olN10 {2 2} refP10 {-2 -2}", "Ch10Gap24", kTRUE)); + if (!userDefineGFWCorr.empty() && !userDefineGFWName.empty()) { + LOGF(info, "User adding GFW CorrelatorConfig:"); + // attentaion: here we follow the index of cfgUserDefineGFWCorr + for (uint i = 0; i < userDefineGFWCorr.size(); i++) { + if (i >= userDefineGFWName.size()) { + LOGF(fatal, "The names you provided are more than configurations. userDefineGFWName.size(): %d > userDefineGFWCorr.size(): %d", userDefineGFWName.size(), userDefineGFWCorr.size()); + break; + } + LOGF(info, "%d: %s %s", i, userDefineGFWCorr.at(i).c_str(), userDefineGFWName.at(i).c_str()); + corrconfigs.push_back(fGFW->GetCorrelatorConfig(userDefineGFWCorr.at(i).c_str(), userDefineGFWName.at(i).c_str(), kFALSE)); + } + } + fGFW->CreateRegions(); + + if (cfgUseAdditionalEventCut) { + fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); + fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + + fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); + fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + + fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } + + myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + myTrackSel.SetMinNClustersTPC(cfgCutTPCclu); + myTrackSel.SetMinNClustersITS(cfgCutITSclu); + if (cfgCutDCAxyppPass3Enabled) + myTrackSel.SetMaxDcaXYPtDep([](float pt) { return 0.004f + 0.013f / pt; }); // Tuned on the LHC22f anchored MC LHC23d1d on primary pions. 7 Sigmas of the resolution + } + + template + void fillProfile(const GFW::CorrConfig& corrconf, const ConstStr& tarName, const double& cent) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (dnx == 0) { + return; + } + if (!corrconf.pTDif) { + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + registry.fill(tarName, cent, val, dnx); + } + return; + } + return; + } + + void fillFC(const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) + { + double dnx, val; + dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); + if (!corrconf.pTDif) { + if (dnx == 0) { + return; + } + val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + fFC->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); + } + return; + } + for (auto i = 1; i <= fPtAxis->GetNbins(); i++) { + dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); + if (dnx == 0) { + continue; + } + val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; + if (std::fabs(val) < 1) { + fFC->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); + } + } + return; + } + + void loadCorrections(uint64_t timestamp, int runNumber) + { + if (correctionsLoaded) { + return; + } + if (!cfgAcceptanceListEnabled && cfgAcceptance.value.empty() == false) { + mAcceptance = ccdb->getForTimeStamp(cfgAcceptance, timestamp); + if (mAcceptance) { + LOGF(info, "Loaded acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); + } else { + LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance); + } + } + if (cfgAcceptanceListEnabled && cfgAcceptanceList.value.empty() == false) { + mAcceptanceList = ccdb->getForTimeStamp(cfgAcceptanceList, timestamp); + if (mAcceptanceList == nullptr) { + LOGF(fatal, "Could not load acceptance weights list from %s", cfgAcceptanceList.value.c_str()); + } + LOGF(info, "Loaded acceptance weights list from %s (%p)", cfgAcceptanceList.value.c_str(), (void*)mAcceptanceList); + + mAcceptance = static_cast(mAcceptanceList->FindObject(Form("%d", runNumber))); + if (mAcceptance == nullptr) { + LOGF(fatal, "Could not find acceptance weights for run %d in acceptance list", runNumber); + } + LOGF(info, "Loaded acceptance weights (%p) for run %d from list (%p)", (void*)mAcceptance, runNumber, (void*)mAcceptanceList); + } + if (cfgEfficiency.value.empty() == false) { + mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); + if (mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency); + } + correctionsLoaded = true; + } + + bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz) + { + float eff = 1.; + if (mEfficiency) + eff = mEfficiency->GetBinContent(mEfficiency->FindBin(pt)); + else + eff = 1.0; + if (eff == 0) + return false; + weight_nue = 1. / eff; + + if (mAcceptance) + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + else + weight_nua = 1; + return true; + } + + template + bool eventSelected(TCollision collision, const int multTrk, const float centrality) + { + registry.fill(HIST("hEventCountSpecific"), 0.5); + if (cfgEvSelkNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return 0; + } + if (cfgEvSelkNoSameBunchPileup) { + registry.fill(HIST("hEventCountSpecific"), 1.5); + } + if (cfgEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return 0; + } + if (cfgEvSelkIsGoodZvtxFT0vsPV) { + registry.fill(HIST("hEventCountSpecific"), 2.5); + } + if (cfgEvSelkNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // no collisions in specified time range + return 0; + } + if (cfgEvSelkNoCollInTimeRangeStandard) { + registry.fill(HIST("hEventCountSpecific"), 3.5); + } + if (cfgEvSelkIsGoodITSLayersAll && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // from Jan 9 2025 AOT meeting + // cut time intervals with dead ITS staves + return 0; + } + if (cfgEvSelkIsGoodITSLayersAll) { + registry.fill(HIST("hEventCountSpecific"), 4.5); + } + if (cfgEvSelkNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + // no other collisions in this Readout Frame with per-collision multiplicity above threshold + return 0; + } + if (cfgEvSelkNoCollInRofStandard) { + registry.fill(HIST("hEventCountSpecific"), 5.5); + } + if (cfgEvSelkNoHighMultCollInPrevRof && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + // veto an event if FT0C amplitude in previous ITS ROF is above threshold + return 0; + } + if (cfgEvSelkNoHighMultCollInPrevRof) { + registry.fill(HIST("hEventCountSpecific"), 6.5); + } + auto multNTracksPV = collision.multNTracksPV(); + auto occupancy = collision.trackOccupancyInTimeRange(); + if (cfgEvSelOccupancy && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) { + return 0; + } + if (cfgEvSelOccupancy) { + registry.fill(HIST("hEventCountSpecific"), 7.5); + } + + if (cfgEvSelMultCorrelation) { + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return 0; + if (multTrk < fMultCutLow->Eval(centrality)) + return 0; + if (multTrk > fMultCutHigh->Eval(centrality)) + return 0; + } + if (cfgEvSelMultCorrelation) { + registry.fill(HIST("hEventCountSpecific"), 8.5); + } + + // V0A T0A 5 sigma cut + if (cfgEvSelV0AT0ACut && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > 5 * fT0AV0ASigma->Eval(collision.multFT0A()))) { + return 0; + } + if (cfgEvSelV0AT0ACut) { + registry.fill(HIST("hEventCountSpecific"), 9.5); + } + + return 1; + } + + template + void eventCounterQA(TCollision collision, const int multTrk, const float centrality) + { + registry.fill(HIST("hEventCountTentative"), 0.5); + // Regradless of the event selection, fill the event counter histograms + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + registry.fill(HIST("hEventCountTentative"), 1.5); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + registry.fill(HIST("hEventCountTentative"), 2.5); + } + if (collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + registry.fill(HIST("hEventCountTentative"), 3.5); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + registry.fill(HIST("hEventCountTentative"), 4.5); + } + if (collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + registry.fill(HIST("hEventCountTentative"), 5.5); + } + if (collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + registry.fill(HIST("hEventCountTentative"), 6.5); + } + auto multNTracksPV = collision.multNTracksPV(); + auto occupancy = collision.trackOccupancyInTimeRange(); + if (!(occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) { + registry.fill(HIST("hEventCountTentative"), 7.5); + } + if (!((multNTracksPV < fMultPVCutLow->Eval(centrality)) || (multNTracksPV > fMultPVCutHigh->Eval(centrality)) || (multTrk < fMultCutLow->Eval(centrality)) || (multTrk > fMultCutHigh->Eval(centrality)))) { + registry.fill(HIST("hEventCountTentative"), 8.5); + } + if (!(std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > 5 * fT0AV0ASigma->Eval(collision.multFT0A()))) { + registry.fill(HIST("hEventCountTentative"), 9.5); + } + } + + template + bool trackSelected(TTrack track) + { + // UPC selection + if (!track.isPVContributor()) { + return false; + } + if (!(std::fabs(track.dcaZ()) < 2.)) { + return false; + } + double dcaLimit = 0.0105 + 0.035 / std::pow(track.pt(), 1.1); + if (!(std::fabs(track.dcaXY()) < dcaLimit)) { + return false; + } + return true; + + // if (cfgCutDCAzPtDepEnabled && (std::fabs(track.dcaZ()) > (0.004f + 0.013f / track.pt()))) + // return false; + + // if (cfgTrkSelSwitch) { + // return myTrackSel.IsSelected(track); + // } else { + // return ((track.tpcNClsFound() >= cfgCutTPCclu) && (track.itsNCls() >= cfgCutITSclu)); + // } + } + + void initHadronicRate(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + if (gHadronicRate.find(mRunNumber) == gHadronicRate.end()) { + auto runDuration = ccdb->getRunDuration(mRunNumber); + mSOR = runDuration.first; + mMinSeconds = std::floor(mSOR * 1.e-3); /// round tsSOR to the highest integer lower than tsSOR + double maxSec = std::ceil(runDuration.second * 1.e-3); /// round tsEOR to the lowest integer higher than tsEOR + const AxisSpec axisSeconds{static_cast((maxSec - mMinSeconds) / 20.f), 0, maxSec - mMinSeconds, "Seconds since SOR"}; + gHadronicRate[mRunNumber] = registry.add(Form("HadronicRate/%i", mRunNumber), ";Time since SOR (s);Hadronic rate (kHz)", kTH2D, {axisSeconds, {510, 0., 51.}}).get(); + } + gCurrentHadronicRate = gHadronicRate[mRunNumber]; + } + + // void process(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracks const& tracks) + void process(UDCollisionsFull::iterator const& collision, UdTracksFull const& tracks) + { + + // Runnumber loading test + // accept only selected run numbers + // int run = collision.runNumber(); + + // extract bc pattern from CCDB for data or anchored MC only + // if (run != lastRun && run >= 500000) { + // LOGF(info, "Updating bcPattern %d ...", run); + // auto tss = ccdb->getRunDuration(run); + // auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", tss.first); + // bcPatternB = grplhcif->getBunchFilling().getBCPattern(); + // lastRun = run; + // LOGF(info, "done!"); + // } + + // auto bcnum = collision.globalBC(); + + registry.fill(HIST("hEventCount"), 0.5); + int gapSide = collision.gapSide(); + if (gapSide < 0 || gapSide > 2) { + return; + } + + int trueGapSide = sgSelector.trueGap(collision, cfgCutFV0, cfgCutFT0A, cfgCutFT0C, cfgCutZDC); + gapSide = trueGapSide; + if (gapSide == cfgGapSideSelection) { + return; + } + + // if (!cfgUseSmallMemory && tracks.size() >= 1) { + // registry.fill(HIST("BeforeSel8_globalTracks_centT0C"), collision.centFT0C(), tracks.size()); + // } + // if (!collision.sel8()) + // return; + // if (tracks.size() < 1) + // return; + registry.fill(HIST("hEventCount"), 1.5); + // auto bc = collision.bc_as(); + // int currentRunNumber = bc.runNumber(); + // for (const auto& ExcludedRun : cfgRunRemoveList.value) { + // if (currentRunNumber == ExcludedRun) { + // return; + // } + // } + // registry.fill(HIST("hEventCount"), 2.5); + // if (!cfgUseSmallMemory) { + // registry.fill(HIST("BeforeCut_globalTracks_centT0C"), collision.centFT0C(), tracks.size()); + // registry.fill(HIST("BeforeCut_PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV()); + // registry.fill(HIST("BeforeCut_globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size()); + // registry.fill(HIST("BeforeCut_globalTracks_multT0A"), collision.multFT0A(), tracks.size()); + // registry.fill(HIST("BeforeCut_globalTracks_multV0A"), collision.multFV0A(), tracks.size()); + // registry.fill(HIST("BeforeCut_multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); + // registry.fill(HIST("BeforeCut_multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); + // } + float cent = 100; + // switch (cfgCentEstimator) { + // case kCentFT0C: + // cent = collision.centFT0C(); + // break; + // case kCentFT0CVariant1: + // cent = collision.centFT0CVariant1(); + // break; + // case kCentFT0M: + // cent = collision.centFT0M(); + // break; + // case kCentFV0A: + // cent = collision.centFV0A(); + // break; + // default: + // cent = collision.centFT0C(); + // } + // if (cfgUseTentativeEventCounter) + // eventCounterQA(collision, tracks.size(), cent); + // if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), cent)) + // return; + // registry.fill(HIST("hEventCount"), 3.5); + float lRandom = fRndm->Rndm(); + float vtxz = collision.posZ(); + registry.fill(HIST("hVtxZ"), vtxz); + registry.fill(HIST("hMult"), tracks.size()); + registry.fill(HIST("hCent"), cent); + fGFW->Clear(); + // if (cfgGetInteractionRate) { + // initHadronicRate(bc); + // double hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, "ZNC hadronic") * 1.e-3; // + // double seconds = bc.timestamp() * 1.e-3 - mMinSeconds; + // if (cfgUseInteractionRateCut && (hadronicRate < cfgCutMinIR || hadronicRate > cfgCutMaxIR)) // cut on hadronic rate + // return; + // gCurrentHadronicRate->Fill(seconds, hadronicRate); + // } + // loadCorrections(bc.timestamp(), currentRunNumber); + // registry.fill(HIST("hEventCount"), 4.5); + + // // fill event QA + // if (!cfgUseSmallMemory) { + // registry.fill(HIST("globalTracks_centT0C"), collision.centFT0C(), tracks.size()); + // registry.fill(HIST("PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV()); + // registry.fill(HIST("globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size()); + // registry.fill(HIST("globalTracks_multT0A"), collision.multFT0A(), tracks.size()); + // registry.fill(HIST("globalTracks_multV0A"), collision.multFV0A(), tracks.size()); + // registry.fill(HIST("multV0A_multT0A"), collision.multFT0A(), collision.multFV0A()); + // registry.fill(HIST("multT0C_centT0C"), collision.centFT0C(), collision.multFT0C()); + // registry.fill(HIST("centFT0CVar_centFT0C"), collision.centFT0C(), collision.centFT0CVariant1()); + // registry.fill(HIST("centFT0M_centFT0C"), collision.centFT0C(), collision.centFT0M()); + // registry.fill(HIST("centFV0A_centFT0C"), collision.centFT0C(), collision.centFV0A()); + // } + + // // track weights + float weff = 1, wacc = 1; + double nTracksCorrected = 0; + float independent = cent; + if (cfgUseNch) { + independent = static_cast(tracks.size()); + } + + for (const auto& track : tracks) { + if (!trackSelected(track)) + continue; + auto momentum = std::array{track.px(), track.py(), track.pz()}; + double pt = RecoDecay::pt(momentum); + double phi = RecoDecay::phi(momentum); + double eta = RecoDecay::eta(momentum); + bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtRefMin < pt) && (pt < cfgCutPtRefMax); // within RF pT range + if (cfgOutputNUAWeights) { + if (cfgOutputNUAWeightsRefPt) { + if (withinPtRef) { + fWeights->fill(phi, eta, vtxz, pt, cent, 0); + } + } else { + fWeights->fill(phi, eta, vtxz, pt, cent, 0); + } + } + if (!setCurrentParticleWeights(weff, wacc, phi, eta, pt, vtxz)) { + continue; + } + registry.fill(HIST("hPt"), track.pt()); + if (withinPtRef) { + registry.fill(HIST("hPhi"), phi); + registry.fill(HIST("hPhiWeighted"), phi, wacc); + registry.fill(HIST("hEta"), eta); + registry.fill(HIST("hPtRef"), pt); + // registry.fill(HIST("hChi2prTPCcls"), track.tpcChi2NCl()); + // registry.fill(HIST("hChi2prITScls"), track.itsChi2NCl()); + // registry.fill(HIST("hnTPCClu"), track.tpcNClsFound()); + // registry.fill(HIST("hnITSClu"), track.itsNCls()); + // registry.fill(HIST("hnTPCCrossedRow"), track.tpcNClsCrossedRows()); + registry.fill(HIST("hDCAz"), track.dcaZ(), track.pt()); + registry.fill(HIST("hDCAxy"), track.dcaXY(), track.pt()); + nTracksCorrected += weff; + } + if (withinPtRef) { + fGFW->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 1); + } + if (withinPtPOI) { + fGFW->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 2); + } + if (withinPtPOI && withinPtRef) { + fGFW->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 4); + } + } + registry.fill(HIST("hTrackCorrection2d"), tracks.size(), nTracksCorrected); + + // Filling Flow Container + for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { + fillFC(corrconfigs.at(l_ind), independent, lRandom); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/Tasks/polarisationRho.cxx b/PWGUD/Tasks/polarisationRho.cxx index 994c921a6df..c10e86baad6 100644 --- a/PWGUD/Tasks/polarisationRho.cxx +++ b/PWGUD/Tasks/polarisationRho.cxx @@ -11,7 +11,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include "TLorentzVector.h" diff --git a/PWGUD/Tasks/sgD0Analyzer.cxx b/PWGUD/Tasks/sgD0Analyzer.cxx index b5c35b9deec..58b01cbe281 100644 --- a/PWGUD/Tasks/sgD0Analyzer.cxx +++ b/PWGUD/Tasks/sgD0Analyzer.cxx @@ -17,7 +17,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include "Common/DataModel/PIDResponse.h" diff --git a/PWGUD/Tasks/sgExclOmega.cxx b/PWGUD/Tasks/sgExclOmega.cxx index 3e24048e621..0a816e1dc0e 100644 --- a/PWGUD/Tasks/sgExclOmega.cxx +++ b/PWGUD/Tasks/sgExclOmega.cxx @@ -17,7 +17,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include "Common/DataModel/PIDResponse.h" diff --git a/PWGUD/Tasks/sgExclusivePhi.cxx b/PWGUD/Tasks/sgExclusivePhi.cxx index 679d1677593..df10373e571 100644 --- a/PWGUD/Tasks/sgExclusivePhi.cxx +++ b/PWGUD/Tasks/sgExclusivePhi.cxx @@ -13,7 +13,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include "TLorentzVector.h" diff --git a/PWGUD/Tasks/sgExclusivePhiITSselections.cxx b/PWGUD/Tasks/sgExclusivePhiITSselections.cxx index 76c56e609f5..2d8bc72c0f6 100644 --- a/PWGUD/Tasks/sgExclusivePhiITSselections.cxx +++ b/PWGUD/Tasks/sgExclusivePhiITSselections.cxx @@ -13,7 +13,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include "TLorentzVector.h" diff --git a/PWGUD/Tasks/sgFourPiAnalyzer.cxx b/PWGUD/Tasks/sgFourPiAnalyzer.cxx index fb437863ed8..6a6abfc4628 100644 --- a/PWGUD/Tasks/sgFourPiAnalyzer.cxx +++ b/PWGUD/Tasks/sgFourPiAnalyzer.cxx @@ -17,7 +17,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include "PWGUD/Core/SGTrackSelector.h" diff --git a/PWGUD/Tasks/sgInclJpsi.cxx b/PWGUD/Tasks/sgInclJpsi.cxx index 7e0557ef5f0..f5001af7c10 100644 --- a/PWGUD/Tasks/sgInclJpsi.cxx +++ b/PWGUD/Tasks/sgInclJpsi.cxx @@ -17,7 +17,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include "Common/DataModel/PIDResponse.h" diff --git a/PWGUD/Tasks/sgSixPiAnalyzer.cxx b/PWGUD/Tasks/sgSixPiAnalyzer.cxx index 215c5d236a1..c3561ad7026 100644 --- a/PWGUD/Tasks/sgSixPiAnalyzer.cxx +++ b/PWGUD/Tasks/sgSixPiAnalyzer.cxx @@ -17,7 +17,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include "PWGUD/Core/SGTrackSelector.h" diff --git a/PWGUD/Tasks/sgSpectraAnalyzer.cxx b/PWGUD/Tasks/sgSpectraAnalyzer.cxx index cffb6014300..afd766e0992 100644 --- a/PWGUD/Tasks/sgSpectraAnalyzer.cxx +++ b/PWGUD/Tasks/sgSpectraAnalyzer.cxx @@ -17,7 +17,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include "PWGUD/Core/SGTrackSelector.h" diff --git a/PWGUD/Tasks/sgTwoPiAnalyzer.cxx b/PWGUD/Tasks/sgTwoPiAnalyzer.cxx index b7015745448..e1568bb1838 100644 --- a/PWGUD/Tasks/sgTwoPiAnalyzer.cxx +++ b/PWGUD/Tasks/sgTwoPiAnalyzer.cxx @@ -17,7 +17,7 @@ #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/O2DatabasePDGPlugin.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include "PWGUD/Core/SGTrackSelector.h" diff --git a/PWGUD/Tasks/sginclusivePhiKstarSD.cxx b/PWGUD/Tasks/sginclusivePhiKstarSD.cxx index 601de7ec349..4e139f0b763 100644 --- a/PWGUD/Tasks/sginclusivePhiKstarSD.cxx +++ b/PWGUD/Tasks/sginclusivePhiKstarSD.cxx @@ -8,24 +8,27 @@ // 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. -// \Single Gap Event Analyzer -// \author Sandeep Dudi, sandeep.dudi3@gmail.com -// \since May 2024 +// +/// \file sginclusivePhiKstarSD.cxx +/// \brief Single Gap Event Analyzer for phi and Kstar +/// \author Sandeep Dudi, sandeep.dudi3@gmail.com +/// \since May 2024 #include #include #include -#include #include #include "Math/Vector4D.h" #include "Math/Vector3D.h" #include "Math/GenVector/Boost.h" +#include "TPDGCode.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" #include "Framework/ASoAHelpers.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "ReconstructionDataFormats/Vertex.h" #include "PWGUD/DataModel/UDTables.h" @@ -40,119 +43,162 @@ using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; -#define mpion 0.1396 -#define mkaon 0.4937 -#define mproton 0.9383 -#define mmuon 0.1057 +using namespace o2::constants::physics; -struct SGResonanceAnalyzer { +struct SginclusivePhiKstarSD { SGSelector sgSelector; + Service pdg; + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - Configurable FV0_cut{"FV0", 50., "FV0A threshold"}; - Configurable FT0A_cut{"FT0A", 50., "FT0A threshold"}; - Configurable FT0C_cut{"FT0C", 50., "FT0C threshold"}; - Configurable FDDA_cut{"FDDA", 10000., "FDDA threshold"}; - Configurable FDDC_cut{"FDDC", 10000., "FDDC threshold"}; - Configurable ZDC_cut{"ZDC", 0., "ZDC threshold"}; + Configurable cutRCTflag{"cutRCTflag", 0, {"0 = off, 1 = CBT, 2 = CBT+ZDC, 3 = CBThadron, 4 = CBThadron+ZDC"}}; + Configurable fv0Cut{"fv0Cut", 50., "FV0A threshold"}; + Configurable ft0aCut{"ft0aCut", 100., "FT0A threshold"}; + Configurable ft0cCut{"ft0cCut", 50., "FT0C threshold"}; + Configurable fddaCut{"fddaCut", 10000., "FDDA threshold"}; + Configurable fddcCut{"fddcCut", 10000., "FDDC threshold"}; + Configurable zdcCut{"zdcCut", 0., "ZDC threshold"}; + Configurable vzCut{"vzCut", 10., "Vz position"}; + Configurable occCut{"occCut", 1000., "Occupancy cut"}; + Configurable hadronicRate{"hadronicRate", 1000., "hadronicRate cut"}; + Configurable useTrs{"useTrs", -1, "kNoCollInTimeRangeStandard cut"}; + Configurable useTrofs{"useTrofs", -1, "kNoCollInRofStandard cut"}; + Configurable useHmpr{"useHmpr", -1, "kNoHighMultCollInPrevRof cut"}; + Configurable useTfb{"useTfb", -1, "kNoTimeFrameBorder cut"}; + Configurable useItsrofb{"useItsrofb", -1, "kNoITSROFrameBorder cut"}; + Configurable useSbp{"useSbp", -1, "kNoSameBunchPileup cut"}; + Configurable useZvtxftovpv{"useZvtxftovpv", -1, "kIsGoodZvtxFT0vsPV cut"}; + Configurable useVtxItsTpc{"useVtxItsTpc", -1, "kIsVertexITSTPC cut"}; + Configurable upcflag{"upcflag", -1, "upc run selection, 0 = std, 1= upc"}; // Track Selections - Configurable PV_cut{"PV_cut", 1.0, "Use Only PV tracks"}; - Configurable dcaZ_cut{"dcaZ_cut", 2.0, "dcaZ cut"}; - Configurable dcaXY_cut{"dcaXY_cut", 0.0, "dcaXY cut (0 for Pt-function)"}; - Configurable tpcChi2_cut{"tpcChi2_cut", 4, "Max tpcChi2NCl"}; - Configurable tpcNClsFindable_cut{"tpcNClsFindable_cut", 70, "Min tpcNClsFindable"}; - Configurable itsChi2_cut{"itsChi2_cut", 36, "Max itsChi2NCl"}; - Configurable eta_cut{"eta_cut", 0.9, "Track Pseudorapidity"}; - Configurable pt_cut{"pt_cut", 0.15, "Track pt cut"}; + Configurable pvCut{"pvCut", 1.0, "Use Only PV tracks"}; + Configurable dcazCut{"dcazCut", 2.0, "dcaZ cut"}; + Configurable dcaxyCut{"dcaxyCut", 0.0, "dcaXY cut (0 for Pt-function)"}; + Configurable tpcChi2Cut{"tpcChi2Cut", 4, "Max tpcChi2NCl"}; + Configurable tpcNClsFindableCut{"tpcNClsFindableCut", 70, "Min tpcNClsFindable"}; + Configurable itsChi2Cut{"itsChi2Cut", 36, "Max itsChi2NCl"}; + Configurable etaCut{"etaCut", 0.9, "Track Pseudorapidity"}; + Configurable ptCut{"ptCut", 0.15, "Track pt cut"}; Configurable pt1{"pt1", 0.3, "pid selection pt1"}; Configurable pt2{"pt2", 0.4, "pid selection pt2"}; Configurable pt3{"pt3", 0.5, "pid selection pt3"}; - Configurable EtaGapMin{"EtaGapMin", 0.0, "Track eta min"}; - Configurable EtaGapMax{"EtaGapMax", 0.9, "Track eta min"}; - Configurable EtaDG{"EtaDG", 0.5, "Track eta DG"}; + Configurable etaGapMin{"etaGapMin", 0.0, "Track eta min"}; + Configurable etaGapMax{"etaGapMax", 0.9, "Track eta max"}; + Configurable etaDG{"etaDG", 0.5, "Track eta DG"}; - Configurable nsigmatpc_cut1{"nsigmatpc1", 3.0, "nsigma tpc cut1"}; - Configurable nsigmatpc_cut2{"nsigmatpc2", 3.0, "nsigma tpc cut2"}; - Configurable nsigmatpc_cut3{"nsigmatpc3", 3.0, "nsigma tpc cut3"}; - Configurable nsigmatpc_cut{"nsigmatpc", 3.0, "nsigma tpc cut"}; - Configurable nsigmatof_cut{"nsigmatof", 9.0, "nsigma tof cut"}; + Configurable nsigmaTpcCut1{"nsigmaTpcCut1", 3.0, "nsigma tpc cut1"}; + Configurable nsigmaTpcCut2{"nsigmaTpcCut2", 3.0, "nsigma tpc cut2"}; + Configurable nsigmaTpcCut3{"nsigmaTpcCut3", 3.0, "nsigma tpc cut3"}; + Configurable nsigmaTpcCut{"nsigmaTpcCut", 3.0, "nsigma tpc cut"}; + Configurable nsigmaTofCut{"nsigmaTofCut", 9.0, "nsigma tpc+tof cut"}; + Configurable nsigmaTofCut1{"nsigmaTofCut1", 3.0, "nsigma tof cut"}; + Configurable pionNsigmaCut{"pionNsigmaCut", 3.0, "nsigma tpc cut for kaon"}; - Configurable mintrack{"min_track", 1, "min track"}; - Configurable maxtrack{"max_track", 50, "max track"}; - Configurable use_tof{"Use_TOF", true, "TOF PID"}; - Configurable QA{"QA", true, ""}; - Configurable rapidity_gap{"rapidity_gap", true, ""}; + Configurable mintrack{"mintrack", 1, "min track"}; + Configurable maxtrack{"maxtrack", 50, "max track"}; + Configurable useTof{"useTof", true, "TOF PID"}; + Configurable ccut{"ccut", true, "TPC + TOF PID"}; + Configurable kaoncut{"kaoncut", true, " kaon slection cut for kstar "}; + + Configurable qa{"qa", true, ""}; + Configurable rapidityGap{"rapidityGap", true, ""}; + Configurable exclusive{"exclusive", false, "for double gap side "}; Configurable phi{"phi", true, ""}; Configurable rho{"rho", true, ""}; Configurable kstar{"kstar", true, ""}; Configurable fourpion{"fourpion", true, ""}; + Configurable mc{"mc", true, ""}; + Configurable gapsideMC{"gapsideMC", 1, "gapside MC"}; Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 1, "Number of mixed events per event"}; Configurable nBkgRotations{"nBkgRotations", 9, "Number of rotated copies (background) per each original candidate"}; Configurable fillRotation{"fillRotation", true, "fill rotation"}; - Configurable confMinRot{"confMinRot", 5.0 * TMath::Pi() / 6.0, "Minimum of rotation"}; - Configurable confMaxRot{"confMaxRot", 7.0 * TMath::Pi() / 6.0, "Maximum of rotation"}; + Configurable confMinRot{"confMinRot", 5.0 * o2::constants::math::PI / 6.0, "Minimum of rotation"}; + Configurable confMaxRot{"confMaxRot", 7.0 * o2::constants::math::PI / 6.0, "Maximum of rotation"}; + // + Configurable reconstruction{"reconstruction", true, ""}; + Configurable generatedId{"generatedId", 31, ""}; + + // Configurable axes for histogram + ConfigurableAxis dcaAxisConfig{"dcaAxisConfig", {600, -0.3f, 0.3f}, "DCAxy & DCAz axis"}; + ConfigurableAxis etaAxisConfig{"etaAxisConfig", {400, -1.0f, 1.0f}, "Pseudorapidity & Rapidity axis"}; + ConfigurableAxis vrtxXAxisConfig{"vrtxXAxisConfig", {400, -0.1f, 0.1f}, "Vertex X axis"}; + ConfigurableAxis vrtxYAxisConfig{"vrtxYAxisConfig", {200, -0.05f, 0.05f}, "Vertex Y axis"}; + ConfigurableAxis vrtxZAxisConfig{"vrtxZAxisConfig", {600, -15.0f, 15.0f}, "Vertex Z axis"}; + // ConfigurableAxis VrtxZAxisConfig{"VrtxZAxisConfig", {600, -15.0f, 15.0f}, "Vertex Z axis"}; - void init(InitContext const&) + void init(InitContext const& context) { + // Axes + AxisSpec dcaxyAxis = {dcaAxisConfig, "DCAxy (cm)"}; + AxisSpec dcazAxis = {dcaAxisConfig, "DCAz (cm)"}; + AxisSpec etaAxis = {etaAxisConfig, "#eta"}; + AxisSpec rapAxis = {etaAxisConfig, "y"}; + AxisSpec VrtxXAxis = {vrtxXAxisConfig, "Vertex X (cm)"}; + AxisSpec VrtxYAxis = {vrtxYAxisConfig, "Vertex Y (cm)"}; + AxisSpec VrtxZAxis = {vrtxZAxisConfig, "Vertex Z (cm)"}; + registry.add("GapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); registry.add("TrueGapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); + registry.add("nPVContributors_data", "Multiplicity_dist_before track cut gap A", kTH1F, {{110, 0, 110}}); + registry.add("nPVContributors_data_1", "Multiplicity_dist_before track cut gap C", kTH1F, {{110, 0, 110}}); + if (phi) { registry.add("os_KK_pT_0", "pt kaon pair", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_KK_pT_1", "pt kaon pair", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_KK_pT_2", "pt kaon pair", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_KK_pT_2", "pt kaon pair", kTH3F, {{305, 0.98, 2.2}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_KK_ls_pT_0", "kaon pair like sign", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_KK_ls_pT_1", "kaon pair like sign", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_KK_ls_pT_2", "kaon pair like sign", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_KK_ls_pT_2", "kaon pair like sign", kTH3F, {{305, 0.98, 2.2}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_KK_mix_pT_0", "kaon pair mix event", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_KK_mix_pT_1", "kaon pair mix event", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_KK_mix_pT_2", "kaon pair mix event", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_KK_mix_pT_2", "kaon pair mix event", kTH3F, {{305, 0.98, 2.2}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_KK_rot_pT_0", "kaon pair mix event", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_KK_rot_pT_1", "kaon pair mix event", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_KK_rot_pT_2", "kaon pair mix event", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_KK_rot_pT_2", "kaon pair mix event", kTH3F, {{305, 0.98, 2.2}, {80, -2.0, 2.0}, {100, 0, 10}}); } if (rho) { - registry.add("os_pp_pT_0", "pt pion pair", kTH3F, {{120, 1.44, 2.04}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_pp_pT_1", "pt pion pair", kTH3F, {{120, 1.44, 2.04}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_pp_pT_2", "pt pion pair", kTH3F, {{120, 1.44, 2.04}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_pp_ls_pT_0", "pion pair like sign", kTH3F, {{120, 1.44, 2.04}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_pp_ls_pT_1", "pion pair like sign", kTH3F, {{120, 1.44, 2.04}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_pp_ls_pT_2", "pion pair like sign", kTH3F, {{120, 1.44, 2.04}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pp_pT_0", "pt pion pair", kTH3F, {{200, 1.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pp_pT_1", "pt pion pair", kTH3F, {{200, 1.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pp_pT_2", "pt pion pair", kTH3F, {{200, 1.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pp_ls_pT_0", "pion pair like sign", kTH3F, {{200, 1.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pp_ls_pT_1", "pion pair like sign", kTH3F, {{200, 1.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pp_ls_pT_2", "pion pair like sign", kTH3F, {{200, 1.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); } if (kstar) { registry.add("os_pk_pT_0", "pion-kaon pair", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_pk_pT_1", "pion-kaon pair", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_pk_pT_2", "pion-kaon pair", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pk_pT_2", "pion-kaon pair", kTH3F, {{600, 0.0, 3.0}, {80, -2.0, 2.0}, {1000, 0, 10}}); registry.add("os_pk_mix_pT_0", "pion-kaon mix pair", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_pk_mix_pT_1", "pion-kaon mix pair", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_pk_mix_pT_2", "pion-kaon mix pair", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pk_mix_pT_2", "pion-kaon mix pair", kTH3F, {{600, 0.0, 3.0}, {80, -2.0, 2.0}, {1000, 0, 10}}); registry.add("os_pk_rot_pT_0", "pion-kaon rotional pair", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_pk_rot_pT_1", "pion-kaon rotional pair", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_pk_rot_pT_2", "pion-kaon rotional pair", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pk_rot_pT_2", "pion-kaon rotional pair", kTH3F, {{600, 0.0, 3.0}, {80, -2.0, 2.0}, {1000, 0, 10}}); registry.add("os_pk_ls_pT_0", "pion-kaon pair like sign", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_pk_ls_pT_1", "pion-kaon like sign", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_pk_ls_pT_2", "pion-kaon like sign", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_pk_ls_pT_2", "pion-kaon like sign", kTH3F, {{600, 0.0, 3.0}, {80, -2.0, 2.0}, {1000, 0, 10}}); - registry.add("hRotation", "hRotation", kTH1F, {{360, 0.0, 2.0 * TMath::Pi()}}); + registry.add("hRotation", "hRotation", kTH1F, {{360, 0.0, o2::constants::math::TwoPI}}); } - // QA plots - if (QA) { - registry.add("tpc_dedx", "p vs dE/dx", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); - registry.add("tof_beta", "p vs beta", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); - - registry.add("tpc_dedx_kaon", "p#k dE/dx", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); - registry.add("tpc_dedx_pion", "p#pi dE/dx", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); - registry.add("tpc_dedx_kaon_1", "tpc+tof pid cut p#k dE/dx", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); - registry.add("tpc_dedx_kaon_2", "tpc+tof pid cut1 p#k dE/dx", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); - registry.add("tpc_dedx_pion_1", "tpc+tof pid cut p#pi dE/dx", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + // qa plots + if (qa) { + registry.add("tpc_dedx", "p vs dE/dx", kTH2F, {{500, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + registry.add("tof_beta", "p vs beta", kTH2F, {{500, 0.0, 10.0}, {500, 0.0, 1.0}}); + + registry.add("tpc_dedx_kaon", "p#k dE/dx", kTH2F, {{500, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + registry.add("tpc_dedx_pion", "p#pi dE/dx", kTH2F, {{500, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + registry.add("tpc_dedx_kaon_1", "tpc+tof pid cut p#k dE/dx", kTH2F, {{500, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + registry.add("tpc_dedx_kaon_2", "tpc+tof pid cut1 p#k dE/dx", kTH2F, {{500, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + registry.add("tpc_dedx_pion_1", "tpc+tof pid cut p#pi dE/dx", kTH2F, {{500, 0.0, 10.0}, {5000, 0.0, 5000.0}}); registry.add("tpc_nsigma_kaon", "p#k n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); registry.add("tpc_nsigma_pion", "p#pi n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); registry.add("tpc_tof_nsigma_kaon", "p#k n#sigma TPC vs TOF", kTH2F, {{100, -10.0, 10.0}, {100, -10.0, 10.0}}); @@ -160,6 +206,10 @@ struct SGResonanceAnalyzer { registry.add("tof_nsigma_kaon", "p#k n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); registry.add("tof_nsigma_pion", "p#pi n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tof_nsigma_kaon_f", "p#k n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tof_nsigma_pion_f", "p#pi n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tpc_nsigma_kaon_f", "p#k n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tpc_nsigma_pion_f", "p#pi n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); registry.add("FT0A", "T0A amplitude", kTH1F, {{500, 0.0, 500.0}}); registry.add("FT0A_0", "T0A amplitude", kTH1F, {{500, 0.0, 500.0}}); @@ -176,10 +226,33 @@ struct SGResonanceAnalyzer { registry.add("V0A", "V0A amplitude", kTH1F, {{1000, 0.0, 1000.0}}); registry.add("V0A_0", "V0A amplitude", kTH1F, {{1000, 0.0, 1000.0}}); registry.add("V0A_1", "V0A amplitude", kTH1F, {{1000, 0.0, 1000.0}}); - if (rapidity_gap) { - registry.add("mult_0", "mult0", kTH1F, {{150, 0, 150}}); - registry.add("mult_1", "mult1", kTH1F, {{150, 0, 150}}); - registry.add("mult_2", "mult2", kTH1F, {{150, 0, 150}}); + + registry.add("hDcaxy_all_before", "DCAxy Distribution of all tracks before track selection; DCAxy (cm); Counts", kTH1F, {dcaxyAxis}); + registry.add("hDcaz_all_before", "DCAz Distribution of all tracks before track selection; DCAz (cm); Counts", kTH1F, {dcazAxis}); + + registry.add("hDcaxy_all_after", "DCAxy Distribution of all tracks after track selection; DCAxy (cm); Counts", kTH1F, {dcaxyAxis}); + registry.add("hDcaz_all_after", "DCAz Distribution of all tracks after track selection; DCAz (cm); Counts", kTH1F, {dcazAxis}); + + registry.add("hDcaxy_pi", "DCAxy Distribution of selected pions; DCAxy (cm); Counts", kTH1F, {dcaxyAxis}); + registry.add("hDcaz_pi", "DCAz Distribution of selected pions; DCAz (cm); Counts", kTH1F, {dcazAxis}); + + registry.add("hDcaxy_ka", "DCAxy Distribution of selected kaons; DCAxy (cm); Counts", kTH1F, {dcaxyAxis}); + registry.add("hDcaz_ka", "DCAz Distribution of selected kaons; DCAz (cm); Counts", kTH1F, {dcazAxis}); + + registry.add("hVertexX", "Vertex X distribution; Vertex X (cm); Counts", kTH1F, {VrtxXAxis}); + registry.add("hVertexY", "Vertex Y distribution; Vertex Y (cm); Counts", kTH1F, {VrtxYAxis}); + registry.add("hVertexZ", "VertexZ distribution; Vertex Z (cm); Counts", kTH1F, {VrtxZAxis}); + + registry.add("hEta_all_after", "Pseudorapidity of all tracks after track selection; #eta; Counts", kTH1F, {etaAxis}); + registry.add("hRap_all_after", "Rapidity of all tracks after track selection; y; Counts", kTH1F, {rapAxis}); + + registry.add("hEta_pi", "Pseudorapidity of selected Pions; #eta; Counts", kTH1F, {etaAxis}); + registry.add("hRap_pi", "Rapidity of selected Pions; y; Counts", kTH1F, {rapAxis}); + + registry.add("hEta_ka", "Pseudorapidity of selected Kaons; #eta; Counts", kTH1F, {etaAxis}); + registry.add("hRap_ka", "Rapidity of selected Kaons; y; Counts", kTH1F, {rapAxis}); + + if (rapidityGap) { registry.add("event_rap_gap", "rap_gap", kTH1F, {{15, 0, 15.0}}); registry.add("rap_mult1", "rap_mult1", kTH1F, {{150, 0, 150}}); registry.add("rap_mult2", "rap_mult2", kTH1F, {{150, 0, 150}}); @@ -192,12 +265,16 @@ struct SGResonanceAnalyzer { registry.add("rap2_mult3", "rap2_mult3", kTH1F, {{150, 0, 150}}); } } - registry.add("gap_mult0", "Mult 0", kTH1F, {{100, 0.0, 100.0}}); registry.add("gap_mult1", "Mult 1", kTH1F, {{100, 0.0, 100.0}}); registry.add("gap_mult2", "Mult 2", kTH1F, {{100, 0.0, 100.0}}); + + registry.add("mult_0", "mult0", kTH1F, {{150, 0, 150}}); + registry.add("mult_1", "mult1", kTH1F, {{150, 0, 150}}); + registry.add("mult_2", "mult2", kTH1F, {{150, 0, 150}}); + // Multiplicity plot - if (rapidity_gap && phi) { + if (rapidityGap && phi) { registry.add("os_kk_mass_rap", "phi mass1", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_kk_mass_rap1", "phi mass2", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_kk_mass_rap2", "phi mass3", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); @@ -220,7 +297,7 @@ struct SGResonanceAnalyzer { registry.add("os_kk_ls_mass2_rap2", "phi ls mass3 DG", kTH3F, {{220, 0.98, 1.2}, {80, -2.0, 2.0}, {100, 0, 10}}); } - if (rapidity_gap && kstar) { + if (rapidityGap && kstar) { registry.add("os_kp_mass_rap", "kstar mass1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_kp_mass_rap1", "kstar mass2", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); registry.add("os_kp_mass_rap2", "kstar mass3", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); @@ -257,57 +334,191 @@ struct SGResonanceAnalyzer { registry.add("costheta_dis1", "costheta_dis1", kTH1F, {{40, -1.0, 1.0}}); registry.add("costheta_vs_phi1", "costheta_vs_phi1", kTH2F, {{40, -1.0, 1.0}, {360, 0.0, 6.28}}); } + if (mc) { + // add histograms for the different process functions + if (context.mOptions.get("processMCTruth")) { + registry.add("MC/Stat", "Count generated events; ; Entries", {HistType::kTH1F, {{1, -0.5, 0.5}}}); + registry.add("MC/recCols", "Number of reconstructed collisions; Number of reconstructed collisions; Entries", {HistType::kTH1F, {{31, -0.5, 30.5}}}); + registry.add("MC/nParts", "Number of McParticles per collision; Number of McParticles; Entries", {HistType::kTH1F, {{1001, -0.5, 1000.5}}}); + registry.add("MC/nRecTracks", "Number of reconstructed tracks per McParticle; Number of reconstructed tracks per McParticle; Entries", {HistType::kTH1F, {{11, -0.5, 10.5}}}); + registry.add("MC/genEtaPt", "Generated events; eta (1); Pt (GeV/c)", {HistType::kTH2F, {{60, -1.5, 1.5}, {250, 0.0, 5.0}}}); + registry.add("MC/genRap", "Generated events; Rapidity (1)", {HistType::kTH1F, {{60, -1.5, 1.5}}}); + registry.add("MC/genMPt", "Generated events; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH2F, {{220, 0.98, 1.2}, {200, 0.0, 10.0}}}); + registry.add("MC/genM", "Generated events; Mass (GeV/c^2)", {HistType::kTH1F, {{220, 0.98, 1.2}}}); + registry.add("MC/genM_1", "Generated events; Mass (GeV/c^2)", {HistType::kTH1F, {{220, 0.98, 1.2}}}); + + registry.add("MC/accMPtRap_phi_G", "Generated Phi; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{220, 0.98, 1.20}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + + registry.add("MC/accEtaPt", "Generated events in acceptance; eta (1); Pt (GeV/c)", {HistType::kTH2F, {{60, -1.5, 1.5}, {250, 0.0, 5.0}}}); + registry.add("MC/accRap", "Generated events in acceptance; Rapidity (1)", {HistType::kTH1F, {{60, -1.5, 1.5}}}); + registry.add("MC/accMPt", "Generated events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH2F, {{220, 0.98, 1.20}, {200, 0.0, 10.0}}}); + registry.add("MC/accMPtRap", "Generated events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{220, 0.98, 1.20}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + registry.add("MC/accM", "Generated events in acceptance; Mass (GeV/c^2)", {HistType::kTH1F, {{220, 0.98, 1.20}}}); + registry.add("MC/selRap", "Selected events in acceptance; Rapidity (1)", {HistType::kTH1F, {{60, -1.5, 1.5}}}); + registry.add("MC/selMPt", "Selected events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH2F, {{250, 2.5, 5.0}, {100, 0.0, 1.0}}}); + registry.add("MC/pDiff", "McTruth - reconstructed track momentum; McTruth - reconstructed track momentum; Entries", {HistType::kTH2F, {{240, -6., 6.}, {3, -1.5, 1.5}}}); + // K*0 + registry.add("MC/accMPtRap_kstar_G", "Generated K*0; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{400, 0., 2.0}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + registry.add("MC/genEtaPt_k", "Generated events; eta (1); Pt (GeV/c)", {HistType::kTH2F, {{60, -1.5, 1.5}, {250, 0.0, 5.0}}}); + registry.add("MC/genRap_k", "Generated events; Rapidity (1)", {HistType::kTH1F, {{60, -1.5, 1.5}}}); + registry.add("MC/genMPt_k", "Generated events; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH2F, {{400, 0., 2.0}, {200, 0.0, 10.0}}}); + registry.add("MC/genM_k", "Generated events; Mass (GeV/c^2)", {HistType::kTH1F, {{400, 0., 2.0}}}); + registry.add("MC/genM_1_k", "Generated events; Mass (GeV/c^2)", {HistType::kTH1F, {{400, 0., 2.0}}}); + + registry.add("MC/accEtaPt_k", "Generated events in acceptance; eta (1); Pt (GeV/c)", {HistType::kTH2F, {{60, -1.5, 1.5}, {250, 0.0, 5.0}}}); + registry.add("MC/accRap_k", "Generated events in acceptance; Rapidity (1)", {HistType::kTH1F, {{60, -1.5, 1.5}}}); + registry.add("MC/accMPt_k", "Generated events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH2F, {{400, 0., 2.0}, {200, 0.0, 10.0}}}); + registry.add("MC/accMPtRap_k", "Generated events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{400, 0., 2.0}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + registry.add("MC/accM_k", "Generated events in acceptance; Mass (GeV/c^2)", {HistType::kTH1F, {{400, 0., 2.0}}}); + } + if (context.mOptions.get("processReco")) { + registry.add("Reco/Stat", "Count reconstruted events; ; Entries", {HistType::kTH1F, {{5, -0.5, 4.5}}}); + registry.add("Reco/nPVContributors", "Number of PV contributors per collision; Number of PV contributors; Entries", {HistType::kTH1F, {{51, -0.5, 50.5}}}); + registry.add("Reco/selRap", "Selected events in acceptance; Rapidity (1)", {HistType::kTH1F, {{60, -1.5, 1.5}}}); + registry.add("Reco/selMPt", "Reconstructed events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH2F, {{220, 0.98, 1.20}, {200, 0.0, 10.0}}}); + registry.add("Reco/selMPtRap", "Reconstructed events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{220, 0.98, 1.20}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + registry.add("Reco/selMPtRap_gen", "Reconstructed(gen) events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{220, 0.98, 1.20}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + registry.add("MC/accMPtRap_phi_T", "Reconstrcted Phi; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{220, 0.98, 1.20}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + registry.add("MC/accMPtRap_kstar_T", "Reconstructed K*0; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{400, 0., 2.0}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + + registry.add("Reco/selPt", "Reconstructed events in acceptance;Pt (GeV/c)", {HistType::kTH1F, {{200, 0.0, 10.0}}}); + registry.add("Reco/selM", "Reconstructed events in acceptance; Mass (GeV/c^2); ", {HistType::kTH1F, {{220, 0.98, 1.20}}}); + registry.add("Reco/mcEtaPt", "Generated events in acceptance; eta (1); Pt (GeV/c)", {HistType::kTH2F, {{60, -1.5, 1.5}, {250, 0.0, 5.0}}}); + registry.add("Reco/mcRap", "Generated events in acceptance; Rapidity (1)", {HistType::kTH1F, {{60, -1.5, 1.5}}}); + registry.add("Reco/mcMPt", "Generated events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH2F, {{250, 2.5, 5.0}, {100, 0.0, 1.0}}}); + registry.add("Reco/pDiff", "McTruth - reconstructed track momentum; McTruth - reconstructed track momentum; Entries", {HistType::kTH2F, {{240, -6., 6.}, {3, -1.5, 1.5}}}); + + registry.add("Reco/selRap_k", "Selected events in acceptance; Rapidity (1)", {HistType::kTH1F, {{60, -1.5, 1.5}}}); + registry.add("Reco/selMPt_k", "Reconstructed events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH2F, {{400, 0., 2.0}, {200, 0.0, 10.0}}}); + registry.add("Reco/selMPtRap_k", "Reconstructed events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{400, 0., 2.0}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + registry.add("Reco/selMPtRap_k_gen", "Reconstructed(gen) events in acceptance; Mass (GeV/c^2); Pt (GeV/c)", {HistType::kTH3F, {{400, 0., 2.0}, {200, 0.0, 10.0}, {60, -1.5, 1.5}}}); + registry.add("Reco/selPt_k", "Reconstructed events in acceptance;Pt (GeV/c)", {HistType::kTH1F, {{200, 0.0, 10.0}}}); + registry.add("Reco/selM_k", "Reconstructed events in acceptance; Mass (GeV/c^2); ", {HistType::kTH1F, {{400, 0., 2.0}}}); + registry.add("Reco/selM_k_K", "Reconstructed events in acceptance; Mass (GeV/c^2); ", {HistType::kTH1F, {{400, 0., 2.0}}}); + + registry.add("Reco/nTracks", "Number of reconstructed tracks per collision; Number of reconstructed tracks; Entries", {HistType::kTH1F, {{101, -0.5, 100.5}}}); + registry.add("Reco/treta_k", "track kaon eta", {HistType::kTH1F, {{200, -5.0, 5.0}}}); + registry.add("Reco/trpt_k", "rec kaon track pt", {HistType::kTH1F, {{200, 0.0, 10.0}}}); + registry.add("Reco/trpt", "rec track pt", {HistType::kTH1F, {{200, 0.0, 10.0}}}); + + registry.add("Reco/tr_dcaz_1", "dcaz-", {HistType::kTH1F, {{1000, -5.0, 5.0}}}); + registry.add("Reco/tr_dcaxy_1", "dcaxy-", {HistType::kTH1F, {{1000, -5.0, 5.0}}}); + registry.add("Reco/tr_chi2ncl_1", "chi2ncl-", {HistType::kTH1F, {{100, 0.0, 100.0}}}); + registry.add("Reco/tr_tpcnclfind_1", "tpcnclfind-", {HistType::kTH1F, {{300, 0.0, 300.0}}}); + registry.add("Reco/tr_itsChi2NCl_1", "itsChi2NCl-", {HistType::kTH1F, {{200, 0.0, 200.0}}}); + registry.add("Reco/tr_Eta_1", " eta -", {HistType::kTH1F, {{300, 1.5, 1.5}}}); + + registry.add("Reco/tr_dcaz_2", "dcaz", {HistType::kTH1F, {{1000, -5.0, 5.0}}}); + registry.add("Reco/tr_dcaxy_2", "dcaxy", {HistType::kTH1F, {{1000, -5.0, 5.0}}}); + registry.add("Reco/tr_chi2ncl_2", "chi2ncl", {HistType::kTH1F, {{100, 0.0, 100.0}}}); + registry.add("Reco/tr_tpcnclfind_2", "tpcnclfind", {HistType::kTH1F, {{300, 0.0, 300.0}}}); + registry.add("Reco/tr_itsChi2NCl_2", "itsChi2NCl", {HistType::kTH1F, {{200, 0.0, 200.0}}}); + + // qa + registry.add("tpc_dedx_mc", "p vs dE/dx", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + registry.add("tof_beta_mc", "p vs beta", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + + registry.add("tpc_dedx_kaon_mc", "p#k dE/dx", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + registry.add("tpc_dedx_pion_mc", "p#pi dE/dx", kTH2F, {{100, 0.0, 10.0}, {5000, 0.0, 5000.0}}); + registry.add("tpc_nsigma_kaon_mc", "p#k n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tpc_nsigma_pion_mc", "p#pi n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + + registry.add("tpc_tof_nsigma_kaon_mc", "p#k n#sigma TPC vs TOF", kTH2F, {{100, -10.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tpc_tof_nsigma_pion_mc", "p#pi n#sigma TPC vs TOF", kTH2F, {{100, -10.0, 10.0}, {100, -10.0, 10.0}}); + + registry.add("tof_nsigma_kaon_mc", "p#k n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tof_nsigma_pion_mc", "p#pi n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tof_nsigma_kaon_f_mc", "p#k n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tof_nsigma_pion_f_mc", "p#pi n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + + registry.add("tpc_nsigma_kaon_f_mc", "p#k n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + registry.add("tpc_nsigma_pion_f_mc", "p#pi n#sigma", kTH2F, {{100, 0.0, 10.0}, {100, -10.0, 10.0}}); + + registry.add("FT0A_0_mc", "T0A amplitude", kTH1F, {{500, 0.0, 500.0}}); + registry.add("FT0A_1_mc", "T0A amplitude", kTH1F, {{20000, 0.0, 20000.0}}); + registry.add("FT0C_0_mc", "T0C amplitude", kTH1F, {{20000, 0.0, 20000.0}}); + registry.add("FT0C_1_mc", "T0C amplitude", kTH1F, {{500, 0.0, 500.0}}); + registry.add("ZDC_A_0_mc", "ZDC amplitude", kTH1F, {{2000, 0.0, 1000.0}}); + registry.add("ZDC_A_1_mc", "ZDC amplitude", kTH1F, {{2000, 0.0, 1000.0}}); + registry.add("ZDC_C_0_mc", "ZDC amplitude", kTH1F, {{2000, 0.0, 1000.0}}); + registry.add("ZDC_C_1_mc", "ZDC amplitude", kTH1F, {{2000, 0.0, 1000.0}}); + registry.add("V0A_0_mc", "V0A amplitude", kTH1F, {{1000, 0.0, 1000.0}}); + registry.add("V0A_1_mc", "V0A amplitude", kTH1F, {{1000, 0.0, 1000.0}}); + } + } } //_____________________________________________________________________________ - Double_t CosThetaCollinsSoperFrame(ROOT::Math::PtEtaPhiMVector pair1, - ROOT::Math::PtEtaPhiMVector pair2, - ROOT::Math::PtEtaPhiMVector fourpion) + double cosThetaCollinsSoperFrame(ROOT::Math::PxPyPzMVector pair1, + ROOT::Math::PxPyPzMVector pair2, + ROOT::Math::PxPyPzMVector fourpion) { - Double_t HalfSqrtSnn = 2680.; - Double_t MassOfLead208 = 193.6823; - Double_t MomentumBeam = TMath::Sqrt(HalfSqrtSnn * HalfSqrtSnn * 208 * 208 - MassOfLead208 * MassOfLead208); + double halfSqrtSnn = 2680.; + double massOfLead208 = 193.6823; + double momentumBeam = std::sqrt(halfSqrtSnn * halfSqrtSnn * 208 * 208 - massOfLead208 * massOfLead208); - TLorentzVector pProjCM(0., 0., -MomentumBeam, HalfSqrtSnn * 208); // projectile - TLorentzVector pTargCM(0., 0., MomentumBeam, HalfSqrtSnn * 208); // target + ROOT::Math::PxPyPzEVector pProjCM(0., 0., -momentumBeam, halfSqrtSnn * 208); // projectile + ROOT::Math::PxPyPzEVector pTargCM(0., 0., momentumBeam, halfSqrtSnn * 208); // target - // TVector3 beta = (-1. / fourpion.E()) * fourpion.Vect(); - ROOT::Math::PtEtaPhiMVector v1 = pair1; - ROOT::Math::PtEtaPhiMVector v2 = pair2; - ROOT::Math::PtEtaPhiMVector v12 = fourpion; + ROOT::Math::PxPyPzMVector v1 = ROOT::Math::PxPyPzMVector(pair1.Px(), pair1.Py(), pair1.Pz(), pair1.M()); + ROOT::Math::PxPyPzMVector v2 = ROOT::Math::PxPyPzMVector(pair2.Px(), pair2.Py(), pair2.Pz(), pair2.M()); + ROOT::Math::PxPyPzMVector v12 = ROOT::Math::PxPyPzMVector(fourpion.Px(), fourpion.Py(), fourpion.Pz(), fourpion.M()); // Boost to center of mass frame ROOT::Math::Boost boostv12{v12.BoostToCM()}; - ROOT::Math::XYZVectorF v1_CM{(boostv12(v1).Vect()).Unit()}; - ROOT::Math::XYZVectorF v2_CM{(boostv12(v2).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam1_CM{(boostv12(pProjCM).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam2_CM{(boostv12(pTargCM).Vect()).Unit()}; - + ROOT::Math::XYZVectorF v1Cm{(boostv12(v1).Vect()).Unit()}; + ROOT::Math::XYZVectorF v2Cm{(boostv12(v2).Vect()).Unit()}; + ROOT::Math::XYZVectorF beam1Cm{(boostv12(pProjCM).Vect()).Unit()}; + ROOT::Math::XYZVectorF beam2Cm{(boostv12(pTargCM).Vect()).Unit()}; // Axes - ROOT::Math::XYZVectorF zaxis_CS{((Beam1_CM.Unit() - Beam2_CM.Unit()).Unit())}; + ROOT::Math::XYZVectorF zaxisCs{((beam1Cm.Unit() - beam2Cm.Unit()).Unit())}; - Double_t CosThetaCS = zaxis_CS.Dot((v1_CM)); - return CosThetaCS; + double cosThetaCs = zaxisCs.Dot((v1Cm)); + return cosThetaCs; + } + + template + bool isGoodRCTflag(C const& coll) + { + switch (cutRCTflag) { + case 1: + return sgSelector.isCBTOk(coll); + case 2: + return sgSelector.isCBTZdcOk(coll); + case 3: + return sgSelector.isCBTHadronOk(coll); + case 4: + return sgSelector.isCBTHadronZdcOk(coll); + default: + return true; + } } template bool selectionPIDKaon1(const T& candidate) { - auto pt = TMath::Sqrt(candidate.px() * candidate.px() + candidate.py() * candidate.py()); + auto pt = std::sqrt(candidate.px() * candidate.px() + candidate.py() * candidate.py()); // float pt1, pt2, pt3 , nsigmatpc_cut1, nsigmatpc_cut2, nsigmatpc_cut3; - if (use_tof && pt < pt1 && std::abs(candidate.tpcNSigmaKa()) < nsigmatpc_cut1) { + if (useTof && pt < pt1 && std::abs(candidate.tpcNSigmaKa()) < nsigmaTpcCut1) { + return true; + } + if (useTof && pt >= pt1 && pt < pt2 && std::abs(candidate.tpcNSigmaKa()) < nsigmaTpcCut2) { + return true; + } + if (useTof && pt >= pt2 && pt < pt3 && std::abs(candidate.tpcNSigmaKa()) < nsigmaTpcCut3) { return true; } - if (use_tof && pt >= pt1 && pt < pt2 && std::abs(candidate.tpcNSigmaKa()) < nsigmatpc_cut2) { + if (useTof && pt >= pt3 && !candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < nsigmaTpcCut) { return true; } - if (use_tof && pt >= pt2 && pt < pt3 && std::abs(candidate.tpcNSigmaKa()) < nsigmatpc_cut3) { + if (useTof && candidate.hasTOF() && ccut && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < nsigmaTofCut) { return true; } - if (pt > pt3 && use_tof && candidate.hasTOF() && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < nsigmatof_cut) { + if (useTof && candidate.hasTOF() && !ccut && std::abs(candidate.tpcNSigmaKa()) < nsigmaTpcCut && std::abs(candidate.tofNSigmaKa()) < nsigmaTofCut1) { return true; } - if (!use_tof && std::abs(candidate.tpcNSigmaKa()) < nsigmatpc_cut) { + + if (!useTof && std::abs(candidate.tpcNSigmaKa()) < nsigmaTpcCut) { return true; } return false; @@ -316,88 +527,121 @@ struct SGResonanceAnalyzer { template bool selectionPIDPion1(const T& candidate) { - auto pt = TMath::Sqrt(candidate.px() * candidate.px() + candidate.py() * candidate.py()); + auto pt = std::sqrt(candidate.px() * candidate.px() + candidate.py() * candidate.py()); - if (use_tof && pt < pt1 && std::abs(candidate.tpcNSigmaPi()) < nsigmatpc_cut1) { + if (useTof && pt < pt1 && std::abs(candidate.tpcNSigmaPi()) < nsigmaTpcCut1) { + return true; + } + if (useTof && pt >= pt1 && pt < pt2 && std::abs(candidate.tpcNSigmaPi()) < nsigmaTpcCut2) { + return true; + } + if (useTof && pt >= pt2 && pt < pt3 && std::abs(candidate.tpcNSigmaPi()) < nsigmaTpcCut3) { return true; } - if (use_tof && pt >= pt1 && pt < pt2 && std::abs(candidate.tpcNSigmaPi()) < nsigmatpc_cut2) { + if (useTof && pt >= pt3 && !candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < nsigmaTpcCut) { return true; } - if (use_tof && pt >= pt2 && pt < pt3 && std::abs(candidate.tpcNSigmaPi()) < nsigmatpc_cut3) { + if (useTof && candidate.hasTOF() && ccut && (candidate.tofNSigmaPi() * candidate.tofNSigmaPi() + candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi()) < nsigmaTofCut) { return true; } - if (pt > pt3 && use_tof && candidate.hasTOF() && (candidate.tofNSigmaPi() * candidate.tofNSigmaPi() + candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi()) < nsigmatof_cut) { + if (useTof && candidate.hasTOF() && !ccut && std::abs(candidate.tpcNSigmaPi()) < nsigmaTpcCut && std::abs(candidate.tofNSigmaPi()) < nsigmaTofCut1) { return true; } - if (!use_tof && std::abs(candidate.tpcNSigmaPi()) < nsigmatpc_cut) { + if (!useTof && std::abs(candidate.tpcNSigmaPi()) < nsigmaTpcCut) { return true; } return false; } //------------------------------------------------------------------------------------------------------ - Double_t PhiCollinsSoperFrame(ROOT::Math::PtEtaPhiMVector pair1, ROOT::Math::PtEtaPhiMVector pair2, ROOT::Math::PtEtaPhiMVector fourpion) + double phiCollinsSoperFrame(ROOT::Math::PxPyPzMVector pair1, ROOT::Math::PxPyPzMVector pair2, ROOT::Math::PxPyPzMVector fourpion) { // Half of the energy per pair of the colliding nucleons. - Double_t HalfSqrtSnn = 2680.; - Double_t MassOfLead208 = 193.6823; - Double_t MomentumBeam = TMath::Sqrt(HalfSqrtSnn * HalfSqrtSnn * 208 * 208 - MassOfLead208 * MassOfLead208); - - TLorentzVector pProjCM(0., 0., -MomentumBeam, HalfSqrtSnn * 208); // projectile - TLorentzVector pTargCM(0., 0., MomentumBeam, HalfSqrtSnn * 208); // target - ROOT::Math::PtEtaPhiMVector v1 = pair1; - ROOT::Math::PtEtaPhiMVector v2 = pair2; - ROOT::Math::PtEtaPhiMVector v12 = fourpion; + double halfSqrtSnn = 2680.; + double massOfLead208 = 193.6823; + double momentumBeam = std::sqrt(halfSqrtSnn * halfSqrtSnn * 208 * 208 - massOfLead208 * massOfLead208); + + ROOT::Math::PxPyPzEVector pProjCM(0., 0., -momentumBeam, halfSqrtSnn * 208); // projectile + ROOT::Math::PxPyPzEVector pTargCM(0., 0., momentumBeam, halfSqrtSnn * 208); // target + + ROOT::Math::PxPyPzMVector v1 = ROOT::Math::PxPyPzMVector(pair1.Px(), pair1.Py(), pair1.Pz(), pair1.M()); + ROOT::Math::PxPyPzMVector v2 = ROOT::Math::PxPyPzMVector(pair2.Px(), pair2.Py(), pair2.Pz(), pair2.M()); + ROOT::Math::PxPyPzMVector v12 = ROOT::Math::PxPyPzMVector(fourpion.Px(), fourpion.Py(), fourpion.Pz(), fourpion.M()); + // Boost to center of mass frame ROOT::Math::Boost boostv12{v12.BoostToCM()}; - ROOT::Math::XYZVectorF v1_CM{(boostv12(v1).Vect()).Unit()}; - ROOT::Math::XYZVectorF v2_CM{(boostv12(v2).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam1_CM{(boostv12(pProjCM).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam2_CM{(boostv12(pTargCM).Vect()).Unit()}; + ROOT::Math::XYZVectorF v1Cm{(boostv12(v1).Vect()).Unit()}; + ROOT::Math::XYZVectorF v2Cm{(boostv12(v2).Vect()).Unit()}; + ROOT::Math::XYZVectorF beam1Cm{(boostv12(pProjCM).Vect()).Unit()}; + ROOT::Math::XYZVectorF beam2Cm{(boostv12(pTargCM).Vect()).Unit()}; // Axes - ROOT::Math::XYZVectorF zaxis_CS{((Beam1_CM.Unit() - Beam2_CM.Unit()).Unit())}; - ROOT::Math::XYZVectorF yaxis_CS{(Beam1_CM.Cross(Beam2_CM)).Unit()}; - ROOT::Math::XYZVectorF xaxis_CS{(yaxis_CS.Cross(zaxis_CS)).Unit()}; + ROOT::Math::XYZVectorF zaxisCs{((beam1Cm.Unit() - beam2Cm.Unit()).Unit())}; + ROOT::Math::XYZVectorF yaxisCs{(beam1Cm.Cross(beam2Cm)).Unit()}; + ROOT::Math::XYZVectorF xaxisCs{(yaxisCs.Cross(zaxisCs)).Unit()}; - Double_t phi = TMath::ATan2(yaxis_CS.Dot(v1_CM), xaxis_CS.Dot(v1_CM)); + double phi = std::atan2(yaxisCs.Dot(v1Cm), xaxisCs.Dot(v1Cm)); return phi; } - using udtracks = soa::Join; - using udtracksfull = soa::Join; - using UDCollisionsFull = soa::Join; // + using UDtracksfull = soa::Join; + using UDCollisionsFull = soa::Join; // using UDCollisionFull = UDCollisionsFull::iterator; - void process(UDCollisionFull const& collision, udtracksfull const& tracks) + void process(UDCollisionFull const& collision, UDtracksfull const& tracks) { - TLorentzVector v0; - TLorentzVector v1; - TLorentzVector v01; - TLorentzVector v0_1; + ROOT::Math::PxPyPzMVector v0; + ROOT::Math::PxPyPzMVector v1; + ROOT::Math::PxPyPzMVector v01; int gapSide = collision.gapSide(); - float FIT_cut[5] = {FV0_cut, FT0A_cut, FT0C_cut, FDDA_cut, FDDC_cut}; - std::vector parameters = {PV_cut, dcaZ_cut, dcaXY_cut, tpcChi2_cut, tpcNClsFindable_cut, itsChi2_cut, eta_cut, pt_cut}; - int truegapSide = sgSelector.trueGap(collision, FIT_cut[0], FIT_cut[1], FIT_cut[2], ZDC_cut); + float fitCut[5] = {fv0Cut, ft0aCut, ft0cCut, fddaCut, fddcCut}; + std::vector parameters = {pvCut, dcazCut, dcaxyCut, tpcChi2Cut, tpcNClsFindableCut, itsChi2Cut, etaCut, ptCut}; + int truegapSide = sgSelector.trueGap(collision, fitCut[0], fitCut[1], fitCut[2], zdcCut); - ROOT::Math::PtEtaPhiMVector phiv; - ROOT::Math::PtEtaPhiMVector phiv1; + ROOT::Math::PxPyPzMVector phiv; + ROOT::Math::PxPyPzMVector phiv1; - std::vector onlyPionTracks_p; - std::vector rawPionTracks_p; + std::vector onlyPionTracksp; + std::vector rawPionTracksp; - std::vector onlyPionTracks_pm; - std::vector rawPionTracks_pm; + std::vector onlyPionTrackspm; + std::vector rawPionTrackspm; - std::vector onlyPionTracks_n; - std::vector rawPionTracks_n; + std::vector onlyPionTracksn; + std::vector rawPionTracksn; registry.fill(HIST("GapSide"), gapSide); registry.fill(HIST("TrueGapSide"), truegapSide); gapSide = truegapSide; if (gapSide < 0 || gapSide > 2) return; - Int_t mult = collision.numContrib(); + if (std::abs(collision.posZ()) > vzCut) + return; + if (std::abs(collision.occupancyInTime()) > occCut) + return; + if (std::abs(collision.hadronicRate()) > hadronicRate) + return; + + if (useTrs != -1 && collision.trs() != useTrs) + return; + if (useTrofs != -1 && collision.trofs() != useTrofs) + return; + if (useHmpr != -1 && collision.hmpr() != useHmpr) + return; + if (useTfb != -1 && collision.tfb() != useTfb) + return; + if (useItsrofb != -1 && collision.itsROFb() != useItsrofb) + return; + if (useSbp != -1 && collision.sbp() != useSbp) + return; + if (useZvtxftovpv != -1 && collision.zVtxFT0vPV() != useZvtxftovpv) + return; + if (useVtxItsTpc != -1 && collision.vtxITSTPC() != useVtxItsTpc) + return; + if (!isGoodRCTflag(collision)) + return; + if (upcflag != -1 && collision.flags() != upcflag) + return; + int mult = collision.numContrib(); if (gapSide == 0) { registry.fill(HIST("gap_mult0"), mult); } @@ -409,32 +653,61 @@ struct SGResonanceAnalyzer { } if (mult < mintrack || mult > maxtrack) return; - Int_t mult0 = 0; - Int_t mult1 = 0; - Int_t mult2 = 0; - Int_t trackgapA = 0; - Int_t trackgapC = 0; - Int_t trackDG = 0; - Int_t trackextra = 0; - Int_t trackextraDG = 0; - for (auto track1 : tracks) { + int mult0 = 0; + int mult1 = 0; + int mult2 = 0; + int trackgapA = 0; + int trackgapC = 0; + int trackDG = 0; + int trackextra = 0; + int trackextraDG = 0; + + if (qa) { + registry.fill(HIST("hVertexX"), collision.posX()); + registry.fill(HIST("hVertexY"), collision.posY()); + registry.fill(HIST("hVertexZ"), collision.posZ()); + } + + /* Partition pvContributors1 = aod::udtrack::isPVContributor == true; + pvContributors1.bindTable(tracks); + if (gapSide == 0) { + registry.get(HIST("nPVContributors_data"))->Fill(pvContributors1.size(), 1.); + } + if (gapSide == 1) { + registry.get(HIST("nPVContributors_data_1"))->Fill(pvContributors1.size(), 1.); + } + */ + for (const auto& track1 : tracks) { + + if (qa) { + registry.fill(HIST("hDcaxy_all_before"), track1.dcaXY()); + registry.fill(HIST("hDcaz_all_before"), track1.dcaZ()); + } + if (!trackselector(track1, parameters)) continue; - v0.SetXYZM(track1.px(), track1.py(), track1.pz(), o2::constants::physics::MassPionCharged); - ROOT::Math::PtEtaPhiMVector vv1(v0.Pt(), v0.Eta(), v0.Phi(), o2::constants::physics::MassPionCharged); + + v0.SetCoordinates(track1.px(), track1.py(), track1.pz(), o2::constants::physics::MassPionCharged); + + if (qa) { + registry.fill(HIST("hDcaxy_all_after"), track1.dcaXY()); + registry.fill(HIST("hDcaz_all_after"), track1.dcaZ()); + registry.fill(HIST("hEta_all_after"), v0.Eta()); + registry.fill(HIST("hRap_all_after"), v0.Rapidity()); + } + if (selectionPIDPion1(track1)) { - onlyPionTracks_pm.push_back(vv1); - rawPionTracks_pm.push_back(track1); + onlyPionTrackspm.push_back(v0); + rawPionTrackspm.push_back(track1); if (track1.sign() == 1) { - onlyPionTracks_p.push_back(vv1); - rawPionTracks_p.push_back(track1); + onlyPionTracksp.push_back(v0); + rawPionTracksp.push_back(track1); } if (track1.sign() == -1) { - onlyPionTracks_n.push_back(vv1); - rawPionTracks_n.push_back(track1); + onlyPionTracksn.push_back(v0); + rawPionTracksn.push_back(track1); } } - if (gapSide == 0) { mult0++; } @@ -444,56 +717,69 @@ struct SGResonanceAnalyzer { if (gapSide == 2) { mult2++; } - if (TMath::Abs(v0.Eta()) < EtaDG) { + if (std::abs(v0.Eta()) < etaDG) { trackDG++; } - if (v0.Eta() > EtaGapMin && v0.Eta() < EtaGapMax) { + if (v0.Eta() > etaGapMin && v0.Eta() < etaGapMax) { trackgapA++; } - if (v0.Eta() < EtaGapMin && v0.Eta() > -EtaGapMax) { + if (v0.Eta() < etaGapMin && v0.Eta() > -etaGapMax) { trackgapC++; } - if (TMath::Abs(v0.Eta()) > EtaGapMax || TMath::Abs(v0.Eta()) < EtaGapMin) { + if (std::abs(v0.Eta()) > etaGapMax || std::abs(v0.Eta()) < etaGapMin) { trackextra++; } - if (TMath::Abs(v0.Eta()) > EtaDG) { + if (std::abs(v0.Eta()) > etaDG) { trackextraDG++; } - if (QA) { + if (qa) { registry.fill(HIST("tpc_dedx"), v0.P(), track1.tpcSignal()); registry.fill(HIST("tof_beta"), v0.P(), track1.beta()); - registry.fill(HIST("tof_nsigma_kaon"), v0.Pt(), track1.tofNSigmaKa()); - registry.fill(HIST("tof_nsigma_pion"), v0.Pt(), track1.tofNSigmaPi()); + registry.fill(HIST("tof_nsigma_kaon_f"), v0.Pt(), track1.tofNSigmaKa()); + registry.fill(HIST("tof_nsigma_pion_f"), v0.Pt(), track1.tofNSigmaPi()); + registry.fill(HIST("tpc_nsigma_kaon_f"), v0.Pt(), track1.tpcNSigmaKa()); + registry.fill(HIST("tpc_nsigma_pion_f"), v0.Pt(), track1.tpcNSigmaPi()); - if (std::abs(track1.tpcNSigmaKa()) < 3.0) { - registry.fill(HIST("tpc_dedx_kaon"), v0.P(), track1.tpcSignal()); - } else if (std::abs(track1.tpcNSigmaPi()) < 3.0) { - registry.fill(HIST("tpc_dedx_pion"), v0.P(), track1.tpcSignal()); - } if (selectionPIDKaon1(track1)) { registry.fill(HIST("tpc_dedx_kaon_1"), v0.P(), track1.tpcSignal()); registry.fill(HIST("tpc_nsigma_kaon"), v0.Pt(), track1.tpcNSigmaKa()); + registry.fill(HIST("tof_nsigma_kaon"), v0.Pt(), track1.tofNSigmaKa()); registry.fill(HIST("tpc_tof_nsigma_kaon"), track1.tpcNSigmaKa(), track1.tofNSigmaKa()); + registry.fill(HIST("hEta_ka"), v0.Eta()); + registry.fill(HIST("hRap_ka"), v0.Rapidity()); + registry.fill(HIST("hDcaxy_ka"), track1.dcaXY()); + registry.fill(HIST("hDcaz_ka"), track1.dcaZ()); } - if (selectionPIDKaon1(track1) && std::abs(track1.tpcNSigmaPi()) > 3.0) { - registry.fill(HIST("tpc_dedx_kaon_2"), v0.P(), track1.tpcSignal()); - } + if (selectionPIDPion1(track1)) { registry.fill(HIST("tpc_dedx_pion_1"), v0.P(), track1.tpcSignal()); registry.fill(HIST("tpc_nsigma_pion"), v0.Pt(), track1.tpcNSigmaPi()); + registry.fill(HIST("tof_nsigma_pion"), v0.Pt(), track1.tofNSigmaPi()); registry.fill(HIST("tpc_tof_nsigma_pion"), track1.tpcNSigmaPi(), track1.tofNSigmaPi()); + registry.fill(HIST("hEta_pi"), v0.Eta()); + registry.fill(HIST("hRap_pi"), v0.Rapidity()); + registry.fill(HIST("hDcaxy_pi"), track1.dcaXY()); + registry.fill(HIST("hDcaz_pi"), track1.dcaZ()); } } } - if (QA) { + if (gapSide == 0) { + registry.fill(HIST("mult_0"), mult0); + } + if (gapSide == 1) { + registry.fill(HIST("mult_1"), mult1); + } + if (gapSide == 2) { + registry.fill(HIST("mult_2"), mult2); + } + if (qa) { if (gapSide == 0) { registry.fill(HIST("V0A_0"), collision.totalFV0AmplitudeA()); registry.fill(HIST("FT0A_0"), collision.totalFT0AmplitudeA()); registry.fill(HIST("FT0C_0"), collision.totalFT0AmplitudeC()); registry.fill(HIST("ZDC_A_0"), collision.energyCommonZNA()); registry.fill(HIST("ZDC_C_0"), collision.energyCommonZNC()); - registry.fill(HIST("mult_0"), mult0); } if (gapSide == 1) { registry.fill(HIST("V0A_1"), collision.totalFV0AmplitudeA()); @@ -501,7 +787,6 @@ struct SGResonanceAnalyzer { registry.fill(HIST("FT0C_1"), collision.totalFT0AmplitudeC()); registry.fill(HIST("ZDC_A_1"), collision.energyCommonZNA()); registry.fill(HIST("ZDC_C_1"), collision.energyCommonZNC()); - registry.fill(HIST("mult_1"), mult1); } if (gapSide == 2) { registry.fill(HIST("V0A"), collision.totalFV0AmplitudeA()); @@ -509,9 +794,8 @@ struct SGResonanceAnalyzer { registry.fill(HIST("FT0C"), collision.totalFT0AmplitudeC()); registry.fill(HIST("ZDC_A"), collision.energyCommonZNA()); registry.fill(HIST("ZDC_C"), collision.energyCommonZNC()); - registry.fill(HIST("mult_2"), mult2); } - if (rapidity_gap) { + if (rapidityGap) { if (trackgapC > 0 && trackgapA == 0 && trackextra == 0) { if (gapSide == 0) { registry.fill(HIST("event_rap_gap"), 1); @@ -557,15 +841,15 @@ struct SGResonanceAnalyzer { } } - if (rapidity_gap) { + if (rapidityGap) { if (trackgapC > 0 && trackgapA == 0 && trackextra == 0) { - for (auto& [t0, t1] : combinations(tracks, tracks)) { + for (const auto& [t0, t1] : combinations(tracks, tracks)) { if (!trackselector(t0, parameters) || !trackselector(t1, parameters)) continue; if (phi && selectionPIDKaon1(t0) && selectionPIDKaon1(t1)) { // Apply kaon hypothesis and create pairs - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); + v0.SetCoordinates(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { @@ -592,15 +876,15 @@ struct SGResonanceAnalyzer { } } } - for (auto& [t0, t1] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { + for (const auto& [t0, t1] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { if (!trackselector(t0, parameters) || !trackselector(t1, parameters)) continue; if (t0.globalIndex() == t1.globalIndex()) continue; if (kstar && selectionPIDKaon1(t0) && selectionPIDPion1(t1)) { // Apply kaon hypothesis and create pairs - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); + v0.SetCoordinates(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { @@ -630,13 +914,13 @@ struct SGResonanceAnalyzer { } if (trackgapC == 0 && trackgapA > 0 && trackextra == 0) { - for (auto& [t0, t1] : combinations(tracks, tracks)) { + for (const auto& [t0, t1] : combinations(tracks, tracks)) { if (!trackselector(t0, parameters) || !trackselector(t1, parameters)) continue; if (phi && selectionPIDKaon1(t0) && selectionPIDKaon1(t1)) { // Apply kaon hypothesis and create pairs - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); + v0.SetCoordinates(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { @@ -663,15 +947,15 @@ struct SGResonanceAnalyzer { } } } - for (auto& [t0, t1] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { + for (const auto& [t0, t1] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { if (!trackselector(t0, parameters) || !trackselector(t1, parameters)) continue; if (t0.globalIndex() == t1.globalIndex()) continue; if (kstar && selectionPIDKaon1(t0) && selectionPIDPion1(t1)) { // Apply kaon hypothesis and create pairs - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); + v0.SetCoordinates(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { @@ -700,13 +984,13 @@ struct SGResonanceAnalyzer { } } if (trackDG > 0 && trackextraDG == 0) { - for (auto& [t0, t1] : combinations(tracks, tracks)) { + for (const auto& [t0, t1] : combinations(tracks, tracks)) { if (!trackselector(t0, parameters) || !trackselector(t1, parameters)) continue; if (phi && selectionPIDKaon1(t0) && selectionPIDKaon1(t1)) { // Apply kaon hypothesis and create pairs - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); + v0.SetCoordinates(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { @@ -733,15 +1017,15 @@ struct SGResonanceAnalyzer { } } } - for (auto& [t0, t1] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { + for (const auto& [t0, t1] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { if (!trackselector(t0, parameters) || !trackselector(t1, parameters)) continue; if (t0.globalIndex() == t1.globalIndex()) continue; if (kstar && selectionPIDKaon1(t0) && selectionPIDPion1(t1)) { // Apply kaon hypothesis and create pairs - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); + v0.SetCoordinates(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { @@ -771,14 +1055,14 @@ struct SGResonanceAnalyzer { } } - for (auto& [t0, t1] : combinations(tracks, tracks)) { + for (const auto& [t0, t1] : combinations(tracks, tracks)) { if (!trackselector(t0, parameters) || !trackselector(t1, parameters)) continue; if (phi && selectionPIDKaon1(t0) && selectionPIDKaon1(t1)) { // Apply kaon hypothesis and create pairs - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); + v0.SetCoordinates(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { @@ -788,7 +1072,7 @@ struct SGResonanceAnalyzer { if (gapSide == 1) { registry.fill(HIST("os_KK_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } - if (gapSide == 2) { + if (exclusive && gapSide == 2 && mult2 == 2) { registry.fill(HIST("os_KK_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } @@ -800,7 +1084,7 @@ struct SGResonanceAnalyzer { if (gapSide == 1) { registry.fill(HIST("os_KK_ls_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } - if (gapSide == 2) { + if (exclusive && gapSide == 2 && mult2 == 2) { registry.fill(HIST("os_KK_ls_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } @@ -816,8 +1100,8 @@ struct SGResonanceAnalyzer { auto rotkaonPx = t0.px() * std::cos(rotangle) - t0.py() * std::sin(rotangle); auto rotkaonPy = t0.px() * std::sin(rotangle) + t0.py() * std::cos(rotangle); - v0.SetXYZM(rotkaonPx, rotkaonPy, t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); + v0.SetCoordinates(rotkaonPx, rotkaonPy, t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); v01 = v0 + v1; if (t0.sign() != t1.sign()) { if (gapSide == 0) { @@ -826,7 +1110,7 @@ struct SGResonanceAnalyzer { if (gapSide == 1) { registry.fill(HIST("os_KK_rot_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } - if (gapSide == 2) { + if (exclusive && gapSide == 2 && mult2 == 2) { registry.fill(HIST("os_KK_rot_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } @@ -834,14 +1118,14 @@ struct SGResonanceAnalyzer { } } } - for (auto& [t0, t1] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { + for (const auto& [t0, t1] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { if (!trackselector(t0, parameters) || !trackselector(t1, parameters)) continue; if (t0.globalIndex() == t1.globalIndex()) continue; - if (rho && selectionPIDProton(t0, use_tof, nsigmatpc_cut, nsigmatof_cut) && selectionPIDPion1(t1)) { - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), mproton); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); + if (rho && selectionPIDProton(t0, useTof, nsigmaTpcCut, nsigmaTofCut) && selectionPIDKaon1(t1)) { + v0.SetCoordinates(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassProton); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKaonCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { @@ -851,7 +1135,7 @@ struct SGResonanceAnalyzer { if (gapSide == 1) { registry.fill(HIST("os_pp_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } - if (gapSide == 2) { + if (exclusive && gapSide == 2 && mult2 == 2) { registry.fill(HIST("os_pp_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } // same sign pair @@ -862,14 +1146,16 @@ struct SGResonanceAnalyzer { if (gapSide == 1) { registry.fill(HIST("os_pp_ls_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } - if (gapSide == 2) { + if (exclusive && gapSide == 2 && mult2 == 2) { registry.fill(HIST("os_pp_ls_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } } if (kstar && selectionPIDKaon1(t0) && selectionPIDPion1(t1)) { - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); + if (kaoncut && t0.tpcNSigmaPi() < pionNsigmaCut) + continue; + v0.SetCoordinates(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { @@ -879,7 +1165,7 @@ struct SGResonanceAnalyzer { if (gapSide == 1) { registry.fill(HIST("os_pk_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } - if (gapSide == 2) { + if (exclusive && gapSide == 2 && mult2 == 2) { registry.fill(HIST("os_pk_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } // same sign pair @@ -890,7 +1176,7 @@ struct SGResonanceAnalyzer { if (gapSide == 1) { registry.fill(HIST("os_pk_ls_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } - if (gapSide == 2) { + if (exclusive && gapSide == 2 && mult2 == 2) { registry.fill(HIST("os_pk_ls_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } @@ -905,8 +1191,8 @@ struct SGResonanceAnalyzer { auto rotkaonPx = t0.px() * std::cos(rotangle) - t0.py() * std::sin(rotangle); auto rotkaonPy = t0.px() * std::sin(rotangle) + t0.py() * std::cos(rotangle); - v0.SetXYZM(rotkaonPx, rotkaonPy, t0.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); + v0.SetCoordinates(rotkaonPx, rotkaonPy, t0.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); v01 = v0 + v1; if (t0.sign() != t1.sign()) { if (gapSide == 0) { @@ -915,7 +1201,7 @@ struct SGResonanceAnalyzer { if (gapSide == 1) { registry.fill(HIST("os_pk_rot_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } - if (gapSide == 2) { + if (exclusive && gapSide == 2 && mult2 == 2) { registry.fill(HIST("os_pk_rot_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } @@ -925,13 +1211,12 @@ struct SGResonanceAnalyzer { } if (fourpion) { if (gapSide == 2 && mult2 == 4) { - - ROOT::Math::PtEtaPhiMVector pair1, pair2, pair3, pair4; - if (onlyPionTracks_p.size() == 2 && onlyPionTracks_n.size() == 2) { - ROOT::Math::PtEtaPhiMVector k1 = onlyPionTracks_p.at(0); - ROOT::Math::PtEtaPhiMVector k2 = onlyPionTracks_p.at(1); - ROOT::Math::PtEtaPhiMVector k3 = onlyPionTracks_n.at(0); - ROOT::Math::PtEtaPhiMVector k4 = onlyPionTracks_n.at(1); + ROOT::Math::PxPyPzMVector pair1, pair2, pair3, pair4; + if (onlyPionTracksp.size() == 2 && onlyPionTracksn.size() == 2) { + ROOT::Math::PxPyPzMVector k1 = onlyPionTracksp.at(0); + ROOT::Math::PxPyPzMVector k2 = onlyPionTracksp.at(1); + ROOT::Math::PxPyPzMVector k3 = onlyPionTracksn.at(0); + ROOT::Math::PxPyPzMVector k4 = onlyPionTracksn.at(1); phiv = k1 + k2 + k3 + k4; pair1 = k1 + k3; pair2 = k2 + k4; @@ -940,66 +1225,70 @@ struct SGResonanceAnalyzer { registry.fill(HIST("os_pppp_pT_2"), phiv.M(), phiv.Pt(), phiv.Rapidity()); registry.fill(HIST("os_pp_vs_pp_mass"), pair1.M(), pair2.M()); registry.fill(HIST("os_pp_vs_pp_pt"), pair1.Pt(), pair2.Pt()); - auto costhetaPair = CosThetaCollinsSoperFrame(pair1, pair2, phiv); - auto phiPair = 1. * TMath::Pi() + PhiCollinsSoperFrame(pair1, pair2, phiv); + auto costhetaPair = cosThetaCollinsSoperFrame(pair1, pair2, phiv); + auto phiPair = 1. * o2::constants::math::PI + phiCollinsSoperFrame(pair1, pair2, phiv); registry.fill(HIST("phi_dis"), phiPair); registry.fill(HIST("costheta_dis"), costhetaPair); registry.fill(HIST("costheta_vs_phi"), costhetaPair, phiPair); registry.fill(HIST("os_pp_vs_pp_mass1"), pair3.M(), pair4.M()); registry.fill(HIST("os_pp_vs_pp_pt1"), pair3.Pt(), pair4.Pt()); - auto costhetaPair1 = CosThetaCollinsSoperFrame(pair3, pair4, phiv); - auto phiPair1 = 1. * TMath::Pi() + PhiCollinsSoperFrame(pair3, pair4, phiv); + auto costhetaPair1 = cosThetaCollinsSoperFrame(pair3, pair4, phiv); + auto phiPair1 = 1. * o2::constants::math::PI + phiCollinsSoperFrame(pair3, pair4, phiv); registry.fill(HIST("phi_dis1"), phiPair1); registry.fill(HIST("costheta_dis1"), costhetaPair1); registry.fill(HIST("costheta_vs_phi1"), costhetaPair1, phiPair1); } - if (onlyPionTracks_p.size() != 2 && onlyPionTracks_n.size() != 2) { - if (onlyPionTracks_p.size() + onlyPionTracks_n.size() != 4) + if (onlyPionTracksp.size() != 2 && onlyPionTracksn.size() != 2) { + if (onlyPionTracksp.size() + onlyPionTracksn.size() != 4) return; - ROOT::Math::PtEtaPhiMVector l1 = onlyPionTracks_pm.at(0); - ROOT::Math::PtEtaPhiMVector l2 = onlyPionTracks_pm.at(1); - ROOT::Math::PtEtaPhiMVector l3 = onlyPionTracks_pm.at(2); - ROOT::Math::PtEtaPhiMVector l4 = onlyPionTracks_pm.at(3); + ROOT::Math::PxPyPzMVector l1 = onlyPionTrackspm.at(0); + ROOT::Math::PxPyPzMVector l2 = onlyPionTrackspm.at(1); + ROOT::Math::PxPyPzMVector l3 = onlyPionTrackspm.at(2); + ROOT::Math::PxPyPzMVector l4 = onlyPionTrackspm.at(3); phiv1 = l1 + l2 + l3 + l4; registry.fill(HIST("os_pppp_pT_2_ls"), phiv1.M(), phiv1.Pt(), phiv1.Rapidity()); } } } } - PROCESS_SWITCH(SGResonanceAnalyzer, process, "Process unlike event", false); + PROCESS_SWITCH(SginclusivePhiKstarSD, process, "Process unlike event", false); - using UDCollisionsFull1 = soa::Join; // + using UDCollisionsFull1 = soa::Join; // SliceCache cache; - Partition posTracks = aod::udtrack::sign > 0; - Partition negTracks = aod::udtrack::sign < 0; + Partition posTracks = aod::udtrack::sign > 0; + Partition negTracks = aod::udtrack::sign < 0; ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for bin"}; ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {10, 0, 100}, "multiplicity percentile for bin"}; using BinningTypeVertexContributor = ColumnBinningPolicy; - void mixprocess(UDCollisionsFull1 const& collisions, udtracksfull const& /*track*/) + void mixprocess(UDCollisionsFull1 const& collisions, UDtracksfull const& /*track*/) { - TLorentzVector v0; - TLorentzVector v1; - TLorentzVector v01; - float FIT_cut[5] = {FV0_cut, FT0A_cut, FT0C_cut, FDDA_cut, FDDC_cut}; - std::vector parameters = {PV_cut, dcaZ_cut, dcaXY_cut, tpcChi2_cut, tpcNClsFindable_cut, itsChi2_cut, eta_cut, pt_cut}; + ROOT::Math::PxPyPzMVector v0; + ROOT::Math::PxPyPzMVector v1; + ROOT::Math::PxPyPzMVector v01; + float fitCut[5] = {fv0Cut, ft0aCut, ft0cCut, fddaCut, fddcCut}; + std::vector parameters = {pvCut, dcazCut, dcaxyCut, tpcChi2Cut, tpcNClsFindableCut, itsChi2Cut, etaCut, ptCut}; BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicityClass}, true}; for (auto const& [collision1, collision2] : o2::soa::selfCombinations(binningOnPositions, cfgNoMixedEvents, -1, collisions, collisions)) { - int truegapSide1 = sgSelector.trueGap(collision1, FIT_cut[0], FIT_cut[1], FIT_cut[2], ZDC_cut); - int truegapSide2 = sgSelector.trueGap(collision2, FIT_cut[0], FIT_cut[1], FIT_cut[2], ZDC_cut); + int truegapSide1 = sgSelector.trueGap(collision1, fitCut[0], fitCut[1], fitCut[2], zdcCut); + int truegapSide2 = sgSelector.trueGap(collision2, fitCut[0], fitCut[1], fitCut[2], zdcCut); if (truegapSide1 != truegapSide2) continue; if (truegapSide1 == -1) continue; + if (std::abs(collision1.posZ()) > vzCut || std::abs(collision2.posZ()) > vzCut) + continue; + if (std::abs(collision1.occupancyInTime()) > occCut || std::abs(collision2.occupancyInTime()) > occCut) + continue; auto posThisColl = posTracks->sliceByCached(aod::udtrack::udCollisionId, collision1.globalIndex(), cache); auto negThisColl = negTracks->sliceByCached(aod::udtrack::udCollisionId, collision2.globalIndex(), cache); // for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posThisColl, negThisColl))) { - for (auto& [track1, track2] : o2::soa::combinations(posThisColl, negThisColl)) { + for (const auto& [track1, track2] : o2::soa::combinations(posThisColl, negThisColl)) { if (!trackselector(track1, parameters) || !trackselector(track2, parameters)) continue; - if (selectionPIDKaon1(track1) && selectionPIDKaon1(track2)) { - v0.SetXYZM(track1.px(), track1.py(), track1.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(track2.px(), track2.py(), track2.pz(), o2::constants::physics::MassKaonCharged); + if (phi && selectionPIDKaon1(track1) && selectionPIDKaon1(track2)) { + v0.SetCoordinates(track1.px(), track1.py(), track1.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(track2.px(), track2.py(), track2.pz(), o2::constants::physics::MassKaonCharged); v01 = v0 + v1; // Opposite sign pairs if (track1.sign() != track2.sign()) { @@ -1015,14 +1304,14 @@ struct SGResonanceAnalyzer { } } } - for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posThisColl, negThisColl))) { + for (const auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posThisColl, negThisColl))) { if (!trackselector(track1, parameters) || !trackselector(track2, parameters)) continue; if (track1.globalIndex() == track2.globalIndex()) continue; - if (selectionPIDKaon1(track1) && selectionPIDPion1(track2)) { - v0.SetXYZM(track1.px(), track1.py(), track1.pz(), o2::constants::physics::MassKaonCharged); - v1.SetXYZM(track2.px(), track2.py(), track2.pz(), o2::constants::physics::MassPionCharged); + if (kstar && selectionPIDKaon1(track1) && selectionPIDPion1(track2)) { + v0.SetCoordinates(track1.px(), track1.py(), track1.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(track2.px(), track2.py(), track2.pz(), o2::constants::physics::MassPionCharged); v01 = v0 + v1; // Opposite sign pairs if (track1.sign() != track2.sign()) { @@ -1040,11 +1329,390 @@ struct SGResonanceAnalyzer { } } } - PROCESS_SWITCH(SGResonanceAnalyzer, mixprocess, "Process Mixed event", false); + PROCESS_SWITCH(SginclusivePhiKstarSD, mixprocess, "Process Mixed event", false); + + // define abbreviations , aod::UDCollisions_001, + using CCs = soa::Join; + using CC = CCs::iterator; + // using TCs = soa::Join; + using TCs = soa::Join; + using TC = TCs::iterator; + + PresliceUnsorted partPerMcCollision = aod::udmcparticle::udMcCollisionId; + PresliceUnsorted colPerMcCollision = aod::udcollision::udMcCollisionId; + PresliceUnsorted trackPerMcParticle = aod::udmctracklabel::udMcParticleId; + + void processMCTruth(aod::UDMcCollisions const& mccollisions, CCs const& collisions, aod::UDMcParticles const& McParts, TCs const& tracks) + { + // number of McCollisions in DF + ROOT::Math::PxPyPzMVector v0; + ROOT::Math::PxPyPzMVector v1; + ROOT::Math::PxPyPzMVector v01; + ROOT::Math::PxPyPzMVector vkstar; + ROOT::Math::PxPyPzMVector vphi; + for (const auto& mccollision : mccollisions) { + if (mccollision.generatorsID() != generatedId) + continue; + registry.get(HIST("MC/Stat"))->Fill(0., 1.); + // get reconstructed collision which belongs to mccollision + auto colSlice = collisions.sliceBy(colPerMcCollision, mccollision.globalIndex()); + registry.get(HIST("MC/recCols"))->Fill(colSlice.size(), 1.); + if (reconstruction && colSlice.size() < 1) + continue; + // get McParticles which belong to mccollision + auto partSlice = McParts.sliceBy(partPerMcCollision, mccollision.globalIndex()); + registry.get(HIST("MC/nParts"))->Fill(partSlice.size(), 1.); + for (const auto& [tr1, tr2] : combinations(partSlice, partSlice)) { + if ((tr1.pdgCode() == kKPlus && tr2.pdgCode() == kPiMinus) || (tr1.pdgCode() == kKMinus && tr2.pdgCode() == kPiPlus) || (tr1.pdgCode() == kPiPlus && tr2.pdgCode() == kKMinus) || (tr1.pdgCode() == kPiMinus && tr2.pdgCode() == kKPlus)) { + if (std::abs(tr1.pdgCode()) == kKPlus) { + v0.SetCoordinates(tr1.px(), tr1.py(), tr1.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(tr2.px(), tr2.py(), tr2.pz(), o2::constants::physics::MassPionCharged); + } else { + v0.SetCoordinates(tr1.px(), tr1.py(), tr1.pz(), o2::constants::physics::MassPionCharged); + v1.SetCoordinates(tr2.px(), tr2.py(), tr2.pz(), o2::constants::physics::MassKaonCharged); + } + if (!tr1.isPhysicalPrimary() || !tr2.isPhysicalPrimary()) + continue; + v01 = v0 + v1; + if (tr1.globalIndex() + 1 != tr2.globalIndex()) { + registry.get(HIST("MC/genM_1_k"))->Fill(v01.M(), 1.); + } + if (std::abs(tr1.globalIndex() - tr2.globalIndex()) != 1) + continue; + bool flag = false; + bool flag1 = false; + if (tr1.has_mothers() && tr2.has_mothers()) { + for (const auto& mother : tr1.mothers_as()) { + if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kK0Star892) { + vkstar.SetCoordinates(mother.px(), mother.py(), mother.pz(), o2::constants::physics::MassK0Star892); + registry.get(HIST("MC/accMPtRap_kstar_G"))->Fill(vkstar.M(), vkstar.Pt(), vkstar.Rapidity(), 1.); + flag = true; + } + } + for (const auto& mother1 : tr2.mothers_as()) { + if (std::abs(mother1.pdgCode()) == o2::constants::physics::Pdg::kK0Star892) { + flag1 = true; + } + } + } + if (flag && flag1) { + registry.get(HIST("MC/genMPt_k"))->Fill(v01.M(), v01.Pt(), 1.); + } + registry.get(HIST("MC/genRap_k"))->Fill(v01.Rapidity(), 1.); + registry.get(HIST("MC/genM_k"))->Fill(v01.M(), 1.); + registry.get(HIST("MC/accRap_k"))->Fill(v01.Rapidity(), 1.); + registry.get(HIST("MC/accMPt_k"))->Fill(v01.M(), v01.Pt(), 1.); + registry.get(HIST("MC/accM_k"))->Fill(v01.M(), 1.); + registry.get(HIST("MC/accMPtRap_k"))->Fill(v01.M(), v01.Pt(), v01.Rapidity(), 1.); + } + + if (std::abs(tr1.pdgCode()) != kKPlus || std::abs(tr2.pdgCode()) != kKPlus) + continue; + v0.SetCoordinates(tr1.px(), tr1.py(), tr1.pz(), o2::constants::physics::MassKaonCharged); + v1.SetCoordinates(tr2.px(), tr2.py(), tr2.pz(), o2::constants::physics::MassKaonCharged); + if (tr1.pdgCode() == tr2.pdgCode()) + continue; + v01 = v0 + v1; + if (!tr1.isPhysicalPrimary() || !tr2.isPhysicalPrimary()) + continue; + if (tr1.globalIndex() + 1 != tr2.globalIndex()) { + registry.get(HIST("MC/genM_1"))->Fill(v01.M(), 1.); + } + if (std::abs(tr1.globalIndex() - tr2.globalIndex()) != 1) + continue; + bool flag = false; + bool flag1 = false; + if (tr1.has_mothers() && tr2.has_mothers()) { + for (const auto& mother : tr1.mothers_as()) { + if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kPhi) { + vphi.SetCoordinates(mother.px(), mother.py(), mother.pz(), o2::constants::physics::MassPhi); + registry.get(HIST("MC/accMPtRap_phi_G"))->Fill(vphi.M(), vphi.Pt(), vphi.Rapidity(), 1.); + flag = true; + } + } + for (const auto& mother1 : tr2.mothers_as()) { + if (std::abs(mother1.pdgCode()) == o2::constants::physics::Pdg::kPhi) { + flag1 = true; + } + } + } + if (flag && flag1) { + registry.get(HIST("MC/genMPt"))->Fill(v01.M(), v01.Pt(), 1.); + } + // registry.get(HIST("MC/genRap"))->Fill(v01.Rapidity(), 1.); + // registry.get(HIST("MC/genM"))->Fill(v01.M(), 1.); + registry.get(HIST("MC/accRap"))->Fill(v01.Rapidity(), 1.); + registry.get(HIST("MC/accMPt"))->Fill(v01.M(), v01.Pt(), 1.); + registry.get(HIST("MC/accM"))->Fill(v01.M(), 1.); + registry.get(HIST("MC/accMPtRap"))->Fill(v01.M(), v01.Pt(), v01.Rapidity(), 1.); + } + // compute the difference between generated and reconstructed particle momentum + for (const auto& McPart : partSlice) { + auto trackSlice = tracks.sliceBy(trackPerMcParticle, McPart.globalIndex()); + registry.get(HIST("MC/nRecTracks"))->Fill(trackSlice.size(), 1.); + // compute momentum difference between MCTruth and Reconstruction + if (trackSlice.size() > 0) { + for (const auto& track : trackSlice) { + // std::cout<(HIST("MC/pDiff"))->Fill(pDiff, track.isPVContributor(), 1.); + } + } else { + registry.get(HIST("MC/pDiff"))->Fill(-5.9, -1, 1.); + } + } + } + } + PROCESS_SWITCH(SginclusivePhiKstarSD, processMCTruth, "Process MC truth", true); + // ............................................................................................................... + void processReco(CC const& collision, TCs const& tracks, aod::UDMcCollisions const& /*mccollisions*/, aod::UDMcParticles const& /*McParts*/) + { + if (!collision.has_udMcCollision()) + return; + auto mccoll = collision.udMcCollision(); + if (mccoll.generatorsID() != generatedId) + return; + float fitCut[5] = {fv0Cut, ft0aCut, ft0cCut, fddaCut, fddcCut}; + std::vector parameters = {pvCut, dcazCut, dcaxyCut, tpcChi2Cut, tpcNClsFindableCut, itsChi2Cut, etaCut, ptCut}; + int truegapSide = sgSelector.trueGap(collision, fitCut[0], fitCut[1], fitCut[2], zdcCut); + registry.get(HIST("Reco/Stat"))->Fill(4.0, 1.); + // Partition pvContributors = aod::udtrack::isPVContributor == true; + // pvContributors.bindTable(tracks); + if (std::abs(collision.posZ()) > vzCut) + return; + if (std::abs(collision.occupancyInTime()) > occCut) + return; + if (std::abs(collision.hadronicRate()) > hadronicRate) + return; + if (useTrs != -1 && collision.trs() != useTrs) + return; + if (useTrofs != -1 && collision.trofs() != useTrofs) + return; + if (useHmpr != -1 && collision.hmpr() != useHmpr) + return; + if (useTfb != -1 && collision.tfb() != useTfb) + return; + if (useItsrofb != -1 && collision.itsROFb() != useItsrofb) + return; + if (useSbp != -1 && collision.sbp() != useSbp) + return; + if (useZvtxftovpv != -1 && collision.zVtxFT0vPV() != useZvtxftovpv) + return; + if (useVtxItsTpc != -1 && collision.vtxITSTPC() != useVtxItsTpc) + return; + if (!isGoodRCTflag(collision)) + return; + if (upcflag != -1 && collision.flags() != upcflag) + return; + + registry.get(HIST("Reco/Stat"))->Fill(truegapSide, 1.); + if (truegapSide != gapsideMC) + return; + // registry.get(HIST("Reco/nPVContributors"))->Fill(pvContributors.size(), 1.); + ROOT::Math::PxPyPzMVector vphi; + ROOT::Math::PxPyPzMVector vkstar; + ROOT::Math::PxPyPzMVector v0; + ROOT::Math::PxPyPzMVector vr0; + ROOT::Math::PxPyPzMVector vr1; + ROOT::Math::PxPyPzMVector vr01; + ROOT::Math::PxPyPzMVector vr0g; + ROOT::Math::PxPyPzMVector vr1g; + ROOT::Math::PxPyPzMVector vr01g; + int t1 = 0; + if (truegapSide == 0) { + registry.fill(HIST("V0A_0_mc"), collision.totalFV0AmplitudeA()); + registry.fill(HIST("FT0A_0_mc"), collision.totalFT0AmplitudeA()); + registry.fill(HIST("FT0C_0_mc"), collision.totalFT0AmplitudeC()); + registry.fill(HIST("ZDC_A_0_mc"), collision.energyCommonZNA()); + registry.fill(HIST("ZDC_C_0_mc"), collision.energyCommonZNC()); + } + if (truegapSide == 1) { + registry.fill(HIST("V0A_1_mc"), collision.totalFV0AmplitudeA()); + registry.fill(HIST("FT0A_1_mc"), collision.totalFT0AmplitudeA()); + registry.fill(HIST("FT0C_1_mc"), collision.totalFT0AmplitudeC()); + registry.fill(HIST("ZDC_A_1_mc"), collision.energyCommonZNA()); + registry.fill(HIST("ZDC_C_1_mc"), collision.energyCommonZNC()); + } + for (const auto& tr1 : tracks) { + if (!tr1.has_udMcParticle()) + continue; + auto mcPart1 = tr1.udMcParticle(); + registry.get(HIST("Reco/tr_dcaz_1"))->Fill(tr1.dcaZ(), 1.); + registry.get(HIST("Reco/tr_dcaxy_1"))->Fill(tr1.dcaXY(), 1.); + registry.get(HIST("Reco/tr_chi2ncl_1"))->Fill(tr1.tpcChi2NCl(), 1.); + registry.get(HIST("Reco/tr_tpcnclfind_1"))->Fill(tr1.tpcNClsFindable(), 1.); + registry.get(HIST("Reco/tr_itsChi2NCl_1"))->Fill(tr1.itsChi2NCl(), 1.); + + if (!trackselector(tr1, parameters)) + continue; + + registry.get(HIST("Reco/tr_dcaz_2"))->Fill(tr1.dcaZ(), 1.); + registry.get(HIST("Reco/tr_dcaxy_2"))->Fill(tr1.dcaXY(), 1.); + registry.get(HIST("Reco/tr_chi2ncl_2"))->Fill(tr1.tpcChi2NCl(), 1.); + registry.get(HIST("Reco/tr_tpcnclfind_2"))->Fill(tr1.tpcNClsFindable(), 1.); + registry.get(HIST("Reco/tr_itsChi2NCl_2"))->Fill(tr1.itsChi2NCl(), 1.); + v0.SetCoordinates(tr1.px(), tr1.py(), tr1.pz(), o2::constants::physics::MassPionCharged); + + registry.fill(HIST("tpc_dedx_mc"), v0.P(), tr1.tpcSignal()); + registry.fill(HIST("tof_beta_mc"), v0.P(), tr1.beta()); + registry.fill(HIST("tof_nsigma_kaon_f_mc"), v0.Pt(), tr1.tofNSigmaKa()); + registry.fill(HIST("tof_nsigma_pion_f_mc"), v0.Pt(), tr1.tofNSigmaPi()); + registry.fill(HIST("tpc_nsigma_kaon_f_mc"), v0.Pt(), tr1.tpcNSigmaKa()); + registry.fill(HIST("tpc_nsigma_pion_f_mc"), v0.Pt(), tr1.tpcNSigmaPi()); + if (selectionPIDKaon1(tr1)) { + registry.fill(HIST("tpc_nsigma_kaon_mc"), v0.Pt(), tr1.tpcNSigmaKa()); + registry.fill(HIST("tof_nsigma_kaon_mc"), v0.Pt(), tr1.tofNSigmaKa()); + registry.fill(HIST("tpc_tof_nsigma_kaon_mc"), tr1.tpcNSigmaKa(), tr1.tofNSigmaKa()); + } + if (selectionPIDPion1(tr1)) { + registry.fill(HIST("tpc_nsigma_pion_mc"), v0.Pt(), tr1.tpcNSigmaPi()); + registry.fill(HIST("tof_nsigma_pion_mc"), v0.Pt(), tr1.tofNSigmaPi()); + registry.fill(HIST("tpc_tof_nsigma_pion_mc"), tr1.tpcNSigmaPi(), tr1.tofNSigmaPi()); + } + + t1++; + vr0.SetCoordinates(tr1.px(), tr1.py(), tr1.pz(), o2::constants::physics::MassKaonCharged); + registry.get(HIST("Reco/trpt"))->Fill(vr0.Pt(), 1.); + registry.get(HIST("Reco/treta_k"))->Fill(vr0.Eta(), 1.); + if (!selectionPIDKaon1(tr1)) + continue; + registry.get(HIST("Reco/trpt_k"))->Fill(vr0.Pt(), 1.); + int t2 = 0; + for (const auto& tr2 : tracks) { + if (!tr2.has_udMcParticle()) + continue; + if (!trackselector(tr2, parameters)) + continue; + t2++; + if (t2 > t1) { + if (!selectionPIDKaon1(tr2)) + continue; + vr1.SetCoordinates(tr2.px(), tr2.py(), tr2.pz(), o2::constants::physics::MassKaonCharged); + auto mcPart2 = tr2.udMcParticle(); + if (std::abs(mcPart2.globalIndex() - mcPart1.globalIndex()) != 1) + continue; + if (std::abs(mcPart1.pdgCode()) != kKPlus || std::abs(mcPart2.pdgCode()) != kKPlus) + continue; + if (mcPart1.pdgCode() == mcPart2.pdgCode()) + continue; + if (!mcPart1.isPhysicalPrimary() || !mcPart2.isPhysicalPrimary()) + continue; + bool flag = false; + bool flag1 = false; + if (mcPart1.has_mothers() && mcPart2.has_mothers()) { + for (const auto& mother : mcPart1.mothers_as()) { + if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kPhi) { + vphi.SetCoordinates(mother.px(), mother.py(), mother.pz(), o2::constants::physics::MassPhi); + registry.get(HIST("MC/accMPtRap_phi_T"))->Fill(vphi.M(), vphi.Pt(), vphi.Rapidity(), 1.); + flag = true; + } + } + for (const auto& mother1 : mcPart1.mothers_as()) { + if (std::abs(mother1.pdgCode()) == o2::constants::physics::Pdg::kPhi) { + flag1 = true; + } + } + } + vr0g.SetCoordinates(mcPart1.px(), mcPart1.py(), mcPart1.pz(), o2::constants::physics::MassKaonCharged); + vr1g.SetCoordinates(mcPart2.px(), mcPart2.py(), mcPart2.pz(), o2::constants::physics::MassKaonCharged); + vr01g = vr0g + vr1g; + vr01 = vr0 + vr1; + + if (flag && flag1) { + registry.get(HIST("Reco/selMPt"))->Fill(vr01.M(), vr01.Pt(), 1.); + } + registry.get(HIST("Reco/selRap"))->Fill(vr01.Rapidity(), 1.); + registry.get(HIST("Reco/selMPtRap"))->Fill(vr01.M(), vr01.Pt(), vr01.Rapidity(), 1.); + registry.get(HIST("Reco/selPt"))->Fill(vr01.Pt(), 1.); + registry.get(HIST("Reco/selM"))->Fill(vr01.M(), 1.); + registry.get(HIST("Reco/selMPtRap_gen"))->Fill(vr01g.M(), vr01g.Pt(), vr01g.Rapidity(), 1.); + } + } + } + // KStar + for (const auto& [tr1, tr2] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { + if (!tr1.has_udMcParticle() || !tr2.has_udMcParticle()) + continue; + if (!selectionPIDPion1(tr1) || !selectionPIDKaon1(tr2)) + continue; + // if (tr1.index() == tr2.index()) + // continue; // We need to run (0,1), (1,0) pairs as well. but same id pairs are not needed. + auto mcPart1 = tr1.udMcParticle(); + auto mcPart2 = tr2.udMcParticle(); + if (std::abs(mcPart1.pdgCode()) != kPiPlus || std::abs(mcPart2.pdgCode()) != kKPlus) + continue; + if (!mcPart1.isPhysicalPrimary() || !mcPart2.isPhysicalPrimary()) + continue; + if (std::abs(mcPart2.globalIndex() - mcPart1.globalIndex()) != 1) + continue; + + if (tr1.sign() * tr2.sign() > 0) + continue; + + vr0.SetCoordinates(tr1.px(), tr1.py(), tr1.pz(), o2::constants::physics::MassPionCharged); + vr1.SetCoordinates(tr2.px(), tr2.py(), tr2.pz(), o2::constants::physics::MassKaonCharged); + vr0g.SetCoordinates(mcPart1.px(), mcPart1.py(), mcPart1.pz(), o2::constants::physics::MassPionCharged); + vr1g.SetCoordinates(mcPart2.px(), mcPart2.py(), mcPart2.pz(), o2::constants::physics::MassKaonCharged); + vr01g = vr0g + vr1g; + vr01 = vr0 + vr1; + if (!trackselector(tr1, parameters) || !trackselector(tr2, parameters)) { + registry.get(HIST("Reco/selM_k"))->Fill(vr01.M(), 1.); + } + if (trackselector(tr1, parameters) && trackselector(tr2, parameters)) { + bool flag = false; + bool flag1 = false; + if (mcPart1.has_mothers() && mcPart2.has_mothers()) { + for (const auto& mother : mcPart1.mothers_as()) { + if (std::abs(mother.pdgCode()) == o2::constants::physics::Pdg::kK0Star892) { + vkstar.SetCoordinates(mother.px(), mother.py(), mother.pz(), o2::constants::physics::MassK0Star892); + registry.get(HIST("MC/accMPtRap_kstar_T"))->Fill(vkstar.M(), vkstar.Pt(), vkstar.Rapidity(), 1.); + flag = true; + } + } + for (const auto& mother1 : mcPart2.mothers_as()) { + if (std::abs(mother1.pdgCode()) == o2::constants::physics::Pdg::kK0Star892) { + flag1 = true; + } + } + } + if (flag && flag1) { + registry.get(HIST("Reco/selMPt_k"))->Fill(vr01.M(), vr01.Pt(), 1.); + } + registry.get(HIST("Reco/selM_k_K"))->Fill(vr01.M(), 1.); + registry.get(HIST("Reco/selRap_k"))->Fill(vr01.Rapidity(), 1.); + registry.get(HIST("Reco/selMPtRap_k"))->Fill(vr01.M(), vr01.Pt(), vr01.Rapidity(), 1.); + registry.get(HIST("Reco/selPt_k"))->Fill(vr01.Pt(), 1.); + registry.get(HIST("Reco/selMPtRap_k_gen"))->Fill(vr01g.M(), vr01g.Pt(), vr01g.Rapidity(), 1.); + } + } + registry.get(HIST("Reco/nTracks"))->Fill(t1, 1.); + // now access the McTruth information + // get McCollision belonging to collision + if (collision.has_udMcCollision()) { + // auto mccollision = collision.udMcCollision(); + registry.get(HIST("Reco/Stat"))->Fill(3., 1.); + } + // compute the difference between generated and reconstructed momentum + for (const auto& track : tracks) { + // is there an associated McParticle? + if (track.has_udMcParticle()) { + auto pTrack = std::sqrt(track.px() * track.px() + track.py() * track.py() + track.pz() * track.pz()); + auto mcPart = track.udMcParticle(); + auto pPart = std::sqrt(mcPart.px() * mcPart.px() + mcPart.py() * mcPart.py() + mcPart.pz() * mcPart.pz()); + auto pDiff = pTrack - pPart; + registry.get(HIST("Reco/pDiff"))->Fill(pDiff, track.isPVContributor(), 1.); + } else { + registry.get(HIST("Reco/pDiff"))->Fill(-5.9, -1, 1.); + } + } + } + PROCESS_SWITCH(SginclusivePhiKstarSD, processReco, "Process reconstructed data", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGUD/Tasks/testMcStdTabsRl.cxx b/PWGUD/Tasks/testMcStdTabsRl.cxx new file mode 100644 index 00000000000..9748b28784f --- /dev/null +++ b/PWGUD/Tasks/testMcStdTabsRl.cxx @@ -0,0 +1,112 @@ +// 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. +// +/// \file testMcStdTabsRl.cxx +/// \brief task to test the Monte Carlo UD production generatorIDs on hyperloop +/// +/// \author Roman Lavicka , Austrian Academy of Sciences & SMI +/// \since 12.02.2025 +// + +// C++ headers +#include +#include +#include +#include + +// O2 headers +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + +// O2Physics headers +#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" + +// ROOT headers +#include "Math/Vector4D.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +struct TestMcStdTabsRl { + + // Global varialbes + Service pdg; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // declare configurables + Configurable useMcgenidGetGeneratorID{"useMcgenidGetGeneratorID", true, {"Use o2::mcgenid::getGeneratorId instead of o2::mccollision::getGeneratorId; default it true."}}; + + struct : ConfigurableGroup { + ConfigurableAxis zzAxisNtracks{"zzAxisNtracks", {100, -0.5, 99.5}, "Number of tracks in collision"}; + ConfigurableAxis zzAxisNparticles{"zzAxisNparticles", {100, -0.5, 99.5}, "Number of particles in collision"}; + ConfigurableAxis zzAxisNprocesses{"zzAxisNprocesses", {1000, -0.5, 999.5}, "Number of processes"}; + ConfigurableAxis zzAxisInvMassWide{"zzAxisInvMassWide", {1000, 0., 10.}, "Invariant mass (GeV/c^{2}), wider range"}; + ConfigurableAxis zzAxisPt{"zzAxisPt", {400, 0., 2.}, "Transversal momentum (GeV/c)"}; + ConfigurableAxis zzAxisRap{"zzAxisRap", {50, -1.2, 1.2}, "Rapidity (a.u.)"}; + } confAxis; + + // init + void init(InitContext&) + { + histos.add("Events/Truth/hGenIDvsCountCollisions", ";Process ID", HistType::kTH2D, {confAxis.zzAxisNprocesses, {1, 0.5, 1.5}}); + histos.add("Events/Truth/hGenIDvsPDGcodesAll", ";Process ID ;PDG codes of all particles (-)", HistType::kTH2D, {confAxis.zzAxisNprocesses, {2001, -1000, 1000}}); + histos.add("Events/Truth/hGenIDvsPDGcodesNoMother", ";Process ID ;PDG codes of particles without mother (-)", HistType::kTH2D, {confAxis.zzAxisNprocesses, {2001, -1000, 1000}}); + histos.add("Events/Truth/hGenIDvsPDGcodesDaughters", ";Process ID ;PDG codes of daughters of particles without mother (-)", HistType::kTH2D, {confAxis.zzAxisNprocesses, {2001, -1000, 1000}}); + histos.add("Events/Truth/hGenIDvsNparticles", ";Process ID ;Number of particles in a collision (-)", HistType::kTH2D, {confAxis.zzAxisNprocesses, confAxis.zzAxisNparticles}); + histos.add("Events/Truth/hGenIDvsNdaughters", ";Process ID ;Number of daughters of no-mother particle in a collision (-)", HistType::kTH2D, {confAxis.zzAxisNprocesses, confAxis.zzAxisNparticles}); + histos.add("Events/Truth/hGenIDvsMotherMass", ";Process ID ;Mother invariant mass (GeV/c^{2})", HistType::kTH2D, {confAxis.zzAxisNprocesses, confAxis.zzAxisInvMassWide}); + histos.add("Events/Truth/hGenIDvsMotherPt", ";Process ID ;Mother p_{T} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisNprocesses, confAxis.zzAxisPt}); + histos.add("Events/Truth/hGenIDvsMotherRap", ";Process ID ;Mother rapidity (-)", HistType::kTH2D, {confAxis.zzAxisNprocesses, confAxis.zzAxisRap}); + + } // end init + + void processMCgen(aod::McCollision const& collision, aod::McParticles const& particles) + { + + const auto genID = useMcgenidGetGeneratorID ? o2::mcgenid::getGeneratorId(collision.getGeneratorId()) : collision.getGeneratorId(); + + histos.get(HIST("Events/Truth/hGenIDvsCountCollisions"))->Fill(genID, 1); + histos.get(HIST("Events/Truth/hGenIDvsNparticles"))->Fill(genID, particles.size()); + + ROOT::Math::LorentzVector> mother; + for (const auto& particle : particles) { + histos.get(HIST("Events/Truth/hGenIDvsPDGcodesAll"))->Fill(genID, particle.pdgCode()); + // if (!particle.isPhysicalPrimary()) continue; + if (particle.has_mothers()) + continue; + mother.SetPxPyPzE(particle.px(), particle.py(), particle.pz(), energy(pdg->Mass(particle.pdgCode()), particle.px(), particle.py(), particle.pz())); + histos.get(HIST("Events/Truth/hGenIDvsPDGcodesNoMother"))->Fill(genID, particle.pdgCode()); + histos.get(HIST("Events/Truth/hGenIDvsMotherMass"))->Fill(genID, mother.M()); + histos.get(HIST("Events/Truth/hGenIDvsMotherPt"))->Fill(genID, particle.pt()); + histos.get(HIST("Events/Truth/hGenIDvsMotherRap"))->Fill(genID, particle.y()); + const auto& daughters = particle.daughters_as(); + histos.get(HIST("Events/Truth/hGenIDvsNdaughters"))->Fill(genID, daughters.size()); + for (const auto& daughter : daughters) { + histos.get(HIST("Events/Truth/hGenIDvsPDGcodesDaughters"))->Fill(genID, daughter.pdgCode()); + } + } + + } // end processMCgenDG + + PROCESS_SWITCH(TestMcStdTabsRl, processMCgen, "Iterate Monte Carlo UD tables with truth data.", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/Tasks/upcEventITSROFcounter.cxx b/PWGUD/Tasks/upcEventITSROFcounter.cxx index 1da6fbfd26c..51241be5d69 100644 --- a/PWGUD/Tasks/upcEventITSROFcounter.cxx +++ b/PWGUD/Tasks/upcEventITSROFcounter.cxx @@ -9,12 +9,23 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file upcEventITSROFcounter.cxx +/// \brief Personal task to analyze tau events from UPC collisions +/// +/// \author Roman Lavicka , Austrian Academy of Sciences & SMI +/// \since 09.08.2024 + +#include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "ITSMFTBase/DPLAlpideParam.h" #include "CCDB/BasicCCDBManager.h" +#include "ReconstructionDataFormats/Vertex.h" +#include "Common/CCDB/EventSelectionParams.h" #include "Common/DataModel/EventSelection.h" #include "PWGUD/DataModel/UDTables.h" @@ -25,6 +36,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::dataformats; using BCsWithRun3Matchings = soa::Join; using CCs = soa::Join; @@ -39,10 +51,10 @@ struct UpcEventITSROFcounter { Configurable nTracksForUPCevent{"nTracksForUPCevent", 16, {"Maximum of tracks defining a UPC collision"}}; Configurable useTrueGap{"useTrueGap", true, {"Calculate gapSide for a given FV0/FT0/ZDC thresholds"}}; - Configurable cutMyGapSideFV0{"FV0", -1, "FV0A threshold for SG selector"}; - Configurable cutMyGapSideFT0A{"FT0A", 150., "FT0A threshold for SG selector"}; - Configurable cutMyGapSideFT0C{"FT0C", 50., "FT0C threshold for SG selector"}; - Configurable cutMyGapSideZDC{"ZDC", 10., "ZDC threshold for SG selector"}; + Configurable cutMyGapSideFV0{"cutMyGapSideFV0", -1, "FV0A threshold for SG selector"}; + Configurable cutMyGapSideFT0A{"cutMyGapSideFT0A", 150., "FT0A threshold for SG selector"}; + Configurable cutMyGapSideFT0C{"cutMyGapSideFT0C", 50., "FT0C threshold for SG selector"}; + Configurable cutMyGapSideZDC{"cutMyGapSideZDC", 10., "ZDC threshold for SG selector"}; ConfigurableAxis axisRunNumbers{"axisRunNumbers", {1400, 544000.5, 545400.5}, "Range of run numbers"}; void init(InitContext&) @@ -53,6 +65,9 @@ struct UpcEventITSROFcounter { histos.add("Events/hCountCollisionsInROFborderMatching", ";;Number of collision (-)", HistType::kTH1D, {{11, -0.5, 10.5}}); histos.add("Events/hCountUPCcollisionsInROFborderMatching", ";;Number of UPC (mult < 17) collision (-)", HistType::kTH1D, {{11, -0.5, 10.5}}); + histos.add("Events/hPVcontribsVsCollisionsPerITSROFstd", "Collisions reconstructed with standard mode;Number of vertex contributors (-); Number of collisions in one ITSROF (-)", HistType::kTH2D, {{101, -0.5, 100.5}, {11, -0.5, 10.5}}); + histos.add("Events/hPVcontribsVsCollisionsPerITSROFupc", "Collisions reconstructed with upc mode;Number of vertex contributors (-); Number of collisions in one ITSROF (-)", HistType::kTH2D, {{101, -0.5, 100.5}, {11, -0.5, 10.5}}); + histos.add("Runs/hStdModeCollDG", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers}); histos.add("Runs/hUpcModeCollDG", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers}); histos.add("Runs/hStdModeCollSG1", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers}); @@ -78,7 +93,7 @@ struct UpcEventITSROFcounter { int64_t ts = bcs.iteratorAt(0).timestamp(); auto alppar = ccdb->getForTimeStamp>("ITS/Config/AlpideParam", ts); - for (auto bc : bcs) { + for (const auto& bc : bcs) { uint64_t globalBC = bc.globalBC(); uint64_t globalIndex = bc.globalIndex(); if (isFirst) { @@ -98,7 +113,7 @@ struct UpcEventITSROFcounter { previousBCinITSROF = bcInITSROF; previousBCglobalIndex = globalIndex; // next is based on exact matching of bc and collision - for (auto& collision : collisions) { + for (const auto& collision : collisions) { if (collision.has_foundBC()) { if (collision.foundBCId() == bc.globalIndex()) { nAllColls++; @@ -113,16 +128,16 @@ struct UpcEventITSROFcounter { } } } // end loop over collisions - } // end loop over bcs + } // end loop over bcs int arrAllColls[1000] = {0}; int arrUPCcolls[1000] = {0}; // next is based on matching of collision bc within ITSROF range in bcs - for (auto& itsrofBorder : vecITSROFborders) { + for (const auto& itsrofBorder : vecITSROFborders) { int nAllCollsInROF = 0; int nUpcCollsInROF = 0; - for (auto& collision : collisions) { + for (const auto& collision : collisions) { if ((itsrofBorder.first < collision.bcId()) && (collision.bcId() < itsrofBorder.second)) { nAllCollsInROF++; if (collision.numContrib() < nTracksForUPCevent + 1) { @@ -138,6 +153,30 @@ struct UpcEventITSROFcounter { histos.get(HIST("Events/hCountCollisionsInROFborderMatching"))->Fill(ncol, arrAllColls[ncol]); histos.get(HIST("Events/hCountUPCcollisionsInROFborderMatching"))->Fill(ncol, arrUPCcolls[ncol]); } + + // TEST vertex contributors per reconstruction flag (std vs upc) + // matching of collision bc within ITSROF range in bcs + for (const auto& itsrofBorder : vecITSROFborders) { + std::vector vecNumContribsStd; + std::vector vecNumContribsUpc; + for (const auto& collision : collisions) { + if ((itsrofBorder.first < collision.bcId()) && (collision.bcId() < itsrofBorder.second)) { + if (collision.flags() & dataformats::Vertex>::Flags::UPCMode) { + vecNumContribsUpc.push_back(collision.numContrib()); + } else { + vecNumContribsStd.push_back(collision.numContrib()); + } + } + } // end loop over collisions + + for (const auto& numContribs : vecNumContribsStd) { + histos.get(HIST("Events/hPVcontribsVsCollisionsPerITSROFstd"))->Fill(numContribs, vecNumContribsStd.size()); + } + for (const auto& numContribs : vecNumContribsUpc) { + histos.get(HIST("Events/hPVcontribsVsCollisionsPerITSROFupc"))->Fill(numContribs, vecNumContribsUpc.size()); + } + + } // end loop over ITSROFs } void processCounterPerRun(FullSGUDCollision const& coll) @@ -179,5 +218,5 @@ struct UpcEventITSROFcounter { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"upc-event-itsrof-counter"})}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGUD/Tasks/upcForward.cxx b/PWGUD/Tasks/upcForward.cxx index 3a3c6ec722d..bebcf0b2be2 100644 --- a/PWGUD/Tasks/upcForward.cxx +++ b/PWGUD/Tasks/upcForward.cxx @@ -18,7 +18,7 @@ for now AO2D.root I am using is #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Common/DataModel/EventSelection.h" -#include "iostream" +#include #include #include #include diff --git a/PWGUD/Tasks/upcJpsiCentralBarrelCorr.cxx b/PWGUD/Tasks/upcJpsiCentralBarrelCorr.cxx deleted file mode 100644 index fed6937f561..00000000000 --- a/PWGUD/Tasks/upcJpsiCentralBarrelCorr.cxx +++ /dev/null @@ -1,2250 +0,0 @@ -// 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. -/// -/// \brief -/// \author Sara Haidlova, sara.haidlova@cern.ch -/// \since March 2024 - -#include -#include - -// O2 headers -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "CommonConstants/MathConstants.h" -#include "CommonConstants/PhysicsConstants.h" - -// O2Physics headers -#include "Common/DataModel/PIDResponse.h" -#include "Common/Core/RecoDecay.h" -#include "PWGUD/DataModel/UDTables.h" -#include "PWGUD/Core/UDHelpers.h" -#include "PWGUD/Core/UPCJpsiCentralBarrelCorrHelper.h" -#include "PWGUD/Core/SGSelector.h" - -// ROOT headers -#include "TLorentzVector.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using namespace o2::constants::math; - -SGSelector sgSelector; - -struct UpcJpsiCentralBarrel { - // configurable axes - ConfigurableAxis axisIVM{"axisIVM", {500.0f, 2.0f, 4.5f}, "M_#it{inv} (GeV/#it{c}^{2})"}; - ConfigurableAxis axisIVMWide{"axisIVMWide", {350.0f, 0.0f, 4.5f}, "M_#it{inv} (GeV/#it{c}^{2})"}; - ConfigurableAxis axisPt{"axisPt", {250.0f, 0.1f, 3.0f}, "#it{p}_T (GeV/#it{c})"}; - ConfigurableAxis axisPt2{"axisPt2", {250.0f, 0.0f, 0.01f}, "#it{p}_T (GeV/#it{c})"}; - ConfigurableAxis axisPt2wide{"axisPt2wide", {250.0f, 0.0f, 0.04f}, "#it{p}_T (GeV/#it{c})"}; - ConfigurableAxis axisP{"axisP", {250.0f, 0.1f, 3.0f}, "#it{p} (GeV/#it{c})"}; - ConfigurableAxis axisEta{"axisEta", {250.0f, -1.5f, 1.5f}, "#eta (-)"}; - ConfigurableAxis axisCounter{"axisCounter", {20.0f, 0.0f, 20.0f}, "Number of events (-)"}; - ConfigurableAxis axisPhi{"axisPhi", {250.0f, 0, TwoPI}, "#phi (rad)"}; - ConfigurableAxis axisAccAngle{"axisAccAngle", {250.0f, -0.2f, 0.2f}, "accAngle"}; - ConfigurableAxis axisAngTheta{"axisAngTheta", {250.0f, -1.5f, 1.5f}, "cos #theta (-)"}; - ConfigurableAxis axisTPC{"axisTPC", {1000.0f, 0, 200.0f}, "TPC d#it{E}/d#it{x}"}; - ConfigurableAxis axisBetaTOF{"axisBetaTOF", {100.0f, 0, 1.5}, "TOF #beta"}; - ConfigurableAxis axisSigma{"axisSigma", {50, -25, 25}, "#sigma"}; - ConfigurableAxis axisZDCEnergy{"axisZDCEnergy", {250, -5.0, 20.0}, "ZDC energy"}; - ConfigurableAxis axisZDCTime{"axisZDCTime", {200, -10.0, 10.0}, "ZDC time"}; - ConfigurableAxis axisDCA{"axisDCA", {1000, -20.0, 20.0}, "DCA"}; - ConfigurableAxis axisChi2{"axisChi2", {200, -10.0, 40}, "Chi2"}; - ConfigurableAxis axisIVMSel{"axisIVMSel", {1000, 0.0, 10.0}, "IVM"}; - ConfigurableAxis axisCounterSel{"axisCounterSel", {1000, 0.0, 200.0}, "Selection"}; - ConfigurableAxis axisITSNCls{"axisITSNCls", {10, 0.0, 10.0}, "ITSNCls"}; - ConfigurableAxis axisTPCNCls{"axisTPCNCls", {170, -1, 160.0}, "TPCNCls"}; - ConfigurableAxis axisTPCCrossed{"axisTPCCrossed", {300, 20, 170.0}, "TPCCrossedRows"}; - - // configurable cuts (modify in json) - // track quality cuts - Configurable TPCNClsCrossedRows{"TPCNClsCrossedRows", 70, "number of crossed rows in TPC"}; - Configurable TOFAtLeastOneProton{"TOFAtLeastOneProton", false, "at least one candidate track has TOF hits"}; - Configurable TOFBothProtons{"TOFBothProtons", false, "both candidate protons have TOF hits"}; - Configurable TOFOneProton{"TOFOneProton", false, "one candidate proton has TOF hits"}; - Configurable DCAcut{"DCAcut", false, "DCA cut from run2."}; - Configurable newCutTPC{"newCutTPC", false, "New cuts for TPC quality tracks."}; - Configurable EtaCut{"EtaCut", 0.9f, "acceptance cut per track"}; - Configurable cutPtTrack{"cutPtTrack", 0.7f, "pT cut per track"}; - Configurable cutVertexZ{"cutVertexZ", 10.0f, "cut on vertex position in Z"}; - Configurable RapCut{"RapCut", 0.9f, "choose event in midrapidity"}; - Configurable dcaZCut{"dcaZCut", 2, "cut on the impact parameter in z of the track to the PV"}; - Configurable dcaXYCut{"dcaXYCut", 1e10, "cut on the impact parameter in xy of the track to the PV"}; - Configurable ITSNClsCut{"ITSNClsCut", 4, "minimal number of ITS clusters"}; - Configurable ITSChi2NClsCut{"ITSChi2NClsCut", 36, "minimal Chi2/cluster for the ITS track"}; - Configurable TPCNClsCrossedRowsCut{"TPCNClsCrossedRowsCut", 70, "minimal number of crossed TPC rows"}; - Configurable TPCChi2NCls{"TPCChi2NCls", 4, "minimal Chi2/cluster for the TPC track"}; - Configurable TPCMinNCls{"TPCMinNCls", 3, "minimum number of TPC clusters"}; - Configurable TPCCrossedOverFindable{"TPCCrossedOverFindable", 3, "number of TPC crossed rows over findable clusters"}; - - // ZDC classes cuts - Configurable ZNenergyCut{"ZNenergyCut", 0.0, "ZN common energy cut"}; - Configurable ZNtimeCut{"ZNtimeCut", 2.0, "ZN time cut"}; - - // Analysis cuts - Configurable maxJpsiMass{"maxJpsiMass", 3.18, "Maximum of the jpsi peak for peak cut"}; - Configurable minJpsiMass{"minJpsiMass", 3.0, "Minimum of the jpsi peak for peak cut"}; - - // SG cuts - Configurable whichGapSide{"whichGapSide", 2, {"0 for side A, 1 for side C, 2 for both sides"}}; - Configurable useTrueGap{"useTrueGap", true, {"Calculate gapSide for a given FV0/FT0/ZDC thresholds"}}; - Configurable cutMyGapSideFV0{"FV0", 100, "FV0A threshold for SG selector"}; - Configurable cutMyGapSideFT0A{"FT0A", 200., "FT0A threshold for SG selector"}; - Configurable cutMyGapSideFT0C{"FT0C", 100., "FT0C threshold for SG selector"}; - Configurable cutMyGapSideZDC{"ZDC", 1000., "ZDC threshold for SG selector"}; - - // process cuts - Configurable doMuons{"doMuons", true, "Provide muon plots."}; - Configurable doElectrons{"doElectrons", true, "Provide electron plots."}; - Configurable doProtons{"doProtons", true, "Provide proton plots."}; - Configurable chargeOrdered{"chargeOrdered", false, "Order tracks based on charge."}; - Configurable doOnlyUPC{"doOnlyUPC", false, "Analyse only collisions with UPC settings."}; - Configurable doOnlyStandard{"doOnlyStandard", false, "Analyse only collisions with standard settings."}; - - // initialize histogram registry - HistogramRegistry Statistics{ - "Statistics", - {}}; - - HistogramRegistry RawData{ - "RawData", - {}}; - - HistogramRegistry Selections{ - "Selections", - {}}; - - HistogramRegistry PVContributors{ - "PVContributors", - {}}; - - HistogramRegistry TG{ - "TG", - {}}; - - HistogramRegistry TGmu{ - "TGmu", - {}}; - - HistogramRegistry TGmuCand{ - "TGmuCand", - {}}; - - HistogramRegistry TGel{ - "TGel", - {}}; - - HistogramRegistry TGelCand{ - "TGelCand", - {}}; - - HistogramRegistry TGp{ - "TGp", - {}}; - - HistogramRegistry TGpCand{ - "TGpCand", - {}}; - - HistogramRegistry JPsiToEl{ - "JPsiToEl", - {}}; - - HistogramRegistry JPsiToMu{ - "JPsiToMu", - {}}; - - HistogramRegistry JPsiToP{ - "JPsiToP", - {}}; - - HistogramRegistry Correlation{ - "Correlation", - {}}; - - HistogramRegistry Asymmetry{ - "Asymmetry", - {}}; - - HistogramRegistry MC{ - "MC", - {}}; - - using UDCollisionsFull = soa::Join; - using UDCollisionFull = UDCollisionsFull::iterator; - using UDTracksFull = soa::Join; - using UDTrackFull = UDTracksFull::iterator; - using SGUDCollisionFull = soa::Join::iterator; - - void init(InitContext&) - { - - // statistics histograms for counters - Statistics.add("Statistics/hNumberOfCollisions", "hNumberOfCollisions", {HistType::kTH1F, {axisCounter}}); - Statistics.add("Statistics/hNumberOfTracks", "hNumberOfTracks", {HistType::kTH1F, {axisCounter}}); - Statistics.add("Statistics/hNumberGT", "hNumberGT", {HistType::kTH1F, {axisCounter}}); - Statistics.add("Statistics/hCutCounterCollisions", "hCutCounterCollisions", {HistType::kTH1F, {axisCounter}}); - Statistics.add("Statistics/hCutCounterTracks", "hCutCounterTracks", {HistType::kTH1F, {axisCounter}}); - - // raw data histograms - RawData.add("RawData/hTrackPt", "hTrackPt", {HistType::kTH1F, {axisPt}}); - RawData.add("RawData/hTrackEta", "hTrackEta", {HistType::kTH1F, {axisEta}}); - RawData.add("RawData/hTrackPhi", "hTrackPhi", {HistType::kTH1F, {axisPhi}}); - RawData.add("RawData/hTrackDCAXYZ", "hTrackDCAXYZ", {HistType::kTH2F, {axisDCA, axisDCA}}); - RawData.add("RawData/hTPCNClsFindable", "hTPCNClsFindable", {HistType::kTH1F, {axisTPC}}); - RawData.add("RawData/hTPCNClsFindableMinusFound", "hTPCNClsFindableMinusFound", {HistType::kTH1F, {axisTPC}}); - RawData.add("RawData/hITSNCls", "hITSNCls", {HistType::kTH1F, {axisCounter}}); - RawData.add("RawData/hTPCNCls", "hTPCNCls", {HistType::kTH1F, {axisCounter}}); - RawData.add("RawData/hITSChi2NCls", "hITSChi2NCls", {HistType::kTH1F, {axisChi2}}); - RawData.add("RawData/hTPCChi2NCls", "hTPCChi2NCls", {HistType::kTH1F, {axisChi2}}); - RawData.add("RawData/hPositionZ", "hPositionZ", {HistType::kTH1F, {axisSigma}}); - RawData.add("RawData/hPositionX", "hPositionX", {HistType::kTH1F, {axisSigma}}); - RawData.add("RawData/hPositionY", "hPositionY", {HistType::kTH1F, {axisSigma}}); - RawData.add("RawData/hPositionXY", "hPositionXY", {HistType::kTH2F, {axisSigma, axisSigma}}); - RawData.add("RawData/hZNACommonEnergy", "hZNACommonEnergy", {HistType::kTH1F, {axisZDCEnergy}}); - RawData.add("RawData/hZNCCommonEnergy", "hZNCCommonEnergy", {HistType::kTH1F, {axisZDCEnergy}}); - RawData.add("RawData/hZNAvsZNCCommonEnergy", "hZNAvsZNCCommonEnergy", {HistType::kTH2F, {axisZDCEnergy, axisZDCEnergy}}); - RawData.add("RawData/hZNATime", "hZNATime", {HistType::kTH1F, {axisZDCTime}}); - RawData.add("RawData/hZNCTime", "hZNCTime", {HistType::kTH1F, {axisZDCTime}}); - RawData.add("RawData/hZNAvsZNCTime", "hZNAvsZNCTime", {HistType::kTH2F, {axisZDCTime, axisZDCTime}}); - RawData.add("RawData/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - RawData.add("RawData/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - RawData.add("RawData/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - RawData.add("RawData/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - RawData.add("RawData/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // Selection checks - Selections.add("Selections/Electron/Mass/Leading/hITSNClsVsM", "hITSNClsVsM", {HistType::kTH2F, {axisIVMSel, axisITSNCls}}); - Selections.add("Selections/Electron/Mass/Leading/hITSChi2NClsVsM", "hITSChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisChi2}}); - Selections.add("Selections/Electron/Mass/Leading/hTPCNClsVsM", "hTPCNClsVsM", {HistType::kTH2F, {axisIVMSel, axisTPCNCls}}); - Selections.add("Selections/Electron/Mass/Leading/hTPCChi2NClsVsM", "hTPCChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisChi2}}); - Selections.add("Selections/Electron/Mass/Leading/hTPCNClsCrossedRowsVsM", "hTPCNClsCrossedRowsVsM", {HistType::kTH2F, {axisIVMSel, axisTPCCrossed}}); - Selections.add("Selections/Electron/Mass/Subleading/hITSNClsVsM", "hITSNClsVsM", {HistType::kTH2F, {axisIVMSel, axisITSNCls}}); - Selections.add("Selections/Electron/Mass/Subleading/hITSChi2NClsVsM", "hITSChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisChi2}}); - Selections.add("Selections/Electron/Mass/Subleading/hTPCNClsVsM", "hTPCNClsVsM", {HistType::kTH2F, {axisIVMSel, axisTPCNCls}}); - Selections.add("Selections/Electron/Mass/Subleading/hTPCChi2NClsVsM", "hTPCChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisChi2}}); - Selections.add("Selections/Electron/Mass/Subleading/hTPCNClsCrossedRowsVsM", "hTPCNClsCrossedRowsVsM", {HistType::kTH2F, {axisIVMSel, axisTPCCrossed}}); - - Selections.add("Selections/Electron/Rapidity/Leading/hITSNClsVsY", "hITSNClsVsY", {HistType::kTH2F, {axisEta, axisITSNCls}}); - Selections.add("Selections/Electron/Rapidity/Leading/hITSChi2NClsVsY", "hITSChi2NClsVsY", {HistType::kTH2F, {axisEta, axisChi2}}); - Selections.add("Selections/Electron/Rapidity/Leading/hTPCNClsVsY", "hTPCNClsVsY", {HistType::kTH2F, {axisEta, axisTPCNCls}}); - Selections.add("Selections/Electron/Rapidity/Leading/hTPCChi2NClsVsY", "hTPCChi2NClsVsY", {HistType::kTH2F, {axisEta, axisChi2}}); - Selections.add("Selections/Electron/Rapidity/Leading/hTPCNClsCrossedRowsVsY", "hTPCNClsCrossedRowsVsY", {HistType::kTH2F, {axisEta, axisTPCCrossed}}); - Selections.add("Selections/Electron/Rapidity/Subleading/hITSNClsVsY", "hITSNClsVsY", {HistType::kTH2F, {axisEta, axisITSNCls}}); - Selections.add("Selections/Electron/Rapidity/Subleading/hITSChi2NClsVsY", "hITSChi2NClsVsY", {HistType::kTH2F, {axisEta, axisChi2}}); - Selections.add("Selections/Electron/Rapidity/Subleading/hTPCNClsVsY", "hTPCNClsVsY", {HistType::kTH2F, {axisEta, axisTPCNCls}}); - Selections.add("Selections/Electron/Rapidity/Subleading/hTPCChi2NClsVsY", "hTPCChi2NClsVsY", {HistType::kTH2F, {axisEta, axisChi2}}); - Selections.add("Selections/Electron/Rapidity/Subleading/hTPCNClsCrossedRowsVsY", "hTPCNClsCrossedRowsVsY", {HistType::kTH2F, {axisEta, axisTPCCrossed}}); - - Selections.add("Selections/Electron/Pt/Leading/hITSNClsVsPt", "hITSNClsVsPt", {HistType::kTH2F, {axisPt, axisITSNCls}}); - Selections.add("Selections/Electron/Pt/Leading/hITSChi2NClsVsPt", "hITSChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisChi2}}); - Selections.add("Selections/Electron/Pt/Leading/hTPCNClsVsPt", "hTPCNClsVsPt", {HistType::kTH2F, {axisPt, axisTPCNCls}}); - Selections.add("Selections/Electron/Pt/Leading/hTPCChi2NClsVsPt", "hTPCChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisChi2}}); - Selections.add("Selections/Electron/Pt/Leading/hTPCNClsCrossedRowsVsPt", "hTPCNClsCrossedRowsVsPt", {HistType::kTH2F, {axisPt, axisTPCCrossed}}); - Selections.add("Selections/Electron/Pt/Subleading/hITSNClsVsPt", "hITSNClsVsPt", {HistType::kTH2F, {axisPt, axisITSNCls}}); - Selections.add("Selections/Electron/Pt/Subleading/hITSChi2NClsVsPt", "hITSChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisChi2}}); - Selections.add("Selections/Electron/Pt/Subleading/hTPCNClsVsPt", "hTPCNClsVsPt", {HistType::kTH2F, {axisPt, axisTPCNCls}}); - Selections.add("Selections/Electron/Pt/Subleading/hTPCChi2NClsVsPt", "hTPCChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisChi2}}); - Selections.add("Selections/Electron/Pt/Subleading/hTPCNClsCrossedRowsVsPt", "hTPCNClsCrossedRowsVsPt", {HistType::kTH2F, {axisPt, axisTPCCrossed}}); - - Selections.add("Selections/Muon/Mass/Leading/hITSNClsVsM", "hITSNClsVsM", {HistType::kTH2F, {axisIVMSel, axisITSNCls}}); - Selections.add("Selections/Muon/Mass/Leading/hITSChi2NClsVsM", "hITSChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisChi2}}); - Selections.add("Selections/Muon/Mass/Leading/hTPCNClsVsM", "hTPCNClsVsM", {HistType::kTH2F, {axisIVMSel, axisTPCNCls}}); - Selections.add("Selections/Muon/Mass/Leading/hTPCChi2NClsVsM", "hTPCChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisChi2}}); - Selections.add("Selections/Muon/Mass/Leading/hTPCNClsCrossedRowsVsM", "hTPCNClsCrossedRowsVsM", {HistType::kTH2F, {axisIVMSel, axisTPCCrossed}}); - Selections.add("Selections/Muon/Mass/Subleading/hITSNClsVsM", "hITSNClsVsM", {HistType::kTH2F, {axisIVMSel, axisITSNCls}}); - Selections.add("Selections/Muon/Mass/Subleading/hITSChi2NClsVsM", "hITSChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisChi2}}); - Selections.add("Selections/Muon/Mass/Subleading/hTPCNClsVsM", "hTPCNClsVsM", {HistType::kTH2F, {axisIVMSel, axisTPCNCls}}); - Selections.add("Selections/Muon/Mass/Subleading/hTPCChi2NClsVsM", "hTPCChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisChi2}}); - Selections.add("Selections/Muon/Mass/Subleading/hTPCNClsCrossedRowsVsM", "hTPCNClsCrossedRowsVsM", {HistType::kTH2F, {axisIVMSel, axisTPCCrossed}}); - - Selections.add("Selections/Muon/Rapidity/Leading/hITSNClsVsY", "hITSNClsVsY", {HistType::kTH2F, {axisEta, axisITSNCls}}); - Selections.add("Selections/Muon/Rapidity/Leading/hITSChi2NClsVsY", "hITSChi2NClsVsY", {HistType::kTH2F, {axisEta, axisChi2}}); - Selections.add("Selections/Muon/Rapidity/Leading/hTPCNClsVsY", "hTPCNClsVsY", {HistType::kTH2F, {axisEta, axisTPCNCls}}); - Selections.add("Selections/Muon/Rapidity/Leading/hTPCChi2NClsVsY", "hTPCChi2NClsVsY", {HistType::kTH2F, {axisEta, axisChi2}}); - Selections.add("Selections/Muon/Rapidity/Leading/hTPCNClsCrossedRowsVsY", "hTPCNClsCrossedRowsVsY", {HistType::kTH2F, {axisEta, axisTPCCrossed}}); - Selections.add("Selections/Muon/Rapidity/Subleading/hITSNClsVsY", "hITSNClsVsY", {HistType::kTH2F, {axisEta, axisITSNCls}}); - Selections.add("Selections/Muon/Rapidity/Subleading/hITSChi2NClsVsY", "hITSChi2NClsVsY", {HistType::kTH2F, {axisEta, axisChi2}}); - Selections.add("Selections/Muon/Rapidity/Subleading/hTPCNClsVsY", "hTPCNClsVsY", {HistType::kTH2F, {axisEta, axisTPCNCls}}); - Selections.add("Selections/Muon/Rapidity/Subleading/hTPCChi2NClsVsY", "hTPCChi2NClsVsY", {HistType::kTH2F, {axisEta, axisChi2}}); - Selections.add("Selections/Muon/Rapidity/Subleading/hTPCNClsCrossedRowsVsY", "hTPCNClsCrossedRowsVsY", {HistType::kTH2F, {axisEta, axisTPCCrossed}}); - - Selections.add("Selections/Muon/Pt/Leading/hITSNClsVsPt", "hITSNClsVsPt", {HistType::kTH2F, {axisPt, axisITSNCls}}); - Selections.add("Selections/Muon/Pt/Leading/hITSChi2NClsVsPt", "hITSChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisChi2}}); - Selections.add("Selections/Muon/Pt/Leading/hTPCNClsVsPt", "hTPCNClsVsPt", {HistType::kTH2F, {axisPt, axisTPCNCls}}); - Selections.add("Selections/Muon/Pt/Leading/hTPCChi2NClsVsPt", "hTPCChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisChi2}}); - Selections.add("Selections/Muon/Pt/Leading/hTPCNClsCrossedRowsVsPt", "hTPCNClsCrossedRowsVsPt", {HistType::kTH2F, {axisPt, axisTPCCrossed}}); - Selections.add("Selections/Muon/Pt/Subleading/hITSNClsVsPt", "hITSNClsVsPt", {HistType::kTH2F, {axisPt, axisITSNCls}}); - Selections.add("Selections/Muon/Pt/Subleading/hITSChi2NClsVsPt", "hITSChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisChi2}}); - Selections.add("Selections/Muon/Pt/Subleading/hTPCNClsVsPt", "hTPCNClsVsPt", {HistType::kTH2F, {axisPt, axisTPCNCls}}); - Selections.add("Selections/Muon/Pt/Subleading/hTPCChi2NClsVsPt", "hTPCChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisChi2}}); - Selections.add("Selections/Muon/Pt/Subleading/hTPCNClsCrossedRowsVsPt", "hTPCNClsCrossedRowsVsPt", {HistType::kTH2F, {axisPt, axisTPCCrossed}}); - - // PVContributors histograms - PVContributors.add("PVContributors/hTrackPt", "hTrackPt", {HistType::kTH1F, {axisPt}}); - PVContributors.add("PVContributors/hTrackEta", "hTrackEta", {HistType::kTH1F, {axisEta}}); - PVContributors.add("PVContributors/hTrackPhi", "hTrackPhi", {HistType::kTH1F, {axisPhi}}); - PVContributors.add("PVContributors/hTPCNClsFindable", "hTPCNClsFindable", {HistType::kTH1F, {axisTPC}}); - PVContributors.add("PVContributors/hTPCNClsFindableMinusFound", "hTPCNClsFindableMinusFound", {HistType::kTH1F, {axisTPC}}); - PVContributors.add("PVContributors/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - PVContributors.add("PVContributors/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - PVContributors.add("PVContributors/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - PVContributors.add("PVContributors/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - PVContributors.add("PVContributors/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // TG histograms - TG.add("TG/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); - TG.add("TG/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); - TG.add("TG/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); - TG.add("TG/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); - TG.add("TG/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); - TG.add("TG/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); - TG.add("TG/hTPCNClsFindable", "hTPCNClsFindable", {HistType::kTH1F, {axisTPC}}); - TG.add("TG/hTPCNClsFindableMinusFound", "hTPCNClsFindableMinusFound", {HistType::kTH1F, {axisTPC}}); - TG.add("TG/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - TG.add("TG/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - TG.add("TG/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - TG.add("TG/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - TG.add("TG/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - TG.add("TG/TPC/TPCNegVsPosSignal", "TPCNegVsPosSignal", HistType::kTH2F, {axisTPC, axisTPC}); - - // TGmu histograms - TGmu.add("TGmu/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); - TGmu.add("TGmu/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); - TGmu.add("TGmu/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); - TGmu.add("TGmu/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); - TGmu.add("TGmu/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); - TGmu.add("TGmu/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); - TGmu.add("TGmu/TPCNegVsPosSignal", "TPCNegVsPosSignal", HistType::kTH2F, {axisTPC, axisTPC}); - TGmu.add("TGmu/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - TGmu.add("TGmu/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - TGmu.add("TGmu/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - TGmu.add("TGmu/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - TGmu.add("TGmu/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // TGmuCand histograms - TGmuCand.add("TGmuCand/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); - TGmuCand.add("TGmuCand/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); - TGmuCand.add("TGmuCand/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); - TGmuCand.add("TGmuCand/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); - TGmuCand.add("TGmuCand/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); - TGmuCand.add("TGmuCand/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); - TGmuCand.add("TGmuCand/hPairPt", "hPairPt", {HistType::kTH1F, {axisPt}}); - TGmuCand.add("TGmuCand/hPairIVM", "hPairIVM", {HistType::kTH1F, {axisIVMWide}}); - TGmuCand.add("TGmuCand/hJpsiPt", "hJpsiPt", {HistType::kTH1F, {axisPt}}); - TGmuCand.add("TGmuCand/hJpsiPt2", "hJpsiPt2", {HistType::kTH1F, {axisPt2}}); - TGmuCand.add("TGmuCand/XnXn/hJpsiPt2", "hJpsiPt2", {HistType::kTH1F, {axisPt2}}); - TGmuCand.add("TGmuCand/OnOn/hJpsiPt2", "hJpsiPt2", {HistType::kTH1F, {axisPt2}}); - TGmuCand.add("TGmuCand/OnXn/hJpsiPt2", "hJpsiPt2", {HistType::kTH1F, {axisPt2}}); - TGmuCand.add("TGmuCand/XnOn/hJpsiPt2", "hJpsiPt2", {HistType::kTH1F, {axisPt2}}); - TGmuCand.add("TGmuCand/hJpsiPt2wide", "hJpsiPt2wide", {HistType::kTH1F, {axisPt2}}); - TGmuCand.add("TGmuCand/XnXn/hJpsiPt2wide", "hJpsiPt2wide", {HistType::kTH1F, {axisPt2wide}}); - TGmuCand.add("TGmuCand/OnOn/hJpsiPt2wide", "hJpsiPt2wide", {HistType::kTH1F, {axisPt2wide}}); - TGmuCand.add("TGmuCand/OnXn/hJpsiPt2wide", "hJpsiPt2wide", {HistType::kTH1F, {axisPt2wide}}); - TGmuCand.add("TGmuCand/XnOn/hJpsiPt2wide", "hJpsiPt2wide", {HistType::kTH1F, {axisPt2wide}}); - TGmuCand.add("TGmuCand/hJpsiRap", "hJpsiRap", {HistType::kTH1F, {axisEta}}); - TGmuCand.add("TGmuCand/TPCNegVsPosSignal", "TPCNegVsPosSignal", HistType::kTH2F, {axisTPC, axisTPC}); - TGmuCand.add("TGmuCand/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - TGmuCand.add("TGmuCand/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - TGmuCand.add("TGmuCand/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - TGmuCand.add("TGmuCand/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - TGmuCand.add("TGmuCand/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // TGel histograms - TGel.add("TGel/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); - TGel.add("TGel/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); - TGel.add("TGel/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); - TGel.add("TGel/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); - TGel.add("TGel/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); - TGel.add("TGel/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); - TGel.add("TGel/TPCNegVsPosSignal", "TPCNegVsPosSignal", HistType::kTH2F, {axisTPC, axisTPC}); - TGel.add("TGel/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - TGel.add("TGel/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - TGel.add("TGel/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - TGel.add("TGel/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - TGel.add("TGel/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // TGelCand histograms - TGelCand.add("TGelCand/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); - TGelCand.add("TGelCand/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); - TGelCand.add("TGelCand/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); - TGelCand.add("TGelCand/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); - TGelCand.add("TGelCand/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); - TGelCand.add("TGelCand/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); - TGelCand.add("TGelCand/TPCNegVsPosSignal", "TPCNegVsPosSignal", HistType::kTH2F, {axisTPC, axisTPC}); - TGelCand.add("TGelCand/hPairPt", "hPairPt", {HistType::kTH1F, {axisPt}}); - TGelCand.add("TGelCand/hPairIVM", "hPairIVM", {HistType::kTH1F, {axisIVMWide}}); - TGelCand.add("TGelCand/hJpsiPt", "hJpsiPt", {HistType::kTH1F, {axisPt}}); - TGelCand.add("TGelCand/hJpsiRap", "hJpsiRap", {HistType::kTH1F, {axisEta}}); - TGelCand.add("TGelCand/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - TGelCand.add("TGelCand/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - TGelCand.add("TGelCand/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - TGelCand.add("TGelCand/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - TGelCand.add("TGelCand/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // TGp histograms - TGp.add("TGp/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); - TGp.add("TGp/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); - TGp.add("TGp/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); - TGp.add("TGp/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); - TGp.add("TGp/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); - TGp.add("TGp/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); - TGp.add("TGp/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - TGp.add("TGp/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - TGp.add("TGp/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - TGp.add("TGp/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - TGp.add("TGp/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // TGpCand histograms - TGpCand.add("TGpCand/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); - TGpCand.add("TGpCand/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); - TGpCand.add("TGpCand/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); - TGpCand.add("TGpCand/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); - TGpCand.add("TGpCand/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); - TGpCand.add("TGpCand/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); - TGpCand.add("TGpCand/hPairPt", "hPairPt", {HistType::kTH1F, {axisPt}}); - TGpCand.add("TGpCand/hPairIVM", "hPairIVM", {HistType::kTH1F, {axisIVMWide}}); - TGpCand.add("TGpCand/hJpsiPt", "hJpsiPt", {HistType::kTH1F, {axisPt}}); - TGpCand.add("TGpCand/hJpsiRap", "hJpsiRap", {HistType::kTH1F, {axisEta}}); - TGpCand.add("TGpCand/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - TGpCand.add("TGpCand/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - TGpCand.add("TGpCand/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - TGpCand.add("TGpCand/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - TGpCand.add("TGpCand/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // JPsiToEl histograms - JPsiToEl.add("JPsiToEl/Coherent/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Coherent/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/XnXn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/OnOn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/OnXn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Coherent/XnOn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Coherent/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - JPsiToEl.add("JPsiToEl/Coherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - JPsiToEl.add("JPsiToEl/Coherent/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - JPsiToEl.add("JPsiToEl/Coherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - JPsiToEl.add("JPsiToEl/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - JPsiToEl.add("JPsiToEl/Incoherent/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/NotCoherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Incoherent/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/NotCoherent/XnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnXn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/NotCoherent/OnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnOn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/NotCoherent/OnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/OnXn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/NotCoherent/XnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToEl.add("JPsiToEl/Incoherent/XnOn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToEl.add("JPsiToEl/Incoherent/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - JPsiToEl.add("JPsiToEl/Incoherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - JPsiToEl.add("JPsiToEl/Incoherent/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - JPsiToEl.add("JPsiToEl/Incoherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - JPsiToEl.add("JPsiToEl/Incoherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // JPsiToMu histograms - JPsiToMu.add("JPsiToMu/Coherent/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Coherent/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/XnXn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/OnOn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/OnXn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Coherent/XnOn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Coherent/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - JPsiToMu.add("JPsiToMu/Coherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - JPsiToMu.add("JPsiToMu/Coherent/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - JPsiToMu.add("JPsiToMu/Coherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - JPsiToMu.add("JPsiToMu/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - JPsiToMu.add("JPsiToMu/Incoherent/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/NotCoherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Incoherent/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/NotCoherent/XnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnXn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/NotCoherent/OnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnOn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/NotCoherent/OnXn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/OnXn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/NotCoherent/XnOn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToMu.add("JPsiToMu/Incoherent/XnOn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToMu.add("JPsiToMu/Incoherent/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - JPsiToMu.add("JPsiToMu/Incoherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - JPsiToMu.add("JPsiToMu/Incoherent/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - JPsiToMu.add("JPsiToMu/Incoherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - JPsiToMu.add("JPsiToMu/Incoherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // JPsiToP histograms - JPsiToP.add("JPsiToP/Coherent/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToP.add("JPsiToP/Coherent/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToP.add("JPsiToP/Coherent/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToP.add("JPsiToP/Coherent/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToP.add("JPsiToP/Coherent/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToP.add("JPsiToP/Coherent/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToP.add("JPsiToP/Coherent/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToP.add("JPsiToP/Coherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToP.add("JPsiToP/Coherent/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToP.add("JPsiToP/Coherent/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToP.add("JPsiToP/Coherent/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToP.add("JPsiToP/Coherent/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - JPsiToP.add("JPsiToP/Coherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - JPsiToP.add("JPsiToP/Coherent/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - JPsiToP.add("JPsiToP/Coherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - JPsiToP.add("JPsiToP/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - JPsiToP.add("JPsiToP/Incoherent/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToP.add("JPsiToP/Incoherent/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToP.add("JPsiToP/Incoherent/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); - JPsiToP.add("JPsiToP/Incoherent/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToP.add("JPsiToP/Incoherent/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToP.add("JPsiToP/Incoherent/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToP.add("JPsiToP/Incoherent/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToP.add("JPsiToP/Incoherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); - JPsiToP.add("JPsiToP/Incoherent/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); - JPsiToP.add("JPsiToP/Incoherent/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); - JPsiToP.add("JPsiToP/Incoherent/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); - JPsiToP.add("JPsiToP/Incoherent/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); - JPsiToP.add("JPsiToP/Incoherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); - JPsiToP.add("JPsiToP/Incoherent/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); - JPsiToP.add("JPsiToP/Incoherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); - JPsiToP.add("JPsiToP/Incoherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); - - // Correlation histograms - Correlation.add("Correlation/Muon/Coherent/AccoplAngle", "AccoplAngle", {HistType::kTH1F, {axisAccAngle}}); - Correlation.add("Correlation/Muon/Coherent/CosTheta", "CosTheta", {HistType::kTH1F, {axisAngTheta}}); - Correlation.add("Correlation/Muon/Coherent/Phi", "Phi", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Muon/Coherent/Phi1", "Phi1", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Muon/Coherent/Phi2", "Phi2", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Muon/Coherent/CosThetaPhi", "CosThetaPhi", {HistType::kTH2F, {{axisAngTheta}, {axisPhi}}}); - - Correlation.add("Correlation/Muon/Incoherent/AccoplAngle", "AccoplAngle", {HistType::kTH1F, {axisAccAngle}}); - Correlation.add("Correlation/Muon/Incoherent/CosTheta", "CosTheta", {HistType::kTH1F, {axisAngTheta}}); - Correlation.add("Correlation/Muon/Incoherent/Phi", "Phi", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Muon/Incoherent/Phi1", "Phi1", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Muon/Incoherent/Phi2", "Phi2", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Muon/Incoherent/CosThetaPhi", "CosThetaPhi", {HistType::kTH2F, {{axisAngTheta}, {axisPhi}}}); - - Correlation.add("Correlation/Electron/Coherent/AccoplAngle", "AccoplAngle", {HistType::kTH1F, {axisAccAngle}}); - Correlation.add("Correlation/Electron/Coherent/CosTheta", "CosTheta", {HistType::kTH1F, {axisAngTheta}}); - Correlation.add("Correlation/Electron/Coherent/Phi", "Phi", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Electron/Coherent/Phi1", "Phi1", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Electron/Coherent/Phi2", "Phi2", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Electron/Coherent/CosThetaPhi", "CosThetaPhi", {HistType::kTH2F, {{axisAngTheta}, {axisPhi}}}); - - Correlation.add("Correlation/Electron/Incoherent/AccoplAngle", "AccoplAngle", {HistType::kTH1F, {axisAccAngle}}); - Correlation.add("Correlation/Electron/Incoherent/CosTheta", "CosTheta", {HistType::kTH1F, {axisAngTheta}}); - Correlation.add("Correlation/Electron/Incoherent/Phi", "Phi", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Electron/Incoherent/Phi1", "Phi1", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Electron/Incoherent/Phi2", "Phi2", {HistType::kTH1F, {axisPhi}}); - Correlation.add("Correlation/Electron/Incoherent/CosThetaPhi", "CosThetaPhi", {HistType::kTH2F, {{axisAngTheta}, {axisPhi}}}); - - // Asymmetry histograms - Asymmetry.add("Asymmetry/Muon/Coherent/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Coherent/XnXn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Coherent/OnOn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Coherent/XnOn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Coherent/OnXn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/XnXn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/OnOn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/XnOn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/OnXn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/XnXn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/OnOn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/XnOn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/OnXn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/XnXn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/OnOn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/XnOn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/OnXn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Coherent/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Coherent/XnXn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Coherent/OnOn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Coherent/XnOn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Coherent/OnXn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/XnXn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/OnOn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/XnOn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Muon/Incoherent/OnXn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/XnXn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/OnOn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/XnOn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Coherent/OnXn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/XnXn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/OnOn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/XnOn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - Asymmetry.add("Asymmetry/Electron/Incoherent/OnXn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); - - // MC histograms - MC.add("MC/hNumberOfMCCollisions", "hNumberOfCollisions", {HistType::kTH1F, {{10, 0, 10}}}); - MC.add("MC/hNumberOfRecoCollisions", "hNumberOfRecoCollisions", {HistType::kTH1F, {{10, 0, 10}}}); - MC.add("MC/Muon/hNumberOfMCTracks", "hNumberOfMCTracks", {HistType::kTH1F, {{10, 0, 10}}}); - MC.add("MC/Electron/hNumberOfMCTracks", "hNumberOfMCTracks", {HistType::kTH1F, {{10, 0, 10}}}); - MC.add("MC/Proton/hNumberOfMCTracks", "hNumberOfMCTracks", {HistType::kTH1F, {{10, 0, 10}}}); - MC.add("MC/hPosZ", "hPosZ", {HistType::kTH1F, {{60, -15, 15}}}); - MC.add("MC/hPDG", "hPDG", {HistType::kTH1F, {{200000, -100000, 100000}}}); - MC.add("MC/Electron/hEta1", "hEta1", {HistType::kTH1F, {axisEta}}); - MC.add("MC/Electron/hEta2", "hEta2", {HistType::kTH1F, {axisEta}}); - MC.add("MC/Electron/hPhi1", "hPhi1", {HistType::kTH1F, {axisPhi}}); - MC.add("MC/Electron/hPhi2", "hPhi2", {HistType::kTH1F, {axisPhi}}); - MC.add("MC/Electron/hIVM", "hIVM", {HistType::kTH1F, {axisIVM}}); - MC.add("MC/Electron/hRapidity", "hRapidity", {HistType::kTH1F, {axisEta}}); - MC.add("MC/Electron/hPt1", "hPt1", {HistType::kTH1F, {axisPt}}); - MC.add("MC/Electron/hPt2", "hPt2", {HistType::kTH1F, {axisPt}}); - MC.add("MC/Electron/hPt", "hPt", {HistType::kTH1F, {axisPt}}); - MC.add("MC/Muon/hEta1", "hEta1", {HistType::kTH1F, {axisEta}}); - MC.add("MC/Muon/hEta2", "hEta2", {HistType::kTH1F, {axisEta}}); - MC.add("MC/Muon/hPhi1", "hPhi1", {HistType::kTH1F, {axisPhi}}); - MC.add("MC/Muon/hPhi2", "hPhi2", {HistType::kTH1F, {axisPhi}}); - MC.add("MC/Muon/hIVM", "hIVM", {HistType::kTH1F, {axisIVM}}); - MC.add("MC/Muon/hRapidity", "hRapidity", {HistType::kTH1F, {axisEta}}); - MC.add("MC/Muon/hPt1", "hPt1", {HistType::kTH1F, {axisPt}}); - MC.add("MC/Muon/hPt2", "hPt2", {HistType::kTH1F, {axisPt}}); - MC.add("MC/Muon/hPt", "hPt", {HistType::kTH1F, {axisPt}}); - MC.add("MC/Proton/hEta1", "hEta1", {HistType::kTH1F, {axisEta}}); - MC.add("MC/Proton/hEta2", "hEta2", {HistType::kTH1F, {axisEta}}); - MC.add("MC/Proton/hPhi1", "hPhi1", {HistType::kTH1F, {axisPhi}}); - MC.add("MC/Proton/hPhi2", "hPhi2", {HistType::kTH1F, {axisPhi}}); - MC.add("MC/Proton/hIVM", "hIVM", {HistType::kTH1F, {axisIVM}}); - MC.add("MC/Proton/hRapidity", "hRapidity", {HistType::kTH1F, {axisEta}}); - MC.add("MC/Proton/hPt1", "hPt1", {HistType::kTH1F, {axisPt}}); - MC.add("MC/Proton/hPt2", "hPt2", {HistType::kTH1F, {axisPt}}); - MC.add("MC/Proton/hPt", "hPt", {HistType::kTH1F, {axisPt}}); - } - - bool cutITSLayers(uint8_t itsClusterMap) const - { - std::vector>> requiredITSHits{}; - requiredITSHits.push_back(std::make_pair(1, std::array{0, 1, 2})); // at least one hit in the innermost layer - constexpr uint8_t bit = 1; - for (auto& itsRequirement : requiredITSHits) { - auto hits = std::count_if(itsRequirement.second.begin(), itsRequirement.second.end(), [&](auto&& requiredLayer) { return itsClusterMap & (bit << requiredLayer); }); - - if ((itsRequirement.first == -1) && (hits > 0)) { - return false; // no hits were required in specified layers - } else if (hits < itsRequirement.first) { - return false; // not enough hits found in specified layers - } - } - return true; - } - - template - bool GoodTrackCuts(T const& track) - { - // choose only PV contributors - if (!track.isPVContributor()) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(1); - return false; - } - // pT cut to choose only tracks contributing to J/psi - if (track.pt() < cutPtTrack) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(2); - return false; - } - // acceptance cut (TPC) - if (std::abs(RecoDecay::eta(std::array{track.px(), track.py(), track.pz()})) > EtaCut) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(3); - return false; - } - // DCA - if (std::abs(track.dcaZ()) > dcaZCut) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(4); - return false; - } - if (DCAcut) { - float dcaXYPtCut = 0.0105f + 0.0350f / pow(track.pt(), 1.1f); - if (std::abs(track.dcaXY()) > dcaXYPtCut) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(5); - return false; - } - } else { - if (std::abs(track.dcaXY()) > dcaXYCut) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(5); - return false; - } - } - // ITS - if (!track.hasITS()) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(6); - return false; - } - if (track.itsNCls() < ITSNClsCut) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(7); - return false; - } - if (!cutITSLayers(track.itsClusterMap())) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(8); - return false; - } - if (track.itsChi2NCl() > ITSChi2NClsCut) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(9); - return false; - } - // TPC - if (!track.hasTPC()) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(10); - return false; - } - if (track.tpcNClsCrossedRows() < TPCNClsCrossedRowsCut) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(11); - return false; - } - if (track.tpcChi2NCl() > TPCChi2NCls) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(12); - return false; // TPC chi2 - } - if ((track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()) < TPCMinNCls) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(13); - return false; - } - if (newCutTPC) { - if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < TPCCrossedOverFindable) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(14); - return false; - } - } - - return true; - } - - // template - bool CandidateCuts(float massJpsi, float rapJpsi) - { - if (std::abs(rapJpsi) > RapCut) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(15); - return false; - } - - if (massJpsi < 2.0f) { - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(16); - return false; - } - - return true; - } - - template - void fillHistograms(C collision, Ts tracks) - { - Statistics.get(HIST("Statistics/hCutCounterCollisions"))->Fill(0); // number of collisions without any cuts - - // check UPC vs standard - if (doOnlyUPC) { - if (collision.flags() == 0) { - return; - } - } - if (doOnlyStandard) { - if (collision.flags() == 1) { - return; - } - } - - // distinguish ZDC classes - bool XnXn = false, OnOn = false, XnOn = false, OnXn = false; - if (collision.energyCommonZNA() < ZNenergyCut && collision.energyCommonZNC() < ZNenergyCut) { - OnOn = true; - } - if (collision.energyCommonZNA() > ZNenergyCut && std::abs(collision.timeZNA()) < ZNtimeCut && collision.energyCommonZNC() > ZNenergyCut && std::abs(collision.timeZNC()) < ZNtimeCut) { - XnXn = true; - } - if (collision.energyCommonZNA() > ZNenergyCut && std::abs(collision.timeZNA()) < ZNtimeCut && collision.energyCommonZNC() < ZNenergyCut) { - XnOn = true; - } - if (collision.energyCommonZNA() < ZNenergyCut && collision.energyCommonZNC() > ZNenergyCut && std::abs(collision.timeZNC()) < ZNtimeCut) { - OnXn = true; - } - - // loop over tracks without selections - for (auto& track : tracks) { - float trkPx = track.px(); - float trkPy = track.py(); - float trkPz = track.pz(); - - Statistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(0); - Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(0); - if (track.isPVContributor() == 1) { - Statistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(1); - PVContributors.get(HIST("PVContributors/hTrackPt"))->Fill(track.pt()); - PVContributors.get(HIST("PVContributors/hTrackEta"))->Fill(RecoDecay::eta(std::array{trkPx, trkPy, trkPz})); - PVContributors.get(HIST("PVContributors/hTrackPhi"))->Fill(RecoDecay::phi(trkPx, trkPy)); - - if (track.hasTPC()) { - PVContributors.get(HIST("PVContributors/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkPx, trkPy, trkPz), track.tpcSignal()); - PVContributors.get(HIST("PVContributors/PID/hTPCVsPt"))->Fill(track.pt(), track.tpcSignal()); - PVContributors.get(HIST("PVContributors/PID/hTPCVsEta"))->Fill(RecoDecay::eta(std::array{trkPx, trkPy, trkPz}), track.tpcSignal()); - PVContributors.get(HIST("PVContributors/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(trkPx, trkPy), track.tpcSignal()); - PVContributors.get(HIST("PVContributors/hTPCNClsFindable"))->Fill(track.tpcNClsFindable()); - PVContributors.get(HIST("PVContributors/hTPCNClsFindableMinusFound"))->Fill(track.tpcNClsFindableMinusFound()); - } - - if (track.hasTOF()) { - PVContributors.get(HIST("PVContributors/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkPx, trkPy, trkPz), track.beta()); - } - } - - RawData.get(HIST("RawData/hTrackPt"))->Fill(track.pt()); - RawData.get(HIST("RawData/hTrackEta"))->Fill(RecoDecay::eta(std::array{trkPx, trkPy, trkPz})); - RawData.get(HIST("RawData/hTrackPhi"))->Fill(RecoDecay::phi(trkPx, trkPy)); - RawData.get(HIST("RawData/hTrackDCAXYZ"))->Fill(track.dcaXY(), track.dcaZ()); - RawData.get(HIST("RawData/hTPCNClsFindable"))->Fill(track.tpcNClsFindable()); - RawData.get(HIST("RawData/hTPCNClsFindableMinusFound"))->Fill(track.tpcNClsFindableMinusFound()); - RawData.get(HIST("RawData/hITSNCls"))->Fill(track.itsNCls()); - RawData.get(HIST("RawData/hTPCNCls"))->Fill(track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()); - RawData.get(HIST("RawData/hITSChi2NCls"))->Fill(track.itsChi2NCl()); - RawData.get(HIST("RawData/hTPCChi2NCls"))->Fill(track.tpcChi2NCl()); - - if (track.hasTPC()) { - RawData.get(HIST("RawData/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkPx, trkPy, trkPz), track.tpcSignal()); - RawData.get(HIST("RawData/PID/hTPCVsPt"))->Fill(track.pt(), track.tpcSignal()); - RawData.get(HIST("RawData/PID/hTPCVsEta"))->Fill(RecoDecay::eta(std::array{trkPx, trkPy, trkPz}), track.tpcSignal()); - RawData.get(HIST("RawData/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(trkPx, trkPy), track.tpcSignal()); - } - - if (track.hasTOF()) { - RawData.get(HIST("RawData/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkPx, trkPy, trkPz), track.beta()); - } - } - - int countGT = 0; - std::vector trkIdx; - // loop over tracks with selections - if (std::abs(collision.posZ()) > cutVertexZ) { - Statistics.get(HIST("Statistics/hCutCounterCollisions"))->Fill(1); - return; - } - - RawData.get(HIST("RawData/hPositionX"))->Fill(collision.posX()); - RawData.get(HIST("RawData/hPositionY"))->Fill(collision.posY()); - RawData.get(HIST("RawData/hPositionZ"))->Fill(collision.posZ()); - RawData.get(HIST("RawData/hPositionXY"))->Fill(collision.posX(), collision.posY()); - RawData.get(HIST("RawData/hZNACommonEnergy"))->Fill(collision.energyCommonZNA()); - RawData.get(HIST("RawData/hZNCCommonEnergy"))->Fill(collision.energyCommonZNC()); - RawData.get(HIST("RawData/hZNAvsZNCCommonEnergy"))->Fill(collision.energyCommonZNA(), collision.energyCommonZNC()); - RawData.get(HIST("RawData/hZNCTime"))->Fill(collision.timeZNC()); - RawData.get(HIST("RawData/hZNATime"))->Fill(collision.timeZNA()); - RawData.get(HIST("RawData/hZNAvsZNCTime"))->Fill(collision.timeZNA(), collision.timeZNC()); - - for (auto& track : tracks) { - - Statistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(2.); - - // select good tracks - if (GoodTrackCuts(track) != 1) { - continue; - } - - countGT++; - trkIdx.push_back(track.index()); - } - - Statistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(3., countGT); - Statistics.get(HIST("Statistics/hNumberGT"))->Fill(countGT); - - float massEl = o2::constants::physics::MassElectron; - float massMu = o2::constants::physics::MassMuonMinus; - float massPr = o2::constants::physics::MassProton; - - if (countGT == 2) { - TLorentzVector mom, daughter[2]; - auto trkDaughter1 = tracks.iteratorAt(trkIdx[0]); - auto trkDaughter2 = tracks.iteratorAt(trkIdx[1]); - - if ((trkDaughter1.sign() * trkDaughter2.sign()) != -1) { - return; - } - - if (chargeOrdered) { - if (tracks.iteratorAt(trkIdx[0]).sign() < 0) { - trkDaughter1 = tracks.iteratorAt(trkIdx[0]); - trkDaughter2 = tracks.iteratorAt(trkIdx[1]); - } else { - trkDaughter1 = tracks.iteratorAt(trkIdx[1]); - trkDaughter2 = tracks.iteratorAt(trkIdx[0]); - } - } - - std::array daughter1 = {trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()}; - std::array daughter2 = {trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()}; - - TG.get(HIST("TG/hTrackPt1"))->Fill(trkDaughter1.pt()); - TG.get(HIST("TG/hTrackPt2"))->Fill(trkDaughter2.pt()); - TG.get(HIST("TG/hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); - TG.get(HIST("TG/hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); - TG.get(HIST("TG/hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); - TG.get(HIST("TG/hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); - - if (trkDaughter1.hasTPC()) { - TG.get(HIST("TG/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - TG.get(HIST("TG/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - TG.get(HIST("TG/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - TG.get(HIST("TG/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - TG.get(HIST("TG/hTPCNClsFindable"))->Fill(trkDaughter1.tpcNClsFindable()); - TG.get(HIST("TG/hTPCNClsFindableMinusFound"))->Fill(trkDaughter1.tpcNClsFindableMinusFound()); - if (trkDaughter1.sign() < 0) { - TG.get(HIST("TG/TPC/TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); - } else { - TG.get(HIST("TG/TPC/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); - } - } - if (trkDaughter2.hasTPC()) { - TG.get(HIST("TG/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - TG.get(HIST("TG/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - TG.get(HIST("TG/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - TG.get(HIST("TG/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - TG.get(HIST("TG/hTPCNClsFindable"))->Fill(trkDaughter2.tpcNClsFindable()); - TG.get(HIST("TG/hTPCNClsFindableMinusFound"))->Fill(trkDaughter2.tpcNClsFindableMinusFound()); - } - if (trkDaughter1.hasTOF()) { - TG.get(HIST("TG/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - TG.get(HIST("TG/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - if (doElectrons) { - if (RecoDecay::sumOfSquares(trkDaughter1.tpcNSigmaMu(), trkDaughter2.tpcNSigmaMu()) > RecoDecay::sumOfSquares(trkDaughter1.tpcNSigmaEl(), trkDaughter2.tpcNSigmaEl())) { - - auto ene1 = RecoDecay::e(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), massEl); - auto ene2 = RecoDecay::e(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), massEl); - daughter[0].SetPxPyPzE(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), ene1); - daughter[1].SetPxPyPzE(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), ene2); - mom = daughter[0] + daughter[1]; - - std::array mother = {trkDaughter1.px() + trkDaughter2.px(), trkDaughter1.py() + trkDaughter2.py(), trkDaughter1.pz() + trkDaughter2.pz()}; - - auto arrMom = std::array{daughter1, daughter2}; - float massJpsi = RecoDecay::m(arrMom, std::array{massEl, massEl}); - float rapJpsi = RecoDecay::y(mother, massJpsi); - - auto leadingP = RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()) > RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()) ? trkDaughter1 : trkDaughter2; - auto subleadingP = (leadingP == trkDaughter1) ? trkDaughter1 : trkDaughter2; - - TGel.get(HIST("TGel/hTrackPt1"))->Fill(trkDaughter1.pt()); - TGel.get(HIST("TGel/hTrackPt2"))->Fill(trkDaughter2.pt()); - TGel.get(HIST("TGel/hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); - TGel.get(HIST("TGel/hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); - TGel.get(HIST("TGel/hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); - TGel.get(HIST("TGel/hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); - - // selections - Selections.get(HIST("Selections/Electron/Mass/Leading/hITSNClsVsM"))->Fill(massJpsi, leadingP.itsNCls()); - Selections.get(HIST("Selections/Electron/Mass/Leading/hITSChi2NClsVsM"))->Fill(massJpsi, leadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Electron/Mass/Leading/hTPCNClsVsM"))->Fill(massJpsi, leadingP.tpcNClsFindable() - leadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Electron/Mass/Leading/hTPCChi2NClsVsM"))->Fill(massJpsi, leadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Electron/Mass/Leading/hTPCNClsCrossedRowsVsM"))->Fill(massJpsi, subleadingP.tpcNClsCrossedRows()); - Selections.get(HIST("Selections/Electron/Mass/Subleading/hITSNClsVsM"))->Fill(massJpsi, subleadingP.itsNCls()); - Selections.get(HIST("Selections/Electron/Mass/Subleading/hITSChi2NClsVsM"))->Fill(massJpsi, subleadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Electron/Mass/Subleading/hTPCNClsVsM"))->Fill(massJpsi, subleadingP.tpcNClsFindable() - subleadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Electron/Mass/Subleading/hTPCChi2NClsVsM"))->Fill(massJpsi, subleadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Electron/Mass/Subleading/hTPCNClsCrossedRowsVsM"))->Fill(massJpsi, subleadingP.tpcNClsCrossedRows()); - - Selections.get(HIST("Selections/Electron/Rapidity/Leading/hITSNClsVsY"))->Fill(rapJpsi, leadingP.itsNCls()); - Selections.get(HIST("Selections/Electron/Rapidity/Leading/hITSChi2NClsVsY"))->Fill(rapJpsi, leadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Electron/Rapidity/Leading/hTPCNClsVsY"))->Fill(rapJpsi, leadingP.tpcNClsFindable() - leadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Electron/Rapidity/Leading/hTPCChi2NClsVsY"))->Fill(rapJpsi, leadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Electron/Rapidity/Leading/hTPCNClsCrossedRowsVsY"))->Fill(rapJpsi, subleadingP.tpcNClsCrossedRows()); - Selections.get(HIST("Selections/Electron/Rapidity/Subleading/hITSNClsVsY"))->Fill(rapJpsi, subleadingP.itsNCls()); - Selections.get(HIST("Selections/Electron/Rapidity/Subleading/hITSChi2NClsVsY"))->Fill(rapJpsi, subleadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Electron/Rapidity/Subleading/hTPCNClsVsY"))->Fill(rapJpsi, subleadingP.tpcNClsFindable() - subleadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Electron/Rapidity/Subleading/hTPCChi2NClsVsY"))->Fill(rapJpsi, subleadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Electron/Rapidity/Subleading/hTPCNClsCrossedRowsVsY"))->Fill(rapJpsi, subleadingP.tpcNClsCrossedRows()); - - Selections.get(HIST("Selections/Electron/Pt/Leading/hITSNClsVsPt"))->Fill(RecoDecay::pt(mother), leadingP.itsNCls()); - Selections.get(HIST("Selections/Electron/Pt/Leading/hITSChi2NClsVsPt"))->Fill(RecoDecay::pt(mother), leadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Electron/Pt/Leading/hTPCNClsVsPt"))->Fill(RecoDecay::pt(mother), leadingP.tpcNClsFindable() - leadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Electron/Pt/Leading/hTPCChi2NClsVsPt"))->Fill(RecoDecay::pt(mother), leadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Electron/Pt/Leading/hTPCNClsCrossedRowsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.tpcNClsCrossedRows()); - Selections.get(HIST("Selections/Electron/Pt/Subleading/hITSNClsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.itsNCls()); - Selections.get(HIST("Selections/Electron/Pt/Subleading/hITSChi2NClsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Electron/Pt/Subleading/hTPCNClsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.tpcNClsFindable() - subleadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Electron/Pt/Subleading/hTPCChi2NClsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Electron/Pt/Subleading/hTPCNClsCrossedRowsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.tpcNClsCrossedRows()); - - if (trkDaughter1.hasTPC()) { - TGel.get(HIST("TGel/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - TGel.get(HIST("TGel/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - TGel.get(HIST("TGel/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - TGel.get(HIST("TGel/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - TGel.get(HIST("TGel/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - TGel.get(HIST("TGel/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - TGel.get(HIST("TGel/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - TGel.get(HIST("TGel/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - TGel.get(HIST("TGel/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - TGel.get(HIST("TGel/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - - if (CandidateCuts(massJpsi, rapJpsi) != 1) { - return; - } - - TGelCand.get(HIST("TGelCand/hTrackPt1"))->Fill(trkDaughter1.pt()); - TGelCand.get(HIST("TGelCand/hTrackPt2"))->Fill(trkDaughter2.pt()); - TGelCand.get(HIST("TGelCand/hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); - TGelCand.get(HIST("TGelCand/hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); - TGelCand.get(HIST("TGelCand/hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); - TGelCand.get(HIST("TGelCand/hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); - TGelCand.get(HIST("TGelCand/hPairPt"))->Fill(RecoDecay::pt(mother)); - TGelCand.get(HIST("TGelCand/hPairIVM"))->Fill(massJpsi); - - if (trkDaughter1.hasTPC()) { - TGelCand.get(HIST("TGelCand/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - TGelCand.get(HIST("TGelCand/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - TGelCand.get(HIST("TGelCand/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - TGelCand.get(HIST("TGelCand/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - if (trkDaughter1.sign() < 0) { - TGelCand.get(HIST("TGelCand/TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); - } else { - TGelCand.get(HIST("TGelCand/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); - } - } - if (trkDaughter2.hasTPC()) { - TGelCand.get(HIST("TGelCand/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - TGelCand.get(HIST("TGelCand/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - TGelCand.get(HIST("TGelCand/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - TGelCand.get(HIST("TGelCand/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - TGelCand.get(HIST("TGelCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - TGelCand.get(HIST("TGelCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - - if (RecoDecay::pt(mother) < 0.2f) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/hIVM"))->Fill(massJpsi); - if (XnXn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hIVM"))->Fill(massJpsi); - } else if (OnXn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hIVM"))->Fill(massJpsi); - } else if (XnOn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hIVM"))->Fill(massJpsi); - } else if (OnOn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hIVM"))->Fill(massJpsi); - } - } else if (RecoDecay::pt(mother) > 0.4f) { - JPsiToEl.get(HIST("JPsiToEl/NotCoherent/hIVM"))->Fill(massJpsi); - if (XnXn) { - JPsiToEl.get(HIST("JPsiToEl/NotCoherent/XnXn/hIVM"))->Fill(massJpsi); - } else if (OnXn) { - JPsiToEl.get(HIST("JPsiToEl/NotCoherent/OnXn/hIVM"))->Fill(massJpsi); - } else if (XnOn) { - JPsiToEl.get(HIST("JPsiToEl/NotCoherent/XnOn/hIVM"))->Fill(massJpsi); - } else if (OnOn) { - JPsiToEl.get(HIST("JPsiToEl/NotCoherent/OnOn/hIVM"))->Fill(massJpsi); - } - } - if (RecoDecay::pt(mother) > 0.2f) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hIVM"))->Fill(massJpsi); - if (XnXn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hIVM"))->Fill(massJpsi); - } else if (OnXn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hIVM"))->Fill(massJpsi); - } else if (XnOn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hIVM"))->Fill(massJpsi); - } else if (OnOn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hIVM"))->Fill(massJpsi); - } - } - - if ((massJpsi < maxJpsiMass) && (massJpsi > minJpsiMass)) { - TGelCand.get(HIST("TGelCand/hJpsiPt"))->Fill(RecoDecay::pt(mother)); - TGelCand.get(HIST("TGelCand/hJpsiRap"))->Fill(rapJpsi); - - if (trkDaughter1.sign() < 0) { - TGelCand.get(HIST("TGelCand/TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); - } else { - TGelCand.get(HIST("TGelCand/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); - } - - if (RecoDecay::pt(mother) < 0.2f) { - // fill track histos - JPsiToEl.get(HIST("JPsiToEl/Coherent/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - - if (XnXn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } else if (OnOn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } else if (XnOn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } else if (OnXn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } - - if (trkDaughter1.hasTPC()) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - - if (trkDaughter1.hasTOF()) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - // fill J/psi histos - JPsiToEl.get(HIST("JPsiToEl/Coherent/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/hRap"))->Fill(rapJpsi); - - if (XnXn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnXn/hRap"))->Fill(rapJpsi); - } else if (OnOn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnOn/hRap"))->Fill(rapJpsi); - } else if (OnXn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/OnXn/hRap"))->Fill(rapJpsi); - } else if (XnOn) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Coherent/XnOn/hRap"))->Fill(rapJpsi); - } - - float* q = correlation(&daughter[0], &daughter[1], &mom); - Correlation.get(HIST("Correlation/Electron/Coherent/Phi1"))->Fill(RecoDecay::phi(daughter1), 1.); - Correlation.get(HIST("Correlation/Electron/Coherent/Phi2"))->Fill(RecoDecay::phi(daughter2), 1.); - Correlation.get(HIST("Correlation/Electron/Coherent/Phi"))->Fill(q[1], 1.); - Correlation.get(HIST("Correlation/Electron/Coherent/CosTheta"))->Fill(q[2], 1.); - Correlation.get(HIST("Correlation/Electron/Coherent/AccoplAngle"))->Fill(q[0], 1.); - Correlation.get(HIST("Correlation/Electron/Coherent/CosThetaPhi"))->Fill(q[2], q[1]); - - double dp = DeltaPhi(daughter[0], daughter[1]); - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/DeltaPhi"))->Fill(dp); - if (XnXn) { - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/XnXn/DeltaPhi"))->Fill(dp); - } else if (OnOn) { - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/OnOn/DeltaPhi"))->Fill(dp); - } else if (XnOn) { - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/XnOn/DeltaPhi"))->Fill(dp); - } else if (OnXn) { - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/OnXn/DeltaPhi"))->Fill(dp); - } - - double dpRandom = DeltaPhiRandom(daughter[0], daughter[1]); - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/DeltaPhiRandom"))->Fill(dpRandom); - if (XnXn) { - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/XnXn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (OnOn) { - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/OnOn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (XnOn) { - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/XnOn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (OnXn) { - Asymmetry.get(HIST("Asymmetry/Electron/Coherent/OnXn/DeltaPhiRandom"))->Fill(dpRandom); - } - - delete[] q; - } // end coherent electrons - if (RecoDecay::pt(mother) > 0.2f) { - // fill track histos - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - - if (XnXn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } else if (OnOn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } else if (XnOn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } else if (OnXn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } - - if (trkDaughter1.hasTPC()) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - - if (trkDaughter1.hasTOF()) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - // fill J/psi histos - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hRap"))->Fill(rapJpsi); - - if (XnXn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnXn/hRap"))->Fill(rapJpsi); - } else if (OnOn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnOn/hRap"))->Fill(rapJpsi); - } else if (OnXn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/OnXn/hRap"))->Fill(rapJpsi); - } else if (XnOn) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/XnOn/hRap"))->Fill(rapJpsi); - } - - float* q = correlation(&daughter[0], &daughter[1], &mom); - Correlation.get(HIST("Correlation/Electron/Incoherent/Phi1"))->Fill(RecoDecay::phi(daughter1), 1.); - Correlation.get(HIST("Correlation/Electron/Incoherent/Phi2"))->Fill(RecoDecay::phi(daughter2), 1.); - Correlation.get(HIST("Correlation/Electron/Incoherent/Phi"))->Fill(q[1], 1.); - Correlation.get(HIST("Correlation/Electron/Incoherent/CosTheta"))->Fill(q[2], 1.); - Correlation.get(HIST("Correlation/Electron/Incoherent/AccoplAngle"))->Fill(q[0], 1.); - Correlation.get(HIST("Correlation/Electron/Incoherent/CosThetaPhi"))->Fill(q[2], q[1]); - - double dp = DeltaPhi(daughter[0], daughter[1]); - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/DeltaPhi"))->Fill(dp); - if (XnXn) { - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/XnXn/DeltaPhi"))->Fill(dp); - } else if (OnOn) { - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/OnOn/DeltaPhi"))->Fill(dp); - } else if (XnOn) { - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/XnOn/DeltaPhi"))->Fill(dp); - } else if (OnXn) { - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/OnXn/DeltaPhi"))->Fill(dp); - } - - double dpRandom = DeltaPhiRandom(daughter[0], daughter[1]); - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/DeltaPhiRandom"))->Fill(dpRandom); - if (XnXn) { - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/XnXn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (OnOn) { - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/OnOn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (XnOn) { - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/XnOn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (OnXn) { - Asymmetry.get(HIST("Asymmetry/Electron/Incoherent/OnXn/DeltaPhiRandom"))->Fill(dpRandom); - } - - delete[] q; - } // end incoherent electrons - } // end mass cut - } - } // end electrons - if (doMuons) { - if (RecoDecay::sumOfSquares(trkDaughter1.tpcNSigmaEl(), trkDaughter2.tpcNSigmaEl()) > RecoDecay::sumOfSquares(trkDaughter1.tpcNSigmaMu(), trkDaughter2.tpcNSigmaMu())) { - - auto ene1 = RecoDecay::e(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), massMu); - auto ene2 = RecoDecay::e(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), massMu); - daughter[0].SetPxPyPzE(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), ene1); - daughter[1].SetPxPyPzE(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), ene2); - mom = daughter[0] + daughter[1]; - - std::array mother = {trkDaughter1.px() + trkDaughter2.px(), trkDaughter1.py() + trkDaughter2.py(), trkDaughter1.pz() + trkDaughter2.pz()}; - - auto arrMom = std::array{daughter1, daughter2}; - float massJpsi = RecoDecay::m(arrMom, std::array{massMu, massMu}); - float rapJpsi = RecoDecay::y(mother, massJpsi); - - auto leadingP = RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()) > RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()) ? trkDaughter1 : trkDaughter2; - auto subleadingP = (leadingP == trkDaughter1) ? trkDaughter1 : trkDaughter2; - - TGmu.get(HIST("TGmu/hTrackPt1"))->Fill(trkDaughter1.pt()); - TGmu.get(HIST("TGmu/hTrackPt2"))->Fill(trkDaughter2.pt()); - TGmu.get(HIST("TGmu/hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); - TGmu.get(HIST("TGmu/hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); - TGmu.get(HIST("TGmu/hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); - TGmu.get(HIST("TGmu/hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); - - // selections - Selections.get(HIST("Selections/Muon/Mass/Leading/hITSNClsVsM"))->Fill(massJpsi, leadingP.itsNCls()); - Selections.get(HIST("Selections/Muon/Mass/Leading/hITSChi2NClsVsM"))->Fill(massJpsi, leadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Muon/Mass/Leading/hTPCNClsVsM"))->Fill(massJpsi, leadingP.tpcNClsFindable() - leadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Muon/Mass/Leading/hTPCChi2NClsVsM"))->Fill(massJpsi, leadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Muon/Mass/Leading/hTPCNClsCrossedRowsVsM"))->Fill(massJpsi, subleadingP.tpcNClsCrossedRows()); - Selections.get(HIST("Selections/Muon/Mass/Subleading/hITSNClsVsM"))->Fill(massJpsi, subleadingP.itsNCls()); - Selections.get(HIST("Selections/Muon/Mass/Subleading/hITSChi2NClsVsM"))->Fill(massJpsi, subleadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Muon/Mass/Subleading/hTPCNClsVsM"))->Fill(massJpsi, subleadingP.tpcNClsFindable() - subleadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Muon/Mass/Subleading/hTPCChi2NClsVsM"))->Fill(massJpsi, subleadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Muon/Mass/Subleading/hTPCNClsCrossedRowsVsM"))->Fill(massJpsi, subleadingP.tpcNClsCrossedRows()); - - Selections.get(HIST("Selections/Muon/Rapidity/Leading/hITSNClsVsY"))->Fill(rapJpsi, leadingP.itsNCls()); - Selections.get(HIST("Selections/Muon/Rapidity/Leading/hITSChi2NClsVsY"))->Fill(rapJpsi, leadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Muon/Rapidity/Leading/hTPCNClsVsY"))->Fill(rapJpsi, leadingP.tpcNClsFindable() - leadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Muon/Rapidity/Leading/hTPCChi2NClsVsY"))->Fill(rapJpsi, leadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Muon/Rapidity/Leading/hTPCNClsCrossedRowsVsY"))->Fill(rapJpsi, subleadingP.tpcNClsCrossedRows()); - Selections.get(HIST("Selections/Muon/Rapidity/Subleading/hITSNClsVsY"))->Fill(rapJpsi, subleadingP.itsNCls()); - Selections.get(HIST("Selections/Muon/Rapidity/Subleading/hITSChi2NClsVsY"))->Fill(rapJpsi, subleadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Muon/Rapidity/Subleading/hTPCNClsVsY"))->Fill(rapJpsi, subleadingP.tpcNClsFindable() - subleadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Muon/Rapidity/Subleading/hTPCChi2NClsVsY"))->Fill(rapJpsi, subleadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Muon/Rapidity/Subleading/hTPCNClsCrossedRowsVsY"))->Fill(rapJpsi, subleadingP.tpcNClsCrossedRows()); - - Selections.get(HIST("Selections/Muon/Pt/Leading/hITSNClsVsPt"))->Fill(RecoDecay::pt(mother), leadingP.itsNCls()); - Selections.get(HIST("Selections/Muon/Pt/Leading/hITSChi2NClsVsPt"))->Fill(RecoDecay::pt(mother), leadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Muon/Pt/Leading/hTPCNClsVsPt"))->Fill(RecoDecay::pt(mother), leadingP.tpcNClsFindable() - leadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Muon/Pt/Leading/hTPCChi2NClsVsPt"))->Fill(RecoDecay::pt(mother), leadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Muon/Pt/Leading/hTPCNClsCrossedRowsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.tpcNClsCrossedRows()); - Selections.get(HIST("Selections/Muon/Pt/Subleading/hITSNClsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.itsNCls()); - Selections.get(HIST("Selections/Muon/Pt/Subleading/hITSChi2NClsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.itsChi2NCl()); - Selections.get(HIST("Selections/Muon/Pt/Subleading/hTPCNClsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.tpcNClsFindable() - subleadingP.tpcNClsFindableMinusFound()); - Selections.get(HIST("Selections/Muon/Pt/Subleading/hTPCChi2NClsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.tpcChi2NCl()); - Selections.get(HIST("Selections/Muon/Pt/Subleading/hTPCNClsCrossedRowsVsPt"))->Fill(RecoDecay::pt(mother), subleadingP.tpcNClsCrossedRows()); - - if (trkDaughter1.hasTPC()) { - TGmu.get(HIST("TGmu/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - TGmu.get(HIST("TGmu/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - TGmu.get(HIST("TGmu/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - TGmu.get(HIST("TGmu/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - if (trkDaughter1.sign() < 0) { - TGmu.get(HIST("TGmu/TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); - } else { - TGmu.get(HIST("TGmu/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); - } - } - if (trkDaughter2.hasTPC()) { - TGmu.get(HIST("TGmu/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - TGmu.get(HIST("TGmu/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - TGmu.get(HIST("TGmu/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - TGmu.get(HIST("TGmu/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - TGmu.get(HIST("TGmu/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - - TGmu.get(HIST("TGmu/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - - if (CandidateCuts(massJpsi, rapJpsi) != 1) { - return; - } - - TGmuCand.get(HIST("TGmuCand/hTrackPt1"))->Fill(trkDaughter1.pt()); - TGmuCand.get(HIST("TGmuCand/hTrackPt2"))->Fill(trkDaughter2.pt()); - TGmuCand.get(HIST("TGmuCand/hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); - TGmuCand.get(HIST("TGmuCand/hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); - TGmuCand.get(HIST("TGmuCand/hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); - TGmuCand.get(HIST("TGmuCand/hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); - TGmuCand.get(HIST("TGmuCand/hPairPt"))->Fill(RecoDecay::pt(mother)); - TGmuCand.get(HIST("TGmuCand/hPairIVM"))->Fill(massJpsi); - - if (trkDaughter1.hasTPC()) { - TGmuCand.get(HIST("TGmuCand/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - TGmuCand.get(HIST("TGmuCand/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - TGmuCand.get(HIST("TGmuCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - TGmuCand.get(HIST("TGmuCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - - if (RecoDecay::pt(mother) < 0.2f) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/hIVM"))->Fill(massJpsi); - if (XnXn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hIVM"))->Fill(massJpsi); - } else if (OnXn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hIVM"))->Fill(massJpsi); - } else if (XnOn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hIVM"))->Fill(massJpsi); - } else if (OnOn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hIVM"))->Fill(massJpsi); - } - } else if (RecoDecay::pt(mother) > 0.4f) { - JPsiToMu.get(HIST("JPsiToMu/NotCoherent/hIVM"))->Fill(massJpsi); - if (XnXn) { - JPsiToMu.get(HIST("JPsiToMu/NotCoherent/XnXn/hIVM"))->Fill(massJpsi); - } else if (OnXn) { - JPsiToMu.get(HIST("JPsiToMu/NotCoherent/OnXn/hIVM"))->Fill(massJpsi); - } else if (XnOn) { - JPsiToMu.get(HIST("JPsiToMu/NotCoherent/XnOn/hIVM"))->Fill(massJpsi); - } else if (OnOn) { - JPsiToMu.get(HIST("JPsiToMu/NotCoherent/OnOn/hIVM"))->Fill(massJpsi); - } - } - if (RecoDecay::pt(mother) > 0.2f) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hIVM"))->Fill(massJpsi); - if (XnXn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hIVM"))->Fill(massJpsi); - } else if (OnXn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hIVM"))->Fill(massJpsi); - } else if (XnOn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hIVM"))->Fill(massJpsi); - } else if (OnOn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hIVM"))->Fill(massJpsi); - } - } - - if ((massJpsi < maxJpsiMass) && (massJpsi > minJpsiMass)) { - TGmuCand.get(HIST("TGmuCand/hJpsiPt"))->Fill(RecoDecay::pt(mother)); - if (RecoDecay::pt(mother) < 0.1f) { - TGmuCand.get(HIST("TGmuCand/hJpsiPt2"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - if (XnXn) { - TGmuCand.get(HIST("TGmuCand/XnXn/hJpsiPt2"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - } else if (XnOn) { - TGmuCand.get(HIST("TGmuCand/XnOn/hJpsiPt2"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - } else if (OnXn) { - TGmuCand.get(HIST("TGmuCand/OnXn/hJpsiPt2"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - } else if (OnOn) { - TGmuCand.get(HIST("TGmuCand/OnOn/hJpsiPt2"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - } - } - TGmuCand.get(HIST("TGmuCand/hJpsiRap"))->Fill(rapJpsi); - if (trkDaughter1.sign() < 0) { - TGmuCand.get(HIST("TGmuCand/TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); - } else { - TGmuCand.get(HIST("TGmuCand/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); - } - - if (RecoDecay::pt(mother) < 0.2f) { - // fill track histos - TGmuCand.get(HIST("TGmuCand/hJpsiPt2wide"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - - if (XnXn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - TGmuCand.get(HIST("TGmuCand/XnXn/hJpsiPt2wide"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - } else if (OnOn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - TGmuCand.get(HIST("TGmuCand/OnOn/hJpsiPt2wide"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - } else if (XnOn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - TGmuCand.get(HIST("TGmuCand/XnOn/hJpsiPt2wide"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - } else if (OnXn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - TGmuCand.get(HIST("TGmuCand/OnXn/hJpsiPt2wide"))->Fill(RecoDecay::pt(mother) * RecoDecay::pt(mother)); - } - - if (trkDaughter1.hasTPC()) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - // fill J/psi histos - JPsiToMu.get(HIST("JPsiToMu/Coherent/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/hRap"))->Fill(rapJpsi); - - if (XnXn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnXn/hRap"))->Fill(rapJpsi); - } else if (OnOn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnOn/hRap"))->Fill(rapJpsi); - } else if (OnXn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/OnXn/hRap"))->Fill(rapJpsi); - } else if (XnOn) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Coherent/XnOn/hRap"))->Fill(rapJpsi); - } - - float* q = correlation(&daughter[0], &daughter[1], &mom); - Correlation.get(HIST("Correlation/Muon/Coherent/Phi1"))->Fill(RecoDecay::phi(daughter1), 1.); - Correlation.get(HIST("Correlation/Muon/Coherent/Phi2"))->Fill(RecoDecay::phi(daughter2), 1.); - Correlation.get(HIST("Correlation/Muon/Coherent/Phi"))->Fill(q[1], 1.); - Correlation.get(HIST("Correlation/Muon/Coherent/CosTheta"))->Fill(q[2], 1.); - Correlation.get(HIST("Correlation/Muon/Coherent/AccoplAngle"))->Fill(q[0], 1.); - Correlation.get(HIST("Correlation/Muon/Coherent/CosThetaPhi"))->Fill(q[2], q[1]); - - double dp = DeltaPhi(daughter[0], daughter[1]); - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/DeltaPhi"))->Fill(dp); - if (XnXn) { - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/XnXn/DeltaPhi"))->Fill(dp); - } else if (OnOn) { - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/OnOn/DeltaPhi"))->Fill(dp); - } else if (XnOn) { - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/XnOn/DeltaPhi"))->Fill(dp); - } else if (OnXn) { - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/OnXn/DeltaPhi"))->Fill(dp); - } - double dpRandom = DeltaPhiRandom(daughter[0], daughter[1]); - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/DeltaPhiRandom"))->Fill(dpRandom); - if (XnXn) { - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/XnXn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (OnOn) { - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/OnOn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (XnOn) { - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/XnOn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (OnXn) { - Asymmetry.get(HIST("Asymmetry/Muon/Coherent/OnXn/DeltaPhiRandom"))->Fill(dpRandom); - } - - delete[] q; - } - if (RecoDecay::pt(mother) > 0.2f) { - // fill track histos - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - - if (XnXn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } else if (OnOn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } else if (XnOn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } else if (OnXn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - } - - if (trkDaughter1.hasTPC()) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - - // fill J/psi histos - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hRap"))->Fill(rapJpsi); - - if (XnXn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnXn/hRap"))->Fill(rapJpsi); - } else if (OnOn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnOn/hRap"))->Fill(rapJpsi); - } else if (OnXn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/OnXn/hRap"))->Fill(rapJpsi); - } else if (XnOn) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/XnOn/hRap"))->Fill(rapJpsi); - } - - float* q = correlation(&daughter[0], &daughter[1], &mom); - Correlation.get(HIST("Correlation/Muon/Incoherent/Phi1"))->Fill(RecoDecay::phi(daughter1), 1.); - Correlation.get(HIST("Correlation/Muon/Incoherent/Phi2"))->Fill(RecoDecay::phi(daughter2), 1.); - Correlation.get(HIST("Correlation/Muon/Incoherent/Phi"))->Fill(q[1], 1.); - Correlation.get(HIST("Correlation/Muon/Incoherent/CosTheta"))->Fill(q[2], 1.); - Correlation.get(HIST("Correlation/Muon/Incoherent/AccoplAngle"))->Fill(q[0], 1.); - Correlation.get(HIST("Correlation/Muon/Incoherent/CosThetaPhi"))->Fill(q[2], q[1]); - - double dp = DeltaPhi(daughter[0], daughter[1]); - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/DeltaPhi"))->Fill(dp); - if (XnXn) { - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/XnXn/DeltaPhi"))->Fill(dp); - } else if (OnOn) { - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/OnOn/DeltaPhi"))->Fill(dp); - } else if (XnOn) { - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/XnOn/DeltaPhi"))->Fill(dp); - } else if (OnXn) { - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/OnXn/DeltaPhi"))->Fill(dp); - } - - double dpRandom = DeltaPhiRandom(daughter[0], daughter[1]); - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/DeltaPhiRandom"))->Fill(dpRandom); - if (XnXn) { - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/XnXn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (OnOn) { - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/OnOn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (XnOn) { - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/XnOn/DeltaPhiRandom"))->Fill(dpRandom); - } else if (OnXn) { - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/OnXn/DeltaPhiRandom"))->Fill(dpRandom); - } - - delete[] q; - } - } - } - } // end muons - if (doProtons) { - if (RecoDecay::sumOfSquares((trkDaughter1.hasTOF() ? trkDaughter1.tofNSigmaPr() : trkDaughter1.tpcNSigmaPr()), (trkDaughter2.hasTOF() ? trkDaughter2.tofNSigmaPr() : trkDaughter2.tpcNSigmaPr()) < 4)) { - - auto ene1 = RecoDecay::e(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), massPr); - auto ene2 = RecoDecay::e(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), massPr); - daughter[0].SetPxPyPzE(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), ene1); - daughter[1].SetPxPyPzE(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), ene2); - mom = daughter[0] + daughter[1]; - - std::array mother = {trkDaughter1.px() + trkDaughter2.px(), trkDaughter1.py() + trkDaughter2.py(), trkDaughter1.pz() + trkDaughter2.pz()}; - - if (TOFBothProtons) { - if (!trkDaughter1.hasTOF() || !trkDaughter2.hasTOF()) - return; - } - if (TOFOneProton) { - if ((trkDaughter1.hasTOF() && trkDaughter2.hasTOF()) || (!trkDaughter1.hasTOF() && !trkDaughter2.hasTOF())) - return; - } - if (TOFAtLeastOneProton) { - if (!trkDaughter1.hasTOF() && !trkDaughter2.hasTOF()) - return; - } - - auto arrMom = std::array{daughter1, daughter2}; - float massJpsi = RecoDecay::m(arrMom, std::array{massPr, massPr}); - float rapJpsi = RecoDecay::y(mother, massJpsi); - - TGp.get(HIST("TGp/hTrackPt1"))->Fill(trkDaughter1.pt()); - TGp.get(HIST("TGp/hTrackPt2"))->Fill(trkDaughter2.pt()); - TGp.get(HIST("TGp/hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); - TGp.get(HIST("TGp/hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); - TGp.get(HIST("TGp/hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); - TGp.get(HIST("TGp/hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); - - if (trkDaughter1.hasTPC()) { - TGp.get(HIST("TGp/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - TGp.get(HIST("TGp/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - TGp.get(HIST("TGp/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - TGp.get(HIST("TGp/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - TGp.get(HIST("TGp/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - TGp.get(HIST("TGp/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - TGp.get(HIST("TGp/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - TGp.get(HIST("TGp/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - TGp.get(HIST("TGp/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - TGp.get(HIST("TGp/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - - if (CandidateCuts(massJpsi, rapJpsi) != 1) { - return; - } - - TGpCand.get(HIST("TGpCand/hTrackPt1"))->Fill(trkDaughter1.pt()); - TGpCand.get(HIST("TGpCand/hTrackPt2"))->Fill(trkDaughter2.pt()); - TGpCand.get(HIST("TGpCand/hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); - TGpCand.get(HIST("TGpCand/hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); - TGpCand.get(HIST("TGpCand/hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); - TGpCand.get(HIST("TGpCand/hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); - TGpCand.get(HIST("TGpCand/hPairPt"))->Fill(RecoDecay::pt(mother)); - TGpCand.get(HIST("TGpCand/hPairIVM"))->Fill(massJpsi); - - if (trkDaughter1.hasTPC()) { - TGpCand.get(HIST("TGpCand/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - TGpCand.get(HIST("TGpCand/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - TGpCand.get(HIST("TGpCand/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - TGpCand.get(HIST("TGpCand/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - TGpCand.get(HIST("TGpCand/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - TGpCand.get(HIST("TGpCand/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - TGpCand.get(HIST("TGpCand/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - TGpCand.get(HIST("TGpCand/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - TGpCand.get(HIST("TGpCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - TGpCand.get(HIST("TGpCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - - if (RecoDecay::pt(mother) < 0.2f) { - JPsiToP.get(HIST("JPsiToP/Coherent/hIVM"))->Fill(massJpsi); - } else { - JPsiToP.get(HIST("JPsiToP/Incoherent/hIVM"))->Fill(massJpsi); - } - - if (massJpsi < maxJpsiMass && massJpsi > minJpsiMass) { - TGpCand.get(HIST("TGpCand/hJpsiPt"))->Fill(RecoDecay::pt(mother)); - TGpCand.get(HIST("TGpCand/hJpsiRap"))->Fill(rapJpsi); - if (RecoDecay::pt(mother) < 0.2f) { - // fill track histos - JPsiToP.get(HIST("JPsiToP/Coherent/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToP.get(HIST("JPsiToP/Coherent/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToP.get(HIST("JPsiToP/Coherent/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToP.get(HIST("JPsiToP/Coherent/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToP.get(HIST("JPsiToP/Coherent/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToP.get(HIST("JPsiToP/Coherent/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - if (trkDaughter1.hasTPC()) { - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - // fill J/psi histos - JPsiToP.get(HIST("JPsiToP/Coherent/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToP.get(HIST("JPsiToP/Coherent/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToP.get(HIST("JPsiToP/Coherent/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToP.get(HIST("JPsiToP/Coherent/hRap"))->Fill(rapJpsi); - } // end coherent - if (RecoDecay::pt(mother) > 0.2f) { - // fill track histos - JPsiToP.get(HIST("JPsiToP/Incoherent/hPt1"))->Fill(trkDaughter1.pt()); - JPsiToP.get(HIST("JPsiToP/Incoherent/hPt2"))->Fill(trkDaughter2.pt()); - JPsiToP.get(HIST("JPsiToP/Incoherent/hEta1"))->Fill(RecoDecay::eta(daughter1)); - JPsiToP.get(HIST("JPsiToP/Incoherent/hEta2"))->Fill(RecoDecay::eta(daughter2)); - JPsiToP.get(HIST("JPsiToP/Incoherent/hPhi1"))->Fill(RecoDecay::phi(daughter1)); - JPsiToP.get(HIST("JPsiToP/Incoherent/hPhi2"))->Fill(RecoDecay::phi(daughter2)); - if (trkDaughter1.hasTPC()) { - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); - } - if (trkDaughter2.hasTPC()) { - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); - } - if (trkDaughter1.hasTOF()) { - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - } - if (trkDaughter2.hasTOF()) { - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - } - // fill J/psi histos - JPsiToP.get(HIST("JPsiToP/Incoherent/hPt"))->Fill(RecoDecay::pt(mother)); - JPsiToP.get(HIST("JPsiToP/Incoherent/hEta"))->Fill(RecoDecay::eta(mother)); - JPsiToP.get(HIST("JPsiToP/Incoherent/hPhi"))->Fill(RecoDecay::phi(mother)); - JPsiToP.get(HIST("JPsiToP/Incoherent/hRap"))->Fill(rapJpsi); - } // end incoherent - } // end mass cut - } - } // end protons - } // end two tracks - } // end reco process - - template - void processMC(C const& mcCollision, T const& mcParticles) - { - - MC.get(HIST("MC/hNumberOfMCCollisions"))->Fill(1.); - MC.get(HIST("MC/hPosZ"))->Fill(mcCollision.posZ()); - - std::array daughPart1Mu; - std::array daughPart2Mu; - std::array daughPart1El; - std::array daughPart2El; - std::array daughPart1Pr; - std::array daughPart2Pr; - - // fill number of particles - for (auto const& mcParticle : mcParticles) { - MC.get(HIST("MC/Muon/hNumberOfMCTracks"))->Fill(1.); - MC.get(HIST("MC/Electron/hNumberOfMCTracks"))->Fill(1.); - MC.get(HIST("MC/Proton/hNumberOfMCTracks"))->Fill(1.); - MC.get(HIST("MC/hPDG"))->Fill(mcParticle.pdgCode()); - - // check if only muons and physical primaries are present - if ((mcParticle.pdgCode() == 13) && mcParticle.isPhysicalPrimary()) { - daughPart1Mu = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; - - MC.get(HIST("MC/Muon/hNumberOfMCTracks"))->Fill(2.); - } - if ((mcParticle.pdgCode() == -13) && mcParticle.isPhysicalPrimary()) { - daughPart2Mu = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; - - MC.get(HIST("MC/Muon/hNumberOfMCTracks"))->Fill(3.); - } - if ((mcParticle.pdgCode() == 11) && mcParticle.isPhysicalPrimary()) { - daughPart1El = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; - - MC.get(HIST("MC/Electron/hNumberOfMCTracks"))->Fill(2.); - } - if ((mcParticle.pdgCode() == -11) && mcParticle.isPhysicalPrimary()) { - daughPart2El = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; - - MC.get(HIST("MC/Electron/hNumberOfMCTracks"))->Fill(3.); - } - if ((mcParticle.pdgCode() == 2212) && mcParticle.isPhysicalPrimary()) { - daughPart1Pr = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; - - MC.get(HIST("MC/Proton/hNumberOfMCTracks"))->Fill(2.); - } - if ((mcParticle.pdgCode() == -2212) && mcParticle.isPhysicalPrimary()) { - daughPart2Pr = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; - - MC.get(HIST("MC/Proton/hNumberOfMCTracks"))->Fill(3.); - } - } - - // calculate J/psi system and needed distributions - std::array motherPartMu = {daughPart1Mu[0] + daughPart2Mu[0], daughPart1Mu[1] + daughPart2Mu[1], daughPart1Mu[2] + daughPart2Mu[2]}; - std::array motherPartEl = {daughPart1El[0] + daughPart2El[0], daughPart1El[1] + daughPart2El[1], daughPart1El[2] + daughPart2El[2]}; - std::array motherPartPr = {daughPart1Pr[0] + daughPart2Pr[0], daughPart1Pr[1] + daughPart2Pr[1], daughPart1Pr[2] + daughPart2Pr[2]}; - - float massEl = o2::constants::physics::MassElectron; - float massMu = o2::constants::physics::MassMuonMinus; - float massPr = o2::constants::physics::MassProton; - - auto arrMomMu = std::array{daughPart1Mu, daughPart2Mu}; - float massJpsiMu = RecoDecay::m(arrMomMu, std::array{massMu, massMu}); - auto arrMomEl = std::array{daughPart1El, daughPart2El}; - float massJpsiEl = RecoDecay::m(arrMomEl, std::array{massEl, massEl}); - auto arrMomPr = std::array{daughPart1Pr, daughPart2Pr}; - float massJpsiPr = RecoDecay::m(arrMomPr, std::array{massPr, massPr}); - - MC.get(HIST("MC/Muon/hEta1"))->Fill(RecoDecay::eta(daughPart1Mu)); - MC.get(HIST("MC/Muon/hEta2"))->Fill(RecoDecay::eta(daughPart2Mu)); - MC.get(HIST("MC/Muon/hPhi1"))->Fill(RecoDecay::phi(daughPart1Mu)); - MC.get(HIST("MC/Muon/hPhi2"))->Fill(RecoDecay::phi(daughPart2Mu)); - MC.get(HIST("MC/Muon/hPt1"))->Fill(RecoDecay::pt(daughPart1Mu)); - MC.get(HIST("MC/Muon/hPt2"))->Fill(RecoDecay::pt(daughPart2Mu)); - MC.get(HIST("MC/Muon/hPt"))->Fill(RecoDecay::pt(motherPartMu)); - MC.get(HIST("MC/Muon/hIVM"))->Fill(massJpsiMu); - MC.get(HIST("MC/Muon/hRapidity"))->Fill(RecoDecay::y(motherPartMu, massJpsiMu)); - - MC.get(HIST("MC/Electron/hEta1"))->Fill(RecoDecay::eta(daughPart1El)); - MC.get(HIST("MC/Electron/hEta2"))->Fill(RecoDecay::eta(daughPart2El)); - MC.get(HIST("MC/Electron/hPhi1"))->Fill(RecoDecay::phi(daughPart1El)); - MC.get(HIST("MC/Electron/hPhi2"))->Fill(RecoDecay::phi(daughPart2El)); - MC.get(HIST("MC/Electron/hPt1"))->Fill(RecoDecay::pt(daughPart1El)); - MC.get(HIST("MC/Electron/hPt2"))->Fill(RecoDecay::pt(daughPart2El)); - MC.get(HIST("MC/Electron/hPt"))->Fill(RecoDecay::pt(motherPartEl)); - MC.get(HIST("MC/Electron/hIVM"))->Fill(massJpsiEl); - MC.get(HIST("MC/Electron/hRapidity"))->Fill(RecoDecay::y(motherPartEl, massJpsiEl)); - - MC.get(HIST("MC/Proton/hEta1"))->Fill(RecoDecay::eta(daughPart1Pr)); - MC.get(HIST("MC/Proton/hEta2"))->Fill(RecoDecay::eta(daughPart2Pr)); - MC.get(HIST("MC/Proton/hPhi1"))->Fill(RecoDecay::phi(daughPart1Pr)); - MC.get(HIST("MC/Proton/hPhi2"))->Fill(RecoDecay::phi(daughPart2Pr)); - MC.get(HIST("MC/Proton/hPt1"))->Fill(RecoDecay::pt(daughPart1Pr)); - MC.get(HIST("MC/Proton/hPt2"))->Fill(RecoDecay::pt(daughPart2Pr)); - MC.get(HIST("MC/Proton/hPt"))->Fill(RecoDecay::pt(motherPartPr)); - MC.get(HIST("MC/Proton/hIVM"))->Fill(massJpsiPr); - MC.get(HIST("MC/Proton/hRapidity"))->Fill(RecoDecay::y(motherPartPr, massJpsiPr)); - - } // end MC skimmed process - - template - void processMCU(C const& collisions) - { - MC.fill(HIST("MC/hNumberOfRecoCollisions"), collisions.size()); - } // end MC unskimmed process - - void processDGrecoLevel(UDCollisionFull const& collision, UDTracksFull const& tracks) - { - fillHistograms(collision, tracks); - } // end DG process - - void processSGrecoLevel(SGUDCollisionFull const& collision, UDTracksFull const& tracks) - { - int gapSide = collision.gapSide(); - int trueGapSide = sgSelector.trueGap(collision, cutMyGapSideFV0, cutMyGapSideFT0A, cutMyGapSideFT0C, cutMyGapSideZDC); - if (useTrueGap) { - gapSide = trueGapSide; - } - if (gapSide != whichGapSide) { - return; - } - fillHistograms(collision, tracks); - - } // end SG process - - void processMCtruth(aod::UDMcCollision const& mcCollision, aod::UDMcParticles const& mcParticles) - { - processMC(mcCollision, mcParticles); - } - - void processMCUnskimmed(aod::McCollision const&, soa::SmallGroups> const& collisions /*, aod::McParticles const& mcParticles, aod::TracksIU const& tracks*/) - { - processMCU(collisions); - } - - PROCESS_SWITCH(UpcJpsiCentralBarrel, processDGrecoLevel, "Iterate over DG skimmed data.", false); - PROCESS_SWITCH(UpcJpsiCentralBarrel, processSGrecoLevel, "Iterate over SG skimmed data.", false); - PROCESS_SWITCH(UpcJpsiCentralBarrel, processMCtruth, "Iterate of MC true data.", true); - PROCESS_SWITCH(UpcJpsiCentralBarrel, processMCUnskimmed, "Iterate over unskimmed data.", true); -}; // end struct - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"upc-jpsi-corr"}), - }; -} diff --git a/PWGUD/Tasks/upcJpsiCorr.cxx b/PWGUD/Tasks/upcJpsiCorr.cxx new file mode 100644 index 00000000000..8db8746b99d --- /dev/null +++ b/PWGUD/Tasks/upcJpsiCorr.cxx @@ -0,0 +1,1378 @@ +// 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. +// +/// \file upcJpsiCorr.cxx +/// \brief Personal task for analysis of azimuthal asymmetry and quantum tomography in J/Psi system. +/// +/// \author Sara Haidlova, sara.haidlova@cern.ch +/// \since March 2024 + +#include +#include + +// O2 headers +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" + +// O2Physics headers +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/RecoDecay.h" +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/Core/UDHelpers.h" +#include "PWGUD/Core/UPCJpsiCentralBarrelCorrHelper.h" +#include "PWGUD/Core/SGSelector.h" + +// ROOT headers +#include "TLorentzVector.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::math; + +SGSelector sgSelector; + +namespace o2::aod +{ +namespace tree +{ +// misc event info +DECLARE_SOA_COLUMN(RunNumber, runNumber, int32_t); +DECLARE_SOA_COLUMN(GlobalBC, globalBC, uint64_t); +// event vertex +DECLARE_SOA_COLUMN(PosX, posX, double); +DECLARE_SOA_COLUMN(PosY, posY, double); +DECLARE_SOA_COLUMN(PosZ, posZ, double); +// FIT info +DECLARE_SOA_COLUMN(TotalFT0AmplitudeA, totalFT0AmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFT0AmplitudeC, totalFT0AmplitudeC, float); +DECLARE_SOA_COLUMN(TotalFV0AmplitudeA, totalFV0AmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFDDAmplitudeA, totalFDDAmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFDDAmplitudeC, totalFDDAmplitudeC, float); +DECLARE_SOA_COLUMN(TimeFT0A, timeFT0A, float); +DECLARE_SOA_COLUMN(TimeFT0C, timeFT0C, float); +DECLARE_SOA_COLUMN(TimeFV0A, timeFV0A, float); +DECLARE_SOA_COLUMN(TimeFDDA, timeFDDA, float); +DECLARE_SOA_COLUMN(TimeFDDC, timeFDDC, float); +// ZDC info +DECLARE_SOA_COLUMN(EnergyCommonZNA, energyCommonZNA, float); +DECLARE_SOA_COLUMN(EnergyCommonZNC, energyCommonZNC, float); +DECLARE_SOA_COLUMN(TimeZNA, timeZNA, float); +DECLARE_SOA_COLUMN(TimeZNC, timeZNC, float); +DECLARE_SOA_COLUMN(NeutronClass, neutronClass, int); + +// J/Psi +DECLARE_SOA_COLUMN(JpsiPt, jpsiPt, double); +DECLARE_SOA_COLUMN(JpsiEta, jpsiEta, double); +DECLARE_SOA_COLUMN(JpsiPhi, jpsiPhi, double); +DECLARE_SOA_COLUMN(JpsiM, jpsiM, double); +DECLARE_SOA_COLUMN(JpsiRap, jpsiRap, double); + +// asymmetry and correlation +DECLARE_SOA_COLUMN(JpsiPhiRandom, jpsiPhiRandom, double); +DECLARE_SOA_COLUMN(JpsiPhiCharge, jpsiPhiCharge, double); +DECLARE_SOA_COLUMN(JpsiPhiCS, jpsiPhiCS, double); +DECLARE_SOA_COLUMN(JpsiCosThetaCS, jpsiCosThetaCS, double); + +// muon tracks +DECLARE_SOA_COLUMN(TrackSign1, trackSign1, double); +DECLARE_SOA_COLUMN(TrackPt1, trackPt1, double); +DECLARE_SOA_COLUMN(TrackEta1, trackEta1, double); +DECLARE_SOA_COLUMN(TrackPhi1, trackPhi1, double); +DECLARE_SOA_COLUMN(TrackSign2, trackSign2, double); +DECLARE_SOA_COLUMN(TrackPt2, trackPt2, double); +DECLARE_SOA_COLUMN(TrackEta2, trackEta2, double); +DECLARE_SOA_COLUMN(TrackPhi2, trackPhi2, double); +} // namespace tree +DECLARE_SOA_TABLE(Tree, "AOD", "TREE", + tree::RunNumber, tree::GlobalBC, + tree::PosX, tree::PosY, tree::PosZ, tree::TotalFT0AmplitudeA, tree::TotalFT0AmplitudeC, tree::TotalFV0AmplitudeA, tree::TotalFDDAmplitudeA, tree::TotalFDDAmplitudeC, + tree::TimeFT0A, tree::TimeFT0C, tree::TimeFV0A, tree::TimeFDDA, tree::TimeFDDC, + tree::EnergyCommonZNA, tree::EnergyCommonZNC, tree::TimeZNA, tree::TimeZNC, tree::NeutronClass, + tree::JpsiPt, tree::JpsiEta, tree::JpsiPhi, tree::JpsiRap, tree::JpsiM, tree::JpsiPhiRandom, tree::JpsiPhiCharge, tree::JpsiPhiCS, tree::JpsiCosThetaCS, + tree::TrackSign1, tree::TrackPt1, tree::TrackEta1, tree::TrackPhi1, + tree::TrackSign2, tree::TrackPt2, tree::TrackEta2, tree::TrackPhi2); +namespace tree_mc +{ +// misc event info +DECLARE_SOA_COLUMN(GlobalBC, globalBC, uint64_t); +// event vertex +DECLARE_SOA_COLUMN(PosX, posX, double); +DECLARE_SOA_COLUMN(PosY, posY, double); +DECLARE_SOA_COLUMN(PosZ, posZ, double); + +// J/Psi +DECLARE_SOA_COLUMN(JpsiPt, jpsiPt, double); +DECLARE_SOA_COLUMN(JpsiEta, jpsiEta, double); +DECLARE_SOA_COLUMN(JpsiPhi, jpsiPhi, double); +DECLARE_SOA_COLUMN(JpsiM, jpsiM, double); +DECLARE_SOA_COLUMN(JpsiRap, jpsiRap, double); + +// asymmetry and correlation +DECLARE_SOA_COLUMN(JpsiPhiRandom, jpsiPhiRandom, double); +DECLARE_SOA_COLUMN(JpsiPhiCharge, jpsiPhiCharge, double); +DECLARE_SOA_COLUMN(JpsiPhiCS, jpsiPhiCS, double); +DECLARE_SOA_COLUMN(JpsiCosThetaCS, jpsiCosThetaCS, double); + +// muon tracks +DECLARE_SOA_COLUMN(TrackSign1, trackSign1, double); +DECLARE_SOA_COLUMN(TrackPt1, trackPt1, double); +DECLARE_SOA_COLUMN(TrackEta1, trackEta1, double); +DECLARE_SOA_COLUMN(TrackPhi1, trackPhi1, double); +DECLARE_SOA_COLUMN(TrackSign2, trackSign2, double); +DECLARE_SOA_COLUMN(TrackPt2, trackPt2, double); +DECLARE_SOA_COLUMN(TrackEta2, trackEta2, double); +DECLARE_SOA_COLUMN(TrackPhi2, trackPhi2, double); +} // namespace tree_mc +DECLARE_SOA_TABLE(TreeMC, "AOD", "TREEMC", + tree_mc::GlobalBC, + tree_mc::JpsiPt, tree_mc::JpsiEta, tree_mc::JpsiPhi, tree_mc::JpsiRap, tree_mc::JpsiM, tree_mc::JpsiPhiRandom, tree_mc::JpsiPhiCharge, tree_mc::JpsiPhiCS, tree_mc::JpsiCosThetaCS, + tree_mc::TrackSign1, tree_mc::TrackPt1, tree_mc::TrackEta1, tree_mc::TrackPhi1, + tree_mc::TrackSign2, tree_mc::TrackPt2, tree_mc::TrackEta2, tree_mc::TrackPhi2); +//} // namespace tree_mc +} // namespace o2::aod + +struct UpcJpsiCorr { + Produces tree; + Produces treeMC; + + // configurable axes + ConfigurableAxis axisIVM{"axisIVM", {500.0f, 2.0f, 4.5f}, "M_#it{inv} (GeV/#it{c}^{2})"}; + ConfigurableAxis axisIVMWide{"axisIVMWide", {350.0f, 0.0f, 4.5f}, "M_#it{inv} (GeV/#it{c}^{2})"}; + ConfigurableAxis axisPt{"axisPt", {250.0f, 0.1f, 3.0f}, "#it{p}_T (GeV/#it{c})"}; + ConfigurableAxis axisPt2{"axisPt2", {250.0f, 0.0f, 0.01f}, "#it{p}_T (GeV/#it{c})"}; + ConfigurableAxis axisPt2wide{"axisPt2wide", {250.0f, 0.0f, 0.04f}, "#it{p}_T (GeV/#it{c})"}; + ConfigurableAxis axisP{"axisP", {250.0f, 0.1f, 3.0f}, "#it{p} (GeV/#it{c})"}; + ConfigurableAxis axisEta{"axisEta", {250.0f, -1.5f, 1.5f}, "#eta (-)"}; + ConfigurableAxis axisCounter{"axisCounter", {20.0f, 0.0f, 20.0f}, "Number of events (-)"}; + ConfigurableAxis axisPhi{"axisPhi", {250.0f, 0, TwoPI}, "#phi (rad)"}; + ConfigurableAxis axisAccAngle{"axisAccAngle", {250.0f, -0.2f, 0.2f}, "accAngle"}; + ConfigurableAxis axisAngTheta{"axisAngTheta", {250.0f, -1.5f, 1.5f}, "cos #theta (-)"}; + ConfigurableAxis axisTPC{"axisTPC", {1000.0f, 0, 200.0f}, "TPC d#it{E}/d#it{x}"}; + ConfigurableAxis axisBetaTOF{"axisBetaTOF", {100.0f, 0, 1.5}, "TOF #beta"}; + ConfigurableAxis axisSigma{"axisSigma", {50, -25, 25}, "#sigma"}; + ConfigurableAxis axisZDCEnergy{"axisZDCEnergy", {250, -5.0, 20.0}, "ZDC energy"}; + ConfigurableAxis axisZDCTime{"axisZDCTime", {200, -10.0, 10.0}, "ZDC time"}; + ConfigurableAxis axisDCA{"axisDCA", {1000, -20.0, 20.0}, "DCA"}; + ConfigurableAxis axisChi2{"axisChi2", {200, -10.0, 40}, "Chi2"}; + ConfigurableAxis axisIVMSel{"axisIVMSel", {1000, 0.0, 10.0}, "IVM"}; + ConfigurableAxis axisCounterSel{"axisCounterSel", {1000, 0.0, 200.0}, "Selection"}; + ConfigurableAxis axisITSNCls{"axisITSNCls", {10, 0.0, 10.0}, "ITSNCls"}; + ConfigurableAxis axisTPCNCls{"axisTPCNCls", {170, -1, 160.0}, "TPCNCls"}; + ConfigurableAxis axisTPCCrossed{"axisTPCCrossed", {300, 20, 170.0}, "TPCCrossedRows"}; + + // configurable cuts (modify in json) + // track quality cuts + Configurable tpcNClsCrossedRows{"tpcNClsCrossedRows", 70, "number of crossed rows in TPC"}; + Configurable tofAtLeastOneProton{"tofAtLeastOneProton", false, "at least one candidate track has TOF hits"}; + Configurable tofBothProtons{"tofBothProtons", false, "both candidate protons have TOF hits"}; + Configurable tofOneProton{"tofOneProton", false, "one candidate proton has TOF hits"}; + Configurable dcaCut{"dcaCut", false, "DCA cut from run2."}; + Configurable newCutTPC{"newCutTPC", false, "New cuts for TPC quality tracks."}; + Configurable etaCut{"etaCut", 0.9f, "acceptance cut per track"}; + Configurable cutPtTrack{"cutPtTrack", 0.1f, "pT cut per track"}; + Configurable cutVertexZ{"cutVertexZ", 10.0f, "cut on vertex position in Z"}; + Configurable rapCut{"rapCut", 0.9f, "choose event in midrapidity"}; + Configurable dcaZCut{"dcaZCut", 2, "cut on the impact parameter in z of the track to the PV"}; + Configurable dcaXYCut{"dcaXYCut", 1e10, "cut on the impact parameter in xy of the track to the PV"}; + Configurable itsNClsCut{"itsNClsCut", 4, "minimal number of ITS clusters"}; + Configurable itsChi2NClsCut{"itsChi2NClsCut", 36, "minimal Chi2/cluster for the ITS track"}; + Configurable tpcNClsCrossedRowsCut{"tpcNClsCrossedRowsCut", 70, "minimal number of crossed TPC rows"}; + Configurable tpcChi2NCls{"tpcChi2NCls", 4, "minimal Chi2/cluster for the TPC track"}; + Configurable tpcMinNCls{"tpcMinNCls", 3, "minimum number of TPC clusters"}; + Configurable tpcCrossedOverFindable{"tpcCrossedOverFindable", 3, "number of TPC crossed rows over findable clusters"}; + + // ZDC classes cuts + Configurable znEnergyCut{"znEnergyCut", 0.0, "ZN common energy cut"}; + Configurable znTimeCut{"znTimeCut", 2.0, "ZN time cut"}; + + // Analysis cuts + Configurable maxJpsiMass{"maxJpsiMass", 3.18, "Maximum of the jpsi peak for peak cut"}; + Configurable minJpsiMass{"minJpsiMass", 3.0, "Minimum of the jpsi peak for peak cut"}; + + // SG cuts + Configurable whichGapSide{"whichGapSide", 2, {"0 for side A, 1 for side C, 2 for both sides"}}; + Configurable useTrueGap{"useTrueGap", true, {"Calculate gapSide for a given FV0/FT0/ZDC thresholds"}}; + Configurable cutMyGapSideFV0{"cutMyGapSideFV0", 100, "FV0A threshold for SG selector"}; + Configurable cutMyGapSideFT0A{"cutMyGapSideFT0A", 200., "FT0A threshold for SG selector"}; + Configurable cutMyGapSideFT0C{"cutMyGapSideFT0C", 100., "FT0C threshold for SG selector"}; + Configurable cutMyGapSideZDC{"cutMyGapSideZDC", 1000., "ZDC threshold for SG selector"}; + + // process cuts + Configurable doMuons{"doMuons", true, "Provide muon plots."}; + Configurable doElectrons{"doElectrons", true, "Provide electron plots."}; + Configurable doProtons{"doProtons", true, "Provide proton plots."}; + Configurable chargeOrdered{"chargeOrdered", false, "Order tracks based on charge."}; + Configurable doOnlyUPC{"doOnlyUPC", false, "Analyse only collisions with UPC settings."}; + Configurable doOnlyStandard{"doOnlyStandard", false, "Analyse only collisions with standard settings."}; + + // initialize histogram registry + HistogramRegistry rStatistics{ + "rStatistics", + {}}; + + HistogramRegistry rRawData{ + "rRawData", + {}}; + + HistogramRegistry rSelections{ + "rSelections", + {}}; + + HistogramRegistry rPVContributors{ + "rPVContributors", + {}}; + + HistogramRegistry rTG{ + "rTG", + {}}; + + HistogramRegistry rTGdaug{ + "TrGdaug", + {}}; + + HistogramRegistry rTGdaugCand{ + "rTGdaugCand", + {}}; + + HistogramRegistry rJpsiToDaug{ + "rJpsiToDaug", + {}}; + + HistogramRegistry rCorrelation{ + "rCorrelation", + {}}; + + HistogramRegistry rAsymmetry{ + "rAsymmetry", + {}}; + + HistogramRegistry rMC{ + "rMC", + {}}; + + using UDCollisionsFull = soa::Join; + using UDCollisionFull = UDCollisionsFull::iterator; + using UDTracksFull = soa::Join; + using UDTrackFull = UDTracksFull::iterator; + using SGUDCollisionFull = soa::Join::iterator; + using MCUDTracksFull = soa::Join; + using MCUDCollisionFull = soa::Join::iterator; + using MCSGUDCollisionFull = soa::Join::iterator; + + void init(InitContext&) + { + + // statistics histograms for counters + rStatistics.add("Statistics/hNumberOfCollisions", "hNumberOfCollisions", {HistType::kTH1F, {axisCounter}}); + rStatistics.add("Statistics/hNumberOfTracks", "hNumberOfTracks", {HistType::kTH1F, {axisCounter}}); + rStatistics.add("Statistics/hNumberGT", "hNumberGT", {HistType::kTH1F, {axisCounter}}); + rStatistics.add("Statistics/hCutCounterCollisions", "hCutCounterCollisions", {HistType::kTH1F, {axisCounter}}); + rStatistics.add("Statistics/hCutCounterTracks", "hCutCounterTracks", {HistType::kTH1F, {axisCounter}}); + + // raw data histograms + rRawData.add("RawData/hTrackPt", "hTrackPt", {HistType::kTH1F, {axisPt}}); + rRawData.add("RawData/hTrackEta", "hTrackEta", {HistType::kTH1F, {axisEta}}); + rRawData.add("RawData/hTrackPhi", "hTrackPhi", {HistType::kTH1F, {axisPhi}}); + rRawData.add("RawData/hTrackDCAXYZ", "hTrackDCAXYZ", {HistType::kTH2F, {axisDCA, axisDCA}}); + rRawData.add("RawData/hTPCNClsFindable", "hTPCNClsFindable", {HistType::kTH1F, {axisTPC}}); + rRawData.add("RawData/hTPCNClsFindableMinusFound", "hTPCNClsFindableMinusFound", {HistType::kTH1F, {axisTPC}}); + rRawData.add("RawData/hITSNCls", "hITSNCls", {HistType::kTH1F, {axisCounter}}); + rRawData.add("RawData/hTPCNCls", "hTPCNCls", {HistType::kTH1F, {axisCounter}}); + rRawData.add("RawData/hITSChi2NCls", "hITSChi2NCls", {HistType::kTH1F, {axisChi2}}); + rRawData.add("RawData/hTPCChi2NCls", "hTPCChi2NCls", {HistType::kTH1F, {axisChi2}}); + rRawData.add("RawData/hPositionZ", "hPositionZ", {HistType::kTH1F, {axisSigma}}); + rRawData.add("RawData/hPositionX", "hPositionX", {HistType::kTH1F, {axisSigma}}); + rRawData.add("RawData/hPositionY", "hPositionY", {HistType::kTH1F, {axisSigma}}); + rRawData.add("RawData/hPositionXY", "hPositionXY", {HistType::kTH2F, {axisSigma, axisSigma}}); + rRawData.add("RawData/QA/ZDC/hZNACommonEnergy", "hZNACommonEnergy", {HistType::kTH1F, {axisZDCEnergy}}); + rRawData.add("RawData/QA/ZDC/hZNCCommonEnergy", "hZNCCommonEnergy", {HistType::kTH1F, {axisZDCEnergy}}); + rRawData.add("RawData/QA/ZDC/hZNAvsZNCCommonEnergy", "hZNAvsZNCCommonEnergy", {HistType::kTH2F, {axisZDCEnergy, axisZDCEnergy}}); + rRawData.add("RawData/QA/ZDC/hZNATime", "hZNATime", {HistType::kTH1F, {axisZDCTime}}); + rRawData.add("RawData/QA/ZDC/hZNCTime", "hZNCTime", {HistType::kTH1F, {axisZDCTime}}); + rRawData.add("RawData/QA/ZDC/hZNAvsZNCTime", "hZNAvsZNCTime", {HistType::kTH2F, {axisZDCTime, axisZDCTime}}); + rRawData.add("RawData/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); + rRawData.add("RawData/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); + rRawData.add("RawData/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); + rRawData.add("RawData/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + rRawData.add("RawData/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + rRawData.add("RawData/QA/FIT/hTotFT0AmplitudeA", "hTotFT0AmplitudeA", {HistType::kTH1D, {{1000, 0.0, 1000}}}); + rRawData.add("RawData/QA/FIT/hTotFT0AmplitudeC", "hTotFT0AmplitudeC", {HistType::kTH1D, {{1000, 0.0, 1000}}}); + rRawData.add("RawData/QA/FIT/hTotFV0AmplitudeA", "hTotFV0AmplitudeA", {HistType::kTH1D, {{1000, 0.0, 1000}}}); + rRawData.add("RawData/QA/FIT/hTotFDDAmplitudeA", "hTotFDDAmplitudeA", {HistType::kTH1D, {{1000, 0.0, 1000}}}); + rRawData.add("RawData/QA/FIT/hTotFDDAmplitudeC", "hTotFDDAmplitudeC", {HistType::kTH1D, {{1000, 0.0, 1000}}}); + rRawData.add("RawData/QA/FIT/hTimeFT0A", "hTimeFT0A", {HistType::kTH1D, {{200, -100, 100}}}); + rRawData.add("RawData/QA/FIT/hTimeFT0C", "hTimeFT0C", {HistType::kTH1D, {{200, -100, 100}}}); + rRawData.add("RawData/QA/FIT/hTimeFV0A", "hTimeFV0A", {HistType::kTH1D, {{200, -100, 100}}}); + rRawData.add("RawData/QA/FIT/hTimeFDDA", "hTimeFDDA", {HistType::kTH1D, {{200, -100, 100}}}); + rRawData.add("RawData/QA/FIT/hTimeFDDC", "hTimeFDDC", {HistType::kTH1D, {{200, -100, 100}}}); + + // Selection checks + rSelections.add("Selections/Electron/Mass/Leading/hITSNCls", "hITSNCls", {HistType::kTH2F, {axisIVMSel, axisITSNCls}}); + rSelections.add("Selections/Electron/Mass/Leading/hITSChi2NCls", "hITSChi2NCls", {HistType::kTH2F, {axisIVMSel, axisChi2}}); + rSelections.add("Selections/Electron/Mass/Leading/hTPCNCls", "hTPCNCls", {HistType::kTH2F, {axisIVMSel, axisTPCNCls}}); + rSelections.add("Selections/Electron/Mass/Leading/hTPCChi2NCls", "hTPCChi2NCls", {HistType::kTH2F, {axisIVMSel, axisChi2}}); + rSelections.add("Selections/Electron/Mass/Leading/hTPCNClsCrossedRows", "hTPCNClsCrossedRows", {HistType::kTH2F, {axisIVMSel, axisTPCCrossed}}); + rSelections.addClone("Selections/Electron/Mass/Leading/", "Selections/Electron/Mass/Subleading/"); + rSelections.addClone("Selections/Electron/Mass/", "Selections/Electron/Rapidity/"); + rSelections.addClone("Selections/Electron/Mass/", "Selections/Electron/Pt/"); + rSelections.addClone("Selections/Electron/", "Selections/Muon/"); + + // PVContributors histograms + rPVContributors.add("PVContributors/hTrackPt", "hTrackPt", {HistType::kTH1F, {axisPt}}); + rPVContributors.add("PVContributors/hTrackEta", "hTrackEta", {HistType::kTH1F, {axisEta}}); + rPVContributors.add("PVContributors/hTrackPhi", "hTrackPhi", {HistType::kTH1F, {axisPhi}}); + rPVContributors.add("PVContributors/hTPCNClsFindable", "hTPCNClsFindable", {HistType::kTH1F, {axisTPC}}); + rPVContributors.add("PVContributors/hTPCNClsFindableMinusFound", "hTPCNClsFindableMinusFound", {HistType::kTH1F, {axisTPC}}); + rPVContributors.add("PVContributors/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); + rPVContributors.add("PVContributors/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); + rPVContributors.add("PVContributors/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); + rPVContributors.add("PVContributors/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + rPVContributors.add("PVContributors/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + + // TG histograms + rTG.add("TG/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); + rTG.add("TG/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); + rTG.add("TG/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); + rTG.add("TG/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); + rTG.add("TG/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); + rTG.add("TG/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); + rTG.add("TG/hTPCNClsFindable", "hTPCNClsFindable", {HistType::kTH1F, {axisTPC}}); + rTG.add("TG/hTPCNClsFindableMinusFound", "hTPCNClsFindableMinusFound", {HistType::kTH1F, {axisTPC}}); + rTG.add("TG/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); + rTG.add("TG/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); + rTG.add("TG/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); + rTG.add("TG/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + rTG.add("TG/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + rTG.add("TG/TPC/TPCNegVsPosSignal", "TPCNegVsPosSignal", HistType::kTH2F, {axisTPC, axisTPC}); + + // TGdaug histograms + rTGdaug.add("TGdaug/Muon/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); + rTGdaug.add("TGdaug/Muon/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); + rTGdaug.add("TGdaug/Muon/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); + rTGdaug.add("TGdaug/Muon/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); + rTGdaug.add("TGdaug/Muon/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); + rTGdaug.add("TGdaug/Muon/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); + rTGdaug.add("TGdaug/Muon/TPCNegVsPosSignal", "TPCNegVsPosSignal", HistType::kTH2F, {axisTPC, axisTPC}); + rTGdaug.add("TGdaug/Muon/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); + rTGdaug.add("TGdaug/Muon/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); + rTGdaug.add("TGdaug/Muon/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); + rTGdaug.add("TGdaug/Muon/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + rTGdaug.add("TGdaug/Muon/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + rTGdaug.addClone("TGdaug/Muon/", "TGdaug/Electron/"); + rTGdaug.addClone("TGdaug/Muon/", "TGdaug/Proton/"); + + // TGmuCand histograms + rTGdaugCand.add("TGdaugCand/Muon/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axisPt}}); + rTGdaugCand.add("TGdaugCand/Muon/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axisEta}}); + rTGdaugCand.add("TGdaugCand/Muon/hTrackPhi1", "hTrackPhi1", {HistType::kTH1F, {axisPhi}}); + rTGdaugCand.add("TGdaugCand/Muon/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); + rTGdaugCand.add("TGdaugCand/Muon/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); + rTGdaugCand.add("TGdaugCand/Muon/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); + rTGdaugCand.add("TGdaugCand/Muon/hPairPt", "hPairPt", {HistType::kTH1F, {axisPt}}); + rTGdaugCand.add("TGdaugCand/Muon/hPairIVM", "hPairIVM", {HistType::kTH1F, {axisIVMWide}}); + rTGdaugCand.add("TGdaugCand/Muon/hJpsiPt", "hJpsiPt", {HistType::kTH1F, {axisPt}}); + rTGdaugCand.add("TGdaugCand/Muon/hJpsiRap", "hJpsiRap", {HistType::kTH1F, {axisEta}}); + rTGdaugCand.add("TGdaugCand/Muon/TPCNegVsPosSignal", "TPCNegVsPosSignal", HistType::kTH2F, {axisTPC, axisTPC}); + rTGdaugCand.add("TGdaugCand/Muon/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); + rTGdaugCand.add("TGdaugCand/Muon/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); + rTGdaugCand.add("TGdaugCand/Muon/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); + rTGdaugCand.add("TGdaugCand/Muon/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + rTGdaugCand.add("TGdaugCand/Muon/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + rTGdaugCand.addClone("TGdaugCand/Muon/", "TGdaugCand/Electron/"); + rTGdaugCand.addClone("TGdaugCand/Muon/", "TGdaugCand/Proton/"); + + // JPsiToEl histograms + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hPt", "Pt of J/Psi ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hPt1", "pT of track 1 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hPt2", "pT of track 2 ; p_{T} {GeV/c]", {HistType::kTH1F, {axisPt}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hEta1", "eta of track 1 ; #eta {-]", {HistType::kTH1F, {axisEta}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hEta2", "eta of track 2 ; #eta {-]", {HistType::kTH1F, {axisEta}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hPhi1", "phi of track 1 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hPhi2", "phi of track 2 ; #phi {-]", {HistType::kTH1F, {axisPhi}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hRap", "Rap of J/Psi ; y {-]", {HistType::kTH1F, {axisEta}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hEta", "Eta of J/Psi ; #eta {-]", {HistType::kTH1F, {axisEta}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/xnxn/hPhi", "Phi of J/Psi ; #phi {-]", {HistType::kTH1F, {axisPhi}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisP, axisTPC}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axisPt, axisTPC}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/PID/hTPCVsPhi", "hTPCVsPhi", {HistType::kTH2F, {axisPhi, axisTPC}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + rJpsiToDaug.add("JPsiToDaug/Electron/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + rJpsiToDaug.add("JPsiToDaug/Electron/NotCoherent/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); + rJpsiToDaug.add("JPsiToDaug/Electron/NotCoherent/xnxn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); + rJpsiToDaug.add("JPsiToDaug/Electron/NotCoherent/onon/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); + rJpsiToDaug.add("JPsiToDaug/Electron/NotCoherent/xnon/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); + rJpsiToDaug.add("JPsiToDaug/Electron/NotCoherent/onxn/hIVM", "J/Psi Invariant Mass ; m {GeV]", {HistType::kTH1F, {axisIVM}}); + rJpsiToDaug.addClone("JPsiToDaug/Electron/Coherent/xnxn/", "JPsiToDaug/Electron/Coherent/onxn/"); + rJpsiToDaug.addClone("JPsiToDaug/Electron/Coherent/xnxn/", "JPsiToDaug/Electron/Coherent/onon/"); + rJpsiToDaug.addClone("JPsiToDaug/Electron/Coherent/xnxn/", "JPsiToDaug/Electron/Coherent/xnon/"); + rJpsiToDaug.addClone("JPsiToDaug/Electron/Coherent/", "JPsiToDaug/Electron/Incoherent/"); + rJpsiToDaug.addClone("JPsiToDaug/Electron/", "JPsiToDaug/Muon/"); + rJpsiToDaug.addClone("JPsiToDaug/Electron/", "JPsiToDaug/Proton/"); + + // Correlation histograms + rCorrelation.add("Correlation/Muon/Coherent/AccoplAngle", "AccoplAngle", {HistType::kTH1F, {axisAccAngle}}); + rCorrelation.add("Correlation/Muon/Coherent/CosTheta", "CosTheta", {HistType::kTH1F, {axisAngTheta}}); + rCorrelation.add("Correlation/Muon/Coherent/Phi", "Phi", {HistType::kTH1F, {axisPhi}}); + rCorrelation.add("Correlation/Muon/Coherent/Phi1", "Phi1", {HistType::kTH1F, {axisPhi}}); + rCorrelation.add("Correlation/Muon/Coherent/Phi2", "Phi2", {HistType::kTH1F, {axisPhi}}); + rCorrelation.add("Correlation/Muon/Coherent/CosThetaPhi", "CosThetaPhi", {HistType::kTH2F, {{axisAngTheta}, {axisPhi}}}); + rCorrelation.addClone("Correlation/Muon/Coherent/", "Correlation/Muon/Incoherent/"); + rCorrelation.addClone("Correlation/Muon/", "Correlation/Electron/"); + rCorrelation.addClone("Correlation/Muon/", "Correlation/Proton/"); + + // Asymmetry histograms + rAsymmetry.add("Asymmetry/Muon/Coherent/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); + rAsymmetry.add("Asymmetry/Muon/Coherent/xnxn/DeltaPhi", "DeltaPhi", {HistType::kTH1F, {{180, -PI, PI}}}); + rAsymmetry.add("Asymmetry/Muon/Coherent/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); + rAsymmetry.add("Asymmetry/Muon/Coherent/xnxn/DeltaPhiRandom", "DeltaPhiRandom", {HistType::kTH1F, {{180, -PI, PI}}}); + rAsymmetry.addClone("Asymmetry/Muon/Coherent/xnxn/", "Asymmetry/Muon/Coherent/onxn/"); + rAsymmetry.addClone("Asymmetry/Muon/Coherent/xnxn/", "Asymmetry/Muon/Coherent/onon/"); + rAsymmetry.addClone("Asymmetry/Muon/Coherent/xnxn/", "Asymmetry/Muon/Coherent/xnon/"); + rAsymmetry.addClone("Asymmetry/Muon/Coherent/", "Asymmetry/Muon/Incoherent/"); + rAsymmetry.addClone("Asymmetry/Muon/", "Asymmetry/Electron/"); + + // MC histograms + rMC.add("MC/hNumberOfMCCollisions", "hNumberOfCollisions", {HistType::kTH1F, {{10, 0, 10}}}); + rMC.add("MC/hNumberOfRecoCollisions", "hNumberOfRecoCollisions", {HistType::kTH1F, {{10, 0, 10}}}); + rMC.add("MC/hNumberOfTrueCollisions", "hNumberOfTrueCollisions", {HistType::kTH1F, {{10, 0, 10}}}); + rMC.add("MC/Muon/hNumberOfMCTracks", "hNumberOfMCTracks", {HistType::kTH1F, {{10, 0, 10}}}); + rMC.add("MC/hNumberOfMatchedMCTracks", "hNumberOfMatchedMCTracks", {HistType::kTH1F, {{10, 0, 10}}}); + rMC.add("MC/hPosZ", "hPosZ", {HistType::kTH1F, {{60, -15, 15}}}); + rMC.add("MC/hMothersPdg", "hMothersPdg", {HistType::kTH1F, {{1000, -500, 500}}}); + rMC.add("MC/hPdg", "hPdg", {HistType::kTH1F, {{1000, -500, 500}}}); + rMC.add("MC/Muon/hEta1", "hEta1", {HistType::kTH1F, {axisEta}}); + rMC.add("MC/Muon/hEta2", "hEta2", {HistType::kTH1F, {axisEta}}); + rMC.add("MC/Muon/hEta", "hEta", {HistType::kTH1F, {axisEta}}); + rMC.add("MC/Muon/hPhi1", "hPhi1", {HistType::kTH1F, {axisPhi}}); + rMC.add("MC/Muon/hPhi2", "hPhi2", {HistType::kTH1F, {axisPhi}}); + rMC.add("MC/Muon/hPhi", "hPhi", {HistType::kTH1F, {axisPhi}}); + rMC.add("MC/Muon/hIVM", "hIVM", {HistType::kTH1F, {axisIVM}}); + rMC.add("MC/Muon/hRapidity", "hRapidity", {HistType::kTH1F, {axisEta}}); + rMC.add("MC/Muon/hPt1", "hPt1", {HistType::kTH1F, {axisPt}}); + rMC.add("MC/Muon/hPt2", "hPt2", {HistType::kTH1F, {axisPt}}); + rMC.add("MC/Muon/hPt", "hPt", {HistType::kTH1F, {axisPt}}); + rMC.add("MC/hResolution", "hResolution", {HistType::kTH1F, {{100, -10, 10}}}); + rMC.add("MC/hResolutionPhi", "hResolutionPhi", {HistType::kTH1F, {{100, -0.01, 0.01}}}); + } + + bool cutITSLayers(uint8_t itsClusterMap) const + { + std::vector>> requiredITSHits{}; + requiredITSHits.push_back(std::make_pair(1, std::array{0, 1, 2})); // at least one hit in the innermost layer + constexpr uint8_t kBit = 1; + for (const auto& itsRequirement : requiredITSHits) { + auto hits = std::count_if(itsRequirement.second.begin(), itsRequirement.second.end(), [&](auto&& requiredLayer) { return itsClusterMap & (kBit << requiredLayer); }); + + if ((itsRequirement.first == -1) && (hits > 0)) { + return false; // no hits were required in specified layers + } else if (hits < itsRequirement.first) { + return false; // not enough hits found in specified layers + } + } + return true; + } + + template + bool goodTrackCuts(T const& track) + { + // choose only PV contributors + if (!track.isPVContributor()) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(1); + return false; + } + // pT cut to choose only tracks contributing to J/psi + if (track.pt() < cutPtTrack) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(2); + return false; + } + // acceptance cut (TPC) + if (std::abs(RecoDecay::eta(std::array{track.px(), track.py(), track.pz()})) > etaCut) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(3); + return false; + } + // DCA + if (std::abs(track.dcaZ()) > dcaZCut) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(4); + return false; + } + if (dcaCut) { + float dcaXYPtCut = 0.0105f + 0.0350f / std::pow(track.pt(), 1.1f); + if (std::abs(track.dcaXY()) > dcaXYPtCut) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(5); + return false; + } + } else { + if (std::abs(track.dcaXY()) > dcaXYCut) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(5); + return false; + } + } + // ITS + if (!track.hasITS()) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(6); + return false; + } + if (track.itsNCls() < itsNClsCut) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(7); + return false; + } + if (!cutITSLayers(track.itsClusterMap())) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(8); + return false; + } + if (track.itsChi2NCl() > itsChi2NClsCut) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(9); + return false; + } + // TPC + if (!track.hasTPC()) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(10); + return false; + } + if (track.tpcNClsCrossedRows() < tpcNClsCrossedRowsCut) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(11); + return false; + } + if (track.tpcChi2NCl() > tpcChi2NCls) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(12); + return false; // TPC chi2 + } + if ((track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()) < tpcMinNCls) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(13); + return false; + } + if (newCutTPC) { + if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < tpcCrossedOverFindable) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(14); + return false; + } + } + + return true; + } + + bool candidateCuts(float massJpsi, float rapJpsi) + { + if (std::abs(rapJpsi) > rapCut) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(15); + return false; + } + + if (massJpsi < 2.0f) { + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(16); + return false; + } + + return true; + } + + static constexpr std::string_view DaugType[3] = {"Electron/", "Muon/", "Proton/"}; + static constexpr std::string_view ProdType[2] = {"Coherent/", "Incoherent/"}; + static constexpr std::string_view NeutronClass[5] = {"", "xnxn/", "onxn/", "onon/", "xnon/"}; + + template + void fillSelections(const T& leadingP, const T& subleadingP, float massJpsi, float rapJpsi, std::array mother) + { + // selections + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Leading/hITSNCls"))->Fill(massJpsi, leadingP.itsNCls()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Leading/hITSChi2NCls"))->Fill(massJpsi, leadingP.itsChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Leading/hTPCNCls"))->Fill(massJpsi, leadingP.tpcNClsFindable() - leadingP.tpcNClsFindableMinusFound()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Leading/hTPCChi2NCls"))->Fill(massJpsi, leadingP.tpcChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Leading/hTPCNClsCrossedRows"))->Fill(massJpsi, subleadingP.tpcNClsCrossedRows()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Subleading/hITSNCls"))->Fill(massJpsi, subleadingP.itsNCls()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Subleading/hITSChi2NCls"))->Fill(massJpsi, subleadingP.itsChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Subleading/hTPCNCls"))->Fill(massJpsi, subleadingP.tpcNClsFindable() - subleadingP.tpcNClsFindableMinusFound()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Subleading/hTPCChi2NCls"))->Fill(massJpsi, subleadingP.tpcChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Mass/Subleading/hTPCNClsCrossedRows"))->Fill(massJpsi, subleadingP.tpcNClsCrossedRows()); + + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Leading/hITSNCls"))->Fill(rapJpsi, leadingP.itsNCls()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Leading/hITSChi2NCls"))->Fill(rapJpsi, leadingP.itsChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Leading/hTPCNCls"))->Fill(rapJpsi, leadingP.tpcNClsFindable() - leadingP.tpcNClsFindableMinusFound()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Leading/hTPCChi2NCls"))->Fill(rapJpsi, leadingP.tpcChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Leading/hTPCNClsCrossedRows"))->Fill(rapJpsi, subleadingP.tpcNClsCrossedRows()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Subleading/hITSNCls"))->Fill(rapJpsi, subleadingP.itsNCls()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Subleading/hITSChi2NCls"))->Fill(rapJpsi, subleadingP.itsChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Subleading/hTPCNCls"))->Fill(rapJpsi, subleadingP.tpcNClsFindable() - subleadingP.tpcNClsFindableMinusFound()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Subleading/hTPCChi2NCls"))->Fill(rapJpsi, subleadingP.tpcChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Rapidity/Subleading/hTPCNClsCrossedRows"))->Fill(rapJpsi, subleadingP.tpcNClsCrossedRows()); + + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Leading/hITSNCls"))->Fill(RecoDecay::pt(mother), leadingP.itsNCls()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Leading/hITSChi2NCls"))->Fill(RecoDecay::pt(mother), leadingP.itsChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Leading/hTPCNCls"))->Fill(RecoDecay::pt(mother), leadingP.tpcNClsFindable() - leadingP.tpcNClsFindableMinusFound()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Leading/hTPCChi2NCls"))->Fill(RecoDecay::pt(mother), leadingP.tpcChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Leading/hTPCNClsCrossedRows"))->Fill(RecoDecay::pt(mother), subleadingP.tpcNClsCrossedRows()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Subleading/hITSNCls"))->Fill(RecoDecay::pt(mother), subleadingP.itsNCls()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Subleading/hITSChi2NCls"))->Fill(RecoDecay::pt(mother), subleadingP.itsChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Subleading/hTPCNCls"))->Fill(RecoDecay::pt(mother), subleadingP.tpcNClsFindable() - subleadingP.tpcNClsFindableMinusFound()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Subleading/hTPCChi2NCls"))->Fill(RecoDecay::pt(mother), subleadingP.tpcChi2NCl()); + rSelections.get(HIST("Selections/") + HIST(DaugType[daug]) + HIST("Pt/Subleading/hTPCNClsCrossedRows"))->Fill(RecoDecay::pt(mother), subleadingP.tpcNClsCrossedRows()); + } + + template + void fillTGdaug(const T& trkDaughter1, const T& trkDaughter2, std::array daughter1, std::array daughter2) + { + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("hTrackPt1"))->Fill(trkDaughter1.pt()); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("hTrackPt2"))->Fill(trkDaughter2.pt()); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); + + if (trkDaughter1.hasTPC()) { + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); + if (trkDaughter1.sign() < 0) { + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); + } else { + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); + } + } + if (trkDaughter2.hasTPC()) { + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); + } + if (trkDaughter1.hasTOF()) { + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + } + if (trkDaughter2.hasTOF()) { + + rTGdaug.get(HIST("TGdaug/") + HIST(DaugType[daug]) + HIST("PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + } + } + template + void fillCand(const T& trkDaughter1, const T& trkDaughter2, std::array daughter1, std::array daughter2, std::array mother, float massJpsi, bool xnxn, bool onon, bool onxn, bool xnon) + { + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("hTrackPt1"))->Fill(trkDaughter1.pt()); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("hTrackPt2"))->Fill(trkDaughter2.pt()); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("hPairPt"))->Fill(RecoDecay::pt(mother)); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("hPairIVM"))->Fill(massJpsi); + + if (trkDaughter1.hasTPC()) { + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); + } + if (trkDaughter2.hasTPC()) { + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); + } + if (trkDaughter1.hasTOF()) { + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + } + if (trkDaughter2.hasTOF()) { + rTGdaugCand.get(HIST("TGdaugCand/") + HIST(DaugType[daug]) + HIST("PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + } + + if (RecoDecay::pt(mother) < 0.2f) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Coherent/hIVM"))->Fill(massJpsi); + if (xnxn) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Coherent/xnxn/hIVM"))->Fill(massJpsi); + } else if (onxn) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Coherent/onxn/hIVM"))->Fill(massJpsi); + } else if (xnon) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Coherent/xnon/hIVM"))->Fill(massJpsi); + } else if (onon) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Coherent/onon/hIVM"))->Fill(massJpsi); + } + } else if (RecoDecay::pt(mother) > 0.4f) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("NotCoherent/hIVM"))->Fill(massJpsi); + if (xnxn) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("NotCoherent/xnxn/hIVM"))->Fill(massJpsi); + } else if (onxn) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("NotCoherent/onxn/hIVM"))->Fill(massJpsi); + } else if (xnon) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("NotCoherent/xnon/hIVM"))->Fill(massJpsi); + } else if (onon) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("NotCoherent/onon/hIVM"))->Fill(massJpsi); + } + } + if (RecoDecay::pt(mother) > 0.2f) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Incoherent/hIVM"))->Fill(massJpsi); + if (xnxn) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Incoherent/xnxn/hIVM"))->Fill(massJpsi); + } else if (onxn) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Incoherent/onxn/hIVM"))->Fill(massJpsi); + } else if (xnon) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Incoherent/xnon/hIVM"))->Fill(massJpsi); + } else if (onon) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST("Incoherent/onon/hIVM"))->Fill(massJpsi); + } + } + } + + template + void fillPeak(const T& trkDaughter1, const T& trkDaughter2, std::array daughter1, std::array daughter2, std::array mother, float rapJpsi) + { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hPt1"))->Fill(trkDaughter1.pt()); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hPt2"))->Fill(trkDaughter2.pt()); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hEta1"))->Fill(RecoDecay::eta(daughter1)); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hEta2"))->Fill(RecoDecay::eta(daughter2)); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hPhi1"))->Fill(RecoDecay::phi(daughter1)); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hPhi2"))->Fill(RecoDecay::phi(daughter2)); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hPt"))->Fill(RecoDecay::pt(mother)); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hEta"))->Fill(RecoDecay::eta(mother)); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hRap"))->Fill(rapJpsi); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("hPhi"))->Fill(RecoDecay::phi(mother)); + + if (trkDaughter1.hasTPC()) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); + } + if (trkDaughter2.hasTPC()) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); + } + if (trkDaughter1.hasTOF()) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + } + if (trkDaughter2.hasTOF()) { + rJpsiToDaug.get(HIST("JPsiToDaug/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + } + } + + template + void fillCorrAsy(std::array daughter1, std::array daughter2, double dp, double dpRandom, float* q) + { + if (neutron == 0) { + rCorrelation.get(HIST("Correlation/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("Phi1"))->Fill(RecoDecay::phi(daughter1), 1.); + rCorrelation.get(HIST("Correlation/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("Phi2"))->Fill(RecoDecay::phi(daughter2), 1.); + rCorrelation.get(HIST("Correlation/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("Phi"))->Fill(q[1], 1.); + rCorrelation.get(HIST("Correlation/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("CosTheta"))->Fill(q[2], 1.); + rCorrelation.get(HIST("Correlation/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("AccoplAngle"))->Fill(q[0], 1.); + rCorrelation.get(HIST("Correlation/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST("CosThetaPhi"))->Fill(q[2], q[1]); + } + + rAsymmetry.get(HIST("Asymmetry/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("DeltaPhi"))->Fill(dp); + rAsymmetry.get(HIST("Asymmetry/") + HIST(DaugType[daug]) + HIST(ProdType[prod]) + HIST(NeutronClass[neutron]) + HIST("DeltaPhiRandom"))->Fill(dpRandom); + } + + template + void fillHistograms(C collision, Ts tracks) + { + rStatistics.get(HIST("Statistics/hCutCounterCollisions"))->Fill(0); // number of collisions without any cuts + + // check UPC vs standard + if (doOnlyUPC) { + if (collision.flags() == 0) { + return; + } + } + if (doOnlyStandard) { + if (collision.flags() == 1) { + return; + } + } + + if (std::abs(collision.posZ()) > cutVertexZ) { + rStatistics.get(HIST("Statistics/hCutCounterCollisions"))->Fill(1); + return; + } + + // distinguish ZDC classes + bool xnxn = false, onon = false, xnon = false, onxn = false; + int neutronClass = -1; + if (collision.energyCommonZNA() < znEnergyCut && collision.energyCommonZNC() < znEnergyCut) { + onon = true; + neutronClass = 0; + } + if (collision.energyCommonZNA() > znEnergyCut && std::abs(collision.timeZNA()) < znTimeCut && collision.energyCommonZNC() > znEnergyCut && std::abs(collision.timeZNC()) < znTimeCut) { + xnxn = true; + neutronClass = 1; + } + if (collision.energyCommonZNA() > znEnergyCut && std::abs(collision.timeZNA()) < znTimeCut && collision.energyCommonZNC() < znEnergyCut) { + xnon = true; + neutronClass = 2; + } + if (collision.energyCommonZNA() < znEnergyCut && collision.energyCommonZNC() > znEnergyCut && std::abs(collision.timeZNC()) < znTimeCut) { + onxn = true; + neutronClass = 3; + } + + // loop over tracks without selections + for (const auto& track : tracks) { + float trkPx = track.px(); + float trkPy = track.py(); + float trkPz = track.pz(); + + rStatistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(0); + rStatistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(0); + if (track.isPVContributor() == 1) { + rStatistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(1); + rPVContributors.get(HIST("PVContributors/hTrackPt"))->Fill(track.pt()); + rPVContributors.get(HIST("PVContributors/hTrackEta"))->Fill(RecoDecay::eta(std::array{trkPx, trkPy, trkPz})); + rPVContributors.get(HIST("PVContributors/hTrackPhi"))->Fill(RecoDecay::phi(trkPx, trkPy)); + + if (track.hasTPC()) { + rPVContributors.get(HIST("PVContributors/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkPx, trkPy, trkPz), track.tpcSignal()); + rPVContributors.get(HIST("PVContributors/PID/hTPCVsPt"))->Fill(track.pt(), track.tpcSignal()); + rPVContributors.get(HIST("PVContributors/PID/hTPCVsEta"))->Fill(RecoDecay::eta(std::array{trkPx, trkPy, trkPz}), track.tpcSignal()); + rPVContributors.get(HIST("PVContributors/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(trkPx, trkPy), track.tpcSignal()); + rPVContributors.get(HIST("PVContributors/hTPCNClsFindable"))->Fill(track.tpcNClsFindable()); + rPVContributors.get(HIST("PVContributors/hTPCNClsFindableMinusFound"))->Fill(track.tpcNClsFindableMinusFound()); + } + + if (track.hasTOF()) { + rPVContributors.get(HIST("PVContributors/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkPx, trkPy, trkPz), track.beta()); + } + } + + rRawData.get(HIST("RawData/hTrackPt"))->Fill(track.pt()); + rRawData.get(HIST("RawData/hTrackEta"))->Fill(RecoDecay::eta(std::array{trkPx, trkPy, trkPz})); + rRawData.get(HIST("RawData/hTrackPhi"))->Fill(RecoDecay::phi(trkPx, trkPy)); + rRawData.get(HIST("RawData/hTrackDCAXYZ"))->Fill(track.dcaXY(), track.dcaZ()); + rRawData.get(HIST("RawData/hTPCNClsFindable"))->Fill(track.tpcNClsFindable()); + rRawData.get(HIST("RawData/hTPCNClsFindableMinusFound"))->Fill(track.tpcNClsFindableMinusFound()); + rRawData.get(HIST("RawData/hITSNCls"))->Fill(track.itsNCls()); + rRawData.get(HIST("RawData/hTPCNCls"))->Fill(track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()); + rRawData.get(HIST("RawData/hITSChi2NCls"))->Fill(track.itsChi2NCl()); + rRawData.get(HIST("RawData/hTPCChi2NCls"))->Fill(track.tpcChi2NCl()); + rRawData.get(HIST("RawData/QA/FIT/hTotFT0AmplitudeA"))->Fill(collision.totalFT0AmplitudeA()); + rRawData.get(HIST("RawData/QA/FIT/hTotFT0AmplitudeC"))->Fill(collision.totalFT0AmplitudeC()); + rRawData.get(HIST("RawData/QA/FIT/hTotFV0AmplitudeA"))->Fill(collision.totalFV0AmplitudeA()); + rRawData.get(HIST("RawData/QA/FIT/hTotFDDAmplitudeA"))->Fill(collision.totalFDDAmplitudeA()); + rRawData.get(HIST("RawData/QA/FIT/hTotFDDAmplitudeC"))->Fill(collision.totalFDDAmplitudeC()); + rRawData.get(HIST("RawData/QA/FIT/hTimeFT0A"))->Fill(collision.timeFT0A()); + rRawData.get(HIST("RawData/QA/FIT/hTimeFT0C"))->Fill(collision.timeFT0C()); + rRawData.get(HIST("RawData/QA/FIT/hTimeFV0A"))->Fill(collision.timeFV0A()); + rRawData.get(HIST("RawData/QA/FIT/hTimeFDDA"))->Fill(collision.timeFDDA()); + rRawData.get(HIST("RawData/QA/FIT/hTimeFDDC"))->Fill(collision.timeFDDC()); + + if (track.hasTPC()) { + rRawData.get(HIST("RawData/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkPx, trkPy, trkPz), track.tpcSignal()); + rRawData.get(HIST("RawData/PID/hTPCVsPt"))->Fill(track.pt(), track.tpcSignal()); + rRawData.get(HIST("RawData/PID/hTPCVsEta"))->Fill(RecoDecay::eta(std::array{trkPx, trkPy, trkPz}), track.tpcSignal()); + rRawData.get(HIST("RawData/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(trkPx, trkPy), track.tpcSignal()); + } + + if (track.hasTOF()) { + rRawData.get(HIST("RawData/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkPx, trkPy, trkPz), track.beta()); + } + } + + int countGT = 0; + std::vector trkIdx; + // loop over tracks with selections + + rRawData.get(HIST("RawData/hPositionX"))->Fill(collision.posX()); + rRawData.get(HIST("RawData/hPositionY"))->Fill(collision.posY()); + rRawData.get(HIST("RawData/hPositionZ"))->Fill(collision.posZ()); + rRawData.get(HIST("RawData/hPositionXY"))->Fill(collision.posX(), collision.posY()); + rRawData.get(HIST("RawData/QA/ZDC/hZNACommonEnergy"))->Fill(collision.energyCommonZNA()); + rRawData.get(HIST("RawData/QA/ZDC/hZNCCommonEnergy"))->Fill(collision.energyCommonZNC()); + rRawData.get(HIST("RawData/QA/ZDC/hZNAvsZNCCommonEnergy"))->Fill(collision.energyCommonZNA(), collision.energyCommonZNC()); + rRawData.get(HIST("RawData/QA/ZDC/hZNCTime"))->Fill(collision.timeZNC()); + rRawData.get(HIST("RawData/QA/ZDC/hZNATime"))->Fill(collision.timeZNA()); + rRawData.get(HIST("RawData/QA/ZDC/hZNAvsZNCTime"))->Fill(collision.timeZNA(), collision.timeZNC()); + + for (const auto& track : tracks) { + + rStatistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(2.); + + // select good tracks + if (goodTrackCuts(track) != 1) { + continue; + } + + countGT++; + trkIdx.push_back(track.index()); + } + + rStatistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(3., countGT); + rStatistics.get(HIST("Statistics/hNumberGT"))->Fill(countGT); + + float massEl = o2::constants::physics::MassElectron; + float massMu = o2::constants::physics::MassMuonMinus; + float massPr = o2::constants::physics::MassProton; + + if (countGT == 2) { + TLorentzVector mom, daughter[2]; + auto trkDaughter1 = tracks.iteratorAt(trkIdx[0]); + auto trkDaughter2 = tracks.iteratorAt(trkIdx[1]); + + if ((trkDaughter1.sign() * trkDaughter2.sign()) != -1) { + return; + } + + if (chargeOrdered) { + if (tracks.iteratorAt(trkIdx[0]).sign() < 0) { + trkDaughter1 = tracks.iteratorAt(trkIdx[0]); + trkDaughter2 = tracks.iteratorAt(trkIdx[1]); + } else { + trkDaughter1 = tracks.iteratorAt(trkIdx[1]); + trkDaughter2 = tracks.iteratorAt(trkIdx[0]); + } + } + + std::array daughter1 = {trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()}; + std::array daughter2 = {trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()}; + + rTG.get(HIST("TG/hTrackPt1"))->Fill(trkDaughter1.pt()); + rTG.get(HIST("TG/hTrackPt2"))->Fill(trkDaughter2.pt()); + rTG.get(HIST("TG/hTrackEta1"))->Fill(RecoDecay::eta(daughter1)); + rTG.get(HIST("TG/hTrackEta2"))->Fill(RecoDecay::eta(daughter2)); + rTG.get(HIST("TG/hTrackPhi1"))->Fill(RecoDecay::phi(daughter1)); + rTG.get(HIST("TG/hTrackPhi2"))->Fill(RecoDecay::phi(daughter2)); + + if (trkDaughter1.hasTPC()) { + rTG.get(HIST("TG/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tpcSignal()); + rTG.get(HIST("TG/PID/hTPCVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tpcSignal()); + rTG.get(HIST("TG/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tpcSignal()); + rTG.get(HIST("TG/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tpcSignal()); + rTG.get(HIST("TG/hTPCNClsFindable"))->Fill(trkDaughter1.tpcNClsFindable()); + rTG.get(HIST("TG/hTPCNClsFindableMinusFound"))->Fill(trkDaughter1.tpcNClsFindableMinusFound()); + if (trkDaughter1.sign() < 0) { + rTG.get(HIST("TG/TPC/TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); + } else { + rTG.get(HIST("TG/TPC/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); + } + } + if (trkDaughter2.hasTPC()) { + rTG.get(HIST("TG/PID/hTPCVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); + rTG.get(HIST("TG/PID/hTPCVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); + rTG.get(HIST("TG/PID/hTPCVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); + rTG.get(HIST("TG/PID/hTPCVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); + rTG.get(HIST("TG/hTPCNClsFindable"))->Fill(trkDaughter2.tpcNClsFindable()); + rTG.get(HIST("TG/hTPCNClsFindableMinusFound"))->Fill(trkDaughter2.tpcNClsFindableMinusFound()); + } + if (trkDaughter1.hasTOF()) { + rTG.get(HIST("TG/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + } + if (trkDaughter2.hasTOF()) { + rTG.get(HIST("TG/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + } + + if (doElectrons) { + if (RecoDecay::sumOfSquares(trkDaughter1.tpcNSigmaMu(), trkDaughter2.tpcNSigmaMu()) > RecoDecay::sumOfSquares(trkDaughter1.tpcNSigmaEl(), trkDaughter2.tpcNSigmaEl())) { + + auto ene1 = RecoDecay::e(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), massEl); + auto ene2 = RecoDecay::e(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), massEl); + daughter[0].SetPxPyPzE(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), ene1); + daughter[1].SetPxPyPzE(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), ene2); + mom = daughter[0] + daughter[1]; + + std::array mother = {trkDaughter1.px() + trkDaughter2.px(), trkDaughter1.py() + trkDaughter2.py(), trkDaughter1.pz() + trkDaughter2.pz()}; + + auto arrMom = std::array{daughter1, daughter2}; + float massJpsi = RecoDecay::m(arrMom, std::array{massEl, massEl}); + float rapJpsi = RecoDecay::y(mother, massJpsi); + + auto leadingP = RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()) > RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()) ? trkDaughter1 : trkDaughter2; + auto subleadingP = (leadingP == trkDaughter1) ? trkDaughter1 : trkDaughter2; + + // TGdaug + fillTGdaug<0>(trkDaughter1, trkDaughter2, daughter1, daughter2); + + // selections + fillSelections<0>(leadingP, subleadingP, massJpsi, rapJpsi, mother); + + if (candidateCuts(massJpsi, rapJpsi) != 1) { + return; + } + + // TGdaugCand + fillCand<0>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, massJpsi, xnxn, onon, onxn, xnon); + + double dp = DeltaPhi(daughter[0], daughter[1]); + float* q = correlation(&daughter[0], &daughter[1], &mom); + double dpRandom = DeltaPhiRandom(daughter[0], daughter[1]); + + if ((massJpsi < maxJpsiMass) && (massJpsi > minJpsiMass)) { + rTGdaugCand.get(HIST("TGdaugCand/Electron/hJpsiPt"))->Fill(RecoDecay::pt(mother)); + rTGdaugCand.get(HIST("TGdaugCand/Electron/hJpsiRap"))->Fill(rapJpsi); + + if (trkDaughter1.sign() < 0) { + rTGdaugCand.get(HIST("TGdaugCand/Electron/TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); + } else { + rTGdaugCand.get(HIST("TGdaugCand/Electron/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); + } + + if (RecoDecay::pt(mother) < 0.2f) { + fillPeak<0, 0, 0>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + + if (xnxn) { + fillPeak<0, 0, 1>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<0, 0, 1>(daughter1, daughter2, dp, dpRandom, q); + } else if (onon) { + fillPeak<0, 0, 3>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<0, 0, 3>(daughter1, daughter2, dp, dpRandom, q); + } else if (xnon) { + fillPeak<0, 0, 4>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<0, 0, 4>(daughter1, daughter2, dp, dpRandom, q); + } else if (onxn) { + fillPeak<0, 0, 2>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<0, 0, 2>(daughter1, daughter2, dp, dpRandom, q); + } + fillCorrAsy<0, 0, 0>(daughter1, daughter2, dp, dpRandom, q); + + } // end coherent electrons + if (RecoDecay::pt(mother) > 0.2f) { + fillPeak<0, 1, 0>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<0, 1, 0>(daughter1, daughter2, dp, dpRandom, q); + + if (xnxn) { + fillPeak<0, 1, 1>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + } else if (onon) { + fillPeak<0, 1, 3>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<0, 1, 3>(daughter1, daughter2, dp, dpRandom, q); + } else if (xnon) { + fillPeak<0, 1, 4>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<0, 1, 4>(daughter1, daughter2, dp, dpRandom, q); + } else if (onxn) { + fillPeak<0, 1, 2>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<0, 1, 2>(daughter1, daughter2, dp, dpRandom, q); + } + + } // end incoherent electrons + } // end mass cut + delete[] q; + } + } // end electrons + if (doMuons) { + if (RecoDecay::sumOfSquares(trkDaughter1.tpcNSigmaEl(), trkDaughter2.tpcNSigmaEl()) > RecoDecay::sumOfSquares(trkDaughter1.tpcNSigmaMu(), trkDaughter2.tpcNSigmaMu())) { + + auto ene1 = RecoDecay::e(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), massMu); + auto ene2 = RecoDecay::e(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), massMu); + daughter[0].SetPxPyPzE(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), ene1); + daughter[1].SetPxPyPzE(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), ene2); + mom = daughter[0] + daughter[1]; + + std::array mother = {trkDaughter1.px() + trkDaughter2.px(), trkDaughter1.py() + trkDaughter2.py(), trkDaughter1.pz() + trkDaughter2.pz()}; + + auto arrMom = std::array{daughter1, daughter2}; + float massJpsi = RecoDecay::m(arrMom, std::array{massMu, massMu}); + float rapJpsi = RecoDecay::y(mother, massJpsi); + + auto leadingP = RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()) > RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()) ? trkDaughter1 : trkDaughter2; + auto subleadingP = (leadingP == trkDaughter1) ? trkDaughter1 : trkDaughter2; + + // TGdaug + fillTGdaug<1>(trkDaughter1, trkDaughter2, daughter1, daughter2); + // selections + fillSelections<1>(leadingP, subleadingP, massJpsi, rapJpsi, mother); + + if (candidateCuts(massJpsi, rapJpsi) != 1) { + return; + } + + // TGdaugCand + fillCand<1>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, massJpsi, xnxn, onon, onxn, xnon); + + double dp = DeltaPhi(daughter[0], daughter[1]); + float* q = correlation(&daughter[0], &daughter[1], &mom); + double dpRandom = DeltaPhiRandom(daughter[0], daughter[1]); + // fill tree with muon J/Psi candidates + tree(collision.runNumber(), collision.globalBC(), + collision.posX(), collision.posY(), collision.posZ(), + collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), collision.totalFV0AmplitudeA(), collision.totalFDDAmplitudeA(), collision.totalFDDAmplitudeC(), + collision.timeFT0A(), collision.timeFT0C(), collision.timeFV0A(), collision.timeFDDA(), collision.timeFDDC(), + collision.energyCommonZNA(), collision.energyCommonZNC(), collision.timeZNA(), collision.timeZNC(), neutronClass, + RecoDecay::pt(mother), RecoDecay::eta(mother), RecoDecay::phi(mother), rapJpsi, massJpsi, dpRandom, dp, q[1], q[2], + trkDaughter1.sign(), trkDaughter1.pt(), RecoDecay::eta(daughter1), RecoDecay::phi(daughter1), + trkDaughter2.sign(), trkDaughter2.pt(), RecoDecay::eta(daughter2), RecoDecay::phi(daughter2)); + + if ((massJpsi < maxJpsiMass) && (massJpsi > minJpsiMass)) { + rTGdaugCand.get(HIST("TGdaugCand/Muon/hJpsiPt"))->Fill(RecoDecay::pt(mother)); + rTGdaugCand.get(HIST("TGdaugCand/Muon/hJpsiRap"))->Fill(rapJpsi); + if (trkDaughter1.sign() < 0) { + rTGdaugCand.get(HIST("TGdaugCand/Muon/TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); + } else { + rTGdaugCand.get(HIST("TGdaugCand/Muon/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); + } + + if (RecoDecay::pt(mother) < 0.2f) { + fillPeak<1, 0, 0>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 0, 0>(daughter1, daughter2, dp, dpRandom, q); + + if (xnxn) { + fillPeak<1, 0, 1>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 0, 1>(daughter1, daughter2, dp, dpRandom, q); + } else if (onon) { + fillPeak<1, 0, 3>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 0, 3>(daughter1, daughter2, dp, dpRandom, q); + } else if (xnon) { + fillPeak<1, 0, 4>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 0, 4>(daughter1, daughter2, dp, dpRandom, q); + } else if (onxn) { + fillPeak<1, 0, 2>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 0, 2>(daughter1, daughter2, dp, dpRandom, q); + } + } + if (RecoDecay::pt(mother) > 0.2f) { + fillPeak<1, 1, 0>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 1, 0>(daughter1, daughter2, dp, dpRandom, q); + + if (xnxn) { + fillPeak<1, 1, 1>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 1, 1>(daughter1, daughter2, dp, dpRandom, q); + } else if (onon) { + fillPeak<1, 1, 3>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 1, 3>(daughter1, daughter2, dp, dpRandom, q); + } else if (xnon) { + fillPeak<1, 1, 4>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 1, 4>(daughter1, daughter2, dp, dpRandom, q); + } else if (onxn) { + fillPeak<1, 1, 2>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + fillCorrAsy<1, 1, 2>(daughter1, daughter2, dp, dpRandom, q); + } + } // end incoherent + } // end mass cut + delete[] q; + } + } // end muons + if (doProtons) { + if (RecoDecay::sumOfSquares((trkDaughter1.hasTOF() ? trkDaughter1.tofNSigmaPr() : trkDaughter1.tpcNSigmaPr()), (trkDaughter2.hasTOF() ? trkDaughter2.tofNSigmaPr() : trkDaughter2.tpcNSigmaPr()) < 4)) { + + auto ene1 = RecoDecay::e(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), massPr); + auto ene2 = RecoDecay::e(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), massPr); + daughter[0].SetPxPyPzE(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz(), ene1); + daughter[1].SetPxPyPzE(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz(), ene2); + mom = daughter[0] + daughter[1]; + + std::array mother = {trkDaughter1.px() + trkDaughter2.px(), trkDaughter1.py() + trkDaughter2.py(), trkDaughter1.pz() + trkDaughter2.pz()}; + + if (tofBothProtons) { + if (!trkDaughter1.hasTOF() || !trkDaughter2.hasTOF()) + return; + } + if (tofOneProton) { + if ((trkDaughter1.hasTOF() && trkDaughter2.hasTOF()) || (!trkDaughter1.hasTOF() && !trkDaughter2.hasTOF())) + return; + } + if (tofAtLeastOneProton) { + if (!trkDaughter1.hasTOF() && !trkDaughter2.hasTOF()) + return; + } + + auto arrMom = std::array{daughter1, daughter2}; + float massJpsi = RecoDecay::m(arrMom, std::array{massPr, massPr}); + float rapJpsi = RecoDecay::y(mother, massJpsi); + + // TGdaug + fillTGdaug<2>(trkDaughter1, trkDaughter2, daughter1, daughter2); + + if (candidateCuts(massJpsi, rapJpsi) != 1) { + return; + } + + // TGdaugCand + fillCand<2>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, massJpsi, xnxn, onon, onxn, xnon); + + if (RecoDecay::pt(mother) < 0.2f) { + rJpsiToDaug.get(HIST("JPsiToDaug/Proton/Coherent/hIVM"))->Fill(massJpsi); + } else { + rJpsiToDaug.get(HIST("JPsiToDaug/Proton/Incoherent/hIVM"))->Fill(massJpsi); + } + + if (massJpsi < maxJpsiMass && massJpsi > minJpsiMass) { + rTGdaugCand.get(HIST("TGdaugCand/Proton/hJpsiPt"))->Fill(RecoDecay::pt(mother)); + rTGdaugCand.get(HIST("TGdaugCand/Proton/hJpsiRap"))->Fill(rapJpsi); + if (RecoDecay::pt(mother) < 0.2f) { + + fillPeak<2, 0, 0>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + + } // end coherent + if (RecoDecay::pt(mother) > 0.2f) { + // fill track histos + fillPeak<1, 1, 0>(trkDaughter1, trkDaughter2, daughter1, daughter2, mother, rapJpsi); + } // end incoherent + } // end mass cut + } + } // end protons + } // end two tracks + } // end reco process + + template + void processMC(C const& mcCollision, T const& mcParticles) + { + + rMC.get(HIST("MC/hNumberOfMCCollisions"))->Fill(1.); + rMC.get(HIST("MC/hPosZ"))->Fill(mcCollision.posZ()); + + std::array daughPart1Mu = {-999, -999, -999}; + std::array daughPart2Mu = {-999, -999, -999}; + std::array motherPart = {-999, -999, -999}; + float energyMother = -999; + float daughPart1pdg = -999; + float daughPart2pdg = -999; + + // fill number of particles + for (auto const& mcParticle : mcParticles) { + rMC.get(HIST("MC/Muon/hNumberOfMCTracks"))->Fill(1.); + rMC.get(HIST("MC/hPdg"))->Fill(mcParticle.pdgCode()); + if (mcParticle.has_daughters()) { + rMC.get(HIST("MC/hMothersPdg"))->Fill(mcParticle.pdgCode()); + rMC.get(HIST("MC/Muon/hNumberOfMCTracks"))->Fill(3.); + if (mcParticle.pdgCode() == 443) { + rMC.get(HIST("MC/Muon/hNumberOfMCTracks"))->Fill(4.); + int count = 0; + for (const auto& daughter : mcParticle.template daughters_as()) { + if ((daughter.pdgCode() == -13) && daughter.isPhysicalPrimary()) { + daughPart1Mu = {daughter.px(), daughter.py(), daughter.pz()}; + daughPart1pdg = daughter.pdgCode(); + + rMC.get(HIST("MC/Muon/hNumberOfMCTracks"))->Fill(5.); + count++; + } + if ((daughter.pdgCode() == 13) && daughter.isPhysicalPrimary()) { + daughPart2Mu = {daughter.px(), daughter.py(), daughter.pz()}; + daughPart2pdg = daughter.pdgCode(); + + rMC.get(HIST("MC/Muon/hNumberOfMCTracks"))->Fill(6.); + count++; + } + } + if (count == 2) { + rMC.get(HIST("MC/Muon/hNumberOfMCTracks"))->Fill(7.); + motherPart = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; + energyMother = mcParticle.e(); + } + } + } + } + + // calculate needed distributions + + rMC.get(HIST("MC/Muon/hEta1"))->Fill(RecoDecay::eta(daughPart1Mu)); + rMC.get(HIST("MC/Muon/hEta2"))->Fill(RecoDecay::eta(daughPart2Mu)); + rMC.get(HIST("MC/Muon/hEta"))->Fill(RecoDecay::eta(motherPart)); + rMC.get(HIST("MC/Muon/hPhi1"))->Fill(RecoDecay::phi(daughPart1Mu)); + rMC.get(HIST("MC/Muon/hPhi2"))->Fill(RecoDecay::phi(daughPart2Mu)); + rMC.get(HIST("MC/Muon/hPhi"))->Fill(RecoDecay::phi(motherPart)); + rMC.get(HIST("MC/Muon/hPt1"))->Fill(RecoDecay::pt(daughPart1Mu)); + rMC.get(HIST("MC/Muon/hPt2"))->Fill(RecoDecay::pt(daughPart2Mu)); + rMC.get(HIST("MC/Muon/hPt"))->Fill(RecoDecay::pt(motherPart)); + rMC.get(HIST("MC/Muon/hIVM"))->Fill(RecoDecay::m(motherPart, energyMother)); + rMC.get(HIST("MC/Muon/hRapidity"))->Fill(RecoDecay::y(motherPart, RecoDecay::m(motherPart, energyMother))); + + float massMu = o2::constants::physics::MassMuonMinus; + auto ene1 = RecoDecay::e(daughPart1Mu, massMu); + auto ene2 = RecoDecay::e(daughPart2Mu, massMu); + + TLorentzVector mom, daughter[2]; + daughter[0].SetPxPyPzE(daughPart1Mu[0], daughPart1Mu[1], daughPart1Mu[2], ene1); + daughter[1].SetPxPyPzE(daughPart2Mu[0], daughPart2Mu[1], daughPart2Mu[2], ene2); + mom = daughter[0] + daughter[1]; + + double dp = DeltaPhi(daughter[0], daughter[1]); + float* q = correlation(&daughter[0], &daughter[1], &mom); + double dpRandom = DeltaPhiRandom(daughter[0], daughter[1]); + + // fill tree with muon J/Psi candidates + treeMC(mcCollision.globalBC(), + RecoDecay::pt(motherPart), RecoDecay::eta(motherPart), RecoDecay::phi(motherPart), RecoDecay::y(motherPart, RecoDecay::m(motherPart, energyMother)), RecoDecay::m(motherPart, energyMother), dpRandom, dp, q[1], q[2], + daughPart1pdg, RecoDecay::pt(daughPart1Mu), RecoDecay::eta(daughPart1Mu), RecoDecay::phi(daughPart1Mu), + daughPart2pdg, RecoDecay::pt(daughPart2Mu), RecoDecay::eta(daughPart2Mu), RecoDecay::phi(daughPart2Mu)); + + } // end MC skimmed process + + void processMCFull(MCUDCollisionFull const& collision, MCUDTracksFull const& tracks, aod::UDMcCollisions const& mcCollision, aod::UDMcParticles const&) + { + rMC.get(HIST("MC/hNumberOfRecoCollisions"))->Fill(collision.size()); + rMC.get(HIST("MC/hNumberOfTrueCollisions"))->Fill(mcCollision.size()); + rMC.get(HIST("MC/hNumberOfMatchedMCTracks"))->Fill(1.); + if (collision.has_udMcCollision()) { + std::array recoTrack; + std::array truePart; + bool mesonFound = false; + for (const auto& track : tracks) { + rMC.get(HIST("MC/hNumberOfMatchedMCTracks"))->Fill(1.); + mesonFound = false; + if (track.has_udMcParticle()) { + rMC.get(HIST("MC/hNumberOfMatchedMCTracks"))->Fill(2.); + auto mcParticle = track.udMcParticle(); + rMC.fill(HIST("MC/hResolution"), mcParticle.px() - track.px()); + if (std::abs(mcParticle.pdgCode()) == 13 && mcParticle.isPhysicalPrimary()) { + rMC.get(HIST("MC/hNumberOfMatchedMCTracks"))->Fill(3.); + if (mcParticle.has_mothers()) { + rMC.get(HIST("MC/hNumberOfMatchedMCTracks"))->Fill(4.); + auto const& mother = mcParticle.mothers_first_as(); + if (mother.pdgCode() == 443) { + rMC.get(HIST("MC/hNumberOfMatchedMCTracks"))->Fill(5.); + recoTrack = {track.px(), track.py(), track.pz()}; + truePart = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; + mesonFound = true; + } + } + } + if (mesonFound) { + rMC.fill(HIST("MC/hResolutionPhi"), RecoDecay::phi(recoTrack) - RecoDecay::phi(truePart)); + } + } + } + } + } // end MC Full process + + void processDGrecoLevel(UDCollisionFull const& collision, UDTracksFull const& tracks) + { + fillHistograms(collision, tracks); + } // end DG process + + void processSGrecoLevel(SGUDCollisionFull const& collision, UDTracksFull const& tracks) + { + int gapSide = collision.gapSide(); + int trueGapSide = sgSelector.trueGap(collision, cutMyGapSideFV0, cutMyGapSideFT0A, cutMyGapSideFT0C, cutMyGapSideZDC); + if (useTrueGap) { + gapSide = trueGapSide; + } + if (gapSide != whichGapSide) { + return; + } + fillHistograms(collision, tracks); + + } // end SG process + + void processMCtruth(aod::UDMcCollision const& mcCollision, aod::UDMcParticles const& mcParticles) + { + processMC(mcCollision, mcParticles); + } + + PROCESS_SWITCH(UpcJpsiCorr, processDGrecoLevel, "Iterate over DG skimmed data.", false); + PROCESS_SWITCH(UpcJpsiCorr, processSGrecoLevel, "Iterate over SG skimmed data.", true); + PROCESS_SWITCH(UpcJpsiCorr, processMCtruth, "Iterate of MC true data.", true); + PROCESS_SWITCH(UpcJpsiCorr, processMCFull, "Iterate over both true and reco.", true); +}; // end struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGUD/Tasks/upcPhotonuclearAnalysisJMG.cxx b/PWGUD/Tasks/upcPhotonuclearAnalysisJMG.cxx index 81834492eca..d20a78429dd 100644 --- a/PWGUD/Tasks/upcPhotonuclearAnalysisJMG.cxx +++ b/PWGUD/Tasks/upcPhotonuclearAnalysisJMG.cxx @@ -11,10 +11,17 @@ /// /// \brief /// \author Josué Martínez García, josuem@cern.ch +/// \file upcPhotonuclearAnalysisJMG.cxx + +#include #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" +#include "CCDB/BasicCCDBManager.h" +#include "Framework/StepTHn.h" +#include "CommonConstants/MathConstants.h" +#include #include "Common/CCDB/EventSelectionParams.h" #include "Common/Core/TrackSelection.h" @@ -22,38 +29,92 @@ #include "Common/Core/trackUtilities.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "PWGCF/Core/CorrelationContainer.h" +#include "DataFormatsParameters/GRPObject.h" #include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/Core/UPCPairCuts.h" #include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace constants::math; +namespace o2::aod +{ +namespace tree +{ +DECLARE_SOA_COLUMN(PtSideA, ptSideA, std::vector); +DECLARE_SOA_COLUMN(RapSideA, rapSideA, std::vector); +DECLARE_SOA_COLUMN(PhiSideA, phiSideA, std::vector); +DECLARE_SOA_COLUMN(TPCSignalSideA, tpcSignalSideA, std::vector); +DECLARE_SOA_COLUMN(TOFSignalSideA, tofSignalSideA, std::vector); +DECLARE_SOA_COLUMN(TPCNSigmaPiSideA, tpcNSigmaPiSideA, std::vector); +DECLARE_SOA_COLUMN(TOFNSigmaPiSideA, tofNSigmaPiSideA, std::vector); +DECLARE_SOA_COLUMN(TPCNSigmaKaSideA, tpcNSigmaKaSideA, std::vector); +DECLARE_SOA_COLUMN(TOFNSigmaKaSideA, tofNSigmaKaSideA, std::vector); +DECLARE_SOA_COLUMN(PtSideC, ptSideC, std::vector); +DECLARE_SOA_COLUMN(RapSideC, rapSideC, std::vector); +DECLARE_SOA_COLUMN(PhiSideC, phiSideC, std::vector); +DECLARE_SOA_COLUMN(TPCSignalSideC, tpcSignalSideC, std::vector); +DECLARE_SOA_COLUMN(TOFSignalSideC, tofSignalSideC, std::vector); +DECLARE_SOA_COLUMN(TPCNSigmaPiSideC, tpcNSigmaPiSideC, std::vector); +DECLARE_SOA_COLUMN(TOFNSigmaPiSideC, tofNSigmaPiSideC, std::vector); +DECLARE_SOA_COLUMN(TPCNSigmaKaSideC, tpcNSigmaKaSideC, std::vector); +DECLARE_SOA_COLUMN(TOFNSigmaKaSideC, tofNSigmaKaSideC, std::vector); +DECLARE_SOA_COLUMN(NchSideA, nchSideA, int); +DECLARE_SOA_COLUMN(MultiplicitySideA, multiplicitySideA, int); +DECLARE_SOA_COLUMN(NchSideC, nchSideC, int); +DECLARE_SOA_COLUMN(MultiplicitySideC, multiplicitySideC, int); +} // namespace tree +DECLARE_SOA_TABLE(TREE, "AOD", "Tree", + tree::PtSideA, + tree::RapSideA, + tree::PhiSideA, + tree::TPCSignalSideA, + tree::TOFSignalSideA, + tree::TPCNSigmaPiSideA, + tree::TOFNSigmaPiSideA, + tree::TPCNSigmaKaSideA, + tree::TOFNSigmaKaSideA, + tree::PtSideC, + tree::RapSideC, + tree::PhiSideC, + tree::TPCSignalSideC, + tree::TOFSignalSideC, + tree::TPCNSigmaPiSideC, + tree::TOFNSigmaPiSideC, + tree::TPCNSigmaKaSideC, + tree::TOFNSigmaKaSideC, + tree::NchSideA, + tree::MultiplicitySideA, + tree::NchSideC, + tree::MultiplicitySideC); +} // namespace o2::aod + +static constexpr float CFGPairCutDefaults[1][5] = {{-1, -1, -1, -1, -1}}; struct upcPhotonuclearAnalysisJMG { + Produces tree; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; // Declare configurables on events/collisions - Configurable cutMyPosZMin{"cutMyPosZMin", -10., {"My collision cut"}}; - Configurable cutMyPosZMax{"cutMyPosZMax", 10., {"My collision cut"}}; - Configurable cutMyTimeZNA{"cutMyTimeZNA", 2., {"My collision cut"}}; - Configurable cutMyTimeZNC{"cutMyTimeZNC", 2., {"My collision cut"}}; + Configurable nEventsMixed{"nEventsMixed", 3, {"Events to be Mixed"}}; + Configurable factorEventsMixed{"factorEventsMixed", 100, {"factorEventsMixed to events mixed"}}; + Configurable myZVtxCut{"myZVtxCut", 10., {"My collision cut"}}; + Configurable myTimeZNACut{"myTimeZNACut", 2., {"My collision cut"}}; + Configurable myTimeZNCCut{"myTimeZNCCut", 2., {"My collision cut"}}; // Declare configurables on side A gap Configurable cutAGapMyEnergyZNAMax{"cutAGapMyEnergyZNAMax", 0., {"My collision cut. A Gap"}}; - Configurable cutAGapMyAmplitudeFT0AMax{"cutAGapMyAmplitudeFT0AMax", 200., {"My collision cut. A Gap"}}; + // Configurable cutAGapMyAmplitudeFT0AMax{"cutAGapMyAmplitudeFT0AMax", 200., {"My collision cut. A Gap"}}; Configurable cutAGapMyEnergyZNCMin{"cutAGapMyEnergyZNCMin", 1., {"My collision cut. A Gap"}}; - Configurable cutAGapMyAmplitudeFT0CMin{"cutAGapMyAmplitudeFT0CMin", 0., {"My collision cut. A Gap"}}; + // Configurable cutAGapMyAmplitudeFT0CMin{"cutAGapMyAmplitudeFT0CMin", 0., {"My collision cut. A Gap"}}; // Declare configurables on side C gap Configurable cutCGapMyEnergyZNAMin{"cutCGapMyEnergyZNAMin", 1., {"My collision cut. C Gap"}}; - Configurable cutCGapMyAmplitudeFT0AMin{"cutCGapMyAmplitudeFT0AMin", 0., {"My collision cut. A Gap"}}; + // Configurable cutCGapMyAmplitudeFT0AMin{"cutCGapMyAmplitudeFT0AMin", 0., {"My collision cut. A Gap"}}; Configurable cutCGapMyEnergyZNCMax{"cutCGapMyEnergyZNCMax", 0., {"My collision cut. C Gap"}}; - Configurable cutCGapMyAmplitudeFT0CMax{"cutCGapMyAmplitudeFT0CMax", 200., {"My collision cut. A Gap"}}; - // Declare configurables on both side gap - Configurable cutBothGapMyEnergyZNAMax{"cutBothGapMyEnergyZNAMax", 0., {"My collision cut. Both Gap"}}; - Configurable cutBothGapMyAmplitudeFT0AMax{"cutBothGapMyAmplitudeFT0AMax", 200., {"My collision cut. A Gap"}}; - Configurable cutBothGapMyEnergyZNCMax{"cutBothGapMyEnergyZNCMax", 0., {"My collision cut. Both Gap"}}; - Configurable cutBothGapMyAmplitudeFT0CMax{"cutBothGapMyAmplitudeFT0CMax", 200., {"My collision cut. A Gap"}}; + // Configurable cutCGapMyAmplitudeFT0CMax{"cutCGapMyAmplitudeFT0CMax", 200., {"My collision cut. A Gap"}}; // Declare configurables on tracks Configurable cutMyptMin{"cutMyptMin", 0.15, {"My Track cut"}}; Configurable cutMyptMax{"cutMyptMax", 10., {"My Track cut"}}; @@ -72,9 +133,36 @@ struct upcPhotonuclearAnalysisJMG { Configurable cutMyTPCNClsCrossedRowsOverNClsFindableMin{"cutMyTPCNClsCrossedRowsOverNClsFindableMin", 0.8f, {"My Track cut"}}; Configurable cutMyTPCNClsOverFindableNClsMin{"cutMyTPCNClsOverFindableNClsMin", 0.5f, {"My Track cut"}}; Configurable cutMyTPCChi2NclMax{"cutMyTPCChi2NclMax", 4.f, {"My Track cut"}}; + Configurable> cfgPairCut{"cfgPairCut", + {CFGPairCutDefaults[0], + 5, + {"Photon", "K0", "Lambda", "Phi", "Rho"}}, + "Pair cuts on various particles"}; + Configurable cfgTwoTrackCut{"cfgTwoTrackCut", -1, {"Two track cut"}}; + ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for histograms"}; + ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -constants::math::PIHalf, constants::math::PIHalf * 3}, "delta phi axis for histograms"}; + ConfigurableAxis axisDeltaEta{"axisDeltaEta", {40, -2, 2}, "delta eta axis for histograms"}; + ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0}, "pt trigger axis for histograms"}; + ConfigurableAxis axisPtAssoc{"axisPtAssoc", {VARIABLE_WIDTH, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0}, "pt associated axis for histograms"}; + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110.1}, "multiplicity / multiplicity axis for histograms"}; + ConfigurableAxis axisVertexEfficiency{"axisVertexEfficiency", {10, -10, 10}, "vertex axis for efficiency histograms"}; + ConfigurableAxis axisEtaEfficiency{"axisEtaEfficiency", {20, -1.0, 1.0}, "eta axis for efficiency histograms"}; + ConfigurableAxis axisPtEfficiency{"axisPtEfficiency", {VARIABLE_WIDTH, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0}, "pt axis for efficiency histograms"}; + + Filter collisionZVtxFilter = nabs(aod::collision::posZ) < myZVtxCut; + Filter collisionZNTimeFilter = nabs(aod::udzdc::timeZNA) < myTimeZNACut && nabs(aod::udzdc::timeZNC) < myTimeZNCCut; + + using FullSGUDCollision = soa::Filtered>; + using FullUDTracks = soa::Join; + + // Output definitions + OutputObj sameGapSideA{"sameEventGapSideA"}; + OutputObj mixedGapSideA{"mixedEventGapSideA"}; + OutputObj sameGapSideC{"sameEventGapSideC"}; + OutputObj mixedGapSideC{"mixedEventGapSideC"}; - using FullSGUDCollision = soa::Join::iterator; - using FullUDTracks = soa::Join; + UPCPairCuts mPairCuts; + bool doPairCuts = false; void init(InitContext const&) { @@ -83,9 +171,9 @@ struct upcPhotonuclearAnalysisJMG { const AxisSpec axisPt{402, -0.05, 20.05}; const AxisSpec axisP{402, -10.05, 10.05}; const AxisSpec axisTPCSignal{802, -0.05, 400.05}; - const AxisSpec axisPhi{64, -2 * o2::constants::math::PI, 2 * o2::constants::math::PI}; + const AxisSpec axisPhi{64, -2 * PI, 2 * PI}; const AxisSpec axisEta{50, -1.2, 1.2}; - const AxisSpec axisNch{101, -0.5, 100.5}; + const AxisSpec axisNch{201, -0.5, 200.5}; const AxisSpec axisZNEnergy{1002, -0.5, 500.5}; const AxisSpec axisZNTime{21, -10.5, 10.5}; const AxisSpec axisFT0Amplitud{201, -0.5, 200.5}; @@ -93,6 +181,21 @@ struct upcPhotonuclearAnalysisJMG { const AxisSpec axisChi2NCls{100, 0, 50}; const AxisSpec axisTPCNClsCrossedRowsMin{100, -0.05, 2.05}; + histos.add("yields", "multiplicity vs pT vs eta", {HistType::kTH3F, {{100, 0, 100, "multiplicity"}, {40, 0, 20, "p_{T}"}, {100, -2, 2, "#eta"}}}); + histos.add("etaphi", "multiplicity vs eta vs phi", {HistType::kTH3F, {{100, 0, 100, "multiplicity"}, {100, -2, 2, "#eta"}, {200, 0, 2 * PI, "#varphi"}}}); + + const int maxMixBin = axisMultiplicity->size() * axisVertex->size(); + histos.add("eventcount", "bin", {HistType::kTH1F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}}}); + mPairCuts.setHistogramRegistry(&histos); + if (cfgPairCut->get("Photon") > 0 || cfgPairCut->get("K0") > 0 || cfgPairCut->get("Lambda") > 0 || + cfgPairCut->get("Phi") > 0 || cfgPairCut->get("Rho") > 0) { + mPairCuts.setPairCut(UPCPairCuts::Photon, cfgPairCut->get("Photon")); + mPairCuts.setPairCut(UPCPairCuts::K0, cfgPairCut->get("K0")); + mPairCuts.setPairCut(UPCPairCuts::Lambda, cfgPairCut->get("Lambda")); + mPairCuts.setPairCut(UPCPairCuts::Phi, cfgPairCut->get("Phi")); + mPairCuts.setPairCut(UPCPairCuts::Rho, cfgPairCut->get("Rho")); + doPairCuts = true; + } histos.add("Events/hCountCollisions", "0 total - 1 side A - 2 side C - 3 both side; Number of analysed collision; counts", kTH1F, {axisCollision}); // histos to selection gap in side A @@ -100,6 +203,7 @@ struct upcPhotonuclearAnalysisJMG { histos.add("Tracks/SGsideA/hTrackPhi", "#it{#phi} distribution; #it{#phi}; counts", kTH1F, {axisPhi}); histos.add("Tracks/SGsideA/hTrackEta", "#it{#eta} distribution; #it{#eta}; counts", kTH1F, {axisEta}); histos.add("Tracks/SGsideA/hTrackTPCSignnalP", "#it{TPC dE/dx vs p}; #it{p*charge}; #it{TPC dE/dx}", kTH2F, {axisP, axisTPCSignal}); + histos.add("Tracks/SGsideA/hTrackTOFSignnalP", "#it{TOF signal vs p}; #it{p*charge}; #it{TOF signal}", kTH2F, {axisP, axisTPCSignal}); histos.add("Tracks/SGsideA/hTrackITSNCls", "#it{N Clusters ITS} distribution; #it{N Clusters ITS}; counts", kTH1F, {axisNCls}); histos.add("Tracks/SGsideA/hTrackITSChi2NCls", "#it{N Clusters Chi2 ITS} distribution; #it{N Clusters Chi2 ITS}; counts", kTH1F, {axisChi2NCls}); histos.add("Tracks/SGsideA/hTrackNClsCrossedRowsOverNClsFindable", "#it{NClsCrossedRows/FindableNCls} distribution in TPC; #it{NClsCrossedRows/FindableNCls}; counts", kTH1F, {axisTPCNClsCrossedRowsMin}); @@ -112,8 +216,9 @@ struct upcPhotonuclearAnalysisJMG { histos.add("Tracks/SGsideA/hTrackTPCChi2NCls", "#it{N Clusters Chi2 TPC} distribution; #it{N Clusters Chi2 TPC}; counts", kTH1F, {axisChi2NCls}); histos.add("Tracks/SGsideA/hTrackITSNClsTPCCls", "#it{ITS Clusters vs TPC Clusters}; #it{TPC Clusters}; #it{ITS Clusters}", kTH2F, {axisNCls, axisNCls}); - histos.add("Events/SGsideA/hTrackZVtx", "vertex in z; z (cm); counts", kTH1F, {axisZvtx}); + histos.add("Events/SGsideA/hZVtx", "vertex in z; z (cm); counts", kTH1F, {axisZvtx}); histos.add("Events/SGsideA/hNch", "#it{Charged Tracks Multiplicity} distribution; #it{Charged Tracks Multiplicity}; counts", kTH1F, {axisNch}); + histos.add("Events/SGsideA/hMultiplicity", "#it{Multiplicity} distribution; #it{Multiplicity}; counts", kTH1F, {axisNch}); histos.add("Events/SGsideA/hPtVSNch", "#it{ #LT p_{T} #GT } vs #it{Charged Tracks Multiplicity}; #it{Charged Tracks Multiplicity}; #it{ #LT p_{T} #GT }", kTH2F, {axisNch, axisPt}); histos.add("Events/SGsideA/hEnergyZNA", "Energy in side A distribution; Energy in side A; counts", kTH1F, {axisZNEnergy}); histos.add("Events/SGsideA/hEnergyZNC", "Energy in side C distribution; Energy in side C; counts", kTH1F, {axisZNEnergy}); @@ -129,6 +234,7 @@ struct upcPhotonuclearAnalysisJMG { histos.add("Tracks/SGsideC/hTrackPhi", "#it{#phi} distribution; #it{#phi}; counts", kTH1F, {axisPhi}); histos.add("Tracks/SGsideC/hTrackEta", "#it{#eta} distribution; #it{#eta}; counts", kTH1F, {axisEta}); histos.add("Tracks/SGsideC/hTrackTPCSignnalP", "#it{TPC dE/dx vs p}; #it{p*charge}; #it{TPC dE/dx}", kTH2F, {axisP, axisTPCSignal}); + histos.add("Tracks/SGsideC/hTrackTOFSignnalP", "#it{TOF signal vs p}; #it{p*charge}; #it{TOF signal}", kTH2F, {axisP, axisTPCSignal}); histos.add("Tracks/SGsideC/hTrackITSNCls", "#it{N Clusters ITS} distribution; #it{N Clusters ITS}; counts", kTH1F, {axisNCls}); histos.add("Tracks/SGsideC/hTrackITSChi2NCls", "#it{N Clusters Chi2 ITS} distribution; #it{N Clusters Chi2 ITS}; counts", kTH1F, {axisChi2NCls}); histos.add("Tracks/SGsideC/hTrackNClsCrossedRowsOverNClsFindable", "#it{NClsCrossedRows/FindableNCls} distribution in TPC; #it{NClsCrossedRows/FindableNCls}; counts", kTH1F, {axisTPCNClsCrossedRowsMin}); @@ -141,8 +247,9 @@ struct upcPhotonuclearAnalysisJMG { histos.add("Tracks/SGsideC/hTrackTPCChi2NCls", "#it{N Clusters Chi2 TPC} distribution; #it{N Clusters Chi2 TPC}; counts", kTH1F, {axisChi2NCls}); histos.add("Tracks/SGsideC/hTrackITSNClsTPCCls", "#it{ITS Clusters vs TPC Clusters}; #it{TPC Clusters}; #it{ITS Clusters}", kTH2F, {axisNCls, axisNCls}); - histos.add("Events/SGsideC/hTrackZVtx", "vertex in z; z (cm); counts", kTH1F, {axisZvtx}); + histos.add("Events/SGsideC/hZVtx", "vertex in z; z (cm); counts", kTH1F, {axisZvtx}); histos.add("Events/SGsideC/hNch", "#it{Charged Tracks Multiplicity} distribution; #it{Charged Tracks Multiplicity}; counts", kTH1F, {axisNch}); + histos.add("Events/SGsideC/hMultiplicity", "#it{Multiplicity} distribution; #it{Multiplicity}; counts", kTH1F, {axisNch}); histos.add("Events/SGsideC/hPtVSNch", "#it{ #LT p_{T} #GT } vs #it{Charged Tracks Multiplicity}; #it{Charged Tracks Multiplicity}; #it{ #LT p_{T} #GT }", kTH2F, {axisNch, axisPt}); histos.add("Events/SGsideC/hEnergyZNA", "Energy in side A distribution; Energy in side A; counts", kTH1F, {axisZNEnergy}); histos.add("Events/SGsideC/hEnergyZNC", "Energy in side C distribution; Energy in side C; counts", kTH1F, {axisZNEnergy}); @@ -153,43 +260,34 @@ struct upcPhotonuclearAnalysisJMG { histos.add("Events/SGsideC/hAmplitudFT0A", "Amplitud in side A distribution; Amplitud in side A; counts", kTH1F, {axisFT0Amplitud}); histos.add("Events/SGsideC/hAmplitudFT0C", "Amplitud in side C distribution; Amplitud in side C; counts", kTH1F, {axisFT0Amplitud}); - // histos to selection gap in both sides - histos.add("Tracks/SGsideBoth/hTrackPt", "#it{p_{T}} distribution; #it{p_{T}}; counts", kTH1F, {axisPt}); - histos.add("Tracks/SGsideBoth/hTrackPhi", "#it{#phi} distribution; #it{#phi}; counts", kTH1F, {axisPhi}); - histos.add("Tracks/SGsideBoth/hTrackEta", "#it{#eta} distribution; #it{#eta}; counts", kTH1F, {axisEta}); - histos.add("Tracks/SGsideBoth/hTrackTPCSignnalP", "#it{TPC dE/dx vs p}; #it{p*charge}; #it{TPC dE/dx}", kTH2F, {axisP, axisTPCSignal}); - histos.add("Tracks/SGsideBoth/hTrackITSNCls", "#it{N Clusters ITS} distribution; #it{N Clusters ITS}; counts", kTH1F, {axisNCls}); - histos.add("Tracks/SGsideBoth/hTrackITSChi2NCls", "#it{N Clusters Chi2 ITS} distribution; #it{N Clusters Chi2 ITS}; counts", kTH1F, {axisChi2NCls}); - histos.add("Tracks/SGsideBoth/hTrackNClsCrossedRowsOverNCls", "#it{NClsCrossedRows/FindableNCls} distribution in TPC; #it{NClsCrossedRows/FindableNCls}; counts", kTH1F, {axisTPCNClsCrossedRowsMin}); - histos.add("Tracks/SGsideBoth/hTrackTPCNClsCrossedRows", "#it{Number of crossed TPC Rows} distribution; #it{Number of crossed TPC Rows}; counts", kTH1F, {axisNCls}); - histos.add("Tracks/SGsideBoth/hTrackTPCNClsFindable", "#it{Findable TPC clusters for this track} distribution; #it{Findable TPC clusters for this track}; counts", kTH1F, {axisNCls}); - histos.add("Tracks/SGsideBoth/hTrackTPCChi2NCls", "#it{N Clusters Chi2 TPC} distribution; #it{N Clusters Chi2 TPC}; counts", kTH1F, {axisChi2NCls}); - histos.add("Tracks/SGsideBoth/hTrackITSNClsTPCCls", "#it{ITS Clusters vs TPC Clusters}; #it{TPC Clusters}; #it{ITS Clusters}", kTH2F, {axisNCls, axisNCls}); - - histos.add("Events/SGsideBoth/hTrackZVtx", "vertex in z; z (cm); counts", kTH1F, {axisZvtx}); - histos.add("Events/SGsideBoth/hNch", "#it{Charged Tracks Multiplicity} distribution; #it{Charged Tracks Multiplicity}; counts", kTH1F, {axisNch}); - histos.add("Events/SGsideBoth/hPtVSNch", "#it{ #LT p_{T} #GT } vs #it{Charged Tracks Multiplicity}; #it{Charged Tracks Multiplicity}; #it{ #LT p_{T} #GT }", kTH2F, {axisNch, axisPt}); - histos.add("Events/SGsideBoth/hEnergyZNA", "Energy in side A distribution; Energy in side A; counts", kTH1F, {axisZNEnergy}); - histos.add("Events/SGsideBoth/hEnergyZNC", "Energy in side C distribution; Energy in side C; counts", kTH1F, {axisZNEnergy}); - histos.add("Events/SGsideBoth/hEnergyRelationSides", "Energy in side A vs energy in side C; Energy in side A; Energy in side C", kTH2F, {axisZNEnergy, axisZNEnergy}); - histos.add("Events/SGsideBoth/hTimeZNA", "Time in side A distribution; Time in side A; counts", kTH1F, {axisZNTime}); - histos.add("Events/SGsideBoth/hTimeZNC", "Time in side C distribution; Time in side C; counts", kTH1F, {axisZNTime}); - histos.add("Events/SGsideBoth/hTimeRelationSides", "Time in side A vs time in side C; Time in side A; Time in side C", kTH2F, {axisZNTime, axisZNTime}); - histos.add("Events/SGsideBoth/hAmplitudFT0A", "Amplitud in side A distribution; Amplitud in side A; counts", kTH1F, {axisFT0Amplitud}); - histos.add("Events/SGsideBoth/hAmplitudFT0C", "Amplitud in side C distribution; Amplitud in side C; counts", kTH1F, {axisFT0Amplitud}); + std::vector corrAxis = {{axisDeltaEta, "#Delta#eta"}, + {axisPtAssoc, "p_{T} (GeV/c)"}, + {axisPtTrigger, "p_{T} (GeV/c)"}, + {axisMultiplicity, "multiplicity / multiplicity"}, + {axisDeltaPhi, "#Delta#varphi (rad)"}, + {axisVertex, "z-vtx (cm)"}}; + std::vector effAxis = {{axisEtaEfficiency, "#eta"}, + {axisEtaEfficiency, "#eta"}, + {axisPtEfficiency, "p_{T} (GeV/c)"}, + {axisVertexEfficiency, "z-vtx (cm)"}}; + sameGapSideA.setObject(new CorrelationContainer("sameEventGapSideA", "sameEventGapSideA", corrAxis, effAxis, {})); + mixedGapSideA.setObject(new CorrelationContainer("mixedEventGapSideA", "mixedEventGapSideA", corrAxis, effAxis, {})); + sameGapSideC.setObject(new CorrelationContainer("sameEventGapSideC", "sameEventGapSideC", corrAxis, effAxis, {})); + mixedGapSideC.setObject(new CorrelationContainer("mixedEventGapSideC", "mixedEventGapSideC", corrAxis, effAxis, {})); } - template - bool isGlobalCollisionCut(C const& collision) - { - if (collision.posZ() < cutMyPosZMin || cutMyPosZMax < collision.posZ()) { - return false; - } - if ((std::abs(collision.timeZNA()) < cutMyTimeZNA && std::abs(collision.timeZNC()) < cutMyTimeZNC) == false) { - return false; - } - return true; - } + std::vector vtxBinsEdges{VARIABLE_WIDTH, -10.0f, -7.0f, -5.0f, -2.5f, 0.0f, 2.5f, 5.0f, 7.0f, 10.0f}; + std::vector gapSideBinsEdges{VARIABLE_WIDTH, -0.5, 0.5, 1.5}; + + SliceCache cache; + int countGapA = 0; + int countGapC = 0; + + // Binning only on PosZ without multiplicity + // using BinningType = ColumnBinningPolicy; + using BinningType = ColumnBinningPolicy; + BinningType bindingOnVtx{{vtxBinsEdges, gapSideBinsEdges}, true}; + SameKindPair pairs{bindingOnVtx, nEventsMixed, -1, &cache}; template bool isCollisionCutSG(CSG const& collision, int SideGap) @@ -199,25 +297,17 @@ struct upcPhotonuclearAnalysisJMG { if ((collision.energyCommonZNA() < cutAGapMyEnergyZNAMax && collision.energyCommonZNC() >= cutAGapMyEnergyZNCMin) == false) { // 0n - A side && Xn - C Side return false; } - if ((collision.totalFT0AmplitudeA() < cutAGapMyAmplitudeFT0AMax && collision.totalFT0AmplitudeC() >= cutAGapMyAmplitudeFT0CMin) == false) { - return false; - } + // if ((collision.totalFT0AmplitudeA() < cutAGapMyAmplitudeFT0AMax && collision.totalFT0AmplitudeC() >= cutAGapMyAmplitudeFT0CMin) == false) { + // return false; + // } break; case 1: // Gap in C side if ((collision.energyCommonZNA() >= cutCGapMyEnergyZNAMin && collision.energyCommonZNC() < cutCGapMyEnergyZNCMax) == false) { // Xn - A side && 0n - C Side return false; } - if ((collision.totalFT0AmplitudeA() >= cutCGapMyAmplitudeFT0AMin && collision.totalFT0AmplitudeC() < cutCGapMyAmplitudeFT0CMax) == false) { - return false; - } - break; - case 2: // Gap in Both Sides - if ((collision.energyCommonZNA() < cutBothGapMyEnergyZNAMax && collision.energyCommonZNC() < cutBothGapMyEnergyZNCMax) == false) { // 0n - A side && 0n - C Side - return false; - } - if ((collision.totalFT0AmplitudeA() < cutBothGapMyAmplitudeFT0AMax && collision.totalFT0AmplitudeC() < cutBothGapMyAmplitudeFT0CMax) == false) { - return false; - } + // if ((collision.totalFT0AmplitudeA() >= cutCGapMyAmplitudeFT0AMin && collision.totalFT0AmplitudeC() < cutCGapMyAmplitudeFT0CMax) == false) { + // return false; + // } break; } return true; @@ -281,19 +371,68 @@ struct upcPhotonuclearAnalysisJMG { return true; } - void processSG(FullSGUDCollision const& reconstructedCollision, FullUDTracks const& reconstructedTracks) + template + void fillQAUD(const TTracks tracks) + { + for (const auto& track : tracks) { + histos.fill(HIST("yields"), tracks.size(), track.pt(), eta(track.px(), track.py(), track.pz())); + histos.fill(HIST("etaphi"), tracks.size(), eta(track.px(), track.py(), track.pz()), phi(track.px(), track.py())); + } + } + + template + bool fillCollisionUD(TTarget target, float multiplicity) + { + target->fillEvent(multiplicity, CorrelationContainer::kCFStepAll); + target->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + return true; + } + + template + void fillCorrelationsUD(TTarget target, const TTracks tracks1, const TTracks tracks2, float multiplicity, float posZ) + { + multiplicity = tracks1.size(); + for (const auto& track1 : tracks1) { + if (isTrackCut(track1) == false) { + continue; + } + target->getTriggerHist()->Fill(CorrelationContainer::kCFStepReconstructed, track1.pt(), multiplicity, posZ, 1.0); + for (const auto& track2 : tracks2) { + if (track1 == track2) { + continue; + } + if (isTrackCut(track2) == false) { + continue; + } + if (doPairCuts && mPairCuts.conversionCuts(track1, track2)) { + continue; + } + float deltaPhi = phi(track1.px(), track1.py()) - phi(track2.px(), track2.py()); + if (deltaPhi > 1.5f * PI) { + deltaPhi -= TwoPI; + } + if (deltaPhi < -PIHalf) { + deltaPhi += TwoPI; + } + target->getPairHist()->Fill(CorrelationContainer::kCFStepReconstructed, eta(track1.px(), track1.py(), track1.pz()) - eta(track2.px(), track2.py(), track2.pz()), track2.pt(), track1.pt(), multiplicity, deltaPhi, posZ, 1.0); + } + } + } + + void processSG(FullSGUDCollision::iterator const& reconstructedCollision, FullUDTracks const& reconstructedTracks) { histos.fill(HIST("Events/hCountCollisions"), 0); - int SGside = reconstructedCollision.gapSide(); + int sgSide = reconstructedCollision.gapSide(); int nTracksCharged = 0; float sumPt = 0; + std::vector vTrackPtSideA, vTrackEtaSideA, vTrackPhiSideA, vTrackTPCSignalSideA, vTrackTOFSignalSideA, vTrackTPCNSigmaPiSideA, vTrackTOFNSigmaPiSideA, vTrackTPCNSigmaKaSideA, vTrackTOFNSigmaKaSideA; + std::vector vTrackPtSideC, vTrackEtaSideC, vTrackPhiSideC, vTrackTPCSignalSideC, vTrackTOFSignalSideC, vTrackTPCNSigmaPiSideC, vTrackTOFNSigmaPiSideC, vTrackTPCNSigmaKaSideC, vTrackTOFNSigmaKaSideC; - if (isGlobalCollisionCut(reconstructedCollision) == false) { - return; - } + int nTracksChargedSideA(-222), nTracksChargedSideC(-222); + int multiplicitySideA(-222), multiplicitySideC(-222); - switch (SGside) { - case 0: // for side A + switch (sgSide) { + case 0: // gap for side A if (isCollisionCutSG(reconstructedCollision, 0) == false) { return; } @@ -304,10 +443,10 @@ struct upcPhotonuclearAnalysisJMG { histos.fill(HIST("Events/SGsideA/hTimeZNA"), reconstructedCollision.timeZNA()); histos.fill(HIST("Events/SGsideA/hTimeZNC"), reconstructedCollision.timeZNC()); histos.fill(HIST("Events/SGsideA/hTimeRelationSides"), reconstructedCollision.timeZNA(), reconstructedCollision.timeZNC()); - histos.fill(HIST("Events/SGsideA/hTrackZVtx"), reconstructedCollision.posZ()); + histos.fill(HIST("Events/SGsideA/hZVtx"), reconstructedCollision.posZ()); histos.fill(HIST("Events/SGsideA/hAmplitudFT0A"), reconstructedCollision.totalFT0AmplitudeA()); histos.fill(HIST("Events/SGsideA/hAmplitudFT0C"), reconstructedCollision.totalFT0AmplitudeC()); - for (auto& track : reconstructedTracks) { + for (const auto& track : reconstructedTracks) { if (track.sign() == 1 || track.sign() == -1) { if (isTrackCut(track) == false) { continue; @@ -318,6 +457,16 @@ struct upcPhotonuclearAnalysisJMG { histos.fill(HIST("Tracks/SGsideA/hTrackPhi"), phi(track.px(), track.py())); histos.fill(HIST("Tracks/SGsideA/hTrackEta"), eta(track.px(), track.py(), track.pz())); histos.fill(HIST("Tracks/SGsideA/hTrackTPCSignnalP"), momentum(track.px(), track.py(), track.pz()) * track.sign(), track.tpcSignal()); + histos.fill(HIST("Tracks/SGsideA/hTrackTOFSignnalP"), momentum(track.px(), track.py(), track.pz()) * track.sign(), track.tofSignal()); + vTrackPtSideA.push_back(track.pt()); + vTrackEtaSideA.push_back(eta(track.px(), track.py(), track.pz())); + vTrackPhiSideA.push_back(phi(track.px(), track.py())); + vTrackTPCSignalSideA.push_back(track.tpcSignal()); + vTrackTOFSignalSideA.push_back(track.tofSignal()); + vTrackTPCNSigmaPiSideA.push_back(track.tpcNSigmaPi()); + vTrackTOFNSigmaPiSideA.push_back(track.tofNSigmaPi()); + vTrackTPCNSigmaKaSideA.push_back(track.tpcNSigmaKa()); + vTrackTOFNSigmaKaSideA.push_back(track.tofNSigmaKa()); histos.fill(HIST("Tracks/SGsideA/hTrackITSNCls"), track.itsNCls()); histos.fill(HIST("Tracks/SGsideA/hTrackITSChi2NCls"), track.itsChi2NCl()); @@ -333,10 +482,13 @@ struct upcPhotonuclearAnalysisJMG { } } histos.fill(HIST("Events/SGsideA/hNch"), nTracksCharged); + histos.fill(HIST("Events/SGsideA/hMultiplicity"), reconstructedTracks.size()); histos.fill(HIST("Events/SGsideA/hPtVSNch"), nTracksCharged, (sumPt / nTracksCharged)); + nTracksChargedSideA = nTracksCharged; + multiplicitySideA = reconstructedTracks.size(); nTracksCharged = sumPt = 0; break; - case 1: // for side C + case 1: // gap for side C if (isCollisionCutSG(reconstructedCollision, 1) == false) { return; } @@ -347,10 +499,10 @@ struct upcPhotonuclearAnalysisJMG { histos.fill(HIST("Events/SGsideC/hTimeZNA"), reconstructedCollision.timeZNA()); histos.fill(HIST("Events/SGsideC/hTimeZNC"), reconstructedCollision.timeZNC()); histos.fill(HIST("Events/SGsideC/hTimeRelationSides"), reconstructedCollision.timeZNA(), reconstructedCollision.timeZNC()); - histos.fill(HIST("Events/SGsideC/hTrackZVtx"), reconstructedCollision.posZ()); + histos.fill(HIST("Events/SGsideC/hZVtx"), reconstructedCollision.posZ()); histos.fill(HIST("Events/SGsideC/hAmplitudFT0A"), reconstructedCollision.totalFT0AmplitudeA()); histos.fill(HIST("Events/SGsideC/hAmplitudFT0C"), reconstructedCollision.totalFT0AmplitudeC()); - for (auto& track : reconstructedTracks) { + for (const auto& track : reconstructedTracks) { if (track.sign() == 1 || track.sign() == -1) { if (isTrackCut(track) == false) { continue; @@ -361,6 +513,16 @@ struct upcPhotonuclearAnalysisJMG { histos.fill(HIST("Tracks/SGsideC/hTrackPhi"), phi(track.px(), track.py())); histos.fill(HIST("Tracks/SGsideC/hTrackEta"), eta(track.px(), track.py(), track.pz())); histos.fill(HIST("Tracks/SGsideC/hTrackTPCSignnalP"), momentum(track.px(), track.py(), track.pz()) * track.sign(), track.tpcSignal()); + histos.fill(HIST("Tracks/SGsideC/hTrackTOFSignnalP"), momentum(track.px(), track.py(), track.pz()) * track.sign(), track.tofSignal()); + vTrackPtSideC.push_back(track.pt()); + vTrackEtaSideC.push_back(eta(track.px(), track.py(), track.pz())); + vTrackPhiSideC.push_back(phi(track.px(), track.py())); + vTrackTPCSignalSideC.push_back(track.tpcSignal()); + vTrackTOFSignalSideC.push_back(track.tofSignal()); + vTrackTPCNSigmaPiSideC.push_back(track.tpcNSigmaPi()); + vTrackTOFNSigmaPiSideC.push_back(track.tofNSigmaPi()); + vTrackTPCNSigmaKaSideC.push_back(track.tpcNSigmaKa()); + vTrackTOFNSigmaKaSideC.push_back(track.tofNSigmaKa()); histos.fill(HIST("Tracks/SGsideC/hTrackITSNCls"), track.itsNCls()); histos.fill(HIST("Tracks/SGsideC/hTrackITSChi2NCls"), track.itsChi2NCl()); @@ -376,54 +538,124 @@ struct upcPhotonuclearAnalysisJMG { } } histos.fill(HIST("Events/SGsideC/hNch"), nTracksCharged); + histos.fill(HIST("Events/SGsideC/hMultiplicity"), reconstructedTracks.size()); histos.fill(HIST("Events/SGsideC/hPtVSNch"), nTracksCharged, (sumPt / nTracksCharged)); + nTracksChargedSideC = nTracksCharged; + multiplicitySideC = reconstructedTracks.size(); nTracksCharged = sumPt = 0; break; - case 2: // for both sides - if (isCollisionCutSG(reconstructedCollision, 2) == false) { + default: + return; + break; + } + tree(vTrackPtSideA, vTrackEtaSideA, vTrackPhiSideA, vTrackTPCSignalSideA, vTrackTOFSignalSideA, vTrackTPCNSigmaPiSideA, vTrackTOFNSigmaPiSideA, vTrackTPCNSigmaKaSideA, vTrackTOFNSigmaKaSideA, vTrackPtSideC, vTrackEtaSideC, vTrackPhiSideC, vTrackTPCSignalSideA, vTrackTOFSignalSideA, vTrackTPCNSigmaPiSideA, vTrackTOFNSigmaPiSideA, vTrackTPCNSigmaKaSideA, vTrackTOFNSigmaKaSideA, nTracksChargedSideA, multiplicitySideA, nTracksChargedSideC, multiplicitySideC); + // nTracksChargedSideA = nTracksChargedSideC = multiplicitySideA = multiplicitySideC = 0; + } + PROCESS_SWITCH(upcPhotonuclearAnalysisJMG, processSG, "Process in UD tables", true); + + void processSame(FullSGUDCollision::iterator const& reconstructedCollision, FullUDTracks const& reconstructedTracks) + { + int sgSide = reconstructedCollision.gapSide(); + float multiplicity = 0; + + switch (sgSide) { + case 0: // gap for side A + if (isCollisionCutSG(reconstructedCollision, 0) == false) { return; } - histos.fill(HIST("Events/hCountCollisions"), 3); - histos.fill(HIST("Events/SGsideBoth/hEnergyZNA"), reconstructedCollision.energyCommonZNA()); - histos.fill(HIST("Events/SGsideBoth/hEnergyZNC"), reconstructedCollision.energyCommonZNC()); - histos.fill(HIST("Events/SGsideBoth/hEnergyRelationSides"), reconstructedCollision.energyCommonZNA(), reconstructedCollision.energyCommonZNC()); - histos.fill(HIST("Events/SGsideBoth/hTimeZNA"), reconstructedCollision.timeZNA()); - histos.fill(HIST("Events/SGsideBoth/hTimeZNC"), reconstructedCollision.timeZNC()); - histos.fill(HIST("Events/SGsideBoth/hTimeRelationSides"), reconstructedCollision.timeZNA(), reconstructedCollision.timeZNC()); - histos.fill(HIST("Events/SGsideBoth/hTrackZVtx"), reconstructedCollision.posZ()); - histos.fill(HIST("Events/SGsideBoth/hAmplitudFT0A"), reconstructedCollision.totalFT0AmplitudeA()); - histos.fill(HIST("Events/SGsideBoth/hAmplitudFT0C"), reconstructedCollision.totalFT0AmplitudeC()); - for (auto& track : reconstructedTracks) { - if (track.sign() == 1 || track.sign() == -1) { - if (isTrackCut(track) == false) { - continue; - } - nTracksCharged++; - sumPt += track.pt(); - histos.fill(HIST("Tracks/SGsideBoth/hTrackPt"), track.pt()); - histos.fill(HIST("Tracks/SGsideBoth/hTrackPhi"), phi(track.px(), track.py())); - histos.fill(HIST("Tracks/SGsideBoth/hTrackEta"), eta(track.px(), track.py(), track.pz())); - histos.fill(HIST("Tracks/SGsideBoth/hTrackTPCSignnalP"), momentum(track.px(), track.py(), track.pz()) * track.sign(), track.tpcSignal()); - - histos.fill(HIST("Tracks/SGsideBoth/hTrackITSNCls"), track.itsNCls()); - histos.fill(HIST("Tracks/SGsideBoth/hTrackITSChi2NCls"), track.itsChi2NCl()); - histos.fill(HIST("Tracks/SGsideBoth/hTrackNClsCrossedRowsOverNCls"), (static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable()))); - histos.fill(HIST("Tracks/SGsideBoth/hTrackTPCNClsCrossedRows"), track.tpcNClsCrossedRows()); - histos.fill(HIST("Tracks/SGsideBoth/hTrackTPCNClsFindable"), track.tpcNClsFindable()); - histos.fill(HIST("Tracks/SGsideBoth/hTrackTPCChi2NCls"), track.tpcChi2NCl()); - histos.fill(HIST("Tracks/SGsideBoth/hTrackITSNClsTPCCls"), track.tpcNClsFindable() - track.tpcNClsFindableMinusFound(), track.itsNCls()); - } + multiplicity = reconstructedTracks.size(); + if (fillCollisionUD(sameGapSideA, multiplicity) == false) { + return; } - histos.fill(HIST("Events/SGsideBoth/hNch"), nTracksCharged); - histos.fill(HIST("Events/SGsideBoth/hPtVSNch"), nTracksCharged, (sumPt / nTracksCharged)); - nTracksCharged = sumPt = 0; + // LOGF(debug, "Filling sameGapSideA events"); + histos.fill(HIST("eventcount"), -2); + fillQAUD(reconstructedTracks); + fillCorrelationsUD(sameGapSideA, reconstructedTracks, reconstructedTracks, multiplicity, reconstructedCollision.posZ()); + break; + case 1: // gap for side C + if (isCollisionCutSG(reconstructedCollision, 1) == false) { + return; + } + multiplicity = reconstructedTracks.size(); + if (fillCollisionUD(sameGapSideC, multiplicity) == false) { + return; + } + histos.fill(HIST("eventcount"), -1); + // LOGF(info, "Filling sameGapSideC events"); + fillCorrelationsUD(sameGapSideC, reconstructedTracks, reconstructedTracks, multiplicity, reconstructedCollision.posZ()); break; default: return; break; } } - PROCESS_SWITCH(upcPhotonuclearAnalysisJMG, processSG, "Process in UD tables", true); + + PROCESS_SWITCH(upcPhotonuclearAnalysisJMG, processSame, "Process same event", true); + + void processMixed(FullSGUDCollision::iterator const& reconstructedCollision) + { + (void)reconstructedCollision; + // int sgSide = reconstructedCollision.gapSide(); + // int sgSide = 0; + + int maxCountGapA = 0; + int maxCountGapC = 0; + + if (auto histEventCount = histos.get(HIST("eventcount"))) { + int binA = histEventCount->GetXaxis()->FindBin(-2); // Gap A + int binC = histEventCount->GetXaxis()->FindBin(-1); // Gap C + + maxCountGapA = histEventCount->GetBinContent(binA) * factorEventsMixed; + maxCountGapC = histEventCount->GetBinContent(binC) * factorEventsMixed; + } + + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + if (collision1.size() == 0 || collision2.size() == 0) { + // LOGF(info, "One or both collisions are empty."); + continue; + } + + if (countGapA >= maxCountGapA && countGapC >= maxCountGapC) { + break; + } + float multiplicity = 0; + if (collision1.gapSide() == 0 && collision2.gapSide() == 0) { // gap on side A + if (isCollisionCutSG(collision1, 0) == false && isCollisionCutSG(collision2, 0) == false) { + continue; + } + // std::cout << "Counts for Gap A: " << countGapA << " Maximum Count for Gap A " << maxCountGapA << std::endl; + ++countGapA; + // LOGF(info, "In the pairs loop, gap side A"); + multiplicity = tracks1.size(); + if (fillCollisionUD(mixedGapSideA, multiplicity) == false) { + return; + } + // histos.fill(HIST("eventcount"), bindingOnVtx.getBin({collision1.posZ()})); + histos.fill(HIST("eventcount"), bindingOnVtx.getBin({collision1.posZ(), collision1.gapSide()})); + fillCorrelationsUD(mixedGapSideA, tracks1, tracks2, multiplicity, collision1.posZ()); + // LOGF(info, "Filling mixedGapSideA events, Gap for side A"); + } + + if (collision1.gapSide() == 1 && collision2.gapSide() == 1) { // gap on side C + if (isCollisionCutSG(collision1, 1) == false && isCollisionCutSG(collision2, 1) == false) { + continue; + } + // std::cout << "Counts for Gap C: " << countGapC << " Maximum Count for Gap C" << maxCountGapC << std::endl; + ++countGapC; + // LOGF(info, "In the pairs loop, gap side C"); + multiplicity = tracks1.size(); + if (fillCollisionUD(mixedGapSideC, multiplicity) == false) { + return; + } + fillCorrelationsUD(mixedGapSideC, tracks1, tracks2, multiplicity, collision1.posZ()); + // LOGF(info, "Filling mixedGapSideC events, Gap for side C"); + } else { + continue; + } + } + } + + PROCESS_SWITCH(upcPhotonuclearAnalysisJMG, processMixed, "Process mixed events", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGUD/Tasks/upcPionAnalysis.cxx b/PWGUD/Tasks/upcPionAnalysis.cxx index 2d5d35cd564..fc215ea1822 100644 --- a/PWGUD/Tasks/upcPionAnalysis.cxx +++ b/PWGUD/Tasks/upcPionAnalysis.cxx @@ -13,7 +13,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include #include "PWGUD/DataModel/UDTables.h" #include #include diff --git a/PWGUD/Tasks/upcQuarkoniaCentralBarrel.cxx b/PWGUD/Tasks/upcQuarkoniaCentralBarrel.cxx new file mode 100644 index 00000000000..f195a750fa4 --- /dev/null +++ b/PWGUD/Tasks/upcQuarkoniaCentralBarrel.cxx @@ -0,0 +1,611 @@ +// 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. +// +/// \file upcQuarkoniaCentralBarrel.cxx +/// \brief quarkonia --> ppbar task +/// +/// \author David Dobrigkeit Chinellato , Austrian Academy of Sciences & SMI +/// \author Roman Lavicka , Austrian Academy of Sciences & SMI +/// \author Romain Schotter , Austrian Academy of Sciences & SMI +// +// V0 analysis task +// ================ +// +// This code loops over a V0Cores table and produces some +// standard analysis output. It is meant to be run over +// derived data. +// +// +// Comments, questions, complaints, suggestions? +// Please write to: +// romain.schotter@cern.ch +// david.dobrigkeit.chinellato@cern.ch +// + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "ReconstructionDataFormats/Track.h" +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/trackUtilities.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/PIDResponse.h" +#include "PWGUD/Core/SGSelector.h" + +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; + +using UDCollisions = soa::Join; +using UDCollision = UDCollisions::iterator; +using UDTracks = soa::Join; +using UDTrack = UDTracks::iterator; + +// simple checkers, but ensure 64 bit integers +#define BITSET(var, nbit) ((var) |= (static_cast(1) << static_cast(nbit))) +#define BITCHECK(var, nbit) ((var) & (static_cast(1) << static_cast(nbit))) + +struct upcQuarkoniaCentralBarrel { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Configurable buildSameSignPairs{"buildSameSignPairs", false, "If true: build same-sign pairs, otherwise consider only opposite-sign pairs"}; + + // rapidity cut on the hyperon-antiHyperon pair + Configurable rapidityCut{"rapidityCut", 0.5, "rapidity cut on the ppbar pair"}; + + struct : ConfigurableGroup { + // Selection criteria: acceptance + Configurable etaCut{"trackSelections.etaCut", 0.8, "max eta for daughters"}; + + // Track quality + Configurable dcaxytopv{"trackSelections.dcaxytopv", .05, "max transverse DCA to PV (cm)"}; + Configurable dcaztopv{"trackSelections.dcaztopv", .05, "max longitudinal DCA to PV (cm)"}; + Configurable minTPCrows{"trackSelections.minTPCrows", 70, "minimum TPC crossed rows"}; + Configurable minTPCclusters{"trackSelections.minTPCclusters", 3, "minimum TPC clusters"}; + Configurable minTPCchi2clusters{"trackSelections.minTPCchi2clusters", 4.0, "minimum TPC chi2/clusters"}; + Configurable minTPCrowsoverfindable{"trackSelections.minTPCrowsoverfindable", 0.8, "minimum TPC rows/findable clusters"}; + Configurable minITSclusters{"trackSelections.minITSclusters", -1, "minimum ITS clusters"}; + Configurable minITSchi2clusters{"trackSelections.minITSchi2clusters", -1.0, "minimum ITS chi2/clusters"}; + Configurable requirePVcontributor{"trackSelections.requirePVcontributor", false, "require that track is a PV contributor"}; + Configurable applyDCAptdepsel{"trackSelections.applyDCAptdepsel", false, "apply DCA pt dep. cut à la Run2"}; + Configurable skipTPConly{"trackSelections.skipTPConly", false, "skip V0s comprised of at least one TPC only prong"}; + Configurable requireITSonly{"trackSelections.requirePosITSonly", false, "require that track is ITSonly (overrides TPC quality)"}; + Configurable rejectITSafterburner{"trackSelections.rejectNegITSafterburner", false, "reject track formed out of afterburner ITS tracks"}; + + // PID (TPC/TOF) + Configurable tpcPidNsigmaCut{"trackSelections.tpcPidNsigmaCut", 5, "tpcPidNsigmaCut"}; + Configurable tofPidNsigmaCut{"trackSelections.tofPidNsigmaCut", 1e+6, "tofPidNsigmaCut"}; + } trackSelections; + + // for MC + Configurable doMCAssociation{"doMCAssociation", true, "if MC, do MC association"}; + + // UPC selections + SGSelector sgSelector; + struct : ConfigurableGroup { + Configurable fv0Cut{"upcCuts.fv0Cut", 100., "FV0A threshold"}; + Configurable ft0aCut{"upcCuts.ft0aCut", 200., "FT0A threshold"}; + Configurable ft0cCut{"upcCuts.ft0cCut", 100., "FT0C threshold"}; + Configurable zdcCut{"upcCuts.zdcCut", 10., "ZDC threshold"}; + // Configurable gapSel{"upcCuts.gapSel", 2, "Gap selection"}; + } upcCuts; + + static constexpr float defaultLifetimeCuts[1][2] = {{30., 20.}}; + Configurable> lifetimecut{"lifetimecut", {defaultLifetimeCuts[0], 2, {"lifetimecutLambda", "lifetimecutK0S"}}, "lifetimecut"}; + + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f, 1.2f, 1.4f, 1.6f, 1.8f, 2.0f, 2.4f, 2.8f, 3.2f, 3.6f, 4.0f, 4.8f, 5.6f, 6.5f, 7.5f, 9.0f, 11.0f, 13.0f, 15.0f, 19.0f, 23.0f, 30.0f, 40.0f, 50.0f}, "pt axis for analysis"}; + ConfigurableAxis axisQuarkoniumMass{"axisQuarkoniumMass", {500, 2.600f, 4.000f}, "M (hyp. #bar{hyp.} ) (GeV/#it{c}^{2})"}; + ConfigurableAxis axisOccupancy{"axisOccupancy", {VARIABLE_WIDTH, 0.0f, 250.0f, 500.0f, 750.0f, 1000.0f, 1500.0f, 2000.0f, 3000.0f, 4500.0f, 6000.0f, 8000.0f, 10000.0f, 50000.0f}, "Occupancy"}; + + ConfigurableAxis axisDCAXYtoPV{"axisDCAXYtoPV", {20, 0.0f, 1.0f}, "DCAxy (cm)"}; + ConfigurableAxis axisDCAZtoPV{"axisDCAZtoPV", {20, 0.0f, 1.0f}, "DCAz (cm)"}; + ConfigurableAxis axisTPCrows{"axisTPCrows", {160, 0.0f, 160.0f}, "N TPC rows"}; + ConfigurableAxis axisTPCclus{"axisTPCclus", {160, 0.0f, 160.0f}, "N TPC Clusters"}; + ConfigurableAxis axisTPCChi2clus{"axisTPCChi2clus", {100, 0.0f, 50.0f}, "TPC Chi2/Clusters"}; + ConfigurableAxis axisTPCrowsOverFindable{"axisTPCrowsOverFindable", {100, 0.0f, 1.0f}, "TPC Rows/Findable"}; + ConfigurableAxis axisITSclus{"axisITSclus", {7, 0.0f, 7.0f}, "N ITS Clusters"}; + ConfigurableAxis axisITSChi2clus{"axisITSChi2clus", {100, 0.0f, 50.0f}, "ITS Chi2/Clusters"}; + ConfigurableAxis axisNsigmaTPC{"axisNsigmaTPC", {200, -10.0f, 10.0f}, "N sigma TPC"}; + ConfigurableAxis axisNsigmaTOF{"axisNsigmaTOF", {200, -10.0f, 10.0f}, "N sigma TOF"}; + + // UPC axes + ConfigurableAxis axisSelGap{"axisSelGap", {4, -1.5, 2.5}, "Gap side"}; + + // PDG database + Service pdgDB; + + void init(InitContext const&) + { + // Event Counters + histos.add("hEventPVz", "hEventPVz", kTH1F, {{100, -20.0f, +20.0f}}); + histos.add("hSelGapSideVsPVz", "hSelGapSideVsPVz", kTH2F, {axisSelGap, {100, -20.0f, +20.0f}}); + + histos.add("hEventOccupancy", "hEventOccupancy", kTH1F, {axisOccupancy}); + histos.add("hSelGapSideVsOccupancy", "hSelGapSideVsOccupancy", kTH2F, {axisSelGap, axisOccupancy}); + + histos.add("hGapSide", "Gap side; Entries", kTH1F, {{5, -0.5, 4.5}}); + histos.add("hSelGapSide", "Selected gap side; Entries", kTH1F, {axisSelGap}); + + // histograms versus mass + histos.add("PPbar/h2dMassPPbar", "h2dMassPPbar", kTH2F, {axisPt, axisQuarkoniumMass}); + // Non-UPC info + histos.add("PPbar/h2dMassPPbarHadronic", "h2dMassPPbarHadronic", kTH2F, {axisPt, axisQuarkoniumMass}); + // UPC info + histos.add("PPbar/h2dMassPPbarSGA", "h2dMassPPbarSGA", kTH2F, {axisPt, axisQuarkoniumMass}); + histos.add("PPbar/h2dMassPPbarSGC", "h2dMassPPbarSGC", kTH2F, {axisPt, axisQuarkoniumMass}); + histos.add("PPbar/h2dMassPPbarDG", "h2dMassPPbarDG", kTH2F, {axisPt, axisQuarkoniumMass}); + + histos.add("PPbar/h2dNbrOfProtonsVsSelGapSide", "h2dNbrOfProtonsVsSelGapSide", kTH2F, {axisSelGap, {100, -0.5f, 99.5f}}); + histos.add("PPbar/h2dNbrOfAntiProtonsVsSelGapSide", "h2dNbrOfAntiProtonsVsSelGapSide", kTH2F, {axisSelGap, {100, -0.5f, 99.5f}}); + // QA plot + // Proton Candidates before selections + histos.add("PPbar/Proton/hDCAxyToPV", "hDCAxyToPV", kTH1F, {axisDCAXYtoPV}); + histos.add("PPbar/Proton/hDCAzToPV", "hDCAzToPV", kTH1F, {axisDCAZtoPV}); + histos.add("PPbar/Proton/hTPCCrossedRows", "hTPCCrossedRows", kTH1F, {axisTPCrows}); + histos.add("PPbar/Proton/hTPCNClusters", "hTPCNClusters", kTH1F, {axisTPCclus}); + histos.add("PPbar/Proton/hTPCChi2Clusters", "hTPCChi2Clusters", kTH1F, {axisTPCChi2clus}); + histos.add("PPbar/Proton/hTPCCrossedRowsOverFindable", "hTPCCrossedRowsOverFindable", kTH1F, {axisTPCrowsOverFindable}); + histos.add("PPbar/Proton/hITSNClusters", "hITSNClusters", kTH1F, {axisITSclus}); + histos.add("PPbar/Proton/hITSChi2Clusters", "hITSChi2Clusters", kTH1F, {axisITSChi2clus}); + histos.add("PPbar/Proton/hTPCNsigma", "hTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("PPbar/Proton/hTOFNsigma", "hTOFNsigma", kTH1F, {axisNsigmaTOF}); + histos.add("PPbar/Proton/h2dITSvsTPCpts", "h2dITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + // Anti Proton before selections + histos.add("PPbar/AntiProton/hDCAxyToPV", "hDCAxyToPV", kTH1F, {axisDCAXYtoPV}); + histos.add("PPbar/AntiProton/hDCAzToPV", "hDCAzToPV", kTH1F, {axisDCAZtoPV}); + histos.add("PPbar/AntiProton/hTPCCrossedRows", "hTPCCrossedRows", kTH1F, {axisTPCrows}); + histos.add("PPbar/AntiProton/hTPCNClusters", "hTPCNClusters", kTH1F, {axisTPCclus}); + histos.add("PPbar/AntiProton/hTPCChi2Clusters", "hTPCChi2Clusters", kTH1F, {axisTPCChi2clus}); + histos.add("PPbar/AntiProton/hTPCCrossedRowsOverFindable", "hTPCCrossedRowsOverFindable", kTH1F, {axisTPCrowsOverFindable}); + histos.add("PPbar/AntiProton/hITSNClusters", "hITSNClusters", kTH1F, {axisITSclus}); + histos.add("PPbar/AntiProton/hITSChi2Clusters", "hITSChi2Clusters", kTH1F, {axisITSChi2clus}); + histos.add("PPbar/AntiProton/hTPCNsigma", "hTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("PPbar/AntiProton/hTOFNsigma", "hTOFNsigma", kTH1F, {axisNsigmaTOF}); + histos.add("PPbar/AntiProton/h2dITSvsTPCpts", "h2dITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + // Proton Candidates after selections + histos.add("PPbar/Proton/hDCAxyToPV_aftersel", "hDCAxyToPV", kTH1F, {axisDCAXYtoPV}); + histos.add("PPbar/Proton/hDCAzToPV_aftersel", "hDCAzToPV", kTH1F, {axisDCAZtoPV}); + histos.add("PPbar/Proton/hTPCCrossedRows_aftersel", "hTPCCrossedRows", kTH1F, {axisTPCrows}); + histos.add("PPbar/Proton/hTPCNClusters_aftersel", "hTPCNClusters", kTH1F, {axisTPCclus}); + histos.add("PPbar/Proton/hTPCChi2Clusters_aftersel", "hTPCChi2Clusters", kTH1F, {axisTPCChi2clus}); + histos.add("PPbar/Proton/hTPCCrossedRowsOverFindable_aftersel", "hTPCCrossedRowsOverFindable", kTH1F, {axisTPCrowsOverFindable}); + histos.add("PPbar/Proton/hITSNClusters_aftersel", "hITSNClusters", kTH1F, {axisITSclus}); + histos.add("PPbar/Proton/hITSChi2Clusters_aftersel", "hITSChi2Clusters", kTH1F, {axisITSChi2clus}); + histos.add("PPbar/Proton/hTPCNsigma_aftersel", "hTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("PPbar/Proton/hTOFNsigma_aftersel", "hTOFNsigma", kTH1F, {axisNsigmaTOF}); + histos.add("PPbar/Proton/h2dITSvsTPCpts_aftersel", "h2dITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + // Anti Proton after selections + histos.add("PPbar/AntiProton/hDCAxyToPV_aftersel", "hDCAxyToPV", kTH1F, {axisDCAXYtoPV}); + histos.add("PPbar/AntiProton/hDCAzToPV_aftersel", "hDCAzToPV", kTH1F, {axisDCAZtoPV}); + histos.add("PPbar/AntiProton/hTPCCrossedRows_aftersel", "hTPCCrossedRows", kTH1F, {axisTPCrows}); + histos.add("PPbar/AntiProton/hTPCNClusters_aftersel", "hTPCNClusters", kTH1F, {axisTPCclus}); + histos.add("PPbar/AntiProton/hTPCChi2Clusters_aftersel", "hTPCChi2Clusters", kTH1F, {axisTPCChi2clus}); + histos.add("PPbar/AntiProton/hTPCCrossedRowsOverFindable_aftersel", "hTPCCrossedRowsOverFindable", kTH1F, {axisTPCrowsOverFindable}); + histos.add("PPbar/AntiProton/hITSNClusters_aftersel", "hITSNClusters", kTH1F, {axisITSclus}); + histos.add("PPbar/AntiProton/hITSChi2Clusters_aftersel", "hITSChi2Clusters", kTH1F, {axisITSChi2clus}); + histos.add("PPbar/AntiProton/hTPCNsigma_aftersel", "hTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("PPbar/AntiProton/hTOFNsigma_aftersel", "hTOFNsigma", kTH1F, {axisNsigmaTOF}); + histos.add("PPbar/AntiProton/h2dITSvsTPCpts_aftersel", "h2dITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + if (doMCAssociation) { + histos.add("PPbar/h2dInvMassTrueEtaC1S", "h2dInvMassTrueEtaC1S", kTH2F, {axisPt, axisQuarkoniumMass}); + histos.add("PPbar/h2dInvMassTrueJPsi", "h2dInvMassTrueJPsi", kTH2F, {axisPt, axisQuarkoniumMass}); + histos.add("PPbar/h2dInvMassTrueChiC0", "h2dInvMassTrueChiC0", kTH2F, {axisPt, axisQuarkoniumMass}); + histos.add("PPbar/h2dInvMassTrueChiC1", "h2dInvMassTrueChiC1", kTH2F, {axisPt, axisQuarkoniumMass}); + histos.add("PPbar/h2dInvMassTrueHC", "h2dInvMassTrueHC", kTH2F, {axisPt, axisQuarkoniumMass}); + histos.add("PPbar/h2dInvMassTrueChiC2", "h2dInvMassTrueChiC2", kTH2F, {axisPt, axisQuarkoniumMass}); + histos.add("PPbar/h2dInvMassTrueEtaC2S", "h2dInvMassTrueEtaC2S", kTH2F, {axisPt, axisQuarkoniumMass}); + histos.add("PPbar/h2dInvMassTruePsi2S", "h2dInvMassTruePsi2S", kTH2F, {axisPt, axisQuarkoniumMass}); + } + + // inspect histogram sizes, please + histos.print(); + } + + template + void fillEventHistograms(TCollision collision, int& selGapSide) + { + // in case we want to push the analysis to Pb-Pb UPC + int gapSide = collision.gapSide(); + // -1 --> Hadronic + // 0 --> Single Gap - A side + // 1 --> Single Gap - C side + // 2 --> Double Gap - both A & C sides + selGapSide = sgSelector.trueGap(collision, upcCuts.fv0Cut, upcCuts.ft0aCut, upcCuts.ft0cCut, upcCuts.zdcCut); + histos.fill(HIST("hGapSide"), gapSide); + histos.fill(HIST("hSelGapSide"), selGapSide); + + histos.fill(HIST("hSelGapSideVsPVz"), selGapSide, collision.posZ()); + histos.fill(HIST("hEventPVz"), collision.posZ()); + + histos.fill(HIST("hEventOccupancy"), collision.occupancyInTime()); + histos.fill(HIST("hSelGapSideVsOccupancy"), selGapSide, collision.occupancyInTime()); + + return; + } + + template + bool isTrackSelected(TTrack track) + { + // + // acceptance cut + // + if (std::fabs(RecoDecay::eta(std::array{track.px(), track.py(), track.pz()})) > trackSelections.etaCut) + return false; + + // PV contributor selection + if (trackSelections.requirePVcontributor && !track.isPVContributor()) + return false; + + // dca XY to PV + if (trackSelections.applyDCAptdepsel) { // apply pt dep. selection on DCAxy + float dcaXYPtCut = 0.0105f + 0.0350f / pow(track.pt(), 1.1f); + if (std::fabs(track.dcaXY()) > dcaXYPtCut) + return false; + } else { + if (std::fabs(track.dcaXY()) > trackSelections.dcaxytopv) + return false; + } + // dca Z to PV + if (std::fabs(track.dcaZ()) > trackSelections.dcaztopv) + return false; + + // + // ITS quality flags + // + if (track.itsNCls() < trackSelections.minITSclusters) + return false; + if (track.itsChi2NCl() < trackSelections.minITSchi2clusters) + return false; + if (trackSelections.rejectITSafterburner && track.itsChi2NCl() < 0) + return false; + if (trackSelections.requireITSonly && track.tpcNClsCrossedRows() > 0) + return false; + + // + // TPC quality flags + // + if (track.tpcNClsCrossedRows() < trackSelections.minTPCrows) + return false; + if (track.tpcChi2NCl() < trackSelections.minTPCchi2clusters) + return false; + if (track.tpcNClsFindable() - track.tpcNClsFindableMinusFound() < trackSelections.minTPCclusters) + return false; + if (static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable()) < trackSelections.minTPCrowsoverfindable) + return false; + if (trackSelections.skipTPConly && track.detectorMap() == o2::aod::track::TPC) + return false; + + // + // TPC PID + // + if (std::fabs(track.tpcNSigmaPr()) > trackSelections.tpcPidNsigmaCut) + return false; + + // + // TOF PID in NSigma + // Bachelor track + if (track.hasTOF()) { + if (std::fabs(track.tofNSigmaPr()) > trackSelections.tofPidNsigmaCut) + return false; + } + + return true; + } + + template + bool checkMCAssociation(TTrack track, TTrackMC trackMC) + // MC association (if asked) + { + if (track.sign() * trackMC.pdgCode() != 2212) + return false; + if (!trackMC.isPhysicalPrimary()) + return false; + return true; + } + + template + void fillQAplot(TTrack track, bool afterSel = false) + { // fill QA information about proton/antiproton track + if (afterSel) { + if (track.sign() > 0) { // Proton Candidates after selections + histos.fill(HIST("PPbar/Proton/hDCAxyToPV_aftersel"), track.dcaXY()); + histos.fill(HIST("PPbar/Proton/hDCAzToPV_aftersel"), track.dcaZ()); + histos.fill(HIST("PPbar/Proton/hTPCCrossedRows_aftersel"), track.tpcNClsCrossedRows()); + histos.fill(HIST("PPbar/Proton/hTPCNClusters_aftersel"), track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()); + histos.fill(HIST("PPbar/Proton/hTPCChi2Clusters_aftersel"), track.tpcChi2NCl()); + histos.fill(HIST("PPbar/Proton/hTPCCrossedRowsOverFindable_aftersel"), static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())); + histos.fill(HIST("PPbar/Proton/hITSNClusters_aftersel"), track.itsNCls()); + histos.fill(HIST("PPbar/Proton/hITSChi2Clusters_aftersel"), track.itsChi2NCl()); + histos.fill(HIST("PPbar/Proton/hTPCNsigma_aftersel"), track.tpcNSigmaPr()); + if (track.hasTOF()) + histos.fill(HIST("PPbar/Proton/hTOFNsigma_aftersel"), track.tofNSigmaPr()); + histos.fill(HIST("PPbar/Proton/h2dITSvsTPCpts_aftersel"), track.tpcNClsCrossedRows(), track.itsNCls()); + } else { // Anti Proton after selections + histos.fill(HIST("PPbar/AntiProton/hDCAxyToPV_aftersel"), track.dcaXY()); + histos.fill(HIST("PPbar/AntiProton/hDCAzToPV_aftersel"), track.dcaZ()); + histos.fill(HIST("PPbar/AntiProton/hTPCCrossedRows_aftersel"), track.tpcNClsCrossedRows()); + histos.fill(HIST("PPbar/AntiProton/hTPCNClusters_aftersel"), track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()); + histos.fill(HIST("PPbar/AntiProton/hTPCChi2Clusters_aftersel"), track.tpcChi2NCl()); + histos.fill(HIST("PPbar/AntiProton/hTPCCrossedRowsOverFindable_aftersel"), static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())); + histos.fill(HIST("PPbar/AntiProton/hITSNClusters_aftersel"), track.itsNCls()); + histos.fill(HIST("PPbar/AntiProton/hITSChi2Clusters_aftersel"), track.itsChi2NCl()); + histos.fill(HIST("PPbar/AntiProton/hTPCNsigma_aftersel"), track.tpcNSigmaPr()); + if (track.hasTOF()) + histos.fill(HIST("PPbar/AntiProton/hTOFNsigma_aftersel"), track.tofNSigmaPr()); + histos.fill(HIST("PPbar/AntiProton/h2dITSvsTPCpts_aftersel"), track.tpcNClsCrossedRows(), track.itsNCls()); + } + } else { + if (track.sign() > 0) { // Proton Candidates before selections + histos.fill(HIST("PPbar/Proton/hDCAxyToPV"), track.dcaXY()); + histos.fill(HIST("PPbar/Proton/hDCAzToPV"), track.dcaZ()); + histos.fill(HIST("PPbar/Proton/hTPCCrossedRows"), track.tpcNClsCrossedRows()); + histos.fill(HIST("PPbar/Proton/hTPCNClusters"), track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()); + histos.fill(HIST("PPbar/Proton/hTPCChi2Clusters"), track.tpcChi2NCl()); + histos.fill(HIST("PPbar/Proton/hTPCCrossedRowsOverFindable"), static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())); + histos.fill(HIST("PPbar/Proton/hITSNClusters"), track.itsNCls()); + histos.fill(HIST("PPbar/Proton/hITSChi2Clusters"), track.itsChi2NCl()); + histos.fill(HIST("PPbar/Proton/hTPCNsigma"), track.tpcNSigmaPr()); + if (track.hasTOF()) + histos.fill(HIST("PPbar/Proton/hTOFNsigma"), track.tofNSigmaPr()); + histos.fill(HIST("PPbar/Proton/h2dITSvsTPCpts"), track.tpcNClsCrossedRows(), track.itsNCls()); + } else { + // Anti Proton before selections + histos.fill(HIST("PPbar/AntiProton/hDCAxyToPV"), track.dcaXY()); + histos.fill(HIST("PPbar/AntiProton/hDCAzToPV"), track.dcaZ()); + histos.fill(HIST("PPbar/AntiProton/hTPCCrossedRows"), track.tpcNClsCrossedRows()); + histos.fill(HIST("PPbar/AntiProton/hTPCNClusters"), track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()); + histos.fill(HIST("PPbar/AntiProton/hTPCChi2Clusters"), track.tpcChi2NCl()); + histos.fill(HIST("PPbar/AntiProton/hTPCCrossedRowsOverFindable"), static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())); + histos.fill(HIST("PPbar/AntiProton/hITSNClusters"), track.itsNCls()); + histos.fill(HIST("PPbar/AntiProton/hITSChi2Clusters"), track.itsChi2NCl()); + histos.fill(HIST("PPbar/AntiProton/hTPCNsigma"), track.tpcNSigmaPr()); + if (track.hasTOF()) + histos.fill(HIST("PPbar/AntiProton/hTOFNsigma"), track.tofNSigmaPr()); + histos.fill(HIST("PPbar/AntiProton/h2dITSvsTPCpts"), track.tpcNClsCrossedRows(), track.itsNCls()); + } + } + } + + template + void analyseTrackPairCandidate(TTrack proton, TTrack antiProton, TTrackMCs const& fullTrackMCs, uint8_t gapSide) + // fill information related to the quarkonium mother + { + float pt = RecoDecay::pt(proton.px() + antiProton.px(), proton.py() + antiProton.py()); + float invmass = RecoDecay::m(std::array{std::array{proton.px(), proton.py(), proton.pz()}, std::array{antiProton.px(), antiProton.py(), antiProton.pz()}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassProtonBar}); + float rapidity = RecoDecay::y(std::array{proton.px() + antiProton.px(), proton.py() + antiProton.py(), proton.pz() + antiProton.pz()}, invmass); + + // rapidity cut on the quarkonium mother + if (!doMCAssociation && std::fabs(rapidity) > rapidityCut) + return; + + // __________________________________________ + // main analysis + if (doMCAssociation) { + if constexpr (requires { proton.udMcParticle(); }) { // check if MC information is available + auto protonMC = fullTrackMCs.iteratorAt(proton.udMcParticle().globalIndex()); + auto antiProtonMC = fullTrackMCs.iteratorAt(antiProton.udMcParticle().globalIndex()); + + if (!protonMC.has_mothers()) + return; + if (!antiProtonMC.has_mothers()) + return; + + float ptmc = RecoDecay::pt(protonMC.px() + antiProtonMC.px(), protonMC.py() + antiProtonMC.py()); + + auto protonMothers = protonMC.template mothers_as(); + auto antiProtonMothers = antiProtonMC.template mothers_as(); + for (const auto& protonMother : protonMothers) { + for (const auto& antiProtonMother : antiProtonMothers) { + if (protonMother.globalIndex() != antiProtonMother.globalIndex()) { + continue; + } + + float rapiditymc = RecoDecay::y(std::array{protonMC.px() + antiProtonMC.px(), protonMC.py() + antiProtonMC.py(), protonMC.pz() + antiProtonMC.pz()}, pdgDB->Mass(protonMother.pdgCode())); + + if (std::fabs(rapiditymc) > rapidityCut) + continue; + + if (protonMother.pdgCode() == 441 && protonMother.pdgCode() == antiProtonMother.pdgCode()) { // EtaC(1S) + histos.fill(HIST("PPbar/h2dInvMassTrueEtaC1S"), ptmc, invmass); + } + if (protonMother.pdgCode() == 443 && protonMother.pdgCode() == antiProtonMother.pdgCode()) { // J/psi + histos.fill(HIST("PPbar/h2dInvMassTrueJPsi"), ptmc, invmass); + } + if (protonMother.pdgCode() == 10441 && protonMother.pdgCode() == antiProtonMother.pdgCode()) { // ChiC0 + histos.fill(HIST("PPbar/h2dInvMassTrueChiC0"), ptmc, invmass); + } + if (protonMother.pdgCode() == 20443 && protonMother.pdgCode() == antiProtonMother.pdgCode()) { // ChiC1 + histos.fill(HIST("PPbar/h2dInvMassTrueChiC1"), ptmc, invmass); + } + if (protonMother.pdgCode() == 10443 && protonMother.pdgCode() == antiProtonMother.pdgCode()) { // hC + histos.fill(HIST("PPbar/h2dInvMassTrueHC"), ptmc, invmass); + } + if (protonMother.pdgCode() == 445 && protonMother.pdgCode() == antiProtonMother.pdgCode()) { // ChiC2 + histos.fill(HIST("PPbar/h2dInvMassTrueChiC2"), ptmc, invmass); + } + if (protonMother.pdgCode() == 100441 && protonMother.pdgCode() == antiProtonMother.pdgCode()) { // EtaC(2S) + histos.fill(HIST("PPbar/h2dInvMassTrueEtaC2S"), ptmc, invmass); + } + if (protonMother.pdgCode() == 100443 && protonMother.pdgCode() == antiProtonMother.pdgCode()) { // Psi(2S) + histos.fill(HIST("PPbar/h2dInvMassTruePsi2S"), ptmc, invmass); + } + } + } + } + } + + histos.fill(HIST("PPbar/h2dMassPPbar"), pt, invmass); + if (gapSide == 0) + histos.fill(HIST("PPbar/h2dMassPPbarSGA"), pt, invmass); + else if (gapSide == 1) + histos.fill(HIST("PPbar/h2dMassPPbarSGC"), pt, invmass); + else if (gapSide == 2) + histos.fill(HIST("PPbar/h2dMassPPbarDG"), pt, invmass); + else + histos.fill(HIST("PPbar/h2dMassPPbarHadronic"), pt, invmass); + + fillQAplot(proton, true); + fillQAplot(antiProton, true); + } + + template + void buildProtonAntiProtonPairs(TTracks const& fullTracks, TTrackMCs const& fullMCTracks, std::vector selProtonIndices, std::vector selAntiProtonIndices, uint8_t gapSide) + { + // 1st loop over all protons + for (const auto& proton : fullTracks) { + // select only protons + if (!selProtonIndices[proton.globalIndex() - fullTracks.offset()]) { // local index needed due to collisions grouping + continue; + } + + // 2nd loop over all protons + for (const auto& antiProton : fullTracks) { + // select only anti-protons + if (!selAntiProtonIndices[antiProton.globalIndex() - fullTracks.offset()]) { // local index needed due to collisions grouping + continue; + } + + // check we don't look at the same protons + if (proton.globalIndex() == antiProton.globalIndex()) { + continue; + } + + // form proton-antiproton pairs and fill histograms + analyseTrackPairCandidate(proton, antiProton, fullMCTracks, gapSide); + } // end antiProton loop + } // end proton loop + + return; + } + + // ______________________________________________________ + // Real data processing - no MC subscription + void processRealData(soa::Join::iterator const& collision, soa::Join const& fullTracks) + { + int selGapSide = -1; // only useful in case one wants to use this task in Pb-Pb UPC + fillEventHistograms(collision, selGapSide); + // __________________________________________ + // perform main analysis + // + // Look at tracks and tag those passing the selections + std::vector selProtonIndices(fullTracks.size(), false); + std::vector selAntiProtonIndices(fullTracks.size(), false); + for (const auto& track : fullTracks) { + if (track.sign() > 0) { + selProtonIndices[track.globalIndex() - fullTracks.offset()] = isTrackSelected(track); + } else { + selAntiProtonIndices[track.globalIndex() - fullTracks.offset()] = isTrackSelected(track); + } + fillQAplot(track, false); + } // end track loop + + // count the number of Proton and antiProton passsing the selections + int nProtons = std::count(selProtonIndices.begin(), selProtonIndices.end(), true); + int nAntiProtons = std::count(selAntiProtonIndices.begin(), selAntiProtonIndices.end(), true); + + // fill the histograms with the number of reconstructed protons/antiprotons per collision + histos.fill(HIST("PPbar/h2dNbrOfProtonsVsSelGapSide"), selGapSide, nProtons); + histos.fill(HIST("PPbar/h2dNbrOfAntiProtonsVsSelGapSide"), selGapSide, nAntiProtons); + + // Check the number of Protons and antiProtons + // needs at least 1 of each + if (!buildSameSignPairs && nProtons >= 1 && nAntiProtons >= 1) { + buildProtonAntiProtonPairs(fullTracks, (TObject*)nullptr, selProtonIndices, selAntiProtonIndices, selGapSide); + } + if (buildSameSignPairs && nProtons > 1) { + buildProtonAntiProtonPairs(fullTracks, (TObject*)nullptr, selProtonIndices, selProtonIndices, selGapSide); + } + if (buildSameSignPairs && nAntiProtons > 1) { + buildProtonAntiProtonPairs(fullTracks, (TObject*)nullptr, selAntiProtonIndices, selAntiProtonIndices, selGapSide); + } + } + + // ______________________________________________________ + // Simulated processing (subscribes to MC information too) + void processMonteCarlo(soa::Join::iterator const& collision, soa::Join const& fullTracks, aod::UDMcCollisions const& /*mccollisions*/, aod::UDMcParticles const& fullMCTracks) + { + int selGapSide = -1; // only useful in case one wants to use this task in Pb-Pb UPC + fillEventHistograms(collision, selGapSide); + // __________________________________________ + // perform main analysis + // + // Look at tracks and tag those passing the selections + std::vector selProtonIndices(fullTracks.size(), false); + std::vector selAntiProtonIndices(fullTracks.size(), false); + for (const auto& track : fullTracks) { + if (!track.has_udMcParticle()) + continue; + + auto trackMC = fullMCTracks.iteratorAt(track.udMcParticle().globalIndex()); + + if (track.sign() > 0) { + selProtonIndices[track.globalIndex() - fullTracks.offset()] = isTrackSelected(track) && (!doMCAssociation || checkMCAssociation(track, trackMC)); + } else { + selAntiProtonIndices[track.globalIndex() - fullTracks.offset()] = isTrackSelected(track) && (!doMCAssociation || checkMCAssociation(track, trackMC)); + } + fillQAplot(track, false); + } // end track loop + + // count the number of Proton and antiProton passsing the selections + int nProtons = std::count(selProtonIndices.begin(), selProtonIndices.end(), true); + int nAntiProtons = std::count(selAntiProtonIndices.begin(), selAntiProtonIndices.end(), true); + + // fill the histograms with the number of reconstructed protons/antiprotons per collision + histos.fill(HIST("PPbar/h2dNbrOfProtonsVsSelGapSide"), selGapSide, nProtons); + histos.fill(HIST("PPbar/h2dNbrOfAntiProtonsVsSelGapSide"), selGapSide, nAntiProtons); + + // Check the number of Protons and antiProtons + // needs at least 1 of each + if (!buildSameSignPairs && nProtons >= 1 && nAntiProtons >= 1) { + buildProtonAntiProtonPairs(fullTracks, fullMCTracks, selProtonIndices, selAntiProtonIndices, selGapSide); + } + if (buildSameSignPairs && nProtons > 1) { + buildProtonAntiProtonPairs(fullTracks, fullMCTracks, selProtonIndices, selProtonIndices, selGapSide); + } + if (buildSameSignPairs && nAntiProtons > 1) { + buildProtonAntiProtonPairs(fullTracks, fullMCTracks, selAntiProtonIndices, selAntiProtonIndices, selGapSide); + } + } + + PROCESS_SWITCH(upcQuarkoniaCentralBarrel, processRealData, "process as if real data", true); + PROCESS_SWITCH(upcQuarkoniaCentralBarrel, processMonteCarlo, "process as if MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/Tasks/upcRhoAnalysis.cxx b/PWGUD/Tasks/upcRhoAnalysis.cxx index 597f4945a3f..244096b0a1b 100644 --- a/PWGUD/Tasks/upcRhoAnalysis.cxx +++ b/PWGUD/Tasks/upcRhoAnalysis.cxx @@ -9,46 +9,53 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// -/// \brief task for analysis of rho in UPCs using UD tables (from SG producer) -/// includes event tagging based on ZN information, track selection, reconstruction, +/// \brief Task for analysis of rho in UPCs using UD tables (from SG producer). +/// Includes event tagging based on ZN information, track selection, reconstruction, /// and also some basic stuff for decay phi anisotropy studies /// \author Jakub Juracka, jakub.juracka@cern.ch +/// \file upcRhoAnalysis.cxx -#include -#include +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" +#include "PWGUD/DataModel/UDTables.h" + +#include "Common/DataModel/PIDResponse.h" -#include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" -#include "random" -#include "TLorentzVector.h" - -#include "Common/DataModel/PIDResponse.h" +#include "Math/Vector4D.h" +#include "TPDGCode.h" -#include "PWGUD/DataModel/UDTables.h" -#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using FullUdSgCollision = soa::Join::iterator; -using FullUdDgCollision = soa::Join::iterator; +using FullUdSgCollision = soa::Join::iterator; +using FullUdDgCollision = soa::Join::iterator; using FullUdTracks = soa::Join; +using FullMcUdCollision = soa::Join::iterator; namespace o2::aod { -namespace tree +namespace reco_tree { -// misc event info +// event info +DECLARE_SOA_COLUMN(RecoSetting, recoSetting, uint16_t); DECLARE_SOA_COLUMN(RunNumber, runNumber, int32_t); -DECLARE_SOA_COLUMN(GlobalBC, globalBC, uint64_t); +DECLARE_SOA_COLUMN(LocalBC, localBC, int); DECLARE_SOA_COLUMN(NumContrib, numContrib, int); -// event vertex -DECLARE_SOA_COLUMN(PosX, posX, double); -DECLARE_SOA_COLUMN(PosY, posY, double); -DECLARE_SOA_COLUMN(PosZ, posZ, double); +DECLARE_SOA_COLUMN(PosX, posX, float); +DECLARE_SOA_COLUMN(PosY, posY, float); +DECLARE_SOA_COLUMN(PosZ, posZ, float); // FIT info DECLARE_SOA_COLUMN(TotalFT0AmplitudeA, totalFT0AmplitudeA, float); DECLARE_SOA_COLUMN(TotalFT0AmplitudeC, totalFT0AmplitudeC, float); @@ -66,491 +73,454 @@ DECLARE_SOA_COLUMN(EnergyCommonZNC, energyCommonZNC, float); DECLARE_SOA_COLUMN(TimeZNA, timeZNA, float); DECLARE_SOA_COLUMN(TimeZNC, timeZNC, float); DECLARE_SOA_COLUMN(NeutronClass, neutronClass, int); -// Rhos -DECLARE_SOA_COLUMN(TotalCharge, totalCharge, int); -// store things for reconstruction of lorentz vectors -DECLARE_SOA_COLUMN(RhoPt, rhoPt, double); -DECLARE_SOA_COLUMN(RhoEta, rhoEta, double); -DECLARE_SOA_COLUMN(RhoPhi, rhoPhi, double); -DECLARE_SOA_COLUMN(RhoM, rhoM, double); -// other stuff -DECLARE_SOA_COLUMN(RhoPhiRandom, rhoPhiRandom, double); -DECLARE_SOA_COLUMN(RhoPhiCharge, rhoPhiCharge, double); -// Pion tracks -DECLARE_SOA_COLUMN(TrackSign, trackSign, std::vector); -// for lorentz vector reconstruction -DECLARE_SOA_COLUMN(TrackPt, trackPt, std::vector); -DECLARE_SOA_COLUMN(TrackEta, trackEta, std::vector); -DECLARE_SOA_COLUMN(TrackPhi, trackPhi, std::vector); -DECLARE_SOA_COLUMN(TrackM, trackM, std::vector); -// other stuff -DECLARE_SOA_COLUMN(TrackPiPID, trackPiPID, std::vector); -DECLARE_SOA_COLUMN(TrackElPID, trackElPID, std::vector); -DECLARE_SOA_COLUMN(TrackDcaXY, trackDcaXY, std::vector); -DECLARE_SOA_COLUMN(TrackDcaZ, trackDcaZ, std::vector); -DECLARE_SOA_COLUMN(TrackTpcSignal, trackTpcSignal, std::vector); -} // namespace tree -DECLARE_SOA_TABLE(Tree, "AOD", "TREE", - tree::RunNumber, tree::GlobalBC, tree::NumContrib, - tree::PosX, tree::PosY, tree::PosZ, tree::TotalFT0AmplitudeA, tree::TotalFT0AmplitudeC, tree::TotalFV0AmplitudeA, tree::TotalFDDAmplitudeA, tree::TotalFDDAmplitudeC, - tree::TimeFT0A, tree::TimeFT0C, tree::TimeFV0A, tree::TimeFDDA, tree::TimeFDDC, - tree::EnergyCommonZNA, tree::EnergyCommonZNC, tree::TimeZNA, tree::TimeZNC, tree::NeutronClass, - tree::TotalCharge, tree::RhoPt, tree::RhoEta, tree::RhoPhi, tree::RhoM, tree::RhoPhiRandom, tree::RhoPhiCharge, - tree::TrackSign, tree::TrackPt, tree::TrackEta, tree::TrackPhi, tree::TrackM, tree::TrackPiPID, tree::TrackElPID, tree::TrackDcaXY, tree::TrackDcaZ, tree::TrackTpcSignal); +// pion tracks +DECLARE_SOA_COLUMN(PhiRandom, phiRandom, float); +DECLARE_SOA_COLUMN(PhiCharge, phiCharge, float); +DECLARE_SOA_COLUMN(TrackSign, trackSign, int[2]); +DECLARE_SOA_COLUMN(TrackPt, trackPt, float[2]); +DECLARE_SOA_COLUMN(TrackEta, trackEta, float[2]); +DECLARE_SOA_COLUMN(TrackPhi, trackPhi, float[2]); +DECLARE_SOA_COLUMN(TrackPiPID, trackPiPID, float[2]); +DECLARE_SOA_COLUMN(TrackElPID, trackElPID, float[2]); +DECLARE_SOA_COLUMN(TrackKaPID, trackKaPID, float[2]); +DECLARE_SOA_COLUMN(TrackDcaXY, trackDcaXY, float[2]); +DECLARE_SOA_COLUMN(TrackDcaZ, trackDcaZ, float[2]); +DECLARE_SOA_COLUMN(TrackTpcSignal, trackTpcSignal, float[2]); +} // namespace reco_tree +DECLARE_SOA_TABLE(RecoTree, "AOD", "RECOTREE", + reco_tree::RecoSetting, reco_tree::RunNumber, reco_tree::LocalBC, reco_tree::NumContrib, reco_tree::PosX, reco_tree::PosY, reco_tree::PosZ, + reco_tree::TotalFT0AmplitudeA, reco_tree::TotalFT0AmplitudeC, reco_tree::TotalFV0AmplitudeA, reco_tree::TotalFDDAmplitudeA, reco_tree::TotalFDDAmplitudeC, + reco_tree::TimeFT0A, reco_tree::TimeFT0C, reco_tree::TimeFV0A, reco_tree::TimeFDDA, reco_tree::TimeFDDC, + reco_tree::EnergyCommonZNA, reco_tree::EnergyCommonZNC, reco_tree::TimeZNA, reco_tree::TimeZNC, reco_tree::NeutronClass, + reco_tree::PhiRandom, reco_tree::PhiCharge, reco_tree::TrackSign, reco_tree::TrackPt, reco_tree::TrackEta, reco_tree::TrackPhi, reco_tree::TrackPiPID, reco_tree::TrackElPID, reco_tree::TrackKaPID, reco_tree::TrackDcaXY, reco_tree::TrackDcaZ, reco_tree::TrackTpcSignal); + +namespace mc_tree +{ +// misc event info +DECLARE_SOA_COLUMN(LocalBc, localBc, int); +// event vertex +DECLARE_SOA_COLUMN(PosX, posX, float); +DECLARE_SOA_COLUMN(PosY, posY, float); +DECLARE_SOA_COLUMN(PosZ, posZ, float); +// pion tracks +DECLARE_SOA_COLUMN(PhiRandom, phiRandom, float); +DECLARE_SOA_COLUMN(PhiCharge, phiCharge, float); +DECLARE_SOA_COLUMN(TrackSign, trackSign, int[2]); +DECLARE_SOA_COLUMN(TrackPt, trackPt, float[2]); +DECLARE_SOA_COLUMN(TrackEta, trackEta, float[2]); +DECLARE_SOA_COLUMN(TrackPhi, trackPhi, float[2]); +} // namespace mc_tree +DECLARE_SOA_TABLE(McTree, "AOD", "MCTREE", + mc_tree::LocalBc, + mc_tree::PosX, mc_tree::PosY, mc_tree::PosZ, + mc_tree::PhiRandom, mc_tree::PhiCharge, mc_tree::TrackSign, mc_tree::TrackPt, mc_tree::TrackEta, mc_tree::TrackPhi); } // namespace o2::aod -struct upcRhoAnalysis { - Produces Tree; +struct UpcRhoAnalysis { + Produces recoTree; + Produces mcTree; - double PcEtaCut = 0.9; // physics coordination recommendation - Configurable requireTof{"requireTof", false, "require TOF signal"}; - Configurable do4pi{"do4pi", true, "do 4pi analysis"}; + SGSelector sgSelector; + + float pcEtaCut = 0.9; // physics coordination recommendation + + Configurable numPions{"numPions", 2, "required number of pions in the event"}; - Configurable collisionsPosZMaxCut{"collisionsPosZMaxCut", 10.0, "max Z position cut on collisions"}; - Configurable ZNcommonEnergyCut{"ZNcommonEnergyCut", 0.0, "ZN common energy cut"}; - Configurable ZNtimeCut{"ZNtimeCut", 2.0, "ZN time cut"}; + Configurable cutGapSide{"cutGapSide", true, "apply gap side cut"}; + Configurable gapSide{"gapSide", 2, "required gap side"}; + Configurable useTrueGap{"useTrueGap", false, "use true gap"}; + Configurable cutTrueGapSideFV0{"cutTrueGapSideFV0", 180000, "FV0A threshold for SG selector"}; + Configurable cutTrueGapSideFT0A{"cutTrueGapSideFT0A", 150., "FT0A threshold for SG selector"}; + Configurable cutTrueGapSideFT0C{"cutTrueGapSideFT0C", 50., "FT0C threshold for SG selector"}; + Configurable cutTrueGapSideZDC{"cutTrueGapSideZDC", 10000., "ZDC threshold for SG selector. 0 is <1n, 4.2 is <2n, 6.7 is <3n, 9.5 is <4n, 12.5 is <5n"}; - Configurable tracksTpcNSigmaPiCut{"tracksTpcNSigmaPiCut", 3.0, "TPC nSigma pion cut"}; - Configurable tracksDcaMaxCut{"tracksDcaMaxCut", 1.0, "max DCA cut on tracks"}; - Configurable tracksMinItsNClsCut{"tracksMinItsNClsCut", 6, "min ITS clusters cut"}; - Configurable tracksMaxItsChi2NClCut{"tracksMaxItsChi2NClCut", 3.0, "max ITS chi2/Ncls cut"}; + Configurable requireTof{"requireTof", false, "require TOF signal"}; + Configurable onlyGoldenRuns{"onlyGoldenRuns", false, "process only golden runs"}; + Configurable useRecoFlag{"useRecoFlag", false, "use reco flag for event selection"}; + Configurable cutRecoFlag{"cutRecoFlag", 1, "0 = std mode, 1 = upc mode"}; + Configurable useRctFlag{"useRctFlag", false, "use RCT flags for event selection"}; + Configurable cutRctFlag{"cutRctFlag", 0, "0 = off, 1 = CBT, 2 = CBT+ZDC, 3 = CBThadron, 4 = CBThadron+ZDC"}; + + Configurable collisionsPosZMaxCut{"collisionsPosZMaxCut", 10.0, "max Z position cut on collisions"}; + Configurable cutNumContribs{"cutNumContribs", true, "cut on number of contributors"}; + Configurable collisionsNumContribsMaxCut{"collisionsNumContribsMaxCut", 2, "max number of contributors cut on collisions"}; + Configurable znCommonEnergyCut{"znCommonEnergyCut", 0.0, "ZN common energy cut"}; + Configurable znTimeCut{"znTimeCut", 2.0, "ZN time cut"}; + + Configurable tracksTpcNSigmaPiCut{"tracksTpcNSigmaPiCut", 3.0, "TPC nSigma pion cut"}; + Configurable tracksDcaMaxCut{"tracksDcaMaxCut", 1.0, "max DCA cut on tracks"}; + Configurable tracksMinItsNClsCut{"tracksMinItsNClsCut", 4, "min ITS clusters cut"}; + Configurable tracksMaxItsChi2NClCut{"tracksMaxItsChi2NClCut", 3.0, "max ITS chi2/Ncls cut"}; Configurable tracksMinTpcNClsCut{"tracksMinTpcNClsCut", 120, "min TPC clusters cut"}; - Configurable tracksMinTpcNClsCrossedRowsCut{"tracksMinTpcNClsCrossedRowsCut", 140, "min TPC crossed rows cut"}; - Configurable tracksMinTpcChi2NClCut{"tracksMinTpcChi2NClCut", 1.0, "min TPC chi2/Ncls cut"}; - Configurable tracksMaxTpcChi2NClCut{"tracksMaxTpcChi2NClCut", 1.8, "max TPC chi2/Ncls cut"}; - Configurable tracksMinTpcNClsCrossedOverFindableCut{"tracksMinTpcNClsCrossedOverFindableCut", 1.05, "min TPC crossed rows / findable clusters cut"}; - Configurable tracksMinPtCut{"tracksMinPtCut", 0.2, "min pT cut on tracks"}; - - Configurable systemMassMinCut{"systemMassMinCut", 0.4, "min M cut for reco system"}; - Configurable systemMassMaxCut{"systemMassMaxCut", 1.2, "max M cut for reco system"}; - Configurable systemPtCut{"systemPtMaxCut", 0.1, "max pT cut for reco system"}; - Configurable systemYCut{"systemYCut", 0.9, "rapiditiy cut for reco system"}; - - ConfigurableAxis mAxis{"mAxis", {1000, 0.0, 10.0}, "m (GeV/#it{c}^{2})"}; - ConfigurableAxis mCutAxis{"mCutAxis", {160, 0.4, 1.2}, "m (GeV/#it{c}^{2})"}; - ConfigurableAxis ptAxis{"ptAxis", {1000, 0.0, 10.0}, "p_{T} (GeV/#it{c})"}; - ConfigurableAxis ptCutAxis{"ptCutAxis", {100, 0.0, 0.1}, "p_{T} (GeV/#it{c})"}; - ConfigurableAxis pt2Axis{"pt2Axis", {100, 0.0, 0.01}, "p_{T}^{2} (GeV^{2}/#it{c}^{2})"}; - ConfigurableAxis etaAxis{"etaAxis", {800, -4.0, 4.0}, "#eta"}; - ConfigurableAxis etaCutAxis{"etaCutAxis", {180, -0.9, 0.9}, "#eta"}; - ConfigurableAxis yAxis{"yAxis", {400, -4.0, 4.0}, "y"}; - ConfigurableAxis yCutAxis{"yCutAxis", {180, -0.9, 0.9}, "y"}; - ConfigurableAxis phiAxis{"phiAxis", {180, 0.0, o2::constants::math::TwoPI}, "#phi"}; - ConfigurableAxis phiAsymmAxis{"phiAsymmAxis", {182, -o2::constants::math::PI, o2::constants::math::PI}, "#phi"}; - ConfigurableAxis momentumFromPhiAxis{"momentumFromPhiAxis", {400, -0.1, 0.1}, "p (GeV/#it{c})"}; - // ConfigurableAxis ptQuantileAxis{"ptQuantileAxis", {0, 0.0181689, 0.0263408, 0.0330488, 0.0390369, 0.045058, 0.0512604, 0.0582598, 0.066986, 0.0788085, 0.1}, "p_{T} (GeV/#it{c})"}; - - HistogramRegistry QC{"QC", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry Pions{"Pions", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry System{"System", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry MC{"MC", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry FourPiQA{"4piQA", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable tracksMinTpcNClsCrossedRowsCut{"tracksMinTpcNClsCrossedRowsCut", 130, "min TPC crossed rows cut"}; + Configurable tracksMinTpcChi2NClCut{"tracksMinTpcChi2NClCut", 1.0, "min TPC chi2/Ncls cut"}; + Configurable tracksMaxTpcChi2NClCut{"tracksMaxTpcChi2NClCut", 3.0, "max TPC chi2/Ncls cut"}; + Configurable tracksMinTpcNClsCrossedOverFindableCut{"tracksMinTpcNClsCrossedOverFindableCut", 1.0, "min TPC crossed rows / findable clusters cut"}; + Configurable tracksMinPtCut{"tracksMinPtCut", 0.1, "min pT cut on tracks"}; + + Configurable systemMassMinCut{"systemMassMinCut", 0.5, "min M cut for reco system"}; + Configurable systemMassMaxCut{"systemMassMaxCut", 1.0, "max M cut for reco system"}; + Configurable systemPtCut{"systemPtCut", 0.1, "max pT cut for reco system"}; + Configurable systemYCut{"systemYCut", 0.9, "rapiditiy cut for reco system"}; + + ConfigurableAxis mAxis{"mAxis", {1000, 0.0, 10.0}, "#it{m} (GeV/#it{c}^{2})"}; + ConfigurableAxis ptAxis{"ptAxis", {1000, 0.0, 10.0}, "#it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis pt2Axis{"pt2Axis", {1000, 0.0, 0.1}, "#it{p}_{T}^{2} (GeV^{2}/#it{c}^{2})"}; + ConfigurableAxis etaAxis{"etaAxis", {300, -1.5, 1.5}, "#it{#eta}"}; + ConfigurableAxis yAxis{"yAxis", {400, -4.0, 4.0}, "#it{y}"}; + ConfigurableAxis phiAxis{"phiAxis", {180, 0.0, o2::constants::math::TwoPI}, "#it{#phi} (rad)"}; + ConfigurableAxis deltaPhiAxis{"deltaPhiAxis", {182, -o2::constants::math::PI, o2::constants::math::PI}, "#Delta#it{#phi} (rad)"}; + ConfigurableAxis znCommonEnergyAxis{"znCommonEnergyAxis", {250, -5.0, 20.0}, "ZN common energy (TeV)"}; + ConfigurableAxis znTimeAxis{"znTimeAxis", {200, -10.0, 10.0}, "ZN time (ns)"}; + ConfigurableAxis runNumberAxis{"runNumberAxis", {1355, 544012.5, 545367.5}, "run number"}; + ConfigurableAxis nSigmaAxis{"nSigmaAxis", {600, -30.0, 30.0}, "TPC #it{n#sigma}"}; + + HistogramRegistry rQC{"rQC", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry rTracks{"rTracks", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry rSystem{"rSystem", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry rMC{"rMC", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(o2::framework::InitContext&) { // QA // // collisions - QC.add("QC/collisions/all/hPosXY", ";x (cm);y (cm);counts", kTH2D, {{2000, -0.1, 0.1}, {2000, -0.1, 0.1}}); - QC.add("QC/collisions/all/hPosZ", ";z (cm);counts", kTH1D, {{400, -20.0, 20.0}}); - QC.add("QC/collisions/all/hNumContrib", ";number of contributors;counts", kTH1D, {{36, -0.5, 35.5}}); - QC.add("QC/collisions/all/hZdcCommonEnergy", ";ZNA common energy;ZNC common energy;counts", kTH2D, {{250, -5.0, 20.0}, {250, -5.0, 20.0}}); - QC.add("QC/collisions/all/hZdcTime", ";ZNA time (ns);ZNC time (ns);counts", kTH2D, {{200, -10.0, 10.0}, {200, -10.0, 10.0}}); - QC.add("QC/collisions/all/hTotalFT0AmplitudeA", ";FT0A amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/all/hTotalFT0AmplitudeC", ";FT0C amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/all/hTotalFV0AmplitudeA", ";FV0A amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/all/hTotalFDDAmplitudeA", ";FDDA amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/all/hTotalFDDAmplitudeC", ";FDDC amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/all/hTimeFT0A", ";FT0A time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); - QC.add("QC/collisions/all/hTimeFT0C", ";FT0C time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); - QC.add("QC/collisions/all/hTimeFV0A", ";FV0A time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); - QC.add("QC/collisions/all/hTimeFDDA", ";FDDA time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); - QC.add("QC/collisions/all/hTimeFDDC", ";FDDC time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); + rQC.add("QC/collisions/all/hPosXY", ";vertex #it{x} (cm);vertex #it{y} (cm);counts", kTH2D, {{2000, -0.1, 0.1}, {2000, -0.1, 0.1}}); + rQC.add("QC/collisions/all/hPosZ", ";vertex #it{z} (cm);counts", kTH1D, {{400, -20.0, 20.0}}); + rQC.add("QC/collisions/all/hNumContrib", ";number of PV contributors;counts", kTH1D, {{36, -0.5, 35.5}}); + rQC.add("QC/collisions/all/hZdcCommonEnergy", ";ZNA common energy (TeV);ZNC common energy (TeV);counts", kTH2D, {znCommonEnergyAxis, znCommonEnergyAxis}); + rQC.add("QC/collisions/all/hZdcTime", ";ZNA time (ns);ZNC time (ns);counts", kTH2D, {znTimeAxis, znTimeAxis}); + rQC.add("QC/collisions/all/hTotalFT0AmplitudeA", ";FT0A amplitude;counts", kTH1D, {{160, 0.0, 160.0}}); + rQC.add("QC/collisions/all/hTotalFT0AmplitudeC", ";FT0C amplitude;counts", kTH1D, {{160, 0.0, 160.0}}); + rQC.add("QC/collisions/all/hTotalFV0AmplitudeA", ";FV0A amplitude;counts", kTH1D, {{300, 0.0, 300.0}}); + rQC.add("QC/collisions/all/hTotalFDDAmplitudeA", ";FDDA amplitude;counts", kTH1D, {{160, 0.0, 160.0}}); + rQC.add("QC/collisions/all/hTotalFDDAmplitudeC", ";FDDC amplitude;counts", kTH1D, {{50, 0.0, 50.0}}); + rQC.add("QC/collisions/all/hTimeFT0A", ";FT0A time (ns);counts", kTH1D, {{500, -10.0, 40.0}}); + rQC.add("QC/collisions/all/hTimeFT0C", ";FT0C time (ns);counts", kTH1D, {{500, -10.0, 40.0}}); + rQC.add("QC/collisions/all/hTimeFV0A", ";FV0A time (ns);counts", kTH1D, {{500, -10.0, 40.0}}); + rQC.add("QC/collisions/all/hTimeFDDA", ";FDDA time (ns);counts", kTH1D, {{500, -10.0, 40.0}}); + rQC.add("QC/collisions/all/hTimeFDDC", ";FDDC time (ns);counts", kTH1D, {{500, -10.0, 40.0}}); // events with selected rho candidates - QC.add("QC/collisions/selected/hPosXY", ";x (cm);y (cm);counts", kTH2D, {{2000, -0.1, 0.1}, {2000, -0.1, 0.1}}); - QC.add("QC/collisions/selected/hPosZ", ";z (cm);counts", kTH1D, {{400, -20.0, 20.0}}); - QC.add("QC/collisions/selected/hNumContrib", ";number of contributors;counts", kTH1D, {{36, -0.5, 35.5}}); - QC.add("QC/collisions/selected/hZdcCommonEnergy", ";ZNA common energy;ZNC common energy;counts", kTH2D, {{250, -5.0, 20.0}, {250, -5.0, 20.0}}); - QC.add("QC/collisions/selected/hZdcTime", ";ZNA time (ns);ZNC time (ns);counts", kTH2D, {{200, -10.0, 10.0}, {200, -10.0, 10.0}}); - QC.add("QC/collisions/selected/hTotalFT0AmplitudeA", ";FT0A amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/selected/hTotalFT0AmplitudeC", ";FT0C amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/selected/hTotalFV0AmplitudeA", ";FV0A amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/selected/hTotalFDDAmplitudeA", ";FDDA amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/selected/hTotalFDDAmplitudeC", ";FDDC amplitude;counts", kTH1D, {{1000, 0.0, 1000.0}}); - QC.add("QC/collisions/selected/hTimeFT0A", ";FT0A time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); - QC.add("QC/collisions/selected/hTimeFT0C", ";FT0C time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); - QC.add("QC/collisions/selected/hTimeFV0A", ";FV0A time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); - QC.add("QC/collisions/selected/hTimeFDDA", ";FDDA time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); - QC.add("QC/collisions/selected/hTimeFDDC", ";FDDC time (ns);counts", kTH1D, {{200, -100.0, 100.0}}); - // all tracks - QC.add("QC/tracks/raw/hTpcNSigmaPi", ";TPC n#sigma_{#pi};counts", kTH1D, {{400, -10.0, 30.0}}); - QC.add("QC/tracks/raw/hTofNSigmaPi", ";TOF n#sigma_{#pi};counts", kTH1D, {{400, -20.0, 20.0}}); - QC.add("QC/tracks/raw/hTpcNSigmaEl", ";TPC n#sigma_{e};counts", kTH1D, {{400, -10.0, 30.0}}); - QC.add("QC/tracks/raw/hDcaXYZ", ";DCA_{z} (cm);DCA_{xy} (cm);counts", kTH2D, {{1000, -5.0, 5.0}, {1000, -5.0, 5.0}}); - QC.add("QC/tracks/raw/hItsNCls", ";ITS N_{cls};counts", kTH1D, {{11, -0.5, 10.5}}); - QC.add("QC/tracks/raw/hItsChi2NCl", ";ITS #chi^{2}/N_{cls};counts", kTH1D, {{1000, 0.0, 100.0}}); - QC.add("QC/tracks/raw/hTpcChi2NCl", ";TPC #chi^{2}/N_{cls};counts", kTH1D, {{1000, 0.0, 100.0}}); - QC.add("QC/tracks/raw/hTpcNCls", ";TPC N_{cls} found;counts", kTH1D, {{200, 0.0, 200.0}}); - QC.add("QC/tracks/raw/hTpcNClsCrossedRows", ";TPC crossed rows;counts", kTH1D, {{200, 0.0, 200.0}}); - QC.add("QC/tracks/raw/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - QC.add("QC/tracks/raw/hEta", ";y;counts", kTH1D, {etaAxis}); - QC.add("QC/tracks/raw/hPhi", ";#phi;counts", kTH1D, {phiAxis}); // tracks passing selections - QC.add("QC/tracks/cut/hTpcNSigmaPi2D", ";TPC n#sigma(#pi_{leading});TPC n#sigma(#pi_{subleading});counts", kTH2D, {{400, -10.0, 30.0}, {400, -10.0, 30.0}}); - QC.add("QC/tracks/cut/hTpcNSigmaEl2D", ";TPC n#sigma(e_{leading});TPC n#sigma(e_{subleading});counts", kTH2D, {{400, -10.0, 30.0}, {400, -10.0, 30.0}}); - QC.add("QC/tracks/cut/hTpcSignalVsP", ";p (GeV/#it{c});TPC signal;counts", kTH2D, {ptAxis, {500, 0.0, 500.0}}); - QC.add("QC/tracks/cut/hTpcSignalVsPt", ";p_{T} (GeV/#it{c});TPC signal;counts", kTH2D, {ptAxis, {500, 0.0, 500.0}}); - QC.add("QC/tracks/cut/hRemainingTracks", ";remaining tracks;counts", kTH1D, {{21, -0.5, 20.5}}); - QC.add("QC/tracks/cut/hDcaXYZ", ";DCA_{z} (cm);DCA_{xy} (cm);counts", kTH2D, {{1000, -5.0, 5.0}, {1000, -5.0, 5.0}}); + rQC.addClone("QC/collisions/all/", "QC/collisions/trackSelections/"); // clone "all" histograms as "selected" + rQC.addClone("QC/collisions/all/", "QC/collisions/systemSelections/"); + + // tracks + rQC.add("QC/tracks/all/hTpcNSigmaPi", ";TPC #it{n#sigma}(#pi);counts", kTH1D, {nSigmaAxis}); + rQC.add("QC/tracks/all/hTpcNSigmaEl", ";TPC #it{n#sigma}(e);counts", kTH1D, {nSigmaAxis}); + rQC.add("QC/tracks/all/hTpcNSigmaKa", ";TPC #it{n#sigma}(K);counts", kTH1D, {nSigmaAxis}); + rQC.add("QC/tracks/all/hDcaXYZ", ";track #it{DCA}_{z} (cm);track #it{DCA}_{xy} (cm);counts", kTH2D, {{1000, -5.0, 5.0}, {400, -2.0, 2.0}}); + rQC.add("QC/tracks/all/hItsNCls", ";ITS #it{N}_{cls};counts", kTH1D, {{11, -0.5, 10.5}}); + rQC.add("QC/tracks/all/hItsChi2NCl", ";ITS #it{#chi}^{2}/#it{N}_{cls};counts", kTH1D, {{200, 0.0, 20.0}}); + rQC.add("QC/tracks/all/hTpcChi2NCl", ";TPC #it{#chi}^{2}/#it{N}_{cls};counts", kTH1D, {{200, 0.0, 20.0}}); + rQC.add("QC/tracks/all/hTpcNCls", ";found TPC #it{N}_{cls};counts", kTH1D, {{160, 0.0, 160.0}}); // tpcNClsFindable() - track.tpcNClsFindableMinusFound + rQC.add("QC/tracks/all/hTpcNClsCrossedRows", ";TPC crossed rows;counts", kTH1D, {{160, 0.0, 160.0}}); + rQC.add("QC/tracks/all/hTpcNClsCrossedRowsOverNClsFindable", ";TPC crossed rows/findable #it{N}_{cls};counts", kTH1D, {{300, 0.5, 2.5}}); + rQC.add("QC/tracks/all/hPt", ";#it{p}_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); + rQC.add("QC/tracks/all/hEta", ";#it{#eta};counts", kTH1D, {etaAxis}); + rQC.add("QC/tracks/all/hPhi", ";#it{#phi};counts", kTH1D, {phiAxis}); + rQC.add("QC/tracks/all/hTpcSignalVsP", ";|#it{p}| (GeV/#it{c});TPC d#it{E}/d#it{x} signal (arb. units);counts", kTH2D, {ptAxis, {500, 0.0, 500.0}}); + rQC.add("QC/tracks/all/hTpcSignalVsPt", ";#it{p}_{T} (GeV/#it{c});TPC d#it{E}/d#it{x} signal (arb. units);counts", kTH2D, {ptAxis, {500, 0.0, 500.0}}); + // tracks passing selections + rQC.addClone("QC/tracks/all/", "QC/tracks/trackSelections/"); // clone "raw" histograms as "cut" + rQC.addClone("QC/tracks/all/", "QC/tracks/systemSelections/"); + rQC.add("QC/tracks/trackSelections/hRemainingTracks", ";remaining tracks;counts", kTH1D, {{21, -0.5, 20.5}}); + rQC.add("QC/tracks/trackSelections/hTpcNSigmaPi2D", ";TPC #it{n#sigma}(#pi)_{leading};TPC #it{n#sigma}(#pi)_{subleading};counts", kTH2D, {nSigmaAxis, nSigmaAxis}); + rQC.add("QC/tracks/trackSelections/hTpcNSigmaEl2D", ";TPC #it{n#sigma}(e)_{leading};TPC #it{n#sigma}(e)_{subleading};counts", kTH2D, {nSigmaAxis, nSigmaAxis}); + rQC.add("QC/tracks/trackSelections/hTpcNSigmaKa2D", ";TPC #it{n#sigma}(K)_{leading};TPC #it{n#sigma}(K)_{subleading};counts", kTH2D, {nSigmaAxis, nSigmaAxis}); // selection counter - std::vector selectionCounterLabels = {"all tracks", "PV contributor", "ITS hit", "ITS N_{clusters}", "ITS #chi^{2}/N_{clusters}", "TPC hit", "TPC N_{clusters} found", "TPC #chi^{2}/N_{clusters}", "TPC crossed rows", - "TPC crossed rows/N_{clusters}", + std::vector selectionCounterLabels = {"all tracks", "PV contributor", "ITS hit", "ITS #it{N}_{cls}", "itsClusterMap check", "ITS #it{#chi}^{2}/#it{N}_{cls}", "TPC hit", "found TPC #it{N}_{cls}", "TPC #it{#chi}^{2}/#it{N}_{cls}", "TPC crossed rows", + "TPC crossed rows/#it{N}_{cls}", "TOF requirement", - "p_{T}", "DCA", "#eta", "exactly 2 tracks", "PID"}; - auto hSelectionCounter = QC.add("QC/tracks/hSelectionCounter", ";;counts", kTH1D, {{static_cast(selectionCounterLabels.size()), -0.5, static_cast(selectionCounterLabels.size()) - 0.5}}); - for (int i = 0; i < static_cast(selectionCounterLabels.size()); ++i) - hSelectionCounter->GetXaxis()->SetBinLabel(i + 1, selectionCounterLabels[i].c_str()); - // TOF hit check - QC.add("QC/tracks/hTofHitCheck", ";leading track TOF hit;subleading track TOF hit;counts", kTH2D, {{2, -0.5, 1.5}, {2, -0.5, 1.5}}); - // RECO HISTOS // - // PIONS - // no selection - Pions.add("pions/no-selection/unlike-sign/hPt", ";p_{T}(#pi_{leading}) (GeV/#it{c});p_{T}(#pi_{subleading}) (GeV/#it{c});counts", kTH2D, {ptAxis, ptAxis}); - Pions.add("pions/no-selection/unlike-sign/hEta", ";#eta(#pi_{leading});#eta(#pi_{subleading});counts", kTH2D, {etaCutAxis, etaCutAxis}); - Pions.add("pions/no-selection/unlike-sign/hPhi", ";#phi(#pi_{leading});#phi(#pi_{subleading});counts", kTH2D, {phiAxis, phiAxis}); - Pions.add("pions/no-selection/like-sign/hPt", ";p_{T}(#pi_{leading}) (GeV/#it{c});p_{T}(#pi_{subleading}) (GeV/#it{c});counts", kTH2D, {ptAxis, ptAxis}); - Pions.add("pions/no-selection/like-sign/hEta", ";#eta(#pi_{leading});#eta(#pi_{subleading});counts", kTH2D, {etaCutAxis, etaCutAxis}); - Pions.add("pions/no-selection/like-sign/hPhi", ";#phi(#pi_{leading});#phi(#pi_{subleading});counts", kTH2D, {phiAxis, phiAxis}); - // selected - Pions.add("pions/selected/unlike-sign/hPt", ";p_{T}(#pi_{leading}) (GeV/#it{c});p_{T}(#pi_{subleading}) (GeV/#it{c});counts", kTH2D, {ptAxis, ptAxis}); - Pions.add("pions/selected/unlike-sign/hEta", ";#eta(#pi_{leading});#eta(#pi_{subleading});counts", kTH2D, {etaCutAxis, etaCutAxis}); - Pions.add("pions/selected/unlike-sign/hPhi", ";#phi(#pi_{leading});#phi(#pi_{subleading});counts", kTH2D, {phiAxis, phiAxis}); - Pions.add("pions/selected/like-sign/hPt", ";p_{T}(#pi_{leading}) (GeV/#it{c});p_{T}(#pi_{subleading}) (GeV/#it{c});counts", kTH2D, {ptAxis, ptAxis}); - Pions.add("pions/selected/like-sign/hEta", ";#eta(#pi_{leading});#eta(#pi_{subleading});counts", kTH2D, {etaCutAxis, etaCutAxis}); - Pions.add("pions/selected/like-sign/hPhi", ";#phi(#pi_{leading});#phi(#pi_{subleading});counts", kTH2D, {phiAxis, phiAxis}); - - // RAW RHOS - System.add("system/raw/unlike-sign/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); - System.add("system/raw/unlike-sign/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - System.add("system/raw/unlike-sign/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mAxis, ptAxis}); - System.add("system/raw/unlike-sign/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/raw/unlike-sign/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - System.add("system/raw/like-sign/positive/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); - System.add("system/raw/like-sign/positive/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - System.add("system/raw/like-sign/positive/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mAxis, ptAxis}); - System.add("system/raw/like-sign/positive/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/raw/like-sign/positive/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - System.add("system/raw/like-sign/negative/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); - System.add("system/raw/like-sign/negative/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - System.add("system/raw/like-sign/negative/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mAxis, ptAxis}); - System.add("system/raw/like-sign/negative/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/raw/like-sign/negative/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - - // SELECTED RHOS - // no selection - System.add("system/cut/no-selection/unlike-sign/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/no-selection/unlike-sign/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/no-selection/unlike-sign/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/no-selection/unlike-sign/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/no-selection/unlike-sign/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/no-selection/unlike-sign/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - System.add("system/cut/no-selection/unlike-sign/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/no-selection/unlike-sign/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/no-selection/unlike-sign/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/no-selection/unlike-sign/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/no-selection/unlike-sign/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/no-selection/unlike-sign/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/no-selection/like-sign/positive/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/no-selection/like-sign/positive/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/no-selection/like-sign/positive/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/no-selection/like-sign/positive/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/no-selection/like-sign/positive/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/no-selection/like-sign/positive/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - System.add("system/cut/no-selection/like-sign/positive/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/no-selection/like-sign/positive/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/no-selection/like-sign/positive/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/no-selection/like-sign/positive/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/no-selection/like-sign/positive/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/no-selection/like-sign/positive/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/no-selection/like-sign/negative/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/no-selection/like-sign/negative/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/no-selection/like-sign/negative/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/no-selection/like-sign/negative/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/no-selection/like-sign/negative/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/no-selection/like-sign/negative/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - System.add("system/cut/no-selection/like-sign/negative/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/no-selection/like-sign/negative/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/no-selection/like-sign/negative/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/no-selection/like-sign/negative/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/no-selection/like-sign/negative/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/no-selection/like-sign/negative/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - // 0n0n - System.add("system/cut/0n0n/unlike-sign/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/0n0n/unlike-sign/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/0n0n/unlike-sign/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/0n0n/unlike-sign/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/0n0n/unlike-sign/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/0n0n/unlike-sign/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - System.add("system/cut/0n0n/unlike-sign/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0n0n/unlike-sign/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0n0n/unlike-sign/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0n0n/unlike-sign/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0n0n/unlike-sign/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/0n0n/unlike-sign/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/0n0n/like-sign/positive/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/0n0n/like-sign/positive/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/0n0n/like-sign/positive/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/0n0n/like-sign/positive/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/0n0n/like-sign/positive/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/0n0n/like-sign/positive/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/positive/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/positive/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/positive/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/positive/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/positive/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/0n0n/like-sign/positive/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/0n0n/like-sign/negative/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/0n0n/like-sign/negative/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/0n0n/like-sign/negative/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/0n0n/like-sign/negative/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/0n0n/like-sign/negative/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/0n0n/like-sign/negative/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/negative/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/negative/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/negative/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/negative/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0n0n/like-sign/negative/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/0n0n/like-sign/negative/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - // Xn0n - System.add("system/cut/Xn0n/unlike-sign/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/Xn0n/unlike-sign/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/Xn0n/unlike-sign/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/Xn0n/unlike-sign/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/Xn0n/unlike-sign/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/Xn0n/unlike-sign/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/Xn0n/unlike-sign/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/Xn0n/unlike-sign/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/Xn0n/unlike-sign/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/Xn0n/unlike-sign/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/Xn0n/unlike-sign/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/Xn0n/unlike-sign/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/Xn0n/like-sign/positive/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/Xn0n/like-sign/positive/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/Xn0n/like-sign/positive/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/Xn0n/like-sign/negative/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/Xn0n/like-sign/negative/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/Xn0n/like-sign/negative/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - // 0nXn - System.add("system/cut/0nXn/unlike-sign/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/0nXn/unlike-sign/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/0nXn/unlike-sign/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/0nXn/unlike-sign/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/0nXn/unlike-sign/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/0nXn/unlike-sign/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0nXn/unlike-sign/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0nXn/unlike-sign/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0nXn/unlike-sign/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0nXn/unlike-sign/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0nXn/unlike-sign/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/0nXn/unlike-sign/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/0nXn/like-sign/positive/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/0nXn/like-sign/positive/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/0nXn/like-sign/positive/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/0nXn/like-sign/positive/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/0nXn/like-sign/positive/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/0nXn/like-sign/positive/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/positive/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/positive/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/positive/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/positive/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/positive/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/0nXn/like-sign/positive/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/0nXn/like-sign/negative/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/0nXn/like-sign/negative/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/0nXn/like-sign/negative/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/0nXn/like-sign/negative/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/0nXn/like-sign/negative/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/0nXn/like-sign/negative/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/negative/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/negative/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/negative/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/negative/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/0nXn/like-sign/negative/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/0nXn/like-sign/negative/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - // XnXn - System.add("system/cut/XnXn/unlike-sign/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/XnXn/unlike-sign/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/XnXn/unlike-sign/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/XnXn/unlike-sign/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/XnXn/unlike-sign/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/XnXn/unlike-sign/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/XnXn/unlike-sign/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/XnXn/unlike-sign/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/XnXn/unlike-sign/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/XnXn/unlike-sign/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/XnXn/unlike-sign/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/XnXn/unlike-sign/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/XnXn/like-sign/positive/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/XnXn/like-sign/positive/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/XnXn/like-sign/positive/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/XnXn/like-sign/positive/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/XnXn/like-sign/positive/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/XnXn/like-sign/positive/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/positive/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/positive/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/positive/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/positive/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/positive/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/XnXn/like-sign/positive/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - - System.add("system/cut/XnXn/like-sign/negative/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mCutAxis}); - System.add("system/cut/XnXn/like-sign/negative/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptCutAxis}); - System.add("system/cut/XnXn/like-sign/negative/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - System.add("system/cut/XnXn/like-sign/negative/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mCutAxis, ptCutAxis}); - System.add("system/cut/XnXn/like-sign/negative/hY", ";y;counts", kTH1D, {yAxis}); - System.add("system/cut/XnXn/like-sign/negative/hPhi", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/negative/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/negative/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/negative/hPhiRandomVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/negative/hPhiChargeVsM", ";m (GeV/#it{c}^{2});#phi;counts", kTH2D, {mCutAxis, phiAsymmAxis}); - System.add("system/cut/XnXn/like-sign/negative/hPyVsPxRandom", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); - System.add("system/cut/XnXn/like-sign/negative/hPyVsPxCharge", ";p_{x} (GeV/#it{c});p_{y} (GeV/#it{c});counts", kTH2D, {momentumFromPhiAxis, momentumFromPhiAxis}); + "#it{p}_{T}", "#it{DCA}", "#it{#eta}", "exactly 2 tracks", "PID"}; + rQC.add("QC/tracks/hSelectionCounter", ";;tracks passing selections", kTH1D, {{static_cast(selectionCounterLabels.size()), -0.5, static_cast(selectionCounterLabels.size()) - 0.5}}); + rQC.add("QC/tracks/hSelectionCounterPerRun", ";;run number;tracks passing selections", kTH2D, {{static_cast(selectionCounterLabels.size()), -0.5, static_cast(selectionCounterLabels.size()) - 0.5}, runNumberAxis}); + for (int i = 0; i < static_cast(selectionCounterLabels.size()); ++i) { + rQC.get(HIST("QC/tracks/hSelectionCounter"))->GetXaxis()->SetBinLabel(i + 1, selectionCounterLabels[i].c_str()); + rQC.get(HIST("QC/tracks/hSelectionCounterPerRun"))->GetXaxis()->SetBinLabel(i + 1, selectionCounterLabels[i].c_str()); + } + rQC.add("QC/tracks/hTofHitCheck", ";leading track TOF hit;subleading track TOF hit;counts", kTH2D, {{2, -0.5, 1.5}, {2, -0.5, 1.5}}); + rQC.get(HIST("QC/tracks/hTofHitCheck"))->GetXaxis()->SetBinLabel(1, "no hit"); + rQC.get(HIST("QC/tracks/hTofHitCheck"))->GetXaxis()->SetBinLabel(2, "hit"); + rQC.get(HIST("QC/tracks/hTofHitCheck"))->GetYaxis()->SetBinLabel(1, "no hit"); + rQC.get(HIST("QC/tracks/hTofHitCheck"))->GetYaxis()->SetBinLabel(2, "hit"); + + // TRACKS (2D) + rTracks.add("tracks/trackSelections/unlike-sign/hPt", ";#it{p}_{T leading} (GeV/#it{c});#it{p}_{T subleading} (GeV/#it{c});counts", kTH2D, {ptAxis, ptAxis}); + rTracks.add("tracks/trackSelections/unlike-sign/hEta", ";#it{#eta}_{leading};#it{#eta}_{subleading};counts", kTH2D, {etaAxis, etaAxis}); + rTracks.add("tracks/trackSelections/unlike-sign/hPhi", ";#it{#phi}_{leading};#it{#phi}_{subleading};counts", kTH2D, {phiAxis, phiAxis}); + rTracks.addClone("tracks/trackSelections/unlike-sign/", "tracks/trackSelections/like-sign/positive/"); + rTracks.addClone("tracks/trackSelections/unlike-sign/", "tracks/trackSelections/like-sign/negative/"); + rTracks.addClone("tracks/trackSelections/", "tracks/systemSelections/"); + + // SYSTEM + rSystem.add("system/all/unlike-sign/hM", ";#it{m} (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); + rSystem.add("system/all/unlike-sign/hPt", ";#it{p}_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); + rSystem.add("system/all/unlike-sign/hPt2", ";#it{p}_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); + rSystem.add("system/all/unlike-sign/hPtVsM", ";#it{m} (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c});counts", kTH2D, {mAxis, ptAxis}); + rSystem.add("system/all/unlike-sign/hY", ";#it{y};counts", kTH1D, {yAxis}); + rSystem.add("system/all/unlike-sign/hPhi", ";#it{#phi};counts", kTH1D, {phiAxis}); + rSystem.add("system/all/unlike-sign/hPhiRandom", ";#Delta#it{#phi}_{random};counts", kTH1D, {deltaPhiAxis}); + rSystem.add("system/all/unlike-sign/hPhiCharge", ";#Delta#it{#phi}_{charge};counts", kTH1D, {deltaPhiAxis}); + rSystem.add("system/all/unlike-sign/hPhiRandomVsM", ";#it{m} (GeV/#it{c}^{2});#Delta#it{#phi}_{random};counts", kTH2D, {mAxis, deltaPhiAxis}); + rSystem.add("system/all/unlike-sign/hPhiChargeVsM", ";#it{m} (GeV/#it{c}^{2});#Delta#it{#phi}_{charge};counts", kTH2D, {mAxis, deltaPhiAxis}); + // clones for like-sign + rSystem.addClone("system/all/unlike-sign/", "system/all/like-sign/positive/"); + rSystem.addClone("system/all/unlike-sign/", "system/all/like-sign/negative/"); + // selected rhos + rSystem.addClone("system/all/", "system/selected/no-selection/"); + // clones for neutron classes + rSystem.addClone("system/selected/no-selection/", "system/selected/0n0n/"); + rSystem.addClone("system/selected/no-selection/", "system/selected/Xn0n/"); + rSystem.addClone("system/selected/no-selection/", "system/selected/0nXn/"); + rSystem.addClone("system/selected/no-selection/", "system/selected/XnXn/"); // MC - MC.add("MC/collisions/hPosXY", ";x (cm);y (cm);counts", kTH2D, {{2000, -0.1, 0.1}, {2000, -0.1, 0.1}}); - MC.add("MC/collisions/hPosZ", ";z (cm);counts", kTH1D, {{400, -20.0, 20.0}}); - MC.add("MC/collisions/hNPions", ";number of pions;counts", kTH1D, {{11, -0.5, 10.5}}); - MC.add("MC/collisions/hNumOfCollisionRecos", ";number of collision reconstructions;counts", kTH1D, {{11, -0.5, 10.5}}); - - MC.add("MC/tracks/all/hPdgCode", ";pdg code;counts", kTH1D, {{2001, -1000.5, 1000.5}}); - MC.add("MC/tracks/all/hProducedByGenerator", ";produced by generator;counts", kTH1D, {{2, -0.5, 1.5}}); - MC.add("MC/tracks/all/hIsPhysicalPrimary", ";is physical primary;counts", kTH1D, {{2, -0.5, 1.5}}); - MC.add("MC/tracks/all/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - MC.add("MC/tracks/all/hEta", ";#eta;counts", kTH1D, {etaAxis}); - MC.add("MC/tracks/all/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - MC.add("MC/tracks/pions/hPt", ";p_{T}(#pi_{leading}) (GeV/#it{c});p_{T}(#pi_{subleading}) (GeV/#it{c});counts", kTH2D, {ptAxis, ptAxis}); - MC.add("MC/tracks/pions/hEta", ";#eta(#pi_{leading});#eta(#pi_{subleading});counts", kTH2D, {etaAxis, etaAxis}); - MC.add("MC/tracks/pions/hPhi", ";#phi(#pi_{leading});#phi(#pi_{subleading});counts", kTH2D, {phiAxis, phiAxis}); - - MC.add("MC/system/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); - MC.add("MC/system/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - MC.add("MC/system/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); - MC.add("MC/system/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mAxis, ptAxis}); - MC.add("MC/system/hY", ";y;counts", kTH1D, {yAxis}); - MC.add("MC/system/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - MC.add("MC/system/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); - MC.add("MC/system/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); - - // 4 pi QA - if (do4pi) { - FourPiQA.add("FourPiQA/reco/tracks/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - FourPiQA.add("FourPiQA/reco/tracks/hEta", ";#eta;counts", kTH1D, {etaAxis}); - FourPiQA.add("FourPiQA/reco/tracks/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - FourPiQA.add("FourPiQA/reco/system/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); - FourPiQA.add("FourPiQA/reco/system/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - FourPiQA.add("FourPiQA/reco/system/hY", ";y;counts", kTH1D, {yAxis}); - FourPiQA.add("FourPiQA/reco/system/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - FourPiQA.add("FourPiQA/MC/tracks/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - FourPiQA.add("FourPiQA/MC/tracks/hEta", ";#eta;counts", kTH1D, {etaAxis}); - FourPiQA.add("FourPiQA/MC/tracks/hPhi", ";#phi;counts", kTH1D, {phiAxis}); - FourPiQA.add("FourPiQA/MC/system/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); - FourPiQA.add("FourPiQA/MC/system/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); - FourPiQA.add("FourPiQA/MC/system/hY", ";y;counts", kTH1D, {yAxis}); - FourPiQA.add("FourPiQA/MC/system/hPhi", ";#phi;counts", kTH1D, {phiAxis}); + // collisions + rMC.add("MC/collisions/hPosXY", ";vertex #it{x} (cm);vertex #it{y} (cm);counts", kTH2D, {{2000, -0.1, 0.1}, {2000, -0.1, 0.1}}); + rMC.add("MC/collisions/hPosZ", ";vertex #it{z} (cm);counts", kTH1D, {{400, -20.0, 20.0}}); + rMC.add("MC/collisions/hNPions", ";number of pions;counts", kTH1D, {{11, -0.5, 10.5}}); + rMC.add("MC/collisions/hNumOfCollisionRecos", ";number of collision reconstructions;counts", kTH1D, {{6, -0.5, 5.5}}); + rMC.add("MC/collisions/hRunNumberVsNumOfCollisionRecos", ";number of collision reconstructions;run number;counts", kTH2D, {{6, -0.5, 5.5}, runNumberAxis}); + // tracks + rMC.add("MC/tracks/all/hPdgCode", ";pdg code;counts", kTH1D, {{2001, -1000.5, 1000.5}}); + rMC.add("MC/tracks/all/hProducedByGenerator", ";produced by generator;counts", kTH1D, {{2, -0.5, 1.5}}); + rMC.add("MC/tracks/all/hIsPhysicalPrimary", ";is physical primary;counts", kTH1D, {{2, -0.5, 1.5}}); + rMC.add("MC/tracks/all/hPt", ";#it{p}_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); + rMC.add("MC/tracks/all/hEta", ";#it{#eta};counts", kTH1D, {etaAxis}); + rMC.add("MC/tracks/all/hPhi", ";#it{#phi};counts", kTH1D, {phiAxis}); + rMC.add("MC/tracks/hPt", ";#it{p}_{T leading} (GeV/#it{c});#it{p}_{T subleading} (GeV/#it{c});counts", kTH2D, {ptAxis, ptAxis}); + rMC.add("MC/tracks/hEta", ";#it{#eta}_{leading};#it{#eta}_{subleading};counts", kTH2D, {etaAxis, etaAxis}); + rMC.add("MC/tracks/hPhi", ";#it{#phi}_{leading};#it{#phi}_{subleading};counts", kTH2D, {phiAxis, phiAxis}); + // system + rMC.add("MC/system/hM", ";#it{m} (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); + rMC.add("MC/system/hPt", ";#it{p}_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); + rMC.add("MC/system/hPt2", ";#it{p}_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); + rMC.add("MC/system/hPtVsM", ";#it{m} (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c});counts", kTH2D, {mAxis, ptAxis}); + rMC.add("MC/system/hY", ";#it{y};counts", kTH1D, {yAxis}); + rMC.add("MC/system/hPhi", ";#it{#phi};counts", kTH1D, {phiAxis}); + rMC.add("MC/system/hPhiRandom", ";#Delta#it{#phi}_{random};counts", kTH1D, {deltaPhiAxis}); + rMC.add("MC/system/hPhiCharge", ";#Delta#it{#phi}_{charge};counts", kTH1D, {deltaPhiAxis}); + rMC.add("MC/system/hPhiRandomVsM", ";#it{m} (GeV/#it{c}^{2});#Delta#it{#phi};counts", kTH2D, {mAxis, deltaPhiAxis}); + rMC.add("MC/system/hPhiChargeVsM", ";#it{m} (GeV/#it{c}^{2});#Delta#it{#phi};counts", kTH2D, {mAxis, deltaPhiAxis}); + rMC.addClone("MC/system/", "MC/system/selected/"); + } + + std::unordered_set goldenRuns = {544491, 544474, 544123, 544098, 544121, 544389, 544032, 544454, 544122, + 544510, 544476, 544091, 544095, 544490, 544124, 544508, 544391, 544013, + 544390, 544184, 544451, 544116, 544185, 544492, 544475, 544392, 544477, 544028}; + + static constexpr std::string_view AppliedSelections[3] = {"all/", "trackSelections/", "systemSelections/"}; + static constexpr std::string_view ChargeLabel[3] = {"unlike-sign/", "like-sign/positive/", "like-sign/negative/"}; + static constexpr std::string_view NeutronClass[5] = {"no-selection/", "0n0n/", "Xn0n/", "0nXn/", "XnXn/"}; + + template + void fillCollisionQcHistos(const C& collision) // fills collision QC histograms before/after cuts + { + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hPosXY"), collision.posX(), collision.posY()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hPosZ"), collision.posZ()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hZdcCommonEnergy"), collision.energyCommonZNA(), collision.energyCommonZNC()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hZdcTime"), collision.timeZNA(), collision.timeZNC()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hNumContrib"), collision.numContrib()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTotalFT0AmplitudeA"), collision.totalFT0AmplitudeA()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTotalFT0AmplitudeC"), collision.totalFT0AmplitudeC()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTotalFV0AmplitudeA"), collision.totalFV0AmplitudeA()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTotalFDDAmplitudeA"), collision.totalFDDAmplitudeA()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTotalFDDAmplitudeC"), collision.totalFDDAmplitudeC()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTimeFT0A"), collision.timeFT0A()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTimeFT0C"), collision.timeFT0C()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTimeFV0A"), collision.timeFV0A()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTimeFDDA"), collision.timeFDDA()); + rQC.fill(HIST("QC/collisions/") + HIST(AppliedSelections[cuts]) + HIST("hTimeFDDC"), collision.timeFDDC()); + } + + template + void fillTrackQcHistos(const T& track) + { + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hPt"), track.pt()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hEta"), eta(track.px(), track.py(), track.pz())); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hPhi"), phi(track.px(), track.py())); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hTpcNSigmaPi"), track.tpcNSigmaPi()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hTpcNSigmaEl"), track.tpcNSigmaEl()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hTpcNSigmaKa"), track.tpcNSigmaKa()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hDcaXYZ"), track.dcaZ(), track.dcaXY()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hItsNCls"), track.itsNCls()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hItsChi2NCl"), track.itsChi2NCl()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hTpcChi2NCl"), track.tpcChi2NCl()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hTpcNCls"), (track.tpcNClsFindable() - track.tpcNClsFindableMinusFound())); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hTpcNClsCrossedRows"), track.tpcNClsCrossedRows()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hTpcNClsCrossedRowsOverNClsFindable"), (static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable()))); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hTpcSignalVsP"), std::abs(momentum(track.px(), track.py(), track.pz())), track.tpcSignal()); + rQC.fill(HIST("QC/tracks/") + HIST(AppliedSelections[cuts]) + HIST("hTpcSignalVsPt"), track.pt(), track.tpcSignal()); + } + + template + void fillTrack2dHistos(float leadingPt, float subleadingPt, float leadingEta, float subleadingEta, float leadingPhi, float subleadingPhi) + { + rTracks.fill(HIST("tracks/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPt"), leadingPt, subleadingPt); + rTracks.fill(HIST("tracks/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hEta"), leadingEta, subleadingEta); + rTracks.fill(HIST("tracks/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPhi"), leadingPhi, subleadingPhi); + } + + template + void fillSystemHistos(float mass, float pt, float rapidity, float phi, float phiRandom, float phiCharge) + { + if (cuts == 0) { + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hM"), mass); + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPt"), pt); + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPt2"), pt * pt); + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPtVsM"), mass, pt); + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hY"), rapidity); + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPhi"), phi); + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPhiRandom"), phiRandom); + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPhiCharge"), phiCharge); + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPhiRandomVsM"), mass, phiRandom); + rSystem.fill(HIST("system/") + HIST(AppliedSelections[cuts]) + HIST(ChargeLabel[charge]) + HIST("hPhiChargeVsM"), mass, phiCharge); + } else { + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hM"), mass); + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hPt"), pt); + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hPt2"), pt * pt); + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hPtVsM"), mass, pt); + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hY"), rapidity); + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hPhi"), phi); + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hPhiRandom"), phiRandom); + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hPhiCharge"), phiCharge); + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hPhiRandomVsM"), mass, phiRandom); + rSystem.fill(HIST("system/") + HIST("selected/") + HIST(NeutronClass[neutronClass]) + HIST(ChargeLabel[charge]) + HIST("hPhiChargeVsM"), mass, phiCharge); } } - template - bool trackPassesCuts(const T& track) // track cuts (PID done separately) + bool cutItsLayers(uint8_t itsClusterMap) const + { + std::vector>> requiredITSHits{}; + requiredITSHits.push_back(std::make_pair(1, std::array{0, 1, 2})); // at least one hit in the innermost layer + constexpr uint8_t kBit = 1; + for (const auto& itsRequirement : requiredITSHits) { + auto hits = std::count_if(itsRequirement.second.begin(), itsRequirement.second.end(), [&](auto&& requiredLayer) { return itsClusterMap & (kBit << requiredLayer); }); + + if ((itsRequirement.first == -1) && (hits > 0)) { + return false; // no hits were required in specified layers + } else if (hits < itsRequirement.first) { + return false; // not enough hits found in specified layers + } + } + return true; + } + + template + bool isGoodRctFlag(const C& collision) + { + switch (cutRctFlag) { + case 1: + return sgSelector.isCBTOk(collision); + case 2: + return sgSelector.isCBTZdcOk(collision); + case 3: + return sgSelector.isCBTHadronOk(collision); + case 4: + return sgSelector.isCBTHadronZdcOk(collision); + default: + return true; + } + } + + template + bool collisionPassesCuts(const C& collision) // collision cuts + { + if (!collision.vtxITSTPC() || !collision.sbp() || !collision.itsROFb() || !collision.tfb()) // not applied automatically in 2023 Pb-Pb pass5 + return false; + + if (std::abs(collision.posZ()) > collisionsPosZMaxCut) + return false; + if (cutNumContribs && (collision.numContrib() > collisionsNumContribsMaxCut)) + return false; + + if (useRctFlag && !isGoodRctFlag(collision)) // check RCT flags + return false; + if (useRecoFlag && (collision.flags() != cutRecoFlag)) // check reconstruction mode + return false; + + return true; + } + + template + bool trackPassesCuts(const T& track, const C& collision) // track cuts (PID done separately) { if (!track.isPVContributor()) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 1); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 1); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 1, collision.runNumber()); if (!track.hasITS()) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 2); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 2); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 2, collision.runNumber()); if (track.itsNCls() < tracksMinItsNClsCut) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 3); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 3); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 3, collision.runNumber()); + + if (!cutItsLayers(track.itsClusterMap())) + return false; + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 4); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 4, collision.runNumber()); if (track.itsChi2NCl() > tracksMaxItsChi2NClCut) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 4); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 5); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 5, collision.runNumber()); if (!track.hasTPC()) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 5); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 6); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 6, collision.runNumber()); if ((track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()) < tracksMinTpcNClsCut) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 6); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 7); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 7, collision.runNumber()); if (track.tpcChi2NCl() > tracksMaxTpcChi2NClCut || track.tpcChi2NCl() < tracksMinTpcChi2NClCut) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 7); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 8); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 8, collision.runNumber()); if (track.tpcNClsCrossedRows() < tracksMinTpcNClsCrossedRowsCut) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 8); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 9); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 9, collision.runNumber()); if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < tracksMinTpcNClsCrossedOverFindableCut) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 9); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 10); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 10, collision.runNumber()); if (requireTof && !track.hasTOF()) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 10); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 11); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 11, collision.runNumber()); if (track.pt() < tracksMinPtCut) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 11); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 12); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 12, collision.runNumber()); if (std::abs(track.dcaZ()) > tracksDcaMaxCut || std::abs(track.dcaXY()) > (0.0105 + 0.0350 / std::pow(track.pt(), 1.01))) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 12); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 13); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 13, collision.runNumber()); - if (std::abs(eta(track.px(), track.py(), track.pz())) > PcEtaCut) + if (std::abs(eta(track.px(), track.py(), track.pz())) > pcEtaCut) return false; - QC.fill(HIST("QC/tracks/hSelectionCounter"), 13); + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 14); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 14, collision.runNumber()); // if all selections passed return true; } template - bool tracksPassPiPID(const T& cutTracks) // n-dimensional PID cut + bool tracksPassPiPID(const T& cutTracks) // n-dimensional pion PID cut { - double radius = 0.0; + float radius = 0.0; for (const auto& track : cutTracks) radius += std::pow(track.tpcNSigmaPi(), 2); return radius < std::pow(tracksTpcNSigmaPiCut, 2); @@ -566,7 +536,7 @@ struct upcRhoAnalysis { } template - int tracksTotalChargeMC(const T& cutTracks) // total charge of selected tracks + int tracksTotalChargeMC(const T& cutTracks) // total charge of selected MC tracks { int charge = 0; for (const auto& track : cutTracks) @@ -574,7 +544,7 @@ struct upcRhoAnalysis { return charge; } - bool systemPassCuts(const TLorentzVector& system) // system cuts + bool systemPassesCuts(const ROOT::Math::PxPyPzMVector& system) // system cuts { if (system.M() < systemMassMinCut || system.M() > systemMassMaxCut) return false; @@ -585,231 +555,193 @@ struct upcRhoAnalysis { return true; } - TLorentzVector reconstructSystem(const std::vector& cutTracks4Vecs) // reconstruct system from 4-vectors + ROOT::Math::PxPyPzMVector reconstructSystem(const std::vector& cutTracksLVs) // reconstruct system from 4-vectors { - TLorentzVector system; - for (const auto& track4Vec : cutTracks4Vecs) - system += track4Vec; + ROOT::Math::PxPyPzMVector system; + for (const auto& trackLV : cutTracksLVs) + system += trackLV; return system; } - double getPhiRandom(const std::vector& cutTracks4Vecs) // decay phi anisotropy - { // two possible definitions of phi: randomize the tracks - std::vector indices = {0, 1}; - unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); // get time-based seed - std::shuffle(indices.begin(), indices.end(), std::default_random_engine(seed)); // shuffle indices + double deltaPhi(const ROOT::Math::PxPyPzMVector& p1, const ROOT::Math::PxPyPzMVector& p2) + { + double dPhi = p1.Phi() - p2.Phi(); + dPhi = std::fmod(dPhi + o2::constants::math::PI, o2::constants::math::TwoPI) - o2::constants::math::PI; // normalize to (-pi, pi) + return dPhi; + } + + float getPhiRandom(const std::vector& cutTracksLVs) // decay phi anisotropy + { // two possible definitions of phi: randomize the tracks + int indices[2] = {0, 1}; + unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); // get time-based seed + std::shuffle(std::begin(indices), std::end(indices), std::default_random_engine(seed)); // shuffle indices // calculate phi - TLorentzVector pOne = cutTracks4Vecs[indices[0]]; - TLorentzVector pTwo = cutTracks4Vecs[indices[1]]; - TLorentzVector pPlus = pOne + pTwo; - TLorentzVector pMinus = pOne - pTwo; - return pPlus.DeltaPhi(pMinus); + ROOT::Math::PxPyPzMVector pOne = cutTracksLVs[indices[0]]; + ROOT::Math::PxPyPzMVector pTwo = cutTracksLVs[indices[1]]; + ROOT::Math::PxPyPzMVector pPlus = pOne + pTwo; + ROOT::Math::PxPyPzMVector pMinus = pOne - pTwo; + return deltaPhi(pPlus, pMinus); } template - double getPhiCharge(const T& cutTracks, const std::vector& cutTracks4Vecs) + float getPhiCharge(const T& cutTracks, const std::vector& cutTracksLVs) { // two possible definitions of phi: charge-based assignment - TLorentzVector pOne, pTwo; - pOne = (cutTracks[0].sign() > 0) ? cutTracks4Vecs[0] : cutTracks4Vecs[1]; - pTwo = (cutTracks[0].sign() > 0) ? cutTracks4Vecs[1] : cutTracks4Vecs[0]; - TLorentzVector pPlus = pOne + pTwo; - TLorentzVector pMinus = pOne - pTwo; - return pPlus.DeltaPhi(pMinus); + ROOT::Math::PxPyPzMVector pOne, pTwo; + pOne = (cutTracks[0].sign() > 0) ? cutTracksLVs[0] : cutTracksLVs[1]; + pTwo = (cutTracks[0].sign() > 0) ? cutTracksLVs[1] : cutTracksLVs[0]; + ROOT::Math::PxPyPzMVector pPlus = pOne + pTwo; + ROOT::Math::PxPyPzMVector pMinus = pOne - pTwo; + return deltaPhi(pPlus, pMinus); } template - double getPhiChargeMC(const T& cutTracks, const std::vector& cutTracks4Vecs) + float getPhiChargeMC(const T& cutTracks, const std::vector& cutTracksLVs) { // the same as for data but using pdg code instead of charge - TLorentzVector pOne, pTwo; - pOne = (cutTracks[0].pdgCode() > 0) ? cutTracks4Vecs[0] : cutTracks4Vecs[1]; - pTwo = (cutTracks[0].pdgCode() > 0) ? cutTracks4Vecs[1] : cutTracks4Vecs[0]; - TLorentzVector pPlus = pOne + pTwo; - TLorentzVector pMinus = pOne - pTwo; - return pPlus.DeltaPhi(pMinus); + ROOT::Math::PxPyPzMVector pOne, pTwo; + pOne = (cutTracks[0].pdgCode() > 0) ? cutTracksLVs[0] : cutTracksLVs[1]; + pTwo = (cutTracks[0].pdgCode() > 0) ? cutTracksLVs[1] : cutTracksLVs[0]; + ROOT::Math::PxPyPzMVector pPlus = pOne + pTwo; + ROOT::Math::PxPyPzMVector pMinus = pOne - pTwo; + return deltaPhi(pPlus, pMinus); } template void processReco(C const& collision, T const& tracks) { - // QC histograms - QC.fill(HIST("QC/collisions/all/hPosXY"), collision.posX(), collision.posY()); - QC.fill(HIST("QC/collisions/all/hPosZ"), collision.posZ()); - QC.fill(HIST("QC/collisions/all/hZdcCommonEnergy"), collision.energyCommonZNA(), collision.energyCommonZNC()); - QC.fill(HIST("QC/collisions/all/hZdcTime"), collision.timeZNA(), collision.timeZNC()); - QC.fill(HIST("QC/collisions/all/hNumContrib"), collision.numContrib()); - QC.fill(HIST("QC/collisions/all/hTotalFT0AmplitudeA"), collision.totalFT0AmplitudeA()); - QC.fill(HIST("QC/collisions/all/hTotalFT0AmplitudeC"), collision.totalFT0AmplitudeC()); - QC.fill(HIST("QC/collisions/all/hTotalFV0AmplitudeA"), collision.totalFV0AmplitudeA()); - QC.fill(HIST("QC/collisions/all/hTotalFDDAmplitudeA"), collision.totalFDDAmplitudeA()); - QC.fill(HIST("QC/collisions/all/hTotalFDDAmplitudeC"), collision.totalFDDAmplitudeC()); - QC.fill(HIST("QC/collisions/all/hTimeFT0A"), collision.timeFT0A()); - QC.fill(HIST("QC/collisions/all/hTimeFT0C"), collision.timeFT0C()); - QC.fill(HIST("QC/collisions/all/hTimeFV0A"), collision.timeFV0A()); - QC.fill(HIST("QC/collisions/all/hTimeFDDA"), collision.timeFDDA()); - QC.fill(HIST("QC/collisions/all/hTimeFDDC"), collision.timeFDDC()); - - // vertex z-position cut - if (std::abs(collision.posZ()) > collisionsPosZMaxCut) + // check if the collision run number is contained within the goldenRuns set + if (onlyGoldenRuns && !goldenRuns.contains(collision.runNumber())) + return; + + fillCollisionQcHistos<0>(collision); // fill QC histograms before cuts + if (!collisionPassesCuts(collision)) return; - // event tagging - bool XnXn = false, OnOn = false, XnOn = false, OnXn = false; // note: On == 0n... int neutronClass = -1; - if (collision.energyCommonZNA() < ZNcommonEnergyCut && collision.energyCommonZNC() < ZNcommonEnergyCut) { - OnOn = true; + bool xnxn = false, onon = false, xnon = false, onxn = false; + float energyCommonZNA = collision.energyCommonZNA(), energyCommonZNC = collision.energyCommonZNC(); + float timeZNA = collision.timeZNA(), timeZNC = collision.timeZNC(); + if (std::isinf(energyCommonZNA)) + energyCommonZNA = -999; + if (std::isinf(energyCommonZNC)) + energyCommonZNC = -999; + if (std::isinf(timeZNA)) + timeZNA = -999; + if (std::isinf(timeZNC)) + timeZNC = -999; + + if (energyCommonZNA <= znCommonEnergyCut && energyCommonZNC <= znCommonEnergyCut) { + onon = true; neutronClass = 0; } - if (collision.energyCommonZNA() > ZNcommonEnergyCut && std::abs(collision.timeZNA()) < ZNtimeCut && collision.energyCommonZNC() < ZNcommonEnergyCut) { - XnOn = true; + if (energyCommonZNA > znCommonEnergyCut && std::abs(timeZNA) <= znTimeCut && energyCommonZNC <= znCommonEnergyCut) { + xnon = true; neutronClass = 1; } - if (collision.energyCommonZNA() < ZNcommonEnergyCut && collision.energyCommonZNC() > ZNcommonEnergyCut && std::abs(collision.timeZNC()) < ZNtimeCut) { - OnXn = true; + if (energyCommonZNA <= znCommonEnergyCut && energyCommonZNC > znCommonEnergyCut && std::abs(timeZNC) <= znTimeCut) { + onxn = true; neutronClass = 2; } - if (collision.energyCommonZNA() > ZNcommonEnergyCut && std::abs(collision.timeZNA()) < ZNtimeCut && - collision.energyCommonZNC() > ZNcommonEnergyCut && std::abs(collision.timeZNC()) < ZNtimeCut) { - XnXn = true; + if (energyCommonZNA > znCommonEnergyCut && std::abs(timeZNA) <= znTimeCut && + energyCommonZNC > znCommonEnergyCut && std::abs(timeZNC) <= znTimeCut) { + xnxn = true; neutronClass = 3; } - // vectors for storing selected tracks and their 4-vectors - std::vector cutTracks; - std::vector cutTracks4Vecs; + std::vector cutTracks; // store selected tracks for (const auto& track : tracks) { - // double p = momentum(track.px(), track.py(), track.pz()); - QC.fill(HIST("QC/tracks/raw/hPt"), track.pt()); - QC.fill(HIST("QC/tracks/raw/hEta"), eta(track.px(), track.py(), track.pz())); - QC.fill(HIST("QC/tracks/raw/hPhi"), phi(track.px(), track.py())); - QC.fill(HIST("QC/tracks/raw/hTpcNSigmaPi"), track.tpcNSigmaPi()); - QC.fill(HIST("QC/tracks/raw/hTofNSigmaPi"), track.tofNSigmaPi()); - QC.fill(HIST("QC/tracks/raw/hTpcNSigmaEl"), track.tpcNSigmaEl()); - QC.fill(HIST("QC/tracks/raw/hDcaXYZ"), track.dcaZ(), track.dcaXY()); - QC.fill(HIST("QC/tracks/raw/hItsNCls"), track.itsNCls()); - QC.fill(HIST("QC/tracks/raw/hItsChi2NCl"), track.itsChi2NCl()); - QC.fill(HIST("QC/tracks/raw/hTpcChi2NCl"), track.tpcChi2NCl()); - QC.fill(HIST("QC/tracks/raw/hTpcNCls"), (track.tpcNClsFindable() - track.tpcNClsFindableMinusFound())); - QC.fill(HIST("QC/tracks/raw/hTpcNClsCrossedRows"), track.tpcNClsCrossedRows()); - QC.fill(HIST("QC/tracks/hSelectionCounter"), 0); - - if (!trackPassesCuts(track)) - continue; + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 0); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 0, collision.runNumber()); + fillTrackQcHistos<0>(track); // fill QC histograms before cuts + if (!trackPassesCuts(track, collision)) // apply track cuts + continue; cutTracks.push_back(track); - TLorentzVector track4Vec; - track4Vec.SetXYZM(track.px(), track.py(), track.pz(), o2::constants::physics::MassPionCharged); // apriori assume pion mass - cutTracks4Vecs.push_back(track4Vec); - QC.fill(HIST("QC/tracks/cut/hTpcSignalVsP"), momentum(track.px(), track.py(), track.pz()), track.tpcSignal()); - QC.fill(HIST("QC/tracks/cut/hTpcSignalVsPt"), track.pt(), track.tpcSignal()); - QC.fill(HIST("QC/tracks/cut/hDcaXYZ"), track.dcaZ(), track.dcaXY()); } - QC.fill(HIST("QC/tracks/cut/hRemainingTracks"), cutTracks.size()); - if (cutTracks.size() != cutTracks4Vecs.size()) { // sanity check - LOG(error); + rQC.fill(HIST("QC/tracks/trackSelections/hRemainingTracks"), cutTracks.size()); + + if (static_cast(cutTracks.size()) != numPions) // further consider only two pion systems return; + for (int i = 0; i < numPions; i++) { + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 15); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 15, collision.runNumber()); } - // reonstruct system and calculate total charge, save commonly used values into variables - TLorentzVector system = reconstructSystem(cutTracks4Vecs); - int totalCharge = tracksTotalCharge(cutTracks); - double mass = system.M(); - double pT = system.Pt(); - double pTsquare = pT * pT; - double rapidity = system.Rapidity(); - double systemPhi = system.Phi() + o2::constants::math::PI; - - if (do4pi && cutTracks.size() == 4 && totalCharge == 0) { - // fill out some 4pi QC histograms - for (int i = 0; i < static_cast(cutTracks.size()); i++) { - FourPiQA.fill(HIST("FourPiQA/reco/tracks/hPt"), cutTracks[i].pt()); - FourPiQA.fill(HIST("FourPiQA/reco/tracks/hEta"), eta(cutTracks[i].px(), cutTracks[i].py(), cutTracks[i].pz())); - FourPiQA.fill(HIST("FourPiQA/reco/tracks/hPhi"), phi(cutTracks[i].px(), cutTracks[i].py())); - } - FourPiQA.fill(HIST("FourPiQA/reco/system/hM"), mass); - FourPiQA.fill(HIST("FourPiQA/reco/system/hPt"), pT); - FourPiQA.fill(HIST("FourPiQA/reco/system/hY"), rapidity); - FourPiQA.fill(HIST("FourPiQA/reco/system/hPhi"), systemPhi); + rQC.fill(HIST("QC/tracks/trackSelections/hTpcNSigmaPi2D"), cutTracks[0].tpcNSigmaPi(), cutTracks[1].tpcNSigmaPi()); + rQC.fill(HIST("QC/tracks/trackSelections/hTpcNSigmaEl2D"), cutTracks[0].tpcNSigmaEl(), cutTracks[1].tpcNSigmaEl()); + rQC.fill(HIST("QC/tracks/trackSelections/hTpcNSigmaKa2D"), cutTracks[0].tpcNSigmaKa(), cutTracks[1].tpcNSigmaKa()); + + // create a vector of 4-vectors for selected tracks + std::vector cutTracksLVs; + for (const auto& cutTrack : cutTracks) { + cutTracksLVs.push_back(ROOT::Math::PxPyPzMVector(cutTrack.px(), cutTrack.py(), cutTrack.pz(), o2::constants::physics::MassPionCharged)); // apriori assume pion mass } - // further consider only two pion systems - if (cutTracks.size() != 2) - return; - for (int i = 0; i < static_cast(cutTracks.size()); i++) - QC.fill(HIST("QC/tracks/hSelectionCounter"), 14); - - QC.fill(HIST("QC/tracks/cut/hTpcNSigmaPi2D"), cutTracks[0].tpcNSigmaPi(), cutTracks[1].tpcNSigmaPi()); - QC.fill(HIST("QC/tracks/cut/hTpcNSigmaEl2D"), cutTracks[0].tpcNSigmaEl(), cutTracks[1].tpcNSigmaEl()); + // differentiate leading- and subleading-momentum tracks + auto leadingMomentumTrack = momentum(cutTracks[0].px(), cutTracks[0].py(), cutTracks[0].pz()) > momentum(cutTracks[1].px(), cutTracks[1].py(), cutTracks[1].pz()) ? cutTracks[0] : cutTracks[1]; + auto subleadingMomentumTrack = (leadingMomentumTrack == cutTracks[0]) ? cutTracks[1] : cutTracks[0]; - if (!tracksPassPiPID(cutTracks)) + auto positiveTrack = cutTracks[0].sign() > 0 ? cutTracks[0] : cutTracks[1]; + auto negativeTrack = cutTracks[0].sign() > 0 ? cutTracks[1] : cutTracks[0]; + + float leadingPt = leadingMomentumTrack.pt(); + float subleadingPt = subleadingMomentumTrack.pt(); + float leadingEta = eta(leadingMomentumTrack.px(), leadingMomentumTrack.py(), leadingMomentumTrack.pz()); + float subleadingEta = eta(subleadingMomentumTrack.px(), subleadingMomentumTrack.py(), subleadingMomentumTrack.pz()); + float leadingPhi = phi(leadingMomentumTrack.px(), leadingMomentumTrack.py()); + float subleadingPhi = phi(subleadingMomentumTrack.px(), subleadingMomentumTrack.py()); + float phiRandom = getPhiRandom(cutTracksLVs); + float phiCharge = getPhiCharge(cutTracks, cutTracksLVs); + + // fill recoTree + int localBc = collision.globalBC() % o2::constants::lhc::LHCMaxBunches; + int trackSigns[2] = {positiveTrack.sign(), negativeTrack.sign()}; + float trackPts[2] = {positiveTrack.pt(), negativeTrack.pt()}; + float trackEtas[2] = {eta(positiveTrack.px(), positiveTrack.py(), positiveTrack.pz()), eta(negativeTrack.px(), negativeTrack.py(), negativeTrack.pz())}; + float trackPhis[2] = {phi(positiveTrack.px(), positiveTrack.py()), phi(negativeTrack.px(), negativeTrack.py())}; + float trackPiPIDs[2] = {positiveTrack.tpcNSigmaPi(), negativeTrack.tpcNSigmaPi()}; + float trackElPIDs[2] = {positiveTrack.tpcNSigmaEl(), negativeTrack.tpcNSigmaEl()}; + float trackKaPIDs[2] = {positiveTrack.tpcNSigmaKa(), negativeTrack.tpcNSigmaKa()}; + float trackDcaXYs[2] = {positiveTrack.dcaXY(), negativeTrack.dcaXY()}; + float trackDcaZs[2] = {positiveTrack.dcaZ(), negativeTrack.dcaZ()}; + float trackTpcSignals[2] = {positiveTrack.tpcSignal(), negativeTrack.tpcSignal()}; + recoTree(collision.flags(), collision.runNumber(), localBc, collision.numContrib(), collision.posX(), collision.posY(), collision.posZ(), + collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), collision.totalFV0AmplitudeA(), collision.totalFDDAmplitudeA(), collision.totalFDDAmplitudeC(), + collision.timeFT0A(), collision.timeFT0C(), collision.timeFV0A(), collision.timeFDDA(), collision.timeFDDC(), + energyCommonZNA, energyCommonZNC, timeZNA, timeZNC, neutronClass, + phiRandom, phiCharge, trackSigns, trackPts, trackEtas, trackPhis, trackPiPIDs, trackElPIDs, trackKaPIDs, trackDcaXYs, trackDcaZs, trackTpcSignals); + + if (!tracksPassPiPID(cutTracks)) // apply PID cut return; - for (int i = 0; i < static_cast(cutTracks.size()); i++) - QC.fill(HIST("QC/tracks/hSelectionCounter"), 15); - double phiRandom = getPhiRandom(cutTracks4Vecs); - double phiCharge = getPhiCharge(cutTracks, cutTracks4Vecs); + for (const auto& cutTrack : cutTracks) { + rQC.fill(HIST("QC/tracks/hSelectionCounter"), 16); + rQC.fill(HIST("QC/tracks/hSelectionCounterPerRun"), 16, collision.runNumber()); + fillTrackQcHistos<1>(cutTrack); // fill QC histograms after cuts + } + rQC.fill(HIST("QC/tracks/hTofHitCheck"), leadingMomentumTrack.hasTOF(), subleadingMomentumTrack.hasTOF()); + fillCollisionQcHistos<1>(collision); // fill QC histograms after track selections - // differentiate leading- and subleading-momentum tracks - auto leadingMomentumTrack = momentum(cutTracks[0].px(), cutTracks[0].py(), cutTracks[0].pz()) > momentum(cutTracks[1].px(), cutTracks[1].py(), cutTracks[1].pz()) ? cutTracks[0] : cutTracks[1]; - auto subleadingMomentumTrack = (leadingMomentumTrack == cutTracks[0]) ? cutTracks[1] : cutTracks[0]; - double leadingPt = leadingMomentumTrack.pt(); - double subleadingPt = subleadingMomentumTrack.pt(); - double leadingEta = eta(leadingMomentumTrack.px(), leadingMomentumTrack.py(), leadingMomentumTrack.pz()); - double subleadingEta = eta(subleadingMomentumTrack.px(), subleadingMomentumTrack.py(), subleadingMomentumTrack.pz()); - double leadingPhi = phi(leadingMomentumTrack.px(), leadingMomentumTrack.py()); - double subleadingPhi = phi(subleadingMomentumTrack.px(), subleadingMomentumTrack.py()); - // fill TOF hit checker - QC.fill(HIST("QC/tracks/hTofHitCheck"), leadingMomentumTrack.hasTOF(), subleadingMomentumTrack.hasTOF()); - - // fill tree - std::vector trackSigns = {leadingMomentumTrack.sign(), subleadingMomentumTrack.sign()}; - std::vector trackPts = {leadingPt, subleadingPt}; - std::vector trackEtas = {leadingEta, subleadingEta}; - std::vector trackPhis = {leadingPhi, subleadingPhi}; - std::vector trackMs = {o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged}; - std::vector trackPiPIDs = {leadingMomentumTrack.tpcNSigmaPi(), subleadingMomentumTrack.tpcNSigmaPi()}; - std::vector trackElPIDs = {leadingMomentumTrack.tpcNSigmaEl(), subleadingMomentumTrack.tpcNSigmaEl()}; - std::vector trackDcaXYs = {leadingMomentumTrack.dcaXY(), subleadingMomentumTrack.dcaXY()}; - std::vector trackDcaZs = {leadingMomentumTrack.dcaZ(), subleadingMomentumTrack.dcaZ()}; - std::vector trackTpcSignals = {leadingMomentumTrack.tpcSignal(), subleadingMomentumTrack.tpcSignal()}; - Tree(collision.runNumber(), collision.globalBC(), collision.numContrib(), - collision.posX(), collision.posY(), collision.posZ(), - collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), collision.totalFV0AmplitudeA(), collision.totalFDDAmplitudeA(), collision.totalFDDAmplitudeC(), - collision.timeFT0A(), collision.timeFT0C(), collision.timeFV0A(), collision.timeFDDA(), collision.timeFDDC(), - collision.energyCommonZNA(), collision.energyCommonZNC(), collision.timeZNA(), collision.timeZNC(), neutronClass, - totalCharge, pT, system.Eta(), system.Phi(), mass, phiRandom, phiCharge, - trackSigns, trackPts, trackEtas, trackPhis, trackMs, trackPiPIDs, trackElPIDs, trackDcaXYs, trackDcaZs, trackTpcSignals); - // fill raw histograms according to the total charge + ROOT::Math::PxPyPzMVector system = reconstructSystem(cutTracksLVs); + int totalCharge = tracksTotalCharge(cutTracks); + float mass = system.M(); + float pT = system.Pt(); + float rapidity = system.Rapidity(); + float systemPhi = system.Phi() + o2::constants::math::PI; + + // fill raw histograms according to total charge switch (totalCharge) { case 0: - Pions.fill(HIST("pions/no-selection/unlike-sign/hPt"), leadingPt, subleadingPt); - Pions.fill(HIST("pions/no-selection/unlike-sign/hEta"), leadingEta, subleadingEta); - Pions.fill(HIST("pions/no-selection/unlike-sign/hPhi"), leadingPhi, subleadingPhi); - System.fill(HIST("system/raw/unlike-sign/hM"), mass); - System.fill(HIST("system/raw/unlike-sign/hPt"), pT); - System.fill(HIST("system/raw/unlike-sign/hPtVsM"), mass, pT); - System.fill(HIST("system/raw/unlike-sign/hY"), rapidity); - System.fill(HIST("system/raw/unlike-sign/hPhi"), systemPhi); + fillTrack2dHistos<1, 0>(leadingPt, subleadingPt, leadingEta, subleadingEta, leadingPhi, subleadingPhi); + fillSystemHistos<0, 0, 0>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); break; case 2: - Pions.fill(HIST("pions/no-selection/like-sign/hPt"), leadingPt, subleadingPt); - Pions.fill(HIST("pions/no-selection/like-sign/hEta"), leadingEta, subleadingEta); - Pions.fill(HIST("pions/no-selection/like-sign/hPhi"), leadingPhi, subleadingPhi); - System.fill(HIST("system/raw/like-sign/positive/hM"), mass); - System.fill(HIST("system/raw/like-sign/positive/hPt"), pT); - System.fill(HIST("system/raw/like-sign/positive/hPtVsM"), mass, pT); - System.fill(HIST("system/raw/like-sign/positive/hY"), rapidity); - System.fill(HIST("system/raw/like-sign/positive/hPhi"), systemPhi); + fillTrack2dHistos<1, 1>(leadingPt, subleadingPt, leadingEta, subleadingEta, leadingPhi, subleadingPhi); + fillSystemHistos<0, 0, 1>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); break; case -2: - Pions.fill(HIST("pions/no-selection/like-sign/hPt"), leadingPt, subleadingPt); - Pions.fill(HIST("pions/no-selection/like-sign/hEta"), leadingEta, subleadingEta); - Pions.fill(HIST("pions/no-selection/like-sign/hPhi"), leadingPhi, subleadingPhi); - System.fill(HIST("system/raw/like-sign/negative/hM"), mass); - System.fill(HIST("system/raw/like-sign/negative/hPt"), pT); - System.fill(HIST("system/raw/like-sign/negative/hPtVsM"), mass, pT); - System.fill(HIST("system/raw/like-sign/negative/hY"), rapidity); - System.fill(HIST("system/raw/like-sign/negative/hPhi"), systemPhi); + fillTrack2dHistos<1, 2>(leadingPt, subleadingPt, leadingEta, subleadingEta, leadingPhi, subleadingPhi); + fillSystemHistos<0, 0, 2>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); break; default: @@ -817,238 +749,51 @@ struct upcRhoAnalysis { } // apply cuts to system - if (!systemPassCuts(system)) + if (!systemPassesCuts(system)) return; - QC.fill(HIST("QC/collisions/selected/hPosXY"), collision.posX(), collision.posY()); - QC.fill(HIST("QC/collisions/selected/hPosZ"), collision.posZ()); - QC.fill(HIST("QC/collisions/selected/hZdcCommonEnergy"), collision.energyCommonZNA(), collision.energyCommonZNC()); - QC.fill(HIST("QC/collisions/selected/hZdcTime"), collision.timeZNA(), collision.timeZNC()); - QC.fill(HIST("QC/collisions/selected/hNumContrib"), collision.numContrib()); - QC.fill(HIST("QC/collisions/selected/hTotalFT0AmplitudeA"), collision.totalFT0AmplitudeA()); - QC.fill(HIST("QC/collisions/selected/hTotalFT0AmplitudeC"), collision.totalFT0AmplitudeC()); - QC.fill(HIST("QC/collisions/selected/hTotalFV0AmplitudeA"), collision.totalFV0AmplitudeA()); - QC.fill(HIST("QC/collisions/selected/hTotalFDDAmplitudeA"), collision.totalFDDAmplitudeA()); - QC.fill(HIST("QC/collisions/selected/hTotalFDDAmplitudeC"), collision.totalFDDAmplitudeC()); - QC.fill(HIST("QC/collisions/selected/hTimeFT0A"), collision.timeFT0A()); - QC.fill(HIST("QC/collisions/selected/hTimeFT0C"), collision.timeFT0C()); - QC.fill(HIST("QC/collisions/selected/hTimeFV0A"), collision.timeFV0A()); - QC.fill(HIST("QC/collisions/selected/hTimeFDDA"), collision.timeFDDA()); - QC.fill(HIST("QC/collisions/selected/hTimeFDDC"), collision.timeFDDC()); - // fill histograms for system passing cuts switch (totalCharge) { case 0: - Pions.fill(HIST("pions/selected/unlike-sign/hPt"), leadingPt, subleadingPt); - Pions.fill(HIST("pions/selected/unlike-sign/hEta"), leadingEta, subleadingEta); - Pions.fill(HIST("pions/selected/unlike-sign/hPhi"), leadingPhi, subleadingPhi); - System.fill(HIST("system/cut/no-selection/unlike-sign/hM"), mass); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPt"), pT); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPt2"), pTsquare); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/no-selection/unlike-sign/hY"), rapidity); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPhi"), systemPhi); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/no-selection/unlike-sign/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - if (OnOn) { - System.fill(HIST("system/cut/0n0n/unlike-sign/hM"), mass); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPt"), pT); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPt2"), pTsquare); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/0n0n/unlike-sign/hY"), rapidity); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPhi"), systemPhi); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/0n0n/unlike-sign/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } else if (XnOn) { - System.fill(HIST("system/cut/Xn0n/unlike-sign/hM"), mass); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPt"), pT); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPt2"), pTsquare); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hY"), rapidity); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPhi"), systemPhi); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/Xn0n/unlike-sign/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } else if (OnXn) { - System.fill(HIST("system/cut/0nXn/unlike-sign/hM"), mass); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPt"), pT); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPt2"), pTsquare); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/0nXn/unlike-sign/hY"), rapidity); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPhi"), systemPhi); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/0nXn/unlike-sign/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } else if (XnXn) { - System.fill(HIST("system/cut/XnXn/unlike-sign/hM"), mass); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPt"), pT); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPt2"), pTsquare); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/XnXn/unlike-sign/hY"), rapidity); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPhi"), systemPhi); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/XnXn/unlike-sign/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } + fillCollisionQcHistos<2>(collision); + for (const auto& cutTrack : cutTracks) + fillTrackQcHistos<2>(cutTrack); + fillTrack2dHistos<2, 0>(leadingPt, subleadingPt, leadingEta, subleadingEta, leadingPhi, subleadingPhi); + fillSystemHistos<1, 0, 0>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (onon) + fillSystemHistos<1, 1, 0>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (xnon) + fillSystemHistos<1, 2, 0>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (onxn) + fillSystemHistos<1, 3, 0>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (xnxn) + fillSystemHistos<1, 4, 0>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); break; case 2: - Pions.fill(HIST("pions/selected/like-sign/hPt"), leadingPt, subleadingPt); - Pions.fill(HIST("pions/selected/like-sign/hEta"), leadingEta, subleadingEta); - Pions.fill(HIST("pions/selected/like-sign/hPhi"), leadingPhi, subleadingPhi); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hM"), mass); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPt"), pT); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPt2"), pTsquare); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hY"), rapidity); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPhi"), systemPhi); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/no-selection/like-sign/positive/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - if (OnOn) { - System.fill(HIST("system/cut/0n0n/like-sign/positive/hM"), mass); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPt"), pT); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPt2"), pTsquare); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hY"), rapidity); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPhi"), systemPhi); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/0n0n/like-sign/positive/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } else if (XnOn) { - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hM"), mass); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPt"), pT); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPt2"), pTsquare); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hY"), rapidity); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPhi"), systemPhi); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/Xn0n/like-sign/positive/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } else if (OnXn) { - System.fill(HIST("system/cut/0nXn/like-sign/positive/hM"), mass); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPt"), pT); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPt2"), pTsquare); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hY"), rapidity); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPhi"), systemPhi); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/0nXn/like-sign/positive/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } else if (XnXn) { - System.fill(HIST("system/cut/XnXn/like-sign/positive/hM"), mass); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPt"), pT); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPt2"), pTsquare); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hY"), rapidity); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPhi"), systemPhi); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/XnXn/like-sign/positive/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } + fillTrack2dHistos<2, 1>(leadingPt, subleadingPt, leadingEta, subleadingEta, leadingPhi, subleadingPhi); + fillSystemHistos<1, 0, 1>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (onon) + fillSystemHistos<1, 1, 1>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (xnon) + fillSystemHistos<1, 2, 1>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (onxn) + fillSystemHistos<1, 3, 1>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (xnxn) + fillSystemHistos<1, 4, 1>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); break; case -2: - Pions.fill(HIST("pions/selected/like-sign/hPt"), leadingPt, subleadingPt); - Pions.fill(HIST("pions/selected/like-sign/hEta"), leadingEta, subleadingEta); - Pions.fill(HIST("pions/selected/like-sign/hPhi"), leadingPhi, subleadingPhi); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hM"), mass); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPt"), pT); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPt2"), pTsquare); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hY"), rapidity); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPhi"), systemPhi); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/no-selection/like-sign/negative/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - if (OnOn) { - System.fill(HIST("system/cut/0n0n/like-sign/negative/hM"), mass); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPt"), pT); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPt2"), pTsquare); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hY"), rapidity); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPhi"), systemPhi); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/0n0n/like-sign/negative/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } else if (XnOn) { - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hM"), mass); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPt"), pT); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPt2"), pTsquare); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hY"), rapidity); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPhi"), systemPhi); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/Xn0n/like-sign/negative/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } else if (OnXn) { - System.fill(HIST("system/cut/0nXn/like-sign/negative/hM"), mass); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPt"), pT); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPt2"), pTsquare); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hY"), rapidity); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPhi"), systemPhi); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/0nXn/like-sign/negative/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } else if (XnXn) { - System.fill(HIST("system/cut/XnXn/like-sign/negative/hM"), mass); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPt"), pT); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPt2"), pTsquare); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPtVsM"), mass, pT); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hY"), rapidity); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPhi"), systemPhi); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPhiRandom"), phiRandom); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPhiCharge"), phiCharge); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPhiRandomVsM"), mass, phiRandom); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPhiChargeVsM"), mass, phiCharge); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPyVsPxRandom"), pT * std::cos(phiRandom), pT * std::sin(phiRandom)); - System.fill(HIST("system/cut/XnXn/like-sign/negative/hPyVsPxCharge"), pT * std::cos(phiCharge), pT * std::sin(phiCharge)); - } + fillTrack2dHistos<2, 2>(leadingPt, subleadingPt, leadingEta, subleadingEta, leadingPhi, subleadingPhi); + fillSystemHistos<1, 0, 2>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (onon) + fillSystemHistos<1, 1, 2>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (xnon) + fillSystemHistos<1, 2, 2>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (onxn) + fillSystemHistos<1, 3, 2>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); + if (xnxn) + fillSystemHistos<1, 4, 2>(mass, pT, rapidity, systemPhi, phiRandom, phiCharge); break; default: @@ -1059,109 +804,124 @@ struct upcRhoAnalysis { template void processMC(C const& mcCollision, T const& mcParticles) { - MC.fill(HIST("MC/collisions/hPosXY"), mcCollision.posX(), mcCollision.posY()); - MC.fill(HIST("MC/collisions/hPosZ"), mcCollision.posZ()); + rMC.fill(HIST("MC/collisions/hPosXY"), mcCollision.posX(), mcCollision.posY()); + rMC.fill(HIST("MC/collisions/hPosZ"), mcCollision.posZ()); std::vector cutMcParticles; - std::vector mcParticles4Vecs; + std::vector mcParticlesLVs; for (auto const& mcParticle : mcParticles) { - MC.fill(HIST("MC/tracks/all/hPdgCode"), mcParticle.pdgCode()); - MC.fill(HIST("MC/tracks/all/hProducedByGenerator"), mcParticle.producedByGenerator()); - MC.fill(HIST("MC/tracks/all/hIsPhysicalPrimary"), mcParticle.isPhysicalPrimary()); - MC.fill(HIST("MC/tracks/all/hPt"), pt(mcParticle.px(), mcParticle.py())); - MC.fill(HIST("MC/tracks/all/hEta"), eta(mcParticle.px(), mcParticle.py(), mcParticle.pz())); - MC.fill(HIST("MC/tracks/all/hPhi"), phi(mcParticle.px(), mcParticle.py())); - if (!mcParticle.isPhysicalPrimary() || std::abs(mcParticle.pdgCode()) != 211) + rMC.fill(HIST("MC/tracks/all/hPdgCode"), mcParticle.pdgCode()); + rMC.fill(HIST("MC/tracks/all/hProducedByGenerator"), mcParticle.producedByGenerator()); + rMC.fill(HIST("MC/tracks/all/hIsPhysicalPrimary"), mcParticle.isPhysicalPrimary()); + rMC.fill(HIST("MC/tracks/all/hPt"), pt(mcParticle.px(), mcParticle.py())); + rMC.fill(HIST("MC/tracks/all/hEta"), eta(mcParticle.px(), mcParticle.py(), mcParticle.pz())); + rMC.fill(HIST("MC/tracks/all/hPhi"), phi(mcParticle.px(), mcParticle.py())); + if (!mcParticle.isPhysicalPrimary() || std::abs(mcParticle.pdgCode()) != kPiPlus) continue; cutMcParticles.push_back(mcParticle); - TLorentzVector pion4Vec; - pion4Vec.SetPxPyPzE(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); - mcParticles4Vecs.push_back(pion4Vec); + ROOT::Math::PxPyPzMVector pionLV; + pionLV.SetPxPyPzE(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); + mcParticlesLVs.push_back(pionLV); } - MC.fill(HIST("MC/collisions/hNPions"), cutMcParticles.size()); + rMC.fill(HIST("MC/collisions/hNPions"), cutMcParticles.size()); - if (mcParticles4Vecs.size() != cutMcParticles.size()) + if (static_cast(cutMcParticles.size()) != numPions) + return; + if (mcParticlesLVs.size() != cutMcParticles.size()) return; if (tracksTotalChargeMC(cutMcParticles) != 0) // shouldn't happen in theory return; - TLorentzVector system = reconstructSystem(mcParticles4Vecs); - double mass = system.M(); - double pT = system.Pt(); - double pTsquare = pT * pT; - double rapidity = system.Rapidity(); - double systemPhi = system.Phi() + o2::constants::math::PI; - - if (do4pi && cutMcParticles.size() == 4) { - for (int i = 0; i < static_cast(cutMcParticles.size()); i++) { - FourPiQA.fill(HIST("FourPiQA/MC/tracks/hPt"), pt(cutMcParticles[i].px(), cutMcParticles[i].py())); - FourPiQA.fill(HIST("FourPiQA/MC/tracks/hEta"), eta(cutMcParticles[i].px(), cutMcParticles[i].py(), cutMcParticles[i].pz())); - FourPiQA.fill(HIST("FourPiQA/MC/tracks/hPhi"), phi(cutMcParticles[i].px(), cutMcParticles[i].py())); - } - FourPiQA.fill(HIST("FourPiQA/MC/system/hM"), mass); - FourPiQA.fill(HIST("FourPiQA/MC/system/hPt"), pT); - FourPiQA.fill(HIST("FourPiQA/MC/system/hY"), rapidity); - FourPiQA.fill(HIST("FourPiQA/MC/system/hPhi"), systemPhi); - } - - if (cutMcParticles.size() != 2) - return; + ROOT::Math::PxPyPzMVector system = reconstructSystem(mcParticlesLVs); + float mass = system.M(); + float pT = system.Pt(); + float rapidity = system.Rapidity(); + float systemPhi = system.Phi() + o2::constants::math::PI; + float phiRandom = getPhiRandom(mcParticlesLVs); + float phiCharge = getPhiChargeMC(cutMcParticles, mcParticlesLVs); auto leadingMomentumPion = momentum(cutMcParticles[0].px(), cutMcParticles[0].py(), cutMcParticles[0].pz()) > momentum(cutMcParticles[1].px(), cutMcParticles[1].py(), cutMcParticles[1].pz()) ? cutMcParticles[0] : cutMcParticles[1]; auto subleadingMomentumPion = (leadingMomentumPion == cutMcParticles[0]) ? cutMcParticles[1] : cutMcParticles[0]; - MC.fill(HIST("MC/tracks/pions/hPt"), pt(leadingMomentumPion.px(), leadingMomentumPion.py()), pt(subleadingMomentumPion.px(), subleadingMomentumPion.py())); - MC.fill(HIST("MC/tracks/pions/hEta"), eta(leadingMomentumPion.px(), leadingMomentumPion.py(), leadingMomentumPion.pz()), eta(subleadingMomentumPion.px(), subleadingMomentumPion.py(), subleadingMomentumPion.pz())); - MC.fill(HIST("MC/tracks/pions/hPhi"), phi(leadingMomentumPion.px(), leadingMomentumPion.py()), phi(subleadingMomentumPion.px(), subleadingMomentumPion.py())); - - double phiRandom = getPhiRandom(mcParticles4Vecs); - double phiCharge = getPhiChargeMC(cutMcParticles, mcParticles4Vecs); - - MC.fill(HIST("MC/system/hM"), mass); - MC.fill(HIST("MC/system/hPt"), pT); - MC.fill(HIST("MC/system/hPtVsM"), mass, pT); - MC.fill(HIST("MC/system/hPt2"), pTsquare); - MC.fill(HIST("MC/system/hY"), rapidity); - MC.fill(HIST("MC/system/hPhi"), systemPhi); - MC.fill(HIST("MC/system/hPhiRandom"), phiRandom); - MC.fill(HIST("MC/system/hPhiCharge"), phiCharge); + rMC.fill(HIST("MC/tracks/hPt"), pt(leadingMomentumPion.px(), leadingMomentumPion.py()), pt(subleadingMomentumPion.px(), subleadingMomentumPion.py())); + rMC.fill(HIST("MC/tracks/hEta"), eta(leadingMomentumPion.px(), leadingMomentumPion.py(), leadingMomentumPion.pz()), eta(subleadingMomentumPion.px(), subleadingMomentumPion.py(), subleadingMomentumPion.pz())); + rMC.fill(HIST("MC/tracks/hPhi"), phi(leadingMomentumPion.px(), leadingMomentumPion.py()), phi(subleadingMomentumPion.px(), subleadingMomentumPion.py())); + + rMC.fill(HIST("MC/system/hM"), mass); + rMC.fill(HIST("MC/system/hPt"), pT); + rMC.fill(HIST("MC/system/hPtVsM"), mass, pT); + rMC.fill(HIST("MC/system/hPt2"), pT * pT); + rMC.fill(HIST("MC/system/hY"), rapidity); + rMC.fill(HIST("MC/system/hPhi"), systemPhi); + rMC.fill(HIST("MC/system/hPhiRandom"), phiRandom); + rMC.fill(HIST("MC/system/hPhiCharge"), phiCharge); + rMC.fill(HIST("MC/system/hPhiRandomVsM"), mass, phiRandom); + rMC.fill(HIST("MC/system/hPhiChargeVsM"), mass, phiCharge); + + if (systemPassesCuts(system)) { + rMC.fill(HIST("MC/system/selected/hM"), mass); + rMC.fill(HIST("MC/system/selected/hPt"), pT); + rMC.fill(HIST("MC/system/selected/hPtVsM"), mass, pT); + rMC.fill(HIST("MC/system/selected/hPt2"), pT * pT); + rMC.fill(HIST("MC/system/selected/hY"), rapidity); + rMC.fill(HIST("MC/system/selected/hPhi"), systemPhi); + rMC.fill(HIST("MC/system/selected/hPhiRandom"), phiRandom); + rMC.fill(HIST("MC/system/selected/hPhiCharge"), phiCharge); + rMC.fill(HIST("MC/system/selected/hPhiRandomVsM"), mass, phiRandom); + rMC.fill(HIST("MC/system/selected/hPhiChargeVsM"), mass, phiCharge); + } + + // fill mcTree + auto positivePion = cutMcParticles[0].pdgCode() > 0 ? cutMcParticles[0] : cutMcParticles[1]; + auto negativePion = cutMcParticles[0].pdgCode() > 0 ? cutMcParticles[1] : cutMcParticles[0]; + int localBc = mcCollision.globalBC() % o2::constants::lhc::LHCMaxBunches; + int trackSigns[2] = {positivePion.pdgCode() / std::abs(positivePion.pdgCode()), negativePion.pdgCode() / std::abs(negativePion.pdgCode())}; + float trackPts[2] = {pt(positivePion.px(), positivePion.py()), pt(negativePion.px(), negativePion.py())}; + float trackEtas[2] = {eta(positivePion.px(), positivePion.py(), positivePion.pz()), eta(negativePion.px(), negativePion.py(), negativePion.pz())}; + float trackPhis[2] = {phi(positivePion.px(), positivePion.py()), phi(negativePion.px(), negativePion.py())}; + mcTree(localBc, + mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), + phiRandom, phiCharge, trackSigns, trackPts, trackEtas, trackPhis); } template void checkNumberOfCollisionReconstructions(C const& collisions) { - MC.fill(HIST("MC/collisions/hNumOfCollisionRecos"), collisions.size()); + rMC.fill(HIST("MC/collisions/hNumOfCollisionRecos"), collisions.size()); + rMC.fill(HIST("MC/collisions/hRunNumberVsNumOfCollisionRecos"), collisions.size(), collisions.begin().runNumber()); } void processSGdata(FullUdSgCollision const& collision, FullUdTracks const& tracks) { - if (collision.gapSide() != 2) + if (cutGapSide && collision.gapSide() != gapSide) + return; + if (useTrueGap && (collision.gapSide() != sgSelector.trueGap(collision, cutTrueGapSideFV0, cutTrueGapSideFT0A, cutTrueGapSideFT0C, cutTrueGapSideZDC))) // check true gap side return; processReco(collision, tracks); } - PROCESS_SWITCH(upcRhoAnalysis, processSGdata, "analyse SG data", true); + PROCESS_SWITCH(UpcRhoAnalysis, processSGdata, "analyse SG data", true); void processDGdata(FullUdDgCollision const& collision, FullUdTracks const& tracks) { processReco(collision, tracks); } - PROCESS_SWITCH(upcRhoAnalysis, processDGdata, "analyse DG data", false); + PROCESS_SWITCH(UpcRhoAnalysis, processDGdata, "analyse DG data", false); void processMCdata(aod::UDMcCollision const& mcCollision, aod::UDMcParticles const& mcParticles) { processMC(mcCollision, mcParticles); } - PROCESS_SWITCH(upcRhoAnalysis, processMCdata, "analyse MC data", false); + PROCESS_SWITCH(UpcRhoAnalysis, processMCdata, "analyse MC data", false); - void processCollisionRecoCheck(aod::McCollision const& /* mcCollision */, soa::SmallGroups> const& collisions) + void processCollisionRecoCheck(aod::UDMcCollision const& /* mcCollision */, soa::SmallGroups> const& collisions) { checkNumberOfCollisionReconstructions(collisions); } - PROCESS_SWITCH(upcRhoAnalysis, processCollisionRecoCheck, "check number of collision reconstructions", false); + PROCESS_SWITCH(UpcRhoAnalysis, processCollisionRecoCheck, "check number of collision reconstructions", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - o2::framework::adaptAnalysisTask(cfgc)}; + o2::framework::adaptAnalysisTask(cfgc)}; } diff --git a/PWGUD/Tasks/upcRhoPrimeAnalysis.cxx b/PWGUD/Tasks/upcRhoPrimeAnalysis.cxx new file mode 100644 index 00000000000..49b6e478674 --- /dev/null +++ b/PWGUD/Tasks/upcRhoPrimeAnalysis.cxx @@ -0,0 +1,338 @@ +// 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. +/// +/// \brief Task for analysis of rho' in UPCs using UD tables (from SG producer). +/// \author Cesar Ramirez, cesar.ramirez@cern.ch + +#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" +#include "PWGUD/DataModel/UDTables.h" + +#include "Common/DataModel/PIDResponse.h" + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Math/Vector4D.h" // similiar to TLorentzVector (which is now legacy apparently) + +#include "random" +#include // Para std::string +#include // Para std::vector + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using FullUDSgCollision = soa::Join::iterator; +using FullUDTracks = soa::Join; + +namespace o2::aod +{ +namespace fourpi +{ + +// for event +DECLARE_SOA_COLUMN(RunNumber, runNumber, int32_t); + +// for rho prime +DECLARE_SOA_COLUMN(M, m, double); +DECLARE_SOA_COLUMN(Pt, pt, double); +DECLARE_SOA_COLUMN(Eta, eta, double); +DECLARE_SOA_COLUMN(Phi, phi, double); + +// for vertex +DECLARE_SOA_COLUMN(PosX, posX, double); +DECLARE_SOA_COLUMN(PosY, posY, double); +DECLARE_SOA_COLUMN(PosZ, posZ, double); + +// for other +DECLARE_SOA_COLUMN(TotalCharge, totalCharge, int); + +// info detec +DECLARE_SOA_COLUMN(TotalFT0AmplitudeA, totalFT0AmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFT0AmplitudeC, totalFT0AmplitudeC, float); +DECLARE_SOA_COLUMN(TotalFV0AmplitudeA, totalFV0AmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFDDAmplitudeA, totalFDDAmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFDDAmplitudeC, totalFDDAmplitudeC, float); +DECLARE_SOA_COLUMN(TimeFT0A, timeFT0A, float); +DECLARE_SOA_COLUMN(TimeFT0C, timeFT0C, float); +DECLARE_SOA_COLUMN(TimeFV0A, timeFV0A, float); +DECLARE_SOA_COLUMN(TimeFDDA, timeFDDA, float); +DECLARE_SOA_COLUMN(TimeFDDC, timeFDDC, float); + +// for pion tracks +DECLARE_SOA_COLUMN(NumContrib, numContrib, int32_t); +DECLARE_SOA_COLUMN(Sign, sign, std::vector); +DECLARE_SOA_COLUMN(TrackPt, trackPt, std::vector); +DECLARE_SOA_COLUMN(TrackEta, trackEta, std::vector); +DECLARE_SOA_COLUMN(TrackPhi, trackPhi, std::vector); +DECLARE_SOA_COLUMN(TPCNSigmaEl, tpcNSigmaEl, std::vector); +DECLARE_SOA_COLUMN(TPCNSigmaPi, tpcNSigmaPi, std::vector); +DECLARE_SOA_COLUMN(TPCNSigmaKa, tpcNSigmaKa, std::vector); +DECLARE_SOA_COLUMN(TPCNSigmaPr, tpcNSigmaPr, std::vector); +DECLARE_SOA_COLUMN(TrackID, trackID, std::vector); + +// for others +DECLARE_SOA_COLUMN(IsReconstructedWithUPC, isReconstructedWithUPC, bool); +DECLARE_SOA_COLUMN(TimeZNA, timeZNA, float); +DECLARE_SOA_COLUMN(TimeZNC, timeZNC, float); +DECLARE_SOA_COLUMN(EnergyCommonZNA, energyCommonZNA, float); +DECLARE_SOA_COLUMN(EnergyCommonZNC, energyCommonZNC, float); +DECLARE_SOA_COLUMN(IsChargeZero, isChargeZero, bool); + +DECLARE_SOA_COLUMN(OccupancyInTime, occupancyInTime, int); +DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, double); + +} // namespace fourpi + +DECLARE_SOA_TABLE(SYSTEMTREE, "AOD", "SystemTree", fourpi::RunNumber, fourpi::M, fourpi::Pt, fourpi::Eta, fourpi::Phi, + fourpi::PosX, fourpi::PosY, fourpi::PosZ, fourpi::TotalCharge, fourpi::TotalFT0AmplitudeA, fourpi::TotalFT0AmplitudeC, fourpi::TotalFV0AmplitudeA, + fourpi::TotalFDDAmplitudeA, fourpi::TotalFDDAmplitudeC, fourpi::TimeFT0A, fourpi::TimeFT0C, fourpi::TimeFV0A, fourpi::TimeFDDA, fourpi::TimeFDDC, + fourpi::NumContrib, fourpi::Sign, fourpi::TrackPt, fourpi::TrackEta, fourpi::TrackPhi, + fourpi::TPCNSigmaEl, fourpi::TPCNSigmaPi, fourpi::TPCNSigmaKa, fourpi::TPCNSigmaPr, fourpi::TrackID, fourpi::IsReconstructedWithUPC, + fourpi::TimeZNA, fourpi::TimeZNC, fourpi::EnergyCommonZNA, fourpi::EnergyCommonZNC, fourpi::IsChargeZero, fourpi::OccupancyInTime, fourpi::HadronicRate); +} // namespace o2::aod + +struct upcRhoPrimeAnalysis { + Produces systemTree; + + double PcEtaCut = 0.9; // physics coordination recommendation + + Configurable specifyGapSide{"specifyGapSide", true, "specify gap side for SG/DG produced data"}; + Configurable gapSide{"gapSide", 2, "gap side for SG produced data"}; + Configurable requireTof{"requireTof", false, "require TOF signal"}; + + Configurable collisionsPosZMaxCut{"collisionsPosZMaxCut", 10.0, "max Z position cut on collisions"}; + Configurable ZNcommonEnergyCut{"ZNcommonEnergyCut", 0.0, "ZN common energy cut"}; + Configurable ZNtimeCut{"ZNtimeCut", 2.0, "ZN time cut"}; + + Configurable tracksTpcNSigmaPiCut{"tracksTpcNSigmaPiCut", 3.0, "TPC nSigma pion cut"}; + Configurable tracksDcaMaxCut{"tracksDcaMaxCut", 1.0, "max DCA cut on tracks"}; + + Configurable systemMassMinCut{"systemMassMinCut", 0.8, "min M cut for reco system"}; + Configurable systemMassMaxCut{"systemMassMaxCut", 2.2, "max M cut for reco system"}; + Configurable systemPtCut{"systemPtMaxCut", 0.1, "max pT cut for reco system"}; + Configurable systemYCut{"systemYCut", 0.9, "rapiditiy cut for reco system"}; + + ConfigurableAxis mAxis{"mAxis", {1000, 0.0, 10.0}, "m (GeV/#it{c}^{2})"}; + ConfigurableAxis mCutAxis{"mCutAxis", {70, 0.5, 1.2}, "m (GeV/#it{c}^{2})"}; + ConfigurableAxis ptAxis{"ptAxis", {1000, 0.0, 10.0}, "p_{T} (GeV/#it{c})"}; + ConfigurableAxis ptCutAxis{"ptCutAxis", {300, 0.0, 0.3}, "p_{T} (GeV/#it{c})"}; + ConfigurableAxis pt2Axis{"pt2Axis", {300, 0.0, 0.09}, "p_{T}^{2} (GeV^{2}/#it{c}^{2})"}; + ConfigurableAxis etaAxis{"etaAxis", {180, -0.9, 0.9}, "#eta"}; + ConfigurableAxis yAxis{"yAxis", {180, -0.9, 0.9}, "y"}; + ConfigurableAxis phiAxis{"phiAxis", {180, 0.0, o2::constants::math::TwoPI}, "#phi"}; + ConfigurableAxis phiAsymmAxis{"phiAsymmAxis", {182, -o2::constants::math::PI, o2::constants::math::PI}, "#phi"}; + ConfigurableAxis momentumFromPhiAxis{"momentumFromPhiAxis", {400, -0.1, 0.1}, "p (GeV/#it{c})"}; + ConfigurableAxis ptQuantileAxis{"ptQuantileAxis", {0, 0.0181689, 0.0263408, 0.0330488, 0.0390369, 0.045058, 0.0512604, 0.0582598, 0.066986, 0.0788085, 0.1}, "p_{T} (GeV/#it{c})"}; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + // selection counter + std::vector selectionCounterLabels = {"all tracks", "PV contributor", "ITS + TPC hit", "TOF requirement", "DCA cut", "#eta cut", "2D TPC n#sigma_{#pi} cut"}; + + // 4PI SYSTEM + // registry.add("4pi/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); + // registry.add("4pi/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); + // registry.add("4pi/hEta", ";Eta (1);counts", kTH1D, {etaAxis}); + // registry.add("4pi/hPhi", ";Phi ();counts", kTH1D, {phiAxis}); + } + + template + bool collisionPassesCuts(const C& collision) // collision cuts + { + if (std::abs(collision.posZ()) > collisionsPosZMaxCut) + return false; + if (specifyGapSide && collision.gapSide() != gapSide) + return false; + return true; + } + + template + bool trackPassesCuts(const T& track) // track cuts (PID done separately) + { + if (!track.isPVContributor()) + return false; + if (!track.hasITS() || !track.hasTPC()) + return false; + if (requireTof && !track.hasTOF()) + return false; + if (std::abs(track.dcaZ()) > tracksDcaMaxCut || std::abs(track.dcaXY()) > (0.0182 + 0.0350 / std::pow(track.pt(), 1.01))) // Run 2 dynamic DCA cut + return false; + if (std::abs(eta(track.px(), track.py(), track.pz())) > PcEtaCut) + return false; + return true; + } + + template + bool tracksPassPiPID(const T& cutTracks) // n-dimensional PID cut + { + double radius = 0.0; + for (const auto& track : cutTracks) + radius += std::pow(track.tpcNSigmaPi(), 2); + return radius < std::pow(tracksTpcNSigmaPiCut, 2); + } + + template + double tracksTotalCharge(const T& cutTracks) // total charge of selected tracks + { + double charge = 0.0; + for (const auto& track : cutTracks) + charge += track.sign(); + return charge; + } + + bool systemPassCuts(const ROOT::Math::PxPyPzMVector& system) // system cuts + { + if (system.M() < systemMassMinCut || system.M() > systemMassMaxCut) + return false; + if (system.Pt() > systemPtCut) + return false; + if (std::abs(system.Rapidity()) > systemYCut) + return false; + return true; + } + + ROOT::Math::PxPyPzMVector reconstructSystem(const std::vector& cutTracks4Vecs) // reconstruct system from 4-vectors + { + ROOT::Math::PxPyPzMVector system; + for (const auto& track4Vec : cutTracks4Vecs) + system += track4Vec; + return system; + } + + double deltaPhi(const ROOT::Math::PxPyPzMVector& p1, const ROOT::Math::PxPyPzMVector& p2) + { + double dPhi = p1.Phi() - p2.Phi(); + if (dPhi > o2::constants::math::PI) + dPhi -= o2::constants::math::TwoPI; + else if (dPhi < -o2::constants::math::PI) + dPhi += o2::constants::math::TwoPI; + return dPhi; // calculate delta phi in (-pi, pi) + } + + double getPhiRandom(const std::vector& cutTracks4Vecs) // decay phi anisotropy + { // two possible definitions of phi: randomize the tracks + std::vector indices = {0, 1}; + unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); // get time-based seed + std::shuffle(indices.begin(), indices.end(), std::default_random_engine(seed)); // shuffle indices + // calculate phi + ROOT::Math::PxPyPzMVector pOne = cutTracks4Vecs[indices[0]]; + ROOT::Math::PxPyPzMVector pTwo = cutTracks4Vecs[indices[1]]; + ROOT::Math::PxPyPzMVector pPlus = pOne + pTwo; + ROOT::Math::PxPyPzMVector pMinus = pOne - pTwo; + return deltaPhi(pPlus, pMinus); + } + + template + double getPhiCharge(const T& cutTracks, const std::vector& cutTracks4Vecs) + { // two possible definitions of phi: charge-based assignment + ROOT::Math::PxPyPzMVector pOne, pTwo; + if (cutTracks[0].sign() > 0) { + pOne = cutTracks4Vecs[0]; + pTwo = cutTracks4Vecs[1]; + } else { + pOne = cutTracks4Vecs[1]; + pTwo = cutTracks4Vecs[0]; + } + ROOT::Math::PxPyPzMVector pPlus = pOne + pTwo; + ROOT::Math::PxPyPzMVector pMinus = pOne - pTwo; + return deltaPhi(pPlus, pMinus); + } + + void processReco(FullUDSgCollision const& collision, FullUDTracks const& tracks) + { + + if (!collisionPassesCuts(collision)) + return; + + // vectors for storing selected tracks and their 4-vectors + std::vector cutTracks; + std::vector cutTracks4Vecs; + + // int trackCounter = 0; + for (const auto& track : tracks) { + + if (!trackPassesCuts(track)) + continue; + // trackCounter++; + cutTracks.push_back(track); + cutTracks4Vecs.push_back(ROOT::Math::PxPyPzMVector(track.px(), track.py(), track.pz(), o2::constants::physics::MassPionCharged)); // apriori assume pion mass + } + + if (!tracksPassPiPID(cutTracks)) + return; + // reonstruct system and calculate total charge, save commonly used values into variables + ROOT::Math::PxPyPzMVector system = reconstructSystem(cutTracks4Vecs); + int totalCharge = tracksTotalCharge(cutTracks); + int nTracks = cutTracks.size(); + double mass = system.M(); + double pT = system.Pt(); + // double pTsquare = pT * pT; + double rapidity = system.Rapidity(); + double systemPhi = system.Phi() + o2::constants::math::PI; + + if (nTracks == 4) { + bool isChargeZero = (tracksTotalCharge(cutTracks) == 0); + + std::vector vTrackPt, vTrackEta, vTrackPhi; + std::vector vSign, vTrackID; + std::vector vTpcNSigmaEl, vTpcNSigmaPi, vTpcNSigmaKa, vTpcNSigmaPr; + + for (size_t i = 0; i < cutTracks.size(); i++) { + double tPt = cutTracks[i].pt(); + double tEta = eta(cutTracks[i].px(), cutTracks[i].py(), cutTracks[i].pz()); + double tPhi = phi(cutTracks[i].px(), cutTracks[i].py()); + + vTrackPt.push_back(tPt); + vTrackEta.push_back(tEta); + vTrackPhi.push_back(tPhi); + vSign.push_back(cutTracks[i].sign()); + vTpcNSigmaEl.push_back(cutTracks[i].tpcNSigmaEl()); + vTpcNSigmaPi.push_back(cutTracks[i].tpcNSigmaPi()); + vTpcNSigmaKa.push_back(cutTracks[i].tpcNSigmaKa()); + vTpcNSigmaPr.push_back(cutTracks[i].tpcNSigmaPr()); + + vTrackID.push_back(i); + } + + bool isReconstructedWithUPC = false; + + if (collision.flags() == 1) { + isReconstructedWithUPC = true; + } else { + isReconstructedWithUPC = false; + } + + systemTree(collision.runNumber(), mass, pT, rapidity, systemPhi, + collision.posX(), collision.posY(), collision.posZ(), totalCharge, + collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), collision.timeFV0A(), + collision.totalFDDAmplitudeA(), collision.totalFDDAmplitudeC(), + collision.timeFT0A(), collision.timeFT0C(), collision.timeFV0A(), + collision.timeFDDA(), collision.timeFDDC(), collision.numContrib(), + vSign, vTrackPt, vTrackEta, vTrackPhi, + vTpcNSigmaEl, vTpcNSigmaPi, vTpcNSigmaKa, vTpcNSigmaPr, + vTrackID, isReconstructedWithUPC, collision.timeZNA(), collision.timeZNC(), + collision.energyCommonZNA(), collision.energyCommonZNC(), + isChargeZero, collision.occupancyInTime(), collision.hadronicRate()); + } + // std::cout<<"Hello World"<(cfgc)}; +} diff --git a/PWGUD/Tasks/upcTauCentralBarrelRL.cxx b/PWGUD/Tasks/upcTauRl.cxx similarity index 62% rename from PWGUD/Tasks/upcTauCentralBarrelRL.cxx rename to PWGUD/Tasks/upcTauRl.cxx index 3d04ff94e74..c0684cec14b 100644 --- a/PWGUD/Tasks/upcTauCentralBarrelRL.cxx +++ b/PWGUD/Tasks/upcTauRl.cxx @@ -8,16 +8,20 @@ // 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. -/// \file upcTauCentralBarrelRL.cxx +// +/// \file upcTauRl.cxx /// \brief Personal task to analyze tau events from UPC collisions -/// \author Roman Lavicka, roman.lavicka@cern.ch +/// +/// \author Roman Lavicka , Austrian Academy of Sciences & SMI /// \since 12.07.2022 +// // C++ headers #include #include #include #include +#include // O2 headers #include "Framework/AnalysisTask.h" @@ -39,17 +43,92 @@ #include "PWGUD/Core/SGSelector.h" // ROOT headers -#include "TLorentzVector.h" +#include "Math/Vector4D.h" #include "TPDGCode.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::constants::physics; -struct UpcTauCentralBarrelRL { +namespace o2::aod +{ +namespace tau_tree +{ +// event info +DECLARE_SOA_COLUMN(RunNumber, runNumber, int32_t); +DECLARE_SOA_COLUMN(Bc, bc, int); +DECLARE_SOA_COLUMN(TotalTracks, totalTracks, int); +DECLARE_SOA_COLUMN(NumContrib, numContrib, int); +DECLARE_SOA_COLUMN(GlobalNonPVtracks, globalNonPVtracks, int); +DECLARE_SOA_COLUMN(PosX, posX, float); +DECLARE_SOA_COLUMN(PosY, posY, float); +DECLARE_SOA_COLUMN(PosZ, posZ, float); +DECLARE_SOA_COLUMN(RecoMode, recoMode, int); +DECLARE_SOA_COLUMN(OccupancyInTime, occupancyInTime, int); +DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, double); +DECLARE_SOA_COLUMN(Trs, trs, int); +DECLARE_SOA_COLUMN(Trofs, trofs, int); +DECLARE_SOA_COLUMN(Hmpr, hmpr, int); +DECLARE_SOA_COLUMN(Tfb, tfb, int); +DECLARE_SOA_COLUMN(ItsRofb, itsRofb, int); +DECLARE_SOA_COLUMN(Sbp, sbp, int); +DECLARE_SOA_COLUMN(ZvtxFT0vsPv, zvtxFT0vsPv, int); +DECLARE_SOA_COLUMN(VtxITSTPC, vtxITSTPC, int); +// FIT info +DECLARE_SOA_COLUMN(TotalFT0AmplitudeA, totalFT0AmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFT0AmplitudeC, totalFT0AmplitudeC, float); +DECLARE_SOA_COLUMN(TotalFV0AmplitudeA, totalFV0AmplitudeA, float); +DECLARE_SOA_COLUMN(EnergyCommonZNA, energyCommonZNA, float); +DECLARE_SOA_COLUMN(EnergyCommonZNC, energyCommonZNC, float); +DECLARE_SOA_COLUMN(TimeFT0A, timeFT0A, float); +DECLARE_SOA_COLUMN(TimeFT0C, timeFT0C, float); +DECLARE_SOA_COLUMN(TimeFV0A, timeFV0A, float); +DECLARE_SOA_COLUMN(TimeZNA, timeZNA, float); +DECLARE_SOA_COLUMN(TimeZNC, timeZNC, float); +// tracks +DECLARE_SOA_COLUMN(TrkPx, trkPx, float[2]); +DECLARE_SOA_COLUMN(TrkPy, trkPy, float[2]); +DECLARE_SOA_COLUMN(TrkPz, trkPz, float[2]); +DECLARE_SOA_COLUMN(TrkSign, trkSign, int[2]); +DECLARE_SOA_COLUMN(TrkDCAxy, trkDCAxy, float[2]); +DECLARE_SOA_COLUMN(TrkDCAz, trkDCAz, float[2]); +DECLARE_SOA_COLUMN(TrkTimeRes, trkTimeRes, float[2]); +DECLARE_SOA_COLUMN(Trk1ITSclusterSizes, trk1ITSclusterSizes, uint32_t); +DECLARE_SOA_COLUMN(Trk2ITSclusterSizes, trk2ITSclusterSizes, uint32_t); +DECLARE_SOA_COLUMN(TrkTPCsignal, trkTPCsignal, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaEl, trkTPCnSigmaEl, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaMu, trkTPCnSigmaMu, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaPi, trkTPCnSigmaPi, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaKa, trkTPCnSigmaKa, float[2]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaPr, trkTPCnSigmaPr, float[2]); +DECLARE_SOA_COLUMN(TrkTPCinnerParam, trkTPCinnerParam, float[2]); +DECLARE_SOA_COLUMN(TrkTOFsignal, trkTOFsignal, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaEl, trkTOFnSigmaEl, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaMu, trkTOFnSigmaMu, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaPi, trkTOFnSigmaPi, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaKa, trkTOFnSigmaKa, float[2]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaPr, trkTOFnSigmaPr, float[2]); +DECLARE_SOA_COLUMN(TrkTOFexpMom, trkTOFexpMom, float[2]); + +} // namespace tau_tree +DECLARE_SOA_TABLE(TauTwoTracks, "AOD", "TAUTWOTRACK", + tau_tree::RunNumber, tau_tree::Bc, tau_tree::TotalTracks, tau_tree::NumContrib, tau_tree::GlobalNonPVtracks, tau_tree::PosX, tau_tree::PosY, tau_tree::PosZ, + tau_tree::RecoMode, tau_tree::OccupancyInTime, tau_tree::HadronicRate, + tau_tree::Trs, tau_tree::Trofs, tau_tree::Hmpr, tau_tree::Tfb, tau_tree::ItsRofb, tau_tree::Sbp, tau_tree::ZvtxFT0vsPv, tau_tree::VtxITSTPC, + tau_tree::TotalFT0AmplitudeA, tau_tree::TotalFT0AmplitudeC, tau_tree::TotalFV0AmplitudeA, tau_tree::EnergyCommonZNA, tau_tree::EnergyCommonZNC, + tau_tree::TimeFT0A, tau_tree::TimeFT0C, tau_tree::TimeFV0A, tau_tree::TimeZNA, tau_tree::TimeZNC, + tau_tree::TrkPx, tau_tree::TrkPy, tau_tree::TrkPz, tau_tree::TrkSign, tau_tree::TrkDCAxy, tau_tree::TrkDCAz, tau_tree::TrkTimeRes, + tau_tree::Trk1ITSclusterSizes, tau_tree::Trk2ITSclusterSizes, + tau_tree::TrkTPCsignal, tau_tree::TrkTPCnSigmaEl, tau_tree::TrkTPCnSigmaMu, tau_tree::TrkTPCnSigmaPi, tau_tree::TrkTPCnSigmaKa, tau_tree::TrkTPCnSigmaPr, tau_tree::TrkTPCinnerParam, + tau_tree::TrkTOFsignal, tau_tree::TrkTOFnSigmaEl, tau_tree::TrkTOFnSigmaMu, tau_tree::TrkTOFnSigmaPi, tau_tree::TrkTOFnSigmaKa, tau_tree::TrkTOFnSigmaPr, tau_tree::TrkTOFexpMom); + +} // namespace o2::aod + +struct UpcTauRl { + Produces tauTwoTracks; // Global varialbes - bool isMC = false; Service pdg; SGSelector sgSelector; @@ -63,17 +142,30 @@ struct UpcTauCentralBarrelRL { Configurable doMCtrueElectronCheck{"doMCtrueElectronCheck", false, {"Check if track hypothesis corresponds to MC truth. If no, it cuts."}}; Configurable oppositeMCtrueElectronCheck{"oppositeMCtrueElectronCheck", false, {"While doMCtrueElectronCheck is true, check if track hypothesis corresponds to MC truth. If yes, it cuts."}}; Configurable doTwoTracks{"doTwoTracks", false, {"Define histos for two tracks and allow to fill them"}}; - Configurable doFourTracks{"doFourTracks", false, {"Define histos for four tracks and allow to fill them"}}; - Configurable doSixTracks{"doSixTracks", false, {"Define histos for six tracks and allow to fill them"}}; + Configurable doOutputTauEvents{"doOutputTauEvents", false, {"Select tau two-tracks events under loose criteria and stores them to root tree"}}; struct : ConfigurableGroup { Configurable whichGapSide{"whichGapSide", 2, {"0 for side A, 1 for side C, 2 for both sides"}}; Configurable useTrueGap{"useTrueGap", true, {"Calculate gapSide for a given FV0/FT0/ZDC thresholds"}}; - Configurable cutTrueGapSideFV0{"TrueGapFV0", -1, "FV0A threshold for SG selector"}; - Configurable cutTrueGapSideFT0A{"TrueGapFT0A", 150., "FT0A threshold for SG selector"}; - Configurable cutTrueGapSideFT0C{"TrueGapFT0C", 50., "FT0C threshold for SG selector"}; - Configurable cutTrueGapSideZDC{"TrueGapZDC", 0., "ZDC threshold for SG selector. 0 is <1n, 4.2 is <2n, 6.7 is <3n, 9.5 is <4n, 12.5 is <5n"}; + Configurable cutNumContribs{"cutNumContribs", 2, {"How many contributors event has"}}; + Configurable useNumContribs{"useNumContribs", true, {"Use coll.numContribs as event cut"}}; + Configurable cutRecoFlag{"cutRecoFlag", 1, {"0 = std mode, 1 = upc mode"}}; + Configurable useRecoFlag{"useRecoFlag", false, {"Use coll.flags as event cut"}}; + Configurable cutRCTflag{"cutRCTflag", 0, {"0 = off, 1 = CBT, 2 = CBT+ZDC, 3 = CBThadron, 4 = CBThadron+ZDC"}}; + Configurable cutTrueGapSideFV0{"cutTrueGapSideFV0", -1, "FV0A threshold for SG selector"}; + Configurable cutTrueGapSideFT0A{"cutTrueGapSideFT0A", 150., "FT0A threshold for SG selector"}; + Configurable cutTrueGapSideFT0C{"cutTrueGapSideFT0C", 50., "FT0C threshold for SG selector"}; + Configurable cutTrueGapSideZDC{"cutTrueGapSideZDC", 0., "ZDC threshold for SG selector. 0 is <1n, 4.2 is <2n, 6.7 is <3n, 9.5 is <4n, 12.5 is <5n"}; Configurable cutFITtime{"cutFITtime", 40., "Maximum FIT time allowed. Default is 40ns"}; + Configurable cutEvTFb{"cutEvTFb", true, {"Event selection bit kNoTimeFrameBorder"}}; + Configurable cutEvITSROFb{"cutEvITSROFb", true, {"Event selection bit kNoITSROFrameBorder"}}; + Configurable cutEvSbp{"cutEvSbp", true, {"Event selection bit kNoSameBunchPileup"}}; + Configurable cutEvZvtxFT0vPV{"cutEvZvtxFT0vPV", false, {"Event selection bit kIsGoodZvtxFT0vsPV"}}; + Configurable cutEvVtxITSTPC{"cutEvVtxITSTPC", true, {"Event selection bit kIsVertexITSTPC"}}; + Configurable cutEvOccupancy{"cutEvOccupancy", 100000., "Maximum allowed occupancy"}; + Configurable cutEvTrs{"cutEvTrs", true, {"Event selection bit kNoCollInTimeRangeStandard"}}; + Configurable cutEvTrofs{"cutEvTrofs", true, {"Event selection bit kNoCollInRofStandard"}}; + Configurable cutEvHmpr{"cutEvHmpr", true, {"Event selection bit kNoHighMultCollInPrevRof"}}; Configurable applyAcceptanceSelection{"applyAcceptanceSelection", false, {"Select events in ALICE CB acceptance set with cutTrackEta"}}; Configurable cutTrackEta{"cutTrackEta", 0.9, "Cut on central barrel track eta in absolute values."}; } cutSample; @@ -96,13 +188,17 @@ struct UpcTauCentralBarrelRL { Configurable cutMinTPCnClsXrows{"cutMinTPCnClsXrows", 70, {"Global track cut"}}; Configurable cutMinTPCnClsXrowsOverNcls{"cutMinTPCnClsXrowsOverNcls", 0.8f, {"Global track cut"}}; Configurable cutMaxTPCchi2{"cutMaxTPCchi2", 4.f, {"Global track cut"}}; + Configurable cutGoodITSTPCmatching{"cutGoodITSTPCmatching", true, {"Global track cut"}}; + Configurable cutMaxTOFchi2{"cutMaxTOFchi2", 3.f, {"Global track cut"}}; } cutGlobalTrack; struct : ConfigurableGroup { + Configurable useThresholdsPID{"useThresholdsPID", false, {"Switch off smaller-sigma-wins pidZ."}}; Configurable applyTauEventSelection{"applyTauEventSelection", true, {"Select tau event."}}; Configurable cutOppositeCharge{"cutOppositeCharge", true, {"Tracks have opposite charge."}}; + Configurable cutSameCharge{"cutSameCharge", false, {"Tracks have same charge."}}; Configurable cutMaxAcoplanarity{"cutMaxAcoplanarity", 4 * o2::constants::math::PI / 5, {"Opening angle of the tracks. What is more goes away."}}; - Configurable cutMinAcoplanarity{"cutMinAcoplanarity", 2 * o2::constants::math::PI / 5, {"Opening angle of the tracks. What is less goes away."}}; + Configurable cutMinAcoplanarity{"cutMinAcoplanarity", 0 * o2::constants::math::PI / 5, {"Opening angle of the tracks. What is less goes away."}}; Configurable cutElectronHasTOF{"cutElectronHasTOF", true, {"Electron is required to hit TOF."}}; Configurable cutGoodElectron{"cutGoodElectron", true, {"Select good electron."}}; Configurable cutOutRho{"cutOutRho", false, {"Cut out rho mass under two tracks are pions hypothesis"}}; @@ -117,14 +213,34 @@ struct UpcTauCentralBarrelRL { Configurable cutMaxElectronNsigmaKa{"cutMaxElectronNsigmaKa", 4.0, {"Good Ka hypo out. Upper n sigma cut on Ka hypo of selected electron. What is less till lower cut goes away."}}; Configurable cutMinElectronNsigmaPr{"cutMinElectronNsigmaPr", -4.0, {"Good Pr hypo out. Lower n sigma cut on Pr hypo of selected electron. What is more till upper cut goes away."}}; Configurable cutMaxElectronNsigmaPr{"cutMaxElectronNsigmaPr", 4.0, {"Good Pr hypo out. Upper n sigma cut on Pr hypo of selected electron. What is less till lower cut goes away."}}; + Configurable cutMinElectronTofNsigmaEl{"cutMinElectronTofNsigmaEl", 3.0, {"Good el TOF hypo in. Upper n sigma cut on el hypo of selected electron. What is more goes away."}}; + Configurable cutMaxElectronTofNsigmaEl{"cutMaxElectronTofNsigmaEl", -3.0, {"Good el TOF hypo in. Lower n sigma cut on el hypo of selected electron. What is less goes away."}}; + Configurable cutMinElectronTofNsigmaKa{"cutMinElectronTofNsigmaKa", -4.0, {"Good Ka TOF hypo out. Lower n sigma cut on Ka TOF hypo of selected electron. What is more till upper cut goes away."}}; + Configurable cutMaxElectronTofNsigmaKa{"cutMaxElectronTofNsigmaKa", 4.0, {"Good Ka TOF hypo out. Upper n sigma cut on Ka TOF hypo of selected electron. What is less till lower cut goes away."}}; Configurable cutPionHasTOF{"cutPionHasTOF", true, {"Pion is required to hit TOF."}}; Configurable cutGoodMupion{"cutGoodMupion", true, {"Select good muon/pion."}}; Configurable cutMinPionNsigmaPi{"cutMinPionNsigmaPi", 4.0, {"Good pi hypo in. Upper n sigma cut on pi hypo of selected electron. What is more goes away."}}; Configurable cutMaxPionNsigmaPi{"cutMaxPionNsigmaPi", -4.0, {"Good pi hypo in. Lower n sigma cut on pi hypo of selected electron. What is less goes away."}}; Configurable cutMinPionNsigmaKa{"cutMinPionNsigmaKa", -4.0, {"Good Ka hypo out. Lower n sigma cut on Ka hypo of selected electron. What is more till upper cut goes away."}}; Configurable cutMaxPionNsigmaKa{"cutMaxPionNsigmaKa", 4.0, {"Good Ka hypo out. Upper n sigma cut on Ka hypo of selected electron. What is less till lower cut goes away."}}; + Configurable cutMinPionTofNsigmaPi{"cutMinPionTofNsigmaPi", 4.0, {"Good pi TOF hypo in. Upper n sigma cut on pi hypo of selected electron. What is more goes away."}}; + Configurable cutMaxPionTofNsigmaPi{"cutMaxPionTofNsigmaPi", -4.0, {"Good pi TOF hypo in. Lower n sigma cut on pi hypo of selected electron. What is less goes away."}}; + Configurable cutElectronPt{"cutElectronPt", 0.9, {"Pt, where PiKaon invariant mass histos will split."}}; } cutTauEvent; + struct : ConfigurableGroup { + Configurable cutCanUseTrackPID{"cutUseTrackPID", true, {"Apply weak PID check on tracks."}}; + Configurable cutCanNgoodPVtracs{"cutCanNgoodPVtracs", 2, {"How many good PV tracks to select."}}; + Configurable cutCanMinElectronNsigmaEl{"cutCanMinElectronNsigmaEl", 4.0, {"Good el candidate hypo in. Upper n sigma cut on el hypo of selected electron. What is more goes away."}}; + Configurable cutCanMaxElectronNsigmaEl{"cutCanMaxElectronNsigmaEl", -2.0, {"Good el candidate hypo in. Lower n sigma cut on el hypo of selected electron. What is less goes away."}}; + Configurable cutCanElectronHasTOF{"cutCanElectronHasTOF", true, {"Electron candidated is required to hit TOF."}}; + Configurable cutCanMinPionNsigmaEl{"cutCanMinPionNsigmaEl", 5.0, {"Good pi candidate hypo in. Upper n sigma cut on pi hypo of selected electron. What is more goes away."}}; + Configurable cutCanMaxPionNsigmaEl{"cutCanMaxPionNsigmaEl", -5.0, {"Good pi candidate hypo in. Lower n sigma cut on pi hypo of selected electron. What is less goes away."}}; + Configurable cutCanMinMuonNsigmaEl{"cutCanMinMuonNsigmaEl", 5.0, {"Good pi candidate hypo in. Upper n sigma cut on pi hypo of selected electron. What is more goes away."}}; + Configurable cutCanMaxMuonNsigmaEl{"cutCanMaxMuonNsigmaEl", -5.0, {"Good pi candidate hypo in. Lower n sigma cut on pi hypo of selected electron. What is less goes away."}}; + Configurable cutCanMupionHasTOF{"cutCanMupionHasTOF", true, {"Mupion candidate is required to hit TOF."}}; + } cutPreselect; + struct : ConfigurableGroup { Configurable usePIDwTOF{"usePIDwTOF", false, {"Determine whether also TOF should be used in testPIDhypothesis"}}; Configurable useScutTOFinTPC{"useScutTOFinTPC", true, {"Determine whether cut on TOF n sigma should be used after TPC-based decision in testPIDhypothesis"}}; @@ -147,6 +263,7 @@ struct UpcTauCentralBarrelRL { ConfigurableAxis zzAxisEta{"zzAxisEta", {50, -1.2, 1.2}, "Pseudorapidity (a.u.)"}; ConfigurableAxis zzAxisRap{"zzAxisRap", {50, -1.2, 1.2}, "Rapidity (a.u.)"}; ConfigurableAxis zzAxisFraction{"zzAxisFraction", {500, 0., 1.}, "Fraction (-)"}; + ConfigurableAxis zzAxisMirrorFraction{"zzAxisMirrorFraction", {500, -1., 1.}, "Fraction (-)"}; ConfigurableAxis zzAxisAcoplanarity{"zzAxisAcoplanarity", {32, 0.0, o2::constants::math::PI}, "Acoplanarity (rad)"}; ConfigurableAxis zzAxisCollinearity{"zzAxisCollinearity", {200, 0, 20}, "Collinearity (-)"}; ConfigurableAxis zzAxisTPCdEdx{"zzAxisTPCdEdx", {2000, 0., 200.}, "TPC dE/dx (a.u.)"}; @@ -163,14 +280,23 @@ struct UpcTauCentralBarrelRL { ConfigurableAxis zzAxisFITamplitude{"zzAxisFITamplitude", {1000, 0., 1000.}, "FIT amplitude"}; AxisSpec zzAxisChannels{CH_ENUM_COUNTER, -0.5, +CH_ENUM_COUNTER - 0.5, "Channels (-)"}; + AxisSpec zzAxisSelections{40, -0.5, 39.5, "Selections (-)"}; + } confAxis; using FullUDTracks = soa::Join; - using FullUDCollision = soa::Join::iterator; - using FullSGUDCollision = soa::Join::iterator; + using FullUDCollisions = soa::Join; + using FullUDCollision = FullUDCollisions::iterator; + using FullSGUDCollisions = soa::Join; + using FullSGUDCollision = FullSGUDCollisions::iterator; using FullMCUDTracks = soa::Join; - using FullMCUDCollision = soa::Join::iterator; - using FullMCSGUDCollision = soa::Join::iterator; + using FullMCUDCollisions = soa::Join; + using FullMCUDCollision = FullMCUDCollisions::iterator; + using FullMCSGUDCollisions = soa::Join; + using FullMCSGUDCollision = FullMCSGUDCollisions::iterator; + + Preslice perCollision = aod::udtrack::udCollisionId; + Preslice perCollisionMC = aod::udtrack::udCollisionId; // init void init(InitContext&) @@ -362,6 +488,9 @@ struct UpcTauCentralBarrelRL { histos.add("EventTwoTracks/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); histos.add("EventTwoTracks/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); histos.add("EventTwoTracks/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); + histos.add("EventTwoTracks/hDaughtersEnergyAsymmetry", ";(E_{electron} - E_{#mu/#pi}) / (E_{electron} + E_{#mu/#pi});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMirrorFraction}); + histos.add("EventTwoTracks/hDaughtersMomentaAsymmetry", ";(#it{p}_{electron} - #it{p}_{#mu/#pi}) / (#it{p}_{electron} + #it{p}_{#mu/#pi});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMirrorFraction}); + histos.add("EventTwoTracks/hDaughtersPtAsymmetry", ";(#it{p_{T}}_{electron} - #it{p_{T}}_{#mu/#pi}) / (#it{p_{T}}_{electron} + #it{p_{T}}_{#mu/#pi});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMirrorFraction}); histos.add("EventTwoTracks/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); histos.add("EventTwoTracks/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); histos.add("EventTwoTracks/hDaughtersPt", ";Daughter 1 #it{p_{T}} (GeV/c);Daughter 2 #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); @@ -388,6 +517,7 @@ struct UpcTauCentralBarrelRL { histos.add("EventTwoTracks/TwoElectrons/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); histos.add("EventTwoTracks/TwoElectrons/hInvariantMassWidePtCut", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); histos.add("EventTwoTracks/TwoElectrons/hAcoplanarity", ";#Delta#phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisAcoplanarity}); + histos.add("EventTwoTracks/TwoElectrons/hCollinearity", ";#DeltaR (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisCollinearity}); histos.add("EventTwoTracks/TwoElectrons/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); histos.add("EventTwoTracks/TwoElectrons/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); histos.add("EventTwoTracks/TwoElectrons/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); @@ -426,102 +556,26 @@ struct UpcTauCentralBarrelRL { histos.add("EventTwoTracks/TwoElectrons/PID/hTOFnSigmaVsLP", ";Leading #it{p} (GeV/c);n#sigma_{TOF} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); histos.add("EventTwoTracks/TwoElectrons/PID/hTOFnSigmaVsOP", ";Other #it{p} (GeV/c);n#sigma_{TOF} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); - histos.add("EventTwoTracks/TwoMuons/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventTwoTracks/TwoMuons/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/TwoMuons/hInvariantMassWidePtCut", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/TwoMuons/hAcoplanarity", ";#Delta#phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisAcoplanarity}); - histos.add("EventTwoTracks/TwoMuons/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventTwoTracks/TwoMuons/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/TwoMuons/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventTwoTracks/TwoMuons/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/TwoMuons/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventTwoTracks/TwoMuons/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/TwoMuons/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); - histos.add("EventTwoTracks/TwoMuons/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/TwoMuons/hDaughtersPt", ";Daughter 1 #it{p_{T}} (GeV/c);Daughter 2 #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/TwoMuons/hDaughtersPhi", ";Daughter 1 #phi (rad);Daughter 2 #phi (rad)", HistType::kTH2D, {confAxis.zzAxisPhi, confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhi", ";Daughter #it{p_{T}} (GeV/c);Daughter fmod(#phi,#pi/9)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisModPhi}); - histos.add("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhiTOF", ";Daughter #it{p_{T}} (GeV/c);Daughter fmod(#phi,#pi/9)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisModPhi}); - histos.add("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhiPtCut", ";Daughter #it{p_{T}} (GeV/c);Daughter fmod(#phi,#pi/9)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisModPhi}); - histos.add("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhiPtCutTOF", ";Daughter #it{p_{T}} (GeV/c);Daughter fmod(#phi,#pi/9)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisModPhi}); - histos.add("EventTwoTracks/TwoMuons/hDaughtersRapidity", ";Daughter 1 #it{y} (-);Daughter 2 #it{y} (-)", HistType::kTH2D, {confAxis.zzAxisRap, confAxis.zzAxisRap}); - histos.add("EventTwoTracks/TwoMuons/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - - histos.add("EventTwoTracks/TwoPions/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventTwoTracks/TwoPions/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/TwoPions/hInvariantMassWidePtCut", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/TwoPions/hAcoplanarity", ";#Delta#phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisAcoplanarity}); - histos.add("EventTwoTracks/TwoPions/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventTwoTracks/TwoPions/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/TwoPions/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventTwoTracks/TwoPions/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/TwoPions/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventTwoTracks/TwoPions/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); - histos.add("EventTwoTracks/TwoPions/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/TwoPions/hDaughtersPt", ";Daughter 1 #it{p_{T}} (GeV/c);Daughter 2 #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/TwoPions/hDaughtersPhi", ";Daughter 1 #phi (rad);Daughter 2 #phi (rad)", HistType::kTH2D, {confAxis.zzAxisPhi, confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/TwoPions/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/TwoPions/hDaughtersPtvsModPhi", ";Daughter #it{p_{T}} (GeV/c);Daughter fmod(#phi,#pi/9)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisModPhi}); - histos.add("EventTwoTracks/TwoPions/hDaughtersPtvsModPhiTOF", ";Daughter #it{p_{T}} (GeV/c);Daughter fmod(#phi,#pi/9)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisModPhi}); - histos.add("EventTwoTracks/TwoPions/hDaughtersPtvsModPhiPtCut", ";Daughter #it{p_{T}} (GeV/c);Daughter fmod(#phi,#pi/9)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisModPhi}); - histos.add("EventTwoTracks/TwoPions/hDaughtersPtvsModPhiPtCutTOF", ";Daughter #it{p_{T}} (GeV/c);Daughter fmod(#phi,#pi/9)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisModPhi}); - histos.add("EventTwoTracks/TwoPions/hDaughtersRapidity", ";Daughter 1 #it{y} (-);Daughter 2 #it{y} (-)", HistType::kTH2D, {confAxis.zzAxisRap, confAxis.zzAxisRap}); - histos.add("EventTwoTracks/TwoPions/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - - histos.add("EventTwoTracks/ElectronMuon/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventTwoTracks/ElectronMuon/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/ElectronMuon/hAcoplanarity", ";#Delta#phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisAcoplanarity}); - histos.add("EventTwoTracks/ElectronMuon/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventTwoTracks/ElectronMuon/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/ElectronMuon/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronMuon/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/ElectronMuon/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventTwoTracks/ElectronMuon/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronMuon/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); - histos.add("EventTwoTracks/ElectronMuon/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/ElectronMuon/hDaughtersPt", ";Daughter 1 #it{p_{T}} (GeV/c);Daughter 2 #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronMuon/hDaughtersPhi", ";Daughter 1 #phi (rad);Daughter 2 #phi (rad)", HistType::kTH2D, {confAxis.zzAxisPhi, confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/ElectronMuon/hDaughtersRapidity", ";Daughter 1 #it{y} (-);Daughter 2 #it{y} (-)", HistType::kTH2D, {confAxis.zzAxisRap, confAxis.zzAxisRap}); - histos.add("EventTwoTracks/ElectronMuon/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - - histos.add("EventTwoTracks/ElectronPion/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventTwoTracks/ElectronPion/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/ElectronPion/hAcoplanarity", ";#Delta#phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisAcoplanarity}); - histos.add("EventTwoTracks/ElectronPion/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventTwoTracks/ElectronPion/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/ElectronPion/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronPion/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/ElectronPion/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventTwoTracks/ElectronPion/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronPion/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); - histos.add("EventTwoTracks/ElectronPion/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/ElectronPion/hDaughtersPt", ";Daughter 1 #it{p_{T}} (GeV/c);Daughter 2 #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronPion/hDaughtersPhi", ";Daughter 1 #phi (rad);Daughter 2 #phi (rad)", HistType::kTH2D, {confAxis.zzAxisPhi, confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/ElectronPion/hDaughtersRapidity", ";Daughter 1 #it{y} (-);Daughter 2 #it{y} (-)", HistType::kTH2D, {confAxis.zzAxisRap, confAxis.zzAxisRap}); - histos.add("EventTwoTracks/ElectronPion/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - - histos.add("EventTwoTracks/MuonPion/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventTwoTracks/MuonPion/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/MuonPion/hInvariantMassWidePtCut", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/MuonPion/hAcoplanarity", ";#Delta#phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisAcoplanarity}); - histos.add("EventTwoTracks/MuonPion/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventTwoTracks/MuonPion/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/MuonPion/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventTwoTracks/MuonPion/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/MuonPion/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventTwoTracks/MuonPion/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/MuonPion/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); - histos.add("EventTwoTracks/MuonPion/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/MuonPion/hDaughtersPt", ";Daughter 1 #it{p_{T}} (GeV/c);Daughter 2 #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/MuonPion/hDaughtersPhi", ";Daughter 1 #phi (rad);Daughter 2 #phi (rad)", HistType::kTH2D, {confAxis.zzAxisPhi, confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/MuonPion/hDaughtersRapidity", ";Daughter 1 #it{y} (-);Daughter 2 #it{y} (-)", HistType::kTH2D, {confAxis.zzAxisRap, confAxis.zzAxisRap}); - histos.add("EventTwoTracks/MuonPion/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - histos.add("EventTwoTracks/ElectronMuPi/hNeventsPtCuts", ";Selection (-);Number of events (-)", HistType::kTH1D, {{20, -0.5, 19.5}}); histos.add("EventTwoTracks/ElectronMuPi/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); histos.add("EventTwoTracks/ElectronMuPi/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/ElectronMuPi/PionsSelection/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventTwoTracks/ElectronMuPi/PionsSelection/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); + histos.add("EventTwoTracks/ElectronMuPi/PionsSelection/hInvariantMass", ";Invariant mass (#pi^{+}#pi^{-}) (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); + histos.add("EventTwoTracks/ElectronMuPi/PionsSelection/hInvariantMassWide", ";Invariant mass (#pi^{+}#pi^{-}) (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/hInvariantMass", ";Invariant mass (K#pi) (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/hInvariantMassWide", ";Invariant mass (K#pi) (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/hMotherMassVsElectronP", ";Invariant mass (K#pi) (GeV/c^{2});Electron #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisMomWide}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/hIMKvsIMe", ";#pi+K invariant mass (GeV/c^{2});#pi+e invariant mass (GeV/c^{2})", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisInvMassWide}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hInvariantMass", ";Invariant mass (K#pi) (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hInvariantMassWide", ";Invariant mass (K#pi) (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hIMKvsIMe", ";#pi+K invariant mass (GeV/c^{2});#pi+e invariant mass (GeV/c^{2})", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisInvMassWide}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hElectronPwideVsOtherPwide", ";Electron #it{p} (GeV/c); #mu/#pi #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hInvariantMass", ";Invariant mass (K#pi) (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hInvariantMassWide", ";Invariant mass (K#pi) (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hIMKvsIMe", ";#pi+K invariant mass (GeV/c^{2});#pi+e invariant mass (GeV/c^{2})", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisInvMassWide}); + histos.add("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hElectronPwideVsOtherPwide", ";Electron #it{p} (GeV/c); #mu/#pi #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); histos.add("EventTwoTracks/ElectronMuPi/hAcoplanarity", ";#Delta#phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisAcoplanarity}); histos.add("EventTwoTracks/ElectronMuPi/hCollinearity", ";#DeltaR (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisCollinearity}); histos.add("EventTwoTracks/ElectronMuPi/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); @@ -530,8 +584,13 @@ struct UpcTauCentralBarrelRL { histos.add("EventTwoTracks/ElectronMuPi/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); histos.add("EventTwoTracks/ElectronMuPi/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); histos.add("EventTwoTracks/ElectronMuPi/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); + histos.add("EventTwoTracks/ElectronMuPi/hMotherMassVsElectronP", ";Invariant mass (GeV/c^{2});Electron #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisMomWide}); + histos.add("EventTwoTracks/ElectronMuPi/hMotherMassVsAcoplanarity", ";Invariant mass (GeV/c^{2});#Delta#phi (rad)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisAcoplanarity}); histos.add("EventTwoTracks/ElectronMuPi/hElectronPt", ";Electron #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); histos.add("EventTwoTracks/ElectronMuPi/hElectronPtWide", ";Electron #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); + histos.add("EventTwoTracks/ElectronMuPi/hDaughtersEnergyAsymmetry", ";(E_{electron} - E_{#mu/#pi}) / (E_{electron} + E_{#mu/#pi});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMirrorFraction}); + histos.add("EventTwoTracks/ElectronMuPi/hDaughtersMomentaAsymmetry", ";(#it{p}_{electron} - #it{p}_{#mu/#pi}) / (#it{p}_{electron} + #it{p}_{#mu/#pi});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMirrorFraction}); + histos.add("EventTwoTracks/ElectronMuPi/hDaughtersPtAsymmetry", ";(#it{p_{T}}_{electron} - #it{p_{T}}_{#mu/#pi}) / (#it{p_{T}}_{electron} + #it{p_{T}}_{#mu/#pi});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMirrorFraction}); histos.add("EventTwoTracks/ElectronMuPi/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); histos.add("EventTwoTracks/ElectronMuPi/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); histos.add("EventTwoTracks/ElectronMuPi/hDaughtersPt", ";Daughter 1 #it{p_{T}} (GeV/c);Daughter 2 #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); @@ -540,6 +599,8 @@ struct UpcTauCentralBarrelRL { histos.add("EventTwoTracks/ElectronMuPi/hDaughtersEnergyFractions", ";E_{electron} / E_{tot} (-);E_{#mu/#pi} / E_{tot} (-)", HistType::kTH2D, {confAxis.zzAxisFraction, confAxis.zzAxisFraction}); histos.add("EventTwoTracks/ElectronMuPi/hElectronPvsOtherP", ";Electron #it{p} (GeV/c); #mu/#pi #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); histos.add("EventTwoTracks/ElectronMuPi/hElectronPwideVsOtherPwide", ";Electron #it{p} (GeV/c); #mu/#pi #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); + histos.add("EventTwoTracks/ElectronMuPi/hElectronPvsAcoplanarity", ";Electron #it{p} (GeV/c); #Delta#phi (rad)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisAcoplanarity}); + histos.add("EventTwoTracks/ElectronMuPi/hOtherPvsAcoplanarity", ";#mu/#pi #it{p} (GeV/c); #Delta#phi (rad)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisAcoplanarity}); histos.add("EventTwoTracks/ElectronMuPi/hElectronPtVsOtherPt", ";Electron #it{p_{T}} (GeV/c); #mu/#pi #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); histos.add("EventTwoTracks/ElectronMuPi/hElectronPhiVsOtherPhi", ";Electron #phi (rad); #mu/#pi #phi (rad)", HistType::kTH2D, {confAxis.zzAxisPhi, confAxis.zzAxisPhi}); histos.add("EventTwoTracks/ElectronMuPi/hElectronRapVsOtherRap", ";Electron #it{y} (-); #mu/#pi #it{y} (-)", HistType::kTH2D, {confAxis.zzAxisRap, confAxis.zzAxisRap}); @@ -569,109 +630,6 @@ struct UpcTauCentralBarrelRL { histos.add("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsMPofO", ";Not-electron #it{p} (GeV/c);n#sigma^{#mu}_{TOF} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); histos.add("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsPPofO", ";Not-electron #it{p} (GeV/c);n#sigma^{#pi}_{TOF} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); histos.add("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaEvsnSigmaPofO", ";Not-electron n#sigma^{e}_{TOF} (arb. units);Not-electron n#sigma^{#pi}_{TOF} (arb. units)", HistType::kTH2D, {confAxis.zzAxisNsigma, confAxis.zzAxisNsigma}); - - histos.add("EventTwoTracks/ElectronOther/hNeventsPtCuts", ";Selection (-);Number of events (-)", HistType::kTH1D, {{20, -0.5, 19.5}}); - histos.add("EventTwoTracks/ElectronOther/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventTwoTracks/ElectronOther/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventTwoTracks/ElectronOther/hAcoplanarity", ";#Delta#phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisAcoplanarity}); - histos.add("EventTwoTracks/ElectronOther/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventTwoTracks/ElectronOther/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/ElectronOther/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronOther/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/ElectronOther/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventTwoTracks/ElectronOther/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronOther/hElectronPt", ";Electron #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronOther/hElectronPtWide", ";Electron #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/ElectronOther/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); - histos.add("EventTwoTracks/ElectronOther/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/ElectronOther/hDaughtersPt", ";Daughter 1 #it{p_{T}} (GeV/c);Daughter 2 #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronOther/hDaughtersPhi", ";Daughter 1 #phi (rad);Daughter 2 #phi (rad)", HistType::kTH2D, {confAxis.zzAxisPhi, confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/ElectronOther/hDaughtersRapidity", ";Daughter 1 #it{y} (-);Daughter 2 #it{y} (-)", HistType::kTH2D, {confAxis.zzAxisRap, confAxis.zzAxisRap}); - histos.add("EventTwoTracks/ElectronOther/hElectronPvsOtherP", ";Electron #it{p} (GeV/c); Other #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisMom}); - histos.add("EventTwoTracks/ElectronOther/hElectronPwideVsOtherPwide", ";Electron #it{p} (GeV/c); Other #it{p} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisMomWide, confAxis.zzAxisMomWide}); - histos.add("EventTwoTracks/ElectronOther/hElectronPtVsOtherPt", ";Electron #it{p_{T}} (GeV/c); Other #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisPt, confAxis.zzAxisPt}); - histos.add("EventTwoTracks/ElectronOther/hElectronPhiVsOtherPhi", ";Electron #phi (rad); Other #phi (rad)", HistType::kTH2D, {confAxis.zzAxisPhi, confAxis.zzAxisPhi}); - histos.add("EventTwoTracks/ElectronOther/hElectronRapVsOtherRap", ";Electron #it{y} (-); Other #it{y} (-)", HistType::kTH2D, {confAxis.zzAxisRap, confAxis.zzAxisRap}); - histos.add("EventTwoTracks/ElectronOther/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - histos.add("EventTwoTracks/ElectronOther/PID/hTPCsignalVsEP", ";Electron #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - histos.add("EventTwoTracks/ElectronOther/PID/hTPCsignalVsOP", ";#it{e}/#mu/#pi #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - histos.add("EventTwoTracks/ElectronOther/PID/hTOFsignalVsP", ";Track #it{p} (GeV/c);TOF signal (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTOFsignal}); - histos.add("EventTwoTracks/ElectronOther/PID/hTOFsignalVsEP", ";Electron #it{p} (GeV/c);TOF signal (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTOFsignal}); - histos.add("EventTwoTracks/ElectronOther/PID/hTOFsignalVsOP", ";Other #it{p} (GeV/c);TOF signal (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTOFsignal}); - histos.add("EventTwoTracks/ElectronOther/PID/hTPCnSigmaVsP", ";Track #it{p} (GeV/c);n#sigma_{TPC} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); - histos.add("EventTwoTracks/ElectronOther/PID/hTPCnSigmaVsEP", ";Electron #it{p} (GeV/c);n#sigma_{TPC} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); - histos.add("EventTwoTracks/ElectronOther/PID/hTPCnSigmaVsMP", ";Muon #it{p} (GeV/c);n#sigma_{TPC} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); - histos.add("EventTwoTracks/ElectronOther/PID/hTPCnSigmaVsPP", ";Pion #it{p} (GeV/c);n#sigma_{TPC} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); - histos.add("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsP", ";Track #it{p} (GeV/c);n#sigma_{TOF} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); - histos.add("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsEP", ";Electron #it{p} (GeV/c);n#sigma_{TOF} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); - histos.add("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsMP", ";Muon #it{p} (GeV/c);n#sigma_{TOF} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); - histos.add("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsPP", ";Pion #it{p} (GeV/c);n#sigma_{TOF} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisNsigma}); - } - - if (doFourTracks) { - histos.add("EventFourTracks/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventFourTracks/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventFourTracks/hInvariantMassWideNoMothers", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventFourTracks/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventFourTracks/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventFourTracks/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventFourTracks/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventFourTracks/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventFourTracks/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventFourTracks/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - - histos.add("EventFourTracks/WithElectron/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventFourTracks/WithElectron/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventFourTracks/WithElectron/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventFourTracks/WithElectron/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventFourTracks/WithElectron/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventFourTracks/WithElectron/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventFourTracks/WithElectron/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventFourTracks/WithElectron/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventFourTracks/WithElectron/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - - histos.add("EventFourTracks/WithMuon/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventFourTracks/WithMuon/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventFourTracks/WithMuon/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventFourTracks/WithMuon/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventFourTracks/WithMuon/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventFourTracks/WithMuon/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventFourTracks/WithMuon/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventFourTracks/WithMuon/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventFourTracks/WithMuon/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - - histos.add("EventFourTracks/WithPion/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventFourTracks/WithPion/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventFourTracks/WithPion/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventFourTracks/WithPion/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventFourTracks/WithPion/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventFourTracks/WithPion/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventFourTracks/WithPion/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventFourTracks/WithPion/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventFourTracks/WithPion/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - } - - if (doSixTracks) { - histos.add("EventSixTracks/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventSixTracks/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventSixTracks/hInvariantMassWideNoMothers", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventSixTracks/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventSixTracks/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventSixTracks/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventSixTracks/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventSixTracks/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventSixTracks/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventSixTracks/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); - - histos.add("EventSixTracks/SixPions/hInvariantMass", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMass}); - histos.add("EventSixTracks/SixPions/hInvariantMassWide", ";Invariant mass (GeV/c^{2});Number of events (-)", HistType::kTH1D, {confAxis.zzAxisInvMassWide}); - histos.add("EventSixTracks/SixPions/hMotherP", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMom}); - histos.add("EventSixTracks/SixPions/hMotherPwide", ";Mother #it{p} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisMomWide}); - histos.add("EventSixTracks/SixPions/hMotherPt", ";Mother #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPt}); - histos.add("EventSixTracks/SixPions/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisPhi}); - histos.add("EventSixTracks/SixPions/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisRap}); - histos.add("EventSixTracks/SixPions/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {confAxis.zzAxisInvMassWide, confAxis.zzAxisPt}); - histos.add("EventSixTracks/SixPions/PID/hTPCsignalVsP", ";Track #it{p} (GeV/c);TPC d#it{E}/d#it{x} (arb. units)", HistType::kTH2D, {confAxis.zzAxisMom, confAxis.zzAxisTPCdEdx}); } if (doTruthHistos) { @@ -704,6 +662,14 @@ struct UpcTauCentralBarrelRL { histos.add("Tracks/Truth/hPionEta", ";Pion #eta (-);Number of events (-)", HistType::kTH1D, {confAxis.zzAxisEta}); } + // histos.add("ProcessDataDG/hSelections", ";Selection (-);Number of passed collision (-)", HistType::kTH1D, {confAxis.zzAxisSelections}); + // histos.add("ProcessDataSG/hSelections", ";Selection (-);Number of passed collision (-)", HistType::kTH1D, {confAxis.zzAxisSelections}); + // histos.add("ProcessMCrecDG/hSelections", ";Selection (-);Number of passed collision (-)", HistType::kTH1D, {confAxis.zzAxisSelections}); + // histos.add("ProcessMCrecSG/hSelections", ";Selection (-);Number of passed collision (-)", HistType::kTH1D, {confAxis.zzAxisSelections}); + // histos.add("ProcessMCgen/hSelections", ";Selection (-);Number of passed collision (-)", HistType::kTH1D, {confAxis.zzAxisSelections}); + // histos.add("OutputTable/hSelections", ";Selection (-);Number of passed collision (-)", HistType::kTH1D, {confAxis.zzAxisSelections}); + histos.add("OutputTable/hRejections", ";Rejections (-);Number of passed collision (-)", HistType::kTH1D, {confAxis.zzAxisSelections}); + } // end init // run (always called before process :( ) @@ -746,12 +712,12 @@ struct UpcTauCentralBarrelRL { bool isFulfillsITSHitRequirementsReinstatement(uint8_t itsClusterMap) const { - constexpr uint8_t bit = 1; - for (auto& itsRequirement : cutMyRequiredITSHits) { - auto hits = std::count_if(itsRequirement.second.begin(), itsRequirement.second.end(), [&](auto&& requiredLayer) { return itsClusterMap & (bit << requiredLayer); }); - if ((itsRequirement.first == -1) && (hits > 0)) { + constexpr uint8_t kBit = 1; + for (const auto& kITSrequirement : cutMyRequiredITSHits) { + auto hits = std::count_if(kITSrequirement.second.begin(), kITSrequirement.second.end(), [&](auto&& requiredLayer) { return itsClusterMap & (kBit << requiredLayer); }); + if ((kITSrequirement.first == -1) && (hits > 0)) { return false; // no hits were required in specified layers - } else if (hits < itsRequirement.first) { + } else if (hits < kITSrequirement.first) { return false; // not enough hits found in specified layers } } @@ -800,6 +766,15 @@ struct UpcTauCentralBarrelRL { return false; if (track.tpcChi2NCl() > cutGlobalTrack.cutMaxTPCchi2) return false; // TPC chi2 + if (cutGlobalTrack.cutGoodITSTPCmatching) { + if (track.itsChi2NCl() < 0.) + return false; // good ITS-TPC matching means ITS ch2 is not negative + } + // TOF + if (track.hasTOF()) { + if (track.tpcChi2NCl() > cutGlobalTrack.cutMaxTOFchi2) + return false; // TOF chi2 + } return true; } @@ -883,53 +858,226 @@ struct UpcTauCentralBarrelRL { return false; // FTOC - if ((std::abs(coll.timeFT0C()) > maxFITtime) && coll.timeFT0A() > -998.) + if ((std::abs(coll.timeFT0C()) > maxFITtime) && coll.timeFT0C() > -998.) + return false; + + return true; + } + + template + bool isGoodRCTflag(C const& coll) + { + switch (cutSample.cutRCTflag) { + case 1: + return sgSelector.isCBTOk(coll); + case 2: + return sgSelector.isCBTZdcOk(coll); + case 3: + return sgSelector.isCBTHadronOk(coll); + case 4: + return sgSelector.isCBTHadronZdcOk(coll); + default: + return true; + } + } + + template + bool isGoodROFtime(C const& coll) + { + + // kNoTimeFrameBorder + if (cutSample.cutEvTFb && !coll.tfb()) + return false; + + // kNoITSROFrameBorder + if (cutSample.cutEvITSROFb && !coll.itsROFb()) + return false; + + // kNoSameBunchPileup + if (cutSample.cutEvSbp && !coll.sbp()) + return false; + + // kIsGoodZvtxFT0vsPV + if (cutSample.cutEvZvtxFT0vPV && !coll.zVtxFT0vPV()) + return false; + + // kIsVertexITSTPC + if (cutSample.cutEvVtxITSTPC && !coll.vtxITSTPC()) + return false; + + // Occupancy + if (coll.occupancyInTime() > cutSample.cutEvOccupancy) + return false; + + // kNoCollInTimeRangeStandard + if (cutSample.cutEvTrs && !coll.trs()) + return false; + + // kNoCollInRofStandard + if (cutSample.cutEvTrofs && !coll.trofs()) + return false; + + // kNoHighMultCollInPrevRof + if (cutSample.cutEvHmpr && !coll.hmpr()) + return false; + + return true; + } + + unsigned int bitsRejection = 0; + unsigned int bitsRejectElCan = 0; + unsigned int bitsRejectMuPiCan = 0; + unsigned int bitsRejectTauEvent = 0; + + void outputGlobalRejectionHistogram() + { + + for (int i{0}; i < 10; i++) { + if (bitsRejection & (1 << i)) + histos.get(HIST("OutputTable/hRejections"))->Fill(i); + } + } + + void outputDetailedRejectionHistogram() + { + + for (int i{0}; i < 10; i++) { + if (bitsRejectTauEvent & (1 << i)) + histos.get(HIST("OutputTable/hRejections"))->Fill(i + 10); + } + + for (int i{0}; i < 10; i++) { + if (bitsRejectElCan & (1 << i)) + histos.get(HIST("OutputTable/hRejections"))->Fill(i + 20); + } + + for (int i{0}; i < 10; i++) { + if (bitsRejectMuPiCan & (1 << i)) + histos.get(HIST("OutputTable/hRejections"))->Fill(i + 30); + } + } + + template + void fillRejectElectronCandidate(T const& electronCandidate) + // Fill reasons of rejecting electron candidate + { + if (electronCandidate.tpcNSigmaEl() < cutPreselect.cutCanMaxElectronNsigmaEl || electronCandidate.tpcNSigmaEl() > cutPreselect.cutCanMinElectronNsigmaEl) + bitsRejectElCan |= (1 << 0); + if (cutPreselect.cutCanElectronHasTOF && !electronCandidate.hasTOF()) + bitsRejectElCan |= (1 << 1); + } + + template + bool isElectronCandidate(T const& electronCandidate) + // Loose criterium to find electron-like particle + // Requiring TOF to avoid double-counting pions/electrons and for better timing + { + fillRejectElectronCandidate(electronCandidate); + if (electronCandidate.tpcNSigmaEl() < cutPreselect.cutCanMaxElectronNsigmaEl || electronCandidate.tpcNSigmaEl() > cutPreselect.cutCanMinElectronNsigmaEl) + return false; + if (cutPreselect.cutCanElectronHasTOF && !electronCandidate.hasTOF()) return false; + return true; + } + template + bool fillRejectMuPionCandidate(T const& muPionCandidate) + // Fill reasons of rejecting mupion candidate + { + if (muPionCandidate.tpcNSigmaMu() < cutPreselect.cutCanMaxMuonNsigmaEl || muPionCandidate.tpcNSigmaMu() > cutPreselect.cutCanMinMuonNsigmaEl) + bitsRejectMuPiCan |= (1 << 0); + if (muPionCandidate.tpcNSigmaPi() < cutPreselect.cutCanMaxPionNsigmaEl || muPionCandidate.tpcNSigmaPi() > cutPreselect.cutCanMinPionNsigmaEl) + bitsRejectMuPiCan |= (1 << 1); + if (cutPreselect.cutCanMupionHasTOF && !muPionCandidate.hasTOF()) + bitsRejectMuPiCan |= (1 << 2); return true; } template - bool selectedGoodElectron(T const& electronCandidate) + bool isMuPionCandidate(T const& muPionCandidate) + // Loose criterium to find muon/pion-like particle + // Requiring TOF for better timing { - if (cutTauEvent.cutElectronHasTOF && !electronCandidate.hasTOF()) + if (muPionCandidate.tpcNSigmaMu() < cutPreselect.cutCanMaxMuonNsigmaEl || muPionCandidate.tpcNSigmaMu() > cutPreselect.cutCanMinMuonNsigmaEl) + return false; + if (muPionCandidate.tpcNSigmaPi() < cutPreselect.cutCanMaxPionNsigmaEl || muPionCandidate.tpcNSigmaPi() > cutPreselect.cutCanMinPionNsigmaEl) return false; + if (cutPreselect.cutCanMupionHasTOF && !muPionCandidate.hasTOF()) + return false; + return true; + } + + template + bool selectedGoodElectron(T const& electronCandidate) + { if (electronCandidate.tpcNSigmaEl() < cutTauEvent.cutMaxElectronNsigmaEl || electronCandidate.tpcNSigmaEl() > cutTauEvent.cutMinElectronNsigmaEl) return false; if (electronCandidate.tpcNSigmaPi() > cutTauEvent.cutMinElectronNsigmaPi && electronCandidate.tpcNSigmaPi() < cutTauEvent.cutMaxElectronNsigmaPi) return false; - if (electronCandidate.tpcNSigmaKa() > cutTauEvent.cutMinElectronNsigmaKa && electronCandidate.tpcNSigmaKa() < cutTauEvent.cutMaxElectronNsigmaKa) - return false; - if (electronCandidate.tpcNSigmaPr() > cutTauEvent.cutMinElectronNsigmaPr && electronCandidate.tpcNSigmaPr() < cutTauEvent.cutMaxElectronNsigmaPr) + if (cutTauEvent.cutElectronHasTOF && !electronCandidate.hasTOF()) return false; + if (electronCandidate.hasTOF()) { + if (electronCandidate.tofNSigmaEl() < cutTauEvent.cutMaxElectronTofNsigmaEl || electronCandidate.tofNSigmaEl() > cutTauEvent.cutMinElectronTofNsigmaEl) + return false; + if (electronCandidate.tofNSigmaPr() > cutTauEvent.cutMinElectronNsigmaPr && electronCandidate.tofNSigmaPr() < cutTauEvent.cutMaxElectronNsigmaPr) + return false; + if (momentum(electronCandidate.px(), electronCandidate.py(), electronCandidate.pz()) < 1.0) { + if (electronCandidate.tofNSigmaKa() > cutTauEvent.cutMinElectronTofNsigmaKa && electronCandidate.tofNSigmaKa() < cutTauEvent.cutMaxElectronTofNsigmaKa) + return false; + } else { + if (electronCandidate.tpcNSigmaKa() > cutTauEvent.cutMinElectronNsigmaKa && electronCandidate.tpcNSigmaKa() < cutTauEvent.cutMaxElectronNsigmaKa) + return false; + } + } return true; } template bool selectedGoodPion(T const& pionCandidate) { - if (cutTauEvent.cutPionHasTOF && !pionCandidate.hasTOF()) - return false; if (pionCandidate.tpcNSigmaPi() < cutTauEvent.cutMaxPionNsigmaPi || pionCandidate.tpcNSigmaPi() > cutTauEvent.cutMinPionNsigmaPi) return false; - if (pionCandidate.tpcNSigmaKa() > cutTauEvent.cutMinPionNsigmaKa && pionCandidate.tpcNSigmaKa() < cutTauEvent.cutMaxPionNsigmaKa) + if (cutTauEvent.cutPionHasTOF && !pionCandidate.hasTOF()) return false; + if (pionCandidate.hasTOF()) { + if (pionCandidate.tofNSigmaPi() < cutTauEvent.cutMaxPionTofNsigmaPi || pionCandidate.tofNSigmaPi() > cutTauEvent.cutMinPionTofNsigmaPi) + return false; + if (pionCandidate.tofNSigmaPr() > cutTauEvent.cutMinElectronNsigmaPr && pionCandidate.tofNSigmaPr() < cutTauEvent.cutMaxElectronNsigmaPr) + return false; + if (momentum(pionCandidate.px(), pionCandidate.py(), pionCandidate.pz()) < 1.0) { + if (pionCandidate.tofNSigmaKa() > cutTauEvent.cutMinElectronTofNsigmaKa && pionCandidate.tofNSigmaKa() < cutTauEvent.cutMaxElectronTofNsigmaKa) + return false; + } + } return true; } template bool selectedTauEvent(T const& trkDaug1, T const& trkDaug2) { - TLorentzVector mother, daug[2], motherOfPions, pion[2]; + ROOT::Math::LorentzVector> mother, daug[2], motherOfPions, pion[2]; daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + if (cutTauEvent.useThresholdsPID) { + if (isElectronCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassElectron, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isElectronCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassElectron, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + if (isMuPionCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassPionCharged, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isMuPionCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassPionCharged, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + } mother = daug[0] + daug[1]; - pion[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(kPiPlus), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); - pion[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(kPiMinus), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + pion[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassPionCharged, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + pion[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassPionCharged, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); motherOfPions = pion[0] + pion[1]; - int enumTrk1 = enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)); + + int enumTrk1 = (cutTauEvent.useThresholdsPID ? (isElectronCandidate(trkDaug1) ? P_ELECTRON : P_PION) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC))); if (cutTauEvent.cutOppositeCharge && (trkDaug1.sign() * trkDaug2.sign() > 0)) return false; + if (cutTauEvent.cutSameCharge && (trkDaug1.sign() * trkDaug2.sign() < 0)) + return false; if (calculateAcoplanarity(daug[0].Phi(), daug[1].Phi()) > cutTauEvent.cutMaxAcoplanarity) return false; if (calculateAcoplanarity(daug[0].Phi(), daug[1].Phi()) < cutTauEvent.cutMinAcoplanarity) @@ -986,16 +1134,17 @@ struct UpcTauCentralBarrelRL { int countPVGTpions = 0; int countPVGTothers = 0; int countTOFtracks = 0; + int countPVGTelmupiAlt = 0; + int countPVGTelectronsAlt = 0; + int countPVGTmupionsAlt = 0; std::vector vecPVidx; - std::vector vecPIDidx; + std::vector vecPVnewPIDidx; // Loop over tracks with selections for (const auto& track : reconstructedBarrelTracks) { if (!track.isPVContributor()) continue; - if (cutGlobalTrack.applyGlobalTrackSelection) { - if (isGlobalTrackReinstatement(track) != 1) - continue; - } + if (cutGlobalTrack.applyGlobalTrackSelection && !isGlobalTrackReinstatement(track)) + continue; countPVGT++; float trkPx = track.px(); float trkPy = track.py(); @@ -1021,7 +1170,6 @@ struct UpcTauCentralBarrelRL { if (track.hasTOF()) countTOFtracks++; int hypothesisID = testPIDhypothesis(track, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC); - vecPIDidx.push_back(hypothesisID); if (hypothesisID == P_ELECTRON || hypothesisID == P_MUON || hypothesisID == P_PION) { countPVGTselected++; vecPVidx.push_back(track.index()); @@ -1035,7 +1183,17 @@ struct UpcTauCentralBarrelRL { } else { countPVGTothers++; } - + // alternative selection + if (isElectronCandidate(track)) { + countPVGTelmupiAlt++; + countPVGTelectronsAlt++; + vecPVnewPIDidx.push_back(track.index()); + } + if (isMuPionCandidate(track)) { + countPVGTelmupiAlt++; + countPVGTmupionsAlt++; + vecPVnewPIDidx.push_back(track.index()); + } } // Loop over tracks with selections histos.get(HIST("Events/hNreconstructedPVGT"))->Fill(countPVGT); @@ -1045,25 +1203,55 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("Events/hNreconstructedPVGTpions"))->Fill(countPVGTpions); histos.get(HIST("Events/hNreconstructedPVGTothers"))->Fill(countPVGTothers); - if (countPVGTselected == 2 && doTwoTracks) { - TLorentzVector mother, daug[2], motherOfPions, pion[2], motherOfMuons, muon[2]; - const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(vecPVidx[0]); - const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(vecPVidx[1]); + bool isTwoSelectedTracks = (cutTauEvent.useThresholdsPID ? countPVGTelmupiAlt == 2 : countPVGTselected == 2); + bool isElEl = (cutTauEvent.useThresholdsPID ? countPVGTelectronsAlt == 2 : countPVGTelectrons == 2); + bool isPiPi = (cutTauEvent.useThresholdsPID ? countPVGTmupionsAlt == 2 : (countPVGTmuons == 2 || (countPVGTmuons == 1 && countPVGTpions == 1) || countPVGTpions == 2)); + bool isFourPion = (cutTauEvent.useThresholdsPID ? countPVGTmupionsAlt == 4 : countPVGTpions == 4); + bool isElThreePion = (cutTauEvent.useThresholdsPID ? (countPVGTelectronsAlt == 1 && countPVGTmupionsAlt == 3) : (countPVGTelectrons == 1 && (countPVGTmuons == 3 || (countPVGTmuons == 2 && countPVGTpions == 1) || (countPVGTmuons == 1 && countPVGTpions == 2) || countPVGTpions == 3))); + bool isSixPion = (cutTauEvent.useThresholdsPID ? countPVGTmupionsAlt == 6 : countPVGTpions == 6); + bool isElMuPion = (cutTauEvent.useThresholdsPID ? (countPVGTelectronsAlt == 1 && countPVGTmupionsAlt == 1) : ((countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1))); + + if (isElEl) + histos.get(HIST("Events/hChannels"))->Fill(CH_EE); + if (isPiPi) + histos.get(HIST("Events/hChannels"))->Fill(CH_PIPI); + if (isFourPion) + histos.get(HIST("Events/hChannels"))->Fill(CH_FOURPI); + if (isElThreePion) + histos.get(HIST("Events/hChannels"))->Fill(CH_ETHREEPI); + if (isSixPion) + histos.get(HIST("Events/hChannels"))->Fill(CH_SIXPI); + if (isElMuPion) + histos.get(HIST("Events/hChannels"))->Fill(CH_EMUPI); + + if (isTwoSelectedTracks && doTwoTracks) { + ROOT::Math::LorentzVector> mother, daug[2], motherOfPions, pion[2], motherOfMuons, muon[2]; + const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(cutTauEvent.useThresholdsPID ? vecPVnewPIDidx[0] : vecPVidx[0]); + const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(cutTauEvent.useThresholdsPID ? vecPVnewPIDidx[1] : vecPVidx[1]); daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + if (cutTauEvent.useThresholdsPID) { + if (isElectronCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassElectron, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isElectronCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassElectron, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + if (isMuPionCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassPionCharged, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isMuPionCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassPionCharged, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + } mother = daug[0] + daug[1]; - pion[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(kPiPlus), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); - pion[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(kPiMinus), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + pion[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassPionCharged, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + pion[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassPionCharged, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); motherOfPions = pion[0] + pion[1]; - muon[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(kMuonPlus), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); - muon[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(kMuonMinus), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + muon[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassMuon, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + muon[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassMuon, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); motherOfMuons = muon[0] + muon[1]; const auto acoplanarity = calculateAcoplanarity(daug[0].Phi(), daug[1].Phi()); const auto collinearity = calculateCollinearity(daug[0].Eta(), daug[1].Eta(), daug[0].Phi(), daug[1].Phi()); if (cutTauEvent.applyTauEventSelection && !selectedTauEvent(trkDaug1, trkDaug2)) { return; } - histos.get(HIST("EventTwoTracks/hInvariantMass"))->Fill(mother.M()); histos.get(HIST("EventTwoTracks/hInvariantMassWide"))->Fill(mother.M()); histos.get(HIST("EventTwoTracks/hInvariantMassWideAllPionMass"))->Fill(motherOfPions.M()); @@ -1074,13 +1262,16 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("EventTwoTracks/hMotherPt"))->Fill(mother.Pt()); histos.get(HIST("EventTwoTracks/hMotherPhi"))->Fill(mother.Phi()); histos.get(HIST("EventTwoTracks/hMotherRapidity"))->Fill(mother.Rapidity()); + histos.get(HIST("EventTwoTracks/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); + histos.get(HIST("EventTwoTracks/hDaughtersEnergyAsymmetry"))->Fill((daug[0].E() - daug[1].E()) / (daug[0].E() + daug[1].E())); + histos.get(HIST("EventTwoTracks/hDaughtersMomentaAsymmetry"))->Fill((daug[0].P() - daug[1].P()) / (daug[0].P() + daug[1].P())); + histos.get(HIST("EventTwoTracks/hDaughtersPtAsymmetry"))->Fill((daug[0].Pt() - daug[1].Pt()) / (daug[0].Pt() + daug[1].Pt())); histos.get(HIST("EventTwoTracks/hDaughtersP"))->Fill(daug[0].P(), daug[1].P()); histos.get(HIST("EventTwoTracks/hDaughtersPwide"))->Fill(daug[0].P(), daug[1].P()); histos.get(HIST("EventTwoTracks/hDaughtersPt"))->Fill(daug[0].Pt(), daug[1].Pt()); histos.get(HIST("EventTwoTracks/hDaughtersPhi"))->Fill(daug[0].Phi(), daug[1].Phi()); histos.get(HIST("EventTwoTracks/hDaughtersRapidity"))->Fill(daug[0].Rapidity(), daug[1].Rapidity()); histos.get(HIST("EventTwoTracks/hDaughtersEnergyFractions"))->Fill(daug[0].E() / (daug[0].E() + daug[1].E()), daug[1].E() / (daug[0].E() + daug[1].E())); - histos.get(HIST("EventTwoTracks/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); if (motherOfPions.Pt() < 0.2) { histos.get(HIST("EventTwoTracks/hInvariantMassWideAllPionMassPtCut"))->Fill(motherOfPions.M()); } @@ -1092,12 +1283,11 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("EventTwoTracks/hDaughtersPvsITSclusterSizeXcos"))->Fill(getAvgITSClSize(trkDaug1) * getCosLambda(trkDaug1), trkDaug1.sign() * daug[0].P()); histos.get(HIST("EventTwoTracks/hDaughtersPvsITSclusterSizeXcos"))->Fill(getAvgITSClSize(trkDaug2) * getCosLambda(trkDaug2), trkDaug2.sign() * daug[1].P()); - // ee, mm, em, pp, ep, mp, pppp, eppp, mppp, pppppp - if (countPVGTelectrons == 2) { - histos.get(HIST("Events/hChannels"))->Fill(CH_EE); + if (isElEl) { histos.get(HIST("EventTwoTracks/TwoElectrons/hInvariantMass"))->Fill(mother.M()); histos.get(HIST("EventTwoTracks/TwoElectrons/hInvariantMassWide"))->Fill(mother.M()); histos.get(HIST("EventTwoTracks/TwoElectrons/hAcoplanarity"))->Fill(acoplanarity); + histos.get(HIST("EventTwoTracks/TwoElectrons/hCollinearity"))->Fill(collinearity); histos.get(HIST("EventTwoTracks/TwoElectrons/hMotherP"))->Fill(mother.P()); histos.get(HIST("EventTwoTracks/TwoElectrons/hMotherPwide"))->Fill(mother.P()); histos.get(HIST("EventTwoTracks/TwoElectrons/hMotherPt"))->Fill(mother.Pt()); @@ -1135,133 +1325,44 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("EventTwoTracks/TwoElectrons/hDaughtersPtvsModPhiTOF"))->Fill(daug[1].P(), getPhiModN(daug[1].Phi(), trkDaug2.sign(), 1)); } } - if (countPVGTmuons == 2) { - histos.get(HIST("Events/hChannels"))->Fill(CH_MUMU); - histos.get(HIST("EventTwoTracks/TwoMuons/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/TwoMuons/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/TwoMuons/hAcoplanarity"))->Fill(acoplanarity); - histos.get(HIST("EventTwoTracks/TwoMuons/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/TwoMuons/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/TwoMuons/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventTwoTracks/TwoMuons/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventTwoTracks/TwoMuons/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventTwoTracks/TwoMuons/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersP"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPwide"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPt"))->Fill(daug[0].Pt(), daug[1].Pt()); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPhi"))->Fill(daug[0].Phi(), daug[1].Phi()); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersRapidity"))->Fill(daug[0].Rapidity(), daug[1].Rapidity()); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhi"))->Fill(daug[0].P(), getPhiModN(daug[0].Phi(), trkDaug1.sign(), 1)); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhi"))->Fill(daug[1].P(), getPhiModN(daug[1].Phi(), trkDaug2.sign(), 1)); - if (mother.Pt() < 0.2) { - histos.get(HIST("EventTwoTracks/TwoMuons/hInvariantMassWidePtCut"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhiPtCut"))->Fill(daug[0].P(), getPhiModN(daug[0].Phi(), trkDaug1.sign(), 1)); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhiPtCut"))->Fill(daug[1].P(), getPhiModN(daug[1].Phi(), trkDaug2.sign(), 1)); - if (countTOFtracks == 2) { - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhiPtCutTOF"))->Fill(daug[0].P(), getPhiModN(daug[0].Phi(), trkDaug1.sign(), 1)); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhiPtCutTOF"))->Fill(daug[1].P(), getPhiModN(daug[1].Phi(), trkDaug2.sign(), 1)); - } - } - if (countTOFtracks == 2) { - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhiTOF"))->Fill(daug[0].P(), getPhiModN(daug[0].Phi(), trkDaug1.sign(), 1)); - histos.get(HIST("EventTwoTracks/TwoMuons/hDaughtersPtvsModPhiTOF"))->Fill(daug[1].P(), getPhiModN(daug[1].Phi(), trkDaug2.sign(), 1)); - } - } - if (countPVGTelectrons == 1 && countPVGTmuons == 1) { - histos.get(HIST("Events/hChannels"))->Fill(CH_EMU); - histos.get(HIST("EventTwoTracks/ElectronMuon/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hAcoplanarity"))->Fill(acoplanarity); - histos.get(HIST("EventTwoTracks/ElectronMuon/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hDaughtersP"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hDaughtersPwide"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hDaughtersPt"))->Fill(daug[0].Pt(), daug[1].Pt()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hDaughtersPhi"))->Fill(daug[0].Phi(), daug[1].Phi()); - histos.get(HIST("EventTwoTracks/ElectronMuon/hDaughtersRapidity"))->Fill(daug[0].Rapidity(), daug[1].Rapidity()); - } - if (countPVGTpions == 2) { - histos.get(HIST("Events/hChannels"))->Fill(CH_PIPI); - histos.get(HIST("EventTwoTracks/TwoPions/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/TwoPions/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/TwoPions/hAcoplanarity"))->Fill(acoplanarity); - histos.get(HIST("EventTwoTracks/TwoPions/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/TwoPions/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/TwoPions/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventTwoTracks/TwoPions/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventTwoTracks/TwoPions/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventTwoTracks/TwoPions/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersP"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPwide"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPt"))->Fill(daug[0].Pt(), daug[1].Pt()); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPhi"))->Fill(daug[0].Phi(), daug[1].Phi()); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersRapidity"))->Fill(daug[0].Rapidity(), daug[1].Rapidity()); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPtvsModPhi"))->Fill(daug[0].P(), getPhiModN(daug[0].Phi(), trkDaug1.sign(), 1)); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPtvsModPhi"))->Fill(daug[1].P(), getPhiModN(daug[1].Phi(), trkDaug2.sign(), 1)); - if (mother.Pt() < 0.2) { - histos.get(HIST("EventTwoTracks/TwoPions/hInvariantMassWidePtCut"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPtvsModPhiPtCut"))->Fill(daug[0].P(), getPhiModN(daug[0].Phi(), trkDaug1.sign(), 1)); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPtvsModPhiPtCut"))->Fill(daug[1].P(), getPhiModN(daug[1].Phi(), trkDaug2.sign(), 1)); - if (countTOFtracks == 2) { - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPtvsModPhiPtCutTOF"))->Fill(daug[0].P(), getPhiModN(daug[0].Phi(), trkDaug1.sign(), 1)); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPtvsModPhiPtCutTOF"))->Fill(daug[1].P(), getPhiModN(daug[1].Phi(), trkDaug2.sign(), 1)); - } - } - if (countTOFtracks == 2) { - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPtvsModPhiTOF"))->Fill(daug[0].P(), getPhiModN(daug[0].Phi(), trkDaug1.sign(), 1)); - histos.get(HIST("EventTwoTracks/TwoPions/hDaughtersPtvsModPhiTOF"))->Fill(daug[1].P(), getPhiModN(daug[1].Phi(), trkDaug2.sign(), 1)); - } - } - if (countPVGTelectrons == 1 && countPVGTpions == 1) { - histos.get(HIST("Events/hChannels"))->Fill(CH_EPI); - histos.get(HIST("EventTwoTracks/ElectronPion/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/ElectronPion/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/ElectronPion/hAcoplanarity"))->Fill(acoplanarity); - histos.get(HIST("EventTwoTracks/ElectronPion/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/ElectronPion/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/ElectronPion/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventTwoTracks/ElectronPion/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventTwoTracks/ElectronPion/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventTwoTracks/ElectronPion/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - histos.get(HIST("EventTwoTracks/ElectronPion/hDaughtersP"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/ElectronPion/hDaughtersPwide"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/ElectronPion/hDaughtersPt"))->Fill(daug[0].Pt(), daug[1].Pt()); - histos.get(HIST("EventTwoTracks/ElectronPion/hDaughtersPhi"))->Fill(daug[0].Phi(), daug[1].Phi()); - histos.get(HIST("EventTwoTracks/ElectronPion/hDaughtersRapidity"))->Fill(daug[0].Rapidity(), daug[1].Rapidity()); - } - if (countPVGTpions == 1 && countPVGTmuons == 1) { - histos.get(HIST("Events/hChannels"))->Fill(CH_MUPI); - histos.get(HIST("EventTwoTracks/MuonPion/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/MuonPion/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/MuonPion/hAcoplanarity"))->Fill(acoplanarity); - histos.get(HIST("EventTwoTracks/MuonPion/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/MuonPion/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/MuonPion/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventTwoTracks/MuonPion/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventTwoTracks/MuonPion/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventTwoTracks/MuonPion/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - histos.get(HIST("EventTwoTracks/MuonPion/hDaughtersP"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/MuonPion/hDaughtersPwide"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/MuonPion/hDaughtersPt"))->Fill(daug[0].Pt(), daug[1].Pt()); - histos.get(HIST("EventTwoTracks/MuonPion/hDaughtersPhi"))->Fill(daug[0].Phi(), daug[1].Phi()); - histos.get(HIST("EventTwoTracks/MuonPion/hDaughtersRapidity"))->Fill(daug[0].Rapidity(), daug[1].Rapidity()); - if (mother.Pt() < 0.2) { - histos.get(HIST("EventTwoTracks/MuonPion/hInvariantMassWidePtCut"))->Fill(mother.M()); + if (isElMuPion) { + const auto& electronPt = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); + const auto& electronP = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].P() : daug[1].P(); + const auto& electronE = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].E() : daug[1].E(); + const auto& mupionPt = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].Pt() : daug[0].Pt(); + const auto& mupionP = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].P() : daug[0].P(); + const auto& mupionE = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].E() : daug[0].E(); + + ROOT::Math::LorentzVector> motherOfPiKaon, kaon; + if (isElectronCandidate(trkDaug1)) { + kaon.SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassKaonCharged, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + motherOfPiKaon = kaon + daug[1]; + } else { + kaon.SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassKaonCharged, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + motherOfPiKaon = daug[0] + kaon; } - } - if ((countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1)) { - double electronPt = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); - double electronE = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].E() : daug[1].E(); - double mupionE = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].E() : daug[0].E(); - histos.get(HIST("Events/hChannels"))->Fill(CH_EMUPI); histos.get(HIST("EventTwoTracks/ElectronMuPi/hInvariantMass"))->Fill(mother.M()); histos.get(HIST("EventTwoTracks/ElectronMuPi/hInvariantMassWide"))->Fill(mother.M()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PionsSelection/hInvariantMass"))->Fill(motherOfPions.M()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PionsSelection/hInvariantMassWide"))->Fill(motherOfPions.M()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/hInvariantMass"))->Fill(motherOfPiKaon.M()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/hInvariantMassWide"))->Fill(motherOfPiKaon.M()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/hMotherMassVsPt"))->Fill(motherOfPiKaon.M(), motherOfPiKaon.Pt()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/hMotherMassVsElectronP"))->Fill(motherOfPiKaon.M(), electronP); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/hIMKvsIMe"))->Fill(motherOfPiKaon.M(), mother.M()); + if (electronPt < cutTauEvent.cutElectronPt) { + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hInvariantMass"))->Fill(motherOfPiKaon.M()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hInvariantMassWide"))->Fill(motherOfPiKaon.M()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hMotherMassVsPt"))->Fill(motherOfPiKaon.M(), motherOfPiKaon.Pt()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hIMKvsIMe"))->Fill(motherOfPiKaon.M(), mother.M()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutLow/hElectronPwideVsOtherPwide"))->Fill(electronP, mupionP); + } else { + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hInvariantMass"))->Fill(motherOfPiKaon.M()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hInvariantMassWide"))->Fill(motherOfPiKaon.M()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hMotherMassVsPt"))->Fill(motherOfPiKaon.M(), motherOfPiKaon.Pt()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hIMKvsIMe"))->Fill(motherOfPiKaon.M(), mother.M()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/KstarSelection/eMomentaCutHigh/hElectronPwideVsOtherPwide"))->Fill(electronP, mupionP); + } histos.get(HIST("EventTwoTracks/ElectronMuPi/hAcoplanarity"))->Fill(acoplanarity); histos.get(HIST("EventTwoTracks/ElectronMuPi/hCollinearity"))->Fill(collinearity); histos.get(HIST("EventTwoTracks/ElectronMuPi/hMotherP"))->Fill(mother.P()); @@ -1270,19 +1371,26 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("EventTwoTracks/ElectronMuPi/hMotherPhi"))->Fill(mother.Phi()); histos.get(HIST("EventTwoTracks/ElectronMuPi/hMotherRapidity"))->Fill(mother.Rapidity()); histos.get(HIST("EventTwoTracks/ElectronMuPi/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hMotherMassVsElectronP"))->Fill(mother.M(), electronP); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hMotherMassVsAcoplanarity"))->Fill(mother.M(), acoplanarity); histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPt"))->Fill(electronPt); histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPtWide"))->Fill(electronPt); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hDaughtersEnergyAsymmetry"))->Fill((daug[0].E() - daug[1].E()) / (daug[0].E() + daug[1].E())); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hDaughtersMomentaAsymmetry"))->Fill((daug[0].P() - daug[1].P()) / (daug[0].P() + daug[1].P())); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hDaughtersPtAsymmetry"))->Fill((daug[0].Pt() - daug[1].Pt()) / (daug[0].Pt() + daug[1].Pt())); histos.get(HIST("EventTwoTracks/ElectronMuPi/hDaughtersP"))->Fill(daug[0].P(), daug[1].P()); histos.get(HIST("EventTwoTracks/ElectronMuPi/hDaughtersPwide"))->Fill(daug[0].P(), daug[1].P()); histos.get(HIST("EventTwoTracks/ElectronMuPi/hDaughtersPt"))->Fill(daug[0].Pt(), daug[1].Pt()); histos.get(HIST("EventTwoTracks/ElectronMuPi/hDaughtersPhi"))->Fill(daug[0].Phi(), daug[1].Phi()); histos.get(HIST("EventTwoTracks/ElectronMuPi/hDaughtersRapidity"))->Fill(daug[0].Rapidity(), daug[1].Rapidity()); histos.get(HIST("EventTwoTracks/ElectronMuPi/hDaughtersEnergyFractions"))->Fill(electronE / (electronE + mupionE), mupionE / (electronE + mupionE)); - histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPvsOtherP"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].P() : daug[1].P(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].P() : daug[0].P()); - histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPwideVsOtherPwide"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].P() : daug[1].P(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].P() : daug[0].P()); - histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPtVsOtherPt"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].Pt() : daug[0].Pt()); - histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPhiVsOtherPhi"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Phi() : daug[1].Phi(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].Phi() : daug[0].Phi()); - histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronRapVsOtherRap"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Rapidity() : daug[1].Rapidity(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].Rapidity() : daug[0].Rapidity()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPvsOtherP"))->Fill(electronP, mupionP); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPwideVsOtherPwide"))->Fill(electronP, mupionP); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPvsAcoplanarity"))->Fill(electronP, acoplanarity); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hOtherPvsAcoplanarity"))->Fill(mupionP, acoplanarity); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPtVsOtherPt"))->Fill(electronPt, mupionPt); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPhiVsOtherPhi"))->Fill(isElectronCandidate(trkDaug1) ? daug[0].Phi() : daug[1].Phi(), isElectronCandidate(trkDaug1) ? daug[1].Phi() : daug[0].Phi()); + histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronRapVsOtherRap"))->Fill(isElectronCandidate(trkDaug1) ? daug[0].Rapidity() : daug[1].Rapidity(), isElectronCandidate(trkDaug1) ? daug[1].Rapidity() : daug[0].Rapidity()); histos.get(HIST("EventTwoTracks/ElectronMuPi/hNeventsPtCuts"))->Fill(0); if (mother.Pt() < 9.) histos.get(HIST("EventTwoTracks/ElectronMuPi/hNeventsPtCuts"))->Fill(1); @@ -1309,158 +1417,6 @@ struct UpcTauCentralBarrelRL { if (electronPt > 2. && electronPt < 100.) histos.get(HIST("EventTwoTracks/ElectronMuPi/hNeventsPtCuts"))->Fill(12); } - if ((countPVGTelectrons == 2) || (countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1)) { - double electronPt = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); - if (countPVGTelectrons == 2) - electronPt = (daug[0].Pt() > daug[1].Pt()) ? daug[0].Pt() : daug[1].Pt(); - histos.get(HIST("EventTwoTracks/ElectronOther/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/ElectronOther/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventTwoTracks/ElectronOther/hAcoplanarity"))->Fill(acoplanarity); - histos.get(HIST("EventTwoTracks/ElectronOther/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/ElectronOther/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventTwoTracks/ElectronOther/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventTwoTracks/ElectronOther/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventTwoTracks/ElectronOther/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventTwoTracks/ElectronOther/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPt"))->Fill(electronPt); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPtWide"))->Fill(electronPt); - histos.get(HIST("EventTwoTracks/ElectronOther/hDaughtersP"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/ElectronOther/hDaughtersPwide"))->Fill(daug[0].P(), daug[1].P()); - histos.get(HIST("EventTwoTracks/ElectronOther/hDaughtersPt"))->Fill(daug[0].Pt(), daug[1].Pt()); - histos.get(HIST("EventTwoTracks/ElectronOther/hDaughtersPhi"))->Fill(daug[0].Phi(), daug[1].Phi()); - histos.get(HIST("EventTwoTracks/ElectronOther/hDaughtersRapidity"))->Fill(daug[0].Rapidity(), daug[1].Rapidity()); - if (countPVGTelectrons == 2) { - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPvsOtherP"))->Fill(((daug[0].P() > daug[1].P()) ? daug[0].P() : daug[1].P()), ((daug[0].P() > daug[1].P()) ? daug[1].P() : daug[0].P())); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPwideVsOtherPwide"))->Fill(((daug[0].P() > daug[1].P()) ? daug[0].P() : daug[1].P()), ((daug[0].P() > daug[1].P()) ? daug[1].P() : daug[0].P())); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPtVsOtherPt"))->Fill(((daug[0].P() > daug[1].P()) ? daug[0].Pt() : daug[1].Pt()), ((daug[0].P() > daug[1].P()) ? daug[1].Pt() : daug[0].Pt())); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPhiVsOtherPhi"))->Fill(((daug[0].P() > daug[1].P()) ? daug[0].Phi() : daug[1].Phi()), ((daug[0].P() > daug[1].P()) ? daug[1].Phi() : daug[0].Phi())); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronRapVsOtherRap"))->Fill(((daug[0].P() > daug[1].P()) ? daug[0].Rapidity() : daug[1].Rapidity()), ((daug[0].P() > daug[1].P()) ? daug[1].Rapidity() : daug[0].Rapidity())); - } else { - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPvsOtherP"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].P() : daug[1].P(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].P() : daug[0].P()); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPwideVsOtherPwide"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].P() : daug[1].P(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].P() : daug[0].P()); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPtVsOtherPt"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].Pt() : daug[0].Pt()); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronPhiVsOtherPhi"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Phi() : daug[1].Phi(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].Phi() : daug[0].Phi()); - histos.get(HIST("EventTwoTracks/ElectronOther/hElectronRapVsOtherRap"))->Fill((enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Rapidity() : daug[1].Rapidity(), (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[1].Rapidity() : daug[0].Rapidity()); - } - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(0); - if (mother.Pt() < 9.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(1); - if (mother.Pt() < 8.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(2); - if (mother.Pt() < 7.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(3); - if (mother.Pt() < 6.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(4); - if (mother.Pt() < 5.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(5); - if (mother.Pt() < 4.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(6); - if (mother.Pt() < 3.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(7); - if (mother.Pt() < 2.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(8); - if (mother.Pt() < 1.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(9); - if (electronPt > 0.1 && electronPt < 1.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(10); - if (electronPt > 1. && electronPt < 2.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(11); - if (electronPt > 2. && electronPt < 100.) - histos.get(HIST("EventTwoTracks/ElectronOther/hNeventsPtCuts"))->Fill(12); - } - } else if (countPVGTselected == 4 && doFourTracks) { - - TLorentzVector mother, daug[4]; - const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(vecPVidx[0]); - const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(vecPVidx[1]); - const auto& trkDaug3 = reconstructedBarrelTracks.iteratorAt(vecPVidx[2]); - const auto& trkDaug4 = reconstructedBarrelTracks.iteratorAt(vecPVidx[3]); - daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); - daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); - daug[2].SetPxPyPzE(trkDaug3.px(), trkDaug3.py(), trkDaug3.pz(), energy(pdg->Mass(trackPDG(trkDaug3, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug3.px(), trkDaug3.py(), trkDaug3.pz())); - daug[3].SetPxPyPzE(trkDaug4.px(), trkDaug4.py(), trkDaug4.pz(), energy(pdg->Mass(trackPDG(trkDaug4, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug4.px(), trkDaug4.py(), trkDaug4.pz())); - mother = daug[0] + daug[1] + daug[2] + daug[3]; - - histos.get(HIST("EventFourTracks/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventFourTracks/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventFourTracks/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventFourTracks/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventFourTracks/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventFourTracks/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventFourTracks/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventFourTracks/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - - // ee, mm, em, pp, ep, mp, pppp, eppp, mppp, pppppp - if (countPVGTpions == 4) { - histos.get(HIST("Events/hChannels"))->Fill(CH_FOURPI); - histos.get(HIST("EventFourTracks/WithPion/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventFourTracks/WithPion/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventFourTracks/WithPion/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventFourTracks/WithPion/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventFourTracks/WithPion/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventFourTracks/WithPion/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventFourTracks/WithPion/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventFourTracks/WithPion/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - } - if (countPVGTelectrons == 1 && countPVGTpions == 3) { - histos.get(HIST("Events/hChannels"))->Fill(CH_ETHREEPI); - histos.get(HIST("EventFourTracks/WithElectron/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventFourTracks/WithElectron/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventFourTracks/WithElectron/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventFourTracks/WithElectron/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventFourTracks/WithElectron/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventFourTracks/WithElectron/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventFourTracks/WithElectron/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventFourTracks/WithElectron/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - } - if (countPVGTpions == 3 && countPVGTmuons == 1) { - histos.get(HIST("Events/hChannels"))->Fill(CH_MUTHREEPI); - histos.get(HIST("EventFourTracks/WithMuon/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventFourTracks/WithMuon/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventFourTracks/WithMuon/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventFourTracks/WithMuon/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventFourTracks/WithMuon/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventFourTracks/WithMuon/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventFourTracks/WithMuon/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventFourTracks/WithMuon/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - } - } else if (countPVGTselected == 6 && doSixTracks) { - TLorentzVector mother, daug[6]; - const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(vecPVidx[0]); - const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(vecPVidx[1]); - const auto& trkDaug3 = reconstructedBarrelTracks.iteratorAt(vecPVidx[2]); - const auto& trkDaug4 = reconstructedBarrelTracks.iteratorAt(vecPVidx[3]); - const auto& trkDaug5 = reconstructedBarrelTracks.iteratorAt(vecPVidx[4]); - const auto& trkDaug6 = reconstructedBarrelTracks.iteratorAt(vecPVidx[5]); - daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); - daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); - daug[2].SetPxPyPzE(trkDaug3.px(), trkDaug3.py(), trkDaug3.pz(), energy(pdg->Mass(trackPDG(trkDaug3, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug3.px(), trkDaug3.py(), trkDaug3.pz())); - daug[3].SetPxPyPzE(trkDaug4.px(), trkDaug4.py(), trkDaug4.pz(), energy(pdg->Mass(trackPDG(trkDaug4, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug4.px(), trkDaug4.py(), trkDaug4.pz())); - daug[4].SetPxPyPzE(trkDaug5.px(), trkDaug5.py(), trkDaug5.pz(), energy(pdg->Mass(trackPDG(trkDaug5, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug5.px(), trkDaug5.py(), trkDaug5.pz())); - daug[5].SetPxPyPzE(trkDaug6.px(), trkDaug6.py(), trkDaug6.pz(), energy(pdg->Mass(trackPDG(trkDaug6, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug6.px(), trkDaug6.py(), trkDaug6.pz())); - mother = daug[0] + daug[1] + daug[2] + daug[3] + daug[4] + daug[5]; - - histos.get(HIST("EventSixTracks/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventSixTracks/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventSixTracks/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventSixTracks/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventSixTracks/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventSixTracks/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventSixTracks/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventSixTracks/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - - // ee, mm, em, pp, ep, mp, pppp, eppp, mppp, pppppp - if (countPVGTpions == 6) { - histos.get(HIST("Events/hChannels"))->Fill(CH_SIXPI); - histos.get(HIST("EventSixTracks/SixPions/hInvariantMass"))->Fill(mother.M()); - histos.get(HIST("EventSixTracks/SixPions/hInvariantMassWide"))->Fill(mother.M()); - histos.get(HIST("EventSixTracks/SixPions/hMotherP"))->Fill(mother.P()); - histos.get(HIST("EventSixTracks/SixPions/hMotherPwide"))->Fill(mother.P()); - histos.get(HIST("EventSixTracks/SixPions/hMotherPt"))->Fill(mother.Pt()); - histos.get(HIST("EventSixTracks/SixPions/hMotherPhi"))->Fill(mother.Phi()); - histos.get(HIST("EventSixTracks/SixPions/hMotherRapidity"))->Fill(mother.Rapidity()); - histos.get(HIST("EventSixTracks/SixPions/hMotherMassVsPt"))->Fill(mother.M(), mother.Pt()); - } } else { printDebugMessage("Other particles"); } @@ -1516,22 +1472,24 @@ struct UpcTauCentralBarrelRL { int countPVGTelectrons = 0; int countPVGTmuons = 0; int countPVGTpions = 0; + int countPVGTelmupiAlt = 0; + int countPVGTelectronsAlt = 0; + int countPVGTmupionsAlt = 0; std::vector vecPVidx; std::vector vecPVnoPIDidx; + std::vector vecPVnewPIDidx; // Loop over tracks with selections for (const auto& track : reconstructedBarrelTracks) { if (!track.isPVContributor()) continue; - if (cutGlobalTrack.applyGlobalTrackSelection && !isGlobalTrackReinstatement(track)) { + if (cutGlobalTrack.applyGlobalTrackSelection && !isGlobalTrackReinstatement(track)) continue; - } countPVGT++; vecPVnoPIDidx.push_back(track.index()); float trkPx = track.px(); float trkPy = track.py(); float trkPz = track.pz(); if (track.hasTPC()) { - // histos.get(HIST("Tracks/GoodTrack/PID/hTPCsignalVsZ"))->Fill(track.z(),track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); @@ -1544,7 +1502,6 @@ struct UpcTauCentralBarrelRL { if (track.hasTOF()) histos.get(HIST("Tracks/GoodTrack/PID/hTOFsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofSignal()); if (track.sign() == 1) { - // histos.get(HIST("Tracks/GoodTrack/PID/PosCharge/hTPCsignalVsZ"))->Fill(track.z(),track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/PosCharge/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/PosCharge/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/PosCharge/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); @@ -1552,7 +1509,6 @@ struct UpcTauCentralBarrelRL { if (track.hasTOF()) histos.get(HIST("Tracks/GoodTrack/PID/PosCharge/hTOFsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofSignal()); } else if (track.sign() == -1) { - // histos.get(HIST("Tracks/GoodTrack/PID/NegCharge/hTPCsignalVsZ"))->Fill(track.z(),track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/NegCharge/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/NegCharge/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/NegCharge/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); @@ -1569,27 +1525,27 @@ struct UpcTauCentralBarrelRL { vecPVidx.push_back(track.index()); if (hypothesisID == P_ELECTRON) { countPVGTelectrons++; - // histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsZ"))->Fill(track.z(),track.tpcSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsPhi"))->Fill(phi(trkPx, trkPy), track.tpcSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcNSigmaEl()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsMu"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaMu()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsPi"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaPi()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsKa"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaKa()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsPr"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaPr()); - if (track.hasTOF()) { - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofNSigmaEl()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsMu"))->Fill(track.tofNSigmaEl(), track.tofNSigmaMu()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsPi"))->Fill(track.tofNSigmaEl(), track.tofNSigmaPi()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsKa"))->Fill(track.tofNSigmaEl(), track.tofNSigmaKa()); - histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsPr"))->Fill(track.tofNSigmaEl(), track.tofNSigmaPr()); + if (!cutTauEvent.useThresholdsPID) { + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsPhi"))->Fill(phi(trkPx, trkPy), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcNSigmaEl()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsMu"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaMu()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsPi"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaPi()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsKa"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaKa()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsPr"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaPr()); + if (track.hasTOF()) { + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofNSigmaEl()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsMu"))->Fill(track.tofNSigmaEl(), track.tofNSigmaMu()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsPi"))->Fill(track.tofNSigmaEl(), track.tofNSigmaPi()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsKa"))->Fill(track.tofNSigmaEl(), track.tofNSigmaKa()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsPr"))->Fill(track.tofNSigmaEl(), track.tofNSigmaPr()); + } } } else if (hypothesisID == P_MUON) { countPVGTmuons++; - // histos.get(HIST("Tracks/GoodTrack/PID/Muon/hTPCsignalVsZ"))->Fill(track.z(),track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/Muon/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/Muon/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/Muon/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); @@ -1609,7 +1565,65 @@ struct UpcTauCentralBarrelRL { } } else { countPVGTpions++; - // histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCsignalVsZ"))->Fill(track.z(),track.tpcSignal()); + if (!cutTauEvent.useThresholdsPID) { + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCsignalVsPhi"))->Fill(phi(trkPx, trkPy), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCnSigmaVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcNSigmaPi()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCnSigmaPiVsEl"))->Fill(track.tpcNSigmaPi(), track.tpcNSigmaEl()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCnSigmaPiVsMu"))->Fill(track.tpcNSigmaPi(), track.tpcNSigmaMu()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCnSigmaPiVsKa"))->Fill(track.tpcNSigmaPi(), track.tpcNSigmaKa()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCnSigmaPiVsPr"))->Fill(track.tpcNSigmaPi(), track.tpcNSigmaPr()); + if (track.hasTOF()) { + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTOFsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTOFnSigmaVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofNSigmaPi()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTOFnSigmaPiVsEl"))->Fill(track.tofNSigmaPi(), track.tofNSigmaEl()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTOFnSigmaPiVsMu"))->Fill(track.tofNSigmaPi(), track.tofNSigmaMu()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTOFnSigmaPiVsKa"))->Fill(track.tofNSigmaPi(), track.tofNSigmaKa()); + histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTOFnSigmaPiVsPr"))->Fill(track.tofNSigmaPi(), track.tofNSigmaPr()); + } + } + } + } else { + histos.get(HIST("Tracks/GoodTrack/PID/Others/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Others/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Others/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Others/hTPCsignalVsPhi"))->Fill(phi(trkPx, trkPy), track.tpcSignal()); + if (track.hasTOF()) { + histos.get(HIST("Tracks/GoodTrack/PID/Others/hTOFsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofSignal()); + } + } + // alternative selection + if (isElectronCandidate(track)) { + countPVGTelmupiAlt++; + countPVGTelectronsAlt++; + vecPVnewPIDidx.push_back(track.index()); + if (cutTauEvent.useThresholdsPID) { + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCsignalVsPhi"))->Fill(phi(trkPx, trkPy), track.tpcSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcNSigmaEl()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsMu"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaMu()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsPi"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaPi()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsKa"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaKa()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTPCnSigmaElVsPr"))->Fill(track.tpcNSigmaEl(), track.tpcNSigmaPr()); + if (track.hasTOF()) { + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofSignal()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofNSigmaEl()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsMu"))->Fill(track.tofNSigmaEl(), track.tofNSigmaMu()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsPi"))->Fill(track.tofNSigmaEl(), track.tofNSigmaPi()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsKa"))->Fill(track.tofNSigmaEl(), track.tofNSigmaKa()); + histos.get(HIST("Tracks/GoodTrack/PID/Electron/hTOFnSigmaElVsPr"))->Fill(track.tofNSigmaEl(), track.tofNSigmaPr()); + } + } + } + if (isMuPionCandidate(track)) { + countPVGTelmupiAlt++; + countPVGTmupionsAlt++; + vecPVnewPIDidx.push_back(track.index()); + if (cutTauEvent.useThresholdsPID) { histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); @@ -1628,21 +1642,12 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("Tracks/GoodTrack/PID/Pion/hTOFnSigmaPiVsPr"))->Fill(track.tofNSigmaPi(), track.tofNSigmaPr()); } } - } else { - // histos.get(HIST("Tracks/GoodTrack/PID/Others/hTPCsignalVsZ"))->Fill(track.z(),track.tpcSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Others/hTPCsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tpcSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Others/hTPCsignalVsPt"))->Fill(track.pt(), track.tpcSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Others/hTPCsignalVsEta"))->Fill(eta(trkPx, trkPy, trkPz), track.tpcSignal()); - histos.get(HIST("Tracks/GoodTrack/PID/Others/hTPCsignalVsPhi"))->Fill(phi(trkPx, trkPy), track.tpcSignal()); - if (track.hasTOF()) { - histos.get(HIST("Tracks/GoodTrack/PID/Others/hTOFsignalVsP"))->Fill(momentum(trkPx, trkPy, trkPz), track.tofSignal()); - } } } // Loop over tracks with selections if (countPVGT == 2 && doTwoTracks) { - TLorentzVector daug[2], pion[2], muon[2]; + ROOT::Math::LorentzVector> daug[2]; const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(vecPVnoPIDidx[0]); const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(vecPVnoPIDidx[1]); daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); @@ -1650,6 +1655,16 @@ struct UpcTauCentralBarrelRL { if (cutTauEvent.applyTauEventSelection && !selectedTauEvent(trkDaug1, trkDaug2)) { return; } + if (cutTauEvent.useThresholdsPID) { + if (isElectronCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassElectron, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isElectronCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassElectron, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + if (isMuPionCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassPionCharged, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isMuPionCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassPionCharged, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + } if (trkDaug1.hasTPC()) { histos.get(HIST("EventTwoTracks/PID/NoPID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); @@ -1669,20 +1684,32 @@ struct UpcTauCentralBarrelRL { } } - if (countPVGTselected == 2 && doTwoTracks) { - TLorentzVector daug[2], pion[2], muon[2]; - const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(vecPVidx[0]); - const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(vecPVidx[1]); + bool isTwoSelectedTracks = (cutTauEvent.useThresholdsPID ? countPVGTelmupiAlt == 2 : countPVGTselected == 2); + bool isElEl = (cutTauEvent.useThresholdsPID ? countPVGTelectronsAlt == 2 : countPVGTelectrons == 2); + bool isElMuPion = (cutTauEvent.useThresholdsPID ? (countPVGTelectronsAlt == 1 && countPVGTmupionsAlt == 1) : ((countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1))); + if (isTwoSelectedTracks && doTwoTracks) { + ROOT::Math::LorentzVector> daug[2], pion[2], muon[2]; + const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(cutTauEvent.useThresholdsPID ? vecPVnewPIDidx[0] : vecPVidx[0]); + const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(cutTauEvent.useThresholdsPID ? vecPVnewPIDidx[1] : vecPVidx[1]); daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); - pion[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(kPiPlus), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); - pion[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(kPiMinus), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); - muon[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(kMuonPlus), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); - muon[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(kMuonMinus), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + pion[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassPionCharged, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + pion[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassPionCharged, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + muon[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassMuon, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + muon[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassMuon, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); if (cutTauEvent.applyTauEventSelection && !selectedTauEvent(trkDaug1, trkDaug2)) { return; } - + if (cutTauEvent.useThresholdsPID) { + if (isElectronCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassElectron, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isElectronCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassElectron, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + if (isMuPionCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassPionCharged, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isMuPionCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassPionCharged, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + } if (trkDaug1.hasTPC()) { histos.get(HIST("EventTwoTracks/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); histos.get(HIST("EventTwoTracks/PID/hTPCnSigmaElVsP"))->Fill(daug[0].P(), trkDaug1.tpcNSigmaEl()); @@ -1693,7 +1720,7 @@ struct UpcTauCentralBarrelRL { if (trkDaug1.hasTOF()) { histos.get(HIST("EventTwoTracks/PID/hTOFsignalVsP"))->Fill(daug[0].P(), trkDaug1.tofSignal()); } - if (countPVGTelectrons == 2) { + if (isElEl) { histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCnSigmaVsP"))->Fill(daug[0].P(), trkDaug1.tpcNSigmaEl()); if (trkDaug1.hasTOF()) { @@ -1701,17 +1728,7 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFnSigmaVsP"))->Fill(daug[0].P(), trkDaug1.tofNSigmaEl()); } } - if (countPVGTmuons == 2) - histos.get(HIST("EventTwoTracks/TwoMuons/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - if (countPVGTpions == 2) - histos.get(HIST("EventTwoTracks/TwoPions/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - if (countPVGTelectrons == 1 && countPVGTmuons == 1) - histos.get(HIST("EventTwoTracks/ElectronMuon/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - if (countPVGTelectrons == 1 && countPVGTpions == 1) - histos.get(HIST("EventTwoTracks/ElectronPion/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - if (countPVGTpions == 1 && countPVGTmuons == 1) - histos.get(HIST("EventTwoTracks/MuonPion/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - if ((countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1)) { + if (isElMuPion) { histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsP"))->Fill(daug[0].P(), trkDaug1.tpcNSigmaEl()); if (trkDaug1.hasTOF()) { @@ -1719,14 +1736,6 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsP"))->Fill(daug[0].P(), trkDaug1.tofNSigmaEl()); } } - if ((countPVGTelectrons == 2) || (countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1)) { - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTPCnSigmaVsP"))->Fill(daug[0].P(), trkDaug1.tpcNSigmaEl()); - if (trkDaug1.hasTOF()) { - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFsignalVsP"))->Fill(daug[0].P(), trkDaug1.tofSignal()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsP"))->Fill(daug[0].P(), trkDaug1.tofNSigmaEl()); - } - } } if (trkDaug2.hasTPC()) { histos.get(HIST("EventTwoTracks/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); @@ -1738,7 +1747,7 @@ struct UpcTauCentralBarrelRL { if (trkDaug2.hasTOF()) { histos.get(HIST("EventTwoTracks/PID/hTOFsignalVsP"))->Fill(daug[1].P(), trkDaug2.tofSignal()); } - if (countPVGTelectrons == 2) { + if (isElEl) { histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCnSigmaVsP"))->Fill(daug[1].P(), trkDaug2.tpcNSigmaEl()); if (trkDaug2.hasTOF()) { @@ -1746,17 +1755,7 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFnSigmaVsP"))->Fill(daug[1].P(), trkDaug2.tofNSigmaEl()); } } - if (countPVGTmuons == 2) - histos.get(HIST("EventTwoTracks/TwoMuons/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - if (countPVGTpions == 2) - histos.get(HIST("EventTwoTracks/TwoPions/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - if (countPVGTelectrons == 1 && countPVGTmuons == 1) - histos.get(HIST("EventTwoTracks/ElectronMuon/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - if (countPVGTelectrons == 1 && countPVGTpions == 1) - histos.get(HIST("EventTwoTracks/ElectronPion/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - if (countPVGTpions == 1 && countPVGTmuons == 1) - histos.get(HIST("EventTwoTracks/MuonPion/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - if ((countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1)) { + if (isElMuPion) { histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsP"))->Fill(daug[1].P(), trkDaug2.tpcNSigmaEl()); if (trkDaug2.hasTOF()) { @@ -1764,17 +1763,9 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsP"))->Fill(daug[1].P(), trkDaug2.tofNSigmaEl()); } } - if ((countPVGTelectrons == 2) || (countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1)) { - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTPCnSigmaVsP"))->Fill(daug[1].P(), trkDaug2.tpcNSigmaEl()); - if (trkDaug2.hasTOF()) { - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFsignalVsP"))->Fill(daug[1].P(), trkDaug2.tofSignal()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsP"))->Fill(daug[1].P(), trkDaug2.tofNSigmaEl()); - } - } } if (trkDaug1.hasTPC() && trkDaug2.hasTPC()) { - if (countPVGTelectrons == 2) { + if ((doprocessDataDG || doprocessDataSG) && isElEl) { if (daug[0].P() > daug[1].P()) { histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCsignalVsLP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCsignalVsOP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); @@ -1803,23 +1794,23 @@ struct UpcTauCentralBarrelRL { } } } - if (!isMC && ((countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1))) { - double electronPt = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); - double electronPID = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); - double ElectronNsigmaEl = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaEl() : trkDaug2.tpcNSigmaEl(); - double ElectronNsigmaPi = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaPi() : trkDaug2.tpcNSigmaPi(); - double otherPt = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); - double otherPID = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); - double otherNsigmaMu = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaMu() : trkDaug2.tpcNSigmaMu(); - double otherNsigmaPi = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaPi() : trkDaug2.tpcNSigmaPi(); + if ((doprocessDataSG || doprocessDataDG) && isElMuPion) { + double electronPt = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); + double electronPID = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); + double electronNsigmaEl = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaEl() : trkDaug2.tpcNSigmaEl(); + double electronNsigmaPi = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaPi() : trkDaug2.tpcNSigmaPi(); + double otherPt = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); + double otherPID = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); + double otherNsigmaMu = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaMu() : trkDaug2.tpcNSigmaMu(); + double otherNsigmaPi = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaPi() : trkDaug2.tpcNSigmaPi(); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCsignalVsEPofE"))->Fill(electronPt, electronPID); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCsignalVsOPofO"))->Fill(otherPt, otherPID); - histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsEPofE"))->Fill(electronPt, ElectronNsigmaEl); + histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsEPofE"))->Fill(electronPt, electronNsigmaEl); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsMPofO"))->Fill(otherPt, otherNsigmaMu); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsPPofO"))->Fill(otherPt, otherNsigmaPi); - histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaEvsnSigmaPofE"))->Fill(ElectronNsigmaEl, ElectronNsigmaPi); + histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaEvsnSigmaPofE"))->Fill(electronNsigmaEl, electronNsigmaPi); if (trkDaug1.hasTOF()) { - if (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { + if (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFsignalVsEPofE"))->Fill(electronPt, trkDaug1.tofSignal()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsEPofE"))->Fill(electronPt, trkDaug1.tofNSigmaEl()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaEvsnSigmaPofE"))->Fill(trkDaug1.tofNSigmaEl(), trkDaug1.tofNSigmaPi()); @@ -1830,7 +1821,7 @@ struct UpcTauCentralBarrelRL { } } if (trkDaug2.hasTOF()) { - if (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { + if (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFsignalVsEPofE"))->Fill(electronPt, trkDaug2.tofSignal()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsEPofE"))->Fill(electronPt, trkDaug2.tofNSigmaEl()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaEvsnSigmaPofE"))->Fill(trkDaug2.tofNSigmaEl(), trkDaug2.tofNSigmaPi()); @@ -1841,142 +1832,6 @@ struct UpcTauCentralBarrelRL { } } } - if ((countPVGTelectrons == 2) || (countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1)) { - double electronPt = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); - double electronPID = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); - double ElectronNsigmaEl = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaEl() : trkDaug2.tpcNSigmaEl(); - double otherPt = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); - double otherPID = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); - double otherNsigmaMu = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaMu() : trkDaug2.tpcNSigmaMu(); - double otherNsigmaPi = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaPi() : trkDaug2.tpcNSigmaPi(); - if (countPVGTelectrons == 2) { - electronPt = (daug[0].Pt() > daug[1].Pt()) ? daug[0].Pt() : daug[1].Pt(); - electronPID = (daug[0].Pt() > daug[1].Pt()) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); - ElectronNsigmaEl = (daug[0].Pt() > daug[1].Pt()) ? trkDaug1.tpcNSigmaEl() : trkDaug2.tpcNSigmaEl(); - otherPt = (daug[0].Pt() > daug[1].Pt()) ? daug[1].Pt() : daug[0].Pt(); - otherPID = (daug[0].Pt() > daug[1].Pt()) ? trkDaug2.tpcSignal() : trkDaug1.tpcSignal(); - otherNsigmaMu = (daug[0].Pt() > daug[1].Pt()) ? trkDaug2.tpcNSigmaMu() : trkDaug1.tpcNSigmaMu(); - otherNsigmaPi = (daug[0].Pt() > daug[1].Pt()) ? trkDaug2.tpcNSigmaPi() : trkDaug1.tpcNSigmaPi(); - } - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTPCsignalVsEP"))->Fill(electronPt, electronPID); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTPCsignalVsOP"))->Fill(otherPt, otherPID); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTPCnSigmaVsEP"))->Fill(electronPt, ElectronNsigmaEl); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTPCnSigmaVsMP"))->Fill(otherPt, otherNsigmaMu); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTPCnSigmaVsPP"))->Fill(otherPt, otherNsigmaPi); - if (trkDaug1.hasTOF()) { - if (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFsignalVsEP"))->Fill(electronPt, trkDaug1.tofSignal()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsEP"))->Fill(electronPt, trkDaug1.tofNSigmaEl()); - } else { - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFsignalVsOP"))->Fill(otherPt, trkDaug1.tofSignal()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsMP"))->Fill(otherPt, trkDaug1.tofNSigmaMu()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsPP"))->Fill(otherPt, trkDaug1.tofNSigmaPi()); - } - } - if (trkDaug2.hasTOF()) { - if (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFsignalVsEP"))->Fill(electronPt, trkDaug2.tofSignal()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsEP"))->Fill(electronPt, trkDaug2.tofNSigmaEl()); - } else { - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFsignalVsOP"))->Fill(otherPt, trkDaug2.tofSignal()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsMP"))->Fill(otherPt, trkDaug2.tofNSigmaMu()); - histos.get(HIST("EventTwoTracks/ElectronOther/PID/hTOFnSigmaVsPP"))->Fill(otherPt, trkDaug2.tofNSigmaPi()); - } - } - } - } - } else if (countPVGTselected == 4 && doFourTracks) { - - TLorentzVector daug[4]; - const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(vecPVidx[0]); - const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(vecPVidx[1]); - const auto& trkDaug3 = reconstructedBarrelTracks.iteratorAt(vecPVidx[2]); - const auto& trkDaug4 = reconstructedBarrelTracks.iteratorAt(vecPVidx[3]); - daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); - daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); - daug[2].SetPxPyPzE(trkDaug3.px(), trkDaug3.py(), trkDaug3.pz(), energy(pdg->Mass(trackPDG(trkDaug3, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug3.px(), trkDaug3.py(), trkDaug3.pz())); - daug[3].SetPxPyPzE(trkDaug4.px(), trkDaug4.py(), trkDaug4.pz(), energy(pdg->Mass(trackPDG(trkDaug4, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug4.px(), trkDaug4.py(), trkDaug4.pz())); - - if (trkDaug1.hasTPC()) { - histos.get(HIST("EventFourTracks/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - if (countPVGTpions == 4) - histos.get(HIST("EventFourTracks/WithPion/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - if (countPVGTelectrons == 1 && countPVGTpions == 3) - histos.get(HIST("EventFourTracks/WithElectron/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - if (countPVGTpions == 3 && countPVGTmuons == 1) - histos.get(HIST("EventFourTracks/WithMuon/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - } - if (trkDaug2.hasTPC()) { - histos.get(HIST("EventFourTracks/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - if (countPVGTpions == 4) - histos.get(HIST("EventFourTracks/WithPion/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - if (countPVGTelectrons == 1 && countPVGTpions == 3) - histos.get(HIST("EventFourTracks/WithElectron/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - if (countPVGTpions == 3 && countPVGTmuons == 1) - histos.get(HIST("EventFourTracks/WithMuon/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - } - if (trkDaug3.hasTPC()) { - histos.get(HIST("EventFourTracks/PID/hTPCsignalVsP"))->Fill(daug[2].P(), trkDaug3.tpcSignal()); - if (countPVGTpions == 4) - histos.get(HIST("EventFourTracks/WithPion/PID/hTPCsignalVsP"))->Fill(daug[2].P(), trkDaug3.tpcSignal()); - if (countPVGTelectrons == 1 && countPVGTpions == 3) - histos.get(HIST("EventFourTracks/WithElectron/PID/hTPCsignalVsP"))->Fill(daug[2].P(), trkDaug3.tpcSignal()); - if (countPVGTpions == 3 && countPVGTmuons == 1) - histos.get(HIST("EventFourTracks/WithMuon/PID/hTPCsignalVsP"))->Fill(daug[2].P(), trkDaug3.tpcSignal()); - } - if (trkDaug4.hasTPC()) { - histos.get(HIST("EventFourTracks/PID/hTPCsignalVsP"))->Fill(daug[3].P(), trkDaug4.tpcSignal()); - if (countPVGTpions == 4) - histos.get(HIST("EventFourTracks/WithPion/PID/hTPCsignalVsP"))->Fill(daug[3].P(), trkDaug4.tpcSignal()); - if (countPVGTelectrons == 1 && countPVGTpions == 3) - histos.get(HIST("EventFourTracks/WithElectron/PID/hTPCsignalVsP"))->Fill(daug[3].P(), trkDaug4.tpcSignal()); - if (countPVGTpions == 3 && countPVGTmuons == 1) - histos.get(HIST("EventFourTracks/WithMuon/PID/hTPCsignalVsP"))->Fill(daug[3].P(), trkDaug4.tpcSignal()); - } - } else if (countPVGTselected == 6 && doSixTracks) { - TLorentzVector daug[6]; - const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(vecPVidx[0]); - const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(vecPVidx[1]); - const auto& trkDaug3 = reconstructedBarrelTracks.iteratorAt(vecPVidx[2]); - const auto& trkDaug4 = reconstructedBarrelTracks.iteratorAt(vecPVidx[3]); - const auto& trkDaug5 = reconstructedBarrelTracks.iteratorAt(vecPVidx[4]); - const auto& trkDaug6 = reconstructedBarrelTracks.iteratorAt(vecPVidx[5]); - daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); - daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); - daug[2].SetPxPyPzE(trkDaug3.px(), trkDaug3.py(), trkDaug3.pz(), energy(pdg->Mass(trackPDG(trkDaug3, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug3.px(), trkDaug3.py(), trkDaug3.pz())); - daug[3].SetPxPyPzE(trkDaug4.px(), trkDaug4.py(), trkDaug4.pz(), energy(pdg->Mass(trackPDG(trkDaug4, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug4.px(), trkDaug4.py(), trkDaug4.pz())); - daug[4].SetPxPyPzE(trkDaug5.px(), trkDaug5.py(), trkDaug5.pz(), energy(pdg->Mass(trackPDG(trkDaug5, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug5.px(), trkDaug5.py(), trkDaug5.pz())); - daug[5].SetPxPyPzE(trkDaug6.px(), trkDaug6.py(), trkDaug6.pz(), energy(pdg->Mass(trackPDG(trkDaug6, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug6.px(), trkDaug6.py(), trkDaug6.pz())); - - if (trkDaug1.hasTPC()) { - histos.get(HIST("EventSixTracks/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - if (countPVGTpions == 6) - histos.get(HIST("EventSixTracks/SixPions/PID/hTPCsignalVsP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); - } - if (trkDaug2.hasTPC()) { - histos.get(HIST("EventSixTracks/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - if (countPVGTpions == 6) - histos.get(HIST("EventSixTracks/SixPions/PID/hTPCsignalVsP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); - } - if (trkDaug3.hasTPC()) { - histos.get(HIST("EventSixTracks/PID/hTPCsignalVsP"))->Fill(daug[2].P(), trkDaug3.tpcSignal()); - if (countPVGTpions == 6) - histos.get(HIST("EventSixTracks/SixPions/PID/hTPCsignalVsP"))->Fill(daug[2].P(), trkDaug3.tpcSignal()); - } - if (trkDaug4.hasTPC()) { - histos.get(HIST("EventSixTracks/PID/hTPCsignalVsP"))->Fill(daug[3].P(), trkDaug4.tpcSignal()); - if (countPVGTpions == 6) - histos.get(HIST("EventSixTracks/SixPions/PID/hTPCsignalVsP"))->Fill(daug[3].P(), trkDaug4.tpcSignal()); - } - if (trkDaug5.hasTPC()) { - histos.get(HIST("EventSixTracks/PID/hTPCsignalVsP"))->Fill(daug[4].P(), trkDaug5.tpcSignal()); - if (countPVGTpions == 6) - histos.get(HIST("EventSixTracks/SixPions/PID/hTPCsignalVsP"))->Fill(daug[4].P(), trkDaug5.tpcSignal()); - } - if (trkDaug6.hasTPC()) { - histos.get(HIST("EventSixTracks/PID/hTPCsignalVsP"))->Fill(daug[5].P(), trkDaug6.tpcSignal()); - if (countPVGTpions == 6) - histos.get(HIST("EventSixTracks/SixPions/PID/hTPCsignalVsP"))->Fill(daug[5].P(), trkDaug6.tpcSignal()); } } else { printDebugMessage("Other particles"); @@ -1991,15 +1846,17 @@ struct UpcTauCentralBarrelRL { int countPVGTelectrons = 0; int countPVGTmuons = 0; int countPVGTpions = 0; + int countPVGTelmupiAlt = 0; + int countPVGTelectronsAlt = 0; + int countPVGTmupionsAlt = 0; std::vector vecPVidx; + std::vector vecPVnewPIDidx; // Loop over tracks with selections for (const auto& track : reconstructedBarrelTracks) { if (!track.isPVContributor()) continue; - if (cutGlobalTrack.applyGlobalTrackSelection) { - if (isGlobalTrackReinstatement(track) != 1) - continue; - } + if (cutGlobalTrack.applyGlobalTrackSelection && !isGlobalTrackReinstatement(track)) + continue; int hypothesisID = testPIDhypothesis(track, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC); if (hypothesisID == P_ELECTRON || hypothesisID == P_MUON || hypothesisID == P_PION) { countPVGTselected++; @@ -2012,20 +1869,73 @@ struct UpcTauCentralBarrelRL { countPVGTpions++; } } + // alternative selection + if (isElectronCandidate(track)) { + countPVGTelmupiAlt++; + countPVGTelectronsAlt++; + vecPVnewPIDidx.push_back(track.index()); + } + if (isMuPionCandidate(track)) { + countPVGTelmupiAlt++; + countPVGTmupionsAlt++; + vecPVnewPIDidx.push_back(track.index()); + } } // Loop over tracks with selections - if (countPVGTselected == 2 && doTwoTracks) { - TLorentzVector daug[2]; - const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(vecPVidx[0]); - const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(vecPVidx[1]); + bool isTwoSelectedTracks = (cutTauEvent.useThresholdsPID ? countPVGTelmupiAlt == 2 : countPVGTselected == 2); + bool isElEl = (cutTauEvent.useThresholdsPID ? countPVGTelectronsAlt == 2 : countPVGTelectrons == 2); + bool isElMuPion = (cutTauEvent.useThresholdsPID ? (countPVGTelectronsAlt == 1 && countPVGTmupionsAlt == 1) : ((countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1))); + if (isTwoSelectedTracks && doTwoTracks) { + ROOT::Math::LorentzVector> daug[2]; + const auto& trkDaug1 = reconstructedBarrelTracks.iteratorAt(cutTauEvent.useThresholdsPID ? vecPVnewPIDidx[0] : vecPVidx[0]); + const auto& trkDaug2 = reconstructedBarrelTracks.iteratorAt(cutTauEvent.useThresholdsPID ? vecPVnewPIDidx[1] : vecPVidx[1]); daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(pdg->Mass(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(pdg->Mass(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)), trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); if (cutTauEvent.applyTauEventSelection && !selectedTauEvent(trkDaug1, trkDaug2)) { return; } + if (cutTauEvent.useThresholdsPID) { + if (isElectronCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassElectron, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isElectronCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassElectron, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + if (isMuPionCandidate(trkDaug1)) + daug[0].SetPxPyPzE(trkDaug1.px(), trkDaug1.py(), trkDaug1.pz(), energy(MassPionCharged, trkDaug1.px(), trkDaug1.py(), trkDaug1.pz())); + if (isMuPionCandidate(trkDaug2)) + daug[1].SetPxPyPzE(trkDaug2.px(), trkDaug2.py(), trkDaug2.pz(), energy(MassPionCharged, trkDaug2.px(), trkDaug2.py(), trkDaug2.pz())); + } if (trkDaug1.hasTPC() && trkDaug2.hasTPC()) { - if (isMC && ((countPVGTelectrons == 1 && countPVGTmuons == 1) || (countPVGTelectrons == 1 && countPVGTpions == 1))) { + if ((doprocessMCgen || doprocessMCrecSG || doprocessMCrecDG) && isElEl) { + if (daug[0].P() > daug[1].P()) { + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCsignalVsLP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCsignalVsOP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCnSigmaVsLP"))->Fill(daug[0].P(), trkDaug1.tpcNSigmaEl()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCnSigmaVsOP"))->Fill(daug[1].P(), trkDaug2.tpcNSigmaEl()); + if (trkDaug1.hasTOF()) { + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFsignalVsLP"))->Fill(daug[0].P(), trkDaug1.tofSignal()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFnSigmaVsLP"))->Fill(daug[0].P(), trkDaug1.tofNSigmaEl()); + } + if (trkDaug2.hasTOF()) { + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFsignalVsOP"))->Fill(daug[1].P(), trkDaug2.tofSignal()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFnSigmaVsOP"))->Fill(daug[1].P(), trkDaug2.tofNSigmaEl()); + } + } else { + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCsignalVsOP"))->Fill(daug[0].P(), trkDaug1.tpcSignal()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCsignalVsLP"))->Fill(daug[1].P(), trkDaug2.tpcSignal()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCnSigmaVsOP"))->Fill(daug[0].P(), trkDaug1.tpcNSigmaEl()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTPCnSigmaVsLP"))->Fill(daug[1].P(), trkDaug2.tpcNSigmaEl()); + if (trkDaug1.hasTOF()) { + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFsignalVsOP"))->Fill(daug[0].P(), trkDaug1.tofSignal()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFnSigmaVsOP"))->Fill(daug[0].P(), trkDaug1.tofNSigmaEl()); + } + if (trkDaug2.hasTOF()) { + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFsignalVsLP"))->Fill(daug[1].P(), trkDaug2.tofSignal()); + histos.get(HIST("EventTwoTracks/TwoElectrons/PID/hTOFnSigmaVsLP"))->Fill(daug[1].P(), trkDaug2.tofNSigmaEl()); + } + } + } + if ((doprocessMCgen || doprocessMCrecSG || doprocessMCrecDG) && isElMuPion) { int pid = 0; if (trkDaug1.has_udMcParticle()) { const auto& part = trkDaug1.udMcParticle(); @@ -2046,7 +1956,7 @@ struct UpcTauCentralBarrelRL { } } bool isNotTrueElectron = false; - if (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { + if (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { if (trkDaug1.has_udMcParticle()) { const auto& particle = trkDaug1.udMcParticle(); if (enumMyParticle(particle.pdgCode()) != P_ELECTRON) @@ -2067,26 +1977,26 @@ struct UpcTauCentralBarrelRL { return; } - double electronPt = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); - double electronPID = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); - double ElectronNsigmaEl = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaEl() : trkDaug2.tpcNSigmaEl(); - double ElectronNsigmaPi = (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaPi() : trkDaug2.tpcNSigmaPi(); - double otherPt = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); - double otherPID = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); - double otherNsigmaEl = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaEl() : trkDaug2.tpcNSigmaEl(); - double otherNsigmaMu = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaMu() : trkDaug2.tpcNSigmaMu(); - double otherNsigmaPi = (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaPi() : trkDaug2.tpcNSigmaPi(); + double electronPt = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); + double electronPID = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); + double electronNsigmaEl = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaEl() : trkDaug2.tpcNSigmaEl(); + double electronNsigmaPi = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaPi() : trkDaug2.tpcNSigmaPi(); + double otherPt = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? daug[0].Pt() : daug[1].Pt(); + double otherPID = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcSignal() : trkDaug2.tpcSignal(); + double otherNsigmaEl = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaEl() : trkDaug2.tpcNSigmaEl(); + double otherNsigmaMu = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaMu() : trkDaug2.tpcNSigmaMu(); + double otherNsigmaPi = (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) ? trkDaug1.tpcNSigmaPi() : trkDaug2.tpcNSigmaPi(); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCsignalVsEPofE"))->Fill(electronPt, electronPID); - histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsEPofE"))->Fill(electronPt, ElectronNsigmaEl); - histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsPPofE"))->Fill(electronPt, ElectronNsigmaPi); - histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaEvsnSigmaPofE"))->Fill(ElectronNsigmaEl, ElectronNsigmaPi); + histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsEPofE"))->Fill(electronPt, electronNsigmaEl); + histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsPPofE"))->Fill(electronPt, electronNsigmaPi); + histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaEvsnSigmaPofE"))->Fill(electronNsigmaEl, electronNsigmaPi); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCsignalVsOPofO"))->Fill(otherPt, otherPID); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsEPofO"))->Fill(otherPt, otherNsigmaEl); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsMPofO"))->Fill(otherPt, otherNsigmaMu); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaVsPPofO"))->Fill(otherPt, otherNsigmaPi); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTPCnSigmaEvsnSigmaPofO"))->Fill(otherNsigmaEl, otherNsigmaPi); if (trkDaug1.hasTOF()) { - if (enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { + if (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug1) : enumMyParticle(trackPDG(trkDaug1, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFsignalVsEPofE"))->Fill(electronPt, trkDaug1.tofSignal()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsEPofE"))->Fill(electronPt, trkDaug1.tofNSigmaEl()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsPPofE"))->Fill(electronPt, trkDaug1.tofNSigmaPi()); @@ -2100,7 +2010,7 @@ struct UpcTauCentralBarrelRL { } } if (trkDaug2.hasTOF()) { - if (enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { + if (cutTauEvent.useThresholdsPID ? isElectronCandidate(trkDaug2) : enumMyParticle(trackPDG(trkDaug2, cutPID.cutSiTPC, cutPID.cutSiTOF, cutPID.usePIDwTOF, cutPID.useScutTOFinTPC)) == P_ELECTRON) { histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFsignalVsEPofE"))->Fill(electronPt, trkDaug2.tofSignal()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsEPofE"))->Fill(electronPt, trkDaug2.tofNSigmaEl()); histos.get(HIST("EventTwoTracks/ElectronMuPi/PID/hTOFnSigmaVsPPofE"))->Fill(electronPt, trkDaug2.tofNSigmaPi()); @@ -2218,57 +2128,272 @@ struct UpcTauCentralBarrelRL { histos.get(HIST("Events/Truth/hChannels"))->Fill(CH_SIXPI); } + template + void outputTauEventCandidates(C const& collision, Ts const& tracks) + { + + int countTracksPerCollision = 0; + int countGoodNonPVtracks = 0; + int countGoodPVtracks = 0; + std::vector vecTrkIdx; + // Loop over tracks with selections + for (const auto& track : tracks) { + countTracksPerCollision++; + if (!isGlobalTrackReinstatement(track)) + continue; + if (!track.isPVContributor()) { + countGoodNonPVtracks++; + continue; + } + countGoodPVtracks++; + vecTrkIdx.push_back(track.index()); + } // Loop over tracks with selections + + // Apply weak condition on track PID + int countPVGTel = 0; + int countPVGTmupi = 0; + if (countGoodPVtracks == 2) { + for (const auto& vecMember : vecTrkIdx) { + const auto& thisTrk = tracks.iteratorAt(vecMember); + if (isElectronCandidate(thisTrk)) { + countPVGTel++; + continue; + } + if (isMuPionCandidate(thisTrk)) { + countPVGTmupi++; + } + } + } + + if (cutPreselect.cutCanUseTrackPID ? ((countPVGTel == 2 && countPVGTmupi == 0) || (countPVGTel == 1 && countPVGTmupi == 1)) : countGoodPVtracks == cutPreselect.cutCanNgoodPVtracs) { + const auto& trk1 = tracks.iteratorAt(vecTrkIdx[0]); + const auto& trk2 = tracks.iteratorAt(vecTrkIdx[1]); + + float px[2] = {trk1.px(), trk2.px()}; + float py[2] = {trk1.py(), trk2.py()}; + float pz[2] = {trk1.pz(), trk2.pz()}; + int sign[2] = {trk1.sign(), trk2.sign()}; + float dcaxy[2] = {trk1.dcaXY(), trk2.dcaXY()}; + float dcaz[2] = {trk1.dcaZ(), trk2.dcaZ()}; + float trkTimeRes[2] = {trk1.trackTimeRes(), trk2.trackTimeRes()}; + uint32_t itsClusterSizesTrk1 = trk1.itsClusterSizes(); + uint32_t itsClusterSizesTrk2 = trk2.itsClusterSizes(); + float tpcSignal[2] = {trk1.tpcSignal(), trk2.tpcSignal()}; + float tpcEl[2] = {trk1.tpcNSigmaEl(), trk2.tpcNSigmaEl()}; + float tpcMu[2] = {trk1.tpcNSigmaMu(), trk2.tpcNSigmaMu()}; + float tpcPi[2] = {trk1.tpcNSigmaPi(), trk2.tpcNSigmaPi()}; + float tpcKa[2] = {trk1.tpcNSigmaKa(), trk2.tpcNSigmaKa()}; + float tpcPr[2] = {trk1.tpcNSigmaPr(), trk2.tpcNSigmaPr()}; + float tpcIP[2] = {trk1.tpcInnerParam(), trk2.tpcInnerParam()}; + float tofSignal[2] = {trk1.tofSignal(), trk2.tofSignal()}; + float tofEl[2] = {trk1.tofNSigmaEl(), trk2.tofNSigmaEl()}; + float tofMu[2] = {trk1.tofNSigmaMu(), trk2.tofNSigmaMu()}; + float tofPi[2] = {trk1.tofNSigmaPi(), trk2.tofNSigmaPi()}; + float tofKa[2] = {trk1.tofNSigmaKa(), trk2.tofNSigmaKa()}; + float tofPr[2] = {trk1.tofNSigmaPr(), trk2.tofNSigmaPr()}; + float tofEP[2] = {trk1.tofExpMom(), trk2.tofExpMom()}; + float ZNinfo[4] = {-999., -999., -999., -999.}; + if constexpr (requires { collision.udZdcsReduced(); }) { + ZNinfo[0] = collision.energyCommonZNA(); + ZNinfo[1] = collision.energyCommonZNC(); + ZNinfo[2] = collision.timeZNA(); + ZNinfo[3] = collision.timeZNC(); + } + + tauTwoTracks(collision.runNumber(), collision.globalBC(), countTracksPerCollision, collision.numContrib(), countGoodNonPVtracks, collision.posX(), collision.posY(), collision.posZ(), + collision.flags(), collision.occupancyInTime(), collision.hadronicRate(), collision.trs(), collision.trofs(), collision.hmpr(), + collision.tfb(), collision.itsROFb(), collision.sbp(), collision.zVtxFT0vPV(), collision.vtxITSTPC(), + collision.totalFT0AmplitudeA(), collision.totalFT0AmplitudeC(), collision.totalFV0AmplitudeA(), ZNinfo[0], ZNinfo[1], + collision.timeFT0A(), collision.timeFT0C(), collision.timeFV0A(), ZNinfo[2], ZNinfo[3], + px, py, pz, sign, dcaxy, dcaz, trkTimeRes, + itsClusterSizesTrk1, itsClusterSizesTrk2, + tpcSignal, tpcEl, tpcMu, tpcPi, tpcKa, tpcPr, tpcIP, + tofSignal, tofEl, tofMu, tofPi, tofKa, tofPr, tofEP); + } else { + // Store info on what would rejected events + bitsRejectTauEvent |= (1 << 0); + + int countTrksPerCol = 0; + int countNonPVtracks = 0; + int countBadTracks = 0; + // Loop over tracks with selections + for (const auto& track : tracks) { + countTrksPerCol++; + if (!isGlobalTrackReinstatement(track)) { + countBadTracks++; + } + if (!track.isPVContributor()) { + countNonPVtracks++; + } + } // Loop over tracks with selections + if (countTrksPerCol - countBadTracks != 2) + bitsRejectTauEvent |= (1 << 1); + if (countTrksPerCol - countNonPVtracks != 2) + bitsRejectTauEvent |= (1 << 2); + } + } + + template + void fillRejectionReasonDG(C const& collision) + { + if (!isGoodROFtime(collision)) + bitsRejection |= (1 << 1); + + if (!isGoodFITtime(collision, cutSample.cutFITtime)) + bitsRejection |= (1 << 2); + + if (cutSample.useNumContribs && (collision.numContrib() != cutSample.cutNumContribs)) + bitsRejection |= (1 << 3); + + if (cutSample.useRecoFlag && (collision.flags() != cutSample.cutRecoFlag)) + bitsRejection |= (1 << 4); + } + + template + void fillRejectionReasonSG(C const& collision) + { + int gapSide = collision.gapSide(); + + if (cutSample.useTrueGap) + gapSide = sgSelector.trueGap(collision, cutSample.cutTrueGapSideFV0, cutSample.cutTrueGapSideFT0A, cutSample.cutTrueGapSideFT0C, cutSample.cutTrueGapSideZDC); + + if (gapSide != cutSample.whichGapSide) + bitsRejection |= (1 << 0); + + if (!isGoodROFtime(collision)) + bitsRejection |= (1 << 1); + + if (!isGoodFITtime(collision, cutSample.cutFITtime)) + bitsRejection |= (1 << 2); + + if (cutSample.useNumContribs && (collision.numContrib() != cutSample.cutNumContribs)) + bitsRejection |= (1 << 3); + + if (cutSample.useRecoFlag && (collision.flags() != cutSample.cutRecoFlag)) + bitsRejection |= (1 << 4); + } + + template + void fillRejectionReasonMCSG(C const& collision) + { + if (collision.gapSide() != cutSample.whichGapSide) + bitsRejection |= (1 << 0); + + if (!isGoodROFtime(collision)) + bitsRejection |= (1 << 1); + + if (!isGoodFITtime(collision, cutSample.cutFITtime)) + bitsRejection |= (1 << 2); + + if (cutSample.useNumContribs && (collision.numContrib() != cutSample.cutNumContribs)) + bitsRejection |= (1 << 3); + + if (cutSample.useRecoFlag && (collision.flags() != cutSample.cutRecoFlag)) + bitsRejection |= (1 << 4); + } + void processDataDG(FullUDCollision const& reconstructedCollision, FullUDTracks const& reconstructedBarrelTracks) { + fillRejectionReasonDG(reconstructedCollision); + outputGlobalRejectionHistogram(); + + if (!isGoodRCTflag(reconstructedCollision)) + return; + + if (!isGoodROFtime(reconstructedCollision)) + return; if (!isGoodFITtime(reconstructedCollision, cutSample.cutFITtime)) return; + if (cutSample.useNumContribs && (reconstructedCollision.numContrib() != cutSample.cutNumContribs)) + return; + + if (cutSample.useRecoFlag && (reconstructedCollision.flags() != cutSample.cutRecoFlag)) + return; + if (doMainHistos) { fillHistograms(reconstructedBarrelTracks); fillFIThistograms(reconstructedCollision); } + if (doPIDhistos) fillPIDhistograms(reconstructedCollision, reconstructedBarrelTracks); + if (doOutputTauEvents) + outputTauEventCandidates(reconstructedCollision, reconstructedBarrelTracks); + + outputDetailedRejectionHistogram(); + } // end processDataDG void processDataSG(FullSGUDCollision const& reconstructedCollision, FullUDTracks const& reconstructedBarrelTracks) { + fillRejectionReasonSG(reconstructedCollision); + outputGlobalRejectionHistogram(); + + if (!isGoodRCTflag(reconstructedCollision)) + return; int gapSide = reconstructedCollision.gapSide(); int trueGapSide = sgSelector.trueGap(reconstructedCollision, cutSample.cutTrueGapSideFV0, cutSample.cutTrueGapSideFT0A, cutSample.cutTrueGapSideFT0C, cutSample.cutTrueGapSideZDC); - histos.fill(HIST("Events/UDtableGapSide"), gapSide); - histos.fill(HIST("Events/TrueGapSideDiffToTableValue"), gapSide - trueGapSide); + if (cutSample.useTrueGap) gapSide = trueGapSide; + if (!isGoodROFtime(reconstructedCollision)) + return; + if (gapSide != cutSample.whichGapSide) return; if (!isGoodFITtime(reconstructedCollision, cutSample.cutFITtime)) return; + if (cutSample.useNumContribs && (reconstructedCollision.numContrib() != cutSample.cutNumContribs)) + return; + + if (cutSample.useRecoFlag && (reconstructedCollision.flags() != cutSample.cutRecoFlag)) + return; + if (doMainHistos) { + histos.fill(HIST("Events/UDtableGapSide"), gapSide); + histos.fill(HIST("Events/TrueGapSideDiffToTableValue"), gapSide - trueGapSide); fillHistograms(reconstructedBarrelTracks); fillFIThistograms(reconstructedCollision); } + if (doPIDhistos) fillPIDhistograms(reconstructedCollision, reconstructedBarrelTracks); + if (doOutputTauEvents) + outputTauEventCandidates(reconstructedCollision, reconstructedBarrelTracks); + + outputDetailedRejectionHistogram(); + } // end processDataSG void processMCrecDG(FullMCUDCollision const& reconstructedCollision, FullMCUDTracks const& reconstructedBarrelTracks, aod::UDMcParticles const&) { - isMC = true; + fillRejectionReasonDG(reconstructedCollision); + outputGlobalRejectionHistogram(); + + if (!isGoodROFtime(reconstructedCollision)) + return; if (!isGoodFITtime(reconstructedCollision, cutSample.cutFITtime)) return; + if (cutSample.useNumContribs && (reconstructedCollision.numContrib() != cutSample.cutNumContribs)) + return; + + if (cutSample.useRecoFlag && (reconstructedCollision.flags() != cutSample.cutRecoFlag)) + return; + if (cutSample.applyAcceptanceSelection) { for (const auto& track : reconstructedBarrelTracks) { if (!track.isPVContributor()) @@ -2288,23 +2413,37 @@ struct UpcTauCentralBarrelRL { fillMCPIDhistograms(reconstructedBarrelTracks); } + if (doOutputTauEvents) + outputTauEventCandidates(reconstructedCollision, reconstructedBarrelTracks); + + outputDetailedRejectionHistogram(); + } // end processMCrecDG void processMCrecSG(FullMCSGUDCollision const& reconstructedCollision, FullMCUDTracks const& reconstructedBarrelTracks, aod::UDMcParticles const&) { - isMC = true; + fillRejectionReasonMCSG(reconstructedCollision); + outputGlobalRejectionHistogram(); int gapSide = reconstructedCollision.gapSide(); - histos.fill(HIST("Events/UDtableGapSide"), gapSide); if (gapSide != cutSample.whichGapSide) return; + if (!isGoodROFtime(reconstructedCollision)) + return; + if (!isGoodFITtime(reconstructedCollision, cutSample.cutFITtime)) return; + if (cutSample.useNumContribs && (reconstructedCollision.numContrib() != cutSample.cutNumContribs)) + return; + + if (cutSample.useRecoFlag && (reconstructedCollision.flags() != cutSample.cutRecoFlag)) + return; + if (cutSample.applyAcceptanceSelection) { for (const auto& track : reconstructedBarrelTracks) { if (!track.isPVContributor()) @@ -2315,6 +2454,7 @@ struct UpcTauCentralBarrelRL { } if (doMainHistos) { + histos.fill(HIST("Events/UDtableGapSide"), gapSide); fillHistograms(reconstructedBarrelTracks); fillFIThistograms(reconstructedCollision); } @@ -2324,12 +2464,16 @@ struct UpcTauCentralBarrelRL { fillMCPIDhistograms(reconstructedBarrelTracks); } + if (doOutputTauEvents) + outputTauEventCandidates(reconstructedCollision, reconstructedBarrelTracks); + + outputDetailedRejectionHistogram(); + } // end processMCrecDG void processMCgen(aod::UDMcCollision const& /*generatedCollision*/, aod::UDMcParticles const& particles) { - isMC = true; if (cutSample.applyAcceptanceSelection) { for (const auto& particle : particles) { @@ -2347,34 +2491,15 @@ struct UpcTauCentralBarrelRL { } // end processMCgenDG - void processTestMC(FullMCUDCollision const& /*reconstructedCollision*/, - FullMCUDTracks const& /*reconstructedBarrelTracks*/, - aod::UDMcCollisions const&, - aod::UDMcParticles const&) - { - // if (reconstructedCollision.has_udMcCollision()) { - // const auto& generatedCollision = reconstructedCollision.udMcCollision(); - // printDebugMessage(Form("%lli udMcCollision found", generatedCollision.size())); // FIXME: Type of size() is not invariant. - // } - - // const auto& track = reconstructedBarrelTracks.iteratorAt(0); - // if (track.size() && track.has_udMcParticle()) { - // const auto& particle = track.udMcParticle(); - // printDebugMessage(Form("%lli udMcParticle found", particle.size())); // FIXME: Type of size() is not invariant. - // } - - } // end processTestMC - - PROCESS_SWITCH(UpcTauCentralBarrelRL, processDataDG, "Iterate UD tables with measured data created by DG-Candidate-Producer.", false); - PROCESS_SWITCH(UpcTauCentralBarrelRL, processDataSG, "Iterate UD tables with measured data created by SG-Candidate-Producer.", false); - PROCESS_SWITCH(UpcTauCentralBarrelRL, processMCrecDG, "Iterate Monte Carlo UD tables with reconstructed data created by DG-Candidate-Producer. Similar to processDataDG but uses association to truth level.", false); - PROCESS_SWITCH(UpcTauCentralBarrelRL, processMCrecSG, "Iterate Monte Carlo UD tables with reconstructed data created by SG-Candidate-Producer. Similar to processDataSG but uses association to truth level and trueGap is not available.", false); - PROCESS_SWITCH(UpcTauCentralBarrelRL, processMCgen, "Iterate Monte Carlo UD tables with truth data.", false); - PROCESS_SWITCH(UpcTauCentralBarrelRL, processTestMC, "Simple test of indices in MC sample.", false); + PROCESS_SWITCH(UpcTauRl, processDataDG, "Iterate UD tables with measured data created by DG-Candidate-Producer.", false); + PROCESS_SWITCH(UpcTauRl, processDataSG, "Iterate UD tables with measured data created by SG-Candidate-Producer.", false); + PROCESS_SWITCH(UpcTauRl, processMCrecDG, "Iterate Monte Carlo UD tables with reconstructed data created by DG-Candidate-Producer. Similar to processDataDG but uses association to truth level.", false); + PROCESS_SWITCH(UpcTauRl, processMCrecSG, "Iterate Monte Carlo UD tables with reconstructed data created by SG-Candidate-Producer. Similar to processDataSG but uses association to truth level and trueGap is not available.", false); + PROCESS_SWITCH(UpcTauRl, processMCgen, "Iterate Monte Carlo UD tables with truth data.", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"upc-tau-rl"})}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGUD/Tasks/upcTauTau13topo.cxx b/PWGUD/Tasks/upcTauTau13topo.cxx index c7d3e870316..0d18b316b8b 100644 --- a/PWGUD/Tasks/upcTauTau13topo.cxx +++ b/PWGUD/Tasks/upcTauTau13topo.cxx @@ -9,9 +9,10 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // -// \brief tau tau analysis 1e+3pi topology -// \author Adam Matyja, adam.tomasz.matyja@cern.ch, adam.matryja@ifj.edu.pl -// \since January 2024 +/// \file upcTauTau13topo.cxx +/// \brief tau tau analysis 1e+3pi topology +/// \author Adam Matyja, adam.tomasz.matyja@cern.ch, adam.matryja@ifj.edu.pl +/// \since January 2024 // to run it execute: // copts="--configuration json://tautauConfig.json -b" // o2-analysis-ud-tautau13topo $copts > output.log @@ -33,33 +34,121 @@ #include "PWGUD/Core/DGPIDSelector.h" #include "PWGUD/Core/SGSelector.h" +#include "Common/Core/RecoDecay.h" +// #include +#include "TPDGCode.h" + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +// derived tables for tautau->4 (=1+3) tracks +namespace o2::aod +{ +namespace tau_tree +{ +// event info +DECLARE_SOA_COLUMN(RunNumber, runNumber, int32_t); +DECLARE_SOA_COLUMN(Bc, bc, int); +DECLARE_SOA_COLUMN(TotalTracks, totalTracks, int); +DECLARE_SOA_COLUMN(NumContrib, numContrib, int); +// DECLARE_SOA_COLUMN(GlobalNonPVtracks, globalNonPVtracks, int); +// DECLARE_SOA_COLUMN(PosX, posX, float); +// DECLARE_SOA_COLUMN(PosY, posY, float); +DECLARE_SOA_COLUMN(PosZ, posZ, float); +DECLARE_SOA_COLUMN(FlagUPC, flagUPC, bool); +DECLARE_SOA_COLUMN(OccupancyInTime, occupancyInTime, int); +DECLARE_SOA_COLUMN(HadronicRate, hadronicRate, double); +DECLARE_SOA_COLUMN(Trs, trs, bool); +DECLARE_SOA_COLUMN(Trofs, trofs, bool); +DECLARE_SOA_COLUMN(Hmpr, hmpr, bool); +// DECLARE_SOA_COLUMN(Tfb, tfb, int); +// DECLARE_SOA_COLUMN(ItsRofb, itsRofb, int); +// DECLARE_SOA_COLUMN(Sbp, sbp, int); +// DECLARE_SOA_COLUMN(ZvtxFT0vsPv, zvtxFT0vsPv, int); +// DECLARE_SOA_COLUMN(VtxITSTPC, vtxITSTPC, int); +DECLARE_SOA_COLUMN(ZdcAenergy, zdcAenergy, float); +DECLARE_SOA_COLUMN(ZdcCenergy, zdcCenergy, float); +DECLARE_SOA_COLUMN(Qtot, qtot, int16_t); +// FIT info +DECLARE_SOA_COLUMN(TotalFT0AmplitudeA, totalFT0AmplitudeA, float); +DECLARE_SOA_COLUMN(TotalFT0AmplitudeC, totalFT0AmplitudeC, float); +DECLARE_SOA_COLUMN(TotalFV0AmplitudeA, totalFV0AmplitudeA, float); +// DECLARE_SOA_COLUMN(TimeFT0A, timeFT0A, float); +// DECLARE_SOA_COLUMN(TimeFT0C, timeFT0C, float); +// DECLARE_SOA_COLUMN(TimeFV0A, timeFV0A, float); +// tracks +DECLARE_SOA_COLUMN(TrkPx, trkPx, float[4]); +DECLARE_SOA_COLUMN(TrkPy, trkPy, float[4]); +DECLARE_SOA_COLUMN(TrkPz, trkPz, float[4]); +// DECLARE_SOA_COLUMN(TrkSign, trkSign, int[4]); +// DECLARE_SOA_COLUMN(TrkDCAxy, trkDCAxy, float[4]); +// DECLARE_SOA_COLUMN(TrkDCAz, trkDCAz, float[4]); +DECLARE_SOA_COLUMN(TrkTPCcr, trkTPCcr, int[4]); +DECLARE_SOA_COLUMN(TrkTPCsignal, trkTPCsignal, float[4]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaEl, trkTPCnSigmaEl, float[4]); +// DECLARE_SOA_COLUMN(TrkTPCnSigmaMu, trkTPCnSigmaMu, float[4]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaPi, trkTPCnSigmaPi, float[4]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaKa, trkTPCnSigmaKa, float[4]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaPr, trkTPCnSigmaPr, float[4]); +DECLARE_SOA_COLUMN(TrkTPCnSigmaMu, trkTPCnSigmaMu, float[4]); +DECLARE_SOA_COLUMN(TrkTOFbeta, trkTOFbeta, float[4]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaEl, trkTOFnSigmaEl, float[4]); +// DECLARE_SOA_COLUMN(TrkTOFnSigmaMu, trkTOFnSigmaMu, float[4]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaPi, trkTOFnSigmaPi, float[4]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaKa, trkTOFnSigmaKa, float[4]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaPr, trkTOFnSigmaPr, float[4]); +DECLARE_SOA_COLUMN(TrkTOFnSigmaMu, trkTOFnSigmaMu, float[4]); +DECLARE_SOA_COLUMN(TrkTOFchi2, trkTOFchi2, float[4]); + +} // end of namespace tau_tree +DECLARE_SOA_TABLE(TauFourTracks, "AOD", "TAUFOURTRACK", + tau_tree::RunNumber, tau_tree::Bc, tau_tree::TotalTracks, tau_tree::NumContrib, + // tau_tree::GlobalNonPVtracks, + // tau_tree::PosX, tau_tree::PosY, + tau_tree::PosZ, + tau_tree::FlagUPC, tau_tree::OccupancyInTime, tau_tree::HadronicRate, tau_tree::ZdcAenergy, tau_tree::ZdcCenergy, + tau_tree::Qtot, + tau_tree::Trs, tau_tree::Trofs, tau_tree::Hmpr, + // tau_tree::Tfb, tau_tree::ItsRofb, tau_tree::Sbp, tau_tree::ZvtxFT0vsPv, tau_tree::VtxITSTPC, + tau_tree::TotalFT0AmplitudeA, tau_tree::TotalFT0AmplitudeC, tau_tree::TotalFV0AmplitudeA, + // tau_tree::TimeFT0A, tau_tree::TimeFT0C, tau_tree::TimeFV0A, + tau_tree::TrkPx, tau_tree::TrkPy, tau_tree::TrkPz, + // tau_tree::TrkSign, + // tau_tree::TrkDCAxy, tau_tree::TrkDCAz, + tau_tree::TrkTPCcr, + tau_tree::TrkTPCsignal, tau_tree::TrkTPCnSigmaEl, tau_tree::TrkTPCnSigmaPi, tau_tree::TrkTPCnSigmaKa, tau_tree::TrkTPCnSigmaPr, tau_tree::TrkTPCnSigmaMu, + tau_tree::TrkTOFbeta, tau_tree::TrkTOFnSigmaEl, tau_tree::TrkTOFnSigmaPi, tau_tree::TrkTOFnSigmaKa, tau_tree::TrkTOFnSigmaPr, tau_tree::TrkTOFnSigmaMu, + tau_tree::TrkTOFchi2); + +} // end of namespace o2::aod struct TauTau13topo { + Produces tauFourTracks; + SGSelector sgSelector; // configurables - Configurable FV0_cut{"FV0", 1000., "FV0A threshold"}; - Configurable FT0A_cut{"FT0A", 150., "FT0A threshold"}; - Configurable FT0C_cut{"FT0C", 50., "FT0C threshold"}; - Configurable ZDC_cut{"ZDC", 100., "ZDC threshold"}; - Configurable gap_Side{"gap", 2, "gap selection"}; + Configurable cutFV0{"cutFV0", 10000., "FV0A threshold"}; + Configurable cutFT0A{"cutFT0A", 150., "FT0A threshold"}; + Configurable cutFT0C{"cutFT0C", 50., "FT0C threshold"}; + Configurable cutZDC{"cutZDC", 10000., "ZDC threshold"}; + Configurable mGapSide{"mGapSide", 2, "gap selection"}; // ConfigurableAxis ptAxis{"pAxis", {100, 0., 5.}, "#it{p} (GeV/#it{c})"}; ConfigurableAxis ptAxis{"ptAxis", {120, 0., 4.}, "#it{p} (GeV/#it{c})"}; // ConfigurableAxis etaAxis{"etaAxis", {100, -2., 2.}, "#eta"}; ConfigurableAxis dedxAxis{"dedxAxis", {100, 20., 160.}, "dE/dx"}; - ConfigurableAxis minvAxis{"MinvAxis", {100, 0.4, 3.5}, "M_{inv} (GeV/#it{c}^{2})"}; + ConfigurableAxis minvAxis{"minvAxis", {100, 0.4, 3.5}, "M_{inv} (GeV/#it{c}^{2})"}; ConfigurableAxis phiAxis{"phiAxis", {120, 0., 3.2}, "#phi"}; // ConfigurableAxis vectorAxis{"vectorAxis", {100, 0., 2.}, "A_{V}"}; // ConfigurableAxis scalarAxis{"scalarAxis", {100, -1., 1.}, "A_{S}"}; - Configurable verbose{"Verbose", {}, "Additional print outs"}; + Configurable verbose{"verbose", {}, "Additional print outs"}; // cut selection configurables - Configurable zvertexcut{"Zvertexcut", 15., "Z vertex cut"}; - Configurable trkEtacut{"TrkEtacut", 1.5, "max track eta cut"}; - Configurable sameSign{"sameSign", {}, "Switch: same(true) or opposite(false) sign"}; - Configurable ptTotcut{"PtTotcut", 0.15, "min pt of all 4 tracks cut"}; + Configurable zvertexcut{"zvertexcut", 10., "Z vertex cut"}; + Configurable trkEtacut{"trkEtacut", 0.9, "max track eta cut"}; + Configurable sameSign{"sameSign", {}, "Switch: same (true) - BG or opposite (false) - SIGNAL sign"}; + Configurable ptTotcut{"ptTotcut", 0.15, "min pt of all 4 tracks cut"}; Configurable minAnglecut{"minAnglecut", 0.05, "min angle between tracks cut"}; Configurable minNsigmaElcut{"minNsigmaElcut", -2., "min Nsigma for Electrons cut"}; Configurable maxNsigmaElcut{"maxNsigmaElcut", 3., "max Nsigma for Electrons cut"}; @@ -67,31 +156,47 @@ struct TauTau13topo { Configurable maxNsigmaPrVetocut{"maxNsigmaPrVetocut", 3., "max Nsigma for Proton veto cut"}; Configurable maxNsigmaKaVetocut{"maxNsigmaKaVetocut", 3., "max Nsigma for Kaon veto cut"}; Configurable minPtEtrkcut{"minPtEtrkcut", 0.25, "min Pt for El track cut"}; - Configurable FITvetoFlag{"FITvetoFlag", {}, "To apply FIT veto"}; - Configurable FITvetoWindow{"FITvetoWindow", 1, "FIT veto window"}; + Configurable mFITvetoFlag{"mFITvetoFlag", true, "To apply FIT veto"}; + Configurable mFITvetoWindow{"mFITvetoWindow", 2, "FIT veto window"}; Configurable useFV0ForVeto{"useFV0ForVeto", 0, "use FV0 for veto"}; Configurable useFDDAForVeto{"useFDDAForVeto", 0, "use FDDA for veto"}; Configurable useFDDCForVeto{"useFDDCForVeto", 0, "use FDDC for veto"}; - Configurable nTofTrkMinCut{"nTofTrkMinCut", 0, "min TOF tracks"}; + Configurable nTofTrkMinCut{"nTofTrkMinCut", 1, "min TOF tracks"}; Configurable invMass3piSignalRegion{"invMass3piSignalRegion", 1, "1-use inv mass 3pi in signal region, 0-in background region"}; - Configurable invMass3piMaxcut{"invMass3piMaxcut", 20., "Z invariant mass of 3 pi cut"}; + Configurable invMass3piMaxcut{"invMass3piMaxcut", 1.8, "Z invariant mass of 3 pi cut"}; Configurable deltaPhiMincut{"deltaPhiMincut", 0., "delta phi electron - 3 pi direction cut"}; Configurable nTPCcrossedRowsMinCut{"nTPCcrossedRowsMinCut", 50, "min N_crossed TPC rows for electron candidate"}; - Configurable nSigma3piMaxCut{"nSigma3piMaxCut", 20., "n sigma 3 pi max cut"}; + Configurable nSigma3piMaxCut{"nSigma3piMaxCut", 5., "n sigma 3 pi max cut"}; + Configurable whichPIDCut{"whichPIDCut", 1., "type of PID selection: 1-TPC,2-sigma(TPC+TOF),3-hardcoded ptCut,default=1"}; + + Configurable generatorIDMC{"generatorIDMC", -1, "MC generator ID"}; + Configurable removeNoTOFrunsInData{"removeNoTOFrunsInData", 1, "1-remove or 0-keep no TOF runs"}; + Configurable occupancyCut{"occupancyCut", 10000., "occupancy cut"}; // Configurable DGactive{"DGactive", false, "Switch on DGproducer"}; // Configurable SGactive{"SGactive", true, "Switch on SGproducer"}; // a pdg object // TDatabasePDG* pdg = nullptr; //not recommended - Service pdg; + // Service pdg; // initialize histogram registry HistogramRegistry registry{ "registry", {}}; + HistogramRegistry registryMC{ + "registryMC", + {}}; + HistogramRegistry registry1MC{ + "registry1MC", + {}}; + + HistogramRegistry registrySkim{ + "registrySkim", + {}}; + void init(InitContext&) { // pdg = TDatabasePDG::Instance(); @@ -109,505 +214,1487 @@ struct TauTau13topo { const AxisSpec vectorAxis{100, 0., 2., "A_{V}"}; const AxisSpec scalarAxis{100, -1., 1., "A_{S}"}; const AxisSpec axisZDC{50, -1., 14., "#it{E} (TeV)"}; + const AxisSpec axisInvMass4trk{160, 0.5, 8.5, "#it{M}^{4trk}_{inv} (GeV/#it{c}^{2})"}; + + if (doprocessDataSG) { + registry.add("global/RunNumber", "Run number; Run; Collisions", {HistType::kTH1F, {{150, 544013, 545367}}}); + registry.add("global/GapSide", "Associated gap side; gap index; Collisions", {HistType::kTH1F, {{5, -1, 4}}}); + registry.add("global/GapSideTrue", "Recalculated gap side; gap index; Collisions", {HistType::kTH1F, {{5, -1, 4}}}); + + registry.add("global/hZNACenergy", "ZNA vs ZNC energy; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registry.add("global/hZNACtime", "ZNA vs ZNC time; #it{time}_{ZNA} (ns); #it{time}_{ZNC} (ns); Collisions", {HistType::kTH2F, {{100, -10., 10.}, {100, -10., 10.}}}); + // registry.add("global/hZNACenergyTest", "ZNA or ZNC energy; #it{E}_{ZNA,ZNC} (GeV); Collisions", {HistType::kTH1F, {{100,-1000,0}}}); + + registry.add("global/hVertexXY", "Vertex position in x and y direction; #it{V}_{x} (cm); #it{V}_{y} (cm); Collisions", {HistType::kTH2F, {{50, -0.05, 0.05}, {50, -0.02, 0.02}}}); + registry.add("global/hVertexZ", "Vertex position in z direction; #it{V}_{z} (cm); Collisions", {HistType::kTH1F, {{100, -25., 25.}}}); + registry.add("global/hNTracks", ";N_{tracks};events", {HistType::kTH1D, {{20, 0., 20.}}}); + // registry.add("global/hNTracksGlobal", ";N_{tracks,global};events", {HistType::kTH1D, {{20, 0., 20.}}}); + registry.add("global/hNTracksPV", ";N_{tracks,PV};events", {HistType::kTH1D, {{20, 0., 20.}}}); + registry.add("global/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + registry.add("global/hTrackPtPV", ";p_T^{trk}; Entries", {HistType::kTH1F, {axispt}}); + registry.add("global/hTrackEtaPhiPV", ";Eta;Phi;", {HistType::kTH2D, {axiseta, {140, -3.5, 3.5}}}); + registry.add("global/hTrackEfficiencyPVGlobal", "0-All,1-ntpc,2-rat,3-chitpc,4chiits,5-dcaz,6-dcaxy,7pt,8eta;Track efficiency; Entries", {HistType::kTH1F, {{15, 0, 15}}}); + registry.add("global/hTrackPVGood", "0-All,1-ntpc,2-rat,3-chitpc,4chiits,5-dcaz,6-dcaxy,7pt,8eta;Track efficiency; Entries", {HistType::kTH1F, {{15, 0, 15}}}); + registry.add("global/hTrackEtaPhiPVGlobal", ";Eta;Phi;", {HistType::kTH2D, {axiseta, {140, -3.5, 3.5}}}); + + registry.add("global/hSignalTPCvsPtPV", ";Pt;TPC Signal", {HistType::kTH2F, {axispt, {200, 0., 200}}}); + registry.add("global/hITSbitPVtrk", "ITS bit for PV tracks; Layer hit;Entries", {HistType::kTH1F, {{10, 0., 10.}}}); + registry.add("global/hITSnbitsVsEtaPVtrk", "n ITS bits vs #eta for PV tracks; #eta;Layer hit;Entries", {HistType::kTH2F, {axiseta, {8, -1., 7.}}}); + registry.add("global/hITSbitVsEtaPVtrk", "ITS bit vs #eta for PV tracks; #eta;Layer hit;Entries", {HistType::kTH2F, {axiseta, {8, 0., 8.}}}); + registry.add("global/hEventEff", "Event cut efficiency: 0-All,1-PV=4,2-Qtot=0,3-El;Cut;entries", {HistType::kTH1F, {{27, -2., 25.}}}); + registry.add("global/hNCombAfterCut", "Combinations after cut: 0-All,5-M3pi,10-Dphi,15-N_{e},20-N_{v#pi},25-Pt,30-Vcal,35-N_{vp},40-N_{vK},45-Tot;N_{comb};entries", {HistType::kTH1F, {{60, 0., 60.}}}); + // registry.add("global/hInvMassElTrack", ";M_{inv}^{2};entries", {HistType::kTH1F, {{100, -0.01, 0.49}}}); + registry.add("global/hDeltaAngleTrackPV", ";#Delta#alpha;entries", {HistType::kTH1F, {{136, 0., 3.2}}}); // 0.49 + registry.add("global/hTrkCheck", ";track type;entries", {HistType::kTH1F, {{16, -1, 15}}}); + + registry.add("global/hRecFlag", ";Reconstruction Flag;events", {HistType::kTH1F, {{10, 0., 10.}}}); + registry.add("global/hOccupancyInTime", ";Occupancy;events", {HistType::kTH1F, {{100, 0., 10000.}}}); + + registry.add("global1/hVertexZ", "Vertex position in z direction; #it{V}_{z} (cm); Collisions", {HistType::kTH1F, {{100, -25., 25.}}}); + registry.add("global1/hNTracks", ";N_{tracks};events", {HistType::kTH1D, {{20, 0., 20.}}}); + registry.add("global1/hNTracksPV", ";N_{tracks,PV};events", {HistType::kTH1D, {{20, 0., 20.}}}); + registry.add("global1/hTrackPtPV", ";p_T^{trk}; Entries", {HistType::kTH1F, {axispt}}); + registry.add("global1/hTrackEtaPhiPV", ";Eta;Phi;", {HistType::kTH2D, {axiseta, {140, -3.5, 3.5}}}); + registry.add("global1/hTrackPVTotCharge", "Q_{Tot};Q_{Tot}; Entries", {HistType::kTH1F, {{11, -5, 6}}}); + + // cut0 + registry.add("control/cut0/h3piMassComb", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registry.add("control/cut0/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registry.add("control/cut0/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registry.add("control/cut0/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("control/cut0/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registry.add("control/cut0/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + // registry.add("control/cut0/h13EtaSum", ";#eta^{1-prong}+#eta^{3-prong};entries", {HistType::kTH1F, {{100, -4., 4.}}}); + registry.add("control/cut0/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registry.add("control/cut0/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry.add("control/cut0/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry.add("control/cut0/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registry.add("control/cut0/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registry.add("control/cut0/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry.add("control/cut0/hsigma3PiNew", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry.add("control/cut0/hsigma2PiNew", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}};#sigma^{2#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry.add("control/cut0/hsigma1PiNew", "#sqrt{#sigma_{1}^{2 }};#sigma^{1#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry.add("control/cut0/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + registry.add("control/cut0/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registry.add("control/cut0/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registry.add("control/cut0/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {{40, 0., 5.}}}); + registry.add("control/cut0/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + registry.add("control/cut0/hInvMass2ElAll", "Inv Mass of 2 Electrons from coherent peak;M_{inv}^{2e};entries", {HistType::kTH1F, {{150, -0.1, 9.}}}); + registry.add("control/cut0/hInvMass2ElCoh", "Inv Mass of 2 Electrons from coherent peak;M_{inv}^{2e};entries", {HistType::kTH1F, {{150, -0.1, 4.}}}); + registry.add("control/cut0/hGamPtCoh", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registry.add("control/cut0/hGamPtCohIM0", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registry.add("control/cut0/hN2gamma", "Number of gamma pairs among 3 comb;N_{#gamma#gamma};entries", {HistType::kTH1F, {{20, 0., 20.}}}); + registry.add("control/cut0/hGamAS", ";A_{S};entries", {HistType::kTH1F, {{100, 0, 0.2}}}); + registry.add("control/cut0/hGamAV", ";A_{V};entries", {HistType::kTH1F, {{100, 0, 0.2}}}); + registry.add("control/cut0/hInvMass2GamCoh", "Inv Mass of 2 Gamma from coherent peak;M_{inv}^{2#gamma};entries", {HistType::kTH1F, {{160, 0.5, 4.5}}}); + registry.add("control/cut0/hDeltaPhi2GamCoh", "Delta Phi of 2 Gamma from coherent peak;#Delta#phi^{2#gamma};entries", {HistType::kTH1F, {phiAxis}}); + + // // cut1 + // registry.add("control/cut1/h3piMassComb", "3#pi mass, 1 entry per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + // registry.add("control/cut1/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + // registry.add("control/cut1/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + // registry.add("control/cut1/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + // registry.add("control/cut1/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + // registry.add("control/cut1/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + // // registry.add("control/cut1/h13EtaSum", ";#eta^{1-prong}+#eta^{3-prong};entries", {HistType::kTH1F, {{100, -4., 4.}}}); + // registry.add("control/cut1/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + // registry.add("control/cut1/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registry.add("control/cut1/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registry.add("control/cut1/h3piMassVsPt", "3#pi mass vs Pt, 1 entry per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + // registry.add("control/cut1/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + // registry.add("control/cut1/hDcaZ", "All 4 tracks dca ;dca_{Z};entries", {HistType::kTH1F, {{100, -0.05, 0.05}}}); + // registry.add("control/cut1/hDcaXY", "All 4 tracks dca ;dca_{XY};entries", {HistType::kTH1F, {{100, -0.05, 0.05}}}); + // registry.add("control/cut1/hChi2TPC", "All 4 tracks Chi2 ;Chi2_{TPC};entries", {HistType::kTH1F, {{48, -2, 10.}}}); + // registry.add("control/cut1/hChi2ITS", "All 4 tracks Chi2 ;Chi2_{ITS};entries", {HistType::kTH1F, {{44, -2, 20.}}}); + // registry.add("control/cut1/hChi2TOF", "All 4 tracks Chi2 ;Chi2_{TOF};entries", {HistType::kTH1F, {{48, -2, 10.}}}); + // registry.add("control/cut1/hTPCnclsFindable", "All 4 tracks NclFind ;N_{TPC,cl,findable};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + // registry.add("control/cut1/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registry.add("control/cut1/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registry.add("control/cut1/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + // registry.add("control/cut1/hZNACenergy", "ZNA vs ZNC energy; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + // registry.add("control/cut1/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {{40, 0., 5.}}}); + // registry.add("control/cut1/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // // cut1a for 20 + registryMC.add("globalMCrec/hPtSpectrumElRec9", "Rec9;#it{p}_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); // effiEl = 23, FIT empty + + // global1 when we require SGProducer + double gap + nPVtracks=4 + registryMC.add("global1MCrec/hVertexZ", "Vertex position in z direction; #it{V}_{z} (cm); Collisions", {HistType::kTH1F, {{100, -25., 25.}}}); + registryMC.add("global1MCrec/hNTracks", ";N_{tracks};events", {HistType::kTH1D, {{20, 0., 20.}}}); + registryMC.add("global1MCrec/hNTracksPV", ";N_{tracks,PV};events", {HistType::kTH1D, {{20, 0., 20.}}}); + registryMC.add("global1MCrec/hTrackPtPV", ";p_T^{trk}; Entries", {HistType::kTH1F, {axispt}}); + registryMC.add("global1MCrec/hTrackEtaPhiPV", ";Eta;Phi;", {HistType::kTH2D, {axiseta, {128, -0.05, 6.35}}}); + registryMC.add("global1MCrec/hTrackPVTotCharge", "Q_{Tot};Q_{Tot}; Entries", {HistType::kTH1F, {{11, -5, 6}}}); + + registryMC.add("global1MCrec/hpTGenRecTracksPV", ";p_{T}^{Rec. tracks,PV} (GeV/c);p_{T}^{Gen} (GeV/c);events", {HistType::kTH2D, {{100, 0., 4.}, {100, 0., 4.}}}); + registryMC.add("global1MCrec/hDeltapTGenRecVsRecpTTracksPV", ";#Delta p_{T}^{Rec.-Gen. tracks,PV} (GeV/c);p_{T}^{Rec. tracks,PV} (GeV/c);events", {HistType::kTH2D, {{100, -4., 4.}, {100, 0., 4.}}}); + registryMC.add("global1MCrec/hEtaGenRecTracksPV", ";#eta^{Rec. tracks,PV} (GeV/c);#eta^{Gen} (GeV/c);events", {HistType::kTH2D, {{100, -2., 2.}, {100, -2., 2.}}}); + registryMC.add("global1MCrec/hDeltaEtaGenRecVsRecpTTracksPV", ";#Delta #eta^{Rec.-Gen. tracks,PV} (GeV/c);p_{T}^{Rec. tracks,PV} (GeV/c);events", {HistType::kTH2D, {{100, -0.25, 0.25}, {100, 0., 4.}}}); + registryMC.add("global1MCrec/hPhiGenRecTracksPV", ";#phi^{Rec. tracks,PV} (GeV/c);#phi^{Gen} (GeV/c);events", {HistType::kTH2D, {{100, 0., 6.4}, {100, 0., 6.4}}}); + registryMC.add("global1MCrec/hDeltaPhiGenRecVsRecpTTracksPV", ";#Delta #phi^{Rec.-Gen. tracks,PV} (GeV/c);p_{T}^{Rec. tracks,PV} (GeV/c);events", {HistType::kTH2D, {{100, -0.5, 0.5}, {100, 0., 4.}}}); + + // pid El in MC true + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut0", "In hip ;#it{p}_{trk}(GeV/#it{c});dE/dx_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut1", "All hip;#it{p}_{trk}(GeV/#it{c});dE/dx_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + // pid separately for each cut (what we reject) + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut2", "rejected, IM hip; #it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut3", "rejected, DP hip; #it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut4", "rejected, El hip; #it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut5", "rejected, vPi hip;#it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut6", "rejected, Pt hip; #it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut7", "rejected, vVc hip;#it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut8", "rejected, pTot hip;#it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut9", "rejected, vPr hip;#it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut10", "rejected, vKa hip;#it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut11", "rejected, nCR hip;#it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut12", "rejected, s3pi hip;#it{p}_{trk} (GeV/#it{c}); d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + // pid sequentialy + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut20", "El hip; #it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut33", "eTOF+20 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut21", "vPi+33 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut24", "vPr+21 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut25", "vKa+24 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut28", "CR+25 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut22", "vVc+28 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut29", "s3pi+22 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut26", "IM+29 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut34", "piTOF+26 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut30", "ptTot+34 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut27", "DP+30 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut35", "ZDC+27 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut23", "Occ+35 hip; #it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + + // registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut31", "FIT+27 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + // registryMC.add("pidTPCMCEltrue/hpvsdedxElHipCut32", "TOF+31 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + + // pid Pi in MC true + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut0", "In hip ;#it{p}_{trk}(GeV/#it{c});dE/dx_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut20", "El hip; #it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut33", "eTOF+20 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut21", "vPi+33 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut24", "vPr+21 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut25", "vKa+24 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut28", "CR+25 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut22", "vVc+28 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut29", "s3pi+22 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut26", "IM+29 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut34", "piTOF+26 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut30", "ptTot+34 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut27", "DP+30 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut35", "ZDC+27 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut23", "Occ+35 hip; #it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + + // registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut31", "FIT+27 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + // registryMC.add("pidTPCMCPitrue/hpvsdedxElHipCut32", "TOF+31 hip;#it{p}_{trk} (GeV/#it{c});d#it{E}/d#it{x}_{trk}", {HistType::kTH2F, {axisp, dedxAxis}}); + + // El PID in TOF MC true + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut0", "In hip ;#it{p}_{trk}(GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut20", "El hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut33", "eTOF+20 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut21", "vPi+33 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut24", "vPr+21 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut25", "vKa+24 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut28", "CR+25 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut22", "vVc+28 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut29", "s3pi+22 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut26", "IM+29 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut34", "piTOF+26 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut30", "ptTot+34 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut27", "DP+30 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut35", "ZDC+27 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + registry1MC.add("pidTOFMCEltrue/hpvsNsigmaElHipCut23", "Occ+27 hip;#it{p}_{trk} (GeV/#it{c});N#sigma El^{TOF}_{trk}", {HistType::kTH2F, {axisp, {100, -5., 5.}}}); + + // cut0 + registryMC.add("controlMCtrue/cut0/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut0/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut0/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut0/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut0/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut0/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut0/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut0/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut0/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut0/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut0/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut0/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut0/hsigma3PiNew", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut0/hsigma2PiNew", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}};#sigma^{2#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut0/hsigma1PiNew", "#sqrt{#sigma_{1}^{2 }};#sigma^{1#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + registryMC.add("controlMCtrue/cut0/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + registryMC.add("controlMCtrue/cut0/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut0/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registry1MC.add("controlMCtrue/cut0/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut0/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut0/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut0/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut0/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut0/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut0/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut0/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCcomb/cut0/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registry1MC.add("controlMCcomb/cut0/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut20 MC + registryMC.add("controlMCtrue/cut20/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut20/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut20/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut20/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut20/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut20/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut20/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut20/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut20/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut20/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut20/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut20/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut20/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut20/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut20/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut20/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut20/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut20/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut20/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut20/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut20/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut20/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut20/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut20/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut20/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut21 MC + registryMC.add("controlMCtrue/cut21/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut21/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut21/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut21/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut21/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut21/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut21/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut21/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut21/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut21/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut21/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut21/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut21/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut21/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut21/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut21/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut21/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut21/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut21/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut21/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut21/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut21/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut21/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut21/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut21/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut24 MC + registryMC.add("controlMCtrue/cut24/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut24/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut24/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut24/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut24/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut24/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut24/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut24/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut24/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut24/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut24/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut24/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut24/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut24/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut24/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut24/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut24/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut24/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut24/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut24/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut24/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut24/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut24/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut24/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut24/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut25 MC + registryMC.add("controlMCtrue/cut25/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut25/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut25/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut25/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut25/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut25/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut25/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut25/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut25/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut25/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut25/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut25/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut25/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut25/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut25/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut25/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut25/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut25/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut25/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut25/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut25/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut25/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut25/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut25/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut25/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut28 MC + registryMC.add("controlMCtrue/cut28/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut28/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut28/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut28/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut28/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut28/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut28/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut28/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut28/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut28/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut28/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut28/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut28/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut28/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut28/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut28/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut28/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut28/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut28/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut28/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut28/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut28/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut28/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut28/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut28/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut22 MC + registryMC.add("controlMCtrue/cut22/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut22/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut22/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut22/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut22/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut22/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut22/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut22/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut22/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut22/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut22/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut22/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut22/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut22/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut22/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut22/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut22/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut22/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut22/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut22/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut22/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut22/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut22/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut22/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut22/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut29 MC + registryMC.add("controlMCtrue/cut29/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut29/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut29/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut29/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut29/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut29/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut29/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut29/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut29/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut29/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut29/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut29/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut29/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut29/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut29/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut29/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut29/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut29/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut29/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut29/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut29/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut29/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut29/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut29/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut29/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut26 MC + registryMC.add("controlMCtrue/cut26/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut26/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut26/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut26/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut26/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut26/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut26/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut26/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut26/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut26/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut26/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut26/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut26/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut26/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut26/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut26/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut26/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut26/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut26/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut26/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut26/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut26/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut26/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut26/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut26/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut30 MC + registryMC.add("controlMCtrue/cut30/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut30/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut30/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut30/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut30/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut30/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut30/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut30/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut30/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut30/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut30/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut30/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut30/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut30/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut30/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut30/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut30/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut30/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut30/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut30/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut30/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut30/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut30/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut30/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut30/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut27 MC + registryMC.add("controlMCtrue/cut27/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut27/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut27/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut27/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut27/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut27/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut27/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut27/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut27/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut27/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut27/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut27/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut27/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut27/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut27/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut27/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut27/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut27/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut27/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut27/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut27/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut27/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut27/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut27/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut27/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // //cut31 MC + // registryMC.add("controlMCtrue/cut31/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut31/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + // registryMC.add("controlMCtrue/cut31/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + // registryMC.add("controlMCtrue/cut31/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + // registryMC.add("controlMCtrue/cut31/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + // registryMC.add("controlMCtrue/cut31/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + // registryMC.add("controlMCtrue/cut31/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + // registryMC.add("controlMCtrue/cut31/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + // registryMC.add("controlMCtrue/cut31/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + // registryMC.add("controlMCtrue/cut31/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + // registryMC.add("controlMCtrue/cut31/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + // registryMC.add("controlMCtrue/cut31/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + // registryMC.add("controlMCtrue/cut31/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registry1MC.add("controlMCtrue/cut31/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // // registryMC.add("controlMCtrue/cut31/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // // registryMC.add("controlMCtrue/cut31/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // // + // registryMC.add("controlMCcomb/cut31/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + // registryMC.add("controlMCcomb/cut31/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + // registryMC.add("controlMCcomb/cut31/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + // registryMC.add("controlMCcomb/cut31/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + // registryMC.add("controlMCcomb/cut31/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + // registryMC.add("controlMCcomb/cut31/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + // registryMC.add("controlMCcomb/cut31/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + // registryMC.add("controlMCcomb/cut31/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registry1MC.add("controlMCcomb/cut31/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // //cut32 MC + // registryMC.add("controlMCtrue/cut32/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut32/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + // registryMC.add("controlMCtrue/cut32/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + // registryMC.add("controlMCtrue/cut32/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + // registryMC.add("controlMCtrue/cut32/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + // registryMC.add("controlMCtrue/cut32/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + // registryMC.add("controlMCtrue/cut32/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + // registryMC.add("controlMCtrue/cut32/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + // registryMC.add("controlMCtrue/cut32/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + // registryMC.add("controlMCtrue/cut32/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + // registryMC.add("controlMCtrue/cut32/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + // registryMC.add("controlMCtrue/cut32/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + // registryMC.add("controlMCtrue/cut32/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registry1MC.add("controlMCtrue/cut32/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // // registryMC.add("controlMCtrue/cut32/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // // registryMC.add("controlMCtrue/cut32/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // // + // registryMC.add("controlMCcomb/cut32/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + // registryMC.add("controlMCcomb/cut32/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + // registryMC.add("controlMCcomb/cut32/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + // registryMC.add("controlMCcomb/cut32/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + // registryMC.add("controlMCcomb/cut32/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + // registryMC.add("controlMCcomb/cut32/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + // registryMC.add("controlMCcomb/cut32/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + // registryMC.add("controlMCcomb/cut32/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registry1MC.add("controlMCcomb/cut32/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut33 MC + registryMC.add("controlMCtrue/cut33/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut33/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut33/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut33/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut33/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut33/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut33/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut33/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut33/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut33/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut33/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut33/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut33/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut33/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut33/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut33/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut33/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut33/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut33/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut33/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut33/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut33/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut33/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut33/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut33/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut34 MC + // registryMC.add("controlMCtrue/cut34/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut34/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {axisInvMass4trk}}); + registryMC.add("controlMCtrue/cut34/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut34/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut34/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut34/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut34/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut34/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut34/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut34/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut34/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut34/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut34/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut34/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut34/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut34/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut34/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut34/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut34/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut34/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut34/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut34/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut34/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut34/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut34/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut34/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut35 MC + // registryMC.add("controlMCtrue/cut34/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut35/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {axisInvMass4trk}}); + registryMC.add("controlMCtrue/cut35/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut35/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut35/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut35/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut35/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut35/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut35/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut35/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut35/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut35/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut35/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut35/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut35/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut35/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut35/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut35/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut35/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut35/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut35/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut35/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut35/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut35/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut35/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut35/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // cut23 MC + registryMC.add("controlMCtrue/cut23/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registryMC.add("controlMCtrue/cut23/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut23/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); + registryMC.add("controlMCtrue/cut23/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); + registryMC.add("controlMCtrue/cut23/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCtrue/cut23/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCtrue/cut23/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCtrue/cut23/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCtrue/cut23/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCtrue/cut23/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCtrue/cut23/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCtrue/cut23/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); + registryMC.add("controlMCtrue/cut23/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCtrue/cut23/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // registryMC.add("controlMCtrue/cut23/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); + // registryMC.add("controlMCtrue/cut23/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); + // + registryMC.add("controlMCcomb/cut23/h3piMass", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); + registryMC.add("controlMCcomb/cut23/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut23/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); + registryMC.add("controlMCcomb/cut23/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); + registryMC.add("controlMCcomb/cut23/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); + registryMC.add("controlMCcomb/cut23/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); + registryMC.add("controlMCcomb/cut23/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); + registryMC.add("controlMCcomb/cut23/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + registry1MC.add("controlMCcomb/cut23/hTofChi2El", ";TOF #chi^{2};entries", {HistType::kTH1F, {{100, 0., 10.}}}); + + // ptSpectrum of electron for MC true and combinatorics + registryMC.add("controlMCtrue/cut0/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut20/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut21/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut22/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut23/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut24/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut25/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut26/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut27/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut28/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut29/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut30/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut31/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + // registryMC.add("controlMCtrue/cut32/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut33/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut34/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCtrue/cut35/hPtSpectrumEl", ";p_{T}^{e} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + + registryMC.add("controlMCcomb/cut0/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); + registryMC.add("controlMCcomb/cut20/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut21/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut22/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut23/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut24/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut25/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut26/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut27/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut28/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut29/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut30/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut31/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut32/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut33/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut34/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + registryMC.add("controlMCcomb/cut35/hPtSpectrumEl", ";p_{T}^{comb} (GeV/c);entries", {HistType::kTH1F, {axispt}}); + // zrobic hpTspectrumEl dla cut 0,20-35: registry.get(HIST("global/hFinalPtSpectrumEl"))->Fill(tmpPt[i]); + + // tau + registryMC.add("tauMC/hMCeta", ";#eta^{#tau};N^{#tau} ", {HistType::kTH1F, {{100, -5., 5.}}}); + registryMC.add("tauMC/hMCy", ";y^{#tau};N^{#tau}", {HistType::kTH1F, {{100, -5., 5.}}}); + registryMC.add("tauMC/hMCphi", ";#phi^{#tau};N^{#tau}", {HistType::kTH1F, {{100, 0., 6.4}}}); + registryMC.add("tauMC/hMCpt", ";#it{p}_{T}^{#tau};N^{#tau}", {HistType::kTH1F, {{100, 0., 10.}}}); + + registryMC.add("tauMC/hMCdeltaeta", ";#Delta#eta^{#tau};events ", {HistType::kTH1F, {{100, -5., 5.}}}); + registryMC.add("tauMC/hMCdeltaphi", ";#Delta#phi^{#tau}(deg.);events", {HistType::kTH1F, {{100, 131., 181}}}); + + // electron + registryMC.add("electronMC/hMCeta", ";#eta^{e};N^{e}", {HistType::kTH1F, {{100, -5., 5.}}}); + registryMC.add("electronMC/hMCy", ";y^{e};N^{e}", {HistType::kTH1F, {{100, -5., 5.}}}); + registryMC.add("electronMC/hMCphi", ";#phi^{e};N^{e}", {HistType::kTH1F, {{100, 0., 6.4}}}); + registryMC.add("electronMC/hMCpt", ";#it{p}_{T}^{e};N^{e}", {HistType::kTH1F, {{400, 0., 10.}}}); + + // efficiency mu + registryMC.add("efficiencyMCMu/effiMu", ";Efficiency #mu3#pi;events", {HistType::kTH1F, {{20, 0., 20.}}}); + registryMC.add("efficiencyMCMu/hpTmuon", ";p_{T}^{#mu, gen} (GeV/c);events", {HistType::kTH1F, {{200, 0., 5.}}}); + + // efficiency pi + registryMC.add("efficiencyMCPi/effiPi", ";Efficiency #pi3#pi;events", {HistType::kTH1F, {{20, 0., 20.}}}); + registryMC.add("efficiencyMCPi/hpTpi", ";p_{T}^{#pi, gen} (GeV/c);events", {HistType::kTH1F, {{200, 0., 5.}}}); + + // efficiency el + registryMC.add("efficiencyMCEl/effiEl", ";Efficiency e3#pi;events", {HistType::kTH1F, {{70, 0., 70.}}}); + registryMC.add("efficiencyMCEl/hpTelec", ";p_{T}^{e, gen} (GeV/c);events", {HistType::kTH1F, {axispt}}); + + // efficiency el + registryMC.add("efficiencyMCEl/hMCdeltaAlphaEpi", ";#Delta#alpha^{e-#pi(3x), gen} (rad);events", {HistType::kTH1F, {{100, -0.1, 3.2}}}); + registryMC.add("efficiencyMCEl/hMCdeltaAlphaPiPi", ";#Delta#alpha^{#pi-#pi(3x), gen} (rad);events", {HistType::kTH1F, {{100, -0.1, 3.2}}}); + registryMC.add("efficiencyMCEl/hMCdeltaPhiEpi", ";#Delta#phi^{e-#pi(3x), gen} (rad);events", {HistType::kTH1F, {{100, -0.1, 3.2}}}); + registryMC.add("efficiencyMCEl/hMCdeltaPhiPipi", ";#Delta#phi^{#pi-#pi(3x), gen} (rad);events", {HistType::kTH1F, {{100, -0.1, 3.2}}}); + registryMC.add("efficiencyMCEl/hMCvirtCal", ";virt Cal. #Delta #alpha^{#pi-#pi(3x), gen} (rad);events", {HistType::kTH1F, {{100, 0., 2.}}}); + registryMC.add("efficiencyMCEl/hMCScalar", ";A_{S}^{#pi-#pi(3x), gen};events", {HistType::kTH1F, {{100, 0., 1.}}}); + registryMC.add("efficiencyMCEl/hMCVector", ";A_{V}^{#pi-#pi(3x), gen};events", {HistType::kTH1F, {{100, 0., 2.}}}); + + // missing eta vs phi + registryMC.add("efficiencyMCEl/hMCptEl", ";p_{T}^{e, true} (GeV/c) ;events", {HistType::kTH1F, {{200, 0., 5.}}}); + // registryMC.add("efficiencyMCEl/hMCpt4trk",";p_{T}^{4 MC part.} (GeV/c) ;events",{HistType::kTH1F,{{100, 0., 5.}}}); + registryMC.add("efficiencyMCEl/hMCpt4trk", ";p_{T}^{4 MC part.} (GeV/c) ;events", {HistType::kTH1F, {axispt}}); + // registryMC.add("efficiencyMCEl/hMCinvmass4pi",";M_{inv}^{4#pi true} (GeV/c^{2}) ;events",{HistType::kTH1F,{{100, 0.4, 5.4}}}); + registryMC.add("efficiencyMCEl/hMCinvmass4pi", ";M_{inv}^{4#pi true} (GeV/c^{2}) ;events", {HistType::kTH1F, {axisInvMass4trk}}); + registryMC.add("efficiencyMCEl/hMCinvmass3pi", ";M_{inv}^{3#pi true} (GeV/c^{2}) ;events", {HistType::kTH1F, {{100, 0.4, 2.4}}}); + registryMC.add("efficiencyMCEl/hMCdeltaphi13", ";#Delta#phi^{1-3 true} ;events", {HistType::kTH1F, {{100, 0., 3.2}}}); + + } // end of MC histograms processEfficiencyMCSG + + if (doprocessDoSkim) { + registrySkim.add("skim/efficiency", ";efficeincy;events", {HistType::kTH1F, {{10, 0., 10.}}}); + } + + } // end of init method + + float eta(float px, float py, float pz) + // Just a simple function to return pseudorapidity + { + float arg = -2.; // outside valid range for std::atanh + float mom = std::sqrt(px * px + py * py + pz * pz); + if (mom != 0) + arg = pz / mom; + if (-1. < arg && arg < 1.) + return std::atanh(arg); // definition of eta + return -999.; + } + + float phi(float px, float py) + // Just a simple function to return azimuthal angle from 0 to 2pi + { + if (px != 0) + return (std::atan2(py, px) + o2::constants::math::PI); + return -999.; + } + + float pt(float px, float py) + // Just a simple function to return pt + { + return std::sqrt(px * px + py * py); + } + + float rapidity(float energy, float pz) + // Just a simple function to return track rapidity + { + return 0.5 * std::log((energy + pz) / (energy - pz)); + } + + // helper function to calculate delta alpha + float deltaAlpha(auto particle1, auto particle2) + { + + TVector3 vtmp(particle1.px(), particle1.py(), particle1.pz()); + TVector3 v1(particle2.px(), particle2.py(), particle2.pz()); + auto angle = v1.Angle(vtmp); + + return angle; + } + + float invariantMass(float E, float px, float py, float pz) + // Just a simple function to return invariant mass + { + return std::sqrt(E * E - px * px - py * py - pz * pz); + } - registry.add("global/GapSide", "Associated gap side; gap index; Collisions", {HistType::kTH1F, {{5, -1, 4}}}); - registry.add("global/GapSideTrue", "Recalculated gap side; gap index; Collisions", {HistType::kTH1F, {{5, -1, 4}}}); - - registry.add("global/hZNACenergy", "ZNA vs ZNC energy; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); - registry.add("global/hZNACtime", "ZNA vs ZNC time; #it{time}_{ZNA} (ns); #it{time}_{ZNC} (ns); Collisions", {HistType::kTH2F, {{100, -10., 10.}, {100, -10., 10.}}}); - // registry.add("global/hZNACenergyTest", "ZNA or ZNC energy; #it{E}_{ZNA,ZNC} (GeV); Collisions", {HistType::kTH1F, {{100,-1000,0}}}); - - registry.add("global/hVertexXY", "Vertex position in x and y direction; #it{V}_{x} (cm); #it{V}_{y} (cm); Collisions", {HistType::kTH2F, {{50, -0.05, 0.05}, {50, -0.02, 0.02}}}); - registry.add("global/hVertexZ", "Vertex position in z direction; #it{V}_{z} (cm); Collisions", {HistType::kTH1F, {{100, -25., 25.}}}); - // registry.add("global/hVertexZ15", "Vertex position in z direction; #it{V}_{z} (cm); Collisions", {HistType::kTH1F, {{100, -25., 25.}}}); - // registry.add("global/hVertexZ10", "Vertex position in z direction; #it{V}_{z} (cm); Collisions", {HistType::kTH1F, {{100, -25., 25.}}}); - registry.add("global/hNTracks", ";N_{tracks};events", {HistType::kTH1D, {{20, 0., 20.}}}); - // registry.add("global/hNTracksGlobal", ";N_{tracks,global};events", {HistType::kTH1D, {{20, 0., 20.}}}); - registry.add("global/hNTracksPV", ";N_{tracks,PV};events", {HistType::kTH1D, {{20, 0., 20.}}}); - registry.add("global/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); - registry.add("global/hTrackPtPV", ";p_T^{trk}; Entries", {HistType::kTH1F, {axispt}}); - registry.add("global/hTrackEtaPhiPV", ";Eta;Phi;", {HistType::kTH2D, {axiseta, {140, -3.5, 3.5}}}); - registry.add("global/hTrackEfficiencyPVGlobal", "0-All,1-ntpc,2-rat,3-chitpc,4chiits,5-dcaz,6-dcaxy,7pt,8eta;Track efficiency; Entries", {HistType::kTH1F, {{15, 0, 15}}}); - registry.add("global/hTrackEtaPhiPVGlobal", ";Eta;Phi;", {HistType::kTH2D, {axiseta, {140, -3.5, 3.5}}}); - - registry.add("global/hSignalTPCvsPtPV", ";Pt;TPC Signal", {HistType::kTH2F, {axispt, {200, 0., 200}}}); - registry.add("global/hITSbitPVtrk", "ITS bit for PV tracks; Layer hit;Entries", {HistType::kTH1F, {{10, 0., 10.}}}); - registry.add("global/hITSnbitsVsEtaPVtrk", "n ITS bits vs #eta for PV tracks; #eta;Layer hit;Entries", {HistType::kTH2F, {axiseta, {8, -1., 7.}}}); - registry.add("global/hITSbitVsEtaPVtrk", "ITS bit vs #eta for PV tracks; #eta;Layer hit;Entries", {HistType::kTH2F, {axiseta, {8, 0., 8.}}}); - registry.add("global/hEventEff", "Event cut efficiency: 0-All,1-PV=4,2-Qtot=0,3-El;Cut;entries", {HistType::kTH1F, {{25, 0., 25.}}}); - registry.add("global/hNCombAfterCut", "Combinations after cut: 0-All,5-M3pi,10-Dphi,15-N_{e},20-N_{v#pi},25-Pt,30-Vcal,35-N_{vp},40-N_{vK},45-Tot;N_{comb};entries", {HistType::kTH1F, {{60, 0., 60.}}}); - // registry.add("global/hInvMassElTrack", ";M_{inv}^{2};entries", {HistType::kTH1F, {{100, -0.01, 0.49}}}); - registry.add("global/hDeltaAngleTrackPV", ";#Delta#alpha;entries", {HistType::kTH1F, {{136, 0., 3.2}}}); // 0.49 - registry.add("global/hTrkCheck", ";track type;entries", {HistType::kTH1F, {{16, -1, 15}}}); - - registry.add("global1/hVertexZ", "Vertex position in z direction; #it{V}_{z} (cm); Collisions", {HistType::kTH1F, {{100, -25., 25.}}}); - registry.add("global1/hNTracks", ";N_{tracks};events", {HistType::kTH1D, {{20, 0., 20.}}}); - registry.add("global1/hNTracksPV", ";N_{tracks,PV};events", {HistType::kTH1D, {{20, 0., 20.}}}); - registry.add("global1/hTrackPtPV", ";p_T^{trk}; Entries", {HistType::kTH1F, {axispt}}); - registry.add("global1/hTrackEtaPhiPV", ";Eta;Phi;", {HistType::kTH2D, {axiseta, {140, -3.5, 3.5}}}); - registry.add("global1/hTrackPVTotCharge", "Q_{Tot};Q_{Tot}; Entries", {HistType::kTH1F, {{11, -5, 6}}}); - - // cut0 - registry.add("control/cut0/h3piMassComb", "3#pi mass, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); - registry.add("control/cut0/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); - registry.add("control/cut0/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); - registry.add("control/cut0/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); - registry.add("control/cut0/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); - registry.add("control/cut0/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); - // registry.add("control/cut0/h13EtaSum", ";#eta^{1-prong}+#eta^{3-prong};entries", {HistType::kTH1F, {{100, -4., 4.}}}); - registry.add("control/cut0/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); - registry.add("control/cut0/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("control/cut0/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("control/cut0/h3piMassVsPt", "3#pi mass vs Pt, up to 4 entries per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); - registry.add("control/cut0/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); - registry.add("control/cut0/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("control/cut0/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); - registry.add("control/cut0/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); - registry.add("control/cut0/hZNACenergy", "ZNA vs ZNC energy, cut0; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); - - registry.add("control/cut0/hInvMass2ElAll", "Inv Mass of 2 Electrons from coherent peak;M_{inv}^{2e};entries", {HistType::kTH1F, {{150, -0.1, 9.}}}); - registry.add("control/cut0/hInvMass2ElCoh", "Inv Mass of 2 Electrons from coherent peak;M_{inv}^{2e};entries", {HistType::kTH1F, {{150, -0.1, 4.}}}); - registry.add("control/cut0/hGamPtCoh", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); - registry.add("control/cut0/hGamPtCohIM0", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); - registry.add("control/cut0/hN2gamma", "Number of gamma pairs among 3 comb;N_{#gamma#gamma};entries", {HistType::kTH1F, {{20, 0., 20.}}}); - registry.add("control/cut0/hGamAS", ";A_{S};entries", {HistType::kTH1F, {{100, 0, 0.2}}}); - registry.add("control/cut0/hGamAV", ";A_{V};entries", {HistType::kTH1F, {{100, 0, 0.2}}}); - registry.add("control/cut0/hInvMass2GamCoh", "Inv Mass of 2 Gamma from coherent peak;M_{inv}^{2#gamma};entries", {HistType::kTH1F, {{160, 0.5, 4.5}}}); - registry.add("control/cut0/hDeltaPhi2GamCoh", "Delta Phi of 2 Gamma from coherent peak;#Delta#phi^{2#gamma};entries", {HistType::kTH1F, {phiAxis}}); - - // cut1 - registry.add("control/cut1/h3piMassComb", "3#pi mass, 1 entry per event ;M_{inv}^{3#pi} (GeV/c^{2});entries", {HistType::kTH1F, {minvAxis}}); - registry.add("control/cut1/h3trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {ptAxis}}); - registry.add("control/cut1/hDeltaPhi13topo", "#Delta #varphi 1+3 topo, 4 entries/event;#Delta#varphi^{1+3};entries", {HistType::kTH1F, {phiAxis}}); - registry.add("control/cut1/h13AssymPt1ProngAver", ";Delta Pt/Sum Pt (1Prong,Aver Pt)", {HistType::kTH1F, {{100, -1., 1.}}}); - registry.add("control/cut1/h13Vector", ";A_{V};entries", {HistType::kTH1F, {vectorAxis}}); - registry.add("control/cut1/h13Scalar", ";A_{S};entries", {HistType::kTH1F, {scalarAxis}}); - // registry.add("control/cut1/h13EtaSum", ";#eta^{1-prong}+#eta^{3-prong};entries", {HistType::kTH1F, {{100, -4., 4.}}}); - registry.add("control/cut1/h4trkPtTot", ";p_{T} (GeV/c);entries", {HistType::kTH1F, {axispt}}); - registry.add("control/cut1/h4piMass", "4#pi mass;M_{inv}^{4#pi} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("control/cut1/h3pi1eMass", "3#pi+e mass;M_{inv}^{3#pi+e} (GeV/c^{2});entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("control/cut1/h3piMassVsPt", "3#pi mass vs Pt, 1 entry per event ;M_{inv}^{3#pi} (GeV/c^{2});p_{T}^{3#pi} (GeV/c);entries", {HistType::kTH2F, {minvAxis, axispt}}); - registry.add("control/cut1/h4trkMassVsPt", "4-track mass vs Pt;M_{inv}^{4track} (GeV/c^{2});p_{T}^{4track} (GeV/c);entries", {HistType::kTH2F, {{100, 1, 5.}, axispt}}); - registry.add("control/cut1/hDcaZ", "All 4 tracks dca ;dca_{Z};entries", {HistType::kTH1F, {{100, -0.05, 0.05}}}); - registry.add("control/cut1/hDcaXY", "All 4 tracks dca ;dca_{XY};entries", {HistType::kTH1F, {{100, -0.05, 0.05}}}); - registry.add("control/cut1/hChi2TPC", "All 4 tracks Chi2 ;Chi2_{TPC};entries", {HistType::kTH1F, {{48, -2, 10.}}}); - registry.add("control/cut1/hChi2ITS", "All 4 tracks Chi2 ;Chi2_{ITS};entries", {HistType::kTH1F, {{44, -2, 20.}}}); - registry.add("control/cut1/hTPCnclsFindable", "All 4 tracks NclFind ;N_{TPC,cl,findable};entries", {HistType::kTH1F, {{160, 0, 160.}}}); - registry.add("control/cut1/hsigma3Pi", "#sqrt{#sigma_{1}^{2 }+#sigma_{2}^{2}+#sigma_{3}^{2}};#sigma^{3#pi};entries", {HistType::kTH1F, {{100, 0., 10.}}}); - registry.add("control/cut1/hNtofTrk", ";N_{TOF trk}; Entries", {HistType::kTH1F, {{7, 0., 7.}}}); - registry.add("control/cut1/hTPCnCrossedRows", "N crossed rows ;N_{TPC,crossed rows};entries", {HistType::kTH1F, {{160, 0, 160.}}}); - registry.add("control/cut1/hZNACenergy", "ZNA vs ZNC energy; #it{E}_{ZNA} (GeV); #it{E}_{ZNC} (GeV); Collisions", {HistType::kTH2F, {axisZDC, axisZDC}}); - - // // cut1a for 2 o2::constants::math::PI) + delta = o2::constants::math::TwoPI - delta; + return delta; } - float CalculateDeltaPhi(TLorentzVector p, TLorentzVector p1) + float calculateDeltaPhi(float p, float p1) { - float delta = p.Phi(); - if (delta < 0) - delta += o2::constants::math::TwoPI; - if (p1.Phi() < 0) - delta -= (p1.Phi() + o2::constants::math::TwoPI); - else - delta -= p1.Phi(); - if (delta < 0) - delta += o2::constants::math::TwoPI; + float delta = RecoDecay::constrainAngle(p); + // if (delta < 0) + // delta += o2::constants::math::TwoPI; + // if (p1 < 0) + // delta -= (p1 + o2::constants::math::TwoPI); + // else + delta -= RecoDecay::constrainAngle(p1); + delta = RecoDecay::constrainAngle(delta); + // if (delta < 0) + // delta += o2::constants::math::TwoPI; if (delta > o2::constants::math::PI) delta = o2::constants::math::TwoPI - delta; return delta; } + // // helper function to calculate scalar asymmetry + // float scalarAsym(auto particle1, auto particle2){ + // auto delta = particle1.pt() - particle2.pt(); + // return TMath::Abs(delta)/(particle1.pt() + particle2.pt()); + // } + // + // // helper function to calculate vector asymmetry + // float vectorAsym(auto particle1, auto particle2){ + // auto delta = TMath::Sqrt((particle1.px() - particle2.px()) * (particle1.px() - particle2.px()) + + // (particle1.py() - particle2.py()) * (particle1.py() - particle2.py())); + // auto sum = TMath::Sqrt((particle1.px() + particle2.px()) * (particle1.px() + particle2.px()) + + // (particle1.py() + particle2.py()) * (particle1.py() + particle2.py())); + // return sum/delta; + // } + + // helper function to calculate scalar asymmetry + float scalarAsymMC(auto particle1, auto particle2) + { + auto pt1 = pt(particle1.px(), particle1.py()); + auto pt2 = pt(particle2.px(), particle2.py()); + auto delta = pt1 - pt2; + return std::abs(delta) / (pt1 + pt2); + } + + // helper function to calculate vector asymmetry + float vectorAsym(auto particle1, auto particle2) + { + auto delta = std::sqrt((particle1.px() - particle2.px()) * (particle1.px() - particle2.px()) + + (particle1.py() - particle2.py()) * (particle1.py() - particle2.py())); + auto sum = std::sqrt((particle1.px() + particle2.px()) * (particle1.px() + particle2.px()) + + (particle1.py() + particle2.py()) * (particle1.py() + particle2.py())); + return sum / delta; + } + // fill control histograms per track template - // void FillControlHistos(T pi3invMass, float pi3pt, float pi3deltaPhi, float pi3assymav, float pi3vector, float pi3scalar, float pi3etasum, float nCRtpc) - void FillControlHistos(T pi3invMass, float pi3pt, float pi3deltaPhi, float pi3assymav, float pi3vector, float pi3scalar, float nCRtpc) + // void fillControlHistos(T pi3invMass, float pi3pt, float pi3deltaPhi, float pi3assymav, float pi3vector, float pi3scalar, float pi3etasum, float nCRtpc) + void fillControlHistos(T pi3invMass, float pi3pt, float pi3deltaPhi, float pi3assymav, float pi3vector, float pi3scalar, float nCRtpc, float ptelec, float tofchi2) + { + static constexpr std::string_view kHistoname[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", + "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", + "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", + "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"}; + registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/h3piMassComb"))->Fill(pi3invMass); + registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/h3trkPtTot"))->Fill(pi3pt); + registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/hDeltaPhi13topo"))->Fill(pi3deltaPhi); + registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/h13AssymPt1ProngAver"))->Fill(pi3assymav); + registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/h13Vector"))->Fill(pi3vector); + registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/h13Scalar"))->Fill(pi3scalar); + // registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/h13EtaSum"))->Fill(pi3etasum); + registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/hTPCnCrossedRows"))->Fill(nCRtpc); + registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/hPtSpectrumEl"))->Fill(ptelec); + registry.get(HIST("control/cut") + HIST(kHistoname[mode]) + HIST("/hTofChi2El"))->Fill(tofchi2); + } + + // fill control histograms per track in MC true + template + void fillControlHistosMCtrue(T pi3invMass, float pi3pt, float pi3deltaPhi, float pi3assymav, float pi3vector, float pi3scalar, float nCRtpc, float ptelec, float tofchi2) + { + static constexpr std::string_view kHistoname[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", + "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", + "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", + "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"}; + registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/h3piMass"))->Fill(pi3invMass); + registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/h3trkPtTot"))->Fill(pi3pt); + registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/hDeltaPhi13topo"))->Fill(pi3deltaPhi); + registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/h13AssymPt1ProngAver"))->Fill(pi3assymav); + registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/h13Vector"))->Fill(pi3vector); + registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/h13Scalar"))->Fill(pi3scalar); + registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/hTPCnCrossedRows"))->Fill(nCRtpc); + registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/hPtSpectrumEl"))->Fill(ptelec); + // registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/h13EtaSum"))->Fill(pi3etasum); + registry1MC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/hTofChi2El"))->Fill(tofchi2); + } + + // fill control histograms per track in MC true + template + void fillControlHistosMCcomb(T pi3invMass, float pi3pt, float pi3deltaPhi, float pi3assymav, float pi3vector, float pi3scalar, float nCRtpc, float ptelec, float tofchi2) { - static constexpr std::string_view histoname[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"}; - registry.get(HIST("control/cut") + HIST(histoname[mode]) + HIST("/h3piMassComb"))->Fill(pi3invMass); - registry.get(HIST("control/cut") + HIST(histoname[mode]) + HIST("/h3trkPtTot"))->Fill(pi3pt); - registry.get(HIST("control/cut") + HIST(histoname[mode]) + HIST("/hDeltaPhi13topo"))->Fill(pi3deltaPhi); - registry.get(HIST("control/cut") + HIST(histoname[mode]) + HIST("/h13AssymPt1ProngAver"))->Fill(pi3assymav); - registry.get(HIST("control/cut") + HIST(histoname[mode]) + HIST("/h13Vector"))->Fill(pi3vector); - registry.get(HIST("control/cut") + HIST(histoname[mode]) + HIST("/h13Scalar"))->Fill(pi3scalar); - // registry.get(HIST("control/cut") + HIST(histoname[mode]) + HIST("/h13EtaSum"))->Fill(pi3etasum); - registry.get(HIST("control/cut") + HIST(histoname[mode]) + HIST("/hTPCnCrossedRows"))->Fill(nCRtpc); + static constexpr std::string_view kHistoname[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", + "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", + "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", + "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"}; + registryMC.get(HIST("controlMCcomb/cut") + HIST(kHistoname[mode]) + HIST("/h3piMass"))->Fill(pi3invMass); + registryMC.get(HIST("controlMCcomb/cut") + HIST(kHistoname[mode]) + HIST("/h3trkPtTot"))->Fill(pi3pt); + registryMC.get(HIST("controlMCcomb/cut") + HIST(kHistoname[mode]) + HIST("/hDeltaPhi13topo"))->Fill(pi3deltaPhi); + registryMC.get(HIST("controlMCcomb/cut") + HIST(kHistoname[mode]) + HIST("/h13AssymPt1ProngAver"))->Fill(pi3assymav); + registryMC.get(HIST("controlMCcomb/cut") + HIST(kHistoname[mode]) + HIST("/h13Vector"))->Fill(pi3vector); + registryMC.get(HIST("controlMCcomb/cut") + HIST(kHistoname[mode]) + HIST("/h13Scalar"))->Fill(pi3scalar); + registryMC.get(HIST("controlMCcomb/cut") + HIST(kHistoname[mode]) + HIST("/hTPCnCrossedRows"))->Fill(nCRtpc); + registryMC.get(HIST("controlMCcomb/cut") + HIST(kHistoname[mode]) + HIST("/hPtSpectrumEl"))->Fill(ptelec); + // registryMC.get(HIST("controlMCtrue/cut") + HIST(kHistoname[mode]) + HIST("/h13EtaSum"))->Fill(pi3etasum); + registry1MC.get(HIST("controlMCcomb/cut") + HIST(kHistoname[mode]) + HIST("/hTofChi2El"))->Fill(tofchi2); } template - int TrackCheck(T track) + int trackCheck(T track) { // 1 if (track.hasITS() && !track.hasTPC() && !track.hasTRD() && !track.hasTOF()) @@ -646,16 +1733,210 @@ struct TauTau13topo { return -1; } + // global track check + histogram cuts separatelly + template + bool isGlobalTrackCheck(T track) + { + bool isGlobalTrack = true; + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(0., 1.); + if (track.tpcNClsCrossedRows() > 70) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(1., 1.); + } else { + isGlobalTrack = false; + } + if (track.tpcNClsFindable() == 0) { + isGlobalTrack = false; + } else { + if (track.tpcNClsCrossedRows() / track.tpcNClsFindable() > 0.8) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(2., 1.); + } else { + isGlobalTrack = false; + } + } + if (track.tpcChi2NCl() < 4.) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(3., 1.); + } else { + isGlobalTrack = false; + } + if (track.itsChi2NCl() < 36.) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(4., 1.); + } else { + isGlobalTrack = false; + } + if (track.dcaZ() < 2.) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(5., 1.); + } else { + isGlobalTrack = false; + } + if (track.dcaXY() < 0.0105 * 0.035 / std::pow(track.pt(), 1.1)) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(6., 1.); + } else { + isGlobalTrack = false; + } + if (track.pt() > 0.1) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(7., 1.); + } else { + isGlobalTrack = false; + } + if (std::abs(eta(track.px(), track.py(), track.pz())) < 0.8) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(8., 1.); + } else { + isGlobalTrack = false; + } + if (track.hasITS()) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(9., 1.); + // old version + // clustermap1 = trk.itsClusterMap(); + // for (int bitNo = 0; bitNo < 7; bitNo++) { + // if (TESTBIT(clustermap1, bitNo)) { // check ITS bits/layers for each PV track + // registry.get(HIST("global/hITSbitPVtrk"))->Fill(bitNo, 1.); + // registry.get(HIST("global/hITSbitVsEtaPVtrk"))->Fill(p.Eta(), bitNo, 1.); + // nITSbits++; + // } + // } // end of loop over ITS bits + // + // isInnerITS = TESTBIT(clustermap1, 0) || TESTBIT(clustermap1, 1) || TESTBIT(clustermap1, 2); + // if (isInnerITS) { + // registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(10., 1.); + // } else { + // isGlobalTrack = false; + // } + // + } else { + isGlobalTrack = false; + } + if (track.hasTPC()) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(11., 1.); + } else { + isGlobalTrack = false; + } + // final global track + if (isGlobalTrack) { + registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(13., 1.); + } + return isGlobalTrack; + } // end of function + + // analysis track quality check with histogram filling + template + bool isGoodTrackCheckHisto(T track) + { + bool isGoodTrack = true; + registry.get(HIST("global/hTrackPVGood"))->Fill(0., 1.); + if (track.hasTPC()) { + registry.get(HIST("global/hTrackPVGood"))->Fill(1., 1.); + } else { + isGoodTrack = false; + } + if (track.tpcChi2NCl() < 4.) { + registry.get(HIST("global/hTrackPVGood"))->Fill(2., 1.); + } else { + isGoodTrack = false; + } + if (track.itsChi2NCl() < 36.) { + registry.get(HIST("global/hTrackPVGood"))->Fill(3., 1.); + } else { + isGoodTrack = false; + } + if (track.dcaZ() < 2.) { + registry.get(HIST("global/hTrackPVGood"))->Fill(4., 1.); + } else { + isGoodTrack = false; + } + if (track.dcaXY() < 0.0105 * 0.035 / std::pow(track.pt(), 1.1)) { + registry.get(HIST("global/hTrackPVGood"))->Fill(5., 1.); + } else { + isGoodTrack = false; + } + + if (track.tpcNClsCrossedRows() > 50) { + registry.get(HIST("global/hTrackPVGood"))->Fill(6., 1.); + } else { + isGoodTrack = false; + } + if (track.tpcNClsFindable() == 0) { + isGoodTrack = false; + } else { + if (track.tpcNClsCrossedRows() / track.tpcNClsFindable() > 0.8) { + registry.get(HIST("global/hTrackPVGood"))->Fill(7., 1.); + } else { + isGoodTrack = false; + } + } + if (isGoodTrack) { + registry.get(HIST("global/hTrackPVGood"))->Fill(13., 1.); + } + return isGoodTrack; + } + + // analysis track quality check + template + bool isGoodTrackCheck(T track) + { + if (!track.hasTPC()) + return false; + if (track.tpcChi2NCl() >= 4.) + return false; + if (track.itsChi2NCl() >= 36.) + return false; + // if (track.dcaZ() >= 2.) return false; + // if (track.dcaXY() >= 0.0105 * 0.035 / std::pow(track.pt(), 1.1)) return false; + if (track.tpcNClsCrossedRows() <= 50) + return false; + if (track.tpcNClsFindable() == 0) + return false; + if (track.tpcNClsCrossedRows() / track.tpcNClsFindable() <= 0.8) + return false; + return true; + } + + // analysis track quality check + template + bool isGoodTOFTrackCheckHisto(T track) + { + bool isGoodTrack = true; + if (track.hasTOF()) { + registry.get(HIST("global/hTrackPVGood"))->Fill(8., 1.); + } else { + isGoodTrack = false; + } + if (track.hasTOF() && track.tofChi2() < 3) { + registry.get(HIST("global/hTrackPVGood"))->Fill(9., 1.); + } else { + isGoodTrack = false; + } + return isGoodTrack; + } + + // analysis track quality check + template + bool isGoodTOFTrackCheck(T track) + { + if (!track.hasTOF()) + return false; + if (track.tofChi2() >= 3) + return false; + return true; + } + // using UDCollisionsFull = soa::Join; // using UDCollisionFull = UDCollisionsFull::iterator; using UDTracksFull = soa::Join; - using UDCollisionsFull2 = soa::Join; + // using UDCollisionsFull2 = soa::Join; // without occupancy cut + using UDCollisionsFull2 = soa::Join; using UDCollisionFull2 = UDCollisionsFull2::iterator; // PVContributors - Filter PVContributorFilter = aod::udtrack::isPVContributor == true; + Filter pVContributorFilter = aod::udtrack::isPVContributor == true; using PVTracks = soa::Filtered; + // using LabeledTracks = soa::Join; + using LabeledTracks = soa::Join; + Preslice perCollision = aod::udtrack::udCollisionId; + // PVContributors in MC handling + // Filter pVContributorFilterMC = aod::udtrack::isPVContributor == true; + // using PVTracksMC = soa::Filtered; + // void processDG(UDCollisionFull const& dgcand, UDTracksFull const& dgtracks) // { // int gapSide = 2; @@ -664,10 +1945,24 @@ struct TauTau13topo { // PROCESS_SWITCH(TauTau13topo, processDG, "Process DG data", DGactive); // void processSG(UDCollisionFull2 const& dgcand, UDTracksFull const& dgtracks) - void process(UDCollisionFull2 const& dgcand, UDTracksFull const& dgtracks, PVTracks const& PVContributors) + void processDataSG(UDCollisionFull2 const& dgcand, UDTracksFull const& dgtracks, PVTracks const& PVContributors) { + registry.get(HIST("global/hEventEff"))->Fill(-2., 1.); + registry.get(HIST("global/RunNumber"))->Fill(dgcand.runNumber()); + if (removeNoTOFrunsInData) { + if (dgcand.runNumber() == 544091 || dgcand.runNumber() == 544095 || dgcand.runNumber() == 544121 || dgcand.runNumber() == 544451) + return; + } + registry.get(HIST("global/hEventEff"))->Fill(-1., 1.); + registry.get(HIST("global/hRecFlag"))->Fill(dgcand.flags()); // reconstruction with upc settings flag + registry.get(HIST("global/hOccupancyInTime"))->Fill(dgcand.occupancyInTime()); + + if (dgcand.occupancyInTime() >= occupancyCut) + return; + registry.get(HIST("global/hEventEff"))->Fill(0., 1.); + int gapSide = dgcand.gapSide(); - int truegapSide = sgSelector.trueGap(dgcand, FV0_cut, FT0A_cut, FT0C_cut, ZDC_cut); + int truegapSide = sgSelector.trueGap(dgcand, cutFV0, cutFT0A, cutFT0C, cutZDC); registry.fill(HIST("global/GapSide"), gapSide); registry.fill(HIST("global/GapSideTrue"), truegapSide); if (gapSide < 0 || gapSide > 2) @@ -679,7 +1974,8 @@ struct TauTau13topo { // // void mainTask(int gapSide, UDTracksFull const& dgtracks) // { - if (gapSide != gap_Side) + registry.get(HIST("global/hEventEff"))->Fill(1., 1.); + if (gapSide != mGapSide) return; // global checks registry.get(HIST("global/hVertexXY"))->Fill(dgcand.posX(), dgcand.posY()); @@ -696,15 +1992,15 @@ struct TauTau13topo { registry.get(HIST("global/hNTracksPV"))->Fill(PVContributors.size()); // zdc information - float ZNAenergy = dgcand.energyCommonZNA(); - float ZNCenergy = dgcand.energyCommonZNC(); - // if (ZNAenergy < 0) registry.get(HIST("global/hZNACenergyTest"))->Fill(ZNAenergy); - // if (ZNCenergy < 0) registry.get(HIST("global/hZNACenergyTest"))->Fill(ZNCenergy); - if (ZNAenergy < 0) - ZNAenergy = -1.; - if (ZNCenergy < 0) - ZNCenergy = -1.; - registry.get(HIST("global/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); + float energyZNA = dgcand.energyCommonZNA(); + float energyZNC = dgcand.energyCommonZNC(); + // if (energyZNA < 0) registry.get(HIST("global/hZNACenergyTest"))->Fill(energyZNA); + // if (energyZNC < 0) registry.get(HIST("global/hZNACenergyTest"))->Fill(energyZNC); + if (energyZNA < 0) + energyZNA = -1.; + if (energyZNC < 0) + energyZNC = -1.; + registry.get(HIST("global/hZNACenergy"))->Fill(energyZNA, energyZNC); registry.get(HIST("global/hZNACtime"))->Fill(dgcand.timeZNA(), dgcand.timeZNC()); uint32_t clusterSizes; @@ -715,17 +2011,15 @@ struct TauTau13topo { int nITSbits = -1; int npT100 = 0; TLorentzVector p; - auto pionMass = pdg->Mass(211); - auto electronMass = pdg->Mass(11); - // TParticlePDG* pion = pdg->GetParticle(211); - // TParticlePDG* electron = pdg->GetParticle(11); + // auto const pionMass = MassPiPlus; + // auto const electronMass = MassElectron; bool flagGlobalCheck = true; - bool isGlobalTrack = true; + // bool isGlobalTrack = true; int qtot = 0; // loop over PV contributors for (const auto& trk : PVContributors) { qtot += trk.sign(); - p.SetXYZM(trk.px(), trk.py(), trk.pz(), pionMass); + p.SetXYZM(trk.px(), trk.py(), trk.pz(), MassPiPlus); registry.get(HIST("global/hTrackPtPV"))->Fill(p.Pt()); if (std::abs(p.Eta()) < trkEtacut) nEtaIn15++; // 1.5 is a default @@ -735,96 +2029,15 @@ struct TauTau13topo { npT100++; if (flagGlobalCheck) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(0., 1.); - if (trk.tpcNClsCrossedRows() > 70) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(1., 1.); - } else { - isGlobalTrack = false; - } - - if (trk.tpcNClsFindable() == 0) { - isGlobalTrack = false; - } else { - if (trk.tpcNClsCrossedRows() / trk.tpcNClsFindable() > 0.8) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(2., 1.); - } else { - isGlobalTrack = false; - } - } - - if (trk.tpcChi2NCl() < 4.) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(3., 1.); - } else { - isGlobalTrack = false; - } - - if (trk.itsChi2NCl() < 36.) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(4., 1.); - } else { - isGlobalTrack = false; - } - - if (trk.dcaZ() < 2.) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(5., 1.); - } else { - isGlobalTrack = false; - } - - if (trk.dcaXY() < 0.0105 * 0.035 / std::pow(trk.pt(), 1.1)) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(6., 1.); - } else { - isGlobalTrack = false; - } - - if (trk.pt() > 0.1) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(7., 1.); - } else { - isGlobalTrack = false; - } - - if (std::abs(p.Eta()) < 0.8) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(8., 1.); - } else { - isGlobalTrack = false; - } - - if (trk.hasITS()) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(9., 1.); - - // old version - // clustermap1 = trk.itsClusterMap(); - // for (int bitNo = 0; bitNo < 7; bitNo++) { - // if (TESTBIT(clustermap1, bitNo)) { // check ITS bits/layers for each PV track - // registry.get(HIST("global/hITSbitPVtrk"))->Fill(bitNo, 1.); - // registry.get(HIST("global/hITSbitVsEtaPVtrk"))->Fill(p.Eta(), bitNo, 1.); - // nITSbits++; - // } - // } // end of loop over ITS bits - // - // isInnerITS = TESTBIT(clustermap1, 0) || TESTBIT(clustermap1, 1) || TESTBIT(clustermap1, 2); - // if (isInnerITS) { - // registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(10., 1.); - // } else { - // isGlobalTrack = false; - // } - // - } else { - isGlobalTrack = false; - } - - if (trk.hasTPC()) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(11., 1.); - } else { - isGlobalTrack = false; - } - - // final global track - if (isGlobalTrack) { - registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(13., 1.); + if (isGlobalTrackCheck(trk)) { registry.get(HIST("global/hTrackEtaPhiPVGlobal"))->Fill(p.Eta(), p.Phi()); } } // end of flag check global + // check track selection + isGoodTrackCheckHisto(trk); + isGoodTOFTrackCheckHisto(trk); + // new version if (trk.hasITS()) { // ITS track nITSbits = -1; @@ -855,7 +2068,7 @@ struct TauTau13topo { // // selection // - registry.get(HIST("global/hEventEff"))->Fill(0., 1.); + registry.get(HIST("global/hEventEff"))->Fill(2., 1.); // skip events with too few/many tracks // if (PVContributors.size() != 4 || dgcand.numContrib() != 4) { @@ -873,35 +2086,44 @@ struct TauTau13topo { // return; // } - registry.get(HIST("global/hEventEff"))->Fill(1., 1.); + registry.get(HIST("global/hEventEff"))->Fill(3., 1.); // registry.get(HIST("global1/hTrackPVTotCharge"))->Fill(dgcand.netCharge()); registry.get(HIST("global1/hTrackPVTotCharge"))->Fill(qtot); registry.get(HIST("global1/hVertexZ"))->Fill(dgcand.posZ()); registry.get(HIST("global1/hNTracks"))->Fill(dgtracks.size()); registry.get(HIST("global1/hNTracksPV"))->Fill(PVContributors.size()); for (const auto& trk : PVContributors) { - p.SetXYZM(trk.px(), trk.py(), trk.pz(), pionMass); + p.SetXYZM(trk.px(), trk.py(), trk.pz(), MassPiPlus); registry.get(HIST("global1/hTrackPtPV"))->Fill(p.Pt()); registry.get(HIST("global1/hTrackEtaPhiPV"))->Fill(p.Eta(), p.Phi()); } - // if vz < 15 - if (std::abs(dgcand.posZ()) >= zvertexcut) { // default = 15 + // if vz < 10 + if (std::abs(dgcand.posZ()) >= zvertexcut) { // default = 10 if (verbose) { LOGF(info, " Candidate rejected: VertexZ is %f", dgcand.posZ()); } return; } - registry.get(HIST("global/hEventEff"))->Fill(2., 1.); + registry.get(HIST("global/hEventEff"))->Fill(4., 1.); // if eta tracks <1.5 if (nEtaIn15 != 4) { if (verbose) { - LOGF(info, " Candidate rejected: Ntrk inside |eta|<1.5 is %d", nEtaIn15); + LOGF(info, " Candidate rejected: Ntrk inside |eta|<0.9 is %d", nEtaIn15); } return; } - registry.get(HIST("global/hEventEff"))->Fill(3., 1.); + registry.get(HIST("global/hEventEff"))->Fill(5., 1.); + + // if pt tracks >0.100 GeV/c + if (npT100 != 4) { + if (verbose) { + LOGF(info, " Candidate rejected: number of tracks with pT>0.1GeV/c is %d", npT100); + } + return; + } + registry.get(HIST("global/hEventEff"))->Fill(6., 1.); // skip events with net charge != 0 if (!sameSign) { // opposite sign is signal @@ -921,7 +2143,7 @@ struct TauTau13topo { return; } } - registry.get(HIST("global/hEventEff"))->Fill(4., 1.); + registry.get(HIST("global/hEventEff"))->Fill(7., 1.); // // skip events with out-of-range rgtrwTOF (fraction-of-good-tracks-with-TOF-hit) // auto rtrwTOF = udhelpers::rPVtrwTOF(dgtracks, PVContributors.size()); @@ -931,8 +2153,36 @@ struct TauTau13topo { // } // return; // } + + // n TOF tracks cut + if (nTofTrk < nTofTrkMinCut) { + if (verbose) { + LOGF(info, " Candidate rejected: nTOFtracks is %d", nTofTrk); + } + return; + } + registry.get(HIST("global/hEventEff"))->Fill(8., 1.); + // // FIT informaton + // + auto bitMin = 16 - mFITvetoWindow; // default is +- 1 bc (1 bit) + auto bitMax = 16 + mFITvetoWindow; + bool flagFITveto = false; + // check FIT information + for (auto bit = bitMin; bit <= bitMax; bit++) { + if (TESTBIT(dgcand.bbFT0Apf(), bit)) + flagFITveto = true; + if (TESTBIT(dgcand.bbFT0Cpf(), bit)) + flagFITveto = true; + if (useFV0ForVeto && TESTBIT(dgcand.bbFV0Apf(), bit)) + flagFITveto = true; + if (useFDDAForVeto && TESTBIT(dgcand.bbFDDApf(), bit)) + flagFITveto = true; + if (useFDDCForVeto && TESTBIT(dgcand.bbFDDCpf(), bit)) + flagFITveto = true; + } // end of loop over FIT bits + // FIT histos for (auto bit = 0; bit <= 32; bit++) { registry.get(HIST("fit/bbFT0Abit"))->Fill(bit, TESTBIT(dgcand.bbFT0Apf(), bit)); registry.get(HIST("fit/bbFT0Cbit"))->Fill(bit, TESTBIT(dgcand.bbFT0Cpf(), bit)); @@ -951,28 +2201,14 @@ struct TauTau13topo { registry.get(HIST("fit/timeFT0"))->Fill(dgcand.timeFT0A(), dgcand.timeFT0C()); registry.get(HIST("fit/timeFDD"))->Fill(dgcand.timeFDDA(), dgcand.timeFDDC()); - // check FIT information - // auto bitMin = -1 + 16; - // auto bitMax = 1 + 16; - // for (auto bit = bitMin; bit <= bitMax; bit++) { - // if (TESTBIT(dgcand.bbFT0Apf(), bit) || - // TESTBIT(dgcand.bbFT0Cpf(), bit) || - // TESTBIT(dgcand.bbFV0Apf(), bit) || - // TESTBIT(dgcand.bbFDDApf(), bit) || - // TESTBIT(dgcand.bbFDDCpf(), bit)) { - // return; - // } - // } - // registry.get(HIST("global/hEventEff"))->Fill(5., 1.); - - // if pt tracks >0.100 GeV/c - if (npT100 != 4) { + // FIT empty + if (mFITvetoFlag && flagFITveto) { if (verbose) { - LOGF(info, " Candidate rejected: number of tracks with pT>0.1GeV/c is %d", npT100); + LOGF(info, " Candidate rejected: FIT is not empty"); } return; } - registry.get(HIST("global/hEventEff"))->Fill(5., 1.); + registry.get(HIST("global/hEventEff"))->Fill(9., 1.); // // here PID from TPC starts to be @@ -981,6 +2217,7 @@ struct TauTau13topo { float tmpMomentum[4]; float tmpPt[4]; float tmpDedx[4]; + float tmpTofNsigmaEl[4]; float pi3invMass[4]; float pi3pt[4]; float pi3deltaPhi[4]; @@ -993,20 +2230,24 @@ struct TauTau13topo { float nSigmaEl[4]; float nSigmaPi[4]; float nSigma3Pi[4] = {0., 0., 0., 0.}; + float nSigma3PiNew[4] = {0., 0., 0., 0.}; float nSigmaPr[4]; float nSigmaKa[4]; - float dcaZ[4]; - float dcaXY[4]; - float chi2TPC[4]; - float chi2ITS[4]; - float nclTPCfind[4]; + // float dcaZ[4]; + // float dcaXY[4]; + // float chi2TPC[4]; + // float chi2ITS[4]; + float chi2TOF[4] = {-1., -1., -1., -1.}; + // float nclTPCfind[4]; float nclTPCcrossedRows[4]; - bool tmpHasTOF[4]; + bool trkHasTof[4]; + bool trkHasTpc[4]; float mass3pi1e[4]; double trkTime[4]; float trkTimeRes[4]; double trkTimeTot = 0.; float trkTimeResTot = 10000.; + int nPiHasTPC[4] = {0, 0, 0, 0}; // 2 gamma from 4 electrons // 12 34 | 01 23 |//1 //6 | 0 5 |counter<3?counter:5-counter counter<3?0:1 @@ -1019,11 +2260,13 @@ struct TauTau13topo { bool flagIMGam2ePV[4] = {true, true, true, true}; for (const auto& trk : PVContributors) { - p.SetXYZM(trk.px(), trk.py(), trk.pz(), electronMass); + p.SetXYZM(trk.px(), trk.py(), trk.pz(), MassElectron); for (const auto& trk1 : PVContributors) { if (trk.index() >= trk1.index()) continue; - p1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), electronMass); + if (trk1.hasTPC()) + nPiHasTPC[trk.index()]++; + p1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), MassElectron); invMass2El[(counterTmp < 3 ? counterTmp : 5 - counterTmp)][(counterTmp < 3 ? 0 : 1)] = (p + p1).Mag2(); gammaPair[(counterTmp < 3 ? counterTmp : 5 - counterTmp)][(counterTmp < 3 ? 0 : 1)] = (p + p1); registry.get(HIST("control/cut0/hInvMass2ElAll"))->Fill((p + p1).Mag2()); @@ -1038,7 +2281,7 @@ struct TauTau13topo { // first loop to add all the tracks together p = TLorentzVector(0., 0., 0., 0.); for (const auto& trk : PVContributors) { - p1.SetXYZM(trk.px(), trk.py(), trk.pz(), pionMass); + p1.SetXYZM(trk.px(), trk.py(), trk.pz(), MassPiPlus); p += p1; scalarPtsum += trk.pt(); } // end of loop over PVContributors @@ -1052,16 +2295,22 @@ struct TauTau13topo { // remove combinatoric bool flagVcalPV[4] = {false, false, false, false}; + // bool trkIsGood[4] = {false, false, false, false}; + bool trkIsTOFGood[4] = {false, false, false, false}; + // second loop to calculate 1 by 1 each combinatorial variable counterTmp = 0; int tmpTrkCheck = -1; for (const auto& trk : PVContributors) { - tmpTrkCheck = TrackCheck(trk); // check detectors associated to track + // trkIsGood[counterTmp] = + isGoodTrackCheck(trk); + trkIsTOFGood[counterTmp] = isGoodTOFTrackCheck(trk); + tmpTrkCheck = trackCheck(trk); // check detectors associated to track registry.get(HIST("global/hTrkCheck"))->Fill(tmpTrkCheck); // inv mass of 3pi + 1e - p1.SetXYZM(trk.px(), trk.py(), trk.pz(), pionMass); - p2.SetXYZM(trk.px(), trk.py(), trk.pz(), electronMass); + p1.SetXYZM(trk.px(), trk.py(), trk.pz(), MassPiPlus); + p2.SetXYZM(trk.px(), trk.py(), trk.pz(), MassElectron); mass3pi1e[counterTmp] = (p - p1 + p2).Mag(); v1.SetXYZ(trk.px(), trk.py(), trk.pz()); @@ -1078,31 +2327,52 @@ struct TauTau13topo { nSigmaEl[counterTmp] = trk.tpcNSigmaEl(); nSigmaPi[counterTmp] = trk.tpcNSigmaPi(); nSigma3Pi[3] += (nSigmaPi[counterTmp] * nSigmaPi[counterTmp]); - nSigmaPr[counterTmp] = trk.tpcNSigmaPr(); - nSigmaKa[counterTmp] = trk.tpcNSigmaKa(); - dcaZ[counterTmp] = trk.dcaZ(); - dcaXY[counterTmp] = trk.dcaXY(); - chi2TPC[counterTmp] = trk.tpcChi2NCl(); - chi2ITS[counterTmp] = trk.itsChi2NCl(); - nclTPCfind[counterTmp] = trk.tpcNClsFindable(); + if (trk.hasTPC()) + nSigma3PiNew[3] += (nSigmaPi[counterTmp] * nSigmaPi[counterTmp]); + + if (whichPIDCut == 1) { // TPC only + nSigmaPr[counterTmp] = trk.tpcNSigmaPr(); + nSigmaKa[counterTmp] = trk.tpcNSigmaKa(); + } else if (whichPIDCut == 2) { // TPC + TOF sigma + nSigmaPr[counterTmp] = std::sqrt(trk.tofNSigmaPr() * trk.tofNSigmaPr() + trk.tpcNSigmaPr() * trk.tpcNSigmaPr()); + nSigmaKa[counterTmp] = std::sqrt(trk.tofNSigmaKa() * trk.tofNSigmaKa() + trk.tpcNSigmaKa() * trk.tpcNSigmaKa()); + } else if (whichPIDCut == 3) { // TPC + TOF hardcoded pt + nSigmaPr[counterTmp] = (trk.pt() < 1.5 ? trk.tofNSigmaPr() : trk.tpcNSigmaPr()); + nSigmaKa[counterTmp] = (trk.pt() < 1.3 ? trk.tofNSigmaKa() : trk.tpcNSigmaKa()); + } else { + nSigmaPr[counterTmp] = trk.tpcNSigmaPr(); + nSigmaKa[counterTmp] = trk.tpcNSigmaKa(); + } + + // dcaZ[counterTmp] = trk.dcaZ(); + // dcaXY[counterTmp] = trk.dcaXY(); + // chi2TPC[counterTmp] = trk.tpcChi2NCl(); + // chi2ITS[counterTmp] = trk.itsChi2NCl(); + if (trk.hasTOF()) + chi2TOF[counterTmp] = trk.tofChi2(); + // nclTPCfind[counterTmp] = trk.tpcNClsFindable(); nclTPCcrossedRows[counterTmp] = trk.tpcNClsCrossedRows(); - tmpHasTOF[counterTmp] = trk.hasTOF(); + // trkHasTof[counterTmp] = trk.hasTOF(); + trkHasTof[counterTmp] = isGoodTOFTrackCheck(trk); + trkHasTpc[counterTmp] = trk.hasTPC(); trkTime[counterTmp] = trk.trackTime(); trkTimeRes[counterTmp] = trk.trackTimeRes(); - p1.SetXYZM(trk.px(), trk.py(), trk.pz(), pionMass); + p1.SetXYZM(trk.px(), trk.py(), trk.pz(), MassPiPlus); tmpMomentum[counterTmp] = p1.P(); tmpPt[counterTmp] = p1.Pt(); tmpDedx[counterTmp] = trk.tpcSignal(); + tmpTofNsigmaEl[counterTmp] = trk.tofNSigmaEl(); - deltaPhiTmp = CalculateDeltaPhi(p - p1, p1); + deltaPhiTmp = calculateDeltaPhi(p - p1, p1); pi3invMass[counterTmp] = (p - p1).Mag(); pi3pt[counterTmp] = (p - p1).Pt(); pi3deltaPhi[counterTmp] = deltaPhiTmp; pi3assymav[counterTmp] = (p1.Pt() - (scalarPtsum - p1.Pt()) / 3.) / (p1.Pt() + (scalarPtsum - p1.Pt()) / 3.); - pi3vector[counterTmp] = (p + p1).Pt() / (p - p1).Pt(); - pi3scalar[counterTmp] = (p.Pt() - p1.Pt()) / (p.Pt() + p1.Pt()); - // pi3etasum[counterTmp] = (p - p1).Eta() + p1.Eta(); + // pi3vector[counterTmp] = (p + p1).Pt() / (p - p1).Pt(); + pi3vector[counterTmp] = p.Pt() / (p - p1 - p1).Pt(); + // pi3scalar[counterTmp] = (p.Pt() - p1.Pt()) / (p.Pt() + p1.Pt()); + pi3scalar[counterTmp] = ((p - p1).Pt() - p1.Pt()) / ((p - p1).Pt() + p1.Pt()); counterTmp++; } // end of loop over PVContributors @@ -1120,7 +2390,7 @@ struct TauTau13topo { for (int i = 0; i < 4; i++) { if (i == iTmpBest) continue; - trkTimeTot += fabs(trkTime[iTmpBest] - trkTime[i]); + trkTimeTot += std::abs(trkTime[iTmpBest] - trkTime[i]); } trkTimeResTot = std::sqrt(trkTimeRes[0] * trkTimeRes[0] + trkTimeRes[1] * trkTimeRes[1] + @@ -1129,13 +2399,27 @@ struct TauTau13topo { // control histos, max 4 per event, cut0 for (int i = 0; i < 4; i++) { - FillControlHistos<0>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); + fillControlHistos<0>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); registry.get(HIST("control/cut0/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); registry.get(HIST("pidTPC/hpvsdedxElHipCut0"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut0"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); // nsigma3Pi calculation nSigma3Pi[i] = nSigma3Pi[3] - (nSigmaPi[i] * nSigmaPi[i]); nSigma3Pi[i] = std::sqrt(nSigma3Pi[i]); registry.get(HIST("control/cut0/hsigma3Pi"))->Fill(nSigma3Pi[i]); + // nsigma3PiNew calculation + if (trkHasTpc[i]) { + nSigma3PiNew[i] = nSigma3PiNew[3] - (nSigmaPi[i] * nSigmaPi[i]); + } + nSigma3PiNew[i] = std::sqrt(nSigma3PiNew[i]); + + if (nPiHasTPC[i] == 3) + registry.get(HIST("control/cut0/hsigma3PiNew"))->Fill(nSigma3PiNew[i]); + if (nPiHasTPC[i] == 2) + registry.get(HIST("control/cut0/hsigma2PiNew"))->Fill(nSigma3PiNew[i]); + if (nPiHasTPC[i] == 1) + registry.get(HIST("control/cut0/hsigma1PiNew"))->Fill(nSigma3PiNew[i]); + // registry.get(HIST("control/cut0/h3pi1eMass"))->Fill(mass3pi1e[i]); } // end of loop over 4 tracks @@ -1144,7 +2428,7 @@ struct TauTau13topo { registry.get(HIST("control/cut0/h4piMass"))->Fill(mass4pi); registry.get(HIST("control/cut0/h4trkMassVsPt"))->Fill(mass4pi, pttot); registry.get(HIST("control/cut0/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut0/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); + registry.get(HIST("control/cut0/hZNACenergy"))->Fill(energyZNA, energyZNC); if (pttot < 0.150) { // give all the gg combinations @@ -1189,7 +2473,7 @@ struct TauTau13topo { registry.get(HIST("control/cut0/hGamAS"))->Fill(scalarAsym); registry.get(HIST("control/cut0/hGamAV"))->Fill(vectorAsym); registry.get(HIST("control/cut0/hInvMass2GamCoh"))->Fill((gammaPair[whichPair][1] + gammaPair[whichPair][0]).M()); - registry.get(HIST("control/cut0/hDeltaPhi2GamCoh"))->Fill(CalculateDeltaPhi(gammaPair[whichPair][1], gammaPair[whichPair][0])); + registry.get(HIST("control/cut0/hDeltaPhi2GamCoh"))->Fill(calculateDeltaPhi(gammaPair[whichPair][1], gammaPair[whichPair][0])); for (int j = 0; j < 4; j++) registry.get(HIST("pidTPC/hpvsdedxElHipCut40"))->Fill(tmpMomentum[j], tmpDedx[j]); if ((gammaPair[whichPair][1] + gammaPair[whichPair][0]).M() > 3. && @@ -1206,7 +2490,7 @@ struct TauTau13topo { registry.get(HIST("control/cut20/hGamAS"))->Fill(scalarAsym); registry.get(HIST("control/cut20/hGamAV"))->Fill(vectorAsym); registry.get(HIST("control/cut20/hInvMass2GamCoh"))->Fill((gammaPair[whichPair][1] + gammaPair[whichPair][0]).M()); - registry.get(HIST("control/cut20/hDeltaPhi2GamCoh"))->Fill(CalculateDeltaPhi(gammaPair[whichPair][1], gammaPair[whichPair][0])); + registry.get(HIST("control/cut20/hDeltaPhi2GamCoh"))->Fill(calculateDeltaPhi(gammaPair[whichPair][1], gammaPair[whichPair][0])); } } // ngam = 1 @@ -1327,512 +2611,2390 @@ struct TauTau13topo { registry.get(HIST("global/hNCombAfterCut"))->Fill(55. + counterTotal, 1.); // draw PID histograms + // + // electron + // if (counterEl > 0) { // Nelectrons>0, cut20 - registry.get(HIST("global/hEventEff"))->Fill(6., 1.); + registry.get(HIST("global/hEventEff"))->Fill(10., 1.); registry.get(HIST("control/cut20/h4trkPtTot"))->Fill(pttot); registry.get(HIST("control/cut20/h4piMass"))->Fill(mass4pi); registry.get(HIST("control/cut20/h4trkMassVsPt"))->Fill(mass4pi, pttot); registry.get(HIST("control/cut20/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut20/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); + registry.get(HIST("control/cut20/hZNACenergy"))->Fill(energyZNA, energyZNC); for (int i = 0; i < 4; i++) { if (flagEl[i]) { registry.get(HIST("pidTPC/hpvsdedxElHipCut20"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut20"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); // for (int j = 0; j < 4; j++) { // if (i == j) continue; // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut20"))->Fill(tmpMomentum[j], tmpDedx[j]); // } - FillControlHistos<20>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); + fillControlHistos<20>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); registry.get(HIST("control/cut20/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); registry.get(HIST("control/cut20/hsigma3Pi"))->Fill(nSigma3Pi[i]); registry.get(HIST("control/cut20/h3pi1eMass"))->Fill(mass3pi1e[i]); } } - - if (flagEl[0] * flagPi[0] + flagEl[1] * flagPi[1] + flagEl[2] * flagPi[2] + flagEl[3] * flagPi[3] > 0) { // pi veto, cut21 - registry.get(HIST("global/hEventEff"))->Fill(7., 1.); - registry.get(HIST("control/cut21/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut21/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut21/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut21/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut21/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - for (int i = 0; i < 4; i++) { - if (flagEl[i] && flagPi[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut21"))->Fill(tmpMomentum[i], tmpDedx[i]); - // for (int j = 0; j < 4; j++) { - // if (i == j) continue; - // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut21"))->Fill(tmpMomentum[j], tmpDedx[j]); - // } - FillControlHistos<21>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut21/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut21/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut21/h3pi1eMass"))->Fill(mass3pi1e[i]); - } - } - - if (flagEl[0] * flagPi[0] * !flagVcalPV[0] + - flagEl[1] * flagPi[1] * !flagVcalPV[1] + - flagEl[2] * flagPi[2] * !flagVcalPV[2] + - flagEl[3] * flagPi[3] * !flagVcalPV[3] > - 0) { // vcal veto, cut22 - registry.get(HIST("global/hEventEff"))->Fill(8., 1.); - registry.get(HIST("control/cut22/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut22/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut22/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut22/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut22/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - for (int i = 0; i < 4; i++) { - if (flagEl[i] && flagPi[i] && !flagVcalPV[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut22"))->Fill(tmpMomentum[i], tmpDedx[i]); - // for (int j = 0; j < 4; j++) { - // if (i == j) continue; - // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut22"))->Fill(tmpMomentum[j], tmpDedx[j]); - // } - FillControlHistos<22>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut22/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut22/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut22/h3pi1eMass"))->Fill(mass3pi1e[i]); - } - } - - if (flagEl[0] * flagPi[0] * !flagVcalPV[0] * flagPt[0] + - flagEl[1] * flagPi[1] * !flagVcalPV[1] * flagPt[1] + - flagEl[2] * flagPi[2] * !flagVcalPV[2] * flagPt[2] + - flagEl[3] * flagPi[3] * !flagVcalPV[3] * flagPt[3] > - 0) { // pT veto, cut23 - registry.get(HIST("global/hEventEff"))->Fill(9., 1.); - registry.get(HIST("control/cut23/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut23/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut23/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut23/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut23/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - for (int i = 0; i < 4; i++) { - if (flagEl[i] && flagPi[i] && !flagVcalPV[i] && flagPt[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut23"))->Fill(tmpMomentum[i], tmpDedx[i]); - // for (int j = 0; j < 4; j++) { - // if (i == j) continue; - // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut23"))->Fill(tmpMomentum[j], tmpDedx[j]); - // } - FillControlHistos<23>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut23/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut23/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut23/h3pi1eMass"))->Fill(mass3pi1e[i]); - } - } - - if (flagEl[0] * flagPi[0] * !flagVcalPV[0] * flagPt[0] * flagPr[0] + - flagEl[1] * flagPi[1] * !flagVcalPV[1] * flagPt[1] * flagPr[1] + - flagEl[2] * flagPi[2] * !flagVcalPV[2] * flagPt[2] * flagPr[2] + - flagEl[3] * flagPi[3] * !flagVcalPV[3] * flagPt[3] * flagPr[3] > - 0) { // proton veto, cut24 - registry.get(HIST("global/hEventEff"))->Fill(10., 1.); - registry.get(HIST("control/cut24/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut24/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut24/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut24/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut24/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - for (int i = 0; i < 4; i++) { - if (flagEl[i] && flagPi[i] && !flagVcalPV[i] && flagPt[i] && flagPr[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut24"))->Fill(tmpMomentum[i], tmpDedx[i]); - // for (int j = 0; j < 4; j++) { - // if (i == j) continue; - // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut24"))->Fill(tmpMomentum[j], tmpDedx[j]); - // } - FillControlHistos<24>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut24/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut24/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut24/h3pi1eMass"))->Fill(mass3pi1e[i]); - } - } - - if (flagEl[0] * flagPi[0] * !flagVcalPV[0] * flagPt[0] * flagPr[0] * flagKa[0] + - flagEl[1] * flagPi[1] * !flagVcalPV[1] * flagPt[1] * flagPr[1] * flagKa[1] + - flagEl[2] * flagPi[2] * !flagVcalPV[2] * flagPt[2] * flagPr[2] * flagKa[2] + - flagEl[3] * flagPi[3] * !flagVcalPV[3] * flagPt[3] * flagPr[3] * flagKa[3] > - 0) { // kaon veto, cut25 - registry.get(HIST("global/hEventEff"))->Fill(11., 1.); - registry.get(HIST("control/cut25/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut25/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut25/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut25/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut25/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - for (int i = 0; i < 4; i++) { - if (flagEl[i] && flagPi[i] && !flagVcalPV[i] && flagPt[i] && flagPr[i] && flagKa[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut25"))->Fill(tmpMomentum[i], tmpDedx[i]); - // for (int j = 0; j < 4; j++) { - // if (i == j) continue; - // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut25"))->Fill(tmpMomentum[j], tmpDedx[j]); - // } - FillControlHistos<25>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut25/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut25/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut25/h3pi1eMass"))->Fill(mass3pi1e[i]); - } - } - - if (flagEl[0] * flagPi[0] * !flagVcalPV[0] * flagPt[0] * flagPr[0] * flagKa[0] * flagIM[0] + - flagEl[1] * flagPi[1] * !flagVcalPV[1] * flagPt[1] * flagPr[1] * flagKa[1] * flagIM[1] + - flagEl[2] * flagPi[2] * !flagVcalPV[2] * flagPt[2] * flagPr[2] * flagKa[2] * flagIM[2] + - flagEl[3] * flagPi[3] * !flagVcalPV[3] * flagPt[3] * flagPr[3] * flagKa[3] * flagIM[3] > - 0) { // 3pi cut, cut26 - registry.get(HIST("global/hEventEff"))->Fill(12., 1.); - registry.get(HIST("control/cut26/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut26/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut26/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut26/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut26/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - for (int i = 0; i < 4; i++) { - if (flagEl[i] && flagPi[i] && !flagVcalPV[i] && flagPt[i] && flagPr[i] && flagKa[i] && flagIM[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut26"))->Fill(tmpMomentum[i], tmpDedx[i]); - // for (int j = 0; j < 4; j++) { - // if (i == j) continue; - // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut26"))->Fill(tmpMomentum[j], tmpDedx[j]); - // } - FillControlHistos<26>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut26/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut26/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut26/h3pi1eMass"))->Fill(mass3pi1e[i]); - } - } - - if (flagEl[0] * flagPi[0] * !flagVcalPV[0] * flagPt[0] * flagPr[0] * flagKa[0] * flagIM[0] * flagDP[0] + - flagEl[1] * flagPi[1] * !flagVcalPV[1] * flagPt[1] * flagPr[1] * flagKa[1] * flagIM[1] * flagDP[1] + - flagEl[2] * flagPi[2] * !flagVcalPV[2] * flagPt[2] * flagPr[2] * flagKa[2] * flagIM[2] * flagDP[2] + - flagEl[3] * flagPi[3] * !flagVcalPV[3] * flagPt[3] * flagPr[3] * flagKa[3] * flagIM[3] * flagDP[3] > - 0) { // delta phi cut, cut27 - registry.get(HIST("global/hEventEff"))->Fill(13., 1.); - registry.get(HIST("control/cut27/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut27/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut27/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut27/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut27/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - for (int i = 0; i < 4; i++) { - if (flagEl[i] && flagPi[i] && !flagVcalPV[i] && flagPt[i] && flagPr[i] && flagKa[i] && flagIM[i] && flagDP[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut27"))->Fill(tmpMomentum[i], tmpDedx[i]); - // for (int j = 0; j < 4; j++) { - // if (i == j) continue; - // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut27"))->Fill(tmpMomentum[j], tmpDedx[j]); - // } - FillControlHistos<27>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut27/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut27/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut27/h3pi1eMass"))->Fill(mass3pi1e[i]); - } - } - - if (flagEl[0] * flagPi[0] * !flagVcalPV[0] * flagPt[0] * flagPr[0] * flagKa[0] * flagIM[0] * flagDP[0] * flagCR[0] + - flagEl[1] * flagPi[1] * !flagVcalPV[1] * flagPt[1] * flagPr[1] * flagKa[1] * flagIM[1] * flagDP[1] * flagCR[1] + - flagEl[2] * flagPi[2] * !flagVcalPV[2] * flagPt[2] * flagPr[2] * flagKa[2] * flagIM[2] * flagDP[2] * flagCR[2] + - flagEl[3] * flagPi[3] * !flagVcalPV[3] * flagPt[3] * flagPr[3] * flagKa[3] * flagIM[3] * flagDP[3] * flagCR[3] > - 0) { // Nc-rTPC cut, cut28 - registry.get(HIST("global/hEventEff"))->Fill(14., 1.); - registry.get(HIST("control/cut28/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut28/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut28/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut28/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut28/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - for (int i = 0; i < 4; i++) { - if (flagEl[i] && flagPi[i] && !flagVcalPV[i] && flagPt[i] && flagPr[i] && flagKa[i] && flagIM[i] && flagDP[i] && flagCR[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut28"))->Fill(tmpMomentum[i], tmpDedx[i]); - FillControlHistos<28>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut28/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut28/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut28/h3pi1eMass"))->Fill(mass3pi1e[i]); - } - } - - if (flagEl[0] * flagPi[0] * !flagVcalPV[0] * flagPt[0] * flagPr[0] * flagKa[0] * flagIM[0] * flagDP[0] * flagCR[0] * flagS3pi[0] + - flagEl[1] * flagPi[1] * !flagVcalPV[1] * flagPt[1] * flagPr[1] * flagKa[1] * flagIM[1] * flagDP[1] * flagCR[1] * flagS3pi[1] + - flagEl[2] * flagPi[2] * !flagVcalPV[2] * flagPt[2] * flagPr[2] * flagKa[2] * flagIM[2] * flagDP[2] * flagCR[2] * flagS3pi[2] + - flagEl[3] * flagPi[3] * !flagVcalPV[3] * flagPt[3] * flagPr[3] * flagKa[3] * flagIM[3] * flagDP[3] * flagCR[3] * flagS3pi[3] > - 0) { // nsigma 3pi cut, cut29 - registry.get(HIST("global/hEventEff"))->Fill(15., 1.); - registry.get(HIST("control/cut29/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut29/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut29/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut29/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut29/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - for (int i = 0; i < 4; i++) { - if (flagEl[i] && flagPi[i] && !flagVcalPV[i] && flagPt[i] && flagPr[i] && flagKa[i] && flagIM[i] && flagDP[i] && flagCR[i] && flagS3pi[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut29"))->Fill(tmpMomentum[i], tmpDedx[i]); - FillControlHistos<29>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut29/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut29/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut29/h3pi1eMass"))->Fill(mass3pi1e[i]); - if (verbose) { - LOGF(info, "cut29 timeTot %f, resTot %f, trackTime %f, %f, %f, %f Res %f, %f, %f, %f", trkTimeTot, trkTimeResTot, trkTime[0], trkTime[1], trkTime[2], trkTime[3], trkTimeRes[0], trkTimeRes[1], trkTimeRes[2], trkTimeRes[3]); - } - } - } - - } else { - if (verbose) { - LOGF(debug, " Candidate rejected: all electrons vetoed by piPID+Vcal+pT+prPID+KaPID+Dphi+IM+CR"); - } - } // end of nsigma 3pi cut - } else { - if (verbose) { - LOGF(debug, " Candidate rejected: all electrons vetoed by piPID+Vcal+pT+prPID+KaPID+Dphi+IM+CR"); - } - } // end of TPC crossed rows for electron cut - } else { - if (verbose) { - LOGF(debug, " Candidate rejected: all electrons vetoed by piPID+Vcal+pT+prPID+KaPID+Dphi+IM"); - } - } // end of delta phi cut - } else { - if (verbose) { - LOGF(debug, " Candidate rejected: all electrons vetoed by piPID+Vcal+pT+prPID+KaPID+Dphi"); - } - } // end of inv mass 3 pi cut - } else { - if (verbose) { - LOGF(debug, " Candidate rejected: all electrons vetoed by piPID+Vcal+pT+prPID+KaPID"); - } - } // end of kaon veto - } else { - if (verbose) { - LOGF(debug, " Candidate rejected: all electrons vetoed by piPID+Vcal+pT+prPID"); - } - } // end of proton veto - } else { - if (verbose) { - LOGF(debug, " Candidate rejected: all electrons vetoed by piPID+Vcal+pT"); - } - } // end of pT veto - } else { - if (verbose) { - LOGF(debug, " Candidate rejected: all electrons vetoed by piPID+Vcal"); - } - } // end of vcal veto - } else { - if (verbose) { - LOGF(debug, " Candidate rejected: all electrons vetoed by pi PID"); - } - } // end of pi veto - } else { // no electron + } else { + // no electron if (verbose) { LOGF(debug, " Candidate rejected: no electron PID among 4 tracks"); } + return; } // end of Nelectrons check - // skip events with pttot<0.15 - if (pttot < ptTotcut) { + // + // electron with tof hit (cut33) + // + if (flagEl[0] * trkHasTof[0] + + flagEl[1] * trkHasTof[1] + + flagEl[2] * trkHasTof[2] + + flagEl[3] * trkHasTof[3] > + 0) { // electron has tof hit cut 33 + registry.get(HIST("global/hEventEff"))->Fill(11., 1.); + // registry.get(HIST("control/cut33/hDcaZ"))->Fill(dcaZ[i]); + // registry.get(HIST("control/cut33/hDcaXY"))->Fill(dcaXY[i]); + // registry.get(HIST("control/cut33/hChi2TPC"))->Fill(chi2TPC[i]); + // registry.get(HIST("control/cut33/hChi2ITS"))->Fill(chi2ITS[i]); + registry.get(HIST("control/cut33/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut33/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut33/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut33/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut33/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i]) { + fillControlHistos<33>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut33/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("pidTPC/hpvsdedxElHipCut33"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut33"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + registry.get(HIST("control/cut33/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut33/h3pi1eMass"))->Fill(mass3pi1e[i]); + // registry.get(HIST("control/cut33/hPtSpectrumEl"))->Fill(tmpPt[i]); + } // only for electron + } + } else { if (verbose) { - LOGF(info, " Candidate rejected: pt tot is %f", pttot); + LOGF(info, "cut33 trackTime %f, %f, %f, %f Res %f, %f, %f, %f", trkTime[0], trkTime[1], trkTime[2], trkTime[3], trkTimeRes[0], trkTimeRes[1], trkTimeRes[2], trkTimeRes[3]); + LOGF(debug, " Candidate rejected: no TOF hit for electron"); } return; - } - if (counterTotal > 0) { - registry.get(HIST("global/hEventEff"))->Fill(16., 1.); - registry.get(HIST("control/cut30/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut30/h4piMass"))->Fill(mass4pi); + } // end of tof hit for electron + + // + // pi veto cut21 + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] > + 0) { // pi veto, cut21 + registry.get(HIST("global/hEventEff"))->Fill(12., 1.); + registry.get(HIST("control/cut21/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut21/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut21/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut21/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut21/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i] && flagPi[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut21"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut21"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + fillControlHistos<21>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut21/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut21/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut21/h3pi1eMass"))->Fill(mass3pi1e[i]); + } + } + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by pi PID"); + } + return; + } // end of pi veto + + // + // proton veto + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] > + 0) { // proton veto, cut24 + registry.get(HIST("global/hEventEff"))->Fill(13., 1.); + registry.get(HIST("control/cut24/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut24/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut24/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut24/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut24/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut24"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut24"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + // for (int j = 0; j < 4; j++) { + // if (i == j) continue; + // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut24"))->Fill(tmpMomentum[j], tmpDedx[j]); + // } + fillControlHistos<24>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut24/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut24/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut24/h3pi1eMass"))->Fill(mass3pi1e[i]); + } + } + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by piPID+Vcal+pT+prPID"); + } + return; + } // end of proton veto + + // + // kaon veto + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] > + 0) { // kaon veto, cut25 + registry.get(HIST("global/hEventEff"))->Fill(14., 1.); + registry.get(HIST("control/cut25/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut25/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut25/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut25/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut25/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut25"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut25"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + // for (int j = 0; j < 4; j++) { + // if (i == j) continue; + // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut25"))->Fill(tmpMomentum[j], tmpDedx[j]); + // } + fillControlHistos<25>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut25/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut25/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut25/h3pi1eMass"))->Fill(mass3pi1e[i]); + } + } + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by KaPID"); + } + return; + } // end of kaon veto + + // + // number of crossed rows in TPC for electron + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] > + 0) { // Nc-rTPC cut, cut28 + registry.get(HIST("global/hEventEff"))->Fill(15., 1.); + registry.get(HIST("control/cut28/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut28/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut28/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut28/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut28/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut28"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut28"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + fillControlHistos<28>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut28/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut28/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut28/h3pi1eMass"))->Fill(mass3pi1e[i]); + } + } + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by CR"); + } + return; + } // end of TPC crossed rows for electron cut + + // + // virtal calorimeter + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] * !flagVcalPV[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] * !flagVcalPV[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] * !flagVcalPV[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] * !flagVcalPV[3] > + 0) { // vcal veto, cut22 + registry.get(HIST("global/hEventEff"))->Fill(16., 1.); + registry.get(HIST("control/cut22/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut22/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut22/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut22/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut22/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut22"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut22"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + // for (int j = 0; j < 4; j++) { + // if (i == j) continue; + // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut22"))->Fill(tmpMomentum[j], tmpDedx[j]); + // } + fillControlHistos<22>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut22/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut22/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut22/h3pi1eMass"))->Fill(mass3pi1e[i]); + } + } + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by Vcal"); + } + return; + } // end of vcal veto + + // + // 3pi nsigma cut29 + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] * !flagVcalPV[0] * flagS3pi[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] * !flagVcalPV[1] * flagS3pi[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] * !flagVcalPV[2] * flagS3pi[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] * !flagVcalPV[3] * flagS3pi[3] > + 0) { // nsigma 3pi cut, cut29 + registry.get(HIST("global/hEventEff"))->Fill(17., 1.); + registry.get(HIST("control/cut29/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut29/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut29/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut29/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut29/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut29"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut29"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + fillControlHistos<29>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut29/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut29/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut29/h3pi1eMass"))->Fill(mass3pi1e[i]); + if (verbose) { + LOGF(info, "cut29 timeTot %f, resTot %f, trackTime %f, %f, %f, %f Res %f, %f, %f, %f", trkTimeTot, trkTimeResTot, trkTime[0], trkTime[1], trkTime[2], trkTime[3], trkTimeRes[0], trkTimeRes[1], trkTimeRes[2], trkTimeRes[3]); + } + } + } + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by 3piPID"); + } + return; + } // end of nsigma 3pi cut + + // + // IM cut + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] * !flagVcalPV[0] * flagS3pi[0] * flagIM[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] * !flagVcalPV[1] * flagS3pi[1] * flagIM[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] * !flagVcalPV[2] * flagS3pi[2] * flagIM[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] * !flagVcalPV[3] * flagS3pi[3] * flagIM[3] > + 0) { // 3pi cut, cut26 + registry.get(HIST("global/hEventEff"))->Fill(18., 1.); + registry.get(HIST("control/cut26/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut26/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut26/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut26/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut26/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut26"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut26"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + // for (int j = 0; j < 4; j++) { + // if (i == j) continue; + // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut26"))->Fill(tmpMomentum[j], tmpDedx[j]); + // } + fillControlHistos<26>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut26/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut26/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut26/h3pi1eMass"))->Fill(mass3pi1e[i]); + } + } + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by IM"); + } + return; + } // end of inv mass 3 pi cut + + // + // at least one pion with tof hit (cut34) + // + int otherTOFtracks[4]; + for (int i = 0; i < 4; i++) { + otherTOFtracks[i] = 0; + if (flagEl[i] && trkHasTof[i]) { + for (int j = 0; j < 4; j++) { + if (i == j) + continue; + // if (trkHasTof[j]) { + if (trkIsTOFGood[j]) { + otherTOFtracks[i]++; + registry.get(HIST("pidTOF/h3piTOFchi2"))->Fill(chi2TOF[j]); + } + } // second loop over tracks + } + } // first loop over tracks + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] * !flagVcalPV[0] * flagS3pi[0] * flagIM[0] * (otherTOFtracks[0] >= 1) + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] * !flagVcalPV[1] * flagS3pi[1] * flagIM[1] * (otherTOFtracks[1] >= 1) + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] * !flagVcalPV[2] * flagS3pi[2] * flagIM[2] * (otherTOFtracks[2] >= 1) + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] * !flagVcalPV[3] * flagS3pi[3] * flagIM[3] * (otherTOFtracks[3] >= 1) > + 0) { // at lest 1 pi with tof hit, cut34 + registry.get(HIST("global/hRecFlag"))->Fill(5 + dgcand.flags()); // reconstruction with upc settings flag + registry.get(HIST("global/hEventEff"))->Fill(19., 1.); + // registry.get(HIST("control/cut34/hDcaZ"))->Fill(dcaZ[i]); + // registry.get(HIST("control/cut34/hDcaXY"))->Fill(dcaXY[i]); + // registry.get(HIST("control/cut34/hChi2TPC"))->Fill(chi2TPC[i]); + // registry.get(HIST("control/cut34/hChi2ITS"))->Fill(chi2ITS[i]); + registry.get(HIST("control/cut34/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut34/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut34/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut34/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut34/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && (otherTOFtracks[i] >= 1)) { + fillControlHistos<34>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut34/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("pidTPC/hpvsdedxElHipCut34"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut34"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + registry.get(HIST("control/cut34/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut34/h3pi1eMass"))->Fill(mass3pi1e[i]); + // registry.get(HIST("control/cut34/hPtSpectrumEl"))->Fill(tmpPt[i]); + } else if (!flagEl[i] && trkHasTof[i]) { + registry.get(HIST("pidTOF/h3piTOFchi2Cut34"))->Fill(chi2TOF[i]); + } + } + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by lack of TOF hit in 3pi"); + } + return; + } // end of at least one pion with tof hit (cut34) + + // + // skip events with pttot<0.15 + // + if (pttot < ptTotcut) { + if (verbose) { + LOGF(info, " Candidate rejected: pt tot is %f", pttot); + } + return; + } else { + registry.get(HIST("global/hEventEff"))->Fill(20., 1.); + registry.get(HIST("control/cut30/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut30/h4piMass"))->Fill(mass4pi); registry.get(HIST("control/cut30/h4trkMassVsPt"))->Fill(mass4pi, pttot); registry.get(HIST("control/cut30/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut30/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); + registry.get(HIST("control/cut30/hZNACenergy"))->Fill(energyZNA, energyZNC); + registry.get(HIST("global/hRecFlag"))->Fill(5 + 2 + dgcand.flags()); // reconstruction with upc settings flag for (int i = 0; i < 4; i++) { - if (flagTotal[i]) { + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && (otherTOFtracks[i] >= 1)) { registry.get(HIST("pidTPC/hpvsdedxElHipCut30"))->Fill(tmpMomentum[i], tmpDedx[i]); - FillControlHistos<30>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut30"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + fillControlHistos<30>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); registry.get(HIST("control/cut30/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); registry.get(HIST("control/cut30/hsigma3Pi"))->Fill(nSigma3Pi[i]); registry.get(HIST("control/cut30/h3pi1eMass"))->Fill(mass3pi1e[i]); + } else if (!flagEl[i] && trkHasTof[i]) { + registry.get(HIST("pidTOF/h3piTOFchi2Cut30"))->Fill(chi2TOF[i]); } } - } + } // end of pttot<0.15 cut30 - // check FIT information - if (FITvetoFlag) { - auto bitMin = 16 - FITvetoWindow; // default is +- 1 bc (1 bit) - auto bitMax = 16 + FITvetoWindow; - for (auto bit = bitMin; bit <= bitMax; bit++) { - if (TESTBIT(dgcand.bbFT0Apf(), bit)) - return; - if (TESTBIT(dgcand.bbFT0Cpf(), bit)) - return; - if (useFV0ForVeto && TESTBIT(dgcand.bbFV0Apf(), bit)) - return; - if (useFDDAForVeto && TESTBIT(dgcand.bbFDDApf(), bit)) - return; - if (useFDDCForVeto && TESTBIT(dgcand.bbFDDCpf(), bit)) - return; - } // end of loop over bits - } // end of check emptyness around given BC in FIT detectors - if (counterTotal > 0) { - registry.get(HIST("global/hEventEff"))->Fill(17., 1.); - registry.get(HIST("control/cut31/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut31/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut31/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut31/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut31/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); + // + // delta phi + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] * !flagVcalPV[0] * flagS3pi[0] * flagIM[0] * (otherTOFtracks[0] >= 1) * flagDP[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] * !flagVcalPV[1] * flagS3pi[1] * flagIM[1] * (otherTOFtracks[1] >= 1) * flagDP[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] * !flagVcalPV[2] * flagS3pi[2] * flagIM[2] * (otherTOFtracks[2] >= 1) * flagDP[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] * !flagVcalPV[3] * flagS3pi[3] * flagIM[3] * (otherTOFtracks[3] >= 1) * flagDP[3] > + 0) { // delta phi cut, cut27 + registry.get(HIST("global/hEventEff"))->Fill(21., 1.); + registry.get(HIST("control/cut27/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut27/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut27/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut27/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut27/hZNACenergy"))->Fill(energyZNA, energyZNC); + registry.get(HIST("global/hRecFlag"))->Fill(5 + 2 + 2 + dgcand.flags()); // reconstruction with upc settings flag for (int i = 0; i < 4; i++) { - if (flagTotal[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut31"))->Fill(tmpMomentum[i], tmpDedx[i]); - FillControlHistos<31>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut31/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut31/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut31/h3pi1eMass"))->Fill(mass3pi1e[i]); + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && (otherTOFtracks[i] >= 1) && flagDP[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut27"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut27"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + // for (int j = 0; j < 4; j++) { + // if (i == j) continue; + // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut27"))->Fill(tmpMomentum[j], tmpDedx[j]); + // } + fillControlHistos<27>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut27/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut27/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut27/h3pi1eMass"))->Fill(mass3pi1e[i]); + } else if (!flagEl[i] && trkHasTof[i]) { + registry.get(HIST("pidTOF/h3piTOFchi2Cut27"))->Fill(chi2TOF[i]); + // LOGF(info, " chi2TOF %f", chi2TOF[i]); } } - } + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by Dphi"); + } + return; + } // end of Dphi - // n TOF tracks cut - if (nTofTrk < nTofTrkMinCut) { + // + // skip events with znac energy cut 35 + // + if (energyZNA >= 1. || energyZNC >= 1.) { if (verbose) { - LOGF(info, " Candidate rejected: nTOFtracks is %d", nTofTrk); + LOGF(info, " Candidate rejected: ZNA, ZNC are %f, %f", energyZNA, energyZNC); } return; - } - if (counterTotal > 0) { - registry.get(HIST("global/hEventEff"))->Fill(18., 1.); - registry.get(HIST("control/cut32/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut32/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut32/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut32/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut32/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); + } else { + registry.get(HIST("global/hEventEff"))->Fill(22., 1.); + registry.get(HIST("control/cut35/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut35/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut35/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut35/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut35/hZNACenergy"))->Fill(energyZNA, energyZNC); for (int i = 0; i < 4; i++) { - if (flagTotal[i]) { - registry.get(HIST("pidTPC/hpvsdedxElHipCut32"))->Fill(tmpMomentum[i], tmpDedx[i]); - FillControlHistos<32>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut32/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("control/cut32/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut32/h3pi1eMass"))->Fill(mass3pi1e[i]); - registry.get(HIST("control/cut32/hPtSpectrumEl"))->Fill(tmpPt[i]); - if (verbose) { - LOGF(info, "cut32 trackTime %f, %f, %f, %f Res %f, %f, %f, %f", trkTime[0], trkTime[1], trkTime[2], trkTime[3], trkTimeRes[0], trkTimeRes[1], trkTimeRes[2], trkTimeRes[3]); - } + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && (otherTOFtracks[i] >= 1) && flagDP[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut35"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut35"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + fillControlHistos<35>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut35/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut35/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut35/h3pi1eMass"))->Fill(mass3pi1e[i]); + } else if (!flagEl[i] && trkHasTof[i]) { + registry.get(HIST("pidTOF/h3piTOFchi2Cut35"))->Fill(chi2TOF[i]); + } + } + } // end of ZNAC energy cut35 + + // + // skip events with occupancy >=1000 + // + if (dgcand.occupancyInTime() >= 1000) { + if (verbose) { + LOGF(info, " Candidate rejected: occupancy is %f", dgcand.occupancyInTime()); + } + return; + } else { + registry.get(HIST("global/hEventEff"))->Fill(23., 1.); + registry.get(HIST("control/cut23/h4trkPtTot"))->Fill(pttot); + registry.get(HIST("control/cut23/h4piMass"))->Fill(mass4pi); + registry.get(HIST("control/cut23/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registry.get(HIST("control/cut23/hNtofTrk"))->Fill(nTofTrk); + registry.get(HIST("control/cut23/hZNACenergy"))->Fill(energyZNA, energyZNC); + for (int i = 0; i < 4; i++) { + if (flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && (otherTOFtracks[i] >= 1) && flagDP[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut23"))->Fill(tmpMomentum[i], tmpDedx[i]); + registry.get(HIST("pidTOF/hpvsNsigmaElHipCut23"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + fillControlHistos<23>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registry.get(HIST("control/cut23/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registry.get(HIST("control/cut23/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry.get(HIST("control/cut23/h3pi1eMass"))->Fill(mass3pi1e[i]); + } else if (!flagEl[i] && trkHasTof[i]) { + registry.get(HIST("pidTOF/h3piTOFchi2Cut23"))->Fill(chi2TOF[i]); } } + } // end of occupancy < 1000 cut23 + + // // only 1 electron + // if (counterTotal == 1) { + // registry.get(HIST("global/hEventEff"))->Fill(19., 1.); + // for (int i = 0; i < 4; i++) { + // registry.get(HIST("control/cut1/hDcaZ"))->Fill(dcaZ[i]); + // registry.get(HIST("control/cut1/hDcaXY"))->Fill(dcaXY[i]); + // registry.get(HIST("control/cut1/hChi2TPC"))->Fill(chi2TPC[i]); + // registry.get(HIST("control/cut1/hChi2ITS"))->Fill(chi2ITS[i]); + // registry.get(HIST("control/cut1/hChi2TOF"))->Fill(chi2TOF[i]); + // if (flagTotal[i]) { + // fillControlHistos<1>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + // registry.get(HIST("control/cut1/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + // registry.get(HIST("pidTPC/hpvsdedxElHipCut1"))->Fill(tmpMomentum[i], tmpDedx[i]); + // for (int j = 0; j < 4; j++) { + // if (i == j) + // continue; + // registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut1"))->Fill(tmpMomentum[j], tmpDedx[j]); + // } + // registry.get(HIST("global/hFinalPtSpectrumEl"))->Fill(tmpPt[i]); + // registry.get(HIST("control/cut1/hTPCnclsFindable"))->Fill(nclTPCfind[i]); + // registry.get(HIST("control/cut1/hsigma3Pi"))->Fill(nSigma3Pi[i]); + // registry.get(HIST("control/cut1/h3pi1eMass"))->Fill(mass3pi1e[i]); + // if (verbose) { + // LOGF(info, "cut1 trackTime %f, %f, %f, %f Res %f, %f, %f, %f", trkTime[0], trkTime[1], trkTime[2], trkTime[3], trkTimeRes[0], trkTimeRes[1], trkTimeRes[2], trkTimeRes[3]); + // } + // } + // } // end of loop over 4 tracks + // registry.get(HIST("control/cut1/h4trkPtTot"))->Fill(pttot); + // registry.get(HIST("control/cut1/h4piMass"))->Fill(mass4pi); + // registry.get(HIST("control/cut1/h4trkMassVsPt"))->Fill(mass4pi, pttot); + // registry.get(HIST("control/cut1/hNtofTrk"))->Fill(nTofTrk); + // registry.get(HIST("control/cut1/hZNACenergy"))->Fill(energyZNA, energyZNC); + // // special case invmass 4pi (2,2.3) + // // if (mass4pi<2.3 && mass4pi>2) { + // // for (int i = 0; i < 4; i++) { + // // registry.get(HIST("control/cut1/cut1a/hDcaZ"))->Fill(dcaZ[i]); + // // registry.get(HIST("control/cut1/cut1a/hDcaXY"))->Fill(dcaXY[i]); + // // registry.get(HIST("control/cut1/cut1a/hChi2TPC"))->Fill(chi2TPC[i]); + // // registry.get(HIST("control/cut1/cut1a/hChi2ITS"))->Fill(chi2ITS[i]); + // // + // // if (flagTotal[i]) { + // // registry.get(HIST("control/cut1/cut1a/h3piMassComb"))->Fill(pi3invMass[i]); + // // registry.get(HIST("control/cut1/cut1a/h3trkPtTot"))->Fill(pi3pt[i]); + // // registry.get(HIST("control/cut1/cut1a/hDeltaPhi13topo"))->Fill(pi3deltaPhi[i]); + // // registry.get(HIST("control/cut1/cut1a/h13AssymPt1ProngAver"))->Fill(pi3assymav[i]); + // // registry.get(HIST("control/cut1/cut1a/h13Vector"))->Fill(pi3vector[i]); + // // registry.get(HIST("control/cut1/cut1a/h13Scalar"))->Fill(pi3scalar[i]); + // // registry.get(HIST("control/cut1/cut1a/h13EtaSum"))->Fill(pi3etasum[i]); + // // registry.get(HIST("control/cut1/cut1a/hTPCnCrossedRows"))->Fill(nclTPCcrossedRows[i]); + // // + // // registry.get(HIST("control/cut1/cut1a/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + // // registry.get(HIST("control/cut1/cut1a/hTPCnclsFindable"))->Fill(nclTPCfind[i]); + // // registry.get(HIST("control/cut1/cut1a/hsigma3Pi"))->Fill(nSigma3Pi[i]); + // // } + // // } + // // registry.get(HIST("control/cut1/cut1a/h4trkPtTot"))->Fill(pttot); + // // registry.get(HIST("control/cut1/cut1a/h4piMass"))->Fill(mass4pi); + // // registry.get(HIST("control/cut1/cut1a/h4trkMassVsPt"))->Fill(mass4pi, pttot); + // // registry.get(HIST("control/cut1/cut1a/hNtofTrk"))->Fill(nTofTrk); + // // } // end of mass window for 4pi case + // + // } else { // more than 1 electron candidate + // if (verbose) { + // LOGF(debug, " Candidate rejected: more than one electron candidate"); + // } + // } // end of 1electrons check + } // end of processDataSG + // check ntracks-4PVtracks + // check pt of remaining (ntracks-4PVtracks) tracks + + // + // basic distributions from MC related to tau, electron and MC particles + // + void processSimpleMCSG(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles) + { + registryMC.get(HIST("globalMC/hMCZvertex"))->Fill(mcCollision.posZ()); + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(0., 1.); + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(0., 1.); + registryMC.get(HIST("efficiencyMCMu/effiMu"))->Fill(0., 1.); + registryMC.get(HIST("efficiencyMCPi/effiPi"))->Fill(0., 1.); + + // check how many physical primaries + // int countPrim = 0; + int countGen = 0; + int countBoth = 0; + int countCharged = 0; + int countChargedFromTau = 0; + int countTau = 0; + + float etaTau[2]; + float phiTau[2]; + + int pionCounter = 0; + int singlePionIndex = -1; + int tmpPionIndex = -1; + // int tmpPionGlobalIndex=-1; + // int singlePionGlobalIndex=-1; + // int singleElectronGlobalIndex=-1; + // int threePionGlobalIndex[3]={-1,-1,-1}; + // int threePionIndex[3]={-1,-1,-1}; + // int motherOfSinglePionIndex=-1; + // int motherOfThreePionIndex=-1; + bool electronFound = false; + bool muonFound = false; + bool threePionsFound = false; + bool singlePionFound = false; + bool tauInRapidity = true; + bool partFromTauInEta = true; + float partPt = 0.; + // bool flagE3pi = false; + // bool flagMu3pi = false; + // bool flagPi3pi = false; + bool flagElPlusElMinus = false; // e+ = 0, e- =1 + bool flagMuPlusMuMinus = false; // mu+ = 0, mu- =1 + bool flagPiPlusPiMinus = false; // pi+ = 0, pi- =1 + + // loop over MC particles + for (const auto& mcParticle : mcParticles) { + // primaries + // if (mcParticle.isPhysicalPrimary()) { + // countPrim++; + // } + // + // MC particles produced by generator only + // + if (mcParticle.producedByGenerator()) { + countGen++; + if (mcParticle.isPhysicalPrimary()) { + countBoth++; + if (mcParticle.pdgCode() != 22 && std::abs(mcParticle.pdgCode()) != 12 && std::abs(mcParticle.pdgCode()) != 14 && std::abs(mcParticle.pdgCode()) != 16 && mcParticle.pdgCode() != 130 && mcParticle.pdgCode() != 111) { + countCharged++; + + registryMC.get(HIST("globalMC/hMCetaGen"))->Fill(mcParticle.eta()); + registryMC.get(HIST("globalMC/hMCphiGen"))->Fill(mcParticle.phi()); + registryMC.get(HIST("globalMC/hMCyGen"))->Fill(mcParticle.y()); + registryMC.get(HIST("globalMC/hMCptGen"))->Fill(mcParticle.pt()); + + if (mcParticle.has_mothers()) { + auto const& mother = mcParticle.mothers_first_as(); + if (std::abs(mother.pdgCode()) == 15) { + countChargedFromTau++; + } // mother is tau + } // mc particle has mother + } // veto neutral particles + } // physicsl primary + } // generator produced by + + // + // tau+/- + // + if (std::abs(mcParticle.pdgCode()) == 15) { // tau+/- + countTau++; + if (countTau <= 2) { + etaTau[countTau - 1] = mcParticle.eta(); + phiTau[countTau - 1] = mcParticle.phi(); + } + + registryMC.get(HIST("tauMC/hMCeta"))->Fill(mcParticle.eta()); + registryMC.get(HIST("tauMC/hMCphi"))->Fill(mcParticle.phi()); + registryMC.get(HIST("tauMC/hMCy"))->Fill(mcParticle.y()); + registryMC.get(HIST("tauMC/hMCpt"))->Fill(mcParticle.pt()); + if (std::abs(mcParticle.y()) > 0.9) + tauInRapidity = false; + pionCounter = 0; + if (mcParticle.has_daughters()) { + for (const auto& daughter : mcParticle.daughters_as()) { + // pions from tau + if (std::abs(daughter.pdgCode()) == 211) { // 211 = pi+ + pionCounter++; + tmpPionIndex = daughter.index(); // returns index of daughter of tau, not in the event, not in the MC particles + if (std::abs(daughter.eta()) > 0.9) + partFromTauInEta = false; + } // end of pion check + // electron from tau + if (std::abs(daughter.pdgCode()) == 11) { // 11 = electron + if (daughter.pdgCode() == 11) + flagElPlusElMinus = true; + registryMC.get(HIST("electronMC/hMCeta"))->Fill(daughter.eta()); + registryMC.get(HIST("electronMC/hMCphi"))->Fill(daughter.phi()); + registryMC.get(HIST("electronMC/hMCy"))->Fill(daughter.y()); + registryMC.get(HIST("electronMC/hMCpt"))->Fill(daughter.pt()); + + electronFound = !electronFound; + partPt = static_cast(daughter.pt()); + // singleElectronGlobalIndex = daughter.globalIndex(); + // LOGF(info,"e pt %f",daughter.pt()); + if (std::abs(daughter.eta()) > 0.9) + partFromTauInEta = false; + } // end of electron check + // muon from tau + if (std::abs(daughter.pdgCode()) == 13) { + if (daughter.pdgCode() == 13) + flagMuPlusMuMinus = true; + muonFound = !muonFound; + partPt = static_cast(daughter.pt()); + // LOGF(info,"mu pt %f",daughter.pt()); + if (std::abs(daughter.eta()) > 0.9) + partFromTauInEta = false; + } // end of muon check + } // end of loop over daughters + if (pionCounter == 3) { + threePionsFound = true; + } // end of 3pi check + if (pionCounter == 1) { + singlePionFound = true; + singlePionIndex = tmpPionIndex; + auto mcPartTmp = mcParticle.daughters_as().begin() + singlePionIndex; + if (mcPartTmp.pdgCode() == -211) + flagPiPlusPiMinus = true; + partPt = static_cast(mcPartTmp.pt()); + // motherOfSinglePionIndex = mcParticle.index(); + if (std::abs(mcPartTmp.eta()) > 0.9) + partFromTauInEta = false; + // LOGF(info,"size %d; tau ID %d GID %d (pdg %d); pi ID %d LID %d GID %d, pt %f", mcParticle.size(), motherOfSinglePionIndex, mcParticle.globalIndex(), mcParticle.pdgCode(),singlePionIndex, mcPartTmp.index(), mcPartTmp.globalIndex(), mcPartTmp.pt()); + } // end of 1 pi check + } // end check tau has daughter + } // end of tau + } // end of loop over MC particles + // LOGF(info,"pt after %f",partPt); + + // tau related things + if (countTau == 2) { + registryMC.get(HIST("tauMC/hMCdeltaeta"))->Fill(etaTau[0] - etaTau[1]); + registryMC.get(HIST("tauMC/hMCdeltaphi"))->Fill(calculateDeltaPhi(phiTau[0], phiTau[1]) * 180. / o2::constants::math::PI); + } + + if (threePionsFound && electronFound) { + // LOGF(info,"3pi + e found"); + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(1., 1.); + if (tauInRapidity) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(2., 1.); + if (partFromTauInEta) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(3., 1.); + registryMC.get(HIST("efficiencyMCEl/hpTelec"))->Fill(partPt, 1.); + // flagE3pi = true; + } // particles from tau in eta + } // tau in y + } // el + 3pi + + if (threePionsFound && muonFound) { + // LOGF(info,"3pi + mu found"); + registryMC.get(HIST("efficiencyMCMu/effiMu"))->Fill(1., 1.); + if (tauInRapidity) { + registryMC.get(HIST("efficiencyMCMu/effiMu"))->Fill(2., 1.); + if (partFromTauInEta) { + registryMC.get(HIST("efficiencyMCMu/effiMu"))->Fill(3., 1.); + registryMC.get(HIST("efficiencyMCMu/hpTmuon"))->Fill(partPt, 1.); + // flagMu3pi = true; + } // particles from tau in eta + } // tau in y + } // el + 3pi + + if (singlePionFound && threePionsFound) { + // LOGF(info,"3pi + pi found in MC"); + // flagPi3pi = true; + registryMC.get(HIST("efficiencyMCPi/effiPi"))->Fill(1., 1.); + if (tauInRapidity) { + registryMC.get(HIST("efficiencyMCPi/effiPi"))->Fill(2., 1.); + if (partFromTauInEta) { + registryMC.get(HIST("efficiencyMCPi/effiPi"))->Fill(3., 1.); + registryMC.get(HIST("efficiencyMCPi/hpTpi"))->Fill(partPt, 1.); + } // particles from tau in eta + } // tau in y + } // el + 3pi + + registryMC.get(HIST("globalMC/hMCnPart"))->Fill(mcParticles.size(), 0); + registryMC.get(HIST("globalMC/hMCnPart"))->Fill(countGen, 1); + registryMC.get(HIST("globalMC/hMCnPart"))->Fill(countBoth, 2); + registryMC.get(HIST("globalMC/hMCnPart"))->Fill(countCharged, 3); + registryMC.get(HIST("globalMC/hMCnPart"))->Fill(countChargedFromTau, 4); + if (countChargedFromTau != 4) + return; + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(1., 1.); + if (electronFound && flagElPlusElMinus) + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(2., 1.); // e- + else if (electronFound && !flagElPlusElMinus) + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(3., 1.); // e+ + if (muonFound && flagMuPlusMuMinus) + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(4., 1.); // mu- + else if (muonFound && !flagMuPlusMuMinus) + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(5., 1.); // mu+ + if (singlePionFound && flagPiPlusPiMinus) + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(6., 1.); // pi- + else if (singlePionFound && !flagPiPlusPiMinus) + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(7., 1.); // pi+ + + if (!tauInRapidity) + return; + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(8., 1.); + if (!partFromTauInEta) + return; + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(9., 1.); + + } // end of processSimpleMCSG + + void processEfficiencyMCSG(aod::UDMcCollision const& mcCollision, + // soa::SmallGroups> const& collisions, + soa::SmallGroups> const& collisions, + LabeledTracks const& tracks, + aod::UDMcParticles const& mcParticles) + { + if (verbose) { + LOGF(info, " GeneratorIDtot %d", mcCollision.generatorsID()); + // below is not implemented in UDMcCollisions + // LOGF(info," GeneratorIDtot %d, GenID %d, subGenID %d, source %d", mcCollision.generatorsID(), mcCollision.getGeneratorId(), mcCollision.getSubGeneratorId(), mcCollision.getSourceId()); + } + registry1MC.get(HIST("globalMC/hGeneratorID"))->Fill(mcCollision.generatorsID()); + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(10., 1.); + if (!(generatorIDMC < 0)) { // do not check generatorsID process if generatorIDMC < 0 + if (mcCollision.generatorsID() != generatorIDMC) + return; } - // electron has TOF hit + int indexProngMC[4]; + int index1ProngMC = -1; + bool is1ProngElectronMC = false; + // bool is1ProngMuonMC = false; + // bool is1ProngPionMC = false; + bool is3prong3PiMC = false; + int motherIndex[4]; + + int count = 0; + + bool tauInRapidity = true; + bool partFromTauInEta = true; + + TLorentzVector tmp(0., 0., 0., 0.); + + for (const auto& mcParticle : mcParticles) { + if (mcParticle.isPhysicalPrimary()) { + if (mcParticle.pdgCode() != 22 && std::abs(mcParticle.pdgCode()) != 12 && std::abs(mcParticle.pdgCode()) != 14 && std::abs(mcParticle.pdgCode()) != 16 && mcParticle.pdgCode() != 130 && mcParticle.pdgCode() != 111) { + if (mcParticle.has_mothers()) { + auto const& mother = mcParticle.mothers_first_as(); + tmp.SetPxPyPzE(mother.px(), mother.py(), mother.pz(), mother.e()); + if (std::abs(mother.pdgCode()) == 15) { + if (std::abs(rapidity(mother.e(), mother.pz())) > 0.9) + // if (std::abs(tmp.Rapidity()) > 0.9) + tauInRapidity = false; + if (std::abs(eta(mcParticle.px(), mcParticle.py(), mcParticle.pz())) > 0.9) + // if (std::abs(tmp.Eta()) > 0.9) + partFromTauInEta = false; + + if (std::abs(mcParticle.pdgCode()) == 11) { + index1ProngMC = mcParticle.index(); + is1ProngElectronMC = true; + } else if (std::abs(mcParticle.pdgCode()) == 13) { + index1ProngMC = mcParticle.index(); + // is1ProngMuonMC = true; + } - // only 1 electron - if (counterTotal == 1) { - registry.get(HIST("global/hEventEff"))->Fill(19., 1.); + if (count < 4) { + indexProngMC[count] = mcParticle.index(); + motherIndex[count] = mother.globalIndex(); + } else { + indexProngMC[3] = mcParticle.index(); + motherIndex[3] = mother.globalIndex(); + } + count++; + if (collisions.size() > 0) { + registryMC.get(HIST("globalMCrec/hMCetaGenCol"))->Fill(eta(mcParticle.px(), mcParticle.py(), mcParticle.pz())); + registryMC.get(HIST("globalMCrec/hMCphiGenCol"))->Fill(phi(mcParticle.px(), mcParticle.py())); + registryMC.get(HIST("globalMCrec/hMCyGenCol"))->Fill(rapidity(mcParticle.e(), mcParticle.pz())); + registryMC.get(HIST("globalMCrec/hMCptGenCol"))->Fill(pt(mcParticle.px(), mcParticle.py())); + } + } // mother is tau + } // has mothers + } // charged particles + } // end if isPhysicalPrimary + + } // end loop over mcParticle + + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(11., 1.); + if (count != 4) + return; + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(12., 1.); + if (!tauInRapidity) + return; + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(13., 1.); + if (!partFromTauInEta) + return; + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(14., 1.); // just to confirm there is exactly the same selection + + if (index1ProngMC < 0) { // pion case + 3pi + // bool onlyPi = true; + // // int motherIndex[4]; + // for (int i = 0; i < 4; i++) { + // auto const& tmpMC = mcParticles.begin() + indexProngMC[i]; + // if (std::abs(tmpMC.pdgCode()) != 211) onlyPi = false; + // // // mother's check already done in a loop before + // // // auto const& mother = tmpMC.mothers_first_as(); + // // // motherIndex[i] = mother.globalIndex(); + // // motherIndex[i] = (tmpMC.mothers_first_as()).globalIndex(); + // } + int motherIndex1Pi = motherIndex[0]; + int motherIndexNew = -1; + int nDifferences = 0; + for (int i = 1; i < 4; i++) { + if (motherIndex1Pi != motherIndex[i]) { // the same mother index + nDifferences++; + motherIndexNew = i; + } + } + if (nDifferences == 3) + index1ProngMC = indexProngMC[0]; + else + index1ProngMC = indexProngMC[motherIndexNew]; + // is1ProngPionMC = true; + // if (!onlyPi) LOGF(info, "ERROR: should be 4 pions, but they are not!"); + } // end of special check for pi + 3pi + + int index3ProngMC[3]; + if (index1ProngMC > 0) { // electron or muon case + 3pi + int index3pi = 0; for (int i = 0; i < 4; i++) { - registry.get(HIST("control/cut1/hDcaZ"))->Fill(dcaZ[i]); - registry.get(HIST("control/cut1/hDcaXY"))->Fill(dcaXY[i]); - registry.get(HIST("control/cut1/hChi2TPC"))->Fill(chi2TPC[i]); - registry.get(HIST("control/cut1/hChi2ITS"))->Fill(chi2ITS[i]); - - if (flagTotal[i]) { - FillControlHistos<1>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut1/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("pidTPC/hpvsdedxElHipCut1"))->Fill(tmpMomentum[i], tmpDedx[i]); + if (index1ProngMC == indexProngMC[i]) + continue; + index3ProngMC[index3pi] = indexProngMC[i]; + index3pi++; + } + } + + // create 1 prong and 3 prong MC references + auto const& tmp1ProngMC = mcParticles.begin() + index1ProngMC; + // LOGF(info,"tmp1ProngMC ID %d, GID %d", tmp1ProngMC.index(), tmp1ProngMC.globalIndex()); + + auto const& tmpPion1MC = mcParticles.begin() + index3ProngMC[0]; + auto const& tmpPion2MC = mcParticles.begin() + index3ProngMC[1]; + auto const& tmpPion3MC = mcParticles.begin() + index3ProngMC[2]; + + if (std::abs(tmpPion1MC.pdgCode()) == 211 && std::abs(tmpPion2MC.pdgCode()) == 211 && std::abs(tmpPion3MC.pdgCode()) == 211) + is3prong3PiMC = true; + + // + // here it comes e+3pi topology in MC + // + if (!(is1ProngElectronMC && is3prong3PiMC)) + return; + + // LOGF(info,"ID3pi1 %d, GID3pi1 %d",tmpPion1MC.index(),tmpPion1MC.globalIndex()); + // LOGF(info,"ID3pi2 %d, GID3pi2 %d",tmpPion2MC.index(),tmpPion2MC.globalIndex()); + // LOGF(info,"ID3pi3 %d, GID3pi3 %d",tmpPion3MC.index(),tmpPion3MC.globalIndex()); + + auto deltaAlpha1 = deltaAlpha(tmp1ProngMC, tmpPion1MC); + auto deltaAlpha2 = deltaAlpha(tmp1ProngMC, tmpPion2MC); + auto deltaAlpha3 = deltaAlpha(tmp1ProngMC, tmpPion3MC); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaAlphaEpi"))->Fill(deltaAlpha1); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaAlphaEpi"))->Fill(deltaAlpha2); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaAlphaEpi"))->Fill(deltaAlpha3); + // + registryMC.get(HIST("efficiencyMCEl/hMCdeltaPhiEpi"))->Fill(calculateDeltaPhi(phi(tmp1ProngMC.px(), tmp1ProngMC.py()), phi(tmpPion1MC.px(), tmpPion1MC.py()))); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaPhiEpi"))->Fill(calculateDeltaPhi(phi(tmp1ProngMC.px(), tmp1ProngMC.py()), phi(tmpPion2MC.px(), tmpPion2MC.py()))); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaPhiEpi"))->Fill(calculateDeltaPhi(phi(tmp1ProngMC.px(), tmp1ProngMC.py()), phi(tmpPion3MC.px(), tmpPion3MC.py()))); + // + registryMC.get(HIST("efficiencyMCEl/hMCdeltaPhiPipi"))->Fill(calculateDeltaPhi(phi(tmpPion1MC.px(), tmpPion1MC.py()), phi(tmpPion2MC.px(), tmpPion2MC.py()))); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaPhiPipi"))->Fill(calculateDeltaPhi(phi(tmpPion1MC.px(), tmpPion1MC.py()), phi(tmpPion3MC.px(), tmpPion3MC.py()))); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaPhiPipi"))->Fill(calculateDeltaPhi(phi(tmpPion2MC.px(), tmpPion2MC.py()), phi(tmpPion3MC.px(), tmpPion3MC.py()))); + + // + auto deltaAlphaPi1 = deltaAlpha(tmpPion1MC, tmpPion2MC); + auto deltaAlphaPi2 = deltaAlpha(tmpPion1MC, tmpPion3MC); + auto deltaAlphaPi3 = deltaAlpha(tmpPion2MC, tmpPion3MC); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaAlphaPiPi"))->Fill(deltaAlphaPi1); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaAlphaPiPi"))->Fill(deltaAlphaPi2); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaAlphaPiPi"))->Fill(deltaAlphaPi3); + // + float energyInCone = 0; + float angleLimit = 0.5; + if (deltaAlpha1 < angleLimit) { + energyInCone += pt(tmpPion1MC.px(), tmpPion1MC.py()); + } + if (deltaAlpha2 < angleLimit) { + energyInCone += pt(tmpPion2MC.px(), tmpPion2MC.py()); + } + if (deltaAlpha3 < angleLimit) { + energyInCone += pt(tmpPion3MC.px(), tmpPion3MC.py()); + } + registryMC.get(HIST("efficiencyMCEl/hMCvirtCal"))->Fill(energyInCone); + // + registryMC.get(HIST("efficiencyMCEl/hMCScalar"))->Fill(scalarAsymMC(tmp1ProngMC, tmpPion1MC)); + registryMC.get(HIST("efficiencyMCEl/hMCScalar"))->Fill(scalarAsymMC(tmp1ProngMC, tmpPion2MC)); + registryMC.get(HIST("efficiencyMCEl/hMCScalar"))->Fill(scalarAsymMC(tmp1ProngMC, tmpPion3MC)); + // + registryMC.get(HIST("efficiencyMCEl/hMCVector"))->Fill(vectorAsym(tmp1ProngMC, tmpPion1MC)); + registryMC.get(HIST("efficiencyMCEl/hMCVector"))->Fill(vectorAsym(tmp1ProngMC, tmpPion2MC)); + registryMC.get(HIST("efficiencyMCEl/hMCVector"))->Fill(vectorAsym(tmp1ProngMC, tmpPion3MC)); + + // add eta phi + registryMC.get(HIST("efficiencyMCEl/hMCptEl"))->Fill(pt(tmp1ProngMC.px(), tmp1ProngMC.py())); + + float px3pi = tmpPion1MC.px() + tmpPion2MC.px() + tmpPion3MC.px(); + float py3pi = tmpPion1MC.py() + tmpPion2MC.py() + tmpPion3MC.py(); + float pz3pi = tmpPion1MC.pz() + tmpPion2MC.pz() + tmpPion3MC.pz(); + float en3pi = tmpPion1MC.e() + tmpPion2MC.e() + tmpPion3MC.e(); + + registryMC.get(HIST("efficiencyMCEl/hMCpt4trk"))->Fill(pt(tmp1ProngMC.px() + px3pi, tmp1ProngMC.py() + py3pi)); + registryMC.get(HIST("efficiencyMCEl/hMCinvmass4pi"))->Fill(invariantMass(tmp1ProngMC.e() + en3pi, tmp1ProngMC.px() + px3pi, tmp1ProngMC.py() + py3pi, tmp1ProngMC.pz() + pz3pi)); + registryMC.get(HIST("efficiencyMCEl/hMCinvmass3pi"))->Fill(invariantMass(en3pi, px3pi, py3pi, pz3pi)); + registryMC.get(HIST("efficiencyMCEl/hMCdeltaphi13"))->Fill(calculateDeltaPhi(phi(tmp1ProngMC.px(), tmp1ProngMC.py()), phi(px3pi, py3pi))); + + // reconstructed event + if (collisions.size() < 1) + return; + registryMC.get(HIST("globalMC/hMCefficiency"))->Fill(15., 1.); // there is at least 1 collision associated to MC collision + if (is1ProngElectronMC && is3prong3PiMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(4., 1.); + if (collisions.size() == 1) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(5., 1.); + + // event selection flags + bool zVertexFlag = false; + bool allInEtaAcceptance = false; + int nTrkInEtaRange = 0; + // bool allAbovePtThreshold = false; + int nTrkAbovePtThreshold = 0; + + int nPVTracks = 0; + int nGhostTracks = 0; + int nGhostPVTracks = 0; + + // int nGenTracks=0; + // int nGenPrimTracks=0; + // int nGenPVTracks=0; + // int nGenPrimPVTracks=0; + + int trackId[4]; // local index in collision + int trackCharge = 0; + bool trackToMCmatch[4]; // match between data track and corresponding MC particle; true = match, false = track not found in this collision + int trackMCId[4]; // when MC found, the global index from MC Particle is stored here + + int matchedElIndexToData = -1; + int gapSide = -2; + int truegapSide = -2; + float reconstructedPtElMatchedToMC = -1; + + bool flagGapSideSGP = false; + bool flagDoubleGap = false; + bool tracksMatchedToMC = false; + + // FIT checks + auto bitMin = 16 - mFITvetoWindow; // default is +- 1 bc (1 bit) + auto bitMax = 16 + mFITvetoWindow; + bool flagFITveto = false; + + for (const auto& collision : collisions) { + // FIT flag set + flagFITveto = false; + for (auto bit = bitMin; bit <= bitMax; bit++) { + if (TESTBIT(collision.bbFT0Apf(), bit)) + flagFITveto = true; + if (TESTBIT(collision.bbFT0Cpf(), bit)) + flagFITveto = true; + if (useFV0ForVeto && TESTBIT(collision.bbFV0Apf(), bit)) + flagFITveto = true; + if (useFDDAForVeto && TESTBIT(collision.bbFDDApf(), bit)) + flagFITveto = true; + if (useFDDCForVeto && TESTBIT(collision.bbFDDCpf(), bit)) + flagFITveto = true; + } // end of loop over FIT bits + + registry1MC.get(HIST("globalMCrec/hRecFlag"))->Fill(collision.flags()); // reconstruction with upc settings flag + registry1MC.get(HIST("globalMCrec/hOccupancyInTime"))->Fill(collision.occupancyInTime()); + + matchedElIndexToData = -1; + reconstructedPtElMatchedToMC = -1; + gapSide = collision.gapSide(); + truegapSide = sgSelector.trueGap(collision, cutFV0, cutFT0A, cutFT0C, cutZDC); + registryMC.fill(HIST("globalMCrec/GapSide"), gapSide); + registryMC.fill(HIST("globalMCrec/GapSideTrue"), truegapSide); + // if (gapSide < 0 || gapSide > 2) continue; //old way + if (gapSide >= 0 && gapSide <= 2) + flagGapSideSGP = true; + + gapSide = truegapSide; + // if (flagGapSideSGP) registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(6., 1./collisions.size()); + // if (flagGapSideSGP && tracksMatchedToMC) registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(7., 1./collisions.size()); // with true information + + // if (gapSide != mGapSide) continue; //old way + if (gapSide == mGapSide) + flagDoubleGap = true; + // if (flagDoubleGap) registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(8., 1./collisions.size()); + // if (flagDoubleGap && tracksMatchedToMC) registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(9., 1./collisions.size()); // with true information + registryMC.get(HIST("globalMCrec/hVertexXY"))->Fill(collision.posX(), collision.posY()); + registryMC.get(HIST("globalMCrec/hVertexZ"))->Fill(collision.posZ()); + + zVertexFlag = true; + if (std::abs(collision.posZ()) >= zvertexcut) + zVertexFlag = false; + + auto groupedTracks = tracks.sliceBy(perCollision, collision.globalIndex()); + registryMC.get(HIST("globalMCrec/hNTracks"))->Fill(groupedTracks.size()); + nPVTracks = 0; + nGhostTracks = 0; + nGhostPVTracks = 0; + + for (int i = 0; i < 4; i++) { + trackToMCmatch[i] = false; + trackMCId[i] = -1; + } + + // nGenTracks=0; + // nGenPrimTracks=0; + // nGenPVTracks=0; + // nGenPrimPVTracks=0; + + trackCharge = 0; + allInEtaAcceptance = false; + nTrkInEtaRange = 0; + // allAbovePtThreshold = false; + nTrkAbovePtThreshold = 0; + + // + // first loop over grouped Tracks + // + for (auto const& track : groupedTracks) { + // ghost track + if (!track.has_udMcParticle()) { + nGhostTracks++; + } + + if (track.isPVContributor()) { + if (nPVTracks < 4) { + trackId[nPVTracks] = track.index(); + } + nPVTracks++; + trackCharge += track.sign(); + // if (std::abs(eta(track.px(),track.py(),track.pz())) >= trkEtacut) allInEtaAcceptance = false; + if (std::abs(eta(track.px(), track.py(), track.pz())) < trkEtacut) + nTrkInEtaRange++; + if (track.pt() > 0.1) + nTrkAbovePtThreshold++; + // // if (track.tpcNSigmaEl() > -2 && track.tpcNSigmaEl() < 3) atLeast1ElectronPID = true; + // ptmp.SetXYZM(track.px(), track.py(), track.pz(), mpion); + // // hPt->Fill(p.Pt()); + // ptot += ptmp; + + if (track.has_udMcParticle()) { + // LOGF(info, "track ID %d match to MC (1p,3p0,3p1,3p2) (%d, %d, %d, %d)", track.udMcParticle().globalIndex(), tmp1ProngMC.globalIndex(), tmpPion1MC.globalIndex(), tmpPion2MC.globalIndex(), tmpPion3MC.globalIndex()); + if (nPVTracks < 5) { + trackMCId[nPVTracks - 1] = track.udMcParticle().globalIndex(); + if (trackMCId[nPVTracks - 1] == tmp1ProngMC.globalIndex()) { + matchedElIndexToData = nPVTracks - 1; + reconstructedPtElMatchedToMC = track.pt(); + } + + if (trackMCId[nPVTracks - 1] == tmp1ProngMC.globalIndex() || + trackMCId[nPVTracks - 1] == tmpPion1MC.globalIndex() || + trackMCId[nPVTracks - 1] == tmpPion2MC.globalIndex() || + trackMCId[nPVTracks - 1] == tmpPion3MC.globalIndex()) + trackToMCmatch[nPVTracks - 1] = true; // flag, we have a match data <=> MC + } + + } else { // end of case where track has MC Particle associated + // ghost PV track + nGhostPVTracks++; + } + } else { // PV contributor + if (track.has_udMcParticle()) { + // LOGF(info,"non-PV trk: pid %4.0d (%f, %f, %f) gid %d pt %f",track.udMcParticle().pdgCode(), track.udMcParticle().vx(),track.udMcParticle().vy(),track.udMcParticle().vz(),track.udMcParticle().globalIndex(),track.pt()); + if (verbose) { + LOGF(info, "non-PV trk: pid %4.0d gid %d", track.udMcParticle().pdgCode(), track.udMcParticle().globalIndex()); + } + } + } + // if (track.isGlobalTrack()) nGlobalTracks++; + } // end of loop over tracks + registryMC.get(HIST("globalMCrec/hNTracksPV"))->Fill(nPVTracks); + registryMC.get(HIST("globalMCrec/hNGhostTracks"))->Fill(nGhostTracks); + registryMC.get(HIST("globalMCrec/hNGhostTracksPV"))->Fill(nGhostPVTracks); + registryMC.get(HIST("globalMCrec/hQtot"))->Fill(trackCharge); + + // check whether tracks match to MC particles + if (trackToMCmatch[0] && trackToMCmatch[1] && trackToMCmatch[2] && trackToMCmatch[3]) + tracksMatchedToMC = true; + registryMC.get(HIST("globalMCrec/hTrackToMCMatch"))->Fill(tracksMatchedToMC); + + if (nTrkInEtaRange >= 4) + allInEtaAcceptance = true; + if (nTrkAbovePtThreshold >= 4) + nTrkAbovePtThreshold = true; + + // zdc information + float energyZNA = collision.energyCommonZNA(); + float energyZNC = collision.energyCommonZNC(); + // if (energyZNA < 0) registry.get(HIST("global/hZNACenergyTest"))->Fill(energyZNA); + // if (energyZNC < 0) registry.get(HIST("global/hZNACenergyTest"))->Fill(energyZNC); + if (energyZNA < 0) + energyZNA = -1.; + if (energyZNC < 0) + energyZNC = -1.; + registryMC.get(HIST("globalMCrec/hZNACenergy"))->Fill(energyZNA, energyZNC); + registryMC.get(HIST("globalMCrec/hZNACtime"))->Fill(collision.timeZNA(), collision.timeZNC()); + + // + // here analysis event selection comes and track eta phi, pt comparison after that + // + // SG producer: flagGapSideSGP ok + // Double gap: flagDoubleGap ok + // npvtracks: nPVTracks ok + // Zvertex: zVertexFlag + // tracks in eta: allInEtaAcceptance + // tracks charge : trackCharge + // MC to data matching: tracksMatchedToMC + + // it is after reconstruction + if (tracksMatchedToMC) { + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec0"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } + + // skip events wrongly reconstructed by SG producernot + if (!flagGapSideSGP) { + if (verbose) { + LOGF(info, " Candidate rejected: DGproducer flag is %d", gapSide); + } + return; + } + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(6., 1. / collisions.size()); + if (tracksMatchedToMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(7., 1. / collisions.size()); // with true information + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec1"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } + + // skip not Double Gap events + if (!flagDoubleGap) { + if (verbose) { + LOGF(info, " Candidate rejected: not double gapevent, gap value is %d", gapSide); + } + return; + } + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(8., 1. / collisions.size()); + if (tracksMatchedToMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(9., 1. / collisions.size()); // with true information + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec2"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } + + // // skip events with too few/many tracks + if (nPVTracks != 4) { + if (verbose) { + LOGF(info, " Candidate rejected: Number of PV contributors is %d", nPVTracks); + } + return; + } + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(10., 1.); + if (tracksMatchedToMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(11., 1.); // with true information + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec3"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } + + // //four reconstructed track with MC track link + // auto const track1 = groupedTracks.begin()+trackId[0]; + // auto const track2 = groupedTracks.begin()+trackId[1]; + // auto const track3 = groupedTracks.begin()+trackId[2]; + // auto const track4 = groupedTracks.begin()+trackId[3]; + + // here comes histos of global1 but in MC + registryMC.get(HIST("global1MCrec/hTrackPVTotCharge"))->Fill(trackCharge); + registryMC.get(HIST("global1MCrec/hVertexZ"))->Fill(collision.posZ()); + registryMC.get(HIST("global1MCrec/hNTracks"))->Fill(groupedTracks.size()); + registryMC.get(HIST("global1MCrec/hNTracksPV"))->Fill(nPVTracks); + + TLorentzVector p, p1; + p.SetXYZM(0., 0., 0., 0.); + TVector3 v1(0, 0, 0); + TVector3 v2(0, 0, 0); + float scalarPtsum = 0; + bool flagVcalPV[4] = {false, false, false, false}; + float deltaphi = 0; + bool trkHasTof[4] = {false, false, false, false}; + int nPiHasTPC[4] = {0, 0, 0, 0}; + // + // second loop, only over PV tracks + // + for (int i = 0; i < 4; i++) { + auto const tmptrack = groupedTracks.begin() + trackId[i]; + // if (tmptrack.hasTOF()) + // trkHasTof[i] = true; + trkHasTof[i] = isGoodTOFTrackCheck(tmptrack); + v1.SetXYZ(tmptrack.px(), tmptrack.py(), tmptrack.pz()); + // second loop to calculate virtual calorimeter for (int j = 0; j < 4; j++) { if (i == j) continue; - registry.get(HIST("pidTPC3pi/hpvsdedxElHipCut1"))->Fill(tmpMomentum[j], tmpDedx[j]); + auto const tmptrack2 = groupedTracks.begin() + trackId[j]; + if (tmptrack2.hasTPC()) + nPiHasTPC[i]++; + v2.SetXYZ(tmptrack2.px(), tmptrack2.py(), tmptrack2.pz()); + deltaphi = v1.Angle(v2); + if (deltaphi < minAnglecut) { // default 0.05 + flagVcalPV[i] = true; + } + } // end of second loop + float tmpEtaData = eta(tmptrack.px(), tmptrack.py(), tmptrack.pz()); + float tmpPhiData = phi(tmptrack.px(), tmptrack.py()); + registryMC.get(HIST("global1MCrec/hTrackEtaPhiPV"))->Fill(tmpEtaData, tmpPhiData); + registryMC.get(HIST("global1MCrec/hTrackPtPV"))->Fill(tmptrack.pt()); + p1.SetXYZM(v1.X(), v1.Y(), v1.Z(), MassPiPlus); // in case of ghost + + if (trackMCId[i] >= 0) { + p1.SetXYZM(v1.X(), v1.Y(), v1.Z(), (std::abs(tmptrack.udMcParticle().pdgCode()) == 211 ? MassPiPlus : MassElectron)); + float tmpPt = pt(tmptrack.udMcParticle().px(), tmptrack.udMcParticle().py()); + float tmpEta = eta(tmptrack.udMcParticle().px(), tmptrack.udMcParticle().py(), tmptrack.udMcParticle().pz()); + float tmpPhi = phi(tmptrack.udMcParticle().px(), tmptrack.udMcParticle().py()); + registryMC.get(HIST("global1MCrec/hpTGenRecTracksPV"))->Fill(tmptrack.pt(), tmpPt); + registryMC.get(HIST("global1MCrec/hDeltapTGenRecVsRecpTTracksPV"))->Fill(tmptrack.pt() - tmpPt, tmptrack.pt()); + registryMC.get(HIST("global1MCrec/hEtaGenRecTracksPV"))->Fill(tmpEtaData, tmpEta); + registryMC.get(HIST("global1MCrec/hDeltaEtaGenRecVsRecpTTracksPV"))->Fill(tmpEtaData - tmpEta, tmptrack.pt()); + registryMC.get(HIST("global1MCrec/hPhiGenRecTracksPV"))->Fill(tmpPhiData, tmpPhi); + registryMC.get(HIST("global1MCrec/hDeltaPhiGenRecVsRecpTTracksPV"))->Fill(calculateDeltaPhi(tmpPhiData, tmpPhi), tmptrack.pt()); + } // MC infor exists + p += p1; + scalarPtsum += p1.Pt(); + } // end of short loop over tracks + + int nTofTracks = trkHasTof[0] + trkHasTof[1] + trkHasTof[2] + trkHasTof[3]; + + // if vz < 10 + if (!zVertexFlag) { // default = 10 + if (verbose) { + LOGF(info, " Candidate rejected: VertexZ is %f", collision.posZ()); } - registry.get(HIST("global/hFinalPtSpectrumEl"))->Fill(tmpPt[i]); - registry.get(HIST("control/cut1/hTPCnclsFindable"))->Fill(nclTPCfind[i]); - registry.get(HIST("control/cut1/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut1/h3pi1eMass"))->Fill(mass3pi1e[i]); + return; + } + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(12., 1.); + if (tracksMatchedToMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(13., 1.); // with true information + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec4"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } + + // if eta tracks <0.9 default + if (!allInEtaAcceptance) { + if (verbose) { + LOGF(info, " Candidate rejected: Ntrk inside |eta|<0.9 is %d", nTrkInEtaRange); + } + return; + } + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(14., 1.); + if (tracksMatchedToMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(15., 1.); // with true information + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec5"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } + + // if pt of tracks >100 MeV/c + if (!nTrkAbovePtThreshold) { if (verbose) { - LOGF(info, "cut1 trackTime %f, %f, %f, %f Res %f, %f, %f, %f", trkTime[0], trkTime[1], trkTime[2], trkTime[3], trkTimeRes[0], trkTimeRes[1], trkTimeRes[2], trkTimeRes[3]); + LOGF(info, " Candidate rejected: Ntrk with pT >100 MeV/c is %d", nTrkAbovePtThreshold); } + return; + } + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(16., 1.); + if (tracksMatchedToMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(17., 1.); // with true information + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec6"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } - // one electron with tof hit (cut33) - if (tmpHasTOF[i]) { - registry.get(HIST("global/hEventEff"))->Fill(20., 1.); - // registry.get(HIST("control/cut33/hDcaZ"))->Fill(dcaZ[i]); - // registry.get(HIST("control/cut33/hDcaXY"))->Fill(dcaXY[i]); - // registry.get(HIST("control/cut33/hChi2TPC"))->Fill(chi2TPC[i]); - // registry.get(HIST("control/cut33/hChi2ITS"))->Fill(chi2ITS[i]); - FillControlHistos<33>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut33/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("pidTPC/hpvsdedxElHipCut33"))->Fill(tmpMomentum[i], tmpDedx[i]); - registry.get(HIST("control/cut33/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut33/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut33/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut33/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut33/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - registry.get(HIST("control/cut33/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut33/h3pi1eMass"))->Fill(mass3pi1e[i]); - registry.get(HIST("control/cut33/hPtSpectrumEl"))->Fill(tmpPt[i]); + // skip events with net charge != 0 + if (!sameSign) { // opposite sign is signal + if (trackCharge != 0) { + if (verbose) { + LOGF(info, " Candidate rejected: Net charge is %d (dgcand %d), while should be 0", trackCharge, collision.netCharge()); + } + return; + } + } else { // same sign is background + if (trackCharge == 0) { if (verbose) { - LOGF(info, "cut33 trackTime %f, %f, %f, %f Res %f, %f, %f, %f", trkTime[0], trkTime[1], trkTime[2], trkTime[3], trkTimeRes[0], trkTimeRes[1], trkTimeRes[2], trkTimeRes[3]); + LOGF(info, " Candidate rejected: Net charge is %d (dgcand %d), while should be not 0", trackCharge, collision.netCharge()); } + return; + } + } + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(18., 1.); + if (tracksMatchedToMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(19., 1.); // with true information + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec7"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } + + // + // n TOF tracks cut 32 + // + if (nTofTracks < nTofTrkMinCut) { + if (verbose) { + LOGF(info, " Candidate rejected: nTOFtracks is %d", nTofTracks); + } + return; + } + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(56., 1.); // TOF tracks > Ntoftracks + if (tracksMatchedToMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(57., 1.); // electron identified, tracks match to MC Particles + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec8"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } - int otherTOFtracks = 0; - for (int j = 0; j < 4; j++) { - if (i == j) - continue; - if (tmpHasTOF[j]) - otherTOFtracks++; + // + // check FIT information + // + if (mFITvetoFlag) { + if (flagFITveto) { + if (verbose) { + LOGF(info, " Candidate rejected: FIT not empty"); } - // at least one pion with tof hit (cut34) - if (otherTOFtracks >= 1) { - registry.get(HIST("global/hEventEff"))->Fill(21., 1.); - // registry.get(HIST("control/cut34/hDcaZ"))->Fill(dcaZ[i]); - // registry.get(HIST("control/cut34/hDcaXY"))->Fill(dcaXY[i]); - // registry.get(HIST("control/cut34/hChi2TPC"))->Fill(chi2TPC[i]); - // registry.get(HIST("control/cut34/hChi2ITS"))->Fill(chi2ITS[i]); - FillControlHistos<34>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); - registry.get(HIST("control/cut34/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - registry.get(HIST("pidTPC/hpvsdedxElHipCut34"))->Fill(tmpMomentum[i], tmpDedx[i]); - registry.get(HIST("control/cut34/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut34/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut34/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut34/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut34/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - registry.get(HIST("control/cut34/hsigma3Pi"))->Fill(nSigma3Pi[i]); - registry.get(HIST("control/cut34/h3pi1eMass"))->Fill(mass3pi1e[i]); - registry.get(HIST("control/cut34/hPtSpectrumEl"))->Fill(tmpPt[i]); - if (verbose) { - LOGF(info, "cut34 trackTime %f, %f, %f, %f Res %f, %f, %f, %f", trkTime[0], trkTime[1], trkTime[2], trkTime[3], trkTimeRes[0], trkTimeRes[1], trkTimeRes[2], trkTimeRes[3]); - } - } // end of at least one pion with tof hit (cut34) + return; + } + } // end of check emptiness around given BC in FIT detectors + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(53., 1.); // electron identified + if (tracksMatchedToMC) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(54., 1.); // electron identified, tracks match to MC Particles + registryMC.get(HIST("globalMCrec/hPtSpectrumElRec9"))->Fill(reconstructedPtElMatchedToMC); // pt El confirmed with true information + } + + // + // here PID from TPC starts to be + // + // temporary control variables per event with combinatorics + float pttot = p.Pt(); + float mass4pi = p.Mag(); + int counterTmp = 0; + + float nSigmaEl[4]; + float nSigmaPi[4]; + float nSigma3Pi[4] = {0., 0., 0., 0.}; + float nSigma3PiNew[4] = {0., 0., 0., 0.}; + float nSigmaPr[4]; + float nSigmaKa[4]; + // float dcaZ[4]; + // float dcaXY[4]; + // float chi2TPC[4]; + // float chi2ITS[4]; + float chi2TOF[4] = {-1., -1., -1., -1.}; + // float nclTPCfind[4]; + float nclTPCcrossedRows[4]; + // bool tmpHasTOF[4]; + // double trkTime[4]; + // float trkTimeRes[4]; + + float tmpMomentum[4]; + float tmpPt[4]; + float tmpDedx[4]; + float tmpTofNsigmaEl[4]; + + float deltaPhiTmp = 0; + float pi3invMass[4]; + float pi3pt[4]; + float pi3deltaPhi[4]; + float pi3assymav[4]; + float pi3vector[4]; + float pi3scalar[4]; + + // bool trkHasTof[4] = {false, false, false, false}; + bool trkHasTpc[4] = {false, false, false, false}; + + // float mass3pi1e[4]; + // double trkTimeTot = 0.; + // float trkTimeResTot = 10000.; + for (int i = 0; i < 4; i++) { + auto const tmptrack = groupedTracks.begin() + trackId[i]; + // if (tmptrack.hasTOF()) trkHasTof[i] = true; + v1.SetXYZ(tmptrack.px(), tmptrack.py(), tmptrack.pz()); + p1.SetXYZM(v1.X(), v1.Y(), v1.Z(), MassPiPlus); // in case of ghost + if (trackMCId[i] >= 0) { + p1.SetXYZM(v1.X(), v1.Y(), v1.Z(), (i == matchedElIndexToData ? MassElectron : MassPiPlus)); + } - } // end of one electron with tof hit (cut33) + nSigmaEl[counterTmp] = tmptrack.tpcNSigmaEl(); + nSigmaPi[counterTmp] = tmptrack.tpcNSigmaPi(); + nSigma3Pi[3] += (nSigmaPi[counterTmp] * nSigmaPi[counterTmp]); + if (tmptrack.hasTPC()) + nSigma3PiNew[3] += (nSigmaPi[counterTmp] * nSigmaPi[counterTmp]); + if (whichPIDCut == 1) { // TPC only + nSigmaPr[counterTmp] = tmptrack.tpcNSigmaPr(); + nSigmaKa[counterTmp] = tmptrack.tpcNSigmaKa(); + } else if (whichPIDCut == 2) { // TPC + TOF sigma + nSigmaPr[counterTmp] = std::sqrt(tmptrack.tofNSigmaPr() * tmptrack.tofNSigmaPr() + tmptrack.tpcNSigmaPr() * tmptrack.tpcNSigmaPr()); + nSigmaKa[counterTmp] = std::sqrt(tmptrack.tofNSigmaKa() * tmptrack.tofNSigmaKa() + tmptrack.tpcNSigmaKa() * tmptrack.tpcNSigmaKa()); + } else if (whichPIDCut == 3) { // TPC + TOF hardcoded pt + nSigmaPr[counterTmp] = (tmptrack.pt() < 1.5 ? tmptrack.tofNSigmaPr() : tmptrack.tpcNSigmaPr()); + nSigmaKa[counterTmp] = (tmptrack.pt() < 1.3 ? tmptrack.tofNSigmaKa() : tmptrack.tpcNSigmaKa()); + } else { + nSigmaPr[counterTmp] = tmptrack.tpcNSigmaPr(); + nSigmaKa[counterTmp] = tmptrack.tpcNSigmaKa(); + } + + // dcaZ[counterTmp] = tmptrack.dcaZ(); + // dcaXY[counterTmp] = tmptrack.dcaXY(); + // chi2TPC[counterTmp] = tmptrack.tpcChi2NCl(); + // chi2ITS[counterTmp] = tmptrack.itsChi2NCl(); + if (tmptrack.hasTOF()) + chi2TOF[counterTmp] = tmptrack.tofChi2(); + // nclTPCfind[counterTmp] = tmptrack.tpcNClsFindable(); + nclTPCcrossedRows[counterTmp] = tmptrack.tpcNClsCrossedRows(); + + // tmpHasTOF[counterTmp] = tmptrack.hasTOF(); + trkHasTpc[counterTmp] = tmptrack.hasTPC(); + // trkTime[counterTmp] = tmptrack.trackTime(); + // trkTimeRes[counterTmp] = tmptrack.trackTimeRes(); + + tmpMomentum[counterTmp] = p1.P(); + tmpPt[counterTmp] = p1.Pt(); + tmpDedx[counterTmp] = tmptrack.tpcSignal(); + tmpTofNsigmaEl[counterTmp] = tmptrack.tofNSigmaEl(); + + deltaPhiTmp = calculateDeltaPhi(p - p1, p1); + pi3invMass[counterTmp] = (p - p1).Mag(); + pi3pt[counterTmp] = (p - p1).Pt(); + pi3deltaPhi[counterTmp] = deltaPhiTmp; + pi3assymav[counterTmp] = (p1.Pt() - (scalarPtsum - p1.Pt()) / 3.) / (p1.Pt() + (scalarPtsum - p1.Pt()) / 3.); + pi3vector[counterTmp] = p.Pt() / (p - p1 - p1).Pt(); + pi3scalar[counterTmp] = ((p - p1).Pt() - p1.Pt()) / ((p - p1).Pt() + p1.Pt()); + + counterTmp++; + } // end of second loop over PVtracks + + // fill the histograms with true information + for (int i = 0; i < 4; i++) { + // nsigma3Pi calculation + nSigma3Pi[i] = nSigma3Pi[3] - (nSigmaPi[i] * nSigmaPi[i]); + nSigma3Pi[i] = std::sqrt(nSigma3Pi[i]); + // nsigma3PiNew calculation + if (trkHasTpc[i]) { + nSigma3PiNew[i] = nSigma3PiNew[3] - (nSigmaPi[i] * nSigmaPi[i]); + } + nSigma3PiNew[i] = std::sqrt(nSigma3PiNew[i]); + + if (i == matchedElIndexToData) { + fillControlHistosMCtrue<0>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut0/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut0"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCtrue/cut0/hsigma3Pi"))->Fill(nSigma3Pi[i]); + if (nPiHasTPC[i] == 3) + registry1MC.get(HIST("controlMCtrue/cut0/hsigma3PiNew"))->Fill(nSigma3PiNew[i]); + if (nPiHasTPC[i] == 2) + registry1MC.get(HIST("controlMCtrue/cut0/hsigma2PiNew"))->Fill(nSigma3PiNew[i]); + if (nPiHasTPC[i] == 1) + registry1MC.get(HIST("controlMCtrue/cut0/hsigma1PiNew"))->Fill(nSigma3PiNew[i]); + + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut0"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + // registryMC.get(HIST("control/cut0/h3pi1eMass"))->Fill(mass3pi1e[i]); + } else { // only for 1prong = electron true + fillControlHistosMCcomb<0>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut0"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut0/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over PV tracks' informations + // global variables + registryMC.get(HIST("controlMCtrue/cut0/h3pi1eMass"))->Fill(mass4pi); // 3pi + 1e mass + registryMC.get(HIST("controlMCtrue/cut0/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut0/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut0/h4trkMassVsPt"))->Fill(mass4pi, pttot); + // registryMC.get(HIST("controlMCtrue/cut0/hNtofTrk"))->Fill(nTofTrk); + registryMC.get(HIST("controlMCtrue/cut0/hZNACenergy"))->Fill(energyZNA, energyZNC); + + // remove combinatorics + // bool flagTotal[4] = {false, false, false, false}; + bool flagIM[4] = {false, false, false, false}; + bool flagDP[4] = {false, false, false, false}; + bool flagEl[4] = {false, false, false, false}; + bool flagPi[4] = {false, false, false, false}; + bool flagPr[4] = {false, false, false, false}; + bool flagKa[4] = {false, false, false, false}; + bool flagCR[4] = {false, false, false, false}; + bool flagS3pi[4] = {false, false, false, false}; + + for (int i = 0; i < 4; i++) { + if (pi3invMass[i] < invMass3piMaxcut) { // default should be 1.8 + if (invMass3piSignalRegion) { + flagIM[i] = true; + } else { + flagIM[i] = false; + } + } else { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut2"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (pi3deltaPhi[i] > deltaPhiMincut) { // default should be 1.5 + flagDP[i] = true; + } else { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut3"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (minNsigmaElcut < nSigmaEl[i] && nSigmaEl[i] < maxNsigmaElcut) { // default (-2,3) + flagEl[i] = true; + } else { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut4"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (std::abs(nSigmaPi[i]) > maxNsigmaPiVetocut) { // default is 4 + flagPi[i] = true; + } else { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut5"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + // if (tmpPt[i] > minPtEtrkcut) { // 0.25 + // flagPt[i] = true; + // } else { + // registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut6"))->Fill(tmpMomentum[i], tmpDedx[i]); + // } + + if (flagVcalPV[i]) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut7"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (pttot < 0.15) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut8"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (std::abs(nSigmaPr[i]) > maxNsigmaPrVetocut) { // default is 3 + flagPr[i] = true; + } else { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut9"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (std::abs(nSigmaKa[i]) > maxNsigmaKaVetocut) { // default is 3 + flagKa[i] = true; + } else { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut10"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (nclTPCcrossedRows[i] > nTPCcrossedRowsMinCut) { // default is 50 + flagCR[i] = true; + } else { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut11"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (nSigma3Pi[i] < nSigma3piMaxCut) { // default is 5 + flagS3pi[i] = true; + } else { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut12"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + // flagTotal[i] = flagEl[i] && flagPi[i] && flagPt[i] && !flagVcalPV[i] && flagPr[i] && flagKa[i] && flagIM[i] && flagDP[i] && flagCR[i] && flagS3pi[i]; + } // end of loop over 4 tracks + + int counterEl = flagEl[0] + flagEl[1] + flagEl[2] + flagEl[3]; + + // + // draw PID and control histograms + // + + // + // Nelectrons in TPC PID nsigma > 0, cut20 + // + if (counterEl > 0) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(20., 1.); // at least 1 electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(21., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(22., 1.); // electron identified, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut20/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut20/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut20/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut20/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut20/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (flagEl[i] && tracksMatchedToMC && (i == matchedElIndexToData)) { // only for 1prong = electron true + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut20"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<20>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut20/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut20/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut20"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + // registry1MC.get(HIST("controlMCtrue/cut20/hTofChi2El"))->Fill(chi2TOF[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<20>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut20"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut20/hsigma3Pi"))->Fill(nSigma3Pi[i]); + // registry1MC.get(HIST("controlMCcomb/cut20/hTofChi2El"))->Fill(chi2TOF[i]); + } + } // end of loop over 4 PV tracks + // end of electron found cut20 + } else { // no electron + if (verbose) { + LOGF(debug, " Candidate rejected: no electron PID among 4 tracks"); + } + return; + } // end of Nelectrons check + + // + // electron has TOF hit + // + if (flagEl[0] * trkHasTof[0] + + flagEl[1] * trkHasTof[1] + + flagEl[2] * trkHasTof[2] + + flagEl[3] * trkHasTof[3] > + 0) { // electron has tof hit cut 33 + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(59., 1.); // electron identified + TOF hit + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(60., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && + trkHasTof[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(61., 1.); // El PID +TOF, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut33/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut33/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut33/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut33/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut33/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && + trkHasTof[i] && (i == matchedElIndexToData)) { // only for 1prong = electron true + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut33"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<33>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut33/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut33/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut33"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<33>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut33"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut33/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: electron has no tof hit "); + } + return; + } // end of electron has tof hit cut 33 + + // + // electron survived pi veto, cut21 + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] > + 0) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(23., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(24., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && + trkHasTof[matchedElIndexToData] && flagPi[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(25., 1.); // pion veto, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut21/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut21/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut21/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut21/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut21/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && trkHasTof[i] && flagPi[i] && (i == matchedElIndexToData)) { // only for 1prong = electron true + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut21"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<21>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut21/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut21/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut21"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<21>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut21"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut21/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by pi PID"); + } + return; + } // end of pi veto, cut21 + + // + // additional proton veto on electron, cut24 + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] > + 0) { // proton veto, cut24 + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(26., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(27., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && trkHasTof[matchedElIndexToData] && flagPi[matchedElIndexToData] && flagPr[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(28., 1.); // proton veto, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut24/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut24/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut24/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut24/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut24/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && flagEl[i] && flagPi[i] && flagPr[i] && (i == matchedElIndexToData)) { // only for 1prong = electron true + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut24"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<24>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut24/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut24/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut24"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<24>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut24"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut24/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by proton PID"); + } + return; + } // end of proton veto, cut24 + + // + // additional kaon veto on electron, cut25 + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] > + 0) { // kaon veto, cut25 + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(29., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(30., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && + trkHasTof[matchedElIndexToData] && flagPi[matchedElIndexToData] && flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(31., 1.); // kaon veto, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut25/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut25/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut25/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut25/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut25/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut25"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<25>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut25/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut25/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut25"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<25>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut25"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut25/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by K PID"); + } + return; + } // end of proton veto, cut25 + + // + // crossd rows in TPC + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] > + 0) { // Nc-rTPC cut, cut28 + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(32., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(33., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && trkHasTof[matchedElIndexToData] && + flagEl[matchedElIndexToData] && flagPi[matchedElIndexToData] && flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData] && flagCR[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(34., 1.); // CR, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut28/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut28/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut28/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut28/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut28/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut28"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<28>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut28/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut28/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut28"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<28>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut28"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut28/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by CR in TPC"); + } + return; + } // end of TPC crossed rows for electron cut, cut28 + + // + // virtual calorimeter for electron + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] * !flagVcalPV[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] * !flagVcalPV[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] * !flagVcalPV[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] * !flagVcalPV[3] > + 0) { // vcal veto on electron, cut22 + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(35., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(36., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && trkHasTof[matchedElIndexToData] && flagPi[matchedElIndexToData] && + flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData] && flagCR[matchedElIndexToData] && + !flagVcalPV[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(37., 1.); // kaon veto, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut22/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut22/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut22/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut22/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut22/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut22"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<22>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut22/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut22/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut22"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<22>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut22"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut22/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by Vcal"); + } + return; + } // end of vcal cut on electron, cut22 + + // + // nsigma 3pi cut, cut29 + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] * !flagVcalPV[0] * flagS3pi[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] * !flagVcalPV[1] * flagS3pi[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] * !flagVcalPV[2] * flagS3pi[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] * !flagVcalPV[3] * flagS3pi[3] > + 0) { // nsigma 3pi cut, cut29 + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(41., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(42., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && trkHasTof[matchedElIndexToData] && flagPi[matchedElIndexToData] && + flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData] && flagCR[matchedElIndexToData] && + !flagVcalPV[matchedElIndexToData] && flagS3pi[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(43., 1.); // kaon veto, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut29/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut29/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut29/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut29/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut29/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut29"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<29>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut29/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut29/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut29"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<29>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut29"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut29/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by 3piSigma"); + } + return; + } // end of sigma 3pi cut, cut29 + + // + // invariant mass of 3 pi <1.8 + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] * !flagVcalPV[0] * flagS3pi[0] * flagIM[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] * !flagVcalPV[1] * flagS3pi[1] * flagIM[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] * !flagVcalPV[2] * flagS3pi[2] * flagIM[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] * !flagVcalPV[3] * flagS3pi[3] * flagIM[3] > + 0) { // IM 3pi cut, cut26 + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(44., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(45., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && trkHasTof[matchedElIndexToData] && flagPi[matchedElIndexToData] && + flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData] && flagCR[matchedElIndexToData] && + !flagVcalPV[matchedElIndexToData] && flagS3pi[matchedElIndexToData] && + flagIM[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(46., 1.); // IM 3pi, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut26/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut26/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut26/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut26/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut26/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut26"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<26>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut26/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut26/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut26"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<26>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut26"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut26/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by IM"); + } + return; + } // end of IM 3pi cut, cut26 + + // + // at least one pion with tof hit (cut34) + // + int otherTOFtracks = 0; + for (int j = 0; j < 4; j++) { + if (j == matchedElIndexToData) + continue; + otherTOFtracks += trkHasTof[j]; } - } // end of loop over 4 tracks - registry.get(HIST("control/cut1/h4trkPtTot"))->Fill(pttot); - registry.get(HIST("control/cut1/h4piMass"))->Fill(mass4pi); - registry.get(HIST("control/cut1/h4trkMassVsPt"))->Fill(mass4pi, pttot); - registry.get(HIST("control/cut1/hNtofTrk"))->Fill(nTofTrk); - registry.get(HIST("control/cut1/hZNACenergy"))->Fill(ZNAenergy, ZNCenergy); - // special case invmass 4pi (2,2.3) - // if (mass4pi<2.3 && mass4pi>2) { - // for (int i = 0; i < 4; i++) { - // registry.get(HIST("control/cut1/cut1a/hDcaZ"))->Fill(dcaZ[i]); - // registry.get(HIST("control/cut1/cut1a/hDcaXY"))->Fill(dcaXY[i]); - // registry.get(HIST("control/cut1/cut1a/hChi2TPC"))->Fill(chi2TPC[i]); - // registry.get(HIST("control/cut1/cut1a/hChi2ITS"))->Fill(chi2ITS[i]); - // - // if (flagTotal[i]) { - // registry.get(HIST("control/cut1/cut1a/h3piMassComb"))->Fill(pi3invMass[i]); - // registry.get(HIST("control/cut1/cut1a/h3trkPtTot"))->Fill(pi3pt[i]); - // registry.get(HIST("control/cut1/cut1a/hDeltaPhi13topo"))->Fill(pi3deltaPhi[i]); - // registry.get(HIST("control/cut1/cut1a/h13AssymPt1ProngAver"))->Fill(pi3assymav[i]); - // registry.get(HIST("control/cut1/cut1a/h13Vector"))->Fill(pi3vector[i]); - // registry.get(HIST("control/cut1/cut1a/h13Scalar"))->Fill(pi3scalar[i]); - // registry.get(HIST("control/cut1/cut1a/h13EtaSum"))->Fill(pi3etasum[i]); - // registry.get(HIST("control/cut1/cut1a/hTPCnCrossedRows"))->Fill(nclTPCcrossedRows[i]); - // - // registry.get(HIST("control/cut1/cut1a/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); - // registry.get(HIST("control/cut1/cut1a/hTPCnclsFindable"))->Fill(nclTPCfind[i]); - // registry.get(HIST("control/cut1/cut1a/hsigma3Pi"))->Fill(nSigma3Pi[i]); - // } - // } - // registry.get(HIST("control/cut1/cut1a/h4trkPtTot"))->Fill(pttot); - // registry.get(HIST("control/cut1/cut1a/h4piMass"))->Fill(mass4pi); - // registry.get(HIST("control/cut1/cut1a/h4trkMassVsPt"))->Fill(mass4pi, pttot); - // registry.get(HIST("control/cut1/cut1a/hNtofTrk"))->Fill(nTofTrk); - // } // end of mass window for 4pi case - } else { // more than 1 electron candidate - if (verbose) { - LOGF(debug, " Candidate rejected: more than one electron candidate"); - } - } // end of 1electrons check - } // end of process - // check ntracks-4PVtracks - // check pt of remaining (ntracks-4PVtracks) tracks + if (otherTOFtracks >= 1) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(62., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(63., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && trkHasTof[matchedElIndexToData] && flagPi[matchedElIndexToData] && + flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData] && flagCR[matchedElIndexToData] && + !flagVcalPV[matchedElIndexToData] && flagS3pi[matchedElIndexToData] && + flagIM[matchedElIndexToData] && trkHasTof[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(64., 1.); // 1tof hit in 3pi, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut34/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut34/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut34/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut34/hZNACenergy"))->Fill(energyZNA, energyZNC); + registry1MC.get(HIST("globalMCrec/hRecFlag"))->Fill(5 + collision.flags()); // reconstruction with upc settings flag + // registryMC.get(HIST("controlMCtrue/cut34/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut34"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<34>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut34/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut34/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut34"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<34>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut34"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut34/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: none of 3pi has no tof hit "); + } + return; + } // end of at least one tof hit in 3pi, cut34 + + // + // skip events with pttot<0.15 + // + if (pttot >= ptTotcut) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(47., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(48., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && trkHasTof[matchedElIndexToData] && flagPi[matchedElIndexToData] && + flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData] && flagCR[matchedElIndexToData] && + !flagVcalPV[matchedElIndexToData] && flagS3pi[matchedElIndexToData] && + flagIM[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(49., 1.); // IM 3pi, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut30/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut30/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut30/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut30/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut30/hNtofTrk"))->Fill(nTofTrk); + registry1MC.get(HIST("globalMCrec/hRecFlag"))->Fill(5 + 2 + collision.flags()); // reconstruction with upc settings flag + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut30"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<30>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut30/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut30/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut30"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<30>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut30"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut30/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(info, " Candidate rejected: pt tot is %f", pttot); + } + return; + } // end of pttot cut, cut30 + + // + // delta phi cut, cut27 + // + if (flagEl[0] * trkHasTof[0] * flagPi[0] * flagPr[0] * flagKa[0] * flagCR[0] * !flagVcalPV[0] * flagS3pi[0] * flagIM[0] * flagDP[0] + + flagEl[1] * trkHasTof[1] * flagPi[1] * flagPr[1] * flagKa[1] * flagCR[1] * !flagVcalPV[1] * flagS3pi[1] * flagIM[1] * flagDP[1] + + flagEl[2] * trkHasTof[2] * flagPi[2] * flagPr[2] * flagKa[2] * flagCR[2] * !flagVcalPV[2] * flagS3pi[2] * flagIM[2] * flagDP[2] + + flagEl[3] * trkHasTof[3] * flagPi[3] * flagPr[3] * flagKa[3] * flagCR[3] * !flagVcalPV[3] * flagS3pi[3] * flagIM[3] * flagDP[3] > + 0) { // delta phi cut, cut27 + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(50., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(51., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && trkHasTof[matchedElIndexToData] && flagPi[matchedElIndexToData] && + flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData] && flagCR[matchedElIndexToData] && + !flagVcalPV[matchedElIndexToData] && flagS3pi[matchedElIndexToData] && + flagIM[matchedElIndexToData] && flagDP[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(52., 1.); // IM 3pi, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut27/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut27/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut27/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut27/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut27/hNtofTrk"))->Fill(nTofTrk); + registry1MC.get(HIST("globalMCrec/hRecFlag"))->Fill(5 + 2 + 2 + collision.flags()); // reconstruction with upc settings flag + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && trkHasTof[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && flagDP[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut27"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<27>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut27/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut27/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut27"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<27>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut27"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut27/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: all electrons vetoed by Dphi"); + } + return; + } // end of dphi 3pi-e cut, cut27 + + // + // ZDC cut Energy < 1 TeV on both sides + // + if (energyZNA < 1. && energyZNC < 1.) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(65., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(66., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && flagPi[matchedElIndexToData] && + flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData] && flagCR[matchedElIndexToData] && + !flagVcalPV[matchedElIndexToData] && flagS3pi[matchedElIndexToData] && + flagIM[matchedElIndexToData] && flagDP[matchedElIndexToData] && trkHasTof[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(67., 1.); // zdc cut, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut35/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut35/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut35/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut35/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut35/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && flagDP[i] && trkHasTof[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut35"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<35>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut35/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut35/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut35"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<35>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut35"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut35/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: zdc cut "); + } + return; + } // end of zdc, cut35 + + // + // occupancy cut 23 + // + if (collision.occupancyInTime() < 1000) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(65., 1.); // electron identified + if (tracksMatchedToMC) + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(66., 1.); // electron identified, tracks match to MC Particles + if (tracksMatchedToMC && flagEl[matchedElIndexToData] && flagPi[matchedElIndexToData] && + flagPr[matchedElIndexToData] && flagKa[matchedElIndexToData] && flagCR[matchedElIndexToData] && + !flagVcalPV[matchedElIndexToData] && flagS3pi[matchedElIndexToData] && + flagIM[matchedElIndexToData] && flagDP[matchedElIndexToData] && trkHasTof[matchedElIndexToData]) { + registryMC.get(HIST("efficiencyMCEl/effiEl"))->Fill(67., 1.); // zdc cut, tracks match to MC Particles, El is MC El true + + registryMC.get(HIST("controlMCtrue/cut23/h4piMass"))->Fill(mass4pi); + registryMC.get(HIST("controlMCtrue/cut23/h4trkPtTot"))->Fill(pttot); + registryMC.get(HIST("controlMCtrue/cut23/h4trkMassVsPt"))->Fill(mass4pi, pttot); + registryMC.get(HIST("controlMCtrue/cut23/hZNACenergy"))->Fill(energyZNA, energyZNC); + // registryMC.get(HIST("controlMCtrue/cut23/hNtofTrk"))->Fill(nTofTrk); + } + for (int i = 0; i < 4; i++) { + if (tracksMatchedToMC && flagEl[i] && flagPi[i] && flagPr[i] && flagKa[i] && flagCR[i] && !flagVcalPV[i] && flagS3pi[i] && flagIM[i] && flagDP[i] && trkHasTof[i] && (i == matchedElIndexToData)) { + registryMC.get(HIST("pidTPCMCEltrue/hpvsdedxElHipCut23"))->Fill(tmpMomentum[i], tmpDedx[i]); + fillControlHistosMCtrue<23>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("controlMCtrue/cut23/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); + registryMC.get(HIST("controlMCtrue/cut23/hsigma3Pi"))->Fill(nSigma3Pi[i]); + registry1MC.get(HIST("pidTOFMCEltrue/hpvsNsigmaElHipCut23"))->Fill(tmpMomentum[i], tmpTofNsigmaEl[i]); + } else if (tracksMatchedToMC && (i != matchedElIndexToData)) { + fillControlHistosMCcomb<23>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i], tmpPt[i], chi2TOF[i]); + registryMC.get(HIST("pidTPCMCPitrue/hpvsdedxElHipCut23"))->Fill(tmpMomentum[i], tmpDedx[i]); + registryMC.get(HIST("controlMCcomb/cut23/hsigma3Pi"))->Fill(nSigma3Pi[i]); + } + } // end of loop over 4 PV tracks + } else { + if (verbose) { + LOGF(debug, " Candidate rejected: occupancy cut "); + } + return; + } // end of occupancy cut23 + + } // end of loop over collisions + } // end of electron + 3pi + + } // end of processEfficiencyMCSG + + // skimming: only 4 tracks selection + void processDoSkim(UDCollisionFull2 const& dgcand, UDTracksFull const& dgtracks, PVTracks const& PVContributors) + { + registrySkim.get(HIST("skim/efficiency"))->Fill(0., 1.); + int gapSide = dgcand.gapSide(); + int truegapSide = sgSelector.trueGap(dgcand, cutFV0, cutFT0A, cutFT0C, cutZDC); + if (gapSide < 0 || gapSide > 2) + return; + registrySkim.get(HIST("skim/efficiency"))->Fill(1., 1.); + + gapSide = truegapSide; + if (gapSide != mGapSide) + return; + registrySkim.get(HIST("skim/efficiency"))->Fill(2., 1.); + + // zdc information + float energyZNA = dgcand.energyCommonZNA(); + float energyZNC = dgcand.energyCommonZNC(); + if (energyZNA < 0) + energyZNA = -1.; + if (energyZNC < 0) + energyZNC = -1.; + + int nTofTrk = 0; + int nEtaIn15 = 0; + int npT100 = 0; + // int qtot = 0; + int16_t qtot = 0; + TLorentzVector p; + for (const auto& trk : PVContributors) { + qtot += trk.sign(); + p.SetXYZM(trk.px(), trk.py(), trk.pz(), MassPiPlus); + if (std::abs(p.Eta()) < trkEtacut) + nEtaIn15++; // 0.9 is a default + if (trk.pt() > 0.1) + npT100++; + if (trk.hasTOF()) + nTofTrk++; + } // end of loop over PV tracks + + if (PVContributors.size() != 4) + return; + registrySkim.get(HIST("skim/efficiency"))->Fill(3., 1.); + + if (nEtaIn15 != 4) + return; + registrySkim.get(HIST("skim/efficiency"))->Fill(4., 1.); + + if (npT100 != 4) + return; + registrySkim.get(HIST("skim/efficiency"))->Fill(5., 1.); + + if (nTofTrk < nTofTrkMinCut) + return; + registrySkim.get(HIST("skim/efficiency"))->Fill(6., 1.); + + // + // FIT informaton + // + auto bitMin = 16 - mFITvetoWindow; // default is +- 1 bc (1 bit) + auto bitMax = 16 + mFITvetoWindow; + bool flagFITveto = false; + // check FIT information + for (auto bit = bitMin; bit <= bitMax; bit++) { + if (TESTBIT(dgcand.bbFT0Apf(), bit)) + flagFITveto = true; + if (TESTBIT(dgcand.bbFT0Cpf(), bit)) + flagFITveto = true; + if (useFV0ForVeto && TESTBIT(dgcand.bbFV0Apf(), bit)) + flagFITveto = true; + if (useFDDAForVeto && TESTBIT(dgcand.bbFDDApf(), bit)) + flagFITveto = true; + if (useFDDCForVeto && TESTBIT(dgcand.bbFDDCpf(), bit)) + flagFITveto = true; + } // end of loop over FIT bits + + if (mFITvetoFlag && flagFITveto) + return; + registrySkim.get(HIST("skim/efficiency"))->Fill(7., 1.); + + // + // variables per track + // + int counterTmp = 0; + float px[4], py[4], pz[4]; + // int sign[4]; + // float dcaZ[4]; + // float dcaXY[4]; + + float tmpDedx[4]; + float tmpTofNsigmaEl[4]; + float tmpTofNsigmaPi[4]; + float tmpTofNsigmaKa[4]; + float tmpTofNsigmaPr[4]; + float tmpTofNsigmaMu[4]; + + float nSigmaEl[4]; + float nSigmaPi[4]; + float nSigmaPr[4]; + float nSigmaKa[4]; + float nSigmaMu[4]; + // float chi2TPC[4]; + // float chi2ITS[4]; + float chi2TOF[4] = {-1., -1., -1., -1.}; + // float nclTPCfind[4]; + int nclTPCcrossedRows[4]; + // double trkTime[4]; + // float trkTimeRes[4]; + float trkTofSignal[4]; + + for (const auto& trk : PVContributors) { + + px[counterTmp] = trk.px(); + py[counterTmp] = trk.py(); + pz[counterTmp] = trk.pz(); + // sign[counterTmp] = trk.sign(); + // dcaZ[counterTmp] = trk.dcaZ(); + // dcaXY[counterTmp] = trk.dcaXY(); + + tmpDedx[counterTmp] = trk.tpcSignal(); + nSigmaEl[counterTmp] = trk.tpcNSigmaEl(); + nSigmaPi[counterTmp] = trk.tpcNSigmaPi(); + nSigmaPr[counterTmp] = trk.tpcNSigmaPr(); + nSigmaKa[counterTmp] = trk.tpcNSigmaKa(); + nSigmaMu[counterTmp] = trk.tpcNSigmaMu(); + + trkTofSignal[counterTmp] = trk.beta(); + tmpTofNsigmaEl[counterTmp] = trk.tofNSigmaEl(); + tmpTofNsigmaPi[counterTmp] = trk.tofNSigmaPi(); + tmpTofNsigmaKa[counterTmp] = trk.tofNSigmaKa(); + tmpTofNsigmaPr[counterTmp] = trk.tofNSigmaPr(); + tmpTofNsigmaMu[counterTmp] = trk.tofNSigmaMu(); + + // chi2TPC[counterTmp] = trk.tpcChi2NCl(); + // chi2ITS[counterTmp] = trk.itsChi2NCl(); + if (trk.hasTOF()) + chi2TOF[counterTmp] = trk.tofChi2(); + // nclTPCfind[counterTmp] = trk.tpcNClsFindable(); + nclTPCcrossedRows[counterTmp] = trk.tpcNClsCrossedRows(); + + // trkTime[counterTmp] = trk.trackTime(); + // trkTimeRes[counterTmp] = trk.trackTimeRes(); + counterTmp++; + } + + tauFourTracks(dgcand.runNumber(), + dgcand.globalBC(), // is it necessary + dgtracks.size(), + dgcand.numContrib(), + // dgcand.posX(), dgcand.posY(), + dgcand.posZ(), + dgcand.flags(), + dgcand.occupancyInTime(), + dgcand.hadronicRate(), // is it necessary + energyZNA, energyZNC, + qtot, + dgcand.trs(), dgcand.trofs(), dgcand.hmpr(), // to test it + // dgcand.tfb(), dgcand.itsROFb(), dgcand.sbp(), dgcand.zVtxFT0vPV(), dgcand.vtxITSTPC(), + dgcand.totalFT0AmplitudeA(), dgcand.totalFT0AmplitudeC(), dgcand.totalFV0AmplitudeA(), + // dgcand.timeFT0A(), dgcand.timeFT0C(), dgcand.timeFV0A(), + px, py, pz, // sign, + // dcaXY, dcaZ, + nclTPCcrossedRows, + tmpDedx, nSigmaEl, nSigmaPi, nSigmaKa, nSigmaPr, nSigmaMu, + trkTofSignal, tmpTofNsigmaEl, tmpTofNsigmaPi, tmpTofNsigmaKa, tmpTofNsigmaPr, tmpTofNsigmaMu, + chi2TOF); + } // end of skim process + + PROCESS_SWITCH(TauTau13topo, processDataSG, "Run over SG Producer tables in reco level (reconstructed data or MC)", true); + PROCESS_SWITCH(TauTau13topo, processSimpleMCSG, "Run over SG Producer tables in true level (MC true only)", false); + PROCESS_SWITCH(TauTau13topo, processEfficiencyMCSG, "Run over SG Producer tables in true and reco level (MC true and reconstructed)", false); + PROCESS_SWITCH(TauTau13topo, processDoSkim, "Run over SG Producer tables to produce skimmed data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ adaptAnalysisTask(cfgc, TaskName{"TauTau13topo"})}; + // adaptAnalysisTask(cfgc)}; } diff --git a/PWGUD/Tasks/upcTestRctTables.cxx b/PWGUD/Tasks/upcTestRctTables.cxx new file mode 100644 index 00000000000..5f6d1bd8db1 --- /dev/null +++ b/PWGUD/Tasks/upcTestRctTables.cxx @@ -0,0 +1,84 @@ +// 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. +// +/// \file upcTestRctTables.cxx +/// \brief Tests Rct Tables in UD tabl;es +/// +/// \author Roman Lavicka , Austrian Academy of Sciences & SMI +/// \since 27.06.2025 +// + +// O2 headers +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" + +// O2Physics headers +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" +#include "PWGUD/DataModel/UDTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct UpcTestRctTables { + + // Global varialbes + SGSelector sgSelector; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // declare configurables + Configurable verboseInfo{"verboseInfo", false, {"Print general info to terminal; default it false."}}; + + using FullSGUDCollisions = soa::Join; + using FullSGUDCollision = FullSGUDCollisions::iterator; + + // init + void init(InitContext&) + { + if (verboseInfo) + printMediumMessage("INIT METHOD"); + + histos.add("OutputTable/hRCTflags", ";RCTflag (-);Number of passed collision (-)", HistType::kTH1D, {{5, -0.5, 4.5}}); + + } // end init + + void processDataSG(FullSGUDCollision const& reconstructedCollision) + { + + histos.get(HIST("OutputTable/hRCTflags"))->Fill(0); + + if (sgSelector.isCBTOk(reconstructedCollision)) + histos.get(HIST("OutputTable/hRCTflags"))->Fill(1); + + if (sgSelector.isCBTZdcOk(reconstructedCollision)) + histos.get(HIST("OutputTable/hRCTflags"))->Fill(2); + + if (sgSelector.isCBTHadronOk(reconstructedCollision)) + histos.get(HIST("OutputTable/hRCTflags"))->Fill(3); + + if (sgSelector.isCBTHadronZdcOk(reconstructedCollision)) + histos.get(HIST("OutputTable/hRCTflags"))->Fill(4); + + } // end processDataSG + + PROCESS_SWITCH(UpcTestRctTables, processDataSG, "Iterate UD tables with measured data created by SG-Candidate-Producer.", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Scripts/find_dependencies.py b/Scripts/find_dependencies.py index 10bd68ee91e..87e07897aff 100755 --- a/Scripts/find_dependencies.py +++ b/Scripts/find_dependencies.py @@ -142,7 +142,7 @@ def print_wf(dic_wf: dict, wf: str): print_wf(dic_wf, wf) -def get_table_producers(table: str, dic_wf_all: dict, case_sensitive=False): +def get_table_producers(table: str, dic_wf_all: dict, case_sensitive=False, reverse=False): """Find all workflows that have this table as output.""" list_producers = [] if not case_sensitive: @@ -151,7 +151,7 @@ def get_table_producers(table: str, dic_wf_all: dict, case_sensitive=False): for wf, dic_wf in dic_wf_all.items(): # Loop over devices for dev in dic_wf: - outputs = [o if case_sensitive else o.lower() for o in dic_wf[dev]["outputs"]] + outputs = [o if case_sensitive else o.lower() for o in dic_wf[dev]["inputs" if reverse else "outputs"]] if table in outputs: list_producers.append(wf) return list(dict.fromkeys(list_producers)) # Remove duplicities @@ -179,12 +179,7 @@ def get_workflow_inputs(wf: str, dic_wf_all: dict): def get_tree_for_workflow( - wf: str, - dic_wf_all: dict, - dic_wf_tree=None, - case_sensitive=False, - level=0, - levels_max=0, + wf: str, dic_wf_all: dict, dic_wf_tree=None, case_sensitive=False, level=0, levels_max=0, reverse=False ): """Get the dependency tree of tables and workflows needed to run this workflow.""" # print(level, levels_max) @@ -194,40 +189,47 @@ def get_tree_for_workflow( msg_fatal(f"Workflow {wf} not found") if wf not in dic_wf_tree: dic_wf_tree[wf] = dic_wf_all[wf] - inputs = get_workflow_inputs(wf, dic_wf_all) + if reverse: + inputs = get_workflow_outputs(wf, dic_wf_all) + symbol_direction = "->" + else: + inputs = get_workflow_inputs(wf, dic_wf_all) + symbol_direction = "<-" if inputs: - print(f"{level * ' '}{wf} <- {inputs}") + print(f"{level * ' '}{wf} {symbol_direction} {inputs}") if levels_max < 0 or level < levels_max: for tab in inputs: - producers = get_table_producers(tab, dic_wf_all, case_sensitive) + producers = get_table_producers(tab, dic_wf_all, case_sensitive, reverse) if producers: - print(f"{level * ' ' + ' '}{tab} <- {producers}") + print(f"{level * ' ' + ' '}{tab} {symbol_direction} {producers}") for p in producers: if p not in dic_wf_tree: # avoid infinite recursion get_tree_for_workflow( - p, - dic_wf_all, - dic_wf_tree, - case_sensitive, - level + 1, - levels_max, + p, dic_wf_all, dic_wf_tree, case_sensitive, level + 1, levels_max, reverse ) return dic_wf_tree -def get_tree_for_table(tab: str, dic_wf_all: dict, dic_wf_tree=None, case_sensitive=False, levels_max=0): +def get_tree_for_table(tab: str, dic_wf_all: dict, dic_wf_tree=None, case_sensitive=False, levels_max=0, reverse=False): """Get the dependency tree of tables and workflows needed to produce this table.""" if dic_wf_tree is None: dic_wf_tree = {} - producers = get_table_producers(tab, dic_wf_all, case_sensitive) + producers = get_table_producers(tab, dic_wf_all, case_sensitive, reverse) + symbol_direction = "<-" + if reverse: + symbol_direction = "->" if producers: - print(f"{tab} <- {producers}") - if levels_max != 0: # Search for more dependencies only if needed. + print(f"{tab} {symbol_direction} {producers}") + if levels_max == 0: # Add producers in the dependency dictionary. + for p in producers: + if p not in dic_wf_tree: + dic_wf_tree[p] = dic_wf_all[p] + else: # Search for more dependencies if needed. print("\nWorkflow dependency tree:\n") for p in producers: - get_tree_for_workflow(p, dic_wf_all, dic_wf_tree, case_sensitive, 0, levels_max) + get_tree_for_workflow(p, dic_wf_all, dic_wf_tree, case_sensitive, 0, levels_max, reverse) else: - print("No producers found") + print(f'No {"consumers" if reverse else "producers"} found') return dic_wf_tree @@ -236,8 +238,22 @@ def main(): parser = argparse.ArgumentParser( description="Find dependencies required to produce a given table or to run a given workflow." ) - parser.add_argument("-t", dest="table", type=str, nargs="+", help="table(s)") - parser.add_argument("-w", dest="workflow", type=str, nargs="+", help="workflow(s)") + parser.add_argument( + "-t", dest="table", type=str, nargs="+", help="table(s) for normal (backward) search (i.e. find producers)" + ) + parser.add_argument( + "-w", dest="workflow", type=str, nargs="+", help="workflow(s) for normal (backward) search (i.e. find inputs)" + ) + parser.add_argument( + "-T", dest="table_rev", type=str, nargs="+", help="table(s) for reverse (forward) search (i.e. find consumers)" + ) + parser.add_argument( + "-W", + dest="workflow_rev", + type=str, + nargs="+", + help="workflow(s) for reverse (forward) search (i.e. find outputs)", + ) parser.add_argument( "-c", dest="case", @@ -266,10 +282,12 @@ def main(): help="maximum number of workflow tree levels (default = 0, include all if < 0)", ) args = parser.parse_args() - if not (args.table or args.workflow): + if not (args.table or args.workflow or args.table_rev or args.workflow_rev): parser.error("Provide table(s) and/or workflow(s)") tables = args.table workflows = args.workflow + tables_rev = args.table_rev + workflows_rev = args.workflow_rev case_sensitive = args.case graph_suffix = args.suffix list_exclude = args.exclude @@ -302,27 +320,29 @@ def main(): dic_deps = {} # Find table dependencies - if tables: - for table in tables: - print(f"\nTable: {table}\n") - if not table: - msg_fatal("Bad table") - # producers = get_table_producers(table, dic_wf_all_simple, case_sensitive) - # if not producers: - # print("No producers found") - # return - # print(producers) - # print_workflows(dic_wf_all_simple, producers) - get_tree_for_table(table, dic_wf_all_simple, dic_deps, case_sensitive, n_levels) + for t, reverse in zip((tables, tables_rev), (False, True)): + if t: + for table in t: + print(f"\nTable: {table}\n") + if not table: + msg_fatal("Bad table") + # producers = get_table_producers(table, dic_wf_all_simple, case_sensitive) + # if not producers: + # print("No producers found") + # return + # print(producers) + # print_workflows(dic_wf_all_simple, producers) + get_tree_for_table(table, dic_wf_all_simple, dic_deps, case_sensitive, n_levels, reverse) # Find workflow dependencies - if workflows: - for workflow in workflows: - print(f"\nWorkflow: {workflow}\n") - if not workflow: - msg_fatal("Bad workflow") - # print_workflows(dic_wf_all_simple, [workflow]) - get_tree_for_workflow(workflow, dic_wf_all_simple, dic_deps, case_sensitive, 0, n_levels) + for w, reverse in zip((workflows, workflows_rev), (False, True)): + if w: + for workflow in w: + print(f"\nWorkflow: {workflow}\n") + if not workflow: + msg_fatal("Bad workflow") + # print_workflows(dic_wf_all_simple, [workflow]) + get_tree_for_workflow(workflow, dic_wf_all_simple, dic_deps, case_sensitive, 0, n_levels, reverse) # Print the tree dictionary with dependencies # print("\nTree\n") @@ -330,7 +350,12 @@ def main(): # Produce topology graph. if graph_suffix and dic_deps: - basename = "_".join((tables if tables else []) + (workflows if workflows else [])) + names_all = [] + for names in (tables, tables_rev, workflows, workflows_rev): + if names: + names_all += names + names_all = list(dict.fromkeys(names_all)) # Remove duplicities + basename = "_".join(names_all) # Set a short file name when the full name would be longer than 255 characters. if len(basename) > 251: basename = "o2_dependencies_" + hashlib.sha1(basename.encode(), usedforsecurity=False).hexdigest() @@ -375,7 +400,7 @@ def main(): dot += dot_workflows + dot_tables + dot_deps dot += "}\n" try: - with open(path_file_dot, "w") as file_dot: + with open(path_file_dot, "w", encoding="utf-8") as file_dot: file_dot.write(dot) except IOError: msg_fatal(f"Failed to open file {path_file_dot}") diff --git a/Scripts/format_includes.awk b/Scripts/format_includes.awk new file mode 100644 index 00000000000..47f9132ed80 --- /dev/null +++ b/Scripts/format_includes.awk @@ -0,0 +1,21 @@ +#!/bin/awk -f + +# Fix include style. +# NB: Run before sorting. + +{ + if ($1 ~ /^#include/) { + h = substr($2, 2, length($2) - 2) + if ( h ~ /^(PWG[A-Z]{2}|Common|ALICE3|DPG|EventFiltering|Tools|Tutorials)\/.*\.h/ ) { $2 = "\""h"\"" } # O2Physics + else if ( h ~ /^(Algorithm|CCDB|Common[A-Z]|DataFormats|DCAFitter|Detectors|EMCAL|Field|Framework|FT0|FV0|GlobalTracking|ITS|MathUtils|MFT|MCH|MID|PHOS|PID|ReconstructionDataFormats|SimulationDataFormat|TOF|TPC|ZDC).*\/.*\.h/ ) { $2 = "<"h">" } # O2 + else if ( h ~ /^(T[A-Z]|Math\/|Roo[A-Z])[[:alnum:]\/]+\.h/ ) { $2 = "<"h">" } # ROOT + else if ( h ~ /^KF[A-Z][[:alnum:]]+\.h/ ) { $2 = "<"h">" } # KFParticle + else if ( h ~ /^(fastjet\/|onnxruntime)/ ) { $2 = "<"h">" } # FastJet, ONNX + else if ( h ~ /^.*DataModel\// ) { $2 = "\""h"\"" } # incomplete path to DataModel + else if ( h ~ /^([[:alnum:]_]+\/)+[[:alnum:]_]+\.h/ ) { $2 = "<"h">" } # other third-party + else if ( $2 ~ /^".*\./ ) { } # other local-looking file + else if ( h ~ /^[[:lower:]_]+\.h/ ) { $2 = "<"h">" } # C system + else if ( h ~ /^[[:lower:]_\/]+/ ) { $2 = "<"h">" } # C++ system + } + print +} diff --git a/Scripts/o2_linter.py b/Scripts/o2_linter.py index f88911d1ee9..2aa8fefb24f 100644 --- a/Scripts/o2_linter.py +++ b/Scripts/o2_linter.py @@ -21,11 +21,68 @@ import os import re import sys -from abc import ABC +from enum import Enum +from pathlib import Path from typing import Union github_mode = False # GitHub mode prefix_disable = "o2-linter: disable=" # prefix for disabling tests +file_config = "o2linter_config" # name of the configuration file (applied per directory) +# If this file exists in the path of the tested file, +# failures of tests listed in this file will not make the linter fail. + + +# issue severity levels +class Severity(Enum): + WARNING = 1 + ERROR = 2 + DEFAULT = ERROR + + +# strings for error messages +message_levels = { + Severity.WARNING: "warning", + Severity.ERROR: "error", +} + + +class Reference(Enum): + ISO_CPP = 1 + LLVM = 2 + GOOGLE = 3 + PY_ZEN = 4 + PY_PEP8 = 5 + O2 = 6 + PWG_HF = 7 + LINTER_1 = 8 + LINTER_2 = 9 + + +references_list: "list[tuple[Reference, str, str]]" = [ + (Reference.ISO_CPP, "C++ Core Guidelines", "https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines"), + (Reference.LLVM, "LLVM Coding Standards", "https://llvm.org/docs/CodingStandards.html"), + (Reference.GOOGLE, "Google C++ Style Guide", "https://google.github.io/styleguide/cppguide.html"), + (Reference.PY_ZEN, "The Zen of Python", "https://peps.python.org/pep-0020/"), + (Reference.PY_PEP8, "Style Guide for Python Code", "https://peps.python.org/pep-0008/"), + (Reference.O2, "ALICE O2 Coding Guidelines", "https://github.com/AliceO2Group/CodingGuidelines"), + ( + Reference.PWG_HF, + "PWG-HF guidelines", + "https://aliceo2group.github.io/analysis-framework/docs/advanced-specifics/pwghf.html#contribute", + ), + ( + Reference.LINTER_1, + "Proposal of the O2 linter", + "https://indico.cern.ch/event/1482467/#29-development-of-the-o2-linte", + ), + ( + Reference.LINTER_2, + "Update of the O2 linter", + "https://indico.cern.ch/event/1513748/#29-o2-linter-development", + ), +] + +references: "dict[Reference, dict]" = {name: {"title": title, "url": url} for name, title, url in references_list} def is_camel_case(name: str) -> bool: @@ -93,16 +150,6 @@ def camel_case_to_kebab_case(line: str) -> str: return "".join(new_line) -def print_error(path: str, line: Union[int, None], title: str, message: str): - """Format and print error message.""" - # return # Use to suppress error messages. - str_line = "" if line is None else f"{line}:" - print(f"{path}:{str_line} {message} [{title}]") # terminal format - if github_mode: - str_line = "" if line is None else f",line={line}" - print(f"::warning file={path}{str_line},title=[{title}]::{message}") # GitHub annotation format - - def is_comment_cpp(line: str) -> bool: """Test whether a line is a C++ comment.""" return line.strip().startswith(("//", "/*")) @@ -120,7 +167,7 @@ def block_ranges(line: str, char_open: str, char_close: str) -> "list[list[int]] """Get list of index ranges of longest blocks opened with char_open and closed with char_close.""" # print(f"Looking for {char_open}{char_close} blocks in \"{line}\".") # print(line) - list_ranges: "list[list[int]]" = [] + list_ranges: list[list[int]] = [] if not all((line, len(char_open) == 1, len(char_close) == 1)): return list_ranges @@ -155,14 +202,38 @@ def direction(char: str) -> int: return list_ranges -class TestSpec(ABC): +def get_tolerated_tests(path: str) -> "list[str]": + """Get the list of tolerated tests. + + Looks for the configuration file. + Starts in the test file directory and iterates through parents. + """ + tests: list[str] = [] + for directory in Path(path).resolve().parents: + path_tests = directory / file_config + if path_tests.is_file(): + with path_tests.open() as content: + tests = [line.strip() for line in content.readlines() if line.strip()] + print(f"{path}:1: info: Tolerating tests from {path_tests}. {tests}") + break + return tests + + +class TestSpec: """Prototype of a test class""" - name = "test-template" # short name of the test - message = "Test failed" # error message + name: str = "test-template" # short name of the test + message: str = "Test failed" # error message + rationale: str = "Rationale missing" # brief rationale explanation + references: "list[Reference]" = [] # list of references relevant for this rule + severity_default: Severity = Severity.DEFAULT + severity_current: Severity = Severity.DEFAULT suffixes: "list[str]" = [] # suffixes of files to test - per_line = True # Test lines separately one by one. - n_issues = 0 # issue counter + per_line: bool = True # Test lines separately one by one. + tolerated: bool = False # flag for tolerating issues + n_issues: int = 0 # issue counter + n_disabled: int = 0 # counter of disabled issues + n_tolerated: int = 0 # counter of tolerated issues def file_matches(self, path: str) -> bool: """Test whether the path matches the pattern for files to test.""" @@ -175,9 +246,22 @@ def is_disabled(self, line: str, prefix_comment="//") -> bool: return False line = line[(line.index(prefix) + len(prefix)) :] # Strip away part before prefix. if self.name in line: - return True + self.n_disabled += 1 + # Look for a comment with a reason for disabling. + if re.search(r" \(.{3,}\)", line): + return True return False + def print_error(self, path: str, line: Union[int, None], message: str): + """Format and print error message.""" + # return # Use to suppress error messages. + line = line or 1 + # terminal format + print(f"{path}:{line}: {message_levels[self.severity_current]}: {message} [{self.name}]") + if github_mode and not self.tolerated: # Annotate only not tolerated issues. + # GitHub annotation format + print(f"::{message_levels[self.severity_current]} file={path},line={line},title=[{self.name}]::{message}") + def test_line(self, line: str) -> bool: """Test a line.""" raise NotImplementedError() @@ -186,16 +270,17 @@ def test_file(self, path: str, content) -> bool: """Test a file in a way that cannot be done line by line.""" raise NotImplementedError() - def run(self, path: str, content) -> bool: + def run(self, path: str, content: "list[str]") -> bool: """Run the test.""" # print(content) passed = True + self.severity_current = Severity.WARNING if self.tolerated else self.severity_default if not self.file_matches(path): return passed # print(f"Running test {self.name} for {path} with {len(content)} lines") if self.per_line: for i, line in enumerate(content): - if not isinstance(self, TestUsingDirectives): # Keep the indentation if needed. + if not isinstance(self, TestUsingDirective): # Keep the indentation if needed. line = line.strip() if not line: continue @@ -204,14 +289,20 @@ def run(self, path: str, content) -> bool: continue if not self.test_line(line): passed = False - self.n_issues += 1 - print_error(path, i + 1, self.name, self.message) + if self.tolerated: + self.n_tolerated += 1 + else: + self.n_issues += 1 + self.print_error(path, i + 1, self.message) else: passed = self.test_file(path, content) if not passed: - self.n_issues += 1 - print_error(path, None, self.name, self.message) - return passed + if self.tolerated: + self.n_tolerated += 1 + else: + self.n_issues += 1 + self.print_error(path, None, self.message) + return passed or self.tolerated ########################## @@ -221,11 +312,13 @@ def run(self, path: str, content) -> bool: # Bad practice -class TestIOStream(TestSpec): +class TestIoStream(TestSpec): """Detect included iostream.""" name = "include-iostream" - message = "Including iostream is discouraged. Use O2 logging instead." + message = "Do not include iostream. Use O2 logging instead." + rationale = "Performance. Avoid injection of static constructors. Consistent logging." + references = [Reference.LLVM, Reference.LINTER_1] suffixes = [".h", ".cxx"] def test_line(self, line: str) -> bool: @@ -238,7 +331,9 @@ class TestUsingStd(TestSpec): """Detect importing names from the std namespace.""" name = "import-std-name" - message = "Importing names from the std namespace is not allowed in headers." + message = "Do not import names from the std namespace in headers." + rationale = "Code safety. Avoid namespace pollution with common names." + references = [Reference.LINTER_1] suffixes = [".h"] def test_line(self, line: str) -> bool: @@ -247,11 +342,13 @@ def test_line(self, line: str) -> bool: return not line.startswith("using std::") -class TestUsingDirectives(TestSpec): +class TestUsingDirective(TestSpec): """Detect using directives in headers.""" name = "using-directive" - message = "Using directives are not allowed in headers." + message = "Do not put using directives at global scope in headers." + rationale = "Code safety. Avoid namespace pollution." + references = [Reference.O2, Reference.ISO_CPP, Reference.LLVM, Reference.GOOGLE, Reference.LINTER_1] suffixes = [".h"] def test_line(self, line: str) -> bool: @@ -265,6 +362,8 @@ class TestStdPrefix(TestSpec): name = "std-prefix" message = "Use std:: prefix for names from the std namespace." + rationale = "Code clarity, safety and portability. Avoid ambiguity (e.g. abs)." + references = [Reference.LLVM, Reference.LINTER_1] suffixes = [".h", ".cxx", ".C"] prefix_bad = r"[^\w:\.\"]" patterns = [ @@ -297,18 +396,18 @@ def test_line(self, line: str) -> bool: # Ignore matches inside strings. for match in matches: n_quotes_before = line.count('"', 0, match[0]) # Count quotation marks before the match. - if n_quotes_before % 2: # If odd, we are inside a string and we should ignore this match. - continue - # We are not inside a string and this match is valid. - return False + if not n_quotes_before % 2: # If even, we are not inside a string and this match is valid. + return False return True -class TestROOT(TestSpec): +class TestRootEntity(TestSpec): """Detect unnecessary use of ROOT entities.""" - name = "root-entity" - message = "Consider replacing ROOT entities with equivalents from standard C++ or from O2." + name = "root/entity" + message = "Replace ROOT entities with equivalents from standard C++ or from O2." + rationale = "Code simplicity and maintainability. O2 is not a ROOT code." + references = [Reference.ISO_CPP, Reference.LINTER_1, Reference.PY_ZEN] suffixes = [".h", ".cxx"] def file_matches(self, path: str) -> bool: @@ -325,18 +424,39 @@ def test_line(self, line: str) -> bool: return re.search(pattern, line) is None +class TestRootLorentzVector(TestSpec): + """Detect use of TLorentzVector.""" + + name = "root/lorentz-vector" + message = ( + "Do not use the TLorentzVector legacy class. " + "Use std::array with RecoDecay methods or the ROOT::Math::LorentzVector template instead." + ) + rationale = "Performance. Use up-to-date tools." + references = [Reference.LINTER_2] + suffixes = [".h", ".cxx"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + return "TLorentzVector" not in line + + class TestPi(TestSpec): """Detect use of external pi.""" name = "external-pi" - message = "Consider using the PI constant (and its multiples and fractions) defined in o2::constants::math." + message = "Use the PI constant (and its multiples and fractions) defined in o2::constants::math." + rationale = "Code maintainability." + references = [Reference.LINTER_1, Reference.PY_ZEN] suffixes = [".h", ".cxx"] def file_matches(self, path: str) -> bool: return super().file_matches(path) and "Macros/" not in path def test_line(self, line: str) -> bool: - pattern = r"M_PI|TMath::(Two)?Pi" + pattern = r"[^\w]M_PI|TMath::(Two)?Pi" if is_comment_cpp(line): return True line = remove_comment_cpp(line) @@ -347,7 +467,9 @@ class TestTwoPiAddSubtract(TestSpec): """Detect adding/subtracting of 2 pi.""" name = "two-pi-add-subtract" - message = "Consider using RecoDecay::constrainAngle to restrict angle to a given range." + message = "Use RecoDecay::constrainAngle to restrict angle to a given range." + rationale = "Code maintainability and safety. Use existing tools." + references = [Reference.ISO_CPP, Reference.LINTER_1, Reference.PY_ZEN] suffixes = [".h", ".cxx"] def test_line(self, line: str) -> bool: @@ -366,14 +488,16 @@ class TestPiMultipleFraction(TestSpec): """Detect multiples/fractions of pi for existing equivalent constants.""" name = "pi-multiple-fraction" - message = "Consider using multiples/fractions of PI defined in o2::constants::math." + message = "Use multiples/fractions of PI defined in o2::constants::math." + rationale = "Code maintainability." + references = [Reference.LINTER_1, Reference.PY_ZEN] suffixes = [".h", ".cxx"] def test_line(self, line: str) -> bool: pattern_pi = r"(M_PI|TMath::(Two)?Pi\(\)|(((o2::)?constants::)?math::)?(Two)?PI)" pattern_multiple = r"(2(\.0*f?)?|0\.2?5f?) \* " # * 2, 0.25, 0.5 pattern_fraction = r" / ((2|3|4)([ ,;\)]|\.0*f?))" # / 2, 3, 4 - pattern = rf"{pattern_multiple}{pattern_pi}|{pattern_pi}{pattern_fraction}" + pattern = rf"{pattern_multiple}{pattern_pi}[^\w]|{pattern_pi}{pattern_fraction}" if is_comment_cpp(line): return True line = remove_comment_cpp(line) @@ -385,9 +509,11 @@ class TestPdgDatabase(TestSpec): name = "pdg/database" message = ( - "Direct use of TDatabasePDG is not allowed. " - "Use o2::constants::physics::Mass... or Service." + "Do not use TDatabasePDG directly. " + "Use o2::constants::physics::Mass... or Service instead." ) + rationale = "Performance." + references = [Reference.LINTER_1] suffixes = [".h", ".cxx"] def file_matches(self, path: str) -> bool: @@ -400,11 +526,13 @@ def test_line(self, line: str) -> bool: return "TDatabasePDG" not in line -class TestPdgCode(TestSpec): - """Detect use of hard-coded PDG codes.""" +class TestPdgExplicitCode(TestSpec): + """Detect hard-coded PDG codes.""" name = "pdg/explicit-code" - message = "Avoid using hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead." + message = "Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead." + rationale = "Code comprehensibility, readability, maintainability and safety." + references = [Reference.O2, Reference.ISO_CPP, Reference.LINTER_1] suffixes = [".h", ".cxx", ".C"] def test_line(self, line: str) -> bool: @@ -413,7 +541,7 @@ def test_line(self, line: str) -> bool: line = remove_comment_cpp(line) if re.search(r"->(GetParticle|Mass)\([+-]?[0-9]+\)", line): return False - match = re.search(r"[Pp][Dd][Gg][\w]* ={1,2} [+-]?([0-9]+);", line) + match = re.search(r"[Pp][Dd][Gg].* !?={1,2} [+-]?([0-9]+)", line) if match: code = match.group(1) if code not in ("0", "1", "999"): @@ -421,13 +549,57 @@ def test_line(self, line: str) -> bool: return True -class TestPdgMass(TestSpec): +class TestPdgExplicitMass(TestSpec): + """Detect hard-coded particle masses.""" + + name = "pdg/explicit-mass" + message = "Avoid hard-coded particle masses. Use o2::constants::physics::Mass... instead." + rationale = "Code comprehensibility, readability, maintainability and safety." + references = [Reference.O2, Reference.ISO_CPP, Reference.LINTER_2] + suffixes = [".h", ".cxx"] + masses: "list[str]" = [] # list of mass values to detect + + def __init__(self) -> None: + super().__init__() + + # List of masses of commonly used particles + self.masses.append(r"0\.000511") # e + self.masses.append(r"0\.105") # μ + self.masses.append(r"0\.139") # π+ + self.masses.append(r"0\.493") # K+ + self.masses.append(r"0\.497") # K0 + self.masses.append(r"0\.938") # p + self.masses.append(r"0\.939") # n + self.masses.append(r"1\.115") # Λ + self.masses.append(r"1\.864") # D0 + self.masses.append(r"2\.286") # Λc + self.masses.append(r"3\.096") # J/ψ + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + iterators = re.finditer(rf"(^|\D)({'|'.join(self.masses)})", line) + matches = [(it.start(), it.group(2)) for it in iterators] + if not matches: + return True + if '"' not in line: # Found a match which cannot be inside a string. + return False + # Ignore matches inside strings. + for match in matches: + n_quotes_before = line.count('"', 0, match[0]) # Count quotation marks before the match. + if not n_quotes_before % 2: # If even, we are not inside a string and this match is valid. + return False + return True + + +class TestPdgKnownMass(TestSpec): """Detect unnecessary call of Mass() for a known PDG code.""" name = "pdg/known-mass" - message = ( - "Consider using o2::constants::physics::Mass... instead of calling a database method for a known PDG code." - ) + message = "Use o2::constants::physics::Mass... instead of calling a database method for a known PDG code." + rationale = "Performance." + references = [Reference.LINTER_1] suffixes = [".h", ".cxx", ".C"] def test_line(self, line: str) -> bool: @@ -437,16 +609,16 @@ def test_line(self, line: str) -> bool: pattern_pdg_code = r"[+-]?(k[A-Z][a-zA-Z0-9]*|[0-9]+)" if re.search(rf"->GetParticle\({pattern_pdg_code}\)->Mass\(\)", line): return False - if re.search(rf"->Mass\({pattern_pdg_code}\)", line): - return False - return True + return not re.search(rf"->Mass\({pattern_pdg_code}\)", line) class TestLogging(TestSpec): """Detect non-O2 logging.""" name = "logging" - message = "Consider using O2 logging (LOG, LOGF, LOGP)." + message = "Use O2 logging (LOG, LOGF, LOGP)." + rationale = "Logs easy to read and process." + references = [Reference.LINTER_1] suffixes = [".h", ".cxx"] def file_matches(self, path: str) -> bool: @@ -465,6 +637,8 @@ class TestConstRefInForLoop(TestSpec): name = "const-ref-in-for-loop" message = "Use constant references for non-modified iterators in range-based for loops." + rationale = "Performance, code comprehensibility and safety." + references = [Reference.O2, Reference.ISO_CPP, Reference.LLVM] suffixes = [".h", ".cxx", ".C"] def test_line(self, line: str) -> bool: @@ -484,6 +658,8 @@ class TestConstRefInSubscription(TestSpec): name = "const-ref-in-process" message = "Use constant references for table subscriptions in process functions." + rationale = "Performance, code comprehensibility and safety." + references = [Reference.O2, Reference.ISO_CPP, Reference.LINTER_1] suffixes = [".cxx"] per_line = False @@ -503,15 +679,14 @@ def test_file(self, path: str, content) -> bool: words = line.split() if len(words) < 2: passed = False - print_error( + self.print_error( path, i + 1, - self.name, "Failed to get the process function name. Keep it on the same line as the switch.", ) continue names_functions.append(words[1][:-1]) # Remove the trailing comma. - # print_error(path, i + 1, self.name, f"Got process function name {words[1][:-1]}.") + # self.print_error(path, i + 1, f"Got process function name {words[1][:-1]}.") # Test process functions. for i, line in enumerate(content): line = line.strip() @@ -548,7 +723,7 @@ def test_file(self, path: str, content) -> bool: for arg in words: if not re.search(r"([\w>] const|const [\w<>:]+)&", arg): passed = False - print_error(path, i + 1, self.name, f"Argument {arg} is not const&.") + self.print_error(path, i + 1, f"Argument {arg} is not const&.") line_process = 0 return passed @@ -561,12 +736,14 @@ class TestWorkflowOptions(TestSpec): "Do not use workflow options to customise workflow topology composition in defineDataProcessing. " "Use process function switches or metadata instead." ) + rationale = "Not supported on AliHyperloop." + references = [Reference.LINTER_1] suffixes = [".cxx"] per_line = False def test_file(self, path: str, content) -> bool: is_inside_define = False # Are we inside defineDataProcessing? - for i, line in enumerate(content): # pylint: disable=unused-variable + for _i, line in enumerate(content): # pylint: disable=unused-variable if not line.strip(): continue if self.is_disabled(line): @@ -590,6 +767,40 @@ def test_file(self, path: str, content) -> bool: return True +class TestMagicNumber(TestSpec): + """Detect magic numbers.""" + + name = "magic-number" + message = "Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant." + rationale = "Code comprehensibility, maintainability and safety." + references = [Reference.O2, Reference.ISO_CPP, Reference.LINTER_2] + suffixes = [".h", ".cxx", ".C"] + pattern_compare = r"([<>]=?|[!=]=)" + pattern_number = r"[\+-]?([\d\.]+(e[\+-]?\d+)?)f?" + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + iterators = re.finditer( + rf" {self.pattern_compare} {self.pattern_number}|\W{self.pattern_number} {self.pattern_compare} ", line + ) + matches = [(it.start(), it.group(2), it.group(4)) for it in iterators] + if not matches: + return True + # Ignore matches inside strings. + for match in matches: + n_quotes_before = line.count('"', 0, match[0]) # Count quotation marks before the match. + if n_quotes_before % 2: # If odd, we are inside a string and we should ignore this match. + continue + # We are not inside a string and this match is valid. + for match_n in (match[1], match[2]): + # Accept only 0 or 1 (int or float). + if (match_n is not None) and (re.match(r"[01](\.0?)?$", match_n) is None): + return False + return True + + # Documentation # Reference: https://rawgit.com/AliceO2Group/CodingGuidelines/master/comments_guidelines.html @@ -599,6 +810,8 @@ class TestDocumentationFile(TestSpec): name = "doc/file" message = "Provide mandatory file documentation." + rationale = "Code comprehensibility. Collaboration." + references = [Reference.O2, Reference.LINTER_1] suffixes = [".h", ".cxx", ".C"] per_line = False @@ -622,7 +835,7 @@ def test_file(self, path: str, content) -> bool: for item in doc_items: if re.search(rf"^{doc_prefix} [\\@]{item['keyword']} +{item['pattern']}", line): item["found"] = True - # print_error(path, i + 1, self.name, f"Found \{item['keyword']}.") + # self.print_error(path, i + 1, f"Found \{item['keyword']}.") break if all(item["found"] for item in doc_items): # All items have been found. passed = True @@ -630,10 +843,9 @@ def test_file(self, path: str, content) -> bool: if not passed: for item in doc_items: if not item["found"]: - print_error( + self.print_error( path, last_doc_line, - self.name, f"Documentation for \\{item['keyword']} is missing, incorrect or misplaced.", ) return passed @@ -642,6 +854,9 @@ def test_file(self, path: str, content) -> bool: # Naming conventions # Reference: https://rawgit.com/AliceO2Group/CodingGuidelines/master/naming_formatting.html +rationale_names = "Code readability, comprehensibility and searchability." +references_names = [Reference.O2, Reference.LINTER_1] + class TestNameFunctionVariable(TestSpec): """Test names of functions and of most variables. @@ -654,6 +869,8 @@ class TestNameFunctionVariable(TestSpec): name = "name/function-variable" message = "Use lowerCamelCase for names of functions and variables." + rationale = rationale_names + references = references_names suffixes = [".h", ".cxx", ".C"] def test_line(self, line: str) -> bool: @@ -694,6 +911,9 @@ def test_line(self, line: str) -> bool: "namespace", "struct", "class", + "explicit", + "concept", + "throw", ): return True if len(words) > 2 and words[1] in ("typename", "class", "struct"): @@ -743,6 +963,8 @@ class TestNameMacro(TestSpec): name = "name/macro" message = "Use SCREAMING_SNAKE_CASE for names of macros. Leading and double underscores are not allowed." + rationale = rationale_names + references = references_names suffixes = [".h", ".cxx", ".C"] def test_line(self, line: str) -> bool: @@ -769,29 +991,27 @@ class TestNameConstant(TestSpec): message = ( 'Use UpperCamelCase for names of constexpr constants. Names of special constants may be prefixed with "k".' ) + rationale = rationale_names + references = references_names suffixes = [".h", ".cxx", ".C"] + def __init__(self) -> None: + super().__init__() + keyword = r"(.+ )" # e.g. "static " + type_val = r"([\w:<>+\-*\/, ]+ )" # value type e.g. "std::array " + prefix = r"(\w+::)" # prefix with namespace or class, e.g. "MyClass::" + name_val = r"(\w+)" # name of the constant + array = r"(\[.*\])" # array declaration: "[...]" + assignment = r"( =|\(\d|{)" # value assignment, e.g. " = 2", " = expression", "(2)", "{2}", "{{...}}" + self.pattern = re.compile(rf"{keyword}?constexpr {type_val}?{prefix}*{name_val}{array}?{assignment}") + def test_line(self, line: str) -> bool: if is_comment_cpp(line): return True line = remove_comment_cpp(line) - words = line.split() - if "constexpr" not in words or "=" not in words: + if not (match := self.pattern.match(line)): return True - # Extract constant name. - words = words[: words.index("=")] # keep only words before "=" - constant_name = words[-1] # last word before "=" - if ( - constant_name.endswith("]") and "[" not in constant_name - ): # it's an array and we do not have the name before "[" here - opens_brackets = ["[" in w for w in words] - if not any(opens_brackets): # The opening "[" is not on this line. We have to give up. - return True - constant_name = words[opens_brackets.index(True)] # the name is in the first element with "[" - if "[" in constant_name: # Remove brackets for arrays. - constant_name = constant_name[: constant_name.index("[")] - if "::" in constant_name: # Remove the class prefix for methods. - constant_name = constant_name.split("::")[-1] + constant_name = match.group(4) # The actual test comes here. if constant_name.startswith("k") and len(constant_name) > 1: # exception for special constants constant_name = constant_name[1:] # test the name without "k" @@ -803,6 +1023,8 @@ class TestNameColumn(TestSpec): name = "name/o2-column" message = "Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters." + rationale = rationale_names + references = references_names suffixes = [".h", ".cxx"] def test_line(self, line: str) -> bool: @@ -822,6 +1044,10 @@ def test_line(self, line: str) -> bool: # return True if column_type_name[0] == "_": # probably a macro variable return True + if "#" in column_type_name: # Remove "#" for strings in macros. + column_type_name = column_type_name[: column_type_name.index("#")] + if "#" in column_getter_name: # Remove "#" for strings in macros. + column_getter_name = column_getter_name[: column_getter_name.index("#")] # The actual test comes here. if not is_upper_camel_case(column_type_name): return False @@ -835,6 +1061,8 @@ class TestNameTable(TestSpec): name = "name/o2-table" message = "Use UpperCamelCase for names of O2 tables." + rationale = rationale_names + references = references_names suffixes = [".h", ".cxx"] def test_line(self, line: str) -> bool: @@ -858,6 +1086,8 @@ def test_line(self, line: str) -> bool: # print(f"Got versioned table \"{table_type_name}\", version {table_version}") if table_type_name[0] == "_": # probably a macro variable return True + if "#" in table_type_name: # Remove "#" for strings in macros. + table_type_name = table_type_name[: table_type_name.index("#")] # The actual test comes here. return is_upper_camel_case(table_type_name) @@ -867,6 +1097,8 @@ class TestNameNamespace(TestSpec): name = "name/namespace" message = "Use snake_case for names of namespaces. Double underscores are not allowed." + rationale = rationale_names + references = references_names suffixes = [".h", ".cxx", ".C"] def test_line(self, line: str) -> bool: @@ -888,16 +1120,18 @@ class TestNameType(TestSpec): """Test names of defined types.""" name = "name/type" - message = "Use UpperCamelCase for names of defined types." + message = "Use UpperCamelCase for names of defined types (including concepts)." + rationale = rationale_names + references = references_names suffixes = [".h", ".cxx", ".C"] def test_line(self, line: str) -> bool: if is_comment_cpp(line): return True - if not (match := re.match(r"using (\w+) = ", line)): + if not (match := re.match(r"(using|concept) (\w+) = ", line)): return True # Extract type name. - type_name = match.group(1) + type_name = match.group(2) # The actual test comes here. return is_upper_camel_case(type_name) @@ -908,20 +1142,17 @@ class TestNameUpperCamelCase(TestSpec): keyword = "key" name = f"name/{keyword}" message = f"Use UpperCamelCase for names of {keyword}." + rationale = rationale_names + references = references_names suffixes = [".h", ".cxx", ".C"] def test_line(self, line: str) -> bool: if is_comment_cpp(line): return True - if not line.startswith(f"{self.keyword} "): + if not (match := re.match(rf"{self.keyword}( (class|struct))? (\w+)", line)): return True # Extract object name. - words = line.split() - if not words[1].isalnum(): # "struct : ...", "enum { ..." - return True - object_name = words[1] - if object_name in ("class", "struct") and len(words) > 2: # enum class ... or enum struct - object_name = words[2] + object_name = match.group(3) # The actual test comes here. return is_upper_camel_case(object_name) @@ -955,6 +1186,8 @@ class TestNameFileCpp(TestSpec): name = "name/file-cpp" message = "Use lowerCamelCase or UpperCamelCase for names of C++ files. See the O2 naming conventions for details." + rationale = rationale_names + references = references_names suffixes = [".h", ".cxx", ".C"] per_line = False @@ -977,6 +1210,8 @@ class TestNameFilePython(TestSpec): name = "name/file-python" message = "Use snake_case for names of Python files." + rationale = rationale_names + references = [Reference.LINTER_1, Reference.PY_PEP8] suffixes = [".py", ".ipynb"] per_line = False @@ -990,6 +1225,8 @@ class TestNameWorkflow(TestSpec): name = "name/o2-workflow" message = "Use kebab-case for names of workflows and match the name of the workflow file." + rationale = f"{rationale_names} Correspondence workflow ↔ file." + references = references_names suffixes = ["CMakeLists.txt"] per_line = False @@ -1005,14 +1242,14 @@ def test_file(self, path: str, content) -> bool: workflow_name = line.strip().split("(")[1].split()[0] if not is_kebab_case(workflow_name): passed = False - print_error(path, i + 1, self.name, f"Invalid workflow name: {workflow_name}.") + self.print_error(path, i + 1, f"Invalid workflow name: {workflow_name}.") continue # Extract workflow file name. next_line = content[i + 1].strip() words = next_line.split() if words[0] != "SOURCES": passed = False - print_error(path, i + 2, self.name, f"Did not find sources for workflow: {workflow_name}.") + self.print_error(path, i + 2, f"Did not find sources for workflow: {workflow_name}.") continue workflow_file_name = os.path.basename(words[1]) # the actual file name # Generate the file name matching the workflow name. @@ -1020,10 +1257,9 @@ def test_file(self, path: str, content) -> bool: # Compare the actual and expected file names. if expected_workflow_file_name != workflow_file_name: passed = False - print_error( + self.print_error( path, i + 1, - self.name, f"Workflow name {workflow_name} does not match its file name {workflow_file_name}. " f"(Matches {expected_workflow_file_name}.)", ) @@ -1036,6 +1272,8 @@ class TestNameTask(TestSpec): name = "name/o2-task" message = "Specify task name only when it cannot be derived from the struct name. Only append to the default name." + rationale = f"{rationale_names} Correspondence struct ↔ device." + references = [Reference.LINTER_1] suffixes = [".cxx"] per_line = False @@ -1073,7 +1311,7 @@ def test_file(self, path: str, content) -> bool: line = line[(index + len("adaptAnalysisTask<")) :] # Extract struct name. if not (match := re.match(r"([^>]+)", line)): - print_error(path, i + 1, self.name, f'Failed to extract struct name from "{line}".') + self.print_error(path, i + 1, f'Failed to extract struct name from "{line}".') return False struct_name = match.group(1) if (index := struct_name.find("<")) > -1: @@ -1094,7 +1332,7 @@ def test_file(self, path: str, content) -> bool: passed = False # Extract explicit task name. if not (match := re.search(r"TaskName\{\"([^\}]+)\"\}", line)): - print_error(path, i + 1, self.name, f'Failed to extract explicit task name from "{line}".') + self.print_error(path, i + 1, f'Failed to extract explicit task name from "{line}".') return False task_name = match.group(1) # print(f"{i + 1}: Got struct \"{struct_name}\" with task name \"{task_name}\".") @@ -1109,10 +1347,9 @@ def test_file(self, path: str, content) -> bool: device_name_from_task_name ) # struct name matching the TaskName if not is_kebab_case(device_name_from_task_name): - print_error( + self.print_error( path, i + 1, - self.name, f"Specified task name {task_name} produces an invalid device name " f"{device_name_from_task_name}.", ) @@ -1120,10 +1357,9 @@ def test_file(self, path: str, content) -> bool: elif device_name_from_struct_name == device_name_from_task_name: # If the task name results in the same device name as the struct name would, # TaskName is redundant and should be removed. - print_error( + self.print_error( path, i + 1, - self.name, f"Specified task name {task_name} and the struct name {struct_name} produce " f"the same device name {device_name_from_struct_name}. TaskName is redundant.", ) @@ -1132,10 +1368,9 @@ def test_file(self, path: str, content) -> bool: # If the device names generated from the task name and from the struct name differ in hyphenation, # capitalisation of the struct name should be fixed and TaskName should be removed. # (special cases: alice3-, -2prong) - print_error( + self.print_error( path, i + 1, - self.name, f"Device names {device_name_from_task_name} and {device_name_from_struct_name} generated " f"from the specified task name {task_name} and from the struct name {struct_name}, " f"respectively, differ in hyphenation. Consider fixing capitalisation of the struct name " @@ -1147,10 +1382,9 @@ def test_file(self, path: str, content) -> bool: # from the struct name, accept it if the struct is templated. If the struct is not templated, # extension is acceptable if adaptAnalysisTask is called multiple times for the same struct. if not struct_templated: - print_error( + self.print_error( path, i + 1, - self.name, f"Device name {device_name_from_task_name} from the specified task name " f"{task_name} is an extension of the device name {device_name_from_struct_name} " f"from the struct name {struct_name} but the struct is not templated. " @@ -1158,16 +1392,15 @@ def test_file(self, path: str, content) -> bool: ) passed = False # else: - # print_error(path, i + 1, self.name, f"Device name {device_name_from_task_name} from + # self.print_error(path, i + 1, f"Device name {device_name_from_task_name} from # the specified task name {task_name} is an extension of the device name # {device_name_from_struct_name} from the struct name {struct_name} and the struct is templated. # All good") else: # Other cases should be rejected. - print_error( + self.print_error( path, i + 1, - self.name, f"Specified task name {task_name} produces device name {device_name_from_task_name} " f"which does not match the device name {device_name_from_struct_name} from " f"the struct name {struct_name}. (Matching struct name {struct_name_from_device_name})", @@ -1184,6 +1417,8 @@ class TestNameFileWorkflow(TestSpec): "Name of a workflow file must match the name of the main struct in it (without the PWG prefix). " '(Class implementation files should be in "Core" directories.)' ) + rationale = f"{rationale_names} Correspondence file ↔ struct." + references = [Reference.LINTER_1] suffixes = [".cxx"] per_line = False @@ -1191,10 +1426,15 @@ def file_matches(self, path: str) -> bool: return super().file_matches(path) and "/Core/" not in path def test_file(self, path: str, content) -> bool: - file_name = os.path.basename(path).rstrip(".cxx") + file_name = os.path.basename(path)[:-4] # file name without suffix base_struct_name = f"{file_name[0].upper()}{file_name[1:]}" # expected base of struct names - if "PWGHF/" in path: - base_struct_name = "Hf" + base_struct_name + if match := re.search("PWG([A-Z]{2})/", path): + name_pwg = match.group(1) + prefix_pwg = name_pwg.capitalize() + if name_pwg in ("HF"): + base_struct_name = rf"{prefix_pwg}{base_struct_name}" # mandatory PWG prefix + else: + base_struct_name = rf"({prefix_pwg})?{base_struct_name}" # optional PWG prefix # print(f"For file {file_name} expecting to find {base_struct_name}.") struct_names = [] # actual struct names in the file for line in content: @@ -1204,15 +1444,12 @@ def test_file(self, path: str, content) -> bool: continue # Extract struct name. words = line.split() - if not words[1].isalnum(): # "struct : ..." + if not words[1].isidentifier(): # "struct : ..." continue struct_name = words[1] struct_names.append(struct_name) # print(f"Found structs: {struct_names}.") - for struct_name in struct_names: - if struct_name.startswith(base_struct_name): - return True - return False + return any(re.match(base_struct_name, struct_name) for struct_name in struct_names) class TestNameConfigurable(TestSpec): @@ -1223,6 +1460,8 @@ class TestNameConfigurable(TestSpec): "Use lowerCamelCase for names of configurables and use the same name " "for the struct member as for the JSON string. (Declare the type and names on the same line.)" ) + rationale = f"{rationale_names} Correspondence C++ code ↔ JSON." + references = [Reference.O2, Reference.LINTER_1] suffixes = [".h", ".cxx"] def file_matches(self, path: str) -> bool: @@ -1231,38 +1470,30 @@ def file_matches(self, path: str) -> bool: def test_line(self, line: str) -> bool: if is_comment_cpp(line): return True - if not line.startswith("Configurable"): - return True + if not (match := re.match(r"((o2::)?framework::)?Configurable(\w+|<.+>) (\w+)( = )?{([^,{]+),", line)): + return not re.match(r"((o2::)?framework::)?Configurable", line) # Extract Configurable name. - words = line.split() - if len(words) < 2: - return False - if len(words) > 2 and words[2] == "=": # expecting Configurable... nameCpp = {"nameJson", - name_cpp = words[1] # nameCpp - name_json = words[3][1:] # expecting "nameJson", - else: - names = words[1].split("{") # expecting Configurable... nameCpp{"nameJson", - if len(names) < 2: - return False - name_cpp = names[0] # nameCpp - name_json = names[1] # expecting "nameJson", - if not name_json: - return False + name_cpp = match.group(4) # nameCpp + name_json = match.group(6) # expecting "nameJson" if name_json[0] != '"': # JSON name is not a literal string. return True - name_json = name_json.strip('",') # expecting nameJson + name_json = name_json[1:-1] # Strip away quotation marks. # The actual test comes here. return is_lower_camel_case(name_cpp) and name_cpp == name_json # PWG-HF +references_hf = [Reference.LINTER_1, Reference.PWG_HF] + class TestHfNameStructClass(TestSpec): """PWGHF: Test names of structs and classes.""" name = "pwghf/name/struct-class" message = 'Names of PWGHF structs and classes must start with "Hf".' + rationale = f"{rationale_names} Correspondence device ↔ workflow." + references = references_hf suffixes = [".h", ".cxx"] def file_matches(self, path: str) -> bool: @@ -1288,6 +1519,8 @@ class TestHfNameFileTask(TestSpec): name = "pwghf/name/task-file" message = 'Name of a PWGHF task workflow file must start with "task".' + rationale = rationale_names + references = references_hf suffixes = [".cxx"] per_line = False @@ -1296,9 +1529,7 @@ def file_matches(self, path: str) -> bool: def test_file(self, path: str, content) -> bool: file_name = os.path.basename(path) - if "/Tasks/" in path and not file_name.startswith("task"): - return False - return True + return not ("/Tasks/" in path and not file_name.startswith("task")) class TestHfStructMembers(TestSpec): @@ -1307,6 +1538,8 @@ class TestHfStructMembers(TestSpec): name = "pwghf/struct-member-order" message = "Declare struct members in the conventional order. See the PWGHF coding guidelines." + rationale = rationale_names + references = references_hf suffixes = [".cxx"] per_line = False member_order = [ @@ -1368,10 +1601,9 @@ def test_file(self, path: str, content) -> bool: first_line < last_line_last_member ): # The current category starts before the end of the previous category. passed = False - print_error( + self.print_error( path, first_line, - self.name, f"{struct_name}: {member.strip()} appears too early " f"(before end of {self.member_order[index_last_member].strip()}).", ) @@ -1395,29 +1627,32 @@ def main(): ) args = parser.parse_args() if args.github: - global github_mode # pylint: disable=global-statement + global github_mode # pylint: disable=global-statement # noqa: PLW0603 github_mode = True - tests = [] # list of activated tests + tests: list[TestSpec] = [] # list of activated tests # Bad practice enable_bad_practice = True if enable_bad_practice: - tests.append(TestIOStream()) + tests.append(TestIoStream()) tests.append(TestUsingStd()) - tests.append(TestUsingDirectives()) + tests.append(TestUsingDirective()) tests.append(TestStdPrefix()) - tests.append(TestROOT()) + tests.append(TestRootEntity()) + tests.append(TestRootLorentzVector()) tests.append(TestPi()) tests.append(TestTwoPiAddSubtract()) tests.append(TestPiMultipleFraction()) tests.append(TestPdgDatabase()) - tests.append(TestPdgCode()) - tests.append(TestPdgMass()) + tests.append(TestPdgExplicitCode()) + tests.append(TestPdgExplicitMass()) + tests.append(TestPdgKnownMass()) tests.append(TestLogging()) tests.append(TestConstRefInForLoop()) tests.append(TestConstRefInSubscription()) tests.append(TestWorkflowOptions()) + tests.append(TestMagicNumber()) # Documentation enable_documentation = True @@ -1454,7 +1689,7 @@ def main(): test_names = [t.name for t in tests] # short names of activated tests suffixes = tuple({s for test in tests for s in test.suffixes}) # all suffixes from all enabled tests passed = True # global result of all tests - n_files_bad = {name: 0 for name in test_names} # counter of files with issues + n_files_bad = dict.fromkeys(test_names, 0) # counter of files with issues # Report overview before running. print(f"Testing {len(args.paths)} files.") @@ -1471,47 +1706,87 @@ def main(): # print(f"Skipping path \"{path}\".") continue try: - with open(path, "r", encoding="utf-8") as file: + with open(path, encoding="utf-8") as file: + tolerated_tests = get_tolerated_tests(path) content = file.readlines() for test in tests: + test.tolerated = test.name in tolerated_tests result = test.run(path, content) if not result: n_files_bad[test.name] += 1 passed = False # print(f"File \"{path}\" {'passed' if result else 'failed'} the test {test.name}.") - except IOError: + except OSError: print(f'Failed to open file "{path}".') sys.exit(1) - # Report results per test. - print("\nResults per test") - len_max = max(len(name) for name in test_names) - print(f"test{' ' * (len_max - len('test'))}\tissues\tbad files") - for test in tests: - print(f"{test.name}{' ' * (len_max - len(test.name))}\t{test.n_issues}\t{n_files_bad[test.name]}") + # Report results for tests that failed or were disabled or were tolerated. + n_issues, n_disabled, n_tolerated = 0, 0, 0 # global counters + if not passed or any(n > 0 for n in (test.n_disabled + test.n_tolerated for test in tests)): + print("\nResults for failed, tolerated and disabled tests") + len_max = max(len(name) for name in test_names) + print(f"test{' ' * (len_max - len('test'))}\tissues\ttolerated\tdisabled\tbad files\trationale") + print("-" * len_max) + ref_names = [] + for test in tests: + if any(n > 0 for n in (test.n_issues, test.n_disabled, test.n_tolerated, n_files_bad[test.name])): + ref_ids = sorted(ref.value for ref in test.references) + ref_names += test.references + print( + f"{test.name}{' ' * (len_max - len(test.name))}\t{test.n_issues}\t{test.n_tolerated}" + f"\t\t{test.n_disabled}\t\t{n_files_bad[test.name]}\t\t{test.rationale} {ref_ids}" + ) + n_issues += test.n_issues + n_disabled += test.n_disabled + n_tolerated += test.n_tolerated + print("-" * len_max) + # Print the totals. + name_total = "total" + print(f"{name_total}{' ' * (len_max - len(name_total))}\t{n_issues}\t{n_tolerated}\t\t{n_disabled}") + # Print list of references for listed tests. + print("\nReferences") + ref_names = list(dict.fromkeys(ref_names)) + for ref_name, data in references.items(): + if ref_name in ref_names: + print(f"[{ref_name.value}]\t{data['title']}. <{data['url']}>.") # Report global result. title_result = "O2 linter result" if passed: msg_result = "All tests passed." if github_mode: - print(f"::notice title={title_result}::{msg_result}") + print(f"\n::notice title={title_result}::{msg_result}") else: - print(f"{title_result}: {msg_result}") + print(f"\n{title_result}: {msg_result}") else: msg_result = "Issues have been found." msg_disable = ( - f'You can disable a test for a line by adding a comment with "{prefix_disable}"' - " followed by the name of the test." + f'Exceptionally, you can disable a test for a line by adding a comment with "{prefix_disable}"' + " followed by the name of the test and parentheses with a reason for the exception." ) + msg_tolerate = f'To tolerate certain issues in a directory, add a line with the test name in "{file_config}".' if github_mode: - print(f"::error title={title_result}::{msg_result}") + print(f"\n::error title={title_result}::{msg_result}") print(f"::notice::{msg_disable}") + print(f"::notice::{msg_tolerate}") else: print(f"\n{title_result}: {msg_result}") print(msg_disable) + print(msg_tolerate) + + # Make results available to the GitHub actions. + if github_mode: + try: + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh: + print(f"n_issues={n_issues}", file=fh) + print(f"n_disabled={n_disabled}", file=fh) + print(f"n_tolerated={n_tolerated}", file=fh) + except KeyError: + print("Skipping writing in GITHUB_OUTPUT.") + # Print tips. - print("\nTip: You can run the O2 linter locally with: python3 Scripts/o2_linter.py ") + print("\nTip: You can run the O2 linter locally from the O2Physics directory with: python3 Scripts/o2_linter.py ") + if not passed: sys.exit(1) diff --git a/Tools/KFparticle/KFUtilities.h b/Tools/KFparticle/KFUtilities.h index 7f03cb1c4af..bec24fd7adc 100644 --- a/Tools/KFparticle/KFUtilities.h +++ b/Tools/KFparticle/KFUtilities.h @@ -22,15 +22,26 @@ #define HomogeneousField #endif +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" + +#include +#include +#include +#include + #include // FIXME -#include "KFParticle.h" -#include "KFPTrack.h" -#include "KFPVertex.h" -#include "KFParticleBase.h" -#include "KFVertex.h" +#include +#include +#include +#include -#include "Common/Core/RecoDecay.h" +#include +#include +#include +#include +#include /// @brief Function to create a KFPVertex from the collision table in the AO2Ds. /// The Multiplicity table is required to set the number of real PV Contributors @@ -154,8 +165,8 @@ KFParticle createKFParticleFromTrackParCov(const o2::track::TrackParametrization /// @return o2::track::TrackParametrizationWithError track o2::track::TrackParCov getTrackParCovFromKFP(const KFParticle& kfParticle, const o2::track::PID pid, const int sign) { - o2::gpu::gpustd::array xyz, pxpypz; - o2::gpu::gpustd::array cv; + std::array xyz, pxpypz; + std::array cv; // get parameters from kfParticle xyz[0] = kfParticle.GetX(); @@ -313,4 +324,91 @@ float ldlXYFromKF(KFParticle kfpParticle, KFParticle PV) return l_particle / dl_particle; } +/// @brief squared distance between track and primary vertex normalised by its uncertainty evaluated in matrix form +/// @param track KFParticle track (must be passed as a copy) +/// @param vtx KFParticle primary vertex +/// @return chi2 to primary vertex +float kfCalculateChi2ToPrimaryVertex(KFParticle track, const KFParticle& vtx) +{ + const float PvPoint[3] = {vtx.X(), vtx.Y(), vtx.Z()}; + + track.TransportToPoint(PvPoint); + return track.GetDeviationFromVertex(vtx); +} + +/// @brief prong's momentum in the secondary (decay) vertex +/// @param track KFParticle track (must be passed as a copy) +/// @param vtx KFParticle secondary vertex +/// @return array with components of prong's momentum in the secondary (decay) vertex +std::array kfCalculateProngMomentumInSecondaryVertex(KFParticle track, const KFParticle& vtx) +{ + const float SvPoint[3] = {vtx.X(), vtx.Y(), vtx.Z()}; + + track.TransportToPoint(SvPoint); + return {track.GetPx(), track.GetPy(), track.GetPz()}; +} + +/// @brief distance of closest approach between two tracks, cm +/// @param track1 KFParticle first track (must be passed as a copy) +/// @param track2 KFParticle second track (must be passed as a copy) +/// @return DCA [cm] in the PCA +float kfCalculateDistanceBetweenParticles(KFParticle track1, KFParticle track2) +{ + float dS[2]; + float dsdr[4][6]; + float params1[8], params2[8]; + float covs1[36], covs2[36]; + track1.GetDStoParticle(track2, dS, dsdr); + track1.Transport(dS[0], dsdr[0], params1, covs1); + track2.Transport(dS[1], dsdr[3], params2, covs2); + const float dx = params1[0] - params2[0]; + const float dy = params1[1] - params2[1]; + const float dz = params1[2] - params2[2]; + return std::sqrt(dx * dx + dy * dy + dz * dz); +} + +/// @brief squared distance between two tracks normalised by its uncertainty evaluated in matrix form +/// @param track1 KFParticle first track (must be passed as a copy) +/// @param track2 KFParticle second track (must be passed as a copy) +/// @return chi2 in PCA +float kfCalculateChi2geoBetweenParticles(KFParticle track1, KFParticle track2) +{ + KFParticle kfPair; + const KFParticle* kfDaughters[3] = {&track1, &track2}; + kfPair.SetConstructMethod(2); + kfPair.Construct(kfDaughters, 2); + + return kfPair.Chi2() / kfPair.NDF(); +} + +/// @brief signed distance between primary and secondary vertex and its uncertainty, cm +/// @param candidate KFParticle decay candidate (must be passed as a copy) +/// @param vtx KFParticle primary vertex +/// @return pair of l and delta l +std::pair kfCalculateLdL(KFParticle candidate, const KFParticle& vtx) +{ + float l, dl; + candidate.SetProductionVertex(vtx); + candidate.KFParticleBase::GetDecayLength(l, dl); + + return std::make_pair(l, dl); +} + +/// @brief Z projection of the impact parameter from the track to the primary vertex, cm +/// @param candidate KFParticle prong +/// @param vtx KFParticle primary vertex +/// @return pair of impact parameter and its error +std::pair kfCalculateImpactParameterZ(const KFParticle& candidate, const KFParticle& vtx) +{ + float distanceToVertexXY, errDistanceToVertexXY; + candidate.GetDistanceFromVertexXY(vtx, distanceToVertexXY, errDistanceToVertexXY); + const float distanceToVertex = candidate.GetDistanceFromVertex(vtx); + const float chi2ToVertex = candidate.GetDeviationFromVertex(vtx); + const float distanceToVertexZ2 = distanceToVertex * distanceToVertex - distanceToVertexXY * distanceToVertexXY; + const float distanceToVertexZ = distanceToVertexZ2 > 0 ? std::sqrt(distanceToVertexZ2) : -std::sqrt(-distanceToVertexZ2); + const float errDistanceToVertexZ2 = (distanceToVertex * distanceToVertex * distanceToVertex * distanceToVertex / chi2ToVertex - distanceToVertexXY * distanceToVertexXY * errDistanceToVertexXY * errDistanceToVertexXY) / distanceToVertexZ2; + const float errDistanceToVertexZ = errDistanceToVertexZ2 > 0 ? std::sqrt(errDistanceToVertexZ2) : -std::sqrt(-errDistanceToVertexZ2); + return std::make_pair(distanceToVertexZ, errDistanceToVertexZ); +} + #endif // TOOLS_KFPARTICLE_KFUTILITIES_H_ diff --git a/Tools/ML/MlResponse.h b/Tools/ML/MlResponse.h index 127512e52ee..c60946bcb03 100644 --- a/Tools/ML/MlResponse.h +++ b/Tools/ML/MlResponse.h @@ -17,21 +17,18 @@ #ifndef TOOLS_ML_MLRESPONSE_H_ #define TOOLS_ML_MLRESPONSE_H_ -#if __has_include() -#include -#else -#include -#endif +#include "Tools/ML/model.h" + +#include +#include +#include +#include +#include #include #include #include -#include "CCDB/CcdbApi.h" -#include "Framework/Array2D.h" - -#include "Tools/ML/model.h" - namespace o2 { namespace cuts_ml @@ -158,7 +155,7 @@ class MlResponse LOG(fatal) << "Model index " << nModel << " is out of range! The number of initialised models is " << mModels.size() << ". Please check your configurables."; } - TypeOutputScore* outputPtr = mModels[nModel].evalModel(input); + TypeOutputScore* outputPtr = mModels[nModel].template evalModel(input); return std::vector{outputPtr, outputPtr + mNClasses}; } diff --git a/Tools/ML/model.cxx b/Tools/ML/model.cxx index 0c29808c73c..62ccd9f9839 100644 --- a/Tools/ML/model.cxx +++ b/Tools/ML/model.cxx @@ -17,9 +17,22 @@ /// \brief A general-purpose class with functions for ONNX model applications /// -// ONNX includes #include "Tools/ML/model.h" +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + namespace o2 { @@ -75,18 +88,8 @@ void OnnxModel::initModel(std::string localPath, bool enableOptimizations, int t } mEnv = std::make_shared(ORT_LOGGING_LEVEL_WARNING, "onnx-model"); -#if __has_include() - mSession = std::make_shared(*mEnv, modelPath, sessionOptions); -#else mSession = std::make_shared(*mEnv, modelPath.c_str(), sessionOptions); -#endif - -#if __has_include() - mInputNames = mSession->GetInputNames(); - mInputShapes = mSession->GetInputShapes(); - mOutputNames = mSession->GetOutputNames(); - mOutputShapes = mSession->GetOutputShapes(); -#else + Ort::AllocatorWithDefaultOptions tmpAllocator; for (size_t i = 0; i < mSession->GetInputCount(); ++i) { mInputNames.push_back(mSession->GetInputNameAllocated(i, tmpAllocator).get()); @@ -100,7 +103,6 @@ void OnnxModel::initModel(std::string localPath, bool enableOptimizations, int t for (size_t i = 0; i < mSession->GetOutputCount(); ++i) { mOutputShapes.emplace_back(mSession->GetOutputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape()); } -#endif LOG(info) << "Input Nodes:"; for (size_t i = 0; i < mInputNames.size(); i++) { LOG(info) << "\t" << mInputNames[i] << " : " << printShape(mInputShapes[i]); diff --git a/Tools/ML/model.h b/Tools/ML/model.h index caca77f1a25..e08b84f129f 100644 --- a/Tools/ML/model.h +++ b/Tools/ML/model.h @@ -20,23 +20,18 @@ #ifndef TOOLS_ML_MODEL_H_ #define TOOLS_ML_MODEL_H_ -// C++ and system includes -#if __has_include() -#include -#else -#include -#endif -#include -#include -#include -#include -#include +#include -// ROOT includes -#include "TSystem.h" +#include -// O2 includes -#include "Framework/Logger.h" +#include +#include +#include +#include +#include +#include +#include +#include namespace o2 { @@ -62,9 +57,6 @@ class OnnxModel // assert(input[0].GetTensorTypeAndShapeInfo().GetShape() == getNumInputNodes()); --> Fails build in debug mode, TODO: assertion should be checked somehow try { -#if __has_include() - auto outputTensors = mSession->Run(mInputNames, input, mOutputNames); -#else Ort::RunOptions runOptions; std::vector inputNamesChar(mInputNames.size(), nullptr); std::transform(std::begin(mInputNames), std::end(mInputNames), std::begin(inputNamesChar), @@ -74,7 +66,6 @@ class OnnxModel std::transform(std::begin(mOutputNames), std::end(mOutputNames), std::begin(outputNamesChar), [&](const std::string& str) { return str.c_str(); }); auto outputTensors = mSession->Run(runOptions, inputNamesChar.data(), input.data(), input.size(), outputNamesChar.data(), outputNamesChar.size()); -#endif LOG(debug) << "Number of output tensors: " << outputTensors.size(); if (outputTensors.size() != mOutputNames.size()) { LOG(fatal) << "Number of output tensors: " << outputTensors.size() << " does not agree with the model specified size: " << mOutputNames.size(); @@ -100,13 +91,9 @@ class OnnxModel assert(size % mInputShapes[0][1] == 0); std::vector inputShape{size / mInputShapes[0][1], mInputShapes[0][1]}; std::vector inputTensors; -#if __has_include() - inputTensors.emplace_back(Ort::Experimental::Value::CreateTensor(input.data(), size, inputShape)); -#else - Ort::MemoryInfo mem_info = + Ort::MemoryInfo memInfo = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault); - inputTensors.emplace_back(Ort::Value::CreateTensor(mem_info, input.data(), size, inputShape.data(), inputShape.size())); -#endif + inputTensors.emplace_back(Ort::Value::CreateTensor(memInfo, input.data(), size, inputShape.data(), inputShape.size())); LOG(debug) << "Input shape calculated from vector: " << printShape(inputShape); return evalModel(inputTensors); } @@ -117,9 +104,7 @@ class OnnxModel { std::vector inputTensors; -#if !__has_include() - Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault); -#endif + Ort::MemoryInfo memInfo = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault); for (size_t iinput = 0; iinput < input.size(); iinput++) { [[maybe_unused]] int totalSize = 1; @@ -134,37 +119,26 @@ class OnnxModel inputShape.push_back(mInputShapes[iinput][idim]); } -#if __has_include() - inputTensors.emplace_back(Ort::Experimental::Value::CreateTensor(input[iinput].data(), size, inputShape)); -#else - inputTensors.emplace_back(Ort::Value::CreateTensor(mem_info, input[iinput].data(), size, inputShape.data(), inputShape.size())); -#endif + inputTensors.emplace_back(Ort::Value::CreateTensor(memInfo, input[iinput].data(), size, inputShape.data(), inputShape.size())); } return evalModel(inputTensors); } // Reset session -#if __has_include() - void resetSession() { mSession.reset(new Ort::Experimental::Session{*mEnv, modelPath, sessionOptions}); } -#else void resetSession() { mSession.reset(new Ort::Session{*mEnv, modelPath.c_str(), sessionOptions}); } -#endif // Getters & Setters Ort::SessionOptions* getSessionOptions() { return &sessionOptions; } // For optimizations in post -#if __has_include() - std::shared_ptr getSession() { return mSession; } -#else std::shared_ptr getSession() { return mSession; } -#endif int getNumInputNodes() const { return mInputShapes[0][1]; } + std::vector> getInputShapes() const { return mInputShapes; } int getNumOutputNodes() const { return mOutputShapes[0][1]; } uint64_t getValidityFrom() const { return validFrom; } uint64_t getValidityUntil() const { return validUntil; } @@ -173,11 +147,7 @@ class OnnxModel private: // Environment variables for the ONNX runtime std::shared_ptr mEnv = nullptr; -#if __has_include() - std::shared_ptr mSession = nullptr; -#else std::shared_ptr mSession = nullptr; -#endif Ort::SessionOptions sessionOptions; // Input & Output specifications of the loaded network diff --git a/Tools/PIDML/CMakeLists.txt b/Tools/PIDML/CMakeLists.txt index 8ac36a5c0df..d7be3345443 100644 --- a/Tools/PIDML/CMakeLists.txt +++ b/Tools/PIDML/CMakeLists.txt @@ -10,19 +10,19 @@ # or submit itself to any jurisdiction. o2physics_add_dpl_workflow(pid-ml-producer - SOURCES pidMLProducer.cxx + SOURCES pidMlProducer.cxx JOB_POOL analysis PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(pid-ml-batch-eff-and-pur-producer - SOURCES pidMLBatchEffAndPurProducer.cxx + SOURCES pidMlBatchEffAndPurProducer.cxx JOB_POOL analysis PUBLIC_LINK_LIBRARIES O2::Framework ONNXRuntime::ONNXRuntime O2::CCDB O2Physics::DataModel COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(pid-ml-eff-and-pur-producer - SOURCES pidMLEffAndPurProducer.cxx + SOURCES pidMlEffAndPurProducer.cxx JOB_POOL analysis PUBLIC_LINK_LIBRARIES O2::Framework ONNXRuntime::ONNXRuntime O2::CCDB O2Physics::DataModel COMPONENT_NAME Analysis) @@ -45,12 +45,6 @@ o2physics_add_dpl_workflow(qa-pid COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(qa-pid-ml - SOURCES qaPidML.cxx + SOURCES qaPidMl.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore ONNXRuntime::ONNXRuntime COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(kaon-pid-ml - SOURCES KaonPidTask.cxx - JOB_POOL analysis - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore ONNXRuntime::ONNXRuntime O2::CCDB O2Physics::DataModel - COMPONENT_NAME Analysis) diff --git a/Tools/PIDML/KaonPidTask.cxx b/Tools/PIDML/KaonPidTask.cxx deleted file mode 100644 index acc29e47bee..00000000000 --- a/Tools/PIDML/KaonPidTask.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// 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. - -/// This task produces invariant mass vs. momentum and dEdX in TPC vs. momentum -/// for Kaons using ML PID from the PID ML ONNX Model. - -#include -#include -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "TLorentzVector.h" -#include "TDatabasePDG.h" -#include "Framework/AnalysisDataModel.h" -#include "Tools/PIDML/pidOnnxModel.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" -#include "CommonConstants/PhysicsConstants.h" -#include "TMath.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -namespace o2::aod -{ -using MyCollisions = soa::Join; -using MyTracks = soa::Join; -using MyCollision = MyCollisions::iterator; -using MyTrack = MyTracks::iterator; -} // namespace o2::aod - -struct KaonPidTask { - SliceCache cache; - Preslice perCol = aod::track::collisionId; - - std::shared_ptr pidModel; // creates a shared pointer to a new instance 'pidmodel'. - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - Configurable cfgZvtxCut{"cfgZvtxCut", 10, "Z vtx cut"}; - Configurable cfgEtaCut{"cfgEtaCut", 0.8, "Pseudorapidity cut"}; - Configurable cfgMaxPtCut{"cfgMaxPtCut", 3.0, "Max Pt cut"}; - Configurable cfgMinPtCut{"cfgMinPtCut", 0.5, "Min Pt cut"}; - Configurable cfgMinNSigmaTPCCut{"cfgMinNSigmaTPCCut", 3., "N-sigma TPC cut"}; - Configurable cfgChargeCut{"cfgChargeCut", 0., "N-sigma TPC cut"}; - Configurable cfgPathLocal{"local-path", ".", "base path to the local directory with ONNX models"}; - Configurable cfgPathCCDB{"ccdb-path", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; - Configurable cfgCCDBURL{"ccdb-url", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; - Configurable cfgPid{"pid", 321, "PID to predict"}; - Configurable cfgCertainty{"certainty", 0.5, "Minimum certainty above which the model accepts a particular type of particle"}; - Configurable cfgTimestamp{"timestamp", 0, "Fixed timestamp"}; - Configurable cfgUseCCDB{"useCCDB", false, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; - - o2::ccdb::CcdbApi ccdbApi; - - Filter collisionFilter = (nabs(aod::collision::posZ) < cfgZvtxCut); - Filter trackFilter = (nabs(aod::track::eta) < cfgEtaCut) && (aod::track::pt > cfgMinPtCut) && (aod::track::pt < cfgMaxPtCut); - - // Applying filters - using MyFilteredCollisions = soa::Filtered; - using MyFilteredCollision = MyFilteredCollisions::iterator; - - Partition positive = (nabs(aod::track::eta) < cfgEtaCut) && (aod::track::pt > cfgMinPtCut) && (aod::track::pt < cfgMaxPtCut) && (aod::track::signed1Pt > cfgChargeCut); - Partition negative = (nabs(aod::track::eta) < cfgEtaCut) && (aod::track::pt > cfgMinPtCut) && (aod::track::pt < cfgMaxPtCut) && (aod::track::signed1Pt < cfgChargeCut); - - void init(o2::framework::InitContext&) - { - AxisSpec vtxZAxis = {100, -20, 20}; - std::vector ptBinning = {0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.8, 3.2, 3.6, 4.}; - AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/#it{c})"}; - - if (cfgUseCCDB) { - ccdbApi.init(cfgCCDBURL); // Initializes ccdbApi when cfgUseCCDB is set to 'true' - } - pidModel = std::make_shared(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, cfgTimestamp.value, cfgPid.value, cfgCertainty.value); - - histos.add("hChargePos", ";z;", kTH1F, {{3, -1.5, 1.5}}); - histos.add("hChargeNeg", ";z;", kTH1F, {{3, -1.5, 1.5}}); - histos.add("hInvariantMass", ";M_{k^{+}k^{-}} (GeV/#it{c}^{2});", kTH1F, {{100, 0., 2.}}); - histos.add("hdEdXvsMomentum", ";P_{K^{+}K^{-}}; dE/dx in TPC (keV/cm)", kTH2F, {{100, 0., 4.}, {200, 20., 400.}}); - } - - void process(MyFilteredCollision const& coll, o2::aod::MyTracks const& /*tracks*/) - { - auto groupPositive = positive->sliceByCached(aod::track::collisionId, coll.globalIndex(), cache); - auto groupNegative = negative->sliceByCached(aod::track::collisionId, coll.globalIndex(), cache); - for (auto track : groupPositive) { - histos.fill(HIST("hChargePos"), track.sign()); - if (pidModel.get()->applyModelBoolean(track)) { - histos.fill(HIST("hdEdXvsMomentum"), track.p(), track.tpcSignal()); - } - } - - for (auto track : groupNegative) { - histos.fill(HIST("hChargeNeg"), track.sign()); - if (pidModel.get()->applyModelBoolean(track)) { - histos.fill(HIST("hdEdXvsMomentum"), track.p(), track.tpcSignal()); - } - } - - for (auto& [pos, neg] : combinations(soa::CombinationsFullIndexPolicy(groupPositive, groupNegative))) { - if (!(pidModel.get()->applyModelBoolean(pos)) || !(pidModel.get()->applyModelBoolean(neg))) { - continue; - } - - TLorentzVector part1Vec; - TLorentzVector part2Vec; - float mMassOne = TDatabasePDG::Instance()->GetParticle(cfgPid.value)->Mass(); - float mMassTwo = TDatabasePDG::Instance()->GetParticle(cfgPid.value)->Mass(); - - part1Vec.SetPtEtaPhiM(pos.pt(), pos.eta(), pos.phi(), mMassOne); - part2Vec.SetPtEtaPhiM(neg.pt(), neg.eta(), neg.phi(), mMassTwo); - - TLorentzVector sumVec(part1Vec); - sumVec += part2Vec; - - histos.fill(HIST("hInvariantMass"), sumVec.M()); - } - } -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; - return workflow; -} diff --git a/Tools/PIDML/pidML.h b/Tools/PIDML/pidMl.h similarity index 80% rename from Tools/PIDML/pidML.h rename to Tools/PIDML/pidMl.h index 821da7efc42..cb45360052c 100644 --- a/Tools/PIDML/pidML.h +++ b/Tools/PIDML/pidMl.h @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file pidML.h +/// \file pidMl.h /// \brief Data model for PID ML training. /// /// \author Maja Kabus @@ -17,8 +17,14 @@ #ifndef TOOLS_PIDML_PIDML_H_ #define TOOLS_PIDML_PIDML_H_ -#include "Framework/AnalysisDataModel.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include + +#include namespace o2::aod { @@ -32,16 +38,16 @@ DECLARE_SOA_COLUMN(Py, py, float); //! Non-dynam DECLARE_SOA_COLUMN(Pz, pz, float); //! Non-dynamic column with track z-momentum DECLARE_SOA_COLUMN(Sign, sign, float); //! Non-dynamic column with track sign DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, uint8_t); //! -DECLARE_SOA_COLUMN(TOFExpSignalDiffEl, tofExpSignalDiffEl, float); //! Difference between signal and expected for electron -DECLARE_SOA_COLUMN(TPCExpSignalDiffEl, tpcExpSignalDiffEl, float); //! Difference between signal and expected for electron -DECLARE_SOA_COLUMN(TOFExpSignalDiffMu, tofExpSignalDiffMu, float); //! Difference between signal and expected for muon -DECLARE_SOA_COLUMN(TPCExpSignalDiffMu, tpcExpSignalDiffMu, float); //! Difference between signal and expected for muon -DECLARE_SOA_COLUMN(TOFExpSignalDiffPi, tofExpSignalDiffPi, float); //! Difference between signal and expected for pion -DECLARE_SOA_COLUMN(TPCExpSignalDiffPi, tpcExpSignalDiffPi, float); //! Difference between signal and expected for pion -DECLARE_SOA_COLUMN(TOFExpSignalDiffKa, tofExpSignalDiffKa, float); //! Difference between signal and expected for kaon -DECLARE_SOA_COLUMN(TPCExpSignalDiffKa, tpcExpSignalDiffKa, float); //! Difference between signal and expected for kaon -DECLARE_SOA_COLUMN(TOFExpSignalDiffPr, tofExpSignalDiffPr, float); //! Difference between signal and expected for proton -DECLARE_SOA_COLUMN(TPCExpSignalDiffPr, tpcExpSignalDiffPr, float); //! Difference between signal and expected for proton +DECLARE_SOA_COLUMN(TofExpSignalDiffEl, tofExpSignalDiffEl, float); //! Difference between signal and expected for electron +DECLARE_SOA_COLUMN(TpcExpSignalDiffEl, tpcExpSignalDiffEl, float); //! Difference between signal and expected for electron +DECLARE_SOA_COLUMN(TofExpSignalDiffMu, tofExpSignalDiffMu, float); //! Difference between signal and expected for muon +DECLARE_SOA_COLUMN(TpcExpSignalDiffMu, tpcExpSignalDiffMu, float); //! Difference between signal and expected for muon +DECLARE_SOA_COLUMN(TofExpSignalDiffPi, tofExpSignalDiffPi, float); //! Difference between signal and expected for pion +DECLARE_SOA_COLUMN(TpcExpSignalDiffPi, tpcExpSignalDiffPi, float); //! Difference between signal and expected for pion +DECLARE_SOA_COLUMN(TofExpSignalDiffKa, tofExpSignalDiffKa, float); //! Difference between signal and expected for kaon +DECLARE_SOA_COLUMN(TpcExpSignalDiffKa, tpcExpSignalDiffKa, float); //! Difference between signal and expected for kaon +DECLARE_SOA_COLUMN(TofExpSignalDiffPr, tofExpSignalDiffPr, float); //! Difference between signal and expected for proton +DECLARE_SOA_COLUMN(TpcExpSignalDiffPr, tpcExpSignalDiffPr, float); //! Difference between signal and expected for proton } // namespace pidtracks DECLARE_SOA_TABLE(PidTracksDataMl, "AOD", "PIDTRACKSDATAML", //! Data tracks for prediction and domain adaptation aod::track::TPCSignal, @@ -63,7 +69,6 @@ DECLARE_SOA_TABLE(PidTracksDataMl, "AOD", "PIDTRACKSDATAML", //! Data tracks for aod::track::DcaXY, aod::track::DcaZ); DECLARE_SOA_TABLE(PidTracksData, "AOD", "PIDTRACKSDATA", //! Data tracks for comparative analysis - aod::cent::CentRun2V0M, aod::mult::MultFV0A, aod::mult::MultFV0C, pidtracks::MultFV0M, aod::mult::MultFT0A, aod::mult::MultFT0C, pidtracks::MultFT0M, aod::mult::MultZNA, aod::mult::MultZNC, @@ -90,34 +95,34 @@ DECLARE_SOA_TABLE(PidTracksData, "AOD", "PIDTRACKSDATA", //! Data tracks for com aod::track::DcaZ, pidtpc::TPCNSigmaEl, pidtpc::TPCExpSigmaEl, - pidtracks::TPCExpSignalDiffEl, + pidtracks::TpcExpSignalDiffEl, pidtof::TOFNSigmaEl, pidtof::TOFExpSigmaEl, - pidtracks::TOFExpSignalDiffEl, + pidtracks::TofExpSignalDiffEl, pidtpc::TPCNSigmaMu, pidtpc::TPCExpSigmaMu, - pidtracks::TPCExpSignalDiffMu, + pidtracks::TpcExpSignalDiffMu, pidtof::TOFNSigmaMu, pidtof::TOFExpSigmaMu, - pidtracks::TOFExpSignalDiffMu, + pidtracks::TofExpSignalDiffMu, pidtpc::TPCNSigmaPi, pidtpc::TPCExpSigmaPi, - pidtracks::TPCExpSignalDiffPi, + pidtracks::TpcExpSignalDiffPi, pidtof::TOFNSigmaPi, pidtof::TOFExpSigmaPi, - pidtracks::TOFExpSignalDiffPi, + pidtracks::TofExpSignalDiffPi, pidtpc::TPCNSigmaKa, pidtpc::TPCExpSigmaKa, - pidtracks::TPCExpSignalDiffKa, + pidtracks::TpcExpSignalDiffKa, pidtof::TOFNSigmaKa, pidtof::TOFExpSigmaKa, - pidtracks::TOFExpSignalDiffKa, + pidtracks::TofExpSignalDiffKa, pidtpc::TPCNSigmaPr, pidtpc::TPCExpSigmaPr, - pidtracks::TPCExpSignalDiffPr, + pidtracks::TpcExpSignalDiffPr, pidtof::TOFNSigmaPr, pidtof::TOFExpSigmaPr, - pidtracks::TOFExpSignalDiffPr); + pidtracks::TofExpSignalDiffPr); DECLARE_SOA_TABLE(PidTracksMcMl, "AOD", "PIDTRACKSMCML", //! MC tracks for training aod::track::TPCSignal, aod::track::TRDSignal, aod::track::TRDPattern, @@ -140,7 +145,6 @@ DECLARE_SOA_TABLE(PidTracksMcMl, "AOD", "PIDTRACKSMCML", //! MC tracks for train aod::mcparticle::PdgCode, pidtracks::IsPhysicalPrimary); DECLARE_SOA_TABLE(PidTracksMc, "AOD", "PIDTRACKSMC", //! MC tracks for comparative analysis - aod::cent::CentRun2V0M, aod::mult::MultFV0A, aod::mult::MultFV0C, pidtracks::MultFV0M, aod::mult::MultFT0A, aod::mult::MultFT0C, pidtracks::MultFT0M, aod::mult::MultZNA, aod::mult::MultZNC, @@ -167,34 +171,34 @@ DECLARE_SOA_TABLE(PidTracksMc, "AOD", "PIDTRACKSMC", //! MC tracks for comparati aod::track::DcaZ, pidtpc::TPCNSigmaEl, pidtpc::TPCExpSigmaEl, - pidtracks::TPCExpSignalDiffEl, + pidtracks::TpcExpSignalDiffEl, pidtof::TOFNSigmaEl, pidtof::TOFExpSigmaEl, - pidtracks::TOFExpSignalDiffEl, + pidtracks::TofExpSignalDiffEl, pidtpc::TPCNSigmaMu, pidtpc::TPCExpSigmaMu, - pidtracks::TPCExpSignalDiffMu, + pidtracks::TpcExpSignalDiffMu, pidtof::TOFNSigmaMu, pidtof::TOFExpSigmaMu, - pidtracks::TOFExpSignalDiffMu, + pidtracks::TofExpSignalDiffMu, pidtpc::TPCNSigmaPi, pidtpc::TPCExpSigmaPi, - pidtracks::TPCExpSignalDiffPi, + pidtracks::TpcExpSignalDiffPi, pidtof::TOFNSigmaPi, pidtof::TOFExpSigmaPi, - pidtracks::TOFExpSignalDiffPi, + pidtracks::TofExpSignalDiffPi, pidtpc::TPCNSigmaKa, pidtpc::TPCExpSigmaKa, - pidtracks::TPCExpSignalDiffKa, + pidtracks::TpcExpSignalDiffKa, pidtof::TOFNSigmaKa, pidtof::TOFExpSigmaKa, - pidtracks::TOFExpSignalDiffKa, + pidtracks::TofExpSignalDiffKa, pidtpc::TPCNSigmaPr, pidtpc::TPCExpSigmaPr, - pidtracks::TPCExpSignalDiffPr, + pidtracks::TpcExpSignalDiffPr, pidtof::TOFNSigmaPr, pidtof::TOFExpSigmaPr, - pidtracks::TOFExpSignalDiffPr, + pidtracks::TofExpSignalDiffPr, aod::mcparticle::PdgCode, pidtracks::IsPhysicalPrimary); } // namespace o2::aod diff --git a/Tools/PIDML/pidMLBatchEffAndPurProducer.cxx b/Tools/PIDML/pidMlBatchEffAndPurProducer.cxx similarity index 57% rename from Tools/PIDML/pidMLBatchEffAndPurProducer.cxx rename to Tools/PIDML/pidMlBatchEffAndPurProducer.cxx index 9a611ded269..34ce845c79d 100644 --- a/Tools/PIDML/pidMLBatchEffAndPurProducer.cxx +++ b/Tools/PIDML/pidMlBatchEffAndPurProducer.cxx @@ -9,26 +9,46 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file pidMLBatchEffAndPurProducer +/// \file pidMlBatchEffAndPurProducer.cxx /// \brief Batch PID execution task. It produces derived data needed for ROOT script, which -/// generates efficiency (recall) and purity (precision) analysis of ML Model PID +/// generate PIDML neural network performance benchmark plots. /// /// \author Michał Olędzki /// \author Marek Mytkowski -#include -#include -#include - -#include "Framework/AnalysisDataModel.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/StaticFor.h" -#include "CCDB/CcdbApi.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" #include "Tools/PIDML/pidOnnxModel.h" #include "Tools/PIDML/pidUtils.h" +// +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -44,9 +64,9 @@ DECLARE_SOA_COLUMN(Pid, pid, int32_t); //! PDG particle ID to be t DECLARE_SOA_COLUMN(Pt, pt, float); //! particle's pt DECLARE_SOA_COLUMN(MlCertainty, mlCertainty, float); //! Machine learning model certainty value for track and pid DECLARE_SOA_COLUMN(NSigma, nSigma, float); //! nSigma value for track and pid -DECLARE_SOA_COLUMN(IsPidMC, isPidMc, bool); //! Is track's mcParticle recognized as "Pid" -DECLARE_SOA_COLUMN(HasTOF, hasTof, bool); //! Does track have TOF detector signal -DECLARE_SOA_COLUMN(HasTRD, hasTrd, bool); //! Does track have TRD detector signal +DECLARE_SOA_COLUMN(IsPidMC, isPidMC, bool); //! Is track's mcParticle recognized as "Pid" +DECLARE_SOA_COLUMN(HasTOF, hasTOF, bool); //! Does track have TOF detector signal +DECLARE_SOA_COLUMN(HasTRD, hasTRD, bool); //! Does track have TRD detector signal } // namespace effandpurpidresult DECLARE_SOA_TABLE(EffAndPurPidResult, "AOD", "PIDEFFANDPURRES", o2::soa::Index<>, @@ -58,49 +78,49 @@ struct PidMlBatchEffAndPurProducer { Produces effAndPurPIDResult; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - static constexpr int32_t currentRunNumber = -1; - static constexpr uint32_t kNPids = 6; - static constexpr int32_t kPids[kNPids] = {2212, 321, 211, -211, -321, -2212}; - static constexpr std::string_view kParticleLabels[kNPids] = {"2212", "321", "211", "0211", "0321", "02212"}; - static constexpr std::string_view kParticleNames[kNPids] = {"proton", "kaon", "pion", "antipion", "antikaon", "antiproton"}; + static constexpr int32_t CurrentRunNumber = -1; + static constexpr uint32_t KNPids = 6; + static constexpr int32_t KPids[KNPids] = {2212, 321, 211, -211, -321, -2212}; + static constexpr std::string_view KParticleLabels[KNPids] = {"2212", "321", "211", "0211", "0321", "02212"}; + static constexpr std::string_view KPatricleNames[KNPids] = {"proton", "kaon", "pion", "antipion", "antikaon", "antiproton"}; - std::array, kNPids> hTracked; - std::array, kNPids> hMCPositive; + std::array, KNPids> hTracked; + std::array, KNPids> hMCPositive; o2::ccdb::CcdbApi ccdbApi; - std::vector models; - Configurable> cfgPids{"pids", std::vector(kPids, kPids + kNPids), "PIDs to predict"}; - Configurable> cfgDetectorsPLimits{"detectors-p-limits", std::array(pidml_pt_cuts::defaultModelPLimits), "\"use {detector} when p >= y_{detector}\": array of 3 doubles [y_TPC, y_TOF, y_TRD]"}; - Configurable cfgPathCCDB{"ccdb-path", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; - Configurable cfgCCDBURL{"ccdb-url", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; - Configurable cfgUseCCDB{"use-ccdb", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; - Configurable cfgPathLocal{"local-path", "/home/mkabus/PIDML/", "base path to the local directory with ONNX models"}; - Configurable cfgUseFixedTimestamp{"use-fixed-timestamp", false, "Whether to use fixed timestamp from configurable instead of timestamp calculated from the data"}; - Configurable cfgTimestamp{"timestamp", 1524176895000, "Hardcoded timestamp for tests"}; + Configurable> pdgPids{"pdgPids", std::vector(KPids, KPids + KNPids), "list of PDG ids of particles to predict. Every subset of {2212, 321, 211, -211, -321, -2212} is correct value."}; + Configurable detectorMomentumLimits{"detectorMomentumLimits", MomentumLimitsMatrix(pidml_pt_cuts::defaultModelPLimits), "\"use {detector} when p >= y_{detector}\": array of 3 doubles [y_TPC, y_TOF, y_TRD]"}; + Configurable ccdbPath{"ccdbPath", "Users/m/mkabus/PIDML", "Base path to the CCDB directory with ONNX models"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; + Configurable useCcdb{"useCcdb", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; + Configurable localPath{"localPath", "/home/mkabus/PIDML/", "Base path to the local directory with ONNX models"}; + Configurable useFixedTimestamp{"useFixedTimestamp", false, "Whether to use fixed timestamp from configurable instead of timestamp calculated from the data"}; + Configurable fixedTimestamp{"fixedTimestamp", 1524176895000, "Hardcoded timestamp for tests"}; Filter trackFilter = requireGlobalTrackInFilter(); using BigTracks = soa::Filtered>; + std::vector> models; void initHistos() { static const AxisSpec axisPt{50, 0, 3.1, "pt"}; - static_for<0, kNPids - 1>([&](auto i) { - if (std::find(cfgPids.value.begin(), cfgPids.value.end(), kPids[i]) != cfgPids.value.end()) { - hTracked[i] = histos.add(Form("%s/hPtMCTracked", kParticleLabels[i].data()), Form("Tracked %ss vs pT", kParticleNames[i].data()), kTH1F, {axisPt}); - hMCPositive[i] = histos.add(Form("%s/hPtMCPositive", kParticleLabels[i].data()), Form("MC Positive %ss vs pT", kParticleNames[i].data()), kTH1F, {axisPt}); + static_for<0, KNPids - 1>([&](auto i) { + if (std::find(pdgPids.value.begin(), pdgPids.value.end(), KPids[i]) != pdgPids.value.end()) { + hTracked[i] = histos.add(Form("%s/hPtMCTracked", KParticleLabels[i].data()), Form("Tracked %ss vs pT", KPatricleNames[i].data()), kTH1F, {axisPt}); + hMCPositive[i] = histos.add(Form("%s/hPtMCPositive", KParticleLabels[i].data()), Form("MC Positive %ss vs pT", KPatricleNames[i].data()), kTH1F, {axisPt}); } }); } void init(InitContext const&) { - if (cfgUseCCDB) { - ccdbApi.init(cfgCCDBURL); + if (useCcdb) { + ccdbApi.init(ccdbUrl); } initHistos(); @@ -110,7 +130,7 @@ struct PidMlBatchEffAndPurProducer { { std::optional index; - if (std::find(cfgPids.value.begin(), cfgPids.value.end(), pdgCode) != cfgPids.value.end()) { + if (std::find(pdgPids.value.begin(), pdgPids.value.end(), pdgCode) != pdgPids.value.end()) { switch (pdgCode) { case 2212: index = 0; @@ -160,7 +180,7 @@ struct PidMlBatchEffAndPurProducer { { nSigma_t nSigma; - switch (TMath::Abs(cfgPid)) { + switch (std::abs(cfgPid)) { case 11: // electron nSigma.tof = track.tofNSigmaEl(); nSigma.tpc = track.tpcNSigmaEl(); @@ -183,10 +203,10 @@ struct PidMlBatchEffAndPurProducer { break; } - if (!inPLimit(track, cfgDetectorsPLimits.value[kTPCTOF]) || tofMissing(track)) { - nSigma.composed = TMath::Abs(nSigma.tpc); + if (!inPLimit(track, detectorMomentumLimits.value[kTPCTOF]) || tofMissing(track)) { + nSigma.composed = std::abs(nSigma.tpc); } else { - nSigma.composed = TMath::Hypot(nSigma.tof, nSigma.tpc); + nSigma.composed = std::hypot(nSigma.tof, nSigma.tpc); } int32_t sign = cfgPid > 0 ? 1 : -1; @@ -202,36 +222,36 @@ struct PidMlBatchEffAndPurProducer { effAndPurPIDResult.reserve(mcParticles.size()); auto bc = collisions.iteratorAt(0).bc_as(); - if (cfgUseCCDB && bc.runNumber() != currentRunNumber) { - uint64_t timestamp = cfgUseFixedTimestamp ? cfgTimestamp.value : bc.timestamp(); - for (const int32_t& pid : cfgPids.value) - models.emplace_back(PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, - ccdbApi, timestamp, pid, 1.1, &cfgDetectorsPLimits.value[0])); + if (useCcdb && bc.runNumber() != CurrentRunNumber) { + uint64_t timestamp = useFixedTimestamp ? fixedTimestamp.value : bc.timestamp(); + for (const int32_t& pid : pdgPids.value) + models.emplace_back(PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, + ccdbApi, timestamp, pid, 1.1, &detectorMomentumLimits.value[0])); } else { - for (int32_t& pid : cfgPids.value) - models.emplace_back(PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, - ccdbApi, -1, pid, 1.1, &cfgDetectorsPLimits.value[0])); + for (const int32_t& pid : pdgPids.value) + models.emplace_back(PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, + ccdbApi, -1, pid, 1.1, &detectorMomentumLimits.value[0])); } - for (auto& mcPart : mcParticles) { + for (const auto& mcPart : mcParticles) { // eta cut is done in requireGlobalTrackInFilter() so we cut it only here - if (mcPart.isPhysicalPrimary() && TMath::Abs(mcPart.eta()) < kGlobalEtaCut) { + if (mcPart.isPhysicalPrimary() && std::abs(mcPart.eta()) < kGlobalEtaCut) { fillMCPositiveHist(mcPart.pdgCode(), mcPart.pt()); } } - for (auto& track : tracks) { + for (const auto& track : tracks) { if (track.has_mcParticle()) { auto mcPart = track.mcParticle(); if (mcPart.isPhysicalPrimary()) { fillTrackedHist(mcPart.pdgCode(), track.pt()); - for (size_t i = 0; i < cfgPids.value.size(); ++i) { + for (size_t i = 0; i < pdgPids.value.size(); ++i) { float mlCertainty = models[i].applyModel(track); - nSigma_t nSigma = getNSigma(track, cfgPids.value[i]); - bool isMCPid = mcPart.pdgCode() == cfgPids.value[i]; + nSigma_t nSigma = getNSigma(track, pdgPids.value[i]); + bool isMCPid = mcPart.pdgCode() == pdgPids.value[i]; - effAndPurPIDResult(track.index(), cfgPids.value[i], track.pt(), mlCertainty, nSigma.composed, isMCPid, track.hasTOF(), track.hasTRD()); + effAndPurPIDResult(track.index(), pdgPids.value[i], track.pt(), mlCertainty, nSigma.composed, isMCPid, track.hasTOF(), track.hasTRD()); } } } diff --git a/Tools/PIDML/pidMLEffAndPurProducer.cxx b/Tools/PIDML/pidMlEffAndPurProducer.cxx similarity index 65% rename from Tools/PIDML/pidMLEffAndPurProducer.cxx rename to Tools/PIDML/pidMlEffAndPurProducer.cxx index 7e626a8d631..1441718b336 100644 --- a/Tools/PIDML/pidMLEffAndPurProducer.cxx +++ b/Tools/PIDML/pidMlEffAndPurProducer.cxx @@ -9,23 +9,33 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file pidMLEffAndPurProducer.cxx +/// \file pidMlEffAndPurProducer.cxx /// \brief Produce pt histograms for tracks accepted by ML network and for MC mcParticles. /// /// \author Michał Olędzki /// \author Marek Mytkowski -#include - -#include "Framework/AnalysisDataModel.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "CCDB/CcdbApi.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" #include "Tools/PIDML/pidOnnxModel.h" -#include "pidOnnxModel.h" #include "Tools/PIDML/pidUtils.h" +// +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -35,19 +45,18 @@ using namespace pidml::pidutils; struct PidMlEffAndPurProducer { HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - PidONNXModel pidModel; - Configurable cfgPid{"pid", 211, "PID to predict"}; - Configurable cfgNSigmaCut{"n-sigma-cut", 3.0f, "TPC and TOF PID nSigma cut"}; - Configurable> cfgDetectorsPLimits{"detectors-p-limits", std::array(pidml_pt_cuts::defaultModelPLimits), "\"use {detector} when p >= y_{detector}\": array of 3 doubles [y_TPC, y_TOF, y_TRD]"}; - Configurable cfgCertainty{"certainty", 0.5, "Min certainty of the model to accept given mcPart to be of given kind"}; + Configurable pdgPid{"pdgPid", 211, "PID to predict"}; + Configurable nSigmaCut{"nSigmaCut", 3.0f, "TPC and TOF PID nSigma cut"}; + Configurable detectorMomentumLimits{"detectorMomentumLimits", MomentumLimitsMatrix(pidml_pt_cuts::defaultModelPLimits), "use {detector} when p >= y_{detector}: array of 3 doubles [y_TPC, y_TOF, y_TRD]"}; + Configurable mlIdentCertaintyThreshold{"mlIdentCertaintyThreshold", 0.5, "Min certainty of the model to accept given mcPart to be of given kind"}; - Configurable cfgPathCCDB{"ccdb-path", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; - Configurable cfgCCDBURL{"ccdb-url", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; - Configurable cfgUseCCDB{"use-ccdb", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; - Configurable cfgPathLocal{"local-path", "/home/mkabus/PIDML", "base path to the local directory with ONNX models"}; + Configurable ccdbPath{"ccdbPath", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; + Configurable useCcdb{"useCcdb", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; + Configurable localPath{"localPath", "/home/mkabus/PIDML", "base path to the local directory with ONNX models"}; - Configurable cfgUseFixedTimestamp{"use-fixed-timestamp", false, "Whether to use fixed timestamp from configurable instead of timestamp calculated from the data"}; - Configurable cfgTimestamp{"timestamp", 1524176895000, "Hardcoded timestamp for tests"}; + Configurable useFixedTimestamp{"useFixedTimestamp", false, "Whether to use fixed timestamp from configurable instead of timestamp calculated from the data"}; + Configurable fixedTimestamp{"fixedTimestamp", 1524176895000, "Hardcoded timestamp for tests"}; o2::ccdb::CcdbApi ccdbApi; int currentRunNumber = -1; @@ -57,16 +66,17 @@ struct PidMlEffAndPurProducer { using BigTracks = soa::Filtered>; + PidONNXModel pidModel; typedef struct nSigma_t { double tpc, tof; } nSigma_t; - nSigma_t GetNSigma(const BigTracks::iterator& track) + nSigma_t getNSigma(const BigTracks::iterator& track) { nSigma_t nSigma; - switch (TMath::Abs(cfgPid)) { + switch (std::abs(pdgPid)) { case 11: // electron nSigma.tof = track.tofNSigmaEl(); nSigma.tpc = track.tpcNSigmaEl(); @@ -92,19 +102,19 @@ struct PidMlEffAndPurProducer { return nSigma; } - bool IsNSigmaAccept(const BigTracks::iterator& track, nSigma_t& nSigma) + bool isNSigmaAccept(const BigTracks::iterator& track, const nSigma_t& nSigma) { // FIXME: for current particles it works, but there are some particles, // which can have different sign and pdgSign - int sign = cfgPid > 0 ? 1 : -1; + int sign = pdgPid > 0 ? 1 : -1; if (track.sign() != sign) return false; - if (!inPLimit(track, cfgDetectorsPLimits.value[kTPCTOF]) || tofMissing(track)) { - if (TMath::Abs(nSigma.tpc) >= cfgNSigmaCut) + if (!inPLimit(track, detectorMomentumLimits.value[kTPCTOF]) || tofMissing(track)) { + if (std::abs(nSigma.tpc) >= nSigmaCut) return false; } else { - if (TMath::Hypot(nSigma.tof, nSigma.tpc) >= cfgNSigmaCut) + if (std::hypot(nSigma.tof, nSigma.tpc) >= nSigmaCut) return false; } @@ -113,11 +123,11 @@ struct PidMlEffAndPurProducer { void init(InitContext const&) { - if (cfgUseCCDB) { - ccdbApi.init(cfgCCDBURL); + if (useCcdb) { + ccdbApi.init(ccdbUrl); } else { - pidModel = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, - cfgPid.value, cfgCertainty.value, &cfgDetectorsPLimits.value[0]); + pidModel = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, -1, + pdgPid.value, mlIdentCertaintyThreshold.value, &detectorMomentumLimits.value[0]); } const AxisSpec axisPt{100, 0, 5.0, "pt"}; @@ -151,26 +161,26 @@ struct PidMlEffAndPurProducer { void process(aod::Collisions const& collisions, BigTracks const& tracks, aod::BCsWithTimestamps const&, aod::McParticles const& mcParticles) { auto bc = collisions.iteratorAt(0).bc_as(); - if (cfgUseCCDB && bc.runNumber() != currentRunNumber) { - uint64_t timestamp = cfgUseFixedTimestamp ? cfgTimestamp.value : bc.timestamp(); - pidModel = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, timestamp, - cfgPid.value, cfgCertainty.value, &cfgDetectorsPLimits.value[0]); + if (useCcdb && bc.runNumber() != currentRunNumber) { + uint64_t timestamp = useFixedTimestamp ? fixedTimestamp.value : bc.timestamp(); + pidModel = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, timestamp, + pdgPid.value, mlIdentCertaintyThreshold.value, &detectorMomentumLimits.value[0]); } - for (auto& mcPart : mcParticles) { + for (const auto& mcPart : mcParticles) { // eta cut is included in requireGlobalTrackInFilter() so we cut it only here - if (mcPart.isPhysicalPrimary() && TMath::Abs(mcPart.eta()) < kGlobalEtaCut && mcPart.pdgCode() == pidModel.mPid) { + if (mcPart.isPhysicalPrimary() && std::abs(mcPart.eta()) < kGlobalEtaCut && mcPart.pdgCode() == pidModel.mPid) { histos.fill(HIST("hPtMCPositive"), mcPart.pt()); } } - for (auto& track : tracks) { + for (const auto& track : tracks) { if (track.has_mcParticle()) { auto mcPart = track.mcParticle(); if (mcPart.isPhysicalPrimary()) { bool mlAccepted = pidModel.applyModelBoolean(track); - nSigma_t nSigma = GetNSigma(track); - bool nSigmaAccepted = IsNSigmaAccept(track, nSigma); + nSigma_t nSigma = getNSigma(track); + bool nSigmaAccepted = isNSigmaAccept(track, nSigma); LOGF(debug, "collision id: %d track id: %d mlAccepted: %d nSigmaAccepted: %d p: %.3f; x: %.3f, y: %.3f, z: %.3f", track.collisionId(), track.index(), mlAccepted, nSigmaAccepted, track.p(), track.x(), track.y(), track.z()); diff --git a/Tools/PIDML/pidMLProducer.cxx b/Tools/PIDML/pidMlProducer.cxx similarity index 80% rename from Tools/PIDML/pidMLProducer.cxx rename to Tools/PIDML/pidMlProducer.cxx index 67cf4308a5e..332a2a8209b 100644 --- a/Tools/PIDML/pidMLProducer.cxx +++ b/Tools/PIDML/pidMlProducer.cxx @@ -9,23 +9,39 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file pidMLProducer.cxx +/// \file pidMlProducer.cxx /// \brief Produce PID ML skimmed data from MC or data files. /// /// \author Maja Kabus /// \author Marek Mytkowski -#include -#include "Framework/AnalysisTask.h" -#include "Framework/StaticFor.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/Centrality.h" +#include "Tools/PIDML/pidMl.h" +#include "Tools/PIDML/pidUtils.h" +// #include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Tools/PIDML/pidML.h" -#include "Tools/PIDML/pidUtils.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -53,36 +69,36 @@ struct PidMlProducer { using BigTracksMC = soa::Filtered>; using MyCollisionML = aod::Collisions::iterator; - using MyCollision = soa::Join::iterator; + using MyCollision = soa::Join::iterator; - static constexpr uint32_t nCharges = 2; + static constexpr uint32_t NCharges = 2; - static constexpr std::string_view histPrefixes[nCharges] = {"minus", "plus"}; + static constexpr std::string_view HistPrefixes[NCharges] = {"minus", "plus"}; // 2D - std::array, nCharges> hTPCSigvsP; - std::array, nCharges> hTOFBetavsP; - std::array, nCharges> hTOFSigvsP; - std::array, nCharges> hFilteredTOFSigvsP; - std::array, nCharges> hTRDPattvsP; - std::array, nCharges> hTRDSigvsP; + std::array, NCharges> hTPCSigvsP; + std::array, NCharges> hTOFBetavsP; + std::array, NCharges> hTOFSigvsP; + std::array, NCharges> hFilteredTOFSigvsP; + std::array, NCharges> hTRDPattvsP; + std::array, NCharges> hTRDSigvsP; // 1D - std::array, nCharges> hP; - std::array, nCharges> hPt; - std::array, nCharges> hPx; - std::array, nCharges> hPy; - std::array, nCharges> hPz; - std::array, nCharges> hX; - std::array, nCharges> hY; - std::array, nCharges> hZ; - std::array, nCharges> hAlpha; - std::array, nCharges> hTrackType; - std::array, nCharges> hTPCNClsShared; - std::array, nCharges> hDcaXY; - std::array, nCharges> hDcaZ; - std::array, nCharges> hPdgCode; - std::array, nCharges> hIsPrimary; + std::array, NCharges> hP; + std::array, NCharges> hPt; + std::array, NCharges> hPx; + std::array, NCharges> hPy; + std::array, NCharges> hPz; + std::array, NCharges> hX; + std::array, NCharges> hY; + std::array, NCharges> hZ; + std::array, NCharges> hAlpha; + std::array, NCharges> hTrackType; + std::array, NCharges> hTPCNClsShared; + std::array, NCharges> hDcaXY; + std::array, NCharges> hDcaZ; + std::array, NCharges> hPdgCode; + std::array, NCharges> hIsPrimary; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -94,33 +110,33 @@ struct PidMlProducer { template void initHistSign() { - hTPCSigvsP[prefixInd] = registry.add(Form("%s/hTPCSigvsP", histPrefixes[prefixInd].data()), genTagvsP("TPC Signal"), HistType::kTH2F, {{500, 0., 10.}, {1000, 0., 600.}}); - hTOFBetavsP[prefixInd] = registry.add(Form("%s/hTOFBetavsP", histPrefixes[prefixInd].data()), genTagvsP("TOF beta"), HistType::kTH2F, {{500, 0., 10.}, {6000, -3., 3.}}); - hTOFSigvsP[prefixInd] = registry.add(Form("%s/hTOFSigvsP", histPrefixes[prefixInd].data()), genTagvsP("TOF signal"), HistType::kTH2F, {{500, 0., 10.}, {10000, -5000., 80000.}}); - hFilteredTOFSigvsP[prefixInd] = registry.add(Form("%s/filtered/hTOFSigvsP", histPrefixes[prefixInd].data()), genTagvsP("TOF signal (filtered)"), HistType::kTH2F, {{500, 0., 10.}, {10000, -5000., 80000.}}); - hTRDPattvsP[prefixInd] = registry.add(Form("%s/hTRDPattvsP", histPrefixes[prefixInd].data()), genTagvsP("TRD pattern"), HistType::kTH2F, {{500, 0., 10.}, {110, -10., 100.}}); - hTRDSigvsP[prefixInd] = registry.add(Form("%s/hTRDSigvsP", histPrefixes[prefixInd].data()), genTagvsP("TRD signal"), HistType::kTH2F, {{500, 0., 10.}, {2500, -2., 100.}}); - hP[prefixInd] = registry.add(Form("%s/hP", histPrefixes[prefixInd].data()), "#it{p};#it{p} (GeV/#it{c})", HistType::kTH1F, {{500, 0., 6.}}); - hPt[prefixInd] = registry.add(Form("%s/hPt", histPrefixes[prefixInd].data()), "#it{p}_{t};#it{p}_{t} (GeV/#it{c})", HistType::kTH1F, {{500, 0., 6.}}); - hPx[prefixInd] = registry.add(Form("%s/hPx", histPrefixes[prefixInd].data()), "#it{p}_{x};#it{p}_{x} (GeV/#it{c})", HistType::kTH1F, {{1000, -6., 6.}}); - hPy[prefixInd] = registry.add(Form("%s/hPy", histPrefixes[prefixInd].data()), "#it{p}_{y};#it{p}_{y} (GeV/#it{c})", HistType::kTH1F, {{1000, -6., 6.}}); - hPz[prefixInd] = registry.add(Form("%s/hPz", histPrefixes[prefixInd].data()), "#it{p}_{z};#it{p}_{z} (GeV/#it{c})", HistType::kTH1F, {{1000, -6., 6.}}); - hX[prefixInd] = registry.add(Form("%s/hX", histPrefixes[prefixInd].data()), "#it{x};#it{x}", HistType::kTH1F, {{1000, -2., 2.}}); - hY[prefixInd] = registry.add(Form("%s/hY", histPrefixes[prefixInd].data()), "#it{y};#it{y}", HistType::kTH1F, {{1000, -2., 2.}}); - hZ[prefixInd] = registry.add(Form("%s/hZ", histPrefixes[prefixInd].data()), "#it{z};#it{z}", HistType::kTH1F, {{1000, -10., 10.}}); - hAlpha[prefixInd] = registry.add(Form("%s/hAlpha", histPrefixes[prefixInd].data()), "alpha;alpha", HistType::kTH1F, {{1000, -5., 5.}}); - hTrackType[prefixInd] = registry.add(Form("%s/hTrackType", histPrefixes[prefixInd].data()), "Track Type;Track Type", HistType::kTH1F, {{300, 0., 300.}}); - hTPCNClsShared[prefixInd] = registry.add(Form("%s/hTPCNClsShared", histPrefixes[prefixInd].data()), "hTPCNClsShared;hTPCNClsShared", HistType::kTH1F, {{100, 0., 100.}}); - hDcaXY[prefixInd] = registry.add(Form("%s/hDcaXY", histPrefixes[prefixInd].data()), "#it{DcaXY};#it{DcaXY}", HistType::kTH1F, {{1000, -1., 1.}}); - hDcaZ[prefixInd] = registry.add(Form("%s/hDcaZ", histPrefixes[prefixInd].data()), "#it{DcaZ};#it{DcaZ}", HistType::kTH1F, {{1000, -1., 1.}}); + hTPCSigvsP[prefixInd] = registry.add(Form("%s/hTPCSigvsP", HistPrefixes[prefixInd].data()), genTagvsP("TPC Signal"), HistType::kTH2F, {{500, 0., 10.}, {1000, 0., 600.}}); + hTOFBetavsP[prefixInd] = registry.add(Form("%s/hTOFBetavsP", HistPrefixes[prefixInd].data()), genTagvsP("TOF beta"), HistType::kTH2F, {{500, 0., 10.}, {6000, -3., 3.}}); + hTOFSigvsP[prefixInd] = registry.add(Form("%s/hTOFSigvsP", HistPrefixes[prefixInd].data()), genTagvsP("TOF signal"), HistType::kTH2F, {{500, 0., 10.}, {10000, -5000., 80000.}}); + hFilteredTOFSigvsP[prefixInd] = registry.add(Form("%s/filtered/hTOFSigvsP", HistPrefixes[prefixInd].data()), genTagvsP("TOF signal (filtered)"), HistType::kTH2F, {{500, 0., 10.}, {10000, -5000., 80000.}}); + hTRDPattvsP[prefixInd] = registry.add(Form("%s/hTRDPattvsP", HistPrefixes[prefixInd].data()), genTagvsP("TRD pattern"), HistType::kTH2F, {{500, 0., 10.}, {110, -10., 100.}}); + hTRDSigvsP[prefixInd] = registry.add(Form("%s/hTRDSigvsP", HistPrefixes[prefixInd].data()), genTagvsP("TRD signal"), HistType::kTH2F, {{500, 0., 10.}, {2500, -2., 100.}}); + hP[prefixInd] = registry.add(Form("%s/hP", HistPrefixes[prefixInd].data()), "#it{p};#it{p} (GeV/#it{c})", HistType::kTH1F, {{500, 0., 6.}}); + hPt[prefixInd] = registry.add(Form("%s/hPt", HistPrefixes[prefixInd].data()), "#it{p}_{t};#it{p}_{t} (GeV/#it{c})", HistType::kTH1F, {{500, 0., 6.}}); + hPx[prefixInd] = registry.add(Form("%s/hPx", HistPrefixes[prefixInd].data()), "#it{p}_{x};#it{p}_{x} (GeV/#it{c})", HistType::kTH1F, {{1000, -6., 6.}}); + hPy[prefixInd] = registry.add(Form("%s/hPy", HistPrefixes[prefixInd].data()), "#it{p}_{y};#it{p}_{y} (GeV/#it{c})", HistType::kTH1F, {{1000, -6., 6.}}); + hPz[prefixInd] = registry.add(Form("%s/hPz", HistPrefixes[prefixInd].data()), "#it{p}_{z};#it{p}_{z} (GeV/#it{c})", HistType::kTH1F, {{1000, -6., 6.}}); + hX[prefixInd] = registry.add(Form("%s/hX", HistPrefixes[prefixInd].data()), "#it{x};#it{x}", HistType::kTH1F, {{1000, -2., 2.}}); + hY[prefixInd] = registry.add(Form("%s/hY", HistPrefixes[prefixInd].data()), "#it{y};#it{y}", HistType::kTH1F, {{1000, -2., 2.}}); + hZ[prefixInd] = registry.add(Form("%s/hZ", HistPrefixes[prefixInd].data()), "#it{z};#it{z}", HistType::kTH1F, {{1000, -10., 10.}}); + hAlpha[prefixInd] = registry.add(Form("%s/hAlpha", HistPrefixes[prefixInd].data()), "alpha;alpha", HistType::kTH1F, {{1000, -5., 5.}}); + hTrackType[prefixInd] = registry.add(Form("%s/hTrackType", HistPrefixes[prefixInd].data()), "Track Type;Track Type", HistType::kTH1F, {{300, 0., 300.}}); + hTPCNClsShared[prefixInd] = registry.add(Form("%s/hTPCNClsShared", HistPrefixes[prefixInd].data()), "hTPCNClsShared;hTPCNClsShared", HistType::kTH1F, {{100, 0., 100.}}); + hDcaXY[prefixInd] = registry.add(Form("%s/hDcaXY", HistPrefixes[prefixInd].data()), "#it{DcaXY};#it{DcaXY}", HistType::kTH1F, {{1000, -1., 1.}}); + hDcaZ[prefixInd] = registry.add(Form("%s/hDcaZ", HistPrefixes[prefixInd].data()), "#it{DcaZ};#it{DcaZ}", HistType::kTH1F, {{1000, -1., 1.}}); } template void initHistSignMC() { initHistSign(); - hPdgCode[prefixInd] = registry.add(Form("%s/hPdgCode", histPrefixes[prefixInd].data()), "#it{PdgCode};#it{PdgCode}", HistType::kTH1F, {{2500, 0., 2500.}}); - hIsPrimary[prefixInd] = registry.add(Form("%s/hIsPrimary", histPrefixes[prefixInd].data()), "#it{IsPrimary};#it{IsPrimary}", HistType::kTH1F, {{4, -0.5, 1.5}}); + hPdgCode[prefixInd] = registry.add(Form("%s/hPdgCode", HistPrefixes[prefixInd].data()), "#it{PdgCode};#it{PdgCode}", HistType::kTH1F, {{2500, 0., 2500.}}); + hIsPrimary[prefixInd] = registry.add(Form("%s/hIsPrimary", HistPrefixes[prefixInd].data()), "#it{IsPrimary};#it{IsPrimary}", HistType::kTH1F, {{4, -0.5, 1.5}}); } template @@ -235,8 +251,7 @@ struct PidMlProducer { void processDataAll(MyCollision const& collision, BigTracksData const& tracks) { for (const auto& track : tracks) { - pidTracksTableData(collision.centRun2V0M(), - collision.multFV0A(), collision.multFV0C(), collision.multFV0M(), + pidTracksTableData(collision.multFV0A(), collision.multFV0C(), collision.multFV0M(), collision.multFT0A(), collision.multFT0C(), collision.multFT0M(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multTPC(), @@ -301,8 +316,7 @@ struct PidMlProducer { const auto mcParticle = track.mcParticle_as(); uint8_t isPrimary = static_cast(mcParticle.isPhysicalPrimary()); uint32_t pdgCode = mcParticle.pdgCode(); - pidTracksTableMC(collision.centRun2V0M(), - collision.multFV0A(), collision.multFV0C(), collision.multFV0M(), + pidTracksTableMC(collision.multFV0A(), collision.multFV0C(), collision.multFV0M(), collision.multFT0A(), collision.multFT0C(), collision.multFT0M(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multTPC(), diff --git a/Tools/PIDML/pidOnnxInterface.h b/Tools/PIDML/pidOnnxInterface.h index 03e7bc19146..6724e5c5167 100644 --- a/Tools/PIDML/pidOnnxInterface.h +++ b/Tools/PIDML/pidOnnxInterface.h @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file pidONNXInterface.h +/// \file pidOnnxInterface.h /// \brief A class that wraps PID ML ONNX model. See README.md for more detailed instructions. /// /// \author Maja Kabus @@ -17,25 +17,29 @@ #ifndef TOOLS_PIDML_PIDONNXINTERFACE_H_ #define TOOLS_PIDML_PIDONNXINTERFACE_H_ -#include -#include +#include "Tools/PIDML/pidOnnxModel.h" +// +#include +#include +#include + +#include +#include #include +#include #include -#include "Framework/Array2D.h" -#include "Tools/PIDML/pidOnnxModel.h" - namespace pidml_pt_cuts { -static constexpr int nPids = 6; -static constexpr int nCutVars = kNDetectors; -constexpr int pids[nPids] = {211, 321, 2212, -211, -321, -2212}; -auto pids_v = std::vector{pids, pids + nPids}; -constexpr double certainties[nPids] = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5}; -auto certainties_v = std::vector{certainties, certainties + nPids}; +static constexpr int NPids = 6; +static constexpr int NCutVars = kNDetectors; +constexpr int Pids[NPids] = {211, 321, 2212, -211, -321, -2212}; +auto pidsV = std::vector{Pids, Pids + NPids}; +constexpr double Certainties[NPids] = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5}; +auto certaintiesV = std::vector{Certainties, Certainties + NPids}; // default values for the cuts -constexpr double cuts[nPids][nCutVars] = {{0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}}; +constexpr double Cuts[NPids][NCutVars] = {{0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}, {0.0, 0.5, 0.8}}; // row labels static const std::vector pidLabels = { "211", "321", "2212", "0211", "0321", "02212"}; @@ -45,16 +49,17 @@ static const std::vector cutVarLabels = { } // namespace pidml_pt_cuts +template struct PidONNXInterface { - PidONNXInterface(std::string& localPath, std::string& ccdbPath, bool useCCDB, o2::ccdb::CcdbApi& ccdbApi, uint64_t timestamp, std::vector const& pids, o2::framework::LabeledArray const& pLimits, std::vector const& minCertainties, bool autoMode) : mNPids{pids.size()}, mPLimits{pLimits} + PidONNXInterface(std::string& localPath, std::string& ccdbPath, bool useCCDB, o2::ccdb::CcdbApi& ccdbApi, uint64_t timestamp, std::vector const& Pids, o2::framework::LabeledArray const& pLimits, std::vector const& minCertainties, bool autoMode) : mNPids{Pids.size()}, mPLimits{pLimits} { - if (pids.size() == 0) { + if (Pids.size() == 0) { LOG(fatal) << "PID ML Interface needs at least 1 output pid to predict"; } std::set tmp; - for (auto& pid : pids) { + for (const auto& pid : Pids) { if (!tmp.insert(pid).second) { - LOG(fatal) << "PID ML Interface: output pids cannot repeat!"; + LOG(fatal) << "PID ML Interface: output Pids cannot repeat!"; } } @@ -63,12 +68,12 @@ struct PidONNXInterface { fillDefaultConfiguration(minCertaintiesFilled); } else { if (minCertainties.size() != mNPids) { - LOG(fatal) << "PID ML Interface: min certainties vector must be of the same size as the output pids vector"; + LOG(fatal) << "PID ML Interface: min Certainties vector must be of the same size as the output Pids vector"; } minCertaintiesFilled = minCertainties; } for (std::size_t i = 0; i < mNPids; i++) { - mModels.emplace_back(localPath, ccdbPath, useCCDB, ccdbApi, timestamp, pids[i], minCertaintiesFilled[i], mPLimits[i]); + mModels.emplace_back(localPath, ccdbPath, useCCDB, ccdbApi, timestamp, Pids[i], minCertaintiesFilled[i], mPLimits[i]); } } PidONNXInterface() = default; @@ -78,8 +83,7 @@ struct PidONNXInterface { PidONNXInterface& operator=(const PidONNXInterface&) = delete; ~PidONNXInterface() = default; - template - float applyModel(const T& track, int pid) + float applyModel(const T::iterator& track, int pid) { for (std::size_t i = 0; i < mNPids; i++) { if (mModels[i].mPid == pid) { @@ -90,8 +94,7 @@ struct PidONNXInterface { return -1.0f; } - template - bool applyModelBoolean(const T& track, int pid) + bool applyModelBoolean(const T::iterator& track, int pid) { for (std::size_t i = 0; i < mNPids; i++) { if (mModels[i].mPid == pid) { @@ -106,12 +109,12 @@ struct PidONNXInterface { void fillDefaultConfiguration(std::vector& minCertainties) { // FIXME: A more sophisticated strategy should be based on pid values as well - mPLimits = o2::framework::LabeledArray{pidml_pt_cuts::cuts[0], pidml_pt_cuts::nPids, pidml_pt_cuts::nCutVars, pidml_pt_cuts::pidLabels, pidml_pt_cuts::cutVarLabels}; + mPLimits = o2::framework::LabeledArray{pidml_pt_cuts::Cuts[0], pidml_pt_cuts::NPids, pidml_pt_cuts::NCutVars, pidml_pt_cuts::pidLabels, pidml_pt_cuts::cutVarLabels}; minCertainties = std::vector(mNPids, 0.5); } - std::vector mModels; - std::size_t mNPids; + std::vector> mModels; + std::size_t mNPids{0}; o2::framework::LabeledArray mPLimits; }; #endif // TOOLS_PIDML_PIDONNXINTERFACE_H_ diff --git a/Tools/PIDML/pidOnnxModel.h b/Tools/PIDML/pidOnnxModel.h index 207bc18cd8e..4ee88106ab0 100644 --- a/Tools/PIDML/pidOnnxModel.h +++ b/Tools/PIDML/pidOnnxModel.h @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file pidONNXModel.h +/// \file pidOnnxModel.h /// \brief A class that wraps PID ML ONNX model. See README.md for more detailed instructions. /// /// \author Maja Kabus @@ -17,27 +17,31 @@ #ifndef TOOLS_PIDML_PIDONNXMODEL_H_ #define TOOLS_PIDML_PIDONNXMODEL_H_ +#include "Tools/PIDML/pidUtils.h" +// +#include +#include +#include + +#include +#include +#include +#include + +#include #include +#include #include +#include +#include #include -#include -#include #include -#include #include +#include +#include +#include +#include #include -#if __has_include() -#include -#else -#include -#endif - -#include "rapidjson/document.h" -#include "rapidjson/filereadstream.h" -#include "CCDB/CcdbApi.h" -#include "Tools/PIDML/pidUtils.h" - -using namespace pidml::pidutils; enum PidMLDetector { kTPCOnly = 0, @@ -46,17 +50,19 @@ enum PidMLDetector { kNDetectors ///< number of available detectors configurations }; +using MomentumLimitsMatrix = std::array; + namespace pidml_pt_cuts { // TODO: for now first limit wouldn't be used, // network needs TPC, so we can either do not cut it by p or return 0.0f as prediction -constexpr std::array defaultModelPLimits({0.0, 0.5, 0.8}); +constexpr MomentumLimitsMatrix defaultModelPLimits({0.0, 0.5, 0.8}); } // namespace pidml_pt_cuts // TODO: Copied from cefpTask, shall we put it in some common utils code? namespace { -bool readJsonFile(const std::string& config, rapidjson::Document& d) +bool readJsonFile(std::string const& config, rapidjson::Document& d) { FILE* fp = fopen(config.data(), "rb"); if (!fp) { @@ -73,9 +79,10 @@ bool readJsonFile(const std::string& config, rapidjson::Document& d) } } // namespace +template struct PidONNXModel { public: - PidONNXModel(std::string& localPath, std::string& ccdbPath, bool useCCDB, o2::ccdb::CcdbApi& ccdbApi, uint64_t timestamp, + PidONNXModel(std::string const& localPath, std::string const& ccdbPath, bool useCCDB, o2::ccdb::CcdbApi const& ccdbApi, uint64_t timestamp, int pid, double minCertainty, const double* pLimits = &pidml_pt_cuts::defaultModelPLimits[0]) : mPid(pid), mMinCertainty(minCertainty), mPLimits(pLimits, pLimits + kNDetectors) { @@ -87,19 +94,9 @@ struct PidONNXModel { Ort::SessionOptions sessionOptions; mEnv = std::make_shared(ORT_LOGGING_LEVEL_WARNING, "pid-onnx-inferer"); LOG(info) << "Loading ONNX model from file: " << modelFile; -#if __has_include() - mSession.reset(new Ort::Experimental::Session{*mEnv, modelFile, sessionOptions}); -#else mSession.reset(new Ort::Session{*mEnv, modelFile.c_str(), sessionOptions}); -#endif LOG(info) << "ONNX model loaded"; -#if __has_include() - mInputNames = mSession->GetInputNames(); - mInputShapes = mSession->GetInputShapes(); - mOutputNames = mSession->GetOutputNames(); - mOutputShapes = mSession->GetOutputShapes(); -#else Ort::AllocatorWithDefaultOptions tmpAllocator; for (size_t i = 0; i < mSession->GetInputCount(); ++i) { mInputNames.push_back(mSession->GetInputNameAllocated(i, tmpAllocator).get()); @@ -113,7 +110,6 @@ struct PidONNXModel { for (size_t i = 0; i < mSession->GetOutputCount(); ++i) { mOutputShapes.emplace_back(mSession->GetOutputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape()); } -#endif LOG(debug) << "Input Node Name/Shape (" << mInputNames.size() << "):"; for (size_t i = 0; i < mInputNames.size(); i++) { @@ -135,20 +131,18 @@ struct PidONNXModel { PidONNXModel& operator=(const PidONNXModel&) = delete; ~PidONNXModel() = default; - template - float applyModel(const T& track) + float applyModel(const typename T::iterator& track) { return getModelOutput(track); } - template - bool applyModelBoolean(const T& track) + bool applyModelBoolean(const typename T::iterator& track) { return getModelOutput(track) >= mMinCertainty; } - int mPid; - double mMinCertainty; + int mPid{0}; + double mMinCertainty{0}; private: void getModelPaths(std::string const& path, std::string& modelDir, std::string& modelFile, std::string& modelPath, int pid, std::string const& ext) @@ -166,7 +160,7 @@ struct PidONNXModel { modelPath = modelDir + "/" + modelFile; } - void downloadFromCCDB(o2::ccdb::CcdbApi& ccdbApi, std::string const& ccdbFile, uint64_t timestamp, std::string const& localDir, std::string const& localFile) + void downloadFromCCDB(o2::ccdb::CcdbApi const& ccdbApi, std::string const& ccdbFile, uint64_t timestamp, std::string const& localDir, std::string const& localFile) { std::map metadata; bool retrieveSuccess = ccdbApi.retrieveBlob(ccdbFile, localDir, metadata, timestamp, false, localFile); @@ -178,7 +172,7 @@ struct PidONNXModel { } } - void loadInputFiles(std::string const& localPath, std::string const& ccdbPath, bool useCCDB, o2::ccdb::CcdbApi& ccdbApi, uint64_t timestamp, int pid, std::string& modelPath) + void loadInputFiles(std::string const& localPath, std::string const& ccdbPath, bool useCCDB, o2::ccdb::CcdbApi const& ccdbApi, uint64_t timestamp, int pid, std::string& modelPath) { rapidjson::Document trainColumnsDoc; rapidjson::Document scalingParamsDoc; @@ -202,91 +196,83 @@ struct PidONNXModel { LOG(info) << "Using configuration files: " << localTrainColumnsPath << ", " << localScalingParamsPath; if (readJsonFile(localTrainColumnsPath, trainColumnsDoc)) { - for (auto& param : trainColumnsDoc["columns_for_training"].GetArray()) { - mTrainColumns.emplace_back(param.GetString()); + for (const auto& param : trainColumnsDoc["columns_for_training"].GetArray()) { + auto columnLabel = param.GetString(); + mTrainColumns.emplace_back(columnLabel); + mGetters.emplace_back(o2::soa::row_helpers::getColumnGetterByLabel(columnLabel)); } } if (readJsonFile(localScalingParamsPath, scalingParamsDoc)) { - for (auto& param : scalingParamsDoc["data"].GetArray()) { + for (const auto& param : scalingParamsDoc["data"].GetArray()) { mScalingParams[param[0].GetString()] = std::make_pair(param[1].GetFloat(), param[2].GetFloat()); } } } - template - std::vector createInputsSingle(const T& track) + static float scale(float value, const std::pair& scalingParams) { - // TODO: Hardcoded for now. Planning to implement RowView extension to get runtime access to selected columns - // sign is short, trackType and tpcNClsShared uint8_t + return (value - scalingParams.first) / scalingParams.second; + } - float scaledTPCSignal = (track.tpcSignal() - mScalingParams.at("fTPCSignal").first) / mScalingParams.at("fTPCSignal").second; + std::vector getValues(const typename T::iterator& track) + { + std::vector output; + output.reserve(mTrainColumns.size()); - std::vector inputValues{scaledTPCSignal}; + bool useTOF = !pidml::pidutils::tofMissing(track) && pidml::pidutils::inPLimit(track, mPLimits[kTPCTOF]); + bool useTRD = !pidml::pidutils::trdMissing(track) && pidml::pidutils::inPLimit(track, mPLimits[kTPCTOFTRD]); - // When TRD Signal shouldn't be used we pass quiet_NaNs to the network - if (!inPLimit(track, mPLimits[kTPCTOFTRD]) || trdMissing(track)) { - inputValues.push_back(std::numeric_limits::quiet_NaN()); - inputValues.push_back(std::numeric_limits::quiet_NaN()); - } else { - float scaledTRDSignal = (track.trdSignal() - mScalingParams.at("fTRDSignal").first) / mScalingParams.at("fTRDSignal").second; - inputValues.push_back(scaledTRDSignal); - inputValues.push_back(track.trdPattern()); - } + for (uint32_t i = 0; i < mTrainColumns.size(); ++i) { + auto& columnLabel = mTrainColumns[i]; - // When TOF Signal shouldn't be used we pass quiet_NaNs to the network - if (!inPLimit(track, mPLimits[kTPCTOF]) || tofMissing(track)) { - inputValues.push_back(std::numeric_limits::quiet_NaN()); - inputValues.push_back(std::numeric_limits::quiet_NaN()); - } else { - float scaledTOFSignal = (track.tofSignal() - mScalingParams.at("fTOFSignal").first) / mScalingParams.at("fTOFSignal").second; - float scaledBeta = (track.beta() - mScalingParams.at("fBeta").first) / mScalingParams.at("fBeta").second; - inputValues.push_back(scaledTOFSignal); - inputValues.push_back(scaledBeta); - } + if ( + ((columnLabel == "fTRDSignal" || columnLabel == "fTRDPattern") && !useTRD) || + ((columnLabel == "fTOFSignal" || columnLabel == "fBeta") && !useTOF)) { + output.push_back(std::numeric_limits::quiet_NaN()); + continue; + } + + std::optional> scalingParams = std::nullopt; + + auto scalingParamsEntry = mScalingParams.find(columnLabel); + if (scalingParamsEntry != mScalingParams.end()) { + scalingParams = scalingParamsEntry->second; + } - float scaledX = (track.x() - mScalingParams.at("fX").first) / mScalingParams.at("fX").second; - float scaledY = (track.y() - mScalingParams.at("fY").first) / mScalingParams.at("fY").second; - float scaledZ = (track.z() - mScalingParams.at("fZ").first) / mScalingParams.at("fZ").second; - float scaledAlpha = (track.alpha() - mScalingParams.at("fAlpha").first) / mScalingParams.at("fAlpha").second; - float scaledTPCNClsShared = (static_cast(track.tpcNClsShared()) - mScalingParams.at("fTPCNClsShared").first) / mScalingParams.at("fTPCNClsShared").second; - float scaledDcaXY = (track.dcaXY() - mScalingParams.at("fDcaXY").first) / mScalingParams.at("fDcaXY").second; - float scaledDcaZ = (track.dcaZ() - mScalingParams.at("fDcaZ").first) / mScalingParams.at("fDcaZ").second; + float value = mGetters[i](track); - inputValues.insert(inputValues.end(), {track.p(), track.pt(), track.px(), track.py(), track.pz(), static_cast(track.sign()), scaledX, scaledY, scaledZ, scaledAlpha, static_cast(track.trackType()), scaledTPCNClsShared, scaledDcaXY, scaledDcaZ}); + if (scalingParams) { + value = scale(value, scalingParams.value()); + } + + output.push_back(value); + } - return inputValues; + return output; } - template - float getModelOutput(const T& track) + float getModelOutput(const typename T::iterator& track) { // First rank of the expected model input is -1 which means that it is dynamic axis. // Axis is exported as dynamic to make it possible to run model inference with the batch of // tracks at once in the future (batch would need to have the same amount of quiet_NaNs in each row). // For now we hardcode 1. - static constexpr int64_t batch_size = 1; - auto input_shape = mInputShapes[0]; - input_shape[0] = batch_size; + static constexpr int64_t BatchSize = 1; + auto inputShape = mInputShapes[0]; + inputShape[0] = BatchSize; - std::vector inputTensorValues = createInputsSingle(track); + std::vector inputTensorValues = getValues(track); std::vector inputTensors; -#if __has_include() - inputTensors.emplace_back(Ort::Experimental::Value::CreateTensor(inputTensorValues.data(), inputTensorValues.size(), input_shape)); -#else - Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault); - inputTensors.emplace_back(Ort::Value::CreateTensor(mem_info, inputTensorValues.data(), inputTensorValues.size(), input_shape.data(), input_shape.size())); -#endif + Ort::MemoryInfo memInfo = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault); + inputTensors.emplace_back(Ort::Value::CreateTensor(memInfo, inputTensorValues.data(), inputTensorValues.size(), inputShape.data(), inputShape.size())); // Double-check the dimensions of the input tensor assert(inputTensors[0].IsTensor() && - inputTensors[0].GetTensorTypeAndShapeInfo().GetShape() == input_shape); + inputTensors[0].GetTensorTypeAndShapeInfo().GetShape() == inputShape); LOG(debug) << "input tensor shape: " << printShape(inputTensors[0].GetTensorTypeAndShapeInfo().GetShape()); try { -#if __has_include() - auto outputTensors = mSession->Run(mInputNames, inputTensors, mOutputNames); -#else Ort::RunOptions runOptions; std::vector inputNamesChar(mInputNames.size(), nullptr); std::transform(std::begin(mInputNames), std::end(mInputNames), std::begin(inputNamesChar), @@ -296,15 +282,14 @@ struct PidONNXModel { std::transform(std::begin(mOutputNames), std::end(mOutputNames), std::begin(outputNamesChar), [&](const std::string& str) { return str.c_str(); }); auto outputTensors = mSession->Run(runOptions, inputNamesChar.data(), inputTensors.data(), inputTensors.size(), outputNamesChar.data(), outputNamesChar.size()); -#endif // Double-check the dimensions of the output tensors // The number of output tensors is equal to the number of output nodes specified in the Run() call assert(outputTensors.size() == mOutputNames.size() && outputTensors[0].IsTensor()); LOG(debug) << "output tensor shape: " << printShape(outputTensors[0].GetTensorTypeAndShapeInfo().GetShape()); - const float* output_value = outputTensors[0].GetTensorData(); - float certainty = *output_value; + const float* outputValue = outputTensors[0].GetTensorData(); + float certainty = *outputValue; return certainty; } catch (const Ort::Exception& exception) { LOG(error) << "Error running model inference: " << exception.what(); @@ -323,15 +308,12 @@ struct PidONNXModel { } std::vector mTrainColumns; + std::vector mGetters; std::map> mScalingParams; std::shared_ptr mEnv = nullptr; // No empty constructors for Session, we need a pointer -#if __has_include() - std::shared_ptr mSession = nullptr; -#else std::shared_ptr mSession = nullptr; -#endif std::vector mPLimits; std::vector mInputNames; diff --git a/Tools/PIDML/qaPid.cxx b/Tools/PIDML/qaPid.cxx index 4efbbbc077a..25fba1ee6a0 100644 --- a/Tools/PIDML/qaPid.cxx +++ b/Tools/PIDML/qaPid.cxx @@ -9,26 +9,42 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// +/// \file qaPid.cxx /// \brief Task to check PID efficiency /// \author Łukasz Sawicki /// \since -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StaticFor.h" +#include "Common/DataModel/PIDResponseCombined.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" -#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -struct EvaluatePid { +struct QaPid { double combinedSignal(float val1, float val2) { - return sqrt(pow(val1, 2) + pow(val2, 2)); + return std::sqrt(std::pow(val1, 2) + std::pow(val2, 2)); } int indexOfSmallestElement(const float array[], int size) @@ -41,113 +57,119 @@ struct EvaluatePid { return index; } + enum ContaminationIn { + kPion, + kProton, + kKaon + }; + void fillContaminationRegistry(int i, int pdgCode, double pt) { - if (i == 0) { - if (pdgCode == 211) { + if (i == ContaminationIn::kPion) { + if (pdgCode == PDG_t::kPiPlus) { histReg.fill(HIST("contamination/211in211"), pt); } - if (pdgCode == -211) { + if (pdgCode == PDG_t::kPiMinus) { histReg.fill(HIST("contamination/0211in211"), pt); } - if (pdgCode == 2212) { + if (pdgCode == PDG_t::kProton) { histReg.fill(HIST("contamination/2212in211"), pt); } - if (pdgCode == -2212) { + if (pdgCode == PDG_t::kProtonBar) { histReg.fill(HIST("contamination/02212in211"), pt); } - if (pdgCode == 321) { + if (pdgCode == PDG_t::kKPlus) { histReg.fill(HIST("contamination/321in211"), pt); } - if (pdgCode == -321) { + if (pdgCode == PDG_t::kKMinus) { histReg.fill(HIST("contamination/0321in211"), pt); } - if (pdgCode == 11) { + if (pdgCode == PDG_t::kElectron) { histReg.fill(HIST("contamination/11in211"), pt); } - if (pdgCode == -11) { + if (pdgCode == PDG_t::kPositron) { histReg.fill(HIST("contamination/011in211"), pt); } - if (pdgCode == 13) { + if (pdgCode == PDG_t::kMuonMinus) { histReg.fill(HIST("contamination/13in211"), pt); } - if (pdgCode == -13) { + if (pdgCode == PDG_t::kMuonPlus) { histReg.fill(HIST("contamination/013in211"), pt); } - } else if (i == 1) { - if (pdgCode == 211) { + } else if (i == ContaminationIn::kProton) { + if (pdgCode == PDG_t::kPiPlus) { histReg.fill(HIST("contamination/211in2212"), pt); } - if (pdgCode == -211) { + if (pdgCode == PDG_t::kPiMinus) { histReg.fill(HIST("contamination/0211in2212"), pt); } - if (pdgCode == 2212) { + if (pdgCode == PDG_t::kProton) { histReg.fill(HIST("contamination/2212in2212"), pt); } - if (pdgCode == -2212) { + if (pdgCode == PDG_t::kProtonBar) { histReg.fill(HIST("contamination/02212in2212"), pt); } - if (pdgCode == 321) { + if (pdgCode == PDG_t::kKPlus) { histReg.fill(HIST("contamination/321in2212"), pt); } - if (pdgCode == -321) { + if (pdgCode == PDG_t::kKMinus) { histReg.fill(HIST("contamination/0321in2212"), pt); } - if (pdgCode == 11) { + if (pdgCode == PDG_t::kElectron) { histReg.fill(HIST("contamination/11in2212"), pt); } - if (pdgCode == -11) { + if (pdgCode == PDG_t::kPositron) { histReg.fill(HIST("contamination/011in2212"), pt); } - if (pdgCode == 13) { + if (pdgCode == PDG_t::kMuonMinus) { histReg.fill(HIST("contamination/13in2212"), pt); } - if (pdgCode == -13) { + if (pdgCode == PDG_t::kMuonPlus) { histReg.fill(HIST("contamination/013in2212"), pt); } - } else if (i == 2) { - if (pdgCode == 211) { + } else if (i == ContaminationIn::kKaon) { + if (pdgCode == PDG_t::kPiPlus) { histReg.fill(HIST("contamination/211in321"), pt); } - if (pdgCode == -211) { + if (pdgCode == PDG_t::kPiMinus) { histReg.fill(HIST("contamination/0211in321"), pt); } - if (pdgCode == 2212) { + if (pdgCode == PDG_t::kProton) { histReg.fill(HIST("contamination/2212in321"), pt); } - if (pdgCode == -2212) { + if (pdgCode == PDG_t::kProtonBar) { histReg.fill(HIST("contamination/02212in321"), pt); } - if (pdgCode == 321) { + if (pdgCode == PDG_t::kKPlus) { histReg.fill(HIST("contamination/321in321"), pt); } - if (pdgCode == -321) { + if (pdgCode == PDG_t::kKMinus) { histReg.fill(HIST("contamination/0321in321"), pt); } - if (pdgCode == 11) { + if (pdgCode == PDG_t::kElectron) { histReg.fill(HIST("contamination/11in321"), pt); } - if (pdgCode == -11) { + if (pdgCode == PDG_t::kPositron) { histReg.fill(HIST("contamination/011in321"), pt); } - if (pdgCode == 13) { + if (pdgCode == PDG_t::kMuonMinus) { histReg.fill(HIST("contamination/13in321"), pt); } - if (pdgCode == -13) { + if (pdgCode == PDG_t::kMuonPlus) { histReg.fill(HIST("contamination/013in321"), pt); } } @@ -157,13 +179,13 @@ struct EvaluatePid { void fillPidHistos(const T& track, const int pdgCode, bool isPidTrue) { if (isPidTrue) { - histReg.fill(HIST(pidTrueRegistryNames[i]), track.pt()); + histReg.fill(HIST(PidTrueRegistryNames[i]), track.pt()); histReg.fill(HIST(TPCPidTrueRegistryNames[i]), track.p(), track.tpcSignal()); histReg.fill(HIST("TPCSignalPidTrue"), track.p(), track.tpcSignal()); histReg.fill(HIST("TOFSignalPidTrue"), track.p(), track.beta()); histReg.fill(HIST(TOFPidTrueRegistryNames[i]), track.p(), track.beta()); } else { - histReg.fill(HIST(pidFalseRegistryNames[i]), track.pt()); + histReg.fill(HIST(PidFalseRegistryNames[i]), track.pt()); histReg.fill(HIST(TPCPidFalseRegistryNames[i]), track.p(), track.tpcSignal()); histReg.fill(HIST("TPCSignalPidFalse"), track.p(), track.tpcSignal()); histReg.fill(HIST("TOFSignalPidFalse"), track.p(), track.beta()); @@ -177,8 +199,8 @@ struct EvaluatePid { // nb of particles (5 particles - Pi, Pr, Ka, e, mu, and 5 antiparticles) static const int numParticles = 10; - static constexpr std::string_view pidTrueRegistryNames[numParticles] = {"pidTrue/211", "pidTrue/2212", "pidTrue/321", "pidTrue/11", "pidTrue/13", "pidTrue/0211", "pidTrue/02212", "pidTrue/0321", "pidTrue/011", "pidTrue/013"}; - static constexpr std::string_view pidFalseRegistryNames[numParticles] = {"pidFalse/211", "pidFalse/2212", "pidFalse/321", "pidFalse/11", "pidFalse/13", "pidFalse/0211", "pidFalse/02212", "pidFalse/0321", "pidFalse/011", "pidFalse/013"}; + static constexpr std::string_view PidTrueRegistryNames[numParticles] = {"pidTrue/211", "pidTrue/2212", "pidTrue/321", "pidTrue/11", "pidTrue/13", "pidTrue/0211", "pidTrue/02212", "pidTrue/0321", "pidTrue/011", "pidTrue/013"}; + static constexpr std::string_view PidFalseRegistryNames[numParticles] = {"pidFalse/211", "pidFalse/2212", "pidFalse/321", "pidFalse/11", "pidFalse/13", "pidFalse/0211", "pidFalse/02212", "pidFalse/0321", "pidFalse/011", "pidFalse/013"}; static constexpr std::string_view TPCPidTrueRegistryNames[numParticles] = {"TPCPidTrue/211", "TPCPidTrue/2212", "TPCPidTrue/321", "TPCPidTrue/11", "TPCPidTrue/13", "TPCPidTrue/0211", "TPCPidTrue/02212", "TPCPidTrue/0321", "TPCPidTrue/011", "TPCPidTrue/013"}; static constexpr std::string_view TPCPidFalseRegistryNames[numParticles] = {"TPCPidFalse/211", "TPCPidFalse/2212", "TPCPidFalse/321", "TPCPidFalse/11", "TPCPidFalse/13", "TPCPidFalse/0211", "TPCPidFalse/02212", "TPCPidFalse/0321", "TPCPidFalse/011", "TPCPidFalse/013"}; @@ -186,13 +208,13 @@ struct EvaluatePid { static constexpr std::string_view TOFPidTrueRegistryNames[numParticles] = {"TOFPidTrue/211", "TOFPidTrue/2212", "TOFPidTrue/321", "TOFPidTrue/11", "TOFPidTrue/13", "TOFPidTrue/0211", "TOFPidTrue/02212", "TOFPidTrue/0321", "TOFPidTrue/011", "TOFPidTrue/013"}; static constexpr std::string_view TOFPidFalseRegistryNames[numParticles] = {"TOFPidFalse/211", "TOFPidFalse/2212", "TOFPidFalse/321", "TOFPidFalse/11", "TOFPidFalse/13", "TOFPidFalse/0211", "TOFPidFalse/02212", "TOFPidFalse/0321", "TOFPidFalse/011", "TOFPidFalse/013"}; - static constexpr int pdgCodes[numParticles] = {211, 2212, 321, 11, 13, -211, -2212, -321, -11, -13}; - static constexpr int pidToPdg[numParticles] = {11, 13, 211, 321, 2212, -11, -13, -211, -321, -2212}; - // charge with index i corresponds to i-th particle from pdgCodes array - static constexpr int particleCharge[numParticles] = {1, 1, 1, -1, -1, -1, -1, -1, 1, 1}; + static constexpr int PdgCodes[numParticles] = {211, 2212, 321, 11, 13, -211, -2212, -321, -11, -13}; + static constexpr int PidToPdg[numParticles] = {11, 13, 211, 321, 2212, -11, -13, -211, -321, -2212}; + // charge with index i corresponds to i-th particle from PdgCodes array + static constexpr int ParticleCharge[numParticles] = {1, 1, 1, -1, -1, -1, -1, -1, 1, 1}; // momentum value when to switch from pid based only on TPC (below the value) to combination of TPC and TOF (above the value) // i-th momentum corresponds to the i-th particle - static constexpr float pSwitch[numParticles] = {0.5, 0.8, 0.5, 0.5, 0.5, 0.5, 0.8, 0.5, 0.5, 0.5}; + static constexpr float PSwitch[numParticles] = {0.5, 0.8, 0.5, 0.5, 0.5, 0.5, 0.8, 0.5, 0.5, 0.5}; static const int maxP = 5; // nb of bins for TH1 hists @@ -323,26 +345,26 @@ struct EvaluatePid { {"TOFPidFalse/011", "PID false e^{+};p (GeV/c); TOF #beta", {HistType::kTH2F, {{binsNb2D, 0.2, 10}, {110, 0, 1.1}}}}}}; template - void pidSimple(const T& track, const int pdgCode, const float tpcNSigmas[], const float tofNSigmas[], int /*arrLen*/) + void pidSimple(const T& track, const int pdgCode, const float tpcNSigmas[], const float tofNSigmas[]) { /* Simplest possible PID, accept particle when: TPCSignal < X if p < Value or - sqrt(TPCSignal^2 + TOFSignal^2) < X if p > Value + std::sqrt(TPCSignal^2 + TOFSignal^2) < X if p > Value */ const float p = track.p(); - if ((p < pSwitch[i]) & (track.sign() == particleCharge[i])) { - if (abs(tpcNSigmas[i]) < nsigmacut.value) { - if (pdgCode == pdgCodes[i]) { + if ((p < PSwitch[i]) & (track.sign() == ParticleCharge[i])) { + if (std::abs(tpcNSigmas[i]) < nsigmacut.value) { + if (pdgCode == PdgCodes[i]) { fillPidHistos(track, pdgCode, true); } else { fillPidHistos(track, pdgCode, false); } } - } else if ((p >= pSwitch[i]) & (track.sign() == particleCharge[i])) { - if (sqrt(pow(tpcNSigmas[i], 2) + pow(tofNSigmas[i], 2)) < nsigmacut.value) { - if (pdgCode == pdgCodes[i]) { + } else if ((p >= PSwitch[i]) & (track.sign() == ParticleCharge[i])) { + if (std::sqrt(std::pow(tpcNSigmas[i], 2) + std::pow(tofNSigmas[i], 2)) < nsigmacut.value) { + if (pdgCode == PdgCodes[i]) { fillPidHistos(track, pdgCode, true); } else { fillPidHistos(track, pdgCode, false); @@ -351,36 +373,36 @@ struct EvaluatePid { } } - template - void pidMinStrategy(const T& track, const int pdgCode, const float tpcNSigmas[], const float tofNSigmas[], int arrLen) + template + void pidMinStrategy(const T& track, const int pdgCode, const float tpcNSigmas[], const float tofNSigmas[]) { const float p = track.p(); // list of Nsigmas for particles - float particleNSigma[arrLen]; + float particleNSigma[kArrLen]; // calculate Nsigmas for every particle - for (int j = 0; j < arrLen; ++j) { - if (p < pSwitch[j]) { - particleNSigma[j] = abs(tpcNSigmas[j]); - } else if (p >= pSwitch[j]) { + for (int j = 0; j < kArrLen; ++j) { + if (p < PSwitch[j]) { + particleNSigma[j] = std::abs(tpcNSigmas[j]); + } else { particleNSigma[j] = combinedSignal(tpcNSigmas[j], tofNSigmas[j]); } } - if ((p < pSwitch[i]) & (track.sign() == particleCharge[i])) { - float tmp_NSigma = abs(tpcNSigmas[i]); - if ((tmp_NSigma < nsigmacut.value) & (indexOfSmallestElement(particleNSigma, arrLen) == i)) { - if (pdgCode == pdgCodes[i]) { + if ((p < PSwitch[i]) & (track.sign() == ParticleCharge[i])) { + float tmpNSigma = std::abs(tpcNSigmas[i]); + if ((tmpNSigma < nsigmacut.value) & (indexOfSmallestElement(particleNSigma, kArrLen) == i)) { + if (pdgCode == PdgCodes[i]) { fillPidHistos(track, pdgCode, true); } else { fillPidHistos(track, pdgCode, false); } } - } else if ((p >= pSwitch[i]) & (track.sign() == particleCharge[i])) { - float tmp_NSigma = combinedSignal(tpcNSigmas[i], tofNSigmas[i]); - if ((tmp_NSigma < nsigmacut.value) & (indexOfSmallestElement(particleNSigma, arrLen) == i)) { - if (pdgCode == pdgCodes[i]) { + } else if ((p >= PSwitch[i]) & (track.sign() == ParticleCharge[i])) { + float tmpNSigma = combinedSignal(tpcNSigmas[i], tofNSigmas[i]); + if ((tmpNSigma < nsigmacut.value) & (indexOfSmallestElement(particleNSigma, kArrLen) == i)) { + if (pdgCode == PdgCodes[i]) { fillPidHistos(track, pdgCode, true); } else { fillPidHistos(track, pdgCode, false); @@ -389,45 +411,45 @@ struct EvaluatePid { } } - template - void pidExclusiveStrategy(const T& track, const int pdgCode, const float tpcNSigmas[], const float tofNSigmas[], int arrLen) + template + void pidExclusiveStrategy(const T& track, const int pdgCode, const float tpcNSigmas[], const float tofNSigmas[]) { const float p = track.p(); // list of Nsigmas for particles - float particleNSigma[arrLen]; + float particleNSigma[kArrLen]; // calculate Nsigmas for every particle - for (int j = 0; j < arrLen; ++j) { - if (p < pSwitch[j]) { - particleNSigma[j] = abs(tpcNSigmas[j]); - } else if (p >= pSwitch[j]) { + for (int j = 0; j < kArrLen; ++j) { + if (p < PSwitch[j]) { + particleNSigma[j] = std::abs(tpcNSigmas[j]); + } else { particleNSigma[j] = combinedSignal(tpcNSigmas[j], tofNSigmas[j]); } } // check how many particles satisfy the condition int counts = 0; - for (int j = 0; j < arrLen; ++j) { + for (int j = 0; j < kArrLen; ++j) { if (particleNSigma[j] < nsigmacut.value) { counts++; } } if (counts == 1) { - if ((p < pSwitch[i]) & (track.sign() == particleCharge[i])) { - float tmp_NSigma = abs(tpcNSigmas[i]); - if ((tmp_NSigma < nsigmacut.value) & (indexOfSmallestElement(particleNSigma, arrLen) == i)) { - if (pdgCode == pdgCodes[i]) { + if ((p < PSwitch[i]) & (track.sign() == ParticleCharge[i])) { + float tmpNSigma = std::abs(tpcNSigmas[i]); + if ((tmpNSigma < nsigmacut.value) & (indexOfSmallestElement(particleNSigma, kArrLen) == i)) { + if (pdgCode == PdgCodes[i]) { fillPidHistos(track, pdgCode, true); } else { fillPidHistos(track, pdgCode, false); } } - } else if ((p >= pSwitch[i]) & (track.sign() == particleCharge[i])) { - float tmp_NSigma = combinedSignal(tpcNSigmas[i], tofNSigmas[i]); - if ((tmp_NSigma < nsigmacut.value) & (indexOfSmallestElement(particleNSigma, arrLen) == i)) { - if (pdgCode == pdgCodes[i]) { + } else if ((p >= PSwitch[i]) & (track.sign() == ParticleCharge[i])) { + float tmpNSigma = combinedSignal(tpcNSigmas[i], tofNSigmas[i]); + if ((tmpNSigma < nsigmacut.value) & (indexOfSmallestElement(particleNSigma, kArrLen) == i)) { + if (pdgCode == PdgCodes[i]) { fillPidHistos(track, pdgCode, true); } else { fillPidHistos(track, pdgCode, false); @@ -442,8 +464,8 @@ struct EvaluatePid { { // Convert PID to PDG code // We don't identify particles with PID bigger than Proton, putting dummy code so they will be skipped. - int bayesPdg = track.bayesID() > o2::track::PID::Proton ? 999 : pidToPdg[track.bayesID()]; - if (track.bayesID() <= o2::track::PID::Proton && track.sign() == -1 * particleCharge[track.bayesID()]) { // Check if antiparticle + int bayesPdg = track.bayesID() > o2::track::PID::Proton ? 999 : PidToPdg[track.bayesID()]; + if (track.bayesID() <= o2::track::PID::Proton && track.sign() == -1 * ParticleCharge[track.bayesID()]) { // Check if antiparticle bayesPdg += numParticles / 2; } return bayesPdg; @@ -453,7 +475,7 @@ struct EvaluatePid { void pidBayes(const T& track, const int pdgCode, const int bayesPdg) { if (bayesPdg == pdgCode) { - if (pdgCode == pdgCodes[i]) { + if (pdgCode == PdgCodes[i]) { fillPidHistos(track, pdgCode, true); } else { fillPidHistos(track, pdgCode, false); @@ -465,34 +487,25 @@ struct EvaluatePid { void fillMcHistos(const T& track, const int pdgCode) { // pions - if (pdgCode == 211) { + if (pdgCode == PDG_t::kPiPlus) { histReg.fill(HIST("MC/211"), track.pt()); - } else if (pdgCode == -211) { + } else if (pdgCode == PDG_t::kPiMinus) { histReg.fill(HIST("MC/0211"), track.pt()); - } - // protons - else if (pdgCode == 2212) { + } /* protons */ else if (pdgCode == PDG_t::kProton) { histReg.fill(HIST("MC/2212"), track.pt()); - } else if (pdgCode == -2212) { + } else if (pdgCode == PDG_t::kProtonBar) { histReg.fill(HIST("MC/02212"), track.pt()); - } - // kaons - else if (pdgCode == 321) { + } /* kaons */ else if (pdgCode == PDG_t::kKPlus) { histReg.fill(HIST("MC/321"), track.pt()); - } else if (pdgCode == -321) { + } else if (pdgCode == PDG_t::kKMinus) { histReg.fill(HIST("MC/0321"), track.pt()); - } - // electrons - else if (pdgCode == 11) { + } /* electrons */ else if (pdgCode == PDG_t::kElectron) { histReg.fill(HIST("MC/11"), track.pt()); - ; - } else if (pdgCode == -11) { + } else if (pdgCode == PDG_t::kPositron) { histReg.fill(HIST("MC/011"), track.pt()); - } - // muons - else if (pdgCode == 13) { + } /* muons */ else if (pdgCode == PDG_t::kMuonMinus) { histReg.fill(HIST("MC/13"), track.pt()); - } else if (pdgCode == -13) { + } else if (pdgCode == PDG_t::kMuonPlus) { histReg.fill(HIST("MC/013"), track.pt()); } else { histReg.fill(HIST("MC/else"), track.pt()); @@ -503,11 +516,18 @@ struct EvaluatePid { Configurable strategy{"strategy", 1, "1-PID with Nsigma method, 2-PID with NSigma and condition for minimal Nsigma value for particle, 3-Exclusive condition for NSigma, 4-Bayesian PID"}; Filter trackFilter = requireGlobalTrackInFilter(); - using pidTracks = soa::Filtered>; + using PidTracks = soa::Filtered>; + + enum PIDStrategy { + kSimple = 1, + kMin = 2, + kExclusive = 3, + kBayes = 4 + }; - void process(pidTracks const& tracks, aod::McParticles const& /*mcParticles*/) + void process(PidTracks const& tracks, aod::McParticles const& /*mcParticles*/) { - for (auto& track : tracks) { + for (const auto& track : tracks) { auto particle = track.mcParticle_as(); int pdgCode = particle.pdgCode(); @@ -518,22 +538,22 @@ struct EvaluatePid { const float tpcNSigmas[numParticles] = {track.tpcNSigmaPi(), track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaEl(), track.tpcNSigmaMu()}; const float tofNSigmas[numParticles] = {track.tofNSigmaPi(), track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaEl(), track.tofNSigmaMu()}; - if (strategy.value == 1) { + if (strategy.value == PIDStrategy::kSimple) { // Simplest strategy. PID with Nsigma method only static_for<0, 9>([&](auto i) { - pidSimple(track, pdgCode, tpcNSigmas, tofNSigmas, 5); + pidSimple(track, pdgCode, tpcNSigmas, tofNSigmas); }); - } else if (strategy.value == 2) { + } else if (strategy.value == PIDStrategy::kMin) { // PID with Nsigma method and additional condition. Selected particle's Nsigma value must be the lowest in order to count particle static_for<0, 9>([&](auto i) { - pidMinStrategy(track, pdgCode, tpcNSigmas, tofNSigmas, 5); + pidMinStrategy(track, pdgCode, tpcNSigmas, tofNSigmas); }); - } else if (strategy.value == 3) { + } else if (strategy.value == PIDStrategy::kExclusive) { // Particle is counted only if one can satisfy the PID NSigma condition static_for<0, 9>([&](auto i) { - pidExclusiveStrategy(track, pdgCode, tpcNSigmas, tofNSigmas, 5); + pidExclusiveStrategy(track, pdgCode, tpcNSigmas, tofNSigmas); }); - } else if (strategy.value == 4) { + } else if (strategy.value == PIDStrategy::kBayes) { int bayesPdg = getPdgFromPid(track); static_for<0, 9>([&](auto i) { pidBayes(track, pdgCode, bayesPdg); @@ -546,6 +566,6 @@ struct EvaluatePid { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/Tools/PIDML/qaPidML.cxx b/Tools/PIDML/qaPidMl.cxx similarity index 75% rename from Tools/PIDML/qaPidML.cxx rename to Tools/PIDML/qaPidMl.cxx index 54cafc437ab..01fca6457e1 100644 --- a/Tools/PIDML/qaPidML.cxx +++ b/Tools/PIDML/qaPidMl.cxx @@ -9,26 +9,39 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// +/// \file qaPidMl.cxx /// \brief Task to check ML PID efficiency. Based on Maja's simpleApplyPidOnnxModel.cxx code /// \author Łukasz Sawicki /// \since -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/StaticFor.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" -#include #include "Tools/PIDML/pidOnnxModel.h" +// +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -struct QaPidML { +struct QaPidMl { static const int maxP = 5; // nb of bins for TH1 hists static const int binsNb = 100; @@ -36,8 +49,8 @@ struct QaPidML { static const int binsNb2D = 1000; static const int numParticles = 3; - static constexpr std::string_view pidTrueRegistryNames[numParticles] = {"pidTrue/211", "pidTrue/2212", "pidTrue/321"}; - static constexpr std::string_view pidFalseRegistryNames[numParticles] = {"pidFalse/211", "pidFalse/2212", "pidFalse/321"}; + static constexpr std::string_view PidTrueRegistryNames[numParticles] = {"pidTrue/211", "pidTrue/2212", "pidTrue/321"}; + static constexpr std::string_view PidFalseRegistryNames[numParticles] = {"pidFalse/211", "pidFalse/2212", "pidFalse/321"}; static constexpr std::string_view TPCPidTrueRegistryNames[numParticles] = {"TPCPidTrue/211", "TPCPidTrue/2212", "TPCPidTrue/321"}; static constexpr std::string_view TPCPidFalseRegistryNames[numParticles] = {"TPCPidFalse/211", "TPCPidFalse/2212", "TPCPidFalse/321"}; @@ -46,11 +59,11 @@ struct QaPidML { static constexpr std::string_view TOFPidFalseRegistryNames[numParticles] = {"TOFPidFalse/211", "TOFPidFalse/2212", "TOFPidFalse/321"}; // available particles: 211, 2212, 321 - static constexpr int particlesPdgCode[numParticles] = {211, 2212, 321}; + static constexpr int ParticlesPdgCode[numParticles] = {211, 2212, 321}; // values of track momentum when to switch from only TPC signal to combined TPC and TOF signal and to TPC+TOF+TRD // i-th momentum corresponds to the i-th particle - static constexpr double pSwitchValue[numParticles][kNDetectors] = {{0.0, 0.5, 0.8}, {0.0, 0.8, 0.8}, {0.0, 0.5, 0.8}}; + static constexpr double PSwitchValue[numParticles][kNDetectors] = {{0.0, 0.5, 0.8}, {0.0, 0.8, 0.8}, {0.0, 0.5, 0.8}}; HistogramRegistry histReg{ "allHistograms", @@ -130,113 +143,119 @@ struct QaPidML { {"TOFPidFalse/2212", "PID false p;p (GeV/c); TOF #beta", {HistType::kTH2F, {{binsNb2D, 0.2, 10}, {110, 0, 1.1}}}}, {"TOFPidFalse/321", "PID false K^{+};p (GeV/c); TOF #beta", {HistType::kTH2F, {{binsNb2D, 0.2, 10}, {110, 0, 1.1}}}}}}; + enum ContaminationIn { + kPion, + kProton, + kKaon + }; + void fillContaminationRegistry(int i, int pdgCode, double pt) { - if (i == 0) { - if (pdgCode == 211) { + if (i == ContaminationIn::kPion) { + if (pdgCode == PDG_t::kPiPlus) { histReg.fill(HIST("contamination/211in211"), pt); } - if (pdgCode == -211) { + if (pdgCode == PDG_t::kPiMinus) { histReg.fill(HIST("contamination/0211in211"), pt); } - if (pdgCode == 2212) { + if (pdgCode == PDG_t::kProton) { histReg.fill(HIST("contamination/2212in211"), pt); } - if (pdgCode == -2212) { + if (pdgCode == PDG_t::kProtonBar) { histReg.fill(HIST("contamination/02212in211"), pt); } - if (pdgCode == 321) { + if (pdgCode == PDG_t::kKPlus) { histReg.fill(HIST("contamination/321in211"), pt); } - if (pdgCode == -321) { + if (pdgCode == PDG_t::kKMinus) { histReg.fill(HIST("contamination/0321in211"), pt); } - if (pdgCode == 11) { + if (pdgCode == PDG_t::kElectron) { histReg.fill(HIST("contamination/11in211"), pt); } - if (pdgCode == -11) { + if (pdgCode == PDG_t::kPositron) { histReg.fill(HIST("contamination/011in211"), pt); } - if (pdgCode == 13) { + if (pdgCode == PDG_t::kMuonMinus) { histReg.fill(HIST("contamination/13in211"), pt); } - if (pdgCode == -13) { + if (pdgCode == PDG_t::kMuonPlus) { histReg.fill(HIST("contamination/013in211"), pt); } - } else if (i == 1) { - if (pdgCode == 211) { + } else if (i == ContaminationIn::kProton) { + if (pdgCode == PDG_t::kPiPlus) { histReg.fill(HIST("contamination/211in2212"), pt); } - if (pdgCode == -211) { + if (pdgCode == PDG_t::kPiMinus) { histReg.fill(HIST("contamination/0211in2212"), pt); } - if (pdgCode == 2212) { + if (pdgCode == PDG_t::kProton) { histReg.fill(HIST("contamination/2212in2212"), pt); } - if (pdgCode == -2212) { + if (pdgCode == PDG_t::kProtonBar) { histReg.fill(HIST("contamination/02212in2212"), pt); } - if (pdgCode == 321) { + if (pdgCode == PDG_t::kKPlus) { histReg.fill(HIST("contamination/321in2212"), pt); } - if (pdgCode == -321) { + if (pdgCode == PDG_t::kKMinus) { histReg.fill(HIST("contamination/0321in2212"), pt); } - if (pdgCode == 11) { + if (pdgCode == PDG_t::kElectron) { histReg.fill(HIST("contamination/11in2212"), pt); } - if (pdgCode == -11) { + if (pdgCode == PDG_t::kPositron) { histReg.fill(HIST("contamination/011in2212"), pt); } - if (pdgCode == 13) { + if (pdgCode == PDG_t::kMuonMinus) { histReg.fill(HIST("contamination/13in2212"), pt); } - if (pdgCode == -13) { + if (pdgCode == PDG_t::kMuonPlus) { histReg.fill(HIST("contamination/013in2212"), pt); } - } else if (i == 2) { - if (pdgCode == 211) { + } else if (i == ContaminationIn::kKaon) { + if (pdgCode == PDG_t::kPiPlus) { histReg.fill(HIST("contamination/211in321"), pt); } - if (pdgCode == -211) { + if (pdgCode == PDG_t::kPiMinus) { histReg.fill(HIST("contamination/0211in321"), pt); } - if (pdgCode == 2212) { + if (pdgCode == PDG_t::kProton) { histReg.fill(HIST("contamination/2212in321"), pt); } - if (pdgCode == -2212) { + if (pdgCode == PDG_t::kProtonBar) { histReg.fill(HIST("contamination/02212in321"), pt); } - if (pdgCode == 321) { + if (pdgCode == PDG_t::kKPlus) { histReg.fill(HIST("contamination/321in321"), pt); } - if (pdgCode == -321) { + if (pdgCode == PDG_t::kKMinus) { histReg.fill(HIST("contamination/0321in321"), pt); } - if (pdgCode == 11) { + if (pdgCode == PDG_t::kElectron) { histReg.fill(HIST("contamination/11in321"), pt); } - if (pdgCode == -11) { + if (pdgCode == PDG_t::kPositron) { histReg.fill(HIST("contamination/011in321"), pt); } - if (pdgCode == 13) { + if (pdgCode == PDG_t::kMuonMinus) { histReg.fill(HIST("contamination/13in321"), pt); } - if (pdgCode == -13) { + if (pdgCode == PDG_t::kMuonPlus) { histReg.fill(HIST("contamination/013in321"), pt); } } @@ -245,34 +264,34 @@ struct QaPidML { template void fillMcHistos(const T& track, const int pdgCode) { - if (pdgCode == 211) { + if (pdgCode == PDG_t::kPiPlus) { // pions histReg.fill(HIST("MC/211"), track.pt()); - } else if (pdgCode == -211) { + } else if (pdgCode == PDG_t::kPiMinus) { // antipions histReg.fill(HIST("MC/0211"), track.pt()); - } else if (pdgCode == 2212) { + } else if (pdgCode == PDG_t::kProton) { // protons histReg.fill(HIST("MC/2212"), track.pt()); - } else if (pdgCode == -2212) { + } else if (pdgCode == PDG_t::kProtonBar) { // antiprotons histReg.fill(HIST("MC/02212"), track.pt()); - } else if (pdgCode == 321) { + } else if (pdgCode == PDG_t::kKPlus) { // kaons histReg.fill(HIST("MC/321"), track.pt()); - } else if (pdgCode == -321) { + } else if (pdgCode == PDG_t::kKMinus) { // antikaons histReg.fill(HIST("MC/0321"), track.pt()); - } else if (pdgCode == 11) { + } else if (pdgCode == PDG_t::kElectron) { // electrons histReg.fill(HIST("MC/11"), track.pt()); - } else if (pdgCode == -11) { + } else if (pdgCode == PDG_t::kPositron) { // positrons histReg.fill(HIST("MC/011"), track.pt()); - } else if (pdgCode == 13) { + } else if (pdgCode == PDG_t::kMuonMinus) { // muons histReg.fill(HIST("MC/13"), track.pt()); - } else if (pdgCode == -13) { + } else if (pdgCode == PDG_t::kMuonPlus) { // antimuons histReg.fill(HIST("MC/013"), track.pt()); } else { @@ -284,13 +303,13 @@ struct QaPidML { void fillPidHistos(const T& track, const int pdgCode, bool isPidTrue) { if (isPidTrue) { - histReg.fill(HIST(pidTrueRegistryNames[i]), track.pt()); + histReg.fill(HIST(PidTrueRegistryNames[i]), track.pt()); histReg.fill(HIST(TPCPidTrueRegistryNames[i]), track.p(), track.tpcSignal()); histReg.fill(HIST("TPCSignalPidTrue"), track.p(), track.tpcSignal()); histReg.fill(HIST("TOFSignalPidTrue"), track.p(), track.beta()); histReg.fill(HIST(TOFPidTrueRegistryNames[i]), track.p(), track.beta()); } else { - histReg.fill(HIST(pidFalseRegistryNames[i]), track.pt()); + histReg.fill(HIST(PidFalseRegistryNames[i]), track.pt()); histReg.fill(HIST(TPCPidFalseRegistryNames[i]), track.p(), track.tpcSignal()); histReg.fill(HIST("TPCSignalPidFalse"), track.p(), track.tpcSignal()); histReg.fill(HIST("TOFSignalPidFalse"), track.p(), track.beta()); @@ -301,26 +320,28 @@ struct QaPidML { } } - int getParticlePdg(float pidCertainties[]) + static constexpr float kCertaintyThreshold = 0.5f; + + int getParticlePdg(const float pidCertainties[]) { // index of the biggest value in an array int index = 0; // index of the second biggest value in an array - int smaller_index = 0; + int smallerIndex = 0; for (int j = 1; j < numParticles; j++) { if (pidCertainties[j] > pidCertainties[index]) { // assign new indexes - smaller_index = index; + smallerIndex = index; index = j; } } // return 0 if certainty with index 'index' is below 0.5 or two indexes have the same value, else map index to particle pdgCode - if ((pidCertainties[index] < 0.5f) | ((pidCertainties[index] == pidCertainties[smaller_index]) & (smaller_index != 0))) { + if ((pidCertainties[index] < kCertaintyThreshold) | ((pidCertainties[index] == pidCertainties[smallerIndex]) & (smallerIndex != 0))) { return 0; } else { - return particlesPdgCode[index]; + return ParticlesPdgCode[index]; } } @@ -333,8 +354,8 @@ struct QaPidML { pidCertainties[2] = model321.applyModel(track); int pid = getParticlePdg(pidCertainties); // condition for sign: we want to work only with pi, p and K, without antiparticles - if (pid == particlesPdgCode[i] && track.sign() == 1) { - if (pdgCodeMC == particlesPdgCode[i]) { + if (pid == ParticlesPdgCode[i] && track.sign() == 1) { + if (pdgCodeMC == ParticlesPdgCode[i]) { fillPidHistos(track, pdgCodeMC, true); } else { fillPidHistos(track, pdgCodeMC, false); @@ -342,42 +363,43 @@ struct QaPidML { } } - // one model for one particle - PidONNXModel model211; - PidONNXModel model2212; - PidONNXModel model321; - - Configurable cfgPathCCDB{"ccdb-path", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; - Configurable cfgCCDBURL{"ccdb-url", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; - Configurable cfgUseCCDB{"useCCDB", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; - Configurable cfgPathLocal{"local-path", "/home/mkabus/PIDML/", "base path to the local directory with ONNX models"}; + Configurable ccdbPath{"ccdbPath", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; + Configurable useCcdb{"useCcdb", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; + Configurable localPath{"localPath", "/home/mkabus/PIDML/", "base path to the local directory with ONNX models"}; o2::ccdb::CcdbApi ccdbApi; int currentRunNumber = -1; + Filter trackFilter = requireGlobalTrackInFilter(); + using PidTracks = soa::Filtered>; + + // one model for one particle + PidONNXModel model211; + PidONNXModel model2212; + PidONNXModel model321; + void init(InitContext const&) { - if (cfgUseCCDB) { - ccdbApi.init(cfgCCDBURL); + if (useCcdb) { + ccdbApi.init(ccdbUrl); } else { - model211 = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, 211, 0.5f, pSwitchValue[0]); - model2212 = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, 2211, 0.5f, pSwitchValue[1]); - model321 = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, 321, 0.5f, pSwitchValue[2]); + model211 = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, -1, PDG_t::kPiPlus, 0.5f, PSwitchValue[0]); + model2212 = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, -1, PDG_t::kProton, 0.5f, PSwitchValue[1]); + model321 = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, -1, PDG_t::kKPlus, 0.5f, PSwitchValue[2]); } } - Filter trackFilter = requireGlobalTrackInFilter(); - using pidTracks = soa::Filtered>; - void process(aod::Collisions const& collisions, pidTracks const& tracks, aod::McParticles const& /*mcParticles*/, aod::BCsWithTimestamps const&) + void process(aod::Collisions const& collisions, PidTracks const& tracks, aod::McParticles const& /*mcParticles*/, aod::BCsWithTimestamps const&) { auto bc = collisions.iteratorAt(0).bc_as(); - if (cfgUseCCDB && bc.runNumber() != currentRunNumber) { - model211 = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, bc.timestamp(), 211, 0.5f, pSwitchValue[0]); - model2212 = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, bc.timestamp(), 2211, 0.5f, pSwitchValue[1]); - model321 = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, bc.timestamp(), 321, 0.5f, pSwitchValue[2]); + if (useCcdb && bc.runNumber() != currentRunNumber) { + model211 = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, bc.timestamp(), PDG_t::kPiPlus, 0.5f, PSwitchValue[0]); + model2212 = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, bc.timestamp(), PDG_t::kProton, 0.5f, PSwitchValue[1]); + model321 = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, bc.timestamp(), PDG_t::kKPlus, 0.5f, PSwitchValue[2]); } - for (auto& track : tracks) { + for (const auto& track : tracks) { auto particle = track.mcParticle_as(); int pdgCodeMC = particle.pdgCode(); @@ -394,6 +416,6 @@ struct QaPidML { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/Tools/PIDML/simpleApplyPidOnnxInterface.cxx b/Tools/PIDML/simpleApplyPidOnnxInterface.cxx index 82f644103ed..268b0609c25 100644 --- a/Tools/PIDML/simpleApplyPidOnnxInterface.cxx +++ b/Tools/PIDML/simpleApplyPidOnnxInterface.cxx @@ -9,19 +9,30 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file simpleApplyPidInterface +/// \file simpleApplyPidOnnxInterface.cxx /// \brief A simple example for using PID obtained from the PID ML ONNX Interface. See README.md for more detailed instructions. /// /// \author Maja Kabus -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "CCDB/CcdbApi.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" #include "Tools/PIDML/pidOnnxInterface.h" +// +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -38,21 +49,19 @@ DECLARE_SOA_COLUMN(Accepted, accepted, bool); //! Whether the model accepted par DECLARE_SOA_TABLE(MlPidResults, "AOD", "MLPIDRESULTS", o2::soa::Index<>, mlpidresult::TrackId, mlpidresult::Pid, mlpidresult::Accepted); } // namespace o2::aod -struct SimpleApplyOnnxInterface { - PidONNXInterface pidInterface; // One instance to manage all needed ONNX models +struct SimpleApplyPidOnnxInterface { + Configurable> ptCuts{"ptCuts", {pidml_pt_cuts::Cuts[0], pidml_pt_cuts::NPids, pidml_pt_cuts::NCutVars, pidml_pt_cuts::pidLabels, pidml_pt_cuts::cutVarLabels}, "pT cuts for each output pid and each detector configuration"}; + Configurable> pdgPids{"pdgPids", std::vector{pidml_pt_cuts::pidsV}, "PIDs to predict"}; + Configurable> mlIdentCertaintyThresholds{"mlIdentCertaintyThresholds", std::vector{pidml_pt_cuts::certaintiesV}, "Min certainties of the models to accept given particle to be of given kind"}; + Configurable autoMode{"autoMode", true, "Use automatic model matching: default pT cuts and min certainties"}; - Configurable> cfgPTCuts{"pT_cuts", {pidml_pt_cuts::cuts[0], pidml_pt_cuts::nPids, pidml_pt_cuts::nCutVars, pidml_pt_cuts::pidLabels, pidml_pt_cuts::cutVarLabels}, "pT cuts for each output pid and each detector configuration"}; - Configurable> cfgPids{"pids", std::vector{pidml_pt_cuts::pids_v}, "PIDs to predict"}; - Configurable> cfgCertainties{"certainties", std::vector{pidml_pt_cuts::certainties_v}, "Min certainties of the models to accept given particle to be of given kind"}; - Configurable cfgAutoMode{"autoMode", true, "Use automatic model matching: default pT cuts and min certainties"}; + Configurable ccdbPath{"ccdbPath", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; + Configurable useCcdb{"useCcdb", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; + Configurable localPath{"localPath", "/home/mkabus/PIDML/", "base path to the local directory with ONNX models"}; - Configurable cfgPathCCDB{"ccdb-path", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; - Configurable cfgCCDBURL{"ccdb-url", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; - Configurable cfgUseCCDB{"useCCDB", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; - Configurable cfgPathLocal{"local-path", "/home/mkabus/PIDML/", "base path to the local directory with ONNX models"}; - - Configurable cfgUseFixedTimestamp{"use-fixed-timestamp", false, "Whether to use fixed timestamp from configurable instead of timestamp calculated from the data"}; - Configurable cfgTimestamp{"timestamp", 1524176895000, "Hardcoded timestamp for tests"}; + Configurable useFixedTimestamp{"useFixedTimestamp", false, "Whether to use fixed timestamp from configurable instead of timestamp calculated from the data"}; + Configurable fixedTimestamp{"fixedTimestamp", 1524176895000, "Hardcoded timestamp for tests"}; o2::ccdb::CcdbApi ccdbApi; int currentRunNumber = -1; @@ -65,25 +74,27 @@ struct SimpleApplyOnnxInterface { // Filter on isGlobalTrack (TracksSelection) using BigTracks = soa::Filtered>; + PidONNXInterface pidInterface; // One instance to manage all needed ONNX models + void init(InitContext const&) { - if (cfgUseCCDB) { - ccdbApi.init(cfgCCDBURL); + if (useCcdb) { + ccdbApi.init(ccdbUrl); } else { - pidInterface = PidONNXInterface(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, cfgPids.value, cfgPTCuts.value, cfgCertainties.value, cfgAutoMode.value); + pidInterface = PidONNXInterface(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, -1, pdgPids.value, ptCuts.value, mlIdentCertaintyThresholds.value, autoMode.value); } } void processCollisions(aod::Collisions const& collisions, BigTracks const& tracks, aod::BCsWithTimestamps const&) { auto bc = collisions.iteratorAt(0).bc_as(); - if (cfgUseCCDB && bc.runNumber() != currentRunNumber) { - uint64_t timestamp = cfgUseFixedTimestamp ? cfgTimestamp.value : bc.timestamp(); - pidInterface = PidONNXInterface(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, timestamp, cfgPids.value, cfgPTCuts.value, cfgCertainties.value, cfgAutoMode.value); + if (useCcdb && bc.runNumber() != currentRunNumber) { + uint64_t timestamp = useFixedTimestamp ? fixedTimestamp.value : bc.timestamp(); + pidInterface = PidONNXInterface(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, timestamp, pdgPids.value, ptCuts.value, mlIdentCertaintyThresholds.value, autoMode.value); } - for (auto& track : tracks) { - for (int pid : cfgPids.value) { + for (const auto& track : tracks) { + for (const int& pid : pdgPids.value) { bool accepted = pidInterface.applyModelBoolean(track, pid); LOGF(info, "collision id: %d track id: %d pid: %d accepted: %d p: %.3f; x: %.3f, y: %.3f, z: %.3f", track.collisionId(), track.index(), pid, accepted, track.p(), track.x(), track.y(), track.z()); @@ -91,12 +102,12 @@ struct SimpleApplyOnnxInterface { } } } - PROCESS_SWITCH(SimpleApplyOnnxInterface, processCollisions, "Process with collisions and bcs for CCDB", true); + PROCESS_SWITCH(SimpleApplyPidOnnxInterface, processCollisions, "Process with collisions and bcs for CCDB", true); void processTracksOnly(BigTracks const& tracks) { - for (auto& track : tracks) { - for (int pid : cfgPids.value) { + for (const auto& track : tracks) { + for (const int& pid : pdgPids.value) { bool accepted = pidInterface.applyModelBoolean(track, pid); LOGF(info, "collision id: %d track id: %d pid: %d accepted: %d p: %.3f; x: %.3f, y: %.3f, z: %.3f", track.collisionId(), track.index(), pid, accepted, track.p(), track.x(), track.y(), track.z()); @@ -104,11 +115,11 @@ struct SimpleApplyOnnxInterface { } } } - PROCESS_SWITCH(SimpleApplyOnnxInterface, processTracksOnly, "Process with tracks only -- faster but no CCDB", false); + PROCESS_SWITCH(SimpleApplyPidOnnxInterface, processTracksOnly, "Process with tracks only -- faster but no CCDB", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/Tools/PIDML/simpleApplyPidOnnxModel.cxx b/Tools/PIDML/simpleApplyPidOnnxModel.cxx index e261c1e10bc..57316713f03 100644 --- a/Tools/PIDML/simpleApplyPidOnnxModel.cxx +++ b/Tools/PIDML/simpleApplyPidOnnxModel.cxx @@ -9,19 +9,28 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file simpleApplyPidModel +/// \file simpleApplyPidOnnxModel.cxx /// \brief A simple example for using PID obtained from the PID ML ONNX Model. See README.md for more detailed instructions. /// /// \author Maja Kabus -#include - -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "CCDB/CcdbApi.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/PIDResponse.h" #include "Tools/PIDML/pidOnnxModel.h" +// +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include using namespace o2; using namespace o2::framework; @@ -38,18 +47,17 @@ DECLARE_SOA_COLUMN(Accepted, accepted, bool); //! Whether the model accepted par DECLARE_SOA_TABLE(MlPidResults, "AOD", "MLPIDRESULTS", o2::soa::Index<>, mlpidresult::TrackId, mlpidresult::Pid, mlpidresult::Accepted); } // namespace o2::aod -struct SimpleApplyOnnxModel { - PidONNXModel pidModel; // One instance per model, e.g., one per each pid to predict - Configurable cfgPid{"pid", 211, "PID to predict"}; - Configurable cfgCertainty{"certainty", 0.5, "Min certainty of the model to accept given particle to be of given kind"}; +struct SimpleApplyPidOnnxModel { + Configurable pdgPid{"pdgPid", 211, "PID to predict"}; + Configurable certainty{"certainty", 0.5, "Min certainty of the model to accept given particle to be of given kind"}; - Configurable cfgPathCCDB{"ccdb-path", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; - Configurable cfgCCDBURL{"ccdb-url", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; - Configurable cfgUseCCDB{"useCCDB", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; - Configurable cfgPathLocal{"local-path", "/home/mkabus/PIDML", "base path to the local directory with ONNX models"}; + Configurable ccdbPath{"ccdbPath", "Users/m/mkabus/PIDML", "base path to the CCDB directory with ONNX models"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "URL of the CCDB repository"}; + Configurable useCcdb{"useCcdb", true, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; + Configurable localPath{"localPath", "/home/mkabus/PIDML", "base path to the local directory with ONNX models"}; - Configurable cfgUseFixedTimestamp{"use-fixed-timestamp", false, "Whether to use fixed timestamp from configurable instead of timestamp calculated from the data"}; - Configurable cfgTimestamp{"timestamp", 1524176895000, "Hardcoded timestamp for tests"}; + Configurable useFixedTimestamp{"useFixedTimestamp", false, "Whether to use fixed timestamp from configurable instead of timestamp calculated from the data"}; + Configurable fixedTimestamp{"fixedTimestamp", 1524176895000, "Hardcoded timestamp for tests"}; o2::ccdb::CcdbApi ccdbApi; int currentRunNumber = -1; @@ -61,47 +69,48 @@ struct SimpleApplyOnnxModel { // TPC signal (FullTracks), TOF signal (TOFSignal), TOF beta (pidTOFbeta), dcaXY and dcaZ (TracksDCA) // Filter on isGlobalTrack (TracksSelection) using BigTracks = soa::Filtered>; + PidONNXModel pidModel; // One instance per model, e.g., one per each pid to predict void init(InitContext const&) { - if (cfgUseCCDB) { - ccdbApi.init(cfgCCDBURL); + if (useCcdb) { + ccdbApi.init(ccdbUrl); } else { - pidModel = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, cfgPid.value, cfgCertainty.value); + pidModel = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, -1, pdgPid.value, certainty.value); } } void processCollisions(aod::Collisions const& collisions, BigTracks const& tracks, aod::BCsWithTimestamps const&) { auto bc = collisions.iteratorAt(0).bc_as(); - if (cfgUseCCDB && bc.runNumber() != currentRunNumber) { - uint64_t timestamp = cfgUseFixedTimestamp ? cfgTimestamp.value : bc.timestamp(); - pidModel = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, timestamp, cfgPid.value, cfgCertainty.value); + if (useCcdb && bc.runNumber() != currentRunNumber) { + uint64_t timestamp = useFixedTimestamp ? fixedTimestamp.value : bc.timestamp(); + pidModel = PidONNXModel(localPath.value, ccdbPath.value, useCcdb.value, ccdbApi, timestamp, pdgPid.value, certainty.value); } - for (auto& track : tracks) { + for (const auto& track : tracks) { bool accepted = pidModel.applyModelBoolean(track); LOGF(info, "collision id: %d track id: %d accepted: %d p: %.3f; x: %.3f, y: %.3f, z: %.3f", track.collisionId(), track.index(), accepted, track.p(), track.x(), track.y(), track.z()); - pidMLResults(track.index(), cfgPid.value, accepted); + pidMLResults(track.index(), pdgPid.value, accepted); } } - PROCESS_SWITCH(SimpleApplyOnnxModel, processCollisions, "Process with collisions and bcs for CCDB", true); + PROCESS_SWITCH(SimpleApplyPidOnnxModel, processCollisions, "Process with collisions and bcs for CCDB", true); void processTracksOnly(BigTracks const& tracks) { - for (auto& track : tracks) { + for (const auto& track : tracks) { bool accepted = pidModel.applyModelBoolean(track); LOGF(info, "collision id: %d track id: %d accepted: %d p: %.3f; x: %.3f, y: %.3f, z: %.3f", track.collisionId(), track.index(), accepted, track.p(), track.x(), track.y(), track.z()); - pidMLResults(track.index(), cfgPid.value, accepted); + pidMLResults(track.index(), pdgPid.value, accepted); } } - PROCESS_SWITCH(SimpleApplyOnnxModel, processTracksOnly, "Process with tracks only -- faster but no CCDB", false); + PROCESS_SWITCH(SimpleApplyPidOnnxModel, processTracksOnly, "Process with tracks only -- faster but no CCDB", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/ML/applyMlSelection.cxx b/Tutorials/ML/applyMlSelection.cxx index dcbfb0f80e9..4ca579acc44 100644 --- a/Tutorials/ML/applyMlSelection.cxx +++ b/Tutorials/ML/applyMlSelection.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2023 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/Tutorials/ML/run_applyMlSelection.sh b/Tutorials/ML/run_applyMlSelection.sh index fe85f857771..8df339186ff 100755 --- a/Tutorials/ML/run_applyMlSelection.sh +++ b/Tutorials/ML/run_applyMlSelection.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright 2019-2023 CERN and copyright holders of ALICE O2. +# Copyright 2019-2025 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. # diff --git a/Tutorials/PWGEM/pcm/CMakeLists.txt b/Tutorials/PWGEM/pcm/CMakeLists.txt index e2863ae717b..72b4616ef2d 100644 --- a/Tutorials/PWGEM/pcm/CMakeLists.txt +++ b/Tutorials/PWGEM/pcm/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2023 CERN and copyright holders of ALICE O2. +# Copyright 2019-2025 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. # diff --git a/Tutorials/PWGEM/pcm/pcmtutorial.cxx b/Tutorials/PWGEM/pcm/pcmtutorial.cxx index 1550f30ebeb..c10b4251991 100644 --- a/Tutorials/PWGEM/pcm/pcmtutorial.cxx +++ b/Tutorials/PWGEM/pcm/pcmtutorial.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2023 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 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. // diff --git a/Tutorials/PWGHF/DataModelMini.h b/Tutorials/PWGHF/DataModelMini.h index 7a03f1462b7..720b7207676 100644 --- a/Tutorials/PWGHF/DataModelMini.h +++ b/Tutorials/PWGHF/DataModelMini.h @@ -17,7 +17,12 @@ #ifndef TUTORIALS_PWGHF_DATAMODELMINI_H_ #define TUTORIALS_PWGHF_DATAMODELMINI_H_ -#include "Framework/AnalysisDataModel.h" +#include "Common/Core/RecoDecay.h" + +#include +#include + +#include namespace o2::aod { diff --git a/Tutorials/PWGHF/dpl-config_skim.json b/Tutorials/PWGHF/dpl-config_skim.json index 3d78778042e..118a3481248 100644 --- a/Tutorials/PWGHF/dpl-config_skim.json +++ b/Tutorials/PWGHF/dpl-config_skim.json @@ -20,7 +20,10 @@ "ccdb-url": "http://alice-ccdb.cern.ch", "isRun2MC": "-1" }, - "tracks-extra-converter": "", + "tracks-extra-v002-converter": { + "processV000ToV002": "true", + "processV001ToV002": "false" + }, "tracks-extra-spawner": "", "track-propagation": { "ccdb-url": "http://alice-ccdb.cern.ch", diff --git a/Tutorials/PWGHF/dpl-config_task.json b/Tutorials/PWGHF/dpl-config_task.json index 4e07d936675..8da330be6d3 100644 --- a/Tutorials/PWGHF/dpl-config_task.json +++ b/Tutorials/PWGHF/dpl-config_task.json @@ -21,7 +21,10 @@ "ccdb-url": "http://alice-ccdb.cern.ch", "isRun2MC": "-1" }, - "tracks-extra-converter": "", + "tracks-extra-v002-converter": { + "processV000ToV002": "true", + "processV001ToV002": "false" + }, "bc-selection-task": { "triggerBcShift": "0", "ITSROFrameStartBorderMargin": "-1", @@ -42,7 +45,7 @@ "minPropagationDistance": "5", "useTrackTuner": "true", "fillTrackTunerTable": "false", - "trackTunerParams": "debugInfo=0|updateTrackDCAs=1|updateTrackCovMat=1|updateCurvature=0|updateCurvatureIU=1|updatePulls=1|isInputFileFromCCDB=1|pathInputFile=Users/m/mfaggin/test/inputsTrackTuner/pp2023/smoothHighPtMC|nameInputFile=trackTuner_DataLHC23fPass1_McLHC23k4b_run535085.root|pathFileQoverPt=Users/h/hsharma/qOverPtGraphs|nameFileQoverPt=D0sigma_Data_removal_itstps_MC_LHC22b1b.root|usePvRefitCorrections=0|qOverPtMC=1|qOverPtData=2", + "trackTunerParams": "debugInfo=0|updateTrackDCAs=1|updateTrackCovMat=1|updateCurvature=0|updateCurvatureIU=1|updatePulls=1|isInputFileFromCCDB=1|pathInputFile=Users/m/mfaggin/test/inputsTrackTuner/pp2023/smoothHighPtMC|nameInputFile=trackTuner_DataLHC23fPass1_McLHC23k4b_run535085.root|pathFileQoverPt=Users/h/hsharma/qOverPtGraphs|nameFileQoverPt=D0sigma_Data_removal_itstps_MC_LHC22b1b.root|usePvRefitCorrections=0|qOverPtMC=1|qOverPtData=2|nPhiBins=0", "axisPtQA": { "values": [ "0", diff --git a/Tutorials/PWGHF/run_skim.sh b/Tutorials/PWGHF/run_skim.sh index 6adefe69b01..3a5b9a6d2e0 100644 --- a/Tutorials/PWGHF/run_skim.sh +++ b/Tutorials/PWGHF/run_skim.sh @@ -44,7 +44,7 @@ o2-analysis-timestamp "${OPTIONS[@]}" | \ o2-analysis-trackselection "${OPTIONS[@]}" | \ o2-analysis-track-propagation "${OPTIONS[@]}" | \ o2-analysis-bc-converter "${OPTIONS[@]}" | \ -o2-analysis-tracks-extra-converter "${OPTIONS[@]}" \ +o2-analysis-tracks-extra-v002-converter "${OPTIONS[@]}" \ > "$LOGFILE" 2>&1 # report status diff --git a/Tutorials/PWGHF/run_task.sh b/Tutorials/PWGHF/run_task.sh index de4096c2b85..1da3b524766 100644 --- a/Tutorials/PWGHF/run_task.sh +++ b/Tutorials/PWGHF/run_task.sh @@ -50,7 +50,7 @@ o2-analysis-pid-tof-base "${OPTIONS[@]}" | \ o2-analysis-pid-tof-full "${OPTIONS[@]}" | \ o2-analysis-ft0-corrected-table "${OPTIONS[@]}" | \ o2-analysis-bc-converter "${OPTIONS[@]}" | \ -o2-analysis-tracks-extra-converter "${OPTIONS[@]}" | \ +o2-analysis-tracks-extra-v002-converter "${OPTIONS[@]}" | \ o2-analysis-zdc-converter "${OPTIONS[@]}" \ > "$LOGFILE" 2>&1 diff --git a/Tutorials/PWGHF/skimCreatorMini.cxx b/Tutorials/PWGHF/skimCreatorMini.cxx index ac6b12e2004..e3aae5bbaf4 100644 --- a/Tutorials/PWGHF/skimCreatorMini.cxx +++ b/Tutorials/PWGHF/skimCreatorMini.cxx @@ -14,21 +14,28 @@ /// /// \author Vít Kučera , Inha University -// O2 -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -// O2Physics +#include "Tutorials/PWGHF/DataModelMini.h" +// #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/TrackSelectionTables.h" -// PWGHF -#include "Tutorials/PWGHF/DataModelMini.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include using namespace o2; using namespace o2::aod; diff --git a/Tutorials/PWGHF/taskMini.cxx b/Tutorials/PWGHF/taskMini.cxx index 871fe710581..813e9879ce4 100644 --- a/Tutorials/PWGHF/taskMini.cxx +++ b/Tutorials/PWGHF/taskMini.cxx @@ -14,23 +14,32 @@ /// /// \author Vít Kučera , Inha University -// O2 -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" - -// O2Physics +#include "Tutorials/PWGHF/DataModelMini.h" +// +#include "PWGHF/Core/HfHelper.h" +// #include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelectorPID.h" #include "Common/Core/trackUtilities.h" -#include "Common/DataModel/PIDResponse.h" - -// PWGHF -#include "PWGHF/Core/HfHelper.h" -#include "Tutorials/PWGHF/DataModelMini.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include using namespace o2; using namespace o2::aod; @@ -314,8 +323,8 @@ struct HfTaskMiniD0 { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"hf-task-mini-candidate-creator-2prong"}), // o2-linter: disable=name/o2-task - adaptAnalysisTask(cfgc, TaskName{"hf-task-mini-candidate-creator-2prong-expressions"}), // o2-linter: disable=name/o2-task + adaptAnalysisTask(cfgc, TaskName{"hf-task-mini-candidate-creator-2prong"}), // o2-linter: disable=name/o2-task (wrong hyphenation) + adaptAnalysisTask(cfgc, TaskName{"hf-task-mini-candidate-creator-2prong-expressions"}), // o2-linter: disable=name/o2-task (wrong hyphenation) adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/PWGLF/Resonance/CMakeLists.txt b/Tutorials/PWGLF/Resonance/CMakeLists.txt index 09f58af5cd0..35ac519aa65 100644 --- a/Tutorials/PWGLF/Resonance/CMakeLists.txt +++ b/Tutorials/PWGLF/Resonance/CMakeLists.txt @@ -49,3 +49,8 @@ o2physics_add_dpl_workflow(resonances-combine SOURCES resonancesCombine.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(resonances-microtrack + SOURCES resonancesMicrotrack.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) diff --git a/Tutorials/PWGLF/Resonance/resonancesCombine.cxx b/Tutorials/PWGLF/Resonance/resonancesCombine.cxx index 0168c140c23..26a28661c6c 100644 --- a/Tutorials/PWGLF/Resonance/resonancesCombine.cxx +++ b/Tutorials/PWGLF/Resonance/resonancesCombine.cxx @@ -172,7 +172,7 @@ struct ResonanceCombine { } } - void process(soa::Join::iterator const& collision, soa::Join const& resotracks) + void process(soa::Join::iterator const& collision, soa::Join const& resotracks) { histos.fill(HIST("hVertexZ"), collision.posZ()); // Both resoCollisions and Qvectors have the same cent column, so we have to use "_as" to access it diff --git a/Tutorials/PWGLF/Resonance/resonancesMicrotrack.cxx b/Tutorials/PWGLF/Resonance/resonancesMicrotrack.cxx new file mode 100644 index 00000000000..5022d4b602d --- /dev/null +++ b/Tutorials/PWGLF/Resonance/resonancesMicrotrack.cxx @@ -0,0 +1,203 @@ +// 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. +/// +/// \file resonancesMicrotrack.cxx +/// \brief Resonance microtrack tutorial +/// \author Bong-Hwi Lim +/// \since 07/03/2025 + +#include +#include + +#include "CommonConstants/MathConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/runDataProcessing.h" +#include "PWGLF/DataModel/LFResonanceTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::math; +// Extract STEP +// Handle resomicrotracks +struct ResonancesMicrotrack { + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Configurable for number of bins + Configurable nBins{"nBins", 100, "N bins in all histos"}; + // Configurable for min pT cut + Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"}; + // Configurable for event plane + Configurable cfgEvtPl{"cfgEvtPl", 40500, "Configuration of three subsystems for the event plane and its resolution, 10000*RefA + 100*RefB + S, where FT0C:0, FT0A:1, FT0M:2, FV0A:3, BPos:5, BNeg:6"}; + + // Track selection + // primary track condition + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", false, "Primary track selection"}; + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; + Configurable cfgPVContributor{"cfgPVContributor", false, "PV contributor track selection"}; + // DCA Selections + // DCAr to PV + Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; + // DCAz to PV + Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 1.0, "Track DCAz cut to PV Maximum"}; + Configurable cMinDCAzToPVcut{"cMinDCAzToPVcut", 0.0, "Track DCAz cut to PV Minimum"}; + + // PID selection + Configurable nSigmaCutTPC{"nSigmaCutTPC", 3.0, "Value of the TPC Nsigma cut"}; + Configurable nSigmaCutTOF{"nSigmaCutTOF", 3.0, "Value of the TOF Nsigma cut"}; + + void init(o2::framework::InitContext&) + { + histos.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{nBins, -15., 15.}}); + histos.add("hMultiplicityPercent", "Multiplicity Percentile", kTH1F, {{120, 0.0f, 120.0f}}); + histos.add("hEta_ResoTracks", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); + histos.add("hEta_ResoMicroTracks", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); + histos.add("hPhi_ResoTracks", "Phi distribution", kTH1F, {{200, 0, TwoPI}}); + histos.add("hPhi_ResoMicroTracks", "Phi distribution", kTH1F, {{200, 0, TwoPI}}); + histos.add("hPt_ResoTracks", "Pt distribution", kTH1F, {{150, 0.0f, 15.0f}}); + histos.add("hPt_ResoMicroTracks", "Pt distribution", kTH1F, {{150, 0.0f, 15.0f}}); + histos.add("hPx_ResoTracks", "Px distribution", kTH1F, {{200, -10.0f, 10.0f}}); + histos.add("hPx_ResoMicroTracks", "Px distribution", kTH1F, {{200, -10.0f, 10.0f}}); + histos.add("hPy_ResoTracks", "Py distribution", kTH1F, {{200, -10.0f, 10.0f}}); + histos.add("hPy_ResoMicroTracks", "Py distribution", kTH1F, {{200, -10.0f, 10.0f}}); + histos.add("hPz_ResoTracks", "Pz distribution", kTH1F, {{200, -10.0f, 10.0f}}); + histos.add("hPz_ResoMicroTracks", "Pz distribution", kTH1F, {{200, -10.0f, 10.0f}}); + + histos.add("hDcaxy_ResoTracks", "Dcaxy distribution", kTH1F, {{200, 0, 2.0f}}); + histos.add("hDcaz_ResoTracks", "Dcaz distribution", kTH1F, {{200, 0, 2.0f}}); + histos.add("hDcaxy_ResoMicroTracks", "Dcaxy distribution", kTH1F, {{200, 0, 2.0f}}); + histos.add("hDcaz_ResoMicroTracks", "Dcaz distribution", kTH1F, {{200, 0, 2.0f}}); + + // PID + histos.add("hNsigmaKaonTPC_ResoMicroTracks", "NsigmaKaonTPC distribution", kTH1F, {{240, -6.0f, 6.0f}}); + histos.add("hNsigmaKaonTOF_ResoMicroTracks", "NsigmaKaonTOF distribution", kTH1F, {{240, -6.0f, 6.0f}}); + histos.add("hNsigmaKaonTPC_ResoTracks", "NsigmaKaonTPC distribution", kTH1F, {{240, -6.0f, 6.0f}}); + histos.add("hNsigmaKaonTOF_ResoTracks", "NsigmaKaonTOF distribution", kTH1F, {{240, -6.0f, 6.0f}}); + + LOG(info) << "Size of the histograms in resonance tutorial with table combination:"; + histos.print(); + } + + template + bool trackCut(const TrackType track) + { + if constexpr (!IsResoMicrotrack) { + if (std::abs(track.pt()) < cMinPtcut) + return false; + if (std::abs(track.dcaXY()) > cMaxDCArToPVcut) + return false; + if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) + return false; + if (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + return false; + } else { + if (std::abs(track.pt()) < cMinPtcut) + return false; + if (o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(track.trackSelectionFlags()) > cMaxDCArToPVcut - Epsilon) + return false; + if (o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(track.trackSelectionFlags()) > cMaxDCAzToPVcut - Epsilon) + return false; + if (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + return false; + } + return true; + } + + template + bool selectionPID(const T& candidate) + { + if constexpr (!IsResoMicrotrack) { + bool tpcPass = std::abs(candidate.tpcNSigmaPr()) < nSigmaCutTPC; + bool tofPass = (candidate.hasTOF()) ? std::abs(candidate.tofNSigmaPr()) < nSigmaCutTOF : true; + if (tpcPass && tofPass) { + return true; + } + // return true; + } else { + bool tpcPass = std::abs(o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(candidate.pidNSigmaPrFlag())) < nSigmaCutTPC + Epsilon; + bool tofPass = candidate.hasTOF() ? std::abs(o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(candidate.pidNSigmaPrFlag())) < nSigmaCutTOF + Epsilon : true; + if (tpcPass && tofPass) { + return true; + } + // return true; + } + return false; + } + + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks) + { + auto multiplicity = collision.cent(); + histos.fill(HIST("hVertexZ"), collision.posZ()); + histos.fill(HIST("hMultiplicityPercent"), multiplicity); + for (auto const& track : dTracks) { + if (!trackCut(track) || !selectionPID(track)) { + continue; + } + + if constexpr (!IsResoMicrotrack) { // ResoTracks + histos.fill(HIST("hEta_ResoTracks"), track.eta()); + histos.fill(HIST("hPhi_ResoTracks"), track.phi()); + histos.fill(HIST("hPt_ResoTracks"), track.pt()); + histos.fill(HIST("hPx_ResoTracks"), track.px()); + histos.fill(HIST("hPy_ResoTracks"), track.py()); + histos.fill(HIST("hPz_ResoTracks"), track.pz()); + histos.fill(HIST("hDcaxy_ResoTracks"), track.dcaXY()); + histos.fill(HIST("hDcaz_ResoTracks"), track.dcaZ()); + histos.fill(HIST("hNsigmaKaonTPC_ResoTracks"), track.tpcNSigmaPr()); + if (track.hasTOF()) { + histos.fill(HIST("hNsigmaKaonTOF_ResoTracks"), track.tofNSigmaPr()); + } + } else { // ResoMicroTracks + histos.fill(HIST("hEta_ResoMicroTracks"), track.eta()); + histos.fill(HIST("hPhi_ResoMicroTracks"), track.phi()); + histos.fill(HIST("hPt_ResoMicroTracks"), track.pt()); + histos.fill(HIST("hPx_ResoMicroTracks"), track.px()); + histos.fill(HIST("hPy_ResoMicroTracks"), track.py()); + histos.fill(HIST("hPz_ResoMicroTracks"), track.pz()); + histos.fill(HIST("hDcaxy_ResoMicroTracks"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAxy(track.trackSelectionFlags())); + histos.fill(HIST("hDcaz_ResoMicroTracks"), o2::aod::resomicrodaughter::ResoMicroTrackSelFlag::decodeDCAz(track.trackSelectionFlags())); + histos.fill(HIST("hNsigmaKaonTPC_ResoMicroTracks"), o2::aod::resomicrodaughter::PidNSigma::getTPCnSigma(track.pidNSigmaPrFlag())); + if (track.hasTOF()) { + histos.fill(HIST("hNsigmaKaonTOF_ResoMicroTracks"), o2::aod::resomicrodaughter::PidNSigma::getTOFnSigma(track.pidNSigmaPrFlag())); + } + } + } + } + void processDummy(aod::ResoCollision const& /*collisions*/) + { + } + PROCESS_SWITCH(ResonancesMicrotrack, processDummy, "Process Dummy", true); + + void processResoTracks(aod::ResoCollision const& collision, aod::ResoTracks const& resotracks) + { + fillHistograms(collision, resotracks); + } + PROCESS_SWITCH(ResonancesMicrotrack, processResoTracks, "Process ResoTracks", false); + + void processResoMicroTracks(aod::ResoCollision const& collision, aod::ResoMicroTracks const& resomicrotracks) + { + fillHistograms(collision, resomicrotracks); + } + PROCESS_SWITCH(ResonancesMicrotrack, processResoMicroTracks, "Process ResoMicroTracks", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/PWGUD/CMakeLists.txt b/Tutorials/PWGUD/CMakeLists.txt index de978b518dc..1be9c2f6815 100644 --- a/Tutorials/PWGUD/CMakeLists.txt +++ b/Tutorials/PWGUD/CMakeLists.txt @@ -53,7 +53,3 @@ o2physics_add_dpl_workflow(udtutorial-07 SOURCES UDTutorial_07.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) - - - - diff --git a/Tutorials/PWGUD/UDTutorial_05.cxx b/Tutorials/PWGUD/UDTutorial_05.cxx index 3a9bfb79605..40375c48614 100644 --- a/Tutorials/PWGUD/UDTutorial_05.cxx +++ b/Tutorials/PWGUD/UDTutorial_05.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. // -#include "iostream" +#include #include "TLorentzVector.h" #include "TDatabasePDG.h" diff --git a/Tutorials/PWGUD/UDTutorial_07.cxx b/Tutorials/PWGUD/UDTutorial_07.cxx index f2a5616f00d..0060b68293e 100644 --- a/Tutorials/PWGUD/UDTutorial_07.cxx +++ b/Tutorials/PWGUD/UDTutorial_07.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // -#include "iostream" +#include #include #include #include "Framework/runDataProcessing.h" diff --git a/Tutorials/src/eventMixing.cxx b/Tutorials/src/eventMixing.cxx index 676d6ba96e3..a1526740886 100644 --- a/Tutorials/src/eventMixing.cxx +++ b/Tutorials/src/eventMixing.cxx @@ -9,10 +9,13 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// +/// \file eventMixing.cxx /// \brief Example tasks for event mixing. -/// \author +/// \author Karwowska Maja /// \since +#include +#include "Framework/AnalysisDataModel.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/ASoAHelpers.h" @@ -37,18 +40,18 @@ DECLARE_SOA_TABLE(MixingHashes, "AOD", "HASH", hash::Bin); struct MixedEvents { SliceCache cache; + Preslice perCollision = aod::track::collisionId; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; using BinningType = ColumnBinningPolicy; - BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) + BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) SameKindPair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored - void process(aod::Collisions const& collisions, aod::Tracks const& tracks) { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); int count = 0; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { // Example of using getBin() to check collisions bin // NOTE that it is a bit different for FlexibleBinning -- check in respective example int bin = binningOnPositions.getBin({c1.posX(), c1.posY()}); @@ -60,7 +63,7 @@ struct MixedEvents { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); trackCount++; if (trackCount == 10) @@ -72,12 +75,14 @@ struct MixedEvents { struct MixedEventsInsideProcess { SliceCache cache; + Preslice perCollision = aod::track::collisionId; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; using BinningType = ColumnBinningPolicy; BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) - void process(aod::Collisions& collisions, aod::Tracks& tracks) + void process(aod::Collisions const& collisions, aod::Tracks const& tracks) + { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); @@ -85,7 +90,7 @@ struct MixedEventsInsideProcess { SameKindPair pair{binningOnPositions, 5, -1, collisions, tracksTuple, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored int count = 0; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex()); count++; if (count == 10) @@ -93,7 +98,7 @@ struct MixedEventsInsideProcess { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); trackCount++; if (trackCount == 10) @@ -105,21 +110,22 @@ struct MixedEventsInsideProcess { struct MixedEventsFilteredTracks { SliceCache cache; + Preslice perCollision = aod::track::collisionId; Filter trackFilter = aod::track::eta < 1.0f; - using myTracks = soa::Filtered; + using MyTracks = soa::Filtered; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; using BinningType = ColumnBinningPolicy; - BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) - SameKindPair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored + BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) + SameKindPair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored - void process(aod::Collisions const& collisions, myTracks const& tracks) + void process(aod::Collisions const& collisions, MyTracks const& tracks) { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); int count = 0; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex()); count++; if (count == 100) @@ -127,7 +133,7 @@ struct MixedEventsFilteredTracks { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { LOGF(info, "Mixed event tracks pair: (%d, %d) (%.2f, %.2f) < 1.0f from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), t1.eta(), t2.eta(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); trackCount++; if (trackCount == 10) @@ -139,19 +145,20 @@ struct MixedEventsFilteredTracks { struct MixedEventsJoinedCollisions { SliceCache cache; - using aodCollisions = soa::Join; + Preslice perCollision = aod::track::collisionId; + using AODCollisions = soa::Join; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; using BinningType = ColumnBinningPolicy; - BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) - SameKindPair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored + BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) + SameKindPair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored - void process(aodCollisions& collisions, aod::Tracks const& tracks, aod::BCsWithTimestamps const&) + void process(AODCollisions const& collisions, aod::Tracks const& tracks, aod::BCsWithTimestamps const&) { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); int count = 0; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex()); count++; if (count == 10) @@ -159,8 +166,8 @@ struct MixedEventsJoinedCollisions { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { - LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision_as().index(), t2.collision_as().index()); trackCount++; if (trackCount == 10) break; @@ -171,19 +178,20 @@ struct MixedEventsJoinedCollisions { struct MixedEventsDynamicColumns { SliceCache cache; - using aodCollisions = soa::Join; + Preslice perCollison = aod::track::collisionId; + using AODCollisions = soa::Join; std::vector zBins{7, -7, 7}; std::vector multBins{VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 100.1}; using BinningType = ColumnBinningPolicy>; - BinningType corrBinning{{zBins, multBins}, true}; // true is for 'ignore overflows' (true by default) - SameKindPair pair{corrBinning, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored + BinningType corrBinning{{zBins, multBins}, true}; // true is for 'ignore overflows' (true by default) + SameKindPair pair{corrBinning, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored - void process(aodCollisions& collisions, aod::Tracks const& tracks) + void process(AODCollisions const& collisions, aod::Tracks const& tracks) { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); int count = 0; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex()); count++; if (count == 10) @@ -191,8 +199,8 @@ struct MixedEventsDynamicColumns { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { - LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision_as().index(), t2.collision_as().index()); trackCount++; if (trackCount == 10) break; @@ -203,10 +211,12 @@ struct MixedEventsDynamicColumns { struct MixedEventsVariousKinds { SliceCache cache; + Preslice perCollisionTrack = aod::track::collisionId; + Preslice perCollisionV0 = aod::v0::collisionId; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; using BinningType = ColumnBinningPolicy; - BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) + BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) Pair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored void process(aod::Collisions const& collisions, aod::Tracks const& tracks, aod::V0s const& v0s) @@ -216,7 +226,7 @@ struct MixedEventsVariousKinds { int count = 0; // tracks1 is an aod::Tracks table of tracks belonging to collision c1 (aod::Collision::iterator) // tracks2 is an aod::V0s table of V0s belonging to collision c2 (aod::Collision::iterator) - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex()); count++; if (count == 100) @@ -224,7 +234,7 @@ struct MixedEventsVariousKinds { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); trackCount++; if (trackCount == 10) @@ -236,11 +246,12 @@ struct MixedEventsVariousKinds { struct MixedEventsTriple { SliceCache cache; + Preslice perCollision = aod::track::collisionId; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; std::vector zBins{7, -7, 7}; using BinningType = ColumnBinningPolicy; - BinningType binningOnPositions{{xBins, yBins, zBins}, true}; // true is for 'ignore overflows' (true by default) + BinningType binningOnPositions{{xBins, yBins, zBins}, true}; // true is for 'ignore overflows' (true by default) SameKindTriple triple{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored void process(aod::Collisions const& collisions, aod::Tracks const& tracks) @@ -248,7 +259,7 @@ struct MixedEventsTriple { LOGF(info, "Input data Collisions %d, Tracks %d", collisions.size(), tracks.size()); int count = 0; - for (auto& [c1, tracks1, c2, tracks2, c3, tracks3] : triple) { + for (const auto& [c1, tracks1, c2, tracks2, c3, tracks3] : triple) { LOGF(info, "Mixed event collisions: (%d, %d, %d)", c1.globalIndex(), c2.globalIndex(), c3.globalIndex()); count++; if (count == 100) @@ -256,7 +267,7 @@ struct MixedEventsTriple { // Example of using tracks from mixed events -- iterate over all track triplets from the three collisions int trackCount = 0; - for (auto& [t1, t2, t3] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2, tracks3))) { + for (const auto& [t1, t2, t3] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2, tracks3))) { LOGF(info, "Mixed event tracks triple: (%d, %d, %d) from events (%d, %d, %d), track event: (%d, %d, %d)", t1.index(), t2.index(), t3.index(), c1.index(), c2.index(), c3.index(), t1.collision().index(), t2.collision().index(), t3.collision().index()); trackCount++; if (trackCount == 10) @@ -268,11 +279,13 @@ struct MixedEventsTriple { struct MixedEventsTripleVariousKinds { SliceCache cache; + Preslice perCollisionTrack = aod::track::collisionId; + Preslice perCollisionV0 = aod::v0::collisionId; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; std::vector zBins{7, -7, 7}; using BinningType = ColumnBinningPolicy; - BinningType binningOnPositions{{xBins, yBins, zBins}, true}; // true is for 'ignore overflows' (true by default) + BinningType binningOnPositions{{xBins, yBins, zBins}, true}; // true is for 'ignore overflows' (true by default) Triple triple{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored void process(aod::Collisions const& collisions, aod::Tracks const& tracks, aod::V0s const& v0s) @@ -283,7 +296,7 @@ struct MixedEventsTripleVariousKinds { // tracks1 is an aod::Tracks table of tracks belonging to collision c1 (aod::Collision::iterator) // tracks2 is an aod::V0s table of V0s belonging to collision c2 (aod::Collision::iterator) // tracks3 is an aod::Tracks table of tracks belonging to collision c3 (aod::Collision::iterator) - for (auto& [c1, tracks1, c2, tracks2, c3, tracks3] : triple) { + for (const auto& [c1, tracks1, c2, tracks2, c3, tracks3] : triple) { LOGF(info, "Mixed event collisions: (%d, %d, %d)", c1.globalIndex(), c2.globalIndex(), c3.globalIndex()); count++; if (count == 100) @@ -291,7 +304,7 @@ struct MixedEventsTripleVariousKinds { // Example of using tracks from mixed events -- iterate over all track triplets from the three collisions int trackCount = 0; - for (auto& [t1, t2, t3] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2, tracks3))) { + for (const auto& [t1, t2, t3] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2, tracks3))) { LOGF(info, "Mixed event tracks triple: (%d, %d, %d) from events (%d, %d, %d), track event: (%d, %d, %d)", t1.index(), t2.index(), t3.index(), c1.index(), c2.index(), c3.index(), t1.collision().index(), t2.collision().index(), t3.collision().index()); trackCount++; if (trackCount == 10) @@ -331,9 +344,9 @@ struct HashTask { void process(aod::Collisions const& collisions) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { int hash = getHash(xBins, yBins, collision.posX(), collision.posY()); - // LOGF(info, "Collision: %d (%f, %f, %f) hash: %d", collision.index(), collision.posX(), collision.posY(), collision.posZ(), hash); + LOGF(info, "Collision: %d (%f, %f, %f) hash: %d", collision.index(), collision.posX(), collision.posY(), collision.posZ(), hash); hashes(hash); } } @@ -341,16 +354,17 @@ struct HashTask { struct MixedEventsWithHashTask { SliceCache cache; - using myCollisions = soa::Join; + Preslice perCollision = aod::track::collisionId; + using MyCollision = soa::Join; NoBinningPolicy hashBin; - SameKindPair> pair{hashBin, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored + SameKindPair> pair{hashBin, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored - void process(myCollisions& collisions, aod::Tracks& tracks) + void process(MyCollision const& collisions, aod::Tracks const& tracks) { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); int count = 0; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex()); count++; if (count == 10) @@ -358,7 +372,7 @@ struct MixedEventsWithHashTask { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d)", t1.globalIndex(), t2.globalIndex(), c1.globalIndex(), c2.globalIndex()); trackCount++; if (trackCount == 10) @@ -370,27 +384,28 @@ struct MixedEventsWithHashTask { struct MixedEventsPartitionedTracks { SliceCache cache; + Preslice perCollision = aod::track::collisionId; Filter trackFilter = (aod::track::x > -0.8f) && (aod::track::x < 0.8f) && (aod::track::y > 1.0f); - using myTracks = soa::Filtered; + using MyTracks = soa::Filtered; - Configurable philow{"phiLow", 1.0f, "lowest phi"}; - Configurable phiup{"phiUp", 2.0f, "highest phi"}; + Configurable phiLow{"phiLow", 1.0f, "lowest phi"}; + Configurable phiUp{"phiUp", 2.0f, "highest phi"}; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; using BinningType = ColumnBinningPolicy; - BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) - SameKindPair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored + BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) + SameKindPair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored - void process(aod::Collisions const& collisions, myTracks const& tracks) + void process(aod::Collisions const& collisions, MyTracks const& tracks) { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); - for (auto& [c1, tracks1, c2, tracks2] : pair) { - Partition leftPhi1 = aod::track::phi < philow; - Partition leftPhi2 = aod::track::phi < philow; - Partition rightPhi1 = aod::track::phi >= phiup; - Partition rightPhi2 = aod::track::phi >= phiup; + for (const auto& [c1, tracks1, c2, tracks2] : pair) { + Partition leftPhi1 = aod::track::phi < phiLow; + Partition leftPhi2 = aod::track::phi < phiLow; + Partition rightPhi1 = aod::track::phi >= phiUp; + Partition rightPhi2 = aod::track::phi >= phiUp; leftPhi1.bindTable(tracks1); leftPhi2.bindTable(tracks2); rightPhi1.bindTable(tracks1); @@ -399,14 +414,14 @@ struct MixedEventsPartitionedTracks { LOGF(info, "Mixed event collisions: (%d, %d), tracks: (%d, %d), left phis: (%d, %d), right phis: (%d, %d)", c1.globalIndex(), c2.globalIndex(), tracks1.size(), tracks2.size(), leftPhi1.size(), leftPhi2.size(), rightPhi1.size(), rightPhi2.size()); // Example of using tracks from mixed events -- iterate over all track pairs from the two partitions from two collisions - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(leftPhi1, leftPhi2))) { - if (t1.phi() >= (float)philow || t2.phi() >= (float)philow) { - LOGF(info, "WRONG Mixed event left tracks pair: (%d, %d) from events (%d, %d), phi: (%.3f. %.3f) < %.3f", t1.index(), t2.index(), c1.index(), c2.index(), t1.phi(), t2.phi(), (float)philow); + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(leftPhi1, leftPhi2))) { + if (t1.phi() >= static_cast(phiLow) || t2.phi() >= static_cast(phiLow)) { + LOGF(info, "WRONG Mixed event left tracks pair: (%d, %d) from events (%d, %d), phi: (%.3f. %.3f) < %.3f", t1.index(), t2.index(), c1.index(), c2.index(), t1.phi(), t2.phi(), (float)phiLow); } } - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(rightPhi1, rightPhi2))) { - if (t1.phi() < (float)phiup || t2.phi() < (float)phiup) { - LOGF(info, "WRONG Mixed event right tracks pair: (%d, %d) from events (%d, %d), phi: (%.3f. %.3f) >= %.3f", t1.index(), t2.index(), c1.index(), c2.index(), t1.phi(), t2.phi(), (float)phiup); + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(rightPhi1, rightPhi2))) { + if (t1.phi() < static_cast(phiUp) || t2.phi() < static_cast(phiUp)) { + LOGF(info, "WRONG Mixed event right tracks pair: (%d, %d) from events (%d, %d), phi: (%.3f. %.3f) >= %.3f", t1.index(), t2.index(), c1.index(), c2.index(), t1.phi(), t2.phi(), (float)phiUp); } } } @@ -415,12 +430,12 @@ struct MixedEventsPartitionedTracks { struct MixedEventsLambdaBinning { SliceCache cache; - Preslice perCol = aod::track::collisionId; + Preslice perCollision = aod::track::collisionId; ConfigurableAxis axisVertex{"axisVertex", {14, -7, 7}, "vertex axis for histograms"}; ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0.0, 2.750, 5.250, 7.750, 12.750, 17.750, 22.750, 27.750, 32.750, 37.750, 42.750, 47.750, 52.750, 57.750, 62.750, 67.750, 72.750, 77.750, 82.750, 87.750, 92.750, 97.750, 250.1}, "multiplicity axis for histograms"}; - void process(aod::Collisions& collisions, aod::Tracks& tracks) + void process(aod::Collisions const& collisions, aod::Tracks const& tracks) { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); @@ -437,7 +452,7 @@ struct MixedEventsLambdaBinning { SameKindPair pair{binningWithLambda, 5, -1, collisions, tracksTuple, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored int count = 0; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { // NOTE that getBin() with FlexibleBinningPolicy needs explicit tuple construction int bin = binningWithLambda.getBin(std::tuple(getTracksSize(c1), c1.posZ())); @@ -448,7 +463,7 @@ struct MixedEventsLambdaBinning { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); trackCount++; if (trackCount == 10) @@ -463,6 +478,7 @@ struct MixedEventsCounters { // https://aliceo2group.github.io/analysis-framework/docs/tutorials/eventMixing.html#mixedeventscounters SliceCache cache; + Preslice perCollision = aod::track::collisionId; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; diff --git a/Tutorials/src/eventMixingValidation.cxx b/Tutorials/src/eventMixingValidation.cxx index 2db94b1d082..cc1933b0a25 100644 --- a/Tutorials/src/eventMixingValidation.cxx +++ b/Tutorials/src/eventMixingValidation.cxx @@ -9,11 +9,14 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. /// +/// \file eventMixingValidation.cxx /// \brief Validation tasks for event mixing. -/// \author +/// \author Karwowska Maja /// \since -#include +#include +#include "Framework/AnalysisDataModel.h" +#include "Framework/SliceCache.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/ASoAHelpers.h" @@ -28,22 +31,23 @@ using namespace o2::soa; struct MixedEventsEmptyTables { SliceCache cache; + Preslice perCollision = aod::track::collisionId; // Dummy filter to enforce empty tables Filter trackFilter = (aod::track::x > -0.8f) && (aod::track::x < -0.8f); - using myTracks = soa::Filtered; + using MyTracks = soa::Filtered; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; using BinningType = ColumnBinningPolicy; BinningType binningOnPositions{{xBins, yBins}, true}; // true is for 'ignore overflows' (true by default) - SameKindPair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored + SameKindPair pair{binningOnPositions, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored - void process(aod::Collisions const& collisions, myTracks const& tracks) + void process(aod::Collisions const& collisions, MyTracks const& tracks) { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); int count = 0; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex()); count++; if (count == 10) @@ -51,7 +55,7 @@ struct MixedEventsEmptyTables { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); trackCount++; if (trackCount == 10) @@ -63,6 +67,7 @@ struct MixedEventsEmptyTables { struct MixedEventsJoinedTracks { SliceCache cache; + Preslice perCollision = aod::track::collisionId; std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; using BinningType = ColumnBinningPolicy; @@ -74,7 +79,7 @@ struct MixedEventsJoinedTracks { LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size()); int count = 0; - for (auto& [c1, tracks1, c2, tracks2] : pair) { + for (const auto& [c1, tracks1, c2, tracks2] : pair) { LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex()); count++; if (count == 100) @@ -82,7 +87,7 @@ struct MixedEventsJoinedTracks { // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions int trackCount = 0; - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); trackCount++; if (trackCount == 10) @@ -94,6 +99,7 @@ struct MixedEventsJoinedTracks { // It should not compile // struct MixedEventsBadSubscription { +// Preslice perCollision = aod::track::collisionId; // std::vector xBins{VARIABLE_WIDTH, -0.064, -0.062, -0.060, 0.066, 0.068, 0.070, 0.072}; // std::vector yBins{VARIABLE_WIDTH, -0.320, -0.301, -0.300, 0.330, 0.340, 0.350, 0.360}; // using BinningType = ColumnBinningPolicy; @@ -103,7 +109,7 @@ struct MixedEventsJoinedTracks { // void process(aod::Collisions const& collisions, aod::Tracks const& tracks) // { // int count = 0; -// for (auto& [c1, tracks1, c2, tracks2] : pair) { +// for (const auto& [c1, tracks1, c2, tracks2] : pair) { // LOGF(info, "Mixed event collisions: (%d, %d)", c1.globalIndex(), c2.globalIndex()); // count++; // if (count == 10) @@ -111,7 +117,7 @@ struct MixedEventsJoinedTracks { // // // Example of using tracks from mixed events -- iterate over all track pairs from the two collisions // int trackCount = 0; -// for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { +// for (const auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d), track event: (%d, %d)", t1.index(), t2.index(), c1.index(), c2.index(), t1.collision().index(), t2.collision().index()); // trackCount++; // if (trackCount == 10) diff --git a/Tutorials/src/extendedTables.cxx b/Tutorials/src/extendedTables.cxx index ce511fbb887..643a81e1504 100644 --- a/Tutorials/src/extendedTables.cxx +++ b/Tutorials/src/extendedTables.cxx @@ -21,6 +21,7 @@ namespace o2::aod namespace extension { DECLARE_SOA_EXPRESSION_COLUMN(P2exp, p2exp, float, track::p* track::p); +DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(Cfg, cfg, float, "cfg"); DECLARE_SOA_COLUMN(mX, mx, float); DECLARE_SOA_COLUMN(mY, my, float); @@ -36,6 +37,8 @@ DECLARE_SOA_TABLE(DynTable, "AOD", "DYNTABLE", DECLARE_SOA_EXTENDED_TABLE_USER(ExTable, Tracks, "EXTABLE", extension::P2exp); +DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(CExTable, Tracks, "CTRK", + extension::Cfg); } // namespace o2::aod using namespace o2; @@ -107,6 +110,14 @@ struct ExtendAndAttach { struct SpawnDynamicColumns { Produces dyntable; Spawns extable; + Defines cextable; + + Configurable factor{"factor", 1.0f, "scale factor"}; + + void init(InitContext&) + { + cextable.projectors[0] = (float)factor * aod::track::p * aod::track::p; + } void process(aod::Tracks const& tracks) { @@ -119,7 +130,7 @@ struct SpawnDynamicColumns { // loop over the joined table struct ProcessExtendedTables { // join the table ExTable and DynTable - using allinfo = soa::Join; + using allinfo = soa::Join; void process(aod::Collision const&, allinfo const& tracks) { @@ -128,6 +139,7 @@ struct ProcessExtendedTables { if (row.trackType() != 3) { if (row.index() % 10000 == 0) { LOGF(info, "E: EXPRESSION P^2 = %.3f, DYNAMIC P^2 = %.3f R^2 = %.3f", row.p2exp(), row.p2dyn(), row.r2dyn()); + LOGF(info, "C: CONF EXPRESSION f * P^2 = %.3f", row.cfg()); } } } diff --git a/Tutorials/src/reweighting.cxx b/Tutorials/src/reweighting.cxx index 72c17a1cb29..17a4ad4bf33 100644 --- a/Tutorials/src/reweighting.cxx +++ b/Tutorials/src/reweighting.cxx @@ -28,11 +28,7 @@ // This workflow is used to create a flat tree for model training // Use o2-aod-merger to combine dataframes in output AnalysisResults_trees.root -#if __has_include() -#include -#else #include -#endif #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Common/DataModel/Multiplicity.h" @@ -82,11 +78,7 @@ struct CreateWeights { Filter centralTracks = nabs(aod::track::eta) < centralEtaCut; /// onnx runtime session handle -#if __has_include() - std::shared_ptr onnxSession = nullptr; -#else std::shared_ptr onnxSession = nullptr; -#endif /// onnx runtime session options Ort::SessionOptions sessionOptions; /// input vectore @@ -98,17 +90,11 @@ struct CreateWeights { { auto path = (std::string)onnxModel; /// create session -#if __has_include() - onnxSession = std::make_shared(env, path, sessionOptions); - /// adjust input shape to use row-by-row model application - inputShapes = onnxSession->GetInputShapes(); -#else onnxSession = std::make_shared(env, path.c_str(), sessionOptions); /// adjust input shape to use row-by-row model application for (size_t i = 0; i < onnxSession->GetInputCount(); ++i) { inputShapes.emplace_back(onnxSession->GetInputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape()); } -#endif if (inputShapes[0][0] < 0) { LOG(warning) << "Model with negative input shape, setting it to 1."; inputShapes[0][0] = 1; @@ -120,11 +106,6 @@ struct CreateWeights { /// get the input variables auto features = collect(collision, tracks); /// add an entry in input vector -#if __has_include() - inputML.push_back(Ort::Experimental::Value::CreateTensor(features.data(), features.size(), inputShapes[0])); - /// run inference - auto result = onnxSession->Run(onnxSession->GetInputNames(), inputML, onnxSession->GetOutputNames()); -#else Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault); inputML.push_back(Ort::Value::CreateTensor(mem_info, features.data(), features.size(), inputShapes[0].data(), inputShapes[0].size())); @@ -142,7 +123,6 @@ struct CreateWeights { outputNamesChar.push_back(onnxSession->GetOutputNameAllocated(i, tmpAllocator).get()); } auto result = onnxSession->Run(runOptions, inputNamesChar.data(), inputML.data(), inputML.size(), outputNamesChar.data(), outputNamesChar.size()); -#endif /// extract scores auto scores = result[1].GetTensorMutableData(); LOGP(info, "Col {}: scores ({}, {})", collision.globalIndex(), scores[0], scores[1]); diff --git a/cppcheck_config b/cppcheck_config new file mode 100644 index 00000000000..1ca9f8a8952 --- /dev/null +++ b/cppcheck_config @@ -0,0 +1,2 @@ +syntaxError +unknownMacro diff --git a/dependencies/FindKFParticle.cmake b/dependencies/FindKFParticle.cmake index 7c789c3f937..6821b601c66 100644 --- a/dependencies/FindKFParticle.cmake +++ b/dependencies/FindKFParticle.cmake @@ -17,7 +17,7 @@ #endif() find_path(KFPARTICLE_INCLUDE_DIR KFParticle.h - PATH_SUFFIXES "include" + PATH_SUFFIXES "include" "include/KFParticle" HINTS "$ENV{KFPARTICLE_ROOT}") find_library(KFPARTICLE_LIBPATH "KFParticle" PATH_SUFFIXES "lib" diff --git a/git b/git new file mode 100644 index 00000000000..e69de29bb2d